diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..e06213f0b5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,436 @@ +# The default style generated by dotnet new editorconfig, with some minor changes. +# All changes are annotated with `# not default` + +root = true + +# All files +[*] +# indent_size intentionally not specified in this section. +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +# Shell scripts +[*.sh] +end_of_line = lf +[*.{cmd,bat}] +end_of_line = crlf + +# Xml files +[*.xml] +indent_size = 2 + +# Markdown files +[*.md] +indent_size = 2 +trim_trailing_whitespace = false + +# PowerShell scripts +[*.ps1] +indent_size = 4 + +# Visual Studio XML project files +[*.{csproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] +indent_size = 2 +charset = utf-8 + +# Visual Studio and .NET related XML config files +[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] +indent_size = 2 + +# YAML files +[*.{yml,yaml}] +indent_size = 2 + +# C# files +[*.cs] + +# Do not set 'end_of_line = crlf' otherwise the rule IDE0055: Fix formatting will trigger on Linux/MAC OS. + +#### Core EditorConfig Options #### + +# Indentation and spacing +indent_size = 4 +tab_width = 4 + +# New line preferences +insert_final_newline = false + +#### .NET Coding Conventions #### + +# Organize usings +dotnet_separate_import_directive_groups = true +dotnet_sort_system_directives_first = true + +# License header +file_header_template = Copyright (c) Microsoft Corporation. All rights reserved.\nLicensed under the MIT license. See LICENSE file in the project root for full license information. + +# this. and Me. preferences +dotnet_style_qualification_for_event = false:warning # not default, default is false:silent, helped with removing this. prefixes +dotnet_style_qualification_for_field = false:warning # not default, same as above +dotnet_style_qualification_for_method = false:warning # not default, same as above +dotnet_style_qualification_for_property = false:warning # not default, same as above + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true:silent +dotnet_style_predefined_type_for_member_access = true:silent + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent + +# Expression-level preferences +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_object_initializer = false:suggestion # not default, default is true, avoided because null references in object initializers are hard to diagnose from logs +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion +dotnet_style_prefer_conditional_expression_over_return = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion + +# IDE0074: Use compound assignment +dotnet_style_prefer_compound_assignment = true:warning # not default, default is true:suggestion, increased severity to ensure it is used +dotnet_diagnostic.IDE0074.severity = warning # not default, set in accordance to previous setting + +# IDE0032: Use auto property +dotnet_style_prefer_auto_properties = true:warning # not default, default is true:suggestion, increased severity to ensure it is used +dotnet_diagnostic.IDE0032.severity = warning # not default, set in accordance to previous setting + +# Field preferences +dotnet_style_readonly_field = true:warning + +# Parameter preferences +dotnet_code_quality_unused_parameters = all:suggestion + +# Suppression preferences +dotnet_remove_unnecessary_suppression_exclusions = none + +#### C# Coding Conventions #### + +# var preferences +csharp_style_var_elsewhere = false:silent # not default, turned off for now +csharp_style_var_for_built_in_types = false:silent # not default, turned off for now +csharp_style_var_when_type_is_apparent = false:silent # not default, turned off for now + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_lambdas = true:suggestion +csharp_style_expression_bodied_local_functions = false:silent +csharp_style_expression_bodied_methods = false:silent +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_properties = true:silent + +# Pattern matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_prefer_not_pattern = true:suggestion +csharp_style_prefer_pattern_matching = true:silent +csharp_style_prefer_switch_expression = true:suggestion + +# Null-checking preferences +csharp_style_conditional_delegate_call = true:suggestion + +# Modifier preferences +csharp_prefer_static_local_function = true:warning +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent + +# Code-block preferences +csharp_prefer_braces = true:silent +csharp_prefer_simple_using_statement = true:warning # not default, default is true:suggestion, increased severity to ensure it is used +dotnet_diagnostic.IDE0063.severity = warning + +# Expression-level preferences +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_prefer_local_over_anonymous_function = false:suggestion # not default, default is true, avoided because we use anonymous functions in multiple places and it does not make the code clearer +csharp_style_prefer_index_operator = true:suggestion +csharp_style_prefer_range_operator = true:suggestion +csharp_style_throw_expression = true:suggestion +csharp_style_unused_value_assignment_preference = discard_variable:suggestion +csharp_style_unused_value_expression_statement_preference = discard_variable:silent + +# 'using' directive preferences +csharp_using_directive_placement = outside_namespace:silent +dotnet_diagnostic.IDE0065.severity = none + +# CA1822: Mark members as static +dotnet_diagnostic.CA1822.severity = suggestion # TODO: increase severity and fix related entries + +# IDE0090: Use 'new(...)' +dotnet_diagnostic.IDE0090.severity = warning # not default, increased severity to go with simpler declarations + +# IDE0005: Remove unnecessary import +dotnet_diagnostic.IDE0005.severity = warning # not default, increased severity to ensure it is used + +#### C# Formatting Rules #### + +# IDE0055: Fix formatting +dotnet_diagnostic.IDE0055.severity = warning + +# New line preferences +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Wrapping preferences +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Naming styles #### + +# not default, we have a lot of multiplatform code in compiler directives that defines methods, but keeps the bodies empty +# IDE0052: Remove unused private members +dotnet_diagnostic.IDE0051.severity = silent + +# not default, we have a lot of multiplatform code in compiler directives that defines methods, but keeps the bodies empty +# IDE0052: Remove unread private members +dotnet_diagnostic.IDE0052.severity = silent + +# IDE1006: Naming Styles +dotnet_diagnostic.IDE1006.severity = warning +dotnet_diagnostic.IDE0073.severity = warning +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_null_check_over_type_check = true:suggestion +csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion +csharp_style_prefer_tuple_swap = true:suggestion + +# Naming rules + +dotnet_style_namespace_match_folder = true:suggestion +csharp_style_namespace_declarations = file_scoped:warning # not default, default is block_scoped:silent, changed to follow modern preferences + +dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.symbols = types_and_namespaces +dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.interfaces_should_be_ipascalcase.severity = suggestion +dotnet_naming_rule.interfaces_should_be_ipascalcase.symbols = interfaces +dotnet_naming_rule.interfaces_should_be_ipascalcase.style = ipascalcase + +dotnet_naming_rule.type_parameters_should_be_tpascalcase.severity = suggestion +dotnet_naming_rule.type_parameters_should_be_tpascalcase.symbols = type_parameters +dotnet_naming_rule.type_parameters_should_be_tpascalcase.style = tpascalcase + +dotnet_naming_rule.methods_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.methods_should_be_pascalcase.symbols = methods +dotnet_naming_rule.methods_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.properties_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.properties_should_be_pascalcase.symbols = properties +dotnet_naming_rule.properties_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.events_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.events_should_be_pascalcase.symbols = events +dotnet_naming_rule.events_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.local_variables_should_be_camelcase.severity = suggestion +dotnet_naming_rule.local_variables_should_be_camelcase.symbols = local_variables +dotnet_naming_rule.local_variables_should_be_camelcase.style = camelcase + +dotnet_naming_rule.local_constants_should_be_camelcase.severity = suggestion +dotnet_naming_rule.local_constants_should_be_camelcase.symbols = local_constants +dotnet_naming_rule.local_constants_should_be_camelcase.style = camelcase + +dotnet_naming_rule.parameters_should_be_camelcase.severity = suggestion +dotnet_naming_rule.parameters_should_be_camelcase.symbols = parameters +dotnet_naming_rule.parameters_should_be_camelcase.style = camelcase + +dotnet_naming_rule.public_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.public_fields_should_be_pascalcase.symbols = public_fields +dotnet_naming_rule.public_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.private_fields_should_be__camelcase.severity = suggestion +dotnet_naming_rule.private_fields_should_be__camelcase.symbols = private_fields +dotnet_naming_rule.private_fields_should_be__camelcase.style = _camelcase + +dotnet_naming_rule.private_static_fields_should_be_s_camelcase.severity = suggestion +dotnet_naming_rule.private_static_fields_should_be_s_camelcase.symbols = private_static_fields +dotnet_naming_rule.private_static_fields_should_be_s_camelcase.style = s_camelcase + +dotnet_naming_rule.public_constant_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.public_constant_fields_should_be_pascalcase.symbols = public_constant_fields +dotnet_naming_rule.public_constant_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.private_constant_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.private_constant_fields_should_be_pascalcase.symbols = private_constant_fields +dotnet_naming_rule.private_constant_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.symbols = public_static_readonly_fields +dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.symbols = private_static_readonly_fields +dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.enums_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.enums_should_be_pascalcase.symbols = enums +dotnet_naming_rule.enums_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.local_functions_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.local_functions_should_be_pascalcase.symbols = local_functions +dotnet_naming_rule.local_functions_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.non_field_members_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascalcase.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascalcase.style = pascalcase + +# Symbol specifications + +dotnet_naming_symbols.interfaces.applicable_kinds = interface +dotnet_naming_symbols.interfaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interfaces.required_modifiers = + +dotnet_naming_symbols.enums.applicable_kinds = enum +dotnet_naming_symbols.enums.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.enums.required_modifiers = + +dotnet_naming_symbols.events.applicable_kinds = event +dotnet_naming_symbols.events.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.events.required_modifiers = + +dotnet_naming_symbols.methods.applicable_kinds = method +dotnet_naming_symbols.methods.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.methods.required_modifiers = + +dotnet_naming_symbols.properties.applicable_kinds = property +dotnet_naming_symbols.properties.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.properties.required_modifiers = + +dotnet_naming_symbols.public_fields.applicable_kinds = field +dotnet_naming_symbols.public_fields.applicable_accessibilities = public, internal +dotnet_naming_symbols.public_fields.required_modifiers = + +dotnet_naming_symbols.private_fields.applicable_kinds = field +dotnet_naming_symbols.private_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_fields.required_modifiers = + +dotnet_naming_symbols.private_static_fields.applicable_kinds = field +dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_static_fields.required_modifiers = static + +dotnet_naming_symbols.types_and_namespaces.applicable_kinds = namespace, class, struct, interface, enum +dotnet_naming_symbols.types_and_namespaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types_and_namespaces.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +dotnet_naming_symbols.type_parameters.applicable_kinds = namespace +dotnet_naming_symbols.type_parameters.applicable_accessibilities = * +dotnet_naming_symbols.type_parameters.required_modifiers = + +dotnet_naming_symbols.private_constant_fields.applicable_kinds = field +dotnet_naming_symbols.private_constant_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_constant_fields.required_modifiers = const + +dotnet_naming_symbols.local_variables.applicable_kinds = local +dotnet_naming_symbols.local_variables.applicable_accessibilities = local +dotnet_naming_symbols.local_variables.required_modifiers = + +dotnet_naming_symbols.local_constants.applicable_kinds = local +dotnet_naming_symbols.local_constants.applicable_accessibilities = local +dotnet_naming_symbols.local_constants.required_modifiers = const + +dotnet_naming_symbols.parameters.applicable_kinds = parameter +dotnet_naming_symbols.parameters.applicable_accessibilities = * +dotnet_naming_symbols.parameters.required_modifiers = + +dotnet_naming_symbols.public_constant_fields.applicable_kinds = field +dotnet_naming_symbols.public_constant_fields.applicable_accessibilities = public, internal +dotnet_naming_symbols.public_constant_fields.required_modifiers = const + +dotnet_naming_symbols.public_static_readonly_fields.applicable_kinds = field +dotnet_naming_symbols.public_static_readonly_fields.applicable_accessibilities = public, internal +dotnet_naming_symbols.public_static_readonly_fields.required_modifiers = readonly, static + +dotnet_naming_symbols.private_static_readonly_fields.applicable_kinds = field +dotnet_naming_symbols.private_static_readonly_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_static_readonly_fields.required_modifiers = readonly, static + +dotnet_naming_symbols.local_functions.applicable_kinds = local_function +dotnet_naming_symbols.local_functions.applicable_accessibilities = * +dotnet_naming_symbols.local_functions.required_modifiers = + +# Naming styles + +dotnet_naming_style.pascalcase.required_prefix = +dotnet_naming_style.pascalcase.required_suffix = +dotnet_naming_style.pascalcase.word_separator = +dotnet_naming_style.pascalcase.capitalization = pascal_case + +dotnet_naming_style.ipascalcase.required_prefix = I +dotnet_naming_style.ipascalcase.required_suffix = +dotnet_naming_style.ipascalcase.word_separator = +dotnet_naming_style.ipascalcase.capitalization = pascal_case + +dotnet_naming_style.tpascalcase.required_prefix = T +dotnet_naming_style.tpascalcase.required_suffix = +dotnet_naming_style.tpascalcase.word_separator = +dotnet_naming_style.tpascalcase.capitalization = pascal_case + +dotnet_naming_style._camelcase.required_prefix = _ +dotnet_naming_style._camelcase.required_suffix = +dotnet_naming_style._camelcase.word_separator = +dotnet_naming_style._camelcase.capitalization = camel_case + +dotnet_naming_style.camelcase.required_prefix = +dotnet_naming_style.camelcase.required_suffix = +dotnet_naming_style.camelcase.word_separator = +dotnet_naming_style.camelcase.capitalization = camel_case + +dotnet_naming_style.s_camelcase.required_prefix = s_ +dotnet_naming_style.s_camelcase.required_suffix = +dotnet_naming_style.s_camelcase.word_separator = +dotnet_naming_style.s_camelcase.capitalization = camel_case diff --git a/TestPlatform.sln b/TestPlatform.sln index f7e9b97ff0..61c4c661c9 100644 --- a/TestPlatform.sln +++ b/TestPlatform.sln @@ -97,6 +97,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{EE49 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E344E0A2-7715-4C7F-BAF7-D64EA94CB19B}" ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig Nuget.config = Nuget.config EndProjectSection EndProject diff --git a/eng/Versions.props b/eng/Versions.props index e3c179fae5..15755f607b 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -33,7 +33,7 @@ 2.1.0 4.1.0-1.21507.14 15.7.2 - 4.8.3 + 4.16.1 5.3.0.1 2.3.0 9.0.1 diff --git a/playground/MSTest1/UnitTest1.cs b/playground/MSTest1/UnitTest1.cs index a3303b5a99..9b925d47ee 100644 --- a/playground/MSTest1/UnitTest1.cs +++ b/playground/MSTest1/UnitTest1.cs @@ -1,13 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace MSTest1 +namespace MSTest1; + +[TestClass] +public class UnitTest1 { - [TestClass] - public class UnitTest1 + [TestMethod] + public void TestMethod1() { - [TestMethod] - public void TestMethod1() - { - } } -} +} \ No newline at end of file diff --git a/playground/TestPlatform.Playground/Program.cs b/playground/TestPlatform.Playground/Program.cs index 37be2f96c3..edd8b95e21 100644 --- a/playground/TestPlatform.Playground/Program.cs +++ b/playground/TestPlatform.Playground/Program.cs @@ -1,8 +1,12 @@ -using Microsoft.TestPlatform.VsTestConsole.TranslationLayer; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.TestPlatform.VsTestConsole.TranslationLayer; using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + using System; using System.Collections.Generic; using System.Diagnostics; @@ -11,123 +15,116 @@ using System.Reflection; using System.Threading; -namespace TestPlatform.Playground +namespace TestPlatform.Playground; + +internal class Program { - internal class Program + static void Main(string[] args) { - static void Main(string[] args) + // This project references TranslationLayer, vstest.console, TestHostProvider, testhost and MSTest1 projects, to make sure + // we build all the dependencies of that are used to run tests via VSTestConsoleWrapper. It then copies the components from + // their original build locations, to $(TargetDir)\vstest.console directory, and it's subfolders to create an executable + // copy of TestPlatform that is similar to what we ship. + // + // The copying might trigger only on re-build, if you see outdated dependencies, Rebuild this project instead of just Build. + // + // Use this as playground for your debugging of end-to-end scenarios, it will automatically attach vstest.console and teshost + // sub-processes. It won't stop at entry-point automatically, don't forget to set your breakpoints, or remove VSTEST_DEBUG_NOBP + // from the environment variables of this project. + + var thisAssemblyPath = Assembly.GetEntryAssembly().Location; + var here = Path.GetDirectoryName(thisAssemblyPath); + var playground = Path.GetFullPath(Path.Combine(here, "..", "..", "..", "..")); + + var console = Path.Combine(here, "vstest.console", "vstest.console.exe"); + var consoleOptions = new ConsoleParameters { - // This project references TranslationLayer, vstest.console, TestHostProvider, testhost and MSTest1 projects, to make sure - // we build all the dependencies of that are used to run tests via VSTestConsoleWrapper. It then copies the components from - // their original build locations, to $(TargetDir)\vstest.console directory, and it's subfolders to create an executable - // copy of TestPlatform that is similar to what we ship. - // - // The copying might trigger only on re-build, if you see outdated dependencies, Rebuild this project instead of just Build. - // - // Use this as playground for your debugging of end-to-end scenarios, it will automatically attach vstest.console and teshost - // sub-processes. It won't stop at entry-point automatically, don't forget to set your breakpoints, or remove VSTEST_DEBUG_NOBP - // from the environment variables of this project. - - var thisAssemblyPath = Assembly.GetEntryAssembly().Location; - var here = Path.GetDirectoryName(thisAssemblyPath); - var playground = Path.GetFullPath(Path.Combine(here, "..", "..", "..", "..")); - - var console = Path.Combine(here, "vstest.console", "vstest.console.exe"); - var consoleOptions = new ConsoleParameters - { - LogFilePath = Path.Combine(here, "logs", "log.txt"), - TraceLevel = TraceLevel.Verbose, - }; - - var r = new VsTestConsoleWrapper(console, consoleOptions); - - var sourceSettings = @" + LogFilePath = Path.Combine(here, "logs", "log.txt"), + TraceLevel = TraceLevel.Verbose, + }; + + var r = new VsTestConsoleWrapper(console, consoleOptions); + + var sourceSettings = @" true "; - var sources = new[] { - Path.Combine(playground, "MSTest1", "bin", "Debug", "net472", "MSTest1.dll") - }; + var sources = new[] { + Path.Combine(playground, "MSTest1", "bin", "Debug", "net472", "MSTest1.dll") + }; + + var options = new TestPlatformOptions(); + r.RunTestsWithCustomTestHost(sources, sourceSettings, options, new TestRunHandler(), new DebuggerTestHostLauncher()); + } + + public class TestRunHandler : ITestRunEventsHandler + { + + public TestRunHandler() + { + } + + public void HandleLogMessage(TestMessageLevel level, string message) + { + Console.WriteLine($"[{level.ToString().ToUpper()}]: {message}"); + } - var options = new TestPlatformOptions(); - r.RunTestsWithCustomTestHost(sources, sourceSettings, options, new TestRunHandler(), new DebuggerTestHostLauncher()); + public void HandleRawMessage(string rawMessage) + { + Console.WriteLine($"[MESSAGE]: { rawMessage}"); } - public class TestRunHandler : ITestRunEventsHandler + public void HandleTestRunComplete(TestRunCompleteEventArgs testRunCompleteArgs, TestRunChangedEventArgs lastChunkArgs, ICollection runContextAttachments, ICollection executorUris) { + Console.WriteLine($"[COMPLETE]: err: { testRunCompleteArgs.Error }, lastChunk: {WriteTests(lastChunkArgs?.NewTestResults)}"); + } + + public void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChangedArgs) + { + Console.WriteLine($"[PROGRESS - NEW RESULTS]: {WriteTests(testRunChangedArgs.NewTestResults)}"); + } - public TestRunHandler() - { - } - - public void HandleLogMessage(TestMessageLevel level, string message) - { - Console.WriteLine($"[{level.ToString().ToUpper()}]: {message}"); - } - - public void HandleRawMessage(string rawMessage) - { - Console.WriteLine($"[MESSAGE]: { rawMessage}"); - } - - public void HandleTestRunComplete(TestRunCompleteEventArgs testRunCompleteArgs, TestRunChangedEventArgs lastChunkArgs, ICollection runContextAttachments, ICollection executorUris) - { - Console.WriteLine($"[COMPLETE]: err: { testRunCompleteArgs.Error }, lastChunk: {WriteTests(lastChunkArgs?.NewTestResults)}"); - } - - public void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChangedArgs) - { - Console.WriteLine($"[PROGRESS - NEW RESULTS]: {WriteTests(testRunChangedArgs.NewTestResults)}"); - } - - public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) - { - throw new NotImplementedException(); - } - - private string WriteTests(IEnumerable testResults) - { - return WriteTests(testResults?.Select(t => t.TestCase)); - } - - private string WriteTests(IEnumerable testCases) - { - if (testCases == null) - { - return null; - } - - return "\t" + string.Join("\n\t", testCases.Select(r => r.DisplayName)); - - } + public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) + { + throw new NotImplementedException(); + } + + private string WriteTests(IEnumerable testResults) + { + return WriteTests(testResults?.Select(t => t.TestCase)); + } + + private string WriteTests(IEnumerable testCases) + { + return testCases == null ? null : "\t" + string.Join("\n\t", testCases.Select(r => r.DisplayName)); + } + } + + internal class DebuggerTestHostLauncher : ITestHostLauncher2 + { + public bool IsDebug => true; + + public bool AttachDebuggerToProcess(int pid) + { + return true; + } + + public bool AttachDebuggerToProcess(int pid, CancellationToken cancellationToken) + { + return true; + } + + public int LaunchTestHost(TestProcessStartInfo defaultTestHostStartInfo) + { + return 1; } - internal class DebuggerTestHostLauncher : ITestHostLauncher2 + public int LaunchTestHost(TestProcessStartInfo defaultTestHostStartInfo, CancellationToken cancellationToken) { - public bool IsDebug => true; - - public bool AttachDebuggerToProcess(int pid) - { - return true; - } - - public bool AttachDebuggerToProcess(int pid, CancellationToken cancellationToken) - { - return true; - } - - public int LaunchTestHost(TestProcessStartInfo defaultTestHostStartInfo) - { - return 1; - } - - public int LaunchTestHost(TestProcessStartInfo defaultTestHostStartInfo, CancellationToken cancellationToken) - { - return 1; - } + return 1; } } -} +} \ No newline at end of file diff --git a/scripts/build/ExternalAssemblyVersions.cs b/scripts/build/ExternalAssemblyVersions.cs index cfaa81efa9..6245a3ea3a 100644 --- a/scripts/build/ExternalAssemblyVersions.cs +++ b/scripts/build/ExternalAssemblyVersions.cs @@ -1,12 +1,14 @@ -namespace Microsoft.VisualStudio.TestPlatform +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.VisualStudio.TestPlatform; + +internal class ExternalAssemblyVersions { - internal class ExternalAssemblyVersions - { - /// - /// Refers to the versions of the assemblies retrieved from the - /// Microsoft.QualityTools.Testing.Fakes.TestRunnerHarness package. - /// The Package version can be found in "scripts\build\TestPlatform.Dependencies.props" - /// - internal const string MicrosoftFakesAssemblyVersion = "17.0.0.0"; - } + /// + /// Refers to the versions of the assemblies retrieved from the + /// Microsoft.QualityTools.Testing.Fakes.TestRunnerHarness package. + /// The Package version can be found in "scripts\build\TestPlatform.Dependencies.props" + /// + internal const string MicrosoftFakesAssemblyVersion = "17.0.0.0"; } \ No newline at end of file diff --git a/scripts/build/TestPlatform.Dependencies.props b/scripts/build/TestPlatform.Dependencies.props index 5190258c1c..8f5fa9f8a4 100644 --- a/scripts/build/TestPlatform.Dependencies.props +++ b/scripts/build/TestPlatform.Dependencies.props @@ -31,7 +31,6 @@ 5.11.0 5.0.0 9.0.1 - 4.8.3 17.1.0-preview-2-31925-026 diff --git a/scripts/build/TestPlatform.Settings.targets b/scripts/build/TestPlatform.Settings.targets index 2a6a9b71bd..28e6a3ca99 100644 --- a/scripts/build/TestPlatform.Settings.targets +++ b/scripts/build/TestPlatform.Settings.targets @@ -7,6 +7,9 @@ readable when we read the file as xml, don't move it to a .props file, unless you change the build server process --> 17.2.0 preview + true + preview + true - - - - stylecop.json - - - - - - 1.0.1 - All - - - diff --git a/src/AttachVS/AttachVs.cs b/src/AttachVS/AttachVs.cs index b4f4c3da53..2c47192174 100644 --- a/src/AttachVS/AttachVs.cs +++ b/src/AttachVS/AttachVs.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; using System.Diagnostics; using System.Linq; using System.Reflection; @@ -7,291 +10,289 @@ using System.Runtime.InteropServices.ComTypes; using System.Threading; -namespace Microsoft.TestPlatform.AttachVS +namespace Microsoft.TestPlatform.AttachVS; + +internal class DebuggerUtility { - internal class DebuggerUtility + internal static bool AttachVSToProcess(int? pid, int? vsPid) { - internal static bool AttachVSToProcess(int? pid, int? vsPid) + try { - try + if (pid == null) { - if (pid == null) - { - Trace($"FAIL: Pid is null."); - return false; - } - var process = Process.GetProcessById(pid.Value); - Trace($"Starting with pid '{pid}({process?.ProcessName})', and vsPid '{vsPid}'"); - Trace($"Using pid: {pid} to get parent VS."); - var vs = GetVsFromPid(Process.GetProcessById(vsPid ?? process.Id)); + Trace($"FAIL: Pid is null."); + return false; + } + var process = Process.GetProcessById(pid.Value); + Trace($"Starting with pid '{pid}({process?.ProcessName})', and vsPid '{vsPid}'"); + Trace($"Using pid: {pid} to get parent VS."); + var vs = GetVsFromPid(Process.GetProcessById(vsPid ?? process.Id)); - if (vs != null) - { - Trace($"Parent VS is {vs.ProcessName} ({vs.Id})."); - AttachTo(process, vs); - } - else + if (vs != null) + { + Trace($"Parent VS is {vs.ProcessName} ({vs.Id})."); + AttachTo(process, vs); + } + else + { + Trace($"Parent VS not found, finding the first VS that started."); + var processes = Process.GetProcesses().Where(p => p.ProcessName == "devenv").Select(p => { - Trace($"Parent VS not found, finding the first VS that started."); - var processes = Process.GetProcesses().Where(p => p.ProcessName == "devenv").Select(p => + try { - try - { - return new { Process = p, StartTime = p.StartTime, HasExited = p.HasExited }; - } - catch - { - return null; - } - }).Where(p => p != null && !p.HasExited).OrderBy(p => p.StartTime).ToList(); + return new { Process = p, p.StartTime, p.HasExited }; + } + catch + { + return null; + } + }).Where(p => p != null && !p.HasExited).OrderBy(p => p.StartTime).ToList(); - var firstVs = processes.FirstOrDefault(); - Trace($"Found VS {firstVs.Process.Id}"); - AttachTo(process, firstVs.Process); - } - return true; - } - catch (Exception ex) - { - Trace($"ERROR: {ex}, {ex.StackTrace}"); - return false; + var firstVs = processes.FirstOrDefault(); + Trace($"Found VS {firstVs.Process.Id}"); + AttachTo(process, firstVs.Process); } + return true; + } + catch (Exception ex) + { + Trace($"ERROR: {ex}, {ex.StackTrace}"); + return false; } + } + + private static void AttachTo(Process process, Process vs) + { + var attached = AttachVs(vs, process.Id); + if (attached) + { + // You won't see this in DebugView++ because at this point VS is already attached and all the output goes into Debug window in VS. + Trace($"SUCCESS: Attached process: {process.ProcessName} ({process.Id})"); + } + else + { + Trace($"FAIL: Could not attach process: {process.ProcessName} ({process.Id})"); + } + } - private static void AttachTo(Process process, Process vs) + private static bool AttachVs(Process vs, int pid) + { + IBindCtx bindCtx = null; + IRunningObjectTable runninObjectTable = null; + IEnumMoniker enumMoniker = null; + try { - var attached = AttachVs(vs, process.Id); - if (attached) + var r = CreateBindCtx(0, out bindCtx); + Marshal.ThrowExceptionForHR(r); + if (bindCtx == null) { - // You won't see this in DebugView++ because at this point VS is already attached and all the output goes into Debug window in VS. - Trace($"SUCCESS: Attached process: {process.ProcessName} ({process.Id})"); + Trace($"BindCtx is null. Cannot attach VS."); + return false; } - else + bindCtx.GetRunningObjectTable(out runninObjectTable); + if (runninObjectTable == null) { - Trace($"FAIL: Could not attach process: {process.ProcessName} ({process.Id})"); + Trace($"RunningObjectTable is null. Cannot attach VS."); + return false; } - } - private static bool AttachVs(Process vs, int pid) - { - IBindCtx bindCtx = null; - IRunningObjectTable runninObjectTable = null; - IEnumMoniker enumMoniker = null; - try + runninObjectTable.EnumRunning(out enumMoniker); + if (enumMoniker == null) { - var r = CreateBindCtx(0, out bindCtx); - Marshal.ThrowExceptionForHR(r); - if (bindCtx == null) - { - Trace($"BindCtx is null. Cannot attach VS."); - return false; - } - bindCtx.GetRunningObjectTable(out runninObjectTable); - if (runninObjectTable == null) - { - Trace($"RunningObjectTable is null. Cannot attach VS."); - return false; - } + Trace($"EnumMoniker is null. Cannot attach VS."); + return false; + } - runninObjectTable.EnumRunning(out enumMoniker); - if (enumMoniker == null) - { - Trace($"EnumMoniker is null. Cannot attach VS."); - return false; - } + var dteSuffix = ":" + vs.Id; - var dteSuffix = ":" + vs.Id; + var moniker = new IMoniker[1]; + while (enumMoniker.Next(1, moniker, IntPtr.Zero) == 0 && moniker[0] != null) + { - var moniker = new IMoniker[1]; - while (enumMoniker.Next(1, moniker, IntPtr.Zero) == 0 && moniker[0] != null) - { - string dn; + moniker[0].GetDisplayName(bindCtx, null, out string dn); - moniker[0].GetDisplayName(bindCtx, null, out dn); + if (dn.StartsWith("!VisualStudio.DTE.") && dn.EndsWith(dteSuffix)) + { + object dbg, lps; + runninObjectTable.GetObject(moniker[0], out object dte); - if (dn.StartsWith("!VisualStudio.DTE.") && dn.EndsWith(dteSuffix)) + // The COM object can be busy, we retry few times, hoping that it won't be busy next time. + for (var i = 0; i < 10; i++) { - object dte, dbg, lps; - runninObjectTable.GetObject(moniker[0], out dte); - - // The COM object can be busy, we retry few times, hoping that it won't be busy next time. - for (var i = 0; i < 10; i++) + try { - try + dbg = dte.GetType().InvokeMember("Debugger", BindingFlags.GetProperty, null, dte, null); + lps = dbg.GetType().InvokeMember("LocalProcesses", BindingFlags.GetProperty, null, dbg, null); + var lpn = (System.Collections.IEnumerator)lps.GetType().InvokeMember("GetEnumerator", BindingFlags.InvokeMethod, null, lps, null); + + while (lpn.MoveNext()) { - dbg = dte.GetType().InvokeMember("Debugger", BindingFlags.GetProperty, null, dte, null); - lps = dbg.GetType().InvokeMember("LocalProcesses", BindingFlags.GetProperty, null, dbg, null); - var lpn = (System.Collections.IEnumerator)lps.GetType().InvokeMember("GetEnumerator", BindingFlags.InvokeMethod, null, lps, null); + var pn = Convert.ToInt32(lpn.Current.GetType().InvokeMember("ProcessID", BindingFlags.GetProperty, null, lpn.Current, null)); - while (lpn.MoveNext()) + if (pn == pid) { - var pn = Convert.ToInt32(lpn.Current.GetType().InvokeMember("ProcessID", BindingFlags.GetProperty, null, lpn.Current, null)); - - if (pn == pid) - { - lpn.Current.GetType().InvokeMember("Attach", BindingFlags.InvokeMethod, null, lpn.Current, null); - return true; - } + lpn.Current.GetType().InvokeMember("Attach", BindingFlags.InvokeMethod, null, lpn.Current, null); + return true; } } - catch (COMException ex) - { - Trace($"ComException: Retrying in 250ms.\n{ex}"); - Thread.Sleep(250); - } } - Marshal.ReleaseComObject(moniker[0]); - - break; + catch (COMException ex) + { + Trace($"ComException: Retrying in 250ms.\n{ex}"); + Thread.Sleep(250); + } } - Marshal.ReleaseComObject(moniker[0]); + + break; } - return false; + + Marshal.ReleaseComObject(moniker[0]); } - finally + return false; + } + finally + { + if (enumMoniker != null) { - if (enumMoniker != null) + try { - try - { - Marshal.ReleaseComObject(enumMoniker); - } - catch { } + Marshal.ReleaseComObject(enumMoniker); } - if (runninObjectTable != null) + catch { } + } + if (runninObjectTable != null) + { + try { - try - { - Marshal.ReleaseComObject(runninObjectTable); - } - catch { } + Marshal.ReleaseComObject(runninObjectTable); } - if (bindCtx != null) + catch { } + } + if (bindCtx != null) + { + try { - try - { - Marshal.ReleaseComObject(bindCtx); - } - catch { } + Marshal.ReleaseComObject(bindCtx); } + catch { } } } + } - private static Process GetVsFromPid(Process process) + private static Process GetVsFromPid(Process process) + { + var parent = process; + while (!IsVsOrNull(parent)) { - var parent = process; - while (!IsVsOrNull(parent)) - { - parent = GetParentProcess(parent); - } + parent = GetParentProcess(parent); + } + + return parent; + } - return parent; + private static bool IsVsOrNull(Process process) + { + if (process == null) + { + Trace("Parent process is null.."); + return true; } - private static bool IsVsOrNull(Process process) + var isVs = process.ProcessName.Equals("devenv", StringComparison.InvariantCultureIgnoreCase); + if (isVs) { - if (process == null) - { - Trace("Parent process is null.."); - return true; - } + Trace($"Process {process.ProcessName} ({process.Id}) is VS."); + } + else + { + Trace($"Process {process.ProcessName} ({process.Id}) is not VS."); + } - var isVs = process.ProcessName.Equals("devenv", StringComparison.InvariantCultureIgnoreCase); - if (isVs) - { - Trace($"Process {process.ProcessName} ({process.Id}) is VS."); - } - else + return isVs; + } + + private static bool IsCorrectParent(Process currentProcess, Process parent) + { + try + { + // Parent needs to start before the child, otherwise it might be a different process + // that is just reusing the same PID. + if (parent.StartTime <= currentProcess.StartTime) { - Trace($"Process {process.ProcessName} ({process.Id}) is not VS."); + return true; } - return isVs; + Trace($"Process {parent.ProcessName} ({parent.Id}) is not a valid parent because it started after the current process."); + return false; + } + catch + { + // Access denied or process exited while we were holding the Process object. + return false; } + } - private static bool IsCorrectParent(Process currentProcess, Process parent) + private static Process GetParentProcess(Process process) + { + int id; + try { - try - { - // Parent needs to start before the child, otherwise it might be a different process - // that is just reusing the same PID. - if (parent.StartTime <= currentProcess.StartTime) - { - return true; - } + var handle = process.Handle; + var res = NtQueryInformationProcess(handle, 0, out var pbi, Marshal.SizeOf(), out int size); - Trace($"Process {parent.ProcessName} ({parent.Id}) is not a valid parent because it started after the current process."); - return false; - } - catch - { - // Access denied or process exited while we were holding the Process object. - return false; - } + var p = res != 0 ? -1 : pbi.InheritedFromUniqueProcessId.ToInt32(); + + id = p; + } + catch + { + id = -1; } - private static Process GetParentProcess(Process process) + Process parent = null; + if (id != -1) { - var id = -1; try { - var handle = process.Handle; - var res = NtQueryInformationProcess(handle, 0, out var pbi, Marshal.SizeOf(), out int size); - - var p = res != 0 ? -1 : pbi.InheritedFromUniqueProcessId.ToInt32(); - - id = p; + parent = Process.GetProcessById(id); } catch { - id = -1; + // throws when parent no longer runs } - - Process parent = null; - if (id != -1) - { - try - { - parent = Process.GetProcessById(id); - } - catch - { - // throws when parent no longer runs - } - } - - return IsCorrectParent(process, parent) ? parent : null; } - private static void Trace(string message, [CallerMemberName] string methodName = null) - { - System.Diagnostics.Trace.WriteLine($"[AttachVS]{methodName}: {message}"); - } + return IsCorrectParent(process, parent) ? parent : null; + } - [StructLayout(LayoutKind.Sequential)] - private struct PROCESS_BASIC_INFORMATION - { - public IntPtr ExitStatus; - public IntPtr PebBaseAddress; - public IntPtr AffinityMask; - public IntPtr BasePriority; - public IntPtr UniqueProcessId; - public IntPtr InheritedFromUniqueProcessId; - } + private static void Trace(string message, [CallerMemberName] string methodName = null) + { + System.Diagnostics.Trace.WriteLine($"[AttachVS]{methodName}: {message}"); + } - [DllImport("ntdll.dll", SetLastError = true)] - private static extern int NtQueryInformationProcess( - IntPtr processHandle, - int processInformationClass, - out PROCESS_BASIC_INFORMATION processInformation, - int processInformationLength, - out int returnLength); + [StructLayout(LayoutKind.Sequential)] + private struct PROCESS_BASIC_INFORMATION + { + public readonly IntPtr ExitStatus; + public readonly IntPtr PebBaseAddress; + public readonly IntPtr AffinityMask; + public readonly IntPtr BasePriority; + public readonly IntPtr UniqueProcessId; + public IntPtr InheritedFromUniqueProcessId; + } - [DllImport("Kernel32")] - private static extern uint GetTickCount(); + [DllImport("ntdll.dll", SetLastError = true)] + private static extern int NtQueryInformationProcess( + IntPtr processHandle, + int processInformationClass, + out PROCESS_BASIC_INFORMATION processInformation, + int processInformationLength, + out int returnLength); - [DllImport("ole32.dll")] - private static extern int CreateBindCtx(uint reserved, out IBindCtx ppbc); - } -} + [DllImport("Kernel32")] + private static extern uint GetTickCount(); + + [DllImport("ole32.dll")] + private static extern int CreateBindCtx(uint reserved, out IBindCtx ppbc); +} \ No newline at end of file diff --git a/src/AttachVS/Program.cs b/src/AttachVS/Program.cs index da7c26c1d4..c7c85e4f96 100644 --- a/src/AttachVS/Program.cs +++ b/src/AttachVS/Program.cs @@ -1,31 +1,33 @@ -using System; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; using System.Diagnostics; using System.Linq; -namespace Microsoft.TestPlatform.AttachVS +namespace Microsoft.TestPlatform.AttachVS; + +internal class Program { - internal class Program + static void Main(string[] args) { - static void Main(string[] args) - { - Trace.Listeners.Add(new ConsoleTraceListener()); + Trace.Listeners.Add(new ConsoleTraceListener()); - int? pid = ParsePid(args, position: 0); - int? vsPid = ParsePid(args, position: 1); + int? pid = ParsePid(args, position: 0); + int? vsPid = ParsePid(args, position: 1); - var exitCode = DebuggerUtility.AttachVSToProcess(pid, vsPid) ? 0 : 1; - Environment.Exit(exitCode); - } + var exitCode = DebuggerUtility.AttachVSToProcess(pid, vsPid) ? 0 : 1; + Environment.Exit(exitCode); + } - private static int? ParsePid(string[] args, int position) - { - var id = args.Skip(position).Take(1).SingleOrDefault(); - int? pid = id == null - ? null - : int.TryParse(id, out var i) - ? i - : null; - return pid; - } + private static int? ParsePid(string[] args, int position) + { + var id = args.Skip(position).Take(1).SingleOrDefault(); + int? pid = id == null + ? null + : int.TryParse(id, out var i) + ? i + : null; + return pid; } -} +} \ No newline at end of file diff --git a/src/DataCollectors/DumpMinitool/Program.cs b/src/DataCollectors/DumpMinitool/Program.cs index 815cf6bfa9..99f2d0e18c 100644 --- a/src/DataCollectors/DumpMinitool/Program.cs +++ b/src/DataCollectors/DumpMinitool/Program.cs @@ -1,173 +1,174 @@ -using Microsoft.Win32.SafeHandles; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.Win32.SafeHandles; + using System; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Runtime.InteropServices; using System.Threading; -namespace DumpMinitool +namespace DumpMinitool; + +internal class Program { - internal class Program + static int Main(string[] args) { - static int Main(string[] args) + DebuggerBreakpoint.WaitForDebugger("VSTEST_DUMPTOOL_DEBUG"); + Console.WriteLine($"Dump minitool: Started with arguments {string.Join(" ", args)}"); + if (args?.Length != 6) { - DebuggerBreakpoint.WaitForDebugger("VSTEST_DUMPTOOL_DEBUG"); - Console.WriteLine($"Dump minitool: Started with arguments {string.Join(" ", args)}"); - if (args?.Length != 6) - { - Console.WriteLine($"There were { args?.Length ?? 0 } parameters. Provide exactly 6 parameters: --file --processId --dumpType "); - return 2; - } + Console.WriteLine($"There were { args?.Length ?? 0 } parameters. Provide exactly 6 parameters: --file --processId --dumpType "); + return 2; + } - var outputFile = args[1]; - var processId = int.Parse(args[3]); - var type = Enum.Parse(typeof(DumpTypeOption), args[5]); + var outputFile = args[1]; + var processId = int.Parse(args[3]); + var type = Enum.Parse(typeof(DumpTypeOption), args[5]); - Console.WriteLine($"Output file: '{outputFile}'"); - Console.WriteLine($"Process id: {processId}"); - Console.WriteLine($"Dump type: {type}"); + Console.WriteLine($"Output file: '{outputFile}'"); + Console.WriteLine($"Process id: {processId}"); + Console.WriteLine($"Dump type: {type}"); - var process = Process.GetProcessById(processId); + var process = Process.GetProcessById(processId); - using (var stream = new FileStream(outputFile, FileMode.Create, FileAccess.ReadWrite, FileShare.None)) - { - NativeMethods.MINIDUMP_EXCEPTION_INFORMATION exceptionInfo = default; + using var stream = new FileStream(outputFile, FileMode.Create, FileAccess.ReadWrite, FileShare.None); + NativeMethods.MINIDUMP_EXCEPTION_INFORMATION exceptionInfo = default; - NativeMethods.MINIDUMP_TYPE dumpType = NativeMethods.MINIDUMP_TYPE.MiniDumpNormal; - switch (type) + NativeMethods.MINIDUMP_TYPE dumpType = NativeMethods.MINIDUMP_TYPE.MiniDumpNormal; + switch (type) + { + case DumpTypeOption.Full: + dumpType = NativeMethods.MINIDUMP_TYPE.MiniDumpWithFullMemory | + NativeMethods.MINIDUMP_TYPE.MiniDumpWithDataSegs | + NativeMethods.MINIDUMP_TYPE.MiniDumpWithHandleData | + NativeMethods.MINIDUMP_TYPE.MiniDumpWithUnloadedModules | + NativeMethods.MINIDUMP_TYPE.MiniDumpWithFullMemoryInfo | + NativeMethods.MINIDUMP_TYPE.MiniDumpWithThreadInfo | + NativeMethods.MINIDUMP_TYPE.MiniDumpWithTokenInformation; + break; + case DumpTypeOption.WithHeap: + dumpType = NativeMethods.MINIDUMP_TYPE.MiniDumpWithPrivateReadWriteMemory | + NativeMethods.MINIDUMP_TYPE.MiniDumpWithDataSegs | + NativeMethods.MINIDUMP_TYPE.MiniDumpWithHandleData | + NativeMethods.MINIDUMP_TYPE.MiniDumpWithUnloadedModules | + NativeMethods.MINIDUMP_TYPE.MiniDumpWithFullMemoryInfo | + NativeMethods.MINIDUMP_TYPE.MiniDumpWithThreadInfo | + NativeMethods.MINIDUMP_TYPE.MiniDumpWithTokenInformation; + break; + case DumpTypeOption.Mini: + dumpType = NativeMethods.MINIDUMP_TYPE.MiniDumpWithThreadInfo; + break; + } + + // Retry the write dump on ERROR_PARTIAL_COPY + for (int i = 0; i < 5; i++) + { + // Dump the process! + if (NativeMethods.MiniDumpWriteDump(process.Handle, (uint)process.Id, stream.SafeFileHandle, dumpType, ref exceptionInfo, IntPtr.Zero, IntPtr.Zero)) + { + Console.WriteLine("Dumped process."); + return 0; + } + else + { + int err = Marshal.GetHRForLastWin32Error(); + if (err != NativeMethods.ERROR_PARTIAL_COPY) { - case DumpTypeOption.Full: - dumpType = NativeMethods.MINIDUMP_TYPE.MiniDumpWithFullMemory | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithDataSegs | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithHandleData | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithUnloadedModules | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithFullMemoryInfo | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithThreadInfo | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithTokenInformation; - break; - case DumpTypeOption.WithHeap: - dumpType = NativeMethods.MINIDUMP_TYPE.MiniDumpWithPrivateReadWriteMemory | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithDataSegs | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithHandleData | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithUnloadedModules | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithFullMemoryInfo | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithThreadInfo | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithTokenInformation; - break; - case DumpTypeOption.Mini: - dumpType = NativeMethods.MINIDUMP_TYPE.MiniDumpWithThreadInfo; - break; + Console.WriteLine($"Error dumping process {err}"); + Marshal.ThrowExceptionForHR(err); } - - // Retry the write dump on ERROR_PARTIAL_COPY - for (int i = 0; i < 5; i++) + else { - // Dump the process! - if (NativeMethods.MiniDumpWriteDump(process.Handle, (uint)process.Id, stream.SafeFileHandle, dumpType, ref exceptionInfo, IntPtr.Zero, IntPtr.Zero)) - { - Console.WriteLine("Dumped process."); - return 0; - } - else - { - int err = Marshal.GetHRForLastWin32Error(); - if (err != NativeMethods.ERROR_PARTIAL_COPY) - { - Console.WriteLine($"Error dumping process {err}"); - Marshal.ThrowExceptionForHR(err); - } - else - { - Console.WriteLine($"Error dumping process, was ERROR_PARTIAL_COPY, retrying."); - } - } + Console.WriteLine($"Error dumping process, was ERROR_PARTIAL_COPY, retrying."); } - - Console.WriteLine($"Error dumping process after 5 retries."); - return 1; } } - private static class NativeMethods - { - public const int ERROR_PARTIAL_COPY = unchecked((int)0x8007012b); + Console.WriteLine($"Error dumping process after 5 retries."); + return 1; + } - [DllImport("Dbghelp.dll", SetLastError = true)] - public static extern bool MiniDumpWriteDump(IntPtr hProcess, uint ProcessId, SafeFileHandle hFile, MINIDUMP_TYPE DumpType, ref MINIDUMP_EXCEPTION_INFORMATION ExceptionParam, IntPtr UserStreamParam, IntPtr CallbackParam); + [SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Do not report for native methods")] + private static class NativeMethods + { + public const int ERROR_PARTIAL_COPY = unchecked((int)0x8007012b); - [StructLayout(LayoutKind.Sequential, Pack = 4)] - public struct MINIDUMP_EXCEPTION_INFORMATION - { - public uint ThreadId; - public IntPtr ExceptionPointers; - public int ClientPointers; - } + [DllImport("Dbghelp.dll", SetLastError = true)] + public static extern bool MiniDumpWriteDump(IntPtr hProcess, uint ProcessId, SafeFileHandle hFile, MINIDUMP_TYPE dumpType, ref MINIDUMP_EXCEPTION_INFORMATION exceptionParam, IntPtr userStreamParam, IntPtr callbackParam); - [Flags] -#pragma warning disable SA1201 // Elements must appear in the correct order - public enum MINIDUMP_TYPE : uint -#pragma warning restore SA1201 // Elements must appear in the correct order - { - MiniDumpNormal = 0, - MiniDumpWithDataSegs = 1 << 0, - MiniDumpWithFullMemory = 1 << 1, - MiniDumpWithHandleData = 1 << 2, - MiniDumpFilterMemory = 1 << 3, - MiniDumpScanMemory = 1 << 4, - MiniDumpWithUnloadedModules = 1 << 5, - MiniDumpWithIndirectlyReferencedMemory = 1 << 6, - MiniDumpFilterModulePaths = 1 << 7, - MiniDumpWithProcessThreadData = 1 << 8, - MiniDumpWithPrivateReadWriteMemory = 1 << 9, - MiniDumpWithoutOptionalData = 1 << 10, - MiniDumpWithFullMemoryInfo = 1 << 11, - MiniDumpWithThreadInfo = 1 << 12, - MiniDumpWithCodeSegs = 1 << 13, - MiniDumpWithoutAuxiliaryState = 1 << 14, - MiniDumpWithFullAuxiliaryState = 1 << 15, - MiniDumpWithPrivateWriteCopyMemory = 1 << 16, - MiniDumpIgnoreInaccessibleMemory = 1 << 17, - MiniDumpWithTokenInformation = 1 << 18, - MiniDumpWithModuleHeaders = 1 << 19, - MiniDumpFilterTriage = 1 << 20, - MiniDumpWithAvxXStateContext = 1 << 21, - MiniDumpWithIptTrace = 1 << 22, - MiniDumpValidTypeFlags = (-1) ^ ((~1) << 22) - } + [StructLayout(LayoutKind.Sequential, Pack = 4)] + public struct MINIDUMP_EXCEPTION_INFORMATION + { + public readonly uint ThreadId; + public readonly IntPtr ExceptionPointers; + public readonly int ClientPointers; } - } - internal enum DumpTypeOption - { - Full, - WithHeap, - Mini, + [Flags] + public enum MINIDUMP_TYPE : uint + { + MiniDumpNormal = 0, + MiniDumpWithDataSegs = 1 << 0, + MiniDumpWithFullMemory = 1 << 1, + MiniDumpWithHandleData = 1 << 2, + MiniDumpFilterMemory = 1 << 3, + MiniDumpScanMemory = 1 << 4, + MiniDumpWithUnloadedModules = 1 << 5, + MiniDumpWithIndirectlyReferencedMemory = 1 << 6, + MiniDumpFilterModulePaths = 1 << 7, + MiniDumpWithProcessThreadData = 1 << 8, + MiniDumpWithPrivateReadWriteMemory = 1 << 9, + MiniDumpWithoutOptionalData = 1 << 10, + MiniDumpWithFullMemoryInfo = 1 << 11, + MiniDumpWithThreadInfo = 1 << 12, + MiniDumpWithCodeSegs = 1 << 13, + MiniDumpWithoutAuxiliaryState = 1 << 14, + MiniDumpWithFullAuxiliaryState = 1 << 15, + MiniDumpWithPrivateWriteCopyMemory = 1 << 16, + MiniDumpIgnoreInaccessibleMemory = 1 << 17, + MiniDumpWithTokenInformation = 1 << 18, + MiniDumpWithModuleHeaders = 1 << 19, + MiniDumpFilterTriage = 1 << 20, + MiniDumpWithAvxXStateContext = 1 << 21, + MiniDumpWithIptTrace = 1 << 22, + MiniDumpValidTypeFlags = (-1) ^ ((~1) << 22) + } } +} - internal static class DebuggerBreakpoint +internal enum DumpTypeOption +{ + Full, + WithHeap, + Mini, +} + +internal static class DebuggerBreakpoint +{ + internal static void WaitForDebugger(string environmentVariable) { - internal static void WaitForDebugger(string environmentVariable) + if (string.IsNullOrWhiteSpace(environmentVariable)) { - if (string.IsNullOrWhiteSpace(environmentVariable)) - { - throw new ArgumentException($"'{nameof(environmentVariable)}' cannot be null or whitespace.", nameof(environmentVariable)); - } + throw new ArgumentException($"'{nameof(environmentVariable)}' cannot be null or whitespace.", nameof(environmentVariable)); + } - var debugEnabled = Environment.GetEnvironmentVariable(environmentVariable); - if (!string.IsNullOrEmpty(debugEnabled) && debugEnabled.Equals("1", StringComparison.Ordinal)) - { - Console.WriteLine("Waiting for debugger attach..."); + var debugEnabled = Environment.GetEnvironmentVariable(environmentVariable); + if (!string.IsNullOrEmpty(debugEnabled) && debugEnabled.Equals("1", StringComparison.Ordinal)) + { + Console.WriteLine("Waiting for debugger attach..."); - var currentProcess = Process.GetCurrentProcess(); - Console.WriteLine("Process Id: {0}, Name: {1}", currentProcess.Id, currentProcess.ProcessName); + var currentProcess = Process.GetCurrentProcess(); + Console.WriteLine("Process Id: {0}, Name: {1}", currentProcess.Id, currentProcess.ProcessName); - while (!Debugger.IsAttached) - { - Thread.Sleep(1000); - } - - Debugger.Break(); + while (!Debugger.IsAttached) + { + Thread.Sleep(1000); } + + Debugger.Break(); } } -} +} \ No newline at end of file diff --git a/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/CollectorNameValueConfigurationManager.cs b/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/CollectorNameValueConfigurationManager.cs index c4a9020f58..6884ea189b 100644 --- a/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/CollectorNameValueConfigurationManager.cs +++ b/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/CollectorNameValueConfigurationManager.cs @@ -1,129 +1,127 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.EventLogCollector +namespace Microsoft.TestPlatform.Extensions.EventLogCollector; + +using System.Collections.Generic; +using System.Xml; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; + +/// +/// Utility class that collectors can use to read name/value configuration information from +/// the XML element sent to them +/// +internal class CollectorNameValueConfigurationManager { - using System.Collections.Generic; - using System.Xml; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; + #region Private constants + // Configuration XML constants + private const string SettingNameAttributeName = "name"; - /// - /// Utility class that collectors can use to read name/value configuration information from - /// the XML element sent to them - /// - internal class CollectorNameValueConfigurationManager - { - #region Private constants - // Configuration XML constants - private const string SettingNameAttributeName = "name"; + private const string SettingValueAttributeName = "value"; - private const string SettingValueAttributeName = "value"; + #endregion - #endregion + #region Private fields - #region Private fields + /// + /// The name/value pairs loaded from the configuration XML element + /// - /// - /// The name/value pairs loaded from the configuration XML element - /// - private IDictionary nameValuePairs = new Dictionary(); + #endregion - #endregion + #region Constructor - #region Constructor + /// + /// Initializes a new instance of the class. + /// Loads the configuration name/value information from the provided XML element into a dictionary + /// + /// + /// XML element containing the configuration + /// + public CollectorNameValueConfigurationManager(XmlElement configurationElement) + { + if (configurationElement == null) + { + // There is no configuration + return; + } - /// - /// Initializes a new instance of the class. - /// Loads the configuration name/value information from the provided XML element into a dictionary - /// - /// - /// XML element containing the configuration - /// - public CollectorNameValueConfigurationManager(XmlElement configurationElement) + // Iterate through top-level XML elements within the configuration element and store + // name/value information for elements that have name/value attributes. + foreach (XmlNode settingNode in configurationElement.ChildNodes) { - if (configurationElement == null) + // Skip all non-elements + if (settingNode is not XmlElement settingElement) { - // There is no configuration - return; + continue; } - // Iterate through top-level XML elements within the configuration element and store - // name/value information for elements that have name/value attributes. - foreach (XmlNode settingNode in configurationElement.ChildNodes) + // Get the setting name + string settingName = settingElement.GetAttribute(SettingNameAttributeName); + if (string.IsNullOrWhiteSpace(settingName)) { - // Skip all non-elements - var settingElement = settingNode as XmlElement; - if (settingElement == null) + if (EqtTrace.IsWarningEnabled) { - continue; + EqtTrace.Warning("Skipping configuration setting due to missing setting name"); } - // Get the setting name - string settingName = settingElement.GetAttribute(SettingNameAttributeName); - if (string.IsNullOrWhiteSpace(settingName)) - { - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning("Skipping configuration setting due to missing setting name"); - } - - continue; - } + continue; + } - // Get the setting value - string settingValue = settingElement.GetAttribute(SettingValueAttributeName); - if (string.IsNullOrWhiteSpace(settingValue)) + // Get the setting value + string settingValue = settingElement.GetAttribute(SettingValueAttributeName); + if (string.IsNullOrWhiteSpace(settingValue)) + { + if (EqtTrace.IsWarningEnabled) { - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning("Skipping configuration setting '{0}' due to missing value", settingName); - } - - continue; + EqtTrace.Warning("Skipping configuration setting '{0}' due to missing value", settingName); } - // Save the name/value pair in the dictionary. Note that duplicate settings are - // overwritten with the last occurrence's value. - if (this.nameValuePairs.ContainsKey(settingName)) + continue; + } + + // Save the name/value pair in the dictionary. Note that duplicate settings are + // overwritten with the last occurrence's value. + if (NameValuePairs.ContainsKey(settingName)) + { + if (EqtTrace.IsVerboseEnabled) { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose( - "Duplicate configuration setting found for '{0}'. Using the last setting.", - settingName); - } + EqtTrace.Verbose( + "Duplicate configuration setting found for '{0}'. Using the last setting.", + settingName); } - - this.nameValuePairs[settingName] = settingValue; } + + NameValuePairs[settingName] = settingValue; } + } - #endregion + #endregion - #region Public properties + #region Public properties - internal IDictionary NameValuePairs => this.nameValuePairs; + internal IDictionary NameValuePairs { get; } = new Dictionary(); - /// - /// Gets the value of the setting specified by name, or null if it was not found - /// - /// The setting name - /// The setting value, or null if the setting was not found - public string this[string name] + /// + /// Gets the value of the setting specified by name, or null if it was not found + /// + /// The setting name + /// The setting value, or null if the setting was not found + public string this[string name] + { + get { - get + if (name == null) { - if (name == null) - { - return null; - } - - this.nameValuePairs.TryGetValue(name, out var settingValue); - return settingValue; + return null; } - set => this.nameValuePairs[name] = value; + NameValuePairs.TryGetValue(name, out var settingValue); + return settingValue; } - #endregion + + set => NameValuePairs[name] = value; } -} + #endregion +} \ No newline at end of file diff --git a/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogCollectorException.cs b/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogCollectorException.cs index 169a7a3442..36f89963d3 100644 --- a/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogCollectorException.cs +++ b/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogCollectorException.cs @@ -1,23 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.EventLogCollector -{ - using System; +namespace Microsoft.TestPlatform.Extensions.EventLogCollector; + +using System; +/// +/// Private Exception class used for event log exceptions +/// +internal class EventLogCollectorException : Exception +{ /// - /// Private Exception class used for event log exceptions + /// Initializes a new instance of the class. /// - internal class EventLogCollectorException : Exception + /// the localized exception message + /// the inner exception + public EventLogCollectorException(string localizedMessage, Exception innerException) + : base(localizedMessage, innerException) { - /// - /// Initializes a new instance of the class. - /// - /// the localized exception message - /// the inner exception - public EventLogCollectorException(string localizedMessage, Exception innerException) - : base(localizedMessage, innerException) - { - } } -} +} \ No newline at end of file diff --git a/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogConstants.cs b/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogConstants.cs index 1f74f8c00c..aa686ffeef 100644 --- a/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogConstants.cs +++ b/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogConstants.cs @@ -1,23 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.EventLogCollector +namespace Microsoft.TestPlatform.Extensions.EventLogCollector; + +/// +/// Constants used by Event Log Data Collector. +/// +internal static class EventLogConstants { - /// - /// Constants used by Event Log Data Collector. - /// - internal static class EventLogConstants - { - // Supported configuration setting names - public const string SettingEventLogs = "EventLogs"; - public const string SettingEventSources = "EventSources"; - public const string SettingEntryTypes = "EntryTypes"; - public const string SettingMaxEntries = "MaxEventLogEntriesToCollect"; + // Supported configuration setting names + public const string SettingEventLogs = "EventLogs"; + public const string SettingEventSources = "EventSources"; + public const string SettingEntryTypes = "EntryTypes"; + public const string SettingMaxEntries = "MaxEventLogEntriesToCollect"; - // default values - public const int DefaultMaxEntries = 50000; + // default values + public const int DefaultMaxEntries = 50000; - public const int TypeColumnMaxLength = 64; - public const int SourceColumnMaxLength = 212; - } + public const int TypeColumnMaxLength = 64; + public const int SourceColumnMaxLength = 212; } \ No newline at end of file diff --git a/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogContainer.cs b/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogContainer.cs index b8a98bc493..c7d6d28ef9 100644 --- a/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogContainer.cs +++ b/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogContainer.cs @@ -1,271 +1,251 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.EventLogCollector -{ - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Globalization; - - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - - using Resource = Microsoft.TestPlatform.Extensions.EventLogCollector.Resources.Resources; - - /// - /// The event log container. - /// - internal class EventLogContainer : IEventLogContainer - { - private ISet eventSources; - - private ISet entryTypes; - - private EventLog eventLog; - - private int nextEntryIndexToCollect; - - private int maxLogEntries; +namespace Microsoft.TestPlatform.Extensions.EventLogCollector; - private DataCollectionLogger dataCollectionLogger; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; - private DataCollectionContext dataCollectionContext; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - private bool limitReached; +using Resource = Resources.Resources; - private List eventLogEntries; +/// +/// The event log container. +/// +internal class EventLogContainer : IEventLogContainer +{ + private readonly ISet _eventSources; - /// - /// Keeps track of if we are disposed. - /// - private bool isDisposed; + private readonly ISet _entryTypes; + private readonly int _maxLogEntries; - /// - /// Initializes a new instance of the class. - /// - /// - /// Event Log Name for which logs has to be collected. - /// - /// - /// The event Sources. - /// - /// - /// The entry Types. - /// - /// - /// Max entries to store - /// - /// - /// Data Collection Logger - /// - /// - /// Data Collection Context - /// - public EventLogContainer(string eventLogName, ISet eventSources, ISet entryTypes, int maxLogEntries, DataCollectionLogger dataCollectionLogger, DataCollectionContext dataCollectionContext) - { - this.CreateEventLog(eventLogName); - this.eventSources = eventSources; - this.entryTypes = entryTypes; - this.maxLogEntries = maxLogEntries; - this.dataCollectionLogger = dataCollectionLogger; - this.dataCollectionContext = dataCollectionContext; + private readonly DataCollectionLogger _dataCollectionLogger; - this.eventLogEntries = new List(); - } + private readonly DataCollectionContext _dataCollectionContext; - /// - public List EventLogEntries => this.eventLogEntries; + /// + /// Keeps track of if we are disposed. + /// + private bool _isDisposed; - /// - public EventLog EventLog => this.eventLog; + /// + /// Initializes a new instance of the class. + /// + /// + /// Event Log Name for which logs has to be collected. + /// + /// + /// The event Sources. + /// + /// + /// The entry Types. + /// + /// + /// Max entries to store + /// + /// + /// Data Collection Logger + /// + /// + /// Data Collection Context + /// + public EventLogContainer(string eventLogName, ISet eventSources, ISet entryTypes, int maxLogEntries, DataCollectionLogger dataCollectionLogger, DataCollectionContext dataCollectionContext) + { + CreateEventLog(eventLogName); + _eventSources = eventSources; + _entryTypes = entryTypes; + _maxLogEntries = maxLogEntries; + _dataCollectionLogger = dataCollectionLogger; + _dataCollectionContext = dataCollectionContext; + + EventLogEntries = new List(); + } - internal int NextEntryIndexToCollect - { - get => this.nextEntryIndexToCollect; + /// + public List EventLogEntries { get; } - set => this.nextEntryIndexToCollect = value; - } + /// + public EventLog EventLog { get; private set; } - /// - /// Gets or sets a value indicating whether limit reached. - /// - internal bool LimitReached - { - get => this.limitReached; + internal int NextEntryIndexToCollect { get; set; } - set => this.limitReached = value; - } + /// + /// Gets or sets a value indicating whether limit reached. + /// + internal bool LimitReached { get; set; } - public void Dispose() - { - this.Dispose(true); + public void Dispose() + { + Dispose(true); - // Use SupressFinalize in case a subclass - // of this type implements a finalizer. - GC.SuppressFinalize(this); - } + // Use SupressFinalize in case a subclass + // of this type implements a finalizer. + GC.SuppressFinalize(this); + } - /// - /// This is the event handler for the EntryWritten event of the System.Diagnostics.EventLog class. - /// Note that the documentation for the EntryWritten event includes these remarks: - /// "The system responds to WriteEntry only if the last write event occurred at least five seconds previously. - /// This implies you will only receive one EntryWritten event notification within a five-second interval, even if more - /// than one event log change occurs. If you insert a sufficiently long sleep interval (around 10 seconds) between calls - /// to WriteEntry, no events will be lost. However, if write events occur more frequently, the most recent write events - /// could be lost." - /// This complicates this data collector because we don't want to sleep to wait for all events or lose the most recent events. - /// To workaround, the implementation does several things: - /// 1. We get the EventLog entries to collect from the EventLog.Entries collection and ignore the EntryWrittenEventArgs. - /// 2. When event log collection ends for a data collection context, this method is called explicitly by the EventLogDataCollector - /// passing null for EntryWrittenEventArgs (which is fine since the argument is ignored. - /// 3. We keep track of which EventLogEntry object in the EventLog.Entries we still need to collect. We do this by inspecting - /// the value of the EventLogEntry.Index property. The value of this property is an integer that is incremented for each entry - /// that is written to the event log, but is reset to 0 if the entire event log is cleared. - /// Another behavior of event logs that we need to account for is that if the event log reaches a size limit, older events are - /// automatically deleted. In this case the collection EventLog.Entries contains only the entries remaining in the log, - /// and the value of the EventLog.Entries[0].Index will not be 0; it will be the index of the oldest entry still in the log. - /// For example, if the first 1000 entries written to an event log (since it was last completely cleared) are deleted because - /// of the size limitation, then EventLog.Entries[0].Index would have a value of 1000 (this value is saved in the local variable - /// "firstIndexInLog" in the method implementation. Similarly "mostRecentIndexInLog" is the index of the last entry written - /// to the log at the time we examine it. - /// - /// Source - /// The System.Diagnostics.EntryWrittenEventArgs object describing the entry that was written. - public void OnEventLogEntryWritten(object source, EntryWrittenEventArgs e) + /// + /// This is the event handler for the EntryWritten event of the System.Diagnostics.EventLog class. + /// Note that the documentation for the EntryWritten event includes these remarks: + /// "The system responds to WriteEntry only if the last write event occurred at least five seconds previously. + /// This implies you will only receive one EntryWritten event notification within a five-second interval, even if more + /// than one event log change occurs. If you insert a sufficiently long sleep interval (around 10 seconds) between calls + /// to WriteEntry, no events will be lost. However, if write events occur more frequently, the most recent write events + /// could be lost." + /// This complicates this data collector because we don't want to sleep to wait for all events or lose the most recent events. + /// To workaround, the implementation does several things: + /// 1. We get the EventLog entries to collect from the EventLog.Entries collection and ignore the EntryWrittenEventArgs. + /// 2. When event log collection ends for a data collection context, this method is called explicitly by the EventLogDataCollector + /// passing null for EntryWrittenEventArgs (which is fine since the argument is ignored. + /// 3. We keep track of which EventLogEntry object in the EventLog.Entries we still need to collect. We do this by inspecting + /// the value of the EventLogEntry.Index property. The value of this property is an integer that is incremented for each entry + /// that is written to the event log, but is reset to 0 if the entire event log is cleared. + /// Another behavior of event logs that we need to account for is that if the event log reaches a size limit, older events are + /// automatically deleted. In this case the collection EventLog.Entries contains only the entries remaining in the log, + /// and the value of the EventLog.Entries[0].Index will not be 0; it will be the index of the oldest entry still in the log. + /// For example, if the first 1000 entries written to an event log (since it was last completely cleared) are deleted because + /// of the size limitation, then EventLog.Entries[0].Index would have a value of 1000 (this value is saved in the local variable + /// "firstIndexInLog" in the method implementation. Similarly "mostRecentIndexInLog" is the index of the last entry written + /// to the log at the time we examine it. + /// + /// Source + /// The System.Diagnostics.EntryWrittenEventArgs object describing the entry that was written. + public void OnEventLogEntryWritten(object source, EntryWrittenEventArgs e) + { + while (!LimitReached) { - while (!this.limitReached) + try { - try + lock (EventLogEntries) { - lock (this.eventLogEntries) + int currentCount = EventLog.Entries.Count; + if (currentCount == 0) { - int currentCount = this.eventLog.Entries.Count; - if (currentCount == 0) - { - break; - } + break; + } - int firstIndexInLog = this.eventLog.Entries[0].Index; - int mostRecentIndexInLog = this.eventLog.Entries[currentCount - 1].Index; + int firstIndexInLog = EventLog.Entries[0].Index; + int mostRecentIndexInLog = EventLog.Entries[currentCount - 1].Index; - if (mostRecentIndexInLog == this.nextEntryIndexToCollect - 1) - { - // We've already collected the most recent entry in the log - break; - } + if (mostRecentIndexInLog == NextEntryIndexToCollect - 1) + { + // We've already collected the most recent entry in the log + break; + } - if (mostRecentIndexInLog < this.nextEntryIndexToCollect - 1) + if (mostRecentIndexInLog < NextEntryIndexToCollect - 1) + { + if (EqtTrace.IsWarningEnabled) { - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning( - string.Format( - CultureInfo.InvariantCulture, - "EventLogDataContainer: OnEventLogEntryWritten: Handling clearing of log (mostRecentIndexInLog < eventLogContainer.NextEntryIndex): firstIndexInLog: {0}:, mostRecentIndexInLog: {1}, NextEntryIndex: {2}", - firstIndexInLog, - mostRecentIndexInLog, - this.nextEntryIndexToCollect)); - } - - // Send warning; event log must have been cleared. - this.dataCollectionLogger.LogWarning( - this.dataCollectionContext, + EqtTrace.Warning( string.Format( CultureInfo.InvariantCulture, - Resource.EventsLostWarning, - this.eventLog.Log)); - - this.nextEntryIndexToCollect = 0; - firstIndexInLog = 0; + "EventLogDataContainer: OnEventLogEntryWritten: Handling clearing of log (mostRecentIndexInLog < eventLogContainer.NextEntryIndex): firstIndexInLog: {0}:, mostRecentIndexInLog: {1}, NextEntryIndex: {2}", + firstIndexInLog, + mostRecentIndexInLog, + NextEntryIndexToCollect)); } - for (; - this.nextEntryIndexToCollect <= mostRecentIndexInLog; - this.nextEntryIndexToCollect++) - { - int nextEntryIndexInCurrentLog = this.nextEntryIndexToCollect - firstIndexInLog; - EventLogEntry nextEntry = this.eventLog.Entries[nextEntryIndexInCurrentLog]; + // Send warning; event log must have been cleared. + _dataCollectionLogger.LogWarning( + _dataCollectionContext, + string.Format( + CultureInfo.InvariantCulture, + Resource.EventsLostWarning, + EventLog.Log)); - // If an explicit list of event sources was provided, only report log entries from those sources - if (this.eventSources != null && this.eventSources.Count > 0) - { - if (!this.eventSources.Contains(nextEntry.Source)) - { - continue; - } - } + NextEntryIndexToCollect = 0; + firstIndexInLog = 0; + } - if (!this.entryTypes.Contains(nextEntry.EntryType)) + for (; + NextEntryIndexToCollect <= mostRecentIndexInLog; + NextEntryIndexToCollect++) + { + int nextEntryIndexInCurrentLog = NextEntryIndexToCollect - firstIndexInLog; + EventLogEntry nextEntry = EventLog.Entries[nextEntryIndexInCurrentLog]; + + // If an explicit list of event sources was provided, only report log entries from those sources + if (_eventSources != null && _eventSources.Count > 0) + { + if (!_eventSources.Contains(nextEntry.Source)) { continue; } + } - if (this.eventLogEntries.Count < this.maxLogEntries) - { - this.eventLogEntries.Add(nextEntry); + if (!_entryTypes.Contains(nextEntry.EntryType)) + { + continue; + } - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose( - string.Format( - CultureInfo.InvariantCulture, - "EventLogDataContainer.OnEventLogEntryWritten() add event with Id {0} from position {1} in the current {2} log", - nextEntry.Index, - nextEntryIndexInCurrentLog, - this.eventLog.Log)); - } - } - else + if (EventLogEntries.Count < _maxLogEntries) + { + EventLogEntries.Add(nextEntry); + + if (EqtTrace.IsVerboseEnabled) { - this.LimitReached = true; - break; + EqtTrace.Verbose( + string.Format( + CultureInfo.InvariantCulture, + "EventLogDataContainer.OnEventLogEntryWritten() add event with Id {0} from position {1} in the current {2} log", + nextEntry.Index, + nextEntryIndexInCurrentLog, + EventLog.Log)); } } + else + { + LimitReached = true; + break; + } } } - catch (Exception exception) - { - this.dataCollectionLogger.LogError( - this.dataCollectionContext, - string.Format( - CultureInfo.InvariantCulture, - Resource.EventsLostError, - this.eventLog.Log, - exception), exception); - } + } + catch (Exception exception) + { + _dataCollectionLogger.LogError( + _dataCollectionContext, + string.Format( + CultureInfo.InvariantCulture, + Resource.EventsLostError, + EventLog.Log, + exception), exception); } } + } - /// - /// The dispose. - /// - /// - /// The disposing. - /// - protected virtual void Dispose(bool disposing) + /// + /// The dispose. + /// + /// + /// The disposing. + /// + protected virtual void Dispose(bool disposing) + { + if (!_isDisposed) { - if (!this.isDisposed) + if (disposing) { - if (disposing) - { - this.eventLog.EnableRaisingEvents = false; - this.eventLog.EntryWritten -= this.OnEventLogEntryWritten; - this.eventLog.Dispose(); - } - - this.isDisposed = true; + EventLog.EnableRaisingEvents = false; + EventLog.EntryWritten -= OnEventLogEntryWritten; + EventLog.Dispose(); } - } - private void CreateEventLog(string eventLogName) - { - this.eventLog = new EventLog(eventLogName); - this.eventLog.EnableRaisingEvents = true; - this.eventLog.EntryWritten += this.OnEventLogEntryWritten; - int currentCount = this.eventLog.Entries.Count; - this.nextEntryIndexToCollect = - (currentCount == 0) ? 0 : this.eventLog.Entries[currentCount - 1].Index + 1; + _isDisposed = true; } } -} + + private void CreateEventLog(string eventLogName) + { + EventLog = new EventLog(eventLogName); + EventLog.EnableRaisingEvents = true; + EventLog.EntryWritten += OnEventLogEntryWritten; + int currentCount = EventLog.Entries.Count; + NextEntryIndexToCollect = + (currentCount == 0) ? 0 : EventLog.Entries[currentCount - 1].Index + 1; + } +} \ No newline at end of file diff --git a/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogDataCollector.cs b/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogDataCollector.cs index 3b5639ea54..f7b02c99fd 100644 --- a/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogDataCollector.cs +++ b/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogDataCollector.cs @@ -1,681 +1,634 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.EventLogCollector +namespace Microsoft.TestPlatform.Extensions.EventLogCollector; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Xml; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +using Resource = Resources.Resources; + +/// +/// A data collector that collects event log data +/// +[DataCollectorTypeUri(DefaultUri)] +[DataCollectorFriendlyName("Event Log")] +public class EventLogDataCollector : DataCollector { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Xml; + #region Constants - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + /// + /// The event log file name. + /// + private const string EventLogFileName = "Event Log"; + + /// + /// DataCollector URI. + /// + private const string DefaultUri = @"datacollector://Microsoft/EventLog/2.0"; + + #endregion - using Resource = Resources.Resources; + #region Private fields /// - /// A data collector that collects event log data + /// Event handler delegate for the SessionStart event /// - [DataCollectorTypeUri(DefaultUri)] - [DataCollectorFriendlyName("Event Log")] - public class EventLogDataCollector : DataCollector - { - #region Constants - - /// - /// The event log file name. - /// - private const string EventLogFileName = "Event Log"; - - /// - /// DataCollector URI. - /// - private const string DefaultUri = @"datacollector://Microsoft/EventLog/2.0"; - - #endregion - - #region Private fields - - /// - /// Event handler delegate for the SessionStart event - /// - private readonly EventHandler sessionStartEventHandler; - - /// - /// Event handler delegate for the SessionEnd event - /// - private readonly EventHandler sessionEndEventHandler; - - /// - /// Event handler delegate for the TestCaseStart event - /// - private readonly EventHandler testCaseStartEventHandler; - - /// - /// Event handler delegate for the TestCaseEnd event - /// - private readonly EventHandler testCaseEndEventHandler; - - /// - /// The event log directories. - /// - private readonly List eventLogDirectories; - - /// - /// Object containing the execution events the data collector registers for - /// - private DataCollectionEvents events; - - /// - /// The sink used by the data collector to send its data - /// - private DataCollectionSink dataSink; - - /// - /// The data collector context. - /// - private DataCollectionContext dataCollectorContext; - - /// - /// Used by the data collector to send warnings, errors, or other messages - /// - private DataCollectionLogger logger; - - /// - /// The event log names. - /// - private ISet eventLogNames; - - /// - /// The event sources. - /// - private ISet eventSources; - - /// - /// The entry types. - /// - private ISet entryTypes; - - /// - /// The max entries. - /// - private int maxEntries; - - /// - /// The file helper. - /// - private IFileHelper fileHelper; - - /// - /// The event log map. - /// - private IDictionary eventLogContainerMap = new Dictionary(); - - #endregion - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - public EventLogDataCollector() - : this(new FileHelper()) - { - } + private readonly EventHandler _sessionStartEventHandler; - /// - /// Initializes a new instance of the class. - /// - /// - /// File Helper. - /// - internal EventLogDataCollector(IFileHelper fileHelper) - { - this.sessionStartEventHandler = this.OnSessionStart; - this.sessionEndEventHandler = this.OnSessionEnd; - this.testCaseStartEventHandler = this.OnTestCaseStart; - this.testCaseEndEventHandler = this.OnTestCaseEnd; - - this.eventLogDirectories = new List(); - this.ContextMap = new Dictionary(); - this.fileHelper = fileHelper; - } + /// + /// Event handler delegate for the SessionEnd event + /// + private readonly EventHandler _sessionEndEventHandler; - #endregion + /// + /// Event handler delegate for the TestCaseStart event + /// + private readonly EventHandler _testCaseStartEventHandler; - #region Internal Fields + /// + /// Event handler delegate for the TestCaseEnd event + /// + private readonly EventHandler _testCaseEndEventHandler; - internal int MaxEntries - { - get - { - return this.maxEntries; - } - } + /// + /// The event log directories. + /// + private readonly List _eventLogDirectories; - internal ISet EventSources - { - get - { - return this.eventSources; - } - } + /// + /// Object containing the execution events the data collector registers for + /// + private DataCollectionEvents _events; - internal ISet EntryTypes - { - get - { - return this.entryTypes; - } - } + /// + /// The sink used by the data collector to send its data + /// + private DataCollectionSink _dataSink; - internal ISet EventLogNames - { - get - { - return this.eventLogNames; - } - } + /// + /// The data collector context. + /// + private DataCollectionContext _dataCollectorContext; - /// - /// Gets the context data. - /// - internal Dictionary ContextMap { get; private set; } - - #endregion - - #region DataCollector Members - - /// - /// Initializes the data collector - /// - /// - /// The XML element containing configuration information for the data collector. Currently, - /// this data collector does not have any configuration, so we ignore this parameter. - /// - /// - /// Object containing the execution events the data collector registers for - /// - /// The sink used by the data collector to send its data - /// - /// Used by the data collector to send warnings, errors, or other messages - /// - /// Provides contextual information about the agent environment - public override void Initialize( - XmlElement configurationElement, - DataCollectionEvents events, - DataCollectionSink dataSink, - DataCollectionLogger logger, - DataCollectionEnvironmentContext dataCollectionEnvironmentContext) - { - ValidateArg.NotNull(events, nameof(events)); - ValidateArg.NotNull(dataSink, nameof(dataSink)); - ValidateArg.NotNull(logger, nameof(logger)); - - this.events = events; - this.dataSink = dataSink; - this.logger = logger; - this.dataCollectorContext = dataCollectionEnvironmentContext.SessionDataCollectionContext; - - // Load the configuration - CollectorNameValueConfigurationManager nameValueSettings = - new CollectorNameValueConfigurationManager(configurationElement); - - // Apply the configuration - this.ConfigureEventSources(nameValueSettings); - this.ConfigureEntryTypes(nameValueSettings); - this.ConfigureMaxEntries(nameValueSettings); - this.ConfigureEventLogNames(nameValueSettings); - - // Register for events - events.SessionStart += this.sessionStartEventHandler; - events.SessionEnd += this.sessionEndEventHandler; - events.TestCaseStart += this.testCaseStartEventHandler; - events.TestCaseEnd += this.testCaseEndEventHandler; - } + /// + /// Used by the data collector to send warnings, errors, or other messages + /// + private DataCollectionLogger _logger; - #endregion - - #region Internal - - /// - /// The write event logs. - /// - /// - /// The event log entries. - /// - /// - /// Max Log Entries. - /// - /// - /// The data collection context. - /// - /// - /// The requested duration. - /// - /// - /// The time request received. - /// - /// - /// The . - /// - internal string WriteEventLogs(List eventLogEntries, int maxLogEntries, DataCollectionContext dataCollectionContext, TimeSpan requestedDuration, DateTime timeRequestReceived) - { - // Generate a unique but friendly Directory name in the temp directory - string eventLogDirName = string.Format( - CultureInfo.InvariantCulture, - "{0}-{1}-{2:yyyy}{2:MM}{2:dd}-{2:HH}{2:mm}{2:ss}.{2:fff}", - "Event Log", - Environment.MachineName, - DateTime.UtcNow); + /// + /// The file helper. + /// + private readonly IFileHelper _fileHelper; - string eventLogDirPath = Path.Combine(Path.GetTempPath(), eventLogDirName); + /// + /// The event log map. + /// + private readonly IDictionary _eventLogContainerMap = new Dictionary(); - // Create the directory - this.fileHelper.CreateDirectory(eventLogDirPath); + #endregion - string eventLogBasePath = Path.Combine(eventLogDirPath, EventLogFileName); - bool unusedFilenameFound = false; + #region Constructor - string eventLogPath = eventLogBasePath + ".xml"; + /// + /// Initializes a new instance of the class. + /// + public EventLogDataCollector() + : this(new FileHelper()) + { + } - if (this.fileHelper.Exists(eventLogPath)) - { - for (int i = 1; !unusedFilenameFound; i++) - { - eventLogPath = eventLogBasePath + "-" + i.ToString(CultureInfo.InvariantCulture) + ".xml"; + /// + /// Initializes a new instance of the class. + /// + /// + /// File Helper. + /// + internal EventLogDataCollector(IFileHelper fileHelper) + { + _sessionStartEventHandler = OnSessionStart; + _sessionEndEventHandler = OnSessionEnd; + _testCaseStartEventHandler = OnTestCaseStart; + _testCaseEndEventHandler = OnTestCaseEnd; + + _eventLogDirectories = new List(); + ContextMap = new Dictionary(); + _fileHelper = fileHelper; + } - if (!this.fileHelper.Exists(eventLogPath)) - { - unusedFilenameFound = true; - } - } - } + #endregion - DateTime minDate = DateTime.MinValue; + #region Internal Fields - // Limit entries to a certain time range if requested - if (requestedDuration < TimeSpan.MaxValue) - { - try - { - minDate = timeRequestReceived - requestedDuration; - } - catch (ArgumentOutOfRangeException) - { - minDate = DateTime.MinValue; - } - } + internal int MaxEntries { get; private set; } - Stopwatch stopwatch = new Stopwatch(); - stopwatch.Start(); - EventLogXmlWriter.WriteEventLogEntriesToXmlFile( - eventLogPath, - eventLogEntries.Where( - entry => entry.TimeGenerated > minDate && entry.TimeGenerated < DateTime.MaxValue).OrderBy(x => x.TimeGenerated).Take(maxLogEntries).ToList(), - this.fileHelper); + internal ISet EventSources { get; private set; } - stopwatch.Stop(); + internal ISet EntryTypes { get; private set; } - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose( - string.Format( - CultureInfo.InvariantCulture, - "EventLogDataContainer: Wrote {0} event log entries to file '{1}' in {2} seconds", - eventLogEntries.Count, - eventLogPath, - stopwatch.Elapsed.TotalSeconds.ToString(CultureInfo.InvariantCulture))); - } + internal ISet EventLogNames { get; private set; } - // Write the event log file - FileTransferInformation fileTransferInformation = - new FileTransferInformation(dataCollectionContext, eventLogPath, true, this.fileHelper); - this.dataSink.SendFileAsync(fileTransferInformation); + /// + /// Gets the context data. + /// + internal Dictionary ContextMap { get; private set; } - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose( - "EventLogDataContainer: Event log successfully sent for data collection context '{0}'.", - dataCollectionContext.ToString()); - } + #endregion - return eventLogPath; - } - #endregion + #region DataCollector Members - #region IDisposable Members + /// + /// Initializes the data collector + /// + /// + /// The XML element containing configuration information for the data collector. Currently, + /// this data collector does not have any configuration, so we ignore this parameter. + /// + /// + /// Object containing the execution events the data collector registers for + /// + /// The sink used by the data collector to send its data + /// + /// Used by the data collector to send warnings, errors, or other messages + /// + /// Provides contextual information about the agent environment + public override void Initialize( + XmlElement configurationElement, + DataCollectionEvents events, + DataCollectionSink dataSink, + DataCollectionLogger logger, + DataCollectionEnvironmentContext dataCollectionEnvironmentContext) + { + ValidateArg.NotNull(events, nameof(events)); + ValidateArg.NotNull(dataSink, nameof(dataSink)); + ValidateArg.NotNull(logger, nameof(logger)); + + _events = events; + _dataSink = dataSink; + _logger = logger; + _dataCollectorContext = dataCollectionEnvironmentContext.SessionDataCollectionContext; + + // Load the configuration + CollectorNameValueConfigurationManager nameValueSettings = + new(configurationElement); + + // Apply the configuration + ConfigureEventSources(nameValueSettings); + ConfigureEntryTypes(nameValueSettings); + ConfigureMaxEntries(nameValueSettings); + ConfigureEventLogNames(nameValueSettings); + + // Register for events + events.SessionStart += _sessionStartEventHandler; + events.SessionEnd += _sessionEndEventHandler; + events.TestCaseStart += _testCaseStartEventHandler; + events.TestCaseEnd += _testCaseEndEventHandler; + } + + #endregion - /// - /// Cleans up resources allocated by the data collector - /// - /// Not used since this class does not have a finalizer. - protected override void Dispose(bool disposing) + #region Internal + + /// + /// The write event logs. + /// + /// + /// The event log entries. + /// + /// + /// Max Log Entries. + /// + /// + /// The data collection context. + /// + /// + /// The requested duration. + /// + /// + /// The time request received. + /// + /// + /// The . + /// + internal string WriteEventLogs(List eventLogEntries, int maxLogEntries, DataCollectionContext dataCollectionContext, TimeSpan requestedDuration, DateTime timeRequestReceived) + { + // Generate a unique but friendly Directory name in the temp directory + string eventLogDirName = string.Format( + CultureInfo.InvariantCulture, + "{0}-{1}-{2:yyyy}{2:MM}{2:dd}-{2:HH}{2:mm}{2:ss}.{2:fff}", + "Event Log", + Environment.MachineName, + DateTime.UtcNow); + + string eventLogDirPath = Path.Combine(Path.GetTempPath(), eventLogDirName); + + // Create the directory + _fileHelper.CreateDirectory(eventLogDirPath); + + string eventLogBasePath = Path.Combine(eventLogDirPath, EventLogFileName); + bool unusedFilenameFound = false; + + string eventLogPath = eventLogBasePath + ".xml"; + + if (_fileHelper.Exists(eventLogPath)) { - // Unregister events - this.events.SessionStart -= this.sessionStartEventHandler; - this.events.SessionEnd -= this.sessionEndEventHandler; - this.events.TestCaseStart -= this.testCaseStartEventHandler; - this.events.TestCaseEnd -= this.testCaseEndEventHandler; - - // Unregister EventLogEntry Written. - foreach (var eventLogContainer in this.eventLogContainerMap.Values) + for (int i = 1; !unusedFilenameFound; i++) { - eventLogContainer.Dispose(); - } + eventLogPath = eventLogBasePath + "-" + i.ToString(CultureInfo.InvariantCulture) + ".xml"; - // Delete all the temp event log directories - this.RemoveTempEventLogDirs(this.eventLogDirectories); + if (!_fileHelper.Exists(eventLogPath)) + { + unusedFilenameFound = true; + } + } } - #endregion + DateTime minDate = DateTime.MinValue; - private static ISet ParseCommaSeparatedList(string commaSeparatedList) + // Limit entries to a certain time range if requested + if (requestedDuration < TimeSpan.MaxValue) { - ISet strings = new HashSet(); - string[] items = commaSeparatedList.Split(new char[] { ',' }); - foreach (string item in items) + try + { + minDate = timeRequestReceived - requestedDuration; + } + catch (ArgumentOutOfRangeException) { - strings.Add(item.Trim()); + minDate = DateTime.MinValue; } + } + + Stopwatch stopwatch = new(); + stopwatch.Start(); + EventLogXmlWriter.WriteEventLogEntriesToXmlFile( + eventLogPath, + eventLogEntries.Where( + entry => entry.TimeGenerated > minDate && entry.TimeGenerated < DateTime.MaxValue).OrderBy(x => x.TimeGenerated).Take(maxLogEntries).ToList(), + _fileHelper); + + stopwatch.Stop(); - return strings; + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose( + string.Format( + CultureInfo.InvariantCulture, + "EventLogDataContainer: Wrote {0} event log entries to file '{1}' in {2} seconds", + eventLogEntries.Count, + eventLogPath, + stopwatch.Elapsed.TotalSeconds.ToString(CultureInfo.InvariantCulture))); } - #region Event Handlers + // Write the event log file + FileTransferInformation fileTransferInformation = + new(dataCollectionContext, eventLogPath, true, _fileHelper); + _dataSink.SendFileAsync(fileTransferInformation); - private void OnSessionStart(object sender, SessionStartEventArgs e) + if (EqtTrace.IsVerboseEnabled) { - ValidateArg.NotNull(e, "SessionStartEventArgs"); - ValidateArg.NotNull(e.Context, "SessionStartEventArgs.Context"); + EqtTrace.Verbose( + "EventLogDataContainer: Event log successfully sent for data collection context '{0}'.", + dataCollectionContext.ToString()); + } - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("EventLogDataCollector: SessionStart received"); - } + return eventLogPath; + } + #endregion - this.StartCollectionForContext(e.Context, true); + #region IDisposable Members + + /// + /// Cleans up resources allocated by the data collector + /// + /// Not used since this class does not have a finalizer. + protected override void Dispose(bool disposing) + { + // Unregister events + _events.SessionStart -= _sessionStartEventHandler; + _events.SessionEnd -= _sessionEndEventHandler; + _events.TestCaseStart -= _testCaseStartEventHandler; + _events.TestCaseEnd -= _testCaseEndEventHandler; + + // Unregister EventLogEntry Written. + foreach (var eventLogContainer in _eventLogContainerMap.Values) + { + eventLogContainer.Dispose(); } - private void OnSessionEnd(object sender, SessionEndEventArgs e) + // Delete all the temp event log directories + RemoveTempEventLogDirs(_eventLogDirectories); + } + + #endregion + + private static ISet ParseCommaSeparatedList(string commaSeparatedList) + { + ISet strings = new HashSet(); + string[] items = commaSeparatedList.Split(new char[] { ',' }); + foreach (string item in items) { - ValidateArg.NotNull(e, "SessionEndEventArgs"); - ValidateArg.NotNull(e.Context, "SessionEndEventArgs.Context"); + strings.Add(item.Trim()); + } - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("EventLogDataCollector: SessionEnd received"); - } + return strings; + } + + #region Event Handlers - this.WriteCollectedEventLogEntries(e.Context, true, TimeSpan.MaxValue, DateTime.UtcNow); + private void OnSessionStart(object sender, SessionStartEventArgs e) + { + ValidateArg.NotNull(e, "SessionStartEventArgs"); + ValidateArg.NotNull(e.Context, "SessionStartEventArgs.Context"); + + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("EventLogDataCollector: SessionStart received"); } - private void OnTestCaseStart(object sender, TestCaseStartEventArgs e) + StartCollectionForContext(e.Context, true); + } + + private void OnSessionEnd(object sender, SessionEndEventArgs e) + { + ValidateArg.NotNull(e, "SessionEndEventArgs"); + ValidateArg.NotNull(e.Context, "SessionEndEventArgs.Context"); + + if (EqtTrace.IsVerboseEnabled) { - ValidateArg.NotNull(e, "TestCaseStartEventArgs"); - ValidateArg.NotNull(e.Context, "TestCaseStartEventArgs.Context"); + EqtTrace.Verbose("EventLogDataCollector: SessionEnd received"); + } - if (!e.Context.HasTestCase) - { - Debug.Fail("Context is not for a test case"); - throw new ArgumentNullException("TestCaseStartEventArgs.Context.HasTestCase"); - } + WriteCollectedEventLogEntries(e.Context, true, TimeSpan.MaxValue, DateTime.UtcNow); + } - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("EventLogDataCollector: TestCaseStart received for test '{0}'.", e.TestCaseName); - } + private void OnTestCaseStart(object sender, TestCaseStartEventArgs e) + { + ValidateArg.NotNull(e, "TestCaseStartEventArgs"); + ValidateArg.NotNull(e.Context, "TestCaseStartEventArgs.Context"); - this.StartCollectionForContext(e.Context, false); + if (!e.Context.HasTestCase) + { + Debug.Fail("Context is not for a test case"); + throw new ArgumentNullException("TestCaseStartEventArgs.Context.HasTestCase"); } - private void OnTestCaseEnd(object sender, TestCaseEndEventArgs e) + if (EqtTrace.IsVerboseEnabled) { - ValidateArg.NotNull(e, "TestCaseEndEventArgs"); + EqtTrace.Verbose("EventLogDataCollector: TestCaseStart received for test '{0}'.", e.TestCaseName); + } - Debug.Assert(e.Context != null, "Context is null"); - Debug.Assert(e.Context.HasTestCase, "Context is not for a test case"); + StartCollectionForContext(e.Context, false); + } - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose( - "EventLogDataCollector: TestCaseEnd received for test '{0}' with Test Outcome: {1}.", - e.TestCaseName, - e.TestOutcome); - } + private void OnTestCaseEnd(object sender, TestCaseEndEventArgs e) + { + ValidateArg.NotNull(e, "TestCaseEndEventArgs"); + + Debug.Assert(e.Context != null, "Context is null"); + Debug.Assert(e.Context.HasTestCase, "Context is not for a test case"); - this.WriteCollectedEventLogEntries(e.Context, false, TimeSpan.MaxValue, DateTime.UtcNow); + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose( + "EventLogDataCollector: TestCaseEnd received for test '{0}' with Test Outcome: {1}.", + e.TestCaseName, + e.TestOutcome); } - #endregion + WriteCollectedEventLogEntries(e.Context, false, TimeSpan.MaxValue, DateTime.UtcNow); + } + + #endregion - #region Private methods + #region Private methods - private void RemoveTempEventLogDirs(List tempDirs) + private void RemoveTempEventLogDirs(List tempDirs) + { + if (tempDirs != null) { - if (tempDirs != null) + foreach (string dir in tempDirs) { - foreach (string dir in tempDirs) - { - // Delete only if the directory is empty - this.fileHelper.DeleteEmptyDirectroy(dir); - } + // Delete only if the directory is empty + _fileHelper.DeleteEmptyDirectroy(dir); } } + } - private void StartCollectionForContext(DataCollectionContext dataCollectionContext, bool isSessionContext) + private void StartCollectionForContext(DataCollectionContext dataCollectionContext, bool isSessionContext) + { + lock (ContextMap) { - EventLogSessionContext eventLogSessionContext = null; - lock (this.ContextMap) - { - eventLogSessionContext = - new EventLogSessionContext(this.eventLogContainerMap); - this.ContextMap.Add(dataCollectionContext, eventLogSessionContext); - } + var eventLogSessionContext = new EventLogSessionContext(_eventLogContainerMap); + ContextMap.Add(dataCollectionContext, eventLogSessionContext); } + } - private void WriteCollectedEventLogEntries( - DataCollectionContext dataCollectionContext, - bool isSessionEnd, - TimeSpan requestedDuration, - DateTime timeRequestReceived) - { - var context = this.GetEventLogSessionContext(dataCollectionContext); - context.CreateEventLogContainerEndIndexMap(); + private void WriteCollectedEventLogEntries( + DataCollectionContext dataCollectionContext, + bool isSessionEnd, + TimeSpan requestedDuration, + DateTime timeRequestReceived) + { + var context = GetEventLogSessionContext(dataCollectionContext); + context.CreateEventLogContainerEndIndexMap(); - List eventLogEntries = new List(); - foreach (KeyValuePair kvp in this.eventLogContainerMap) + List eventLogEntries = new(); + foreach (KeyValuePair kvp in _eventLogContainerMap) + { + try { - try + if (isSessionEnd) { - if (isSessionEnd) - { - kvp.Value.EventLog.EnableRaisingEvents = false; - } - - for (int i = context.EventLogContainerStartIndexMap[kvp.Key]; i <= context.EventLogContainerEndIndexMap[kvp.Key]; i++) - { - eventLogEntries.Add(kvp.Value.EventLogEntries[i]); - } + kvp.Value.EventLog.EnableRaisingEvents = false; } - catch (Exception e) + + for (int i = context.EventLogContainerStartIndexMap[kvp.Key]; i <= context.EventLogContainerEndIndexMap[kvp.Key]; i++) { - this.logger.LogWarning( - dataCollectionContext, - string.Format( - CultureInfo.InvariantCulture, - Resource.CleanupException, - kvp.Value.EventLog, - e.ToString())); + eventLogEntries.Add(kvp.Value.EventLogEntries[i]); } } + catch (Exception e) + { + _logger.LogWarning( + dataCollectionContext, + string.Format( + CultureInfo.InvariantCulture, + Resource.CleanupException, + kvp.Value.EventLog, + e.ToString())); + } + } - var fileName = this.WriteEventLogs(eventLogEntries, isSessionEnd ? int.MaxValue : this.maxEntries, dataCollectionContext, requestedDuration, timeRequestReceived); + var fileName = WriteEventLogs(eventLogEntries, isSessionEnd ? int.MaxValue : MaxEntries, dataCollectionContext, requestedDuration, timeRequestReceived); - // Add the directory to the list - this.eventLogDirectories.Add(Path.GetDirectoryName(fileName)); + // Add the directory to the list + _eventLogDirectories.Add(Path.GetDirectoryName(fileName)); - lock (this.ContextMap) - { - this.ContextMap.Remove(dataCollectionContext); - } + lock (ContextMap) + { + ContextMap.Remove(dataCollectionContext); } + } - private void ConfigureEventLogNames(CollectorNameValueConfigurationManager collectorNameValueConfigurationManager) + private void ConfigureEventLogNames(CollectorNameValueConfigurationManager collectorNameValueConfigurationManager) + { + EventLogNames = new HashSet(); + string eventLogs = collectorNameValueConfigurationManager[EventLogConstants.SettingEventLogs]; + if (eventLogs != null) { - this.eventLogNames = new HashSet(); - string eventLogs = collectorNameValueConfigurationManager[EventLogConstants.SettingEventLogs]; - if (eventLogs != null) - { - this.eventLogNames = ParseCommaSeparatedList(eventLogs); - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose( - "EventLogDataCollector configuration: " + EventLogConstants.SettingEventLogs + "=" + eventLogs); - } - } - else + EventLogNames = ParseCommaSeparatedList(eventLogs); + if (EqtTrace.IsVerboseEnabled) { - // Default to collecting these standard logs - this.eventLogNames.Add("System"); - this.eventLogNames.Add("Application"); + EqtTrace.Verbose( + "EventLogDataCollector configuration: " + EventLogConstants.SettingEventLogs + "=" + eventLogs); } + } + else + { + // Default to collecting these standard logs + EventLogNames.Add("System"); + EventLogNames.Add("Application"); + } - foreach (string eventLogName in this.eventLogNames) + foreach (string eventLogName in EventLogNames) + { + try { - try + // Create an EventLog object and add it to the eventLogContext if one does not already exist + if (!_eventLogContainerMap.ContainsKey(eventLogName)) { - // Create an EventLog object and add it to the eventLogContext if one does not already exist - if (!this.eventLogContainerMap.ContainsKey(eventLogName)) - { - IEventLogContainer eventLogContainer = new EventLogContainer( - eventLogName, - this.eventSources, - this.entryTypes, - int.MaxValue, - this.logger, - this.dataCollectorContext); - this.eventLogContainerMap.Add(eventLogName, eventLogContainer); - } - - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose(string.Format( - CultureInfo.InvariantCulture, - "EventLogDataCollector: Created EventSource '{0}'", - eventLogName)); - } + IEventLogContainer eventLogContainer = new EventLogContainer( + eventLogName, + EventSources, + EntryTypes, + int.MaxValue, + _logger, + _dataCollectorContext); + _eventLogContainerMap.Add(eventLogName, eventLogContainer); } - catch (Exception ex) + + if (EqtTrace.IsVerboseEnabled) { - this.logger.LogError( - this.dataCollectorContext, - new EventLogCollectorException(string.Format(CultureInfo.InvariantCulture, Resource.ReadError, eventLogName, Environment.MachineName), ex)); + EqtTrace.Verbose(string.Format( + CultureInfo.InvariantCulture, + "EventLogDataCollector: Created EventSource '{0}'", + eventLogName)); } } + catch (Exception ex) + { + _logger.LogError( + _dataCollectorContext, + new EventLogCollectorException(string.Format(CultureInfo.InvariantCulture, Resource.ReadError, eventLogName, Environment.MachineName), ex)); + } } + } - private void ConfigureEventSources(CollectorNameValueConfigurationManager collectorNameValueConfigurationManager) + private void ConfigureEventSources(CollectorNameValueConfigurationManager collectorNameValueConfigurationManager) + { + string eventSourcesStr = collectorNameValueConfigurationManager[EventLogConstants.SettingEventSources]; + if (!string.IsNullOrEmpty(eventSourcesStr)) { - string eventSourcesStr = collectorNameValueConfigurationManager[EventLogConstants.SettingEventSources]; - if (!string.IsNullOrEmpty(eventSourcesStr)) + EventSources = ParseCommaSeparatedList(eventSourcesStr); + if (EqtTrace.IsVerboseEnabled) { - this.eventSources = ParseCommaSeparatedList(eventSourcesStr); - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose( - "EventLogDataCollector configuration: " + EventLogConstants.SettingEventSources + "=" - + this.eventSources); - } + EqtTrace.Verbose( + "EventLogDataCollector configuration: " + EventLogConstants.SettingEventSources + "=" + + EventSources); } } + } - private void ConfigureEntryTypes(CollectorNameValueConfigurationManager collectorNameValueConfigurationManager) + private void ConfigureEntryTypes(CollectorNameValueConfigurationManager collectorNameValueConfigurationManager) + { + EntryTypes = new HashSet(); + string entryTypesStr = collectorNameValueConfigurationManager[EventLogConstants.SettingEntryTypes]; + if (entryTypesStr != null) { - this.entryTypes = new HashSet(); - string entryTypesStr = collectorNameValueConfigurationManager[EventLogConstants.SettingEntryTypes]; - if (entryTypesStr != null) + foreach (string entryTypestring in ParseCommaSeparatedList(entryTypesStr)) { - foreach (string entryTypestring in ParseCommaSeparatedList(entryTypesStr)) - { - this.entryTypes.Add( - (EventLogEntryType)Enum.Parse(typeof(EventLogEntryType), entryTypestring, true)); - } - - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose( - "EventLogDataCollector configuration: " + EventLogConstants.SettingEntryTypes + "=" - + this.entryTypes); - } + EntryTypes.Add( + (EventLogEntryType)Enum.Parse(typeof(EventLogEntryType), entryTypestring, true)); } - else + + if (EqtTrace.IsVerboseEnabled) { - this.entryTypes.Add(EventLogEntryType.Error); - this.entryTypes.Add(EventLogEntryType.Warning); - this.entryTypes.Add(EventLogEntryType.FailureAudit); + EqtTrace.Verbose( + "EventLogDataCollector configuration: " + EventLogConstants.SettingEntryTypes + "=" + + EntryTypes); } } + else + { + EntryTypes.Add(EventLogEntryType.Error); + EntryTypes.Add(EventLogEntryType.Warning); + EntryTypes.Add(EventLogEntryType.FailureAudit); + } + } - private void ConfigureMaxEntries(CollectorNameValueConfigurationManager collectorNameValueConfigurationManager) + private void ConfigureMaxEntries(CollectorNameValueConfigurationManager collectorNameValueConfigurationManager) + { + string maxEntriesstring = collectorNameValueConfigurationManager[EventLogConstants.SettingMaxEntries]; + if (maxEntriesstring != null) { - string maxEntriesstring = collectorNameValueConfigurationManager[EventLogConstants.SettingMaxEntries]; - if (maxEntriesstring != null) + try { - try - { - this.maxEntries = int.Parse(maxEntriesstring, CultureInfo.InvariantCulture); + MaxEntries = int.Parse(maxEntriesstring, CultureInfo.InvariantCulture); - // A negative or 0 value means no maximum - if (this.maxEntries <= 0) - { - this.maxEntries = int.MaxValue; - } - } - catch (FormatException) + // A negative or 0 value means no maximum + if (MaxEntries <= 0) { - this.maxEntries = EventLogConstants.DefaultMaxEntries; - } - - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose( - "EventLogDataCollector configuration: " + EventLogConstants.SettingMaxEntries + "=" - + this.maxEntries); + MaxEntries = int.MaxValue; } } - else + catch (FormatException) { - this.maxEntries = EventLogConstants.DefaultMaxEntries; + MaxEntries = EventLogConstants.DefaultMaxEntries; } - } - private EventLogSessionContext GetEventLogSessionContext(DataCollectionContext dataCollectionContext) - { - EventLogSessionContext eventLogSessionContext; - bool eventLogContainerFound; - lock (this.ContextMap) + if (EqtTrace.IsVerboseEnabled) { - eventLogContainerFound = this.ContextMap.TryGetValue(dataCollectionContext, out eventLogSessionContext); + EqtTrace.Verbose( + "EventLogDataCollector configuration: " + EventLogConstants.SettingMaxEntries + "=" + + MaxEntries); } + } + else + { + MaxEntries = EventLogConstants.DefaultMaxEntries; + } + } - if (!eventLogContainerFound) - { - string msg = string.Format( - CultureInfo.InvariantCulture, - Resource.ContextNotFoundException, - dataCollectionContext.ToString()); - throw new EventLogCollectorException(msg, null); - } + private EventLogSessionContext GetEventLogSessionContext(DataCollectionContext dataCollectionContext) + { + EventLogSessionContext eventLogSessionContext; + bool eventLogContainerFound; + lock (ContextMap) + { + eventLogContainerFound = ContextMap.TryGetValue(dataCollectionContext, out eventLogSessionContext); + } - return eventLogSessionContext; + if (!eventLogContainerFound) + { + string msg = string.Format( + CultureInfo.InvariantCulture, + Resource.ContextNotFoundException, + dataCollectionContext.ToString()); + throw new EventLogCollectorException(msg, null); } - #endregion + return eventLogSessionContext; } -} + + #endregion +} \ No newline at end of file diff --git a/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogSessionContext.cs b/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogSessionContext.cs index 059975eea7..6050336e84 100644 --- a/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogSessionContext.cs +++ b/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogSessionContext.cs @@ -1,65 +1,64 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.EventLogCollector +namespace Microsoft.TestPlatform.Extensions.EventLogCollector; + +using System.Collections.Generic; + +/// +/// Stores the start and end index for EventLogEntries corresponding to a data collection session. +/// +internal class EventLogSessionContext { - using System.Collections.Generic; + private readonly IDictionary _eventLogContainerMap; /// - /// Stores the start and end index for EventLogEntries corresponding to a data collection session. + /// Initializes a new instance of the class. /// - internal class EventLogSessionContext + /// + /// Event Log container map. + /// + public EventLogSessionContext(IDictionary eventLogContainerMap) { - private IDictionary eventLogContainerMap; + _eventLogContainerMap = eventLogContainerMap; + CreateEventLogContainerStartIndexMap(); + } - /// - /// Initializes a new instance of the class. - /// - /// - /// Event Log container map. - /// - public EventLogSessionContext(IDictionary eventLogContainerMap) - { - this.eventLogContainerMap = eventLogContainerMap; - this.CreateEventLogContainerStartIndexMap(); - } + /// + /// Gets the start index for EventLogs Entries. + /// + internal Dictionary EventLogContainerStartIndexMap { get; private set; } - /// - /// Gets the start index for EventLogs Entries. - /// - internal Dictionary EventLogContainerStartIndexMap { get; private set; } + /// + /// Gets the end index for EventLogs Entries + /// + internal Dictionary EventLogContainerEndIndexMap { get; private set; } - /// - /// Gets the end index for EventLogs Entries - /// - internal Dictionary EventLogContainerEndIndexMap { get; private set; } + /// + /// Creates the end index map for EventLogs Entries + /// + public void CreateEventLogContainerEndIndexMap() + { + EventLogContainerEndIndexMap = new Dictionary(_eventLogContainerMap.Count); - /// - /// Creates the end index map for EventLogs Entries - /// - public void CreateEventLogContainerEndIndexMap() + foreach (KeyValuePair kvp in _eventLogContainerMap) { - this.EventLogContainerEndIndexMap = new Dictionary(this.eventLogContainerMap.Count); - - foreach (KeyValuePair kvp in this.eventLogContainerMap) - { - kvp.Value.OnEventLogEntryWritten(kvp.Value.EventLog, null); + kvp.Value.OnEventLogEntryWritten(kvp.Value.EventLog, null); - this.EventLogContainerEndIndexMap.Add(kvp.Key, kvp.Value.EventLogEntries.Count - 1); - } + EventLogContainerEndIndexMap.Add(kvp.Key, kvp.Value.EventLogEntries.Count - 1); } + } - /// - /// Creates the start index map for EventLogs Entries - /// - public void CreateEventLogContainerStartIndexMap() - { - this.EventLogContainerStartIndexMap = new Dictionary(this.eventLogContainerMap.Count); + /// + /// Creates the start index map for EventLogs Entries + /// + public void CreateEventLogContainerStartIndexMap() + { + EventLogContainerStartIndexMap = new Dictionary(_eventLogContainerMap.Count); - foreach (KeyValuePair kvp in this.eventLogContainerMap) - { - this.EventLogContainerStartIndexMap.Add(kvp.Key, kvp.Value.EventLogEntries.Count); - } + foreach (KeyValuePair kvp in _eventLogContainerMap) + { + EventLogContainerStartIndexMap.Add(kvp.Key, kvp.Value.EventLogEntries.Count); } } } \ No newline at end of file diff --git a/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogXmlWriter.cs b/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogXmlWriter.cs index 1446d31295..71dcf27841 100644 --- a/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogXmlWriter.cs +++ b/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogXmlWriter.cs @@ -1,89 +1,84 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.EventLogCollector -{ - using System; - using System.Collections.Generic; - using System.Data; - using System.Diagnostics; - using System.Globalization; - using System.IO; - using System.Text; +namespace Microsoft.TestPlatform.Extensions.EventLogCollector; + +using System; +using System.Collections.Generic; +using System.Data; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Text; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +/// +/// This class writes event log entries to an XML file in a format that can be retrieved into a DataSet +/// +internal static class EventLogXmlWriter +{ + #region Public methods /// - /// This class writes event log entries to an XML file in a format that can be retrieved into a DataSet + /// The write event log entries to xml file. /// - internal static class EventLogXmlWriter + /// + /// The xml file path. + /// + /// + /// The event log entries. + /// + /// + /// The file Helper. + /// + public static void WriteEventLogEntriesToXmlFile(string xmlFilePath, List eventLogEntries, IFileHelper fileHelper) { - #region Public methods + using DataTable dataTable = new(); + dataTable.Locale = CultureInfo.InvariantCulture; - /// - /// The write event log entries to xml file. - /// - /// - /// The xml file path. - /// - /// - /// The event log entries. - /// - /// - /// The file Helper. - /// - public static void WriteEventLogEntriesToXmlFile(string xmlFilePath, List eventLogEntries, IFileHelper fileHelper) - { - using (DataTable dataTable = new DataTable()) - { - dataTable.Locale = CultureInfo.InvariantCulture; + // The MaxLength of the Type and Source columns must be set to allow indices to be created on them + DataColumn typeColumn = new("Type", typeof(string)); + typeColumn.MaxLength = EventLogConstants.TypeColumnMaxLength; + dataTable.Columns.Add(typeColumn); - // The MaxLength of the Type and Source columns must be set to allow indices to be created on them - DataColumn typeColumn = new DataColumn("Type", typeof(string)); - typeColumn.MaxLength = EventLogConstants.TypeColumnMaxLength; - dataTable.Columns.Add(typeColumn); + dataTable.Columns.Add(new DataColumn("DateTime", typeof(DateTime))); - dataTable.Columns.Add(new DataColumn("DateTime", typeof(DateTime))); + DataColumn sourceColumn = new("Source", typeof(string)); + sourceColumn.MaxLength = EventLogConstants.SourceColumnMaxLength; + dataTable.Columns.Add(sourceColumn); - DataColumn sourceColumn = new DataColumn("Source", typeof(string)); - sourceColumn.MaxLength = EventLogConstants.SourceColumnMaxLength; - dataTable.Columns.Add(sourceColumn); + dataTable.Columns.Add(new DataColumn("Category", typeof(string))); + dataTable.Columns.Add(new DataColumn("EventID", typeof(long))); + dataTable.Columns.Add(new DataColumn("Description", typeof(string))); + dataTable.Columns.Add(new DataColumn("User", typeof(string))); + dataTable.Columns.Add(new DataColumn("Computer", typeof(string))); + dataTable.ExtendedProperties.Add("TimestampColumnName", "DateTime"); + dataTable.ExtendedProperties.Add("IndexColumnNames", "Source,Type"); - dataTable.Columns.Add(new DataColumn("Category", typeof(string))); - dataTable.Columns.Add(new DataColumn("EventID", typeof(long))); - dataTable.Columns.Add(new DataColumn("Description", typeof(string))); - dataTable.Columns.Add(new DataColumn("User", typeof(string))); - dataTable.Columns.Add(new DataColumn("Computer", typeof(string))); - dataTable.ExtendedProperties.Add("TimestampColumnName", "DateTime"); - dataTable.ExtendedProperties.Add("IndexColumnNames", "Source,Type"); - - foreach (EventLogEntry entry in eventLogEntries) - { - DataRow row = dataTable.NewRow(); - row["Type"] = entry.EntryType.ToString(); - row["DateTime"] = entry.TimeGenerated; - row["Source"] = entry.Source; - row["Category"] = entry.Category; - row["EventID"] = entry.InstanceId; - row["Description"] = entry.Message; - row["User"] = entry.UserName; - row["Computer"] = entry.MachineName; - dataTable.Rows.Add(row); - } + foreach (EventLogEntry entry in eventLogEntries) + { + DataRow row = dataTable.NewRow(); + row["Type"] = entry.EntryType.ToString(); + row["DateTime"] = entry.TimeGenerated; + row["Source"] = entry.Source; + row["Category"] = entry.Category; + row["EventID"] = entry.InstanceId; + row["Description"] = entry.Message; + row["User"] = entry.UserName; + row["Computer"] = entry.MachineName; + dataTable.Rows.Add(row); + } - DataSet dataSet = new DataSet(); - dataSet.Locale = CultureInfo.InvariantCulture; - dataSet.Tables.Add(dataTable); + DataSet dataSet = new(); + dataSet.Locale = CultureInfo.InvariantCulture; + dataSet.Tables.Add(dataTable); - // Use UTF-16 encoding - StringBuilder stringBuilder = new StringBuilder(); - using (StringWriter stringWriter = new StringWriter(stringBuilder)) - { - dataSet.WriteXml(stringWriter, XmlWriteMode.WriteSchema); - fileHelper.WriteAllTextToFile(xmlFilePath, stringBuilder.ToString()); - } - } - } + // Use UTF-16 encoding + StringBuilder stringBuilder = new(); + using StringWriter stringWriter = new(stringBuilder); + dataSet.WriteXml(stringWriter, XmlWriteMode.WriteSchema); + fileHelper.WriteAllTextToFile(xmlFilePath, stringBuilder.ToString()); } - #endregion } +#endregion \ No newline at end of file diff --git a/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/IEventLogContainer.cs b/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/IEventLogContainer.cs index 71166a0576..fa1d544d96 100644 --- a/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/IEventLogContainer.cs +++ b/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/IEventLogContainer.cs @@ -1,36 +1,35 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.EventLogCollector -{ - using System; - using System.Collections.Generic; - using System.Diagnostics; +namespace Microsoft.TestPlatform.Extensions.EventLogCollector; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +/// +/// Event log container interface +/// +internal interface IEventLogContainer : IDisposable +{ /// - /// Event log container interface + /// Gets the event log. /// - internal interface IEventLogContainer : IDisposable - { - /// - /// Gets the event log. - /// - EventLog EventLog { get; } + EventLog EventLog { get; } - /// - /// Gets the event log entries. - /// - List EventLogEntries { get; } + /// + /// Gets the event log entries. + /// + List EventLogEntries { get; } - /// - /// Event Handler for handling log entries. - /// - /// - /// The source object that raised EventLog entry event. - /// - /// - /// Contains data related to EventLog entry. - /// - void OnEventLogEntryWritten(object source, EntryWrittenEventArgs e); - } -} + /// + /// Event Handler for handling log entries. + /// + /// + /// The source object that raised EventLog entry event. + /// + /// + /// Contains data related to EventLog entry. + /// + void OnEventLogEntryWritten(object source, EntryWrittenEventArgs e); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.AdapterUtilities/Helpers/ReflectionHelpers.MethodBase.cs b/src/Microsoft.TestPlatform.AdapterUtilities/Helpers/ReflectionHelpers.MethodBase.cs index 0eaad1f4ed..8d3ce23fcb 100644 --- a/src/Microsoft.TestPlatform.AdapterUtilities/Helpers/ReflectionHelpers.MethodBase.cs +++ b/src/Microsoft.TestPlatform.AdapterUtilities/Helpers/ReflectionHelpers.MethodBase.cs @@ -1,56 +1,55 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AdapterUtilities.Helpers -{ - using System; - using System.Reflection; +namespace Microsoft.TestPlatform.AdapterUtilities.Helpers; - internal static partial class ReflectionHelpers - { +using System; +using System.Reflection; + +internal static partial class ReflectionHelpers +{ #if NETSTANDARD1_0 || NETSTANDARD1_3 || WINDOWS_UWP - private static readonly Type methodBase = typeof(MethodBase); + private static readonly Type MethodBase = typeof(MethodBase); - private const string MemberTypePropertyName = "MemberType"; - private const string ReflectedTypePropertyName = "ReflectedType"; - private const string MethodHandlePropertyName = "MethodHandle"; + private const string MemberTypePropertyName = "MemberType"; + private const string ReflectedTypePropertyName = "ReflectedType"; + private const string MethodHandlePropertyName = "MethodHandle"; - private static readonly PropertyInfo memberTypeProperty = methodBase.GetRuntimeProperty(MemberTypePropertyName); - private static readonly PropertyInfo reflectedTypeProperty = methodBase.GetRuntimeProperty(ReflectedTypePropertyName); - private static readonly PropertyInfo methodHandleProperty = methodBase.GetRuntimeProperty(MethodHandlePropertyName); + private static readonly PropertyInfo MemberTypeProperty = MethodBase.GetRuntimeProperty(MemberTypePropertyName); + private static readonly PropertyInfo ReflectedTypeProperty = MethodBase.GetRuntimeProperty(ReflectedTypePropertyName); + private static readonly PropertyInfo MethodHandleProperty = MethodBase.GetRuntimeProperty(MethodHandlePropertyName); #endif - internal static bool IsMethod(MethodBase method) - { + internal static bool IsMethod(MethodBase method) + { #if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !WINDOWS_UWP - return method.MemberType == MemberTypes.Method; + return method.MemberType == MemberTypes.Method; #else - AssertSupport(memberTypeProperty, MemberTypePropertyName, methodBase.FullName); + AssertSupport(MemberTypeProperty, MemberTypePropertyName, MethodBase.FullName); - return (int)memberTypeProperty.GetValue(method) == 8; + return (int)MemberTypeProperty.GetValue(method) == 8; #endif - } + } - internal static Type GetReflectedType(MethodBase method) - { + internal static Type GetReflectedType(MethodBase method) + { #if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !WINDOWS_UWP - return method.ReflectedType; + return method.ReflectedType; #else - AssertSupport(memberTypeProperty, ReflectedTypePropertyName, methodBase.FullName); + AssertSupport(MemberTypeProperty, ReflectedTypePropertyName, MethodBase.FullName); - return reflectedTypeProperty.GetValue(method) as Type; + return ReflectedTypeProperty.GetValue(method) as Type; #endif - } + } - internal static RuntimeMethodHandle GetMethodHandle(MethodBase method) - { + internal static RuntimeMethodHandle GetMethodHandle(MethodBase method) + { #if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !WINDOWS_UWP - return method.MethodHandle; + return method.MethodHandle; #else - AssertSupport(memberTypeProperty, MethodHandlePropertyName, methodBase.FullName); + AssertSupport(MemberTypeProperty, MethodHandlePropertyName, MethodBase.FullName); - return (RuntimeMethodHandle)methodHandleProperty.GetValue(method); + return (RuntimeMethodHandle)MethodHandleProperty.GetValue(method); #endif - } } } diff --git a/src/Microsoft.TestPlatform.AdapterUtilities/Helpers/ReflectionHelpers.Type.cs b/src/Microsoft.TestPlatform.AdapterUtilities/Helpers/ReflectionHelpers.Type.cs index d8e8d23b5c..921c7a294b 100644 --- a/src/Microsoft.TestPlatform.AdapterUtilities/Helpers/ReflectionHelpers.Type.cs +++ b/src/Microsoft.TestPlatform.AdapterUtilities/Helpers/ReflectionHelpers.Type.cs @@ -1,29 +1,28 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AdapterUtilities.Helpers -{ - using System; - using System.Reflection; +namespace Microsoft.TestPlatform.AdapterUtilities.Helpers; + +using System; +using System.Reflection; - internal static partial class ReflectionHelpers +internal static partial class ReflectionHelpers +{ + internal static bool IsGenericType(Type type) { - internal static bool IsGenericType(Type type) - { #if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !WINDOWS_UWP - return type.IsGenericType; + return type.IsGenericType; #else - return type.GetTypeInfo().IsGenericType; + return type.GetTypeInfo().IsGenericType; #endif - } + } - internal static MethodBase GetDeclaringMethod(Type type) - { + internal static MethodBase GetDeclaringMethod(Type type) + { #if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !WINDOWS_UWP - return type.DeclaringMethod; + return type.DeclaringMethod; #else - return type.GetTypeInfo().DeclaringMethod; + return type.GetTypeInfo().DeclaringMethod; #endif - } } } diff --git a/src/Microsoft.TestPlatform.AdapterUtilities/Helpers/ReflectionHelpers.cs b/src/Microsoft.TestPlatform.AdapterUtilities/Helpers/ReflectionHelpers.cs index f3585d2617..8970ebb0b9 100644 --- a/src/Microsoft.TestPlatform.AdapterUtilities/Helpers/ReflectionHelpers.cs +++ b/src/Microsoft.TestPlatform.AdapterUtilities/Helpers/ReflectionHelpers.cs @@ -1,97 +1,96 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AdapterUtilities.Helpers -{ - using Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities; - using Microsoft.TestPlatform.AdapterUtilities.Resources; +namespace Microsoft.TestPlatform.AdapterUtilities.Helpers; + +using Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities; +using Microsoft.TestPlatform.AdapterUtilities.Resources; - using System; - using System.Globalization; - using System.Text; +using System; +using System.Globalization; +using System.Text; - internal static partial class ReflectionHelpers +internal static partial class ReflectionHelpers +{ + private static void AssertSupport(T obj, string methodName, string className) + where T : class { - private static void AssertSupport(T obj, string methodName, string className) - where T : class + if (obj == null) { - if (obj == null) - { - throw new NotImplementedException(string.Format(Resources.MethodNotImplementedOnPlatform, className, methodName)); - } + throw new NotImplementedException(string.Format(Resources.MethodNotImplementedOnPlatform, className, methodName)); } + } - internal static string ParseEscapedString(string escapedString) + internal static string ParseEscapedString(string escapedString) + { + var stringBuilder = new StringBuilder(); + var end = 0; + for (int i = 0; i < escapedString.Length; i++) { - var stringBuilder = new StringBuilder(); - var end = 0; - for (int i = 0; i < escapedString.Length; i++) + if (escapedString[i] == '\'') { - if (escapedString[i] == '\'') - { - stringBuilder.Append(escapedString, end, i - end); - end = i = ParseEscapedStringSegment(escapedString, i + 1, stringBuilder); - } - } - - if (stringBuilder.Length == 0) - { - return escapedString; + stringBuilder.Append(escapedString, end, i - end); + end = i = ParseEscapedStringSegment(escapedString, i + 1, stringBuilder); } + } - if (end != 0 && end < escapedString.Length) - { - stringBuilder.Append(escapedString, end, escapedString.Length - end); - } + if (stringBuilder.Length == 0) + { + return escapedString; + } - return stringBuilder.ToString(); + if (end != 0 && end < escapedString.Length) + { + stringBuilder.Append(escapedString, end, escapedString.Length - end); } - // Unescapes a C# style escaped string. - private static int ParseEscapedStringSegment(string escapedStringSegment, int pos, StringBuilder stringBuilder) + return stringBuilder.ToString(); + } + + // Unescapes a C# style escaped string. + private static int ParseEscapedStringSegment(string escapedStringSegment, int pos, StringBuilder stringBuilder) + { + for (int i = pos; i < escapedStringSegment.Length; i++) { - for (int i = pos; i < escapedStringSegment.Length; i++) + switch (escapedStringSegment[i]) { - switch (escapedStringSegment[i]) - { - case '\\': - if (escapedStringSegment[i + 1] == 'u') - { - char c; - - try - { - var code = escapedStringSegment.Substring(i + 2, 4); - c = (char)Convert.ToInt32(code, 16); - } - catch - { - throw new InvalidManagedNameException( - string.Format(CultureInfo.CurrentCulture, Resources.ErrorInvalidSequenceAt, escapedStringSegment, i) - ); - } + case '\\': + if (escapedStringSegment[i + 1] == 'u') + { + char c; - stringBuilder.Append(c); - i += 5; + try + { + var code = escapedStringSegment.Substring(i + 2, 4); + c = (char)Convert.ToInt32(code, 16); } - else + catch { - stringBuilder.Append(escapedStringSegment[++i]); + throw new InvalidManagedNameException( + string.Format(CultureInfo.CurrentCulture, Resources.ErrorInvalidSequenceAt, escapedStringSegment, i) + ); } - break; + stringBuilder.Append(c); + i += 5; + } + else + { + stringBuilder.Append(escapedStringSegment[++i]); + } - case '\'': - return i + 1; + break; - default: - stringBuilder.Append(escapedStringSegment[i]); - break; - } - } + case '\'': + return i + 1; - string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorNoClosingQuote, escapedStringSegment); - throw new InvalidManagedNameException(message); + default: + stringBuilder.Append(escapedStringSegment[i]); + break; + } } + + string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorNoClosingQuote, escapedStringSegment); + throw new InvalidManagedNameException(message); } } diff --git a/src/Microsoft.TestPlatform.AdapterUtilities/HierarchyConstants.cs b/src/Microsoft.TestPlatform.AdapterUtilities/HierarchyConstants.cs index 1546637c7c..0abe66a117 100644 --- a/src/Microsoft.TestPlatform.AdapterUtilities/HierarchyConstants.cs +++ b/src/Microsoft.TestPlatform.AdapterUtilities/HierarchyConstants.cs @@ -1,42 +1,41 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AdapterUtilities +namespace Microsoft.TestPlatform.AdapterUtilities; + +/// +/// Constants to help declare Hierarchy test property. +/// +public static class HierarchyConstants { /// - /// Constants to help declare Hierarchy test property. + /// Label to use on Hierarchy test property. /// - public static class HierarchyConstants + public const string HierarchyLabel = "Hierarchy"; + + /// + /// Property id to use on Hierarchy test property. + /// + public const string HierarchyPropertyId = "TestCase." + HierarchyLabel; + + /// + /// Meanings of the indices in the Hierarchy array. + /// + public static class Levels { /// - /// Label to use on Hierarchy test property. + /// Total length of Hierarchy array. /// - public const string HierarchyLabel = "Hierarchy"; + public const int TotalLevelCount = 2; /// - /// Property id to use on Hierarchy test property. + /// Index of the namespace element of the array. /// - public const string HierarchyPropertyId = "TestCase." + HierarchyLabel; + public const int NamespaceIndex = 0; /// - /// Meanings of the indices in the Hierarchy array. + /// Index of the class element of the array. /// - public static class Levels - { - /// - /// Total length of Hierarchy array. - /// - public const int TotalLevelCount = 2; - - /// - /// Index of the namespace element of the array. - /// - public const int NamespaceIndex = 0; - - /// - /// Index of the class element of the array. - /// - public const int ClassIndex = 1; - } + public const int ClassIndex = 1; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameConstants.cs b/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameConstants.cs index 9415968b99..02e8387e6a 100644 --- a/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameConstants.cs +++ b/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameConstants.cs @@ -1,31 +1,30 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AdapterUtilities +namespace Microsoft.TestPlatform.AdapterUtilities; + +/// +/// Contants to help declare ManagedType and ManagedMethod test properties. +/// +public static class ManagedNameConstants { /// - /// Constants to help declare ManagedType and ManagedMethod test properties. + /// Label to use on ManagedType test property. /// - public static class ManagedNameConstants - { - /// - /// Label to use on ManagedType test property. - /// - public const string ManagedTypeLabel = "ManagedType"; + public const string ManagedTypeLabel = "ManagedType"; - /// - /// Label to use on ManagedMethod test property. - /// - public const string ManagedMethodLabel = "ManagedMethod"; + /// + /// Label to use on ManagedMethod test property. + /// + public const string ManagedMethodLabel = "ManagedMethod"; - /// - /// Property id to use on ManagedType test property. - /// - public const string ManagedTypePropertyId = "TestCase." + ManagedTypeLabel; + /// + /// Property id to use on ManagedType test property. + /// + public const string ManagedTypePropertyId = "TestCase." + ManagedTypeLabel; - /// - /// Property id to use on ManagedMethod test property. - /// - public const string ManagedMethodPropertyId = "TestCase." + ManagedMethodLabel; - } -} + /// + /// Property id to use on ManagedMethod test property. + /// + public const string ManagedMethodPropertyId = "TestCase." + ManagedMethodLabel; +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/InvalidManagedNameException.cs b/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/InvalidManagedNameException.cs index 3cbbaf86f5..7bb5317ff4 100644 --- a/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/InvalidManagedNameException.cs +++ b/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/InvalidManagedNameException.cs @@ -1,27 +1,26 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities -{ - using System; +namespace Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities; + +using System; #if !NETSTANDARD1_0 && !WINDOWS_UWP - using System.Runtime.Serialization; +using System.Runtime.Serialization; #endif #if !NETSTANDARD1_0 && !WINDOWS_UWP - [Serializable] +[Serializable] #endif - public class InvalidManagedNameException : - Exception +public class InvalidManagedNameException : + Exception #if !NETSTANDARD1_0 && !WINDOWS_UWP - , ISerializable + , ISerializable #endif - { - public InvalidManagedNameException(string message) : base(message) { } +{ + public InvalidManagedNameException(string message) : base(message) { } #if !NETSTANDARD1_0 && !WINDOWS_UWP - protected InvalidManagedNameException(SerializationInfo info, StreamingContext context) : base(info, context) { } + protected InvalidManagedNameException(SerializationInfo info, StreamingContext context) : base(info, context) { } #endif - } -} \ No newline at end of file +} diff --git a/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/ManagedNameHelper.Reflection.cs b/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/ManagedNameHelper.Reflection.cs index 5d37a39f80..cb7d4714f6 100644 --- a/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/ManagedNameHelper.Reflection.cs +++ b/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/ManagedNameHelper.Reflection.cs @@ -1,574 +1,572 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities -{ - using Microsoft.TestPlatform.AdapterUtilities.Resources; - using Microsoft.TestPlatform.AdapterUtilities.Helpers; +namespace Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities; + +using Microsoft.TestPlatform.AdapterUtilities.Resources; +using Microsoft.TestPlatform.AdapterUtilities.Helpers; - using System; - using System.Globalization; - using System.Reflection; - using System.Text; +using System; +using System.Globalization; +using System.Reflection; +using System.Text; #if !NET20 - using System.Linq; +using System.Linq; #endif - public static partial class ManagedNameHelper +public static partial class ManagedNameHelper +{ + /// + /// Gets fully qualified managed type and method name from given instance. + /// + /// + /// A instance to get fully qualified managed type and method name. + /// + /// + /// When this method returns, contains the fully qualified managed type name of the . + /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. + /// The format is defined in the RFC. + /// + /// + /// When this method returns, contains the fully qualified managed method name of the . + /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. + /// The format is defined in the RFC. + /// + /// + /// is null. + /// + /// + /// must describe a method. + /// + /// + /// Required functionality on is missing on the current platform. + /// + /// + /// More information about and can be found in + /// the RFC. + /// + public static void GetManagedName(MethodBase method, out string managedTypeName, out string managedMethodName) + => GetManagedName(method, out managedTypeName, out managedMethodName, out _); + + /// + /// Gets fully qualified managed type and method name from given instance. + /// + /// + /// A instance to get fully qualified managed type and method name. + /// + /// + /// When this method returns, contains the fully qualified managed type name of the . + /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. + /// The format is defined in the RFC. + /// + /// + /// When this method returns, contains the fully qualified managed method name of the . + /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. + /// The format is defined in the RFC. + /// + /// + /// When this method returns, contains the default test hierarchy values of the . + /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. + /// + /// + /// is null. + /// + /// + /// must describe a method. + /// + /// + /// Required functionality on is missing on the current platform. + /// + /// + /// More information about and can be found in + /// the RFC. + /// + public static void GetManagedName(MethodBase method, out string managedTypeName, out string managedMethodName, out string[] hierarchyValues) { - /// - /// Gets fully qualified managed type and method name from given instance. - /// - /// - /// A instance to get fully qualified managed type and method name. - /// - /// - /// When this method returns, contains the fully qualified managed type name of the . - /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. - /// The format is defined in the RFC. - /// - /// - /// When this method returns, contains the fully qualified managed method name of the . - /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. - /// The format is defined in the RFC. - /// - /// - /// is null. - /// - /// - /// must describe a method. - /// - /// - /// Required functionality on is missing on the current platform. - /// - /// - /// More information about and can be found in - /// the RFC. - /// - public static void GetManagedName(MethodBase method, out string managedTypeName, out string managedMethodName) - => GetManagedName(method, out managedTypeName, out managedMethodName, out _); - - /// - /// Gets fully qualified managed type and method name from given instance. - /// - /// - /// A instance to get fully qualified managed type and method name. - /// - /// - /// When this method returns, contains the fully qualified managed type name of the . - /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. - /// The format is defined in the RFC. - /// - /// - /// When this method returns, contains the fully qualified managed method name of the . - /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. - /// The format is defined in the RFC. - /// - /// - /// When this method returns, contains the default test hierarchy values of the . - /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. - /// - /// - /// is null. - /// - /// - /// must describe a method. - /// - /// - /// Required functionality on is missing on the current platform. - /// - /// - /// More information about and can be found in - /// the RFC. - /// - public static void GetManagedName(MethodBase method, out string managedTypeName, out string managedMethodName, out string[] hierarchyValues) - { - if (method == null) - { - throw new ArgumentNullException(nameof(method)); - } + if (method == null) + { + throw new ArgumentNullException(nameof(method)); + } - if (!ReflectionHelpers.IsMethod(method)) - { - throw new NotSupportedException(nameof(method)); - } + if (!ReflectionHelpers.IsMethod(method)) + { + throw new NotSupportedException(nameof(method)); + } - var semanticType = ReflectionHelpers.GetReflectedType(method); - if (ReflectionHelpers.IsGenericType(semanticType)) - { - // The type might have some of its generic parameters specified, so make - // sure we are working with the open form of the generic type. - semanticType = semanticType.GetGenericTypeDefinition(); - - // The method might have some of its parameters specified by the original closed type - // declaration. Here we use the method handle (basically metadata token) to create - // a new method reference using the open form of the reflected type. The intent is - // to strip all generic type parameters. - var methodHandle = ReflectionHelpers.GetMethodHandle(method); - method = MethodBase.GetMethodFromHandle(methodHandle, semanticType.TypeHandle); - } + var semanticType = ReflectionHelpers.GetReflectedType(method); + if (ReflectionHelpers.IsGenericType(semanticType)) + { + // The type might have some of its generic parameters specified, so make + // sure we are working with the open form of the generic type. + semanticType = semanticType.GetGenericTypeDefinition(); + + // The method might have some of its parameters specified by the original closed type + // declaration. Here we use the method handle (basically metadata token) to create + // a new method reference using the open form of the reflected type. The intent is + // to strip all generic type parameters. + var methodHandle = ReflectionHelpers.GetMethodHandle(method); + method = MethodBase.GetMethodFromHandle(methodHandle, semanticType.TypeHandle); + } - if (method.IsGenericMethod) - { - // If this method is generic, then convert to the generic method definition - // so that we get the open generic type definitions for parameters. - method = ((MethodInfo)method).GetGenericMethodDefinition(); - } + if (method.IsGenericMethod) + { + // If this method is generic, then convert to the generic method definition + // so that we get the open generic type definitions for parameters. + method = ((MethodInfo)method).GetGenericMethodDefinition(); + } - var typeBuilder = new StringBuilder(); - var methodBuilder = new StringBuilder(); + var typeBuilder = new StringBuilder(); + var methodBuilder = new StringBuilder(); - // Namespace and Type Name (with arity designation) - var hierarchyPos = AppendTypeString(typeBuilder, semanticType, closedType: false); + // Namespace and Type Name (with arity designation) + var hierarchyPos = AppendTypeString(typeBuilder, semanticType, closedType: false); - // Method Name with method arity - var arity = method.GetGenericArguments().Length; - AppendMethodString(methodBuilder, method.Name, arity); - if (arity > 0) - { - methodBuilder.Append('`'); - methodBuilder.Append(arity); - } + // Method Name with method arity + var arity = method.GetGenericArguments().Length; + AppendMethodString(methodBuilder, method.Name, arity); + if (arity > 0) + { + methodBuilder.Append('`'); + methodBuilder.Append(arity); + } - // Type Parameters - var paramList = method.GetParameters(); - if (paramList.Length != 0) + // Type Parameters + var paramList = method.GetParameters(); + if (paramList.Length != 0) + { + methodBuilder.Append('('); + foreach (var p in paramList) { - methodBuilder.Append('('); - foreach (var p in paramList) - { - AppendTypeString(methodBuilder, p.ParameterType, closedType: true); - methodBuilder.Append(','); - } - // Replace the last ',' with ')' - methodBuilder[methodBuilder.Length - 1] = ')'; + AppendTypeString(methodBuilder, p.ParameterType, closedType: true); + methodBuilder.Append(','); } + // Replace the last ',' with ')' + methodBuilder[methodBuilder.Length - 1] = ')'; + } - managedTypeName = typeBuilder.ToString(); - managedMethodName = methodBuilder.ToString(); - hierarchyValues = new[] { + managedTypeName = typeBuilder.ToString(); + managedMethodName = methodBuilder.ToString(); + hierarchyValues = new[] { managedTypeName.Substring(hierarchyPos[0], hierarchyPos[1] - hierarchyPos[0]), managedTypeName.Substring(hierarchyPos[1] + 1, hierarchyPos[2] - hierarchyPos[1] - 1), }; - } + } + + /// + /// Gets the object with the specified + /// and in the instance. + /// + /// + /// An instance to search in. + /// + /// + /// The fully qualified managed name of the type. + /// The format is defined in the RFC. + /// + /// + /// The fully qualified managed name of the method. + /// The format is defined in the RFC. + /// + /// + /// A object that represents specified parameters, throws if null. + /// + /// + /// Values specified with and + /// does not correspond to a method in the instance, or malformed. + /// + /// + /// More information about and can be found in + /// the RFC. + /// + public static MethodBase GetMethod(Assembly assembly, string managedTypeName, string managedMethodName) + { + Type type; - /// - /// Gets the object with the specified - /// and in the instance. - /// - /// - /// An instance to search in. - /// - /// - /// The fully qualified managed name of the type. - /// The format is defined in the RFC. - /// - /// - /// The fully qualified managed name of the method. - /// The format is defined in the RFC. - /// - /// - /// A object that represents specified parameters, throws if null. - /// - /// - /// Values specified with and - /// does not correspond to a method in the instance, or malformed. - /// - /// - /// More information about and can be found in - /// the RFC. - /// - public static MethodBase GetMethod(Assembly assembly, string managedTypeName, string managedMethodName) - { - Type type; - - var parsedManagedTypeName = ReflectionHelpers.ParseEscapedString(managedTypeName); + var parsedManagedTypeName = ReflectionHelpers.ParseEscapedString(managedTypeName); #if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !WINDOWS_UWP - type = assembly.GetType(parsedManagedTypeName, throwOnError: false, ignoreCase: false); + type = assembly.GetType(parsedManagedTypeName, throwOnError: false, ignoreCase: false); #else - try - { - type = assembly.GetType(parsedManagedTypeName); - } - catch - { - type = null; - } + try + { + type = assembly.GetType(parsedManagedTypeName); + } + catch + { + type = null; + } #endif - if (type == null) - { - string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorTypeNotFound, parsedManagedTypeName); - throw new InvalidManagedNameException(message); - } + if (type == null) + { + string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorTypeNotFound, parsedManagedTypeName); + throw new InvalidManagedNameException(message); + } - MethodInfo method = null; - ManagedNameParser.ParseManagedMethodName(managedMethodName, out var methodName, out var methodArity, out var parameterTypes); + MethodInfo method = null; + ManagedNameParser.ParseManagedMethodName(managedMethodName, out var methodName, out var methodArity, out var parameterTypes); #if NET20 || NET35 - if (!IsNullOrWhiteSpace(methodName)) + if (!IsNullOrWhiteSpace(methodName)) #else - if (!string.IsNullOrWhiteSpace(methodName)) + if (!string.IsNullOrWhiteSpace(methodName)) #endif + { + method = FindMethod(type, methodName, methodArity, parameterTypes); + } + + if (method == null) + { + string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorMethodNotFound, methodName, managedTypeName); + throw new InvalidManagedNameException(message); + } + + return method; + } + + private static MethodInfo FindMethod(Type type, string methodName, int methodArity, string[] parameterTypes) + { + bool Filter(MemberInfo mbr, object param) + { + var method = mbr as MethodInfo; + if (method.Name != methodName || method.GetGenericArguments().Length != methodArity) { - method = FindMethod(type, methodName, methodArity, parameterTypes); + return false; } - if (method == null) + var paramList = method.GetParameters(); + if (paramList.Length == 0 && parameterTypes == null) { - string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorMethodNotFound, methodName, managedTypeName); - throw new InvalidManagedNameException(message); + return true; } - - return method; - } - - private static MethodInfo FindMethod(Type type, string methodName, int methodArity, string[] parameterTypes) - { - bool filter(MemberInfo mbr, object param) + else if (parameterTypes == null || paramList.Length != parameterTypes.Length) { - var method = mbr as MethodInfo; - if (method.Name != methodName || method.GetGenericArguments().Length != methodArity) - { - return false; - } + return false; + } - var paramList = method.GetParameters(); - if (paramList.Length == 0 && parameterTypes == null) - { - return true; - } - else if (parameterTypes == null || paramList.Length != parameterTypes.Length) + for (int i = 0; i < paramList.Length; i++) + { + if (GetTypeString(paramList[i].ParameterType, closedType: true) != parameterTypes[i]) { return false; } - - for (int i = 0; i < paramList.Length; i++) - { - if (GetTypeString(paramList[i].ParameterType, closedType: true) != parameterTypes[i]) - { - return false; - } - } - - return true; } - MemberInfo[] methods; + return true; + } + + MemberInfo[] methods; #if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !WINDOWS_UWP - var bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; - methods = type.FindMembers(MemberTypes.Method, bindingFlags, filter, null); + var bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; + methods = type.FindMembers(MemberTypes.Method, bindingFlags, Filter, null); #else - methods = type.GetRuntimeMethods().Where(m => filter(m, null)).ToArray(); + methods = type.GetRuntimeMethods().Where(m => Filter(m, null)).ToArray(); #endif #if NET20 - return (MethodInfo)SingleOrDefault(methods); + return (MethodInfo)SingleOrDefault(methods); #else - return (MethodInfo)methods.SingleOrDefault(); + return (MethodInfo)methods.SingleOrDefault(); #endif - } + } - private static int[] AppendTypeString(StringBuilder b, Type type, bool closedType) - { - int[] hierarchies = null; + private static int[] AppendTypeString(StringBuilder b, Type type, bool closedType) + { + int[] hierarchies = null; - if (type.IsArray) + if (type.IsArray) + { + hierarchies = AppendTypeString(b, type.GetElementType(), closedType); + b.Append('['); + for (int i = 0; i < type.GetArrayRank() - 1; i++) { - hierarchies = AppendTypeString(b, type.GetElementType(), closedType); - b.Append('['); - for (int i = 0; i < type.GetArrayRank() - 1; i++) - { - b.Append(','); - } - b.Append(']'); + b.Append(','); } - else if (type.IsGenericParameter) + b.Append(']'); + } + else if (type.IsGenericParameter) + { + if (ReflectionHelpers.GetDeclaringMethod(type) != null) { - if (ReflectionHelpers.GetDeclaringMethod(type) != null) - { - b.Append('!'); - } b.Append('!'); - b.Append(type.GenericParameterPosition); } - else - { - hierarchies = new int[3]; - hierarchies[0] = b.Length; + b.Append('!'); + b.Append(type.GenericParameterPosition); + } + else + { + hierarchies = new int[3]; + hierarchies[0] = b.Length; - AppendNamespace(b, type.Namespace); - hierarchies[1] = b.Length; + AppendNamespace(b, type.Namespace); + hierarchies[1] = b.Length; - b.Append('.'); + b.Append('.'); - AppendNestedTypeName(b, type); - if (closedType) - { - AppendGenericTypeParameters(b, type); - } - hierarchies[2] = b.Length; + AppendNestedTypeName(b, type); + if (closedType) + { + AppendGenericTypeParameters(b, type); } - - return hierarchies; + hierarchies[2] = b.Length; } - private static void AppendNamespace(StringBuilder b, string namespaceString) - { - int start = 0; - bool shouldEscape = false; + return hierarchies; + } - for (int i = 0; i <= namespaceString.Length; i++) + private static void AppendNamespace(StringBuilder b, string namespaceString) + { + int start = 0; + bool shouldEscape = false; + + for (int i = 0; i <= namespaceString.Length; i++) + { + if (i == namespaceString.Length || namespaceString[i] == '.') { - if (i == namespaceString.Length || namespaceString[i] == '.') + if (start != 0) { - if (start != 0) - { - b.Append('.'); - } - - var part = namespaceString.Substring(start, i - start); - if (shouldEscape) - { - NormalizeAndAppendString(b, part); - shouldEscape = false; - } - else - { - b.Append(part); - } - - start = i + 1; - continue; + b.Append('.'); } - shouldEscape = shouldEscape || NeedsEscaping(namespaceString[i], i - start); + var part = namespaceString.Substring(start, i - start); + if (shouldEscape) + { + NormalizeAndAppendString(b, part); + shouldEscape = false; + } + else + { + b.Append(part); + } + + start = i + 1; + continue; } + + shouldEscape = shouldEscape || NeedsEscaping(namespaceString[i], i - start); } + } - private static void AppendMethodString(StringBuilder methodBuilder, string name, int methodArity) + private static void AppendMethodString(StringBuilder methodBuilder, string name, int methodArity) + { + var arityStart = name.LastIndexOf('`'); + var arity = 0; + if (arityStart > 0) { - var arityStart = name.LastIndexOf('`'); - var arity = 0; - if (arityStart > 0) + arityStart++; + var arityString = name.Substring(arityStart, name.Length - arityStart); + if (int.TryParse(arityString, out arity)) { - arityStart++; - var arityString = name.Substring(arityStart, name.Length - arityStart); - if (int.TryParse(arityString, out arity)) + if (arity == methodArity) { - if (arity == methodArity) - { - name = name.Substring(0, arityStart - 1); - } + name = name.Substring(0, arityStart - 1); } } + } - if (IsNormalized(name)) - { - methodBuilder.Append(name); - } - else - { - NormalizeAndAppendString(methodBuilder, name); - } + if (IsNormalized(name)) + { + methodBuilder.Append(name); + } + else + { + NormalizeAndAppendString(methodBuilder, name); + } - if (arity > 0 && methodArity == arity) - { - methodBuilder.Append($"`{arity}"); - } + if (arity > 0 && methodArity == arity) + { + methodBuilder.Append($"`{arity}"); } + } - private static void NormalizeAndAppendString(StringBuilder b, string name) + private static void NormalizeAndAppendString(StringBuilder b, string name) + { + b.Append('\''); + for (int i = 0; i < name.Length; i++) { - b.Append('\''); - for (int i = 0; i < name.Length; i++) + char c = name[i]; + if (NeedsEscaping(c, i)) { - char c = name[i]; - if (NeedsEscaping(c, i)) + if (c == '\\' || c == '\'') { - if (c == '\\' || c == '\'') - { - // var encoded = Convert.ToString(((uint)c), 16); - // b.Append("\\u"); - // b.Append('0', 4 - encoded.Length); - // b.Append(encoded); - - b.Append('\\'); - b.Append(c); - continue; - } - } + // var encoded = Convert.ToString(((uint)c), 16); + // b.Append("\\u"); + // b.Append('0', 4 - encoded.Length); + // b.Append(encoded); - b.Append(c); + b.Append('\\'); + b.Append(c); + continue; + } } - b.Append('\''); + + b.Append(c); } + b.Append('\''); + } - private static int AppendNestedTypeName(StringBuilder b, Type type) + private static int AppendNestedTypeName(StringBuilder b, Type type) + { + var outerArity = 0; + if (type.IsNested) { - var outerArity = 0; - if (type.IsNested) - { - outerArity = AppendNestedTypeName(b, type.DeclaringType); - b.Append('+'); - } + outerArity = AppendNestedTypeName(b, type.DeclaringType); + b.Append('+'); + } - var typeName = type.Name; - var stars = 0; - if (type.IsPointer) + var typeName = type.Name; + var stars = 0; + if (type.IsPointer) + { + for (int i = typeName.Length - 1; i > 0; i--) { - for (int i = typeName.Length - 1; i > 0; i--) + if (typeName[i] != '*') { - if (typeName[i] != '*') - { - stars = typeName.Length - i - 1; - typeName = typeName.Substring(0, i + 1); - break; - } + stars = typeName.Length - i - 1; + typeName = typeName.Substring(0, i + 1); + break; } } + } - var info = type.GetTypeInfo(); - var arity = !info.IsGenericType - ? 0 - : info.GenericTypeParameters.Length > 0 - ? info.GenericTypeParameters.Length - : info.GenericTypeArguments.Length; + var info = type.GetTypeInfo(); + var arity = !info.IsGenericType + ? 0 + : info.GenericTypeParameters.Length > 0 + ? info.GenericTypeParameters.Length + : info.GenericTypeArguments.Length; - AppendMethodString(b, typeName, arity - outerArity); - b.Append('*', stars); - return arity; - } + AppendMethodString(b, typeName, arity - outerArity); + b.Append('*', stars); + return arity; + } - private static void AppendGenericTypeParameters(StringBuilder b, Type type) - { - Type[] genargs; + private static void AppendGenericTypeParameters(StringBuilder b, Type type) + { + Type[] genargs; #if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !WINDOWS_UWP - genargs = type.GetGenericArguments(); + genargs = type.GetGenericArguments(); #else - genargs = type.GetTypeInfo().GenericTypeArguments; + genargs = type.GetTypeInfo().GenericTypeArguments; #endif - if (genargs.Length != 0) - { - b.Append('<'); - foreach (var argType in genargs) - { - AppendTypeString(b, argType, closedType: true); - b.Append(','); - } - // Replace the last ',' with '>' - b[b.Length - 1] = '>'; - } - } - - private static bool IsNormalized(string s) + if (genargs.Length != 0) { - for (int i = 0; i < s.Length; i++) + b.Append('<'); + foreach (var argType in genargs) { - if (NeedsEscaping(s[i], i) && s[i] != '.') - { - return false; - } + AppendTypeString(b, argType, closedType: true); + b.Append(','); } - - return true; + // Replace the last ',' with '>' + b[b.Length - 1] = '>'; } + } - private static bool NeedsEscaping(char c, int pos) + private static bool IsNormalized(string s) + { + for (int i = 0; i < s.Length; i++) { - if (pos == 0 && char.IsDigit(c)) - { - return true; - } - - if (c == '_' - || char.IsLetterOrDigit(c) // Lu, Ll, Lt, Lm, Lo, or Nl - ) + if (NeedsEscaping(s[i], i) && s[i] != '.') { return false; } + } - var category = CharUnicodeInfo.GetUnicodeCategory(c); - if (category == UnicodeCategory.NonSpacingMark // Mn - || category == UnicodeCategory.SpacingCombiningMark // Mc - || category == UnicodeCategory.ConnectorPunctuation // Pc - || category == UnicodeCategory.Format) // Cf - { - return false; - } + return true; + } + private static bool NeedsEscaping(char c, int pos) + { + if (pos == 0 && char.IsDigit(c)) + { return true; } - private static string GetTypeString(Type type, bool closedType) + if (c == '_' + || char.IsLetterOrDigit(c) // Lu, Ll, Lt, Lm, Lo, or Nl + ) + { + return false; + } + + var category = CharUnicodeInfo.GetUnicodeCategory(c); + if (category == UnicodeCategory.NonSpacingMark // Mn + || category == UnicodeCategory.SpacingCombiningMark // Mc + || category == UnicodeCategory.ConnectorPunctuation // Pc + || category == UnicodeCategory.Format) // Cf { - var builder = new StringBuilder(); - AppendTypeString(builder, type, closedType); - return builder.ToString(); + return false; } + return true; + } + + private static string GetTypeString(Type type, bool closedType) + { + var builder = new StringBuilder(); + AppendTypeString(builder, type, closedType); + return builder.ToString(); + } + #if NET20 + // the method is mostly copied from + // https://github.com/dotnet/runtime/blob/c0840723b382bcfa67b35839af8572fcd38f1d13/src/libraries/System.Linq/src/System/Linq/Single.cs#L86 + public static TSource SingleOrDefault(System.Collections.Generic.IEnumerable source) + { + if (source == null) + { + throw new ArgumentNullException(nameof(source)); + } - // the method is mostly copied from - // https://github.com/dotnet/runtime/blob/c0840723b382bcfa67b35839af8572fcd38f1d13/src/libraries/System.Linq/src/System/Linq/Single.cs#L86 - public static TSource SingleOrDefault(System.Collections.Generic.IEnumerable source) + if (source is System.Collections.Generic.IList list) { - if (source == null) + switch (list.Count) { - throw new ArgumentNullException(nameof(source)); + case 0: + return default; + case 1: + return list[0]; } - - if (source is System.Collections.Generic.IList list) + } + else + { + using (System.Collections.Generic.IEnumerator e = source.GetEnumerator()) { - switch (list.Count) + if (!e.MoveNext()) { - case 0: - return default; - case 1: - return list[0]; + return default; } - } - else - { - using (System.Collections.Generic.IEnumerator e = source.GetEnumerator()) + + TSource result = e.Current; + if (!e.MoveNext()) { - if (!e.MoveNext()) - { - return default; - } - - TSource result = e.Current; - if (!e.MoveNext()) - { - return result; - } + return result; } } - - throw new InvalidOperationException("MoreThanOneElement"); } + + throw new InvalidOperationException("MoreThanOneElement"); + } #endif #if NET20 || NET35 - public static bool IsNullOrWhiteSpace(string value) - { - if (value is null) return true; + public static bool IsNullOrWhiteSpace(string value) + { + if (value is null) return true; - for (int i = 0; i < value.Length; i++) + for (int i = 0; i < value.Length; i++) + { + if (!char.IsWhiteSpace(value[i])) { - if (!char.IsWhiteSpace(value[i])) - { - return false; - } + return false; } - - return true; } -#endif + + return true; } +#endif } diff --git a/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/ManagedNameParser.cs b/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/ManagedNameParser.cs index 96226f732e..e3a90e1759 100644 --- a/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/ManagedNameParser.cs +++ b/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/ManagedNameParser.cs @@ -1,267 +1,265 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities +namespace Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities; + +using Microsoft.TestPlatform.AdapterUtilities.Helpers; +using Microsoft.TestPlatform.AdapterUtilities.Resources; + +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; + +public class ManagedNameParser { - using Microsoft.TestPlatform.AdapterUtilities.Helpers; - using Microsoft.TestPlatform.AdapterUtilities.Resources; + /// + /// Parses a given fully qualified managed type name into its namespace and type name. + /// + /// + /// The fully qualified managed type name to parse. + /// The format is defined in the RFC. + /// + /// + /// When this method returns, contains the parsed namespace name of the . + /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. + /// + /// + /// When this method returns, contains the parsed type name of the . + /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. + /// + public static void ParseManagedTypeName(string managedTypeName, out string namespaceName, out string typeName) + { + int pos = managedTypeName.LastIndexOf('.'); + if (pos == -1) + { + namespaceName = string.Empty; + typeName = managedTypeName; + } + else + { + namespaceName = managedTypeName.Substring(0, pos); + typeName = managedTypeName.Substring(pos + 1); + } + } + + /// + /// Parses a given fully qualified managed method name into its name, arity and parameter types. + /// + /// + /// The fully qualified managed method name to parse. + /// The format is defined in the RFC. + /// + /// + /// When this method returns, contains the parsed method name of the . + /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. + /// + /// + /// When this method returns, contains the parsed arity of the . + /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. + /// + /// + /// When this method returns, contains the parsed parameter types of the . + /// If there are no parameter types in , is set to null. + /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. + /// + /// + /// Thrown if contains spaces, incomplete, or the arity isn't numeric. + /// + public static void ParseManagedMethodName(string managedMethodName, out string methodName, out int arity, out string[] parameterTypes) + { + int pos = ParseMethodName(managedMethodName, 0, out var escapedMethodName, out arity); + methodName = ReflectionHelpers.ParseEscapedString(escapedMethodName); + pos = ParseParameterTypeList(managedMethodName, pos, out parameterTypes); + if (pos != managedMethodName.Length) + { + string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorUnexpectedCharactersAtEnd, pos); + throw new InvalidManagedNameException(message); + } + } - using System.Collections.Generic; - using System.Diagnostics; - using System.Globalization; + private static string Capture(string managedMethodName, int start, int end) + => managedMethodName.Substring(start, end - start); - public class ManagedNameParser + private static int ParseMethodName(string managedMethodName, int start, out string methodName, out int arity) { - /// - /// Parses a given fully qualified managed type name into its namespace and type name. - /// - /// - /// The fully qualified managed type name to parse. - /// The format is defined in the RFC. - /// - /// - /// When this method returns, contains the parsed namespace name of the . - /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. - /// - /// - /// When this method returns, contains the parsed type name of the . - /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. - /// - public static void ParseManagedTypeName(string managedTypeName, out string namespaceName, out string typeName) + var i = start; + var quoted = false; + for (; i < managedMethodName.Length; i++) { - int pos = managedTypeName.LastIndexOf('.'); - if (pos == -1) + var c = managedMethodName[i]; + if (c == '\'' || quoted) { - namespaceName = string.Empty; - typeName = managedTypeName; + quoted = c == '\'' ? !quoted : quoted; + continue; } - else + + switch (c) { - namespaceName = managedTypeName.Substring(0, pos); - typeName = managedTypeName.Substring(pos + 1); + case var w when char.IsWhiteSpace(w): + string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorWhitespaceNotValid, i); + throw new InvalidManagedNameException(message); + + case '`': + methodName = Capture(managedMethodName, start, i); + return ParseArity(managedMethodName, i, out arity); + + case '(': + methodName = Capture(managedMethodName, start, i); + arity = 0; + return i; } } + methodName = Capture(managedMethodName, start, i); + arity = 0; + return i; + } - /// - /// Parses a given fully qualified managed method name into its name, arity and parameter types. - /// - /// - /// The fully qualified managed method name to parse. - /// The format is defined in the RFC. - /// - /// - /// When this method returns, contains the parsed method name of the . - /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. - /// - /// - /// When this method returns, contains the parsed arity of the . - /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. - /// - /// - /// When this method returns, contains the parsed parameter types of the . - /// If there are no parameter types in , is set to null. - /// This parameter is passed uninitialized; any value originally supplied in result will be overwritten. - /// - /// - /// Thrown if contains spaces, incomplete, or the arity isn't numeric. - /// - public static void ParseManagedMethodName(string managedMethodName, out string methodName, out int arity, out string[] parameterTypes) + // parse arity in the form `nn where nn is an integer value. + private static int ParseArity(string managedMethodName, int start, out int arity) + { + Debug.Assert(managedMethodName[start] == '`'); + + int i = start + 1; // skip initial '`' char + for (; i < managedMethodName.Length; i++) { - int pos = ParseMethodName(managedMethodName, 0, out var escapedMethodName, out arity); - methodName = ReflectionHelpers.ParseEscapedString(escapedMethodName); - pos = ParseParameterTypeList(managedMethodName, pos, out parameterTypes); - if (pos != managedMethodName.Length) - { - string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorUnexpectedCharactersAtEnd, pos); - throw new InvalidManagedNameException(message); - } + if (managedMethodName[i] == '(') break; + } + if (!int.TryParse(Capture(managedMethodName, start + 1, i), out arity)) + { + string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorMethodArityMustBeNumeric); + throw new InvalidManagedNameException(message); + } + return i; + } + + private static int ParseParameterTypeList(string managedMethodName, int start, out string[] parameterTypes) + { + parameterTypes = null; + if (start == managedMethodName.Length) + { + return start; } + Debug.Assert(managedMethodName[start] == '('); - private static string Capture(string managedMethodName, int start, int end) - => managedMethodName.Substring(start, end - start); + var types = new List(); - private static int ParseMethodName(string managedMethodName, int start, out string methodName, out int arity) + int i = start + 1; // skip initial '(' char + for (; i < managedMethodName.Length; i++) { - var i = start; - var quoted = false; - for (; i < managedMethodName.Length; i++) + switch (managedMethodName[i]) { - var c = managedMethodName[i]; - if (c == '\'' || quoted) - { - quoted = c == '\'' ? !quoted : quoted; - continue; - } - - switch (c) - { - case var w when char.IsWhiteSpace(w): - string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorWhitespaceNotValid, i); - throw new InvalidManagedNameException(message); - - case '`': - methodName = Capture(managedMethodName, start, i); - return ParseArity(managedMethodName, i, out arity); - - case '(': - methodName = Capture(managedMethodName, start, i); - arity = 0; - return i; - } + case ')': + if (types.Count != 0) + { + parameterTypes = types.ToArray(); + } + return i + 1; // consume right parens + + case ',': + break; + + default: + i = ParseParameterType(managedMethodName, i, out var parameterType); + types.Add(parameterType); + break; } - methodName = Capture(managedMethodName, start, i); - arity = 0; - return i; } - // parse arity in the form `nn where nn is an integer value. - private static int ParseArity(string managedMethodName, int start, out int arity) - { - arity = 0; - Debug.Assert(managedMethodName[start] == '`'); + string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorIncompleteManagedName); + throw new InvalidManagedNameException(message); + } - int i = start + 1; // skip initial '`' char - for (; i < managedMethodName.Length; i++) + private static int ParseParameterType(string managedMethodName, int start, out string parameterType) + { + parameterType = string.Empty; + var quoted = false; + + int i; + for (i = start; i < managedMethodName.Length; i++) + { + if (managedMethodName[i] == '\'' || quoted) { - if (managedMethodName[i] == '(') break; + quoted = managedMethodName[i] == '\'' ? !quoted : quoted; + continue; } - if (!int.TryParse(Capture(managedMethodName, start + 1, i), out arity)) + + switch (managedMethodName[i]) { - string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorMethodArityMustBeNumeric); - throw new InvalidManagedNameException(message); + case '<': + i = ParseGenericBrackets(managedMethodName, i + 1); + break; + + case '[': + i = ParseArrayBrackets(managedMethodName, i + 1); + break; + + case ',': + case ')': + parameterType = Capture(managedMethodName, start, i); + return i - 1; + + case var w when char.IsWhiteSpace(w): + string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorWhitespaceNotValid, i); + throw new InvalidManagedNameException(message); } - return i; } + return i; + } + + private static int ParseArrayBrackets(string managedMethodName, int start) + { + var quoted = false; - private static int ParseParameterTypeList(string managedMethodName, int start, out string[] parameterTypes) + for (int i = start; i < managedMethodName.Length; i++) { - parameterTypes = null; - if (start == managedMethodName.Length) + if (managedMethodName[i] == '\'' || quoted) { - return start; + quoted = managedMethodName[i] == '\'' ? !quoted : quoted; + continue; } - Debug.Assert(managedMethodName[start] == '('); - - var types = new List(); - int i = start + 1; // skip initial '(' char - for (; i < managedMethodName.Length; i++) + switch (managedMethodName[i]) { - switch (managedMethodName[i]) - { - case ')': - if (types.Count != 0) - { - parameterTypes = types.ToArray(); - } - return i + 1; // consume right parens - - case ',': - break; - - default: - i = ParseParameterType(managedMethodName, i, out var parameterType); - types.Add(parameterType); - break; - } + case ']': + return i; + case var w when char.IsWhiteSpace(w): + string msg = string.Format(CultureInfo.CurrentCulture, Resources.ErrorWhitespaceNotValid, i); + throw new InvalidManagedNameException(msg); } - - string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorIncompleteManagedName); - throw new InvalidManagedNameException(message); } - private static int ParseParameterType(string managedMethodName, int start, out string parameterType) - { - parameterType = string.Empty; - var quoted = false; + string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorIncompleteManagedName); + throw new InvalidManagedNameException(message); + } - int i = start; - for (i = start; i < managedMethodName.Length; i++) - { - if (managedMethodName[i] == '\'' || quoted) - { - quoted = managedMethodName[i] == '\'' ? !quoted : quoted; - continue; - } - - switch (managedMethodName[i]) - { - case '<': - i = ParseGenericBrackets(managedMethodName, i + 1); - break; - - case '[': - i = ParseArrayBrackets(managedMethodName, i + 1); - break; - - case ',': - case ')': - parameterType = Capture(managedMethodName, start, i); - return i - 1; - - case var w when char.IsWhiteSpace(w): - string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorWhitespaceNotValid, i); - throw new InvalidManagedNameException(message); - } - } - return i; - } + private static int ParseGenericBrackets(string managedMethodName, int start) + { + var quoted = false; - private static int ParseArrayBrackets(string managedMethodName, int start) + for (int i = start; i < managedMethodName.Length; i++) { - var quoted = false; - - for (int i = start; i < managedMethodName.Length; i++) + if (managedMethodName[i] == '\'' || quoted) { - if (managedMethodName[i] == '\'' || quoted) - { - quoted = managedMethodName[i] == '\'' ? !quoted : quoted; - continue; - } - - switch (managedMethodName[i]) - { - case ']': - return i; - case var w when char.IsWhiteSpace(w): - string msg = string.Format(CultureInfo.CurrentCulture, Resources.ErrorWhitespaceNotValid, i); - throw new InvalidManagedNameException(msg); - } + quoted = managedMethodName[i] == '\'' ? !quoted : quoted; + continue; } - string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorIncompleteManagedName); - throw new InvalidManagedNameException(message); - } + switch (managedMethodName[i]) + { + case '<': + i = ParseGenericBrackets(managedMethodName, i + 1); + break; - private static int ParseGenericBrackets(string managedMethodName, int start) - { - var quoted = false; + case '>': + return i; - for (int i = start; i < managedMethodName.Length; i++) - { - if (managedMethodName[i] == '\'' || quoted) - { - quoted = managedMethodName[i] == '\'' ? !quoted : quoted; - continue; - } - - switch (managedMethodName[i]) - { - case '<': - i = ParseGenericBrackets(managedMethodName, i + 1); - break; - - case '>': - return i; - - case var w when char.IsWhiteSpace(w): - string msg = string.Format(CultureInfo.CurrentCulture, Resources.ErrorWhitespaceNotValid, i); - throw new InvalidManagedNameException(msg); - } + case var w when char.IsWhiteSpace(w): + string msg = string.Format(CultureInfo.CurrentCulture, Resources.ErrorWhitespaceNotValid, i); + throw new InvalidManagedNameException(msg); } - - string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorIncompleteManagedName); - throw new InvalidManagedNameException(message); } + + string message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorIncompleteManagedName); + throw new InvalidManagedNameException(message); } } diff --git a/src/Microsoft.TestPlatform.AdapterUtilities/TestIdProvider.cs b/src/Microsoft.TestPlatform.AdapterUtilities/TestIdProvider.cs index 7df8ce8cc2..89916480c8 100644 --- a/src/Microsoft.TestPlatform.AdapterUtilities/TestIdProvider.cs +++ b/src/Microsoft.TestPlatform.AdapterUtilities/TestIdProvider.cs @@ -1,382 +1,370 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AdapterUtilities +namespace Microsoft.TestPlatform.AdapterUtilities; + +using System; +using System.Text; + +public class TestIdProvider { - using System; - using System.Text; + internal const int BlockBits = 512; + internal const int DigestBits = 160; + internal const int BlockBytes = BlockBits / 8; + internal const int DigestBytes = DigestBits / 8; + + private Guid _id = Guid.Empty; + private byte[] _hash = null; + private byte[] _lastBlock = new byte[BlockBytes]; + private int _position = 0; + + private readonly Sha1Implementation _hasher; - public class TestIdProvider + public TestIdProvider() { - internal const int BlockBits = 512; - internal const int DigestBits = 160; - internal const int BlockBytes = BlockBits / 8; - internal const int DigestBytes = DigestBits / 8; + _hasher = new Sha1Implementation(); + } - private Guid id = Guid.Empty; - private byte[] hash = null; - private byte[] lastBlock = new byte[BlockBytes]; - private int position = 0; + public void AppendString(string str) + { + if (_hash != null) + { + throw new InvalidOperationException(); + } + + var bytes = Encoding.Unicode.GetBytes(str); + var end = Math.Min(BlockBytes - _position, bytes.Length); + + Buffer.BlockCopy(bytes, 0, _lastBlock, _position, end); + + // Block length is not reached yet. + if (end + _position < BlockBytes) + { + _position += end; + return; + } - private readonly Sha1Implementation hasher; + _hasher.ProcessBlock(_lastBlock, 0, _lastBlock.Length); + _position = 0; - public TestIdProvider() + // We processed the entire string already + if (end == bytes.Length) { - hasher = new Sha1Implementation(); + return; } - public void AppendString(string str) + int start = 0; + while (end < bytes.Length) { - if (hash != null) + start = end; + end += BlockBytes; + if (end > bytes.Length) { - throw new InvalidOperationException(); + break; } - var bytes = Encoding.Unicode.GetBytes(str); - var end = Math.Min(BlockBytes - position, bytes.Length); + _hasher.ProcessBlock(bytes, start, end - start); + } - Buffer.BlockCopy(bytes, 0, lastBlock, position, end); + if (end > bytes.Length) + { + _position = bytes.Length - start; + Buffer.BlockCopy(bytes, start, _lastBlock, 0, _position); + } + } - // Block length is not reached yet. - if (end + position < BlockBytes) - { - position += end; - return; - } + public byte[] GetHash() + { + if (_hash != null) + { + return _hash; + } - hasher.ProcessBlock(lastBlock, 0, lastBlock.Length); - position = 0; + if (_position != 0) + { + _hasher.PadMessage(ref _lastBlock, _position); + _hasher.ProcessBlock(_lastBlock, 0, _lastBlock.Length); + } + + _hash = _hasher.ProcessFinalBlock(); + + return _hash; + } + + public Guid GetId() + { + if (_id != Guid.Empty) + { + return _id; + } + + var toGuid = new byte[16]; + Array.Copy(GetHash(), toGuid, 16); + _id = new Guid(toGuid); + + return _id; + } + + /// + /// SHA-1 Implementation as in https://tools.ietf.org/html/rfc3174 + /// + /// + /// This implementation only works with messages with a length + /// that is a multiple of the size of 8-bits. + /// + internal class Sha1Implementation + { + /* + * Many of the variable, function and parameter names in this code + * were used because those were the names used in the publication. + * + * For more information please refer to https://tools.ietf.org/html/rfc3174. + */ - // We processed the entire string already - if (end == bytes.Length) + private int _streamSize = 0; + private bool _messagePadded = false; + + public Sha1Implementation() + { + Reset(); + } + + /// + /// A sequence of logical functions to be used in SHA-1. + /// Each f(t), 0 <= t <= 79, operates on three 32-bit words B, C, D and produces a 32-bit word as output. + /// + /// Function index. 0 <= t <= 79 + /// Word B + /// Word C + /// Word D + /// + /// f(t;B,C,D) = (B AND C) OR ((NOT B) AND D) ( 0 <= t <= 19) + /// f(t;B,C,D) = B XOR C XOR D (20 <= t <= 39) + /// f(t;B,C,D) = (B AND C) OR (B AND D) OR (C AND D) (40 <= t <= 59) + /// f(t;B,C,D) = B XOR C XOR D (60 <= t <= 79) + /// + private static uint F(int t, uint b, uint c, uint d) + { + if (t >= 0 && t <= 19) { - return; + return (b & c) | (~b & d); } - - int start = 0; - while (end < bytes.Length) + else if ((t >= 20 && t <= 39) || (t >= 60 && t <= 79)) { - start = end; - end += BlockBytes; - if (end > bytes.Length) - { - break; - } - - hasher.ProcessBlock(bytes, start, end - start); + return b ^ c ^ d; } - - if (end > bytes.Length) + else { - position = bytes.Length - start; - Buffer.BlockCopy(bytes, start, lastBlock, 0, position); + return t >= 40 && t <= 59 + ? (b & c) | (b & d) | (c & d) + : throw new ArgumentException("Argument out of bounds! 0 <= t < 80", nameof(t)); } } - public byte[] GetHash() + /// + /// Returns a constant word K(t) which is used in the SHA-1. + /// + /// Word index. + /// + /// K(t) = 0x5A827999 ( 0 <= t <= 19) + /// K(t) = 0x6ED9EBA1 (20 <= t <= 39) + /// K(t) = 0x8F1BBCDC (40 <= t <= 59) + /// K(t) = 0xCA62C1D6 (60 <= t <= 79) + /// + private static uint K(int t) { - if (hash != null) + if (t >= 0 && t <= 19) { - return hash; + return 0x5A827999u; } - - if (position != 0) + else if (t >= 20 && t <= 39) { - hasher.PadMessage(ref lastBlock, position); - hasher.ProcessBlock(lastBlock, 0, lastBlock.Length); + return 0x6ED9EBA1u; } + else if (t >= 40 && t <= 59) + { + return 0x8F1BBCDCu; + } + else + { + return t >= 60 && t <= 79 ? 0xCA62C1D6u : throw new ArgumentException("Argument out of bounds! 0 <= t < 80", nameof(t)); + } + } - hash = hasher.ProcessFinalBlock(); - - return hash; + /// + /// The circular left shift operation. + /// + /// An uint word. + /// 0 <= n < 32 + /// S^n(X) = (X << n) OR (X >> 32-n) + private static uint S(uint x, byte n) + { + return n > 32 ? throw new ArgumentOutOfRangeException(nameof(n)) : (x << n) | (x >> (32 - n)); } - public Guid GetId() + /// + /// Ensures that given bytes are in big endian notation. + /// + /// An array of bytes + private static void EnsureBigEndian(ref byte[] array) { - if (id != Guid.Empty) + if (BitConverter.IsLittleEndian) { - return id; + Array.Reverse(array); } + } - var toGuid = new byte[16]; - Array.Copy(GetHash(), toGuid, 16); - id = new Guid(toGuid); + private readonly uint[] _h = new uint[5]; - return id; + private void Reset() + { + _streamSize = 0; + _messagePadded = false; + + // as defined in https://tools.ietf.org/html/rfc3174#section-6.1 + _h[0] = 0x67452301u; + _h[1] = 0xEFCDAB89u; + _h[2] = 0x98BADCFEu; + _h[3] = 0x10325476u; + _h[4] = 0xC3D2E1F0u; } - /// - /// SHA-1 Implementation as in https://tools.ietf.org/html/rfc3174 - /// - /// - /// This implementation only works with messages with a length - /// that is a multiple of the size of 8-bits. - /// - internal class Sha1Implementation + public byte[] ComputeHash(byte[] message) { - /* - * Many of the variable, function and parameter names in this code - * were used because those were the names used in the publication. - * - * For more information please refer to https://tools.ietf.org/html/rfc3174. - */ + Reset(); + _streamSize = 0; + PadMessage(ref message); - private int streamSize = 0; - private bool messagePadded = false; + ProcessBlock(message, 0, message.Length); - public Sha1Implementation() - { - Reset(); - } + return ProcessFinalBlock(); + } - /// - /// A sequence of logical functions to be used in SHA-1. - /// Each f(t), 0 <= t <= 79, operates on three 32-bit words B, C, D and produces a 32-bit word as output. - /// - /// Function index. 0 <= t <= 79 - /// Word B - /// Word C - /// Word D - /// - /// f(t;B,C,D) = (B AND C) OR ((NOT B) AND D) ( 0 <= t <= 19) - /// f(t;B,C,D) = B XOR C XOR D (20 <= t <= 39) - /// f(t;B,C,D) = (B AND C) OR (B AND D) OR (C AND D) (40 <= t <= 59) - /// f(t;B,C,D) = B XOR C XOR D (60 <= t <= 79) - /// - private static uint F(int t, uint B, uint C, uint D) + private void ProcessMultipleBlocks(byte[] message) + { + var messageCount = message.Length / BlockBytes; + for (var i = 0; i < messageCount; i += 1) { - if (t >= 0 && t <= 19) - { - return (B & C) | (~B & D); - } - else if ((t >= 20 && t <= 39) || (t >= 60 && t <= 79)) - { - return B ^ C ^ D; - } - else if (t >= 40 && t <= 59) - { - return (B & C) | (B & D) | (C & D); - } - else - { - throw new ArgumentException("Argument out of bounds! 0 <= t < 80", nameof(t)); - } + ProcessBlock(message, i * BlockBytes, BlockBytes); } + } - /// - /// Returns a constant word K(t) which is used in the SHA-1. - /// - /// Word index. - /// - /// K(t) = 0x5A827999 ( 0 <= t <= 19) - /// K(t) = 0x6ED9EBA1 (20 <= t <= 39) - /// K(t) = 0x8F1BBCDC (40 <= t <= 59) - /// K(t) = 0xCA62C1D6 (60 <= t <= 79) - /// - private static uint K(int t) + public byte[] ProcessFinalBlock() + { + if (!_messagePadded) { - if (t >= 0 && t <= 19) - { - return 0x5A827999u; - } - else if (t >= 20 && t <= 39) - { - return 0x6ED9EBA1u; - } - else if (t >= 40 && t <= 59) - { - return 0x8F1BBCDCu; - } - else if (t >= 60 && t <= 79) - { - return 0xCA62C1D6u; - } - else - { - throw new ArgumentException("Argument out of bounds! 0 <= t < 80", nameof(t)); - } + var pad = new byte[0]; + PadMessage(ref pad, 0); + ProcessBlock(pad, 0, pad.Length); } - /// - /// The circular left shift operation. - /// - /// An uint word. - /// 0 <= n < 32 - /// S^n(X) = (X << n) OR (X >> 32-n) - private static uint S(uint X, byte n) + var digest = new byte[DigestBytes]; + for (int t = 0; t < _h.Length; t++) { - if (n > 32) - { - throw new ArgumentOutOfRangeException(nameof(n)); - } + var hi = BitConverter.GetBytes(_h[t]); + EnsureBigEndian(ref hi); - return (X << n) | (X >> (32 - n)); - } - - /// - /// Ensures that given bytes are in big endian notation. - /// - /// An array of bytes - private static void EnsureBigEndian(ref byte[] array) - { - if (BitConverter.IsLittleEndian) - { - Array.Reverse(array); - } + Buffer.BlockCopy(hi, 0, digest, t * hi.Length, hi.Length); } - private readonly uint[] H = new uint[5]; + return digest; + } - private void Reset() + public void PadMessage(ref byte[] message, int length = 0) + { + if (_messagePadded) { - streamSize = 0; - messagePadded = false; - - // as defined in https://tools.ietf.org/html/rfc3174#section-6.1 - H[0] = 0x67452301u; - H[1] = 0xEFCDAB89u; - H[2] = 0x98BADCFEu; - H[3] = 0x10325476u; - H[4] = 0xC3D2E1F0u; + throw new InvalidOperationException(); } - public byte[] ComputeHash(byte[] message) + if (length == 0) { - Reset(); - streamSize = 0; - PadMessage(ref message); - - ProcessBlock(message, 0, message.Length); - - return ProcessFinalBlock(); + length = message.Length; } - - private void ProcessMultipleBlocks(byte[] message) + else { - var messageCount = message.Length / BlockBytes; - for (var i = 0; i < messageCount; i += 1) - { - ProcessBlock(message, i * BlockBytes, BlockBytes); - } + Array.Resize(ref message, length); } - public byte[] ProcessFinalBlock() - { - if (!messagePadded) - { - var pad = new byte[0]; - PadMessage(ref pad, 0); - ProcessBlock(pad, 0, pad.Length); - } - - var digest = new byte[DigestBytes]; - for (int t = 0; t < H.Length; t++) - { - var hi = BitConverter.GetBytes(H[t]); - EnsureBigEndian(ref hi); - - Buffer.BlockCopy(hi, 0, digest, t * hi.Length, hi.Length); - } - - return digest; - } + _streamSize += length; - public void PadMessage(ref byte[] message, int length = 0) - { - if (messagePadded) - { - throw new InvalidOperationException(); - } + var paddingBytes = BlockBytes - (length % BlockBytes); - if (length == 0) - { - length = message.Length; - } - else - { - Array.Resize(ref message, length); - } + // 64bit uint message size will be appended to end of the padding, making sure we have space for it. + if (paddingBytes <= 8) + paddingBytes += BlockBytes; - streamSize += length; + var padding = new byte[paddingBytes]; + padding[0] = 0b10000000; - var paddingBytes = BlockBytes - (length % BlockBytes); + var messageBits = (ulong)_streamSize << 3; + var messageSize = BitConverter.GetBytes(messageBits); + EnsureBigEndian(ref messageSize); - // 64bit uint message size will be appended to end of the padding, making sure we have space for it. - if (paddingBytes <= 8) - paddingBytes += BlockBytes; + Buffer.BlockCopy(messageSize, 0, padding, padding.Length - messageSize.Length, messageSize.Length); - var padding = new byte[paddingBytes]; - padding[0] = 0b10000000; + Array.Resize(ref message, message.Length + padding.Length); + Buffer.BlockCopy(padding, 0, message, length, padding.Length); - var messageBits = (ulong)streamSize << 3; - var messageSize = BitConverter.GetBytes(messageBits); - EnsureBigEndian(ref messageSize); + _messagePadded = true; + } - Buffer.BlockCopy(messageSize, 0, padding, padding.Length - messageSize.Length, messageSize.Length); + public void ProcessBlock(byte[] message, int start, int length) + { + if (start + length > message.Length) + { + throw new ArgumentOutOfRangeException(nameof(length)); + } + if (length % BlockBytes != 0) + { + throw new ArgumentException($"Invalid block size. Actual: {length}, Expected: Multiples of {BlockBytes}", nameof(length)); + } + if (length != BlockBytes) + { + ProcessMultipleBlocks(message); + return; + } + + _streamSize += BlockBytes; + var w = new uint[80]; - Array.Resize(ref message, message.Length + padding.Length); - Buffer.BlockCopy(padding, 0, message, length, padding.Length); + // Get W(0) .. W(15) + for (int t = 0; t <= 15; t++) + { + var wordBytes = new byte[sizeof(uint)]; + Buffer.BlockCopy(message, start + (t * sizeof(uint)), wordBytes, 0, sizeof(uint)); + EnsureBigEndian(ref wordBytes); + + w[t] = BitConverter.ToUInt32(wordBytes, 0); + } - messagePadded = true; + // Calculate W(16) .. W(79) + for (int t = 16; t <= 79; t++) + { + w[t] = S(w[t - 3] ^ w[t - 8] ^ w[t - 14] ^ w[t - 16], 1); } - public void ProcessBlock(byte[] message, int start, int length) + uint a = _h[0], + b = _h[1], + c = _h[2], + d = _h[3], + e = _h[4]; + + for (int t = 0; t < 80; t++) { - if (start + length > message.Length) - { - throw new ArgumentOutOfRangeException(nameof(length)); - } - if (length % BlockBytes != 0) - { - throw new ArgumentException($"Invalid block size. Actual: {length}, Expected: Multiples of {BlockBytes}", nameof(length)); - } - if (length != BlockBytes) - { - ProcessMultipleBlocks(message); - return; - } - - streamSize += BlockBytes; - var W = new uint[80]; - - // Get W(0) .. W(15) - for (int t = 0; t <= 15; t++) - { - var wordBytes = new byte[sizeof(uint)]; - Buffer.BlockCopy(message, start + (t * sizeof(uint)), wordBytes, 0, sizeof(uint)); - EnsureBigEndian(ref wordBytes); - - W[t] = BitConverter.ToUInt32(wordBytes, 0); - } - - // Calculate W(16) .. W(79) - for (int t = 16; t <= 79; t++) - { - W[t] = S(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1); - } - - uint A = H[0], - B = H[1], - C = H[2], - D = H[3], - E = H[4]; - - for (int t = 0; t < 80; t++) - { - var temp = S(A, 5) + F(t, B, C, D) + E + W[t] + K(t); - E = D; - D = C; - C = S(B, 30); - B = A; - A = temp; - } - - H[0] += A; - H[1] += B; - H[2] += C; - H[3] += D; - H[4] += E; + var temp = S(a, 5) + F(t, b, c, d) + e + w[t] + K(t); + e = d; + d = c; + c = S(b, 30); + b = a; + a = temp; } + + _h[0] += a; + _h[1] += b; + _h[2] += c; + _h[3] += d; + _h[4] += e; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Build/ArgumentEscaper.cs b/src/Microsoft.TestPlatform.Build/ArgumentEscaper.cs index 86178efb95..42383db561 100644 --- a/src/Microsoft.TestPlatform.Build/ArgumentEscaper.cs +++ b/src/Microsoft.TestPlatform.Build/ArgumentEscaper.cs @@ -1,102 +1,100 @@ -using System; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; using System.Text; -namespace Microsoft.TestPlatform.Build.Utils +namespace Microsoft.TestPlatform.Build.Utils; + +public static class ArgumentEscaper { - public static class ArgumentEscaper + /// + /// Undo the processing which took place to create string[] args in Main, + /// so that the next process will receive the same string[] args + /// + /// See here for more info: + /// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx + /// + /// + /// Return original string passed by client + public static string HandleEscapeSequenceInArgForProcessStart(string arg) { - /// - /// Undo the processing which took place to create string[] args in Main, - /// so that the next process will receive the same string[] args - /// - /// See here for more info: - /// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx - /// - /// - /// Return original string passed by client - public static string HandleEscapeSequenceInArgForProcessStart(string arg) + var sb = new StringBuilder(); + + var needsQuotes = ShouldSurroundWithQuotes(arg); + var isQuoted = needsQuotes || IsSurroundedWithQuotes(arg); + + if (needsQuotes) { - var sb = new StringBuilder(); + sb.Append('\"'); + } - var needsQuotes = ShouldSurroundWithQuotes(arg); - var isQuoted = needsQuotes || IsSurroundedWithQuotes(arg); + for (int i = 0; i < arg.Length; ++i) + { + var backslashCount = 0; - if (needsQuotes) + // Consume All Backslashes + while (i < arg.Length && arg[i] == '\\') { - sb.Append('\"'); + backslashCount++; + i++; } - for (int i = 0; i < arg.Length; ++i) + // Escape any backslashes at the end of the arg + // when the argument is also quoted. + // This ensures the outside quote is interpreted as + // an argument delimiter + if (i == arg.Length && isQuoted) { - var backslashCount = 0; - - // Consume All Backslashes - while (i < arg.Length && arg[i] == '\\') - { - backslashCount++; - i++; - } - - // Escape any backslashes at the end of the arg - // when the argument is also quoted. - // This ensures the outside quote is interpreted as - // an argument delimiter - if (i == arg.Length && isQuoted) - { - sb.Append('\\', 2 * backslashCount); - } - - // At then end of the arg, which isn't quoted, - // just add the backslashes, no need to escape - else if (i == arg.Length) - { - sb.Append('\\', backslashCount); - } - - // Escape any preceding backslashes and the quote - else if (arg[i] == '"') - { - sb.Append('\\', (2 * backslashCount) + 1); - sb.Append('"'); - } - - // Output any consumed backslashes and the character - else - { - sb.Append('\\', backslashCount); - sb.Append(arg[i]); - } + sb.Append('\\', 2 * backslashCount); } - if (needsQuotes) + // At then end of the arg, which isn't quoted, + // just add the backslashes, no need to escape + else if (i == arg.Length) { - sb.Append('\"'); + sb.Append('\\', backslashCount); } - return sb.ToString(); - } - - internal static bool ShouldSurroundWithQuotes(string argument) - { - // Don't quote already quoted strings - if (IsSurroundedWithQuotes(argument)) + // Escape any preceding backslashes and the quote + else if (arg[i] == '"') { - return false; + sb.Append('\\', (2 * backslashCount) + 1); + sb.Append('"'); } - // Only quote if whitespace exists in the string - return ArgumentContainsWhitespace(argument); + // Output any consumed backslashes and the character + else + { + sb.Append('\\', backslashCount); + sb.Append(arg[i]); + } } - internal static bool IsSurroundedWithQuotes(string argument) + if (needsQuotes) { - return argument.StartsWith("\"", StringComparison.Ordinal) && - argument.EndsWith("\"", StringComparison.Ordinal); + sb.Append('\"'); } - internal static bool ArgumentContainsWhitespace(string argument) + return sb.ToString(); + } + + internal static bool ShouldSurroundWithQuotes(string argument) + { + // Don't quote already quoted strings + if (IsSurroundedWithQuotes(argument)) { - return argument.Contains(" ") || argument.Contains("\t") || argument.Contains("\n"); + return false; } + + // Only quote if whitespace exists in the string + return ArgumentContainsWhitespace(argument); } -} + + internal static bool IsSurroundedWithQuotes(string argument) + => argument.StartsWith("\"", StringComparison.Ordinal) + && argument.EndsWith("\"", StringComparison.Ordinal); + + internal static bool ArgumentContainsWhitespace(string argument) + => argument.Contains(" ") || argument.Contains("\t") || argument.Contains("\n"); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Build/Tasks/VSTestForwardingApp.cs b/src/Microsoft.TestPlatform.Build/Tasks/VSTestForwardingApp.cs index 0131b222d5..921bfb900c 100644 --- a/src/Microsoft.TestPlatform.Build/Tasks/VSTestForwardingApp.cs +++ b/src/Microsoft.TestPlatform.Build/Tasks/VSTestForwardingApp.cs @@ -1,64 +1,63 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Build.Tasks +namespace Microsoft.TestPlatform.Build.Tasks; + +using Utils; + +using System; +using System.Collections.Generic; +using System.Diagnostics; + +using Trace; + +public class VSTestForwardingApp { - using Microsoft.TestPlatform.Build.Utils; - using System; - using System.Collections.Generic; - using System.Diagnostics; - using Trace; + private const string HostExe = "dotnet"; + private readonly List _allArgs = new(); + private int _activeProcessId; - public class VSTestForwardingApp + public VSTestForwardingApp(string vsTestExePath, IEnumerable argsToForward) { - private const string hostExe = "dotnet"; - private readonly List allArgs = new List(); - private int activeProcessId; + _allArgs.Add("exec"); - public VSTestForwardingApp(string vsTestExePath, IEnumerable argsToForward) - { - this.allArgs.Add("exec"); - - // Ensure that path to vstest.console is whitespace friendly. User may install - // dotnet-cli to any folder containing whitespace (e.g. VS installs to program files). - // Arguments are already whitespace friendly. - this.allArgs.Add(ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(vsTestExePath)); - this.allArgs.AddRange(argsToForward); - } + // Ensure that path to vstest.console is whitespace friendly. User may install + // dotnet-cli to any folder containing whitespace (e.g. VS installs to program files). + // Arguments are already whitespace friendly. + _allArgs.Add(ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(vsTestExePath)); + _allArgs.AddRange(argsToForward); + } - public int Execute() + public int Execute() + { + var processInfo = new ProcessStartInfo { - var processInfo = new ProcessStartInfo - { - FileName = hostExe, - Arguments = string.Join(" ", this.allArgs), - UseShellExecute = false, - }; + FileName = HostExe, + Arguments = string.Join(" ", _allArgs), + UseShellExecute = false, + }; - Tracing.Trace("VSTest: Starting vstest.console..."); - Tracing.Trace("VSTest: Arguments: " + processInfo.FileName + " " + processInfo.Arguments); + Tracing.Trace("VSTest: Starting vstest.console..."); + Tracing.Trace("VSTest: Arguments: " + processInfo.FileName + " " + processInfo.Arguments); - using (var activeProcess = new Process { StartInfo = processInfo }) - { - activeProcess.Start(); - this.activeProcessId = activeProcess.Id; + using var activeProcess = new Process { StartInfo = processInfo }; + activeProcess.Start(); + _activeProcessId = activeProcess.Id; - activeProcess.WaitForExit(); - Tracing.Trace("VSTest: Exit code: " + activeProcess.ExitCode); - return activeProcess.ExitCode; - } - } + activeProcess.WaitForExit(); + Tracing.Trace("VSTest: Exit code: " + activeProcess.ExitCode); + return activeProcess.ExitCode; + } - public void Cancel() + public void Cancel() + { + try + { + Process.GetProcessById(_activeProcessId).Kill(); + } + catch (ArgumentException ex) { - try - { - Process.GetProcessById(activeProcessId).Kill(); - } - catch(ArgumentException ex) - { - Tracing.Trace(string.Format("VSTest: Killing process throws ArgumentException with the following message {0}. It may be that process is not running", ex)); - } + Tracing.Trace(string.Format("VSTest: Killing process throws ArgumentException with the following message {0}. It may be that process is not running", ex)); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Build/Tasks/VSTestLogsTask.cs b/src/Microsoft.TestPlatform.Build/Tasks/VSTestLogsTask.cs index e50edf4b3e..466e4954c1 100644 --- a/src/Microsoft.TestPlatform.Build/Tasks/VSTestLogsTask.cs +++ b/src/Microsoft.TestPlatform.Build/Tasks/VSTestLogsTask.cs @@ -1,47 +1,48 @@ -// Copyright(c) Microsoft Corporation.All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Build.Tasks +namespace Microsoft.TestPlatform.Build.Tasks; + +using System; + +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +using Resources; + +public class VSTestLogsTask : Task { - using System; - using Microsoft.Build.Framework; - using Microsoft.Build.Utilities; - using Microsoft.TestPlatform.Build.Resources; + public string LogType + { + get; + set; + } + + public string ProjectFilePath + { + get; + set; + } - public class VSTestLogsTask : Task + public override bool Execute() { - public string LogType + if (string.Equals(LogType, "BuildStarted", StringComparison.OrdinalIgnoreCase)) { - get; - set; + Log.LogMessage(MessageImportance.Normal, Resources.BuildStarted); } - - public string ProjectFilePath + else if (string.Equals(LogType, "BuildCompleted", StringComparison.OrdinalIgnoreCase)) { - get; - set; + Log.LogMessage(MessageImportance.Normal, Resources.BuildCompleted + Environment.NewLine); } - - public override bool Execute() + else if (string.Equals(LogType, "NoIsTestProjectProperty", StringComparison.OrdinalIgnoreCase)) { - if (string.Equals(LogType, "BuildStarted", StringComparison.OrdinalIgnoreCase)) - { - Log.LogMessage(MessageImportance.Normal, Resources.BuildStarted); - } - else if (string.Equals(LogType, "BuildCompleted", StringComparison.OrdinalIgnoreCase)) - { - Log.LogMessage(MessageImportance.Normal, Resources.BuildCompleted + Environment.NewLine); - } - else if (string.Equals(LogType, "NoIsTestProjectProperty", StringComparison.OrdinalIgnoreCase)) - { - Log.LogMessage(MessageImportance.Low, Resources.NoIsTestProjectProperty); - } - else - { - return false; - } - - return true; + Log.LogMessage(MessageImportance.Low, Resources.NoIsTestProjectProperty); } + else + { + return false; + } + + return true; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs b/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs index 2ded9cc953..aa3360ca57 100644 --- a/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs +++ b/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs @@ -1,420 +1,421 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Build.Tasks +namespace Microsoft.TestPlatform.Build.Tasks; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading; + +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; +using Resources; +using Utils; + +using Trace; + +public class VSTestTask : Task, ICancelableTask { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Linq; - using System.Threading; - using Microsoft.Build.Framework; - using Microsoft.Build.Utilities; - using Microsoft.TestPlatform.Build.Resources; - using Microsoft.TestPlatform.Build.Utils; - using Trace; - - public class VSTestTask : Task, ICancelableTask + // The process which is invoking vstest.console + private VSTestForwardingApp _vsTestForwardingApp; + + private const string VsTestAppName = "vstest.console.dll"; + private const string CodeCovergaeString = "Code Coverage"; + + public string TestFileFullPath { - // The process which is invoking vstest.console - private VSTestForwardingApp vsTestForwardingApp; + get; + set; + } - private const string vsTestAppName = "vstest.console.dll"; - private const string CodeCovergaeString = "Code Coverage"; + public string VSTestSetting + { + get; + set; + } - public string TestFileFullPath - { - get; - set; - } + public string[] VSTestTestAdapterPath + { + get; + set; + } - public string VSTestSetting - { - get; - set; - } + public string VSTestFramework + { + get; + set; + } - public string[] VSTestTestAdapterPath - { - get; - set; - } + public string VSTestPlatform + { + get; + set; + } - public string VSTestFramework - { - get; - set; - } + public string VSTestTestCaseFilter + { + get; + set; + } + public string[] VSTestLogger + { + get; + set; + } - public string VSTestPlatform - { - get; - set; - } + public string VSTestListTests + { + get; + set; + } - public string VSTestTestCaseFilter - { - get; - set; - } - public string[] VSTestLogger - { - get; - set; - } + public string VSTestDiag + { + get; + set; + } - public string VSTestListTests - { - get; - set; - } + public string[] VSTestCLIRunSettings + { + get; + set; + } - public string VSTestDiag - { - get; - set; - } + [Required] + public string VSTestConsolePath + { + get; + set; + } - public string[] VSTestCLIRunSettings - { - get; - set; - } + public string VSTestResultsDirectory + { + get; + set; + } - [Required] - public string VSTestConsolePath - { - get; - set; - } + public string VSTestVerbosity + { + get; + set; + } - public string VSTestResultsDirectory - { - get; - set; - } + public string[] VSTestCollect + { + get; + set; + } - public string VSTestVerbosity - { - get; - set; - } + public string VSTestBlame + { + get; + set; + } - public string[] VSTestCollect - { - get; - set; - } + public string VSTestBlameCrash + { + get; + set; + } - public string VSTestBlame - { - get; - set; - } + public string VSTestBlameCrashDumpType + { + get; + set; + } + + public string VSTestBlameCrashCollectAlways + { + get; + set; + } + + public string VSTestBlameHang + { + get; + set; + } + + public string VSTestBlameHangDumpType + { + get; + set; + } + public string VSTestBlameHangTimeout + { + get; + set; + } + + public string VSTestTraceDataCollectorDirectoryPath + { + get; + set; + } - public string VSTestBlameCrash + public string VSTestNoLogo + { + get; + set; + } + + public override bool Execute() + { + var traceEnabledValue = Environment.GetEnvironmentVariable("VSTEST_BUILD_TRACE"); + Tracing.traceEnabled = !string.IsNullOrEmpty(traceEnabledValue) && traceEnabledValue.Equals("1", StringComparison.OrdinalIgnoreCase); + + var debugEnabled = Environment.GetEnvironmentVariable("VSTEST_BUILD_DEBUG"); + if (!string.IsNullOrEmpty(debugEnabled) && debugEnabled.Equals("1", StringComparison.Ordinal)) { - get; - set; + Console.WriteLine("Waiting for debugger attach..."); + + var currentProcess = Process.GetCurrentProcess(); + Console.WriteLine(string.Format("Process Id: {0}, Name: {1}", currentProcess.Id, currentProcess.ProcessName)); + + while (!Debugger.IsAttached) + { + Thread.Sleep(1000); + } + + Debugger.Break(); } - public string VSTestBlameCrashDumpType + // Avoid logging "Task returned false but did not log an error." on test failure, because we don't + // write MSBuild error. https://github.com/dotnet/msbuild/blob/51a1071f8871e0c93afbaf1b2ac2c9e59c7b6491/src/Framework/IBuildEngine7.cs#L12 + var allowfailureWithoutError = BuildEngine.GetType().GetProperty("AllowFailureWithoutError"); + allowfailureWithoutError?.SetValue(BuildEngine, true); + + _vsTestForwardingApp = new VSTestForwardingApp(VSTestConsolePath, CreateArgument()); + if (!string.IsNullOrEmpty(VSTestFramework)) { - get; - set; + Console.WriteLine(Resources.TestRunningSummary, TestFileFullPath, VSTestFramework); } - public string VSTestBlameCrashCollectAlways + return _vsTestForwardingApp.Execute() == 0; + } + + public void Cancel() + { + Tracing.Trace("VSTest: Killing the process..."); + _vsTestForwardingApp.Cancel(); + } + + internal IEnumerable CreateArgument() + { + var allArgs = AddArgs(); + + // VSTestCLIRunSettings should be last argument in allArgs as vstest.console ignore options after "--"(CLIRunSettings option). + AddCliRunSettingsArgs(allArgs); + + return allArgs; + } + + private void AddCliRunSettingsArgs(List allArgs) + { + if (VSTestCLIRunSettings != null && VSTestCLIRunSettings.Length > 0) { - get; - set; + allArgs.Add("--"); + foreach (var arg in VSTestCLIRunSettings) + { + allArgs.Add(ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(arg)); + } } + } - public string VSTestBlameHang + private List AddArgs() + { + var isConsoleLoggerSpecifiedByUser = false; + var isCollectCodeCoverageEnabled = false; + var isRunSettingsEnabled = false; + var allArgs = new List(); + + // TODO log arguments in task + if (!string.IsNullOrEmpty(VSTestSetting)) { - get; - set; + isRunSettingsEnabled = true; + allArgs.Add("--settings:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(VSTestSetting)); } - public string VSTestBlameHangDumpType + if (VSTestTestAdapterPath != null && VSTestTestAdapterPath.Length > 0) { - get; - set; + foreach (var arg in VSTestTestAdapterPath) + { + allArgs.Add("--testAdapterPath:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(arg)); + } } - public string VSTestBlameHangTimeout + + if (!string.IsNullOrEmpty(VSTestFramework)) { - get; - set; + allArgs.Add("--framework:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(VSTestFramework)); } - public string VSTestTraceDataCollectorDirectoryPath + // vstest.console only support x86 and x64 for argument platform + if (!string.IsNullOrEmpty(VSTestPlatform) && !VSTestPlatform.Contains("AnyCPU")) { - get; - set; + allArgs.Add("--platform:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(VSTestPlatform)); } - public string VSTestNoLogo + if (!string.IsNullOrEmpty(VSTestTestCaseFilter)) { - get; - set; + allArgs.Add("--testCaseFilter:" + + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(VSTestTestCaseFilter)); } - public override bool Execute() + if (VSTestLogger != null && VSTestLogger.Length > 0) { - var traceEnabledValue = Environment.GetEnvironmentVariable("VSTEST_BUILD_TRACE"); - Tracing.traceEnabled = !string.IsNullOrEmpty(traceEnabledValue) && traceEnabledValue.Equals("1", StringComparison.OrdinalIgnoreCase); - - var debugEnabled = Environment.GetEnvironmentVariable("VSTEST_BUILD_DEBUG"); - if (!string.IsNullOrEmpty(debugEnabled) && debugEnabled.Equals("1", StringComparison.Ordinal)) + foreach (var arg in VSTestLogger) { - Console.WriteLine("Waiting for debugger attach..."); + allArgs.Add("--logger:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(arg)); - var currentProcess = Process.GetCurrentProcess(); - Console.WriteLine(string.Format("Process Id: {0}, Name: {1}", currentProcess.Id, currentProcess.ProcessName)); - - while (!Debugger.IsAttached) + if (arg.StartsWith("console", StringComparison.OrdinalIgnoreCase)) { - Thread.Sleep(1000); + isConsoleLoggerSpecifiedByUser = true; } - - Debugger.Break(); - } - - // Avoid logging "Task returned false but did not log an error." on test failure, because we don't - // write MSBuild error. https://github.com/dotnet/msbuild/blob/51a1071f8871e0c93afbaf1b2ac2c9e59c7b6491/src/Framework/IBuildEngine7.cs#L12 - var allowfailureWithoutError = BuildEngine.GetType().GetProperty("AllowFailureWithoutError"); - allowfailureWithoutError?.SetValue(BuildEngine, true); - - vsTestForwardingApp = new VSTestForwardingApp(this.VSTestConsolePath, this.CreateArgument()); - if (!string.IsNullOrEmpty(this.VSTestFramework)) - { - Console.WriteLine(Resources.TestRunningSummary, this.TestFileFullPath, this.VSTestFramework); } - - return vsTestForwardingApp.Execute() == 0; } - public void Cancel() + if (!string.IsNullOrEmpty(VSTestResultsDirectory)) { - Tracing.Trace("VSTest: Killing the process..."); - vsTestForwardingApp.Cancel(); + allArgs.Add("--resultsDirectory:" + + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(VSTestResultsDirectory)); } - internal IEnumerable CreateArgument() + if (!string.IsNullOrEmpty(VSTestListTests)) { - var allArgs = this.AddArgs(); - - // VSTestCLIRunSettings should be last argument in allArgs as vstest.console ignore options after "--"(CLIRunSettings option). - this.AddCLIRunSettingsArgs(allArgs); - - return allArgs; + allArgs.Add("--listTests"); } - private void AddCLIRunSettingsArgs(List allArgs) + if (!string.IsNullOrEmpty(VSTestDiag)) { - if (this.VSTestCLIRunSettings != null && this.VSTestCLIRunSettings.Length > 0) - { - allArgs.Add("--"); - foreach (var arg in this.VSTestCLIRunSettings) - { - allArgs.Add(ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(arg)); - } - } + allArgs.Add("--Diag:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(VSTestDiag)); } - private List AddArgs() + if (string.IsNullOrEmpty(TestFileFullPath)) + { + Log.LogError("Test file path cannot be empty or null."); + } + else { - var isConsoleLoggerSpecifiedByUser = false; - var isCollectCodeCoverageEnabled = false; - var isRunSettingsEnabled = false; - var allArgs = new List(); + allArgs.Add(ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(TestFileFullPath)); + } - // TODO log arguments in task - if (!string.IsNullOrEmpty(this.VSTestSetting)) - { - isRunSettingsEnabled = true; - allArgs.Add("--settings:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(this.VSTestSetting)); - } + // Console logger was not specified by user, but verbosity was, hence add default console logger with verbosity as specified + if (!string.IsNullOrWhiteSpace(VSTestVerbosity) && !isConsoleLoggerSpecifiedByUser) + { + var normalTestLogging = new List() { "n", "normal", "d", "detailed", "diag", "diagnostic" }; + var quietTestLogging = new List() { "q", "quiet" }; - if (this.VSTestTestAdapterPath != null && this.VSTestTestAdapterPath.Length > 0) + string vsTestVerbosity = "minimal"; + if (normalTestLogging.Contains(VSTestVerbosity.ToLowerInvariant())) { - foreach (var arg in this.VSTestTestAdapterPath) - { - allArgs.Add("--testAdapterPath:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(arg)); - } + vsTestVerbosity = "normal"; } - - if (!string.IsNullOrEmpty(this.VSTestFramework)) + else if (quietTestLogging.Contains(VSTestVerbosity.ToLowerInvariant())) { - allArgs.Add("--framework:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(this.VSTestFramework)); + vsTestVerbosity = "quiet"; } - // vstest.console only support x86 and x64 for argument platform - if (!string.IsNullOrEmpty(this.VSTestPlatform) && !this.VSTestPlatform.Contains("AnyCPU")) - { - allArgs.Add("--platform:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(this.VSTestPlatform)); - } + allArgs.Add("--logger:Console;Verbosity=" + vsTestVerbosity); + } - if (!string.IsNullOrEmpty(this.VSTestTestCaseFilter)) - { - allArgs.Add("--testCaseFilter:" + - ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(this.VSTestTestCaseFilter)); - } + var blameCrash = !string.IsNullOrEmpty(VSTestBlameCrash); + var blameHang = !string.IsNullOrEmpty(VSTestBlameHang); + if (!string.IsNullOrEmpty(VSTestBlame) || blameCrash || blameHang) + { + var blameArgs = "--Blame"; - if (this.VSTestLogger != null && this.VSTestLogger.Length > 0) + var dumpArgs = new List(); + if (blameCrash || blameHang) { - foreach (var arg in this.VSTestLogger) + if (blameCrash) { - allArgs.Add("--logger:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(arg)); - - if (arg.StartsWith("console", StringComparison.OrdinalIgnoreCase)) + dumpArgs.Add("CollectDump"); + if (!string.IsNullOrEmpty(VSTestBlameCrashCollectAlways)) { - isConsoleLoggerSpecifiedByUser = true; + dumpArgs.Add($"CollectAlways={VSTestBlameCrashCollectAlways}"); } - } - } - - if (!string.IsNullOrEmpty(this.VSTestResultsDirectory)) - { - allArgs.Add("--resultsDirectory:" + - ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(this.VSTestResultsDirectory)); - } - - if (!string.IsNullOrEmpty(this.VSTestListTests)) - { - allArgs.Add("--listTests"); - } - if (!string.IsNullOrEmpty(this.VSTestDiag)) - { - allArgs.Add("--Diag:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(this.VSTestDiag)); - } - - if (string.IsNullOrEmpty(this.TestFileFullPath)) - { - this.Log.LogError("Test file path cannot be empty or null."); - } - else - { - allArgs.Add(ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(this.TestFileFullPath)); - } - - // Console logger was not specified by user, but verbosity was, hence add default console logger with verbosity as specified - if (!string.IsNullOrWhiteSpace(this.VSTestVerbosity) && !isConsoleLoggerSpecifiedByUser) - { - var normalTestLogging = new List() { "n", "normal", "d", "detailed", "diag", "diagnostic" }; - var quietTestLogging = new List() { "q", "quiet" }; - - string vsTestVerbosity = "minimal"; - if (normalTestLogging.Contains(this.VSTestVerbosity.ToLowerInvariant())) - { - vsTestVerbosity = "normal"; - } - else if (quietTestLogging.Contains(this.VSTestVerbosity.ToLowerInvariant())) - { - vsTestVerbosity = "quiet"; + if (!string.IsNullOrEmpty(VSTestBlameCrashDumpType)) + { + dumpArgs.Add($"DumpType={VSTestBlameCrashDumpType}"); + } } - allArgs.Add("--logger:Console;Verbosity=" + vsTestVerbosity); - } - - var blameCrash = !string.IsNullOrEmpty(this.VSTestBlameCrash); - var blameHang = !string.IsNullOrEmpty(this.VSTestBlameHang); - if (!string.IsNullOrEmpty(this.VSTestBlame) || blameCrash || blameHang) - { - var blameArgs = "--Blame"; - - var dumpArgs = new List(); - if (blameCrash || blameHang) + if (blameHang) { - if (blameCrash) - { - dumpArgs.Add("CollectDump"); - if (!string.IsNullOrEmpty(this.VSTestBlameCrashCollectAlways)) - { - dumpArgs.Add($"CollectAlways={this.VSTestBlameCrashCollectAlways}"); - } - - if (!string.IsNullOrEmpty(this.VSTestBlameCrashDumpType)) - { - dumpArgs.Add($"DumpType={this.VSTestBlameCrashDumpType}"); - } - } + dumpArgs.Add("CollectHangDump"); - if (blameHang) + if (!string.IsNullOrEmpty(VSTestBlameHangDumpType)) { - dumpArgs.Add("CollectHangDump"); - - if (!string.IsNullOrEmpty(this.VSTestBlameHangDumpType)) - { - dumpArgs.Add($"HangDumpType={this.VSTestBlameHangDumpType}"); - } - - if (!string.IsNullOrEmpty(this.VSTestBlameHangTimeout)) - { - dumpArgs.Add($"TestTimeout={this.VSTestBlameHangTimeout}"); - } + dumpArgs.Add($"HangDumpType={VSTestBlameHangDumpType}"); } - if (dumpArgs.Any()) + if (!string.IsNullOrEmpty(VSTestBlameHangTimeout)) { - blameArgs += $":\"{string.Join(";", dumpArgs)}\""; + dumpArgs.Add($"TestTimeout={VSTestBlameHangTimeout}"); } } - allArgs.Add(blameArgs); - } - - if (this.VSTestCollect != null && this.VSTestCollect.Length > 0) - { - foreach (var arg in this.VSTestCollect) + if (dumpArgs.Any()) { - // For collecting code coverage, argument value can be either "Code Coverage" or "Code Coverage;a=b;c=d". - // Split the argument with ';' and compare first token value. - var tokens = arg.Split(';'); - - if (arg.Equals(CodeCovergaeString, StringComparison.OrdinalIgnoreCase) || - tokens[0].Equals(CodeCovergaeString, StringComparison.OrdinalIgnoreCase)) - { - isCollectCodeCoverageEnabled = true; - } - - allArgs.Add("--collect:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(arg)); + blameArgs += $":\"{string.Join(";", dumpArgs)}\""; } } - if (isCollectCodeCoverageEnabled || isRunSettingsEnabled) + allArgs.Add(blameArgs); + } + + if (VSTestCollect != null && VSTestCollect.Length > 0) + { + foreach (var arg in VSTestCollect) { - // Pass TraceDataCollector path to vstest.console as TestAdapterPath if --collect "Code Coverage" - // or --settings (User can enable code coverage from runsettings) option given. - // Not parsing the runsettings for two reason: - // 1. To keep no knowledge of runsettings structure in VSTestTask. - // 2. Impact of adding adapter path always is minimal. (worst case: loads additional data collector assembly in datacollector process.) - // This is required due to currently trace datacollector not ships with dotnet sdk, can be remove once we have - // go code coverage x-plat. - if (!string.IsNullOrEmpty(this.VSTestTraceDataCollectorDirectoryPath)) + // For collecting code coverage, argument value can be either "Code Coverage" or "Code Coverage;a=b;c=d". + // Split the argument with ';' and compare first token value. + var tokens = arg.Split(';'); + + if (arg.Equals(CodeCovergaeString, StringComparison.OrdinalIgnoreCase) || + tokens[0].Equals(CodeCovergaeString, StringComparison.OrdinalIgnoreCase)) { - allArgs.Add("--testAdapterPath:" + - ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(this - .VSTestTraceDataCollectorDirectoryPath)); - } - else - { - if (isCollectCodeCoverageEnabled) - { - // Not showing message in runsettings scenario, because we are not sure that code coverage is enabled. - // User might be using older Microsoft.NET.Test.Sdk which don't have CodeCoverage infra. - Console.WriteLine(Resources.UpdateTestSdkForCollectingCodeCoverage); - } + isCollectCodeCoverageEnabled = true; } + + allArgs.Add("--collect:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(arg)); } + } - if (!string.IsNullOrWhiteSpace(this.VSTestNoLogo)) + if (isCollectCodeCoverageEnabled || isRunSettingsEnabled) + { + // Pass TraceDataCollector path to vstest.console as TestAdapterPath if --collect "Code Coverage" + // or --settings (User can enable code coverage from runsettings) option given. + // Not parsing the runsettings for two reason: + // 1. To keep no knowledge of runsettings structure in VSTestTask. + // 2. Impact of adding adapter path always is minimal. (worst case: loads additional data collector assembly in datacollector process.) + // This is required due to currently trace datacollector not ships with dotnet sdk, can be remove once we have + // go code coverage x-plat. + if (!string.IsNullOrEmpty(VSTestTraceDataCollectorDirectoryPath)) + { + allArgs.Add("--testAdapterPath:" + + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart( + VSTestTraceDataCollectorDirectoryPath)); + } + else { - allArgs.Add("--nologo"); + if (isCollectCodeCoverageEnabled) + { + // Not showing message in runsettings scenario, because we are not sure that code coverage is enabled. + // User might be using older Microsoft.NET.Test.Sdk which don't have CodeCoverage infra. + Console.WriteLine(Resources.UpdateTestSdkForCollectingCodeCoverage); + } } + } - return allArgs; + if (!string.IsNullOrWhiteSpace(VSTestNoLogo)) + { + allArgs.Add("--nologo"); } + + return allArgs; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Build/Tracing.cs b/src/Microsoft.TestPlatform.Build/Tracing.cs index 55d024c672..c64a77dffa 100644 --- a/src/Microsoft.TestPlatform.Build/Tracing.cs +++ b/src/Microsoft.TestPlatform.Build/Tracing.cs @@ -1,17 +1,20 @@ - +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + using System; -namespace Microsoft.TestPlatform.Build.Trace +namespace Microsoft.TestPlatform.Build.Trace; + +public static class Tracing { - public static class Tracing + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Part of the public API.")] + public static bool traceEnabled = false; + + public static void Trace(string message) { - public static bool traceEnabled = false; - public static void Trace(string message) + if (traceEnabled) { - if (traceEnabled) - { - Console.WriteLine(message); - } + Console.WriteLine(message); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Client/AttachmentsProcessing/TestRunAttachmentsProcessingEventsHandler.cs b/src/Microsoft.TestPlatform.Client/AttachmentsProcessing/TestRunAttachmentsProcessingEventsHandler.cs index 6bceff7f24..fe68c17171 100644 --- a/src/Microsoft.TestPlatform.Client/AttachmentsProcessing/TestRunAttachmentsProcessingEventsHandler.cs +++ b/src/Microsoft.TestPlatform.Client/AttachmentsProcessing/TestRunAttachmentsProcessingEventsHandler.cs @@ -1,77 +1,77 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing +namespace Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing; + +using CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Logging; + +using System.Collections.Generic; + +/// +/// The test run attachments processing events handler. +/// +/// +public class TestRunAttachmentsProcessingEventsHandler : ITestRunAttachmentsProcessingEventsHandler { - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using System.Collections.Generic; + private readonly ICommunicationManager _communicationManager; /// - /// The test run attachments processing events handler. + /// Initializes a new instance of the class. /// - /// - public class TestRunAttachmentsProcessingEventsHandler : ITestRunAttachmentsProcessingEventsHandler + /// The communication manager. + public TestRunAttachmentsProcessingEventsHandler(ICommunicationManager communicationManager) { - private readonly ICommunicationManager communicationManager; + _communicationManager = communicationManager; + } - /// - /// Initializes a new instance of the class. - /// - /// The communication manager. - public TestRunAttachmentsProcessingEventsHandler(ICommunicationManager communicationManager) + /// + public void HandleTestRunAttachmentsProcessingComplete(TestRunAttachmentsProcessingCompleteEventArgs attachmentsProcessingCompleteEventArgs, IEnumerable lastChunk) + { + if (EqtTrace.IsInfoEnabled) { - this.communicationManager = communicationManager; + EqtTrace.Info("Test run attachments processing completed."); } - /// - public void HandleTestRunAttachmentsProcessingComplete(TestRunAttachmentsProcessingCompleteEventArgs attachmentsProcessingCompleteEventArgs, IEnumerable lastChunk) + var payload = new TestRunAttachmentsProcessingCompletePayload() { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("Test run attachments processing completed."); - } - - var payload = new TestRunAttachmentsProcessingCompletePayload() - { - AttachmentsProcessingCompleteEventArgs = attachmentsProcessingCompleteEventArgs, - Attachments = lastChunk - }; + AttachmentsProcessingCompleteEventArgs = attachmentsProcessingCompleteEventArgs, + Attachments = lastChunk + }; - this.communicationManager.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, payload); - } + _communicationManager.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, payload); + } - /// - public void HandleTestRunAttachmentsProcessingProgress(TestRunAttachmentsProcessingProgressEventArgs attachmentsProcessingProgressEventArgs) + /// + public void HandleTestRunAttachmentsProcessingProgress(TestRunAttachmentsProcessingProgressEventArgs attachmentsProcessingProgressEventArgs) + { + var payload = new TestRunAttachmentsProcessingProgressPayload() { - var payload = new TestRunAttachmentsProcessingProgressPayload() - { - AttachmentsProcessingProgressEventArgs = attachmentsProcessingProgressEventArgs, - }; + AttachmentsProcessingProgressEventArgs = attachmentsProcessingProgressEventArgs, + }; - this.communicationManager.SendMessage(MessageType.TestRunAttachmentsProcessingProgress, payload); - } + _communicationManager.SendMessage(MessageType.TestRunAttachmentsProcessingProgress, payload); + } - /// - public void HandleProcessedAttachmentsChunk(IEnumerable attachments) - { - throw new System.NotImplementedException(); - } + /// + public void HandleProcessedAttachmentsChunk(IEnumerable attachments) + { + throw new System.NotImplementedException(); + } - /// - public void HandleLogMessage(TestMessageLevel level, string message) - { - var testMessagePayload = new TestMessagePayload { MessageLevel = level, Message = message }; - this.communicationManager.SendMessage(MessageType.TestMessage, testMessagePayload); - } + /// + public void HandleLogMessage(TestMessageLevel level, string message) + { + var testMessagePayload = new TestMessagePayload { MessageLevel = level, Message = message }; + _communicationManager.SendMessage(MessageType.TestMessage, testMessagePayload); + } - /// - public void HandleRawMessage(string rawMessage) - { - // No-Op - } + /// + public void HandleRawMessage(string rawMessage) + { + // No-Op } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs index 58d8e9d2a5..d7dfa604ab 100644 --- a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs +++ b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs @@ -1,598 +1,591 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Client.DesignMode +namespace Microsoft.VisualStudio.TestPlatform.Client.DesignMode; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Net; +using System.Threading; +using System.Threading.Tasks; + +using Client; +using TestRunAttachmentsProcessing; +using RequestHelper; +using Common.Logging; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using CommunicationUtilities; +using CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using CoreUtilities.Helpers; +using CrossPlatEngine; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; +using ObjectModel.Logging; +using PlatformAbstractions; +using PlatformAbstractions.Interfaces; + +using CommunicationUtilitiesResources = CommunicationUtilities.Resources.Resources; + +/// +/// The design mode client. +/// +public class DesignModeClient : IDesignModeClient { - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Net; - using System.Threading; - using System.Threading.Tasks; - - using Microsoft.VisualStudio.TestPlatform.Client; - using Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing; - using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - - using CommunicationUtilitiesResources = CommunicationUtilities.Resources.Resources; + private readonly ICommunicationManager _communicationManager; + private readonly IDataSerializer _dataSerializer; + + private readonly ProtocolConfig _protocolConfig = ObjectModel.Constants.DefaultProtocolConfig; + private readonly IEnvironment _platformEnvironment; + private readonly TestSessionMessageLogger _testSessionMessageLogger; + private readonly object _lockObject = new(); + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Part of the public API.")] + protected Action onCustomTestHostLaunchAckReceived; + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Part of the public API.")] + protected Action onAttachDebuggerAckRecieved; /// - /// The design mode client. + /// Initializes a new instance of the class. /// - public class DesignModeClient : IDesignModeClient + public DesignModeClient() + : this(new SocketCommunicationManager(), JsonDataSerializer.Instance, new PlatformEnvironment()) { - private readonly ICommunicationManager communicationManager; - private readonly IDataSerializer dataSerializer; - - private ProtocolConfig protocolConfig = ObjectModel.Constants.DefaultProtocolConfig; - private IEnvironment platformEnvironment; - private TestSessionMessageLogger testSessionMessageLogger; - private object lockObject = new object(); - - protected Action onCustomTestHostLaunchAckReceived; - protected Action onAttachDebuggerAckRecieved; - - /// - /// Initializes a new instance of the class. - /// - public DesignModeClient() - : this(new SocketCommunicationManager(), JsonDataSerializer.Instance, new PlatformEnvironment()) - { - } + } - /// - /// Initializes a new instance of the class. - /// - /// - /// The communication manager. - /// - /// - /// The data Serializer. - /// - /// - /// The platform Environment - /// - internal DesignModeClient(ICommunicationManager communicationManager, IDataSerializer dataSerializer, IEnvironment platformEnvironment) - { - this.communicationManager = communicationManager; - this.dataSerializer = dataSerializer; - this.platformEnvironment = platformEnvironment; - this.testSessionMessageLogger = TestSessionMessageLogger.Instance; - this.testSessionMessageLogger.TestRunMessage += this.TestRunMessageHandler; - } + /// + /// Initializes a new instance of the class. + /// + /// + /// The communication manager. + /// + /// + /// The data Serializer. + /// + /// + /// The platform Environment + /// + internal DesignModeClient(ICommunicationManager communicationManager, IDataSerializer dataSerializer, IEnvironment platformEnvironment) + { + _communicationManager = communicationManager; + _dataSerializer = dataSerializer; + _platformEnvironment = platformEnvironment; + _testSessionMessageLogger = TestSessionMessageLogger.Instance; + _testSessionMessageLogger.TestRunMessage += TestRunMessageHandler; + } - /// - /// Property exposing the Instance - /// - public static IDesignModeClient Instance { get; private set; } + /// + /// Property exposing the Instance + /// + public static IDesignModeClient Instance { get; private set; } - /// - /// Initializes DesignMode - /// - public static void Initialize() - { - Instance = new DesignModeClient(); - } + /// + /// Initializes DesignMode + /// + public static void Initialize() + { + Instance = new DesignModeClient(); + } - /// - /// Creates a client and waits for server to accept connection asynchronously - /// - /// - /// Port number to connect - /// - /// - /// The test Request Manager. - /// - public void ConnectToClientAndProcessRequests(int port, ITestRequestManager testRequestManager) - { - EqtTrace.Info("Trying to connect to server on port : {0}", port); - this.communicationManager.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)); + /// + /// Creates a client and waits for server to accept connection asynchronously + /// + /// + /// Port number to connect + /// + /// + /// The test Request Manager. + /// + public void ConnectToClientAndProcessRequests(int port, ITestRequestManager testRequestManager) + { + EqtTrace.Info("Trying to connect to server on port : {0}", port); + _communicationManager.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)); - var connectionTimeoutInSecs = EnvironmentHelper.GetConnectionTimeout(); + var connectionTimeoutInSecs = EnvironmentHelper.GetConnectionTimeout(); - // Wait for the connection to the server and listen for requests. - if (this.communicationManager.WaitForServerConnection(connectionTimeoutInSecs * 1000)) - { - this.communicationManager.SendMessage(MessageType.SessionConnected); - this.ProcessRequests(testRequestManager); - } - else - { - EqtTrace.Error("DesignModeClient : ConnectToClientAndProcessRequests : Client timed out while connecting to the server."); - this.Dispose(); - throw new TimeoutException( - string.Format( - CultureInfo.CurrentUICulture, - CommunicationUtilitiesResources.ConnectionTimeoutErrorMessage, - CoreUtilities.Constants.VstestConsoleProcessName, - "translation layer", - connectionTimeoutInSecs, - EnvironmentHelper.VstestConnectionTimeout) - ); - } + // Wait for the connection to the server and listen for requests. + if (_communicationManager.WaitForServerConnection(connectionTimeoutInSecs * 1000)) + { + _communicationManager.SendMessage(MessageType.SessionConnected); + ProcessRequests(testRequestManager); } - - public void HandleParentProcessExit() + else { - // Dispose off the communications to end the session - // this should end the "ProcessRequests" loop with an exception - this.Dispose(); + EqtTrace.Error("DesignModeClient : ConnectToClientAndProcessRequests : Client timed out while connecting to the server."); + Dispose(); + throw new TimeoutException( + string.Format( + CultureInfo.CurrentUICulture, + CommunicationUtilitiesResources.ConnectionTimeoutErrorMessage, + CoreUtilities.Constants.VstestConsoleProcessName, + "translation layer", + connectionTimeoutInSecs, + EnvironmentHelper.VstestConnectionTimeout) + ); + } + } - EqtTrace.Info("DesignModeClient: Parent process exited, Exiting myself.."); + public void HandleParentProcessExit() + { + // Dispose off the communications to end the session + // this should end the "ProcessRequests" loop with an exception + Dispose(); - this.platformEnvironment.Exit(1); - } + EqtTrace.Info("DesignModeClient: Parent process exited, Exiting myself.."); - /// - /// Process Requests from the IDE - /// - /// - /// The test Request Manager. - /// - private void ProcessRequests(ITestRequestManager testRequestManager) - { - var isSessionEnd = false; + _platformEnvironment.Exit(1); + } - do - { - try - { - var message = this.communicationManager.ReceiveMessage(); + /// + /// Process Requests from the IDE + /// + /// + /// The test Request Manager. + /// + private void ProcessRequests(ITestRequestManager testRequestManager) + { + var isSessionEnd = false; - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DesignModeClient.ProcessRequests: Processing Message: {0}", message); - } + do + { + try + { + var message = _communicationManager.ReceiveMessage(); - switch (message.MessageType) - { - case MessageType.VersionCheck: - { - var version = this.dataSerializer.DeserializePayload(message); - this.protocolConfig.Version = Math.Min(version, this.protocolConfig.Version); - this.communicationManager.SendMessage(MessageType.VersionCheck, this.protocolConfig.Version); - break; - } - - case MessageType.ExtensionsInitialize: - { - // Do not filter the Editor/IDE provided extensions by name - var extensionPaths = this.communicationManager.DeserializePayload>(message); - testRequestManager.InitializeExtensions(extensionPaths, skipExtensionFilters: true); - break; - } - - case MessageType.StartTestSession: - { - var testSessionPayload = this.communicationManager.DeserializePayload(message); - this.StartTestSession(testSessionPayload, testRequestManager); - break; - } - - case MessageType.StopTestSession: - { - var testSessionInfo = this.communicationManager.DeserializePayload(message); - this.StopTestSession(testSessionInfo); - break; - } - - case MessageType.StartDiscovery: - { - var discoveryPayload = this.dataSerializer.DeserializePayload(message); - this.StartDiscovery(discoveryPayload, testRequestManager); - break; - } - - case MessageType.GetTestRunnerProcessStartInfoForRunAll: - case MessageType.GetTestRunnerProcessStartInfoForRunSelected: - { - var testRunPayload = - this.communicationManager.DeserializePayload( - message); - this.StartTestRun(testRunPayload, testRequestManager, shouldLaunchTesthost: true); - break; - } - - case MessageType.TestRunAllSourcesWithDefaultHost: - case MessageType.TestRunSelectedTestCasesDefaultHost: - { - var testRunPayload = - this.communicationManager.DeserializePayload( - message); - this.StartTestRun(testRunPayload, testRequestManager, shouldLaunchTesthost: false); - break; - } - - case MessageType.TestRunAttachmentsProcessingStart: - { - var testRunAttachmentsProcessingPayload = - this.communicationManager.DeserializePayload(message); - this.StartTestRunAttachmentsProcessing(testRunAttachmentsProcessingPayload, testRequestManager); - break; - } - - case MessageType.CancelDiscovery: - { - testRequestManager.CancelDiscovery(); - break; - } - - case MessageType.CancelTestRun: - { - testRequestManager.CancelTestRun(); - break; - } - - case MessageType.AbortTestRun: - { - testRequestManager.AbortTestRun(); - break; - } - - case MessageType.TestRunAttachmentsProcessingCancel: - { - testRequestManager.CancelTestRunAttachmentsProcessing(); - break; - } - - case MessageType.CustomTestHostLaunchCallback: - { - this.onCustomTestHostLaunchAckReceived?.Invoke(message); - break; - } - - case MessageType.EditorAttachDebuggerCallback: - { - this.onAttachDebuggerAckRecieved?.Invoke(message); - break; - } - - case MessageType.SessionEnd: - { - EqtTrace.Info("DesignModeClient: Session End message received from server. Closing the connection."); - isSessionEnd = true; - this.Dispose(); - break; - } - - default: - { - EqtTrace.Info("DesignModeClient: Invalid Message received: {0}", message); - break; - } - } - } - catch (Exception ex) + if (EqtTrace.IsInfoEnabled) { - EqtTrace.Error("DesignModeClient: Error processing request: {0}", ex); - isSessionEnd = true; - this.Dispose(); + EqtTrace.Info("DesignModeClient.ProcessRequests: Processing Message: {0}", message); } - } - while (!isSessionEnd); - } - /// - /// Send a custom host launch message to IDE - /// - /// - /// The test Process Start Info. - /// - /// - /// The cancellation token. - /// - /// - /// The . - /// - public int LaunchCustomHost(TestProcessStartInfo testProcessStartInfo, CancellationToken cancellationToken) - { - lock (this.lockObject) - { - var waitHandle = new AutoResetEvent(false); - Message ackMessage = null; - this.onCustomTestHostLaunchAckReceived = (ackRawMessage) => + switch (message.MessageType) { - ackMessage = ackRawMessage; - waitHandle.Set(); - }; + case MessageType.VersionCheck: + { + var version = _dataSerializer.DeserializePayload(message); + _protocolConfig.Version = Math.Min(version, _protocolConfig.Version); + _communicationManager.SendMessage(MessageType.VersionCheck, _protocolConfig.Version); + break; + } - this.communicationManager.SendMessage(MessageType.CustomTestHostLaunch, testProcessStartInfo); + case MessageType.ExtensionsInitialize: + { + // Do not filter the Editor/IDE provided extensions by name + var extensionPaths = _communicationManager.DeserializePayload>(message); + testRequestManager.InitializeExtensions(extensionPaths, skipExtensionFilters: true); + break; + } - // LifeCycle of the TP through DesignModeClient is maintained by the IDEs or user-facing-clients like LUTs, who call TestPlatform - // TP is handing over the control of launch to these IDEs and so, TP has to wait indefinite - // Even if TP has a timeout here, there is no way TP can abort or stop the thread/task that is hung in IDE or LUT - // Even if TP can abort the API somehow, TP is essentially putting IDEs or Clients in inconsistent state without having info on - // Since the IDEs own user-UI-experience here, TP will let the custom host launch as much time as IDEs define it for their users - WaitHandle.WaitAny(new WaitHandle[] { waitHandle, cancellationToken.WaitHandle }); + case MessageType.StartTestSession: + { + var testSessionPayload = _communicationManager.DeserializePayload(message); + StartTestSession(testSessionPayload, testRequestManager); + break; + } - cancellationToken.ThrowTestPlatformExceptionIfCancellationRequested(); + case MessageType.StopTestSession: + { + var testSessionInfo = _communicationManager.DeserializePayload(message); + StopTestSession(testSessionInfo); + break; + } - this.onCustomTestHostLaunchAckReceived = null; + case MessageType.StartDiscovery: + { + var discoveryPayload = _dataSerializer.DeserializePayload(message); + StartDiscovery(discoveryPayload, testRequestManager); + break; + } - var ackPayload = this.dataSerializer.DeserializePayload(ackMessage); + case MessageType.GetTestRunnerProcessStartInfoForRunAll: + case MessageType.GetTestRunnerProcessStartInfoForRunSelected: + { + var testRunPayload = + _communicationManager.DeserializePayload( + message); + StartTestRun(testRunPayload, testRequestManager, shouldLaunchTesthost: true); + break; + } + + case MessageType.TestRunAllSourcesWithDefaultHost: + case MessageType.TestRunSelectedTestCasesDefaultHost: + { + var testRunPayload = + _communicationManager.DeserializePayload( + message); + StartTestRun(testRunPayload, testRequestManager, shouldLaunchTesthost: false); + break; + } + + case MessageType.TestRunAttachmentsProcessingStart: + { + var testRunAttachmentsProcessingPayload = + _communicationManager.DeserializePayload(message); + StartTestRunAttachmentsProcessing(testRunAttachmentsProcessingPayload, testRequestManager); + break; + } - if (ackPayload.HostProcessId > 0) - { - return ackPayload.HostProcessId; - } - else - { - throw new TestPlatformException(ackPayload.ErrorMessage); + case MessageType.CancelDiscovery: + { + testRequestManager.CancelDiscovery(); + break; + } + + case MessageType.CancelTestRun: + { + testRequestManager.CancelTestRun(); + break; + } + + case MessageType.AbortTestRun: + { + testRequestManager.AbortTestRun(); + break; + } + + case MessageType.TestRunAttachmentsProcessingCancel: + { + testRequestManager.CancelTestRunAttachmentsProcessing(); + break; + } + + case MessageType.CustomTestHostLaunchCallback: + { + onCustomTestHostLaunchAckReceived?.Invoke(message); + break; + } + + case MessageType.EditorAttachDebuggerCallback: + { + onAttachDebuggerAckRecieved?.Invoke(message); + break; + } + + case MessageType.SessionEnd: + { + EqtTrace.Info("DesignModeClient: Session End message received from server. Closing the connection."); + isSessionEnd = true; + Dispose(); + break; + } + + default: + { + EqtTrace.Info("DesignModeClient: Invalid Message received: {0}", message); + break; + } } } - } - - /// - public bool AttachDebuggerToProcess(int pid, CancellationToken cancellationToken) - { - // If an attach request is issued but there is no support for attaching on the other - // side of the communication channel, we simply return and let the caller know the - // request failed. - if (this.protocolConfig.Version < ObjectModel.Constants.MinimumProtocolVersionWithDebugSupport) + catch (Exception ex) { - return false; + EqtTrace.Error("DesignModeClient: Error processing request: {0}", ex); + isSessionEnd = true; + Dispose(); } + } + while (!isSessionEnd); + } - lock (this.lockObject) + /// + /// Send a custom host launch message to IDE + /// + /// + /// The test Process Start Info. + /// + /// + /// The cancellation token. + /// + /// + /// The . + /// + public int LaunchCustomHost(TestProcessStartInfo testProcessStartInfo, CancellationToken cancellationToken) + { + lock (_lockObject) + { + var waitHandle = new AutoResetEvent(false); + Message ackMessage = null; + onCustomTestHostLaunchAckReceived = (ackRawMessage) => { - var waitHandle = new AutoResetEvent(false); - Message ackMessage = null; - this.onAttachDebuggerAckRecieved = (ackRawMessage) => - { - ackMessage = ackRawMessage; - waitHandle.Set(); - }; + ackMessage = ackRawMessage; + waitHandle.Set(); + }; - this.communicationManager.SendMessage(MessageType.EditorAttachDebugger, pid); + _communicationManager.SendMessage(MessageType.CustomTestHostLaunch, testProcessStartInfo); - WaitHandle.WaitAny(new WaitHandle[] { waitHandle, cancellationToken.WaitHandle }); + // LifeCycle of the TP through DesignModeClient is maintained by the IDEs or user-facing-clients like LUTs, who call TestPlatform + // TP is handing over the control of launch to these IDEs and so, TP has to wait indefinite + // Even if TP has a timeout here, there is no way TP can abort or stop the thread/task that is hung in IDE or LUT + // Even if TP can abort the API somehow, TP is essentially putting IDEs or Clients in inconsistent state without having info on + // Since the IDEs own user-UI-experience here, TP will let the custom host launch as much time as IDEs define it for their users + WaitHandle.WaitAny(new WaitHandle[] { waitHandle, cancellationToken.WaitHandle }); - cancellationToken.ThrowTestPlatformExceptionIfCancellationRequested(); - this.onAttachDebuggerAckRecieved = null; + cancellationToken.ThrowTestPlatformExceptionIfCancellationRequested(); - var ackPayload = this.dataSerializer.DeserializePayload(ackMessage); - if (!ackPayload.Attached) - { - EqtTrace.Warning(ackPayload.ErrorMessage); - } + onCustomTestHostLaunchAckReceived = null; - return ackPayload.Attached; - } - } + var ackPayload = _dataSerializer.DeserializePayload(ackMessage); - /// - /// Send the raw messages to IDE - /// - /// - public void SendRawMessage(string rawMessage) - { - this.communicationManager.SendRawMessage(rawMessage); + return ackPayload.HostProcessId > 0 ? ackPayload.HostProcessId : throw new TestPlatformException(ackPayload.ErrorMessage); } + } - /// - public void SendTestMessage(TestMessageLevel level, string message) + /// + public bool AttachDebuggerToProcess(int pid, CancellationToken cancellationToken) + { + // If an attach request is issued but there is no support for attaching on the other + // side of the communication channel, we simply return and let the caller know the + // request failed. + if (_protocolConfig.Version < ObjectModel.Constants.MinimumProtocolVersionWithDebugSupport) { - var payload = new TestMessagePayload { MessageLevel = level, Message = message }; - this.communicationManager.SendMessage(MessageType.TestMessage, payload); + return false; } - /// - /// Sends the test session logger warning and error messages to IDE; - /// - /// - /// - public void TestRunMessageHandler(object sender, TestRunMessageEventArgs e) + lock (_lockObject) { - // save into trace log and send the message to the IDE - // - // there is a mismatch between log levels that VS uses and that TP - // uses. In VS you can choose Trace level which will enable Test platform - // logs on Verbose level. Below we report Errors and warnings always to the - // IDE no matter what the level of VS logging is, but Info only when the Eqt trace - // info level is enabled (so only when VS enables Trace logging) - switch (e.Level) + var waitHandle = new AutoResetEvent(false); + Message ackMessage = null; + onAttachDebuggerAckRecieved = (ackRawMessage) => { - case TestMessageLevel.Error: - EqtTrace.Error(e.Message); - SendTestMessage(e.Level, e.Message); - break; - case TestMessageLevel.Warning: - EqtTrace.Warning(e.Message); - SendTestMessage(e.Level, e.Message); - break; + ackMessage = ackRawMessage; + waitHandle.Set(); + }; - case TestMessageLevel.Informational: - EqtTrace.Info(e.Message); + _communicationManager.SendMessage(MessageType.EditorAttachDebugger, pid); - if (EqtTrace.IsInfoEnabled) - SendTestMessage(e.Level, e.Message); - break; + WaitHandle.WaitAny(new WaitHandle[] { waitHandle, cancellationToken.WaitHandle }); + cancellationToken.ThrowTestPlatformExceptionIfCancellationRequested(); + onAttachDebuggerAckRecieved = null; - default: - throw new NotSupportedException($"Test message level '{e.Level}' is not supported."); + var ackPayload = _dataSerializer.DeserializePayload(ackMessage); + if (!ackPayload.Attached) + { + EqtTrace.Warning(ackPayload.ErrorMessage); } + + return ackPayload.Attached; } + } - private void StartTestRun(TestRunRequestPayload testRunPayload, ITestRequestManager testRequestManager, bool shouldLaunchTesthost) - { - Task.Run( - () => - { - try - { - testRequestManager.ResetOptions(); - - // We must avoid re-launching the test host if the test run payload already - // contains test session info. Test session info being present is an indicative - // of an already running test host spawned by a start test session call. - var customLauncher = - shouldLaunchTesthost && testRunPayload.TestSessionInfo == null - ? DesignModeTestHostLauncherFactory.GetCustomHostLauncherForTestRun( - this, - testRunPayload.DebuggingEnabled) - : null; - - testRequestManager.RunTests(testRunPayload, customLauncher, new DesignModeTestEventsRegistrar(this), this.protocolConfig); - } - catch (Exception ex) - { - EqtTrace.Error("DesignModeClient: Exception in StartTestRun: " + ex); + /// + /// Send the raw messages to IDE + /// + /// + public void SendRawMessage(string rawMessage) + { + _communicationManager.SendRawMessage(rawMessage); + } - var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = ex.ToString() }; - this.communicationManager.SendMessage(MessageType.TestMessage, testMessagePayload); - var runCompletePayload = new TestRunCompletePayload() - { - TestRunCompleteArgs = new TestRunCompleteEventArgs(null, false, true, ex, null, null, TimeSpan.MinValue), - LastRunTests = null - }; - - // Send run complete to translation layer - this.communicationManager.SendMessage(MessageType.ExecutionComplete, runCompletePayload); - } - }); - } + /// + public void SendTestMessage(TestMessageLevel level, string message) + { + var payload = new TestMessagePayload { MessageLevel = level, Message = message }; + _communicationManager.SendMessage(MessageType.TestMessage, payload); + } - private void StartDiscovery(DiscoveryRequestPayload discoveryRequestPayload, ITestRequestManager testRequestManager) + /// + /// Sends the test session logger warning and error messages to IDE; + /// + /// + /// + public void TestRunMessageHandler(object sender, TestRunMessageEventArgs e) + { + // save into trace log and send the message to the IDE + // + // there is a mismatch between log levels that VS uses and that TP + // uses. In VS you can choose Trace level which will enable Test platform + // logs on Verbose level. Below we report Errors and warnings always to the + // IDE no matter what the level of VS logging is, but Info only when the Eqt trace + // info level is enabled (so only when VS enables Trace logging) + switch (e.Level) { - Task.Run( - () => - { - try - { - testRequestManager.ResetOptions(); - testRequestManager.DiscoverTests(discoveryRequestPayload, new DesignModeTestEventsRegistrar(this), this.protocolConfig); - } - catch (Exception ex) - { - EqtTrace.Error("DesignModeClient: Exception in StartDiscovery: " + ex); + case TestMessageLevel.Error: + EqtTrace.Error(e.Message); + SendTestMessage(e.Level, e.Message); + break; + case TestMessageLevel.Warning: + EqtTrace.Warning(e.Message); + SendTestMessage(e.Level, e.Message); + break; + + case TestMessageLevel.Informational: + EqtTrace.Info(e.Message); + + if (EqtTrace.IsInfoEnabled) + SendTestMessage(e.Level, e.Message); + break; - var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = ex.ToString() }; - this.communicationManager.SendMessage(MessageType.TestMessage, testMessagePayload); - var payload = new DiscoveryCompletePayload() - { - IsAborted = true, - LastDiscoveredTests = null, - TotalTests = -1 - }; - - // Send run complete to translation layer - this.communicationManager.SendMessage(MessageType.DiscoveryComplete, payload); - } - }); + default: + throw new NotSupportedException($"Test message level '{e.Level}' is not supported."); } + } - private void StartTestRunAttachmentsProcessing(TestRunAttachmentsProcessingPayload attachmentsProcessingPayload, ITestRequestManager testRequestManager) - { - Task.Run( - () => + private void StartTestRun(TestRunRequestPayload testRunPayload, ITestRequestManager testRequestManager, bool shouldLaunchTesthost) + { + Task.Run( + () => + { + try { - try - { - testRequestManager.ProcessTestRunAttachments(attachmentsProcessingPayload, new TestRunAttachmentsProcessingEventsHandler(this.communicationManager), this.protocolConfig); - } - catch (Exception ex) - { - EqtTrace.Error("DesignModeClient: Exception in StartTestRunAttachmentsProcessing: " + ex); - - var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = ex.ToString() }; - this.communicationManager.SendMessage(MessageType.TestMessage, testMessagePayload); + testRequestManager.ResetOptions(); + + // We must avoid re-launching the test host if the test run payload already + // contains test session info. Test session info being present is an indicative + // of an already running test host spawned by a start test session call. + var customLauncher = + shouldLaunchTesthost && testRunPayload.TestSessionInfo == null + ? DesignModeTestHostLauncherFactory.GetCustomHostLauncherForTestRun( + this, + testRunPayload.DebuggingEnabled) + : null; + + testRequestManager.RunTests(testRunPayload, customLauncher, new DesignModeTestEventsRegistrar(this), _protocolConfig); + } + catch (Exception ex) + { + EqtTrace.Error("DesignModeClient: Exception in StartTestRun: " + ex); - var payload = new TestRunAttachmentsProcessingCompletePayload() - { - Attachments = null - }; + var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = ex.ToString() }; + _communicationManager.SendMessage(MessageType.TestMessage, testMessagePayload); + var runCompletePayload = new TestRunCompletePayload() + { + TestRunCompleteArgs = new TestRunCompleteEventArgs(null, false, true, ex, null, null, TimeSpan.MinValue), + LastRunTests = null + }; - // Send run complete to translation layer - this.communicationManager.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, payload); - } - }); - } + // Send run complete to translation layer + _communicationManager.SendMessage(MessageType.ExecutionComplete, runCompletePayload); + } + }); + } - private void StartTestSession(StartTestSessionPayload payload, ITestRequestManager requestManager) - { - Task.Run(() => + private void StartDiscovery(DiscoveryRequestPayload discoveryRequestPayload, ITestRequestManager testRequestManager) + { + Task.Run( + () => { - var eventsHandler = new TestSessionEventsHandler(this.communicationManager); - try { - var customLauncher = payload.HasCustomHostLauncher - ? DesignModeTestHostLauncherFactory.GetCustomHostLauncherForTestRun(this, payload.IsDebuggingEnabled) - : null; - - requestManager.ResetOptions(); - requestManager.StartTestSession(payload, customLauncher, eventsHandler, this.protocolConfig); + testRequestManager.ResetOptions(); + testRequestManager.DiscoverTests(discoveryRequestPayload, new DesignModeTestEventsRegistrar(this), _protocolConfig); } catch (Exception ex) { - EqtTrace.Error("DesignModeClient: Exception in StartTestSession: " + ex); + EqtTrace.Error("DesignModeClient: Exception in StartDiscovery: " + ex); + + var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = ex.ToString() }; + _communicationManager.SendMessage(MessageType.TestMessage, testMessagePayload); + + var payload = new DiscoveryCompletePayload() + { + IsAborted = true, + LastDiscoveredTests = null, + TotalTests = -1 + }; - eventsHandler.HandleLogMessage(TestMessageLevel.Error, ex.ToString()); - eventsHandler.HandleStartTestSessionComplete(null); + // Send run complete to translation layer + _communicationManager.SendMessage(MessageType.DiscoveryComplete, payload); } }); - } + } - private void StopTestSession(TestSessionInfo testSessionInfo) - { - Task.Run(() => + private void StartTestRunAttachmentsProcessing(TestRunAttachmentsProcessingPayload attachmentsProcessingPayload, ITestRequestManager testRequestManager) + { + Task.Run( + () => { - var eventsHandler = new TestSessionEventsHandler(this.communicationManager); - try { - var stopped = TestSessionPool.Instance.KillSession(testSessionInfo); - - eventsHandler.HandleStopTestSessionComplete(testSessionInfo, stopped); + testRequestManager.ProcessTestRunAttachments(attachmentsProcessingPayload, new TestRunAttachmentsProcessingEventsHandler(_communicationManager), _protocolConfig); } catch (Exception ex) { - EqtTrace.Error("DesignModeClient: Exception in StopTestSession: " + ex); + EqtTrace.Error("DesignModeClient: Exception in StartTestRunAttachmentsProcessing: " + ex); + + var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = ex.ToString() }; + _communicationManager.SendMessage(MessageType.TestMessage, testMessagePayload); + + var payload = new TestRunAttachmentsProcessingCompletePayload() + { + Attachments = null + }; - eventsHandler.HandleLogMessage(TestMessageLevel.Error, ex.ToString()); - eventsHandler.HandleStopTestSessionComplete(testSessionInfo, false); + // Send run complete to translation layer + _communicationManager.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, payload); } }); - } + } + + private void StartTestSession(StartTestSessionPayload payload, ITestRequestManager requestManager) + { + Task.Run(() => + { + var eventsHandler = new TestSessionEventsHandler(_communicationManager); + + try + { + var customLauncher = payload.HasCustomHostLauncher + ? DesignModeTestHostLauncherFactory.GetCustomHostLauncherForTestRun(this, payload.IsDebuggingEnabled) + : null; - #region IDisposable Support + requestManager.ResetOptions(); + requestManager.StartTestSession(payload, customLauncher, eventsHandler, _protocolConfig); + } + catch (Exception ex) + { + EqtTrace.Error("DesignModeClient: Exception in StartTestSession: " + ex); - private bool disposedValue = false; // To detect redundant calls + eventsHandler.HandleLogMessage(TestMessageLevel.Error, ex.ToString()); + eventsHandler.HandleStartTestSessionComplete(null); + } + }); + } - protected virtual void Dispose(bool disposing) + private void StopTestSession(TestSessionInfo testSessionInfo) + { + Task.Run(() => { - if (!disposedValue) + var eventsHandler = new TestSessionEventsHandler(_communicationManager); + + try { - if (disposing) - { - this.communicationManager?.StopClient(); - } + var stopped = TestSessionPool.Instance.KillSession(testSessionInfo); - disposedValue = true; + eventsHandler.HandleStopTestSessionComplete(testSessionInfo, stopped); } - } + catch (Exception ex) + { + EqtTrace.Error("DesignModeClient: Exception in StopTestSession: " + ex); + + eventsHandler.HandleLogMessage(TestMessageLevel.Error, ex.ToString()); + eventsHandler.HandleStopTestSessionComplete(testSessionInfo, false); + } + }); + } + + #region IDisposable Support - // This code added to correctly implement the disposable pattern. - public void Dispose() + private bool _disposedValue = false; // To detect redundant calls + + protected virtual void Dispose(bool disposing) + { + if (!_disposedValue) { - // Do not change this code. Put cleanup code in Dispose(bool disposing) above. - Dispose(true); + if (disposing) + { + _communicationManager?.StopClient(); + } + + _disposedValue = true; } - #endregion } -} + + // This code added to correctly implement the disposable pattern. + public void Dispose() + { + // Do not change this code. Put cleanup code in Dispose(bool disposing) above. + Dispose(true); + } + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestEventsRegistrar.cs b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestEventsRegistrar.cs index be33e0b96d..78a8164aef 100644 --- a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestEventsRegistrar.cs +++ b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestEventsRegistrar.cs @@ -1,66 +1,67 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Client.DesignMode +namespace Microsoft.VisualStudio.TestPlatform.Client.DesignMode; + +using Common.Interfaces; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using ObjectModel.Logging; + +/// +/// Registers the discovery and test run events for design mode flow +/// +public class DesignModeTestEventsRegistrar : ITestDiscoveryEventsRegistrar, ITestRunEventsRegistrar { - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + private readonly IDesignModeClient _designModeClient; + + public DesignModeTestEventsRegistrar(IDesignModeClient designModeClient) + { + _designModeClient = designModeClient; + } + + #region ITestDiscoveryEventsRegistrar + + public void RegisterDiscoveryEvents(IDiscoveryRequest discoveryRequest) + { + discoveryRequest.OnRawMessageReceived += OnRawMessageReceived; + } + + public void UnregisterDiscoveryEvents(IDiscoveryRequest discoveryRequest) + { + discoveryRequest.OnRawMessageReceived -= OnRawMessageReceived; + } + + #endregion + + #region ITestRunEventsRegistrar + + public void RegisterTestRunEvents(ITestRunRequest testRunRequest) + { + testRunRequest.OnRawMessageReceived += OnRawMessageReceived; + } + + public void UnregisterTestRunEvents(ITestRunRequest testRunRequest) + { + testRunRequest.OnRawMessageReceived -= OnRawMessageReceived; + } + + #endregion /// - /// Registers the discovery and test run events for design mode flow + /// RawMessage received handler for getting rawmessages directly from the host /// - public class DesignModeTestEventsRegistrar : ITestDiscoveryEventsRegistrar, ITestRunEventsRegistrar + /// + /// RawMessage from the testhost + private void OnRawMessageReceived(object sender, string rawMessage) + { + // Directly send the data to translation layer instead of de-serializing it here + _designModeClient.SendRawMessage(rawMessage); + } + + public void LogWarning(string message) { - private IDesignModeClient designModeClient; - - public DesignModeTestEventsRegistrar(IDesignModeClient designModeClient) - { - this.designModeClient = designModeClient; - } - - #region ITestDiscoveryEventsRegistrar - - public void RegisterDiscoveryEvents(IDiscoveryRequest discoveryRequest) - { - discoveryRequest.OnRawMessageReceived += OnRawMessageReceived; - } - - public void UnregisterDiscoveryEvents(IDiscoveryRequest discoveryRequest) - { - discoveryRequest.OnRawMessageReceived -= OnRawMessageReceived; - } - - #endregion - - #region ITestRunEventsRegistrar - - public void RegisterTestRunEvents(ITestRunRequest testRunRequest) - { - testRunRequest.OnRawMessageReceived += OnRawMessageReceived; - } - - public void UnregisterTestRunEvents(ITestRunRequest testRunRequest) - { - testRunRequest.OnRawMessageReceived -= OnRawMessageReceived; - } - - #endregion - - /// - /// RawMessage received handler for getting rawmessages directly from the host - /// - /// - /// RawMessage from the testhost - private void OnRawMessageReceived(object sender, string rawMessage) - { - // Directly send the data to translation layer instead of de-serializing it here - this.designModeClient.SendRawMessage(rawMessage); - } - - public void LogWarning(string message) - { - this.designModeClient.SendTestMessage(TestMessageLevel.Warning, message); - } + _designModeClient.SendTestMessage(TestMessageLevel.Warning, message); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestHostLauncher.cs b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestHostLauncher.cs index 33c37b6995..387e35a6b3 100644 --- a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestHostLauncher.cs +++ b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestHostLauncher.cs @@ -1,67 +1,67 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Client.DesignMode +namespace Microsoft.VisualStudio.TestPlatform.Client.DesignMode; + +using System.Threading; + +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; + +/// +/// DesignMode TestHost Launcher for hosting of test process +/// +internal class DesignModeTestHostLauncher : ITestHostLauncher2 { - using System.Threading; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; + private readonly IDesignModeClient _designModeClient; /// - /// DesignMode TestHost Launcher for hosting of test process + /// Initializes a new instance of the class. /// - internal class DesignModeTestHostLauncher : ITestHostLauncher2 + /// Design mode client instance. + public DesignModeTestHostLauncher(IDesignModeClient designModeClient) { - private readonly IDesignModeClient designModeClient; - - /// - /// Initializes a new instance of the class. - /// - /// Design mode client instance. - public DesignModeTestHostLauncher(IDesignModeClient designModeClient) - { - this.designModeClient = designModeClient; - } - - /// - public virtual bool IsDebug => false; - - /// - public bool AttachDebuggerToProcess(int pid) - { - return this.designModeClient.AttachDebuggerToProcess(pid, CancellationToken.None); - } + _designModeClient = designModeClient; + } - /// - public bool AttachDebuggerToProcess(int pid, CancellationToken cancellationToken) - { - return this.designModeClient.AttachDebuggerToProcess(pid, cancellationToken); - } + /// + public virtual bool IsDebug => false; - /// - public int LaunchTestHost(TestProcessStartInfo defaultTestHostStartInfo) - { - return this.designModeClient.LaunchCustomHost(defaultTestHostStartInfo, CancellationToken.None); - } + /// + public bool AttachDebuggerToProcess(int pid) + { + return _designModeClient.AttachDebuggerToProcess(pid, CancellationToken.None); + } - /// - public int LaunchTestHost(TestProcessStartInfo defaultTestHostStartInfo, CancellationToken cancellationToken) - { - return this.designModeClient.LaunchCustomHost(defaultTestHostStartInfo, cancellationToken); - } + /// + public bool AttachDebuggerToProcess(int pid, CancellationToken cancellationToken) + { + return _designModeClient.AttachDebuggerToProcess(pid, cancellationToken); } - /// - /// DesignMode Debug Launcher to use if debugging enabled - /// - internal class DesignModeDebugTestHostLauncher : DesignModeTestHostLauncher + /// + public int LaunchTestHost(TestProcessStartInfo defaultTestHostStartInfo) { - /// - public DesignModeDebugTestHostLauncher(IDesignModeClient designModeClient) : base(designModeClient) - { - } + return _designModeClient.LaunchCustomHost(defaultTestHostStartInfo, CancellationToken.None); + } - /// - public override bool IsDebug => true; + /// + public int LaunchTestHost(TestProcessStartInfo defaultTestHostStartInfo, CancellationToken cancellationToken) + { + return _designModeClient.LaunchCustomHost(defaultTestHostStartInfo, cancellationToken); } } + +/// +/// DesignMode Debug Launcher to use if debugging enabled +/// +internal class DesignModeDebugTestHostLauncher : DesignModeTestHostLauncher +{ + /// + public DesignModeDebugTestHostLauncher(IDesignModeClient designModeClient) : base(designModeClient) + { + } + + /// + public override bool IsDebug => true; +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestHostLauncherFactory.cs b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestHostLauncherFactory.cs index 5b92bc54ba..ea903e6a94 100644 --- a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestHostLauncherFactory.cs +++ b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestHostLauncherFactory.cs @@ -1,33 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Client.DesignMode +namespace Microsoft.VisualStudio.TestPlatform.Client.DesignMode; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; + +/// +/// Factory for providing the design mode test host launchers +/// +public static class DesignModeTestHostLauncherFactory { - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; + private static ITestHostLauncher s_defaultLauncher; + private static ITestHostLauncher s_debugLauncher; - /// - /// Factory for providing the design mode test host launchers - /// - public static class DesignModeTestHostLauncherFactory + public static ITestHostLauncher GetCustomHostLauncherForTestRun(IDesignModeClient designModeClient, bool debuggingEnabled) { - private static ITestHostLauncher defaultLauncher; - private static ITestHostLauncher debugLauncher; - - public static ITestHostLauncher GetCustomHostLauncherForTestRun(IDesignModeClient designModeClient, bool debuggingEnabled) - { - ITestHostLauncher testHostLauncher = null; - - if (!debuggingEnabled) - { - testHostLauncher = defaultLauncher = defaultLauncher ?? new DesignModeTestHostLauncher(designModeClient); - } - else - { - testHostLauncher = debugLauncher = debugLauncher ?? new DesignModeDebugTestHostLauncher(designModeClient); - } - - return testHostLauncher; - } + ITestHostLauncher testHostLauncher = !debuggingEnabled + ? (s_defaultLauncher ??= new DesignModeTestHostLauncher(designModeClient)) + : (s_debugLauncher ??= new DesignModeDebugTestHostLauncher(designModeClient)); + return testHostLauncher; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Client/DesignMode/IDesignModeClient.cs b/src/Microsoft.TestPlatform.Client/DesignMode/IDesignModeClient.cs index 1b633c0a67..83a68a0acf 100644 --- a/src/Microsoft.TestPlatform.Client/DesignMode/IDesignModeClient.cs +++ b/src/Microsoft.TestPlatform.Client/DesignMode/IDesignModeClient.cs @@ -1,57 +1,57 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Client.DesignMode +namespace Microsoft.VisualStudio.TestPlatform.Client.DesignMode; + +using System; +using System.Threading; + +using RequestHelper; +using ObjectModel; +using ObjectModel.Logging; + +/// +/// The interface for design mode client. +/// +public interface IDesignModeClient : IDisposable { - using System; - using System.Threading; - using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + /// + /// Setups client based on port + /// + /// port number to connect + void ConnectToClientAndProcessRequests(int port, ITestRequestManager testRequestManager); + + /// + /// Send a custom host launch message to IDE + /// + /// Default TestHost Start Info + /// The cancellation Token. + /// Process id of the launched test host. + int LaunchCustomHost(TestProcessStartInfo defaultTestHostStartInfo, CancellationToken cancellationToken); + + /// + /// Attach debugger to an already running process. + /// + /// Process ID of the process to which the debugger should be attached. + /// The cancellation token. + /// if the debugger was successfully attached to the requested process, otherwise. + bool AttachDebuggerToProcess(int pid, CancellationToken cancellationToken); + + /// + /// Handles parent process exit + /// + void HandleParentProcessExit(); + + /// + /// Send the raw messages to IDE + /// + /// + void SendRawMessage(string rawMessage); /// - /// The interface for design mode client. + /// Send the test session messages to IDE /// - public interface IDesignModeClient : IDisposable - { - /// - /// Setups client based on port - /// - /// port number to connect - void ConnectToClientAndProcessRequests(int port, ITestRequestManager testRequestManager); - - /// - /// Send a custom host launch message to IDE - /// - /// Default TestHost Start Info - /// The cancellation Token. - /// Process id of the launched test host. - int LaunchCustomHost(TestProcessStartInfo defaultTestHostStartInfo, CancellationToken cancellationToken); - - /// - /// Attach debugger to an already running process. - /// - /// Process ID of the process to which the debugger should be attached. - /// The cancellation token. - /// if the debugger was successfully attached to the requested process, otherwise. - bool AttachDebuggerToProcess(int pid, CancellationToken cancellationToken); - - /// - /// Handles parent process exit - /// - void HandleParentProcessExit(); - - /// - /// Send the raw messages to IDE - /// - /// - void SendRawMessage(string rawMessage); - - /// - /// Send the test session messages to IDE - /// - /// Level for the message - /// Actual message string - void SendTestMessage(TestMessageLevel level, string message); - } -} + /// Level for the message + /// Actual message string + void SendTestMessage(TestMessageLevel level, string message); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Client/Discovery/DiscoveryRequest.cs b/src/Microsoft.TestPlatform.Client/Discovery/DiscoveryRequest.cs index d63a2508e2..182584ee9a 100644 --- a/src/Microsoft.TestPlatform.Client/Discovery/DiscoveryRequest.cs +++ b/src/Microsoft.TestPlatform.Client/Discovery/DiscoveryRequest.cs @@ -1,568 +1,554 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Client.Discovery +namespace Microsoft.VisualStudio.TestPlatform.Client.Discovery; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; + +using Common.Telemetry; +using CommunicationUtilities; +using CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; +using ObjectModel.Logging; +using Utilities; + +/// +/// The discovery request. +/// +public sealed class DiscoveryRequest : IDiscoveryRequest, ITestDiscoveryEventsHandler2 { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading; - - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.Utilities; + private readonly IDataSerializer _dataSerializer; /// - /// The discovery request. + /// Initializes a new instance of the class. /// - public sealed class DiscoveryRequest : IDiscoveryRequest, ITestDiscoveryEventsHandler2 + /// The Request Data instance providing services and data for discovery + /// Discovery criterion. + /// Discovery manager instance. + internal DiscoveryRequest(IRequestData requestData, DiscoveryCriteria criteria, IProxyDiscoveryManager discoveryManager, ITestLoggerManager loggerManager) + : this(requestData, criteria, discoveryManager, loggerManager, JsonDataSerializer.Instance) { - private IDataSerializer dataSerializer; - - /// - /// Initializes a new instance of the class. - /// - /// The Request Data instance providing services and data for discovery - /// Discovery criterion. - /// Discovery manager instance. - internal DiscoveryRequest(IRequestData requestData, DiscoveryCriteria criteria, IProxyDiscoveryManager discoveryManager, ITestLoggerManager loggerManager) - : this(requestData, criteria, discoveryManager, loggerManager, JsonDataSerializer.Instance) - { - } + } + + /// + /// Initializes a new instance of the class. + /// + /// The Request Data instance providing services and data for discovery + /// Discovery criterion. + /// Discovery manager instance. + /// Data Serializer + internal DiscoveryRequest( + IRequestData requestData, + DiscoveryCriteria criteria, + IProxyDiscoveryManager discoveryManager, + ITestLoggerManager loggerManager, + IDataSerializer dataSerializer) + { + RequestData = requestData; + DiscoveryCriteria = criteria; + DiscoveryManager = discoveryManager; + LoggerManager = loggerManager; + _dataSerializer = dataSerializer; + } - /// - /// Initializes a new instance of the class. - /// - /// The Request Data instance providing services and data for discovery - /// Discovery criterion. - /// Discovery manager instance. - /// Data Serializer - internal DiscoveryRequest( - IRequestData requestData, - DiscoveryCriteria criteria, - IProxyDiscoveryManager discoveryManager, - ITestLoggerManager loggerManager, - IDataSerializer dataSerializer) + /// + /// Start the discovery request + /// + public void DiscoverAsync() + { + if (EqtTrace.IsVerboseEnabled) { - this.requestData = requestData; - this.DiscoveryCriteria = criteria; - this.DiscoveryManager = discoveryManager; - this.LoggerManager = loggerManager; - this.dataSerializer = dataSerializer; + EqtTrace.Verbose("DiscoveryRequest.DiscoverAsync: Starting."); } - /// - /// Start the discovery request - /// - public void DiscoverAsync() + lock (_syncObject) { - if (EqtTrace.IsVerboseEnabled) + if (_disposed) { - EqtTrace.Verbose("DiscoveryRequest.DiscoverAsync: Starting."); + throw new ObjectDisposedException("DiscoveryRequest"); } - lock (this.syncObject) - { - if (this.disposed) - { - throw new ObjectDisposedException("DiscoveryRequest"); - } - - // Reset the discovery completion event - this.discoveryCompleted.Reset(); + // Reset the discovery completion event + _discoveryCompleted.Reset(); - this.discoveryInProgress = true; - try - { - this.discoveryStartTime = DateTime.UtcNow; + DiscoveryInProgress = true; + try + { + _discoveryStartTime = DateTime.UtcNow; - // Collecting Data Point Number of sources sent for discovery - this.requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfSourcesSentForDiscovery, this.DiscoveryCriteria.Sources.Count()); + // Collecting Data Point Number of sources sent for discovery + RequestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfSourcesSentForDiscovery, DiscoveryCriteria.Sources.Count()); - // Invoke OnDiscoveryStart event - var discoveryStartEvent = new DiscoveryStartEventArgs(this.DiscoveryCriteria); - this.LoggerManager.HandleDiscoveryStart(discoveryStartEvent); - this.OnDiscoveryStart.SafeInvoke(this, discoveryStartEvent, "DiscoveryRequest.DiscoveryStart"); + // Invoke OnDiscoveryStart event + var discoveryStartEvent = new DiscoveryStartEventArgs(DiscoveryCriteria); + LoggerManager.HandleDiscoveryStart(discoveryStartEvent); + OnDiscoveryStart.SafeInvoke(this, discoveryStartEvent, "DiscoveryRequest.DiscoveryStart"); - this.DiscoveryManager.DiscoverTests(this.DiscoveryCriteria, this); - } - catch - { - this.discoveryInProgress = false; - throw; - } + DiscoveryManager.DiscoverTests(DiscoveryCriteria, this); } - - if (EqtTrace.IsInfoEnabled) + catch { - EqtTrace.Info("DiscoveryRequest.DiscoverAsync: Started."); + DiscoveryInProgress = false; + throw; } } - /// - /// Aborts the test discovery. - /// - public void Abort() + if (EqtTrace.IsInfoEnabled) { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("DiscoveryRequest.Abort: Aborting."); - } - - lock (this.syncObject) - { - if (this.disposed) - { - throw new ObjectDisposedException("DiscoveryRequest"); - } - - if (this.discoveryInProgress) - { - this.DiscoveryManager.Abort(); - } - else - { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DiscoveryRequest.Abort: No operation to abort."); - } - - return; - } - } + EqtTrace.Info("DiscoveryRequest.DiscoverAsync: Started."); + } + } - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DiscoveryRequest.Abort: Aborted."); - } + /// + /// Aborts the test discovery. + /// + public void Abort() + { + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("DiscoveryRequest.Abort: Aborting."); } - /// - /// Wait for discovery completion - /// - /// The timeout. - bool IRequest.WaitForCompletion(int timeout) + lock (_syncObject) { - if (EqtTrace.IsVerboseEnabled) + if (_disposed) { - EqtTrace.Verbose("DiscoveryRequest.WaitForCompletion: Waiting with timeout {0}.", timeout); + throw new ObjectDisposedException("DiscoveryRequest"); } - if (this.disposed) + if (DiscoveryInProgress) { - throw new ObjectDisposedException("DiscoveryRequest"); + DiscoveryManager.Abort(); } - - // This method is not synchronized as it can lead to dead-lock - // (the discoveryCompletionEvent cannot be raised unless that lock is released) - if (this.discoveryCompleted != null) + else { - return this.discoveryCompleted.WaitOne(timeout); + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("DiscoveryRequest.Abort: No operation to abort."); + } + + return; } + } - return true; + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("DiscoveryRequest.Abort: Aborted."); } + } - /// - /// Raised when the test discovery starts. - /// - public event EventHandler OnDiscoveryStart; - - /// - /// Raised when the test discovery completes. - /// - public event EventHandler OnDiscoveryComplete; - - /// - /// Raised when the message is received. - /// - /// TestRunMessageEventArgs should be renamed to more generic - public event EventHandler OnDiscoveryMessage; - - /// - /// Raised when new tests are discovered in this discovery request. - /// - public event EventHandler OnDiscoveredTests; - - /// - /// Raised when a discovery event related message is received from host - /// This is required if one wants to re-direct the message over the process boundary without any processing overhead - /// All the discovery events should come as raw messages as well as proper serialized events like OnDiscoveredTests - /// - public event EventHandler OnRawMessageReceived; - - /// - /// Specifies the discovery criterion - /// - public DiscoveryCriteria DiscoveryCriteria + /// + /// Wait for discovery completion + /// + /// The timeout. + bool IRequest.WaitForCompletion(int timeout) + { + if (EqtTrace.IsVerboseEnabled) { - get; - private set; + EqtTrace.Verbose("DiscoveryRequest.WaitForCompletion: Waiting with timeout {0}.", timeout); } - /// - /// Get the status for the discovery - /// Returns true if discovery is in progress - /// - internal bool DiscoveryInProgress + if (_disposed) { - get { return this.discoveryInProgress; } + throw new ObjectDisposedException("DiscoveryRequest"); } - /// - /// Parent discovery manager - /// - internal IProxyDiscoveryManager DiscoveryManager { get; private set; } + // This method is not synchronized as it can lead to dead-lock + // (the discoveryCompletionEvent cannot be raised unless that lock is released) + return _discoveryCompleted == null || _discoveryCompleted.WaitOne(timeout); + } + + /// + /// Raised when the test discovery starts. + /// + public event EventHandler OnDiscoveryStart; + + /// + /// Raised when the test discovery completes. + /// + public event EventHandler OnDiscoveryComplete; + + /// + /// Raised when the message is received. + /// + /// TestRunMessageEventArgs should be renamed to more generic + public event EventHandler OnDiscoveryMessage; + + /// + /// Raised when new tests are discovered in this discovery request. + /// + public event EventHandler OnDiscoveredTests; + + /// + /// Raised when a discovery event related message is received from host + /// This is required if one wants to re-direct the message over the process boundary without any processing overhead + /// All the discovery events should come as raw messages as well as proper serialized events like OnDiscoveredTests + /// + public event EventHandler OnRawMessageReceived; + + /// + /// Specifies the discovery criterion + /// + public DiscoveryCriteria DiscoveryCriteria + { + get; + private set; + } - /// - /// Logger manager. - /// - internal ITestLoggerManager LoggerManager { get; private set; } + /// + /// Get the status for the discovery + /// Returns true if discovery is in progress + /// + internal bool DiscoveryInProgress { get; private set; } - #region ITestDiscoveryEventsHandler2 Methods + /// + /// Parent discovery manager + /// + internal IProxyDiscoveryManager DiscoveryManager { get; private set; } - /// - public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk) + /// + /// Logger manager. + /// + internal ITestLoggerManager LoggerManager { get; private set; } + + #region ITestDiscoveryEventsHandler2 Methods + + /// + public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk) + { + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("DiscoveryRequest.DiscoveryComplete: Starting. Aborted:{0}, TotalTests:{1}", discoveryCompleteEventArgs.IsAborted, discoveryCompleteEventArgs.TotalCount); + } + + lock (_syncObject) { - if (EqtTrace.IsVerboseEnabled) + if (_disposed) { - EqtTrace.Verbose("DiscoveryRequest.DiscoveryComplete: Starting. Aborted:{0}, TotalTests:{1}", discoveryCompleteEventArgs.IsAborted, discoveryCompleteEventArgs.TotalCount); + if (EqtTrace.IsWarningEnabled) + { + EqtTrace.Warning("DiscoveryRequest.DiscoveryComplete: Ignoring as the object is disposed."); + } + + return; } - lock (this.syncObject) + // If discovery event is already raised, ignore current one. + if (_discoveryCompleted.WaitOne(0)) { - if (this.disposed) + if (EqtTrace.IsVerboseEnabled) { - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning("DiscoveryRequest.DiscoveryComplete: Ignoring as the object is disposed."); - } - - return; + EqtTrace.Verbose("DiscoveryRequest.DiscoveryComplete:Ignoring duplicate DiscoveryComplete. Aborted:{0}, TotalTests:{1}", discoveryCompleteEventArgs.IsAborted, discoveryCompleteEventArgs.TotalCount); } - // If discovery event is already raised, ignore current one. - if (this.discoveryCompleted.WaitOne(0)) - { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("DiscoveryRequest.DiscoveryComplete:Ignoring duplicate DiscoveryComplete. Aborted:{0}, TotalTests:{1}", discoveryCompleteEventArgs.IsAborted, discoveryCompleteEventArgs.TotalCount); - } + return; + } - return; - } + // Close the discovery session and terminate any test host processes. This operation should never + // throw. + DiscoveryManager?.Close(); - // Close the discovery session and terminate any test host processes. This operation should never - // throw. - this.DiscoveryManager?.Close(); + try + { + // Raise onDiscoveredTests event if there are some tests in the last chunk. + // (We don't want to send the tests in the discovery complete event so that programming on top of + // RS client is easier i.e. user does not have to listen on discovery complete event.) + if (lastChunk != null && lastChunk.Any()) + { + var discoveredTestsEvent = new DiscoveredTestsEventArgs(lastChunk); + LoggerManager.HandleDiscoveredTests(discoveredTestsEvent); + OnDiscoveredTests.SafeInvoke(this, discoveredTestsEvent, "DiscoveryRequest.DiscoveryComplete"); + } - try + LoggerManager.HandleDiscoveryComplete(discoveryCompleteEventArgs); + OnDiscoveryComplete.SafeInvoke(this, discoveryCompleteEventArgs, "DiscoveryRequest.DiscoveryComplete"); + } + finally + { + // Notify the waiting handle that discovery is complete + if (_discoveryCompleted != null) { - // Raise onDiscoveredTests event if there are some tests in the last chunk. - // (We don't want to send the tests in the discovery complete event so that programming on top of - // RS client is easier i.e. user does not have to listen on discovery complete event.) - if (lastChunk != null && lastChunk.Any()) + _discoveryCompleted.Set(); + if (EqtTrace.IsVerboseEnabled) { - var discoveredTestsEvent = new DiscoveredTestsEventArgs(lastChunk); - this.LoggerManager.HandleDiscoveredTests(discoveredTestsEvent); - this.OnDiscoveredTests.SafeInvoke(this, discoveredTestsEvent, "DiscoveryRequest.DiscoveryComplete"); + EqtTrace.Verbose("DiscoveryRequest.DiscoveryComplete: Notified the discovery complete event."); } - - this.LoggerManager.HandleDiscoveryComplete(discoveryCompleteEventArgs); - this.OnDiscoveryComplete.SafeInvoke(this, discoveryCompleteEventArgs, "DiscoveryRequest.DiscoveryComplete"); } - finally + else { - // Notify the waiting handle that discovery is complete - if (this.discoveryCompleted != null) - { - this.discoveryCompleted.Set(); - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("DiscoveryRequest.DiscoveryComplete: Notified the discovery complete event."); - } - } - else + if (EqtTrace.IsWarningEnabled) { - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning("DiscoveryRequest.DiscoveryComplete: Discovery complete event was null."); - } + EqtTrace.Warning("DiscoveryRequest.DiscoveryComplete: Discovery complete event was null."); } + } - this.discoveryInProgress = false; - var discoveryFinalTimeTaken = DateTime.UtcNow - this.discoveryStartTime; + DiscoveryInProgress = false; + var discoveryFinalTimeTaken = DateTime.UtcNow - _discoveryStartTime; - // Fill in the Metrics From Test Host Process - var metrics = discoveryCompleteEventArgs.Metrics; - if (metrics != null && metrics.Count != 0) + // Fill in the Metrics From Test Host Process + var metrics = discoveryCompleteEventArgs.Metrics; + if (metrics != null && metrics.Count != 0) + { + foreach (var metric in metrics) { - foreach (var metric in metrics) - { - this.requestData.MetricsCollection.Add(metric.Key, metric.Value); - } + RequestData.MetricsCollection.Add(metric.Key, metric.Value); } - - // Collecting Total Time Taken - this.requestData.MetricsCollection.Add( - TelemetryDataConstants.TimeTakenInSecForDiscovery, discoveryFinalTimeTaken.TotalSeconds); } - } - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DiscoveryRequest.DiscoveryComplete: Completed."); + // Collecting Total Time Taken + RequestData.MetricsCollection.Add( + TelemetryDataConstants.TimeTakenInSecForDiscovery, discoveryFinalTimeTaken.TotalSeconds); } } - /// - public void HandleDiscoveredTests(IEnumerable discoveredTestCases) + if (EqtTrace.IsInfoEnabled) { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("DiscoveryRequest.SendDiscoveredTests: Starting."); - } + EqtTrace.Info("DiscoveryRequest.DiscoveryComplete: Completed."); + } + } + + /// + public void HandleDiscoveredTests(IEnumerable discoveredTestCases) + { + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("DiscoveryRequest.SendDiscoveredTests: Starting."); + } - lock (this.syncObject) + lock (_syncObject) + { + if (_disposed) { - if (this.disposed) + if (EqtTrace.IsWarningEnabled) { - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning("DiscoveryRequest.SendDiscoveredTests: Ignoring as the object is disposed."); - } - - return; + EqtTrace.Warning("DiscoveryRequest.SendDiscoveredTests: Ignoring as the object is disposed."); } - var discoveredTestsEvent = new DiscoveredTestsEventArgs(discoveredTestCases); - this.LoggerManager.HandleDiscoveredTests(discoveredTestsEvent); - this.OnDiscoveredTests.SafeInvoke(this, discoveredTestsEvent, "DiscoveryRequest.OnDiscoveredTests"); + return; } - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DiscoveryRequest.SendDiscoveredTests: Completed."); - } + var discoveredTestsEvent = new DiscoveredTestsEventArgs(discoveredTestCases); + LoggerManager.HandleDiscoveredTests(discoveredTestsEvent); + OnDiscoveredTests.SafeInvoke(this, discoveredTestsEvent, "DiscoveryRequest.OnDiscoveredTests"); } - /// - /// Dispatch TestRunMessage event to listeners. - /// - /// Output level of the message being sent. - /// Actual contents of the message - public void HandleLogMessage(TestMessageLevel level, string message) + if (EqtTrace.IsInfoEnabled) { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("DiscoveryRequest.SendDiscoveryMessage: Starting."); - } + EqtTrace.Info("DiscoveryRequest.SendDiscoveredTests: Completed."); + } + } - lock (this.syncObject) + /// + /// Dispatch TestRunMessage event to listeners. + /// + /// Output level of the message being sent. + /// Actual contents of the message + public void HandleLogMessage(TestMessageLevel level, string message) + { + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("DiscoveryRequest.SendDiscoveryMessage: Starting."); + } + + lock (_syncObject) + { + if (_disposed) { - if (this.disposed) + if (EqtTrace.IsWarningEnabled) { - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning("DiscoveryRequest.SendDiscoveryMessage: Ignoring as the object is disposed."); - } - - return; + EqtTrace.Warning("DiscoveryRequest.SendDiscoveryMessage: Ignoring as the object is disposed."); } - var testRunMessageEvent = new TestRunMessageEventArgs(level, message); - this.LoggerManager.HandleDiscoveryMessage(testRunMessageEvent); - this.OnDiscoveryMessage.SafeInvoke(this, testRunMessageEvent, "DiscoveryRequest.OnTestMessageRecieved"); + return; } - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DiscoveryRequest.SendDiscoveryMessage: Completed."); - } + var testRunMessageEvent = new TestRunMessageEventArgs(level, message); + LoggerManager.HandleDiscoveryMessage(testRunMessageEvent); + OnDiscoveryMessage.SafeInvoke(this, testRunMessageEvent, "DiscoveryRequest.OnTestMessageRecieved"); } - /// - /// Handle Raw message directly from the host - /// - /// Raw message. - public void HandleRawMessage(string rawMessage) + if (EqtTrace.IsInfoEnabled) { - // Note: Deserialize rawMessage only if required. + EqtTrace.Info("DiscoveryRequest.SendDiscoveryMessage: Completed."); + } + } - var message = this.LoggerManager.LoggersInitialized || this.requestData.IsTelemetryOptedIn - ? this.dataSerializer.DeserializeMessage(rawMessage) - : null; + /// + /// Handle Raw message directly from the host + /// + /// Raw message. + public void HandleRawMessage(string rawMessage) + { + // Note: Deserialize rawMessage only if required. - if (string.Equals(message?.MessageType, MessageType.DiscoveryComplete)) - { - var discoveryCompletePayload = this.dataSerializer.DeserializePayload(message); - rawMessage = UpdateRawMessageWithTelemetryInfo(discoveryCompletePayload, message) ?? rawMessage; - HandleLoggerManagerDiscoveryComplete(discoveryCompletePayload); - } + var message = LoggerManager.LoggersInitialized || RequestData.IsTelemetryOptedIn + ? _dataSerializer.DeserializeMessage(rawMessage) + : null; - this.OnRawMessageReceived?.Invoke(this, rawMessage); + if (string.Equals(message?.MessageType, MessageType.DiscoveryComplete)) + { + var discoveryCompletePayload = _dataSerializer.DeserializePayload(message); + rawMessage = UpdateRawMessageWithTelemetryInfo(discoveryCompletePayload, message) ?? rawMessage; + HandleLoggerManagerDiscoveryComplete(discoveryCompletePayload); } - /// - /// Handles LoggerManager's DiscoveryComplete. - /// - /// Discovery complete payload. - private void HandleLoggerManagerDiscoveryComplete(DiscoveryCompletePayload discoveryCompletePayload) + OnRawMessageReceived?.Invoke(this, rawMessage); + } + + /// + /// Handles LoggerManager's DiscoveryComplete. + /// + /// Discovery complete payload. + private void HandleLoggerManagerDiscoveryComplete(DiscoveryCompletePayload discoveryCompletePayload) + { + if (LoggerManager.LoggersInitialized && discoveryCompletePayload != null) { - if (this.LoggerManager.LoggersInitialized && discoveryCompletePayload != null) + // Send last chunk to logger manager. + if (discoveryCompletePayload.LastDiscoveredTests != null) { - // Send last chunk to logger manager. - if (discoveryCompletePayload.LastDiscoveredTests != null) - { - var discoveredTestsEventArgs = new DiscoveredTestsEventArgs(discoveryCompletePayload.LastDiscoveredTests); - this.LoggerManager.HandleDiscoveredTests(discoveredTestsEventArgs); - } - - // Send discovery complete to logger manager. - var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(discoveryCompletePayload.TotalTests, discoveryCompletePayload.IsAborted); - discoveryCompleteEventArgs.Metrics = discoveryCompletePayload.Metrics; - this.LoggerManager.HandleDiscoveryComplete(discoveryCompleteEventArgs); + var discoveredTestsEventArgs = new DiscoveredTestsEventArgs(discoveryCompletePayload.LastDiscoveredTests); + LoggerManager.HandleDiscoveredTests(discoveredTestsEventArgs); } + + // Send discovery complete to logger manager. + var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(discoveryCompletePayload.TotalTests, discoveryCompletePayload.IsAborted); + discoveryCompleteEventArgs.Metrics = discoveryCompletePayload.Metrics; + LoggerManager.HandleDiscoveryComplete(discoveryCompleteEventArgs); } + } - /// - /// Update raw message with telemetry info. - /// - /// Discovery complete payload. - /// Message. - /// Updated rawMessage. - private string UpdateRawMessageWithTelemetryInfo(DiscoveryCompletePayload discoveryCompletePayload, Message message) - { - var rawMessage = default(string); + /// + /// Update raw message with telemetry info. + /// + /// Discovery complete payload. + /// Message. + /// Updated rawMessage. + private string UpdateRawMessageWithTelemetryInfo(DiscoveryCompletePayload discoveryCompletePayload, Message message) + { + var rawMessage = default(string); - if (this.requestData.IsTelemetryOptedIn) + if (RequestData.IsTelemetryOptedIn) + { + if (discoveryCompletePayload != null) { - if (discoveryCompletePayload != null) + if (discoveryCompletePayload.Metrics == null) { - if (discoveryCompletePayload.Metrics == null) - { - discoveryCompletePayload.Metrics = this.requestData.MetricsCollection.Metrics; - } - else + discoveryCompletePayload.Metrics = RequestData.MetricsCollection.Metrics; + } + else + { + foreach (var kvp in RequestData.MetricsCollection.Metrics) { - foreach (var kvp in this.requestData.MetricsCollection.Metrics) - { - discoveryCompletePayload.Metrics[kvp.Key] = kvp.Value; - } + discoveryCompletePayload.Metrics[kvp.Key] = kvp.Value; } - - var discoveryFinalTimeTakenForDesignMode = DateTime.UtcNow - this.discoveryStartTime; - - // Collecting Total Time Taken - discoveryCompletePayload.Metrics[TelemetryDataConstants.TimeTakenInSecForDiscovery] = discoveryFinalTimeTakenForDesignMode.TotalSeconds; } - if (message is VersionedMessage message1) - { - var version = message1.Version; + var discoveryFinalTimeTakenForDesignMode = DateTime.UtcNow - _discoveryStartTime; - rawMessage = this.dataSerializer.SerializePayload( - MessageType.DiscoveryComplete, - discoveryCompletePayload, - version); - } - else - { - rawMessage = this.dataSerializer.SerializePayload( - MessageType.DiscoveryComplete, - discoveryCompletePayload); - } + // Collecting Total Time Taken + discoveryCompletePayload.Metrics[TelemetryDataConstants.TimeTakenInSecForDiscovery] = discoveryFinalTimeTakenForDesignMode.TotalSeconds; } - return rawMessage; + if (message is VersionedMessage message1) + { + var version = message1.Version; + + rawMessage = _dataSerializer.SerializePayload( + MessageType.DiscoveryComplete, + discoveryCompletePayload, + version); + } + else + { + rawMessage = _dataSerializer.SerializePayload( + MessageType.DiscoveryComplete, + discoveryCompletePayload); + } } - #endregion + return rawMessage; + } - #region IDisposable implementation + #endregion - /// - /// Performs application-defined tasks associated with freeing, releasing, or - /// resetting unmanaged resources. - /// - public void Dispose() - { - this.Dispose(true); + #region IDisposable implementation - GC.SuppressFinalize(this); - } + /// + /// Performs application-defined tasks associated with freeing, releasing, or + /// resetting unmanaged resources. + /// + public void Dispose() + { + Dispose(true); - private void Dispose(bool disposing) + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (EqtTrace.IsVerboseEnabled) { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("DiscoveryRequest.Dispose: Starting."); - } + EqtTrace.Verbose("DiscoveryRequest.Dispose: Starting."); + } - lock (this.syncObject) + lock (_syncObject) + { + if (!_disposed) { - if (!this.disposed) + if (disposing) { - if (disposing) + if (_discoveryCompleted != null) { - if (this.discoveryCompleted != null) - { - this.discoveryCompleted.Dispose(); - } + _discoveryCompleted.Dispose(); } - - // Indicate that object has been disposed - this.discoveryCompleted = null; - this.disposed = true; } - } - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DiscoveryRequest.Dispose: Completed."); + // Indicate that object has been disposed + _discoveryCompleted = null; + _disposed = true; } } - #endregion + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("DiscoveryRequest.Dispose: Completed."); + } + } - #region privates fields + #endregion - /// - /// Request Data - /// - internal IRequestData requestData; + #region privates fields - /// - /// If this request has been disposed. - /// - private bool disposed = false; + /// + /// Request Data + /// + internal IRequestData RequestData; - /// - /// It get set when current discovery request is completed. - /// - private ManualResetEvent discoveryCompleted = new ManualResetEvent(false); + /// + /// If this request has been disposed. + /// + private bool _disposed = false; - /// - /// Sync object for various operations - /// - private object syncObject = new Object(); + /// + /// It get set when current discovery request is completed. + /// + private ManualResetEvent _discoveryCompleted = new(false); - /// - /// Whether or not the test discovery is in progress. - /// - private bool discoveryInProgress; + /// + /// Sync object for various operations + /// + private readonly object _syncObject = new(); - /// - /// Discovery Start Time - /// - private DateTime discoveryStartTime; + /// + /// Discovery Start Time + /// + private DateTime _discoveryStartTime; - #endregion - } -} + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Client/Execution/TestRunRequest.cs b/src/Microsoft.TestPlatform.Client/Execution/TestRunRequest.cs index e3efa01cb8..36697c47ea 100644 --- a/src/Microsoft.TestPlatform.Client/Execution/TestRunRequest.cs +++ b/src/Microsoft.TestPlatform.Client/Execution/TestRunRequest.cs @@ -1,698 +1,681 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Client.Execution +namespace Microsoft.VisualStudio.TestPlatform.Client.Execution; + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Threading; + +using Common.Telemetry; +using CommunicationUtilities; +using CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using ObjectModel.Engine; +using ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using Utilities; + +using ClientResources = Resources.Resources; + +public class TestRunRequest : ITestRunRequest, ITestRunEventsHandler2 { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Diagnostics; - using System.Linq; - using System.Threading; - - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities; - - using ClientResources = Microsoft.VisualStudio.TestPlatform.Client.Resources.Resources; - using CommunicationObjectModel = Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - - public class TestRunRequest : ITestRunRequest, ITestRunEventsHandler2 + /// + /// Specifies whether the run is disposed or not + /// + private bool _disposed; + + /// + /// Sync object for various operations + /// + private readonly object _syncObject = new(); + + /// + /// Sync object for cancel operation + /// + private readonly object _cancelSyncObject = new(); + + /// + /// The run completion event which will be signaled on completion of test run. + /// + private ManualResetEvent _runCompletionEvent = new(true); + + /// + /// Tracks the time taken by each run request + /// + private Stopwatch _runRequestTimeTracker; + + private readonly IDataSerializer _dataSerializer; + + /// + /// Time out for run provided by client. + /// + private long _testSessionTimeout; + + private Timer _timer; + + /// + /// Execution Start Time + /// + private DateTime _executionStartTime; + + /// + /// Request Data + /// + private readonly IRequestData _requestData; + + internal TestRunRequest(IRequestData requestData, TestRunCriteria testRunCriteria, IProxyExecutionManager executionManager, ITestLoggerManager loggerManager) : + this(requestData, testRunCriteria, executionManager, loggerManager, JsonDataSerializer.Instance) { - /// - /// The criteria/config for this test run request. - /// - internal TestRunCriteria testRunCriteria; - - /// - /// Specifies whether the run is disposed or not - /// - private bool disposed; - - /// - /// Sync object for various operations - /// - private object syncObject = new object(); - - /// - /// Sync object for cancel operation - /// - private object cancelSyncObject = new object(); - - /// - /// The run completion event which will be signaled on completion of test run. - /// - private ManualResetEvent runCompletionEvent = new ManualResetEvent(true); - - /// - /// Tracks the time taken by each run request - /// - private Stopwatch runRequestTimeTracker; - - private IDataSerializer dataSerializer; - - /// - /// Time out for run provided by client. - /// - private long testSessionTimeout; - - private Timer timer; - - /// - /// Execution Start Time - /// - private DateTime executionStartTime; - - /// - /// Request Data - /// - private IRequestData requestData; - - internal TestRunRequest(IRequestData requestData, TestRunCriteria testRunCriteria, IProxyExecutionManager executionManager, ITestLoggerManager loggerManager) : - this(requestData, testRunCriteria, executionManager, loggerManager, JsonDataSerializer.Instance) - { - } + } - internal TestRunRequest(IRequestData requestData, TestRunCriteria testRunCriteria, IProxyExecutionManager executionManager, ITestLoggerManager loggerManager, IDataSerializer dataSerializer) + internal TestRunRequest(IRequestData requestData, TestRunCriteria testRunCriteria, IProxyExecutionManager executionManager, ITestLoggerManager loggerManager, IDataSerializer dataSerializer) + { + Debug.Assert(testRunCriteria != null, "Test run criteria cannot be null"); + Debug.Assert(executionManager != null, "ExecutionManager cannot be null"); + Debug.Assert(requestData != null, "request Data is null"); + Debug.Assert(loggerManager != null, "LoggerManager cannot be null"); + + if (EqtTrace.IsVerboseEnabled) { - Debug.Assert(testRunCriteria != null, "Test run criteria cannot be null"); - Debug.Assert(executionManager != null, "ExecutionManager cannot be null"); - Debug.Assert(requestData != null, "request Data is null"); - Debug.Assert(loggerManager != null, "LoggerManager cannot be null"); + EqtTrace.Verbose("TestRunRequest.ExecuteAsync: Creating test run request."); + } - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("TestRunRequest.ExecuteAsync: Creating test run request."); - } + TestRunCriteria = testRunCriteria; + ExecutionManager = executionManager; + LoggerManager = loggerManager; + State = TestRunState.Pending; + _dataSerializer = dataSerializer; + _requestData = requestData; + } - this.testRunCriteria = testRunCriteria; - this.ExecutionManager = executionManager; - this.LoggerManager = loggerManager; - this.State = TestRunState.Pending; - this.dataSerializer = dataSerializer; - this.requestData = requestData; - } + #region ITestRunRequest - #region ITestRunRequest + /// + /// Execute the test run asynchronously + /// + /// The process id of test host. + public int ExecuteAsync() + { + EqtTrace.Verbose("TestRunRequest.ExecuteAsync: Starting."); - /// - /// Execute the test run asynchronously - /// - /// The process id of test host. - public int ExecuteAsync() + lock (_syncObject) { - EqtTrace.Verbose("TestRunRequest.ExecuteAsync: Starting."); + if (_disposed) + { + throw new ObjectDisposedException("testRunRequest"); + } - lock (this.syncObject) + if (State != TestRunState.Pending) { - if (this.disposed) - { - throw new ObjectDisposedException("testRunRequest"); - } + throw new InvalidOperationException(ClientResources.InvalidStateForExecution); + } - if (this.State != TestRunState.Pending) - { - throw new InvalidOperationException(ClientResources.InvalidStateForExecution); - } + _executionStartTime = DateTime.UtcNow; - this.executionStartTime = DateTime.UtcNow; + // Collecting Number of sources Sent For Execution + var numberOfSources = (uint)(TestRunCriteria.Sources != null ? TestRunCriteria.Sources.Count() : 0); + _requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfSourcesSentForRun, numberOfSources); - // Collecting Number of sources Sent For Execution - var numberOfSources = (uint)(testRunCriteria.Sources != null ? testRunCriteria.Sources.Count() : 0); - this.requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfSourcesSentForRun, numberOfSources); + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("TestRunRequest.ExecuteAsync: Starting run with settings:{0}", TestRunCriteria); + } - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("TestRunRequest.ExecuteAsync: Starting run with settings:{0}", this.testRunCriteria); - } + if (EqtTrace.IsVerboseEnabled) + { + // Waiting for warm up to be over. + EqtTrace.Verbose("TestRunRequest.ExecuteAsync: Wait for the first run request is over."); + } - if (EqtTrace.IsVerboseEnabled) - { - // Waiting for warm up to be over. - EqtTrace.Verbose("TestRunRequest.ExecuteAsync: Wait for the first run request is over."); - } + State = TestRunState.InProgress; - this.State = TestRunState.InProgress; + // Reset the run completion event + // (This needs to be done before queuing the test run because if the test run finishes fast then runCompletion event can + // remain in non-signaled state even though run is actually complete. + _runCompletionEvent.Reset(); - // Reset the run completion event - // (This needs to be done before queuing the test run because if the test run finishes fast then runCompletion event can - // remain in non-signaled state even though run is actually complete. - this.runCompletionEvent.Reset(); + try + { + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(TestRunCriteria.TestRunSettings); + _testSessionTimeout = runConfiguration.TestSessionTimeout; - try + if (_testSessionTimeout > 0) { - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(this.TestRunCriteria.TestRunSettings); - this.testSessionTimeout = runConfiguration.TestSessionTimeout; - - if (testSessionTimeout > 0) + if (EqtTrace.IsVerboseEnabled) { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose(String.Format("TestRunRequest.ExecuteAsync: TestSessionTimeout is {0} milliseconds.", testSessionTimeout)); - } - - this.timer = new Timer(this.OnTestSessionTimeout, null, TimeSpan.FromMilliseconds(testSessionTimeout), TimeSpan.FromMilliseconds(0)); + EqtTrace.Verbose(String.Format("TestRunRequest.ExecuteAsync: TestSessionTimeout is {0} milliseconds.", _testSessionTimeout)); } - this.runRequestTimeTracker = new Stopwatch(); + _timer = new Timer(OnTestSessionTimeout, null, TimeSpan.FromMilliseconds(_testSessionTimeout), TimeSpan.FromMilliseconds(0)); + } - // Start the stop watch for calculating the test run time taken overall - this.runRequestTimeTracker.Start(); - var testRunStartEvent = new TestRunStartEventArgs(this.testRunCriteria); - this.LoggerManager.HandleTestRunStart(testRunStartEvent); - this.OnRunStart.SafeInvoke(this, testRunStartEvent, "TestRun.TestRunStart"); - int processId = this.ExecutionManager.StartTestRun(this.testRunCriteria, this); + _runRequestTimeTracker = new Stopwatch(); - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("TestRunRequest.ExecuteAsync: Started."); - } + // Start the stop watch for calculating the test run time taken overall + _runRequestTimeTracker.Start(); + var testRunStartEvent = new TestRunStartEventArgs(TestRunCriteria); + LoggerManager.HandleTestRunStart(testRunStartEvent); + OnRunStart.SafeInvoke(this, testRunStartEvent, "TestRun.TestRunStart"); + int processId = ExecutionManager.StartTestRun(TestRunCriteria, this); - return processId; - } - catch + if (EqtTrace.IsInfoEnabled) { - this.State = TestRunState.Pending; - throw; + EqtTrace.Info("TestRunRequest.ExecuteAsync: Started."); } + + return processId; + } + catch + { + State = TestRunState.Pending; + throw; } } + } - internal void OnTestSessionTimeout(object obj) + internal void OnTestSessionTimeout(object obj) + { + if (EqtTrace.IsVerboseEnabled) { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose(string.Format("TestRunRequest.OnTestSessionTimeout: calling cancellation as test run exceeded testSessionTimeout {0} milliseconds", testSessionTimeout)); - } + EqtTrace.Verbose(string.Format("TestRunRequest.OnTestSessionTimeout: calling cancellation as test run exceeded testSessionTimeout {0} milliseconds", _testSessionTimeout)); + } + + string message = string.Format(ClientResources.TestSessionTimeoutMessage, _testSessionTimeout); + var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = message }; + var rawMessage = _dataSerializer.SerializePayload(MessageType.TestMessage, testMessagePayload); + + HandleLogMessage(TestMessageLevel.Error, message); + HandleRawMessage(rawMessage); + Abort(); + } - string message = string.Format(ClientResources.TestSessionTimeoutMessage, this.testSessionTimeout); - var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = message }; - var rawMessage = this.dataSerializer.SerializePayload(MessageType.TestMessage, testMessagePayload); + /// + /// Wait for the run completion + /// + public bool WaitForCompletion(int timeout) + { + EqtTrace.Verbose("TestRunRequest.WaitForCompletion: Waiting with timeout {0}.", timeout); - this.HandleLogMessage(TestMessageLevel.Error, message); - this.HandleRawMessage(rawMessage); - this.Abort(); + if (_disposed) + { + throw new ObjectDisposedException("testRunRequest"); } - /// - /// Wait for the run completion - /// - public bool WaitForCompletion(int timeout) + if (State != TestRunState.InProgress + && !(State == TestRunState.Completed + || State == TestRunState.Canceled + || State == TestRunState.Aborted)) { - EqtTrace.Verbose("TestRunRequest.WaitForCompletion: Waiting with timeout {0}.", timeout); + // If run is already terminated, then we should not throw an exception. + throw new InvalidOperationException(ClientResources.WaitForCompletionOperationIsNotAllowedWhenNoTestRunIsActive); + } + + // This method is not synchronized as it can lead to dead-lock + // (the runCompletionEvent cannot be raised unless that lock is released) + + // Wait for run completion (In case m_runCompletionEvent is closed, then waitOne will throw nice error) + return _runCompletionEvent == null || _runCompletionEvent.WaitOne(timeout); + } - if (this.disposed) + /// + /// Cancel the test run asynchronously + /// + public void CancelAsync() + { + EqtTrace.Verbose("TestRunRequest.CancelAsync: Canceling."); + + lock (_cancelSyncObject) + { + if (_disposed) { - throw new ObjectDisposedException("testRunRequest"); + EqtTrace.Warning("Ignoring TestRunRequest.CancelAsync() as testRunRequest object has already been disposed."); + return; } - if (this.State != TestRunState.InProgress - && !(this.State == TestRunState.Completed - || this.State == TestRunState.Canceled - || this.State == TestRunState.Aborted)) + if (State != TestRunState.InProgress) { - // If run is already terminated, then we should not throw an exception. - throw new InvalidOperationException(ClientResources.WaitForCompletionOperationIsNotAllowedWhenNoTestRunIsActive); + EqtTrace.Info("Ignoring TestRunRequest.CancelAsync(). No test run in progress."); } - - // This method is not synchronized as it can lead to dead-lock - // (the runCompletionEvent cannot be raised unless that lock is released) - - // Wait for run completion (In case m_runCompletionEvent is closed, then waitOne will throw nice error) - if (this.runCompletionEvent != null) + else { - return this.runCompletionEvent.WaitOne(timeout); + // Inform the service about run cancellation + ExecutionManager.Cancel(this); } - - return true; } - /// - /// Cancel the test run asynchronously - /// - public void CancelAsync() - { - EqtTrace.Verbose("TestRunRequest.CancelAsync: Canceling."); - - lock (this.cancelSyncObject) - { - if (this.disposed) - { - EqtTrace.Warning("Ignoring TestRunRequest.CancelAsync() as testRunRequest object has already been disposed."); - return; - } - - if (this.State != TestRunState.InProgress) - { - EqtTrace.Info("Ignoring TestRunRequest.CancelAsync(). No test run in progress."); - } - else - { - // Inform the service about run cancellation - this.ExecutionManager.Cancel(this); - } - } + EqtTrace.Info("TestRunRequest.CancelAsync: Canceled."); + } - EqtTrace.Info("TestRunRequest.CancelAsync: Canceled."); - } + /// + /// Aborts the test run execution process. + /// + public void Abort() + { + EqtTrace.Verbose("TestRunRequest.Abort: Aborting."); - /// - /// Aborts the test run execution process. - /// - public void Abort() + lock (_cancelSyncObject) { - EqtTrace.Verbose("TestRunRequest.Abort: Aborting."); - - lock (this.cancelSyncObject) + if (_disposed) { - if (this.disposed) - { - EqtTrace.Warning("Ignoring TestRunRequest.Abort() as testRunRequest object has already been disposed"); - return; - } - - if (this.State != TestRunState.InProgress) - { - EqtTrace.Info("Ignoring TestRunRequest.Abort(). No test run in progress."); - } - else - { - this.ExecutionManager.Abort(this); - } + EqtTrace.Warning("Ignoring TestRunRequest.Abort() as testRunRequest object has already been disposed"); + return; } - EqtTrace.Info("TestRunRequest.Abort: Aborted."); + if (State != TestRunState.InProgress) + { + EqtTrace.Info("Ignoring TestRunRequest.Abort(). No test run in progress."); + } + else + { + ExecutionManager.Abort(this); + } } + EqtTrace.Info("TestRunRequest.Abort: Aborted."); + } - /// - /// Specifies the test run criteria - /// - public ITestRunConfiguration TestRunConfiguration - { - get { return this.testRunCriteria; } - } - /// - /// State of the test run - /// - public TestRunState State { get; private set; } + /// + /// Specifies the test run criteria + /// + public ITestRunConfiguration TestRunConfiguration + { + get { return TestRunCriteria; } + } + + /// + /// State of the test run + /// + public TestRunState State { get; private set; } - /// - /// Raised when the test run statistics change. - /// - public event EventHandler OnRunStatsChange; + /// + /// Raised when the test run statistics change. + /// + public event EventHandler OnRunStatsChange; - /// - /// Raised when the test run starts. - /// - public event EventHandler OnRunStart; + /// + /// Raised when the test run starts. + /// + public event EventHandler OnRunStart; - /// - /// Raised when the test message is received. - /// - public event EventHandler TestRunMessage; + /// + /// Raised when the test message is received. + /// + public event EventHandler TestRunMessage; - /// - /// Raised when the test run completes. - /// - public event EventHandler OnRunCompletion; + /// + /// Raised when the test run completes. + /// + public event EventHandler OnRunCompletion; - /// - /// Raised when data collection message is received. - /// + /// + /// Raised when data collection message is received. + /// #pragma warning disable 67 - public event EventHandler DataCollectionMessage; + public event EventHandler DataCollectionMessage; #pragma warning restore 67 - /// - /// Raised when a test run event raw message is received from host - /// This is required if one wants to re-direct the message over the process boundary without any processing overhead - /// All the run events should come as raw messages as well as proper serialized events like OnRunStatsChange - /// - public event EventHandler OnRawMessageReceived; - - /// - /// Parent execution manager - /// - internal IProxyExecutionManager ExecutionManager - { - get; private set; - } + /// + /// Raised when a test run event raw message is received from host + /// This is required if one wants to re-direct the message over the process boundary without any processing overhead + /// All the run events should come as raw messages as well as proper serialized events like OnRunStatsChange + /// + public event EventHandler OnRawMessageReceived; + + /// + /// Parent execution manager + /// + internal IProxyExecutionManager ExecutionManager + { + get; private set; + } - /// - /// Logger manager. - /// - internal ITestLoggerManager LoggerManager - { - get; private set; - } + /// + /// Logger manager. + /// + internal ITestLoggerManager LoggerManager + { + get; private set; + } - #endregion + #endregion - #region IDisposable implementation + #region IDisposable implementation - // Summary: - // Performs application-defined tasks associated with freeing, releasing, or - // resetting unmanaged resources. - public void Dispose() - { - this.Dispose(true); + // Summary: + // Performs application-defined tasks associated with freeing, releasing, or + // resetting unmanaged resources. + public void Dispose() + { + Dispose(true); - GC.SuppressFinalize(this); - } + GC.SuppressFinalize(this); + } + + #endregion - #endregion + /// + /// The criteria/config for this test run request. + /// + public TestRunCriteria TestRunCriteria { get; internal set; } - public TestRunCriteria TestRunCriteria + /// + /// Invoked when test run is complete + /// + public void HandleTestRunComplete(TestRunCompleteEventArgs runCompleteArgs, TestRunChangedEventArgs lastChunkArgs, ICollection runContextAttachments, ICollection executorUris) + { + if (runCompleteArgs == null) { - get { return this.testRunCriteria; } + throw new ArgumentNullException(nameof(runCompleteArgs)); } - /// - /// Invoked when test run is complete - /// - public void HandleTestRunComplete(TestRunCompleteEventArgs runCompleteArgs, TestRunChangedEventArgs lastChunkArgs, ICollection runContextAttachments, ICollection executorUris) + bool isAborted = runCompleteArgs.IsAborted; + bool isCanceled = runCompleteArgs.IsCanceled; + + EqtTrace.Verbose("TestRunRequest:TestRunComplete: Starting. IsAborted:{0} IsCanceled:{1}.", isAborted, isCanceled); + + lock (_syncObject) { - if (runCompleteArgs == null) + // If this object is disposed, don't do anything + if (_disposed) { - throw new ArgumentNullException(nameof(runCompleteArgs)); + EqtTrace.Warning("TestRunRequest.TestRunComplete: Ignoring as the object is disposed."); + return; } - bool isAborted = runCompleteArgs.IsAborted; - bool isCanceled = runCompleteArgs.IsCanceled; + if (_runCompletionEvent.WaitOne(0)) + { + EqtTrace.Info("TestRunRequest:TestRunComplete:Ignoring duplicate event. IsAborted:{0} IsCanceled:{1}.", isAborted, isCanceled); + return; + } - EqtTrace.Verbose("TestRunRequest:TestRunComplete: Starting. IsAborted:{0} IsCanceled:{1}.", isAborted, isCanceled); + // Disposing off the resources held by the execution manager so that the test host process can shut down. + ExecutionManager?.Close(); - lock (this.syncObject) + try { - // If this object is disposed, don't do anything - if (this.disposed) - { - EqtTrace.Warning("TestRunRequest.TestRunComplete: Ignoring as the object is disposed."); - return; - } + _runRequestTimeTracker.Stop(); - if (this.runCompletionEvent.WaitOne(0)) + if (lastChunkArgs != null) { - EqtTrace.Info("TestRunRequest:TestRunComplete:Ignoring duplicate event. IsAborted:{0} IsCanceled:{1}.", isAborted, isCanceled); - return; + // Raised the changed event also + LoggerManager.HandleTestRunStatsChange(lastChunkArgs); + OnRunStatsChange.SafeInvoke(this, lastChunkArgs, "TestRun.RunStatsChanged"); } - // Disposing off the resources held by the execution manager so that the test host process can shut down. - this.ExecutionManager?.Close(); - - try + TestRunCompleteEventArgs runCompletedEvent = + new( + runCompleteArgs.TestRunStatistics, + runCompleteArgs.IsCanceled, + runCompleteArgs.IsAborted, + runCompleteArgs.Error, + // This is required as TMI adapter is sending attachments as List which cannot be type casted to Collection. + runContextAttachments != null ? new Collection(runContextAttachments.ToList()) : null, + runCompleteArgs.InvokedDataCollectors, + _runRequestTimeTracker.Elapsed); + + // Ignore the time sent (runCompleteArgs.ElapsedTimeInRunningTests) + // by either engines - as both calculate at different points + // If we use them, it would be an incorrect comparison between TAEF and Rocksteady + LoggerManager.HandleTestRunComplete(runCompletedEvent); + OnRunCompletion.SafeInvoke(this, runCompletedEvent, "TestRun.TestRunComplete"); + } + finally + { + if (isCanceled) { - this.runRequestTimeTracker.Stop(); - - if (lastChunkArgs != null) - { - // Raised the changed event also - this.LoggerManager.HandleTestRunStatsChange(lastChunkArgs); - this.OnRunStatsChange.SafeInvoke(this, lastChunkArgs, "TestRun.RunStatsChanged"); - } - - TestRunCompleteEventArgs runCompletedEvent = - new TestRunCompleteEventArgs( - runCompleteArgs.TestRunStatistics, - runCompleteArgs.IsCanceled, - runCompleteArgs.IsAborted, - runCompleteArgs.Error, - // This is required as TMI adapter is sending attachments as List which cannot be type casted to Collection. - runContextAttachments != null ? new Collection(runContextAttachments.ToList()) : null, - runCompleteArgs.InvokedDataCollectors, - this.runRequestTimeTracker.Elapsed); - - // Ignore the time sent (runCompleteArgs.ElapsedTimeInRunningTests) - // by either engines - as both calculate at different points - // If we use them, it would be an incorrect comparison between TAEF and Rocksteady - this.LoggerManager.HandleTestRunComplete(runCompletedEvent); - this.OnRunCompletion.SafeInvoke(this, runCompletedEvent, "TestRun.TestRunComplete"); + State = TestRunState.Canceled; } - finally + else { - if (isCanceled) - { - this.State = TestRunState.Canceled; - } - else if (isAborted) - { - this.State = TestRunState.Aborted; - } - else - { - this.State = TestRunState.Completed; - } + State = isAborted ? TestRunState.Aborted : TestRunState.Completed; + } - // Notify the waiting handle that run is complete - this.runCompletionEvent.Set(); + // Notify the waiting handle that run is complete + _runCompletionEvent.Set(); - var executionTotalTimeTaken = DateTime.UtcNow - this.executionStartTime; + var executionTotalTimeTaken = DateTime.UtcNow - _executionStartTime; - // Fill in the time taken to complete the run - this.requestData.MetricsCollection.Add(TelemetryDataConstants.TimeTakenInSecForRun, executionTotalTimeTaken.TotalSeconds); + // Fill in the time taken to complete the run + _requestData.MetricsCollection.Add(TelemetryDataConstants.TimeTakenInSecForRun, executionTotalTimeTaken.TotalSeconds); - // Fill in the Metrics From Test Host Process - var metrics = runCompleteArgs.Metrics; - if (metrics != null && metrics.Count != 0) + // Fill in the Metrics From Test Host Process + var metrics = runCompleteArgs.Metrics; + if (metrics != null && metrics.Count != 0) + { + foreach (var metric in metrics) { - foreach (var metric in metrics) - { - this.requestData.MetricsCollection.Add(metric.Key, metric.Value); - } + _requestData.MetricsCollection.Add(metric.Key, metric.Value); } } - - EqtTrace.Info("TestRunRequest:TestRunComplete: Completed."); } + + EqtTrace.Info("TestRunRequest:TestRunComplete: Completed."); } + } - /// - /// Invoked when test run statistics change. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1", Justification = "This is not an external event")] - public virtual void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChangedArgs) + /// + /// Invoked when test run statistics change. + /// + public virtual void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChangedArgs) + { + if (testRunChangedArgs != null) { - if (testRunChangedArgs != null) + EqtTrace.Verbose("TestRunRequest:SendTestRunStatsChange: Starting."); + if (testRunChangedArgs.ActiveTests != null) { - EqtTrace.Verbose("TestRunRequest:SendTestRunStatsChange: Starting."); - if (testRunChangedArgs.ActiveTests != null) - { - // Do verbose check to save performance in iterating test cases - if (EqtTrace.IsVerboseEnabled) - { - foreach (TestCase testCase in testRunChangedArgs.ActiveTests) - { - EqtTrace.Verbose("InProgress is {0}", testCase.DisplayName); - } - } - } - - lock (this.syncObject) + // Do verbose check to save performance in iterating test cases + if (EqtTrace.IsVerboseEnabled) { - // If this object is disposed, don't do anything - if (this.disposed) + foreach (TestCase testCase in testRunChangedArgs.ActiveTests) { - EqtTrace.Warning("TestRunRequest.SendTestRunStatsChange: Ignoring as the object is disposed."); - return; + EqtTrace.Verbose("InProgress is {0}", testCase.DisplayName); } - - // TODO: Invoke this event in a separate thread. - // For now, I am setting the ConcurrencyMode on the callback attribute to Multiple - this.LoggerManager.HandleTestRunStatsChange(testRunChangedArgs); - this.OnRunStatsChange.SafeInvoke(this, testRunChangedArgs, "TestRun.RunStatsChanged"); } - - EqtTrace.Info("TestRunRequest:SendTestRunStatsChange: Completed."); } - } - /// - /// Invoked when log messages are received - /// - public void HandleLogMessage(TestMessageLevel level, string message) - { - EqtTrace.Verbose("TestRunRequest:SendTestRunMessage: Starting."); - - lock (this.syncObject) + lock (_syncObject) { // If this object is disposed, don't do anything - if (this.disposed) + if (_disposed) { - EqtTrace.Warning("TestRunRequest.SendTestRunMessage: Ignoring as the object is disposed."); + EqtTrace.Warning("TestRunRequest.SendTestRunStatsChange: Ignoring as the object is disposed."); return; } - var testRunMessageEvent = new TestRunMessageEventArgs(level, message); - this.LoggerManager.HandleTestRunMessage(testRunMessageEvent); - this.TestRunMessage.SafeInvoke(this, testRunMessageEvent, "TestRun.LogMessages"); + // TODO: Invoke this event in a separate thread. + // For now, I am setting the ConcurrencyMode on the callback attribute to Multiple + LoggerManager.HandleTestRunStatsChange(testRunChangedArgs); + OnRunStatsChange.SafeInvoke(this, testRunChangedArgs, "TestRun.RunStatsChanged"); } - EqtTrace.Info("TestRunRequest:SendTestRunMessage: Completed."); + EqtTrace.Info("TestRunRequest:SendTestRunStatsChange: Completed."); } + } - /// - /// Handle Raw message directly from the host - /// - /// - public void HandleRawMessage(string rawMessage) - { - // Note: Deserialize rawMessage only if required. - - var message = this.LoggerManager.LoggersInitialized || this.requestData.IsTelemetryOptedIn ? - this.dataSerializer.DeserializeMessage(rawMessage) : null; + /// + /// Invoked when log messages are received + /// + public void HandleLogMessage(TestMessageLevel level, string message) + { + EqtTrace.Verbose("TestRunRequest:SendTestRunMessage: Starting."); - if (string.Equals(message?.MessageType, MessageType.ExecutionComplete)) + lock (_syncObject) + { + // If this object is disposed, don't do anything + if (_disposed) { - var testRunCompletePayload = this.dataSerializer.DeserializePayload(message); - rawMessage = UpdateRawMessageWithTelemetryInfo(testRunCompletePayload, message) ?? rawMessage; - HandleLoggerManagerTestRunComplete(testRunCompletePayload); + EqtTrace.Warning("TestRunRequest.SendTestRunMessage: Ignoring as the object is disposed."); + return; } - this.OnRawMessageReceived?.Invoke(this, rawMessage); + var testRunMessageEvent = new TestRunMessageEventArgs(level, message); + LoggerManager.HandleTestRunMessage(testRunMessageEvent); + TestRunMessage.SafeInvoke(this, testRunMessageEvent, "TestRun.LogMessages"); } - /// - /// Handles LoggerManager's TestRunComplete. - /// - /// TestRun complete payload. - private void HandleLoggerManagerTestRunComplete(TestRunCompletePayload testRunCompletePayload) - { - if (this.LoggerManager.LoggersInitialized && testRunCompletePayload != null) - { - // Send last chunk to logger manager. - if (testRunCompletePayload.LastRunTests != null) - { - this.LoggerManager.HandleTestRunStatsChange(testRunCompletePayload.LastRunTests); - } + EqtTrace.Info("TestRunRequest:SendTestRunMessage: Completed."); + } - // Note: In HandleRawMessage attachments are considered from TestRunCompleteArgs, while in HandleTestRunComplete attachments are considered directly from testRunCompletePayload. - // Ideally we should have attachmentSets at one place only. - // Send test run complete to logger manager. - TestRunCompleteEventArgs testRunCompleteArgs = - new TestRunCompleteEventArgs( - testRunCompletePayload.TestRunCompleteArgs.TestRunStatistics, - testRunCompletePayload.TestRunCompleteArgs.IsCanceled, - testRunCompletePayload.TestRunCompleteArgs.IsAborted, - testRunCompletePayload.TestRunCompleteArgs.Error, - testRunCompletePayload.TestRunCompleteArgs.AttachmentSets, - testRunCompletePayload.TestRunCompleteArgs.InvokedDataCollectors, - this.runRequestTimeTracker.Elapsed); - this.LoggerManager.HandleTestRunComplete(testRunCompleteArgs); - } + /// + /// Handle Raw message directly from the host + /// + /// + public void HandleRawMessage(string rawMessage) + { + // Note: Deserialize rawMessage only if required. + + var message = LoggerManager.LoggersInitialized || _requestData.IsTelemetryOptedIn ? + _dataSerializer.DeserializeMessage(rawMessage) : null; + + if (string.Equals(message?.MessageType, MessageType.ExecutionComplete)) + { + var testRunCompletePayload = _dataSerializer.DeserializePayload(message); + rawMessage = UpdateRawMessageWithTelemetryInfo(testRunCompletePayload, message) ?? rawMessage; + HandleLoggerManagerTestRunComplete(testRunCompletePayload); } - /// - /// Update raw message with telemetry info. - /// - /// Test run complete payload. - /// Updated rawMessage. - /// - private string UpdateRawMessageWithTelemetryInfo(TestRunCompletePayload testRunCompletePayload, Message message) + OnRawMessageReceived?.Invoke(this, rawMessage); + } + + /// + /// Handles LoggerManager's TestRunComplete. + /// + /// TestRun complete payload. + private void HandleLoggerManagerTestRunComplete(TestRunCompletePayload testRunCompletePayload) + { + if (LoggerManager.LoggersInitialized && testRunCompletePayload != null) { - var rawMessage = default(string); - if (this.requestData.IsTelemetryOptedIn) + // Send last chunk to logger manager. + if (testRunCompletePayload.LastRunTests != null) { - if (testRunCompletePayload?.TestRunCompleteArgs != null) - { - if (testRunCompletePayload.TestRunCompleteArgs.Metrics == null) - { - testRunCompletePayload.TestRunCompleteArgs.Metrics = this.requestData.MetricsCollection.Metrics; - } - else - { - foreach (var kvp in this.requestData.MetricsCollection.Metrics) - { - testRunCompletePayload.TestRunCompleteArgs.Metrics[kvp.Key] = kvp.Value; - } - } + LoggerManager.HandleTestRunStatsChange(testRunCompletePayload.LastRunTests); + } - // Fill in the time taken to complete the run - var executionTotalTimeTakenForDesignMode = DateTime.UtcNow - this.executionStartTime; - testRunCompletePayload.TestRunCompleteArgs.Metrics[TelemetryDataConstants.TimeTakenInSecForRun] = executionTotalTimeTakenForDesignMode.TotalSeconds; - } + // Note: In HandleRawMessage attachments are considered from TestRunCompleteArgs, while in HandleTestRunComplete attachments are considered directly from testRunCompletePayload. + // Ideally we should have attachmentSets at one place only. + // Send test run complete to logger manager. + TestRunCompleteEventArgs testRunCompleteArgs = + new( + testRunCompletePayload.TestRunCompleteArgs.TestRunStatistics, + testRunCompletePayload.TestRunCompleteArgs.IsCanceled, + testRunCompletePayload.TestRunCompleteArgs.IsAborted, + testRunCompletePayload.TestRunCompleteArgs.Error, + testRunCompletePayload.TestRunCompleteArgs.AttachmentSets, + testRunCompletePayload.TestRunCompleteArgs.InvokedDataCollectors, + _runRequestTimeTracker.Elapsed); + LoggerManager.HandleTestRunComplete(testRunCompleteArgs); + } + } - if (message is VersionedMessage message1) + /// + /// Update raw message with telemetry info. + /// + /// Test run complete payload. + /// Updated rawMessage. + /// + private string UpdateRawMessageWithTelemetryInfo(TestRunCompletePayload testRunCompletePayload, Message message) + { + var rawMessage = default(string); + if (_requestData.IsTelemetryOptedIn) + { + if (testRunCompletePayload?.TestRunCompleteArgs != null) + { + if (testRunCompletePayload.TestRunCompleteArgs.Metrics == null) { - var version = message1.Version; - - rawMessage = this.dataSerializer.SerializePayload( - MessageType.ExecutionComplete, - testRunCompletePayload, - version); + testRunCompletePayload.TestRunCompleteArgs.Metrics = _requestData.MetricsCollection.Metrics; } else { - rawMessage = this.dataSerializer.SerializePayload( - MessageType.ExecutionComplete, - testRunCompletePayload); + foreach (var kvp in _requestData.MetricsCollection.Metrics) + { + testRunCompletePayload.TestRunCompleteArgs.Metrics[kvp.Key] = kvp.Value; + } } - } - return rawMessage; - } + // Fill in the time taken to complete the run + var executionTotalTimeTakenForDesignMode = DateTime.UtcNow - _executionStartTime; + testRunCompletePayload.TestRunCompleteArgs.Metrics[TelemetryDataConstants.TimeTakenInSecForRun] = executionTotalTimeTakenForDesignMode.TotalSeconds; + } - /// - /// Launch process with debugger attached - /// - /// - /// processid - public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) - { - int processId = -1; + if (message is VersionedMessage message1) + { + var version = message1.Version; - // Only launch while the test run is in progress and the launcher is a debug one - if (this.State == TestRunState.InProgress && this.testRunCriteria.TestHostLauncher.IsDebug) + rawMessage = _dataSerializer.SerializePayload( + MessageType.ExecutionComplete, + testRunCompletePayload, + version); + } + else { - processId = this.testRunCriteria.TestHostLauncher.LaunchTestHost(testProcessStartInfo); + rawMessage = _dataSerializer.SerializePayload( + MessageType.ExecutionComplete, + testRunCompletePayload); } - - return processId; } - /// - public bool AttachDebuggerToProcess(int pid) + return rawMessage; + } + + /// + /// Launch process with debugger attached + /// + /// + /// processid + public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) + { + int processId = -1; + + // Only launch while the test run is in progress and the launcher is a debug one + if (State == TestRunState.InProgress && TestRunCriteria.TestHostLauncher.IsDebug) { - return this.testRunCriteria.TestHostLauncher is ITestHostLauncher2 launcher - && launcher.AttachDebuggerToProcess(pid); + processId = TestRunCriteria.TestHostLauncher.LaunchTestHost(testProcessStartInfo); } - /// - /// Dispose the run - /// - /// - protected virtual void Dispose(bool disposing) - { - EqtTrace.Verbose("TestRunRequest.Dispose: Starting."); + return processId; + } + + /// + public bool AttachDebuggerToProcess(int pid) + { + return TestRunCriteria.TestHostLauncher is ITestHostLauncher2 launcher + && launcher.AttachDebuggerToProcess(pid); + } - lock (this.syncObject) + /// + /// Dispose the run + /// + /// + protected virtual void Dispose(bool disposing) + { + EqtTrace.Verbose("TestRunRequest.Dispose: Starting."); + + lock (_syncObject) + { + if (!_disposed) { - if (!this.disposed) + if (disposing) { - if (disposing) - { - this.runCompletionEvent?.Dispose(); - } - - // Indicate that object has been disposed - this.runCompletionEvent = null; - this.disposed = true; + _runCompletionEvent?.Dispose(); } - } - EqtTrace.Info("TestRunRequest.Dispose: Completed."); + // Indicate that object has been disposed + _runCompletionEvent = null; + _disposed = true; + } } + + EqtTrace.Info("TestRunRequest.Dispose: Completed."); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Client/RequestHelper/ITestRequestManager.cs b/src/Microsoft.TestPlatform.Client/RequestHelper/ITestRequestManager.cs index 714e1df9cb..224d4c22d8 100644 --- a/src/Microsoft.TestPlatform.Client/RequestHelper/ITestRequestManager.cs +++ b/src/Microsoft.TestPlatform.Client/RequestHelper/ITestRequestManager.cs @@ -1,110 +1,110 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Client.RequestHelper -{ - using System; - using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.Client; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; +namespace Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; + +using System; +using System.Collections.Generic; + +using Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; + +/// +/// Defines the contract for running various requests. +/// +public interface ITestRequestManager : IDisposable +{ /// - /// Defines the contract for running various requests. + /// Initializes the extensions while probing additional paths. /// - public interface ITestRequestManager : IDisposable - { - /// - /// Initializes the extensions while probing additional paths. - /// - /// - /// Paths to additional extensions. - /// Skip extension filtering by name if true. - void InitializeExtensions( - IEnumerable pathToAdditionalExtensions, - bool skipExtensionFilters); + /// + /// Paths to additional extensions. + /// Skip extension filtering by name if true. + void InitializeExtensions( + IEnumerable pathToAdditionalExtensions, + bool skipExtensionFilters); - /// - /// Resets vstest.console.exe options. - /// - void ResetOptions(); + /// + /// Resets vstest.console.exe options. + /// + void ResetOptions(); - /// - /// Discovers tests given a list of sources and some run settings. - /// - /// - /// Discovery payload. - /// Discovery events registrar. - /// Protocol related information. - void DiscoverTests( - DiscoveryRequestPayload discoveryPayload, - ITestDiscoveryEventsRegistrar disoveryEventsRegistrar, - ProtocolConfig protocolConfig); + /// + /// Discovers tests given a list of sources and some run settings. + /// + /// + /// Discovery payload. + /// Discovery events registrar. + /// Protocol related information. + void DiscoverTests( + DiscoveryRequestPayload discoveryPayload, + ITestDiscoveryEventsRegistrar disoveryEventsRegistrar, + ProtocolConfig protocolConfig); - /// - /// Runs tests given a list of sources and some run settings. - /// - /// - /// Test run request payload. - /// Custom test host launcher for the run. - /// Run events registrar. - /// Protocol related information. - void RunTests( - TestRunRequestPayload testRunRequestPayLoad, - ITestHostLauncher customTestHostLauncher, - ITestRunEventsRegistrar testRunEventsRegistrar, - ProtocolConfig protocolConfig); + /// + /// Runs tests given a list of sources and some run settings. + /// + /// + /// Test run request payload. + /// Custom test host launcher for the run. + /// Run events registrar. + /// Protocol related information. + void RunTests( + TestRunRequestPayload testRunRequestPayLoad, + ITestHostLauncher customTestHostLauncher, + ITestRunEventsRegistrar testRunEventsRegistrar, + ProtocolConfig protocolConfig); - /// - /// Processes test run attachments. - /// - /// - /// - /// Test run attachments processing payload. - /// - /// - /// Test run attachments processing events handler. - /// - /// Protocol related information. - void ProcessTestRunAttachments( - TestRunAttachmentsProcessingPayload testRunAttachmentsProcessingPayload, - ITestRunAttachmentsProcessingEventsHandler testRunAttachmentsProcessingEventsHandler, - ProtocolConfig protocolConfig); + /// + /// Processes test run attachments. + /// + /// + /// + /// Test run attachments processing payload. + /// + /// + /// Test run attachments processing events handler. + /// + /// Protocol related information. + void ProcessTestRunAttachments( + TestRunAttachmentsProcessingPayload testRunAttachmentsProcessingPayload, + ITestRunAttachmentsProcessingEventsHandler testRunAttachmentsProcessingEventsHandler, + ProtocolConfig protocolConfig); - /// - /// Starts a test session. - /// - /// - /// The start test session payload. - /// The custom test host launcher. - /// The events handler. - /// Protocol related information. - void StartTestSession( - StartTestSessionPayload payload, - ITestHostLauncher testHostLauncher, - ITestSessionEventsHandler eventsHandler, - ProtocolConfig protocolConfig); + /// + /// Starts a test session. + /// + /// + /// The start test session payload. + /// The custom test host launcher. + /// The events handler. + /// Protocol related information. + void StartTestSession( + StartTestSessionPayload payload, + ITestHostLauncher testHostLauncher, + ITestSessionEventsHandler eventsHandler, + ProtocolConfig protocolConfig); - /// - /// Cancel the current test run request. - /// - void CancelTestRun(); + /// + /// Cancel the current test run request. + /// + void CancelTestRun(); - /// - /// Abort the current test run. - /// - void AbortTestRun(); + /// + /// Abort the current test run. + /// + void AbortTestRun(); - /// - /// Cancels the current discovery request. - /// - void CancelDiscovery(); + /// + /// Cancels the current discovery request. + /// + void CancelDiscovery(); - /// - /// Cancels the current test run attachments processing request. - /// - void CancelTestRunAttachmentsProcessing(); - } -} + /// + /// Cancels the current test run attachments processing request. + /// + void CancelTestRunAttachmentsProcessing(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Client/TestPlatform.cs b/src/Microsoft.TestPlatform.Client/TestPlatform.cs index bb7c62320d..3e3814b68c 100644 --- a/src/Microsoft.TestPlatform.Client/TestPlatform.cs +++ b/src/Microsoft.TestPlatform.Client/TestPlatform.cs @@ -1,339 +1,339 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Client +namespace Microsoft.VisualStudio.TestPlatform.Client; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; + +using Discovery; +using Execution; +using Common; +using Common.ExtensionFramework; +using Common.Hosting; +using Common.Logging; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using CrossPlatEngine; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; +using ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using PlatformAbstractions; +using Utilities.Helpers; +using Utilities.Helpers.Interfaces; + +using ClientResources = Resources.Resources; + +/// +/// Implementation for TestPlatform. +/// +internal class TestPlatform : ITestPlatform { - using System; - using System.Collections.Generic; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Reflection; - - using Microsoft.VisualStudio.TestPlatform.Client.Discovery; - using Microsoft.VisualStudio.TestPlatform.Client.Execution; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.Hosting; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using ClientResources = Resources.Resources; + private readonly TestRuntimeProviderManager _testHostProviderManager; + + private readonly IFileHelper _fileHelper; + + static TestPlatform() + { + // TODO: This is not the right way to force initialization of default extensions. + // Test runtime providers require this today. They're getting initialized even before + // test adapter paths are provided, which is incorrect. + AddExtensionAssembliesFromExtensionDirectory(); + } /// - /// Implementation for TestPlatform. + /// Initializes a new instance of the class. /// - internal class TestPlatform : ITestPlatform + public TestPlatform() + : this( + new TestEngine(), + new FileHelper(), + TestRuntimeProviderManager.Instance) { - private readonly TestRuntimeProviderManager testHostProviderManager; + } - private readonly IFileHelper fileHelper; + /// + /// Initializes a new instance of the class. + /// + /// + /// The test engine. + /// The file helper. + /// The data. + protected TestPlatform( + ITestEngine testEngine, + IFileHelper filehelper, + TestRuntimeProviderManager testHostProviderManager) + { + TestEngine = testEngine; + _fileHelper = filehelper; + _testHostProviderManager = testHostProviderManager; + } - static TestPlatform() - { - // TODO: This is not the right way to force initialization of default extensions. - // Test runtime providers require this today. They're getting initialized even before - // test adapter paths are provided, which is incorrect. - AddExtensionAssembliesFromExtensionDirectory(); - } + /// + /// Gets or sets the test engine instance. + /// + private ITestEngine TestEngine { get; set; } - /// - /// Initializes a new instance of the class. - /// - public TestPlatform() - : this( - new TestEngine(), - new FileHelper(), - TestRuntimeProviderManager.Instance) + /// + public IDiscoveryRequest CreateDiscoveryRequest( + IRequestData requestData, + DiscoveryCriteria discoveryCriteria, + TestPlatformOptions options) + { + if (discoveryCriteria == null) { + throw new ArgumentNullException(nameof(discoveryCriteria)); } - /// - /// Initializes a new instance of the class. - /// - /// - /// The test engine. - /// The file helper. - /// The data. - protected TestPlatform( - ITestEngine testEngine, - IFileHelper filehelper, - TestRuntimeProviderManager testHostProviderManager) + // Update cache with Extension folder's files. + AddExtensionAssemblies(discoveryCriteria.RunSettings); + + // Update extension assemblies from source when design mode is false. + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(discoveryCriteria.RunSettings); + if (!runConfiguration.DesignMode) { - this.TestEngine = testEngine; - this.fileHelper = filehelper; - this.testHostProviderManager = testHostProviderManager; + AddExtensionAssembliesFromSource(discoveryCriteria.Sources); } - /// - /// Gets or sets the test engine instance. - /// - private ITestEngine TestEngine { get; set; } + // Initialize loggers. + var loggerManager = TestEngine.GetLoggerManager(requestData); + loggerManager.Initialize(discoveryCriteria.RunSettings); - /// - public IDiscoveryRequest CreateDiscoveryRequest( - IRequestData requestData, - DiscoveryCriteria discoveryCriteria, - TestPlatformOptions options) - { - if (discoveryCriteria == null) - { - throw new ArgumentNullException(nameof(discoveryCriteria)); - } + var testHostManager = _testHostProviderManager.GetTestHostManagerByRunConfiguration(discoveryCriteria.RunSettings); + ThrowExceptionIfTestHostManagerIsNull(testHostManager, discoveryCriteria.RunSettings); - // Update cache with Extension folder's files. - this.AddExtensionAssemblies(discoveryCriteria.RunSettings); - - // Update extension assemblies from source when design mode is false. - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(discoveryCriteria.RunSettings); - if (!runConfiguration.DesignMode) - { - this.AddExtensionAssembliesFromSource(discoveryCriteria.Sources); - } + testHostManager.Initialize(TestSessionMessageLogger.Instance, discoveryCriteria.RunSettings); - // Initialize loggers. - var loggerManager = this.TestEngine.GetLoggerManager(requestData); - loggerManager.Initialize(discoveryCriteria.RunSettings); + var discoveryManager = TestEngine.GetDiscoveryManager(requestData, testHostManager, discoveryCriteria); + discoveryManager.Initialize(options?.SkipDefaultAdapters ?? false); - var testHostManager = this.testHostProviderManager.GetTestHostManagerByRunConfiguration(discoveryCriteria.RunSettings); - ThrowExceptionIfTestHostManagerIsNull(testHostManager, discoveryCriteria.RunSettings); + return new DiscoveryRequest(requestData, discoveryCriteria, discoveryManager, loggerManager); + } - testHostManager.Initialize(TestSessionMessageLogger.Instance, discoveryCriteria.RunSettings); + /// + public ITestRunRequest CreateTestRunRequest( + IRequestData requestData, + TestRunCriteria testRunCriteria, + TestPlatformOptions options) + { + if (testRunCriteria == null) + { + throw new ArgumentNullException(nameof(testRunCriteria)); + } - var discoveryManager = this.TestEngine.GetDiscoveryManager(requestData, testHostManager, discoveryCriteria); - discoveryManager.Initialize(options?.SkipDefaultAdapters ?? false); + AddExtensionAssemblies(testRunCriteria.TestRunSettings); - return new DiscoveryRequest(requestData, discoveryCriteria, discoveryManager, loggerManager); - } + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(testRunCriteria.TestRunSettings); - /// - public ITestRunRequest CreateTestRunRequest( - IRequestData requestData, - TestRunCriteria testRunCriteria, - TestPlatformOptions options) + // Update extension assemblies from source when design mode is false. + if (!runConfiguration.DesignMode) { - if (testRunCriteria == null) - { - throw new ArgumentNullException(nameof(testRunCriteria)); - } + AddExtensionAssembliesFromSource(testRunCriteria); + } - this.AddExtensionAssemblies(testRunCriteria.TestRunSettings); + // Initialize loggers. + var loggerManager = TestEngine.GetLoggerManager(requestData); + loggerManager.Initialize(testRunCriteria.TestRunSettings); - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(testRunCriteria.TestRunSettings); + var testHostManager = _testHostProviderManager.GetTestHostManagerByRunConfiguration(testRunCriteria.TestRunSettings); + ThrowExceptionIfTestHostManagerIsNull(testHostManager, testRunCriteria.TestRunSettings); - // Update extension assemblies from source when design mode is false. - if (!runConfiguration.DesignMode) - { - this.AddExtensionAssembliesFromSource(testRunCriteria); - } + testHostManager.Initialize(TestSessionMessageLogger.Instance, testRunCriteria.TestRunSettings); - // Initialize loggers. - var loggerManager = this.TestEngine.GetLoggerManager(requestData); - loggerManager.Initialize(testRunCriteria.TestRunSettings); + // NOTE: The custom launcher should not be set when we have test session info available. + if (testRunCriteria.TestHostLauncher != null) + { + testHostManager.SetCustomLauncher(testRunCriteria.TestHostLauncher); + } - var testHostManager = this.testHostProviderManager.GetTestHostManagerByRunConfiguration(testRunCriteria.TestRunSettings); - ThrowExceptionIfTestHostManagerIsNull(testHostManager, testRunCriteria.TestRunSettings); + var executionManager = TestEngine.GetExecutionManager(requestData, testHostManager, testRunCriteria); + executionManager.Initialize(options?.SkipDefaultAdapters ?? false); - testHostManager.Initialize(TestSessionMessageLogger.Instance, testRunCriteria.TestRunSettings); + return new TestRunRequest(requestData, testRunCriteria, executionManager, loggerManager); + } - // NOTE: The custom launcher should not be set when we have test session info available. - if (testRunCriteria.TestHostLauncher != null) - { - testHostManager.SetCustomLauncher(testRunCriteria.TestHostLauncher); - } + /// + public bool StartTestSession( + IRequestData requestData, + StartTestSessionCriteria testSessionCriteria, + ITestSessionEventsHandler eventsHandler) + { + if (testSessionCriteria == null) + { + throw new ArgumentNullException(nameof(testSessionCriteria)); + } - var executionManager = this.TestEngine.GetExecutionManager(requestData, testHostManager, testRunCriteria); - executionManager.Initialize(options?.SkipDefaultAdapters ?? false); + AddExtensionAssemblies(testSessionCriteria.RunSettings); - return new TestRunRequest(requestData, testRunCriteria, executionManager, loggerManager); + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(testSessionCriteria.RunSettings); + if (!runConfiguration.DesignMode) + { + return false; } - /// - public bool StartTestSession( - IRequestData requestData, - StartTestSessionCriteria testSessionCriteria, - ITestSessionEventsHandler eventsHandler) + var testSessionManager = TestEngine.GetTestSessionManager(requestData, testSessionCriteria); + if (testSessionManager == null) { - if (testSessionCriteria == null) - { - throw new ArgumentNullException(nameof(testSessionCriteria)); - } - - this.AddExtensionAssemblies(testSessionCriteria.RunSettings); - - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(testSessionCriteria.RunSettings); - if (!runConfiguration.DesignMode) - { - return false; - } + // The test session manager is null because the combination of runsettings and + // sources tells us we should run in-process (i.e. in vstest.console). Because + // of this no session will be created because there's no testhost to be launched. + // Expecting a subsequent call to execute tests with the same set of parameters. + eventsHandler.HandleStartTestSessionComplete(null); + return false; + } - var testSessionManager = this.TestEngine.GetTestSessionManager(requestData, testSessionCriteria); - if (testSessionManager == null) - { - // The test session manager is null because the combination of runsettings and - // sources tells us we should run in-process (i.e. in vstest.console). Because - // of this no session will be created because there's no testhost to be launched. - // Expecting a subsequent call to execute tests with the same set of parameters. - eventsHandler.HandleStartTestSessionComplete(null); - return false; - } + return testSessionManager.StartSession(eventsHandler); + } - return testSessionManager.StartSession(eventsHandler); - } + /// + /// The dispose. + /// + public void Dispose() + { + throw new NotImplementedException(); + } - /// - /// The dispose. - /// - public void Dispose() - { - throw new NotImplementedException(); - } + /// + public void UpdateExtensions( + IEnumerable pathToAdditionalExtensions, + bool skipExtensionFilters) + { + TestEngine.GetExtensionManager().UseAdditionalExtensions(pathToAdditionalExtensions, skipExtensionFilters); + } - /// - public void UpdateExtensions( - IEnumerable pathToAdditionalExtensions, - bool skipExtensionFilters) - { - this.TestEngine.GetExtensionManager().UseAdditionalExtensions(pathToAdditionalExtensions, skipExtensionFilters); - } + /// + public void ClearExtensions() + { + TestEngine.GetExtensionManager().ClearExtensions(); + } - /// - public void ClearExtensions() + private void ThrowExceptionIfTestHostManagerIsNull( + ITestRuntimeProvider testHostManager, + string settingsXml) + { + if (testHostManager == null) { - this.TestEngine.GetExtensionManager().ClearExtensions(); + EqtTrace.Error("TestPlatform.CreateTestRunRequest: No suitable testHostProvider found for runsettings : {0}", settingsXml); + throw new TestPlatformException(string.Format(CultureInfo.CurrentCulture, ClientResources.NoTestHostProviderFound)); } + } - private void ThrowExceptionIfTestHostManagerIsNull( - ITestRuntimeProvider testHostManager, - string settingsXml) - { - if (testHostManager == null) - { - EqtTrace.Error("TestPlatform.CreateTestRunRequest: No suitable testHostProvider found for runsettings : {0}", settingsXml); - throw new TestPlatformException(string.Format(CultureInfo.CurrentCulture, ClientResources.NoTestHostProviderFound)); - } - } + /// + /// Updates the test adapter paths provided through run settings to be used by the test + /// service. + /// + /// + /// The run settings. + private void AddExtensionAssemblies(string runSettings) + { + IEnumerable customTestAdaptersPaths = RunSettingsUtilities.GetTestAdaptersPaths(runSettings); - /// - /// Updates the test adapter paths provided through run settings to be used by the test - /// service. - /// - /// - /// The run settings. - private void AddExtensionAssemblies(string runSettings) + if (customTestAdaptersPaths != null) { - IEnumerable customTestAdaptersPaths = RunSettingsUtilities.GetTestAdaptersPaths(runSettings); - - if (customTestAdaptersPaths != null) + foreach (string customTestAdaptersPath in customTestAdaptersPaths) { - foreach (string customTestAdaptersPath in customTestAdaptersPaths) + var adapterPath = Path.GetFullPath(Environment.ExpandEnvironmentVariables(customTestAdaptersPath)); + if (!Directory.Exists(adapterPath)) { - var adapterPath = Path.GetFullPath(Environment.ExpandEnvironmentVariables(customTestAdaptersPath)); - if (!Directory.Exists(adapterPath)) + if (EqtTrace.IsWarningEnabled) { - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning(string.Format("AdapterPath Not Found:", adapterPath)); - } - - continue; + EqtTrace.Warning(string.Format("AdapterPath Not Found:", adapterPath)); } - var extensionAssemblies = new List( - this.fileHelper.EnumerateFiles( - adapterPath, - SearchOption.AllDirectories, - TestPlatformConstants.TestAdapterEndsWithPattern, - TestPlatformConstants.TestLoggerEndsWithPattern, - TestPlatformConstants.DataCollectorEndsWithPattern, - TestPlatformConstants.RunTimeEndsWithPattern)); + continue; + } - if (extensionAssemblies.Count > 0) - { - this.UpdateExtensions(extensionAssemblies, skipExtensionFilters: false); - } + var extensionAssemblies = new List( + _fileHelper.EnumerateFiles( + adapterPath, + SearchOption.AllDirectories, + TestPlatformConstants.TestAdapterEndsWithPattern, + TestPlatformConstants.TestLoggerEndsWithPattern, + TestPlatformConstants.DataCollectorEndsWithPattern, + TestPlatformConstants.RunTimeEndsWithPattern)); + + if (extensionAssemblies.Count > 0) + { + UpdateExtensions(extensionAssemblies, skipExtensionFilters: false); } } } + } - /// - /// Updates the extension assemblies from source directory. - /// - /// - /// The test run criteria. - private void AddExtensionAssembliesFromSource(TestRunCriteria testRunCriteria) + /// + /// Updates the extension assemblies from source directory. + /// + /// + /// The test run criteria. + private void AddExtensionAssembliesFromSource(TestRunCriteria testRunCriteria) + { + IEnumerable sources = testRunCriteria.Sources; + if (testRunCriteria.HasSpecificTests) { - IEnumerable sources = testRunCriteria.Sources; - if (testRunCriteria.HasSpecificTests) - { - // If the test execution is with a test filter, group them by sources. - sources = testRunCriteria.Tests.Select(tc => tc.Source).Distinct(); - } - - AddExtensionAssembliesFromSource(sources); + // If the test execution is with a test filter, group them by sources. + sources = testRunCriteria.Tests.Select(tc => tc.Source).Distinct(); } - /// - /// Updates the test logger paths from source directory. - /// - /// - /// The list of sources. - private void AddExtensionAssembliesFromSource(IEnumerable sources) - { - // Currently we support discovering loggers only from Source directory. - var loggersToUpdate = new List(); + AddExtensionAssembliesFromSource(sources); + } - foreach (var source in sources) - { - var sourceDirectory = Path.GetDirectoryName(source); - if (!string.IsNullOrEmpty(sourceDirectory) - && this.fileHelper.DirectoryExists(sourceDirectory)) - { - loggersToUpdate.AddRange( - this.fileHelper.EnumerateFiles( - sourceDirectory, - SearchOption.TopDirectoryOnly, - TestPlatformConstants.TestLoggerEndsWithPattern)); - } - } + /// + /// Updates the test logger paths from source directory. + /// + /// + /// The list of sources. + private void AddExtensionAssembliesFromSource(IEnumerable sources) + { + // Currently we support discovering loggers only from Source directory. + var loggersToUpdate = new List(); - if (loggersToUpdate.Count > 0) + foreach (var source in sources) + { + var sourceDirectory = Path.GetDirectoryName(source); + if (!string.IsNullOrEmpty(sourceDirectory) + && _fileHelper.DirectoryExists(sourceDirectory)) { - this.UpdateExtensions(loggersToUpdate, skipExtensionFilters: false); + loggersToUpdate.AddRange( + _fileHelper.EnumerateFiles( + sourceDirectory, + SearchOption.TopDirectoryOnly, + TestPlatformConstants.TestLoggerEndsWithPattern)); } } - /// - /// Finds all test platform extensions from the `.\Extensions` directory. This is used to - /// load the inbox extensions like TrxLogger and legacy test extensions like MSTest v1, - /// MSTest C++, etc.. - /// - private static void AddExtensionAssembliesFromExtensionDirectory() + if (loggersToUpdate.Count > 0) { - var fileHelper = new FileHelper(); - var extensionsFolder = Path.Combine( - Path.GetDirectoryName( - typeof(TestPlatform).GetTypeInfo().Assembly.GetAssemblyLocation()), - "Extensions"); + UpdateExtensions(loggersToUpdate, skipExtensionFilters: false); + } + } - if (fileHelper.DirectoryExists(extensionsFolder)) - { - var defaultExtensionPaths = fileHelper.EnumerateFiles( - extensionsFolder, - SearchOption.TopDirectoryOnly, - ".dll", - ".exe"); + /// + /// Finds all test platform extensions from the `.\Extensions` directory. This is used to + /// load the inbox extensions like TrxLogger and legacy test extensions like MSTest v1, + /// MSTest C++, etc.. + /// + private static void AddExtensionAssembliesFromExtensionDirectory() + { + var fileHelper = new FileHelper(); + var extensionsFolder = Path.Combine( + Path.GetDirectoryName( + typeof(TestPlatform).GetTypeInfo().Assembly.GetAssemblyLocation()), + "Extensions"); - TestPluginCache.Instance.DefaultExtensionPaths = defaultExtensionPaths; - } + if (fileHelper.DirectoryExists(extensionsFolder)) + { + var defaultExtensionPaths = fileHelper.EnumerateFiles( + extensionsFolder, + SearchOption.TopDirectoryOnly, + ".dll", + ".exe"); + + TestPluginCache.Instance.DefaultExtensionPaths = defaultExtensionPaths; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Client/TestPlatformFactory.cs b/src/Microsoft.TestPlatform.Client/TestPlatformFactory.cs index 44ffa5e33f..b11ef880fa 100644 --- a/src/Microsoft.TestPlatform.Client/TestPlatformFactory.cs +++ b/src/Microsoft.TestPlatform.Client/TestPlatformFactory.cs @@ -1,24 +1,20 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Client +namespace Microsoft.VisualStudio.TestPlatform.Client; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +/// +/// The factory class that provides an instance of the test platform. +/// +public class TestPlatformFactory { - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + private static ITestPlatform s_testPlatform; /// - /// The factory class that provides an instance of the test platform. + /// Gets an instance of the test platform. /// - public class TestPlatformFactory - { - private static ITestPlatform testPlatform; - - /// - /// Gets an instance of the test platform. - /// - /// The instance. - public static ITestPlatform GetTestPlatform() - { - return testPlatform ?? (testPlatform = new TestPlatform()); - } - } -} + /// The instance. + public static ITestPlatform GetTestPlatform() => s_testPlatform ??= new TestPlatform(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Client/TestSession/TestSessionEventsHandler.cs b/src/Microsoft.TestPlatform.Client/TestSession/TestSessionEventsHandler.cs index d5eaa5e6cc..f1004df645 100644 --- a/src/Microsoft.TestPlatform.Client/TestSession/TestSessionEventsHandler.cs +++ b/src/Microsoft.TestPlatform.Client/TestSession/TestSessionEventsHandler.cs @@ -1,72 +1,73 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Client +namespace Microsoft.VisualStudio.TestPlatform.Client; + +using CommunicationUtilities.Interfaces; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; + +using ObjectModel.Logging; + +/// +/// Defines the way in which test session events should be handled. +/// +internal class TestSessionEventsHandler : ITestSessionEventsHandler { - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + private readonly ICommunicationManager _communicationManager; /// - /// Defines the way in which test session events should be handled. + /// Creates an instance of the current class. /// - internal class TestSessionEventsHandler : ITestSessionEventsHandler + /// + /// + /// The communication manager used for passing messages around. + /// + public TestSessionEventsHandler(ICommunicationManager communicationManager) { - private readonly ICommunicationManager communicationManager; - - /// - /// Creates an instance of the current class. - /// - /// - /// - /// The communication manager used for passing messages around. - /// - public TestSessionEventsHandler(ICommunicationManager communicationManager) - { - this.communicationManager = communicationManager; - } + _communicationManager = communicationManager; + } - /// - public void HandleStartTestSessionComplete(TestSessionInfo testSessionInfo) + /// + public void HandleStartTestSessionComplete(TestSessionInfo testSessionInfo) + { + var ackPayload = new StartTestSessionAckPayload() { - var ackPayload = new StartTestSessionAckPayload() - { - TestSessionInfo = testSessionInfo - }; + TestSessionInfo = testSessionInfo + }; - this.communicationManager.SendMessage(MessageType.StartTestSessionCallback, ackPayload); - } + _communicationManager.SendMessage(MessageType.StartTestSessionCallback, ackPayload); + } - /// - public void HandleStopTestSessionComplete(TestSessionInfo testSessionInfo, bool stopped) + /// + public void HandleStopTestSessionComplete(TestSessionInfo testSessionInfo, bool stopped) + { + var ackPayload = new StopTestSessionAckPayload() { - var ackPayload = new StopTestSessionAckPayload() - { - TestSessionInfo = testSessionInfo, - IsStopped = stopped - }; + TestSessionInfo = testSessionInfo, + IsStopped = stopped + }; - this.communicationManager.SendMessage(MessageType.StopTestSessionCallback, ackPayload); - } + _communicationManager.SendMessage(MessageType.StopTestSessionCallback, ackPayload); + } - /// - public void HandleLogMessage(TestMessageLevel level, string message) + /// + public void HandleLogMessage(TestMessageLevel level, string message) + { + var messagePayload = new TestMessagePayload() { - var messagePayload = new TestMessagePayload() - { - MessageLevel = level, - Message = message - }; + MessageLevel = level, + Message = message + }; - this.communicationManager.SendMessage(MessageType.TestMessage, messagePayload); - } + _communicationManager.SendMessage(MessageType.TestMessage, messagePayload); + } - /// - public void HandleRawMessage(string rawMessage) - { - // No-op. - } + /// + public void HandleRawMessage(string rawMessage) + { + // No-op. } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Constants.cs b/src/Microsoft.TestPlatform.Common/Constants.cs index 9f86b7f26b..921a80dcf1 100644 --- a/src/Microsoft.TestPlatform.Common/Constants.cs +++ b/src/Microsoft.TestPlatform.Common/Constants.cs @@ -1,67 +1,66 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common +namespace Microsoft.VisualStudio.TestPlatform.Common; + +/// +/// Defines the defaults used across different components. +/// +public static class TestPlatformDefaults { /// - /// Defines the defaults used across different components. + /// string in the vstest.console.exe.config that specifies the bound on no of jobs in the job queue. /// - public static class TestPlatformDefaults - { - /// - /// string in the vstest.console.exe.config that specifies the bound on no of jobs in the job queue. - /// - public const string MaxNumberOfEventsLoggerEventQueueCanHold = "MaxNumberOfEventsLoggerEventQueueCanHold"; + public const string MaxNumberOfEventsLoggerEventQueueCanHold = "MaxNumberOfEventsLoggerEventQueueCanHold"; - /// - /// Default bound on the job queue. - /// - public const int DefaultMaxNumberOfEventsLoggerEventQueueCanHold = 500; + /// + /// Default bound on the job queue. + /// + public const int DefaultMaxNumberOfEventsLoggerEventQueueCanHold = 500; - /// - /// string in the vstest.console.exe.config that specifies the size bound on job queue. - /// - public const string MaxBytesLoggerEventQueueCanHold = "MaxBytesLoggerEventQueueCanHold"; + /// + /// string in the vstest.console.exe.config that specifies the size bound on job queue. + /// + public const string MaxBytesLoggerEventQueueCanHold = "MaxBytesLoggerEventQueueCanHold"; - /// - /// string in the rocksteady.exe.config that specifies whether or not we should try to keep memory usage by queue bounded. - /// - public const string EnableBoundsOnLoggerEventQueue = "EnableBoundsOnLoggerEventQueue"; + /// + /// string in the rocksteady.exe.config that specifies whether or not we should try to keep memory usage by queue bounded. + /// + public const string EnableBoundsOnLoggerEventQueue = "EnableBoundsOnLoggerEventQueue"; - /// - /// Default bound on the total size of all objects in the job queue. (25MB) - /// - public const int DefaultMaxBytesLoggerEventQueueCanHold = 25000000; + /// + /// Default bound on the total size of all objects in the job queue. (25MB) + /// + public const int DefaultMaxBytesLoggerEventQueueCanHold = 25000000; - /// - /// Default value of the boolean that determines whether or not job queue should be bounded. - /// - public const bool DefaultEnableBoundsOnLoggerEventQueue = true; - } + /// + /// Default value of the boolean that determines whether or not job queue should be bounded. + /// + public const bool DefaultEnableBoundsOnLoggerEventQueue = true; +} +/// +/// Defines the constants used across different components. +/// +public static class TestPlatformConstants +{ /// - /// Defines the constants used across different components. + /// Pattern used to find the test adapters library using String.EndWith /// - public static class TestPlatformConstants - { - /// - /// Pattern used to find the test adapters library using String.EndWith - /// - public const string TestAdapterEndsWithPattern = @"TestAdapter.dll"; + public const string TestAdapterEndsWithPattern = @"TestAdapter.dll"; - /// - /// Pattern used to find the test loggers library using String.EndWith - /// - public const string TestLoggerEndsWithPattern = @"TestLogger.dll"; + /// + /// Pattern used to find the test loggers library using String.EndWith + /// + public const string TestLoggerEndsWithPattern = @"TestLogger.dll"; - /// - /// Pattern used to find the data collectors library using String.EndWith - /// - public const string DataCollectorEndsWithPattern = @"Collector.dll"; + /// + /// Pattern used to find the data collectors library using String.EndWith + /// + public const string DataCollectorEndsWithPattern = @"Collector.dll"; - /// - /// Pattern used to find the run time providers library using String.EndWith - /// - public const string RunTimeEndsWithPattern = @"RuntimeProvider.dll"; - } -} + /// + /// Pattern used to find the run time providers library using String.EndWith + /// + public const string RunTimeEndsWithPattern = @"RuntimeProvider.dll"; +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/AfterTestRunEndResult.cs b/src/Microsoft.TestPlatform.Common/DataCollection/AfterTestRunEndResult.cs index a81642ea30..d978238729 100644 --- a/src/Microsoft.TestPlatform.Common/DataCollection/AfterTestRunEndResult.cs +++ b/src/Microsoft.TestPlatform.Common/DataCollection/AfterTestRunEndResult.cs @@ -1,67 +1,67 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollection -{ - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollection; - /// - /// Payload object that is used to exchange data between datacollector process and runner process. - /// - [DataContract] - public class AfterTestRunEndResult +using ObjectModel; + +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; + +/// +/// Payload object that is used to exchange data between datacollector process and runner process. +/// +[DataContract] +public class AfterTestRunEndResult +{ + // We have more than one ctor for backward-compatibility reason but we don't want to add dependency on Newtosoft([JsonConstructor]) + // We want to fallback to the non-public default constructor https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_ConstructorHandling.htm during deserialization + private AfterTestRunEndResult() { - // We have more than one ctor for backward-compatibility reason but we don't want to add dependency on Newtonsoft([JsonConstructor]) - // We want to fallback to the non-public default constructor https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_ConstructorHandling.htm during deserialization - private AfterTestRunEndResult() - { - } + } - /// - /// Initializes a new instance of the class. - /// - /// - /// The collection of attachment sets. - /// - /// - /// The metrics. - /// - public AfterTestRunEndResult(Collection attachmentSets, IDictionary metrics) - : this(attachmentSets, new Collection(), metrics) - { } + /// + /// Initializes a new instance of the class. + /// + /// + /// The collection of attachment sets. + /// + /// + /// The metrics. + /// + public AfterTestRunEndResult(Collection attachmentSets, IDictionary metrics) + : this(attachmentSets, new Collection(), metrics) + { } - /// - /// Initializes a new instance of the class. - /// - /// - /// The collection of attachment sets. - /// - /// - /// The collection of the DataCollectors invoked during test session - /// - /// - /// The metrics. - /// - public AfterTestRunEndResult(Collection attachmentSets, - Collection invokedDataCollectors, - IDictionary metrics) - { - this.AttachmentSets = attachmentSets; - this.InvokedDataCollectors = invokedDataCollectors; - this.Metrics = metrics; - } + /// + /// Initializes a new instance of the class. + /// + /// + /// The collection of attachment sets. + /// + /// + /// The collection of the DataCollectors invoked during test session + /// + /// + /// The metrics. + /// + public AfterTestRunEndResult(Collection attachmentSets, + Collection invokedDataCollectors, + IDictionary metrics) + { + AttachmentSets = attachmentSets; + InvokedDataCollectors = invokedDataCollectors; + Metrics = metrics; + } - [DataMember] - public Collection AttachmentSets { get; private set; } + [DataMember] + public Collection AttachmentSets { get; private set; } - [DataMember] - public Collection InvokedDataCollectors { get; private set; } + [DataMember] + public Collection InvokedDataCollectors { get; private set; } - [DataMember] - public IDictionary Metrics { get; private set; } - } + [DataMember] + public IDictionary Metrics { get; private set; } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/BeforeTestRunStartResult.cs b/src/Microsoft.TestPlatform.Common/DataCollection/BeforeTestRunStartResult.cs index a5b727f2fc..0e4ef10c1e 100644 --- a/src/Microsoft.TestPlatform.Common/DataCollection/BeforeTestRunStartResult.cs +++ b/src/Microsoft.TestPlatform.Common/DataCollection/BeforeTestRunStartResult.cs @@ -1,42 +1,41 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollection -{ - using System.Collections.Generic; - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollection; + +using System.Collections.Generic; +using System.Runtime.Serialization; +/// +/// Payload object that is used to exchange data between datacollector process and runner process. +/// +[DataContract] +public class BeforeTestRunStartResult +{ /// - /// Payload object that is used to exchange data between datacollector process and runner process. + /// Initializes a new instance of the class. /// - [DataContract] - public class BeforeTestRunStartResult + /// + /// The environment variables. + /// + /// + /// The data Collection Events Port. + /// + public BeforeTestRunStartResult(IDictionary environmentVariables, int dataCollectionEventsPort) { - /// - /// Initializes a new instance of the class. - /// - /// - /// The environment variables. - /// - /// - /// The data Collection Events Port. - /// - public BeforeTestRunStartResult(IDictionary environmentVariables, int dataCollectionEventsPort) - { - this.EnvironmentVariables = environmentVariables; - this.DataCollectionEventsPort = dataCollectionEventsPort; - } + EnvironmentVariables = environmentVariables; + DataCollectionEventsPort = dataCollectionEventsPort; + } - /// - /// Gets the environment variable dictionary. - /// - [DataMember] - public IDictionary EnvironmentVariables { get; private set; } + /// + /// Gets the environment variable dictionary. + /// + [DataMember] + public IDictionary EnvironmentVariables { get; private set; } - /// - /// Gets the data collection events port. - /// - [DataMember] - public int DataCollectionEventsPort { get; private set; } - } + /// + /// Gets the data collection events port. + /// + [DataMember] + public int DataCollectionEventsPort { get; private set; } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionAttachmentManager.cs b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionAttachmentManager.cs index 50eaa48b6b..a952366b1d 100644 --- a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionAttachmentManager.cs +++ b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionAttachmentManager.cs @@ -1,387 +1,386 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector; + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +using Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +/// +/// Manages file transfer from data collector to test runner service. +/// +internal class DataCollectionAttachmentManager : IDataCollectionAttachmentManager { - using System; - using System.Collections.Generic; - using System.ComponentModel; - using System.Diagnostics; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Threading; - using System.Threading.Tasks; - - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + private static readonly object AttachmentTaskLock = new(); + + #region Fields /// - /// Manages file transfer from data collector to test runner service. + /// Default results directory to be used when user didn't specify. /// - internal class DataCollectionAttachmentManager : IDataCollectionAttachmentManager - { - private static object attachmentTaskLock = new object(); + private const string DefaultOutputDirectoryName = "TestResults"; - #region Fields + /// + /// Logger for data collection messages + /// + private IMessageSink _messageSink; - /// - /// Default results directory to be used when user didn't specify. - /// - private const string DefaultOutputDirectoryName = "TestResults"; + /// + /// Attachment transfer tasks associated with a given datacollection context. + /// + private readonly Dictionary> _attachmentTasks; - /// - /// Logger for data collection messages - /// - private IMessageSink messageSink; + /// + /// Use to cancel attachment transfers if test run is canceled. + /// + private readonly CancellationTokenSource _cancellationTokenSource; - /// - /// Attachment transfer tasks associated with a given datacollection context. - /// - private Dictionary> attachmentTasks; + /// + /// File helper instance. + /// + private readonly IFileHelper _fileHelper; - /// - /// Use to cancel attachment transfers if test run is canceled. - /// - private CancellationTokenSource cancellationTokenSource; + #endregion - /// - /// File helper instance. - /// - private IFileHelper fileHelper; + #region Constructor - #endregion + /// + /// Initializes a new instance of the class. + /// + public DataCollectionAttachmentManager() + : this(new TestPlatform.Utilities.Helpers.FileHelper()) + { + } - #region Constructor + /// + /// Initializes a new instance of the class. + /// + /// File helper instance. + protected DataCollectionAttachmentManager(IFileHelper fileHelper) + { + _fileHelper = fileHelper; + _cancellationTokenSource = new CancellationTokenSource(); + _attachmentTasks = new Dictionary>(); + AttachmentSets = new Dictionary>(); + } - /// - /// Initializes a new instance of the class. - /// - public DataCollectionAttachmentManager() - : this(new TestPlatform.Utilities.Helpers.FileHelper()) - { - } + #endregion - /// - /// Initializes a new instance of the class. - /// - /// File helper instance. - protected DataCollectionAttachmentManager(IFileHelper fileHelper) - { - this.fileHelper = fileHelper; - this.cancellationTokenSource = new CancellationTokenSource(); - this.attachmentTasks = new Dictionary>(); - this.AttachmentSets = new Dictionary>(); - } + #region Properties - #endregion + /// + /// Gets the session output directory. + /// + internal string SessionOutputDirectory { get; private set; } - #region Properties + /// + /// Gets the attachment sets for the given datacollection context. + /// + internal Dictionary> AttachmentSets + { + get; private set; + } + #endregion - /// - /// Gets the session output directory. - /// - internal string SessionOutputDirectory { get; private set; } + #region public methods - /// - /// Gets the attachment sets for the given datacollection context. - /// - internal Dictionary> AttachmentSets - { - get; private set; - } - #endregion + /// + public void Initialize(SessionId id, string outputDirectory, IMessageSink messageSink) + { + ValidateArg.NotNull(id, nameof(id)); + ValidateArg.NotNull(messageSink, nameof(messageSink)); - #region public methods + _messageSink = messageSink; - /// - public void Initialize(SessionId id, string outputDirectory, IMessageSink messageSink) + if (string.IsNullOrEmpty(outputDirectory)) { - ValidateArg.NotNull(id, nameof(id)); - ValidateArg.NotNull(messageSink, nameof(messageSink)); - - this.messageSink = messageSink; - - if (string.IsNullOrEmpty(outputDirectory)) - { - this.SessionOutputDirectory = Path.Combine(Path.GetTempPath(), DefaultOutputDirectoryName, id.Id.ToString()); - } - else - { - // Create a session specific directory under base output directory. - var expandedOutputDirectory = Environment.ExpandEnvironmentVariables(outputDirectory); - var absolutePath = Path.GetFullPath(expandedOutputDirectory); - this.SessionOutputDirectory = Path.Combine(absolutePath, id.Id.ToString()); - } - - try - { - // Create the output directory if it doesn't exist. - if (!Directory.Exists(this.SessionOutputDirectory)) - { - Directory.CreateDirectory(this.SessionOutputDirectory); - } - } - catch (UnauthorizedAccessException accessException) - { - string accessDeniedMessage = string.Format(CultureInfo.CurrentCulture, Resources.Resources.AccessDenied, accessException.Message); - ConsoleOutput.Instance.Error(false, accessDeniedMessage); - throw; - } - + SessionOutputDirectory = Path.Combine(Path.GetTempPath(), DefaultOutputDirectoryName, id.Id.ToString()); + } + else + { + // Create a session specific directory under base output directory. + var expandedOutputDirectory = Environment.ExpandEnvironmentVariables(outputDirectory); + var absolutePath = Path.GetFullPath(expandedOutputDirectory); + SessionOutputDirectory = Path.Combine(absolutePath, id.Id.ToString()); } - /// - public List GetAttachments(DataCollectionContext dataCollectionContext) + try { - try - { - if (this.attachmentTasks.TryGetValue(dataCollectionContext, out var tasks)) - { - Task.WhenAll(tasks.ToArray()).Wait(); - } - } - catch (Exception ex) + // Create the output directory if it doesn't exist. + if (!Directory.Exists(SessionOutputDirectory)) { - EqtTrace.Error("DataCollectionAttachmentManager.GetAttachments: Fail to get attachments: {0} ", ex); + Directory.CreateDirectory(SessionOutputDirectory); } + } + catch (UnauthorizedAccessException accessException) + { + string accessDeniedMessage = string.Format(CultureInfo.CurrentCulture, Resources.Resources.AccessDenied, accessException.Message); + ConsoleOutput.Instance.Error(false, accessDeniedMessage); + throw; + } - List attachments = new List(); + } - if (this.AttachmentSets.TryGetValue(dataCollectionContext, out var uriAttachmentSetMap)) + /// + public List GetAttachments(DataCollectionContext dataCollectionContext) + { + try + { + if (_attachmentTasks.TryGetValue(dataCollectionContext, out var tasks)) { - attachments = uriAttachmentSetMap.Values.ToList(); - this.attachmentTasks.Remove(dataCollectionContext); - this.AttachmentSets.Remove(dataCollectionContext); + Task.WhenAll(tasks.ToArray()).Wait(); } - - return attachments; } + catch (Exception ex) + { + EqtTrace.Error("DataCollectionAttachmentManager.GetAttachments: Fail to get attachments: {0} ", ex); + } + + List attachments = new(); - /// - public void AddAttachment(FileTransferInformation fileTransferInfo, AsyncCompletedEventHandler sendFileCompletedCallback, Uri uri, string friendlyName) + if (AttachmentSets.TryGetValue(dataCollectionContext, out var uriAttachmentSetMap)) { - ValidateArg.NotNull(fileTransferInfo, nameof(fileTransferInfo)); + attachments = uriAttachmentSetMap.Values.ToList(); + _attachmentTasks.Remove(dataCollectionContext); + AttachmentSets.Remove(dataCollectionContext); + } - if (string.IsNullOrEmpty(this.SessionOutputDirectory)) - { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error( - "DataCollectionAttachmentManager.AddAttachment: Initialize not invoked."); - } + return attachments; + } - return; - } + /// + public void AddAttachment(FileTransferInformation fileTransferInfo, AsyncCompletedEventHandler sendFileCompletedCallback, Uri uri, string friendlyName) + { + ValidateArg.NotNull(fileTransferInfo, nameof(fileTransferInfo)); - if (!this.AttachmentSets.ContainsKey(fileTransferInfo.Context)) + if (string.IsNullOrEmpty(SessionOutputDirectory)) + { + if (EqtTrace.IsErrorEnabled) { - var uriAttachmentSetMap = new Dictionary(); - this.AttachmentSets.Add(fileTransferInfo.Context, uriAttachmentSetMap); - this.attachmentTasks.Add(fileTransferInfo.Context, new List()); + EqtTrace.Error( + "DataCollectionAttachmentManager.AddAttachment: Initialize not invoked."); } - if (!this.AttachmentSets[fileTransferInfo.Context].ContainsKey(uri)) - { - this.AttachmentSets[fileTransferInfo.Context].Add(uri, new AttachmentSet(uri, friendlyName)); - } + return; + } - this.AddNewFileTransfer(fileTransferInfo, sendFileCompletedCallback, uri, friendlyName); + if (!AttachmentSets.ContainsKey(fileTransferInfo.Context)) + { + var uriAttachmentSetMap = new Dictionary(); + AttachmentSets.Add(fileTransferInfo.Context, uriAttachmentSetMap); + _attachmentTasks.Add(fileTransferInfo.Context, new List()); } - /// - public void Cancel() + if (!AttachmentSets[fileTransferInfo.Context].ContainsKey(uri)) { - this.cancellationTokenSource.Cancel(); + AttachmentSets[fileTransferInfo.Context].Add(uri, new AttachmentSet(uri, friendlyName)); } - #endregion + AddNewFileTransfer(fileTransferInfo, sendFileCompletedCallback, uri, friendlyName); + } - #region private methods + /// + public void Cancel() + { + _cancellationTokenSource.Cancel(); + } - /// - /// Sanity checks on CopyRequestData - /// - /// - /// The file Transfer Info. - /// - /// - /// The local File Path. - /// - private static void Validate(FileTransferInformation fileTransferInfo, string localFilePath) - { - if (!File.Exists(fileTransferInfo.FileName)) - { - throw new FileNotFoundException( - string.Format( - CultureInfo.CurrentCulture, - "Could not find source file '{0}'.", - fileTransferInfo.FileName)); - } + #endregion - var directoryName = Path.GetDirectoryName(localFilePath); + #region private methods - if (!Directory.Exists(directoryName)) - { - Directory.CreateDirectory(directoryName); - } - else if (File.Exists(localFilePath)) - { - File.Delete(localFilePath); - } + /// + /// Sanity checks on CopyRequestData + /// + /// + /// The file Transfer Info. + /// + /// + /// The local File Path. + /// + private static void Validate(FileTransferInformation fileTransferInfo, string localFilePath) + { + if (!File.Exists(fileTransferInfo.FileName)) + { + throw new FileNotFoundException( + string.Format( + CultureInfo.CurrentCulture, + "Could not find source file '{0}'.", + fileTransferInfo.FileName)); } - /// - /// Add a new file transfer (either copy/move) request. - /// - /// - /// The file Transfer Info. - /// - /// - /// The send File Completed Callback. - /// - /// - /// The uri. - /// - /// - /// The friendly Name. - /// - private void AddNewFileTransfer(FileTransferInformation fileTransferInfo, AsyncCompletedEventHandler sendFileCompletedCallback, Uri uri, string friendlyName) + var directoryName = Path.GetDirectoryName(localFilePath); + + if (!Directory.Exists(directoryName)) { - var context = fileTransferInfo.Context; - Debug.Assert( - context != null, - "DataCollectionManager.AddNewFileTransfer: FileDataHeaderMessage with null context."); - - var testCaseId = fileTransferInfo.Context.HasTestCase - ? fileTransferInfo.Context.TestExecId.Id.ToString() - : string.Empty; - - var directoryPath = Path.Combine( - this.SessionOutputDirectory, - testCaseId); - var localFilePath = Path.Combine(directoryPath, Path.GetFileName(fileTransferInfo.FileName)); - - var task = Task.Factory.StartNew( - () => - { - Validate(fileTransferInfo, localFilePath); + Directory.CreateDirectory(directoryName); + } + else if (File.Exists(localFilePath)) + { + File.Delete(localFilePath); + } + } - if (this.cancellationTokenSource.Token.IsCancellationRequested) - { - this.cancellationTokenSource.Token.ThrowIfCancellationRequested(); - } + /// + /// Add a new file transfer (either copy/move) request. + /// + /// + /// The file Transfer Info. + /// + /// + /// The send File Completed Callback. + /// + /// + /// The uri. + /// + /// + /// The friendly Name. + /// + private void AddNewFileTransfer(FileTransferInformation fileTransferInfo, AsyncCompletedEventHandler sendFileCompletedCallback, Uri uri, string friendlyName) + { + var context = fileTransferInfo.Context; + Debug.Assert( + context != null, + "DataCollectionManager.AddNewFileTransfer: FileDataHeaderMessage with null context."); + + var testCaseId = fileTransferInfo.Context.HasTestCase + ? fileTransferInfo.Context.TestExecId.Id.ToString() + : string.Empty; + + var directoryPath = Path.Combine( + SessionOutputDirectory, + testCaseId); + var localFilePath = Path.Combine(directoryPath, Path.GetFileName(fileTransferInfo.FileName)); + + var task = Task.Factory.StartNew( + () => + { + Validate(fileTransferInfo, localFilePath); + + if (_cancellationTokenSource.Token.IsCancellationRequested) + { + _cancellationTokenSource.Token.ThrowIfCancellationRequested(); + } - try + try + { + if (fileTransferInfo.PerformCleanup) { - if (fileTransferInfo.PerformCleanup) + if (EqtTrace.IsInfoEnabled) { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DataCollectionAttachmentManager.AddNewFileTransfer : Moving file {0} to {1}", fileTransferInfo.FileName, localFilePath); - } + EqtTrace.Info("DataCollectionAttachmentManager.AddNewFileTransfer : Moving file {0} to {1}", fileTransferInfo.FileName, localFilePath); + } - this.fileHelper.MoveFile(fileTransferInfo.FileName, localFilePath); + _fileHelper.MoveFile(fileTransferInfo.FileName, localFilePath); - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DataCollectionAttachmentManager.AddNewFileTransfer : Moved file {0} to {1}", fileTransferInfo.FileName, localFilePath); - } + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("DataCollectionAttachmentManager.AddNewFileTransfer : Moved file {0} to {1}", fileTransferInfo.FileName, localFilePath); } - else + } + else + { + if (EqtTrace.IsInfoEnabled) { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DataCollectionAttachmentManager.AddNewFileTransfer : Copying file {0} to {1}", fileTransferInfo.FileName, localFilePath); - } + EqtTrace.Info("DataCollectionAttachmentManager.AddNewFileTransfer : Copying file {0} to {1}", fileTransferInfo.FileName, localFilePath); + } - this.fileHelper.CopyFile(fileTransferInfo.FileName, localFilePath); + _fileHelper.CopyFile(fileTransferInfo.FileName, localFilePath); - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DataCollectionAttachmentManager.AddNewFileTransfer : Copied file {0} to {1}", fileTransferInfo.FileName, localFilePath); - } + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("DataCollectionAttachmentManager.AddNewFileTransfer : Copied file {0} to {1}", fileTransferInfo.FileName, localFilePath); } } - catch (Exception ex) - { - this.LogError( - ex.ToString(), - uri, - friendlyName, - Guid.Parse(testCaseId)); + } + catch (Exception ex) + { + LogError( + ex.ToString(), + uri, + friendlyName, + Guid.Parse(testCaseId)); - throw; - } - }, - this.cancellationTokenSource.Token); + throw; + } + }, + _cancellationTokenSource.Token); - var continuationTask = task.ContinueWith( - (t) => + var continuationTask = task.ContinueWith( + (t) => + { + try { - try + if (t.Exception == null) { - if (t.Exception == null) + lock (AttachmentTaskLock) { - lock (attachmentTaskLock) - { - this.AttachmentSets[fileTransferInfo.Context][uri].Attachments.Add(UriDataAttachment.CreateFrom(localFilePath, fileTransferInfo.Description)); - } + AttachmentSets[fileTransferInfo.Context][uri].Attachments.Add(UriDataAttachment.CreateFrom(localFilePath, fileTransferInfo.Description)); } - - sendFileCompletedCallback?.Invoke(this, new AsyncCompletedEventArgs(t.Exception, false, fileTransferInfo.UserToken)); } - catch (Exception e) + + sendFileCompletedCallback?.Invoke(this, new AsyncCompletedEventArgs(t.Exception, false, fileTransferInfo.UserToken)); + } + catch (Exception e) + { + if (EqtTrace.IsErrorEnabled) { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error( - "DataCollectionAttachmentManager.TriggerCallBack: Error occurred while raising the file transfer completed callback for {0}. Error: {1}", - localFilePath, - e.ToString()); - } + EqtTrace.Error( + "DataCollectionAttachmentManager.TriggerCallBack: Error occurred while raising the file transfer completed callback for {0}. Error: {1}", + localFilePath, + e.ToString()); } - }, - this.cancellationTokenSource.Token); + } + }, + _cancellationTokenSource.Token); - this.attachmentTasks[fileTransferInfo.Context].Add(continuationTask); - } + _attachmentTasks[fileTransferInfo.Context].Add(continuationTask); + } - /// - /// Logs an error message. - /// - /// - /// The error message. - /// - /// - /// The collector uri. - /// - /// - /// The collector friendly name. - /// - /// - /// Id of testCase if available, null otherwise. - /// - private void LogError(string errorMessage, Uri collectorUri, string collectorFriendlyName, Guid testCaseId) + /// + /// Logs an error message. + /// + /// + /// The error message. + /// + /// + /// The collector uri. + /// + /// + /// The collector friendly name. + /// + /// + /// Id of testCase if available, null otherwise. + /// + private void LogError(string errorMessage, Uri collectorUri, string collectorFriendlyName, Guid testCaseId) + { + var args = new DataCollectionMessageEventArgs(TestMessageLevel.Error, errorMessage) { - var args = new DataCollectionMessageEventArgs(TestMessageLevel.Error, errorMessage) - { - Uri = collectorUri, - FriendlyName = collectorFriendlyName - }; - - if (!testCaseId.Equals(Guid.Empty)) - { - args.TestCaseId = testCaseId; - } + Uri = collectorUri, + FriendlyName = collectorFriendlyName + }; - this.messageSink.SendMessage(args); + if (!testCaseId.Equals(Guid.Empty)) + { + args.TestCaseId = testCaseId; } - #endregion + _messageSink.SendMessage(args); } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionEnvironmentVariable.cs b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionEnvironmentVariable.cs index bec2b004ca..0eb679ad9c 100644 --- a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionEnvironmentVariable.cs +++ b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionEnvironmentVariable.cs @@ -1,107 +1,106 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector; + +using System.Collections.Generic; + +using ObjectModel; + +/// +/// An environment variable requested to be set in the test execution environment by a data collector, including the +/// friendly names of data collectors that requested it. +/// This is needed to find list of environment variables needed for test run after eliminating the duplicate name and keys. +/// For details check DataCollectionPluginManager.AddCollectorEnvironmentVariables() method. +/// +internal class DataCollectionEnvironmentVariable { - using System.Collections.Generic; + #region Fields + + /// + /// Variable name and requested value + /// + private readonly KeyValuePair _variable; + + /// + /// Friendly names of data collectors that requested this environment variable + /// + private readonly List _dataCollectorsThatRequested; + + #endregion - using Microsoft.VisualStudio.TestPlatform.ObjectModel; + #region Constructors /// - /// An environment variable requested to be set in the test execution environment by a data collector, including the - /// friendly names of data collectors that requested it. - /// This is needed to find list of environment variables needed for test run after eliminating the duplicate name and keys. - /// For details check DataCollectionPluginManager.AddCollectorEnvironmentVariables() method. + /// Initializes a new instance of the class. /// - internal class DataCollectionEnvironmentVariable + /// + /// Variable name and requested value. + /// + /// + /// Friendly name of the data collector requesting it. + /// + public DataCollectionEnvironmentVariable( + KeyValuePair variable, + string requestingDataCollectorFriendlyName) { - #region Fields - - /// - /// Variable name and requested value - /// - private readonly KeyValuePair variable; - - /// - /// Friendly names of data collectors that requested this environment variable - /// - private List dataCollectorsThatRequested; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// - /// Variable name and requested value. - /// - /// - /// Friendly name of the data collector requesting it. - /// - public DataCollectionEnvironmentVariable( - KeyValuePair variable, - string requestingDataCollectorFriendlyName) - { - ValidateArg.NotNullOrEmpty(variable.Key, nameof(variable.Key)); - ValidateArg.NotNullOrEmpty(requestingDataCollectorFriendlyName, nameof(requestingDataCollectorFriendlyName)); + ValidateArg.NotNullOrEmpty(variable.Key, nameof(variable.Key)); + ValidateArg.NotNullOrEmpty(requestingDataCollectorFriendlyName, nameof(requestingDataCollectorFriendlyName)); - this.variable = variable; - this.dataCollectorsThatRequested = new List { requestingDataCollectorFriendlyName }; - } + _variable = variable; + _dataCollectorsThatRequested = new List { requestingDataCollectorFriendlyName }; + } - #endregion + #endregion - #region Properties + #region Properties - /// - /// Gets variable name. - /// - public string Name + /// + /// Gets variable name. + /// + public string Name + { + get { - get - { - return this.variable.Key; - } + return _variable.Key; } + } - /// - /// Gets requested value - /// - public string Value + /// + /// Gets requested value + /// + public string Value + { + get { - get - { - return this.variable.Value; - } + return _variable.Value; } + } - /// - /// Gets friendly name of the first data collector that requested this environment variable - /// - public string FirstDataCollectorThatRequested + /// + /// Gets friendly name of the first data collector that requested this environment variable + /// + public string FirstDataCollectorThatRequested + { + get { - get - { - return this.dataCollectorsThatRequested[0]; - } + return _dataCollectorsThatRequested[0]; } + } - #endregion - - #region Methods + #endregion - /// - /// Adds the data collector to the list of data collectors that requested this variable. - /// - /// Friendly name of requesting data collector. - public void AddRequestingDataCollector(string requestingDataCollectorFriendlyName) - { - ValidateArg.NotNullOrEmpty(requestingDataCollectorFriendlyName, nameof(requestingDataCollectorFriendlyName)); - this.dataCollectorsThatRequested.Add(requestingDataCollectorFriendlyName); - } + #region Methods - #endregion + /// + /// Adds the data collector to the list of data collectors that requested this variable. + /// + /// Friendly name of requesting data collector. + public void AddRequestingDataCollector(string requestingDataCollectorFriendlyName) + { + ValidateArg.NotNullOrEmpty(requestingDataCollectorFriendlyName, nameof(requestingDataCollectorFriendlyName)); + _dataCollectorsThatRequested.Add(requestingDataCollectorFriendlyName); } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionManager.cs b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionManager.cs index de09f2c22f..8bde074f51 100644 --- a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionManager.cs +++ b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionManager.cs @@ -1,785 +1,783 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector; + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Globalization; +using System.Linq; + +using Interfaces; +using ExtensionFramework; +using Logging; +using Utilities; +using ObjectModel; +using ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; + +/// +/// Manages data collection. +/// +internal class DataCollectionManager : IDataCollectionManager { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Globalization; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; + private static readonly object SyncObject = new(); + private const string CodeCoverageFriendlyName = "Code Coverage"; /// - /// Manages data collection. + /// Value indicating whether data collection is currently enabled. /// - internal class DataCollectionManager : IDataCollectionManager + private bool _isDataCollectionEnabled; + + /// + /// Data collection environment context. + /// + private DataCollectionEnvironmentContext _dataCollectionEnvironmentContext; + + /// + /// Attachment manager for performing file transfers for datacollectors. + /// + private readonly IDataCollectionAttachmentManager _attachmentManager; + + /// + /// Message sink for sending data collection messages to client.. + /// + private readonly IMessageSink _messageSink; + + /// + /// Events that can be subscribed by datacollectors. + /// + private readonly TestPlatformDataCollectionEvents _events; + + /// + /// Specifies whether the object is disposed or not. + /// + private bool _disposed; + + /// + /// Extension manager for data collectors. + /// + private DataCollectorExtensionManager _dataCollectorExtensionManager; + + /// + /// Request data + /// + private readonly IDataCollectionTelemetryManager _dataCollectionTelemetryManager; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The message Sink. + /// + internal DataCollectionManager(IMessageSink messageSink, IRequestData requestData) : this(new DataCollectionAttachmentManager(), messageSink, new DataCollectionTelemetryManager(requestData)) { - private static object syncObject = new object(); - private const string CodeCoverageFriendlyName = "Code Coverage"; - - /// - /// Value indicating whether data collection is currently enabled. - /// - private bool isDataCollectionEnabled; - - /// - /// Data collection environment context. - /// - private DataCollectionEnvironmentContext dataCollectionEnvironmentContext; - - /// - /// Attachment manager for performing file transfers for datacollectors. - /// - private IDataCollectionAttachmentManager attachmentManager; - - /// - /// Message sink for sending data collection messages to client.. - /// - private IMessageSink messageSink; - - /// - /// Events that can be subscribed by datacollectors. - /// - private TestPlatformDataCollectionEvents events; - - /// - /// Specifies whether the object is disposed or not. - /// - private bool disposed; - - /// - /// Extension manager for data collectors. - /// - private DataCollectorExtensionManager dataCollectorExtensionManager; - - /// - /// Request data - /// - private IDataCollectionTelemetryManager dataCollectionTelemetryManager; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The message Sink. - /// - internal DataCollectionManager(IMessageSink messageSink, IRequestData requestData) : this(new DataCollectionAttachmentManager(), messageSink, new DataCollectionTelemetryManager(requestData)) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// The datacollection Attachment Manager. - /// - /// - /// The message Sink. - /// - /// - /// The constructor is not public because the factory method should be used to get instances of this class. - /// - protected DataCollectionManager(IDataCollectionAttachmentManager datacollectionAttachmentManager, IMessageSink messageSink, IDataCollectionTelemetryManager dataCollectionTelemetryManager) - { - this.attachmentManager = datacollectionAttachmentManager; - this.messageSink = messageSink; - this.events = new TestPlatformDataCollectionEvents(); - this.dataCollectorExtensionManager = null; - this.RunDataCollectors = new Dictionary(); - this.dataCollectionTelemetryManager = dataCollectionTelemetryManager; - } - - /// - /// Gets the instance of DataCollectionManager. - /// - public static DataCollectionManager Instance { get; private set; } - - /// - /// Gets cache of data collectors associated with the run. - /// - internal Dictionary RunDataCollectors { get; private set; } - - /// - /// Gets the data collector extension manager. - /// - private DataCollectorExtensionManager DataCollectorExtensionManager - { - get - { - if (this.dataCollectorExtensionManager == null) - { - // TODO : change IMessageSink and use IMessageLogger instead. - this.dataCollectorExtensionManager = DataCollectorExtensionManager.Create(TestSessionMessageLogger.Instance); - } + } - return this.dataCollectorExtensionManager; - } - } + /// + /// Initializes a new instance of the class. + /// + /// + /// The datacollection Attachment Manager. + /// + /// + /// The message Sink. + /// + /// + /// The constructor is not public because the factory method should be used to get instances of this class. + /// + protected DataCollectionManager(IDataCollectionAttachmentManager datacollectionAttachmentManager, IMessageSink messageSink, IDataCollectionTelemetryManager dataCollectionTelemetryManager) + { + _attachmentManager = datacollectionAttachmentManager; + _messageSink = messageSink; + _events = new TestPlatformDataCollectionEvents(); + _dataCollectorExtensionManager = null; + RunDataCollectors = new Dictionary(); + _dataCollectionTelemetryManager = dataCollectionTelemetryManager; + } + + /// + /// Gets the instance of DataCollectionManager. + /// + public static DataCollectionManager Instance { get; private set; } - /// - /// Creates an instance of the TestLoggerExtensionManager. - /// - /// - /// The message sink. - /// - /// - /// The . - /// - public static DataCollectionManager Create(IMessageSink messageSink, IRequestData requestData) + /// + /// Gets cache of data collectors associated with the run. + /// + internal Dictionary RunDataCollectors { get; private set; } + + /// + /// Gets the data collector extension manager. + /// + private DataCollectorExtensionManager DataCollectorExtensionManager + { + get { - if (Instance == null) + if (_dataCollectorExtensionManager == null) { - lock (syncObject) - { - if (Instance == null) - { - Instance = new DataCollectionManager(messageSink, requestData); - } - } + // TODO : change IMessageSink and use IMessageLogger instead. + _dataCollectorExtensionManager = DataCollectorExtensionManager.Create(TestSessionMessageLogger.Instance); } - return Instance; + return _dataCollectorExtensionManager; } + } - /// - public IDictionary InitializeDataCollectors(string settingsXml) + /// + /// Creates an instance of the TestLoggerExtensionManager. + /// + /// + /// The message sink. + /// + /// + /// The . + /// + public static DataCollectionManager Create(IMessageSink messageSink, IRequestData requestData) + { + if (Instance == null) { - if (string.IsNullOrEmpty(settingsXml) && EqtTrace.IsInfoEnabled) + lock (SyncObject) { - EqtTrace.Info("DataCollectionManager.InitializeDataCollectors : Runsettings is null or empty."); + if (Instance == null) + { + Instance = new DataCollectionManager(messageSink, requestData); + } } + } - ValidateArg.NotNull(settingsXml, nameof(settingsXml)); + return Instance; + } - var sessionId = new SessionId(Guid.NewGuid()); - var dataCollectionContext = new DataCollectionContext(sessionId); - this.dataCollectionEnvironmentContext = DataCollectionEnvironmentContext.CreateForLocalEnvironment(dataCollectionContext); + /// + public IDictionary InitializeDataCollectors(string settingsXml) + { + if (string.IsNullOrEmpty(settingsXml) && EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("DataCollectionManager.InitializeDataCollectors : Runsettings is null or empty."); + } - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml); - var resultsDirectory = RunSettingsUtilities.GetTestResultsDirectory(runConfiguration); + ValidateArg.NotNull(settingsXml, nameof(settingsXml)); - this.attachmentManager.Initialize(sessionId, resultsDirectory, this.messageSink); + var sessionId = new SessionId(Guid.NewGuid()); + var dataCollectionContext = new DataCollectionContext(sessionId); + _dataCollectionEnvironmentContext = DataCollectionEnvironmentContext.CreateForLocalEnvironment(dataCollectionContext); - // Environment variables are passed to testhost process, through ProcessStartInfo.EnvironmentVariables, which handles the key in a case-insensitive manner, which is translated to lowercase. - // Therefore, using StringComparer.OrdinalIgnoreCase so that same keys with different cases are treated as same. - var executionEnvironmentVariables = new Dictionary(StringComparer.OrdinalIgnoreCase); + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml); + var resultsDirectory = RunSettingsUtilities.GetTestResultsDirectory(runConfiguration); - var dataCollectionRunSettings = XmlRunSettingsUtilities.GetDataCollectionRunSettings(settingsXml); + _attachmentManager.Initialize(sessionId, resultsDirectory, _messageSink); - this.isDataCollectionEnabled = dataCollectionRunSettings.IsCollectionEnabled; + // Environment variables are passed to testhost process, through ProcessStartInfo.EnvironmentVariables, which handles the key in a case-insensitive manner, which is translated to lowercase. + // Therefore, using StringComparer.OrdinalIgnoreCase so that same keys with different cases are treated as same. + var executionEnvironmentVariables = new Dictionary(StringComparer.OrdinalIgnoreCase); - // If dataCollectionRunSettings is null, that means datacollectors are not configured. - if (dataCollectionRunSettings == null || !dataCollectionRunSettings.IsCollectionEnabled) - { - return executionEnvironmentVariables; - } + var dataCollectionRunSettings = XmlRunSettingsUtilities.GetDataCollectionRunSettings(settingsXml); - // Get settings for each data collector, load and initialize the data collectors. - var enabledDataCollectorsSettings = this.GetDataCollectorsEnabledForRun(dataCollectionRunSettings); - if (enabledDataCollectorsSettings == null || enabledDataCollectorsSettings.Count == 0) - { - return executionEnvironmentVariables; - } - - foreach (var dataCollectorSettings in enabledDataCollectorsSettings) - { - this.LoadAndInitialize(dataCollectorSettings, settingsXml); - } - - // Once all data collectors have been initialized, query for environment variables - var dataCollectorEnvironmentVariables = this.GetEnvironmentVariables(out var unloadedAnyCollector); - - foreach (var variable in dataCollectorEnvironmentVariables.Values) - { - executionEnvironmentVariables.Add(variable.Name, variable.Value); - } + _isDataCollectionEnabled = dataCollectionRunSettings.IsCollectionEnabled; + // If dataCollectionRunSettings is null, that means datacollectors are not configured. + if (dataCollectionRunSettings == null || !dataCollectionRunSettings.IsCollectionEnabled) + { return executionEnvironmentVariables; } - /// - public void Dispose() + // Get settings for each data collector, load and initialize the data collectors. + var enabledDataCollectorsSettings = GetDataCollectorsEnabledForRun(dataCollectionRunSettings); + if (enabledDataCollectorsSettings == null || enabledDataCollectorsSettings.Count == 0) { - this.Dispose(true); + return executionEnvironmentVariables; + } - // Use SupressFinalize in case a subclass - // of this type implements a finalizer. - GC.SuppressFinalize(this); + foreach (var dataCollectorSettings in enabledDataCollectorsSettings) + { + LoadAndInitialize(dataCollectorSettings, settingsXml); } - /// - public Collection SessionEnded(bool isCancelled = false) + // Once all data collectors have been initialized, query for environment variables + var dataCollectorEnvironmentVariables = GetEnvironmentVariables(out _); + + foreach (var variable in dataCollectorEnvironmentVariables.Values) { - // Return null if datacollection is not enabled. - if (!this.isDataCollectionEnabled) - { - return new Collection(); - } + executionEnvironmentVariables.Add(variable.Name, variable.Value); + } - if (isCancelled) - { - this.attachmentManager.Cancel(); - return new Collection(); - } + return executionEnvironmentVariables; + } - var endEvent = new SessionEndEventArgs(this.dataCollectionEnvironmentContext.SessionDataCollectionContext); - this.SendEvent(endEvent); + /// + public void Dispose() + { + Dispose(true); - var result = new List(); - try - { - result = this.attachmentManager.GetAttachments(endEvent.Context); - } - catch (Exception ex) - { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("DataCollectionManager.SessionEnded: Failed to get attachments : {0}", ex); - } + // Use SupressFinalize in case a subclass + // of this type implements a finalizer. + GC.SuppressFinalize(this); + } - return new Collection(result); - } + /// + public Collection SessionEnded(bool isCancelled = false) + { + // Return null if datacollection is not enabled. + if (!_isDataCollectionEnabled) + { + return new Collection(); + } + + if (isCancelled) + { + _attachmentManager.Cancel(); + return new Collection(); + } + + var endEvent = new SessionEndEventArgs(_dataCollectionEnvironmentContext.SessionDataCollectionContext); + SendEvent(endEvent); - if (EqtTrace.IsVerboseEnabled) + var result = new List(); + try + { + result = _attachmentManager.GetAttachments(endEvent.Context); + } + catch (Exception ex) + { + if (EqtTrace.IsErrorEnabled) { - this.LogAttachments(result); + EqtTrace.Error("DataCollectionManager.SessionEnded: Failed to get attachments : {0}", ex); } return new Collection(result); } - /// - public Collection GetInvokedDataCollectors() + if (EqtTrace.IsVerboseEnabled) { - List invokedDataCollector = new List(); - foreach (DataCollectorInformation dataCollectorInformation in this.RunDataCollectors.Values) - { - invokedDataCollector.Add(new InvokedDataCollector(dataCollectorInformation.DataCollectorConfig.TypeUri, - dataCollectorInformation.DataCollectorConfig.FriendlyName, - dataCollectorInformation.DataCollectorConfig.DataCollectorType.AssemblyQualifiedName, - dataCollectorInformation.DataCollectorConfig.FilePath, - dataCollectorInformation.DataCollectorConfig.HasAttachmentsProcessor())); - } + LogAttachments(result); + } + + return new Collection(result); + } - return new Collection(invokedDataCollector); + /// + public Collection GetInvokedDataCollectors() + { + List invokedDataCollector = new(); + foreach (DataCollectorInformation dataCollectorInformation in RunDataCollectors.Values) + { + invokedDataCollector.Add(new InvokedDataCollector(dataCollectorInformation.DataCollectorConfig.TypeUri, + dataCollectorInformation.DataCollectorConfig.FriendlyName, + dataCollectorInformation.DataCollectorConfig.DataCollectorType.AssemblyQualifiedName, + dataCollectorInformation.DataCollectorConfig.FilePath, + dataCollectorInformation.DataCollectorConfig.HasAttachmentsProcessor())); } - /// - public void TestHostLaunched(int processId) + return new Collection(invokedDataCollector); + } + + /// + public void TestHostLaunched(int processId) + { + if (!_isDataCollectionEnabled) { - if (!this.isDataCollectionEnabled) - { - return; - } + return; + } + + var testHostLaunchedEventArgs = new TestHostLaunchedEventArgs(_dataCollectionEnvironmentContext.SessionDataCollectionContext, processId); + + SendEvent(testHostLaunchedEventArgs); + } + + /// + public bool SessionStarted(SessionStartEventArgs sessionStartEventArgs) + { + // If datacollectors are not configured or datacollection is not enabled, return false. + if (!_isDataCollectionEnabled || RunDataCollectors.Count == 0) + { + return false; + } - var testHostLaunchedEventArgs = new TestHostLaunchedEventArgs(this.dataCollectionEnvironmentContext.SessionDataCollectionContext, processId); + sessionStartEventArgs.Context = new DataCollectionContext(_dataCollectionEnvironmentContext.SessionDataCollectionContext.SessionId); + SendEvent(sessionStartEventArgs); - this.SendEvent(testHostLaunchedEventArgs); + return _events.AreTestCaseEventsSubscribed(); + } + + /// + public void TestCaseStarted(TestCaseStartEventArgs testCaseStartEventArgs) + { + if (!_isDataCollectionEnabled) + { + return; } - /// - public bool SessionStarted(SessionStartEventArgs sessionStartEventArgs) + var context = new DataCollectionContext(_dataCollectionEnvironmentContext.SessionDataCollectionContext.SessionId, testCaseStartEventArgs.TestElement); + testCaseStartEventArgs.Context = context; + + SendEvent(testCaseStartEventArgs); + } + + /// + public Collection TestCaseEnded(TestCaseEndEventArgs testCaseEndEventArgs) + { + if (!_isDataCollectionEnabled) { - // If datacollectors are not configured or datacollection is not enabled, return false. - if (!this.isDataCollectionEnabled || this.RunDataCollectors.Count == 0) + return new Collection(); + } + + var context = new DataCollectionContext(_dataCollectionEnvironmentContext.SessionDataCollectionContext.SessionId, testCaseEndEventArgs.TestElement); + testCaseEndEventArgs.Context = context; + + SendEvent(testCaseEndEventArgs); + + List result = null; + try + { + result = _attachmentManager.GetAttachments(testCaseEndEventArgs.Context); + } + catch (Exception ex) + { + if (EqtTrace.IsErrorEnabled) { - return false; + EqtTrace.Error("DataCollectionManager.TestCaseEnded: Failed to get attachments : {0}", ex); } - sessionStartEventArgs.Context = new DataCollectionContext(this.dataCollectionEnvironmentContext.SessionDataCollectionContext.SessionId); - this.SendEvent(sessionStartEventArgs); + return new Collection(result); + } - return this.events.AreTestCaseEventsSubscribed(); + if (EqtTrace.IsVerboseEnabled) + { + LogAttachments(result); } - /// - public void TestCaseStarted(TestCaseStartEventArgs testCaseStartEventArgs) + return new Collection(result); + } + + /// + /// The dispose. + /// + /// + /// The disposing. + /// + protected virtual void Dispose(bool disposing) + { + if (!_disposed) { - if (!this.isDataCollectionEnabled) + if (disposing) { - return; + CleanupPlugins(); } - var context = new DataCollectionContext(this.dataCollectionEnvironmentContext.SessionDataCollectionContext.SessionId, testCaseStartEventArgs.TestElement); - testCaseStartEventArgs.Context = context; + _disposed = true; + } + } + + private void CleanupPlugins() + { + EqtTrace.Info("DataCollectionManager.CleanupPlugins: CleanupPlugins called"); - this.SendEvent(testCaseStartEventArgs); + if (!_isDataCollectionEnabled) + { + return; } - /// - public Collection TestCaseEnded(TestCaseEndEventArgs testCaseEndEventArgs) + if (EqtTrace.IsVerboseEnabled) { - if (!this.isDataCollectionEnabled) - { - return new Collection(); - } + EqtTrace.Verbose("DataCollectionManager.CleanupPlugins: Cleaning up {0} plugins", RunDataCollectors.Count); + } - var context = new DataCollectionContext(this.dataCollectionEnvironmentContext.SessionDataCollectionContext.SessionId, testCaseEndEventArgs.TestElement); - testCaseEndEventArgs.Context = context; + RemoveDataCollectors(new List(RunDataCollectors.Values)); - this.SendEvent(testCaseEndEventArgs); + EqtTrace.Info("DataCollectionManager.CleanupPlugins: CleanupPlugins finished"); + } - List result = null; - try + #region Load and Initialize DataCollectors + + /// + /// Tries to get uri of the data collector corresponding to the friendly name. If no such data collector exists return null. + /// + /// The friendly Name. + /// The data collector Uri. + /// + protected virtual bool TryGetUriFromFriendlyName(string friendlyName, out string dataCollectorUri) + { + var extensionManager = _dataCollectorExtensionManager; + foreach (var extension in extensionManager.TestExtensions) + { + if (string.Equals(friendlyName, extension.Metadata.FriendlyName, StringComparison.OrdinalIgnoreCase)) { - result = this.attachmentManager.GetAttachments(testCaseEndEventArgs.Context); + dataCollectorUri = extension.Metadata.ExtensionUri; + return true; } - catch (Exception ex) - { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("DataCollectionManager.TestCaseEnded: Failed to get attachments : {0}", ex); - } + } - return new Collection(result); - } + dataCollectorUri = null; + return false; + } - if (EqtTrace.IsVerboseEnabled) + /// + /// Gets the DataCollectorConfig using uri. + /// + /// + /// The extension uri. + /// + /// + /// The . + /// + protected virtual DataCollectorConfig TryGetDataCollectorConfig(string extensionUri) + { + var extensionManager = _dataCollectorExtensionManager; + foreach (var extension in extensionManager.TestExtensions) + { + if (string.Equals(extension.TestPluginInfo.IdentifierData, extensionUri, StringComparison.OrdinalIgnoreCase)) { - this.LogAttachments(result); + return (DataCollectorConfig)extension.TestPluginInfo; } + } - return new Collection(result); + return null; + } + + protected virtual bool IsUriValid(string uri) + { + if (string.IsNullOrEmpty(uri)) + { + return false; } - /// - /// The dispose. - /// - /// - /// The disposing. - /// - protected virtual void Dispose(bool disposing) + var extensionManager = _dataCollectorExtensionManager; + foreach (var extension in extensionManager.TestExtensions) { - if (!this.disposed) + if (string.Equals(uri, extension.Metadata.ExtensionUri, StringComparison.OrdinalIgnoreCase)) { - if (disposing) - { - CleanupPlugins(); - } - - this.disposed = true; + return true; } } + return false; + } - private void CleanupPlugins() + /// + /// Gets the extension using uri. + /// + /// + /// The extension uri. + /// + /// + /// The . + /// + protected virtual DataCollector TryGetTestExtension(string extensionUri) + { + return DataCollectorExtensionManager.TryGetTestExtension(extensionUri).Value; + } + + /// + /// Loads and initializes data collector using data collector settings. + /// + /// + /// The data collector settings. + /// + /// runsettings Xml + private void LoadAndInitialize(DataCollectorSettings dataCollectorSettings, string settingsXml) + { + DataCollectorInformation dataCollectorInfo; + DataCollectorConfig dataCollectorConfig; + + try { - EqtTrace.Info("DataCollectionManager.CleanupPlugins: CleanupPlugins called"); + // Look up the extension and initialize it if one is found. + var extensionManager = DataCollectorExtensionManager; + var dataCollectorUri = dataCollectorSettings.Uri?.ToString(); - if (!this.isDataCollectionEnabled) + if (!IsUriValid(dataCollectorUri) && !TryGetUriFromFriendlyName(dataCollectorSettings.FriendlyName, out dataCollectorUri)) { - return; + LogWarning(string.Format(CultureInfo.CurrentUICulture, Resources.Resources.UnableToFetchUriString, dataCollectorSettings.FriendlyName)); } - if (EqtTrace.IsVerboseEnabled) + DataCollector dataCollector = null; + if (!string.IsNullOrWhiteSpace(dataCollectorUri)) { - EqtTrace.Verbose("DataCollectionManager.CleanupPlugins: Cleaning up {0} plugins", this.RunDataCollectors.Count); + dataCollector = TryGetTestExtension(dataCollectorUri); } - RemoveDataCollectors(new List(this.RunDataCollectors.Values)); + if (dataCollector == null) + { + LogWarning(string.Format(CultureInfo.CurrentUICulture, Resources.Resources.DataCollectorNotFound, dataCollectorSettings.FriendlyName)); + return; + } - EqtTrace.Info("DataCollectionManager.CleanupPlugins: CleanupPlugins finished"); - } + if (RunDataCollectors.ContainsKey(dataCollector.GetType())) + { + // Collector is already loaded (may be configured twice). Ignore duplicates and return. + return; + } - #region Load and Initialize DataCollectors + dataCollectorConfig = TryGetDataCollectorConfig(dataCollectorUri); - /// - /// Tries to get uri of the data collector corresponding to the friendly name. If no such data collector exists return null. - /// - /// The friendly Name. - /// The data collector Uri. - /// - protected virtual bool TryGetUriFromFriendlyName(string friendlyName, out string dataCollectorUri) + // Attempt to get the data collector information verifying that all of the required metadata for the collector is available. + dataCollectorInfo = new DataCollectorInformation( + dataCollector, + dataCollectorSettings.Configuration, + dataCollectorConfig, + _dataCollectionEnvironmentContext, + _attachmentManager, + _events, + _messageSink, + settingsXml); + } + catch (Exception ex) { - var extensionManager = this.dataCollectorExtensionManager; - foreach (var extension in extensionManager.TestExtensions) + if (EqtTrace.IsErrorEnabled) { - if (string.Equals(friendlyName, extension.Metadata.FriendlyName, StringComparison.OrdinalIgnoreCase)) - { - dataCollectorUri = extension.Metadata.ExtensionUri; - return true; - } + EqtTrace.Error("DataCollectionManager.LoadAndInitialize: exception while creating data collector {0} : {1}", dataCollectorSettings.FriendlyName, ex); } - dataCollectorUri = null; - return false; + // No data collector info, so send the error with no direct association to the collector. + LogWarning(string.Format(CultureInfo.CurrentUICulture, Resources.Resources.DataCollectorInitializationError, dataCollectorSettings.FriendlyName, ex)); + return; } - /// - /// Gets the DataCollectorConfig using uri. - /// - /// - /// The extension uri. - /// - /// - /// The . - /// - protected virtual DataCollectorConfig TryGetDataCollectorConfig(string extensionUri) + try { - var extensionManager = this.dataCollectorExtensionManager; - foreach (var extension in extensionManager.TestExtensions) + dataCollectorInfo.InitializeDataCollector(); + lock (RunDataCollectors) { - if (string.Equals(extension.TestPluginInfo.IdentifierData, extensionUri, StringComparison.OrdinalIgnoreCase)) - { - return (DataCollectorConfig)extension.TestPluginInfo; - } + // Add data collectors to run cache. + RunDataCollectors[dataCollectorConfig.DataCollectorType] = dataCollectorInfo; } - - return null; } - - protected virtual bool IsUriValid(string uri) + catch (Exception ex) { - if (string.IsNullOrEmpty(uri)) + if (EqtTrace.IsErrorEnabled) { - return false; + EqtTrace.Error("DataCollectionManager.LoadAndInitialize: exception while initializing data collector {0} : {1}", dataCollectorSettings.FriendlyName, ex); } - var extensionManager = this.dataCollectorExtensionManager; - foreach (var extension in extensionManager.TestExtensions) - { - if (string.Equals(uri, extension.Metadata.ExtensionUri, StringComparison.OrdinalIgnoreCase)) - { - return true; - } - } - return false; - } + // Log error. + dataCollectorInfo.Logger.LogError(_dataCollectionEnvironmentContext.SessionDataCollectionContext, string.Format(CultureInfo.CurrentCulture, Resources.Resources.DataCollectorInitializationError, dataCollectorConfig.FriendlyName, ex)); - /// - /// Gets the extension using uri. - /// - /// - /// The extension uri. - /// - /// - /// The . - /// - protected virtual DataCollector TryGetTestExtension(string extensionUri) - { - return this.DataCollectorExtensionManager.TryGetTestExtension(extensionUri).Value; + // Dispose datacollector. + dataCollectorInfo.DisposeDataCollector(); } + } - /// - /// Loads and initializes data collector using data collector settings. - /// - /// - /// The data collector settings. - /// - /// runsettings Xml - private void LoadAndInitialize(DataCollectorSettings dataCollectorSettings, string settingsXml) + /// + /// Finds data collector enabled for the run in data collection settings. + /// + /// data collection settings + /// List of enabled data collectors + private List GetDataCollectorsEnabledForRun(DataCollectionRunSettings dataCollectionSettings) + { + var runEnabledDataCollectors = new List(); + foreach (var settings in dataCollectionSettings.DataCollectorSettingsList) { - DataCollectorInformation dataCollectorInfo; - DataCollectorConfig dataCollectorConfig; - - try + if (settings.IsEnabled) { - // Look up the extension and initialize it if one is found. - var extensionManager = this.DataCollectorExtensionManager; - var dataCollectorUri = dataCollectorSettings.Uri?.ToString(); - - if (!IsUriValid(dataCollectorUri) && !this.TryGetUriFromFriendlyName(dataCollectorSettings.FriendlyName, out dataCollectorUri)) + if (runEnabledDataCollectors.Any(dcSettings => string.Equals(dcSettings.FriendlyName, settings.FriendlyName, StringComparison.OrdinalIgnoreCase))) { - this.LogWarning(string.Format(CultureInfo.CurrentUICulture, Resources.Resources.UnableToFetchUriString, dataCollectorSettings.FriendlyName)); + // If Uri or assembly qualified type name is repeated, consider data collector as duplicate and ignore it. + LogWarning(string.Format(CultureInfo.CurrentUICulture, Resources.Resources.IgnoredDuplicateConfiguration, settings.FriendlyName)); + continue; } - DataCollector dataCollector = null; - if (!string.IsNullOrWhiteSpace(dataCollectorUri)) - { - dataCollector = this.TryGetTestExtension(dataCollectorUri); - } - - if (dataCollector == null) - { - this.LogWarning(string.Format(CultureInfo.CurrentUICulture, Resources.Resources.DataCollectorNotFound, dataCollectorSettings.FriendlyName)); - return; - } - - if (this.RunDataCollectors.ContainsKey(dataCollector.GetType())) - { - // Collector is already loaded (may be configured twice). Ignore duplicates and return. - return; - } - - dataCollectorConfig = this.TryGetDataCollectorConfig(dataCollectorUri); - - // Attempt to get the data collector information verifying that all of the required metadata for the collector is available. - dataCollectorInfo = new DataCollectorInformation( - dataCollector, - dataCollectorSettings.Configuration, - dataCollectorConfig, - this.dataCollectionEnvironmentContext, - this.attachmentManager, - this.events, - this.messageSink, - settingsXml); + runEnabledDataCollectors.Add(settings); } - catch (Exception ex) - { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("DataCollectionManager.LoadAndInitialize: exception while creating data collector {0} : {1}", dataCollectorSettings.FriendlyName, ex); - } + } - // No data collector info, so send the error with no direct association to the collector. - this.LogWarning(string.Format(CultureInfo.CurrentUICulture, Resources.Resources.DataCollectorInitializationError, dataCollectorSettings.FriendlyName, ex)); - return; - } + return runEnabledDataCollectors; + } - try - { - dataCollectorInfo.InitializeDataCollector(); - lock (this.RunDataCollectors) - { - // Add data collectors to run cache. - this.RunDataCollectors[dataCollectorConfig.DataCollectorType] = dataCollectorInfo; - } - } - catch (Exception ex) - { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("DataCollectionManager.LoadAndInitialize: exception while initializing data collector {0} : {1}", dataCollectorSettings.FriendlyName, ex); - } + #endregion - // Log error. - dataCollectorInfo.Logger.LogError(this.dataCollectionEnvironmentContext.SessionDataCollectionContext, string.Format(CultureInfo.CurrentCulture, Resources.Resources.DataCollectorInitializationError, dataCollectorConfig.FriendlyName, ex)); + /// + /// Sends a warning message against the session which is not associated with a data collector. + /// + /// + /// This should only be used when we do not have the data collector info yet. After we have the data + /// collector info we can use the data collectors logger for errors. + /// + /// The message to be logged. + private void LogWarning(string warningMessage) + { + _messageSink.SendMessage(new DataCollectionMessageEventArgs(TestMessageLevel.Warning, warningMessage)); + } - // Dispose datacollector. - dataCollectorInfo.DisposeDataCollector(); - } - } + /// + /// Sends the event to all data collectors and fires a callback on the sender, letting it + /// know when all plugins have completed processing the event + /// + /// The context information for the event + private void SendEvent(DataCollectionEventArgs args) + { + ValidateArg.NotNull(args, nameof(args)); - /// - /// Finds data collector enabled for the run in data collection settings. - /// - /// data collection settings - /// List of enabled data collectors - private List GetDataCollectorsEnabledForRun(DataCollectionRunSettings dataCollectionSettings) + if (!_isDataCollectionEnabled) { - var runEnabledDataCollectors = new List(); - foreach (var settings in dataCollectionSettings.DataCollectorSettingsList) + if (EqtTrace.IsErrorEnabled) { - if (settings.IsEnabled) - { - if (runEnabledDataCollectors.Any(dcSettings => string.Equals(dcSettings.FriendlyName, settings.FriendlyName, StringComparison.OrdinalIgnoreCase))) - { - // If Uri or assembly qualified type name is repeated, consider data collector as duplicate and ignore it. - this.LogWarning(string.Format(CultureInfo.CurrentUICulture, Resources.Resources.IgnoredDuplicateConfiguration, settings.FriendlyName)); - continue; - } - - runEnabledDataCollectors.Add(settings); - } + EqtTrace.Error("DataCollectionManger:SendEvent: SendEvent called when no collection is enabled."); } - return runEnabledDataCollectors; + return; } - #endregion + // do not send events multiple times + _events.RaiseEvent(args); + } - /// - /// Sends a warning message against the session which is not associated with a data collector. - /// - /// - /// This should only be used when we do not have the data collector info yet. After we have the data - /// collector info we can use the data collectors logger for errors. - /// - /// The message to be logged. - private void LogWarning(string warningMessage) + /// + /// The get environment variables. + /// + /// + /// The unloaded any collector. + /// + /// + /// Dictionary of variable name as key and collector requested environment variable as value. + /// + private Dictionary GetEnvironmentVariables(out bool unloadedAnyCollector) + { + var failedCollectors = new List(); + unloadedAnyCollector = false; + var dataCollectorEnvironmentVariable = new Dictionary(StringComparer.OrdinalIgnoreCase); + + // Ordering here is temporary to enable Fakes + Code Coverage integration in scenarios when Fakes decides to instrument code using + // CLR Instrumentation Engine. This code will be cleaned when both Fakes and Code Coverage will fully switch to CLR Instrumentation Engine. + foreach (var dataCollectorInfo in RunDataCollectors.Values. + OrderBy(rdc => rdc.DataCollectorConfig.FriendlyName.Equals(CodeCoverageFriendlyName, StringComparison.OrdinalIgnoreCase) ? 1 : 0)) { - this.messageSink.SendMessage(new DataCollectionMessageEventArgs(TestMessageLevel.Warning, warningMessage)); - } + try + { + dataCollectorInfo.SetTestExecutionEnvironmentVariables(); + AddCollectorEnvironmentVariables(dataCollectorInfo, dataCollectorEnvironmentVariable); + } + catch (Exception ex) + { + unloadedAnyCollector = true; - /// - /// Sends the event to all data collectors and fires a callback on the sender, letting it - /// know when all plugins have completed processing the event - /// - /// The context information for the event - private void SendEvent(DataCollectionEventArgs args) - { - ValidateArg.NotNull(args, nameof(args)); + var friendlyName = dataCollectorInfo.DataCollectorConfig.FriendlyName; + failedCollectors.Add(dataCollectorInfo); + dataCollectorInfo.Logger.LogError( + _dataCollectionEnvironmentContext.SessionDataCollectionContext, + string.Format(CultureInfo.CurrentCulture, Resources.Resources.DataCollectorErrorOnGetVariable, friendlyName, ex)); - if (!this.isDataCollectionEnabled) - { if (EqtTrace.IsErrorEnabled) { - EqtTrace.Error("DataCollectionManger:SendEvent: SendEvent called when no collection is enabled."); + EqtTrace.Error("DataCollectionManager.GetEnvironmentVariables: Failed to get variable for Collector '{0}': {1}", friendlyName, ex); } - - return; } + } + + RemoveDataCollectors(failedCollectors); + return dataCollectorEnvironmentVariable; + } - // do not send events multiple times - this.events.RaiseEvent(args); - } - - /// - /// The get environment variables. - /// - /// - /// The unloaded any collector. - /// - /// - /// Dictionary of variable name as key and collector requested environment variable as value. - /// - private Dictionary GetEnvironmentVariables(out bool unloadedAnyCollector) - { - var failedCollectors = new List(); - unloadedAnyCollector = false; - var dataCollectorEnvironmentVariable = new Dictionary(StringComparer.OrdinalIgnoreCase); - - // Ordering here is temporary to enable Fakes + Code Coverage integration in scenarios when Fakes decides to instrument code using - // CLR Instrumentation Engine. This code will be cleaned when both Fakes and Code Coverage will fully switch to CLR Instrumentation Engine. - foreach (var dataCollectorInfo in this.RunDataCollectors.Values. - OrderBy(rdc => rdc.DataCollectorConfig.FriendlyName.Equals(CodeCoverageFriendlyName, StringComparison.OrdinalIgnoreCase) ? 1 : 0)) + /// + /// Collects environment variable to be set in test process by avoiding duplicates + /// and detecting override of variable value by multiple adapters. + /// + /// + /// The data Collection Wrapper. + /// + /// + /// Environment variables required for already loaded plugin. + /// + private void AddCollectorEnvironmentVariables( + DataCollectorInformation dataCollectionWrapper, + Dictionary dataCollectorEnvironmentVariables) + { + if (dataCollectionWrapper.TestExecutionEnvironmentVariables != null) + { + var collectorFriendlyName = dataCollectionWrapper.DataCollectorConfig.FriendlyName; + foreach (var namevaluepair in dataCollectionWrapper.TestExecutionEnvironmentVariables) { - try + if (dataCollectorEnvironmentVariables.TryGetValue(namevaluepair.Key, out var alreadyRequestedVariable)) { - dataCollectorInfo.SetTestExecutionEnvironmentVariables(); - this.AddCollectorEnvironmentVariables(dataCollectorInfo, dataCollectorEnvironmentVariable); - } - catch (Exception ex) - { - unloadedAnyCollector = true; - - var friendlyName = dataCollectorInfo.DataCollectorConfig.FriendlyName; - failedCollectors.Add(dataCollectorInfo); - dataCollectorInfo.Logger.LogError( - this.dataCollectionEnvironmentContext.SessionDataCollectionContext, - string.Format(CultureInfo.CurrentCulture, Resources.Resources.DataCollectorErrorOnGetVariable, friendlyName, ex)); - - if (EqtTrace.IsErrorEnabled) + // Dev10 behavior is to consider environment variables values as case sensitive. + if (string.Equals(namevaluepair.Value, alreadyRequestedVariable.Value, StringComparison.Ordinal)) { - EqtTrace.Error("DataCollectionManager.GetEnvironmentVariables: Failed to get variable for Collector '{0}': {1}", friendlyName, ex); + alreadyRequestedVariable.AddRequestingDataCollector(collectorFriendlyName); } - } - } - - this.RemoveDataCollectors(failedCollectors); - return dataCollectorEnvironmentVariable; - } - - /// - /// Collects environment variable to be set in test process by avoiding duplicates - /// and detecting override of variable value by multiple adapters. - /// - /// - /// The data Collection Wrapper. - /// - /// - /// Environment variables required for already loaded plugin. - /// - private void AddCollectorEnvironmentVariables( - DataCollectorInformation dataCollectionWrapper, - Dictionary dataCollectorEnvironmentVariables) - { - if (dataCollectionWrapper.TestExecutionEnvironmentVariables != null) - { - var collectorFriendlyName = dataCollectionWrapper.DataCollectorConfig.FriendlyName; - foreach (var namevaluepair in dataCollectionWrapper.TestExecutionEnvironmentVariables) - { - if (dataCollectorEnvironmentVariables.TryGetValue(namevaluepair.Key, out var alreadyRequestedVariable)) + else { - // Dev10 behavior is to consider environment variables values as case sensitive. - if (string.Equals(namevaluepair.Value, alreadyRequestedVariable.Value, StringComparison.Ordinal)) + // Data collector is overriding an already requested variable, possibly an error. + var message = string.Format( + CultureInfo.CurrentUICulture, + Resources.Resources.DataCollectorRequestedDuplicateEnvironmentVariable, + collectorFriendlyName, + namevaluepair.Key, + namevaluepair.Value, + alreadyRequestedVariable.FirstDataCollectorThatRequested, + alreadyRequestedVariable.Value); + + if (collectorFriendlyName.Equals(CodeCoverageFriendlyName, StringComparison.OrdinalIgnoreCase)) { - alreadyRequestedVariable.AddRequestingDataCollector(collectorFriendlyName); + // Do not treat this as error for Code Coverage Data Collector. This is expected in some Fakes integration scenarios + EqtTrace.Info(message); } else { - // Data collector is overriding an already requested variable, possibly an error. - var message = string.Format( - CultureInfo.CurrentUICulture, - Resources.Resources.DataCollectorRequestedDuplicateEnvironmentVariable, - collectorFriendlyName, - namevaluepair.Key, - namevaluepair.Value, - alreadyRequestedVariable.FirstDataCollectorThatRequested, - alreadyRequestedVariable.Value); - - if (collectorFriendlyName.Equals(CodeCoverageFriendlyName, StringComparison.OrdinalIgnoreCase)) - { - // Do not treat this as error for Code Coverage Data Collector. This is expected in some Fakes integration scenarios - EqtTrace.Info(message); - } - else - { - dataCollectionWrapper.Logger.LogError(this.dataCollectionEnvironmentContext.SessionDataCollectionContext, message); - } + dataCollectionWrapper.Logger.LogError(_dataCollectionEnvironmentContext.SessionDataCollectionContext, message); } - - dataCollectionTelemetryManager.RecordEnvironmentVariableConflict(dataCollectionWrapper, namevaluepair.Key, namevaluepair.Value, alreadyRequestedVariable.Value); } - else + + _dataCollectionTelemetryManager.RecordEnvironmentVariableConflict(dataCollectionWrapper, namevaluepair.Key, namevaluepair.Value, alreadyRequestedVariable.Value); + } + else + { + if (EqtTrace.IsVerboseEnabled) { - if (EqtTrace.IsVerboseEnabled) - { - // new variable, add to the list. - EqtTrace.Verbose("DataCollectionManager.AddCollectionEnvironmentVariables: Adding Environment variable '{0}' value '{1}'", namevaluepair.Key, namevaluepair.Value); - } + // new variable, add to the list. + EqtTrace.Verbose("DataCollectionManager.AddCollectionEnvironmentVariables: Adding Environment variable '{0}' value '{1}'", namevaluepair.Key, namevaluepair.Value); + } - dataCollectorEnvironmentVariables.Add( - namevaluepair.Key, - new DataCollectionEnvironmentVariable(namevaluepair, collectorFriendlyName)); + dataCollectorEnvironmentVariables.Add( + namevaluepair.Key, + new DataCollectionEnvironmentVariable(namevaluepair, collectorFriendlyName)); - dataCollectionTelemetryManager.RecordEnvironmentVariableAddition(dataCollectionWrapper, namevaluepair.Key, namevaluepair.Value); - } + _dataCollectionTelemetryManager.RecordEnvironmentVariableAddition(dataCollectionWrapper, namevaluepair.Key, namevaluepair.Value); } } } + } + + /// + /// The remove data collectors. + /// + /// + /// The data collectors to remove. + /// + private void RemoveDataCollectors(IReadOnlyCollection dataCollectorsToRemove) + { + if (dataCollectorsToRemove == null || !dataCollectorsToRemove.Any()) + { + return; + } - /// - /// The remove data collectors. - /// - /// - /// The data collectors to remove. - /// - private void RemoveDataCollectors(IReadOnlyCollection dataCollectorsToRemove) + lock (RunDataCollectors) { - if (dataCollectorsToRemove == null || !dataCollectorsToRemove.Any()) + foreach (var dataCollectorToRemove in dataCollectorsToRemove) { - return; + dataCollectorToRemove.DisposeDataCollector(); + RunDataCollectors.Remove(dataCollectorToRemove.DataCollector.GetType()); } - lock (this.RunDataCollectors) + if (RunDataCollectors.Count == 0) { - foreach (var dataCollectorToRemove in dataCollectorsToRemove) - { - dataCollectorToRemove.DisposeDataCollector(); - this.RunDataCollectors.Remove(dataCollectorToRemove.DataCollector.GetType()); - } - - if (this.RunDataCollectors.Count == 0) - { - this.isDataCollectionEnabled = false; - } + _isDataCollectionEnabled = false; } } + } - private void LogAttachments(List attachmentSets) + private void LogAttachments(List attachmentSets) + { + foreach (var entry in attachmentSets) { - foreach (var entry in attachmentSets) - { - foreach (var file in entry.Attachments) - { - EqtTrace.Verbose( - "Test Attachment Description: Collector:'{0}' Uri:'{1}' Description:'{2}' Uri:'{3}' ", - entry.DisplayName, - entry.Uri, - file.Description, - file.Uri); - } + foreach (var file in entry.Attachments) + { + EqtTrace.Verbose( + "Test Attachment Description: Collector:'{0}' Uri:'{1}' Description:'{2}' Uri:'{3}' ", + entry.DisplayName, + entry.Uri, + file.Description, + file.Uri); } } } diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionTelemetryManager.cs b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionTelemetryManager.cs index c7d9c49c00..7350e959c8 100644 --- a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionTelemetryManager.cs +++ b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionTelemetryManager.cs @@ -4,98 +4,93 @@ using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + using System; using System.Linq; -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector; + +/// +/// Stores and provides telemetry information for data collection. +/// +internal class DataCollectionTelemetryManager : IDataCollectionTelemetryManager { - /// - /// Stores and provides telemetry information for data collection. - /// - internal class DataCollectionTelemetryManager : IDataCollectionTelemetryManager + private const string CorProfilerVariable = "COR_PROFILER"; + private const string CoreClrProfilerVariable = "CORECLR_PROFILER"; + private const string ClrIeInstrumentationMethodConfigurationPrefix32Variable = "MicrosoftInstrumentationEngine_ConfigPath32_"; + private const string ClrIeInstrumentationMethodConfigurationPrefix64Variable = "MicrosoftInstrumentationEngine_ConfigPath64_"; + + private static readonly Guid ClrIeProfilerGuid = Guid.Parse("{324f817a-7420-4e6d-b3c1-143fbed6d855}"); + private const string OverwrittenProfilerName = "overwritten"; + + private readonly IRequestData _requestData; + + internal DataCollectionTelemetryManager(IRequestData requestData) { - private const string CorProfilerVariable = "COR_PROFILER"; - private const string CoreClrProfilerVariable = "CORECLR_PROFILER"; - private const string ClrIeInstrumentationMethodConfigurationPrefix32Variable = "MicrosoftInstrumentationEngine_ConfigPath32_"; - private const string ClrIeInstrumentationMethodConfigurationPrefix64Variable = "MicrosoftInstrumentationEngine_ConfigPath64_"; + _requestData = requestData; + } - private static readonly Guid ClrIeProfilerGuid = Guid.Parse("{324f817a-7420-4e6d-b3c1-143fbed6d855}"); - private const string OverwrittenProfilerName = "overwritten"; + /// + public void RecordEnvironmentVariableAddition(DataCollectorInformation dataCollectorInformation, string name, string value) + { + RecordProfilerMetricForNewVariable(CorProfilerVariable, TelemetryDataConstants.DataCollectorsCorProfiler, dataCollectorInformation, name, value); + RecordProfilerMetricForNewVariable(CoreClrProfilerVariable, TelemetryDataConstants.DataCollectorsCoreClrProfiler, dataCollectorInformation, name, value); + } - private readonly IRequestData requestData; + /// + public void RecordEnvironmentVariableConflict(DataCollectorInformation dataCollectorInformation, string name, string value, string existingValue) + { + RecordProfilerMetricForConflictedVariable(CorProfilerVariable, TelemetryDataConstants.DataCollectorsCorProfiler, dataCollectorInformation, name, value, existingValue); + RecordProfilerMetricForConflictedVariable(CoreClrProfilerVariable, TelemetryDataConstants.DataCollectorsCoreClrProfiler, dataCollectorInformation, name, value, existingValue); + } - internal DataCollectionTelemetryManager(IRequestData requestData) + private void RecordProfilerMetricForNewVariable(string profilerVariable, string telemetryPrefix, DataCollectorInformation dataCollectorInformation, string name, string value) + { + if (!string.Equals(profilerVariable, name, StringComparison.Ordinal)) { - this.requestData = requestData; + return; } - /// - public void RecordEnvironmentVariableAddition(DataCollectorInformation dataCollectorInformation, string name, string value) - { - RecordProfilerMetricForNewVariable(CorProfilerVariable, TelemetryDataConstants.DataCollectorsCorProfiler, dataCollectorInformation, name, value); - RecordProfilerMetricForNewVariable(CoreClrProfilerVariable, TelemetryDataConstants.DataCollectorsCoreClrProfiler, dataCollectorInformation, name, value); - } + _requestData.MetricsCollection.Add(GetTelemetryKey(telemetryPrefix, dataCollectorInformation), GetProfilerGuid(value).ToString()); + } - /// - public void RecordEnvironmentVariableConflict(DataCollectorInformation dataCollectorInformation, string name, string value, string existingValue) + private void RecordProfilerMetricForConflictedVariable(string profilerVariable, string telemetryPrefix, DataCollectorInformation dataCollectorInformation, string name, string value, string existingValue) + { + // If data collector is requesting same profiler record it same as new + if (string.Equals(value, existingValue, StringComparison.OrdinalIgnoreCase)) { - RecordProfilerMetricForConflictedVariable(CorProfilerVariable, TelemetryDataConstants.DataCollectorsCorProfiler, dataCollectorInformation, name, value, existingValue); - RecordProfilerMetricForConflictedVariable(CoreClrProfilerVariable, TelemetryDataConstants.DataCollectorsCoreClrProfiler, dataCollectorInformation, name, value, existingValue); + RecordProfilerMetricForNewVariable(profilerVariable, telemetryPrefix, dataCollectorInformation, name, value); + return; } - private void RecordProfilerMetricForNewVariable(string profilerVariable, string telemetryPrefix, DataCollectorInformation dataCollectorInformation, string name, string value) + if (!string.Equals(profilerVariable, name, StringComparison.Ordinal)) { - if (!string.Equals(profilerVariable, name, StringComparison.Ordinal)) - { - return; - } - - requestData.MetricsCollection.Add(GetTelemetryKey(telemetryPrefix, dataCollectorInformation), GetProfilerGuid(value).ToString()); + return; } - private void RecordProfilerMetricForConflictedVariable(string profilerVariable, string telemetryPrefix, DataCollectorInformation dataCollectorInformation, string name, string value, string existingValue) - { - // If data collector is requesting same profiler record it same as new - if (string.Equals(value, existingValue, StringComparison.OrdinalIgnoreCase)) - { - RecordProfilerMetricForNewVariable(profilerVariable, telemetryPrefix, dataCollectorInformation, name, value); - return; - } + var existingProfilerGuid = GetProfilerGuid(existingValue); - if (!string.Equals(profilerVariable, name, StringComparison.Ordinal)) + if (ClrIeProfilerGuid == existingProfilerGuid) + { + if (dataCollectorInformation.TestExecutionEnvironmentVariables != null && + dataCollectorInformation.TestExecutionEnvironmentVariables.Any(pair => pair.Key.StartsWith(ClrIeInstrumentationMethodConfigurationPrefix32Variable)) && + dataCollectorInformation.TestExecutionEnvironmentVariables.Any(pair => pair.Key.StartsWith(ClrIeInstrumentationMethodConfigurationPrefix64Variable))) { + _requestData.MetricsCollection.Add(GetTelemetryKey(telemetryPrefix, dataCollectorInformation), ClrIeProfilerGuid.ToString()); return; } - - var existingProfilerGuid = GetProfilerGuid(existingValue); - - if (ClrIeProfilerGuid == existingProfilerGuid) - { - if (dataCollectorInformation.TestExecutionEnvironmentVariables != null && - dataCollectorInformation.TestExecutionEnvironmentVariables.Any(pair => pair.Key.StartsWith(ClrIeInstrumentationMethodConfigurationPrefix32Variable)) && - dataCollectorInformation.TestExecutionEnvironmentVariables.Any(pair => pair.Key.StartsWith(ClrIeInstrumentationMethodConfigurationPrefix64Variable))) - { - requestData.MetricsCollection.Add(GetTelemetryKey(telemetryPrefix, dataCollectorInformation), ClrIeProfilerGuid.ToString()); - return; - } - } - - requestData.MetricsCollection.Add(GetTelemetryKey(telemetryPrefix, dataCollectorInformation), $"{existingProfilerGuid}({OverwrittenProfilerName}:{GetProfilerGuid(value)})"); } - private static Guid GetProfilerGuid(string profilerGuid) - { - if (Guid.TryParse(profilerGuid, out var guid)) - { - return guid; - } + _requestData.MetricsCollection.Add(GetTelemetryKey(telemetryPrefix, dataCollectorInformation), $"{existingProfilerGuid}({OverwrittenProfilerName}:{GetProfilerGuid(value)})"); + } - return Guid.Empty; - } + private static Guid GetProfilerGuid(string profilerGuid) + { + return Guid.TryParse(profilerGuid, out var guid) ? guid : Guid.Empty; + } - private static string GetTelemetryKey(string telemetryPrefix, DataCollectorInformation dataCollectorInformation) - { - return string.Format("{0}.{1}", telemetryPrefix, dataCollectorInformation.DataCollectorConfig?.TypeUri?.ToString()); - } + private static string GetTelemetryKey(string telemetryPrefix, DataCollectorInformation dataCollectorInformation) + { + return string.Format("{0}.{1}", telemetryPrefix, dataCollectorInformation.DataCollectorConfig?.TypeUri?.ToString()); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectorConfig.cs b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectorConfig.cs index 538c65692c..a221ae933f 100644 --- a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectorConfig.cs +++ b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectorConfig.cs @@ -1,169 +1,168 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; + +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +/// +/// The data collector config. +/// +internal class DataCollectorConfig : TestExtensionPluginInformation { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Linq; - using System.Reflection; - - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - /// - /// The data collector config. + /// Initializes a new instance of the class. /// - internal class DataCollectorConfig : TestExtensionPluginInformation + /// + /// The type. + /// + public DataCollectorConfig(Type type) + : base(type) { - /// - /// Initializes a new instance of the class. - /// - /// - /// The type. - /// - public DataCollectorConfig(Type type) - : base(type) - { - ValidateArg.NotNull(type, nameof(type)); + ValidateArg.NotNull(type, nameof(type)); - this.DataCollectorType = type; - this.TypeUri = GetTypeUri(type); - this.FriendlyName = GetFriendlyName(type); - this.AttachmentsProcessorType = GetAttachmentsProcessors(type); - } + DataCollectorType = type; + TypeUri = GetTypeUri(type); + FriendlyName = GetFriendlyName(type); + AttachmentsProcessorType = GetAttachmentsProcessors(type); + } - /// - /// Gets the data collector type. - /// - public Type DataCollectorType { get; private set; } + /// + /// Gets the data collector type. + /// + public Type DataCollectorType { get; private set; } - /// - /// Gets the type uri. - /// - public Uri TypeUri { get; private set; } + /// + /// Gets the type uri. + /// + public Uri TypeUri { get; private set; } - /// - /// Gets the friendly name. - /// - public string FriendlyName { get; private set; } + /// + /// Gets the friendly name. + /// + public string FriendlyName { get; private set; } - /// - public override string IdentifierData + /// + public override string IdentifierData + { + get { - get - { - return this.TypeUri?.ToString(); - } + return TypeUri?.ToString(); } + } - /// - public override ICollection Metadata + /// + public override ICollection Metadata + { + get { - get - { - return new object[] { this.TypeUri.ToString(), this.FriendlyName, this.AttachmentsProcessorType != null }; - } + return new object[] { TypeUri.ToString(), FriendlyName, AttachmentsProcessorType != null }; } + } + + /// + /// Gets attachments processor + /// + public Type AttachmentsProcessorType { get; private set; } + + /// + /// Check if collector registers an attachment processor. + /// + /// True if collector registers an attachment processor. + public bool HasAttachmentsProcessor() => AttachmentsProcessorType != null; - /// - /// Gets attachments processor - /// - public Type AttachmentsProcessorType { get; private set; } - - /// - /// Check if collector registers an attachment processor. - /// - /// True if collector registers an attachment processor. - public bool HasAttachmentsProcessor() => AttachmentsProcessorType != null; - - /// - /// Gets the Type Uri for the data collector. - /// - /// The data collector to get the Type URI for. - /// Type Uri of the data collector. - private static Uri GetTypeUri(Type dataCollectorType) + /// + /// Gets the Type Uri for the data collector. + /// + /// The data collector to get the Type URI for. + /// Type Uri of the data collector. + private static Uri GetTypeUri(Type dataCollectorType) + { + Uri typeUri = null; + var typeUriAttributes = GetAttributes(dataCollectorType, typeof(DataCollectorTypeUriAttribute)); + if (typeUriAttributes != null && typeUriAttributes.Length > 0) { - Uri typeUri = null; - var typeUriAttributes = GetAttributes(dataCollectorType, typeof(DataCollectorTypeUriAttribute)); - if (typeUriAttributes != null && typeUriAttributes.Length > 0) + var typeUriAttribute = (DataCollectorTypeUriAttribute)typeUriAttributes[0]; + if (!string.IsNullOrWhiteSpace(typeUriAttribute.TypeUri)) { - var typeUriAttribute = (DataCollectorTypeUriAttribute)typeUriAttributes[0]; - if (!string.IsNullOrWhiteSpace(typeUriAttribute.TypeUri)) - { - typeUri = new Uri(typeUriAttribute.TypeUri); - } + typeUri = new Uri(typeUriAttribute.TypeUri); } - - return typeUri; } - /// - /// Gets the attachment processor for the data collector. - /// - /// The data collector to get the attachment processor for. - /// Type of the attachment processor. - private static Type GetAttachmentsProcessors(Type dataCollectorType) + return typeUri; + } + + /// + /// Gets the attachment processor for the data collector. + /// + /// The data collector to get the attachment processor for. + /// Type of the attachment processor. + private static Type GetAttachmentsProcessors(Type dataCollectorType) + { + Type attachmentsProcessor = null; + var attachmenstProcessors = GetAttributes(dataCollectorType, typeof(DataCollectorAttachmentProcessorAttribute)); + if (attachmenstProcessors != null && attachmenstProcessors.Length > 0) { - Type attachmentsProcessor = null; - var attachmenstProcessors = GetAttributes(dataCollectorType, typeof(DataCollectorAttachmentProcessorAttribute)); - if (attachmenstProcessors != null && attachmenstProcessors.Length > 0) + var attachmenstProcessorsAttribute = (DataCollectorAttachmentProcessorAttribute)attachmenstProcessors[0]; + if (attachmenstProcessorsAttribute.Type != null) { - var attachmenstProcessorsAttribute = (DataCollectorAttachmentProcessorAttribute)attachmenstProcessors[0]; - if (attachmenstProcessorsAttribute.Type != null) - { - attachmentsProcessor = attachmenstProcessorsAttribute.Type; - } + attachmentsProcessor = attachmenstProcessorsAttribute.Type; } - - return attachmentsProcessor; } - /// - /// Gets the friendly name for the data collector. - /// - /// The data collector to get the Type URI for. - /// Friendly name of the data collector. - private static string GetFriendlyName(Type dataCollectorType) - { - string friendlyName = string.Empty; + return attachmentsProcessor; + } - // Get the friendly name from the attribute. - var friendlyNameAttributes = GetAttributes(dataCollectorType, typeof(DataCollectorFriendlyNameAttribute)); - if (friendlyNameAttributes != null && friendlyNameAttributes.Length > 0) + /// + /// Gets the friendly name for the data collector. + /// + /// The data collector to get the Type URI for. + /// Friendly name of the data collector. + private static string GetFriendlyName(Type dataCollectorType) + { + string friendlyName = string.Empty; + + // Get the friendly name from the attribute. + var friendlyNameAttributes = GetAttributes(dataCollectorType, typeof(DataCollectorFriendlyNameAttribute)); + if (friendlyNameAttributes != null && friendlyNameAttributes.Length > 0) + { + var friendlyNameAttribute = (DataCollectorFriendlyNameAttribute)friendlyNameAttributes[0]; + if (!string.IsNullOrEmpty(friendlyNameAttribute.FriendlyName)) { - var friendlyNameAttribute = (DataCollectorFriendlyNameAttribute)friendlyNameAttributes[0]; - if (!string.IsNullOrEmpty(friendlyNameAttribute.FriendlyName)) - { - friendlyName = friendlyNameAttribute.FriendlyName; - } + friendlyName = friendlyNameAttribute.FriendlyName; } - - return friendlyName; } - /// - /// Gets the attributes of the specified type from the data collector type. - /// - /// - /// Data collector type to get attribute from. - /// - /// - /// The type of attribute to look for. - /// - /// - /// Array of attributes matching the type provided. Will be an empty array if none were found. - /// - private static object[] GetAttributes(Type dataCollectorType, Type attributeType) - { - Debug.Assert(dataCollectorType != null, "null dataCollectorType"); - Debug.Assert(attributeType != null, "null attributeType"); + return friendlyName; + } - // If any attribute constructor on the type throws, the exception will bubble up through - // the "GetCustomAttributes" method. - return dataCollectorType.GetTypeInfo().GetCustomAttributes(attributeType, true).ToArray(); - } + /// + /// Gets the attributes of the specified type from the data collector type. + /// + /// + /// Data collector type to get attribute from. + /// + /// + /// The type of attribute to look for. + /// + /// + /// Array of attributes matching the type provided. Will be an empty array if none were found. + /// + private static object[] GetAttributes(Type dataCollectorType, Type attributeType) + { + Debug.Assert(dataCollectorType != null, "null dataCollectorType"); + Debug.Assert(attributeType != null, "null attributeType"); + + // If any attribute constructor on the type throws, the exception will bubble up through + // the "GetCustomAttributes" method. + return dataCollectorType.GetTypeInfo().GetCustomAttributes(attributeType, true).ToArray(); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectorInformation.cs b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectorInformation.cs index 5b04927b0b..4fd1edd7e7 100644 --- a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectorInformation.cs +++ b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectorInformation.cs @@ -1,188 +1,186 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector; + +using System; +using System.Collections.Generic; +using System.Xml; +using System.IO; + +using Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +/// +/// Encapsulates datacollector object and other objects required to facilitate datacollection. +/// +internal class DataCollectorInformation { - using System; - using System.Collections.Generic; - using System.Xml; - using System.IO; + /// + /// Initializes a new instance of the class. + /// + /// + /// The data collector. + /// + /// + /// The configuration element. + /// + /// + /// The data collector config. + /// + /// + /// The environment Context. + /// + /// + /// The attachment Manager. + /// + /// + /// The events. + /// + /// + /// The message Sink. + /// + /// + internal DataCollectorInformation(DataCollector dataCollector, XmlElement configurationElement, DataCollectorConfig dataCollectorConfig, DataCollectionEnvironmentContext environmentContext, IDataCollectionAttachmentManager attachmentManager, TestPlatformDataCollectionEvents events, IMessageSink messageSink, string settingsXml) + { + DataCollector = dataCollector; + ConfigurationElement = configurationElement; + DataCollectorConfig = dataCollectorConfig; + Events = events; + EnvironmentContext = environmentContext; + DataCollectionSink = new TestPlatformDataCollectionSink(attachmentManager, dataCollectorConfig); + Logger = new TestPlatformDataCollectionLogger(messageSink, dataCollectorConfig); + SettingsXml = settingsXml; + } + + /// + /// Gets or sets the data collector. + /// + public DataCollector DataCollector { get; set; } + + /// + /// Gets or sets the configuration element. + /// + public XmlElement ConfigurationElement { get; set; } + + /// + /// Gets or sets the data collector config. + /// + public DataCollectorConfig DataCollectorConfig { get; set; } + + /// + /// Gets the events object on which the collector registers for events + /// + public TestPlatformDataCollectionEvents Events { get; private set; } + + /// + /// Gets the datacollection sink. + /// + public TestPlatformDataCollectionSink DataCollectionSink { get; private set; } - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + /// + /// Gets the data collection environment context. + /// + public DataCollectionEnvironmentContext EnvironmentContext { get; private set; } /// - /// Encapsulates datacollector object and other objects required to facilitate datacollection. + /// Gets the data collection logger /// - internal class DataCollectorInformation + public TestPlatformDataCollectionLogger Logger { get; private set; } + + /// + /// Gets the data collection logger + /// + private string SettingsXml { get; set; } + + private const string DefaultConfigurationSettings = @""; + + /// + /// Gets or sets environment variables supplied by the data collector. + /// These are available after the collector has been initialized. + /// + public IEnumerable> TestExecutionEnvironmentVariables { - /// - /// Initializes a new instance of the class. - /// - /// - /// The data collector. - /// - /// - /// The configuration element. - /// - /// - /// The data collector config. - /// - /// - /// The environment Context. - /// - /// - /// The attachment Manager. - /// - /// - /// The events. - /// - /// - /// The message Sink. - /// - /// - internal DataCollectorInformation(DataCollector dataCollector, XmlElement configurationElement, DataCollectorConfig dataCollectorConfig, DataCollectionEnvironmentContext environmentContext, IDataCollectionAttachmentManager attachmentManager, TestPlatformDataCollectionEvents events, IMessageSink messageSink, string settingsXml) - { - this.DataCollector = dataCollector; - this.ConfigurationElement = configurationElement; - this.DataCollectorConfig = dataCollectorConfig; - this.Events = events; - this.EnvironmentContext = environmentContext; - this.DataCollectionSink = new TestPlatformDataCollectionSink(attachmentManager, dataCollectorConfig); - this.Logger = new TestPlatformDataCollectionLogger(messageSink, dataCollectorConfig); - this.SettingsXml = settingsXml; - } + get; + set; + } - /// - /// Gets or sets the data collector. - /// - public DataCollector DataCollector { get; set; } - - /// - /// Gets or sets the configuration element. - /// - public XmlElement ConfigurationElement { get; set; } - - /// - /// Gets or sets the data collector config. - /// - public DataCollectorConfig DataCollectorConfig { get; set; } - - /// - /// Gets the events object on which the collector registers for events - /// - public TestPlatformDataCollectionEvents Events { get; private set; } - - /// - /// Gets the datacollection sink. - /// - public TestPlatformDataCollectionSink DataCollectionSink { get; private set; } - - /// - /// Gets the data collection environment context. - /// - public DataCollectionEnvironmentContext EnvironmentContext { get; private set; } - - /// - /// Gets the data collection logger - /// - public TestPlatformDataCollectionLogger Logger { get; private set; } - - /// - /// Gets the data collection logger - /// - private string SettingsXml { get; set; } - - private const string DefaultConfigurationSettings = @""; - - /// - /// Gets or sets environment variables supplied by the data collector. - /// These are available after the collector has been initialized. - /// - public IEnumerable> TestExecutionEnvironmentVariables - { - get; - set; - } + /// + /// Initializes datacollectors. + /// + internal void InitializeDataCollector() + { + UpdateConfigurationElement(); - /// - /// Initializes datacollectors. - /// - internal void InitializeDataCollector() - { - UpdateConfigurationElement(); + DataCollector.Initialize(ConfigurationElement, Events, DataCollectionSink, Logger, EnvironmentContext); + } - this.DataCollector.Initialize(this.ConfigurationElement, this.Events, this.DataCollectionSink, this.Logger, this.EnvironmentContext); - } + private void UpdateConfigurationElement() + { + var frameWork = XmlRunSettingsUtilities.GetRunConfigurationNode(SettingsXml).TargetFramework; - private void UpdateConfigurationElement() + if (ConfigurationElement == null) { - var frameWork = XmlRunSettingsUtilities.GetRunConfigurationNode(this.SettingsXml).TargetFramework; - - if (this.ConfigurationElement == null) + var doc = new XmlDocument(); + using ( + var xmlReader = XmlReader.Create( + new StringReader(DefaultConfigurationSettings), + new XmlReaderSettings { CloseInput = true, DtdProcessing = DtdProcessing.Prohibit })) { - var doc = new XmlDocument(); - using ( - var xmlReader = XmlReader.Create( - new StringReader(DefaultConfigurationSettings), - new XmlReaderSettings { CloseInput = true, DtdProcessing = DtdProcessing.Prohibit })) - { - doc.Load(xmlReader); - } - - this.ConfigurationElement = doc.DocumentElement; + doc.Load(xmlReader); } - // Add Framework config, since it could be required by DataCollector, to determine whether they support this Framework or not - if (frameWork != null) - { - AppendChildNodeOrInnerText(this.ConfigurationElement.OwnerDocument, this.ConfigurationElement, "Framework", string.Empty, frameWork.Name); - } + ConfigurationElement = doc.DocumentElement; } - private static void AppendChildNodeOrInnerText(XmlDocument doc, XmlElement owner, string elementName, string nameSpaceUri, string innerText) + // Add Framework config, since it could be required by DataCollector, to determine whether they support this Framework or not + if (frameWork != null) { - var node = owner.SelectSingleNode(elementName) ?? doc.CreateNode("element", elementName, nameSpaceUri); - node.InnerText = innerText; - owner.AppendChild(node); + AppendChildNodeOrInnerText(ConfigurationElement.OwnerDocument, ConfigurationElement, "Framework", string.Empty, frameWork.Name); } + } + + private static void AppendChildNodeOrInnerText(XmlDocument doc, XmlElement owner, string elementName, string nameSpaceUri, string innerText) + { + var node = owner.SelectSingleNode(elementName) ?? doc.CreateNode("element", elementName, nameSpaceUri); + node.InnerText = innerText; + owner.AppendChild(node); + } - /// - /// Disposes datacollector. - /// - internal void DisposeDataCollector() + /// + /// Disposes datacollector. + /// + internal void DisposeDataCollector() + { + try { - try + if (EqtTrace.IsVerboseEnabled) { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("dataCollectorInfo.DisposeDataCollector: calling Dispose() on {0}", this.DataCollector.GetType()); - } - - this.DataCollector.Dispose(); + EqtTrace.Verbose("dataCollectorInfo.DisposeDataCollector: calling Dispose() on {0}", DataCollector.GetType()); } - catch (Exception ex) + + DataCollector.Dispose(); + } + catch (Exception ex) + { + if (EqtTrace.IsErrorEnabled) { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("DataCollectorInfo.DisposeDataCollector: exception while calling Dispose() on {0}: " + ex, this.DataCollector.GetType()); - } + EqtTrace.Error("DataCollectorInfo.DisposeDataCollector: exception while calling Dispose() on {0}: " + ex, DataCollector.GetType()); } } + } - /// - /// The get test execution environment variables sync. - /// - public void SetTestExecutionEnvironmentVariables() + /// + /// The get test execution environment variables sync. + /// + public void SetTestExecutionEnvironmentVariables() + { + if (DataCollector is ITestExecutionEnvironmentSpecifier testExecutionEnvironmentSpecifier) { - var testExecutionEnvironmentSpecifier = this.DataCollector as ITestExecutionEnvironmentSpecifier; - if (testExecutionEnvironmentSpecifier != null) - { - // Get the environment variables the data collector wants set in the test execution environment - this.TestExecutionEnvironmentVariables = testExecutionEnvironmentSpecifier.GetTestExecutionEnvironmentVariables(); - } + // Get the environment variables the data collector wants set in the test execution environment + TestExecutionEnvironmentVariables = testExecutionEnvironmentSpecifier.GetTestExecutionEnvironmentVariables(); } } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/Interfaces/IDataCollectionAttachmentManager.cs b/src/Microsoft.TestPlatform.Common/DataCollection/Interfaces/IDataCollectionAttachmentManager.cs index 2b4928c2a2..4d831afd3f 100644 --- a/src/Microsoft.TestPlatform.Common/DataCollection/Interfaces/IDataCollectionAttachmentManager.cs +++ b/src/Microsoft.TestPlatform.Common/DataCollection/Interfaces/IDataCollectionAttachmentManager.cs @@ -1,65 +1,64 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces -{ - using System; - using System.Collections.Generic; - using System.ComponentModel; +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; + +using System; +using System.Collections.Generic; +using System.ComponentModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +/// +/// The DataCollectionAttachmentManager Interface. +/// +internal interface IDataCollectionAttachmentManager +{ /// - /// The DataCollectionAttachmentManager Interface. + /// Initializes session, output directory and data collection log. /// - internal interface IDataCollectionAttachmentManager - { - /// - /// Initializes session, output directory and data collection log. - /// - /// - /// The id. - /// - /// - /// The output directory. - /// - /// - /// The message Sink. - /// - void Initialize(SessionId id, string outputDirectory, IMessageSink messageSink); + /// + /// The id. + /// + /// + /// The output directory. + /// + /// + /// The message Sink. + /// + void Initialize(SessionId id, string outputDirectory, IMessageSink messageSink); - /// - /// Gets attachment sets associated with given collection context. - /// - /// - /// The data collection context. - /// - /// - /// The . - /// - List GetAttachments(DataCollectionContext dataCollectionContext); + /// + /// Gets attachment sets associated with given collection context. + /// + /// + /// The data collection context. + /// + /// + /// The . + /// + List GetAttachments(DataCollectionContext dataCollectionContext); - /// - /// Adds new attachment to current context - /// - /// - /// The file Transfer Info. - /// - /// - /// The send File Completed Callback. - /// - /// - /// Uri of the data collector. - /// - /// - /// The friendly Name. - /// - void AddAttachment(FileTransferInformation fileTransferInfo, AsyncCompletedEventHandler sendFileCompletedCallback, Uri dataCollectorUri, string friendlyName); + /// + /// Adds new attachment to current context + /// + /// + /// The file Transfer Info. + /// + /// + /// The send File Completed Callback. + /// + /// + /// Uri of the data collector. + /// + /// + /// The friendly Name. + /// + void AddAttachment(FileTransferInformation fileTransferInfo, AsyncCompletedEventHandler sendFileCompletedCallback, Uri dataCollectorUri, string friendlyName); - /// - /// Stops processing further transfer requests as test run is canceled. - /// - void Cancel(); - } -} + /// + /// Stops processing further transfer requests as test run is canceled. + /// + void Cancel(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/Interfaces/IDataCollectionManager.cs b/src/Microsoft.TestPlatform.Common/DataCollection/Interfaces/IDataCollectionManager.cs index a18a852473..522580c6e1 100644 --- a/src/Microsoft.TestPlatform.Common/DataCollection/Interfaces/IDataCollectionManager.cs +++ b/src/Microsoft.TestPlatform.Common/DataCollection/Interfaces/IDataCollectionManager.cs @@ -1,76 +1,75 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces -{ - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +/// +/// Defines the Data Collection Manager for Data Collectors. +/// +internal interface IDataCollectionManager : IDisposable +{ /// - /// Defines the Data Collection Manager for Data Collectors. + /// Loads and initializes data collector plugins. /// - internal interface IDataCollectionManager : IDisposable - { - /// - /// Loads and initializes data collector plugins. - /// - /// Run Settings which has DataCollector configuration. - /// Environment variables. - IDictionary InitializeDataCollectors(string settingsXml); + /// Run Settings which has DataCollector configuration. + /// Environment variables. + IDictionary InitializeDataCollectors(string settingsXml); - /// - /// Raises TestCaseStart event to all data collectors configured for run. - /// - /// TestCaseStart event. - void TestCaseStarted(TestCaseStartEventArgs testCaseStartEventArgs); + /// + /// Raises TestCaseStart event to all data collectors configured for run. + /// + /// TestCaseStart event. + void TestCaseStarted(TestCaseStartEventArgs testCaseStartEventArgs); - /// - /// Raises TestCaseEnd event to all data collectors configured for run. - /// - /// - /// The test Case End Event Args. - /// - /// - /// Collection of testCase attachmentSet. - /// - Collection TestCaseEnded(TestCaseEndEventArgs testCaseEndEventArgs); + /// + /// Raises TestCaseEnd event to all data collectors configured for run. + /// + /// + /// The test Case End Event Args. + /// + /// + /// Collection of testCase attachmentSet. + /// + Collection TestCaseEnded(TestCaseEndEventArgs testCaseEndEventArgs); - /// - /// Raises TestHostLaunched event to all data collectors configured for run. - /// - /// - /// Process ID of test host. - /// - void TestHostLaunched(int processId); + /// + /// Raises TestHostLaunched event to all data collectors configured for run. + /// + /// + /// Process ID of test host. + /// + void TestHostLaunched(int processId); - /// - /// Raises SessionStart event to all data collectors configured for run. - /// - /// - /// The session start Event Args. - /// - /// boolean value specifying whether test case events are subscribed by datacollectors. Based on this execution process will decide whether to send TestCaseStart and TestCaseEnd events to dataCollector process. - bool SessionStarted(SessionStartEventArgs sessionStartEventArgs); + /// + /// Raises SessionStart event to all data collectors configured for run. + /// + /// + /// The session start Event Args. + /// + /// boolean value specifying whether test case events are subscribed by datacollectors. Based on this execution process will decide whether to send TestCaseStart and TestCaseEnd events to dataCollector process. + bool SessionStarted(SessionStartEventArgs sessionStartEventArgs); - /// - /// Raises SessionEnd event to all data collectors configured for run. - /// - /// - /// Boolean to specify is the test run is canceled or not. - /// - /// - /// Collection of session attachmentSet. - /// - Collection SessionEnded(bool isCancelled); + /// + /// Raises SessionEnd event to all data collectors configured for run. + /// + /// + /// Boolean to specify is the test run is canceled or not. + /// + /// + /// Collection of session attachmentSet. + /// + Collection SessionEnded(bool isCancelled); - /// - /// Return a collections of the invoked data collectors - /// - /// Collection of data collectors. - Collection GetInvokedDataCollectors(); - } + /// + /// Return a collections of the invoked data collectors + /// + /// Collection of data collectors. + Collection GetInvokedDataCollectors(); } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/Interfaces/IDataCollectionTelemetryManager.cs b/src/Microsoft.TestPlatform.Common/DataCollection/Interfaces/IDataCollectionTelemetryManager.cs index 9bc3550914..4d55c3401f 100644 --- a/src/Microsoft.TestPlatform.Common/DataCollection/Interfaces/IDataCollectionTelemetryManager.cs +++ b/src/Microsoft.TestPlatform.Common/DataCollection/Interfaces/IDataCollectionTelemetryManager.cs @@ -1,42 +1,41 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; + +/// +/// The IDataCollectionTelemetryManager Interface. +/// +internal interface IDataCollectionTelemetryManager { /// - /// The IDataCollectionTelemetryManager Interface. + /// Record telemetry regarding environment variable added. /// - internal interface IDataCollectionTelemetryManager - { - /// - /// Record telemetry regarding environment variable added. - /// - /// - /// Data collector information which requested environment variable. - /// - /// - /// Environment variable name. - /// - /// - /// Environment variable value. - /// - void RecordEnvironmentVariableAddition(DataCollectorInformation dataCollectorInformation, string name, string value); + /// + /// Data collector information which requested environment variable. + /// + /// + /// Environment variable name. + /// + /// + /// Environment variable value. + /// + void RecordEnvironmentVariableAddition(DataCollectorInformation dataCollectorInformation, string name, string value); - /// - /// Record telemetry regarding environment variable is conflicting. - /// - /// - /// Data collector information which requested environment variable. - /// - /// - /// Environment variable name. - /// - /// - /// Environment variable value. - /// - /// - /// Environment variable value that was requested previously. - /// - void RecordEnvironmentVariableConflict(DataCollectorInformation dataCollectorInformation, string name, string value, string existingValue); - } -} + /// + /// Record telemetry regarding environment variable is conflicting. + /// + /// + /// Data collector information which requested environment variable. + /// + /// + /// Environment variable name. + /// + /// + /// Environment variable value. + /// + /// + /// Environment variable value that was requested previously. + /// + void RecordEnvironmentVariableConflict(DataCollectorInformation dataCollectorInformation, string name, string value, string existingValue); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/Interfaces/IMessageSink.cs b/src/Microsoft.TestPlatform.Common/DataCollection/Interfaces/IMessageSink.cs index b5b6e492a9..87beabe27c 100644 --- a/src/Microsoft.TestPlatform.Common/DataCollection/Interfaces/IMessageSink.cs +++ b/src/Microsoft.TestPlatform.Common/DataCollection/Interfaces/IMessageSink.cs @@ -1,19 +1,18 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces -{ - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +/// +/// Expose methods to be used by data collection process to send messages to Test Platform Client. +/// +internal interface IMessageSink +{ /// - /// Expose methods to be used by data collection process to send messages to Test Platform Client. + /// Data collection message as sent by DataCollectionLogger. /// - internal interface IMessageSink - { - /// - /// Data collection message as sent by DataCollectionLogger. - /// - /// Data collection message event args. - void SendMessage(DataCollectionMessageEventArgs args); - } -} + /// Data collection message event args. + void SendMessage(DataCollectionMessageEventArgs args); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/TestPlatformDataCollectionEvents.cs b/src/Microsoft.TestPlatform.Common/DataCollection/TestPlatformDataCollectionEvents.cs index 35585a6663..6e0731aef0 100644 --- a/src/Microsoft.TestPlatform.Common/DataCollection/TestPlatformDataCollectionEvents.cs +++ b/src/Microsoft.TestPlatform.Common/DataCollection/TestPlatformDataCollectionEvents.cs @@ -1,184 +1,179 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector -{ - using System; - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector; + +using System; +using System.Collections.Generic; + +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.Utilities; +/// +/// The test platform data collection events. +/// +internal sealed class TestPlatformDataCollectionEvents : DataCollectionEvents +{ + /// + /// Maps the type of event args to the multi cast delegate for that event + /// + private readonly Dictionary _eventArgsToEventInvokerMap; /// - /// The test platform data collection events. + /// Initializes a new instance of the class by mapping the types of expected event args to the multi cast + /// delegate that invokes the event on registered targets /// - internal sealed class TestPlatformDataCollectionEvents : DataCollectionEvents + internal TestPlatformDataCollectionEvents() { - /// - /// Maps the type of event args to the multi cast delegate for that event - /// - private Dictionary eventArgsToEventInvokerMap; - - /// - /// Initializes a new instance of the class by mapping the types of expected event args to the multi cast - /// delegate that invokes the event on registered targets - /// - internal TestPlatformDataCollectionEvents() + _eventArgsToEventInvokerMap = new Dictionary(4) { - this.eventArgsToEventInvokerMap = new Dictionary(4); + [typeof(TestHostLaunchedEventArgs)] = OnTestHostLaunched, + [typeof(SessionStartEventArgs)] = OnSessionStart, + [typeof(SessionEndEventArgs)] = OnSessionEnd, + [typeof(TestCaseStartEventArgs)] = OnTestCaseStart, + [typeof(TestCaseEndEventArgs)] = OnTestCaseEnd + }; + } - this.eventArgsToEventInvokerMap[typeof(TestHostLaunchedEventArgs)] = this.OnTestHostLaunched; - this.eventArgsToEventInvokerMap[typeof(SessionStartEventArgs)] = this.OnSessionStart; - this.eventArgsToEventInvokerMap[typeof(SessionEndEventArgs)] = this.OnSessionEnd; - this.eventArgsToEventInvokerMap[typeof(TestCaseStartEventArgs)] = this.OnTestCaseStart; - this.eventArgsToEventInvokerMap[typeof(TestCaseEndEventArgs)] = this.OnTestCaseEnd; - } + /// + /// Delegate for the event invoker methods (OnSessionStart, OnTestCaseResume, etc.) + /// + /// + /// Contains the event data + /// + private delegate void EventInvoker(DataCollectionEventArgs e); - /// - /// Delegate for the event invoker methods (OnSessionStart, OnTestCaseResume, etc.) - /// - /// - /// Contains the event data - /// - private delegate void EventInvoker(DataCollectionEventArgs e); - - /// - /// Raised when test host process has initialized - /// - public override event EventHandler TestHostLaunched; - - /// - /// Raised when a session is starting - /// - public override event EventHandler SessionStart; - - /// - /// Raised when a session is ending - /// - public override event EventHandler SessionEnd; - - /// - /// Raised when a test case is starting - /// - public override event EventHandler TestCaseStart; - - /// - /// Raised when a test case is ending - /// - public override event EventHandler TestCaseEnd; - - /// - /// Raises the event corresponding to the event arguments to all registered handlers - /// - /// - /// Contains the event data - /// - internal void RaiseEvent(DataCollectionEventArgs e) - { - ValidateArg.NotNull(e, "DataCollectionEventArgs"); + /// + /// Raised when test host process has initialized + /// + public override event EventHandler TestHostLaunched; + /// + /// Raised when a session is starting + /// + public override event EventHandler SessionStart; - if (this.eventArgsToEventInvokerMap.TryGetValue(e.GetType(), out var onEvent)) - { - onEvent(e); - } - else - { - EqtTrace.Fail("TestPlatformDataCollectionEvents.RaiseEvent: Unrecognized data collection event of type {0}.", e.GetType().FullName); - } - } + /// + /// Raised when a session is ending + /// + public override event EventHandler SessionEnd; + + /// + /// Raised when a test case is starting + /// + public override event EventHandler TestCaseStart; - /// - /// Checks whether any data collector has subscribed for test case events. - /// - internal bool AreTestCaseEventsSubscribed() + /// + /// Raised when a test case is ending + /// + public override event EventHandler TestCaseEnd; + + /// + /// Raises the event corresponding to the event arguments to all registered handlers + /// + /// + /// Contains the event data + /// + internal void RaiseEvent(DataCollectionEventArgs e) + { + ValidateArg.NotNull(e, "DataCollectionEventArgs"); + + + if (_eventArgsToEventInvokerMap.TryGetValue(e.GetType(), out var onEvent)) + { + onEvent(e); + } + else { - bool valueOnFailure = false; - return (HasEventListener(this.TestCaseStart, valueOnFailure) || HasEventListener(this.TestCaseEnd, valueOnFailure)); + EqtTrace.Fail("TestPlatformDataCollectionEvents.RaiseEvent: Unrecognized data collection event of type {0}.", e.GetType().FullName); } + } - private bool HasEventListener(MulticastDelegate eventToCheck, bool valueOnFailure) + /// + /// Checks whether any data collector has subscribed for test case events. + /// + internal bool AreTestCaseEventsSubscribed() + { + bool valueOnFailure = false; + return (HasEventListener(TestCaseStart, valueOnFailure) || HasEventListener(TestCaseEnd, valueOnFailure)); + } + + private bool HasEventListener(MulticastDelegate eventToCheck, bool valueOnFailure) + { + try { - try + if (eventToCheck == null) { - if (eventToCheck == null) - { - return false; - } - - Delegate[] listeners = eventToCheck.GetInvocationList(); - if (listeners == null || listeners.Length == 0) - { - return false; - } - - return true; + return false; } - catch (Exception ex) - { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("TestPlatformDataCollectionEvents.AreTestCaseLevelEventsRequired: Exception occurred while checking whether event {0} has any listeners or not. {1}", eventToCheck, ex); - } - return valueOnFailure; - } + Delegate[] listeners = eventToCheck.GetInvocationList(); + return listeners != null && listeners.Length != 0; } - - /// - /// Raises the TestHostLaunched event - /// - /// - /// Contains the event data - /// - private void OnTestHostLaunched(DataCollectionEventArgs e) + catch (Exception ex) { - this.TestHostLaunched.SafeInvoke(this, e, "DataCollectionEvents.TestHostLaunched"); - } + if (EqtTrace.IsErrorEnabled) + { + EqtTrace.Error("TestPlatformDataCollectionEvents.AreTestCaseLevelEventsRequired: Exception occurred while checking whether event {0} has any listeners or not. {1}", eventToCheck, ex); + } - /// - /// Raises the SessionStart event - /// - /// - /// Contains the event data - /// - private void OnSessionStart(DataCollectionEventArgs e) - { - this.SessionStart.SafeInvoke(this, e, "DataCollectionEvents.SessionStart"); + return valueOnFailure; } + } - /// - /// Raises the SessionEnd event - /// - /// - /// Contains the event data - /// - private void OnSessionEnd(DataCollectionEventArgs e) - { - this.SessionEnd.SafeInvoke(this, e, "DataCollectionEvents.SessionEnd"); - } + /// + /// Raises the TestHostLaunched event + /// + /// + /// Contains the event data + /// + private void OnTestHostLaunched(DataCollectionEventArgs e) + { + TestHostLaunched.SafeInvoke(this, e, "DataCollectionEvents.TestHostLaunched"); + } - /// - /// Raises the TestCaseStart event - /// - /// - /// Contains the event data - /// - private void OnTestCaseStart(DataCollectionEventArgs e) - { - this.TestCaseStart.SafeInvoke(this, e, "DataCollectionEvents.TestCaseStart"); - } + /// + /// Raises the SessionStart event + /// + /// + /// Contains the event data + /// + private void OnSessionStart(DataCollectionEventArgs e) + { + SessionStart.SafeInvoke(this, e, "DataCollectionEvents.SessionStart"); + } - /// - /// Raises the TestCaseEnd event - /// - /// - /// Contains the event data - /// - private void OnTestCaseEnd(DataCollectionEventArgs e) - { - this.TestCaseEnd.SafeInvoke(this, e, "DataCollectionEvents.TestCaseEnd"); - } + /// + /// Raises the SessionEnd event + /// + /// + /// Contains the event data + /// + private void OnSessionEnd(DataCollectionEventArgs e) + { + SessionEnd.SafeInvoke(this, e, "DataCollectionEvents.SessionEnd"); + } + + /// + /// Raises the TestCaseStart event + /// + /// + /// Contains the event data + /// + private void OnTestCaseStart(DataCollectionEventArgs e) + { + TestCaseStart.SafeInvoke(this, e, "DataCollectionEvents.TestCaseStart"); + } + + /// + /// Raises the TestCaseEnd event + /// + /// + /// Contains the event data + /// + private void OnTestCaseEnd(DataCollectionEventArgs e) + { + TestCaseEnd.SafeInvoke(this, e, "DataCollectionEvents.TestCaseEnd"); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/TestPlatformDataCollectionLogger.cs b/src/Microsoft.TestPlatform.Common/DataCollection/TestPlatformDataCollectionLogger.cs index 02de86b114..183e84f096 100644 --- a/src/Microsoft.TestPlatform.Common/DataCollection/TestPlatformDataCollectionLogger.cs +++ b/src/Microsoft.TestPlatform.Common/DataCollection/TestPlatformDataCollectionLogger.cs @@ -1,157 +1,156 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector; + +using System; +using System.Diagnostics; +using System.Globalization; + +using Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +/// +/// Class used by data collectors to send messages to the client +/// +internal class TestPlatformDataCollectionLogger : DataCollectionLogger { - using System; - using System.Diagnostics; - using System.Globalization; + /// + /// DataCollector's config info. + /// + private readonly DataCollectorConfig _dataCollectorConfig; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + /// + /// Message sink. + /// + private readonly IMessageSink _sink; /// - /// Class used by data collectors to send messages to the client + /// Initializes a new instance of the class. /// - internal class TestPlatformDataCollectionLogger : DataCollectionLogger + /// + /// The underlying raw IMessageSink. Cannot be null. + /// + /// + /// The data Collector Information. + /// + internal TestPlatformDataCollectionLogger(IMessageSink sink, DataCollectorConfig dataCollectorConfig) { - /// - /// DataCollector's config info. - /// - private readonly DataCollectorConfig dataCollectorConfig; - - /// - /// Message sink. - /// - private readonly IMessageSink sink; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The underlying raw IMessageSink. Cannot be null. - /// - /// - /// The data Collector Information. - /// - internal TestPlatformDataCollectionLogger(IMessageSink sink, DataCollectorConfig dataCollectorConfig) + ValidateArg.NotNull(dataCollectorConfig, "dataCollectorInformation"); + ValidateArg.NotNull(sink, nameof(sink)); + _dataCollectorConfig = dataCollectorConfig; + _sink = sink; + } + + /// + public override void LogError(DataCollectionContext context, string text) + { + ValidateArg.NotNull(context, nameof(context)); + ValidateArg.NotNull(text, nameof(text)); + + if (EqtTrace.IsErrorEnabled) { - ValidateArg.NotNull(dataCollectorConfig, "dataCollectorInformation"); - ValidateArg.NotNull(sink, nameof(sink)); - this.dataCollectorConfig = dataCollectorConfig; - this.sink = sink; + EqtTrace.Error( + "Data collector '{0}' logged the following error: {1}", + _dataCollectorConfig.TypeUri, + text); } - /// - public override void LogError(DataCollectionContext context, string text) + SendTextMessage(context, text, TestMessageLevel.Error); + } + + /// + public override void LogError(DataCollectionContext context, string text, Exception exception) + { + ValidateArg.NotNull(context, nameof(context)); + ValidateArg.NotNull(text, nameof(text)); + ValidateArg.NotNull(exception, nameof(exception)); + + // Make sure the data collection context is not a derived data collection context. This + // is done to safeguard from 3rd parties creating their own data collection contexts. + if (context.GetType() != typeof(DataCollectionContext)) { - ValidateArg.NotNull(context, nameof(context)); - ValidateArg.NotNull(text, nameof(text)); - - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error( - "Data collector '{0}' logged the following error: {1}", - this.dataCollectorConfig.TypeUri, - text); - } - - this.SendTextMessage(context, text, TestMessageLevel.Error); + throw new InvalidOperationException(Resources.Resources.WrongDataCollectionContextType); } - /// - public override void LogError(DataCollectionContext context, string text, Exception exception) + if (EqtTrace.IsErrorEnabled) { - ValidateArg.NotNull(context, nameof(context)); - ValidateArg.NotNull(text, nameof(text)); - ValidateArg.NotNull(exception, nameof(exception)); - - // Make sure the data collection context is not a derived data collection context. This - // is done to safeguard from 3rd parties creating their own data collection contexts. - if (context.GetType() != typeof(DataCollectionContext)) - { - throw new InvalidOperationException(Resources.Resources.WrongDataCollectionContextType); - } - - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error( - "Data collector '{0}' logged the following error:" + Environment.NewLine + - "Description: {1}" + Environment.NewLine + - "Exception type: {2}" + Environment.NewLine + "Exception message: {3}" - + Environment.NewLine + "Exception stack trace: {4}", - this.dataCollectorConfig.TypeUri, - text, - exception.GetType(), - exception.Message, - exception.StackTrace); - } - - // Currently there is one type of DataCollectionMessage sent across client for all message kind. - // If required new type can be created for different message type. - var message = string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.ReportDataCollectorException, + EqtTrace.Error( + "Data collector '{0}' logged the following error:" + Environment.NewLine + + "Description: {1}" + Environment.NewLine + + "Exception type: {2}" + Environment.NewLine + "Exception message: {3}" + + Environment.NewLine + "Exception stack trace: {4}", + _dataCollectorConfig.TypeUri, + text, exception.GetType(), exception.Message, - text); - this.SendTextMessage(context, message, TestMessageLevel.Error); + exception.StackTrace); } - /// - public override void LogWarning(DataCollectionContext context, string text) - { - ValidateArg.NotNull(context, nameof(context)); - ValidateArg.NotNull(text, nameof(text)); - EqtTrace.Warning( - "Data collector '{0}' logged the following warning: {1}", - this.dataCollectorConfig.TypeUri, - text); + // Currently there is one type of DataCollectionMessage sent across client for all message kind. + // If required new type can be created for different message type. + var message = string.Format( + CultureInfo.CurrentCulture, + Resources.Resources.ReportDataCollectorException, + exception.GetType(), + exception.Message, + text); + SendTextMessage(context, message, TestMessageLevel.Error); + } + + /// + public override void LogWarning(DataCollectionContext context, string text) + { + ValidateArg.NotNull(context, nameof(context)); + ValidateArg.NotNull(text, nameof(text)); + EqtTrace.Warning( + "Data collector '{0}' logged the following warning: {1}", + _dataCollectorConfig.TypeUri, + text); + + SendTextMessage(context, text, TestMessageLevel.Warning); + } - this.SendTextMessage(context, text, TestMessageLevel.Warning); + /// + /// Sends text to message sink. + /// + /// + /// The context. + /// + /// + /// The text. + /// + /// + /// The level. + /// + /// Throws InvalidOperationException. + /// + private void SendTextMessage(DataCollectionContext context, string text, TestMessageLevel level) + { + ValidateArg.NotNull(context, nameof(context)); + ValidateArg.NotNull(text, nameof(text)); + + Debug.Assert( + level >= TestMessageLevel.Informational && level <= TestMessageLevel.Error, + "Invalid level: " + level); + + // Make sure the data collection context is not a derived data collection context. This + // is done to safeguard from 3rd parties creating their own data collection contexts. + if (context.GetType() != typeof(DataCollectionContext)) + { + throw new InvalidOperationException(Resources.Resources.WrongDataCollectionContextType); } - /// - /// Sends text to message sink. - /// - /// - /// The context. - /// - /// - /// The text. - /// - /// - /// The level. - /// - /// Throws InvalidOperationException. - /// - private void SendTextMessage(DataCollectionContext context, string text, TestMessageLevel level) + var args = new DataCollectionMessageEventArgs(level, text); + args.Uri = _dataCollectorConfig.TypeUri; + args.FriendlyName = _dataCollectorConfig.FriendlyName; + if (context.HasTestCase) { - ValidateArg.NotNull(context, nameof(context)); - ValidateArg.NotNull(text, nameof(text)); - - Debug.Assert( - level >= TestMessageLevel.Informational && level <= TestMessageLevel.Error, - "Invalid level: " + level); - - // Make sure the data collection context is not a derived data collection context. This - // is done to safeguard from 3rd parties creating their own data collection contexts. - if (context.GetType() != typeof(DataCollectionContext)) - { - throw new InvalidOperationException(Resources.Resources.WrongDataCollectionContextType); - } - - var args = new DataCollectionMessageEventArgs(level, text); - args.Uri = this.dataCollectorConfig.TypeUri; - args.FriendlyName = this.dataCollectorConfig.FriendlyName; - if (context.HasTestCase) - { - args.TestCaseId = context.TestExecId.Id; - } - - this.sink.SendMessage(args); + args.TestCaseId = context.TestExecId.Id; } + + _sink.SendMessage(args); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/TestPlatformDataCollectionSink.cs b/src/Microsoft.TestPlatform.Common/DataCollection/TestPlatformDataCollectionSink.cs index c698d52f02..bd2e07bf7d 100644 --- a/src/Microsoft.TestPlatform.Common/DataCollection/TestPlatformDataCollectionSink.cs +++ b/src/Microsoft.TestPlatform.Common/DataCollection/TestPlatformDataCollectionSink.cs @@ -1,68 +1,67 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector -{ - using System.ComponentModel; +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector; + +using System.ComponentModel; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +/// +/// The test platform data collection sink. +/// +internal class TestPlatformDataCollectionSink : DataCollectionSink +{ /// - /// The test platform data collection sink. + /// Initializes a new instance of the class. + /// Creates a data collector sink for data transfer. /// - internal class TestPlatformDataCollectionSink : DataCollectionSink + /// + /// The attachment Manager. + /// + /// + /// Data collector info. + /// + internal TestPlatformDataCollectionSink(IDataCollectionAttachmentManager attachmentManager, DataCollectorConfig dataCollectorConfig) { - /// - /// Initializes a new instance of the class. - /// Creates a data collector sink for data transfer. - /// - /// - /// The attachment Manager. - /// - /// - /// Data collector info. - /// - internal TestPlatformDataCollectionSink(IDataCollectionAttachmentManager attachmentManager, DataCollectorConfig dataCollectorConfig) - { - ValidateArg.NotNull(attachmentManager, nameof(attachmentManager)); - ValidateArg.NotNull(dataCollectorConfig, nameof(dataCollectorConfig)); + ValidateArg.NotNull(attachmentManager, nameof(attachmentManager)); + ValidateArg.NotNull(dataCollectorConfig, nameof(dataCollectorConfig)); - this.DataCollectorConfig = dataCollectorConfig; - this.AttachmentManager = attachmentManager; - } + DataCollectorConfig = dataCollectorConfig; + AttachmentManager = attachmentManager; + } - /// - /// Event handler for handling file transfer completed event. - /// - public override event AsyncCompletedEventHandler SendFileCompleted; + /// + /// Event handler for handling file transfer completed event. + /// + public override event AsyncCompletedEventHandler SendFileCompleted; - /// - /// Gets or sets message sink to transfer collection message. - /// - private IDataCollectionAttachmentManager AttachmentManager - { - get; set; - } + /// + /// Gets or sets message sink to transfer collection message. + /// + private IDataCollectionAttachmentManager AttachmentManager + { + get; set; + } - /// - /// Gets or sets dataCollector with which this data sink is associated. - /// - private DataCollectorConfig DataCollectorConfig - { - get; set; - } + /// + /// Gets or sets dataCollector with which this data sink is associated. + /// + private DataCollectorConfig DataCollectorConfig + { + get; set; + } - /// - /// Sends a file asynchronously. - /// - /// Information about the file being transferred. - public override void SendFileAsync(FileTransferInformation fileTransferInformation) - { - ValidateArg.NotNull(fileTransferInformation, nameof(fileTransferInformation)); + /// + /// Sends a file asynchronously. + /// + /// Information about the file being transferred. + public override void SendFileAsync(FileTransferInformation fileTransferInformation) + { + ValidateArg.NotNull(fileTransferInformation, nameof(fileTransferInformation)); - this.AttachmentManager.AddAttachment(fileTransferInformation, this.SendFileCompleted, this.DataCollectorConfig.TypeUri, this.DataCollectorConfig.FriendlyName); - } + AttachmentManager.AddAttachment(fileTransferInformation, SendFileCompleted, DataCollectorConfig.TypeUri, DataCollectorConfig.FriendlyName); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Exceptions/InvalidLoggerException.cs b/src/Microsoft.TestPlatform.Common/Exceptions/InvalidLoggerException.cs index 14661d60bc..512d37f9e4 100644 --- a/src/Microsoft.TestPlatform.Common/Exceptions/InvalidLoggerException.cs +++ b/src/Microsoft.TestPlatform.Common/Exceptions/InvalidLoggerException.cs @@ -1,35 +1,34 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Exceptions -{ - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using System; +namespace Microsoft.VisualStudio.TestPlatform.Common.Exceptions; - public class InvalidLoggerException : TestPlatformException - { - #region Constructors +using ObjectModel; - /// - /// Initializes with the message. - /// - /// Message for the exception. - public InvalidLoggerException(string message) - : base(message) - { - } +using System; - /// - /// Initializes with message and inner exception. - /// - /// Message for the exception. - /// The inner exception. - public InvalidLoggerException(string message, Exception innerException) - : base(message, innerException) - { - } +public class InvalidLoggerException : TestPlatformException +{ + #region Constructors - #endregion + /// + /// Initializes with the message. + /// + /// Message for the exception. + public InvalidLoggerException(string message) + : base(message) + { + } + + /// + /// Initializes with message and inner exception. + /// + /// Message for the exception. + /// The inner exception. + public InvalidLoggerException(string message, Exception innerException) + : base(message, innerException) + { } -} + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/DataCollectionExtensionManager.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/DataCollectionExtensionManager.cs index b3c07f626f..08937bfec7 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/DataCollectionExtensionManager.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/DataCollectionExtensionManager.cs @@ -1,152 +1,151 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; + +using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using DataCollector; +using Utilities; +using Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +/// +/// Manages loading and provides access to data collector extensions implementing the +/// DataCollector interface. +/// +internal class DataCollectorExtensionManager : TestExtensionManager +{ /// - /// Manages loading and provides access to data collector extensions implementing the - /// DataCollector interface. + /// Default constructor. /// - internal class DataCollectorExtensionManager : TestExtensionManager + /// + /// The unfiltered Test Extensions. + /// + /// + /// The test Extensions. + /// + /// + /// The logger. + /// + /// + /// The constructor is not public because the factory method should be used to get instances of this class. + /// + protected DataCollectorExtensionManager( + IEnumerable>> unfilteredTestExtensions, + IEnumerable> testExtensions, + IMessageLogger logger) + : base(unfilteredTestExtensions, testExtensions, logger) { - /// - /// Default constructor. - /// - /// - /// The unfiltered Test Extensions. - /// - /// - /// The test Extensions. - /// - /// - /// The logger. - /// - /// - /// The constructor is not public because the factory method should be used to get instances of this class. - /// - protected DataCollectorExtensionManager( - IEnumerable>> unfilteredTestExtensions, - IEnumerable> testExtensions, - IMessageLogger logger) - : base(unfilteredTestExtensions, testExtensions, logger) - { - } + } - /// - /// Gets an instance of the DataCollectorExtensionManager. - /// - /// - /// The message Logger. - /// - /// - /// The DataCollectorExtensionManager. - /// - public static DataCollectorExtensionManager Create(IMessageLogger messageLogger) - { - TestPluginManager.Instance.GetSpecificTestExtensions( - TestPlatformConstants.DataCollectorEndsWithPattern, - out var unfilteredTestExtensions, - out var filteredTestExtensions); + /// + /// Gets an instance of the DataCollectorExtensionManager. + /// + /// + /// The message Logger. + /// + /// + /// The DataCollectorExtensionManager. + /// + public static DataCollectorExtensionManager Create(IMessageLogger messageLogger) + { + TestPluginManager.Instance.GetSpecificTestExtensions( + TestPlatformConstants.DataCollectorEndsWithPattern, + out var unfilteredTestExtensions, + out var filteredTestExtensions); - return new DataCollectorExtensionManager(unfilteredTestExtensions, filteredTestExtensions, messageLogger); - } + return new DataCollectorExtensionManager(unfilteredTestExtensions, filteredTestExtensions, messageLogger); + } - /// - /// Gets an instance of the DataCollectorExtensionManager. - /// - /// - /// File path that contains data collectors to load. - /// - /// - /// Skip the extensions cache. - /// - /// - /// The message Logger. - /// - /// - /// The DataCollectorExtensionManager. - /// - public static DataCollectorExtensionManager Create(string extensionAssemblyFilePath, bool skipCache, IMessageLogger messageLogger) - { - TestPluginManager.Instance.GetTestExtensions( - extensionAssemblyFilePath, - out var unfilteredTestExtensions, - out var filteredTestExtensions, - skipCache); + /// + /// Gets an instance of the DataCollectorExtensionManager. + /// + /// + /// File path that contains data collectors to load. + /// + /// + /// Skip the extensions cache. + /// + /// + /// The message Logger. + /// + /// + /// The DataCollectorExtensionManager. + /// + public static DataCollectorExtensionManager Create(string extensionAssemblyFilePath, bool skipCache, IMessageLogger messageLogger) + { + TestPluginManager.Instance.GetTestExtensions( + extensionAssemblyFilePath, + out var unfilteredTestExtensions, + out var filteredTestExtensions, + skipCache); - return new DataCollectorExtensionManager(unfilteredTestExtensions, filteredTestExtensions, messageLogger); - } + return new DataCollectorExtensionManager(unfilteredTestExtensions, filteredTestExtensions, messageLogger); } +} +/// +/// Hold data about the Data Collector. +/// +public class DataCollectorMetadata : IDataCollectorCapabilities +{ /// - /// Hold data about the Data Collector. + /// Constructor for DataCollectorMetadata /// - public class DataCollectorMetadata : IDataCollectorCapabilities - { - /// - /// Constructor for DataCollectorMetadata - /// - /// - /// Uri identifying the data collector. - /// - /// - /// The friendly Name. - /// - public DataCollectorMetadata(string extension, string friendlyName) - : this(extension, friendlyName, false) - { } + /// + /// Uri identifying the data collector. + /// + /// + /// The friendly Name. + /// + public DataCollectorMetadata(string extension, string friendlyName) + : this(extension, friendlyName, false) + { } - /// - /// Constructor for DataCollectorMetadata - /// - /// - /// Uri identifying the data collector. - /// - /// - /// The friendly Name. - /// - /// Indicates if the current data collector registers an attachment processor - /// - public DataCollectorMetadata(string extension, string friendlyName, bool hasAttachmentProcessor) - { - this.ExtensionUri = extension; - this.FriendlyName = friendlyName; - this.HasAttachmentProcessor = hasAttachmentProcessor; - } + /// + /// Constructor for DataCollectorMetadata + /// + /// + /// Uri identifying the data collector. + /// + /// + /// The friendly Name. + /// + /// Indicates if the current data collector registers an attachment processor + /// + public DataCollectorMetadata(string extension, string friendlyName, bool hasAttachmentProcessor) + { + ExtensionUri = extension; + FriendlyName = friendlyName; + HasAttachmentProcessor = hasAttachmentProcessor; + } - /// - /// Gets Uri identifying the data collector. - /// - public string ExtensionUri - { - get; - private set; - } + /// + /// Gets Uri identifying the data collector. + /// + public string ExtensionUri + { + get; + private set; + } - /// - /// Gets Friendly Name identifying the data collector. - /// - public string FriendlyName - { - get; - private set; - } + /// + /// Gets Friendly Name identifying the data collector. + /// + public string FriendlyName + { + get; + private set; + } - /// - /// Check if the data collector has got attachment processor registered - /// - public bool HasAttachmentProcessor - { - get; - private set; - } + /// + /// Check if the data collector has got attachment processor registered + /// + public bool HasAttachmentProcessor + { + get; + private set; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestDiscoveryExtensionManager.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestDiscoveryExtensionManager.cs index db0ce646dd..94f8c0e9c4 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestDiscoveryExtensionManager.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestDiscoveryExtensionManager.cs @@ -1,211 +1,209 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework +namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; + +using System; +using System.Collections.Generic; + +using Utilities; +using Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using ObjectModel; +using ObjectModel.Adapter; + +/// +/// Responsible for managing the Test Discoverer extensions which are available. +/// +internal class TestDiscoveryExtensionManager { - using System; - using System.Collections.Generic; + #region Fields + + private static TestDiscoveryExtensionManager s_testDiscoveryExtensionManager; + + #endregion - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + #region Constructor /// - /// Responsible for managing the Test Discoverer extensions which are available. + /// Default constructor. /// - internal class TestDiscoveryExtensionManager + /// The factory should be used for getting instances of this type so the constructor is not public. + protected TestDiscoveryExtensionManager( + IEnumerable> discoverers, + IEnumerable>> unfilteredDiscoverers) { - #region Fields + ValidateArg.NotNull(discoverers, nameof(discoverers)); + ValidateArg.NotNull(unfilteredDiscoverers, nameof(unfilteredDiscoverers)); - private static TestDiscoveryExtensionManager testDiscoveryExtensionManager; - - #endregion - - #region Constructor + Discoverers = discoverers; + UnfilteredDiscoverers = unfilteredDiscoverers; + } - /// - /// Default constructor. - /// - /// The factory should be used for getting instances of this type so the constructor is not public. - protected TestDiscoveryExtensionManager( - IEnumerable> discoverers, - IEnumerable>> unfilteredDiscoverers) - { - ValidateArg.NotNull>>(discoverers, nameof(discoverers)); - ValidateArg.NotNull>>>(unfilteredDiscoverers, nameof(unfilteredDiscoverers)); + #endregion - this.Discoverers = discoverers; - this.UnfilteredDiscoverers = unfilteredDiscoverers; - } + #region Properties - #endregion - - #region Properties - - /// - /// Gets the unfiltered list of test discoverers which are available. - /// - /// - /// Used in the /ListDiscoverers command line argument processor to generically list out extensions. - /// - public IEnumerable>> UnfilteredDiscoverers { get; private set; } - - /// - /// Gets the discoverers which are available for discovering tests. - /// - public IEnumerable> Discoverers { get; private set; } - - #endregion - - #region Factory - - /// - /// Gets an instance of the Test Discovery Extension Manager. - /// - /// - /// Instance of the Test Discovery Extension Manager - /// - /// - /// This would provide a discovery extension manager where extensions in - /// all the extension assemblies are discovered. This is cached. - /// - public static TestDiscoveryExtensionManager Create() - { - if (testDiscoveryExtensionManager == null) - { + /// + /// Gets the unfiltered list of test discoverers which are available. + /// + /// + /// Used in the /ListDiscoverers command line argument processor to generically list out extensions. + /// + public IEnumerable>> UnfilteredDiscoverers { get; private set; } - TestPluginManager.Instance - .GetSpecificTestExtensions( - TestPlatformConstants.TestAdapterEndsWithPattern, - out var unfilteredTestExtensions, - out var testExtensions); + /// + /// Gets the discoverers which are available for discovering tests. + /// + public IEnumerable> Discoverers { get; private set; } - testDiscoveryExtensionManager = new TestDiscoveryExtensionManager( - testExtensions, - unfilteredTestExtensions); - } + #endregion - return testDiscoveryExtensionManager; - } + #region Factory - /// - /// Gets an instance of the Test Discovery Extension Manager for the extension. - /// - /// The extension assembly. - /// The instance. - /// - /// This would provide a discovery extension manager where extensions in - /// only the extension assembly provided are discovered. This is not cached - /// - public static TestDiscoveryExtensionManager GetDiscoveryExtensionManager(string extensionAssembly) + /// + /// Gets an instance of the Test Discovery Extension Manager. + /// + /// + /// Instance of the Test Discovery Extension Manager + /// + /// + /// This would provide a discovery extension manager where extensions in + /// all the extension assemblies are discovered. This is cached. + /// + public static TestDiscoveryExtensionManager Create() + { + if (s_testDiscoveryExtensionManager == null) { TestPluginManager.Instance - .GetTestExtensions( - extensionAssembly, + .GetSpecificTestExtensions( + TestPlatformConstants.TestAdapterEndsWithPattern, out var unfilteredTestExtensions, out var testExtensions); - return new TestDiscoveryExtensionManager( + s_testDiscoveryExtensionManager = new TestDiscoveryExtensionManager( testExtensions, unfilteredTestExtensions); } - /// - /// Loads and Initializes all the extensions. - /// - /// The throw On Error. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - internal static void LoadAndInitializeAllExtensions(bool throwOnError) - { - try - { - var allDiscoverers = Create(); - - // Iterate throw the discoverers so that they are initialized - foreach (var discoverer in allDiscoverers.Discoverers) - { - // discoverer.value below is what initializes the extension types and hence is not under a EqtTrace.IsVerboseEnabled check. - EqtTrace.Verbose("TestDiscoveryManager: LoadExtensions: Created discoverer {0}", discoverer.Value); - } - } - catch (Exception ex) - { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("TestDiscoveryManager: LoadExtensions: Exception occurred while loading extensions {0}", ex); - } - - if (throwOnError) - { - throw; - } - } - } + return s_testDiscoveryExtensionManager; + } - /// - /// Destroys the cache. - /// - internal static void Destroy() - { - testDiscoveryExtensionManager = null; - } + /// + /// Gets an instance of the Test Discovery Extension Manager for the extension. + /// + /// The extension assembly. + /// The instance. + /// + /// This would provide a discovery extension manager where extensions in + /// only the extension assembly provided are discovered. This is not cached + /// + public static TestDiscoveryExtensionManager GetDiscoveryExtensionManager(string extensionAssembly) + { - #endregion + TestPluginManager.Instance + .GetTestExtensions( + extensionAssembly, + out var unfilteredTestExtensions, + out var testExtensions); + + return new TestDiscoveryExtensionManager( + testExtensions, + unfilteredTestExtensions); } /// - /// Hold data about the Test discoverer. + /// Loads and Initializes all the extensions. /// - internal class TestDiscovererMetadata : ITestDiscovererCapabilities + /// The throw On Error. + internal static void LoadAndInitializeAllExtensions(bool throwOnError) { - /// - /// The default constructor. - /// - /// The file Extensions. - /// The default Executor Uri. - public TestDiscovererMetadata(IReadOnlyCollection fileExtensions, string defaultExecutorUri, AssemblyType assemblyType = default) + try + { + var allDiscoverers = Create(); + + // Iterate throw the discoverers so that they are initialized + foreach (var discoverer in allDiscoverers.Discoverers) + { + // discoverer.value below is what initializes the extension types and hence is not under a EqtTrace.IsVerboseEnabled check. + EqtTrace.Verbose("TestDiscoveryManager: LoadExtensions: Created discoverer {0}", discoverer.Value); + } + } + catch (Exception ex) { - if (fileExtensions != null && fileExtensions.Count > 0) + if (EqtTrace.IsErrorEnabled) { - this.FileExtension = new List(fileExtensions); + EqtTrace.Error("TestDiscoveryManager: LoadExtensions: Exception occurred while loading extensions {0}", ex); } - if (!string.IsNullOrWhiteSpace(defaultExecutorUri)) + if (throwOnError) { - this.DefaultExecutorUri = new Uri(defaultExecutorUri); + throw; } - - this.AssemblyType = assemblyType; } + } - /// - /// Gets file extensions supported by the discoverer. - /// - public IEnumerable FileExtension - { - get; - private set; - } + /// + /// Destroys the cache. + /// + internal static void Destroy() + { + s_testDiscoveryExtensionManager = null; + } + + #endregion +} - /// - /// Gets the default executor Uri for this discoverer - /// - public Uri DefaultExecutorUri +/// +/// Hold data about the Test discoverer. +/// +internal class TestDiscovererMetadata : ITestDiscovererCapabilities +{ + /// + /// The default constructor. + /// + /// The file Extensions. + /// The default Executor Uri. + public TestDiscovererMetadata(IReadOnlyCollection fileExtensions, string defaultExecutorUri, AssemblyType assemblyType = default) + { + if (fileExtensions != null && fileExtensions.Count > 0) { - get; - private set; + FileExtension = new List(fileExtensions); } - /// - /// Gets assembly type supported by the discoverer. - /// - public AssemblyType AssemblyType + if (!string.IsNullOrWhiteSpace(defaultExecutorUri)) { - get; - private set; + DefaultExecutorUri = new Uri(defaultExecutorUri); } + + AssemblyType = assemblyType; } -} + + /// + /// Gets file extensions supported by the discoverer. + /// + public IEnumerable FileExtension + { + get; + private set; + } + + /// + /// Gets the default executor Uri for this discoverer + /// + public Uri DefaultExecutorUri + { + get; + private set; + } + + /// + /// Gets assembly type supported by the discoverer. + /// + public AssemblyType AssemblyType + { + get; + private set; + } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestExecutorExtensionManager.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestExecutorExtensionManager.cs index b131657be8..013599263a 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestExecutorExtensionManager.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestExecutorExtensionManager.cs @@ -1,267 +1,265 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework +namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; + +using System; +using System.Collections.Generic; +using System.Linq; + +using Utilities; +using Interfaces; +using Logging; +using ObjectModel; +using ObjectModel.Adapter; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +/// +/// Manages the Test Executor extensions. +/// +internal class TestExecutorExtensionManager : TestExtensionManager { - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + #region Fields + + private static TestExecutorExtensionManager s_testExecutorExtensionManager; + private static readonly object Synclock = new(); + + #endregion + + #region Constructor /// - /// Manages the Test Executor extensions. + /// Default constructor. /// - internal class TestExecutorExtensionManager : TestExtensionManager + /// The unfiltered Test Extensions. + /// The test Extensions. + /// The logger. + /// + /// This constructor is not public because instances should be retrieved using the + /// factory method. The constructor is protected for testing purposes. + /// + protected TestExecutorExtensionManager( + IEnumerable>> unfilteredTestExtensions, + IEnumerable> testExtensions, + IMessageLogger logger) + : base(unfilteredTestExtensions, testExtensions, logger) { - #region Fields - - private static TestExecutorExtensionManager testExecutorExtensionManager; - private static object synclock = new object(); - - #endregion - - #region Constructor - - /// - /// Default constructor. - /// - /// The unfiltered Test Extensions. - /// The test Extensions. - /// The logger. - /// - /// This constructor is not public because instances should be retrieved using the - /// factory method. The constructor is protected for testing purposes. - /// - [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")] - protected TestExecutorExtensionManager( - IEnumerable>> unfilteredTestExtensions, - IEnumerable> testExtensions, - IMessageLogger logger) - : base(unfilteredTestExtensions, testExtensions, logger) - { - } + } - #endregion - - #region Private Methods - /// - /// Merges two test extension lists. - /// - /// - /// Type of first test extension. - /// Type of second test extension. - /// Type of the value used in the lazy extension expression. - /// - /// First test extension list. - /// Second test extension list. - /// - /// A merged list of test extensions. - private static IEnumerable> MergeTestExtensionLists( - IEnumerable> testExtensions1, - IEnumerable> testExtensions2) where TExecutor1 : ITestExecutor where TExecutor2 : TExecutor1 - { - if (!testExtensions2.Any()) - { - return testExtensions1; - } + #endregion - var mergedTestExtensions = new List>(); - var cache = new Dictionary>(); + #region Private Methods + /// + /// Merges two test extension lists. + /// + /// + /// Type of first test extension. + /// Type of second test extension. + /// Type of the value used in the lazy extension expression. + /// + /// First test extension list. + /// Second test extension list. + /// + /// A merged list of test extensions. + private static IEnumerable> MergeTestExtensionLists( + IEnumerable> testExtensions1, + IEnumerable> testExtensions2) where TExecutor1 : ITestExecutor where TExecutor2 : TExecutor1 + { + if (!testExtensions2.Any()) + { + return testExtensions1; + } - // Create the cache used for merging by adding all extensions from the first list. - foreach (var testExtension in testExtensions1) - { - cache.Add(testExtension.TestPluginInfo.IdentifierData, testExtension); - } + var mergedTestExtensions = new List>(); + var cache = new Dictionary>(); - // Update the cache with extensions from the second list. Should there be any conflict - // we prefer the second extension to the first. - foreach (var testExtension in testExtensions2) - { - if (cache.ContainsKey(testExtension.TestPluginInfo.IdentifierData)) - { - cache[testExtension.TestPluginInfo.IdentifierData] = - new LazyExtension( - (TExecutor1)testExtension.Value, testExtension.Metadata); - } - } + // Create the cache used for merging by adding all extensions from the first list. + foreach (var testExtension in testExtensions1) + { + cache.Add(testExtension.TestPluginInfo.IdentifierData, testExtension); + } - // Create the merged test extensions list from the cache. - foreach (var kvp in cache) + // Update the cache with extensions from the second list. Should there be any conflict + // we prefer the second extension to the first. + foreach (var testExtension in testExtensions2) + { + if (cache.ContainsKey(testExtension.TestPluginInfo.IdentifierData)) { - mergedTestExtensions.Add(kvp.Value); + cache[testExtension.TestPluginInfo.IdentifierData] = + new LazyExtension( + (TExecutor1)testExtension.Value, testExtension.Metadata); } + } - return mergedTestExtensions; + // Create the merged test extensions list from the cache. + foreach (var kvp in cache) + { + mergedTestExtensions.Add(kvp.Value); } - #endregion + return mergedTestExtensions; + } + + #endregion - #region Factory Methods + #region Factory Methods - /// - /// Creates the TestExecutorExtensionManager. - /// - /// Instance of the TestExecutorExtensionManager - internal static TestExecutorExtensionManager Create() + /// + /// Creates the TestExecutorExtensionManager. + /// + /// Instance of the TestExecutorExtensionManager + internal static TestExecutorExtensionManager Create() + { + if (s_testExecutorExtensionManager == null) { - if (testExecutorExtensionManager == null) + lock (Synclock) { - lock (synclock) + if (s_testExecutorExtensionManager == null) { - if (testExecutorExtensionManager == null) - { - - // Get all extensions for ITestExecutor. - TestPluginManager.Instance - .GetSpecificTestExtensions( - TestPlatformConstants.TestAdapterEndsWithPattern, - out var unfilteredTestExtensions1, - out var testExtensions1); - - // Get all extensions for ITestExecutor2. - TestPluginManager.Instance - .GetSpecificTestExtensions( - TestPlatformConstants.TestAdapterEndsWithPattern, - out var unfilteredTestExtensions2, - out var testExtensions2); - - // Merge the extension lists. - var mergedUnfilteredTestExtensions = TestExecutorExtensionManager.MergeTestExtensionLists( - unfilteredTestExtensions1, - unfilteredTestExtensions2); - - var mergedTestExtensions = TestExecutorExtensionManager.MergeTestExtensionLists( - testExtensions1, - testExtensions2); - - // Create the TestExecutorExtensionManager using the merged extension list. - testExecutorExtensionManager = new TestExecutorExtensionManager( - mergedUnfilteredTestExtensions, mergedTestExtensions, TestSessionMessageLogger.Instance); - } + + // Get all extensions for ITestExecutor. + TestPluginManager.Instance + .GetSpecificTestExtensions( + TestPlatformConstants.TestAdapterEndsWithPattern, + out var unfilteredTestExtensions1, + out var testExtensions1); + + // Get all extensions for ITestExecutor2. + TestPluginManager.Instance + .GetSpecificTestExtensions( + TestPlatformConstants.TestAdapterEndsWithPattern, + out var unfilteredTestExtensions2, + out var testExtensions2); + + // Merge the extension lists. + var mergedUnfilteredTestExtensions = MergeTestExtensionLists( + unfilteredTestExtensions1, + unfilteredTestExtensions2); + + var mergedTestExtensions = MergeTestExtensionLists( + testExtensions1, + testExtensions2); + + // Create the TestExecutorExtensionManager using the merged extension list. + s_testExecutorExtensionManager = new TestExecutorExtensionManager( + mergedUnfilteredTestExtensions, mergedTestExtensions, TestSessionMessageLogger.Instance); } } - - return testExecutorExtensionManager; } - /// - /// Gets an instance of the Test Execution Extension Manager for the extension. - /// - /// The extension assembly. - /// The . - /// - /// This would provide an execution extension manager where extensions in - /// only the extension assembly provided are discovered. This is not cached. - /// - internal static TestExecutorExtensionManager GetExecutionExtensionManager(string extensionAssembly) - { + return s_testExecutorExtensionManager; + } + + /// + /// Gets an instance of the Test Execution Extension Manager for the extension. + /// + /// The extension assembly. + /// The . + /// + /// This would provide an execution extension manager where extensions in + /// only the extension assembly provided are discovered. This is not cached. + /// + internal static TestExecutorExtensionManager GetExecutionExtensionManager(string extensionAssembly) + { - // Get all extensions for ITestExecutor. - TestPluginManager.Instance - .GetTestExtensions( - extensionAssembly, - out var unfilteredTestExtensions1, - out var testExtensions1); - - // Get all extensions for ITestExecutor2. - TestPluginManager.Instance - .GetTestExtensions( - extensionAssembly, - out var unfilteredTestExtensions2, - out var testExtensions2); - - // Merge the extension lists. - var mergedUnfilteredTestExtensions = TestExecutorExtensionManager.MergeTestExtensionLists( - unfilteredTestExtensions1, - unfilteredTestExtensions2); - - var mergedTestExtensions = TestExecutorExtensionManager.MergeTestExtensionLists( - testExtensions1, - testExtensions2); - - // TODO: This can be optimized - The base class's populate map would be called repeatedly for the same extension assembly. - // Have a single instance of TestExecutorExtensionManager that keeps populating the map iteratively. - return new TestExecutorExtensionManager( - mergedUnfilteredTestExtensions, - mergedTestExtensions, - TestSessionMessageLogger.Instance); + // Get all extensions for ITestExecutor. + TestPluginManager.Instance + .GetTestExtensions( + extensionAssembly, + out var unfilteredTestExtensions1, + out var testExtensions1); + + // Get all extensions for ITestExecutor2. + TestPluginManager.Instance + .GetTestExtensions( + extensionAssembly, + out var unfilteredTestExtensions2, + out var testExtensions2); + + // Merge the extension lists. + var mergedUnfilteredTestExtensions = MergeTestExtensionLists( + unfilteredTestExtensions1, + unfilteredTestExtensions2); + + var mergedTestExtensions = MergeTestExtensionLists( + testExtensions1, + testExtensions2); + + // TODO: This can be optimized - The base class's populate map would be called repeatedly for the same extension assembly. + // Have a single instance of TestExecutorExtensionManager that keeps populating the map iteratively. + return new TestExecutorExtensionManager( + mergedUnfilteredTestExtensions, + mergedTestExtensions, + TestSessionMessageLogger.Instance); + } + + /// + /// Destroy the TestExecutorExtensionManager. + /// + internal static void Destroy() + { + lock (Synclock) + { + s_testExecutorExtensionManager = null; } + } - /// - /// Destroy the TestExecutorExtensionManager. - /// - internal static void Destroy() + /// + /// Load all the executors and fail on error + /// + /// Indicates whether this method should throw on error. + internal static void LoadAndInitializeAllExtensions(bool shouldThrowOnError) + { + var executorExtensionManager = Create(); + + try { - lock (synclock) + foreach (var executor in executorExtensionManager.TestExtensions) { - testExecutorExtensionManager = null; + // Note: - The below Verbose call should not be under IsVerboseEnabled check as we want to + // call executor.Value even if logging is not enabled. + EqtTrace.Verbose("TestExecutorExtensionManager: Loading executor {0}", executor.Value); } } - - /// - /// Load all the executors and fail on error - /// - /// Indicates whether this method should throw on error. - internal static void LoadAndInitializeAllExtensions(bool shouldThrowOnError) + catch (Exception ex) { - var executorExtensionManager = Create(); - - try + if (EqtTrace.IsErrorEnabled) { - foreach (var executor in executorExtensionManager.TestExtensions) - { - // Note: - The below Verbose call should not be under IsVerboseEnabled check as we want to - // call executor.Value even if logging is not enabled. - EqtTrace.Verbose("TestExecutorExtensionManager: Loading executor {0}", executor.Value); - } + EqtTrace.Error( + "TestExecutorExtensionManager: LoadAndInitialize: Exception occurred while loading extensions {0}", + ex); } - catch (Exception ex) - { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error( - "TestExecutorExtensionManager: LoadAndInitialize: Exception occurred while loading extensions {0}", - ex); - } - if (shouldThrowOnError) - { - throw; - } + if (shouldThrowOnError) + { + throw; } } - - #endregion } + #endregion +} + +/// +/// Holds data about the Test executor. +/// +internal class TestExecutorMetadata : ITestExecutorCapabilities +{ /// - /// Holds data about the Test executor. + /// The constructor /// - internal class TestExecutorMetadata : ITestExecutorCapabilities + /// Uri identifying the executor + public TestExecutorMetadata(string extensionUri) { - /// - /// The constructor - /// - /// Uri identifying the executor - public TestExecutorMetadata(string extensionUri) - { - this.ExtensionUri = extensionUri; - } + ExtensionUri = extensionUri; + } - /// - /// Gets Uri identifying the executor. - /// - public string ExtensionUri - { - get; - private set; - } + /// + /// Gets Uri identifying the executor. + /// + public string ExtensionUri + { + get; + private set; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestExtensionManager.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestExtensionManager.cs index 7bf7bb2d74..6d7a1bca38 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestExtensionManager.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestExtensionManager.cs @@ -1,198 +1,197 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework +namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; + +using Utilities; +using Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +using System; +using System.Collections.Generic; +using System.Globalization; + +using CommonResources = Resources.Resources; + +/// +/// Generic base class for managing extensions and looking them up by their URI. +/// +/// The type of the extension. +/// The type of the metadata. +internal abstract class TestExtensionManager + where TMetadata : ITestExtensionCapabilities { - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Globalization; - using CommonResources = Microsoft.VisualStudio.TestPlatform.Common.Resources.Resources; + #region Fields /// - /// Generic base class for managing extensions and looking them up by their URI. + /// Used for logging errors. /// - /// The type of the extension. - /// The type of the metadata. - internal abstract class TestExtensionManager - where TMetadata : ITestExtensionCapabilities + private readonly IMessageLogger _logger; + + #endregion + + #region Constructor + + /// + /// Default constructor. + /// + /// + /// The unfiltered Test Extensions. + /// + /// + /// The test Extensions. + /// + /// + /// The logger. + /// + protected TestExtensionManager( + IEnumerable>> unfilteredTestExtensions, + IEnumerable> testExtensions, + IMessageLogger logger) { - #region Fields - - /// - /// Used for logging errors. - /// - private IMessageLogger logger; - - #endregion - - #region Constructor - - /// - /// Default constructor. - /// - /// - /// The unfiltered Test Extensions. - /// - /// - /// The test Extensions. - /// - /// - /// The logger. - /// - protected TestExtensionManager( - IEnumerable>> unfilteredTestExtensions, - IEnumerable> testExtensions, - IMessageLogger logger) - { - ValidateArg.NotNull>>>(unfilteredTestExtensions, nameof(unfilteredTestExtensions)); - ValidateArg.NotNull>>(testExtensions, nameof(testExtensions)); - ValidateArg.NotNull(logger, nameof(logger)); + ValidateArg.NotNull(unfilteredTestExtensions, nameof(unfilteredTestExtensions)); + ValidateArg.NotNull(testExtensions, nameof(testExtensions)); + ValidateArg.NotNull(logger, nameof(logger)); - this.logger = logger; - this.TestExtensions = testExtensions; - this.UnfilteredTestExtensions = unfilteredTestExtensions; + _logger = logger; + TestExtensions = testExtensions; + UnfilteredTestExtensions = unfilteredTestExtensions; - // Populate the map to avoid threading issues - this.PopulateMap(); - } + // Populate the map to avoid threading issues + PopulateMap(); + } - #endregion + #endregion - #region Properties + #region Properties - /// - /// Gets unfiltered list of test extensions which are available. - /// - /// - /// When we populate the "TestExtensions" property it - /// will filter out extensions which are missing required pieces of metadata such - /// as the "ExtensionUri". This field is here so we can report on extensions which - /// are missing metadata. - /// - public IEnumerable>> UnfilteredTestExtensions - { - get; private set; - } + /// + /// Gets unfiltered list of test extensions which are available. + /// + /// + /// When we populate the "TestExtensions" property it + /// will filter out extensions which are missing required pieces of metadata such + /// as the "ExtensionUri". This field is here so we can report on extensions which + /// are missing metadata. + /// + public IEnumerable>> UnfilteredTestExtensions + { + get; private set; + } - /// - /// Gets filtered list of test extensions which are available. - /// - /// - /// When we populate the "TestExtensions" property it - /// will filter out extensions which are missing required pieces of metadata such - /// as the "ExtensionUri". This field is here so we can report on extensions which - /// are missing metadata. - /// - public IEnumerable> TestExtensions - { - get; - private set; - } + /// + /// Gets filtered list of test extensions which are available. + /// + /// + /// When we populate the "TestExtensions" property it + /// will filter out extensions which are missing required pieces of metadata such + /// as the "ExtensionUri". This field is here so we can report on extensions which + /// are missing metadata. + /// + public IEnumerable> TestExtensions + { + get; + private set; + } - /// - /// Gets mapping between test extension URI and test extension. - /// - public Dictionary> TestExtensionByUri - { - get; - private set; - } + /// + /// Gets mapping between test extension URI and test extension. + /// + public Dictionary> TestExtensionByUri + { + get; + private set; + } - #endregion + #endregion - #region Public Methods + #region Public Methods - /// - /// Looks up the test extension by its URI. - /// - /// The URI of the test extension to be looked up. - /// The test extension or null if one was not found. - public LazyExtension TryGetTestExtension(Uri extensionUri) - { - ValidateArg.NotNull(extensionUri, nameof(extensionUri)); + /// + /// Looks up the test extension by its URI. + /// + /// The URI of the test extension to be looked up. + /// The test extension or null if one was not found. + public LazyExtension TryGetTestExtension(Uri extensionUri) + { + ValidateArg.NotNull(extensionUri, nameof(extensionUri)); - this.TestExtensionByUri.TryGetValue(extensionUri, out var testExtension); + TestExtensionByUri.TryGetValue(extensionUri, out var testExtension); - return testExtension; - } + return testExtension; + } - /// - /// Looks up the test extension by its URI (passed as a string). - /// - /// The URI of the test extension to be looked up. - /// The test extension or null if one was not found. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1057:StringUriOverloadsCallSystemUriOverloads", Justification = "Case insensitiveness needs to be supported.")] - public LazyExtension TryGetTestExtension(string extensionUri) - { - ValidateArg.NotNull(extensionUri, nameof(extensionUri)); + /// + /// Looks up the test extension by its URI (passed as a string). + /// + /// The URI of the test extension to be looked up. + /// The test extension or null if one was not found. + public LazyExtension TryGetTestExtension(string extensionUri) + { + ValidateArg.NotNull(extensionUri, nameof(extensionUri)); - LazyExtension testExtension = null; - foreach (var availableExtensionUri in this.TestExtensionByUri.Keys) + LazyExtension testExtension = null; + foreach (var availableExtensionUri in TestExtensionByUri.Keys) + { + if (string.Equals(extensionUri, availableExtensionUri.AbsoluteUri, StringComparison.OrdinalIgnoreCase)) { - if (string.Equals(extensionUri, availableExtensionUri.AbsoluteUri, StringComparison.OrdinalIgnoreCase)) - { - this.TestExtensionByUri.TryGetValue(availableExtensionUri, out testExtension); - break; - } + TestExtensionByUri.TryGetValue(availableExtensionUri, out testExtension); + break; } - return testExtension; } + return testExtension; + } - #endregion + #endregion + + /// + /// Populate the extension map. + /// + private void PopulateMap() + { + TestExtensionByUri = new Dictionary>(); - /// - /// Populate the extension map. - /// - private void PopulateMap() + if (TestExtensions == null) { - this.TestExtensionByUri = new Dictionary>(); + return; + } - if (this.TestExtensions == null) + foreach (var extension in TestExtensions) + { + // Convert the extension uri string to an actual uri. + Uri uri = null; + try { - return; + uri = new Uri(extension.Metadata.ExtensionUri); } - - foreach (var extension in this.TestExtensions) + catch (FormatException e) { - // Convert the extension uri string to an actual uri. - Uri uri = null; - try + if (_logger != null) { - uri = new Uri(extension.Metadata.ExtensionUri); + _logger.SendMessage( + TestMessageLevel.Warning, + string.Format(CultureInfo.CurrentUICulture, CommonResources.InvalidExtensionUriFormat, extension.Metadata.ExtensionUri, e)); } - catch (FormatException e) + } + + if (uri != null) + { + // Make sure we are not trying to add an extension with a duplicate uri. + if (!TestExtensionByUri.ContainsKey(uri)) { - if (this.logger != null) - { - this.logger.SendMessage( - TestMessageLevel.Warning, - string.Format(CultureInfo.CurrentUICulture, CommonResources.InvalidExtensionUriFormat, extension.Metadata.ExtensionUri, e)); - } + TestExtensionByUri.Add(uri, extension); } - - if (uri != null) + else { - // Make sure we are not trying to add an extension with a duplicate uri. - if (!this.TestExtensionByUri.ContainsKey(uri)) + if (_logger != null) { - this.TestExtensionByUri.Add(uri, extension); - } - else - { - if (this.logger != null) - { - this.logger.SendMessage( - TestMessageLevel.Warning, - string.Format(CultureInfo.CurrentUICulture, CommonResources.DuplicateExtensionUri, extension.Metadata.ExtensionUri)); - } + _logger.SendMessage( + TestMessageLevel.Warning, + string.Format(CultureInfo.CurrentUICulture, CommonResources.DuplicateExtensionUri, extension.Metadata.ExtensionUri)); } } } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestLoggerExtensionManager.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestLoggerExtensionManager.cs index 56a4227332..32353ef004 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestLoggerExtensionManager.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestLoggerExtensionManager.cs @@ -1,102 +1,100 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework -{ - using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; + +using System.Collections.Generic; + +using Utilities; +using Interfaces; +using ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +/// +/// Manages loading and provides access to logging extensions implementing the +/// ITestLogger interface. +/// +internal class TestLoggerExtensionManager : TestExtensionManager +{ /// - /// Manages loading and provides access to logging extensions implementing the - /// ITestLogger interface. + /// Initializes a new instance of the class. /// - internal class TestLoggerExtensionManager : TestExtensionManager + /// + /// The unfiltered Test Extensions. + /// + /// + /// The test Extensions. + /// + /// + /// The logger. + /// + /// + /// The constructor is not public because the factory method should be used to get instances of this class. + /// + protected TestLoggerExtensionManager( + IEnumerable>> unfilteredTestExtensions, + IEnumerable> testExtensions, + IMessageLogger logger) + : base(unfilteredTestExtensions, testExtensions, logger) { - /// - /// Initializes a new instance of the class. - /// - /// - /// The unfiltered Test Extensions. - /// - /// - /// The test Extensions. - /// - /// - /// The logger. - /// - /// - /// The constructor is not public because the factory method should be used to get instances of this class. - /// - protected TestLoggerExtensionManager( - IEnumerable>> unfilteredTestExtensions, - IEnumerable> testExtensions, - IMessageLogger logger) - : base(unfilteredTestExtensions, testExtensions, logger) - { - } + } - /// - /// Gets an instance of the TestLoggerExtensionManager. - /// - /// - /// The message Logger. - /// - /// - /// The TestLoggerExtensionManager. - /// - public static TestLoggerExtensionManager Create(IMessageLogger messageLogger) - { - IEnumerable> filteredTestExtensions; - IEnumerable>> unfilteredTestExtensions; + /// + /// Gets an instance of the TestLoggerExtensionManager. + /// + /// + /// The message Logger. + /// + /// + /// The TestLoggerExtensionManager. + /// + public static TestLoggerExtensionManager Create(IMessageLogger messageLogger) + { - TestPluginManager.Instance.GetSpecificTestExtensions( - TestPlatformConstants.TestLoggerEndsWithPattern, - out unfilteredTestExtensions, - out filteredTestExtensions); + TestPluginManager.Instance.GetSpecificTestExtensions( + TestPlatformConstants.TestLoggerEndsWithPattern, + out IEnumerable>> unfilteredTestExtensions, + out IEnumerable> filteredTestExtensions); - return new TestLoggerExtensionManager(unfilteredTestExtensions, filteredTestExtensions, messageLogger); - } + return new TestLoggerExtensionManager(unfilteredTestExtensions, filteredTestExtensions, messageLogger); } +} +/// +/// Hold data about the Test logger. +/// +public class TestLoggerMetadata : ITestLoggerCapabilities +{ /// - /// Hold data about the Test logger. + /// Constructor for TestLoggerMetadata /// - public class TestLoggerMetadata : ITestLoggerCapabilities + /// + /// Uri identifying the logger. + /// + /// + /// The friendly Name. + /// + public TestLoggerMetadata(string extension, string friendlyName) { - /// - /// Constructor for TestLoggerMetadata - /// - /// - /// Uri identifying the logger. - /// - /// - /// The friendly Name. - /// - public TestLoggerMetadata(string extension, string friendlyName) - { - this.ExtensionUri = extension; - this.FriendlyName = friendlyName; - } + ExtensionUri = extension; + FriendlyName = friendlyName; + } - /// - /// Gets Uri identifying the logger. - /// - public string ExtensionUri - { - get; - private set; - } + /// + /// Gets Uri identifying the logger. + /// + public string ExtensionUri + { + get; + private set; + } - /// - /// Gets Friendly Name identifying the logger. - /// - public string FriendlyName - { - get; - private set; - } + /// + /// Gets Friendly Name identifying the logger. + /// + public string FriendlyName + { + get; + private set; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginCache.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginCache.cs index eaec74411c..a7bbbae7c2 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginCache.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginCache.cs @@ -1,600 +1,587 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework -{ +namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; + #if NETFRAMEWORK - using System.Threading; +using System.Threading; #endif - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Reflection; - - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; + +using Utilities; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using ObjectModel; +using PlatformAbstractions; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; + +/// +/// The test plugin cache. +/// +/// Making this a singleton to offer better unit testing. +public class TestPluginCache +{ + #region Private Members + + private readonly Dictionary _resolvedAssemblies; + + private List _filterableExtensionPaths; + private List _unfilterableExtensionPaths; /// - /// The test plugin cache. + /// Assembly resolver used to resolve the additional extensions /// - /// Making this a singleton to offer better unit testing. - public class TestPluginCache - { - #region Private Members + private AssemblyResolver _assemblyResolver; - private readonly Dictionary resolvedAssemblies; + /// + /// Lock for extensions update + /// + private readonly object _lockForExtensionsUpdate; - private List filterableExtensionPaths; - private List unfilterableExtensionPaths; + private static TestPluginCache s_instance; - /// - /// Assembly resolver used to resolve the additional extensions - /// - private AssemblyResolver assemblyResolver; + private readonly List _defaultExtensionPaths = new(); - /// - /// Lock for extensions update - /// - private object lockForExtensionsUpdate; + #endregion - private static TestPluginCache instance; + #region Constructor - private List defaultExtensionPaths = new List(); + /// + /// Initializes a new instance of the class. + /// + protected TestPluginCache() + { + _resolvedAssemblies = new Dictionary(); + _filterableExtensionPaths = new List(); + _unfilterableExtensionPaths = new List(); + _lockForExtensionsUpdate = new object(); + TestExtensions = null; + } - #endregion + #endregion - #region Constructor + #region Public Properties - /// - /// Initializes a new instance of the class. - /// - protected TestPluginCache() + public static TestPluginCache Instance + { + get { - this.resolvedAssemblies = new Dictionary(); - this.filterableExtensionPaths = new List(); - this.unfilterableExtensionPaths = new List(); - this.lockForExtensionsUpdate = new object(); - this.TestExtensions = null; + return s_instance ??= new TestPluginCache(); } - #endregion + internal set + { + s_instance = value; + } + } + + /// + /// Gets the test extensions discovered by the cache until now. + /// + /// Returns null if discovery of extensions is not done. + internal TestExtensions TestExtensions { get; private set; } - #region Public Properties + #endregion + + #region Public Methods + + /// + /// Gets a list of all extension paths filtered by input string. + /// + /// Pattern to filter extension paths. + public List GetExtensionPaths(string endsWithPattern, bool skipDefaultExtensions = false) + { + var extensions = GetFilteredExtensions(_filterableExtensionPaths, endsWithPattern); - public static TestPluginCache Instance + if (EqtTrace.IsVerboseEnabled) { - get - { - return instance ?? (instance = new TestPluginCache()); - } + EqtTrace.Verbose( + "TestPluginCache.GetExtensionPaths: Filtered extension paths: {0}", string.Join(Environment.NewLine, extensions)); + } - internal set + if (!skipDefaultExtensions) + { + extensions = extensions.Concat(_defaultExtensionPaths); + if (EqtTrace.IsVerboseEnabled) { - instance = value; + EqtTrace.Verbose( + "TestPluginCache.GetExtensionPaths: Added default extension paths: {0}", string.Join(Environment.NewLine, _defaultExtensionPaths)); } } - /// - /// Gets the test extensions discovered by the cache until now. - /// - /// Returns null if discovery of extensions is not done. - internal TestExtensions TestExtensions { get; private set; } + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose( + "TestPluginCache.GetExtensionPaths: Added unfilterableExtensionPaths: {0}", string.Join(Environment.NewLine, _unfilterableExtensionPaths)); + } - #endregion + return extensions.Concat(_unfilterableExtensionPaths).ToList(); + } - #region Public Methods + /// + /// Performs discovery of specific type of test extensions in files ending with the specified pattern. + /// + /// + /// Type of Plugin info. + /// + /// + /// Type of extension. + /// + /// + /// Pattern used to select files using String.EndsWith + /// + /// + /// The . of test plugin info. + /// + public Dictionary DiscoverTestExtensions(string endsWithPattern) + where TPluginInfo : TestPluginInformation + { + EqtTrace.Verbose("TestPluginCache.DiscoverTestExtensions: finding test extensions in assemblies ends with: {0} TPluginInfo: {1} TExtension: {2}", endsWithPattern, typeof(TPluginInfo), typeof(TExtension)); + // Return the cached value if cache is valid. + if (TestExtensions != null && TestExtensions.AreTestExtensionsCached()) + { + return TestExtensions.GetTestExtensionCache(); + } + + Dictionary pluginInfos = null; + SetupAssemblyResolver(null); - /// - /// Gets a list of all extension paths filtered by input string. - /// - /// Pattern to filter extension paths. - public List GetExtensionPaths(string endsWithPattern, bool skipDefaultExtensions = false) + // Some times TestPlatform.core.dll assembly fails to load in the current appdomain (from devenv.exe). + // Reason for failures are not known. Below handler, again calls assembly.load() in failing assembly + // and that succeeds. + // Because of this assembly failure, below domain.CreateInstanceAndUnwrap() call fails with error + // "Unable to cast transparent proxy to type 'Microsoft.VisualStudio.TestPlatform.Core.TestPluginsFramework.TestPluginDiscoverer" + var platformAssemblyResolver = new PlatformAssemblyResolver(); + platformAssemblyResolver.AssemblyResolve += CurrentDomainAssemblyResolve; + + try { - var extensions = this.GetFilteredExtensions(this.filterableExtensionPaths, endsWithPattern); + EqtTrace.Verbose("TestPluginCache.DiscoverTestExtensions: Discovering the extensions using extension path."); + + // Combine all the possible extensions - both default and additional. + var allExtensionPaths = GetExtensionPaths(endsWithPattern); if (EqtTrace.IsVerboseEnabled) { EqtTrace.Verbose( - "TestPluginCache.GetExtensionPaths: Filtered extension paths: {0}", string.Join(Environment.NewLine, extensions)); + "TestPluginCache.DiscoverTestExtensions: Discovering the extensions using allExtensionPaths: {0}", string.Join(Environment.NewLine, allExtensionPaths)); } - if (!skipDefaultExtensions) + // Discover the test extensions from candidate assemblies. + pluginInfos = GetTestExtensions(allExtensionPaths); + + if (TestExtensions == null) { - extensions = extensions.Concat(this.defaultExtensionPaths); - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose( - "TestPluginCache.GetExtensionPaths: Added default extension paths: {0}", string.Join(Environment.NewLine, this.defaultExtensionPaths)); - } + TestExtensions = new TestExtensions(); } + TestExtensions.AddExtension(pluginInfos); + + // Set the cache bool to true. + TestExtensions.SetTestExtensionsCacheStatusToTrue(); + if (EqtTrace.IsVerboseEnabled) { + var extensionString = _filterableExtensionPaths != null + ? string.Join(",", _filterableExtensionPaths.ToArray()) + : null; EqtTrace.Verbose( - "TestPluginCache.GetExtensionPaths: Added unfilterableExtensionPaths: {0}", string.Join(Environment.NewLine, this.unfilterableExtensionPaths)); + "TestPluginCache: Discovered the extensions using extension path '{0}'.", + extensionString); } - return extensions.Concat(this.unfilterableExtensionPaths).ToList(); + LogExtensions(); } - - /// - /// Performs discovery of specific type of test extensions in files ending with the specified pattern. - /// - /// - /// Type of Plugin info. - /// - /// - /// Type of extension. - /// - /// - /// Pattern used to select files using String.EndsWith - /// - /// - /// The . of test plugin info. - /// - public Dictionary DiscoverTestExtensions(string endsWithPattern) - where TPluginInfo : TestPluginInformation +#if NETFRAMEWORK + catch (ThreadAbortException) { - EqtTrace.Verbose("TestPluginCache.DiscoverTestExtensions: finding test extensions in assemblies ends with: {0} TPluginInfo: {1} TExtension: {2}", endsWithPattern, typeof(TPluginInfo), typeof(TExtension)); - // Return the cached value if cache is valid. - if (this.TestExtensions != null && this.TestExtensions.AreTestExtensionsCached()) + // Nothing to do here, we just do not want to do an EqtTrace.Fail for this thread + // being aborted as it is a legitimate exception to receive. + if (EqtTrace.IsVerboseEnabled) { - return this.TestExtensions.GetTestExtensionCache(); + EqtTrace.Verbose("TestPluginCache.DiscoverTestExtensions: Data extension discovery is being aborted due to a thread abort."); } - - Dictionary pluginInfos = null; - this.SetupAssemblyResolver(null); - - // Some times TestPlatform.core.dll assembly fails to load in the current appdomain (from devenv.exe). - // Reason for failures are not known. Below handler, again calls assembly.load() in failing assembly - // and that succeeds. - // Because of this assembly failure, below domain.CreateInstanceAndUnwrap() call fails with error - // "Unable to cast transparent proxy to type 'Microsoft.VisualStudio.TestPlatform.Core.TestPluginsFramework.TestPluginDiscoverer" - var platformAssemblyResolver = new PlatformAssemblyResolver(); - platformAssemblyResolver.AssemblyResolve += this.CurrentDomainAssemblyResolve; - - try + } +#endif + catch (Exception e) + { + EqtTrace.Error("TestPluginCache: Discovery failed! {0}", e); + throw; + } + finally + { + if (platformAssemblyResolver != null) { - EqtTrace.Verbose("TestPluginCache.DiscoverTestExtensions: Discovering the extensions using extension path."); - - // Combine all the possible extensions - both default and additional. - var allExtensionPaths = this.GetExtensionPaths(endsWithPattern); - - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose( - "TestPluginCache.DiscoverTestExtensions: Discovering the extensions using allExtensionPaths: {0}", string.Join(Environment.NewLine, allExtensionPaths)); - } + platformAssemblyResolver.AssemblyResolve -= CurrentDomainAssemblyResolve; + platformAssemblyResolver.Dispose(); + } - // Discover the test extensions from candidate assemblies. - pluginInfos = this.GetTestExtensions(allExtensionPaths); + // clear the assemblies + lock (_resolvedAssemblies) + { + _resolvedAssemblies?.Clear(); + } + } - if (this.TestExtensions == null) - { - this.TestExtensions = new TestExtensions(); - } + return pluginInfos; + } - this.TestExtensions.AddExtension(pluginInfos); + /// + /// Use the parameter path to extensions + /// + /// List of extension paths + /// Skip extension name filtering (if true) + public void UpdateExtensions(IEnumerable additionalExtensionsPath, bool skipExtensionFilters) + { + lock (_lockForExtensionsUpdate) + { + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("TestPluginCache: Update extensions started. Skip filter = " + skipExtensionFilters); + } - // Set the cache bool to true. - this.TestExtensions.SetTestExtensionsCacheStatusToTrue(); + var extensions = additionalExtensionsPath?.ToList(); + if (extensions == null || extensions.Count == 0) + { + return; + } - if (EqtTrace.IsVerboseEnabled) + if (skipExtensionFilters) + { + // Add the extensions to un-filter list. These extensions will never be filtered + // based on file name (e.g. *.testadapter.dll etc.). + if (TryMergeExtensionPaths(_unfilterableExtensionPaths, extensions, + out _unfilterableExtensionPaths)) { - var extensionString = this.filterableExtensionPaths != null - ? string.Join(",", this.filterableExtensionPaths.ToArray()) - : null; - EqtTrace.Verbose( - "TestPluginCache: Discovered the extensions using extension path '{0}'.", - extensionString); + // Set the extensions discovered to false so that the next time anyone tries + // to get the additional extensions, we rediscover. + TestExtensions?.InvalidateCache(); } - - this.LogExtensions(); } -#if NETFRAMEWORK - catch (ThreadAbortException) + else { - // Nothing to do here, we just do not want to do an EqtTrace.Fail for this thread - // being aborted as it is a legitimate exception to receive. - if (EqtTrace.IsVerboseEnabled) + if (TryMergeExtensionPaths(_filterableExtensionPaths, extensions, + out _filterableExtensionPaths)) { - EqtTrace.Verbose("TestPluginCache.DiscoverTestExtensions: Data extension discovery is being aborted due to a thread abort."); + TestExtensions?.InvalidateCache(); } } -#endif - catch (Exception e) - { - EqtTrace.Error("TestPluginCache: Discovery failed! {0}", e); - throw; - } - finally + + if (EqtTrace.IsVerboseEnabled) { - if (platformAssemblyResolver != null) - { - platformAssemblyResolver.AssemblyResolve -= this.CurrentDomainAssemblyResolve; - platformAssemblyResolver.Dispose(); - } + var directories = _filterableExtensionPaths.Concat(_unfilterableExtensionPaths).Select(e => Path.GetDirectoryName(Path.GetFullPath(e))).Distinct(); + var directoryString = string.Join(",", directories); + EqtTrace.Verbose( + "TestPluginCache: Using directories for assembly resolution '{0}'.", + directoryString); - // clear the assemblies - lock (this.resolvedAssemblies) - { - this.resolvedAssemblies?.Clear(); - } + var extensionString = string.Join(",", _filterableExtensionPaths.Concat(_unfilterableExtensionPaths)); + EqtTrace.Verbose("TestPluginCache: Updated the available extensions to '{0}'.", extensionString); } - - return pluginInfos; } + } - /// - /// Use the parameter path to extensions - /// - /// List of extension paths - /// Skip extension name filtering (if true) - public void UpdateExtensions(IEnumerable additionalExtensionsPath, bool skipExtensionFilters) - { - lock (this.lockForExtensionsUpdate) - { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("TestPluginCache: Update extensions started. Skip filter = " + skipExtensionFilters); - } + /// + /// Clear the previously cached extensions + /// + public void ClearExtensions() + { + _filterableExtensionPaths?.Clear(); + _unfilterableExtensionPaths?.Clear(); + TestExtensions?.InvalidateCache(); + } - var extensions = additionalExtensionsPath?.ToList(); - if (extensions == null || extensions.Count == 0) - { - return; - } + /// + /// Add search directories to assembly resolver + /// + /// + public void AddResolverSearchDirectories(string[] directories) + { + _assemblyResolver.AddSearchDirectories(directories); + } - if (skipExtensionFilters) - { - // Add the extensions to un-filter list. These extensions will never be filtered - // based on file name (e.g. *.testadapter.dll etc.). - if (TryMergeExtensionPaths(this.unfilterableExtensionPaths, extensions, - out this.unfilterableExtensionPaths)) - { - // Set the extensions discovered to false so that the next time anyone tries - // to get the additional extensions, we rediscover. - this.TestExtensions?.InvalidateCache(); - } - } - else - { - if (TryMergeExtensionPaths(this.filterableExtensionPaths, extensions, - out this.filterableExtensionPaths)) - { - this.TestExtensions?.InvalidateCache(); - } - } + #endregion - if (EqtTrace.IsVerboseEnabled) - { - var directories = this.filterableExtensionPaths.Concat(this.unfilterableExtensionPaths).Select(e => Path.GetDirectoryName(Path.GetFullPath(e))).Distinct(); - var directoryString = string.Join(",", directories); - EqtTrace.Verbose( - "TestPluginCache: Using directories for assembly resolution '{0}'.", - directoryString); - - var extensionString = string.Join(",", this.filterableExtensionPaths.Concat(this.unfilterableExtensionPaths)); - EqtTrace.Verbose("TestPluginCache: Updated the available extensions to '{0}'.", extensionString); - } - } - } + #region Utility methods - /// - /// Clear the previously cached extensions - /// - public void ClearExtensions() + internal IEnumerable DefaultExtensionPaths + { + get { - this.filterableExtensionPaths?.Clear(); - this.unfilterableExtensionPaths?.Clear(); - this.TestExtensions?.InvalidateCache(); + return _defaultExtensionPaths; } - /// - /// Add search directories to assembly resolver - /// - /// - public void AddResolverSearchDirectories(string[] directories) + set { - assemblyResolver.AddSearchDirectories(directories); + if (value != null) + { + _defaultExtensionPaths.AddRange(value); + } } + } - #endregion - - #region Utility methods - - internal IEnumerable DefaultExtensionPaths + /// + /// The get test extensions. + /// + /// + /// The extension assembly. + /// + /// + /// Skip the extensions cache. + /// + /// + /// Type of Test plugin info. + /// + /// + /// Type of extension. + /// + /// + /// The . + /// + internal Dictionary GetTestExtensions(string extensionAssembly, bool skipCache = false) where TPluginInfo : TestPluginInformation + { + if (skipCache) { - get - { - return this.defaultExtensionPaths; - } + return GetTestExtensions(new List() { extensionAssembly }); + } + else + { + // Check if extensions from this assembly have already been discovered. + var extensions = TestExtensions?.GetExtensionsDiscoveredFromAssembly( + TestExtensions.GetTestExtensionCache(), + extensionAssembly); - set + if (extensions != null && extensions.Count > 0) { - if (value != null) - { - this.defaultExtensionPaths.AddRange(value); - } + return extensions; } - } - /// - /// The get test extensions. - /// - /// - /// The extension assembly. - /// - /// - /// Skip the extensions cache. - /// - /// - /// Type of Test plugin info. - /// - /// - /// Type of extension. - /// - /// - /// The . - /// - internal Dictionary GetTestExtensions(string extensionAssembly, bool skipCache = false) where TPluginInfo : TestPluginInformation - { - if (skipCache) + var pluginInfos = GetTestExtensions(new List() { extensionAssembly }); + + // Add extensions discovered to the cache. + if (TestExtensions == null) { - return this.GetTestExtensions(new List() { extensionAssembly }); + TestExtensions = new TestExtensions(); } - else - { - // Check if extensions from this assembly have already been discovered. - var extensions = this.TestExtensions?.GetExtensionsDiscoveredFromAssembly( - this.TestExtensions.GetTestExtensionCache(), - extensionAssembly); - if (extensions != null && extensions.Count > 0) - { - return extensions; - } + TestExtensions.AddExtension(pluginInfos); + return pluginInfos; + } + } - var pluginInfos = this.GetTestExtensions(new List() { extensionAssembly }); + /// + /// Gets the resolution paths for the extension assembly to facilitate assembly resolution. + /// + /// The extension assembly. + /// Resolution paths for the assembly. + internal IList GetResolutionPaths(string extensionAssembly) + { + var resolutionPaths = new List(); - // Add extensions discovered to the cache. - if (this.TestExtensions == null) - { - this.TestExtensions = new TestExtensions(); - } + var extensionDirectory = Path.GetDirectoryName(Path.GetFullPath(extensionAssembly)); + resolutionPaths.Add(extensionDirectory); - this.TestExtensions.AddExtension(pluginInfos); - return pluginInfos; - } + var currentDirectory = Path.GetDirectoryName(typeof(TestPluginCache).GetTypeInfo().Assembly.GetAssemblyLocation()); + if (!resolutionPaths.Contains(currentDirectory)) + { + resolutionPaths.Add(currentDirectory); } - /// - /// Gets the resolution paths for the extension assembly to facilitate assembly resolution. - /// - /// The extension assembly. - /// Resolution paths for the assembly. - internal IList GetResolutionPaths(string extensionAssembly) - { - var resolutionPaths = new List(); + return resolutionPaths; + } - var extensionDirectory = Path.GetDirectoryName(Path.GetFullPath(extensionAssembly)); - resolutionPaths.Add(extensionDirectory); + /// + /// Gets the default set of resolution paths for the assembly resolution + /// + /// List of paths. + internal IList GetDefaultResolutionPaths() + { + var resolutionPaths = new List(); - var currentDirectory = Path.GetDirectoryName(typeof(TestPluginCache).GetTypeInfo().Assembly.GetAssemblyLocation()); - if (!resolutionPaths.Contains(currentDirectory)) - { - resolutionPaths.Add(currentDirectory); - } + // Add the extension directories for assembly resolution + var extensionDirectories = GetExtensionPaths(string.Empty).Select(e => Path.GetDirectoryName(Path.GetFullPath(e))).Distinct().ToList(); + if (extensionDirectories.Any()) + { + resolutionPaths.AddRange(extensionDirectories); + } - return resolutionPaths; + // Keep current directory for resolution + var currentDirectory = Path.GetDirectoryName(typeof(TestPluginCache).GetTypeInfo().Assembly.GetAssemblyLocation()); + if (!resolutionPaths.Contains(currentDirectory)) + { + resolutionPaths.Add(currentDirectory); } - /// - /// Gets the default set of resolution paths for the assembly resolution - /// - /// List of paths. - internal IList GetDefaultResolutionPaths() + // If running in Visual Studio context, add well known directories for resolution + var installContext = new InstallationContext(new FileHelper()); + if (installContext.TryGetVisualStudioDirectory(out string vsInstallPath)) { - var resolutionPaths = new List(); + resolutionPaths.AddRange(installContext.GetVisualStudioCommonLocations(vsInstallPath)); + } - // Add the extension directories for assembly resolution - var extensionDirectories = this.GetExtensionPaths(string.Empty).Select(e => Path.GetDirectoryName(Path.GetFullPath(e))).Distinct().ToList(); - if (extensionDirectories.Any()) - { - resolutionPaths.AddRange(extensionDirectories); - } + return resolutionPaths; + } - // Keep current directory for resolution - var currentDirectory = Path.GetDirectoryName(typeof(TestPluginCache).GetTypeInfo().Assembly.GetAssemblyLocation()); - if (!resolutionPaths.Contains(currentDirectory)) - { - resolutionPaths.Add(currentDirectory); - } + /// + /// Get the files which match the regex pattern + /// + /// + /// The extensions. + /// + /// + /// Pattern used to select files using String.EndsWith + /// + /// + /// The list of files which match the regex pattern + /// + protected virtual IEnumerable GetFilteredExtensions(List extensions, string endsWithPattern) + { + return string.IsNullOrEmpty(endsWithPattern) + ? extensions + : extensions.Where(ext => ext.EndsWith(endsWithPattern, StringComparison.OrdinalIgnoreCase)); + } - // If running in Visual Studio context, add well known directories for resolution - var installContext = new InstallationContext(new FileHelper()); - if (installContext.TryGetVisualStudioDirectory(out string vsInstallPath)) + private static bool TryMergeExtensionPaths(List extensionsList, List additionalExtensions, out List mergedExtensionsList) + { + if (additionalExtensions.Count == extensionsList.Count && additionalExtensions.All(extensionsList.Contains)) + { + if (EqtTrace.IsVerboseEnabled) { - resolutionPaths.AddRange(installContext.GetVisualStudioCommonLocations(vsInstallPath)); + var extensionString = string.Join(",", extensionsList); + EqtTrace.Verbose( + "TestPluginCache: Ignoring extensions merge as there is no change. Current additionalExtensions are '{0}'.", + extensionString); } - return resolutionPaths; + mergedExtensionsList = extensionsList; + return false; } - /// - /// Get the files which match the regex pattern - /// - /// - /// The extensions. - /// - /// - /// Pattern used to select files using String.EndsWith - /// - /// - /// The list of files which match the regex pattern - /// - protected virtual IEnumerable GetFilteredExtensions(List extensions, string endsWithPattern) - { - if (string.IsNullOrEmpty(endsWithPattern)) - { - return extensions; - } + // Don't do a strict check for existence of the extension path. The extension paths may or may + // not exist on the disk. In case of .net core, the paths are relative to the nuget packages + // directory. The path to nuget directory is automatically setup for CLR to resolve. + // Test platform tries to load every extension by assembly name. If it is not resolved, we don't throw + // an error. + additionalExtensions.AddRange(extensionsList); + mergedExtensionsList = additionalExtensions.Select(Path.GetFullPath) + .Distinct(StringComparer.OrdinalIgnoreCase).ToList(); - return extensions.Where(ext => ext.EndsWith(endsWithPattern, StringComparison.OrdinalIgnoreCase)); - } + return true; + } - private static bool TryMergeExtensionPaths(List extensionsList, List additionalExtensions, out List mergedExtensionsList) + /// + /// Gets the test extensions defined in the extension assembly list. + /// + /// + /// Type of PluginInfo. + /// + /// + /// Type of Extension. + /// + /// + /// Extension assembly paths. + /// + /// + /// List of extensions. + /// + /// + /// Added to mock out dependency from the actual test plugin discovery as such. + /// + private Dictionary GetTestExtensions(IEnumerable extensionPaths) where TPluginInfo : TestPluginInformation + { + foreach (var extensionPath in extensionPaths) { - if (additionalExtensions.Count == extensionsList.Count && additionalExtensions.All(extensionsList.Contains)) - { - if (EqtTrace.IsVerboseEnabled) - { - var extensionString = string.Join(",", extensionsList); - EqtTrace.Verbose( - "TestPluginCache: Ignoring extensions merge as there is no change. Current additionalExtensions are '{0}'.", - extensionString); - } - - mergedExtensionsList = extensionsList; - return false; - } + SetupAssemblyResolver(extensionPath); + } - // Don't do a strict check for existence of the extension path. The extension paths may or may - // not exist on the disk. In case of .net core, the paths are relative to the nuget packages - // directory. The path to nuget directory is automatically setup for CLR to resolve. - // Test platform tries to load every extension by assembly name. If it is not resolved, we don't throw - // an error. - additionalExtensions.AddRange(extensionsList); - mergedExtensionsList = additionalExtensions.Select(Path.GetFullPath) - .Distinct(StringComparer.OrdinalIgnoreCase).ToList(); + return new TestPluginDiscoverer().GetTestExtensionsInformation(extensionPaths); + } - return true; - } + protected void SetupAssemblyResolver(string extensionAssembly) + { + IList resolutionPaths = string.IsNullOrEmpty(extensionAssembly) ? GetDefaultResolutionPaths() : GetResolutionPaths(extensionAssembly); - /// - /// Gets the test extensions defined in the extension assembly list. - /// - /// - /// Type of PluginInfo. - /// - /// - /// Type of Extension. - /// - /// - /// Extension assembly paths. - /// - /// - /// List of extensions. - /// - /// - /// Added to mock out dependency from the actual test plugin discovery as such. - /// - private Dictionary GetTestExtensions(IEnumerable extensionPaths) where TPluginInfo : TestPluginInformation + // Add assembly resolver which can resolve the extensions from the specified directory. + if (_assemblyResolver == null) { - foreach (var extensionPath in extensionPaths) - { - this.SetupAssemblyResolver(extensionPath); - } - - return new TestPluginDiscoverer().GetTestExtensionsInformation(extensionPaths); + _assemblyResolver = new AssemblyResolver(resolutionPaths); } - - protected void SetupAssemblyResolver(string extensionAssembly) + else { - IList resolutionPaths; - - if (string.IsNullOrEmpty(extensionAssembly)) - { - resolutionPaths = this.GetDefaultResolutionPaths(); - } - else - { - resolutionPaths = this.GetResolutionPaths(extensionAssembly); - } - - // Add assembly resolver which can resolve the extensions from the specified directory. - if (this.assemblyResolver == null) - { - this.assemblyResolver = new AssemblyResolver(resolutionPaths); - } - else - { - this.assemblyResolver.AddSearchDirectories(resolutionPaths); - } + _assemblyResolver.AddSearchDirectories(resolutionPaths); } + } - private Assembly CurrentDomainAssemblyResolve(object sender, AssemblyResolveEventArgs args) - { - var assemblyName = new AssemblyName(args.Name); + private Assembly CurrentDomainAssemblyResolve(object sender, AssemblyResolveEventArgs args) + { + var assemblyName = new AssemblyName(args.Name); - Assembly assembly = null; - lock (this.resolvedAssemblies) + Assembly assembly = null; + lock (_resolvedAssemblies) + { + try { - try - { - EqtTrace.Verbose("CurrentDomainAssemblyResolve: Resolving assembly '{0}'.", args.Name); + EqtTrace.Verbose("CurrentDomainAssemblyResolve: Resolving assembly '{0}'.", args.Name); - if (this.resolvedAssemblies.TryGetValue(args.Name, out assembly)) - { - return assembly; - } + if (_resolvedAssemblies.TryGetValue(args.Name, out assembly)) + { + return assembly; + } - // Put it in the resolved assembly so that if below Assembly.Load call - // triggers another assembly resolution, then we don't end up in stack overflow - this.resolvedAssemblies[args.Name] = null; + // Put it in the resolved assembly so that if below Assembly.Load call + // triggers another assembly resolution, then we don't end up in stack overflow + _resolvedAssemblies[args.Name] = null; - assembly = Assembly.Load(assemblyName); + assembly = Assembly.Load(assemblyName); - // Replace the value with the loaded assembly - this.resolvedAssemblies[args.Name] = assembly; + // Replace the value with the loaded assembly + _resolvedAssemblies[args.Name] = assembly; - return assembly; - } - finally + return assembly; + } + finally + { + if (assembly == null) { - if (assembly == null) - { - EqtTrace.Verbose("CurrentDomainAssemblyResolve: Failed to resolve assembly '{0}'.", args.Name); - } + EqtTrace.Verbose("CurrentDomainAssemblyResolve: Failed to resolve assembly '{0}'.", args.Name); } } } + } - /// - /// Log the extensions - /// - private void LogExtensions() + /// + /// Log the extensions + /// + private void LogExtensions() + { + if (EqtTrace.IsVerboseEnabled) { - if (EqtTrace.IsVerboseEnabled) - { - var discoverers = this.TestExtensions.TestDiscoverers != null ? string.Join(",", this.TestExtensions.TestDiscoverers.Keys.ToArray()) : null; - EqtTrace.Verbose("TestPluginCache: Discoverers are '{0}'.", discoverers); + var discoverers = TestExtensions.TestDiscoverers != null ? string.Join(",", TestExtensions.TestDiscoverers.Keys.ToArray()) : null; + EqtTrace.Verbose("TestPluginCache: Discoverers are '{0}'.", discoverers); - var executors = this.TestExtensions.TestExecutors != null ? string.Join(",", this.TestExtensions.TestExecutors.Keys.ToArray()) : null; - EqtTrace.Verbose("TestPluginCache: Executors are '{0}'.", executors); + var executors = TestExtensions.TestExecutors != null ? string.Join(",", TestExtensions.TestExecutors.Keys.ToArray()) : null; + EqtTrace.Verbose("TestPluginCache: Executors are '{0}'.", executors); - var executors2 = this.TestExtensions.TestExecutors2 != null ? string.Join(",", this.TestExtensions.TestExecutors2.Keys.ToArray()) : null; - EqtTrace.Verbose("TestPluginCache: Executors2 are '{0}'.", executors2); + var executors2 = TestExtensions.TestExecutors2 != null ? string.Join(",", TestExtensions.TestExecutors2.Keys.ToArray()) : null; + EqtTrace.Verbose("TestPluginCache: Executors2 are '{0}'.", executors2); - var settingsProviders = this.TestExtensions.TestSettingsProviders != null ? string.Join(",", this.TestExtensions.TestSettingsProviders.Keys.ToArray()) : null; - EqtTrace.Verbose("TestPluginCache: Setting providers are '{0}'.", settingsProviders); + var settingsProviders = TestExtensions.TestSettingsProviders != null ? string.Join(",", TestExtensions.TestSettingsProviders.Keys.ToArray()) : null; + EqtTrace.Verbose("TestPluginCache: Setting providers are '{0}'.", settingsProviders); - var loggers = this.TestExtensions.TestLoggers != null ? string.Join(",", this.TestExtensions.TestLoggers.Keys.ToArray()) : null; - EqtTrace.Verbose("TestPluginCache: Loggers are '{0}'.", loggers); + var loggers = TestExtensions.TestLoggers != null ? string.Join(",", TestExtensions.TestLoggers.Keys.ToArray()) : null; + EqtTrace.Verbose("TestPluginCache: Loggers are '{0}'.", loggers); - var testhosts = this.TestExtensions.TestHosts != null ? string.Join(",", this.TestExtensions.TestHosts.Keys.ToArray()) : null; - EqtTrace.Verbose("TestPluginCache: TestHosts are '{0}'.", testhosts); + var testhosts = TestExtensions.TestHosts != null ? string.Join(",", TestExtensions.TestHosts.Keys.ToArray()) : null; + EqtTrace.Verbose("TestPluginCache: TestHosts are '{0}'.", testhosts); - var dataCollectors = this.TestExtensions.DataCollectors != null ? string.Join(",", this.TestExtensions.DataCollectors.Keys.ToArray()) : null; - EqtTrace.Verbose("TestPluginCache: DataCollectors are '{0}'.", dataCollectors); - } + var dataCollectors = TestExtensions.DataCollectors != null ? string.Join(",", TestExtensions.DataCollectors.Keys.ToArray()) : null; + EqtTrace.Verbose("TestPluginCache: DataCollectors are '{0}'.", dataCollectors); } - - #endregion } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs index 11cadec8cb..9d93ac4a2c 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs @@ -1,40 +1,39 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework +namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; + +using System; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Diagnostics; +using System.Globalization; +using System.Collections.Generic; + +using Utilities; +using Logging; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using CommonResources = Resources.Resources; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; + +/// +/// Discovers test extensions in a directory. +/// +internal class TestPluginDiscoverer { - using System; - using System.IO; - using System.Linq; - using System.Reflection; - using System.Diagnostics; - using System.Globalization; - using System.Collections.Generic; - - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using CommonResources = Resources.Resources; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; + private static readonly HashSet UnloadableFiles = new(); + private readonly MetadataReaderExtensionsHelper _extensionHelper = new(); /// - /// Discovers test extensions in a directory. + /// Initializes a new instance of the class. /// - internal class TestPluginDiscoverer + public TestPluginDiscoverer() { - private static HashSet UnloadableFiles = new HashSet(); - private readonly MetadataReaderExtensionsHelper extensionHelper = new MetadataReaderExtensionsHelper(); - - /// - /// Initializes a new instance of the class. - /// - public TestPluginDiscoverer() - { - } + } - #region Fields + #region Fields #if WINDOWS_UAP private static HashSet platformAssemblies = new HashSet(new string[] { @@ -52,226 +51,225 @@ public TestPluginDiscoverer() private const string SYSTEM_ASSEMBLY_PREFIX = "system."; #endif - #endregion + #endregion - #region Public Methods + #region Public Methods - /// - /// Gets information about each of the test extensions available. - /// - /// - /// The path to the extensions. - /// - /// - /// A dictionary of assembly qualified name and test plugin information. - /// - public Dictionary GetTestExtensionsInformation(IEnumerable extensionPaths) where TPluginInfo : TestPluginInformation - { - Debug.Assert(extensionPaths != null); + /// + /// Gets information about each of the test extensions available. + /// + /// + /// The path to the extensions. + /// + /// + /// A dictionary of assembly qualified name and test plugin information. + /// + public Dictionary GetTestExtensionsInformation(IEnumerable extensionPaths) where TPluginInfo : TestPluginInformation + { + Debug.Assert(extensionPaths != null); - var pluginInfos = new Dictionary(); + var pluginInfos = new Dictionary(); - // C++ UWP adapters do not follow TestAdapater naming convention, so making this exception - if (!extensionPaths.Any()) - { - this.AddKnownExtensions(ref extensionPaths); - } + // C++ UWP adapters do not follow TestAdapater naming convention, so making this exception + if (!extensionPaths.Any()) + { + AddKnownExtensions(ref extensionPaths); + } - this.GetTestExtensionsFromFiles(extensionPaths.ToArray(), pluginInfos); + GetTestExtensionsFromFiles(extensionPaths.ToArray(), pluginInfos); - return pluginInfos; - } + return pluginInfos; + } - #endregion + #endregion - #region Private Methods + #region Private Methods - private void AddKnownExtensions(ref IEnumerable extensionPaths) - { - // For C++ UWP adapter, & OLD C# UWP(MSTest V1) adapter - // In UWP .Net Native Compilation mode managed dll's are packaged differently, & File.Exists() fails. - // Include these two dll's if so far no adapters(extensions) were found, & let Assembly.Load() fail if they are not present. - extensionPaths = extensionPaths.Concat(new[] { "Microsoft.VisualStudio.TestTools.CppUnitTestFramework.CppUnitTestExtension.dll", "Microsoft.VisualStudio.TestPlatform.Extensions.MSAppContainerAdapter.dll" }); - } + private void AddKnownExtensions(ref IEnumerable extensionPaths) + { + // For C++ UWP adapter, & OLD C# UWP(MSTest V1) adapter + // In UWP .Net Native Compilation mode managed dll's are packaged differently, & File.Exists() fails. + // Include these two dll's if so far no adapters(extensions) were found, & let Assembly.Load() fail if they are not present. + extensionPaths = extensionPaths.Concat(new[] { "Microsoft.VisualStudio.TestTools.CppUnitTestFramework.CppUnitTestExtension.dll", "Microsoft.VisualStudio.TestPlatform.Extensions.MSAppContainerAdapter.dll" }); + } - /// - /// Gets test extension information from the given collection of files. - /// - /// - /// Type of Test Plugin Information. - /// - /// - /// Type of extension. - /// - /// - /// List of dll's to check for test extension availability - /// - /// - /// Test plugins collection to add to. - /// - private void GetTestExtensionsFromFiles( - string[] files, - Dictionary pluginInfos) where TPluginInfo : TestPluginInformation - { - Debug.Assert(files != null, "null files"); - Debug.Assert(pluginInfos != null, "null pluginInfos"); + /// + /// Gets test extension information from the given collection of files. + /// + /// + /// Type of Test Plugin Information. + /// + /// + /// Type of extension. + /// + /// + /// List of dll's to check for test extension availability + /// + /// + /// Test plugins collection to add to. + /// + private void GetTestExtensionsFromFiles( + string[] files, + Dictionary pluginInfos) where TPluginInfo : TestPluginInformation + { + Debug.Assert(files != null, "null files"); + Debug.Assert(pluginInfos != null, "null pluginInfos"); - // Scan each of the files for data extensions. - foreach (var file in files) + // Scan each of the files for data extensions. + foreach (var file in files) + { + if (UnloadableFiles.Contains(file)) { - if (UnloadableFiles.Contains(file)) - { - continue; - } - try - { - Assembly assembly = null; - var assemblyName = Path.GetFileNameWithoutExtension(file); - assembly = Assembly.Load(new AssemblyName(assemblyName)); - if (assembly != null) - { - this.GetTestExtensionsFromAssembly(assembly, pluginInfos, file); - } - } - catch (FileLoadException e) - { - EqtTrace.Warning("TestPluginDiscoverer-FileLoadException: Failed to load extensions from file '{0}'. Skipping test extension scan for this file. Error: {1}", file, e); - string fileLoadErrorMessage = string.Format(CultureInfo.CurrentUICulture, CommonResources.FailedToLoadAdapaterFile, file); - TestSessionMessageLogger.Instance.SendMessage(TestMessageLevel.Warning, fileLoadErrorMessage); - UnloadableFiles.Add(file); - } - catch (Exception e) - { - EqtTrace.Warning("TestPluginDiscoverer: Failed to load extensions from file '{0}'. Skipping test extension scan for this file. Error: {1}", file, e); - } + continue; } - } - - /// - /// Gets test extensions from a given assembly. - /// - /// Assembly to check for test extension availability - /// Test extensions collection to add to. - /// - /// Type of Test Plugin Information. - /// - /// - /// Type of Extensions. - /// - private void GetTestExtensionsFromAssembly(Assembly assembly, Dictionary pluginInfos, string filePath) where TPluginInfo : TestPluginInformation - { - Debug.Assert(assembly != null, "null assembly"); - Debug.Assert(pluginInfos != null, "null pluginInfos"); - - List types = new List(); - Type extension = typeof(TExtension); - try { - var discoveredExtensions = this.extensionHelper.DiscoverTestExtensionTypesV2Attribute(assembly, filePath); - if (discoveredExtensions?.Length > 0) + Assembly assembly = null; + var assemblyName = Path.GetFileNameWithoutExtension(file); + assembly = Assembly.Load(new AssemblyName(assemblyName)); + if (assembly != null) { - types.AddRange(discoveredExtensions); + GetTestExtensionsFromAssembly(assembly, pluginInfos, file); } } + catch (FileLoadException e) + { + EqtTrace.Warning("TestPluginDiscoverer-FileLoadException: Failed to load extensions from file '{0}'. Skipping test extension scan for this file. Error: {1}", file, e); + string fileLoadErrorMessage = string.Format(CultureInfo.CurrentUICulture, CommonResources.FailedToLoadAdapaterFile, file); + TestSessionMessageLogger.Instance.SendMessage(TestMessageLevel.Warning, fileLoadErrorMessage); + UnloadableFiles.Add(file); + } catch (Exception e) { - EqtTrace.Warning("TestPluginDiscoverer: Failed to get types searching for 'TestPlatformExtensionVersionAttribute' from assembly '{0}'. Error: {1}", assembly.FullName, e.ToString()); + EqtTrace.Warning("TestPluginDiscoverer: Failed to load extensions from file '{0}'. Skipping test extension scan for this file. Error: {1}", file, e); } + } + } - try - { - var typesToLoad = TypesToLoadUtilities.GetTypesToLoad(assembly); - if (typesToLoad?.Any() == true) - { - types.AddRange(typesToLoad); - } + /// + /// Gets test extensions from a given assembly. + /// + /// Assembly to check for test extension availability + /// Test extensions collection to add to. + /// + /// Type of Test Plugin Information. + /// + /// + /// Type of Extensions. + /// + private void GetTestExtensionsFromAssembly(Assembly assembly, Dictionary pluginInfos, string filePath) where TPluginInfo : TestPluginInformation + { + Debug.Assert(assembly != null, "null assembly"); + Debug.Assert(pluginInfos != null, "null pluginInfos"); - if (!types.Any()) - { - types.AddRange(assembly.GetTypes().Where(type => type.GetTypeInfo().IsClass && !type.GetTypeInfo().IsAbstract)); - } + List types = new(); + Type extension = typeof(TExtension); + + try + { + var discoveredExtensions = _extensionHelper.DiscoverTestExtensionTypesV2Attribute(assembly, filePath); + if (discoveredExtensions?.Length > 0) + { + types.AddRange(discoveredExtensions); } - catch (ReflectionTypeLoadException e) + } + catch (Exception e) + { + EqtTrace.Warning("TestPluginDiscoverer: Failed to get types searching for 'TestPlatformExtensionVersionAttribute' from assembly '{0}'. Error: {1}", assembly.FullName, e.ToString()); + } + + try + { + var typesToLoad = TypesToLoadUtilities.GetTypesToLoad(assembly); + if (typesToLoad?.Any() == true) { - EqtTrace.Warning("TestPluginDiscoverer: Failed to get types from assembly '{0}'. Error: {1}", assembly.FullName, e.ToString()); + types.AddRange(typesToLoad); + } - if (e.Types?.Length > 0) - { - types.AddRange(e.Types.Where(type => type.GetTypeInfo().IsClass && !type.GetTypeInfo().IsAbstract)); - } + if (!types.Any()) + { + types.AddRange(assembly.GetTypes().Where(type => type.GetTypeInfo().IsClass && !type.GetTypeInfo().IsAbstract)); + } + } + catch (ReflectionTypeLoadException e) + { + EqtTrace.Warning("TestPluginDiscoverer: Failed to get types from assembly '{0}'. Error: {1}", assembly.FullName, e.ToString()); - if (e.LoaderExceptions != null) - { - foreach (var ex in e.LoaderExceptions) - { - EqtTrace.Warning("LoaderExceptions: {0}", ex); - } - } + if (e.Types?.Length > 0) + { + types.AddRange(e.Types.Where(type => type.GetTypeInfo().IsClass && !type.GetTypeInfo().IsAbstract)); } - if (types != null && types.Any()) + if (e.LoaderExceptions != null) { - foreach (var type in types) + foreach (var ex in e.LoaderExceptions) { - GetTestExtensionFromType(type, extension, pluginInfos, filePath); + EqtTrace.Warning("LoaderExceptions: {0}", ex); } } } - /// - /// Attempts to find a test extension from given type. - /// - /// - /// Type of the test plugin information - /// - /// - /// Type to inspect for being test extension - /// - /// - /// Test extension type to look for. - /// - /// - /// Test extensions collection to add to. - /// - private void GetTestExtensionFromType( - Type type, - Type extensionType, - Dictionary extensionCollection, - string filePath) - where TPluginInfo : TestPluginInformation + if (types != null && types.Any()) { - if (extensionType.GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) + foreach (var type in types) { - var rawPluginInfo = Activator.CreateInstance(typeof(TPluginInfo), type); - var pluginInfo = (TPluginInfo)rawPluginInfo; - pluginInfo.FilePath = filePath; + GetTestExtensionFromType(type, extension, pluginInfos, filePath); + } + } + } + + /// + /// Attempts to find a test extension from given type. + /// + /// + /// Type of the test plugin information + /// + /// + /// Type to inspect for being test extension + /// + /// + /// Test extension type to look for. + /// + /// + /// Test extensions collection to add to. + /// + private void GetTestExtensionFromType( + Type type, + Type extensionType, + Dictionary extensionCollection, + string filePath) + where TPluginInfo : TestPluginInformation + { + if (extensionType.GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) + { + var rawPluginInfo = Activator.CreateInstance(typeof(TPluginInfo), type); + var pluginInfo = (TPluginInfo)rawPluginInfo; + pluginInfo.FilePath = filePath; - if (pluginInfo == null || pluginInfo.IdentifierData == null) + if (pluginInfo == null || pluginInfo.IdentifierData == null) + { + if (EqtTrace.IsErrorEnabled) { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error( + EqtTrace.Error( "GetTestExtensionFromType: Either PluginInformation is null or PluginInformation doesn't contain IdentifierData for type {0}.", type.FullName); - } - return; } + return; + } - if (extensionCollection.ContainsKey(pluginInfo.IdentifierData)) - { - EqtTrace.Warning( + if (extensionCollection.ContainsKey(pluginInfo.IdentifierData)) + { + EqtTrace.Warning( "GetTestExtensionFromType: Discovered multiple test extensions with identifier data '{0}' and type '{1}' inside file '{2}'; keeping the first one '{3}'.", - pluginInfo.IdentifierData, pluginInfo.AssemblyQualifiedName, filePath, extensionCollection[pluginInfo.IdentifierData].AssemblyQualifiedName); - } - else - { - extensionCollection.Add(pluginInfo.IdentifierData, pluginInfo); - EqtTrace.Info("GetTestExtensionFromType: Register extension with identifier data '{0}' and type '{1}' inside file '{2}'", - pluginInfo.IdentifierData, pluginInfo.AssemblyQualifiedName, filePath); - } + pluginInfo.IdentifierData, pluginInfo.AssemblyQualifiedName, filePath, extensionCollection[pluginInfo.IdentifierData].AssemblyQualifiedName); + } + else + { + extensionCollection.Add(pluginInfo.IdentifierData, pluginInfo); + EqtTrace.Info("GetTestExtensionFromType: Register extension with identifier data '{0}' and type '{1}' inside file '{2}'", + pluginInfo.IdentifierData, pluginInfo.AssemblyQualifiedName, filePath); } } - - #endregion } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginManager.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginManager.cs index 3ef28c131c..5fa02d17fc 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginManager.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginManager.cs @@ -1,254 +1,243 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework +namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; + +using System; +using System.Collections.Generic; +using System.Reflection; + +using Utilities; +using ObjectModel; + +/// +/// Manages test plugins information. +/// +internal class TestPluginManager { - using System; - using System.Collections.Generic; - using System.Reflection; + private static TestPluginManager s_instance; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; + #region Public Static Methods /// - /// Manages test plugins information. + /// Gets the singleton instance of TestPluginManager. /// - internal class TestPluginManager - { - private static TestPluginManager instance; - - #region Public Static Methods + public static TestPluginManager Instance + => s_instance ??= new TestPluginManager(); - /// - /// Gets the singleton instance of TestPluginManager. - /// - public static TestPluginManager Instance + /// + /// Gets data type of test extension with given assembly qualified name. + /// + /// Assembly qualified name of the test extension + /// Data type of the test extension + public static Type GetTestExtensionType(string extensionTypeName) + { + Type extensionType; + try { - get - { - if (instance == null) - { - instance = new TestPluginManager(); - } - - return instance; - } + extensionType = Type.GetType(extensionTypeName, true); } - - /// - /// Gets data type of test extension with given assembly qualified name. - /// - /// Assembly qualified name of the test extension - /// Data type of the test extension - public static Type GetTestExtensionType(string extensionTypeName) + catch (Exception ex) { - Type extensionType = null; - try - { - extensionType = Type.GetType(extensionTypeName, true); - } - catch (Exception ex) - { - EqtTrace.Error( - "GetTestExtensionType: Failed to get type for test extension '{0}': {1}", - extensionTypeName, - ex); - throw; - } - - return extensionType; + EqtTrace.Error( + "GetTestExtensionType: Failed to get type for test extension '{0}': {1}", + extensionTypeName, + ex); + throw; } - /// - /// Instantiates a given data type. - /// - /// Return type of the test extension - /// Data type of the extension to be instantiated - /// Test extension instance - public static T CreateTestExtension(Type extensionType) + return extensionType; + } + + /// + /// Instantiates a given data type. + /// + /// Return type of the test extension + /// Data type of the extension to be instantiated + /// Test extension instance + public static T CreateTestExtension(Type extensionType) + { + if (extensionType == null) { - if (extensionType == null) - { - throw new ArgumentNullException(nameof(extensionType)); - } + throw new ArgumentNullException(nameof(extensionType)); + } - EqtTrace.Info("TestPluginManager.CreateTestExtension: Attempting to load test extension: " + extensionType); + EqtTrace.Info("TestPluginManager.CreateTestExtension: Attempting to load test extension: " + extensionType); - try - { - object rawPlugin = Activator.CreateInstance(extensionType); + try + { + object rawPlugin = Activator.CreateInstance(extensionType); - T testExtension = (T)rawPlugin; - return testExtension; - } - catch (Exception ex) + T testExtension = (T)rawPlugin; + return testExtension; + } + catch (Exception ex) + { + if (ex is TargetInvocationException) { - if (ex is TargetInvocationException) + if (EqtTrace.IsErrorEnabled) { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("TestPluginManager.CreateTestExtension: Could not create instance of type: " + extensionType.ToString() + " Exception: " + ex); - } - throw; + EqtTrace.Error("TestPluginManager.CreateTestExtension: Could not create instance of type: " + extensionType.ToString() + " Exception: " + ex); } + throw; + } #if NETFRAMEWORK - else if (ex is SystemException) - { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("TestPluginManager.CreateTestExtension: Could not create instance of type: " + extensionType.ToString() + " Exception: " + ex); - } - throw; - } -#endif + else if (ex is SystemException) + { if (EqtTrace.IsErrorEnabled) { EqtTrace.Error("TestPluginManager.CreateTestExtension: Could not create instance of type: " + extensionType.ToString() + " Exception: " + ex); } - throw; } - } +#endif + if (EqtTrace.IsErrorEnabled) + { + EqtTrace.Error("TestPluginManager.CreateTestExtension: Could not create instance of type: " + extensionType.ToString() + " Exception: " + ex); + } - #endregion - - #region Public Methods - - /// - /// Retrieves the test extension collections of given extension type. - /// - /// - /// Type of the required extensions - /// - /// - /// Type of metadata of required extensions - /// - /// - /// Concrete type of metadata - /// - /// - /// Pattern used to select files using String.EndsWith - /// - /// - /// Receives unfiltered list of test extensions - /// - /// - /// Receives test extensions filtered by Identifier data - /// - public void GetSpecificTestExtensions( - string endsWithPattern, - out IEnumerable>> unfiltered, - out IEnumerable> filtered) where TMetadata : IMetadata where TPluginInfo : TestPluginInformation - { - var extensions = TestPluginCache.Instance.DiscoverTestExtensions(endsWithPattern); - this.GetExtensions(extensions, out unfiltered, out filtered); + throw; } + } - /// - /// Retrieves the test extension collections of given extension type for the provided extension assembly. - /// - /// - /// The extension assembly. - /// - /// - /// - /// - /// Type of the required extensions - /// - /// - /// Type of metadata of required extensions - /// - /// - /// Concrete type of metadata - /// - /// - /// Receives unfiltered list of test extensions - /// - /// - /// Receives test extensions filtered by Identifier data - /// - /// - /// Skip the extensions cache. - /// - public void GetTestExtensions( - string extensionAssembly, - out IEnumerable>> unfiltered, - out IEnumerable> filtered, - bool skipCache = false) where TMetadata : IMetadata where TPluginInfo : TestPluginInformation - { - var extensions = TestPluginCache.Instance.GetTestExtensions(extensionAssembly, skipCache); - this.GetExtensions(extensions, out unfiltered, out filtered); - } + #endregion - #endregion + #region Public Methods - #region Private Methods + /// + /// Retrieves the test extension collections of given extension type. + /// + /// + /// Type of the required extensions + /// + /// + /// Type of metadata of required extensions + /// + /// + /// Concrete type of metadata + /// + /// + /// Pattern used to select files using String.EndsWith + /// + /// + /// Receives unfiltered list of test extensions + /// + /// + /// Receives test extensions filtered by Identifier data + /// + public void GetSpecificTestExtensions( + string endsWithPattern, + out IEnumerable>> unfiltered, + out IEnumerable> filtered) where TMetadata : IMetadata where TPluginInfo : TestPluginInformation + { + var extensions = TestPluginCache.Instance.DiscoverTestExtensions(endsWithPattern); + GetExtensions(extensions, out unfiltered, out filtered); + } - /// - /// Prepares a List of TestPluginInformation> - /// - /// Type of TestPluginIInformation. - /// The dictionary containing plugin identifier data and its info. - /// Collection of test plugins information - private IEnumerable GetValuesFromDictionary(Dictionary dictionary) where T : TestPluginInformation - { - var values = new List(); + /// + /// Retrieves the test extension collections of given extension type for the provided extension assembly. + /// + /// + /// The extension assembly. + /// + /// + /// + /// + /// Type of the required extensions + /// + /// + /// Type of metadata of required extensions + /// + /// + /// Concrete type of metadata + /// + /// + /// Receives unfiltered list of test extensions + /// + /// + /// Receives test extensions filtered by Identifier data + /// + /// + /// Skip the extensions cache. + /// + public void GetTestExtensions( + string extensionAssembly, + out IEnumerable>> unfiltered, + out IEnumerable> filtered, + bool skipCache = false) where TMetadata : IMetadata where TPluginInfo : TestPluginInformation + { + var extensions = TestPluginCache.Instance.GetTestExtensions(extensionAssembly, skipCache); + GetExtensions(extensions, out unfiltered, out filtered); + } - foreach (var key in dictionary.Keys) - { - values.Add(dictionary[key]); - } + #endregion - return values; - } + #region Private Methods + + /// + /// Prepares a List of TestPluginInformation> + /// + /// Type of TestPluginIInformation. + /// The dictionary containing plugin identifier data and its info. + /// Collection of test plugins information + private IEnumerable GetValuesFromDictionary(Dictionary dictionary) where T : TestPluginInformation + { + var values = new List(); - /// - /// Gets unfiltered and filtered extensions from the provided test extension collection. - /// - /// - /// - /// - /// Type of the required extensions - /// - /// - /// Type of metadata of required extensions - /// - /// - /// Concrete type of metadata - /// - /// - /// The test extension dictionary. - /// - /// - /// Receives unfiltered list of test extensions - /// - /// - /// Receives test extensions filtered by Identifier data - /// - private void GetExtensions( - Dictionary testPluginInfo, - out IEnumerable>> unfiltered, - out IEnumerable> filtered) where TMetadata : IMetadata where TPluginInfo : TestPluginInformation + foreach (var key in dictionary.Keys) { - var unfilteredExtensions = new List>>(); - var filteredExtensions = new List>(); + values.Add(dictionary[key]); + } - var testPlugins = this.GetValuesFromDictionary(testPluginInfo); - foreach (var plugin in testPlugins) - { - if (!string.IsNullOrEmpty(plugin.IdentifierData)) - { - var testExtension = new LazyExtension(plugin, typeof(TMetadata)); - filteredExtensions.Add(testExtension); - } + return values; + } - unfilteredExtensions.Add(new LazyExtension>(plugin, new Dictionary())); + /// + /// Gets unfiltered and filtered extensions from the provided test extension collection. + /// + /// + /// + /// + /// Type of the required extensions + /// + /// + /// Type of metadata of required extensions + /// + /// + /// Concrete type of metadata + /// + /// + /// The test extension dictionary. + /// + /// + /// Receives unfiltered list of test extensions + /// + /// + /// Receives test extensions filtered by Identifier data + /// + private void GetExtensions( + Dictionary testPluginInfo, + out IEnumerable>> unfiltered, + out IEnumerable> filtered) where TMetadata : IMetadata where TPluginInfo : TestPluginInformation + { + var unfilteredExtensions = new List>>(); + var filteredExtensions = new List>(); + + var testPlugins = GetValuesFromDictionary(testPluginInfo); + foreach (var plugin in testPlugins) + { + if (!string.IsNullOrEmpty(plugin.IdentifierData)) + { + var testExtension = new LazyExtension(plugin, typeof(TMetadata)); + filteredExtensions.Add(testExtension); } - unfiltered = unfilteredExtensions; - filtered = filteredExtensions; + unfilteredExtensions.Add(new LazyExtension>(plugin, new Dictionary())); } - #endregion + unfiltered = unfilteredExtensions; + filtered = filteredExtensions; } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/LazyExtension.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/LazyExtension.cs index 20025ee16e..d1af4e7b07 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/LazyExtension.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/LazyExtension.cs @@ -1,173 +1,164 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities +namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; + +using System; +using System.Linq; + +/// +/// Class to hold a test extension type +/// +/// Test extension type +/// Test extension metadata +public class LazyExtension { - using System; - using System.Linq; + #region Private Members + + private static readonly object Synclock = new(); + private TExtension _extension; + private TMetadata _metadata; + private readonly Type _metadataType; + private readonly Func _extensionCreator; + + #endregion + + #region Constructors /// - /// Class to hold a test extension type + /// The constructor. /// - /// Test extension type - /// Test extension metadata - public class LazyExtension + /// Test extension Instance + /// test extension metadata + public LazyExtension(TExtension instance, TMetadata metadata) { - #region Private Members - - private static object synclock = new object(); - private TExtension extension; - private TMetadata metadata; - private TestPluginInformation testPluginInfo; - private Type metadataType; - private bool isExtensionCreated; - private Func extensionCreator; - - #endregion - - #region Constructors - - /// - /// The constructor. - /// - /// Test extension Instance - /// test extension metadata - public LazyExtension(TExtension instance, TMetadata metadata) + if (instance == null) { - if (instance == null) - { - throw new ArgumentNullException(nameof(instance)); - } - - if (metadata == null) - { - throw new ArgumentNullException(nameof(instance)); - } - - this.extension = instance; - this.metadata = metadata; - this.isExtensionCreated = true; + throw new ArgumentNullException(nameof(instance)); } - /// - /// The constructor. - /// - /// Test plugin to instantiated on demand. - /// Metadata type to instantiate on demand - public LazyExtension(TestPluginInformation pluginInfo, Type metadataType) + if (metadata == null) { - this.testPluginInfo = pluginInfo ?? throw new ArgumentNullException(nameof(pluginInfo)); - this.metadataType = metadataType ?? throw new ArgumentNullException(nameof(metadataType)); - this.isExtensionCreated = false; + throw new ArgumentNullException(nameof(instance)); } - /// - /// The constructor. - /// - /// Test plugin to instantiated on demand - /// Test extension metadata - public LazyExtension(TestPluginInformation pluginInfo, TMetadata metadata) - { - if (metadata == null) - { - throw new ArgumentNullException(nameof(metadata)); - } + _extension = instance; + _metadata = metadata; + IsExtensionCreated = true; + } - this.testPluginInfo = pluginInfo ?? throw new ArgumentNullException(nameof(pluginInfo)); - this.metadata = metadata; - this.isExtensionCreated = false; - } + /// + /// The constructor. + /// + /// Test plugin to instantiated on demand. + /// Metadata type to instantiate on demand + public LazyExtension(TestPluginInformation pluginInfo, Type metadataType) + { + TestPluginInfo = pluginInfo ?? throw new ArgumentNullException(nameof(pluginInfo)); + _metadataType = metadataType ?? throw new ArgumentNullException(nameof(metadataType)); + IsExtensionCreated = false; + } - /// - /// Delegate Constructor - /// - /// Test extension creator delegate - /// test extension metadata - public LazyExtension(Func creator, TMetadata metadata) + /// + /// The constructor. + /// + /// Test plugin to instantiated on demand + /// Test extension metadata + public LazyExtension(TestPluginInformation pluginInfo, TMetadata metadata) + { + if (metadata == null) { - if (metadata == null) - { - throw new ArgumentNullException(nameof(metadata)); - } - - this.extensionCreator = creator ?? throw new ArgumentNullException(nameof(creator)); - this.metadata = metadata; - this.isExtensionCreated = false; + throw new ArgumentNullException(nameof(metadata)); } - #endregion - - #region Public Properties + TestPluginInfo = pluginInfo ?? throw new ArgumentNullException(nameof(pluginInfo)); + _metadata = metadata; + IsExtensionCreated = false; + } - /// - /// Gets a value indicating whether is extension created. - /// - internal bool IsExtensionCreated + /// + /// Delegate Constructor + /// + /// Test extension creator delegate + /// test extension metadata + public LazyExtension(Func creator, TMetadata metadata) + { + if (metadata == null) { - get - { - return this.isExtensionCreated; - } + throw new ArgumentNullException(nameof(metadata)); } - internal TestPluginInformation TestPluginInfo => this.testPluginInfo; + _extensionCreator = creator ?? throw new ArgumentNullException(nameof(creator)); + _metadata = metadata; + IsExtensionCreated = false; + } + + #endregion + + #region Public Properties - /// - /// Gets the test extension instance. - /// - public TExtension Value + /// + /// Gets a value indicating whether is extension created. + /// + internal bool IsExtensionCreated { get; private set; } + + internal TestPluginInformation TestPluginInfo { get; private set; } + + /// + /// Gets the test extension instance. + /// + public TExtension Value + { + get { - get + if (!IsExtensionCreated) { - if (!this.isExtensionCreated) + if (_extensionCreator != null) { - if (this.extensionCreator != null) - { - this.extension = this.extensionCreator(); - } - else if (this.extension == null) + _extension = _extensionCreator(); + } + else if (_extension == null) + { + lock (Synclock) { - lock (synclock) + if (_extension == null && TestPluginInfo != null) { - if (this.extension == null && this.testPluginInfo != null) - { - var pluginType = TestPluginManager.GetTestExtensionType(this.testPluginInfo.AssemblyQualifiedName); - this.extension = TestPluginManager.CreateTestExtension(pluginType); - } + var pluginType = TestPluginManager.GetTestExtensionType(TestPluginInfo.AssemblyQualifiedName); + _extension = TestPluginManager.CreateTestExtension(pluginType); } } - - this.isExtensionCreated = true; } - return this.extension; + IsExtensionCreated = true; } + + return _extension; } + } - /// - /// Gets the test extension metadata - /// - public TMetadata Metadata + /// + /// Gets the test extension metadata + /// + public TMetadata Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) + lock (Synclock) { - lock (synclock) + if (_metadata == null && TestPluginInfo != null) { - if (this.metadata == null && this.testPluginInfo != null) - { - var parameters = this.testPluginInfo.Metadata?.ToArray(); - var dataObject = Activator.CreateInstance(this.metadataType, parameters); - this.metadata = (TMetadata)dataObject; - } + var parameters = TestPluginInfo.Metadata?.ToArray(); + var dataObject = Activator.CreateInstance(_metadataType, parameters); + _metadata = (TMetadata)dataObject; } } - - return this.metadata; } - } - #endregion + return _metadata; + } } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestDiscovererPluginInformation.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestDiscovererPluginInformation.cs index a85a225f7d..b580ed6b43 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestDiscovererPluginInformation.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestDiscovererPluginInformation.cs @@ -1,139 +1,138 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities -{ - using System; - using System.Collections.Generic; - using System.ComponentModel; - using System.Linq; - using System.Reflection; +namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Reflection; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using ObjectModel; + +/// +/// The test discoverer plugin information. +/// +internal class TestDiscovererPluginInformation : TestPluginInformation +{ /// - /// The test discoverer plugin information. + /// Default constructor /// - internal class TestDiscovererPluginInformation : TestPluginInformation + /// Data type of the test discoverer + public TestDiscovererPluginInformation(Type testDiscovererType) + : base(testDiscovererType) { - /// - /// Default constructor - /// - /// Data type of the test discoverer - public TestDiscovererPluginInformation(Type testDiscovererType) - : base(testDiscovererType) + if (testDiscovererType != null) { - if (testDiscovererType != null) - { - this.FileExtensions = GetFileExtensions(testDiscovererType); - this.DefaultExecutorUri = GetDefaultExecutorUri(testDiscovererType); - this.AssemblyType = GetAssemblyType(testDiscovererType); - } + FileExtensions = GetFileExtensions(testDiscovererType); + DefaultExecutorUri = GetDefaultExecutorUri(testDiscovererType); + AssemblyType = GetAssemblyType(testDiscovererType); } + } - /// - /// Metadata for the test plugin - /// - public override ICollection Metadata + /// + /// Metadata for the test plugin + /// + public override ICollection Metadata + { + get { - get - { - return new object[] { this.FileExtensions, this.DefaultExecutorUri, this.AssemblyType }; - } + return new object[] { FileExtensions, DefaultExecutorUri, AssemblyType }; } + } - /// - /// Gets collection of file extensions supported by discoverer plugin. - /// - public List FileExtensions - { - get; - private set; - } + /// + /// Gets collection of file extensions supported by discoverer plugin. + /// + public List FileExtensions + { + get; + private set; + } - /// - /// Gets the Uri identifying the executor - /// - public string DefaultExecutorUri - { - get; - private set; - } + /// + /// Gets the Uri identifying the executor + /// + public string DefaultExecutorUri + { + get; + private set; + } - /// - /// Gets the assembly type supported by discoverer plugin. - /// - public AssemblyType AssemblyType - { - get; - private set; - } + /// + /// Gets the assembly type supported by discoverer plugin. + /// + public AssemblyType AssemblyType + { + get; + private set; + } - /// - /// Helper to get file extensions from the FileExtensionAttribute on the discover plugin. - /// - /// Data type of the test discoverer - /// List of file extensions - private static List GetFileExtensions(Type testDicovererType) - { - var fileExtensions = new List(); + /// + /// Helper to get file extensions from the FileExtensionAttribute on the discover plugin. + /// + /// Data type of the test discoverer + /// List of file extensions + private static List GetFileExtensions(Type testDicovererType) + { + var fileExtensions = new List(); - var attributes = testDicovererType.GetTypeInfo().GetCustomAttributes(typeof(FileExtensionAttribute), false).ToArray(); - if (attributes != null && attributes.Length > 0) + var attributes = testDicovererType.GetTypeInfo().GetCustomAttributes(typeof(FileExtensionAttribute), false).ToArray(); + if (attributes != null && attributes.Length > 0) + { + foreach (var attribute in attributes) { - foreach (var attribute in attributes) + var fileExtAttribute = (FileExtensionAttribute)attribute; + if (!string.IsNullOrEmpty(fileExtAttribute.FileExtension)) { - var fileExtAttribute = (FileExtensionAttribute)attribute; - if (!string.IsNullOrEmpty(fileExtAttribute.FileExtension)) - { - fileExtensions.Add(fileExtAttribute.FileExtension); - } + fileExtensions.Add(fileExtAttribute.FileExtension); } } - - return fileExtensions; } - /// - /// Returns the value of default executor Uri on this type. 'Null' if not present. - /// - /// The test discoverer Type. - /// The default executor URI. - private static string GetDefaultExecutorUri(Type testDiscovererType) + return fileExtensions; + } + + /// + /// Returns the value of default executor Uri on this type. 'Null' if not present. + /// + /// The test discoverer Type. + /// The default executor URI. + private static string GetDefaultExecutorUri(Type testDiscovererType) + { + string result = string.Empty; + + object[] attributes = testDiscovererType.GetTypeInfo().GetCustomAttributes(typeof(DefaultExecutorUriAttribute), false).ToArray(); + if (attributes != null && attributes.Length > 0) { - string result = string.Empty; + DefaultExecutorUriAttribute executorUriAttribute = (DefaultExecutorUriAttribute)attributes[0]; - object[] attributes = testDiscovererType.GetTypeInfo().GetCustomAttributes(typeof(DefaultExecutorUriAttribute), false).ToArray(); - if (attributes != null && attributes.Length > 0) + if (!string.IsNullOrEmpty(executorUriAttribute.ExecutorUri)) { - DefaultExecutorUriAttribute executorUriAttribute = (DefaultExecutorUriAttribute)attributes[0]; - - if (!string.IsNullOrEmpty(executorUriAttribute.ExecutorUri)) - { - result = executorUriAttribute.ExecutorUri; - } + result = executorUriAttribute.ExecutorUri; } - - return result; } - /// - /// Helper to get the supported assembly type from the CategoryAttribute on the discover plugin. - /// - /// The test discoverer Type. - /// Supported assembly type. - private AssemblyType GetAssemblyType(Type testDiscovererType) - { - var assemblyType = default(AssemblyType); + return result; + } + + /// + /// Helper to get the supported assembly type from the CategoryAttribute on the discover plugin. + /// + /// The test discoverer Type. + /// Supported assembly type. + private AssemblyType GetAssemblyType(Type testDiscovererType) + { - // Get Category - var attribute = testDiscovererType.GetTypeInfo().GetCustomAttribute(typeof(CategoryAttribute)); - var category = (attribute as CategoryAttribute)?.Category; + // Get Category + var attribute = testDiscovererType.GetTypeInfo().GetCustomAttribute(typeof(CategoryAttribute)); + var category = (attribute as CategoryAttribute)?.Category; - // Get assembly type from category. - Enum.TryParse(category, true, out assemblyType); - return assemblyType; - } + // Get assembly type from category. + Enum.TryParse(category, true, out AssemblyType assemblyType); + return assemblyType; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExecutorPluginInformation.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExecutorPluginInformation.cs index b768494fb2..0c4046d1c2 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExecutorPluginInformation.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExecutorPluginInformation.cs @@ -1,37 +1,36 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; + +using System; +/// +/// The test executor plugin information. +/// +internal class TestExecutorPluginInformation : TestExtensionPluginInformation +{ /// - /// The test executor plugin information. + /// Default constructor /// - internal class TestExecutorPluginInformation : TestExtensionPluginInformation + /// The test Executor Type. + public TestExecutorPluginInformation(Type testExecutorType) + : base(testExecutorType) { - /// - /// Default constructor - /// - /// The test Executor Type. - public TestExecutorPluginInformation(Type testExecutorType) - : base(testExecutorType) - { - } } +} +/// +/// The test executor 2 plugin information. +/// +internal class TestExecutorPluginInformation2 : TestExtensionPluginInformation +{ /// - /// The test executor 2 plugin information. + /// Default constructor /// - internal class TestExecutorPluginInformation2 : TestExtensionPluginInformation + /// The test Executor Type. + public TestExecutorPluginInformation2(Type testExecutorType) + : base(testExecutorType) { - /// - /// Default constructor - /// - /// The test Executor Type. - public TestExecutorPluginInformation2(Type testExecutorType) - : base(testExecutorType) - { - } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensionPluginInformation.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensionPluginInformation.cs index ac3face5da..ba81d8f804 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensionPluginInformation.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensionPluginInformation.cs @@ -1,90 +1,89 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Reflection; +namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using ObjectModel; +/// +/// The test extension plugin information. +/// +internal abstract class TestExtensionPluginInformation : TestPluginInformation +{ /// - /// The test extension plugin information. + /// Default constructor /// - internal abstract class TestExtensionPluginInformation : TestPluginInformation + /// The test Logger Type. + public TestExtensionPluginInformation(Type type) + : base(type) { - /// - /// Default constructor - /// - /// The test Logger Type. - public TestExtensionPluginInformation(Type type) - : base(type) + if (type != null) { - if (type != null) - { - this.ExtensionUri = GetExtensionUri(type); - } - } - - /// - /// Gets data value identifying the test plugin - /// - public override string IdentifierData - { - get - { - return this.ExtensionUri; - } + ExtensionUri = GetExtensionUri(type); } + } - /// - /// Metadata for the test plugin - /// - public override ICollection Metadata + /// + /// Gets data value identifying the test plugin + /// + public override string IdentifierData + { + get { - get - { - return new object[] { this.ExtensionUri }; - } + return ExtensionUri; } + } - /// - /// Gets the Uri identifying the test extension. - /// - public string ExtensionUri + /// + /// Metadata for the test plugin + /// + public override ICollection Metadata + { + get { - get; - private set; + return new object[] { ExtensionUri }; } + } - /// - /// Helper to get the Uri from the ExtensionUriAttribute on logger plugin. - /// - /// Data type of the test logger - /// Uri identifying the test logger - private static string GetExtensionUri(Type testLoggerType) - { - string extensionUri = string.Empty; + /// + /// Gets the Uri identifying the test extension. + /// + public string ExtensionUri + { + get; + private set; + } - object[] attributes = testLoggerType.GetTypeInfo().GetCustomAttributes(typeof(ExtensionUriAttribute), false).ToArray(); - if (attributes != null && attributes.Length > 0) - { - ExtensionUriAttribute extensionUriAttribute = (ExtensionUriAttribute)attributes[0]; + /// + /// Helper to get the Uri from the ExtensionUriAttribute on logger plugin. + /// + /// Data type of the test logger + /// Uri identifying the test logger + private static string GetExtensionUri(Type testLoggerType) + { + string extensionUri = string.Empty; - if (!string.IsNullOrEmpty(extensionUriAttribute.ExtensionUri)) - { - extensionUri = extensionUriAttribute.ExtensionUri; - } - } + object[] attributes = testLoggerType.GetTypeInfo().GetCustomAttributes(typeof(ExtensionUriAttribute), false).ToArray(); + if (attributes != null && attributes.Length > 0) + { + ExtensionUriAttribute extensionUriAttribute = (ExtensionUriAttribute)attributes[0]; - if (EqtTrace.IsErrorEnabled && string.IsNullOrEmpty(extensionUri)) + if (!string.IsNullOrEmpty(extensionUriAttribute.ExtensionUri)) { - EqtTrace.Error("The type \"{0}\" defined in \"{1}\" does not have ExtensionUri attribute.", testLoggerType.ToString(), testLoggerType.GetTypeInfo().Module.Name); + extensionUri = extensionUriAttribute.ExtensionUri; } + } - return extensionUri; + if (EqtTrace.IsErrorEnabled && string.IsNullOrEmpty(extensionUri)) + { + EqtTrace.Error("The type \"{0}\" defined in \"{1}\" does not have ExtensionUri attribute.", testLoggerType.ToString(), testLoggerType.GetTypeInfo().Module.Name); } + + return extensionUri; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensions.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensions.cs index ea0a52a4f5..e6057b76ac 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensions.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensions.cs @@ -1,401 +1,402 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities +namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +using DataCollector; + +using ObjectModel; + +using PlatformAbstractions; + +/// +/// The test extension information. +/// +public class TestExtensions { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Reflection; + #region Properties - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + /// + /// Gets or sets test discoverer extensions. + /// + internal Dictionary TestDiscoverers { get; set; } /// - /// The test extension information. + /// Gets or sets a value indicating whether are test discoverers cached. /// - public class TestExtensions - { - #region Properties - - /// - /// Gets or sets test discoverer extensions. - /// - internal Dictionary TestDiscoverers { get; set; } - - /// - /// Gets or sets a value indicating whether are test discoverers cached. - /// - internal bool AreTestDiscoverersCached { get; set; } - - /// - /// Gets or sets test executor extensions. - /// - internal Dictionary TestExecutors { get; set; } - - /// - /// Gets or sets a value indicating whether are test executors cached. - /// - internal bool AreTestExecutorsCached { get; set; } - - /// - /// Gets or sets test executor 2 extensions. - /// - internal Dictionary TestExecutors2 { get; set; } - - /// - /// Gets or sets a value indicating whether are test executors 2 cached. - /// - internal bool AreTestExecutors2Cached { get; set; } - - /// - /// Gets or sets test setting provider extensions. - /// - internal Dictionary TestSettingsProviders { get; set; } - - /// - /// Gets or sets a value indicating whether are test settings providers cached. - /// - internal bool AreTestSettingsProvidersCached { get; set; } - - /// - /// Gets or sets test logger extensions. - /// - internal Dictionary TestLoggers { get; set; } - - /// - /// Gets or sets a value indicating whether are test loggers cached. - /// - internal bool AreTestLoggersCached { get; set; } - - /// - /// Gets or sets test logger extensions. - /// - internal Dictionary TestHosts { get; set; } - - /// - /// Gets or sets a value indicating whether are test hosts cached. - /// - internal bool AreTestHostsCached { get; set; } - - /// - /// Gets or sets data collectors extensions. - /// - internal Dictionary DataCollectors { get; set; } - - /// - /// Gets or sets a value indicating whether are test hosts cached. - /// - internal bool AreDataCollectorsCached { get; set; } - - #endregion - - #region Internal methods - - /// - /// Adds the extensions specified to the current set of extensions. - /// - /// - /// Type of plugin info. - /// - /// - /// The info about new extensions discovered - /// - /// - /// The of extensions discovered - /// - internal Dictionary AddExtension( - Dictionary newExtensions) where TPluginInfo : TestPluginInformation - { - var existingExtensions = this.GetTestExtensionCache(); - if (newExtensions == null) - { - return existingExtensions; - } + internal bool AreTestDiscoverersCached { get; set; } - if (existingExtensions == null) - { - this.SetTestExtensionCache(newExtensions); - return newExtensions; - } + /// + /// Gets or sets test executor extensions. + /// + internal Dictionary TestExecutors { get; set; } - foreach (var extension in newExtensions) - { - if (existingExtensions.ContainsKey(extension.Key)) - { - EqtTrace.Warning( - "TestExtensions.AddExtensions: Attempt to add multiple test extensions with identifier data '{0}'", - extension.Key); - } - else - { - existingExtensions.Add(extension.Key, extension.Value); - } - } + /// + /// Gets or sets a value indicating whether are test executors cached. + /// + internal bool AreTestExecutorsCached { get; set; } - return existingExtensions; - } + /// + /// Gets or sets test executor 2 extensions. + /// + internal Dictionary TestExecutors2 { get; set; } - /// - /// Gets the extensions already discovered that are defined in the specified assembly. - /// - /// The extension assembly. - /// The test extensions defined the extension assembly if it is already discovered. null if not. - internal TestExtensions GetExtensionsDiscoveredFromAssembly(string extensionAssembly) - { - var testExtensions = new TestExtensions(); - - testExtensions.TestDiscoverers = - this.GetExtensionsDiscoveredFromAssembly( - this.TestDiscoverers, - extensionAssembly); - testExtensions.TestExecutors = - this.GetExtensionsDiscoveredFromAssembly( - this.TestExecutors, - extensionAssembly); - testExtensions.TestExecutors2 = - this.GetExtensionsDiscoveredFromAssembly( - this.TestExecutors2, - extensionAssembly); - testExtensions.TestSettingsProviders = - this.GetExtensionsDiscoveredFromAssembly( - this.TestSettingsProviders, - extensionAssembly); - testExtensions.TestLoggers = - this.GetExtensionsDiscoveredFromAssembly( - this.TestLoggers, - extensionAssembly); - testExtensions.TestHosts = - this.GetExtensionsDiscoveredFromAssembly( - this.TestHosts, - extensionAssembly); - testExtensions.DataCollectors = - this.GetExtensionsDiscoveredFromAssembly( - this.DataCollectors, - extensionAssembly); - - if (testExtensions.TestDiscoverers.Any() - || testExtensions.TestExecutors.Any() - || testExtensions.TestExecutors2.Any() - || testExtensions.TestSettingsProviders.Any() - || testExtensions.TestLoggers.Any() - || testExtensions.TestHosts.Any() - || testExtensions.DataCollectors.Any()) - { - // This extension has already been discovered. - return testExtensions; - } + /// + /// Gets or sets a value indicating whether are test executors 2 cached. + /// + internal bool AreTestExecutors2Cached { get; set; } + + /// + /// Gets or sets test setting provider extensions. + /// + internal Dictionary TestSettingsProviders { get; set; } + + /// + /// Gets or sets a value indicating whether are test settings providers cached. + /// + internal bool AreTestSettingsProvidersCached { get; set; } + + /// + /// Gets or sets test logger extensions. + /// + internal Dictionary TestLoggers { get; set; } - return null; + /// + /// Gets or sets a value indicating whether are test loggers cached. + /// + internal bool AreTestLoggersCached { get; set; } + + /// + /// Gets or sets test logger extensions. + /// + internal Dictionary TestHosts { get; set; } + + /// + /// Gets or sets a value indicating whether are test hosts cached. + /// + internal bool AreTestHostsCached { get; set; } + + /// + /// Gets or sets data collectors extensions. + /// + internal Dictionary DataCollectors { get; set; } + + /// + /// Gets or sets a value indicating whether are test hosts cached. + /// + internal bool AreDataCollectorsCached { get; set; } + + #endregion + + #region Internal methods + + /// + /// Adds the extensions specified to the current set of extensions. + /// + /// + /// Type of plugin info. + /// + /// + /// The info about new extensions discovered + /// + /// + /// The of extensions discovered + /// + internal Dictionary AddExtension( + Dictionary newExtensions) where TPluginInfo : TestPluginInformation + { + var existingExtensions = GetTestExtensionCache(); + if (newExtensions == null) + { + return existingExtensions; } - internal Dictionary GetTestExtensionCache() where TPluginInfo : TestPluginInformation + if (existingExtensions == null) { - Type type = typeof(TPluginInfo); + SetTestExtensionCache(newExtensions); + return newExtensions; + } - if (type == typeof(TestDiscovererPluginInformation)) - { - return (Dictionary)(object)this.TestDiscoverers; - } - else if (type == typeof(TestExecutorPluginInformation)) - { - return (Dictionary)(object)this.TestExecutors; - } - else if (type == typeof(TestExecutorPluginInformation2)) - { - return (Dictionary)(object)this.TestExecutors2; - } - else if (type == typeof(TestLoggerPluginInformation)) - { - return (Dictionary)(object)this.TestLoggers; - } - else if (type == typeof(TestSettingsProviderPluginInformation)) - { - return (Dictionary)(object)this.TestSettingsProviders; - } - else if (type == typeof(TestRuntimePluginInformation)) + foreach (var extension in newExtensions) + { + if (existingExtensions.ContainsKey(extension.Key)) { - return (Dictionary)(object)this.TestHosts; + EqtTrace.Warning( + "TestExtensions.AddExtensions: Attempt to add multiple test extensions with identifier data '{0}'", + extension.Key); } - else if (type == typeof(DataCollectorConfig)) + else { - return (Dictionary)(object)this.DataCollectors; + existingExtensions.Add(extension.Key, extension.Value); } + } + + return existingExtensions; + } - return null; + /// + /// Gets the extensions already discovered that are defined in the specified assembly. + /// + /// The extension assembly. + /// The test extensions defined the extension assembly if it is already discovered. null if not. + internal TestExtensions GetExtensionsDiscoveredFromAssembly(string extensionAssembly) + { + var testExtensions = new TestExtensions(); + + testExtensions.TestDiscoverers = + GetExtensionsDiscoveredFromAssembly( + TestDiscoverers, + extensionAssembly); + testExtensions.TestExecutors = + GetExtensionsDiscoveredFromAssembly( + TestExecutors, + extensionAssembly); + testExtensions.TestExecutors2 = + GetExtensionsDiscoveredFromAssembly( + TestExecutors2, + extensionAssembly); + testExtensions.TestSettingsProviders = + GetExtensionsDiscoveredFromAssembly( + TestSettingsProviders, + extensionAssembly); + testExtensions.TestLoggers = + GetExtensionsDiscoveredFromAssembly( + TestLoggers, + extensionAssembly); + testExtensions.TestHosts = + GetExtensionsDiscoveredFromAssembly( + TestHosts, + extensionAssembly); + testExtensions.DataCollectors = + GetExtensionsDiscoveredFromAssembly( + DataCollectors, + extensionAssembly); + + if (testExtensions.TestDiscoverers.Any() + || testExtensions.TestExecutors.Any() + || testExtensions.TestExecutors2.Any() + || testExtensions.TestSettingsProviders.Any() + || testExtensions.TestLoggers.Any() + || testExtensions.TestHosts.Any() + || testExtensions.DataCollectors.Any()) + { + // This extension has already been discovered. + return testExtensions; } - /// - /// The are test extensions cached. - /// - /// - /// - /// - /// The . - /// - internal bool AreTestExtensionsCached() where TPluginInfo : TestPluginInformation + return null; + } + + internal Dictionary GetTestExtensionCache() where TPluginInfo : TestPluginInformation + { + Type type = typeof(TPluginInfo); + + if (type == typeof(TestDiscovererPluginInformation)) { - Type type = typeof(TPluginInfo); - - if (type == typeof(TestDiscovererPluginInformation)) - { - return this.AreTestDiscoverersCached; - } - else if (type == typeof(TestExecutorPluginInformation)) - { - return this.AreTestExecutorsCached; - } - else if (type == typeof(TestExecutorPluginInformation2)) - { - return this.AreTestExecutors2Cached; - } - else if (type == typeof(TestLoggerPluginInformation)) - { - return this.AreTestLoggersCached; - } - else if (type == typeof(TestSettingsProviderPluginInformation)) - { - return this.AreTestSettingsProvidersCached; - } - else if (type == typeof(TestRuntimePluginInformation)) - { - return this.AreTestHostsCached; - } - else if (type == typeof(DataCollectorConfig)) - { - return this.AreDataCollectorsCached; - } + return (Dictionary)(object)TestDiscoverers; + } + else if (type == typeof(TestExecutorPluginInformation)) + { + return (Dictionary)(object)TestExecutors; + } + else if (type == typeof(TestExecutorPluginInformation2)) + { + return (Dictionary)(object)TestExecutors2; + } + else if (type == typeof(TestLoggerPluginInformation)) + { + return (Dictionary)(object)TestLoggers; + } + else if (type == typeof(TestSettingsProviderPluginInformation)) + { + return (Dictionary)(object)TestSettingsProviders; + } + else if (type == typeof(TestRuntimePluginInformation)) + { + return (Dictionary)(object)TestHosts; + } + else if (type == typeof(DataCollectorConfig)) + { + return (Dictionary)(object)DataCollectors; + } + + return null; + } + + /// + /// The are test extensions cached. + /// + /// + /// + /// + /// The . + /// + internal bool AreTestExtensionsCached() where TPluginInfo : TestPluginInformation + { + Type type = typeof(TPluginInfo); - return false; + if (type == typeof(TestDiscovererPluginInformation)) + { + return AreTestDiscoverersCached; + } + else if (type == typeof(TestExecutorPluginInformation)) + { + return AreTestExecutorsCached; + } + else if (type == typeof(TestExecutorPluginInformation2)) + { + return AreTestExecutors2Cached; + } + else if (type == typeof(TestLoggerPluginInformation)) + { + return AreTestLoggersCached; + } + else if (type == typeof(TestSettingsProviderPluginInformation)) + { + return AreTestSettingsProvidersCached; + } + else if (type == typeof(TestRuntimePluginInformation)) + { + return AreTestHostsCached; + } + else if (type == typeof(DataCollectorConfig)) + { + return AreDataCollectorsCached; } - /// - /// The set test extensions cache status. - /// - /// - /// - internal void SetTestExtensionsCacheStatusToTrue() where TPluginInfo : TestPluginInformation + return false; + } + + /// + /// The set test extensions cache status. + /// + /// + /// + internal void SetTestExtensionsCacheStatusToTrue() where TPluginInfo : TestPluginInformation + { + Type type = typeof(TPluginInfo); + + if (type == typeof(TestDiscovererPluginInformation)) { - Type type = typeof(TPluginInfo); - - if (type == typeof(TestDiscovererPluginInformation)) - { - this.AreTestDiscoverersCached = true; - } - else if (type == typeof(TestExecutorPluginInformation)) - { - this.AreTestExecutorsCached = true; - } - else if (type == typeof(TestExecutorPluginInformation2)) - { - this.AreTestExecutors2Cached = true; - } - else if (type == typeof(TestLoggerPluginInformation)) - { - this.AreTestLoggersCached = true; - } - else if (type == typeof(TestSettingsProviderPluginInformation)) - { - this.AreTestSettingsProvidersCached = true; - } - else if (type == typeof(TestRuntimePluginInformation)) - { - this.AreTestHostsCached = true; - } - else if (type == typeof(DataCollectorConfig)) - { - this.AreDataCollectorsCached = true; - } + AreTestDiscoverersCached = true; + } + else if (type == typeof(TestExecutorPluginInformation)) + { + AreTestExecutorsCached = true; } + else if (type == typeof(TestExecutorPluginInformation2)) + { + AreTestExecutors2Cached = true; + } + else if (type == typeof(TestLoggerPluginInformation)) + { + AreTestLoggersCached = true; + } + else if (type == typeof(TestSettingsProviderPluginInformation)) + { + AreTestSettingsProvidersCached = true; + } + else if (type == typeof(TestRuntimePluginInformation)) + { + AreTestHostsCached = true; + } + else if (type == typeof(DataCollectorConfig)) + { + AreDataCollectorsCached = true; + } + } + + /// + /// The invalidate cache of plugin infos. + /// + internal void InvalidateCache() + { + AreTestDiscoverersCached = false; + AreTestExecutorsCached = false; + AreTestExecutors2Cached = false; + AreTestLoggersCached = false; + AreTestSettingsProvidersCached = false; + AreTestHostsCached = false; + AreDataCollectorsCached = false; + } - /// - /// The invalidate cache of plugin infos. - /// - internal void InvalidateCache() - { - this.AreTestDiscoverersCached = false; - this.AreTestExecutorsCached = false; - this.AreTestExecutors2Cached = false; - this.AreTestLoggersCached = false; - this.AreTestSettingsProvidersCached = false; - this.AreTestHostsCached = false; - this.AreDataCollectorsCached = false; - } - - /// - /// Gets extensions discovered from assembly. - /// - /// - /// The extension collection. - /// - /// - /// The extension assembly. - /// - /// - /// - /// - /// The . of extensions discovered in assembly - /// - internal Dictionary GetExtensionsDiscoveredFromAssembly( - Dictionary extensionCollection, - string extensionAssembly) - { - var extensions = new Dictionary(); - if (extensionCollection != null) + /// + /// Gets extensions discovered from assembly. + /// + /// + /// The extension collection. + /// + /// + /// The extension assembly. + /// + /// + /// + /// + /// The . of extensions discovered in assembly + /// + internal Dictionary GetExtensionsDiscoveredFromAssembly( + Dictionary extensionCollection, + string extensionAssembly) + { + var extensions = new Dictionary(); + if (extensionCollection != null) + { + foreach (var extension in extensionCollection) { - foreach (var extension in extensionCollection) + var testPluginInformation = extension.Value as TestPluginInformation; + var extensionType = Type.GetType(testPluginInformation?.AssemblyQualifiedName); + if (string.Equals(extensionType.GetTypeInfo().Assembly.GetAssemblyLocation(), extensionAssembly)) { - var testPluginInformation = extension.Value as TestPluginInformation; - var extensionType = Type.GetType(testPluginInformation?.AssemblyQualifiedName); - if (string.Equals(extensionType.GetTypeInfo().Assembly.GetAssemblyLocation(), extensionAssembly)) - { - extensions.Add(extension.Key, extension.Value); - } + extensions.Add(extension.Key, extension.Value); } } - - return extensions; } - #endregion + return extensions; + } - #region Private methods + #endregion - private void SetTestExtensionCache(Dictionary testPluginInfos) where TPluginInfo : TestPluginInformation - { - Type type = typeof(TPluginInfo); + #region Private methods - if (type == typeof(TestDiscovererPluginInformation)) - { - this.TestDiscoverers = (Dictionary)(object)testPluginInfos; - } - else if (type == typeof(TestExecutorPluginInformation)) - { - this.TestExecutors = (Dictionary)(object)testPluginInfos; - } - else if (type == typeof(TestExecutorPluginInformation2)) - { - this.TestExecutors2 = (Dictionary)(object)testPluginInfos; - } - else if (type == typeof(TestLoggerPluginInformation)) - { - this.TestLoggers = (Dictionary)(object)testPluginInfos; - } - else if (type == typeof(TestSettingsProviderPluginInformation)) - { - this.TestSettingsProviders = (Dictionary)(object)testPluginInfos; - } - else if (type == typeof(TestRuntimePluginInformation)) - { - this.TestHosts = (Dictionary)(object)testPluginInfos; - } - else if (type == typeof(DataCollectorConfig)) - { - this.DataCollectors = (Dictionary)(object)testPluginInfos; - } - } + private void SetTestExtensionCache(Dictionary testPluginInfos) where TPluginInfo : TestPluginInformation + { + Type type = typeof(TPluginInfo); - #endregion + if (type == typeof(TestDiscovererPluginInformation)) + { + TestDiscoverers = (Dictionary)(object)testPluginInfos; + } + else if (type == typeof(TestExecutorPluginInformation)) + { + TestExecutors = (Dictionary)(object)testPluginInfos; + } + else if (type == typeof(TestExecutorPluginInformation2)) + { + TestExecutors2 = (Dictionary)(object)testPluginInfos; + } + else if (type == typeof(TestLoggerPluginInformation)) + { + TestLoggers = (Dictionary)(object)testPluginInfos; + } + else if (type == typeof(TestSettingsProviderPluginInformation)) + { + TestSettingsProviders = (Dictionary)(object)testPluginInfos; + } + else if (type == typeof(TestRuntimePluginInformation)) + { + TestHosts = (Dictionary)(object)testPluginInfos; + } + else if (type == typeof(DataCollectorConfig)) + { + DataCollectors = (Dictionary)(object)testPluginInfos; + } } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestLoggerPluginInformation.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestLoggerPluginInformation.cs index e8e8268346..282d592ce5 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestLoggerPluginInformation.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestLoggerPluginInformation.cs @@ -1,71 +1,70 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Reflection; +namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; - using ObjectModel; +using ObjectModel; +/// +/// The test logger plugin information. +/// +internal class TestLoggerPluginInformation : TestExtensionPluginInformation +{ /// - /// The test logger plugin information. + /// Default constructor /// - internal class TestLoggerPluginInformation : TestExtensionPluginInformation + /// The test Logger Type. + public TestLoggerPluginInformation(Type testLoggerType) + : base(testLoggerType) { - /// - /// Default constructor - /// - /// The test Logger Type. - public TestLoggerPluginInformation(Type testLoggerType) - : base(testLoggerType) - { - this.FriendlyName = GetFriendlyName(testLoggerType); - } + FriendlyName = GetFriendlyName(testLoggerType); + } - /// - /// Gets the Friendly Name identifying the logger - /// - public string FriendlyName - { - get; - private set; - } + /// + /// Gets the Friendly Name identifying the logger + /// + public string FriendlyName + { + get; + private set; + } - /// - /// Metadata for the test plugin - /// - public override ICollection Metadata + /// + /// Metadata for the test plugin + /// + public override ICollection Metadata + { + get { - get - { - return new Object[] { this.ExtensionUri, this.FriendlyName }; - } + return new Object[] { ExtensionUri, FriendlyName }; } + } + + /// + /// Helper to get the FriendlyName from the FriendlyNameAttribute on logger plugin. + /// + /// Data type of the test logger + /// FriendlyName identifying the test logger + private static string GetFriendlyName(Type testLoggerType) + { + string friendlyName = string.Empty; - /// - /// Helper to get the FriendlyName from the FriendlyNameAttribute on logger plugin. - /// - /// Data type of the test logger - /// FriendlyName identifying the test logger - private static string GetFriendlyName(Type testLoggerType) + object[] attributes = testLoggerType.GetTypeInfo().GetCustomAttributes(typeof(FriendlyNameAttribute), false).ToArray(); + if (attributes != null && attributes.Length > 0) { - string friendlyName = string.Empty; + FriendlyNameAttribute friendlyNameAttribute = (FriendlyNameAttribute)attributes[0]; - object[] attributes = testLoggerType.GetTypeInfo().GetCustomAttributes(typeof(FriendlyNameAttribute), false).ToArray(); - if (attributes != null && attributes.Length > 0) + if (!string.IsNullOrEmpty(friendlyNameAttribute.FriendlyName)) { - FriendlyNameAttribute friendlyNameAttribute = (FriendlyNameAttribute)attributes[0]; - - if (!string.IsNullOrEmpty(friendlyNameAttribute.FriendlyName)) - { - friendlyName = friendlyNameAttribute.FriendlyName; - } + friendlyName = friendlyNameAttribute.FriendlyName; } - - return friendlyName; } + + return friendlyName; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestPluginInformation.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestPluginInformation.cs index d78e28ed02..32a056de4f 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestPluginInformation.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestPluginInformation.cs @@ -1,63 +1,62 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities -{ - using System; - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; + +using System; +using System.Collections.Generic; - public abstract class TestPluginInformation +public abstract class TestPluginInformation +{ + /// + /// Default constructor + /// + /// Data type of the test plugin + protected TestPluginInformation(Type testExtensionType) { - /// - /// Default constructor - /// - /// Data type of the test plugin - protected TestPluginInformation(Type testExtensionType) + if (testExtensionType != null) { - if (testExtensionType != null) - { - this.AssemblyQualifiedName = testExtensionType.AssemblyQualifiedName; - } + AssemblyQualifiedName = testExtensionType.AssemblyQualifiedName; } + } - /// - /// Gets data value identifying the test plugin - /// - public virtual string IdentifierData + /// + /// Gets data value identifying the test plugin + /// + public virtual string IdentifierData + { + get { - get - { - return this.AssemblyQualifiedName; - } + return AssemblyQualifiedName; } + } - /// - /// Metadata for the test plugin - /// - public virtual ICollection Metadata + /// + /// Metadata for the test plugin + /// + public virtual ICollection Metadata + { + get { - get - { - return new object[] { this.AssemblyQualifiedName }; - } + return new object[] { AssemblyQualifiedName }; } + } - /// - /// Gets the Assembly qualified name of the plugin - /// - public string AssemblyQualifiedName - { - get; - private set; - } + /// + /// Gets the Assembly qualified name of the plugin + /// + public string AssemblyQualifiedName + { + get; + private set; + } - /// - /// Gets the file path of the plugin - /// - public string FilePath - { - get; - internal set; - } + /// + /// Gets the file path of the plugin + /// + public string FilePath + { + get; + internal set; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestRunTimePluginInformation.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestRunTimePluginInformation.cs index fc529d5c26..185cb18a8d 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestRunTimePluginInformation.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestRunTimePluginInformation.cs @@ -1,71 +1,70 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Reflection; +namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using ObjectModel; +/// +/// The test host plugin information. +/// +internal class TestRuntimePluginInformation : TestExtensionPluginInformation +{ /// - /// The test host plugin information. + /// Default constructor /// - internal class TestRuntimePluginInformation : TestExtensionPluginInformation + /// The testhost Type. + public TestRuntimePluginInformation(Type testHostType) + : base(testHostType) { - /// - /// Default constructor - /// - /// The testhost Type. - public TestRuntimePluginInformation(Type testHostType) - : base(testHostType) - { - this.FriendlyName = GetFriendlyName(testHostType); - } + FriendlyName = GetFriendlyName(testHostType); + } - /// - /// Gets the Friendly Name identifying the testhost - /// - public string FriendlyName - { - get; - private set; - } + /// + /// Gets the Friendly Name identifying the testhost + /// + public string FriendlyName + { + get; + private set; + } - /// - /// Metadata for the testhost plugin - /// - public override ICollection Metadata + /// + /// Metadata for the testhost plugin + /// + public override ICollection Metadata + { + get { - get - { - return new Object[] { this.ExtensionUri, this.FriendlyName }; - } + return new Object[] { ExtensionUri, FriendlyName }; } + } + + /// + /// Helper to get the FriendlyName from the FriendlyNameAttribute on testhost plugin. + /// + /// Data type of the testhost + /// FriendlyName identifying the testhost + private static string GetFriendlyName(Type testHostType) + { + string friendlyName = string.Empty; - /// - /// Helper to get the FriendlyName from the FriendlyNameAttribute on testhost plugin. - /// - /// Data type of the testhost - /// FriendlyName identifying the testhost - private static string GetFriendlyName(Type testHostType) + object[] attributes = testHostType.GetTypeInfo().GetCustomAttributes(typeof(FriendlyNameAttribute), false).ToArray(); + if (attributes != null && attributes.Length > 0) { - string friendlyName = string.Empty; + FriendlyNameAttribute friendlyNameAttribute = (FriendlyNameAttribute)attributes[0]; - object[] attributes = testHostType.GetTypeInfo().GetCustomAttributes(typeof(FriendlyNameAttribute), false).ToArray(); - if (attributes != null && attributes.Length > 0) + if (!string.IsNullOrEmpty(friendlyNameAttribute.FriendlyName)) { - FriendlyNameAttribute friendlyNameAttribute = (FriendlyNameAttribute)attributes[0]; - - if (!string.IsNullOrEmpty(friendlyNameAttribute.FriendlyName)) - { - friendlyName = friendlyNameAttribute.FriendlyName; - } + friendlyName = friendlyNameAttribute.FriendlyName; } - - return friendlyName; } + + return friendlyName; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestSettingsProviderPluginInformation.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestSettingsProviderPluginInformation.cs index 0946b14ab8..9637edcd7d 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestSettingsProviderPluginInformation.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestSettingsProviderPluginInformation.cs @@ -1,85 +1,84 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Reflection; +namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; - using ObjectModel; +using ObjectModel; +/// +/// The test settings provider plugin information. +/// +internal class TestSettingsProviderPluginInformation : TestPluginInformation +{ /// - /// The test settings provider plugin information. + /// Default constructor /// - internal class TestSettingsProviderPluginInformation : TestPluginInformation + /// The test Settings Provider Type. + public TestSettingsProviderPluginInformation(Type testSettingsProviderType) + : base(testSettingsProviderType) { - /// - /// Default constructor - /// - /// The test Settings Provider Type. - public TestSettingsProviderPluginInformation(Type testSettingsProviderType) - : base(testSettingsProviderType) + if (testSettingsProviderType != null) { - if (testSettingsProviderType != null) - { - this.SettingsName = GetTestSettingsName(testSettingsProviderType); - } + SettingsName = GetTestSettingsName(testSettingsProviderType); } + } - /// - /// Gets data value identifying the test plugin - /// - public override string IdentifierData + /// + /// Gets data value identifying the test plugin + /// + public override string IdentifierData + { + get { - get - { - return this.SettingsName; - } + return SettingsName; } + } - /// - /// Metadata for the test plugin - /// - public override ICollection Metadata + /// + /// Metadata for the test plugin + /// + public override ICollection Metadata + { + get { - get - { - return new object[] { this.SettingsName }; - } + return new object[] { SettingsName }; } + } - /// - /// Gets name of test settings supported by plugin. - /// - public string SettingsName - { - get; - private set; - } + /// + /// Gets name of test settings supported by plugin. + /// + public string SettingsName + { + get; + private set; + } - /// - /// Helper to get the test settings name from SettingsNameAttribute on test setting provider plugin. - /// - /// Data type of test setting provider - /// Test settings name supported by plugin - private static string GetTestSettingsName(Type testSettingsProviderType) + /// + /// Helper to get the test settings name from SettingsNameAttribute on test setting provider plugin. + /// + /// Data type of test setting provider + /// Test settings name supported by plugin + private static string GetTestSettingsName(Type testSettingsProviderType) + { + string settingName = string.Empty; + + object[] attributes = testSettingsProviderType.GetTypeInfo().GetCustomAttributes(typeof(SettingsNameAttribute), false).ToArray(); + if (attributes != null && attributes.Length > 0) { - string settingName = string.Empty; + SettingsNameAttribute settingsNameAttribute = (SettingsNameAttribute)attributes[0]; - object[] attributes = testSettingsProviderType.GetTypeInfo().GetCustomAttributes(typeof(SettingsNameAttribute), false).ToArray(); - if (attributes != null && attributes.Length > 0) + if (!string.IsNullOrEmpty(settingsNameAttribute.SettingsName)) { - SettingsNameAttribute settingsNameAttribute = (SettingsNameAttribute)attributes[0]; - - if (!string.IsNullOrEmpty(settingsNameAttribute.SettingsName)) - { - settingName = settingsNameAttribute.SettingsName; - } + settingName = settingsNameAttribute.SettingsName; } - - return settingName; } + + return settingName; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/VSExtensionManager.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/VSExtensionManager.cs index 635004ea45..2da554bddc 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/VSExtensionManager.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/VSExtensionManager.cs @@ -1,215 +1,213 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework +namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Reflection; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Interfaces; +using Resources; + +/// +/// Manager for VisualStudio based extensions +/// +public class VSExtensionManager : IVSExtensionManager { - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Reflection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Resources; + private const string ExtensionManagerService = "Microsoft.VisualStudio.ExtensionManager.ExtensionManagerService"; + private const string ExtensionManagerAssemblyName = @"Microsoft.VisualStudio.ExtensionManager"; + private const string ExtensionManagerImplAssemblyName = @"Microsoft.VisualStudio.ExtensionManager.Implementation"; - /// - /// Manager for VisualStudio based extensions - /// - public class VSExtensionManager : IVSExtensionManager - { - private const string ExtensionManagerService = "Microsoft.VisualStudio.ExtensionManager.ExtensionManagerService"; - private const string ExtensionManagerAssemblyName = @"Microsoft.VisualStudio.ExtensionManager"; - private const string ExtensionManagerImplAssemblyName = @"Microsoft.VisualStudio.ExtensionManager.Implementation"; + private const string SettingsManagerTypeName = "Microsoft.VisualStudio.Settings.ExternalSettingsManager"; + private const string SettingsManagerAssemblyName = @"Microsoft.VisualStudio.Settings.15.0"; - private const string SettingsManagerTypeName = "Microsoft.VisualStudio.Settings.ExternalSettingsManager"; - private const string SettingsManagerAssemblyName = @"Microsoft.VisualStudio.Settings.15.0"; + private readonly IFileHelper _fileHelper; - private readonly IFileHelper fileHelper; + private Assembly _extensionManagerAssembly; + private Assembly _extensionManagerImplAssembly; + private Type _extensionManagerServiceType; - private Assembly extensionManagerAssembly; - private Assembly extensionManagerImplAssembly; - private Type extensionManagerServiceType; + private Assembly _settingsManagerAssembly; + private Type _settingsManagerType; + + /// + /// Default constructor for manager for Visual Studio based extensions + /// + public VSExtensionManager() + : this(new FileHelper()) + { + } - private Assembly settingsManagerAssembly; - private Type settingsManagerType; + internal VSExtensionManager(IFileHelper fileHelper) + { + _fileHelper = fileHelper; + } - /// - /// Default constructor for manager for Visual Studio based extensions - /// - public VSExtensionManager() : this(new FileHelper()) + /// + /// Get the available unit test extensions installed. + /// If no extensions are installed then it returns an empty list. + /// + /// + public IEnumerable GetUnitTestExtensions() + { + try { + return GetTestExtensionsInternal(Constants.UnitTestExtensionType); } - - internal VSExtensionManager(IFileHelper fileHelper) + catch (Exception ex) { - this.fileHelper = fileHelper; + string message = string.Format(CultureInfo.CurrentCulture, Resources.FailedToFindInstalledUnitTestExtensions, ex); + throw new TestPlatformException(message, ex); } + } + + /// + /// Get the unit tests extensions + /// + private IEnumerable GetTestExtensionsInternal(string extensionType) + { + IEnumerable installedExtensions = new List(); - /// - /// Get the available unit test extensions installed. - /// If no extensions are installed then it returns an empty list. - /// - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - public IEnumerable GetUnitTestExtensions() + // Navigate up to the IDE folder + // In case of xcopyable vstest.console, this functionality is not supported. + var installContext = new InstallationContext(_fileHelper); + if (!installContext.TryGetVisualStudioDirectory(out string vsInstallPath)) { - try - { - return GetTestExtensionsInternal(Constants.UnitTestExtensionType); - } - catch (Exception ex) - { - string message = string.Format(CultureInfo.CurrentCulture, Resources.FailedToFindInstalledUnitTestExtensions, ex); - throw new TestPlatformException(message, ex); - } + throw new TestPlatformException(string.Format(CultureInfo.CurrentCulture, Resources.VSInstallationNotFound)); } - /// - /// Get the unit tests extensions - /// - private IEnumerable GetTestExtensionsInternal(string extensionType) + // Adding resolution paths for resolving dependencies. + var resolutionPaths = installContext.GetVisualStudioCommonLocations(vsInstallPath); + using (var assemblyResolver = new AssemblyResolver(resolutionPaths)) { - IEnumerable installedExtensions = new List(); + object extensionManager; + object settingsManager; - // Navigate up to the IDE folder - // In case of xcopyable vstest.console, this functionality is not supported. - var installContext = new InstallationContext(this.fileHelper); - if (!installContext.TryGetVisualStudioDirectory(out string vsInstallPath)) + settingsManager = SettingsManagerType.GetMethod("CreateForApplication", new Type[] { typeof(String) }).Invoke(null, new object[] { installContext.GetVisualStudioPath(vsInstallPath) }); + if (settingsManager != null) { - throw new TestPlatformException(string.Format(CultureInfo.CurrentCulture, Resources.VSInstallationNotFound)); - } - - // Adding resolution paths for resolving dependencies. - var resolutionPaths = installContext.GetVisualStudioCommonLocations(vsInstallPath); - using (var assemblyResolver = new AssemblyResolver(resolutionPaths)) - { - object extensionManager; - object settingsManager; - - settingsManager = SettingsManagerType.GetMethod("CreateForApplication", new Type[] { typeof(String) }).Invoke(null, new object[] { installContext.GetVisualStudioPath(vsInstallPath) }); - if (settingsManager != null) + try { - try - { - // create extension manager - extensionManager = Activator.CreateInstance(ExtensionManagerServiceType, settingsManager); + // create extension manager + extensionManager = Activator.CreateInstance(ExtensionManagerServiceType, settingsManager); - if (extensionManager != null) - { - installedExtensions = ExtensionManagerServiceType.GetMethod("GetEnabledExtensionContentLocations", new Type[] { typeof(String) }).Invoke( - extensionManager, new object[] { extensionType }) as IEnumerable; - } - else - { - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning("VSExtensionManager : Unable to create extension manager"); - } - } + if (extensionManager != null) + { + installedExtensions = ExtensionManagerServiceType.GetMethod("GetEnabledExtensionContentLocations", new Type[] { typeof(String) }).Invoke( + extensionManager, new object[] { extensionType }) as IEnumerable; } - finally + else { - // Dispose the settings manager - IDisposable disposable = (settingsManager as IDisposable); - if (disposable != null) + if (EqtTrace.IsWarningEnabled) { - disposable.Dispose(); + EqtTrace.Warning("VSExtensionManager : Unable to create extension manager"); } } } - else + finally { - if(EqtTrace.IsWarningEnabled) + // Dispose the settings manager + IDisposable disposable = (settingsManager as IDisposable); + if (disposable != null) { - EqtTrace.Warning("VSExtensionManager : Unable to create settings manager"); + disposable.Dispose(); } } } - - return installedExtensions; - } - - /// - /// Used to explicitly load Microsoft.VisualStudio.ExtensionManager.dll - /// - private Assembly ExtensionManagerDefAssembly - { - get + else { - if (extensionManagerAssembly == null) + if (EqtTrace.IsWarningEnabled) { - extensionManagerAssembly = Assembly.Load(new AssemblyName(ExtensionManagerAssemblyName)); + EqtTrace.Warning("VSExtensionManager : Unable to create settings manager"); } - return extensionManagerAssembly; } } - /// - /// Used to explicitly load Microsoft.VisualStudio.ExtensionManager.Implementation.dll - /// - private Assembly ExtensionManagerImplAssembly + return installedExtensions; + } + + /// + /// Used to explicitly load Microsoft.VisualStudio.ExtensionManager.dll + /// + private Assembly ExtensionManagerDefAssembly + { + get { - get + if (_extensionManagerAssembly == null) { - if (extensionManagerImplAssembly == null) - { - // Make sure ExtensionManager assembly is already loaded. - Assembly extensionMgrAssembly = ExtensionManagerDefAssembly; - if (extensionMgrAssembly != null) - { - extensionManagerImplAssembly = Assembly.Load(new AssemblyName(ExtensionManagerImplAssemblyName)); - } - } - - return extensionManagerImplAssembly; + _extensionManagerAssembly = Assembly.Load(new AssemblyName(ExtensionManagerAssemblyName)); } + return _extensionManagerAssembly; } + } - /// - /// Returns the Type of ExtensionManagerService. - /// - private Type ExtensionManagerServiceType + /// + /// Used to explicitly load Microsoft.VisualStudio.ExtensionManager.Implementation.dll + /// + private Assembly ExtensionManagerImplAssembly + { + get { - get + if (_extensionManagerImplAssembly == null) { - if (extensionManagerServiceType == null) + // Make sure ExtensionManager assembly is already loaded. + Assembly extensionMgrAssembly = ExtensionManagerDefAssembly; + if (extensionMgrAssembly != null) { - extensionManagerServiceType = ExtensionManagerImplAssembly.GetType(ExtensionManagerService); + _extensionManagerImplAssembly = Assembly.Load(new AssemblyName(ExtensionManagerImplAssemblyName)); } - return extensionManagerServiceType; } + + return _extensionManagerImplAssembly; } + } - /// - /// Used to explicitly load Microsoft.VisualStudio.Settings.15.0.dll - /// - private Assembly SettingsManagerAssembly + /// + /// Returns the Type of ExtensionManagerService. + /// + private Type ExtensionManagerServiceType + { + get { - get + if (_extensionManagerServiceType == null) { - if (settingsManagerAssembly == null) - { - settingsManagerAssembly = Assembly.Load(new AssemblyName(SettingsManagerAssemblyName)); - } - - return settingsManagerAssembly; + _extensionManagerServiceType = ExtensionManagerImplAssembly.GetType(ExtensionManagerService); } + return _extensionManagerServiceType; } + } - private Type SettingsManagerType + /// + /// Used to explicitly load Microsoft.VisualStudio.Settings.15.0.dll + /// + private Assembly SettingsManagerAssembly + { + get { - get + if (_settingsManagerAssembly == null) { - if (settingsManagerType == null) - { - settingsManagerType = SettingsManagerAssembly.GetType(SettingsManagerTypeName); - } - - return settingsManagerType; + _settingsManagerAssembly = Assembly.Load(new AssemblyName(SettingsManagerAssemblyName)); } + + return _settingsManagerAssembly; } } -} + private Type SettingsManagerType + { + get + { + if (_settingsManagerType == null) + { + _settingsManagerType = SettingsManagerAssembly.GetType(SettingsManagerTypeName); + } + + return _settingsManagerType; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Filtering/Condition.cs b/src/Microsoft.TestPlatform.Common/Filtering/Condition.cs index 1020100988..6718e11c45 100644 --- a/src/Microsoft.TestPlatform.Common/Filtering/Condition.cs +++ b/src/Microsoft.TestPlatform.Common/Filtering/Condition.cs @@ -1,396 +1,391 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Filtering +namespace Microsoft.VisualStudio.TestPlatform.Common.Filtering; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using System.Text; + +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; + +using CommonResources = Resources.Resources; + +internal enum Operation +{ + Equal, + NotEqual, + Contains, + NotContains +} + +/// +/// Operator in order of precedence. +/// Precedence(And) > Precedence(Or) +/// Precedence of OpenBrace and CloseBrace operators is not used, instead parsing code takes care of same. +/// +internal enum Operator +{ + None, + Or, + And, + OpenBrace, + CloseBrace, +} + +/// +/// Represents a condition in filter expression. +/// +internal class Condition { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Globalization; - using System.Linq; - using System.Text; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using CommonResources = Microsoft.VisualStudio.TestPlatform.Common.Resources.Resources; - - internal enum Operation + #region Fields + + /// + /// Default property name which will be used when filter has only property value. + /// + public const string DefaultPropertyName = "FullyQualifiedName"; + + /// + /// Default operation which will be used when filter has only property value. + /// + public const Operation DefaultOperation = Operation.Contains; + + /// + /// Name of the property used in condition. + /// + internal string Name { - Equal, - NotEqual, - Contains, - NotContains + get; + private set; } /// - /// Operator in order of precedence. - /// Precedence(And) > Precedence(Or) - /// Precedence of OpenBrace and CloseBrace operators is not used, instead parsing code takes care of same. + /// Value for the property. /// - internal enum Operator + internal string Value { - None, - Or, - And, - OpenBrace, - CloseBrace, + get; + private set; } /// - /// Represents a condition in filter expression. + /// Operation to be performed. /// - internal class Condition + internal Operation Operation { - #region Fields - - /// - /// Default property name which will be used when filter has only property value. - /// - public const string DefaultPropertyName = "FullyQualifiedName"; - - /// - /// Default operation which will be used when filter has only property value. - /// - public const Operation DefaultOperation = Operation.Contains; - - /// - /// Name of the property used in condition. - /// - internal string Name - { - get; - private set; - } - - /// - /// Value for the property. - /// - internal string Value - { - get; - private set; - } - - /// - /// Operation to be performed. - /// - internal Operation Operation - { - get; - private set; - } - #endregion + get; + private set; + } + #endregion - #region Constructors - internal Condition(string name, Operation operation, string value) - { - this.Name = name; - this.Operation = operation; - this.Value = value; - } - #endregion + #region Constructors + internal Condition(string name, Operation operation, string value) + { + Name = name; + Operation = operation; + Value = value; + } + #endregion - /// - /// Evaluate this condition for testObject. - /// - internal bool Evaluate(Func propertyValueProvider) + /// + /// Evaluate this condition for testObject. + /// + internal bool Evaluate(Func propertyValueProvider) + { + ValidateArg.NotNull(propertyValueProvider, nameof(propertyValueProvider)); + var result = false; + var multiValue = GetPropertyValue(propertyValueProvider); + switch (Operation) { - ValidateArg.NotNull(propertyValueProvider, nameof(propertyValueProvider)); - var result = false; - var multiValue = this.GetPropertyValue(propertyValueProvider); - switch (this.Operation) - { - case Operation.Equal: - // if any value in multi-valued property matches 'this.Value', for Equal to evaluate true. - if (null != multiValue) + case Operation.Equal: + // if any value in multi-valued property matches 'this.Value', for Equal to evaluate true. + if (null != multiValue) + { + foreach (string propertyValue in multiValue) { - foreach (string propertyValue in multiValue) + result = result || string.Equals(propertyValue, Value, StringComparison.OrdinalIgnoreCase); + if (result) { - result = result || string.Equals(propertyValue, Value, StringComparison.OrdinalIgnoreCase); - if (result) - { - break; - } + break; } } - break; + } + break; - case Operation.NotEqual: - // all values in multi-valued property should not match 'this.Value' for NotEqual to evaluate true. - result = true; + case Operation.NotEqual: + // all values in multi-valued property should not match 'this.Value' for NotEqual to evaluate true. + result = true; - // if value is null. - if (null != multiValue) + // if value is null. + if (null != multiValue) + { + foreach (string propertyValue in multiValue) { - foreach (string propertyValue in multiValue) + result = result && !string.Equals(propertyValue, Value, StringComparison.OrdinalIgnoreCase); + if (!result) { - result = result && !string.Equals(propertyValue, Value, StringComparison.OrdinalIgnoreCase); - if (!result) - { - break; - } + break; } } - break; + } + break; - case Operation.Contains: - // if any value in multi-valued property contains 'this.Value' for 'Contains' to be true. - if (null != multiValue) + case Operation.Contains: + // if any value in multi-valued property contains 'this.Value' for 'Contains' to be true. + if (null != multiValue) + { + foreach (string propertyValue in multiValue) { - foreach (string propertyValue in multiValue) + Debug.Assert(null != propertyValue, "PropertyValue can not be null."); + result = result || propertyValue.IndexOf(Value, StringComparison.OrdinalIgnoreCase) != -1; + if (result) { - Debug.Assert(null != propertyValue, "PropertyValue can not be null."); - result = result || propertyValue.IndexOf(Value, StringComparison.OrdinalIgnoreCase) != -1; - if (result) - { - break; - } + break; } } - break; + } + break; - case Operation.NotContains: - // all values in multi-valued property should not contain 'this.Value' for NotContains to evaluate true. - result = true; + case Operation.NotContains: + // all values in multi-valued property should not contain 'this.Value' for NotContains to evaluate true. + result = true; - if (null != multiValue) + if (null != multiValue) + { + foreach (string propertyValue in multiValue) { - foreach (string propertyValue in multiValue) + Debug.Assert(null != propertyValue, "PropertyValue can not be null."); + result = result && propertyValue.IndexOf(Value, StringComparison.OrdinalIgnoreCase) == -1; + if (!result) { - Debug.Assert(null != propertyValue, "PropertyValue can not be null."); - result = result && propertyValue.IndexOf(Value, StringComparison.OrdinalIgnoreCase) == -1; - if (!result) - { - break; - } + break; } } - break; - } - return result; + } + break; } + return result; + } - /// - /// Returns a condition object after parsing input string of format 'Operation' - /// - internal static Condition Parse(string conditionString) + /// + /// Returns a condition object after parsing input string of format 'Operation' + /// + internal static Condition Parse(string conditionString) + { + if (string.IsNullOrWhiteSpace(conditionString)) { - if (string.IsNullOrWhiteSpace(conditionString)) - { - ThrownFormatExceptionForInvalidCondition(conditionString); - } + ThrownFormatExceptionForInvalidCondition(conditionString); + } - var parts = TokenizeFilterConditionString(conditionString).ToArray(); - if (parts.Length == 1) - { - // If only parameter values is passed, create condition with default property name, - // default operation and given condition string as parameter value. - return new Condition(Condition.DefaultPropertyName, Condition.DefaultOperation, FilterHelper.Unescape(conditionString.Trim())); - } + var parts = TokenizeFilterConditionString(conditionString).ToArray(); + if (parts.Length == 1) + { + // If only parameter values is passed, create condition with default property name, + // default operation and given condition string as parameter value. + return new Condition(DefaultPropertyName, DefaultOperation, FilterHelper.Unescape(conditionString.Trim())); + } + + if (parts.Length != 3) + { + ThrownFormatExceptionForInvalidCondition(conditionString); + } - if (parts.Length != 3) + for (int index = 0; index < 3; index++) + { + if (string.IsNullOrWhiteSpace(parts[index])) { ThrownFormatExceptionForInvalidCondition(conditionString); } + parts[index] = parts[index].Trim(); + } - for (int index = 0; index < 3; index++) - { - if (string.IsNullOrWhiteSpace(parts[index])) - { - ThrownFormatExceptionForInvalidCondition(conditionString); - } - parts[index] = parts[index].Trim(); - } + Operation operation = GetOperator(parts[1]); + Condition condition = new(parts[0], operation, FilterHelper.Unescape(parts[2])); + return condition; + } - Operation operation = GetOperator(parts[1]); - Condition condition = new Condition(parts[0], operation, FilterHelper.Unescape(parts[2])); - return condition; - } + private static void ThrownFormatExceptionForInvalidCondition(string conditionString) + { + throw new FormatException(string.Format(CultureInfo.CurrentCulture, CommonResources.TestCaseFilterFormatException, + string.Format(CultureInfo.CurrentCulture, CommonResources.InvalidCondition, conditionString))); + } - private static void ThrownFormatExceptionForInvalidCondition(string conditionString) - { - throw new FormatException(string.Format(CultureInfo.CurrentCulture, CommonResources.TestCaseFilterFormatException, - string.Format(CultureInfo.CurrentCulture, CommonResources.InvalidCondition, conditionString))); - } + /// + /// Check if condition validates any property in properties. + /// + internal bool ValidForProperties(IEnumerable properties, Func propertyProvider) + { + bool valid = false; - /// - /// Check if condition validates any property in properties. - /// - internal bool ValidForProperties(IEnumerable properties, Func propertyProvider) + if (properties.Contains(Name, StringComparer.OrdinalIgnoreCase)) { - bool valid = false; + valid = true; - if (properties.Contains(this.Name, StringComparer.OrdinalIgnoreCase)) + // Check if operation ~ (Contains) is on property of type string. + if (Operation == Operation.Contains) { - valid = true; - - // Check if operation ~ (Contains) is on property of type string. - if (this.Operation == Operation.Contains) - { - valid = this.ValidForContainsOperation(propertyProvider); - } + valid = ValidForContainsOperation(propertyProvider); } - return valid; } + return valid; + } - private bool ValidForContainsOperation(Func propertyProvider) - { - bool valid = true; + private bool ValidForContainsOperation(Func propertyProvider) + { + bool valid = true; - // It is OK for propertyProvider to be null, no syntax check will happen. + // It is OK for propertyProvider to be null, no syntax check will happen. - // Check validity of operator only if related TestProperty is non-null. - // if null, it might be custom validation ignore it. - if (null != propertyProvider) + // Check validity of operator only if related TestProperty is non-null. + // if null, it might be custom validation ignore it. + if (null != propertyProvider) + { + TestProperty testProperty = propertyProvider(Name); + if (null != testProperty) { - TestProperty testProperty = propertyProvider(Name); - if (null != testProperty) - { - Type propertyType = testProperty.GetValueType(); - valid = typeof(string) == propertyType || - typeof(string[]) == propertyType; - } + Type propertyType = testProperty.GetValueType(); + valid = typeof(string) == propertyType || + typeof(string[]) == propertyType; } - return valid; } + return valid; + } - /// - /// Return Operation corresponding to the operationString - /// - private static Operation GetOperator(string operationString) + /// + /// Return Operation corresponding to the operationString + /// + private static Operation GetOperator(string operationString) + { + switch (operationString) { - switch (operationString) - { - case "=": - return Operation.Equal; + case "=": + return Operation.Equal; - case "!=": - return Operation.NotEqual; + case "!=": + return Operation.NotEqual; - case "~": - return Operation.Contains; + case "~": + return Operation.Contains; - case "!~": - return Operation.NotContains; - } - throw new FormatException(string.Format(CultureInfo.CurrentCulture, CommonResources.TestCaseFilterFormatException, string.Format(CultureInfo.CurrentCulture, CommonResources.InvalidOperator, operationString))); + case "!~": + return Operation.NotContains; } + throw new FormatException(string.Format(CultureInfo.CurrentCulture, CommonResources.TestCaseFilterFormatException, string.Format(CultureInfo.CurrentCulture, CommonResources.InvalidOperator, operationString))); + } - /// - /// Returns property value for Property using propertValueProvider. - /// - private string[] GetPropertyValue(Func propertyValueProvider) + /// + /// Returns property value for Property using propertValueProvider. + /// + private string[] GetPropertyValue(Func propertyValueProvider) + { + var propertyValue = propertyValueProvider(Name); + if (null != propertyValue) { - var propertyValue = propertyValueProvider(this.Name); - if (null != propertyValue) + if (propertyValue is not string[] multiValue) { - var multiValue = propertyValue as string[]; - if (null == multiValue) - { - multiValue = new string[1]; - multiValue[0] = propertyValue.ToString(); - } - return multiValue; + multiValue = new string[1]; + multiValue[0] = propertyValue.ToString(); } - - return null; + return multiValue; } - internal static IEnumerable TokenizeFilterConditionString(string str) - { - if (str == null) - { - throw new ArgumentNullException(nameof(str)); - } + return null; + } - return TokenizeFilterConditionStringWorker(str); + internal static IEnumerable TokenizeFilterConditionString(string str) + { + return str == null ? throw new ArgumentNullException(nameof(str)) : TokenizeFilterConditionStringWorker(str); - IEnumerable TokenizeFilterConditionStringWorker(string s) + static IEnumerable TokenizeFilterConditionStringWorker(string s) + { + StringBuilder tokenBuilder = new(); + + var last = '\0'; + for (int i = 0; i < s.Length; ++i) { - StringBuilder tokenBuilder = new StringBuilder(); + var current = s[i]; - var last = '\0'; - for (int i = 0; i < s.Length; ++i) + if (last == FilterHelper.EscapeCharacter) { - var current = s[i]; + // Don't check if `current` is one of the special characters here. + // Instead, we blindly let any character follows '\' pass though and + // relies on `FilterHelpers.Unescape` to report such errors. + tokenBuilder.Append(current); - if (last == FilterHelper.EscapeCharacter) + if (current == FilterHelper.EscapeCharacter) { - // Don't check if `current` is one of the special characters here. - // Instead, we blindly let any character follows '\' pass though and - // relies on `FilterHelpers.Unescape` to report such errors. - tokenBuilder.Append(current); - - if (current == FilterHelper.EscapeCharacter) - { - // We just encountered double backslash (i.e. escaped '\'), therefore set `last` to '\0' - // so the second '\' (i.e. current) will not be treated as the prefix of escape sequence - // in next iteration. - current = '\0'; - } + // We just encountered double backslash (i.e. escaped '\'), therefore set `last` to '\0' + // so the second '\' (i.e. current) will not be treated as the prefix of escape sequence + // in next iteration. + current = '\0'; } - else + } + else + { + switch (current) { - switch (current) - { - case '=': - if (tokenBuilder.Length > 0) - { - yield return tokenBuilder.ToString(); - tokenBuilder.Clear(); - } - yield return "="; - break; - - case '!': - if (tokenBuilder.Length > 0) - { - yield return tokenBuilder.ToString(); - tokenBuilder.Clear(); - } - // Determine if this is a "!=" or "!~" or just a single "!". - var next = i + 1; - if (next < s.Length && s[next] == '=') - { - i = next; - current = '='; - yield return "!="; - } - else if (next < s.Length && s[next] == '~') - { - i = next; - current = '~'; - yield return "!~"; - } - else - { - yield return "!"; - } - break; - - case '~': - if (tokenBuilder.Length > 0) - { - yield return tokenBuilder.ToString(); - tokenBuilder.Clear(); - } - yield return "~"; - break; - - default: - tokenBuilder.Append(current); - break; - } + case '=': + if (tokenBuilder.Length > 0) + { + yield return tokenBuilder.ToString(); + tokenBuilder.Clear(); + } + yield return "="; + break; + + case '!': + if (tokenBuilder.Length > 0) + { + yield return tokenBuilder.ToString(); + tokenBuilder.Clear(); + } + // Determine if this is a "!=" or "!~" or just a single "!". + var next = i + 1; + if (next < s.Length && s[next] == '=') + { + i = next; + current = '='; + yield return "!="; + } + else if (next < s.Length && s[next] == '~') + { + i = next; + current = '~'; + yield return "!~"; + } + else + { + yield return "!"; + } + break; + + case '~': + if (tokenBuilder.Length > 0) + { + yield return tokenBuilder.ToString(); + tokenBuilder.Clear(); + } + yield return "~"; + break; + + default: + tokenBuilder.Append(current); + break; } - last = current; } + last = current; + } - if (tokenBuilder.Length > 0) - { - yield return tokenBuilder.ToString(); - } + if (tokenBuilder.Length > 0) + { + yield return tokenBuilder.ToString(); } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Filtering/FastFilter.cs b/src/Microsoft.TestPlatform.Common/Filtering/FastFilter.cs index c452f2317a..f42662f7e5 100644 --- a/src/Microsoft.TestPlatform.Common/Filtering/FastFilter.cs +++ b/src/Microsoft.TestPlatform.Common/Filtering/FastFilter.cs @@ -1,225 +1,220 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Filtering +namespace Microsoft.VisualStudio.TestPlatform.Common.Filtering; + +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using System.Text.RegularExpressions; + +using ObjectModel; + +internal sealed class FastFilter { - using System; - using System.Collections.Generic; - using System.Collections.Immutable; - using System.Diagnostics; - using System.Globalization; - using System.Linq; - using System.Text.RegularExpressions; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - - internal sealed class FastFilter - { - internal ImmutableDictionary> FilterProperties { get; } + internal ImmutableDictionary> FilterProperties { get; } - internal bool IsFilteredOutWhenMatched { get; } + internal bool IsFilteredOutWhenMatched { get; } - internal Regex PropertyValueRegex { get; set; } + internal Regex PropertyValueRegex { get; set; } - internal string PropertyValueRegexReplacement { get; set; } + internal string PropertyValueRegexReplacement { get; set; } - internal FastFilter(ImmutableDictionary> filterProperties, Operation filterOperation, Operator filterOperator) - { - ValidateArg.NotNullOrEmpty(filterProperties, nameof(filterProperties)); + internal FastFilter(ImmutableDictionary> filterProperties, Operation filterOperation, Operator filterOperator) + { + ValidateArg.NotNullOrEmpty(filterProperties, nameof(filterProperties)); - this.FilterProperties = filterProperties; + FilterProperties = filterProperties; - if (filterOperation == Operation.Equal && (filterOperator == Operator.Or || filterOperator == Operator.None)) - { - IsFilteredOutWhenMatched = false; - } - else if (filterOperation == Operation.NotEqual && (filterOperator == Operator.And || filterOperator == Operator.None)) - { - IsFilteredOutWhenMatched = true; - } - else - { - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Resources.FastFilterException)); - } + if (filterOperation == Operation.Equal && (filterOperator == Operator.Or || filterOperator == Operator.None)) + { + IsFilteredOutWhenMatched = false; } - - internal string[] ValidForProperties(IEnumerable properties) + else { - return this.FilterProperties.Keys.All(name => properties.Contains(name)) - ? null - : this.FilterProperties.Keys.Where(name => !properties.Contains(name)).ToArray(); + IsFilteredOutWhenMatched = filterOperation == Operation.NotEqual && (filterOperator == Operator.And || filterOperator == Operator.None) + ? true + : throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Resources.FastFilterException)); } + } - internal bool Evaluate(Func propertyValueProvider) - { - ValidateArg.NotNull(propertyValueProvider, nameof(propertyValueProvider)); + internal string[] ValidForProperties(IEnumerable properties) + { + return FilterProperties.Keys.All(name => properties.Contains(name)) + ? null + : FilterProperties.Keys.Where(name => !properties.Contains(name)).ToArray(); + } + + internal bool Evaluate(Func propertyValueProvider) + { + ValidateArg.NotNull(propertyValueProvider, nameof(propertyValueProvider)); - bool matched = false; - foreach (var name in this.FilterProperties.Keys) + bool matched = false; + foreach (var name in FilterProperties.Keys) + { + // If there is no value corresponding to given name, treat it as unmatched. + if (TryGetPropertyValue(name, propertyValueProvider, out var singleValue, out var multiValues)) { - // If there is no value corresponding to given name, treat it as unmatched. - if (TryGetPropertyValue(name, propertyValueProvider, out var singleValue, out var multiValues)) + if (singleValue != null) { - if (singleValue != null) - { - var value = PropertyValueRegex == null ? singleValue : ApplyRegex(singleValue); - matched = value != null && this.FilterProperties[name].Contains(value); - } - else - { - matched = (PropertyValueRegex == null ? multiValues : multiValues.Select(value => ApplyRegex(value))) - .Any(result => result != null && this.FilterProperties[name].Contains(result)); - } - - if (matched) - { - break; - } + var value = PropertyValueRegex == null ? singleValue : ApplyRegex(singleValue); + matched = value != null && FilterProperties[name].Contains(value); + } + else + { + matched = (PropertyValueRegex == null ? multiValues : multiValues.Select(value => ApplyRegex(value))) + .Any(result => result != null && FilterProperties[name].Contains(result)); } - } - - return IsFilteredOutWhenMatched ? !matched : matched; - } - - /// - /// Apply regex matching or replacement to given value. - /// - /// For matching, returns the result of matching, null if no match found. For replacement, returns the result of replacement. - private string ApplyRegex(string value) - { - Debug.Assert(PropertyValueRegex != null); - string result = null; - if (PropertyValueRegexReplacement == null) - { - var match = PropertyValueRegex.Match(value); - if (match.Success) + if (matched) { - result = match.Value; + break; } } - else - { - result = PropertyValueRegex.Replace(value, PropertyValueRegexReplacement); - } - return result; } - /// - /// Returns property value for Property using propertValueProvider. - /// - private static bool TryGetPropertyValue(string name, Func propertyValueProvider, out string singleValue, out string[] multiValues) + return IsFilteredOutWhenMatched ? !matched : matched; + } + + /// + /// Apply regex matching or replacement to given value. + /// + /// For matching, returns the result of matching, null if no match found. For replacement, returns the result of replacement. + private string ApplyRegex(string value) + { + Debug.Assert(PropertyValueRegex != null); + + string result = null; + if (PropertyValueRegexReplacement == null) { - var propertyValue = propertyValueProvider(name); - if (null != propertyValue) + var match = PropertyValueRegex.Match(value); + if (match.Success) { - multiValues = propertyValue as string[]; - singleValue = multiValues == null ? propertyValue.ToString() : null; - return true; + result = match.Value; } - - singleValue = null; - multiValues = null; - return false; } - - internal static Builder CreateBuilder() + else { - return new Builder(); + result = PropertyValueRegex.Replace(value, PropertyValueRegexReplacement); } + return result; + } - internal sealed class Builder + /// + /// Returns property value for Property using propertValueProvider. + /// + private static bool TryGetPropertyValue(string name, Func propertyValueProvider, out string singleValue, out string[] multiValues) + { + var propertyValue = propertyValueProvider(name); + if (null != propertyValue) { - private bool operatorEncountered = false; - private Operator fastFilterOperator = Operator.None; + multiValues = propertyValue as string[]; + singleValue = multiValues == null ? propertyValue.ToString() : null; + return true; + } + + singleValue = null; + multiValues = null; + return false; + } + + internal static Builder CreateBuilder() + { + return new Builder(); + } + + internal sealed class Builder + { + private bool _operatorEncountered = false; + private Operator _fastFilterOperator = Operator.None; - private bool conditionEncountered = false; - private Operation fastFilterOperation; - private ImmutableDictionary.Builder>.Builder filterDictionaryBuilder = ImmutableDictionary.CreateBuilder.Builder>(StringComparer.OrdinalIgnoreCase); + private bool _conditionEncountered = false; + private Operation _fastFilterOperation; + private readonly ImmutableDictionary.Builder>.Builder _filterDictionaryBuilder = ImmutableDictionary.CreateBuilder.Builder>(StringComparer.OrdinalIgnoreCase); - private bool containsValidFilter = true; + private bool _containsValidFilter = true; - internal bool ContainsValidFilter => containsValidFilter && conditionEncountered; + internal bool ContainsValidFilter => _containsValidFilter && _conditionEncountered; - internal void AddOperator(Operator @operator) + internal void AddOperator(Operator @operator) + { + if (_containsValidFilter && (@operator == Operator.And || @operator == Operator.Or)) { - if (containsValidFilter && (@operator == Operator.And || @operator == Operator.Or)) + if (_operatorEncountered) { - if (operatorEncountered) - { - containsValidFilter = fastFilterOperator == @operator; - } - else - { - operatorEncountered = true; - fastFilterOperator = @operator; - if ((fastFilterOperation == Operation.NotEqual && fastFilterOperator == Operator.Or) - || (fastFilterOperation == Operation.Equal && fastFilterOperator == Operator.And)) - { - containsValidFilter = false; - } - } + _containsValidFilter = _fastFilterOperator == @operator; } else { - containsValidFilter = false; + _operatorEncountered = true; + _fastFilterOperator = @operator; + if ((_fastFilterOperation == Operation.NotEqual && _fastFilterOperator == Operator.Or) + || (_fastFilterOperation == Operation.Equal && _fastFilterOperator == Operator.And)) + { + _containsValidFilter = false; + } } } + else + { + _containsValidFilter = false; + } + } - internal void AddCondition(Condition condition) + internal void AddCondition(Condition condition) + { + if (!_containsValidFilter) { - if (!containsValidFilter) - { - return; - } + return; + } - if (conditionEncountered) + if (_conditionEncountered) + { + if (condition.Operation == _fastFilterOperation) { - if (condition.Operation == fastFilterOperation) - { - AddProperty(condition.Name, condition.Value); - } - else - { - containsValidFilter = false; - } + AddProperty(condition.Name, condition.Value); } else { - conditionEncountered = true; - fastFilterOperation = condition.Operation; - AddProperty(condition.Name, condition.Value); - - // Don't support `Contains`. - if (fastFilterOperation != Operation.Equal && fastFilterOperation != Operation.NotEqual) - { - containsValidFilter = false; - } + _containsValidFilter = false; } } - - private void AddProperty(string name, string value) + else { - if (!filterDictionaryBuilder.TryGetValue(name, out var values)) + _conditionEncountered = true; + _fastFilterOperation = condition.Operation; + AddProperty(condition.Name, condition.Value); + + // Don't support `Contains`. + if (_fastFilterOperation != Operation.Equal && _fastFilterOperation != Operation.NotEqual) { - values = ImmutableHashSet.CreateBuilder(StringComparer.OrdinalIgnoreCase); - filterDictionaryBuilder.Add(name, values); + _containsValidFilter = false; } - - values.Add(value); } + } - internal FastFilter ToFastFilter() + private void AddProperty(string name, string value) + { + if (!_filterDictionaryBuilder.TryGetValue(name, out var values)) { - if (ContainsValidFilter) - { - return new FastFilter( - filterDictionaryBuilder.ToImmutableDictionary(kvp => kvp.Key, kvp => (ISet)filterDictionaryBuilder[kvp.Key].ToImmutable()), - fastFilterOperation, - fastFilterOperator); - } - - return null; + values = ImmutableHashSet.CreateBuilder(StringComparer.OrdinalIgnoreCase); + _filterDictionaryBuilder.Add(name, values); } + + values.Add(value); + } + + internal FastFilter ToFastFilter() + { + return ContainsValidFilter + ? new FastFilter( + _filterDictionaryBuilder.ToImmutableDictionary(kvp => kvp.Key, kvp => (ISet)_filterDictionaryBuilder[kvp.Key].ToImmutable()), + _fastFilterOperation, + _fastFilterOperator) + : null; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Filtering/FilterExpression.cs b/src/Microsoft.TestPlatform.Common/Filtering/FilterExpression.cs index cc0202fbfb..e48e2efc1c 100644 --- a/src/Microsoft.TestPlatform.Common/Filtering/FilterExpression.cs +++ b/src/Microsoft.TestPlatform.Common/Filtering/FilterExpression.cs @@ -1,370 +1,358 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Filtering +namespace Microsoft.VisualStudio.TestPlatform.Common.Filtering; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; + +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; + +using CommonResources = Resources.Resources; + +/// +/// Represents an expression tree. +/// Supports: +/// Logical Operators: &, | +/// Equality Operators: =, != +/// Parenthesis (, ) for grouping. +/// +internal class FilterExpression { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Globalization; - using System.Linq; - using System.Text; - using System.Text.RegularExpressions; - - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using CommonResources = Microsoft.VisualStudio.TestPlatform.Common.Resources.Resources; + /// + /// Condition, if expression is conditional expression. + /// + private readonly Condition _condition; + + /// + /// Left operand, when expression is logical expression. + /// + private readonly FilterExpression _left; /// - /// Represents an expression tree. - /// Supports: - /// Logical Operators: &, | - /// Equality Operators: =, != - /// Parenthesis (, ) for grouping. + /// Right operand, when expression is logical expression. /// - internal class FilterExpression + private readonly FilterExpression _right; + + /// + /// If logical expression is using logical And ('&') operator. + /// + private readonly bool _areJoinedByAnd; + + #region Constructors + + private FilterExpression(FilterExpression left, FilterExpression right, bool areJoinedByAnd) { - /// - /// Condition, if expression is conditional expression. - /// - private readonly Condition condition; + ValidateArg.NotNull(left, nameof(left)); + ValidateArg.NotNull(right, nameof(right)); - /// - /// Left operand, when expression is logical expression. - /// - private readonly FilterExpression left; + _left = left; + _right = right; + _areJoinedByAnd = areJoinedByAnd; + } - /// - /// Right operand, when expression is logical expression. - /// - private readonly FilterExpression right; + private FilterExpression(Condition condition) + { + ValidateArg.NotNull(condition, nameof(condition)); + _condition = condition; + } + #endregion - /// - /// If logical expression is using logical And ('&') operator. - /// - private readonly bool areJoinedByAnd; + /// + /// Create a new filter expression 'And'ing 'this' with 'filter'. + /// + private FilterExpression And(FilterExpression filter) + { + return new FilterExpression(this, filter, true); + } - #region Constructors + /// + /// Create a new filter expression 'Or'ing 'this' with 'filter'. + /// + private FilterExpression Or(FilterExpression filter) + { + return new FilterExpression(this, filter, false); + } - private FilterExpression(FilterExpression left, FilterExpression right, bool areJoinedByAnd) + /// + /// Process the given operator from the filterStack. + /// Puts back the result of operation back to filterStack. + /// + private static void ProcessOperator(Stack filterStack, Operator op) + { + if (op == Operator.And) { - ValidateArg.NotNull(left, nameof(left)); - ValidateArg.NotNull(right, nameof(right)); + if (filterStack.Count < 2) + { + throw new FormatException(string.Format(CultureInfo.CurrentCulture, CommonResources.TestCaseFilterFormatException, CommonResources.MissingOperand)); + } - this.left = left; - this.right = right; - this.areJoinedByAnd = areJoinedByAnd; + var filterRight = filterStack.Pop(); + var filterLeft = filterStack.Pop(); + var result = filterLeft.And(filterRight); + filterStack.Push(result); } + else if (op == Operator.Or) + { + if (filterStack.Count < 2) + { + throw new FormatException(string.Format(CultureInfo.CurrentCulture, CommonResources.TestCaseFilterFormatException, CommonResources.MissingOperand)); + } - private FilterExpression(Condition condition) + var filterRight = filterStack.Pop(); + var filterLeft = filterStack.Pop(); + var result = filterLeft.Or(filterRight); + filterStack.Push(result); + } + else if (op == Operator.OpenBrace) { - ValidateArg.NotNull(condition, nameof(condition)); - this.condition = condition; + throw new FormatException(string.Format(CultureInfo.CurrentCulture, CommonResources.TestCaseFilterFormatException, CommonResources.MissingCloseParenthesis)); } - #endregion - - /// - /// Create a new filter expression 'And'ing 'this' with 'filter'. - /// - private FilterExpression And(FilterExpression filter) + else { - return new FilterExpression(this, filter, true); + Debug.Fail("ProcessOperator called for Unexpected operator."); + throw new FormatException(string.Format(CultureInfo.CurrentCulture, CommonResources.TestCaseFilterFormatException, string.Empty)); } + } + + /// + /// True, if filter is valid for given set of properties. + /// When False, invalidProperties would contain properties making filter invalid. + /// + internal string[] ValidForProperties(IEnumerable properties, Func propertyProvider) + { + string[] invalidProperties = null; - /// - /// Create a new filter expression 'Or'ing 'this' with 'filter'. - /// - private FilterExpression Or(FilterExpression filter) + if (null == properties) { - return new FilterExpression(this, filter, false); + // if null, initialize to empty list so that invalid properties can be found. + properties = Enumerable.Empty(); } - /// - /// Process the given operator from the filterStack. - /// Puts back the result of operation back to filterStack. - /// - private static void ProcessOperator(Stack filterStack, Operator op) + bool valid = false; + if (_condition != null) { - if (op == Operator.And) + valid = _condition.ValidForProperties(properties, propertyProvider); + if (!valid) { - if (filterStack.Count < 2) - { - throw new FormatException(string.Format(CultureInfo.CurrentCulture, CommonResources.TestCaseFilterFormatException, CommonResources.MissingOperand)); - } - - var filterRight = filterStack.Pop(); - var filterLeft = filterStack.Pop(); - var result = filterLeft.And(filterRight); - filterStack.Push(result); + invalidProperties = new string[1] { _condition.Name }; } - else if (op == Operator.Or) - { - if (filterStack.Count < 2) - { - throw new FormatException(string.Format(CultureInfo.CurrentCulture, CommonResources.TestCaseFilterFormatException, CommonResources.MissingOperand)); - } - - var filterRight = filterStack.Pop(); - var filterLeft = filterStack.Pop(); - var result = filterLeft.Or(filterRight); - filterStack.Push(result); - } - else if (op == Operator.OpenBrace) + } + else + { + invalidProperties = _left.ValidForProperties(properties, propertyProvider); + var invalidRight = _right.ValidForProperties(properties, propertyProvider); + if (null == invalidProperties) { - throw new FormatException(string.Format(CultureInfo.CurrentCulture, CommonResources.TestCaseFilterFormatException, CommonResources.MissingCloseParenthesis)); + invalidProperties = invalidRight; } - else + else if (null != invalidRight) { - Debug.Fail("ProcessOperator called for Unexpected operator."); - throw new FormatException(string.Format(CultureInfo.CurrentCulture, CommonResources.TestCaseFilterFormatException, string.Empty)); + invalidProperties = invalidProperties.Concat(invalidRight).ToArray(); } } + return invalidProperties; + } - /// - /// True, if filter is valid for given set of properties. - /// When False, invalidProperties would contain properties making filter invalid. - /// - internal string[] ValidForProperties(IEnumerable properties, Func propertyProvider) + /// + /// Return FilterExpression after parsing the given filter expression, and a FastFilter when possible. + /// + internal static FilterExpression Parse(string filterString, out FastFilter fastFilter) + { + ValidateArg.NotNull(filterString, nameof(filterString)); + + // Below parsing doesn't error out on pattern (), so explicitly search for that (empty parenthesis). + var invalidInput = Regex.Match(filterString, @"\(\s*\)"); + if (invalidInput.Success) { - string[] invalidProperties = null; + throw new FormatException(string.Format(CultureInfo.CurrentCulture, CommonResources.TestCaseFilterFormatException, CommonResources.EmptyParenthesis)); + } - if (null == properties) - { - // if null, initialize to empty list so that invalid properties can be found. - properties = Enumerable.Empty(); - } + var tokens = TokenizeFilterExpressionString(filterString); + var operatorStack = new Stack(); + var filterStack = new Stack(); - bool valid = false; - if (this.condition != null) - { - valid = this.condition.ValidForProperties(properties, propertyProvider); - if (!valid) - { - invalidProperties = new string[1] { this.condition.Name }; - } - } - else - { - invalidProperties = this.left.ValidForProperties(properties, propertyProvider); - var invalidRight = this.right.ValidForProperties(properties, propertyProvider); - if (null == invalidProperties) - { - invalidProperties = invalidRight; - } - else if (null != invalidRight) - { - invalidProperties = invalidProperties.Concat(invalidRight).ToArray(); - } - } - return invalidProperties; - } + var fastFilterBuilder = FastFilter.CreateBuilder(); - /// - /// Return FilterExpression after parsing the given filter expression, and a FastFilter when possible. - /// - internal static FilterExpression Parse(string filterString, out FastFilter fastFilter) + // This is based on standard parsing of in order expression using two stacks (operand stack and operator stack) + // Precedence(And) > Precedence(Or) + foreach (var inputToken in tokens) { - ValidateArg.NotNull(filterString, nameof(filterString)); - - // Below parsing doesn't error out on pattern (), so explicitly search for that (empty parenthesis). - var invalidInput = Regex.Match(filterString, @"\(\s*\)"); - if (invalidInput.Success) + var token = inputToken.Trim(); + if (string.IsNullOrEmpty(token)) { - throw new FormatException(string.Format(CultureInfo.CurrentCulture, CommonResources.TestCaseFilterFormatException, CommonResources.EmptyParenthesis)); + // ignore empty tokens + continue; } - var tokens = TokenizeFilterExpressionString(filterString); - var operatorStack = new Stack(); - var filterStack = new Stack(); - - var fastFilterBuilder = FastFilter.CreateBuilder(); - - // This is based on standard parsing of in order expression using two stacks (operand stack and operator stack) - // Precedence(And) > Precedence(Or) - foreach (var inputToken in tokens) + switch (token) { - var token = inputToken.Trim(); - if (string.IsNullOrEmpty(token)) - { - // ignore empty tokens - continue; - } + case "&": + case "|": - switch (token) - { - case "&": - case "|": - - Operator currentOperator = Operator.And; - if (string.Equals("|", token)) - { - currentOperator = Operator.Or; - } + Operator currentOperator = Operator.And; + if (string.Equals("|", token)) + { + currentOperator = Operator.Or; + } - fastFilterBuilder.AddOperator(currentOperator); + fastFilterBuilder.AddOperator(currentOperator); - // Always put only higher priority operator on stack. - // if lesser priority -- pop up the stack and process the operator to maintain operator precedence. - // if equal priority -- pop up the stack and process the operator to maintain operator associativity. - // OpenBrace is special condition. & or | can come on top of OpenBrace for case like ((a=b)&c=d) - while (true) + // Always put only higher priority operator on stack. + // if lesser priority -- pop up the stack and process the operator to maintain operator precedence. + // if equal priority -- pop up the stack and process the operator to maintain operator associativity. + // OpenBrace is special condition. & or | can come on top of OpenBrace for case like ((a=b)&c=d) + while (true) + { + bool isEmpty = operatorStack.Count == 0; + Operator stackTopOperator = isEmpty ? Operator.None : operatorStack.Peek(); + if (isEmpty || stackTopOperator == Operator.OpenBrace || stackTopOperator < currentOperator) { - bool isEmpty = operatorStack.Count == 0; - Operator stackTopOperator = isEmpty ? Operator.None : operatorStack.Peek(); - if (isEmpty || stackTopOperator == Operator.OpenBrace || stackTopOperator < currentOperator) - { - operatorStack.Push(currentOperator); - break; - } - stackTopOperator = operatorStack.Pop(); - ProcessOperator(filterStack, stackTopOperator); + operatorStack.Push(currentOperator); + break; } - break; + stackTopOperator = operatorStack.Pop(); + ProcessOperator(filterStack, stackTopOperator); + } + break; - case "(": - operatorStack.Push(Operator.OpenBrace); - break; + case "(": + operatorStack.Push(Operator.OpenBrace); + break; - case ")": - // process operators from the stack till OpenBrace is found. - // If stack is empty at any time, than matching OpenBrace is missing from the expression. + case ")": + // process operators from the stack till OpenBrace is found. + // If stack is empty at any time, than matching OpenBrace is missing from the expression. + if (operatorStack.Count == 0) + { + throw new FormatException(string.Format(CultureInfo.CurrentCulture, CommonResources.TestCaseFilterFormatException, CommonResources.MissingOpenParenthesis)); + } + + Operator temp = operatorStack.Pop(); + while (temp != Operator.OpenBrace) + { + ProcessOperator(filterStack, temp); if (operatorStack.Count == 0) { throw new FormatException(string.Format(CultureInfo.CurrentCulture, CommonResources.TestCaseFilterFormatException, CommonResources.MissingOpenParenthesis)); } + temp = operatorStack.Pop(); + } - Operator temp = operatorStack.Pop(); - while (temp != Operator.OpenBrace) - { - ProcessOperator(filterStack, temp); - if (operatorStack.Count == 0) - { - throw new FormatException(string.Format(CultureInfo.CurrentCulture, CommonResources.TestCaseFilterFormatException, CommonResources.MissingOpenParenthesis)); - } - temp = operatorStack.Pop(); - } - - break; + break; - default: - // push the operand to the operand stack. - Condition condition = Condition.Parse(token); - FilterExpression filter = new FilterExpression(condition); - filterStack.Push(filter); + default: + // push the operand to the operand stack. + Condition condition = Condition.Parse(token); + FilterExpression filter = new(condition); + filterStack.Push(filter); - fastFilterBuilder.AddCondition(condition); - break; - } - } - while (operatorStack.Count != 0) - { - Operator temp = operatorStack.Pop(); - ProcessOperator(filterStack, temp); + fastFilterBuilder.AddCondition(condition); + break; } + } + while (operatorStack.Count != 0) + { + Operator temp = operatorStack.Pop(); + ProcessOperator(filterStack, temp); + } - if (filterStack.Count != 1) - { - throw new FormatException(string.Format(CultureInfo.CurrentCulture, CommonResources.TestCaseFilterFormatException, CommonResources.MissingOperator)); - } + if (filterStack.Count != 1) + { + throw new FormatException(string.Format(CultureInfo.CurrentCulture, CommonResources.TestCaseFilterFormatException, CommonResources.MissingOperator)); + } - fastFilter = fastFilterBuilder.ToFastFilter(); + fastFilter = fastFilterBuilder.ToFastFilter(); - return filterStack.Pop(); - } + return filterStack.Pop(); + } - /// - /// Evaluate filterExpression with given propertyValueProvider. - /// - /// The property Value Provider. - /// True if evaluation is successful. - internal bool Evaluate(Func propertyValueProvider) - { - ValidateArg.NotNull(propertyValueProvider, nameof(propertyValueProvider)); + /// + /// Evaluate filterExpression with given propertyValueProvider. + /// + /// The property Value Provider. + /// True if evaluation is successful. + internal bool Evaluate(Func propertyValueProvider) + { + ValidateArg.NotNull(propertyValueProvider, nameof(propertyValueProvider)); - bool filterResult = false; - if (null != this.condition) - { - filterResult = this.condition.Evaluate(propertyValueProvider); - } - else - { - // & or | operator - bool leftResult = this.left.Evaluate(propertyValueProvider); - bool rightResult = this.right.Evaluate(propertyValueProvider); - if (this.areJoinedByAnd) - { - filterResult = leftResult && rightResult; - } - else - { - filterResult = leftResult || rightResult; - } - } - return filterResult; + bool filterResult = false; + if (null != _condition) + { + filterResult = _condition.Evaluate(propertyValueProvider); } - - internal static IEnumerable TokenizeFilterExpressionString(string str) + else { - if (str == null) - { - throw new ArgumentNullException(nameof(str)); - } + // & or | operator + bool leftResult = _left.Evaluate(propertyValueProvider); + bool rightResult = _right.Evaluate(propertyValueProvider); + filterResult = _areJoinedByAnd ? leftResult && rightResult : leftResult || rightResult; + } + return filterResult; + } + + internal static IEnumerable TokenizeFilterExpressionString(string str) + { + return str == null ? throw new ArgumentNullException(nameof(str)) : TokenizeFilterExpressionStringHelper(str); - return TokenizeFilterExpressionStringHelper(str); + static IEnumerable TokenizeFilterExpressionStringHelper(string s) + { + StringBuilder tokenBuilder = new(); - IEnumerable TokenizeFilterExpressionStringHelper(string s) + var last = '\0'; + for (int i = 0; i < s.Length; ++i) { - StringBuilder tokenBuilder = new StringBuilder(); + var current = s[i]; - var last = '\0'; - for (int i = 0; i < s.Length; ++i) + if (last == FilterHelper.EscapeCharacter) { - var current = s[i]; + // Don't check if `current` is one of the special characters here. + // Instead, we blindly let any character follows '\' pass though and + // relies on `FilterHelpers.Unescape` to report such errors. + tokenBuilder.Append(current); - if (last == FilterHelper.EscapeCharacter) + if (current == FilterHelper.EscapeCharacter) { - // Don't check if `current` is one of the special characters here. - // Instead, we blindly let any character follows '\' pass though and - // relies on `FilterHelpers.Unescape` to report such errors. - tokenBuilder.Append(current); - - if (current == FilterHelper.EscapeCharacter) - { - // We just encountered "\\" (escaped '\'), this will set last to '\0' - // so the next char will not be treated as a suffix of escape sequence. - current = '\0'; - } + // We just encountered "\\" (escaped '\'), this will set last to '\0' + // so the next char will not be treated as a suffix of escape sequence. + current = '\0'; } - else + } + else + { + switch (current) { - switch (current) - { - case '(': - case ')': - case '&': - case '|': - if (tokenBuilder.Length > 0) - { - yield return tokenBuilder.ToString(); - tokenBuilder.Clear(); - } - yield return current.ToString(); - break; - - default: - tokenBuilder.Append(current); - break; - } - } + case '(': + case ')': + case '&': + case '|': + if (tokenBuilder.Length > 0) + { + yield return tokenBuilder.ToString(); + tokenBuilder.Clear(); + } + yield return current.ToString(); + break; - last = current; + default: + tokenBuilder.Append(current); + break; + } } - if (tokenBuilder.Length > 0) - { - yield return tokenBuilder.ToString(); - } + last = current; + } + + if (tokenBuilder.Length > 0) + { + yield return tokenBuilder.ToString(); } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Filtering/FilterExpressionWrapper.cs b/src/Microsoft.TestPlatform.Common/Filtering/FilterExpressionWrapper.cs index fa4648e554..e554a64cab 100644 --- a/src/Microsoft.TestPlatform.Common/Filtering/FilterExpressionWrapper.cs +++ b/src/Microsoft.TestPlatform.Common/Filtering/FilterExpressionWrapper.cs @@ -1,133 +1,129 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Filtering +namespace Microsoft.VisualStudio.TestPlatform.Common.Filtering; + +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +using ObjectModel; +using ObjectModel.Client; +using System.Diagnostics; + +/// +/// Class holds information related to filtering criteria. +/// +public class FilterExpressionWrapper { - using System; - using System.Collections.Generic; - using System.Text.RegularExpressions; + /// + /// FilterExpression corresponding to filter criteria + /// + private readonly FilterExpression _filterExpression; + + /// + /// Exposed for testing purpose. + /// + internal readonly FastFilter FastFilter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using System.Diagnostics; + private bool UseFastFilter => FastFilter != null; /// - /// Class holds information related to filtering criteria. + /// Initializes FilterExpressionWrapper with given filterString and options. /// - public class FilterExpressionWrapper + public FilterExpressionWrapper(string filterString, FilterOptions options) { - /// - /// FilterExpression corresponding to filter criteria - /// - private readonly FilterExpression filterExpression; - - /// - /// Exposed for testing purpose. - /// - internal readonly FastFilter fastFilter; - - private bool UseFastFilter => this.fastFilter != null; - - /// - /// Initializes FilterExpressionWrapper with given filterString and options. - /// - public FilterExpressionWrapper(string filterString, FilterOptions options) - { - ValidateArg.NotNullOrEmpty(filterString, nameof(filterString)); + ValidateArg.NotNullOrEmpty(filterString, nameof(filterString)); - this.FilterString = filterString; - this.FilterOptions = options; + FilterString = filterString; + FilterOptions = options; - try + try + { + // We prefer fast filter when it's available. + _filterExpression = FilterExpression.Parse(filterString, out FastFilter); + + if (UseFastFilter) { - // We prefer fast filter when it's available. - this.filterExpression = FilterExpression.Parse(filterString, out this.fastFilter); + _filterExpression = null; + + // Property value regex is only supported for fast filter, + // so we ignore it if no fast filter is constructed. - if (UseFastFilter) + // TODO: surface an error message to suer. + var regexString = options?.FilterRegEx; + if (!string.IsNullOrEmpty(regexString)) { - this.filterExpression = null; - - // Property value regex is only supported for fast filter, - // so we ignore it if no fast filter is constructed. - - // TODO: surface an error message to suer. - var regexString = options?.FilterRegEx; - if (!string.IsNullOrEmpty(regexString)) - { - Debug.Assert(options.FilterRegExReplacement != null ? options.FilterRegEx != null : true); - this.fastFilter.PropertyValueRegex = new Regex(regexString, RegexOptions.Compiled); - this.fastFilter.PropertyValueRegexReplacement = options.FilterRegExReplacement; - } + Debug.Assert(options.FilterRegExReplacement == null || options.FilterRegEx != null); + FastFilter.PropertyValueRegex = new Regex(regexString, RegexOptions.Compiled); + FastFilter.PropertyValueRegexReplacement = options.FilterRegExReplacement; } - - } - catch (FormatException ex) - { - this.ParseError = ex.Message; } - catch (ArgumentException ex) - { - this.fastFilter = null; - this.ParseError = ex.Message; - } - } - /// - /// Initializes FilterExpressionWrapper with given filterString. - /// - public FilterExpressionWrapper(string filterString) - : this(filterString, null) - { } - - /// - /// User specified filter criteria. - /// - public string FilterString + catch (FormatException ex) { - get; - private set; + ParseError = ex.Message; } - - /// - /// User specified additional filter options. - /// - public FilterOptions FilterOptions + catch (ArgumentException ex) { - get; - private set; + FastFilter = null; + ParseError = ex.Message; } + } - /// - /// Parsing error (if any), when parsing 'FilterString' with built-in parser. - /// - public string ParseError - { - get; - private set; - } + /// + /// Initializes FilterExpressionWrapper with given filterString. + /// + public FilterExpressionWrapper(string filterString) + : this(filterString, null) + { + } - /// - /// Validate if underlying filter expression is valid for given set of supported properties. - /// - public string[] ValidForProperties(IEnumerable supportedProperties, Func propertyProvider) - { - return UseFastFilter ? this.fastFilter.ValidForProperties(supportedProperties) : this.filterExpression?.ValidForProperties(supportedProperties, propertyProvider); - } + /// + /// User specified filter criteria. + /// + public string FilterString + { + get; + private set; + } - /// - /// Evaluate filterExpression with given propertyValueProvider. - /// - public bool Evaluate(Func propertyValueProvider) - { - ValidateArg.NotNull(propertyValueProvider, nameof(propertyValueProvider)); + /// + /// User specified additional filter options. + /// + public FilterOptions FilterOptions + { + get; + private set; + } - if (UseFastFilter) - { - return this.fastFilter.Evaluate(propertyValueProvider); - } + /// + /// Parsing error (if any), when parsing 'FilterString' with built-in parser. + /// + public string ParseError + { + get; + private set; + } - return this.filterExpression == null ? false : this.filterExpression.Evaluate(propertyValueProvider); - } + /// + /// Validate if underlying filter expression is valid for given set of supported properties. + /// + public string[] ValidForProperties(IEnumerable supportedProperties, Func propertyProvider) + { + return UseFastFilter ? FastFilter.ValidForProperties(supportedProperties) : _filterExpression?.ValidForProperties(supportedProperties, propertyProvider); + } + + /// + /// Evaluate filterExpression with given propertyValueProvider. + /// + public bool Evaluate(Func propertyValueProvider) + { + ValidateArg.NotNull(propertyValueProvider, nameof(propertyValueProvider)); + + return UseFastFilter + ? FastFilter.Evaluate(propertyValueProvider) + : _filterExpression != null && _filterExpression.Evaluate(propertyValueProvider); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Filtering/TestCaseFilterExpression.cs b/src/Microsoft.TestPlatform.Common/Filtering/TestCaseFilterExpression.cs index 54cb6bc8ce..223c3303e6 100644 --- a/src/Microsoft.TestPlatform.Common/Filtering/TestCaseFilterExpression.cs +++ b/src/Microsoft.TestPlatform.Common/Filtering/TestCaseFilterExpression.cs @@ -1,81 +1,80 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Filtering -{ - using System; - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.Common.Filtering; + +using System; +using System.Collections.Generic; + +using ObjectModel; +using ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +/// +/// Implements ITestCaseFilterExpression, providing test case filtering functionality. +/// +public class TestCaseFilterExpression : ITestCaseFilterExpression +{ + private readonly FilterExpressionWrapper _filterWrapper; /// - /// Implements ITestCaseFilterExpression, providing test case filtering functionality. + /// If filter Expression is valid for performing TestCase matching + /// (has only supported properties, syntax etc) /// - public class TestCaseFilterExpression : ITestCaseFilterExpression - { - private FilterExpressionWrapper filterWrapper; + private readonly bool _validForMatch; - /// - /// If filter Expression is valid for performing TestCase matching - /// (has only supported properties, syntax etc) - /// - private readonly bool validForMatch; + /// + /// Adapter specific filter expression. + /// + public TestCaseFilterExpression(FilterExpressionWrapper filterWrapper) + { + ValidateArg.NotNull(filterWrapper, nameof(filterWrapper)); + _filterWrapper = filterWrapper; + _validForMatch = string.IsNullOrEmpty(filterWrapper.ParseError); + } - /// - /// Adapter specific filter expression. - /// - public TestCaseFilterExpression(FilterExpressionWrapper filterWrapper) + /// + /// User specified filter criteria. + /// + public string TestCaseFilterValue + { + get { - ValidateArg.NotNull(filterWrapper, nameof(filterWrapper)); - this.filterWrapper = filterWrapper; - this.validForMatch = string.IsNullOrEmpty(filterWrapper.ParseError); + return _filterWrapper.FilterString; } + } - /// - /// User specified filter criteria. - /// - public string TestCaseFilterValue + /// + /// Validate if underlying filter expression is valid for given set of supported properties. + /// + public string[] ValidForProperties(IEnumerable supportedProperties, Func propertyProvider) + { + string[] invalidProperties = null; + if (null != _filterWrapper && _validForMatch) { - get - { - return this.filterWrapper.FilterString; - } + invalidProperties = _filterWrapper.ValidForProperties(supportedProperties, propertyProvider); } + return invalidProperties; + } - /// - /// Validate if underlying filter expression is valid for given set of supported properties. - /// - public string[] ValidForProperties(IEnumerable supportedProperties, Func propertyProvider) + /// + /// Match test case with filter criteria. + /// + public bool MatchTestCase(TestCase testCase, Func propertyValueProvider) + { + ValidateArg.NotNull(testCase, nameof(testCase)); + ValidateArg.NotNull(propertyValueProvider, nameof(propertyValueProvider)); + if (!_validForMatch) { - string[] invalidProperties = null; - if (null != this.filterWrapper && this.validForMatch) - { - invalidProperties = this.filterWrapper.ValidForProperties(supportedProperties, propertyProvider); - } - return invalidProperties; + return false; } - /// - /// Match test case with filter criteria. - /// - public bool MatchTestCase(TestCase testCase, Func propertyValueProvider) + if (null == _filterWrapper) { - ValidateArg.NotNull(testCase, nameof(testCase)); - ValidateArg.NotNull(propertyValueProvider, nameof(propertyValueProvider)); - if (!this.validForMatch) - { - return false; - } - - if (null == this.filterWrapper) - { - // can be null when parsing error occurs. Invalid filter results in no match. - return false; - } - return this.filterWrapper.Evaluate(propertyValueProvider); + // can be null when parsing error occurs. Invalid filter results in no match. + return false; } - + return _filterWrapper.Evaluate(propertyValueProvider); } -} + +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Hosting/TestRunTimeExtensionManager.cs b/src/Microsoft.TestPlatform.Common/Hosting/TestRunTimeExtensionManager.cs index c150d1f5aa..912a988630 100644 --- a/src/Microsoft.TestPlatform.Common/Hosting/TestRunTimeExtensionManager.cs +++ b/src/Microsoft.TestPlatform.Common/Hosting/TestRunTimeExtensionManager.cs @@ -1,66 +1,62 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Hosting -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.Common.Hosting; + +using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Interfaces; +using ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +/// +/// Manages loading and provides access to testhost extensions implementing the +/// ITestRuntimeProvider interface. +/// +internal class TestRuntimeExtensionManager : TestExtensionManager +{ /// - /// Manages loading and provides access to testhost extensions implementing the - /// ITestRuntimeProvider interface. + /// Initializes a new instance of the class. + /// Default constructor. /// - internal class TestRuntimeExtensionManager : TestExtensionManager + /// + /// The unfiltered Test Extensions. + /// + /// + /// The test Extensions. + /// + /// + /// The logger. + /// + /// + /// The constructor is not public because the factory method should be used to get instances of this class. + /// + protected TestRuntimeExtensionManager( + IEnumerable>> unfilteredTestExtensions, + IEnumerable> testExtensions, + IMessageLogger logger) + : base(unfilteredTestExtensions, testExtensions, logger) { - /// - /// Initializes a new instance of the class. - /// Default constructor. - /// - /// - /// The unfiltered Test Extensions. - /// - /// - /// The test Extensions. - /// - /// - /// The logger. - /// - /// - /// The constructor is not public because the factory method should be used to get instances of this class. - /// - protected TestRuntimeExtensionManager( - IEnumerable>> unfilteredTestExtensions, - IEnumerable> testExtensions, - IMessageLogger logger) - : base(unfilteredTestExtensions, testExtensions, logger) - { - } - - /// - /// Gets an instance of the TestLoggerExtensionManager. - /// - /// - /// The message Logger. - /// - /// - /// The TestLoggerExtensionManager. - /// - public static TestRuntimeExtensionManager Create(IMessageLogger messageLogger) - { - IEnumerable> filteredTestExtensions; - IEnumerable>> unfilteredTestExtensions; + } - TestPluginManager.Instance.GetSpecificTestExtensions( - TestPlatformConstants.RunTimeEndsWithPattern, - out unfilteredTestExtensions, - out filteredTestExtensions); + /// + /// Gets an instance of the TestLoggerExtensionManager. + /// + /// + /// The message Logger. + /// + /// + /// The TestLoggerExtensionManager. + /// + public static TestRuntimeExtensionManager Create(IMessageLogger messageLogger) + { + TestPluginManager.Instance.GetSpecificTestExtensions( + TestPlatformConstants.RunTimeEndsWithPattern, + out IEnumerable>> unfilteredTestExtensions, + out IEnumerable> filteredTestExtensions); - return new TestRuntimeExtensionManager(unfilteredTestExtensions, filteredTestExtensions, messageLogger); - } + return new TestRuntimeExtensionManager(unfilteredTestExtensions, filteredTestExtensions, messageLogger); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Hosting/TestRunTimeMetadata.cs b/src/Microsoft.TestPlatform.Common/Hosting/TestRunTimeMetadata.cs index 441b2e6c95..7d87f06b30 100644 --- a/src/Microsoft.TestPlatform.Common/Hosting/TestRunTimeMetadata.cs +++ b/src/Microsoft.TestPlatform.Common/Hosting/TestRunTimeMetadata.cs @@ -1,46 +1,45 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Hosting -{ - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; +namespace Microsoft.VisualStudio.TestPlatform.Common.Hosting; + +using Interfaces; +/// +/// Hold data about the Test Host. +/// +public class TestRuntimeMetadata : ITestRuntimeCapabilities +{ /// - /// Hold data about the Test Host. + /// Constructor for TestRuntimeMetadata /// - public class TestRuntimeMetadata : ITestRuntimeCapabilities + /// + /// Uri identifying the testhost. + /// + /// + /// The friendly Name. + /// + public TestRuntimeMetadata(string extension, string friendlyName) { - /// - /// Constructor for TestRuntimeMetadata - /// - /// - /// Uri identifying the testhost. - /// - /// - /// The friendly Name. - /// - public TestRuntimeMetadata(string extension, string friendlyName) - { - this.ExtensionUri = extension; - this.FriendlyName = friendlyName; - } + ExtensionUri = extension; + FriendlyName = friendlyName; + } - /// - /// Gets Uri identifying the testhost. - /// - public string ExtensionUri - { - get; - private set; - } + /// + /// Gets Uri identifying the testhost. + /// + public string ExtensionUri + { + get; + private set; + } - /// - /// Gets Friendly Name identifying the testhost. - /// - public string FriendlyName - { - get; - private set; - } + /// + /// Gets Friendly Name identifying the testhost. + /// + public string FriendlyName + { + get; + private set; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Hosting/TestRunTimeProviderManager.cs b/src/Microsoft.TestPlatform.Common/Hosting/TestRunTimeProviderManager.cs index da1e3b30c9..5c7d227089 100644 --- a/src/Microsoft.TestPlatform.Common/Hosting/TestRunTimeProviderManager.cs +++ b/src/Microsoft.TestPlatform.Common/Hosting/TestRunTimeProviderManager.cs @@ -1,71 +1,70 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Hosting -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.Common.Hosting; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using System; - /// - /// Responsible for managing TestRuntimeProviderManager extensions - /// - public class TestRuntimeProviderManager - { - #region Fields +using Logging; +using ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - private static TestRuntimeProviderManager testHostManager; +/// +/// Responsible for managing TestRuntimeProviderManager extensions +/// +public class TestRuntimeProviderManager +{ + #region Fields - private readonly TestRuntimeExtensionManager testHostExtensionManager; + private static TestRuntimeProviderManager s_testHostManager; - #endregion + private readonly TestRuntimeExtensionManager _testHostExtensionManager; - #region Constructor + #endregion - /// - /// Initializes a new instance of the class. - /// Default constructor. - /// - /// - /// The session Logger. - /// - protected TestRuntimeProviderManager(IMessageLogger sessionLogger) - { - this.testHostExtensionManager = TestRuntimeExtensionManager.Create(sessionLogger); - } + #region Constructor - /// - /// Gets the instance of TestRuntimeProviderManager - /// - public static TestRuntimeProviderManager Instance => testHostManager - ?? (testHostManager = new TestRuntimeProviderManager(TestSessionMessageLogger.Instance)); + /// + /// Initializes a new instance of the class. + /// Default constructor. + /// + /// + /// The session Logger. + /// + protected TestRuntimeProviderManager(IMessageLogger sessionLogger) + { + _testHostExtensionManager = TestRuntimeExtensionManager.Create(sessionLogger); + } - #endregion + /// + /// Gets the instance of TestRuntimeProviderManager + /// + public static TestRuntimeProviderManager Instance + => s_testHostManager ??= new TestRuntimeProviderManager(TestSessionMessageLogger.Instance); - #region Public Methods + #endregion - public ITestRuntimeProvider GetTestHostManagerByUri(string hostUri) - { - var host = this.testHostExtensionManager.TryGetTestExtension(hostUri); - return host?.Value; - } + #region Public Methods + + public ITestRuntimeProvider GetTestHostManagerByUri(string hostUri) + { + var host = _testHostExtensionManager.TryGetTestExtension(hostUri); + return host?.Value; + } - public virtual ITestRuntimeProvider GetTestHostManagerByRunConfiguration(string runConfiguration) + public virtual ITestRuntimeProvider GetTestHostManagerByRunConfiguration(string runConfiguration) + { + foreach (var testExtension in _testHostExtensionManager.TestExtensions) { - foreach (var testExtension in this.testHostExtensionManager.TestExtensions) + if (testExtension.Value.CanExecuteCurrentRunConfiguration(runConfiguration)) { - if (testExtension.Value.CanExecuteCurrentRunConfiguration(runConfiguration)) - { - // we are creating a new Instance of ITestRuntimeProvider so that each POM gets it's own object of ITestRuntimeProvider - return (ITestRuntimeProvider)Activator.CreateInstance(testExtension.Value.GetType()); - } + // we are creating a new Instance of ITestRuntimeProvider so that each POM gets it's own object of ITestRuntimeProvider + return (ITestRuntimeProvider)Activator.CreateInstance(testExtension.Value.GetType()); } - - return null; } - #endregion + return null; } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IParallelOperationManager.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IParallelOperationManager.cs index 8eab8ee796..af2b303d66 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IParallelOperationManager.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IParallelOperationManager.cs @@ -1,17 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + +/// +/// Interface defining the parallel operation manager +/// +public interface IParallelOperationManager { /// - /// Interface defining the parallel operation manager + /// Update the parallelism level of the manager /// - public interface IParallelOperationManager - { - /// - /// Update the parallelism level of the manager - /// - /// Parallelism level - void UpdateParallelLevel(int parallelLevel); - } -} + /// Parallelism level + void UpdateParallelLevel(int parallelLevel); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IParallelProxyDiscoveryManager.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IParallelProxyDiscoveryManager.cs index 908b744543..3ba91dfb0a 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IParallelProxyDiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IParallelProxyDiscoveryManager.cs @@ -1,28 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + +using System.Collections.Generic; +/// +/// Interface defining the parallel discovery manager +/// +public interface IParallelProxyDiscoveryManager : IParallelOperationManager, IProxyDiscoveryManager +{ /// - /// Interface defining the parallel discovery manager + /// Handles Partial Discovery Complete event coming from a specific concurrent proxy discovery manager + /// Each concurrent proxy discovery manager will signal the parallel discovery manager when its complete /// - public interface IParallelProxyDiscoveryManager : IParallelOperationManager, IProxyDiscoveryManager - { - /// - /// Handles Partial Discovery Complete event coming from a specific concurrent proxy discovery manager - /// Each concurrent proxy discovery manager will signal the parallel discovery manager when its complete - /// - /// discovery manager instance - /// Total Tests discovered for the concurrent discovery - /// LastChunk testcases for the concurrent discovery - /// True if discovery is aborted - /// True if parallel discovery is complete - bool HandlePartialDiscoveryComplete( - IProxyDiscoveryManager proxyDiscoveryManager, - long totalTests, - IEnumerable lastChunk, - bool isAborted); - } -} + /// discovery manager instance + /// Total Tests discovered for the concurrent discovery + /// LastChunk testcases for the concurrent discovery + /// True if discovery is aborted + /// True if parallel discovery is complete + bool HandlePartialDiscoveryComplete( + IProxyDiscoveryManager proxyDiscoveryManager, + long totalTests, + IEnumerable lastChunk, + bool isAborted); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IParallelProxyExecutionManager.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IParallelProxyExecutionManager.cs index 3834ce414c..3381970880 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IParallelProxyExecutionManager.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IParallelProxyExecutionManager.cs @@ -1,32 +1,31 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + +using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Client; +/// +/// Interface defining the parallel execution manager +/// +public interface IParallelProxyExecutionManager : IParallelOperationManager, IProxyExecutionManager +{ /// - /// Interface defining the parallel execution manager + /// Handles Partial Run Complete event coming from a specific concurrent proxy execution manager + /// Each concurrent proxy execution manager will signal the parallel execution manager when its complete /// - public interface IParallelProxyExecutionManager : IParallelOperationManager, IProxyExecutionManager - { - /// - /// Handles Partial Run Complete event coming from a specific concurrent proxy execution manager - /// Each concurrent proxy execution manager will signal the parallel execution manager when its complete - /// - /// Concurrent Execution manager that completed the run - /// RunCompleteArgs for the concurrent run - /// LastChunk testresults for the concurrent run - /// RunAttachments for the concurrent run - /// ExecutorURIs of the adapters involved in executing the tests - /// True if parallel run is complete - bool HandlePartialRunComplete( - IProxyExecutionManager proxyExecutionManager, - TestRunCompleteEventArgs testRunCompleteArgs, - TestRunChangedEventArgs lastChunkArgs, - ICollection runContextAttachments, - ICollection executorUris); - } -} + /// Concurrent Execution manager that completed the run + /// RunCompleteArgs for the concurrent run + /// LastChunk testresults for the concurrent run + /// RunAttachments for the concurrent run + /// ExecutorURIs of the adapters involved in executing the tests + /// True if parallel run is complete + bool HandlePartialRunComplete( + IProxyExecutionManager proxyExecutionManager, + TestRunCompleteEventArgs testRunCompleteArgs, + TestRunChangedEventArgs lastChunkArgs, + ICollection runContextAttachments, + ICollection executorUris); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IProxyDiscoveryManager.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IProxyDiscoveryManager.cs index c77c525236..abb72e0f1c 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IProxyDiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IProxyDiscoveryManager.cs @@ -1,37 +1,36 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine -{ - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + +using Client; +/// +/// Orchestrates discovery operations for the engine communicating with the client. +/// +public interface IProxyDiscoveryManager +{ /// - /// Orchestrates discovery operations for the engine communicating with the client. + /// Initializes test discovery. Create the test host, setup channel and initialize extensions. + /// Skip default adapters flag. /// - public interface IProxyDiscoveryManager - { - /// - /// Initializes test discovery. Create the test host, setup channel and initialize extensions. - /// Skip default adapters flag. - /// - void Initialize(bool skipDefaultAdapters); + void Initialize(bool skipDefaultAdapters); - /// - /// Discovers tests - /// - /// Settings, parameters for the discovery request - /// EventHandler for handling discovery events from Engine - void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler); + /// + /// Discovers tests + /// + /// Settings, parameters for the discovery request + /// EventHandler for handling discovery events from Engine + void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler); - /// - /// Aborts the test operation. - /// - void Abort(); + /// + /// Aborts the test operation. + /// + void Abort(); - /// - /// Closes the current test operation. - /// Send a EndSession message to close the test host and channel gracefully. - /// - void Close(); - } -} + /// + /// Closes the current test operation. + /// Send a EndSession message to close the test host and channel gracefully. + /// + void Close(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IProxyExecutionManager.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IProxyExecutionManager.cs index 1e696eef6f..4aec854839 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IProxyExecutionManager.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IProxyExecutionManager.cs @@ -1,50 +1,49 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + +using Client; + +/// +/// Orchestrates test execution related functionality for the engine communicating with the client. +/// +public interface IProxyExecutionManager { - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + /// + /// Gets whether current Execution Manager is initialized or not + /// + bool IsInitialized { get; } + + /// + /// Initializes test execution. Create the test host, setup channel and initialize extensions. + /// Skip default adapters flag. + /// + void Initialize(bool skipDefaultAdapters); + + /// + /// Starts the test run. + /// + /// The settings/options for the test run. + /// EventHandler for handling execution events from Engine. + /// The process id of the runner executing tests. + int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler); + + /// + /// Cancels the test run. On the test host, this will send a message to adapters. + /// + // EventHandler for handling execution events from Engine. + void Cancel(ITestRunEventsHandler eventHandler); + + /// + /// Aborts the test operation. This will forcefully terminate the test host. + /// + // EventHandler for handling execution events from Engine. + void Abort(ITestRunEventsHandler eventHandler); /// - /// Orchestrates test execution related functionality for the engine communicating with the client. + /// Closes the current test operation by sending a end session message. + /// Terminates the test host. /// - public interface IProxyExecutionManager - { - /// - /// Gets whether current Execution Manager is initialized or not - /// - bool IsInitialized { get; } - - /// - /// Initializes test execution. Create the test host, setup channel and initialize extensions. - /// Skip default adapters flag. - /// - void Initialize(bool skipDefaultAdapters); - - /// - /// Starts the test run. - /// - /// The settings/options for the test run. - /// EventHandler for handling execution events from Engine. - /// The process id of the runner executing tests. - int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler); - - /// - /// Cancels the test run. On the test host, this will send a message to adapters. - /// - // EventHandler for handling execution events from Engine. - void Cancel(ITestRunEventsHandler eventHandler); - - /// - /// Aborts the test operation. This will forcefully terminate the test host. - /// - // EventHandler for handling execution events from Engine. - void Abort(ITestRunEventsHandler eventHandler); - - /// - /// Closes the current test operation by sending a end session message. - /// Terminates the test host. - /// - void Close(); - } + void Close(); } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IProxyTestSessionManager.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IProxyTestSessionManager.cs index f7db16f472..22470a33cb 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IProxyTestSessionManager.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/IProxyTestSessionManager.cs @@ -1,32 +1,31 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine -{ - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + +using Client; +/// +/// Orchestrates test session related functionality for the engine communicating with the +/// client. +/// +public interface IProxyTestSessionManager +{ /// - /// Orchestrates test session related functionality for the engine communicating with the - /// client. + /// Starts the test session based on the test session criteria. /// - public interface IProxyTestSessionManager - { - /// - /// Starts the test session based on the test session criteria. - /// - /// - /// - /// Event handler for handling events fired during test session management operations. - /// - /// - /// True if the operation succeeded, false otherwise. - bool StartSession(ITestSessionEventsHandler eventsHandler); + /// + /// + /// Event handler for handling events fired during test session management operations. + /// + /// + /// True if the operation succeeded, false otherwise. + bool StartSession(ITestSessionEventsHandler eventsHandler); - /// - /// Stops the test session. - /// - /// - /// True if the operation succeeded, false otherwise. - bool StopSession(); - } -} + /// + /// Stops the test session. + /// + /// + /// True if the operation succeeded, false otherwise. + bool StopSession(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/ITestEngine.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/ITestEngine.cs index 0f75e1616a..b627640e4a 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/ITestEngine.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/ITestEngine.cs @@ -1,85 +1,85 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine -{ - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + +using Client; + +using Host; +/// +/// Defines the functionality of a test engine. +/// +public interface ITestEngine +{ /// - /// Defines the functionality of a test engine. + /// Fetches the DiscoveryManager for this engine. This manager would provide all + /// functionality required for discovery. /// - public interface ITestEngine - { - /// - /// Fetches the DiscoveryManager for this engine. This manager would provide all - /// functionality required for discovery. - /// - /// - /// - /// The request data for providing discovery services and data. - /// - /// Test host manager for the current test discovery. - /// The discovery criteria. - /// - /// An IProxyDiscoveryManager object that can do discovery. - IProxyDiscoveryManager GetDiscoveryManager( - IRequestData requestData, - ITestRuntimeProvider testHostManager, - DiscoveryCriteria discoveryCriteria); + /// + /// + /// The request data for providing discovery services and data. + /// + /// Test host manager for the current test discovery. + /// The discovery criteria. + /// + /// An IProxyDiscoveryManager object that can do discovery. + IProxyDiscoveryManager GetDiscoveryManager( + IRequestData requestData, + ITestRuntimeProvider testHostManager, + DiscoveryCriteria discoveryCriteria); - /// - /// Fetches the ExecutionManager for this engine. This manager would provide all - /// functionality required for execution. - /// - /// - /// - /// The request data for providing common execution services and data. - /// - /// Test host manager for the current test run. - /// Test run criteria of the current test run. - /// - /// An IProxyExecutionManager object that can do execution. - IProxyExecutionManager GetExecutionManager( - IRequestData requestData, - ITestRuntimeProvider testHostManager, - TestRunCriteria testRunCriteria); + /// + /// Fetches the ExecutionManager for this engine. This manager would provide all + /// functionality required for execution. + /// + /// + /// + /// The request data for providing common execution services and data. + /// + /// Test host manager for the current test run. + /// Test run criteria of the current test run. + /// + /// An IProxyExecutionManager object that can do execution. + IProxyExecutionManager GetExecutionManager( + IRequestData requestData, + ITestRuntimeProvider testHostManager, + TestRunCriteria testRunCriteria); - /// - /// Fetches the TestSessionManager for this engine. This manager would provide all - /// functionality required for test session management. - /// - /// - /// - /// The request data for providing test session services and data. - /// - /// - /// Test session criteria of the current test session. - /// - /// - /// An IProxyTestSessionManager object that can manage test sessions. - IProxyTestSessionManager GetTestSessionManager( - IRequestData requestData, - StartTestSessionCriteria testSessionCriteria); + /// + /// Fetches the TestSessionManager for this engine. This manager would provide all + /// functionality required for test session management. + /// + /// + /// + /// The request data for providing test session services and data. + /// + /// + /// Test session criteria of the current test session. + /// + /// + /// An IProxyTestSessionManager object that can manage test sessions. + IProxyTestSessionManager GetTestSessionManager( + IRequestData requestData, + StartTestSessionCriteria testSessionCriteria); - /// - /// Fetches the extension manager for this engine. This manager would provide extensibility - /// features that this engine supports. - /// - /// - /// An ITestExtensionManager object that helps with extensibility. - ITestExtensionManager GetExtensionManager(); + /// + /// Fetches the extension manager for this engine. This manager would provide extensibility + /// features that this engine supports. + /// + /// + /// An ITestExtensionManager object that helps with extensibility. + ITestExtensionManager GetExtensionManager(); - /// - /// Fetches the logger manager for this engine. This manager will provide logger - /// extensibility features that this engine supports. - /// - /// - /// - /// The request data for providing common execution services and data. - /// - /// - /// An ITestLoggerManager object that helps with logger extensibility. - ITestLoggerManager GetLoggerManager(IRequestData requestData); - } -} + /// + /// Fetches the logger manager for this engine. This manager will provide logger + /// extensibility features that this engine supports. + /// + /// + /// + /// The request data for providing common execution services and data. + /// + /// + /// An ITestLoggerManager object that helps with logger extensibility. + ITestLoggerManager GetLoggerManager(IRequestData requestData); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/ITestExtensionManager.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/ITestExtensionManager.cs index d3936240e8..de6f18c2f9 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/ITestExtensionManager.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/ITestExtensionManager.cs @@ -1,25 +1,24 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + +using System.Collections.Generic; +/// +/// Orchestrates extensions for this engine. +/// +public interface ITestExtensionManager +{ /// - /// Orchestrates extensions for this engine. + /// Update the extensions data /// - public interface ITestExtensionManager - { - /// - /// Update the extensions data - /// - /// List of extension paths - /// Skips filtering of extensions (if true) - void UseAdditionalExtensions(IEnumerable pathToAdditionalExtensions, bool skipExtensionFilters); + /// List of extension paths + /// Skips filtering of extensions (if true) + void UseAdditionalExtensions(IEnumerable pathToAdditionalExtensions, bool skipExtensionFilters); - /// - /// Clear the extensions data - /// - void ClearExtensions(); - } -} + /// + /// Clear the extensions data + /// + void ClearExtensions(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/ITestLoggerManager.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/ITestLoggerManager.cs index 8a9b199bf2..b0926796bf 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/ITestLoggerManager.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/ITestLoggerManager.cs @@ -1,77 +1,77 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + +using System; + +using Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Logging; +/// +/// Orchestrates logger operations for this engine. +/// +public interface ITestLoggerManager : IDisposable +{ /// - /// Orchestrates logger operations for this engine. + /// Loggers initialized flag. /// - public interface ITestLoggerManager : IDisposable + bool LoggersInitialized { - /// - /// Loggers initialized flag. - /// - bool LoggersInitialized - { - get; - } + get; + } - /// - /// Initialize loggers. - /// - void Initialize(string runSettings); + /// + /// Initialize loggers. + /// + void Initialize(string runSettings); - /// - /// Handles test run message. - /// - /// - void HandleTestRunMessage(TestRunMessageEventArgs e); + /// + /// Handles test run message. + /// + /// + void HandleTestRunMessage(TestRunMessageEventArgs e); - /// - /// Handles test run start. - /// - /// - void HandleTestRunStart(TestRunStartEventArgs e); + /// + /// Handles test run start. + /// + /// + void HandleTestRunStart(TestRunStartEventArgs e); - /// - /// Handles test run stats change. - /// - /// - void HandleTestRunStatsChange(TestRunChangedEventArgs e); + /// + /// Handles test run stats change. + /// + /// + void HandleTestRunStatsChange(TestRunChangedEventArgs e); - /// - /// Handles test run complete. - /// - /// - void HandleTestRunComplete(TestRunCompleteEventArgs e); + /// + /// Handles test run complete. + /// + /// + void HandleTestRunComplete(TestRunCompleteEventArgs e); - /// - /// Handles discovery message. - /// - /// - void HandleDiscoveryMessage(TestRunMessageEventArgs e); + /// + /// Handles discovery message. + /// + /// + void HandleDiscoveryMessage(TestRunMessageEventArgs e); - /// - /// Handles discovery start. - /// - /// - void HandleDiscoveryStart(DiscoveryStartEventArgs e); + /// + /// Handles discovery start. + /// + /// + void HandleDiscoveryStart(DiscoveryStartEventArgs e); - /// - /// Handles discovered tests. - /// - /// - void HandleDiscoveredTests(DiscoveredTestsEventArgs e); + /// + /// Handles discovered tests. + /// + /// + void HandleDiscoveredTests(DiscoveredTestsEventArgs e); - /// - /// Handles discovery complete. - /// - /// - void HandleDiscoveryComplete(DiscoveryCompleteEventArgs e); - } -} + /// + /// Handles discovery complete. + /// + /// + void HandleDiscoveryComplete(DiscoveryCompleteEventArgs e); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/TestExecutionContext.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/TestExecutionContext.cs index 8f0ebb0267..1ee9429c17 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/TestExecutionContext.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ClientProtocol/TestExecutionContext.cs @@ -1,185 +1,185 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; + +using System; +using System.Runtime.Serialization; + +using Client; + +/// +/// Stores information about test execution context. +/// +[DataContract] +public class TestExecutionContext { - using System; - using System.Runtime.Serialization; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// This constructor doesn't perform any parameter validation, it is meant to be used for serialization."/> + public TestExecutionContext() + { + // Default constructor for Serialization. + } + + /// + /// Initializes a new instance of the class. + /// + /// Frequency of run stats event. + /// Timeout that triggers sending results regardless of cache size. + /// Whether execution is out of process + /// Whether executor process should be kept running after test run completion + /// Whether data collection is enabled or not. + /// Indicates whether test case level events are required. + /// True if ExecutionContext is associated with Test run, false otherwise. + /// True if ExecutionContext needs debugger, false otherwise. + /// Filter criteria string for filtering tests. + /// Additional options for test case filter. + public TestExecutionContext( + long frequencyOfRunStatsChangeEvent, + TimeSpan runStatsChangeEventTimeout, + bool inIsolation, + bool keepAlive, + bool isDataCollectionEnabled, + bool areTestCaseLevelEventsRequired, + bool hasTestRun, + bool isDebug, + string testCaseFilter, + FilterOptions filterOptions) + { + FrequencyOfRunStatsChangeEvent = frequencyOfRunStatsChangeEvent; + RunStatsChangeEventTimeout = runStatsChangeEventTimeout; + InIsolation = inIsolation; + KeepAlive = keepAlive; + IsDataCollectionEnabled = isDataCollectionEnabled; + AreTestCaseLevelEventsRequired = areTestCaseLevelEventsRequired; + + IsDebug = isDebug; + + HasTestRun = hasTestRun; + TestCaseFilter = testCaseFilter; + FilterOptions = filterOptions; + } + + #endregion + + #region Properties + + /// + /// Gets or sets the frequency of run stats event. + /// + [DataMember] + public long FrequencyOfRunStatsChangeEvent + { + get; + set; + } /// - /// Stores information about test execution context. + /// Gets or sets the timeout that triggers sending results regardless of cache size. /// - [DataContract] - public class TestExecutionContext + [DataMember] + public TimeSpan RunStatsChangeEventTimeout { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// This constructor doesn't perform any parameter validation, it is meant to be used for serialization."/> - public TestExecutionContext() - { - // Default constructor for Serialization. - } - - /// - /// Initializes a new instance of the class. - /// - /// Frequency of run stats event. - /// Timeout that triggers sending results regardless of cache size. - /// Whether execution is out of process - /// Whether executor process should be kept running after test run completion - /// Whether data collection is enabled or not. - /// Indicates whether test case level events are required. - /// True if ExecutionContext is associated with Test run, false otherwise. - /// True if ExecutionContext needs debugger, false otherwise. - /// Filter criteria string for filtering tests. - /// Additional options for test case filter. - public TestExecutionContext( - long frequencyOfRunStatsChangeEvent, - TimeSpan runStatsChangeEventTimeout, - bool inIsolation, - bool keepAlive, - bool isDataCollectionEnabled, - bool areTestCaseLevelEventsRequired, - bool hasTestRun, - bool isDebug, - string testCaseFilter, - FilterOptions filterOptions) - { - this.FrequencyOfRunStatsChangeEvent = frequencyOfRunStatsChangeEvent; - this.RunStatsChangeEventTimeout = runStatsChangeEventTimeout; - this.InIsolation = inIsolation; - this.KeepAlive = keepAlive; - this.IsDataCollectionEnabled = isDataCollectionEnabled; - this.AreTestCaseLevelEventsRequired = areTestCaseLevelEventsRequired; - - this.IsDebug = isDebug; - - this.HasTestRun = hasTestRun; - this.TestCaseFilter = testCaseFilter; - this.FilterOptions = filterOptions; - } - - #endregion - - #region Properties - - /// - /// Gets or sets the frequency of run stats event. - /// - [DataMember] - public long FrequencyOfRunStatsChangeEvent - { - get; - set; - } - - /// - /// Gets or sets the timeout that triggers sending results regardless of cache size. - /// - [DataMember] - public TimeSpan RunStatsChangeEventTimeout - { - get; - set; - } - - /// - /// Gets or sets a value indicating whether execution is out of process. - /// - [DataMember] - public bool InIsolation - { - get; - set; - } - - /// - /// Gets or sets a value indicating whether executor process should be kept running after test run completion. - /// - [DataMember] - public bool KeepAlive - { - get; - set; - } - - /// - /// Gets or sets a value indicating whether test case level events need to be sent or not - /// - [DataMember] - public bool AreTestCaseLevelEventsRequired - { - get; - set; - } - - /// - /// Gets or sets a value indicating whether execution is in debug mode. - /// - [DataMember] - public bool IsDebug - { - get; - set; - } - - /// - /// Gets or sets the filter criteria for run with sources to filter test cases. - /// - [DataMember] - public string TestCaseFilter - { - get; - set; - } - - - /// - /// Gets or sets additional options for filtering. - /// - [DataMember] - public FilterOptions FilterOptions - { - get; - set; - } - - /// - /// Gets or sets a value indicating whether data collection is enabled or not. - /// - /// This does not need to be serialized over to the test host process. - [IgnoreDataMember] - public bool IsDataCollectionEnabled - { - get; - set; - } - - /// - /// Gets or sets a value indicating whether execution context is associated with a test run. - /// - [IgnoreDataMember] - public bool HasTestRun - { - get; - set; - } - - /// - /// Gets or sets a configuration associated with this run. - /// - /// It is not serialized over wcf as the information is available in the run settings - [IgnoreDataMember] - public RunConfiguration TestRunConfiguration - { - get; - set; - } - - #endregion + get; + set; } -} + + /// + /// Gets or sets a value indicating whether execution is out of process. + /// + [DataMember] + public bool InIsolation + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether executor process should be kept running after test run completion. + /// + [DataMember] + public bool KeepAlive + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether test case level events need to be sent or not + /// + [DataMember] + public bool AreTestCaseLevelEventsRequired + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether execution is in debug mode. + /// + [DataMember] + public bool IsDebug + { + get; + set; + } + + /// + /// Gets or sets the filter criteria for run with sources to filter test cases. + /// + [DataMember] + public string TestCaseFilter + { + get; + set; + } + + + /// + /// Gets or sets additional options for filtering. + /// + [DataMember] + public FilterOptions FilterOptions + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether data collection is enabled or not. + /// + /// This does not need to be serialized over to the test host process. + [IgnoreDataMember] + public bool IsDataCollectionEnabled + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether execution context is associated with a test run. + /// + [IgnoreDataMember] + public bool HasTestRun + { + get; + set; + } + + /// + /// Gets or sets a configuration associated with this run. + /// + /// It is not serialized over wcf as the information is available in the run settings + [IgnoreDataMember] + public RunConfiguration TestRunConfiguration + { + get; + set; + } + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/IDataCollectorAttachmentsProcessorsFactory.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/IDataCollectorAttachmentsProcessorsFactory.cs index 530ae616dd..b4f04b8c95 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/IDataCollectorAttachmentsProcessorsFactory.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/IDataCollectorAttachmentsProcessorsFactory.cs @@ -2,44 +2,44 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + +/// +/// Creates and return a list of available attachments processor +/// +internal interface IDataCollectorAttachmentsProcessorsFactory { /// /// Creates and return a list of available attachments processor /// - internal interface IDataCollectorAttachmentsProcessorsFactory - { - /// - /// Creates and return a list of available attachments processor - /// - /// List of invoked data collectors - /// Message logger - /// List of attachments processors - DataCollectorAttachmentProcessor[] Create(InvokedDataCollector[] invokedDataCollectors, IMessageLogger logger); - } + /// List of invoked data collectors + /// Message logger + /// List of attachments processors + DataCollectorAttachmentProcessor[] Create(InvokedDataCollector[] invokedDataCollectors, IMessageLogger logger); +} +/// +/// Registered data collector attachment processor +/// +internal class DataCollectorAttachmentProcessor +{ /// - /// Registered data collector attachment processor + /// Data collector FriendlyName /// - internal class DataCollectorAttachmentProcessor - { - /// - /// Data collector FriendlyName - /// - public string FriendlyName { get; private set; } + public string FriendlyName { get; private set; } - /// - /// Data collector attachment processor instance - /// - public IDataCollectorAttachmentProcessor DataCollectorAttachmentProcessorInstance { get; private set; } + /// + /// Data collector attachment processor instance + /// + public IDataCollectorAttachmentProcessor DataCollectorAttachmentProcessorInstance { get; private set; } - public DataCollectorAttachmentProcessor(string friendlyName, IDataCollectorAttachmentProcessor dataCollectorAttachmentProcessor) - { - this.FriendlyName = string.IsNullOrEmpty(friendlyName) ? throw new ArgumentException("Invalid FriendlyName", nameof(friendlyName)) : friendlyName; - this.DataCollectorAttachmentProcessorInstance = dataCollectorAttachmentProcessor ?? throw new ArgumentNullException(nameof(dataCollectorAttachmentProcessor)); - } + public DataCollectorAttachmentProcessor(string friendlyName, IDataCollectorAttachmentProcessor dataCollectorAttachmentProcessor) + { + FriendlyName = string.IsNullOrEmpty(friendlyName) ? throw new ArgumentException("Invalid FriendlyName", nameof(friendlyName)) : friendlyName; + DataCollectorAttachmentProcessorInstance = dataCollectorAttachmentProcessor ?? throw new ArgumentNullException(nameof(dataCollectorAttachmentProcessor)); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ITestCaseEventsHandler.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ITestCaseEventsHandler.cs index 4cd9ef7870..9298162997 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ITestCaseEventsHandler.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ITestCaseEventsHandler.cs @@ -1,45 +1,44 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + +using System.Collections.Generic; +/// +/// The Test Case level events. +/// +public interface ITestCaseEventsHandler +{ /// - /// The Test Case level events. + /// Report start of executing a test case. /// - public interface ITestCaseEventsHandler - { - /// - /// Report start of executing a test case. - /// - /// Details of the test case whose execution is just started. - void SendTestCaseStart(TestCase testCase); + /// Details of the test case whose execution is just started. + void SendTestCaseStart(TestCase testCase); - /// - /// Report end of executing a test case. - /// - /// Details of the test case. - /// Result of the test case executed. - void SendTestCaseEnd(TestCase testCase, TestOutcome outcome); + /// + /// Report end of executing a test case. + /// + /// Details of the test case. + /// Result of the test case executed. + void SendTestCaseEnd(TestCase testCase, TestOutcome outcome); - /// - /// Sends the test result - /// - /// The result. - void SendTestResult(TestResult result); + /// + /// Sends the test result + /// + /// The result. + void SendTestResult(TestResult result); - /// - /// Send session start event. - /// The purpose of this is to perform any initialization before the test case level events are sent. - /// - /// The session start properties. - void SendSessionStart(IDictionary properties); + /// + /// Send session start event. + /// The purpose of this is to perform any initialization before the test case level events are sent. + /// + /// The session start properties. + void SendSessionStart(IDictionary properties); - /// - /// Sends session end event. - /// The purpose of this is to perform any cleanup after the test case level events are sent. - /// - void SendSessionEnd(); - } -} + /// + /// Sends session end event. + /// The purpose of this is to perform any cleanup after the test case level events are sent. + /// + void SendSessionEnd(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ITestRunAttachmentsProcessingManager.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ITestRunAttachmentsProcessingManager.cs index 02f80bf3c1..16a4d12ba4 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ITestRunAttachmentsProcessingManager.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/ITestRunAttachmentsProcessingManager.cs @@ -5,33 +5,33 @@ using System.Collections.ObjectModel; using System.Threading; using System.Threading.Tasks; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + +/// +/// Orchestrates test run attachments processing operations. +/// +internal interface ITestRunAttachmentsProcessingManager { /// - /// Orchestrates test run attachments processing operations. + /// Processes attachments and provides results through handler /// - internal interface ITestRunAttachmentsProcessingManager - { - /// - /// Processes attachments and provides results through handler - /// - /// RunSettings - /// Collection of attachments - /// Collection of invoked data collectors - /// EventHandler for handling test run attachments processing event - /// Cancellation token - Task ProcessTestRunAttachmentsAsync(string runSettingsXml, IRequestData requestData, IEnumerable attachments, IEnumerable invokedDataCollector, ITestRunAttachmentsProcessingEventsHandler eventHandler, CancellationToken cancellationToken); + /// RunSettings + /// Collection of attachments + /// Collection of invoked data collectors + /// EventHandler for handling test run attachments processing event + /// Cancellation token + Task ProcessTestRunAttachmentsAsync(string runSettingsXml, IRequestData requestData, IEnumerable attachments, IEnumerable invokedDataCollector, ITestRunAttachmentsProcessingEventsHandler eventHandler, CancellationToken cancellationToken); - /// - /// Processes attachments - /// - /// RunSettings - /// Collection of attachments - /// Collection of invoked data collectors - /// Cancellation token - /// Collection of attachments. - Task> ProcessTestRunAttachmentsAsync(string runSettingsXml, IRequestData requestData, IEnumerable attachments, IEnumerable invokedDataCollector, CancellationToken cancellationToken); - } -} + /// + /// Processes attachments + /// + /// RunSettings + /// Collection of attachments + /// Collection of invoked data collectors + /// Cancellation token + /// Collection of attachments. + Task> ProcessTestRunAttachmentsAsync(string runSettingsXml, IRequestData requestData, IEnumerable attachments, IEnumerable invokedDataCollector, CancellationToken cancellationToken); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/IDiscoveryManager.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/IDiscoveryManager.cs index e60787a968..77e32bfa19 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/IDiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/IDiscoveryManager.cs @@ -1,33 +1,32 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; + +using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Client; +/// +/// Orchestrates discovery operations for the engine communicating with the test host process. +/// +public interface IDiscoveryManager +{ /// - /// Orchestrates discovery operations for the engine communicating with the test host process. + /// Initializes the discovery manager. /// - public interface IDiscoveryManager - { - /// - /// Initializes the discovery manager. - /// - /// The path to additional extensions. - void Initialize(IEnumerable pathToAdditionalExtensions, ITestDiscoveryEventsHandler2 eventHandler); + /// The path to additional extensions. + void Initialize(IEnumerable pathToAdditionalExtensions, ITestDiscoveryEventsHandler2 eventHandler); - /// - /// Discovers tests - /// - /// Settings, parameters for the discovery request - /// EventHandler for handling discovery events from Engine - void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler); + /// + /// Discovers tests + /// + /// Settings, parameters for the discovery request + /// EventHandler for handling discovery events from Engine + void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler); - /// - /// Aborts the test discovery. - /// - void Abort(); - } -} + /// + /// Aborts the test discovery. + /// + void Abort(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/IExecutionManager.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/IExecutionManager.cs index d868f7ec86..7955dbc1c8 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/IExecutionManager.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/IExecutionManager.cs @@ -1,60 +1,60 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; + +using System.Collections.Generic; + +using Client; + +using ClientProtocol; + +/// +/// Orchestrates test execution related functionality for the engine communicating with the test host process. +/// +public interface IExecutionManager { - using System.Collections.Generic; + /// + /// Initializes the execution manager. + /// + /// The path to additional extensions. + void Initialize(IEnumerable pathToAdditionalExtensions, ITestMessageEventHandler testMessageEventsHandler); + + /// + /// Starts the test run with sources. + /// + /// The adapter Source Map. + /// The packages which actually contain sources. A testhost can at max execute for one package at time + /// Package can be null if test source, and package are same + /// + /// The run Settings. + /// The test Execution Context. + /// EventHandler for handling test cases level events from Engine. + /// EventHandler for handling execution events from Engine. + void StartTestRun(Dictionary> adapterSourceMap, string package, string runSettings, TestExecutionContext testExecutionContext, ITestCaseEventsHandler testCaseEvents, ITestRunEventsHandler eventHandler); - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; + /// + /// Starts the test run with tests. + /// + /// The test list. + /// The packages which actually contain sources. A testhost can at max execute for one package at time + /// Package can be null if test source, and package are same + /// + /// The run Settings. + /// The test Execution Context. + /// /// EventHandler for handling test cases level events from Engine. + /// EventHandler for handling execution events from Engine. + void StartTestRun(IEnumerable tests, string package, string runSettings, TestExecutionContext testExecutionContext, ITestCaseEventsHandler testCaseEvents, ITestRunEventsHandler eventHandler); + + /// + /// Cancel the test execution. + /// + /// EventHandler for handling execution events from Engine. + void Cancel(ITestRunEventsHandler testRunEventsHandler); /// - /// Orchestrates test execution related functionality for the engine communicating with the test host process. + /// Aborts the test execution. /// - public interface IExecutionManager - { - /// - /// Initializes the execution manager. - /// - /// The path to additional extensions. - void Initialize(IEnumerable pathToAdditionalExtensions, ITestMessageEventHandler testMessageEventsHandler); - - /// - /// Starts the test run with sources. - /// - /// The adapter Source Map. - /// The packages which actually contain sources. A testhost can at max execute for one package at time - /// Package can be null if test source, and package are same - /// - /// The run Settings. - /// The test Execution Context. - /// EventHandler for handling test cases level events from Engine. - /// EventHandler for handling execution events from Engine. - void StartTestRun(Dictionary> adapterSourceMap, string package, string runSettings, TestExecutionContext testExecutionContext, ITestCaseEventsHandler testCaseEvents, ITestRunEventsHandler eventHandler); - - /// - /// Starts the test run with tests. - /// - /// The test list. - /// The packages which actually contain sources. A testhost can at max execute for one package at time - /// Package can be null if test source, and package are same - /// - /// The run Settings. - /// The test Execution Context. - /// /// EventHandler for handling test cases level events from Engine. - /// EventHandler for handling execution events from Engine. - void StartTestRun(IEnumerable tests, string package, string runSettings, TestExecutionContext testExecutionContext, ITestCaseEventsHandler testCaseEvents, ITestRunEventsHandler eventHandler); - - /// - /// Cancel the test execution. - /// - /// EventHandler for handling execution events from Engine. - void Cancel(ITestRunEventsHandler testRunEventsHandler); - - /// - /// Aborts the test execution. - /// - /// EventHandler for handling execution events from Engine. - void Abort(ITestRunEventsHandler testRunEventsHandler); - } -} + /// EventHandler for handling execution events from Engine. + void Abort(ITestRunEventsHandler testRunEventsHandler); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/ITestHostManagerFactory.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/ITestHostManagerFactory.cs index acb649fdc5..e7b26eb557 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/ITestHostManagerFactory.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/ITestHostManagerFactory.cs @@ -1,23 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; + +/// +/// The factory that provides discovery and execution managers to the test host. +/// +public interface ITestHostManagerFactory { /// - /// The factory that provides discovery and execution managers to the test host. + /// The discovery manager instance for any discovery related operations inside of the test host. /// - public interface ITestHostManagerFactory - { - /// - /// The discovery manager instance for any discovery related operations inside of the test host. - /// - /// The discovery manager. - IDiscoveryManager GetDiscoveryManager(); + /// The discovery manager. + IDiscoveryManager GetDiscoveryManager(); - /// - /// The execution manager instance for any discovery related operations inside of the test host. - /// - /// The execution manager. - IExecutionManager GetExecutionManager(); - } -} + /// + /// The execution manager instance for any discovery related operations inside of the test host. + /// + /// The execution manager. + IExecutionManager GetExecutionManager(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/IAssemblyProperties.cs b/src/Microsoft.TestPlatform.Common/Interfaces/IAssemblyProperties.cs index ede5a7d257..bc9478b2a6 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/IAssemblyProperties.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/IAssemblyProperties.cs @@ -1,18 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces -{ - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces; + +using Utilities; +/// +/// Metadata that is available for input test source, e.g. Whether it is native or managed dll, etc.. +/// +public interface IAssemblyProperties +{ /// - /// Metadata that is available for input test source, e.g. Whether it is native or managed dll, etc.. + /// Determines assembly type from file. /// - public interface IAssemblyProperties - { - /// - /// Determines assembly type from file. - /// - AssemblyType GetAssemblyType(string filePath); - } -} + AssemblyType GetAssemblyType(string filePath); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/IBaseTestEventsRegistrar.cs b/src/Microsoft.TestPlatform.Common/Interfaces/IBaseTestEventsRegistrar.cs index eec8315ee9..9a3136be01 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/IBaseTestEventsRegistrar.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/IBaseTestEventsRegistrar.cs @@ -1,14 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces; + +public interface IBaseTestEventsRegistrar { - public interface IBaseTestEventsRegistrar - { - /// - /// Log warning message before request is created. - /// - /// message string - void LogWarning(string message); - } -} + /// + /// Log warning message before request is created. + /// + /// message string + void LogWarning(string message); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/IDataCollectorCapabilities.cs b/src/Microsoft.TestPlatform.Common/Interfaces/IDataCollectorCapabilities.cs index 965c3dd44f..b347132d2b 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/IDataCollectorCapabilities.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/IDataCollectorCapabilities.cs @@ -1,21 +1,20 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces; + +/// +/// Metadata that is available from data collectors. +/// +public interface IDataCollectorCapabilities : ITestExtensionCapabilities { /// - /// Metadata that is available from data collectors. + /// Gets the friendly name corresponding to the data collector. /// - public interface IDataCollectorCapabilities : ITestExtensionCapabilities - { - /// - /// Gets the friendly name corresponding to the data collector. - /// - string FriendlyName { get; } + string FriendlyName { get; } - /// - /// Check if the data collector has got attachment processor registered. - /// - bool HasAttachmentProcessor { get; } - } -} + /// + /// Check if the data collector has got attachment processor registered. + /// + bool HasAttachmentProcessor { get; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/IRunSettingsProvider.cs b/src/Microsoft.TestPlatform.Common/Interfaces/IRunSettingsProvider.cs index 8d0e184c57..90ddecfaa2 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/IRunSettingsProvider.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/IRunSettingsProvider.cs @@ -1,22 +1,21 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces; + +/// +/// Provides access to the active run settings. +/// +internal interface IRunSettingsProvider { /// - /// Provides access to the active run settings. + /// The active run settings. /// - internal interface IRunSettingsProvider - { - /// - /// The active run settings. - /// - RunSettings ActiveRunSettings { get; } + RunSettings ActiveRunSettings { get; } - /// - /// Set the active run settings. - /// - /// RunSettings to make the active Run Settings. - void SetActiveRunSettings(RunSettings runSettings); - } -} + /// + /// Set the active run settings. + /// + /// RunSettings to make the active Run Settings. + void SetActiveRunSettings(RunSettings runSettings); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/ISettingsProviderCapabilities.cs b/src/Microsoft.TestPlatform.Common/Interfaces/ISettingsProviderCapabilities.cs index bdd538d1f1..6c5a5b6a9a 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/ISettingsProviderCapabilities.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/ISettingsProviderCapabilities.cs @@ -1,19 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces; +/// +/// Metadata that is available from Settings Providers. +/// +public interface ISettingsProviderCapabilities { - using System.Diagnostics.CodeAnalysis; - /// - /// Metadata that is available from Settings Providers. + /// Gets the name of the settings section. /// - [SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes", Justification = "This interface is only public due to limitations in MEF which require metadata interfaces to be public.")] - public interface ISettingsProviderCapabilities - { - /// - /// Gets the name of the settings section. - /// - string SettingsName { get; } - } -} + string SettingsName { get; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/ITestDiscovererCapabilities.cs b/src/Microsoft.TestPlatform.Common/Interfaces/ITestDiscovererCapabilities.cs index d7f7ec2a7a..e727a39721 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/ITestDiscovererCapabilities.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/ITestDiscovererCapabilities.cs @@ -1,31 +1,30 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces -{ - using System; - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces; + +using System; +using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Utilities; +/// +/// Metadata that is available from Test Discoverers. +/// +public interface ITestDiscovererCapabilities +{ /// - /// Metadata that is available from Test Discoverers. + /// List of file extensions that the test discoverer can process tests from. /// - public interface ITestDiscovererCapabilities - { - /// - /// List of file extensions that the test discoverer can process tests from. - /// - IEnumerable FileExtension { get; } + IEnumerable FileExtension { get; } - /// - /// Default executor Uri for this discoverer - /// - Uri DefaultExecutorUri { get; } + /// + /// Default executor Uri for this discoverer + /// + Uri DefaultExecutorUri { get; } - /// - /// Assembly type that the test discoverer supports. - /// - AssemblyType AssemblyType { get; } - } -} + /// + /// Assembly type that the test discoverer supports. + /// + AssemblyType AssemblyType { get; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/ITestDiscoveryEventsRegistrar.cs b/src/Microsoft.TestPlatform.Common/Interfaces/ITestDiscoveryEventsRegistrar.cs index 984b5b582a..aa36325e6a 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/ITestDiscoveryEventsRegistrar.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/ITestDiscoveryEventsRegistrar.cs @@ -1,23 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces -{ - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces; + +using ObjectModel.Client; - public interface ITestDiscoveryEventsRegistrar : IBaseTestEventsRegistrar - { - /// - /// Registers to receive discovery events from discovery request. - /// These events will then be broadcast to any registered loggers. - /// - /// The discovery request to register for events on. - void RegisterDiscoveryEvents(IDiscoveryRequest discoveryRequest); +public interface ITestDiscoveryEventsRegistrar : IBaseTestEventsRegistrar +{ + /// + /// Registers to receive discovery events from discovery request. + /// These events will then be broadcast to any registered loggers. + /// + /// The discovery request to register for events on. + void RegisterDiscoveryEvents(IDiscoveryRequest discoveryRequest); - /// - /// Unregister the events from the discovery request. - /// - /// The discovery request from which events should be unregistered. - void UnregisterDiscoveryEvents(IDiscoveryRequest discoveryRequest); - } -} + /// + /// Unregister the events from the discovery request. + /// + /// The discovery request from which events should be unregistered. + void UnregisterDiscoveryEvents(IDiscoveryRequest discoveryRequest); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/ITestExecutorCapabilities.cs b/src/Microsoft.TestPlatform.Common/Interfaces/ITestExecutorCapabilities.cs index c8fd2fbf57..52b5ccc49a 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/ITestExecutorCapabilities.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/ITestExecutorCapabilities.cs @@ -1,12 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces; + +/// +/// Metadata that is available from Test Executors. +/// +internal interface ITestExecutorCapabilities : ITestExtensionCapabilities { - /// - /// Metadata that is available from Test Executors. - /// - internal interface ITestExecutorCapabilities : ITestExtensionCapabilities - { - } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/ITestExtensionCapabilities.cs b/src/Microsoft.TestPlatform.Common/Interfaces/ITestExtensionCapabilities.cs index 8f23e8e126..da169ce257 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/ITestExtensionCapabilities.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/ITestExtensionCapabilities.cs @@ -1,16 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces; + +/// +/// Basic metadata for extensions which are identified by a URI. +/// +public interface ITestExtensionCapabilities { /// - /// Basic metadata for extensions which are identified by a URI. + /// Gets the URI of the test extension. /// - public interface ITestExtensionCapabilities - { - /// - /// Gets the URI of the test extension. - /// - string ExtensionUri { get; } - } -} + string ExtensionUri { get; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/ITestLoggerCapabilities.cs b/src/Microsoft.TestPlatform.Common/Interfaces/ITestLoggerCapabilities.cs index 16d30d5750..07a5fb6a6a 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/ITestLoggerCapabilities.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/ITestLoggerCapabilities.cs @@ -1,14 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces; + +/// +/// Metadata that is available from Test Loggers. +/// +public interface ITestLoggerCapabilities : ITestExtensionCapabilities { - /// - /// Metadata that is available from Test Loggers. - /// - public interface ITestLoggerCapabilities : ITestExtensionCapabilities - { - /// specifies the friendly name corresponding to the logger. - string FriendlyName { get; } - } -} + /// specifies the friendly name corresponding to the logger. + string FriendlyName { get; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/ITestRunEventsRegistrar.cs b/src/Microsoft.TestPlatform.Common/Interfaces/ITestRunEventsRegistrar.cs index 23cdbc0fb8..d3ce2812f5 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/ITestRunEventsRegistrar.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/ITestRunEventsRegistrar.cs @@ -1,23 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces -{ - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces; + +using ObjectModel.Client; - public interface ITestRunEventsRegistrar : IBaseTestEventsRegistrar - { - /// - /// Registers to receive events from the provided test run request. - /// These events will then be broadcast to any registered loggers. - /// - /// The run request to register for events on. - void RegisterTestRunEvents(ITestRunRequest testRunRequest); +public interface ITestRunEventsRegistrar : IBaseTestEventsRegistrar +{ + /// + /// Registers to receive events from the provided test run request. + /// These events will then be broadcast to any registered loggers. + /// + /// The run request to register for events on. + void RegisterTestRunEvents(ITestRunRequest testRunRequest); - /// - /// Unregisters the events from the test run request. - /// - /// The run request from which events should be unregistered. - void UnregisterTestRunEvents(ITestRunRequest testRunRequest); - } -} + /// + /// Unregisters the events from the test run request. + /// + /// The run request from which events should be unregistered. + void UnregisterTestRunEvents(ITestRunRequest testRunRequest); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/ITestRunTimeCapabilities.cs b/src/Microsoft.TestPlatform.Common/Interfaces/ITestRunTimeCapabilities.cs index 9b1b17ab67..ef93ef764a 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/ITestRunTimeCapabilities.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/ITestRunTimeCapabilities.cs @@ -1,14 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces; + +/// +/// Metadata that is available from Test Host. +/// +public interface ITestRuntimeCapabilities : ITestExtensionCapabilities { - /// - /// Metadata that is available from Test Host. - /// - public interface ITestRuntimeCapabilities : ITestExtensionCapabilities - { - /// specifies the friendly name corresponding to the TestHost. - string FriendlyName { get; } - } -} + /// specifies the friendly name corresponding to the TestHost. + string FriendlyName { get; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/IVSExtensionManager.cs b/src/Microsoft.TestPlatform.Common/Interfaces/IVSExtensionManager.cs index 977f2d34cf..7a53b81c1b 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/IVSExtensionManager.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/IVSExtensionManager.cs @@ -1,15 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.Common.Interfaces; + +using System.Collections.Generic; - public interface IVSExtensionManager - { - /// - /// Get the unit test extensions installed via vsix. - /// - IEnumerable GetUnitTestExtensions(); - } -} +public interface IVSExtensionManager +{ + /// + /// Get the unit test extensions installed via vsix. + /// + IEnumerable GetUnitTestExtensions(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Logging/InternalTestLoggerEvents.cs b/src/Microsoft.TestPlatform.Common/Logging/InternalTestLoggerEvents.cs index 3cf909db96..38386fcad7 100644 --- a/src/Microsoft.TestPlatform.Common/Logging/InternalTestLoggerEvents.cs +++ b/src/Microsoft.TestPlatform.Common/Logging/InternalTestLoggerEvents.cs @@ -1,468 +1,470 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Logging -{ - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using System; - using System.Collections.ObjectModel; - using System.Diagnostics; +namespace Microsoft.VisualStudio.TestPlatform.Common.Logging; + +using ObjectModel; +using ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.Utilities; + +using System; +using System.Collections.ObjectModel; +using System.Diagnostics; #if NETFRAMEWORK - using System.Configuration; +using System.Configuration; #endif +/// +/// Exposes events that Test Loggers can register for and allows for them +/// to be raised through the IRunMessageLogger interface. +/// +internal class InternalTestLoggerEvents : TestLoggerEvents, IDisposable +{ + #region Fields + /// - /// Exposes events that Test Loggers can register for and allows for them - /// to be raised through the IRunMessageLogger interface. + /// Queue used for events which are to be sent to the loggers. /// - internal class InternalTestLoggerEvents : TestLoggerEvents, IDisposable - { - #region Fields - - /// - /// Queue used for events which are to be sent to the loggers. - /// - /// - /// Using the queue accomplishes two things. - /// 1. Loggers do not need to be written to be thread safe because - /// we will only be raising one event to them at a time. - /// 2. Allows all events to go to all loggers even during initialization - /// because we queue up all events sent until raising of events to the - /// loggers is enabled - /// - private JobQueue loggerEventQueue; - - /// - /// Keeps track if we are disposed. - /// - private bool isDisposed = false; - - /// - /// Specifies whether logger event queue is bounded or not - /// - private bool isBoundsOnLoggerEventQueueEnabled; - - private TestSessionMessageLogger testSessionMessageLogger; - #endregion - - #region Constructor - - /// - /// Default constructor. - /// - public InternalTestLoggerEvents(TestSessionMessageLogger testSessionMessageLogger) - { + /// + /// Using the queue accomplishes two things. + /// 1. Loggers do not need to be written to be thread safe because + /// we will only be raising one event to them at a time. + /// 2. Allows all events to go to all loggers even during initialization + /// because we queue up all events sent until raising of events to the + /// loggers is enabled + /// + private readonly JobQueue _loggerEventQueue; - // Initialize the queue and pause it. - // Note: The queue will be resumed when events are enabled. This is done so all - // loggers receive all messages. - this.isBoundsOnLoggerEventQueueEnabled = IsBoundsEnabledOnLoggerEventQueue(); - this.loggerEventQueue = new JobQueue( - this.ProcessQueuedJob, - "Test Logger", - GetMaxNumberOfJobsInQueue(), - GetMaxBytesQueueCanHold(), - this.isBoundsOnLoggerEventQueueEnabled, - (message) => EqtTrace.Error(message)); - this.loggerEventQueue.Pause(); - - // Register for events from the test run message logger so they - // can be raised to the loggers. - this.testSessionMessageLogger = testSessionMessageLogger; - this.testSessionMessageLogger.TestRunMessage += this.TestRunMessageHandler; - } + /// + /// Keeps track if we are disposed. + /// + private bool _isDisposed = false; - #endregion + /// + /// Specifies whether logger event queue is bounded or not + /// + private readonly bool _isBoundsOnLoggerEventQueueEnabled; - #region Events + private readonly TestSessionMessageLogger _testSessionMessageLogger; + #endregion - /// - /// Raised when a test message is received. - /// - public override event EventHandler TestRunMessage; + #region Constructor - /// - /// Raised when a test run starts. - /// - public override event EventHandler TestRunStart; + /// + /// Default constructor. + /// + public InternalTestLoggerEvents(TestSessionMessageLogger testSessionMessageLogger) + { - /// - /// Raised when a test result is received. - /// - public override event EventHandler TestResult; + // Initialize the queue and pause it. + // Note: The queue will be resumed when events are enabled. This is done so all + // loggers receive all messages. + _isBoundsOnLoggerEventQueueEnabled = IsBoundsEnabledOnLoggerEventQueue(); + _loggerEventQueue = new JobQueue( + ProcessQueuedJob, + "Test Logger", + GetMaxNumberOfJobsInQueue(), + GetMaxBytesQueueCanHold(), + _isBoundsOnLoggerEventQueueEnabled, + (message) => EqtTrace.Error(message)); + _loggerEventQueue.Pause(); + + // Register for events from the test run message logger so they + // can be raised to the loggers. + _testSessionMessageLogger = testSessionMessageLogger; + _testSessionMessageLogger.TestRunMessage += TestRunMessageHandler; + } - /// - /// Raised when a test run is complete. - /// - public override event EventHandler TestRunComplete; + #endregion - /// - /// Raised when test discovery starts. - /// - public override event EventHandler DiscoveryStart; + #region Events - /// - /// Raised when a discovery message is received. - /// - public override event EventHandler DiscoveryMessage; + /// + /// Raised when a test message is received. + /// + public override event EventHandler TestRunMessage; - /// - /// Raised when discovered tests are received - /// - public override event EventHandler DiscoveredTests; + /// + /// Raised when a test run starts. + /// + public override event EventHandler TestRunStart; - /// - /// Raised when test discovery is complete - /// - public override event EventHandler DiscoveryComplete; + /// + /// Raised when a test result is received. + /// + public override event EventHandler TestResult; - #endregion + /// + /// Raised when a test run is complete. + /// + public override event EventHandler TestRunComplete; - #region IDisposable + /// + /// Raised when test discovery starts. + /// + public override event EventHandler DiscoveryStart; - /// - /// Waits for all pending messages to be processed by the loggers cleans up. - /// - public void Dispose() - { - if (this.isDisposed) - { - return; - } - this.isDisposed = true; + /// + /// Raised when a discovery message is received. + /// + public override event EventHandler DiscoveryMessage; - // Unregister for test run messages. - this.testSessionMessageLogger.TestRunMessage -= this.TestRunMessageHandler; + /// + /// Raised when discovered tests are received + /// + public override event EventHandler DiscoveredTests; - // Ensure that the queue is processed before returning. - this.loggerEventQueue.Resume(); - this.loggerEventQueue.Dispose(); - } + /// + /// Raised when test discovery is complete + /// + public override event EventHandler DiscoveryComplete; - #endregion + #endregion - #region Internal Methods + #region IDisposable - /// - /// Enables sending of events to the loggers which are registered and flushes the queue. - /// - /// - /// By default events are disabled and will not be raised until this method is called. - /// This is done because during logger initialization, errors could be sent and we do not - /// want them broadcast out to the loggers until all loggers have been enabled. Without this - /// all loggers would not receive the errors which were sent prior to initialization finishing. - /// - internal void EnableEvents() + /// + /// Waits for all pending messages to be processed by the loggers cleans up. + /// + public void Dispose() + { + if (_isDisposed) { - this.CheckDisposed(); + return; + } + _isDisposed = true; - this.loggerEventQueue.Resume(); + // Unregister for test run messages. + _testSessionMessageLogger.TestRunMessage -= TestRunMessageHandler; - // Allow currently queued events to flush from the queue. This is done so that information - // logged during initialization completes processing before we begin other tasks. This is - // important for instance when errors are logged during initialization and need to be output - // to the console before we begin outputting other information to the console. - this.loggerEventQueue.Flush(); - } + // Ensure that the queue is processed before returning. + _loggerEventQueue.Resume(); + _loggerEventQueue.Dispose(); + } - /// - /// Raises a test run message event to the enabled loggers. - /// - /// Arguments to be raised. - internal void RaiseTestRunMessage(TestRunMessageEventArgs args) - { - if (args == null) - { - throw new ArgumentNullException(nameof(args)); - } + #endregion - this.CheckDisposed(); + #region Internal Methods - // Sending 0 size as this event is not expected to contain any data. - this.SafeInvokeAsync(() => this.TestRunMessage, args, 0, "InternalTestLoggerEvents.SendTestRunMessage"); - } + /// + /// Enables sending of events to the loggers which are registered and flushes the queue. + /// + /// + /// By default events are disabled and will not be raised until this method is called. + /// This is done because during logger initialization, errors could be sent and we do not + /// want them broadcast out to the loggers until all loggers have been enabled. Without this + /// all loggers would not receive the errors which were sent prior to initialization finishing. + /// + internal void EnableEvents() + { + CheckDisposed(); + + _loggerEventQueue.Resume(); - internal void WaitForEventCompletion() + // Allow currently queued events to flush from the queue. This is done so that information + // logged during initialization completes processing before we begin other tasks. This is + // important for instance when errors are logged during initialization and need to be output + // to the console before we begin outputting other information to the console. + _loggerEventQueue.Flush(); + } + + /// + /// Raises a test run message event to the enabled loggers. + /// + /// Arguments to be raised. + internal void RaiseTestRunMessage(TestRunMessageEventArgs args) + { + if (args == null) { - this.loggerEventQueue.Flush(); + throw new ArgumentNullException(nameof(args)); } - /// - /// Raises a test result event to the enabled loggers. - /// - /// Arguments to be raised. - internal void RaiseTestResult(TestResultEventArgs args) - { - ValidateArg.NotNull(args, nameof(args)); + CheckDisposed(); - this.CheckDisposed(); + // Sending 0 size as this event is not expected to contain any data. + SafeInvokeAsync(() => TestRunMessage, args, 0, "InternalTestLoggerEvents.SendTestRunMessage"); + } - // find the approx size of test result - int resultSize = 0; - if (this.isBoundsOnLoggerEventQueueEnabled) - { - resultSize = FindTestResultSize(args) * sizeof(char); - } + internal void WaitForEventCompletion() + { + _loggerEventQueue.Flush(); + } - this.SafeInvokeAsync(() => this.TestResult, args, resultSize, "InternalTestLoggerEvents.SendTestResult"); - } + /// + /// Raises a test result event to the enabled loggers. + /// + /// Arguments to be raised. + internal void RaiseTestResult(TestResultEventArgs args) + { + ValidateArg.NotNull(args, nameof(args)); + + CheckDisposed(); - /// - /// Raises the test run start event to enabled loggers. - /// - /// Arguments to be raised. - internal void RaiseTestRunStart(TestRunStartEventArgs args) + // find the approx size of test result + int resultSize = 0; + if (_isBoundsOnLoggerEventQueueEnabled) { - ValidateArg.NotNull(args, nameof(args)); + resultSize = FindTestResultSize(args) * sizeof(char); + } - CheckDisposed(); + SafeInvokeAsync(() => TestResult, args, resultSize, "InternalTestLoggerEvents.SendTestResult"); + } - this.SafeInvokeAsync(() => this.TestRunStart, args, 0, "InternalTestLoggerEvents.SendTestRunStart"); - } + /// + /// Raises the test run start event to enabled loggers. + /// + /// Arguments to be raised. + internal void RaiseTestRunStart(TestRunStartEventArgs args) + { + ValidateArg.NotNull(args, nameof(args)); - /// - /// Raises a discovery start event to the enabled loggers. - /// - /// Arguments to be raised. - internal void RaiseDiscoveryStart(DiscoveryStartEventArgs args) - { - ValidateArg.NotNull(args, nameof(args)); + CheckDisposed(); - CheckDisposed(); + SafeInvokeAsync(() => TestRunStart, args, 0, "InternalTestLoggerEvents.SendTestRunStart"); + } - SafeInvokeAsync(() => this.DiscoveryStart, args, 0, "InternalTestLoggerEvents.SendDiscoveryStart"); - } + /// + /// Raises a discovery start event to the enabled loggers. + /// + /// Arguments to be raised. + internal void RaiseDiscoveryStart(DiscoveryStartEventArgs args) + { + ValidateArg.NotNull(args, nameof(args)); - /// - /// Raises a discovery message event to the enabled loggers. - /// - /// Arguments to be raised. - internal void RaiseDiscoveryMessage(TestRunMessageEventArgs args) - { - ValidateArg.NotNull(args, nameof(args)); + CheckDisposed(); - this.CheckDisposed(); + SafeInvokeAsync(() => DiscoveryStart, args, 0, "InternalTestLoggerEvents.SendDiscoveryStart"); + } - // Sending 0 size as this event is not expected to contain any data. - this.SafeInvokeAsync(() => this.DiscoveryMessage, args, 0, "InternalTestLoggerEvents.SendDiscoveryMessage"); - } + /// + /// Raises a discovery message event to the enabled loggers. + /// + /// Arguments to be raised. + internal void RaiseDiscoveryMessage(TestRunMessageEventArgs args) + { + ValidateArg.NotNull(args, nameof(args)); - /// - /// Raises discovered tests event to the enabled loggers. - /// - /// Arguments to be raised. - internal void RaiseDiscoveredTests(DiscoveredTestsEventArgs args) - { - ValidateArg.NotNull(args, nameof(args)); + CheckDisposed(); - CheckDisposed(); + // Sending 0 size as this event is not expected to contain any data. + SafeInvokeAsync(() => DiscoveryMessage, args, 0, "InternalTestLoggerEvents.SendDiscoveryMessage"); + } - SafeInvokeAsync(() => this.DiscoveredTests, args, 0, "InternalTestLoggerEvents.SendDiscoveredTests"); - } + /// + /// Raises discovered tests event to the enabled loggers. + /// + /// Arguments to be raised. + internal void RaiseDiscoveredTests(DiscoveredTestsEventArgs args) + { + ValidateArg.NotNull(args, nameof(args)); - /// - /// Raises discovery complete event to the enabled loggers. - /// - /// Arguments to be raised. - internal void RaiseDiscoveryComplete(DiscoveryCompleteEventArgs args) - { - ValidateArg.NotNull(args, nameof(args)); + CheckDisposed(); - CheckDisposed(); + SafeInvokeAsync(() => DiscoveredTests, args, 0, "InternalTestLoggerEvents.SendDiscoveredTests"); + } - // Sending 0 size as this event is not expected to contain any data. - SafeInvokeAsync(() => this.DiscoveryComplete, args, 0, "InternalTestLoggerEvents.SendDiscoveryComplete"); + /// + /// Raises discovery complete event to the enabled loggers. + /// + /// Arguments to be raised. + internal void RaiseDiscoveryComplete(DiscoveryCompleteEventArgs args) + { + ValidateArg.NotNull(args, nameof(args)); - // Wait for the loggers to finish processing the messages for the run. - this.loggerEventQueue.Flush(); - } + CheckDisposed(); - /// - /// Raises test run complete to the enabled loggers - /// - /// Arguments to be raised - internal void RaiseTestRunComplete(TestRunCompleteEventArgs args) - { - ValidateArg.NotNull(args, nameof(args)); + // Sending 0 size as this event is not expected to contain any data. + SafeInvokeAsync(() => DiscoveryComplete, args, 0, "InternalTestLoggerEvents.SendDiscoveryComplete"); - CheckDisposed(); + // Wait for the loggers to finish processing the messages for the run. + _loggerEventQueue.Flush(); + } - // Size is being send as 0. (It is good to send the size as the job queue uses it) - SafeInvokeAsync(() => this.TestRunComplete, args, 0, "InternalTestLoggerEvents.SendTestRunComplete"); + /// + /// Raises test run complete to the enabled loggers + /// + /// Arguments to be raised + internal void RaiseTestRunComplete(TestRunCompleteEventArgs args) + { + ValidateArg.NotNull(args, nameof(args)); - // Wait for the loggers to finish processing the messages for the run. - this.loggerEventQueue.Flush(); - } + CheckDisposed(); - /// - /// Raise the test run complete event to test loggers and waits - /// for the events to be processed. - /// - /// Specifies the stats of the test run. - /// Specifies whether the test run is canceled. - /// Specifies whether the test run is aborted. - /// Specifies the error that occurs during the test run. - /// Run level attachment sets - /// Invoked data collectors - /// Time elapsed in just running the tests. - internal void CompleteTestRun(ITestRunStatistics stats, bool isCanceled, bool isAborted, Exception error, Collection attachmentSet, Collection invokedDataCollectors, TimeSpan elapsedTime) - { - this.CheckDisposed(); + // Size is being send as 0. (It is good to send the size as the job queue uses it) + SafeInvokeAsync(() => TestRunComplete, args, 0, "InternalTestLoggerEvents.SendTestRunComplete"); - var args = new TestRunCompleteEventArgs(stats, isCanceled, isAborted, error, attachmentSet, invokedDataCollectors, elapsedTime); + // Wait for the loggers to finish processing the messages for the run. + _loggerEventQueue.Flush(); + } - // Sending 0 size as this event is not expected to contain any data. - this.SafeInvokeAsync(() => this.TestRunComplete, args, 0, "InternalTestLoggerEvents.SendTestRunComplete"); + /// + /// Raise the test run complete event to test loggers and waits + /// for the events to be processed. + /// + /// Specifies the stats of the test run. + /// Specifies whether the test run is canceled. + /// Specifies whether the test run is aborted. + /// Specifies the error that occurs during the test run. + /// Run level attachment sets + /// Invoked data collectors + /// Time elapsed in just running the tests. + internal void CompleteTestRun(ITestRunStatistics stats, bool isCanceled, bool isAborted, Exception error, Collection attachmentSet, Collection invokedDataCollectors, TimeSpan elapsedTime) + { + CheckDisposed(); - // Wait for the loggers to finish processing the messages for the run. - this.loggerEventQueue.Flush(); - } + var args = new TestRunCompleteEventArgs(stats, isCanceled, isAborted, error, attachmentSet, invokedDataCollectors, elapsedTime); - #endregion + // Sending 0 size as this event is not expected to contain any data. + SafeInvokeAsync(() => TestRunComplete, args, 0, "InternalTestLoggerEvents.SendTestRunComplete"); - #region Private Members + // Wait for the loggers to finish processing the messages for the run. + _loggerEventQueue.Flush(); + } - /// - /// Called when a test run message is sent through the ITestRunMessageLogger which is exported. - /// - private void TestRunMessageHandler(object sender, TestRunMessageEventArgs e) - { - // Broadcast the message to the loggers. - this.SafeInvokeAsync(() => this.TestRunMessage, e, 0, "InternalTestLoggerEvents.SendMessage"); - } + #endregion - /// - /// Invokes each of the subscribers of the event and handles exceptions which are thrown - /// ensuring that each handler is invoked even if one throws. - /// The actual calling of the subscribers is done on a background thread. - /// - private void SafeInvokeAsync(Func eventHandlersFactory, EventArgs args, int size, string traceDisplayName) - { - ValidateArg.NotNull(eventHandlersFactory, nameof(eventHandlersFactory)); - ValidateArg.NotNull(args, nameof(args)); - - // Invoke the handlers on a background thread. - this.loggerEventQueue.QueueJob( - () => - { - var eventHandlers = eventHandlersFactory(); - eventHandlers?.SafeInvoke(this, args, traceDisplayName); - }, size); - } + #region Private Members - /// - /// Method called to process a job which is coming from the logger event queue. - /// - private void ProcessQueuedJob(Action action) - { - action(); - } + /// + /// Called when a test run message is sent through the ITestRunMessageLogger which is exported. + /// + private void TestRunMessageHandler(object sender, TestRunMessageEventArgs e) + { + // Broadcast the message to the loggers. + SafeInvokeAsync(() => TestRunMessage, e, 0, "InternalTestLoggerEvents.SendMessage"); + } - /// - /// Throws if we are disposed. - /// - private void CheckDisposed() - { - if (this.isDisposed) + /// + /// Invokes each of the subscribers of the event and handles exceptions which are thrown + /// ensuring that each handler is invoked even if one throws. + /// The actual calling of the subscribers is done on a background thread. + /// + private void SafeInvokeAsync(Func eventHandlersFactory, EventArgs args, int size, string traceDisplayName) + { + ValidateArg.NotNull(eventHandlersFactory, nameof(eventHandlersFactory)); + ValidateArg.NotNull(args, nameof(args)); + + // Invoke the handlers on a background thread. + _loggerEventQueue.QueueJob( + () => { - throw new ObjectDisposedException(typeof(TestLoggerEvents).FullName); - } - } + var eventHandlers = eventHandlersFactory(); + eventHandlers?.SafeInvoke(this, args, traceDisplayName); + }, size); + } - /// - /// The method parses the config file of vstest.console.exe to see if the Max Job Queue Length is defined. - /// Return the Max Queue Length so defined or a default value specified by TestPlatformDefaults.DefaultMaxLoggerEventsToCache - /// - private int GetMaxNumberOfJobsInQueue() - { - return GetSetting(TestPlatformDefaults.MaxNumberOfEventsLoggerEventQueueCanHold, - TestPlatformDefaults.DefaultMaxNumberOfEventsLoggerEventQueueCanHold); - } + /// + /// Method called to process a job which is coming from the logger event queue. + /// + private void ProcessQueuedJob(Action action) + { + action(); + } - /// - /// The method parses the config file of vstest.console.exe to see if the Max Job Queue size is defined. - /// Return the Max Queue size so defined or a default value specified by TestPlatformDefaults.DefaultMaxJobQueueSize - /// - private int GetMaxBytesQueueCanHold() + /// + /// Throws if we are disposed. + /// + private void CheckDisposed() + { + if (_isDisposed) { - return GetSetting(TestPlatformDefaults.MaxBytesLoggerEventQueueCanHold, - TestPlatformDefaults.DefaultMaxBytesLoggerEventQueueCanHold); + throw new ObjectDisposedException(typeof(TestLoggerEvents).FullName); } + } - /// - /// Returns whether flow control on logger events queue should be enabled or not. Default is enabled. - /// - private static bool IsBoundsEnabledOnLoggerEventQueue() - { - bool enableBounds; + /// + /// The method parses the config file of vstest.console.exe to see if the Max Job Queue Length is defined. + /// Return the Max Queue Length so defined or a default value specified by TestPlatformDefaults.DefaultMaxLoggerEventsToCache + /// + private int GetMaxNumberOfJobsInQueue() + { + return GetSetting(TestPlatformDefaults.MaxNumberOfEventsLoggerEventQueueCanHold, + TestPlatformDefaults.DefaultMaxNumberOfEventsLoggerEventQueueCanHold); + } + + /// + /// The method parses the config file of vstest.console.exe to see if the Max Job Queue size is defined. + /// Return the Max Queue size so defined or a default value specified by TestPlatformDefaults.DefaultMaxJobQueueSize + /// + private int GetMaxBytesQueueCanHold() + { + return GetSetting(TestPlatformDefaults.MaxBytesLoggerEventQueueCanHold, + TestPlatformDefaults.DefaultMaxBytesLoggerEventQueueCanHold); + } + + /// + /// Returns whether flow control on logger events queue should be enabled or not. Default is enabled. + /// + private static bool IsBoundsEnabledOnLoggerEventQueue() + { + bool enableBounds; + string enableBoundsOnEventQueueIsDefined = #if NETFRAMEWORK - string enableBoundsOnEventQueueIsDefined = ConfigurationManager.AppSettings[TestPlatformDefaults.EnableBoundsOnLoggerEventQueue]; + ConfigurationManager.AppSettings[TestPlatformDefaults.EnableBoundsOnLoggerEventQueue]; #else - string enableBoundsOnEventQueueIsDefined = null; + null; #endif - if (string.IsNullOrEmpty(enableBoundsOnEventQueueIsDefined)) + if (string.IsNullOrEmpty(enableBoundsOnEventQueueIsDefined)) + { + enableBounds = TestPlatformDefaults.DefaultEnableBoundsOnLoggerEventQueue; + } + else + { + if (!(bool.TryParse(enableBoundsOnEventQueueIsDefined, out enableBounds))) { enableBounds = TestPlatformDefaults.DefaultEnableBoundsOnLoggerEventQueue; } - else - { - if (!(bool.TryParse(enableBoundsOnEventQueueIsDefined, out enableBounds))) - { - enableBounds = TestPlatformDefaults.DefaultEnableBoundsOnLoggerEventQueue; - } - } - return enableBounds; } + return enableBounds; + } - /// - /// Returns the approximate size of a TestResult instance. - /// - private static int FindTestResultSize(TestResultEventArgs args) - { - Debug.Assert(args != null && args.Result != null); + /// + /// Returns the approximate size of a TestResult instance. + /// + private static int FindTestResultSize(TestResultEventArgs args) + { + Debug.Assert(args != null && args.Result != null); - int size = 0; + int size = 0; - if (args.Result.Messages.Count != 0) + if (args.Result.Messages.Count != 0) + { + foreach (TestResultMessage msg in args.Result.Messages) { - foreach (TestResultMessage msg in args.Result.Messages) - { - if (!string.IsNullOrEmpty(msg.Text)) - size += msg.Text.Length; - } + if (!string.IsNullOrEmpty(msg.Text)) + size += msg.Text.Length; } - return size; } + return size; + } - /// - /// Get the appsetting value for the parameter appSettingKey. Use the parameter defaultValue if - /// value is not there or is invalid. - /// - private int GetSetting(string appSettingKey, int defaultValue) - { - int value; + /// + /// Get the appsetting value for the parameter appSettingKey. Use the parameter defaultValue if + /// value is not there or is invalid. + /// + private int GetSetting(string appSettingKey, int defaultValue) + { + int value; + string appSettingValue = #if NETFRAMEWORK - string appSettingValue = ConfigurationManager.AppSettings[appSettingKey]; + ConfigurationManager.AppSettings[appSettingKey]; #else - string appSettingValue = null; + null; #endif - if (string.IsNullOrEmpty(appSettingValue)) - { - value = defaultValue; - } - else if (!int.TryParse(appSettingValue, out value) || value < 1) - { - EqtTrace.Warning("Unacceptable value '{0}' of {1}. Using default {2}", appSettingValue, appSettingKey, defaultValue); - value = defaultValue; - } - - return value; + if (string.IsNullOrEmpty(appSettingValue)) + { + value = defaultValue; + } + else if (!int.TryParse(appSettingValue, out value) || value < 1) + { + EqtTrace.Warning("Unacceptable value '{0}' of {1}. Using default {2}", appSettingValue, appSettingKey, defaultValue); + value = defaultValue; } - #endregion + return value; } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Logging/TestSessionMessageLogger.cs b/src/Microsoft.TestPlatform.Common/Logging/TestSessionMessageLogger.cs index 558bfb6fa2..ddcc87d06c 100644 --- a/src/Microsoft.TestPlatform.Common/Logging/TestSessionMessageLogger.cs +++ b/src/Microsoft.TestPlatform.Common/Logging/TestSessionMessageLogger.cs @@ -1,84 +1,83 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Logging -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.Common.Logging; + +using System; + +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.Utilities; +using ObjectModelCommonResources = ObjectModel.Resources.CommonResources; - using ObjectModelCommonResources = Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources.CommonResources; +/// +/// The test session message logger. +/// +internal class TestSessionMessageLogger : IMessageLogger +{ + private static TestSessionMessageLogger s_instance; /// - /// The test session message logger. + /// Initializes a new instance of the class. /// - internal class TestSessionMessageLogger : IMessageLogger + protected TestSessionMessageLogger() { - private static TestSessionMessageLogger instance; + TreatTestAdapterErrorsAsWarnings = Constants.DefaultTreatTestAdapterErrorsAsWarnings; + } + + /// + /// Raised when a discovery message is received. + /// + internal event EventHandler TestRunMessage; - /// - /// Initializes a new instance of the class. - /// - protected TestSessionMessageLogger() + /// + /// Gets the instance of the singleton. + /// + public static TestSessionMessageLogger Instance + { + get { - this.TreatTestAdapterErrorsAsWarnings = Constants.DefaultTreatTestAdapterErrorsAsWarnings; + return s_instance ??= new TestSessionMessageLogger(); } + set + { + s_instance = value; + } + } - /// - /// Raised when a discovery message is received. - /// - internal event EventHandler TestRunMessage; + /// + /// Gets or sets a value indicating whether to treat test adapter errors as warnings. + /// + internal bool TreatTestAdapterErrorsAsWarnings + { + get; + set; + } - /// - /// Gets the instance of the singleton. - /// - public static TestSessionMessageLogger Instance + /// + /// Sends a message to all listeners. + /// + /// Level of the message. + /// The message to be sent. + public void SendMessage(TestMessageLevel testMessageLevel, string message) + { + if (string.IsNullOrWhiteSpace(message)) { - get - { - return instance ?? (instance = new TestSessionMessageLogger()); - } - set - { - instance = value; - } + throw new ArgumentException(ObjectModelCommonResources.CannotBeNullOrEmpty, nameof(message)); } - /// - /// Gets or sets a value indicating whether to treat test adapter errors as warnings. - /// - internal bool TreatTestAdapterErrorsAsWarnings + if (TreatTestAdapterErrorsAsWarnings + && testMessageLevel == TestMessageLevel.Error) { - get; - set; + // Downgrade the message severity to Warning... + testMessageLevel = TestMessageLevel.Warning; } - /// - /// Sends a message to all listeners. - /// - /// Level of the message. - /// The message to be sent. - public void SendMessage(TestMessageLevel testMessageLevel, string message) + if (TestRunMessage != null) { - if (string.IsNullOrWhiteSpace(message)) - { - throw new ArgumentException(ObjectModelCommonResources.CannotBeNullOrEmpty, nameof(message)); - } - - if (this.TreatTestAdapterErrorsAsWarnings - && testMessageLevel == TestMessageLevel.Error) - { - // Downgrade the message severity to Warning... - testMessageLevel = TestMessageLevel.Warning; - } - - if (this.TestRunMessage != null) - { - var args = new TestRunMessageEventArgs(testMessageLevel, message); - this.TestRunMessage.SafeInvoke(this, args, "TestRunMessageLoggerProxy.SendMessage"); - } + var args = new TestRunMessageEventArgs(testMessageLevel, message); + TestRunMessage.SafeInvoke(this, args, "TestRunMessageLoggerProxy.SendMessage"); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/RequestData.cs b/src/Microsoft.TestPlatform.Common/RequestData.cs index 128bc3fc5f..5e78922849 100644 --- a/src/Microsoft.TestPlatform.Common/RequestData.cs +++ b/src/Microsoft.TestPlatform.Common/RequestData.cs @@ -1,58 +1,58 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common +namespace Microsoft.VisualStudio.TestPlatform.Common; + +using System; + +using Telemetry; +using ObjectModel.Client; + +/// +/// +/// Provide common services and data for a discovery/run request. +/// +public class RequestData : IRequestData { - using System; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + /// + /// The metrics collection. + /// + private IMetricsCollection _metricsCollection; - /// /// - /// Provide common services and data for a discovery/run request. + /// The protocol config. /// - public class RequestData : IRequestData + private ProtocolConfig _protocolConfig; + + /// + /// The default constructor for request data. + /// + public RequestData() { - /// - /// The metrics collection. - /// - private IMetricsCollection metricsCollection; - - /// - /// The protocol config. - /// - private ProtocolConfig protocolConfig; - - /// - /// The default constructor for request data. - /// - public RequestData() - { - this.MetricsCollection = new NoOpMetricsCollection(); - this.IsTelemetryOptedIn = false; - } - - /// - /// Gets or sets the metrics collection. - /// - public IMetricsCollection MetricsCollection - { - get => this.metricsCollection; - set => this.metricsCollection = value ?? throw new ArgumentNullException(nameof(value)); - } - - /// - /// Gets or sets the protocol config. - /// - public ProtocolConfig ProtocolConfig - { - get => this.protocolConfig; - set => this.protocolConfig = value ?? throw new ArgumentNullException(nameof(value)); - } - - /// - /// Gets or sets a value indicating whether is telemetry opted in. - /// - public bool IsTelemetryOptedIn { get; set; } + MetricsCollection = new NoOpMetricsCollection(); + IsTelemetryOptedIn = false; } -} + + /// + /// Gets or sets the metrics collection. + /// + public IMetricsCollection MetricsCollection + { + get => _metricsCollection; + set => _metricsCollection = value ?? throw new ArgumentNullException(nameof(value)); + } + + /// + /// Gets or sets the protocol config. + /// + public ProtocolConfig ProtocolConfig + { + get => _protocolConfig; + set => _protocolConfig = value ?? throw new ArgumentNullException(nameof(value)); + } + + /// + /// Gets or sets a value indicating whether is telemetry opted in. + /// + public bool IsTelemetryOptedIn { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/RunSettings.cs b/src/Microsoft.TestPlatform.Common/RunSettings.cs index 722c642d15..030348f58d 100644 --- a/src/Microsoft.TestPlatform.Common/RunSettings.cs +++ b/src/Microsoft.TestPlatform.Common/RunSettings.cs @@ -1,285 +1,267 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common +namespace Microsoft.VisualStudio.TestPlatform.Common; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Xml; + +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Interfaces; +using Logging; +using SettingsProvider; +using ObjectModel; +using ObjectModel.Adapter; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; + +using CommonResources = Resources.Resources; +using ObjectModelCommonResources = ObjectModel.Resources.CommonResources; + +/// +/// Used for loading settings for a run. +/// +public class RunSettings : IRunSettings { - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Globalization; - using System.IO; - using System.Xml; - - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.Common.SettingsProvider; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - - using CommonResources = Microsoft.VisualStudio.TestPlatform.Common.Resources.Resources; - using ObjectModelCommonResources = Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources.CommonResources; + #region Fields /// - /// Used for loading settings for a run. + /// Map of the settings names in the file to their associated settings provider. /// - public class RunSettings : IRunSettings + private readonly Dictionary> _settings; + + /// + /// Used to keep track if settings have been loaded. + /// + private bool _isSettingsLoaded; + + #endregion + + /// + /// Initializes a new instance of the class. + /// + public RunSettings() { - #region Fields + _settings = new Dictionary>(); + } + + #region Properties - /// - /// Map of the settings names in the file to their associated settings provider. - /// - private Dictionary> settings; + /// + /// Gets the settings in the form of Xml string. + /// + public string SettingsXml { get; private set; } - /// - /// Used to keep track if settings have been loaded. - /// - private bool isSettingsLoaded; + #endregion - #endregion + #region Public Methods - /// - /// Initializes a new instance of the class. - /// - public RunSettings() + /// + /// Get the settings for the provided settings name. + /// + /// Name of the settings section to get. + /// The settings provider for the settings or null if one was not found. + public ISettingsProvider GetSettings(string settingsName) + { + if (StringUtilities.IsNullOrWhiteSpace(settingsName)) { - this.settings = new Dictionary>(); + throw new ArgumentException(ObjectModelCommonResources.CannotBeNullOrEmpty, nameof(settingsName)); } - #region Properties - - /// - /// Gets the settings in the form of Xml string. - /// - public string SettingsXml { get; private set; } + // Try and lookup the settings provider. + ISettingsProvider result = null; + _settings.TryGetValue(settingsName, out var provider); - #endregion + // If a provider was found, return it. + if (provider != null) + { + result = provider.Value; + } - #region Public Methods + return result; + } - /// - /// Get the settings for the provided settings name. - /// - /// Name of the settings section to get. - /// The settings provider for the settings or null if one was not found. - public ISettingsProvider GetSettings(string settingsName) + /// + /// Load the settings from the provided xml string. + /// + /// xml string + public void LoadSettingsXml(string settings) + { + if (StringUtilities.IsNullOrWhiteSpace(settings)) { - if (StringUtilities.IsNullOrWhiteSpace(settingsName)) - { - throw new ArgumentException(ObjectModelCommonResources.CannotBeNullOrEmpty, nameof(settingsName)); - } + throw new ArgumentException(ObjectModelCommonResources.CannotBeNullOrEmpty, settings); + } - // Try and lookup the settings provider. - ISettingsProvider result = null; - this.settings.TryGetValue(settingsName, out var provider); + using var stringReader = new StringReader(settings); + var reader = XmlReader.Create(stringReader, XmlRunSettingsUtilities.ReaderSettings); + ValidateAndSaveSettings(reader); + } - // If a provider was found, return it. - if (provider != null) - { - result = provider.Value; - } + /// + /// Initialize settings providers with the settings xml. + /// + /// The settings xml string. + public void InitializeSettingsProviders(string settings) + { + using var stringReader = new StringReader(settings); + var reader = XmlReader.Create(stringReader, XmlRunSettingsUtilities.ReaderSettings); + ReadRunSettings(reader); + } - return result; - } + #endregion - /// - /// Load the settings from the provided xml string. - /// - /// xml string - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", - Justification = "XmlReaderSettings.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] - public void LoadSettingsXml(string settings) - { - if (StringUtilities.IsNullOrWhiteSpace(settings)) - { - throw new ArgumentException(ObjectModelCommonResources.CannotBeNullOrEmpty, settings); - } + #region Private Methods - using (var stringReader = new StringReader(settings)) - { - var reader = XmlReader.Create(stringReader, XmlRunSettingsUtilities.ReaderSettings); - this.ValidateAndSaveSettings(reader); - } + /// + /// Validate the runsettings checking that it is well formed. + /// This would throw XML exception on failure. + /// + /// A xml reader instance. + private void ValidateAndSaveSettings(XmlReader reader) + { + try + { + var dom = new XmlDocument(); + dom.Load(reader); + using var writer = new StringWriter(CultureInfo.InvariantCulture); + dom.Save(writer); + SettingsXml = writer.ToString(); } - - /// - /// Initialize settings providers with the settings xml. - /// - /// The settings xml string. - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", - Justification = "XmlReaderSettings.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] - public void InitializeSettingsProviders(string settings) + catch (Exception e) { - using (var stringReader = new StringReader(settings)) - { - var reader = XmlReader.Create(stringReader, XmlRunSettingsUtilities.ReaderSettings); - this.ReadRunSettings(reader); - } + throw new SettingsException( + string.Format( + CultureInfo.CurrentCulture, + CommonResources.RunSettingsParseError, + e.Message), + e); } + } - #endregion + /// + /// Reads test run settings from XmlReader + /// + /// + private void ReadRunSettings(XmlReader reader) + { + // If settings have already been loaded, throw. + if (_isSettingsLoaded) + { + throw new InvalidOperationException(CommonResources.RunSettingsAlreadyLoaded); + } - #region Private Methods + _isSettingsLoaded = true; - /// - /// Validate the runsettings checking that it is well formed. - /// This would throw XML exception on failure. - /// - /// A xml reader instance. - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", - Justification = "XmlDocument.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] - private void ValidateAndSaveSettings(XmlReader reader) + try { - try - { - var dom = new XmlDocument(); - dom.Load(reader); - using (var writer = new StringWriter(CultureInfo.InvariantCulture)) - { - dom.Save(writer); - this.SettingsXml = writer.ToString(); - } - } - catch (Exception e) + // Read to the root element. + XmlReaderUtilities.ReadToRootNode(reader); + + // Read to the first section. + reader.ReadToNextElement(); + + // Lookup the settings provider for each of the elements. + var settingsExtensionManager = SettingsProviderExtensionManager.Create(); + while (!reader.EOF) { - throw new SettingsException( - string.Format( - CultureInfo.CurrentCulture, - CommonResources.RunSettingsParseError, - e.Message), - e); + LoadSection(reader, settingsExtensionManager); + reader.SkipToNextElement(); } } + catch (SettingsException) + { + throw; + } + catch (Exception e) + { + throw new SettingsException( + string.Format( + CultureInfo.CurrentCulture, + CommonResources.RunSettingsParseError, + e.Message), + e); + } + } + + /// + /// Loads the section for the current element of the reader. + /// + /// Reader to load the section from. + /// Settings extension manager to get the provider from. + private void LoadSection(XmlReader reader, SettingsProviderExtensionManager settingsExtensionManager) + { + ValidateArg.NotNull(reader, nameof(reader)); + ValidateArg.NotNull(settingsExtensionManager, nameof(settingsExtensionManager)); - /// - /// Reads test run settings from XmlReader - /// - /// - private void ReadRunSettings(XmlReader reader) + // Check for duplicate settings + if (_settings.ContainsKey(reader.Name)) { - // If settings have already been loaded, throw. - if (this.isSettingsLoaded) - { - throw new InvalidOperationException(CommonResources.RunSettingsAlreadyLoaded); - } + TestSessionMessageLogger.Instance.SendMessage( + TestMessageLevel.Error, + string.Format(CultureInfo.CurrentCulture, CommonResources.DuplicateSettingsProvided, reader.Name)); - this.isSettingsLoaded = true; + return; + } + // Look up the section for this node. + var provider = settingsExtensionManager.GetSettingsProvider(reader.Name); + + if (provider != null) + { try { - // Read to the root element. - XmlReaderUtilities.ReadToRootNode(reader); - - // Read to the first section. - reader.ReadToNextElement(); - - // Lookup the settings provider for each of the elements. - var settingsExtensionManager = SettingsProviderExtensionManager.Create(); - while (!reader.EOF) - { - this.LoadSection(reader, settingsExtensionManager); - reader.SkipToNextElement(); - } - } - catch (SettingsException) - { - throw; + // Have the provider load the settings. + provider.Value.Load(reader.ReadSubtree()); } catch (Exception e) { - throw new SettingsException( + // Setup to throw the exception when the section is requested. + provider = CreateLazyThrower( string.Format( CultureInfo.CurrentCulture, - CommonResources.RunSettingsParseError, + CommonResources.SettingsProviderInitializationError, + provider.Metadata.SettingsName, e.Message), + provider.Metadata, e); } } - - /// - /// Loads the section for the current element of the reader. - /// - /// Reader to load the section from. - /// Settings extension manager to get the provider from. - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "This methods must not fail on crash in loading settings.")] - private void LoadSection(XmlReader reader, SettingsProviderExtensionManager settingsExtensionManager) + else { - ValidateArg.NotNull(reader, nameof(reader)); - ValidateArg.NotNull(settingsExtensionManager, nameof(settingsExtensionManager)); - - // Check for duplicate settings - if (this.settings.ContainsKey(reader.Name)) - { - TestSessionMessageLogger.Instance.SendMessage( - TestMessageLevel.Error, - string.Format(CultureInfo.CurrentCulture, CommonResources.DuplicateSettingsProvided, reader.Name)); - - return; - } - - // Look up the section for this node. - var provider = settingsExtensionManager.GetSettingsProvider(reader.Name); - - if (provider != null) - { - try - { - // Have the provider load the settings. - provider.Value.Load(reader.ReadSubtree()); - } - catch (Exception e) - { - // Setup to throw the exception when the section is requested. - provider = CreateLazyThrower( - string.Format( - CultureInfo.CurrentCulture, - CommonResources.SettingsProviderInitializationError, - provider.Metadata.SettingsName, - e.Message), - provider.Metadata, - e); - } - } - else - { - // Setup to throw when this section is requested. - var metadata = new TestSettingsProviderMetadata(reader.Name); - - var message = string.Format( - CultureInfo.CurrentCulture, - CommonResources.SettingsProviderNotFound, - metadata.SettingsName); + // Setup to throw when this section is requested. + var metadata = new TestSettingsProviderMetadata(reader.Name); - provider = CreateLazyThrower(message, metadata); - } + var message = string.Format( + CultureInfo.CurrentCulture, + CommonResources.SettingsProviderNotFound, + metadata.SettingsName); - // Cache the provider instance so it can be looked up later when the section is requested. - this.settings.Add(provider.Metadata.SettingsName, provider); + provider = CreateLazyThrower(message, metadata); } - /// - /// Creates a lazy instance which will throw a SettingsException when the value property is accessed. - /// - /// Message for the exception. - /// Metadata to use for the lazy instance. - /// Inner exception to include in the exception which is thrown. - /// Lazy instance setup to throw when the value property is accessed. - private static LazyExtension CreateLazyThrower( - string message, - ISettingsProviderCapabilities metadata, - Exception innerException = null) - { - return new LazyExtension( - () => - { - throw new SettingsException(message, innerException); - }, - metadata); - } + // Cache the provider instance so it can be looked up later when the section is requested. + _settings.Add(provider.Metadata.SettingsName, provider); + } - #endregion + /// + /// Creates a lazy instance which will throw a SettingsException when the value property is accessed. + /// + /// Message for the exception. + /// Metadata to use for the lazy instance. + /// Inner exception to include in the exception which is thrown. + /// Lazy instance setup to throw when the value property is accessed. + private static LazyExtension CreateLazyThrower( + string message, + ISettingsProviderCapabilities metadata, + Exception innerException = null) + { + return new LazyExtension( + () => throw new SettingsException(message, innerException), + metadata); } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/RunSettingsManager.cs b/src/Microsoft.TestPlatform.Common/RunSettingsManager.cs index 41c4a58feb..f8e4f791f2 100644 --- a/src/Microsoft.TestPlatform.Common/RunSettingsManager.cs +++ b/src/Microsoft.TestPlatform.Common/RunSettingsManager.cs @@ -1,83 +1,83 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common -{ - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +namespace Microsoft.VisualStudio.TestPlatform.Common; - /// - /// Manages the active run settings. - /// - internal class RunSettingsManager : IRunSettingsProvider - { - #region private members +using Interfaces; - private static object lockObject = new object(); +using ObjectModel; - private static RunSettingsManager runSettingsManagerInstance; +/// +/// Manages the active run settings. +/// +internal class RunSettingsManager : IRunSettingsProvider +{ + #region private members - #endregion + private static readonly object LockObject = new(); - #region Constructor + private static RunSettingsManager s_runSettingsManagerInstance; - /// - /// Default constructor. - /// - private RunSettingsManager() - { - this.ActiveRunSettings = new RunSettings(); - } + #endregion + #region Constructor + + /// + /// Default constructor. + /// + private RunSettingsManager() + { + ActiveRunSettings = new RunSettings(); + } - #endregion - #region IRunSettingsProvider + #endregion - /// - /// Gets the active run settings. - /// - public RunSettings ActiveRunSettings { get; private set; } + #region IRunSettingsProvider + + /// + /// Gets the active run settings. + /// + public RunSettings ActiveRunSettings { get; private set; } - #endregion + #endregion - #region Public Methods + #region Public Methods - public static RunSettingsManager Instance + public static RunSettingsManager Instance + { + get { - get + if (s_runSettingsManagerInstance != null) { - if (runSettingsManagerInstance != null) - { - return runSettingsManagerInstance; - } + return s_runSettingsManagerInstance; + } - lock (lockObject) + lock (LockObject) + { + if (s_runSettingsManagerInstance == null) { - if (runSettingsManagerInstance == null) - { - runSettingsManagerInstance = new RunSettingsManager(); - } + s_runSettingsManagerInstance = new RunSettingsManager(); } - - return runSettingsManagerInstance; - } - internal set - { - runSettingsManagerInstance = value; } - } - /// - /// Set the active run settings. - /// - /// RunSettings to make the active Run Settings. - public void SetActiveRunSettings(RunSettings runSettings) + return s_runSettingsManagerInstance; + } + internal set { - ValidateArg.NotNull(runSettings, nameof(runSettings)); - this.ActiveRunSettings = runSettings; + s_runSettingsManagerInstance = value; } + } - #endregion + /// + /// Set the active run settings. + /// + /// RunSettings to make the active Run Settings. + public void SetActiveRunSettings(RunSettings runSettings) + { + ValidateArg.NotNull(runSettings, nameof(runSettings)); + ActiveRunSettings = runSettings; } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/SettingsProvider/SettingsProviderExtensionManager.cs b/src/Microsoft.TestPlatform.Common/SettingsProvider/SettingsProviderExtensionManager.cs index 0ba94175fb..9a6d47bf42 100644 --- a/src/Microsoft.TestPlatform.Common/SettingsProvider/SettingsProviderExtensionManager.cs +++ b/src/Microsoft.TestPlatform.Common/SettingsProvider/SettingsProviderExtensionManager.cs @@ -1,244 +1,232 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.SettingsProvider +namespace Microsoft.VisualStudio.TestPlatform.Common.SettingsProvider; + +using System; +using System.Collections.Generic; +using System.Globalization; + +using ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Interfaces; +using Logging; +using ObjectModel; +using ObjectModel.Adapter; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +using CommonResources = Resources.Resources; +using ObjectModelCommonResources = ObjectModel.Resources.CommonResources; + +/// +/// Manages the settings provider extensions. +/// +/// +/// This is a non-shared instance because we want different settings provider instances to +/// be used for each run settings instance. +/// +public class SettingsProviderExtensionManager { - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Globalization; - - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - - using CommonResources = Microsoft.VisualStudio.TestPlatform.Common.Resources.Resources; - using ObjectModelCommonResources = Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources.CommonResources; + #region Fields + private static SettingsProviderExtensionManager s_settingsProviderExtensionManager; + private static readonly object Synclock = new(); /// - /// Manages the settings provider extensions. + /// The settings providers which are available. + /// + private readonly IEnumerable> _settingsProviders; + + /// + /// Used for logging errors. + /// + private readonly IMessageLogger _logger; + + #endregion + + #region Constructor + + /// + /// Initializes with the settings providers. /// /// - /// This is a non-shared instance because we want different settings provider instances to - /// be used for each run settings instance. + /// The settings providers are imported as non-shared because we need different settings provider + /// instances to be used for each run settings. /// - public class SettingsProviderExtensionManager + protected SettingsProviderExtensionManager( + IEnumerable> settingsProviders, + IEnumerable>> unfilteredSettingsProviders, + IMessageLogger logger) { - #region Fields - private static SettingsProviderExtensionManager settingsProviderExtensionManager; - private static object synclock = new object(); - - /// - /// The settings providers which are available. - /// - private IEnumerable> settingsProviders; - private Dictionary> settingsProvidersMap; - - /// - /// Used for logging errors. - /// - private IMessageLogger logger; - - #endregion - - #region Constructor - - /// - /// Initializes with the settings providers. - /// - /// - /// The settings providers are imported as non-shared because we need different settings provider - /// instances to be used for each run settings. - /// - [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")] - protected SettingsProviderExtensionManager( - IEnumerable> settingsProviders, - IEnumerable>> unfilteredSettingsProviders, - IMessageLogger logger) - { - ValidateArg.NotNull>>(settingsProviders, nameof(settingsProviders)); - ValidateArg.NotNull>>>(unfilteredSettingsProviders, nameof(unfilteredSettingsProviders)); - ValidateArg.NotNull(logger, nameof(logger)); + ValidateArg.NotNull(settingsProviders, nameof(settingsProviders)); + ValidateArg.NotNull(unfilteredSettingsProviders, nameof(unfilteredSettingsProviders)); + ValidateArg.NotNull(logger, nameof(logger)); - this.settingsProviders = settingsProviders; - this.UnfilteredSettingsProviders = unfilteredSettingsProviders; - this.logger = logger; + _settingsProviders = settingsProviders; + UnfilteredSettingsProviders = unfilteredSettingsProviders; + _logger = logger; - // Populate the map to avoid threading issues - this.PopulateMap(); - } + // Populate the map to avoid threading issues + PopulateMap(); + } - #endregion + #endregion - #region Properties + #region Properties - /// - /// Gets the Unfiltered list of settings providers. Used for the /ListSettingsProviders command line argument. - /// - [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")] - public IEnumerable>> UnfilteredSettingsProviders { get; private set; } + /// + /// Gets the Unfiltered list of settings providers. Used for the /ListSettingsProviders command line argument. + /// + public IEnumerable>> UnfilteredSettingsProviders { get; private set; } - /// - /// Gets the map of settings name to settings provider. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")] - public Dictionary> SettingsProvidersMap - { - get - { - return this.settingsProvidersMap; - } - } + /// + /// Gets the map of settings name to settings provider. + /// + public Dictionary> SettingsProvidersMap { get; private set; } - #endregion + #endregion - #region Static Methods + #region Static Methods - /// - /// Creates an instance of the settings provider. - /// - /// Instance of the settings provider. - public static SettingsProviderExtensionManager Create() + /// + /// Creates an instance of the settings provider. + /// + /// Instance of the settings provider. + public static SettingsProviderExtensionManager Create() + { + if (s_settingsProviderExtensionManager == null) { - if (settingsProviderExtensionManager == null) + lock (Synclock) { - lock (synclock) + if (s_settingsProviderExtensionManager == null) { - if (settingsProviderExtensionManager == null) - { - - TestPluginManager.Instance - .GetSpecificTestExtensions( - TestPlatformConstants.TestAdapterEndsWithPattern, - out var unfilteredTestExtensions, - out var testExtensions); - - settingsProviderExtensionManager = new SettingsProviderExtensionManager( - testExtensions, unfilteredTestExtensions, TestSessionMessageLogger.Instance); - } + + TestPluginManager.Instance + .GetSpecificTestExtensions( + TestPlatformConstants.TestAdapterEndsWithPattern, + out var unfilteredTestExtensions, + out var testExtensions); + + s_settingsProviderExtensionManager = new SettingsProviderExtensionManager( + testExtensions, unfilteredTestExtensions, TestSessionMessageLogger.Instance); } } + } - return settingsProviderExtensionManager; + return s_settingsProviderExtensionManager; + } + + /// + /// Destroy the extension manager. + /// + public static void Destroy() + { + lock (Synclock) + { + s_settingsProviderExtensionManager = null; } + } - /// - /// Destroy the extension manager. - /// - public static void Destroy() + /// + /// Load all the settings provider and fail on error + /// + /// Indicates whether this method should throw on error. + public static void LoadAndInitializeAllExtensions(bool shouldThrowOnError) + { + var extensionManager = Create(); + + try { - lock (synclock) + foreach (var settingsProvider in extensionManager.SettingsProvidersMap) { - settingsProviderExtensionManager = null; + // Note: - The below Verbose call should not be under IsVerboseEnabled check as we want to + // call executor.Value even if logging is not enabled. + EqtTrace.Verbose("SettingsProviderExtensionManager: Loading settings provider {0}", settingsProvider.Value.Value); } } - - /// - /// Load all the settings provider and fail on error - /// - /// Indicates whether this method should throw on error. - public static void LoadAndInitializeAllExtensions(bool shouldThrowOnError) + catch (Exception ex) { - var extensionManager = Create(); - - try + if (EqtTrace.IsErrorEnabled) { - foreach (var settingsProvider in extensionManager.SettingsProvidersMap) - { - // Note: - The below Verbose call should not be under IsVerboseEnabled check as we want to - // call executor.Value even if logging is not enabled. - EqtTrace.Verbose("SettingsProviderExtensionManager: Loading settings provider {0}", settingsProvider.Value.Value); - } + EqtTrace.Error("SettingsProviderExtensionManager: LoadAndInitialize: Exception occurred while loading extensions {0}", ex); } - catch (Exception ex) - { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("SettingsProviderExtensionManager: LoadAndInitialize: Exception occurred while loading extensions {0}", ex); - } - if (shouldThrowOnError) - { - throw; - } + if (shouldThrowOnError) + { + throw; } } + } - #endregion + #endregion - #region Public Methods + #region Public Methods - /// - /// Gets the settings with the provided name. - /// - /// Name of the settings to get. - /// Settings provider with the provided name or null if one was not found. - internal LazyExtension GetSettingsProvider(string settingsName) + /// + /// Gets the settings with the provided name. + /// + /// Name of the settings to get. + /// Settings provider with the provided name or null if one was not found. + internal LazyExtension GetSettingsProvider(string settingsName) + { + if (string.IsNullOrWhiteSpace(settingsName)) { - if (string.IsNullOrWhiteSpace(settingsName)) - { - throw new ArgumentException(ObjectModelCommonResources.CannotBeNullOrEmpty, nameof(settingsName)); - } + throw new ArgumentException(ObjectModelCommonResources.CannotBeNullOrEmpty, nameof(settingsName)); + } - this.SettingsProvidersMap.TryGetValue(settingsName, out LazyExtension settingsProvider); + SettingsProvidersMap.TryGetValue(settingsName, out LazyExtension settingsProvider); - return settingsProvider; - } + return settingsProvider; + } - #endregion + #endregion - /// - /// Populate the settings provider map - /// - private void PopulateMap() - { - this.settingsProvidersMap = new Dictionary>(); + /// + /// Populate the settings provider map + /// + private void PopulateMap() + { + SettingsProvidersMap = new Dictionary>(); - foreach (var settingsProvider in this.settingsProviders) + foreach (var settingsProvider in _settingsProviders) + { + if (SettingsProvidersMap.ContainsKey(settingsProvider.Metadata.SettingsName)) { - if (this.settingsProvidersMap.ContainsKey(settingsProvider.Metadata.SettingsName)) - { - this.logger.SendMessage( - TestMessageLevel.Error, - string.Format( - CultureInfo.CurrentUICulture, - CommonResources.DuplicateSettingsName, - settingsProvider.Metadata.SettingsName)); - } - else - { - this.settingsProvidersMap.Add(settingsProvider.Metadata.SettingsName, settingsProvider); - } + _logger.SendMessage( + TestMessageLevel.Error, + string.Format( + CultureInfo.CurrentUICulture, + CommonResources.DuplicateSettingsName, + settingsProvider.Metadata.SettingsName)); + } + else + { + SettingsProvidersMap.Add(settingsProvider.Metadata.SettingsName, settingsProvider); } } } +} +/// +/// Hold data about the Test settings provider. +/// +internal class TestSettingsProviderMetadata : ISettingsProviderCapabilities +{ /// - /// Hold data about the Test settings provider. + /// The constructor /// - internal class TestSettingsProviderMetadata : ISettingsProviderCapabilities + /// Test settings name + public TestSettingsProviderMetadata(string settingsName) { - /// - /// The constructor - /// - /// Test settings name - public TestSettingsProviderMetadata(string settingsName) - { - this.SettingsName = settingsName; - } + SettingsName = settingsName; + } - /// - /// Gets test settings name. - /// - public string SettingsName - { - get; - private set; - } + /// + /// Gets test settings name. + /// + public string SettingsName + { + get; + private set; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Telemetry/MetricsCollection.cs b/src/Microsoft.TestPlatform.Common/Telemetry/MetricsCollection.cs index 92185d2ed4..cfc2008496 100644 --- a/src/Microsoft.TestPlatform.Common/Telemetry/MetricsCollection.cs +++ b/src/Microsoft.TestPlatform.Common/Telemetry/MetricsCollection.cs @@ -1,49 +1,48 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Telemetry +namespace Microsoft.VisualStudio.TestPlatform.Common.Telemetry; + +using System.Collections.Generic; + +using ObjectModel.Client; + +/// +/// +/// This Class will collect Metrics. +/// +public class MetricsCollection : IMetricsCollection { - using System.Collections.Generic; + private readonly Dictionary _metricDictionary; + + /// + /// The Metrics Collection + /// + public MetricsCollection() + { + _metricDictionary = new Dictionary(); + } - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + /// + /// Add The Metrics + /// + /// + /// + public void Add(string metric, object value) + { + _metricDictionary[metric] = value; + } + + /// + /// Returns the Metrics + /// + public IDictionary Metrics => _metricDictionary; - /// /// - /// This Class will collect Metrics. + /// Clears the Metrics /// - public class MetricsCollection : IMetricsCollection + public void Clear() { - private Dictionary metricDictionary; - - /// - /// The Metrics Collection - /// - public MetricsCollection() - { - this.metricDictionary = new Dictionary(); - } - - /// - /// Add The Metrics - /// - /// - /// - public void Add(string metric, object value) - { - this.metricDictionary[metric] = value; - } - - /// - /// Returns the Metrics - /// - public IDictionary Metrics => this.metricDictionary; - - /// - /// Clears the Metrics - /// - public void Clear() - { - this.metricDictionary?.Clear(); - } + _metricDictionary?.Clear(); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Telemetry/NoOpMetricsCollection.cs b/src/Microsoft.TestPlatform.Common/Telemetry/NoOpMetricsCollection.cs index adee1f4a25..5452cfe68a 100644 --- a/src/Microsoft.TestPlatform.Common/Telemetry/NoOpMetricsCollection.cs +++ b/src/Microsoft.TestPlatform.Common/Telemetry/NoOpMetricsCollection.cs @@ -1,30 +1,29 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Telemetry -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.Common.Telemetry; + +using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Client; +/// +/// If Telemetry is opted out, this class will be initialized and will do No operation. +/// +public class NoOpMetricsCollection : IMetricsCollection +{ /// - /// If Telemetry is opted out, this class will be initialized and will do No operation. + /// Will do NO-OP /// - public class NoOpMetricsCollection : IMetricsCollection + /// + /// + public void Add(string message, object value) { - /// - /// Will do NO-OP - /// - /// - /// - public void Add(string message, object value) - { - // No operation - } - - /// - /// Will return empty list - /// - public IDictionary Metrics => new Dictionary(); + // No operation } -} + + /// + /// Will return empty list + /// + public IDictionary Metrics => new Dictionary(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Telemetry/TelemetryDataConstants.cs b/src/Microsoft.TestPlatform.Common/Telemetry/TelemetryDataConstants.cs index e9c3515892..aa796d683a 100644 --- a/src/Microsoft.TestPlatform.Common/Telemetry/TelemetryDataConstants.cs +++ b/src/Microsoft.TestPlatform.Common/Telemetry/TelemetryDataConstants.cs @@ -1,129 +1,128 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Telemetry +namespace Microsoft.VisualStudio.TestPlatform.Common.Telemetry; + +/// +/// The Telemetry data constants. +/// +public static class TelemetryDataConstants { - /// - /// The Telemetry data constants. - /// - public static class TelemetryDataConstants - { - // ******************** Execution *********************** - public static string ParallelEnabledDuringExecution = "VS.TestRun.ParallelEnabled"; + // ******************** Execution *********************** + public static string ParallelEnabledDuringExecution = "VS.TestRun.ParallelEnabled"; - // Total number of tests ran under one test request - public static string TotalTestsRun = "VS.TestRun.TotalTests"; + // Total number of tests ran under one test request + public static string TotalTestsRun = "VS.TestRun.TotalTests"; - // Total time taken to complete one test run request - public static string TimeTakenInSecForRun = "VS.TestRun.TimeTakenInSec"; + // Total time taken to complete one test run request + public static string TimeTakenInSecForRun = "VS.TestRun.TimeTakenInSec"; - public static string TestSettingsUsed = "VS.TestRun.IsTestSettingsUsed"; + public static string TestSettingsUsed = "VS.TestRun.IsTestSettingsUsed"; - public static string DisableAppDomain = "VS.TestRun.DisableAppDomain"; + public static string DisableAppDomain = "VS.TestRun.DisableAppDomain"; - // All data related to legacy settings nodes will be prefixed with this. - public static string LegacySettingPrefix = "VS.TestRun.LegacySettings"; + // All data related to legacy settings nodes will be prefixed with this. + public static string LegacySettingPrefix = "VS.TestRun.LegacySettings"; - public static string DataCollectorsEnabled = "VS.TestRun.DataCollectorsEnabled"; + public static string DataCollectorsEnabled = "VS.TestRun.DataCollectorsEnabled"; - internal const string InvokedDataCollectors = "VS.TestRun.InvokedDataCollectors"; + internal const string InvokedDataCollectors = "VS.TestRun.InvokedDataCollectors"; - internal const string DataCollectorsCorProfiler = "VS.TestPlatform.DataCollector.CorProfiler"; + internal const string DataCollectorsCorProfiler = "VS.TestPlatform.DataCollector.CorProfiler"; - internal const string DataCollectorsCoreClrProfiler = "VS.TestPlatform.DataCollector.CoreClrProfiler"; + internal const string DataCollectorsCoreClrProfiler = "VS.TestPlatform.DataCollector.CoreClrProfiler"; - public static string RunState = "VS.TestRun.RunState"; + public static string RunState = "VS.TestRun.RunState"; - public static string NumberOfSourcesSentForRun = "VS.TestRun.NumberOfSources"; + public static string NumberOfSourcesSentForRun = "VS.TestRun.NumberOfSources"; - public static string TargetDevice = "VS.TestRun.TargetDevice"; + public static string TargetDevice = "VS.TestRun.TargetDevice"; - public static string TargetFramework = "VS.TestRun.TargetFramework"; + public static string TargetFramework = "VS.TestRun.TargetFramework"; - public static string TargetPlatform = "VS.TestRun.TargetPlatform"; + public static string TargetPlatform = "VS.TestRun.TargetPlatform"; - public static string MaxCPUcount = "VS.TestRun.MaxCPUcount"; + public static string MaxCPUcount = "VS.TestRun.MaxCPUcount"; - public static string TestPlatformVersion = "VS.TestRun.TestPlatformVersion"; + public static string TestPlatformVersion = "VS.TestRun.TestPlatformVersion"; - public static string TargetOS = "VS.TestRun.TargetOS"; + public static string TargetOS = "VS.TestRun.TargetOS"; - public static string LoggerUsed = "VS.TestRun.LoggersUsed"; + public static string LoggerUsed = "VS.TestRun.LoggersUsed"; - public static string CommandLineSwitches = "VS.TestRun.CommandLineSwitches"; + public static string CommandLineSwitches = "VS.TestRun.CommandLineSwitches"; - // Adapter name will get appended. eg:- VS.TestRun.TotalTestsRun.executor//cppunittestexecutor/v1 - // In case of parallel it will be sum of all tests ran by an adapter in different execution process - public static string TotalTestsRanByAdapter = "VS.TestRun.TotalTestsRun"; + // Adapter name will get appended. eg:- VS.TestRun.TotalTestsRun.executor//cppunittestexecutor/v1 + // In case of parallel it will be sum of all tests ran by an adapter in different execution process + public static string TotalTestsRanByAdapter = "VS.TestRun.TotalTestsRun"; - // Adapter name will get appended. eg:- VS.TestRun.TimeTakenToRun.executor//cppunittestexecutor/v1 - // In case of parallel it will be sum of all time taken by an adapter to run tests in different execution process - public static string TimeTakenToRunTestsByAnAdapter = "VS.TestRun.TimeTakenToRun"; + // Adapter name will get appended. eg:- VS.TestRun.TimeTakenToRun.executor//cppunittestexecutor/v1 + // In case of parallel it will be sum of all time taken by an adapter to run tests in different execution process + public static string TimeTakenToRunTestsByAnAdapter = "VS.TestRun.TimeTakenToRun"; - // Reports details for MSTestV1. Reports just the count when TPv1 is used. - // Reports legacy when the legacy runner TMI / TPv0 is used. - // Adds an extension when an extension (tips) is used. - // eg:- VS.TestRun.TotalTestsRunByMSTestv1 - a unit test using TPv1 and MSTestV1 - // eg:- VS.TestRun.TotalTestsRunByMSTestv1.legacy - a unit test using TPv0 and MSTestV1 - // eg:- VS.TestRun.TotalTestsRunByMSTestv1.legacy.extension.codedui - a coded ui test using TPv0 and MSTestV1 - // Counts in this metric are not subtracted from the TotalTestsRanByAdapter. This metrics just - // provides more insight into what was actually executed. - public static string TotalTestsRunByMSTestv1 = "VS.TestRun.TotalTestsRunByMSTestv1"; + // Reports details for MSTestV1. Reports just the count when TPv1 is used. + // Reports legacy when the legacy runner TMI / TPv0 is used. + // Adds an extension when an extension (tips) is used. + // eg:- VS.TestRun.TotalTestsRunByMSTestv1 - a unit test using TPv1 and MSTestV1 + // eg:- VS.TestRun.TotalTestsRunByMSTestv1.legacy - a unit test using TPv0 and MSTestV1 + // eg:- VS.TestRun.TotalTestsRunByMSTestv1.legacy.extension.codedui - a coded ui test using TPv0 and MSTestV1 + // Counts in this metric are not subtracted from the TotalTestsRanByAdapter. This metrics just + // provides more insight into what was actually executed. + public static string TotalTestsRunByMSTestv1 = "VS.TestRun.TotalTestsRunByMSTestv1"; - // Total number of adapter discovered on the machine. - public static string NumberOfAdapterDiscoveredDuringExecution = "VS.TestRun.AdaptersDiscoveredCount"; + // Total number of adapter discovered on the machine. + public static string NumberOfAdapterDiscoveredDuringExecution = "VS.TestRun.AdaptersDiscoveredCount"; - public static string NumberOfAdapterUsedToRunTests = "VS.TestRun.AdaptersUsedCount"; + public static string NumberOfAdapterUsedToRunTests = "VS.TestRun.AdaptersUsedCount"; - // It will be the sum of the times taken by all adapter to run tests. - // In case of parallel it can be more than total time taken to complete run request. - public static string TimeTakenByAllAdaptersInSec = "VS.TestRun.TimeTakenByAllAdapters"; + // It will be the sum of the times taken by all adapter to run tests. + // In case of parallel it can be more than total time taken to complete run request. + public static string TimeTakenByAllAdaptersInSec = "VS.TestRun.TimeTakenByAllAdapters"; - // *********************Discovery**************************** - public static string TotalTestsDiscovered = "VS.TestDiscovery.TotalTests"; + // *********************Discovery**************************** + public static string TotalTestsDiscovered = "VS.TestDiscovery.TotalTests"; - public static string ParallelEnabledDuringDiscovery = "VS.TestDiscovery.ParallelEnabled"; + public static string ParallelEnabledDuringDiscovery = "VS.TestDiscovery.ParallelEnabled"; - public static string ParallelEnabledDuringStartTestSession = "VS.StartTestSession.ParallelEnabled"; + public static string ParallelEnabledDuringStartTestSession = "VS.StartTestSession.ParallelEnabled"; - // All the times are in sec - public static string TimeTakenInSecForDiscovery = "VS.TestDiscovery.TotalTimeTakenInSec"; + // All the times are in sec + public static string TimeTakenInSecForDiscovery = "VS.TestDiscovery.TotalTimeTakenInSec"; - public static string TimeTakenToLoadAdaptersInSec = "VS.TestDiscovery.TimeTakenToLoadAdaptersInSec"; + public static string TimeTakenToLoadAdaptersInSec = "VS.TestDiscovery.TimeTakenToLoadAdaptersInSec"; - // It will be the sum of the times taken by all adapter to discover tests. - public static string TimeTakenInSecByAllAdapters = "VS.TestDiscovery.TimeTakenInSecByAllAdapters"; + // It will be the sum of the times taken by all adapter to discover tests. + public static string TimeTakenInSecByAllAdapters = "VS.TestDiscovery.TimeTakenInSecByAllAdapters"; - // Adapter name will get appended. eg:- VS.TestDiscovery.TimeTakenAdapter.executor//cppunittestexecutor/v1 - public static string TimeTakenToDiscoverTestsByAnAdapter = "VS.TestDiscovery.TimeTakenAdapter"; + // Adapter name will get appended. eg:- VS.TestDiscovery.TimeTakenAdapter.executor//cppunittestexecutor/v1 + public static string TimeTakenToDiscoverTestsByAnAdapter = "VS.TestDiscovery.TimeTakenAdapter"; - // Adapter name will get appended. eg:- VS.TestDiscovery.TotalTestsDiscovered.executor//cppunittestexecutor/v1 - public static string TotalTestsByAdapter = "VS.TestDiscovery.TotalTestsDiscovered"; + // Adapter name will get appended. eg:- VS.TestDiscovery.TotalTestsDiscovered.executor//cppunittestexecutor/v1 + public static string TotalTestsByAdapter = "VS.TestDiscovery.TotalTestsDiscovered"; - public static string DiscoveryState = "VS.TestDiscovery.DiscoveryState"; + public static string DiscoveryState = "VS.TestDiscovery.DiscoveryState"; - public static string NumberOfSourcesSentForDiscovery = "VS.TestDiscovery.NumberOfSources"; + public static string NumberOfSourcesSentForDiscovery = "VS.TestDiscovery.NumberOfSources"; - public static string NumberOfAdapterDiscoveredDuringDiscovery = "VS.TestDiscovery.AdaptersDiscoveredCount"; + public static string NumberOfAdapterDiscoveredDuringDiscovery = "VS.TestDiscovery.AdaptersDiscoveredCount"; - public static string NumberOfAdapterUsedToDiscoverTests = "VS.TestDiscovery.AdaptersUsedCount"; + public static string NumberOfAdapterUsedToDiscoverTests = "VS.TestDiscovery.AdaptersUsedCount"; - // *********************Attachments Processing**************************** - public static string NumberOfAttachmentsSentForProcessing = "VS.AttachmentsProcessing.InitialAttachmentsCount"; + // *********************Attachments Processing**************************** + public static string NumberOfAttachmentsSentForProcessing = "VS.AttachmentsProcessing.InitialAttachmentsCount"; - public static string NumberOfAttachmentsAfterProcessing = "VS.AttachmentsProcessing.FinalAttachmentsCount"; + public static string NumberOfAttachmentsAfterProcessing = "VS.AttachmentsProcessing.FinalAttachmentsCount"; - public static string TimeTakenInSecForAttachmentsProcessing = "VS.AttachmentsProcessing.TotalTimeTakenInSec"; + public static string TimeTakenInSecForAttachmentsProcessing = "VS.AttachmentsProcessing.TotalTimeTakenInSec"; - public static string AttachmentsProcessingState = "VS.AttachmentsProcessing.State"; + public static string AttachmentsProcessingState = "VS.AttachmentsProcessing.State"; - // **************Events Name ********************************** - public static string TestDiscoveryCompleteEvent = "vs/testplatform/testdiscoverysession"; + // **************Events Name ********************************** + public static string TestDiscoveryCompleteEvent = "vs/testplatform/testdiscoverysession"; - public static string TestExecutionCompleteEvent = "vs/testplatform/testrunsession"; + public static string TestExecutionCompleteEvent = "vs/testplatform/testrunsession"; - public static string TestAttachmentsProcessingCompleteEvent = "vs/testplatform/testattachmentsprocessingsession"; + public static string TestAttachmentsProcessingCompleteEvent = "vs/testplatform/testattachmentsprocessingsession"; - public static string StartTestSessionCompleteEvent = "vs/testplatform/starttestsession"; - } -} + public static string StartTestSessionCompleteEvent = "vs/testplatform/starttestsession"; +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Utilities/AssemblyProperties.cs b/src/Microsoft.TestPlatform.Common/Utilities/AssemblyProperties.cs index 504776695b..6b4a713260 100644 --- a/src/Microsoft.TestPlatform.Common/Utilities/AssemblyProperties.cs +++ b/src/Microsoft.TestPlatform.Common/Utilities/AssemblyProperties.cs @@ -1,73 +1,70 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities +namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities; + +using System; +using System.IO; +using System.Reflection.PortableExecutable; + +using Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +public class AssemblyProperties : IAssemblyProperties { - using System; - using System.IO; - using System.Reflection.PortableExecutable; + private readonly IFileHelper _fileHelper; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + /// + /// Initializes a new instance of the class. + /// + public AssemblyProperties() : this(new FileHelper()) + { + } - public class AssemblyProperties : IAssemblyProperties + /// + /// Initializes a new instance of the class. + /// + /// File helper. + public AssemblyProperties(IFileHelper fileHelper) { - private readonly IFileHelper fileHelper; + _fileHelper = fileHelper; + } + + /// + /// Determines assembly type from file. + /// + public AssemblyType GetAssemblyType(string filePath) + { + var assemblyType = AssemblyType.None; - /// - /// Initializes a new instance of the class. - /// - public AssemblyProperties() : this(new FileHelper()) + try { - } + using var fileStream = _fileHelper.GetStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + using var peReader = new PEReader(fileStream); + // Resources for PEReader: + // 1. https://msdn.microsoft.com/library/windows/desktop/ms680547(v=vs.85).aspx?id=19509 + // 2. https://github.com/dotnet/corefx/tree/master/src/System.Reflection.Metadata - /// - /// Initializes a new instance of the class. - /// - /// File helper. - public AssemblyProperties(IFileHelper fileHelper) + var peHeaders = peReader.PEHeaders; + var corHeader = peHeaders.CorHeader; + var corHeaderStartOffset = peHeaders.CorHeaderStartOffset; + + assemblyType = (corHeader != null && corHeaderStartOffset >= 0) ? + AssemblyType.Managed : + AssemblyType.Native; + } + catch (Exception ex) { - this.fileHelper = fileHelper; + EqtTrace.Warning("PEReaderHelper.GetAssemblyType: failed to determine assembly type: {0} for assembly: {1}", ex, filePath); } - /// - /// Determines assembly type from file. - /// - public AssemblyType GetAssemblyType(string filePath) + if (EqtTrace.IsInfoEnabled) { - var assemblyType = AssemblyType.None; - - try - { - using (var fileStream = this.fileHelper.GetStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - using (var peReader = new PEReader(fileStream)) - { - // Resources for PEReader: - // 1. https://msdn.microsoft.com/library/windows/desktop/ms680547(v=vs.85).aspx?id=19509 - // 2. https://github.com/dotnet/corefx/tree/master/src/System.Reflection.Metadata - - var peHeaders = peReader.PEHeaders; - var corHeader = peHeaders.CorHeader; - var corHeaderStartOffset = peHeaders.CorHeaderStartOffset; - - assemblyType = (corHeader != null && corHeaderStartOffset >= 0) ? - AssemblyType.Managed : - AssemblyType.Native; - } - } - catch (Exception ex) - { - EqtTrace.Warning("PEReaderHelper.GetAssemblyType: failed to determine assembly type: {0} for assembly: {1}", ex, filePath); - } - - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("PEReaderHelper.GetAssemblyType: Determined assemblyType:'{0}' for source: '{1}'", assemblyType, filePath); - } - - return assemblyType; + EqtTrace.Info("PEReaderHelper.GetAssemblyType: Determined assemblyType:'{0}' for source: '{1}'", assemblyType, filePath); } + + return assemblyType; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Utilities/AssemblyResolver.cs b/src/Microsoft.TestPlatform.Common/Utilities/AssemblyResolver.cs index 1f39c51c22..1e044feaff 100644 --- a/src/Microsoft.TestPlatform.Common/Utilities/AssemblyResolver.cs +++ b/src/Microsoft.TestPlatform.Common/Utilities/AssemblyResolver.cs @@ -1,276 +1,261 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities +namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; + +using ObjectModel; +using PlatformAbstractions; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; + +internal class AssemblyResolver : IDisposable { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.IO; - using System.Linq; - using System.Reflection; - - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - - internal class AssemblyResolver : IDisposable + /// + /// The directories to look for assemblies to resolve. + /// + private readonly HashSet _searchDirectories; + + /// + /// Dictionary of Assemblies discovered to date. Must be locked as it may + /// be accessed in a multi-threaded context. + /// + private readonly Dictionary _resolvedAssemblies; + + /// + /// Specifies whether the resolver is disposed or not + /// + private bool _isDisposed; + + /// + /// Assembly resolver for platform + /// + private readonly IAssemblyResolver _platformAssemblyResolver; + + private readonly IAssemblyLoadContext _platformAssemblyLoadContext; + + private static readonly string[] SupportedFileExtensions = { ".dll", ".exe" }; + + /// + /// Initializes a new instance of the class. + /// + /// The search directories. + [System.Security.SecurityCritical] + public AssemblyResolver(IEnumerable directories) { - /// - /// The directories to look for assemblies to resolve. - /// - private HashSet searchDirectories; - - /// - /// Dictionary of Assemblies discovered to date. Must be locked as it may - /// be accessed in a multi-threaded context. - /// - private Dictionary resolvedAssemblies; - - /// - /// Specifies whether the resolver is disposed or not - /// - private bool isDisposed; - - /// - /// Assembly resolver for platform - /// - private IAssemblyResolver platformAssemblyResolver; - - private IAssemblyLoadContext platformAssemblyLoadContext; - - private static readonly string[] SupportedFileExtensions = { ".dll", ".exe" }; - - /// - /// Initializes a new instance of the class. - /// - /// The search directories. - [System.Security.SecurityCritical] - public AssemblyResolver(IEnumerable directories) + if (EqtTrace.IsInfoEnabled) { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info($"AssemblyResolver.ctor: Creating AssemblyResolver with searchDirectories {string.Join(",", directories)}"); - } + EqtTrace.Info($"AssemblyResolver.ctor: Creating AssemblyResolver with searchDirectories {string.Join(",", directories)}"); + } - this.resolvedAssemblies = new Dictionary(); + _resolvedAssemblies = new Dictionary(); - if (directories == null || !directories.Any()) - { - this.searchDirectories = new HashSet(); - } - else - { - this.searchDirectories = new HashSet(directories); - } + _searchDirectories = directories == null || !directories.Any() ? new HashSet() : new HashSet(directories); + + _platformAssemblyResolver = new PlatformAssemblyResolver(); + _platformAssemblyLoadContext = new PlatformAssemblyLoadContext(); - this.platformAssemblyResolver = new PlatformAssemblyResolver(); - this.platformAssemblyLoadContext = new PlatformAssemblyLoadContext(); + _platformAssemblyResolver.AssemblyResolve += OnResolve; + } - this.platformAssemblyResolver.AssemblyResolve += this.OnResolve; + /// + /// Set the directories from which assemblies should be searched + /// + /// The search directories. + [System.Security.SecurityCritical] + internal void AddSearchDirectories(IEnumerable directories) + { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info($"AssemblyResolver.AddSearchDirectories: Adding more searchDirectories {string.Join(",", directories)}"); } - /// - /// Set the directories from which assemblies should be searched - /// - /// The search directories. - [System.Security.SecurityCritical] - internal void AddSearchDirectories(IEnumerable directories) + foreach (var directory in directories) { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info($"AssemblyResolver.AddSearchDirectories: Adding more searchDirectories {string.Join(",", directories)}"); - } + _searchDirectories.Add(directory); + } + } - foreach (var directory in directories) - { - this.searchDirectories.Add(directory); - } + /// + /// Assembly Resolve event handler for App Domain - called when CLR loader cannot resolve assembly. + /// + /// + /// The . + /// + private Assembly OnResolve(object sender, AssemblyResolveEventArgs args) + { + if (string.IsNullOrEmpty(args?.Name)) + { + Debug.Fail("AssemblyResolver.OnResolve: args.Name is null or empty."); + return null; } - /// - /// Assembly Resolve event handler for App Domain - called when CLR loader cannot resolve assembly. - /// - /// - /// The . - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods", MessageId = "System.Reflection.Assembly.LoadFrom")] - private Assembly OnResolve(object sender, AssemblyResolveEventArgs args) + if (_searchDirectories == null || _searchDirectories.Count == 0) { - if (string.IsNullOrEmpty(args?.Name)) + EqtTrace.Info("AssemblyResolver.OnResolve: {0}: There are no search directories, returning.", args.Name); + return null; + } + + EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Resolving assembly.", args.Name); + + // args.Name is like: "Microsoft.VisualStudio.TestTools.Common, Version=[VersionMajor].0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". + lock (_resolvedAssemblies) + { + if (_resolvedAssemblies.TryGetValue(args.Name, out var assembly)) { - Debug.Fail("AssemblyResolver.OnResolve: args.Name is null or empty."); - return null; + EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Resolved from cache.", args.Name); + return assembly; } - if (this.searchDirectories == null || this.searchDirectories.Count == 0) + AssemblyName requestedName = null; + try { - EqtTrace.Info("AssemblyResolver.OnResolve: {0}: There are no search directories, returning.", args.Name); - return null; + // Can throw ArgumentException, FileLoadException if arg is empty/wrong format, etc. Should not return null. + requestedName = new AssemblyName(args.Name); } - - EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Resolving assembly.", args.Name); - - // args.Name is like: "Microsoft.VisualStudio.TestTools.Common, Version=[VersionMajor].0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". - lock (this.resolvedAssemblies) + catch (Exception ex) { - if (this.resolvedAssemblies.TryGetValue(args.Name, out var assembly)) - { - EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Resolved from cache.", args.Name); - return assembly; - } - - AssemblyName requestedName = null; - try + if (EqtTrace.IsInfoEnabled) { - // Can throw ArgumentException, FileLoadException if arg is empty/wrong format, etc. Should not return null. - requestedName = new AssemblyName(args.Name); + EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Failed to create assemblyName. Reason:{1} ", args.Name, ex); } - catch (Exception ex) - { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Failed to create assemblyName. Reason:{1} ", args.Name, ex); - } - this.resolvedAssemblies[args.Name] = null; - return null; - } + _resolvedAssemblies[args.Name] = null; + return null; + } - Debug.Assert(requestedName != null && !string.IsNullOrEmpty(requestedName.Name), "AssemblyResolver.OnResolve: requested is null or name is empty!"); + Debug.Assert(requestedName != null && !string.IsNullOrEmpty(requestedName.Name), "AssemblyResolver.OnResolve: requested is null or name is empty!"); - foreach (var dir in this.searchDirectories) + foreach (var dir in _searchDirectories) + { + if (string.IsNullOrEmpty(dir)) { - if (string.IsNullOrEmpty(dir)) - { - continue; - } + continue; + } - EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Searching in: '{1}'.", args.Name, dir); + EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Searching in: '{1}'.", args.Name, dir); - foreach (var extension in SupportedFileExtensions) + foreach (var extension in SupportedFileExtensions) + { + var assemblyPath = Path.Combine(dir, requestedName.Name + extension); + try { - var assemblyPath = Path.Combine(dir, requestedName.Name + extension); - try + if (!File.Exists(assemblyPath)) { - if (!File.Exists(assemblyPath)) - { - EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Assembly path does not exist: '{1}', returning.", args.Name, assemblyPath); + EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Assembly path does not exist: '{1}', returning.", args.Name, assemblyPath); - continue; - } + continue; + } - AssemblyName foundName = this.platformAssemblyLoadContext.GetAssemblyNameFromPath(assemblyPath); + AssemblyName foundName = _platformAssemblyLoadContext.GetAssemblyNameFromPath(assemblyPath); - if (!this.RequestedAssemblyNameMatchesFound(requestedName, foundName)) - { - EqtTrace.Info("AssemblyResolver.OnResolve: {0}: File exists but version/public key is wrong. Try next extension.", args.Name); - continue; // File exists but version/public key is wrong. Try next extension. - } + if (!RequestedAssemblyNameMatchesFound(requestedName, foundName)) + { + EqtTrace.Info("AssemblyResolver.OnResolve: {0}: File exists but version/public key is wrong. Try next extension.", args.Name); + continue; // File exists but version/public key is wrong. Try next extension. + } - EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Loading assembly '{1}'.", args.Name, assemblyPath); - - assembly = this.platformAssemblyLoadContext.LoadAssemblyFromPath(assemblyPath); - this.resolvedAssemblies[args.Name] = assembly; + EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Loading assembly '{1}'.", args.Name, assemblyPath); - EqtTrace.Info("AssemblyResolver.OnResolve: Resolved assembly: {0}, from path: {1}", args.Name, assemblyPath); + assembly = _platformAssemblyLoadContext.LoadAssemblyFromPath(assemblyPath); + _resolvedAssemblies[args.Name] = assembly; - return assembly; - } - catch (FileLoadException ex) - { - EqtTrace.Error("AssemblyResolver.OnResolve: {0}: Failed to load assembly. Reason:{1} ", args.Name, ex); + EqtTrace.Info("AssemblyResolver.OnResolve: Resolved assembly: {0}, from path: {1}", args.Name, assemblyPath); - // Re-throw FileLoadException, because this exception means that the assembly - // was found, but could not be loaded. This will allow us to report a more - // specific error message to the user for things like access denied. - throw; - } - catch (Exception ex) - { - // For all other exceptions, try the next extension. - EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Failed to load assembly. Reason:{1} ", args.Name, ex); - } + return assembly; } - } + catch (FileLoadException ex) + { + EqtTrace.Error("AssemblyResolver.OnResolve: {0}: Failed to load assembly. Reason:{1} ", args.Name, ex); - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Failed to load assembly.", args.Name); + // Re-throw FileLoadException, because this exception means that the assembly + // was found, but could not be loaded. This will allow us to report a more + // specific error message to the user for things like access denied. + throw; + } + catch (Exception ex) + { + // For all other exceptions, try the next extension. + EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Failed to load assembly. Reason:{1} ", args.Name, ex); + } } + } - this.resolvedAssemblies[args.Name] = null; - return null; + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Failed to load assembly.", args.Name); } + + _resolvedAssemblies[args.Name] = null; + return null; } + } + + /// + /// Verifies that found assembly name matches requested to avoid security issues. + /// Looks only at PublicKeyToken and Version, empty matches anything. + /// VSWhidbey 415774. + /// + /// + /// The . + /// + private bool RequestedAssemblyNameMatchesFound(AssemblyName requestedName, AssemblyName foundName) + { + Debug.Assert(requestedName != null); + Debug.Assert(foundName != null); - /// - /// Verifies that found assembly name matches requested to avoid security issues. - /// Looks only at PublicKeyToken and Version, empty matches anything. - /// VSWhidbey 415774. - /// - /// - /// The . - /// - private bool RequestedAssemblyNameMatchesFound(AssemblyName requestedName, AssemblyName foundName) + var requestedPublicKey = requestedName.GetPublicKeyToken(); + if (requestedPublicKey != null) { - Debug.Assert(requestedName != null); - Debug.Assert(foundName != null); + var foundPublicKey = foundName.GetPublicKeyToken(); + if (foundPublicKey == null) + { + return false; + } - var requestedPublicKey = requestedName.GetPublicKeyToken(); - if (requestedPublicKey != null) + for (var index = 0; index < requestedPublicKey.Length; ++index) { - var foundPublicKey = foundName.GetPublicKeyToken(); - if (foundPublicKey == null) + if (requestedPublicKey[index] != foundPublicKey[index]) { return false; } - - for (var index = 0; index < requestedPublicKey.Length; ++index) - { - if (requestedPublicKey[index] != foundPublicKey[index]) - { - return false; - } - } - } - - if (requestedName.Version != null) - { - return requestedName.Version.Equals(foundName.Version); } - - return true; } - ~AssemblyResolver() - { - this.Dispose(false); - } + return requestedName.Version == null || requestedName.Version.Equals(foundName.Version); + } - public void Dispose() - { - this.Dispose(true); + ~AssemblyResolver() + { + Dispose(false); + } - // Use SupressFinalize in case a subclass - // of this type implements a finalizer. - GC.SuppressFinalize(this); - } + public void Dispose() + { + Dispose(true); + + // Use SupressFinalize in case a subclass + // of this type implements a finalizer. + GC.SuppressFinalize(this); + } - [System.Security.SecurityCritical] - protected virtual void Dispose(bool disposing) + [System.Security.SecurityCritical] + protected virtual void Dispose(bool disposing) + { + if (!_isDisposed) { - if (!this.isDisposed) + if (disposing) { - if (disposing) - { - this.platformAssemblyResolver.AssemblyResolve -= this.OnResolve; - this.platformAssemblyResolver.Dispose(); - } - - this.isDisposed = true; + _platformAssemblyResolver.AssemblyResolve -= OnResolve; + _platformAssemblyResolver.Dispose(); } + + _isDisposed = true; } } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Utilities/AssemblyType.cs b/src/Microsoft.TestPlatform.Common/Utilities/AssemblyType.cs index 045c6177bb..2800c37363 100644 --- a/src/Microsoft.TestPlatform.Common/Utilities/AssemblyType.cs +++ b/src/Microsoft.TestPlatform.Common/Utilities/AssemblyType.cs @@ -1,12 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities +namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities; + +public enum AssemblyType { - public enum AssemblyType - { - None, - Native, - Managed - } -} + None, + Native, + Managed +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Utilities/CancellationTokenExtensions.cs b/src/Microsoft.TestPlatform.Common/Utilities/CancellationTokenExtensions.cs index a09eefbdf0..5753ee520b 100644 --- a/src/Microsoft.TestPlatform.Common/Utilities/CancellationTokenExtensions.cs +++ b/src/Microsoft.TestPlatform.Common/Utilities/CancellationTokenExtensions.cs @@ -1,23 +1,23 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities -{ - using System.Threading; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities; + +using System.Threading; - public static class CancellationTokenExtensions +using ObjectModel; + +public static class CancellationTokenExtensions +{ + /// + /// Extension method used to throw TestPlatformException in case operation is canceled. + /// + /// CancellationToken on which cancel is requested + public static void ThrowTestPlatformExceptionIfCancellationRequested(this CancellationToken token) { - /// - /// Extension method used to throw TestPlatformException in case operation is canceled. - /// - /// CancellationToken on which cancel is requested - public static void ThrowTestPlatformExceptionIfCancellationRequested(this CancellationToken token) + if (token.IsCancellationRequested) { - if (token.IsCancellationRequested) - { - throw new TestPlatformException(Resources.Resources.CancellationRequested); - } + throw new TestPlatformException(Resources.Resources.CancellationRequested); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Utilities/ExceptionUtilities.cs b/src/Microsoft.TestPlatform.Common/Utilities/ExceptionUtilities.cs index 2fda16a13d..099ce01329 100644 --- a/src/Microsoft.TestPlatform.Common/Utilities/ExceptionUtilities.cs +++ b/src/Microsoft.TestPlatform.Common/Utilities/ExceptionUtilities.cs @@ -1,53 +1,52 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities -{ - using System; - using System.Text; +namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities; + +using System; +using System.Text; +/// +/// Exception utilities. +/// +public class ExceptionUtilities +{ /// - /// Exception utilities. + /// Returns an exception message with all inner exceptions messages. /// - public class ExceptionUtilities + /// The exception. + /// The formatted string message of the exception. + public static string GetExceptionMessage(Exception exception) { - /// - /// Returns an exception message with all inner exceptions messages. - /// - /// The exception. - /// The formatted string message of the exception. - public static string GetExceptionMessage(Exception exception) + if (exception == null) { - if (exception == null) - { - return string.Empty; - } - - var exceptionString = new StringBuilder(exception.Message); - AppendStackTrace(exceptionString, exception); + return string.Empty; + } - var inner = exception.InnerException; - while (inner != null) - { - exceptionString - .AppendLine() - .Append(Resources.Resources.InnerException).Append(" ").AppendLine(inner.Message); - AppendStackTrace(exceptionString, inner); - inner = inner.InnerException; - } + var exceptionString = new StringBuilder(exception.Message); + AppendStackTrace(exceptionString, exception); - return exceptionString.ToString(); + var inner = exception.InnerException; + while (inner != null) + { + exceptionString + .AppendLine() + .Append(Resources.Resources.InnerException).Append(" ").AppendLine(inner.Message); + AppendStackTrace(exceptionString, inner); + inner = inner.InnerException; } - private static void AppendStackTrace(StringBuilder stringBuilder, Exception exception) + return exceptionString.ToString(); + } + + private static void AppendStackTrace(StringBuilder stringBuilder, Exception exception) + { + if (!string.IsNullOrEmpty(exception.StackTrace)) { - if (!string.IsNullOrEmpty(exception.StackTrace)) - { - stringBuilder - .AppendLine() - .AppendLine(Resources.Resources.StackTrace) - .AppendLine(exception.StackTrace); - } + stringBuilder + .AppendLine() + .AppendLine(Resources.Resources.StackTrace) + .AppendLine(exception.StackTrace); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs b/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs index 5f368905fe..aa8b588289 100644 --- a/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs +++ b/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs @@ -1,337 +1,334 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities +namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Reflection; +using System.Xml; +using System.Xml.XPath; + +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; + +/// +/// Provides helper to configure run settings for Fakes. Works even when Fakes are not installed on the machine. +/// +public static class FakesUtilities { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.IO; - using System.Reflection; - using System.Xml; - using System.Xml.XPath; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; + private const string ConfiguratorAssemblyQualifiedName = "Microsoft.VisualStudio.TestPlatform.Fakes.FakesDataCollectorConfiguration"; - /// - /// Provides helper to configure run settings for Fakes. Works even when Fakes are not installed on the machine. - /// - public static class FakesUtilities - { - private const string ConfiguratorAssemblyQualifiedName = "Microsoft.VisualStudio.TestPlatform.Fakes.FakesDataCollectorConfiguration"; + private const string NetFrameworkConfiguratorMethodName = "GetDataCollectorSettingsOrDefault"; - private const string NetFrameworkConfiguratorMethodName = "GetDataCollectorSettingsOrDefault"; + private const string CrossPlatformConfiguratorMethodName = "GetCrossPlatformDataCollectorSettings"; - private const string CrossPlatformConfiguratorMethodName = "GetCrossPlatformDataCollectorSettings"; + // Must be kept in sync with version being generated by VSUnitTesting + private const string AssemblyVersion = ExternalAssemblyVersions.MicrosoftFakesAssemblyVersion; + private const string FakesConfiguratorAssembly = "Microsoft.VisualStudio.TestPlatform.Fakes, Version=" + AssemblyVersion + ", Culture=neutral"; - // Must be kept in sync with version being generated by VSUnitTesting - private const string AssemblyVersion = ExternalAssemblyVersions.MicrosoftFakesAssemblyVersion; - private const string FakesConfiguratorAssembly = "Microsoft.VisualStudio.TestPlatform.Fakes, Version=" + AssemblyVersion + ", Culture=neutral"; - - /// - /// Dynamically compute the Fakes data collector settings, given a set of test assemblies - /// - /// test sources - /// runsettings - /// updated runsettings for fakes - public static string GenerateFakesSettingsForRunConfiguration(string[] sources, string runSettingsXml) + /// + /// Dynamically compute the Fakes data collector settings, given a set of test assemblies + /// + /// test sources + /// runsettings + /// updated runsettings for fakes + public static string GenerateFakesSettingsForRunConfiguration(string[] sources, string runSettingsXml) + { + if (sources == null) { - if (sources == null) - { - throw new ArgumentNullException(nameof(sources)); - } - - if (runSettingsXml == null) - { - throw new ArgumentNullException(nameof(runSettingsXml)); - } + throw new ArgumentNullException(nameof(sources)); + } - var doc = new XmlDocument(); - using (var xmlReader = XmlReader.Create( - new StringReader(runSettingsXml), - new XmlReaderSettings() { CloseInput = true })) - { - doc.Load(xmlReader); - } + if (runSettingsXml == null) + { + throw new ArgumentNullException(nameof(runSettingsXml)); + } - var frameworkVersion = GetFramework(runSettingsXml); - if (frameworkVersion == null) - { - return runSettingsXml; - } + var doc = new XmlDocument(); + using (var xmlReader = XmlReader.Create( + new StringReader(runSettingsXml), + new XmlReaderSettings() { CloseInput = true })) + { + doc.Load(xmlReader); + } - return TryAddFakesDataCollectorSettings(doc, sources, (FrameworkVersion)frameworkVersion) + var frameworkVersion = GetFramework(runSettingsXml); + return frameworkVersion == null + ? runSettingsXml + : TryAddFakesDataCollectorSettings(doc, sources, (FrameworkVersion)frameworkVersion) ? doc.OuterXml : runSettingsXml; - } + } - /// - /// returns FrameworkVersion contained in the runsettingsXML - /// - /// - /// - private static FrameworkVersion? GetFramework(string runSettingsXml) + /// + /// returns FrameworkVersion contained in the runsettingsXML + /// + /// + /// + private static FrameworkVersion? GetFramework(string runSettingsXml) + { + // We assume that only .NET Core, .NET Standard, or .NET Framework projects can have fakes. + var targetFramework = XmlRunSettingsUtilities.GetRunConfigurationNode(runSettingsXml)?.TargetFramework; + + if (targetFramework == null) { - // We assume that only .NET Core, .NET Standard, or .NET Framework projects can have fakes. - var targetFramework = XmlRunSettingsUtilities.GetRunConfigurationNode(runSettingsXml)?.TargetFramework; + return null; + } - if (targetFramework == null) - { - return null; - } + // Since there are no FrameworkVersion values for .Net Core 2.0 +, we check TargetFramework instead + // and default to FrameworkCore10 for .Net Core + if (targetFramework.Name.IndexOf("netstandard", StringComparison.OrdinalIgnoreCase) >= 0 || + targetFramework.Name.IndexOf("netcoreapp", StringComparison.OrdinalIgnoreCase) >= 0 || + targetFramework.Name.IndexOf("net5", StringComparison.OrdinalIgnoreCase) >= 0) + { + return FrameworkVersion.FrameworkCore10; + } - // Since there are no FrameworkVersion values for .Net Core 2.0 +, we check TargetFramework instead - // and default to FrameworkCore10 for .Net Core - if (targetFramework.Name.IndexOf("netstandard", StringComparison.OrdinalIgnoreCase) >= 0 || - targetFramework.Name.IndexOf("netcoreapp", StringComparison.OrdinalIgnoreCase) >= 0 || - targetFramework.Name.IndexOf("net5", StringComparison.OrdinalIgnoreCase) >= 0) - { - return FrameworkVersion.FrameworkCore10; - } + // Since the Datacollector is separated on the NetFramework/NetCore line, any value of NETFramework + // can be passed along to the fakes data collector configuration creator. + // We default to Framework40 to preserve back compat + return FrameworkVersion.Framework40; + } - // Since the Datacollector is separated on the NetFramework/NetCore line, any value of NETFramework - // can be passed along to the fakes data collector configuration creator. - // We default to Framework40 to preserve back compat - return FrameworkVersion.Framework40; - } + /// + /// Tries to embed the Fakes data collector settings for the given run settings. + /// + /// runsettings + /// test sources + /// true if runSettings was modified; false otherwise. + private static bool TryAddFakesDataCollectorSettings( + XmlDocument runSettings, + IEnumerable sources, + FrameworkVersion framework) + { + // A new Fakes Configurator API makes the decision to add the right datacollector uri to the configuration + // There now exist two data collector URIs to support two different scenarios. The new scenario involves + // using the CLRIE profiler, and the old involves using the Intellitrace profiler (which isn't supported in + // .NET Core scenarios). The old API still exists for fallback measures. - /// - /// Tries to embed the Fakes data collector settings for the given run settings. - /// - /// runsettings - /// test sources - /// true if runSettings was modified; false otherwise. - private static bool TryAddFakesDataCollectorSettings( - XmlDocument runSettings, - IEnumerable sources, - FrameworkVersion framework) + var crossPlatformConfigurator = TryGetFakesCrossPlatformDataCollectorConfigurator(); + if (crossPlatformConfigurator != null) { - // A new Fakes Configurator API makes the decision to add the right datacollector uri to the configuration - // There now exist two data collector URIs to support two different scenarios. The new scenario involves - // using the CLRIE profiler, and the old involves using the Intellitrace profiler (which isn't supported in - // .NET Core scenarios). The old API still exists for fallback measures. + var sourceTfmMap = CreateDictionary(sources, framework); + var fakesSettings = crossPlatformConfigurator(sourceTfmMap); - var crossPlatformConfigurator = TryGetFakesCrossPlatformDataCollectorConfigurator(); - if (crossPlatformConfigurator != null) + // if no fakes, return settings unchanged + if (fakesSettings == null) { - var sourceTFMMap = CreateDictionary(sources, framework); - var fakesSettings = crossPlatformConfigurator(sourceTFMMap); - - // if no fakes, return settings unchanged - if (fakesSettings == null) - { - return false; - } - - InsertOrReplaceFakesDataCollectorNode(runSettings, fakesSettings); - return true; + return false; } - return AddFallbackFakesSettings(runSettings, sources, framework); + InsertOrReplaceFakesDataCollectorNode(runSettings, fakesSettings); + return true; } - internal static void InsertOrReplaceFakesDataCollectorNode(XmlDocument runSettings, DataCollectorSettings settings) - { - // override current settings - var navigator = runSettings.CreateNavigator(); - var nodes = navigator.Select("/RunSettings/DataCollectionRunSettings/DataCollectors/DataCollector"); + return AddFallbackFakesSettings(runSettings, sources, framework); + } + + internal static void InsertOrReplaceFakesDataCollectorNode(XmlDocument runSettings, DataCollectorSettings settings) + { + // override current settings + var navigator = runSettings.CreateNavigator(); + var nodes = navigator.Select("/RunSettings/DataCollectionRunSettings/DataCollectors/DataCollector"); - foreach (XPathNavigator dataCollectorNavigator in nodes) + foreach (XPathNavigator dataCollectorNavigator in nodes) + { + var uri = dataCollectorNavigator.GetAttribute("uri", string.Empty); + // We assume that only one uri can exist in a given runsettings + if (string.Equals(FakesMetadata.DataCollectorUriV1, uri, StringComparison.OrdinalIgnoreCase) || + string.Equals(FakesMetadata.DataCollectorUriV2, uri, StringComparison.OrdinalIgnoreCase)) { - var uri = dataCollectorNavigator.GetAttribute("uri", string.Empty); - // We assume that only one uri can exist in a given runsettings - if (string.Equals(FakesMetadata.DataCollectorUriV1, uri, StringComparison.OrdinalIgnoreCase) || - string.Equals(FakesMetadata.DataCollectorUriV2, uri, StringComparison.OrdinalIgnoreCase)) - { - dataCollectorNavigator.ReplaceSelf(settings.ToXml().CreateNavigator()); - return; - } + dataCollectorNavigator.ReplaceSelf(settings.ToXml().CreateNavigator()); + return; } - - // insert new node - XmlRunSettingsUtilities.InsertDataCollectorsNode(runSettings.CreateNavigator(), settings); } - private static IDictionary CreateDictionary(IEnumerable sources, FrameworkVersion framework) + // insert new node + XmlRunSettingsUtilities.InsertDataCollectorsNode(runSettings.CreateNavigator(), settings); + } + + private static IDictionary CreateDictionary(IEnumerable sources, FrameworkVersion framework) + { + var dict = new Dictionary(); + foreach (var source in sources) { - var dict = new Dictionary(); - foreach(var source in sources) + if (!dict.ContainsKey(source)) { - if (!dict.ContainsKey(source)) - { - dict.Add(source, framework); - } + dict.Add(source, framework); } + } - return dict; + return dict; + } + + private static bool AddFallbackFakesSettings( + XmlDocument runSettings, + IEnumerable sources, + FrameworkVersion framework) + { + + // The fallback settings is for the old implementation of fakes + // that only supports .Net Framework versions + if (framework != FrameworkVersion.Framework35 && + framework != FrameworkVersion.Framework40 && + framework != FrameworkVersion.Framework45) + { + return false; } - private static bool AddFallbackFakesSettings( - XmlDocument runSettings, - IEnumerable sources, - FrameworkVersion framework) + Func, string> netFrameworkConfigurator = TryGetNetFrameworkFakesDataCollectorConfigurator(); + if (netFrameworkConfigurator == null) { + return false; + } - // The fallback settings is for the old implementation of fakes - // that only supports .Net Framework versions - if (framework != FrameworkVersion.Framework35 && - framework != FrameworkVersion.Framework40 && - framework != FrameworkVersion.Framework45) - { - return false; - } + // if no fakes, return settings unchanged + var fakesConfiguration = netFrameworkConfigurator(sources); + if (fakesConfiguration == null) + { + return false; + } - Func, string> netFrameworkConfigurator = TryGetNetFrameworkFakesDataCollectorConfigurator(); - if (netFrameworkConfigurator == null) - { - return false; - } + // integrate fakes settings in configuration + // if the settings don't have any data collector settings, populate with empty settings + EnsureSettingsNode(runSettings, new DataCollectionRunSettings()); - // if no fakes, return settings unchanged - var fakesConfiguration = netFrameworkConfigurator(sources); - if (fakesConfiguration == null) - { - return false; - } + // embed fakes settings + var fakesSettings = CreateFakesDataCollectorSettings(); + var doc = new XmlDocument(); + using (var xmlReader = XmlReader.Create( + new StringReader(fakesConfiguration), + new XmlReaderSettings() { CloseInput = true })) + { + doc.Load(xmlReader); + } - // integrate fakes settings in configuration - // if the settings don't have any data collector settings, populate with empty settings - EnsureSettingsNode(runSettings, new DataCollectionRunSettings()); + fakesSettings.Configuration = doc.DocumentElement; + XmlRunSettingsUtilities.InsertDataCollectorsNode(runSettings.CreateNavigator(), fakesSettings); - // embed fakes settings - var fakesSettings = CreateFakesDataCollectorSettings(); - var doc = new XmlDocument(); - using (var xmlReader = XmlReader.Create( - new StringReader(fakesConfiguration), - new XmlReaderSettings() { CloseInput = true })) - { - doc.Load(xmlReader); - } + return true; + } - fakesSettings.Configuration = doc.DocumentElement; - XmlRunSettingsUtilities.InsertDataCollectorsNode(runSettings.CreateNavigator(), fakesSettings); + /// + /// Ensures that an xml element corresponding to the test run settings exists in the setting document. + /// + /// settings + /// settingsNode + private static void EnsureSettingsNode(XmlDocument settings, TestRunSettings settingsNode) + { + Debug.Assert(settingsNode != null, "Invalid Settings Node"); + Debug.Assert(settings != null, "Invalid Settings"); - return true; + var root = settings.DocumentElement; + if (root[settingsNode.Name] == null) + { + var newElement = settingsNode.ToXml(); + XmlNode newNode = settings.ImportNode(newElement, true); + root.AppendChild(newNode); } + } - /// - /// Ensures that an xml element corresponding to the test run settings exists in the setting document. - /// - /// settings - /// settingsNode - private static void EnsureSettingsNode(XmlDocument settings, TestRunSettings settingsNode) + private static Func, string> TryGetNetFrameworkFakesDataCollectorConfigurator() + { +#if NETFRAMEWORK + try { - Debug.Assert(settingsNode != null, "Invalid Settings Node"); - Debug.Assert(settings != null, "Invalid Settings"); - - var root = settings.DocumentElement; - if (root[settingsNode.Name] == null) + var assembly = LoadTestPlatformAssembly(); + var type = assembly?.GetType(ConfiguratorAssemblyQualifiedName, false); + var method = type?.GetMethod(NetFrameworkConfiguratorMethodName, new Type[] { typeof(IEnumerable) }); + if (method != null) { - var newElement = settingsNode.ToXml(); - XmlNode newNode = settings.ImportNode(newElement, true); - root.AppendChild(newNode); + return (Func, string>)method.CreateDelegate(typeof(Func, string>)); } } - - private static Func, string> TryGetNetFrameworkFakesDataCollectorConfigurator() + catch (Exception ex) { -#if NETFRAMEWORK - try - { - var assembly = LoadTestPlatformAssembly(); - var type = assembly?.GetType(ConfiguratorAssemblyQualifiedName, false); - var method = type?.GetMethod(NetFrameworkConfiguratorMethodName, new Type[] { typeof(IEnumerable) }); - if (method != null) - { - return (Func, string>)method.CreateDelegate(typeof(Func, string>)); - } - } - catch (Exception ex) + if (EqtTrace.IsInfoEnabled) { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("Failed to create Fakes Configurator. Reason:{0} ", ex); - } + EqtTrace.Info("Failed to create Fakes Configurator. Reason:{0} ", ex); } -#endif - return null; } +#endif + return null; + } - private static Func, DataCollectorSettings> TryGetFakesCrossPlatformDataCollectorConfigurator() + private static Func, DataCollectorSettings> TryGetFakesCrossPlatformDataCollectorConfigurator() + { + try { - try - { - var assembly = LoadTestPlatformAssembly(); - var type = assembly?.GetType(ConfiguratorAssemblyQualifiedName, false, false); - var method = type?.GetMethod(CrossPlatformConfiguratorMethodName, new Type[] { typeof(IDictionary) }); - if (method != null) - { - return (Func, DataCollectorSettings>)method.CreateDelegate(typeof(Func, DataCollectorSettings>)); - } - } - catch (Exception ex) + var assembly = LoadTestPlatformAssembly(); + var type = assembly?.GetType(ConfiguratorAssemblyQualifiedName, false, false); + var method = type?.GetMethod(CrossPlatformConfiguratorMethodName, new Type[] { typeof(IDictionary) }); + if (method != null) { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("Failed to create newly implemented Fakes Configurator. Reason:{0} ", ex); - } + return (Func, DataCollectorSettings>)method.CreateDelegate(typeof(Func, DataCollectorSettings>)); } - - return null; } - private static Assembly LoadTestPlatformAssembly() + catch (Exception ex) { - try + if (EqtTrace.IsInfoEnabled) { - return Assembly.Load(new AssemblyName(FakesConfiguratorAssembly)); + EqtTrace.Info("Failed to create newly implemented Fakes Configurator. Reason:{0} ", ex); } - catch (Exception ex) - { - EqtTrace.Info("Failed to load assembly {0}. Reason:{1}", FakesConfiguratorAssembly, ex); - } - return null; } - /// - /// Adds the Fakes data collector settings in the run settings document. - /// - /// - /// The . - /// - private static DataCollectorSettings CreateFakesDataCollectorSettings() + return null; + } + private static Assembly LoadTestPlatformAssembly() + { + try { - // embed the fakes run settings - var settings = new DataCollectorSettings - { - AssemblyQualifiedName = FakesMetadata.DataCollectorAssemblyQualifiedName, - FriendlyName = FakesMetadata.FriendlyName, - IsEnabled = true, - Uri = new Uri(FakesMetadata.DataCollectorUriV1) - }; - return settings; + return Assembly.Load(new AssemblyName(FakesConfiguratorAssembly)); } - - internal static class FakesMetadata + catch (Exception ex) { - /// - /// Friendly name of the data collector - /// - public const string FriendlyName = "UnitTestIsolation"; - - /// - /// Gets the URI of the data collector - /// - public const string DataCollectorUriV1 = "datacollector://microsoft/unittestisolation/1.0"; - - /// - /// Gets the URI of the data collector - /// - public const string DataCollectorUriV2 = "datacollector://microsoft/unittestisolation/2.0"; - - /// - /// Gets the assembly qualified name of the data collector type - /// - public const string DataCollectorAssemblyQualifiedName = "Microsoft.VisualStudio.TraceCollector.UnitTestIsolationDataCollector, Microsoft.VisualStudio.TraceCollector, Version=" + AssemblyVersion + ", Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; + EqtTrace.Info("Failed to load assembly {0}. Reason:{1}", FakesConfiguratorAssembly, ex); } + return null; + } + + /// + /// Adds the Fakes data collector settings in the run settings document. + /// + /// + /// The . + /// + private static DataCollectorSettings CreateFakesDataCollectorSettings() + { + // embed the fakes run settings + var settings = new DataCollectorSettings + { + AssemblyQualifiedName = FakesMetadata.DataCollectorAssemblyQualifiedName, + FriendlyName = FakesMetadata.FriendlyName, + IsEnabled = true, + Uri = new Uri(FakesMetadata.DataCollectorUriV1) + }; + return settings; + } + + internal static class FakesMetadata + { + /// + /// Friendly name of the data collector + /// + public const string FriendlyName = "UnitTestIsolation"; + + /// + /// Gets the URI of the data collector + /// + public const string DataCollectorUriV1 = "datacollector://microsoft/unittestisolation/1.0"; + + /// + /// Gets the URI of the data collector + /// + public const string DataCollectorUriV2 = "datacollector://microsoft/unittestisolation/2.0"; + + /// + /// Gets the assembly qualified name of the data collector type + /// + public const string DataCollectorAssemblyQualifiedName = "Microsoft.VisualStudio.TraceCollector.UnitTestIsolationDataCollector, Microsoft.VisualStudio.TraceCollector, Version=" + AssemblyVersion + ", Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Utilities/InstallationContext.cs b/src/Microsoft.TestPlatform.Common/Utilities/InstallationContext.cs index 37b2cb9eeb..7a3535f645 100644 --- a/src/Microsoft.TestPlatform.Common/Utilities/InstallationContext.cs +++ b/src/Microsoft.TestPlatform.Common/Utilities/InstallationContext.cs @@ -1,58 +1,58 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities -{ - using System.IO; - using System.Reflection; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities; - public class InstallationContext - { - private const string DevenvExe = "devenv.exe"; - private const string PrivateAssembliesDirName = "PrivateAssemblies"; - private const string PublicAssembliesDirName = "PublicAssemblies"; +using System.IO; +using System.Reflection; - private readonly IFileHelper fileHelper; +using PlatformAbstractions; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - public InstallationContext(IFileHelper fileHelper) - { - this.fileHelper = fileHelper; - } +public class InstallationContext +{ + private const string DevenvExe = "devenv.exe"; + private const string PrivateAssembliesDirName = "PrivateAssemblies"; + private const string PublicAssembliesDirName = "PublicAssemblies"; - public bool TryGetVisualStudioDirectory(out string visualStudioDirectory) + private readonly IFileHelper _fileHelper; + + public InstallationContext(IFileHelper fileHelper) + { + _fileHelper = fileHelper; + } + + public bool TryGetVisualStudioDirectory(out string visualStudioDirectory) + { + var vsInstallPath = new DirectoryInfo(typeof(InstallationContext).GetTypeInfo().Assembly.GetAssemblyLocation()).Parent?.Parent?.Parent?.FullName; + if (!string.IsNullOrEmpty(vsInstallPath)) { - var vsInstallPath = new DirectoryInfo(typeof(InstallationContext).GetTypeInfo().Assembly.GetAssemblyLocation()).Parent?.Parent?.Parent?.FullName; - if (!string.IsNullOrEmpty(vsInstallPath)) + var pathToDevenv = Path.Combine(vsInstallPath, DevenvExe); + if (!string.IsNullOrEmpty(pathToDevenv) && _fileHelper.Exists(pathToDevenv)) { - var pathToDevenv = Path.Combine(vsInstallPath, DevenvExe); - if (!string.IsNullOrEmpty(pathToDevenv) && this.fileHelper.Exists(pathToDevenv)) - { - visualStudioDirectory = vsInstallPath; - return true; - } + visualStudioDirectory = vsInstallPath; + return true; } - - visualStudioDirectory = string.Empty; - return false; } - public string GetVisualStudioPath(string visualStudioDirectory) - { - return Path.Combine(visualStudioDirectory, DevenvExe); - } + visualStudioDirectory = string.Empty; + return false; + } + + public string GetVisualStudioPath(string visualStudioDirectory) + { + return Path.Combine(visualStudioDirectory, DevenvExe); + } - public string[] GetVisualStudioCommonLocations(string visualStudioDirectory) + public string[] GetVisualStudioCommonLocations(string visualStudioDirectory) + { + return new[] { - return new[] - { - Path.Combine(visualStudioDirectory, PrivateAssembliesDirName), - Path.Combine(visualStudioDirectory, PublicAssembliesDirName), - Path.Combine(visualStudioDirectory, "CommonExtensions", "Microsoft", "TestWindow"), - Path.Combine(visualStudioDirectory, "CommonExtensions", "Microsoft", "TeamFoundation", "Team Explorer"), - visualStudioDirectory - }; - } + Path.Combine(visualStudioDirectory, PrivateAssembliesDirName), + Path.Combine(visualStudioDirectory, PublicAssembliesDirName), + Path.Combine(visualStudioDirectory, "CommonExtensions", "Microsoft", "TestWindow"), + Path.Combine(visualStudioDirectory, "CommonExtensions", "Microsoft", "TeamFoundation", "Team Explorer"), + visualStudioDirectory + }; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Utilities/MetadataReaderHelper.cs b/src/Microsoft.TestPlatform.Common/Utilities/MetadataReaderHelper.cs index a71e56906b..828149883d 100644 --- a/src/Microsoft.TestPlatform.Common/Utilities/MetadataReaderHelper.cs +++ b/src/Microsoft.TestPlatform.Common/Utilities/MetadataReaderHelper.cs @@ -1,193 +1,192 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities -{ - using System; - using System.Collections.Concurrent; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Reflection; - using System.Reflection.Metadata; - using System.Reflection.PortableExecutable; - using System.Text; +namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities; + +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Reflection.Metadata; +using System.Reflection.PortableExecutable; +using System.Text; + +using ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +/* Expected attribute shape - /* Expected attribute shape + namespace Microsoft.VisualStudio.TestPlatform + { + using System; - namespace Microsoft.VisualStudio.TestPlatform + [AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = true)] + internal sealed class TestExtensionTypesV2Attribute : Attribute { - using System; + public string ExtensionType { get; } + public string ExtensionIdentifier { get; } + public Type ExtensionImplementation { get; } + public int Version { get; } - [AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = true)] - internal sealed class TestExtensionTypesV2Attribute : Attribute + public TestExtensionTypesV2Attribute(string extensionType, string extensionIdentifier, Type extensionImplementation, int version) { - public string ExtensionType { get; } - public string ExtensionIdentifier { get; } - public Type ExtensionImplementation { get; } - public int Version { get; } - - public TestExtensionTypesV2Attribute(string extensionType, string extensionIdentifier, Type extensionImplementation, int version) - { - ExtensionType = extensionType; - ExtensionIdentifier = extensionIdentifier; - ExtensionImplementation = extensionImplementation; - Version = version; - } + ExtensionType = extensionType; + ExtensionIdentifier = extensionIdentifier; + ExtensionImplementation = extensionImplementation; + Version = version; } } - */ - internal class MetadataReaderExtensionsHelper - { - private const string TestExtensionTypesAttributeV2 = "Microsoft.VisualStudio.TestPlatform.TestExtensionTypesV2Attribute"; - private static readonly ConcurrentDictionary assemblyCache = new ConcurrentDictionary(); - private static readonly Type[] emptyTypeArray = new Type[0]; + } +*/ +internal class MetadataReaderExtensionsHelper +{ + private const string TestExtensionTypesAttributeV2 = "Microsoft.VisualStudio.TestPlatform.TestExtensionTypesV2Attribute"; + private static readonly ConcurrentDictionary AssemblyCache = new(); + private static readonly Type[] EmptyTypeArray = new Type[0]; - public Type[] DiscoverTestExtensionTypesV2Attribute(Assembly loadedAssembly, string assemblyFilePath) - => assemblyCache.GetOrAdd(assemblyFilePath, DiscoverTestExtensionTypesV2AttributeInternal(loadedAssembly, assemblyFilePath)); + public Type[] DiscoverTestExtensionTypesV2Attribute(Assembly loadedAssembly, string assemblyFilePath) + => AssemblyCache.GetOrAdd(assemblyFilePath, DiscoverTestExtensionTypesV2AttributeInternal(loadedAssembly, assemblyFilePath)); - private Type[] DiscoverTestExtensionTypesV2AttributeInternal(Assembly loadedAssembly, string assemblyFilePath) - { - EqtTrace.Verbose($"MetadataReaderExtensionsHelper: Discovering extensions inside assembly '{loadedAssembly.FullName}' file path '{assemblyFilePath}'"); + private Type[] DiscoverTestExtensionTypesV2AttributeInternal(Assembly loadedAssembly, string assemblyFilePath) + { + EqtTrace.Verbose($"MetadataReaderExtensionsHelper: Discovering extensions inside assembly '{loadedAssembly.FullName}' file path '{assemblyFilePath}'"); #if !NETSTANDARD1_3 - // We don't cache the load because this method is used by DiscoverTestExtensionTypesV2Attribute that caches the outcome Type[] - Assembly assemblyToAnalyze = Assembly.LoadFile(assemblyFilePath); -#else - Assembly assemblyToAnalyze = loadedAssembly; + // We don't cache the load because this method is used by DiscoverTestExtensionTypesV2Attribute that caches the outcome Type[] + Assembly assemblyToAnalyze = Assembly.LoadFile(assemblyFilePath); +#else + Assembly assemblyToAnalyze = loadedAssembly; #endif - List> extensions = null; - using (var stream = new FileStream(assemblyFilePath, FileMode.Open, FileAccess.Read)) - using (var reader = new PEReader(stream, PEStreamOptions.Default)) - { - MetadataReader metadataReader = reader.GetMetadataReader(); + List> extensions = null; + using (var stream = new FileStream(assemblyFilePath, FileMode.Open, FileAccess.Read)) + using (var reader = new PEReader(stream, PEStreamOptions.Default)) + { + MetadataReader metadataReader = reader.GetMetadataReader(); - // Search for the custom attribute TestExtensionTypesAttributeV2 - ECMA-335 II.22.10 CustomAttribute : 0x0C - foreach (var customAttributeHandle in metadataReader.CustomAttributes) + // Search for the custom attribute TestExtensionTypesAttributeV2 - ECMA-335 II.22.10 CustomAttribute : 0x0C + foreach (var customAttributeHandle in metadataReader.CustomAttributes) + { + string attributeFullName = null; + try { - string attributeFullName = null; - try + if (customAttributeHandle.IsNil) { - if (customAttributeHandle.IsNil) - { - continue; - } + continue; + } - // Read custom attribute metadata row - var customAttribute = metadataReader.GetCustomAttribute(customAttributeHandle); + // Read custom attribute metadata row + var customAttribute = metadataReader.GetCustomAttribute(customAttributeHandle); - // We expect that the attribute is defined inside current assembly by the extension owner - // and so ctor should point to the MethodDefinition table - ECMA-335 II.22.26 MethodDef : 0x06 - // and parent scope should be the current assembly [assembly:...] - ECMA-335 II.22.2 Assembly : 0x20 - if (customAttribute.Constructor.Kind != HandleKind.MethodDefinition || customAttribute.Parent.Kind != HandleKind.AssemblyDefinition) - { - continue; - } + // We expect that the attribute is defined inside current assembly by the extension owner + // and so ctor should point to the MethodDefinition table - ECMA-335 II.22.26 MethodDef : 0x06 + // and parent scope should be the current assembly [assembly:...] - ECMA-335 II.22.2 Assembly : 0x20 + if (customAttribute.Constructor.Kind != HandleKind.MethodDefinition || customAttribute.Parent.Kind != HandleKind.AssemblyDefinition) + { + continue; + } - // Read MethodDef metadata row - var methodDefinition = metadataReader.GetMethodDefinition((MethodDefinitionHandle)customAttribute.Constructor); + // Read MethodDef metadata row + var methodDefinition = metadataReader.GetMethodDefinition((MethodDefinitionHandle)customAttribute.Constructor); - // Check that name is .ctor - if (metadataReader.GetString(methodDefinition.Name) != ".ctor") - { - continue; - } + // Check that name is .ctor + if (metadataReader.GetString(methodDefinition.Name) != ".ctor") + { + continue; + } - // Get the custom attribute TypeDef handle - var typeDefinitionHandle = methodDefinition.GetDeclaringType(); + // Get the custom attribute TypeDef handle + var typeDefinitionHandle = methodDefinition.GetDeclaringType(); - // Read TypeDef metadata row - var typeDef = metadataReader.GetTypeDefinition(typeDefinitionHandle); + // Read TypeDef metadata row + var typeDef = metadataReader.GetTypeDefinition(typeDefinitionHandle); - // Check the attribute type full name - attributeFullName = $"{metadataReader.GetString(typeDef.Namespace)}.{metadataReader.GetString(typeDef.Name)}"; - if (attributeFullName == TestExtensionTypesAttributeV2) + // Check the attribute type full name + attributeFullName = $"{metadataReader.GetString(typeDef.Namespace)}.{metadataReader.GetString(typeDef.Name)}"; + if (attributeFullName == TestExtensionTypesAttributeV2) + { + // We don't do any signature verification to allow future possibility to add new parameter in a back compat way. + // Get signature blob using methodDefinition.Signature index into Blob heap - ECMA-335 II.22.26 MethodDef : 0x06, 'Signature' column + // BlobReader signatureReader = metadataReader.GetBlobReader(methodDefinition.Signature); + // var decoder = new SignatureDecoder(new SignatureDecoder(), metadataReader, genericContext: null); + // var ctorDecodedSignature = decoder.DecodeMethodSignature(ref signatureReader); + // Log the signature for analysis purpose + // EqtTrace.Verbose($"MetadataReaderExtensionsHelper: Find possible good attribute candidate '{attributeFullName}' with ctor signature: '{ctorDecodedSignature.ReturnType}" + + // $" ctor ({(ctorDecodedSignature.ParameterTypes.Length > 0 ? ctorDecodedSignature.ParameterTypes.Aggregate((a, b) => $"{a},{b}").Trim(',') : "(")})'"); + + // Read the ctor signature values - ECMA-335 II.23.3 Custom attributes + BlobReader valueReader = metadataReader.GetBlobReader(customAttribute.Value); + // Verify the prolog + if (valueReader.ReadUInt16() == 1) { - // We don't do any signature verification to allow future possibility to add new parameter in a back compat way. - // Get signature blob using methodDefinition.Signature index into Blob heap - ECMA-335 II.22.26 MethodDef : 0x06, 'Signature' column - // BlobReader signatureReader = metadataReader.GetBlobReader(methodDefinition.Signature); - // var decoder = new SignatureDecoder(new SignatureDecoder(), metadataReader, genericContext: null); - // var ctorDecodedSignature = decoder.DecodeMethodSignature(ref signatureReader); - // Log the signature for analysis purpose - // EqtTrace.Verbose($"MetadataReaderExtensionsHelper: Find possible good attribute candidate '{attributeFullName}' with ctor signature: '{ctorDecodedSignature.ReturnType}" + - // $" ctor ({(ctorDecodedSignature.ParameterTypes.Length > 0 ? ctorDecodedSignature.ParameterTypes.Aggregate((a, b) => $"{a},{b}").Trim(',') : "(")})'"); - - // Read the ctor signature values - ECMA-335 II.23.3 Custom attributes - BlobReader valueReader = metadataReader.GetBlobReader(customAttribute.Value); - // Verify the prolog - if (valueReader.ReadUInt16() == 1) + // Expected ctor shape ctor(string,string,System.Type,Int32) + // [assembly: TestExtensionTypesV2(ExtensionMetadata.ExtensionType, ExtensionMetadata.Uri, typeof(ExtensionImplementation), 1)] + + // If the parameter kind is string, (middle line in above diagram) then the blob contains + // a SerString – a PackedLen count of bytes, followed by the UTF8 characters.If the + // string is null, its PackedLen has the value 0xFF(with no following characters).If + // the string is empty(“”), then PackedLen has the value 0x00(with no following + // characters). + string extension = valueReader.ReadSerializedString(); + string extensionIdentifier = valueReader.ReadSerializedString(); + + // If the parameter kind is System.Type, (also, the middle line in above diagram) its + // value is stored as a SerString(as defined in the previous paragraph), representing its + // canonical name. The canonical name is its full type name, followed optionally by + // the assembly where it is defined, its version, culture and public-key-token.If the + // assembly name is omitted, the CLI looks first in the current assembly, and then in + // the system library(mscorlib); in these two special cases, it is permitted to omit the + // assembly-name, version, culture and public-key-token. + string extensionImplementation = valueReader.ReadSerializedString(); + + // If the parameter kind is simple(first line in the above diagram) (bool, char, float32, + // float64, int8, int16, int32, int64, unsigned int8, unsigned int16, unsigned int32 or + // unsigned int64) then the 'blob' contains its binary value(Val). (A bool is a single + // byte with value 0(false) or 1(true); char is a two-byte Unicode character; and the + // others have their obvious meaning.) This pattern is also used if the parameter kind is + // an enum -- simply store the value of the enum's underlying integer type. + int version = valueReader.ReadInt32(); + try { - // Expected ctor shape ctor(string,string,System.Type,Int32) - // [assembly: TestExtensionTypesV2(ExtensionMetadata.ExtensionType, ExtensionMetadata.Uri, typeof(ExtensionImplementation), 1)] - - // If the parameter kind is string, (middle line in above diagram) then the blob contains - // a SerString – a PackedLen count of bytes, followed by the UTF8 characters.If the - // string is null, its PackedLen has the value 0xFF(with no following characters).If - // the string is empty(“”), then PackedLen has the value 0x00(with no following - // characters). - string extension = valueReader.ReadSerializedString(); - string extensionIdentifier = valueReader.ReadSerializedString(); - - // If the parameter kind is System.Type, (also, the middle line in above diagram) its - // value is stored as a SerString(as defined in the previous paragraph), representing its - // canonical name. The canonical name is its full type name, followed optionally by - // the assembly where it is defined, its version, culture and public-key-token.If the - // assembly name is omitted, the CLI looks first in the current assembly, and then in - // the system library(mscorlib); in these two special cases, it is permitted to omit the - // assembly-name, version, culture and public-key-token. - string extensionImplementation = valueReader.ReadSerializedString(); - - // If the parameter kind is simple(first line in the above diagram) (bool, char, float32, - // float64, int8, int16, int32, int64, unsigned int8, unsigned int16, unsigned int32 or - // unsigned int64) then the 'blob' contains its binary value(Val). (A bool is a single - // byte with value 0(false) or 1(true); char is a two-byte Unicode character; and the - // others have their obvious meaning.) This pattern is also used if the parameter kind is - // an enum -- simply store the value of the enum's underlying integer type. - int version = valueReader.ReadInt32(); - try + var extensionType = assemblyToAnalyze.GetType(extensionImplementation); + if (extensionType is null) { - var extensionType = assemblyToAnalyze.GetType(extensionImplementation); - if (extensionType is null) - { - EqtTrace.Verbose($"MetadataReaderExtensionsHelper: Unable to get extension type for '{extensionImplementation}'"); - continue; - } - - if (extensions is null) extensions = new List>(); - extensions.Add(Tuple.Create(version, extensionType)); - EqtTrace.Verbose($"MetadataReaderExtensionsHelper: Valid extension found: extension type '{extension}' identifier '{extensionIdentifier}' implementation '{extensionType}' version '{version}'"); - } - catch (Exception ex) - { - EqtTrace.Verbose($"MetadataReaderExtensionsHelper: Failure during type creation, extension full name: '{extensionImplementation}'\n{FormatException(ex)}"); + EqtTrace.Verbose($"MetadataReaderExtensionsHelper: Unable to get extension type for '{extensionImplementation}'"); + continue; } + + if (extensions is null) extensions = new List>(); + extensions.Add(Tuple.Create(version, extensionType)); + EqtTrace.Verbose($"MetadataReaderExtensionsHelper: Valid extension found: extension type '{extension}' identifier '{extensionIdentifier}' implementation '{extensionType}' version '{version}'"); + } + catch (Exception ex) + { + EqtTrace.Verbose($"MetadataReaderExtensionsHelper: Failure during type creation, extension full name: '{extensionImplementation}'\n{FormatException(ex)}"); } } } - catch (Exception ex) - { - EqtTrace.Verbose($"MetadataReaderExtensionsHelper: Failure during custom attribute analysis, attribute full name: {attributeFullName}\n{FormatException(ex)}"); - } + } + catch (Exception ex) + { + EqtTrace.Verbose($"MetadataReaderExtensionsHelper: Failure during custom attribute analysis, attribute full name: {attributeFullName}\n{FormatException(ex)}"); } } - - return extensions?.OrderByDescending(t => t.Item1).Select(t => t.Item2).ToArray() ?? emptyTypeArray; } - private string FormatException(Exception ex) - { - StringBuilder log = new StringBuilder(); - Exception current = ex; - while (current != null) - { - log.AppendLine(current.ToString()); - current = current.InnerException; - } + return extensions?.OrderByDescending(t => t.Item1).Select(t => t.Item2).ToArray() ?? EmptyTypeArray; + } - return log.ToString(); + private string FormatException(Exception ex) + { + StringBuilder log = new(); + Exception current = ex; + while (current != null) + { + log.AppendLine(current.ToString()); + current = current.InnerException; } + + return log.ToString(); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsProviderExtensions.cs b/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsProviderExtensions.cs index 9caf3d38d1..99f9f9f00a 100644 --- a/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsProviderExtensions.cs +++ b/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsProviderExtensions.cs @@ -1,260 +1,247 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities +namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities; + +using System.IO; +using System.Xml; + +using Microsoft.VisualStudio.TestPlatform.Utilities; +using Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using System.Text.RegularExpressions; + +/// +/// Utilities to get the run settings from the provider and the command line options specified. +/// +internal static class RunSettingsProviderExtensions { - using System.Diagnostics.CodeAnalysis; - using System.IO; - using System.Xml; + public const string EmptyRunSettings = @""; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using System.Text.RegularExpressions; + /// + /// Pattern used to find parameter node. + /// + private const string ParameterString = "Parameter"; /// - /// Utilities to get the run settings from the provider and the command line options specified. + /// Pattern that indicates Attribute name. /// - internal static class RunSettingsProviderExtensions - { - public const string EmptyRunSettings = @""; - - /// - /// Pattern used to find parameter node. - /// - private const string ParameterString = "Parameter"; - - /// - /// Pattern that indicates Attribute name. - /// - private const string AttributeNameString = "AttrName"; - - /// - /// Pattern that indicates Attribute value. - /// - private const string AttributeValueString = "AttrValue"; - - /// - /// Attribute name key for test run parameter node - /// - private const string NameString = "name"; - - /// - /// Attribute value key for test run parameter node - /// - private const string ValueString = "value"; - - public static void UpdateRunSettings(this IRunSettingsProvider runSettingsProvider, string runsettingsXml) - { - ValidateArg.NotNull(runSettingsProvider, nameof(runSettingsProvider)); - ValidateArg.NotNullOrWhiteSpace(runsettingsXml, nameof(runsettingsXml)); + private const string AttributeNameString = "AttrName"; - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(runsettingsXml); - runSettingsProvider.SetActiveRunSettings(runSettings); - } + /// + /// Pattern that indicates Attribute value. + /// + private const string AttributeValueString = "AttrValue"; - public static void AddDefaultRunSettings(this IRunSettingsProvider runSettingsProvider) - { - ValidateArg.NotNull(runSettingsProvider, nameof(runSettingsProvider)); + /// + /// Attribute name key for test run parameter node + /// + private const string NameString = "name"; - var runSettingsXml = runSettingsProvider.ActiveRunSettings?.SettingsXml; + /// + /// Attribute value key for test run parameter node + /// + private const string ValueString = "value"; - if (string.IsNullOrWhiteSpace(runSettingsXml)) - { - runSettingsXml = EmptyRunSettings; - } + public static void UpdateRunSettings(this IRunSettingsProvider runSettingsProvider, string runsettingsXml) + { + ValidateArg.NotNull(runSettingsProvider, nameof(runSettingsProvider)); + ValidateArg.NotNullOrWhiteSpace(runsettingsXml, nameof(runsettingsXml)); - runSettingsXml = AddDefaultRunSettings(runSettingsXml); - runSettingsProvider.UpdateRunSettings(runSettingsXml); - } + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(runsettingsXml); + runSettingsProvider.SetActiveRunSettings(runSettings); + } + + public static void AddDefaultRunSettings(this IRunSettingsProvider runSettingsProvider) + { + ValidateArg.NotNull(runSettingsProvider, nameof(runSettingsProvider)); + + var runSettingsXml = runSettingsProvider.ActiveRunSettings?.SettingsXml; - public static void UpdateRunSettingsXmlDocumentInnerXml(XmlDocument xmlDocument, string key, string data) + if (string.IsNullOrWhiteSpace(runSettingsXml)) { - var node = GetXmlNode(xmlDocument, key) ?? CreateNode(xmlDocument, key); - node.InnerXml = data; + runSettingsXml = EmptyRunSettings; } - public static void UpdateRunSettingsNode(this IRunSettingsProvider runSettingsProvider, string key, string data) - { - ValidateArg.NotNull(runSettingsProvider, nameof(runSettingsProvider)); - ValidateArg.NotNullOrWhiteSpace(key, nameof(key)); - ValidateArg.NotNull(data, nameof(data)); + runSettingsXml = AddDefaultRunSettings(runSettingsXml); + runSettingsProvider.UpdateRunSettings(runSettingsXml); + } - var xmlDocument = runSettingsProvider.GetRunSettingXmlDocument(); - UpdateRunSettingsXmlDocument(xmlDocument, key, data); - runSettingsProvider.UpdateRunSettings(xmlDocument.OuterXml); - } + public static void UpdateRunSettingsXmlDocumentInnerXml(XmlDocument xmlDocument, string key, string data) + { + var node = GetXmlNode(xmlDocument, key) ?? CreateNode(xmlDocument, key); + node.InnerXml = data; + } - /// - /// Matches with test run parameter node pattern and returns that match. - /// - /// - /// - /// - public static Match GetTestRunParameterNodeMatch(this IRunSettingsProvider runSettingsProvider, string node) - { - var attrName = $"(?<{AttributeNameString}>[\\w.:-]+)"; - var attrValue = $"(?<{AttributeValueString}>.+)"; - Regex regex = new Regex($"{Constants.TestRunParametersName}.{ParameterString}\\(name\\s*=\\s*\"{attrName}\"\\s*,\\s*value\\s*=\\s*\"{attrValue}\"\\)"); - Match match = regex.Match(node); - return match; - } + public static void UpdateRunSettingsNode(this IRunSettingsProvider runSettingsProvider, string key, string data) + { + ValidateArg.NotNull(runSettingsProvider, nameof(runSettingsProvider)); + ValidateArg.NotNullOrWhiteSpace(key, nameof(key)); + ValidateArg.NotNull(data, nameof(data)); - /// - /// If test run parameter exists already it will override with new value otherwise this will add new test run parameter. - /// - /// - /// - public static void UpdateTestRunParameterSettingsNode(this IRunSettingsProvider runSettingsProvider, Match match) - { - ValidateArg.NotNull(runSettingsProvider, nameof(runSettingsProvider)); + var xmlDocument = runSettingsProvider.GetRunSettingXmlDocument(); + UpdateRunSettingsXmlDocument(xmlDocument, key, data); + runSettingsProvider.UpdateRunSettings(xmlDocument.OuterXml); + } + + /// + /// Matches with test run parameter node pattern and returns that match. + /// + /// + /// + /// + public static Match GetTestRunParameterNodeMatch(this IRunSettingsProvider runSettingsProvider, string node) + { + var attrName = $"(?<{AttributeNameString}>[\\w.:-]+)"; + var attrValue = $"(?<{AttributeValueString}>.+)"; + Regex regex = new($"{Constants.TestRunParametersName}.{ParameterString}\\(name\\s*=\\s*\"{attrName}\"\\s*,\\s*value\\s*=\\s*\"{attrValue}\"\\)"); + Match match = regex.Match(node); + return match; + } - var xmlDocument = runSettingsProvider.GetRunSettingXmlDocument(); - XmlNode testRunParameterNode = GetXmlNode(xmlDocument, Constants.TestRunParametersName) ?? xmlDocument.CreateElement(Constants.TestRunParametersName); - var attrName = match.Groups[AttributeNameString].Value; - var attrValue = match.Groups[AttributeValueString].Value; + /// + /// If test run parameter exists already it will override with new value otherwise this will add new test run parameter. + /// + /// + /// + public static void UpdateTestRunParameterSettingsNode(this IRunSettingsProvider runSettingsProvider, Match match) + { + ValidateArg.NotNull(runSettingsProvider, nameof(runSettingsProvider)); - if (!TryOverrideAttributeValue(testRunParameterNode, attrName, attrValue)) - { - XmlElement element = xmlDocument.CreateElement(ParameterString); - element.SetAttribute(NameString, attrName); - element.SetAttribute(ValueString, attrValue); - testRunParameterNode.AppendChild(element); - xmlDocument.DocumentElement.AppendChild(testRunParameterNode); - } + var xmlDocument = runSettingsProvider.GetRunSettingXmlDocument(); + XmlNode testRunParameterNode = GetXmlNode(xmlDocument, Constants.TestRunParametersName) ?? xmlDocument.CreateElement(Constants.TestRunParametersName); + var attrName = match.Groups[AttributeNameString].Value; + var attrValue = match.Groups[AttributeValueString].Value; - runSettingsProvider.UpdateRunSettings(xmlDocument.OuterXml); + if (!TryOverrideAttributeValue(testRunParameterNode, attrName, attrValue)) + { + XmlElement element = xmlDocument.CreateElement(ParameterString); + element.SetAttribute(NameString, attrName); + element.SetAttribute(ValueString, attrValue); + testRunParameterNode.AppendChild(element); + xmlDocument.DocumentElement.AppendChild(testRunParameterNode); } - private static bool TryOverrideAttributeValue(XmlNode xmlNode, string attrName, string attrValue) + runSettingsProvider.UpdateRunSettings(xmlDocument.OuterXml); + } + + private static bool TryOverrideAttributeValue(XmlNode xmlNode, string attrName, string attrValue) + { + foreach (XmlNode node in xmlNode.ChildNodes) { - foreach (XmlNode node in xmlNode.ChildNodes) + if (string.Compare(node.Attributes[NameString].Value, attrName) == 0) { - if (string.Compare(node.Attributes[NameString].Value, attrName) == 0) - { - node.Attributes[ValueString].Value = attrValue; - return true; - } + node.Attributes[ValueString].Value = attrValue; + return true; } - - return false; } - public static void UpdateRunSettingsNodeInnerXml(this IRunSettingsProvider runSettingsProvider, string key, string xml) - { - ValidateArg.NotNull(runSettingsProvider, nameof(runSettingsProvider)); - ValidateArg.NotNullOrWhiteSpace(key, nameof(key)); - ValidateArg.NotNull(xml, nameof(xml)); + return false; + } - var xmlDocument = runSettingsProvider.GetRunSettingXmlDocument(); - UpdateRunSettingsXmlDocumentInnerXml(xmlDocument, key, xml); - runSettingsProvider.UpdateRunSettings(xmlDocument.OuterXml); - } + public static void UpdateRunSettingsNodeInnerXml(this IRunSettingsProvider runSettingsProvider, string key, string xml) + { + ValidateArg.NotNull(runSettingsProvider, nameof(runSettingsProvider)); + ValidateArg.NotNullOrWhiteSpace(key, nameof(key)); + ValidateArg.NotNull(xml, nameof(xml)); - public static string QueryRunSettingsNode(this IRunSettingsProvider runSettingsProvider, string key) - { - ValidateArg.NotNull(runSettingsProvider, nameof(runSettingsProvider)); - ValidateArg.NotNullOrWhiteSpace(key, nameof(key)); + var xmlDocument = runSettingsProvider.GetRunSettingXmlDocument(); + UpdateRunSettingsXmlDocumentInnerXml(xmlDocument, key, xml); + runSettingsProvider.UpdateRunSettings(xmlDocument.OuterXml); + } - var xmlDocument = runSettingsProvider.GetRunSettingXmlDocument(); - var node = GetXmlNode(xmlDocument, key); - return node?.InnerText; - } + public static string QueryRunSettingsNode(this IRunSettingsProvider runSettingsProvider, string key) + { + ValidateArg.NotNull(runSettingsProvider, nameof(runSettingsProvider)); + ValidateArg.NotNullOrWhiteSpace(key, nameof(key)); - internal static XmlNode GetXmlNode(XmlDocument xmlDocument, string key) - { - var xPath = key.Replace('.', '/'); - var node = xmlDocument.SelectSingleNode(string.Format("//RunSettings/{0}", xPath)); - return node; - } + var xmlDocument = runSettingsProvider.GetRunSettingXmlDocument(); + var node = GetXmlNode(xmlDocument, key); + return node?.InnerText; + } - internal static void UpdateRunSettingsXmlDocument(XmlDocument xmlDocument, string key, string data) - { - var node = GetXmlNode(xmlDocument, key) ?? CreateNode(xmlDocument, key); - node.InnerText = data; - } + internal static XmlNode GetXmlNode(XmlDocument xmlDocument, string key) + { + var xPath = key.Replace('.', '/'); + var node = xmlDocument.SelectSingleNode(string.Format("//RunSettings/{0}", xPath)); + return node; + } - /// - /// Gets the effective run settings adding the default run settings if not already present. - /// - /// The run settings XML. - /// Effective run settings. - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", - Justification = "XmlDocument.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] - private static string AddDefaultRunSettings(string runSettings) - { - var architecture = Constants.DefaultPlatform; - var framework = Framework.DefaultFramework; - var defaultResultsDirectory = Path.Combine(Directory.GetCurrentDirectory(), Constants.ResultsDirectoryName); + internal static void UpdateRunSettingsXmlDocument(XmlDocument xmlDocument, string key, string data) + { + var node = GetXmlNode(xmlDocument, key) ?? CreateNode(xmlDocument, key); + node.InnerText = data; + } - using (var stream = new StringReader(runSettings)) - using (var reader = XmlReader.Create(stream, XmlRunSettingsUtilities.ReaderSettings)) - { - var document = new XmlDocument(); - document.Load(reader); + /// + /// Gets the effective run settings adding the default run settings if not already present. + /// + /// The run settings XML. + /// Effective run settings. + private static string AddDefaultRunSettings(string runSettings) + { + var architecture = Constants.DefaultPlatform; + var framework = Framework.DefaultFramework; + var defaultResultsDirectory = Path.Combine(Directory.GetCurrentDirectory(), Constants.ResultsDirectoryName); - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(document, architecture, framework, defaultResultsDirectory); - return document.OuterXml; - } - } + using var stream = new StringReader(runSettings); + using var reader = XmlReader.Create(stream, XmlRunSettingsUtilities.ReaderSettings); + var document = new XmlDocument(); + document.Load(reader); - private static XmlNode CreateNode(XmlDocument doc, string xPath) - { - var path = xPath.Split('.'); - XmlNode node = null; - XmlNode parent = doc.DocumentElement; + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(document, architecture, framework, defaultResultsDirectory); + return document.OuterXml; + } - for (var i = 0; i < path.Length; i++) - { - node = parent.SelectSingleNode(path[i]) ?? parent.AppendChild(doc.CreateElement(path[i])); - parent = node; - } + private static XmlNode CreateNode(XmlDocument doc, string xPath) + { + var path = xPath.Split('.'); + XmlNode node = null; + XmlNode parent = doc.DocumentElement; - return node; + for (var i = 0; i < path.Length; i++) + { + node = parent.SelectSingleNode(path[i]) ?? parent.AppendChild(doc.CreateElement(path[i])); + parent = node; } - private static XmlDocument GetRunSettingXmlDocument(this IRunSettingsProvider runSettingsProvider) - { - ValidateArg.NotNull(runSettingsProvider, nameof(runSettingsProvider)); + return node; + } + + private static XmlDocument GetRunSettingXmlDocument(this IRunSettingsProvider runSettingsProvider) + { + ValidateArg.NotNull(runSettingsProvider, nameof(runSettingsProvider)); - var doc = new XmlDocument(); + var doc = new XmlDocument(); - if (runSettingsProvider.ActiveRunSettings != null && - !string.IsNullOrEmpty(runSettingsProvider.ActiveRunSettings.SettingsXml)) - { - var settingsXml = runSettingsProvider.ActiveRunSettings.SettingsXml; + if (runSettingsProvider.ActiveRunSettings != null && + !string.IsNullOrEmpty(runSettingsProvider.ActiveRunSettings.SettingsXml)) + { + var settingsXml = runSettingsProvider.ActiveRunSettings.SettingsXml; #if NETFRAMEWORK - using (var reader = XmlReader.Create(new StringReader(settingsXml), new XmlReaderSettings() { XmlResolver = null, CloseInput = true, DtdProcessing = DtdProcessing.Prohibit })) - { + using var reader = XmlReader.Create(new StringReader(settingsXml), new XmlReaderSettings() { XmlResolver = null, CloseInput = true, DtdProcessing = DtdProcessing.Prohibit }); #else - using ( - var reader = XmlReader.Create(new StringReader(settingsXml), - new XmlReaderSettings() { CloseInput = true, DtdProcessing = DtdProcessing.Prohibit })) - { + using var reader = XmlReader.Create(new StringReader(settingsXml), + new XmlReaderSettings() { CloseInput = true, DtdProcessing = DtdProcessing.Prohibit }); #endif - doc.Load(reader); - } - } - else - { + doc.Load(reader); + } + else + { #if NETFRAMEWORK - doc = (XmlDocument) XmlRunSettingsUtilities.CreateDefaultRunSettings(); + doc = (XmlDocument)XmlRunSettingsUtilities.CreateDefaultRunSettings(); #else - using ( - var reader = - XmlReader.Create( - new StringReader( - XmlRunSettingsUtilities.CreateDefaultRunSettings().CreateNavigator().OuterXml), - new XmlReaderSettings() { CloseInput = true, DtdProcessing = DtdProcessing.Prohibit })) - { - doc.Load(reader); - } + using var reader = + XmlReader.Create( + new StringReader( + XmlRunSettingsUtilities.CreateDefaultRunSettings().CreateNavigator().OuterXml), + new XmlReaderSettings() { CloseInput = true, DtdProcessing = DtdProcessing.Prohibit }); + doc.Load(reader); #endif - } - return doc; } + return doc; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsUtilities.cs b/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsUtilities.cs index 28f037c4c9..607c0586dc 100644 --- a/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsUtilities.cs +++ b/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsUtilities.cs @@ -1,197 +1,197 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities -{ - using System; - using System.Collections.Generic; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities; + +using System; +using System.Collections.Generic; +using System.Linq; + +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +/// +/// Utility methods for RunSettings. +/// +public static class RunSettingsUtilities +{ /// - /// Utility methods for RunSettings. + /// Create RunSettings object corresponding to settingsXml /// - public static class RunSettingsUtilities + public static RunSettings CreateAndInitializeRunSettings(string settingsXml) { - /// - /// Create RunSettings object corresponding to settingsXml - /// - public static RunSettings CreateAndInitializeRunSettings(string settingsXml) - { - RunSettings settings = null; + RunSettings settings = null; - if (!StringUtilities.IsNullOrWhiteSpace(settingsXml)) - { - settings = new RunSettings(); - settings.LoadSettingsXml(settingsXml); - settings.InitializeSettingsProviders(settingsXml); - } - return settings; + if (!StringUtilities.IsNullOrWhiteSpace(settingsXml)) + { + settings = new RunSettings(); + settings.LoadSettingsXml(settingsXml); + settings.InitializeSettingsProviders(settingsXml); } + return settings; + } - /// - /// Gets the test results directory from the run configuration - /// - /// Test run configuration - /// Test results directory - public static string GetTestResultsDirectory(RunConfiguration runConfiguration) + /// + /// Gets the test results directory from the run configuration + /// + /// Test run configuration + /// Test results directory + public static string GetTestResultsDirectory(RunConfiguration runConfiguration) + { + string resultsDirectory = null; + if (runConfiguration != null) { - string resultsDirectory = null; - if (runConfiguration != null) - { - // It will try to get path from runsettings, if not found then it will return default path. - resultsDirectory = Environment.ExpandEnvironmentVariables(runConfiguration.ResultsDirectory); - } + // It will try to get path from runsettings, if not found then it will return default path. + resultsDirectory = Environment.ExpandEnvironmentVariables(runConfiguration.ResultsDirectory); + } + + return resultsDirectory; + } - return resultsDirectory; + /// + /// Gets the target framework from the run configuration + /// + /// Test run configuration + /// Target Framework + public static Framework GetTargetFramework(RunConfiguration runConfiguration) + { + Framework targetFramework = null; + if (runConfiguration != null) + { + // It will get target framework from runsettings + targetFramework = runConfiguration.TargetFramework; } - /// - /// Gets the target framework from the run configuration - /// - /// Test run configuration - /// Target Framework - public static Framework GetTargetFramework(RunConfiguration runConfiguration) + return targetFramework; + } + + /// + /// Gets the solution directory from run configuration + /// + /// Test run configuration + /// Solution directory + public static string GetSolutionDirectory(RunConfiguration runConfiguration) + { + string solutionDirectory = null; + if (runConfiguration != null) { - Framework targetFramework = null; - if (runConfiguration != null) + if (!string.IsNullOrEmpty(runConfiguration.SolutionDirectory)) { - // It will get target framework from runsettings - targetFramework = runConfiguration.TargetFramework; + // Env var is expanded in run configuration + solutionDirectory = runConfiguration.SolutionDirectory; } + } + + return solutionDirectory; + } + + /// + /// Gets the maximum CPU count from setting xml + /// + /// setting xml + /// Maximum CPU Count + public static int GetMaxCpuCount(string settingXml) + { + int cpuCount = Constants.DefaultCpuCount; - return targetFramework; + if (string.IsNullOrEmpty(settingXml)) + { + return cpuCount; } - /// - /// Gets the solution directory from run configuration - /// - /// Test run configuration - /// Solution directory - public static string GetSolutionDirectory(RunConfiguration runConfiguration) + try { - string solutionDirectory = null; - if (runConfiguration != null) + var configuration = XmlRunSettingsUtilities.GetRunConfigurationNode(settingXml); + cpuCount = GetMaxCpuCount(configuration); + } + catch (SettingsException ex) + { + if (EqtTrace.IsVerboseEnabled) { - if (!string.IsNullOrEmpty(runConfiguration.SolutionDirectory)) - { - // Env var is expanded in run configuration - solutionDirectory = runConfiguration.SolutionDirectory; - } + EqtTrace.Verbose("RunSettingsUtilities.GetMaxCpuCount: Unable to get maximum CPU count from Setting Xml. {0}", ex); } - - return solutionDirectory; } - /// - /// Gets the maximum CPU count from setting xml - /// - /// setting xml - /// Maximum CPU Count - public static int GetMaxCpuCount(string settingXml) + return cpuCount; + } + + /// + /// Gets the maximum CPU count from run configuration + /// + /// Test run configuration + /// Maximum CPU Count + public static int GetMaxCpuCount(RunConfiguration runConfiguration) + { + int cpuCount = Constants.DefaultCpuCount; + + if (runConfiguration != null) { - int cpuCount = Constants.DefaultCpuCount; + cpuCount = runConfiguration.MaxCpuCount; + } - if (string.IsNullOrEmpty(settingXml)) - { - return cpuCount; - } + return cpuCount; + } + /// + /// Gets the value of TreatNoTestsAsError parameter from runsettings file + /// + /// Runsetting string value + /// The value of TreatNoTestsAsError + public static bool GetTreatNoTestsAsError(string runSettings) + { + bool treatNoTestsAsError = false; + if (runSettings != null) + { try { - var configuration = XmlRunSettingsUtilities.GetRunConfigurationNode(settingXml); - cpuCount = GetMaxCpuCount(configuration); + RunConfiguration runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runSettings); + treatNoTestsAsError = GetTreatNoTestsAsError(runConfiguration); } - catch (SettingsException ex) + catch (SettingsException se) { - if (EqtTrace.IsVerboseEnabled) + if (EqtTrace.IsErrorEnabled) { - EqtTrace.Verbose("RunSettingsUtilities.GetMaxCpuCount: Unable to get maximum CPU count from Setting Xml. {0}", ex); + EqtTrace.Error("RunSettingsUtilities.GetTreatNoTestsAsError: Unable to get the value of TreatNoTestsAsError from runsettings: Error {0}", se); } } - - return cpuCount; } - /// - /// Gets the maximum CPU count from run configuration - /// - /// Test run configuration - /// Maximum CPU Count - public static int GetMaxCpuCount(RunConfiguration runConfiguration) - { - int cpuCount = Constants.DefaultCpuCount; + return treatNoTestsAsError; + } - if (runConfiguration != null) - { - cpuCount = runConfiguration.MaxCpuCount; - } + private static bool GetTreatNoTestsAsError(RunConfiguration runConfiguration) + { + bool treatNoTestsAsError = false; - return cpuCount; - } - /// - /// Gets the value of TreatNoTestsAsError parameter from runsettings file - /// - /// Runsetting string value - /// The value of TreatNoTestsAsError - public static bool GetTreatNoTestsAsError(string runSettings) + if (runConfiguration != null) { - bool treatNoTestsAsError = false; - - if (runSettings != null) - { - try - { - RunConfiguration runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runSettings); - treatNoTestsAsError = GetTreatNoTestsAsError(runConfiguration); - } - catch (SettingsException se) - { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("RunSettingsUtilities.GetTreatNoTestsAsError: Unable to get the value of TreatNoTestsAsError from runsettings: Error {0}", se); - } - } - } - - return treatNoTestsAsError; + treatNoTestsAsError = runConfiguration.TreatNoTestsAsError; } - private static bool GetTreatNoTestsAsError(RunConfiguration runConfiguration) - { - bool treatNoTestsAsError = false; - - if (runConfiguration != null) - { - treatNoTestsAsError = runConfiguration.TreatNoTestsAsError; - } + return treatNoTestsAsError; + } - return treatNoTestsAsError; - } + /// + /// Gets the test adapters path from the run configuration + /// + /// Test run settings + /// True to return null, if adapter paths is not set. + /// Test adapters paths + public static IEnumerable GetTestAdaptersPaths(string runSettings) + { + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runSettings); - /// - /// Gets the test adapters path from the run configuration - /// - /// Test run settings - /// True to return null, if adapter paths is not set. - /// Test adapters paths - public static IEnumerable GetTestAdaptersPaths(string runSettings) + IEnumerable testAdaptersPaths = Enumerable.Empty(); + if (runConfiguration != null) { - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runSettings); - - IEnumerable testAdaptersPaths = Enumerable.Empty(); - if (runConfiguration != null) + if (runConfiguration.TestAdaptersPathsSet) { - if (runConfiguration.TestAdaptersPathsSet) - { - testAdaptersPaths = runConfiguration.TestAdaptersPaths.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); - } + testAdaptersPaths = runConfiguration.TestAdaptersPaths.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); } - - return testAdaptersPaths; } + return testAdaptersPaths; } -} + +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Utilities/TypesToLoadUtilities.cs b/src/Microsoft.TestPlatform.Common/Utilities/TypesToLoadUtilities.cs index 22f568f399..051c89f849 100644 --- a/src/Microsoft.TestPlatform.Common/Utilities/TypesToLoadUtilities.cs +++ b/src/Microsoft.TestPlatform.Common/Utilities/TypesToLoadUtilities.cs @@ -1,42 +1,38 @@ -// Copyright(c) Microsoft Corporation.All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities -{ - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using System; - using System.Collections.Generic; - using System.Reflection; - using System.Linq; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - internal static class TypesToLoadUtilities - { - public const string TypesToLoadAttributeFullName = "Microsoft.VisualStudio.TestPlatform.TestExtensionTypesAttribute"; +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Linq; - internal static IEnumerable GetTypesToLoad(Assembly assembly) - { - ValidateArg.NotNull(assembly, nameof(assembly)); +internal static class TypesToLoadUtilities +{ + public const string TypesToLoadAttributeFullName = "Microsoft.VisualStudio.TestPlatform.TestExtensionTypesAttribute"; - var typesToLoad = assembly - .GetCustomAttributes(TypesToLoadAttributeFullName) - .SelectMany(i => GetTypesToLoad(i)); + internal static IEnumerable GetTypesToLoad(Assembly assembly) + { + ValidateArg.NotNull(assembly, nameof(assembly)); - return typesToLoad; - } + var typesToLoad = assembly + .GetCustomAttributes(TypesToLoadAttributeFullName) + .SelectMany(i => GetTypesToLoad(i)); - private static IEnumerable GetTypesToLoad(Attribute attribute) - { - if (attribute == null) - return Enumerable.Empty(); + return typesToLoad; + } - var type = attribute.GetType(); - var typesProperty = type.GetProperty("Types"); - if(typesProperty == null) - return Enumerable.Empty(); + private static IEnumerable GetTypesToLoad(Attribute attribute) + { + if (attribute == null) + return Enumerable.Empty(); - return typesProperty.GetValue(attribute) as Type[]; - } + var type = attribute.GetType(); + var typesProperty = type.GetProperty("Types"); + return typesProperty == null ? Enumerable.Empty() : typesProperty.GetValue(attribute) as Type[]; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/CommunicationEndpointFactory.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/CommunicationEndpointFactory.cs index 99b2621f38..740265ca20 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/CommunicationEndpointFactory.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/CommunicationEndpointFactory.cs @@ -1,30 +1,21 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities -{ - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - /// - /// Implements ICommunicationEndpointFactory. - /// - public class CommunicationEndpointFactory : ICommunicationEndpointFactory - { - /// - public ICommunicationEndPoint Create(ConnectionRole role) - { - ICommunicationEndPoint endPoint; - if (role == ConnectionRole.Host) - { - endPoint = new SocketServer(); - } - else - { - endPoint = new SocketClient(); - } +using Interfaces; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; - return endPoint; - } +/// +/// Implements ICommunicationEndpointFactory. +/// +public class CommunicationEndpointFactory : ICommunicationEndpointFactory +{ + /// + public ICommunicationEndPoint Create(ConnectionRole role) + { + ICommunicationEndPoint endPoint = role == ConnectionRole.Host ? new SocketServer() : new SocketClient(); + return endPoint; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionRequestHandler.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionRequestHandler.cs index 8ed776bba3..a8d0401335 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionRequestHandler.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionRequestHandler.cs @@ -1,425 +1,429 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Net; +using System.Threading; +using System.Threading.Tasks; + +using CoreUtilities.Helpers; + +using Common; +using Microsoft.VisualStudio.TestPlatform.Common.DataCollection; +using Common.DataCollector; +using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; +using Common.ExtensionFramework; +using Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +using CommunicationUtilitiesResources = Resources.Resources; +using CoreUtilitiesConstants = CoreUtilities.Constants; + +/// +/// Handles test session events received from vstest console process. +/// +internal class DataCollectionRequestHandler : IDataCollectionRequestHandler, IDisposable { - using System; - using System.Collections.Generic; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Net; - using System.Threading; - using System.Threading.Tasks; - using CoreUtilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollection; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using CommunicationUtilitiesResources = Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources.Resources; - using CoreUtilitiesConstants = Microsoft.VisualStudio.TestPlatform.CoreUtilities.Constants; + private static readonly object SyncObject = new(); - /// - /// Handles test session events received from vstest console process. - /// - internal class DataCollectionRequestHandler : IDataCollectionRequestHandler, IDisposable - { - private static readonly object SyncObject = new object(); + private readonly ICommunicationManager _communicationManager; - private readonly ICommunicationManager communicationManager; + private readonly IMessageSink _messageSink; - private IMessageSink messageSink; + private readonly IDataCollectionManager _dataCollectionManager; - private IDataCollectionManager dataCollectionManager; + private readonly IDataCollectionTestCaseEventHandler _dataCollectionTestCaseEventHandler; - private IDataCollectionTestCaseEventHandler dataCollectionTestCaseEventHandler; + private Task _testCaseEventMonitorTask; - private Task testCaseEventMonitorTask; + private readonly IDataSerializer _dataSerializer; - private IDataSerializer dataSerializer; + private readonly IFileHelper _fileHelper; - private IFileHelper fileHelper; + private readonly IRequestData _requestData; - private IRequestData requestData; + /// + /// Use to cancel data collection test case events monitoring if test run is canceled. + /// + private readonly CancellationTokenSource _cancellationTokenSource; - /// - /// Use to cancel data collection test case events monitoring if test run is canceled. - /// - private CancellationTokenSource cancellationTokenSource; + /// + /// Initializes a new instance of the class. + /// + /// + /// The message sink. + /// + /// + /// The request data. + /// + protected DataCollectionRequestHandler(IMessageSink messageSink, IRequestData requestData) + : this( + new SocketCommunicationManager(), + messageSink, + DataCollectionManager.Create(messageSink, requestData), + new DataCollectionTestCaseEventHandler(), + JsonDataSerializer.Instance, + new FileHelper(), + requestData) + { + _messageSink = messageSink; + } - /// - /// Initializes a new instance of the class. - /// - /// - /// The message sink. - /// - /// - /// The request data. - /// - protected DataCollectionRequestHandler(IMessageSink messageSink, IRequestData requestData) - : this( - new SocketCommunicationManager(), - messageSink, - DataCollectionManager.Create(messageSink, requestData), - new DataCollectionTestCaseEventHandler(), - JsonDataSerializer.Instance, - new FileHelper(), - requestData) - { - this.messageSink = messageSink; - } + /// + /// Initializes a new instance of the class. + /// + /// + /// The communication manager. + /// + /// + /// The message sink. + /// + /// + /// The data collection manager. + /// + /// + /// The data collection test case event handler. + /// + /// + /// Serializer for serialization and deserialization of the messages. + /// + /// + /// File Helper + /// + /// + /// Request data + /// + protected DataCollectionRequestHandler( + ICommunicationManager communicationManager, + IMessageSink messageSink, + IDataCollectionManager dataCollectionManager, + IDataCollectionTestCaseEventHandler dataCollectionTestCaseEventHandler, + IDataSerializer dataSerializer, + IFileHelper fileHelper, + IRequestData requestData) + { + _communicationManager = communicationManager; + _messageSink = messageSink; + _dataCollectionManager = dataCollectionManager; + _dataSerializer = dataSerializer; + _dataCollectionTestCaseEventHandler = dataCollectionTestCaseEventHandler; + _cancellationTokenSource = new CancellationTokenSource(); + _fileHelper = fileHelper; + _requestData = requestData; + } - /// - /// Initializes a new instance of the class. - /// - /// - /// The communication manager. - /// - /// - /// The message sink. - /// - /// - /// The data collection manager. - /// - /// - /// The data collection test case event handler. - /// - /// - /// Serializer for serialization and deserialization of the messages. - /// - /// - /// File Helper - /// - /// - /// Request data - /// - protected DataCollectionRequestHandler( - ICommunicationManager communicationManager, - IMessageSink messageSink, - IDataCollectionManager dataCollectionManager, - IDataCollectionTestCaseEventHandler dataCollectionTestCaseEventHandler, - IDataSerializer dataSerializer, - IFileHelper fileHelper, - IRequestData requestData) - { - this.communicationManager = communicationManager; - this.messageSink = messageSink; - this.dataCollectionManager = dataCollectionManager; - this.dataSerializer = dataSerializer; - this.dataCollectionTestCaseEventHandler = dataCollectionTestCaseEventHandler; - this.cancellationTokenSource = new CancellationTokenSource(); - this.fileHelper = fileHelper; - this.requestData = requestData; - } + /// + /// Gets the singleton instance of DataCollectionRequestHandler. + /// + public static DataCollectionRequestHandler Instance { get; private set; } - /// - /// Gets the singleton instance of DataCollectionRequestHandler. - /// - public static DataCollectionRequestHandler Instance { get; private set; } - - /// - /// Creates singleton instance of DataCollectionRequestHandler. - /// - /// - /// Handles socket communication. - /// - /// - /// Message sink for sending messages to execution process. - /// - /// - /// The instance of . - /// - public static DataCollectionRequestHandler Create( - ICommunicationManager communicationManager, - IMessageSink messageSink) + /// + /// Creates singleton instance of DataCollectionRequestHandler. + /// + /// + /// Handles socket communication. + /// + /// + /// Message sink for sending messages to execution process. + /// + /// + /// The instance of . + /// + public static DataCollectionRequestHandler Create( + ICommunicationManager communicationManager, + IMessageSink messageSink) + { + ValidateArg.NotNull(communicationManager, nameof(communicationManager)); + ValidateArg.NotNull(messageSink, nameof(messageSink)); + if (Instance == null) { - ValidateArg.NotNull(communicationManager, nameof(communicationManager)); - ValidateArg.NotNull(messageSink, nameof(messageSink)); - if (Instance == null) + lock (SyncObject) { - lock (SyncObject) + if (Instance == null) { - if (Instance == null) - { - var requestData = new RequestData(); - - Instance = new DataCollectionRequestHandler( - communicationManager, - messageSink, - DataCollectionManager.Create(messageSink, requestData), - new DataCollectionTestCaseEventHandler(), - JsonDataSerializer.Instance, - new FileHelper(), - requestData); - } + var requestData = new RequestData(); + + Instance = new DataCollectionRequestHandler( + communicationManager, + messageSink, + DataCollectionManager.Create(messageSink, requestData), + new DataCollectionTestCaseEventHandler(), + JsonDataSerializer.Instance, + new FileHelper(), + requestData); } } - - return Instance; } - /// - public void InitializeCommunication(int port) - { - this.communicationManager.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)); - } + return Instance; + } - /// - public bool WaitForRequestSenderConnection(int connectionTimeout) - { - return this.communicationManager.WaitForServerConnection(connectionTimeout); - } + /// + public void InitializeCommunication(int port) + { + _communicationManager.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)); + } - /// - /// Process requests. - /// - public void ProcessRequests() + /// + public bool WaitForRequestSenderConnection(int connectionTimeout) + { + return _communicationManager.WaitForServerConnection(connectionTimeout); + } + + /// + /// Process requests. + /// + public void ProcessRequests() + { + var isSessionEnded = false; + + do { - var isSessionEnded = false; + var message = _communicationManager.ReceiveMessage(); - do + if (EqtTrace.IsInfoEnabled) { - var message = this.communicationManager.ReceiveMessage(); - - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DataCollectionRequestHandler.ProcessRequests : Datacollector received message: {0}", message); - } + EqtTrace.Info("DataCollectionRequestHandler.ProcessRequests : Datacollector received message: {0}", message); + } - switch (message.MessageType) - { - case MessageType.BeforeTestRunStart: - this.HandleBeforeTestRunStart(message); - break; - - case MessageType.AfterTestRunEnd: - this.HandleAfterTestRunEnd(message); - isSessionEnded = true; - break; - - case MessageType.TestHostLaunched: - var testHostLaunchedPayload = this.dataSerializer.DeserializePayload(message); - this.dataCollectionManager.TestHostLaunched(testHostLaunchedPayload.ProcessId); - break; - - default: - EqtTrace.Error("DataCollectionRequestHandler.ProcessRequests : Invalid Message types: {0}", message.MessageType); - break; - } + switch (message.MessageType) + { + case MessageType.BeforeTestRunStart: + HandleBeforeTestRunStart(message); + break; + + case MessageType.AfterTestRunEnd: + HandleAfterTestRunEnd(message); + isSessionEnded = true; + break; + + case MessageType.TestHostLaunched: + var testHostLaunchedPayload = _dataSerializer.DeserializePayload(message); + _dataCollectionManager.TestHostLaunched(testHostLaunchedPayload.ProcessId); + break; + + default: + EqtTrace.Error("DataCollectionRequestHandler.ProcessRequests : Invalid Message types: {0}", message.MessageType); + break; } - while (!isSessionEnded); } + while (!isSessionEnded); + } - /// - /// Sends datacollection message. - /// - /// - /// The args. - /// - public void SendDataCollectionMessage(DataCollectionMessageEventArgs args) - { - this.communicationManager.SendMessage(MessageType.DataCollectionMessage, args); - } + /// + /// Sends datacollection message. + /// + /// + /// The args. + /// + public void SendDataCollectionMessage(DataCollectionMessageEventArgs args) + { + _communicationManager.SendMessage(MessageType.DataCollectionMessage, args); + } - /// - /// The dispose. - /// - public void Dispose() - { - this.communicationManager?.StopClient(); - } + /// + /// The dispose. + /// + public void Dispose() + { + _communicationManager?.StopClient(); + } - /// - /// Closes the connection - /// - public void Close() - { - this.Dispose(); - EqtTrace.Info("Closing the connection !"); - } + /// + /// Closes the connection + /// + public void Close() + { + Dispose(); + EqtTrace.Info("Closing the connection !"); + } - /// - /// Update the test adapter paths provided through run settings to be used by the test plugin cache. - /// - /// - /// The before test run start payload - /// - private void AddExtensionAssemblies(BeforeTestRunStartPayload payload) + /// + /// Update the test adapter paths provided through run settings to be used by the test plugin cache. + /// + /// + /// The before test run start payload + /// + private void AddExtensionAssemblies(BeforeTestRunStartPayload payload) + { + try { - try + var customTestAdaptersPaths = RunSettingsUtilities.GetTestAdaptersPaths(payload.SettingsXml); + + // In case of dotnet vstest with code coverage, data collector needs to be picked up from publish folder. + // Therefore, adding source dll folders to search datacollectors in these. + var datacollectorSearchPaths = new HashSet(); + foreach (var source in payload.Sources) { - var customTestAdaptersPaths = RunSettingsUtilities.GetTestAdaptersPaths(payload.SettingsXml); + datacollectorSearchPaths.Add(Path.GetDirectoryName(source)); + } - // In case of dotnet vstest with code coverage, data collector needs to be picked up from publish folder. - // Therefore, adding source dll folders to search datacollectors in these. - var datacollectorSearchPaths = new HashSet(); - foreach (var source in payload.Sources) - { - datacollectorSearchPaths.Add(Path.GetDirectoryName(source)); - } + if (customTestAdaptersPaths != null) + { + datacollectorSearchPaths.UnionWith(customTestAdaptersPaths); + } - if (customTestAdaptersPaths != null) + List extensionAssemblies = new(); + foreach (var datacollectorSearchPath in datacollectorSearchPaths) + { + var adapterPath = + Path.GetFullPath(Environment.ExpandEnvironmentVariables(datacollectorSearchPath)); + if (!_fileHelper.DirectoryExists(adapterPath)) { - datacollectorSearchPaths.UnionWith(customTestAdaptersPaths); + EqtTrace.Warning(string.Format("AdapterPath Not Found:", adapterPath)); + continue; } - List extensionAssemblies = new List(); - foreach (var datacollectorSearchPath in datacollectorSearchPaths) - { - var adapterPath = - Path.GetFullPath(Environment.ExpandEnvironmentVariables(datacollectorSearchPath)); - if (!this.fileHelper.DirectoryExists(adapterPath)) - { - EqtTrace.Warning(string.Format("AdapterPath Not Found:", adapterPath)); - continue; - } - - extensionAssemblies.AddRange( - this.fileHelper.EnumerateFiles( - adapterPath, - SearchOption.AllDirectories, - TestPlatformConstants.DataCollectorEndsWithPattern)); - } + extensionAssemblies.AddRange( + _fileHelper.EnumerateFiles( + adapterPath, + SearchOption.AllDirectories, + TestPlatformConstants.DataCollectorEndsWithPattern)); + } - if (extensionAssemblies.Count > 0) - { - TestPluginCache.Instance.UpdateExtensions(extensionAssemblies, skipExtensionFilters: false); - } + if (extensionAssemblies.Count > 0) + { + TestPluginCache.Instance.UpdateExtensions(extensionAssemblies, skipExtensionFilters: false); } - catch (Exception e) + } + catch (Exception e) + { + // If any exception is thrown while updating additional assemblies, log the exception in eqt trace. + if (EqtTrace.IsErrorEnabled) { - // If any exception is thrown while updating additional assemblies, log the exception in eqt trace. - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("DataCollectionRequestHandler.AddExtensionAssemblies: Exception occurred: {0}", e); - } + EqtTrace.Error("DataCollectionRequestHandler.AddExtensionAssemblies: Exception occurred: {0}", e); } } + } - private void HandleBeforeTestRunStart(Message message) - { - // Initialize datacollectors and get environment variables. - var payload = this.dataSerializer.DeserializePayload(message); - this.UpdateRequestData(payload.IsTelemetryOptedIn); - this.AddExtensionAssemblies(payload); + private void HandleBeforeTestRunStart(Message message) + { + // Initialize datacollectors and get environment variables. + var payload = _dataSerializer.DeserializePayload(message); + UpdateRequestData(payload.IsTelemetryOptedIn); + AddExtensionAssemblies(payload); - var envVariables = this.dataCollectionManager.InitializeDataCollectors(payload.SettingsXml); + var envVariables = _dataCollectionManager.InitializeDataCollectors(payload.SettingsXml); - var properties = new Dictionary(); - properties.Add(CoreUtilitiesConstants.TestSourcesKeyName, payload.Sources); - var eventArgs = new SessionStartEventArgs(properties); + var properties = new Dictionary + { + { CoreUtilitiesConstants.TestSourcesKeyName, payload.Sources } + }; + var eventArgs = new SessionStartEventArgs(properties); - var areTestCaseLevelEventsRequired = this.dataCollectionManager.SessionStarted(eventArgs); + var areTestCaseLevelEventsRequired = _dataCollectionManager.SessionStarted(eventArgs); - // Open a socket communication port for test level events. - var testCaseEventsPort = 0; - if (areTestCaseLevelEventsRequired) - { - testCaseEventsPort = this.dataCollectionTestCaseEventHandler.InitializeCommunication(); + // Open a socket communication port for test level events. + var testCaseEventsPort = 0; + if (areTestCaseLevelEventsRequired) + { + testCaseEventsPort = _dataCollectionTestCaseEventHandler.InitializeCommunication(); - this.testCaseEventMonitorTask = Task.Factory.StartNew( - () => + _testCaseEventMonitorTask = Task.Factory.StartNew( + () => + { + try { - try - { - var timeout = EnvironmentHelper.GetConnectionTimeout(); - if (this.dataCollectionTestCaseEventHandler.WaitForRequestHandlerConnection( + var timeout = EnvironmentHelper.GetConnectionTimeout(); + if (_dataCollectionTestCaseEventHandler.WaitForRequestHandlerConnection( timeout * 1000)) - { - this.dataCollectionTestCaseEventHandler.ProcessRequests(); - } - else - { - EqtTrace.Error( - "DataCollectionRequestHandler.HandleBeforeTestRunStart: TestCaseEventHandler timed out while connecting to the Sender."); - this.dataCollectionTestCaseEventHandler.Close(); - throw new TestPlatformException( - string.Format( - CultureInfo.CurrentUICulture, - CommunicationUtilitiesResources.ConnectionTimeoutErrorMessage, - CoreUtilitiesConstants.DatacollectorProcessName, - CoreUtilitiesConstants.TesthostProcessName, - timeout, - EnvironmentHelper.VstestConnectionTimeout)); - } + { + _dataCollectionTestCaseEventHandler.ProcessRequests(); } - catch (Exception e) + else { - EqtTrace.Error("DataCollectionRequestHandler.HandleBeforeTestRunStart : Error occurred during initialization of TestHost : {0}", e); + EqtTrace.Error( + "DataCollectionRequestHandler.HandleBeforeTestRunStart: TestCaseEventHandler timed out while connecting to the Sender."); + _dataCollectionTestCaseEventHandler.Close(); + throw new TestPlatformException( + string.Format( + CultureInfo.CurrentUICulture, + CommunicationUtilitiesResources.ConnectionTimeoutErrorMessage, + CoreUtilitiesConstants.DatacollectorProcessName, + CoreUtilitiesConstants.TesthostProcessName, + timeout, + EnvironmentHelper.VstestConnectionTimeout)); } - }, - this.cancellationTokenSource.Token); - } + } + catch (Exception e) + { + EqtTrace.Error("DataCollectionRequestHandler.HandleBeforeTestRunStart : Error occurred during initialization of TestHost : {0}", e); + } + }, + _cancellationTokenSource.Token); + } - this.communicationManager.SendMessage( - MessageType.BeforeTestRunStartResult, - new BeforeTestRunStartResult(envVariables, testCaseEventsPort)); + _communicationManager.SendMessage( + MessageType.BeforeTestRunStartResult, + new BeforeTestRunStartResult(envVariables, testCaseEventsPort)); - EqtTrace.Info("DataCollectionRequestHandler.ProcessRequests : DataCollection started."); - } + EqtTrace.Info("DataCollectionRequestHandler.ProcessRequests : DataCollection started."); + } - private void HandleAfterTestRunEnd(Message message) - { - var isCancelled = this.dataSerializer.DeserializePayload(message); + private void HandleAfterTestRunEnd(Message message) + { + var isCancelled = _dataSerializer.DeserializePayload(message); - if (isCancelled) - { - this.cancellationTokenSource.Cancel(); - } + if (isCancelled) + { + _cancellationTokenSource.Cancel(); + } - try - { - this.testCaseEventMonitorTask?.Wait(this.cancellationTokenSource.Token); - this.dataCollectionTestCaseEventHandler.Close(); - } - catch (Exception ex) - { - EqtTrace.Error("DataCollectionRequestHandler.HandleAfterTestRunEnd : Error while processing event from testhost: {0}", ex.ToString()); - } + try + { + _testCaseEventMonitorTask?.Wait(_cancellationTokenSource.Token); + _dataCollectionTestCaseEventHandler.Close(); + } + catch (Exception ex) + { + EqtTrace.Error("DataCollectionRequestHandler.HandleAfterTestRunEnd : Error while processing event from testhost: {0}", ex.ToString()); + } - var attachmentsets = this.dataCollectionManager.SessionEnded(isCancelled); - var invokedDataCollectors = this.dataCollectionManager.GetInvokedDataCollectors(); + var attachmentsets = _dataCollectionManager.SessionEnded(isCancelled); + var invokedDataCollectors = _dataCollectionManager.GetInvokedDataCollectors(); - if (invokedDataCollectors != null && invokedDataCollectors.Any()) - { - // For the invoked collectors we report the same information as ProxyDataCollectionManager.cs line ~416 - var invokedDataCollectorsForMetrics = invokedDataCollectors.Select(x => new { x.Uri, x.FriendlyName, x.HasAttachmentProcessor }.ToString()); - this.requestData.MetricsCollection.Add(TelemetryDataConstants.InvokedDataCollectors, string.Join(",", invokedDataCollectorsForMetrics.ToArray())); - } + if (invokedDataCollectors != null && invokedDataCollectors.Any()) + { + // For the invoked collectors we report the same information as ProxyDataCollectionManager.cs line ~416 + var invokedDataCollectorsForMetrics = invokedDataCollectors.Select(x => new { x.Uri, x.FriendlyName, x.HasAttachmentProcessor }.ToString()); + _requestData.MetricsCollection.Add(TelemetryDataConstants.InvokedDataCollectors, string.Join(",", invokedDataCollectorsForMetrics.ToArray())); + } - var afterTestRunEndResult = new AfterTestRunEndResult(attachmentsets, invokedDataCollectors, this.requestData.MetricsCollection.Metrics); + var afterTestRunEndResult = new AfterTestRunEndResult(attachmentsets, invokedDataCollectors, _requestData.MetricsCollection.Metrics); - // Dispose all datacollectors before sending attachments to vstest.console process. - // As datacollector process exits itself on parent process(vstest.console) exits. - this.dataCollectionManager?.Dispose(); + // Dispose all datacollectors before sending attachments to vstest.console process. + // As datacollector process exits itself on parent process(vstest.console) exits. + _dataCollectionManager?.Dispose(); - this.communicationManager.SendMessage(MessageType.AfterTestRunEndResult, afterTestRunEndResult); - EqtTrace.Info("DataCollectionRequestHandler.ProcessRequests : Session End message received from server. Closing the connection."); + _communicationManager.SendMessage(MessageType.AfterTestRunEndResult, afterTestRunEndResult); + EqtTrace.Info("DataCollectionRequestHandler.ProcessRequests : Session End message received from server. Closing the connection."); - this.Close(); + Close(); - EqtTrace.Info("DataCollectionRequestHandler.ProcessRequests : DataCollection completed"); - } + EqtTrace.Info("DataCollectionRequestHandler.ProcessRequests : DataCollection completed"); + } - private void UpdateRequestData(bool isTelemetryOptedIn) + private void UpdateRequestData(bool isTelemetryOptedIn) + { + if (isTelemetryOptedIn != _requestData.IsTelemetryOptedIn) { - if (isTelemetryOptedIn != this.requestData.IsTelemetryOptedIn) - { - this.requestData.MetricsCollection = isTelemetryOptedIn ? (IMetricsCollection)new MetricsCollection() : new NoOpMetricsCollection(); - this.requestData.IsTelemetryOptedIn = isTelemetryOptedIn; - } + _requestData.MetricsCollection = isTelemetryOptedIn ? (IMetricsCollection)new MetricsCollection() : new NoOpMetricsCollection(); + _requestData.IsTelemetryOptedIn = isTelemetryOptedIn; } } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionRequestSender.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionRequestSender.cs index f51e3b7d5d..286a750c7e 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionRequestSender.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionRequestSender.cs @@ -1,209 +1,208 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection; + +using System.Collections.Generic; +using System.Globalization; +using System.Net; + +using Microsoft.VisualStudio.TestPlatform.Common.DataCollection; +using Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +using CommonResources = Common.Resources.Resources; + +/// +/// Utility class that facilitates the IPC communication. Acts as server. +/// +public sealed class DataCollectionRequestSender : IDataCollectionRequestSender { - using System.Collections.Generic; - using System.Globalization; - using System.Net; + private readonly ICommunicationManager _communicationManager; + private readonly IDataSerializer _dataSerializer; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + /// + /// Initializes a new instance of the class. + /// + public DataCollectionRequestSender() + : this(new SocketCommunicationManager(), JsonDataSerializer.Instance) + { + } - using CommonResources = Microsoft.VisualStudio.TestPlatform.Common.Resources.Resources; + /// + /// Initializes a new instance of the class. + /// + /// + /// The communication manager. + /// + /// + /// The data serializer. + /// + internal DataCollectionRequestSender(ICommunicationManager communicationManager, IDataSerializer dataSerializer) + { + _communicationManager = communicationManager; + _dataSerializer = dataSerializer; + } /// - /// Utility class that facilitates the IPC communication. Acts as server. + /// Creates an endpoint and listens for client connection asynchronously /// - public sealed class DataCollectionRequestSender : IDataCollectionRequestSender + /// Port number + public int InitializeCommunication() { - private ICommunicationManager communicationManager; - private IDataSerializer dataSerializer; - - /// - /// Initializes a new instance of the class. - /// - public DataCollectionRequestSender() - : this(new SocketCommunicationManager(), JsonDataSerializer.Instance) + if (EqtTrace.IsVerboseEnabled) { + EqtTrace.Verbose("DataCollectionRequestSender.InitializeCommunication : Initialize communication. "); } - /// - /// Initializes a new instance of the class. - /// - /// - /// The communication manager. - /// - /// - /// The data serializer. - /// - internal DataCollectionRequestSender(ICommunicationManager communicationManager, IDataSerializer dataSerializer) - { - this.communicationManager = communicationManager; - this.dataSerializer = dataSerializer; - } + var endpoint = _communicationManager.HostServer(new IPEndPoint(IPAddress.Loopback, 0)); + _communicationManager.AcceptClientAsync(); + return endpoint.Port; + } - /// - /// Creates an endpoint and listens for client connection asynchronously - /// - /// Port number - public int InitializeCommunication() + /// + /// Waits for Request Handler to be connected + /// + /// Time to wait for connection + /// True, if Handler is connected + public bool WaitForRequestHandlerConnection(int clientConnectionTimeout) + { + if (EqtTrace.IsVerboseEnabled) { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("DataCollectionRequestSender.InitializeCommunication : Initialize communication. "); - } - - var endpoint = this.communicationManager.HostServer(new IPEndPoint(IPAddress.Loopback, 0)); - this.communicationManager.AcceptClientAsync(); - return endpoint.Port; + EqtTrace.Verbose("DataCollectionRequestSender.WaitForRequestHandlerConnection : Waiting for connection with timeout: {0}", clientConnectionTimeout); } - /// - /// Waits for Request Handler to be connected - /// - /// Time to wait for connection - /// True, if Handler is connected - public bool WaitForRequestHandlerConnection(int clientConnectionTimeout) - { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("DataCollectionRequestSender.WaitForRequestHandlerConnection : Waiting for connection with timeout: {0}", clientConnectionTimeout); - } + return _communicationManager.WaitForClientConnection(clientConnectionTimeout); + } - return this.communicationManager.WaitForClientConnection(clientConnectionTimeout); - } + /// + /// The dispose. + /// + public void Dispose() + { + _communicationManager?.StopServer(); + } - /// - /// The dispose. - /// - public void Dispose() + /// + /// Closes the connection + /// + public void Close() + { + if (EqtTrace.IsInfoEnabled) { - this.communicationManager?.StopServer(); + EqtTrace.Info("Closing the connection"); } - /// - /// Closes the connection - /// - public void Close() - { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("Closing the connection"); - } + _communicationManager?.StopServer(); + } - this.communicationManager?.StopServer(); - } + /// + public void SendTestHostLaunched(TestHostLaunchedPayload testHostLaunchedPayload) + { + _communicationManager.SendMessage(MessageType.TestHostLaunched, testHostLaunchedPayload); + } - /// - public void SendTestHostLaunched(TestHostLaunchedPayload testHostLaunchedPayload) + /// + public BeforeTestRunStartResult SendBeforeTestRunStartAndGetResult(string settingsXml, IEnumerable sources, bool isTelemetryOptedIn, ITestMessageEventHandler runEventsHandler) + { + var isDataCollectionStarted = false; + BeforeTestRunStartResult result = null; + + if (EqtTrace.IsVerboseEnabled) { - this.communicationManager.SendMessage(MessageType.TestHostLaunched, testHostLaunchedPayload); + EqtTrace.Verbose("DataCollectionRequestSender.SendBeforeTestRunStartAndGetResult : Send BeforeTestRunStart message with settingsXml {0} and sources {1}: ", settingsXml, sources.ToString()); } - /// - public BeforeTestRunStartResult SendBeforeTestRunStartAndGetResult(string settingsXml, IEnumerable sources, bool isTelemetryOptedIn, ITestMessageEventHandler runEventsHandler) + var payload = new BeforeTestRunStartPayload + { + SettingsXml = settingsXml, + Sources = sources, + IsTelemetryOptedIn = isTelemetryOptedIn + }; + + _communicationManager.SendMessage(MessageType.BeforeTestRunStart, payload); + + while (!isDataCollectionStarted) { - var isDataCollectionStarted = false; - BeforeTestRunStartResult result = null; + var message = _communicationManager.ReceiveMessage(); if (EqtTrace.IsVerboseEnabled) { - EqtTrace.Verbose("DataCollectionRequestSender.SendBeforeTestRunStartAndGetResult : Send BeforeTestRunStart message with settingsXml {0} and sources {1}: ", settingsXml, sources.ToString()); + EqtTrace.Verbose("DataCollectionRequestSender.SendBeforeTestRunStartAndGetResult : Received message: {0}", message); } - var payload = new BeforeTestRunStartPayload + if (message.MessageType == MessageType.DataCollectionMessage) { - SettingsXml = settingsXml, - Sources = sources, - IsTelemetryOptedIn = isTelemetryOptedIn - }; - - this.communicationManager.SendMessage(MessageType.BeforeTestRunStart, payload); - - while (!isDataCollectionStarted) + var dataCollectionMessageEventArgs = _dataSerializer.DeserializePayload(message); + LogDataCollectorMessage(dataCollectionMessageEventArgs, runEventsHandler); + } + else if (message.MessageType == MessageType.BeforeTestRunStartResult) { - var message = this.communicationManager.ReceiveMessage(); - - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("DataCollectionRequestSender.SendBeforeTestRunStartAndGetResult : Received message: {0}", message); - } - - if (message.MessageType == MessageType.DataCollectionMessage) - { - var dataCollectionMessageEventArgs = this.dataSerializer.DeserializePayload(message); - this.LogDataCollectorMessage(dataCollectionMessageEventArgs, runEventsHandler); - } - else if (message.MessageType == MessageType.BeforeTestRunStartResult) - { - isDataCollectionStarted = true; - result = this.dataSerializer.DeserializePayload(message); - } + isDataCollectionStarted = true; + result = _dataSerializer.DeserializePayload(message); } - - return result; } - /// - public AfterTestRunEndResult SendAfterTestRunEndAndGetResult(ITestMessageEventHandler runEventsHandler, bool isCancelled) + return result; + } + + /// + public AfterTestRunEndResult SendAfterTestRunEndAndGetResult(ITestMessageEventHandler runEventsHandler, bool isCancelled) + { + var isDataCollectionComplete = false; + AfterTestRunEndResult result = null; + + if (EqtTrace.IsVerboseEnabled) { - var isDataCollectionComplete = false; - AfterTestRunEndResult result = null; + EqtTrace.Verbose("DataCollectionRequestSender.SendAfterTestRunStartAndGetResult : Send AfterTestRunEnd message with isCancelled: {0}", isCancelled); + } - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("DataCollectionRequestSender.SendAfterTestRunStartAndGetResult : Send AfterTestRunEnd message with isCancelled: {0}", isCancelled); - } + _communicationManager.SendMessage(MessageType.AfterTestRunEnd, isCancelled); - this.communicationManager.SendMessage(MessageType.AfterTestRunEnd, isCancelled); + // Cycle through the messages that the datacollector sends. + // Currently each of the operations are not separate tasks since they should not each take much time. This is just a notification. + while (!isDataCollectionComplete && !isCancelled) + { + var message = _communicationManager.ReceiveMessage(); - // Cycle through the messages that the datacollector sends. - // Currently each of the operations are not separate tasks since they should not each take much time. This is just a notification. - while (!isDataCollectionComplete && !isCancelled) + if (EqtTrace.IsVerboseEnabled) { - var message = this.communicationManager.ReceiveMessage(); - - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("DataCollectionRequestSender.SendAfterTestRunStartAndGetResult : Received message: {0}", message); - } - - if (message.MessageType == MessageType.DataCollectionMessage) - { - var dataCollectionMessageEventArgs = this.dataSerializer.DeserializePayload(message); - this.LogDataCollectorMessage(dataCollectionMessageEventArgs, runEventsHandler); - } - else if (message.MessageType == MessageType.AfterTestRunEndResult) - { - result = this.dataSerializer.DeserializePayload(message); - isDataCollectionComplete = true; - } + EqtTrace.Verbose("DataCollectionRequestSender.SendAfterTestRunStartAndGetResult : Received message: {0}", message); } - return result; - } - - private void LogDataCollectorMessage(DataCollectionMessageEventArgs dataCollectionMessageEventArgs, ITestMessageEventHandler requestHandler) - { - string logMessage; - if (string.IsNullOrWhiteSpace(dataCollectionMessageEventArgs.FriendlyName)) + if (message.MessageType == MessageType.DataCollectionMessage) { - // Message from data collection framework. - logMessage = string.Format(CultureInfo.CurrentCulture, CommonResources.DataCollectionMessageFormat, dataCollectionMessageEventArgs.Message); + var dataCollectionMessageEventArgs = _dataSerializer.DeserializePayload(message); + LogDataCollectorMessage(dataCollectionMessageEventArgs, runEventsHandler); } - else + else if (message.MessageType == MessageType.AfterTestRunEndResult) { - // Message from individual data collector. - logMessage = string.Format(CultureInfo.CurrentCulture, CommonResources.DataCollectorMessageFormat, dataCollectionMessageEventArgs.FriendlyName, dataCollectionMessageEventArgs.Message); + result = _dataSerializer.DeserializePayload(message); + isDataCollectionComplete = true; } + } + + return result; + } - requestHandler.HandleLogMessage(dataCollectionMessageEventArgs.Level, logMessage); + private void LogDataCollectorMessage(DataCollectionMessageEventArgs dataCollectionMessageEventArgs, ITestMessageEventHandler requestHandler) + { + string logMessage; + if (string.IsNullOrWhiteSpace(dataCollectionMessageEventArgs.FriendlyName)) + { + // Message from data collection framework. + logMessage = string.Format(CultureInfo.CurrentCulture, CommonResources.DataCollectionMessageFormat, dataCollectionMessageEventArgs.Message); + } + else + { + // Message from individual data collector. + logMessage = string.Format(CultureInfo.CurrentCulture, CommonResources.DataCollectorMessageFormat, dataCollectionMessageEventArgs.FriendlyName, dataCollectionMessageEventArgs.Message); } + + requestHandler.HandleLogMessage(dataCollectionMessageEventArgs.Level, logMessage); } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionTestCaseEventHandler.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionTestCaseEventHandler.cs index 46438e5824..ab60d76a0c 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionTestCaseEventHandler.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionTestCaseEventHandler.cs @@ -1,133 +1,132 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection; + +using System.Net; + +using Common.DataCollector; +using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +/// +/// The test case data collection request handler. +/// +internal class DataCollectionTestCaseEventHandler : IDataCollectionTestCaseEventHandler { - using System.Net; + private readonly ICommunicationManager _communicationManager; + private readonly IDataCollectionManager _dataCollectionManager; + private readonly IDataSerializer _dataSerializer; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + /// + /// Initializes a new instance of the class. + /// + internal DataCollectionTestCaseEventHandler() + : this(new SocketCommunicationManager(), DataCollectionManager.Instance, JsonDataSerializer.Instance) + { + } /// - /// The test case data collection request handler. + /// Initializes a new instance of the class. /// - internal class DataCollectionTestCaseEventHandler : IDataCollectionTestCaseEventHandler + /// Communication manager implementation. + /// Data collection manager implementation. + /// Serializer for serialization and deserialization of the messages. + internal DataCollectionTestCaseEventHandler(ICommunicationManager communicationManager, IDataCollectionManager dataCollectionManager, IDataSerializer dataSerializer) { - private ICommunicationManager communicationManager; - private IDataCollectionManager dataCollectionManager; - private IDataSerializer dataSerializer; - - /// - /// Initializes a new instance of the class. - /// - internal DataCollectionTestCaseEventHandler() - : this(new SocketCommunicationManager(), DataCollectionManager.Instance, JsonDataSerializer.Instance) - { - } + _communicationManager = communicationManager; + _dataCollectionManager = dataCollectionManager; + _dataSerializer = dataSerializer; + } - /// - /// Initializes a new instance of the class. - /// - /// Communication manager implementation. - /// Data collection manager implementation. - /// Serializer for serialization and deserialization of the messages. - internal DataCollectionTestCaseEventHandler(ICommunicationManager communicationManager, IDataCollectionManager dataCollectionManager, IDataSerializer dataSerializer) - { - this.communicationManager = communicationManager; - this.dataCollectionManager = dataCollectionManager; - this.dataSerializer = dataSerializer; - } + /// + public int InitializeCommunication() + { + var endpoint = _communicationManager.HostServer(new IPEndPoint(IPAddress.Loopback, 0)); + _communicationManager.AcceptClientAsync(); + return endpoint.Port; + } - /// - public int InitializeCommunication() - { - var endpoint = this.communicationManager.HostServer(new IPEndPoint(IPAddress.Loopback, 0)); - this.communicationManager.AcceptClientAsync(); - return endpoint.Port; - } + /// + public bool WaitForRequestHandlerConnection(int connectionTimeout) + { + return _communicationManager.WaitForClientConnection(connectionTimeout); + } - /// - public bool WaitForRequestHandlerConnection(int connectionTimeout) - { - return this.communicationManager.WaitForClientConnection(connectionTimeout); - } + /// + public void Close() + { + _communicationManager?.StopServer(); + } - /// - public void Close() - { - this.communicationManager?.StopServer(); - } + /// + public void ProcessRequests() + { + var isSessionEnd = false; - /// - public void ProcessRequests() + do { - var isSessionEnd = false; - - do + var message = _communicationManager.ReceiveMessage(); + switch (message.MessageType) { - var message = this.communicationManager.ReceiveMessage(); - switch (message.MessageType) - { - case MessageType.DataCollectionTestStart: - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DataCollectionTestCaseEventHandler: Test case starting."); - } - - var testCaseStartEventArgs = this.dataSerializer.DeserializePayload(message); - this.dataCollectionManager.TestCaseStarted(testCaseStartEventArgs); - this.communicationManager.SendMessage(MessageType.DataCollectionTestStartAck); - - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DataCollectionTestCaseEventHandler: Test case '{0} - {1}' started.", testCaseStartEventArgs.TestCaseName, testCaseStartEventArgs.TestCaseId); - } - - break; - - case MessageType.DataCollectionTestEnd: - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DataCollectionTestCaseEventHandler : Test case completing."); - } - - var testCaseEndEventArgs = this.dataSerializer.DeserializePayload(message); - var attachmentSets = this.dataCollectionManager.TestCaseEnded(testCaseEndEventArgs); - this.communicationManager.SendMessage(MessageType.DataCollectionTestEndResult, attachmentSets); - - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DataCollectionTestCaseEventHandler: Test case '{0} - {1}' completed", testCaseEndEventArgs.TestCaseName, testCaseEndEventArgs.TestCaseId); - } - - break; - - case MessageType.SessionEnd: - isSessionEnd = true; - - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DataCollectionTestCaseEventHandler: Test session ended"); - } - - this.Close(); - - break; - - default: - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DataCollectionTestCaseEventHandler: Invalid Message type '{0}'", message.MessageType); - } - - break; - } + case MessageType.DataCollectionTestStart: + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("DataCollectionTestCaseEventHandler: Test case starting."); + } + + var testCaseStartEventArgs = _dataSerializer.DeserializePayload(message); + _dataCollectionManager.TestCaseStarted(testCaseStartEventArgs); + _communicationManager.SendMessage(MessageType.DataCollectionTestStartAck); + + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("DataCollectionTestCaseEventHandler: Test case '{0} - {1}' started.", testCaseStartEventArgs.TestCaseName, testCaseStartEventArgs.TestCaseId); + } + + break; + + case MessageType.DataCollectionTestEnd: + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("DataCollectionTestCaseEventHandler : Test case completing."); + } + + var testCaseEndEventArgs = _dataSerializer.DeserializePayload(message); + var attachmentSets = _dataCollectionManager.TestCaseEnded(testCaseEndEventArgs); + _communicationManager.SendMessage(MessageType.DataCollectionTestEndResult, attachmentSets); + + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("DataCollectionTestCaseEventHandler: Test case '{0} - {1}' completed", testCaseEndEventArgs.TestCaseName, testCaseEndEventArgs.TestCaseId); + } + + break; + + case MessageType.SessionEnd: + isSessionEnd = true; + + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("DataCollectionTestCaseEventHandler: Test session ended"); + } + + Close(); + + break; + + default: + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("DataCollectionTestCaseEventHandler: Invalid Message type '{0}'", message.MessageType); + } + + break; } - while (!isSessionEnd); } + while (!isSessionEnd); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionTestCaseEventSender.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionTestCaseEventSender.cs index 6cd01bd90e..93d56f8796 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionTestCaseEventSender.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionTestCaseEventSender.cs @@ -1,125 +1,124 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities -{ - using System.Collections.ObjectModel; - using System.Net; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using System.Collections.ObjectModel; +using System.Net; - public class DataCollectionTestCaseEventSender : IDataCollectionTestCaseEventSender - { - private static readonly object SyncObject = new object(); +using Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - private readonly ICommunicationManager communicationManager; +public class DataCollectionTestCaseEventSender : IDataCollectionTestCaseEventSender +{ + private static readonly object SyncObject = new(); - private IDataSerializer dataSerializer; + private readonly ICommunicationManager _communicationManager; - /// - /// Initializes a new instance of the class. - /// - protected DataCollectionTestCaseEventSender() - : this(new SocketCommunicationManager(), JsonDataSerializer.Instance) - { - } + private readonly IDataSerializer _dataSerializer; - /// - /// Initializes a new instance of the class. - /// - /// Communication manager. - /// Serializer for serialization and deserialization of the messages. - protected DataCollectionTestCaseEventSender(ICommunicationManager communicationManager, IDataSerializer dataSerializer) - { - this.communicationManager = communicationManager; - this.dataSerializer = dataSerializer; - } + /// + /// Initializes a new instance of the class. + /// + protected DataCollectionTestCaseEventSender() + : this(new SocketCommunicationManager(), JsonDataSerializer.Instance) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Communication manager. + /// Serializer for serialization and deserialization of the messages. + protected DataCollectionTestCaseEventSender(ICommunicationManager communicationManager, IDataSerializer dataSerializer) + { + _communicationManager = communicationManager; + _dataSerializer = dataSerializer; + } - /// - /// Gets the singleton instance of DataCollectionTestCaseEventSender. - /// - // TODO : Re-factor to pass the instance as singleton. - public static DataCollectionTestCaseEventSender Instance { get; private set; } - - /// - /// Gets singleton instance of DataCollectionRequestHandler. - /// - /// A singleton instance of - public static DataCollectionTestCaseEventSender Create() + /// + /// Gets the singleton instance of DataCollectionTestCaseEventSender. + /// + // TODO : Re-factor to pass the instance as singleton. + public static DataCollectionTestCaseEventSender Instance { get; private set; } + + /// + /// Gets singleton instance of DataCollectionRequestHandler. + /// + /// A singleton instance of + public static DataCollectionTestCaseEventSender Create() + { + if (Instance == null) { - if (Instance == null) + lock (SyncObject) { - lock (SyncObject) + if (Instance == null) { - if (Instance == null) - { - Instance = new DataCollectionTestCaseEventSender(); - } + Instance = new DataCollectionTestCaseEventSender(); } } - - return Instance; } - /// - public void InitializeCommunication(int port) - { - this.communicationManager.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)); - } + return Instance; + } - /// - public bool WaitForRequestSenderConnection(int connectionTimeout) - { - return this.communicationManager.WaitForServerConnection(connectionTimeout); - } + /// + public void InitializeCommunication(int port) + { + _communicationManager.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)); + } - /// - public void Close() - { - this.communicationManager?.StopClient(); - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("Closing the connection !"); - } - } + /// + public bool WaitForRequestSenderConnection(int connectionTimeout) + { + return _communicationManager.WaitForServerConnection(connectionTimeout); + } - /// - public void SendTestCaseStart(TestCaseStartEventArgs e) + /// + public void Close() + { + _communicationManager?.StopClient(); + if (EqtTrace.IsInfoEnabled) { - this.communicationManager.SendMessage(MessageType.DataCollectionTestStart, e); - - var message = this.communicationManager.ReceiveMessage(); - if (message != null && message.MessageType != MessageType.DataCollectionTestStartAck) - { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("DataCollectionTestCaseEventSender.SendTestCaseStart : MessageType.DataCollectionTestStartAck not received."); - } - } + EqtTrace.Info("Closing the connection !"); } + } - /// - public Collection SendTestCaseEnd(TestCaseEndEventArgs e) - { - var attachmentSets = new Collection(); - this.communicationManager.SendMessage(MessageType.DataCollectionTestEnd, e); + /// + public void SendTestCaseStart(TestCaseStartEventArgs e) + { + _communicationManager.SendMessage(MessageType.DataCollectionTestStart, e); - var message = this.communicationManager.ReceiveMessage(); - if (message != null && message.MessageType == MessageType.DataCollectionTestEndResult) + var message = _communicationManager.ReceiveMessage(); + if (message != null && message.MessageType != MessageType.DataCollectionTestStartAck) + { + if (EqtTrace.IsErrorEnabled) { - attachmentSets = this.dataSerializer.DeserializePayload>(message); + EqtTrace.Error("DataCollectionTestCaseEventSender.SendTestCaseStart : MessageType.DataCollectionTestStartAck not received."); } - - return attachmentSets; } + } - /// - public void SendTestSessionEnd(SessionEndEventArgs e) + /// + public Collection SendTestCaseEnd(TestCaseEndEventArgs e) + { + var attachmentSets = new Collection(); + _communicationManager.SendMessage(MessageType.DataCollectionTestEnd, e); + + var message = _communicationManager.ReceiveMessage(); + if (message != null && message.MessageType == MessageType.DataCollectionTestEndResult) { - this.communicationManager.SendMessage(MessageType.SessionEnd, e); + attachmentSets = _dataSerializer.DeserializePayload>(message); } + + return attachmentSets; + } + + /// + public void SendTestSessionEnd(SessionEndEventArgs e) + { + _communicationManager.SendMessage(MessageType.SessionEnd, e); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestDiscoveryEventHandler.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestDiscoveryEventHandler.cs index bcc62695b2..a8f7783e24 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestDiscoveryEventHandler.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestDiscoveryEventHandler.cs @@ -1,88 +1,90 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; + +using System.Collections.Generic; + +using Interfaces; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +using TestPlatform.ObjectModel.Client; + +/// +/// The test discovery event handler. +/// +public class TestDiscoveryEventHandler : ITestDiscoveryEventsHandler2 { - using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using TestPlatform.ObjectModel.Client; + private readonly ITestRequestHandler _requestHandler; /// - /// The test discovery event handler. + /// Initializes a new instance of the class. /// - public class TestDiscoveryEventHandler : ITestDiscoveryEventsHandler2 + /// The Request Handler. + public TestDiscoveryEventHandler(ITestRequestHandler requestHandler) { - private ITestRequestHandler requestHandler; + _requestHandler = requestHandler; + } - /// - /// Initializes a new instance of the class. - /// - /// The Request Handler. - public TestDiscoveryEventHandler(ITestRequestHandler requestHandler) - { - this.requestHandler = requestHandler; - } + /// + /// Handles discovered tests + /// + /// List of test cases + public void HandleDiscoveredTests(IEnumerable discoveredTestCases) + { + EqtTrace.Info("Test Cases found "); + _requestHandler.SendTestCases(discoveredTestCases); + } - /// - /// Handles discovered tests - /// - /// List of test cases - public void HandleDiscoveredTests(IEnumerable discoveredTestCases) + /// + /// Handle discovery complete. + /// + /// Discovery Complete Events Args. + /// The last chunk. + public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk) + { + if (EqtTrace.IsInfoEnabled) { - EqtTrace.Info("Test Cases found "); - this.requestHandler.SendTestCases(discoveredTestCases); + EqtTrace.Info(discoveryCompleteEventArgs.IsAborted ? "Discover Aborted." : "Discover Finished."); } - /// - /// Handle discovery complete. - /// - /// Discovery Complete Events Args. - /// The last chunk. - public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk) + _requestHandler.DiscoveryComplete(discoveryCompleteEventArgs, lastChunk); + } + + /// + /// The handle discovery message. + /// + /// Logging level. + /// Logging message. + public void HandleLogMessage(TestMessageLevel level, string message) + { + switch ((TestMessageLevel)level) { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info(discoveryCompleteEventArgs.IsAborted ? "Discover Aborted." : "Discover Finished."); - } + case TestMessageLevel.Informational: + EqtTrace.Info(message); + break; - this.requestHandler.DiscoveryComplete(discoveryCompleteEventArgs, lastChunk); - } + case TestMessageLevel.Warning: + EqtTrace.Warning(message); + break; - /// - /// The handle discovery message. - /// - /// Logging level. - /// Logging message. - public void HandleLogMessage(TestMessageLevel level, string message) - { - switch ((TestMessageLevel)level) - { - case TestMessageLevel.Informational: - EqtTrace.Info(message); - break; - - case TestMessageLevel.Warning: - EqtTrace.Warning(message); - break; - - case TestMessageLevel.Error: - EqtTrace.Error(message); - break; - - default: - EqtTrace.Info(message); - break; - } - - this.requestHandler.SendLog(level, message); - } + case TestMessageLevel.Error: + EqtTrace.Error(message); + break; - public void HandleRawMessage(string rawMessage) - { - // No-Op - // TestHost at this point has no functionality where it requires rawmessage + default: + EqtTrace.Info(message); + break; } + + _requestHandler.SendLog(level, message); + } + + public void HandleRawMessage(string rawMessage) + { + // No-Op + // TestHost at this point has no functionality where it requires rawmessage } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestInitializeEventsHandler.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestInitializeEventsHandler.cs index 5bbde0f4a1..3bd18c8f68 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestInitializeEventsHandler.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestInitializeEventsHandler.cs @@ -1,62 +1,62 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.EventHandlers +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.EventHandlers; + +using Interfaces; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +/// +/// The test run events handler. +/// +public class TestInitializeEventsHandler : ITestMessageEventHandler { - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + private readonly ITestRequestHandler _requestHandler; /// - /// The test run events handler. + /// Initializes a new instance of the class. /// - public class TestInitializeEventsHandler : ITestMessageEventHandler + /// test request handler + public TestInitializeEventsHandler(ITestRequestHandler requestHandler) { - private ITestRequestHandler requestHandler; + _requestHandler = requestHandler; + } - /// - /// Initializes a new instance of the class. - /// - /// test request handler - public TestInitializeEventsHandler(ITestRequestHandler requestHandler) + /// + /// Handles a test run message. + /// + /// The level. + /// The message. + public void HandleLogMessage(TestMessageLevel level, string message) + { + switch ((TestMessageLevel)level) { - this.requestHandler = requestHandler; - } + case TestMessageLevel.Informational: + EqtTrace.Info(message); + break; - /// - /// Handles a test run message. - /// - /// The level. - /// The message. - public void HandleLogMessage(TestMessageLevel level, string message) - { - switch ((TestMessageLevel)level) - { - case TestMessageLevel.Informational: - EqtTrace.Info(message); - break; - - case TestMessageLevel.Warning: - EqtTrace.Warning(message); - break; - - case TestMessageLevel.Error: - EqtTrace.Error(message); - break; - - default: - EqtTrace.Info(message); - break; - } - - this.requestHandler.SendLog(level, message); - } + case TestMessageLevel.Warning: + EqtTrace.Warning(message); + break; - public void HandleRawMessage(string rawMessage) - { - // No-Op - // TestHost at this point has no functionality where it requires rawmessage + case TestMessageLevel.Error: + EqtTrace.Error(message); + break; + + default: + EqtTrace.Info(message); + break; } + + _requestHandler.SendLog(level, message); + } + + public void HandleRawMessage(string rawMessage) + { + // No-Op + // TestHost at this point has no functionality where it requires rawmessage } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestRunEventsHandler.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestRunEventsHandler.cs index 3dc09a5140..e26c9729c0 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestRunEventsHandler.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/EventHandlers/TestRunEventsHandler.cs @@ -1,106 +1,106 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.EventHandlers +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.EventHandlers; + +using System.Collections.Generic; + +using Interfaces; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +/// +/// The test run events handler. +/// +public class TestRunEventsHandler : ITestRunEventsHandler2 { - using System.Collections.Generic; + private readonly ITestRequestHandler _requestHandler; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + /// + /// Initializes a new instance of the class. + /// + /// test request handler + public TestRunEventsHandler(ITestRequestHandler requestHandler) + { + _requestHandler = requestHandler; + } /// - /// The test run events handler. + /// Handle test run stats change. /// - public class TestRunEventsHandler : ITestRunEventsHandler2 + /// The test run changed args. + public void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChangedArgs) { - private ITestRequestHandler requestHandler; + EqtTrace.Info("Sending test run statistics"); + _requestHandler.SendTestRunStatistics(testRunChangedArgs); + } - /// - /// Initializes a new instance of the class. - /// - /// test request handler - public TestRunEventsHandler(ITestRequestHandler requestHandler) - { - this.requestHandler = requestHandler; - } + /// + /// Handle test run complete. + /// + /// The test run complete args. + /// The last chunk args. + /// The run context attachments. + /// The executor uris. + public void HandleTestRunComplete(TestRunCompleteEventArgs testRunCompleteArgs, TestRunChangedEventArgs lastChunkArgs, ICollection runContextAttachments, ICollection executorUris) + { + EqtTrace.Info("Sending test run complete"); + _requestHandler.SendExecutionComplete(testRunCompleteArgs, lastChunkArgs, runContextAttachments, executorUris); + } - /// - /// Handle test run stats change. - /// - /// The test run changed args. - public void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChangedArgs) + /// + /// Handles a test run message. + /// + /// The level. + /// The message. + public void HandleLogMessage(TestMessageLevel level, string message) + { + switch ((TestMessageLevel)level) { - EqtTrace.Info("Sending test run statistics"); - this.requestHandler.SendTestRunStatistics(testRunChangedArgs); - } + case TestMessageLevel.Informational: + EqtTrace.Info(message); + break; - /// - /// Handle test run complete. - /// - /// The test run complete args. - /// The last chunk args. - /// The run context attachments. - /// The executor uris. - public void HandleTestRunComplete(TestRunCompleteEventArgs testRunCompleteArgs, TestRunChangedEventArgs lastChunkArgs, ICollection runContextAttachments, ICollection executorUris) - { - EqtTrace.Info("Sending test run complete"); - this.requestHandler.SendExecutionComplete(testRunCompleteArgs, lastChunkArgs, runContextAttachments, executorUris); - } + case TestMessageLevel.Warning: + EqtTrace.Warning(message); + break; - /// - /// Handles a test run message. - /// - /// The level. - /// The message. - public void HandleLogMessage(TestMessageLevel level, string message) - { - switch ((TestMessageLevel)level) - { - case TestMessageLevel.Informational: - EqtTrace.Info(message); - break; - - case TestMessageLevel.Warning: - EqtTrace.Warning(message); - break; - - case TestMessageLevel.Error: - EqtTrace.Error(message); - break; - - default: - EqtTrace.Info(message); - break; - } - - this.requestHandler.SendLog(level, message); - } + case TestMessageLevel.Error: + EqtTrace.Error(message); + break; - public void HandleRawMessage(string rawMessage) - { - // No-Op - // TestHost at this point has no functionality where it requires rawmessage + default: + EqtTrace.Info(message); + break; } - /// - /// Launches a process with a given process info under debugger - /// Adapter get to call into this to launch any additional processes under debugger - /// - /// Process start info - /// ProcessId of the launched process - public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) - { - EqtTrace.Info("Sending LaunchProcessWithDebuggerAttached on additional test process: {0}", testProcessStartInfo?.FileName); - return this.requestHandler.LaunchProcessWithDebuggerAttached(testProcessStartInfo); - } + _requestHandler.SendLog(level, message); + } - /// - public bool AttachDebuggerToProcess(int pid) - { - EqtTrace.Info("Sending AttachDebuggerToProcess on additional test process with pid: {0}", pid); - return this.requestHandler.AttachDebuggerToProcess(pid); - } + public void HandleRawMessage(string rawMessage) + { + // No-Op + // TestHost at this point has no functionality where it requires rawmessage + } + + /// + /// Launches a process with a given process info under debugger + /// Adapter get to call into this to launch any additional processes under debugger + /// + /// Process start info + /// ProcessId of the launched process + public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) + { + EqtTrace.Info("Sending LaunchProcessWithDebuggerAttached on additional test process: {0}", testProcessStartInfo?.FileName); + return _requestHandler.LaunchProcessWithDebuggerAttached(testProcessStartInfo); + } + + /// + public bool AttachDebuggerToProcess(int pid) + { + EqtTrace.Info("Sending AttachDebuggerToProcess on additional test process with pid: {0}", pid); + return _requestHandler.AttachDebuggerToProcess(pid); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/CommunicationException.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/CommunicationException.cs index 4dcfebff5d..649bccbcc4 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/CommunicationException.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/CommunicationException.cs @@ -1,41 +1,40 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; + +using System; +/// +/// Exception thrown when communication on a channel fails. +/// +public class CommunicationException : Exception +{ /// - /// Exception thrown when communication on a channel fails. + /// Initializes a new instance of the class. /// - public class CommunicationException : Exception + public CommunicationException() { - /// - /// Initializes a new instance of the class. - /// - public CommunicationException() - { - } + } - /// - /// Initializes a new instance of the class with provided - /// message. - /// - /// Message describing the error. - public CommunicationException(string message) - : base(message) - { - } + /// + /// Initializes a new instance of the class with provided + /// message. + /// + /// Message describing the error. + public CommunicationException(string message) + : base(message) + { + } - /// - /// Initializes a new instance of the class with provided - /// message and inner exception. - /// - /// Message describing the error. - /// Inner exception. - public CommunicationException(string message, Exception inner) - : base(message, inner) - { - } + /// + /// Initializes a new instance of the class with provided + /// message and inner exception. + /// + /// Message describing the error. + /// Inner exception. + public CommunicationException(string message, Exception inner) + : base(message, inner) + { } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/ConnectedEventArgs.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/ConnectedEventArgs.cs index ae248cca92..d01c785c53 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/ConnectedEventArgs.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/ConnectedEventArgs.cs @@ -1,51 +1,50 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; + +using System; + +/// +/// Provides properties for the connected communication channel. +/// +public class ConnectedEventArgs : EventArgs { - using System; + /// + /// Initializes a new instance of the class. + /// + public ConnectedEventArgs() + { + } /// - /// Provides properties for the connected communication channel. + /// Initializes a new instance of the class. /// - public class ConnectedEventArgs : EventArgs + /// Communication channel for this connection. + public ConnectedEventArgs(ICommunicationChannel channel) + { + Channel = channel; + Connected = true; + } + + public ConnectedEventArgs(Exception faultException) { - /// - /// Initializes a new instance of the class. - /// - public ConnectedEventArgs() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Communication channel for this connection. - public ConnectedEventArgs(ICommunicationChannel channel) - { - this.Channel = channel; - this.Connected = true; - } - - public ConnectedEventArgs(Exception faultException) - { - this.Connected = false; - this.Fault = faultException; - } - - /// - /// Gets the communication channel based on this connection. - /// - public ICommunicationChannel Channel { get; private set; } - - /// - /// Gets a value indicating whether channel is connected or not, true if it's connected. - /// - public bool Connected { get; private set; } - - /// - /// Gets the exception if it's not connected. - /// - public Exception Fault { get; private set; } + Connected = false; + Fault = faultException; } -} + + /// + /// Gets the communication channel based on this connection. + /// + public ICommunicationChannel Channel { get; private set; } + + /// + /// Gets a value indicating whether channel is connected or not, true if it's connected. + /// + public bool Connected { get; private set; } + + /// + /// Gets the exception if it's not connected. + /// + public Exception Fault { get; private set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/DisconnectedEventArgs.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/DisconnectedEventArgs.cs index d79bc5ea91..fe99dc4bbf 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/DisconnectedEventArgs.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/DisconnectedEventArgs.cs @@ -1,18 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; + +using System; +/// +/// Provides information on disconnection of a communication channel. +/// +public class DisconnectedEventArgs : EventArgs +{ /// - /// Provides information on disconnection of a communication channel. + /// Gets or sets if there's an error on disconnection. /// - public class DisconnectedEventArgs : EventArgs - { - /// - /// Gets or sets if there's an error on disconnection. - /// - public Exception Error { get; set; } - } -} + public Exception Error { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/ICommunicationChannel.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/ICommunicationChannel.cs index f518e9fd45..9cc5619d6d 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/ICommunicationChannel.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/ICommunicationChannel.cs @@ -1,29 +1,28 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces -{ - using System; - using System.Threading.Tasks; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; + +using System; +using System.Threading.Tasks; - public interface ICommunicationChannel : IDisposable - { - /// - /// Event raised when data is received on the communication channel. - /// - event EventHandler MessageReceived; +public interface ICommunicationChannel : IDisposable +{ + /// + /// Event raised when data is received on the communication channel. + /// + event EventHandler MessageReceived; - /// - /// Frames and sends the provided data over communication channel. - /// - /// Data to send over the channel. - /// A implying async nature of the function. - Task Send(string data); + /// + /// Frames and sends the provided data over communication channel. + /// + /// Data to send over the channel. + /// A implying async nature of the function. + Task Send(string data); - /// - /// Notification from server/client that data is available. - /// - /// A implying async nature of the function. - Task NotifyDataAvailable(); - } -} + /// + /// Notification from server/client that data is available. + /// + /// A implying async nature of the function. + Task NotifyDataAvailable(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/MessageReceivedEventArgs.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/MessageReceivedEventArgs.cs index f7c17f5a3b..9553586405 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/MessageReceivedEventArgs.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/MessageReceivedEventArgs.cs @@ -1,18 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; + +using System; +/// +/// Provides a framed data and related properties. +/// +public class MessageReceivedEventArgs : EventArgs +{ /// - /// Provides a framed data and related properties. + /// Gets or sets the data contained in message frame. /// - public class MessageReceivedEventArgs : EventArgs - { - /// - /// Gets or sets the data contained in message frame. - /// - public string Data { get; set; } - } -} + public string Data { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ICommunicationEndpoint.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ICommunicationEndpoint.cs index e44e3e49a9..37852dd2d3 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ICommunicationEndpoint.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ICommunicationEndpoint.cs @@ -1,32 +1,31 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; + +using System; - public interface ICommunicationEndPoint - { - /// - /// Event raised when an endPoint is connected. - /// - event EventHandler Connected; +public interface ICommunicationEndPoint +{ + /// + /// Event raised when an endPoint is connected. + /// + event EventHandler Connected; - /// - /// Event raised when an endPoint is disconnected. - /// - event EventHandler Disconnected; + /// + /// Event raised when an endPoint is disconnected. + /// + event EventHandler Disconnected; - /// - /// Starts the endPoint and channel. - /// - /// Address to connect - /// Address of the connected endPoint - string Start(string endPoint); + /// + /// Starts the endPoint and channel. + /// + /// Address to connect + /// Address of the connected endPoint + string Start(string endPoint); - /// - /// Stops the endPoint and closes the underlying communication channel. - /// - void Stop(); - } + /// + /// Stops the endPoint and closes the underlying communication channel. + /// + void Stop(); } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ICommunicationEndpointFactory.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ICommunicationEndpointFactory.cs index 4fc2630b12..6aec5611b1 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ICommunicationEndpointFactory.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ICommunicationEndpointFactory.cs @@ -1,17 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces -{ - using TestPlatform.ObjectModel; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; + +using TestPlatform.ObjectModel; - public interface ICommunicationEndpointFactory - { - /// - /// Create communication endpoint. - /// - /// Endpoint role. - /// Return communication endpoint object. - ICommunicationEndPoint Create(ConnectionRole role); - } +public interface ICommunicationEndpointFactory +{ + /// + /// Create communication endpoint. + /// + /// Endpoint role. + /// Return communication endpoint object. + ICommunicationEndPoint Create(ConnectionRole role); } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ICommunicationManager.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ICommunicationManager.cs index 61f7a31826..d33acecaf7 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ICommunicationManager.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ICommunicationManager.cs @@ -1,132 +1,131 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; + +using System.Net; +using System.Threading; +using System.Threading.Tasks; + +/// +/// The Communication Manager interface. +/// +public interface ICommunicationManager { - using System.Net; - using System.Threading; - using System.Threading.Tasks; - - /// - /// The Communication Manager interface. - /// - public interface ICommunicationManager - { - /// - /// Host a server and listens on endpoint for requests - /// - /// End point where server is hosted - /// Port number of the listening endpoint - IPEndPoint HostServer(IPEndPoint endpoint); - - /// - /// Accepts client connection asynchronously - /// - /// A representing the asynchronous operation. - Task AcceptClientAsync(); - - /// - /// Waits for client to be connected to this server - /// Whoever hosting the server should use this method to - /// wait for a client to connect - /// - /// Time to wait for the connection - /// True, if Server got a connection from client - bool WaitForClientConnection(int connectionTimeout); - - /// - /// Waits for server to be connected - /// Whoever creating the client and trying to connect to a server - /// should use this method to wait for connection to be established with server - /// - /// Time to wait for the connection - /// True, if Server got a connection from client - bool WaitForServerConnection(int connectionTimeout); - - /// - /// Stops any hosted server - /// - void StopServer(); - - /// - /// Creates a Client Channel and connects to server on given port number - /// - /// End point for client to connect to - /// A representing the asynchronous operation. - Task SetupClientAsync(IPEndPoint endpoint); - - /// - /// Stops any client connected to server - /// - void StopClient(); - - /// - /// Writes message to the binary writer. - /// - /// Type of Message to be sent, for instance TestSessionStart - void SendMessage(string messageType); - - /// - /// Reads message from the binary reader - /// - /// Returns message read from the binary reader - Message ReceiveMessage(); - - /// - /// Reads message from the binary reader - /// - /// Raw message string - string ReceiveRawMessage(); - - /// - /// Reads message from the binary reader using read timeout - /// - /// - /// The cancellation Token. - /// - /// - /// Returns message read from the binary reader - /// - Task ReceiveMessageAsync(CancellationToken cancellationToken); - - /// - /// Reads message from the binary reader using read timeout - /// - /// - /// The cancellation Token. - /// - /// - /// Raw message string - /// - Task ReceiveRawMessageAsync(CancellationToken cancellationToken); - - /// - /// Writes message to the binary writer with payload - /// - /// Type of Message to be sent, for instance TestSessionStart - /// payload to be sent - void SendMessage(string messageType, object payload); - - /// - /// Writes message to the binary writer with payload - /// - /// Type of Message to be sent, for instance TestSessionStart - /// payload to be sent - /// version to be sent - void SendMessage(string messageType, object payload, int version); - - /// - /// Send serialized raw message - /// - /// serialized message - void SendRawMessage(string rawMessage); - - /// - /// Deserializes the Message into actual TestPlatform objects - /// - /// The type of object to deserialize to. - /// Message object - /// TestPlatform object - T DeserializePayload(Message message); - } -} + /// + /// Host a server and listens on endpoint for requests + /// + /// End point where server is hosted + /// Port number of the listening endpoint + IPEndPoint HostServer(IPEndPoint endpoint); + + /// + /// Accepts client connection asynchronously + /// + /// A representing the asynchronous operation. + Task AcceptClientAsync(); + + /// + /// Waits for client to be connected to this server + /// Whoever hosting the server should use this method to + /// wait for a client to connect + /// + /// Time to wait for the connection + /// True, if Server got a connection from client + bool WaitForClientConnection(int connectionTimeout); + + /// + /// Waits for server to be connected + /// Whoever creating the client and trying to connect to a server + /// should use this method to wait for connection to be established with server + /// + /// Time to wait for the connection + /// True, if Server got a connection from client + bool WaitForServerConnection(int connectionTimeout); + + /// + /// Stops any hosted server + /// + void StopServer(); + + /// + /// Creates a Client Channel and connects to server on given port number + /// + /// End point for client to connect to + /// A representing the asynchronous operation. + Task SetupClientAsync(IPEndPoint endpoint); + + /// + /// Stops any client connected to server + /// + void StopClient(); + + /// + /// Writes message to the binary writer. + /// + /// Type of Message to be sent, for instance TestSessionStart + void SendMessage(string messageType); + + /// + /// Reads message from the binary reader + /// + /// Returns message read from the binary reader + Message ReceiveMessage(); + + /// + /// Reads message from the binary reader + /// + /// Raw message string + string ReceiveRawMessage(); + + /// + /// Reads message from the binary reader using read timeout + /// + /// + /// The cancellation Token. + /// + /// + /// Returns message read from the binary reader + /// + Task ReceiveMessageAsync(CancellationToken cancellationToken); + + /// + /// Reads message from the binary reader using read timeout + /// + /// + /// The cancellation Token. + /// + /// + /// Raw message string + /// + Task ReceiveRawMessageAsync(CancellationToken cancellationToken); + + /// + /// Writes message to the binary writer with payload + /// + /// Type of Message to be sent, for instance TestSessionStart + /// payload to be sent + void SendMessage(string messageType, object payload); + + /// + /// Writes message to the binary writer with payload + /// + /// Type of Message to be sent, for instance TestSessionStart + /// payload to be sent + /// version to be sent + void SendMessage(string messageType, object payload, int version); + + /// + /// Send serialized raw message + /// + /// serialized message + void SendRawMessage(string rawMessage); + + /// + /// Deserializes the Message into actual TestPlatform objects + /// + /// The type of object to deserialize to. + /// Message object + /// TestPlatform object + T DeserializePayload(Message message); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionRequestHandler.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionRequestHandler.cs index 7eda77da92..f88308bc38 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionRequestHandler.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionRequestHandler.cs @@ -1,34 +1,33 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection.Interfaces; + +/// +/// The DataCollectionRequestHandler interface. +/// +internal interface IDataCollectionRequestHandler { /// - /// The DataCollectionRequestHandler interface. + /// Setups client based on port /// - internal interface IDataCollectionRequestHandler - { - /// - /// Setups client based on port - /// - /// port number to connect - void InitializeCommunication(int port); + /// port number to connect + void InitializeCommunication(int port); - /// - /// Waits for Request Handler to connect to Request Sender - /// - /// Timeout for establishing connection - /// True if connected, false if timed-out - bool WaitForRequestSenderConnection(int connectionTimeout); + /// + /// Waits for Request Handler to connect to Request Sender + /// + /// Timeout for establishing connection + /// True if connected, false if timed-out + bool WaitForRequestSenderConnection(int connectionTimeout); - /// - /// Listens to the commands from server - /// - void ProcessRequests(); + /// + /// Listens to the commands from server + /// + void ProcessRequests(); - /// - /// Closes the connection - /// - void Close(); - } + /// + /// Closes the connection + /// + void Close(); } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionRequestSender.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionRequestSender.cs index 5dd36660b1..5a4168fb5a 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionRequestSender.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionRequestSender.cs @@ -1,77 +1,76 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection.Interfaces -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection.Interfaces; + +using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.Common.DataCollection; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +/// +/// Defines contract to send test platform requests to test host +/// +internal interface IDataCollectionRequestSender +{ /// - /// Defines contract to send test platform requests to test host + /// Initializes the communication for sending requests /// - internal interface IDataCollectionRequestSender - { - /// - /// Initializes the communication for sending requests - /// - /// Port Number of the communication channel - int InitializeCommunication(); + /// Port Number of the communication channel + int InitializeCommunication(); - /// - /// Waits for Request Handler to be connected - /// - /// Time to wait for connection - /// True, if Handler is connected - bool WaitForRequestHandlerConnection(int connectionTimeout); + /// + /// Waits for Request Handler to be connected + /// + /// Time to wait for connection + /// True, if Handler is connected + bool WaitForRequestHandlerConnection(int connectionTimeout); - /// - /// Close the Sender - /// - void Close(); + /// + /// Close the Sender + /// + void Close(); - /// - /// Sends the TestHostLaunched event - /// - /// - /// Test host launched payload - /// - void SendTestHostLaunched(TestHostLaunchedPayload testHostLaunchedPayload); + /// + /// Sends the TestHostLaunched event + /// + /// + /// Test host launched payload + /// + void SendTestHostLaunched(TestHostLaunchedPayload testHostLaunchedPayload); - /// - /// Sends the BeforeTestRunStart event and waits for result - /// - /// - /// Run settings for test run. - /// - /// - /// Test run sources - /// - /// - /// Telemetry opted in flag. - /// - /// - /// Test message event handler for handling messages. - /// - /// - /// BeforeTestRunStartResult containing environment variables - /// - BeforeTestRunStartResult SendBeforeTestRunStartAndGetResult(string settingXml, IEnumerable sources, bool isTelemetryOptedIn, ITestMessageEventHandler runEventsHandler); + /// + /// Sends the BeforeTestRunStart event and waits for result + /// + /// + /// Run settings for test run. + /// + /// + /// Test run sources + /// + /// + /// Telemetry opted in flag. + /// + /// + /// Test message event handler for handling messages. + /// + /// + /// BeforeTestRunStartResult containing environment variables + /// + BeforeTestRunStartResult SendBeforeTestRunStartAndGetResult(string settingXml, IEnumerable sources, bool isTelemetryOptedIn, ITestMessageEventHandler runEventsHandler); - /// - /// Sends the AfterTestRunEnd event and waits for result - /// - /// - /// Test message event handler for handling messages. - /// - /// - /// The value to specify whether the test run is canceled or not. - /// - /// - /// AfterTestRunEndResult containing dataCollector attachments and metrics - /// - AfterTestRunEndResult SendAfterTestRunEndAndGetResult(ITestMessageEventHandler runEventsHandler, bool isCancelled); - } + /// + /// Sends the AfterTestRunEnd event and waits for result + /// + /// + /// Test message event handler for handling messages. + /// + /// + /// The value to specify whether the test run is canceled or not. + /// + /// + /// AfterTestRunEndResult containing dataCollector attachments and metrics + /// + AfterTestRunEndResult SendAfterTestRunEndAndGetResult(ITestMessageEventHandler runEventsHandler, bool isCancelled); } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionTestCaseEventHandler.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionTestCaseEventHandler.cs index 214346dbb5..cf33bce02d 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionTestCaseEventHandler.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionTestCaseEventHandler.cs @@ -1,36 +1,35 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; + +/// +/// Interface for interacting with execution process for getting test case events in data collection process. +/// +internal interface IDataCollectionTestCaseEventHandler { + // TODO : Similar interfaces exist, need redesign. + /// - /// Interface for interacting with execution process for getting test case events in data collection process. + /// Initializes the communication for sending requests /// - internal interface IDataCollectionTestCaseEventHandler - { - // TODO : Similar interfaces exist, need redesign. - - /// - /// Initializes the communication for sending requests - /// - /// Port Number of the communication channel - int InitializeCommunication(); + /// Port Number of the communication channel + int InitializeCommunication(); - /// - /// Waits for Request Handler to be connected. - /// - /// Time to wait for connection - /// True, if Handler is connected - bool WaitForRequestHandlerConnection(int connectionTimeout); + /// + /// Waits for Request Handler to be connected. + /// + /// Time to wait for connection + /// True, if Handler is connected + bool WaitForRequestHandlerConnection(int connectionTimeout); - /// - /// Close the handler - /// - void Close(); + /// + /// Close the handler + /// + void Close(); - /// - /// Listens to the commands from execution process - /// - void ProcessRequests(); - } -} + /// + /// Listens to the commands from execution process + /// + void ProcessRequests(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionTestCaseEventSender.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionTestCaseEventSender.cs index e73d69ef8e..8b43567c4e 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionTestCaseEventSender.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionTestCaseEventSender.cs @@ -1,61 +1,60 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; + +using System.Collections.ObjectModel; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +/// +/// Interface for sending test case events from test execution process to data collection process +/// +public interface IDataCollectionTestCaseEventSender { - using System.Collections.ObjectModel; + /// + /// Setups client based on port + /// + /// port number to connect + void InitializeCommunication(int port); + + /// + /// Waits for Request Handler to connect to Request Sender + /// + /// Timeout for establishing connection + /// True if connected, false if timed-out + bool WaitForRequestSenderConnection(int connectionTimeout); - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + /// + /// Closes the connection + /// + void Close(); + + /// + /// Sends the TestCaseStart event. + /// + /// + /// The args containing info about TestCaseStart event. + /// + void SendTestCaseStart(TestCaseStartEventArgs e); + + /// + /// Sends the TestCaseCompleted event along with outcome. + /// + /// + /// The args containing info about TestResult event. + /// + /// + /// The Collection of TestCase attachments. + /// + Collection SendTestCaseEnd(TestCaseEndEventArgs e); /// - /// Interface for sending test case events from test execution process to data collection process + /// Sends the SessionEnd event. This is used to as a trigger to close communication channel between datacollector process and testhost process. /// - public interface IDataCollectionTestCaseEventSender - { - /// - /// Setups client based on port - /// - /// port number to connect - void InitializeCommunication(int port); - - /// - /// Waits for Request Handler to connect to Request Sender - /// - /// Timeout for establishing connection - /// True if connected, false if timed-out - bool WaitForRequestSenderConnection(int connectionTimeout); - - /// - /// Closes the connection - /// - void Close(); - - /// - /// Sends the TestCaseStart event. - /// - /// - /// The args containing info about TestCaseStart event. - /// - void SendTestCaseStart(TestCaseStartEventArgs e); - - /// - /// Sends the TestCaseCompleted event along with outcome. - /// - /// - /// The args containing info about TestResult event. - /// - /// - /// The Collection of TestCase attachments. - /// - Collection SendTestCaseEnd(TestCaseEndEventArgs e); - - /// - /// Sends the SessionEnd event. This is used to as a trigger to close communication channel between datacollector process and testhost process. - /// - /// - /// The args containing info about SessionEnd event. - /// - void SendTestSessionEnd(SessionEndEventArgs e); - } -} + /// + /// The args containing info about SessionEnd event. + /// + void SendTestSessionEnd(SessionEndEventArgs e); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataSerializer.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataSerializer.cs index 97f52c5ca2..82e1f6dd08 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataSerializer.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataSerializer.cs @@ -1,58 +1,57 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; + +/// +/// IDataSerializer interface for serializing data +/// +public interface IDataSerializer { /// - /// IDataSerializer interface for serializing data + /// Deserializes the raw message into Message /// - public interface IDataSerializer - { - /// - /// Deserializes the raw message into Message - /// - /// Raw message off the IPC channel - /// Message object - Message DeserializeMessage(string rawMessage); + /// Raw message off the IPC channel + /// Message object + Message DeserializeMessage(string rawMessage); - /// - /// Deserializes the Message into actual TestPlatform objects - /// - /// The type of object to deserialize to. - /// Message object - /// TestPlatform object - T DeserializePayload(Message message); + /// + /// Deserializes the Message into actual TestPlatform objects + /// + /// The type of object to deserialize to. + /// Message object + /// TestPlatform object + T DeserializePayload(Message message); - /// - /// Serializes and creates a raw message given a message type - /// - /// Message Type - /// Raw Serialized message - string SerializeMessage(string messageType); + /// + /// Serializes and creates a raw message given a message type + /// + /// Message Type + /// Raw Serialized message + string SerializeMessage(string messageType); - /// - /// Serializes and creates a raw message given a message type and the object payload - /// - /// Message Type - /// Payload of the message - /// Raw Serialized message - string SerializePayload(string messageType, object payload); + /// + /// Serializes and creates a raw message given a message type and the object payload + /// + /// Message Type + /// Payload of the message + /// Raw Serialized message + string SerializePayload(string messageType, object payload); - /// - /// Serializes and creates a raw message given a message type and the object payload - /// - /// Message Type - /// Payload of the message - /// version to be sent - /// Raw Serialized message - string SerializePayload(string messageType, object payload, int version); + /// + /// Serializes and creates a raw message given a message type and the object payload + /// + /// Message Type + /// Payload of the message + /// version to be sent + /// Raw Serialized message + string SerializePayload(string messageType, object payload, int version); - /// - /// Creates cloned object for given object. - /// - /// The type of object to be cloned. - /// Object to be cloned. - /// Newly cloned object. - T Clone(T obj); - } -} + /// + /// Creates cloned object for given object. + /// + /// The type of object to be cloned. + /// Object to be cloned. + /// Newly cloned object. + T Clone(T obj); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ITestRequestHandler.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ITestRequestHandler.cs index 8908a72fc7..dd9c76da97 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ITestRequestHandler.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ITestRequestHandler.cs @@ -1,97 +1,96 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces -{ - using System; - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; + +using System; +using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +/// +/// Defines the contract for handling test platform requests +/// +public interface ITestRequestHandler : IDisposable +{ /// - /// Defines the contract for handling test platform requests + /// Gets or sets connection info for to start server/client. /// - public interface ITestRequestHandler : IDisposable - { - /// - /// Gets or sets connection info for to start server/client. - /// - TestHostConnectionInfo ConnectionInfo { get; set; } + TestHostConnectionInfo ConnectionInfo { get; set; } - /// - /// Setups client based on port - /// - void InitializeCommunication(); + /// + /// Setups client based on port + /// + void InitializeCommunication(); - /// - /// Waits for Request Handler to connect to Request Sender - /// - /// Timeout for establishing connection - /// True if connected, false if timed-out - bool WaitForRequestSenderConnection(int connectionTimeout); + /// + /// Waits for Request Handler to connect to Request Sender + /// + /// Timeout for establishing connection + /// True if connected, false if timed-out + bool WaitForRequestSenderConnection(int connectionTimeout); - /// - /// Listens to the commands from server - /// - /// the test host manager. - void ProcessRequests(ITestHostManagerFactory testHostManagerFactory); + /// + /// Listens to the commands from server + /// + /// the test host manager. + void ProcessRequests(ITestHostManagerFactory testHostManagerFactory); - /// - /// Closes the connection - /// - void Close(); + /// + /// Closes the connection + /// + void Close(); - /// - /// The send test cases. - /// - /// The discovered test cases. - void SendTestCases(IEnumerable discoveredTestCases); + /// + /// The send test cases. + /// + /// The discovered test cases. + void SendTestCases(IEnumerable discoveredTestCases); - /// - /// The send test run statistics. - /// - /// The test run changed args. - void SendTestRunStatistics(TestRunChangedEventArgs testRunChangedArgs); + /// + /// The send test run statistics. + /// + /// The test run changed args. + void SendTestRunStatistics(TestRunChangedEventArgs testRunChangedArgs); - /// - /// Sends the logs back to the server. - /// - /// The message level. - /// The message. - void SendLog(TestMessageLevel messageLevel, string message); + /// + /// Sends the logs back to the server. + /// + /// The message level. + /// The message. + void SendLog(TestMessageLevel messageLevel, string message); - /// - /// The send execution complete. - /// - /// The test run complete args. - /// The last chunk args. - /// The run context attachments. - /// The executor uris. - void SendExecutionComplete(TestRunCompleteEventArgs testRunCompleteArgs, TestRunChangedEventArgs lastChunkArgs, ICollection runContextAttachments, ICollection executorUris); + /// + /// The send execution complete. + /// + /// The test run complete args. + /// The last chunk args. + /// The run context attachments. + /// The executor uris. + void SendExecutionComplete(TestRunCompleteEventArgs testRunCompleteArgs, TestRunChangedEventArgs lastChunkArgs, ICollection runContextAttachments, ICollection executorUris); - /// - /// The discovery complete handler - /// - /// Discovery Complete Event Args - /// The last Chunk. - void DiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk); + /// + /// The discovery complete handler + /// + /// Discovery Complete Event Args + /// The last Chunk. + void DiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk); - /// - /// Launches a process with a given process info under debugger - /// Adapter get to call into this to launch any additional processes under debugger - /// - /// Process start info - /// ProcessId of the launched process - int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo); + /// + /// Launches a process with a given process info under debugger + /// Adapter get to call into this to launch any additional processes under debugger + /// + /// Process start info + /// ProcessId of the launched process + int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo); - /// - /// Attach debugger to an already running process. - /// - /// Process ID of the process to which the debugger should be attached. - /// if the debugger was successfully attached to the requested process, otherwise. - bool AttachDebuggerToProcess(int pid); - } -} + /// + /// Attach debugger to an already running process. + /// + /// Process ID of the process to which the debugger should be attached. + /// if the debugger was successfully attached to the requested process, otherwise. + bool AttachDebuggerToProcess(int pid); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ITestRequestSender.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ITestRequestSender.cs index d65aa7bb0f..eb5e1b287e 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ITestRequestSender.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ITestRequestSender.cs @@ -1,96 +1,95 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; + +using System; +using System.Collections.Generic; +using System.Threading; + +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +/// +/// Defines contract to send test platform requests to test host +/// +public interface ITestRequestSender : IDisposable { - using System; - using System.Collections.Generic; - using System.Threading; + /// + /// Initializes the communication for sending requests + /// + /// Port Number of the communication channel + int InitializeCommunication(); - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + /// + /// Used for protocol version check with TestHost + /// + void CheckVersionWithTestHost(); + + /// + /// Waits for Request Handler to be connected + /// + /// Time to wait for connection + /// Cancellation token + /// True, if Handler is connected + bool WaitForRequestHandlerConnection(int connectionTimeout, CancellationToken cancellationToken); + + /// + /// Close the Sender + /// + void Close(); + + /// + /// Initializes the Discovery + /// + /// Paths to check for additional extensions + void InitializeDiscovery(IEnumerable pathToAdditionalExtensions); + + /// + /// Initializes the Execution + /// + /// Paths to check for additional extensions + void InitializeExecution(IEnumerable pathToAdditionalExtensions); + + /// + /// Discovers the tests + /// + /// DiscoveryCriteria for discovery + /// EventHandler for discovery events + void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 discoveryEventsHandler); + + /// + /// Starts the TestRun with given sources and criteria + /// + /// RunCriteria for test run + /// EventHandler for test run events + void StartTestRun(TestRunCriteriaWithSources runCriteria, ITestRunEventsHandler eventHandler); + + /// + /// Starts the TestRun with given test cases and criteria + /// + /// RunCriteria for test run + /// EventHandler for test run events + void StartTestRun(TestRunCriteriaWithTests runCriteria, ITestRunEventsHandler eventHandler); + + /// + /// Ends the Session + /// + void EndSession(); + + /// + /// Send the request to cancel the test run + /// + void SendTestRunCancel(); + + /// + /// Send the request to abort the test run + /// + void SendTestRunAbort(); /// - /// Defines contract to send test platform requests to test host + /// Handle client process exit /// - public interface ITestRequestSender : IDisposable - { - /// - /// Initializes the communication for sending requests - /// - /// Port Number of the communication channel - int InitializeCommunication(); - - /// - /// Used for protocol version check with TestHost - /// - void CheckVersionWithTestHost(); - - /// - /// Waits for Request Handler to be connected - /// - /// Time to wait for connection - /// Cancellation token - /// True, if Handler is connected - bool WaitForRequestHandlerConnection(int connectionTimeout, CancellationToken cancellationToken); - - /// - /// Close the Sender - /// - void Close(); - - /// - /// Initializes the Discovery - /// - /// Paths to check for additional extensions - void InitializeDiscovery(IEnumerable pathToAdditionalExtensions); - - /// - /// Initializes the Execution - /// - /// Paths to check for additional extensions - void InitializeExecution(IEnumerable pathToAdditionalExtensions); - - /// - /// Discovers the tests - /// - /// DiscoveryCriteria for discovery - /// EventHandler for discovery events - void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 discoveryEventsHandler); - - /// - /// Starts the TestRun with given sources and criteria - /// - /// RunCriteria for test run - /// EventHandler for test run events - void StartTestRun(TestRunCriteriaWithSources runCriteria, ITestRunEventsHandler eventHandler); - - /// - /// Starts the TestRun with given test cases and criteria - /// - /// RunCriteria for test run - /// EventHandler for test run events - void StartTestRun(TestRunCriteriaWithTests runCriteria, ITestRunEventsHandler eventHandler); - - /// - /// Ends the Session - /// - void EndSession(); - - /// - /// Send the request to cancel the test run - /// - void SendTestRunCancel(); - - /// - /// Send the request to abort the test run - /// - void SendTestRunAbort(); - - /// - /// Handle client process exit - /// - /// Standard error output - void OnClientProcessExit(string stdError); - } -} + /// Standard error output + void OnClientProcessExit(string stdError); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ITransport.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ITransport.cs index d32c15a182..24ade9548e 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ITransport.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ITransport.cs @@ -1,27 +1,26 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces -{ - using System; - using System.Net; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; + +using System; +using System.Net; +/// +/// The transport Layer Interface +/// +public interface ITransport : IDisposable +{ /// - /// The transport Layer Interface + /// Initializes Transport Layer /// - public interface ITransport : IDisposable - { - /// - /// Initializes Transport Layer - /// - /// Endpoint - IPEndPoint Initialize(); + /// Endpoint + IPEndPoint Initialize(); - /// - /// Waits for the connection over transport layer to established - /// - /// Time to wait for connection - /// True if connection is established - bool WaitForConnection(int connectionTimeout); - } -} + /// + /// Waits for the connection over transport layer to established + /// + /// Time to wait for connection + /// True if connection is established + bool WaitForConnection(int connectionTimeout); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/JsonDataSerializer.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/JsonDataSerializer.cs index 72c44d1e6c..eaf7aa24ca 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/JsonDataSerializer.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/JsonDataSerializer.cs @@ -1,240 +1,222 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities -{ - using System; - using System.IO; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; + +using System; +using System.IO; + +using Interfaces; +using Serialization; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +/// +/// JsonDataSerializes serializes and deserializes data using Json format +/// +public class JsonDataSerializer : IDataSerializer +{ + private static JsonDataSerializer s_instance; - using Newtonsoft.Json; - using Newtonsoft.Json.Linq; + private static JsonSerializer s_payloadSerializer; // payload serializer for version <= 1 + private static JsonSerializer s_payloadSerializer2; // payload serializer for version >= 2 + private static JsonSerializer s_serializer; // generic serializer /// - /// JsonDataSerializes serializes and deserializes data using Json format + /// Prevents a default instance of the class from being created. /// - public class JsonDataSerializer : IDataSerializer + private JsonDataSerializer() { - private static JsonDataSerializer instance; + var jsonSettings = new JsonSerializerSettings + { + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateParseHandling = DateParseHandling.DateTimeOffset, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + TypeNameHandling = TypeNameHandling.None, + ReferenceLoopHandling = ReferenceLoopHandling.Ignore + }; - private static JsonSerializer payloadSerializer; // payload serializer for version <= 1 - private static JsonSerializer payloadSerializer2; // payload serializer for version >= 2 - private static JsonSerializer serializer; // generic serializer + s_serializer = JsonSerializer.Create(); + s_payloadSerializer = JsonSerializer.Create(jsonSettings); + s_payloadSerializer2 = JsonSerializer.Create(jsonSettings); - /// - /// Prevents a default instance of the class from being created. - /// - private JsonDataSerializer() - { - var jsonSettings = new JsonSerializerSettings - { - DateFormatHandling = DateFormatHandling.IsoDateFormat, - DateParseHandling = DateParseHandling.DateTimeOffset, - DateTimeZoneHandling = DateTimeZoneHandling.Utc, - TypeNameHandling = TypeNameHandling.None, - ReferenceLoopHandling = ReferenceLoopHandling.Ignore - }; - - serializer = JsonSerializer.Create(); - payloadSerializer = JsonSerializer.Create(jsonSettings); - payloadSerializer2 = JsonSerializer.Create(jsonSettings); - - payloadSerializer.ContractResolver = new TestPlatformContractResolver1(); - payloadSerializer2.ContractResolver = new DefaultTestPlatformContractResolver(); + s_payloadSerializer.ContractResolver = new TestPlatformContractResolver1(); + s_payloadSerializer2.ContractResolver = new DefaultTestPlatformContractResolver(); #if TRACE_JSON_SERIALIZATION - // MemoryTraceWriter can help diagnose serialization issues. Enable it for - // debug builds only. - // Note that MemoryTraceWriter is not thread safe, please don't use it in parallel - // test runs. See https://github.com/JamesNK/Newtonsoft.Json/issues/1279 - payloadSerializer.TraceWriter = new MemoryTraceWriter(); - payloadSerializer2.TraceWriter = new MemoryTraceWriter(); + // MemoryTraceWriter can help diagnose serialization issues. Enable it for + // debug builds only. + // Note that MemoryTraceWriter is not thread safe, please don't use it in parallel + // test runs. See https://github.com/JamesNK/Newtonsoft.Json/issues/1279 + payloadSerializer.TraceWriter = new MemoryTraceWriter(); + payloadSerializer2.TraceWriter = new MemoryTraceWriter(); #endif - } + } - /// - /// Gets the JSON Serializer instance. - /// - public static JsonDataSerializer Instance - { - get - { - return instance ?? (instance = new JsonDataSerializer()); - } - } + /// + /// Gets the JSON Serializer instance. + /// + public static JsonDataSerializer Instance => s_instance ??= new JsonDataSerializer(); - /// - /// Deserialize a from raw JSON text. - /// - /// JSON string. - /// A instance. - public Message DeserializeMessage(string rawMessage) - { - return this.Deserialize(serializer, rawMessage); - } + /// + /// Deserialize a from raw JSON text. + /// + /// JSON string. + /// A instance. + public Message DeserializeMessage(string rawMessage) + { + return Deserialize(s_serializer, rawMessage); + } - /// - /// Deserialize the for a message. - /// - /// A object. - /// Payload type. - /// The deserialized payload. - public T DeserializePayload(Message message) - { - var versionedMessage = message as VersionedMessage; - var payloadSerializer = this.GetPayloadSerializer(versionedMessage?.Version); - return this.Deserialize(payloadSerializer, message.Payload); - } + /// + /// Deserialize the for a message. + /// + /// A object. + /// Payload type. + /// The deserialized payload. + public T DeserializePayload(Message message) + { + var versionedMessage = message as VersionedMessage; + var payloadSerializer = GetPayloadSerializer(versionedMessage?.Version); + return Deserialize(payloadSerializer, message.Payload); + } - /// - /// Deserialize raw JSON to an object using the default serializer. - /// - /// JSON string. - /// Version of serializer to be used. - /// Target type to deserialize. - /// An instance of . - public T Deserialize(string json, int version = 1) - { - var payloadSerializer = this.GetPayloadSerializer(version); - return this.Deserialize(payloadSerializer, json); - } + /// + /// Deserialize raw JSON to an object using the default serializer. + /// + /// JSON string. + /// Version of serializer to be used. + /// Target type to deserialize. + /// An instance of . + public T Deserialize(string json, int version = 1) + { + var payloadSerializer = GetPayloadSerializer(version); + return Deserialize(payloadSerializer, json); + } - /// - /// Serialize an empty message. - /// - /// Type of the message. - /// Serialized message. - public string SerializeMessage(string messageType) - { - return this.Serialize(serializer, new Message { MessageType = messageType }); - } + /// + /// Serialize an empty message. + /// + /// Type of the message. + /// Serialized message. + public string SerializeMessage(string messageType) + { + return Serialize(s_serializer, new Message { MessageType = messageType }); + } - /// - /// Serialize a message with payload. - /// - /// Type of the message. - /// Payload for the message. - /// Serialized message. - public string SerializePayload(string messageType, object payload) - { - return this.SerializePayload(messageType, payload, 1); - } + /// + /// Serialize a message with payload. + /// + /// Type of the message. + /// Payload for the message. + /// Serialized message. + public string SerializePayload(string messageType, object payload) + { + return SerializePayload(messageType, payload, 1); + } - /// - /// Serialize a message with payload. - /// - /// Type of the message. - /// Payload for the message. - /// Version for the message. - /// Serialized message. - public string SerializePayload(string messageType, object payload, int version) - { - var payloadSerializer = this.GetPayloadSerializer(version); - var serializedPayload = JToken.FromObject(payload, payloadSerializer); + /// + /// Serialize a message with payload. + /// + /// Type of the message. + /// Payload for the message. + /// Version for the message. + /// Serialized message. + public string SerializePayload(string messageType, object payload, int version) + { + var payloadSerializer = GetPayloadSerializer(version); + var serializedPayload = JToken.FromObject(payload, payloadSerializer); - return version > 1 ? - this.Serialize(serializer, new VersionedMessage { MessageType = messageType, Version = version, Payload = serializedPayload }) : - this.Serialize(serializer, new Message { MessageType = messageType, Payload = serializedPayload }); - } + return version > 1 ? + Serialize(s_serializer, new VersionedMessage { MessageType = messageType, Version = version, Payload = serializedPayload }) : + Serialize(s_serializer, new Message { MessageType = messageType, Payload = serializedPayload }); + } - /// - /// Serialize an object to JSON using default serialization settings. - /// - /// Type of object to serialize. - /// Instance of the object to serialize. - /// Version to be stamped. - /// JSON string. - public string Serialize(T data, int version = 1) + /// + /// Serialize an object to JSON using default serialization settings. + /// + /// Type of object to serialize. + /// Instance of the object to serialize. + /// Version to be stamped. + /// JSON string. + public string Serialize(T data, int version = 1) + { + var payloadSerializer = GetPayloadSerializer(version); + return Serialize(payloadSerializer, data); + } + + /// + public T Clone(T obj) + { + if (obj == null) { - var payloadSerializer = this.GetPayloadSerializer(version); - return this.Serialize(payloadSerializer, data); + return default; } - /// - public T Clone(T obj) - { - if (obj == null) - { - return default; - } + var stringObj = Serialize(obj, 2); + return Deserialize(stringObj, 2); + } - var stringObj = this.Serialize(obj, 2); - return this.Deserialize(stringObj, 2); - } + /// + /// Serialize data. + /// + /// Type of data. + /// Serializer. + /// Data to be serialized. + /// Serialized data. + private string Serialize(JsonSerializer serializer, T data) + { + using var stringWriter = new StringWriter(); + using var jsonWriter = new JsonTextWriter(stringWriter); + serializer.Serialize(jsonWriter, data); + return stringWriter.ToString(); + } - /// - /// Serialize data. - /// - /// Type of data. - /// Serializer. - /// Data to be serialized. - /// Serialized data. - private string Serialize(JsonSerializer serializer, T data) - { - using (var stringWriter = new StringWriter()) - using (var jsonWriter = new JsonTextWriter(stringWriter)) - { - serializer.Serialize(jsonWriter, data); - return stringWriter.ToString(); - } - } + /// + /// Deserialize data. + /// + /// Type of data. + /// Serializer. + /// Data to be deserialized. + /// Deserialized data. + private T Deserialize(JsonSerializer serializer, string data) + { + using var stringReader = new StringReader(data); + using var jsonReader = new JsonTextReader(stringReader); + return serializer.Deserialize(jsonReader); + } - /// - /// Deserialize data. - /// - /// Type of data. - /// Serializer. - /// Data to be deserialized. - /// Deserialized data. - private T Deserialize(JsonSerializer serializer, string data) - { - using (var stringReader = new StringReader(data)) - using (var jsonReader = new JsonTextReader(stringReader)) - { - return serializer.Deserialize(jsonReader); - } - } + /// + /// Deserialize JToken object to T object. + /// + /// Type of data. + /// Serializer. + /// JToken to be deserialized. + /// Deserialized data. + private T Deserialize(JsonSerializer serializer, JToken jToken) + { + return jToken.ToObject(serializer); + } - /// - /// Deserialize JToken object to T object. - /// - /// Type of data. - /// Serializer. - /// JToken to be deserialized. - /// Deserialized data. - private T Deserialize(JsonSerializer serializer, JToken jToken) + private JsonSerializer GetPayloadSerializer(int? version) + { + if (version == null) { - return jToken.ToObject(serializer); + version = 1; } - private JsonSerializer GetPayloadSerializer(int? version) + return version switch { - if (version == null) - { - version = 1; - } - - switch (version) - { - // 0 is used during negotiation - case 0: - case 1: - // Protocol version 3 was accidentally used with serializer v1 and not - // serializer v2, we downgrade to protocol 2 when 3 would be negotiated - // unless this is disabled by VSTEST_DISABLE_PROTOCOL_3_VERSION_DOWNGRADE - // env variable. - case 3: - return payloadSerializer; - case 2: - case 4: - case 5: - return payloadSerializer2; - default: - throw new NotSupportedException($"Protocol version {version} is not supported. " + - "Ensure it is compatible with the latest serializer or add a new one."); - } - } + // 0 is used during negotiation. + // Protocol version 3 was accidentally used with serializer v1 and not + // serializer v2, we downgrade to protocol 2 when 3 would be negotiated + // unless this is disabled by VSTEST_DISABLE_PROTOCOL_3_VERSION_DOWNGRADE + // env variable. + 0 or 1 or 3 => s_payloadSerializer, + 2 or 4 or 5 => s_payloadSerializer2, + _ => throw new NotSupportedException($"Protocol version {version} is not supported. " + + "Ensure it is compatible with the latest serializer or add a new one."), + }; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/LengthPrefixCommunicationChannel.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/LengthPrefixCommunicationChannel.cs index 63785782a1..8357b99994 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/LengthPrefixCommunicationChannel.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/LengthPrefixCommunicationChannel.cs @@ -1,87 +1,90 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; + +using System; +using System.IO; +using System.Text; +using System.Threading.Tasks; + +using Interfaces; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using PlatformAbstractions; + +using Utilities; + +/// +/// A communication channel using a length prefix packet frame for communication. +/// +public class LengthPrefixCommunicationChannel : ICommunicationChannel { - using System; - using System.IO; - using System.Text; - using System.Threading.Tasks; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.Utilities; + private readonly BinaryReader _reader; + + private readonly BinaryWriter _writer; /// - /// A communication channel using a length prefix packet frame for communication. + /// Sync object for sending messages + /// Write for binarywriter is NOT thread-safe /// - public class LengthPrefixCommunicationChannel : ICommunicationChannel - { - private readonly BinaryReader reader; + private readonly object _writeSyncObject = new(); - private readonly BinaryWriter writer; - - /// - /// Sync object for sending messages - /// Write for binarywriter is NOT thread-safe - /// - private object writeSyncObject = new object(); - - public LengthPrefixCommunicationChannel(Stream stream) - { - this.reader = new BinaryReader(stream, Encoding.UTF8, true); + public LengthPrefixCommunicationChannel(Stream stream) + { + _reader = new BinaryReader(stream, Encoding.UTF8, true); - // Using the Buffered stream while writing, improves the write performance. By reducing the number of writes. - this.writer = new BinaryWriter(new PlatformStream().CreateBufferedStream(stream, SocketConstants.BufferSize), Encoding.UTF8, true); - } + // Using the Buffered stream while writing, improves the write performance. By reducing the number of writes. + _writer = new BinaryWriter(new PlatformStream().CreateBufferedStream(stream, SocketConstants.BufferSize), Encoding.UTF8, true); + } - /// - public event EventHandler MessageReceived; + /// + public event EventHandler MessageReceived; - /// - public Task Send(string data) + /// + public Task Send(string data) + { + try { - try + // Writing Message on binarywriter is not Thread-Safe + // Need to sync one by one to avoid buffer corruption + lock (_writeSyncObject) { - // Writing Message on binarywriter is not Thread-Safe - // Need to sync one by one to avoid buffer corruption - lock (this.writeSyncObject) - { - this.writer.Write(data); - this.writer.Flush(); - } + _writer.Write(data); + _writer.Flush(); } - catch (Exception ex) - { - EqtTrace.Error("LengthPrefixCommunicationChannel.Send: Error sending data: {0}.", ex); - throw new CommunicationException("Unable to send data over channel.", ex); - } - - return Task.FromResult(0); } - - /// - public Task NotifyDataAvailable() + catch (Exception ex) { - // Try read data even if no one is listening to the data stream. Some server - // implementations (like Sockets) depend on the read operation to determine if a - // connection is closed. - if (this.MessageReceived != null) - { - var data = this.reader.ReadString(); - this.MessageReceived.SafeInvoke(this, new MessageReceivedEventArgs { Data = data }, "LengthPrefixCommunicationChannel: MessageReceived"); - } - - return Task.FromResult(0); + EqtTrace.Error("LengthPrefixCommunicationChannel.Send: Error sending data: {0}.", ex); + throw new CommunicationException("Unable to send data over channel.", ex); } - /// - public void Dispose() + return Task.FromResult(0); + } + + /// + public Task NotifyDataAvailable() + { + // Try read data even if no one is listening to the data stream. Some server + // implementations (like Sockets) depend on the read operation to determine if a + // connection is closed. + if (MessageReceived != null) { - EqtTrace.Verbose("LengthPrefixCommunicationChannel.Dispose: Dispose reader and writer."); - this.reader.Dispose(); - this.writer.Dispose(); - GC.SuppressFinalize(this); + var data = _reader.ReadString(); + MessageReceived.SafeInvoke(this, new MessageReceivedEventArgs { Data = data }, "LengthPrefixCommunicationChannel: MessageReceived"); } + + return Task.FromResult(0); + } + + /// + public void Dispose() + { + EqtTrace.Verbose("LengthPrefixCommunicationChannel.Dispose: Dispose reader and writer."); + _reader.Dispose(); + _writer.Dispose(); + GC.SuppressFinalize(this); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/BeforeTestRunStartPayload.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/BeforeTestRunStartPayload.cs index a8872140fe..b96a218fb1 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/BeforeTestRunStartPayload.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/BeforeTestRunStartPayload.cs @@ -1,28 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; + +using System.Collections.Generic; +/// +/// The before test run start payload +/// +public class BeforeTestRunStartPayload +{ /// - /// The before test run start payload + /// Gets or sets run settings xml. /// - public class BeforeTestRunStartPayload - { - /// - /// Gets or sets run settings xml. - /// - public string SettingsXml { get; set; } + public string SettingsXml { get; set; } - /// - /// Gets or sets list of test sources. - /// - public IEnumerable Sources { get; set; } + /// + /// Gets or sets list of test sources. + /// + public IEnumerable Sources { get; set; } - /// - /// Gets or sets a value indicating whether telemetry is enabled. - /// - public bool IsTelemetryOptedIn { get; set; } - } -} + /// + /// Gets or sets a value indicating whether telemetry is enabled. + /// + public bool IsTelemetryOptedIn { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/DiscoveryCompletePayload.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/DiscoveryCompletePayload.cs index 1abacd4f4e..4904a62289 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/DiscoveryCompletePayload.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/DiscoveryCompletePayload.cs @@ -1,34 +1,34 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel -{ - using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; + +using System.Collections.Generic; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +/// +/// The discovery complete payload. +/// +public class DiscoveryCompletePayload +{ /// - /// The discovery complete payload. + /// Gets or sets the total number of tests discovered. /// - public class DiscoveryCompletePayload - { - /// - /// Gets or sets the total number of tests discovered. - /// - public long TotalTests { get; set; } + public long TotalTests { get; set; } - /// - /// Gets or sets the last chunk of discovered tests. - /// - public IEnumerable LastDiscoveredTests { get; set; } + /// + /// Gets or sets the last chunk of discovered tests. + /// + public IEnumerable LastDiscoveredTests { get; set; } - /// - /// Gets or sets a value indicating whether discovery was aborted. - /// - public bool IsAborted { get; set; } + /// + /// Gets or sets a value indicating whether discovery was aborted. + /// + public bool IsAborted { get; set; } - /// - /// Gets or sets the Metrics - /// - public IDictionary Metrics { get; set; } - } -} + /// + /// Gets or sets the Metrics + /// + public IDictionary Metrics { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/Message.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/Message.cs index 2ea60f3454..920df62a63 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/Message.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/Message.cs @@ -1,33 +1,32 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Linq; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +/// +/// Construct used for communication +/// +public class Message +{ /// - /// Construct used for communication + /// Gets or sets the message type. /// - public class Message - { - /// - /// Gets or sets the message type. - /// - public string MessageType { get; set; } + public string MessageType { get; set; } - /// - /// Gets or sets the payload. - /// - public JToken Payload { get; set; } + /// + /// Gets or sets the payload. + /// + public JToken Payload { get; set; } - /// - /// To string implementation. - /// - /// The . - public override string ToString() - { - return "(" + this.MessageType + ") -> " + (this.Payload == null ? "null" : this.Payload.ToString(Formatting.Indented)); - } + /// + /// To string implementation. + /// + /// The . + public override string ToString() + { + return "(" + MessageType + ") -> " + (Payload == null ? "null" : Payload.ToString(Formatting.Indented)); } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/MessageType.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/MessageType.cs index 0a92bbc38b..9fc8c57caf 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/MessageType.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/MessageType.cs @@ -1,265 +1,264 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; + +/// +/// The message type. +/// +public static class MessageType { /// - /// The message type. - /// - public static class MessageType - { - /// - /// The session start. - /// - public const string SessionStart = "TestSession.Start"; - - /// - /// The session end. - /// - public const string SessionEnd = "TestSession.Terminate"; - - /// - /// The is aborted. - /// - public const string SessionAbort = "TestSession.Abort"; - - /// - /// The session connected. - /// - public const string SessionConnected = "TestSession.Connected"; - - /// - /// Test Message - /// - public const string TestMessage = "TestSession.Message"; - - /// - /// Protocol Version - /// - public const string VersionCheck = "ProtocolVersion"; - - /// - /// Protocol Error - /// - public const string ProtocolError = "ProtocolError"; - - /// - /// The session start. - /// - public const string DiscoveryInitialize = "TestDiscovery.Initialize"; - - /// - /// The discovery started. - /// - public const string StartDiscovery = "TestDiscovery.Start"; - - /// - /// The test cases found. - /// - public const string TestCasesFound = "TestDiscovery.TestFound"; - - /// - /// The discovery complete. - /// - public const string DiscoveryComplete = "TestDiscovery.Completed"; - - /// - /// Cancel Test Discovery - /// - public const string CancelDiscovery = "TestDiscovery.Cancel"; - - /// - /// The session start. - /// - public const string ExecutionInitialize = "TestExecution.Initialize"; - - /// - /// Cancel the current test run - /// - public const string CancelTestRun = "TestExecution.Cancel"; - - /// - /// Cancel the current test run - /// - public const string AbortTestRun = "TestExecution.Abort"; - - /// - /// Start test execution. - /// - public const string StartTestExecutionWithSources = "TestExecution.StartWithSources"; - - /// - /// Start test execution. - /// - public const string StartTestExecutionWithTests = "TestExecution.StartWithTests"; - - /// - /// The test run stats change. - /// - public const string TestRunStatsChange = "TestExecution.StatsChange"; - - /// - /// The execution complete. - /// - public const string ExecutionComplete = "TestExecution.Completed"; - - /// - /// The message to get runner process startInfo for run all tests in given sources - /// - public const string GetTestRunnerProcessStartInfoForRunAll = "TestExecution.GetTestRunnerProcessStartInfoForRunAll"; - - /// - /// The message to get runner process startInfo for run selected tests - /// - public const string GetTestRunnerProcessStartInfoForRunSelected = "TestExecution.GetTestRunnerProcessStartInfoForRunSelected"; - - /// - /// CustomTestHostLaunch - /// - public const string CustomTestHostLaunch = "TestExecution.CustomTestHostLaunch"; - - /// - /// Custom Test Host launch callback - /// - public const string CustomTestHostLaunchCallback = "TestExecution.CustomTestHostLaunchCallback"; - - /// - /// Test run attachments processing - /// - public const string TestRunAttachmentsProcessingStart = "TestRunAttachmentsProcessing.Start"; - - /// - /// Test run attachments processing callback - /// - public const string TestRunAttachmentsProcessingComplete = "TestRunAttachmentsProcessing.Complete"; - - /// - /// Test run attachments processing progress - /// - public const string TestRunAttachmentsProcessingProgress = "TestRunAttachmentsProcessing.Progress"; - - /// - /// Cancel test run attachments processing - /// - public const string TestRunAttachmentsProcessingCancel = "TestRunAttachmentsProcessing.Cancel"; - - /// - /// Extensions Initialization - /// - public const string ExtensionsInitialize = "Extensions.Initialize"; - - /// - /// Start Test Run All Sources - /// - public const string TestRunAllSourcesWithDefaultHost = "TestExecution.RunAllWithDefaultHost"; - - /// - /// Start Test Run - Testcases - /// - public const string TestRunSelectedTestCasesDefaultHost = "TestExecution.RunSelectedWithDefaultHost"; - - /// - /// Launch Adapter Process With DebuggerAttached - /// - public const string LaunchAdapterProcessWithDebuggerAttached = "TestExecution.LaunchAdapterProcessWithDebuggerAttached"; - - /// - /// Launch Adapter Process With DebuggerAttached - /// - public const string LaunchAdapterProcessWithDebuggerAttachedCallback = "TestExecution.LaunchAdapterProcessWithDebuggerAttachedCallback"; - - /// - /// Attach debugger to process. - /// - public const string AttachDebugger = "TestExecution.AttachDebugger"; - - /// - /// Attach debugger to process callback. - /// - public const string AttachDebuggerCallback = "TestExecution.AttachDebuggerCallback"; - - /// - /// Attach debugger to process. - /// - public const string EditorAttachDebugger = "TestExecution.EditorAttachDebugger"; - - /// - /// Attach debugger to process callback. - /// - public const string EditorAttachDebuggerCallback = "TestExecution.EditorAttachDebuggerCallback"; - - /// - /// Data Collection Message - /// - public const string DataCollectionMessage = "DataCollection.SendMessage"; - - /// - /// StartTestSession message. - /// - public const string StartTestSession = "TestSession.StartTestSession"; - - /// - /// StartTestSession callback message. - /// - public const string StartTestSessionCallback = "TestSession.StartTestSessionCallback"; - - /// - /// StopTestSession message. - /// - public const string StopTestSession = "TestSession.StopTestSession"; - - /// - /// StopTestSession callback message. - /// - public const string StopTestSessionCallback = "TestSession.StopTestSessionCallback"; - - #region DataCollector messages - - /// - /// Event message type sent to datacollector process right after test host process has started. - /// - public const string TestHostLaunched = "DataCollection.TestHostLaunched"; - - /// - /// Event message type send to datacollector process before test run starts. - /// - public const string BeforeTestRunStart = "DataCollection.BeforeTestRunStart"; - - /// - /// Event message type used by datacollector to send results after receiving test run start event. - /// - public const string BeforeTestRunStartResult = "DataCollection.BeforeTestRunStartResult"; - - /// - /// Event message type send to datacollector process after test run ends. - /// - public const string AfterTestRunEnd = "DataCollection.AfterTestRunEnd"; - - /// - /// Event message type used by datacollector to send result on receiving test run end event. - /// - public const string AfterTestRunEndResult = "DataCollection.AfterTestRunEndResult"; - - /// - /// Event message type send to datacollector process before test case execution starts. - /// - public const string DataCollectionTestStart = "DataCollection.TestStart"; - - /// - /// Event message type used to signal datacollector process that test case execution has ended. - /// - public const string DataCollectionTestEnd = "DataCollection.TestEnd"; - - /// - /// Event message type used by datacollector to send result on receiving TestEnd. - /// - public const string DataCollectionTestEndResult = "DataCollection.TestEndResult"; - - /// - /// Ack Event message type send to datacollector process before test case execution starts. - /// - public const string DataCollectionTestStartAck = "DataCollection.TestStartAck"; - - #endregion - } -} + /// The session start. + /// + public const string SessionStart = "TestSession.Start"; + + /// + /// The session end. + /// + public const string SessionEnd = "TestSession.Terminate"; + + /// + /// The is aborted. + /// + public const string SessionAbort = "TestSession.Abort"; + + /// + /// The session connected. + /// + public const string SessionConnected = "TestSession.Connected"; + + /// + /// Test Message + /// + public const string TestMessage = "TestSession.Message"; + + /// + /// Protocol Version + /// + public const string VersionCheck = "ProtocolVersion"; + + /// + /// Protocol Error + /// + public const string ProtocolError = "ProtocolError"; + + /// + /// The session start. + /// + public const string DiscoveryInitialize = "TestDiscovery.Initialize"; + + /// + /// The discovery started. + /// + public const string StartDiscovery = "TestDiscovery.Start"; + + /// + /// The test cases found. + /// + public const string TestCasesFound = "TestDiscovery.TestFound"; + + /// + /// The discovery complete. + /// + public const string DiscoveryComplete = "TestDiscovery.Completed"; + + /// + /// Cancel Test Discovery + /// + public const string CancelDiscovery = "TestDiscovery.Cancel"; + + /// + /// The session start. + /// + public const string ExecutionInitialize = "TestExecution.Initialize"; + + /// + /// Cancel the current test run + /// + public const string CancelTestRun = "TestExecution.Cancel"; + + /// + /// Cancel the current test run + /// + public const string AbortTestRun = "TestExecution.Abort"; + + /// + /// Start test execution. + /// + public const string StartTestExecutionWithSources = "TestExecution.StartWithSources"; + + /// + /// Start test execution. + /// + public const string StartTestExecutionWithTests = "TestExecution.StartWithTests"; + + /// + /// The test run stats change. + /// + public const string TestRunStatsChange = "TestExecution.StatsChange"; + + /// + /// The execution complete. + /// + public const string ExecutionComplete = "TestExecution.Completed"; + + /// + /// The message to get runner process startInfo for run all tests in given sources + /// + public const string GetTestRunnerProcessStartInfoForRunAll = "TestExecution.GetTestRunnerProcessStartInfoForRunAll"; + + /// + /// The message to get runner process startInfo for run selected tests + /// + public const string GetTestRunnerProcessStartInfoForRunSelected = "TestExecution.GetTestRunnerProcessStartInfoForRunSelected"; + + /// + /// CustomTestHostLaunch + /// + public const string CustomTestHostLaunch = "TestExecution.CustomTestHostLaunch"; + + /// + /// Custom Test Host launch callback + /// + public const string CustomTestHostLaunchCallback = "TestExecution.CustomTestHostLaunchCallback"; + + /// + /// Test run attachments processing + /// + public const string TestRunAttachmentsProcessingStart = "TestRunAttachmentsProcessing.Start"; + + /// + /// Test run attachments processing callback + /// + public const string TestRunAttachmentsProcessingComplete = "TestRunAttachmentsProcessing.Complete"; + + /// + /// Test run attachments processing progress + /// + public const string TestRunAttachmentsProcessingProgress = "TestRunAttachmentsProcessing.Progress"; + + /// + /// Cancel test run attachments processing + /// + public const string TestRunAttachmentsProcessingCancel = "TestRunAttachmentsProcessing.Cancel"; + + /// + /// Extensions Initialization + /// + public const string ExtensionsInitialize = "Extensions.Initialize"; + + /// + /// Start Test Run All Sources + /// + public const string TestRunAllSourcesWithDefaultHost = "TestExecution.RunAllWithDefaultHost"; + + /// + /// Start Test Run - Testcases + /// + public const string TestRunSelectedTestCasesDefaultHost = "TestExecution.RunSelectedWithDefaultHost"; + + /// + /// Launch Adapter Process With DebuggerAttached + /// + public const string LaunchAdapterProcessWithDebuggerAttached = "TestExecution.LaunchAdapterProcessWithDebuggerAttached"; + + /// + /// Launch Adapter Process With DebuggerAttached + /// + public const string LaunchAdapterProcessWithDebuggerAttachedCallback = "TestExecution.LaunchAdapterProcessWithDebuggerAttachedCallback"; + + /// + /// Attach debugger to process. + /// + public const string AttachDebugger = "TestExecution.AttachDebugger"; + + /// + /// Attach debugger to process callback. + /// + public const string AttachDebuggerCallback = "TestExecution.AttachDebuggerCallback"; + + /// + /// Attach debugger to process. + /// + public const string EditorAttachDebugger = "TestExecution.EditorAttachDebugger"; + + /// + /// Attach debugger to process callback. + /// + public const string EditorAttachDebuggerCallback = "TestExecution.EditorAttachDebuggerCallback"; + + /// + /// Data Collection Message + /// + public const string DataCollectionMessage = "DataCollection.SendMessage"; + + /// + /// StartTestSession message. + /// + public const string StartTestSession = "TestSession.StartTestSession"; + + /// + /// StartTestSession callback message. + /// + public const string StartTestSessionCallback = "TestSession.StartTestSessionCallback"; + + /// + /// StopTestSession message. + /// + public const string StopTestSession = "TestSession.StopTestSession"; + + /// + /// StopTestSession callback message. + /// + public const string StopTestSessionCallback = "TestSession.StopTestSessionCallback"; + + #region DataCollector messages + + /// + /// Event message type sent to datacollector process right after test host process has started. + /// + public const string TestHostLaunched = "DataCollection.TestHostLaunched"; + + /// + /// Event message type send to datacollector process before test run starts. + /// + public const string BeforeTestRunStart = "DataCollection.BeforeTestRunStart"; + + /// + /// Event message type used by datacollector to send results after receiving test run start event. + /// + public const string BeforeTestRunStartResult = "DataCollection.BeforeTestRunStartResult"; + + /// + /// Event message type send to datacollector process after test run ends. + /// + public const string AfterTestRunEnd = "DataCollection.AfterTestRunEnd"; + + /// + /// Event message type used by datacollector to send result on receiving test run end event. + /// + public const string AfterTestRunEndResult = "DataCollection.AfterTestRunEndResult"; + + /// + /// Event message type send to datacollector process before test case execution starts. + /// + public const string DataCollectionTestStart = "DataCollection.TestStart"; + + /// + /// Event message type used to signal datacollector process that test case execution has ended. + /// + public const string DataCollectionTestEnd = "DataCollection.TestEnd"; + + /// + /// Event message type used by datacollector to send result on receiving TestEnd. + /// + public const string DataCollectionTestEndResult = "DataCollection.TestEndResult"; + + /// + /// Ack Event message type send to datacollector process before test case execution starts. + /// + public const string DataCollectionTestStartAck = "DataCollection.TestStartAck"; + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestHostLaunchedPayload.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestHostLaunchedPayload.cs index 203bbb0ea6..f216f20fb6 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestHostLaunchedPayload.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestHostLaunchedPayload.cs @@ -1,16 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel -{ - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; + +using System.Runtime.Serialization; - public class TestHostLaunchedPayload - { - /// - /// Gets or sets the test run process id of test host. - /// - [DataMember] - public int ProcessId { get; set; } - } -} +public class TestHostLaunchedPayload +{ + /// + /// Gets or sets the test run process id of test host. + /// + [DataMember] + public int ProcessId { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestMessagePayload.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestMessagePayload.cs index b5c4e610ed..2f71a32306 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestMessagePayload.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestMessagePayload.cs @@ -1,23 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel -{ - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +/// +/// The test message payload. +/// +public class TestMessagePayload +{ /// - /// The test message payload. + /// Gets or sets the message level. /// - public class TestMessagePayload - { - /// - /// Gets or sets the message level. - /// - public TestMessageLevel MessageLevel { get; set; } + public TestMessageLevel MessageLevel { get; set; } - /// - /// Gets or sets the message. - /// - public string Message { get; set; } - } -} + /// + /// Gets or sets the message. + /// + public string Message { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestRunAttachmentsProcessingCompletePayload.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestRunAttachmentsProcessingCompletePayload.cs index 40ac9c4c8b..3cdd10d75c 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestRunAttachmentsProcessingCompletePayload.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestRunAttachmentsProcessingCompletePayload.cs @@ -1,26 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; + +using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +/// +/// Test run attachments processing complete payload. +/// +public class TestRunAttachmentsProcessingCompletePayload +{ /// - /// Test run attachments processing complete payload. + /// Gets or sets the test run attachments processing complete args. /// - public class TestRunAttachmentsProcessingCompletePayload - { - /// - /// Gets or sets the test run attachments processing complete args. - /// - public TestRunAttachmentsProcessingCompleteEventArgs AttachmentsProcessingCompleteEventArgs { get; set; } + public TestRunAttachmentsProcessingCompleteEventArgs AttachmentsProcessingCompleteEventArgs { get; set; } - /// - /// Gets or sets the attachments. - /// - public IEnumerable Attachments { get; set; } - } -} + /// + /// Gets or sets the attachments. + /// + public IEnumerable Attachments { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestRunAttachmentsProcessingProgressPayload.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestRunAttachmentsProcessingProgressPayload.cs index 80082ae30d..7312b7a3f2 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestRunAttachmentsProcessingProgressPayload.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestRunAttachmentsProcessingProgressPayload.cs @@ -1,18 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel -{ - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +/// +/// Test run attachments processing complete payload. +/// +public class TestRunAttachmentsProcessingProgressPayload +{ /// - /// Test run attachments processing complete payload. + /// Gets or sets the test run attachments processing complete args. /// - public class TestRunAttachmentsProcessingProgressPayload - { - /// - /// Gets or sets the test run attachments processing complete args. - /// - public TestRunAttachmentsProcessingProgressEventArgs AttachmentsProcessingProgressEventArgs { get; set; } - } -} + public TestRunAttachmentsProcessingProgressEventArgs AttachmentsProcessingProgressEventArgs { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestRunCompletePayload.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestRunCompletePayload.cs index 4f708327ae..6cd636e8ae 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestRunCompletePayload.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestRunCompletePayload.cs @@ -1,36 +1,35 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; + +using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +/// +/// The test run complete payload. +/// +public class TestRunCompletePayload +{ /// - /// The test run complete payload. + /// Gets or sets the test run complete args. /// - public class TestRunCompletePayload - { - /// - /// Gets or sets the test run complete args. - /// - public TestRunCompleteEventArgs TestRunCompleteArgs { get; set; } + public TestRunCompleteEventArgs TestRunCompleteArgs { get; set; } - /// - /// Gets or sets the last run tests. - /// - public TestRunChangedEventArgs LastRunTests { get; set; } + /// + /// Gets or sets the last run tests. + /// + public TestRunChangedEventArgs LastRunTests { get; set; } - /// - /// Gets or sets the run attachments. - /// - public ICollection RunAttachments { get; set; } + /// + /// Gets or sets the run attachments. + /// + public ICollection RunAttachments { get; set; } - /// - /// Gets or sets the executor uris that were used to run the tests. - /// - public ICollection ExecutorUris { get; set; } - } -} + /// + /// Gets or sets the executor uris that were used to run the tests. + /// + public ICollection ExecutorUris { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestRunStatsPayload.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestRunStatsPayload.cs index 655c067407..f48cdeb266 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestRunStatsPayload.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/TestRunStatsPayload.cs @@ -1,25 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel -{ - using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; + +using System.Collections.Generic; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +/// +/// The test run stats payload. +/// +public class TestRunStatsPayload +{ /// - /// The test run stats payload. + /// Gets or sets the test run changed event args. /// - public class TestRunStatsPayload - { - /// - /// Gets or sets the test run changed event args. - /// - public TestRunChangedEventArgs TestRunChangedArgs { get; set; } + public TestRunChangedEventArgs TestRunChangedArgs { get; set; } - /// - /// Gets or sets the in progress test cases. - /// - public IEnumerable InProgressTestCases { get; set; } - } -} + /// + /// Gets or sets the in progress test cases. + /// + public IEnumerable InProgressTestCases { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/VersionedMessage.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/VersionedMessage.cs index a48e59cdae..8f4d9a1469 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/VersionedMessage.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Messages/VersionedMessage.cs @@ -1,17 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; + +/// +/// Construct with version used for communication +/// Introduced in 15.1.0 version and default message protocol v2 onwards. +/// +public class VersionedMessage : Message { /// - /// Construct with version used for communication - /// Introduced in 15.1.0 version and default message protocol v2 onwards. + /// Gets or sets the version of the message /// - public class VersionedMessage : Message - { - /// - /// Gets or sets the version of the message - /// - public int Version { get; set; } - } + public int Version { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/ObjectModel/TestRunCriteriaWithSources.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/ObjectModel/TestRunCriteriaWithSources.cs index 96cc0f8bc7..42c19049de 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/ObjectModel/TestRunCriteriaWithSources.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/ObjectModel/TestRunCriteriaWithSources.cs @@ -1,55 +1,54 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; + +using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; - using Newtonsoft.Json; +using Newtonsoft.Json; +/// +/// The test run criteria with sources. +/// +public class TestRunCriteriaWithSources +{ /// - /// The test run criteria with sources. + /// Initializes a new instance of the class. /// - public class TestRunCriteriaWithSources + /// The adapter source map. + /// The package which actually contain sources. A testhost can at max execute for one package at time + /// Package can be null if test source, and package are same + /// + /// The run settings. + /// The test Execution Context. + [JsonConstructor] + public TestRunCriteriaWithSources(Dictionary> adapterSourceMap, string package, string runSettings, TestExecutionContext testExecutionContext) { - /// - /// Initializes a new instance of the class. - /// - /// The adapter source map. - /// The package which actually contain sources. A testhost can at max execute for one package at time - /// Package can be null if test source, and package are same - /// - /// The run settings. - /// The test Execution Context. - [JsonConstructor] - public TestRunCriteriaWithSources(Dictionary> adapterSourceMap, string package, string runSettings, TestExecutionContext testExecutionContext) - { - this.AdapterSourceMap = adapterSourceMap; - this.Package = package; - this.RunSettings = runSettings; - this.TestExecutionContext = testExecutionContext; - } - - /// - /// Gets the adapter source map. - /// - public Dictionary> AdapterSourceMap { get; private set; } - - /// - /// Gets the run settings. - /// - public string RunSettings { get; private set; } - - /// - /// Gets or sets the test execution context. - /// - public TestExecutionContext TestExecutionContext { get; set; } - - /// - /// Gets the test Containers (e.g. .appx, .appxrecipie) - /// - public string Package { get; private set; } + AdapterSourceMap = adapterSourceMap; + Package = package; + RunSettings = runSettings; + TestExecutionContext = testExecutionContext; } + + /// + /// Gets the adapter source map. + /// + public Dictionary> AdapterSourceMap { get; private set; } + + /// + /// Gets the run settings. + /// + public string RunSettings { get; private set; } + + /// + /// Gets or sets the test execution context. + /// + public TestExecutionContext TestExecutionContext { get; set; } + + /// + /// Gets the test Containers (e.g. .appx, .appxrecipie) + /// + public string Package { get; private set; } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/ObjectModel/TestRunCriteriaWithTests.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/ObjectModel/TestRunCriteriaWithTests.cs index fe5337f87b..f4247796ed 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/ObjectModel/TestRunCriteriaWithTests.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/ObjectModel/TestRunCriteriaWithTests.cs @@ -1,57 +1,56 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; + +using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; - using Newtonsoft.Json; +using Newtonsoft.Json; +/// +/// The test run criteria with tests. +/// +public class TestRunCriteriaWithTests +{ /// - /// The test run criteria with tests. + /// Initializes a new instance of the class. + /// Ensure that names of constructor parameters match the public property names of the same for JSON serialization /// - public class TestRunCriteriaWithTests + /// The tests. + /// The package which actually contain sources. A testhost can at max execute for one package at time + /// Package can be null if test source, and package are same + /// + /// The test run settings. + /// The test Execution Context. + [JsonConstructor] + public TestRunCriteriaWithTests(IEnumerable tests, string package, string runSettings, TestExecutionContext testExecutionContext) { - /// - /// Initializes a new instance of the class. - /// Ensure that names of constructor parameters match the public property names of the same for JSON serialization - /// - /// The tests. - /// The package which actually contain sources. A testhost can at max execute for one package at time - /// Package can be null if test source, and package are same - /// - /// The test run settings. - /// The test Execution Context. - [JsonConstructor] - public TestRunCriteriaWithTests(IEnumerable tests, string package, string runSettings, TestExecutionContext testExecutionContext) - { - this.Tests = tests; - this.Package = package; - this.RunSettings = runSettings; - this.TestExecutionContext = testExecutionContext; - } - - /// - /// Gets the tests. - /// - public IEnumerable Tests { get; private set; } - - /// - /// Gets the test run settings. - /// - public string RunSettings { get; private set; } - - /// - /// Gets or sets the test execution context. - /// - public TestExecutionContext TestExecutionContext { get; set; } - - /// - /// Gets the test Containers (e.g. .appx, .appxrecipie) - /// - public string Package { get; private set; } + Tests = tests; + Package = package; + RunSettings = runSettings; + TestExecutionContext = testExecutionContext; } + + /// + /// Gets the tests. + /// + public IEnumerable Tests { get; private set; } + + /// + /// Gets the test run settings. + /// + public string RunSettings { get; private set; } + + /// + /// Gets or sets the test execution context. + /// + public TestExecutionContext TestExecutionContext { get; set; } + + /// + /// Gets the test Containers (e.g. .appx, .appxrecipie) + /// + public string Package { get; private set; } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/DefaultTestPlatformContractResolver.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/DefaultTestPlatformContractResolver.cs index 3b8e3c526f..f16c623826 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/DefaultTestPlatformContractResolver.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/DefaultTestPlatformContractResolver.cs @@ -1,46 +1,45 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization -{ - using System; - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using System; +using System.Collections.Generic; - using Newtonsoft.Json.Serialization; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - /// - /// JSON contract resolver for mapping test platform types. - /// - public class DefaultTestPlatformContractResolver : DefaultContractResolver - { - /// - protected override JsonContract CreateContract(Type objectType) - { - var contract = base.CreateContract(objectType); +using Newtonsoft.Json.Serialization; - if (typeof(List>) == objectType) - { - // ObjectModel.TestObject provides a custom TestProperty based data store for all - // inherited objects. This converter helps with serialization of TestProperty and values - // over the wire. - // Each object inherited from TestObject handles it's own serialization. Most of them use - // this TestProperty data store for members as well. In such cases, we just ignore those - // properties. E.g. TestCase object's CodeFilePath is ignored for serialization since the - // actual data is already getting serialized by this converter. - // OTOH, TestResult has members that are not based off this store. - contract.Converter = new TestObjectConverter(); - } - else if (objectType == typeof(ITestRunStatistics)) - { - // This converter is required to hint json.net to use a concrete class for serialization - // of ITestRunStatistics. We can't remove ITestRunStatistics since it is a breaking change. - contract.Converter = new TestRunStatisticsConverter(); - } +/// +/// JSON contract resolver for mapping test platform types. +/// +public class DefaultTestPlatformContractResolver : DefaultContractResolver +{ + /// + protected override JsonContract CreateContract(Type objectType) + { + var contract = base.CreateContract(objectType); - return contract; + if (typeof(List>) == objectType) + { + // ObjectModel.TestObject provides a custom TestProperty based data store for all + // inherited objects. This converter helps with serialization of TestProperty and values + // over the wire. + // Each object inherited from TestObject handles it's own serialization. Most of them use + // this TestProperty data store for members as well. In such cases, we just ignore those + // properties. E.g. TestCase object's CodeFilePath is ignored for serialization since the + // actual data is already getting serialized by this converter. + // OTOH, TestResult has members that are not based off this store. + contract.Converter = new TestObjectConverter(); + } + else if (objectType == typeof(ITestRunStatistics)) + { + // This converter is required to hint json.net to use a concrete class for serialization + // of ITestRunStatistics. We can't remove ITestRunStatistics since it is a breaking change. + contract.Converter = new TestRunStatisticsConverter(); } + + return contract; } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestCaseConverter.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestCaseConverter.cs index 433154b323..7c3fee88e8 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestCaseConverter.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestCaseConverter.cs @@ -1,156 +1,157 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization; + +using System; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +/// +/// Converter used by v1 protocol serializer to serialize TestCase object to and from v1 json +/// +public class TestCaseConverter : JsonConverter { - using System; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Newtonsoft.Json; - using Newtonsoft.Json.Linq; - - /// - /// Converter used by v1 protocol serializer to serialize TestCase object to and from v1 json - /// - public class TestCaseConverter : JsonConverter + /// + public override bool CanConvert(Type objectType) { - /// - public override bool CanConvert(Type objectType) - { - return typeof(TestCase) == objectType; - } + return typeof(TestCase) == objectType; + } - /// - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - var testCase = new TestCase(); + /// + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + var testCase = new TestCase(); - var data = JObject.Load(reader); - var properties = data["Properties"]; + var data = JObject.Load(reader); + var properties = data["Properties"]; - if (properties != null && properties.HasValues) + if (properties != null && properties.HasValues) + { + // Every class that inherits from TestObject uses a properties store for + // key value pairs. + foreach (var property in properties.Values()) { - // Every class that inherits from TestObject uses a properties store for - // key value pairs. - foreach (var property in properties.Values()) - { - var testProperty = property["Key"].ToObject(serializer); + var testProperty = property["Key"].ToObject(serializer); - // Let the null values be passed in as null data - var token = property["Value"]; - string propertyData = null; - if (token.Type != JTokenType.Null) + // Let the null values be passed in as null data + var token = property["Value"]; + string propertyData = null; + if (token.Type != JTokenType.Null) + { + // If the property is already a string. No need to convert again. + if (token.Type == JTokenType.String) { - // If the property is already a string. No need to convert again. - if (token.Type == JTokenType.String) - { - propertyData = token.ToObject(serializer); - } - else - { - // On deserialization, the value for each TestProperty is always a string. It is up - // to the consumer to deserialize it further as appropriate. - propertyData = token.ToString(Formatting.None).Trim('"'); - } + propertyData = token.ToObject(serializer); } - - switch (testProperty.Id) + else { - case "TestCase.Id": - testCase.Id = Guid.Parse(propertyData); break; - case "TestCase.ExecutorUri": - testCase.ExecutorUri = new Uri(propertyData); break; - case "TestCase.FullyQualifiedName": - testCase.FullyQualifiedName = propertyData; break; - case "TestCase.DisplayName": - testCase.DisplayName = propertyData; break; - case "TestCase.Source": - testCase.Source = propertyData; break; - case "TestCase.CodeFilePath": - testCase.CodeFilePath = propertyData; break; - case "TestCase.LineNumber": - testCase.LineNumber = int.Parse(propertyData); break; - default: - // No need to register member properties as they get registered as part of TestCaseProperties class. - testProperty = TestProperty.Register(testProperty.Id, testProperty.Label, testProperty.GetValueType(), testProperty.Attributes, typeof(TestObject)); - testCase.SetPropertyValue(testProperty, propertyData); - break; + // On deserialization, the value for each TestProperty is always a string. It is up + // to the consumer to deserialize it further as appropriate. + propertyData = token.ToString(Formatting.None).Trim('"'); } } - } - return testCase; - } - - /// - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - // P2 to P1 - var testCase = value as TestCase; - - writer.WriteStartObject(); - writer.WritePropertyName("Properties"); - writer.WriteStartArray(); - - // Version Note: In 15.0.0, if some properties in TestCase were not set, they were not serialized. - // Starting 15.1.0, test platform sends in default values for properties that were not set. This is not - // a breaking change. - - // TestCase.FullyQualifiedName - writer.WriteStartObject(); - AddProperty(writer, TestCaseProperties.FullyQualifiedName, serializer); - writer.WriteValue(testCase.FullyQualifiedName); - writer.WriteEndObject(); - - // TestCase.ExecutorUri - writer.WriteStartObject(); - AddProperty(writer, TestCaseProperties.ExecutorUri, serializer); - writer.WriteValue(testCase.ExecutorUri.OriginalString); - writer.WriteEndObject(); - - // TestCase.Source - writer.WriteStartObject(); - AddProperty(writer, TestCaseProperties.Source, serializer); - writer.WriteValue(testCase.Source); - writer.WriteEndObject(); - - // TestCase.CodeFilePath - writer.WriteStartObject(); - AddProperty(writer, TestCaseProperties.CodeFilePath, serializer); - writer.WriteValue(testCase.CodeFilePath); - writer.WriteEndObject(); - - // TestCase.DisplayName - writer.WriteStartObject(); - AddProperty(writer, TestCaseProperties.DisplayName, serializer); - writer.WriteValue(testCase.DisplayName); - writer.WriteEndObject(); - - // TestCase.Id - writer.WriteStartObject(); - AddProperty(writer, TestCaseProperties.Id, serializer); - writer.WriteValue(testCase.Id); - writer.WriteEndObject(); - - // TestCase.LineNumber - writer.WriteStartObject(); - AddProperty(writer, TestCaseProperties.LineNumber, serializer); - writer.WriteValue(testCase.LineNumber); - writer.WriteEndObject(); - - foreach (var property in testCase.GetProperties()) - { - serializer.Serialize(writer, property); + switch (testProperty.Id) + { + case "TestCase.Id": + testCase.Id = Guid.Parse(propertyData); break; + case "TestCase.ExecutorUri": + testCase.ExecutorUri = new Uri(propertyData); break; + case "TestCase.FullyQualifiedName": + testCase.FullyQualifiedName = propertyData; break; + case "TestCase.DisplayName": + testCase.DisplayName = propertyData; break; + case "TestCase.Source": + testCase.Source = propertyData; break; + case "TestCase.CodeFilePath": + testCase.CodeFilePath = propertyData; break; + case "TestCase.LineNumber": + testCase.LineNumber = int.Parse(propertyData); break; + default: + // No need to register member properties as they get registered as part of TestCaseProperties class. + testProperty = TestProperty.Register(testProperty.Id, testProperty.Label, testProperty.GetValueType(), testProperty.Attributes, typeof(TestObject)); + testCase.SetPropertyValue(testProperty, propertyData); + break; + } } - - writer.WriteEndArray(); - writer.WriteEndObject(); } - private static void AddProperty(JsonWriter writer, TestProperty property, JsonSerializer serializer) + return testCase; + } + + /// + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + // P2 to P1 + var testCase = value as TestCase; + + writer.WriteStartObject(); + writer.WritePropertyName("Properties"); + writer.WriteStartArray(); + + // Version Note: In 15.0.0, if some properties in TestCase were not set, they were not serialized. + // Starting 15.1.0, test platform sends in default values for properties that were not set. This is not + // a breaking change. + + // TestCase.FullyQualifiedName + writer.WriteStartObject(); + AddProperty(writer, TestCaseProperties.FullyQualifiedName, serializer); + writer.WriteValue(testCase.FullyQualifiedName); + writer.WriteEndObject(); + + // TestCase.ExecutorUri + writer.WriteStartObject(); + AddProperty(writer, TestCaseProperties.ExecutorUri, serializer); + writer.WriteValue(testCase.ExecutorUri.OriginalString); + writer.WriteEndObject(); + + // TestCase.Source + writer.WriteStartObject(); + AddProperty(writer, TestCaseProperties.Source, serializer); + writer.WriteValue(testCase.Source); + writer.WriteEndObject(); + + // TestCase.CodeFilePath + writer.WriteStartObject(); + AddProperty(writer, TestCaseProperties.CodeFilePath, serializer); + writer.WriteValue(testCase.CodeFilePath); + writer.WriteEndObject(); + + // TestCase.DisplayName + writer.WriteStartObject(); + AddProperty(writer, TestCaseProperties.DisplayName, serializer); + writer.WriteValue(testCase.DisplayName); + writer.WriteEndObject(); + + // TestCase.Id + writer.WriteStartObject(); + AddProperty(writer, TestCaseProperties.Id, serializer); + writer.WriteValue(testCase.Id); + writer.WriteEndObject(); + + // TestCase.LineNumber + writer.WriteStartObject(); + AddProperty(writer, TestCaseProperties.LineNumber, serializer); + writer.WriteValue(testCase.LineNumber); + writer.WriteEndObject(); + + foreach (var property in testCase.GetProperties()) { - writer.WritePropertyName("Key"); serializer.Serialize(writer, property); - writer.WritePropertyName("Value"); } + + writer.WriteEndArray(); + writer.WriteEndObject(); + } + + private static void AddProperty(JsonWriter writer, TestProperty property, JsonSerializer serializer) + { + writer.WritePropertyName("Key"); + serializer.Serialize(writer, property); + writer.WritePropertyName("Value"); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestObjectConverter.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestObjectConverter.cs index b12b1f5a16..7b34136f5a 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestObjectConverter.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestObjectConverter.cs @@ -1,85 +1,84 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization -{ - using System; - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using System; +using System.Collections.Generic; - using Newtonsoft.Json; - using Newtonsoft.Json.Linq; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; - /// - /// JSON converter for the and derived entities. - /// - public class TestObjectConverter : JsonConverter - { - /// - public override bool CanRead => true; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; - /// - public override bool CanWrite => false; +/// +/// JSON converter for the and derived entities. +/// +public class TestObjectConverter : JsonConverter +{ + /// + public override bool CanRead => true; - /// - public override bool CanConvert(Type objectType) - { - throw new NotImplementedException(); - } + /// + public override bool CanWrite => false; - /// - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + public override bool CanConvert(Type objectType) + { + throw new NotImplementedException(); + } + + /// + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + if (objectType != typeof(List>)) { - if (objectType != typeof(List>)) - { - // Support only deserialization of KeyValuePair list - throw new ArgumentException("the objectType was not a KeyValuePair list", nameof(objectType)); - } + // Support only deserialization of KeyValuePair list + throw new ArgumentException("the objectType was not a KeyValuePair list", nameof(objectType)); + } - var propertyList = new List>(); + var propertyList = new List>(); - if (reader.TokenType == JsonToken.StartArray) + if (reader.TokenType == JsonToken.StartArray) + { + var properties = JArray.Load(reader); + if (properties != null && properties.HasValues) { - var properties = JArray.Load(reader); - if (properties != null && properties.HasValues) + // Every class that inherits from TestObject uses a properties store for + // key value pairs. + foreach (var property in properties) { - // Every class that inherits from TestObject uses a properties store for - // key value pairs. - foreach (var property in properties) - { - var testProperty = property["Key"].ToObject(serializer); + var testProperty = property["Key"].ToObject(serializer); - // Let the null values be passed in as null data - var token = property["Value"]; - object propertyData = null; - if (token.Type != JTokenType.Null) + // Let the null values be passed in as null data + var token = property["Value"]; + object propertyData = null; + if (token.Type != JTokenType.Null) + { + // If the property is already a string. No need to convert again. + if (token.Type == JTokenType.String) { - // If the property is already a string. No need to convert again. - if (token.Type == JTokenType.String) - { - propertyData = token.ToObject(typeof(string), serializer); - } - else - { - // On deserialization, the value for each TestProperty is always a string. It is up - // to the consumer to deserialize it further as appropriate. - propertyData = token.ToString(Formatting.None).Trim('"'); - } + propertyData = token.ToObject(typeof(string), serializer); + } + else + { + // On deserialization, the value for each TestProperty is always a string. It is up + // to the consumer to deserialize it further as appropriate. + propertyData = token.ToString(Formatting.None).Trim('"'); } - - propertyList.Add(new KeyValuePair(testProperty, propertyData)); } + + propertyList.Add(new KeyValuePair(testProperty, propertyData)); } } - - return propertyList; } - /// - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - // Create an array of dictionary - } + return propertyList; + } + + /// + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + // Create an array of dictionary } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestPlatformContractResolver1.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestPlatformContractResolver1.cs index 0f50bd53f0..18870cf72e 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestPlatformContractResolver1.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestPlatformContractResolver1.cs @@ -1,31 +1,32 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization -{ - using System; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Newtonsoft.Json.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization; + +using System; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; - /// - /// JSON contract resolver for mapping test platform types for v1 serialization. - /// - public class TestPlatformContractResolver1 : DefaultTestPlatformContractResolver +using Newtonsoft.Json.Serialization; + +/// +/// JSON contract resolver for mapping test platform types for v1 serialization. +/// +public class TestPlatformContractResolver1 : DefaultTestPlatformContractResolver +{ + /// + protected override JsonContract CreateContract(Type objectType) { - /// - protected override JsonContract CreateContract(Type objectType) + var contract = base.CreateContract(objectType); + if (typeof(TestCase) == objectType) { - var contract = base.CreateContract(objectType); - if (typeof(TestCase) == objectType) - { - contract.Converter = new TestCaseConverter(); - } - else if (typeof(TestResult) == objectType) - { - contract.Converter = new TestResultConverter(); - } - - return contract; + contract.Converter = new TestCaseConverter(); + } + else if (typeof(TestResult) == objectType) + { + contract.Converter = new TestResultConverter(); } + + return contract; } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestResultConverter.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestResultConverter.cs index 1e3aad1bab..3a4a6505e5 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestResultConverter.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestResultConverter.cs @@ -1,198 +1,199 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization; + +using System; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +/// +/// Converter used by v1 protocol serializer to serialize TestResult object to and from v1 json +/// +public class TestResultConverter : JsonConverter { - using System; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Newtonsoft.Json; - using Newtonsoft.Json.Linq; - - /// - /// Converter used by v1 protocol serializer to serialize TestResult object to and from v1 json - /// - public class TestResultConverter : JsonConverter + /// + public override bool CanConvert(Type objectType) { - /// - public override bool CanConvert(Type objectType) - { - return typeof(TestResult) == objectType; - } + return typeof(TestResult) == objectType; + } - /// - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - var data = JObject.Load(reader); + /// + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + var data = JObject.Load(reader); - var testCase = data["TestCase"].ToObject(serializer); - var testResult = new TestResult(testCase); + var testCase = data["TestCase"].ToObject(serializer); + var testResult = new TestResult(testCase); - // Add attachments for the result - var attachments = data["Attachments"]; - if (attachments != null && attachments.HasValues) + // Add attachments for the result + var attachments = data["Attachments"]; + if (attachments != null && attachments.HasValues) + { + foreach (var attachment in attachments.Values()) { - foreach (var attachment in attachments.Values()) + if (attachment.Type != JTokenType.Null) { - if (attachment.Type != JTokenType.Null) - { - testResult.Attachments.Add(attachment.ToObject(serializer)); - } + testResult.Attachments.Add(attachment.ToObject(serializer)); } } + } - // Add messages for the result - var messages = data["Messages"]; - if (messages != null && messages.HasValues) + // Add messages for the result + var messages = data["Messages"]; + if (messages != null && messages.HasValues) + { + foreach (var message in messages.Values()) { - foreach (var message in messages.Values()) + if (message.Type != JTokenType.Null) { - if (message.Type != JTokenType.Null) - { - testResult.Messages.Add(message.ToObject(serializer)); - } + testResult.Messages.Add(message.ToObject(serializer)); } } + } - JToken properties = data["Properties"]; - if (properties != null && properties.HasValues) + JToken properties = data["Properties"]; + if (properties != null && properties.HasValues) + { + // Every class that inherits from TestObject uses a properties store for + // key value pairs. + foreach (var property in properties.Values()) { - // Every class that inherits from TestObject uses a properties store for - // key value pairs. - foreach (var property in properties.Values()) - { - var testProperty = property["Key"].ToObject(serializer); + var testProperty = property["Key"].ToObject(serializer); - // Let the null values be passed in as null data - var token = property["Value"]; - string propertyData = null; - if (token.Type != JTokenType.Null) + // Let the null values be passed in as null data + var token = property["Value"]; + string propertyData = null; + if (token.Type != JTokenType.Null) + { + // If the property is already a string. No need to convert again. + if (token.Type == JTokenType.String) { - // If the property is already a string. No need to convert again. - if (token.Type == JTokenType.String) - { - propertyData = token.ToObject(serializer); - } - else - { - // On deserialization, the value for each TestProperty is always a string. It is up - // to the consumer to deserialize it further as appropriate. - propertyData = token.ToString(Formatting.None).Trim('"'); - } + propertyData = token.ToObject(serializer); } - - switch (testProperty.Id) + else { - case "TestResult.DisplayName": - testResult.DisplayName = propertyData; break; - case "TestResult.ComputerName": - testResult.ComputerName = propertyData ?? string.Empty; break; - case "TestResult.Outcome": - testResult.Outcome = (TestOutcome)Enum.Parse(typeof(TestOutcome), propertyData); break; - case "TestResult.Duration": - testResult.Duration = TimeSpan.Parse(propertyData); break; - case "TestResult.StartTime": - testResult.StartTime = DateTimeOffset.Parse(propertyData); break; - case "TestResult.EndTime": - testResult.EndTime = DateTimeOffset.Parse(propertyData); break; - case "TestResult.ErrorMessage": - testResult.ErrorMessage = propertyData; break; - case "TestResult.ErrorStackTrace": - testResult.ErrorStackTrace = propertyData; break; - default: - // No need to register member properties as they get registered as part of TestResultProperties class. - testProperty = TestProperty.Register(testProperty.Id, testProperty.Label, testProperty.GetValueType(), testProperty.Attributes, typeof(TestObject)); - testResult.SetPropertyValue(testProperty, propertyData); - break; + // On deserialization, the value for each TestProperty is always a string. It is up + // to the consumer to deserialize it further as appropriate. + propertyData = token.ToString(Formatting.None).Trim('"'); } } - } - return testResult; - } - - /// - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - // P2 to P1 - var testResult = value as TestResult; - - writer.WriteStartObject(); - writer.WritePropertyName("TestCase"); - serializer.Serialize(writer, testResult.TestCase); - writer.WritePropertyName("Attachments"); - serializer.Serialize(writer, testResult.Attachments); - writer.WritePropertyName("Messages"); - serializer.Serialize(writer, testResult.Messages); - - writer.WritePropertyName("Properties"); - writer.WriteStartArray(); - - // Version Note: In 15.0.0, if some properties in TestResult were not set, they were not serialized. - // Starting 15.1.0, test platform sends in default values for properties that were not set. This is not - // a breaking change. - - // TestResult.Outcome - writer.WriteStartObject(); - AddProperty(writer, TestResultProperties.Outcome, serializer); - writer.WriteValue((int)testResult.Outcome); - writer.WriteEndObject(); - - // TestResult.ErrorMessage - writer.WriteStartObject(); - AddProperty(writer, TestResultProperties.ErrorMessage, serializer); - writer.WriteValue(testResult.ErrorMessage); - writer.WriteEndObject(); - - // TestResult.ErrorStackTrace - writer.WriteStartObject(); - AddProperty(writer, TestResultProperties.ErrorStackTrace, serializer); - writer.WriteValue(testResult.ErrorStackTrace); - writer.WriteEndObject(); - - // TestResult.DisplayName - writer.WriteStartObject(); - AddProperty(writer, TestResultProperties.DisplayName, serializer); - writer.WriteValue(testResult.DisplayName); - writer.WriteEndObject(); - - // TestResult.ComputerName - writer.WriteStartObject(); - AddProperty(writer, TestResultProperties.ComputerName, serializer); - writer.WriteValue(testResult.ComputerName ?? string.Empty); - writer.WriteEndObject(); - - // TestResult.Duration - writer.WriteStartObject(); - AddProperty(writer, TestResultProperties.Duration, serializer); - writer.WriteValue(testResult.Duration); - writer.WriteEndObject(); - - // TestResult.StartTime - writer.WriteStartObject(); - AddProperty(writer, TestResultProperties.StartTime, serializer); - writer.WriteValue(testResult.StartTime); - writer.WriteEndObject(); - - // TestResult.EndTime - writer.WriteStartObject(); - AddProperty(writer, TestResultProperties.EndTime, serializer); - writer.WriteValue(testResult.EndTime); - writer.WriteEndObject(); - - foreach (var property in testResult.GetProperties()) - { - serializer.Serialize(writer, property); + switch (testProperty.Id) + { + case "TestResult.DisplayName": + testResult.DisplayName = propertyData; break; + case "TestResult.ComputerName": + testResult.ComputerName = propertyData ?? string.Empty; break; + case "TestResult.Outcome": + testResult.Outcome = (TestOutcome)Enum.Parse(typeof(TestOutcome), propertyData); break; + case "TestResult.Duration": + testResult.Duration = TimeSpan.Parse(propertyData); break; + case "TestResult.StartTime": + testResult.StartTime = DateTimeOffset.Parse(propertyData); break; + case "TestResult.EndTime": + testResult.EndTime = DateTimeOffset.Parse(propertyData); break; + case "TestResult.ErrorMessage": + testResult.ErrorMessage = propertyData; break; + case "TestResult.ErrorStackTrace": + testResult.ErrorStackTrace = propertyData; break; + default: + // No need to register member properties as they get registered as part of TestResultProperties class. + testProperty = TestProperty.Register(testProperty.Id, testProperty.Label, testProperty.GetValueType(), testProperty.Attributes, typeof(TestObject)); + testResult.SetPropertyValue(testProperty, propertyData); + break; + } } - - writer.WriteEndArray(); - writer.WriteEndObject(); } - private static void AddProperty(JsonWriter writer, TestProperty property, JsonSerializer serializer) + return testResult; + } + + /// + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + // P2 to P1 + var testResult = value as TestResult; + + writer.WriteStartObject(); + writer.WritePropertyName("TestCase"); + serializer.Serialize(writer, testResult.TestCase); + writer.WritePropertyName("Attachments"); + serializer.Serialize(writer, testResult.Attachments); + writer.WritePropertyName("Messages"); + serializer.Serialize(writer, testResult.Messages); + + writer.WritePropertyName("Properties"); + writer.WriteStartArray(); + + // Version Note: In 15.0.0, if some properties in TestResult were not set, they were not serialized. + // Starting 15.1.0, test platform sends in default values for properties that were not set. This is not + // a breaking change. + + // TestResult.Outcome + writer.WriteStartObject(); + AddProperty(writer, TestResultProperties.Outcome, serializer); + writer.WriteValue((int)testResult.Outcome); + writer.WriteEndObject(); + + // TestResult.ErrorMessage + writer.WriteStartObject(); + AddProperty(writer, TestResultProperties.ErrorMessage, serializer); + writer.WriteValue(testResult.ErrorMessage); + writer.WriteEndObject(); + + // TestResult.ErrorStackTrace + writer.WriteStartObject(); + AddProperty(writer, TestResultProperties.ErrorStackTrace, serializer); + writer.WriteValue(testResult.ErrorStackTrace); + writer.WriteEndObject(); + + // TestResult.DisplayName + writer.WriteStartObject(); + AddProperty(writer, TestResultProperties.DisplayName, serializer); + writer.WriteValue(testResult.DisplayName); + writer.WriteEndObject(); + + // TestResult.ComputerName + writer.WriteStartObject(); + AddProperty(writer, TestResultProperties.ComputerName, serializer); + writer.WriteValue(testResult.ComputerName ?? string.Empty); + writer.WriteEndObject(); + + // TestResult.Duration + writer.WriteStartObject(); + AddProperty(writer, TestResultProperties.Duration, serializer); + writer.WriteValue(testResult.Duration); + writer.WriteEndObject(); + + // TestResult.StartTime + writer.WriteStartObject(); + AddProperty(writer, TestResultProperties.StartTime, serializer); + writer.WriteValue(testResult.StartTime); + writer.WriteEndObject(); + + // TestResult.EndTime + writer.WriteStartObject(); + AddProperty(writer, TestResultProperties.EndTime, serializer); + writer.WriteValue(testResult.EndTime); + writer.WriteEndObject(); + + foreach (var property in testResult.GetProperties()) { - writer.WritePropertyName("Key"); serializer.Serialize(writer, property); - writer.WritePropertyName("Value"); } + + writer.WriteEndArray(); + writer.WriteEndObject(); + } + + private static void AddProperty(JsonWriter writer, TestProperty property, JsonSerializer serializer) + { + writer.WritePropertyName("Key"); + serializer.Serialize(writer, property); + writer.WritePropertyName("Value"); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestRunStatisticsConverter.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestRunStatisticsConverter.cs index 84ab32da58..5326905deb 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestRunStatisticsConverter.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestRunStatisticsConverter.cs @@ -1,33 +1,34 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization -{ - using System; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Newtonsoft.Json; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization; + +using System; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - /// - /// JSON converter for converting ITestRunStatistics to TestRunStatistics - /// - public class TestRunStatisticsConverter : JsonConverter +using Newtonsoft.Json; + +/// +/// JSON converter for converting ITestRunStatistics to TestRunStatistics +/// +public class TestRunStatisticsConverter : JsonConverter +{ + /// + public override bool CanConvert(Type objectType) { - /// - public override bool CanConvert(Type objectType) - { - return objectType.Equals(typeof(TestRunStatistics)); - } + return objectType.Equals(typeof(TestRunStatistics)); + } - /// - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - return serializer.Deserialize(reader); - } + /// + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + return serializer.Deserialize(reader); + } - /// - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - serializer.Serialize(writer, value); - } + /// + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + serializer.Serialize(writer, value); } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/SocketClient.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/SocketClient.cs index 7059a538bc..bc3d8d6269 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/SocketClient.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/SocketClient.cs @@ -1,132 +1,133 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; + +using System; +using System.IO; +using System.Net.Sockets; +using System.Threading; +using System.Threading.Tasks; + +using Interfaces; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using Utilities; + +/// +/// Communication client implementation over sockets. +/// +public class SocketClient : ICommunicationEndPoint { - using System; - using System.IO; - using System.Net; - using System.Net.Sockets; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities; - - /// - /// Communication client implementation over sockets. - /// - public class SocketClient : ICommunicationEndPoint + private readonly CancellationTokenSource _cancellation; + private readonly TcpClient _tcpClient; + private readonly Func _channelFactory; + private ICommunicationChannel _channel; + private bool _stopped; + private string _endPoint; + + public SocketClient() + : this(stream => new LengthPrefixCommunicationChannel(stream)) { - private readonly CancellationTokenSource cancellation; - private readonly TcpClient tcpClient; - private readonly Func channelFactory; - private ICommunicationChannel channel; - private bool stopped; - private string endPoint; - - public SocketClient() - : this(stream => new LengthPrefixCommunicationChannel(stream)) - { - } + } - protected SocketClient(Func channelFactory) - { - // Used to cancel the message loop - this.cancellation = new CancellationTokenSource(); - this.stopped = false; + protected SocketClient(Func channelFactory) + { + // Used to cancel the message loop + _cancellation = new CancellationTokenSource(); + _stopped = false; - this.tcpClient = new TcpClient { NoDelay = true }; - this.channelFactory = channelFactory; - } + _tcpClient = new TcpClient { NoDelay = true }; + _channelFactory = channelFactory; + } - /// - public event EventHandler Connected; + /// + public event EventHandler Connected; - /// - public event EventHandler Disconnected; + /// + public event EventHandler Disconnected; - /// - public string Start(string endPoint) - { - this.endPoint = endPoint; - var ipEndPoint = endPoint.GetIPEndPoint(); + /// + public string Start(string endPoint) + { + _endPoint = endPoint; + var ipEndPoint = endPoint.GetIpEndPoint(); - EqtTrace.Info("SocketClient.Start: connecting to server endpoint: {0}", endPoint); + EqtTrace.Info("SocketClient.Start: connecting to server endpoint: {0}", endPoint); - // Don't start if the endPoint port is zero - this.tcpClient.ConnectAsync(ipEndPoint.Address, ipEndPoint.Port).ContinueWith(this.OnServerConnected); - return ipEndPoint.ToString(); - } + // Don't start if the endPoint port is zero + _tcpClient.ConnectAsync(ipEndPoint.Address, ipEndPoint.Port).ContinueWith(OnServerConnected); + return ipEndPoint.ToString(); + } - /// - public void Stop() - { - EqtTrace.Info("SocketClient.Stop: Stop communication from server endpoint: {0}", this.endPoint); + /// + public void Stop() + { + EqtTrace.Info("SocketClient.Stop: Stop communication from server endpoint: {0}", _endPoint); - if (!this.stopped) - { - EqtTrace.Info("SocketClient: Stop: Cancellation requested. Stopping message loop."); - this.cancellation.Cancel(); - } + if (!_stopped) + { + EqtTrace.Info("SocketClient: Stop: Cancellation requested. Stopping message loop."); + _cancellation.Cancel(); } + } - private void OnServerConnected(Task connectAsyncTask) - { - EqtTrace.Info("SocketClient.OnServerConnected: connected to server endpoint: {0}", this.endPoint); + private void OnServerConnected(Task connectAsyncTask) + { + EqtTrace.Info("SocketClient.OnServerConnected: connected to server endpoint: {0}", _endPoint); - if (this.Connected != null) + if (Connected != null) + { + if (connectAsyncTask.IsFaulted) { - if (connectAsyncTask.IsFaulted) + Connected.SafeInvoke(this, new ConnectedEventArgs(connectAsyncTask.Exception), "SocketClient: Server Failed to Connect"); + if (EqtTrace.IsVerboseEnabled) { - this.Connected.SafeInvoke(this, new ConnectedEventArgs(connectAsyncTask.Exception), "SocketClient: Server Failed to Connect"); - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("Unable to connect to server, Exception occurred : {0}", connectAsyncTask.Exception); - } + EqtTrace.Verbose("Unable to connect to server, Exception occurred : {0}", connectAsyncTask.Exception); } - else + } + else + { + _channel = _channelFactory(_tcpClient.GetStream()); + Connected.SafeInvoke(this, new ConnectedEventArgs(_channel), "SocketClient: ServerConnected"); + + if (EqtTrace.IsVerboseEnabled) { - this.channel = this.channelFactory(this.tcpClient.GetStream()); - this.Connected.SafeInvoke(this, new ConnectedEventArgs(this.channel), "SocketClient: ServerConnected"); - - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("Connected to server, and starting MessageLoopAsync"); - } - - // Start the message loop - Task.Run(() => this.tcpClient.MessageLoopAsync( - this.channel, - this.Stop, - this.cancellation.Token)) - .ConfigureAwait(false); + EqtTrace.Verbose("Connected to server, and starting MessageLoopAsync"); } + + // Start the message loop + Task.Run(() => _tcpClient.MessageLoopAsync( + _channel, + Stop, + _cancellation.Token)) + .ConfigureAwait(false); } } + } - private void Stop(Exception error) - { - EqtTrace.Info("SocketClient.PrivateStop: Stop communication from server endpoint: {0}, error:{1}", this.endPoint, error); + private void Stop(Exception error) + { + EqtTrace.Info("SocketClient.PrivateStop: Stop communication from server endpoint: {0}, error:{1}", _endPoint, error); - if (!this.stopped) - { - // Do not allow stop to be called multiple times. - this.stopped = true; + if (!_stopped) + { + // Do not allow stop to be called multiple times. + _stopped = true; - // Close the client and dispose the underlying stream + // Close the client and dispose the underlying stream #if NETFRAMEWORK - // tcpClient.Close() calls tcpClient.Dispose(). - this.tcpClient?.Close(); + // tcpClient.Close() calls tcpClient.Dispose(). + _tcpClient?.Close(); #else - // tcpClient.Close() not available for netstandard1.5. - this.tcpClient?.Dispose(); + // tcpClient.Close() not available for netstandard1.5. + _tcpClient?.Dispose(); #endif - this.channel.Dispose(); - this.cancellation.Dispose(); + _channel.Dispose(); + _cancellation.Dispose(); - this.Disconnected?.SafeInvoke(this, new DisconnectedEventArgs(), "SocketClient: ServerDisconnected"); - } + Disconnected?.SafeInvoke(this, new DisconnectedEventArgs(), "SocketClient: ServerDisconnected"); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/SocketCommunicationManager.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/SocketCommunicationManager.cs index f9209e20f1..325f0c58d5 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/SocketCommunicationManager.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/SocketCommunicationManager.cs @@ -1,415 +1,415 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; + +using System; +using System.Diagnostics; +using System.IO; +using System.Net; +using System.Net.Sockets; +using System.Threading; +using System.Threading.Tasks; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +/// +/// Facilitates communication using sockets +/// +public class SocketCommunicationManager : ICommunicationManager { - using System; - using System.Diagnostics; - using System.IO; - using System.Net; - using System.Net.Sockets; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + /// + /// The server stream read timeout constant (in microseconds). + /// + private const int STREAMREADTIMEOUT = 1000 * 1000; + + /// + /// TCP Listener to host TCP channel and listen + /// + private TcpListener _tcpListener; + + /// + /// TCP Client that can connect to a TCP listener + /// + private TcpClient _tcpClient; + + /// + /// Binary Writer to write to channel stream + /// + private BinaryWriter _binaryWriter; /// - /// Facilitates communication using sockets + /// Binary reader to read from channel stream /// - public class SocketCommunicationManager : ICommunicationManager + private BinaryReader _binaryReader; + + /// + /// Serializer for the data objects + /// + private readonly IDataSerializer _dataSerializer; + + /// + /// Event used to maintain client connection state + /// + private readonly ManualResetEvent _clientConnectedEvent = new(false); + + /// + /// Event used to maintain client connection state + /// + private readonly ManualResetEvent _clientConnectionAcceptedEvent = new(false); + + /// + /// Sync object for sending messages + /// SendMessage over socket channel is NOT thread-safe + /// + private readonly object _sendSyncObject = new(); + + /// + /// Sync object for receiving messages + /// + private readonly object _receiveSyncObject = new(); + + private Socket _socket; + + /// + /// Initializes a new instance of the class. + /// + public SocketCommunicationManager() + : this(JsonDataSerializer.Instance) { - /// - /// The server stream read timeout constant (in microseconds). - /// - private const int STREAMREADTIMEOUT = 1000 * 1000; - - /// - /// TCP Listener to host TCP channel and listen - /// - private TcpListener tcpListener; - - /// - /// TCP Client that can connect to a TCP listener - /// - private TcpClient tcpClient; - - /// - /// Binary Writer to write to channel stream - /// - private BinaryWriter binaryWriter; - - /// - /// Binary reader to read from channel stream - /// - private BinaryReader binaryReader; - - /// - /// Serializer for the data objects - /// - private IDataSerializer dataSerializer; - - /// - /// Event used to maintain client connection state - /// - private ManualResetEvent clientConnectedEvent = new ManualResetEvent(false); - - /// - /// Event used to maintain client connection state - /// - private ManualResetEvent clientConnectionAcceptedEvent = new ManualResetEvent(false); - - /// - /// Sync object for sending messages - /// SendMessage over socket channel is NOT thread-safe - /// - private object sendSyncObject = new object(); - - /// - /// Sync object for receiving messages - /// - private object receiveSyncObject = new object(); - - private Socket socket; - - /// - /// Initializes a new instance of the class. - /// - public SocketCommunicationManager() - : this(JsonDataSerializer.Instance) - { - } + } - internal SocketCommunicationManager(IDataSerializer dataSerializer) - { - this.dataSerializer = dataSerializer; - } + internal SocketCommunicationManager(IDataSerializer dataSerializer) + { + _dataSerializer = dataSerializer; + } - #region ServerMethods + #region ServerMethods - /// - /// Host TCP Socket Server and start listening - /// - /// End point where server is hosted - /// Port of the listener - public IPEndPoint HostServer(IPEndPoint endpoint) - { - this.tcpListener = new TcpListener(endpoint); - this.tcpListener.Start(); - EqtTrace.Info("Listening on Endpoint : {0}", (IPEndPoint)this.tcpListener.LocalEndpoint); + /// + /// Host TCP Socket Server and start listening + /// + /// End point where server is hosted + /// Port of the listener + public IPEndPoint HostServer(IPEndPoint endpoint) + { + _tcpListener = new TcpListener(endpoint); + _tcpListener.Start(); + EqtTrace.Info("Listening on Endpoint : {0}", (IPEndPoint)_tcpListener.LocalEndpoint); - return (IPEndPoint)this.tcpListener.LocalEndpoint; - } + return (IPEndPoint)_tcpListener.LocalEndpoint; + } - /// - /// Accepts client async - /// - /// A representing the asynchronous operation. - public async Task AcceptClientAsync() + /// + /// Accepts client async + /// + /// A representing the asynchronous operation. + public async Task AcceptClientAsync() + { + if (_tcpListener != null) { - if (this.tcpListener != null) - { - this.clientConnectedEvent.Reset(); + _clientConnectedEvent.Reset(); - var client = await this.tcpListener.AcceptTcpClientAsync(); - this.socket = client.Client; - this.socket.NoDelay = true; + var client = await _tcpListener.AcceptTcpClientAsync(); + _socket = client.Client; + _socket.NoDelay = true; - // Using Buffered stream only in case of write, and Network stream in case of read. - var bufferedStream = new PlatformStream().CreateBufferedStream(client.GetStream(), SocketConstants.BufferSize); - var networkStream = client.GetStream(); - this.binaryReader = new BinaryReader(networkStream); - this.binaryWriter = new BinaryWriter(bufferedStream); + // Using Buffered stream only in case of write, and Network stream in case of read. + var bufferedStream = new PlatformStream().CreateBufferedStream(client.GetStream(), SocketConstants.BufferSize); + var networkStream = client.GetStream(); + _binaryReader = new BinaryReader(networkStream); + _binaryWriter = new BinaryWriter(bufferedStream); - this.clientConnectedEvent.Set(); - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("Using the buffer size of {0} bytes", SocketConstants.BufferSize); - EqtTrace.Info("Accepted Client request and set the flag"); - } + _clientConnectedEvent.Set(); + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("Using the buffer size of {0} bytes", SocketConstants.BufferSize); + EqtTrace.Info("Accepted Client request and set the flag"); } } + } - /// - /// Waits for Client Connection - /// - /// Time to Wait for the connection - /// True if Client is connected, false otherwise - public bool WaitForClientConnection(int clientConnectionTimeout) - { - return this.clientConnectedEvent.WaitOne(clientConnectionTimeout); - } + /// + /// Waits for Client Connection + /// + /// Time to Wait for the connection + /// True if Client is connected, false otherwise + public bool WaitForClientConnection(int clientConnectionTimeout) + { + return _clientConnectedEvent.WaitOne(clientConnectionTimeout); + } - /// - /// Stop Listener - /// - public void StopServer() - { - this.tcpListener?.Stop(); - this.tcpListener = null; - this.binaryReader?.Dispose(); - this.binaryWriter?.Dispose(); - } + /// + /// Stop Listener + /// + public void StopServer() + { + _tcpListener?.Stop(); + _tcpListener = null; + _binaryReader?.Dispose(); + _binaryWriter?.Dispose(); + } - #endregion + #endregion - #region ClientMethods + #region ClientMethods - /// - /// Connects to server async - /// - /// EndPointAddress for client to connect - /// A representing the asynchronous operation. - public async Task SetupClientAsync(IPEndPoint endpoint) + /// + /// Connects to server async + /// + /// EndPointAddress for client to connect + /// A representing the asynchronous operation. + public async Task SetupClientAsync(IPEndPoint endpoint) + { + // TODO: pass cancellation token, if user cancels the operation, so we don't wait 50 secs to connect + // for now added a check for validation of this.tcpclient + _clientConnectionAcceptedEvent.Reset(); + EqtTrace.Info("Trying to connect to server on socket : {0} ", endpoint); + _tcpClient = new TcpClient { NoDelay = true }; + _socket = _tcpClient.Client; + + Stopwatch watch = new(); + watch.Start(); + var connectionTimeout = EnvironmentHelper.GetConnectionTimeout() * 1000; + do { - // TODO: pass cancellation token, if user cancels the operation, so we don't wait 50 secs to connect - // for now added a check for validation of this.tcpclient - this.clientConnectionAcceptedEvent.Reset(); - EqtTrace.Info("Trying to connect to server on socket : {0} ", endpoint); - this.tcpClient = new TcpClient { NoDelay = true }; - this.socket = this.tcpClient.Client; - - Stopwatch watch = new Stopwatch(); - watch.Start(); - var connectionTimeout = EnvironmentHelper.GetConnectionTimeout() * 1000; - do + try { - try + EqtTrace.Verbose("SocketCommunicationManager : SetupClientAsync : Attempting to connect to the server."); + await _tcpClient.ConnectAsync(endpoint.Address, endpoint.Port); + + if (_tcpClient.Connected) { - EqtTrace.Verbose("SocketCommunicationManager : SetupClientAsync : Attempting to connect to the server."); - await this.tcpClient.ConnectAsync(endpoint.Address, endpoint.Port); + // Using Buffered stream only in case of write, and Network stream in case of read. + var bufferedStream = new PlatformStream().CreateBufferedStream(_tcpClient.GetStream(), SocketConstants.BufferSize); + var networkStream = _tcpClient.GetStream(); + _binaryReader = new BinaryReader(networkStream); + _binaryWriter = new BinaryWriter(bufferedStream); - if (this.tcpClient.Connected) + if (EqtTrace.IsInfoEnabled) { - // Using Buffered stream only in case of write, and Network stream in case of read. - var bufferedStream = new PlatformStream().CreateBufferedStream(this.tcpClient.GetStream(), SocketConstants.BufferSize); - var networkStream = this.tcpClient.GetStream(); - this.binaryReader = new BinaryReader(networkStream); - this.binaryWriter = new BinaryWriter(bufferedStream); - - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("Connected to the server successfully "); - EqtTrace.Info("Using the buffer size of {0} bytes", SocketConstants.BufferSize); - } - - this.clientConnectionAcceptedEvent.Set(); + EqtTrace.Info("Connected to the server successfully "); + EqtTrace.Info("Using the buffer size of {0} bytes", SocketConstants.BufferSize); } + + _clientConnectionAcceptedEvent.Set(); } - catch (Exception ex) - { - EqtTrace.Error("Connection Failed with error {0}, retrying", ex.ToString()); - } } - while ((this.tcpClient != null) && !this.tcpClient.Connected && watch.ElapsedMilliseconds < connectionTimeout); + catch (Exception ex) + { + EqtTrace.Error("Connection Failed with error {0}, retrying", ex.ToString()); + } } + while ((_tcpClient != null) && !_tcpClient.Connected && watch.ElapsedMilliseconds < connectionTimeout); + } - /// - /// Waits for server to be connected - /// Whoever creating the client and trying to connect to a server - /// should use this method to wait for connection to be established with server - /// - /// Time to wait for the connection - /// True, if Server got a connection from client - public bool WaitForServerConnection(int connectionTimeout) - { - return this.clientConnectionAcceptedEvent.WaitOne(connectionTimeout); - } + /// + /// Waits for server to be connected + /// Whoever creating the client and trying to connect to a server + /// should use this method to wait for connection to be established with server + /// + /// Time to wait for the connection + /// True, if Server got a connection from client + public bool WaitForServerConnection(int connectionTimeout) + { + return _clientConnectionAcceptedEvent.WaitOne(connectionTimeout); + } - /// - /// Stop Listener - /// - public void StopClient() - { + /// + /// Stop Listener + /// + public void StopClient() + { #if NETFRAMEWORK - // tcpClient.Close() calls tcpClient.Dispose(). - this.tcpClient?.Close(); + // tcpClient.Close() calls tcpClient.Dispose(). + _tcpClient?.Close(); #else - // tcpClient.Close() not available for netstandard1.5. - this.tcpClient?.Dispose(); + // tcpClient.Close() not available for netstandard1.5. + _tcpClient?.Dispose(); #endif - this.tcpClient = null; - this.binaryReader?.Dispose(); - this.binaryWriter?.Dispose(); - } + _tcpClient = null; + _binaryReader?.Dispose(); + _binaryWriter?.Dispose(); + } - #endregion + #endregion - /// - /// Writes message to the binary writer. - /// - /// Type of Message to be sent, for instance TestSessionStart - public void SendMessage(string messageType) - { - var serializedObject = this.dataSerializer.SerializeMessage(messageType); - this.WriteAndFlushToChannel(serializedObject); - } + /// + /// Writes message to the binary writer. + /// + /// Type of Message to be sent, for instance TestSessionStart + public void SendMessage(string messageType) + { + var serializedObject = _dataSerializer.SerializeMessage(messageType); + WriteAndFlushToChannel(serializedObject); + } - /// - /// Writes message to the binary writer with payload - /// - /// Type of Message to be sent, for instance TestSessionStart - /// payload to be sent - public void SendMessage(string messageType, object payload) - { - var rawMessage = this.dataSerializer.SerializePayload(messageType, payload); - this.WriteAndFlushToChannel(rawMessage); - } + /// + /// Writes message to the binary writer with payload + /// + /// Type of Message to be sent, for instance TestSessionStart + /// payload to be sent + public void SendMessage(string messageType, object payload) + { + var rawMessage = _dataSerializer.SerializePayload(messageType, payload); + WriteAndFlushToChannel(rawMessage); + } - /// - /// Writes message to the binary writer with payload - /// - /// Type of Message to be sent, for instance TestSessionStart - /// payload to be sent - /// version to be sent - public void SendMessage(string messageType, object payload, int version) - { - var rawMessage = this.dataSerializer.SerializePayload(messageType, payload, version); - this.WriteAndFlushToChannel(rawMessage); - } + /// + /// Writes message to the binary writer with payload + /// + /// Type of Message to be sent, for instance TestSessionStart + /// payload to be sent + /// version to be sent + public void SendMessage(string messageType, object payload, int version) + { + var rawMessage = _dataSerializer.SerializePayload(messageType, payload, version); + WriteAndFlushToChannel(rawMessage); + } - /// - /// Send serialized raw message - /// - /// serialized message - public void SendRawMessage(string rawMessage) - { - this.WriteAndFlushToChannel(rawMessage); - } + /// + /// Send serialized raw message + /// + /// serialized message + public void SendRawMessage(string rawMessage) + { + WriteAndFlushToChannel(rawMessage); + } - /// - /// Reads message from the binary reader - /// - /// Returns message read from the binary reader - public Message ReceiveMessage() + /// + /// Reads message from the binary reader + /// + /// Returns message read from the binary reader + public Message ReceiveMessage() + { + var rawMessage = ReceiveRawMessage(); + if (!string.IsNullOrEmpty(rawMessage)) { - var rawMessage = this.ReceiveRawMessage(); - if (!string.IsNullOrEmpty(rawMessage)) - { - return this.dataSerializer.DeserializeMessage(rawMessage); - } - - return null; + return _dataSerializer.DeserializeMessage(rawMessage); } - /// - /// Reads message from the binary reader using read timeout - /// - /// - /// The cancellation Token. - /// - /// - /// Returns message read from the binary reader - /// - public async Task ReceiveMessageAsync(CancellationToken cancellationToken) - { - var rawMessage = await this.ReceiveRawMessageAsync(cancellationToken); - if (!string.IsNullOrEmpty(rawMessage)) - { - return this.dataSerializer.DeserializeMessage(rawMessage); - } - - return null; - } + return null; + } - /// - /// Reads message from the binary reader - /// - /// Raw message string - public string ReceiveRawMessage() + /// + /// Reads message from the binary reader using read timeout + /// + /// + /// The cancellation Token. + /// + /// + /// Returns message read from the binary reader + /// + public async Task ReceiveMessageAsync(CancellationToken cancellationToken) + { + var rawMessage = await ReceiveRawMessageAsync(cancellationToken); + if (!string.IsNullOrEmpty(rawMessage)) { - lock (this.receiveSyncObject) - { - // Reading message on binaryreader is not thread-safe - return this.binaryReader?.ReadString(); - } + return _dataSerializer.DeserializeMessage(rawMessage); } - /// - /// Reads message from the binary reader using read timeout - /// - /// - /// The cancellation Token. - /// - /// - /// Raw message string - /// - public async Task ReceiveRawMessageAsync(CancellationToken cancellationToken) - { - var str = await Task.Run(() => this.TryReceiveRawMessage(cancellationToken)); - return str; - } + return null; + } - /// - /// Deserializes the Message into actual TestPlatform objects - /// - /// The type of object to deserialize to. - /// Message object - /// TestPlatform object - public T DeserializePayload(Message message) + /// + /// Reads message from the binary reader + /// + /// Raw message string + public string ReceiveRawMessage() + { + lock (_receiveSyncObject) { - return this.dataSerializer.DeserializePayload(message); + // Reading message on binaryreader is not thread-safe + return _binaryReader?.ReadString(); } + } - private string TryReceiveRawMessage(CancellationToken cancellationToken) - { - string str = null; - bool success = false; + /// + /// Reads message from the binary reader using read timeout + /// + /// + /// The cancellation Token. + /// + /// + /// Raw message string + /// + public async Task ReceiveRawMessageAsync(CancellationToken cancellationToken) + { + var str = await Task.Run(() => TryReceiveRawMessage(cancellationToken)); + return str; + } + + /// + /// Deserializes the Message into actual TestPlatform objects + /// + /// The type of object to deserialize to. + /// Message object + /// TestPlatform object + public T DeserializePayload(Message message) + { + return _dataSerializer.DeserializePayload(message); + } - // Set read timeout to avoid blocking receive raw message - while (!cancellationToken.IsCancellationRequested && !success) + private string TryReceiveRawMessage(CancellationToken cancellationToken) + { + string str = null; + bool success = false; + + // Set read timeout to avoid blocking receive raw message + while (!cancellationToken.IsCancellationRequested && !success) + { + try { - try + if (_socket.Poll(STREAMREADTIMEOUT, SelectMode.SelectRead)) { - if (this.socket.Poll(STREAMREADTIMEOUT, SelectMode.SelectRead)) - { - str = this.ReceiveRawMessage(); - success = true; - } + str = ReceiveRawMessage(); + success = true; } - catch (IOException ioException) + } + catch (IOException ioException) + { + if (ioException.InnerException is SocketException socketException + && socketException.SocketErrorCode == SocketError.TimedOut) { - if (ioException.InnerException is SocketException socketException - && socketException.SocketErrorCode == SocketError.TimedOut) - { - EqtTrace.Info( - "SocketCommunicationManager ReceiveMessage: failed to receive message because read timeout {0}", - ioException); - } - else - { - EqtTrace.Error( - "SocketCommunicationManager ReceiveMessage: failed to receive message {0}", - ioException); - break; - } + EqtTrace.Info( + "SocketCommunicationManager ReceiveMessage: failed to receive message because read timeout {0}", + ioException); } - catch (Exception exception) + else { EqtTrace.Error( "SocketCommunicationManager ReceiveMessage: failed to receive message {0}", - exception); + ioException); break; } } - - return str; + catch (Exception exception) + { + EqtTrace.Error( + "SocketCommunicationManager ReceiveMessage: failed to receive message {0}", + exception); + break; + } } - /// - /// Writes the data on socket and flushes the buffer - /// - /// message to write - private void WriteAndFlushToChannel(string rawMessage) + return str; + } + + /// + /// Writes the data on socket and flushes the buffer + /// + /// message to write + private void WriteAndFlushToChannel(string rawMessage) + { + // Writing Message on binarywriter is not Thread-Safe + // Need to sync one by one to avoid buffer corruption + lock (_sendSyncObject) { - // Writing Message on binarywriter is not Thread-Safe - // Need to sync one by one to avoid buffer corruption - lock (this.sendSyncObject) - { - this.binaryWriter?.Write(rawMessage); - this.binaryWriter?.Flush(); - } + _binaryWriter?.Write(rawMessage); + _binaryWriter?.Flush(); } } } diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/SocketConstants.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/SocketConstants.cs index 4279445ee9..c4d1858637 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/SocketConstants.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/SocketConstants.cs @@ -1,11 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; + +public class SocketConstants { - public class SocketConstants - { - // Buffer size for the buffered stream we are using. - public const int BufferSize = 16384; - } -} + // Buffer size for the buffered stream we are using. + public const int BufferSize = 16384; +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/SocketServer.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/SocketServer.cs index ecfc134bec..7a01775836 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/SocketServer.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/SocketServer.cs @@ -1,135 +1,137 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities -{ - using System; - using System.IO; - using System.Net.Sockets; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - /// - /// Communication server implementation over sockets. - /// - public class SocketServer : ICommunicationEndPoint - { - private readonly CancellationTokenSource cancellation; +using System; +using System.IO; +using System.Net.Sockets; +using System.Threading; +using System.Threading.Tasks; + +using Interfaces; - private readonly Func channelFactory; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; - private ICommunicationChannel channel; +using Utilities; - private TcpListener tcpListener; +/// +/// Communication server implementation over sockets. +/// +public class SocketServer : ICommunicationEndPoint +{ + private readonly CancellationTokenSource _cancellation; - private TcpClient tcpClient; + private readonly Func _channelFactory; - private bool stopped; + private ICommunicationChannel _channel; - private string endPoint; + private TcpListener _tcpListener; - /// - /// Initializes a new instance of the class. - /// - public SocketServer() - : this(stream => new LengthPrefixCommunicationChannel(stream)) - { - } + private TcpClient _tcpClient; - /// - /// Initializes a new instance of the class with given channel - /// factory implementation. - /// - /// Factory to create communication channel. - protected SocketServer(Func channelFactory) - { - // Used to cancel the message loop - this.cancellation = new CancellationTokenSource(); + private bool _stopped; - this.channelFactory = channelFactory; - } + private string _endPoint; - /// - public event EventHandler Connected; + /// + /// Initializes a new instance of the class. + /// + public SocketServer() + : this(stream => new LengthPrefixCommunicationChannel(stream)) + { + } - /// - public event EventHandler Disconnected; + /// + /// Initializes a new instance of the class with given channel + /// factory implementation. + /// + /// Factory to create communication channel. + protected SocketServer(Func channelFactory) + { + // Used to cancel the message loop + _cancellation = new CancellationTokenSource(); - public string Start(string endPoint) - { - this.tcpListener = new TcpListener(endPoint.GetIPEndPoint()); + _channelFactory = channelFactory; + } - this.tcpListener.Start(); + /// + public event EventHandler Connected; - this.endPoint = this.tcpListener.LocalEndpoint.ToString(); - EqtTrace.Info("SocketServer.Start: Listening on endpoint : {0}", this.endPoint); + /// + public event EventHandler Disconnected; - // Serves a single client at the moment. An error in connection, or message loop just - // terminates the entire server. - this.tcpListener.AcceptTcpClientAsync().ContinueWith(t => this.OnClientConnected(t.Result)); - return this.endPoint; - } + public string Start(string endPoint) + { + _tcpListener = new TcpListener(endPoint.GetIpEndPoint()); + + _tcpListener.Start(); + + _endPoint = _tcpListener.LocalEndpoint.ToString(); + EqtTrace.Info("SocketServer.Start: Listening on endpoint : {0}", _endPoint); + + // Serves a single client at the moment. An error in connection, or message loop just + // terminates the entire server. + _tcpListener.AcceptTcpClientAsync().ContinueWith(t => OnClientConnected(t.Result)); + return _endPoint; + } - /// - public void Stop() + /// + public void Stop() + { + EqtTrace.Info("SocketServer.Stop: Stop server endPoint: {0}", _endPoint); + if (!_stopped) { - EqtTrace.Info("SocketServer.Stop: Stop server endPoint: {0}", this.endPoint); - if (!this.stopped) - { - EqtTrace.Info("SocketServer.Stop: Cancellation requested. Stopping message loop."); - this.cancellation.Cancel(); - } + EqtTrace.Info("SocketServer.Stop: Cancellation requested. Stopping message loop."); + _cancellation.Cancel(); } + } + + private void OnClientConnected(TcpClient client) + { + _tcpClient = client; + _tcpClient.Client.NoDelay = true; - private void OnClientConnected(TcpClient client) + if (Connected != null) { - this.tcpClient = client; - this.tcpClient.Client.NoDelay = true; + _channel = _channelFactory(_tcpClient.GetStream()); + Connected.SafeInvoke(this, new ConnectedEventArgs(_channel), "SocketServer: ClientConnected"); - if (this.Connected != null) + if (EqtTrace.IsVerboseEnabled) { - this.channel = this.channelFactory(this.tcpClient.GetStream()); - this.Connected.SafeInvoke(this, new ConnectedEventArgs(this.channel), "SocketServer: ClientConnected"); - - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("SocketServer.OnClientConnected: Client connected for endPoint: {0}, starting MessageLoopAsync:", this.endPoint); - } - - // Start the message loop - Task.Run(() => this.tcpClient.MessageLoopAsync(this.channel, error => this.Stop(error), this.cancellation.Token)).ConfigureAwait(false); + EqtTrace.Verbose("SocketServer.OnClientConnected: Client connected for endPoint: {0}, starting MessageLoopAsync:", _endPoint); } + + // Start the message loop + Task.Run(() => _tcpClient.MessageLoopAsync(_channel, error => Stop(error), _cancellation.Token)).ConfigureAwait(false); } + } - private void Stop(Exception error) - { - EqtTrace.Info("SocketServer.PrivateStop: Stopping server endPoint: {0} error: {1}", this.endPoint, error); + private void Stop(Exception error) + { + EqtTrace.Info("SocketServer.PrivateStop: Stopping server endPoint: {0} error: {1}", _endPoint, error); - if (!this.stopped) - { - // Do not allow stop to be called multiple times. - this.stopped = true; + if (!_stopped) + { + // Do not allow stop to be called multiple times. + _stopped = true; - // Stop accepting any other connections - this.tcpListener.Stop(); + // Stop accepting any other connections + _tcpListener.Stop(); - // Close the client and dispose the underlying stream + // Close the client and dispose the underlying stream #if NETFRAMEWORK - // tcpClient.Close() calls tcpClient.Dispose(). - this.tcpClient?.Close(); + // tcpClient.Close() calls tcpClient.Dispose(). + _tcpClient?.Close(); #else - // tcpClient.Close() not available for netstandard1.5. - this.tcpClient?.Dispose(); + // tcpClient.Close() not available for netstandard1.5. + _tcpClient?.Dispose(); #endif - this.channel.Dispose(); - this.cancellation.Dispose(); + _channel.Dispose(); + _cancellation.Dispose(); - EqtTrace.Info("SocketServer.Stop: Raise disconnected event endPoint: {0} error: {1}", this.endPoint, error); - this.Disconnected?.SafeInvoke(this, new DisconnectedEventArgs { Error = error }, "SocketServer: ClientDisconnected"); - } + EqtTrace.Info("SocketServer.Stop: Raise disconnected event endPoint: {0} error: {1}", _endPoint, error); + Disconnected?.SafeInvoke(this, new DisconnectedEventArgs { Error = error }, "SocketServer: ClientDisconnected"); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/SocketTransport.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/SocketTransport.cs index 5ac5df5e65..016347f381 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/SocketTransport.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/SocketTransport.cs @@ -1,102 +1,99 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities -{ - using System; - using System.Net; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using System; +using System.Net; - /// - public sealed class SocketTransport : ITransport - { - /// - /// Specifies whether the resolver is disposed or not - /// - private bool disposed; +using Interfaces; - private TestHostConnectionInfo connectionInfo; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; - private ICommunicationManager communicationManager; +/// +public sealed class SocketTransport : ITransport +{ + /// + /// Specifies whether the resolver is disposed or not + /// + private bool _disposed; - public SocketTransport(ICommunicationManager communicationManager, TestHostConnectionInfo connectionInfo) - { - this.communicationManager = communicationManager; - this.connectionInfo = connectionInfo; - } + private readonly TestHostConnectionInfo _connectionInfo; - /// - public IPEndPoint Initialize() - { - var endpoint = this.GetIPEndPoint(this.connectionInfo.Endpoint); - switch (this.connectionInfo.Role) - { - case ConnectionRole.Host: - { - // In case users passes endpoint Port as 0 HostServer will allocate endpoint at appropriate port, - // So reassign endpoint to point to correct endpoint. - endpoint = this.communicationManager.HostServer(endpoint); - this.communicationManager.AcceptClientAsync(); - return endpoint; - } - - case ConnectionRole.Client: - { - this.communicationManager.SetupClientAsync(this.GetIPEndPoint(this.connectionInfo.Endpoint)); - return endpoint; - } - - default: - throw new NotImplementedException("Unsupported Connection Role"); - } - } + private readonly ICommunicationManager _communicationManager; - /// - public bool WaitForConnection(int connectionTimeout) - { - return this.connectionInfo.Role == ConnectionRole.Client ? this.communicationManager.WaitForServerConnection(connectionTimeout) : this.communicationManager.WaitForClientConnection(connectionTimeout); - } + public SocketTransport(ICommunicationManager communicationManager, TestHostConnectionInfo connectionInfo) + { + _communicationManager = communicationManager; + _connectionInfo = connectionInfo; + } - public void Dispose() + /// + public IPEndPoint Initialize() + { + var endpoint = GetIpEndPoint(_connectionInfo.Endpoint); + switch (_connectionInfo.Role) { - this.Dispose(true); - } + case ConnectionRole.Host: + { + // In case users passes endpoint Port as 0 HostServer will allocate endpoint at appropriate port, + // So reassign endpoint to point to correct endpoint. + endpoint = _communicationManager.HostServer(endpoint); + _communicationManager.AcceptClientAsync(); + return endpoint; + } - private void Dispose(bool disposing) - { - if (!this.disposed) - { - if (disposing) + case ConnectionRole.Client: { - if (this.connectionInfo.Role == ConnectionRole.Client) - { - this.communicationManager?.StopClient(); - } - else - { - this.communicationManager?.StopServer(); - } + _communicationManager.SetupClientAsync(GetIpEndPoint(_connectionInfo.Endpoint)); + return endpoint; } - this.disposed = true; - } + default: + throw new NotImplementedException("Unsupported Connection Role"); } + } + + /// + public bool WaitForConnection(int connectionTimeout) + { + return _connectionInfo.Role == ConnectionRole.Client ? _communicationManager.WaitForServerConnection(connectionTimeout) : _communicationManager.WaitForClientConnection(connectionTimeout); + } - /// - /// Converts a given string endpoint address to valid Ipv4, Ipv6 IPEndpoint - /// - /// Input endpoint address - /// IPEndpoint from give string - private IPEndPoint GetIPEndPoint(string endpointAddress) + public void Dispose() + { + Dispose(true); + } + + private void Dispose(bool disposing) + { + if (!_disposed) { - if (Uri.TryCreate(string.Concat("tcp://", endpointAddress), UriKind.Absolute, out Uri uri)) + if (disposing) { - return new IPEndPoint(IPAddress.Parse(uri.Host), uri.Port < 0 ? 0 : uri.Port); + if (_connectionInfo.Role == ConnectionRole.Client) + { + _communicationManager?.StopClient(); + } + else + { + _communicationManager?.StopServer(); + } } - return null; + _disposed = true; } } -} + + /// + /// Converts a given string endpoint address to valid Ipv4, Ipv6 IPEndpoint + /// + /// Input endpoint address + /// IPEndpoint from give string + private IPEndPoint GetIpEndPoint(string endpointAddress) + { + return Uri.TryCreate(string.Concat("tcp://", endpointAddress), UriKind.Absolute, out Uri uri) + ? new IPEndPoint(IPAddress.Parse(uri.Host), uri.Port < 0 ? 0 : uri.Port) + : null; + } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/TcpClientExtensions.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/TcpClientExtensions.cs index 415bc587f1..5c754f3cd1 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/TcpClientExtensions.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/TcpClientExtensions.cs @@ -1,113 +1,110 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities -{ - using System; - using System.IO; - using System.Net; - using System.Net.Sockets; - using System.Threading; - using System.Threading.Tasks; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; + +using System; +using System.IO; +using System.Net; +using System.Net.Sockets; +using System.Threading; +using System.Threading.Tasks; + +using Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; + +internal static class TcpClientExtensions +{ + // Timeout for polling stream in micro seconds. + private const int Streamreadtimeout = 1000 * 1000; - internal static class TcpClientExtensions + internal static Task MessageLoopAsync( + this TcpClient client, + ICommunicationChannel channel, + Action errorHandler, + CancellationToken cancellationToken) { - // Timeout for polling stream in micro seconds. - private const int STREAMREADTIMEOUT = 1000 * 1000; + Exception error = null; - internal static Task MessageLoopAsync( - this TcpClient client, - ICommunicationChannel channel, - Action errorHandler, - CancellationToken cancellationToken) + var remoteEndPoint = string.Empty; + var localEndPoint = string.Empty; + try { - Exception error = null; + remoteEndPoint = client.Client.RemoteEndPoint?.ToString(); + localEndPoint = client.Client.LocalEndPoint?.ToString(); + } + catch (SocketException socketException) + { + EqtTrace.Error( + "TcpClientExtensions.MessageLoopAsync: Failed to access the endpoint due to socket error: {0}", + socketException); + } - var remoteEndPoint = string.Empty; - var localEndPoint = string.Empty; - try - { - remoteEndPoint = client.Client.RemoteEndPoint?.ToString(); - localEndPoint = client.Client.LocalEndPoint?.ToString(); - } - catch (SocketException socketException) - { - EqtTrace.Error( - "TcpClientExtensions.MessageLoopAsync: Failed to access the endpoint due to socket error: {0}", - socketException); - } + // Set read timeout to avoid blocking receive raw message + while (channel != null && !cancellationToken.IsCancellationRequested) + { + EqtTrace.Verbose("TcpClientExtensions.MessageLoopAsync: Polling on remoteEndPoint: {0} localEndPoint: {1}", remoteEndPoint, localEndPoint); - // Set read timeout to avoid blocking receive raw message - while (channel != null && !cancellationToken.IsCancellationRequested) + try { - EqtTrace.Verbose("TcpClientExtensions.MessageLoopAsync: Polling on remoteEndPoint: {0} localEndPoint: {1}", remoteEndPoint, localEndPoint); - - try + if (client.Client.Poll(Streamreadtimeout, SelectMode.SelectRead)) { - if (client.Client.Poll(STREAMREADTIMEOUT, SelectMode.SelectRead)) - { - EqtTrace.Verbose("TcpClientExtensions.MessageLoopAsync: NotifyDataAvailable remoteEndPoint: {0} localEndPoint: {1}", remoteEndPoint, localEndPoint); - channel.NotifyDataAvailable(); - } + EqtTrace.Verbose("TcpClientExtensions.MessageLoopAsync: NotifyDataAvailable remoteEndPoint: {0} localEndPoint: {1}", remoteEndPoint, localEndPoint); + channel.NotifyDataAvailable(); } - catch (IOException ioException) + } + catch (IOException ioException) + { + if (ioException.InnerException is SocketException socketException + && socketException.SocketErrorCode == SocketError.TimedOut) { - if (ioException.InnerException is SocketException socketException - && socketException.SocketErrorCode == SocketError.TimedOut) - { - EqtTrace.Info( - "Socket: Message loop: failed to receive message due to read timeout {0}, remoteEndPoint: {1} localEndPoint: {2}", - ioException, - remoteEndPoint, - localEndPoint); - } - else - { - EqtTrace.Error( - "Socket: Message loop: failed to receive message due to socket error {0}, remoteEndPoint: {1} localEndPoint: {2}", - ioException, - remoteEndPoint, - localEndPoint); - error = ioException; - break; - } + EqtTrace.Info( + "Socket: Message loop: failed to receive message due to read timeout {0}, remoteEndPoint: {1} localEndPoint: {2}", + ioException, + remoteEndPoint, + localEndPoint); } - catch (Exception exception) + else { EqtTrace.Error( - "Socket: Message loop: failed to receive message {0}, remoteEndPoint: {1} localEndPoint: {2}", - exception, + "Socket: Message loop: failed to receive message due to socket error {0}, remoteEndPoint: {1} localEndPoint: {2}", + ioException, remoteEndPoint, localEndPoint); - error = exception; + error = ioException; break; } } + catch (Exception exception) + { + EqtTrace.Error( + "Socket: Message loop: failed to receive message {0}, remoteEndPoint: {1} localEndPoint: {2}", + exception, + remoteEndPoint, + localEndPoint); + error = exception; + break; + } + } - // Try clean up and raise client disconnected events - errorHandler(error); - - EqtTrace.Verbose("TcpClientExtensions.MessageLoopAsync: exiting MessageLoopAsync remoteEndPoint: {0} localEndPoint: {1}", remoteEndPoint, localEndPoint); + // Try clean up and raise client disconnected events + errorHandler(error); - return Task.FromResult(0); - } + EqtTrace.Verbose("TcpClientExtensions.MessageLoopAsync: exiting MessageLoopAsync remoteEndPoint: {0} localEndPoint: {1}", remoteEndPoint, localEndPoint); - /// - /// Converts a given string endpoint address to valid Ipv4, Ipv6 IPEndpoint - /// - /// Input endpoint address - /// IPEndpoint from give string, if its not a valid string. It will create endpoint with loop back address with port 0 - internal static IPEndPoint GetIPEndPoint(this string value) - { - if (Uri.TryCreate(string.Concat("tcp://", value), UriKind.Absolute, out Uri uri)) - { - return new IPEndPoint(IPAddress.Parse(uri.Host), uri.Port < 0 ? 0 : uri.Port); - } + return Task.FromResult(0); + } - return new IPEndPoint(IPAddress.Loopback, 0); - } + /// + /// Converts a given string endpoint address to valid Ipv4, Ipv6 IPEndpoint + /// + /// Input endpoint address + /// IPEndpoint from give string, if its not a valid string. It will create endpoint with loop back address with port 0 + internal static IPEndPoint GetIpEndPoint(this string value) + { + return Uri.TryCreate(string.Concat("tcp://", value), UriKind.Absolute, out Uri uri) + ? new IPEndPoint(IPAddress.Parse(uri.Host), uri.Port < 0 ? 0 : uri.Port) + : new IPEndPoint(IPAddress.Loopback, 0); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/TestRequestSender.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/TestRequestSender.cs index 4e2cb19bf0..42dbbe9290 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/TestRequestSender.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/TestRequestSender.cs @@ -1,773 +1,764 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities -{ - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Threading; - using CoreUtilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using CommonResources = Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources.Resources; - using ObjectModelConstants = Microsoft.VisualStudio.TestPlatform.ObjectModel.Constants; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - /// - /// Test request sender implementation. - /// - public class TestRequestSender : ITestRequestSender - { - // Time to wait for test host exit - private const int ClientProcessExitWaitTimeout = 10 * 1000; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; - private readonly IDataSerializer dataSerializer; +using CoreUtilities.Helpers; - private readonly ManualResetEventSlim connected; +using Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - private readonly ManualResetEventSlim clientExited; +using CommonResources = Resources.Resources; +using ObjectModelConstants = TestPlatform.ObjectModel.Constants; - private readonly int clientExitedWaitTime; +/// +/// Test request sender implementation. +/// +public class TestRequestSender : ITestRequestSender +{ + // Time to wait for test host exit + private const int ClientProcessExitWaitTimeout = 10 * 1000; - private ICommunicationEndPoint communicationEndpoint; + private readonly IDataSerializer _dataSerializer; - private ICommunicationChannel channel; + private readonly ManualResetEventSlim _connected; - private EventHandler onMessageReceived; + private readonly ManualResetEventSlim _clientExited; - private Action onDisconnected; + private readonly int _clientExitedWaitTime; - // Set to 1 if Discovery/Execution is complete, i.e. complete handlers have been invoked - private int operationCompleted; + private ICommunicationEndPoint _communicationEndpoint; - private ITestMessageEventHandler messageEventHandler; + private ICommunicationChannel _channel; - private string clientExitErrorMessage; + private EventHandler _onMessageReceived; - // Set default to 1, if protocol version check does not happen - // that implies host is using version 1. - private int protocolVersion = 1; + private Action _onDisconnected; - // Must be in sync with the highest supported version in - // src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestRequestHandler.cs file. - private int highestSupportedVersion = 5; + // Set to 1 if Discovery/Execution is complete, i.e. complete handlers have been invoked + private int _operationCompleted; - private TestHostConnectionInfo connectionInfo; + private ITestMessageEventHandler _messageEventHandler; - private ITestRuntimeProvider runtimeProvider; + private string _clientExitErrorMessage; - /// - /// Initializes a new instance of the class. - /// - /// Protocol configuration. - /// The runtime provider. - public TestRequestSender(ProtocolConfig protocolConfig, ITestRuntimeProvider runtimeProvider) - : this( - runtimeProvider, - communicationEndPoint: null, - runtimeProvider.GetTestHostConnectionInfo(), - JsonDataSerializer.Instance, - protocolConfig, - ClientProcessExitWaitTimeout) - { - this.SetCommunicationEndPoint(); - } + // Set default to 1, if protocol version check does not happen + // that implies host is using version 1. + private int _protocolVersion = 1; - internal TestRequestSender( - ITestRuntimeProvider runtimeProvider, - ICommunicationEndPoint communicationEndPoint, - TestHostConnectionInfo connectionInfo, - IDataSerializer serializer, - ProtocolConfig protocolConfig, - int clientExitedWaitTime) - { - this.dataSerializer = serializer; - this.connected = new ManualResetEventSlim(false); - this.clientExited = new ManualResetEventSlim(false); - this.clientExitedWaitTime = clientExitedWaitTime; - this.operationCompleted = 0; - - this.highestSupportedVersion = protocolConfig.Version; - - // The connectionInfo here is that of RuntimeProvider, so reverse the role of runner. - this.runtimeProvider = runtimeProvider; - this.communicationEndpoint = communicationEndPoint; - this.connectionInfo.Endpoint = connectionInfo.Endpoint; - this.connectionInfo.Role = connectionInfo.Role == ConnectionRole.Host - ? ConnectionRole.Client - : ConnectionRole.Host; - } + // Must be in sync with the highest supported version in + // src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestRequestHandler.cs file. + private readonly int _highestSupportedVersion = 5; - /// - /// Initializes a new instance of the class. - /// Used only for testing to inject communication endpoint. - /// - /// Communication server implementation. - /// ConnectionInfo to set up transport layer - /// Serializer implementation. - /// Protocol configuration. - /// Time to wait for client process exit. - internal TestRequestSender( - ICommunicationEndPoint communicationEndPoint, - TestHostConnectionInfo connectionInfo, - IDataSerializer serializer, - ProtocolConfig protocolConfig, - int clientExitedWaitTime) - : this( - runtimeProvider: null, - communicationEndPoint, - connectionInfo, - serializer, - protocolConfig, - clientExitedWaitTime) - { - } + private readonly TestHostConnectionInfo _connectionInfo; - public bool CloseConnectionOnOperationComplete { get; set; } = true; + private readonly ITestRuntimeProvider _runtimeProvider; - /// - public int InitializeCommunication() - { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("TestRequestSender.InitializeCommunication: initialize communication. "); - } + /// + /// Initializes a new instance of the class. + /// + /// Protocol configuration. + /// The runtime provider. + public TestRequestSender(ProtocolConfig protocolConfig, ITestRuntimeProvider runtimeProvider) + : this( + runtimeProvider, + communicationEndPoint: null, + runtimeProvider.GetTestHostConnectionInfo(), + JsonDataSerializer.Instance, + protocolConfig, + ClientProcessExitWaitTimeout) + { + SetCommunicationEndPoint(); + } - // this.clientExitCancellationSource = new CancellationTokenSource(); - this.clientExitErrorMessage = string.Empty; - this.communicationEndpoint.Connected += (sender, args) => - { - this.channel = args.Channel; - if (args.Connected && this.channel != null) - { - this.connected.Set(); - } - }; + internal TestRequestSender( + ITestRuntimeProvider runtimeProvider, + ICommunicationEndPoint communicationEndPoint, + TestHostConnectionInfo connectionInfo, + IDataSerializer serializer, + ProtocolConfig protocolConfig, + int clientExitedWaitTime) + { + _dataSerializer = serializer; + _connected = new ManualResetEventSlim(false); + _clientExited = new ManualResetEventSlim(false); + _clientExitedWaitTime = clientExitedWaitTime; + _operationCompleted = 0; + + _highestSupportedVersion = protocolConfig.Version; + + // The connectionInfo here is that of RuntimeProvider, so reverse the role of runner. + _runtimeProvider = runtimeProvider; + _communicationEndpoint = communicationEndPoint; + _connectionInfo.Endpoint = connectionInfo.Endpoint; + _connectionInfo.Role = connectionInfo.Role == ConnectionRole.Host + ? ConnectionRole.Client + : ConnectionRole.Host; + } - this.communicationEndpoint.Disconnected += (sender, args) => - { - // If there's an disconnected event handler, call it - this.onDisconnected?.Invoke(args); - }; - - // Server start returns the listener port - // return int.Parse(this.communicationServer.Start()); - var endpoint = this.communicationEndpoint.Start(this.connectionInfo.Endpoint); - return endpoint.GetIPEndPoint().Port; + /// + /// Initializes a new instance of the class. + /// Used only for testing to inject communication endpoint. + /// + /// Communication server implementation. + /// ConnectionInfo to set up transport layer + /// Serializer implementation. + /// Protocol configuration. + /// Time to wait for client process exit. + internal TestRequestSender( + ICommunicationEndPoint communicationEndPoint, + TestHostConnectionInfo connectionInfo, + IDataSerializer serializer, + ProtocolConfig protocolConfig, + int clientExitedWaitTime) + : this( + runtimeProvider: null, + communicationEndPoint, + connectionInfo, + serializer, + protocolConfig, + clientExitedWaitTime) + { + } + + public bool CloseConnectionOnOperationComplete { get; set; } = true; + + /// + public int InitializeCommunication() + { + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("TestRequestSender.InitializeCommunication: initialize communication. "); } - /// - public bool WaitForRequestHandlerConnection(int connectionTimeout, CancellationToken cancellationToken) + // this.clientExitCancellationSource = new CancellationTokenSource(); + _clientExitErrorMessage = string.Empty; + _communicationEndpoint.Connected += (sender, args) => { - if (EqtTrace.IsVerboseEnabled) + _channel = args.Channel; + if (args.Connected && _channel != null) { - EqtTrace.Verbose("TestRequestSender.WaitForRequestHandlerConnection: waiting for connection with timeout: {0}", connectionTimeout); + _connected.Set(); } + }; - // Wait until either connection is successful, handled by connected.WaitHandle - // or operation is canceled, handled by cancellationToken.WaitHandle - // or testhost exits unexpectedly, handled by clientExited.WaitHandle - var waitIndex = WaitHandle.WaitAny(new WaitHandle[] { this.connected.WaitHandle, cancellationToken.WaitHandle, this.clientExited.WaitHandle }, connectionTimeout); + _communicationEndpoint.Disconnected += (sender, args) => + // If there's an disconnected event handler, call it + _onDisconnected?.Invoke(args); - // Return true if connection was successful. - return waitIndex == 0; - } + // Server start returns the listener port + // return int.Parse(this.communicationServer.Start()); + var endpoint = _communicationEndpoint.Start(_connectionInfo.Endpoint); + return endpoint.GetIpEndPoint().Port; + } - /// - public void CheckVersionWithTestHost() + /// + public bool WaitForRequestHandlerConnection(int connectionTimeout, CancellationToken cancellationToken) + { + if (EqtTrace.IsVerboseEnabled) { - // Negotiation follows these steps: - // Runner sends highest supported version to Test host - // Test host sends the version it can support (must be less than highest) to runner - // Error case: test host can send a protocol error if it cannot find a supported version - var protocolNegotiated = new ManualResetEvent(false); - this.onMessageReceived = (sender, args) => - { - var message = this.dataSerializer.DeserializeMessage(args.Data); - - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("TestRequestSender.CheckVersionWithTestHost: onMessageReceived received message: {0}", message); - } + EqtTrace.Verbose("TestRequestSender.WaitForRequestHandlerConnection: waiting for connection with timeout: {0}", connectionTimeout); + } - if (message.MessageType == MessageType.VersionCheck) - { - this.protocolVersion = this.dataSerializer.DeserializePayload(message); - } + // Wait until either connection is successful, handled by connected.WaitHandle + // or operation is canceled, handled by cancellationToken.WaitHandle + // or testhost exits unexpectedly, handled by clientExited.WaitHandle + var waitIndex = WaitHandle.WaitAny(new WaitHandle[] { _connected.WaitHandle, cancellationToken.WaitHandle, _clientExited.WaitHandle }, connectionTimeout); - // TRH can also send TestMessage if tracing is enabled, so log it at runner end - else if (message.MessageType == MessageType.TestMessage) - { - // Ignore test messages. Currently we don't have handler(which sends messages to client/console.) here. - // Above we are logging it to EqtTrace. - } - else if (message.MessageType == MessageType.ProtocolError) - { - throw new TestPlatformException(string.Format(CultureInfo.CurrentUICulture, CommonResources.VersionCheckFailed)); - } - else - { - throw new TestPlatformException(string.Format( - CultureInfo.CurrentUICulture, - CommonResources.UnexpectedMessage, - MessageType.VersionCheck, - message.MessageType)); - } + // Return true if connection was successful. + return waitIndex == 0; + } - protocolNegotiated.Set(); - }; - this.channel.MessageReceived += this.onMessageReceived; + /// + public void CheckVersionWithTestHost() + { + // Negotiation follows these steps: + // Runner sends highest supported version to Test host + // Test host sends the version it can support (must be less than highest) to runner + // Error case: test host can send a protocol error if it cannot find a supported version + var protocolNegotiated = new ManualResetEvent(false); + _onMessageReceived = (sender, args) => + { + var message = _dataSerializer.DeserializeMessage(args.Data); - try + if (EqtTrace.IsVerboseEnabled) { - // Send the protocol negotiation request. Note that we always serialize this data - // without any versioning in the message itself. - var data = this.dataSerializer.SerializePayload(MessageType.VersionCheck, this.highestSupportedVersion); - - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("TestRequestSender.CheckVersionWithTestHost: Sending check version message: {0}", data); - } + EqtTrace.Verbose("TestRequestSender.CheckVersionWithTestHost: onMessageReceived received message: {0}", message); + } - this.channel.Send(data); + if (message.MessageType == MessageType.VersionCheck) + { + _protocolVersion = _dataSerializer.DeserializePayload(message); + } - // Wait for negotiation response - var timeout = EnvironmentHelper.GetConnectionTimeout(); - if (!protocolNegotiated.WaitOne(timeout * 1000)) - { - throw new TestPlatformException(string.Format(CultureInfo.CurrentUICulture, CommonResources.VersionCheckTimedout, timeout, EnvironmentHelper.VstestConnectionTimeout)); - } + // TRH can also send TestMessage if tracing is enabled, so log it at runner end + else if (message.MessageType == MessageType.TestMessage) + { + // Ignore test messages. Currently we don't have handler(which sends messages to client/console.) here. + // Above we are logging it to EqtTrace. } - finally + else if (message.MessageType == MessageType.ProtocolError) { - this.channel.MessageReceived -= this.onMessageReceived; - this.onMessageReceived = null; + throw new TestPlatformException(string.Format(CultureInfo.CurrentUICulture, CommonResources.VersionCheckFailed)); } - } - - #region Discovery Protocol - - /// - public void InitializeDiscovery(IEnumerable pathToAdditionalExtensions) - { - var message = this.dataSerializer.SerializePayload( - MessageType.DiscoveryInitialize, - pathToAdditionalExtensions, - this.protocolVersion); - - if (EqtTrace.IsVerboseEnabled) + else { - EqtTrace.Verbose("TestRequestSender.InitializeDiscovery: Sending initialize discovery with message: {0}", message); + throw new TestPlatformException(string.Format( + CultureInfo.CurrentUICulture, + CommonResources.UnexpectedMessage, + MessageType.VersionCheck, + message.MessageType)); } - this.channel.Send(message); - } + protocolNegotiated.Set(); + }; + _channel.MessageReceived += _onMessageReceived; - /// - public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 discoveryEventsHandler) + try { - this.messageEventHandler = discoveryEventsHandler; - this.onDisconnected = (disconnectedEventArgs) => - { - this.OnDiscoveryAbort(discoveryEventsHandler, disconnectedEventArgs.Error, true); - }; - this.onMessageReceived = (sender, args) => this.OnDiscoveryMessageReceived(discoveryEventsHandler, args); - - this.channel.MessageReceived += this.onMessageReceived; - var message = this.dataSerializer.SerializePayload( - MessageType.StartDiscovery, - discoveryCriteria, - this.protocolVersion); + // Send the protocol negotiation request. Note that we always serialize this data + // without any versioning in the message itself. + var data = _dataSerializer.SerializePayload(MessageType.VersionCheck, _highestSupportedVersion); if (EqtTrace.IsVerboseEnabled) { - EqtTrace.Verbose("TestRequestSender.DiscoverTests: Sending discover tests with message: {0}", message); + EqtTrace.Verbose("TestRequestSender.CheckVersionWithTestHost: Sending check version message: {0}", data); } - this.channel.Send(message); - } - #endregion - - #region Execution Protocol + _channel.Send(data); - /// - public void InitializeExecution(IEnumerable pathToAdditionalExtensions) - { - var message = this.dataSerializer.SerializePayload( - MessageType.ExecutionInitialize, - pathToAdditionalExtensions, - this.protocolVersion); - if (EqtTrace.IsVerboseEnabled) + // Wait for negotiation response + var timeout = EnvironmentHelper.GetConnectionTimeout(); + if (!protocolNegotiated.WaitOne(timeout * 1000)) { - EqtTrace.Verbose("TestRequestSender.InitializeExecution: Sending initialize execution with message: {0}", message); + throw new TestPlatformException(string.Format(CultureInfo.CurrentUICulture, CommonResources.VersionCheckTimedout, timeout, EnvironmentHelper.VstestConnectionTimeout)); } - - this.channel.Send(message); } - - /// - public void StartTestRun(TestRunCriteriaWithSources runCriteria, ITestRunEventsHandler eventHandler) + finally { - this.messageEventHandler = eventHandler; - this.onDisconnected = (disconnectedEventArgs) => - { - this.OnTestRunAbort(eventHandler, disconnectedEventArgs.Error, true); - }; - - this.onMessageReceived = (sender, args) => this.OnExecutionMessageReceived(sender, args, eventHandler); - this.channel.MessageReceived += this.onMessageReceived; - - // This code section is needed because we altered the old testhost launch process for - // the debugging workflow. Now we don't ask VS to launch and attach to the testhost - // process for us as we previously did, instead we launch it as a standalone process - // and rely on the testhost to ask VS to attach the debugger to itself. - // - // In order to avoid breaking compatibility with previous testhost versions because of - // those changes (older testhosts won't know to request VS to attach to themselves - // thinking instead VS launched and attached to them already), we request VS to attach - // to the testhost here before starting the test run. - if (runCriteria.TestExecutionContext != null - && runCriteria.TestExecutionContext.IsDebug - && this.runtimeProvider is ITestRuntimeProvider2 convertedRuntimeProvider - && this.protocolVersion < ObjectModelConstants.MinimumProtocolVersionWithDebugSupport) - { - var handler = (ITestRunEventsHandler2)eventHandler; - if (!convertedRuntimeProvider.AttachDebuggerToTestHost()) - { - EqtTrace.Warning( - string.Format( - CultureInfo.CurrentUICulture, - CommonResources.AttachDebuggerToDefaultTestHostFailure)); - } - } + _channel.MessageReceived -= _onMessageReceived; + _onMessageReceived = null; + } + } - var message = this.dataSerializer.SerializePayload( - MessageType.StartTestExecutionWithSources, - runCriteria, - this.protocolVersion); + #region Discovery Protocol - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("TestRequestSender.StartTestRun: Sending test run with message: {0}", message); - } + /// + public void InitializeDiscovery(IEnumerable pathToAdditionalExtensions) + { + var message = _dataSerializer.SerializePayload( + MessageType.DiscoveryInitialize, + pathToAdditionalExtensions, + _protocolVersion); - this.channel.Send(message); + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("TestRequestSender.InitializeDiscovery: Sending initialize discovery with message: {0}", message); } - /// - public void StartTestRun(TestRunCriteriaWithTests runCriteria, ITestRunEventsHandler eventHandler) + _channel.Send(message); + } + + /// + public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 discoveryEventsHandler) + { + _messageEventHandler = discoveryEventsHandler; + _onDisconnected = (disconnectedEventArgs) => OnDiscoveryAbort(discoveryEventsHandler, disconnectedEventArgs.Error, true); + _onMessageReceived = (sender, args) => OnDiscoveryMessageReceived(discoveryEventsHandler, args); + + _channel.MessageReceived += _onMessageReceived; + var message = _dataSerializer.SerializePayload( + MessageType.StartDiscovery, + discoveryCriteria, + _protocolVersion); + + if (EqtTrace.IsVerboseEnabled) { - this.messageEventHandler = eventHandler; - this.onDisconnected = (disconnectedEventArgs) => - { - this.OnTestRunAbort(eventHandler, disconnectedEventArgs.Error, true); - }; - - this.onMessageReceived = (sender, args) => this.OnExecutionMessageReceived(sender, args, eventHandler); - this.channel.MessageReceived += this.onMessageReceived; - - // This code section is needed because we altered the old testhost launch process for - // the debugging workflow. Now we don't ask VS to launch and attach to the testhost - // process for us as we previously did, instead we launch it as a standalone process - // and rely on the testhost to ask VS to attach the debugger to itself. - // - // In order to avoid breaking compatibility with previous testhost versions because of - // those changes (older testhosts won't know to request VS to attach to themselves - // thinking instead VS launched and attached to them already), we request VS to attach - // to the testhost here before starting the test run. - if (runCriteria.TestExecutionContext != null - && runCriteria.TestExecutionContext.IsDebug - && this.runtimeProvider is ITestRuntimeProvider2 convertedRuntimeProvider - && this.protocolVersion < ObjectModelConstants.MinimumProtocolVersionWithDebugSupport) - { - var handler = (ITestRunEventsHandler2)eventHandler; - if (!convertedRuntimeProvider.AttachDebuggerToTestHost()) - { - EqtTrace.Warning( - string.Format( - CultureInfo.CurrentUICulture, - CommonResources.AttachDebuggerToDefaultTestHostFailure)); - } - } + EqtTrace.Verbose("TestRequestSender.DiscoverTests: Sending discover tests with message: {0}", message); + } - var message = this.dataSerializer.SerializePayload( - MessageType.StartTestExecutionWithTests, - runCriteria, - this.protocolVersion); + _channel.Send(message); + } + #endregion - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("TestRequestSender.StartTestRun: Sending test run with message: {0}", message); - } + #region Execution Protocol - this.channel.Send(message); + /// + public void InitializeExecution(IEnumerable pathToAdditionalExtensions) + { + var message = _dataSerializer.SerializePayload( + MessageType.ExecutionInitialize, + pathToAdditionalExtensions, + _protocolVersion); + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("TestRequestSender.InitializeExecution: Sending initialize execution with message: {0}", message); } - /// - public void SendTestRunCancel() + _channel.Send(message); + } + + /// + public void StartTestRun(TestRunCriteriaWithSources runCriteria, ITestRunEventsHandler eventHandler) + { + _messageEventHandler = eventHandler; + _onDisconnected = (disconnectedEventArgs) => OnTestRunAbort(eventHandler, disconnectedEventArgs.Error, true); + + _onMessageReceived = (sender, args) => OnExecutionMessageReceived(sender, args, eventHandler); + _channel.MessageReceived += _onMessageReceived; + + // This code section is needed because we altered the old testhost launch process for + // the debugging workflow. Now we don't ask VS to launch and attach to the testhost + // process for us as we previously did, instead we launch it as a standalone process + // and rely on the testhost to ask VS to attach the debugger to itself. + // + // In order to avoid breaking compatibility with previous testhost versions because of + // those changes (older testhosts won't know to request VS to attach to themselves + // thinking instead VS launched and attached to them already), we request VS to attach + // to the testhost here before starting the test run. + if (runCriteria.TestExecutionContext != null + && runCriteria.TestExecutionContext.IsDebug + && _runtimeProvider is ITestRuntimeProvider2 convertedRuntimeProvider + && _protocolVersion < ObjectModelConstants.MinimumProtocolVersionWithDebugSupport) { - if (this.IsOperationComplete()) + var handler = (ITestRunEventsHandler2)eventHandler; + if (!convertedRuntimeProvider.AttachDebuggerToTestHost()) { - EqtTrace.Verbose("TestRequestSender: SendTestRunCancel: Operation is already complete. Skip error message."); - return; + EqtTrace.Warning( + string.Format( + CultureInfo.CurrentUICulture, + CommonResources.AttachDebuggerToDefaultTestHostFailure)); } + } - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("TestRequestSender.SendTestRunCancel: Sending test run cancel."); - } + var message = _dataSerializer.SerializePayload( + MessageType.StartTestExecutionWithSources, + runCriteria, + _protocolVersion); - this.channel?.Send(this.dataSerializer.SerializeMessage(MessageType.CancelTestRun)); + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("TestRequestSender.StartTestRun: Sending test run with message: {0}", message); } - /// - public void SendTestRunAbort() + _channel.Send(message); + } + + /// + public void StartTestRun(TestRunCriteriaWithTests runCriteria, ITestRunEventsHandler eventHandler) + { + _messageEventHandler = eventHandler; + _onDisconnected = (disconnectedEventArgs) => OnTestRunAbort(eventHandler, disconnectedEventArgs.Error, true); + + _onMessageReceived = (sender, args) => OnExecutionMessageReceived(sender, args, eventHandler); + _channel.MessageReceived += _onMessageReceived; + + // This code section is needed because we altered the old testhost launch process for + // the debugging workflow. Now we don't ask VS to launch and attach to the testhost + // process for us as we previously did, instead we launch it as a standalone process + // and rely on the testhost to ask VS to attach the debugger to itself. + // + // In order to avoid breaking compatibility with previous testhost versions because of + // those changes (older testhosts won't know to request VS to attach to themselves + // thinking instead VS launched and attached to them already), we request VS to attach + // to the testhost here before starting the test run. + if (runCriteria.TestExecutionContext != null + && runCriteria.TestExecutionContext.IsDebug + && _runtimeProvider is ITestRuntimeProvider2 convertedRuntimeProvider + && _protocolVersion < ObjectModelConstants.MinimumProtocolVersionWithDebugSupport) { - if (this.IsOperationComplete()) + var handler = (ITestRunEventsHandler2)eventHandler; + if (!convertedRuntimeProvider.AttachDebuggerToTestHost()) { - EqtTrace.Verbose("TestRequestSender: SendTestRunAbort: Operation is already complete. Skip error message."); - return; + EqtTrace.Warning( + string.Format( + CultureInfo.CurrentUICulture, + CommonResources.AttachDebuggerToDefaultTestHostFailure)); } + } - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("TestRequestSender.SendTestRunAbort: Sending test run abort."); - } + var message = _dataSerializer.SerializePayload( + MessageType.StartTestExecutionWithTests, + runCriteria, + _protocolVersion); - this.channel?.Send(this.dataSerializer.SerializeMessage(MessageType.AbortTestRun)); + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("TestRequestSender.StartTestRun: Sending test run with message: {0}", message); } - #endregion + _channel.Send(message); + } - /// - public void EndSession() + /// + public void SendTestRunCancel() + { + if (IsOperationComplete()) { - if (!this.IsOperationComplete()) - { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("TestRequestSender.EndSession: Sending end session."); - } - - this.channel?.Send(this.dataSerializer.SerializeMessage(MessageType.SessionEnd)); - } + EqtTrace.Verbose("TestRequestSender: SendTestRunCancel: Operation is already complete. Skip error message."); + return; } - /// - public void OnClientProcessExit(string stdError) + if (EqtTrace.IsVerboseEnabled) { - // This method is called on test host exit. If test host has any errors, stdError - // provides the crash call stack. - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info($"TestRequestSender.OnClientProcessExit: Test host process exited. Standard error: {stdError}"); - } + EqtTrace.Verbose("TestRequestSender.SendTestRunCancel: Sending test run cancel."); + } - this.clientExitErrorMessage = stdError; - this.clientExited.Set(); + _channel?.Send(_dataSerializer.SerializeMessage(MessageType.CancelTestRun)); + } - // Break communication loop. In some cases (E.g: When tests creates child processes to testhost) communication channel won't break if testhost exits. - this.communicationEndpoint.Stop(); + /// + public void SendTestRunAbort() + { + if (IsOperationComplete()) + { + EqtTrace.Verbose("TestRequestSender: SendTestRunAbort: Operation is already complete. Skip error message."); + return; } - /// - public void Close() + if (EqtTrace.IsVerboseEnabled) { - this.Dispose(); - EqtTrace.Info("Closing the connection"); + EqtTrace.Verbose("TestRequestSender.SendTestRunAbort: Sending test run abort."); } - /// - public void Dispose() + _channel?.Send(_dataSerializer.SerializeMessage(MessageType.AbortTestRun)); + } + + #endregion + + /// + public void EndSession() + { + if (!IsOperationComplete()) { - if (this.channel != null) + if (EqtTrace.IsVerboseEnabled) { - this.channel.MessageReceived -= this.onMessageReceived; + EqtTrace.Verbose("TestRequestSender.EndSession: Sending end session."); } - this.communicationEndpoint.Stop(); - GC.SuppressFinalize(this); + _channel?.Send(_dataSerializer.SerializeMessage(MessageType.SessionEnd)); } + } - private void OnExecutionMessageReceived(object sender, MessageReceivedEventArgs messageReceived, ITestRunEventsHandler testRunEventsHandler) + /// + public void OnClientProcessExit(string stdError) + { + // This method is called on test host exit. If test host has any errors, stdError + // provides the crash call stack. + if (EqtTrace.IsInfoEnabled) { - try - { - var rawMessage = messageReceived.Data; - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("TestRequestSender.OnExecutionMessageReceived: Received message: {0}", rawMessage); - } + EqtTrace.Info($"TestRequestSender.OnClientProcessExit: Test host process exited. Standard error: {stdError}"); + } - // Send raw message first to unblock handlers waiting to send message to IDEs - testRunEventsHandler.HandleRawMessage(rawMessage); + _clientExitErrorMessage = stdError; + _clientExited.Set(); - var message = this.dataSerializer.DeserializeMessage(rawMessage); - switch (message.MessageType) - { - case MessageType.TestRunStatsChange: - var testRunChangedArgs = this.dataSerializer.DeserializePayload(message); - testRunEventsHandler.HandleTestRunStatsChange(testRunChangedArgs); - break; - case MessageType.ExecutionComplete: - var testRunCompletePayload = this.dataSerializer.DeserializePayload(message); - - testRunEventsHandler.HandleTestRunComplete( - testRunCompletePayload.TestRunCompleteArgs, - testRunCompletePayload.LastRunTests, - testRunCompletePayload.RunAttachments, - testRunCompletePayload.ExecutorUris); - - this.SetOperationComplete(); - break; - case MessageType.TestMessage: - var testMessagePayload = this.dataSerializer.DeserializePayload(message); - testRunEventsHandler.HandleLogMessage(testMessagePayload.MessageLevel, testMessagePayload.Message); - break; - case MessageType.LaunchAdapterProcessWithDebuggerAttached: - var testProcessStartInfo = this.dataSerializer.DeserializePayload(message); - int processId = testRunEventsHandler.LaunchProcessWithDebuggerAttached(testProcessStartInfo); - - var data = - this.dataSerializer.SerializePayload( - MessageType.LaunchAdapterProcessWithDebuggerAttachedCallback, - processId, - this.protocolVersion); - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("TestRequestSender.OnExecutionMessageReceived: Sending LaunchAdapterProcessWithDebuggerAttachedCallback message: {0}", data); - } - - this.channel.Send(data); - break; - - case MessageType.AttachDebugger: - var testProcessPid = this.dataSerializer.DeserializePayload(message); - bool result = ((ITestRunEventsHandler2)testRunEventsHandler).AttachDebuggerToProcess(testProcessPid.ProcessID); - - var resultMessage = this.dataSerializer.SerializePayload( - MessageType.AttachDebuggerCallback, - result, - this.protocolVersion); - - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("TestRequestSender.OnExecutionMessageReceived: Sending AttachDebugger with message: {0}", message); - } - - this.channel.Send(resultMessage); - - break; - } - } - catch (Exception exception) - { - this.OnTestRunAbort(testRunEventsHandler, exception, false); - } + // Break communication loop. In some cases (E.g: When tests creates child processes to testhost) communication channel won't break if testhost exits. + _communicationEndpoint.Stop(); + } + + /// + public void Close() + { + Dispose(); + EqtTrace.Info("Closing the connection"); + } + + /// + public void Dispose() + { + if (_channel != null) + { + _channel.MessageReceived -= _onMessageReceived; } - private void OnDiscoveryMessageReceived(ITestDiscoveryEventsHandler2 discoveryEventsHandler, MessageReceivedEventArgs args) + _communicationEndpoint.Stop(); + GC.SuppressFinalize(this); + } + + private void OnExecutionMessageReceived(object sender, MessageReceivedEventArgs messageReceived, ITestRunEventsHandler testRunEventsHandler) + { + try { - try + var rawMessage = messageReceived.Data; + if (EqtTrace.IsVerboseEnabled) { - var rawMessage = args.Data; + EqtTrace.Verbose("TestRequestSender.OnExecutionMessageReceived: Received message: {0}", rawMessage); + } - // Currently each of the operations are not separate tasks since they should not each take much time. This is just a notification. - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("TestRequestSender.OnDiscoveryMessageReceived: Received message: {0}", rawMessage); - } + // Send raw message first to unblock handlers waiting to send message to IDEs + testRunEventsHandler.HandleRawMessage(rawMessage); - // Send raw message first to unblock handlers waiting to send message to IDEs - discoveryEventsHandler.HandleRawMessage(rawMessage); + var message = _dataSerializer.DeserializeMessage(rawMessage); + switch (message.MessageType) + { + case MessageType.TestRunStatsChange: + var testRunChangedArgs = _dataSerializer.DeserializePayload(message); + testRunEventsHandler.HandleTestRunStatsChange(testRunChangedArgs); + break; + case MessageType.ExecutionComplete: + var testRunCompletePayload = _dataSerializer.DeserializePayload(message); + + testRunEventsHandler.HandleTestRunComplete( + testRunCompletePayload.TestRunCompleteArgs, + testRunCompletePayload.LastRunTests, + testRunCompletePayload.RunAttachments, + testRunCompletePayload.ExecutorUris); + + SetOperationComplete(); + break; + case MessageType.TestMessage: + var testMessagePayload = _dataSerializer.DeserializePayload(message); + testRunEventsHandler.HandleLogMessage(testMessagePayload.MessageLevel, testMessagePayload.Message); + break; + case MessageType.LaunchAdapterProcessWithDebuggerAttached: + var testProcessStartInfo = _dataSerializer.DeserializePayload(message); + int processId = testRunEventsHandler.LaunchProcessWithDebuggerAttached(testProcessStartInfo); + + var data = + _dataSerializer.SerializePayload( + MessageType.LaunchAdapterProcessWithDebuggerAttachedCallback, + processId, + _protocolVersion); + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("TestRequestSender.OnExecutionMessageReceived: Sending LaunchAdapterProcessWithDebuggerAttachedCallback message: {0}", data); + } - var data = this.dataSerializer.DeserializeMessage(rawMessage); - switch (data.MessageType) - { - case MessageType.TestCasesFound: - var testCases = this.dataSerializer.DeserializePayload>(data); - discoveryEventsHandler.HandleDiscoveredTests(testCases); - break; - case MessageType.DiscoveryComplete: - var discoveryCompletePayload = - this.dataSerializer.DeserializePayload(data); - var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(discoveryCompletePayload.TotalTests, discoveryCompletePayload.IsAborted); - discoveryCompleteEventArgs.Metrics = discoveryCompletePayload.Metrics; - discoveryEventsHandler.HandleDiscoveryComplete( - discoveryCompleteEventArgs, - discoveryCompletePayload.LastDiscoveredTests); - this.SetOperationComplete(); - break; - case MessageType.TestMessage: - var testMessagePayload = this.dataSerializer.DeserializePayload( - data); - discoveryEventsHandler.HandleLogMessage( - testMessagePayload.MessageLevel, - testMessagePayload.Message); - break; - } - } - catch (Exception ex) - { - this.OnDiscoveryAbort(discoveryEventsHandler, ex, false); + _channel.Send(data); + break; + + case MessageType.AttachDebugger: + var testProcessPid = _dataSerializer.DeserializePayload(message); + bool result = ((ITestRunEventsHandler2)testRunEventsHandler).AttachDebuggerToProcess(testProcessPid.ProcessID); + + var resultMessage = _dataSerializer.SerializePayload( + MessageType.AttachDebuggerCallback, + result, + _protocolVersion); + + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("TestRequestSender.OnExecutionMessageReceived: Sending AttachDebugger with message: {0}", message); + } + + _channel.Send(resultMessage); + + break; } } + catch (Exception exception) + { + OnTestRunAbort(testRunEventsHandler, exception, false); + } + } - private void OnTestRunAbort(ITestRunEventsHandler testRunEventsHandler, Exception exception, bool getClientError) + private void OnDiscoveryMessageReceived(ITestDiscoveryEventsHandler2 discoveryEventsHandler, MessageReceivedEventArgs args) + { + try { - if (this.IsOperationComplete()) + var rawMessage = args.Data; + + // Currently each of the operations are not separate tasks since they should not each take much time. This is just a notification. + if (EqtTrace.IsVerboseEnabled) { - EqtTrace.Verbose("TestRequestSender: OnTestRunAbort: Operation is already complete. Skip error message."); - return; + EqtTrace.Verbose("TestRequestSender.OnDiscoveryMessageReceived: Received message: {0}", rawMessage); + } + + // Send raw message first to unblock handlers waiting to send message to IDEs + discoveryEventsHandler.HandleRawMessage(rawMessage); + + var data = _dataSerializer.DeserializeMessage(rawMessage); + switch (data.MessageType) + { + case MessageType.TestCasesFound: + var testCases = _dataSerializer.DeserializePayload>(data); + discoveryEventsHandler.HandleDiscoveredTests(testCases); + break; + case MessageType.DiscoveryComplete: + var discoveryCompletePayload = + _dataSerializer.DeserializePayload(data); + var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(discoveryCompletePayload.TotalTests, discoveryCompletePayload.IsAborted); + discoveryCompleteEventArgs.Metrics = discoveryCompletePayload.Metrics; + discoveryEventsHandler.HandleDiscoveryComplete( + discoveryCompleteEventArgs, + discoveryCompletePayload.LastDiscoveredTests); + SetOperationComplete(); + break; + case MessageType.TestMessage: + var testMessagePayload = _dataSerializer.DeserializePayload( + data); + discoveryEventsHandler.HandleLogMessage( + testMessagePayload.MessageLevel, + testMessagePayload.Message); + break; } + } + catch (Exception ex) + { + OnDiscoveryAbort(discoveryEventsHandler, ex, false); + } + } + + private void OnTestRunAbort(ITestRunEventsHandler testRunEventsHandler, Exception exception, bool getClientError) + { + if (IsOperationComplete()) + { + EqtTrace.Verbose("TestRequestSender: OnTestRunAbort: Operation is already complete. Skip error message."); + return; + } - EqtTrace.Verbose("TestRequestSender: OnTestRunAbort: Set operation complete."); - this.SetOperationComplete(); + EqtTrace.Verbose("TestRequestSender: OnTestRunAbort: Set operation complete."); + SetOperationComplete(); - var reason = this.GetAbortErrorMessage(exception, getClientError); - EqtTrace.Error("TestRequestSender: Aborting test run because {0}", reason); - this.LogErrorMessage(string.Format(CommonResources.AbortedTestRun, reason)); + var reason = GetAbortErrorMessage(exception, getClientError); + EqtTrace.Error("TestRequestSender: Aborting test run because {0}", reason); + LogErrorMessage(string.Format(CommonResources.AbortedTestRun, reason)); - // notify test run abort to vstest console wrapper. - var completeArgs = new TestRunCompleteEventArgs(null, false, true, exception, null, null, TimeSpan.Zero); - var payload = new TestRunCompletePayload { TestRunCompleteArgs = completeArgs }; - var rawMessage = this.dataSerializer.SerializePayload(MessageType.ExecutionComplete, payload); - testRunEventsHandler.HandleRawMessage(rawMessage); + // notify test run abort to vstest console wrapper. + var completeArgs = new TestRunCompleteEventArgs(null, false, true, exception, null, null, TimeSpan.Zero); + var payload = new TestRunCompletePayload { TestRunCompleteArgs = completeArgs }; + var rawMessage = _dataSerializer.SerializePayload(MessageType.ExecutionComplete, payload); + testRunEventsHandler.HandleRawMessage(rawMessage); - // notify of a test run complete and bail out. - testRunEventsHandler.HandleTestRunComplete(completeArgs, null, null, null); - } + // notify of a test run complete and bail out. + testRunEventsHandler.HandleTestRunComplete(completeArgs, null, null, null); + } - private void OnDiscoveryAbort(ITestDiscoveryEventsHandler2 eventHandler, Exception exception, bool getClientError) + private void OnDiscoveryAbort(ITestDiscoveryEventsHandler2 eventHandler, Exception exception, bool getClientError) + { + if (IsOperationComplete()) { - if (this.IsOperationComplete()) - { - EqtTrace.Verbose("TestRequestSender: OnDiscoveryAbort: Operation is already complete. Skip error message."); - return; - } + EqtTrace.Verbose("TestRequestSender: OnDiscoveryAbort: Operation is already complete. Skip error message."); + return; + } - EqtTrace.Verbose("TestRequestSender: OnDiscoveryAbort: Set operation complete."); - this.SetOperationComplete(); + EqtTrace.Verbose("TestRequestSender: OnDiscoveryAbort: Set operation complete."); + SetOperationComplete(); - var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(-1, true); - var reason = this.GetAbortErrorMessage(exception, getClientError); - EqtTrace.Error("TestRequestSender: Aborting test discovery because {0}", reason); - this.LogErrorMessage(string.Format(CommonResources.AbortedTestDiscovery, reason)); + var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(-1, true); + var reason = GetAbortErrorMessage(exception, getClientError); + EqtTrace.Error("TestRequestSender: Aborting test discovery because {0}", reason); + LogErrorMessage(string.Format(CommonResources.AbortedTestDiscovery, reason)); - // Notify discovery abort to IDE test output - var payload = new DiscoveryCompletePayload() - { - IsAborted = true, - LastDiscoveredTests = null, - TotalTests = -1 - }; - var rawMessage = this.dataSerializer.SerializePayload(MessageType.DiscoveryComplete, payload); - eventHandler.HandleRawMessage(rawMessage); - - // Complete discovery - eventHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, null); - } + // Notify discovery abort to IDE test output + var payload = new DiscoveryCompletePayload() + { + IsAborted = true, + LastDiscoveredTests = null, + TotalTests = -1 + }; + var rawMessage = _dataSerializer.SerializePayload(MessageType.DiscoveryComplete, payload); + eventHandler.HandleRawMessage(rawMessage); + + // Complete discovery + eventHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, null); + } + + private string GetAbortErrorMessage(Exception exception, bool getClientError) + { + EqtTrace.Verbose("TestRequestSender: GetAbortErrorMessage: Exception: " + exception); - private string GetAbortErrorMessage(Exception exception, bool getClientError) + // It is also possible for an operation to abort even if client has not + // disconnected, e.g. if there's an error parsing the response from test host. We + // want the exception to be available in those scenarios. + var reason = exception?.Message; + if (getClientError) { - EqtTrace.Verbose("TestRequestSender: GetAbortErrorMessage: Exception: " + exception); + EqtTrace.Verbose("TestRequestSender: GetAbortErrorMessage: Client has disconnected. Wait for standard error."); - // It is also possible for an operation to abort even if client has not - // disconnected, e.g. if there's an error parsing the response from test host. We - // want the exception to be available in those scenarios. - var reason = exception?.Message; - if (getClientError) + // Wait for test host to exit for a moment + if (_clientExited.Wait(_clientExitedWaitTime)) { - EqtTrace.Verbose("TestRequestSender: GetAbortErrorMessage: Client has disconnected. Wait for standard error."); - - // Wait for test host to exit for a moment - if (this.clientExited.Wait(this.clientExitedWaitTime)) + // Set a default message of test host process exited and additionally specify the error if present + EqtTrace.Info("TestRequestSender: GetAbortErrorMessage: Received test host error message."); + reason = CommonResources.TestHostProcessCrashed; + if (!string.IsNullOrWhiteSpace(_clientExitErrorMessage)) { - // Set a default message of test host process exited and additionally specify the error if present - EqtTrace.Info("TestRequestSender: GetAbortErrorMessage: Received test host error message."); - reason = CommonResources.TestHostProcessCrashed; - if (!string.IsNullOrWhiteSpace(this.clientExitErrorMessage)) - { - reason = $"{reason} : {this.clientExitErrorMessage}"; - } - } - else - { - reason = CommonResources.UnableToCommunicateToTestHost; - EqtTrace.Info("TestRequestSender: GetAbortErrorMessage: Timed out waiting for test host error message."); + reason = $"{reason} : {_clientExitErrorMessage}"; } } - - return reason; - } - - private void LogErrorMessage(string message) - { - if (this.messageEventHandler == null) + else { - EqtTrace.Error("TestRequestSender.LogErrorMessage: Message event handler not set. Error: " + message); - return; + reason = CommonResources.UnableToCommunicateToTestHost; + EqtTrace.Info("TestRequestSender: GetAbortErrorMessage: Timed out waiting for test host error message."); } + } - // Log to vstest console - this.messageEventHandler.HandleLogMessage(TestMessageLevel.Error, message); + return reason; + } - // Log to vs ide test output - var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = message }; - var rawMessage = this.dataSerializer.SerializePayload(MessageType.TestMessage, testMessagePayload); - this.messageEventHandler.HandleRawMessage(rawMessage); + private void LogErrorMessage(string message) + { + if (_messageEventHandler == null) + { + EqtTrace.Error("TestRequestSender.LogErrorMessage: Message event handler not set. Error: " + message); + return; } - private bool IsOperationComplete() + // Log to vstest console + _messageEventHandler.HandleLogMessage(TestMessageLevel.Error, message); + + // Log to vs ide test output + var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = message }; + var rawMessage = _dataSerializer.SerializePayload(MessageType.TestMessage, testMessagePayload); + _messageEventHandler.HandleRawMessage(rawMessage); + } + + private bool IsOperationComplete() + { + return _operationCompleted == 1; + } + + private void SetOperationComplete() + { + // When sharing the testhost between discovery and execution we must keep the + // testhost alive after completing the operation it was spawned for. As such we + // suppress the test request sender channel close taking place here. This channel + // will be closed when the test session owner decides to dispose of the test session + // object. + if (!CloseConnectionOnOperationComplete) { - return this.operationCompleted == 1; + return; } - private void SetOperationComplete() + // Complete the currently ongoing operation (Discovery/Execution) + if (EqtTrace.IsVerboseEnabled) { - // When sharing the testhost between discovery and execution we must keep the - // testhost alive after completing the operation it was spawned for. As such we - // suppress the test request sender channel close taking place here. This channel - // will be closed when the test session owner decides to dispose of the test session - // object. - if (!this.CloseConnectionOnOperationComplete) - { - return; - } + EqtTrace.Verbose("TestRequestSender.SetOperationComplete: Setting operation complete."); + } + + _communicationEndpoint.Stop(); + Interlocked.CompareExchange(ref _operationCompleted, 1, 0); + } - // Complete the currently ongoing operation (Discovery/Execution) + private void SetCommunicationEndPoint() + { + // TODO: Use factory to get the communication endpoint. It will abstract out the type of communication endpoint like socket, shared memory or named pipe etc., + if (_connectionInfo.Role == ConnectionRole.Client) + { + _communicationEndpoint = new SocketClient(); if (EqtTrace.IsVerboseEnabled) { - EqtTrace.Verbose("TestRequestSender.SetOperationComplete: Setting operation complete."); + EqtTrace.Verbose("TestRequestSender is acting as client"); } - - this.communicationEndpoint.Stop(); - Interlocked.CompareExchange(ref this.operationCompleted, 1, 0); } - - private void SetCommunicationEndPoint() + else { - // TODO: Use factory to get the communication endpoint. It will abstract out the type of communication endpoint like socket, shared memory or named pipe etc., - if (this.connectionInfo.Role == ConnectionRole.Client) - { - this.communicationEndpoint = new SocketClient(); - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("TestRequestSender is acting as client"); - } - } - else + _communicationEndpoint = new SocketServer(); + if (EqtTrace.IsVerboseEnabled) { - this.communicationEndpoint = new SocketServer(); - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("TestRequestSender is acting as server"); - } + EqtTrace.Verbose("TestRequestSender is acting as server"); } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Constants.cs b/src/Microsoft.TestPlatform.CoreUtilities/Constants.cs index 31bb8f635b..970e516703 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Constants.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Constants.cs @@ -1,42 +1,41 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities +namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities; + +/// +/// The set of constants required for across various(Communication, CrossPlatform, etc.) modules. +/// +public class Constants { /// - /// The set of constants required for across various(Communication, CrossPlatform, etc.) modules. + /// Vstest.console process name, without file extension(.exe/.dll) /// - public class Constants - { - /// - /// Vstest.console process name, without file extension(.exe/.dll) - /// - public const string VstestConsoleProcessName = "vstest.console"; + public const string VstestConsoleProcessName = "vstest.console"; - /// - /// Testhost process name, without file extension(.exe/.dll) and architecture type(x86). - /// - public const string TesthostProcessName = "testhost"; + /// + /// Testhost process name, without file extension(.exe/.dll) and architecture type(x86). + /// + public const string TesthostProcessName = "testhost"; - /// - /// Datacollector process name, without file extension(.exe/.dll) - /// - public const string DatacollectorProcessName = "datacollector"; + /// + /// Datacollector process name, without file extension(.exe/.dll) + /// + public const string DatacollectorProcessName = "datacollector"; - /// - /// Number of character should be logged on child process exited with - /// error message on standard error. - /// - public const int StandardErrorMaxLength = 8192; // 8 KB + /// + /// Number of character should be logged on child process exited with + /// error message on standard error. + /// + public const int StandardErrorMaxLength = 8192; // 8 KB - /// - /// Environment Variable Specified by user to setup Culture. - /// - public const string DotNetUserSpecifiedCulture = "DOTNET_CLI_UI_LANGUAGE"; + /// + /// Environment Variable Specified by user to setup Culture. + /// + public const string DotNetUserSpecifiedCulture = "DOTNET_CLI_UI_LANGUAGE"; - /// - /// Test sources key name - /// - public const string TestSourcesKeyName = "TestSources"; - } -} + /// + /// Test sources key name + /// + public const string TestSourcesKeyName = "TestSources"; +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Extensions/StringBuilderExtensions.cs b/src/Microsoft.TestPlatform.CoreUtilities/Extensions/StringBuilderExtensions.cs index 52e27472bf..ce90f41571 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Extensions/StringBuilderExtensions.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Extensions/StringBuilderExtensions.cs @@ -1,40 +1,39 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions -{ - using System; - using System.Text; +namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; + +using System; +using System.Text; - public static class StringBuilderExtensions +public static class StringBuilderExtensions +{ + /// + /// Append given data from to string builder with new line. + /// + /// string builder + /// data to be appended. + /// + public static void AppendSafeWithNewLine(this StringBuilder result, string data) { - /// - /// Append given data from to string builder with new line. - /// - /// string builder - /// data to be appended. - /// - public static void AppendSafeWithNewLine(this StringBuilder result, string data) + if (!string.IsNullOrEmpty(data)) { - if (!string.IsNullOrEmpty(data)) + // Don't append more data if already reached max length. + if (result.Length >= result.MaxCapacity) { - // Don't append more data if already reached max length. - if (result.Length >= result.MaxCapacity) - { - return; - } - - // Add newline for readability. - data += Environment.NewLine; + return; + } - // Append sub string of data if appending all the data exceeds max capacity. - if (result.Length + data.Length >= result.MaxCapacity) - { - data = data.Substring(0, result.MaxCapacity - result.Length); - } + // Add newline for readability. + data += Environment.NewLine; - result.Append(data); + // Append sub string of data if appending all the data exceeds max capacity. + if (result.Length + data.Length >= result.MaxCapacity) + { + data = data.Substring(0, result.MaxCapacity - result.Length); } + + result.Append(data); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Extensions/StringExtensions.cs b/src/Microsoft.TestPlatform.CoreUtilities/Extensions/StringExtensions.cs index 1e04c64a9b..ea2d13bd7e 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Extensions/StringExtensions.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Extensions/StringExtensions.cs @@ -1,18 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions +namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; + +public static class StringExtensions { - public static class StringExtensions + /// + /// Add double quote around string. Useful in case of path which has white space in between. + /// + /// + /// + public static string AddDoubleQuote(this string value) { - /// - /// Add double quote around string. Useful in case of path which has white space in between. - /// - /// - /// - public static string AddDoubleQuote(this string value) - { - return "\"" + value + "\""; - } + return "\"" + value + "\""; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/CommandLineArgumentsHelper.cs b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/CommandLineArgumentsHelper.cs index e23a13d49f..5444f76ea4 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/CommandLineArgumentsHelper.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/CommandLineArgumentsHelper.cs @@ -1,92 +1,91 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers -{ - using System; - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; + +using System; +using System.Collections.Generic; +/// +/// Helper class for processing arguments passed to a process. +/// +public class CommandLineArgumentsHelper +{ /// - /// Helper class for processing arguments passed to a process. + /// Parse command line arguments to a dictionary. /// - public class CommandLineArgumentsHelper + /// Command line arguments. Ex: { "--port", "12312", "--parentprocessid", "2312", "--testsourcepath", "C:\temp\1.dll" } + /// Dictionary of arguments keys and values. + public static IDictionary GetArgumentsDictionary(string[] args) { - /// - /// Parse command line arguments to a dictionary. - /// - /// Command line arguments. Ex: { "--port", "12312", "--parentprocessid", "2312", "--testsourcepath", "C:\temp\1.dll" } - /// Dictionary of arguments keys and values. - public static IDictionary GetArgumentsDictionary(string[] args) + var argsDictionary = new Dictionary(); + if (args == null) { - var argsDictionary = new Dictionary(); - if (args == null) - { - return argsDictionary; - } + return argsDictionary; + } - for (int i = 0; i < args.Length; i++) + for (int i = 0; i < args.Length; i++) + { + if (args[i].StartsWith("-")) { - if (args[i].StartsWith("-")) + if (i < args.Length - 1 && !args[i + 1].StartsWith("-")) { - if (i < args.Length - 1 && !args[i + 1].StartsWith("-")) - { - argsDictionary.Add(args[i], args[i + 1]); - i++; - } - else - { - argsDictionary.Add(args[i], null); - } + argsDictionary.Add(args[i], args[i + 1]); + i++; + } + else + { + argsDictionary.Add(args[i], null); } } - - return argsDictionary; } - /// - /// Parse the value of an argument as an integer. - /// - /// Dictionary of all arguments Ex: { "--port":"12312", "--parentprocessid":"2312" } - /// The full name for required argument. Ex: "--port" - /// Value of the argument. - /// Thrown if value of an argument is not an integer. - public static int GetIntArgFromDict(IDictionary argsDictionary, string fullname) - { - var found = TryGetIntArgFromDict(argsDictionary, fullname, out var value); - return found ? value : 0; - } + return argsDictionary; + } - /// - /// Try get the argument and parse the value of an argument as an integer. - /// - /// Dictionary of all arguments Ex: { "--port":"12312", "--parentprocessid":"2312" } - /// The full name for required argument. Ex: "--port" - /// Value of the argument. - /// Thrown if value of an argument is not an integer. - public static bool TryGetIntArgFromDict(IDictionary argsDictionary, string fullname, out int value) - { - var found = argsDictionary.TryGetValue(fullname, out var optionValue); - if (!found) - { - value = default; - return false; - } + /// + /// Parse the value of an argument as an integer. + /// + /// Dictionary of all arguments Ex: { "--port":"12312", "--parentprocessid":"2312" } + /// The full name for required argument. Ex: "--port" + /// Value of the argument. + /// Thrown if value of an argument is not an integer. + public static int GetIntArgFromDict(IDictionary argsDictionary, string fullname) + { + var found = TryGetIntArgFromDict(argsDictionary, fullname, out var value); + return found ? value : 0; + } - value = int.Parse(optionValue); - return true; + /// + /// Try get the argument and parse the value of an argument as an integer. + /// + /// Dictionary of all arguments Ex: { "--port":"12312", "--parentprocessid":"2312" } + /// The full name for required argument. Ex: "--port" + /// Value of the argument. + /// Thrown if value of an argument is not an integer. + public static bool TryGetIntArgFromDict(IDictionary argsDictionary, string fullname, out int value) + { + var found = argsDictionary.TryGetValue(fullname, out var optionValue); + if (!found) + { + value = default; + return false; } + value = int.Parse(optionValue); + return true; + } - /// - /// Parse the value of an argument as a string. - /// - /// Dictionary of all arguments Ex: { "--port":"12312", "--parentprocessid":"2312" } - /// The full name for required argument. Ex: "--port" - /// Value of the argument. - /// Thrown if value of an argument is not an integer. - public static string GetStringArgFromDict(IDictionary argsDictionary, string fullname) - { - return argsDictionary.TryGetValue(fullname, out var optionValue) ? optionValue : string.Empty; - } + + /// + /// Parse the value of an argument as a string. + /// + /// Dictionary of all arguments Ex: { "--port":"12312", "--parentprocessid":"2312" } + /// The full name for required argument. Ex: "--port" + /// Value of the argument. + /// Thrown if value of an argument is not an integer. + public static string GetStringArgFromDict(IDictionary argsDictionary, string fullname) + { + return argsDictionary.TryGetValue(fullname, out var optionValue) ? optionValue : string.Empty; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/DotnetHostHelper.cs b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/DotnetHostHelper.cs index 613c9a7cb6..160331bfb5 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/DotnetHostHelper.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/DotnetHostHelper.cs @@ -3,281 +3,211 @@ #if !NETSTANDARD1_0 -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers; + +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; +using CoreUtilities.Resources; +using Interfaces; +using ObjectModel; +using PlatformAbstractions; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Win32; + +using System; +using System.IO; +using System.Reflection.PortableExecutable; + +public class DotnetHostHelper : IDotnetHostHelper { - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Resources; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.Win32; - using System; - using System.IO; - using System.Reflection.PortableExecutable; - - public class DotnetHostHelper : IDotnetHostHelper + public const string MONOEXENAME = "mono"; + + private readonly IFileHelper _fileHelper; + private readonly IEnvironment _environment; + private readonly IWindowsRegistryHelper _windowsRegistryHelper; + private readonly IEnvironmentVariableHelper _environmentVariableHelper; + private readonly IProcessHelper _processHelper; + private readonly string _muxerName; + + /// + /// Initializes a new instance of the class. + /// + public DotnetHostHelper() : this(new FileHelper(), new PlatformEnvironment(), new WindowsRegistryHelper(), new EnvironmentVariableHelper(), new ProcessHelper()) { - public const string MONOEXENAME = "mono"; - - private readonly IFileHelper fileHelper; - private readonly IEnvironment environment; - private readonly IWindowsRegistryHelper windowsRegistryHelper; - private readonly IEnvironmentVariableHelper environmentVariableHelper; - private readonly IProcessHelper processHelper; - private readonly string muxerName; - - /// - /// Initializes a new instance of the class. - /// - public DotnetHostHelper() : this(new FileHelper(), new PlatformEnvironment(), new WindowsRegistryHelper(), new EnvironmentVariableHelper(), new ProcessHelper()) - { - } + } - /// - /// Initializes a new instance of the class. - /// - /// File Helper - /// Environment Helper - public DotnetHostHelper(IFileHelper fileHelper, IEnvironment environment) : this(fileHelper, environment, new WindowsRegistryHelper(), new EnvironmentVariableHelper(), new ProcessHelper()) - { - } + /// + /// Initializes a new instance of the class. + /// + /// File Helper + /// Environment Helper + public DotnetHostHelper(IFileHelper fileHelper, IEnvironment environment) : this(fileHelper, environment, new WindowsRegistryHelper(), new EnvironmentVariableHelper(), new ProcessHelper()) + { + } - /// - /// Initializes a new instance of the class. - /// - /// File Helper - /// Environment Helper - /// WindowsRegistry Helper - /// EnvironmentVariable Helper - /// Process Helper - internal DotnetHostHelper( - IFileHelper fileHelper, - IEnvironment environment, - IWindowsRegistryHelper windowsRegistryHelper, - IEnvironmentVariableHelper environmentVariableHelper, - IProcessHelper processHelper) - { - this.fileHelper = fileHelper; - this.environment = environment; - this.windowsRegistryHelper = windowsRegistryHelper; - this.environmentVariableHelper = environmentVariableHelper; - this.processHelper = processHelper; - this.muxerName = environment.OperatingSystem == PlatformOperatingSystem.Windows ? "dotnet.exe" : "dotnet"; - } + /// + /// Initializes a new instance of the class. + /// + /// File Helper + /// Environment Helper + /// WindowsRegistry Helper + /// EnvironmentVariable Helper + /// Process Helper + internal DotnetHostHelper( + IFileHelper fileHelper, + IEnvironment environment, + IWindowsRegistryHelper windowsRegistryHelper, + IEnvironmentVariableHelper environmentVariableHelper, + IProcessHelper processHelper) + { + _fileHelper = fileHelper; + _environment = environment; + _windowsRegistryHelper = windowsRegistryHelper; + _environmentVariableHelper = environmentVariableHelper; + _processHelper = processHelper; + _muxerName = environment.OperatingSystem == PlatformOperatingSystem.Windows ? "dotnet.exe" : "dotnet"; + } - /// - public string GetDotnetPath() + /// + public string GetDotnetPath() + { + if (!TryGetExecutablePath("dotnet", out var dotnetPath)) { - if (!TryGetExecutablePath("dotnet", out var dotnetPath)) - { - string errorMessage = string.Format(Resources.NoDotnetExeFound, "dotnet"); - - EqtTrace.Error(errorMessage); - throw new FileNotFoundException(errorMessage); - } + string errorMessage = string.Format(Resources.NoDotnetExeFound, "dotnet"); - return dotnetPath; + EqtTrace.Error(errorMessage); + throw new FileNotFoundException(errorMessage); } - public string GetMonoPath() - { - if (!TryGetExecutablePath(MONOEXENAME, out var monoPath)) - { - string errorMessage = string.Format(Resources.NoDotnetExeFound, MONOEXENAME); + return dotnetPath; + } - EqtTrace.Error(errorMessage); - throw new FileNotFoundException(errorMessage); - } + public string GetMonoPath() + { + if (!TryGetExecutablePath(MONOEXENAME, out var monoPath)) + { + string errorMessage = string.Format(Resources.NoDotnetExeFound, MONOEXENAME); - return monoPath; + EqtTrace.Error(errorMessage); + throw new FileNotFoundException(errorMessage); } - private bool TryGetExecutablePath(string executableBaseName, out string executablePath) - { - if (this.environment.OperatingSystem.Equals(PlatformOperatingSystem.Windows)) - { - executableBaseName += ".exe"; - } - - executablePath = string.Empty; - var pathString = Environment.GetEnvironmentVariable("PATH"); - foreach (string path in pathString.Split(Path.PathSeparator)) - { - string exeFullPath = Path.Combine(path.Trim(), executableBaseName); - if (this.fileHelper.Exists(exeFullPath)) - { - executablePath = exeFullPath; - return true; - } - } + return monoPath; + } - return false; + private bool TryGetExecutablePath(string executableBaseName, out string executablePath) + { + if (_environment.OperatingSystem.Equals(PlatformOperatingSystem.Windows)) + { + executableBaseName += ".exe"; } - public bool TryGetDotnetPathByArchitecture(PlatformArchitecture targetArchitecture, out string muxerPath) + executablePath = string.Empty; + var pathString = Environment.GetEnvironmentVariable("PATH"); + foreach (string path in pathString.Split(Path.PathSeparator)) { - if (this.processHelper.GetCurrentProcessArchitecture() == targetArchitecture) + string exeFullPath = Path.Combine(path.Trim(), executableBaseName); + if (_fileHelper.Exists(exeFullPath)) { - string currentProcessFileName = this.processHelper.GetCurrentProcessFileName(); - if (Path.GetFileName(currentProcessFileName) != this.muxerName) - { - EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Target architecture is the same as the current process architecture '{targetArchitecture}', but the current process is not a muxer: '{currentProcessFileName}'"); - } - else - { - muxerPath = currentProcessFileName; - EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Target architecture is the same as the current process architecture '{targetArchitecture}', and the current process is a muxer, using that: '{muxerPath}'"); - return true; - } + executablePath = exeFullPath; + return true; } + } - // We used similar approach as the runtime resolver. - // https://github.com/dotnet/runtime/blob/main/src/native/corehost/fxr_resolver.cpp#L55 - - bool isWinOs = environment.OperatingSystem == PlatformOperatingSystem.Windows; - EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Searching for muxer named '{muxerName}'"); - - // Try to search using env vars in the order - // DOTNET_ROOT_{arch} - // DOTNET_ROOT(x86) if X86 on Win (here we cannot check if current process is WOW64 because this is SDK process arch and not real host arch so it's irrelevant) - // "DOTNET_ROOT(x86) is used instead when running a 32-bit executable on a 64-bit OS." - // DOTNET_ROOT - string envKey = $"DOTNET_ROOT_{targetArchitecture.ToString().ToUpperInvariant()}"; - - // Try on arch specific env var - string envVar = this.environmentVariableHelper.GetEnvironmentVariable(envKey); + return false; + } - // Try on non virtualized x86 var(should happen only on non-x86 architecture) - if ((envVar == null || !this.fileHelper.DirectoryExists(envVar)) && - targetArchitecture == PlatformArchitecture.X86 && this.environment.OperatingSystem == PlatformOperatingSystem.Windows) + public bool TryGetDotnetPathByArchitecture(PlatformArchitecture targetArchitecture, out string muxerPath) + { + if (_processHelper.GetCurrentProcessArchitecture() == targetArchitecture) + { + string currentProcessFileName = _processHelper.GetCurrentProcessFileName(); + if (Path.GetFileName(currentProcessFileName) != _muxerName) { - envKey = $"DOTNET_ROOT(x86)"; - envVar = this.environmentVariableHelper.GetEnvironmentVariable(envKey); + EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Target architecture is the same as the current process architecture '{targetArchitecture}', but the current process is not a muxer: '{currentProcessFileName}'"); } - - // Try on default DOTNET_ROOT - if (envVar == null || !this.fileHelper.DirectoryExists(envVar)) + else { - envKey = "DOTNET_ROOT"; - envVar = this.environmentVariableHelper.GetEnvironmentVariable(envKey); + muxerPath = currentProcessFileName; + EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Target architecture is the same as the current process architecture '{targetArchitecture}', and the current process is a muxer, using that: '{muxerPath}'"); + return true; } + } - if (envVar != null) - { - // If directory specified by env vars does not exists, it's like env var doesn't exists as well. - if (!this.fileHelper.DirectoryExists(envVar)) - { - EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Folder specified by env variable does not exist: '{envVar}={envKey}'"); - } - else - { - muxerPath = Path.Combine(envVar, muxerName); - if (!this.fileHelper.Exists(muxerPath)) - { - // If environment variable was specified, and the directory it points at exists, but it does not contain a muxer, or the muxer is incompatible with the target architecture - // we stop the search to be compliant with the approach that apphost (compiled .NET executables) use to find the muxer. - EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Folder specified by env variable does not contain any muxer: '{envVar}={envKey}'"); - muxerPath = null; - return false; - } + // We used similar approach as the runtime resolver. + // https://github.com/dotnet/runtime/blob/main/src/native/corehost/fxr_resolver.cpp#L55 - if (!IsValidArchitectureMuxer(targetArchitecture, muxerPath)) - { - EqtTrace.Verbose($"DotnetHostHelper: Invalid muxer resolved using env var key '{envKey}' in '{envVar}'"); - muxerPath = null; - return false; - } + bool isWinOs = _environment.OperatingSystem == PlatformOperatingSystem.Windows; + EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Searching for muxer named '{_muxerName}'"); - EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer compatible with '{targetArchitecture}' resolved from env variable '{envKey}' in '{muxerPath}'"); - return true; - } - } + // Try to search using env vars in the order + // DOTNET_ROOT_{arch} + // DOTNET_ROOT(x86) if X86 on Win (here we cannot check if current process is WOW64 because this is SDK process arch and not real host arch so it's irrelevant) + // "DOTNET_ROOT(x86) is used instead when running a 32-bit executable on a 64-bit OS." + // DOTNET_ROOT + string envKey = $"DOTNET_ROOT_{targetArchitecture.ToString().ToUpperInvariant()}"; + + // Try on arch specific env var + string envVar = _environmentVariableHelper.GetEnvironmentVariable(envKey); + + // Try on non virtualized x86 var(should happen only on non-x86 architecture) + if ((envVar == null || !_fileHelper.DirectoryExists(envVar)) && + targetArchitecture == PlatformArchitecture.X86 && _environment.OperatingSystem == PlatformOperatingSystem.Windows) + { + envKey = $"DOTNET_ROOT(x86)"; + envVar = _environmentVariableHelper.GetEnvironmentVariable(envKey); + } - EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer was not found using DOTNET_ROOT* env variables."); + // Try on default DOTNET_ROOT + if (envVar == null || !_fileHelper.DirectoryExists(envVar)) + { + envKey = "DOTNET_ROOT"; + envVar = _environmentVariableHelper.GetEnvironmentVariable(envKey); + } - // Try to search for global registration - if (isWinOs) + if (envVar != null) + { + // If directory specified by env vars does not exists, it's like env var doesn't exists as well. + if (!_fileHelper.DirectoryExists(envVar)) { - muxerPath = GetMuxerFromGlobalRegistrationWin(targetArchitecture); + EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Folder specified by env variable does not exist: '{envVar}={envKey}'"); } else { - muxerPath = GetMuxerFromGlobalRegistrationOnUnix(targetArchitecture); - } - - if (muxerPath != null) - { - if (!this.fileHelper.Exists(muxerPath)) + muxerPath = Path.Combine(envVar, _muxerName); + if (!_fileHelper.Exists(muxerPath)) { - // If muxer doesn't exists or it's wrong we stop the search - EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer file not found for global registration '{muxerPath}'"); + // If environment variable was specified, and the directory it points at exists, but it does not contain a muxer, or the muxer is incompatible with the target architecture + // we stop the search to be compliant with the approach that apphost (compiled .NET executables) use to find the muxer. + EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Folder specified by env variable does not contain any muxer: '{envVar}={envKey}'"); muxerPath = null; return false; } if (!IsValidArchitectureMuxer(targetArchitecture, muxerPath)) { - // If muxer is wrong we stop the search - EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer resolved using global registration is not compatible with the target architecture: '{muxerPath}'"); + EqtTrace.Verbose($"DotnetHostHelper: Invalid muxer resolved using env var key '{envKey}' in '{envVar}'"); muxerPath = null; return false; } - EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer compatible with '{targetArchitecture}' resolved from global registration: '{muxerPath}'"); + EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer compatible with '{targetArchitecture}' resolved from env variable '{envKey}' in '{muxerPath}'"); return true; } + } - EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer not found using global registrations"); + EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer was not found using DOTNET_ROOT* env variables."); - // Try searching in default installation location if it exists - if (isWinOs) - { - // If we're on x64/arm64 SDK and target is x86 we need to search on non virtualized windows folder - if ((this.environment.Architecture == PlatformArchitecture.X64 || this.environment.Architecture == PlatformArchitecture.ARM64) && - targetArchitecture == PlatformArchitecture.X86) - { - muxerPath = Path.Combine(this.environmentVariableHelper.GetEnvironmentVariable("ProgramFiles(x86)"), "dotnet", muxerName); - } - else - { - // If we're on ARM and target is x64 we expect correct installation inside x64 folder - if (this.environment.Architecture == PlatformArchitecture.ARM64 && targetArchitecture == PlatformArchitecture.X64) - { - muxerPath = Path.Combine(this.environmentVariableHelper.GetEnvironmentVariable("ProgramFiles"), "dotnet", "x64", muxerName); - } - else - { - muxerPath = Path.Combine(this.environmentVariableHelper.GetEnvironmentVariable("ProgramFiles"), "dotnet", muxerName); - } - } - } - else - { - if (this.environment.OperatingSystem == PlatformOperatingSystem.OSX) - { - // If we're on ARM and target is x64 we expect correct installation inside x64 folder - if (this.environment.Architecture == PlatformArchitecture.ARM64 && targetArchitecture == PlatformArchitecture.X64) - { - muxerPath = Path.Combine("/usr/local/share/dotnet/x64", muxerName); - } - else - { - muxerPath = Path.Combine("/usr/local/share/dotnet", muxerName); - } - } - else - { - muxerPath = Path.Combine("/usr/share/dotnet", muxerName); - } - } + // Try to search for global registration + muxerPath = isWinOs ? GetMuxerFromGlobalRegistrationWin(targetArchitecture) : GetMuxerFromGlobalRegistrationOnUnix(targetArchitecture); - if (!this.fileHelper.Exists(muxerPath)) + if (muxerPath != null) + { + if (!_fileHelper.Exists(muxerPath)) { - // If muxer doesn't exists we stop the search - EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer was not found in default installation location: '{muxerPath}'"); + // If muxer doesn't exists or it's wrong we stop the search + EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer file not found for global registration '{muxerPath}'"); muxerPath = null; return false; } @@ -285,206 +215,237 @@ public bool TryGetDotnetPathByArchitecture(PlatformArchitecture targetArchitectu if (!IsValidArchitectureMuxer(targetArchitecture, muxerPath)) { // If muxer is wrong we stop the search - EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer resolved in default installation path is not compatible with the target architecture: '{muxerPath}'"); + EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer resolved using global registration is not compatible with the target architecture: '{muxerPath}'"); muxerPath = null; return false; } - EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer compatible with '{targetArchitecture}' resolved from default installation path: '{muxerPath}'"); + EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer compatible with '{targetArchitecture}' resolved from global registration: '{muxerPath}'"); return true; } - private string GetMuxerFromGlobalRegistrationWin(PlatformArchitecture targetArchitecture) + EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer not found using global registrations"); + + // Try searching in default installation location if it exists + if (isWinOs) { - // Installed version are always in 32-bit view of registry - // https://github.com/dotnet/designs/blob/main/accepted/2020/install-locations.md#globally-registered-install-location-new - // "Note that this registry key is "redirected" that means that 32-bit processes see different copy of the key than 64bit processes. - // So it's important that both installers and the host access only the 32-bit view of the registry." - using (IRegistryKey hklm = windowsRegistryHelper.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)) + // If we're on x64/arm64 SDK and target is x86 we need to search on non virtualized windows folder + if ((_environment.Architecture == PlatformArchitecture.X64 || _environment.Architecture == PlatformArchitecture.ARM64) && + targetArchitecture == PlatformArchitecture.X86) { - if (hklm != null) - { - using (IRegistryKey dotnetInstalledVersion = hklm.OpenSubKey(@"SOFTWARE\dotnet\Setup\InstalledVersions")) - { - if (dotnetInstalledVersion != null) - { - using (IRegistryKey nativeArch = dotnetInstalledVersion.OpenSubKey(targetArchitecture.ToString().ToLowerInvariant())) - { - string installLocation = nativeArch?.GetValue("InstallLocation")?.ToString(); - - if (installLocation != null) - { - string path = Path.Combine(installLocation.Trim(), this.muxerName); - EqtTrace.Verbose($@"DotnetHostHelper.GetMuxerFromGlobalRegistrationWin: Muxer resolved using win registry key 'SOFTWARE\dotnet\Setup\InstalledVersions\{targetArchitecture.ToString().ToLowerInvariant()}\InstallLocation' in '{path}'"); - return path; - } - else - { - EqtTrace.Verbose($@"DotnetHostHelper.GetMuxerFromGlobalRegistrationWin: Missing registry InstallLocation"); - } - } - } - else - { - EqtTrace.Verbose($@"DotnetHostHelper.GetMuxerFromGlobalRegistrationWin: Missing RegistryHive.LocalMachine for RegistryView.Registry32"); - } - } - } - else - { - EqtTrace.Verbose($@"DotnetHostHelper.GetMuxerFromGlobalRegistrationWin: Missing SOFTWARE\dotnet\Setup\InstalledVersions subkey"); - } + muxerPath = Path.Combine(_environmentVariableHelper.GetEnvironmentVariable("ProgramFiles(x86)"), "dotnet", _muxerName); + } + else + { + // If we're on ARM and target is x64 we expect correct installation inside x64 folder + muxerPath = _environment.Architecture == PlatformArchitecture.ARM64 && targetArchitecture == PlatformArchitecture.X64 + ? Path.Combine(_environmentVariableHelper.GetEnvironmentVariable("ProgramFiles"), "dotnet", "x64", _muxerName) + : Path.Combine(_environmentVariableHelper.GetEnvironmentVariable("ProgramFiles"), "dotnet", _muxerName); + } + } + else + { + if (_environment.OperatingSystem == PlatformOperatingSystem.OSX) + { + // If we're on ARM and target is x64 we expect correct installation inside x64 folder + muxerPath = _environment.Architecture == PlatformArchitecture.ARM64 && targetArchitecture == PlatformArchitecture.X64 + ? Path.Combine("/usr/local/share/dotnet/x64", _muxerName) + : Path.Combine("/usr/local/share/dotnet", _muxerName); + } + else + { + muxerPath = Path.Combine("/usr/share/dotnet", _muxerName); } - - return null; } - private string GetMuxerFromGlobalRegistrationOnUnix(PlatformArchitecture targetArchitecture) + if (!_fileHelper.Exists(muxerPath)) { - string baseInstallLocation = "/etc/dotnet/"; + // If muxer doesn't exists we stop the search + EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer was not found in default installation location: '{muxerPath}'"); + muxerPath = null; + return false; + } - // We search for architecture specific installation - string installLocation = $"{baseInstallLocation}install_location_{targetArchitecture.ToString().ToLowerInvariant()}"; + if (!IsValidArchitectureMuxer(targetArchitecture, muxerPath)) + { + // If muxer is wrong we stop the search + EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer resolved in default installation path is not compatible with the target architecture: '{muxerPath}'"); + muxerPath = null; + return false; + } - // We try to load archless install location file - if (!this.fileHelper.Exists(installLocation)) - { - installLocation = $"{baseInstallLocation}install_location"; - } + EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Muxer compatible with '{targetArchitecture}' resolved from default installation path: '{muxerPath}'"); + return true; + } - if (this.fileHelper.Exists(installLocation)) + private string GetMuxerFromGlobalRegistrationWin(PlatformArchitecture targetArchitecture) + { + // Installed version are always in 32-bit view of registry + // https://github.com/dotnet/designs/blob/main/accepted/2020/install-locations.md#globally-registered-install-location-new + // "Note that this registry key is "redirected" that means that 32-bit processes see different copy of the key than 64bit processes. + // So it's important that both installers and the host access only the 32-bit view of the registry." + using (IRegistryKey hklm = _windowsRegistryHelper.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)) + { + if (hklm != null) { - try + using IRegistryKey dotnetInstalledVersion = hklm.OpenSubKey(@"SOFTWARE\dotnet\Setup\InstalledVersions"); + if (dotnetInstalledVersion != null) { - using (Stream stream = this.fileHelper.GetStream(installLocation, FileMode.Open, FileAccess.Read)) - using (StreamReader streamReader = new StreamReader(stream)) + using IRegistryKey nativeArch = dotnetInstalledVersion.OpenSubKey(targetArchitecture.ToString().ToLowerInvariant()); + string installLocation = nativeArch?.GetValue("InstallLocation")?.ToString(); + + if (installLocation != null) { - string content = streamReader.ReadToEnd().Trim(); - EqtTrace.Verbose($"DotnetHostHelper: '{installLocation}' content '{content}'"); - string path = Path.Combine(content, this.muxerName); - EqtTrace.Verbose($"DotnetHostHelper: Muxer resolved using '{installLocation}' in '{path}'"); + string path = Path.Combine(installLocation.Trim(), _muxerName); + EqtTrace.Verbose($@"DotnetHostHelper.GetMuxerFromGlobalRegistrationWin: Muxer resolved using win registry key 'SOFTWARE\dotnet\Setup\InstalledVersions\{targetArchitecture.ToString().ToLowerInvariant()}\InstallLocation' in '{path}'"); return path; } + else + { + EqtTrace.Verbose($@"DotnetHostHelper.GetMuxerFromGlobalRegistrationWin: Missing registry InstallLocation"); + } } - catch (Exception ex) + else { - EqtTrace.Error($"DotnetHostHelper.GetMuxerFromGlobalRegistrationOnUnix: Exception during '{installLocation}' muxer resolution.\n{ex}"); + EqtTrace.Verbose($@"DotnetHostHelper.GetMuxerFromGlobalRegistrationWin: Missing RegistryHive.LocalMachine for RegistryView.Registry32"); } } + else + { + EqtTrace.Verbose($@"DotnetHostHelper.GetMuxerFromGlobalRegistrationWin: Missing SOFTWARE\dotnet\Setup\InstalledVersions subkey"); + } + } + + return null; + } + + private string GetMuxerFromGlobalRegistrationOnUnix(PlatformArchitecture targetArchitecture) + { + string baseInstallLocation = "/etc/dotnet/"; + + // We search for architecture specific installation + string installLocation = $"{baseInstallLocation}install_location_{targetArchitecture.ToString().ToLowerInvariant()}"; - return null; + // We try to load archless install location file + if (!_fileHelper.Exists(installLocation)) + { + installLocation = $"{baseInstallLocation}install_location"; } - private PlatformArchitecture? GetMuxerArchitectureByPEHeaderOnWin(string path) + if (_fileHelper.Exists(installLocation)) { try { - using (Stream stream = this.fileHelper.GetStream(path, FileMode.Open, FileAccess.Read)) - using (PEReader peReader = new PEReader(stream)) - { - switch (peReader.PEHeaders.CoffHeader.Machine) - { - case Machine.Amd64: - return PlatformArchitecture.X64; - case Machine.IA64: - return PlatformArchitecture.X64; - case Machine.Arm64: - return PlatformArchitecture.ARM64; - case Machine.Arm: - return PlatformArchitecture.ARM; - case Machine.I386: - return PlatformArchitecture.X86; - default: - break; - } - } + using Stream stream = _fileHelper.GetStream(installLocation, FileMode.Open, FileAccess.Read); + using StreamReader streamReader = new(stream); + string content = streamReader.ReadToEnd().Trim(); + EqtTrace.Verbose($"DotnetHostHelper: '{installLocation}' content '{content}'"); + string path = Path.Combine(content, _muxerName); + EqtTrace.Verbose($"DotnetHostHelper: Muxer resolved using '{installLocation}' in '{path}'"); + return path; } catch (Exception ex) { - EqtTrace.Error($"DotnetHostHelper.GetMuxerArchitectureByPEHeaderOnWin: Failed to get architecture from PEHeader for '{path}'\n{ex}"); + EqtTrace.Error($"DotnetHostHelper.GetMuxerFromGlobalRegistrationOnUnix: Exception during '{installLocation}' muxer resolution.\n{ex}"); } - - return null; } - // See https://opensource.apple.com/source/xnu/xnu-2050.18.24/EXTERNAL_HEADERS/mach-o/loader.h - // https://opensource.apple.com/source/xnu/xnu-4570.41.2/osfmk/mach/machine.h.auto.html - private PlatformArchitecture? GetMuxerArchitectureByMachoOnMac(string path) - { - try - { - PlatformArchitecture? architecture; - using (var headerReader = this.fileHelper.GetStream(path, FileMode.Open, FileAccess.Read)) - { - var magicBytes = new byte[4]; - var cpuInfoBytes = new byte[4]; - headerReader.Read(magicBytes, 0, magicBytes.Length); - headerReader.Read(cpuInfoBytes, 0, cpuInfoBytes.Length); - - var magic = BitConverter.ToUInt32(magicBytes, 0); - var cpuInfo = BitConverter.ToUInt32(cpuInfoBytes, 0); - switch ((MacOsCpuType)cpuInfo) - { - case MacOsCpuType.Arm64Magic: - case MacOsCpuType.Arm64Cigam: - architecture = PlatformArchitecture.ARM64; - break; - case MacOsCpuType.X64Magic: - case MacOsCpuType.X64Cigam: - architecture = PlatformArchitecture.X64; - break; - case MacOsCpuType.X86Magic: - case MacOsCpuType.X86Cigam: - architecture = PlatformArchitecture.X86; - break; - default: - architecture = null; - break; - } + return null; + } - return architecture; - } - } - catch (Exception ex) + private PlatformArchitecture? GetMuxerArchitectureByPEHeaderOnWin(string path) + { + try + { + using Stream stream = _fileHelper.GetStream(path, FileMode.Open, FileAccess.Read); + using PEReader peReader = new(stream); + switch (peReader.PEHeaders.CoffHeader.Machine) { - // In case of failure during header reading we must fallback to the next place(default installation path) - EqtTrace.Error($"DotnetHostHelper.GetMuxerArchitectureByMachoOnMac: Failed to get architecture from Mach-O for '{path}'\n{ex}"); + case Machine.Amd64: + return PlatformArchitecture.X64; + case Machine.IA64: + return PlatformArchitecture.X64; + case Machine.Arm64: + return PlatformArchitecture.ARM64; + case Machine.Arm: + return PlatformArchitecture.ARM; + case Machine.I386: + return PlatformArchitecture.X86; + default: + break; } - - return null; } - - internal enum MacOsCpuType : uint + catch (Exception ex) { - Arm64Magic = 0x0100000c, - Arm64Cigam = 0x0c000001, - X64Magic = 0x01000007, - X64Cigam = 0x07000001, - X86Magic = 0x00000007, - X86Cigam = 0x07000000 + EqtTrace.Error($"DotnetHostHelper.GetMuxerArchitectureByPEHeaderOnWin: Failed to get architecture from PEHeader for '{path}'\n{ex}"); } - private bool IsValidArchitectureMuxer(PlatformArchitecture targetArchitecture, string path) + return null; + } + + // See https://opensource.apple.com/source/xnu/xnu-2050.18.24/EXTERNAL_HEADERS/mach-o/loader.h + // https://opensource.apple.com/source/xnu/xnu-4570.41.2/osfmk/mach/machine.h.auto.html + private PlatformArchitecture? GetMuxerArchitectureByMachoOnMac(string path) + { + try { - PlatformArchitecture? muxerPlatform = null; - if (this.environment.OperatingSystem == PlatformOperatingSystem.Windows) + using var headerReader = _fileHelper.GetStream(path, FileMode.Open, FileAccess.Read); + var magicBytes = new byte[4]; + var cpuInfoBytes = new byte[4]; + headerReader.Read(magicBytes, 0, magicBytes.Length); + headerReader.Read(cpuInfoBytes, 0, cpuInfoBytes.Length); + + var magic = BitConverter.ToUInt32(magicBytes, 0); + var cpuInfo = BitConverter.ToUInt32(cpuInfoBytes, 0); + PlatformArchitecture? architecture = (MacOsCpuType)cpuInfo switch { - muxerPlatform = GetMuxerArchitectureByPEHeaderOnWin(path); - } - else if (this.environment.OperatingSystem == PlatformOperatingSystem.OSX) - { - muxerPlatform = GetMuxerArchitectureByMachoOnMac(path); - } + MacOsCpuType.Arm64Magic or MacOsCpuType.Arm64Cigam => PlatformArchitecture.ARM64, + MacOsCpuType.X64Magic or MacOsCpuType.X64Cigam => PlatformArchitecture.X64, + MacOsCpuType.X86Magic or MacOsCpuType.X86Cigam => PlatformArchitecture.X86, + _ => null, + }; - if (targetArchitecture != muxerPlatform) - { - EqtTrace.Verbose($"DotnetHostHelper.IsValidArchitectureMuxer: Incompatible architecture muxer, target architecture '{targetArchitecture}', actual '{muxerPlatform}'"); - return false; - } + return architecture; + } + catch (Exception ex) + { + // In case of failure during header reading we must fallback to the next place(default installation path) + EqtTrace.Error($"DotnetHostHelper.GetMuxerArchitectureByMachoOnMac: Failed to get architecture from Mach-O for '{path}'\n{ex}"); + } - EqtTrace.Verbose($"DotnetHostHelper.IsValidArchitectureMuxer: Compatible architecture muxer, target architecture '{targetArchitecture}', actual '{muxerPlatform}'"); - return true; + return null; + } + + internal enum MacOsCpuType : uint + { + Arm64Magic = 0x0100000c, + Arm64Cigam = 0x0c000001, + X64Magic = 0x01000007, + X64Cigam = 0x07000001, + X86Magic = 0x00000007, + X86Cigam = 0x07000000 + } + + private bool IsValidArchitectureMuxer(PlatformArchitecture targetArchitecture, string path) + { + PlatformArchitecture? muxerPlatform = null; + if (_environment.OperatingSystem == PlatformOperatingSystem.Windows) + { + muxerPlatform = GetMuxerArchitectureByPEHeaderOnWin(path); + } + else if (_environment.OperatingSystem == PlatformOperatingSystem.OSX) + { + muxerPlatform = GetMuxerArchitectureByMachoOnMac(path); } + + if (targetArchitecture != muxerPlatform) + { + EqtTrace.Verbose($"DotnetHostHelper.IsValidArchitectureMuxer: Incompatible architecture muxer, target architecture '{targetArchitecture}', actual '{muxerPlatform}'"); + return false; + } + + EqtTrace.Verbose($"DotnetHostHelper.IsValidArchitectureMuxer: Compatible architecture muxer, target architecture '{targetArchitecture}', actual '{muxerPlatform}'"); + return true; } } diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/EnvironmentHelper.cs b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/EnvironmentHelper.cs index 032d9c1275..069962be71 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/EnvironmentHelper.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/EnvironmentHelper.cs @@ -1,39 +1,40 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers -{ - using ObjectModel; +namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; - using System; +using ObjectModel; - public class EnvironmentHelper - { - public const string VstestConnectionTimeout = "VSTEST_CONNECTION_TIMEOUT"; - public const int DefaultConnectionTimeout = 90; // seconds +#if !NETSTANDARD1_0 +using System; +#endif - /// - /// Get timeout based on environment variable VSTEST_CONNECTION_TIMEOUT. - /// - public static int GetConnectionTimeout() - { +public class EnvironmentHelper +{ + public const string VstestConnectionTimeout = "VSTEST_CONNECTION_TIMEOUT"; + public const int DefaultConnectionTimeout = 90; // seconds + + /// + /// Get timeout based on environment variable VSTEST_CONNECTION_TIMEOUT. + /// + public static int GetConnectionTimeout() + { #if NETSTANDARD1_0 - var envVarValue = string.Empty; + var envVarValue = string.Empty; #else - var envVarValue = Environment.GetEnvironmentVariable(VstestConnectionTimeout); + var envVarValue = Environment.GetEnvironmentVariable(VstestConnectionTimeout); #endif - if (!string.IsNullOrEmpty(envVarValue) && int.TryParse(envVarValue, out int value) && value >= 0) - { - EqtTrace.Info("EnvironmentHelper.GetConnectionTimeout: {0} value set to {1}.", VstestConnectionTimeout, value); - } - else - { - value = DefaultConnectionTimeout; - } - - return value; + if (!string.IsNullOrEmpty(envVarValue) && int.TryParse(envVarValue, out int value) && value >= 0) + { + EqtTrace.Info("EnvironmentHelper.GetConnectionTimeout: {0} value set to {1}.", VstestConnectionTimeout, value); } + else + { + value = DefaultConnectionTimeout; + } + + return value; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/EnvironmentVariableHelper.cs b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/EnvironmentVariableHelper.cs index db75f3d704..196418233e 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/EnvironmentVariableHelper.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/EnvironmentVariableHelper.cs @@ -4,15 +4,15 @@ #if !NETSTANDARD1_0 using System; + using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; -namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers +namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; + +internal class EnvironmentVariableHelper : IEnvironmentVariableHelper { - internal class EnvironmentVariableHelper : IEnvironmentVariableHelper - { - public string GetEnvironmentVariable(string variable) - => Environment.GetEnvironmentVariable(variable); - } + public string GetEnvironmentVariable(string variable) + => Environment.GetEnvironmentVariable(variable); } #endif \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/FileHelper.cs b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/FileHelper.cs index 754959cebb..7e15388951 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/FileHelper.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/FileHelper.cs @@ -3,145 +3,142 @@ #if !NETSTANDARD1_0 -namespace Microsoft.VisualStudio.TestPlatform.Utilities.Helpers +namespace Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; + +using Interfaces; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; + +/// +/// The file helper. +/// +public class FileHelper : IFileHelper { - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + private static readonly Version DefaultFileVersion = new(0, 0); - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.IO; - using System.Linq; + /// + public DirectoryInfo CreateDirectory(string path) + { + return Directory.CreateDirectory(path); + } - /// - /// The file helper. - /// - public class FileHelper : IFileHelper + /// + public string GetCurrentDirectory() { - private static readonly Version DefaultFileVersion = new Version(0, 0); + return Directory.GetCurrentDirectory(); + } - /// - public DirectoryInfo CreateDirectory(string path) - { - return Directory.CreateDirectory(path); - } + /// + public bool Exists(string path) + { + return File.Exists(path); + } - /// - public string GetCurrentDirectory() - { - return Directory.GetCurrentDirectory(); - } + /// + public bool DirectoryExists(string path) + { + return Directory.Exists(path); + } - /// - public bool Exists(string path) - { - return File.Exists(path); - } + /// + public Stream GetStream(string filePath, FileMode mode, FileAccess access = FileAccess.ReadWrite) + { + return new FileStream(filePath, mode, access); + } - /// - public bool DirectoryExists(string path) - { - return Directory.Exists(path); - } + /// + public Stream GetStream(string filePath, FileMode mode, FileAccess access, FileShare share) + { + return new FileStream(filePath, mode, access, share); + } - /// -#pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads - public Stream GetStream(string filePath, FileMode mode, FileAccess access = FileAccess.ReadWrite) -#pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads - { - return new FileStream(filePath, mode, access); - } - /// - public Stream GetStream(string filePath, FileMode mode, FileAccess access, FileShare share) + /// + public IEnumerable EnumerateFiles( + string directory, + SearchOption searchOption, + params string[] endsWithSearchPatterns) + { + if (endsWithSearchPatterns == null || endsWithSearchPatterns.Length == 0) { - return new FileStream(filePath, mode, access, share); + return Enumerable.Empty(); } + var files = Directory.EnumerateFiles(directory, "*", searchOption); - /// - public IEnumerable EnumerateFiles( - string directory, - SearchOption searchOption, - params string[] endsWithSearchPatterns) - { - if (endsWithSearchPatterns == null || endsWithSearchPatterns.Length == 0) - { - return Enumerable.Empty(); - } - - var files = Directory.EnumerateFiles(directory, "*", searchOption); - - return files.Where( - file => endsWithSearchPatterns.Any( - pattern => file.EndsWith(pattern, StringComparison.OrdinalIgnoreCase))); - } + return files.Where( + file => endsWithSearchPatterns.Any( + pattern => file.EndsWith(pattern, StringComparison.OrdinalIgnoreCase))); + } - /// - public FileAttributes GetFileAttributes(string path) - { - return new FileInfo(path).Attributes; - } + /// + public FileAttributes GetFileAttributes(string path) + { + return new FileInfo(path).Attributes; + } - /// - public Version GetFileVersion(string path) - { - var currentFileVersion = FileVersionInfo.GetVersionInfo(path)?.FileVersion; - return Version.TryParse(currentFileVersion, out var currentVersion) ? currentVersion : DefaultFileVersion; - } + /// + public Version GetFileVersion(string path) + { + var currentFileVersion = FileVersionInfo.GetVersionInfo(path)?.FileVersion; + return Version.TryParse(currentFileVersion, out var currentVersion) ? currentVersion : DefaultFileVersion; + } - /// - public void CopyFile(string sourcePath, string destinationPath) - { - File.Copy(sourcePath, destinationPath); - } + /// + public void CopyFile(string sourcePath, string destinationPath) + { + File.Copy(sourcePath, destinationPath); + } - /// - public void MoveFile(string sourcePath, string destinationPath) - { - File.Move(sourcePath, destinationPath); - } + /// + public void MoveFile(string sourcePath, string destinationPath) + { + File.Move(sourcePath, destinationPath); + } - /// - public void WriteAllTextToFile(string filePath, string content) - { - File.WriteAllText(filePath, content); - } + /// + public void WriteAllTextToFile(string filePath, string content) + { + File.WriteAllText(filePath, content); + } - /// - public string GetFullPath(string path) - { - return Path.GetFullPath(path); - } + /// + public string GetFullPath(string path) + { + return Path.GetFullPath(path); + } - /// - public void DeleteEmptyDirectroy(string dirPath) + /// + public void DeleteEmptyDirectroy(string dirPath) + { + try { - try - { - if (Directory.Exists(dirPath) - && !Directory.EnumerateFileSystemEntries(dirPath).Any()) - { - Directory.Delete(dirPath, true); - } - } - catch + if (Directory.Exists(dirPath) + && !Directory.EnumerateFileSystemEntries(dirPath).Any()) { - // ignored + Directory.Delete(dirPath, true); } } - - /// - public string[] GetFiles(string path, string searchPattern, SearchOption searchOption) + catch { - return Directory.GetFiles(path, searchPattern, searchOption); + // ignored } + } - /// - public void Delete(string path) - { - File.Delete(path); - } + /// + public string[] GetFiles(string path, string searchPattern, SearchOption searchOption) + { + return Directory.GetFiles(path, searchPattern, searchOption); + } + + /// + public void Delete(string path) + { + File.Delete(path); } } diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IDotnetHostHelper.cs b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IDotnetHostHelper.cs index 6f166f36a6..96c5f23933 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IDotnetHostHelper.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IDotnetHostHelper.cs @@ -1,35 +1,33 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.Interfaces; + +/// +/// Helper class for getting info about dotnet host. +/// +public interface IDotnetHostHelper { /// - /// Helper class for getting info about dotnet host. + /// Gets the full path for of .net core host. /// - public interface IDotnetHostHelper - { - /// - /// Gets the full path for of .net core host. - /// - /// Full path to dotnet executable - /// Debuggers require the full path of executable to launch it. - string GetDotnetPath(); + /// Full path to dotnet executable + /// Debuggers require the full path of executable to launch it. + string GetDotnetPath(); - /// - /// Gets the full path of mono host. - /// - /// Full path to mono executable - string GetMonoPath(); + /// + /// Gets the full path of mono host. + /// + /// Full path to mono executable + string GetMonoPath(); - /// - /// Try to locate muxer of specific architecture - /// - /// Specific architecture - /// Path to the muxer - /// True if native muxer is found - bool TryGetDotnetPathByArchitecture(PlatformArchitecture targetArchitecture, out string muxerPath); - } -} + /// + /// Try to locate muxer of specific architecture + /// + /// Specific architecture + /// Path to the muxer + /// True if native muxer is found + bool TryGetDotnetPathByArchitecture(PlatformArchitecture targetArchitecture, out string muxerPath); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IEnvironmentVariableHelper.cs b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IEnvironmentVariableHelper.cs index 7734fa2198..da62c12f5e 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IEnvironmentVariableHelper.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IEnvironmentVariableHelper.cs @@ -1,10 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +internal interface IEnvironmentVariableHelper { - internal interface IEnvironmentVariableHelper - { - string GetEnvironmentVariable(string variable); - } -} + string GetEnvironmentVariable(string variable); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IFileHelper.cs b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IFileHelper.cs index 68d9f4f497..9944af63c3 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IFileHelper.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IFileHelper.cs @@ -1,151 +1,150 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces -{ - using System; - using System.Collections.Generic; - using System.IO; +namespace Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +using System; +#if !NETSTANDARD1_0 +using System.Collections.Generic; +using System.IO; +#endif +/// +/// The FileHelper interface. +/// +public interface IFileHelper +{ +#if !NETSTANDARD1_0 /// - /// The FileHelper interface. + /// Creates a directory. /// - public interface IFileHelper - { -#if !NETSTANDARD1_0 - /// - /// Creates a directory. - /// - /// Path of the directory. - /// for the created directory. - DirectoryInfo CreateDirectory(string path); + /// Path of the directory. + /// for the created directory. + DirectoryInfo CreateDirectory(string path); #endif - /// - /// Gets the current directory - /// - /// Current directory - string GetCurrentDirectory(); - - /// - /// Exists utility to check if file exists (case sensitive). - /// - /// The path of file. - /// True if file exists . - bool Exists(string path); - - /// - /// Exists utility to check if directory exists (case sensitive). - /// - /// The path of file. - /// True if directory exists . - bool DirectoryExists(string path); + /// + /// Gets the current directory + /// + /// Current directory + string GetCurrentDirectory(); + + /// + /// Exists utility to check if file exists (case sensitive). + /// + /// The path of file. + /// True if file exists . + bool Exists(string path); + + /// + /// Exists utility to check if directory exists (case sensitive). + /// + /// The path of file. + /// True if directory exists . + bool DirectoryExists(string path); #if !NETSTANDARD1_0 - /// - /// Gets a stream for the file. - /// - /// Path to the file. - /// for file operations. - /// for file operations. - /// A that supports read/write on the file. -#pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads - Stream GetStream(string filePath, FileMode mode, FileAccess access = FileAccess.ReadWrite); -#pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads - - /// - /// Gets a stream for the file. - /// - /// Path to the file. - /// for file operations. - /// for file operations. - /// for file operations. - /// A that supports read/write on the file. - Stream GetStream(string filePath, FileMode mode, FileAccess access, FileShare share); - - /// - /// Enumerates files which match a pattern (case insensitive) in a directory. - /// - /// Parent directory to search. - /// for directory. - /// Patterns used to select files using String.EndsWith - /// List of files matching the pattern. - IEnumerable EnumerateFiles(string directory, SearchOption searchOption, params string[] endsWithSearchPatterns); - - /// - /// Gets attributes of a file. - /// - /// Full path of the file. - /// Attributes of the file. - FileAttributes GetFileAttributes(string path); + /// + /// Gets a stream for the file. + /// + /// Path to the file. + /// for file operations. + /// for file operations. + /// A that supports read/write on the file. + Stream GetStream(string filePath, FileMode mode, FileAccess access = FileAccess.ReadWrite); + + /// + /// Gets a stream for the file. + /// + /// Path to the file. + /// for file operations. + /// for file operations. + /// for file operations. + /// A that supports read/write on the file. + Stream GetStream(string filePath, FileMode mode, FileAccess access, FileShare share); + + /// + /// Enumerates files which match a pattern (case insensitive) in a directory. + /// + /// Parent directory to search. + /// for directory. + /// Patterns used to select files using String.EndsWith + /// List of files matching the pattern. + IEnumerable EnumerateFiles(string directory, SearchOption searchOption, params string[] endsWithSearchPatterns); + + /// + /// Gets attributes of a file. + /// + /// Full path of the file. + /// Attributes of the file. + FileAttributes GetFileAttributes(string path); #endif - /// - /// Gets the version information of the file. - /// - /// Full path to the file. - /// File Version information of the file. - Version GetFileVersion(string path); - - /// - /// Copy a file in the file system. - /// - /// Full path of the file. - /// Target path for the file. - void CopyFile(string sourcePath, string destinationPath); - - /// - /// Moves a file in the file system. - /// - /// Full path of the file. - /// Target path for the file. - void MoveFile(string sourcePath, string destinationPath); - - /// - /// The write all text to file. - /// - /// - /// The file Path. - /// - /// - /// The content. - /// - void WriteAllTextToFile(string filePath, string content); - - /// - /// Gets full path if relative path is specified. - /// - /// - /// The path. - /// - /// - /// Full path. - /// - string GetFullPath(string path); - - /// - /// Helper for deleting a directory. It deletes the directory only if its empty. - /// - /// - /// The directory path. - /// - void DeleteEmptyDirectroy(string directoryPath); + /// + /// Gets the version information of the file. + /// + /// Full path to the file. + /// File Version information of the file. + Version GetFileVersion(string path); + + /// + /// Copy a file in the file system. + /// + /// Full path of the file. + /// Target path for the file. + void CopyFile(string sourcePath, string destinationPath); + + /// + /// Moves a file in the file system. + /// + /// Full path of the file. + /// Target path for the file. + void MoveFile(string sourcePath, string destinationPath); + + /// + /// The write all text to file. + /// + /// + /// The file Path. + /// + /// + /// The content. + /// + void WriteAllTextToFile(string filePath, string content); + + /// + /// Gets full path if relative path is specified. + /// + /// + /// The path. + /// + /// + /// Full path. + /// + string GetFullPath(string path); + + /// + /// Helper for deleting a directory. It deletes the directory only if its empty. + /// + /// + /// The directory path. + /// + void DeleteEmptyDirectroy(string directoryPath); #if !NETSTANDARD1_0 - /// - /// Gets all files in directory based on search pattern - /// - /// Directory Path - /// Search pattern - /// Search option - /// string[] - string[] GetFiles(string path, string searchPattern, SearchOption searchOption); + /// + /// Gets all files in directory based on search pattern + /// + /// Directory Path + /// Search pattern + /// Search option + /// string[] + string[] GetFiles(string path, string searchPattern, SearchOption searchOption); #endif - /// - /// Deletes the specified file - /// - /// - void Delete(string path); - } -} + /// + /// Deletes the specified file + /// + /// + void Delete(string path); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IRunsettingsHelper.cs b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IRunsettingsHelper.cs index 21064568a2..128d780fa8 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IRunsettingsHelper.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IRunsettingsHelper.cs @@ -1,10 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +internal interface IRunSettingsHelper { - internal interface IRunSettingsHelper - { - bool IsDefaultTargetArchitecture { get; set; } - } -} + bool IsDefaultTargetArchitecture { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IWindowsRegistryHelper.cs b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IWindowsRegistryHelper.cs index 27328f76c4..04b7703b53 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IWindowsRegistryHelper.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IWindowsRegistryHelper.cs @@ -5,23 +5,23 @@ #if !NETSTANDARD1_0 using System; + using Microsoft.Win32; -namespace Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +internal interface IWindowsRegistryHelper { - internal interface IWindowsRegistryHelper - { - IRegistryKey OpenBaseKey(RegistryHive hKey, RegistryView view); - } + IRegistryKey OpenBaseKey(RegistryHive hKey, RegistryView view); +} - internal interface IRegistryKey : IDisposable - { - IRegistryKey OpenSubKey(string name); +internal interface IRegistryKey : IDisposable +{ + IRegistryKey OpenSubKey(string name); - object GetValue(string name); + object GetValue(string name); - string[] GetSubKeyNames(); - } + string[] GetSubKeyNames(); } #endif diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/RunSettingsHelper.cs b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/RunSettingsHelper.cs index 8b2387a845..e67d093a66 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/RunSettingsHelper.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/RunSettingsHelper.cs @@ -3,21 +3,20 @@ using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; -namespace Microsoft.VisualStudio.TestPlatform.Utilities.Helpers +namespace Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; + +/// +/// RunSettingsHelper is used to globally share additional informations about the state of runsettings. +/// +internal class RunSettingsHelper : IRunSettingsHelper { - /// - /// RunSettingsHelper is used to globally share additional informations about the state of runsettings. - /// - internal class RunSettingsHelper : IRunSettingsHelper - { - private static IRunSettingsHelper runSettings = new RunSettingsHelper(); + private static readonly IRunSettingsHelper RunSettings = new RunSettingsHelper(); - public static IRunSettingsHelper Instance = runSettings; + public static IRunSettingsHelper Instance = RunSettings; - /// - /// If false user updated the RunConfiguration.TargetPlatform using - /// --arch or runsettings file or -- RunConfiguration.TargetPlatform=arch - /// - public bool IsDefaultTargetArchitecture { get; set; } = true; - } -} + /// + /// If false user updated the RunConfiguration.TargetPlatform using + /// --arch or runsettings file or -- RunConfiguration.TargetPlatform=arch + /// + public bool IsDefaultTargetArchitecture { get; set; } = true; +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/WindowsRegistryHelper.cs b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/WindowsRegistryHelper.cs index 82c0ed59f1..9fdb7d0e1f 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/WindowsRegistryHelper.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/WindowsRegistryHelper.cs @@ -1,49 +1,48 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -#if !NETSTANDARD1_0 +#if !NETSTANDARD1_0 using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; using Microsoft.Win32; -namespace Microsoft.VisualStudio.TestPlatform.Utilities.Helpers +namespace Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; + +internal class WindowsRegistryHelper : IWindowsRegistryHelper { - internal class WindowsRegistryHelper : IWindowsRegistryHelper + public IRegistryKey OpenBaseKey(RegistryHive hKey, RegistryView view) + { + var keyRegistry = RegistryKey.OpenBaseKey(hKey, view); + return keyRegistry is null ? null : new RegistryKeyWrapper(keyRegistry); + } +} + +internal class RegistryKeyWrapper : IRegistryKey +{ + private readonly RegistryKey _registryKey; + + public RegistryKeyWrapper(RegistryKey registryKey) { - public IRegistryKey OpenBaseKey(RegistryHive hKey, RegistryView view) - { - var keyRegistry = RegistryKey.OpenBaseKey(hKey, view); - return keyRegistry is null ? null : new RegistryKeyWrapper(keyRegistry); - } + _registryKey = registryKey; } - internal class RegistryKeyWrapper : IRegistryKey + public object GetValue(string name) + { + return _registryKey?.GetValue(name)?.ToString(); + } + + public IRegistryKey OpenSubKey(string name) + { + var keyRegistry = _registryKey.OpenSubKey(name); + return keyRegistry is null ? null : new RegistryKeyWrapper(keyRegistry); + } + + public string[] GetSubKeyNames() + => _registryKey?.GetSubKeyNames(); + + public void Dispose() { - private readonly RegistryKey registryKey; - - public RegistryKeyWrapper(RegistryKey registryKey) - { - this.registryKey = registryKey; - } - - public object GetValue(string name) - { - return registryKey?.GetValue(name)?.ToString(); - } - - public IRegistryKey OpenSubKey(string name) - { - var keyRegistry = this.registryKey.OpenSubKey(name); - return keyRegistry is null ? null : new RegistryKeyWrapper(keyRegistry); - } - - public string[] GetSubKeyNames() - => this.registryKey?.GetSubKeyNames(); - - public void Dispose() - { - this.registryKey?.Dispose(); - } + _registryKey?.Dispose(); } } diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Output/ConsoleOutput.cs b/src/Microsoft.TestPlatform.CoreUtilities/Output/ConsoleOutput.cs index d4b36eb43c..36063bc19c 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Output/ConsoleOutput.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Output/ConsoleOutput.cs @@ -3,88 +3,87 @@ #if !NETSTANDARD1_0 && !WINDOWS_UWP -namespace Microsoft.VisualStudio.TestPlatform.Utilities +namespace Microsoft.VisualStudio.TestPlatform.Utilities; + +using System; +using System.IO; + +/// +/// Sends output to the console. +/// +public class ConsoleOutput : IOutput { - using System; - using System.IO; + private static readonly object LockObject = new(); + private static ConsoleOutput s_consoleOutput = null; + + private readonly TextWriter _standardOutput = null; + private readonly TextWriter _standardError = null; /// - /// Sends output to the console. + /// Initializes a new instance of the class. /// - public class ConsoleOutput : IOutput + internal ConsoleOutput() { - private static object lockObject = new object(); - private static ConsoleOutput consoleOutput = null; - - private TextWriter standardOutput = null; - private TextWriter standardError = null; - - /// - /// Initializes a new instance of the class. - /// - internal ConsoleOutput() - { - this.standardOutput = Console.Out; - this.standardError = Console.Error; - } + _standardOutput = Console.Out; + _standardError = Console.Error; + } - /// - /// Gets the instance of . - /// - public static ConsoleOutput Instance + /// + /// Gets the instance of . + /// + public static ConsoleOutput Instance + { + get { - get + if (s_consoleOutput != null) { - if (consoleOutput != null) - { - return consoleOutput; - } + return s_consoleOutput; + } - lock (lockObject) + lock (LockObject) + { + if (s_consoleOutput == null) { - if (consoleOutput == null) - { - consoleOutput = new ConsoleOutput(); - } + s_consoleOutput = new ConsoleOutput(); } - - return consoleOutput; } - } - /// - /// Writes the message with a new line. - /// - /// Message to be output. - /// Level of the message. - public void WriteLine(string message, OutputLevel level) - { - this.Write(message, level); - this.Write(Environment.NewLine, level); + return s_consoleOutput; } + } + + /// + /// Writes the message with a new line. + /// + /// Message to be output. + /// Level of the message. + public void WriteLine(string message, OutputLevel level) + { + Write(message, level); + Write(Environment.NewLine, level); + } - /// - /// Writes the message with no new line. - /// - /// Message to be output. - /// Level of the message. - public void Write(string message, OutputLevel level) + /// + /// Writes the message with no new line. + /// + /// Message to be output. + /// Level of the message. + public void Write(string message, OutputLevel level) + { + switch (level) { - switch (level) - { - case OutputLevel.Information: - case OutputLevel.Warning: - this.standardOutput.Write(message); - break; + case OutputLevel.Information: + case OutputLevel.Warning: + _standardOutput.Write(message); + break; - case OutputLevel.Error: - this.standardError.Write(message); - break; + case OutputLevel.Error: + _standardError.Write(message); + break; - default: - this.standardOutput.Write("ConsoleOutput.WriteLine: The output level is unrecognized: {0}", level); - break; - } + default: + _standardOutput.Write("ConsoleOutput.WriteLine: The output level is unrecognized: {0}", level); + break; } } } diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Output/IOutput.cs b/src/Microsoft.TestPlatform.CoreUtilities/Output/IOutput.cs index 599d51fbe0..975b424f0f 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Output/IOutput.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Output/IOutput.cs @@ -1,25 +1,24 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Utilities +namespace Microsoft.VisualStudio.TestPlatform.Utilities; + +/// +/// Interface to output information under the command line. +/// +public interface IOutput { /// - /// Interface to output information under the command line. + /// Writes the message with a new line. /// - public interface IOutput - { - /// - /// Writes the message with a new line. - /// - /// Message to be output. - /// Level of the message. - void WriteLine(string message, OutputLevel level); + /// Message to be output. + /// Level of the message. + void WriteLine(string message, OutputLevel level); - /// - /// Writes the message with no new line. - /// - /// Message to be output. - /// Level of the message. - void Write(string message, OutputLevel level); - } -} + /// + /// Writes the message with no new line. + /// + /// Message to be output. + /// Level of the message. + void Write(string message, OutputLevel level); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Output/OutputExtensions.cs b/src/Microsoft.TestPlatform.CoreUtilities/Output/OutputExtensions.cs index 915b0c45d5..ffd51831a9 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Output/OutputExtensions.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Output/OutputExtensions.cs @@ -3,155 +3,133 @@ #if !NETSTANDARD1_0 && !WINDOWS_UWP -namespace Microsoft.VisualStudio.TestPlatform.Utilities +namespace Microsoft.VisualStudio.TestPlatform.Utilities; + +using CoreUtilities.Resources; + +using System; +using System.Globalization; + +/// +/// Utility Methods for sending output to IOutput. +/// +public static class OutputExtensions { - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Resources; + private const string DefaultFormat = "{0}"; - using System; - using System.Globalization; + /// + /// Output an error message. + /// + /// Output instance the method is being invoked with. + /// Bool to decide whether Verbose level should be added as prefix or not in log messages. + /// Format string for the error message. + /// Arguments to format into the format string. + public static void Error(this IOutput output, bool appendPrefix, string format, params object[] args) + { + SetColorForAction(ConsoleColor.Red, () => Output(output, OutputLevel.Error, appendPrefix ? Resources.CommandLineError : DefaultFormat, format, args)); + } /// - /// Utility Methods for sending output to IOutput. + /// Output a warning message. /// - public static class OutputExtensions + /// Output instance the method is being invoked with. + /// Bool to decide whether Verbose level should be added as prefix or not in log messages. + /// Format string for the warning message. + /// Arguments to format into the format string. + public static void Warning(this IOutput output, bool appendPrefix, string format, params object[] args) { - private const string DefaultFormat = "{0}"; - - /// - /// Output an error message. - /// - /// Output instance the method is being invoked with. - /// Bool to decide whether Verbose level should be added as prefix or not in log messages. - /// Format string for the error message. - /// Arguments to format into the format string. - public static void Error(this IOutput output, bool appendPrefix, string format, params object[] args) - { - SetColorForAction(ConsoleColor.Red, () => - { - Output(output, OutputLevel.Error, appendPrefix ? Resources.CommandLineError : DefaultFormat, format, args); - }); - } + SetColorForAction(ConsoleColor.Yellow, () => Output(output, OutputLevel.Warning, appendPrefix ? Resources.CommandLineWarning : DefaultFormat, format, args)); + } - /// - /// Output a warning message. - /// - /// Output instance the method is being invoked with. - /// Bool to decide whether Verbose level should be added as prefix or not in log messages. - /// Format string for the warning message. - /// Arguments to format into the format string. - public static void Warning(this IOutput output, bool appendPrefix, string format, params object[] args) - { - SetColorForAction(ConsoleColor.Yellow, () => - { - Output(output, OutputLevel.Warning, appendPrefix ? Resources.CommandLineWarning : DefaultFormat, format, args); - }); - } + /// + /// Output a informational message. + /// + /// Output instance the method is being invoked with. + /// Bool to decide whether Verbose level should be added as prefix or not in log messages. + /// Format string for the informational message. + /// Arguments to format into the format string. + public static void Information(this IOutput output, bool appendPrefix, string format, params object[] args) + { + Information(output, appendPrefix, Console.ForegroundColor, format, args); + } - /// - /// Output a informational message. - /// - /// Output instance the method is being invoked with. - /// Bool to decide whether Verbose level should be added as prefix or not in log messages. - /// Format string for the informational message. - /// Arguments to format into the format string. - public static void Information(this IOutput output, bool appendPrefix, string format, params object[] args) - { - Information(output, appendPrefix, Console.ForegroundColor, format, args); - } + /// + /// Output a informational message. + /// + /// Output instance the method is being invoked with. + /// Bool to decide whether Verbose level should be added as prefix or not in log messages. + /// Color in which text prints. + /// Format string for the informational message. + /// Arguments to format into the format string. + public static void Information(this IOutput output, bool appendPrefix, ConsoleColor foregroundColor, string format, params object[] args) + { + SetColorForAction(foregroundColor, () => Output(output, OutputLevel.Information, appendPrefix ? Resources.CommandLineInformational : DefaultFormat, format, args)); + } + + /// + /// Write string with a given console color + /// + /// Output instance the method is being invoked with. + /// Message to be written + /// OutputLevel + /// Console color for the output message + public static void Write(this IOutput output, string message, OutputLevel level, ConsoleColor foregroundColor) + { + SetColorForAction(foregroundColor, () => output.Write(message, level)); + } - /// - /// Output a informational message. - /// - /// Output instance the method is being invoked with. - /// Bool to decide whether Verbose level should be added as prefix or not in log messages. - /// Color in which text prints. - /// Format string for the informational message. - /// Arguments to format into the format string. - public static void Information(this IOutput output, bool appendPrefix, ConsoleColor foregroundColor, string format, params object[] args) + /// + /// Formats the message. + /// + /// An output instance to write the message. + /// Message level. + /// Format string for the message type. + /// Format string for the error message. + /// Arguments to format into the format string. + private static void Output(IOutput output, OutputLevel level, string messageTypeFormat, string format, params object[] args) + { + if (output == null) { - SetColorForAction(foregroundColor, () => - { - Output(output, OutputLevel.Information, appendPrefix ? Resources.CommandLineInformational : DefaultFormat, format, args); - }); + throw new ArgumentNullException(nameof(output)); } - /// - /// Write string with a given console color - /// - /// Output instance the method is being invoked with. - /// Message to be written - /// OutputLevel - /// Console color for the output message - public static void Write(this IOutput output, string message, OutputLevel level, ConsoleColor foregroundColor) + output.WriteLine(Format(messageTypeFormat, format, args), level); + } + + /// + /// Formats the message. + /// + /// Format string for the message type. + /// Format string for the error message. + /// Arguments to format into the format string. + /// Formatted message. + private static string Format(string messageTypeFormat, string format, params object[] args) + { + if (format == null || string.IsNullOrEmpty(format.Trim())) { - SetColorForAction(foregroundColor, () => - { - output.Write(message, level); - }); + throw new ArgumentException(Resources.CannotBeNullOrEmpty, nameof(format)); } - /// - /// Formats the message. - /// - /// An output instance to write the message. - /// Message level. - /// Format string for the message type. - /// Format string for the error message. - /// Arguments to format into the format string. - private static void Output(IOutput output, OutputLevel level, string messageTypeFormat, string format, params object[] args) - { - if (output == null) - { - throw new ArgumentNullException(nameof(output)); - } + string message = args != null && args.Length > 0 ? string.Format(CultureInfo.CurrentCulture, format, args) : format; + return string.Format(CultureInfo.CurrentCulture, messageTypeFormat, message); + } - output.WriteLine(Format(messageTypeFormat, format, args), level); + private static void SetColorForAction(ConsoleColor foregroundColor, Action action) + { + if (action == null) + { + return; } - /// - /// Formats the message. - /// - /// Format string for the message type. - /// Format string for the error message. - /// Arguments to format into the format string. - /// Formatted message. - private static string Format(string messageTypeFormat, string format, params object[] args) + var previousForegroundColor = Console.ForegroundColor; + try { - if (format == null || string.IsNullOrEmpty(format.Trim())) - { - throw new ArgumentException(Resources.CannotBeNullOrEmpty, nameof(format)); - } - - string message = null; - if (args != null && args.Length > 0) - { - message = string.Format(CultureInfo.CurrentCulture, format, args); - } - else - { - message = format; - } - - return string.Format(CultureInfo.CurrentCulture, messageTypeFormat, message); + Console.ForegroundColor = foregroundColor; + action.Invoke(); } - - private static void SetColorForAction(ConsoleColor foregroundColor, Action action) + finally { - if (action == null) - { - return; - } - - var previousForegroundColor = Console.ForegroundColor; - try - { - Console.ForegroundColor = foregroundColor; - action.Invoke(); - } - finally - { - Console.ForegroundColor = previousForegroundColor; - } + Console.ForegroundColor = previousForegroundColor; } } } diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Output/OutputLevel.cs b/src/Microsoft.TestPlatform.CoreUtilities/Output/OutputLevel.cs index 87c1381805..af56aa133d 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Output/OutputLevel.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Output/OutputLevel.cs @@ -1,26 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Utilities +namespace Microsoft.VisualStudio.TestPlatform.Utilities; + +/// +/// Defines the level of output. +/// +public enum OutputLevel { /// - /// Defines the level of output. + /// Informational message. /// - public enum OutputLevel - { - /// - /// Informational message. - /// - Information = 0, + Information = 0, - /// - /// Warning message. - /// - Warning = 1, + /// + /// Warning message. + /// + Warning = 1, - /// - /// Error message. - /// - Error = 2, - } -} + /// + /// Error message. + /// + Error = 2, +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Properties/AssemblyInfo.cs b/src/Microsoft.TestPlatform.CoreUtilities/Properties/AssemblyInfo.cs index 167c461f4c..1fdf4c2a64 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Properties/AssemblyInfo.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Properties/AssemblyInfo.cs @@ -29,7 +29,7 @@ [assembly: InternalsVisibleTo("Microsoft.TestPlatform.TestHostProvider.UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] -# if !NETSTANDARD1_0 +#if !NETSTANDARD1_0 // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("d472046e-ed17-4750-a2a3-29935b5215f6")] #endif \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Tracing/EqtTrace.cs b/src/Microsoft.TestPlatform.CoreUtilities/Tracing/EqtTrace.cs index 59b4247ae8..9d2ad84faa 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Tracing/EqtTrace.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Tracing/EqtTrace.cs @@ -1,829 +1,829 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.Diagnostics; +using System.Globalization; +using System.Text; + +/// +/// Wrapper class for tracing. +/// - Shortcut-methods for Error, Warning, Info, Verbose. +/// - Adds additional information to the trace: calling process name, PID, ThreadID, Time. +/// - Uses custom switch EqtTraceLevel from .config file. +/// - By default tracing if OFF. +/// - Our build environment always sets the /d:TRACE so this class is always enabled, +/// the Debug class is enabled only in debug builds (/d:DEBUG). +/// - We ignore exceptions thrown by underlying TraceSwitch (e.g. due to config file error). +/// We log ignored exceptions to system Application log. +/// We pass through exceptions thrown due to incorrect arguments to EqtTrace methods. +/// Usage: EqtTrace.Info("Here's how to trace info"); +/// +public static class EqtTrace { - using System; - using System.Diagnostics; - using System.Globalization; - using System.Text; + private static readonly IPlatformEqtTrace TraceImpl = new PlatformEqtTrace(); - /// - /// Wrapper class for tracing. - /// - Shortcut-methods for Error, Warning, Info, Verbose. - /// - Adds additional information to the trace: calling process name, PID, ThreadID, Time. - /// - Uses custom switch EqtTraceLevel from .config file. - /// - By default tracing if OFF. - /// - Our build environment always sets the /d:TRACE so this class is always enabled, - /// the Debug class is enabled only in debug builds (/d:DEBUG). - /// - We ignore exceptions thrown by underlying TraceSwitch (e.g. due to config file error). - /// We log ignored exceptions to system Application log. - /// We pass through exceptions thrown due to incorrect arguments to EqtTrace methods. - /// Usage: EqtTrace.Info("Here's how to trace info"); - /// - public static class EqtTrace +#if NETFRAMEWORK + public static void SetupRemoteEqtTraceListeners(AppDomain childDomain) { - private static IPlatformEqtTrace traceImpl = new PlatformEqtTrace(); + TraceImpl.SetupRemoteEqtTraceListeners(childDomain); + } -#if NETFRAMEWORK - public static void SetupRemoteEqtTraceListeners(AppDomain childDomain) - { - traceImpl.SetupRemoteEqtTraceListeners(childDomain); - } + public static void SetupListener(TraceListener listener) + { + TraceImpl.SetupListener(listener); + } - public static void SetupListener(TraceListener listener) + public static TraceLevel TraceLevel + { + get { - traceImpl.SetupListener(listener); + return (TraceLevel)TraceImpl.GetTraceLevel(); } - - public static TraceLevel TraceLevel + set { - get - { - return (TraceLevel)traceImpl.GetTraceLevel(); - } - set - { - traceImpl.SetTraceLevel((PlatformTraceLevel)value); - } + TraceImpl.SetTraceLevel((PlatformTraceLevel)value); } + } #endif #if NETSTANDARD || NET - public static PlatformTraceLevel TraceLevel + public static PlatformTraceLevel TraceLevel + { + get { - get - { - return traceImpl.GetTraceLevel(); - } - set - { - traceImpl.SetTraceLevel(value); - } + return TraceImpl.GetTraceLevel(); + } + set + { + TraceImpl.SetTraceLevel(value); } + } #endif - public static string LogFile + public static string LogFile + { + get { - get - { - return traceImpl.GetLogFile(); - } + return TraceImpl.GetLogFile(); } + } - public static bool DoNotInitailize + // There is a typo on this property but it's part of the public API so we cannot change it. + public static bool DoNotInitailize + { + get { - get - { - return traceImpl.DoNotInitialize; - } - set - { - traceImpl.DoNotInitialize = value; - } + return TraceImpl.DoNotInitialize; } - - public static string ErrorOnInitialization + set { - get; - set; + TraceImpl.DoNotInitialize = value; } + } - /// - /// Gets a value indicating whether tracing error statements is enabled. - /// - public static bool IsErrorEnabled + public static string ErrorOnInitialization + { + get; + set; + } + + /// + /// Gets a value indicating whether tracing error statements is enabled. + /// + public static bool IsErrorEnabled + { + get { - get - { - return traceImpl.ShouldTrace(PlatformTraceLevel.Error); - } + return TraceImpl.ShouldTrace(PlatformTraceLevel.Error); } + } - /// - /// Gets a value indicating whether tracing info statements is enabled. - /// - public static bool IsInfoEnabled + /// + /// Gets a value indicating whether tracing info statements is enabled. + /// + public static bool IsInfoEnabled + { + get { - get - { - return traceImpl.ShouldTrace(PlatformTraceLevel.Info); - } + return TraceImpl.ShouldTrace(PlatformTraceLevel.Info); } + } - /// - /// Gets a value indicating whether tracing verbose statements is enabled. - /// - public static bool IsVerboseEnabled + /// + /// Gets a value indicating whether tracing verbose statements is enabled. + /// + public static bool IsVerboseEnabled + { + get { - get - { - return traceImpl.ShouldTrace(PlatformTraceLevel.Verbose); - } + return TraceImpl.ShouldTrace(PlatformTraceLevel.Verbose); } + } - /// - /// Gets a value indicating whether tracing warning statements is enabled. - /// - public static bool IsWarningEnabled + /// + /// Gets a value indicating whether tracing warning statements is enabled. + /// + public static bool IsWarningEnabled + { + get { - get - { - return traceImpl.ShouldTrace(PlatformTraceLevel.Warning); - } + return TraceImpl.ShouldTrace(PlatformTraceLevel.Warning); } + } - /// - /// Initializes the verbose tracing with custom log file - /// And overrides if any trace is set before - /// - /// - /// A custom log file for trace messages. - /// - /// - /// The . - /// - public static bool InitializeVerboseTrace(string customLogFile) + /// + /// Initializes the verbose tracing with custom log file + /// And overrides if any trace is set before + /// + /// + /// A custom log file for trace messages. + /// + /// + /// The . + /// + public static bool InitializeVerboseTrace(string customLogFile) + { + return InitializeTrace(customLogFile, PlatformTraceLevel.Verbose); + } + + /// + /// Initializes the tracing with custom log file and trace level. + /// Overrides if any trace is set before. + /// + /// Custom log file for trace messages. + /// Trace level. + /// Trace initialized flag. + public static bool InitializeTrace(string customLogFile, PlatformTraceLevel traceLevel) + { + if (!TraceImpl.InitializeTrace(customLogFile, traceLevel)) { - return InitializeTrace(customLogFile, PlatformTraceLevel.Verbose); + ErrorOnInitialization = PlatformEqtTrace.ErrorOnInitialization; + return false; } - /// - /// Initializes the tracing with custom log file and trace level. - /// Overrides if any trace is set before. - /// - /// Custom log file for trace messages. - /// Trace level. - /// Trace initialized flag. - public static bool InitializeTrace(string customLogFile, PlatformTraceLevel traceLevel) - { - if (!traceImpl.InitializeTrace(customLogFile, traceLevel)) - { - ErrorOnInitialization = PlatformEqtTrace.ErrorOnInitialization; - return false; - } + return true; + } - return true; - } + /// + /// Prints an error message and prompts with a Debug dialog + /// + /// the error message + [Conditional("TRACE")] + public static void Fail(string message) + { + Fail(message, null); + } + + /// + /// Combines together EqtTrace.Fail and Debug.Fail: + /// Prints an formatted error message and prompts with a Debug dialog. + /// + /// The formatted error message + /// Arguments to the format + [Conditional("TRACE")] + public static void Fail(string format, params object[] args) + { + string message = string.Format(CultureInfo.InvariantCulture, format, args); - /// - /// Prints an error message and prompts with a Debug dialog - /// - /// the error message - [Conditional("TRACE")] - public static void Fail(string message) + Error(message); + FailDebugger(message); + } + + /// + /// Trace an error message. + /// + /// Error message. + [Conditional("TRACE")] + public static void Error(string message) + { + if (TraceImpl.ShouldTrace(PlatformTraceLevel.Error)) { - Fail(message, null); + TraceImpl.WriteLine(PlatformTraceLevel.Error, message); } + } - /// - /// Combines together EqtTrace.Fail and Debug.Fail: - /// Prints an formatted error message and prompts with a Debug dialog. - /// - /// The formatted error message - /// Arguments to the format - [Conditional("TRACE")] - public static void Fail(string format, params object[] args) + /// + /// Only prints the message if the condition is true + /// + /// Condition for tracing. + /// Trace error message. + [Conditional("TRACE")] + public static void ErrorIf(bool condition, string message) + { + if (condition) { - string message = string.Format(CultureInfo.InvariantCulture, format, args); - Error(message); - FailDebugger(message); } + } - /// - /// Trace an error message. - /// - /// Error message. - [Conditional("TRACE")] - public static void Error(string message) - { - if (traceImpl.ShouldTrace(PlatformTraceLevel.Error)) - { - traceImpl.WriteLine(PlatformTraceLevel.Error, message); - } - } + /// + /// Only prints the formatted message if the condition is false + /// + /// Condition for tracing. + /// Trace error message. + [Conditional("TRACE")] + public static void ErrorUnless(bool condition, string message) + { + ErrorIf(!condition, message); + } - /// - /// Only prints the message if the condition is true - /// - /// Condition for tracing. - /// Trace error message. - [Conditional("TRACE")] - public static void ErrorIf(bool condition, string message) + /// + /// Prints the message if the condition is false. If the condition is true, + /// the message is instead printed at the specified trace level. + /// + /// Condition for trace. + /// Level for trace. + /// Trace message. + [Conditional("TRACE")] + public static void ErrorUnlessAlterTrace(bool condition, PlatformTraceLevel bumpLevel, string message) + { + if (condition) { - if (condition) - { - Error(message); - } + WriteAtLevel(bumpLevel, message); } - - /// - /// Only prints the formatted message if the condition is false - /// - /// Condition for tracing. - /// Trace error message. - [Conditional("TRACE")] - public static void ErrorUnless(bool condition, string message) + else { - ErrorIf(!condition, message); + Error(message); } + } - /// - /// Prints the message if the condition is false. If the condition is true, - /// the message is instead printed at the specified trace level. - /// - /// Condition for trace. - /// Level for trace. - /// Trace message. - [Conditional("TRACE")] - public static void ErrorUnlessAlterTrace(bool condition, PlatformTraceLevel bumpLevel, string message) - { - if (condition) - { - WriteAtLevel(bumpLevel, message); - } - else - { - Error(message); - } - } + /// + /// Trace an error message with formatting arguments. + /// + /// Format of error message. + /// Parameters for the error message. + [Conditional("TRACE")] + public static void Error(string format, params object[] args) + { + Debug.Assert(format != null, "format != null"); - /// - /// Trace an error message with formatting arguments. - /// - /// Format of error message. - /// Parameters for the error message. - [Conditional("TRACE")] - public static void Error(string format, params object[] args) + // Check level before doing string.Format to avoid string creation if tracing is off. + if (TraceImpl.ShouldTrace(PlatformTraceLevel.Error)) { - Debug.Assert(format != null, "format != null"); - - // Check level before doing string.Format to avoid string creation if tracing is off. - if (traceImpl.ShouldTrace(PlatformTraceLevel.Error)) - { - Error(string.Format(CultureInfo.InvariantCulture, format, args)); - } + Error(string.Format(CultureInfo.InvariantCulture, format, args)); } + } - /// - /// Only prints the formatted message if the condition is false - /// - /// Condition for trace. - /// Message format. - /// Trace message format arguments. - [Conditional("TRACE")] - public static void ErrorUnless(bool condition, string format, params object[] args) + /// + /// Only prints the formatted message if the condition is false + /// + /// Condition for trace. + /// Message format. + /// Trace message format arguments. + [Conditional("TRACE")] + public static void ErrorUnless(bool condition, string format, params object[] args) + { + ErrorIf(!condition, format, args); + } + + /// + /// Prints the message if the condition is false. If the condition is true, + /// the message is instead printed at the specified trace level. + /// + /// Condition for trace. + /// Level for trace. + /// Message format. + /// Trace message format arguments. + [Conditional("TRACE")] + public static void ErrorUnlessAlterTrace(bool condition, PlatformTraceLevel bumpLevel, string format, params object[] args) + { + if (condition) { - ErrorIf(!condition, format, args); + WriteAtLevel(bumpLevel, format, args); } - - /// - /// Prints the message if the condition is false. If the condition is true, - /// the message is instead printed at the specified trace level. - /// - /// Condition for trace. - /// Level for trace. - /// Message format. - /// Trace message format arguments. - [Conditional("TRACE")] - public static void ErrorUnlessAlterTrace(bool condition, PlatformTraceLevel bumpLevel, string format, params object[] args) + else { - if (condition) - { - WriteAtLevel(bumpLevel, format, args); - } - else - { - Error(format, args); - } + Error(format, args); } + } - /// - /// Only prints the formatted message if the condition is true - /// - /// Condition for trace. - /// Message format. - /// Trace message format arguments. - [Conditional("TRACE")] - public static void ErrorIf(bool condition, string format, params object[] args) + /// + /// Only prints the formatted message if the condition is true + /// + /// Condition for trace. + /// Message format. + /// Trace message format arguments. + [Conditional("TRACE")] + public static void ErrorIf(bool condition, string format, params object[] args) + { + if (condition) { - if (condition) - { - Error(format, args); - } + Error(format, args); } + } - /// - /// Error and Debug.Fail combined in one call. - /// - /// The message to send to Debug.Fail and Error. - /// Arguments to string.Format. - [Conditional("TRACE")] - public static void ErrorAssert(string format, params object[] args) + /// + /// Error and Debug.Fail combined in one call. + /// + /// The message to send to Debug.Fail and Error. + /// Arguments to string.Format. + [Conditional("TRACE")] + public static void ErrorAssert(string format, params object[] args) + { + Debug.Assert(format != null, "format != null"); + var message = string.Format(CultureInfo.InvariantCulture, format, args); + Error(message); + FailDebugger(message); + } + + /// + /// Write a exception if tracing for error is enabled + /// + /// The exception to write. + [Conditional("TRACE")] + public static void Error(Exception exceptionToTrace) + { + Debug.Assert(exceptionToTrace != null, "exceptionToTrace != null"); + + // Write only if tracing for error is enabled. + // Done upfront to avoid performance hit. + if (TraceImpl.ShouldTrace(PlatformTraceLevel.Error)) { - Debug.Assert(format != null, "format != null"); - var message = string.Format(CultureInfo.InvariantCulture, format, args); - Error(message); - FailDebugger(message); + // Write at error level + TraceImpl.WriteLine(PlatformTraceLevel.Error, FormatException(exceptionToTrace)); } + } - /// - /// Write a exception if tracing for error is enabled - /// - /// The exception to write. - [Conditional("TRACE")] - public static void Error(Exception exceptionToTrace) + /// + /// Trace a warning message. + /// + /// Trace message. + [Conditional("TRACE")] + public static void Warning(string message) + { + if (TraceImpl.ShouldTrace(PlatformTraceLevel.Warning)) { - Debug.Assert(exceptionToTrace != null, "exceptionToTrace != null"); - - // Write only if tracing for error is enabled. - // Done upfront to avoid performance hit. - if (traceImpl.ShouldTrace(PlatformTraceLevel.Error)) - { - // Write at error level - traceImpl.WriteLine(PlatformTraceLevel.Error, FormatException(exceptionToTrace)); - } + TraceImpl.WriteLine(PlatformTraceLevel.Warning, message); } + } - /// - /// Trace a warning message. - /// - /// Trace message. - [Conditional("TRACE")] - public static void Warning(string message) + /// + /// Only prints the formatted message if the condition is true + /// + /// Condition to evaluate for tracing. + /// Message to trace. + [Conditional("TRACE")] + public static void WarningIf(bool condition, string message) + { + if (condition) { - if (traceImpl.ShouldTrace(PlatformTraceLevel.Warning)) - { - traceImpl.WriteLine(PlatformTraceLevel.Warning, message); - } + Warning(message); } + } + + /// + /// Only prints the formatted message if the condition is false + /// + /// Condition to evaluate for tracing. + /// Message to trace. + [Conditional("TRACE")] + public static void WarningUnless(bool condition, string message) + { + WarningIf(!condition, message); + } - /// - /// Only prints the formatted message if the condition is true - /// - /// Condition to evaluate for tracing. - /// Message to trace. - [Conditional("TRACE")] - public static void WarningIf(bool condition, string message) + /// + /// Prints the message if the condition is false. If the condition is true, + /// the message is instead printed at the specified trace level. + /// + /// Condition to evaluate for tracing. + /// Trace message level. + /// Message to trace. + [Conditional("TRACE")] + public static void WarningUnlessAlterTrace(bool condition, PlatformTraceLevel bumpLevel, string message) + { + if (condition) { - if (condition) - { - Warning(message); - } + WriteAtLevel(bumpLevel, message); } - - /// - /// Only prints the formatted message if the condition is false - /// - /// Condition to evaluate for tracing. - /// Message to trace. - [Conditional("TRACE")] - public static void WarningUnless(bool condition, string message) + else { - WarningIf(!condition, message); + Warning(message); } + } - /// - /// Prints the message if the condition is false. If the condition is true, - /// the message is instead printed at the specified trace level. - /// - /// Condition to evaluate for tracing. - /// Trace message level. - /// Message to trace. - [Conditional("TRACE")] - public static void WarningUnlessAlterTrace(bool condition, PlatformTraceLevel bumpLevel, string message) + /// + /// Trace a warning message. + /// + /// Format of the trace message. + /// Arguments for the trace message format. + [Conditional("TRACE")] + public static void Warning(string format, params object[] args) + { + Debug.Assert(format != null, "format != null"); + + // Check level before doing string.Format to avoid string creation if tracing is off. + if (TraceImpl.ShouldTrace(PlatformTraceLevel.Warning)) { - if (condition) - { - WriteAtLevel(bumpLevel, message); - } - else - { - Warning(message); - } + Warning(string.Format(CultureInfo.InvariantCulture, format, args)); } + } - /// - /// Trace a warning message. - /// - /// Format of the trace message. - /// Arguments for the trace message format. - [Conditional("TRACE")] - public static void Warning(string format, params object[] args) + /// + /// Trace a warning message based on a condition. + /// + /// Condition for tracing. + /// Format of the trace message. + /// Arguments for the trace message. + [Conditional("TRACE")] + public static void WarningIf(bool condition, string format, params object[] args) + { + if (condition) { - Debug.Assert(format != null, "format != null"); - - // Check level before doing string.Format to avoid string creation if tracing is off. - if (traceImpl.ShouldTrace(PlatformTraceLevel.Warning)) - { - Warning(string.Format(CultureInfo.InvariantCulture, format, args)); - } + Warning(format, args); } + } - /// - /// Trace a warning message based on a condition. - /// - /// Condition for tracing. - /// Format of the trace message. - /// Arguments for the trace message. - [Conditional("TRACE")] - public static void WarningIf(bool condition, string format, params object[] args) + /// + /// Only prints the formatted message if the condition is false + /// + /// Condition for tracing. + /// Format of trace message. + /// Arguments for the trace message. + [Conditional("TRACE")] + public static void WarningUnless(bool condition, string format, params object[] args) + { + WarningIf(!condition, format, args); + } + + /// + /// Prints the message if the condition is false. If the condition is true, + /// the message is instead printed at the specified trace level. + /// + /// Condition for tracing. + /// Level of trace message. + /// Format of the trace message. + /// Arguments for trace message. + [Conditional("TRACE")] + public static void WarningUnlessAlterTrace(bool condition, PlatformTraceLevel bumpLevel, string format, params object[] args) + { + if (condition) { - if (condition) - { - Warning(format, args); - } + WriteAtLevel(bumpLevel, format, args); } - - /// - /// Only prints the formatted message if the condition is false - /// - /// Condition for tracing. - /// Format of trace message. - /// Arguments for the trace message. - [Conditional("TRACE")] - public static void WarningUnless(bool condition, string format, params object[] args) + else { - WarningIf(!condition, format, args); + Warning(format, args); } + } - /// - /// Prints the message if the condition is false. If the condition is true, - /// the message is instead printed at the specified trace level. - /// - /// Condition for tracing. - /// Level of trace message. - /// Format of the trace message. - /// Arguments for trace message. - [Conditional("TRACE")] - public static void WarningUnlessAlterTrace(bool condition, PlatformTraceLevel bumpLevel, string format, params object[] args) + /// + /// Trace an informational message. + /// + /// Trace message. + [Conditional("TRACE")] + public static void Info(string message) + { + if (TraceImpl.ShouldTrace(PlatformTraceLevel.Info)) { - if (condition) - { - WriteAtLevel(bumpLevel, format, args); - } - else - { - Warning(format, args); - } + TraceImpl.WriteLine(PlatformTraceLevel.Info, message); } + } - /// - /// Trace an informational message. - /// - /// Trace message. - [Conditional("TRACE")] - public static void Info(string message) + /// + /// Trace an informational message based on a condition. + /// + /// Condition for tracing. + /// Trace message. + [Conditional("TRACE")] + public static void InfoIf(bool condition, string message) + { + if (condition) { - if (traceImpl.ShouldTrace(PlatformTraceLevel.Info)) - { - traceImpl.WriteLine(PlatformTraceLevel.Info, message); - } + Info(message); } + } - /// - /// Trace an informational message based on a condition. - /// - /// Condition for tracing. - /// Trace message. - [Conditional("TRACE")] - public static void InfoIf(bool condition, string message) + /// + /// Only prints the formatted message if the condition is false + /// + /// Condition for tracing. + /// Trace message. + [Conditional("TRACE")] + public static void InfoUnless(bool condition, string message) + { + InfoIf(!condition, message); + } + + /// + /// Prints the message if the condition is false. If the condition is true, + /// the message is instead printed at the specified trace level. + /// + /// Condition for tracing. + /// Trace message level. + /// Trace message. + [Conditional("TRACE")] + public static void InfoUnlessAlterTrace(bool condition, PlatformTraceLevel bumpLevel, string message) + { + if (condition) { - if (condition) - { - Info(message); - } + WriteAtLevel(bumpLevel, message); } - - /// - /// Only prints the formatted message if the condition is false - /// - /// Condition for tracing. - /// Trace message. - [Conditional("TRACE")] - public static void InfoUnless(bool condition, string message) + else { - InfoIf(!condition, message); + Info(message); } + } - /// - /// Prints the message if the condition is false. If the condition is true, - /// the message is instead printed at the specified trace level. - /// - /// Condition for tracing. - /// Trace message level. - /// Trace message. - [Conditional("TRACE")] - public static void InfoUnlessAlterTrace(bool condition, PlatformTraceLevel bumpLevel, string message) + /// + /// Trace an informational message based on a format. + /// + /// Trace message format. + /// Arguments for trace format. + [Conditional("TRACE")] + public static void Info(string format, params object[] args) + { + Debug.Assert(format != null, "format != null"); + + // Check level before doing string.Format to avoid string creation if tracing is off. + if (TraceImpl.ShouldTrace(PlatformTraceLevel.Info)) { - if (condition) - { - WriteAtLevel(bumpLevel, message); - } - else - { - Info(message); - } + Info(string.Format(CultureInfo.InvariantCulture, format, args)); } + } - /// - /// Trace an informational message based on a format. - /// - /// Trace message format. - /// Arguments for trace format. - [Conditional("TRACE")] - public static void Info(string format, params object[] args) + /// + /// Trace an informational message based on a condition. + /// + /// Condition for tracing. + /// Format of the trace message. + /// Arguments for the trace format. + [Conditional("TRACE")] + public static void InfoIf(bool condition, string format, params object[] args) + { + if (condition) { - Debug.Assert(format != null, "format != null"); - - // Check level before doing string.Format to avoid string creation if tracing is off. - if (traceImpl.ShouldTrace(PlatformTraceLevel.Info)) - { - Info(string.Format(CultureInfo.InvariantCulture, format, args)); - } + Info(format, args); } + } - /// - /// Trace an informational message based on a condition. - /// - /// Condition for tracing. - /// Format of the trace message. - /// Arguments for the trace format. - [Conditional("TRACE")] - public static void InfoIf(bool condition, string format, params object[] args) + /// + /// Only prints the formatted message if the condition is false + /// + /// Condition for tracing. + /// Trace message format. + /// Trace message format arguments. + [Conditional("TRACE")] + public static void InfoUnless(bool condition, string format, params object[] args) + { + InfoIf(!condition, format, args); + } + + /// + /// Prints the message if the condition is false. If the condition is true, + /// the message is instead printed at the specified trace level. + /// + /// Condition for tracing. + /// Trace message level. + /// Trace message format. + /// Trace message arguments. + [Conditional("TRACE")] + public static void InfoUnlessAlterTrace(bool condition, PlatformTraceLevel bumpLevel, string format, params object[] args) + { + if (condition) { - if (condition) - { - Info(format, args); - } + WriteAtLevel(bumpLevel, format, args); } - - /// - /// Only prints the formatted message if the condition is false - /// - /// Condition for tracing. - /// Trace message format. - /// Trace message format arguments. - [Conditional("TRACE")] - public static void InfoUnless(bool condition, string format, params object[] args) + else { - InfoIf(!condition, format, args); + Info(format, args); } + } - /// - /// Prints the message if the condition is false. If the condition is true, - /// the message is instead printed at the specified trace level. - /// - /// Condition for tracing. - /// Trace message level. - /// Trace message format. - /// Trace message arguments. - [Conditional("TRACE")] - public static void InfoUnlessAlterTrace(bool condition, PlatformTraceLevel bumpLevel, string format, params object[] args) + /// + /// Trace a verbose message. + /// + /// Trace message. + [Conditional("TRACE")] + public static void Verbose(string message) + { + if (TraceImpl.ShouldTrace(PlatformTraceLevel.Verbose)) { - if (condition) - { - WriteAtLevel(bumpLevel, format, args); - } - else - { - Info(format, args); - } + TraceImpl.WriteLine(PlatformTraceLevel.Verbose, message); } + } - /// - /// Trace a verbose message. - /// - /// Trace message. - [Conditional("TRACE")] - public static void Verbose(string message) + /// + /// Trace a verbose message based on condition. + /// + /// Condition for tracing. + /// Trace message. + [Conditional("TRACE")] + public static void VerboseIf(bool condition, string message) + { + if (condition) { - if (traceImpl.ShouldTrace(PlatformTraceLevel.Verbose)) - { - traceImpl.WriteLine(PlatformTraceLevel.Verbose, message); - } + Verbose(message); } + } - /// - /// Trace a verbose message based on condition. - /// - /// Condition for tracing. - /// Trace message. - [Conditional("TRACE")] - public static void VerboseIf(bool condition, string message) + /// + /// Only prints the formatted message if the condition is false + /// + /// Condition for tracing. + /// Trace message. + [Conditional("TRACE")] + public static void VerboseUnless(bool condition, string message) + { + VerboseIf(!condition, message); + } + + /// + /// Prints the message if the condition is false. If the condition is true, + /// the message is instead printed at the specified trace level. + /// + /// Condition for tracing. + /// Trace message level. + /// Trace message. + [Conditional("TRACE")] + public static void VerboseUnlessAlterTrace(bool condition, PlatformTraceLevel level, string message) + { + if (condition) { - if (condition) - { - Verbose(message); - } + WriteAtLevel(level, message); } - - /// - /// Only prints the formatted message if the condition is false - /// - /// Condition for tracing. - /// Trace message. - [Conditional("TRACE")] - public static void VerboseUnless(bool condition, string message) + else { - VerboseIf(!condition, message); + Verbose(message); } + } - /// - /// Prints the message if the condition is false. If the condition is true, - /// the message is instead printed at the specified trace level. - /// - /// Condition for tracing. - /// Trace message level. - /// Trace message. - [Conditional("TRACE")] - public static void VerboseUnlessAlterTrace(bool condition, PlatformTraceLevel level, string message) + /// + /// Trace a verbose message. + /// + /// Format of trace message. + /// Arguments for trace message. + [Conditional("TRACE")] + public static void Verbose(string format, params object[] args) + { + Debug.Assert(format != null, "format != null"); + + // Check level before doing string.Format to avoid string creation if tracing is off. + if (TraceImpl.ShouldTrace(PlatformTraceLevel.Verbose)) { - if (condition) - { - WriteAtLevel(level, message); - } - else - { - Verbose(message); - } + Verbose(string.Format(CultureInfo.InvariantCulture, format, args)); } + } - /// - /// Trace a verbose message. - /// - /// Format of trace message. - /// Arguments for trace message. - [Conditional("TRACE")] - public static void Verbose(string format, params object[] args) + /// + /// Trace a verbose message based on a condition. + /// + /// Condition for tracing. + /// Message format. + /// Arguments for trace message. + [Conditional("TRACE")] + public static void VerboseIf(bool condition, string format, params object[] args) + { + if (condition) { - Debug.Assert(format != null, "format != null"); - - // Check level before doing string.Format to avoid string creation if tracing is off. - if (traceImpl.ShouldTrace(PlatformTraceLevel.Verbose)) - { - Verbose(string.Format(CultureInfo.InvariantCulture, format, args)); - } + Verbose(format, args); } + } - /// - /// Trace a verbose message based on a condition. - /// - /// Condition for tracing. - /// Message format. - /// Arguments for trace message. - [Conditional("TRACE")] - public static void VerboseIf(bool condition, string format, params object[] args) + /// + /// Only prints the formatted message if the condition is false + /// + /// Condition for tracing. + /// Format for the trace message. + /// Trace message arguments. + [Conditional("TRACE")] + public static void VerboseUnless(bool condition, string format, params object[] args) + { + VerboseIf(!condition, format, args); + } + + /// + /// Prints the message if the condition is false. If the condition is true, + /// the message is instead printed at the specified trace level. + /// + /// Condition for tracing. + /// Trace message level. + /// Format of the trace message. + /// Arguments for the trace message format. + [Conditional("TRACE")] + public static void VerboseUnlessAlterTrace(bool condition, PlatformTraceLevel level, string format, params object[] args) + { + if (condition) { - if (condition) - { - Verbose(format, args); - } + WriteAtLevel(level, format, args); } - - /// - /// Only prints the formatted message if the condition is false - /// - /// Condition for tracing. - /// Format for the trace message. - /// Trace message arguments. - [Conditional("TRACE")] - public static void VerboseUnless(bool condition, string format, params object[] args) + else { - VerboseIf(!condition, format, args); + Verbose(format, args); } + } - /// - /// Prints the message if the condition is false. If the condition is true, - /// the message is instead printed at the specified trace level. - /// - /// Condition for tracing. - /// Trace message level. - /// Format of the trace message. - /// Arguments for the trace message format. - [Conditional("TRACE")] - public static void VerboseUnlessAlterTrace(bool condition, PlatformTraceLevel level, string format, params object[] args) + /// + /// Formats an exception into a nice looking message. + /// + /// The exception to write. + /// The formatted string. + private static string FormatException(Exception exceptionToTrace) + { + // Prefix for each line + string prefix = Environment.NewLine + '\t'; + + // Format this exception + StringBuilder message = new(); + message.Append( + string.Format( + CultureInfo.InvariantCulture, + "Exception: {0}{1}Message: {2}{3}Stack Trace: {4}", + exceptionToTrace.GetType(), + prefix, + exceptionToTrace.Message, + prefix, + exceptionToTrace.StackTrace)); + + // If there is base exception, add that to message + if (exceptionToTrace.GetBaseException() != null) { - if (condition) - { - WriteAtLevel(level, format, args); - } - else - { - Verbose(format, args); - } + message.Append( + string.Format( + CultureInfo.InvariantCulture, + "{0}BaseExceptionMessage: {1}", + prefix, + exceptionToTrace.GetBaseException().Message)); } - /// - /// Formats an exception into a nice looking message. - /// - /// The exception to write. - /// The formatted string. - private static string FormatException(Exception exceptionToTrace) + // If there is inner exception, add that to message + // We deliberately avoid recursive calls here. + if (exceptionToTrace.InnerException != null) { - // Prefix for each line - string prefix = Environment.NewLine + '\t'; - - // Format this exception - StringBuilder message = new StringBuilder(); + // Format same as outer exception except + // "InnerException" is prefixed to each line + Exception inner = exceptionToTrace.InnerException; + prefix += "InnerException"; message.Append( string.Format( CultureInfo.InvariantCulture, - "Exception: {0}{1}Message: {2}{3}Stack Trace: {4}", - exceptionToTrace.GetType(), + "{0}: {1}{2} Message: {3}{4} Stack Trace: {5}", + prefix, + inner.GetType(), prefix, - exceptionToTrace.Message, + inner.Message, prefix, - exceptionToTrace.StackTrace)); + inner.StackTrace)); - // If there is base exception, add that to message - if (exceptionToTrace.GetBaseException() != null) + if (inner.GetBaseException() != null) { message.Append( string.Format( CultureInfo.InvariantCulture, "{0}BaseExceptionMessage: {1}", prefix, - exceptionToTrace.GetBaseException().Message)); - } - - // If there is inner exception, add that to message - // We deliberately avoid recursive calls here. - if (exceptionToTrace.InnerException != null) - { - // Format same as outer exception except - // "InnerException" is prefixed to each line - Exception inner = exceptionToTrace.InnerException; - prefix += "InnerException"; - message.Append( - string.Format( - CultureInfo.InvariantCulture, - "{0}: {1}{2} Message: {3}{4} Stack Trace: {5}", - prefix, - inner.GetType(), - prefix, - inner.Message, - prefix, - inner.StackTrace)); - - if (inner.GetBaseException() != null) - { - message.Append( - string.Format( - CultureInfo.InvariantCulture, - "{0}BaseExceptionMessage: {1}", - prefix, - inner.GetBaseException().Message)); - } + inner.GetBaseException().Message)); } + } - // Append a new line - message.Append(Environment.NewLine); + // Append a new line + message.Append(Environment.NewLine); - return message.ToString(); - } + return message.ToString(); + } - private static void WriteAtLevel(PlatformTraceLevel level, string message) + private static void WriteAtLevel(PlatformTraceLevel level, string message) + { + switch (level) { - switch (level) - { - case PlatformTraceLevel.Off: - return; - case PlatformTraceLevel.Error: - Error(message); - break; - case PlatformTraceLevel.Warning: - Warning(message); - break; - case PlatformTraceLevel.Info: - Info(message); - break; - case PlatformTraceLevel.Verbose: - Verbose(message); - break; - default: - FailDebugger("We should never get here!"); - break; - } + case PlatformTraceLevel.Off: + return; + case PlatformTraceLevel.Error: + Error(message); + break; + case PlatformTraceLevel.Warning: + Warning(message); + break; + case PlatformTraceLevel.Info: + Info(message); + break; + case PlatformTraceLevel.Verbose: + Verbose(message); + break; + default: + FailDebugger("We should never get here!"); + break; } + } - private static void WriteAtLevel(PlatformTraceLevel level, string format, params object[] args) - { - Debug.Assert(format != null, "format != null"); - WriteAtLevel(level, string.Format(CultureInfo.InvariantCulture, format, args)); - } + private static void WriteAtLevel(PlatformTraceLevel level, string format, params object[] args) + { + Debug.Assert(format != null, "format != null"); + WriteAtLevel(level, string.Format(CultureInfo.InvariantCulture, format, args)); + } - private static void FailDebugger(string message) - { + private static void FailDebugger(string message) + { #if DEBUG #if NETSTANDARD1_0 - Debug.Assert(false, message); + Debug.Assert(false, message); #else - Debug.Fail(message); + Debug.Fail(message); #endif #endif - } } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Tracing/Interfaces/ITestPlatformEventSource.cs b/src/Microsoft.TestPlatform.CoreUtilities/Tracing/Interfaces/ITestPlatformEventSource.cs index 767d09cf83..b96bc2f19a 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Tracing/Interfaces/ITestPlatformEventSource.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Tracing/Interfaces/ITestPlatformEventSource.cs @@ -1,262 +1,261 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; + +/// +/// TestPlatform Instrumentation events +/// +public interface ITestPlatformEventSource { /// - /// TestPlatform Instrumentation events - /// - public interface ITestPlatformEventSource - { - /// - /// The vs test console start. - /// - void VsTestConsoleStart(); - - /// - /// The vs test console stop. - /// - void VsTestConsoleStop(); - - /// - /// The discovery request start. - /// - void DiscoveryRequestStart(); - - /// - /// The discovery request stop. - /// - void DiscoveryRequestStop(); - - /// - /// The execution request start. - /// - void ExecutionRequestStart(); - - /// - /// The execution request stop. - /// - void ExecutionRequestStop(); - - /// - /// The test host start. - /// - void TestHostStart(); - - /// - /// The test host stop. - /// - void TestHostStop(); - - /// - /// The test host AppDomain Start. - /// - void TestHostAppDomainCreationStart(); - - /// - /// The test host AppDomain Stop. - /// - void TestHostAppDomainCreationStop(); - - /// - /// The adapter search start. - /// - void AdapterSearchStart(); - - /// - /// The adapter search stop. - /// - void AdapterSearchStop(); - - /// - /// The adapter execution start. - /// - /// - /// The executor uri. - /// - void AdapterExecutionStart(string executorUri); - - /// - /// The adapter execution stop. - /// - /// - /// The number of tests. - /// - void AdapterExecutionStop(long numberOfTests); - - /// - /// The adapter discovery start. - /// - /// - /// The executor uri. - /// - void AdapterDiscoveryStart(string executorUri); - - /// - /// The adapter discovery stop. - /// - /// - /// The number of tests. - /// - void AdapterDiscoveryStop(long numberOfTests); - - /// - /// The discovery start. - /// - void DiscoveryStart(); - - /// - /// The discovery stop. - /// - /// - /// The number of tests. - /// - void DiscoveryStop(long numberOfTests); - - /// - /// The execution start. - /// - void ExecutionStart(); - - /// - /// The execution stop. - /// - /// - /// The number of tests. - /// - void ExecutionStop(long numberOfTests); - - /// - /// The data collection start. - /// - /// - /// The data collector uri. - /// - void DataCollectionStart(string dataCollectorUri); - - /// - /// The data collection stop. - /// - void DataCollectionStop(); - - /// - /// Mark the start of translation layer initialization. - /// - void TranslationLayerInitializeStart(); - - /// - /// Mark the completion of translation layer initialization. - /// - void TranslationLayerInitializeStop(); - - /// - /// Mark the start of translation layer discovery request. - /// - void TranslationLayerDiscoveryStart(); - - /// - /// Mark the completion of translation layer discovery request. - /// - void TranslationLayerDiscoveryStop(); - - /// - /// Mark the start of translation layer execution request. - /// - /// Set to 1 if custom test host is used, 0 otherwise - /// - /// Number of test cases if request has a filter - /// - void TranslationLayerExecutionStart(long customTestHost, long sourcesCount, long testCasesCount, string runSettings); - - /// - /// Mark the completion of translation layer execution request. - /// - void TranslationLayerExecutionStop(); - - /// - /// Mark the start of Metrics Dispose. - /// - void MetricsDisposeStart(); - - /// - /// Mark the completion of Metrics Dispose. - /// - void MetricsDisposeStop(); - - /// - /// The test run attachments processing request start. - /// - void TestRunAttachmentsProcessingRequestStart(); - - /// - /// The test run attachments processing request stop. - /// - void TestRunAttachmentsProcessingRequestStop(); - - /// - /// The test run attachments processing start. - /// - /// - /// The number of attachments. - /// - void TestRunAttachmentsProcessingStart(long numberOfAttachments); - - /// - /// The test run attachments processing stop. - /// - /// - /// The number of attachments. - /// - void TestRunAttachmentsProcessingStop(long numberOfAttachments); - - /// - /// Mark the start of translation layer test run attachments processing request. - /// - void TranslationLayerTestRunAttachmentsProcessingStart(); - - /// - /// Mark the completion of translation layer test run attachments processing request. - /// - void TranslationLayerTestRunAttachmentsProcessingStop(); - - /// - /// The start of the test session start request. - /// - void StartTestSessionStart(); - - /// - /// The end of the test session start request. - /// - void StartTestSessionStop(); - - /// - /// Mark the start of a translation layer start test session request. - /// - void TranslationLayerStartTestSessionStart(); - - /// - /// Mark the end of a translation layer start test session request. - /// - void TranslationLayerStartTestSessionStop(); - - /// - /// The start of the test session stop request. - /// - void StopTestSessionStart(); - - /// - /// The end of the test session stop request. - /// - void StopTestSessionStop(); - - /// - /// Mark the start of a translation layer stop test session request. - /// - void TranslationLayerStopTestSessionStart(); - - /// - /// Mark the end of a translation layer stop test session request. - /// - void TranslationLayerStopTestSessionStop(); - } -} + /// The vs test console start. + /// + void VsTestConsoleStart(); + + /// + /// The vs test console stop. + /// + void VsTestConsoleStop(); + + /// + /// The discovery request start. + /// + void DiscoveryRequestStart(); + + /// + /// The discovery request stop. + /// + void DiscoveryRequestStop(); + + /// + /// The execution request start. + /// + void ExecutionRequestStart(); + + /// + /// The execution request stop. + /// + void ExecutionRequestStop(); + + /// + /// The test host start. + /// + void TestHostStart(); + + /// + /// The test host stop. + /// + void TestHostStop(); + + /// + /// The test host AppDomain Start. + /// + void TestHostAppDomainCreationStart(); + + /// + /// The test host AppDomain Stop. + /// + void TestHostAppDomainCreationStop(); + + /// + /// The adapter search start. + /// + void AdapterSearchStart(); + + /// + /// The adapter search stop. + /// + void AdapterSearchStop(); + + /// + /// The adapter execution start. + /// + /// + /// The executor uri. + /// + void AdapterExecutionStart(string executorUri); + + /// + /// The adapter execution stop. + /// + /// + /// The number of tests. + /// + void AdapterExecutionStop(long numberOfTests); + + /// + /// The adapter discovery start. + /// + /// + /// The executor uri. + /// + void AdapterDiscoveryStart(string executorUri); + + /// + /// The adapter discovery stop. + /// + /// + /// The number of tests. + /// + void AdapterDiscoveryStop(long numberOfTests); + + /// + /// The discovery start. + /// + void DiscoveryStart(); + + /// + /// The discovery stop. + /// + /// + /// The number of tests. + /// + void DiscoveryStop(long numberOfTests); + + /// + /// The execution start. + /// + void ExecutionStart(); + + /// + /// The execution stop. + /// + /// + /// The number of tests. + /// + void ExecutionStop(long numberOfTests); + + /// + /// The data collection start. + /// + /// + /// The data collector uri. + /// + void DataCollectionStart(string dataCollectorUri); + + /// + /// The data collection stop. + /// + void DataCollectionStop(); + + /// + /// Mark the start of translation layer initialization. + /// + void TranslationLayerInitializeStart(); + + /// + /// Mark the completion of translation layer initialization. + /// + void TranslationLayerInitializeStop(); + + /// + /// Mark the start of translation layer discovery request. + /// + void TranslationLayerDiscoveryStart(); + + /// + /// Mark the completion of translation layer discovery request. + /// + void TranslationLayerDiscoveryStop(); + + /// + /// Mark the start of translation layer execution request. + /// + /// Set to 1 if custom test host is used, 0 otherwise + /// + /// Number of test cases if request has a filter + /// + void TranslationLayerExecutionStart(long customTestHost, long sourcesCount, long testCasesCount, string runSettings); + + /// + /// Mark the completion of translation layer execution request. + /// + void TranslationLayerExecutionStop(); + + /// + /// Mark the start of Metrics Dispose. + /// + void MetricsDisposeStart(); + + /// + /// Mark the completion of Metrics Dispose. + /// + void MetricsDisposeStop(); + + /// + /// The test run attachments processing request start. + /// + void TestRunAttachmentsProcessingRequestStart(); + + /// + /// The test run attachments processing request stop. + /// + void TestRunAttachmentsProcessingRequestStop(); + + /// + /// The test run attachments processing start. + /// + /// + /// The number of attachments. + /// + void TestRunAttachmentsProcessingStart(long numberOfAttachments); + + /// + /// The test run attachments processing stop. + /// + /// + /// The number of attachments. + /// + void TestRunAttachmentsProcessingStop(long numberOfAttachments); + + /// + /// Mark the start of translation layer test run attachments processing request. + /// + void TranslationLayerTestRunAttachmentsProcessingStart(); + + /// + /// Mark the completion of translation layer test run attachments processing request. + /// + void TranslationLayerTestRunAttachmentsProcessingStop(); + + /// + /// The start of the test session start request. + /// + void StartTestSessionStart(); + + /// + /// The end of the test session start request. + /// + void StartTestSessionStop(); + + /// + /// Mark the start of a translation layer start test session request. + /// + void TranslationLayerStartTestSessionStart(); + + /// + /// Mark the end of a translation layer start test session request. + /// + void TranslationLayerStartTestSessionStop(); + + /// + /// The start of the test session stop request. + /// + void StopTestSessionStart(); + + /// + /// The end of the test session stop request. + /// + void StopTestSessionStop(); + + /// + /// Mark the start of a translation layer stop test session request. + /// + void TranslationLayerStopTestSessionStart(); + + /// + /// Mark the end of a translation layer stop test session request. + /// + void TranslationLayerStopTestSessionStop(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Tracing/TestPlatformEventSource.cs b/src/Microsoft.TestPlatform.CoreUtilities/Tracing/TestPlatformEventSource.cs index 3ad391be38..1306e7131b 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Tracing/TestPlatformEventSource.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Tracing/TestPlatformEventSource.cs @@ -3,341 +3,340 @@ #if !NETSTANDARD1_0 -namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing -{ - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; +namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing; - using System.Diagnostics.Tracing; +using Interfaces; - /// - [EventSource(Name = "TestPlatform")] - public class TestPlatformEventSource : EventSource, ITestPlatformEventSource - { - private static readonly TestPlatformEventSource LocalInstance = new TestPlatformEventSource(); +using System.Diagnostics.Tracing; - /// - /// Gets the instance of . - /// - public static ITestPlatformEventSource Instance - { - get - { - return LocalInstance; - } - } +/// +[EventSource(Name = "TestPlatform")] +public class TestPlatformEventSource : EventSource, ITestPlatformEventSource +{ + private static readonly TestPlatformEventSource LocalInstance = new(); - /// - [Event(TestPlatformInstrumentationEvents.VsTestConsoleStartEventId)] - public void VsTestConsoleStart() + /// + /// Gets the instance of . + /// + public static ITestPlatformEventSource Instance + { + get { - this.WriteEvent(TestPlatformInstrumentationEvents.VsTestConsoleStartEventId); + return LocalInstance; } + } - /// - [Event(TestPlatformInstrumentationEvents.VsTestConsoleStopEventId)] - public void VsTestConsoleStop() - { - this.WriteEvent(TestPlatformInstrumentationEvents.VsTestConsoleStopEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.VsTestConsoleStartEventId)] + public void VsTestConsoleStart() + { + WriteEvent(TestPlatformInstrumentationEvents.VsTestConsoleStartEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.DiscoveryRequestStartEventId)] - public void DiscoveryRequestStart() - { - this.WriteEvent(TestPlatformInstrumentationEvents.DiscoveryRequestStartEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.VsTestConsoleStopEventId)] + public void VsTestConsoleStop() + { + WriteEvent(TestPlatformInstrumentationEvents.VsTestConsoleStopEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.DiscoveryRequestStopEventId)] - public void DiscoveryRequestStop() - { - this.WriteEvent(TestPlatformInstrumentationEvents.DiscoveryRequestStopEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.DiscoveryRequestStartEventId)] + public void DiscoveryRequestStart() + { + WriteEvent(TestPlatformInstrumentationEvents.DiscoveryRequestStartEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.ExecutionRequestStartEventId)] - public void ExecutionRequestStart() - { - this.WriteEvent(TestPlatformInstrumentationEvents.ExecutionRequestStartEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.DiscoveryRequestStopEventId)] + public void DiscoveryRequestStop() + { + WriteEvent(TestPlatformInstrumentationEvents.DiscoveryRequestStopEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.ExecutionRequestStopEventId)] - public void ExecutionRequestStop() - { - this.WriteEvent(TestPlatformInstrumentationEvents.ExecutionRequestStopEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.ExecutionRequestStartEventId)] + public void ExecutionRequestStart() + { + WriteEvent(TestPlatformInstrumentationEvents.ExecutionRequestStartEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.TestHostStartEventId)] - public void TestHostStart() - { - this.WriteEvent(TestPlatformInstrumentationEvents.TestHostStartEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.ExecutionRequestStopEventId)] + public void ExecutionRequestStop() + { + WriteEvent(TestPlatformInstrumentationEvents.ExecutionRequestStopEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.TestHostStopEventId)] - public void TestHostStop() - { - this.WriteEvent(TestPlatformInstrumentationEvents.TestHostStopEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.TestHostStartEventId)] + public void TestHostStart() + { + WriteEvent(TestPlatformInstrumentationEvents.TestHostStartEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.TestHostAppDomainCreationStartEventId)] - public void TestHostAppDomainCreationStart() - { - this.WriteEvent(TestPlatformInstrumentationEvents.TestHostAppDomainCreationStartEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.TestHostStopEventId)] + public void TestHostStop() + { + WriteEvent(TestPlatformInstrumentationEvents.TestHostStopEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.TestHostAppDomainCreationStopEventId)] - public void TestHostAppDomainCreationStop() - { - this.WriteEvent(TestPlatformInstrumentationEvents.TestHostAppDomainCreationStopEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.TestHostAppDomainCreationStartEventId)] + public void TestHostAppDomainCreationStart() + { + WriteEvent(TestPlatformInstrumentationEvents.TestHostAppDomainCreationStartEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.AdapterSearchStartEventId)] - public void AdapterSearchStart() - { - this.WriteEvent(TestPlatformInstrumentationEvents.AdapterSearchStartEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.TestHostAppDomainCreationStopEventId)] + public void TestHostAppDomainCreationStop() + { + WriteEvent(TestPlatformInstrumentationEvents.TestHostAppDomainCreationStopEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.AdapterSearchStopEventId)] - public void AdapterSearchStop() - { - this.WriteEvent(TestPlatformInstrumentationEvents.AdapterSearchStopEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.AdapterSearchStartEventId)] + public void AdapterSearchStart() + { + WriteEvent(TestPlatformInstrumentationEvents.AdapterSearchStartEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.AdapterExecutionStartEventId)] - public void AdapterExecutionStart(string executorUri) - { - this.WriteEvent(TestPlatformInstrumentationEvents.AdapterExecutionStartEventId, executorUri); - } + /// + [Event(TestPlatformInstrumentationEvents.AdapterSearchStopEventId)] + public void AdapterSearchStop() + { + WriteEvent(TestPlatformInstrumentationEvents.AdapterSearchStopEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.AdapterExecutionStopEventId)] - public void AdapterExecutionStop(long numberOfTests) - { - this.WriteEvent(TestPlatformInstrumentationEvents.AdapterExecutionStopEventId, numberOfTests); - } + /// + [Event(TestPlatformInstrumentationEvents.AdapterExecutionStartEventId)] + public void AdapterExecutionStart(string executorUri) + { + WriteEvent(TestPlatformInstrumentationEvents.AdapterExecutionStartEventId, executorUri); + } - /// - [Event(TestPlatformInstrumentationEvents.AdapterDiscoveryStartEventId)] - public void AdapterDiscoveryStart(string executorUri) - { - this.WriteEvent(TestPlatformInstrumentationEvents.AdapterDiscoveryStartEventId, executorUri); - } + /// + [Event(TestPlatformInstrumentationEvents.AdapterExecutionStopEventId)] + public void AdapterExecutionStop(long numberOfTests) + { + WriteEvent(TestPlatformInstrumentationEvents.AdapterExecutionStopEventId, numberOfTests); + } - /// - [Event(TestPlatformInstrumentationEvents.AdapterDiscoveryStopEventId)] - public void AdapterDiscoveryStop(long numberOfTests) - { - this.WriteEvent(TestPlatformInstrumentationEvents.AdapterDiscoveryStopEventId, numberOfTests); - } + /// + [Event(TestPlatformInstrumentationEvents.AdapterDiscoveryStartEventId)] + public void AdapterDiscoveryStart(string executorUri) + { + WriteEvent(TestPlatformInstrumentationEvents.AdapterDiscoveryStartEventId, executorUri); + } - /// - [Event(TestPlatformInstrumentationEvents.DiscoveryStartEventId)] - public void DiscoveryStart() - { - this.WriteEvent(TestPlatformInstrumentationEvents.DiscoveryStartEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.AdapterDiscoveryStopEventId)] + public void AdapterDiscoveryStop(long numberOfTests) + { + WriteEvent(TestPlatformInstrumentationEvents.AdapterDiscoveryStopEventId, numberOfTests); + } - /// - [Event(TestPlatformInstrumentationEvents.DiscoveryStopEventId)] - public void DiscoveryStop(long numberOfTests) - { - this.WriteEvent(TestPlatformInstrumentationEvents.DiscoveryStopEventId, numberOfTests); - } + /// + [Event(TestPlatformInstrumentationEvents.DiscoveryStartEventId)] + public void DiscoveryStart() + { + WriteEvent(TestPlatformInstrumentationEvents.DiscoveryStartEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.ExecutionStartEventId)] - public void ExecutionStart() - { - this.WriteEvent(TestPlatformInstrumentationEvents.ExecutionStartEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.DiscoveryStopEventId)] + public void DiscoveryStop(long numberOfTests) + { + WriteEvent(TestPlatformInstrumentationEvents.DiscoveryStopEventId, numberOfTests); + } - /// - [Event(TestPlatformInstrumentationEvents.ExecutionStopEventId)] - public void ExecutionStop(long numberOfTests) - { - this.WriteEvent(TestPlatformInstrumentationEvents.ExecutionStopEventId, numberOfTests); - } + /// + [Event(TestPlatformInstrumentationEvents.ExecutionStartEventId)] + public void ExecutionStart() + { + WriteEvent(TestPlatformInstrumentationEvents.ExecutionStartEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.DataCollectionStartEventId)] - public void DataCollectionStart(string dataCollectorUri) - { - this.WriteEvent(TestPlatformInstrumentationEvents.DataCollectionStartEventId, dataCollectorUri); - } + /// + [Event(TestPlatformInstrumentationEvents.ExecutionStopEventId)] + public void ExecutionStop(long numberOfTests) + { + WriteEvent(TestPlatformInstrumentationEvents.ExecutionStopEventId, numberOfTests); + } - /// - [Event(TestPlatformInstrumentationEvents.DataCollectionStopEventId)] - public void DataCollectionStop() - { - this.WriteEvent(TestPlatformInstrumentationEvents.DataCollectionStopEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.DataCollectionStartEventId)] + public void DataCollectionStart(string dataCollectorUri) + { + WriteEvent(TestPlatformInstrumentationEvents.DataCollectionStartEventId, dataCollectorUri); + } - /// - [Event(TestPlatformInstrumentationEvents.TranslationLayerInitializeStartEventId)] - public void TranslationLayerInitializeStart() - { - this.WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerInitializeStartEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.DataCollectionStopEventId)] + public void DataCollectionStop() + { + WriteEvent(TestPlatformInstrumentationEvents.DataCollectionStopEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.TranslationLayerInitializeStopEventId)] - public void TranslationLayerInitializeStop() - { - this.WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerInitializeStopEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.TranslationLayerInitializeStartEventId)] + public void TranslationLayerInitializeStart() + { + WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerInitializeStartEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.TranslationLayerDiscoveryStartEventId)] - public void TranslationLayerDiscoveryStart() - { - this.WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerDiscoveryStartEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.TranslationLayerInitializeStopEventId)] + public void TranslationLayerInitializeStop() + { + WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerInitializeStopEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.TranslationLayerDiscoveryStopEventId)] - public void TranslationLayerDiscoveryStop() - { - this.WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerDiscoveryStopEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.TranslationLayerDiscoveryStartEventId)] + public void TranslationLayerDiscoveryStart() + { + WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerDiscoveryStartEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.TranslationLayerExecutionStartEventId)] - public void TranslationLayerExecutionStart(long customTestHost, long sourcesCount, long testCasesCount, string runSettings) - { - this.WriteEvent( - TestPlatformInstrumentationEvents.TranslationLayerExecutionStartEventId, - customTestHost, - sourcesCount, - testCasesCount, - runSettings); - } + /// + [Event(TestPlatformInstrumentationEvents.TranslationLayerDiscoveryStopEventId)] + public void TranslationLayerDiscoveryStop() + { + WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerDiscoveryStopEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.TranslationLayerExecutionStopEventId)] - public void TranslationLayerExecutionStop() - { - this.WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerExecutionStopEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.TranslationLayerExecutionStartEventId)] + public void TranslationLayerExecutionStart(long customTestHost, long sourcesCount, long testCasesCount, string runSettings) + { + WriteEvent( + TestPlatformInstrumentationEvents.TranslationLayerExecutionStartEventId, + customTestHost, + sourcesCount, + testCasesCount, + runSettings); + } - /// - [Event(TestPlatformInstrumentationEvents.MetricsDisposeStartEventId)] - public void MetricsDisposeStart() - { - this.WriteEvent(TestPlatformInstrumentationEvents.MetricsDisposeStartEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.TranslationLayerExecutionStopEventId)] + public void TranslationLayerExecutionStop() + { + WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerExecutionStopEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.MetricsDisposeStopEventId)] - public void MetricsDisposeStop() - { - this.WriteEvent(TestPlatformInstrumentationEvents.MetricsDisposeStopEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.MetricsDisposeStartEventId)] + public void MetricsDisposeStart() + { + WriteEvent(TestPlatformInstrumentationEvents.MetricsDisposeStartEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingRequestStartEventId)] - public void TestRunAttachmentsProcessingRequestStart() - { - this.WriteEvent(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingRequestStartEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.MetricsDisposeStopEventId)] + public void MetricsDisposeStop() + { + WriteEvent(TestPlatformInstrumentationEvents.MetricsDisposeStopEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingRequestStopEventId)] - public void TestRunAttachmentsProcessingRequestStop() - { - this.WriteEvent(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingRequestStopEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingRequestStartEventId)] + public void TestRunAttachmentsProcessingRequestStart() + { + WriteEvent(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingRequestStartEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingStartEventId)] - public void TestRunAttachmentsProcessingStart(long numberOfAttachments) - { - this.WriteEvent(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingStartEventId, numberOfAttachments); - } + /// + [Event(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingRequestStopEventId)] + public void TestRunAttachmentsProcessingRequestStop() + { + WriteEvent(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingRequestStopEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingStopEventId)] - public void TestRunAttachmentsProcessingStop(long numberOfAttachments) - { - this.WriteEvent(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingStopEventId, numberOfAttachments); - } + /// + [Event(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingStartEventId)] + public void TestRunAttachmentsProcessingStart(long numberOfAttachments) + { + WriteEvent(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingStartEventId, numberOfAttachments); + } - /// - [Event(TestPlatformInstrumentationEvents.TranslationLayerTestRunAttachmentsProcessingStartEventId)] - public void TranslationLayerTestRunAttachmentsProcessingStart() - { - this.WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerTestRunAttachmentsProcessingStartEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingStopEventId)] + public void TestRunAttachmentsProcessingStop(long numberOfAttachments) + { + WriteEvent(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingStopEventId, numberOfAttachments); + } - /// - [Event(TestPlatformInstrumentationEvents.TranslationLayerTestRunAttachmentsProcessingStopEventId)] - public void TranslationLayerTestRunAttachmentsProcessingStop() - { - this.WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerTestRunAttachmentsProcessingStopEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.TranslationLayerTestRunAttachmentsProcessingStartEventId)] + public void TranslationLayerTestRunAttachmentsProcessingStart() + { + WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerTestRunAttachmentsProcessingStartEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.StartTestSessionStartEventId)] - public void StartTestSessionStart() - { - this.WriteEvent(TestPlatformInstrumentationEvents.StartTestSessionStartEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.TranslationLayerTestRunAttachmentsProcessingStopEventId)] + public void TranslationLayerTestRunAttachmentsProcessingStop() + { + WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerTestRunAttachmentsProcessingStopEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.StartTestSessionStopEventId)] - public void StartTestSessionStop() - { - this.WriteEvent(TestPlatformInstrumentationEvents.StartTestSessionStopEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.StartTestSessionStartEventId)] + public void StartTestSessionStart() + { + WriteEvent(TestPlatformInstrumentationEvents.StartTestSessionStartEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.TranslationLayerStartTestSessionStartEventId)] - public void TranslationLayerStartTestSessionStart() - { - this.WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerStartTestSessionStartEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.StartTestSessionStopEventId)] + public void StartTestSessionStop() + { + WriteEvent(TestPlatformInstrumentationEvents.StartTestSessionStopEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.TranslationLayerStartTestSessionStopEventId)] - public void TranslationLayerStartTestSessionStop() - { - this.WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerStartTestSessionStopEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.TranslationLayerStartTestSessionStartEventId)] + public void TranslationLayerStartTestSessionStart() + { + WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerStartTestSessionStartEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.StopTestSessionStartEventId)] - public void StopTestSessionStart() - { - this.WriteEvent(TestPlatformInstrumentationEvents.StopTestSessionStartEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.TranslationLayerStartTestSessionStopEventId)] + public void TranslationLayerStartTestSessionStop() + { + WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerStartTestSessionStopEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.StopTestSessionStopEventId)] - public void StopTestSessionStop() - { - this.WriteEvent(TestPlatformInstrumentationEvents.StopTestSessionStopEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.StopTestSessionStartEventId)] + public void StopTestSessionStart() + { + WriteEvent(TestPlatformInstrumentationEvents.StopTestSessionStartEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.TranslationLayerStopTestSessionStartEventId)] - public void TranslationLayerStopTestSessionStart() - { - this.WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerStopTestSessionStartEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.StopTestSessionStopEventId)] + public void StopTestSessionStop() + { + WriteEvent(TestPlatformInstrumentationEvents.StopTestSessionStopEventId); + } - /// - [Event(TestPlatformInstrumentationEvents.TranslationLayerStopTestSessionStopEventId)] - public void TranslationLayerStopTestSessionStop() - { - this.WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerStopTestSessionStopEventId); - } + /// + [Event(TestPlatformInstrumentationEvents.TranslationLayerStopTestSessionStartEventId)] + public void TranslationLayerStopTestSessionStart() + { + WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerStopTestSessionStartEventId); + } + + /// + [Event(TestPlatformInstrumentationEvents.TranslationLayerStopTestSessionStopEventId)] + public void TranslationLayerStopTestSessionStop() + { + WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerStopTestSessionStopEventId); } } diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Tracing/TestPlatformInstrumentationEvents.cs b/src/Microsoft.TestPlatform.CoreUtilities/Tracing/TestPlatformInstrumentationEvents.cs index 51e8fec9ba..d04ed80915 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Tracing/TestPlatformInstrumentationEvents.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Tracing/TestPlatformInstrumentationEvents.cs @@ -1,231 +1,230 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing +namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing; + +/// +/// TestPlatform Event Ids and tasks constants +/// +internal class TestPlatformInstrumentationEvents { /// - /// TestPlatform Event Ids and tasks constants - /// - internal class TestPlatformInstrumentationEvents - { - /// - /// The discovery start event id. - /// - public const int DiscoveryStartEventId = 0x1; - - /// - /// The discovery stop event id. - /// - public const int DiscoveryStopEventId = 0x2; - - /// - /// The execution start event id. - /// - public const int ExecutionStartEventId = 0x4; - - /// - /// The execution stop event id. - /// - public const int ExecutionStopEventId = 0x5; - - /// - /// The adapter execution start event id. - /// - public const int AdapterExecutionStartEventId = 0x7; - - /// - /// The adapter execution stop event id. - /// - public const int AdapterExecutionStopEventId = 0x8; - - /// - /// The console runner start event id. - /// - public const int VsTestConsoleStartEventId = 0x10; - - /// - /// The console runner stop event id. - /// - public const int VsTestConsoleStopEventId = 0x11; - - /// - /// The test host start event id. - /// - public const int TestHostStartEventId = 0x13; - - /// - /// The test host stop event id. - /// - public const int TestHostStopEventId = 0x14; - - /// - /// The adapter search start event id. - /// - public const int AdapterSearchStartEventId = 0x16; - - /// - /// The adapter search stop event id. - /// - public const int AdapterSearchStopEventId = 0x17; - - /// - /// The discovery request start event id. - /// - public const int DiscoveryRequestStartEventId = 0x19; - - /// - /// The discovery request stop event id. - /// - public const int DiscoveryRequestStopEventId = 0x20; - - /// - /// The execution request start event id. - /// - public const int ExecutionRequestStartEventId = 0x21; - - /// - /// The execution request stop event id. - /// - public const int ExecutionRequestStopEventId = 0x22; - - /// - /// The data collection start event id. - /// - public const int DataCollectionStartEventId = 0x25; - - /// - /// The data collection stop event id. - /// - public const int DataCollectionStopEventId = 0x26; - - /// - /// The adapter discovery start event id. - /// - public const int AdapterDiscoveryStartEventId = 0x27; - - /// - /// The adapter discovery stop event id. - /// - public const int AdapterDiscoveryStopEventId = 0x28; - - /// - /// The test host appdomain start event id. - /// - public const int TestHostAppDomainCreationStartEventId = 0x30; - - /// - /// The test host appdomain stop event id. - /// - public const int TestHostAppDomainCreationStopEventId = 0x31; - - /// - /// Events fired on initialization of translation layer. - /// - public const int TranslationLayerInitializeStartEventId = 0x32; - - /// - /// Events fired on initialization complete of translation layer. - /// - public const int TranslationLayerInitializeStopEventId = 0x33; - - /// - /// Events fired on discovery start of translation layer. - /// - public const int TranslationLayerDiscoveryStartEventId = 0x34; - - /// - /// Events fired on discovery complete in translation layer. - /// - public const int TranslationLayerDiscoveryStopEventId = 0x35; - - /// - /// Event fired on execution start in translation layer. - /// - public const int TranslationLayerExecutionStartEventId = 0x36; - - /// - /// Event fired on execution complete in translation layer. - /// - public const int TranslationLayerExecutionStopEventId = 0x37; - - /// - /// Event fired on Metrics Dispose start. - /// - public const int MetricsDisposeStartEventId = 0x38; - - /// - /// Event fired on Metrics Dispose completes. - /// - public const int MetricsDisposeStopEventId = 0x39; - - /// - /// The session attachments processing start event id. - /// - public const int TestRunAttachmentsProcessingStartEventId = 0x40; - - /// - /// The session attachments processing stop event id. - /// - public const int TestRunAttachmentsProcessingStopEventId = 0x41; - - /// - /// The session attachments processing request start event id. - /// - public const int TestRunAttachmentsProcessingRequestStartEventId = 0x42; - - /// - /// The session attachments processing request stop event id. - /// - public const int TestRunAttachmentsProcessingRequestStopEventId = 0x43; - - /// - /// Events fired on session attachments processing start of translation layer. - /// - public const int TranslationLayerTestRunAttachmentsProcessingStartEventId = 0x44; - - /// - /// Events fired on session attachments processing complete in translation layer. - /// - public const int TranslationLayerTestRunAttachmentsProcessingStopEventId = 0x45; - - /// - /// The start test session start event id. - /// - public const int StartTestSessionStartEventId = 0x46; - - /// - /// The start test session stop event id. - /// - public const int StartTestSessionStopEventId = 0x47; - - /// - /// The translation layer start test session start event id. - /// - public const int TranslationLayerStartTestSessionStartEventId = 0x48; - - /// - /// The translation layer start test session stop event id. - /// - public const int TranslationLayerStartTestSessionStopEventId = 0x49; - - /// - /// The stop test session start event id. - /// - public const int StopTestSessionStartEventId = 0x4A; - - /// - /// The stop test session stop event id. - /// - public const int StopTestSessionStopEventId = 0x4B; - - /// - /// The translation layer stop test session start event id. - /// - public const int TranslationLayerStopTestSessionStartEventId = 0x4C; - - /// - /// The translation layer stop test session stop event id. - /// - public const int TranslationLayerStopTestSessionStopEventId = 0x4D; - } + /// The discovery start event id. + /// + public const int DiscoveryStartEventId = 0x1; + + /// + /// The discovery stop event id. + /// + public const int DiscoveryStopEventId = 0x2; + + /// + /// The execution start event id. + /// + public const int ExecutionStartEventId = 0x4; + + /// + /// The execution stop event id. + /// + public const int ExecutionStopEventId = 0x5; + + /// + /// The adapter execution start event id. + /// + public const int AdapterExecutionStartEventId = 0x7; + + /// + /// The adapter execution stop event id. + /// + public const int AdapterExecutionStopEventId = 0x8; + + /// + /// The console runner start event id. + /// + public const int VsTestConsoleStartEventId = 0x10; + + /// + /// The console runner stop event id. + /// + public const int VsTestConsoleStopEventId = 0x11; + + /// + /// The test host start event id. + /// + public const int TestHostStartEventId = 0x13; + + /// + /// The test host stop event id. + /// + public const int TestHostStopEventId = 0x14; + + /// + /// The adapter search start event id. + /// + public const int AdapterSearchStartEventId = 0x16; + + /// + /// The adapter search stop event id. + /// + public const int AdapterSearchStopEventId = 0x17; + + /// + /// The discovery request start event id. + /// + public const int DiscoveryRequestStartEventId = 0x19; + + /// + /// The discovery request stop event id. + /// + public const int DiscoveryRequestStopEventId = 0x20; + + /// + /// The execution request start event id. + /// + public const int ExecutionRequestStartEventId = 0x21; + + /// + /// The execution request stop event id. + /// + public const int ExecutionRequestStopEventId = 0x22; + + /// + /// The data collection start event id. + /// + public const int DataCollectionStartEventId = 0x25; + + /// + /// The data collection stop event id. + /// + public const int DataCollectionStopEventId = 0x26; + + /// + /// The adapter discovery start event id. + /// + public const int AdapterDiscoveryStartEventId = 0x27; + + /// + /// The adapter discovery stop event id. + /// + public const int AdapterDiscoveryStopEventId = 0x28; + + /// + /// The test host appdomain start event id. + /// + public const int TestHostAppDomainCreationStartEventId = 0x30; + + /// + /// The test host appdomain stop event id. + /// + public const int TestHostAppDomainCreationStopEventId = 0x31; + + /// + /// Events fired on initialization of translation layer. + /// + public const int TranslationLayerInitializeStartEventId = 0x32; + + /// + /// Events fired on initialization complete of translation layer. + /// + public const int TranslationLayerInitializeStopEventId = 0x33; + + /// + /// Events fired on discovery start of translation layer. + /// + public const int TranslationLayerDiscoveryStartEventId = 0x34; + + /// + /// Events fired on discovery complete in translation layer. + /// + public const int TranslationLayerDiscoveryStopEventId = 0x35; + + /// + /// Event fired on execution start in translation layer. + /// + public const int TranslationLayerExecutionStartEventId = 0x36; + + /// + /// Event fired on execution complete in translation layer. + /// + public const int TranslationLayerExecutionStopEventId = 0x37; + + /// + /// Event fired on Metrics Dispose start. + /// + public const int MetricsDisposeStartEventId = 0x38; + + /// + /// Event fired on Metrics Dispose completes. + /// + public const int MetricsDisposeStopEventId = 0x39; + + /// + /// The session attachments processing start event id. + /// + public const int TestRunAttachmentsProcessingStartEventId = 0x40; + + /// + /// The session attachments processing stop event id. + /// + public const int TestRunAttachmentsProcessingStopEventId = 0x41; + + /// + /// The session attachments processing request start event id. + /// + public const int TestRunAttachmentsProcessingRequestStartEventId = 0x42; + + /// + /// The session attachments processing request stop event id. + /// + public const int TestRunAttachmentsProcessingRequestStopEventId = 0x43; + + /// + /// Events fired on session attachments processing start of translation layer. + /// + public const int TranslationLayerTestRunAttachmentsProcessingStartEventId = 0x44; + + /// + /// Events fired on session attachments processing complete in translation layer. + /// + public const int TranslationLayerTestRunAttachmentsProcessingStopEventId = 0x45; + + /// + /// The start test session start event id. + /// + public const int StartTestSessionStartEventId = 0x46; + + /// + /// The start test session stop event id. + /// + public const int StartTestSessionStopEventId = 0x47; + + /// + /// The translation layer start test session start event id. + /// + public const int TranslationLayerStartTestSessionStartEventId = 0x48; + + /// + /// The translation layer start test session stop event id. + /// + public const int TranslationLayerStartTestSessionStopEventId = 0x49; + + /// + /// The stop test session start event id. + /// + public const int StopTestSessionStartEventId = 0x4A; + + /// + /// The stop test session stop event id. + /// + public const int StopTestSessionStopEventId = 0x4B; + + /// + /// The translation layer stop test session start event id. + /// + public const int TranslationLayerStopTestSessionStartEventId = 0x4C; + + /// + /// The translation layer stop test session stop event id. + /// + public const int TranslationLayerStopTestSessionStopEventId = 0x4D; } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Utilities/Job.cs b/src/Microsoft.TestPlatform.CoreUtilities/Utilities/Job.cs index ff433b8482..680844d42f 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Utilities/Job.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Utilities/Job.cs @@ -1,101 +1,100 @@ + // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -#pragma warning disable SA1649 // SA1649FileNameMustMatchTypeName. This is a generic type. -namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities -{ - using System.Threading; +namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities; + +using System.Threading; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using ObjectModel; + +/// +/// Wrapper class around a job used to send additional information to the background thread. +/// +/// The type of the job. +internal class Job +{ + #region Constructor /// - /// Wrapper class around a job used to send additional information to the background thread. + /// Initializes a new instance of the class. /// - /// The type of the job. - internal class Job + /// + /// Job to be processed. + /// + /// + /// Size of payload. + /// + public Job(TPayload job, int size) { - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - /// - /// Job to be processed. - /// - /// - /// Size of payload. - /// - public Job(TPayload job, int size) - { - this.Payload = job; - this.Size = size; - } + Payload = job; + Size = size; + } - /// - /// Prevents a default instance of the class from being created. - /// - private Job() - { - this.Size = 0; - } + /// + /// Prevents a default instance of the class from being created. + /// + private Job() + { + Size = 0; + } - #endregion + #endregion - #region Properties + #region Properties - /// - /// Gets a special job that indicates the queue should shutdown. - /// - public static Job ShutdownJob + /// + /// Gets a special job that indicates the queue should shutdown. + /// + public static Job ShutdownJob + { + get { - get - { - var shutdownJob = new Job(); - shutdownJob.Shutdown = true; + var shutdownJob = new Job(); + shutdownJob.Shutdown = true; - return shutdownJob; - } + return shutdownJob; } + } - /// - /// Gets the job to be processed. - /// - public TPayload Payload { get; private set; } - - /// - /// Gets a value indicating whether the background thread should shutdown. - /// - public bool Shutdown { get; private set; } + /// + /// Gets the job to be processed. + /// + public TPayload Payload { get; private set; } - /// - /// Gets the signal that this job is being processed. - /// - public ManualResetEvent WaitManualResetEvent { get; private set; } + /// + /// Gets a value indicating whether the background thread should shutdown. + /// + public bool Shutdown { get; private set; } - /// - /// Gets the size of this job instance. This is used to manage the total size of Job Queue. - /// - public int Size { get; private set; } + /// + /// Gets the signal that this job is being processed. + /// + public ManualResetEvent WaitManualResetEvent { get; private set; } - #endregion + /// + /// Gets the size of this job instance. This is used to manage the total size of Job Queue. + /// + public int Size { get; private set; } - #region Static Methods + #endregion - /// - /// Creates a job with a manual reset event that will be set when the job is processed. - /// - /// The wait Event. - /// The wait job. - public static Job CreateWaitJob(ManualResetEvent waitEvent) - { - ValidateArg.NotNull(waitEvent, nameof(waitEvent)); - var waitJob = new Job(); - waitJob.WaitManualResetEvent = waitEvent; + #region Static Methods - return waitJob; - } + /// + /// Creates a job with a manual reset event that will be set when the job is processed. + /// + /// The wait Event. + /// The wait job. + public static Job CreateWaitJob(ManualResetEvent waitEvent) + { + ValidateArg.NotNull(waitEvent, nameof(waitEvent)); + var waitJob = new Job(); + waitJob.WaitManualResetEvent = waitEvent; - #endregion + return waitJob; } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Utilities/JobQueue.cs b/src/Microsoft.TestPlatform.CoreUtilities/Utilities/JobQueue.cs index 09b3f3dbb3..64cf9d4a5f 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Utilities/JobQueue.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Utilities/JobQueue.cs @@ -1,376 +1,371 @@ + // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -#pragma warning disable SA1649 // SA1649FileNameMustMatchTypeName. This is a generic type. -namespace Microsoft.VisualStudio.TestPlatform.Utilities +namespace Microsoft.VisualStudio.TestPlatform.Utilities; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; + +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using CoreUtilities.Resources; +using ObjectModel; + +/// +/// Generic queue for processing jobs on a background thread. +/// +/// The type of the job that is being processed. +public class JobQueue : IDisposable { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Diagnostics.CodeAnalysis; - using System.Globalization; - using System.Threading; - using System.Threading.Tasks; - - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Resources; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; + #region Fields /// - /// Generic queue for processing jobs on a background thread. + /// Handler which processes the individual jobs. /// - /// The type of the job that is being processed. - public class JobQueue : IDisposable - { - #region Fields - - /// - /// Handler which processes the individual jobs. - /// - private Action processJob; - - /// - /// Name used when displaying information or reporting errors about this queue. - /// - private string displayName; - - /// - /// The queue of jobs. - /// - private Queue> jobsQueue; - - /// - /// Signaled when a job is added to the queue. Used to wakeup the background thread. - /// - private ManualResetEvent jobAdded; - - /// - /// The maximum number of jobs the job queue may hold. - /// - private int maxNumberOfJobsInQueue; - - /// - /// The maximum total size of jobs the job queue may hold. - /// - private int maxBytesQueueCanHold; - - /// - /// Gives the approximate total size of objects in the queue. - /// - private int currentNumberOfBytesQueueIsHolding; - - /// - /// Tells whether the queue should be bounded on size and no of events. - /// - private bool enableBoundsOnQueue; - - /// - /// Used to pause and resume processing of the queue. By default the manual reset event is - /// set so the queue can continue processing. - /// - private ManualResetEvent queueProcessing; - - /// - /// The background thread which is processing the jobs. Used when disposing to wait - /// for the thread to complete. - /// - private Task backgroundJobProcessor; - - /// - /// Keeps track of if we are disposed. - /// - private bool isDisposed; - - /// - /// Logs to this action any exception when processing jobs. - /// - private Action exceptionLogger; - - #endregion - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - /// Action to handle the processing of the job. - /// Name to used when displaying information about this queue. - /// The max Queue Length. - /// The max Queue Size. - /// The enable Bounds. - /// The exception Logger. - public JobQueue(Action processJob, string displayName, int maxQueueLength, int maxQueueSize, bool enableBounds, Action exceptionLogger) - { - this.processJob = processJob ?? throw new ArgumentNullException(nameof(processJob)); + private readonly Action _processJob; - if (string.IsNullOrWhiteSpace(displayName)) - { - throw new ArgumentException(Resources.CannotBeNullOrEmpty, nameof(displayName)); - } + /// + /// Name used when displaying information or reporting errors about this queue. + /// + private readonly string _displayName; - if (maxQueueLength < 1) - { - throw new ArgumentOutOfRangeException(nameof(maxQueueLength)); - } + /// + /// The queue of jobs. + /// + private readonly Queue> _jobsQueue; - if (maxQueueSize < 1) - { - throw new ArgumentOutOfRangeException(nameof(maxQueueSize)); - } + /// + /// Signaled when a job is added to the queue. Used to wakeup the background thread. + /// + private readonly ManualResetEvent _jobAdded; - this.maxNumberOfJobsInQueue = maxQueueLength; - this.maxBytesQueueCanHold = maxQueueSize; - this.enableBoundsOnQueue = enableBounds; + /// + /// The maximum number of jobs the job queue may hold. + /// + private readonly int _maxNumberOfJobsInQueue; - // Initialize defaults. - this.jobsQueue = new Queue>(); - this.jobAdded = new ManualResetEvent(false); - this.queueProcessing = new ManualResetEvent(true); - this.currentNumberOfBytesQueueIsHolding = 0; - this.isDisposed = false; + /// + /// The maximum total size of jobs the job queue may hold. + /// + private readonly int _maxBytesQueueCanHold; - // Save off the arguments. - this.displayName = displayName; - this.exceptionLogger = exceptionLogger; + /// + /// Gives the approximate total size of objects in the queue. + /// + private int _currentNumberOfBytesQueueIsHolding; - // Setup the background thread to process the jobs. - this.backgroundJobProcessor = new Task(() => this.BackgroundJobProcessor(), TaskCreationOptions.LongRunning); - this.backgroundJobProcessor.Start(); - } + /// + /// Tells whether the queue should be bounded on size and no of events. + /// + private bool _enableBoundsOnQueue; - #endregion + /// + /// Used to pause and resume processing of the queue. By default the manual reset event is + /// set so the queue can continue processing. + /// + private readonly ManualResetEvent _queueProcessing; - #region Methods + /// + /// The background thread which is processing the jobs. Used when disposing to wait + /// for the thread to complete. + /// + private readonly Task _backgroundJobProcessor; - /// - /// Adds a job to the queue. - /// - /// Job to add to the queue. - /// The job Size. - public void QueueJob(T job, int jobSize) - { - this.CheckDisposed(); + /// + /// Keeps track of if we are disposed. + /// + private bool _isDisposed; - Debug.Assert(jobSize >= 0, "Job size should never be negative"); + /// + /// Logs to this action any exception when processing jobs. + /// + private readonly Action _exceptionLogger; - // Add the job and signal that a new job is available. - this.InternalQueueJob(new Job(job, jobSize)); - } + #endregion - /// - /// Pause the processing of queued jobs. - /// - public void Pause() - { - this.CheckDisposed(); + #region Constructor - // Do not allow any jobs to be processed. - this.queueProcessing.Reset(); - } + /// + /// Initializes a new instance of the class. + /// + /// Action to handle the processing of the job. + /// Name to used when displaying information about this queue. + /// The max Queue Length. + /// The max Queue Size. + /// The enable Bounds. + /// The exception Logger. + public JobQueue(Action processJob, string displayName, int maxQueueLength, int maxQueueSize, bool enableBounds, Action exceptionLogger) + { + _processJob = processJob ?? throw new ArgumentNullException(nameof(processJob)); - /// - /// Resume the processing of queued jobs. - /// - public void Resume() + if (string.IsNullOrWhiteSpace(displayName)) { - this.CheckDisposed(); + throw new ArgumentException(Resources.CannotBeNullOrEmpty, nameof(displayName)); + } - // Resume processing of jobs. - this.queueProcessing.Set(); + if (maxQueueLength < 1) + { + throw new ArgumentOutOfRangeException(nameof(maxQueueLength)); } - /// - /// Waits for all current jobs in the queue to be processed and then returns. - /// - public void Flush() + if (maxQueueSize < 1) { - this.CheckDisposed(); + throw new ArgumentOutOfRangeException(nameof(maxQueueSize)); + } - // Create the wait job. - using (var waitEvent = new ManualResetEvent(false)) - { - var waitJob = Job.CreateWaitJob(waitEvent); + _maxNumberOfJobsInQueue = maxQueueLength; + _maxBytesQueueCanHold = maxQueueSize; + _enableBoundsOnQueue = enableBounds; - // Queue the wait job and wait for it to be processed. - this.InternalQueueJob(waitJob); + // Initialize defaults. + _jobsQueue = new Queue>(); + _jobAdded = new ManualResetEvent(false); + _queueProcessing = new ManualResetEvent(true); + _currentNumberOfBytesQueueIsHolding = 0; + _isDisposed = false; - waitEvent.WaitOne(); - } - } + // Save off the arguments. + _displayName = displayName; + _exceptionLogger = exceptionLogger; - /// - /// Waits for all pending jobs to complete and shutdown the background thread. - /// - public void Dispose() - { - if (this.isDisposed) - { - return; - } + // Setup the background thread to process the jobs. + _backgroundJobProcessor = new Task(() => BackgroundJobProcessor(), TaskCreationOptions.LongRunning); + _backgroundJobProcessor.Start(); + } - // If the queue is paused, then throw. - if (!this.queueProcessing.WaitOne(0)) - { - throw new InvalidOperationException( - string.Format(CultureInfo.CurrentUICulture, Resources.QueuePausedDisposeError, this.displayName)); - } + #endregion - this.isDisposed = true; + #region Methods - // Disable bounds on the queue so that any waiting threads can proceed. - lock (this.jobsQueue) - { - this.enableBoundsOnQueue = false; - Monitor.PulseAll(this.jobsQueue); - } + /// + /// Adds a job to the queue. + /// + /// Job to add to the queue. + /// The job Size. + public void QueueJob(T job, int jobSize) + { + CheckDisposed(); - // Flag the queue as being shutdown and wake up the background thread. - this.InternalQueueJob(Job.ShutdownJob); + Debug.Assert(jobSize >= 0, "Job size should never be negative"); - // Wait for the background thread to shutdown. - this.backgroundJobProcessor.Wait(); + // Add the job and signal that a new job is available. + InternalQueueJob(new Job(job, jobSize)); + } - // Cleanup - this.jobAdded.Dispose(); - this.queueProcessing.Dispose(); - } + /// + /// Pause the processing of queued jobs. + /// + public void Pause() + { + CheckDisposed(); + + // Do not allow any jobs to be processed. + _queueProcessing.Reset(); + } + + /// + /// Resume the processing of queued jobs. + /// + public void Resume() + { + CheckDisposed(); + + // Resume processing of jobs. + _queueProcessing.Set(); + } + + /// + /// Waits for all current jobs in the queue to be processed and then returns. + /// + public void Flush() + { + CheckDisposed(); - #endregion + // Create the wait job. + using var waitEvent = new ManualResetEvent(false); + var waitJob = Job.CreateWaitJob(waitEvent); - #region Private Methods + // Queue the wait job and wait for it to be processed. + InternalQueueJob(waitJob); + + waitEvent.WaitOne(); + } - /// - /// Block the queue call. - /// A separate protected virtual method had to be made so that it can be over-ridden when writing unit test to check - /// if bounds on the queue are applied correctly. - /// - /// True if the queue is empty. - protected virtual bool WaitForQueueToGetEmpty() + /// + /// Waits for all pending jobs to complete and shutdown the background thread. + /// + public void Dispose() + { + if (_isDisposed) { - EqtTrace.Verbose("blocking on over filled queue."); - return Monitor.Wait(this.jobsQueue); + return; } - /// - /// Queue the job and signal the background thread. - /// - /// Job to be queued. - private void InternalQueueJob(Job job) + // If the queue is paused, then throw. + if (!_queueProcessing.WaitOne(0)) { - // Add the job and signal that a new job is available. - lock (this.jobsQueue) - { - // If the queue is getting over filled wait till the background processor releases the thread. - while (this.enableBoundsOnQueue - && - ((this.jobsQueue.Count >= this.maxNumberOfJobsInQueue) - || - (this.currentNumberOfBytesQueueIsHolding >= this.maxBytesQueueCanHold))) - { - this.WaitForQueueToGetEmpty(); - } + throw new InvalidOperationException( + string.Format(CultureInfo.CurrentUICulture, Resources.QueuePausedDisposeError, _displayName)); + } - this.jobsQueue.Enqueue(job); - this.currentNumberOfBytesQueueIsHolding += job.Size; - this.jobAdded.Set(); - } + _isDisposed = true; + + // Disable bounds on the queue so that any waiting threads can proceed. + lock (_jobsQueue) + { + _enableBoundsOnQueue = false; + Monitor.PulseAll(_jobsQueue); } - /// - /// Throws wen the queue has been disposed. - /// - private void CheckDisposed() + // Flag the queue as being shutdown and wake up the background thread. + InternalQueueJob(Job.ShutdownJob); + + // Wait for the background thread to shutdown. + _backgroundJobProcessor.Wait(); + + // Cleanup + _jobAdded.Dispose(); + _queueProcessing.Dispose(); + } + + #endregion + + #region Private Methods + + /// + /// Block the queue call. + /// A separate protected virtual method had to be made so that it can be over-ridden when writing unit test to check + /// if bounds on the queue are applied correctly. + /// + /// True if the queue is empty. + protected virtual bool WaitForQueueToGetEmpty() + { + EqtTrace.Verbose("blocking on over filled queue."); + return Monitor.Wait(_jobsQueue); + } + + /// + /// Queue the job and signal the background thread. + /// + /// Job to be queued. + private void InternalQueueJob(Job job) + { + // Add the job and signal that a new job is available. + lock (_jobsQueue) { - if (this.isDisposed) + // If the queue is getting over filled wait till the background processor releases the thread. + while (_enableBoundsOnQueue + && + ((_jobsQueue.Count >= _maxNumberOfJobsInQueue) + || + (_currentNumberOfBytesQueueIsHolding >= _maxBytesQueueCanHold))) { - throw new ObjectDisposedException( - string.Format(CultureInfo.CurrentUICulture, Resources.QueueAlreadyDisposed, this.displayName)); + WaitForQueueToGetEmpty(); } + + _jobsQueue.Enqueue(job); + _currentNumberOfBytesQueueIsHolding += job.Size; + _jobAdded.Set(); } + } - /// - /// Method which processes the jobs on the background thread. - /// - private void BackgroundJobProcessor() + /// + /// Throws wen the queue has been disposed. + /// + private void CheckDisposed() + { + if (_isDisposed) { - bool shutdown = false; - - do - { - this.jobAdded.WaitOne(); - - // Pull all of the current jobs out of the queue. - List> jobs = new List>(); - lock (this.jobsQueue) - { - while (this.jobsQueue.Count != 0) - { - var job = this.jobsQueue.Dequeue(); - this.currentNumberOfBytesQueueIsHolding -= job.Size; + throw new ObjectDisposedException( + string.Format(CultureInfo.CurrentUICulture, Resources.QueueAlreadyDisposed, _displayName)); + } + } - // If this is a shutdown job, signal shutdown and stop adding jobs. - if (job.Shutdown) - { - shutdown = true; - break; - } + /// + /// Method which processes the jobs on the background thread. + /// + private void BackgroundJobProcessor() + { + bool shutdown = false; - jobs.Add(job); - } + do + { + _jobAdded.WaitOne(); - // Reset the manual reset event so we get notified of new jobs that are added. - this.jobAdded.Reset(); + // Pull all of the current jobs out of the queue. + List> jobs = new(); + lock (_jobsQueue) + { + while (_jobsQueue.Count != 0) + { + var job = _jobsQueue.Dequeue(); + _currentNumberOfBytesQueueIsHolding -= job.Size; - // Releases a thread waiting on the queue to get empty, to continue with the enqueuing process. - if (this.enableBoundsOnQueue) + // If this is a shutdown job, signal shutdown and stop adding jobs. + if (job.Shutdown) { - Monitor.PulseAll(this.jobsQueue); + shutdown = true; + break; } + + jobs.Add(job); } - // Process the jobs - foreach (var job in jobs) - { - // Wait for the queue to be open (not paused) and process the job. - this.queueProcessing.WaitOne(); + // Reset the manual reset event so we get notified of new jobs that are added. + _jobAdded.Reset(); - // If this is a wait job, signal the manual reset event and continue. - if (job.WaitManualResetEvent != null) - { - job.WaitManualResetEvent.Set(); - } - else - { - this.SafeProcessJob(job.Payload); - } + // Releases a thread waiting on the queue to get empty, to continue with the enqueuing process. + if (_enableBoundsOnQueue) + { + Monitor.PulseAll(_jobsQueue); } } - while (!shutdown); - } - /// - /// Executes the process job handler and logs any exceptions which occur. - /// - /// Job to be executed. - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "unknown action could throw all kinds of exceptions.")] - private void SafeProcessJob(T job) - { - try + // Process the jobs + foreach (var job in jobs) { - this.processJob(job); - } - catch (Exception e) - { - this.exceptionLogger( - string.Format( - CultureInfo.CurrentUICulture, - Resources.ExceptionFromJobProcessor, - this.displayName, - e)); + // Wait for the queue to be open (not paused) and process the job. + _queueProcessing.WaitOne(); + + // If this is a wait job, signal the manual reset event and continue. + if (job.WaitManualResetEvent != null) + { + job.WaitManualResetEvent.Set(); + } + else + { + SafeProcessJob(job.Payload); + } } } + while (!shutdown); + } - #endregion + /// + /// Executes the process job handler and logs any exceptions which occur. + /// + /// Job to be executed. + private void SafeProcessJob(T job) + { + try + { + _processJob(job); + } + catch (Exception e) + { + _exceptionLogger( + string.Format( + CultureInfo.CurrentUICulture, + Resources.ExceptionFromJobProcessor, + _displayName, + e)); + } } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Utilities/MulticastDelegateUtilities.cs b/src/Microsoft.TestPlatform.CoreUtilities/Utilities/MulticastDelegateUtilities.cs index 5d12e4ae24..758fff56ff 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Utilities/MulticastDelegateUtilities.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Utilities/MulticastDelegateUtilities.cs @@ -1,61 +1,61 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Utilities -{ - using System; - using System.Reflection; +namespace Microsoft.VisualStudio.TestPlatform.Utilities; + +using System; +using System.Reflection; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Resources; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using CoreUtilities.Resources; +using ObjectModel; + +/// +/// Utility methods for MulticastDelegates. +/// +public static class MulticastDelegateUtilities +{ /// - /// Utility methods for MulticastDelegates. + /// Invokes each of the subscribers of the event and handles exceptions which are thrown + /// ensuring that each handler is invoked even if one throws. /// - public static class MulticastDelegateUtilities + /// Event handler to invoke. + /// Sender to use when raising the event. + /// Arguments to provide. + /// Name to use when tracing out errors. + public static void SafeInvoke(this Delegate delegates, object sender, EventArgs args, string traceDisplayName) { - /// - /// Invokes each of the subscribers of the event and handles exceptions which are thrown - /// ensuring that each handler is invoked even if one throws. - /// - /// Event handler to invoke. - /// Sender to use when raising the event. - /// Arguments to provide. - /// Name to use when tracing out errors. - public static void SafeInvoke(this Delegate delegates, object sender, EventArgs args, string traceDisplayName) + if (args == null) { - if (args == null) - { - throw new ArgumentNullException(Resources.CannotBeNullOrEmpty, "args"); - } + throw new ArgumentNullException(Resources.CannotBeNullOrEmpty, "args"); + } - if (string.IsNullOrWhiteSpace(traceDisplayName)) - { - throw new ArgumentException(Resources.CannotBeNullOrEmpty, traceDisplayName); - } + if (string.IsNullOrWhiteSpace(traceDisplayName)) + { + throw new ArgumentException(Resources.CannotBeNullOrEmpty, traceDisplayName); + } - if (delegates != null) + if (delegates != null) + { + foreach (Delegate handler in delegates.GetInvocationList()) { - foreach (Delegate handler in delegates.GetInvocationList()) + try { - try - { - handler.DynamicInvoke(sender, args); - } - catch (TargetInvocationException e) + handler.DynamicInvoke(sender, args); + } + catch (TargetInvocationException e) + { + if (EqtTrace.IsErrorEnabled) { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error( - "{0}: Exception occurred while calling handler of type {1} for {2}: {3}", - traceDisplayName, - handler.Target.GetType().FullName, - args.GetType().Name, - e); - } + EqtTrace.Error( + "{0}: Exception occurred while calling handler of type {1} for {2}: {3}", + traceDisplayName, + handler.Target.GetType().FullName, + args.GetType().Name, + e); } } } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Utilities/TimeSpanParser.cs b/src/Microsoft.TestPlatform.CoreUtilities/Utilities/TimeSpanParser.cs index a85b6d8430..1ef541eb6c 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Utilities/TimeSpanParser.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Utilities/TimeSpanParser.cs @@ -4,80 +4,79 @@ using System; using System.Text.RegularExpressions; -namespace Microsoft.VisualStudio.TestPlatform.Utilities +namespace Microsoft.VisualStudio.TestPlatform.Utilities; + +public static class TimeSpanParser { - public static class TimeSpanParser + static readonly Regex Pattern = new(@"(?^\d+(?:\.\d+)?)\s*(?ms|mil|m|h|d|s?[a-z]*)$", RegexOptions.IgnoreCase); + + public static TimeSpan Parse(string time) { - static readonly Regex pattern = new Regex(@"(?^\d+(?:\.\d+)?)\s*(?ms|mil|m|h|d|s?[a-z]*)$", RegexOptions.IgnoreCase); + return TryParse(time, out var result) ? result : throw GetFormatException(time); + } - public static TimeSpan Parse(string time) + public static bool TryParse(string time, out TimeSpan result) + { + if (string.IsNullOrWhiteSpace(time)) { - return TryParse(time, out var result) ? result : throw GetFormatException(time); + result = TimeSpan.Zero; + return true; } - public static bool TryParse(string time, out TimeSpan result) + var match = Pattern.Match(time); + if (!match.Success) { - if (string.IsNullOrWhiteSpace(time)) - { - result = TimeSpan.Zero; - return true; - } - - var match = pattern.Match(time); - if (!match.Success) - { - result = TimeSpan.Zero; - return false; - } - - var value = match.Groups["value"].Value; - if (!double.TryParse(value, out var number)) - { - throw GetFormatException(value); - } - - var suffix = match.Groups["suffix"].Value; - var c = StringComparison.OrdinalIgnoreCase; + result = TimeSpan.Zero; + return false; + } - // mil to distinguish milliseconds from minutes - // "" when there is just the raw milliseconds value - if (suffix.StartsWith("ms", c) || suffix.StartsWith("mil", c) || suffix == string.Empty) - { - result = TimeSpan.FromMilliseconds(number); - return true; - } + var value = match.Groups["value"].Value; + if (!double.TryParse(value, out var number)) + { + throw GetFormatException(value); + } - if (suffix.StartsWith("s", c)) - { - result = TimeSpan.FromSeconds(number); - return true; - } + var suffix = match.Groups["suffix"].Value; + var c = StringComparison.OrdinalIgnoreCase; - if (suffix.StartsWith("m", c)) - { - result = TimeSpan.FromMinutes(number); - return true; - } + // mil to distinguish milliseconds from minutes + // "" when there is just the raw milliseconds value + if (suffix.StartsWith("ms", c) || suffix.StartsWith("mil", c) || suffix == string.Empty) + { + result = TimeSpan.FromMilliseconds(number); + return true; + } - if (suffix.StartsWith("h", c)) - { - result = TimeSpan.FromHours(number); - return true; - } + if (suffix.StartsWith("s", c)) + { + result = TimeSpan.FromSeconds(number); + return true; + } - if (suffix.StartsWith("d", c)) - { - result = TimeSpan.FromDays(number); - return true; - } + if (suffix.StartsWith("m", c)) + { + result = TimeSpan.FromMinutes(number); + return true; + } - result = TimeSpan.Zero; - return false; + if (suffix.StartsWith("h", c)) + { + result = TimeSpan.FromHours(number); + return true; } - static FormatException GetFormatException(string value) + if (suffix.StartsWith("d", c)) { - return new FormatException($"The value '{value}' is not a valid time string. Use a time string in this format 5400000 / 5400000ms / 5400s / 90m / 1.5h / 0.625d."); + result = TimeSpan.FromDays(number); + return true; } + + result = TimeSpan.Zero; + return false; + } + + static FormatException GetFormatException(string value) + { + return new FormatException($"The value '{value}' is not a valid time string. Use a time string in this format 5400000 / 5400000ms / 5400s / 90m / 1.5h / 0.625d."); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CoreUtilities/ValidateArg.cs b/src/Microsoft.TestPlatform.CoreUtilities/ValidateArg.cs index 160fb478b1..7f121ddc0d 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/ValidateArg.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/ValidateArg.cs @@ -1,258 +1,235 @@ + // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -#pragma warning disable SA1402 // FileMayOnlyContainASingleClass. This is a ported class from ObjectModel. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Globalization; - using System.Linq; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Resources; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using CoreUtilities.Resources; + +/// +/// Helper to validate parameters. +/// +public static class ValidateArg +{ /// - /// Helper to validate parameters. + /// Throws ArgumentNullException if the argument is null, otherwise passes it through. /// - public static class ValidateArg + /// + /// Type to validate. + /// + /// + /// The argument to check. + /// + /// + /// The parameter name of the argument. + /// + /// + /// Type of argument. + /// + [DebuggerStepThrough] + public static T NotNull([ValidatedNotNull] T arg, string parameterName) + where T : class { - /// - /// Throws ArgumentNullException if the argument is null, otherwise passes it through. - /// - /// - /// Type to validate. - /// - /// - /// The argument to check. - /// - /// - /// The parameter name of the argument. - /// - /// - /// Type of argument. - /// - [DebuggerStepThrough] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "This is shared source. This method may not be called in the current assembly.")] - public static T NotNull([ValidatedNotNull]T arg, string parameterName) - where T : class - { - if (arg == null) - { - throw new ArgumentNullException(parameterName); - } - - return arg; - } + return arg ?? throw new ArgumentNullException(parameterName); + } - /// - /// Validate a string is not null or empty. - /// - /// - /// Input string. - /// - /// - /// Name of the parameter to validate. - /// - /// - /// Validated string. - /// - /// - /// Thrown if the input string is null or empty. - /// - [DebuggerStepThrough] - public static string NotNullOrEmpty([ValidatedNotNull]string arg, string parameterName) - { - if (string.IsNullOrEmpty(arg)) - { - throw new ArgumentNullException(parameterName); - } + /// + /// Validate a string is not null or empty. + /// + /// + /// Input string. + /// + /// + /// Name of the parameter to validate. + /// + /// + /// Validated string. + /// + /// + /// Thrown if the input string is null or empty. + /// + [DebuggerStepThrough] + public static string NotNullOrEmpty([ValidatedNotNull] string arg, string parameterName) + { + return string.IsNullOrEmpty(arg) ? throw new ArgumentNullException(parameterName) : arg; + } - return arg; - } + /// + /// Validate a string is not null, empty or consists only of white-space characters. + /// + /// + /// Input string. + /// + /// + /// Name of the parameter to validate. + /// + /// + /// Validated string. + /// + /// + /// Thrown if the input string is null, empty or consists only of white-space characters. + /// + [DebuggerStepThrough] + public static string NotNullOrWhiteSpace([ValidatedNotNull] string arg, string parameterName) + { + return string.IsNullOrWhiteSpace(arg) ? throw new ArgumentNullException(parameterName) : arg; + } - /// - /// Validate a string is not null, empty or consists only of white-space characters. - /// - /// - /// Input string. - /// - /// - /// Name of the parameter to validate. - /// - /// - /// Validated string. - /// - /// - /// Thrown if the input string is null, empty or consists only of white-space characters. - /// - [DebuggerStepThrough] - public static string NotNullOrWhiteSpace([ValidatedNotNull]string arg, string parameterName) + /// + /// Throws ArgumentOutOfRangeException if the argument is less than zero. + /// + /// The argument to check. + /// The parameter name of the argument. + [DebuggerStepThrough] + public static void NotNegative(int arg, string parameterName) + { + if (arg < 0) { - if (string.IsNullOrWhiteSpace(arg)) - { - throw new ArgumentNullException(parameterName); - } - - return arg; + var message = string.Format(CultureInfo.CurrentCulture, Resources.Error_ArgumentIsNegative); + throw new ArgumentOutOfRangeException(parameterName, arg, message); } + } - /// - /// Throws ArgumentOutOfRangeException if the argument is less than zero. - /// - /// The argument to check. - /// The parameter name of the argument. - [DebuggerStepThrough] - public static void NotNegative(int arg, string parameterName) + /// + /// Throws ArgumentOutOfRangeException if the argument is less than zero. + /// + /// The argument to check. + /// The parameter name of the argument. + [DebuggerStepThrough] + public static void NotNegative(long arg, string parameterName) + { + if (arg < 0) { - if (arg < 0) - { - var message = string.Format(CultureInfo.CurrentCulture, Resources.Error_ArgumentIsNegative); - throw new ArgumentOutOfRangeException(parameterName, arg, message); - } + var message = string.Format(CultureInfo.CurrentCulture, Resources.Error_ArgumentIsNegative); + throw new ArgumentOutOfRangeException(parameterName, arg, message); } + } - /// - /// Throws ArgumentOutOfRangeException if the argument is less than zero. - /// - /// The argument to check. - /// The parameter name of the argument. - [DebuggerStepThrough] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "This is shared source. This method may not be called in the current assembly.")] - public static void NotNegative(long arg, string parameterName) - { - if (arg < 0) - { - var message = string.Format(CultureInfo.CurrentCulture, Resources.Error_ArgumentIsNegative); - throw new ArgumentOutOfRangeException(parameterName, arg, message); - } - } + /// + /// Throws ArgumentNullException if the string is null, ArgumentException if the string is empty. + /// + /// Type of parameter to validate. + /// The argument to check. + /// The parameter name of the argument. + [DebuggerStepThrough] + public static void NotNullOrEmpty([ValidatedNotNull] IEnumerable arg, string parameterName) + { + NotNull(arg, parameterName); - /// - /// Throws ArgumentNullException if the string is null, ArgumentException if the string is empty. - /// - /// Type of parameter to validate. - /// The argument to check. - /// The parameter name of the argument. - [DebuggerStepThrough] - public static void NotNullOrEmpty([ValidatedNotNull]IEnumerable arg, string parameterName) + if (!arg.Any()) { - NotNull(arg, parameterName); - - if (!arg.Any()) - { - var message = string.Format(CultureInfo.CurrentCulture, Resources.Error_ArgumentIsEmpty); - throw new ArgumentException(message, parameterName); - } + var message = string.Format(CultureInfo.CurrentCulture, Resources.Error_ArgumentIsEmpty); + throw new ArgumentException(message, parameterName); } + } - /// - /// Throws ArgumentNullException if the argument is null, ArgumentException if the argument is not the correct type. - /// - /// The argument to check. - /// The parameter name of the argument. - /// The type of the expected argument. - [DebuggerStepThrough] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "This is shared source. This method may not be called in the current assembly.")] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "This is shared source. This method may not be called in the current assembly.")] - public static void TypeOf([ValidatedNotNull]object arg, string parameterName) - where T : class - { - NotNull(arg, parameterName); + /// + /// Throws ArgumentNullException if the argument is null, ArgumentException if the argument is not the correct type. + /// + /// The argument to check. + /// The parameter name of the argument. + /// The type of the expected argument. + [DebuggerStepThrough] + public static void TypeOf([ValidatedNotNull] object arg, string parameterName) + where T : class + { + NotNull(arg, parameterName); - if (!(arg is T)) - { - var message = string.Format(CultureInfo.CurrentCulture, Resources.Error_ArgumentNotTypeOf, typeof(T).FullName); - throw new ArgumentException(message, parameterName); - } + if (!(arg is T)) + { + var message = string.Format(CultureInfo.CurrentCulture, Resources.Error_ArgumentNotTypeOf, typeof(T).FullName); + throw new ArgumentException(message, parameterName); } } +} +/// +/// Helper to validate parameter properties. +/// +public static class ValidateArgProperty +{ /// - /// Helper to validate parameter properties. + /// Throws ArgumentException if the argument is null. /// - public static class ValidateArgProperty + /// The argument to check (e.g. Param1.PropertyA). + /// The parameter name of the argument. + /// The property name of the argument. + [DebuggerStepThrough] + public static void NotNull([ValidatedNotNull] object arg, string parameterName, string propertyName) { - /// - /// Throws ArgumentException if the argument is null. - /// - /// The argument to check (e.g. Param1.PropertyA). - /// The parameter name of the argument. - /// The property name of the argument. - [DebuggerStepThrough] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "This is shared source. This method may not be called in the current assembly.")] - public static void NotNull([ValidatedNotNull]object arg, string parameterName, string propertyName) + if (arg == null) { - if (arg == null) - { - var message = string.Format(CultureInfo.CurrentCulture, Resources.Error_ArgumentPropertyIsNull, propertyName); - throw new ArgumentNullException(parameterName, message); - } + var message = string.Format(CultureInfo.CurrentCulture, Resources.Error_ArgumentPropertyIsNull, propertyName); + throw new ArgumentNullException(parameterName, message); } + } - /// - /// Throws ArgumentException if the argument is less than zero. - /// - /// The argument to check (e.g. Param1.PropertyA). - /// The parameter name of the argument. - /// The property name of the argument. - [DebuggerStepThrough] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "This is shared source. This method may not be called in the current assembly.")] - public static void NotNegative(int arg, string parameterName, string propertyName) + /// + /// Throws ArgumentException if the argument is less than zero. + /// + /// The argument to check (e.g. Param1.PropertyA). + /// The parameter name of the argument. + /// The property name of the argument. + [DebuggerStepThrough] + public static void NotNegative(int arg, string parameterName, string propertyName) + { + if (arg < 0) { - if (arg < 0) - { - var message = string.Format(CultureInfo.CurrentCulture, Resources.Error_ArgumentPropertyIsNegative, propertyName); - throw new ArgumentException(message, parameterName); - } + var message = string.Format(CultureInfo.CurrentCulture, Resources.Error_ArgumentPropertyIsNegative, propertyName); + throw new ArgumentException(message, parameterName); } + } - /// - /// Throws ArgumentException if the argument string is null or empty. - /// - /// The argument to check (e.g. Param1.PropertyA). - /// The parameter name of the argument. - /// The property name of the argument. - [DebuggerStepThrough] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "This is shared source. This method may not be called in the current assembly.")] - public static void NotNullOrEmpty([ValidatedNotNull]string arg, string parameterName, string propertyName) - { - NotNull(arg, parameterName, propertyName); - - if (string.IsNullOrEmpty(arg)) - { - var message = string.Format(CultureInfo.CurrentCulture, Resources.Error_ArgumentPropertyIsEmpty, propertyName); - throw new ArgumentException(message, parameterName); - } - } + /// + /// Throws ArgumentException if the argument string is null or empty. + /// + /// The argument to check (e.g. Param1.PropertyA). + /// The parameter name of the argument. + /// The property name of the argument. + [DebuggerStepThrough] + public static void NotNullOrEmpty([ValidatedNotNull] string arg, string parameterName, string propertyName) + { + NotNull(arg, parameterName, propertyName); - /// - /// Throws ArgumentException if the argument is null or is not the correct type. - /// - /// The argument to check (e.g. Param1.PropertyA). - /// The parameter name of the argument. - /// The property name of the argument. - /// The type of the expected argument. - [DebuggerStepThrough] - public static void TypeOf([ValidatedNotNull]object arg, string parameterName, string propertyName) - where T : class + if (string.IsNullOrEmpty(arg)) { - NotNull(arg, parameterName, propertyName); - - if (!(arg is T)) - { - var message = string.Format(CultureInfo.CurrentCulture, Resources.Error_ArgumentPropertyNotTypeOf, propertyName, typeof(T).FullName); - throw new ArgumentException(message, parameterName); - } + var message = string.Format(CultureInfo.CurrentCulture, Resources.Error_ArgumentPropertyIsEmpty, propertyName); + throw new ArgumentException(message, parameterName); } } /// - /// Secret attribute that tells the CA1062 validate arguments rule that this method validates the argument is not null. + /// Throws ArgumentException if the argument is null or is not the correct type. /// - [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class ValidatedNotNullAttribute : Attribute + /// The argument to check (e.g. Param1.PropertyA). + /// The parameter name of the argument. + /// The property name of the argument. + /// The type of the expected argument. + [DebuggerStepThrough] + public static void TypeOf([ValidatedNotNull] object arg, string parameterName, string propertyName) + where T : class { + NotNull(arg, parameterName, propertyName); + + if (!(arg is T)) + { + var message = string.Format(CultureInfo.CurrentCulture, Resources.Error_ArgumentPropertyNotTypeOf, propertyName, typeof(T).FullName); + throw new ArgumentException(message, parameterName); + } } +} + +/// +/// Secret attribute that tells the CA1062 validate arguments rule that this method validates the argument is not null. +/// +[AttributeUsage(AttributeTargets.Parameter)] +internal sealed class ValidatedNotNullAttribute : Attribute +{ } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Adapter/FrameworkHandle.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Adapter/FrameworkHandle.cs index ca8ba14780..82daf63533 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Adapter/FrameworkHandle.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Adapter/FrameworkHandle.cs @@ -1,139 +1,122 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter; + +using System; +using System.Collections.Generic; + +using Execution; + +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; +using ObjectModel.Engine.ClientProtocol; + +using CrossPlatEngineResources = Resources.Resources; + +/// +/// Handle to the framework which is passed to the test executors. +/// +internal class FrameworkHandle : TestExecutionRecorder, IFrameworkHandle2, IDisposable { - using System; - using System.Collections.Generic; - using System.Globalization; - using Execution; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; + /// + /// Context in which the current run is executing. + /// + private readonly TestExecutionContext _testExecutionContext; + + /// + /// DebugLauncher for launching additional adapter processes under debugger + /// + private readonly ITestRunEventsHandler _testRunEventsHandler; - using CrossPlatEngineResources = Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources.Resources; + /// + /// Specifies whether the handle is disposed or not + /// + private bool _isDisposed; /// - /// Handle to the framework which is passed to the test executors. + /// Initializes a new instance of the class. /// - internal class FrameworkHandle : TestExecutionRecorder, IFrameworkHandle2, IDisposable + /// The test case level events handler. + /// The test run cache. + /// The test execution context. + /// TestRun Events Handler + public FrameworkHandle(ITestCaseEventsHandler testCaseEventsHandler, ITestRunCache testRunCache, + TestExecutionContext testExecutionContext, ITestRunEventsHandler testRunEventsHandler) + : base(testCaseEventsHandler, testRunCache) { - /// - /// boolean that gives the value of EnableShutdownAfterTestRun. - /// Default value is set to false in the constructor. - /// - private bool enableShutdownAfterTestRun; - - /// - /// Context in which the current run is executing. - /// - private TestExecutionContext testExecutionContext; - - /// - /// DebugLauncher for launching additional adapter processes under debugger - /// - private ITestRunEventsHandler testRunEventsHandler; - - /// - /// Specifies whether the handle is disposed or not - /// - private bool isDisposed; - - /// - /// Initializes a new instance of the class. - /// - /// The test case level events handler. - /// The test run cache. - /// The test execution context. - /// TestRun Events Handler - public FrameworkHandle(ITestCaseEventsHandler testCaseEventsHandler, ITestRunCache testRunCache, - TestExecutionContext testExecutionContext, ITestRunEventsHandler testRunEventsHandler) - : base(testCaseEventsHandler, testRunCache) - { - this.testExecutionContext = testExecutionContext; - this.testRunEventsHandler = testRunEventsHandler; - } + _testExecutionContext = testExecutionContext; + _testRunEventsHandler = testRunEventsHandler; + } - /// - /// Give a hint to the execution framework to enable the shutdown of execution process after the test run is complete. This should be used only in out of process test runs when IRunContext.KeepAlive is true - /// and should be used only when absolutely required as using it degrades the performance of the subsequent run. - /// It throws InvalidOperationException when it is attempted to be enabled when keepAlive is false. - /// - public bool EnableShutdownAfterTestRun - { - get - { - return this.enableShutdownAfterTestRun; - } - - set - { - this.enableShutdownAfterTestRun = value; - } - } + /// + /// Give a hint to the execution framework to enable the shutdown of execution process after the test run is complete. This should be used only in out of process test runs when IRunContext.KeepAlive is true + /// and should be used only when absolutely required as using it degrades the performance of the subsequent run. + /// It throws InvalidOperationException when it is attempted to be enabled when keepAlive is false. + /// + public bool EnableShutdownAfterTestRun { get; set; } - /// - /// Launch the specified process with the debugger attached. - /// - /// File path to the exe to launch. - /// Working directory that process should use. - /// Command line arguments the process should be launched with. - /// Environment variables to be set in target process - /// Process ID of the started process. - public int LaunchProcessWithDebuggerAttached(string filePath, string workingDirectory, string arguments, IDictionary environmentVariables) + /// + /// Launch the specified process with the debugger attached. + /// + /// File path to the exe to launch. + /// Working directory that process should use. + /// Command line arguments the process should be launched with. + /// Environment variables to be set in target process + /// Process ID of the started process. + public int LaunchProcessWithDebuggerAttached(string filePath, string workingDirectory, string arguments, IDictionary environmentVariables) + { + // If an adapter attempts to launch a process after the run is complete (=> this object is disposed) + // throw an error. + if (_isDisposed) { - // If an adapter attempts to launch a process after the run is complete (=> this object is disposed) - // throw an error. - if (this.isDisposed) - { - throw new ObjectDisposedException("IFrameworkHandle"); - } - - // If it is not a debug run, then throw an error - if (!this.testExecutionContext.IsDebug) - { - throw new InvalidOperationException(CrossPlatEngineResources.LaunchDebugProcessNotAllowedForANonDebugRun); - } - - var processInfo = new TestProcessStartInfo() - { - Arguments = arguments, - EnvironmentVariables = environmentVariables, - FileName = filePath, - WorkingDirectory = workingDirectory - }; - - return this.testRunEventsHandler.LaunchProcessWithDebuggerAttached(processInfo); + throw new ObjectDisposedException("IFrameworkHandle"); } - /// - public bool AttachDebuggerToProcess(int pid) + // If it is not a debug run, then throw an error + if (!_testExecutionContext.IsDebug) { - return ((ITestRunEventsHandler2)this.testRunEventsHandler).AttachDebuggerToProcess(pid); + throw new InvalidOperationException(CrossPlatEngineResources.LaunchDebugProcessNotAllowedForANonDebugRun); } - public void Dispose() + var processInfo = new TestProcessStartInfo() { - this.Dispose(true); + Arguments = arguments, + EnvironmentVariables = environmentVariables, + FileName = filePath, + WorkingDirectory = workingDirectory + }; - // Use SupressFinalize in case a subclass - // of this valueType implements a finalizer. - GC.SuppressFinalize(this); - } + return _testRunEventsHandler.LaunchProcessWithDebuggerAttached(processInfo); + } - protected virtual void Dispose(bool disposing) + /// + public bool AttachDebuggerToProcess(int pid) + { + return ((ITestRunEventsHandler2)_testRunEventsHandler).AttachDebuggerToProcess(pid); + } + + public void Dispose() + { + Dispose(true); + + // Use SupressFinalize in case a subclass + // of this valueType implements a finalizer. + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + // If you need thread safety, use a lock around these + // operations, as well as in your methods that use the resource. + if (!_isDisposed) { - // If you need thread safety, use a lock around these - // operations, as well as in your methods that use the resource. - if (!this.isDisposed) - { - // Indicate that the instance has been disposed. - this.isDisposed = true; - } + // Indicate that the instance has been disposed. + _isDisposed = true; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Adapter/RunContext.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Adapter/RunContext.cs index c2233ded9b..867178983b 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Adapter/RunContext.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Adapter/RunContext.cs @@ -1,44 +1,44 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter; + +using Discovery; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + +/// +/// Provides user specified runSettings and framework provided context of the run. +/// +public class RunContext : DiscoveryContext, IRunContext { - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + /// + /// Gets a value indicating whether the execution process should be kept alive after the run is finished. + /// + public bool KeepAlive { get; internal set; } + + /// + /// Gets a value indicating whether the discovery or execution is happening in-process or out-of-process. + /// + public bool InIsolation { get; internal set; } + + /// + /// Gets a value indicating whether data collection is enabled. + /// + public bool IsDataCollectionEnabled { get; internal set; } + + /// + /// Gets a value indicating whether the test is being debugged. + /// + public bool IsBeingDebugged { get; internal set; } + + /// + /// Gets the directory which should be used for storing result files/deployment files etc. + /// + public string TestRunDirectory { get; internal set; } /// - /// Provides user specified runSettings and framework provided context of the run. + /// Gets the directory for Solution. /// - public class RunContext : DiscoveryContext, IRunContext - { - /// - /// Gets a value indicating whether the execution process should be kept alive after the run is finished. - /// - public bool KeepAlive { get; internal set; } - - /// - /// Gets a value indicating whether the discovery or execution is happening in-process or out-of-process. - /// - public bool InIsolation { get; internal set; } - - /// - /// Gets a value indicating whether data collection is enabled. - /// - public bool IsDataCollectionEnabled { get; internal set; } - - /// - /// Gets a value indicating whether the test is being debugged. - /// - public bool IsBeingDebugged { get; internal set; } - - /// - /// Gets the directory which should be used for storing result files/deployment files etc. - /// - public string TestRunDirectory { get; internal set; } - - /// - /// Gets the directory for Solution. - /// - public string SolutionDirectory { get; internal set; } - } -} + public string SolutionDirectory { get; internal set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Adapter/TestExecutionRecorder.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Adapter/TestExecutionRecorder.cs index b347b020a5..3c96a7aef7 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Adapter/TestExecutionRecorder.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Adapter/TestExecutionRecorder.cs @@ -1,154 +1,153 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter; + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +using Common.Logging; +using Execution; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using ObjectModel.Engine; + +/// +/// The test execution recorder used for recording test results and test messages. +/// +internal class TestExecutionRecorder : TestSessionMessageLogger, ITestExecutionRecorder { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; + private readonly List _attachmentSets; + private readonly ITestRunCache _testRunCache; + private readonly ITestCaseEventsHandler _testCaseEventsHandler; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + /// + /// Contains TestCase Ids for test cases that are in progress + /// Start has been recorded but End has not yet been recorded. + /// + private readonly HashSet _testCaseInProgressMap; + + private readonly object _testCaseInProgressSyncObject = new(); /// - /// The test execution recorder used for recording test results and test messages. + /// Initializes a new instance of the class. /// - internal class TestExecutionRecorder : TestSessionMessageLogger, ITestExecutionRecorder + /// The test Case Events Handler. + /// The test run cache. + public TestExecutionRecorder(ITestCaseEventsHandler testCaseEventsHandler, ITestRunCache testRunCache) { - private List attachmentSets; - private ITestRunCache testRunCache; - private ITestCaseEventsHandler testCaseEventsHandler; - - /// - /// Contains TestCase Ids for test cases that are in progress - /// Start has been recorded but End has not yet been recorded. - /// - private HashSet testCaseInProgressMap; - - private object testCaseInProgressSyncObject = new object(); - - /// - /// Initializes a new instance of the class. - /// - /// The test Case Events Handler. - /// The test run cache. - public TestExecutionRecorder(ITestCaseEventsHandler testCaseEventsHandler, ITestRunCache testRunCache) - { - this.testRunCache = testRunCache; - this.testCaseEventsHandler = testCaseEventsHandler; - this.attachmentSets = new List(); - - // As a framework guideline, we should get events in this order: - // 1. Test Case Start. - // 2. Test Case End. - // 3. Test Case Result. - // If that is not that case. - // If Test Adapters don't send the events in the above order, Test Case Results are cached till the Test Case End event is received. - this.testCaseInProgressMap = new HashSet(); - } + _testRunCache = testRunCache; + _testCaseEventsHandler = testCaseEventsHandler; + _attachmentSets = new List(); + + // As a framework guideline, we should get events in this order: + // 1. Test Case Start. + // 2. Test Case End. + // 3. Test Case Result. + // If that is not that case. + // If Test Adapters don't send the events in the above order, Test Case Results are cached till the Test Case End event is received. + _testCaseInProgressMap = new HashSet(); + } - /// - /// Gets the attachments received from adapters. - /// - internal Collection Attachments + /// + /// Gets the attachments received from adapters. + /// + internal Collection Attachments + { + get { - get - { - return new Collection(this.attachmentSets); - } + return new Collection(_attachmentSets); } + } - /// - /// Notify the framework about starting of the test case. - /// Framework sends this event to data collectors enabled in the run. If no data collector is enabled, then the event is ignored. - /// - /// test case which will be started. - public void RecordStart(TestCase testCase) - { - EqtTrace.Verbose("TestExecutionRecorder.RecordStart: Starting test: {0}.", testCase?.FullyQualifiedName); - this.testRunCache.OnTestStarted(testCase); + /// + /// Notify the framework about starting of the test case. + /// Framework sends this event to data collectors enabled in the run. If no data collector is enabled, then the event is ignored. + /// + /// test case which will be started. + public void RecordStart(TestCase testCase) + { + EqtTrace.Verbose("TestExecutionRecorder.RecordStart: Starting test: {0}.", testCase?.FullyQualifiedName); + _testRunCache.OnTestStarted(testCase); - if (this.testCaseEventsHandler != null) + if (_testCaseEventsHandler != null) + { + lock (_testCaseInProgressSyncObject) { - lock (this.testCaseInProgressSyncObject) + // Do not send TestCaseStart for a test in progress + if (!_testCaseInProgressMap.Contains(testCase.Id)) { - // Do not send TestCaseStart for a test in progress - if (!this.testCaseInProgressMap.Contains(testCase.Id)) - { - this.testCaseInProgressMap.Add(testCase.Id); - this.testCaseEventsHandler.SendTestCaseStart(testCase); - } + _testCaseInProgressMap.Add(testCase.Id); + _testCaseEventsHandler.SendTestCaseStart(testCase); } } } + } - /// - /// Notify the framework about the test result. - /// - /// Test Result to be sent to the framework. - /// Exception thrown by the framework when an executor attempts to send - /// test result to the framework when the test(s) is canceled. - public void RecordResult(TestResult testResult) + /// + /// Notify the framework about the test result. + /// + /// Test Result to be sent to the framework. + /// Exception thrown by the framework when an executor attempts to send + /// test result to the framework when the test(s) is canceled. + public void RecordResult(TestResult testResult) + { + EqtTrace.Verbose("TestExecutionRecorder.RecordResult: Received result for test: {0}.", testResult?.TestCase?.FullyQualifiedName); + if (_testCaseEventsHandler != null) { - EqtTrace.Verbose("TestExecutionRecorder.RecordResult: Received result for test: {0}.", testResult?.TestCase?.FullyQualifiedName); - if (this.testCaseEventsHandler != null) - { - // Send TestCaseEnd in case RecordEnd was not called. - this.SendTestCaseEnd(testResult.TestCase, testResult.Outcome); - this.testCaseEventsHandler.SendTestResult(testResult); - } - - // Test Result should always be flushed, even if datacollecter attachment is missing - this.testRunCache.OnNewTestResult(testResult); + // Send TestCaseEnd in case RecordEnd was not called. + SendTestCaseEnd(testResult.TestCase, testResult.Outcome); + _testCaseEventsHandler.SendTestResult(testResult); } - /// - /// Notify the framework about completion of the test case. - /// Framework sends this event to data collectors enabled in the run. If no data collector is enabled, then the event is ignored. - /// - /// test case which has completed. - /// outcome of the test case. - public void RecordEnd(TestCase testCase, TestOutcome outcome) - { - EqtTrace.Verbose("TestExecutionRecorder.RecordEnd: test: {0} execution completed.", testCase?.FullyQualifiedName); - this.testRunCache.OnTestCompletion(testCase); - this.SendTestCaseEnd(testCase, outcome); - } + // Test Result should always be flushed, even if datacollecter attachment is missing + _testRunCache.OnNewTestResult(testResult); + } + + /// + /// Notify the framework about completion of the test case. + /// Framework sends this event to data collectors enabled in the run. If no data collector is enabled, then the event is ignored. + /// + /// test case which has completed. + /// outcome of the test case. + public void RecordEnd(TestCase testCase, TestOutcome outcome) + { + EqtTrace.Verbose("TestExecutionRecorder.RecordEnd: test: {0} execution completed.", testCase?.FullyQualifiedName); + _testRunCache.OnTestCompletion(testCase); + SendTestCaseEnd(testCase, outcome); + } - /// - /// Send TestCaseEnd event for given testCase if not sent already - /// - /// - /// - private void SendTestCaseEnd(TestCase testCase, TestOutcome outcome) + /// + /// Send TestCaseEnd event for given testCase if not sent already + /// + /// + /// + private void SendTestCaseEnd(TestCase testCase, TestOutcome outcome) + { + if (_testCaseEventsHandler != null) { - if (this.testCaseEventsHandler != null) + lock (_testCaseInProgressSyncObject) { - lock (this.testCaseInProgressSyncObject) + // TestCaseEnd must always be preceded by TestCaseStart for a given test case id + if (_testCaseInProgressMap.Contains(testCase.Id)) { - // TestCaseEnd must always be preceded by TestCaseStart for a given test case id - if (this.testCaseInProgressMap.Contains(testCase.Id)) - { - // Send test case end event to handler. - this.testCaseEventsHandler.SendTestCaseEnd(testCase, outcome); - - // Remove it from map so that we send only one TestCaseEnd for every TestCaseStart. - this.testCaseInProgressMap.Remove(testCase.Id); - } + // Send test case end event to handler. + _testCaseEventsHandler.SendTestCaseEnd(testCase, outcome); + + // Remove it from map so that we send only one TestCaseEnd for every TestCaseStart. + _testCaseInProgressMap.Remove(testCase.Id); } } } + } - /// - /// Notify the framework about run level attachments. - /// - /// The attachment sets. - public void RecordAttachments(IList attachments) - { - this.attachmentSets.AddRange(attachments); - } + /// + /// Notify the framework about run level attachments. + /// + /// The attachment sets. + public void RecordAttachments(IList attachments) + { + _attachmentSets.AddRange(attachments); } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/DataCollectorAttachmentsProcessorsFactory.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/DataCollectorAttachmentsProcessorsFactory.cs index 5628b3540e..b478af3a5c 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/DataCollectorAttachmentsProcessorsFactory.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/DataCollectorAttachmentsProcessorsFactory.cs @@ -5,6 +5,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; + using Microsoft.VisualStudio.TestPlatform.Common.DataCollector; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; using Microsoft.VisualStudio.TestPlatform.Common.Logging; @@ -14,81 +15,80 @@ using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; using Microsoft.VisualStudio.TestPlatform.Utilities; -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.TestRunAttachmentsProcessing +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.TestRunAttachmentsProcessing; + +internal class DataCollectorAttachmentsProcessorsFactory : IDataCollectorAttachmentsProcessorsFactory { - internal class DataCollectorAttachmentsProcessorsFactory : IDataCollectorAttachmentsProcessorsFactory + private const string CoverageFriendlyName = "Code Coverage"; + private static readonly ConcurrentDictionary DataCollectorExtensionManagerCache = new(); + + public DataCollectorAttachmentProcessor[] Create(InvokedDataCollector[] invokedDataCollectors, IMessageLogger logger) { - private const string CoverageFriendlyName = "Code Coverage"; - private static readonly ConcurrentDictionary dataCollectorExtensionManagerCache = new ConcurrentDictionary(); + IDictionary> datacollectorsAttachmentsProcessors = new Dictionary>(); - public DataCollectorAttachmentProcessor[] Create(InvokedDataCollector[] invokedDataCollectors, IMessageLogger logger) + if (invokedDataCollectors?.Length > 0) { - IDictionary> datacollectorsAttachmentsProcessors = new Dictionary>(); - - if (invokedDataCollectors?.Length > 0) + // We order files by filename descending so in case of the same collector from the same nuget but with different versions, we'll run the newer version. + // i.e. C:\Users\xxx\.nuget\packages\coverlet.collector + // /3.0.2 + // /3.0.3 + // /3.1.0 + foreach (var invokedDataCollector in invokedDataCollectors.OrderByDescending(d => d.FilePath)) { - // We order files by filename descending so in case of the same collector from the same nuget but with different versions, we'll run the newer version. - // i.e. C:\Users\xxx\.nuget\packages\coverlet.collector - // /3.0.2 - // /3.0.3 - // /3.1.0 - foreach (var invokedDataCollector in invokedDataCollectors.OrderByDescending(d => d.FilePath)) + // We'll merge using only one AQN in case of more "same processors" in different assembly. + if (!invokedDataCollector.HasAttachmentProcessor) { - // We'll merge using only one AQN in case of more "same processors" in different assembly. - if (!invokedDataCollector.HasAttachmentProcessor) - { - continue; - } + continue; + } - EqtTrace.Info($"DataCollectorAttachmentsProcessorsFactory: Analyzing data collector attachment processor Uri: {invokedDataCollector.Uri} AssemblyQualifiedName: {invokedDataCollector.AssemblyQualifiedName} FilePath: {invokedDataCollector.FilePath} HasAttachmentProcessor: {invokedDataCollector.HasAttachmentProcessor}"); + EqtTrace.Info($"DataCollectorAttachmentsProcessorsFactory: Analyzing data collector attachment processor Uri: {invokedDataCollector.Uri} AssemblyQualifiedName: {invokedDataCollector.AssemblyQualifiedName} FilePath: {invokedDataCollector.FilePath} HasAttachmentProcessor: {invokedDataCollector.HasAttachmentProcessor}"); - // We cache extension locally by file path - var dataCollectorExtensionManager = dataCollectorExtensionManagerCache.GetOrAdd(invokedDataCollector.FilePath, DataCollectorExtensionManager.Create(invokedDataCollector.FilePath, true, TestSessionMessageLogger.Instance)); - var dataCollectorExtension = dataCollectorExtensionManager.TryGetTestExtension(invokedDataCollector.Uri); - if (dataCollectorExtension?.Metadata.HasAttachmentProcessor == true) + // We cache extension locally by file path + var dataCollectorExtensionManager = DataCollectorExtensionManagerCache.GetOrAdd(invokedDataCollector.FilePath, DataCollectorExtensionManager.Create(invokedDataCollector.FilePath, true, TestSessionMessageLogger.Instance)); + var dataCollectorExtension = dataCollectorExtensionManager.TryGetTestExtension(invokedDataCollector.Uri); + if (dataCollectorExtension?.Metadata.HasAttachmentProcessor == true) + { + Type attachmentProcessorType = ((DataCollectorConfig)dataCollectorExtension.TestPluginInfo).AttachmentsProcessorType; + IDataCollectorAttachmentProcessor dataCollectorAttachmentProcessorInstance = null; + try { - Type attachmentProcessorType = ((DataCollectorConfig)dataCollectorExtension.TestPluginInfo).AttachmentsProcessorType; - IDataCollectorAttachmentProcessor dataCollectorAttachmentProcessorInstance = null; - try - { - dataCollectorAttachmentProcessorInstance = TestPluginManager.CreateTestExtension(attachmentProcessorType); - EqtTrace.Info($"DataCollectorAttachmentsProcessorsFactory: Creation of collector attachment processor '{attachmentProcessorType.AssemblyQualifiedName}' from file '{invokedDataCollector.FilePath}' succeded"); - } - catch (Exception ex) - { - EqtTrace.Error($"DataCollectorAttachmentsProcessorsFactory: Failed during the creation of data collector attachment processor '{attachmentProcessorType.AssemblyQualifiedName}'\n{ex}"); - logger?.SendMessage(TestMessageLevel.Error, $"DataCollectorAttachmentsProcessorsFactory: Failed during the creation of data collector attachment processor '{attachmentProcessorType.AssemblyQualifiedName}'\n{ex}"); - } - - if (dataCollectorAttachmentProcessorInstance != null && !datacollectorsAttachmentsProcessors.ContainsKey(attachmentProcessorType.AssemblyQualifiedName)) - { - datacollectorsAttachmentsProcessors.Add(attachmentProcessorType.AssemblyQualifiedName, new Tuple(dataCollectorExtension.Metadata.FriendlyName, dataCollectorAttachmentProcessorInstance)); - EqtTrace.Info($"DataCollectorAttachmentsProcessorsFactory: Collector attachment processor '{attachmentProcessorType.AssemblyQualifiedName}' from file '{invokedDataCollector.FilePath}' added to the 'run list'"); - } + dataCollectorAttachmentProcessorInstance = TestPluginManager.CreateTestExtension(attachmentProcessorType); + EqtTrace.Info($"DataCollectorAttachmentsProcessorsFactory: Creation of collector attachment processor '{attachmentProcessorType.AssemblyQualifiedName}' from file '{invokedDataCollector.FilePath}' succeded"); } - else + catch (Exception ex) { - EqtTrace.Info($"DataCollectorAttachmentsProcessorsFactory: DataCollectorExtension not found for uri '{invokedDataCollector.Uri}'"); + EqtTrace.Error($"DataCollectorAttachmentsProcessorsFactory: Failed during the creation of data collector attachment processor '{attachmentProcessorType.AssemblyQualifiedName}'\n{ex}"); + logger?.SendMessage(TestMessageLevel.Error, $"DataCollectorAttachmentsProcessorsFactory: Failed during the creation of data collector attachment processor '{attachmentProcessorType.AssemblyQualifiedName}'\n{ex}"); } - } - } - // We provide the implementation of CodeCoverageDataAttachmentsHandler through nuget package, but in case of absent registration or if for some reason - // the attachment processor from package fails we fallback to the default implementation. - if (!datacollectorsAttachmentsProcessors.ContainsKey(typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName)) - { - datacollectorsAttachmentsProcessors.Add(typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName, new Tuple(CoverageFriendlyName, new CodeCoverageDataAttachmentsHandler())); - EqtTrace.Info($"DataCollectorAttachmentsProcessorsFactory: Collector attachment processor '{typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName}' for the data collector with friendly name '{CoverageFriendlyName}' added to the 'run list'"); + if (dataCollectorAttachmentProcessorInstance != null && !datacollectorsAttachmentsProcessors.ContainsKey(attachmentProcessorType.AssemblyQualifiedName)) + { + datacollectorsAttachmentsProcessors.Add(attachmentProcessorType.AssemblyQualifiedName, new Tuple(dataCollectorExtension.Metadata.FriendlyName, dataCollectorAttachmentProcessorInstance)); + EqtTrace.Info($"DataCollectorAttachmentsProcessorsFactory: Collector attachment processor '{attachmentProcessorType.AssemblyQualifiedName}' from file '{invokedDataCollector.FilePath}' added to the 'run list'"); + } + } + else + { + EqtTrace.Info($"DataCollectorAttachmentsProcessorsFactory: DataCollectorExtension not found for uri '{invokedDataCollector.Uri}'"); + } } + } - var finalDatacollectorsAttachmentsProcessors = new List(); - foreach (var attachementProcessor in datacollectorsAttachmentsProcessors) - { - EqtTrace.Info($"DataCollectorAttachmentsProcessorsFactory: Valid data collector attachment processor found: '{attachementProcessor.Value.Item2.GetType().AssemblyQualifiedName}'"); - finalDatacollectorsAttachmentsProcessors.Add(new DataCollectorAttachmentProcessor(attachementProcessor.Value.Item1, attachementProcessor.Value.Item2)); - } + // We provide the implementation of CodeCoverageDataAttachmentsHandler through nuget package, but in case of absent registration or if for some reason + // the attachment processor from package fails we fallback to the default implementation. + if (!datacollectorsAttachmentsProcessors.ContainsKey(typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName)) + { + datacollectorsAttachmentsProcessors.Add(typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName, new Tuple(CoverageFriendlyName, new CodeCoverageDataAttachmentsHandler())); + EqtTrace.Info($"DataCollectorAttachmentsProcessorsFactory: Collector attachment processor '{typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName}' for the data collector with friendly name '{CoverageFriendlyName}' added to the 'run list'"); + } - return finalDatacollectorsAttachmentsProcessors.ToArray(); + var finalDatacollectorsAttachmentsProcessors = new List(); + foreach (var attachementProcessor in datacollectorsAttachmentsProcessors) + { + EqtTrace.Info($"DataCollectorAttachmentsProcessorsFactory: Valid data collector attachment processor found: '{attachementProcessor.Value.Item2.GetType().AssemblyQualifiedName}'"); + finalDatacollectorsAttachmentsProcessors.Add(new DataCollectorAttachmentProcessor(attachementProcessor.Value.Item1, attachementProcessor.Value.Item2)); } + + return finalDatacollectorsAttachmentsProcessors.ToArray(); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/TestRunAttachmentsProcessingManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/TestRunAttachmentsProcessingManager.cs index 84afd1ca5d..60d672ea86 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/TestRunAttachmentsProcessingManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/TestRunAttachmentsProcessingManager.cs @@ -9,6 +9,7 @@ using System.Threading; using System.Threading.Tasks; using System.Xml; + using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; using Microsoft.VisualStudio.TestPlatform.ObjectModel; @@ -17,207 +18,206 @@ using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.TestRunAttachmentsProcessing +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.TestRunAttachmentsProcessing; + +/// +/// Orchestrates test run attachments processing operations. +/// +internal class TestRunAttachmentsProcessingManager : ITestRunAttachmentsProcessingManager { + private static readonly string AttachmentsProcessingCompleted = "Completed"; + private static readonly string AttachmentsProcessingCanceled = "Canceled"; + private static readonly string AttachmentsProcessingFailed = "Failed"; + + private readonly ITestPlatformEventSource _testPlatformEventSource; + private readonly IDataCollectorAttachmentsProcessorsFactory _dataCollectorAttachmentsProcessorsFactory; + /// - /// Orchestrates test run attachments processing operations. + /// Initializes a new instance of the class. /// - internal class TestRunAttachmentsProcessingManager : ITestRunAttachmentsProcessingManager + public TestRunAttachmentsProcessingManager(ITestPlatformEventSource testPlatformEventSource, IDataCollectorAttachmentsProcessorsFactory dataCollectorAttachmentsProcessorsFactory) { - private static string AttachmentsProcessingCompleted = "Completed"; - private static string AttachmentsProcessingCanceled = "Canceled"; - private static string AttachmentsProcessingFailed = "Failed"; + _testPlatformEventSource = testPlatformEventSource ?? throw new ArgumentNullException(nameof(testPlatformEventSource)); + _dataCollectorAttachmentsProcessorsFactory = dataCollectorAttachmentsProcessorsFactory ?? throw new ArgumentNullException(nameof(dataCollectorAttachmentsProcessorsFactory)); + } - private readonly ITestPlatformEventSource testPlatformEventSource; - private readonly IDataCollectorAttachmentsProcessorsFactory dataCollectorAttachmentsProcessorsFactory; + /// + public async Task ProcessTestRunAttachmentsAsync(string runSettingsXml, IRequestData requestData, IEnumerable attachments, IEnumerable invokedDataCollector, ITestRunAttachmentsProcessingEventsHandler eventHandler, CancellationToken cancellationToken) + { + await InternalProcessTestRunAttachmentsAsync(runSettingsXml, requestData, new Collection(attachments.ToList()), invokedDataCollector, eventHandler, cancellationToken).ConfigureAwait(false); + } + /// + public Task> ProcessTestRunAttachmentsAsync(string runSettingsXml, IRequestData requestData, IEnumerable attachments, IEnumerable invokedDataCollector, CancellationToken cancellationToken) + { + return InternalProcessTestRunAttachmentsAsync(runSettingsXml, requestData, new Collection(attachments.ToList()), invokedDataCollector, null, cancellationToken); + } - /// - /// Initializes a new instance of the class. - /// - public TestRunAttachmentsProcessingManager(ITestPlatformEventSource testPlatformEventSource, IDataCollectorAttachmentsProcessorsFactory dataCollectorAttachmentsProcessorsFactory) - { - this.testPlatformEventSource = testPlatformEventSource ?? throw new ArgumentNullException(nameof(testPlatformEventSource)); - this.dataCollectorAttachmentsProcessorsFactory = dataCollectorAttachmentsProcessorsFactory ?? throw new ArgumentNullException(nameof(dataCollectorAttachmentsProcessorsFactory)); - } + private async Task> InternalProcessTestRunAttachmentsAsync(string runSettingsXml, IRequestData requestData, Collection attachments, IEnumerable invokedDataCollector, ITestRunAttachmentsProcessingEventsHandler eventHandler, CancellationToken cancellationToken) + { + Stopwatch stopwatch = Stopwatch.StartNew(); - /// - public async Task ProcessTestRunAttachmentsAsync(string runSettingsXml, IRequestData requestData, IEnumerable attachments, IEnumerable invokedDataCollector, ITestRunAttachmentsProcessingEventsHandler eventHandler, CancellationToken cancellationToken) + try { - await InternalProcessTestRunAttachmentsAsync(runSettingsXml, requestData, new Collection(attachments.ToList()), invokedDataCollector, eventHandler, cancellationToken).ConfigureAwait(false); - } - /// - public Task> ProcessTestRunAttachmentsAsync(string runSettingsXml, IRequestData requestData, IEnumerable attachments, IEnumerable invokedDataCollector, CancellationToken cancellationToken) - { - return InternalProcessTestRunAttachmentsAsync(runSettingsXml, requestData, new Collection(attachments.ToList()), invokedDataCollector, null, cancellationToken); - } + _testPlatformEventSource.TestRunAttachmentsProcessingStart(attachments?.Count ?? 0); + requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfAttachmentsSentForProcessing, attachments?.Count ?? 0); - private async Task> InternalProcessTestRunAttachmentsAsync(string runSettingsXml, IRequestData requestData, Collection attachments, IEnumerable invokedDataCollector, ITestRunAttachmentsProcessingEventsHandler eventHandler, CancellationToken cancellationToken) - { - Stopwatch stopwatch = Stopwatch.StartNew(); + cancellationToken.ThrowIfCancellationRequested(); - try + var taskCompletionSource = new TaskCompletionSource>(); + using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled())) { - testPlatformEventSource.TestRunAttachmentsProcessingStart(attachments?.Count ?? 0); - requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfAttachmentsSentForProcessing, attachments?.Count ?? 0); + Task> task = Task.Run(async () => await ProcessAttachmentsAsync(runSettingsXml, new Collection(attachments.ToList()), invokedDataCollector, eventHandler, cancellationToken)); - cancellationToken.ThrowIfCancellationRequested(); + var completedTask = await Task.WhenAny(task, taskCompletionSource.Task).ConfigureAwait(false); - var taskCompletionSource = new TaskCompletionSource>(); - using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled())) + if (completedTask == task) { - Task> task = Task.Run(async () => await ProcessAttachmentsAsync(runSettingsXml, new Collection(attachments.ToList()), invokedDataCollector, eventHandler, cancellationToken)); - - var completedTask = await Task.WhenAny(task, taskCompletionSource.Task).ConfigureAwait(false); - - if (completedTask == task) - { - return FinalizeOperation(requestData, new TestRunAttachmentsProcessingCompleteEventArgs(false, null), await task, stopwatch, eventHandler); - } - else - { - eventHandler?.HandleLogMessage(TestMessageLevel.Informational, "Attachments processing was cancelled."); - return FinalizeOperation(requestData, new TestRunAttachmentsProcessingCompleteEventArgs(true, null), attachments, stopwatch, eventHandler); - } + return FinalizeOperation(requestData, new TestRunAttachmentsProcessingCompleteEventArgs(false, null), await task, stopwatch, eventHandler); } - } - catch (OperationCanceledException) - { - if (EqtTrace.IsWarningEnabled) + else { - EqtTrace.Warning("TestRunAttachmentsProcessingManager: Operation was cancelled."); + eventHandler?.HandleLogMessage(TestMessageLevel.Informational, "Attachments processing was cancelled."); + return FinalizeOperation(requestData, new TestRunAttachmentsProcessingCompleteEventArgs(true, null), attachments, stopwatch, eventHandler); } - return FinalizeOperation(requestData, new TestRunAttachmentsProcessingCompleteEventArgs(true, null), attachments, stopwatch, eventHandler); } - catch (Exception e) + } + catch (OperationCanceledException) + { + if (EqtTrace.IsWarningEnabled) { - EqtTrace.Error("TestRunAttachmentsProcessingManager: Exception in ProcessTestRunAttachmentsAsync: " + e); - - eventHandler?.HandleLogMessage(TestMessageLevel.Error, e.ToString()); - return FinalizeOperation(requestData, new TestRunAttachmentsProcessingCompleteEventArgs(false, e), attachments, stopwatch, eventHandler); + EqtTrace.Warning("TestRunAttachmentsProcessingManager: Operation was cancelled."); } + return FinalizeOperation(requestData, new TestRunAttachmentsProcessingCompleteEventArgs(true, null), attachments, stopwatch, eventHandler); } + catch (Exception e) + { + EqtTrace.Error("TestRunAttachmentsProcessingManager: Exception in ProcessTestRunAttachmentsAsync: " + e); - private async Task> ProcessAttachmentsAsync(string runSettingsXml, Collection attachments, IEnumerable invokedDataCollector, ITestRunAttachmentsProcessingEventsHandler eventsHandler, CancellationToken cancellationToken) + eventHandler?.HandleLogMessage(TestMessageLevel.Error, e.ToString()); + return FinalizeOperation(requestData, new TestRunAttachmentsProcessingCompleteEventArgs(false, e), attachments, stopwatch, eventHandler); + } + } + + private async Task> ProcessAttachmentsAsync(string runSettingsXml, Collection attachments, IEnumerable invokedDataCollector, ITestRunAttachmentsProcessingEventsHandler eventsHandler, CancellationToken cancellationToken) + { + if (attachments == null || !attachments.Any()) return attachments; + var dataCollectionRunSettings = XmlRunSettingsUtilities.GetDataCollectionRunSettings(runSettingsXml); + + var logger = CreateMessageLogger(eventsHandler); + var dataCollectorAttachmentsProcessors = _dataCollectorAttachmentsProcessorsFactory.Create(invokedDataCollector?.ToArray(), logger); + for (int i = 0; i < dataCollectorAttachmentsProcessors.Length; i++) { - if (attachments == null || !attachments.Any()) return attachments; - var dataCollectionRunSettings = XmlRunSettingsUtilities.GetDataCollectionRunSettings(runSettingsXml); + var dataCollectorAttachmentsProcessor = dataCollectorAttachmentsProcessors[i]; + int attachmentsHandlerIndex = i + 1; - var logger = CreateMessageLogger(eventsHandler); - var dataCollectorAttachmentsProcessors = this.dataCollectorAttachmentsProcessorsFactory.Create(invokedDataCollector?.ToArray(), logger); - for (int i = 0; i < dataCollectorAttachmentsProcessors.Length; i++) + if (!dataCollectorAttachmentsProcessor.DataCollectorAttachmentProcessorInstance.SupportsIncrementalProcessing) { - var dataCollectorAttachmentsProcessor = dataCollectorAttachmentsProcessors[i]; - int attachmentsHandlerIndex = i + 1; + EqtTrace.Error($"TestRunAttachmentsProcessingManager: Non incremental attachment processors are not supported, '{dataCollectorAttachmentsProcessor.DataCollectorAttachmentProcessorInstance.GetType()}'"); + logger.SendMessage(TestMessageLevel.Error, $"Non incremental attachment processors are not supported '{dataCollectorAttachmentsProcessor.DataCollectorAttachmentProcessorInstance.GetType()}'"); + continue; + } - if (!dataCollectorAttachmentsProcessor.DataCollectorAttachmentProcessorInstance.SupportsIncrementalProcessing) - { - EqtTrace.Error($"TestRunAttachmentsProcessingManager: Non incremental attachment processors are not supported, '{dataCollectorAttachmentsProcessor.DataCollectorAttachmentProcessorInstance.GetType()}'"); - logger.SendMessage(TestMessageLevel.Error, $"Non incremental attachment processors are not supported '{dataCollectorAttachmentsProcessor.DataCollectorAttachmentProcessorInstance.GetType()}'"); - continue; - } + // We run processor code inside a try/catch because we want to continue with the others in case of failure. + Collection attachmentsBackup = null; + try + { + // We temporarily save the attachments to process because, in case of processor exception, + // we'll restore the attachmentSets to make those available to other processors. + // NB. attachments.ToList() is done on purpose we need a new ref list. + attachmentsBackup = new Collection(attachments.ToList()); - // We run processor code inside a try/catch because we want to continue with the others in case of failure. - Collection attachmentsBackup = null; - try + ICollection attachmentProcessorUris = dataCollectorAttachmentsProcessor.DataCollectorAttachmentProcessorInstance.GetExtensionUris()?.ToList(); + if (attachmentProcessorUris != null && attachmentProcessorUris.Any()) { - // We temporarily save the attachments to process because, in case of processor exception, - // we'll restore the attachmentSets to make those available to other processors. - // NB. attachments.ToList() is done on purpose we need a new ref list. - attachmentsBackup = new Collection(attachments.ToList()); - - ICollection attachmentProcessorUris = dataCollectorAttachmentsProcessor.DataCollectorAttachmentProcessorInstance.GetExtensionUris()?.ToList(); - if (attachmentProcessorUris != null && attachmentProcessorUris.Any()) + var attachmentsToBeProcessed = attachments.Where(dataCollectionAttachment => attachmentProcessorUris.Any(uri => uri.Equals(dataCollectionAttachment.Uri))).ToArray(); + if (attachmentsToBeProcessed.Any()) { - var attachmentsToBeProcessed = attachments.Where(dataCollectionAttachment => attachmentProcessorUris.Any(uri => uri.Equals(dataCollectionAttachment.Uri))).ToArray(); - if (attachmentsToBeProcessed.Any()) + foreach (var attachment in attachmentsToBeProcessed) { - foreach (var attachment in attachmentsToBeProcessed) - { - attachments.Remove(attachment); - } + attachments.Remove(attachment); + } - IProgress progressReporter = new Progress((int progress) => - eventsHandler?.HandleTestRunAttachmentsProcessingProgress( - new TestRunAttachmentsProcessingProgressEventArgs(attachmentsHandlerIndex, attachmentProcessorUris, progress, dataCollectorAttachmentsProcessors.Length))); + IProgress progressReporter = new Progress((int progress) => + eventsHandler?.HandleTestRunAttachmentsProcessingProgress( + new TestRunAttachmentsProcessingProgressEventArgs(attachmentsHandlerIndex, attachmentProcessorUris, progress, dataCollectorAttachmentsProcessors.Length))); - XmlElement configuration = null; - var collectorConfiguration = dataCollectionRunSettings?.DataCollectorSettingsList.SingleOrDefault(c => c.FriendlyName == dataCollectorAttachmentsProcessor.FriendlyName); - if (collectorConfiguration != null && collectorConfiguration.IsEnabled) - { - configuration = collectorConfiguration.Configuration; - } + XmlElement configuration = null; + var collectorConfiguration = dataCollectionRunSettings?.DataCollectorSettingsList.SingleOrDefault(c => c.FriendlyName == dataCollectorAttachmentsProcessor.FriendlyName); + if (collectorConfiguration != null && collectorConfiguration.IsEnabled) + { + configuration = collectorConfiguration.Configuration; + } - EqtTrace.Info($"TestRunAttachmentsProcessingManager: Invocation of data collector attachment processor '{dataCollectorAttachmentsProcessor.DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName}' with configuration '{(configuration == null ? "null" : configuration.OuterXml)}'"); - ICollection processedAttachments = await dataCollectorAttachmentsProcessor.DataCollectorAttachmentProcessorInstance.ProcessAttachmentSetsAsync( - configuration, - new Collection(attachmentsToBeProcessed), - progressReporter, - logger, - cancellationToken).ConfigureAwait(false); + EqtTrace.Info($"TestRunAttachmentsProcessingManager: Invocation of data collector attachment processor '{dataCollectorAttachmentsProcessor.DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName}' with configuration '{(configuration == null ? "null" : configuration.OuterXml)}'"); + ICollection processedAttachments = await dataCollectorAttachmentsProcessor.DataCollectorAttachmentProcessorInstance.ProcessAttachmentSetsAsync( + configuration, + new Collection(attachmentsToBeProcessed), + progressReporter, + logger, + cancellationToken).ConfigureAwait(false); - if (processedAttachments != null && processedAttachments.Any()) + if (processedAttachments != null && processedAttachments.Any()) + { + foreach (var attachment in processedAttachments) { - foreach (var attachment in processedAttachments) - { - attachments.Add(attachment); - } + attachments.Add(attachment); } } } } - catch (Exception e) - { - EqtTrace.Error("TestRunAttachmentsProcessingManager: Exception in ProcessAttachmentsAsync: " + e); - logger.SendMessage(TestMessageLevel.Error, e.ToString()); - - // Restore the attachment sets for the others attachment processors. - attachments = attachmentsBackup; - } } + catch (Exception e) + { + EqtTrace.Error("TestRunAttachmentsProcessingManager: Exception in ProcessAttachmentsAsync: " + e); + logger.SendMessage(TestMessageLevel.Error, e.ToString()); - return attachments; + // Restore the attachment sets for the others attachment processors. + attachments = attachmentsBackup; + } } - private Collection FinalizeOperation(IRequestData requestData, TestRunAttachmentsProcessingCompleteEventArgs completeArgs, Collection attachments, Stopwatch stopwatch, ITestRunAttachmentsProcessingEventsHandler eventHandler) - { - testPlatformEventSource.TestRunAttachmentsProcessingStop(attachments.Count); - requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfAttachmentsAfterProcessing, attachments.Count); - requestData.MetricsCollection.Add(TelemetryDataConstants.AttachmentsProcessingState, completeArgs.Error != null ? AttachmentsProcessingFailed : completeArgs.IsCanceled ? AttachmentsProcessingCanceled : AttachmentsProcessingCompleted); + return attachments; + } - stopwatch.Stop(); - requestData.MetricsCollection.Add(TelemetryDataConstants.TimeTakenInSecForAttachmentsProcessing, stopwatch.Elapsed.TotalSeconds); + private Collection FinalizeOperation(IRequestData requestData, TestRunAttachmentsProcessingCompleteEventArgs completeArgs, Collection attachments, Stopwatch stopwatch, ITestRunAttachmentsProcessingEventsHandler eventHandler) + { + _testPlatformEventSource.TestRunAttachmentsProcessingStop(attachments.Count); + requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfAttachmentsAfterProcessing, attachments.Count); + requestData.MetricsCollection.Add(TelemetryDataConstants.AttachmentsProcessingState, completeArgs.Error != null ? AttachmentsProcessingFailed : completeArgs.IsCanceled ? AttachmentsProcessingCanceled : AttachmentsProcessingCompleted); - completeArgs.Metrics = requestData.MetricsCollection.Metrics; - eventHandler?.HandleTestRunAttachmentsProcessingComplete(completeArgs, attachments); + stopwatch.Stop(); + requestData.MetricsCollection.Add(TelemetryDataConstants.TimeTakenInSecForAttachmentsProcessing, stopwatch.Elapsed.TotalSeconds); - return attachments; - } + completeArgs.Metrics = requestData.MetricsCollection.Metrics; + eventHandler?.HandleTestRunAttachmentsProcessingComplete(completeArgs, attachments); + + return attachments; + } + + private IMessageLogger CreateMessageLogger(ITestRunAttachmentsProcessingEventsHandler eventsHandler) + { + return eventsHandler != null ? (IMessageLogger)new AttachmentsProcessingMessageLogger(eventsHandler) : new NullMessageLogger(); + } - private IMessageLogger CreateMessageLogger(ITestRunAttachmentsProcessingEventsHandler eventsHandler) + private class AttachmentsProcessingMessageLogger : IMessageLogger + { + private readonly ITestRunAttachmentsProcessingEventsHandler _eventsHandler; + + public AttachmentsProcessingMessageLogger(ITestRunAttachmentsProcessingEventsHandler eventsHandler) { - return eventsHandler != null ? (IMessageLogger)new AttachmentsProcessingMessageLogger(eventsHandler) : new NullMessageLogger(); + _eventsHandler = eventsHandler ?? throw new ArgumentNullException(nameof(eventsHandler)); } - private class AttachmentsProcessingMessageLogger : IMessageLogger + public void SendMessage(TestMessageLevel testMessageLevel, string message) { - private readonly ITestRunAttachmentsProcessingEventsHandler eventsHandler; - - public AttachmentsProcessingMessageLogger(ITestRunAttachmentsProcessingEventsHandler eventsHandler) - { - this.eventsHandler = eventsHandler ?? throw new ArgumentNullException(nameof(eventsHandler)); - } - - public void SendMessage(TestMessageLevel testMessageLevel, string message) - { - eventsHandler.HandleLogMessage(testMessageLevel, message); - } + _eventsHandler.HandleLogMessage(testMessageLevel, message); } + } - private class NullMessageLogger : IMessageLogger + private class NullMessageLogger : IMessageLogger + { + public void SendMessage(TestMessageLevel testMessageLevel, string message) { - public void SendMessage(TestMessageLevel testMessageLevel, string message) - { - } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/DiscoveryCriteriaExtensions.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/DiscoveryCriteriaExtensions.cs index 8691acfee0..92e9dfc139 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/DiscoveryCriteriaExtensions.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/DiscoveryCriteriaExtensions.cs @@ -1,41 +1,40 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client -{ - using System.Collections.Generic; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; + +using System.Collections.Generic; +using System.Linq; +using ObjectModel; +using ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - internal static class DiscoveryCriteriaExtensions +internal static class DiscoveryCriteriaExtensions +{ + public static void UpdateDiscoveryCriteria(this DiscoveryCriteria discoveryCriteria, ITestRuntimeProvider testRuntimeProvider) { - public static void UpdateDiscoveryCriteria(this DiscoveryCriteria discoveryCriteria, ITestRuntimeProvider testRuntimeProvider) - { - var actualTestSources = testRuntimeProvider.GetTestSources(discoveryCriteria.Sources); + var actualTestSources = testRuntimeProvider.GetTestSources(discoveryCriteria.Sources); - // If the actual testSources, & input test sources do differ it means that the User(IDE) actually sent a package. - // We are limiting that only one package can be sent per session, so picking the first entry in sources - if (discoveryCriteria.Sources.Except(actualTestSources).Any()) - { - discoveryCriteria.Package = discoveryCriteria.Sources.FirstOrDefault(); + // If the actual testSources, & input test sources do differ it means that the User(IDE) actually sent a package. + // We are limiting that only one package can be sent per session, so picking the first entry in sources + if (discoveryCriteria.Sources.Except(actualTestSources).Any()) + { + discoveryCriteria.Package = discoveryCriteria.Sources.FirstOrDefault(); - // Allow TestRuntimeProvider to update source map, this is required for remote scenarios. - // If we run for specific tests, then we expect the test case object to contain correct source path for remote scenario as well - UpdateTestSources(actualTestSources, discoveryCriteria.AdapterSourceMap); - } + // Allow TestRuntimeProvider to update source map, this is required for remote scenarios. + // If we run for specific tests, then we expect the test case object to contain correct source path for remote scenario as well + UpdateTestSources(actualTestSources, discoveryCriteria.AdapterSourceMap); } + } - /// - /// Update the AdapterSourceMap - /// - /// actual test sources - /// Adapter Source Map - private static void UpdateTestSources(IEnumerable sources, Dictionary> adapterSourceMap) - { - adapterSourceMap.Clear(); - adapterSourceMap.Add(Constants.UnspecifiedAdapterPath, sources); - } + /// + /// Update the AdapterSourceMap + /// + /// actual test sources + /// Adapter Source Map + private static void UpdateTestSources(IEnumerable sources, Dictionary> adapterSourceMap) + { + adapterSourceMap.Clear(); + adapterSourceMap.Add(Constants.UnspecifiedAdapterPath, sources); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs index db1baf2d1a..01064d21ba 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs @@ -1,111 +1,110 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +using Common.ExtensionFramework; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; +using ObjectModel.Engine.TesthostProtocol; +using ObjectModel.Host; +using ObjectModel.Logging; + +internal class InProcessProxyDiscoveryManager : IProxyDiscoveryManager { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; - - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - - internal class InProcessProxyDiscoveryManager : IProxyDiscoveryManager + private readonly ITestHostManagerFactory _testHostManagerFactory; + private readonly IDiscoveryManager _discoveryManager; + private readonly ITestRuntimeProvider _testHostManager; + + public bool IsInitialized { get; private set; } = false; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The test Host Manager. + /// + /// + /// Manager factory + /// + public InProcessProxyDiscoveryManager(ITestRuntimeProvider testHostManager, ITestHostManagerFactory testHostManagerFactory) { - private ITestHostManagerFactory testHostManagerFactory; - private IDiscoveryManager discoveryManager; - private ITestRuntimeProvider testHostManager; - - public bool IsInitialized { get; private set; } = false; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The test Host Manager. - /// - /// - /// Manager factory - /// - public InProcessProxyDiscoveryManager(ITestRuntimeProvider testHostManager, ITestHostManagerFactory testHostManagerFactory) - { - this.testHostManager = testHostManager; - this.testHostManagerFactory = testHostManagerFactory; - this.discoveryManager = this.testHostManagerFactory.GetDiscoveryManager(); - } + _testHostManager = testHostManager; + _testHostManagerFactory = testHostManagerFactory; + _discoveryManager = _testHostManagerFactory.GetDiscoveryManager(); + } - /// - /// Initializes test discovery. - /// Skip default adapters flag. - /// - public void Initialize(bool skipDefaultAdapters) - { - } + /// + /// Initializes test discovery. + /// Skip default adapters flag. + /// + public void Initialize(bool skipDefaultAdapters) + { + } - /// - /// Discovers tests - /// - /// Settings, parameters for the discovery request - /// EventHandler for handling discovery events from Engine - public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler) + /// + /// Discovers tests + /// + /// Settings, parameters for the discovery request + /// EventHandler for handling discovery events from Engine + public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler) + { + Task.Run(() => { - Task.Run(() => + try { - try - { - // Initialize extension before discovery - this.InitializeExtensions(discoveryCriteria.Sources); - discoveryCriteria.UpdateDiscoveryCriteria(testHostManager); - - this.discoveryManager.DiscoverTests(discoveryCriteria, eventHandler); - } - catch (Exception exception) - { - EqtTrace.Error("InProcessProxyDiscoveryManager.DiscoverTests: Failed to discover tests: {0}", exception); - - // Send a discovery complete to caller. - eventHandler.HandleLogMessage(TestMessageLevel.Error, exception.ToString()); - - var discoveryCompeleteEventsArg = new DiscoveryCompleteEventArgs(-1, true); - - eventHandler.HandleDiscoveryComplete(discoveryCompeleteEventsArg, Enumerable.Empty()); - } - }); - } + // Initialize extension before discovery + InitializeExtensions(discoveryCriteria.Sources); + discoveryCriteria.UpdateDiscoveryCriteria(_testHostManager); - /// - /// Closes the current test operation. - /// This function is of no use in this context as we are not creating any testhost - /// - public void Close() - { - } + _discoveryManager.DiscoverTests(discoveryCriteria, eventHandler); + } + catch (Exception exception) + { + EqtTrace.Error("InProcessProxyDiscoveryManager.DiscoverTests: Failed to discover tests: {0}", exception); - /// - /// Aborts the test operation. - /// - public void Abort() - { - Task.Run(() => this.testHostManagerFactory.GetDiscoveryManager().Abort()); - } + // Send a discovery complete to caller. + eventHandler.HandleLogMessage(TestMessageLevel.Error, exception.ToString()); - private void InitializeExtensions(IEnumerable sources) - { - var extensionsFromSource = this.testHostManager.GetTestPlatformExtensions(sources, Enumerable.Empty()); - if (extensionsFromSource.Any()) - { - TestPluginCache.Instance.UpdateExtensions(extensionsFromSource, false); + var discoveryCompeleteEventsArg = new DiscoveryCompleteEventArgs(-1, true); + + eventHandler.HandleDiscoveryComplete(discoveryCompeleteEventsArg, Enumerable.Empty()); } + }); + } + + /// + /// Closes the current test operation. + /// This function is of no use in this context as we are not creating any testhost + /// + public void Close() + { + } + + /// + /// Aborts the test operation. + /// + public void Abort() + { + Task.Run(() => _testHostManagerFactory.GetDiscoveryManager().Abort()); + } - // We don't need to pass list of extension as we are running inside vstest.console and - // it will use TestPluginCache of vstest.console - discoveryManager.Initialize(Enumerable.Empty(), null); + private void InitializeExtensions(IEnumerable sources) + { + var extensionsFromSource = _testHostManager.GetTestPlatformExtensions(sources, Enumerable.Empty()); + if (extensionsFromSource.Any()) + { + TestPluginCache.Instance.UpdateExtensions(extensionsFromSource, false); } + + // We don't need to pass list of extension as we are running inside vstest.console and + // it will use TestPluginCache of vstest.console + _discoveryManager.Initialize(Enumerable.Empty(), null); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs index 8647402846..cdad132d78 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs @@ -1,150 +1,149 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; + +using Common.ExtensionFramework; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; +using ObjectModel.Engine.ClientProtocol; +using ObjectModel.Engine.TesthostProtocol; +using ObjectModel.Host; +using ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; + +internal class InProcessProxyExecutionManager : IProxyExecutionManager { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Linq; - using System.Threading.Tasks; - - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - - internal class InProcessProxyExecutionManager : IProxyExecutionManager + private readonly ITestHostManagerFactory _testHostManagerFactory; + private readonly IExecutionManager _executionManager; + private readonly ITestRuntimeProvider _testHostManager; + + public bool IsInitialized { get; private set; } = false; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The test Host Manager. + /// + /// + /// Manager factory + /// + public InProcessProxyExecutionManager(ITestRuntimeProvider testHostManager, ITestHostManagerFactory testHostManagerFactory) { - private ITestHostManagerFactory testHostManagerFactory; - private IExecutionManager executionManager; - private ITestRuntimeProvider testHostManager; - - public bool IsInitialized { get; private set; } = false; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The test Host Manager. - /// - /// - /// Manager factory - /// - public InProcessProxyExecutionManager(ITestRuntimeProvider testHostManager, ITestHostManagerFactory testHostManagerFactory) - { - this.testHostManager = testHostManager; - this.testHostManagerFactory = testHostManagerFactory; - this.executionManager = this.testHostManagerFactory.GetExecutionManager(); - } + _testHostManager = testHostManager; + _testHostManagerFactory = testHostManagerFactory; + _executionManager = _testHostManagerFactory.GetExecutionManager(); + } - /// - /// Initialize adapters. - /// Skip default adapters flag. - /// - public void Initialize(bool skipDefaultAdapters) - { - } + /// + /// Initialize adapters. + /// Skip default adapters flag. + /// + public void Initialize(bool skipDefaultAdapters) + { + } - /// - public int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler) + /// + public int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler) + { + try { - try + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(testRunCriteria.TestRunSettings); + var testPackages = new List(testRunCriteria.HasSpecificSources ? testRunCriteria.Sources : + // If the test execution is with a test filter, group them by sources + testRunCriteria.Tests.GroupBy(tc => tc.Source).Select(g => g.Key)); + + // This code should be in sync with ProxyExecutionManager.StartTestRun executionContext + var executionContext = new TestExecutionContext( + testRunCriteria.FrequencyOfRunStatsChangeEvent, + testRunCriteria.RunStatsChangeEventTimeout, + inIsolation: runConfiguration.InIsolation, + keepAlive: testRunCriteria.KeepAlive, + isDataCollectionEnabled: false, + areTestCaseLevelEventsRequired: false, + hasTestRun: true, + isDebug: (testRunCriteria.TestHostLauncher != null && testRunCriteria.TestHostLauncher.IsDebug), + testCaseFilter: testRunCriteria.TestCaseFilter, + filterOptions: testRunCriteria.FilterOptions); + + // Initialize extension before execution + InitializeExtensions(testPackages); + + if (testRunCriteria.HasSpecificSources) { - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(testRunCriteria.TestRunSettings); - var testPackages = new List(testRunCriteria.HasSpecificSources ? testRunCriteria.Sources : - // If the test execution is with a test filter, group them by sources - testRunCriteria.Tests.GroupBy(tc => tc.Source).Select(g => g.Key)); - - // This code should be in sync with ProxyExecutionManager.StartTestRun executionContext - var executionContext = new TestExecutionContext( - testRunCriteria.FrequencyOfRunStatsChangeEvent, - testRunCriteria.RunStatsChangeEventTimeout, - inIsolation: runConfiguration.InIsolation, - keepAlive: testRunCriteria.KeepAlive, - isDataCollectionEnabled: false, - areTestCaseLevelEventsRequired: false, - hasTestRun: true, - isDebug: (testRunCriteria.TestHostLauncher != null && testRunCriteria.TestHostLauncher.IsDebug), - testCaseFilter: testRunCriteria.TestCaseFilter, - filterOptions: testRunCriteria.FilterOptions); - - // Initialize extension before execution - this.InitializeExtensions(testPackages); - - if (testRunCriteria.HasSpecificSources) - { - var runRequest = testRunCriteria.CreateTestRunCriteriaForSources(testHostManager, testRunCriteria.TestRunSettings, executionContext, testPackages); - - Task.Run(() => executionManager.StartTestRun(runRequest.AdapterSourceMap, runRequest.Package, - runRequest.RunSettings, runRequest.TestExecutionContext, null, eventHandler)); - } - else - { - var runRequest = testRunCriteria.CreateTestRunCriteriaForTests(testHostManager, testRunCriteria.TestRunSettings, executionContext, testPackages); - - Task.Run(() => executionManager.StartTestRun(runRequest.Tests, runRequest.Package, - runRequest.RunSettings, runRequest.TestExecutionContext, null, eventHandler)); - } + var runRequest = testRunCriteria.CreateTestRunCriteriaForSources(_testHostManager, testRunCriteria.TestRunSettings, executionContext, testPackages); + + Task.Run(() => _executionManager.StartTestRun(runRequest.AdapterSourceMap, runRequest.Package, + runRequest.RunSettings, runRequest.TestExecutionContext, null, eventHandler)); } - catch (Exception exception) + else { - EqtTrace.Error("InProcessProxyexecutionManager.StartTestRun: Failed to start test run: {0}", exception); - - // Send exception message. - eventHandler.HandleLogMessage(TestMessageLevel.Error, exception.ToString()); + var runRequest = testRunCriteria.CreateTestRunCriteriaForTests(_testHostManager, testRunCriteria.TestRunSettings, executionContext, testPackages); - // Send a run complete to caller. - var completeArgs = new TestRunCompleteEventArgs(null, false, true, exception, new Collection(), new Collection(), TimeSpan.Zero); - eventHandler.HandleTestRunComplete(completeArgs, null, null, null); + Task.Run(() => _executionManager.StartTestRun(runRequest.Tests, runRequest.Package, + runRequest.RunSettings, runRequest.TestExecutionContext, null, eventHandler)); } - - return 0; } - - /// - /// Aborts the test operation. - /// - /// EventHandler for handling execution events from Engine. - public void Abort(ITestRunEventsHandler eventHandler) + catch (Exception exception) { - Task.Run(() => this.testHostManagerFactory.GetExecutionManager().Abort(eventHandler)); - } + EqtTrace.Error("InProcessProxyexecutionManager.StartTestRun: Failed to start test run: {0}", exception); - /// - /// Cancels the test run. - /// - /// EventHandler for handling execution events from Engine. - public void Cancel(ITestRunEventsHandler eventHandler) - { - Task.Run(() => this.testHostManagerFactory.GetExecutionManager().Cancel(eventHandler)); - } + // Send exception message. + eventHandler.HandleLogMessage(TestMessageLevel.Error, exception.ToString()); - /// - /// Closes the current test operation. - /// This function is of no use in this context as we are not creating any testhost - /// - public void Close() - { + // Send a run complete to caller. + var completeArgs = new TestRunCompleteEventArgs(null, false, true, exception, new Collection(), new Collection(), TimeSpan.Zero); + eventHandler.HandleTestRunComplete(completeArgs, null, null, null); } + return 0; + } - private void InitializeExtensions(IEnumerable sources) - { - var extensionsFromSource = this.testHostManager.GetTestPlatformExtensions(sources, Enumerable.Empty()); - if (extensionsFromSource.Any()) - { - TestPluginCache.Instance.UpdateExtensions(extensionsFromSource, false); - } + /// + /// Aborts the test operation. + /// + /// EventHandler for handling execution events from Engine. + public void Abort(ITestRunEventsHandler eventHandler) + { + Task.Run(() => _testHostManagerFactory.GetExecutionManager().Abort(eventHandler)); + } + + /// + /// Cancels the test run. + /// + /// EventHandler for handling execution events from Engine. + public void Cancel(ITestRunEventsHandler eventHandler) + { + Task.Run(() => _testHostManagerFactory.GetExecutionManager().Cancel(eventHandler)); + } + + /// + /// Closes the current test operation. + /// This function is of no use in this context as we are not creating any testhost + /// + public void Close() + { + } - // We don't need to pass list of extension as we are running inside vstest.console and - // it will use TestPluginCache of vstest.console - executionManager.Initialize(Enumerable.Empty(), null); + + private void InitializeExtensions(IEnumerable sources) + { + var extensionsFromSource = _testHostManager.GetTestPlatformExtensions(sources, Enumerable.Empty()); + if (extensionsFromSource.Any()) + { + TestPluginCache.Instance.UpdateExtensions(extensionsFromSource, false); } + + // We don't need to pass list of extension as we are running inside vstest.console and + // it will use TestPluginCache of vstest.console + _executionManager.Initialize(Enumerable.Empty(), null); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/LoggerNameValueConfigurationManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/LoggerNameValueConfigurationManager.cs index 305fb5a5c8..284eef6c26 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/LoggerNameValueConfigurationManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/LoggerNameValueConfigurationManager.cs @@ -1,78 +1,73 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; + +using System.Collections.Generic; +using System.Xml; + +using ObjectModel; + +/// +/// Utility class that loggers can use to read name/value configuration information from the XML element sent to them +/// +internal class LoggerNameValueConfigurationManager { - using System.Collections.Generic; - using System.Xml; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; /// - /// Utility class that loggers can use to read name/value configuration information from the XML element sent to them + /// Initializes a new instance of the class. + /// Loads the configuration name/value information from the provided XML element into a dictionary /// - internal class LoggerNameValueConfigurationManager + /// + /// XML element containing the configuration + /// + public LoggerNameValueConfigurationManager(XmlElement configurationElement) { - /// - /// The name/value pairs loaded from the configuration XML element - /// - private Dictionary nameValuePairs = new Dictionary(); + Initialize(configurationElement); + } - /// - /// Initializes a new instance of the class. - /// Loads the configuration name/value information from the provided XML element into a dictionary - /// - /// - /// XML element containing the configuration - /// - public LoggerNameValueConfigurationManager(XmlElement configurationElement) + public Dictionary NameValuePairs { get; } = new Dictionary(); + + private void Initialize(XmlElement configurationElement) + { + if (configurationElement == null) { - Initialize(configurationElement); + // There is no configuration + return; } - public Dictionary NameValuePairs => this.nameValuePairs; - - private void Initialize(XmlElement configurationElement) + // Iterate through top-level XML elements within the configuration element and store + // name/value information for elements that have name/value attributes. + foreach (XmlNode settingNode in configurationElement.ChildNodes) { - if (configurationElement == null) + // Skip all non-elements + if (settingNode is not XmlElement settingElement) { - // There is no configuration - return; + continue; } - // Iterate through top-level XML elements within the configuration element and store - // name/value information for elements that have name/value attributes. - foreach (XmlNode settingNode in configurationElement.ChildNodes) - { - // Skip all non-elements - var settingElement = settingNode as XmlElement; - if (settingElement == null) - { - continue; - } - - // Get the setting name - string settingName = settingElement.Name; + // Get the setting name + string settingName = settingElement.Name; - // Get the setting value - string settingValue = settingElement.InnerText; + // Get the setting value + string settingValue = settingElement.InnerText; - if (string.IsNullOrWhiteSpace(settingValue)) - { - EqtTrace.Warning("Skipping configuration setting '{0}' due to missing value", settingName); - continue; - } - - // Save the name/value pair in the dictionary. Note that duplicate settings are - // overwritten with the last occurrence's value. - if (this.nameValuePairs.ContainsKey(settingName)) - { - EqtTrace.Verbose( - "Duplicate configuration setting found for '{0}'. Using the last setting.", - settingName); - } + if (string.IsNullOrWhiteSpace(settingValue)) + { + EqtTrace.Warning("Skipping configuration setting '{0}' due to missing value", settingName); + continue; + } - this.NameValuePairs[settingName] = settingValue; + // Save the name/value pair in the dictionary. Note that duplicate settings are + // overwritten with the last occurrence's value. + if (NameValuePairs.ContainsKey(settingName)) + { + EqtTrace.Verbose( + "Duplicate configuration setting found for '{0}'. Using the last setting.", + settingName); } + + NameValuePairs[settingName] = settingValue; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelDiscoveryDataAggregator.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelDiscoveryDataAggregator.cs index f41394d598..0126cde985 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelDiscoveryDataAggregator.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelDiscoveryDataAggregator.cs @@ -1,133 +1,132 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; + +using Common.Telemetry; + +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; + +/// +/// ParallelDiscoveryDataAggregator aggregates discovery data from parallel discovery managers +/// +internal class ParallelDiscoveryDataAggregator { - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using System; - using System.Collections.Concurrent; - using System.Collections.Generic; - using System.Linq; + #region PrivateFields + + private readonly object _dataUpdateSyncObject = new(); + private readonly ConcurrentDictionary _metricsAggregator; + + #endregion + + public ParallelDiscoveryDataAggregator() + { + IsAborted = false; + TotalTests = 0; + _metricsAggregator = new ConcurrentDictionary(); + } + + #region Public Properties /// - /// ParallelDiscoveryDataAggregator aggregates discovery data from parallel discovery managers + /// Set to true if any of the request is aborted /// - internal class ParallelDiscoveryDataAggregator - { - #region PrivateFields + public bool IsAborted { get; private set; } + + /// + /// Aggregate total test count + /// + public long TotalTests { get; private set; } - private object dataUpdateSyncObject = new object(); - private ConcurrentDictionary metricsAggregator; + #endregion - #endregion + #region Public Methods - public ParallelDiscoveryDataAggregator() + /// + /// Returns the Aggregated Metrics. + /// + /// + public IDictionary GetAggregatedDiscoveryDataMetrics() + { + if (_metricsAggregator == null || _metricsAggregator.Count == 0) { - IsAborted = false; - TotalTests = 0; - this.metricsAggregator = new ConcurrentDictionary(); + return new ConcurrentDictionary(); } - #region Public Properties + var adapterUsedCount = _metricsAggregator.Count(metrics => + metrics.Key.Contains(TelemetryDataConstants.TotalTestsByAdapter)); - /// - /// Set to true if any of the request is aborted - /// - public bool IsAborted { get; private set; } + var adaptersDiscoveredCount = _metricsAggregator.Count(metrics => + metrics.Key.Contains(TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter)); - /// - /// Aggregate total test count - /// - public long TotalTests { get; private set; } + // Aggregating Total Adapter Used Count + _metricsAggregator.TryAdd( + TelemetryDataConstants.NumberOfAdapterUsedToDiscoverTests, + adapterUsedCount); - #endregion + // Aggregating Total Adapters Discovered Count + _metricsAggregator.TryAdd( + TelemetryDataConstants.NumberOfAdapterDiscoveredDuringDiscovery, + adaptersDiscoveredCount); - #region Public Methods + return _metricsAggregator; + } - /// - /// Returns the Aggregated Metrics. - /// - /// - public IDictionary GetAggregatedDiscoveryDataMetrics() + /// + /// Aggregate discovery data + /// Must be thread-safe as this is expected to be called by parallel managers + /// + public void Aggregate(long totalTests, bool isAborted) + { + lock (_dataUpdateSyncObject) { - if (this.metricsAggregator == null || this.metricsAggregator.Count == 0) + IsAborted = IsAborted || isAborted; + + if (IsAborted) { - return new ConcurrentDictionary(); + // Do not aggregate tests count if test discovery is aborted. It is mandated by + // platform that tests count is negative for discovery abort event. + // See `DiscoveryCompleteEventArgs`. + TotalTests = -1; + return; } - var adapterUsedCount = this.metricsAggregator.Count(metrics => - metrics.Key.Contains(TelemetryDataConstants.TotalTestsByAdapter)); - - var adaptersDiscoveredCount = this.metricsAggregator.Count(metrics => - metrics.Key.Contains(TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter)); - - // Aggregating Total Adapter Used Count - this.metricsAggregator.TryAdd( - TelemetryDataConstants.NumberOfAdapterUsedToDiscoverTests, - adapterUsedCount); - - // Aggregating Total Adapters Discovered Count - this.metricsAggregator.TryAdd( - TelemetryDataConstants.NumberOfAdapterDiscoveredDuringDiscovery, - adaptersDiscoveredCount); - - return this.metricsAggregator; + TotalTests += totalTests; } + } - /// - /// Aggregate discovery data - /// Must be thread-safe as this is expected to be called by parallel managers - /// - public void Aggregate(long totalTests, bool isAborted) + /// + /// Aggregates the metrics from Test Host Process. + /// + /// + public void AggregateDiscoveryDataMetrics(IDictionary metrics) + { + if (metrics == null || metrics.Count == 0 || _metricsAggregator == null) { - lock (dataUpdateSyncObject) - { - this.IsAborted = this.IsAborted || isAborted; - - if (this.IsAborted) - { - // Do not aggregate tests count if test discovery is aborted. It is mandated by - // platform that tests count is negative for discovery abort event. - // See `DiscoveryCompleteEventArgs`. - this.TotalTests = -1; - return; - } - - this.TotalTests += totalTests; - } + return; } - /// - /// Aggregates the metrics from Test Host Process. - /// - /// - public void AggregateDiscoveryDataMetrics(IDictionary metrics) + foreach (var metric in metrics) { - if (metrics == null || metrics.Count == 0 || metricsAggregator == null) + if (metric.Key.Contains(TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter) || metric.Key.Contains(TelemetryDataConstants.TimeTakenInSecByAllAdapters) || (metric.Key.Contains(TelemetryDataConstants.TotalTestsDiscovered) || metric.Key.Contains(TelemetryDataConstants.TotalTestsByAdapter) || metric.Key.Contains(TelemetryDataConstants.TimeTakenToLoadAdaptersInSec))) { - return; - } + var newValue = Convert.ToDouble(metric.Value); - foreach (var metric in metrics) - { - if (metric.Key.Contains(TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter) || metric.Key.Contains(TelemetryDataConstants.TimeTakenInSecByAllAdapters) || (metric.Key.Contains(TelemetryDataConstants.TotalTestsDiscovered) || metric.Key.Contains(TelemetryDataConstants.TotalTestsByAdapter) || metric.Key.Contains(TelemetryDataConstants.TimeTakenToLoadAdaptersInSec))) + if (_metricsAggregator.TryGetValue(metric.Key, out object oldValue)) + { + double oldDoubleValue = Convert.ToDouble(oldValue); + _metricsAggregator[metric.Key] = newValue + oldDoubleValue; + } + else { - var newValue = Convert.ToDouble(metric.Value); - object oldValue; - - if (this.metricsAggregator.TryGetValue(metric.Key, out oldValue)) - { - double oldDoubleValue = Convert.ToDouble(oldValue); - this.metricsAggregator[metric.Key] = newValue + oldDoubleValue; - } - else - { - this.metricsAggregator.TryAdd(metric.Key, newValue); - } + _metricsAggregator.TryAdd(metric.Key, newValue); } } } - - #endregion } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelDiscoveryEventsHandler.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelDiscoveryEventsHandler.cs index 1552ca924c..e785c3418b 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelDiscoveryEventsHandler.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelDiscoveryEventsHandler.cs @@ -1,164 +1,163 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; + +using System.Collections.Generic; + +using Common.Telemetry; +using CommunicationUtilities; +using CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; +using ObjectModel.Logging; + +using CommonResources = Common.Resources.Resources; + +/// +/// ParallelDiscoveryEventsHandler for handling the discovery events in case of parallel discovery +/// +internal class ParallelDiscoveryEventsHandler : ITestDiscoveryEventsHandler2 { - using System.Collections.Generic; + private readonly IProxyDiscoveryManager _proxyDiscoveryManager; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + private readonly ITestDiscoveryEventsHandler2 _actualDiscoveryEventsHandler; - using CommonResources = Common.Resources.Resources; + private readonly IParallelProxyDiscoveryManager _parallelProxyDiscoveryManager; - /// - /// ParallelDiscoveryEventsHandler for handling the discovery events in case of parallel discovery - /// - internal class ParallelDiscoveryEventsHandler : ITestDiscoveryEventsHandler2 - { - private IProxyDiscoveryManager proxyDiscoveryManager; + private readonly ParallelDiscoveryDataAggregator _discoveryDataAggregator; - private ITestDiscoveryEventsHandler2 actualDiscoveryEventsHandler; + private readonly IDataSerializer _dataSerializer; - private IParallelProxyDiscoveryManager parallelProxyDiscoveryManager; + private readonly IRequestData _requestData; - private ParallelDiscoveryDataAggregator discoveryDataAggregator; + public ParallelDiscoveryEventsHandler(IRequestData requestData, + IProxyDiscoveryManager proxyDiscoveryManager, + ITestDiscoveryEventsHandler2 actualDiscoveryEventsHandler, + IParallelProxyDiscoveryManager parallelProxyDiscoveryManager, + ParallelDiscoveryDataAggregator discoveryDataAggregator) : + this(requestData, proxyDiscoveryManager, actualDiscoveryEventsHandler, parallelProxyDiscoveryManager, discoveryDataAggregator, JsonDataSerializer.Instance) + { + } - private IDataSerializer dataSerializer; + internal ParallelDiscoveryEventsHandler(IRequestData requestData, + IProxyDiscoveryManager proxyDiscoveryManager, + ITestDiscoveryEventsHandler2 actualDiscoveryEventsHandler, + IParallelProxyDiscoveryManager parallelProxyDiscoveryManager, + ParallelDiscoveryDataAggregator discoveryDataAggregator, + IDataSerializer dataSerializer) + { + _proxyDiscoveryManager = proxyDiscoveryManager; + _actualDiscoveryEventsHandler = actualDiscoveryEventsHandler; + _parallelProxyDiscoveryManager = parallelProxyDiscoveryManager; + _discoveryDataAggregator = discoveryDataAggregator; + _dataSerializer = dataSerializer; + _requestData = requestData; + } - private IRequestData requestData; + /// + public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk) + { + var totalTests = discoveryCompleteEventArgs.TotalCount; + var isAborted = discoveryCompleteEventArgs.IsAborted; - public ParallelDiscoveryEventsHandler(IRequestData requestData, - IProxyDiscoveryManager proxyDiscoveryManager, - ITestDiscoveryEventsHandler2 actualDiscoveryEventsHandler, - IParallelProxyDiscoveryManager parallelProxyDiscoveryManager, - ParallelDiscoveryDataAggregator discoveryDataAggregator) : - this(requestData, proxyDiscoveryManager, actualDiscoveryEventsHandler, parallelProxyDiscoveryManager, discoveryDataAggregator, JsonDataSerializer.Instance) + // we get discovery complete events from each host process + // so we cannot "complete" the actual operation until all sources are consumed + // We should not block last chunk results while we aggregate overall discovery data + if (lastChunk != null) { + ConvertToRawMessageAndSend(MessageType.TestCasesFound, lastChunk); + HandleDiscoveredTests(lastChunk); } - internal ParallelDiscoveryEventsHandler(IRequestData requestData, - IProxyDiscoveryManager proxyDiscoveryManager, - ITestDiscoveryEventsHandler2 actualDiscoveryEventsHandler, - IParallelProxyDiscoveryManager parallelProxyDiscoveryManager, - ParallelDiscoveryDataAggregator discoveryDataAggregator, - IDataSerializer dataSerializer) - { - this.proxyDiscoveryManager = proxyDiscoveryManager; - this.actualDiscoveryEventsHandler = actualDiscoveryEventsHandler; - this.parallelProxyDiscoveryManager = parallelProxyDiscoveryManager; - this.discoveryDataAggregator = discoveryDataAggregator; - this.dataSerializer = dataSerializer; - this.requestData = requestData; - } + // Aggregate for final discovery complete + _discoveryDataAggregator.Aggregate(totalTests, isAborted); - /// - public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk) - { - var totalTests = discoveryCompleteEventArgs.TotalCount; - var isAborted = discoveryCompleteEventArgs.IsAborted; + // Aggregate Discovery Data Metrics + _discoveryDataAggregator.AggregateDiscoveryDataMetrics(discoveryCompleteEventArgs.Metrics); - // we get discovery complete events from each host process - // so we cannot "complete" the actual operation until all sources are consumed - // We should not block last chunk results while we aggregate overall discovery data - if (lastChunk != null) + // Do not send TestDiscoveryComplete to actual test discovery handler + // We need to see if there are still sources left - let the parallel manager decide + var parallelDiscoveryComplete = _parallelProxyDiscoveryManager.HandlePartialDiscoveryComplete( + _proxyDiscoveryManager, + totalTests, + null, // lastChunk should be null as we already sent this data above + isAborted); + + if (parallelDiscoveryComplete) + { + // In case of sequential discovery - RawMessage would have contained a 'DiscoveryCompletePayload' object + // To send a raw message - we need to create raw message from an aggregated payload object + var testDiscoveryCompletePayload = new DiscoveryCompletePayload() { - ConvertToRawMessageAndSend(MessageType.TestCasesFound, lastChunk); - this.HandleDiscoveredTests(lastChunk); - } + TotalTests = _discoveryDataAggregator.TotalTests, + IsAborted = _discoveryDataAggregator.IsAborted, + LastDiscoveredTests = null + }; - // Aggregate for final discovery complete - discoveryDataAggregator.Aggregate(totalTests, isAborted); + // Collecting Final Discovery State + _requestData.MetricsCollection.Add(TelemetryDataConstants.DiscoveryState, isAborted ? "Aborted" : "Completed"); - // Aggregate Discovery Data Metrics - discoveryDataAggregator.AggregateDiscoveryDataMetrics(discoveryCompleteEventArgs.Metrics); + // Collect Aggregated Metrics Data + var aggregatedDiscoveryDataMetrics = _discoveryDataAggregator.GetAggregatedDiscoveryDataMetrics(); + testDiscoveryCompletePayload.Metrics = aggregatedDiscoveryDataMetrics; - // Do not send TestDiscoveryComplete to actual test discovery handler - // We need to see if there are still sources left - let the parallel manager decide - var parallelDiscoveryComplete = this.parallelProxyDiscoveryManager.HandlePartialDiscoveryComplete( - this.proxyDiscoveryManager, - totalTests, - null, // lastChunk should be null as we already sent this data above - isAborted); + // we have to send raw messages as we block the discovery complete actual raw messages + ConvertToRawMessageAndSend(MessageType.DiscoveryComplete, testDiscoveryCompletePayload); - if (parallelDiscoveryComplete) - { - // In case of sequential discovery - RawMessage would have contained a 'DiscoveryCompletePayload' object - // To send a raw message - we need to create raw message from an aggregated payload object - var testDiscoveryCompletePayload = new DiscoveryCompletePayload() - { - TotalTests = discoveryDataAggregator.TotalTests, - IsAborted = discoveryDataAggregator.IsAborted, - LastDiscoveredTests = null - }; - - // Collecting Final Discovery State - this.requestData.MetricsCollection.Add(TelemetryDataConstants.DiscoveryState, isAborted ? "Aborted" : "Completed"); - - // Collect Aggregated Metrics Data - var aggregatedDiscoveryDataMetrics = discoveryDataAggregator.GetAggregatedDiscoveryDataMetrics(); - testDiscoveryCompletePayload.Metrics = aggregatedDiscoveryDataMetrics; - - // we have to send raw messages as we block the discovery complete actual raw messages - this.ConvertToRawMessageAndSend(MessageType.DiscoveryComplete, testDiscoveryCompletePayload); - - var finalDiscoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(this.discoveryDataAggregator.TotalTests, - this.discoveryDataAggregator.IsAborted); - finalDiscoveryCompleteEventArgs.Metrics = aggregatedDiscoveryDataMetrics; - - // send actual test discovery complete to clients - this.actualDiscoveryEventsHandler.HandleDiscoveryComplete(finalDiscoveryCompleteEventArgs, null); - } - } + var finalDiscoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(_discoveryDataAggregator.TotalTests, + _discoveryDataAggregator.IsAborted); + finalDiscoveryCompleteEventArgs.Metrics = aggregatedDiscoveryDataMetrics; - /// - public void HandleRawMessage(string rawMessage) - { - // In case of parallel - we can send everything but handle complete - // DiscoveryComplete is not true-end of the overall discovery as we only get completion of one host here - // Always aggregate data, deserialize and raw for complete events - var message = this.dataSerializer.DeserializeMessage(rawMessage); - - // Do not send CancellationRequested message to Output window in IDE, as it is not useful for user - if (string.Equals(message.MessageType, MessageType.TestMessage) - && rawMessage.IndexOf(CommonResources.CancellationRequested) >= 0) - { - return; - } - - // Do not deserialize further - if (!string.Equals(MessageType.DiscoveryComplete, message.MessageType)) - { - this.actualDiscoveryEventsHandler.HandleRawMessage(rawMessage); - } + // send actual test discovery complete to clients + _actualDiscoveryEventsHandler.HandleDiscoveryComplete(finalDiscoveryCompleteEventArgs, null); } + } - /// - public void HandleDiscoveredTests(IEnumerable discoveredTestCases) + /// + public void HandleRawMessage(string rawMessage) + { + // In case of parallel - we can send everything but handle complete + // DiscoveryComplete is not true-end of the overall discovery as we only get completion of one host here + // Always aggregate data, deserialize and raw for complete events + var message = _dataSerializer.DeserializeMessage(rawMessage); + + // Do not send CancellationRequested message to Output window in IDE, as it is not useful for user + if (string.Equals(message.MessageType, MessageType.TestMessage) + && rawMessage.IndexOf(CommonResources.CancellationRequested) >= 0) { - this.actualDiscoveryEventsHandler.HandleDiscoveredTests(discoveredTestCases); + return; } - /// - public void HandleLogMessage(TestMessageLevel level, string message) + // Do not deserialize further + if (!string.Equals(MessageType.DiscoveryComplete, message.MessageType)) { - this.actualDiscoveryEventsHandler.HandleLogMessage(level, message); + _actualDiscoveryEventsHandler.HandleRawMessage(rawMessage); } + } - /// - /// To send message to IDE output window use HandleRawMessage - /// - /// - /// - private void ConvertToRawMessageAndSend(string messageType, object payload) - { - var rawMessage = this.dataSerializer.SerializePayload(messageType, payload); - this.actualDiscoveryEventsHandler.HandleRawMessage(rawMessage); - } + /// + public void HandleDiscoveredTests(IEnumerable discoveredTestCases) + { + _actualDiscoveryEventsHandler.HandleDiscoveredTests(discoveredTestCases); + } + + /// + public void HandleLogMessage(TestMessageLevel level, string message) + { + _actualDiscoveryEventsHandler.HandleLogMessage(level, message); + } + + /// + /// To send message to IDE output window use HandleRawMessage + /// + /// + /// + private void ConvertToRawMessageAndSend(string messageType, object payload) + { + var rawMessage = _dataSerializer.SerializePayload(messageType, payload); + _actualDiscoveryEventsHandler.HandleRawMessage(rawMessage); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelOperationManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelOperationManager.cs index 323847a815..49bde28ef6 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelOperationManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelOperationManager.cs @@ -1,258 +1,256 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; + +using System; +using System.Collections; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +using ObjectModel; +using ObjectModel.Engine; + +/// +/// Abstract class having common parallel manager implementation +/// +internal abstract class ParallelOperationManager : IParallelOperationManager, IDisposable { - using System; - using System.Collections; - using System.Collections.Concurrent; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; + #region ConcurrentManagerInstanceData - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + protected Func CreateNewConcurrentManager { get; set; } /// - /// Abstract class having common parallel manager implementation + /// Gets a value indicating whether hosts are shared. /// - internal abstract class ParallelOperationManager : IParallelOperationManager, IDisposable - { - #region ConcurrentManagerInstanceData + protected bool SharedHosts { get; private set; } - protected Func CreateNewConcurrentManager { get; set; } + private IDictionary _concurrentManagerHandlerMap; - /// - /// Gets a value indicating whether hosts are shared. - /// - protected bool SharedHosts { get; private set; } + /// + /// Singleton Instance of this class + /// + protected static T s_instance = default; - private IDictionary concurrentManagerHandlerMap; + /// + /// Default number of Processes + /// + private int _currentParallelLevel = 0; - /// - /// Singleton Instance of this class - /// - protected static T instance = default(T); + #endregion - /// - /// Default number of Processes - /// - private int currentParallelLevel = 0; + #region Concurrency Keeper Objects - #endregion + /// + /// LockObject to iterate our sourceEnumerator in parallel + /// We can use the sourceEnumerator itself as lockObject, but since its a changing object - it's risky to use it as one + /// + protected object _sourceEnumeratorLockObject = new(); - #region Concurrency Keeper Objects + #endregion - /// - /// LockObject to iterate our sourceEnumerator in parallel - /// We can use the sourceEnumerator itself as lockObject, but since its a changing object - it's risky to use it as one - /// - protected object sourceEnumeratorLockObject = new object(); + protected ParallelOperationManager(Func createNewManager, int parallelLevel, bool sharedHosts) + { + CreateNewConcurrentManager = createNewManager; + SharedHosts = sharedHosts; - #endregion + // Update Parallel Level + UpdateParallelLevel(parallelLevel); + } - protected ParallelOperationManager(Func createNewManager, int parallelLevel, bool sharedHosts) - { - this.CreateNewConcurrentManager = createNewManager; - this.SharedHosts = sharedHosts; + /// + /// Remove and dispose a manager from concurrent list of manager. + /// + /// Manager to remove + public void RemoveManager(T manager) + { + _concurrentManagerHandlerMap.Remove(manager); + } - // Update Parallel Level - this.UpdateParallelLevel(parallelLevel); - } + /// + /// Add a manager in concurrent list of manager. + /// + /// Manager to add + /// eventHandler of the manager + public void AddManager(T manager, TU handler) + { + _concurrentManagerHandlerMap.Add(manager, handler); + } - /// - /// Remove and dispose a manager from concurrent list of manager. - /// - /// Manager to remove - public void RemoveManager(T manager) + /// + /// Update event handler for the manager. + /// If it is a new manager, add this. + /// + /// Manager to update + /// event handler to update for manager + public void UpdateHandlerForManager(T manager, TU handler) + { + if (_concurrentManagerHandlerMap.ContainsKey(manager)) { - this.concurrentManagerHandlerMap.Remove(manager); + _concurrentManagerHandlerMap[manager] = handler; } - - /// - /// Add a manager in concurrent list of manager. - /// - /// Manager to add - /// eventHandler of the manager - public void AddManager(T manager, U handler) + else { - this.concurrentManagerHandlerMap.Add(manager, handler); + AddManager(manager, handler); } + } - /// - /// Update event handler for the manager. - /// If it is a new manager, add this. - /// - /// Manager to update - /// event handler to update for manager - public void UpdateHandlerForManager(T manager, U handler) - { - if(this.concurrentManagerHandlerMap.ContainsKey(manager)) - { - this.concurrentManagerHandlerMap[manager] = handler; - } - else - { - this.AddManager(manager, handler); - } - } + /// + /// Get the event handler associated with the manager. + /// + /// Manager + public TU GetHandlerForGivenManager(T manager) + { + return _concurrentManagerHandlerMap[manager]; + } - /// - /// Get the event handler associated with the manager. - /// - /// Manager - public U GetHandlerForGivenManager(T manager) - { - return this.concurrentManagerHandlerMap[manager]; - } + /// + /// Get total number of active concurrent manager + /// + public int GetConcurrentManagersCount() + { + return _concurrentManagerHandlerMap.Count; + } + + /// + /// Get instances of all active concurrent manager + /// + public IEnumerable GetConcurrentManagerInstances() + { + return _concurrentManagerHandlerMap.Keys.ToList(); + } - /// - /// Get total number of active concurrent manager - /// - public int GetConcurrentManagersCount() - { - return this.concurrentManagerHandlerMap.Count; - } - /// - /// Get instances of all active concurrent manager - /// - public IEnumerable GetConcurrentManagerInstances() + /// + /// Updates the Concurrent Executors according to new parallel setting + /// + /// Number of Parallel Executors allowed + public void UpdateParallelLevel(int newParallelLevel) + { + if (_concurrentManagerHandlerMap == null) { - return this.concurrentManagerHandlerMap.Keys.ToList(); + // not initialized yet + // create rest of concurrent clients other than default one + _concurrentManagerHandlerMap = new ConcurrentDictionary(); + for (int i = 0; i < newParallelLevel; i++) + { + AddManager(CreateNewConcurrentManager(), default); + } } - - - /// - /// Updates the Concurrent Executors according to new parallel setting - /// - /// Number of Parallel Executors allowed - public void UpdateParallelLevel(int newParallelLevel) + else if (_currentParallelLevel != newParallelLevel) { - if (this.concurrentManagerHandlerMap == null) + // If number of concurrent clients is less than the new level + // Create more concurrent clients and update the list + if (_currentParallelLevel < newParallelLevel) { - // not initialized yet - // create rest of concurrent clients other than default one - this.concurrentManagerHandlerMap = new ConcurrentDictionary(); - for (int i = 0; i < newParallelLevel; i++) + for (int i = 0; i < newParallelLevel - _currentParallelLevel; i++) { - this.AddManager(this.CreateNewConcurrentManager(), default(U)); + AddManager(CreateNewConcurrentManager(), default); } } - else if (this.currentParallelLevel != newParallelLevel) + else { - // If number of concurrent clients is less than the new level - // Create more concurrent clients and update the list - if (this.currentParallelLevel < newParallelLevel) + // If number of concurrent clients is more than the new level + // Dispose off the extra ones + int managersCount = _currentParallelLevel - newParallelLevel; + + foreach (var concurrentManager in GetConcurrentManagerInstances()) { - for (int i = 0; i < newParallelLevel - this.currentParallelLevel; i++) + if (managersCount == 0) { - this.AddManager(this.CreateNewConcurrentManager(), default(U)); + break; } - } - else - { - // If number of concurrent clients is more than the new level - // Dispose off the extra ones - int managersCount = currentParallelLevel - newParallelLevel; - - foreach(var concurrentManager in this.GetConcurrentManagerInstances()) + else { - if (managersCount == 0) - { - break; - } - else - { - this.RemoveManager(concurrentManager); - managersCount--; - } + RemoveManager(concurrentManager); + managersCount--; } } } - - // Update current parallel setting to new one - this.currentParallelLevel = newParallelLevel; } - public void Dispose() + // Update current parallel setting to new one + _currentParallelLevel = newParallelLevel; + } + + public void Dispose() + { + if (_concurrentManagerHandlerMap != null) { - if (this.concurrentManagerHandlerMap != null) + foreach (var managerInstance in GetConcurrentManagerInstances()) { - foreach (var managerInstance in this.GetConcurrentManagerInstances()) - { - this.RemoveManager(managerInstance); - } + RemoveManager(managerInstance); } - - instance = default(T); } - protected void DoActionOnAllManagers(Action action, bool doActionsInParallel = false) + s_instance = default; + } + + protected void DoActionOnAllManagers(Action action, bool doActionsInParallel = false) + { + if (_concurrentManagerHandlerMap != null && _concurrentManagerHandlerMap.Count > 0) { - if (this.concurrentManagerHandlerMap != null && this.concurrentManagerHandlerMap.Count > 0) + int i = 0; + var actionTasks = new Task[_concurrentManagerHandlerMap.Count]; + foreach (var client in GetConcurrentManagerInstances()) { - int i = 0; - var actionTasks = new Task[this.concurrentManagerHandlerMap.Count]; - foreach (var client in this.GetConcurrentManagerInstances()) + // Read the array before firing the task - beware of closures + if (doActionsInParallel) { - // Read the array before firing the task - beware of closures - if (doActionsInParallel) - { - actionTasks[i] = Task.Run(() => action(client)); - i++; - } - else - { - this.DoManagerAction(() => action(client)); - } + actionTasks[i] = Task.Run(() => action(client)); + i++; } - - if (doActionsInParallel) + else { - this.DoManagerAction(() => Task.WaitAll(actionTasks)); + DoManagerAction(() => action(client)); } } - } - private void DoManagerAction(Action action) - { - try + if (doActionsInParallel) { - action(); + DoManagerAction(() => Task.WaitAll(actionTasks)); } - catch (Exception ex) + } + } + + private void DoManagerAction(Action action) + { + try + { + action(); + } + catch (Exception ex) + { + // Exception can occur if we are trying to cancel a test run on an executor where test run is not even fired + // we can safely ignore that as user is just canceling the test run and we don't care about additional parallel executors + // as we will be disposing them off soon anyway + if (EqtTrace.IsWarningEnabled) { - // Exception can occur if we are trying to cancel a test run on an executor where test run is not even fired - // we can safely ignore that as user is just canceling the test run and we don't care about additional parallel executors - // as we will be disposing them off soon anyway - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning("AbstractParallelOperationManager: Exception while invoking an action on Proxy Manager instance: {0}", ex); - } + EqtTrace.Warning("AbstractParallelOperationManager: Exception while invoking an action on Proxy Manager instance: {0}", ex); } } + } - /// - /// Fetches the next data object for the concurrent executor to work on - /// - /// source data to work on - source file or testCaseList - /// True, if data exists. False otherwise - protected bool TryFetchNextSource(IEnumerator enumerator, out Y source) + /// + /// Fetches the next data object for the concurrent executor to work on + /// + /// source data to work on - source file or testCaseList + /// True, if data exists. False otherwise + protected bool TryFetchNextSource(IEnumerator enumerator, out TY source) + { + source = default; + var hasNext = false; + lock (_sourceEnumeratorLockObject) { - source = default(Y); - var hasNext = false; - lock (this.sourceEnumeratorLockObject) + if (enumerator != null && enumerator.MoveNext()) { - if (enumerator != null && enumerator.MoveNext()) - { - source = (Y)enumerator.Current; - hasNext = source != null; - } + source = (TY)enumerator.Current; + hasNext = source != null; } - - return hasNext; } - } -} + return hasNext; + } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyDiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyDiscoveryManager.cs index c7ea14d07a..a122cd1ed6 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyDiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyDiscoveryManager.cs @@ -1,231 +1,232 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +using CommunicationUtilities; +using CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; +using ObjectModel.Logging; + +/// +/// ParallelProxyDiscoveryManager that manages parallel discovery +/// +internal class ParallelProxyDiscoveryManager : ParallelOperationManager, IParallelProxyDiscoveryManager { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + private readonly IDataSerializer _dataSerializer; - /// - /// ParallelProxyDiscoveryManager that manages parallel discovery - /// - internal class ParallelProxyDiscoveryManager : ParallelOperationManager, IParallelProxyDiscoveryManager - { - private IDataSerializer dataSerializer; + #region DiscoverySpecificData - #region DiscoverySpecificData + private int _discoveryCompletedClients = 0; + private int _availableTestSources = -1; - private int discoveryCompletedClients = 0; - private int availableTestSources = -1; + private DiscoveryCriteria _actualDiscoveryCriteria; - private DiscoveryCriteria actualDiscoveryCriteria; + private IEnumerator _sourceEnumerator; - private IEnumerator sourceEnumerator; + private ITestDiscoveryEventsHandler2 _currentDiscoveryEventsHandler; - private ITestDiscoveryEventsHandler2 currentDiscoveryEventsHandler; + private ParallelDiscoveryDataAggregator _currentDiscoveryDataAggregator; - private ParallelDiscoveryDataAggregator currentDiscoveryDataAggregator; + private readonly IRequestData _requestData; - private IRequestData requestData; + // This field indicates if abort was requested by testplatform (user) + private bool _discoveryAbortRequested = false; - // This field indicates if abort was requested by testplatform (user) - private bool discoveryAbortRequested = false; + #endregion - #endregion + #region Concurrency Keeper Objects - #region Concurrency Keeper Objects + /// + /// LockObject to update discovery status in parallel + /// + private readonly object _discoveryStatusLockObject = new(); - /// - /// LockObject to update discovery status in parallel - /// - private object discoveryStatusLockObject = new object(); + #endregion - #endregion + public ParallelProxyDiscoveryManager(IRequestData requestData, Func actualProxyManagerCreator, int parallelLevel, bool sharedHosts) + : this(requestData, actualProxyManagerCreator, JsonDataSerializer.Instance, parallelLevel, sharedHosts) + { + } - public ParallelProxyDiscoveryManager(IRequestData requestData, Func actualProxyManagerCreator, int parallelLevel, bool sharedHosts) - : this(requestData, actualProxyManagerCreator, JsonDataSerializer.Instance, parallelLevel, sharedHosts) - { - } + internal ParallelProxyDiscoveryManager(IRequestData requestData, Func actualProxyManagerCreator, IDataSerializer dataSerializer, int parallelLevel, bool sharedHosts) + : base(actualProxyManagerCreator, parallelLevel, sharedHosts) + { + _requestData = requestData; + _dataSerializer = dataSerializer; + } - internal ParallelProxyDiscoveryManager(IRequestData requestData, Func actualProxyManagerCreator, IDataSerializer dataSerializer, int parallelLevel, bool sharedHosts) - : base(actualProxyManagerCreator, parallelLevel, sharedHosts) - { - this.requestData = requestData; - this.dataSerializer = dataSerializer; - } + #region IProxyDiscoveryManager + + /// + public void Initialize(bool skipDefaultAdapters) + { + DoActionOnAllManagers((proxyManager) => proxyManager.Initialize(skipDefaultAdapters), doActionsInParallel: true); + } + + /// + public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler) + { + _actualDiscoveryCriteria = discoveryCriteria; - #region IProxyDiscoveryManager + // Set the enumerator for parallel yielding of sources + // Whenever a concurrent executor becomes free, it picks up the next source using this enumerator + _sourceEnumerator = discoveryCriteria.Sources.GetEnumerator(); + _availableTestSources = discoveryCriteria.Sources.Count(); - /// - public void Initialize(bool skipDefaultAdapters) + if (EqtTrace.IsVerboseEnabled) { - this.DoActionOnAllManagers((proxyManager) => proxyManager.Initialize(skipDefaultAdapters), doActionsInParallel: true); + EqtTrace.Verbose("ParallelProxyDiscoveryManager: Start discovery. Total sources: " + _availableTestSources); } + DiscoverTestsPrivate(eventHandler); + } + + /// + public void Abort() + { + _discoveryAbortRequested = true; + DoActionOnAllManagers((proxyManager) => proxyManager.Abort(), doActionsInParallel: true); + } + + /// + public void Close() + { + DoActionOnAllManagers(proxyManager => proxyManager.Close(), doActionsInParallel: true); + } + + #endregion - /// - public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler) + #region IParallelProxyDiscoveryManager methods + + /// + public bool HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, long totalTests, IEnumerable lastChunk, bool isAborted) + { + var allDiscoverersCompleted = false; + lock (_discoveryStatusLockObject) { - this.actualDiscoveryCriteria = discoveryCriteria; + // Each concurrent Executor calls this method + // So, we need to keep track of total discovery complete calls + _discoveryCompletedClients++; - // Set the enumerator for parallel yielding of sources - // Whenever a concurrent executor becomes free, it picks up the next source using this enumerator - this.sourceEnumerator = discoveryCriteria.Sources.GetEnumerator(); - this.availableTestSources = discoveryCriteria.Sources.Count(); + // If there are no more sources/testcases, a parallel executor is truly done with discovery + allDiscoverersCompleted = _discoveryCompletedClients == _availableTestSources; if (EqtTrace.IsVerboseEnabled) { - EqtTrace.Verbose("ParallelProxyDiscoveryManager: Start discovery. Total sources: " + this.availableTestSources); + EqtTrace.Verbose("ParallelProxyDiscoveryManager: HandlePartialDiscoveryComplete: Total completed clients = {0}, Discovery complete = {1}.", _discoveryCompletedClients, allDiscoverersCompleted); } - this.DiscoverTestsPrivate(eventHandler); } - /// - public void Abort() + /* + If discovery is complete or discovery aborting was requsted by testPlatfrom(user) + we need to stop all ongoing discoveries, because we want to separate aborting request + when testhost crashed by itself and when user requested it (f.e. through TW) + Schedule the clean up for managers and handlers. + */ + if (allDiscoverersCompleted || _discoveryAbortRequested) { - this.discoveryAbortRequested = true; - this.DoActionOnAllManagers((proxyManager) => proxyManager.Abort(), doActionsInParallel: true); - } + // Reset enumerators + _sourceEnumerator = null; - /// - public void Close() - { - this.DoActionOnAllManagers(proxyManager => proxyManager.Close(), doActionsInParallel: true); - } + _currentDiscoveryDataAggregator = null; + _currentDiscoveryEventsHandler = null; - #endregion + // Dispose concurrent executors + UpdateParallelLevel(0); - #region IParallelProxyDiscoveryManager methods + return true; + } - /// - public bool HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, long totalTests, IEnumerable lastChunk, bool isAborted) + /* Discovery is not complete. + Now when both.net framework and.net core projects can run in parallel + we should clear manager and create new one for both cases. + Otherwise `proxyDiscoveryManager` instance is alredy closed by now and it will give exception + when trying to do some operation on it. + */ + if (EqtTrace.IsVerboseEnabled) { - var allDiscoverersCompleted = false; - lock (this.discoveryStatusLockObject) - { - // Each concurrent Executor calls this method - // So, we need to keep track of total discovery complete calls - this.discoveryCompletedClients++; + EqtTrace.Verbose("ParallelProxyDiscoveryManager: HandlePartialDiscoveryComplete: Replace discovery manager. Shared: {0}, Aborted: {1}.", SharedHosts, isAborted); + } - // If there are no more sources/testcases, a parallel executor is truly done with discovery - allDiscoverersCompleted = this.discoveryCompletedClients == this.availableTestSources; + RemoveManager(proxyDiscoveryManager); - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("ParallelProxyDiscoveryManager: HandlePartialDiscoveryComplete: Total completed clients = {0}, Discovery complete = {1}.", this.discoveryCompletedClients, allDiscoverersCompleted); - } - } + proxyDiscoveryManager = CreateNewConcurrentManager(); + var parallelEventsHandler = new ParallelDiscoveryEventsHandler( + _requestData, + proxyDiscoveryManager, + _currentDiscoveryEventsHandler, + this, + _currentDiscoveryDataAggregator); + AddManager(proxyDiscoveryManager, parallelEventsHandler); - /* - If discovery is complete or discovery aborting was requsted by testPlatfrom(user) - we need to stop all ongoing discoveries, because we want to separate aborting request - when testhost crashed by itself and when user requested it (f.e. through TW) - Schedule the clean up for managers and handlers. - */ - if (allDiscoverersCompleted || discoveryAbortRequested) - { - // Reset enumerators - this.sourceEnumerator = null; + // Second, let's attempt to trigger discovery for the next source. + DiscoverTestsOnConcurrentManager(proxyDiscoveryManager); - this.currentDiscoveryDataAggregator = null; - this.currentDiscoveryEventsHandler = null; + return false; + } - // Dispose concurrent executors - this.UpdateParallelLevel(0); + #endregion - return true; - } + private void DiscoverTestsPrivate(ITestDiscoveryEventsHandler2 discoveryEventsHandler) + { + _currentDiscoveryEventsHandler = discoveryEventsHandler; - /* Discovery is not complete. - Now when both.net framework and.net core projects can run in parallel - we should clear manager and create new one for both cases. - Otherwise `proxyDiscoveryManager` instance is alredy closed by now and it will give exception - when trying to do some operation on it. - */ - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("ParallelProxyDiscoveryManager: HandlePartialDiscoveryComplete: Replace discovery manager. Shared: {0}, Aborted: {1}.", this.SharedHosts, isAborted); - } + // Reset the discovery complete data + _discoveryCompletedClients = 0; - this.RemoveManager(proxyDiscoveryManager); + // One data aggregator per parallel discovery + _currentDiscoveryDataAggregator = new ParallelDiscoveryDataAggregator(); - proxyDiscoveryManager = this.CreateNewConcurrentManager(); + foreach (var concurrentManager in GetConcurrentManagerInstances()) + { var parallelEventsHandler = new ParallelDiscoveryEventsHandler( - this.requestData, - proxyDiscoveryManager, - this.currentDiscoveryEventsHandler, - this, - this.currentDiscoveryDataAggregator); - this.AddManager(proxyDiscoveryManager, parallelEventsHandler); - - // Second, let's attempt to trigger discovery for the next source. - this.DiscoverTestsOnConcurrentManager(proxyDiscoveryManager); - - return false; + _requestData, + concurrentManager, + discoveryEventsHandler, + this, + _currentDiscoveryDataAggregator); + + UpdateHandlerForManager(concurrentManager, parallelEventsHandler); + DiscoverTestsOnConcurrentManager(concurrentManager); } + } - #endregion - - private void DiscoverTestsPrivate(ITestDiscoveryEventsHandler2 discoveryEventsHandler) + /// + /// Triggers the discovery for the next data object on the concurrent discoverer + /// Each concurrent discoverer calls this method, once its completed working on previous data + /// + /// Proxy discovery manager instance. + private void DiscoverTestsOnConcurrentManager(IProxyDiscoveryManager proxyDiscoveryManager) + { + // Peek to see if we have sources to trigger a discovery + if (TryFetchNextSource(_sourceEnumerator, out string nextSource)) { - this.currentDiscoveryEventsHandler = discoveryEventsHandler; - - // Reset the discovery complete data - this.discoveryCompletedClients = 0; - - // One data aggregator per parallel discovery - this.currentDiscoveryDataAggregator = new ParallelDiscoveryDataAggregator(); - - foreach (var concurrentManager in this.GetConcurrentManagerInstances()) + if (EqtTrace.IsVerboseEnabled) { - var parallelEventsHandler = new ParallelDiscoveryEventsHandler( - this.requestData, - concurrentManager, - discoveryEventsHandler, - this, - this.currentDiscoveryDataAggregator); - - this.UpdateHandlerForManager(concurrentManager, parallelEventsHandler); - this.DiscoverTestsOnConcurrentManager(concurrentManager); + EqtTrace.Verbose("ProxyParallelDiscoveryManager: Triggering test discovery for next source: {0}", nextSource); } - } - /// - /// Triggers the discovery for the next data object on the concurrent discoverer - /// Each concurrent discoverer calls this method, once its completed working on previous data - /// - /// Proxy discovery manager instance. - private void DiscoverTestsOnConcurrentManager(IProxyDiscoveryManager proxyDiscoveryManager) - { - // Peek to see if we have sources to trigger a discovery - if (this.TryFetchNextSource(this.sourceEnumerator, out string nextSource)) - { - if (EqtTrace.IsVerboseEnabled) + // Kick off another discovery task for the next source + var discoveryCriteria = new DiscoveryCriteria(new[] { nextSource }, _actualDiscoveryCriteria.FrequencyOfDiscoveredTestsEvent, _actualDiscoveryCriteria.DiscoveredTestEventTimeout, _actualDiscoveryCriteria.RunSettings); + discoveryCriteria.TestCaseFilter = _actualDiscoveryCriteria.TestCaseFilter; + Task.Run(() => { - EqtTrace.Verbose("ProxyParallelDiscoveryManager: Triggering test discovery for next source: {0}", nextSource); - } - - // Kick off another discovery task for the next source - var discoveryCriteria = new DiscoveryCriteria(new[] { nextSource }, this.actualDiscoveryCriteria.FrequencyOfDiscoveredTestsEvent, this.actualDiscoveryCriteria.DiscoveredTestEventTimeout, this.actualDiscoveryCriteria.RunSettings); - discoveryCriteria.TestCaseFilter = this.actualDiscoveryCriteria.TestCaseFilter; - Task.Run(() => + if (EqtTrace.IsVerboseEnabled) { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("ParallelProxyDiscoveryManager: Discovery started."); - } + EqtTrace.Verbose("ParallelProxyDiscoveryManager: Discovery started."); + } - proxyDiscoveryManager.DiscoverTests(discoveryCriteria, this.GetHandlerForGivenManager(proxyDiscoveryManager)); - }) - .ContinueWith(t => + proxyDiscoveryManager.DiscoverTests(discoveryCriteria, GetHandlerForGivenManager(proxyDiscoveryManager)); + }) + .ContinueWith(t => { // Just in case, the actual discovery couldn't start for an instance. Ensure that // we call discovery complete since we have already fetched a source. Otherwise @@ -235,9 +236,9 @@ private void DiscoverTestsOnConcurrentManager(IProxyDiscoveryManager proxyDiscov EqtTrace.Error("ParallelProxyDiscoveryManager: Failed to trigger discovery. Exception: " + t.Exception); } - var handler = this.GetHandlerForGivenManager(proxyDiscoveryManager); + var handler = GetHandlerForGivenManager(proxyDiscoveryManager); var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = t.Exception.ToString() }; - handler.HandleRawMessage(this.dataSerializer.SerializePayload(MessageType.TestMessage, testMessagePayload)); + handler.HandleRawMessage(_dataSerializer.SerializePayload(MessageType.TestMessage, testMessagePayload)); handler.HandleLogMessage(TestMessageLevel.Error, t.Exception.ToString()); // Send discovery complete. Similar logic is also used in ProxyDiscoveryManager.DiscoverTests. @@ -249,12 +250,11 @@ private void DiscoverTestsOnConcurrentManager(IProxyDiscoveryManager proxyDiscov handler.HandleDiscoveryComplete(discoveryCompleteEventsArgs, null); }, TaskContinuationOptions.OnlyOnFaulted); - } + } - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("ProxyParallelDiscoveryManager: No sources available for discovery."); - } + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("ProxyParallelDiscoveryManager: No sources available for discovery."); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyExecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyExecutionManager.cs index 9264f2817a..824b709a0d 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyExecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyExecutionManager.cs @@ -1,358 +1,351 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +using CommunicationUtilities; +using CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using CoreUtilities.Tracing; +using DataCollection; +using TestRunAttachmentsProcessing; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; +using ObjectModel.Logging; + +/// +/// ParallelProxyExecutionManager that manages parallel execution +/// +internal class ParallelProxyExecutionManager : ParallelOperationManager, IParallelProxyExecutionManager { - using System; - using System.Collections; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Linq; - using System.Threading; - using System.Threading.Tasks; - - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.TestRunAttachmentsProcessing; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.Utilities; + private readonly IDataSerializer _dataSerializer; - /// - /// ParallelProxyExecutionManager that manages parallel execution - /// - internal class ParallelProxyExecutionManager : ParallelOperationManager, IParallelProxyExecutionManager - { - private IDataSerializer dataSerializer; + #region TestRunSpecificData - #region TestRunSpecificData + // This variable id to differentiate between implicit (abort requested by testPlatform) and explicit (test host aborted) abort. + private bool _abortRequested = false; - // This variable id to differentiate between implicit (abort requested by testPlatform) and explicit (test host aborted) abort. - private bool abortRequested = false; + private int _runCompletedClients = 0; + private int _runStartedClients = 0; + private int _availableTestSources = -1; - private int runCompletedClients = 0; - private int runStartedClients = 0; - private int availableTestSources = -1; + private TestRunCriteria _actualTestRunCriteria; - private TestRunCriteria actualTestRunCriteria; + private IEnumerator _sourceEnumerator; - private IEnumerator sourceEnumerator; + private IEnumerator _testCaseListEnumerator; - private IEnumerator testCaseListEnumerator; + private bool _hasSpecificTestsRun = false; - private bool hasSpecificTestsRun = false; + private ITestRunEventsHandler _currentRunEventsHandler; - private ITestRunEventsHandler currentRunEventsHandler; + private ParallelRunDataAggregator _currentRunDataAggregator; - private ParallelRunDataAggregator currentRunDataAggregator; + private readonly IRequestData _requestData; + private bool _skipDefaultAdapters; - private IRequestData requestData; - private bool skipDefaultAdapters; + /// + public bool IsInitialized { get; private set; } = false; - /// - public bool IsInitialized { get; private set; } = false; + #endregion - #endregion + #region Concurrency Keeper Objects - #region Concurrency Keeper Objects + /// + /// LockObject to update execution status in parallel + /// + private readonly object _executionStatusLockObject = new(); - /// - /// LockObject to update execution status in parallel - /// - private readonly object executionStatusLockObject = new object(); + #endregion - #endregion + public ParallelProxyExecutionManager(IRequestData requestData, Func actualProxyManagerCreator, int parallelLevel) + : this(requestData, actualProxyManagerCreator, JsonDataSerializer.Instance, parallelLevel, true) + { + } - public ParallelProxyExecutionManager(IRequestData requestData, Func actualProxyManagerCreator, int parallelLevel) - : this(requestData, actualProxyManagerCreator, JsonDataSerializer.Instance, parallelLevel, true) - { - } + public ParallelProxyExecutionManager(IRequestData requestData, Func actualProxyManagerCreator, int parallelLevel, bool sharedHosts) + : this(requestData, actualProxyManagerCreator, JsonDataSerializer.Instance, parallelLevel, sharedHosts) + { + } - public ParallelProxyExecutionManager(IRequestData requestData, Func actualProxyManagerCreator, int parallelLevel, bool sharedHosts) - : this(requestData, actualProxyManagerCreator, JsonDataSerializer.Instance, parallelLevel, sharedHosts) - { - } + internal ParallelProxyExecutionManager(IRequestData requestData, Func actualProxyManagerCreator, IDataSerializer dataSerializer, int parallelLevel, bool sharedHosts) + : base(actualProxyManagerCreator, parallelLevel, sharedHosts) + { + _requestData = requestData; + _dataSerializer = dataSerializer; + } - internal ParallelProxyExecutionManager(IRequestData requestData, Func actualProxyManagerCreator, IDataSerializer dataSerializer, int parallelLevel, bool sharedHosts) - : base(actualProxyManagerCreator, parallelLevel, sharedHosts) - { - this.requestData = requestData; - this.dataSerializer = dataSerializer; - } + #region IProxyExecutionManager - #region IProxyExecutionManager + public void Initialize(bool skipDefaultAdapters) + { + _skipDefaultAdapters = skipDefaultAdapters; + DoActionOnAllManagers((proxyManager) => proxyManager.Initialize(skipDefaultAdapters), doActionsInParallel: true); + IsInitialized = true; + } - public void Initialize(bool skipDefaultAdapters) - { - this.skipDefaultAdapters = skipDefaultAdapters; - this.DoActionOnAllManagers((proxyManager) => proxyManager.Initialize(skipDefaultAdapters), doActionsInParallel: true); - this.IsInitialized = true; - } + public int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler) + { + _hasSpecificTestsRun = testRunCriteria.HasSpecificTests; + _actualTestRunCriteria = testRunCriteria; - public int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler) + if (_hasSpecificTestsRun) { - this.hasSpecificTestsRun = testRunCriteria.HasSpecificTests; - this.actualTestRunCriteria = testRunCriteria; - - if (this.hasSpecificTestsRun) + var testCasesBySource = new Dictionary>(); + foreach (var test in testRunCriteria.Tests) { - var testCasesBySource = new Dictionary>(); - foreach (var test in testRunCriteria.Tests) + if (!testCasesBySource.ContainsKey(test.Source)) { - if (!testCasesBySource.ContainsKey(test.Source)) - { - testCasesBySource.Add(test.Source, new List()); - } - - testCasesBySource[test.Source].Add(test); + testCasesBySource.Add(test.Source, new List()); } - // Do not use "Dictionary.ValueCollection.Enumerator" - it becomes nondeterministic once we go out of scope of this method - // Use "ToArray" to copy ValueColleciton to a simple array and use it's enumerator - // Set the enumerator for parallel yielding of testCases - // Whenever a concurrent executor becomes free, it picks up the next set of testCases using this enumerator - var testCaseLists = testCasesBySource.Values.ToArray(); - this.testCaseListEnumerator = testCaseLists.GetEnumerator(); - this.availableTestSources = testCaseLists.Length; - } - else - { - // Set the enumerator for parallel yielding of sources - // Whenever a concurrent executor becomes free, it picks up the next source using this enumerator - this.sourceEnumerator = testRunCriteria.Sources.GetEnumerator(); - this.availableTestSources = testRunCriteria.Sources.Count(); + testCasesBySource[test.Source].Add(test); } - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("ParallelProxyExecutionManager: Start execution. Total sources: " + this.availableTestSources); - } - return this.StartTestRunPrivate(eventHandler); + // Do not use "Dictionary.ValueCollection.Enumerator" - it becomes nondeterministic once we go out of scope of this method + // Use "ToArray" to copy ValueColleciton to a simple array and use it's enumerator + // Set the enumerator for parallel yielding of testCases + // Whenever a concurrent executor becomes free, it picks up the next set of testCases using this enumerator + var testCaseLists = testCasesBySource.Values.ToArray(); + _testCaseListEnumerator = testCaseLists.GetEnumerator(); + _availableTestSources = testCaseLists.Length; } - - public void Abort(ITestRunEventsHandler runEventsHandler) + else { - // Test platform initiated abort. - abortRequested = true; - this.DoActionOnAllManagers((proxyManager) => proxyManager.Abort(runEventsHandler), doActionsInParallel: true); + // Set the enumerator for parallel yielding of sources + // Whenever a concurrent executor becomes free, it picks up the next source using this enumerator + _sourceEnumerator = testRunCriteria.Sources.GetEnumerator(); + _availableTestSources = testRunCriteria.Sources.Count(); } - public void Cancel(ITestRunEventsHandler runEventsHandler) + if (EqtTrace.IsVerboseEnabled) { - this.DoActionOnAllManagers((proxyManager) => proxyManager.Cancel(runEventsHandler), doActionsInParallel: true); + EqtTrace.Verbose("ParallelProxyExecutionManager: Start execution. Total sources: " + _availableTestSources); } + return StartTestRunPrivate(eventHandler); + } - public void Close() - { - this.DoActionOnAllManagers(proxyManager => proxyManager.Close(), doActionsInParallel: true); - } - - #endregion - - #region IParallelProxyExecutionManager methods - - /// - /// Handles Partial Run Complete event coming from a specific concurrent proxy execution manager - /// Each concurrent proxy execution manager will signal the parallel execution manager when its complete - /// - /// Concurrent Execution manager that completed the run - /// RunCompleteArgs for the concurrent run - /// LastChunk testresults for the concurrent run - /// RunAttachments for the concurrent run - /// ExecutorURIs of the adapters involved in executing the tests - /// True if parallel run is complete - public bool HandlePartialRunComplete( - IProxyExecutionManager proxyExecutionManager, - TestRunCompleteEventArgs testRunCompleteArgs, - TestRunChangedEventArgs lastChunkArgs, - ICollection runContextAttachments, - ICollection executorUris) - { - var allRunsCompleted = false; - lock (this.executionStatusLockObject) - { - // Each concurrent Executor calls this method - // So, we need to keep track of total run complete calls - this.runCompletedClients++; - - if (testRunCompleteArgs.IsCanceled || abortRequested) - { - allRunsCompleted = this.runCompletedClients == this.runStartedClients; - } - else - { - allRunsCompleted = this.runCompletedClients == this.availableTestSources; - } + public void Abort(ITestRunEventsHandler runEventsHandler) + { + // Test platform initiated abort. + _abortRequested = true; + DoActionOnAllManagers((proxyManager) => proxyManager.Abort(runEventsHandler), doActionsInParallel: true); + } - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("ParallelProxyExecutionManager: HandlePartialRunComplete: Total completed clients = {0}, Run complete = {1}, Run canceled: {2}.", this.runCompletedClients, allRunsCompleted, testRunCompleteArgs.IsCanceled); - } - } + public void Cancel(ITestRunEventsHandler runEventsHandler) + { + DoActionOnAllManagers((proxyManager) => proxyManager.Cancel(runEventsHandler), doActionsInParallel: true); + } - // verify that all executors are done with the execution and there are no more sources/testcases to execute - if (allRunsCompleted) - { - // Reset enumerators - this.sourceEnumerator = null; - this.testCaseListEnumerator = null; + public void Close() + { + DoActionOnAllManagers(proxyManager => proxyManager.Close(), doActionsInParallel: true); + } - this.currentRunDataAggregator = null; - this.currentRunEventsHandler = null; + #endregion - // Dispose concurrent executors - // Do not do the cleanup task in the current thread as we will unnecessarily add to execution time - this.UpdateParallelLevel(0); + #region IParallelProxyExecutionManager methods - return true; - } + /// + /// Handles Partial Run Complete event coming from a specific concurrent proxy execution manager + /// Each concurrent proxy execution manager will signal the parallel execution manager when its complete + /// + /// Concurrent Execution manager that completed the run + /// RunCompleteArgs for the concurrent run + /// LastChunk testresults for the concurrent run + /// RunAttachments for the concurrent run + /// ExecutorURIs of the adapters involved in executing the tests + /// True if parallel run is complete + public bool HandlePartialRunComplete( + IProxyExecutionManager proxyExecutionManager, + TestRunCompleteEventArgs testRunCompleteArgs, + TestRunChangedEventArgs lastChunkArgs, + ICollection runContextAttachments, + ICollection executorUris) + { + var allRunsCompleted = false; + lock (_executionStatusLockObject) + { + // Each concurrent Executor calls this method + // So, we need to keep track of total run complete calls + _runCompletedClients++; + allRunsCompleted = testRunCompleteArgs.IsCanceled || _abortRequested + ? _runCompletedClients == _runStartedClients + : _runCompletedClients == _availableTestSources; if (EqtTrace.IsVerboseEnabled) { - EqtTrace.Verbose("ParallelProxyExecutionManager: HandlePartialRunComplete: Replace execution manager. Shared: {0}, Aborted: {1}.", this.SharedHosts, testRunCompleteArgs.IsAborted); + EqtTrace.Verbose("ParallelProxyExecutionManager: HandlePartialRunComplete: Total completed clients = {0}, Run complete = {1}, Run canceled: {2}.", _runCompletedClients, allRunsCompleted, testRunCompleteArgs.IsCanceled); } + } + + // verify that all executors are done with the execution and there are no more sources/testcases to execute + if (allRunsCompleted) + { + // Reset enumerators + _sourceEnumerator = null; + _testCaseListEnumerator = null; - this.RemoveManager(proxyExecutionManager); - proxyExecutionManager = CreateNewConcurrentManager(); - var parallelEventsHandler = this.GetEventsHandler(proxyExecutionManager); - this.AddManager(proxyExecutionManager, parallelEventsHandler); + _currentRunDataAggregator = null; + _currentRunEventsHandler = null; - // If cancel is triggered for any one run or abort is requested by test platform, there is no reason to fetch next source - // and queue another test run - if (!testRunCompleteArgs.IsCanceled && !abortRequested) - { - this.StartTestRunOnConcurrentManager(proxyExecutionManager); - } + // Dispose concurrent executors + // Do not do the cleanup task in the current thread as we will unnecessarily add to execution time + UpdateParallelLevel(0); - return false; + return true; } - #endregion - private int StartTestRunPrivate(ITestRunEventsHandler runEventsHandler) + if (EqtTrace.IsVerboseEnabled) { - this.currentRunEventsHandler = runEventsHandler; + EqtTrace.Verbose("ParallelProxyExecutionManager: HandlePartialRunComplete: Replace execution manager. Shared: {0}, Aborted: {1}.", SharedHosts, testRunCompleteArgs.IsAborted); + } - // Reset the run complete data - this.runCompletedClients = 0; + RemoveManager(proxyExecutionManager); + proxyExecutionManager = CreateNewConcurrentManager(); + var parallelEventsHandler = GetEventsHandler(proxyExecutionManager); + AddManager(proxyExecutionManager, parallelEventsHandler); - // One data aggregator per parallel run - this.currentRunDataAggregator = new ParallelRunDataAggregator(this.actualTestRunCriteria.TestRunSettings); + // If cancel is triggered for any one run or abort is requested by test platform, there is no reason to fetch next source + // and queue another test run + if (!testRunCompleteArgs.IsCanceled && !_abortRequested) + { + StartTestRunOnConcurrentManager(proxyExecutionManager); + } - foreach (var concurrentManager in this.GetConcurrentManagerInstances()) - { - var parallelEventsHandler = this.GetEventsHandler(concurrentManager); - this.UpdateHandlerForManager(concurrentManager, parallelEventsHandler); - this.StartTestRunOnConcurrentManager(concurrentManager); - } + return false; + } - return 1; - } + #endregion + + private int StartTestRunPrivate(ITestRunEventsHandler runEventsHandler) + { + _currentRunEventsHandler = runEventsHandler; + + // Reset the run complete data + _runCompletedClients = 0; + + // One data aggregator per parallel run + _currentRunDataAggregator = new ParallelRunDataAggregator(_actualTestRunCriteria.TestRunSettings); - private ParallelRunEventsHandler GetEventsHandler(IProxyExecutionManager concurrentManager) + foreach (var concurrentManager in GetConcurrentManagerInstances()) { - if (concurrentManager is ProxyExecutionManagerWithDataCollection) - { - var concurrentManagerWithDataCollection = concurrentManager as ProxyExecutionManagerWithDataCollection; - var attachmentsProcessingManager = new TestRunAttachmentsProcessingManager(TestPlatformEventSource.Instance, new DataCollectorAttachmentsProcessorsFactory()); - - return new ParallelDataCollectionEventsHandler( - this.requestData, - concurrentManagerWithDataCollection, - this.currentRunEventsHandler, - this, - this.currentRunDataAggregator, - attachmentsProcessingManager, - concurrentManagerWithDataCollection.CancellationToken); - } + var parallelEventsHandler = GetEventsHandler(concurrentManager); + UpdateHandlerForManager(concurrentManager, parallelEventsHandler); + StartTestRunOnConcurrentManager(concurrentManager); + } - return new ParallelRunEventsHandler( - this.requestData, - concurrentManager, - this.currentRunEventsHandler, - this, - this.currentRunDataAggregator); + return 1; + } + + private ParallelRunEventsHandler GetEventsHandler(IProxyExecutionManager concurrentManager) + { + if (concurrentManager is ProxyExecutionManagerWithDataCollection) + { + var concurrentManagerWithDataCollection = concurrentManager as ProxyExecutionManagerWithDataCollection; + var attachmentsProcessingManager = new TestRunAttachmentsProcessingManager(TestPlatformEventSource.Instance, new DataCollectorAttachmentsProcessorsFactory()); + + return new ParallelDataCollectionEventsHandler( + _requestData, + concurrentManagerWithDataCollection, + _currentRunEventsHandler, + this, + _currentRunDataAggregator, + attachmentsProcessingManager, + concurrentManagerWithDataCollection.CancellationToken); } - /// - /// Triggers the execution for the next data object on the concurrent executor - /// Each concurrent executor calls this method, once its completed working on previous data - /// - /// Proxy execution manager instance. - /// True, if execution triggered - private void StartTestRunOnConcurrentManager(IProxyExecutionManager proxyExecutionManager) + return new ParallelRunEventsHandler( + _requestData, + concurrentManager, + _currentRunEventsHandler, + this, + _currentRunDataAggregator); + } + + /// + /// Triggers the execution for the next data object on the concurrent executor + /// Each concurrent executor calls this method, once its completed working on previous data + /// + /// Proxy execution manager instance. + /// True, if execution triggered + private void StartTestRunOnConcurrentManager(IProxyExecutionManager proxyExecutionManager) + { + TestRunCriteria testRunCriteria = null; + if (!_hasSpecificTestsRun) { - TestRunCriteria testRunCriteria = null; - if (!this.hasSpecificTestsRun) + if (TryFetchNextSource(_sourceEnumerator, out string nextSource)) { - if (this.TryFetchNextSource(this.sourceEnumerator, out string nextSource)) - { - EqtTrace.Info("ProxyParallelExecutionManager: Triggering test run for next source: {0}", nextSource); - testRunCriteria = new TestRunCriteria(new[] { nextSource }, this.actualTestRunCriteria); - } + EqtTrace.Info("ProxyParallelExecutionManager: Triggering test run for next source: {0}", nextSource); + testRunCriteria = new TestRunCriteria(new[] { nextSource }, _actualTestRunCriteria); } - else + } + else + { + if (TryFetchNextSource(_testCaseListEnumerator, out List nextSetOfTests)) { - if (this.TryFetchNextSource(this.testCaseListEnumerator, out List nextSetOfTests)) - { - EqtTrace.Info("ProxyParallelExecutionManager: Triggering test run for next source: {0}", nextSetOfTests?.FirstOrDefault()?.Source); - testRunCriteria = new TestRunCriteria(nextSetOfTests, this.actualTestRunCriteria); - } + EqtTrace.Info("ProxyParallelExecutionManager: Triggering test run for next source: {0}", nextSetOfTests?.FirstOrDefault()?.Source); + testRunCriteria = new TestRunCriteria(nextSetOfTests, _actualTestRunCriteria); } + } - if (testRunCriteria != null) + if (testRunCriteria != null) + { + if (!proxyExecutionManager.IsInitialized) { - if (!proxyExecutionManager.IsInitialized) - { - proxyExecutionManager.Initialize(this.skipDefaultAdapters); - } + proxyExecutionManager.Initialize(_skipDefaultAdapters); + } - Task.Run(() => + Task.Run(() => { - Interlocked.Increment(ref this.runStartedClients); + Interlocked.Increment(ref _runStartedClients); if (EqtTrace.IsVerboseEnabled) { - EqtTrace.Verbose("ParallelProxyExecutionManager: Execution started. Started clients: " + this.runStartedClients); + EqtTrace.Verbose("ParallelProxyExecutionManager: Execution started. Started clients: " + _runStartedClients); } - proxyExecutionManager.StartTestRun(testRunCriteria, this.GetHandlerForGivenManager(proxyExecutionManager)); + proxyExecutionManager.StartTestRun(testRunCriteria, GetHandlerForGivenManager(proxyExecutionManager)); }) .ContinueWith(t => - { - // Just in case, the actual execution couldn't start for an instance. Ensure that - // we call execution complete since we have already fetched a source. Otherwise - // execution will not terminate - if (EqtTrace.IsErrorEnabled) { - EqtTrace.Error("ParallelProxyExecutionManager: Failed to trigger execution. Exception: " + t.Exception); - } - - var handler = this.GetHandlerForGivenManager(proxyExecutionManager); - var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = t.Exception.ToString() }; - handler.HandleRawMessage(this.dataSerializer.SerializePayload(MessageType.TestMessage, testMessagePayload)); - handler.HandleLogMessage(TestMessageLevel.Error, t.Exception.ToString()); - - // Send a run complete to caller. Similar logic is also used in ProxyExecutionManager.StartTestRun - // Differences: - // Aborted is sent to allow the current execution manager replaced with another instance - // Ensure that the test run aggregator in parallel run events handler doesn't add these statistics - // (since the test run didn't even start) - var completeArgs = new TestRunCompleteEventArgs(null, false, true, null, new Collection(), new Collection(), TimeSpan.Zero); - handler.HandleTestRunComplete(completeArgs, null, null, null); - }, - TaskContinuationOptions.OnlyOnFaulted); - } + // Just in case, the actual execution couldn't start for an instance. Ensure that + // we call execution complete since we have already fetched a source. Otherwise + // execution will not terminate + if (EqtTrace.IsErrorEnabled) + { + EqtTrace.Error("ParallelProxyExecutionManager: Failed to trigger execution. Exception: " + t.Exception); + } + + var handler = GetHandlerForGivenManager(proxyExecutionManager); + var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = t.Exception.ToString() }; + handler.HandleRawMessage(_dataSerializer.SerializePayload(MessageType.TestMessage, testMessagePayload)); + handler.HandleLogMessage(TestMessageLevel.Error, t.Exception.ToString()); + + // Send a run complete to caller. Similar logic is also used in ProxyExecutionManager.StartTestRun + // Differences: + // Aborted is sent to allow the current execution manager replaced with another instance + // Ensure that the test run aggregator in parallel run events handler doesn't add these statistics + // (since the test run didn't even start) + var completeArgs = new TestRunCompleteEventArgs(null, false, true, null, new Collection(), new Collection(), TimeSpan.Zero); + handler.HandleTestRunComplete(completeArgs, null, null, null); + }, + TaskContinuationOptions.OnlyOnFaulted); + } - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("ProxyParallelExecutionManager: No sources available for execution."); - } + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("ProxyParallelExecutionManager: No sources available for execution."); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelRunDataAggregator.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelRunDataAggregator.cs index eda28500fa..5323aa0f5a 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelRunDataAggregator.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelRunDataAggregator.cs @@ -1,215 +1,211 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; + +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; + +using Common.Telemetry; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +/// +/// ParallelRunDataAggregator aggregates test run data from execution managers running in parallel +/// +internal class ParallelRunDataAggregator { - using System; - using System.Collections.Concurrent; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Linq; + #region PrivateFields - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - /// - /// ParallelRunDataAggregator aggregates test run data from execution managers running in parallel - /// - internal class ParallelRunDataAggregator - { - #region PrivateFields - - private readonly string runSettingsXml; + private readonly List _executorUris; - private List executorUris; + private readonly List _testRunStatsList; - private List testRunStatsList; + private readonly ConcurrentDictionary _metricsAggregator; - private ConcurrentDictionary metricsAggregator; + private readonly object _dataUpdateSyncObject = new(); - private object dataUpdateSyncObject = new object(); + #endregion - #endregion - - public ParallelRunDataAggregator(string runSettingsXml) - { - this.runSettingsXml = runSettingsXml ?? throw new ArgumentNullException(nameof(runSettingsXml)); - ElapsedTime = TimeSpan.Zero; - RunContextAttachments = new Collection(); - RunCompleteArgsAttachments = new List(); - InvokedDataCollectors = new Collection(); - Exceptions = new List(); - executorUris = new List(); - testRunStatsList = new List(); - - metricsAggregator = new ConcurrentDictionary(); - - IsAborted = false; - IsCanceled = false; - } + public ParallelRunDataAggregator(string runSettingsXml) + { + RunSettings = runSettingsXml ?? throw new ArgumentNullException(nameof(runSettingsXml)); + ElapsedTime = TimeSpan.Zero; + RunContextAttachments = new Collection(); + RunCompleteArgsAttachments = new List(); + InvokedDataCollectors = new Collection(); + Exceptions = new List(); + _executorUris = new List(); + _testRunStatsList = new List(); + + _metricsAggregator = new ConcurrentDictionary(); + + IsAborted = false; + IsCanceled = false; + } - #region Public Properties + #region Public Properties - public TimeSpan ElapsedTime { get; set; } + public TimeSpan ElapsedTime { get; set; } - public Collection RunContextAttachments { get; set; } + public Collection RunContextAttachments { get; set; } - public List RunCompleteArgsAttachments { get; } + public List RunCompleteArgsAttachments { get; } - public Collection InvokedDataCollectors { get; set; } + public Collection InvokedDataCollectors { get; set; } - public List Exceptions { get; } + public List Exceptions { get; } - public HashSet ExecutorUris => new HashSet(executorUris); + public HashSet ExecutorUris => new(_executorUris); - public bool IsAborted { get; private set; } + public bool IsAborted { get; private set; } - public bool IsCanceled { get; private set; } + public bool IsCanceled { get; private set; } - public string RunSettings => this.runSettingsXml; + public string RunSettings { get; private set; } - #endregion + #endregion - #region Public Methods + #region Public Methods - public ITestRunStatistics GetAggregatedRunStats() + public ITestRunStatistics GetAggregatedRunStats() + { + var testOutcomeMap = new Dictionary(); + long totalTests = 0; + if (_testRunStatsList.Count > 0) { - var testOutcomeMap = new Dictionary(); - long totalTests = 0; - if (testRunStatsList.Count > 0) + foreach (var runStats in _testRunStatsList) { - foreach (var runStats in testRunStatsList) + foreach (var outcome in runStats.Stats.Keys) { - foreach (var outcome in runStats.Stats.Keys) + if (!testOutcomeMap.ContainsKey(outcome)) { - if (!testOutcomeMap.ContainsKey(outcome)) - { - testOutcomeMap.Add(outcome, 0); - } - testOutcomeMap[outcome] += runStats.Stats[outcome]; + testOutcomeMap.Add(outcome, 0); } - totalTests += runStats.ExecutedTests; + testOutcomeMap[outcome] += runStats.Stats[outcome]; } + totalTests += runStats.ExecutedTests; } - - var overallRunStats = new TestRunStatistics(testOutcomeMap); - overallRunStats.ExecutedTests = totalTests; - return overallRunStats; } - /// - /// Returns the Aggregated Run Data Metrics - /// - /// - public IDictionary GetAggregatedRunDataMetrics() - { - if (this.metricsAggregator == null || this.metricsAggregator.Count == 0) - { - return new ConcurrentDictionary(); - } + var overallRunStats = new TestRunStatistics(testOutcomeMap); + overallRunStats.ExecutedTests = totalTests; + return overallRunStats; + } - var adapterUsedCount = this.metricsAggregator.Count(metrics => - metrics.Key.Contains(TelemetryDataConstants.TotalTestsRanByAdapter)); + /// + /// Returns the Aggregated Run Data Metrics + /// + /// + public IDictionary GetAggregatedRunDataMetrics() + { + if (_metricsAggregator == null || _metricsAggregator.Count == 0) + { + return new ConcurrentDictionary(); + } - var adaptersDiscoveredCount = this.metricsAggregator.Count(metrics => - metrics.Key.Contains(TelemetryDataConstants.TimeTakenToRunTestsByAnAdapter)); + var adapterUsedCount = _metricsAggregator.Count(metrics => + metrics.Key.Contains(TelemetryDataConstants.TotalTestsRanByAdapter)); - // Aggregating Total Adapter Used Count - this.metricsAggregator.TryAdd(TelemetryDataConstants.NumberOfAdapterUsedToRunTests, adapterUsedCount); + var adaptersDiscoveredCount = _metricsAggregator.Count(metrics => + metrics.Key.Contains(TelemetryDataConstants.TimeTakenToRunTestsByAnAdapter)); - // Aggregating Total Adapters Discovered Count - this.metricsAggregator.TryAdd( - TelemetryDataConstants.NumberOfAdapterDiscoveredDuringExecution, - adaptersDiscoveredCount); + // Aggregating Total Adapter Used Count + _metricsAggregator.TryAdd(TelemetryDataConstants.NumberOfAdapterUsedToRunTests, adapterUsedCount); - return this.metricsAggregator; - } + // Aggregating Total Adapters Discovered Count + _metricsAggregator.TryAdd( + TelemetryDataConstants.NumberOfAdapterDiscoveredDuringExecution, + adaptersDiscoveredCount); - public Exception GetAggregatedException() - { - if (Exceptions == null || Exceptions.Count < 1) return null; + return _metricsAggregator; + } - return new AggregateException(Exceptions); - } + public Exception GetAggregatedException() + { + return Exceptions == null || Exceptions.Count < 1 ? null : (Exception)new AggregateException(Exceptions); + } - /// - /// Aggregate Run Data - /// Must be thread-safe as this is expected to be called by parallel managers - /// - public void Aggregate( - ITestRunStatistics testRunStats, - ICollection executorUris, - Exception exception, - TimeSpan elapsedTime, - bool isAborted, - bool isCanceled, - ICollection runContextAttachments, - Collection runCompleteArgsAttachments, - Collection invokedDataCollectors) + /// + /// Aggregate Run Data + /// Must be thread-safe as this is expected to be called by parallel managers + /// + public void Aggregate( + ITestRunStatistics testRunStats, + ICollection executorUris, + Exception exception, + TimeSpan elapsedTime, + bool isAborted, + bool isCanceled, + ICollection runContextAttachments, + Collection runCompleteArgsAttachments, + Collection invokedDataCollectors) + { + lock (_dataUpdateSyncObject) { - lock (dataUpdateSyncObject) - { - this.IsAborted = this.IsAborted || isAborted; - this.IsCanceled = this.IsCanceled || isCanceled; + IsAborted = IsAborted || isAborted; + IsCanceled = IsCanceled || isCanceled; - ElapsedTime = TimeSpan.FromMilliseconds(Math.Max(ElapsedTime.TotalMilliseconds, elapsedTime.TotalMilliseconds)); - if (runContextAttachments != null) + ElapsedTime = TimeSpan.FromMilliseconds(Math.Max(ElapsedTime.TotalMilliseconds, elapsedTime.TotalMilliseconds)); + if (runContextAttachments != null) + { + foreach (var attachmentSet in runContextAttachments) { - foreach (var attachmentSet in runContextAttachments) - { - RunContextAttachments.Add(attachmentSet); - } + RunContextAttachments.Add(attachmentSet); } + } - if (runCompleteArgsAttachments != null) RunCompleteArgsAttachments.AddRange(runCompleteArgsAttachments); - if (exception != null) Exceptions.Add(exception); - if (executorUris != null) this.executorUris.AddRange(executorUris); - if (testRunStats != null) testRunStatsList.Add(testRunStats); + if (runCompleteArgsAttachments != null) RunCompleteArgsAttachments.AddRange(runCompleteArgsAttachments); + if (exception != null) Exceptions.Add(exception); + if (executorUris != null) _executorUris.AddRange(executorUris); + if (testRunStats != null) _testRunStatsList.Add(testRunStats); - if (invokedDataCollectors?.Count > 0) + if (invokedDataCollectors?.Count > 0) + { + foreach (var invokedDataCollector in invokedDataCollectors) { - foreach (var invokedDataCollector in invokedDataCollectors) + if (!InvokedDataCollectors.Contains(invokedDataCollector)) { - if (!this.InvokedDataCollectors.Contains(invokedDataCollector)) - { - this.InvokedDataCollectors.Add(invokedDataCollector); - } + InvokedDataCollectors.Add(invokedDataCollector); } } } } + } - /// - /// Aggregates Run Data Metrics from each Test Host Process - /// - /// - public void AggregateRunDataMetrics(IDictionary metrics) + /// + /// Aggregates Run Data Metrics from each Test Host Process + /// + /// + public void AggregateRunDataMetrics(IDictionary metrics) + { + if (metrics == null || metrics.Count == 0 || _metricsAggregator == null) { - if (metrics == null || metrics.Count == 0 || this.metricsAggregator == null) - { - return; - } + return; + } - foreach (var metric in metrics) + foreach (var metric in metrics) + { + if (metric.Key.Contains(TelemetryDataConstants.TimeTakenToRunTestsByAnAdapter) || metric.Key.Contains(TelemetryDataConstants.TimeTakenByAllAdaptersInSec) || (metric.Key.Contains(TelemetryDataConstants.TotalTestsRun) || metric.Key.Contains(TelemetryDataConstants.TotalTestsRanByAdapter))) { - if (metric.Key.Contains(TelemetryDataConstants.TimeTakenToRunTestsByAnAdapter) || metric.Key.Contains(TelemetryDataConstants.TimeTakenByAllAdaptersInSec) || (metric.Key.Contains(TelemetryDataConstants.TotalTestsRun) || metric.Key.Contains(TelemetryDataConstants.TotalTestsRanByAdapter))) - { - var newValue = Convert.ToDouble(metric.Value); + var newValue = Convert.ToDouble(metric.Value); - if (this.metricsAggregator.TryGetValue(metric.Key, out var oldValue)) - { - var oldDoubleValue = Convert.ToDouble(oldValue); - this.metricsAggregator[metric.Key] = newValue + oldDoubleValue; - } - else - { - this.metricsAggregator.TryAdd(metric.Key, newValue); - } + if (_metricsAggregator.TryGetValue(metric.Key, out var oldValue)) + { + var oldDoubleValue = Convert.ToDouble(oldValue); + _metricsAggregator[metric.Key] = newValue + oldDoubleValue; + } + else + { + _metricsAggregator.TryAdd(metric.Key, newValue); } } } - - #endregion } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelRunEventsHandler.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelRunEventsHandler.cs index 896f488b6e..bfbafa7b3d 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelRunEventsHandler.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelRunEventsHandler.cs @@ -1,191 +1,188 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +using Common.Telemetry; +using CommunicationUtilities; +using CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; +using ObjectModel.Logging; + +/// +/// ParallelRunEventsHandler for handling the run events in case of parallel execution +/// +internal class ParallelRunEventsHandler : ITestRunEventsHandler2 { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Globalization; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + private readonly IProxyExecutionManager _proxyExecutionManager; - /// - /// ParallelRunEventsHandler for handling the run events in case of parallel execution - /// - internal class ParallelRunEventsHandler : ITestRunEventsHandler2 - { - private IProxyExecutionManager proxyExecutionManager; + private readonly ITestRunEventsHandler _actualRunEventsHandler; - private ITestRunEventsHandler actualRunEventsHandler; + private readonly IParallelProxyExecutionManager _parallelProxyExecutionManager; - private IParallelProxyExecutionManager parallelProxyExecutionManager; + private readonly ParallelRunDataAggregator _runDataAggregator; - private ParallelRunDataAggregator runDataAggregator; + private readonly IDataSerializer _dataSerializer; - private IDataSerializer dataSerializer; + protected IRequestData _requestData; - protected IRequestData requestData; + public ParallelRunEventsHandler(IRequestData requestData, + IProxyExecutionManager proxyExecutionManager, + ITestRunEventsHandler actualRunEventsHandler, + IParallelProxyExecutionManager parallelProxyExecutionManager, + ParallelRunDataAggregator runDataAggregator) : + this(requestData, proxyExecutionManager, actualRunEventsHandler, parallelProxyExecutionManager, runDataAggregator, JsonDataSerializer.Instance) + { + } - public ParallelRunEventsHandler(IRequestData requestData, - IProxyExecutionManager proxyExecutionManager, - ITestRunEventsHandler actualRunEventsHandler, - IParallelProxyExecutionManager parallelProxyExecutionManager, - ParallelRunDataAggregator runDataAggregator) : - this(requestData, proxyExecutionManager, actualRunEventsHandler, parallelProxyExecutionManager, runDataAggregator, JsonDataSerializer.Instance) - { - } + internal ParallelRunEventsHandler(IRequestData requestData, + IProxyExecutionManager proxyExecutionManager, + ITestRunEventsHandler actualRunEventsHandler, + IParallelProxyExecutionManager parallelProxyExecutionManager, + ParallelRunDataAggregator runDataAggregator, + IDataSerializer dataSerializer) + { + _proxyExecutionManager = proxyExecutionManager; + _actualRunEventsHandler = actualRunEventsHandler; + _parallelProxyExecutionManager = parallelProxyExecutionManager; + _runDataAggregator = runDataAggregator; + _dataSerializer = dataSerializer; + _requestData = requestData; + } - internal ParallelRunEventsHandler(IRequestData requestData, - IProxyExecutionManager proxyExecutionManager, - ITestRunEventsHandler actualRunEventsHandler, - IParallelProxyExecutionManager parallelProxyExecutionManager, - ParallelRunDataAggregator runDataAggregator, - IDataSerializer dataSerializer) - { - this.proxyExecutionManager = proxyExecutionManager; - this.actualRunEventsHandler = actualRunEventsHandler; - this.parallelProxyExecutionManager = parallelProxyExecutionManager; - this.runDataAggregator = runDataAggregator; - this.dataSerializer = dataSerializer; - this.requestData = requestData; - } + /// + /// Handles the Run Complete event from a parallel proxy manager + /// + public virtual void HandleTestRunComplete( + TestRunCompleteEventArgs testRunCompleteArgs, + TestRunChangedEventArgs lastChunkArgs, + ICollection runContextAttachments, + ICollection executorUris) + { + var parallelRunComplete = HandleSingleTestRunComplete(testRunCompleteArgs, lastChunkArgs, runContextAttachments, executorUris); - /// - /// Handles the Run Complete event from a parallel proxy manager - /// - public virtual void HandleTestRunComplete( - TestRunCompleteEventArgs testRunCompleteArgs, - TestRunChangedEventArgs lastChunkArgs, - ICollection runContextAttachments, - ICollection executorUris) + if (parallelRunComplete) { - var parallelRunComplete = HandleSingleTestRunComplete(testRunCompleteArgs, lastChunkArgs, runContextAttachments, executorUris); - - if (parallelRunComplete) - { - var completedArgs = new TestRunCompleteEventArgs(this.runDataAggregator.GetAggregatedRunStats(), - this.runDataAggregator.IsCanceled, - this.runDataAggregator.IsAborted, - this.runDataAggregator.GetAggregatedException(), - new Collection(this.runDataAggregator.RunCompleteArgsAttachments), - new Collection(this.runDataAggregator.InvokedDataCollectors), - this.runDataAggregator.ElapsedTime); - - // Collect Final RunState - this.requestData.MetricsCollection.Add(TelemetryDataConstants.RunState, this.runDataAggregator.IsAborted ? "Aborted" : this.runDataAggregator.IsCanceled ? "Canceled" : "Completed"); - - // Collect Aggregated Metrics Data - var aggregatedRunDataMetrics = runDataAggregator.GetAggregatedRunDataMetrics(); - - completedArgs.Metrics = aggregatedRunDataMetrics; - HandleParallelTestRunComplete(completedArgs); - } + var completedArgs = new TestRunCompleteEventArgs(_runDataAggregator.GetAggregatedRunStats(), + _runDataAggregator.IsCanceled, + _runDataAggregator.IsAborted, + _runDataAggregator.GetAggregatedException(), + new Collection(_runDataAggregator.RunCompleteArgsAttachments), + new Collection(_runDataAggregator.InvokedDataCollectors), + _runDataAggregator.ElapsedTime); + + // Collect Final RunState + _requestData.MetricsCollection.Add(TelemetryDataConstants.RunState, _runDataAggregator.IsAborted ? "Aborted" : _runDataAggregator.IsCanceled ? "Canceled" : "Completed"); + + // Collect Aggregated Metrics Data + var aggregatedRunDataMetrics = _runDataAggregator.GetAggregatedRunDataMetrics(); + + completedArgs.Metrics = aggregatedRunDataMetrics; + HandleParallelTestRunComplete(completedArgs); } + } - protected bool HandleSingleTestRunComplete(TestRunCompleteEventArgs testRunCompleteArgs, - TestRunChangedEventArgs lastChunkArgs, - ICollection runContextAttachments, - ICollection executorUris) + protected bool HandleSingleTestRunComplete(TestRunCompleteEventArgs testRunCompleteArgs, + TestRunChangedEventArgs lastChunkArgs, + ICollection runContextAttachments, + ICollection executorUris) + { + // we get run complete events from each executor process + // so we cannot "complete" the actual executor operation until all sources/testcases are consumed + // We should not block last chunk results while we aggregate overall run data + if (lastChunkArgs != null) { - // we get run complete events from each executor process - // so we cannot "complete" the actual executor operation until all sources/testcases are consumed - // We should not block last chunk results while we aggregate overall run data - if (lastChunkArgs != null) - { - ConvertToRawMessageAndSend(MessageType.TestRunStatsChange, lastChunkArgs); - HandleTestRunStatsChange(lastChunkArgs); - } - - // Update run stats, executorUris, etc. - // we need this data when we send the final run complete - this.runDataAggregator.Aggregate( - testRunCompleteArgs.TestRunStatistics, - executorUris, - testRunCompleteArgs.Error, - testRunCompleteArgs.ElapsedTimeInRunningTests, - testRunCompleteArgs.IsAborted, - testRunCompleteArgs.IsCanceled, - runContextAttachments, - testRunCompleteArgs.AttachmentSets, - testRunCompleteArgs.InvokedDataCollectors); - - // Aggregate Run Data Metrics - this.runDataAggregator.AggregateRunDataMetrics(testRunCompleteArgs.Metrics); - - return this.parallelProxyExecutionManager.HandlePartialRunComplete( - this.proxyExecutionManager, - testRunCompleteArgs, - null, // lastChunk should be null as we already sent this data above - runContextAttachments, - executorUris); + ConvertToRawMessageAndSend(MessageType.TestRunStatsChange, lastChunkArgs); + HandleTestRunStatsChange(lastChunkArgs); } - protected void HandleParallelTestRunComplete(TestRunCompleteEventArgs completedArgs) - { - // In case of sequential execution - RawMessage would have contained a 'TestRunCompletePayload' object - // To send a rawmessge - we need to create rawmessage from an aggregated payload object - var testRunCompletePayload = new TestRunCompletePayload() - { - ExecutorUris = this.runDataAggregator.ExecutorUris, - LastRunTests = null, - RunAttachments = this.runDataAggregator.RunContextAttachments, - TestRunCompleteArgs = completedArgs - }; - - // we have to send rawmessages as we block the run complete actual raw messages - ConvertToRawMessageAndSend(MessageType.ExecutionComplete, testRunCompletePayload); - - // send actual test run complete to clients - this.actualRunEventsHandler.HandleTestRunComplete( - completedArgs, null, this.runDataAggregator.RunContextAttachments, this.runDataAggregator.ExecutorUris); - } + // Update run stats, executorUris, etc. + // we need this data when we send the final run complete + _runDataAggregator.Aggregate( + testRunCompleteArgs.TestRunStatistics, + executorUris, + testRunCompleteArgs.Error, + testRunCompleteArgs.ElapsedTimeInRunningTests, + testRunCompleteArgs.IsAborted, + testRunCompleteArgs.IsCanceled, + runContextAttachments, + testRunCompleteArgs.AttachmentSets, + testRunCompleteArgs.InvokedDataCollectors); + + // Aggregate Run Data Metrics + _runDataAggregator.AggregateRunDataMetrics(testRunCompleteArgs.Metrics); + + return _parallelProxyExecutionManager.HandlePartialRunComplete( + _proxyExecutionManager, + testRunCompleteArgs, + null, // lastChunk should be null as we already sent this data above + runContextAttachments, + executorUris); + } - public void HandleRawMessage(string rawMessage) + protected void HandleParallelTestRunComplete(TestRunCompleteEventArgs completedArgs) + { + // In case of sequential execution - RawMessage would have contained a 'TestRunCompletePayload' object + // To send a rawmessge - we need to create rawmessage from an aggregated payload object + var testRunCompletePayload = new TestRunCompletePayload() { - // In case of parallel - we can send everything but handle complete - // HandleComplete is not true-end of the overall execution as we only get completion of one executor here - // Always aggregate data, deserialize and raw for complete events - var message = this.dataSerializer.DeserializeMessage(rawMessage); - - // Do not deserialize further - just send if not execution complete - if (!string.Equals(MessageType.ExecutionComplete, message.MessageType)) - { - this.actualRunEventsHandler.HandleRawMessage(rawMessage); - } - } + ExecutorUris = _runDataAggregator.ExecutorUris, + LastRunTests = null, + RunAttachments = _runDataAggregator.RunContextAttachments, + TestRunCompleteArgs = completedArgs + }; + + // we have to send rawmessages as we block the run complete actual raw messages + ConvertToRawMessageAndSend(MessageType.ExecutionComplete, testRunCompletePayload); + + // send actual test run complete to clients + _actualRunEventsHandler.HandleTestRunComplete( + completedArgs, null, _runDataAggregator.RunContextAttachments, _runDataAggregator.ExecutorUris); + } - public void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChangedArgs) - { - this.actualRunEventsHandler.HandleTestRunStatsChange(testRunChangedArgs); - } + public void HandleRawMessage(string rawMessage) + { + // In case of parallel - we can send everything but handle complete + // HandleComplete is not true-end of the overall execution as we only get completion of one executor here + // Always aggregate data, deserialize and raw for complete events + var message = _dataSerializer.DeserializeMessage(rawMessage); - public void HandleLogMessage(TestMessageLevel level, string message) + // Do not deserialize further - just send if not execution complete + if (!string.Equals(MessageType.ExecutionComplete, message.MessageType)) { - this.actualRunEventsHandler.HandleLogMessage(level, message); + _actualRunEventsHandler.HandleRawMessage(rawMessage); } + } - public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) - { - return this.actualRunEventsHandler.LaunchProcessWithDebuggerAttached(testProcessStartInfo); - } + public void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChangedArgs) + { + _actualRunEventsHandler.HandleTestRunStatsChange(testRunChangedArgs); + } - /// - public bool AttachDebuggerToProcess(int pid) - { - return ((ITestRunEventsHandler2)this.actualRunEventsHandler).AttachDebuggerToProcess(pid); - } + public void HandleLogMessage(TestMessageLevel level, string message) + { + _actualRunEventsHandler.HandleLogMessage(level, message); + } - private void ConvertToRawMessageAndSend(string messageType, object payload) - { - var rawMessage = this.dataSerializer.SerializePayload(messageType, payload); - this.actualRunEventsHandler.HandleRawMessage(rawMessage); - } + public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) + { + return _actualRunEventsHandler.LaunchProcessWithDebuggerAttached(testProcessStartInfo); + } + + /// + public bool AttachDebuggerToProcess(int pid) + { + return ((ITestRunEventsHandler2)_actualRunEventsHandler).AttachDebuggerToProcess(pid); + } + + private void ConvertToRawMessageAndSend(string messageType, object payload) + { + var rawMessage = _dataSerializer.SerializePayload(messageType, payload); + _actualRunEventsHandler.HandleRawMessage(rawMessage); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyDiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyDiscoveryManager.cs index c8d85fa1b8..25f27a88b9 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyDiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyDiscoveryManager.cs @@ -1,298 +1,296 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; + +using System; +using System.Collections.Generic; +using System.Linq; + +using Common; +using Common.ExtensionFramework; +using CommunicationUtilities; +using CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; +using ObjectModel.Host; +using ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +/// +/// Orchestrates discovery operations for the engine communicating with the client. +/// +public class ProxyDiscoveryManager : IProxyDiscoveryManager, IBaseProxy, ITestDiscoveryEventsHandler2 { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading; - - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + private readonly TestSessionInfo _testSessionInfo = null; + readonly Func _proxyOperationManagerCreator; + + private ITestRuntimeProvider _testHostManager; + private IRequestData _requestData; + + private readonly IFileHelper _fileHelper; + private readonly IDataSerializer _dataSerializer; + private bool _isCommunicationEstablished; + + private ProxyOperationManager _proxyOperationManager = null; + private ITestDiscoveryEventsHandler2 _baseTestDiscoveryEventsHandler; + private bool _skipDefaultAdapters; + + #region Constructors /// - /// Orchestrates discovery operations for the engine communicating with the client. + /// Initializes a new instance of the class. /// - public class ProxyDiscoveryManager : IProxyDiscoveryManager, IBaseProxy, ITestDiscoveryEventsHandler2 + /// + /// The test session info. + /// The proxy operation manager creator. + public ProxyDiscoveryManager( + TestSessionInfo testSessionInfo, + Func proxyOperationManagerCreator) { - private readonly TestSessionInfo testSessionInfo = null; - Func proxyOperationManagerCreator; - - private ITestRuntimeProvider testHostManager; - private IRequestData requestData; - - private readonly IFileHelper fileHelper; - private readonly IDataSerializer dataSerializer; - private bool isCommunicationEstablished; - - private ProxyOperationManager proxyOperationManager = null; - private ITestDiscoveryEventsHandler2 baseTestDiscoveryEventsHandler; - private bool skipDefaultAdapters; - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// - /// The test session info. - /// The proxy operation manager creator. - public ProxyDiscoveryManager( - TestSessionInfo testSessionInfo, - Func proxyOperationManagerCreator) - { - // Filling in test session info and proxy information. - this.testSessionInfo = testSessionInfo; - this.proxyOperationManagerCreator = proxyOperationManagerCreator; - - this.requestData = null; - this.testHostManager = null; - this.dataSerializer = JsonDataSerializer.Instance; - this.fileHelper = new FileHelper(); - this.isCommunicationEstablished = false; - } + // Filling in test session info and proxy information. + _testSessionInfo = testSessionInfo; + _proxyOperationManagerCreator = proxyOperationManagerCreator; + + _requestData = null; + _testHostManager = null; + _dataSerializer = JsonDataSerializer.Instance; + _fileHelper = new FileHelper(); + _isCommunicationEstablished = false; + } - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// The request data for providing discovery services and data. - /// - /// Test request sender instance. - /// Test host manager instance. - public ProxyDiscoveryManager( - IRequestData requestData, - ITestRequestSender testRequestSender, - ITestRuntimeProvider testHostManager) - : this( - requestData, - testRequestSender, - testHostManager, - JsonDataSerializer.Instance, - new FileHelper()) - { } - - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// Constructor with dependency injection. Used for unit testing. - /// - /// - /// - /// The request data for providing discovery services and data. - /// - /// The request sender. - /// Test host manager instance. - /// The data serializer. - /// The file helper. - internal ProxyDiscoveryManager( - IRequestData requestData, - ITestRequestSender requestSender, - ITestRuntimeProvider testHostManager, - IDataSerializer dataSerializer, - IFileHelper fileHelper) - { - this.requestData = requestData; - this.testHostManager = testHostManager; + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// The request data for providing discovery services and data. + /// + /// Test request sender instance. + /// Test host manager instance. + public ProxyDiscoveryManager( + IRequestData requestData, + ITestRequestSender testRequestSender, + ITestRuntimeProvider testHostManager) + : this( + requestData, + testRequestSender, + testHostManager, + JsonDataSerializer.Instance, + new FileHelper()) + { } - this.dataSerializer = dataSerializer; - this.fileHelper = fileHelper; - this.isCommunicationEstablished = false; + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// Constructor with dependency injection. Used for unit testing. + /// + /// + /// + /// The request data for providing discovery services and data. + /// + /// The request sender. + /// Test host manager instance. + /// The data serializer. + /// The file helper. + internal ProxyDiscoveryManager( + IRequestData requestData, + ITestRequestSender requestSender, + ITestRuntimeProvider testHostManager, + IDataSerializer dataSerializer, + IFileHelper fileHelper) + { + _requestData = requestData; + _testHostManager = testHostManager; - // Create a new proxy operation manager. - this.proxyOperationManager = new ProxyOperationManager(requestData, requestSender, testHostManager, this); - } + _dataSerializer = dataSerializer; + _fileHelper = fileHelper; + _isCommunicationEstablished = false; - #endregion + // Create a new proxy operation manager. + _proxyOperationManager = new ProxyOperationManager(requestData, requestSender, testHostManager, this); + } - #region IProxyDiscoveryManager implementation. + #endregion + + #region IProxyDiscoveryManager implementation. + + /// + public void Initialize(bool skipDefaultAdapters) + { + _skipDefaultAdapters = skipDefaultAdapters; + } - /// - public void Initialize(bool skipDefaultAdapters) + /// + public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler) + { + if (_proxyOperationManager == null) { - this.skipDefaultAdapters = skipDefaultAdapters; + _proxyOperationManager = _proxyOperationManagerCreator( + discoveryCriteria.Sources.First(), + this); + + _testHostManager = _proxyOperationManager.TestHostManager; + _requestData = _proxyOperationManager.RequestData; } - /// - public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler) + _baseTestDiscoveryEventsHandler = eventHandler; + try { - if (this.proxyOperationManager == null) - { - this.proxyOperationManager = this.proxyOperationManagerCreator( - discoveryCriteria.Sources.First(), - this); - - this.testHostManager = this.proxyOperationManager.TestHostManager; - this.requestData = this.proxyOperationManager.RequestData; - } + _isCommunicationEstablished = _proxyOperationManager.SetupChannel(discoveryCriteria.Sources, discoveryCriteria.RunSettings); - this.baseTestDiscoveryEventsHandler = eventHandler; - try + if (_isCommunicationEstablished) { - this.isCommunicationEstablished = this.proxyOperationManager.SetupChannel(discoveryCriteria.Sources, discoveryCriteria.RunSettings); + InitializeExtensions(discoveryCriteria.Sources); + discoveryCriteria.UpdateDiscoveryCriteria(_testHostManager); - if (this.isCommunicationEstablished) - { - this.InitializeExtensions(discoveryCriteria.Sources); - discoveryCriteria.UpdateDiscoveryCriteria(testHostManager); - - this.proxyOperationManager.RequestSender.DiscoverTests(discoveryCriteria, this); - } - } - catch (Exception exception) - { - EqtTrace.Error("ProxyDiscoveryManager.DiscoverTests: Failed to discover tests: {0}", exception); - - // Log to vs ide test output - var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = exception.ToString() }; - var rawMessage = this.dataSerializer.SerializePayload(MessageType.TestMessage, testMessagePayload); - this.HandleRawMessage(rawMessage); - - // Log to vstest.console - // Send a discovery complete to caller. Similar logic is also used in ParallelProxyDiscoveryManager.DiscoverTestsOnConcurrentManager - // Aborted is `true`: in case of parallel discovery (or non shared host), an aborted message ensures another discovery manager - // created to replace the current one. This will help if the current discovery manager is aborted due to irreparable error - // and the test host is lost as well. - this.HandleLogMessage(TestMessageLevel.Error, exception.ToString()); - - var discoveryCompletePayload = new DiscoveryCompletePayload() - { - IsAborted = true, - LastDiscoveredTests = null, - TotalTests = -1 - }; - this.HandleRawMessage(this.dataSerializer.SerializePayload(MessageType.DiscoveryComplete, discoveryCompletePayload)); - var discoveryCompleteEventsArgs = new DiscoveryCompleteEventArgs(-1, true); - - this.HandleDiscoveryComplete(discoveryCompleteEventsArgs, new List()); + _proxyOperationManager.RequestSender.DiscoverTests(discoveryCriteria, this); } } - - /// - public void Abort() + catch (Exception exception) { - // Do nothing if the proxy is not initialized yet. - if (this.proxyOperationManager == null) - { - return; - } + EqtTrace.Error("ProxyDiscoveryManager.DiscoverTests: Failed to discover tests: {0}", exception); - // Cancel fast, try to stop testhost deployment/launch - this.proxyOperationManager.CancellationTokenSource.Cancel(); - this.Close(); - } + // Log to vs ide test output + var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = exception.ToString() }; + var rawMessage = _dataSerializer.SerializePayload(MessageType.TestMessage, testMessagePayload); + HandleRawMessage(rawMessage); - /// - public void Close() - { - // Do nothing if the proxy is not initialized yet. - if (this.proxyOperationManager == null) - { - return; - } + // Log to vstest.console + // Send a discovery complete to caller. Similar logic is also used in ParallelProxyDiscoveryManager.DiscoverTestsOnConcurrentManager + // Aborted is `true`: in case of parallel discovery (or non shared host), an aborted message ensures another discovery manager + // created to replace the current one. This will help if the current discovery manager is aborted due to irreparable error + // and the test host is lost as well. + HandleLogMessage(TestMessageLevel.Error, exception.ToString()); - // When no test session is being used we don't share the testhost - // between test discovery and test run. The testhost is closed upon - // successfully completing the operation it was spawned for. - // - // In contrast, the new workflow (using test sessions) means we should keep - // the testhost alive until explicitly closed by the test session owner. - if (this.testSessionInfo == null) + var discoveryCompletePayload = new DiscoveryCompletePayload() { - this.proxyOperationManager.Close(); - return; - } - - TestSessionPool.Instance.ReturnProxy(this.testSessionInfo, this.proxyOperationManager.Id); + IsAborted = true, + LastDiscoveredTests = null, + TotalTests = -1 + }; + HandleRawMessage(_dataSerializer.SerializePayload(MessageType.DiscoveryComplete, discoveryCompletePayload)); + var discoveryCompleteEventsArgs = new DiscoveryCompleteEventArgs(-1, true); + + HandleDiscoveryComplete(discoveryCompleteEventsArgs, new List()); } + } - /// - public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk) + /// + public void Abort() + { + // Do nothing if the proxy is not initialized yet. + if (_proxyOperationManager == null) { - this.baseTestDiscoveryEventsHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, lastChunk); + return; } - /// - public void HandleDiscoveredTests(IEnumerable discoveredTestCases) - { - this.baseTestDiscoveryEventsHandler.HandleDiscoveredTests(discoveredTestCases); - } + // Cancel fast, try to stop testhost deployment/launch + _proxyOperationManager.CancellationTokenSource.Cancel(); + Close(); + } - /// - public void HandleRawMessage(string rawMessage) + /// + public void Close() + { + // Do nothing if the proxy is not initialized yet. + if (_proxyOperationManager == null) { - var message = this.dataSerializer.DeserializeMessage(rawMessage); - if(string.Equals(message.MessageType, MessageType.DiscoveryComplete)) - { - this.Close(); - } - - this.baseTestDiscoveryEventsHandler.HandleRawMessage(rawMessage); + return; } - /// - public void HandleLogMessage(TestMessageLevel level, string message) + // When no test session is being used we don't share the testhost + // between test discovery and test run. The testhost is closed upon + // successfully completing the operation it was spawned for. + // + // In contrast, the new workflow (using test sessions) means we should keep + // the testhost alive until explicitly closed by the test session owner. + if (_testSessionInfo == null) { - this.baseTestDiscoveryEventsHandler.HandleLogMessage(level, message); + _proxyOperationManager.Close(); + return; } - #endregion + TestSessionPool.Instance.ReturnProxy(_testSessionInfo, _proxyOperationManager.Id); + } + + /// + public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk) + { + _baseTestDiscoveryEventsHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, lastChunk); + } - #region IBaseProxy implementation. - /// - public virtual TestProcessStartInfo UpdateTestProcessStartInfo(TestProcessStartInfo testProcessStartInfo) + /// + public void HandleDiscoveredTests(IEnumerable discoveredTestCases) + { + _baseTestDiscoveryEventsHandler.HandleDiscoveredTests(discoveredTestCases); + } + + /// + public void HandleRawMessage(string rawMessage) + { + var message = _dataSerializer.DeserializeMessage(rawMessage); + if (string.Equals(message.MessageType, MessageType.DiscoveryComplete)) { - // Update Telemetry Opt in status because by default in Test Host Telemetry is opted out - var telemetryOptedIn = this.proxyOperationManager.RequestData.IsTelemetryOptedIn ? "true" : "false"; - testProcessStartInfo.Arguments += " --telemetryoptedin " + telemetryOptedIn; - return testProcessStartInfo; + Close(); } - #endregion - private void InitializeExtensions(IEnumerable sources) - { - var extensions = TestPluginCache.Instance.GetExtensionPaths(TestPlatformConstants.TestAdapterEndsWithPattern, this.skipDefaultAdapters); + _baseTestDiscoveryEventsHandler.HandleRawMessage(rawMessage); + } - // Filter out non existing extensions - var nonExistingExtensions = extensions.Where(extension => !this.fileHelper.Exists(extension)); - if (nonExistingExtensions.Any()) - { - this.LogMessage(TestMessageLevel.Warning, string.Format(Resources.Resources.NonExistingExtensions, string.Join(",", nonExistingExtensions))); - } + /// + public void HandleLogMessage(TestMessageLevel level, string message) + { + _baseTestDiscoveryEventsHandler.HandleLogMessage(level, message); + } - var sourceList = sources.ToList(); - var platformExtensions = this.testHostManager.GetTestPlatformExtensions(sourceList, extensions.Except(nonExistingExtensions)); + #endregion - // Only send this if needed. - if (platformExtensions.Any()) - { - this.proxyOperationManager.RequestSender.InitializeDiscovery(platformExtensions); - } - } + #region IBaseProxy implementation. + /// + public virtual TestProcessStartInfo UpdateTestProcessStartInfo(TestProcessStartInfo testProcessStartInfo) + { + // Update Telemetry Opt in status because by default in Test Host Telemetry is opted out + var telemetryOptedIn = _proxyOperationManager.RequestData.IsTelemetryOptedIn ? "true" : "false"; + testProcessStartInfo.Arguments += " --telemetryoptedin " + telemetryOptedIn; + return testProcessStartInfo; + } + #endregion - private void LogMessage(TestMessageLevel testMessageLevel, string message) + private void InitializeExtensions(IEnumerable sources) + { + var extensions = TestPluginCache.Instance.GetExtensionPaths(TestPlatformConstants.TestAdapterEndsWithPattern, _skipDefaultAdapters); + + // Filter out non existing extensions + var nonExistingExtensions = extensions.Where(extension => !_fileHelper.Exists(extension)); + if (nonExistingExtensions.Any()) { - // Log to translation layer. - var testMessagePayload = new TestMessagePayload { MessageLevel = testMessageLevel, Message = message }; - var rawMessage = this.dataSerializer.SerializePayload(MessageType.TestMessage, testMessagePayload); - this.HandleRawMessage(rawMessage); + LogMessage(TestMessageLevel.Warning, string.Format(Resources.Resources.NonExistingExtensions, string.Join(",", nonExistingExtensions))); + } - // Log to vstest.console layer. - this.HandleLogMessage(testMessageLevel, message); + var sourceList = sources.ToList(); + var platformExtensions = _testHostManager.GetTestPlatformExtensions(sourceList, extensions.Except(nonExistingExtensions)); + + // Only send this if needed. + if (platformExtensions.Any()) + { + _proxyOperationManager.RequestSender.InitializeDiscovery(platformExtensions); } } -} + + private void LogMessage(TestMessageLevel testMessageLevel, string message) + { + // Log to translation layer. + var testMessagePayload = new TestMessagePayload { MessageLevel = testMessageLevel, Message = message }; + var rawMessage = _dataSerializer.SerializePayload(MessageType.TestMessage, testMessagePayload); + HandleRawMessage(rawMessage); + + // Log to vstest.console layer. + HandleLogMessage(testMessageLevel, message); + } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManager.cs index de275432e7..a36eb5d51b 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManager.cs @@ -1,447 +1,442 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading; + +using Microsoft.VisualStudio.TestPlatform.Common; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Utilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +/// +/// Orchestrates test execution operations for the engine communicating with the client. +/// +internal class ProxyExecutionManager : IProxyExecutionManager, IBaseProxy, ITestRunEventsHandler2 { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Linq; - using System.Threading; - - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + private readonly TestSessionInfo _testSessionInfo = null; + private readonly Func _proxyOperationManagerCreator; + + private ITestRuntimeProvider _testHostManager; + + private readonly IFileHelper _fileHelper; + private readonly IDataSerializer _dataSerializer; + private bool _isCommunicationEstablished; + + private ProxyOperationManager _proxyOperationManager = null; + private ITestRunEventsHandler _baseTestRunEventsHandler; + private bool _skipDefaultAdapters; + private readonly bool _debugEnabledForTestSession = false; + + /// + public bool IsInitialized { get; private set; } = false; /// - /// Orchestrates test execution operations for the engine communicating with the client. + /// Gets or sets the cancellation token source. /// - internal class ProxyExecutionManager : IProxyExecutionManager, IBaseProxy, ITestRunEventsHandler2 + public CancellationTokenSource CancellationTokenSource { - private readonly TestSessionInfo testSessionInfo = null; - Func proxyOperationManagerCreator; + get { return _proxyOperationManager.CancellationTokenSource; } + set { _proxyOperationManager.CancellationTokenSource = value; } + } + #region Constructors - private ITestRuntimeProvider testHostManager; - private IRequestData requestData; + /// + /// Initializes a new instance of the class. + /// + /// + /// The test session info. + /// The proxy operation manager creator. + /// + /// A flag indicating if debugging should be enabled or not. + /// + public ProxyExecutionManager( + TestSessionInfo testSessionInfo, + Func proxyOperationManagerCreator, + bool debugEnabledForTestSession) + { + // Filling in test session info and proxy information. + _testSessionInfo = testSessionInfo; + _proxyOperationManagerCreator = proxyOperationManagerCreator; - private readonly IFileHelper fileHelper; - private readonly IDataSerializer dataSerializer; - private bool isCommunicationEstablished; + // This should be set to enable debugging when we have test session info available. + _debugEnabledForTestSession = debugEnabledForTestSession; - private ProxyOperationManager proxyOperationManager = null; - private ITestRunEventsHandler baseTestRunEventsHandler; - private bool skipDefaultAdapters; - private readonly bool debugEnabledForTestSession = false; + _testHostManager = null; + _dataSerializer = JsonDataSerializer.Instance; + _fileHelper = new FileHelper(); + _isCommunicationEstablished = false; + } - /// - public bool IsInitialized { get; private set; } = false; + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// The request data for providing services and data for run. + /// + /// Test request sender instance. + /// Test host manager for this proxy. + public ProxyExecutionManager( + IRequestData requestData, + ITestRequestSender requestSender, + ITestRuntimeProvider testHostManager) : + this( + requestData, + requestSender, + testHostManager, + JsonDataSerializer.Instance, + new FileHelper()) + { + } - /// - /// Gets or sets the cancellation token source. - /// - public CancellationTokenSource CancellationTokenSource - { - get { return this.proxyOperationManager.CancellationTokenSource; } - set { this.proxyOperationManager.CancellationTokenSource = value; } - } - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// - /// The test session info. - /// The proxy operation manager creator. - /// - /// A flag indicating if debugging should be enabled or not. - /// - public ProxyExecutionManager( - TestSessionInfo testSessionInfo, - Func proxyOperationManagerCreator, - bool debugEnabledForTestSession) - { - // Filling in test session info and proxy information. - this.testSessionInfo = testSessionInfo; - this.proxyOperationManagerCreator = proxyOperationManagerCreator; - - // This should be set to enable debugging when we have test session info available. - this.debugEnabledForTestSession = debugEnabledForTestSession; - - this.requestData = null; - this.testHostManager = null; - this.dataSerializer = JsonDataSerializer.Instance; - this.fileHelper = new FileHelper(); - this.isCommunicationEstablished = false; - } + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// Constructor with dependency injection. Used for unit testing. + /// + /// + /// The request data for common services and data for run. + /// Request sender instance. + /// Test host manager instance. + /// Data serializer instance. + /// File helper instance. + internal ProxyExecutionManager( + IRequestData requestData, + ITestRequestSender requestSender, + ITestRuntimeProvider testHostManager, + IDataSerializer dataSerializer, + IFileHelper fileHelper) + { + _testHostManager = testHostManager; + _dataSerializer = dataSerializer; + _isCommunicationEstablished = false; + _fileHelper = fileHelper; - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// The request data for providing services and data for run. - /// - /// Test request sender instance. - /// Test host manager for this proxy. - public ProxyExecutionManager( - IRequestData requestData, - ITestRequestSender requestSender, - ITestRuntimeProvider testHostManager) : - this( - requestData, - requestSender, - testHostManager, - JsonDataSerializer.Instance, - new FileHelper()) - { - } + // Create a new proxy operation manager. + _proxyOperationManager = new ProxyOperationManager(requestData, requestSender, testHostManager, this); + } - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// Constructor with dependency injection. Used for unit testing. - /// - /// - /// The request data for common services and data for run. - /// Request sender instance. - /// Test host manager instance. - /// Data serializer instance. - /// File helper instance. - internal ProxyExecutionManager( - IRequestData requestData, - ITestRequestSender requestSender, - ITestRuntimeProvider testHostManager, - IDataSerializer dataSerializer, - IFileHelper fileHelper) - { - this.testHostManager = testHostManager; - this.dataSerializer = dataSerializer; - this.isCommunicationEstablished = false; - this.requestData = requestData; - this.fileHelper = fileHelper; - - // Create a new proxy operation manager. - this.proxyOperationManager = new ProxyOperationManager(requestData, requestSender, testHostManager, this); - } + #endregion - #endregion + #region IProxyExecutionManager implementation. - #region IProxyExecutionManager implementation. + /// + public virtual void Initialize(bool skipDefaultAdapters) + { + _skipDefaultAdapters = skipDefaultAdapters; + IsInitialized = true; + } - /// - public virtual void Initialize(bool skipDefaultAdapters) + /// + public virtual int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler) + { + if (_proxyOperationManager == null) { - this.skipDefaultAdapters = skipDefaultAdapters; - this.IsInitialized = true; + // In case we have an active test session, we always prefer the already + // created proxies instead of the ones that need to be created on the spot. + var sources = testRunCriteria.HasSpecificTests + ? TestSourcesUtility.GetSources(testRunCriteria.Tests) + : testRunCriteria.Sources; + + _proxyOperationManager = _proxyOperationManagerCreator( + sources.First(), + this); + + _testHostManager = _proxyOperationManager.TestHostManager; } - /// - public virtual int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler) + _baseTestRunEventsHandler = eventHandler; + try { - if (this.proxyOperationManager == null) + if (EqtTrace.IsVerboseEnabled) { - // In case we have an active test session, we always prefer the already - // created proxies instead of the ones that need to be created on the spot. - var sources = testRunCriteria.HasSpecificTests - ? TestSourcesUtility.GetSources(testRunCriteria.Tests) - : testRunCriteria.Sources; - - this.proxyOperationManager = this.proxyOperationManagerCreator( - sources.First(), - this); - - this.testHostManager = this.proxyOperationManager.TestHostManager; - this.requestData = this.proxyOperationManager.RequestData; + EqtTrace.Verbose("ProxyExecutionManager: Test host is always Lazy initialize."); } - this.baseTestRunEventsHandler = eventHandler; - try - { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("ProxyExecutionManager: Test host is always Lazy initialize."); - } - - var testSources = new List( - testRunCriteria.HasSpecificSources - ? testRunCriteria.Sources - // If the test execution is with a test filter, group them by sources. - : testRunCriteria.Tests.GroupBy(tc => tc.Source).Select(g => g.Key)); + var testSources = new List( + testRunCriteria.HasSpecificSources + ? testRunCriteria.Sources + // If the test execution is with a test filter, group them by sources. + : testRunCriteria.Tests.GroupBy(tc => tc.Source).Select(g => g.Key)); - this.isCommunicationEstablished = this.proxyOperationManager.SetupChannel( - testSources, - testRunCriteria.TestRunSettings); + _isCommunicationEstablished = _proxyOperationManager.SetupChannel( + testSources, + testRunCriteria.TestRunSettings); - if (this.isCommunicationEstablished) + if (_isCommunicationEstablished) + { + _proxyOperationManager.CancellationTokenSource.Token.ThrowTestPlatformExceptionIfCancellationRequested(); + + InitializeExtensions(testSources); + + // This code should be in sync with InProcessProxyExecutionManager.StartTestRun + // execution context. + var executionContext = new TestExecutionContext( + testRunCriteria.FrequencyOfRunStatsChangeEvent, + testRunCriteria.RunStatsChangeEventTimeout, + inIsolation: false, + keepAlive: testRunCriteria.KeepAlive, + isDataCollectionEnabled: false, + areTestCaseLevelEventsRequired: false, + hasTestRun: true, + // Debugging should happen if there's a custom test host launcher present + // and is in debugging mode, or if the debugging is enabled in case the + // test session info is present. + isDebug: + (testRunCriteria.TestHostLauncher != null && testRunCriteria.TestHostLauncher.IsDebug) + || _debugEnabledForTestSession, + testCaseFilter: testRunCriteria.TestCaseFilter, + filterOptions: testRunCriteria.FilterOptions); + + // This is workaround for the bug https://github.com/Microsoft/vstest/issues/970 + var runsettings = _proxyOperationManager.RemoveNodesFromRunsettingsIfRequired( + testRunCriteria.TestRunSettings, + (testMessageLevel, message) => { LogMessage(testMessageLevel, message); }); + + if (testRunCriteria.HasSpecificSources) { - this.proxyOperationManager.CancellationTokenSource.Token.ThrowTestPlatformExceptionIfCancellationRequested(); - - this.InitializeExtensions(testSources); - - // This code should be in sync with InProcessProxyExecutionManager.StartTestRun - // execution context. - var executionContext = new TestExecutionContext( - testRunCriteria.FrequencyOfRunStatsChangeEvent, - testRunCriteria.RunStatsChangeEventTimeout, - inIsolation: false, - keepAlive: testRunCriteria.KeepAlive, - isDataCollectionEnabled: false, - areTestCaseLevelEventsRequired: false, - hasTestRun: true, - // Debugging should happen if there's a custom test host launcher present - // and is in debugging mode, or if the debugging is enabled in case the - // test session info is present. - isDebug: - (testRunCriteria.TestHostLauncher != null && testRunCriteria.TestHostLauncher.IsDebug) - || this.debugEnabledForTestSession, - testCaseFilter: testRunCriteria.TestCaseFilter, - filterOptions: testRunCriteria.FilterOptions); - - // This is workaround for the bug https://github.com/Microsoft/vstest/issues/970 - var runsettings = this.proxyOperationManager.RemoveNodesFromRunsettingsIfRequired( - testRunCriteria.TestRunSettings, - (testMessageLevel, message) => { this.LogMessage(testMessageLevel, message); }); - - if (testRunCriteria.HasSpecificSources) - { - var runRequest = testRunCriteria.CreateTestRunCriteriaForSources( - testHostManager, - runsettings, - executionContext, - testSources); - this.proxyOperationManager.RequestSender.StartTestRun(runRequest, this); - } - else - { - var runRequest = testRunCriteria.CreateTestRunCriteriaForTests( - testHostManager, - runsettings, - executionContext, - testSources); - this.proxyOperationManager.RequestSender.StartTestRun(runRequest, this); - } + var runRequest = testRunCriteria.CreateTestRunCriteriaForSources( + _testHostManager, + runsettings, + executionContext, + testSources); + _proxyOperationManager.RequestSender.StartTestRun(runRequest, this); } - } - catch (Exception exception) - { - EqtTrace.Error("ProxyExecutionManager.StartTestRun: Failed to start test run: {0}", exception); - - // Log error message to design mode and CLI. - // TestPlatformException is expected exception, log only the message. - // For other exceptions, log the stacktrace as well. - var errorMessage = exception is TestPlatformException ? exception.Message : exception.ToString(); - var testMessagePayload = new TestMessagePayload() + else { - MessageLevel = TestMessageLevel.Error, - Message = errorMessage - }; - this.HandleRawMessage(this.dataSerializer.SerializePayload(MessageType.TestMessage, testMessagePayload)); - this.LogMessage(TestMessageLevel.Error, errorMessage); - - // Send a run complete to caller. Similar logic is also used in - // ParallelProxyExecutionManager.StartTestRunOnConcurrentManager. - // - // Aborted is `true`: in case of parallel run (or non shared host), an aborted - // message ensures another execution manager created to replace the current one. - // This will help if the current execution manager is aborted due to irreparable - // error and the test host is lost as well. - var completeArgs = new TestRunCompleteEventArgs(null, false, true, null, new Collection(), new Collection(), TimeSpan.Zero); - var testRunCompletePayload = new TestRunCompletePayload { TestRunCompleteArgs = completeArgs }; - this.HandleRawMessage(this.dataSerializer.SerializePayload(MessageType.ExecutionComplete, testRunCompletePayload)); - this.HandleTestRunComplete(completeArgs, null, null, null); + var runRequest = testRunCriteria.CreateTestRunCriteriaForTests( + _testHostManager, + runsettings, + executionContext, + testSources); + _proxyOperationManager.RequestSender.StartTestRun(runRequest, this); + } } - - return 0; } - - /// - public virtual void Cancel(ITestRunEventsHandler eventHandler) + catch (Exception exception) { - // Just in case ExecuteAsync isn't called yet, set the eventhandler. - if (this.baseTestRunEventsHandler == null) - { - this.baseTestRunEventsHandler = eventHandler; - } - - // Do nothing if the proxy is not initialized yet. - if (this.proxyOperationManager == null) - { - return; - } + EqtTrace.Error("ProxyExecutionManager.StartTestRun: Failed to start test run: {0}", exception); - // Cancel fast, try to stop testhost deployment/launch. - this.proxyOperationManager.CancellationTokenSource.Cancel(); - if (this.isCommunicationEstablished) + // Log error message to design mode and CLI. + // TestPlatformException is expected exception, log only the message. + // For other exceptions, log the stacktrace as well. + var errorMessage = exception is TestPlatformException ? exception.Message : exception.ToString(); + var testMessagePayload = new TestMessagePayload() { - this.proxyOperationManager.RequestSender.SendTestRunCancel(); - } + MessageLevel = TestMessageLevel.Error, + Message = errorMessage + }; + HandleRawMessage(_dataSerializer.SerializePayload(MessageType.TestMessage, testMessagePayload)); + LogMessage(TestMessageLevel.Error, errorMessage); + + // Send a run complete to caller. Similar logic is also used in + // ParallelProxyExecutionManager.StartTestRunOnConcurrentManager. + // + // Aborted is `true`: in case of parallel run (or non shared host), an aborted + // message ensures another execution manager created to replace the current one. + // This will help if the current execution manager is aborted due to irreparable + // error and the test host is lost as well. + var completeArgs = new TestRunCompleteEventArgs(null, false, true, null, new Collection(), new Collection(), TimeSpan.Zero); + var testRunCompletePayload = new TestRunCompletePayload { TestRunCompleteArgs = completeArgs }; + HandleRawMessage(_dataSerializer.SerializePayload(MessageType.ExecutionComplete, testRunCompletePayload)); + HandleTestRunComplete(completeArgs, null, null, null); } - /// - public void Abort(ITestRunEventsHandler eventHandler) - { - // Just in case ExecuteAsync isn't called yet, set the eventhandler. - if (this.baseTestRunEventsHandler == null) - { - this.baseTestRunEventsHandler = eventHandler; - } - - // Do nothing if the proxy is not initialized yet. - if (this.proxyOperationManager == null) - { - return; - } - - // Cancel fast, try to stop testhost deployment/launch. - this.proxyOperationManager.CancellationTokenSource.Cancel(); + return 0; + } - if (this.isCommunicationEstablished) - { - this.proxyOperationManager.RequestSender.SendTestRunAbort(); - } + /// + public virtual void Cancel(ITestRunEventsHandler eventHandler) + { + // Just in case ExecuteAsync isn't called yet, set the eventhandler. + if (_baseTestRunEventsHandler == null) + { + _baseTestRunEventsHandler = eventHandler; } - /// - public void Close() + // Do nothing if the proxy is not initialized yet. + if (_proxyOperationManager == null) { - // Do nothing if the proxy is not initialized yet. - if (this.proxyOperationManager == null) - { - return; - } - - // When no test session is being used we don't share the testhost - // between test discovery and test run. The testhost is closed upon - // successfully completing the operation it was spawned for. - // - // In contrast, the new workflow (using test sessions) means we should keep - // the testhost alive until explicitly closed by the test session owner. - if (this.testSessionInfo == null) - { - this.proxyOperationManager.Close(); - return; - } - - TestSessionPool.Instance.ReturnProxy(this.testSessionInfo, this.proxyOperationManager.Id); + return; } - /// - public virtual int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) + // Cancel fast, try to stop testhost deployment/launch. + _proxyOperationManager.CancellationTokenSource.Cancel(); + if (_isCommunicationEstablished) { - return this.baseTestRunEventsHandler.LaunchProcessWithDebuggerAttached(testProcessStartInfo); + _proxyOperationManager.RequestSender.SendTestRunCancel(); } + } - /// - public bool AttachDebuggerToProcess(int pid) + /// + public void Abort(ITestRunEventsHandler eventHandler) + { + // Just in case ExecuteAsync isn't called yet, set the eventhandler. + if (_baseTestRunEventsHandler == null) { - return ((ITestRunEventsHandler2)this.baseTestRunEventsHandler).AttachDebuggerToProcess(pid); + _baseTestRunEventsHandler = eventHandler; } - /// - public void HandleTestRunComplete(TestRunCompleteEventArgs testRunCompleteArgs, TestRunChangedEventArgs lastChunkArgs, ICollection runContextAttachments, ICollection executorUris) + // Do nothing if the proxy is not initialized yet. + if (_proxyOperationManager == null) { - this.baseTestRunEventsHandler.HandleTestRunComplete(testRunCompleteArgs, lastChunkArgs, runContextAttachments, executorUris); + return; } - /// - public void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChangedArgs) + // Cancel fast, try to stop testhost deployment/launch. + _proxyOperationManager.CancellationTokenSource.Cancel(); + + if (_isCommunicationEstablished) { - this.baseTestRunEventsHandler.HandleTestRunStatsChange(testRunChangedArgs); + _proxyOperationManager.RequestSender.SendTestRunAbort(); } + } - /// - public void HandleRawMessage(string rawMessage) + /// + public void Close() + { + // Do nothing if the proxy is not initialized yet. + if (_proxyOperationManager == null) { - var message = this.dataSerializer.DeserializeMessage(rawMessage); - - if (string.Equals(message.MessageType, MessageType.ExecutionComplete)) - { - this.Close(); - } - - this.baseTestRunEventsHandler.HandleRawMessage(rawMessage); + return; } - /// - public void HandleLogMessage(TestMessageLevel level, string message) + // When no test session is being used we don't share the testhost + // between test discovery and test run. The testhost is closed upon + // successfully completing the operation it was spawned for. + // + // In contrast, the new workflow (using test sessions) means we should keep + // the testhost alive until explicitly closed by the test session owner. + if (_testSessionInfo == null) { - this.baseTestRunEventsHandler.HandleLogMessage(level, message); + _proxyOperationManager.Close(); + return; } - #endregion + TestSessionPool.Instance.ReturnProxy(_testSessionInfo, _proxyOperationManager.Id); + } - #region IBaseProxy implementation. - /// - public virtual TestProcessStartInfo UpdateTestProcessStartInfo(TestProcessStartInfo testProcessStartInfo) - { - // Update Telemetry Opt in status because by default in Test Host Telemetry is opted out - var telemetryOptedIn = this.proxyOperationManager.RequestData.IsTelemetryOptedIn ? "true" : "false"; - testProcessStartInfo.Arguments += " --telemetryoptedin " + telemetryOptedIn; - return testProcessStartInfo; - } - #endregion - - /// - /// Ensures that the engine is ready for test operations. Usually includes starting up the - /// test host process. - /// - /// - /// List of test sources. - /// Run settings to be used. - /// - /// - /// Returns true if the communication is established b/w runner and host, false otherwise. - /// - public virtual bool SetupChannel(IEnumerable sources, string runSettings) + /// + public virtual int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) + { + return _baseTestRunEventsHandler.LaunchProcessWithDebuggerAttached(testProcessStartInfo); + } + + /// + public bool AttachDebuggerToProcess(int pid) + { + return ((ITestRunEventsHandler2)_baseTestRunEventsHandler).AttachDebuggerToProcess(pid); + } + + /// + public void HandleTestRunComplete(TestRunCompleteEventArgs testRunCompleteArgs, TestRunChangedEventArgs lastChunkArgs, ICollection runContextAttachments, ICollection executorUris) + { + _baseTestRunEventsHandler.HandleTestRunComplete(testRunCompleteArgs, lastChunkArgs, runContextAttachments, executorUris); + } + + /// + public void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChangedArgs) + { + _baseTestRunEventsHandler.HandleTestRunStatsChange(testRunChangedArgs); + } + + /// + public void HandleRawMessage(string rawMessage) + { + var message = _dataSerializer.DeserializeMessage(rawMessage); + + if (string.Equals(message.MessageType, MessageType.ExecutionComplete)) { - return this.proxyOperationManager.SetupChannel(sources, runSettings); + Close(); } - private void LogMessage(TestMessageLevel testMessageLevel, string message) - { - // Log to vs ide test output. - var testMessagePayload = new TestMessagePayload { MessageLevel = testMessageLevel, Message = message }; - var rawMessage = this.dataSerializer.SerializePayload(MessageType.TestMessage, testMessagePayload); - this.HandleRawMessage(rawMessage); + _baseTestRunEventsHandler.HandleRawMessage(rawMessage); + } - // Log to vstest.console. - this.HandleLogMessage(testMessageLevel, message); - } + /// + public void HandleLogMessage(TestMessageLevel level, string message) + { + _baseTestRunEventsHandler.HandleLogMessage(level, message); + } - private void InitializeExtensions(IEnumerable sources) - { - var extensions = TestPluginCache.Instance.GetExtensionPaths(TestPlatformConstants.TestAdapterEndsWithPattern, this.skipDefaultAdapters); + #endregion - // Filter out non existing extensions. - var nonExistingExtensions = extensions.Where(extension => !this.fileHelper.Exists(extension)); - if (nonExistingExtensions.Any()) - { - this.LogMessage(TestMessageLevel.Warning, string.Format(Resources.Resources.NonExistingExtensions, string.Join(",", nonExistingExtensions))); - } + #region IBaseProxy implementation. + /// + public virtual TestProcessStartInfo UpdateTestProcessStartInfo(TestProcessStartInfo testProcessStartInfo) + { + // Update Telemetry Opt in status because by default in Test Host Telemetry is opted out + var telemetryOptedIn = _proxyOperationManager.RequestData.IsTelemetryOptedIn ? "true" : "false"; + testProcessStartInfo.Arguments += " --telemetryoptedin " + telemetryOptedIn; + return testProcessStartInfo; + } + #endregion + + /// + /// Ensures that the engine is ready for test operations. Usually includes starting up the + /// test host process. + /// + /// + /// List of test sources. + /// Run settings to be used. + /// + /// + /// Returns true if the communication is established b/w runner and host, false otherwise. + /// + public virtual bool SetupChannel(IEnumerable sources, string runSettings) + { + return _proxyOperationManager.SetupChannel(sources, runSettings); + } + + private void LogMessage(TestMessageLevel testMessageLevel, string message) + { + // Log to vs ide test output. + var testMessagePayload = new TestMessagePayload { MessageLevel = testMessageLevel, Message = message }; + var rawMessage = _dataSerializer.SerializePayload(MessageType.TestMessage, testMessagePayload); + HandleRawMessage(rawMessage); - var sourceList = sources.ToList(); - var platformExtensions = this.testHostManager.GetTestPlatformExtensions(sourceList, extensions.Except(nonExistingExtensions)); + // Log to vstest.console. + HandleLogMessage(testMessageLevel, message); + } - // Only send this if needed. - if (platformExtensions.Any()) - { - this.proxyOperationManager.RequestSender.InitializeExecution(platformExtensions); - } + private void InitializeExtensions(IEnumerable sources) + { + var extensions = TestPluginCache.Instance.GetExtensionPaths(TestPlatformConstants.TestAdapterEndsWithPattern, _skipDefaultAdapters); + + // Filter out non existing extensions. + var nonExistingExtensions = extensions.Where(extension => !_fileHelper.Exists(extension)); + if (nonExistingExtensions.Any()) + { + LogMessage(TestMessageLevel.Warning, string.Format(Resources.Resources.NonExistingExtensions, string.Join(",", nonExistingExtensions))); + } + + var sourceList = sources.ToList(); + var platformExtensions = _testHostManager.GetTestPlatformExtensions(sourceList, extensions.Except(nonExistingExtensions)); + + // Only send this if needed. + if (platformExtensions.Any()) + { + _proxyOperationManager.RequestSender.InitializeExecution(platformExtensions); } } } diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManagerWithDataCollection.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManagerWithDataCollection.cs index 8aad17856d..a0267d121e 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManagerWithDataCollection.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManagerWithDataCollection.cs @@ -1,223 +1,223 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; + +using System; +using System.Collections.Generic; +using System.Threading; + +using CommunicationUtilities.Interfaces; +using DataCollection; +using DataCollection.Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Host; +using ObjectModel.Logging; + +/// +/// The proxy execution manager with data collection. +/// +internal class ProxyExecutionManagerWithDataCollection : ProxyExecutionManager { - using System; - using System.Collections.Generic; - using System.Threading; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + private IDictionary _dataCollectionEnvironmentVariables; + private int _dataCollectionPort; + private readonly IRequestData _requestData; /// - /// The proxy execution manager with data collection. + /// Initializes a new instance of the class. /// - internal class ProxyExecutionManagerWithDataCollection : ProxyExecutionManager + /// + /// Test request sender instance. + /// + /// + /// Test host manager for this operation. + /// + /// + /// The proxy Data Collection Manager. + /// + /// + /// The request data for providing execution services and data. + /// + public ProxyExecutionManagerWithDataCollection( + IRequestData requestData, + ITestRequestSender requestSender, + ITestRuntimeProvider testHostManager, + IProxyDataCollectionManager proxyDataCollectionManager) + : base( + requestData, + requestSender, + testHostManager) { - private IDictionary dataCollectionEnvironmentVariables; - private int dataCollectionPort; - private IRequestData requestData; - - /// - /// Initializes a new instance of the class. - /// - /// - /// Test request sender instance. - /// - /// - /// Test host manager for this operation. - /// - /// - /// The proxy Data Collection Manager. - /// - /// - /// The request data for providing execution services and data. - /// - public ProxyExecutionManagerWithDataCollection( - IRequestData requestData, - ITestRequestSender requestSender, - ITestRuntimeProvider testHostManager, - IProxyDataCollectionManager proxyDataCollectionManager) - : base( - requestData, - requestSender, - testHostManager) - { - this.ProxyDataCollectionManager = proxyDataCollectionManager; - this.DataCollectionRunEventsHandler = new DataCollectionRunEventsHandler(); - this.requestData = requestData; - this.dataCollectionEnvironmentVariables = new Dictionary(); + ProxyDataCollectionManager = proxyDataCollectionManager; + DataCollectionRunEventsHandler = new DataCollectionRunEventsHandler(); + _requestData = requestData; + _dataCollectionEnvironmentVariables = new Dictionary(); - testHostManager.HostLaunched += this.TestHostLaunchedHandler; - } + testHostManager.HostLaunched += TestHostLaunchedHandler; + } - private void TestHostLaunchedHandler(object sender, HostProviderEventArgs e) - { - this.ProxyDataCollectionManager.TestHostLaunched(e.ProcessId); - } + private void TestHostLaunchedHandler(object sender, HostProviderEventArgs e) + { + ProxyDataCollectionManager.TestHostLaunched(e.ProcessId); + } - /// - /// Gets the data collection run events handler. - /// - internal DataCollectionRunEventsHandler DataCollectionRunEventsHandler - { - get; private set; - } + /// + /// Gets the data collection run events handler. + /// + internal DataCollectionRunEventsHandler DataCollectionRunEventsHandler + { + get; private set; + } - /// - /// Gets the proxy data collection manager. - /// - internal IProxyDataCollectionManager ProxyDataCollectionManager - { - get; private set; - } + /// + /// Gets the proxy data collection manager. + /// + internal IProxyDataCollectionManager ProxyDataCollectionManager + { + get; private set; + } + + /// + /// Gets the cancellation token for execution. + /// + internal CancellationToken CancellationToken => CancellationTokenSource.Token; - /// - /// Gets the cancellation token for execution. - /// - internal CancellationToken CancellationToken => CancellationTokenSource.Token; + /// + /// Ensure that the Execution component of engine is ready for execution usually by loading extensions. + /// Skip default adapters flag. + /// + public override void Initialize(bool skipDefaultAdapters) + { + ProxyDataCollectionManager.Initialize(); - /// - /// Ensure that the Execution component of engine is ready for execution usually by loading extensions. - /// Skip default adapters flag. - /// - public override void Initialize(bool skipDefaultAdapters) + try { - this.ProxyDataCollectionManager.Initialize(); + var dataCollectionParameters = ProxyDataCollectionManager.BeforeTestRunStart( + resetDataCollectors: true, + isRunStartingNow: true, + runEventsHandler: DataCollectionRunEventsHandler); - try - { - var dataCollectionParameters = this.ProxyDataCollectionManager.BeforeTestRunStart( - resetDataCollectors: true, - isRunStartingNow: true, - runEventsHandler: this.DataCollectionRunEventsHandler); - - if (dataCollectionParameters != null) - { - this.dataCollectionEnvironmentVariables = dataCollectionParameters.EnvironmentVariables; - this.dataCollectionPort = dataCollectionParameters.DataCollectionEventsPort; - } - } - catch (Exception) + if (dataCollectionParameters != null) { - // On failure in calling BeforeTestRunStart, call AfterTestRunEnd to end DataCollectionProcess - this.ProxyDataCollectionManager.AfterTestRunEnd(isCanceled: true, runEventsHandler: this.DataCollectionRunEventsHandler); - throw; + _dataCollectionEnvironmentVariables = dataCollectionParameters.EnvironmentVariables; + _dataCollectionPort = dataCollectionParameters.DataCollectionEventsPort; } - - base.Initialize(skipDefaultAdapters); } - - /// - /// Starts the test run - /// - /// The settings/options for the test run. - /// EventHandler for handling execution events from Engine. - /// The process id of the runner executing tests. - public override int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler) + catch (Exception) { - var currentEventHandler = eventHandler; - if (this.ProxyDataCollectionManager != null) - { - currentEventHandler = new DataCollectionTestRunEventsHandler(eventHandler, this.ProxyDataCollectionManager, this.CancellationTokenSource.Token); - } - - // Log all the messages that are reported while initializing DataCollectionClient - if (this.DataCollectionRunEventsHandler.Messages.Count > 0) - { - foreach (var message in this.DataCollectionRunEventsHandler.Messages) - { - currentEventHandler.HandleLogMessage(message.Item1, message.Item2); - } + // On failure in calling BeforeTestRunStart, call AfterTestRunEnd to end DataCollectionProcess + ProxyDataCollectionManager.AfterTestRunEnd(isCanceled: true, runEventsHandler: DataCollectionRunEventsHandler); + throw; + } - this.DataCollectionRunEventsHandler.Messages.Clear(); - } + base.Initialize(skipDefaultAdapters); + } - return base.StartTestRun(testRunCriteria, currentEventHandler); + /// + /// Starts the test run + /// + /// The settings/options for the test run. + /// EventHandler for handling execution events from Engine. + /// The process id of the runner executing tests. + public override int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler) + { + var currentEventHandler = eventHandler; + if (ProxyDataCollectionManager != null) + { + currentEventHandler = new DataCollectionTestRunEventsHandler(eventHandler, ProxyDataCollectionManager, CancellationTokenSource.Token); } - public override int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) + // Log all the messages that are reported while initializing DataCollectionClient + if (DataCollectionRunEventsHandler.Messages.Count > 0) { - if (this.dataCollectionEnvironmentVariables != null) + foreach (var message in DataCollectionRunEventsHandler.Messages) { - if (testProcessStartInfo.EnvironmentVariables == null) - { - testProcessStartInfo.EnvironmentVariables = new Dictionary(); - } - - foreach(var envVariable in this.dataCollectionEnvironmentVariables) - { - if (testProcessStartInfo.EnvironmentVariables.ContainsKey(envVariable.Key)) - { - testProcessStartInfo.EnvironmentVariables[envVariable.Key] = envVariable.Value; - } - else - { - testProcessStartInfo.EnvironmentVariables.Add(envVariable.Key, envVariable.Value); - } - } + currentEventHandler.HandleLogMessage(message.Item1, message.Item2); } - return base.LaunchProcessWithDebuggerAttached(testProcessStartInfo); + DataCollectionRunEventsHandler.Messages.Clear(); } - /// - public override TestProcessStartInfo UpdateTestProcessStartInfo(TestProcessStartInfo testProcessStartInfo) + return base.StartTestRun(testRunCriteria, currentEventHandler); + } + + public override int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) + { + if (_dataCollectionEnvironmentVariables != null) { if (testProcessStartInfo.EnvironmentVariables == null) { - testProcessStartInfo.EnvironmentVariables = this.dataCollectionEnvironmentVariables; + testProcessStartInfo.EnvironmentVariables = new Dictionary(); } - else + + foreach (var envVariable in _dataCollectionEnvironmentVariables) { - foreach (var kvp in this.dataCollectionEnvironmentVariables) + if (testProcessStartInfo.EnvironmentVariables.ContainsKey(envVariable.Key)) + { + testProcessStartInfo.EnvironmentVariables[envVariable.Key] = envVariable.Value; + } + else { - testProcessStartInfo.EnvironmentVariables[kvp.Key] = kvp.Value; + testProcessStartInfo.EnvironmentVariables.Add(envVariable.Key, envVariable.Value); } } + } - // Update Telemetry Opt in status because by default in Test Host Telemetry is opted out - var telemetryOptedIn = this.requestData.IsTelemetryOptedIn ? "true" : "false"; - testProcessStartInfo.Arguments += " --datacollectionport " + this.dataCollectionPort - + " --telemetryoptedin " + telemetryOptedIn; + return base.LaunchProcessWithDebuggerAttached(testProcessStartInfo); + } - return testProcessStartInfo; + /// + public override TestProcessStartInfo UpdateTestProcessStartInfo(TestProcessStartInfo testProcessStartInfo) + { + if (testProcessStartInfo.EnvironmentVariables == null) + { + testProcessStartInfo.EnvironmentVariables = _dataCollectionEnvironmentVariables; } + else + { + foreach (var kvp in _dataCollectionEnvironmentVariables) + { + testProcessStartInfo.EnvironmentVariables[kvp.Key] = kvp.Value; + } + } + + // Update Telemetry Opt in status because by default in Test Host Telemetry is opted out + var telemetryOptedIn = _requestData.IsTelemetryOptedIn ? "true" : "false"; + testProcessStartInfo.Arguments += " --datacollectionport " + _dataCollectionPort + + " --telemetryoptedin " + telemetryOptedIn; + + return testProcessStartInfo; } +} +/// +/// Handles Log events and stores them in list. Messages in the list will be logged after test execution begins. +/// +internal class DataCollectionRunEventsHandler : ITestMessageEventHandler +{ /// - /// Handles Log events and stores them in list. Messages in the list will be logged after test execution begins. + /// Initializes a new instance of the class. /// - internal class DataCollectionRunEventsHandler : ITestMessageEventHandler + public DataCollectionRunEventsHandler() { - /// - /// Initializes a new instance of the class. - /// - public DataCollectionRunEventsHandler() - { - this.Messages = new List>(); - } + Messages = new List>(); + } - /// - /// Gets the cached messages. - /// - public List> Messages { get; private set; } + /// + /// Gets the cached messages. + /// + public List> Messages { get; private set; } - /// - public void HandleLogMessage(TestMessageLevel level, string message) - { - this.Messages.Add(new Tuple(level, message)); - } + /// + public void HandleLogMessage(TestMessageLevel level, string message) + { + Messages.Add(new Tuple(level, message)); + } - /// - public void HandleRawMessage(string rawMessage) - { - throw new NotImplementedException(); - } + /// + public void HandleRawMessage(string rawMessage) + { + throw new NotImplementedException(); } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs index 4809ade961..e7143e2594 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs @@ -1,486 +1,482 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Threading; + +using CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using CoreUtilities.Extensions; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Host; +using ObjectModel.Logging; +using PlatformAbstractions; +using PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities; + +using CoreUtilities.Helpers; + +using CrossPlatEngineResources = Resources.Resources; +using CommunicationUtilitiesResources = CommunicationUtilities.Resources.Resources; +using CoreUtilitiesConstants = CoreUtilities.Constants; + +/// +/// Base class for any operations that the client needs to drive through the engine. +/// +public class ProxyOperationManager { - using System; - using System.Collections.Generic; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Reflection; - using System.Threading; - - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities; - - using CoreUtilities.Helpers; - - using CrossPlatEngineResources = Resources.Resources; - using CommunicationUtilitiesResources = CommunicationUtilities.Resources.Resources; - using CoreUtilitiesConstants = CoreUtilities.Constants; + private readonly string _versionCheckPropertyName = "IsVersionCheckRequired"; + private readonly string _makeRunsettingsCompatiblePropertyName = "MakeRunsettingsCompatible"; + private readonly ManualResetEventSlim _testHostExited = new(false); + private readonly IProcessHelper _processHelper; + + private readonly IBaseProxy _baseProxy; + private bool _versionCheckRequired = true; + private bool _makeRunsettingsCompatible; + private bool _makeRunsettingsCompatibleSet; + private bool _initialized; + private bool _testHostLaunched; + private int _testHostProcessId; + private string _testHostProcessStdError; + + #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// + /// Request data instance. + /// Request sender instance. + /// Test host manager instance. + public ProxyOperationManager( + IRequestData requestData, + ITestRequestSender requestSender, + ITestRuntimeProvider testHostManager) + : this( + requestData, + requestSender, + testHostManager, + null) + { } /// - /// Base class for any operations that the client needs to drive through the engine. + /// Initializes a new instance of the class. /// - public class ProxyOperationManager + /// + /// Request data instance. + /// Request sender instance. + /// Test host manager instance. + /// The base proxy. + public ProxyOperationManager( + IRequestData requestData, + ITestRequestSender requestSender, + ITestRuntimeProvider testHostManager, + IBaseProxy baseProxy) { - private readonly string versionCheckPropertyName = "IsVersionCheckRequired"; - private readonly string makeRunsettingsCompatiblePropertyName = "MakeRunsettingsCompatible"; - private readonly ManualResetEventSlim testHostExited = new ManualResetEventSlim(false); - private readonly IProcessHelper processHelper; - - private IBaseProxy baseProxy; - private bool versionCheckRequired = true; - private bool makeRunsettingsCompatible; - private bool makeRunsettingsCompatibleSet; - private bool initialized; - private bool testHostLaunched; - private int testHostProcessId; - private string testHostProcessStdError; - - #region Constructors - /// - /// Initializes a new instance of the class. - /// - /// - /// Request data instance. - /// Request sender instance. - /// Test host manager instance. - public ProxyOperationManager( - IRequestData requestData, - ITestRequestSender requestSender, - ITestRuntimeProvider testHostManager) - : this( - requestData, - requestSender, - testHostManager, - null) - { } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Request data instance. - /// Request sender instance. - /// Test host manager instance. - /// The base proxy. - public ProxyOperationManager( - IRequestData requestData, - ITestRequestSender requestSender, - ITestRuntimeProvider testHostManager, - IBaseProxy baseProxy) - { - this.RequestData = requestData; - this.RequestSender = requestSender; - this.TestHostManager = testHostManager; - this.baseProxy = baseProxy; - - this.initialized = false; - this.testHostLaunched = false; - this.testHostProcessId = -1; - this.processHelper = new ProcessHelper(); - this.CancellationTokenSource = new CancellationTokenSource(); - } + RequestData = requestData; + RequestSender = requestSender; + TestHostManager = testHostManager; + _baseProxy = baseProxy; + + _initialized = false; + _testHostLaunched = false; + _testHostProcessId = -1; + _processHelper = new ProcessHelper(); + CancellationTokenSource = new CancellationTokenSource(); + } - #endregion - - #region Properties - /// - /// Gets or sets the request data. - /// - public IRequestData RequestData { get; set; } - - /// - /// Gets or sets the server for communication. - /// - public ITestRequestSender RequestSender { get; set; } - - /// - /// Gets or sets the test host manager. - /// - public ITestRuntimeProvider TestHostManager { get; set; } - - /// - /// Gets the proxy operation manager id for proxy test session manager internal organization. - /// - public int Id { get; set; } = -1; - - /// - /// Gets or sets the cancellation token source. - /// - public CancellationTokenSource CancellationTokenSource { get; set; } - #endregion - - #region IProxyOperationManager implementation. - /// - /// Initializes the proxy. - /// - /// - /// - /// Flag indicating if we should skip the default adapters initialization. - /// - public virtual void Initialize(bool skipDefaultAdapters) - { - // No-op. - } + #endregion + + #region Properties + /// + /// Gets or sets the request data. + /// + public IRequestData RequestData { get; set; } + + /// + /// Gets or sets the server for communication. + /// + public ITestRequestSender RequestSender { get; set; } + + /// + /// Gets or sets the test host manager. + /// + public ITestRuntimeProvider TestHostManager { get; set; } + + /// + /// Gets the proxy operation manager id for proxy test session manager internal organization. + /// + public int Id { get; set; } = -1; + + /// + /// Gets or sets the cancellation token source. + /// + public CancellationTokenSource CancellationTokenSource { get; set; } + #endregion + + #region IProxyOperationManager implementation. + /// + /// Initializes the proxy. + /// + /// + /// + /// Flag indicating if we should skip the default adapters initialization. + /// + public virtual void Initialize(bool skipDefaultAdapters) + { + // No-op. + } + + /// + /// Ensures that the engine is ready for test operations. Usually includes starting up the + /// test host process. + /// + /// + /// List of test sources. + /// Run settings to be used. + /// The events handler. + /// + /// + /// Returns true if the communication is established b/w runner and host, false otherwise. + /// + public virtual bool SetupChannel( + IEnumerable sources, + string runSettings, + ITestMessageEventHandler eventHandler) + { + // NOTE: Event handler is ignored here, but it is used in the overloaded method. + return SetupChannel(sources, runSettings); + } + + /// + /// Ensures that the engine is ready for test operations. Usually includes starting up the + /// test host process. + /// + /// + /// List of test sources. + /// Run settings to be used. + /// + /// + /// Returns true if the communication is established b/w runner and host, false otherwise. + /// + public virtual bool SetupChannel(IEnumerable sources, string runSettings) + { + CancellationTokenSource.Token.ThrowTestPlatformExceptionIfCancellationRequested(); - /// - /// Ensures that the engine is ready for test operations. Usually includes starting up the - /// test host process. - /// - /// - /// List of test sources. - /// Run settings to be used. - /// The events handler. - /// - /// - /// Returns true if the communication is established b/w runner and host, false otherwise. - /// - public virtual bool SetupChannel( - IEnumerable sources, - string runSettings, - ITestMessageEventHandler eventHandler) + if (_initialized) { - // NOTE: Event handler is ignored here, but it is used in the overloaded method. - return this.SetupChannel(sources, runSettings); + return true; } - /// - /// Ensures that the engine is ready for test operations. Usually includes starting up the - /// test host process. - /// - /// - /// List of test sources. - /// Run settings to be used. - /// - /// - /// Returns true if the communication is established b/w runner and host, false otherwise. - /// - public virtual bool SetupChannel(IEnumerable sources, string runSettings) - { - this.CancellationTokenSource.Token.ThrowTestPlatformExceptionIfCancellationRequested(); + var connTimeout = EnvironmentHelper.GetConnectionTimeout(); - if (this.initialized) - { - return true; - } + _testHostProcessStdError = string.Empty; + TestHostConnectionInfo testHostConnectionInfo = TestHostManager.GetTestHostConnectionInfo(); - var connTimeout = EnvironmentHelper.GetConnectionTimeout(); + var portNumber = 0; + if (testHostConnectionInfo.Role == ConnectionRole.Client) + { + portNumber = RequestSender.InitializeCommunication(); + testHostConnectionInfo.Endpoint += portNumber; + } - this.testHostProcessStdError = string.Empty; - TestHostConnectionInfo testHostConnectionInfo = this.TestHostManager.GetTestHostConnectionInfo(); + var processId = _processHelper.GetCurrentProcessId(); + var connectionInfo = new TestRunnerConnectionInfo() + { + Port = portNumber, + ConnectionInfo = testHostConnectionInfo, + RunnerProcessId = processId, + LogFile = GetTimestampedLogFile(EqtTrace.LogFile), + TraceLevel = (int)EqtTrace.TraceLevel + }; + + // Subscribe to test host events. + TestHostManager.HostLaunched += TestHostManagerHostLaunched; + TestHostManager.HostExited += TestHostManagerHostExited; + + // Get environment variables from run settings. + var envVars = InferRunSettingsHelper.GetEnvironmentVariables(runSettings); + + // Get the test process start info. + var testHostStartInfo = UpdateTestProcessStartInfo( + TestHostManager.GetTestHostProcessStartInfo( + sources, + envVars, + connectionInfo)); + try + { + // Launch the test host. + _testHostLaunched = TestHostManager.LaunchTestHostAsync( + testHostStartInfo, + CancellationTokenSource.Token).Result; - var portNumber = 0; - if (testHostConnectionInfo.Role == ConnectionRole.Client) + if (_testHostLaunched && testHostConnectionInfo.Role == ConnectionRole.Host) { - portNumber = this.RequestSender.InitializeCommunication(); - testHostConnectionInfo.Endpoint += portNumber; + // If test runtime is service host, try to poll for connection as client. + RequestSender.InitializeCommunication(); } + } + catch (Exception ex) + { + EqtTrace.Error("ProxyOperationManager: Failed to launch testhost :{0}", ex); - var processId = this.processHelper.GetCurrentProcessId(); - var connectionInfo = new TestRunnerConnectionInfo() - { - Port = portNumber, - ConnectionInfo = testHostConnectionInfo, - RunnerProcessId = processId, - LogFile = this.GetTimestampedLogFile(EqtTrace.LogFile), - TraceLevel = (int)EqtTrace.TraceLevel - }; - - // Subscribe to test host events. - this.TestHostManager.HostLaunched += this.TestHostManagerHostLaunched; - this.TestHostManager.HostExited += this.TestHostManagerHostExited; - - // Get environment variables from run settings. - var envVars = InferRunSettingsHelper.GetEnvironmentVariables(runSettings); - - // Get the test process start info. - var testHostStartInfo = this.UpdateTestProcessStartInfo( - this.TestHostManager.GetTestHostProcessStartInfo( - sources, - envVars, - connectionInfo)); - try - { - // Launch the test host. - this.testHostLaunched = this.TestHostManager.LaunchTestHostAsync( - testHostStartInfo, - this.CancellationTokenSource.Token).Result; + CancellationTokenSource.Token.ThrowTestPlatformExceptionIfCancellationRequested(); + throw new TestPlatformException(string.Format( + CultureInfo.CurrentUICulture, + CrossPlatEngineResources.FailedToLaunchTestHost, + ex.ToString())); + } - if (this.testHostLaunched && testHostConnectionInfo.Role == ConnectionRole.Host) - { - // If test runtime is service host, try to poll for connection as client. - this.RequestSender.InitializeCommunication(); - } - } - catch (Exception ex) - { - EqtTrace.Error("ProxyOperationManager: Failed to launch testhost :{0}", ex); + // Warn the user that execution will wait for debugger attach. + var hostDebugEnabled = Environment.GetEnvironmentVariable("VSTEST_HOST_DEBUG"); + var nativeHostDebugEnabled = Environment.GetEnvironmentVariable("VSTEST_HOST_NATIVE_DEBUG"); - this.CancellationTokenSource.Token.ThrowTestPlatformExceptionIfCancellationRequested(); - throw new TestPlatformException(string.Format( - CultureInfo.CurrentUICulture, - CrossPlatEngineResources.FailedToLaunchTestHost, - ex.ToString())); - } + if ((!string.IsNullOrEmpty(hostDebugEnabled) + && hostDebugEnabled.Equals("1", StringComparison.Ordinal)) + || (new PlatformEnvironment().OperatingSystem.Equals(PlatformOperatingSystem.Windows) + && !string.IsNullOrEmpty(nativeHostDebugEnabled) + && nativeHostDebugEnabled.Equals("1", StringComparison.Ordinal))) + { + ConsoleOutput.Instance.WriteLine( + CrossPlatEngineResources.HostDebuggerWarning, + OutputLevel.Warning); - // Warn the user that execution will wait for debugger attach. - var hostDebugEnabled = Environment.GetEnvironmentVariable("VSTEST_HOST_DEBUG"); - var nativeHostDebugEnabled = Environment.GetEnvironmentVariable("VSTEST_HOST_NATIVE_DEBUG"); + ConsoleOutput.Instance.WriteLine( + string.Format( + "Process Id: {0}, Name: {1}", + _testHostProcessId, + _processHelper.GetProcessName(_testHostProcessId)), + OutputLevel.Information); - if ((!string.IsNullOrEmpty(hostDebugEnabled) - && hostDebugEnabled.Equals("1", StringComparison.Ordinal)) - || (new PlatformEnvironment().OperatingSystem.Equals(PlatformOperatingSystem.Windows) - && !string.IsNullOrEmpty(nativeHostDebugEnabled) - && nativeHostDebugEnabled.Equals("1", StringComparison.Ordinal))) - { - ConsoleOutput.Instance.WriteLine( - CrossPlatEngineResources.HostDebuggerWarning, - OutputLevel.Warning); - - ConsoleOutput.Instance.WriteLine( - string.Format( - "Process Id: {0}, Name: {1}", - this.testHostProcessId, - this.processHelper.GetProcessName(this.testHostProcessId)), - OutputLevel.Information); - - // Increase connection timeout when debugging is enabled. - connTimeout *= 5; - } + // Increase connection timeout when debugging is enabled. + connTimeout *= 5; + } - // If test host does not launch then throw exception, otherwise wait for connection. - if (!this.testHostLaunched - || !this.RequestSender.WaitForRequestHandlerConnection( - connTimeout * 1000, - this.CancellationTokenSource.Token)) - { - EqtTrace.Verbose($"Test host failed to start Test host launched:{testHostLaunched} test host exited: {testHostExited.IsSet}"); - // Throw a test platform exception with the appropriate message if user requested cancellation. - this.CancellationTokenSource.Token.ThrowTestPlatformExceptionIfCancellationRequested(); + // If test host does not launch then throw exception, otherwise wait for connection. + if (!_testHostLaunched + || !RequestSender.WaitForRequestHandlerConnection( + connTimeout * 1000, + CancellationTokenSource.Token)) + { + EqtTrace.Verbose($"Test host failed to start Test host launched:{_testHostLaunched} test host exited: {_testHostExited.IsSet}"); + // Throw a test platform exception with the appropriate message if user requested cancellation. + CancellationTokenSource.Token.ThrowTestPlatformExceptionIfCancellationRequested(); - // Throw a test platform exception along with the error messages from the test if the test host exited unexpectedly - // before communication was established. - this.ThrowOnTestHostExited(this.testHostExited.IsSet); + // Throw a test platform exception along with the error messages from the test if the test host exited unexpectedly + // before communication was established. + ThrowOnTestHostExited(_testHostExited.IsSet); - // Throw a test platform exception stating the connection to test could not be established even after waiting - // for the configure timeout period. - this.ThrowExceptionOnConnectionFailure(connTimeout); - } + // Throw a test platform exception stating the connection to test could not be established even after waiting + // for the configure timeout period. + ThrowExceptionOnConnectionFailure(connTimeout); + } - // Handling special case for dotnet core projects with older test hosts. - // Older test hosts are not aware of protocol version check, hence we should not be - // sending VersionCheck message to these test hosts. - this.CompatIssueWithVersionCheckAndRunsettings(); - if (this.versionCheckRequired) - { - this.RequestSender.CheckVersionWithTestHost(); - } + // Handling special case for dotnet core projects with older test hosts. + // Older test hosts are not aware of protocol version check, hence we should not be + // sending VersionCheck message to these test hosts. + CompatIssueWithVersionCheckAndRunsettings(); + if (_versionCheckRequired) + { + RequestSender.CheckVersionWithTestHost(); + } - this.initialized = true; + _initialized = true; - return true; - } + return true; + } - /// - /// Closes the channel and terminates the test host process. - /// - public virtual void Close() + /// + /// Closes the channel and terminates the test host process. + /// + public virtual void Close() + { + try { - try + // Do not send message if the host did not launch. + if (_testHostLaunched) { - // Do not send message if the host did not launch. - if (this.testHostLaunched) + RequestSender.EndSession(); + + // We want to give test host a chance to safely close. + // The upper bound for wait should be 100ms. + var timeout = 100; + EqtTrace.Verbose("ProxyOperationManager.Close: waiting for test host to exit for {0} ms", timeout); + if (!_testHostExited.Wait(timeout)) { - this.RequestSender.EndSession(); - - // We want to give test host a chance to safely close. - // The upper bound for wait should be 100ms. - var timeout = 100; - EqtTrace.Verbose("ProxyOperationManager.Close: waiting for test host to exit for {0} ms", timeout); - if (!this.testHostExited.Wait(timeout)) - { - EqtTrace.Warning("ProxyOperationManager: Timed out waiting for test host to exit. Will terminate process."); - } - - // Closing the communication channel. - this.RequestSender.Close(); + EqtTrace.Warning("ProxyOperationManager: Timed out waiting for test host to exit. Will terminate process."); } - } - catch (Exception ex) - { - // Error in sending an end session is not necessarily a failure. Discovery and execution should be already - // complete at this time. - EqtTrace.Warning("ProxyOperationManager: Failed to end session: " + ex); - } - finally - { - this.initialized = false; - - // Please clean up test host. - this.TestHostManager.CleanTestHostAsync(CancellationToken.None).Wait(); - this.TestHostManager.HostExited -= this.TestHostManagerHostExited; - this.TestHostManager.HostLaunched -= this.TestHostManagerHostLaunched; + // Closing the communication channel. + RequestSender.Close(); } } - - #endregion - - /// - /// This method is exposed to enable derived classes to modify - /// . For example, data collectors need additional - /// environment variables to be passed. - /// - /// - /// The test process start info. - /// - /// - /// The . - /// - public virtual TestProcessStartInfo UpdateTestProcessStartInfo(TestProcessStartInfo testProcessStartInfo) + catch (Exception ex) { - // TODO (copoiena): If called and testhost is already running, we should restart. - if (this.baseProxy == null) - { - // Update Telemetry Opt in status because by default in Test Host Telemetry is opted out - var telemetryOptedIn = this.RequestData.IsTelemetryOptedIn ? "true" : "false"; - testProcessStartInfo.Arguments += " --telemetryoptedin " + telemetryOptedIn; - return testProcessStartInfo; - } + // Error in sending an end session is not necessarily a failure. Discovery and execution should be already + // complete at this time. + EqtTrace.Warning("ProxyOperationManager: Failed to end session: " + ex); + } + finally + { + _initialized = false; - return this.baseProxy.UpdateTestProcessStartInfo(testProcessStartInfo); + // Please clean up test host. + TestHostManager.CleanTestHostAsync(CancellationToken.None).Wait(); + + TestHostManager.HostExited -= TestHostManagerHostExited; + TestHostManager.HostLaunched -= TestHostManagerHostLaunched; } + } - /// - /// This function will remove the unknown run settings nodes from the run settings strings. - /// This is necessary because older test hosts may throw exceptions when encountering - /// unknown nodes. - /// - /// - /// Run settings string. - /// - /// The run settings after removing non-required nodes. - public string RemoveNodesFromRunsettingsIfRequired(string runsettingsXml, Action logMessage) - { - var updatedRunSettingsXml = runsettingsXml; - if (!this.makeRunsettingsCompatibleSet) - { - this.CompatIssueWithVersionCheckAndRunsettings(); - } + #endregion - if (this.makeRunsettingsCompatible) - { - logMessage.Invoke(TestMessageLevel.Warning, CrossPlatEngineResources.OldTestHostIsGettingUsed); - updatedRunSettingsXml = InferRunSettingsHelper.MakeRunsettingsCompatible(runsettingsXml); - } + /// + /// This method is exposed to enable derived classes to modify + /// . For example, data collectors need additional + /// environment variables to be passed. + /// + /// + /// The test process start info. + /// + /// + /// The . + /// + public virtual TestProcessStartInfo UpdateTestProcessStartInfo(TestProcessStartInfo testProcessStartInfo) + { + // TODO (copoiena): If called and testhost is already running, we should restart. + if (_baseProxy == null) + { + // Update Telemetry Opt in status because by default in Test Host Telemetry is opted out + var telemetryOptedIn = RequestData.IsTelemetryOptedIn ? "true" : "false"; + testProcessStartInfo.Arguments += " --telemetryoptedin " + telemetryOptedIn; + return testProcessStartInfo; + } - // We can remove "TargetPlatform" because is not needed, process is already in a "specific" target platform after test host process start, - // so the default architecture is always the correct one. - // This allow us to support new architecture enumeration without the need to update old test sdk. - updatedRunSettingsXml = InferRunSettingsHelper.RemoveTargetPlatformElement(updatedRunSettingsXml); + return _baseProxy.UpdateTestProcessStartInfo(testProcessStartInfo); + } - return updatedRunSettingsXml; + /// + /// This function will remove the unknown run settings nodes from the run settings strings. + /// This is necessary because older test hosts may throw exceptions when encountering + /// unknown nodes. + /// + /// + /// Run settings string. + /// + /// The run settings after removing non-required nodes. + public string RemoveNodesFromRunsettingsIfRequired(string runsettingsXml, Action logMessage) + { + var updatedRunSettingsXml = runsettingsXml; + if (!_makeRunsettingsCompatibleSet) + { + CompatIssueWithVersionCheckAndRunsettings(); } - private string GetTimestampedLogFile(string logFile) + if (_makeRunsettingsCompatible) { - if (string.IsNullOrWhiteSpace(logFile)) - { - return null; - } + logMessage.Invoke(TestMessageLevel.Warning, CrossPlatEngineResources.OldTestHostIsGettingUsed); + updatedRunSettingsXml = InferRunSettingsHelper.MakeRunsettingsCompatible(runsettingsXml); + } + + // We can remove "TargetPlatform" because is not needed, process is already in a "specific" target platform after test host process start, + // so the default architecture is always the correct one. + // This allow us to support new architecture enumeration without the need to update old test sdk. + updatedRunSettingsXml = InferRunSettingsHelper.RemoveTargetPlatformElement(updatedRunSettingsXml); - return Path.ChangeExtension( + return updatedRunSettingsXml; + } + + private string GetTimestampedLogFile(string logFile) + { + return string.IsNullOrWhiteSpace(logFile) + ? null + : Path.ChangeExtension( logFile, string.Format( "host.{0}_{1}{2}", DateTime.Now.ToString("yy-MM-dd_HH-mm-ss_fffff"), new PlatformEnvironment().GetCurrentManagedThreadId(), Path.GetExtension(logFile))).AddDoubleQuote(); - } - - private void CompatIssueWithVersionCheckAndRunsettings() - { - var properties = this.TestHostManager.GetType().GetRuntimeProperties(); + } - var versionCheckProperty = properties.FirstOrDefault(p => string.Equals(p.Name, versionCheckPropertyName, StringComparison.OrdinalIgnoreCase)); - if (versionCheckProperty != null) - { - this.versionCheckRequired = (bool)versionCheckProperty.GetValue(this.TestHostManager); - } + private void CompatIssueWithVersionCheckAndRunsettings() + { + var properties = TestHostManager.GetType().GetRuntimeProperties(); - var makeRunsettingsCompatibleProperty = properties.FirstOrDefault(p => string.Equals(p.Name, makeRunsettingsCompatiblePropertyName, StringComparison.OrdinalIgnoreCase)); - if (makeRunsettingsCompatibleProperty != null) - { - this.makeRunsettingsCompatible = (bool)makeRunsettingsCompatibleProperty.GetValue(this.TestHostManager); - this.makeRunsettingsCompatibleSet = true; - } + var versionCheckProperty = properties.FirstOrDefault(p => string.Equals(p.Name, _versionCheckPropertyName, StringComparison.OrdinalIgnoreCase)); + if (versionCheckProperty != null) + { + _versionCheckRequired = (bool)versionCheckProperty.GetValue(TestHostManager); } - private void TestHostManagerHostLaunched(object sender, HostProviderEventArgs e) + var makeRunsettingsCompatibleProperty = properties.FirstOrDefault(p => string.Equals(p.Name, _makeRunsettingsCompatiblePropertyName, StringComparison.OrdinalIgnoreCase)); + if (makeRunsettingsCompatibleProperty != null) { - EqtTrace.Verbose(e.Data); - this.testHostProcessId = e.ProcessId; + _makeRunsettingsCompatible = (bool)makeRunsettingsCompatibleProperty.GetValue(TestHostManager); + _makeRunsettingsCompatibleSet = true; } + } + + private void TestHostManagerHostLaunched(object sender, HostProviderEventArgs e) + { + EqtTrace.Verbose(e.Data); + _testHostProcessId = e.ProcessId; + } - private void TestHostManagerHostExited(object sender, HostProviderEventArgs e) + private void TestHostManagerHostExited(object sender, HostProviderEventArgs e) + { + EqtTrace.Verbose("CrossPlatEngine.TestHostManagerHostExited: calling on client process exit callback."); + _testHostProcessStdError = e.Data; + + // This needs to be set before we call the OnClientProcess exit because the + // OnClientProcess will short-circuit WaitForRequestHandlerConnection in SetupChannel + // that then continues to throw an exception and checks if the test host process exited. + // If not it reports timeout, if we don't set this before OnClientProcessExit we will + // report timeout even though we exited the test host before even attempting the connect. + _testHostExited.Set(); + RequestSender.OnClientProcessExit(_testHostProcessStdError); + } + + private void ThrowOnTestHostExited(bool testHostExited) + { + if (testHostExited) { - EqtTrace.Verbose("CrossPlatEngine.TestHostManagerHostExited: calling on client process exit callback."); - this.testHostProcessStdError = e.Data; - - // This needs to be set before we call the OnClientProcess exit because the - // OnClientProcess will short-circuit WaitForRequestHandlerConnection in SetupChannel - // that then continues to throw an exception and checks if the test host process exited. - // If not it reports timeout, if we don't set this before OnClientProcessExit we will - // report timeout even though we exited the test host before even attempting the connect. - this.testHostExited.Set(); - this.RequestSender.OnClientProcessExit(this.testHostProcessStdError); + // We might consider passing standard output here in case standard error is not + // available because some errors don't end up in the standard error output. + throw new TestPlatformException(string.Format(CrossPlatEngineResources.TestHostExitedWithError, _testHostProcessStdError)); } + } - private void ThrowOnTestHostExited(bool testHostExited) + private void ThrowExceptionOnConnectionFailure(int connTimeout) + { + // Failed to launch testhost process. + var errorMsg = CrossPlatEngineResources.InitializationFailed; + + // Testhost launched but timeout occurred due to machine slowness. + if (_testHostLaunched) { - if (testHostExited) - { - // We might consider passing standard output here in case standard error is not - // available because some errors don't end up in the standard error output. - throw new TestPlatformException(string.Format(CrossPlatEngineResources.TestHostExitedWithError, this.testHostProcessStdError)); - } + errorMsg = string.Format( + CommunicationUtilitiesResources.ConnectionTimeoutErrorMessage, + CoreUtilitiesConstants.VstestConsoleProcessName, + CoreUtilitiesConstants.TesthostProcessName, + connTimeout, + EnvironmentHelper.VstestConnectionTimeout); } - private void ThrowExceptionOnConnectionFailure(int connTimeout) + // After testhost process launched failed with error. + if (!string.IsNullOrWhiteSpace(_testHostProcessStdError)) { - // Failed to launch testhost process. - var errorMsg = CrossPlatEngineResources.InitializationFailed; - - // Testhost launched but timeout occurred due to machine slowness. - if (this.testHostLaunched) - { - errorMsg = string.Format( - CommunicationUtilitiesResources.ConnectionTimeoutErrorMessage, - CoreUtilitiesConstants.VstestConsoleProcessName, - CoreUtilitiesConstants.TesthostProcessName, - connTimeout, - EnvironmentHelper.VstestConnectionTimeout); - } - - // After testhost process launched failed with error. - if (!string.IsNullOrWhiteSpace(this.testHostProcessStdError)) - { - // Testhost failed with error. - errorMsg = string.Format(CrossPlatEngineResources.TestHostExitedWithError, this.testHostProcessStdError); - } - - throw new TestPlatformException(string.Format(CultureInfo.CurrentUICulture, errorMsg)); + // Testhost failed with error. + errorMsg = string.Format(CrossPlatEngineResources.TestHostExitedWithError, _testHostProcessStdError); } + + throw new TestPlatformException(string.Format(CultureInfo.CurrentUICulture, errorMsg)); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManagerWithDataCollection.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManagerWithDataCollection.cs index 67b8b07c4c..6345f14ade 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManagerWithDataCollection.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManagerWithDataCollection.cs @@ -1,146 +1,145 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client -{ - using System; - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; + +using System; +using System.Collections.Generic; + +using CommunicationUtilities.Interfaces; +using DataCollection.Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; +/// +/// The proxy operation manager with data collection. +/// +public class ProxyOperationManagerWithDataCollection : ProxyOperationManager +{ + private IDictionary _dataCollectionEnvironmentVariables; + private readonly IRequestData _requestData; + private int _dataCollectionPort; /// - /// The proxy operation manager with data collection. + /// Initializes a new instance of the + /// class. /// - public class ProxyOperationManagerWithDataCollection : ProxyOperationManager + /// + /// The request data. + /// The request sender. + /// The test host manager. + /// The data collection proxy. + public ProxyOperationManagerWithDataCollection( + IRequestData requestData, + ITestRequestSender requestSender, + ITestRuntimeProvider testHostManager, + IProxyDataCollectionManager proxyDataCollectionManager) + : base( + requestData, + requestSender, + testHostManager) { - private IDictionary dataCollectionEnvironmentVariables; - private IRequestData requestData; - private int dataCollectionPort; - - /// - /// Initializes a new instance of the - /// class. - /// - /// - /// The request data. - /// The request sender. - /// The test host manager. - /// The data collection proxy. - public ProxyOperationManagerWithDataCollection( - IRequestData requestData, - ITestRequestSender requestSender, - ITestRuntimeProvider testHostManager, - IProxyDataCollectionManager proxyDataCollectionManager) - : base( - requestData, - requestSender, - testHostManager) - { - this.ProxyDataCollectionManager = proxyDataCollectionManager; - this.DataCollectionRunEventsHandler = new DataCollectionRunEventsHandler(); - this.requestData = requestData; - this.dataCollectionEnvironmentVariables = new Dictionary(); + ProxyDataCollectionManager = proxyDataCollectionManager; + DataCollectionRunEventsHandler = new DataCollectionRunEventsHandler(); + _requestData = requestData; + _dataCollectionEnvironmentVariables = new Dictionary(); - testHostManager.HostLaunched += this.TestHostLaunchedHandler; - } + testHostManager.HostLaunched += TestHostLaunchedHandler; + } + + /// + public override void Initialize(bool skipDefaultAdapters) + { + ProxyDataCollectionManager.Initialize(); - /// - public override void Initialize(bool skipDefaultAdapters) + try { - this.ProxyDataCollectionManager.Initialize(); + var dataCollectionParameters = ProxyDataCollectionManager.BeforeTestRunStart( + resetDataCollectors: true, + isRunStartingNow: true, + runEventsHandler: DataCollectionRunEventsHandler); - try - { - var dataCollectionParameters = this.ProxyDataCollectionManager.BeforeTestRunStart( - resetDataCollectors: true, - isRunStartingNow: true, - runEventsHandler: this.DataCollectionRunEventsHandler); - - if (dataCollectionParameters != null) - { - this.dataCollectionEnvironmentVariables = dataCollectionParameters.EnvironmentVariables; - this.dataCollectionPort = dataCollectionParameters.DataCollectionEventsPort; - } - } - catch (Exception) + if (dataCollectionParameters != null) { - // On failure in calling BeforeTestRunStart, call AfterTestRunEnd to end the data - // collection process. - this.ProxyDataCollectionManager.AfterTestRunEnd( - isCanceled: true, - runEventsHandler: this.DataCollectionRunEventsHandler); - throw; + _dataCollectionEnvironmentVariables = dataCollectionParameters.EnvironmentVariables; + _dataCollectionPort = dataCollectionParameters.DataCollectionEventsPort; } - - base.Initialize(skipDefaultAdapters); + } + catch (Exception) + { + // On failure in calling BeforeTestRunStart, call AfterTestRunEnd to end the data + // collection process. + ProxyDataCollectionManager.AfterTestRunEnd( + isCanceled: true, + runEventsHandler: DataCollectionRunEventsHandler); + throw; } - /// - public override TestProcessStartInfo UpdateTestProcessStartInfo(TestProcessStartInfo testProcessStartInfo) + base.Initialize(skipDefaultAdapters); + } + + /// + public override TestProcessStartInfo UpdateTestProcessStartInfo(TestProcessStartInfo testProcessStartInfo) + { + if (testProcessStartInfo.EnvironmentVariables == null) { - if (testProcessStartInfo.EnvironmentVariables == null) - { - testProcessStartInfo.EnvironmentVariables = this.dataCollectionEnvironmentVariables; - } - else + testProcessStartInfo.EnvironmentVariables = _dataCollectionEnvironmentVariables; + } + else + { + foreach (var kvp in _dataCollectionEnvironmentVariables) { - foreach (var kvp in this.dataCollectionEnvironmentVariables) - { - testProcessStartInfo.EnvironmentVariables[kvp.Key] = kvp.Value; - } + testProcessStartInfo.EnvironmentVariables[kvp.Key] = kvp.Value; } + } - // Update telemetry opt in status because by default test host telemetry is opted out. - var telemetryOptedIn = this.requestData.IsTelemetryOptedIn ? "true" : "false"; - testProcessStartInfo.Arguments += " --datacollectionport " + this.dataCollectionPort - + " --telemetryoptedin " + telemetryOptedIn; + // Update telemetry opt in status because by default test host telemetry is opted out. + var telemetryOptedIn = _requestData.IsTelemetryOptedIn ? "true" : "false"; + testProcessStartInfo.Arguments += " --datacollectionport " + _dataCollectionPort + + " --telemetryoptedin " + telemetryOptedIn; - return testProcessStartInfo; - } + return testProcessStartInfo; + } - /// - public override bool SetupChannel( - IEnumerable sources, - string runSettings, - ITestMessageEventHandler eventHandler) + /// + public override bool SetupChannel( + IEnumerable sources, + string runSettings, + ITestMessageEventHandler eventHandler) + { + // Log all the messages that are reported while initializing the DataCollectionClient. + if (DataCollectionRunEventsHandler.Messages.Count > 0) { - // Log all the messages that are reported while initializing the DataCollectionClient. - if (this.DataCollectionRunEventsHandler.Messages.Count > 0) + foreach (var message in DataCollectionRunEventsHandler.Messages) { - foreach (var message in this.DataCollectionRunEventsHandler.Messages) - { - eventHandler.HandleLogMessage(message.Item1, message.Item2); - } - - this.DataCollectionRunEventsHandler.Messages.Clear(); + eventHandler.HandleLogMessage(message.Item1, message.Item2); } - return base.SetupChannel(sources, runSettings); + DataCollectionRunEventsHandler.Messages.Clear(); } - /// - /// Gets the data collection run events handler. - /// - internal DataCollectionRunEventsHandler DataCollectionRunEventsHandler - { - get; private set; - } + return base.SetupChannel(sources, runSettings); + } - /// - /// Gets the proxy data collection manager. - /// - internal IProxyDataCollectionManager ProxyDataCollectionManager - { - get; private set; - } + /// + /// Gets the data collection run events handler. + /// + internal DataCollectionRunEventsHandler DataCollectionRunEventsHandler + { + get; private set; + } - private void TestHostLaunchedHandler(object sender, HostProviderEventArgs e) - { - this.ProxyDataCollectionManager.TestHostLaunched(e.ProcessId); - } + /// + /// Gets the proxy data collection manager. + /// + internal IProxyDataCollectionManager ProxyDataCollectionManager + { + get; private set; + } + + private void TestHostLaunchedHandler(object sender, HostProviderEventArgs e) + { + ProxyDataCollectionManager.TestHostLaunched(e.ProcessId); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/TestLoggerManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/TestLoggerManager.cs index 25ba5e7e07..b584b901ac 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/TestLoggerManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/TestLoggerManager.cs @@ -1,685 +1,684 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Reflection; +using System.Xml; + +using Common.Exceptions; +using Common.ExtensionFramework; +using Common.Logging; +using Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; +using ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using PlatformAbstractions; +using PlatformAbstractions.Interfaces; + +using CommonResources = Common.Resources.Resources; + +/// +/// Responsible for managing logger extensions and broadcasting results +/// and error/warning/informational messages to them. +/// +internal class TestLoggerManager : ITestLoggerManager { - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Globalization; - using System.Linq; - using System.Reflection; - using System.Xml; - using Microsoft.VisualStudio.TestPlatform.Common.Exceptions; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using CommonResources = Common.Resources.Resources; - - /// - /// Responsible for managing logger extensions and broadcasting results - /// and error/warning/informational messages to them. - /// - internal class TestLoggerManager : ITestLoggerManager - { - #region FieldsLog - - /// - /// Keeps track if we are disposed. - /// - private bool isDisposed = false; - - /// - /// Used to keep track of which loggers have been initialized. - /// - private HashSet initializedLoggers = new HashSet(); - - /// - /// Test run directory. - /// - private string testRunDirectory; - - /// - /// Target framework. - /// - private string targetFramework; - - /// - /// TreatNoTestsAsError value; - /// - private bool treatNoTestsAsError; - - /// - /// Test Logger Events instance which will be passed to loggers when they are initialized. - /// - private InternalTestLoggerEvents loggerEvents; - - /// - /// Message logger. - /// - private IMessageLogger messageLogger; - - /// - /// Request data. - /// - private IRequestData requestData; - - /// - /// Logger extension manager. - /// - private TestLoggerExtensionManager testLoggerExtensionManager; - - /// - /// AssemblyLoadContext for current platform - /// - private IAssemblyLoadContext assemblyLoadContext; - - #endregion - - #region Constructor - - /// - /// Test logger manager. - /// - /// Request Data for Providing Common Services/Data for Discovery and Execution. - /// Message Logger. - /// Logger events. - public TestLoggerManager(IRequestData requestData, IMessageLogger messageLogger, InternalTestLoggerEvents loggerEvents) : this(requestData, messageLogger, loggerEvents, new PlatformAssemblyLoadContext()) - { - } - - /// - /// Test logger manager. - /// - /// - /// - /// - /// - internal TestLoggerManager(IRequestData requestData, IMessageLogger messageLogger, - InternalTestLoggerEvents loggerEvents, IAssemblyLoadContext assemblyLoadContext) - { - this.requestData = requestData; - this.messageLogger = messageLogger; - this.testLoggerExtensionManager = null; - this.loggerEvents = loggerEvents; - this.assemblyLoadContext = assemblyLoadContext; - } - - #endregion + #region FieldsLog - #region Properties + /// + /// Keeps track if we are disposed. + /// + private bool _isDisposed = false; - /// - /// Loggers initialized flag. - /// - public bool LoggersInitialized => this.initializedLoggers.Any(); + /// + /// Used to keep track of which loggers have been initialized. + /// + private readonly HashSet _initializedLoggers = new(); - private TestLoggerExtensionManager TestLoggerExtensionManager - { - get - { - if (this.testLoggerExtensionManager == null) - { - this.testLoggerExtensionManager = TestLoggerExtensionManager.Create(messageLogger); - } + /// + /// Test run directory. + /// + private string _testRunDirectory; - return this.testLoggerExtensionManager; - } - } + /// + /// Target framework. + /// + private string _targetFramework; - #endregion + /// + /// TreatNoTestsAsError value; + /// + private bool _treatNoTestsAsError; - #region Public Methods + /// + /// Test Logger Events instance which will be passed to loggers when they are initialized. + /// + private readonly InternalTestLoggerEvents _loggerEvents; - /// - /// Initializes all the loggers passed by user - /// - public void Initialize(string runSettings) - { - // Enable logger events - EnableLogging(); + /// + /// Message logger. + /// + private readonly IMessageLogger _messageLogger; - // Store test run directory. This runsettings is the final runsettings merging CLI args and runsettings. - this.testRunDirectory = GetResultsDirectory(runSettings); - this.targetFramework = GetTargetFramework(runSettings)?.Name; - this.treatNoTestsAsError = GetTreatNoTestsAsError(runSettings); + /// + /// Request data. + /// + private readonly IRequestData _requestData; - var loggers = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettings); + /// + /// Logger extension manager. + /// + private TestLoggerExtensionManager _testLoggerExtensionManager; - foreach (var logger in loggers?.LoggerSettingsList ?? Enumerable.Empty()) - { - // Don't add logger if its disabled. - if (!logger.IsEnabled) - { - continue; - } + /// + /// AssemblyLoadContext for current platform + /// + private readonly IAssemblyLoadContext _assemblyLoadContext; - var parameters = GetParametersFromConfigurationElement(logger.Configuration); - var loggerInitialized = false; + #endregion - // Try initializing logger by type. - if (!string.IsNullOrWhiteSpace(logger.AssemblyQualifiedName)) - { - loggerInitialized = InitializeLoggerByType(logger.AssemblyQualifiedName, logger.CodeBase, parameters); - } + #region Constructor - // Try initializing logger by uri. - if (!loggerInitialized && - !string.IsNullOrWhiteSpace(logger.Uri?.ToString())) - { - loggerInitialized = InitializeLoggerByUri(logger.Uri, parameters); - } + /// + /// Test logger manager. + /// + /// Request Data for Providing Common Services/Data for Discovery and Execution. + /// Message Logger. + /// Logger events. + public TestLoggerManager(IRequestData requestData, IMessageLogger messageLogger, InternalTestLoggerEvents loggerEvents) : this(requestData, messageLogger, loggerEvents, new PlatformAssemblyLoadContext()) + { + } - // Try initializing logger by friendly name. - if (!loggerInitialized && - TryGetUriFromFriendlyName(logger.FriendlyName, out var loggerUri) && - loggerUri != null) - { - loggerInitialized = InitializeLoggerByUri(loggerUri, parameters); - } + /// + /// Test logger manager. + /// + /// + /// + /// + /// + internal TestLoggerManager(IRequestData requestData, IMessageLogger messageLogger, + InternalTestLoggerEvents loggerEvents, IAssemblyLoadContext assemblyLoadContext) + { + _requestData = requestData; + _messageLogger = messageLogger; + _testLoggerExtensionManager = null; + _loggerEvents = loggerEvents; + _assemblyLoadContext = assemblyLoadContext; + } - // Output error if logger is not initialized. - if (!loggerInitialized) - { - var value = !string.IsNullOrWhiteSpace(logger.AssemblyQualifiedName) - ? logger.AssemblyQualifiedName - : !string.IsNullOrWhiteSpace(logger.Uri?.ToString()) - ? logger.Uri.ToString() - : logger.FriendlyName; + #endregion - throw new InvalidLoggerException( - string.Format( - CultureInfo.CurrentUICulture, - CommonResources.LoggerNotFound, - value)); - } - } + #region Properties - requestData.MetricsCollection.Add(TelemetryDataConstants.LoggerUsed, string.Join(",", this.initializedLoggers.ToArray())); - } + /// + /// Loggers initialized flag. + /// + public bool LoggersInitialized => _initializedLoggers.Any(); - /// - /// Handles test run message event. - /// - /// TestRunMessage event args. - public void HandleTestRunMessage(TestRunMessageEventArgs e) + private TestLoggerExtensionManager TestLoggerExtensionManager + { + get { - if (this.isDisposed) + if (_testLoggerExtensionManager == null) { - EqtTrace.Warning("TestLoggerManager.HandleTestRunMessage: Ignoring as the object is disposed."); - return; + _testLoggerExtensionManager = TestLoggerExtensionManager.Create(_messageLogger); } - this.loggerEvents.RaiseTestRunMessage(e); + return _testLoggerExtensionManager; } + } + + #endregion + + #region Public Methods + + /// + /// Initializes all the loggers passed by user + /// + public void Initialize(string runSettings) + { + // Enable logger events + EnableLogging(); + + // Store test run directory. This runsettings is the final runsettings merging CLI args and runsettings. + _testRunDirectory = GetResultsDirectory(runSettings); + _targetFramework = GetTargetFramework(runSettings)?.Name; + _treatNoTestsAsError = GetTreatNoTestsAsError(runSettings); + + var loggers = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettings); - /// - /// Handle test run stats change event. - /// - /// TestRunChanged event args. - public void HandleTestRunStatsChange(TestRunChangedEventArgs e) + foreach (var logger in loggers?.LoggerSettingsList ?? Enumerable.Empty()) { - if (this.isDisposed) + // Don't add logger if its disabled. + if (!logger.IsEnabled) { - EqtTrace.Warning("TestLoggerManager.HandleTestRunStatsChange: Ignoring as the object is disposed."); - return; + continue; } - foreach (TestResult result in e.NewTestResults) + var parameters = GetParametersFromConfigurationElement(logger.Configuration); + var loggerInitialized = false; + + // Try initializing logger by type. + if (!string.IsNullOrWhiteSpace(logger.AssemblyQualifiedName)) { - this.loggerEvents.RaiseTestResult(new TestResultEventArgs(result)); + loggerInitialized = InitializeLoggerByType(logger.AssemblyQualifiedName, logger.CodeBase, parameters); } - } - /// - /// Handles test run start event. - /// - /// TestRunStart event args. - public void HandleTestRunStart(TestRunStartEventArgs e) - { - if (this.isDisposed) + // Try initializing logger by uri. + if (!loggerInitialized && + !string.IsNullOrWhiteSpace(logger.Uri?.ToString())) { - EqtTrace.Warning("TestLoggerManager.HandleTestRunStart: Ignoring as the object is disposed."); - return; + loggerInitialized = InitializeLoggerByUri(logger.Uri, parameters); } - this.loggerEvents.RaiseTestRunStart(e); - } - - /// - /// Handles test run complete. - /// - /// TestRunComplete event args. - public void HandleTestRunComplete(TestRunCompleteEventArgs e) - { - if (!this.isDisposed) + // Try initializing logger by friendly name. + if (!loggerInitialized && + TryGetUriFromFriendlyName(logger.FriendlyName, out var loggerUri) && + loggerUri != null) { - try - { - this.loggerEvents.CompleteTestRun(e.TestRunStatistics, e.IsCanceled, e.IsAborted, e.Error, - e.AttachmentSets, e.InvokedDataCollectors, e.ElapsedTimeInRunningTests); - } - finally - { - this.Dispose(); - } + loggerInitialized = InitializeLoggerByUri(loggerUri, parameters); } - else + + // Output error if logger is not initialized. + if (!loggerInitialized) { - // Note: We are not raising warning in case testLoggerManager is disposed as HandleRawMessage and HandleTestRunComplete both can call HandleTestRunComplete. - EqtTrace.Verbose("TestLoggerManager.HandleTestRunComplete: Ignoring as the object is disposed."); + var value = !string.IsNullOrWhiteSpace(logger.AssemblyQualifiedName) + ? logger.AssemblyQualifiedName + : !string.IsNullOrWhiteSpace(logger.Uri?.ToString()) + ? logger.Uri.ToString() + : logger.FriendlyName; + + throw new InvalidLoggerException( + string.Format( + CultureInfo.CurrentUICulture, + CommonResources.LoggerNotFound, + value)); } } - /// - /// Handles discovery message event. - /// - /// TestRunMessage event args. - public void HandleDiscoveryMessage(TestRunMessageEventArgs e) + _requestData.MetricsCollection.Add(TelemetryDataConstants.LoggerUsed, string.Join(",", _initializedLoggers.ToArray())); + } + + /// + /// Handles test run message event. + /// + /// TestRunMessage event args. + public void HandleTestRunMessage(TestRunMessageEventArgs e) + { + if (_isDisposed) { - if (this.isDisposed) - { - EqtTrace.Warning("TestLoggerManager.HandleDiscoveryMessage: Ignoring as the object is disposed."); - return; - } + EqtTrace.Warning("TestLoggerManager.HandleTestRunMessage: Ignoring as the object is disposed."); + return; + } - this.loggerEvents.RaiseDiscoveryMessage(e); + _loggerEvents.RaiseTestRunMessage(e); + } + + /// + /// Handle test run stats change event. + /// + /// TestRunChanged event args. + public void HandleTestRunStatsChange(TestRunChangedEventArgs e) + { + if (_isDisposed) + { + EqtTrace.Warning("TestLoggerManager.HandleTestRunStatsChange: Ignoring as the object is disposed."); + return; } - /// - /// Handle discovered tests. - /// - /// DiscoveredTests event args. - public void HandleDiscoveredTests(DiscoveredTestsEventArgs e) + foreach (TestResult result in e.NewTestResults) { - if (this.isDisposed) - { - EqtTrace.Warning("TestLoggerManager.HandleDiscoveredTests: Ignoring as the object is disposed."); - return; - } + _loggerEvents.RaiseTestResult(new TestResultEventArgs(result)); + } + } - this.loggerEvents.RaiseDiscoveredTests(e); + /// + /// Handles test run start event. + /// + /// TestRunStart event args. + public void HandleTestRunStart(TestRunStartEventArgs e) + { + if (_isDisposed) + { + EqtTrace.Warning("TestLoggerManager.HandleTestRunStart: Ignoring as the object is disposed."); + return; } - /// - /// Handles discovery complete event. - /// - /// DiscoveryComplete event args. - public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs e) + _loggerEvents.RaiseTestRunStart(e); + } + + /// + /// Handles test run complete. + /// + /// TestRunComplete event args. + public void HandleTestRunComplete(TestRunCompleteEventArgs e) + { + if (!_isDisposed) { - if (!this.isDisposed) + try { - try - { - this.loggerEvents.RaiseDiscoveryComplete(e); - } - finally - { - this.Dispose(); - } + _loggerEvents.CompleteTestRun(e.TestRunStatistics, e.IsCanceled, e.IsAborted, e.Error, + e.AttachmentSets, e.InvokedDataCollectors, e.ElapsedTimeInRunningTests); } - else + finally { - // Note: We are not raising warning in case testLoggerManager is disposed as HandleRawMessage and HandleDiscoveryComplete both can call HandleDiscoveryComplete. - EqtTrace.Verbose("TestLoggerManager.HandleDiscoveryComplete: Ignoring as the object is disposed."); + Dispose(); } } - - /// - /// Handles discovery start event. - /// - /// DiscoveryStart event args. - public void HandleDiscoveryStart(DiscoveryStartEventArgs e) + else { - if (this.isDisposed) - { - EqtTrace.Warning("TestLoggerManager.HandleDiscoveryStart: Ignoring as the object is disposed."); - return; - } - - this.loggerEvents.RaiseDiscoveryStart(e); + // Note: We are not raising warning in case testLoggerManager is disposed as HandleRawMessage and HandleTestRunComplete both can call HandleTestRunComplete. + EqtTrace.Verbose("TestLoggerManager.HandleTestRunComplete: Ignoring as the object is disposed."); } + } - /// - /// Ensure that all pending messages are sent to the loggers. - /// - public void Dispose() + /// + /// Handles discovery message event. + /// + /// TestRunMessage event args. + public void HandleDiscoveryMessage(TestRunMessageEventArgs e) + { + if (_isDisposed) { - this.Dispose(true); - - // Use SupressFinalize in case a subclass - // of this type implements a finalizer. - GC.SuppressFinalize(this); + EqtTrace.Warning("TestLoggerManager.HandleDiscoveryMessage: Ignoring as the object is disposed."); + return; } - #endregion - - /// - /// Initializes logger with the specified URI and parameters. - /// For ex. TfsPublisher takes parameters such as Platform, Flavor etc. - /// - /// URI of the logger to add. - /// Logger parameters. - /// Logger Initialized flag. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2234:PassSystemUriObjectsInsteadOfStrings", Justification = "Case insensitive needs to be supported "), SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Third party loggers could potentially throw all kinds of exceptions.")] - internal bool InitializeLoggerByUri(Uri uri, Dictionary parameters) + _loggerEvents.RaiseDiscoveryMessage(e); + } + + /// + /// Handle discovered tests. + /// + /// DiscoveredTests event args. + public void HandleDiscoveredTests(DiscoveredTestsEventArgs e) + { + if (_isDisposed) { - ValidateArg.NotNull(uri, nameof(uri)); - this.CheckDisposed(); + EqtTrace.Warning("TestLoggerManager.HandleDiscoveredTests: Ignoring as the object is disposed."); + return; + } - // Look up the extension and initialize it if one is found. - var extensionManager = this.TestLoggerExtensionManager; - var logger = extensionManager.TryGetTestExtension(uri.AbsoluteUri); + _loggerEvents.RaiseDiscoveredTests(e); + } - if (logger == null) + /// + /// Handles discovery complete event. + /// + /// DiscoveryComplete event args. + public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs e) + { + if (!_isDisposed) + { + try { - return false; + _loggerEvents.RaiseDiscoveryComplete(e); } - - // If the logger has already been initialized just return. - if (this.initializedLoggers.Contains(logger.Value.GetType())) + finally { - EqtTrace.Verbose("TestLoggerManager: Skipping duplicate logger initialization: {0}", logger.Value.GetType()); - return true; + Dispose(); } + } + else + { + // Note: We are not raising warning in case testLoggerManager is disposed as HandleRawMessage and HandleDiscoveryComplete both can call HandleDiscoveryComplete. + EqtTrace.Verbose("TestLoggerManager.HandleDiscoveryComplete: Ignoring as the object is disposed."); + } + } - // Initialize logger. - var initialized = InitializeLogger(logger.Value, logger.Metadata.ExtensionUri, parameters); + /// + /// Handles discovery start event. + /// + /// DiscoveryStart event args. + public void HandleDiscoveryStart(DiscoveryStartEventArgs e) + { + if (_isDisposed) + { + EqtTrace.Warning("TestLoggerManager.HandleDiscoveryStart: Ignoring as the object is disposed."); + return; + } - // Add logger in initializedLoggers list. - if (initialized) - { - this.initializedLoggers.Add(logger.Value.GetType()); - } + _loggerEvents.RaiseDiscoveryStart(e); + } - return initialized; - } + /// + /// Ensure that all pending messages are sent to the loggers. + /// + public void Dispose() + { + Dispose(true); - /// - /// Tries to get uri of the logger corresponding to the friendly name. If no such logger exists return null. - /// - /// The friendly Name. - /// The logger Uri. - /// - internal bool TryGetUriFromFriendlyName(string friendlyName, out Uri loggerUri) - { - var extensionManager = this.TestLoggerExtensionManager; - foreach (var extension in extensionManager.TestExtensions) - { - if (string.Equals(friendlyName, extension.Metadata.FriendlyName, StringComparison.OrdinalIgnoreCase)) - { - try - { - loggerUri = new Uri(extension.Metadata.ExtensionUri); - } - catch (UriFormatException) - { - loggerUri = null; - - throw new InvalidLoggerException( - string.Format( - CultureInfo.CurrentUICulture, - CommonResources.LoggerUriInvalid, - extension.Metadata.ExtensionUri)); - } - - return true; - } - } + // Use SupressFinalize in case a subclass + // of this type implements a finalizer. + GC.SuppressFinalize(this); + } + + #endregion - loggerUri = null; + /// + /// Initializes logger with the specified URI and parameters. + /// For ex. TfsPublisher takes parameters such as Platform, Flavor etc. + /// + /// URI of the logger to add. + /// Logger parameters. + /// Logger Initialized flag. + internal bool InitializeLoggerByUri(Uri uri, Dictionary parameters) + { + ValidateArg.NotNull(uri, nameof(uri)); + CheckDisposed(); + + // Look up the extension and initialize it if one is found. + var extensionManager = TestLoggerExtensionManager; + var logger = extensionManager.TryGetTestExtension(uri.AbsoluteUri); + + if (logger == null) + { return false; } - /// - /// Gets the test results directory. - /// - /// Test run settings. - /// Test results directory - internal string GetResultsDirectory(string runSettings) + // If the logger has already been initialized just return. + if (_initializedLoggers.Contains(logger.Value.GetType())) { - string resultsDirectory = null; - if (runSettings != null) - { - try - { - RunConfiguration runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runSettings); - resultsDirectory = RunSettingsUtilities.GetTestResultsDirectory(runConfiguration); - } - catch (SettingsException se) - { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("TestLoggerManager.GetResultsDirectory: Unable to get the test results directory: Error {0}", se); - } - } - } + EqtTrace.Verbose("TestLoggerManager: Skipping duplicate logger initialization: {0}", logger.Value.GetType()); + return true; + } - return resultsDirectory; + // Initialize logger. + var initialized = InitializeLogger(logger.Value, logger.Metadata.ExtensionUri, parameters); + + // Add logger in initializedLoggers list. + if (initialized) + { + _initializedLoggers.Add(logger.Value.GetType()); } - /// - /// Gets the target framework of the test run. - /// - /// Test run settings. - /// Target framework - internal Framework GetTargetFramework(string runSettings) + return initialized; + } + + /// + /// Tries to get uri of the logger corresponding to the friendly name. If no such logger exists return null. + /// + /// The friendly Name. + /// The logger Uri. + /// + internal bool TryGetUriFromFriendlyName(string friendlyName, out Uri loggerUri) + { + var extensionManager = TestLoggerExtensionManager; + foreach (var extension in extensionManager.TestExtensions) { - Framework targetFramework = null; - if (runSettings != null) + if (string.Equals(friendlyName, extension.Metadata.FriendlyName, StringComparison.OrdinalIgnoreCase)) { try { - RunConfiguration runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runSettings); - targetFramework = RunSettingsUtilities.GetTargetFramework(runConfiguration); + loggerUri = new Uri(extension.Metadata.ExtensionUri); } - catch (SettingsException se) + catch (UriFormatException) { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("TestLoggerManager.GetResultsDirectory: Unable to get the target framework: Error {0}", se); - } - } - } + loggerUri = null; - return targetFramework; - } + throw new InvalidLoggerException( + string.Format( + CultureInfo.CurrentUICulture, + CommonResources.LoggerUriInvalid, + extension.Metadata.ExtensionUri)); + } - /// - /// Get TreatNoTestsAsError value of the test run - /// - /// - /// - internal bool GetTreatNoTestsAsError(string runSettings) - { - return RunSettingsUtilities.GetTreatNoTestsAsError(runSettings); + return true; + } } - /// - /// Enables sending of events to the loggers which are registered. - /// - /// - /// By default events are disabled and will not be raised until this method is called. - /// This is done because during logger initialization, errors could be sent and we do not - /// want them broadcast out to the loggers until all loggers have been enabled. Without this - /// all loggers would not receive the errors which were sent prior to initialization finishing. - /// - internal void EnableLogging() - { - this.CheckDisposed(); - this.loggerEvents.EnableEvents(); - } + loggerUri = null; + return false; + } - /// - /// Ensure that all pending messages are sent to the loggers. - /// - /// - /// The disposing. - /// - internal virtual void Dispose(bool disposing) + /// + /// Gets the test results directory. + /// + /// Test run settings. + /// Test results directory + internal string GetResultsDirectory(string runSettings) + { + string resultsDirectory = null; + if (runSettings != null) { - if (!this.isDisposed) + try { - if (disposing) + RunConfiguration runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runSettings); + resultsDirectory = RunSettingsUtilities.GetTestResultsDirectory(runConfiguration); + } + catch (SettingsException se) + { + if (EqtTrace.IsErrorEnabled) { - this.loggerEvents.Dispose(); + EqtTrace.Error("TestLoggerManager.GetResultsDirectory: Unable to get the test results directory: Error {0}", se); } - - this.isDisposed = true; } } - /// - /// Get parameters from configuration element. - /// - /// - /// - private Dictionary GetParametersFromConfigurationElement(XmlElement configuration) - { - var configurationManager = new LoggerNameValueConfigurationManager(configuration); - return configurationManager.NameValuePairs; - } + return resultsDirectory; + } - /// - /// Initialize logger with the specified type and parameters. - /// - /// Assembly qualified name. - /// Code base. - /// Logger parameters. - /// Logger Initialized flag. - private bool InitializeLoggerByType(string assemblyQualifiedName, string codeBase, Dictionary parameters) + /// + /// Gets the target framework of the test run. + /// + /// Test run settings. + /// Target framework + internal Framework GetTargetFramework(string runSettings) + { + Framework targetFramework = null; + if (runSettings != null) { - this.CheckDisposed(); try { - // Load logger assembly. - Assembly assembly = this.assemblyLoadContext.LoadAssemblyFromPath(codeBase); - var loggerType = - assembly?.GetTypes() - .FirstOrDefault(x => x.AssemblyQualifiedName.Equals(assemblyQualifiedName)); - - // Create logger instance - var constructorInfo = loggerType?.GetConstructor(Type.EmptyTypes); - var logger = constructorInfo?.Invoke(new object[] { }); - - // Handle logger null scenario. - if (logger == null) + RunConfiguration runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runSettings); + targetFramework = RunSettingsUtilities.GetTargetFramework(runConfiguration); + } + catch (SettingsException se) + { + if (EqtTrace.IsErrorEnabled) { - return false; + EqtTrace.Error("TestLoggerManager.GetResultsDirectory: Unable to get the target framework: Error {0}", se); } + } + } - // If the logger has already been initialized just return. - if (this.initializedLoggers.Contains(logger.GetType())) - { - EqtTrace.Verbose("TestLoggerManager: Skipping duplicate logger initialization: {0}", logger.GetType()); - return true; - } + return targetFramework; + } - // Get Logger instance and initialize. - var initialized = InitializeLogger(logger, null, parameters); + /// + /// Get TreatNoTestsAsError value of the test run + /// + /// + /// + internal bool GetTreatNoTestsAsError(string runSettings) + { + return RunSettingsUtilities.GetTreatNoTestsAsError(runSettings); + } - // Add logger in initializedLoggers list. - if (initialized) - { - this.initializedLoggers.Add(logger.GetType()); - } + /// + /// Enables sending of events to the loggers which are registered. + /// + /// + /// By default events are disabled and will not be raised until this method is called. + /// This is done because during logger initialization, errors could be sent and we do not + /// want them broadcast out to the loggers until all loggers have been enabled. Without this + /// all loggers would not receive the errors which were sent prior to initialization finishing. + /// + internal void EnableLogging() + { + CheckDisposed(); + _loggerEvents.EnableEvents(); + } - return initialized; - } - catch (Exception ex) + /// + /// Ensure that all pending messages are sent to the loggers. + /// + /// + /// The disposing. + /// + internal virtual void Dispose(bool disposing) + { + if (!_isDisposed) + { + if (disposing) { - EqtTrace.Error( - "TestLoggerManager: Error occurred while initializing the Logger assemblyQualifiedName : {0}, codeBase : {1} , Exception Details : {2}", assemblyQualifiedName, codeBase, ex); - return false; + _loggerEvents.Dispose(); } + + _isDisposed = true; } + } - private bool InitializeLogger(object logger, string extensionUri, Dictionary parameters) + /// + /// Get parameters from configuration element. + /// + /// + /// + private Dictionary GetParametersFromConfigurationElement(XmlElement configuration) + { + var configurationManager = new LoggerNameValueConfigurationManager(configuration); + return configurationManager.NameValuePairs; + } + + /// + /// Initialize logger with the specified type and parameters. + /// + /// Assembly qualified name. + /// Code base. + /// Logger parameters. + /// Logger Initialized flag. + private bool InitializeLoggerByType(string assemblyQualifiedName, string codeBase, Dictionary parameters) + { + CheckDisposed(); + try { + // Load logger assembly. + Assembly assembly = _assemblyLoadContext.LoadAssemblyFromPath(codeBase); + var loggerType = + assembly?.GetTypes() + .FirstOrDefault(x => x.AssemblyQualifiedName.Equals(assemblyQualifiedName)); + + // Create logger instance + var constructorInfo = loggerType?.GetConstructor(Type.EmptyTypes); + var logger = constructorInfo?.Invoke(new object[] { }); + + // Handle logger null scenario. if (logger == null) { return false; } - try + // If the logger has already been initialized just return. + if (_initializedLoggers.Contains(logger.GetType())) { - switch (logger) - { - case ITestLoggerWithParameters _: - ((ITestLoggerWithParameters)logger).Initialize(loggerEvents, - UpdateLoggerParameters(parameters)); - break; - - case ITestLogger _: - ((ITestLogger)logger).Initialize(loggerEvents, testRunDirectory); - break; - - default: - // If logger is of different type, then logger should not be initialized. - EqtTrace.Error( - "TestLoggerManager: Incorrect logger type: {0}", logger.GetType()); - return false; - } + EqtTrace.Verbose("TestLoggerManager: Skipping duplicate logger initialization: {0}", logger.GetType()); + return true; } - catch (Exception ex) - { - var loggerUri = string.IsNullOrEmpty(extensionUri) ? logger.GetType().ToString() : extensionUri; - EqtTrace.Error( - "TestLoggerManager: Error while initializing logger: {0}, Exception details: {1}", loggerUri, ex); - this.messageLogger.SendMessage( - TestMessageLevel.Error, - string.Format( - CultureInfo.CurrentUICulture, - CommonResources.LoggerInitializationError, - string.IsNullOrEmpty(extensionUri) ? "type" : "uri", - string.IsNullOrEmpty(extensionUri) ? logger.GetType().ToString() : extensionUri, - ex)); + // Get Logger instance and initialize. + var initialized = InitializeLogger(logger, null, parameters); - throw new InvalidLoggerException($"Error while initializing logger: {loggerUri}, Exception details: {ex.Message}"); + // Add logger in initializedLoggers list. + if (initialized) + { + _initializedLoggers.Add(logger.GetType()); } - return true; + return initialized; + } + catch (Exception ex) + { + EqtTrace.Error( + "TestLoggerManager: Error occurred while initializing the Logger assemblyQualifiedName : {0}, codeBase : {1} , Exception Details : {2}", assemblyQualifiedName, codeBase, ex); + return false; } + } - /// - /// Populates user supplied and default logger parameters. - /// - private Dictionary UpdateLoggerParameters(Dictionary parameters) + private bool InitializeLogger(object logger, string extensionUri, Dictionary parameters) + { + if (logger == null) { - var loggerParams = new Dictionary(StringComparer.OrdinalIgnoreCase); - if (parameters != null) + return false; + } + + try + { + switch (logger) { - loggerParams = new Dictionary(parameters, StringComparer.OrdinalIgnoreCase); + case ITestLoggerWithParameters _: + ((ITestLoggerWithParameters)logger).Initialize(_loggerEvents, + UpdateLoggerParameters(parameters)); + break; + + case ITestLogger _: + ((ITestLogger)logger).Initialize(_loggerEvents, _testRunDirectory); + break; + + default: + // If logger is of different type, then logger should not be initialized. + EqtTrace.Error( + "TestLoggerManager: Incorrect logger type: {0}", logger.GetType()); + return false; } + } + catch (Exception ex) + { + var loggerUri = string.IsNullOrEmpty(extensionUri) ? logger.GetType().ToString() : extensionUri; + EqtTrace.Error( + "TestLoggerManager: Error while initializing logger: {0}, Exception details: {1}", loggerUri, ex); + + _messageLogger.SendMessage( + TestMessageLevel.Error, + string.Format( + CultureInfo.CurrentUICulture, + CommonResources.LoggerInitializationError, + string.IsNullOrEmpty(extensionUri) ? "type" : "uri", + string.IsNullOrEmpty(extensionUri) ? logger.GetType().ToString() : extensionUri, + ex)); + + throw new InvalidLoggerException($"Error while initializing logger: {loggerUri}, Exception details: {ex.Message}"); + } - // Add default logger parameters... - loggerParams[DefaultLoggerParameterNames.TestRunDirectory] = testRunDirectory; - loggerParams[DefaultLoggerParameterNames.TargetFramework] = targetFramework; + return true; + } - // Add custom logger parameters - if (treatNoTestsAsError) - { - loggerParams[Constants.TreatNoTestsAsError] = treatNoTestsAsError.ToString(); - } + /// + /// Populates user supplied and default logger parameters. + /// + private Dictionary UpdateLoggerParameters(Dictionary parameters) + { + var loggerParams = new Dictionary(StringComparer.OrdinalIgnoreCase); + if (parameters != null) + { + loggerParams = new Dictionary(parameters, StringComparer.OrdinalIgnoreCase); + } + + // Add default logger parameters... + loggerParams[DefaultLoggerParameterNames.TestRunDirectory] = _testRunDirectory; + loggerParams[DefaultLoggerParameterNames.TargetFramework] = _targetFramework; - return loggerParams; + // Add custom logger parameters + if (_treatNoTestsAsError) + { + loggerParams[Constants.TreatNoTestsAsError] = _treatNoTestsAsError.ToString(); } - private void CheckDisposed() + return loggerParams; + } + + private void CheckDisposed() + { + if (_isDisposed) { - if (this.isDisposed) - { - throw new ObjectDisposedException(typeof(TestLoggerManager).FullName); - } + throw new ObjectDisposedException(typeof(TestLoggerManager).FullName); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/TestRunCriteriaExtensions.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/TestRunCriteriaExtensions.cs index 615432a468..84e027c21d 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/TestRunCriteriaExtensions.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/TestRunCriteriaExtensions.cs @@ -1,75 +1,74 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client -{ - using System.Collections.Generic; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; + +using System.Collections.Generic; +using System.Linq; +using ObjectModel; +using ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using ObjectModel.Engine.ClientProtocol; - internal static class TestRunCriteriaExtensions +internal static class TestRunCriteriaExtensions +{ + public static TestRunCriteriaWithSources CreateTestRunCriteriaForSources(this TestRunCriteria testRunCriteria, ITestRuntimeProvider testRuntimeProvider, + string runSettings, TestExecutionContext executionContext, IEnumerable inputPackages) { - public static TestRunCriteriaWithSources CreateTestRunCriteriaForSources(this TestRunCriteria testRunCriteria, ITestRuntimeProvider testRuntimeProvider, - string runSettings, TestExecutionContext executionContext, IEnumerable inputPackages) + if (TryCheckTestSourceDifferFromPackage(testRuntimeProvider, inputPackages, out IEnumerable actualTestSources)) { - if (TryCheckTestSourceDifferFromPackage(testRuntimeProvider, inputPackages, out IEnumerable actualTestSources)) - { - UpdateTestSources(actualTestSources, testRunCriteria.AdapterSourceMap); - } - else - { - inputPackages = null; - } - - return new TestRunCriteriaWithSources(testRunCriteria.AdapterSourceMap, inputPackages?.FirstOrDefault(), runSettings, executionContext); + UpdateTestSources(actualTestSources, testRunCriteria.AdapterSourceMap); + } + else + { + inputPackages = null; } - public static TestRunCriteriaWithTests CreateTestRunCriteriaForTests(this TestRunCriteria testRunCriteria, ITestRuntimeProvider testRuntimeProvider, - string runSettings, TestExecutionContext executionContext, IEnumerable inputPackages) + return new TestRunCriteriaWithSources(testRunCriteria.AdapterSourceMap, inputPackages?.FirstOrDefault(), runSettings, executionContext); + } + + public static TestRunCriteriaWithTests CreateTestRunCriteriaForTests(this TestRunCriteria testRunCriteria, ITestRuntimeProvider testRuntimeProvider, + string runSettings, TestExecutionContext executionContext, IEnumerable inputPackages) + { + if (TryCheckTestSourceDifferFromPackage(testRuntimeProvider, inputPackages, out IEnumerable actualTestSources)) { - if (TryCheckTestSourceDifferFromPackage(testRuntimeProvider, inputPackages, out IEnumerable actualTestSources)) + // In UWP scenario TestCase object contains the package as source, which is not actual test source for adapters, + // so update test case before sending them. + // We are limiting that a testhost will always run for a single package, A package can contain multiple sources + foreach (var tc in testRunCriteria.Tests) { - // In UWP scenario TestCase object contains the package as source, which is not actual test source for adapters, - // so update test case before sending them. - // We are limiting that a testhost will always run for a single package, A package can contain multiple sources - foreach (var tc in testRunCriteria.Tests) - { - tc.Source = actualTestSources.FirstOrDefault(); - } + tc.Source = actualTestSources.FirstOrDefault(); } - else - { - inputPackages = null; - } - - return new TestRunCriteriaWithTests(testRunCriteria.Tests, inputPackages?.FirstOrDefault(), runSettings, executionContext); } - - private static bool TryCheckTestSourceDifferFromPackage(ITestRuntimeProvider testRuntimeProvider, - IEnumerable inputPackages, out IEnumerable actualTestSources) + else { - actualTestSources = testRuntimeProvider.GetTestSources(inputPackages); - - // For netcore/fullclr both packages and sources are same thing, - // For UWP the actual source(exe) differs from input source(.appxrecipe) which we call package. - // So in such models we check if they differ, then we pass this info to test host to update TestCase source with package info, - // since this is needed by IDE's to map a TestCase to project. - return inputPackages.Except(actualTestSources).Any(); + inputPackages = null; } - /// - /// Update the AdapterSourceMap - /// - /// actual test sources - /// Adapter Source Map - private static void UpdateTestSources(IEnumerable sources, Dictionary> adapterSourceMap) - { - adapterSourceMap.Clear(); - adapterSourceMap.Add(Constants.UnspecifiedAdapterPath, sources); - } + return new TestRunCriteriaWithTests(testRunCriteria.Tests, inputPackages?.FirstOrDefault(), runSettings, executionContext); + } + + private static bool TryCheckTestSourceDifferFromPackage(ITestRuntimeProvider testRuntimeProvider, + IEnumerable inputPackages, out IEnumerable actualTestSources) + { + actualTestSources = testRuntimeProvider.GetTestSources(inputPackages); + + // For netcore/fullclr both packages and sources are same thing, + // For UWP the actual source(exe) differs from input source(.appxrecipe) which we call package. + // So in such models we check if they differ, then we pass this info to test host to update TestCase source with package info, + // since this is needed by IDE's to map a TestCase to project. + return inputPackages.Except(actualTestSources).Any(); + } + + /// + /// Update the AdapterSourceMap + /// + /// actual test sources + /// Adapter Source Map + private static void UpdateTestSources(IEnumerable sources, Dictionary> adapterSourceMap) + { + adapterSourceMap.Clear(); + adapterSourceMap.Add(Constants.UnspecifiedAdapterPath, sources); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Constants.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Constants.cs index 0faf5d7f3f..25609cd8fc 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Constants.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Constants.cs @@ -1,27 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine -{ - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.IO; +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; + +using PlatformAbstractions; - /// - /// The set of constants used throughout this project. - /// - public class Constants +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; + +/// +/// The set of constants used throughout this project. +/// +public class Constants +{ + // Replace this collection with a list of adapters we want to allow from the "Extensions" folder in Next Major VS Release. + internal static readonly IList DefaultAdapters = new ReadOnlyCollection(new List { - // Replace this collection with a list of adapters we want to allow from the "Extensions" folder in Next Major VS Release. - internal static readonly IList DefaultAdapters = new ReadOnlyCollection(new List - { - "executor://CodedWebTestAdapter/v1", - "executor://MSTestAdapter/v1", - "executor://WebTestAdapter/v1", - "executor://CppUnitTestExecutor/v1" - }); + "executor://CodedWebTestAdapter/v1", + "executor://MSTestAdapter/v1", + "executor://WebTestAdapter/v1", + "executor://CppUnitTestExecutor/v1" + }); - internal static string DefaultAdapterLocation = Path.Combine(new ProcessHelper().GetCurrentProcessLocation(), "Extensions"); - } -} + internal static string DefaultAdapterLocation = Path.Combine(new ProcessHelper().GetCurrentProcessLocation(), "Extensions"); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionLauncher.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionLauncher.cs index 5496f46a51..79bf4fb8b6 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionLauncher.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionLauncher.cs @@ -1,98 +1,97 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; + +using System; +using System.Collections.Generic; +using System.Text; + +using CoreUtilities.Extensions; +using Interfaces; +using ObjectModel; +using ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; + +/// +/// Abstract DataCollection Launcher provides functionality to handle process launch and exit events. +/// +internal abstract class DataCollectionLauncher : IDataCollectionLauncher { - using System; - using System.Collections.Generic; - using System.Text; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; + protected IProcessHelper _processHelper; + + protected IMessageLogger _messageLogger; + + protected StringBuilder _processStdError; /// - /// Abstract DataCollection Launcher provides functionality to handle process launch and exit events. + /// Initializes a new instance of the class. /// - internal abstract class DataCollectionLauncher : IDataCollectionLauncher + /// + /// The process helper. + /// + /// + /// The message logger. + /// + public DataCollectionLauncher(IProcessHelper processHelper, IMessageLogger messageLogger) { - protected IProcessHelper processHelper; - - protected IMessageLogger messageLogger; + _processHelper = processHelper; + _messageLogger = messageLogger; + _processStdError = new StringBuilder(0, CoreUtilities.Constants.StandardErrorMaxLength); + } - protected StringBuilder processStdError; + /// + public int DataCollectorProcessId { get; protected set; } - /// - /// Initializes a new instance of the class. - /// - /// - /// The process helper. - /// - /// - /// The message logger. - /// - public DataCollectionLauncher(IProcessHelper processHelper, IMessageLogger messageLogger) - { - this.processHelper = processHelper; - this.messageLogger = messageLogger; - this.processStdError = new StringBuilder(0, CoreUtilities.Constants.StandardErrorMaxLength); - } + /// + /// Gets callback on process exit + /// + protected Action ExitCallBack => (process) => + { + var processStdErrorStr = _processStdError.ToString(); - /// - public int DataCollectorProcessId { get; protected set; } + _processHelper.TryGetExitCode(process, out int exitCode); - /// - /// Gets callback on process exit - /// - protected Action ExitCallBack => (process) => + if (exitCode != 0) { - var exitCode = 0; - var processStdErrorStr = this.processStdError.ToString(); - - this.processHelper.TryGetExitCode(process, out exitCode); + EqtTrace.Error("DataCollectionLauncher.ExitCallBack: Data collector exited with exitcode:{0} error: '{1}'", exitCode, processStdErrorStr); - if (exitCode != 0) + if (!string.IsNullOrWhiteSpace(processStdErrorStr)) { - EqtTrace.Error("DataCollectionLauncher.ExitCallBack: Data collector exited with exitcode:{0} error: '{1}'", exitCode, processStdErrorStr); - - if (!string.IsNullOrWhiteSpace(processStdErrorStr)) - { - this.messageLogger.SendMessage(TestMessageLevel.Error, processStdErrorStr); - } - } - else - { - EqtTrace.Info("DataCollectionLauncher.ExitCallBack: Data collector exited with exitcode: 0 error: '{0}'", processStdErrorStr); + _messageLogger.SendMessage(TestMessageLevel.Error, processStdErrorStr); } - }; - - /// - /// Gets callback to read from process error stream - /// - protected Action ErrorReceivedCallback => (process, data) => + } + else { - // Log all standard error message because on too much data we ignore starting part. - // This is helpful in abnormal failure of datacollector. - EqtTrace.Warning("DataCollectionLauncher.ErrorReceivedCallback datacollector standard error line: {0}", data); + EqtTrace.Info("DataCollectionLauncher.ExitCallBack: Data collector exited with exitcode: 0 error: '{0}'", processStdErrorStr); + } + }; - this.processStdError.AppendSafeWithNewLine(data); - }; + /// + /// Gets callback to read from process error stream + /// + protected Action ErrorReceivedCallback => (process, data) => + { + // Log all standard error message because on too much data we ignore starting part. + // This is helpful in abnormal failure of datacollector. + EqtTrace.Warning("DataCollectionLauncher.ErrorReceivedCallback datacollector standard error line: {0}", data); - /// - /// The launch data collector. - /// - /// - /// The environment variables. - /// - /// - /// The command line arguments. - /// - /// - /// The . - /// - public abstract int LaunchDataCollector( - IDictionary environmentVariables, - IList commandLineArguments); - } + _processStdError.AppendSafeWithNewLine(data); + }; + + /// + /// The launch data collector. + /// + /// + /// The environment variables. + /// + /// + /// The command line arguments. + /// + /// + /// The . + /// + public abstract int LaunchDataCollector( + IDictionary environmentVariables, + IList commandLineArguments); } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionLauncherFactory.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionLauncherFactory.cs index b8f96dd1ec..6ae4e2c19d 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionLauncherFactory.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionLauncherFactory.cs @@ -1,50 +1,47 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; + +using System; + +using Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +/// +/// Factory for creating DataCollectionLauncher +/// +internal static class DataCollectionLauncherFactory +{ /// - /// Factory for creating DataCollectionLauncher + /// The get data collector launcher. /// - internal static class DataCollectionLauncherFactory + /// + /// The . + /// + internal static IDataCollectionLauncher GetDataCollectorLauncher(IProcessHelper processHelper, string settingsXml) { - /// - /// The get data collector launcher. - /// - /// - /// The . - /// - internal static IDataCollectionLauncher GetDataCollectorLauncher(IProcessHelper processHelper, string settingsXml) + // Always launch datacollector.exe if code coverage is configured. + if (!string.IsNullOrWhiteSpace(settingsXml)) { - // Always launch datacollector.exe if code coverage is configured. - if (!string.IsNullOrWhiteSpace(settingsXml)) + var dataCollectionRunSettings = XmlRunSettingsUtilities.GetDataCollectionRunSettings(settingsXml); + foreach (var dataCollectorSettings in dataCollectionRunSettings.DataCollectorSettingsList) { - var dataCollectionRunSettings = XmlRunSettingsUtilities.GetDataCollectionRunSettings(settingsXml); - foreach (var dataCollectorSettings in dataCollectionRunSettings.DataCollectorSettingsList) + if (string.Equals(dataCollectorSettings.FriendlyName, "event Log", StringComparison.OrdinalIgnoreCase) || string.Equals(dataCollectorSettings.Uri?.ToString(), @"datacollector://Microsoft/EventLog/2.0", StringComparison.OrdinalIgnoreCase)) { - if (string.Equals(dataCollectorSettings.FriendlyName, "event Log", StringComparison.OrdinalIgnoreCase) || string.Equals(dataCollectorSettings.Uri?.ToString(), @"datacollector://Microsoft/EventLog/2.0", StringComparison.OrdinalIgnoreCase)) - { - return new DefaultDataCollectionLauncher(); - } + return new DefaultDataCollectionLauncher(); } } + } - // Target Framework of DataCollection process and Runner should be same. - var currentProcessPath = processHelper.GetCurrentProcessFileName(); - - if (currentProcessPath.EndsWith("dotnet", StringComparison.OrdinalIgnoreCase) - || currentProcessPath.EndsWith("dotnet.exe", StringComparison.OrdinalIgnoreCase)) - { - return new DotnetDataCollectionLauncher(); - } + // Target Framework of DataCollection process and Runner should be same. + var currentProcessPath = processHelper.GetCurrentProcessFileName(); - return new DefaultDataCollectionLauncher(); - } + return currentProcessPath.EndsWith("dotnet", StringComparison.OrdinalIgnoreCase) + || currentProcessPath.EndsWith("dotnet.exe", StringComparison.OrdinalIgnoreCase) + ? new DotnetDataCollectionLauncher() + : new DefaultDataCollectionLauncher(); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionParameters.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionParameters.cs index db3d47013b..730955e088 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionParameters.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionParameters.cs @@ -1,62 +1,61 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; + +using System.Collections.Generic; +/// +/// The data collection parameters. +/// +public class DataCollectionParameters +{ /// - /// The data collection parameters. + /// Initializes a new instance of the class. /// - public class DataCollectionParameters + /// + /// The are test case level events required. + /// + /// + /// The environment variables. + /// + /// + /// The data Collection Events Port. + /// + public DataCollectionParameters( + bool areTestCaseLevelEventsRequired, + IDictionary environmentVariables, + int dataCollectionEventsPort) { - /// - /// Initializes a new instance of the class. - /// - /// - /// The are test case level events required. - /// - /// - /// The environment variables. - /// - /// - /// The data Collection Events Port. - /// - public DataCollectionParameters( - bool areTestCaseLevelEventsRequired, - IDictionary environmentVariables, - int dataCollectionEventsPort) - { - this.AreTestCaseLevelEventsRequired = areTestCaseLevelEventsRequired; - this.EnvironmentVariables = environmentVariables; - this.DataCollectionEventsPort = dataCollectionEventsPort; - } + AreTestCaseLevelEventsRequired = areTestCaseLevelEventsRequired; + EnvironmentVariables = environmentVariables; + DataCollectionEventsPort = dataCollectionEventsPort; + } - /// - /// Gets a value indicating whether any of the enabled data collectors - /// registered for test case level events - /// - public bool AreTestCaseLevelEventsRequired { get; private set; } + /// + /// Gets a value indicating whether any of the enabled data collectors + /// registered for test case level events + /// + public bool AreTestCaseLevelEventsRequired { get; private set; } - /// - /// Gets BeforeTestRunStart Call on the DataCollectors can yield/return a set of environment variables - /// - public IDictionary EnvironmentVariables { get; private set; } + /// + /// Gets BeforeTestRunStart Call on the DataCollectors can yield/return a set of environment variables + /// + public IDictionary EnvironmentVariables { get; private set; } - /// - /// Gets the data collection events port. - /// - public int DataCollectionEventsPort { get; private set; } + /// + /// Gets the data collection events port. + /// + public int DataCollectionEventsPort { get; private set; } - /// - /// The create default parameter instance. - /// - /// - /// The . - /// - public static DataCollectionParameters CreateDefaultParameterInstance() - { - return new DataCollectionParameters(areTestCaseLevelEventsRequired: false, environmentVariables: null, dataCollectionEventsPort: 0); - } + /// + /// The create default parameter instance. + /// + /// + /// The . + /// + public static DataCollectionParameters CreateDefaultParameterInstance() + { + return new DataCollectionParameters(areTestCaseLevelEventsRequired: false, environmentVariables: null, dataCollectionEventsPort: 0); } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionResult.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionResult.cs index 440dcdbf6d..c12dd2ee26 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionResult.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionResult.cs @@ -1,30 +1,30 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; + +using ObjectModel; + +using System.Collections.ObjectModel; + +/// +/// Information returned after data collection. +/// +public class DataCollectionResult { - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using System.Collections.ObjectModel; + public DataCollectionResult(Collection attachments, Collection invokedDataCollectors) + { + Attachments = attachments; + InvokedDataCollectors = invokedDataCollectors; + } /// - /// Information returned after data collection. + /// Get list of attachments /// - public class DataCollectionResult - { - public DataCollectionResult(Collection attachments, Collection invokedDataCollectors) - { - this.Attachments = attachments; - this.InvokedDataCollectors = invokedDataCollectors; - } - - /// - /// Get list of attachments - /// - public Collection Attachments { get; } + public Collection Attachments { get; } - /// - /// Get the list of the invoked data collectors. - /// - public Collection InvokedDataCollectors { get; } - } -} + /// + /// Get the list of the invoked data collectors. + /// + public Collection InvokedDataCollectors { get; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionTestRunEventsHandler.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionTestRunEventsHandler.cs index b7f0883cd4..9ee7f8916b 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionTestRunEventsHandler.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DataCollectionTestRunEventsHandler.cs @@ -1,230 +1,227 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading; + +using CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Logging; + +/// +/// Handles DataCollection attachments by calling DataCollection Process on Test Run Complete. +/// Existing functionality of ITestRunEventsHandler is decorated with additional call to Data Collection Process. +/// +internal class DataCollectionTestRunEventsHandler : ITestRunEventsHandler2 { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Linq; - using System.Threading; - - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + private readonly IProxyDataCollectionManager _proxyDataCollectionManager; + private readonly ITestRunEventsHandler _testRunEventsHandler; + private CancellationToken _cancellationToken; + private readonly IDataSerializer _dataSerializer; + private Collection _dataCollectionAttachmentSets; + private Collection _invokedDataCollectors; /// - /// Handles DataCollection attachments by calling DataCollection Process on Test Run Complete. - /// Existing functionality of ITestRunEventsHandler is decorated with additional call to Data Collection Process. + /// Initializes a new instance of the class. /// - internal class DataCollectionTestRunEventsHandler : ITestRunEventsHandler2 + /// + /// The base test run events handler. + /// + /// + /// The proxy Data Collection Manager. + /// + public DataCollectionTestRunEventsHandler(ITestRunEventsHandler baseTestRunEventsHandler, IProxyDataCollectionManager proxyDataCollectionManager, CancellationToken cancellationToken) + : this(baseTestRunEventsHandler, proxyDataCollectionManager, JsonDataSerializer.Instance, cancellationToken) { - private IProxyDataCollectionManager proxyDataCollectionManager; - private ITestRunEventsHandler testRunEventsHandler; - private CancellationToken cancellationToken; - private IDataSerializer dataSerializer; - private Collection dataCollectionAttachmentSets; - private Collection invokedDataCollectors; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The base test run events handler. - /// - /// - /// The proxy Data Collection Manager. - /// - public DataCollectionTestRunEventsHandler(ITestRunEventsHandler baseTestRunEventsHandler, IProxyDataCollectionManager proxyDataCollectionManager, CancellationToken cancellationToken) - : this(baseTestRunEventsHandler, proxyDataCollectionManager, JsonDataSerializer.Instance, cancellationToken) - { - } + } - /// - /// Initializes a new instance of the class. - /// - /// - /// The base test run events handler. - /// - /// - /// The proxy Data Collection Manager. - /// - /// - /// The data Serializer. - /// - public DataCollectionTestRunEventsHandler(ITestRunEventsHandler baseTestRunEventsHandler, IProxyDataCollectionManager proxyDataCollectionManager, IDataSerializer dataSerializer, CancellationToken cancellationToken) - { - this.proxyDataCollectionManager = proxyDataCollectionManager; - this.testRunEventsHandler = baseTestRunEventsHandler; - this.cancellationToken = cancellationToken; - this.dataSerializer = dataSerializer; - } + /// + /// Initializes a new instance of the class. + /// + /// + /// The base test run events handler. + /// + /// + /// The proxy Data Collection Manager. + /// + /// + /// The data Serializer. + /// + public DataCollectionTestRunEventsHandler(ITestRunEventsHandler baseTestRunEventsHandler, IProxyDataCollectionManager proxyDataCollectionManager, IDataSerializer dataSerializer, CancellationToken cancellationToken) + { + _proxyDataCollectionManager = proxyDataCollectionManager; + _testRunEventsHandler = baseTestRunEventsHandler; + _cancellationToken = cancellationToken; + _dataSerializer = dataSerializer; + } - /// - /// The handle log message. - /// - /// - /// The level. - /// - /// - /// The message. - /// - public void HandleLogMessage(TestMessageLevel level, string message) - { - this.testRunEventsHandler.HandleLogMessage(level, message); - } + /// + /// The handle log message. + /// + /// + /// The level. + /// + /// + /// The message. + /// + public void HandleLogMessage(TestMessageLevel level, string message) + { + _testRunEventsHandler.HandleLogMessage(level, message); + } - /// - /// The handle raw message. - /// - /// - /// The raw message. - /// - public void HandleRawMessage(string rawMessage) + /// + /// The handle raw message. + /// + /// + /// The raw message. + /// + public void HandleRawMessage(string rawMessage) + { + // In case of data collection, data collection attachments should be attached to raw message for ExecutionComplete + var message = _dataSerializer.DeserializeMessage(rawMessage); + + if (string.Equals(MessageType.ExecutionComplete, message.MessageType)) { - // In case of data collection, data collection attachments should be attached to raw message for ExecutionComplete - var message = this.dataSerializer.DeserializeMessage(rawMessage); + var dataCollectionResult = _proxyDataCollectionManager?.AfterTestRunEnd(_cancellationToken.IsCancellationRequested, this); + _dataCollectionAttachmentSets = dataCollectionResult?.Attachments; - if (string.Equals(MessageType.ExecutionComplete, message.MessageType)) - { - var dataCollectionResult = this.proxyDataCollectionManager?.AfterTestRunEnd(this.cancellationToken.IsCancellationRequested, this); - this.dataCollectionAttachmentSets = dataCollectionResult?.Attachments; + var testRunCompletePayload = + _dataSerializer.DeserializePayload(message); - var testRunCompletePayload = - this.dataSerializer.DeserializePayload(message); + if (_dataCollectionAttachmentSets != null && _dataCollectionAttachmentSets.Any()) + { + GetCombinedAttachmentSets( + testRunCompletePayload.TestRunCompleteArgs.AttachmentSets, + _dataCollectionAttachmentSets); + } - if (this.dataCollectionAttachmentSets != null && this.dataCollectionAttachmentSets.Any()) + _invokedDataCollectors = dataCollectionResult?.InvokedDataCollectors; + if (_invokedDataCollectors?.Count > 0) + { + foreach (var dataCollector in _invokedDataCollectors) { - GetCombinedAttachmentSets( - testRunCompletePayload.TestRunCompleteArgs.AttachmentSets, - this.dataCollectionAttachmentSets); + testRunCompletePayload.TestRunCompleteArgs.InvokedDataCollectors.Add(dataCollector); } + } - this.invokedDataCollectors = dataCollectionResult?.InvokedDataCollectors; - if (this.invokedDataCollectors?.Count > 0) - { - foreach (var dataCollector in this.invokedDataCollectors) - { - testRunCompletePayload.TestRunCompleteArgs.InvokedDataCollectors.Add(dataCollector); - } - } + rawMessage = _dataSerializer.SerializePayload( + MessageType.ExecutionComplete, + testRunCompletePayload); + } - rawMessage = this.dataSerializer.SerializePayload( - MessageType.ExecutionComplete, - testRunCompletePayload); - } + _testRunEventsHandler.HandleRawMessage(rawMessage); + } - this.testRunEventsHandler.HandleRawMessage(rawMessage); + /// + /// The handle test run complete. + /// + /// + /// The test run complete args. + /// + /// + /// The last chunk args. + /// + /// + /// The run context attachments. + /// + /// + /// The executor uris. + /// + public void HandleTestRunComplete(TestRunCompleteEventArgs testRunCompleteArgs, TestRunChangedEventArgs lastChunkArgs, ICollection runContextAttachments, ICollection executorUris) + { + if (_dataCollectionAttachmentSets != null && _dataCollectionAttachmentSets.Any()) + { + runContextAttachments = GetCombinedAttachmentSets(_dataCollectionAttachmentSets, runContextAttachments); } - /// - /// The handle test run complete. - /// - /// - /// The test run complete args. - /// - /// - /// The last chunk args. - /// - /// - /// The run context attachments. - /// - /// - /// The executor uris. - /// - public void HandleTestRunComplete(TestRunCompleteEventArgs testRunCompleteArgs, TestRunChangedEventArgs lastChunkArgs, ICollection runContextAttachments, ICollection executorUris) + // At the moment, we don't support running data collectors inside testhost process, so it will always be empty inside "TestRunCompleteEventArgs testRunCompleteArgs". + // We load invoked data collectors from data collector process inside "DataCollectionTestRunEventsHandler.HandleRawMessage" method. + if (_invokedDataCollectors != null && _invokedDataCollectors.Any()) { - if (this.dataCollectionAttachmentSets != null && this.dataCollectionAttachmentSets.Any()) + foreach (var dataCollector in _invokedDataCollectors) { - runContextAttachments = GetCombinedAttachmentSets(this.dataCollectionAttachmentSets, runContextAttachments); + testRunCompleteArgs.InvokedDataCollectors.Add(dataCollector); } + } - // At the moment, we don't support running data collectors inside testhost process, so it will always be empty inside "TestRunCompleteEventArgs testRunCompleteArgs". - // We load invoked data collectors from data collector process inside "DataCollectionTestRunEventsHandler.HandleRawMessage" method. - if (this.invokedDataCollectors != null && this.invokedDataCollectors.Any()) - { - foreach (var dataCollector in this.invokedDataCollectors) - { - testRunCompleteArgs.InvokedDataCollectors.Add(dataCollector); - } - } + _testRunEventsHandler.HandleTestRunComplete(testRunCompleteArgs, lastChunkArgs, runContextAttachments, executorUris); + } - this.testRunEventsHandler.HandleTestRunComplete(testRunCompleteArgs, lastChunkArgs, runContextAttachments, executorUris); - } + /// + /// The handle test run stats change. + /// + /// + /// The test run changed args. + /// + public void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChangedArgs) + { + _testRunEventsHandler.HandleTestRunStatsChange(testRunChangedArgs); + } - /// - /// The handle test run stats change. - /// - /// - /// The test run changed args. - /// - public void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChangedArgs) - { - this.testRunEventsHandler.HandleTestRunStatsChange(testRunChangedArgs); - } + /// + /// Launches a process with a given process info under debugger + /// Adapter get to call into this to launch any additional processes under debugger + /// + /// Process start info + /// ProcessId of the launched process + public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) + { + return _testRunEventsHandler.LaunchProcessWithDebuggerAttached(testProcessStartInfo); + } - /// - /// Launches a process with a given process info under debugger - /// Adapter get to call into this to launch any additional processes under debugger - /// - /// Process start info - /// ProcessId of the launched process - public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) + /// + public bool AttachDebuggerToProcess(int pid) + { + return ((ITestRunEventsHandler2)_testRunEventsHandler).AttachDebuggerToProcess(pid); + } + + /// + /// The get combined attachment sets. + /// + /// + /// The run attachments. + /// + /// + /// The run context attachments. + /// + /// + /// The . + /// + internal static ICollection GetCombinedAttachmentSets(Collection originalAttachmentSets, ICollection newAttachments) + { + if (newAttachments == null || newAttachments.Count == 0) { - return this.testRunEventsHandler.LaunchProcessWithDebuggerAttached(testProcessStartInfo); + return originalAttachmentSets; } - /// - public bool AttachDebuggerToProcess(int pid) + if (originalAttachmentSets == null) { - return ((ITestRunEventsHandler2)this.testRunEventsHandler).AttachDebuggerToProcess(pid); + return new Collection(newAttachments.ToList()); } - /// - /// The get combined attachment sets. - /// - /// - /// The run attachments. - /// - /// - /// The run context attachments. - /// - /// - /// The . - /// - internal static ICollection GetCombinedAttachmentSets(Collection originalAttachmentSets, ICollection newAttachments) + foreach (var attachmentSet in newAttachments) { - if (newAttachments == null || newAttachments.Count == 0) - { - return originalAttachmentSets; - } - - if (originalAttachmentSets == null) + var attSet = originalAttachmentSets.FirstOrDefault(item => Equals(item.Uri, attachmentSet.Uri)); + if (attSet == null) { - return new Collection(newAttachments.ToList()); + originalAttachmentSets.Add(attachmentSet); } - - foreach (var attachmentSet in newAttachments) + else { - var attSet = originalAttachmentSets.FirstOrDefault(item => Uri.Equals(item.Uri, attachmentSet.Uri)); - if (attSet == null) - { - originalAttachmentSets.Add(attachmentSet); - } - else + foreach (var attachment in attachmentSet.Attachments) { - foreach (var attachment in attachmentSet.Attachments) - { - attSet.Attachments.Add(attachment); - } + attSet.Attachments.Add(attachment); } } - - return originalAttachmentSets; } + + return originalAttachmentSets; } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DefaultDataCollectionLauncher.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DefaultDataCollectionLauncher.cs index 3ce2560159..ab1cb52f87 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DefaultDataCollectionLauncher.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DefaultDataCollectionLauncher.cs @@ -1,77 +1,70 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection -{ - using System; - using System.Collections.Generic; - using System.IO; - using System.Reflection; +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Common.Logging; +using ObjectModel.Logging; +using PlatformAbstractions; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; + +/// +/// The datacollection launcher. +/// This works for Desktop local scenarios +/// +internal class DefaultDataCollectionLauncher : DataCollectionLauncher +{ + private const string DataCollectorProcessName = "datacollector.exe"; /// - /// The datacollection launcher. - /// This works for Desktop local scenarios + /// The constructor. /// - internal class DefaultDataCollectionLauncher : DataCollectionLauncher + public DefaultDataCollectionLauncher() + : this(new ProcessHelper(), TestSessionMessageLogger.Instance) { - private const string DataCollectorProcessName = "datacollector.exe"; - - /// - /// The constructor. - /// - public DefaultDataCollectionLauncher() - : this(new ProcessHelper(), TestSessionMessageLogger.Instance) - { - } + } - /// - /// Initializes a new instance of the class. - /// - /// - /// The process helper. - /// - /// - /// The message Logger. - /// - internal DefaultDataCollectionLauncher(IProcessHelper processHelper, IMessageLogger messageLogger) : base(processHelper, messageLogger) - { - this.processHelper = processHelper; - this.DataCollectorProcessId = -1; - } + /// + /// Initializes a new instance of the class. + /// + /// + /// The process helper. + /// + /// + /// The message Logger. + /// + internal DefaultDataCollectionLauncher(IProcessHelper processHelper, IMessageLogger messageLogger) : base(processHelper, messageLogger) + { + _processHelper = processHelper; + DataCollectorProcessId = -1; + } - /// - /// Launches the test host for discovery/execution. - /// - /// Environment variables for the process. - /// The command line arguments to pass to the process. - /// ProcessId of launched Process. 0 means not launched. - public override int LaunchDataCollector(IDictionary environmentVariables, IList commandLineArguments) - { - string dataCollectorProcessPath = null; - var dataCollectorDirectory = Path.GetDirectoryName(typeof(DefaultDataCollectionLauncher).GetTypeInfo().Assembly.GetAssemblyLocation()); + /// + /// Launches the test host for discovery/execution. + /// + /// Environment variables for the process. + /// The command line arguments to pass to the process. + /// ProcessId of launched Process. 0 means not launched. + public override int LaunchDataCollector(IDictionary environmentVariables, IList commandLineArguments) + { + var dataCollectorDirectory = Path.GetDirectoryName(typeof(DefaultDataCollectionLauncher).GetTypeInfo().Assembly.GetAssemblyLocation()); - var currentProcessPath = this.processHelper.GetCurrentProcessFileName(); + var currentProcessPath = _processHelper.GetCurrentProcessFileName(); - // If current process is dotnet/dotnet.exe and you are here, datacollector.exe is present in TestHost folder. - if (currentProcessPath.EndsWith("dotnet", StringComparison.OrdinalIgnoreCase) - || currentProcessPath.EndsWith("dotnet.exe", StringComparison.OrdinalIgnoreCase)) - { - dataCollectorProcessPath = Path.Combine(dataCollectorDirectory, "TestHost", DataCollectorProcessName); - } - else - { - dataCollectorProcessPath = Path.Combine(dataCollectorDirectory, DataCollectorProcessName); - } + // If current process is dotnet/dotnet.exe and you are here, datacollector.exe is present in TestHost folder. + string dataCollectorProcessPath = currentProcessPath.EndsWith("dotnet", StringComparison.OrdinalIgnoreCase) + || currentProcessPath.EndsWith("dotnet.exe", StringComparison.OrdinalIgnoreCase) + ? Path.Combine(dataCollectorDirectory, "TestHost", DataCollectorProcessName) + : Path.Combine(dataCollectorDirectory, DataCollectorProcessName); - var argumentsString = string.Join(" ", commandLineArguments); - var dataCollectorProcess = this.processHelper.LaunchProcess(dataCollectorProcessPath, argumentsString, Directory.GetCurrentDirectory(), environmentVariables, this.ErrorReceivedCallback, this.ExitCallBack, null) ; - this.DataCollectorProcessId = this.processHelper.GetProcessId(dataCollectorProcess); - return this.DataCollectorProcessId; - } + var argumentsString = string.Join(" ", commandLineArguments); + var dataCollectorProcess = _processHelper.LaunchProcess(dataCollectorProcessPath, argumentsString, Directory.GetCurrentDirectory(), environmentVariables, ErrorReceivedCallback, ExitCallBack, null); + DataCollectorProcessId = _processHelper.GetProcessId(dataCollectorProcess); + return DataCollectorProcessId; } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DotnetDataCollectionLauncher.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DotnetDataCollectionLauncher.cs index 07ea260cd8..eb192f8864 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DotnetDataCollectionLauncher.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DotnetDataCollectionLauncher.cs @@ -1,125 +1,123 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; + +using System.Collections.Generic; +using System.IO; +using System.Reflection; + +using Common.Logging; +using CoreUtilities.Extensions; +using ObjectModel; +using ObjectModel.Logging; +using PlatformAbstractions; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +/// +/// The datacollection launcher. +/// This works for Desktop local scenarios +/// +internal class DotnetDataCollectionLauncher : DataCollectionLauncher { - using System.Collections.Generic; - using System.IO; - using System.Reflection; - - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + private const string DataCollectorProcessName = "datacollector.dll"; + + private readonly IFileHelper _fileHelper; /// - /// The datacollection launcher. - /// This works for Desktop local scenarios + /// Initializes a new instance of the class. /// - internal class DotnetDataCollectionLauncher : DataCollectionLauncher + public DotnetDataCollectionLauncher() + : this(new ProcessHelper(), new FileHelper(), TestSessionMessageLogger.Instance) { - private const string DataCollectorProcessName = "datacollector.dll"; + } - private IFileHelper fileHelper; + /// + /// Initializes a new instance of the class. + /// + /// + /// The process helper. + /// + /// + /// The file Helper. + /// + /// + /// The message Logger. + /// + internal DotnetDataCollectionLauncher(IProcessHelper processHelper, IFileHelper fileHelper, IMessageLogger messageLogger) : base(processHelper, messageLogger) + { + _processHelper = processHelper; + _fileHelper = fileHelper; + DataCollectorProcessId = -1; + } - /// - /// Initializes a new instance of the class. - /// - public DotnetDataCollectionLauncher() - : this(new ProcessHelper(), new FileHelper(), TestSessionMessageLogger.Instance) - { - } + /// + /// Launches the test host for discovery/execution. + /// + /// Environment variables for the process. + /// The command line arguments to pass to the process. + /// ProcessId of launched Process. 0 means not launched. + public override int LaunchDataCollector(IDictionary environmentVariables, IList commandLineArguments) + { + var dataCollectorDirectory = Path.GetDirectoryName(typeof(DefaultDataCollectionLauncher).GetTypeInfo().Assembly.GetAssemblyLocation()); + var currentProcessFileName = _processHelper.GetCurrentProcessFileName(); - /// - /// Initializes a new instance of the class. - /// - /// - /// The process helper. - /// - /// - /// The file Helper. - /// - /// - /// The message Logger. - /// - internal DotnetDataCollectionLauncher(IProcessHelper processHelper, IFileHelper fileHelper, IMessageLogger messageLogger) : base(processHelper, messageLogger) + if (EqtTrace.IsVerboseEnabled) { - this.processHelper = processHelper; - this.fileHelper = fileHelper; - this.DataCollectorProcessId = -1; + EqtTrace.Verbose("DotnetDataCollectionLauncher: Full path of dotnet.exe is {0}", currentProcessFileName); } - /// - /// Launches the test host for discovery/execution. - /// - /// Environment variables for the process. - /// The command line arguments to pass to the process. - /// ProcessId of launched Process. 0 means not launched. - public override int LaunchDataCollector(IDictionary environmentVariables, IList commandLineArguments) - { - string dataCollectorFileName = null; - var dataCollectorDirectory = Path.GetDirectoryName(typeof(DefaultDataCollectionLauncher).GetTypeInfo().Assembly.GetAssemblyLocation()); - var currentProcessFileName = this.processHelper.GetCurrentProcessFileName(); + var dataCollectorAssemblyPath = Path.Combine(dataCollectorDirectory, DataCollectorProcessName); - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("DotnetDataCollectionLauncher: Full path of dotnet.exe is {0}", currentProcessFileName); - } - - var dataCollectorAssemblyPath = Path.Combine(dataCollectorDirectory, DataCollectorProcessName); + string dataCollectorFileName = Path.GetFileNameWithoutExtension(dataCollectorAssemblyPath); - dataCollectorFileName = Path.GetFileNameWithoutExtension(dataCollectorAssemblyPath); + var args = "exec"; - var args = "exec"; + // Probe for runtime config and deps file for the test source + var runtimeConfigPath = Path.Combine(dataCollectorDirectory, string.Concat(dataCollectorFileName, ".runtimeconfig.json")); - // Probe for runtime config and deps file for the test source - var runtimeConfigPath = Path.Combine(dataCollectorDirectory, string.Concat(dataCollectorFileName, ".runtimeconfig.json")); - - if (this.fileHelper.Exists(runtimeConfigPath)) + if (_fileHelper.Exists(runtimeConfigPath)) + { + var argsToAdd = " --runtimeconfig " + runtimeConfigPath.AddDoubleQuote(); + args += argsToAdd; + if (EqtTrace.IsVerboseEnabled) { - var argsToAdd = " --runtimeconfig " + runtimeConfigPath.AddDoubleQuote(); - args += argsToAdd; - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("DotnetDataCollectionLauncher: Adding {0} in args", argsToAdd); - } + EqtTrace.Verbose("DotnetDataCollectionLauncher: Adding {0} in args", argsToAdd); } - else + } + else + { + if (EqtTrace.IsVerboseEnabled) { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("DotnetDataCollectionLauncher: File {0}, does not exist", runtimeConfigPath); - } + EqtTrace.Verbose("DotnetDataCollectionLauncher: File {0}, does not exist", runtimeConfigPath); } + } - // Use the deps.json for test source - var depsFilePath = Path.Combine(dataCollectorDirectory, string.Concat(dataCollectorFileName, ".deps.json")); - if (this.fileHelper.Exists(depsFilePath)) + // Use the deps.json for test source + var depsFilePath = Path.Combine(dataCollectorDirectory, string.Concat(dataCollectorFileName, ".deps.json")); + if (_fileHelper.Exists(depsFilePath)) + { + var argsToAdd = " --depsfile " + depsFilePath.AddDoubleQuote(); + args += argsToAdd; + if (EqtTrace.IsVerboseEnabled) { - var argsToAdd = " --depsfile " + depsFilePath.AddDoubleQuote(); - args += argsToAdd; - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("DotnetDataCollectionLauncher: Adding {0} in args", argsToAdd); - } + EqtTrace.Verbose("DotnetDataCollectionLauncher: Adding {0} in args", argsToAdd); } - else + } + else + { + if (EqtTrace.IsVerboseEnabled) { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("DotnetDataCollectionLauncher: File {0}, does not exist", depsFilePath); - } + EqtTrace.Verbose("DotnetDataCollectionLauncher: File {0}, does not exist", depsFilePath); } - - var cliArgs = string.Join(" ", commandLineArguments); - var argumentsString = string.Format("{0} \"{1}\" {2} ", args, dataCollectorAssemblyPath, cliArgs); - var dataCollectorProcess = this.processHelper.LaunchProcess(currentProcessFileName, argumentsString, Directory.GetCurrentDirectory(), environmentVariables, this.ErrorReceivedCallback, this.ExitCallBack, null); - this.DataCollectorProcessId = this.processHelper.GetProcessId(dataCollectorProcess); - return this.DataCollectorProcessId; } + + var cliArgs = string.Join(" ", commandLineArguments); + var argumentsString = string.Format("{0} \"{1}\" {2} ", args, dataCollectorAssemblyPath, cliArgs); + var dataCollectorProcess = _processHelper.LaunchProcess(currentProcessFileName, argumentsString, Directory.GetCurrentDirectory(), environmentVariables, ErrorReceivedCallback, ExitCallBack, null); + DataCollectorProcessId = _processHelper.GetProcessId(dataCollectorProcess); + return DataCollectorProcessId; } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollectionExtensionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollectionExtensionManager.cs index 7e82007df3..a27f1c20e3 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollectionExtensionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollectionExtensionManager.cs @@ -1,343 +1,345 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Xml; + +using Common.ExtensionFramework; +using Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.InProcDataCollector; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +/// +/// The in process data collection extension manager. +/// +internal class InProcDataCollectionExtensionManager { - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Reflection; - using System.Xml; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.InProcDataCollector; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + internal IDictionary InProcDataCollectors; - /// - /// The in process data collection extension manager. - /// - internal class InProcDataCollectionExtensionManager - { - internal IDictionary InProcDataCollectors; + private readonly IDataCollectionSink _inProcDataCollectionSink; - private IDataCollectionSink inProcDataCollectionSink; + private const string DataCollectorEndsWithPattern = @"Collector.dll"; - private const string DataCollectorEndsWithPattern = @"Collector.dll"; + private readonly string _defaultCodeBase; - private string defaultCodeBase; + private readonly List _codeBasePaths; - private List codeBasePaths; + private readonly IFileHelper _fileHelper; - private IFileHelper fileHelper; + /// + /// Loaded in-proc datacollectors collection + /// + private IEnumerable _inProcDataCollectorSettingsCollection; - /// - /// Loaded in-proc datacollectors collection - /// - private IEnumerable inProcDataCollectorSettingsCollection; + /// + /// Initializes a new instance of the class. + /// + /// + /// The run settings. + /// + /// + /// The data collection test case event manager. + /// + /// + /// The default code base to be used by in-proc data collector + /// + public InProcDataCollectionExtensionManager(string runSettings, ITestEventsPublisher testEventsPublisher, string defaultCodeBase, TestPluginCache testPluginCache) + : this(runSettings, testEventsPublisher, defaultCodeBase, testPluginCache, new FileHelper()) + { } + + protected InProcDataCollectionExtensionManager(string runSettings, ITestEventsPublisher testEventsPublisher, string defaultCodeBase, TestPluginCache testPluginCache, IFileHelper fileHelper) + { + InProcDataCollectors = new Dictionary(); + _inProcDataCollectionSink = new InProcDataCollectionSink(); + _defaultCodeBase = defaultCodeBase; + _fileHelper = fileHelper; + _codeBasePaths = new List { _defaultCodeBase }; + + // Get Datacollector code base paths from test plugin cache + var extensionPaths = testPluginCache.GetExtensionPaths(DataCollectorEndsWithPattern); + foreach (var extensionPath in extensionPaths) + { + _codeBasePaths.Add(Path.GetDirectoryName(extensionPath)); + } - /// - /// Initializes a new instance of the class. - /// - /// - /// The run settings. - /// - /// - /// The data collection test case event manager. - /// - /// - /// The default code base to be used by in-proc data collector - /// - public InProcDataCollectionExtensionManager(string runSettings, ITestEventsPublisher testEventsPublisher, string defaultCodeBase, TestPluginCache testPluginCache) - : this(runSettings, testEventsPublisher, defaultCodeBase, testPluginCache, new FileHelper()) - {} + // Initialize InProcDataCollectors + InitializeInProcDataCollectors(runSettings); - protected InProcDataCollectionExtensionManager(string runSettings, ITestEventsPublisher testEventsPublisher, string defaultCodeBase, TestPluginCache testPluginCache, IFileHelper fileHelper) + if (IsInProcDataCollectionEnabled) { - this.InProcDataCollectors = new Dictionary(); - this.inProcDataCollectionSink = new InProcDataCollectionSink(); - this.defaultCodeBase = defaultCodeBase; - this.fileHelper = fileHelper; - this.codeBasePaths = new List { this.defaultCodeBase }; - - // Get Datacollector code base paths from test plugin cache - var extensionPaths = testPluginCache.GetExtensionPaths(DataCollectorEndsWithPattern); - foreach (var extensionPath in extensionPaths) - { - this.codeBasePaths.Add(Path.GetDirectoryName(extensionPath)); - } + testEventsPublisher.TestCaseEnd += TriggerTestCaseEnd; + testEventsPublisher.TestCaseStart += TriggerTestCaseStart; + testEventsPublisher.TestResult += TriggerUpdateTestResult; + testEventsPublisher.SessionStart += TriggerTestSessionStart; + testEventsPublisher.SessionEnd += TriggerTestSessionEnd; + } + } - // Initialize InProcDataCollectors - this.InitializeInProcDataCollectors(runSettings); + /// + /// Gets a value indicating whether is in-proc data collection enabled. + /// + public bool IsInProcDataCollectionEnabled { get; private set; } - if (this.IsInProcDataCollectionEnabled) - { - testEventsPublisher.TestCaseEnd += this.TriggerTestCaseEnd; - testEventsPublisher.TestCaseStart += this.TriggerTestCaseStart; - testEventsPublisher.TestResult += this.TriggerUpdateTestResult; - testEventsPublisher.SessionStart += this.TriggerTestSessionStart; - testEventsPublisher.SessionEnd += this.TriggerTestSessionEnd; - } - } + /// + /// Creates data collector instance based on datacollector settings provided. + /// + /// + /// Settings to be used for creating DataCollector. + /// + /// + /// TypeInfo of datacollector. + /// + /// + /// The . + /// + protected virtual IInProcDataCollector CreateDataCollector(string assemblyQualifiedName, string codebase, XmlElement configuration, TypeInfo interfaceTypeInfo) + { + var inProcDataCollector = new InProcDataCollector( + codebase, + assemblyQualifiedName, + interfaceTypeInfo, + configuration?.OuterXml); - /// - /// Gets a value indicating whether is in-proc data collection enabled. - /// - public bool IsInProcDataCollectionEnabled { get; private set; } - - /// - /// Creates data collector instance based on datacollector settings provided. - /// - /// - /// Settings to be used for creating DataCollector. - /// - /// - /// TypeInfo of datacollector. - /// - /// - /// The . - /// - protected virtual IInProcDataCollector CreateDataCollector(string assemblyQualifiedName, string codebase, XmlElement configuration, TypeInfo interfaceTypeInfo) - { - var inProcDataCollector = new InProcDataCollector( - codebase, - assemblyQualifiedName, - interfaceTypeInfo, - configuration?.OuterXml); + inProcDataCollector.LoadDataCollector(_inProcDataCollectionSink); - inProcDataCollector.LoadDataCollector(this.inProcDataCollectionSink); + return inProcDataCollector; + } - return inProcDataCollector; - } + /// + /// The trigger test session start. + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void TriggerTestSessionStart(object sender, SessionStartEventArgs e) + { + TestSessionStartArgs testSessionStartArgs = new(GetSessionStartProperties(e)); + TriggerInProcDataCollectionMethods(Constants.TestSessionStartMethodName, testSessionStartArgs); + } - /// - /// The trigger test session start. - /// - /// - /// The sender. - /// - /// - /// The e. - /// - private void TriggerTestSessionStart(object sender, SessionStartEventArgs e) - { - TestSessionStartArgs testSessionStartArgs = new TestSessionStartArgs(this.GetSessionStartProperties(e)); - this.TriggerInProcDataCollectionMethods(Constants.TestSessionStartMethodName, testSessionStartArgs); - } + /// + /// The trigger session end. + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void TriggerTestSessionEnd(object sender, SessionEndEventArgs e) + { + var testSessionEndArgs = new TestSessionEndArgs(); + TriggerInProcDataCollectionMethods(Constants.TestSessionEndMethodName, testSessionEndArgs); + } - /// - /// The trigger session end. - /// - /// - /// The sender. - /// - /// - /// The e. - /// - private void TriggerTestSessionEnd(object sender, SessionEndEventArgs e) - { - var testSessionEndArgs = new TestSessionEndArgs(); - this.TriggerInProcDataCollectionMethods(Constants.TestSessionEndMethodName, testSessionEndArgs); - } + /// + /// The trigger test case start. + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void TriggerTestCaseStart(object sender, TestCaseStartEventArgs e) + { + var testCaseStartArgs = new TestCaseStartArgs(e.TestElement); + TriggerInProcDataCollectionMethods(Constants.TestCaseStartMethodName, testCaseStartArgs); + } - /// - /// The trigger test case start. - /// - /// - /// The sender. - /// - /// - /// The e. - /// - private void TriggerTestCaseStart(object sender, TestCaseStartEventArgs e) - { - var testCaseStartArgs = new TestCaseStartArgs(e.TestElement); - this.TriggerInProcDataCollectionMethods(Constants.TestCaseStartMethodName, testCaseStartArgs); - } + /// + /// The trigger test case end. + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void TriggerTestCaseEnd(object sender, TestCaseEndEventArgs e) + { + var dataCollectionContext = new DataCollectionContext(e.TestElement); + var testCaseEndArgs = new TestCaseEndArgs(dataCollectionContext, e.TestOutcome); + TriggerInProcDataCollectionMethods(Constants.TestCaseEndMethodName, testCaseEndArgs); + } - /// - /// The trigger test case end. - /// - /// - /// The sender. - /// - /// - /// The e. - /// - private void TriggerTestCaseEnd(object sender, TestCaseEndEventArgs e) - { - var dataCollectionContext = new DataCollectionContext(e.TestElement); - var testCaseEndArgs = new TestCaseEndArgs(dataCollectionContext, e.TestOutcome); - this.TriggerInProcDataCollectionMethods(Constants.TestCaseEndMethodName, testCaseEndArgs); - } + /// + /// Triggers the send test result method + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void TriggerUpdateTestResult(object sender, TestResultEventArgs e) + { + // Just set the cached in-proc data if already exists + SetInProcDataCollectionDataInTestResult(e.TestResult); + } - /// - /// Triggers the send test result method - /// - /// - /// The sender. - /// - /// - /// The e. - /// - private void TriggerUpdateTestResult(object sender, TestResultEventArgs e) + /// + /// Loads all the in-proc data collector dlls + /// + /// + /// The run Settings. + /// + private void InitializeInProcDataCollectors(string runSettings) + { + try { - // Just set the cached in-proc data if already exists - this.SetInProcDataCollectionDataInTestResult(e.TestResult); - } + // Check if runsettings contains in-proc datacollector element + var inProcDataCollectionRunSettings = XmlRunSettingsUtilities.GetInProcDataCollectionRunSettings(runSettings); + var inProcDataCollectionSettingsPresentInRunSettings = inProcDataCollectionRunSettings?.IsCollectionEnabled ?? false; - /// - /// Loads all the in-proc data collector dlls - /// - /// - /// The run Settings. - /// - private void InitializeInProcDataCollectors(string runSettings) - { - try - { - // Check if runsettings contains in-proc datacollector element - var inProcDataCollectionRunSettings = XmlRunSettingsUtilities.GetInProcDataCollectionRunSettings(runSettings); - var inProcDataCollectionSettingsPresentInRunSettings = inProcDataCollectionRunSettings?.IsCollectionEnabled ?? false; + // Verify if it has any valid in-proc datacollectors or just a dummy element + inProcDataCollectionSettingsPresentInRunSettings = inProcDataCollectionSettingsPresentInRunSettings && + inProcDataCollectionRunSettings.DataCollectorSettingsList.Any(); - // Verify if it has any valid in-proc datacollectors or just a dummy element - inProcDataCollectionSettingsPresentInRunSettings = inProcDataCollectionSettingsPresentInRunSettings && - inProcDataCollectionRunSettings.DataCollectorSettingsList.Any(); + // Initialize if we have at least one + if (inProcDataCollectionSettingsPresentInRunSettings) + { + _inProcDataCollectorSettingsCollection = inProcDataCollectionRunSettings.DataCollectorSettingsList; - // Initialize if we have at least one - if (inProcDataCollectionSettingsPresentInRunSettings) + var interfaceTypeInfo = typeof(InProcDataCollection).GetTypeInfo(); + foreach (var inProcDc in _inProcDataCollectorSettingsCollection) { - this.inProcDataCollectorSettingsCollection = inProcDataCollectionRunSettings.DataCollectorSettingsList; - - var interfaceTypeInfo = typeof(InProcDataCollection).GetTypeInfo(); - foreach (var inProcDc in this.inProcDataCollectorSettingsCollection) - { - var codeBase = this.GetCodebase(inProcDc.CodeBase); - var assemblyQualifiedName = inProcDc.AssemblyQualifiedName; - var configuration = inProcDc.Configuration; - var inProcDataCollector = this.CreateDataCollector(assemblyQualifiedName, codeBase, configuration, interfaceTypeInfo); - this.InProcDataCollectors[inProcDataCollector.AssemblyQualifiedName] = inProcDataCollector; - } + var codeBase = GetCodebase(inProcDc.CodeBase); + var assemblyQualifiedName = inProcDc.AssemblyQualifiedName; + var configuration = inProcDc.Configuration; + var inProcDataCollector = CreateDataCollector(assemblyQualifiedName, codeBase, configuration, interfaceTypeInfo); + InProcDataCollectors[inProcDataCollector.AssemblyQualifiedName] = inProcDataCollector; } } - catch (Exception ex) - { - EqtTrace.Error("InProcDataCollectionExtensionManager: Error occurred while Initializing the datacollectors : {0}", ex); - } - finally - { - this.IsInProcDataCollectionEnabled = this.InProcDataCollectors.Any(); - } } - - /// - /// Gets code base for in-proc datacollector - /// Uses all codebasePaths to check where the datacollector exists - /// - /// The code base. - /// Code base - private string GetCodebase(string codeBase) + catch (Exception ex) { - if (!Path.IsPathRooted(codeBase)) - { - foreach (var extensionPath in this.codeBasePaths) - { - var assemblyPath = Path.Combine(extensionPath, codeBase); - if (this.fileHelper.Exists(assemblyPath)) - { - return assemblyPath; - } - } - } - - return codeBase; + EqtTrace.Error("InProcDataCollectionExtensionManager: Error occurred while Initializing the datacollectors : {0}", ex); } - - private IDictionary GetSessionStartProperties(SessionStartEventArgs sessionStartEventArgs) + finally { - var properties = new Dictionary(); - properties.Add(Constants.TestSourcesPropertyName, sessionStartEventArgs.GetPropertyValue>(Constants.TestSourcesPropertyName)); - return properties; + IsInProcDataCollectionEnabled = InProcDataCollectors.Any(); } + } - private void TriggerInProcDataCollectionMethods(string methodName, InProcDataCollectionArgs methodArg) + /// + /// Gets code base for in-proc datacollector + /// Uses all codebasePaths to check where the datacollector exists + /// + /// The code base. + /// Code base + private string GetCodebase(string codeBase) + { + if (!Path.IsPathRooted(codeBase)) { - try + foreach (var extensionPath in _codeBasePaths) { - foreach (var inProcDc in this.InProcDataCollectors.Values) + var assemblyPath = Path.Combine(extensionPath, codeBase); + if (_fileHelper.Exists(assemblyPath)) { - inProcDc.TriggerInProcDataCollectionMethod(methodName, methodArg); + return assemblyPath; } } - catch (Exception ex) - { - EqtTrace.Error("InProcDataCollectionExtensionManager: Error occurred while Triggering the {0} method : {1}", methodName, ex); - } } - /// - /// Set the data sent via datacollection sink in the testresult property for upstream applications to read. - /// And removes the data from the dictionary. - /// - /// - /// The test Result. - /// - private void SetInProcDataCollectionDataInTestResult(TestResult testResult) + return codeBase; + } + + private IDictionary GetSessionStartProperties(SessionStartEventArgs sessionStartEventArgs) + { + var properties = new Dictionary { - // Loops through each datacollector reads the data collection data and sets as TestResult property. - foreach (var entry in this.InProcDataCollectors) - { - var dataCollectionData = ((InProcDataCollectionSink)this.inProcDataCollectionSink).GetDataCollectionDataSetForTestCase(testResult.TestCase.Id); + { Constants.TestSourcesPropertyName, sessionStartEventArgs.GetPropertyValue>(Constants.TestSourcesPropertyName) } + }; + return properties; + } - foreach (var keyValuePair in dataCollectionData) - { - var testProperty = TestProperty.Register(id: keyValuePair.Key, label: keyValuePair.Key, category: string.Empty, description: string.Empty, valueType: typeof(string), validateValueCallback: null, attributes: TestPropertyAttributes.None, owner: typeof(TestCase)); - testResult.SetPropertyValue(testProperty, keyValuePair.Value); - } + private void TriggerInProcDataCollectionMethods(string methodName, InProcDataCollectionArgs methodArg) + { + try + { + foreach (var inProcDc in InProcDataCollectors.Values) + { + inProcDc.TriggerInProcDataCollectionMethod(methodName, methodArg); } } + catch (Exception ex) + { + EqtTrace.Error("InProcDataCollectionExtensionManager: Error occurred while Triggering the {0} method : {1}", methodName, ex); + } } - internal static class Constants + /// + /// Set the data sent via datacollection sink in the testresult property for upstream applications to read. + /// And removes the data from the dictionary. + /// + /// + /// The test Result. + /// + private void SetInProcDataCollectionDataInTestResult(TestResult testResult) { - /// - /// The test session start method name. - /// - public const string TestSessionStartMethodName = "TestSessionStart"; - - /// - /// The test session end method name. - /// - public const string TestSessionEndMethodName = "TestSessionEnd"; - - /// - /// The test case start method name. - /// - public const string TestCaseStartMethodName = "TestCaseStart"; - - /// - /// The test case end method name. - /// - public const string TestCaseEndMethodName = "TestCaseEnd"; - - /// - /// Test sources property name - /// - public const string TestSourcesPropertyName = "TestSources"; - - /// - /// Coverlet in-proc data collector code base - /// - public const string CoverletDataCollectorCodebase = "coverlet.collector.dll"; - - /// - /// Coverlet in-proc data collector type name - /// - public const string CoverletDataCollectorTypeName = "Coverlet.Collector.DataCollection.CoverletInProcDataCollector"; + // Loops through each datacollector reads the data collection data and sets as TestResult property. + foreach (var entry in InProcDataCollectors) + { + var dataCollectionData = ((InProcDataCollectionSink)_inProcDataCollectionSink).GetDataCollectionDataSetForTestCase(testResult.TestCase.Id); + + foreach (var keyValuePair in dataCollectionData) + { + var testProperty = TestProperty.Register(id: keyValuePair.Key, label: keyValuePair.Key, category: string.Empty, description: string.Empty, valueType: typeof(string), validateValueCallback: null, attributes: TestPropertyAttributes.None, owner: typeof(TestCase)); + testResult.SetPropertyValue(testProperty, keyValuePair.Value); + } + } } } + +internal static class Constants +{ + /// + /// The test session start method name. + /// + public const string TestSessionStartMethodName = "TestSessionStart"; + + /// + /// The test session end method name. + /// + public const string TestSessionEndMethodName = "TestSessionEnd"; + + /// + /// The test case start method name. + /// + public const string TestCaseStartMethodName = "TestCaseStart"; + + /// + /// The test case end method name. + /// + public const string TestCaseEndMethodName = "TestCaseEnd"; + + /// + /// Test sources property name + /// + public const string TestSourcesPropertyName = "TestSources"; + + /// + /// Coverlet in-proc data collector code base + /// + public const string CoverletDataCollectorCodebase = "coverlet.collector.dll"; + + /// + /// Coverlet in-proc data collector type name + /// + public const string CoverletDataCollectorTypeName = "Coverlet.Collector.DataCollection.CoverletInProcDataCollector"; +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollectionSink.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollectionSink.cs index 079ac0587f..4628fa9628 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollectionSink.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollectionSink.cs @@ -1,101 +1,99 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; + +using System; +using System.Collections.Generic; + +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +// +internal class InProcDataCollectionSink : IDataCollectionSink { - using System; - using System.Collections.Generic; + private readonly IDictionary _testCaseDataCollectionDataMap; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + /// + /// In process data collection sink + /// + public InProcDataCollectionSink() + { + _testCaseDataCollectionDataMap = new Dictionary(); + } // - internal class InProcDataCollectionSink : IDataCollectionSink + public void SendData(DataCollectionContext dataCollectionContext, string key, string value) { - private IDictionary testCaseDataCollectionDataMap; + ValidateArg.NotNullOrEmpty(key, nameof(key)); + ValidateArg.NotNullOrEmpty(value, nameof(value)); + ValidateArg.NotNullOrEmpty(dataCollectionContext.TestCase.Id.ToString(), "dataCollectionContext.TestCase.Id"); - /// - /// In process data collection sink - /// - public InProcDataCollectionSink() - { - this.testCaseDataCollectionDataMap = new Dictionary(); - } + var testCaseId = dataCollectionContext.TestCase.Id; + AddKeyValuePairToDictionary(testCaseId, key, value); + } - // - public void SendData(DataCollectionContext dataCollectionContext, string key, string value) + /// + /// Gets the data collection data stored in the in process data collection sink + /// + /// valid test case id + /// test data collection dictionary + public IDictionary GetDataCollectionDataSetForTestCase(Guid testCaseId) + { + + if (!_testCaseDataCollectionDataMap.TryGetValue(testCaseId, out TestCaseDataCollectionData testCaseDataCollection)) { - ValidateArg.NotNullOrEmpty(key, nameof(key)); - ValidateArg.NotNullOrEmpty(value, nameof(value)); - ValidateArg.NotNullOrEmpty(dataCollectionContext.TestCase.Id.ToString(), "dataCollectionContext.TestCase.Id"); + if (EqtTrace.IsWarningEnabled) + { + EqtTrace.Warning("No DataCollection Data set for the test case {0}", testCaseId); + } - var testCaseId = dataCollectionContext.TestCase.Id; - this.AddKeyValuePairToDictionary(testCaseId, key, value); + return new Dictionary(); } - - /// - /// Gets the data collection data stored in the in process data collection sink - /// - /// valid test case id - /// test data collection dictionary - public IDictionary GetDataCollectionDataSetForTestCase(Guid testCaseId) + else { - TestCaseDataCollectionData testCaseDataCollection = null; - - if (!this.testCaseDataCollectionDataMap.TryGetValue(testCaseId, out testCaseDataCollection)) - { - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning("No DataCollection Data set for the test case {0}", testCaseId); - } + _testCaseDataCollectionDataMap.Remove(testCaseId); + return testCaseDataCollection.CollectionData; + } + } - return new Dictionary(); - } - else - { - this.testCaseDataCollectionDataMap.Remove(testCaseId); - return testCaseDataCollection.CollectionData; - } + private void AddKeyValuePairToDictionary(Guid testCaseId, string key, string value) + { + if (!_testCaseDataCollectionDataMap.ContainsKey(testCaseId)) + { + var testCaseCollectionData = new TestCaseDataCollectionData(); + testCaseCollectionData.AddOrUpdateData(key, value); + _testCaseDataCollectionDataMap[testCaseId] = testCaseCollectionData; } + else + { + _testCaseDataCollectionDataMap[testCaseId].AddOrUpdateData(key, value); + } + } - private void AddKeyValuePairToDictionary(Guid testCaseId, string key, string value) + private class TestCaseDataCollectionData + { + public TestCaseDataCollectionData() { - if (!this.testCaseDataCollectionDataMap.ContainsKey(testCaseId)) - { - var testCaseCollectionData = new TestCaseDataCollectionData(); - testCaseCollectionData.AddOrUpdateData(key, value); - this.testCaseDataCollectionDataMap[testCaseId] = testCaseCollectionData; - } - else - { - this.testCaseDataCollectionDataMap[testCaseId].AddOrUpdateData(key, value); - } + CollectionData = new Dictionary(); } - private class TestCaseDataCollectionData + internal IDictionary CollectionData { get; private set; } + + internal void AddOrUpdateData(string key, string value) { - public TestCaseDataCollectionData() + if (!CollectionData.ContainsKey(key)) { - this.CollectionData = new Dictionary(); + CollectionData[key] = value; } - - internal IDictionary CollectionData { get; private set; } - - internal void AddOrUpdateData(string key, string value) + else { - if (!this.CollectionData.ContainsKey(key)) - { - this.CollectionData[key] = value; - } - else + if (EqtTrace.IsWarningEnabled) { - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning("The data for in-proc data collector with key {0} has already been set. Will be reset with new value", key); - } - this.CollectionData[key] = value; + EqtTrace.Warning("The data for in-proc data collector with key {0} has already been set. Will be reset with new value", key); } + CollectionData[key] = value; } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollector.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollector.cs index 3c8abb8da9..930a584f05 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollector.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollector.cs @@ -1,175 +1,172 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; + +using System; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; + +using Common.ExtensionFramework; +using Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; +using PlatformAbstractions; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; + +/// +/// Class representing an InProcDataCollector loaded by InProcDataCollectionExtensionManager +/// +internal class InProcDataCollector : IInProcDataCollector { - using System; - using System.Diagnostics; - using System.IO; - using System.Linq; - using System.Reflection; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; + /// + /// DataCollector Class Type + /// + private readonly Type _dataCollectorType; + + /// + /// Instance of the + /// + private object _dataCollectorObject; + + /// + /// Config XML from the runsettings for current datacollector + /// + private readonly string _configXml; /// - /// Class representing an InProcDataCollector loaded by InProcDataCollectionExtensionManager + /// AssemblyLoadContext for current platform /// - internal class InProcDataCollector : IInProcDataCollector + private readonly IAssemblyLoadContext _assemblyLoadContext; + + public InProcDataCollector( + string codeBase, + string assemblyQualifiedName, + TypeInfo interfaceTypeInfo, + string configXml) + : this(codeBase, assemblyQualifiedName, interfaceTypeInfo, configXml, new PlatformAssemblyLoadContext(), TestPluginCache.Instance) { - /// - /// DataCollector Class Type - /// - private Type dataCollectorType; - - /// - /// Instance of the - /// - private object dataCollectorObject; - - /// - /// Config XML from the runsettings for current datacollector - /// - private string configXml; - - /// - /// AssemblyLoadContext for current platform - /// - private IAssemblyLoadContext assemblyLoadContext; - - public InProcDataCollector( - string codeBase, - string assemblyQualifiedName, - TypeInfo interfaceTypeInfo, - string configXml) - : this(codeBase, assemblyQualifiedName, interfaceTypeInfo, configXml, new PlatformAssemblyLoadContext(), TestPluginCache.Instance) - { - } + } - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - internal InProcDataCollector(string codeBase, string assemblyQualifiedName, TypeInfo interfaceTypeInfo, string configXml, IAssemblyLoadContext assemblyLoadContext, TestPluginCache testPluginCache) - { - this.configXml = configXml; - this.assemblyLoadContext = assemblyLoadContext; - - var assembly = this.LoadInProcDataCollectorExtension(codeBase); - - Func filterPredicate; - if (Path.GetFileName(codeBase) == Constants.CoverletDataCollectorCodebase) - { - // If we're loading coverlet collector we skip to check the version of assembly - // to allow upgrade through nuget package - filterPredicate = (x) => x.FullName.Equals(Constants.CoverletDataCollectorTypeName) && interfaceTypeInfo.IsAssignableFrom(x.GetTypeInfo()); - - // Coverlet collector is consumed as nuget package we need to add assemblies directory to resolver to correctly load references. - Debug.Assert(Path.IsPathRooted(codeBase), "Absolute path expected"); - testPluginCache.AddResolverSearchDirectories(new string[] { Path.GetDirectoryName(codeBase) }); - } - else - { - filterPredicate = (x) => x.AssemblyQualifiedName.Equals(assemblyQualifiedName) && interfaceTypeInfo.IsAssignableFrom(x.GetTypeInfo()); - } - - this.dataCollectorType = assembly?.GetTypes().FirstOrDefault(filterPredicate); - this.AssemblyQualifiedName = this.dataCollectorType?.AssemblyQualifiedName; - } + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + internal InProcDataCollector(string codeBase, string assemblyQualifiedName, TypeInfo interfaceTypeInfo, string configXml, IAssemblyLoadContext assemblyLoadContext, TestPluginCache testPluginCache) + { + _configXml = configXml; + _assemblyLoadContext = assemblyLoadContext; - /// - /// AssemblyQualifiedName of the datacollector type - /// - public string AssemblyQualifiedName { get; private set; } + var assembly = LoadInProcDataCollectorExtension(codeBase); - /// - /// Loads the DataCollector type - /// - /// Sink object to send data - public void LoadDataCollector(IDataCollectionSink inProcDataCollectionSink) + Func filterPredicate; + if (Path.GetFileName(codeBase) == Constants.CoverletDataCollectorCodebase) { - this.dataCollectorObject = CreateObjectFromType(dataCollectorType); - InitializeDataCollector(dataCollectorObject, inProcDataCollectionSink); - } + // If we're loading coverlet collector we skip to check the version of assembly + // to allow upgrade through nuget package + filterPredicate = (x) => x.FullName.Equals(Constants.CoverletDataCollectorTypeName) && interfaceTypeInfo.IsAssignableFrom(x.GetTypeInfo()); - /// - /// Triggers InProcDataCollection Methods - /// - /// Name of the method to trigger - /// Arguments for the method - public void TriggerInProcDataCollectionMethod(string methodName, InProcDataCollectionArgs methodArg) + // Coverlet collector is consumed as nuget package we need to add assemblies directory to resolver to correctly load references. + Debug.Assert(Path.IsPathRooted(codeBase), "Absolute path expected"); + testPluginCache.AddResolverSearchDirectories(new string[] { Path.GetDirectoryName(codeBase) }); + } + else { - var methodInfo = GetMethodInfoFromType(this.dataCollectorObject.GetType(), methodName, new[] { methodArg.GetType() }); - - if (methodName.Equals(Constants.TestSessionStartMethodName)) - { - var testSessionStartArgs = (TestSessionStartArgs)methodArg; - testSessionStartArgs.Configuration = configXml; - methodInfo?.Invoke(this.dataCollectorObject, new object[] { testSessionStartArgs }); - } - else - { - methodInfo?.Invoke(this.dataCollectorObject, new object[] { methodArg }); - } + filterPredicate = (x) => x.AssemblyQualifiedName.Equals(assemblyQualifiedName) && interfaceTypeInfo.IsAssignableFrom(x.GetTypeInfo()); } - #region Private Methods + _dataCollectorType = assembly?.GetTypes().FirstOrDefault(filterPredicate); + AssemblyQualifiedName = _dataCollectorType?.AssemblyQualifiedName; + } + + /// + /// AssemblyQualifiedName of the datacollector type + /// + public string AssemblyQualifiedName { get; private set; } + + /// + /// Loads the DataCollector type + /// + /// Sink object to send data + public void LoadDataCollector(IDataCollectionSink inProcDataCollectionSink) + { + _dataCollectorObject = CreateObjectFromType(_dataCollectorType); + InitializeDataCollector(_dataCollectorObject, inProcDataCollectionSink); + } + + /// + /// Triggers InProcDataCollection Methods + /// + /// Name of the method to trigger + /// Arguments for the method + public void TriggerInProcDataCollectionMethod(string methodName, InProcDataCollectionArgs methodArg) + { + var methodInfo = GetMethodInfoFromType(_dataCollectorObject.GetType(), methodName, new[] { methodArg.GetType() }); - private void InitializeDataCollector(object obj, IDataCollectionSink inProcDataCollectionSink) + if (methodName.Equals(Constants.TestSessionStartMethodName)) { - var initializeMethodInfo = GetMethodInfoFromType(obj.GetType(), "Initialize", new Type[] { typeof(IDataCollectionSink) }); - initializeMethodInfo.Invoke(obj, new object[] { inProcDataCollectionSink }); + var testSessionStartArgs = (TestSessionStartArgs)methodArg; + testSessionStartArgs.Configuration = _configXml; + methodInfo?.Invoke(_dataCollectorObject, new object[] { testSessionStartArgs }); } - - private static MethodInfo GetMethodInfoFromType(Type type, string funcName, Type[] argumentTypes) + else { - return type.GetMethod(funcName, argumentTypes); + methodInfo?.Invoke(_dataCollectorObject, new object[] { methodArg }); } + } - private static object CreateObjectFromType(Type type) - { - object obj = null; + #region Private Methods + + private void InitializeDataCollector(object obj, IDataCollectionSink inProcDataCollectionSink) + { + var initializeMethodInfo = GetMethodInfoFromType(obj.GetType(), "Initialize", new Type[] { typeof(IDataCollectionSink) }); + initializeMethodInfo.Invoke(obj, new object[] { inProcDataCollectionSink }); + } - var constructorInfo = type.GetConstructor(Type.EmptyTypes); - obj = constructorInfo?.Invoke(new object[] { }); + private static MethodInfo GetMethodInfoFromType(Type type, string funcName, Type[] argumentTypes) + { + return type.GetMethod(funcName, argumentTypes); + } - return obj; - } + private static object CreateObjectFromType(Type type) + { + var constructorInfo = type.GetConstructor(Type.EmptyTypes); + object obj = constructorInfo?.Invoke(new object[] { }); + return obj; + } - /// - /// Loads the assembly into the default context based on the code base path - /// - /// - /// - private Assembly LoadInProcDataCollectorExtension(string codeBase) + /// + /// Loads the assembly into the default context based on the code base path + /// + /// + /// + private Assembly LoadInProcDataCollectorExtension(string codeBase) + { + Assembly assembly = null; + try { - Assembly assembly = null; - try - { - assembly = this.assemblyLoadContext.LoadAssemblyFromPath(Environment.ExpandEnvironmentVariables(codeBase)); - } - catch (Exception ex) - { - EqtTrace.Error( - "InProcDataCollectionExtensionManager: Error occurred while loading the InProcDataCollector : {0} , Exception Details : {1}", codeBase, ex); - } - - return assembly; + assembly = _assemblyLoadContext.LoadAssemblyFromPath(Environment.ExpandEnvironmentVariables(codeBase)); + } + catch (Exception ex) + { + EqtTrace.Error( + "InProcDataCollectionExtensionManager: Error occurred while loading the InProcDataCollector : {0} , Exception Details : {1}", codeBase, ex); } - #endregion + return assembly; } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/IDataCollectionLauncher.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/IDataCollectionLauncher.cs index 3ecc52e14b..27dfa8c79f 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/IDataCollectionLauncher.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/IDataCollectionLauncher.cs @@ -1,32 +1,31 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; + +using System.Collections.Generic; +/// +/// The DataCollectionLauncher interface. +/// +internal interface IDataCollectionLauncher +{ /// - /// The DataCollectionLauncher interface. + /// Gets the data collector process id /// - internal interface IDataCollectionLauncher - { - /// - /// Gets the data collector process id - /// - int DataCollectorProcessId { get; } + int DataCollectorProcessId { get; } - /// - /// The launch data collector. - /// - /// - /// The environment variables. - /// - /// - /// The command line arguments. - /// - /// - /// The . - /// - int LaunchDataCollector(IDictionary environmentVariables, IList commandLineArguments); - } + /// + /// The launch data collector. + /// + /// + /// The environment variables. + /// + /// + /// The command line arguments. + /// + /// + /// The . + /// + int LaunchDataCollector(IDictionary environmentVariables, IList commandLineArguments); } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/IDataCollectorsSettingsProvider.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/IDataCollectorsSettingsProvider.cs index a131b129d0..2f31c5563d 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/IDataCollectorsSettingsProvider.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/IDataCollectorsSettingsProvider.cs @@ -1,19 +1,18 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces -{ - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; + +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +/// +/// The DataCollectorsSettingsProvider interface. +/// +public interface IDataCollectorsSettingsProvider : ISettingsProvider +{ /// - /// The DataCollectorsSettingsProvider interface. + /// Gets run specific data collection settings. /// - public interface IDataCollectorsSettingsProvider : ISettingsProvider - { - /// - /// Gets run specific data collection settings. - /// - DataCollectionRunSettings Settings { get; } - } + DataCollectionRunSettings Settings { get; } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/IInProcDataCollector.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/IInProcDataCollector.cs index e3e59f5982..ff76b962ba 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/IInProcDataCollector.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/IInProcDataCollector.cs @@ -1,29 +1,28 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces -{ - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; - internal interface IInProcDataCollector - { - /// - /// AssemblyQualifiedName of the datacollector type - /// - string AssemblyQualifiedName { get; } +internal interface IInProcDataCollector +{ + /// + /// AssemblyQualifiedName of the datacollector type + /// + string AssemblyQualifiedName { get; } - /// - /// Loads the DataCollector type - /// - /// Sink object to send data - void LoadDataCollector(IDataCollectionSink inProcDataCollectionSink); + /// + /// Loads the DataCollector type + /// + /// Sink object to send data + void LoadDataCollector(IDataCollectionSink inProcDataCollectionSink); - /// - /// Triggers InProcDataCollection Methods - /// - /// Name of the method to trigger - /// Arguments for the method - void TriggerInProcDataCollectionMethod(string methodName, InProcDataCollectionArgs methodArg); - } -} + /// + /// Triggers InProcDataCollection Methods + /// + /// Name of the method to trigger + /// Arguments for the method + void TriggerInProcDataCollectionMethod(string methodName, InProcDataCollectionArgs methodArg); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/IProxyDataCollectionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/IProxyDataCollectionManager.cs index 5bc5e920af..54ba7033bc 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/IProxyDataCollectionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/IProxyDataCollectionManager.cs @@ -1,75 +1,72 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces -{ - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; + +using System; +using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +/// +/// The ProxyDataCollectionManager interface. +/// +public interface IProxyDataCollectionManager : IDisposable +{ /// - /// The ProxyDataCollectionManager interface. + /// Initializes proxy datacollection manager. /// - public interface IProxyDataCollectionManager : IDisposable - { - /// - /// Initializes proxy datacollection manager. - /// - void Initialize(); + void Initialize(); - /// - /// The settings xml - /// - string SettingsXml { get; } + /// + /// The settings xml + /// + string SettingsXml { get; } - /// - /// List of test sources - /// - IEnumerable Sources { get; } + /// + /// List of test sources + /// + IEnumerable Sources { get; } - /// - /// Invoked before starting of test run - /// - /// - /// Bool value to reset and reinitialize datacollectors. - /// - /// - /// Bool value to specify if the test execution has started or not. - /// - /// - /// The run Events Handler. - /// - /// - /// BeforeTestRunStartResult object - /// - DataCollectionParameters BeforeTestRunStart( - bool resetDataCollectors, - bool isRunStartingNow, - ITestMessageEventHandler runEventsHandler); + /// + /// Invoked before starting of test run + /// + /// + /// Bool value to reset and reinitialize datacollectors. + /// + /// + /// Bool value to specify if the test execution has started or not. + /// + /// + /// The run Events Handler. + /// + /// + /// BeforeTestRunStartResult object + /// + DataCollectionParameters BeforeTestRunStart( + bool resetDataCollectors, + bool isRunStartingNow, + ITestMessageEventHandler runEventsHandler); - /// - /// Invoked after ending of test run - /// - /// - /// The is Canceled. - /// - /// - /// The run Events Handler. - /// - /// - /// The . - /// - DataCollectionResult AfterTestRunEnd(bool isCanceled, ITestMessageEventHandler runEventsHandler); + /// + /// Invoked after ending of test run + /// + /// + /// The is Canceled. + /// + /// + /// The run Events Handler. + /// + /// + /// The . + /// + DataCollectionResult AfterTestRunEnd(bool isCanceled, ITestMessageEventHandler runEventsHandler); - /// - /// Invoked after initialization of test host - /// - /// - /// Process ID of test host - /// - void TestHostLaunched(int processId); - } + /// + /// Invoked after initialization of test host + /// + /// + /// Process ID of test host + /// + void TestHostLaunched(int processId); } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/ITestEventsPublisher.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/ITestEventsPublisher.cs index 5a79eef295..e2a4f7f3d0 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/ITestEventsPublisher.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/Interfaces/ITestEventsPublisher.cs @@ -1,40 +1,39 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; + +using System; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +/// +/// Manager for sending test case events to data collectors. +/// +internal interface ITestEventsPublisher { - using System; + /// + /// The session start event. + /// + event EventHandler SessionStart; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + /// + /// The session end event. + /// + event EventHandler SessionEnd; + + /// + /// The test case start event. + /// + event EventHandler TestCaseStart; + + /// + /// The test case end event. + /// + event EventHandler TestCaseEnd; /// - /// Manager for sending test case events to data collectors. + /// The test result event. /// - internal interface ITestEventsPublisher - { - /// - /// The session start event. - /// - event EventHandler SessionStart; - - /// - /// The session end event. - /// - event EventHandler SessionEnd; - - /// - /// The test case start event. - /// - event EventHandler TestCaseStart; - - /// - /// The test case end event. - /// - event EventHandler TestCaseEnd; - - /// - /// The test result event. - /// - event EventHandler TestResult; - } -} + event EventHandler TestResult; +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ParallelDataCollectionEventsHandler.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ParallelDataCollectionEventsHandler.cs index 0d250772f9..ed47afff1c 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ParallelDataCollectionEventsHandler.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ParallelDataCollectionEventsHandler.cs @@ -1,76 +1,75 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; + +using System.Collections.Generic; +using System.Threading; + +using CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Client.Parallel; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; + +internal class ParallelDataCollectionEventsHandler : ParallelRunEventsHandler { - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Threading; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + private readonly ParallelRunDataAggregator _runDataAggregator; + private readonly ITestRunAttachmentsProcessingManager _attachmentsProcessingManager; + private readonly CancellationToken _cancellationToken; - internal class ParallelDataCollectionEventsHandler : ParallelRunEventsHandler + public ParallelDataCollectionEventsHandler(IRequestData requestData, + IProxyExecutionManager proxyExecutionManager, + ITestRunEventsHandler actualRunEventsHandler, + IParallelProxyExecutionManager parallelProxyExecutionManager, + ParallelRunDataAggregator runDataAggregator, + ITestRunAttachmentsProcessingManager attachmentsProcessingManager, + CancellationToken cancellationToken) : + this(requestData, proxyExecutionManager, actualRunEventsHandler, parallelProxyExecutionManager, runDataAggregator, JsonDataSerializer.Instance) { - private readonly ParallelRunDataAggregator runDataAggregator; - private readonly ITestRunAttachmentsProcessingManager attachmentsProcessingManager; - private readonly CancellationToken cancellationToken; + _attachmentsProcessingManager = attachmentsProcessingManager; + _cancellationToken = cancellationToken; + } - public ParallelDataCollectionEventsHandler(IRequestData requestData, - IProxyExecutionManager proxyExecutionManager, - ITestRunEventsHandler actualRunEventsHandler, - IParallelProxyExecutionManager parallelProxyExecutionManager, - ParallelRunDataAggregator runDataAggregator, - ITestRunAttachmentsProcessingManager attachmentsProcessingManager, - CancellationToken cancellationToken) : - this(requestData, proxyExecutionManager, actualRunEventsHandler, parallelProxyExecutionManager, runDataAggregator, JsonDataSerializer.Instance) - { - this.attachmentsProcessingManager = attachmentsProcessingManager; - this.cancellationToken = cancellationToken; - } + internal ParallelDataCollectionEventsHandler(IRequestData requestData, + IProxyExecutionManager proxyExecutionManager, + ITestRunEventsHandler actualRunEventsHandler, + IParallelProxyExecutionManager parallelProxyExecutionManager, + ParallelRunDataAggregator runDataAggregator, + IDataSerializer dataSerializer) : + base(requestData, proxyExecutionManager, actualRunEventsHandler, parallelProxyExecutionManager, runDataAggregator, dataSerializer) + { + _runDataAggregator = runDataAggregator; + } - internal ParallelDataCollectionEventsHandler(IRequestData requestData, - IProxyExecutionManager proxyExecutionManager, - ITestRunEventsHandler actualRunEventsHandler, - IParallelProxyExecutionManager parallelProxyExecutionManager, - ParallelRunDataAggregator runDataAggregator, - IDataSerializer dataSerializer) : - base(requestData, proxyExecutionManager, actualRunEventsHandler, parallelProxyExecutionManager, runDataAggregator, dataSerializer) - { - this.runDataAggregator = runDataAggregator; - } + /// + /// Handles the Run Complete event from a parallel proxy manager + /// + public override void HandleTestRunComplete( + TestRunCompleteEventArgs testRunCompleteArgs, + TestRunChangedEventArgs lastChunkArgs, + ICollection runContextAttachments, + ICollection executorUris) + { + var parallelRunComplete = HandleSingleTestRunComplete(testRunCompleteArgs, lastChunkArgs, runContextAttachments, executorUris); - /// - /// Handles the Run Complete event from a parallel proxy manager - /// - public override void HandleTestRunComplete( - TestRunCompleteEventArgs testRunCompleteArgs, - TestRunChangedEventArgs lastChunkArgs, - ICollection runContextAttachments, - ICollection executorUris) + if (parallelRunComplete) { - var parallelRunComplete = HandleSingleTestRunComplete(testRunCompleteArgs, lastChunkArgs, runContextAttachments, executorUris); - - if (parallelRunComplete) - { - runDataAggregator.RunContextAttachments = attachmentsProcessingManager.ProcessTestRunAttachmentsAsync(runDataAggregator.RunSettings, requestData, runDataAggregator.RunContextAttachments, runDataAggregator.InvokedDataCollectors, cancellationToken).Result ?? runDataAggregator.RunContextAttachments; + _runDataAggregator.RunContextAttachments = _attachmentsProcessingManager.ProcessTestRunAttachmentsAsync(_runDataAggregator.RunSettings, _requestData, _runDataAggregator.RunContextAttachments, _runDataAggregator.InvokedDataCollectors, _cancellationToken).Result ?? _runDataAggregator.RunContextAttachments; - var completedArgs = new TestRunCompleteEventArgs(this.runDataAggregator.GetAggregatedRunStats(), - this.runDataAggregator.IsCanceled, - this.runDataAggregator.IsAborted, - this.runDataAggregator.GetAggregatedException(), - this.runDataAggregator.RunContextAttachments, - this.runDataAggregator.InvokedDataCollectors, - this.runDataAggregator.ElapsedTime); + var completedArgs = new TestRunCompleteEventArgs(_runDataAggregator.GetAggregatedRunStats(), + _runDataAggregator.IsCanceled, + _runDataAggregator.IsAborted, + _runDataAggregator.GetAggregatedException(), + _runDataAggregator.RunContextAttachments, + _runDataAggregator.InvokedDataCollectors, + _runDataAggregator.ElapsedTime); - // Add Metrics from Test Host - completedArgs.Metrics = this.runDataAggregator.GetAggregatedRunDataMetrics(); + // Add Metrics from Test Host + completedArgs.Metrics = _runDataAggregator.GetAggregatedRunDataMetrics(); - HandleParallelTestRunComplete(completedArgs); - } + HandleParallelTestRunComplete(completedArgs); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ProxyDataCollectionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ProxyDataCollectionManager.cs index 8757b1bc4a..e1d61258fa 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ProxyDataCollectionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ProxyDataCollectionManager.cs @@ -1,201 +1,200 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Xml; +using CoreUtilities.Helpers; +using Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using CoreUtilities.Extensions; +using Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using PlatformAbstractions; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities; + +using CrossPlatEngineResources = Resources.Resources; +using CommunicationUtilitiesResources = CommunicationUtilities.Resources.Resources; +using CoreUtilitiesConstants = CoreUtilities.Constants; +using Microsoft.VisualStudio.TestPlatform.Common.DataCollection; + +/// +/// Managed datacollector interaction from runner process. +/// +internal class ProxyDataCollectionManager : IProxyDataCollectionManager { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Reflection; - using System.Xml; - using CoreUtilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities; - - using CrossPlatEngineResources = Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources.Resources; - using CommunicationUtilitiesResources = Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources.Resources; - using CoreUtilitiesConstants = Microsoft.VisualStudio.TestPlatform.CoreUtilities.Constants; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollection; + private const string PortOption = "--port"; + private const string DiagOption = "--diag"; + private const string ParentProcessIdOption = "--parentprocessid"; + private const string TraceLevelOption = "--tracelevel"; + public const string DebugEnvironmentVaribleName = "VSTEST_DATACOLLECTOR_DEBUG"; + + private readonly IDataCollectionRequestSender _dataCollectionRequestSender; + private readonly IDataCollectionLauncher _dataCollectionLauncher; + private readonly IProcessHelper _processHelper; + private readonly IRequestData _requestData; + private int _dataCollectionPort; + private int _dataCollectionProcessId; /// - /// Managed datacollector interaction from runner process. + /// The settings xml /// - internal class ProxyDataCollectionManager : IProxyDataCollectionManager + public string SettingsXml { get; } + + /// + /// List of test sources + /// + public IEnumerable Sources { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Request Data providing common execution/discovery services. + /// + /// + /// Runsettings that contains the datacollector related configuration. + /// + /// + /// Test Run sources + /// + public ProxyDataCollectionManager(IRequestData requestData, string settingsXml, IEnumerable sources) + : this(requestData, settingsXml, sources, new ProcessHelper()) { - private const string PortOption = "--port"; - private const string DiagOption = "--diag"; - private const string ParentProcessIdOption = "--parentprocessid"; - private const string TraceLevelOption = "--tracelevel"; - public const string DebugEnvironmentVaribleName = "VSTEST_DATACOLLECTOR_DEBUG"; - - private IDataCollectionRequestSender dataCollectionRequestSender; - private IDataCollectionLauncher dataCollectionLauncher; - private IProcessHelper processHelper; - private IRequestData requestData; - private int dataCollectionPort; - private int dataCollectionProcessId; - - /// - /// The settings xml - /// - public string SettingsXml { get; } - - /// - /// List of test sources - /// - public IEnumerable Sources { get; } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Request Data providing common execution/discovery services. - /// - /// - /// Runsettings that contains the datacollector related configuration. - /// - /// - /// Test Run sources - /// - public ProxyDataCollectionManager(IRequestData requestData, string settingsXml, IEnumerable sources) - : this(requestData, settingsXml, sources, new ProcessHelper()) - { - } + } - /// - /// Initializes a new instance of the class. - /// - /// - /// Request Data providing common execution/discovery services. - /// - /// - /// The settings xml. - /// - /// - /// Test Run sources - /// - /// - /// The process helper. - /// - internal ProxyDataCollectionManager(IRequestData requestData, string settingsXml, IEnumerable sources, IProcessHelper processHelper) : this(requestData, settingsXml, sources, new DataCollectionRequestSender(), processHelper, DataCollectionLauncherFactory.GetDataCollectorLauncher(processHelper, settingsXml)) - { - } + /// + /// Initializes a new instance of the class. + /// + /// + /// Request Data providing common execution/discovery services. + /// + /// + /// The settings xml. + /// + /// + /// Test Run sources + /// + /// + /// The process helper. + /// + internal ProxyDataCollectionManager(IRequestData requestData, string settingsXml, IEnumerable sources, IProcessHelper processHelper) : this(requestData, settingsXml, sources, new DataCollectionRequestSender(), processHelper, DataCollectionLauncherFactory.GetDataCollectorLauncher(processHelper, settingsXml)) + { + } - /// - /// Initializes a new instance of the class. - /// - /// - /// Request Data providing common execution/discovery services. - /// - /// - /// Runsettings that contains the datacollector related configuration. - /// - /// - /// Test Run sources - /// - /// - /// Handles communication with datacollector process. - /// - /// - /// The process Helper. - /// - /// - /// Launches datacollector process. - /// - internal ProxyDataCollectionManager(IRequestData requestData, string settingsXml, - IEnumerable sources, - IDataCollectionRequestSender dataCollectionRequestSender, IProcessHelper processHelper, - IDataCollectionLauncher dataCollectionLauncher) - { - // DataCollector process needs the information of the Extensions folder - // Add the Extensions folder path to runsettings. - this.SettingsXml = UpdateExtensionsFolderInRunSettings(settingsXml); - this.Sources = sources; - this.requestData = requestData; - - this.dataCollectionRequestSender = dataCollectionRequestSender; - this.dataCollectionLauncher = dataCollectionLauncher; - this.processHelper = processHelper; - this.LogEnabledDataCollectors(); - } + /// + /// Initializes a new instance of the class. + /// + /// + /// Request Data providing common execution/discovery services. + /// + /// + /// Runsettings that contains the datacollector related configuration. + /// + /// + /// Test Run sources + /// + /// + /// Handles communication with datacollector process. + /// + /// + /// The process Helper. + /// + /// + /// Launches datacollector process. + /// + internal ProxyDataCollectionManager(IRequestData requestData, string settingsXml, + IEnumerable sources, + IDataCollectionRequestSender dataCollectionRequestSender, IProcessHelper processHelper, + IDataCollectionLauncher dataCollectionLauncher) + { + // DataCollector process needs the information of the Extensions folder + // Add the Extensions folder path to runsettings. + SettingsXml = UpdateExtensionsFolderInRunSettings(settingsXml); + Sources = sources; + _requestData = requestData; + + _dataCollectionRequestSender = dataCollectionRequestSender; + _dataCollectionLauncher = dataCollectionLauncher; + _processHelper = processHelper; + LogEnabledDataCollectors(); + } - /// - /// Invoked after ending of test run - /// - /// - /// The is Canceled. - /// - /// - /// The run Events Handler. - /// - /// - /// The . - /// - public DataCollectionResult AfterTestRunEnd(bool isCanceled, ITestMessageEventHandler runEventsHandler) - { - AfterTestRunEndResult afterTestRunEnd = null; - this.InvokeDataCollectionServiceAction( + /// + /// Invoked after ending of test run + /// + /// + /// The is Canceled. + /// + /// + /// The run Events Handler. + /// + /// + /// The . + /// + public DataCollectionResult AfterTestRunEnd(bool isCanceled, ITestMessageEventHandler runEventsHandler) + { + AfterTestRunEndResult afterTestRunEnd = null; + InvokeDataCollectionServiceAction( () => { - EqtTrace.Info("ProxyDataCollectionManager.AfterTestRunEnd: Get attachment set and invoked data collectors processId: {0} port: {1}", dataCollectionProcessId, dataCollectionPort); - afterTestRunEnd = this.dataCollectionRequestSender.SendAfterTestRunEndAndGetResult(runEventsHandler, isCanceled); + EqtTrace.Info("ProxyDataCollectionManager.AfterTestRunEnd: Get attachment set and invoked data collectors processId: {0} port: {1}", _dataCollectionProcessId, _dataCollectionPort); + afterTestRunEnd = _dataCollectionRequestSender.SendAfterTestRunEndAndGetResult(runEventsHandler, isCanceled); }, runEventsHandler); - if (requestData.IsTelemetryOptedIn && afterTestRunEnd?.Metrics != null) + if (_requestData.IsTelemetryOptedIn && afterTestRunEnd?.Metrics != null) + { + foreach (var metric in afterTestRunEnd.Metrics) { - foreach (var metric in afterTestRunEnd.Metrics) - { - requestData.MetricsCollection.Add(metric.Key, metric.Value); - } + _requestData.MetricsCollection.Add(metric.Key, metric.Value); } - - return new DataCollectionResult(afterTestRunEnd?.AttachmentSets, afterTestRunEnd?.InvokedDataCollectors); } - /// - /// Invoked before starting of test run - /// - /// - /// The reset Data Collectors. - /// - /// - /// The is Run Starting Now. - /// - /// - /// The run Events Handler. - /// - /// - /// BeforeTestRunStartResult object - /// - public DataCollectionParameters BeforeTestRunStart( - bool resetDataCollectors, - bool isRunStartingNow, - ITestMessageEventHandler runEventsHandler) - { - var areTestCaseLevelEventsRequired = false; - IDictionary environmentVariables = new Dictionary(); + return new DataCollectionResult(afterTestRunEnd?.AttachmentSets, afterTestRunEnd?.InvokedDataCollectors); + } + + /// + /// Invoked before starting of test run + /// + /// + /// The reset Data Collectors. + /// + /// + /// The is Run Starting Now. + /// + /// + /// The run Events Handler. + /// + /// + /// BeforeTestRunStartResult object + /// + public DataCollectionParameters BeforeTestRunStart( + bool resetDataCollectors, + bool isRunStartingNow, + ITestMessageEventHandler runEventsHandler) + { + var areTestCaseLevelEventsRequired = false; + IDictionary environmentVariables = new Dictionary(); - var dataCollectionEventsPort = 0; - this.InvokeDataCollectionServiceAction( + var dataCollectionEventsPort = 0; + InvokeDataCollectionServiceAction( () => { - EqtTrace.Info("ProxyDataCollectionManager.BeforeTestRunStart: Get environment variable and port for datacollector processId: {0} port: {1}", this.dataCollectionProcessId, this.dataCollectionPort); - var result = this.dataCollectionRequestSender.SendBeforeTestRunStartAndGetResult(this.SettingsXml, this.Sources, this.requestData.IsTelemetryOptedIn, runEventsHandler); + EqtTrace.Info("ProxyDataCollectionManager.BeforeTestRunStart: Get environment variable and port for datacollector processId: {0} port: {1}", _dataCollectionProcessId, _dataCollectionPort); + var result = _dataCollectionRequestSender.SendBeforeTestRunStartAndGetResult(SettingsXml, Sources, _requestData.IsTelemetryOptedIn, runEventsHandler); environmentVariables = result.EnvironmentVariables; dataCollectionEventsPort = result.DataCollectionEventsPort; @@ -204,216 +203,214 @@ public DataCollectionParameters BeforeTestRunStart( string.Join(";", environmentVariables), dataCollectionEventsPort); }, - runEventsHandler); - return new DataCollectionParameters( - areTestCaseLevelEventsRequired, - environmentVariables, - dataCollectionEventsPort); - } + runEventsHandler); + return new DataCollectionParameters( + areTestCaseLevelEventsRequired, + environmentVariables, + dataCollectionEventsPort); + } - /// - public void TestHostLaunched(int processId) - { - var payload = new TestHostLaunchedPayload(); - payload.ProcessId = processId; + /// + public void TestHostLaunched(int processId) + { + var payload = new TestHostLaunchedPayload(); + payload.ProcessId = processId; - this.dataCollectionRequestSender.SendTestHostLaunched(payload); - } + _dataCollectionRequestSender.SendTestHostLaunched(payload); + } - /// - /// The dispose. - /// - public void Dispose() - { - EqtTrace.Info("ProxyDataCollectionManager.Dispose: calling dispose for datacollector processId: {0} port: {1}", this.dataCollectionProcessId, this.dataCollectionPort); - this.dataCollectionRequestSender.Close(); - } + /// + /// The dispose. + /// + public void Dispose() + { + EqtTrace.Info("ProxyDataCollectionManager.Dispose: calling dispose for datacollector processId: {0} port: {1}", _dataCollectionProcessId, _dataCollectionPort); + _dataCollectionRequestSender.Close(); + } - /// - public void Initialize() - { - this.dataCollectionPort = this.dataCollectionRequestSender.InitializeCommunication(); + /// + public void Initialize() + { + _dataCollectionPort = _dataCollectionRequestSender.InitializeCommunication(); - // Warn the user that execution will wait for debugger attach. - this.dataCollectionProcessId = this.dataCollectionLauncher.LaunchDataCollector(null, this.GetCommandLineArguments(this.dataCollectionPort)); - EqtTrace.Info("ProxyDataCollectionManager.Initialize: Launched datacollector processId: {0} port: {1}", this.dataCollectionProcessId, this.dataCollectionPort); + // Warn the user that execution will wait for debugger attach. + _dataCollectionProcessId = _dataCollectionLauncher.LaunchDataCollector(null, GetCommandLineArguments(_dataCollectionPort)); + EqtTrace.Info("ProxyDataCollectionManager.Initialize: Launched datacollector processId: {0} port: {1}", _dataCollectionProcessId, _dataCollectionPort); - var connectionTimeout = this.GetConnectionTimeout(dataCollectionProcessId); + var connectionTimeout = GetConnectionTimeout(_dataCollectionProcessId); - EqtTrace.Info("ProxyDataCollectionManager.Initialize: waiting for connection with timeout: {0} seconds", connectionTimeout); + EqtTrace.Info("ProxyDataCollectionManager.Initialize: waiting for connection with timeout: {0} seconds", connectionTimeout); - var connected = this.dataCollectionRequestSender.WaitForRequestHandlerConnection(connectionTimeout * 1000); - if (connected == false) - { - EqtTrace.Error("ProxyDataCollectionManager.Initialize: failed to connect to datacollector process, processId: {0} port: {1}", this.dataCollectionProcessId, this.dataCollectionPort); - throw new TestPlatformException( - string.Format( - CultureInfo.CurrentUICulture, - CommunicationUtilitiesResources.ConnectionTimeoutErrorMessage, - CoreUtilitiesConstants.VstestConsoleProcessName, - CoreUtilitiesConstants.DatacollectorProcessName, - connectionTimeout, - EnvironmentHelper.VstestConnectionTimeout) - ); - } + var connected = _dataCollectionRequestSender.WaitForRequestHandlerConnection(connectionTimeout * 1000); + if (connected == false) + { + EqtTrace.Error("ProxyDataCollectionManager.Initialize: failed to connect to datacollector process, processId: {0} port: {1}", _dataCollectionProcessId, _dataCollectionPort); + throw new TestPlatformException( + string.Format( + CultureInfo.CurrentUICulture, + CommunicationUtilitiesResources.ConnectionTimeoutErrorMessage, + CoreUtilitiesConstants.VstestConsoleProcessName, + CoreUtilitiesConstants.DatacollectorProcessName, + connectionTimeout, + EnvironmentHelper.VstestConnectionTimeout) + ); } + } + + private int GetConnectionTimeout(int processId) + { + var connectionTimeout = EnvironmentHelper.GetConnectionTimeout(); - private int GetConnectionTimeout(int processId) + // Increase connection timeout when debugging is enabled. + var dataCollectorDebugEnabled = Environment.GetEnvironmentVariable(DebugEnvironmentVaribleName); + if (!string.IsNullOrEmpty(dataCollectorDebugEnabled) && + dataCollectorDebugEnabled.Equals("1", StringComparison.Ordinal)) { - var connectionTimeout = EnvironmentHelper.GetConnectionTimeout(); + ConsoleOutput.Instance.WriteLine(CrossPlatEngineResources.DataCollectorDebuggerWarning, OutputLevel.Warning); + ConsoleOutput.Instance.WriteLine( + string.Format("Process Id: {0}, Name: {1}", processId, _processHelper.GetProcessName(processId)), + OutputLevel.Information); // Increase connection timeout when debugging is enabled. - var dataCollectorDebugEnabled = Environment.GetEnvironmentVariable(DebugEnvironmentVaribleName); - if (!string.IsNullOrEmpty(dataCollectorDebugEnabled) && - dataCollectorDebugEnabled.Equals("1", StringComparison.Ordinal)) - { - ConsoleOutput.Instance.WriteLine(CrossPlatEngineResources.DataCollectorDebuggerWarning, OutputLevel.Warning); - ConsoleOutput.Instance.WriteLine( - string.Format("Process Id: {0}, Name: {1}", processId, this.processHelper.GetProcessName(processId)), - OutputLevel.Information); - - // Increase connection timeout when debugging is enabled. - connectionTimeout *= 5; - } - - return connectionTimeout; + connectionTimeout *= 5; } - private void InvokeDataCollectionServiceAction(Action action, ITestMessageEventHandler runEventsHandler) + return connectionTimeout; + } + + private void InvokeDataCollectionServiceAction(Action action, ITestMessageEventHandler runEventsHandler) + { + try { - try + if (EqtTrace.IsVerboseEnabled) { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("ProxyDataCollectionManager.InvokeDataCollectionServiceAction: Starting."); - } - - action(); - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("ProxyDataCollectionManager.InvokeDataCollectionServiceAction: Completed."); - } + EqtTrace.Verbose("ProxyDataCollectionManager.InvokeDataCollectionServiceAction: Starting."); } - catch (Exception ex) - { - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning("ProxyDataCollectionManager.InvokeDataCollectionServiceAction: TestPlatformException = {0}.", ex); - } - this.HandleExceptionMessage(runEventsHandler, ex); + action(); + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("ProxyDataCollectionManager.InvokeDataCollectionServiceAction: Completed."); } } - - private void HandleExceptionMessage(ITestMessageEventHandler runEventsHandler, Exception exception) + catch (Exception ex) { - if (EqtTrace.IsErrorEnabled) + if (EqtTrace.IsWarningEnabled) { - EqtTrace.Error(exception); + EqtTrace.Warning("ProxyDataCollectionManager.InvokeDataCollectionServiceAction: TestPlatformException = {0}.", ex); } - runEventsHandler.HandleLogMessage(ObjectModel.Logging.TestMessageLevel.Error, exception.ToString()); + HandleExceptionMessage(runEventsHandler, ex); } + } - private IList GetCommandLineArguments(int portNumber) + private void HandleExceptionMessage(ITestMessageEventHandler runEventsHandler, Exception exception) + { + if (EqtTrace.IsErrorEnabled) { - var commandlineArguments = new List(); + EqtTrace.Error(exception); + } - commandlineArguments.Add(PortOption); - commandlineArguments.Add(portNumber.ToString()); + runEventsHandler.HandleLogMessage(ObjectModel.Logging.TestMessageLevel.Error, exception.ToString()); + } - commandlineArguments.Add(ParentProcessIdOption); - commandlineArguments.Add(this.processHelper.GetCurrentProcessId().ToString()); + private IList GetCommandLineArguments(int portNumber) + { + var commandlineArguments = new List + { + PortOption, + portNumber.ToString(), - if (!string.IsNullOrEmpty(EqtTrace.LogFile)) - { - commandlineArguments.Add(DiagOption); - commandlineArguments.Add(this.GetTimestampedLogFile(EqtTrace.LogFile)); + ParentProcessIdOption, + _processHelper.GetCurrentProcessId().ToString() + }; - commandlineArguments.Add(TraceLevelOption); - commandlineArguments.Add(((int)EqtTrace.TraceLevel).ToString()); - } + if (!string.IsNullOrEmpty(EqtTrace.LogFile)) + { + commandlineArguments.Add(DiagOption); + commandlineArguments.Add(GetTimestampedLogFile(EqtTrace.LogFile)); - return commandlineArguments; + commandlineArguments.Add(TraceLevelOption); + commandlineArguments.Add(((int)EqtTrace.TraceLevel).ToString()); } - private string GetTimestampedLogFile(string logFile) - { - return Path.ChangeExtension( - logFile, - string.Format( - "datacollector.{0}_{1}{2}", - DateTime.Now.ToString("yy-MM-dd_HH-mm-ss_fffff"), - new PlatformEnvironment().GetCurrentManagedThreadId(), - Path.GetExtension(logFile))).AddDoubleQuote(); - } + return commandlineArguments; + } + + private string GetTimestampedLogFile(string logFile) + { + return Path.ChangeExtension( + logFile, + string.Format( + "datacollector.{0}_{1}{2}", + DateTime.Now.ToString("yy-MM-dd_HH-mm-ss_fffff"), + new PlatformEnvironment().GetCurrentManagedThreadId(), + Path.GetExtension(logFile))).AddDoubleQuote(); + } - /// - /// Update Extensions path folder in test adapters paths in runsettings. - /// - /// - private static string UpdateExtensionsFolderInRunSettings(string settingsXml) + /// + /// Update Extensions path folder in test adapters paths in runsettings. + /// + /// + private static string UpdateExtensionsFolderInRunSettings(string settingsXml) + { + if (string.IsNullOrWhiteSpace(settingsXml)) { - if (string.IsNullOrWhiteSpace(settingsXml)) - { - return settingsXml; - } + return settingsXml; + } - var extensionsFolder = Path.Combine(Path.GetDirectoryName(typeof(ITestPlatform).GetTypeInfo().Assembly.GetAssemblyLocation()), "Extensions"); + var extensionsFolder = Path.Combine(Path.GetDirectoryName(typeof(ITestPlatform).GetTypeInfo().Assembly.GetAssemblyLocation()), "Extensions"); - using (var stream = new StringReader(settingsXml)) - using (var reader = XmlReader.Create(stream, XmlRunSettingsUtilities.ReaderSettings)) - { - var document = new XmlDocument(); - document.Load(reader); + using var stream = new StringReader(settingsXml); + using var reader = XmlReader.Create(stream, XmlRunSettingsUtilities.ReaderSettings); + var document = new XmlDocument(); + document.Load(reader); - var tapNode = RunSettingsProviderExtensions.GetXmlNode(document, "RunConfiguration.TestAdaptersPaths"); + var tapNode = RunSettingsProviderExtensions.GetXmlNode(document, "RunConfiguration.TestAdaptersPaths"); - if (tapNode != null && !string.IsNullOrWhiteSpace(tapNode.InnerText)) - { - extensionsFolder = string.Concat(tapNode.InnerText, ';', extensionsFolder); - } + if (tapNode != null && !string.IsNullOrWhiteSpace(tapNode.InnerText)) + { + extensionsFolder = string.Concat(tapNode.InnerText, ';', extensionsFolder); + } - RunSettingsProviderExtensions.UpdateRunSettingsXmlDocument(document, "RunConfiguration.TestAdaptersPaths", extensionsFolder); + RunSettingsProviderExtensions.UpdateRunSettingsXmlDocument(document, "RunConfiguration.TestAdaptersPaths", extensionsFolder); - return document.OuterXml; - } - } + return document.OuterXml; + } - /// - /// Log Enabled Data Collectors - /// - private void LogEnabledDataCollectors() + /// + /// Log Enabled Data Collectors + /// + private void LogEnabledDataCollectors() + { + if (!_requestData.IsTelemetryOptedIn) { - if (!this.requestData.IsTelemetryOptedIn) - { - return; - } + return; + } - var dataCollectionSettings = XmlRunSettingsUtilities.GetDataCollectionRunSettings(this.SettingsXml); + var dataCollectionSettings = XmlRunSettingsUtilities.GetDataCollectionRunSettings(SettingsXml); - if (dataCollectionSettings == null || !dataCollectionSettings.IsCollectionEnabled) - { - return; - } + if (dataCollectionSettings == null || !dataCollectionSettings.IsCollectionEnabled) + { + return; + } - var enabledDataCollectors = new List(); - foreach (var settings in dataCollectionSettings.DataCollectorSettingsList) + var enabledDataCollectors = new List(); + foreach (var settings in dataCollectionSettings.DataCollectorSettingsList) + { + if (settings.IsEnabled) { - if (settings.IsEnabled) + if (enabledDataCollectors.Any(dcSettings => string.Equals(dcSettings.FriendlyName, settings.FriendlyName, StringComparison.OrdinalIgnoreCase))) { - if (enabledDataCollectors.Any(dcSettings => string.Equals(dcSettings.FriendlyName, settings.FriendlyName, StringComparison.OrdinalIgnoreCase))) - { - // If Uri or assembly qualified type name is repeated, consider data collector as duplicate and ignore it. - continue; - } - - enabledDataCollectors.Add(settings); + // If Uri or assembly qualified type name is repeated, consider data collector as duplicate and ignore it. + continue; } - } - var dataCollectors = enabledDataCollectors.Select(x => new { x.FriendlyName, x.Uri }.ToString()); - this.requestData.MetricsCollection.Add(TelemetryDataConstants.DataCollectorsEnabled, string.Join(",", dataCollectors.ToArray())); + enabledDataCollectors.Add(settings); + } } + + var dataCollectors = enabledDataCollectors.Select(x => new { x.FriendlyName, x.Uri }.ToString()); + _requestData.MetricsCollection.Add(TelemetryDataConstants.DataCollectorsEnabled, string.Join(",", dataCollectors.ToArray())); } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ProxyOutOfProcDataCollectionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ProxyOutOfProcDataCollectionManager.cs index b10e7193fe..0c8139edaa 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ProxyOutOfProcDataCollectionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ProxyOutOfProcDataCollectionManager.cs @@ -1,101 +1,98 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +/// +/// Sends test case events to communication layer. +/// +internal class ProxyOutOfProcDataCollectionManager { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; + private readonly IDataCollectionTestCaseEventSender _dataCollectionTestCaseEventSender; + private readonly ITestEventsPublisher _testEventsPublisher; + private readonly Dictionary> _attachmentsCache; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + /// + /// Sync object for ensuring that only run is active at a time + /// + private readonly object _syncObject = new(); /// - /// Sends test case events to communication layer. + /// Initializes a new instance of the class. /// - internal class ProxyOutOfProcDataCollectionManager + /// + /// The data collection test case event sender. + /// + /// + /// The data collection test case event manager. + /// + public ProxyOutOfProcDataCollectionManager(IDataCollectionTestCaseEventSender dataCollectionTestCaseEventSender, ITestEventsPublisher testEventsPublisher) { - private IDataCollectionTestCaseEventSender dataCollectionTestCaseEventSender; - private ITestEventsPublisher testEventsPublisher; - private Dictionary> attachmentsCache; - - /// - /// Sync object for ensuring that only run is active at a time - /// - private object syncObject = new object(); + _attachmentsCache = new Dictionary>(); + _testEventsPublisher = testEventsPublisher; + _dataCollectionTestCaseEventSender = dataCollectionTestCaseEventSender; - /// - /// Initializes a new instance of the class. - /// - /// - /// The data collection test case event sender. - /// - /// - /// The data collection test case event manager. - /// - public ProxyOutOfProcDataCollectionManager(IDataCollectionTestCaseEventSender dataCollectionTestCaseEventSender, ITestEventsPublisher testEventsPublisher) - { - this.attachmentsCache = new Dictionary>(); - this.testEventsPublisher = testEventsPublisher; - this.dataCollectionTestCaseEventSender = dataCollectionTestCaseEventSender; + _testEventsPublisher.TestCaseStart += TriggerTestCaseStart; + _testEventsPublisher.TestCaseEnd += TriggerTestCaseEnd; + _testEventsPublisher.TestResult += TriggerSendTestResult; + _testEventsPublisher.SessionEnd += TriggerTestSessionEnd; + _attachmentsCache = new Dictionary>(); + } - this.testEventsPublisher.TestCaseStart += this.TriggerTestCaseStart; - this.testEventsPublisher.TestCaseEnd += this.TriggerTestCaseEnd; - this.testEventsPublisher.TestResult += TriggerSendTestResult; - this.testEventsPublisher.SessionEnd += this.TriggerTestSessionEnd; - this.attachmentsCache = new Dictionary>(); - } + private void TriggerTestCaseStart(object sender, TestCaseStartEventArgs e) + { + _dataCollectionTestCaseEventSender.SendTestCaseStart(e); + } - private void TriggerTestCaseStart(object sender, TestCaseStartEventArgs e) - { - this.dataCollectionTestCaseEventSender.SendTestCaseStart(e); - } + private void TriggerTestCaseEnd(object sender, TestCaseEndEventArgs e) + { + var attachments = _dataCollectionTestCaseEventSender.SendTestCaseEnd(e); - private void TriggerTestCaseEnd(object sender, TestCaseEndEventArgs e) + if (attachments != null) { - var attachments = this.dataCollectionTestCaseEventSender.SendTestCaseEnd(e); - - if (attachments != null) + lock (_syncObject) { - lock (syncObject) + if (!_attachmentsCache.TryGetValue(e.TestCaseId, out Collection attachmentSets)) { - Collection attachmentSets; - if (!attachmentsCache.TryGetValue(e.TestCaseId, out attachmentSets)) - { - attachmentSets = new Collection(); - this.attachmentsCache.Add(e.TestCaseId, attachmentSets); - } + attachmentSets = new Collection(); + _attachmentsCache.Add(e.TestCaseId, attachmentSets); + } - foreach (var attachment in attachments) - { - attachmentSets.Add(attachment); - } + foreach (var attachment in attachments) + { + attachmentSets.Add(attachment); } } } + } - private void TriggerSendTestResult(object sender, TestResultEventArgs e) + private void TriggerSendTestResult(object sender, TestResultEventArgs e) + { + lock (_syncObject) { - lock (syncObject) + if (_attachmentsCache.TryGetValue(e.TestCaseId, out Collection attachmentSets)) { - Collection attachmentSets; - if (this.attachmentsCache.TryGetValue(e.TestCaseId, out attachmentSets)) + foreach (var attachment in attachmentSets) { - foreach (var attachment in attachmentSets) - { - e.TestResult.Attachments.Add(attachment); - } + e.TestResult.Attachments.Add(attachment); } - - this.attachmentsCache.Remove(e.TestCaseId); } - } - private void TriggerTestSessionEnd(object sender, SessionEndEventArgs e) - { - this.dataCollectionTestCaseEventSender.SendTestSessionEnd(e); + _attachmentsCache.Remove(e.TestCaseId); } } -} + + private void TriggerTestSessionEnd(object sender, SessionEndEventArgs e) + { + _dataCollectionTestCaseEventSender.SendTestSessionEnd(e); + } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs index f85f70fa65..99933e40de 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs @@ -1,339 +1,338 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Threading; + +using Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Common.Filtering; +using Common.Interfaces; +using Common.Logging; +using Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using CoreUtilities.Tracing; +using CoreUtilities.Tracing.Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Logging; +using PlatformAbstractions; + +using Utilities; + +using CrossPlatEngineResources = Resources.Resources; + +/// +/// Enumerates through all the discoverers. +/// +internal class DiscovererEnumerator { - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Reflection; - using System.Threading; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Filtering; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Utilities; - using CrossPlatEngineResources = Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources.Resources; + private readonly DiscoveryResultCache _discoveryResultCache; + private readonly ITestPlatformEventSource _testPlatformEventSource; + private readonly IRequestData _requestData; + private readonly IAssemblyProperties _assemblyProperties; + private readonly CancellationToken _cancellationToken; /// - /// Enumerates through all the discoverers. + /// Initializes a new instance of the class. /// - internal class DiscovererEnumerator + /// The request data for providing discovery services and data. + /// The discovery result cache. + public DiscovererEnumerator(IRequestData requestData, DiscoveryResultCache discoveryResultCache, CancellationToken token) + : this(requestData, discoveryResultCache, TestPlatformEventSource.Instance, token) { - private readonly DiscoveryResultCache discoveryResultCache; - private readonly ITestPlatformEventSource testPlatformEventSource; - private readonly IRequestData requestData; - private readonly IAssemblyProperties assemblyProperties; - private readonly CancellationToken cancellationToken; - - /// - /// Initializes a new instance of the class. - /// - /// The request data for providing discovery services and data. - /// The discovery result cache. - public DiscovererEnumerator(IRequestData requestData, DiscoveryResultCache discoveryResultCache, CancellationToken token) - : this(requestData, discoveryResultCache, TestPlatformEventSource.Instance, token) - { - } + } - /// - /// Initializes a new instance of the class. - /// - /// The request data for providing discovery services and data. - /// The discovery result cache. - /// Telemetry events receiver - /// Cancellation Token to abort discovery - public DiscovererEnumerator(IRequestData requestData, - DiscoveryResultCache discoveryResultCache, - ITestPlatformEventSource testPlatformEventSource, - CancellationToken token) - : this(requestData, discoveryResultCache, testPlatformEventSource, new AssemblyProperties(), token) - { - } + /// + /// Initializes a new instance of the class. + /// + /// The request data for providing discovery services and data. + /// The discovery result cache. + /// Telemetry events receiver + /// Cancellation Token to abort discovery + public DiscovererEnumerator(IRequestData requestData, + DiscoveryResultCache discoveryResultCache, + ITestPlatformEventSource testPlatformEventSource, + CancellationToken token) + : this(requestData, discoveryResultCache, testPlatformEventSource, new AssemblyProperties(), token) + { + } - /// - /// Initializes a new instance of the class. - /// - /// The request data for providing discovery services and data. - /// The discovery result cache. - /// Telemetry events receiver - /// Information on the assemblies being discovered - /// Cancellation Token to abort discovery - public DiscovererEnumerator(IRequestData requestData, - DiscoveryResultCache discoveryResultCache, - ITestPlatformEventSource testPlatformEventSource, - IAssemblyProperties assemblyProperties, - CancellationToken token) - { - // Added this to make class testable, needed a PEHeader mocked Instance - this.discoveryResultCache = discoveryResultCache; - this.testPlatformEventSource = testPlatformEventSource; - this.requestData = requestData; - this.assemblyProperties = assemblyProperties; - this.cancellationToken = token; - } + /// + /// Initializes a new instance of the class. + /// + /// The request data for providing discovery services and data. + /// The discovery result cache. + /// Telemetry events receiver + /// Information on the assemblies being discovered + /// Cancellation Token to abort discovery + public DiscovererEnumerator(IRequestData requestData, + DiscoveryResultCache discoveryResultCache, + ITestPlatformEventSource testPlatformEventSource, + IAssemblyProperties assemblyProperties, + CancellationToken token) + { + // Added this to make class testable, needed a PEHeader mocked Instance + _discoveryResultCache = discoveryResultCache; + _testPlatformEventSource = testPlatformEventSource; + _requestData = requestData; + _assemblyProperties = assemblyProperties; + _cancellationToken = token; + } - /// - /// Discovers tests from the sources. - /// - /// The test extension source map. - /// The settings. - /// The test case filter. - /// The logger. - public void LoadTests(IDictionary> testExtensionSourceMap, IRunSettings settings, string testCaseFilter, IMessageLogger logger) + /// + /// Discovers tests from the sources. + /// + /// The test extension source map. + /// The settings. + /// The test case filter. + /// The logger. + public void LoadTests(IDictionary> testExtensionSourceMap, IRunSettings settings, string testCaseFilter, IMessageLogger logger) + { + _testPlatformEventSource.DiscoveryStart(); + try { - this.testPlatformEventSource.DiscoveryStart(); - try + foreach (var kvp in testExtensionSourceMap) { - foreach (var kvp in testExtensionSourceMap) - { - this.LoadTestsFromAnExtension(kvp.Key, kvp.Value, settings, testCaseFilter, logger); - } - } - finally - { - this.testPlatformEventSource.DiscoveryStop(this.discoveryResultCache.TotalDiscoveredTests); + LoadTestsFromAnExtension(kvp.Key, kvp.Value, settings, testCaseFilter, logger); } } - - /// - /// Loads test cases from individual source. - /// Discovery extensions update progress through ITestCaseDiscoverySink. - /// Discovery extensions sends discovery messages through TestRunMessageLoggerProxy - /// - /// The extension Assembly. - /// The sources. - /// The settings. - /// The test case filter. - /// The logger. - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", - Justification = "This methods must invoke all possible discoverers and not fail or crash in any one.")] - private void LoadTestsFromAnExtension(string extensionAssembly, IEnumerable sources, IRunSettings settings, string testCaseFilter, IMessageLogger logger) + finally { - // Stopwatch to collect metrics - var timeStart = DateTime.UtcNow; + _testPlatformEventSource.DiscoveryStop(_discoveryResultCache.TotalDiscoveredTests); + } + } - var discovererToSourcesMap = GetDiscovererToSourcesMap(extensionAssembly, sources, logger, this.assemblyProperties); - var totalAdapterLoadTIme = DateTime.UtcNow - timeStart; + /// + /// Loads test cases from individual source. + /// Discovery extensions update progress through ITestCaseDiscoverySink. + /// Discovery extensions sends discovery messages through TestRunMessageLoggerProxy + /// + /// The extension Assembly. + /// The sources. + /// The settings. + /// The test case filter. + /// The logger. + private void LoadTestsFromAnExtension(string extensionAssembly, IEnumerable sources, IRunSettings settings, string testCaseFilter, IMessageLogger logger) + { + // Stopwatch to collect metrics + var timeStart = DateTime.UtcNow; - // Collecting Data Point for TimeTaken to Load Adapters - this.requestData.MetricsCollection.Add(TelemetryDataConstants.TimeTakenToLoadAdaptersInSec, totalAdapterLoadTIme.TotalSeconds); + var discovererToSourcesMap = GetDiscovererToSourcesMap(extensionAssembly, sources, logger, _assemblyProperties); + var totalAdapterLoadTIme = DateTime.UtcNow - timeStart; - // Warning is logged for in the inner function - if (discovererToSourcesMap == null || !discovererToSourcesMap.Any()) - { - return; - } + // Collecting Data Point for TimeTaken to Load Adapters + _requestData.MetricsCollection.Add(TelemetryDataConstants.TimeTakenToLoadAdaptersInSec, totalAdapterLoadTIme.TotalSeconds); - double totalTimeTakenByAdapters = 0; - double totalAdaptersUsed = 0; - try - { - // Collecting Total Number of Adapters Discovered in Machine - this.requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringDiscovery, discovererToSourcesMap.Keys.Count); + // Warning is logged for in the inner function + if (discovererToSourcesMap == null || !discovererToSourcesMap.Any()) + { + return; + } - var context = new DiscoveryContext { RunSettings = settings }; - context.FilterExpressionWrapper = !string.IsNullOrEmpty(testCaseFilter) ? new FilterExpressionWrapper(testCaseFilter) : null; + double totalTimeTakenByAdapters = 0; + double totalAdaptersUsed = 0; + try + { + // Collecting Total Number of Adapters Discovered in Machine + _requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringDiscovery, discovererToSourcesMap.Keys.Count); - // Set on the logger the TreatAdapterErrorAsWarning setting from runsettings. - this.SetAdapterLoggingSettings(logger, settings); + var context = new DiscoveryContext { RunSettings = settings }; + context.FilterExpressionWrapper = !string.IsNullOrEmpty(testCaseFilter) ? new FilterExpressionWrapper(testCaseFilter) : null; - var discoverySink = new TestCaseDiscoverySink(this.discoveryResultCache); - foreach (var discoverer in discovererToSourcesMap.Keys) - { - if (this.cancellationToken.IsCancellationRequested) - { - EqtTrace.Info("DiscovererEnumerator.LoadTestsFromAnExtension: Cancellation Requested. Aborting the discovery"); - LogTestsDiscoveryCancellation(logger); - return; - } - - this.DiscoverTestsFromSingleDiscoverer(discoverer, discovererToSourcesMap, context, discoverySink, logger, ref totalAdaptersUsed, ref totalTimeTakenByAdapters); - } + // Set on the logger the TreatAdapterErrorAsWarning setting from runsettings. + SetAdapterLoggingSettings(logger, settings); - if (this.discoveryResultCache.TotalDiscoveredTests == 0) + var discoverySink = new TestCaseDiscoverySink(_discoveryResultCache); + foreach (var discoverer in discovererToSourcesMap.Keys) + { + if (_cancellationToken.IsCancellationRequested) { - LogWarningOnNoTestsDiscovered(sources, testCaseFilter, logger); + EqtTrace.Info("DiscovererEnumerator.LoadTestsFromAnExtension: Cancellation Requested. Aborting the discovery"); + LogTestsDiscoveryCancellation(logger); + return; } + + DiscoverTestsFromSingleDiscoverer(discoverer, discovererToSourcesMap, context, discoverySink, logger, ref totalAdaptersUsed, ref totalTimeTakenByAdapters); } - finally + + if (_discoveryResultCache.TotalDiscoveredTests == 0) { - this.CollectTelemetryAtEnd(totalTimeTakenByAdapters, totalAdaptersUsed); + LogWarningOnNoTestsDiscovered(sources, testCaseFilter, logger); } } - - private void LogTestsDiscoveryCancellation(IMessageLogger logger) + finally { - logger.SendMessage(TestMessageLevel.Warning, CrossPlatEngineResources.TestDiscoveryCancelled); + CollectTelemetryAtEnd(totalTimeTakenByAdapters, totalAdaptersUsed); } + } - private void CollectTelemetryAtEnd(double totalTimeTakenByAdapters, double totalAdaptersUsed) - { - // Collecting Total Time Taken by Adapters - this.requestData.MetricsCollection.Add(TelemetryDataConstants.TimeTakenInSecByAllAdapters, - totalTimeTakenByAdapters); + private void LogTestsDiscoveryCancellation(IMessageLogger logger) + { + logger.SendMessage(TestMessageLevel.Warning, CrossPlatEngineResources.TestDiscoveryCancelled); + } - // Collecting Total Adapters Used to Discover tests - this.requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfAdapterUsedToDiscoverTests, - totalAdaptersUsed); + private void CollectTelemetryAtEnd(double totalTimeTakenByAdapters, double totalAdaptersUsed) + { + // Collecting Total Time Taken by Adapters + _requestData.MetricsCollection.Add(TelemetryDataConstants.TimeTakenInSecByAllAdapters, + totalTimeTakenByAdapters); + + // Collecting Total Adapters Used to Discover tests + _requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfAdapterUsedToDiscoverTests, + totalAdaptersUsed); + } + + private void DiscoverTestsFromSingleDiscoverer( + LazyExtension discoverer, + Dictionary, IEnumerable> discovererToSourcesMap, + DiscoveryContext context, + TestCaseDiscoverySink discoverySink, + IMessageLogger logger, + ref double totalAdaptersUsed, + ref double totalTimeTakenByAdapters) + { + if (!TryToLoadDiscoverer(discoverer, logger, out var discovererType)) + { + // Fail to instantiate the discoverer type. + return; } - private void DiscoverTestsFromSingleDiscoverer( - LazyExtension discoverer, - Dictionary, IEnumerable> discovererToSourcesMap, - DiscoveryContext context, - TestCaseDiscoverySink discoverySink, - IMessageLogger logger, - ref double totalAdaptersUsed, - ref double totalTimeTakenByAdapters) + // on instantiated successfully, get tests + try { - if (!DiscovererEnumerator.TryToLoadDiscoverer(discoverer, logger, out var discovererType)) - { - // Fail to instantiate the discoverer type. - return; - } + EqtTrace.Verbose( + "DiscovererEnumerator.DiscoverTestsFromSingleDiscoverer: Loading tests for {0}", + discoverer.Value.GetType().FullName); - // on instantiated successfully, get tests - try + if (discoverer.Metadata.DefaultExecutorUri == null) { - EqtTrace.Verbose( - "DiscovererEnumerator.DiscoverTestsFromSingleDiscoverer: Loading tests for {0}", - discoverer.Value.GetType().FullName); - - if (discoverer.Metadata.DefaultExecutorUri == null) - { - throw new Exception($@"DefaultExecutorUri is null, did you decorate the discoverer class with [DefaultExecutorUri()] attribute? For example [DefaultExecutorUri(""executor://example.testadapter"")]."); - } - - var currentTotalTests = this.discoveryResultCache.TotalDiscoveredTests; - var newTimeStart = DateTime.UtcNow; + throw new Exception($@"DefaultExecutorUri is null, did you decorate the discoverer class with [DefaultExecutorUri()] attribute? For example [DefaultExecutorUri(""executor://example.testadapter"")]."); + } - this.testPlatformEventSource.AdapterDiscoveryStart(discoverer.Metadata.DefaultExecutorUri.AbsoluteUri); - discoverer.Value.DiscoverTests(discovererToSourcesMap[discoverer], context, logger, discoverySink); + var currentTotalTests = _discoveryResultCache.TotalDiscoveredTests; + var newTimeStart = DateTime.UtcNow; - var totalAdapterRunTime = DateTime.UtcNow - newTimeStart; + _testPlatformEventSource.AdapterDiscoveryStart(discoverer.Metadata.DefaultExecutorUri.AbsoluteUri); + discoverer.Value.DiscoverTests(discovererToSourcesMap[discoverer], context, logger, discoverySink); - this.testPlatformEventSource.AdapterDiscoveryStop(this.discoveryResultCache.TotalDiscoveredTests - - currentTotalTests); + var totalAdapterRunTime = DateTime.UtcNow - newTimeStart; - // Record Total Tests Discovered By each Discoverer. - var totalTestsDiscoveredByCurrentDiscoverer = this.discoveryResultCache.TotalDiscoveredTests - currentTotalTests; - this.requestData.MetricsCollection.Add( - string.Format("{0}.{1}", TelemetryDataConstants.TotalTestsByAdapter, - discoverer.Metadata.DefaultExecutorUri), totalTestsDiscoveredByCurrentDiscoverer); + _testPlatformEventSource.AdapterDiscoveryStop(_discoveryResultCache.TotalDiscoveredTests - + currentTotalTests); - totalAdaptersUsed++; + // Record Total Tests Discovered By each Discoverer. + var totalTestsDiscoveredByCurrentDiscoverer = _discoveryResultCache.TotalDiscoveredTests - currentTotalTests; + _requestData.MetricsCollection.Add( + string.Format("{0}.{1}", TelemetryDataConstants.TotalTestsByAdapter, + discoverer.Metadata.DefaultExecutorUri), totalTestsDiscoveredByCurrentDiscoverer); - EqtTrace.Verbose("DiscovererEnumerator.DiscoverTestsFromSingleDiscoverer: Done loading tests for {0}", - discoverer.Value.GetType().FullName); + totalAdaptersUsed++; - var discovererFromDeprecatedLocations = IsDiscovererFromDeprecatedLocations(discoverer); - if (discovererFromDeprecatedLocations) - { - logger.SendMessage(TestMessageLevel.Warning, - string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.DeprecatedAdapterPath)); - } + EqtTrace.Verbose("DiscovererEnumerator.DiscoverTestsFromSingleDiscoverer: Done loading tests for {0}", + discoverer.Value.GetType().FullName); - // Collecting Data Point for Time Taken to Discover Tests by each Adapter - this.requestData.MetricsCollection.Add( - string.Format("{0}.{1}", TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter, - discoverer.Metadata.DefaultExecutorUri), totalAdapterRunTime.TotalSeconds); - totalTimeTakenByAdapters += totalAdapterRunTime.TotalSeconds; - } - catch (Exception e) + var discovererFromDeprecatedLocations = IsDiscovererFromDeprecatedLocations(discoverer); + if (discovererFromDeprecatedLocations) { - var message = string.Format( - CultureInfo.CurrentUICulture, - CrossPlatEngineResources.ExceptionFromLoadTests, - discovererType.Name, - e.Message); - - logger.SendMessage(TestMessageLevel.Error, message); - EqtTrace.Error("DiscovererEnumerator.DiscoverTestsFromSingleDiscoverer: {0} ", e); + logger.SendMessage(TestMessageLevel.Warning, + string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.DeprecatedAdapterPath)); } - } - private static bool TryToLoadDiscoverer(LazyExtension discoverer, IMessageLogger logger, out Type discovererType) + // Collecting Data Point for Time Taken to Discover Tests by each Adapter + _requestData.MetricsCollection.Add( + string.Format("{0}.{1}", TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter, + discoverer.Metadata.DefaultExecutorUri), totalAdapterRunTime.TotalSeconds); + totalTimeTakenByAdapters += totalAdapterRunTime.TotalSeconds; + } + catch (Exception e) { - discovererType = null; - - // See if discoverer can be instantiated successfully else move next. - try - { - discovererType = discoverer.Value.GetType(); - } - catch (Exception e) - { - var mesage = string.Format( - CultureInfo.CurrentUICulture, - CrossPlatEngineResources.DiscovererInstantiationException, - e.Message); - logger.SendMessage(TestMessageLevel.Warning, mesage); - EqtTrace.Error("DiscovererEnumerator.LoadTestsFromAnExtension: {0} ", e); + var message = string.Format( + CultureInfo.CurrentUICulture, + CrossPlatEngineResources.ExceptionFromLoadTests, + discovererType.Name, + e.Message); + + logger.SendMessage(TestMessageLevel.Error, message); + EqtTrace.Error("DiscovererEnumerator.DiscoverTestsFromSingleDiscoverer: {0} ", e); + } + } - return false; - } + private static bool TryToLoadDiscoverer(LazyExtension discoverer, IMessageLogger logger, out Type discovererType) + { + discovererType = null; - return true; + // See if discoverer can be instantiated successfully else move next. + try + { + discovererType = discoverer.Value.GetType(); } - - private static bool IsDiscovererFromDeprecatedLocations( - LazyExtension discoverer) + catch (Exception e) { - if (CrossPlatEngine.Constants.DefaultAdapters.Contains(discoverer.Metadata.DefaultExecutorUri.ToString(), - StringComparer.OrdinalIgnoreCase)) - { - return false; - } + var mesage = string.Format( + CultureInfo.CurrentUICulture, + CrossPlatEngineResources.DiscovererInstantiationException, + e.Message); + logger.SendMessage(TestMessageLevel.Warning, mesage); + EqtTrace.Error("DiscovererEnumerator.LoadTestsFromAnExtension: {0} ", e); + + return false; + } - var discovererLocation = discoverer.Value.GetType().GetTypeInfo().Assembly.GetAssemblyLocation(); + return true; + } - return Path.GetDirectoryName(discovererLocation) - .Equals(CrossPlatEngine.Constants.DefaultAdapterLocation, StringComparison.OrdinalIgnoreCase); + private static bool IsDiscovererFromDeprecatedLocations( + LazyExtension discoverer) + { + if (CrossPlatEngine.Constants.DefaultAdapters.Contains(discoverer.Metadata.DefaultExecutorUri.ToString(), + StringComparer.OrdinalIgnoreCase)) + { + return false; } - private static void LogWarningOnNoTestsDiscovered(IEnumerable sources, string testCaseFilter, IMessageLogger logger) - { - var sourcesString = string.Join(" ", sources); + var discovererLocation = discoverer.Value.GetType().GetTypeInfo().Assembly.GetAssemblyLocation(); - // Print warning on no tests. - if (!string.IsNullOrEmpty(testCaseFilter)) - { - var testCaseFilterToShow = TestCaseFilterDeterminer.ShortenTestCaseFilterIfRequired(testCaseFilter); + return Path.GetDirectoryName(discovererLocation) + .Equals(CrossPlatEngine.Constants.DefaultAdapterLocation, StringComparison.OrdinalIgnoreCase); + } - logger.SendMessage( - TestMessageLevel.Warning, - string.Format(CrossPlatEngineResources.NoTestsAvailableForGivenTestCaseFilter, testCaseFilterToShow, sourcesString)); - } - else - { - logger.SendMessage( - TestMessageLevel.Warning, - string.Format( - CultureInfo.CurrentUICulture, - CrossPlatEngineResources.TestRunFailed_NoDiscovererFound_NoTestsAreAvailableInTheSources, - sourcesString)); - } + private static void LogWarningOnNoTestsDiscovered(IEnumerable sources, string testCaseFilter, IMessageLogger logger) + { + var sourcesString = string.Join(" ", sources); + + // Print warning on no tests. + if (!string.IsNullOrEmpty(testCaseFilter)) + { + var testCaseFilterToShow = TestCaseFilterDeterminer.ShortenTestCaseFilterIfRequired(testCaseFilter); + + logger.SendMessage( + TestMessageLevel.Warning, + string.Format(CrossPlatEngineResources.NoTestsAvailableForGivenTestCaseFilter, testCaseFilterToShow, sourcesString)); + } + else + { + logger.SendMessage( + TestMessageLevel.Warning, + string.Format( + CultureInfo.CurrentUICulture, + CrossPlatEngineResources.TestRunFailed_NoDiscovererFound_NoTestsAreAvailableInTheSources, + sourcesString)); } + } - private void SetAdapterLoggingSettings(IMessageLogger messageLogger, IRunSettings runSettings) + private void SetAdapterLoggingSettings(IMessageLogger messageLogger, IRunSettings runSettings) + { + if (messageLogger is TestSessionMessageLogger discoveryMessageLogger && runSettings != null) { - var discoveryMessageLogger = messageLogger as TestSessionMessageLogger; - if (discoveryMessageLogger != null && runSettings != null) - { #if Todo // TODO : Enable this when RunSettings is enabled. IRunConfigurationSettingsProvider runConfigurationSettingsProvider = @@ -345,156 +344,152 @@ private void SetAdapterLoggingSettings(IMessageLogger messageLogger, IRunSetting = runConfigurationSettingsProvider.Settings.TreatTestAdapterErrorsAsWarnings; } #endif - } } + } - /// - /// Get the discoverers matching with the parameter sources - /// - /// The extension assembly. - /// The sources. - /// The logger instance. - /// The map between an extension type and a source. - internal static Dictionary, IEnumerable> GetDiscovererToSourcesMap( - string extensionAssembly, - IEnumerable sources, - IMessageLogger logger, - IAssemblyProperties assemblyProperties) + /// + /// Get the discoverers matching with the parameter sources + /// + /// The extension assembly. + /// The sources. + /// The logger instance. + /// The map between an extension type and a source. + internal static Dictionary, IEnumerable> GetDiscovererToSourcesMap( + string extensionAssembly, + IEnumerable sources, + IMessageLogger logger, + IAssemblyProperties assemblyProperties) + { + var allDiscoverers = GetDiscoverers(extensionAssembly, throwOnError: true); + + if (allDiscoverers == null || !allDiscoverers.Any()) { - var allDiscoverers = GetDiscoverers(extensionAssembly, throwOnError: true); + var sourcesString = string.Join(" ", sources); + // No discoverer available, log a warning + logger.SendMessage( + TestMessageLevel.Warning, + string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.TestRunFailed_NoDiscovererFound_NoTestsAreAvailableInTheSources, sourcesString)); - if (allDiscoverers == null || !allDiscoverers.Any()) - { - var sourcesString = string.Join(" ", sources); - // No discoverer available, log a warning - logger.SendMessage( - TestMessageLevel.Warning, - string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.TestRunFailed_NoDiscovererFound_NoTestsAreAvailableInTheSources, sourcesString)); + return null; + } - return null; - } + IDictionary> assemblyTypeToSoucesMap = null; + var result = new Dictionary, IEnumerable>(); + var sourcesForWhichNoDiscovererIsAvailable = new List(sources); - IDictionary> assemblyTypeToSoucesMap = null; - var result = new Dictionary, IEnumerable>(); - var sourcesForWhichNoDiscovererIsAvailable = new List(sources); + foreach (var discoverer in allDiscoverers) + { + var sourcesToCheck = sources; - foreach (var discoverer in allDiscoverers) + if (discoverer.Metadata.AssemblyType == AssemblyType.Native || + discoverer.Metadata.AssemblyType == AssemblyType.Managed) { - var sourcesToCheck = sources; - - if (discoverer.Metadata.AssemblyType == AssemblyType.Native || - discoverer.Metadata.AssemblyType == AssemblyType.Managed) - { - assemblyTypeToSoucesMap = assemblyTypeToSoucesMap ?? GetAssemblyTypeToSoucesMap(sources, assemblyProperties); - sourcesToCheck = assemblyTypeToSoucesMap[AssemblyType.None].Concat(assemblyTypeToSoucesMap[discoverer.Metadata.AssemblyType]); - } - - // Find the sources which this discoverer can look at. - // Based on whether it is registered for a matching file extension or no file extensions at all. - var matchingSources = (from source in sourcesToCheck - where - (discoverer.Metadata.FileExtension == null - || discoverer.Metadata.FileExtension.Contains( - Path.GetExtension(source), - StringComparer.OrdinalIgnoreCase)) - select source).ToList(); // ToList is required to actually execute the query - - // Update the source list for which no matching source is available. - if (matchingSources.Any()) - { - sourcesForWhichNoDiscovererIsAvailable = - sourcesForWhichNoDiscovererIsAvailable.Except(matchingSources, StringComparer.OrdinalIgnoreCase) - .ToList(); - result.Add(discoverer, matchingSources); - } + assemblyTypeToSoucesMap ??= GetAssemblyTypeToSoucesMap(sources, assemblyProperties); + sourcesToCheck = assemblyTypeToSoucesMap[AssemblyType.None].Concat(assemblyTypeToSoucesMap[discoverer.Metadata.AssemblyType]); } - if (EqtTrace.IsWarningEnabled && sourcesForWhichNoDiscovererIsAvailable != null) + // Find the sources which this discoverer can look at. + // Based on whether it is registered for a matching file extension or no file extensions at all. + var matchingSources = (from source in sourcesToCheck + where + (discoverer.Metadata.FileExtension == null + || discoverer.Metadata.FileExtension.Contains( + Path.GetExtension(source), + StringComparer.OrdinalIgnoreCase)) + select source).ToList(); // ToList is required to actually execute the query + + // Update the source list for which no matching source is available. + if (matchingSources.Any()) { - foreach (var source in sourcesForWhichNoDiscovererIsAvailable) - { - // Log a warning to log file, not to the "default logger for discovery time messages". - EqtTrace.Warning( - "No test discoverer is registered to perform discovery for the type of test source '{0}'. Register a test discoverer for this source type and try again.", - source); - } + sourcesForWhichNoDiscovererIsAvailable = + sourcesForWhichNoDiscovererIsAvailable.Except(matchingSources, StringComparer.OrdinalIgnoreCase) + .ToList(); + result.Add(discoverer, matchingSources); } - - return result; } - /// - /// Get assembly type to sources map. - /// - /// Sources. - /// Assembly type. - /// Sources with matching assembly type. - private static IDictionary> GetAssemblyTypeToSoucesMap(IEnumerable sources, IAssemblyProperties assemblyProperties) + if (EqtTrace.IsWarningEnabled && sourcesForWhichNoDiscovererIsAvailable != null) { - var assemblyTypeToSoucesMap = new Dictionary>() + foreach (var source in sourcesForWhichNoDiscovererIsAvailable) { - { AssemblyType.Native, new List()}, - { AssemblyType.Managed, new List()}, - { AssemblyType.None, new List()} - }; + // Log a warning to log file, not to the "default logger for discovery time messages". + EqtTrace.Warning( + "No test discoverer is registered to perform discovery for the type of test source '{0}'. Register a test discoverer for this source type and try again.", + source); + } + } + + return result; + } + + /// + /// Get assembly type to sources map. + /// + /// Sources. + /// Assembly type. + /// Sources with matching assembly type. + private static IDictionary> GetAssemblyTypeToSoucesMap(IEnumerable sources, IAssemblyProperties assemblyProperties) + { + var assemblyTypeToSoucesMap = new Dictionary>() + { + { AssemblyType.Native, new List()}, + { AssemblyType.Managed, new List()}, + { AssemblyType.None, new List()} + }; - if (sources != null && sources.Any()) + if (sources != null && sources.Any()) + { + foreach (string source in sources) { - foreach (string source in sources) - { - var sourcesList = IsAssembly(source) ? - assemblyTypeToSoucesMap[assemblyProperties.GetAssemblyType(source)] : - assemblyTypeToSoucesMap[AssemblyType.None]; + var sourcesList = IsAssembly(source) ? + assemblyTypeToSoucesMap[assemblyProperties.GetAssemblyType(source)] : + assemblyTypeToSoucesMap[AssemblyType.None]; - sourcesList.Add(source); - } + sourcesList.Add(source); } - - return assemblyTypeToSoucesMap; } - /// - /// Finds if a file is an assembly or not. - /// - /// File path. - /// True if file is an assembly. - private static bool IsAssembly(string filePath) - { - var fileExtension = Path.GetExtension(filePath); + return assemblyTypeToSoucesMap; + } - return ".dll".Equals(fileExtension, StringComparison.OrdinalIgnoreCase) || - ".exe".Equals(fileExtension, StringComparison.OrdinalIgnoreCase); - } + /// + /// Finds if a file is an assembly or not. + /// + /// File path. + /// True if file is an assembly. + private static bool IsAssembly(string filePath) + { + var fileExtension = Path.GetExtension(filePath); + + return ".dll".Equals(fileExtension, StringComparison.OrdinalIgnoreCase) || + ".exe".Equals(fileExtension, StringComparison.OrdinalIgnoreCase); + } - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - [SuppressMessage("Microsoft.Design", - "CA1006:DoNotNestGenericTypesInMemberSignatures")] - private static IEnumerable> GetDiscoverers( - string extensionAssembly, - bool throwOnError) + private static IEnumerable> GetDiscoverers( + string extensionAssembly, + bool throwOnError) + { + try { - try + if (string.IsNullOrEmpty(extensionAssembly) || string.Equals(extensionAssembly, Constants.UnspecifiedAdapterPath)) { - if (string.IsNullOrEmpty(extensionAssembly) || string.Equals(extensionAssembly, Constants.UnspecifiedAdapterPath)) - { - // full discovery. - return TestDiscoveryExtensionManager.Create().Discoverers; - } - else - { - return TestDiscoveryExtensionManager.GetDiscoveryExtensionManager(extensionAssembly).Discoverers; - } + // full discovery. + return TestDiscoveryExtensionManager.Create().Discoverers; } - catch (Exception ex) + else { - EqtTrace.Error($"TestDiscoveryManager: LoadExtensions: Exception occurred while loading extensions {ex}"); - if (throwOnError) - { - throw; - } - - return null; + return TestDiscoveryExtensionManager.GetDiscoveryExtensionManager(extensionAssembly).Discoverers; } } + catch (Exception ex) + { + EqtTrace.Error($"TestDiscoveryManager: LoadExtensions: Exception occurred while loading extensions {ex}"); + if (throwOnError) + { + throw; + } + + return null; + } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryContext.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryContext.cs index 4f6e53d421..50b088453f 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryContext.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryContext.cs @@ -1,66 +1,65 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery -{ - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Linq; +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; - using Microsoft.VisualStudio.TestPlatform.Common.Filtering; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using Common.Filtering; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using CrossPlatEngineResources = Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources.Resources; +using CrossPlatEngineResources = Resources.Resources; +/// +/// Specifies the user specified RunSettings and framework provided context of the discovery. +/// +public class DiscoveryContext : IDiscoveryContext +{ /// - /// Specifies the user specified RunSettings and framework provided context of the discovery. + /// Gets the run settings specified for this request. /// - public class DiscoveryContext : IDiscoveryContext - { - /// - /// Gets the run settings specified for this request. - /// - public IRunSettings RunSettings { get; internal set; } + public IRunSettings RunSettings { get; internal set; } - /// - /// Returns TestCaseFilterExpression validated for supportedProperties. - /// If there is a parsing error in filter expression, TestPlatformFormatException() is thrown. - /// - /// The supported Properties. - /// The property Provider. - /// The . - public ITestCaseFilterExpression GetTestCaseFilter(IEnumerable supportedProperties, Func propertyProvider) + /// + /// Returns TestCaseFilterExpression validated for supportedProperties. + /// If there is a parsing error in filter expression, TestPlatformFormatException() is thrown. + /// + /// The supported Properties. + /// The property Provider. + /// The . + public ITestCaseFilterExpression GetTestCaseFilter(IEnumerable supportedProperties, Func propertyProvider) + { + TestCaseFilterExpression adapterSpecificTestCaseFilter = null; + if (FilterExpressionWrapper != null) { - TestCaseFilterExpression adapterSpecificTestCaseFilter = null; - if (this.FilterExpressionWrapper != null) + if (!string.IsNullOrEmpty(FilterExpressionWrapper.ParseError)) { - if (!string.IsNullOrEmpty(this.FilterExpressionWrapper.ParseError)) - { - throw new TestPlatformFormatException(this.FilterExpressionWrapper.ParseError, this.FilterExpressionWrapper.FilterString); - } + throw new TestPlatformFormatException(FilterExpressionWrapper.ParseError, FilterExpressionWrapper.FilterString); + } - adapterSpecificTestCaseFilter = new TestCaseFilterExpression(this.FilterExpressionWrapper); - var invalidProperties = adapterSpecificTestCaseFilter.ValidForProperties(supportedProperties, propertyProvider); + adapterSpecificTestCaseFilter = new TestCaseFilterExpression(FilterExpressionWrapper); + var invalidProperties = adapterSpecificTestCaseFilter.ValidForProperties(supportedProperties, propertyProvider); - if (invalidProperties != null) - { - var invalidPropertiesString = string.Join(CrossPlatEngineResources.StringSeperator, invalidProperties); - var validPropertiesSttring = supportedProperties == null ? string.Empty : string.Join(CrossPlatEngineResources.StringSeperator, supportedProperties.ToArray()); - var errorMessage = string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.UnsupportedPropertiesInTestCaseFilter, invalidPropertiesString, validPropertiesSttring); + if (invalidProperties != null) + { + var invalidPropertiesString = string.Join(CrossPlatEngineResources.StringSeperator, invalidProperties); + var validPropertiesSttring = supportedProperties == null ? string.Empty : string.Join(CrossPlatEngineResources.StringSeperator, supportedProperties.ToArray()); + var errorMessage = string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.UnsupportedPropertiesInTestCaseFilter, invalidPropertiesString, validPropertiesSttring); - // For unsupported property dont throw exception, just log the message. Later it is going to handle properly with TestCaseFilterExpression.MatchTestCase(). - EqtTrace.Info(errorMessage); - } + // For unsupported property dont throw exception, just log the message. Later it is going to handle properly with TestCaseFilterExpression.MatchTestCase(). + EqtTrace.Info(errorMessage); } - - return adapterSpecificTestCaseFilter; } - /// - /// Gets or sets the FilterExpressionWrapper instance as created from filter string. - /// - internal FilterExpressionWrapper FilterExpressionWrapper {get; set; } + return adapterSpecificTestCaseFilter; } -} + + /// + /// Gets or sets the FilterExpressionWrapper instance as created from filter string. + /// + internal FilterExpressionWrapper FilterExpressionWrapper { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs index f2751c18e5..e0bd30e994 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryManager.cs @@ -1,297 +1,297 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Threading; + +using Common.ExtensionFramework; +using Common.Logging; +using Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using CoreUtilities.Tracing; +using CoreUtilities.Tracing.Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine.TesthostProtocol; +using ObjectModel.Logging; + +using CrossPlatEngineResources = Resources.Resources; + +/// +/// Orchestrates discovery operations for the engine communicating with the test host process. +/// +public class DiscoveryManager : IDiscoveryManager { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Threading; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - - using CrossPlatEngineResources = Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources.Resources; + private readonly TestSessionMessageLogger _sessionMessageLogger; + private readonly ITestPlatformEventSource _testPlatformEventSource; + private readonly IRequestData _requestData; + private ITestDiscoveryEventsHandler2 _testDiscoveryEventsHandler; + private DiscoveryCriteria _discoveryCriteria; + private readonly CancellationTokenSource _cancellationTokenSource = new(); /// - /// Orchestrates discovery operations for the engine communicating with the test host process. + /// Initializes a new instance of the class. /// - public class DiscoveryManager : IDiscoveryManager + public DiscoveryManager(IRequestData requestData) : this(requestData, TestPlatformEventSource.Instance) { - private readonly TestSessionMessageLogger sessionMessageLogger; - private readonly ITestPlatformEventSource testPlatformEventSource; - private readonly IRequestData requestData; - private ITestDiscoveryEventsHandler2 testDiscoveryEventsHandler; - private DiscoveryCriteria discoveryCriteria; - private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); - - /// - /// Initializes a new instance of the class. - /// - public DiscoveryManager(IRequestData requestData) : this(requestData, TestPlatformEventSource.Instance) - { - } + } - /// - /// Initializes a new instance of the class. - /// - /// - /// The Request Data for providing discovery services and data. - /// - /// - /// The test platform event source. - /// - protected DiscoveryManager(IRequestData requestData, ITestPlatformEventSource testPlatformEventSource) + /// + /// Initializes a new instance of the class. + /// + /// + /// The Request Data for providing discovery services and data. + /// + /// + /// The test platform event source. + /// + protected DiscoveryManager(IRequestData requestData, ITestPlatformEventSource testPlatformEventSource) + { + _sessionMessageLogger = TestSessionMessageLogger.Instance; + _sessionMessageLogger.TestRunMessage += TestSessionMessageHandler; + _testPlatformEventSource = testPlatformEventSource; + _requestData = requestData; + } + + /// + /// Initializes the discovery manager. + /// + /// The path to additional extensions. + public void Initialize(IEnumerable pathToAdditionalExtensions, ITestDiscoveryEventsHandler2 eventHandler) + { + _testPlatformEventSource.AdapterSearchStart(); + _testDiscoveryEventsHandler = eventHandler; + if (pathToAdditionalExtensions != null && pathToAdditionalExtensions.Any()) { - this.sessionMessageLogger = TestSessionMessageLogger.Instance; - this.sessionMessageLogger.TestRunMessage += this.TestSessionMessageHandler; - this.testPlatformEventSource = testPlatformEventSource; - this.requestData = requestData; + // Start using these additional extensions + TestPluginCache.Instance.DefaultExtensionPaths = pathToAdditionalExtensions; } - /// - /// Initializes the discovery manager. - /// - /// The path to additional extensions. - public void Initialize(IEnumerable pathToAdditionalExtensions, ITestDiscoveryEventsHandler2 eventHandler) - { - this.testPlatformEventSource.AdapterSearchStart(); - this.testDiscoveryEventsHandler = eventHandler; - if (pathToAdditionalExtensions != null && pathToAdditionalExtensions.Any()) - { - // Start using these additional extensions - TestPluginCache.Instance.DefaultExtensionPaths = pathToAdditionalExtensions; - } + // Load and Initialize extensions. + TestDiscoveryExtensionManager.LoadAndInitializeAllExtensions(false); + _testPlatformEventSource.AdapterSearchStop(); + } - // Load and Initialize extensions. - TestDiscoveryExtensionManager.LoadAndInitializeAllExtensions(false); - this.testPlatformEventSource.AdapterSearchStop(); - } + /// + /// Discovers tests + /// + /// Settings, parameters for the discovery request + /// EventHandler for handling discovery events from Engine + public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler) + { + var discoveryResultCache = new DiscoveryResultCache( + discoveryCriteria.FrequencyOfDiscoveredTestsEvent, + discoveryCriteria.DiscoveredTestEventTimeout, + OnReportTestCases); - /// - /// Discovers tests - /// - /// Settings, parameters for the discovery request - /// EventHandler for handling discovery events from Engine - public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler) + try { - var discoveryResultCache = new DiscoveryResultCache( - discoveryCriteria.FrequencyOfDiscoveredTestsEvent, - discoveryCriteria.DiscoveredTestEventTimeout, - this.OnReportTestCases); + _discoveryCriteria = discoveryCriteria; + EqtTrace.Info("TestDiscoveryManager.DoDiscovery: Background test discovery started."); + _testDiscoveryEventsHandler = eventHandler; + var verifiedExtensionSourceMap = new Dictionary>(); - try + // Validate the sources + foreach (var kvp in discoveryCriteria.AdapterSourceMap) { - this.discoveryCriteria = discoveryCriteria; - EqtTrace.Info("TestDiscoveryManager.DoDiscovery: Background test discovery started."); - this.testDiscoveryEventsHandler = eventHandler; - var verifiedExtensionSourceMap = new Dictionary>(); - - // Validate the sources - foreach (var kvp in discoveryCriteria.AdapterSourceMap) + var verifiedSources = GetValidSources(kvp.Value, _sessionMessageLogger, discoveryCriteria.Package); + if (verifiedSources.Any()) { - var verifiedSources = GetValidSources(kvp.Value, this.sessionMessageLogger, discoveryCriteria.Package); - if (verifiedSources.Any()) - { - verifiedExtensionSourceMap.Add(kvp.Key, kvp.Value); - } + verifiedExtensionSourceMap.Add(kvp.Key, kvp.Value); } + } - // If there are sources to discover - if (verifiedExtensionSourceMap.Any()) - { - new DiscovererEnumerator(this.requestData, discoveryResultCache, cancellationTokenSource.Token).LoadTests( - verifiedExtensionSourceMap, - RunSettingsUtilities.CreateAndInitializeRunSettings(discoveryCriteria.RunSettings), - discoveryCriteria.TestCaseFilter, - this.sessionMessageLogger); - } - } - finally + // If there are sources to discover + if (verifiedExtensionSourceMap.Any()) { - // Discovery complete. Raise the DiscoveryCompleteEvent. - EqtTrace.Verbose("TestDiscoveryManager.DoDiscovery: Background Test Discovery complete."); + new DiscovererEnumerator(_requestData, discoveryResultCache, _cancellationTokenSource.Token).LoadTests( + verifiedExtensionSourceMap, + RunSettingsUtilities.CreateAndInitializeRunSettings(discoveryCriteria.RunSettings), + discoveryCriteria.TestCaseFilter, + _sessionMessageLogger); + } + } + finally + { + // Discovery complete. Raise the DiscoveryCompleteEvent. + EqtTrace.Verbose("TestDiscoveryManager.DoDiscovery: Background Test Discovery complete."); - var totalDiscoveredTestCount = discoveryResultCache.TotalDiscoveredTests; - var lastChunk = discoveryResultCache.Tests; + var totalDiscoveredTestCount = discoveryResultCache.TotalDiscoveredTests; + var lastChunk = discoveryResultCache.Tests; - EqtTrace.Verbose("TestDiscoveryManager.DiscoveryComplete: Calling DiscoveryComplete callback."); + EqtTrace.Verbose("TestDiscoveryManager.DiscoveryComplete: Calling DiscoveryComplete callback."); - if (eventHandler != null) - { - if (lastChunk != null) - { - UpdateTestCases(lastChunk, this.discoveryCriteria.Package); - } - - // Collecting Discovery State - this.requestData.MetricsCollection.Add(TelemetryDataConstants.DiscoveryState, "Completed"); - - // Collecting Total Tests Discovered - this.requestData.MetricsCollection.Add(TelemetryDataConstants.TotalTestsDiscovered, totalDiscoveredTestCount); - var discoveryCompleteEventsArgs = new DiscoveryCompleteEventArgs(totalDiscoveredTestCount, false) - { - Metrics = this.requestData.MetricsCollection.Metrics - }; - - eventHandler.HandleDiscoveryComplete(discoveryCompleteEventsArgs, lastChunk); - } - else + if (eventHandler != null) + { + if (lastChunk != null) { - EqtTrace.Warning( - "DiscoveryManager: Could not pass the discovery complete message as the callback is null."); + UpdateTestCases(lastChunk, _discoveryCriteria.Package); } - EqtTrace.Verbose("TestDiscoveryManager.DiscoveryComplete: Called DiscoveryComplete callback."); + // Collecting Discovery State + _requestData.MetricsCollection.Add(TelemetryDataConstants.DiscoveryState, "Completed"); + + // Collecting Total Tests Discovered + _requestData.MetricsCollection.Add(TelemetryDataConstants.TotalTestsDiscovered, totalDiscoveredTestCount); + var discoveryCompleteEventsArgs = new DiscoveryCompleteEventArgs(totalDiscoveredTestCount, false) + { + Metrics = _requestData.MetricsCollection.Metrics + }; - this.testDiscoveryEventsHandler = null; + eventHandler.HandleDiscoveryComplete(discoveryCompleteEventsArgs, lastChunk); } + else + { + EqtTrace.Warning( + "DiscoveryManager: Could not pass the discovery complete message as the callback is null."); + } + + EqtTrace.Verbose("TestDiscoveryManager.DiscoveryComplete: Called DiscoveryComplete callback."); + + _testDiscoveryEventsHandler = null; } + } - /// - /// Aborts the test discovery. - /// - public void Abort() + /// + /// Aborts the test discovery. + /// + public void Abort() + { + _cancellationTokenSource.Cancel(); + } + + private void OnReportTestCases(IEnumerable testCases) + { + UpdateTestCases(testCases, _discoveryCriteria.Package); + + if (_testDiscoveryEventsHandler != null) { - this.cancellationTokenSource.Cancel(); + _testDiscoveryEventsHandler.HandleDiscoveredTests(testCases); } - - private void OnReportTestCases(IEnumerable testCases) + else { - UpdateTestCases(testCases, this.discoveryCriteria.Package); - - if (this.testDiscoveryEventsHandler != null) + if (EqtTrace.IsWarningEnabled) { - this.testDiscoveryEventsHandler.HandleDiscoveredTests(testCases); - } - else - { - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning("DiscoveryManager: Could not pass the test results as the callback is null."); - } + EqtTrace.Warning("DiscoveryManager: Could not pass the test results as the callback is null."); } } + } + + /// + /// Verify/Normalize the test source files. + /// + /// Paths to source file to look for tests in. + /// logger + /// package + /// The list of verified sources. + internal static IEnumerable GetValidSources(IEnumerable sources, IMessageLogger logger, string package) + { + Debug.Assert(sources != null, "sources"); + var verifiedSources = new HashSet(StringComparer.OrdinalIgnoreCase); - /// - /// Verify/Normalize the test source files. - /// - /// Paths to source file to look for tests in. - /// logger - /// package - /// The list of verified sources. - internal static IEnumerable GetValidSources(IEnumerable sources, IMessageLogger logger, string package) + foreach (string source in sources) { - Debug.Assert(sources != null, "sources"); - var verifiedSources = new HashSet(StringComparer.OrdinalIgnoreCase); + // It is possible that runtime provider sent relative source path for remote scenario. + string src = !Path.IsPathRooted(source) ? Path.Combine(Directory.GetCurrentDirectory(), source) : source; - foreach (string source in sources) + if (!File.Exists(src)) { - // It is possible that runtime provider sent relative source path for remote scenario. - string src = !Path.IsPathRooted(source) ? Path.Combine(Directory.GetCurrentDirectory(), source) : source; - - if (!File.Exists(src)) + void SendWarning() { - void SendWarning() - { - var errorMessage = string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.FileNotFound, src); - logger.SendMessage(TestMessageLevel.Warning, errorMessage); - } - - if (string.IsNullOrEmpty(package)) - { - SendWarning(); - - continue; - } - - // It is also possible that this is a packaged app, so the tests might be inside the package - src = !Path.IsPathRooted(source) ? Path.Combine(Path.GetDirectoryName(package), source) : source; + var errorMessage = string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.FileNotFound, src); + logger.SendMessage(TestMessageLevel.Warning, errorMessage); + } - if (!File.Exists(src)) - { - SendWarning(); + if (string.IsNullOrEmpty(package)) + { + SendWarning(); - continue; - } + continue; } - if (!verifiedSources.Add(src)) + // It is also possible that this is a packaged app, so the tests might be inside the package + src = !Path.IsPathRooted(source) ? Path.Combine(Path.GetDirectoryName(package), source) : source; + + if (!File.Exists(src)) { - var errorMessage = string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.DuplicateSource, src); - logger.SendMessage(TestMessageLevel.Warning, errorMessage); + SendWarning(); + + continue; } } - // No valid source is found => we cannot discover. - if (!verifiedSources.Any()) + if (!verifiedSources.Add(src)) { - var sourcesString = string.Join(",", sources.ToArray()); - var errorMessage = string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.NoValidSourceFoundForDiscovery, sourcesString); + var errorMessage = string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.DuplicateSource, src); logger.SendMessage(TestMessageLevel.Warning, errorMessage); - - EqtTrace.Warning("TestDiscoveryManager: None of the source {0} is valid. ", sourcesString); - - return verifiedSources; } + } - // Log the sources from where tests are being discovered - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("TestDiscoveryManager: Discovering tests from sources {0}", string.Join(",", verifiedSources.ToArray())); - } + // No valid source is found => we cannot discover. + if (!verifiedSources.Any()) + { + var sourcesString = string.Join(",", sources.ToArray()); + var errorMessage = string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.NoValidSourceFoundForDiscovery, sourcesString); + logger.SendMessage(TestMessageLevel.Warning, errorMessage); + + EqtTrace.Warning("TestDiscoveryManager: None of the source {0} is valid. ", sourcesString); return verifiedSources; } - private void TestSessionMessageHandler(object sender, TestRunMessageEventArgs e) + // Log the sources from where tests are being discovered + if (EqtTrace.IsInfoEnabled) { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info( - "TestDiscoveryManager.RunMessage: calling TestRunMessage({0}, {1}) callback.", - e.Level, - e.Message); - } + EqtTrace.Info("TestDiscoveryManager: Discovering tests from sources {0}", string.Join(",", verifiedSources.ToArray())); + } - if (this.testDiscoveryEventsHandler != null) - { - this.testDiscoveryEventsHandler.HandleLogMessage(e.Level, e.Message); - } - else + return verifiedSources; + } + + private void TestSessionMessageHandler(object sender, TestRunMessageEventArgs e) + { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info( + "TestDiscoveryManager.RunMessage: calling TestRunMessage({0}, {1}) callback.", + e.Level, + e.Message); + } + + if (_testDiscoveryEventsHandler != null) + { + _testDiscoveryEventsHandler.HandleLogMessage(e.Level, e.Message); + } + else + { + if (EqtTrace.IsWarningEnabled) { - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning( - "DiscoveryManager: Could not pass the log message '{0}' as the callback is null.", - e.Message); - } + EqtTrace.Warning( + "DiscoveryManager: Could not pass the log message '{0}' as the callback is null.", + e.Message); } } + } - private static void UpdateTestCases(IEnumerable testCases, string package) + private static void UpdateTestCases(IEnumerable testCases, string package) + { + // Update TestCase objects Source data to contain the actual source(package) provided by IDE(users), + // else these test cases are not displayed in TestWindow. + if (!string.IsNullOrEmpty(package)) { - // Update TestCase objects Source data to contain the actual source(package) provided by IDE(users), - // else these test cases are not displayed in TestWindow. - if (!string.IsNullOrEmpty(package)) + foreach (var tc in testCases) { - foreach (var tc in testCases) - { - tc.Source = package; - } + tc.Source = package; } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryResultCache.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryResultCache.cs index 2048fff45b..3addf15808 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryResultCache.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscoveryResultCache.cs @@ -1,139 +1,127 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery; + +using System; +using System.Collections.Generic; +using System.Diagnostics; + +using ObjectModel; + +/// +/// The discovery result cache. +/// +internal class DiscoveryResultCache { - using System; - using System.Collections.Generic; - using System.Diagnostics; + #region private members + + /// + /// Callback used when cache is full. + /// + private readonly OnReportTestCases _onReportTestCases; + + /// + /// Max size of the test case buffer + /// + private readonly long _cacheSize; + + /// + /// Timeout that triggers sending test cases regardless of cache size. + /// + private readonly TimeSpan _cacheTimeout; + + /// + /// Last time test cases were sent. + /// + private DateTime _lastUpdate; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; + /// + /// Test case buffer + /// + private List _tests; /// - /// The discovery result cache. + /// Sync object /// - internal class DiscoveryResultCache + private readonly object _syncObject = new(); + + #endregion + + /// + /// Initializes a new instance of the class. + /// + /// The cache size. + /// The discovered test event timeout. + /// The on report test cases. + public DiscoveryResultCache(long cacheSize, TimeSpan discoveredTestEventTimeout, OnReportTestCases onReportTestCases) { - #region private members - - /// - /// Callback used when cache is full. - /// - private OnReportTestCases onReportTestCases; - - /// - /// Total tests discovered in this request - /// - private long totalDiscoveredTests; - - /// - /// Max size of the test case buffer - /// - private long cacheSize; - - /// - /// Timeout that triggers sending test cases regardless of cache size. - /// - private TimeSpan cacheTimeout; - - /// - /// Last time test cases were sent. - /// - private DateTime lastUpdate; - - /// - /// Test case buffer - /// - private List tests; - - /// - /// Sync object - /// - private object syncObject = new object(); - - #endregion - - /// - /// Initializes a new instance of the class. - /// - /// The cache size. - /// The discovered test event timeout. - /// The on report test cases. - public DiscoveryResultCache(long cacheSize, TimeSpan discoveredTestEventTimeout, OnReportTestCases onReportTestCases) - { - Debug.Assert(cacheSize > 0, "Buffer size cannot be less than zero"); - Debug.Assert(onReportTestCases != null, "Callback which listens for cache size limit cannot be null."); - Debug.Assert(discoveredTestEventTimeout > TimeSpan.MinValue, "The cache timeout must be greater than min value."); + Debug.Assert(cacheSize > 0, "Buffer size cannot be less than zero"); + Debug.Assert(onReportTestCases != null, "Callback which listens for cache size limit cannot be null."); + Debug.Assert(discoveredTestEventTimeout > TimeSpan.MinValue, "The cache timeout must be greater than min value."); - this.cacheSize = cacheSize; - this.onReportTestCases = onReportTestCases; - this.lastUpdate = DateTime.Now; - this.cacheTimeout = discoveredTestEventTimeout; + _cacheSize = cacheSize; + _onReportTestCases = onReportTestCases; + _lastUpdate = DateTime.Now; + _cacheTimeout = discoveredTestEventTimeout; - this.tests = new List(); - this.totalDiscoveredTests = 0; - } + _tests = new List(); + TotalDiscoveredTests = 0; + } - /// - /// Called when the cache is ready to report some discovered test cases. - /// - public delegate void OnReportTestCases(ICollection tests); + /// + /// Called when the cache is ready to report some discovered test cases. + /// + public delegate void OnReportTestCases(ICollection tests); - /// - /// Gets the tests present in the cache currently - /// - public IList Tests + /// + /// Gets the tests present in the cache currently + /// + public IList Tests + { + get { - get - { - // This needs to new list to avoid concurrency issues. - return new List(this.tests); - } + // This needs to new list to avoid concurrency issues. + return new List(_tests); } + } - /// - /// Gets the total discovered tests - /// - public long TotalDiscoveredTests + /// + /// Gets the total discovered tests + /// + public long TotalDiscoveredTests { get; private set; } + + /// + /// Adds a test to the cache. + /// + /// The test. + public void AddTest(TestCase test) + { + Debug.Assert(test != null, "DiscoveryResultCache.AddTest called with no new test."); + + if (test == null) { - get - { - return this.totalDiscoveredTests; - } + EqtTrace.Warning("DiscoveryResultCache.AddTest: An attempt was made to add a 'null' test"); + return; } - /// - /// Adds a test to the cache. - /// - /// The test. - public void AddTest(TestCase test) + lock (_syncObject) { - Debug.Assert(test != null, "DiscoveryResultCache.AddTest called with no new test."); + _tests.Add(test); + TotalDiscoveredTests++; - if (test == null) + // Send test cases when the specified cache size has been reached or + // after the specified cache timeout has been hit. + var timeDelta = DateTime.Now - _lastUpdate; + if (_tests.Count >= _cacheSize || (timeDelta > _cacheTimeout && _tests.Count > 0)) { - EqtTrace.Warning("DiscoveryResultCache.AddTest: An attempt was made to add a 'null' test"); - return; - } + // Pass on the buffer to the listener and clear the old one + _onReportTestCases(_tests); + _tests = new List(); + _lastUpdate = DateTime.Now; - lock (this.syncObject) - { - this.tests.Add(test); - this.totalDiscoveredTests++; - - // Send test cases when the specified cache size has been reached or - // after the specified cache timeout has been hit. - var timeDelta = DateTime.Now - this.lastUpdate; - if (this.tests.Count >= this.cacheSize || (timeDelta > this.cacheTimeout && this.tests.Count > 0)) - { - // Pass on the buffer to the listener and clear the old one - this.onReportTestCases(this.tests); - this.tests = new List(); - this.lastUpdate = DateTime.Now; - - EqtTrace.Verbose("DiscoveryResultCache.AddTest: Notified the onReportTestCases callback."); - } + EqtTrace.Verbose("DiscoveryResultCache.AddTest: Notified the onReportTestCases callback."); } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/TestCaseDiscoverySink.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/TestCaseDiscoverySink.cs index a73f95a733..ded23c2a0c 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/TestCaseDiscoverySink.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/TestCaseDiscoverySink.cs @@ -1,37 +1,36 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery; + +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + +/// +/// The test case discovery sink. +/// +internal class TestCaseDiscoverySink : ITestCaseDiscoverySink { - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + private readonly DiscoveryResultCache _discoveryRequestCache; /// - /// The test case discovery sink. + /// Initializes a new instance of the class. /// - internal class TestCaseDiscoverySink : ITestCaseDiscoverySink + /// The discovery request cache. + internal TestCaseDiscoverySink(DiscoveryResultCache discoveryRequestCache) { - private DiscoveryResultCache discoveryRequestCache; - - /// - /// Initializes a new instance of the class. - /// - /// The discovery request cache. - internal TestCaseDiscoverySink(DiscoveryResultCache discoveryRequestCache) - { - this.discoveryRequestCache = discoveryRequestCache; - } + _discoveryRequestCache = discoveryRequestCache; + } - /// - /// Sends the test case to the discovery cache. - /// - /// The discovered test. - public void SendTestCase(TestCase discoveredTest) + /// + /// Sends the test case to the discovery cache. + /// + /// The discovered test. + public void SendTestCase(TestCase discoveredTest) + { + if (_discoveryRequestCache != null) { - if (this.discoveryRequestCache != null) - { - this.discoveryRequestCache.AddTest(discoveredTest); - } + _discoveryRequestCache.AddTest(discoveredTest); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestCaseEventsHandler.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestCaseEventsHandler.cs index 9faa970901..c0c7901e32 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestCaseEventsHandler.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestCaseEventsHandler.cs @@ -1,66 +1,66 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.EventHandlers -{ - using System; - using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.Utilities; +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.EventHandlers; - /// - /// The test case events handler. - /// - internal class TestCaseEventsHandler : ITestCaseEventsHandler, ITestEventsPublisher - { - public event EventHandler SessionStart; +using System; +using System.Collections.Generic; + +using DataCollection.Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using ObjectModel.Engine; +using Microsoft.VisualStudio.TestPlatform.Utilities; - public event EventHandler SessionEnd; +/// +/// The test case events handler. +/// +internal class TestCaseEventsHandler : ITestCaseEventsHandler, ITestEventsPublisher +{ + public event EventHandler SessionStart; + + public event EventHandler SessionEnd; - public event EventHandler TestCaseStart; + public event EventHandler TestCaseStart; - public event EventHandler TestCaseEnd; + public event EventHandler TestCaseEnd; - public event EventHandler TestResult; + public event EventHandler TestResult; - /// - /// Initializes a new instance of the class. - /// - public TestCaseEventsHandler() - { - } + /// + /// Initializes a new instance of the class. + /// + public TestCaseEventsHandler() + { + } - /// - public void SendTestCaseStart(TestCase testCase) - { - this.TestCaseStart.SafeInvoke(this, new TestCaseStartEventArgs(testCase), "TestCaseEventsHandler.RaiseTestCaseStart"); - } + /// + public void SendTestCaseStart(TestCase testCase) + { + TestCaseStart.SafeInvoke(this, new TestCaseStartEventArgs(testCase), "TestCaseEventsHandler.RaiseTestCaseStart"); + } - /// - public void SendTestCaseEnd(TestCase testCase, TestOutcome outcome) - { - this.TestCaseEnd.SafeInvoke(this, new TestCaseEndEventArgs(testCase, outcome), "TestCaseEventsHandler.RaiseTestCaseEnd"); - } + /// + public void SendTestCaseEnd(TestCase testCase, TestOutcome outcome) + { + TestCaseEnd.SafeInvoke(this, new TestCaseEndEventArgs(testCase, outcome), "TestCaseEventsHandler.RaiseTestCaseEnd"); + } - /// - public void SendTestResult(TestResult result) - { - this.TestResult.SafeInvoke(this, new TestResultEventArgs(result), "TestCaseEventsHandler.RaiseTestCaseEnd"); - } + /// + public void SendTestResult(TestResult result) + { + TestResult.SafeInvoke(this, new TestResultEventArgs(result), "TestCaseEventsHandler.RaiseTestCaseEnd"); + } - /// - public void SendSessionStart(IDictionary properties) - { - this.SessionStart.SafeInvoke(this, new SessionStartEventArgs(properties), "TestCaseEventsHandler.RaiseSessionStart"); - } + /// + public void SendSessionStart(IDictionary properties) + { + SessionStart.SafeInvoke(this, new SessionStartEventArgs(properties), "TestCaseEventsHandler.RaiseSessionStart"); + } - /// - public void SendSessionEnd() - { - this.SessionEnd.SafeInvoke(this, new SessionEndEventArgs(), "TestCaseEventsHandler.RaiseSessionEnd"); - } + /// + public void SendSessionEnd() + { + SessionEnd.SafeInvoke(this, new SessionEndEventArgs(), "TestCaseEventsHandler.RaiseSessionEnd"); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestRequestHandler.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestRequestHandler.cs index 8b76a4cf05..2d2f2b2e71 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestRequestHandler.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestRequestHandler.cs @@ -1,545 +1,538 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; + +using System; +using System.Collections.Generic; +using System.Threading; + +using EventHandlers; +using Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.EventHandlers; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using Utilities; + +using CrossPlatResources = CrossPlatEngine.Resources.Resources; +using ObjectModelConstants = TestPlatform.ObjectModel.Constants; + +public class TestRequestHandler : ITestRequestHandler { - using System; - using System.Collections.Generic; - using System.Threading; - - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.EventHandlers; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.EventHandlers; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using CrossPlatResources = Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources.Resources; - using ObjectModelConstants = Microsoft.VisualStudio.TestPlatform.ObjectModel.Constants; - - public class TestRequestHandler : ITestRequestHandler + private int _protocolVersion = 1; + + // Must be in sync with the highest supported version in + // src/Microsoft.TestPlatform.CommunicationUtilities/TestRequestSender.cs file. + private readonly int _highestSupportedVersion = 5; + + private readonly IDataSerializer _dataSerializer; + private ITestHostManagerFactory _testHostManagerFactory; + private ICommunicationEndPoint _communicationEndPoint; + private readonly ICommunicationEndpointFactory _communicationEndpointFactory; + private ICommunicationChannel _channel; + + private readonly JobQueue _jobQueue; + private readonly ManualResetEventSlim _requestSenderConnected; + private readonly ManualResetEventSlim _testHostManagerFactoryReady; + private readonly ManualResetEventSlim _sessionCompleted; + private Action _onLaunchAdapterProcessWithDebuggerAttachedAckReceived; + private Action _onAttachDebuggerAckRecieved; + private Exception _messageProcessingUnrecoverableError; + + public TestHostConnectionInfo ConnectionInfo { get; set; } + + /// + /// Initializes a new instance of the . + /// + public TestRequestHandler() : this(JsonDataSerializer.Instance, new CommunicationEndpointFactory()) { - private int protocolVersion = 1; - - // Must be in sync with the highest supported version in - // src/Microsoft.TestPlatform.CommunicationUtilities/TestRequestSender.cs file. - private int highestSupportedVersion = 5; - - private readonly IDataSerializer dataSerializer; - private ITestHostManagerFactory testHostManagerFactory; - private ICommunicationEndPoint communicationEndPoint; - private ICommunicationEndpointFactory communicationEndpointFactory; - private ICommunicationChannel channel; - - private JobQueue jobQueue; - private ManualResetEventSlim requestSenderConnected; - private ManualResetEventSlim testHostManagerFactoryReady; - private ManualResetEventSlim sessionCompleted; - private Action onLaunchAdapterProcessWithDebuggerAttachedAckReceived; - private Action onAttachDebuggerAckRecieved; - private Exception messageProcessingUnrecoverableError; - - public TestHostConnectionInfo ConnectionInfo { get; set; } - - /// - /// Initializes a new instance of the . - /// - public TestRequestHandler() : this(JsonDataSerializer.Instance, new CommunicationEndpointFactory()) - { - } + } - protected TestRequestHandler( - TestHostConnectionInfo connectionInfo, - ICommunicationEndpointFactory communicationEndpointFactory, - IDataSerializer dataSerializer, - JobQueue jobQueue, - Action onLaunchAdapterProcessWithDebuggerAttachedAckReceived, - Action onAttachDebuggerAckRecieved) - { - this.communicationEndpointFactory = communicationEndpointFactory; - this.ConnectionInfo = connectionInfo; - this.dataSerializer = dataSerializer; - this.requestSenderConnected = new ManualResetEventSlim(false); - this.testHostManagerFactoryReady = new ManualResetEventSlim(false); - this.sessionCompleted = new ManualResetEventSlim(false); - this.onLaunchAdapterProcessWithDebuggerAttachedAckReceived = onLaunchAdapterProcessWithDebuggerAttachedAckReceived; - this.onAttachDebuggerAckRecieved = onAttachDebuggerAckRecieved; - this.jobQueue = jobQueue; - } + protected TestRequestHandler( + TestHostConnectionInfo connectionInfo, + ICommunicationEndpointFactory communicationEndpointFactory, + IDataSerializer dataSerializer, + JobQueue jobQueue, + Action onLaunchAdapterProcessWithDebuggerAttachedAckReceived, + Action onAttachDebuggerAckRecieved) + { + _communicationEndpointFactory = communicationEndpointFactory; + ConnectionInfo = connectionInfo; + _dataSerializer = dataSerializer; + _requestSenderConnected = new ManualResetEventSlim(false); + _testHostManagerFactoryReady = new ManualResetEventSlim(false); + _sessionCompleted = new ManualResetEventSlim(false); + _onLaunchAdapterProcessWithDebuggerAttachedAckReceived = onLaunchAdapterProcessWithDebuggerAttachedAckReceived; + _onAttachDebuggerAckRecieved = onAttachDebuggerAckRecieved; + _jobQueue = jobQueue; + } - protected TestRequestHandler(IDataSerializer dataSerializer, ICommunicationEndpointFactory communicationEndpointFactory) - { - this.dataSerializer = dataSerializer; - this.communicationEndpointFactory = communicationEndpointFactory; - this.requestSenderConnected = new ManualResetEventSlim(false); - this.sessionCompleted = new ManualResetEventSlim(false); - this.testHostManagerFactoryReady = new ManualResetEventSlim(false); - this.onLaunchAdapterProcessWithDebuggerAttachedAckReceived = (message) => { throw new NotImplementedException(); }; - this.onAttachDebuggerAckRecieved = (message) => { throw new NotImplementedException(); }; - - this.jobQueue = new JobQueue( - (action) => { action(); }, - "TestHostOperationQueue", - 500, - 25000000, - true, - (message) => EqtTrace.Error(message)); - } + protected TestRequestHandler(IDataSerializer dataSerializer, ICommunicationEndpointFactory communicationEndpointFactory) + { + _dataSerializer = dataSerializer; + _communicationEndpointFactory = communicationEndpointFactory; + _requestSenderConnected = new ManualResetEventSlim(false); + _sessionCompleted = new ManualResetEventSlim(false); + _testHostManagerFactoryReady = new ManualResetEventSlim(false); + _onLaunchAdapterProcessWithDebuggerAttachedAckReceived = (message) => throw new NotImplementedException(); + _onAttachDebuggerAckRecieved = (message) => throw new NotImplementedException(); + + _jobQueue = new JobQueue( + (action) => action(), + "TestHostOperationQueue", + 500, + 25000000, + true, + (message) => EqtTrace.Error(message)); + } - /// - public virtual void InitializeCommunication() + /// + public virtual void InitializeCommunication() + { + _communicationEndPoint = _communicationEndpointFactory.Create(ConnectionInfo.Role); + _communicationEndPoint.Connected += (sender, connectedArgs) => { - this.communicationEndPoint = this.communicationEndpointFactory.Create(this.ConnectionInfo.Role); - this.communicationEndPoint.Connected += (sender, connectedArgs) => + if (!connectedArgs.Connected) { - if (!connectedArgs.Connected) - { - requestSenderConnected.Set(); - throw connectedArgs.Fault; - } - this.channel = connectedArgs.Channel; - this.channel.MessageReceived += this.OnMessageReceived; - requestSenderConnected.Set(); - }; + _requestSenderConnected.Set(); + throw connectedArgs.Fault; + } + _channel = connectedArgs.Channel; + _channel.MessageReceived += OnMessageReceived; + _requestSenderConnected.Set(); + }; - this.communicationEndPoint.Start(this.ConnectionInfo.Endpoint); - } + _communicationEndPoint.Start(ConnectionInfo.Endpoint); + } - /// - public bool WaitForRequestSenderConnection(int connectionTimeout) - { - return requestSenderConnected.Wait(connectionTimeout); - } + /// + public bool WaitForRequestSenderConnection(int connectionTimeout) + { + return _requestSenderConnected.Wait(connectionTimeout); + } - /// - public void ProcessRequests(ITestHostManagerFactory testHostManagerFactory) - { - this.testHostManagerFactory = testHostManagerFactory; - this.testHostManagerFactoryReady.Set(); - this.sessionCompleted.Wait(); - } + /// + public void ProcessRequests(ITestHostManagerFactory testHostManagerFactory) + { + _testHostManagerFactory = testHostManagerFactory; + _testHostManagerFactoryReady.Set(); + _sessionCompleted.Wait(); + } - /// - public void Dispose() - { - this.communicationEndPoint.Stop(); - this.channel?.Dispose(); - } + /// + public void Dispose() + { + _communicationEndPoint.Stop(); + _channel?.Dispose(); + } - /// - public void Close() - { - this.Dispose(); - EqtTrace.Info("Closing the connection !"); - } + /// + public void Close() + { + Dispose(); + EqtTrace.Info("Closing the connection !"); + } - /// - public void SendTestCases(IEnumerable discoveredTestCases) - { - var data = this.dataSerializer.SerializePayload(MessageType.TestCasesFound, discoveredTestCases, this.protocolVersion); - this.SendData(data); - } + /// + public void SendTestCases(IEnumerable discoveredTestCases) + { + var data = _dataSerializer.SerializePayload(MessageType.TestCasesFound, discoveredTestCases, _protocolVersion); + SendData(data); + } - /// - public void SendTestRunStatistics(TestRunChangedEventArgs testRunChangedArgs) - { - var data = this.dataSerializer.SerializePayload(MessageType.TestRunStatsChange, testRunChangedArgs, this.protocolVersion); - this.SendData(data); - } + /// + public void SendTestRunStatistics(TestRunChangedEventArgs testRunChangedArgs) + { + var data = _dataSerializer.SerializePayload(MessageType.TestRunStatsChange, testRunChangedArgs, _protocolVersion); + SendData(data); + } + + /// + public void SendLog(TestMessageLevel messageLevel, string message) + { + var data = _dataSerializer.SerializePayload( + MessageType.TestMessage, + new TestMessagePayload { MessageLevel = messageLevel, Message = message }, + _protocolVersion); + SendData(data); + } - /// - public void SendLog(TestMessageLevel messageLevel, string message) + /// + public void SendExecutionComplete( + TestRunCompleteEventArgs testRunCompleteArgs, + TestRunChangedEventArgs lastChunkArgs, + ICollection runContextAttachments, + ICollection executorUris) + { + // When we abort the run we might have saved the error before we gave the handler the chance to abort + // if the handler does not return with any new error we report the original one. + if (testRunCompleteArgs.IsAborted && testRunCompleteArgs.Error == null && _messageProcessingUnrecoverableError != null) { - var data = this.dataSerializer.SerializePayload( - MessageType.TestMessage, - new TestMessagePayload { MessageLevel = messageLevel, Message = message }, - this.protocolVersion); - this.SendData(data); + var curentArgs = testRunCompleteArgs; + testRunCompleteArgs = new TestRunCompleteEventArgs( + curentArgs.TestRunStatistics, + curentArgs.IsCanceled, + curentArgs.IsAborted, + _messageProcessingUnrecoverableError, + curentArgs.AttachmentSets, curentArgs.InvokedDataCollectors, curentArgs.ElapsedTimeInRunningTests + ); } + var data = _dataSerializer.SerializePayload( + MessageType.ExecutionComplete, + new TestRunCompletePayload + { + TestRunCompleteArgs = testRunCompleteArgs, + LastRunTests = lastChunkArgs, + RunAttachments = runContextAttachments, + ExecutorUris = executorUris + }, + _protocolVersion); + SendData(data); + } - /// - public void SendExecutionComplete( - TestRunCompleteEventArgs testRunCompleteArgs, - TestRunChangedEventArgs lastChunkArgs, - ICollection runContextAttachments, - ICollection executorUris) - { - // When we abort the run we might have saved the error before we gave the handler the chance to abort - // if the handler does not return with any new error we report the original one. - if (testRunCompleteArgs.IsAborted && testRunCompleteArgs.Error == null && this.messageProcessingUnrecoverableError != null) + /// + public void DiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk) + { + var data = _dataSerializer.SerializePayload( + MessageType.DiscoveryComplete, + new DiscoveryCompletePayload { - var curentArgs = testRunCompleteArgs; - testRunCompleteArgs = new TestRunCompleteEventArgs( - curentArgs.TestRunStatistics, - curentArgs.IsCanceled, - curentArgs.IsAborted, - this.messageProcessingUnrecoverableError, - curentArgs.AttachmentSets, curentArgs.InvokedDataCollectors, curentArgs.ElapsedTimeInRunningTests - ); - } - var data = this.dataSerializer.SerializePayload( - MessageType.ExecutionComplete, - new TestRunCompletePayload - { - TestRunCompleteArgs = testRunCompleteArgs, - LastRunTests = lastChunkArgs, - RunAttachments = runContextAttachments, - ExecutorUris = executorUris - }, - this.protocolVersion); - this.SendData(data); - } + TotalTests = discoveryCompleteEventArgs.TotalCount, + LastDiscoveredTests = discoveryCompleteEventArgs.IsAborted ? null : lastChunk, + IsAborted = discoveryCompleteEventArgs.IsAborted, + Metrics = discoveryCompleteEventArgs.Metrics + }, + _protocolVersion); + SendData(data); + } - /// - public void DiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk) + /// + public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) + { + var waitHandle = new ManualResetEventSlim(false); + Message ackMessage = null; + _onLaunchAdapterProcessWithDebuggerAttachedAckReceived = (ackRawMessage) => { - var data = this.dataSerializer.SerializePayload( - MessageType.DiscoveryComplete, - new DiscoveryCompletePayload - { - TotalTests = discoveryCompleteEventArgs.TotalCount, - LastDiscoveredTests = discoveryCompleteEventArgs.IsAborted ? null : lastChunk, - IsAborted = discoveryCompleteEventArgs.IsAborted, - Metrics = discoveryCompleteEventArgs.Metrics - }, - this.protocolVersion); - this.SendData(data); - } + ackMessage = ackRawMessage; + waitHandle.Set(); + }; - /// - public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) - { - var waitHandle = new ManualResetEventSlim(false); - Message ackMessage = null; - this.onLaunchAdapterProcessWithDebuggerAttachedAckReceived = (ackRawMessage) => - { - ackMessage = ackRawMessage; - waitHandle.Set(); - }; + var data = _dataSerializer.SerializePayload(MessageType.LaunchAdapterProcessWithDebuggerAttached, + testProcessStartInfo, _protocolVersion); - var data = dataSerializer.SerializePayload(MessageType.LaunchAdapterProcessWithDebuggerAttached, - testProcessStartInfo, protocolVersion); + SendData(data); - this.SendData(data); + EqtTrace.Verbose("Waiting for LaunchAdapterProcessWithDebuggerAttached ack"); + waitHandle.Wait(); + _onLaunchAdapterProcessWithDebuggerAttachedAckReceived = null; + return _dataSerializer.DeserializePayload(ackMessage); + } - EqtTrace.Verbose("Waiting for LaunchAdapterProcessWithDebuggerAttached ack"); - waitHandle.Wait(); - this.onLaunchAdapterProcessWithDebuggerAttachedAckReceived = null; - return this.dataSerializer.DeserializePayload(ackMessage); + /// + public bool AttachDebuggerToProcess(int pid) + { + // If an attach request is issued but there is no support for attaching on the other + // side of the communication channel, we simply return and let the caller know the + // request failed. + if (_protocolVersion < ObjectModelConstants.MinimumProtocolVersionWithDebugSupport) + { + return false; } - /// - public bool AttachDebuggerToProcess(int pid) + Message ackMessage = null; + var waitHandle = new ManualResetEventSlim(false); + + _onAttachDebuggerAckRecieved = (ackRawMessage) => { - // If an attach request is issued but there is no support for attaching on the other - // side of the communication channel, we simply return and let the caller know the - // request failed. - if (this.protocolVersion < ObjectModelConstants.MinimumProtocolVersionWithDebugSupport) - { - return false; - } + ackMessage = ackRawMessage; + waitHandle.Set(); + }; - Message ackMessage = null; - var waitHandle = new ManualResetEventSlim(false); + var data = _dataSerializer.SerializePayload( + MessageType.AttachDebugger, + new TestProcessAttachDebuggerPayload(pid), + _protocolVersion); + SendData(data); - this.onAttachDebuggerAckRecieved = (ackRawMessage) => - { - ackMessage = ackRawMessage; - waitHandle.Set(); - }; + EqtTrace.Verbose("Waiting for AttachDebuggerToProcess ack ..."); + waitHandle.Wait(); - var data = dataSerializer.SerializePayload( - MessageType.AttachDebugger, - new TestProcessAttachDebuggerPayload(pid), - protocolVersion); - this.SendData(data); + _onAttachDebuggerAckRecieved = null; + return _dataSerializer.DeserializePayload(ackMessage); + } - EqtTrace.Verbose("Waiting for AttachDebuggerToProcess ack ..."); - waitHandle.Wait(); + public void OnMessageReceived(object sender, MessageReceivedEventArgs messageReceivedArgs) + { + var message = _dataSerializer.DeserializeMessage(messageReceivedArgs.Data); - this.onAttachDebuggerAckRecieved = null; - return this.dataSerializer.DeserializePayload(ackMessage); + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("TestRequestHandler.OnMessageReceived: received message: {0}", message); } - public void OnMessageReceived(object sender, MessageReceivedEventArgs messageReceivedArgs) + switch (message.MessageType) { - var message = this.dataSerializer.DeserializeMessage(messageReceivedArgs.Data); + case MessageType.VersionCheck: + try + { + var version = _dataSerializer.DeserializePayload(message); + // choose the highest version that we both support + var negotiatedVersion = Math.Min(version, _highestSupportedVersion); + // BUT don't choose 3, because protocol version 3 has performance problems in 16.7.1-16.8. Those problems are caused + // by choosing payloadSerializer instead of payloadSerializer2 for protocol version 3. + // + // We cannot just update the code to choose the new serializer, because then that change would apply only to testhost. + // Testhost is is delivered by Microsoft.NET.Test.SDK nuget package, and can be used with an older vstest.console. + // An older vstest.console, that supports protocol version 3, would serialize its messages using payloadSerializer, + // but the fixed testhost would serialize it using payloadSerializer2, resulting in incompatible messages. + // + // Instead we must downgrade to protocol version 2 when 3 would be negotiated. Or higher when higher version + // would be negotiated. + if (negotiatedVersion != 3) + { + _protocolVersion = negotiatedVersion; + } + else + { + var flag = Environment.GetEnvironmentVariable("VSTEST_DISABLE_PROTOCOL_3_VERSION_DOWNGRADE"); + var flagIsEnabled = flag != null && flag != "0"; + var dowgradeIsDisabled = flagIsEnabled; + _protocolVersion = dowgradeIsDisabled ? negotiatedVersion : 2; + } - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("TestRequestHandler.OnMessageReceived: received message: {0}", message); - } + // Send the negotiated protocol to request sender + _channel.Send(_dataSerializer.SerializePayload(MessageType.VersionCheck, _protocolVersion)); - switch (message.MessageType) - { - case MessageType.VersionCheck: + // Can only do this after InitializeCommunication because TestHost cannot "Send Log" unless communications are initialized + if (!string.IsNullOrEmpty(EqtTrace.LogFile)) + { + SendLog(TestMessageLevel.Informational, string.Format(CrossPlatResources.TesthostDiagLogOutputFile, EqtTrace.LogFile)); + } + else if (!string.IsNullOrEmpty(EqtTrace.ErrorOnInitialization)) + { + SendLog(TestMessageLevel.Warning, EqtTrace.ErrorOnInitialization); + } + } + catch (Exception ex) + { + _messageProcessingUnrecoverableError = ex; + EqtTrace.Error("Failed processing message {0}, aborting test run.", message.MessageType); + EqtTrace.Error(ex); + goto case MessageType.AbortTestRun; + } + break; + + case MessageType.DiscoveryInitialize: + { try { - var version = this.dataSerializer.DeserializePayload(message); - // choose the highest version that we both support - var negotiatedVersion = Math.Min(version, highestSupportedVersion); - // BUT don't choose 3, because protocol version 3 has performance problems in 16.7.1-16.8. Those problems are caused - // by choosing payloadSerializer instead of payloadSerializer2 for protocol version 3. - // - // We cannot just update the code to choose the new serializer, because then that change would apply only to testhost. - // Testhost is is delivered by Microsoft.NET.Test.SDK nuget package, and can be used with an older vstest.console. - // An older vstest.console, that supports protocol version 3, would serialize its messages using payloadSerializer, - // but the fixed testhost would serialize it using payloadSerializer2, resulting in incompatible messages. - // - // Instead we must downgrade to protocol version 2 when 3 would be negotiated. Or higher when higher version - // would be negotiated. - if (negotiatedVersion != 3) - { - this.protocolVersion = negotiatedVersion; - } - else - { - var flag = Environment.GetEnvironmentVariable("VSTEST_DISABLE_PROTOCOL_3_VERSION_DOWNGRADE"); - var flagIsEnabled = flag != null && flag != "0"; - var dowgradeIsDisabled = flagIsEnabled; - if (dowgradeIsDisabled) - { - this.protocolVersion = negotiatedVersion; - } - else - { - this.protocolVersion = 2; - } - } - - // Send the negotiated protocol to request sender - this.channel.Send(this.dataSerializer.SerializePayload(MessageType.VersionCheck, this.protocolVersion)); - - // Can only do this after InitializeCommunication because TestHost cannot "Send Log" unless communications are initialized - if (!string.IsNullOrEmpty(EqtTrace.LogFile)) + _testHostManagerFactoryReady.Wait(); + var discoveryEventsHandler = new TestDiscoveryEventHandler(this); + var pathToAdditionalExtensions = _dataSerializer.DeserializePayload>(message); + Action job = () => { - this.SendLog(TestMessageLevel.Informational, string.Format(CrossPlatResources.TesthostDiagLogOutputFile, EqtTrace.LogFile)); - } - else if (!string.IsNullOrEmpty(EqtTrace.ErrorOnInitialization)) - { - this.SendLog(TestMessageLevel.Warning, EqtTrace.ErrorOnInitialization); - } + EqtTrace.Info("TestRequestHandler.OnMessageReceived: Running job '{0}'.", message.MessageType); + _testHostManagerFactory.GetDiscoveryManager().Initialize(pathToAdditionalExtensions, discoveryEventsHandler); + }; + _jobQueue.QueueJob(job, 0); } catch (Exception ex) { - this.messageProcessingUnrecoverableError = ex; + _messageProcessingUnrecoverableError = ex; EqtTrace.Error("Failed processing message {0}, aborting test run.", message.MessageType); EqtTrace.Error(ex); goto case MessageType.AbortTestRun; } break; + } - case MessageType.DiscoveryInitialize: + case MessageType.StartDiscovery: + { + try { - try - { - this.testHostManagerFactoryReady.Wait(); - var discoveryEventsHandler = new TestDiscoveryEventHandler(this); - var pathToAdditionalExtensions = this.dataSerializer.DeserializePayload>(message); - Action job = () => - { - EqtTrace.Info("TestRequestHandler.OnMessageReceived: Running job '{0}'.", message.MessageType); - testHostManagerFactory.GetDiscoveryManager().Initialize(pathToAdditionalExtensions, discoveryEventsHandler); - }; - jobQueue.QueueJob(job, 0); - } - catch (Exception ex) + _testHostManagerFactoryReady.Wait(); + var discoveryEventsHandler = new TestDiscoveryEventHandler(this); + var discoveryCriteria = _dataSerializer.DeserializePayload(message); + Action job = () => { - this.messageProcessingUnrecoverableError = ex; - EqtTrace.Error("Failed processing message {0}, aborting test run.", message.MessageType); - EqtTrace.Error(ex); - goto case MessageType.AbortTestRun; - } - break; - } + EqtTrace.Info("TestRequestHandler.OnMessageReceived: Running job '{0}'.", message.MessageType); + _testHostManagerFactory.GetDiscoveryManager() + .DiscoverTests(discoveryCriteria, discoveryEventsHandler); + }; - case MessageType.StartDiscovery: + _jobQueue.QueueJob(job, 0); + } + catch (Exception ex) { - try - { - this.testHostManagerFactoryReady.Wait(); - var discoveryEventsHandler = new TestDiscoveryEventHandler(this); - var discoveryCriteria = this.dataSerializer.DeserializePayload(message); - Action job = () => - { - EqtTrace.Info("TestRequestHandler.OnMessageReceived: Running job '{0}'.", message.MessageType); - testHostManagerFactory.GetDiscoveryManager() - .DiscoverTests(discoveryCriteria, discoveryEventsHandler); - }; - - jobQueue.QueueJob(job, 0); - } - catch (Exception ex) - { - this.messageProcessingUnrecoverableError = ex; - EqtTrace.Error("Failed processing message {0}, aborting test run.", message.MessageType); - EqtTrace.Error(ex); - goto case MessageType.AbortTestRun; - } - break; + _messageProcessingUnrecoverableError = ex; + EqtTrace.Error("Failed processing message {0}, aborting test run.", message.MessageType); + EqtTrace.Error(ex); + goto case MessageType.AbortTestRun; } + break; + } - case MessageType.ExecutionInitialize: + case MessageType.ExecutionInitialize: + { + try { - try + _testHostManagerFactoryReady.Wait(); + var testInitializeEventsHandler = new TestInitializeEventsHandler(this); + var pathToAdditionalExtensions = _dataSerializer.DeserializePayload>(message); + Action job = () => { - this.testHostManagerFactoryReady.Wait(); - var testInitializeEventsHandler = new TestInitializeEventsHandler(this); - var pathToAdditionalExtensions = this.dataSerializer.DeserializePayload>(message); - Action job = () => - { - EqtTrace.Info("TestRequestHandler.OnMessageReceived: Running job '{0}'.", message.MessageType); - testHostManagerFactory.GetExecutionManager().Initialize(pathToAdditionalExtensions, testInitializeEventsHandler); - }; - jobQueue.QueueJob(job, 0); - } - catch (Exception ex) - { - this.messageProcessingUnrecoverableError = ex; - EqtTrace.Error("Failed processing message {0}, aborting test run.", message.MessageType); - EqtTrace.Error(ex); - goto case MessageType.AbortTestRun; - } - break; + EqtTrace.Info("TestRequestHandler.OnMessageReceived: Running job '{0}'.", message.MessageType); + _testHostManagerFactory.GetExecutionManager().Initialize(pathToAdditionalExtensions, testInitializeEventsHandler); + }; + _jobQueue.QueueJob(job, 0); } + catch (Exception ex) + { + _messageProcessingUnrecoverableError = ex; + EqtTrace.Error("Failed processing message {0}, aborting test run.", message.MessageType); + EqtTrace.Error(ex); + goto case MessageType.AbortTestRun; + } + break; + } - case MessageType.StartTestExecutionWithSources: + case MessageType.StartTestExecutionWithSources: + { + try { - try + var testRunEventsHandler = new TestRunEventsHandler(this); + _testHostManagerFactoryReady.Wait(); + var testRunCriteriaWithSources = _dataSerializer.DeserializePayload(message); + Action job = () => { - var testRunEventsHandler = new TestRunEventsHandler(this); - this.testHostManagerFactoryReady.Wait(); - var testRunCriteriaWithSources = this.dataSerializer.DeserializePayload(message); - Action job = () => - { - EqtTrace.Info("TestRequestHandler.OnMessageReceived: Running job '{0}'.", message.MessageType); - testHostManagerFactory.GetExecutionManager() + EqtTrace.Info("TestRequestHandler.OnMessageReceived: Running job '{0}'.", message.MessageType); + _testHostManagerFactory.GetExecutionManager() .StartTestRun( testRunCriteriaWithSources.AdapterSourceMap, testRunCriteriaWithSources.Package, testRunCriteriaWithSources.RunSettings, testRunCriteriaWithSources.TestExecutionContext, - this.GetTestCaseEventsHandler(testRunCriteriaWithSources.RunSettings), + GetTestCaseEventsHandler(testRunCriteriaWithSources.RunSettings), testRunEventsHandler); - }; - jobQueue.QueueJob(job, 0); - } - catch (Exception ex) - { - this.messageProcessingUnrecoverableError = ex; - EqtTrace.Error("Failed processing message {0}, aborting test run.", message.MessageType); - EqtTrace.Error(ex); - goto case MessageType.AbortTestRun; - } - break; + }; + _jobQueue.QueueJob(job, 0); } + catch (Exception ex) + { + _messageProcessingUnrecoverableError = ex; + EqtTrace.Error("Failed processing message {0}, aborting test run.", message.MessageType); + EqtTrace.Error(ex); + goto case MessageType.AbortTestRun; + } + break; + } - case MessageType.StartTestExecutionWithTests: + case MessageType.StartTestExecutionWithTests: + { + try { - try + var testRunEventsHandler = new TestRunEventsHandler(this); + _testHostManagerFactoryReady.Wait(); + var testRunCriteriaWithTests = + _dataSerializer.DeserializePayload(message); + + Action job = () => { - var testRunEventsHandler = new TestRunEventsHandler(this); - this.testHostManagerFactoryReady.Wait(); - var testRunCriteriaWithTests = - this.dataSerializer.DeserializePayload(message); - - Action job = () => - { - EqtTrace.Info("TestRequestHandler.OnMessageReceived: Running job '{0}'.", message.MessageType); - testHostManagerFactory.GetExecutionManager() + EqtTrace.Info("TestRequestHandler.OnMessageReceived: Running job '{0}'.", message.MessageType); + _testHostManagerFactory.GetExecutionManager() .StartTestRun( testRunCriteriaWithTests.Tests, testRunCriteriaWithTests.Package, testRunCriteriaWithTests.RunSettings, testRunCriteriaWithTests.TestExecutionContext, - this.GetTestCaseEventsHandler(testRunCriteriaWithTests.RunSettings), + GetTestCaseEventsHandler(testRunCriteriaWithTests.RunSettings), testRunEventsHandler); - }; - jobQueue.QueueJob(job, 0); - } - catch (Exception ex) - { - this.messageProcessingUnrecoverableError = ex; - EqtTrace.Error("Failed processing message {0}, aborting test run.", message.MessageType); - EqtTrace.Error(ex); - goto case MessageType.AbortTestRun; - } - break; - } - - case MessageType.CancelTestRun: - jobQueue.Pause(); - this.testHostManagerFactoryReady.Wait(); - testHostManagerFactory.GetExecutionManager().Cancel(new TestRunEventsHandler(this)); - break; - - case MessageType.LaunchAdapterProcessWithDebuggerAttachedCallback: - this.onLaunchAdapterProcessWithDebuggerAttachedAckReceived?.Invoke(message); - break; - - case MessageType.AttachDebuggerCallback: - this.onAttachDebuggerAckRecieved?.Invoke(message); - break; - - case MessageType.AbortTestRun: - try - { - jobQueue.Pause(); - this.testHostManagerFactoryReady.Wait(); - testHostManagerFactory.GetExecutionManager().Abort(new TestRunEventsHandler(this)); + }; + _jobQueue.QueueJob(job, 0); } catch (Exception ex) { - EqtTrace.Error("Failed processing message {0}. Stopping communication.", message.MessageType); + _messageProcessingUnrecoverableError = ex; + EqtTrace.Error("Failed processing message {0}, aborting test run.", message.MessageType); EqtTrace.Error(ex); - sessionCompleted.Set(); - this.Close(); + goto case MessageType.AbortTestRun; } break; + } - case MessageType.SessionEnd: - { - EqtTrace.Info("Session End message received from server. Closing the connection."); - sessionCompleted.Set(); - this.Close(); - break; - } + case MessageType.CancelTestRun: + _jobQueue.Pause(); + _testHostManagerFactoryReady.Wait(); + _testHostManagerFactory.GetExecutionManager().Cancel(new TestRunEventsHandler(this)); + break; - case MessageType.SessionAbort: - { - // Don't do anything for now. - break; - } + case MessageType.LaunchAdapterProcessWithDebuggerAttachedCallback: + _onLaunchAdapterProcessWithDebuggerAttachedAckReceived?.Invoke(message); + break; - default: - { - EqtTrace.Info("Invalid Message types"); - break; - } - } - } + case MessageType.AttachDebuggerCallback: + _onAttachDebuggerAckRecieved?.Invoke(message); + break; - private ITestCaseEventsHandler GetTestCaseEventsHandler(string runSettings) - { - ITestCaseEventsHandler testCaseEventsHandler = null; + case MessageType.AbortTestRun: + try + { + _jobQueue.Pause(); + _testHostManagerFactoryReady.Wait(); + _testHostManagerFactory.GetExecutionManager().Abort(new TestRunEventsHandler(this)); + } + catch (Exception ex) + { + EqtTrace.Error("Failed processing message {0}. Stopping communication.", message.MessageType); + EqtTrace.Error(ex); + _sessionCompleted.Set(); + Close(); + } + break; - // Listen to test case events only if data collection is enabled - if ((XmlRunSettingsUtilities.IsDataCollectionEnabled(runSettings) && DataCollectionTestCaseEventSender.Instance != null) || XmlRunSettingsUtilities.IsInProcDataCollectionEnabled(runSettings)) - { - testCaseEventsHandler = new TestCaseEventsHandler(); - } + case MessageType.SessionEnd: + { + EqtTrace.Info("Session End message received from server. Closing the connection."); + _sessionCompleted.Set(); + Close(); + break; + } + + case MessageType.SessionAbort: + { + // Don't do anything for now. + break; + } - return testCaseEventsHandler; + default: + { + EqtTrace.Info("Invalid Message types"); + break; + } } + } + + private ITestCaseEventsHandler GetTestCaseEventsHandler(string runSettings) + { + ITestCaseEventsHandler testCaseEventsHandler = null; - private void SendData(string data) + // Listen to test case events only if data collection is enabled + if ((XmlRunSettingsUtilities.IsDataCollectionEnabled(runSettings) && DataCollectionTestCaseEventSender.Instance != null) || XmlRunSettingsUtilities.IsInProcDataCollectionEnabled(runSettings)) { - EqtTrace.Verbose("TestRequestHandler.SendData: sending data from testhost: {0}", data); - this.channel.Send(data); + testCaseEventsHandler = new TestCaseEventsHandler(); } + + return testCaseEventsHandler; + } + + private void SendData(string data) + { + EqtTrace.Verbose("TestRequestHandler.SendData: sending data from testhost: {0}", data); + _channel.Send(data); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs index 8abee57b9e..9e8a7f8702 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs @@ -1,774 +1,764 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; + +using CommunicationUtilities.Interfaces; + +using Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Common.Interfaces; +using Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using CommunicationUtilities; +using CoreUtilities.Tracing.Interfaces; +using Adapter; +using DataCollection.Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; +using ObjectModel.Engine.ClientProtocol; +using ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using PlatformAbstractions; +using PlatformAbstractions.Interfaces; + +using CrossPlatEngineResources = Resources.Resources; + +/// +/// The base run tests. +/// +internal abstract class BaseRunTests { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Diagnostics; - using System.Diagnostics.CodeAnalysis; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Reflection; - using System.Threading.Tasks; - using CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - - using CrossPlatEngineResources = Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources.Resources; + #region private fields + + private readonly ITestEventsPublisher _testEventsPublisher; + private protected string _package; + private readonly IRequestData _requestData; + + /// + /// Specifies that the test run cancellation is requested + /// + private volatile bool _isCancellationRequested; + + /// + /// Active executor which is executing the tests currently + /// + private ITestExecutor _activeExecutor; + private readonly ITestCaseEventsHandler _testCaseEventsHandler; + private readonly ITestPlatformEventSource _testPlatformEventSource; + + /// + /// To create thread in given apartment state. + /// + private readonly IThread _platformThread; + + /// + /// The Run configuration. To determine framework and execution thread apartment state. + /// + private RunConfiguration _runConfiguration; /// - /// The base run tests. + /// The Serializer to clone testcase object in case of user input test source is package. E.g UWP scenario(appx/build.appxrecipe). /// - internal abstract class BaseRunTests + private readonly IDataSerializer _dataSerializer; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// The request data for providing common execution services and data + /// The user input test source(package) if it differs from actual test source otherwise null. + /// The run settings. + /// The test execution context. + /// The test case events handler. + /// The test run events handler. + /// Test platform event source. + protected BaseRunTests( + IRequestData requestData, + string package, + string runSettings, + TestExecutionContext testExecutionContext, + ITestCaseEventsHandler testCaseEventsHandler, + ITestRunEventsHandler testRunEventsHandler, + ITestPlatformEventSource testPlatformEventSource) + : this( + requestData, + package, + runSettings, + testExecutionContext, + testCaseEventsHandler, + testRunEventsHandler, + testPlatformEventSource, + testCaseEventsHandler as ITestEventsPublisher, + new PlatformThread(), + JsonDataSerializer.Instance) { - #region private fields - - private string runSettings; - private TestExecutionContext testExecutionContext; - private ITestRunEventsHandler testRunEventsHandler; - private ITestEventsPublisher testEventsPublisher; - private ITestRunCache testRunCache; - private protected string package; - private IRequestData requestData; - - /// - /// Specifies that the test run cancellation is requested - /// - private volatile bool isCancellationRequested; - - /// - /// Active executor which is executing the tests currently - /// - private ITestExecutor activeExecutor; - private ITestCaseEventsHandler testCaseEventsHandler; - private RunContext runContext; - private FrameworkHandle frameworkHandle; - - private ICollection executorUrisThatRanTests; - private ITestPlatformEventSource testPlatformEventSource; - - /// - /// To create thread in given apartment state. - /// - private IThread platformThread; - - /// - /// The Run configuration. To determine framework and execution thread apartment state. - /// - private RunConfiguration runConfiguration; - - /// - /// The Serializer to clone testcase object in case of user input test source is package. E.g UWP scenario(appx/build.appxrecipe). - /// - private IDataSerializer dataSerializer; - - #endregion - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - /// The request data for providing common execution services and data - /// The user input test source(package) if it differs from actual test source otherwise null. - /// The run settings. - /// The test execution context. - /// The test case events handler. - /// The test run events handler. - /// Test platform event source. - protected BaseRunTests( - IRequestData requestData, - string package, - string runSettings, - TestExecutionContext testExecutionContext, - ITestCaseEventsHandler testCaseEventsHandler, - ITestRunEventsHandler testRunEventsHandler, - ITestPlatformEventSource testPlatformEventSource) - : this( - requestData, - package, - runSettings, - testExecutionContext, - testCaseEventsHandler, - testRunEventsHandler, - testPlatformEventSource, - testCaseEventsHandler as ITestEventsPublisher, - new PlatformThread(), - JsonDataSerializer.Instance) - { - } + } - /// - /// Initializes a new instance of the class. - /// - /// Provides services and data for execution - /// The user input test source(package) list if it differs from actual test source otherwise null. - /// The run settings. - /// The test execution context. - /// The test case events handler. - /// The test run events handler. - /// Test platform event source. - /// Publisher for test events. - /// Platform Thread. - /// Data Serializer for cloning TestCase and test results object. - protected BaseRunTests( - IRequestData requestData, - string package, - string runSettings, - TestExecutionContext testExecutionContext, - ITestCaseEventsHandler testCaseEventsHandler, - ITestRunEventsHandler testRunEventsHandler, - ITestPlatformEventSource testPlatformEventSource, - ITestEventsPublisher testEventsPublisher, - IThread platformThread, - IDataSerializer dataSerializer) - { - this.package = package; - this.runSettings = runSettings; - this.testExecutionContext = testExecutionContext; - this.testCaseEventsHandler = testCaseEventsHandler; - this.testRunEventsHandler = testRunEventsHandler; - this.requestData = requestData; - - this.isCancellationRequested = false; - this.testPlatformEventSource = testPlatformEventSource; - this.testEventsPublisher = testEventsPublisher; - this.platformThread = platformThread; - this.dataSerializer = dataSerializer; - this.SetContext(); - } + /// + /// Initializes a new instance of the class. + /// + /// Provides services and data for execution + /// The user input test source(package) list if it differs from actual test source otherwise null. + /// The run settings. + /// The test execution context. + /// The test case events handler. + /// The test run events handler. + /// Test platform event source. + /// Publisher for test events. + /// Platform Thread. + /// Data Serializer for cloning TestCase and test results object. + protected BaseRunTests( + IRequestData requestData, + string package, + string runSettings, + TestExecutionContext testExecutionContext, + ITestCaseEventsHandler testCaseEventsHandler, + ITestRunEventsHandler testRunEventsHandler, + ITestPlatformEventSource testPlatformEventSource, + ITestEventsPublisher testEventsPublisher, + IThread platformThread, + IDataSerializer dataSerializer) + { + _package = package; + RunSettings = runSettings; + TestExecutionContext = testExecutionContext; + _testCaseEventsHandler = testCaseEventsHandler; + TestRunEventsHandler = testRunEventsHandler; + _requestData = requestData; + + _isCancellationRequested = false; + _testPlatformEventSource = testPlatformEventSource; + _testEventsPublisher = testEventsPublisher; + _platformThread = platformThread; + _dataSerializer = dataSerializer; + SetContext(); + } - #endregion + #endregion - #region Properties + #region Properties - /// - /// Gets the run settings. - /// - protected string RunSettings => this.runSettings; + /// + /// Gets the run settings. + /// + protected string RunSettings { get; private set; } - /// - /// Gets the test execution context. - /// - protected TestExecutionContext TestExecutionContext => this.testExecutionContext; + /// + /// Gets the test execution context. + /// + protected TestExecutionContext TestExecutionContext { get; private set; } - /// - /// Gets the test run events handler. - /// - protected ITestRunEventsHandler TestRunEventsHandler => this.testRunEventsHandler; + /// + /// Gets the test run events handler. + /// + protected ITestRunEventsHandler TestRunEventsHandler { get; private set; } - /// - /// Gets the test run cache. - /// - protected ITestRunCache TestRunCache => this.testRunCache; + /// + /// Gets the test run cache. + /// + protected ITestRunCache TestRunCache { get; private set; } - protected bool IsCancellationRequested => this.isCancellationRequested; + protected bool IsCancellationRequested => _isCancellationRequested; - protected RunContext RunContext => this.runContext; + protected RunContext RunContext { get; private set; } - protected FrameworkHandle FrameworkHandle => this.frameworkHandle; + protected FrameworkHandle FrameworkHandle { get; private set; } - protected ICollection ExecutorUrisThatRanTests => this.executorUrisThatRanTests; + protected ICollection ExecutorUrisThatRanTests { get; private set; } - #endregion + #endregion - #region Public methods + #region Public methods - public void RunTests() + public void RunTests() + { + using (TestRunCache) { - using (this.testRunCache) + TimeSpan elapsedTime = TimeSpan.Zero; + + Exception exception = null; + bool isAborted = false; + bool shutdownAfterRun = false; + + try { - TimeSpan elapsedTime = TimeSpan.Zero; + // Call Session-Start event on in-proc datacollectors + SendSessionStart(); - Exception exception = null; - bool isAborted = false; - bool shutdownAfterRun = false; + elapsedTime = RunTestsInternal(); - try + // Check the adapter setting for shutting down this process after run + shutdownAfterRun = FrameworkHandle.EnableShutdownAfterTestRun; + } + catch (Exception ex) + { + if (EqtTrace.IsErrorEnabled) { - // Call Session-Start event on in-proc datacollectors - this.SendSessionStart(); + EqtTrace.Error("BaseRunTests.RunTests: Failed to run the tests. Reason: {0}.", ex); + } + + exception = new Exception(ex.Message, ex.InnerException); - elapsedTime = this.RunTestsInternal(); + isAborted = true; + } + finally + { + // Trigger Session End on in-proc datacollectors + SendSessionEnd(); - // Check the adapter setting for shutting down this process after run - shutdownAfterRun = this.frameworkHandle.EnableShutdownAfterTestRun; + try + { + // Send the test run complete event. + RaiseTestRunComplete(exception, _isCancellationRequested, isAborted, shutdownAfterRun, elapsedTime); } - catch (Exception ex) + catch (Exception ex2) { if (EqtTrace.IsErrorEnabled) { - EqtTrace.Error("BaseRunTests.RunTests: Failed to run the tests. Reason: {0}.", ex); + EqtTrace.Error("BaseRunTests.RunTests: Failed to raise runCompletion error. Reason: {0}.", ex2); } - exception = new Exception(ex.Message, ex.InnerException); - - isAborted = true; + // TODO : this does not crash the process currently because of the job queue. + // Let the process crash + throw; } - finally - { - // Trigger Session End on in-proc datacollectors - this.SendSessionEnd(); + } + } - try - { - // Send the test run complete event. - this.RaiseTestRunComplete(exception, this.isCancellationRequested, isAborted, shutdownAfterRun, elapsedTime); - } - catch (Exception ex2) - { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("BaseRunTests.RunTests: Failed to raise runCompletion error. Reason: {0}.", ex2); - } + EqtTrace.Verbose("BaseRunTests.RunTests: Run is complete."); + } - // TODO : this does not crash the process currently because of the job queue. - // Let the process crash - throw; - } - } - } + internal void Abort() + { + EqtTrace.Verbose("BaseRunTests.Abort: Calling RaiseTestRunComplete"); + RaiseTestRunComplete(exception: null, canceled: _isCancellationRequested, aborted: true, adapterHintToShutdownAfterRun: false, elapsedTime: TimeSpan.Zero); + } - EqtTrace.Verbose("BaseRunTests.RunTests: Run is complete."); - } + /// + /// Cancel the current run by setting cancellation token for active executor + /// + internal void Cancel() + { + // Note: Test host delegates the cancellation to active executor and doesn't call HandleTestRunComplete in cancel request. + // Its expected from active executor to respect the cancel request and thus return from RunTests quickly (canceling the tests). + _isCancellationRequested = true; - internal void Abort() + if (_activeExecutor == null) { - EqtTrace.Verbose("BaseRunTests.Abort: Calling RaiseTestRunComplete"); - this.RaiseTestRunComplete(exception: null, canceled: this.isCancellationRequested, aborted: true, adapterHintToShutdownAfterRun: false, elapsedTime: TimeSpan.Zero); + return; } - /// - /// Cancel the current run by setting cancellation token for active executor - /// - internal void Cancel() + if (NotRequiredStaThread() || !TryToRunInStaThread(() => CancelTestRunInternal(_activeExecutor), false)) { - // Note: Test host delegates the cancellation to active executor and doesn't call HandleTestRunComplete in cancel request. - // Its expected from active executor to respect the cancel request and thus return from RunTests quickly (canceling the tests). - this.isCancellationRequested = true; - - if (this.activeExecutor == null) - { - return; - } - - if (this.NotRequiredSTAThread() || !this.TryToRunInSTAThread(() => this.CancelTestRunInternal(this.activeExecutor), false)) - { - Task.Run(() => this.CancelTestRunInternal(this.activeExecutor)); - } + Task.Run(() => CancelTestRunInternal(_activeExecutor)); } + } - #region Abstract methods + #region Abstract methods - protected abstract void BeforeRaisingTestRunComplete(bool exceptionsHitDuringRunTests); + protected abstract void BeforeRaisingTestRunComplete(bool exceptionsHitDuringRunTests); - protected abstract IEnumerable> GetExecutorUriExtensionMap( - IFrameworkHandle testExecutorFrameworkHandle, - RunContext runContext); + protected abstract IEnumerable> GetExecutorUriExtensionMap( + IFrameworkHandle testExecutorFrameworkHandle, + RunContext runContext); - protected abstract void InvokeExecutor( - LazyExtension executor, - Tuple executorUriExtensionTuple, - RunContext runContext, - IFrameworkHandle frameworkHandle); + protected abstract void InvokeExecutor( + LazyExtension executor, + Tuple executorUriExtensionTuple, + RunContext runContext, + IFrameworkHandle frameworkHandle); - /// - /// Asks the adapter about attaching the debugger to the default test host. - /// - /// The executor used to run the tests. - /// The executor URI. - /// The run context. - /// - /// if must attach the debugger to the default test host, - /// otherwise. - /// - protected abstract bool ShouldAttachDebuggerToTestHost( - LazyExtension executor, - Tuple executorUriExtensionTuple, - RunContext runContext); + /// + /// Asks the adapter about attaching the debugger to the default test host. + /// + /// The executor used to run the tests. + /// The executor URI. + /// The run context. + /// + /// if must attach the debugger to the default test host, + /// otherwise. + /// + protected abstract bool ShouldAttachDebuggerToTestHost( + LazyExtension executor, + Tuple executorUriExtensionTuple, + RunContext runContext); - protected abstract void SendSessionStart(); + protected abstract void SendSessionStart(); - protected abstract void SendSessionEnd(); + protected abstract void SendSessionEnd(); - #endregion + #endregion - private void CancelTestRunInternal(ITestExecutor executor) + private void CancelTestRunInternal(ITestExecutor executor) + { + try { - try - { - executor.Cancel(); - } - catch (Exception e) - { - EqtTrace.Info("{0}.Cancel threw an exception: {1} ", executor.GetType().FullName, e); - } + executor.Cancel(); } - #endregion - - #region Private methods - - private void SetContext() + catch (Exception e) { - this.testRunCache = new TestRunCache(this.testExecutionContext.FrequencyOfRunStatsChangeEvent, this.testExecutionContext.RunStatsChangeEventTimeout, this.OnCacheHit); - - this.runContext = new RunContext(); - this.runContext.RunSettings = RunSettingsUtilities.CreateAndInitializeRunSettings(this.runSettings); - this.runContext.KeepAlive = this.testExecutionContext.KeepAlive; - this.runContext.InIsolation = this.testExecutionContext.InIsolation; - this.runContext.IsDataCollectionEnabled = this.testExecutionContext.IsDataCollectionEnabled; - this.runContext.IsBeingDebugged = this.testExecutionContext.IsDebug; - - var runConfig = XmlRunSettingsUtilities.GetRunConfigurationNode(this.runSettings); - this.runContext.TestRunDirectory = RunSettingsUtilities.GetTestResultsDirectory(runConfig); - this.runContext.SolutionDirectory = RunSettingsUtilities.GetSolutionDirectory(runConfig); - this.runConfiguration = runConfig; - - this.frameworkHandle = new FrameworkHandle( - this.testCaseEventsHandler, - this.testRunCache, - this.testExecutionContext, - this.testRunEventsHandler); - this.frameworkHandle.TestRunMessage += this.OnTestRunMessage; - - this.executorUrisThatRanTests = new List(); + EqtTrace.Info("{0}.Cancel threw an exception: {1} ", executor.GetType().FullName, e); } + } + #endregion - private void OnTestRunMessage(object sender, TestRunMessageEventArgs e) - { - this.testRunEventsHandler.HandleLogMessage(e.Level, e.Message); - } + #region Private methods - private TimeSpan RunTestsInternal() - { - long totalTests = 0; + private void SetContext() + { + TestRunCache = new TestRunCache(TestExecutionContext.FrequencyOfRunStatsChangeEvent, TestExecutionContext.RunStatsChangeEventTimeout, OnCacheHit); + + RunContext = new RunContext(); + RunContext.RunSettings = RunSettingsUtilities.CreateAndInitializeRunSettings(RunSettings); + RunContext.KeepAlive = TestExecutionContext.KeepAlive; + RunContext.InIsolation = TestExecutionContext.InIsolation; + RunContext.IsDataCollectionEnabled = TestExecutionContext.IsDataCollectionEnabled; + RunContext.IsBeingDebugged = TestExecutionContext.IsDebug; + + var runConfig = XmlRunSettingsUtilities.GetRunConfigurationNode(RunSettings); + RunContext.TestRunDirectory = RunSettingsUtilities.GetTestResultsDirectory(runConfig); + RunContext.SolutionDirectory = RunSettingsUtilities.GetSolutionDirectory(runConfig); + _runConfiguration = runConfig; + + FrameworkHandle = new FrameworkHandle( + _testCaseEventsHandler, + TestRunCache, + TestExecutionContext, + TestRunEventsHandler); + FrameworkHandle.TestRunMessage += OnTestRunMessage; + + ExecutorUrisThatRanTests = new List(); + } - var executorUriExtensionMap = this.GetExecutorUriExtensionMap(this.frameworkHandle, this.runContext); + private void OnTestRunMessage(object sender, TestRunMessageEventArgs e) + { + TestRunEventsHandler.HandleLogMessage(e.Level, e.Message); + } - // Set on the logger the TreatAdapterErrorAsWarning setting from runsettings. - this.SetAdapterLoggingSettings(); + private TimeSpan RunTestsInternal() + { + long totalTests = 0; - var stopwatch = new Stopwatch(); - stopwatch.Start(); - this.testPlatformEventSource.ExecutionStart(); - var exceptionsHitDuringRunTests = this.RunTestInternalWithExecutors( - executorUriExtensionMap, - totalTests); + var executorUriExtensionMap = GetExecutorUriExtensionMap(FrameworkHandle, RunContext); - stopwatch.Stop(); - this.testPlatformEventSource.ExecutionStop(this.testRunCache.TotalExecutedTests); - this.BeforeRaisingTestRunComplete(exceptionsHitDuringRunTests); - return stopwatch.Elapsed; - } + // Set on the logger the TreatAdapterErrorAsWarning setting from runsettings. + SetAdapterLoggingSettings(); - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "This methods must call all possible executors and not fail on crash in any executor.")] - private bool RunTestInternalWithExecutors(IEnumerable> executorUriExtensionMap, long totalTests) - { - // Collecting Total Number of Adapters Discovered in Machine. - this.requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringExecution, executorUriExtensionMap.Count()); + var stopwatch = new Stopwatch(); + stopwatch.Start(); + _testPlatformEventSource.ExecutionStart(); + var exceptionsHitDuringRunTests = RunTestInternalWithExecutors( + executorUriExtensionMap, + totalTests); - var attachedToTestHost = false; - var executorCache = new Dictionary>(); - foreach (var executorUriExtensionTuple in executorUriExtensionMap) + stopwatch.Stop(); + _testPlatformEventSource.ExecutionStop(TestRunCache.TotalExecutedTests); + BeforeRaisingTestRunComplete(exceptionsHitDuringRunTests); + return stopwatch.Elapsed; + } + + private bool RunTestInternalWithExecutors(IEnumerable> executorUriExtensionMap, long totalTests) + { + // Collecting Total Number of Adapters Discovered in Machine. + _requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringExecution, executorUriExtensionMap.Count()); + + var attachedToTestHost = false; + var executorCache = new Dictionary>(); + foreach (var executorUriExtensionTuple in executorUriExtensionMap) + { + // Avoid processing the same executor twice. + if (executorCache.ContainsKey(executorUriExtensionTuple.Item1.AbsoluteUri)) { - // Avoid processing the same executor twice. - if (executorCache.ContainsKey(executorUriExtensionTuple.Item1.AbsoluteUri)) - { - continue; - } + continue; + } - // Get the extension manager. - var extensionManager = this.GetExecutorExtensionManager(executorUriExtensionTuple.Item2); + // Get the extension manager. + var extensionManager = GetExecutorExtensionManager(executorUriExtensionTuple.Item2); - // Look up the executor. - var executor = extensionManager.TryGetTestExtension(executorUriExtensionTuple.Item1); - if (executor == null) - { - // Commenting this out because of a compatibility issue with Microsoft.Dotnet.ProjectModel released on nuGet.org. - // this.activeExecutor = null; - // var runtimeVersion = string.Concat(PlatformServices.Default.Runtime.RuntimeType, " ", - // PlatformServices.Default.Runtime.RuntimeVersion); - var runtimeVersion = " "; - this.TestRunEventsHandler?.HandleLogMessage( - TestMessageLevel.Warning, - string.Format( - CultureInfo.CurrentUICulture, - CrossPlatEngineResources.NoMatchingExecutor, - executorUriExtensionTuple.Item1.AbsoluteUri, - runtimeVersion)); + // Look up the executor. + var executor = extensionManager.TryGetTestExtension(executorUriExtensionTuple.Item1); + if (executor == null) + { + // Commenting this out because of a compatibility issue with Microsoft.Dotnet.ProjectModel released on nuGet.org. + // this.activeExecutor = null; + // var runtimeVersion = string.Concat(PlatformServices.Default.Runtime.RuntimeType, " ", + // PlatformServices.Default.Runtime.RuntimeVersion); + var runtimeVersion = " "; + TestRunEventsHandler?.HandleLogMessage( + TestMessageLevel.Warning, + string.Format( + CultureInfo.CurrentUICulture, + CrossPlatEngineResources.NoMatchingExecutor, + executorUriExtensionTuple.Item1.AbsoluteUri, + runtimeVersion)); - continue; - } + continue; + } - // Cache the executor. - executorCache.Add(executorUriExtensionTuple.Item1.AbsoluteUri, executor); + // Cache the executor. + executorCache.Add(executorUriExtensionTuple.Item1.AbsoluteUri, executor); - // Check if we actually have to attach to the default test host. - if (!this.runContext.IsBeingDebugged || attachedToTestHost) - { - // We already know we should attach to the default test host, simply continue. - continue; - } + // Check if we actually have to attach to the default test host. + if (!RunContext.IsBeingDebugged || attachedToTestHost) + { + // We already know we should attach to the default test host, simply continue. + continue; + } - // If there's at least one adapter in the filtered adapters list that doesn't - // implement the new test executor interface, we should attach to the default test - // host by default. - // Same goes if all adapters implement the new test executor interface but at - // least one of them needs the test platform to attach to the default test host. - if (!(executor.Value is ITestExecutor2) - || this.ShouldAttachDebuggerToTestHost(executor, executorUriExtensionTuple, this.runContext)) - { - EqtTrace.Verbose("Attaching to default test host."); + // If there's at least one adapter in the filtered adapters list that doesn't + // implement the new test executor interface, we should attach to the default test + // host by default. + // Same goes if all adapters implement the new test executor interface but at + // least one of them needs the test platform to attach to the default test host. + if (!(executor.Value is ITestExecutor2) + || ShouldAttachDebuggerToTestHost(executor, executorUriExtensionTuple, RunContext)) + { + EqtTrace.Verbose("Attaching to default test host."); - attachedToTestHost = true; - var pid = Process.GetCurrentProcess().Id; - if (!this.frameworkHandle.AttachDebuggerToProcess(pid)) - { - EqtTrace.Warning( - string.Format( - CultureInfo.CurrentUICulture, - CrossPlatEngineResources.AttachDebuggerToDefaultTestHostFailure, - pid)); - } + attachedToTestHost = true; + var pid = Process.GetCurrentProcess().Id; + if (!FrameworkHandle.AttachDebuggerToProcess(pid)) + { + EqtTrace.Warning( + string.Format( + CultureInfo.CurrentUICulture, + CrossPlatEngineResources.AttachDebuggerToDefaultTestHostFailure, + pid)); } } + } - // Call the executor for each group of tests. - var exceptionsHitDuringRunTests = false; - var executorsFromDeprecatedLocations = false; - double totalTimeTakenByAdapters = 0; + // Call the executor for each group of tests. + var exceptionsHitDuringRunTests = false; + var executorsFromDeprecatedLocations = false; + double totalTimeTakenByAdapters = 0; + + foreach (var executorUriExtensionTuple in executorUriExtensionMap) + { + var executorUri = executorUriExtensionTuple.Item1.AbsoluteUri; + // Get the executor from the cache. + if (!executorCache.TryGetValue(executorUri, out var executor)) + { + continue; + } - foreach (var executorUriExtensionTuple in executorUriExtensionMap) + try { - var executorUri = executorUriExtensionTuple.Item1.AbsoluteUri; - // Get the executor from the cache. - if (!executorCache.TryGetValue(executorUri, out var executor)) + if (EqtTrace.IsVerboseEnabled) { - continue; + EqtTrace.Verbose( + "BaseRunTests.RunTestInternalWithExecutors: Running tests for {0}", + executor.Metadata.ExtensionUri); } - try + // set the active executor + _activeExecutor = executor.Value; + + // If test run cancellation is requested, skip the next executor + if (_isCancellationRequested) { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose( - "BaseRunTests.RunTestInternalWithExecutors: Running tests for {0}", - executor.Metadata.ExtensionUri); - } + break; + } - // set the active executor - this.activeExecutor = executor.Value; + var timeStartNow = DateTime.UtcNow; - // If test run cancellation is requested, skip the next executor - if (this.isCancellationRequested) - { - break; - } + var currentTotalTests = TestRunCache.TotalExecutedTests; + _testPlatformEventSource.AdapterExecutionStart(executorUri); - var timeStartNow = DateTime.UtcNow; + // Run the tests. + if (NotRequiredStaThread() || !TryToRunInStaThread(() => InvokeExecutor(executor, executorUriExtensionTuple, RunContext, FrameworkHandle), true)) + { + InvokeExecutor(executor, executorUriExtensionTuple, RunContext, FrameworkHandle); + } - var currentTotalTests = this.testRunCache.TotalExecutedTests; - this.testPlatformEventSource.AdapterExecutionStart(executorUri); + _testPlatformEventSource.AdapterExecutionStop(TestRunCache.TotalExecutedTests - currentTotalTests); - // Run the tests. - if (this.NotRequiredSTAThread() || !this.TryToRunInSTAThread(() => this.InvokeExecutor(executor, executorUriExtensionTuple, this.runContext, this.frameworkHandle), true)) - { - this.InvokeExecutor(executor, executorUriExtensionTuple, this.runContext, this.frameworkHandle); - } + var totalTimeTaken = DateTime.UtcNow - timeStartNow; - this.testPlatformEventSource.AdapterExecutionStop(this.testRunCache.TotalExecutedTests - currentTotalTests); + // Identify whether the executor did run any tests at all + if (TestRunCache.TotalExecutedTests > totalTests) + { + ExecutorUrisThatRanTests.Add(executorUri); - var totalTimeTaken = DateTime.UtcNow - timeStartNow; + // Collecting Total Tests Ran by each Adapter + var totalTestRun = TestRunCache.TotalExecutedTests - totalTests; + _requestData.MetricsCollection.Add(string.Format("{0}.{1}", TelemetryDataConstants.TotalTestsRanByAdapter, executorUri), totalTestRun); - // Identify whether the executor did run any tests at all - if (this.testRunCache.TotalExecutedTests > totalTests) + // Only enable this for MSTestV1 telemetry for now, this might become more generic later. + if (MsTestV1TelemetryHelper.IsMsTestV1Adapter(executorUri)) { - this.executorUrisThatRanTests.Add(executorUri); - - // Collecting Total Tests Ran by each Adapter - var totalTestRun = this.testRunCache.TotalExecutedTests - totalTests; - this.requestData.MetricsCollection.Add(string.Format("{0}.{1}", TelemetryDataConstants.TotalTestsRanByAdapter, executorUri), totalTestRun); - - // Only enable this for MSTestV1 telemetry for now, this might become more generic later. - if (MSTestV1TelemetryHelper.IsMSTestV1Adapter(executorUri)) + foreach (var adapterMetrics in TestRunCache.AdapterTelemetry.Keys.Where(k => k.StartsWith(executorUri))) { - foreach (var adapterMetrics in this.testRunCache.AdapterTelemetry.Keys.Where(k => k.StartsWith(executorUri))) - { - var value = this.testRunCache.AdapterTelemetry[adapterMetrics]; + var value = TestRunCache.AdapterTelemetry[adapterMetrics]; - this.requestData.MetricsCollection.Add(string.Format("{0}.{1}", TelemetryDataConstants.TotalTestsRunByMSTestv1, adapterMetrics), value); - } + _requestData.MetricsCollection.Add(string.Format("{0}.{1}", TelemetryDataConstants.TotalTestsRunByMSTestv1, adapterMetrics), value); } - - if (!CrossPlatEngine.Constants.DefaultAdapters.Contains(executor.Metadata.ExtensionUri, StringComparer.OrdinalIgnoreCase)) - { - var executorLocation = executor.Value.GetType().GetTypeInfo().Assembly.GetAssemblyLocation(); - - executorsFromDeprecatedLocations |= Path.GetDirectoryName(executorLocation).Equals(CrossPlatEngine.Constants.DefaultAdapterLocation); - } - - totalTests = this.testRunCache.TotalExecutedTests; } - if (EqtTrace.IsVerboseEnabled) + if (!CrossPlatEngine.Constants.DefaultAdapters.Contains(executor.Metadata.ExtensionUri, StringComparer.OrdinalIgnoreCase)) { - EqtTrace.Verbose( - "BaseRunTests.RunTestInternalWithExecutors: Completed running tests for {0}", - executor.Metadata.ExtensionUri); + var executorLocation = executor.Value.GetType().GetTypeInfo().Assembly.GetAssemblyLocation(); + + executorsFromDeprecatedLocations |= Path.GetDirectoryName(executorLocation).Equals(CrossPlatEngine.Constants.DefaultAdapterLocation); } - // Collecting Time Taken by each executor Uri - this.requestData.MetricsCollection.Add(string.Format("{0}.{1}", TelemetryDataConstants.TimeTakenToRunTestsByAnAdapter, executorUri), totalTimeTaken.TotalSeconds); - totalTimeTakenByAdapters += totalTimeTaken.TotalSeconds; + totalTests = TestRunCache.TotalExecutedTests; } - catch (Exception e) + + if (EqtTrace.IsVerboseEnabled) { - string exceptionMessage = (e is UnauthorizedAccessException) - ? string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.AccessDenied, e.Message) - : ExceptionUtilities.GetExceptionMessage(e); + EqtTrace.Verbose( + "BaseRunTests.RunTestInternalWithExecutors: Completed running tests for {0}", + executor.Metadata.ExtensionUri); + } - exceptionsHitDuringRunTests = true; + // Collecting Time Taken by each executor Uri + _requestData.MetricsCollection.Add(string.Format("{0}.{1}", TelemetryDataConstants.TimeTakenToRunTestsByAnAdapter, executorUri), totalTimeTaken.TotalSeconds); + totalTimeTakenByAdapters += totalTimeTaken.TotalSeconds; + } + catch (Exception e) + { + string exceptionMessage = (e is UnauthorizedAccessException) + ? string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.AccessDenied, e.Message) + : ExceptionUtilities.GetExceptionMessage(e); - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error( - "BaseRunTests.RunTestInternalWithExecutors: An exception occurred while invoking executor {0}. {1}.", - executorUriExtensionTuple.Item1, - e); - } + exceptionsHitDuringRunTests = true; - this.TestRunEventsHandler?.HandleLogMessage( - TestMessageLevel.Error, - string.Format( - CultureInfo.CurrentCulture, - CrossPlatEngineResources.ExceptionFromRunTests, - executorUriExtensionTuple.Item1, - exceptionMessage)); - } - finally + if (EqtTrace.IsErrorEnabled) { - this.activeExecutor = null; + EqtTrace.Error( + "BaseRunTests.RunTestInternalWithExecutors: An exception occurred while invoking executor {0}. {1}.", + executorUriExtensionTuple.Item1, + e); } - } - // Collecting Total Time Taken by Adapters - this.requestData.MetricsCollection.Add(TelemetryDataConstants.TimeTakenByAllAdaptersInSec, totalTimeTakenByAdapters); - - if (executorsFromDeprecatedLocations) + TestRunEventsHandler?.HandleLogMessage( + TestMessageLevel.Error, + string.Format( + CultureInfo.CurrentCulture, + CrossPlatEngineResources.ExceptionFromRunTests, + executorUriExtensionTuple.Item1, + exceptionMessage)); + } + finally { - this.TestRunEventsHandler?.HandleLogMessage(TestMessageLevel.Warning, string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.DeprecatedAdapterPath)); + _activeExecutor = null; } - - return exceptionsHitDuringRunTests; } - private bool NotRequiredSTAThread() + // Collecting Total Time Taken by Adapters + _requestData.MetricsCollection.Add(TelemetryDataConstants.TimeTakenByAllAdaptersInSec, totalTimeTakenByAdapters); + + if (executorsFromDeprecatedLocations) { - return this.runConfiguration.ExecutionThreadApartmentState != PlatformApartmentState.STA; + TestRunEventsHandler?.HandleLogMessage(TestMessageLevel.Warning, string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.DeprecatedAdapterPath)); } - private TestExecutorExtensionManager GetExecutorExtensionManager(string extensionAssembly) + return exceptionsHitDuringRunTests; + } + + private bool NotRequiredStaThread() + { + return _runConfiguration.ExecutionThreadApartmentState != PlatformApartmentState.STA; + } + + private TestExecutorExtensionManager GetExecutorExtensionManager(string extensionAssembly) + { + try { - try + if (string.IsNullOrEmpty(extensionAssembly) + || string.Equals(extensionAssembly, Constants.UnspecifiedAdapterPath)) { - if (string.IsNullOrEmpty(extensionAssembly) - || string.Equals(extensionAssembly, Constants.UnspecifiedAdapterPath)) - { - // full execution. Since the extension manager is cached this can be created multiple times without harming performance. - return TestExecutorExtensionManager.Create(); - } - else - { - return TestExecutorExtensionManager.GetExecutionExtensionManager(extensionAssembly); - } + // full execution. Since the extension manager is cached this can be created multiple times without harming performance. + return TestExecutorExtensionManager.Create(); } - catch (Exception ex) + else { - EqtTrace.Error( - "BaseRunTests: GetExecutorExtensionManager: Exception occurred while loading extensions {0}", - ex); - - return null; + return TestExecutorExtensionManager.GetExecutionExtensionManager(extensionAssembly); } } - - private void SetAdapterLoggingSettings() + catch (Exception ex) { - // TODO: enable the below once runsettings is in. - // var sessionMessageLogger = testExecutorFrameworkHandle as TestSessionMessageLogger; - // if (sessionMessageLogger != null - // && testExecutionContext != null - // && testExecutionContext.TestRunConfiguration != null) - // { - // sessionMessageLogger.TreatTestAdapterErrorsAsWarnings - // = testExecutionContext.TestRunConfiguration.TreatTestAdapterErrorsAsWarnings; - // } + EqtTrace.Error( + "BaseRunTests: GetExecutorExtensionManager: Exception occurred while loading extensions {0}", + ex); + + return null; } + } - private void RaiseTestRunComplete( - Exception exception, - bool canceled, - bool aborted, - bool adapterHintToShutdownAfterRun, - TimeSpan elapsedTime) - { - var runStats = this.testRunCache?.TestRunStatistics ?? new TestRunStatistics(new Dictionary()); - var lastChunkTestResults = this.testRunCache?.GetLastChunk() ?? new List(); + private void SetAdapterLoggingSettings() + { + // TODO: enable the below once runsettings is in. + // var sessionMessageLogger = testExecutorFrameworkHandle as TestSessionMessageLogger; + // if (sessionMessageLogger != null + // && testExecutionContext != null + // && testExecutionContext.TestRunConfiguration != null) + // { + // sessionMessageLogger.TreatTestAdapterErrorsAsWarnings + // = testExecutionContext.TestRunConfiguration.TreatTestAdapterErrorsAsWarnings; + // } + } - if (this.testRunEventsHandler != null) - { - // Collecting Total Tests Run - this.requestData.MetricsCollection.Add(TelemetryDataConstants.TotalTestsRun, runStats.ExecutedTests); + private void RaiseTestRunComplete( + Exception exception, + bool canceled, + bool aborted, + bool adapterHintToShutdownAfterRun, + TimeSpan elapsedTime) + { + var runStats = TestRunCache?.TestRunStatistics ?? new TestRunStatistics(new Dictionary()); + var lastChunkTestResults = TestRunCache?.GetLastChunk() ?? new List(); - // Collecting Test Run State - this.requestData.MetricsCollection.Add(TelemetryDataConstants.RunState, canceled ? "Canceled" : (aborted ? "Aborted" : "Completed")); + if (TestRunEventsHandler != null) + { + // Collecting Total Tests Run + _requestData.MetricsCollection.Add(TelemetryDataConstants.TotalTestsRun, runStats.ExecutedTests); - // Collecting Number of Adapters Used to run tests. - this.requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfAdapterUsedToRunTests, this.ExecutorUrisThatRanTests.Count); + // Collecting Test Run State + _requestData.MetricsCollection.Add(TelemetryDataConstants.RunState, canceled ? "Canceled" : (aborted ? "Aborted" : "Completed")); - if (lastChunkTestResults.Any() && this.IsTestSourceIsPackage()) - { - this.UpdateTestCaseSourceToPackage(lastChunkTestResults, null, out lastChunkTestResults, out var updatedTestCases); - } + // Collecting Number of Adapters Used to run tests. + _requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfAdapterUsedToRunTests, ExecutorUrisThatRanTests.Count); - var testRunChangedEventArgs = new TestRunChangedEventArgs(runStats, lastChunkTestResults, Enumerable.Empty()); - - // Adding Metrics along with Test Run Complete Event Args - Collection attachments = this.frameworkHandle?.Attachments; - var testRunCompleteEventArgs = new TestRunCompleteEventArgs( - runStats, - canceled, - aborted, - exception, - attachments, - // Today we don't offer an extension to run collectors for test adapters. - new Collection(), - elapsedTime); - testRunCompleteEventArgs.Metrics = this.requestData.MetricsCollection.Metrics; - - this.testRunEventsHandler.HandleTestRunComplete( - testRunCompleteEventArgs, - testRunChangedEventArgs, - attachments, - this.executorUrisThatRanTests); - } - else + if (lastChunkTestResults.Any() && IsTestSourceIsPackage()) { - EqtTrace.Warning("Could not pass run completion as the callback is null. Aborted :{0}", aborted); + UpdateTestCaseSourceToPackage(lastChunkTestResults, null, out lastChunkTestResults, out _); } - } - private bool IsTestSourceIsPackage() + var testRunChangedEventArgs = new TestRunChangedEventArgs(runStats, lastChunkTestResults, Enumerable.Empty()); + + // Adding Metrics along with Test Run Complete Event Args + Collection attachments = FrameworkHandle?.Attachments; + var testRunCompleteEventArgs = new TestRunCompleteEventArgs( + runStats, + canceled, + aborted, + exception, + attachments, + // Today we don't offer an extension to run collectors for test adapters. + new Collection(), + elapsedTime); + testRunCompleteEventArgs.Metrics = _requestData.MetricsCollection.Metrics; + + TestRunEventsHandler.HandleTestRunComplete( + testRunCompleteEventArgs, + testRunChangedEventArgs, + attachments, + ExecutorUrisThatRanTests); + } + else { - return !string.IsNullOrEmpty(this.package); + EqtTrace.Warning("Could not pass run completion as the callback is null. Aborted :{0}", aborted); } + } - private void OnCacheHit(TestRunStatistics testRunStats, ICollection results, ICollection inProgressTestCases) - { - if (this.testRunEventsHandler != null) - { - if (this.IsTestSourceIsPackage()) - { - this.UpdateTestCaseSourceToPackage(results, inProgressTestCases, out results, out inProgressTestCases); - } + private bool IsTestSourceIsPackage() + { + return !string.IsNullOrEmpty(_package); + } - var testRunChangedEventArgs = new TestRunChangedEventArgs(testRunStats, results, inProgressTestCases); - this.testRunEventsHandler.HandleTestRunStatsChange(testRunChangedEventArgs); - } - else + private void OnCacheHit(TestRunStatistics testRunStats, ICollection results, ICollection inProgressTestCases) + { + if (TestRunEventsHandler != null) + { + if (IsTestSourceIsPackage()) { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("BaseRunTests.OnCacheHit: Unable to send TestRunStatsChange Event as TestRunEventsHandler is NULL"); - } + UpdateTestCaseSourceToPackage(results, inProgressTestCases, out results, out inProgressTestCases); } - } - private bool TryToRunInSTAThread(Action action, bool waitForCompletion) + var testRunChangedEventArgs = new TestRunChangedEventArgs(testRunStats, results, inProgressTestCases); + TestRunEventsHandler.HandleTestRunStatsChange(testRunChangedEventArgs); + } + else { - bool success = true; - try + if (EqtTrace.IsErrorEnabled) { - EqtTrace.Verbose("BaseRunTests.TryToRunInSTAThread: Using STA thread to call adapter API."); - this.platformThread.Run(action, PlatformApartmentState.STA, waitForCompletion); + EqtTrace.Error("BaseRunTests.OnCacheHit: Unable to send TestRunStatsChange Event as TestRunEventsHandler is NULL"); } - catch (ThreadApartmentStateNotSupportedException ex) - { - success = false; - EqtTrace.Warning("BaseRunTests.TryToRunInSTAThread: Failed to run in STA thread: {0}", ex); - this.TestRunEventsHandler.HandleLogMessage( - TestMessageLevel.Warning, - string.Format(CultureInfo.CurrentUICulture, Resources.ExecutionThreadApartmentStateNotSupportedForFramework, this.runConfiguration.TargetFramework.ToString())); - } - - return success; } + } - private void UpdateTestCaseSourceToPackage( - ICollection testResults, - ICollection inProgressTestCases, - out ICollection updatedTestResults, - out ICollection updatedInProgressTestCases) + private bool TryToRunInStaThread(Action action, bool waitForCompletion) + { + bool success = true; + try { - EqtTrace.Verbose("BaseRunTests.UpdateTestCaseSourceToPackage: Update source details for testResults and testCases."); - - updatedTestResults = this.UpdateTestResults(testResults, this.package); - updatedInProgressTestCases = this.UpdateInProgressTests(inProgressTestCases, this.package); + EqtTrace.Verbose("BaseRunTests.TryToRunInSTAThread: Using STA thread to call adapter API."); + _platformThread.Run(action, PlatformApartmentState.STA, waitForCompletion); } - - private ICollection UpdateTestResults(ICollection testResults, string package) + catch (ThreadApartmentStateNotSupportedException ex) { - ICollection updatedTestResults = new List(); + success = false; + EqtTrace.Warning("BaseRunTests.TryToRunInSTAThread: Failed to run in STA thread: {0}", ex); + TestRunEventsHandler.HandleLogMessage( + TestMessageLevel.Warning, + string.Format(CultureInfo.CurrentUICulture, CrossPlatEngineResources.ExecutionThreadApartmentStateNotSupportedForFramework, _runConfiguration.TargetFramework.ToString())); + } - foreach (var testResult in testResults) - { - var updatedTestResult = this.dataSerializer.Clone(testResult); - updatedTestResult.TestCase.Source = package; - updatedTestResults.Add(updatedTestResult); - } + return success; + } - return updatedTestResults; - } + private void UpdateTestCaseSourceToPackage( + ICollection testResults, + ICollection inProgressTestCases, + out ICollection updatedTestResults, + out ICollection updatedInProgressTestCases) + { + EqtTrace.Verbose("BaseRunTests.UpdateTestCaseSourceToPackage: Update source details for testResults and testCases."); + + updatedTestResults = UpdateTestResults(testResults, _package); + updatedInProgressTestCases = UpdateInProgressTests(inProgressTestCases, _package); + } + + private ICollection UpdateTestResults(ICollection testResults, string package) + { + ICollection updatedTestResults = new List(); - private ICollection UpdateInProgressTests(ICollection inProgressTestCases, string package) + foreach (var testResult in testResults) { - if (inProgressTestCases == null) - { - return null; - } + var updatedTestResult = _dataSerializer.Clone(testResult); + updatedTestResult.TestCase.Source = package; + updatedTestResults.Add(updatedTestResult); + } - ICollection updatedTestCases = new List(); - foreach (var inProgressTestCase in inProgressTestCases) - { - var updatedTestCase = this.dataSerializer.Clone(inProgressTestCase); - updatedTestCase.Source = package; - updatedTestCases.Add(updatedTestCase); - } + return updatedTestResults; + } - return updatedTestCases; + private ICollection UpdateInProgressTests(ICollection inProgressTestCases, string package) + { + if (inProgressTestCases == null) + { + return null; } - #endregion + ICollection updatedTestCases = new List(); + foreach (var inProgressTestCase in inProgressTestCases) + { + var updatedTestCase = _dataSerializer.Clone(inProgressTestCase); + updatedTestCase.Source = package; + updatedTestCases.Add(updatedTestCase); + } + + return updatedTestCases; } + + #endregion } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs index 332da35a3e..84a029ef41 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs @@ -1,252 +1,251 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; + +using System; +using System.Collections.Generic; +using System.Linq; + +using Common.ExtensionFramework; +using Common.Logging; +using Common.SettingsProvider; +using CommunicationUtilities; +using CoreUtilities.Tracing; +using CoreUtilities.Tracing.Interfaces; +using DataCollection; +using DataCollection.Interfaces; +using Utilities; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; +using ObjectModel.Engine.ClientProtocol; +using ObjectModel.Engine.TesthostProtocol; +using ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; + +/// +/// Orchestrates test execution related functionality for the engine communicating with the test host process. +/// +public class ExecutionManager : IExecutionManager { - using System; - using System.Collections.Generic; - using System.Linq; - - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.Common.SettingsProvider; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; + private readonly ITestPlatformEventSource _testPlatformEventSource; + private BaseRunTests _activeTestRun; + private readonly IRequestData _requestData; + private readonly TestSessionMessageLogger _sessionMessageLogger; + private ITestMessageEventHandler _testMessageEventsHandler; /// - /// Orchestrates test execution related functionality for the engine communicating with the test host process. + /// Initializes a new instance of the class. /// - public class ExecutionManager : IExecutionManager + public ExecutionManager(IRequestData requestData) : this(TestPlatformEventSource.Instance, requestData) { - private readonly ITestPlatformEventSource testPlatformEventSource; - private BaseRunTests activeTestRun; - private IRequestData requestData; - private readonly TestSessionMessageLogger sessionMessageLogger; - private ITestMessageEventHandler testMessageEventsHandler; + _sessionMessageLogger = TestSessionMessageLogger.Instance; + _sessionMessageLogger.TestRunMessage += TestSessionMessageHandler; + } - /// - /// Initializes a new instance of the class. - /// - public ExecutionManager(IRequestData requestData) : this(TestPlatformEventSource.Instance, requestData) - { - this.sessionMessageLogger = TestSessionMessageLogger.Instance; - this.sessionMessageLogger.TestRunMessage += this.TestSessionMessageHandler; - } + /// + /// Initializes a new instance of the class. + /// + /// Test platform event source. + protected ExecutionManager(ITestPlatformEventSource testPlatformEventSource, IRequestData requestData) + { + _testPlatformEventSource = testPlatformEventSource; + _requestData = requestData; + } - /// - /// Initializes a new instance of the class. - /// - /// Test platform event source. - protected ExecutionManager(ITestPlatformEventSource testPlatformEventSource, IRequestData requestData) - { - this.testPlatformEventSource = testPlatformEventSource; - this.requestData = requestData; - } + #region IExecutionManager Implementation - #region IExecutionManager Implementation + /// + /// Initializes the execution manager. + /// + /// The path to additional extensions. + public void Initialize(IEnumerable pathToAdditionalExtensions, ITestMessageEventHandler testMessageEventsHandler) + { + _testMessageEventsHandler = testMessageEventsHandler; + _testPlatformEventSource.AdapterSearchStart(); - /// - /// Initializes the execution manager. - /// - /// The path to additional extensions. - public void Initialize(IEnumerable pathToAdditionalExtensions, ITestMessageEventHandler testMessageEventsHandler) + if (pathToAdditionalExtensions != null && pathToAdditionalExtensions.Any()) { - this.testMessageEventsHandler = testMessageEventsHandler; - this.testPlatformEventSource.AdapterSearchStart(); - - if (pathToAdditionalExtensions != null && pathToAdditionalExtensions.Any()) - { - // Start using these additional extensions - TestPluginCache.Instance.DefaultExtensionPaths = pathToAdditionalExtensions; - } + // Start using these additional extensions + TestPluginCache.Instance.DefaultExtensionPaths = pathToAdditionalExtensions; + } - this.LoadExtensions(); + LoadExtensions(); - //unsubscribe session logger - this.sessionMessageLogger.TestRunMessage -= this.TestSessionMessageHandler; + //unsubscribe session logger + _sessionMessageLogger.TestRunMessage -= TestSessionMessageHandler; - this.testPlatformEventSource.AdapterSearchStop(); - } + _testPlatformEventSource.AdapterSearchStop(); + } - /// - /// Starts the test run - /// - /// The adapter Source Map. - /// The user input test source(package) if it differ from actual test source otherwise null. - /// The run Settings. - /// The test Execution Context. - /// EventHandler for handling test cases level events from Engine. - /// EventHandler for handling execution events from Engine. - public void StartTestRun( - Dictionary> adapterSourceMap, - string package, - string runSettings, - TestExecutionContext testExecutionContext, - ITestCaseEventsHandler testCaseEventsHandler, - ITestRunEventsHandler runEventsHandler) + /// + /// Starts the test run + /// + /// The adapter Source Map. + /// The user input test source(package) if it differ from actual test source otherwise null. + /// The run Settings. + /// The test Execution Context. + /// EventHandler for handling test cases level events from Engine. + /// EventHandler for handling execution events from Engine. + public void StartTestRun( + Dictionary> adapterSourceMap, + string package, + string runSettings, + TestExecutionContext testExecutionContext, + ITestCaseEventsHandler testCaseEventsHandler, + ITestRunEventsHandler runEventsHandler) + { + try { - try - { - this.InitializeDataCollectors(runSettings, testCaseEventsHandler as ITestEventsPublisher, TestSourcesUtility.GetDefaultCodebasePath(adapterSourceMap)); + InitializeDataCollectors(runSettings, testCaseEventsHandler as ITestEventsPublisher, TestSourcesUtility.GetDefaultCodebasePath(adapterSourceMap)); - this.activeTestRun = new RunTestsWithSources(this.requestData, adapterSourceMap, package, runSettings, testExecutionContext, testCaseEventsHandler, runEventsHandler); + _activeTestRun = new RunTestsWithSources(_requestData, adapterSourceMap, package, runSettings, testExecutionContext, testCaseEventsHandler, runEventsHandler); - this.activeTestRun.RunTests(); - } - catch (Exception e) - { - runEventsHandler.HandleLogMessage(TestMessageLevel.Error, e.ToString()); - this.Abort(runEventsHandler); - } - finally - { - this.activeTestRun = null; - } + _activeTestRun.RunTests(); + } + catch (Exception e) + { + runEventsHandler.HandleLogMessage(TestMessageLevel.Error, e.ToString()); + Abort(runEventsHandler); } + finally + { + _activeTestRun = null; + } + } - /// - /// Starts the test run with tests. - /// - /// The test list. - /// The user input test source(package) if it differ from actual test source otherwise null. - /// The run Settings. - /// The test Execution Context. - /// EventHandler for handling test cases level events from Engine. - /// EventHandler for handling execution events from Engine. - public void StartTestRun( - IEnumerable tests, - string package, - string runSettings, - TestExecutionContext testExecutionContext, - ITestCaseEventsHandler testCaseEventsHandler, - ITestRunEventsHandler runEventsHandler) - { - try - { - this.InitializeDataCollectors(runSettings, testCaseEventsHandler as ITestEventsPublisher, TestSourcesUtility.GetDefaultCodebasePath(tests)); + /// + /// Starts the test run with tests. + /// + /// The test list. + /// The user input test source(package) if it differ from actual test source otherwise null. + /// The run Settings. + /// The test Execution Context. + /// EventHandler for handling test cases level events from Engine. + /// EventHandler for handling execution events from Engine. + public void StartTestRun( + IEnumerable tests, + string package, + string runSettings, + TestExecutionContext testExecutionContext, + ITestCaseEventsHandler testCaseEventsHandler, + ITestRunEventsHandler runEventsHandler) + { + try + { + InitializeDataCollectors(runSettings, testCaseEventsHandler as ITestEventsPublisher, TestSourcesUtility.GetDefaultCodebasePath(tests)); - this.activeTestRun = new RunTestsWithTests(this.requestData, tests, package, runSettings, testExecutionContext, testCaseEventsHandler, runEventsHandler); + _activeTestRun = new RunTestsWithTests(_requestData, tests, package, runSettings, testExecutionContext, testCaseEventsHandler, runEventsHandler); - this.activeTestRun.RunTests(); - } - catch (Exception e) - { - runEventsHandler.HandleLogMessage(TestMessageLevel.Error, e.ToString()); - this.Abort(runEventsHandler); - } - finally - { - this.activeTestRun = null; - } + _activeTestRun.RunTests(); + } + catch (Exception e) + { + runEventsHandler.HandleLogMessage(TestMessageLevel.Error, e.ToString()); + Abort(runEventsHandler); + } + finally + { + _activeTestRun = null; } + } - /// - /// Cancel the test execution. - /// - public void Cancel(ITestRunEventsHandler testRunEventsHandler) + /// + /// Cancel the test execution. + /// + public void Cancel(ITestRunEventsHandler testRunEventsHandler) + { + if (_activeTestRun == null) { - if (this.activeTestRun == null) - { - var testRunCompleteEventArgs = new TestRunCompleteEventArgs(null, true, false, null, null, null, TimeSpan.Zero); - testRunEventsHandler.HandleTestRunComplete(testRunCompleteEventArgs, null, null, null); - } - else - { - this.activeTestRun.Cancel(); - } + var testRunCompleteEventArgs = new TestRunCompleteEventArgs(null, true, false, null, null, null, TimeSpan.Zero); + testRunEventsHandler.HandleTestRunComplete(testRunCompleteEventArgs, null, null, null); } + else + { + _activeTestRun.Cancel(); + } + } - /// - /// Aborts the test execution. - /// - public void Abort(ITestRunEventsHandler testRunEventsHandler) + /// + /// Aborts the test execution. + /// + public void Abort(ITestRunEventsHandler testRunEventsHandler) + { + if (_activeTestRun == null) { - if (this.activeTestRun == null) - { - var testRunCompleteEventArgs = new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero); - testRunEventsHandler.HandleTestRunComplete(testRunCompleteEventArgs, null, null, null); - } - else - { - this.activeTestRun.Abort(); - } + var testRunCompleteEventArgs = new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero); + testRunEventsHandler.HandleTestRunComplete(testRunCompleteEventArgs, null, null, null); + } + else + { + _activeTestRun.Abort(); } + } - #endregion + #endregion - #region private methods + #region private methods - private void LoadExtensions() + private void LoadExtensions() + { + try { - try - { - // Load the extensions on creation so that we dont have to spend time during first execution. - EqtTrace.Verbose("TestExecutorService: Loading the extensions"); + // Load the extensions on creation so that we dont have to spend time during first execution. + EqtTrace.Verbose("TestExecutorService: Loading the extensions"); - TestExecutorExtensionManager.LoadAndInitializeAllExtensions(false); + TestExecutorExtensionManager.LoadAndInitializeAllExtensions(false); - EqtTrace.Verbose("TestExecutorService: Loaded the executors"); + EqtTrace.Verbose("TestExecutorService: Loaded the executors"); - SettingsProviderExtensionManager.LoadAndInitializeAllExtensions(false); + SettingsProviderExtensionManager.LoadAndInitializeAllExtensions(false); - EqtTrace.Verbose("TestExecutorService: Loaded the settings providers"); - EqtTrace.Info("TestExecutorService: Loaded the extensions"); - } - catch (Exception ex) + EqtTrace.Verbose("TestExecutorService: Loaded the settings providers"); + EqtTrace.Info("TestExecutorService: Loaded the extensions"); + } + catch (Exception ex) + { + if (EqtTrace.IsWarningEnabled) { - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning("TestExecutorWebService: Exception occurred while calling test connection. {0}", ex); - } + EqtTrace.Warning("TestExecutorWebService: Exception occurred while calling test connection. {0}", ex); } } + } - /// - /// Initializes out-proc and in-proc data collectors. - /// - private void InitializeDataCollectors(string runSettings, ITestEventsPublisher testEventsPublisher, string defaultCodeBase) + /// + /// Initializes out-proc and in-proc data collectors. + /// + private void InitializeDataCollectors(string runSettings, ITestEventsPublisher testEventsPublisher, string defaultCodeBase) + { + // Initialize out-proc data collectors if declared in run settings. + if (DataCollectionTestCaseEventSender.Instance != null && XmlRunSettingsUtilities.IsDataCollectionEnabled(runSettings)) { - // Initialize out-proc data collectors if declared in run settings. - if (DataCollectionTestCaseEventSender.Instance != null && XmlRunSettingsUtilities.IsDataCollectionEnabled(runSettings)) - { - var outOfProcDataCollectionManager = new ProxyOutOfProcDataCollectionManager(DataCollectionTestCaseEventSender.Instance, testEventsPublisher); - } + _ = new ProxyOutOfProcDataCollectionManager(DataCollectionTestCaseEventSender.Instance, testEventsPublisher); + } - // Initialize in-proc data collectors if declared in run settings. - if (XmlRunSettingsUtilities.IsInProcDataCollectionEnabled(runSettings)) - { - var inProcDataCollectionExtensionManager = new InProcDataCollectionExtensionManager(runSettings, testEventsPublisher, defaultCodeBase, TestPluginCache.Instance); - } + // Initialize in-proc data collectors if declared in run settings. + if (XmlRunSettingsUtilities.IsInProcDataCollectionEnabled(runSettings)) + { + _ = new InProcDataCollectionExtensionManager(runSettings, testEventsPublisher, defaultCodeBase, TestPluginCache.Instance); } + } - private void TestSessionMessageHandler(object sender, TestRunMessageEventArgs e) + private void TestSessionMessageHandler(object sender, TestRunMessageEventArgs e) + { + if (_testMessageEventsHandler != null) { - if (this.testMessageEventsHandler != null) - { - this.testMessageEventsHandler.HandleLogMessage(e.Level, e.Message); - } - else + _testMessageEventsHandler.HandleLogMessage(e.Level, e.Message); + } + else + { + if (EqtTrace.IsWarningEnabled) { - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning( - "ExecutionManager: Could not pass the log message '{0}' as the callback is null.", - e.Message); - } + EqtTrace.Warning( + "ExecutionManager: Could not pass the log message '{0}' as the callback is null.", + e.Message); } } - - #endregion } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/MSTestV1TelemetryHelper.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/MSTestV1TelemetryHelper.cs index 8e71c106c8..309fa291f4 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/MSTestV1TelemetryHelper.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/MSTestV1TelemetryHelper.cs @@ -1,90 +1,85 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution -{ - using System; - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using System; +using System.Collections.Generic; - internal class MSTestV1TelemetryHelper - { - private static TestProperty testTypeProperty; - private static TestProperty extensionIdProperty; +using ObjectModel; - internal static bool IsMSTestV1Adapter(Uri executorUri) - { - return IsMSTestV1Adapter(executorUri.AbsoluteUri); - } +internal class MsTestV1TelemetryHelper +{ + private static TestProperty s_testTypeProperty; + private static TestProperty s_extensionIdProperty; - internal static bool IsMSTestV1Adapter(string executorUri) { - return string.Equals(executorUri, "executor://mstestadapter/v1", StringComparison.OrdinalIgnoreCase); - } + internal static bool IsMsTestV1Adapter(Uri executorUri) + { + return IsMsTestV1Adapter(executorUri.AbsoluteUri); + } - internal static void AddTelemetry(TestResult testResult, IDictionary adapterTelemetry) + internal static bool IsMsTestV1Adapter(string executorUri) + { + return string.Equals(executorUri, "executor://mstestadapter/v1", StringComparison.OrdinalIgnoreCase); + } + + internal static void AddTelemetry(TestResult testResult, IDictionary adapterTelemetry) + { + var executorUri = testResult?.TestCase?.ExecutorUri; + // add additional info for mstestadapter/v1 + if (IsMsTestV1Adapter(executorUri)) { - var executorUri = testResult?.TestCase?.ExecutorUri; - // add additional info for mstestadapter/v1 - if (IsMSTestV1Adapter(executorUri)) + if (s_testTypeProperty == null) { - if (testTypeProperty == null) - { - // this is present when the legacy runner is used, and contains a guid which - // is the test type. - // GenericTestType 982B8C01-1A8A-48F5-B98A-67EE64BC8687 - // OrderedTestType ec4800e8-40e5-4ab3-8510-b8bf29b1904d - // UnitTestType 13CDC9D9-DDB5-4fa4-A97D-D965CCFC6D4B - // WebTestType 4e7599fa-5ecb-43e9-a887-cd63cf72d207 - // CodedWebTestType 37e36796-fb51-4610-8d5c-e00ceaa68b9f - testTypeProperty = TestProperty.Register("TestType", "TestType", typeof(Guid), typeof(TestResult)); - } - - if (extensionIdProperty == null) - { - extensionIdProperty = TestProperty.Register("ExtensionId", "ExtensionId", typeof(string), typeof(TestResult)); - } - // Get addional data from test result passed by MSTestv1 - // Only legacy tests have testtype. + // this is present when the legacy runner is used, and contains a guid which + // is the test type. + // GenericTestType 982B8C01-1A8A-48F5-B98A-67EE64BC8687 + // OrderedTestType ec4800e8-40e5-4ab3-8510-b8bf29b1904d + // UnitTestType 13CDC9D9-DDB5-4fa4-A97D-D965CCFC6D4B + // WebTestType 4e7599fa-5ecb-43e9-a887-cd63cf72d207 + // CodedWebTestType 37e36796-fb51-4610-8d5c-e00ceaa68b9f + s_testTypeProperty = TestProperty.Register("TestType", "TestType", typeof(Guid), typeof(TestResult)); + } - var testType = testResult.GetPropertyValue(testTypeProperty, Guid.Empty); - var hasTestType = testType != Guid.Empty; + if (s_extensionIdProperty == null) + { + s_extensionIdProperty = TestProperty.Register("ExtensionId", "ExtensionId", typeof(string), typeof(TestResult)); + } + // Get addional data from test result passed by MSTestv1 + // Only legacy tests have testtype. - string key; - if (hasTestType) - { - var testExtension = testResult.GetPropertyValue(extensionIdProperty, null); - var hasExtension = !string.IsNullOrWhiteSpace(testExtension); + var testType = testResult.GetPropertyValue(s_testTypeProperty, Guid.Empty); + var hasTestType = testType != Guid.Empty; - if (hasExtension && testExtension.StartsWith("urn:")) - { - // remove urn: prefix - testExtension = testExtension.Remove(0, 4); - } + string key; + if (hasTestType) + { + var testExtension = testResult.GetPropertyValue(s_extensionIdProperty, null); + var hasExtension = !string.IsNullOrWhiteSpace(testExtension); - if (hasExtension) - { - key = $"{testResult.TestCase.ExecutorUri.AbsoluteUri}.legacy.extension.{testExtension}.count"; - } - else - { - key = $"{testResult.TestCase.ExecutorUri.AbsoluteUri}.legacy.count"; - } - } - else + if (hasExtension && testExtension.StartsWith("urn:")) { - key = $"{testResult.TestCase.ExecutorUri.AbsoluteUri}.count"; + // remove urn: prefix + testExtension = testExtension.Remove(0, 4); } - if (adapterTelemetry.ContainsKey(key)) - { - adapterTelemetry[key]++; - } - else - { - adapterTelemetry[key] = 1; - } + key = hasExtension + ? $"{testResult.TestCase.ExecutorUri.AbsoluteUri}.legacy.extension.{testExtension}.count" + : $"{testResult.TestCase.ExecutorUri.AbsoluteUri}.legacy.count"; + } + else + { + key = $"{testResult.TestCase.ExecutorUri.AbsoluteUri}.count"; + } + + if (adapterTelemetry.ContainsKey(key)) + { + adapterTelemetry[key]++; + } + else + { + adapterTelemetry[key] = 1; } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithSources.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithSources.cs index d9372453fd..6113bc4da8 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithSources.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithSources.cs @@ -1,257 +1,243 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; + +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Common.Filtering; +using Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using CoreUtilities.Tracing; +using Adapter; +using Discovery; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using ObjectModel.Engine; +using ObjectModel.Engine.ClientProtocol; + +using ObjectModel.Client; +using ObjectModel.Logging; + +using Utilities; + +using CrossPlatEngineResources = Resources.Resources; + +internal class RunTestsWithSources : BaseRunTests { - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Linq; - - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Filtering; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; - - using ObjectModel.Client; - using ObjectModel.Logging; - using Utilities; - using CrossPlatEngineResources = Resources.Resources; - - internal class RunTestsWithSources : BaseRunTests - { - private Dictionary> adapterSourceMap; + private readonly Dictionary> _adapterSourceMap; + + private Dictionary, IEnumerable> _executorUriVsSourceList; - private Dictionary, IEnumerable> executorUriVsSourceList; + private readonly ITestCaseEventsHandler _testCaseEventsHandler; + + public RunTestsWithSources(IRequestData requestData, Dictionary> adapterSourceMap, string package, string runSettings, TestExecutionContext testExecutionContext, ITestCaseEventsHandler testCaseEventsHandler, ITestRunEventsHandler testRunEventsHandler) + : this(requestData, adapterSourceMap, package, runSettings, testExecutionContext, testCaseEventsHandler, testRunEventsHandler, null) + { + } - private ITestCaseEventsHandler testCaseEventsHandler; + /// + /// Used for unit testing only. + /// + /// + /// + /// The user input test source(package) if it differ from actual test source otherwise null. + /// + /// + /// + /// + /// + /// + internal RunTestsWithSources(IRequestData requestData, Dictionary> adapterSourceMap, string package, string runSettings, TestExecutionContext testExecutionContext, ITestCaseEventsHandler testCaseEventsHandler, ITestRunEventsHandler testRunEventsHandler, Dictionary, IEnumerable> executorUriVsSourceList) + : base(requestData, package, runSettings, testExecutionContext, testCaseEventsHandler, testRunEventsHandler, TestPlatformEventSource.Instance) + { + _adapterSourceMap = adapterSourceMap; + _executorUriVsSourceList = executorUriVsSourceList; + _testCaseEventsHandler = testCaseEventsHandler; + } - public RunTestsWithSources(IRequestData requestData, Dictionary> adapterSourceMap, string package, string runSettings, TestExecutionContext testExecutionContext, ITestCaseEventsHandler testCaseEventsHandler, ITestRunEventsHandler testRunEventsHandler) - : this(requestData, adapterSourceMap, package, runSettings, testExecutionContext, testCaseEventsHandler, testRunEventsHandler, null) + protected override void BeforeRaisingTestRunComplete(bool exceptionsHitDuringRunTests) + { + // If run was with sources and no test was executed and cancellation was not requested, + // then raise a warning saying that no test was present in the sources. + // The warning is raised only if total no of tests that have been run is zero. + if (!exceptionsHitDuringRunTests && _executorUriVsSourceList?.Count > 0 && !IsCancellationRequested + && TestRunCache?.TotalExecutedTests <= 0) { + LogWarningOnNoTestsExecuted(); } + } - /// - /// Used for unit testing only. - /// - /// - /// - /// The user input test source(package) if it differ from actual test source otherwise null. - /// - /// - /// - /// - /// - /// - internal RunTestsWithSources(IRequestData requestData, Dictionary> adapterSourceMap, string package, string runSettings, TestExecutionContext testExecutionContext, ITestCaseEventsHandler testCaseEventsHandler, ITestRunEventsHandler testRunEventsHandler, Dictionary, IEnumerable> executorUriVsSourceList) - : base(requestData, package, runSettings, testExecutionContext, testCaseEventsHandler, testRunEventsHandler, TestPlatformEventSource.Instance) + private void LogWarningOnNoTestsExecuted() + { + IEnumerable sources = new List(); + var sourcesArray = _adapterSourceMap.Values + .Aggregate(sources, (current, enumerable) => current.Concat(enumerable)).ToArray(); + var sourcesString = string.Join(" ", sourcesArray); + + if (TestExecutionContext.TestCaseFilter != null) { - this.adapterSourceMap = adapterSourceMap; - this.executorUriVsSourceList = executorUriVsSourceList; - this.testCaseEventsHandler = testCaseEventsHandler; + var testCaseFilterToShow = TestCaseFilterDeterminer.ShortenTestCaseFilterIfRequired(TestExecutionContext.TestCaseFilter); + TestRunEventsHandler?.HandleLogMessage( + TestMessageLevel.Warning, + string.Format(CrossPlatEngineResources.NoTestsAvailableForGivenTestCaseFilter, testCaseFilterToShow, sourcesString)); } - - protected override void BeforeRaisingTestRunComplete(bool exceptionsHitDuringRunTests) + else { - // If run was with sources and no test was executed and cancellation was not requested, - // then raise a warning saying that no test was present in the sources. - // The warning is raised only if total no of tests that have been run is zero. - if (!exceptionsHitDuringRunTests && this.executorUriVsSourceList?.Count > 0 && !this.IsCancellationRequested - && this.TestRunCache?.TotalExecutedTests <= 0) - { - this.LogWarningOnNoTestsExecuted(); - } + TestRunEventsHandler?.HandleLogMessage( + TestMessageLevel.Warning, + string.Format( + CultureInfo.CurrentUICulture, + CrossPlatEngineResources.TestRunFailed_NoDiscovererFound_NoTestsAreAvailableInTheSources, + sourcesString)); } + } - private void LogWarningOnNoTestsExecuted() - { - IEnumerable sources = new List(); - var sourcesArray = this.adapterSourceMap.Values - .Aggregate(sources, (current, enumerable) => current.Concat(enumerable)).ToArray(); - var sourcesString = string.Join(" ", sourcesArray); + protected override IEnumerable> GetExecutorUriExtensionMap(IFrameworkHandle testExecutorFrameworkHandle, RunContext runContext) + { + _executorUriVsSourceList = GetExecutorVsSourcesList(testExecutorFrameworkHandle); + var executorUris = _executorUriVsSourceList.Keys; - if (this.TestExecutionContext.TestCaseFilter != null) - { - var testCaseFilterToShow = TestCaseFilterDeterminer.ShortenTestCaseFilterIfRequired(this.TestExecutionContext.TestCaseFilter); - this.TestRunEventsHandler?.HandleLogMessage( - TestMessageLevel.Warning, - string.Format(CrossPlatEngineResources.NoTestsAvailableForGivenTestCaseFilter, testCaseFilterToShow, sourcesString)); - } - else - { - this.TestRunEventsHandler?.HandleLogMessage( - TestMessageLevel.Warning, - string.Format( - CultureInfo.CurrentUICulture, - CrossPlatEngineResources.TestRunFailed_NoDiscovererFound_NoTestsAreAvailableInTheSources, - sourcesString)); - } - } + runContext.FilterExpressionWrapper = !string.IsNullOrEmpty(TestExecutionContext.TestCaseFilter) + ? new FilterExpressionWrapper(TestExecutionContext.TestCaseFilter, TestExecutionContext.FilterOptions) + : null; - protected override IEnumerable> GetExecutorUriExtensionMap(IFrameworkHandle testExecutorFrameworkHandle, RunContext runContext) - { - this.executorUriVsSourceList = this.GetExecutorVsSourcesList(testExecutorFrameworkHandle); - var executorUris = this.executorUriVsSourceList.Keys; + return executorUris; + } - if (!string.IsNullOrEmpty(this.TestExecutionContext.TestCaseFilter)) - { - runContext.FilterExpressionWrapper = new FilterExpressionWrapper(this.TestExecutionContext.TestCaseFilter, this.TestExecutionContext.FilterOptions); - } - else - { - runContext.FilterExpressionWrapper = null; - } + protected override void InvokeExecutor( + LazyExtension executor, + Tuple executorUriExtensionTuple, + RunContext runContext, + IFrameworkHandle frameworkHandle) + { + executor?.Value.RunTests(_executorUriVsSourceList[executorUriExtensionTuple], runContext, frameworkHandle); + } - return executorUris; - } + /// + protected override bool ShouldAttachDebuggerToTestHost( + LazyExtension executor, + Tuple executorUriExtensionTuple, + RunContext runContext) + { + // If the adapter doesn't implement the new test executor interface we should attach to + // the default test host by default to preserve old behavior. + return !(executor?.Value is ITestExecutor2 convertedExecutor) + || convertedExecutor.ShouldAttachToTestHost( + _executorUriVsSourceList[executorUriExtensionTuple], + runContext); + } - protected override void InvokeExecutor( - LazyExtension executor, - Tuple executorUriExtensionTuple, - RunContext runContext, - IFrameworkHandle frameworkHandle) - { - executor?.Value.RunTests(this.executorUriVsSourceList[executorUriExtensionTuple], runContext, frameworkHandle); - } + /// + /// Returns executor Vs sources list + /// + private Dictionary, IEnumerable> GetExecutorVsSourcesList(IMessageLogger logger) + { + var result = new Dictionary, IEnumerable>(); + + var verifiedExtensionSourceMap = new Dictionary>(); - /// - protected override bool ShouldAttachDebuggerToTestHost( - LazyExtension executor, - Tuple executorUriExtensionTuple, - RunContext runContext) + // Validate the sources + foreach (var kvp in _adapterSourceMap) { - // If the adapter doesn't implement the new test executor interface we should attach to - // the default test host by default to preserve old behavior. - if (!(executor?.Value is ITestExecutor2 convertedExecutor)) + var verifiedSources = DiscoveryManager.GetValidSources(kvp.Value, logger, _package); + if (verifiedSources.Any()) { - return true; + verifiedExtensionSourceMap.Add(kvp.Key, kvp.Value); } - - return convertedExecutor.ShouldAttachToTestHost( - this.executorUriVsSourceList[executorUriExtensionTuple], - runContext); } - /// - /// Returns executor Vs sources list - /// - private Dictionary, IEnumerable> GetExecutorVsSourcesList(IMessageLogger logger) + // No valid source is found => no executor vs source map + if (!verifiedExtensionSourceMap.Any()) { - var result = new Dictionary, IEnumerable>(); - - var verifiedExtensionSourceMap = new Dictionary>(); - - // Validate the sources - foreach (var kvp in this.adapterSourceMap) - { - var verifiedSources = DiscoveryManager.GetValidSources(kvp.Value, logger, package); - if (verifiedSources.Any()) - { - verifiedExtensionSourceMap.Add(kvp.Key, kvp.Value); - } - } + return result; + } - // No valid source is found => no executor vs source map - if (!verifiedExtensionSourceMap.Any()) + foreach (var kvp in verifiedExtensionSourceMap) + { + Dictionary, IEnumerable> + discovererToSourcesMap = DiscovererEnumerator.GetDiscovererToSourcesMap( + kvp.Key, + kvp.Value, + logger, + new AssemblyProperties()); + + // Warning is logged by the inner layer + if (discovererToSourcesMap == null || discovererToSourcesMap.Count == 0) { - return result; + continue; } - foreach (var kvp in verifiedExtensionSourceMap) + foreach (var discoverer in discovererToSourcesMap.Keys) { - Dictionary, IEnumerable> - discovererToSourcesMap = DiscovererEnumerator.GetDiscovererToSourcesMap( - kvp.Key, - kvp.Value, - logger, - new AssemblyProperties()); - - // Warning is logged by the inner layer - if (discovererToSourcesMap == null || discovererToSourcesMap.Count == 0) + var executorUri = discoverer.Metadata.DefaultExecutorUri; + if (executorUri == null) { + string errorMessage = string.Format( + CultureInfo.CurrentUICulture, + CrossPlatEngineResources.IgnoringExecutorAsNoDefaultExecutorUriAttribute, + discoverer.Value); + logger.SendMessage(TestMessageLevel.Warning, errorMessage); continue; } - foreach (var discoverer in discovererToSourcesMap.Keys) + var executorUriExtensionTuple = new Tuple(executorUri, kvp.Key); + + if (!result.ContainsKey(executorUriExtensionTuple)) + { + result.Add(executorUriExtensionTuple, discovererToSourcesMap[discoverer]); + } + else { - var executorUri = discoverer.Metadata.DefaultExecutorUri; - if (executorUri == null) - { - string errorMessage = string.Format( - CultureInfo.CurrentUICulture, - CrossPlatEngineResources.IgnoringExecutorAsNoDefaultExecutorUriAttribute, - discoverer.Value); - logger.SendMessage(TestMessageLevel.Warning, errorMessage); - continue; - } - - var executorUriExtensionTuple = new Tuple(executorUri, kvp.Key); - - if (!result.ContainsKey(executorUriExtensionTuple)) - { - result.Add(executorUriExtensionTuple, discovererToSourcesMap[discoverer]); - } - else - { - string errorMessage = string.Format( - CultureInfo.CurrentUICulture, - CrossPlatEngineResources.DuplicateAdaptersFound, - executorUri, - discoverer.Value); - logger.SendMessage(TestMessageLevel.Warning, errorMessage); - } + string errorMessage = string.Format( + CultureInfo.CurrentUICulture, + CrossPlatEngineResources.DuplicateAdaptersFound, + executorUri, + discoverer.Value); + logger.SendMessage(TestMessageLevel.Warning, errorMessage); } } - - return result; } - private static string TestCaseFilterToShow(string testCaseFilter) - { - var maxTestCaseFilterToShowLength = 63; - string testCaseFilterToShow; + return result; + } - if (testCaseFilter.Length > maxTestCaseFilterToShowLength) - { - testCaseFilterToShow = testCaseFilter.Substring(0, maxTestCaseFilterToShowLength - 3) + "..."; - } - else - { - testCaseFilterToShow = testCaseFilter; - } + private static string TestCaseFilterToShow(string testCaseFilter) + { + var maxTestCaseFilterToShowLength = 63; + string testCaseFilterToShow = testCaseFilter.Length > maxTestCaseFilterToShowLength + ? testCaseFilter.Substring(0, maxTestCaseFilterToShowLength - 3) + "..." + : testCaseFilter; + return testCaseFilterToShow; + } - return testCaseFilterToShow; - } + /// + /// Sends Session-End event on in-proc datacollectors + /// + protected override void SendSessionEnd() + { + _testCaseEventsHandler?.SendSessionEnd(); + } - /// - /// Sends Session-End event on in-proc datacollectors - /// - protected override void SendSessionEnd() + /// + /// Sends Session-Start event on in-proc datacollectors + /// + protected override void SendSessionStart() + { + // Send session start with test sources in property bag for session start event args. + if (_testCaseEventsHandler == null) { - this.testCaseEventsHandler?.SendSessionEnd(); + return; } - /// - /// Sends Session-Start event on in-proc datacollectors - /// - protected override void SendSessionStart() + var properties = new Dictionary { - // Send session start with test sources in property bag for session start event args. - if (this.testCaseEventsHandler == null) - { - return; - } + { "TestSources", TestSourcesUtility.GetSources(_adapterSourceMap) } + }; - var properties = new Dictionary(); - properties.Add("TestSources", TestSourcesUtility.GetSources(this.adapterSourceMap)); - - this.testCaseEventsHandler.SendSessionStart(properties); - } + _testCaseEventsHandler.SendSessionStart(properties); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithTests.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithTests.cs index b072cac0a0..350883afd2 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithTests.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithTests.cs @@ -1,149 +1,147 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; + +using System; +using System.Collections.Generic; +using System.Diagnostics; + +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Common.Interfaces; +using CoreUtilities.Tracing; +using Adapter; +using Utilities; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using ObjectModel.Engine; +using ObjectModel.Engine.ClientProtocol; + +using ObjectModel.Client; + +internal class RunTestsWithTests : BaseRunTests { - using System; - using System.Collections.Generic; - using System.Diagnostics; - - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; - - using ObjectModel.Client; - - internal class RunTestsWithTests : BaseRunTests - { - private IEnumerable testCases; + private readonly IEnumerable _testCases; - private Dictionary, List> executorUriVsTestList; + private Dictionary, List> _executorUriVsTestList; - private ITestCaseEventsHandler testCaseEventsHandler; + private readonly ITestCaseEventsHandler _testCaseEventsHandler; - public RunTestsWithTests(IRequestData requestData, IEnumerable testCases, string package, string runSettings, TestExecutionContext testExecutionContext, ITestCaseEventsHandler testCaseEventsHandler, ITestRunEventsHandler testRunEventsHandler) - : this(requestData, testCases, package, runSettings, testExecutionContext, testCaseEventsHandler, testRunEventsHandler, null) - { - } + public RunTestsWithTests(IRequestData requestData, IEnumerable testCases, string package, string runSettings, TestExecutionContext testExecutionContext, ITestCaseEventsHandler testCaseEventsHandler, ITestRunEventsHandler testRunEventsHandler) + : this(requestData, testCases, package, runSettings, testExecutionContext, testCaseEventsHandler, testRunEventsHandler, null) + { + } - /// - /// Used for unit testing only. - /// - /// - /// The user input test source(package) if it differ from actual test source otherwise null. - /// - /// - /// - /// - /// - /// - internal RunTestsWithTests(IRequestData requestData, IEnumerable testCases, string package, string runSettings, TestExecutionContext testExecutionContext, ITestCaseEventsHandler testCaseEventsHandler, ITestRunEventsHandler testRunEventsHandler, Dictionary, List> executorUriVsTestList) - : base(requestData, package, runSettings, testExecutionContext, testCaseEventsHandler, testRunEventsHandler, TestPlatformEventSource.Instance) - { - this.testCases = testCases; - this.executorUriVsTestList = executorUriVsTestList; - this.testCaseEventsHandler = testCaseEventsHandler; - } + /// + /// Used for unit testing only. + /// + /// + /// The user input test source(package) if it differ from actual test source otherwise null. + /// + /// + /// + /// + /// + /// + internal RunTestsWithTests(IRequestData requestData, IEnumerable testCases, string package, string runSettings, TestExecutionContext testExecutionContext, ITestCaseEventsHandler testCaseEventsHandler, ITestRunEventsHandler testRunEventsHandler, Dictionary, List> executorUriVsTestList) + : base(requestData, package, runSettings, testExecutionContext, testCaseEventsHandler, testRunEventsHandler, TestPlatformEventSource.Instance) + { + _testCases = testCases; + _executorUriVsTestList = executorUriVsTestList; + _testCaseEventsHandler = testCaseEventsHandler; + } - protected override void BeforeRaisingTestRunComplete(bool exceptionsHitDuringRunTests) - { - // Do Nothing. - } + protected override void BeforeRaisingTestRunComplete(bool exceptionsHitDuringRunTests) + { + // Do Nothing. + } - protected override IEnumerable> GetExecutorUriExtensionMap(IFrameworkHandle testExecutorFrameworkHandle, RunContext runContext) - { - this.executorUriVsTestList = this.GetExecutorVsTestCaseList(this.testCases); + protected override IEnumerable> GetExecutorUriExtensionMap(IFrameworkHandle testExecutorFrameworkHandle, RunContext runContext) + { + _executorUriVsTestList = GetExecutorVsTestCaseList(_testCases); - Debug.Assert(this.TestExecutionContext.TestCaseFilter == null, "TestCaseFilter should be null for specific tests."); - runContext.FilterExpressionWrapper = null; + Debug.Assert(TestExecutionContext.TestCaseFilter == null, "TestCaseFilter should be null for specific tests."); + runContext.FilterExpressionWrapper = null; - return this.executorUriVsTestList.Keys; - } + return _executorUriVsTestList.Keys; + } - protected override void InvokeExecutor( - LazyExtension executor, - Tuple executorUri, - RunContext runContext, - IFrameworkHandle frameworkHandle) - { - executor?.Value.RunTests(this.executorUriVsTestList[executorUri], runContext, frameworkHandle); - } + protected override void InvokeExecutor( + LazyExtension executor, + Tuple executorUri, + RunContext runContext, + IFrameworkHandle frameworkHandle) + { + executor?.Value.RunTests(_executorUriVsTestList[executorUri], runContext, frameworkHandle); + } - /// - protected override bool ShouldAttachDebuggerToTestHost( - LazyExtension executor, - Tuple executorUri, - RunContext runContext) - { - // If the adapter doesn't implement the new test executor interface we should attach to - // the default test host by default to preserve old behavior. - if (!(executor?.Value is ITestExecutor2 convertedExecutor)) - { - return true; - } + /// + protected override bool ShouldAttachDebuggerToTestHost( + LazyExtension executor, + Tuple executorUri, + RunContext runContext) + { + // If the adapter doesn't implement the new test executor interface we should attach to + // the default test host by default to preserve old behavior. + return !(executor?.Value is ITestExecutor2 convertedExecutor) + || convertedExecutor.ShouldAttachToTestHost(_executorUriVsTestList[executorUri], runContext); + } - return convertedExecutor.ShouldAttachToTestHost(this.executorUriVsTestList[executorUri], runContext); - } + /// + /// Sends Session-End event on in-proc datacollectors + /// + protected override void SendSessionEnd() + { + _testCaseEventsHandler?.SendSessionEnd(); + } - /// - /// Sends Session-End event on in-proc datacollectors - /// - protected override void SendSessionEnd() + /// + /// Sends Session-Start event on in-proc datacollectors + /// + protected override void SendSessionStart() + { + // Send session start with test sources in property bag for session start event args. + if (_testCaseEventsHandler == null) { - this.testCaseEventsHandler?.SendSessionEnd(); + return; } - /// - /// Sends Session-Start event on in-proc datacollectors - /// - protected override void SendSessionStart() + var properties = new Dictionary { - // Send session start with test sources in property bag for session start event args. - if (this.testCaseEventsHandler == null) - { - return; - } + { "TestSources", TestSourcesUtility.GetSources(_testCases) } + }; - var properties = new Dictionary(); - properties.Add("TestSources", TestSourcesUtility.GetSources(this.testCases)); - - this.testCaseEventsHandler.SendSessionStart(properties); - } + _testCaseEventsHandler.SendSessionStart(properties); + } - /// - /// Returns the executor Vs TestCase list - /// - private Dictionary, List> GetExecutorVsTestCaseList(IEnumerable tests) + /// + /// Returns the executor Vs TestCase list + /// + private Dictionary, List> GetExecutorVsTestCaseList(IEnumerable tests) + { + var result = new Dictionary, List>(); + foreach (var test in tests) { - var result = new Dictionary, List>(); - foreach (var test in tests) - { - List testList; - // TODO: Fill this in with the right extension value. - var executorUriExtensionTuple = new Tuple( - test.ExecutorUri, - Constants.UnspecifiedAdapterPath); + // TODO: Fill this in with the right extension value. + var executorUriExtensionTuple = new Tuple( + test.ExecutorUri, + Constants.UnspecifiedAdapterPath); - if (result.TryGetValue(executorUriExtensionTuple, out testList)) - { - testList.Add(test); - } - else + if (result.TryGetValue(executorUriExtensionTuple, out List testList)) + { + testList.Add(test); + } + else + { + testList = new List { - testList = new List(); - testList.Add(test); - result.Add(executorUriExtensionTuple, testList); - } + test + }; + result.Add(executorUriExtensionTuple, testList); } - - return result; } + + return result; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/TestRunCache.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/TestRunCache.cs index 05df170e30..8c085a550a 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/TestRunCache.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/TestRunCache.cs @@ -1,405 +1,403 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Threading; + +using ObjectModel; + +using ObjectModel.Client; + +/// +/// Maintains a cache of last 'n' test results and maintains stats for the complete run. +/// +internal class TestRunCache : ITestRunCache { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Diagnostics; - using System.Linq; - using System.Threading; + #region Private Members - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using ObjectModel.Client; + /// + /// Specifies whether the object is disposed or not. + /// + private bool _isDisposed; /// - /// Maintains a cache of last 'n' test results and maintains stats for the complete run. + /// Test run stats /// - internal class TestRunCache : ITestRunCache - { - #region Private Members - - /// - /// Specifies whether the object is disposed or not. - /// - private bool isDisposed; - - /// - /// Test run stats - /// - private Dictionary runStats; - - /// - /// Total tests which have currently executed - /// - private long totalExecutedTests; - - /// - /// Callback used when cache is ready to report some test results/case. - /// - private OnCacheHit onCacheHit; - - /// - /// Max size of the test result buffer - /// - private long cacheSize; - - /// - /// Timeout that triggers sending results regardless of cache size. - /// - private TimeSpan cacheTimeout; - - /// - /// Timer for cache - /// - private Timer timer; - - /// - /// Last time results were sent. - /// - private DateTime lastUpdate; - - /// - /// The test case currently in progress. - /// - private ICollection inProgressTests; - - /// - /// Test results buffer - /// - private ICollection testResults; - - /// - /// Sync object - /// - private object syncObject; - - #endregion - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - /// The cache size. - /// The cache timeout. - /// The on cache hit. - internal TestRunCache(long cacheSize, TimeSpan cacheTimeout, OnCacheHit onCacheHit) - { - Debug.Assert(cacheSize > 0, "Buffer size cannot be less than zero"); - Debug.Assert(onCacheHit != null, "Callback which listens for cache size limit cannot be null."); - Debug.Assert(cacheTimeout > TimeSpan.MinValue, "The cache timeout must be greater than min value."); + private readonly Dictionary _runStats; - if (cacheTimeout.TotalMilliseconds > int.MaxValue) - { - cacheTimeout = TimeSpan.FromMilliseconds(int.MaxValue / 2); - } + /// + /// Total tests which have currently executed + /// + private long _totalExecutedTests; + + /// + /// Callback used when cache is ready to report some test results/case. + /// + private readonly OnCacheHit _onCacheHit; + + /// + /// Max size of the test result buffer + /// + private readonly long _cacheSize; + + /// + /// Timeout that triggers sending results regardless of cache size. + /// + private readonly TimeSpan _cacheTimeout; + + /// + /// Timer for cache + /// + private Timer _timer; + + /// + /// Last time results were sent. + /// + private DateTime _lastUpdate; + + /// + /// The test case currently in progress. + /// + private ICollection _inProgressTests; - this.cacheSize = cacheSize; - this.onCacheHit = onCacheHit; - this.lastUpdate = DateTime.Now; - this.cacheTimeout = cacheTimeout; - this.inProgressTests = new Collection(); - this.testResults = new Collection(); - this.runStats = new Dictionary(); - this.syncObject = new object(); + /// + /// Test results buffer + /// + private ICollection _testResults; + + /// + /// Sync object + /// + private readonly object _syncObject; - this.timer = new Timer(this.OnCacheTimeHit, this, cacheTimeout, cacheTimeout); + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// The cache size. + /// The cache timeout. + /// The on cache hit. + internal TestRunCache(long cacheSize, TimeSpan cacheTimeout, OnCacheHit onCacheHit) + { + Debug.Assert(cacheSize > 0, "Buffer size cannot be less than zero"); + Debug.Assert(onCacheHit != null, "Callback which listens for cache size limit cannot be null."); + Debug.Assert(cacheTimeout > TimeSpan.MinValue, "The cache timeout must be greater than min value."); + + if (cacheTimeout.TotalMilliseconds > int.MaxValue) + { + cacheTimeout = TimeSpan.FromMilliseconds(int.MaxValue / 2); } - #endregion + _cacheSize = cacheSize; + _onCacheHit = onCacheHit; + _lastUpdate = DateTime.Now; + _cacheTimeout = cacheTimeout; + _inProgressTests = new Collection(); + _testResults = new Collection(); + _runStats = new Dictionary(); + _syncObject = new object(); + + _timer = new Timer(OnCacheTimeHit, this, cacheTimeout, cacheTimeout); + } + + #endregion - #region Delegates + #region Delegates - /// - /// Called when the cache is ready to report on the current status. - /// - internal delegate void OnCacheHit(TestRunStatistics testRunStats, ICollection results, ICollection inProgressTests); + /// + /// Called when the cache is ready to report on the current status. + /// + internal delegate void OnCacheHit(TestRunStatistics testRunStats, ICollection results, ICollection inProgressTests); - #endregion + #endregion - #region Properties + #region Properties - /// - /// Gets the test results present in the cache currently. - /// - public ICollection TestResults + /// + /// Gets the test results present in the cache currently. + /// + public ICollection TestResults + { + get { - get + lock (_syncObject) { - lock (this.syncObject) - { - return this.testResults; - } + return _testResults; } } + } - /// - /// Gets the set of in-progress test cases present in the cache currently. - /// - public ICollection InProgressTests + /// + /// Gets the set of in-progress test cases present in the cache currently. + /// + public ICollection InProgressTests + { + get { - get + lock (_syncObject) { - lock (this.syncObject) - { - return this.inProgressTests; - } + return _inProgressTests; } } + } - /// - /// Gets the total executed tests. - /// - public long TotalExecutedTests + /// + /// Gets the total executed tests. + /// + public long TotalExecutedTests + { + get { - get + lock (_syncObject) { - lock (this.syncObject) - { - return this.totalExecutedTests; - } + return _totalExecutedTests; } } + } - /// - /// Gets the test run stats - /// - public TestRunStatistics TestRunStatistics + /// + /// Gets the test run stats + /// + public TestRunStatistics TestRunStatistics + { + get { - get + lock (_syncObject) { - lock (this.syncObject) - { - var stats = new TestRunStatistics(new Dictionary(this.runStats)); - stats.ExecutedTests = this.TotalExecutedTests; + var stats = new TestRunStatistics(new Dictionary(_runStats)); + stats.ExecutedTests = TotalExecutedTests; - return stats; - } + return stats; } } + } - public IDictionary AdapterTelemetry { get; set; } = new Dictionary(); - #endregion + public IDictionary AdapterTelemetry { get; set; } = new Dictionary(); + #endregion - #region Public/internal methods + #region Public/internal methods - /// - /// Disposes the cache - /// - public void Dispose() - { - this.Dispose(true); + /// + /// Disposes the cache + /// + public void Dispose() + { + Dispose(true); - // Use SupressFinalize in case a subclass - // of this valueType implements a finalizer. - GC.SuppressFinalize(this); - } + // Use SupressFinalize in case a subclass + // of this valueType implements a finalizer. + GC.SuppressFinalize(this); + } - /// - /// Notifies the cache that a test is starting. - /// This notification comes from the adapter to the engine which then calls into the cache. - /// - /// The test Case. - public void OnTestStarted(TestCase testCase) + /// + /// Notifies the cache that a test is starting. + /// This notification comes from the adapter to the engine which then calls into the cache. + /// + /// The test Case. + public void OnTestStarted(TestCase testCase) + { + lock (_syncObject) { - lock (this.syncObject) - { - this.inProgressTests.Add(testCase); + _inProgressTests.Add(testCase); - this.CheckForCacheHit(); - } + CheckForCacheHit(); } + } - /// - /// Notifies the cache of a new test result from the adapter. - /// - /// The test result. - public void OnNewTestResult(TestResult testResult) + /// + /// Notifies the cache of a new test result from the adapter. + /// + /// The test result. + public void OnNewTestResult(TestResult testResult) + { + lock (_syncObject) { - lock (this.syncObject) - { - this.totalExecutedTests++; - this.testResults.Add(testResult); - MSTestV1TelemetryHelper.AddTelemetry(testResult, this.AdapterTelemetry); + _totalExecutedTests++; + _testResults.Add(testResult); + MsTestV1TelemetryHelper.AddTelemetry(testResult, AdapterTelemetry); - long count; - if (this.runStats.TryGetValue(testResult.Outcome, out count)) - { - count++; - } - else - { - count = 1; - } + if (_runStats.TryGetValue(testResult.Outcome, out long count)) + { + count++; + } + else + { + count = 1; + } - this.runStats[testResult.Outcome] = count; + _runStats[testResult.Outcome] = count; - this.RemoveInProgress(testResult); + RemoveInProgress(testResult); - this.CheckForCacheHit(); - } + CheckForCacheHit(); } + } - /// - /// Notifies the cache of a test completion. - /// - /// - /// The completed Test. - /// - /// True if this test has been removed from the list of in progress tests. - public bool OnTestCompletion(TestCase completedTest) + /// + /// Notifies the cache of a test completion. + /// + /// + /// The completed Test. + /// + /// True if this test has been removed from the list of in progress tests. + public bool OnTestCompletion(TestCase completedTest) + { + lock (_syncObject) { - lock (this.syncObject) + if (completedTest == null) { - if (completedTest == null) - { - EqtTrace.Warning("TestRunCache: completedTest is null"); - return false; - } - - if (this.inProgressTests == null || this.inProgressTests.Count == 0) - { - EqtTrace.Warning("TestRunCache: InProgressTests is null"); - return false; - } + EqtTrace.Warning("TestRunCache: completedTest is null"); + return false; + } - var removed = this.inProgressTests.Remove(completedTest); - if (removed) - { - return true; - } + if (_inProgressTests == null || _inProgressTests.Count == 0) + { + EqtTrace.Warning("TestRunCache: InProgressTests is null"); + return false; + } - // Try finding/removing a matching test corresponding to the completed test - var inProgressTest = this.inProgressTests.FirstOrDefault(inProgress => inProgress.Id == completedTest.Id); - if (inProgressTest != null) - { - removed = this.inProgressTests.Remove(inProgressTest); - } + var removed = _inProgressTests.Remove(completedTest); + if (removed) + { + return true; + } - return removed; + // Try finding/removing a matching test corresponding to the completed test + var inProgressTest = _inProgressTests.FirstOrDefault(inProgress => inProgress.Id == completedTest.Id); + if (inProgressTest != null) + { + removed = _inProgressTests.Remove(inProgressTest); } + + return removed; } + } - /// - /// Returns the last chunk - /// - /// The set of test results remaining in the cache. - public ICollection GetLastChunk() + /// + /// Returns the last chunk + /// + /// The set of test results remaining in the cache. + public ICollection GetLastChunk() + { + lock (_syncObject) { - lock (this.syncObject) - { - var lastChunk = this.testResults; + var lastChunk = _testResults; - this.testResults = new Collection(); + _testResults = new Collection(); - return lastChunk; - } + return lastChunk; } + } - /// - /// The dispose. - /// - /// Indicates if this needs to clean up managed resources. - /// - /// The dispose pattern is a best practice to differentiate between managed and native resources cleanup. - /// Even though this particular class does not have any native resources - honoring the pattern to be consistent throughout the code base. - /// - protected virtual void Dispose(bool disposing) + /// + /// The dispose. + /// + /// Indicates if this needs to clean up managed resources. + /// + /// The dispose pattern is a best practice to differentiate between managed and native resources cleanup. + /// Even though this particular class does not have any native resources - honoring the pattern to be consistent throughout the code base. + /// + protected virtual void Dispose(bool disposing) + { + // If you need thread safety, use a lock around these + // operations, as well as in your methods that use the resource. + if (disposing && !_isDisposed) { - // If you need thread safety, use a lock around these - // operations, as well as in your methods that use the resource. - if (disposing && !this.isDisposed) + if (_timer != null) { - if (this.timer != null) - { - this.timer.Dispose(); - this.timer = null; - } - - // Indicate that the instance has been disposed. - this.isDisposed = true; + _timer.Dispose(); + _timer = null; } + + // Indicate that the instance has been disposed. + _isDisposed = true; } + } - #endregion + #endregion - #region Private methods. + #region Private methods. - /// - /// Checks if the cache timeout/size has been met. - /// - private void CheckForCacheHit() + /// + /// Checks if the cache timeout/size has been met. + /// + private void CheckForCacheHit() + { + lock (_syncObject) { - lock (this.syncObject) - { - // Send results when the specified cache size has been reached or - // after the specified cache timeout has been hit. - var timeDelta = DateTime.Now - this.lastUpdate; + // Send results when the specified cache size has been reached or + // after the specified cache timeout has been hit. + var timeDelta = DateTime.Now - _lastUpdate; - var inProgressTestsCount = this.inProgressTests.Count; + var inProgressTestsCount = _inProgressTests.Count; - if ((this.testResults.Count + inProgressTestsCount) >= this.cacheSize || (timeDelta >= this.cacheTimeout && inProgressTestsCount > 0)) - { - this.SendResults(); - } + if ((_testResults.Count + inProgressTestsCount) >= _cacheSize || (timeDelta >= _cacheTimeout && inProgressTestsCount > 0)) + { + SendResults(); } } + } - private void CheckForCacheHitOnTimer() + private void CheckForCacheHitOnTimer() + { + lock (_syncObject) { - lock (this.syncObject) + if (_testResults.Count > 0 || _inProgressTests.Count > 0) { - if (this.testResults.Count > 0 || this.inProgressTests.Count > 0) - { - this.SendResults(); - } + SendResults(); } } + } - private void SendResults() - { - // Pass on the buffer to the listener and clear the old one - this.onCacheHit(this.TestRunStatistics, this.testResults, this.inProgressTests); - this.testResults = new Collection(); - this.inProgressTests = new Collection(); - this.lastUpdate = DateTime.Now; + private void SendResults() + { + // Pass on the buffer to the listener and clear the old one + _onCacheHit(TestRunStatistics, _testResults, _inProgressTests); + _testResults = new Collection(); + _inProgressTests = new Collection(); + _lastUpdate = DateTime.Now; - // Reset the timer - this.timer.Change(this.cacheTimeout, this.cacheTimeout); + // Reset the timer + _timer.Change(_cacheTimeout, _cacheTimeout); - EqtTrace.Verbose("TestRunCache: OnNewTestResult: Notified the onCacheHit callback."); - } + EqtTrace.Verbose("TestRunCache: OnNewTestResult: Notified the onCacheHit callback."); + } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - private void OnCacheTimeHit(object state) + private void OnCacheTimeHit(object state) + { + lock (_syncObject) { - lock (this.syncObject) + try { - try - { - this.CheckForCacheHitOnTimer(); - } - catch (Exception ex) + CheckForCacheHitOnTimer(); + } + catch (Exception ex) + { + if (EqtTrace.IsErrorEnabled) { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("TestRunCache: OnCacheTimeHit: Exception occurred while checking for cache hit. {0}", ex); - } + EqtTrace.Error("TestRunCache: OnCacheTimeHit: Exception occurred while checking for cache hit. {0}", ex); } } } + } - private void RemoveInProgress(TestResult result) + private void RemoveInProgress(TestResult result) + { + var removed = OnTestCompletion(result.TestCase); + if (!removed) { - var removed = this.OnTestCompletion(result.TestCase); - if (!removed) - { - EqtTrace.Warning("TestRunCache: No test found corresponding to testResult '{0}' in inProgress list.", result.DisplayName); - } + EqtTrace.Warning("TestRunCache: No test found corresponding to testResult '{0}' in inProgress list.", result.DisplayName); } - - #endregion } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Interfaces/ITestRunCache.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Interfaces/ITestRunCache.cs index c35d99e160..1265b5995b 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Interfaces/ITestRunCache.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Interfaces/ITestRunCache.cs @@ -1,42 +1,41 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; + +using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using System; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using System; - /// - /// The cache for test execution information. - /// - internal interface ITestRunCache : IDisposable - { - #region Properties +/// +/// The cache for test execution information. +/// +internal interface ITestRunCache : IDisposable +{ + #region Properties - ICollection TestResults { get; } + ICollection TestResults { get; } - ICollection InProgressTests { get; } - long TotalExecutedTests { get; } + ICollection InProgressTests { get; } + long TotalExecutedTests { get; } - TestRunStatistics TestRunStatistics { get; } + TestRunStatistics TestRunStatistics { get; } - IDictionary AdapterTelemetry { get; } + IDictionary AdapterTelemetry { get; } - #endregion + #endregion - #region Methods + #region Methods - void OnTestStarted(TestCase testCase); + void OnTestStarted(TestCase testCase); - void OnNewTestResult(TestResult testResult); + void OnNewTestResult(TestResult testResult); - bool OnTestCompletion(TestCase completedTest); + bool OnTestCompletion(TestCase completedTest); - ICollection GetLastChunk(); + ICollection GetLastChunk(); - #endregion - } + #endregion } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs index 9a4d5240cb..6575393727 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs @@ -1,91 +1,91 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; + +using Common; +using Common.Hosting; +using Common.Logging; +using Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using CommunicationUtilities; +using Client; +using Client.Parallel; +using DataCollection; +using Utilities; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; +using ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using PlatformAbstractions; +using PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities; + +/// +/// Cross platform test engine entry point for the client. +/// +public class TestEngine : ITestEngine { - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Linq; - - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Hosting; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities; + #region Private Fields - /// - /// Cross platform test engine entry point for the client. - /// - public class TestEngine : ITestEngine + private readonly TestRuntimeProviderManager _testHostProviderManager; + private ITestExtensionManager _testExtensionManager; + private readonly IProcessHelper _processHelper; + + #endregion + + public TestEngine() : this(TestRuntimeProviderManager.Instance, new ProcessHelper()) { - #region Private Fields + } - private readonly TestRuntimeProviderManager testHostProviderManager; - private ITestExtensionManager testExtensionManager; - private IProcessHelper processHelper; + protected TestEngine( + TestRuntimeProviderManager testHostProviderManager, + IProcessHelper processHelper) + { + _testHostProviderManager = testHostProviderManager; + _processHelper = processHelper; + } - #endregion + #region ITestEngine implementation - public TestEngine() : this(TestRuntimeProviderManager.Instance, new ProcessHelper()) - { - } + /// + public IProxyDiscoveryManager GetDiscoveryManager( + IRequestData requestData, + ITestRuntimeProvider testHostManager, + DiscoveryCriteria discoveryCriteria) + { + var parallelLevel = VerifyParallelSettingAndCalculateParallelLevel( + discoveryCriteria.Sources.Count(), + discoveryCriteria.RunSettings); + + // Collecting IsParallel enabled. + requestData.MetricsCollection.Add( + TelemetryDataConstants.ParallelEnabledDuringDiscovery, + parallelLevel > 1 ? "True" : "False"); - protected TestEngine( - TestRuntimeProviderManager testHostProviderManager, - IProcessHelper processHelper) + if (ShouldRunInNoIsolation(discoveryCriteria.RunSettings, parallelLevel > 1, false)) { - this.testHostProviderManager = testHostProviderManager; - this.processHelper = processHelper; + var isTelemetryOptedIn = requestData.IsTelemetryOptedIn; + var newRequestData = GetRequestData(isTelemetryOptedIn); + return new InProcessProxyDiscoveryManager( + testHostManager, + new TestHostManagerFactory(newRequestData)); } - #region ITestEngine implementation - - /// - public IProxyDiscoveryManager GetDiscoveryManager( - IRequestData requestData, - ITestRuntimeProvider testHostManager, - DiscoveryCriteria discoveryCriteria) + Func proxyDiscoveryManagerCreator = () => { - var parallelLevel = this.VerifyParallelSettingAndCalculateParallelLevel( - discoveryCriteria.Sources.Count(), - discoveryCriteria.RunSettings); - - // Collecting IsParallel enabled. - requestData.MetricsCollection.Add( - TelemetryDataConstants.ParallelEnabledDuringDiscovery, - parallelLevel > 1 ? "True" : "False"); - - if (this.ShouldRunInNoIsolation(discoveryCriteria.RunSettings, parallelLevel > 1, false)) - { - var isTelemetryOptedIn = requestData.IsTelemetryOptedIn; - var newRequestData = this.GetRequestData(isTelemetryOptedIn); - return new InProcessProxyDiscoveryManager( - testHostManager, - new TestHostManagerFactory(newRequestData)); - } - - Func proxyDiscoveryManagerCreator = () => - { - var hostManager = this.testHostProviderManager.GetTestHostManagerByRunConfiguration(discoveryCriteria.RunSettings); - hostManager?.Initialize(TestSessionMessageLogger.Instance, discoveryCriteria.RunSettings); + var hostManager = _testHostProviderManager.GetTestHostManagerByRunConfiguration(discoveryCriteria.RunSettings); + hostManager?.Initialize(TestSessionMessageLogger.Instance, discoveryCriteria.RunSettings); - // This function is used to either take a pre-existing proxy operation manager from - // the test pool or to create a new proxy operation manager on the spot. - Func + // This function is used to either take a pre-existing proxy operation manager from + // the test pool or to create a new proxy operation manager on the spot. + Func proxyOperationManagerCreator = ( string source, ProxyDiscoveryManager proxyDiscoveryManager) => @@ -102,7 +102,7 @@ public IProxyDiscoveryManager GetDiscoveryManager( // If the proxy creation process based on test session info failed, then // we'll proceed with the normal creation process as if no test session // info was passed in in the first place. - // + // // WARNING: This should not normally happen and it raises questions // regarding the test session pool operation and consistency. EqtTrace.Warning("ProxyDiscoveryManager creation with test session failed."); @@ -117,79 +117,79 @@ public IProxyDiscoveryManager GetDiscoveryManager( return proxyOperationManager; }; - // In case we have an active test session, we always prefer the already - // created proxies instead of the ones that need to be created on the spot. - return (discoveryCriteria.TestSessionInfo != null) - ? new ProxyDiscoveryManager( - discoveryCriteria.TestSessionInfo, - proxyOperationManagerCreator) - : new ProxyDiscoveryManager( - requestData, - new TestRequestSender(requestData.ProtocolConfig, hostManager), - hostManager); - }; - - return (parallelLevel > 1 || !testHostManager.Shared) - ? new ParallelProxyDiscoveryManager( + // In case we have an active test session, we always prefer the already + // created proxies instead of the ones that need to be created on the spot. + return (discoveryCriteria.TestSessionInfo != null) + ? new ProxyDiscoveryManager( + discoveryCriteria.TestSessionInfo, + proxyOperationManagerCreator) + : new ProxyDiscoveryManager( requestData, - proxyDiscoveryManagerCreator, - parallelLevel, - sharedHosts: testHostManager.Shared) - : proxyDiscoveryManagerCreator(); - } + new TestRequestSender(requestData.ProtocolConfig, hostManager), + hostManager); + }; - /// - public IProxyExecutionManager GetExecutionManager( - IRequestData requestData, - ITestRuntimeProvider testHostManager, - TestRunCriteria testRunCriteria) - { - var distinctSources = GetDistinctNumberOfSources(testRunCriteria); - var parallelLevel = this.VerifyParallelSettingAndCalculateParallelLevel( - distinctSources, - testRunCriteria.TestRunSettings); + return (parallelLevel > 1 || !testHostManager.Shared) + ? new ParallelProxyDiscoveryManager( + requestData, + proxyDiscoveryManagerCreator, + parallelLevel, + sharedHosts: testHostManager.Shared) + : proxyDiscoveryManagerCreator(); + } + + /// + public IProxyExecutionManager GetExecutionManager( + IRequestData requestData, + ITestRuntimeProvider testHostManager, + TestRunCriteria testRunCriteria) + { + var distinctSources = GetDistinctNumberOfSources(testRunCriteria); + var parallelLevel = VerifyParallelSettingAndCalculateParallelLevel( + distinctSources, + testRunCriteria.TestRunSettings); - // Collecting IsParallel enabled. - requestData.MetricsCollection.Add( - TelemetryDataConstants.ParallelEnabledDuringExecution, - parallelLevel > 1 ? "True" : "False"); + // Collecting IsParallel enabled. + requestData.MetricsCollection.Add( + TelemetryDataConstants.ParallelEnabledDuringExecution, + parallelLevel > 1 ? "True" : "False"); - var isDataCollectorEnabled = XmlRunSettingsUtilities.IsDataCollectionEnabled(testRunCriteria.TestRunSettings); - var isInProcDataCollectorEnabled = XmlRunSettingsUtilities.IsInProcDataCollectionEnabled(testRunCriteria.TestRunSettings); + var isDataCollectorEnabled = XmlRunSettingsUtilities.IsDataCollectionEnabled(testRunCriteria.TestRunSettings); + var isInProcDataCollectorEnabled = XmlRunSettingsUtilities.IsInProcDataCollectionEnabled(testRunCriteria.TestRunSettings); - if (this.ShouldRunInNoIsolation( + if (ShouldRunInNoIsolation( testRunCriteria.TestRunSettings, parallelLevel > 1, isDataCollectorEnabled || isInProcDataCollectorEnabled)) - { - var isTelemetryOptedIn = requestData.IsTelemetryOptedIn; - var newRequestData = this.GetRequestData(isTelemetryOptedIn); - return new InProcessProxyExecutionManager( - testHostManager, - new TestHostManagerFactory(newRequestData)); - } + { + var isTelemetryOptedIn = requestData.IsTelemetryOptedIn; + var newRequestData = GetRequestData(isTelemetryOptedIn); + return new InProcessProxyExecutionManager( + testHostManager, + new TestHostManagerFactory(newRequestData)); + } - // SetupChannel ProxyExecutionManager with data collection if data collectors are - // specififed in run settings. - Func proxyExecutionManagerCreator = () => - { - // Create a new host manager, to be associated with individual - // ProxyExecutionManager(&POM) - var hostManager = this.testHostProviderManager.GetTestHostManagerByRunConfiguration(testRunCriteria.TestRunSettings); - hostManager?.Initialize(TestSessionMessageLogger.Instance, testRunCriteria.TestRunSettings); + // SetupChannel ProxyExecutionManager with data collection if data collectors are + // specified in run settings. + Func proxyExecutionManagerCreator = () => + { + // Create a new host manager, to be associated with individual + // ProxyExecutionManager(&POM) + var hostManager = _testHostProviderManager.GetTestHostManagerByRunConfiguration(testRunCriteria.TestRunSettings); + hostManager?.Initialize(TestSessionMessageLogger.Instance, testRunCriteria.TestRunSettings); - if (testRunCriteria.TestHostLauncher != null) - { - hostManager.SetCustomLauncher(testRunCriteria.TestHostLauncher); - } + if (testRunCriteria.TestHostLauncher != null) + { + hostManager.SetCustomLauncher(testRunCriteria.TestHostLauncher); + } - var requestSender = new TestRequestSender(requestData.ProtocolConfig, hostManager); + var requestSender = new TestRequestSender(requestData.ProtocolConfig, hostManager); - if (testRunCriteria.TestSessionInfo != null) - { - // This function is used to either take a pre-existing proxy operation manager from - // the test pool or to create a new proxy operation manager on the spot. - Func + if (testRunCriteria.TestSessionInfo != null) + { + // This function is used to either take a pre-existing proxy operation manager from + // the test pool or to create a new proxy operation manager on the spot. + Func proxyOperationManagerCreator = ( string source, ProxyExecutionManager proxyExecutionManager) => @@ -204,7 +204,7 @@ public IProxyExecutionManager GetExecutionManager( // If the proxy creation process based on test session info failed, then // we'll proceed with the normal creation process as if no test session // info was passed in in the first place. - // + // // WARNING: This should not normally happen and it raises questions // regarding the test session pool operation and consistency. EqtTrace.Warning("ProxyExecutionManager creation with test session failed."); @@ -219,310 +219,298 @@ public IProxyExecutionManager GetExecutionManager( return proxyOperationManager; }; - // In case we have an active test session, data collection needs were - // already taken care of when first creating the session. As a consequence - // we always return this proxy instead of choosing between the vanilla - // execution proxy and the one with data collection enabled. - return new ProxyExecutionManager( - testRunCriteria.TestSessionInfo, - proxyOperationManagerCreator, - testRunCriteria.DebugEnabledForTestSession); - } + // In case we have an active test session, data collection needs were + // already taken care of when first creating the session. As a consequence + // we always return this proxy instead of choosing between the vanilla + // execution proxy and the one with data collection enabled. + return new ProxyExecutionManager( + testRunCriteria.TestSessionInfo, + proxyOperationManagerCreator, + testRunCriteria.DebugEnabledForTestSession); + } - return isDataCollectorEnabled - ? new ProxyExecutionManagerWithDataCollection( - requestData, - requestSender, - hostManager, - new ProxyDataCollectionManager( - requestData, - testRunCriteria.TestRunSettings, - GetSourcesFromTestRunCriteria(testRunCriteria))) - : new ProxyExecutionManager( + return isDataCollectorEnabled + ? new ProxyExecutionManagerWithDataCollection( + requestData, + requestSender, + hostManager, + new ProxyDataCollectionManager( requestData, - requestSender, - hostManager); - }; - - // parallelLevel = 1 for desktop should go via else route. - var executionManager = (parallelLevel > 1 || !testHostManager.Shared) - ? new ParallelProxyExecutionManager( + testRunCriteria.TestRunSettings, + GetSourcesFromTestRunCriteria(testRunCriteria))) + : new ProxyExecutionManager( requestData, - proxyExecutionManagerCreator, - parallelLevel, - sharedHosts: testHostManager.Shared) - : proxyExecutionManagerCreator(); + requestSender, + hostManager); + }; - EqtTrace.Verbose($"TestEngine.GetExecutionManager: Chosen execution manager '{executionManager.GetType().AssemblyQualifiedName}' ParallelLevel '{parallelLevel}' Shared host '{testHostManager.Shared}'"); + // parallelLevel = 1 for desktop should go via else route. + var executionManager = (parallelLevel > 1 || !testHostManager.Shared) + ? new ParallelProxyExecutionManager( + requestData, + proxyExecutionManagerCreator, + parallelLevel, + sharedHosts: testHostManager.Shared) + : proxyExecutionManagerCreator(); - return executionManager; - } + EqtTrace.Verbose($"TestEngine.GetExecutionManager: Chosen execution manager '{executionManager.GetType().AssemblyQualifiedName}' ParallelLevel '{parallelLevel}' Shared host '{testHostManager.Shared}'"); - /// - public IProxyTestSessionManager GetTestSessionManager( - IRequestData requestData, - StartTestSessionCriteria testSessionCriteria) - { - var parallelLevel = this.VerifyParallelSettingAndCalculateParallelLevel( - testSessionCriteria.Sources.Count, - testSessionCriteria.RunSettings); + return executionManager; + } - requestData.MetricsCollection.Add( - TelemetryDataConstants.ParallelEnabledDuringStartTestSession, - parallelLevel > 1 ? "True" : "False"); + /// + public IProxyTestSessionManager GetTestSessionManager( + IRequestData requestData, + StartTestSessionCriteria testSessionCriteria) + { + var parallelLevel = VerifyParallelSettingAndCalculateParallelLevel( + testSessionCriteria.Sources.Count, + testSessionCriteria.RunSettings); - var isDataCollectorEnabled = XmlRunSettingsUtilities.IsDataCollectionEnabled(testSessionCriteria.RunSettings); - var isInProcDataCollectorEnabled = XmlRunSettingsUtilities.IsInProcDataCollectionEnabled(testSessionCriteria.RunSettings); + requestData.MetricsCollection.Add( + TelemetryDataConstants.ParallelEnabledDuringStartTestSession, + parallelLevel > 1 ? "True" : "False"); - if (this.ShouldRunInNoIsolation( + var isDataCollectorEnabled = XmlRunSettingsUtilities.IsDataCollectionEnabled(testSessionCriteria.RunSettings); + var isInProcDataCollectorEnabled = XmlRunSettingsUtilities.IsInProcDataCollectionEnabled(testSessionCriteria.RunSettings); + + if (ShouldRunInNoIsolation( testSessionCriteria.RunSettings, parallelLevel > 1, isDataCollectorEnabled || isInProcDataCollectorEnabled)) + { + // This condition is the equivalent of the in-process proxy execution manager case. + // In this case all tests will be run in the vstest.console process, so there's no + // test host to be started. As a consequence there'll be no session info. + return null; + } + + Func proxyCreator = () => + { + var hostManager = _testHostProviderManager.GetTestHostManagerByRunConfiguration(testSessionCriteria.RunSettings); + if (hostManager == null) { - // This condition is the equivalent of the in-process proxy execution manager case. - // In this case all tests will be run in the vstest.console process, so there's no - // test host to be started. As a consequence there'll be no session info. - return null; + throw new TestPlatformException( + string.Format( + CultureInfo.CurrentCulture, + Resources.Resources.NoTestHostProviderFound)); } - Func proxyCreator = () => + hostManager.Initialize(TestSessionMessageLogger.Instance, testSessionCriteria.RunSettings); + if (testSessionCriteria.TestHostLauncher != null) { - var hostManager = this.testHostProviderManager.GetTestHostManagerByRunConfiguration(testSessionCriteria.RunSettings); - if (hostManager == null) - { - throw new TestPlatformException( - string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.NoTestHostProviderFound)); - } - - hostManager.Initialize(TestSessionMessageLogger.Instance, testSessionCriteria.RunSettings); - if (testSessionCriteria.TestHostLauncher != null) - { - hostManager.SetCustomLauncher(testSessionCriteria.TestHostLauncher); - } - - var requestSender = new TestRequestSender(requestData.ProtocolConfig, hostManager) - { - CloseConnectionOnOperationComplete = false - }; + hostManager.SetCustomLauncher(testSessionCriteria.TestHostLauncher); + } - // TODO (copoiena): For now we don't support data collection alongside test - // sessions. - // - // The reason for this is that, in the case of Code Coverage for example, the - // data collector needs to pass some environment variables to the testhost process - // before the testhost process is started. This means that the data collector must - // be running when the testhost process is spawned, however the testhost process - // should be spawned during build, and it's problematic to have the data collector - // running during build because it must instrument the .dll files that don't exist - // yet. - return isDataCollectorEnabled - ? null - // ? new ProxyOperationManagerWithDataCollection( - // requestData, - // requestSender, - // hostManager, - // new ProxyDataCollectionManager( - // requestData, - // testSessionCriteria.RunSettings, - // testSessionCriteria.Sources)) - // { - // CloseRequestSenderChannelOnProxyClose = true - // } - : new ProxyOperationManager( - requestData, - requestSender, - hostManager); + var requestSender = new TestRequestSender(requestData.ProtocolConfig, hostManager) + { + CloseConnectionOnOperationComplete = false }; - var testhostManager = this.testHostProviderManager.GetTestHostManagerByRunConfiguration(testSessionCriteria.RunSettings); - testhostManager.Initialize(TestSessionMessageLogger.Instance, testSessionCriteria.RunSettings); - var testhostCount = (parallelLevel > 1 || !testhostManager.Shared) - ? testSessionCriteria.Sources.Count - : 1; + // TODO (copoiena): For now we don't support data collection alongside test + // sessions. + // + // The reason for this is that, in the case of Code Coverage for example, the + // data collector needs to pass some environment variables to the testhost process + // before the testhost process is started. This means that the data collector must + // be running when the testhost process is spawned, however the testhost process + // should be spawned during build, and it's problematic to have the data collector + // running during build because it must instrument the .dll files that don't exist + // yet. + return isDataCollectorEnabled + ? null + // ? new ProxyOperationManagerWithDataCollection( + // requestData, + // requestSender, + // hostManager, + // new ProxyDataCollectionManager( + // requestData, + // testSessionCriteria.RunSettings, + // testSessionCriteria.Sources)) + // { + // CloseRequestSenderChannelOnProxyClose = true + // } + : new ProxyOperationManager( + requestData, + requestSender, + hostManager); + }; - return new ProxyTestSessionManager(testSessionCriteria, testhostCount, proxyCreator); - } + var testhostManager = _testHostProviderManager.GetTestHostManagerByRunConfiguration(testSessionCriteria.RunSettings); + testhostManager.Initialize(TestSessionMessageLogger.Instance, testSessionCriteria.RunSettings); + var testhostCount = (parallelLevel > 1 || !testhostManager.Shared) + ? testSessionCriteria.Sources.Count + : 1; - /// - public ITestExtensionManager GetExtensionManager() - { - return this.testExtensionManager - ?? (this.testExtensionManager = new TestExtensionManager()); - } + return new ProxyTestSessionManager(testSessionCriteria, testhostCount, proxyCreator); + } - /// - public ITestLoggerManager GetLoggerManager(IRequestData requestData) - { - return new TestLoggerManager( - requestData, - TestSessionMessageLogger.Instance, - new InternalTestLoggerEvents(TestSessionMessageLogger.Instance)); - } + /// + public ITestExtensionManager GetExtensionManager() => _testExtensionManager ??= new TestExtensionManager(); - #endregion + /// + public ITestLoggerManager GetLoggerManager(IRequestData requestData) + { + return new TestLoggerManager( + requestData, + TestSessionMessageLogger.Instance, + new InternalTestLoggerEvents(TestSessionMessageLogger.Instance)); + } - private static int GetDistinctNumberOfSources(TestRunCriteria testRunCriteria) - { - // No point in creating more processes if number of sources is less than what the user - // configured for. - int numSources = 1; - if (testRunCriteria.HasSpecificTests) - { - numSources = new HashSet( - testRunCriteria.Tests.Select(testCase => testCase.Source)).Count; - } - else - { - numSources = testRunCriteria.Sources.Count(); - } + #endregion - return numSources; - } + private static int GetDistinctNumberOfSources(TestRunCriteria testRunCriteria) + { + // No point in creating more processes if number of sources is less than what the user + // configured for. + int numSources = testRunCriteria.HasSpecificTests + ? new HashSet( + testRunCriteria.Tests.Select(testCase => testCase.Source)).Count + : testRunCriteria.Sources.Count(); + return numSources; + } - /// - /// Verifies parallel setting and returns parallel level to use based on the run criteria. - /// - /// - /// The source count. - /// The run settings. - /// - /// The parallel level to use. - private int VerifyParallelSettingAndCalculateParallelLevel( - int sourceCount, - string runSettings) + /// + /// Verifies parallel setting and returns parallel level to use based on the run criteria. + /// + /// + /// The source count. + /// The run settings. + /// + /// The parallel level to use. + private int VerifyParallelSettingAndCalculateParallelLevel( + int sourceCount, + string runSettings) + { + // Default is 1. + int parallelLevelToUse; + try { - // Default is 1. - int parallelLevelToUse = 1; - try + // Check the user parallel setting. + int userParallelSetting = RunSettingsUtilities.GetMaxCpuCount(runSettings); + parallelLevelToUse = userParallelSetting == 0 + ? Environment.ProcessorCount + : userParallelSetting; + var enableParallel = parallelLevelToUse > 1; + + EqtTrace.Verbose( + "TestEngine: Initializing Parallel Execution as MaxCpuCount is set to: {0}", + parallelLevelToUse); + + // Verify if the number of sources is less than user setting of parallel. + // We should use number of sources as the parallel level, if sources count is less + // than parallel level. + if (enableParallel) { - // Check the user parallel setting. - int userParallelSetting = RunSettingsUtilities.GetMaxCpuCount(runSettings); - parallelLevelToUse = userParallelSetting == 0 - ? Environment.ProcessorCount - : userParallelSetting; - var enableParallel = parallelLevelToUse > 1; - - EqtTrace.Verbose( - "TestEngine: Initializing Parallel Execution as MaxCpuCount is set to: {0}", - parallelLevelToUse); - - // Verify if the number of sources is less than user setting of parallel. - // We should use number of sources as the parallel level, if sources count is less - // than parallel level. - if (enableParallel) - { - parallelLevelToUse = Math.Min(sourceCount, parallelLevelToUse); + parallelLevelToUse = Math.Min(sourceCount, parallelLevelToUse); - // If only one source, no need to use parallel service client. - enableParallel = parallelLevelToUse > 1; + // If only one source, no need to use parallel service client. + enableParallel = parallelLevelToUse > 1; - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Verbose( - "TestEngine: ParallelExecution set to '{0}' as the parallel level is adjusted to '{1}' based on number of sources", - enableParallel, - parallelLevelToUse); - } + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Verbose( + "TestEngine: ParallelExecution set to '{0}' as the parallel level is adjusted to '{1}' based on number of sources", + enableParallel, + parallelLevelToUse); } } - catch (Exception ex) - { - EqtTrace.Error( - "TestEngine: Error occurred while initializing ParallelExecution: {0}", - ex); - EqtTrace.Warning("TestEngine: Defaulting to Sequential Execution"); - - parallelLevelToUse = 1; - } - - return parallelLevelToUse; } - - private bool ShouldRunInNoIsolation( - string runsettings, - bool isParallelEnabled, - bool isDataCollectorEnabled) + catch (Exception ex) { - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettings); + EqtTrace.Error( + "TestEngine: Error occurred while initializing ParallelExecution: {0}", + ex); + EqtTrace.Warning("TestEngine: Defaulting to Sequential Execution"); - if (runConfiguration.InIsolation) - { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("TestEngine.ShouldRunInNoIsolation: running test in isolation"); - } - return false; - } + parallelLevelToUse = 1; + } - // Run tests in isolation if run is authored using testsettings. - if (InferRunSettingsHelper.IsTestSettingsEnabled(runsettings)) - { - return false; - } + return parallelLevelToUse; + } - var currentProcessPath = this.processHelper.GetCurrentProcessFileName(); + private bool ShouldRunInNoIsolation( + string runsettings, + bool isParallelEnabled, + bool isDataCollectorEnabled) + { + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettings); - // If running with the dotnet executable, then don't run in in process. - if (currentProcessPath.EndsWith("dotnet", StringComparison.OrdinalIgnoreCase) - || currentProcessPath.EndsWith("dotnet.exe", StringComparison.OrdinalIgnoreCase)) + if (runConfiguration.InIsolation) + { + if (EqtTrace.IsInfoEnabled) { - return false; + EqtTrace.Info("TestEngine.ShouldRunInNoIsolation: running test in isolation"); } + return false; + } - // Return true if - // 1) Not running in parallel; - // 2) Data collector is not enabled; - // 3) Target framework is X64 or anyCpu; - // 4) DisableAppDomain is false; - // 5) Not running in design mode; - // 6) target framework is NETFramework (Desktop test); - if (!isParallelEnabled && - !isDataCollectorEnabled && - (runConfiguration.TargetPlatform == ObjectModel.Constants.DefaultPlatform || runConfiguration.TargetPlatform == Architecture.AnyCPU) && - !runConfiguration.DisableAppDomain && - !runConfiguration.DesignMode && - runConfiguration.TargetFramework.Name.IndexOf("netframework", StringComparison.OrdinalIgnoreCase) >= 0) - { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("TestEngine.ShouldRunInNoIsolation: running test in process(inside vstest.console.exe process)"); - } - return true; - } + // Run tests in isolation if run is authored using testsettings. + if (InferRunSettingsHelper.IsTestSettingsEnabled(runsettings)) + { + return false; + } + + var currentProcessPath = _processHelper.GetCurrentProcessFileName(); + // If running with the dotnet executable, then don't run in in process. + if (currentProcessPath.EndsWith("dotnet", StringComparison.OrdinalIgnoreCase) + || currentProcessPath.EndsWith("dotnet.exe", StringComparison.OrdinalIgnoreCase)) + { return false; } - /// - /// Get request data on basis of telemetry opted in or not. - /// - /// - /// A flag indicating if telemetry is opted in. - /// - /// The request data. - private IRequestData GetRequestData(bool isTelemetryOptedIn) + // Return true if + // 1) Not running in parallel; + // 2) Data collector is not enabled; + // 3) Target framework is X64 or anyCpu; + // 4) DisableAppDomain is false; + // 5) Not running in design mode; + // 6) target framework is NETFramework (Desktop test); + if (!isParallelEnabled && + !isDataCollectorEnabled && + (runConfiguration.TargetPlatform == ObjectModel.Constants.DefaultPlatform || runConfiguration.TargetPlatform == Architecture.AnyCPU) && + !runConfiguration.DisableAppDomain && + !runConfiguration.DesignMode && + runConfiguration.TargetFramework.Name.IndexOf("netframework", StringComparison.OrdinalIgnoreCase) >= 0) { - return new RequestData + if (EqtTrace.IsInfoEnabled) { - MetricsCollection = isTelemetryOptedIn - ? (IMetricsCollection)new MetricsCollection() - : new NoOpMetricsCollection(), - IsTelemetryOptedIn = isTelemetryOptedIn - }; + EqtTrace.Info("TestEngine.ShouldRunInNoIsolation: running test in process(inside vstest.console.exe process)"); + } + return true; } - /// - /// Gets test sources from test run criteria. - /// - /// - /// The test sources. - private IEnumerable GetSourcesFromTestRunCriteria(TestRunCriteria testRunCriteria) + return false; + } + + /// + /// Get request data on basis of telemetry opted in or not. + /// + /// + /// A flag indicating if telemetry is opted in. + /// + /// The request data. + private IRequestData GetRequestData(bool isTelemetryOptedIn) + { + return new RequestData { - return testRunCriteria.HasSpecificTests - ? TestSourcesUtility.GetSources(testRunCriteria.Tests) - : testRunCriteria.Sources; - } + MetricsCollection = isTelemetryOptedIn + ? (IMetricsCollection)new MetricsCollection() + : new NoOpMetricsCollection(), + IsTelemetryOptedIn = isTelemetryOptedIn + }; + } + + /// + /// Gets test sources from test run criteria. + /// + /// + /// The test sources. + private IEnumerable GetSourcesFromTestRunCriteria(TestRunCriteria testRunCriteria) + { + return testRunCriteria.HasSpecificTests + ? TestSourcesUtility.GetSources(testRunCriteria.Tests) + : testRunCriteria.Sources; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/TestExtensionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/TestExtensionManager.cs index 807aeb397a..827ba7bc4c 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/TestExtensionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/TestExtensionManager.cs @@ -1,28 +1,28 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; + +using System.Collections.Generic; + +using Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; +using ObjectModel.Engine; - /// - /// Orchestrates extensions for this engine. - /// - public class TestExtensionManager : ITestExtensionManager +/// +/// Orchestrates extensions for this engine. +/// +public class TestExtensionManager : ITestExtensionManager +{ + /// + public void ClearExtensions() { - /// - public void ClearExtensions() - { - TestPluginCache.Instance.ClearExtensions(); - } + TestPluginCache.Instance.ClearExtensions(); + } - /// - public void UseAdditionalExtensions(IEnumerable pathToAdditionalExtensions, bool skipExtensionFilters) - { - TestPluginCache.Instance.UpdateExtensions(pathToAdditionalExtensions, skipExtensionFilters); - } + /// + public void UseAdditionalExtensions(IEnumerable pathToAdditionalExtensions, bool skipExtensionFilters) + { + TestPluginCache.Instance.UpdateExtensions(pathToAdditionalExtensions, skipExtensionFilters); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/TestHostManagerFactory.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/TestHostManagerFactory.cs index 9f5c967e08..e9e7fa5d0d 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/TestHostManagerFactory.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/TestHostManagerFactory.cs @@ -1,59 +1,47 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; + +using Discovery; + +using Execution; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using ObjectModel.Engine.TesthostProtocol; + +/// +/// The factory that provides discovery and execution managers to the test host. +/// +public class TestHostManagerFactory : ITestHostManagerFactory { - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; + private IDiscoveryManager _discoveryManager; + private IExecutionManager _executionManager; + private readonly IRequestData _requestData; /// - /// The factory that provides discovery and execution managers to the test host. + /// Initializes a new instance of the class. /// - public class TestHostManagerFactory : ITestHostManagerFactory + /// + /// Provide common services and data for a discovery/run request. + /// + public TestHostManagerFactory(IRequestData requestData) { - private IDiscoveryManager discoveryManager; - private IExecutionManager executionManager; - private IRequestData requestData; - - /// - /// Initializes a new instance of the class. - /// - /// - /// Provide common services and data for a discovery/run request. - /// - public TestHostManagerFactory(IRequestData requestData) - { - this.requestData = requestData ?? throw new System.ArgumentNullException(nameof(requestData)); - } - - /// - /// The discovery manager instance for any discovery related operations inside of the test host. - /// - /// The discovery manager. - public IDiscoveryManager GetDiscoveryManager() - { - if (this.discoveryManager == null) - { - this.discoveryManager = new DiscoveryManager(this.requestData); - } - - return this.discoveryManager; - } - - /// - /// The execution manager instance for any discovery related operations inside of the test host. - /// - /// The execution manager. - public IExecutionManager GetExecutionManager() - { - if (this.executionManager == null) - { - this.executionManager = new ExecutionManager(this.requestData); - } - - return this.executionManager; - } + _requestData = requestData ?? throw new System.ArgumentNullException(nameof(requestData)); } -} + + /// + /// The discovery manager instance for any discovery related operations inside of the test host. + /// + /// The discovery manager. + public IDiscoveryManager GetDiscoveryManager() + => _discoveryManager ??= new DiscoveryManager(_requestData); + + /// + /// The execution manager instance for any discovery related operations inside of the test host. + /// + /// The execution manager. + public IExecutionManager GetExecutionManager() + => _executionManager ??= new ExecutionManager(_requestData); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/TestSession/ProxyTestSessionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/TestSession/ProxyTestSessionManager.cs index 142400d0a2..1a6bccb87a 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/TestSession/ProxyTestSessionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/TestSession/ProxyTestSessionManager.cs @@ -1,348 +1,345 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine -{ - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Threading.Tasks; +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading.Tasks; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; +using Client; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; - using CrossPlatResources = Resources.Resources; +using CrossPlatResources = Resources.Resources; + +/// +/// Orchestrates test session operations for the engine communicating with the client. +/// +public class ProxyTestSessionManager : IProxyTestSessionManager +{ + private readonly object _lockObject = new(); + private readonly object _proxyOperationLockObject = new(); + private volatile bool _proxySetupFailed = false; + private readonly StartTestSessionCriteria _testSessionCriteria; + private readonly int _testhostCount; + private TestSessionInfo _testSessionInfo; + private readonly Func _proxyCreator; + private readonly IList _proxyContainerList; + private readonly IDictionary _proxyMap; /// - /// Orchestrates test session operations for the engine communicating with the client. + /// Initializes a new instance of the class. /// - public class ProxyTestSessionManager : IProxyTestSessionManager + /// + /// The test session criteria. + /// The testhost count. + /// The proxy creator. + public ProxyTestSessionManager( + StartTestSessionCriteria criteria, + int testhostCount, + Func proxyCreator) { - private readonly object lockObject = new object(); - private readonly object proxyOperationLockObject = new object(); - private volatile bool proxySetupFailed = false; - private StartTestSessionCriteria testSessionCriteria; - private int testhostCount; - private TestSessionInfo testSessionInfo; - private Func proxyCreator; - private IList proxyContainerList; - private IDictionary proxyMap; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The test session criteria. - /// The testhost count. - /// The proxy creator. - public ProxyTestSessionManager( - StartTestSessionCriteria criteria, - int testhostCount, - Func proxyCreator) - { - this.testSessionCriteria = criteria; - this.testhostCount = testhostCount; - this.proxyCreator = proxyCreator; + _testSessionCriteria = criteria; + _testhostCount = testhostCount; + _proxyCreator = proxyCreator; - this.proxyContainerList = new List(); - this.proxyMap = new Dictionary(); - } + _proxyContainerList = new List(); + _proxyMap = new Dictionary(); + } - /// - public virtual bool StartSession(ITestSessionEventsHandler eventsHandler) + /// + public virtual bool StartSession(ITestSessionEventsHandler eventsHandler) + { + lock (_lockObject) { - lock (this.lockObject) - { - if (this.testSessionInfo != null) - { - return false; - } - this.testSessionInfo = new TestSessionInfo(); - } - - // Create all the proxies in parallel, one task per proxy. - var taskList = new Task[this.testhostCount]; - for (int i = 0; i < taskList.Length; ++i) - { - // The testhost count is equal to 1 because one of the following conditions - // holds true: - // 1. we're dealing with a shared testhost (e.g.: .NET Framework testhost) - // that must process multiple sources within the same testhost process; - // 2. we're dealing with a single testhost (shared or not, it doesn't matter) - // that must process a single source; - // Either way, no further processing of the original test source list is needed - // in either of those cases. - // - // Consequentely, if the testhost count is greater than one it means that the - // testhost is not shared (e.g.: .NET Core testhost), in which case each test - // source must be processed by a dedicated testhost, which is the reason we - // create a list with a single element, i.e. the current source to be processed. - var sources = (this.testhostCount == 1) - ? this.testSessionCriteria.Sources - : new List() { this.testSessionCriteria.Sources[i] }; - - taskList[i] = Task.Factory.StartNew(() => - { - if (!this.SetupRawProxy( - sources, - this.testSessionCriteria.RunSettings)) - { - this.proxySetupFailed = true; - } - }); - } - - // Wait for proxy creation to be over. - Task.WaitAll(taskList); - - // Dispose of all proxies if even one of them failed during setup. - if (this.proxySetupFailed) + if (_testSessionInfo != null) { - this.DisposeProxies(); return false; } - - // Make the session available. - if (!TestSessionPool.Instance.AddSession(this.testSessionInfo, this)) - { - this.DisposeProxies(); - return false; - } - - // Let the caller know the session has been created. - eventsHandler.HandleStartTestSessionComplete(this.testSessionInfo); - return true; + _testSessionInfo = new TestSessionInfo(); } - /// - public virtual bool StopSession() + // Create all the proxies in parallel, one task per proxy. + var taskList = new Task[_testhostCount]; + for (int i = 0; i < taskList.Length; ++i) { - lock (this.lockObject) + // The testhost count is equal to 1 because one of the following conditions + // holds true: + // 1. we're dealing with a shared testhost (e.g.: .NET Framework testhost) + // that must process multiple sources within the same testhost process; + // 2. we're dealing with a single testhost (shared or not, it doesn't matter) + // that must process a single source; + // Either way, no further processing of the original test source list is needed + // in either of those cases. + // + // Consequentely, if the testhost count is greater than one it means that the + // testhost is not shared (e.g.: .NET Core testhost), in which case each test + // source must be processed by a dedicated testhost, which is the reason we + // create a list with a single element, i.e. the current source to be processed. + var sources = (_testhostCount == 1) + ? _testSessionCriteria.Sources + : new List() { _testSessionCriteria.Sources[i] }; + + taskList[i] = Task.Factory.StartNew(() => { - if (this.testSessionInfo == null) + if (!SetupRawProxy( + sources, + _testSessionCriteria.RunSettings)) { - return false; + _proxySetupFailed = true; } - this.testSessionInfo = null; - } + }); + } - this.DisposeProxies(); - return true; + // Wait for proxy creation to be over. + Task.WaitAll(taskList); + + // Dispose of all proxies if even one of them failed during setup. + if (_proxySetupFailed) + { + DisposeProxies(); + return false; } - /// - /// Dequeues a proxy to be used either by discovery or execution. - /// - /// - /// The source to be associated to this proxy. - /// The run settings. - /// - /// The dequeued proxy. - public virtual ProxyOperationManager DequeueProxy(string source, string runSettings) + // Make the session available. + if (!TestSessionPool.Instance.AddSession(_testSessionInfo, this)) { - ProxyOperationManagerContainer proxyContainer = null; + DisposeProxies(); + return false; + } + + // Let the caller know the session has been created. + eventsHandler.HandleStartTestSessionComplete(_testSessionInfo); + return true; + } - lock (this.proxyOperationLockObject) + /// + public virtual bool StopSession() + { + lock (_lockObject) + { + if (_testSessionInfo == null) { - // No proxy available means the caller will have to create its own proxy. - if (!this.proxyMap.ContainsKey(source) - || !this.proxyContainerList[this.proxyMap[source]].IsAvailable) - { - throw new InvalidOperationException( - string.Format( - CultureInfo.CurrentUICulture, - CrossPlatResources.NoAvailableProxyForDeque)); - } + return false; + } + _testSessionInfo = null; + } - // We must ensure the current run settings match the run settings from when the - // testhost was started. If not, throw an exception to force the caller to create - // its own proxy instead. - // - // TODO (copoiena): This run settings match is rudimentary. We should refine the - // match criteria in the future. - if (!this.testSessionCriteria.RunSettings.Equals(runSettings)) - { - throw new InvalidOperationException( - string.Format( - CultureInfo.CurrentUICulture, - CrossPlatResources.NoProxyMatchesDescription)); - } + DisposeProxies(); + return true; + } - // Get the actual proxy. - proxyContainer = this.proxyContainerList[this.proxyMap[source]]; + /// + /// Dequeues a proxy to be used either by discovery or execution. + /// + /// + /// The source to be associated to this proxy. + /// The run settings. + /// + /// The dequeued proxy. + public virtual ProxyOperationManager DequeueProxy(string source, string runSettings) + { + ProxyOperationManagerContainer proxyContainer = null; + + lock (_proxyOperationLockObject) + { + // No proxy available means the caller will have to create its own proxy. + if (!_proxyMap.ContainsKey(source) + || !_proxyContainerList[_proxyMap[source]].IsAvailable) + { + throw new InvalidOperationException( + string.Format( + CultureInfo.CurrentUICulture, + CrossPlatResources.NoAvailableProxyForDeque)); + } - // Mark the proxy as unavailable. - proxyContainer.IsAvailable = false; + // We must ensure the current run settings match the run settings from when the + // testhost was started. If not, throw an exception to force the caller to create + // its own proxy instead. + // + // TODO (copoiena): This run settings match is rudimentary. We should refine the + // match criteria in the future. + if (!_testSessionCriteria.RunSettings.Equals(runSettings)) + { + throw new InvalidOperationException( + string.Format( + CultureInfo.CurrentUICulture, + CrossPlatResources.NoProxyMatchesDescription)); } - return proxyContainer.Proxy; + // Get the actual proxy. + proxyContainer = _proxyContainerList[_proxyMap[source]]; + + // Mark the proxy as unavailable. + proxyContainer.IsAvailable = false; } - /// - /// Enqueues a proxy back once discovery or executions is done with it. - /// - /// - /// The id of the proxy to be re-enqueued. - /// - /// True if the operation succeeded, false otherwise. - public virtual bool EnqueueProxy(int proxyId) + return proxyContainer.Proxy; + } + + /// + /// Enqueues a proxy back once discovery or executions is done with it. + /// + /// + /// The id of the proxy to be re-enqueued. + /// + /// True if the operation succeeded, false otherwise. + public virtual bool EnqueueProxy(int proxyId) + { + lock (_proxyOperationLockObject) { - lock (this.proxyOperationLockObject) + // Check if the proxy exists. + if (proxyId < 0 || proxyId >= _proxyContainerList.Count) { - // Check if the proxy exists. - if (proxyId < 0 || proxyId >= this.proxyContainerList.Count) - { - throw new ArgumentException( - string.Format( - CultureInfo.CurrentUICulture, - CrossPlatResources.NoSuchProxyId, - proxyId)); - } - - // Get the actual proxy. - var proxyContainer = this.proxyContainerList[proxyId]; - if (proxyContainer.IsAvailable) - { - throw new InvalidOperationException( - string.Format( - CultureInfo.CurrentUICulture, - CrossPlatResources.ProxyIsAlreadyAvailable, - proxyId)); - } + throw new ArgumentException( + string.Format( + CultureInfo.CurrentUICulture, + CrossPlatResources.NoSuchProxyId, + proxyId)); + } - // Mark the proxy as available. - proxyContainer.IsAvailable = true; + // Get the actual proxy. + var proxyContainer = _proxyContainerList[proxyId]; + if (proxyContainer.IsAvailable) + { + throw new InvalidOperationException( + string.Format( + CultureInfo.CurrentUICulture, + CrossPlatResources.ProxyIsAlreadyAvailable, + proxyId)); } - return true; + // Mark the proxy as available. + proxyContainer.IsAvailable = true; } - private int EnqueueNewProxy( - IList sources, - ProxyOperationManagerContainer operationManagerContainer) - { - lock (this.proxyOperationLockObject) - { - var index = this.proxyContainerList.Count; + return true; + } - // Add the proxy container to the proxy container list. - this.proxyContainerList.Add(operationManagerContainer); + private int EnqueueNewProxy( + IList sources, + ProxyOperationManagerContainer operationManagerContainer) + { + lock (_proxyOperationLockObject) + { + var index = _proxyContainerList.Count; - foreach (var source in sources) - { - // Add the proxy index to the map. - this.proxyMap.Add( - source, - index); - } + // Add the proxy container to the proxy container list. + _proxyContainerList.Add(operationManagerContainer); - return index; + foreach (var source in sources) + { + // Add the proxy index to the map. + _proxyMap.Add( + source, + index); } + + return index; } + } - private bool SetupRawProxy( - IList sources, - string runSettings) + private bool SetupRawProxy( + IList sources, + string runSettings) + { + try { - try + // Create and cache the proxy. + var operationManagerProxy = _proxyCreator(); + if (operationManagerProxy == null) { - // Create and cache the proxy. - var operationManagerProxy = this.proxyCreator(); - if (operationManagerProxy == null) - { - return false; - } - - // Initialize the proxy. - operationManagerProxy.Initialize(skipDefaultAdapters: false); - - // Start the test host associated to the proxy. - if (!operationManagerProxy.SetupChannel(sources, runSettings)) - { - return false; - } + return false; + } - // Associate each source in the source list with this new proxy operation - // container. - var operationManagerContainer = new ProxyOperationManagerContainer( - operationManagerProxy, - available: true); + // Initialize the proxy. + operationManagerProxy.Initialize(skipDefaultAdapters: false); - operationManagerContainer.Proxy.Id = this.EnqueueNewProxy(sources, operationManagerContainer); - return true; - } - catch (Exception ex) + // Start the test host associated to the proxy. + if (!operationManagerProxy.SetupChannel(sources, runSettings)) { - // Log & silently eat up the exception. It's a valid course of action to - // just forfeit proxy creation. This means that anyone wishing to get a - // proxy operation manager would have to create their own, on the spot, - // instead of getting one already created, and this case is handled - // gracefully already. - EqtTrace.Error( - "ProxyTestSessionManager.StartSession: Cannot create proxy. Error: {0}", - ex.ToString()); + return false; } - return false; + // Associate each source in the source list with this new proxy operation + // container. + var operationManagerContainer = new ProxyOperationManagerContainer( + operationManagerProxy, + available: true); + + operationManagerContainer.Proxy.Id = EnqueueNewProxy(sources, operationManagerContainer); + return true; } + catch (Exception ex) + { + // Log & silently eat up the exception. It's a valid course of action to + // just forfeit proxy creation. This means that anyone wishing to get a + // proxy operation manager would have to create their own, on the spot, + // instead of getting one already created, and this case is handled + // gracefully already. + EqtTrace.Error( + "ProxyTestSessionManager.StartSession: Cannot create proxy. Error: {0}", + ex.ToString()); + } + + return false; + } - private void DisposeProxies() + private void DisposeProxies() + { + lock (_proxyOperationLockObject) { - lock (this.proxyOperationLockObject) + if (_proxyContainerList.Count == 0) { - if (this.proxyContainerList.Count == 0) - { - return; - } + return; + } - // Dispose of all the proxies in parallel, one task per proxy. - int i = 0; - var taskList = new Task[this.proxyContainerList.Count]; - foreach (var proxyContainer in this.proxyContainerList) - { - taskList[i++] = Task.Factory.StartNew(() => - { - // Initiate the end session handshake with the underlying testhost. - proxyContainer.Proxy.Close(); - }); - } + // Dispose of all the proxies in parallel, one task per proxy. + int i = 0; + var taskList = new Task[_proxyContainerList.Count]; + foreach (var proxyContainer in _proxyContainerList) + { + taskList[i++] = Task.Factory.StartNew(() => + // Initiate the end session handshake with the underlying testhost. + proxyContainer.Proxy.Close()); + } - // Wait for proxy disposal to be over. - Task.WaitAll(taskList); + // Wait for proxy disposal to be over. + Task.WaitAll(taskList); - this.proxyContainerList.Clear(); - this.proxyMap.Clear(); - } + _proxyContainerList.Clear(); + _proxyMap.Clear(); } } +} +/// +/// Defines a container encapsulating the proxy and its corresponding state info. +/// +internal class ProxyOperationManagerContainer +{ /// - /// Defines a container encapsulating the proxy and its corresponding state info. + /// Initializes a new instance of the class. /// - internal class ProxyOperationManagerContainer + /// + /// The proxy. + /// A flag indicating if the proxy is available to do work. + public ProxyOperationManagerContainer(ProxyOperationManager proxy, bool available) { - /// - /// Initializes a new instance of the class. - /// - /// - /// The proxy. - /// A flag indicating if the proxy is available to do work. - public ProxyOperationManagerContainer(ProxyOperationManager proxy, bool available) - { - this.Proxy = proxy; - this.IsAvailable = available; - } + Proxy = proxy; + IsAvailable = available; + } - /// - /// Gets or sets the proxy. - /// - public ProxyOperationManager Proxy { get; set; } + /// + /// Gets or sets the proxy. + /// + public ProxyOperationManager Proxy { get; set; } - /// - /// Gets or sets a flag indicating if the proxy is available to do work. - /// - public bool IsAvailable { get; set; } - } -} + /// + /// Gets or sets a flag indicating if the proxy is available to do work. + /// + public bool IsAvailable { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/TestSession/TestSessionPool.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/TestSession/TestSessionPool.cs index 751a508809..f06d69e4f9 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/TestSession/TestSessionPool.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/TestSession/TestSessionPool.cs @@ -1,202 +1,201 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; + +using System; +using System.Collections.Generic; + +using Client; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; + +/// +/// Represents the test session pool. +/// +public class TestSessionPool { - using System; - using System.Collections.Generic; + private static readonly object InstanceLockObject = new(); + private static volatile TestSessionPool s_instance; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + private readonly object _lockObject = new(); + private readonly Dictionary _sessionPool; /// - /// Represents the test session pool. + /// Initializes a new instance of the class. /// - public class TestSessionPool + internal TestSessionPool() { - private static object instanceLockObject = new object(); - private static volatile TestSessionPool instance; - - private object lockObject = new object(); - private Dictionary sessionPool; - - /// - /// Initializes a new instance of the class. - /// - internal TestSessionPool() - { - this.sessionPool = new Dictionary(); - } + _sessionPool = new Dictionary(); + } - /// - /// Gets the test session pool instance. - /// Sets the test session pool instance for testing purposes only. - /// - /// - /// Thread-safe singleton pattern. - public static TestSessionPool Instance + /// + /// Gets the test session pool instance. + /// Sets the test session pool instance for testing purposes only. + /// + /// + /// Thread-safe singleton pattern. + public static TestSessionPool Instance + { + get { - get + if (s_instance == null) { - if (TestSessionPool.instance == null) + lock (InstanceLockObject) { - lock (TestSessionPool.instanceLockObject) + if (s_instance == null) { - if (TestSessionPool.instance == null) - { - TestSessionPool.instance = new TestSessionPool(); - } + s_instance = new TestSessionPool(); } } - - return TestSessionPool.instance; - } - internal set - { - TestSessionPool.instance = value; } - } - /// - /// Adds a session to the pool. - /// - /// - /// The test session info object. - /// The proxy manager object. - /// - /// True if the operation succeeded, false otherwise. - public virtual bool AddSession( - TestSessionInfo testSessionInfo, - ProxyTestSessionManager proxyManager) + return s_instance; + } + internal set { - lock (this.lockObject) - { - // Check if the session info already exists. - if (this.sessionPool.ContainsKey(testSessionInfo)) - { - return false; - } - - // Adds an association between session info and proxy manager to the pool. - this.sessionPool.Add(testSessionInfo, proxyManager); - return true; - } + s_instance = value; } + } - /// - /// Kills and removes a session from the pool. - /// - /// - /// The test session info object. - /// - /// True if the operation succeeded, false otherwise. - public virtual bool KillSession(TestSessionInfo testSessionInfo) + /// + /// Adds a session to the pool. + /// + /// + /// The test session info object. + /// The proxy manager object. + /// + /// True if the operation succeeded, false otherwise. + public virtual bool AddSession( + TestSessionInfo testSessionInfo, + ProxyTestSessionManager proxyManager) + { + lock (_lockObject) { - // TODO (copoiena): What happens if some request is running for the current session ? - // Should we stop the request as well ? Probably yes. - IProxyTestSessionManager proxyManager = null; - - lock (this.lockObject) + // Check if the session info already exists. + if (_sessionPool.ContainsKey(testSessionInfo)) { - // Check if the session info exists. - if (!this.sessionPool.ContainsKey(testSessionInfo)) - { - return false; - } - - // Remove the session from the pool. - proxyManager = this.sessionPool[testSessionInfo]; - this.sessionPool.Remove(testSessionInfo); + return false; } - // Kill the session. - return proxyManager.StopSession(); + // Adds an association between session info and proxy manager to the pool. + _sessionPool.Add(testSessionInfo, proxyManager); + return true; } + } + + /// + /// Kills and removes a session from the pool. + /// + /// + /// The test session info object. + /// + /// True if the operation succeeded, false otherwise. + public virtual bool KillSession(TestSessionInfo testSessionInfo) + { + // TODO (copoiena): What happens if some request is running for the current session ? + // Should we stop the request as well ? Probably yes. + IProxyTestSessionManager proxyManager = null; - /// - /// Gets a reference to the proxy object from the session pool. - /// - /// - /// The test session info object. - /// The source to be associated to this proxy. - /// The run settings. - /// - /// The proxy object. - public virtual ProxyOperationManager TryTakeProxy( - TestSessionInfo testSessionInfo, - string source, - string runSettings) + lock (_lockObject) { - ProxyTestSessionManager sessionManager = null; - lock (this.lockObject) + // Check if the session info exists. + if (!_sessionPool.ContainsKey(testSessionInfo)) { - if (!this.sessionPool.ContainsKey(testSessionInfo)) - { - return null; - } - - // Gets the session manager reference from the pool. - sessionManager = this.sessionPool[testSessionInfo]; + return false; } - try - { - // Deque an actual proxy to do work. - return sessionManager.DequeueProxy(source, runSettings); - } - catch (InvalidOperationException ex) + // Remove the session from the pool. + proxyManager = _sessionPool[testSessionInfo]; + _sessionPool.Remove(testSessionInfo); + } + + // Kill the session. + return proxyManager.StopSession(); + } + + /// + /// Gets a reference to the proxy object from the session pool. + /// + /// + /// The test session info object. + /// The source to be associated to this proxy. + /// The run settings. + /// + /// The proxy object. + public virtual ProxyOperationManager TryTakeProxy( + TestSessionInfo testSessionInfo, + string source, + string runSettings) + { + ProxyTestSessionManager sessionManager = null; + lock (_lockObject) + { + if (!_sessionPool.ContainsKey(testSessionInfo)) { - // If we are unable to dequeue the proxy we just eat up the exception here as - // it is safe to proceed. - // - // WARNING: This should not normally happen and it raises questions regarding the - // test session pool operation and consistency. - EqtTrace.Warning("TestSessionPool.ReturnProxy failed: {0}", ex.ToString()); + return null; } - return null; + // Gets the session manager reference from the pool. + sessionManager = _sessionPool[testSessionInfo]; } - /// - /// Returns the proxy object to the session pool. - /// - /// - /// The test session info object. - /// The proxy id to be returned. - /// - /// True if the operation succeeded, false otherwise. - public virtual bool ReturnProxy(TestSessionInfo testSessionInfo, int proxyId) + try { - ProxyTestSessionManager sessionManager = null; - lock (this.lockObject) - { - if (!this.sessionPool.ContainsKey(testSessionInfo)) - { - return false; - } + // Deque an actual proxy to do work. + return sessionManager.DequeueProxy(source, runSettings); + } + catch (InvalidOperationException ex) + { + // If we are unable to dequeue the proxy we just eat up the exception here as + // it is safe to proceed. + // + // WARNING: This should not normally happen and it raises questions regarding the + // test session pool operation and consistency. + EqtTrace.Warning("TestSessionPool.ReturnProxy failed: {0}", ex.ToString()); + } - // Gets the session manager reference from the pool. - sessionManager = this.sessionPool[testSessionInfo]; - } + return null; + } - try - { - // Try re-enqueueing the specified proxy. - return sessionManager.EnqueueProxy(proxyId); - } - catch (InvalidOperationException ex) + /// + /// Returns the proxy object to the session pool. + /// + /// + /// The test session info object. + /// The proxy id to be returned. + /// + /// True if the operation succeeded, false otherwise. + public virtual bool ReturnProxy(TestSessionInfo testSessionInfo, int proxyId) + { + ProxyTestSessionManager sessionManager = null; + lock (_lockObject) + { + if (!_sessionPool.ContainsKey(testSessionInfo)) { - // If we are unable to re-enqueue the proxy we just eat up the exception here as - // it is safe to proceed. - // - // WARNING: This should not normally happen and it raises questions regarding the - // test session pool operation and consistency. - EqtTrace.Warning("TestSessionPool.ReturnProxy failed: {0}", ex.ToString()); + return false; } - return false; + // Gets the session manager reference from the pool. + sessionManager = _sessionPool[testSessionInfo]; + } + + try + { + // Try re-enqueueing the specified proxy. + return sessionManager.EnqueueProxy(proxyId); + } + catch (InvalidOperationException ex) + { + // If we are unable to re-enqueue the proxy we just eat up the exception here as + // it is safe to proceed. + // + // WARNING: This should not normally happen and it raises questions regarding the + // test session pool operation and consistency. + EqtTrace.Warning("TestSessionPool.ReturnProxy failed: {0}", ex.ToString()); } + + return false; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Utilities/TestCaseFilterDeterminer.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Utilities/TestCaseFilterDeterminer.cs index 2d563e77f4..48b216a8a7 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Utilities/TestCaseFilterDeterminer.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Utilities/TestCaseFilterDeterminer.cs @@ -1,26 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Utilities -{ - internal class TestCaseFilterDeterminer - { - private const int MaxLengthOfTestCaseFilterToShow = 256; - - internal static string ShortenTestCaseFilterIfRequired(string testCaseFilter) - { - string shortenTestCaseFilter; +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Utilities; - if (testCaseFilter.Length > MaxLengthOfTestCaseFilterToShow) - { - shortenTestCaseFilter = testCaseFilter.Substring(0, MaxLengthOfTestCaseFilterToShow) + "..."; - } - else - { - shortenTestCaseFilter = testCaseFilter; - } +internal class TestCaseFilterDeterminer +{ + private const int MaxLengthOfTestCaseFilterToShow = 256; - return shortenTestCaseFilter; - } + internal static string ShortenTestCaseFilterIfRequired(string testCaseFilter) + { + string shortenTestCaseFilter = testCaseFilter.Length > MaxLengthOfTestCaseFilterToShow + ? testCaseFilter.Substring(0, MaxLengthOfTestCaseFilterToShow) + "..." + : testCaseFilter; + return shortenTestCaseFilter; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Utilities/TestSourcesUtility.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Utilities/TestSourcesUtility.cs index dd5ab82986..79f6b6b65a 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Utilities/TestSourcesUtility.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Utilities/TestSourcesUtility.cs @@ -1,59 +1,59 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Utilities -{ - using System.Collections.Generic; - using System.IO; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Utilities; + +using System.Collections.Generic; +using System.IO; +using System.Linq; +using ObjectModel; + +/// +/// Test sources utility class +/// +internal class TestSourcesUtility +{ /// - /// Test sources utility class + /// Gets test sources from adapter source map /// - internal class TestSourcesUtility + /// The test list. + /// List of test Sources + internal static IEnumerable GetSources(Dictionary> adapterSourceMap) { - /// - /// Gets test sources from adapter source map - /// - /// The test list. - /// List of test Sources - internal static IEnumerable GetSources(Dictionary> adapterSourceMap) - { - IEnumerable sources = new List(); - return adapterSourceMap?.Values?.Aggregate(sources, (current, enumerable) => current.Concat(enumerable)); - } + IEnumerable sources = new List(); + return adapterSourceMap?.Values?.Aggregate(sources, (current, enumerable) => current.Concat(enumerable)); + } - /// - /// Gets test sources from test case list - /// - /// The test list. - /// List of test Sources - internal static IEnumerable GetSources(IEnumerable tests) - { - return tests?.Select(tc => tc.Source).Distinct(); - } + /// + /// Gets test sources from test case list + /// + /// The test list. + /// List of test Sources + internal static IEnumerable GetSources(IEnumerable tests) + { + return tests?.Select(tc => tc.Source).Distinct(); + } - /// - /// Gets default code base path for in-proc collector from test sources - /// - /// The test list. - /// List of test Sources - internal static string GetDefaultCodebasePath(Dictionary> adapterSourceMap) - { - var source = GetSources(adapterSourceMap)?.FirstOrDefault(); - return source != null ? Path.GetDirectoryName(source) : null; - } + /// + /// Gets default code base path for in-proc collector from test sources + /// + /// The test list. + /// List of test Sources + internal static string GetDefaultCodebasePath(Dictionary> adapterSourceMap) + { + var source = GetSources(adapterSourceMap)?.FirstOrDefault(); + return source != null ? Path.GetDirectoryName(source) : null; + } - /// - /// Gets default code base path for in-proc collector from test sources - /// - /// The test list. - /// List of test Sources - internal static string GetDefaultCodebasePath(IEnumerable tests) - { - var source = GetSources(tests)?.FirstOrDefault(); - return source != null ? Path.GetDirectoryName(source) : null; - } + /// + /// Gets default code base path for in-proc collector from test sources + /// + /// The test list. + /// List of test Sources + internal static string GetDefaultCodebasePath(IEnumerable tests) + { + var source = GetSources(tests)?.FirstOrDefault(); + return source != null ? Path.GetDirectoryName(source) : null; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Execution.Shared/DebuggerBreakpoint.cs b/src/Microsoft.TestPlatform.Execution.Shared/DebuggerBreakpoint.cs index f54892d4a2..91b8a1e058 100644 --- a/src/Microsoft.TestPlatform.Execution.Shared/DebuggerBreakpoint.cs +++ b/src/Microsoft.TestPlatform.Execution.Shared/DebuggerBreakpoint.cs @@ -1,213 +1,218 @@ -using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; using Microsoft.VisualStudio.TestPlatform.Utilities; + using System; using System.Diagnostics; using System.IO; +#if !NETCOREAPP1_0 && DEBUG using System.Reflection; +#endif using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; -namespace Microsoft.VisualStudio.TestPlatform.Execution +namespace Microsoft.VisualStudio.TestPlatform.Execution; + +internal static class DebuggerBreakpoint { - internal static class DebuggerBreakpoint + internal static void AttachVisualStudioDebugger(string environmentVariable) { - internal static void AttachVisualStudioDebugger(string environmentVariable) - { #if NETCOREAPP1_0 || !DEBUG - return; + return; #else - if (string.IsNullOrWhiteSpace(environmentVariable)) + if (string.IsNullOrWhiteSpace(environmentVariable)) + { + throw new ArgumentException($"'{nameof(environmentVariable)}' cannot be null or whitespace.", nameof(environmentVariable)); + } + + if (Debugger.IsAttached) + return; + + var debugEnabled = Environment.GetEnvironmentVariable(environmentVariable); + if (!string.IsNullOrEmpty(debugEnabled) && !debugEnabled.Equals("0", StringComparison.Ordinal)) + { + int? vsPid = null; + if (int.TryParse(debugEnabled, out int pid)) { - throw new ArgumentException($"'{nameof(environmentVariable)}' cannot be null or whitespace.", nameof(environmentVariable)); + // The option is used to both enable and disable attaching (0 and 1) + // and providing custom vs pid (any number higher than 1) + vsPid = pid <= 1 ? null : (int?)pid; } - if (Debugger.IsAttached) - return; - - var debugEnabled = Environment.GetEnvironmentVariable(environmentVariable); - if (!string.IsNullOrEmpty(debugEnabled) && !debugEnabled.Equals("0", StringComparison.Ordinal)) + if (vsPid == null) { - int? vsPid = null; - if (int.TryParse(debugEnabled, out int pid)) - { - // The option is used to both enable and disable attaching (0 and 1) - // and providing custom vs pid (any number higher than 1) - vsPid = pid <= 1 ? null : (int?)pid; - } - - if (vsPid == null) - { - ConsoleOutput.Instance.WriteLine("Attaching Visual Studio, either a parent or the one that was started first... To specify a VS instance to use, use the PID in the option, instead of 1. No breakpoints are automatically set.", OutputLevel.Information); - } - else - { - ConsoleOutput.Instance.WriteLine($"Attaching Visual Studio with PID {vsPid} to the process '{Process.GetCurrentProcess().ProcessName}({Process.GetCurrentProcess().Id})'... No breakpoints are automatically set.", OutputLevel.Information); - } - - AttachVS(Process.GetCurrentProcess(), vsPid); - - Break(); + ConsoleOutput.Instance.WriteLine("Attaching Visual Studio, either a parent or the one that was started first... To specify a VS instance to use, use the PID in the option, instead of 1. No breakpoints are automatically set.", OutputLevel.Information); } -#endif + else + { + ConsoleOutput.Instance.WriteLine($"Attaching Visual Studio with PID {vsPid} to the process '{Process.GetCurrentProcess().ProcessName}({Process.GetCurrentProcess().Id})'... No breakpoints are automatically set.", OutputLevel.Information); + } + + AttachVs(Process.GetCurrentProcess(), vsPid); + + Break(); } +#endif + } - private static bool AttachVS(Process process, int? vsPid) - { + private static bool AttachVs(Process process, int? vsPid) + { #if NETCOREAPP1_0 || !DEBUG - return false; + return false; #else - // The way we attach VS is not compatible with .NET Core 2.1 and .NET Core 3.1, but works in .NET Framework and .NET. - // We could call the library code directly here for .NET, and .NET Framework, but then we would also need to package it - // together with testhost. So instead we always run the executable, and pass path to it using env variable. - - var env = "VSTEST_DEBUG_ATTACHVS_PATH"; - var vsAttachPath = Environment.GetEnvironmentVariable(env) ?? FindAttachVs(); - - // Always set it so we propagate it to child processes even if it was not previously set. - Environment.SetEnvironmentVariable(env, vsAttachPath); + // The way we attach VS is not compatible with .NET Core 2.1 and .NET Core 3.1, but works in .NET Framework and .NET. + // We could call the library code directly here for .NET, and .NET Framework, but then we would also need to package it + // together with testhost. So instead we always run the executable, and pass path to it using env variable. - if (vsAttachPath == null) - { - throw new InvalidOperationException($"Cannot find AttachVS.exe tool."); - } + const string env = "VSTEST_DEBUG_ATTACHVS_PATH"; + var vsAttachPath = Environment.GetEnvironmentVariable(env) ?? FindAttachVs(); - if (!File.Exists(vsAttachPath)) - { - throw new InvalidOperationException($"Cannot start tool, path {vsAttachPath} does not exist."); - } - var attachVsProcess = Process.Start(vsAttachPath, $"{process.Id} {vsPid}"); - attachVsProcess.WaitForExit(); + // Always set it so we propagate it to child processes even if it was not previously set. + Environment.SetEnvironmentVariable(env, vsAttachPath); - return attachVsProcess.ExitCode == 0; -#endif + if (vsAttachPath == null) + { + throw new InvalidOperationException($"Cannot find AttachVS.exe tool."); } - private static string FindAttachVs() + if (!File.Exists(vsAttachPath)) { -# if NETCOREAPP1_0 || !DEBUG - return null; -# else - - var fromPath = FindOnPath("AttachVS.exe"); - if (fromPath != null) - { - return fromPath; - } + throw new InvalidOperationException($"Cannot start tool, path {vsAttachPath} does not exist."); + } + var attachVsProcess = Process.Start(vsAttachPath, $"{process.Id} {vsPid}"); + attachVsProcess.WaitForExit(); - var parent = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - while (parent != null) - { - var path = Path.Combine(parent, @"src\AttachVS\bin\Debug\net472\AttachVS.exe"); - if (File.Exists(path)) - { - return path; - } + return attachVsProcess.ExitCode == 0; +#endif + } - parent = Path.GetDirectoryName(parent); - } + private static string FindAttachVs() + { +#if NETCOREAPP1_0 || !DEBUG + return null; +#else - return parent; -#endif + var fromPath = FindOnPath("AttachVS.exe"); + if (fromPath != null) + { + return fromPath; } - private static string FindOnPath(string exeName) + var parent = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + while (parent != null) { - var paths = Environment.GetEnvironmentVariable("PATH").Split(';'); - foreach (var p in paths) + var path = Path.Combine(parent, @"src\AttachVS\bin\Debug\net472\AttachVS.exe"); + if (File.Exists(path)) { - var path = Path.Combine(p, exeName); - if (File.Exists(path)) - { - return path; - } + return path; } - return null; + parent = Path.GetDirectoryName(parent); } - internal static void WaitForDebugger(string environmentVariable) - { - if (Debugger.IsAttached) - return; + return parent; +#endif + } - if (string.IsNullOrWhiteSpace(environmentVariable)) + private static string FindOnPath(string exeName) + { + var paths = Environment.GetEnvironmentVariable("PATH").Split(';'); + foreach (var p in paths) + { + var path = Path.Combine(p, exeName); + if (File.Exists(path)) { - throw new ArgumentException($"'{nameof(environmentVariable)}' cannot be null or whitespace.", nameof(environmentVariable)); + return path; } + } - var debugEnabled = Environment.GetEnvironmentVariable(environmentVariable); - if (!string.IsNullOrEmpty(debugEnabled) && debugEnabled.Equals("1", StringComparison.Ordinal)) - { - ConsoleOutput.Instance.WriteLine("Waiting for debugger attach...", OutputLevel.Information); - - var currentProcess = Process.GetCurrentProcess(); - ConsoleOutput.Instance.WriteLine( - string.Format("Process Id: {0}, Name: {1}", currentProcess.Id, currentProcess.ProcessName), - OutputLevel.Information); + return null; + } - while (!Debugger.IsAttached) - { - Thread.Sleep(1000); - } + internal static void WaitForDebugger(string environmentVariable) + { + if (Debugger.IsAttached) + return; - Break(); - } + if (string.IsNullOrWhiteSpace(environmentVariable)) + { + throw new ArgumentException($"'{nameof(environmentVariable)}' cannot be null or whitespace.", nameof(environmentVariable)); } - internal static void WaitForNativeDebugger(string environmentVariable) + var debugEnabled = Environment.GetEnvironmentVariable(environmentVariable); + if (!string.IsNullOrEmpty(debugEnabled) && debugEnabled.Equals("1", StringComparison.Ordinal)) { - if (string.IsNullOrWhiteSpace(environmentVariable)) - { - throw new ArgumentException($"'{nameof(environmentVariable)}' cannot be null or whitespace.", nameof(environmentVariable)); - } + ConsoleOutput.Instance.WriteLine("Waiting for debugger attach...", OutputLevel.Information); - // Check if native debugging is enabled and OS is windows. - var nativeDebugEnabled = Environment.GetEnvironmentVariable(environmentVariable); + var currentProcess = Process.GetCurrentProcess(); + ConsoleOutput.Instance.WriteLine( + string.Format("Process Id: {0}, Name: {1}", currentProcess.Id, currentProcess.ProcessName), + OutputLevel.Information); - if (!string.IsNullOrEmpty(nativeDebugEnabled) && nativeDebugEnabled.Equals("1", StringComparison.Ordinal) - && new PlatformEnvironment().OperatingSystem.Equals(PlatformOperatingSystem.Windows)) + while (!Debugger.IsAttached) { - while (!IsDebuggerPresent()) - { - Task.Delay(1000).Wait(); - } - - BreakNative(); + Thread.Sleep(1000); } + + Break(); } + } - private static void Break() + internal static void WaitForNativeDebugger(string environmentVariable) + { + if (string.IsNullOrWhiteSpace(environmentVariable)) { - if (ShouldNotBreak()) + throw new ArgumentException($"'{nameof(environmentVariable)}' cannot be null or whitespace.", nameof(environmentVariable)); + } + + // Check if native debugging is enabled and OS is windows. + var nativeDebugEnabled = Environment.GetEnvironmentVariable(environmentVariable); + + if (!string.IsNullOrEmpty(nativeDebugEnabled) && nativeDebugEnabled.Equals("1", StringComparison.Ordinal) + && new PlatformEnvironment().OperatingSystem.Equals(PlatformOperatingSystem.Windows)) + { + while (!IsDebuggerPresent()) { - return; + Task.Delay(1000).Wait(); } - Debugger.Break(); + BreakNative(); } + } - private static bool ShouldNotBreak() + private static void Break() + { + if (ShouldNotBreak()) { - return Environment.GetEnvironmentVariable("VSTEST_DEBUG_NOBP")?.Equals("1") ?? false; + return; } - private static void BreakNative() - { - if (ShouldNotBreak()) - { - return; - } + Debugger.Break(); + } - DebugBreak(); - } + private static bool ShouldNotBreak() + { + return Environment.GetEnvironmentVariable("VSTEST_DEBUG_NOBP")?.Equals("1") ?? false; + } - // Native APIs for enabling native debugging. - [DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool IsDebuggerPresent(); + private static void BreakNative() + { + if (ShouldNotBreak()) + { + return; + } - [DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)] - internal static extern void DebugBreak(); + DebugBreak(); } -} + + // Native APIs for enabling native debugging. + [DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool IsDebuggerPresent(); + + [DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)] + internal static extern void DebugBreak(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Execution.Shared/UILanguageOverride.cs b/src/Microsoft.TestPlatform.Execution.Shared/UILanguageOverride.cs index a8e37d9a76..5ebed84c9a 100644 --- a/src/Microsoft.TestPlatform.Execution.Shared/UILanguageOverride.cs +++ b/src/Microsoft.TestPlatform.Execution.Shared/UILanguageOverride.cs @@ -4,79 +4,78 @@ using System; using System.Globalization; -namespace Microsoft.VisualStudio.TestPlatform.Execution +namespace Microsoft.VisualStudio.TestPlatform.Execution; + +internal static class UiLanguageOverride { - internal static class UILanguageOverride - { - private const string DOTNET_CLI_UI_LANGUAGE = nameof(DOTNET_CLI_UI_LANGUAGE); - private const string VSLANG = nameof(VSLANG); - private const string PreferredUILang = nameof(PreferredUILang); + private const string DotnetCliUiLanguage = nameof(DotnetCliUiLanguage); + private const string Vslang = nameof(Vslang); + private const string PreferredUiLang = nameof(PreferredUiLang); - internal static void SetCultureSpecifiedByUser() + internal static void SetCultureSpecifiedByUser() + { + CultureInfo language = GetOverriddenUiLanguage(); + if (language == null) { - CultureInfo language = GetOverriddenUILanguage(); - if (language == null) - { - return; - } - - ApplyOverrideToCurrentProcess(language); - FlowOverrideToChildProcesses(language); + return; } + ApplyOverrideToCurrentProcess(language); + FlowOverrideToChildProcesses(language); + } - private static void ApplyOverrideToCurrentProcess(CultureInfo language) - { - CultureInfo.DefaultThreadCurrentUICulture = language; - } - private static CultureInfo GetOverriddenUILanguage() + private static void ApplyOverrideToCurrentProcess(CultureInfo language) + { + CultureInfo.DefaultThreadCurrentUICulture = language; + } + + private static CultureInfo GetOverriddenUiLanguage() + { + // DOTNET_CLI_UI_LANGUAGE= is the main way for users to customize the CLI's UI language. + string dotnetCliLanguage = Environment.GetEnvironmentVariable(DotnetCliUiLanguage); + if (dotnetCliLanguage != null) { - // DOTNET_CLI_UI_LANGUAGE= is the main way for users to customize the CLI's UI language. - string dotnetCliLanguage = Environment.GetEnvironmentVariable(DOTNET_CLI_UI_LANGUAGE); - if (dotnetCliLanguage != null) + try { - try - { - return new CultureInfo(dotnetCliLanguage); - } - catch (CultureNotFoundException) { } + return new CultureInfo(dotnetCliLanguage); } + catch (CultureNotFoundException) { } + } #if !NETCOREAPP1_0 - // VSLANG= is set by VS and we respect that as well so that we will respect the VS - // language preference if we're invoked by VS. - string vsLang = Environment.GetEnvironmentVariable(VSLANG); - if (vsLang != null && int.TryParse(vsLang, out int vsLcid)) + // VSLANG= is set by VS and we respect that as well so that we will respect the VS + // language preference if we're invoked by VS. + string vsLang = Environment.GetEnvironmentVariable(Vslang); + if (vsLang != null && int.TryParse(vsLang, out int vsLcid)) + { + try { - try - { - return new CultureInfo(vsLcid); - } - catch (ArgumentOutOfRangeException) { } - catch (CultureNotFoundException) { } + return new CultureInfo(vsLcid); } -# endif - return null; + catch (ArgumentOutOfRangeException) { } + catch (CultureNotFoundException) { } } +# endif + return null; + } - private static void FlowOverrideToChildProcesses(CultureInfo language) - { - // Do not override any environment variables that are already set as we do not want to clobber a more granular setting with our global setting. - SetIfNotAlreadySet(DOTNET_CLI_UI_LANGUAGE, language.Name); + private static void FlowOverrideToChildProcesses(CultureInfo language) + { + // Do not override any environment variables that are already set as we do not want to clobber a more granular setting with our global setting. + SetIfNotAlreadySet(DotnetCliUiLanguage, language.Name); #if !NETCOREAPP1_0 - SetIfNotAlreadySet(VSLANG, language.LCID.ToString()); // for tools following VS guidelines to just work in CLI + SetIfNotAlreadySet(Vslang, language.LCID.ToString()); // for tools following VS guidelines to just work in CLI #endif - SetIfNotAlreadySet(PreferredUILang, language.Name); // for C#/VB targets that pass $(PreferredUILang) to compiler - } + SetIfNotAlreadySet(PreferredUiLang, language.Name); // for C#/VB targets that pass $(PreferredUILang) to compiler + } - private static void SetIfNotAlreadySet(string environmentVariableName, string value) + private static void SetIfNotAlreadySet(string environmentVariableName, string value) + { + string currentValue = Environment.GetEnvironmentVariable(environmentVariableName); + if (currentValue == null) { - string currentValue = Environment.GetEnvironmentVariable(environmentVariableName); - if (currentValue == null) - { - Environment.SetEnvironmentVariable(environmentVariableName, value); - } + Environment.SetEnvironmentVariable(environmentVariableName, value); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameCollector.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameCollector.cs index 3f4ce6071f..a1c83acd4c 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameCollector.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameCollector.cs @@ -1,633 +1,633 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Xml; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +/// +/// The blame collector. +/// +[DataCollectorFriendlyName("Blame")] +[DataCollectorTypeUri("datacollector://Microsoft/TestPlatform/Extensions/Blame/v1")] +public class BlameCollector : DataCollector, ITestExecutionEnvironmentSpecifier { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Xml; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + private const int DefaultInactivityTimeInMinutes = 60; + + private DataCollectionSink _dataCollectionSink; + private DataCollectionEnvironmentContext _context; + private DataCollectionEvents _events; + private DataCollectionLogger _logger; + private readonly IProcessDumpUtility _processDumpUtility; + private List _testSequence; + private Dictionary _testObjectDictionary; + private readonly IBlameReaderWriter _blameReaderWriter; + private readonly IFileHelper _fileHelper; + private XmlElement _configurationElement; + private int _testStartCount; + private int _testEndCount; + private bool _collectProcessDumpOnTrigger; + private bool _collectProcessDumpOnTestHostHang; + private bool _collectDumpAlways; + private bool _processFullDumpEnabled; + private bool _inactivityTimerAlreadyFired; + private string _attachmentGuid; + private IInactivityTimer _inactivityTimer; + private TimeSpan _inactivityTimespan = TimeSpan.FromMinutes(DefaultInactivityTimeInMinutes); + private int _testHostProcessId; + private string _targetFramework; + private readonly List> _environmentVariables = new(); + private bool _uploadDumpFiles; + private string _tempDirectory; /// - /// The blame collector. + /// Initializes a new instance of the class. + /// Using XmlReaderWriter by default /// - [DataCollectorFriendlyName("Blame")] - [DataCollectorTypeUri("datacollector://Microsoft/TestPlatform/Extensions/Blame/v1")] - public class BlameCollector : DataCollector, ITestExecutionEnvironmentSpecifier + public BlameCollector() + : this(new XmlReaderWriter(), new ProcessDumpUtility(), null, new FileHelper()) { - private const int DefaultInactivityTimeInMinutes = 60; - - private DataCollectionSink dataCollectionSink; - private DataCollectionEnvironmentContext context; - private DataCollectionEvents events; - private DataCollectionLogger logger; - private IProcessDumpUtility processDumpUtility; - private List testSequence; - private Dictionary testObjectDictionary; - private IBlameReaderWriter blameReaderWriter; - private IFileHelper fileHelper; - private XmlElement configurationElement; - private int testStartCount; - private int testEndCount; - private bool collectProcessDumpOnTrigger; - private bool collectProcessDumpOnTestHostHang; - private bool collectDumpAlways; - private bool processFullDumpEnabled; - private bool inactivityTimerAlreadyFired; - private string attachmentGuid; - private IInactivityTimer inactivityTimer; - private TimeSpan inactivityTimespan = TimeSpan.FromMinutes(DefaultInactivityTimeInMinutes); - private int testHostProcessId; - private string targetFramework; - private List> environmentVariables = new List>(); - private bool uploadDumpFiles; - private string tempDirectory; - - /// - /// Initializes a new instance of the class. - /// Using XmlReaderWriter by default - /// - public BlameCollector() - : this(new XmlReaderWriter(), new ProcessDumpUtility(), null, new FileHelper()) - { - } + } - /// - /// Initializes a new instance of the class. - /// - /// - /// BlameReaderWriter instance. - /// - /// - /// IProcessDumpUtility instance. - /// - /// - /// InactivityTimer instance. - /// - /// - /// Filehelper instance. - /// - internal BlameCollector( - IBlameReaderWriter blameReaderWriter, - IProcessDumpUtility processDumpUtility, - IInactivityTimer inactivityTimer, - IFileHelper fileHelper) - { - this.blameReaderWriter = blameReaderWriter; - this.processDumpUtility = processDumpUtility; - this.inactivityTimer = inactivityTimer; - this.fileHelper = fileHelper; - } + /// + /// Initializes a new instance of the class. + /// + /// + /// BlameReaderWriter instance. + /// + /// + /// IProcessDumpUtility instance. + /// + /// + /// InactivityTimer instance. + /// + /// + /// Filehelper instance. + /// + internal BlameCollector( + IBlameReaderWriter blameReaderWriter, + IProcessDumpUtility processDumpUtility, + IInactivityTimer inactivityTimer, + IFileHelper fileHelper) + { + _blameReaderWriter = blameReaderWriter; + _processDumpUtility = processDumpUtility; + _inactivityTimer = inactivityTimer; + _fileHelper = fileHelper; + } - /// - /// Gets environment variables that should be set in the test execution environment - /// - /// Environment variables that should be set in the test execution environment - public IEnumerable> GetTestExecutionEnvironmentVariables() - { - return this.environmentVariables; - } + /// + /// Gets environment variables that should be set in the test execution environment + /// + /// Environment variables that should be set in the test execution environment + public IEnumerable> GetTestExecutionEnvironmentVariables() + { + return _environmentVariables; + } - /// - /// Initializes parameters for the new instance of the class - /// - /// The Xml Element to save to - /// Data collection events to which methods subscribe - /// A data collection sink for data transfer - /// Data Collection Logger to send messages to the client - /// Context of data collector environment - public override void Initialize( - XmlElement configurationElement, - DataCollectionEvents events, - DataCollectionSink dataSink, - DataCollectionLogger logger, - DataCollectionEnvironmentContext environmentContext) + /// + /// Initializes parameters for the new instance of the class + /// + /// The Xml Element to save to + /// Data collection events to which methods subscribe + /// A data collection sink for data transfer + /// Data Collection Logger to send messages to the client + /// Context of data collector environment + public override void Initialize( + XmlElement configurationElement, + DataCollectionEvents events, + DataCollectionSink dataSink, + DataCollectionLogger logger, + DataCollectionEnvironmentContext environmentContext) + { + ValidateArg.NotNull(logger, nameof(logger)); + + _events = events; + _dataCollectionSink = dataSink; + _context = environmentContext; + _configurationElement = configurationElement; + _testSequence = new List(); + _testObjectDictionary = new Dictionary(); + _logger = logger; + + // Subscribing to events + _events.TestHostLaunched += TestHostLaunchedHandler; + _events.SessionEnd += SessionEndedHandler; + _events.TestCaseStart += EventsTestCaseStart; + _events.TestCaseEnd += EventsTestCaseEnd; + + if (_configurationElement != null) { - ValidateArg.NotNull(logger, nameof(logger)); - - this.events = events; - this.dataCollectionSink = dataSink; - this.context = environmentContext; - this.configurationElement = configurationElement; - this.testSequence = new List(); - this.testObjectDictionary = new Dictionary(); - this.logger = logger; - - // Subscribing to events - this.events.TestHostLaunched += this.TestHostLaunchedHandler; - this.events.SessionEnd += this.SessionEndedHandler; - this.events.TestCaseStart += this.EventsTestCaseStart; - this.events.TestCaseEnd += this.EventsTestCaseEnd; - - if (this.configurationElement != null) - { - var collectDumpNode = this.configurationElement[Constants.DumpModeKey]; - this.collectProcessDumpOnTrigger = collectDumpNode != null; - - if (this.collectProcessDumpOnTrigger) - { - this.ValidateAndAddTriggerBasedProcessDumpParameters(collectDumpNode); - - // enabling dumps on MacOS needs to be done explicitly https://github.com/dotnet/runtime/pull/40105 - this.environmentVariables.Add(new KeyValuePair("COMPlus_DbgEnableElfDumpOnMacOS", "1")); - this.environmentVariables.Add(new KeyValuePair("COMPlus_DbgEnableMiniDump", "1")); - - // https://github.com/dotnet/coreclr/blob/master/Documentation/botr/xplat-minidump-generation.md - // 2 MiniDumpWithPrivateReadWriteMemory - // 4 MiniDumpWithFullMemory - this.environmentVariables.Add(new KeyValuePair("COMPlus_DbgMiniDumpType", this.processFullDumpEnabled ? "4" : "2")); - var dumpDirectory = this.GetDumpDirectory(); - var dumpPath = Path.Combine(dumpDirectory, $"%e_%p_%t_crashdump.dmp"); - this.environmentVariables.Add(new KeyValuePair("COMPlus_DbgMiniDumpName", dumpPath)); - } + var collectDumpNode = _configurationElement[Constants.DumpModeKey]; + _collectProcessDumpOnTrigger = collectDumpNode != null; - var collectHangBasedDumpNode = this.configurationElement[Constants.CollectDumpOnTestSessionHang]; - this.collectProcessDumpOnTestHostHang = collectHangBasedDumpNode != null; - if (this.collectProcessDumpOnTestHostHang) - { - // enabling dumps on MacOS needs to be done explicitly https://github.com/dotnet/runtime/pull/40105 - this.environmentVariables.Add(new KeyValuePair("COMPlus_DbgEnableElfDumpOnMacOS", "1")); + if (_collectProcessDumpOnTrigger) + { + ValidateAndAddTriggerBasedProcessDumpParameters(collectDumpNode); + + // enabling dumps on MacOS needs to be done explicitly https://github.com/dotnet/runtime/pull/40105 + _environmentVariables.Add(new KeyValuePair("COMPlus_DbgEnableElfDumpOnMacOS", "1")); + _environmentVariables.Add(new KeyValuePair("COMPlus_DbgEnableMiniDump", "1")); + + // https://github.com/dotnet/coreclr/blob/master/Documentation/botr/xplat-minidump-generation.md + // 2 MiniDumpWithPrivateReadWriteMemory + // 4 MiniDumpWithFullMemory + _environmentVariables.Add(new KeyValuePair("COMPlus_DbgMiniDumpType", _processFullDumpEnabled ? "4" : "2")); + var dumpDirectory = GetDumpDirectory(); + var dumpPath = Path.Combine(dumpDirectory, $"%e_%p_%t_crashdump.dmp"); + _environmentVariables.Add(new KeyValuePair("COMPlus_DbgMiniDumpName", dumpPath)); + } - this.ValidateAndAddHangBasedProcessDumpParameters(collectHangBasedDumpNode); - } + var collectHangBasedDumpNode = _configurationElement[Constants.CollectDumpOnTestSessionHang]; + _collectProcessDumpOnTestHostHang = collectHangBasedDumpNode != null; + if (_collectProcessDumpOnTestHostHang) + { + // enabling dumps on MacOS needs to be done explicitly https://github.com/dotnet/runtime/pull/40105 + _environmentVariables.Add(new KeyValuePair("COMPlus_DbgEnableElfDumpOnMacOS", "1")); - var tfm = this.configurationElement[Constants.TargetFramework]?.InnerText; - if (!string.IsNullOrWhiteSpace(tfm)) - { - this.targetFramework = tfm; - } + ValidateAndAddHangBasedProcessDumpParameters(collectHangBasedDumpNode); } - this.attachmentGuid = Guid.NewGuid().ToString("N"); - - if (this.collectProcessDumpOnTestHostHang) + var tfm = _configurationElement[Constants.TargetFramework]?.InnerText; + if (!string.IsNullOrWhiteSpace(tfm)) { - this.inactivityTimer = this.inactivityTimer ?? new InactivityTimer(this.CollectDumpAndAbortTesthost); - this.ResetInactivityTimer(); + _targetFramework = tfm; } } - /// - /// Disposes of the timer when called to prevent further calls. - /// Kills the other instance of proc dump if launched for collecting trigger based dumps. - /// Starts and waits for a new proc dump process to collect a single dump and then - /// kills the testhost process. - /// - private void CollectDumpAndAbortTesthost() + _attachmentGuid = Guid.NewGuid().ToString("N"); + + if (_collectProcessDumpOnTestHostHang) { - this.inactivityTimerAlreadyFired = true; + _inactivityTimer ??= new InactivityTimer(CollectDumpAndAbortTesthost); + ResetInactivityTimer(); + } + } - string value; - string unit; + /// + /// Disposes of the timer when called to prevent further calls. + /// Kills the other instance of proc dump if launched for collecting trigger based dumps. + /// Starts and waits for a new proc dump process to collect a single dump and then + /// kills the testhost process. + /// + private void CollectDumpAndAbortTesthost() + { + _inactivityTimerAlreadyFired = true; - if (this.inactivityTimespan.TotalSeconds <= 90) - { - value = ((int)this.inactivityTimespan.TotalSeconds).ToString(); - unit = Resources.Resources.Seconds; - } - else - { - value = Math.Round(this.inactivityTimespan.TotalMinutes, 2).ToString(); - unit = Resources.Resources.Minutes; - } + string value; + string unit; - var message = string.Format(CultureInfo.CurrentUICulture, Resources.Resources.InactivityTimeout, value, unit); + if (_inactivityTimespan.TotalSeconds <= 90) + { + value = ((int)_inactivityTimespan.TotalSeconds).ToString(); + unit = Resources.Resources.Seconds; + } + else + { + value = Math.Round(_inactivityTimespan.TotalMinutes, 2).ToString(); + unit = Resources.Resources.Minutes; + } - EqtTrace.Warning(message); - this.logger.LogWarning(this.context.SessionDataCollectionContext, message); + var message = string.Format(CultureInfo.CurrentUICulture, Resources.Resources.InactivityTimeout, value, unit); - try - { - EqtTrace.Verbose("Calling dispose on Inactivity timer."); - this.inactivityTimer.Dispose(); - } - catch - { - EqtTrace.Verbose("Inactivity timer is already disposed."); - } + EqtTrace.Warning(message); + _logger.LogWarning(_context.SessionDataCollectionContext, message); - if (this.collectProcessDumpOnTrigger) - { - // Detach procdump from the testhost process to prevent testhost process from crashing - // if/when we try to kill the existing proc dump process. - // And also prevent collecting dump on exit of the process. - this.processDumpUtility.DetachFromTargetProcess(this.testHostProcessId); - } + try + { + EqtTrace.Verbose("Calling dispose on Inactivity timer."); + _inactivityTimer.Dispose(); + } + catch + { + EqtTrace.Verbose("Inactivity timer is already disposed."); + } - var hangDumpSuccess = false; - try - { - Action logWarning = m => this.logger.LogWarning(this.context.SessionDataCollectionContext, m); - var dumpDirectory = this.GetDumpDirectory(); - this.processDumpUtility.StartHangBasedProcessDump(this.testHostProcessId, dumpDirectory, this.processFullDumpEnabled, this.targetFramework, logWarning); - hangDumpSuccess = true; - } - catch (Exception ex) - { - this.logger.LogError(this.context.SessionDataCollectionContext, $"Blame: Creating hang dump failed with error.", ex); - } + if (_collectProcessDumpOnTrigger) + { + // Detach procdump from the testhost process to prevent testhost process from crashing + // if/when we try to kill the existing proc dump process. + // And also prevent collecting dump on exit of the process. + _processDumpUtility.DetachFromTargetProcess(_testHostProcessId); + } + + var hangDumpSuccess = false; + try + { + Action logWarning = m => _logger.LogWarning(_context.SessionDataCollectionContext, m); + var dumpDirectory = GetDumpDirectory(); + _processDumpUtility.StartHangBasedProcessDump(_testHostProcessId, dumpDirectory, _processFullDumpEnabled, _targetFramework, logWarning); + hangDumpSuccess = true; + } + catch (Exception ex) + { + _logger.LogError(_context.SessionDataCollectionContext, $"Blame: Creating hang dump failed with error.", ex); + } - if (this.uploadDumpFiles) + if (_uploadDumpFiles) + { + try { - try + var dumpFiles = _processDumpUtility.GetDumpFiles(true, /* if we killed it by hang dumper, we already have our dump, otherwise it might have crashed, and we want all dumps */ !hangDumpSuccess); + foreach (var dumpFile in dumpFiles) { - var dumpFiles = this.processDumpUtility.GetDumpFiles(true, /* if we killed it by hang dumper, we already have our dump, otherwise it might have crashed, and we want all dumps */ !hangDumpSuccess); - foreach (var dumpFile in dumpFiles) + try { - try - { - if (!string.IsNullOrEmpty(dumpFile)) - { - var fileTransferInformation = new FileTransferInformation(this.context.SessionDataCollectionContext, dumpFile, true, this.fileHelper); - this.dataCollectionSink.SendFileAsync(fileTransferInformation); - } - } - catch (Exception ex) + if (!string.IsNullOrEmpty(dumpFile)) { - // Eat up any exception here and log it but proceed with killing the test host process. - EqtTrace.Error(ex); + var fileTransferInformation = new FileTransferInformation(_context.SessionDataCollectionContext, dumpFile, true, _fileHelper); + _dataCollectionSink.SendFileAsync(fileTransferInformation); } + } + catch (Exception ex) + { + // Eat up any exception here and log it but proceed with killing the test host process. + EqtTrace.Error(ex); + } - if (!dumpFiles.Any()) - { - EqtTrace.Error("BlameCollector.CollectDumpAndAbortTesthost: blame:CollectDumpOnHang was enabled but dump file was not generated."); - } + if (!dumpFiles.Any()) + { + EqtTrace.Error("BlameCollector.CollectDumpAndAbortTesthost: blame:CollectDumpOnHang was enabled but dump file was not generated."); } } - catch (Exception ex) - { - this.logger.LogError(this.context.SessionDataCollectionContext, $"Blame: Collecting hang dump failed with error.", ex); - } } - else + catch (Exception ex) { - EqtTrace.Info("BlameCollector.CollectDumpAndAbortTesthost: Custom path to dump directory was provided via VSTEST_DUMP_PATH. Skipping attachment upload, the caller is responsible for collecting and uploading the dumps themselves."); + _logger.LogError(_context.SessionDataCollectionContext, $"Blame: Collecting hang dump failed with error.", ex); } + } + else + { + EqtTrace.Info("BlameCollector.CollectDumpAndAbortTesthost: Custom path to dump directory was provided via VSTEST_DUMP_PATH. Skipping attachment upload, the caller is responsible for collecting and uploading the dumps themselves."); + } + try + { + var p = Process.GetProcessById(_testHostProcessId); try { - var p = Process.GetProcessById(this.testHostProcessId); - try - { - if (!p.HasExited) - { - p.Kill(); - } - } - catch (InvalidOperationException) + if (!p.HasExited) { + p.Kill(); } } - catch (Exception ex) + catch (InvalidOperationException) { - EqtTrace.Error(ex); } } + catch (Exception ex) + { + EqtTrace.Error(ex); + } + } - private void ValidateAndAddTriggerBasedProcessDumpParameters(XmlElement collectDumpNode) + private void ValidateAndAddTriggerBasedProcessDumpParameters(XmlElement collectDumpNode) + { + foreach (XmlAttribute blameAttribute in collectDumpNode.Attributes) { - foreach (XmlAttribute blameAttribute in collectDumpNode.Attributes) + switch (blameAttribute) { - switch (blameAttribute) - { - case XmlAttribute attribute when string.Equals(attribute.Name, Constants.CollectDumpAlwaysKey, StringComparison.OrdinalIgnoreCase): + case XmlAttribute attribute when string.Equals(attribute.Name, Constants.CollectDumpAlwaysKey, StringComparison.OrdinalIgnoreCase): - if (string.Equals(attribute.Value, Constants.TrueConfigurationValue, StringComparison.OrdinalIgnoreCase) || string.Equals(attribute.Value, Constants.FalseConfigurationValue, StringComparison.OrdinalIgnoreCase)) - { - bool.TryParse(attribute.Value, out this.collectDumpAlways); - } - else - { - this.logger.LogWarning(this.context.SessionDataCollectionContext, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterValueIncorrect, attribute.Name, Constants.TrueConfigurationValue, Constants.FalseConfigurationValue)); - } + if (string.Equals(attribute.Value, Constants.TrueConfigurationValue, StringComparison.OrdinalIgnoreCase) || string.Equals(attribute.Value, Constants.FalseConfigurationValue, StringComparison.OrdinalIgnoreCase)) + { + bool.TryParse(attribute.Value, out _collectDumpAlways); + } + else + { + _logger.LogWarning(_context.SessionDataCollectionContext, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterValueIncorrect, attribute.Name, Constants.TrueConfigurationValue, Constants.FalseConfigurationValue)); + } - break; + break; - case XmlAttribute attribute when string.Equals(attribute.Name, Constants.DumpTypeKey, StringComparison.OrdinalIgnoreCase): + case XmlAttribute attribute when string.Equals(attribute.Name, Constants.DumpTypeKey, StringComparison.OrdinalIgnoreCase): - if (string.Equals(attribute.Value, Constants.FullConfigurationValue, StringComparison.OrdinalIgnoreCase) || string.Equals(attribute.Value, Constants.MiniConfigurationValue, StringComparison.OrdinalIgnoreCase)) - { - this.processFullDumpEnabled = string.Equals(attribute.Value, Constants.FullConfigurationValue, StringComparison.OrdinalIgnoreCase); - } - else - { - this.logger.LogWarning(this.context.SessionDataCollectionContext, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterValueIncorrect, attribute.Name, Constants.FullConfigurationValue, Constants.MiniConfigurationValue)); - } + if (string.Equals(attribute.Value, Constants.FullConfigurationValue, StringComparison.OrdinalIgnoreCase) || string.Equals(attribute.Value, Constants.MiniConfigurationValue, StringComparison.OrdinalIgnoreCase)) + { + _processFullDumpEnabled = string.Equals(attribute.Value, Constants.FullConfigurationValue, StringComparison.OrdinalIgnoreCase); + } + else + { + _logger.LogWarning(_context.SessionDataCollectionContext, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterValueIncorrect, attribute.Name, Constants.FullConfigurationValue, Constants.MiniConfigurationValue)); + } - break; + break; - default: + default: - this.logger.LogWarning(this.context.SessionDataCollectionContext, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterKeyIncorrect, blameAttribute.Name)); - break; - } + _logger.LogWarning(_context.SessionDataCollectionContext, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterKeyIncorrect, blameAttribute.Name)); + break; } } + } - private void ValidateAndAddHangBasedProcessDumpParameters(XmlElement collectDumpNode) + private void ValidateAndAddHangBasedProcessDumpParameters(XmlElement collectDumpNode) + { + foreach (XmlAttribute blameAttribute in collectDumpNode.Attributes) { - foreach (XmlAttribute blameAttribute in collectDumpNode.Attributes) + switch (blameAttribute) { - switch (blameAttribute) - { - case XmlAttribute attribute when string.Equals(attribute.Name, Constants.TestTimeout, StringComparison.OrdinalIgnoreCase): + case XmlAttribute attribute when string.Equals(attribute.Name, Constants.TestTimeout, StringComparison.OrdinalIgnoreCase): - if (!string.IsNullOrWhiteSpace(attribute.Value) && TimeSpanParser.TryParse(attribute.Value, out var timeout)) - { - this.inactivityTimespan = timeout; - } - else - { - this.logger.LogWarning(this.context.SessionDataCollectionContext, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.UnexpectedValueForInactivityTimespanValue, attribute.Value)); - } + if (!string.IsNullOrWhiteSpace(attribute.Value) && TimeSpanParser.TryParse(attribute.Value, out var timeout)) + { + _inactivityTimespan = timeout; + } + else + { + _logger.LogWarning(_context.SessionDataCollectionContext, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.UnexpectedValueForInactivityTimespanValue, attribute.Value)); + } - break; + break; - // allow HangDumpType attribute to be used on the hang dump this is the prefered way - case XmlAttribute attribute when string.Equals(attribute.Name, Constants.HangDumpTypeKey, StringComparison.OrdinalIgnoreCase): + // allow HangDumpType attribute to be used on the hang dump this is the prefered way + case XmlAttribute attribute when string.Equals(attribute.Name, Constants.HangDumpTypeKey, StringComparison.OrdinalIgnoreCase): - if (string.Equals(attribute.Value, Constants.FullConfigurationValue, StringComparison.OrdinalIgnoreCase) || string.Equals(attribute.Value, Constants.MiniConfigurationValue, StringComparison.OrdinalIgnoreCase)) - { - this.processFullDumpEnabled = string.Equals(attribute.Value, Constants.FullConfigurationValue, StringComparison.OrdinalIgnoreCase); - } - else - { - this.logger.LogWarning(this.context.SessionDataCollectionContext, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterValueIncorrect, attribute.Name, Constants.FullConfigurationValue, Constants.MiniConfigurationValue)); - } + if (string.Equals(attribute.Value, Constants.FullConfigurationValue, StringComparison.OrdinalIgnoreCase) || string.Equals(attribute.Value, Constants.MiniConfigurationValue, StringComparison.OrdinalIgnoreCase)) + { + _processFullDumpEnabled = string.Equals(attribute.Value, Constants.FullConfigurationValue, StringComparison.OrdinalIgnoreCase); + } + else + { + _logger.LogWarning(_context.SessionDataCollectionContext, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterValueIncorrect, attribute.Name, Constants.FullConfigurationValue, Constants.MiniConfigurationValue)); + } - break; + break; - // allow DumpType attribute to be used on the hang dump for backwards compatibility - case XmlAttribute attribute when string.Equals(attribute.Name, Constants.DumpTypeKey, StringComparison.OrdinalIgnoreCase): + // allow DumpType attribute to be used on the hang dump for backwards compatibility + case XmlAttribute attribute when string.Equals(attribute.Name, Constants.DumpTypeKey, StringComparison.OrdinalIgnoreCase): - if (string.Equals(attribute.Value, Constants.FullConfigurationValue, StringComparison.OrdinalIgnoreCase) || string.Equals(attribute.Value, Constants.MiniConfigurationValue, StringComparison.OrdinalIgnoreCase)) - { - this.processFullDumpEnabled = string.Equals(attribute.Value, Constants.FullConfigurationValue, StringComparison.OrdinalIgnoreCase); - } - else - { - this.logger.LogWarning(this.context.SessionDataCollectionContext, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterValueIncorrect, attribute.Name, Constants.FullConfigurationValue, Constants.MiniConfigurationValue)); - } + if (string.Equals(attribute.Value, Constants.FullConfigurationValue, StringComparison.OrdinalIgnoreCase) || string.Equals(attribute.Value, Constants.MiniConfigurationValue, StringComparison.OrdinalIgnoreCase)) + { + _processFullDumpEnabled = string.Equals(attribute.Value, Constants.FullConfigurationValue, StringComparison.OrdinalIgnoreCase); + } + else + { + _logger.LogWarning(_context.SessionDataCollectionContext, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterValueIncorrect, attribute.Name, Constants.FullConfigurationValue, Constants.MiniConfigurationValue)); + } - break; + break; - default: + default: - this.logger.LogWarning(this.context.SessionDataCollectionContext, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterKeyIncorrect, blameAttribute.Name)); - break; - } + _logger.LogWarning(_context.SessionDataCollectionContext, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterKeyIncorrect, blameAttribute.Name)); + break; } } + } + + /// + /// Called when Test Case Start event is invoked + /// + /// Sender + /// TestCaseStartEventArgs + private void EventsTestCaseStart(object sender, TestCaseStartEventArgs e) + { + ResetInactivityTimer(); - /// - /// Called when Test Case Start event is invoked - /// - /// Sender - /// TestCaseStartEventArgs - private void EventsTestCaseStart(object sender, TestCaseStartEventArgs e) + if (EqtTrace.IsInfoEnabled) { - this.ResetInactivityTimer(); + EqtTrace.Info("Blame Collector : Test Case Start"); + } - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("Blame Collector : Test Case Start"); - } + var blameTestObject = new BlameTestObject(e.TestElement); - var blameTestObject = new BlameTestObject(e.TestElement); + // Add guid to list of test sequence to maintain the order. + _testSequence.Add(blameTestObject.Id); - // Add guid to list of test sequence to maintain the order. - this.testSequence.Add(blameTestObject.Id); + // Add the test object to the dictionary. + _testObjectDictionary.Add(blameTestObject.Id, blameTestObject); - // Add the test object to the dictionary. - this.testObjectDictionary.Add(blameTestObject.Id, blameTestObject); + // Increment test start count. + _testStartCount++; + } - // Increment test start count. - this.testStartCount++; - } + /// + /// Called when Test Case End event is invoked + /// + /// Sender + /// TestCaseEndEventArgs + private void EventsTestCaseEnd(object sender, TestCaseEndEventArgs e) + { + ResetInactivityTimer(); - /// - /// Called when Test Case End event is invoked - /// - /// Sender - /// TestCaseEndEventArgs - private void EventsTestCaseEnd(object sender, TestCaseEndEventArgs e) + if (EqtTrace.IsInfoEnabled) { - this.ResetInactivityTimer(); - - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("Blame Collector : Test Case End"); - } + EqtTrace.Info("Blame Collector : Test Case End"); + } - this.testEndCount++; + _testEndCount++; - // Update the test object in the dictionary as the test has completed. - if (this.testObjectDictionary.ContainsKey(e.TestElement.Id)) - { - this.testObjectDictionary[e.TestElement.Id].IsCompleted = true; - } + // Update the test object in the dictionary as the test has completed. + if (_testObjectDictionary.ContainsKey(e.TestElement.Id)) + { + _testObjectDictionary[e.TestElement.Id].IsCompleted = true; } + } - /// - /// Called when Session End event is invoked - /// - /// Sender - /// SessionEndEventArgs - private void SessionEndedHandler(object sender, SessionEndEventArgs args) + /// + /// Called when Session End event is invoked + /// + /// Sender + /// SessionEndEventArgs + private void SessionEndedHandler(object sender, SessionEndEventArgs args) + { + ResetInactivityTimer(); + + if (EqtTrace.IsInfoEnabled) { - this.ResetInactivityTimer(); + EqtTrace.Info("Blame Collector : Session End"); + } - if (EqtTrace.IsInfoEnabled) + try + { + // If the last test crashes, it will not invoke a test case end and therefore + // In case of crash testStartCount will be greater than testEndCount and we need to write the sequence + // And send the attachment. This won't indicate failure if there are 0 tests in the assembly, or when it fails in setup. + var processCrashedWhenRunningTests = _testStartCount > _testEndCount; + if (processCrashedWhenRunningTests) { - EqtTrace.Info("Blame Collector : Session End"); - } + var filepath = Path.Combine(GetTempDirectory(), Constants.AttachmentFileName + "_" + _attachmentGuid); - try + filepath = _blameReaderWriter.WriteTestSequence(_testSequence, _testObjectDictionary, filepath); + var fti = new FileTransferInformation(_context.SessionDataCollectionContext, filepath, true); + _dataCollectionSink.SendFileAsync(fti); + } + else { - // If the last test crashes, it will not invoke a test case end and therefore - // In case of crash testStartCount will be greater than testEndCount and we need to write the sequence - // And send the attachment. This won't indicate failure if there are 0 tests in the assembly, or when it fails in setup. - var processCrashedWhenRunningTests = this.testStartCount > this.testEndCount; - if (processCrashedWhenRunningTests) + if (_collectProcessDumpOnTestHostHang) { - var filepath = Path.Combine(this.GetTempDirectory(), Constants.AttachmentFileName + "_" + this.attachmentGuid); - - filepath = this.blameReaderWriter.WriteTestSequence(this.testSequence, this.testObjectDictionary, filepath); - var fti = new FileTransferInformation(this.context.SessionDataCollectionContext, filepath, true); - this.dataCollectionSink.SendFileAsync(fti); - } - else - { - if (this.collectProcessDumpOnTestHostHang) - { - this.logger.LogWarning(this.context.SessionDataCollectionContext, Resources.Resources.NotGeneratingSequenceFile); - } + _logger.LogWarning(_context.SessionDataCollectionContext, Resources.Resources.NotGeneratingSequenceFile); } + } - if (this.uploadDumpFiles) + if (_uploadDumpFiles) + { + try { - try + var dumpFiles = _processDumpUtility.GetDumpFiles(warnOnNoDumpFiles: _collectDumpAlways, processCrashedWhenRunningTests); + foreach (var dumpFile in dumpFiles) { - var dumpFiles = this.processDumpUtility.GetDumpFiles(warnOnNoDumpFiles: this.collectDumpAlways, processCrashedWhenRunningTests); - foreach (var dumpFile in dumpFiles) + if (!string.IsNullOrEmpty(dumpFile)) { - if (!string.IsNullOrEmpty(dumpFile)) + try + { + var fileTranferInformation = new FileTransferInformation(_context.SessionDataCollectionContext, dumpFile, true); + _dataCollectionSink.SendFileAsync(fileTranferInformation); + } + catch (FileNotFoundException ex) { - try - { - var fileTranferInformation = new FileTransferInformation(this.context.SessionDataCollectionContext, dumpFile, true); - this.dataCollectionSink.SendFileAsync(fileTranferInformation); - } - catch (FileNotFoundException ex) - { - EqtTrace.Warning(ex.ToString()); - this.logger.LogWarning(args.Context, ex.ToString()); - } + EqtTrace.Warning(ex.ToString()); + _logger.LogWarning(args.Context, ex.ToString()); } } } - catch (FileNotFoundException ex) - { - EqtTrace.Warning(ex.ToString()); - this.logger.LogWarning(args.Context, ex.ToString()); - } } - else + catch (FileNotFoundException ex) { - EqtTrace.Info("BlameCollector.CollectDumpAndAbortTesthost: Custom path to dump directory was provided via VSTEST_DUMP_PATH. Skipping attachment upload, the caller is responsible for collecting and uploading the dumps themselves."); + EqtTrace.Warning(ex.ToString()); + _logger.LogWarning(args.Context, ex.ToString()); } } - finally + else { - // Attempt to terminate the proc dump process if proc dump was enabled - if (this.collectProcessDumpOnTrigger) - { - this.processDumpUtility.DetachFromTargetProcess(this.testHostProcessId); - } - - this.DeregisterEvents(); + EqtTrace.Info("BlameCollector.CollectDumpAndAbortTesthost: Custom path to dump directory was provided via VSTEST_DUMP_PATH. Skipping attachment upload, the caller is responsible for collecting and uploading the dumps themselves."); } } - - /// - /// Called when Test Host Initialized is invoked - /// - /// Sender - /// TestHostLaunchedEventArgs - private void TestHostLaunchedHandler(object sender, TestHostLaunchedEventArgs args) + finally { - this.ResetInactivityTimer(); - this.testHostProcessId = args.TestHostProcessId; - - if (!this.collectProcessDumpOnTrigger) + // Attempt to terminate the proc dump process if proc dump was enabled + if (_collectProcessDumpOnTrigger) { - return; + _processDumpUtility.DetachFromTargetProcess(_testHostProcessId); } - try - { - var dumpDirectory = this.GetDumpDirectory(); - this.processDumpUtility.StartTriggerBasedProcessDump(args.TestHostProcessId, dumpDirectory, this.processFullDumpEnabled, this.targetFramework, this.collectDumpAlways); - } - catch (TestPlatformException e) - { - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning("BlameCollector.TestHostLaunchedHandler: Could not start process dump. {0}", e); - } + DeregisterEvents(); + } + } - this.logger.LogWarning(args.Context, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.ProcDumpCouldNotStart, e.Message)); - } - catch (Exception e) - { - if (EqtTrace.IsWarningEnabled) - { - EqtTrace.Warning("BlameCollector.TestHostLaunchedHandler: Could not start process dump. {0}", e); - } + /// + /// Called when Test Host Initialized is invoked + /// + /// Sender + /// TestHostLaunchedEventArgs + private void TestHostLaunchedHandler(object sender, TestHostLaunchedEventArgs args) + { + ResetInactivityTimer(); + _testHostProcessId = args.TestHostProcessId; - this.logger.LogWarning(args.Context, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.ProcDumpCouldNotStart, e.ToString())); - } + if (!_collectProcessDumpOnTrigger) + { + return; } - /// - /// Resets the inactivity timer - /// - private void ResetInactivityTimer() + try + { + var dumpDirectory = GetDumpDirectory(); + _processDumpUtility.StartTriggerBasedProcessDump(args.TestHostProcessId, dumpDirectory, _processFullDumpEnabled, _targetFramework, _collectDumpAlways); + } + catch (TestPlatformException e) { - if (!this.collectProcessDumpOnTestHostHang || this.inactivityTimerAlreadyFired) + if (EqtTrace.IsWarningEnabled) { - return; + EqtTrace.Warning("BlameCollector.TestHostLaunchedHandler: Could not start process dump. {0}", e); } - EqtTrace.Verbose("Reset the inactivity timer since an event was received."); - try - { - this.inactivityTimer.ResetTimer(this.inactivityTimespan); - } - catch (Exception e) + _logger.LogWarning(args.Context, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.ProcDumpCouldNotStart, e.Message)); + } + catch (Exception e) + { + if (EqtTrace.IsWarningEnabled) { - EqtTrace.Warning($"Failed to reset the inactivity timer with error {e}"); + EqtTrace.Warning("BlameCollector.TestHostLaunchedHandler: Could not start process dump. {0}", e); } + + _logger.LogWarning(args.Context, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.ProcDumpCouldNotStart, e.ToString())); } + } - /// - /// Method to de-register handlers and cleanup - /// - private void DeregisterEvents() + /// + /// Resets the inactivity timer + /// + private void ResetInactivityTimer() + { + if (!_collectProcessDumpOnTestHostHang || _inactivityTimerAlreadyFired) { - this.events.SessionEnd -= this.SessionEndedHandler; - this.events.TestCaseStart -= this.EventsTestCaseStart; - this.events.TestCaseEnd -= this.EventsTestCaseEnd; + return; } - private string GetTempDirectory() + EqtTrace.Verbose("Reset the inactivity timer since an event was received."); + try { - if (string.IsNullOrWhiteSpace(this.tempDirectory)) - { - // DUMP_TEMP_PATH will be used as temporary storage location - // for the dumps, this won't affect the dump uploads. Just the place where - // we store them before moving them to the final folder. - - // AGENT_TEMPDIRECTORY is AzureDevops variable, which is set to path - // that is cleaned up after every job. This is preferable to use over - // just the normal temp. - var temp = Environment.GetEnvironmentVariable("VSTEST_DUMP_TEMP_PATH") ?? Environment.GetEnvironmentVariable("AGENT_TEMPDIRECTORY") ?? Path.GetTempPath(); - this.tempDirectory = Path.Combine(temp, Guid.NewGuid().ToString()); - Directory.CreateDirectory(this.tempDirectory); - return this.tempDirectory; - } - - return this.tempDirectory; + _inactivityTimer.ResetTimer(_inactivityTimespan); + } + catch (Exception e) + { + EqtTrace.Warning($"Failed to reset the inactivity timer with error {e}"); } + } + + /// + /// Method to de-register handlers and cleanup + /// + private void DeregisterEvents() + { + _events.SessionEnd -= SessionEndedHandler; + _events.TestCaseStart -= EventsTestCaseStart; + _events.TestCaseEnd -= EventsTestCaseEnd; + } - private string GetDumpDirectory() + private string GetTempDirectory() + { + if (string.IsNullOrWhiteSpace(_tempDirectory)) { - // Using a custom dump path for scenarios where we want to upload the - // dump files ourselves, such as when running in Helix. - // This will save into the directory specified via VSTEST_DUMP_PATH, and - // skip uploading dumps via attachments. - var dumpDirectoryOverride = Environment.GetEnvironmentVariable("VSTEST_DUMP_PATH"); - var dumpDirectoryOverrideHasValue = !string.IsNullOrWhiteSpace(dumpDirectoryOverride); - this.uploadDumpFiles = !dumpDirectoryOverrideHasValue; - - var dumpDirectory = dumpDirectoryOverrideHasValue ? dumpDirectoryOverride : this.GetTempDirectory(); - Directory.CreateDirectory(dumpDirectory); - var dumpPath = Path.Combine(Path.GetFullPath(dumpDirectory)); - - if (!this.uploadDumpFiles) - { - this.logger.LogWarning(this.context.SessionDataCollectionContext, $"VSTEST_DUMP_PATH is specified. Dump files will be saved in: {dumpPath}, and won't be added to attachments."); - } + // DUMP_TEMP_PATH will be used as temporary storage location + // for the dumps, this won't affect the dump uploads. Just the place where + // we store them before moving them to the final folder. + + // AGENT_TEMPDIRECTORY is AzureDevops variable, which is set to path + // that is cleaned up after every job. This is preferable to use over + // just the normal temp. + var temp = Environment.GetEnvironmentVariable("VSTEST_DUMP_TEMP_PATH") ?? Environment.GetEnvironmentVariable("AGENT_TEMPDIRECTORY") ?? Path.GetTempPath(); + _tempDirectory = Path.Combine(temp, Guid.NewGuid().ToString()); + Directory.CreateDirectory(_tempDirectory); + return _tempDirectory; + } + + return _tempDirectory; + } - return dumpPath; + private string GetDumpDirectory() + { + // Using a custom dump path for scenarios where we want to upload the + // dump files ourselves, such as when running in Helix. + // This will save into the directory specified via VSTEST_DUMP_PATH, and + // skip uploading dumps via attachments. + var dumpDirectoryOverride = Environment.GetEnvironmentVariable("VSTEST_DUMP_PATH"); + var dumpDirectoryOverrideHasValue = !string.IsNullOrWhiteSpace(dumpDirectoryOverride); + _uploadDumpFiles = !dumpDirectoryOverrideHasValue; + + var dumpDirectory = dumpDirectoryOverrideHasValue ? dumpDirectoryOverride : GetTempDirectory(); + Directory.CreateDirectory(dumpDirectory); + var dumpPath = Path.Combine(Path.GetFullPath(dumpDirectory)); + + if (!_uploadDumpFiles) + { + _logger.LogWarning(_context.SessionDataCollectionContext, $"VSTEST_DUMP_PATH is specified. Dump files will be saved in: {dumpPath}, and won't be added to attachments."); } + + return dumpPath; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameLogger.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameLogger.cs index 80ce1c3166..13c1d63222 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameLogger.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameLogger.cs @@ -1,165 +1,165 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.Utilities; + +/// +/// The blame logger. +/// +[FriendlyName(BlameLogger.FriendlyName)] +[ExtensionUri(BlameLogger.ExtensionUri)] +public class BlameLogger : ITestLogger { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.Utilities; + #region Constants /// - /// The blame logger. + /// Uri used to uniquely identify the Blame logger. /// - [FriendlyName(BlameLogger.FriendlyName)] - [ExtensionUri(BlameLogger.ExtensionUri)] - public class BlameLogger : ITestLogger - { - #region Constants - - /// - /// Uri used to uniquely identify the Blame logger. - /// - public const string ExtensionUri = "logger://Microsoft/TestPlatform/Extensions/Blame/v1"; + public const string ExtensionUri = "logger://Microsoft/TestPlatform/Extensions/Blame/v1"; - /// - /// Alternate user friendly string to uniquely identify the Blame logger. - /// - public const string FriendlyName = "Blame"; + /// + /// Alternate user friendly string to uniquely identify the Blame logger. + /// + public const string FriendlyName = "Blame"; - /// - /// The blame reader writer. - /// - private readonly IBlameReaderWriter blameReaderWriter; + /// + /// The blame reader writer. + /// + private readonly IBlameReaderWriter _blameReaderWriter; - /// - /// The output. - /// - private readonly IOutput output; + /// + /// The output. + /// + private readonly IOutput _output; - #endregion + #endregion - #region Constructor + #region Constructor - /// - /// Initializes a new instance of the class. - /// - public BlameLogger() - : this(ConsoleOutput.Instance, new XmlReaderWriter()) - { - } + /// + /// Initializes a new instance of the class. + /// + public BlameLogger() + : this(ConsoleOutput.Instance, new XmlReaderWriter()) + { + } - /// - /// Initializes a new instance of the class. - /// Constructor added for testing purpose - /// - /// Output Instance - /// BlameReaderWriter Instance - protected BlameLogger(IOutput output, IBlameReaderWriter blameReaderWriter) - { - this.output = output; - this.blameReaderWriter = blameReaderWriter; - } + /// + /// Initializes a new instance of the class. + /// Constructor added for testing purpose + /// + /// Output Instance + /// BlameReaderWriter Instance + protected BlameLogger(IOutput output, IBlameReaderWriter blameReaderWriter) + { + _output = output; + _blameReaderWriter = blameReaderWriter; + } - #endregion + #endregion - #region ITestLogger + #region ITestLogger - /// - /// Initializes the Logger. - /// - /// Events that can be registered for. - /// Test Run Directory - public void Initialize(TestLoggerEvents events, string testRunDictionary) + /// + /// Initializes the Logger. + /// + /// Events that can be registered for. + /// Test Run Directory + public void Initialize(TestLoggerEvents events, string testRunDictionary) + { + if (events == null) { - if (events == null) - { - throw new ArgumentNullException(nameof(events)); - } - - events.TestRunComplete += this.TestRunCompleteHandler; + throw new ArgumentNullException(nameof(events)); } - /// - /// Called when a test run is complete. - /// - /// Sender - /// TestRunCompleteEventArgs - private void TestRunCompleteHandler(object sender, TestRunCompleteEventArgs e) - { - if (sender == null) - { - throw new ArgumentNullException(nameof(sender)); - } + events.TestRunComplete += TestRunCompleteHandler; + } - ValidateArg.NotNull(sender, nameof(sender)); - ValidateArg.NotNull(e, nameof(e)); + /// + /// Called when a test run is complete. + /// + /// Sender + /// TestRunCompleteEventArgs + private void TestRunCompleteHandler(object sender, TestRunCompleteEventArgs e) + { + if (sender == null) + { + throw new ArgumentNullException(nameof(sender)); + } - if (!e.IsAborted) - { - return; - } + ValidateArg.NotNull(sender, nameof(sender)); + ValidateArg.NotNull(e, nameof(e)); - this.output.WriteLine(string.Empty, OutputLevel.Information); + if (!e.IsAborted) + { + return; + } - // Gets the faulty test cases if test aborted - var testCaseNames = this.GetFaultyTestCaseNames(e); - if (!testCaseNames.Any()) - { - return; - } + _output.WriteLine(string.Empty, OutputLevel.Information); - StringBuilder sb = new StringBuilder(); - foreach (var tcn in testCaseNames) - { - sb.Append(tcn).Append(Environment.NewLine); - } + // Gets the faulty test cases if test aborted + var testCaseNames = GetFaultyTestCaseNames(e); + if (!testCaseNames.Any()) + { + return; + } - this.output.Error(false, Resources.Resources.AbortedTestRun, sb.ToString()); + var sb = new StringBuilder(); + foreach (var tcn in testCaseNames) + { + sb.Append(tcn).Append(Environment.NewLine); } - #endregion + _output.Error(false, Resources.Resources.AbortedTestRun, sb.ToString()); + } + + #endregion - #region Faulty test case fetch + #region Faulty test case fetch - /// - /// Fetches faulty test case - /// - /// - /// The TestRunCompleteEventArgs. - /// - /// - /// Faulty test cases name - /// - private IEnumerable GetFaultyTestCaseNames(TestRunCompleteEventArgs e) + /// + /// Fetches faulty test case + /// + /// + /// The TestRunCompleteEventArgs. + /// + /// + /// Faulty test cases name + /// + private IEnumerable GetFaultyTestCaseNames(TestRunCompleteEventArgs e) + { + var faultyTestCaseNames = new List(); + foreach (var attachmentSet in e.AttachmentSets) { - var faultyTestCaseNames = new List(); - foreach (var attachmentSet in e.AttachmentSets) + if (attachmentSet.DisplayName.Equals(Constants.BlameDataCollectorName)) { - if (attachmentSet.DisplayName.Equals(Constants.BlameDataCollectorName)) - { - // Process only Sequence_.xml attachments - var uriDataAttachment = attachmentSet.Attachments.LastOrDefault((attachment) => attachment.Uri.ToString().EndsWith(".xml")); + // Process only Sequence_.xml attachments + var uriDataAttachment = attachmentSet.Attachments.LastOrDefault((attachment) => attachment.Uri.ToString().EndsWith(".xml")); - if (uriDataAttachment != null) + if (uriDataAttachment != null) + { + var filepath = uriDataAttachment.Uri.LocalPath; + var testCaseList = _blameReaderWriter.ReadTestSequence(filepath); + if (testCaseList.Count > 0) { - var filepath = uriDataAttachment.Uri.LocalPath; - var testCaseList = this.blameReaderWriter.ReadTestSequence(filepath); - if (testCaseList.Count > 0) - { - var testcases = testCaseList.Where(t => !t.IsCompleted).Select(t => t.FullyQualifiedName).ToList(); - faultyTestCaseNames.AddRange(testcases); - } + var testcases = testCaseList.Where(t => !t.IsCompleted).Select(t => t.FullyQualifiedName).ToList(); + faultyTestCaseNames.AddRange(testcases); } } } - - return faultyTestCaseNames; } - #endregion + return faultyTestCaseNames; } -} \ No newline at end of file + + #endregion +} diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameTestObject.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameTestObject.cs index 7295d83ae3..08f513447a 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameTestObject.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameTestObject.cs @@ -1,162 +1,98 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; + +public class BlameTestObject { - using System; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public BlameTestObject() + { + // Default constructor + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Fully qualified name of the test case. + /// + /// + /// The Uri of the executor to use for running this test. + /// + /// + /// Test container source from which the test is discovered. + /// + public BlameTestObject(string fullyQualifiedName, Uri executorUri, string source) + { + ValidateArg.NotNullOrEmpty(fullyQualifiedName, nameof(fullyQualifiedName)); + ValidateArg.NotNull(executorUri, nameof(executorUri)); + ValidateArg.NotNullOrEmpty(source, nameof(source)); + + Id = Guid.Empty; + FullyQualifiedName = fullyQualifiedName; + ExecutorUri = executorUri; + Source = source; + IsCompleted = false; + } - public class BlameTestObject + /// + /// Initializes a new instance of the class. + /// + /// + /// The test case + /// + public BlameTestObject(TestCase testCase) { - private Guid id; - private string fullyQualifiedName; - private string source; - private bool isCompleted; - private string displayName; - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - public BlameTestObject() - { - // Default constructor - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Fully qualified name of the test case. - /// - /// - /// The Uri of the executor to use for running this test. - /// - /// - /// Test container source from which the test is discovered. - /// - public BlameTestObject(string fullyQualifiedName, Uri executorUri, string source) - { - ValidateArg.NotNullOrEmpty(fullyQualifiedName, nameof(fullyQualifiedName)); - ValidateArg.NotNull(executorUri, nameof(executorUri)); - ValidateArg.NotNullOrEmpty(source, nameof(source)); - - this.Id = Guid.Empty; - this.FullyQualifiedName = fullyQualifiedName; - this.ExecutorUri = executorUri; - this.Source = source; - this.IsCompleted = false; - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// The test case - /// - public BlameTestObject(TestCase testCase) - { - this.Id = testCase.Id; - this.FullyQualifiedName = testCase.FullyQualifiedName; - this.ExecutorUri = testCase.ExecutorUri; - this.Source = testCase.Source; - this.DisplayName = testCase.DisplayName; - this.IsCompleted = false; - } - - #endregion - - #region Properties - - /// - /// Gets or sets the id of the test case. - /// - public Guid Id - { - get - { - return this.id; - } - - set - { - this.id = value; - } - } - - /// - /// Gets or sets the fully qualified name of the test case. - /// - public string FullyQualifiedName - { - get - { - return this.fullyQualifiedName; - } - - set - { - this.fullyQualifiedName = value; - } - } - - /// - /// Gets or sets the Uri of the Executor to use for running this test. - /// - public Uri ExecutorUri - { - get; set; - } - - /// - /// Gets or sets the test container source from which the test is discovered. - /// - public string Source - { - get - { - return this.source; - } - - set - { - this.source = value; - } - } - - /// - /// Gets or sets a value indicating whether test case is completed or not. - /// - public bool IsCompleted - { - get - { - return this.isCompleted; - } - - set - { - this.isCompleted = value; - } - } - - /// - /// Gets or sets the display name of the test case - /// - public string DisplayName - { - get - { - return this.displayName; - } - - set - { - this.displayName = value; - } - } - - #endregion + Id = testCase.Id; + FullyQualifiedName = testCase.FullyQualifiedName; + ExecutorUri = testCase.ExecutorUri; + Source = testCase.Source; + DisplayName = testCase.DisplayName; + IsCompleted = false; } + + #endregion + + #region Properties + + /// + /// Gets or sets the id of the test case. + /// + public Guid Id { get; set; } + + /// + /// Gets or sets the fully qualified name of the test case. + /// + public string FullyQualifiedName { get; set; } + + /// + /// Gets or sets the Uri of the Executor to use for running this test. + /// + public Uri ExecutorUri { get; set; } + + /// + /// Gets or sets the test container source from which the test is discovered. + /// + public string Source { get; set; } + + /// + /// Gets or sets a value indicating whether test case is completed or not. + /// + public bool IsCompleted { get; set; } + + /// + /// Gets or sets the display name of the test case + /// + public string DisplayName { get; set; } + + #endregion } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Constants.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Constants.cs index 3365773fb1..2c935b9954 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Constants.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Constants.cs @@ -1,128 +1,127 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +/// +/// Class for constants used across the files. +/// +internal static class Constants { /// - /// Class for constants used across the files. - /// - internal static class Constants - { - /// - /// Root node name for Xml file. - /// - public const string BlameRootNode = "TestSequence"; - - /// - /// Node name for each Xml node. - /// - public const string BlameTestNode = "Test"; - - /// - /// Attachment File name. - /// - public const string AttachmentFileName = "Sequence"; - - /// - /// Test Name Attribute. - /// - public const string TestNameAttribute = "Name"; - - /// - /// Test Source Attribute. - /// - public const string TestSourceAttribute = "Source"; - - /// - /// Test Completed Attribute. - /// - public const string TestCompletedAttribute = "Completed"; - - /// - /// Test Display Name Attribute. - /// - public const string TestDisplayNameAttribute = "DisplayName"; - - /// - /// Friendly name of the data collector - /// - public const string BlameDataCollectorName = "Blame"; - - /// - /// Configuration key name for dump mode - /// - public const string DumpModeKey = "CollectDump"; - - /// - /// Configuration key name for hang dump mode - /// - public const string HangDumpModeKey = "CollectHangDump"; - - /// - /// Proc dump 32 bit version - /// - public const string ProcdumpProcess = "procdump.exe"; - - /// - /// Proc dump 64 bit version - /// - public const string Procdump64Process = "procdump64.exe"; - - /// - /// Proc dump 64 bit version - /// - public const string ProcdumpUnixProcess = "procdump"; - - /// - /// Configuration key name for collect dump always - /// - public const string CollectDumpAlwaysKey = "CollectAlways"; - - /// - /// Configuration key name for collecting dump in case of testhost hang - /// - public const string CollectDumpOnTestSessionHang = "CollectDumpOnTestSessionHang"; - - /// - /// Configuration key name for specifying what the expected execution time for the longest running test is. - /// If no events come from the test host for this period a dump will be collected and the test host process will - /// be killed. - /// - public const string TestTimeout = "TestTimeout"; - - /// - /// Configuration key name for dump type - /// - public const string DumpTypeKey = "DumpType"; - - /// - /// Configuration key name for hang dump type - /// - public const string HangDumpTypeKey = "HangDumpType"; - - /// - /// Configuration value for true - /// - public const string TrueConfigurationValue = "True"; - - /// - /// Configuration value for false - /// - public const string FalseConfigurationValue = "False"; - - /// - /// Configuration value for full - /// - public const string FullConfigurationValue = "Full"; - - /// - /// Configuration value for mini - /// - public const string MiniConfigurationValue = "Mini"; - - /// - /// The target framework of test host. - /// - public const string TargetFramework = "Framework"; - } -} + /// Root node name for Xml file. + /// + public const string BlameRootNode = "TestSequence"; + + /// + /// Node name for each Xml node. + /// + public const string BlameTestNode = "Test"; + + /// + /// Attachment File name. + /// + public const string AttachmentFileName = "Sequence"; + + /// + /// Test Name Attribute. + /// + public const string TestNameAttribute = "Name"; + + /// + /// Test Source Attribute. + /// + public const string TestSourceAttribute = "Source"; + + /// + /// Test Completed Attribute. + /// + public const string TestCompletedAttribute = "Completed"; + + /// + /// Test Display Name Attribute. + /// + public const string TestDisplayNameAttribute = "DisplayName"; + + /// + /// Friendly name of the data collector + /// + public const string BlameDataCollectorName = "Blame"; + + /// + /// Configuration key name for dump mode + /// + public const string DumpModeKey = "CollectDump"; + + /// + /// Configuration key name for hang dump mode + /// + public const string HangDumpModeKey = "CollectHangDump"; + + /// + /// Proc dump 32 bit version + /// + public const string ProcdumpProcess = "procdump.exe"; + + /// + /// Proc dump 64 bit version + /// + public const string Procdump64Process = "procdump64.exe"; + + /// + /// Proc dump 64 bit version + /// + public const string ProcdumpUnixProcess = "procdump"; + + /// + /// Configuration key name for collect dump always + /// + public const string CollectDumpAlwaysKey = "CollectAlways"; + + /// + /// Configuration key name for collecting dump in case of testhost hang + /// + public const string CollectDumpOnTestSessionHang = "CollectDumpOnTestSessionHang"; + + /// + /// Configuration key name for specifying what the expected execution time for the longest running test is. + /// If no events come from the test host for this period a dump will be collected and the test host process will + /// be killed. + /// + public const string TestTimeout = "TestTimeout"; + + /// + /// Configuration key name for dump type + /// + public const string DumpTypeKey = "DumpType"; + + /// + /// Configuration key name for hang dump type + /// + public const string HangDumpTypeKey = "HangDumpType"; + + /// + /// Configuration value for true + /// + public const string TrueConfigurationValue = "True"; + + /// + /// Configuration value for false + /// + public const string FalseConfigurationValue = "False"; + + /// + /// Configuration value for full + /// + public const string FullConfigurationValue = "Full"; + + /// + /// Configuration value for mini + /// + public const string MiniConfigurationValue = "Mini"; + + /// + /// The target framework of test host. + /// + public const string TargetFramework = "Framework"; +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/CrashDumperFactory.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/CrashDumperFactory.cs index 708c32973b..e0ba9df1e8 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/CrashDumperFactory.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/CrashDumperFactory.cs @@ -1,68 +1,69 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector -{ - using System; - using System.Runtime.InteropServices; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using NuGet.Frameworks; +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; +using System.Runtime.InteropServices; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - internal class CrashDumperFactory : ICrashDumperFactory +using NuGet.Frameworks; + +internal class CrashDumperFactory : ICrashDumperFactory +{ + public ICrashDumper Create(string targetFramework) { - public ICrashDumper Create(string targetFramework) + if (targetFramework is null) { - if (targetFramework is null) - { - throw new ArgumentNullException(nameof(targetFramework)); - } + throw new ArgumentNullException(nameof(targetFramework)); + } - EqtTrace.Info($"CrashDumperFactory: Creating dumper for {RuntimeInformation.OSDescription} with target framework {targetFramework}."); + EqtTrace.Info($"CrashDumperFactory: Creating dumper for {RuntimeInformation.OSDescription} with target framework {targetFramework}."); - var tfm = NuGetFramework.Parse(targetFramework); + var tfm = NuGetFramework.Parse(targetFramework); - if (tfm == null || tfm.IsUnsupported) - { - EqtTrace.Error($"CrashDumperFactory: Could not parse target framework {targetFramework}, to a supported framework version."); - throw new NotSupportedException($"Could not parse target framework {targetFramework}, to a supported framework version."); - } + if (tfm == null || tfm.IsUnsupported) + { + EqtTrace.Error($"CrashDumperFactory: Could not parse target framework {targetFramework}, to a supported framework version."); + throw new NotSupportedException($"Could not parse target framework {targetFramework}, to a supported framework version."); + } - var isNet50OrNewer = tfm.Framework == ".NETCoreApp" && tfm.Version >= Version.Parse("5.0.0.0"); + var isNet50OrNewer = tfm.Framework == ".NETCoreApp" && tfm.Version >= Version.Parse("5.0.0.0"); - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + if (!isNet50OrNewer) { - if (!isNet50OrNewer) - { - EqtTrace.Info($"CrashDumperFactory: This is Windows on {targetFramework} which is not net5.0 or newer, returning ProcDumpCrashDumper that uses ProcDump utility."); - return new ProcDumpDumper(); - } - - // On net5.0 we don't have the capability to crash dump on exit, which is useful in rare cases - // like when user exits the testhost process with a random exit code, adding this evn variable - // to force using procdump. This relies on netclient dumper actualy doing all it's work in blame collector - // where it sets all the environment variables, so in effect we will have two crash dumpers active at the same time. - // This proven to be working okay while net5.0 could not create dumps from Task.Run, and I was using this same technique - // to get dump of testhost. This needs PROCDUMP_PATH set to directory with procdump.exe, or having it in path. - var procdumpOverride = Environment.GetEnvironmentVariable("VSTEST_DUMP_FORCEPROCDUMP")?.Trim(); - var forceUsingProcdump = !string.IsNullOrWhiteSpace(procdumpOverride) && procdumpOverride != "0"; - if (forceUsingProcdump) - { - EqtTrace.Info($"CrashDumperFactory: This is Windows on {targetFramework}. Forcing the use of ProcDumpCrashDumper that uses ProcDump utility, via VSTEST_DUMP_FORCEPROCDUMP={procdumpOverride}."); - return new ProcDumpDumper(); - } - - EqtTrace.Info($"CrashDumperFactory: This is Windows on {targetFramework}, returning the .NETClient dumper which uses env variables to collect crashdumps of testhost and any child process."); - return new NetClientCrashDumper(new FileHelper()); + EqtTrace.Info($"CrashDumperFactory: This is Windows on {targetFramework} which is not net5.0 or newer, returning ProcDumpCrashDumper that uses ProcDump utility."); + return new ProcDumpDumper(); } - if (isNet50OrNewer) + // On net5.0 we don't have the capability to crash dump on exit, which is useful in rare cases + // like when user exits the testhost process with a random exit code, adding this evn variable + // to force using procdump. This relies on netclient dumper actualy doing all it's work in blame collector + // where it sets all the environment variables, so in effect we will have two crash dumpers active at the same time. + // This proven to be working okay while net5.0 could not create dumps from Task.Run, and I was using this same technique + // to get dump of testhost. This needs PROCDUMP_PATH set to directory with procdump.exe, or having it in path. + var procdumpOverride = Environment.GetEnvironmentVariable("VSTEST_DUMP_FORCEPROCDUMP")?.Trim(); + var forceUsingProcdump = !string.IsNullOrWhiteSpace(procdumpOverride) && procdumpOverride != "0"; + if (forceUsingProcdump) { - EqtTrace.Info($"CrashDumperFactory: This is {RuntimeInformation.OSDescription} on {targetFramework} .NETClient dumper which uses env variables to collect crashdumps of testhost and any child process."); - return new NetClientCrashDumper(new FileHelper()); + EqtTrace.Info($"CrashDumperFactory: This is Windows on {targetFramework}. Forcing the use of ProcDumpCrashDumper that uses ProcDump utility, via VSTEST_DUMP_FORCEPROCDUMP={procdumpOverride}."); + return new ProcDumpDumper(); } - throw new PlatformNotSupportedException($"Unsupported operating system: {RuntimeInformation.OSDescription}, and framework: {targetFramework}."); + EqtTrace.Info($"CrashDumperFactory: This is Windows on {targetFramework}, returning the .NETClient dumper which uses env variables to collect crashdumps of testhost and any child process."); + return new NetClientCrashDumper(new FileHelper()); } + + if (isNet50OrNewer) + { + EqtTrace.Info($"CrashDumperFactory: This is {RuntimeInformation.OSDescription} on {targetFramework} .NETClient dumper which uses env variables to collect crashdumps of testhost and any child process."); + return new NetClientCrashDumper(new FileHelper()); + } + + throw new PlatformNotSupportedException($"Unsupported operating system: {RuntimeInformation.OSDescription}, and framework: {targetFramework}."); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/DumpTypeOption.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/DumpTypeOption.cs index 997c65955d..4c30049b24 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/DumpTypeOption.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/DumpTypeOption.cs @@ -1,12 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +public enum DumpTypeOption { - public enum DumpTypeOption - { - Full, - WithHeap, - Mini, - } -} + Full, + WithHeap, + Mini, +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/HangDumperFactory.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/HangDumperFactory.cs index 1e5a4db51d..4f8296b1ad 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/HangDumperFactory.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/HangDumperFactory.cs @@ -1,96 +1,97 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; +using System.Runtime.InteropServices; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using NuGet.Frameworks; + +internal class HangDumperFactory : IHangDumperFactory { - using System; - using System.Runtime.InteropServices; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using NuGet.Frameworks; + public Action LogWarning { get; set; } - internal class HangDumperFactory : IHangDumperFactory + public IHangDumper Create(string targetFramework) { - public Action LogWarning { get; set; } - - public IHangDumper Create(string targetFramework) + if (targetFramework is null) { - if (targetFramework is null) - { - throw new ArgumentNullException(nameof(targetFramework)); - } + throw new ArgumentNullException(nameof(targetFramework)); + } - EqtTrace.Info($"HangDumperFactory: Creating dumper for {RuntimeInformation.OSDescription} with target framework {targetFramework}."); - var procdumpOverride = Environment.GetEnvironmentVariable("VSTEST_DUMP_FORCEPROCDUMP")?.Trim(); - var netdumpOverride = Environment.GetEnvironmentVariable("VSTEST_DUMP_FORCENETDUMP")?.Trim(); - EqtTrace.Verbose($"HangDumperFactory: Overrides for dumpers: VSTEST_DUMP_FORCEPROCDUMP={procdumpOverride};VSTEST_DUMP_FORCENETDUMP={netdumpOverride}"); + EqtTrace.Info($"HangDumperFactory: Creating dumper for {RuntimeInformation.OSDescription} with target framework {targetFramework}."); + var procdumpOverride = Environment.GetEnvironmentVariable("VSTEST_DUMP_FORCEPROCDUMP")?.Trim(); + var netdumpOverride = Environment.GetEnvironmentVariable("VSTEST_DUMP_FORCENETDUMP")?.Trim(); + EqtTrace.Verbose($"HangDumperFactory: Overrides for dumpers: VSTEST_DUMP_FORCEPROCDUMP={procdumpOverride};VSTEST_DUMP_FORCENETDUMP={netdumpOverride}"); - var tfm = NuGetFramework.Parse(targetFramework); + var tfm = NuGetFramework.Parse(targetFramework); - if (tfm == null || tfm.IsUnsupported) + if (tfm == null || tfm.IsUnsupported) + { + EqtTrace.Error($"HangDumperFactory: Could not parse target framework {targetFramework}, to a supported framework version."); + throw new NotSupportedException($"Could not parse target framework {targetFramework}, to a supported framework version."); + } + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + // On some system the interop dumper will thrown AccessViolationException, add an option to force procdump. + var forceUsingProcdump = !string.IsNullOrWhiteSpace(procdumpOverride) && procdumpOverride != "0"; + if (forceUsingProcdump) { - EqtTrace.Error($"HangDumperFactory: Could not parse target framework {targetFramework}, to a supported framework version."); - throw new NotSupportedException($"Could not parse target framework {targetFramework}, to a supported framework version."); + EqtTrace.Info($"HangDumperFactory: This is Windows on Forcing the use of ProcDumpHangDumper that uses ProcDump utility, via VSTEST_DUMP_FORCEPROCDUMP={procdumpOverride}."); + return new ProcDumpDumper(); } - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + // On some system the interop dumper will thrown AccessViolationException, add an option to force procdump. + var forceUsingNetdump = !string.IsNullOrWhiteSpace(netdumpOverride) && netdumpOverride != "0"; + if (forceUsingNetdump) { - // On some system the interop dumper will thrown AccessViolationException, add an option to force procdump. - var forceUsingProcdump = !string.IsNullOrWhiteSpace(procdumpOverride) && procdumpOverride != "0"; - if (forceUsingProcdump) + var isLessThan50 = tfm.Framework == ".NETCoreApp" && tfm.Version < Version.Parse("5.0.0.0"); + if (!isLessThan50) { - EqtTrace.Info($"HangDumperFactory: This is Windows on Forcing the use of ProcDumpHangDumper that uses ProcDump utility, via VSTEST_DUMP_FORCEPROCDUMP={procdumpOverride}."); - return new ProcDumpDumper(); + EqtTrace.Info($"HangDumperFactory: This is Windows on {tfm.Framework} {tfm.Version}, VSTEST_DUMP_FORCENETDUMP={netdumpOverride} is active, forcing use of .NetClientHangDumper"); + return new NetClientHangDumper(); } - - // On some system the interop dumper will thrown AccessViolationException, add an option to force procdump. - var forceUsingNetdump = !string.IsNullOrWhiteSpace(netdumpOverride) && netdumpOverride != "0"; - if (forceUsingNetdump) + else { - var isLessThan50 = tfm.Framework == ".NETCoreApp" && tfm.Version < Version.Parse("5.0.0.0"); - if (!isLessThan50) - { - EqtTrace.Info($"HangDumperFactory: This is Windows on {tfm.Framework} {tfm.Version}, VSTEST_DUMP_FORCENETDUMP={netdumpOverride} is active, forcing use of .NetClientHangDumper"); - return new NetClientHangDumper(); - } - else - { - EqtTrace.Info($"HangDumperFactory: This is Windows on {tfm.Framework} {tfm.Version}, VSTEST_DUMP_FORCENETDUMP={netdumpOverride} is active, but only applies to .NET 5.0 and newer. Falling back to default hang dumper."); - } + EqtTrace.Info($"HangDumperFactory: This is Windows on {tfm.Framework} {tfm.Version}, VSTEST_DUMP_FORCENETDUMP={netdumpOverride} is active, but only applies to .NET 5.0 and newer. Falling back to default hang dumper."); } - - EqtTrace.Info($"HangDumperFactory: This is Windows, returning the default WindowsHangDumper that P/Invokes MiniDumpWriteDump."); - return new WindowsHangDumper(this.LogWarning); } - if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - var isLessThan31 = tfm.Framework == ".NETCoreApp" && tfm.Version < Version.Parse("3.1.0.0"); - if (isLessThan31) - { - EqtTrace.Info($"HangDumperFactory: This is Linux on netcoreapp2.1, returning SigtrapDumper."); + EqtTrace.Info($"HangDumperFactory: This is Windows, returning the default WindowsHangDumper that P/Invokes MiniDumpWriteDump."); + return new WindowsHangDumper(LogWarning); + } - return new SigtrapDumper(); - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + var isLessThan31 = tfm.Framework == ".NETCoreApp" && tfm.Version < Version.Parse("3.1.0.0"); + if (isLessThan31) + { + EqtTrace.Info($"HangDumperFactory: This is Linux on netcoreapp2.1, returning SigtrapDumper."); - EqtTrace.Info($"HangDumperFactory: This is Linux netcoreapp3.1 or newer, returning the standard NETClient library dumper."); - return new NetClientHangDumper(); + return new SigtrapDumper(); } - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - var isLessThan50 = tfm.Framework == ".NETCoreApp" && tfm.Version < Version.Parse("5.0.0.0"); - if (isLessThan50) - { - EqtTrace.Info($"HangDumperFactory: This is OSX on {targetFramework}, This combination of OS and framework is not supported."); + EqtTrace.Info($"HangDumperFactory: This is Linux netcoreapp3.1 or newer, returning the standard NETClient library dumper."); + return new NetClientHangDumper(); + } - throw new PlatformNotSupportedException($"Unsupported target framework {targetFramework} on OS {RuntimeInformation.OSDescription}"); - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + var isLessThan50 = tfm.Framework == ".NETCoreApp" && tfm.Version < Version.Parse("5.0.0.0"); + if (isLessThan50) + { + EqtTrace.Info($"HangDumperFactory: This is OSX on {targetFramework}, This combination of OS and framework is not supported."); - EqtTrace.Info($"HangDumperFactory: This is OSX on net5.0 or newer, returning the standard NETClient library dumper."); - return new NetClientHangDumper(); + throw new PlatformNotSupportedException($"Unsupported target framework {targetFramework} on OS {RuntimeInformation.OSDescription}"); } - throw new PlatformNotSupportedException($"Unsupported operating system: {RuntimeInformation.OSDescription}"); + EqtTrace.Info($"HangDumperFactory: This is OSX on net5.0 or newer, returning the standard NETClient library dumper."); + return new NetClientHangDumper(); } + + throw new PlatformNotSupportedException($"Unsupported operating system: {RuntimeInformation.OSDescription}"); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ICrashDumper.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ICrashDumper.cs index b303bfc82a..1207a7a2ec 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ICrashDumper.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ICrashDumper.cs @@ -1,18 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector -{ - using System.Collections.Generic; +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System.Collections.Generic; - public interface ICrashDumper - { - void AttachToTargetProcess(int processId, string outputDirectory, DumpTypeOption dumpType, bool collectAlways); +public interface ICrashDumper +{ + void AttachToTargetProcess(int processId, string outputDirectory, DumpTypeOption dumpType, bool collectAlways); - void WaitForDumpToFinish(); + void WaitForDumpToFinish(); - void DetachFromTargetProcess(int processId); + void DetachFromTargetProcess(int processId); - IEnumerable GetDumpFiles(bool processCrashed); - } -} + IEnumerable GetDumpFiles(bool processCrashed); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ICrashDumperFactory.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ICrashDumperFactory.cs index c992ec7e34..95fe3db017 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ICrashDumperFactory.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ICrashDumperFactory.cs @@ -1,10 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +public interface ICrashDumperFactory { - public interface ICrashDumperFactory - { - ICrashDumper Create(string targetFramework); - } -} + ICrashDumper Create(string targetFramework); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/IHangDumper.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/IHangDumper.cs index c13e099b3b..cc65860676 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/IHangDumper.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/IHangDumper.cs @@ -1,10 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +public interface IHangDumper { - public interface IHangDumper - { - void Dump(int processId, string outputDirectory, DumpTypeOption dumpType); - } -} + void Dump(int processId, string outputDirectory, DumpTypeOption dumpType); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/IHangDumperFactory.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/IHangDumperFactory.cs index 3abc057078..fd08233887 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/IHangDumperFactory.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/IHangDumperFactory.cs @@ -1,14 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector -{ - using System; +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; - public interface IHangDumperFactory - { - Action LogWarning { get; set; } +public interface IHangDumperFactory +{ + Action LogWarning { get; set; } - IHangDumper Create(string targetFramework); - } -} + IHangDumper Create(string targetFramework); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/InactivityTimer.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/InactivityTimer.cs index 33e6d246d1..6e06e9f0b5 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/InactivityTimer.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/InactivityTimer.cs @@ -1,36 +1,35 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; +using System.Threading; + +public class InactivityTimer : IInactivityTimer { - using System; - using System.Threading; + private readonly Timer _timer; - public class InactivityTimer : IInactivityTimer + /// + /// Initializes a new instance of the class. + /// Creates a new timer with infinite timeout + /// + /// Function to callback once the timer times out. + public InactivityTimer(Action timerCallback) { - private Timer timer; - - /// - /// Initializes a new instance of the class. - /// Creates a new timer with infinite timeout - /// - /// Function to callback once the timer times out. - public InactivityTimer(Action timerCallback) - { - this.timer = new Timer((object state) => timerCallback()); - } + _timer = new Timer((object state) => timerCallback()); + } - /// - public void ResetTimer(TimeSpan inactivityTimespan) - { - this.timer.Change(inactivityTimespan, TimeSpan.FromMilliseconds(-1)); - } + /// + public void ResetTimer(TimeSpan inactivityTimespan) + { + _timer.Change(inactivityTimespan, TimeSpan.FromMilliseconds(-1)); + } - /// - public void Dispose() - { - this.timer.Dispose(); - GC.SuppressFinalize(this); - } + /// + public void Dispose() + { + _timer.Dispose(); + GC.SuppressFinalize(this); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IBlameReaderWriter.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IBlameReaderWriter.cs index 8f695d6e34..c43e0b96f8 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IBlameReaderWriter.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IBlameReaderWriter.cs @@ -1,27 +1,26 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector -{ - using System; - using System.Collections.Generic; +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; +using System.Collections.Generic; - public interface IBlameReaderWriter - { - /// - /// Writes tests to document - /// - /// List of test guid in sequence - /// Dictionary of test objects - /// The path of file - /// File Path - string WriteTestSequence(List testSequence, Dictionary testObjectDictionary, string filePath); +public interface IBlameReaderWriter +{ + /// + /// Writes tests to document + /// + /// List of test guid in sequence + /// Dictionary of test objects + /// The path of file + /// File Path + string WriteTestSequence(List testSequence, Dictionary testObjectDictionary, string filePath); - /// - /// Reads all tests from file - /// - /// The path of saved file - /// All tests - List ReadTestSequence(string filePath); - } -} + /// + /// Reads all tests from file + /// + /// The path of saved file + /// All tests + List ReadTestSequence(string filePath); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IInactivityTimer.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IInactivityTimer.cs index 5d54fcdb65..6241019bca 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IInactivityTimer.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IInactivityTimer.cs @@ -1,16 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector -{ - using System; +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; - public interface IInactivityTimer : IDisposable - { - /// - /// Resets the timer and configures it to fire after inactivityTimespan elapses - /// - /// Duration after which the timer should fire - void ResetTimer(TimeSpan inactivityTimespan); - } -} +public interface IInactivityTimer : IDisposable +{ + /// + /// Resets the timer and configures it to fire after inactivityTimespan elapses + /// + /// Duration after which the timer should fire + void ResetTimer(TimeSpan inactivityTimespan); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/INativeMethodsHelper.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/INativeMethodsHelper.cs index eca1e128a7..ee8282d9c2 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/INativeMethodsHelper.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/INativeMethodsHelper.cs @@ -1,17 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector -{ - using System; +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; - public interface INativeMethodsHelper - { - /// - /// Returns if a process is 64 bit process - /// - /// Process Handle - /// Bool for Is64Bit - bool Is64Bit(IntPtr processHandle); - } -} +public interface INativeMethodsHelper +{ + /// + /// Returns if a process is 64 bit process + /// + /// Process Handle + /// Bool for Is64Bit + bool Is64Bit(IntPtr processHandle); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IProcDumpArgsBuilder.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IProcDumpArgsBuilder.cs index 67cf836dd2..367f082007 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IProcDumpArgsBuilder.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IProcDumpArgsBuilder.cs @@ -1,43 +1,42 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector -{ - using System.Collections.Generic; +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System.Collections.Generic; - public interface IProcDumpArgsBuilder - { - /// - /// Arguments for procdump.exe - /// - /// - /// Process Id - /// - /// - /// Filename for dump file - /// - /// - /// List of exceptions to look for - /// - /// - /// Is full dump enabled - /// - /// Arguments - string BuildTriggerBasedProcDumpArgs(int processId, string filename, IEnumerable procDumpExceptionsList, bool isFullDump); +public interface IProcDumpArgsBuilder +{ + /// + /// Arguments for procdump.exe + /// + /// + /// Process Id + /// + /// + /// Filename for dump file + /// + /// + /// List of exceptions to look for + /// + /// + /// Is full dump enabled + /// + /// Arguments + string BuildTriggerBasedProcDumpArgs(int processId, string filename, IEnumerable procDumpExceptionsList, bool isFullDump); - /// - /// Arguments for procdump.exe for getting a dump in case of a testhost hang - /// - /// - /// Process Id - /// - /// - /// Filename for dump file - /// - /// - /// Is full dump enabled - /// - /// Arguments - string BuildHangBasedProcDumpArgs(int processId, string filename, bool isFullDump); - } -} + /// + /// Arguments for procdump.exe for getting a dump in case of a testhost hang + /// + /// + /// Process Id + /// + /// + /// Filename for dump file + /// + /// + /// Is full dump enabled + /// + /// Arguments + string BuildHangBasedProcDumpArgs(int processId, string filename, bool isFullDump); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IProcessDumpUtility.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IProcessDumpUtility.cs index ec1e14ffef..deb3e687a8 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IProcessDumpUtility.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IProcessDumpUtility.cs @@ -1,71 +1,70 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector -{ - using System; - using System.Collections.Generic; +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; +using System.Collections.Generic; - public interface IProcessDumpUtility - { - /// - /// Get generated dump files - /// - /// Writes warning when no dump file is found. - /// Process might have crashed. If true it crashed for sure. If false we don't know. - /// - /// Path of dump file - /// - IEnumerable GetDumpFiles(bool warnOnNoDumpFiles, bool processCrashed); +public interface IProcessDumpUtility +{ + /// + /// Get generated dump files + /// + /// Writes warning when no dump file is found. + /// Process might have crashed. If true it crashed for sure. If false we don't know. + /// + /// Path of dump file + /// + IEnumerable GetDumpFiles(bool warnOnNoDumpFiles, bool processCrashed); - /// - /// Launch proc dump process - /// - /// - /// Process ID of test host - /// - /// - /// Path to TestResults directory - /// - /// - /// Is full dump enabled - /// - /// - /// The target framework of the process - /// - /// - /// Collect the dump on process exit even if there is no exception - /// - void StartTriggerBasedProcessDump(int processId, string testResultsDirectory, bool isFullDump, string targetFramework, bool collectAlways); + /// + /// Launch proc dump process + /// + /// + /// Process ID of test host + /// + /// + /// Path to TestResults directory + /// + /// + /// Is full dump enabled + /// + /// + /// The target framework of the process + /// + /// + /// Collect the dump on process exit even if there is no exception + /// + void StartTriggerBasedProcessDump(int processId, string testResultsDirectory, bool isFullDump, string targetFramework, bool collectAlways); - /// - /// Launch proc dump process to capture dump in case of a testhost hang and wait for it to exit - /// - /// - /// Process ID of test host - /// - /// - /// Path to TestResults directory - /// - /// - /// Is full dump enabled - /// - /// - /// The target framework of the process - /// - /// - /// Callback to datacollector logger to log warning - /// - void StartHangBasedProcessDump(int processId, string testResultsDirectory, bool isFullDump, string targetFramework, Action logWarning = null); + /// + /// Launch proc dump process to capture dump in case of a testhost hang and wait for it to exit + /// + /// + /// Process ID of test host + /// + /// + /// Path to TestResults directory + /// + /// + /// Is full dump enabled + /// + /// + /// The target framework of the process + /// + /// + /// Callback to datacollector logger to log warning + /// + void StartHangBasedProcessDump(int processId, string testResultsDirectory, bool isFullDump, string targetFramework, Action logWarning = null); - /// - /// Detaches the proc dump process from the target process - /// Ensure this is called before terminating the proc dump process - /// as it might lead to the testhost process crashing otherwise. - /// - /// - /// Process Id of the process to detach from - /// - void DetachFromTargetProcess(int targetProcessId); - } -} + /// + /// Detaches the proc dump process from the target process + /// Ensure this is called before terminating the proc dump process + /// as it might lead to the testhost process crashing otherwise. + /// + /// + /// Process Id of the process to detach from + /// + void DetachFromTargetProcess(int targetProcessId); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/NativeMethodsHelper.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/NativeMethodsHelper.cs index 90436921f2..034b4432bc 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/NativeMethodsHelper.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/NativeMethodsHelper.cs @@ -1,44 +1,44 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector -{ - using System; - using System.Runtime.InteropServices; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; +using System.Runtime.InteropServices; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; - public class NativeMethodsHelper : INativeMethodsHelper +public class NativeMethodsHelper : INativeMethodsHelper +{ + /// + /// Returns if a process is 64 bit process + /// + /// Process Handle + /// Bool for Is64Bit + public bool Is64Bit(IntPtr processHandle) { - /// - /// Returns if a process is 64 bit process - /// - /// Process Handle - /// Bool for Is64Bit - public bool Is64Bit(IntPtr processHandle) - { - // WOW64 is the x86 emulator that allows 32 bit Windows - based applications to run seamlessly on 64 bit Windows. + // WOW64 is the x86 emulator that allows 32 bit Windows - based applications to run seamlessly on 64 bit Windows. - // If the function succeeds, the return value is a nonzero value. - var isWow64Process = IsWow64Process(processHandle, out var isWow64); - if (!isWow64Process) + // If the function succeeds, the return value is a nonzero value. + var isWow64Process = IsWow64Process(processHandle, out var isWow64); + if (!isWow64Process) + { + if (EqtTrace.IsVerboseEnabled) { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("NativeMethodsHelper: The call to IsWow64Process failed."); - } + EqtTrace.Verbose("NativeMethodsHelper: The call to IsWow64Process failed."); } - - var is64Bit = !isWow64; - EqtTrace.Verbose($"NativeMethodsHelper: is Wow64Process: {isWow64Process} is 64bit: {is64Bit}."); - - return is64Bit; } - // A pointer to a value that is set to TRUE if the process is running under WOW64. - // If the process is running under 32-bit Windows, the value is set to FALSE. - // If the process is a 64-bit application running under 64-bit Windows, the value is also set to FALSE. - [DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool IsWow64Process([In] IntPtr process, [Out] out bool wow64Process); + var is64Bit = !isWow64; + EqtTrace.Verbose($"NativeMethodsHelper: is Wow64Process: {isWow64Process} is 64bit: {is64Bit}."); + + return is64Bit; } -} + + // A pointer to a value that is set to TRUE if the process is running under WOW64. + // If the process is running under 32-bit Windows, the value is set to FALSE. + // If the process is a 64-bit application running under 64-bit Windows, the value is also set to FALSE. + [DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool IsWow64Process([In] IntPtr process, [Out] out bool wow64Process); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/NetClientCrashDumper.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/NetClientCrashDumper.cs index 1952afe88e..af7c2c240c 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/NetClientCrashDumper.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/NetClientCrashDumper.cs @@ -1,44 +1,44 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; +using System.Collections.Generic; +using System.IO; + +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +internal class NetClientCrashDumper : ICrashDumper { - using System; - using System.Collections.Generic; - using System.IO; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + private string _outputDirectory; + private readonly IFileHelper _fileHelper; + + public NetClientCrashDumper(IFileHelper fileHelper) + { + _fileHelper = fileHelper; + } + + public void AttachToTargetProcess(int processId, string outputDirectory, DumpTypeOption dumpType, bool collectAlways) + { + // we don't need to do anything directly here, we setup the env variables + // in the dumper configuration, including the path + _outputDirectory = outputDirectory; + } + + public void DetachFromTargetProcess(int processId) + { + // here we might consider renaming the files to have timestamp + } + + public IEnumerable GetDumpFiles(bool processCrashed) + { + return _fileHelper.DirectoryExists(_outputDirectory) + ? _fileHelper.GetFiles(_outputDirectory, "*_crashdump*.dmp", SearchOption.AllDirectories) + : Array.Empty(); + } - internal class NetClientCrashDumper : ICrashDumper + public void WaitForDumpToFinish() { - private string outputDirectory; - private IFileHelper fileHelper; - - public NetClientCrashDumper(IFileHelper fileHelper) - { - this.fileHelper = fileHelper; - } - - public void AttachToTargetProcess(int processId, string outputDirectory, DumpTypeOption dumpType, bool collectAlways) - { - // we don't need to do anything directly here, we setup the env variables - // in the dumper configuration, including the path - this.outputDirectory = outputDirectory; - } - - public void DetachFromTargetProcess(int processId) - { - // here we might consider renaming the files to have timestamp - } - - public IEnumerable GetDumpFiles(bool processCrashed) - { - return this.fileHelper.DirectoryExists(this.outputDirectory) - ? this.fileHelper.GetFiles(this.outputDirectory, "*_crashdump*.dmp", SearchOption.AllDirectories) - : Array.Empty(); - } - - public void WaitForDumpToFinish() - { - } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/NetClientHangDumper.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/NetClientHangDumper.cs index 3d0d52d6a6..c776290eea 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/NetClientHangDumper.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/NetClientHangDumper.cs @@ -1,60 +1,62 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector -{ - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.IO; - using System.Linq; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.Diagnostics.NETCore.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities; +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +using Diagnostics.NETCore.Client; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities; - internal class NetClientHangDumper : IHangDumper +internal class NetClientHangDumper : IHangDumper +{ + public void Dump(int processId, string outputDirectory, DumpTypeOption type) { - public void Dump(int processId, string outputDirectory, DumpTypeOption type) - { - var process = Process.GetProcessById(processId); - var processTree = process.GetProcessTree(); + var process = Process.GetProcessById(processId); + var processTree = process.GetProcessTree(); - if (EqtTrace.IsVerboseEnabled) + if (EqtTrace.IsVerboseEnabled) + { + if (processTree.Count > 1) { - if (processTree.Count > 1) - { - EqtTrace.Verbose("NetClientHangDumper.Dump: Dumping this process tree (from bottom):"); - ConsoleOutput.Instance.Information(false, "Blame: Dumping this process tree (from bottom):"); + EqtTrace.Verbose("NetClientHangDumper.Dump: Dumping this process tree (from bottom):"); + ConsoleOutput.Instance.Information(false, "Blame: Dumping this process tree (from bottom):"); - foreach (var p in processTree.OrderBy(t => t.Level)) - { - EqtTrace.Verbose($"NetClientHangDumper.Dump: {(p.Level != 0 ? " + " : " > ")}{new string('-', p.Level)} {p.Process.Id} - {p.Process.ProcessName}"); - ConsoleOutput.Instance.Information(false, $"Blame: {(p.Level != 0 ? " + " : " > ")}{new string('-', p.Level)} {p.Process.Id} - {p.Process.ProcessName}"); - } - } - else + foreach (var p in processTree.OrderBy(t => t.Level)) { - EqtTrace.Verbose($"NetClientHangDumper.Dump: Dumping {process.Id} - {process.ProcessName}."); - ConsoleOutput.Instance.Information(false, $"Blame: Dumping {process.Id} - {process.ProcessName}"); + EqtTrace.Verbose($"NetClientHangDumper.Dump: {(p.Level != 0 ? " + " : " > ")}{new string('-', p.Level)} {p.Process.Id} - {p.Process.ProcessName}"); + ConsoleOutput.Instance.Information(false, $"Blame: {(p.Level != 0 ? " + " : " > ")}{new string('-', p.Level)} {p.Process.Id} - {p.Process.ProcessName}"); } } + else + { + EqtTrace.Verbose($"NetClientHangDumper.Dump: Dumping {process.Id} - {process.ProcessName}."); + ConsoleOutput.Instance.Information(false, $"Blame: Dumping {process.Id} - {process.ProcessName}"); + } + } - var bottomUpTree = processTree.OrderByDescending(t => t.Level).Select(t => t.Process); + var bottomUpTree = processTree.OrderByDescending(t => t.Level).Select(t => t.Process); - // Do not suspend processes with NetClient dumper it stops the diagnostic thread running in - // them and hang dump request will get stuck forever, because the process is not co-operating. - // Instead we start one task per dump asynchronously, and hope that the parent process will start dumping - // before the child process is done dumping. This way if the parent is waiting for the children to exit, - // we will be dumping it before it observes the child exiting and we get a more accurate results. If we did not - // do this, then parent that is awaiting child might exit before we get to dumping it. - var tasks = new List(); - var timeout = new CancellationTokenSource(); - timeout.CancelAfter(TimeSpan.FromMinutes(5)); - foreach (var p in bottomUpTree) - { - tasks.Add(Task.Run( + // Do not suspend processes with NetClient dumper it stops the diagnostic thread running in + // them and hang dump request will get stuck forever, because the process is not co-operating. + // Instead we start one task per dump asynchronously, and hope that the parent process will start dumping + // before the child process is done dumping. This way if the parent is waiting for the children to exit, + // we will be dumping it before it observes the child exiting and we get a more accurate results. If we did not + // do this, then parent that is awaiting child might exit before we get to dumping it. + var tasks = new List(); + var timeout = new CancellationTokenSource(); + timeout.CancelAfter(TimeSpan.FromMinutes(5)); + foreach (var p in bottomUpTree) + { + tasks.Add(Task.Run( () => { try @@ -73,29 +75,28 @@ public void Dump(int processId, string outputDirectory, DumpTypeOption type) EqtTrace.Error($"NetClientHangDumper.Dump: Error dumping process {p.Id} - {p.ProcessName}: {ex}."); } }, timeout.Token)); - } + } + + try + { + Task.WhenAll(tasks).GetAwaiter().GetResult(); + } + catch (TaskCanceledException) + { + EqtTrace.Error($"NetClientHangDumper.Dump: Hang dump timed out."); + } + foreach (var p in bottomUpTree) + { try { - Task.WhenAll(tasks).GetAwaiter().GetResult(); + EqtTrace.Verbose($"NetClientHangDumper.Dump: Killing process {p.Id} - {p.ProcessName}."); + p.Kill(); } - catch (TaskCanceledException) + catch (Exception ex) { - EqtTrace.Error($"NetClientHangDumper.Dump: Hang dump timed out."); - } - - foreach (var p in bottomUpTree) - { - try - { - EqtTrace.Verbose($"NetClientHangDumper.Dump: Killing process {p.Id} - {p.ProcessName}."); - p.Kill(); - } - catch (Exception ex) - { - EqtTrace.Error($"NetClientHangDumper.Dump: Error killing process {p.Id} - {p.ProcessName}: {ex}."); - } + EqtTrace.Error($"NetClientHangDumper.Dump: Error killing process {p.Id} - {p.ProcessName}: {ex}."); } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpArgsBuilder.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpArgsBuilder.cs index 5ab8cc57d3..ba7dd97400 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpArgsBuilder.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpArgsBuilder.cs @@ -1,72 +1,71 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector -{ - using System; - using System.Collections.Generic; - using System.Text; - - public class ProcDumpArgsBuilder : IProcDumpArgsBuilder - { - /// - public string BuildTriggerBasedProcDumpArgs(int processId, string filename, IEnumerable procDumpExceptionsList, bool isFullDump) - { - // -accepteula: Auto accept end-user license agreement - // - // -e: Write a dump when the process encounters an unhandled exception. Include the 1 to create dump on first chance exceptions. - // We use -e 1 to make sure we are able to catch StackOverflow and AccessViolationException exceptions. - // -g: Run as a native debugger in a managed process (no interop). - // We use -g to be able to intercept StackOverflow and AccessViolationException. - // -t: Write a dump when the process terminates. - // Collect the dump all the time, even if CollectAlways is not enabled to produce dumps for Environment.FailFast. We will later ignore the last - // dump file for testhost when we know that test host did not crash. - // -ma: Full dump argument. - // -f: Filter the exceptions. - // Filter the first chance exceptions only to those that are most likely to kill the whole process. +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; - // Fully override parameters to procdump - var procdumpArgumentsFromEnv = Environment.GetEnvironmentVariable("VSTEST_DUMP_PROCDUMPARGUMENTS")?.Trim(); +using System; +using System.Collections.Generic; +using System.Text; - // Useful additional arguments are -n 100, to collect all dumps that you can, or -o to overwrite dump, or -f EXCEPTION_NAME to add exception to filter list - var procdumpAdditonalArgumentsFromEnv = Environment.GetEnvironmentVariable("VSTEST_DUMP_PROCDUMPADDITIONALARGUMENTS")?.Trim(); - StringBuilder procDumpArgument = new StringBuilder($"-accepteula -e 1 -g -t {procdumpAdditonalArgumentsFromEnv}"); - if (isFullDump) - { - procDumpArgument.Append("-ma "); - } +public class ProcDumpArgsBuilder : IProcDumpArgsBuilder +{ + /// + public string BuildTriggerBasedProcDumpArgs(int processId, string filename, IEnumerable procDumpExceptionsList, bool isFullDump) + { + // -accepteula: Auto accept end-user license agreement + // + // -e: Write a dump when the process encounters an unhandled exception. Include the 1 to create dump on first chance exceptions. + // We use -e 1 to make sure we are able to catch StackOverflow and AccessViolationException exceptions. + // -g: Run as a native debugger in a managed process (no interop). + // We use -g to be able to intercept StackOverflow and AccessViolationException. + // -t: Write a dump when the process terminates. + // Collect the dump all the time, even if CollectAlways is not enabled to produce dumps for Environment.FailFast. We will later ignore the last + // dump file for testhost when we know that test host did not crash. + // -ma: Full dump argument. + // -f: Filter the exceptions. + // Filter the first chance exceptions only to those that are most likely to kill the whole process. - foreach (var exceptionFilter in procDumpExceptionsList) - { - procDumpArgument.Append($"-f {exceptionFilter} "); - } + // Fully override parameters to procdump + var procdumpArgumentsFromEnv = Environment.GetEnvironmentVariable("VSTEST_DUMP_PROCDUMPARGUMENTS")?.Trim(); - procDumpArgument.Append($"{processId} {filename}.dmp"); - var argument = string.IsNullOrWhiteSpace(procdumpArgumentsFromEnv) ? procDumpArgument.ToString() : procdumpArgumentsFromEnv; - if (!argument.ToUpperInvariant().Contains("-accepteula".ToUpperInvariant())) - { - argument = $"-accepteula {argument}"; - } + // Useful additional arguments are -n 100, to collect all dumps that you can, or -o to overwrite dump, or -f EXCEPTION_NAME to add exception to filter list + var procdumpAdditonalArgumentsFromEnv = Environment.GetEnvironmentVariable("VSTEST_DUMP_PROCDUMPADDITIONALARGUMENTS")?.Trim(); + StringBuilder procDumpArgument = new($"-accepteula -e 1 -g -t {procdumpAdditonalArgumentsFromEnv}"); + if (isFullDump) + { + procDumpArgument.Append("-ma "); + } - return argument; + foreach (var exceptionFilter in procDumpExceptionsList) + { + procDumpArgument.Append($"-f {exceptionFilter} "); } - /// - public string BuildHangBasedProcDumpArgs(int processId, string filename, bool isFullDump) + procDumpArgument.Append($"{processId} {filename}.dmp"); + var argument = string.IsNullOrWhiteSpace(procdumpArgumentsFromEnv) ? procDumpArgument.ToString() : procdumpArgumentsFromEnv; + if (!argument.ToUpperInvariant().Contains("-accepteula".ToUpperInvariant())) { - // -accepteula: Auto accept end-user license agreement - // -ma: Full dump argument. - // -n: Number of dumps to capture. - StringBuilder procDumpArgument = new StringBuilder("-accepteula -n 1"); - if (isFullDump) - { - procDumpArgument.Append(" -ma"); - } + argument = $"-accepteula {argument}"; + } - procDumpArgument.Append($" {processId} {filename}.dmp"); - var argument = procDumpArgument.ToString(); + return argument; + } - return argument; + /// + public string BuildHangBasedProcDumpArgs(int processId, string filename, bool isFullDump) + { + // -accepteula: Auto accept end-user license agreement + // -ma: Full dump argument. + // -n: Number of dumps to capture. + StringBuilder procDumpArgument = new("-accepteula -n 1"); + if (isFullDump) + { + procDumpArgument.Append(" -ma"); } + + procDumpArgument.Append($" {processId} {filename}.dmp"); + var argument = procDumpArgument.ToString(); + + return argument; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs index 14d362d5c0..3924c38751 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs @@ -1,335 +1,328 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +public class ProcDumpDumper : ICrashDumper, IHangDumper { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.IO; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - - public class ProcDumpDumper : ICrashDumper, IHangDumper + private static readonly IEnumerable ProcDumpExceptionsList = new List() { - private static readonly IEnumerable ProcDumpExceptionsList = new List() - { - "STACK_OVERFLOW", - "ACCESS_VIOLATION" - }; - - private IProcessHelper processHelper; - private IFileHelper fileHelper; - private IEnvironment environment; - private Process procDumpProcess; - private string tempDirectory; - private string dumpFileName; - private INativeMethodsHelper nativeMethodsHelper; - private bool collectAlways; - private string outputDirectory; - private Process process; - private string outputFilePrefix; - - public ProcDumpDumper() - : this(new ProcessHelper(), new FileHelper(), new PlatformEnvironment(), new NativeMethodsHelper()) + "STACK_OVERFLOW", + "ACCESS_VIOLATION" + }; + + private readonly IProcessHelper _processHelper; + private readonly IFileHelper _fileHelper; + private readonly IEnvironment _environment; + private Process _procDumpProcess; + private string _tempDirectory; + private string _dumpFileName; + private readonly INativeMethodsHelper _nativeMethodsHelper; + private bool _collectAlways; + private string _outputDirectory; + private Process _process; + private string _outputFilePrefix; + + public ProcDumpDumper() + : this(new ProcessHelper(), new FileHelper(), new PlatformEnvironment(), new NativeMethodsHelper()) + { + } + + public ProcDumpDumper(IProcessHelper processHelper, IFileHelper fileHelper, IEnvironment environment, INativeMethodsHelper nativeMethodsHelper) + { + _processHelper = processHelper; + _fileHelper = fileHelper; + _environment = environment; + _nativeMethodsHelper = nativeMethodsHelper; + } + + protected Action OutputReceivedCallback => (process, data) => + { + // useful for visibility when debugging this tool + // Console.ForegroundColor = ConsoleColor.Cyan; + // Console.WriteLine(data); + // Console.ForegroundColor = ConsoleColor.White; + // Log all standard output message of procdump in diag files. + // Otherwise they end up coming on console in pipleine. + if (EqtTrace.IsInfoEnabled) { + EqtTrace.Info("ProcDumpDumper.OutputReceivedCallback: Output received from procdump process: " + data); } + }; - public ProcDumpDumper(IProcessHelper processHelper, IFileHelper fileHelper, IEnvironment environment, INativeMethodsHelper nativeMethodsHelper) + /// + public void WaitForDumpToFinish() + { + if (_processHelper == null) { - this.processHelper = processHelper; - this.fileHelper = fileHelper; - this.environment = environment; - this.nativeMethodsHelper = nativeMethodsHelper; + EqtTrace.Info($"ProcDumpDumper.WaitForDumpToFinish: ProcDump was not previously attached, this might indicate error during setup, look for ProcDumpDumper.AttachToTargetProcess."); } - protected Action OutputReceivedCallback => (process, data) => - { - // useful for visibility when debugging this tool - // Console.ForegroundColor = ConsoleColor.Cyan; - // Console.WriteLine(data); - // Console.ForegroundColor = ConsoleColor.White; - // Log all standard output message of procdump in diag files. - // Otherwise they end up coming on console in pipleine. - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("ProcDumpDumper.OutputReceivedCallback: Output received from procdump process: " + data); - } - }; + _processHelper?.WaitForProcessExit(_procDumpProcess); + } - /// - public void WaitForDumpToFinish() + /// + public void AttachToTargetProcess(int processId, string outputDirectory, DumpTypeOption dumpType, bool collectAlways) + { + _collectAlways = collectAlways; + _outputDirectory = outputDirectory; + _process = Process.GetProcessById(processId); + _outputFilePrefix = $"{_process.ProcessName}_{_process.Id}_{DateTime.Now:yyyyMMddTHHmmss}_crashdump"; + var outputFile = Path.Combine(outputDirectory, $"{_outputFilePrefix}.dmp"); + EqtTrace.Info($"ProcDumpDumper.AttachToTargetProcess: Attaching to process '{processId}' to dump into '{outputFile}'."); + + // Procdump will append .dmp at the end of the dump file. We generate this internally so it is rather a safety check. + if (!outputFile.EndsWith(".dmp", StringComparison.OrdinalIgnoreCase)) { - if (this.processHelper == null) - { - EqtTrace.Info($"ProcDumpDumper.WaitForDumpToFinish: ProcDump was not previously attached, this might indicate error during setup, look for ProcDumpDumper.AttachToTargetProcess."); - } - - this.processHelper?.WaitForProcessExit(this.procDumpProcess); + throw new InvalidOperationException("Procdump crash dump file must end with .dmp extension."); } - /// - public void AttachToTargetProcess(int processId, string outputDirectory, DumpTypeOption dumpType, bool collectAlways) + if (!TryGetProcDumpExecutable(processId, out var procDumpPath)) { - this.collectAlways = collectAlways; - this.outputDirectory = outputDirectory; - this.process = Process.GetProcessById(processId); - this.outputFilePrefix = $"{this.process.ProcessName}_{this.process.Id}_{DateTime.Now:yyyyMMddTHHmmss}_crashdump"; - var outputFile = Path.Combine(outputDirectory, $"{this.outputFilePrefix}.dmp"); - EqtTrace.Info($"ProcDumpDumper.AttachToTargetProcess: Attaching to process '{processId}' to dump into '{outputFile}'."); - - // Procdump will append .dmp at the end of the dump file. We generate this internally so it is rather a safety check. - if (!outputFile.EndsWith(".dmp", StringComparison.OrdinalIgnoreCase)) - { - throw new InvalidOperationException("Procdump crash dump file must end with .dmp extension."); - } + var err = $"{procDumpPath} could not be found, please set PROCDUMP_PATH environment variable to a directory that contains {procDumpPath} executable, or make sure that the executable is available on PATH."; + ConsoleOutput.Instance.Warning(false, err); + EqtTrace.Error($"ProcDumpDumper.AttachToTargetProcess: {err}"); + return; + } - if (!this.TryGetProcDumpExecutable(processId, out var procDumpPath)) - { - var err = $"{procDumpPath} could not be found, please set PROCDUMP_PATH environment variable to a directory that contains {procDumpPath} executable, or make sure that the executable is available on PATH."; - ConsoleOutput.Instance.Warning(false, err); - EqtTrace.Error($"ProcDumpDumper.AttachToTargetProcess: {err}"); - return; - } + _tempDirectory = Path.GetDirectoryName(outputFile); + _dumpFileName = Path.GetFileNameWithoutExtension(outputFile); + + string procDumpArgs = new ProcDumpArgsBuilder().BuildTriggerBasedProcDumpArgs( + processId, + _dumpFileName, + ProcDumpExceptionsList, + isFullDump: dumpType == DumpTypeOption.Full); + + EqtTrace.Info($"ProcDumpDumper.AttachToTargetProcess: Running ProcDump with arguments: '{procDumpArgs}'."); + _procDumpProcess = _processHelper.LaunchProcess( + procDumpPath, + procDumpArgs, + _tempDirectory, + null, + null, + null, + OutputReceivedCallback) as Process; + + EqtTrace.Info($"ProcDumpDumper.AttachToTargetProcess: ProcDump started as process with id '{_procDumpProcess.Id}'."); + } - this.tempDirectory = Path.GetDirectoryName(outputFile); - this.dumpFileName = Path.GetFileNameWithoutExtension(outputFile); - - string procDumpArgs = new ProcDumpArgsBuilder().BuildTriggerBasedProcDumpArgs( - processId, - this.dumpFileName, - ProcDumpExceptionsList, - isFullDump: dumpType == DumpTypeOption.Full); - - EqtTrace.Info($"ProcDumpDumper.AttachToTargetProcess: Running ProcDump with arguments: '{procDumpArgs}'."); - this.procDumpProcess = this.processHelper.LaunchProcess( - procDumpPath, - procDumpArgs, - this.tempDirectory, - null, - null, - null, - this.OutputReceivedCallback) as Process; - - EqtTrace.Info($"ProcDumpDumper.AttachToTargetProcess: ProcDump started as process with id '{this.procDumpProcess.Id}'."); + /// + public void DetachFromTargetProcess(int targetProcessId) + { + if (_procDumpProcess == null) + { + EqtTrace.Info($"ProcDumpDumper.DetachFromTargetProcess: ProcDump was not previously attached, this might indicate error during setup, look for ProcDumpDumper.AttachToTargetProcess."); + return; } - /// - public void DetachFromTargetProcess(int targetProcessId) + try + { + EqtTrace.Info($"ProcDumpDumper.DetachFromTargetProcess: ProcDump detaching from target process '{targetProcessId}'."); + new Win32NamedEvent($"Procdump-{targetProcessId}").Set(); + } + finally { - if (this.procDumpProcess == null) - { - EqtTrace.Info($"ProcDumpDumper.DetachFromTargetProcess: ProcDump was not previously attached, this might indicate error during setup, look for ProcDumpDumper.AttachToTargetProcess."); - return; - } - try { - EqtTrace.Info($"ProcDumpDumper.DetachFromTargetProcess: ProcDump detaching from target process '{targetProcessId}'."); - new Win32NamedEvent($"Procdump-{targetProcessId}").Set(); + EqtTrace.Info("ProcDumpDumper.DetachFromTargetProcess: Attempting to kill proc dump process."); + _processHelper.TerminateProcess(_procDumpProcess); } - finally + catch (Exception e) { - try - { - EqtTrace.Info("ProcDumpDumper.DetachFromTargetProcess: Attempting to kill proc dump process."); - this.processHelper.TerminateProcess(this.procDumpProcess); - } - catch (Exception e) - { - EqtTrace.Warning($"ProcDumpDumper.DetachFromTargetProcess: Failed to kill proc dump process with exception {e}"); - } + EqtTrace.Warning($"ProcDumpDumper.DetachFromTargetProcess: Failed to kill proc dump process with exception {e}"); } } + } - public IEnumerable GetDumpFiles(bool processCrashed) + public IEnumerable GetDumpFiles(bool processCrashed) + { + var allDumps = _fileHelper.DirectoryExists(_outputDirectory) + ? _fileHelper.GetFiles(_outputDirectory, "*_crashdump*.dmp", SearchOption.AllDirectories) + : Array.Empty(); + + // We are always collecting dump on exit even when collectAlways option is false, to make sure we collect + // dump for Environment.FailFast. So there always can be a dump if the process already exited. In most cases + // this was just a normal process exit that was not caused by an exception and user is not interested in getting that + // dump because it only pollutes their CI. + // The hangdumps and crash dumps actually end up in the same folder, but we can distinguish them based on the _crashdump suffix. + if (_collectAlways) { - var allDumps = this.fileHelper.DirectoryExists(this.outputDirectory) - ? this.fileHelper.GetFiles(this.outputDirectory, "*_crashdump*.dmp", SearchOption.AllDirectories) - : Array.Empty(); - - // We are always collecting dump on exit even when collectAlways option is false, to make sure we collect - // dump for Environment.FailFast. So there always can be a dump if the process already exited. In most cases - // this was just a normal process exit that was not caused by an exception and user is not interested in getting that - // dump because it only pollutes their CI. - // The hangdumps and crash dumps actually end up in the same folder, but we can distinguish them based on the _crashdump suffix. - if (this.collectAlways) - { - return allDumps; - } + return allDumps; + } - if (processCrashed) - { - return allDumps; - } + if (processCrashed) + { + return allDumps; + } - // There can be more dumps in the crash folder from the child processes that were .NET5 or newer and crashed - // get only the ones that match the path we provide to procdump. And get the last one created. - var allTargetProcessDumps = allDumps - .Where(dump => Path.GetFileNameWithoutExtension(dump) - .StartsWith(this.outputFilePrefix)) - .Select(dump => new FileInfo(dump)) - .OrderBy(dump => dump.LastWriteTime).ThenBy(dump => dump.Name) - .ToList(); + // There can be more dumps in the crash folder from the child processes that were .NET5 or newer and crashed + // get only the ones that match the path we provide to procdump. And get the last one created. + var allTargetProcessDumps = allDumps + .Where(dump => Path.GetFileNameWithoutExtension(dump) + .StartsWith(_outputFilePrefix)) + .Select(dump => new FileInfo(dump)) + .OrderBy(dump => dump.LastWriteTime).ThenBy(dump => dump.Name) + .ToList(); - var dumpToRemove = allTargetProcessDumps.LastOrDefault(); + var dumpToRemove = allTargetProcessDumps.LastOrDefault(); - if (dumpToRemove != null) + if (dumpToRemove != null) + { + EqtTrace.Verbose($"ProcDumpDumper.GetDumpFiles: Found {allTargetProcessDumps.Count} dumps for the target process, removing {dumpToRemove.Name} because we always collect a dump, even if there is no crash. But the process did not crash and user did not specify CollectAlways=true."); + try { - EqtTrace.Verbose($"ProcDumpDumper.GetDumpFiles: Found {allTargetProcessDumps.Count} dumps for the target process, removing {dumpToRemove.Name} because we always collect a dump, even if there is no crash. But the process did not crash and user did not specify CollectAlways=true."); - try - { - File.Delete(dumpToRemove.FullName); - } - catch (Exception ex) - { - EqtTrace.Error($"ProcDumpDumper.GetDumpFiles: Removing dump failed with: {ex}"); - EqtTrace.Error(ex); - } + File.Delete(dumpToRemove.FullName); + } + catch (Exception ex) + { + EqtTrace.Error($"ProcDumpDumper.GetDumpFiles: Removing dump failed with: {ex}"); + EqtTrace.Error(ex); } - - return allTargetProcessDumps.Take(allTargetProcessDumps.Count - 1).Select(dump => dump.FullName).ToList(); } - // Hang dumps the process using procdump. - public void Dump(int processId, string outputDirectory, DumpTypeOption dumpType) + return allTargetProcessDumps.Take(allTargetProcessDumps.Count - 1).Select(dump => dump.FullName).ToList(); + } + + // Hang dumps the process using procdump. + public void Dump(int processId, string outputDirectory, DumpTypeOption dumpType) + { + var process = Process.GetProcessById(processId); + var outputFile = Path.Combine(outputDirectory, $"{process.ProcessName}_{processId}_{DateTime.Now:yyyyMMddTHHmmss}_hangdump.dmp"); + EqtTrace.Info($"ProcDumpDumper.Dump: Hang dumping process '{processId}' to dump into '{outputFile}'."); + + // Procdump will append .dmp at the end of the dump file. We generate this internally so it is rather a safety check. + if (!outputFile.EndsWith(".dmp", StringComparison.OrdinalIgnoreCase)) { - var process = Process.GetProcessById(processId); - var outputFile = Path.Combine(outputDirectory, $"{process.ProcessName}_{processId}_{DateTime.Now:yyyyMMddTHHmmss}_hangdump.dmp"); - EqtTrace.Info($"ProcDumpDumper.Dump: Hang dumping process '{processId}' to dump into '{outputFile}'."); + throw new InvalidOperationException("Procdump crash dump file must end with .dmp extension."); + } - // Procdump will append .dmp at the end of the dump file. We generate this internally so it is rather a safety check. - if (!outputFile.EndsWith(".dmp", StringComparison.OrdinalIgnoreCase)) - { - throw new InvalidOperationException("Procdump crash dump file must end with .dmp extension."); - } + if (!TryGetProcDumpExecutable(processId, out var procDumpPath)) + { + var err = $"{procDumpPath} could not be found, please set PROCDUMP_PATH environment variable to a directory that contains {procDumpPath} executable, or make sure that the executable is available on PATH."; + ConsoleOutput.Instance.Warning(false, err); + EqtTrace.Error($"ProcDumpDumper.Dump: {err}"); + return; + } - if (!this.TryGetProcDumpExecutable(processId, out var procDumpPath)) - { - var err = $"{procDumpPath} could not be found, please set PROCDUMP_PATH environment variable to a directory that contains {procDumpPath} executable, or make sure that the executable is available on PATH."; - ConsoleOutput.Instance.Warning(false, err); - EqtTrace.Error($"ProcDumpDumper.Dump: {err}"); - return; - } + var tempDirectory = Path.GetDirectoryName(outputFile); + var dumpFileName = Path.GetFileNameWithoutExtension(outputFile); - var tempDirectory = Path.GetDirectoryName(outputFile); - var dumpFileName = Path.GetFileNameWithoutExtension(outputFile); + string procDumpArgs = new ProcDumpArgsBuilder().BuildHangBasedProcDumpArgs( + processId, + dumpFileName, + isFullDump: dumpType == DumpTypeOption.Full); - string procDumpArgs = new ProcDumpArgsBuilder().BuildHangBasedProcDumpArgs( - processId, - dumpFileName, - isFullDump: dumpType == DumpTypeOption.Full); + EqtTrace.Info($"ProcDumpDumper.Dump: Running ProcDump with arguments: '{procDumpArgs}'."); + var procDumpProcess = _processHelper.LaunchProcess( + procDumpPath, + procDumpArgs, + tempDirectory, + null, + null, + null, + OutputReceivedCallback) as Process; - EqtTrace.Info($"ProcDumpDumper.Dump: Running ProcDump with arguments: '{procDumpArgs}'."); - var procDumpProcess = this.processHelper.LaunchProcess( - procDumpPath, - procDumpArgs, - tempDirectory, - null, - null, - null, - this.OutputReceivedCallback) as Process; + EqtTrace.Info($"ProcDumpDumper.Dump: ProcDump started as process with id '{procDumpProcess.Id}'."); - EqtTrace.Info($"ProcDumpDumper.Dump: ProcDump started as process with id '{procDumpProcess.Id}'."); + _processHelper?.WaitForProcessExit(procDumpProcess); - this.processHelper?.WaitForProcessExit(procDumpProcess); + EqtTrace.Info($"ProcDumpDumper.Dump: ProcDump finished hang dumping process with id '{processId}'."); + } - EqtTrace.Info($"ProcDumpDumper.Dump: ProcDump finished hang dumping process with id '{processId}'."); + /// + /// Try get proc dump executable path from env variable or PATH, if it does not success the result is false, and the name of the exe we tried to find. + /// + /// + /// Process Id to determine the bittness + /// + /// + /// Path to procdump or the name of the executable we tried to resolve when we don't find it + /// + /// proc dump executable path + private bool TryGetProcDumpExecutable(int processId, out string path) + { + var procdumpDirectory = Environment.GetEnvironmentVariable("PROCDUMP_PATH"); + var searchPath = false; + if (string.IsNullOrWhiteSpace(procdumpDirectory)) + { + EqtTrace.Verbose("ProcDumpDumper.GetProcDumpExecutable: PROCDUMP_PATH env variable is empty will try to run ProcDump from PATH."); + searchPath = true; } - - /// - /// Try get proc dump executable path from env variable or PATH, if it does not success the result is false, and the name of the exe we tried to find. - /// - /// - /// Process Id to determine the bittness - /// - /// - /// Path to procdump or the name of the executable we tried to resolve when we don't find it - /// - /// proc dump executable path - private bool TryGetProcDumpExecutable(int processId, out string path) + else if (!Directory.Exists(procdumpDirectory)) { - var procdumpDirectory = Environment.GetEnvironmentVariable("PROCDUMP_PATH"); - var searchPath = false; - if (string.IsNullOrWhiteSpace(procdumpDirectory)) - { - EqtTrace.Verbose("ProcDumpDumper.GetProcDumpExecutable: PROCDUMP_PATH env variable is empty will try to run ProcDump from PATH."); - searchPath = true; - } - else if (!Directory.Exists(procdumpDirectory)) - { - EqtTrace.Verbose($"ProcDumpDumper.GetProcDumpExecutable: PROCDUMP_PATH env variable '{procdumpDirectory}' is not a directory, or the directory does not exist. Will try to run ProcDump from PATH."); - searchPath = true; - } + EqtTrace.Verbose($"ProcDumpDumper.GetProcDumpExecutable: PROCDUMP_PATH env variable '{procdumpDirectory}' is not a directory, or the directory does not exist. Will try to run ProcDump from PATH."); + searchPath = true; + } - string filename; - if (this.environment.OperatingSystem == PlatformOperatingSystem.Windows) - { - // Launch proc dump according to process architecture - if (this.environment.Architecture == PlatformArchitecture.X86) - { - filename = Constants.ProcdumpProcess; - } - else - { - filename = this.nativeMethodsHelper.Is64Bit(this.processHelper.GetProcessHandle(processId)) ? + string filename; + if (_environment.OperatingSystem == PlatformOperatingSystem.Windows) + { + // Launch proc dump according to process architecture + filename = _environment.Architecture == PlatformArchitecture.X86 + ? Constants.ProcdumpProcess + : _nativeMethodsHelper.Is64Bit(_processHelper.GetProcessHandle(processId)) ? Constants.Procdump64Process : Constants.ProcdumpProcess; - } - } - else if (this.environment.OperatingSystem == PlatformOperatingSystem.Unix || this.environment.OperatingSystem == PlatformOperatingSystem.OSX) - { - filename = Constants.ProcdumpUnixProcess; - } - else - { - throw new NotSupportedException($"Not supported platform {this.environment.OperatingSystem}"); - } - - if (!searchPath) - { - var candidatePath = Path.Combine(procdumpDirectory, filename); - if (File.Exists(candidatePath)) - { - EqtTrace.Verbose($"ProcDumpDumper.GetProcDumpExecutable: Path to ProcDump '{candidatePath}' exists, using that."); - path = candidatePath; - return true; - } - - EqtTrace.Verbose($"ProcDumpDumper.GetProcDumpExecutable: Path '{candidatePath}' does not exist will try to run {filename} from PATH."); - } + } + else + { + filename = _environment.OperatingSystem == PlatformOperatingSystem.Unix || _environment.OperatingSystem == PlatformOperatingSystem.OSX + ? Constants.ProcdumpUnixProcess + : throw new NotSupportedException($"Not supported platform {_environment.OperatingSystem}"); + } - if (this.TryGetExecutablePath(filename, out var p)) + if (!searchPath) + { + var candidatePath = Path.Combine(procdumpDirectory, filename); + if (File.Exists(candidatePath)) { - EqtTrace.Verbose($"ProcDumpDumper.GetProcDumpExecutable: Resolved {filename} to {p} from PATH."); - path = p; + EqtTrace.Verbose($"ProcDumpDumper.GetProcDumpExecutable: Path to ProcDump '{candidatePath}' exists, using that."); + path = candidatePath; return true; } - EqtTrace.Verbose($"ProcDumpDumper.GetProcDumpExecutable: Could not find {filename} on PATH."); - path = filename; - return false; + EqtTrace.Verbose($"ProcDumpDumper.GetProcDumpExecutable: Path '{candidatePath}' does not exist will try to run {filename} from PATH."); } - private bool TryGetExecutablePath(string executable, out string executablePath) + if (TryGetExecutablePath(filename, out var p)) + { + EqtTrace.Verbose($"ProcDumpDumper.GetProcDumpExecutable: Resolved {filename} to {p} from PATH."); + path = p; + return true; + } + + EqtTrace.Verbose($"ProcDumpDumper.GetProcDumpExecutable: Could not find {filename} on PATH."); + path = filename; + return false; + } + + private bool TryGetExecutablePath(string executable, out string executablePath) + { + executablePath = string.Empty; + var pathString = Environment.GetEnvironmentVariable("PATH"); + foreach (string path in pathString.Split(Path.PathSeparator)) { - executablePath = string.Empty; - var pathString = Environment.GetEnvironmentVariable("PATH"); - foreach (string path in pathString.Split(Path.PathSeparator)) + string exeFullPath = Path.Combine(path.Trim(), executable); + if (_fileHelper.Exists(exeFullPath)) { - string exeFullPath = Path.Combine(path.Trim(), executable); - if (this.fileHelper.Exists(exeFullPath)) - { - executablePath = exeFullPath; - return true; - } + executablePath = exeFullPath; + return true; } - - return false; } + + return false; } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessCodeMethods.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessCodeMethods.cs index d1c7340265..ec7fb22901 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessCodeMethods.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessCodeMethods.cs @@ -1,265 +1,252 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; + +/// +/// Helper functions for process info. +/// +internal static class ProcessCodeMethods { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.IO; - using System.Linq; - using System.Runtime.InteropServices; - using System.Text; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + private const int InvalidProcessId = -1; - /// - /// Helper functions for process info. - /// - internal static class ProcessCodeMethods + public static void Suspend(this Process process) { - private const int InvalidProcessId = -1; - - public static void Suspend(this Process process) + if (process.HasExited) { - if (process.HasExited) - { - EqtTrace.Verbose($"ProcessCodeMethods.Suspend: Process {process.Id} - {process.ProcessName} already exited, skipping."); - return; - } - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - SuspendWindows(process); - } - else - { - // TODO: do not suspend on Mac and Linux, this prevents the process from being dumped when we use the net client dumper, checking if we can post a different signal - // SuspendLinuxMacOs(process); - } + EqtTrace.Verbose($"ProcessCodeMethods.Suspend: Process {process.Id} - {process.ProcessName} already exited, skipping."); + return; } - public static List GetProcessTree(this Process process) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - var childProcesses = Process.GetProcesses() - .Where(p => IsChildCandidate(p, process)) - .ToList(); - - var acc = new List(); - foreach (var c in childProcesses) - { - try - { - var parentId = GetParentPid(c); - - // c.ParentId = parentId; - acc.Add(new ProcessTreeNode { ParentId = parentId, Process = c }); - } - catch - { - // many things can go wrong with this - // just ignore errors - } - } - - var level = 1; - var limit = 10; - ResolveChildren(process, acc, level, limit); - - return new List { new ProcessTreeNode { Process = process, Level = 0 } }.Concat(acc.Where(a => a.Level > 0)).ToList(); + SuspendWindows(process); } - - internal static void SuspendWindows(Process process) + else { - EqtTrace.Verbose($"ProcessCodeMethods.Suspend: Suspending process {process.Id} - {process.ProcessName}."); - NtSuspendProcess(process.Handle); + // TODO: do not suspend on Mac and Linux, this prevents the process from being dumped when we use the net client dumper, checking if we can post a different signal + // SuspendLinuxMacOs(process); } + } + + public static List GetProcessTree(this Process process) + { + var childProcesses = Process.GetProcesses() + .Where(p => IsChildCandidate(p, process)) + .ToList(); - internal static void SuspendLinuxMacOs(Process process) + var acc = new List(); + foreach (var c in childProcesses) { try { - var output = new StringBuilder(); - var err = new StringBuilder(); - Process ps = new Process(); - ps.StartInfo.FileName = "kill"; - ps.StartInfo.Arguments = $"-STOP {process.Id}"; - ps.StartInfo.UseShellExecute = false; - ps.StartInfo.RedirectStandardOutput = true; - ps.OutputDataReceived += (_, e) => output.Append(e.Data); - ps.ErrorDataReceived += (_, e) => err.Append(e.Data); - ps.Start(); - ps.BeginOutputReadLine(); - ps.WaitForExit(5_000); - - if (!string.IsNullOrWhiteSpace(err.ToString())) - { - EqtTrace.Verbose($"ProcessCodeMethods.SuspendLinuxMacOs: Error suspending process {process.Id} - {process.ProcessName}, {err}."); - } + var parentId = GetParentPid(c); + + // c.ParentId = parentId; + acc.Add(new ProcessTreeNode { ParentId = parentId, Process = c }); } - catch (Exception ex) + catch { - EqtTrace.Verbose($"ProcessCodeMethods.GetParentPidMacOs: Error getting parent of process {process.Id} - {process.ProcessName}, {ex}."); + // many things can go wrong with this + // just ignore errors } } - /// - /// Returns the parent id of a process or -1 if it fails. - /// - /// The process to find parent of. - /// The pid of the parent process. - internal static int GetParentPid(Process process) + var level = 1; + var limit = 10; + ResolveChildren(process, acc, level, limit); + + return new List { new ProcessTreeNode { Process = process, Level = 0 } }.Concat(acc.Where(a => a.Level > 0)).ToList(); + } + + internal static void SuspendWindows(Process process) + { + EqtTrace.Verbose($"ProcessCodeMethods.Suspend: Suspending process {process.Id} - {process.ProcessName}."); + NtSuspendProcess(process.Handle); + } + + internal static void SuspendLinuxMacOs(Process process) + { + try + { + var output = new StringBuilder(); + var err = new StringBuilder(); + Process ps = new(); + ps.StartInfo.FileName = "kill"; + ps.StartInfo.Arguments = $"-STOP {process.Id}"; + ps.StartInfo.UseShellExecute = false; + ps.StartInfo.RedirectStandardOutput = true; + ps.OutputDataReceived += (_, e) => output.Append(e.Data); + ps.ErrorDataReceived += (_, e) => err.Append(e.Data); + ps.Start(); + ps.BeginOutputReadLine(); + ps.WaitForExit(5_000); + + if (!string.IsNullOrWhiteSpace(err.ToString())) + { + EqtTrace.Verbose($"ProcessCodeMethods.SuspendLinuxMacOs: Error suspending process {process.Id} - {process.ProcessName}, {err}."); + } + } + catch (Exception ex) { - return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? GetParentPidWindows(process) - : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) - ? GetParentPidLinux(process) - : RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? - GetParentPidMacOs(process) - : throw new PlatformNotSupportedException(); + EqtTrace.Verbose($"ProcessCodeMethods.GetParentPidMacOs: Error getting parent of process {process.Id} - {process.ProcessName}, {ex}."); } + } - internal static int GetParentPidWindows(Process process) + /// + /// Returns the parent id of a process or -1 if it fails. + /// + /// The process to find parent of. + /// The pid of the parent process. + internal static int GetParentPid(Process process) + { + return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + ? GetParentPidWindows(process) + : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) + ? GetParentPidLinux(process) + : RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? + GetParentPidMacOs(process) + : throw new PlatformNotSupportedException(); + } + + internal static int GetParentPidWindows(Process process) + { + try { - try - { - var handle = process.Handle; - var res = NtQueryInformationProcess(handle, 0, out var pbi, Marshal.SizeOf(), out int size); + var handle = process.Handle; + var res = NtQueryInformationProcess(handle, 0, out var pbi, Marshal.SizeOf(), out int size); - var p = res != 0 ? InvalidProcessId : pbi.InheritedFromUniqueProcessId.ToInt32(); + var p = res != 0 ? InvalidProcessId : pbi.InheritedFromUniqueProcessId.ToInt32(); - return p; - } - catch (Exception ex) - { - EqtTrace.Verbose($"ProcessCodeMethods.GetParentPidLinux: Error getting parent of process {process.Id} - {process.ProcessName}, {ex}."); - return InvalidProcessId; - } + return p; } - - /// Read the /proc file system for information about the parent. - /// The process to get the parent process from. - /// The process id. - internal static int GetParentPidLinux(Process process) + catch (Exception ex) { - var pid = process.Id; + EqtTrace.Verbose($"ProcessCodeMethods.GetParentPidLinux: Error getting parent of process {process.Id} - {process.ProcessName}, {ex}."); + return InvalidProcessId; + } + } - // read /proc//stat - // 4th column will contain the ppid, 92 in the example below - // ex: 93 (bash) S 92 93 2 4294967295 ... - var path = $"/proc/{pid}/stat"; - try - { - var stat = File.ReadAllText(path); - var parts = stat.Split(' '); + /// Read the /proc file system for information about the parent. + /// The process to get the parent process from. + /// The process id. + internal static int GetParentPidLinux(Process process) + { + var pid = process.Id; - if (parts.Length < 5) - { - return InvalidProcessId; - } + // read /proc//stat + // 4th column will contain the ppid, 92 in the example below + // ex: 93 (bash) S 92 93 2 4294967295 ... + var path = $"/proc/{pid}/stat"; + try + { + var stat = File.ReadAllText(path); + var parts = stat.Split(' '); - return int.Parse(parts[3]); - } - catch (Exception ex) - { - EqtTrace.Verbose($"ProcessCodeMethods.GetParentPidLinux: Error getting parent of process {process.Id} - {process.ProcessName}, {ex}."); - return InvalidProcessId; - } + return parts.Length < 5 ? InvalidProcessId : int.Parse(parts[3]); } - - internal static int GetParentPidMacOs(Process process) + catch (Exception ex) { - try - { - var output = new StringBuilder(); - var err = new StringBuilder(); - Process ps = new Process(); - ps.StartInfo.FileName = "ps"; - ps.StartInfo.Arguments = $"-o ppid= {process.Id}"; - ps.StartInfo.UseShellExecute = false; - ps.StartInfo.RedirectStandardOutput = true; - ps.OutputDataReceived += (_, e) => output.Append(e.Data); - ps.ErrorDataReceived += (_, e) => err.Append(e.Data); - ps.Start(); - ps.BeginOutputReadLine(); - ps.WaitForExit(5_000); - - var o = output.ToString(); - var parent = int.TryParse(o.Trim(), out var ppid) ? ppid : InvalidProcessId; - - if (!string.IsNullOrWhiteSpace(err.ToString())) - { - EqtTrace.Verbose($"ProcessCodeMethods.GetParentPidMacOs: Error getting parent of process {process.Id} - {process.ProcessName}, {err}."); - } - - return parent; - } - catch (Exception ex) - { - EqtTrace.Verbose($"ProcessCodeMethods.GetParentPidMacOs: Error getting parent of process {process.Id} - {process.ProcessName}, {ex}."); - return InvalidProcessId; - } + EqtTrace.Verbose($"ProcessCodeMethods.GetParentPidLinux: Error getting parent of process {process.Id} - {process.ProcessName}, {ex}."); + return InvalidProcessId; } + } - private static void ResolveChildren(Process parent, List acc, int level, int limit) + internal static int GetParentPidMacOs(Process process) + { + try { - if (limit < 0) - { - // hit recursion limit, just returning - return; - } + var output = new StringBuilder(); + var err = new StringBuilder(); + Process ps = new(); + ps.StartInfo.FileName = "ps"; + ps.StartInfo.Arguments = $"-o ppid= {process.Id}"; + ps.StartInfo.UseShellExecute = false; + ps.StartInfo.RedirectStandardOutput = true; + ps.OutputDataReceived += (_, e) => output.Append(e.Data); + ps.ErrorDataReceived += (_, e) => err.Append(e.Data); + ps.Start(); + ps.BeginOutputReadLine(); + ps.WaitForExit(5_000); - // only take children that are newer than the parent, because process ids (PIDs) get recycled - var children = acc.Where(p => p.ParentId == parent.Id && p.Process.StartTime > parent.StartTime).ToList(); + var o = output.ToString(); + var parent = int.TryParse(o.Trim(), out var ppid) ? ppid : InvalidProcessId; - foreach (var child in children) + if (!string.IsNullOrWhiteSpace(err.ToString())) { - child.Level = level; - ResolveChildren(child.Process, acc, level + 1, limit); + EqtTrace.Verbose($"ProcessCodeMethods.GetParentPidMacOs: Error getting parent of process {process.Id} - {process.ProcessName}, {err}."); } - } - private static bool IsChildCandidate(Process child, Process parent) + return parent; + } + catch (Exception ex) { - // this is extremely slow under debugger, but fast without it - try - { - return child.StartTime > parent.StartTime && child.Id != parent.Id; - } - catch - { - /* access denied or process has exits most likely */ - return false; - } + EqtTrace.Verbose($"ProcessCodeMethods.GetParentPidMacOs: Error getting parent of process {process.Id} - {process.ProcessName}, {ex}."); + return InvalidProcessId; } + } - [StructLayout(LayoutKind.Sequential)] - private struct PROCESS_BASIC_INFORMATION + private static void ResolveChildren(Process parent, List acc, int level, int limit) + { + if (limit < 0) { - public IntPtr ExitStatus; - public IntPtr PebBaseAddress; - public IntPtr AffinityMask; - public IntPtr BasePriority; - public IntPtr UniqueProcessId; - public IntPtr InheritedFromUniqueProcessId; + // hit recursion limit, just returning + return; } - [DllImport("ntdll.dll", SetLastError = true)] -#pragma warning disable SA1201 // Elements must appear in the correct order - private static extern int NtQueryInformationProcess( - IntPtr processHandle, - int processInformationClass, - out PROCESS_BASIC_INFORMATION processInformation, - int processInformationLength, - out int returnLength); + // only take children that are newer than the parent, because process ids (PIDs) get recycled + var children = acc.Where(p => p.ParentId == parent.Id && p.Process.StartTime > parent.StartTime).ToList(); + + foreach (var child in children) + { + child.Level = level; + ResolveChildren(child.Process, acc, level + 1, limit); + } + } - [DllImport("ntdll.dll", SetLastError = true)] - private static extern IntPtr NtSuspendProcess(IntPtr processHandle); + private static bool IsChildCandidate(Process child, Process parent) + { + // this is extremely slow under debugger, but fast without it + try + { + return child.StartTime > parent.StartTime && child.Id != parent.Id; + } + catch + { + /* access denied or process has exits most likely */ + return false; + } + } -#pragma warning restore SA1201 // Elements must appear in the correct order + [StructLayout(LayoutKind.Sequential)] + private struct ProcessBasicInformation + { + public readonly IntPtr ExitStatus; + public readonly IntPtr PebBaseAddress; + public readonly IntPtr AffinityMask; + public readonly IntPtr BasePriority; + public readonly IntPtr UniqueProcessId; + public IntPtr InheritedFromUniqueProcessId; } -} + + [DllImport("ntdll.dll", SetLastError = true)] + private static extern int NtQueryInformationProcess( + IntPtr processHandle, + int processInformationClass, + out ProcessBasicInformation processInformation, + int processInformationLength, + out int returnLength); + + [DllImport("ntdll.dll", SetLastError = true)] + private static extern IntPtr NtSuspendProcess(IntPtr processHandle); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessDumpUtility.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessDumpUtility.cs index 9364b9f6c7..232fe470d8 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessDumpUtility.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessDumpUtility.cs @@ -1,149 +1,147 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +internal class ProcessDumpUtility : IProcessDumpUtility { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.IO; - using System.Linq; - using System.Runtime.InteropServices; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - - internal class ProcessDumpUtility : IProcessDumpUtility + private readonly IProcessHelper _processHelper; + private readonly IFileHelper _fileHelper; + private readonly IHangDumperFactory _hangDumperFactory; + private readonly ICrashDumperFactory _crashDumperFactory; + private ICrashDumper _crashDumper; + private string _hangDumpDirectory; + private string _crashDumpDirectory; + private bool _wasHangDumped; + + public ProcessDumpUtility() + : this(new ProcessHelper(), new FileHelper(), new HangDumperFactory(), new CrashDumperFactory()) { - private readonly IProcessHelper processHelper; - private readonly IFileHelper fileHelper; - private readonly IHangDumperFactory hangDumperFactory; - private readonly ICrashDumperFactory crashDumperFactory; - private ICrashDumper crashDumper; - private string hangDumpDirectory; - private string crashDumpDirectory; - private bool wasHangDumped; - - public ProcessDumpUtility() - : this(new ProcessHelper(), new FileHelper(), new HangDumperFactory(), new CrashDumperFactory()) - { - } + } - public ProcessDumpUtility(IProcessHelper processHelper, IFileHelper fileHelper, IHangDumperFactory hangDumperFactory, ICrashDumperFactory crashDumperFactory) - { - this.processHelper = processHelper; - this.fileHelper = fileHelper; - this.hangDumperFactory = hangDumperFactory; - this.crashDumperFactory = crashDumperFactory; - } + public ProcessDumpUtility(IProcessHelper processHelper, IFileHelper fileHelper, IHangDumperFactory hangDumperFactory, ICrashDumperFactory crashDumperFactory) + { + _processHelper = processHelper; + _fileHelper = fileHelper; + _hangDumperFactory = hangDumperFactory; + _crashDumperFactory = crashDumperFactory; + } - protected Action OutputReceivedCallback => (process, data) => + protected Action OutputReceivedCallback => (process, data) => + { + // Log all standard output message of procdump in diag files. + // Otherwise they end up coming on console in pipleine. + if (EqtTrace.IsInfoEnabled) { - // Log all standard output message of procdump in diag files. - // Otherwise they end up coming on console in pipleine. - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("ProcessDumpUtility.OutputReceivedCallback: Output received from procdump process: " + data); - } - }; + EqtTrace.Info("ProcessDumpUtility.OutputReceivedCallback: Output received from procdump process: " + data); + } + }; - /// - public IEnumerable GetDumpFiles(bool warnOnNoDumpFiles, bool processCrashed) + /// + public IEnumerable GetDumpFiles(bool warnOnNoDumpFiles, bool processCrashed) + { + if (!_wasHangDumped) { - if (!this.wasHangDumped) - { - this.crashDumper.WaitForDumpToFinish(); - } + _crashDumper.WaitForDumpToFinish(); + } - // If the process was hang dumped we killed it ourselves, so it crashed when executing tests, - // but we already have the hang dump, and should not also collect the exit dump that we got - // from killing the process by the hang dumper. - IEnumerable crashDumps = this.crashDumper?.GetDumpFiles(processCrashed) ?? new List(); + // If the process was hang dumped we killed it ourselves, so it crashed when executing tests, + // but we already have the hang dump, and should not also collect the exit dump that we got + // from killing the process by the hang dumper. + IEnumerable crashDumps = _crashDumper?.GetDumpFiles(processCrashed) ?? new List(); - IEnumerable hangDumps = this.fileHelper.DirectoryExists(this.hangDumpDirectory) - ? this.fileHelper.GetFiles(this.hangDumpDirectory, "*_hangdump*.dmp", SearchOption.TopDirectoryOnly) - : Array.Empty(); + IEnumerable hangDumps = _fileHelper.DirectoryExists(_hangDumpDirectory) + ? _fileHelper.GetFiles(_hangDumpDirectory, "*_hangdump*.dmp", SearchOption.TopDirectoryOnly) + : Array.Empty(); - var foundDumps = new List(); - foreach (var dumpPath in crashDumps.Concat(hangDumps)) + var foundDumps = new List(); + foreach (var dumpPath in crashDumps.Concat(hangDumps)) + { + EqtTrace.Info($"ProcessDumpUtility.GetDumpFiles: Looking for dump file '{dumpPath}'."); + var found = _fileHelper.Exists(dumpPath); + if (found) { - EqtTrace.Info($"ProcessDumpUtility.GetDumpFiles: Looking for dump file '{dumpPath}'."); - var found = this.fileHelper.Exists(dumpPath); - if (found) - { - EqtTrace.Info($"ProcessDumpUtility.GetDumpFile: Found dump file '{dumpPath}'."); - foundDumps.Add(dumpPath); - } - else - { - EqtTrace.Warning($"ProcessDumpUtility.GetDumpFile: Dump file '{dumpPath}' was not found."); - } + EqtTrace.Info($"ProcessDumpUtility.GetDumpFile: Found dump file '{dumpPath}'."); + foundDumps.Add(dumpPath); } - - if (warnOnNoDumpFiles && !foundDumps.Any()) + else { - EqtTrace.Error($"ProcessDumpUtility.GetDumpFile: Could not find any dump file in {this.hangDumpDirectory}."); - throw new FileNotFoundException(Resources.Resources.DumpFileNotGeneratedErrorMessage); + EqtTrace.Warning($"ProcessDumpUtility.GetDumpFile: Dump file '{dumpPath}' was not found."); } - - return foundDumps; } - /// - public void StartHangBasedProcessDump(int processId, string tempDirectory, bool isFullDump, string targetFramework, Action logWarning = null) + if (warnOnNoDumpFiles && !foundDumps.Any()) { - this.HangDump(processId, tempDirectory, isFullDump ? DumpTypeOption.Full : DumpTypeOption.Mini, targetFramework, logWarning); + EqtTrace.Error($"ProcessDumpUtility.GetDumpFile: Could not find any dump file in {_hangDumpDirectory}."); + throw new FileNotFoundException(Resources.Resources.DumpFileNotGeneratedErrorMessage); } - /// - public void StartTriggerBasedProcessDump(int processId, string testResultsDirectory, bool isFullDump, string targetFramework, bool collectAlways) - { - this.CrashDump(processId, testResultsDirectory, isFullDump ? DumpTypeOption.Full : DumpTypeOption.Mini, targetFramework, collectAlways); - } + return foundDumps; + } - /// - public void DetachFromTargetProcess(int targetProcessId) - { - this.crashDumper?.DetachFromTargetProcess(targetProcessId); - } + /// + public void StartHangBasedProcessDump(int processId, string tempDirectory, bool isFullDump, string targetFramework, Action logWarning = null) + { + HangDump(processId, tempDirectory, isFullDump ? DumpTypeOption.Full : DumpTypeOption.Mini, targetFramework, logWarning); + } - private void CrashDump(int processId, string tempDirectory, DumpTypeOption dumpType, string targetFramework, bool collectAlways) - { - var processName = this.processHelper.GetProcessName(processId); - EqtTrace.Info($"ProcessDumpUtility.CrashDump: Creating {dumpType.ToString().ToLowerInvariant()} dump of process {processName} ({processId}) into temporary path '{tempDirectory}'."); - this.crashDumpDirectory = tempDirectory; + /// + public void StartTriggerBasedProcessDump(int processId, string testResultsDirectory, bool isFullDump, string targetFramework, bool collectAlways) + { + CrashDump(processId, testResultsDirectory, isFullDump ? DumpTypeOption.Full : DumpTypeOption.Mini, targetFramework, collectAlways); + } - this.crashDumper = this.crashDumperFactory.Create(targetFramework); - ConsoleOutput.Instance.Information(false, $"Blame: Attaching crash dump utility to process {processName} ({processId})."); - this.crashDumper.AttachToTargetProcess(processId, tempDirectory, dumpType, collectAlways); - } + /// + public void DetachFromTargetProcess(int targetProcessId) + { + _crashDumper?.DetachFromTargetProcess(targetProcessId); + } - private void HangDump(int processId, string tempDirectory, DumpTypeOption dumpType, string targetFramework, Action logWarning = null) - { - this.wasHangDumped = true; + private void CrashDump(int processId, string tempDirectory, DumpTypeOption dumpType, string targetFramework, bool collectAlways) + { + var processName = _processHelper.GetProcessName(processId); + EqtTrace.Info($"ProcessDumpUtility.CrashDump: Creating {dumpType.ToString().ToLowerInvariant()} dump of process {processName} ({processId}) into temporary path '{tempDirectory}'."); + _crashDumpDirectory = tempDirectory; - var processName = this.processHelper.GetProcessName(processId); - EqtTrace.Info($"ProcessDumpUtility.HangDump: Creating {dumpType.ToString().ToLowerInvariant()} dump of process {processName} ({processId}) into temporary path '{tempDirectory}'."); + _crashDumper = _crashDumperFactory.Create(targetFramework); + ConsoleOutput.Instance.Information(false, $"Blame: Attaching crash dump utility to process {processName} ({processId})."); + _crashDumper.AttachToTargetProcess(processId, tempDirectory, dumpType, collectAlways); + } - this.hangDumpDirectory = tempDirectory; + private void HangDump(int processId, string tempDirectory, DumpTypeOption dumpType, string targetFramework, Action logWarning = null) + { + _wasHangDumped = true; - // oh how ugly this is, but the whole infra above this starts with initializing the logger in Initialize - // the logger needs to pass around 2 parameters, so I am just passing it around as callback instead - this.hangDumperFactory.LogWarning = logWarning; - var dumper = this.hangDumperFactory.Create(targetFramework); + var processName = _processHelper.GetProcessName(processId); + EqtTrace.Info($"ProcessDumpUtility.HangDump: Creating {dumpType.ToString().ToLowerInvariant()} dump of process {processName} ({processId}) into temporary path '{tempDirectory}'."); - try - { - dumper.Dump(processId, tempDirectory, dumpType); - } - catch (Exception ex) - { - EqtTrace.Error($"Blame: Failed with error {ex}."); - throw; - } + _hangDumpDirectory = tempDirectory; + + // oh how ugly this is, but the whole infra above this starts with initializing the logger in Initialize + // the logger needs to pass around 2 parameters, so I am just passing it around as callback instead + _hangDumperFactory.LogWarning = logWarning; + var dumper = _hangDumperFactory.Create(targetFramework); + + try + { + dumper.Dump(processId, tempDirectory, dumpType); + } + catch (Exception ex) + { + EqtTrace.Error($"Blame: Failed with error {ex}."); + throw; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessTreeNode.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessTreeNode.cs index e093c0fa63..d1fa0c2c50 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessTreeNode.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessTreeNode.cs @@ -1,29 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector -{ - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.IO; - using System.Linq; - using System.Runtime.InteropServices; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; +using System.Diagnostics; - internal class ProcessTreeNode - { - public Process Process { get; set; } +internal class ProcessTreeNode +{ + public Process Process { get; set; } - public int Level { get; set; } + public int Level { get; set; } - public int ParentId { get; set; } + public int ParentId { get; set; } - public Process ParentProcess { get; set; } - } -} + public Process ParentProcess { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/SigtrapDumper.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/SigtrapDumper.cs index 2c2bbfc17c..20855671f9 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/SigtrapDumper.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/SigtrapDumper.cs @@ -1,15 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector -{ - using System.Diagnostics; +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System.Diagnostics; - internal class SigtrapDumper : IHangDumper +internal class SigtrapDumper : IHangDumper +{ + public void Dump(int processId, string outputDirectory, DumpTypeOption type) { - public void Dump(int processId, string outputDirectory, DumpTypeOption type) - { - Process.Start("kill", $"-s SIGTRAP {processId}"); - } + Process.Start("kill", $"-s SIGTRAP {processId}"); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Win32NamedEvent.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Win32NamedEvent.cs index 9afdd0ef08..439785adb8 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Win32NamedEvent.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Win32NamedEvent.cs @@ -1,47 +1,46 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; +using System.Runtime.InteropServices; + +public class Win32NamedEvent { - using System; - using System.Runtime.InteropServices; + private const uint EventModifyState = 0x0002; + + private readonly string _eventName; - public class Win32NamedEvent + /// + /// Initializes a new instance of the class. + /// Create a NamedEvent object with the name of the event, and assume auto reset with + /// an initial state of reset. + /// + /// The name of the win32 event + public Win32NamedEvent(string eventName) { - private const uint EventModifyState = 0x0002; - - private string eventName; - - /// - /// Initializes a new instance of the class. - /// Create a NamedEvent object with the name of the event, and assume auto reset with - /// an initial state of reset. - /// - /// The name of the win32 event - public Win32NamedEvent(string eventName) - { - this.eventName = eventName; - } - - /// - /// Set the named event to a signaled state. The Wait() method will not block any - /// thread as long as the event is in a signaled state. - /// - public void Set() - { - IntPtr handle = OpenEvent(Win32NamedEvent.EventModifyState, false, this.eventName); - SetEvent(handle); - CloseHandle(handle); - } - - [DllImport("kernel32.dll", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool CloseHandle(IntPtr hObject); - - [DllImport("kernel32.dll")] - private static extern bool SetEvent(IntPtr hEvent); - - [DllImport("Kernel32.dll", SetLastError = true)] - private static extern IntPtr OpenEvent(uint dwDesiredAccess, bool bInheritHandle, string lpName); + _eventName = eventName; } -} + + /// + /// Set the named event to a signaled state. The Wait() method will not block any + /// thread as long as the event is in a signaled state. + /// + public void Set() + { + IntPtr handle = OpenEvent(EventModifyState, false, _eventName); + SetEvent(handle); + CloseHandle(handle); + } + + [DllImport("kernel32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + private static extern bool CloseHandle(IntPtr hObject); + + [DllImport("kernel32.dll")] + private static extern bool SetEvent(IntPtr hEvent); + + [DllImport("Kernel32.dll", SetLastError = true)] + private static extern IntPtr OpenEvent(uint dwDesiredAccess, bool bInheritHandle, string lpName); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/WindowsHangDumper.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/WindowsHangDumper.cs index d06b1e6ed9..4fed8fd16e 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/WindowsHangDumper.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/WindowsHangDumper.cs @@ -1,282 +1,279 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using Win32.SafeHandles; + +internal class WindowsHangDumper : IHangDumper { - using System; - using System.Diagnostics; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Reflection; - using System.Runtime.InteropServices; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.Win32.SafeHandles; + private readonly Action _logWarning; - internal class WindowsHangDumper : IHangDumper + public WindowsHangDumper(Action logWarning) { - private Action logWarning; + _logWarning = logWarning ?? (_ => { }); + } - public WindowsHangDumper(Action logWarning) + private static Action OutputReceivedCallback => (process, data) => + { + // useful for visibility when debugging this tool + // Console.ForegroundColor = ConsoleColor.Cyan; + // Console.WriteLine(data); + // Console.ForegroundColor = ConsoleColor.White; + // Log all standard output message of procdump in diag files. + // Otherwise they end up coming on console in pipleine. + if (EqtTrace.IsInfoEnabled) { - this.logWarning = logWarning ?? (_ => { }); + EqtTrace.Info("ProcDumpDumper.OutputReceivedCallback: Output received from procdump process: " + data); } + }; - private static Action OutputReceivedCallback => (process, data) => - { - // useful for visibility when debugging this tool - // Console.ForegroundColor = ConsoleColor.Cyan; - // Console.WriteLine(data); - // Console.ForegroundColor = ConsoleColor.White; - // Log all standard output message of procdump in diag files. - // Otherwise they end up coming on console in pipleine. - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("ProcDumpDumper.OutputReceivedCallback: Output received from procdump process: " + data); - } - }; + public void Dump(int processId, string outputDirectory, DumpTypeOption type) + { + var process = Process.GetProcessById(processId); + var processTree = process.GetProcessTree().Where(p => p.Process.ProcessName != "conhost" && p.Process.ProcessName != "WerFault").ToList(); - public void Dump(int processId, string outputDirectory, DumpTypeOption type) + if (processTree.Count > 1) { - var process = Process.GetProcessById(processId); - var processTree = process.GetProcessTree().Where(p => p.Process.ProcessName != "conhost" && p.Process.ProcessName != "WerFault").ToList(); - - if (processTree.Count > 1) + var tree = processTree.OrderBy(t => t.Level); + EqtTrace.Verbose("WindowsHangDumper.Dump: Dumping this process tree (from bottom):"); + foreach (var p in tree) { - var tree = processTree.OrderBy(t => t.Level); - EqtTrace.Verbose("WindowsHangDumper.Dump: Dumping this process tree (from bottom):"); - foreach (var p in tree) - { - EqtTrace.Verbose($"WindowsHangDumper.Dump: {new string(' ', p.Level)}{(p.Level != 0 ? " +" : " >-")} {p.Process.Id} - {p.Process.ProcessName}"); - } - - // logging warning separately to avoid interleving the messages in the log which make this tree unreadable - this.logWarning(Resources.Resources.DumpingTree); - foreach (var p in tree) - { - this.logWarning($"{new string(' ', p.Level)}{(p.Level != 0 ? "+-" : ">")} {p.Process.Id} - {p.Process.ProcessName}"); - } - } - else - { - EqtTrace.Verbose($"NetClientHangDumper.Dump: Dumping {process.Id} - {process.ProcessName}."); - var message = string.Format(CultureInfo.CurrentUICulture, Resources.Resources.Dumping, process.Id, process.ProcessName); - this.logWarning(message); + EqtTrace.Verbose($"WindowsHangDumper.Dump: {new string(' ', p.Level)}{(p.Level != 0 ? " +" : " >-")} {p.Process.Id} - {p.Process.ProcessName}"); } - var bottomUpTree = processTree.OrderByDescending(t => t.Level).Select(t => t.Process); - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + // logging warning separately to avoid interleving the messages in the log which make this tree unreadable + _logWarning(Resources.Resources.DumpingTree); + foreach (var p in tree) { - foreach (var p in bottomUpTree) - { - try - { - p.Suspend(); - } - catch (Exception ex) - { - EqtTrace.Error($"WindowsHangDumper.Dump: Error suspending process {p.Id} - {p.ProcessName}: {ex}."); - } - } + _logWarning($"{new string(' ', p.Level)}{(p.Level != 0 ? "+-" : ">")} {p.Process.Id} - {p.Process.ProcessName}"); } + } + else + { + EqtTrace.Verbose($"NetClientHangDumper.Dump: Dumping {process.Id} - {process.ProcessName}."); + var message = string.Format(CultureInfo.CurrentUICulture, Resources.Resources.Dumping, process.Id, process.ProcessName); + _logWarning(message); + } + var bottomUpTree = processTree.OrderByDescending(t => t.Level).Select(t => t.Process); + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { foreach (var p in bottomUpTree) { try { - var outputFile = Path.Combine(outputDirectory, $"{p.ProcessName}_{p.Id}_{DateTime.Now:yyyyMMddTHHmmss}_hangdump.dmp"); - CollectDump(p, outputFile, type); + p.Suspend(); } catch (Exception ex) { - EqtTrace.Error($"WindowsHangDumper.Dump: Error dumping process {p.Id} - {p.ProcessName}: {ex}."); - } - - try - { - EqtTrace.Verbose($"WindowsHangDumper.Dump: Killing process {p.Id} - {p.ProcessName}."); - p.Kill(); - } - catch (Exception ex) - { - EqtTrace.Error($"WindowsHangDumper.Dump: Error killing process {p.Id} - {p.ProcessName}: {ex}."); + EqtTrace.Error($"WindowsHangDumper.Dump: Error suspending process {p.Id} - {p.ProcessName}: {ex}."); } } } - internal static void CollectDump(Process process, string outputFile, DumpTypeOption type) + foreach (var p in bottomUpTree) { - if (process.HasExited) + try { - EqtTrace.Verbose($"WindowsHangDumper.CollectDump: {process.Id} - {process.ProcessName} already exited, skipping."); - return; + var outputFile = Path.Combine(outputDirectory, $"{p.ProcessName}_{p.Id}_{DateTime.Now:yyyyMMddTHHmmss}_hangdump.dmp"); + CollectDump(p, outputFile, type); + } + catch (Exception ex) + { + EqtTrace.Error($"WindowsHangDumper.Dump: Error dumping process {p.Id} - {p.ProcessName}: {ex}."); } - EqtTrace.Verbose($"WindowsHangDumper.CollectDump: Selected dump type {type}. Dumping {process.Id} - {process.ProcessName} in {outputFile}. "); - - if (RuntimeInformation.OSArchitecture == System.Runtime.InteropServices.Architecture.X86) + try { - // This is x86 OS, the current process and the target process must be x86. (Or maybe arm64, but let's not worry about that now). - // Just dump it using PInvoke. - EqtTrace.Verbose($"WindowsHangDumper.CollectDump: We are on x86 Windows, both processes are x86, using PInvoke dumper."); - CollectDumpUsingMiniDumpWriteDump(process, outputFile, type); + EqtTrace.Verbose($"WindowsHangDumper.Dump: Killing process {p.Id} - {p.ProcessName}."); + p.Kill(); } - else if (RuntimeInformation.OSArchitecture == System.Runtime.InteropServices.Architecture.X64) + catch (Exception ex) { - var targetProcessIs64Bit = new NativeMethodsHelper().Is64Bit(process.Handle); + EqtTrace.Error($"WindowsHangDumper.Dump: Error killing process {p.Id} - {p.ProcessName}: {ex}."); + } + } + } - var currentProcessIs64Bit = RuntimeInformation.ProcessArchitecture == System.Runtime.InteropServices.Architecture.X64; + internal static void CollectDump(Process process, string outputFile, DumpTypeOption type) + { + if (process.HasExited) + { + EqtTrace.Verbose($"WindowsHangDumper.CollectDump: {process.Id} - {process.ProcessName} already exited, skipping."); + return; + } - if (targetProcessIs64Bit && currentProcessIs64Bit) - { - // Both processes are x64 architecture, dump it using the PInvoke call. - EqtTrace.Verbose($"WindowsHangDumper.CollectDump: We are on x64 Windows, and both processes are x64, using PInvoke dumper."); - CollectDumpUsingMiniDumpWriteDump(process, outputFile, type); - } - else if (!targetProcessIs64Bit && !currentProcessIs64Bit) + EqtTrace.Verbose($"WindowsHangDumper.CollectDump: Selected dump type {type}. Dumping {process.Id} - {process.ProcessName} in {outputFile}. "); + + if (RuntimeInformation.OSArchitecture == System.Runtime.InteropServices.Architecture.X86) + { + // This is x86 OS, the current process and the target process must be x86. (Or maybe arm64, but let's not worry about that now). + // Just dump it using PInvoke. + EqtTrace.Verbose($"WindowsHangDumper.CollectDump: We are on x86 Windows, both processes are x86, using PInvoke dumper."); + CollectDumpUsingMiniDumpWriteDump(process, outputFile, type); + } + else if (RuntimeInformation.OSArchitecture == System.Runtime.InteropServices.Architecture.X64) + { + var targetProcessIs64Bit = new NativeMethodsHelper().Is64Bit(process.Handle); + + var currentProcessIs64Bit = RuntimeInformation.ProcessArchitecture == System.Runtime.InteropServices.Architecture.X64; + + if (targetProcessIs64Bit && currentProcessIs64Bit) + { + // Both processes are x64 architecture, dump it using the PInvoke call. + EqtTrace.Verbose($"WindowsHangDumper.CollectDump: We are on x64 Windows, and both processes are x64, using PInvoke dumper."); + CollectDumpUsingMiniDumpWriteDump(process, outputFile, type); + } + else if (!targetProcessIs64Bit && !currentProcessIs64Bit) + { + // Both processes are x86 architecture, dump it using the PInvoke call. + EqtTrace.Verbose($"WindowsHangDumper.CollectDump: We are on x64 Windows, and both processes are x86, using PInvoke dumper."); + CollectDumpUsingMiniDumpWriteDump(process, outputFile, type); + } + else + { + string dumpMinitoolName; + if (!currentProcessIs64Bit && targetProcessIs64Bit) { - // Both processes are x86 architecture, dump it using the PInvoke call. - EqtTrace.Verbose($"WindowsHangDumper.CollectDump: We are on x64 Windows, and both processes are x86, using PInvoke dumper."); - CollectDumpUsingMiniDumpWriteDump(process, outputFile, type); + EqtTrace.Verbose($"WindowsHangDumper.CollectDump: We are on x64 Windows, datacollector is x86, and target process is x64, using 64-bit MiniDumptool."); + dumpMinitoolName = "DumpMinitool.exe"; } else { - string dumpMinitoolName; - if (!currentProcessIs64Bit && targetProcessIs64Bit) - { - EqtTrace.Verbose($"WindowsHangDumper.CollectDump: We are on x64 Windows, datacollector is x86, and target process is x64, using 64-bit MiniDumptool."); - dumpMinitoolName = "DumpMinitool.exe"; - } - else - { - EqtTrace.Verbose($"WindowsHangDumper.CollectDump: We are on x64 Windows, datacollector is x64, and target process is x86, using 32-bit MiniDumptool."); - dumpMinitoolName = "DumpMinitool.x86.exe"; - } - - var args = $"--file \"{outputFile}\" --processId {process.Id} --dumpType {type}"; - var dumpMinitoolPath = Path.Combine(Path.GetDirectoryName(Assembly.GetCallingAssembly().Location), dumpMinitoolName); - if (!File.Exists(dumpMinitoolPath)) - { - throw new FileNotFoundException("Could not find DumpMinitool", dumpMinitoolPath); - } + EqtTrace.Verbose($"WindowsHangDumper.CollectDump: We are on x64 Windows, datacollector is x64, and target process is x86, using 32-bit MiniDumptool."); + dumpMinitoolName = "DumpMinitool.x86.exe"; + } - EqtTrace.Info($"ProcDumpDumper.CollectDump: Running DumpMinitool: '{dumpMinitoolPath} {args}'."); - var dumpMiniTool = new ProcessHelper().LaunchProcess( - dumpMinitoolPath, - args, - Path.GetDirectoryName(outputFile), - null, - null, - null, - OutputReceivedCallback) as Process; - dumpMiniTool.WaitForExit(); - EqtTrace.Info($"ProcDumpDumper.CollectDump: {dumpMinitoolName} exited with exitcode: '{dumpMiniTool.ExitCode}'."); + var args = $"--file \"{outputFile}\" --processId {process.Id} --dumpType {type}"; + var dumpMinitoolPath = Path.Combine(Path.GetDirectoryName(Assembly.GetCallingAssembly().Location), dumpMinitoolName); + if (!File.Exists(dumpMinitoolPath)) + { + throw new FileNotFoundException("Could not find DumpMinitool", dumpMinitoolPath); } + + EqtTrace.Info($"ProcDumpDumper.CollectDump: Running DumpMinitool: '{dumpMinitoolPath} {args}'."); + var dumpMiniTool = new ProcessHelper().LaunchProcess( + dumpMinitoolPath, + args, + Path.GetDirectoryName(outputFile), + null, + null, + null, + OutputReceivedCallback) as Process; + dumpMiniTool.WaitForExit(); + EqtTrace.Info($"ProcDumpDumper.CollectDump: {dumpMinitoolName} exited with exitcode: '{dumpMiniTool.ExitCode}'."); } + } + + EqtTrace.Verbose($"WindowsHangDumper.CollectDump: Finished dumping {process.Id} - {process.ProcessName} in {outputFile}. "); + } + + private static void CollectDumpUsingMiniDumpWriteDump(Process process, string outputFile, DumpTypeOption type) + { + // Open the file for writing + using var stream = new FileStream(outputFile, FileMode.Create, FileAccess.ReadWrite, FileShare.None); + NativeMethods.MinidumpExceptionInformation exceptionInfo = default; - EqtTrace.Verbose($"WindowsHangDumper.CollectDump: Finished dumping {process.Id} - {process.ProcessName} in {outputFile}. "); + NativeMethods.MinidumpType dumpType = NativeMethods.MinidumpType.MiniDumpNormal; + switch (type) + { + case DumpTypeOption.Full: + dumpType = NativeMethods.MinidumpType.MiniDumpWithFullMemory | + NativeMethods.MinidumpType.MiniDumpWithDataSegs | + NativeMethods.MinidumpType.MiniDumpWithHandleData | + NativeMethods.MinidumpType.MiniDumpWithUnloadedModules | + NativeMethods.MinidumpType.MiniDumpWithFullMemoryInfo | + NativeMethods.MinidumpType.MiniDumpWithThreadInfo | + NativeMethods.MinidumpType.MiniDumpWithTokenInformation; + break; + case DumpTypeOption.WithHeap: + dumpType = NativeMethods.MinidumpType.MiniDumpWithPrivateReadWriteMemory | + NativeMethods.MinidumpType.MiniDumpWithDataSegs | + NativeMethods.MinidumpType.MiniDumpWithHandleData | + NativeMethods.MinidumpType.MiniDumpWithUnloadedModules | + NativeMethods.MinidumpType.MiniDumpWithFullMemoryInfo | + NativeMethods.MinidumpType.MiniDumpWithThreadInfo | + NativeMethods.MinidumpType.MiniDumpWithTokenInformation; + break; + case DumpTypeOption.Mini: + dumpType = NativeMethods.MinidumpType.MiniDumpWithThreadInfo; + break; } - private static void CollectDumpUsingMiniDumpWriteDump(Process process, string outputFile, DumpTypeOption type) + // Retry the write dump on ERROR_PARTIAL_COPY + for (int i = 0; i < 5; i++) { - // Open the file for writing - using (var stream = new FileStream(outputFile, FileMode.Create, FileAccess.ReadWrite, FileShare.None)) + // Dump the process! + if (NativeMethods.MiniDumpWriteDump(process.Handle, (uint)process.Id, stream.SafeFileHandle, dumpType, ref exceptionInfo, IntPtr.Zero, IntPtr.Zero)) { - NativeMethods.MINIDUMP_EXCEPTION_INFORMATION exceptionInfo = default; - - NativeMethods.MINIDUMP_TYPE dumpType = NativeMethods.MINIDUMP_TYPE.MiniDumpNormal; - switch (type) - { - case DumpTypeOption.Full: - dumpType = NativeMethods.MINIDUMP_TYPE.MiniDumpWithFullMemory | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithDataSegs | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithHandleData | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithUnloadedModules | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithFullMemoryInfo | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithThreadInfo | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithTokenInformation; - break; - case DumpTypeOption.WithHeap: - dumpType = NativeMethods.MINIDUMP_TYPE.MiniDumpWithPrivateReadWriteMemory | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithDataSegs | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithHandleData | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithUnloadedModules | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithFullMemoryInfo | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithThreadInfo | - NativeMethods.MINIDUMP_TYPE.MiniDumpWithTokenInformation; - break; - case DumpTypeOption.Mini: - dumpType = NativeMethods.MINIDUMP_TYPE.MiniDumpWithThreadInfo; - break; - } - - // Retry the write dump on ERROR_PARTIAL_COPY - for (int i = 0; i < 5; i++) + break; + } + else + { + int err = Marshal.GetHRForLastWin32Error(); + if (err != NativeMethods.ErrorPartialCopy) { - // Dump the process! - if (NativeMethods.MiniDumpWriteDump(process.Handle, (uint)process.Id, stream.SafeFileHandle, dumpType, ref exceptionInfo, IntPtr.Zero, IntPtr.Zero)) - { - break; - } - else - { - int err = Marshal.GetHRForLastWin32Error(); - if (err != NativeMethods.ERROR_PARTIAL_COPY) - { - Marshal.ThrowExceptionForHR(err); - } - } + Marshal.ThrowExceptionForHR(err); } } } + } - private static class NativeMethods - { - public const int ERROR_PARTIAL_COPY = unchecked((int)0x8007012b); + private static class NativeMethods + { + public const int ErrorPartialCopy = unchecked((int)0x8007012b); - [DllImport("Dbghelp.dll", SetLastError = true)] - public static extern bool MiniDumpWriteDump(IntPtr hProcess, uint ProcessId, SafeFileHandle hFile, MINIDUMP_TYPE DumpType, ref MINIDUMP_EXCEPTION_INFORMATION ExceptionParam, IntPtr UserStreamParam, IntPtr CallbackParam); + [DllImport("Dbghelp.dll", SetLastError = true)] + public static extern bool MiniDumpWriteDump(IntPtr hProcess, uint processId, SafeFileHandle hFile, MinidumpType dumpType, ref MinidumpExceptionInformation exceptionParam, IntPtr userStreamParam, IntPtr callbackParam); - [StructLayout(LayoutKind.Sequential, Pack = 4)] - public struct MINIDUMP_EXCEPTION_INFORMATION - { - public uint ThreadId; - public IntPtr ExceptionPointers; - public int ClientPointers; - } + [StructLayout(LayoutKind.Sequential, Pack = 4)] + public struct MinidumpExceptionInformation + { + public readonly uint ThreadId; + public readonly IntPtr ExceptionPointers; + public readonly int ClientPointers; + } - [Flags] -#pragma warning disable SA1201 // Elements must appear in the correct order - public enum MINIDUMP_TYPE : uint -#pragma warning restore SA1201 // Elements must appear in the correct order - { - MiniDumpNormal = 0, - MiniDumpWithDataSegs = 1 << 0, - MiniDumpWithFullMemory = 1 << 1, - MiniDumpWithHandleData = 1 << 2, - MiniDumpFilterMemory = 1 << 3, - MiniDumpScanMemory = 1 << 4, - MiniDumpWithUnloadedModules = 1 << 5, - MiniDumpWithIndirectlyReferencedMemory = 1 << 6, - MiniDumpFilterModulePaths = 1 << 7, - MiniDumpWithProcessThreadData = 1 << 8, - MiniDumpWithPrivateReadWriteMemory = 1 << 9, - MiniDumpWithoutOptionalData = 1 << 10, - MiniDumpWithFullMemoryInfo = 1 << 11, - MiniDumpWithThreadInfo = 1 << 12, - MiniDumpWithCodeSegs = 1 << 13, - MiniDumpWithoutAuxiliaryState = 1 << 14, - MiniDumpWithFullAuxiliaryState = 1 << 15, - MiniDumpWithPrivateWriteCopyMemory = 1 << 16, - MiniDumpIgnoreInaccessibleMemory = 1 << 17, - MiniDumpWithTokenInformation = 1 << 18, - MiniDumpWithModuleHeaders = 1 << 19, - MiniDumpFilterTriage = 1 << 20, - MiniDumpWithAvxXStateContext = 1 << 21, - MiniDumpWithIptTrace = 1 << 22, - MiniDumpValidTypeFlags = (-1) ^ ((~1) << 22) - } + [Flags] + public enum MinidumpType : uint + { + MiniDumpNormal = 0, + MiniDumpWithDataSegs = 1 << 0, + MiniDumpWithFullMemory = 1 << 1, + MiniDumpWithHandleData = 1 << 2, + MiniDumpFilterMemory = 1 << 3, + MiniDumpScanMemory = 1 << 4, + MiniDumpWithUnloadedModules = 1 << 5, + MiniDumpWithIndirectlyReferencedMemory = 1 << 6, + MiniDumpFilterModulePaths = 1 << 7, + MiniDumpWithProcessThreadData = 1 << 8, + MiniDumpWithPrivateReadWriteMemory = 1 << 9, + MiniDumpWithoutOptionalData = 1 << 10, + MiniDumpWithFullMemoryInfo = 1 << 11, + MiniDumpWithThreadInfo = 1 << 12, + MiniDumpWithCodeSegs = 1 << 13, + MiniDumpWithoutAuxiliaryState = 1 << 14, + MiniDumpWithFullAuxiliaryState = 1 << 15, + MiniDumpWithPrivateWriteCopyMemory = 1 << 16, + MiniDumpIgnoreInaccessibleMemory = 1 << 17, + MiniDumpWithTokenInformation = 1 << 18, + MiniDumpWithModuleHeaders = 1 << 19, + MiniDumpFilterTriage = 1 << 20, + MiniDumpWithAvxXStateContext = 1 << 21, + MiniDumpWithIptTrace = 1 << 22, + MiniDumpValidTypeFlags = (-1) ^ ((~1) << 22) } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/XmlReaderWriter.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/XmlReaderWriter.cs index a799ad8740..3cb3b7277f 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/XmlReaderWriter.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/XmlReaderWriter.cs @@ -1,148 +1,147 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +/// +/// XmlReaderWriter class for reading and writing test sequences to file +/// +public class XmlReaderWriter : IBlameReaderWriter { - using System; - using System.Collections.Generic; - using System.IO; - using System.Xml; + /// + /// The file helper. + /// + private readonly IFileHelper _fileHelper; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + #region Constructor /// - /// XmlReaderWriter class for reading and writing test sequences to file + /// Initializes a new instance of the class. /// - public class XmlReaderWriter : IBlameReaderWriter + internal XmlReaderWriter() + : this(new FileHelper()) { - /// - /// The file helper. - /// - private readonly IFileHelper fileHelper; - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - internal XmlReaderWriter() - : this(new FileHelper()) - { - } + } - /// - /// Initializes a new instance of the class. - /// Protected for testing purposes - /// - /// - /// The file helper. - /// - protected XmlReaderWriter(IFileHelper fileHelper) - { - this.fileHelper = fileHelper; - } + /// + /// Initializes a new instance of the class. + /// Protected for testing purposes + /// + /// + /// The file helper. + /// + protected XmlReaderWriter(IFileHelper fileHelper) + { + _fileHelper = fileHelper; + } - #endregion - - /// - /// Writes test Sequence to file. - /// Protected for testing purposes - /// - /// - /// Sequence of Guids - /// - /// - /// Dictionary of test objects - /// - /// - /// The file Path. - /// - /// File path - public string WriteTestSequence(List testSequence, Dictionary testObjectDictionary, string filePath) - { - ValidateArg.NotNull(testSequence, nameof(testSequence)); - ValidateArg.NotNull(testObjectDictionary, nameof(testObjectDictionary)); - ValidateArg.NotNullOrEmpty(filePath, nameof(filePath)); + #endregion - filePath += ".xml"; + /// + /// Writes test Sequence to file. + /// Protected for testing purposes + /// + /// + /// Sequence of Guids + /// + /// + /// Dictionary of test objects + /// + /// + /// The file Path. + /// + /// File path + public string WriteTestSequence(List testSequence, Dictionary testObjectDictionary, string filePath) + { + ValidateArg.NotNull(testSequence, nameof(testSequence)); + ValidateArg.NotNull(testObjectDictionary, nameof(testObjectDictionary)); + ValidateArg.NotNullOrEmpty(filePath, nameof(filePath)); - // Writing test sequence - var xmlDocument = new XmlDocument(); - var xmlDeclaration = xmlDocument.CreateNode(XmlNodeType.XmlDeclaration, string.Empty, string.Empty); - var blameTestRoot = xmlDocument.CreateElement(Constants.BlameRootNode); - xmlDocument.AppendChild(xmlDeclaration); + filePath += ".xml"; - foreach (var testGuid in testSequence) - { - if (testObjectDictionary.ContainsKey(testGuid)) - { - var testObject = testObjectDictionary[testGuid]; + // Writing test sequence + var xmlDocument = new XmlDocument(); + var xmlDeclaration = xmlDocument.CreateNode(XmlNodeType.XmlDeclaration, string.Empty, string.Empty); + var blameTestRoot = xmlDocument.CreateElement(Constants.BlameRootNode); + xmlDocument.AppendChild(xmlDeclaration); - var testElement = xmlDocument.CreateElement(Constants.BlameTestNode); - testElement.SetAttribute(Constants.TestNameAttribute, testObject.FullyQualifiedName); - testElement.SetAttribute(Constants.TestDisplayNameAttribute, testObject.DisplayName); - testElement.SetAttribute(Constants.TestSourceAttribute, testObject.Source); - testElement.SetAttribute(Constants.TestCompletedAttribute, testObject.IsCompleted.ToString()); + foreach (var testGuid in testSequence) + { + if (testObjectDictionary.ContainsKey(testGuid)) + { + var testObject = testObjectDictionary[testGuid]; - blameTestRoot.AppendChild(testElement); - } - } + var testElement = xmlDocument.CreateElement(Constants.BlameTestNode); + testElement.SetAttribute(Constants.TestNameAttribute, testObject.FullyQualifiedName); + testElement.SetAttribute(Constants.TestDisplayNameAttribute, testObject.DisplayName); + testElement.SetAttribute(Constants.TestSourceAttribute, testObject.Source); + testElement.SetAttribute(Constants.TestCompletedAttribute, testObject.IsCompleted.ToString()); - xmlDocument.AppendChild(blameTestRoot); - using (var stream = this.fileHelper.GetStream(filePath, FileMode.Create)) - { - xmlDocument.Save(stream); + blameTestRoot.AppendChild(testElement); } + } - return filePath; + xmlDocument.AppendChild(blameTestRoot); + using (var stream = _fileHelper.GetStream(filePath, FileMode.Create)) + { + xmlDocument.Save(stream); } - /// - /// Reads All test case from file - /// - /// The path of test sequence file - /// Test Case List - public List ReadTestSequence(string filePath) + return filePath; + } + + /// + /// Reads All test case from file + /// + /// The path of test sequence file + /// Test Case List + public List ReadTestSequence(string filePath) + { + ValidateArg.NotNull(filePath, nameof(filePath)); + + if (!_fileHelper.Exists(filePath)) { - ValidateArg.NotNull(filePath, nameof(filePath)); + throw new FileNotFoundException(); + } - if (!this.fileHelper.Exists(filePath)) + var testCaseList = new List(); + try + { + // Reading test sequence + var xmlDocument = new XmlDocument(); + using (var stream = _fileHelper.GetStream(filePath, FileMode.Open)) { - throw new FileNotFoundException(); + xmlDocument.Load(stream); } - var testCaseList = new List(); - try + var root = xmlDocument.LastChild; + foreach (XmlNode node in root) { - // Reading test sequence - var xmlDocument = new XmlDocument(); - using (var stream = this.fileHelper.GetStream(filePath, FileMode.Open)) + var testCase = new BlameTestObject { - xmlDocument.Load(stream); - } - - var root = xmlDocument.LastChild; - foreach (XmlNode node in root) - { - var testCase = new BlameTestObject - { - FullyQualifiedName = - node.Attributes[Constants.TestNameAttribute].Value, - Source = node.Attributes[Constants.TestSourceAttribute].Value, - DisplayName = node.Attributes[Constants.TestDisplayNameAttribute].Value, - IsCompleted = node.Attributes[Constants.TestCompletedAttribute].Value == "True" ? true : false - }; - testCaseList.Add(testCase); - } + FullyQualifiedName = + node.Attributes[Constants.TestNameAttribute].Value, + Source = node.Attributes[Constants.TestSourceAttribute].Value, + DisplayName = node.Attributes[Constants.TestDisplayNameAttribute].Value, + IsCompleted = node.Attributes[Constants.TestCompletedAttribute].Value == "True" + }; + testCaseList.Add(testCase); } - catch (XmlException xmlException) - { - EqtTrace.Warning("XmlReaderWriter : Exception ", xmlException); - } - - return testCaseList; } + catch (XmlException xmlException) + { + EqtTrace.Warning("XmlReaderWriter : Exception ", xmlException); + } + + return testCaseList; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.HtmlLogger/Constants.cs b/src/Microsoft.TestPlatform.Extensions.HtmlLogger/Constants.cs index 1c0ac5394e..aef299500d 100644 --- a/src/Microsoft.TestPlatform.Extensions.HtmlLogger/Constants.cs +++ b/src/Microsoft.TestPlatform.Extensions.HtmlLogger/Constants.cs @@ -1,67 +1,67 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger +namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger; + +using System; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; + +public static class Constants { - using System; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - - public static class Constants - { - /// - /// Uri used to uniquely identify the Html logger. - /// - public const string ExtensionUri = "logger://Microsoft/TestPlatform/HtmlLogger/v1"; - - /// - /// Alternate user friendly string to uniquely identify the console logger. - /// - public const string FriendlyName = "Html"; - - /// - /// The file extension of xml file - /// - public const string XmlFileExtension = "xml"; - - /// - /// The file extension of html file - /// - public const string HtmlFileExtension = "html"; - - /// /// - /// Property Id storing the TestType. - /// - public const string TestTypePropertyIdentifier = "TestType"; - - /// - /// Ordered test type guid - /// - public static readonly Guid OrderedTestTypeGuid = new Guid("ec4800e8-40e5-4ab3-8510-b8bf29b1904d"); - - /// - /// Property Id storing the ParentExecutionId. - /// - public const string ParentExecutionIdPropertyIdentifier = "ParentExecId"; - - /// - /// Property Id storing the ExecutionId. - /// - public const string ExecutionIdPropertyIdentifier = "ExecutionId"; - - /// - /// Log file parameter key - /// - public const string LogFileNameKey = "LogFileName"; - - /// - /// Log file prefix parameter key - /// - public const string LogFilePrefixKey = "LogFilePrefix"; - - public static readonly TestProperty ExecutionIdProperty = TestProperty.Register("ExecutionId", ExecutionIdPropertyIdentifier, typeof(Guid), TestPropertyAttributes.Hidden, typeof(TestResult)); - - public static readonly TestProperty ParentExecIdProperty = TestProperty.Register("ParentExecId", ParentExecutionIdPropertyIdentifier, typeof(Guid), TestPropertyAttributes.Hidden, typeof(TestResult)); - - public static readonly TestProperty TestTypeProperty = TestProperty.Register("TestType", TestTypePropertyIdentifier, typeof(Guid), TestPropertyAttributes.Hidden, typeof(TestResult)); - } + /// + /// Uri used to uniquely identify the Html logger. + /// + public const string ExtensionUri = "logger://Microsoft/TestPlatform/HtmlLogger/v1"; + + /// + /// Alternate user friendly string to uniquely identify the console logger. + /// + public const string FriendlyName = "Html"; + + /// + /// The file extension of xml file + /// + public const string XmlFileExtension = "xml"; + + /// + /// The file extension of html file + /// + public const string HtmlFileExtension = "html"; + + /// /// + /// Property Id storing the TestType. + /// + public const string TestTypePropertyIdentifier = "TestType"; + + /// + /// Ordered test type guid + /// + public static readonly Guid OrderedTestTypeGuid = new("ec4800e8-40e5-4ab3-8510-b8bf29b1904d"); + + /// + /// Property Id storing the ParentExecutionId. + /// + public const string ParentExecutionIdPropertyIdentifier = "ParentExecId"; + + /// + /// Property Id storing the ExecutionId. + /// + public const string ExecutionIdPropertyIdentifier = "ExecutionId"; + + /// + /// Log file parameter key + /// + public const string LogFileNameKey = "LogFileName"; + + /// + /// Log file prefix parameter key + /// + public const string LogFilePrefixKey = "LogFilePrefix"; + + public static readonly TestProperty ExecutionIdProperty = TestProperty.Register("ExecutionId", ExecutionIdPropertyIdentifier, typeof(Guid), TestPropertyAttributes.Hidden, typeof(TestResult)); + + public static readonly TestProperty ParentExecIdProperty = TestProperty.Register("ParentExecId", ParentExecutionIdPropertyIdentifier, typeof(Guid), TestPropertyAttributes.Hidden, typeof(TestResult)); + + public static readonly TestProperty TestTypeProperty = TestProperty.Register("TestType", TestTypePropertyIdentifier, typeof(Guid), TestPropertyAttributes.Hidden, typeof(TestResult)); } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.HtmlLogger/HtmlLogger.cs b/src/Microsoft.TestPlatform.Extensions.HtmlLogger/HtmlLogger.cs index b040c6194d..d6f63d81a5 100644 --- a/src/Microsoft.TestPlatform.Extensions.HtmlLogger/HtmlLogger.cs +++ b/src/Microsoft.TestPlatform.Extensions.HtmlLogger/HtmlLogger.cs @@ -1,443 +1,441 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger +namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Runtime.Serialization; + +using ObjectModel; +using Utilities; +using Utilities.Helpers; +using Utilities.Helpers.Interfaces; + +using HtmlResource = Resources.Resources; +using HtmlLoggerConstants = Constants; +using NuGet.Frameworks; + +/// +/// Logger for generating Html. +/// +[FriendlyName(HtmlLoggerConstants.FriendlyName)] +[ExtensionUri(HtmlLoggerConstants.ExtensionUri)] +public class HtmlLogger : ITestLoggerWithParameters { - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - - using System; - using System.Collections.Concurrent; - using System.Collections.Generic; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Runtime.Serialization; - - using ObjectModel; - using Utilities; - using Utilities.Helpers; - using Utilities.Helpers.Interfaces; - - using HtmlResource = Resources.Resources; - using HtmlLoggerConstants = Constants; - using NuGet.Frameworks; + private readonly IFileHelper _fileHelper; + private readonly XmlObjectSerializer _xmlSerializer; + private readonly IHtmlTransformer _htmlTransformer; + private Dictionary _parametersDictionary; + + public HtmlLogger() + : this(new FileHelper(), new HtmlTransformer(), new DataContractSerializer(typeof(TestRunDetails))) + { + } + + public HtmlLogger(IFileHelper fileHelper, IHtmlTransformer htmlTransformer, + XmlObjectSerializer dataContractSerializer) + { + _fileHelper = fileHelper; + _htmlTransformer = htmlTransformer; + _xmlSerializer = dataContractSerializer; + } /// - /// Logger for generating Html. + /// Gets the directory under which default html file and test results attachments should be saved. /// - [FriendlyName(HtmlLoggerConstants.FriendlyName)] - [ExtensionUri(HtmlLoggerConstants.ExtensionUri)] - public class HtmlLogger : ITestLoggerWithParameters - { - private readonly IFileHelper fileHelper; - private readonly XmlObjectSerializer xmlSerializer; - private readonly IHtmlTransformer htmlTransformer; - private Dictionary parametersDictionary; + public string TestResultsDirPath { get; private set; } - public HtmlLogger() - : this(new FileHelper(), new HtmlTransformer(), new DataContractSerializer(typeof(TestRunDetails))) - { - } + /// + /// Total results are stored in sequential order + /// + /// + public ConcurrentDictionary Results { get; private set; } - public HtmlLogger(IFileHelper fileHelper, IHtmlTransformer htmlTransformer, - XmlObjectSerializer dataContractSerializer) - { - this.fileHelper = fileHelper; - this.htmlTransformer = htmlTransformer; - this.xmlSerializer = dataContractSerializer; - } + /// + /// + /// + public ConcurrentDictionary ResultCollectionDictionary { get; private set; } - /// - /// Gets the directory under which default html file and test results attachments should be saved. - /// - public string TestResultsDirPath { get; private set; } - - /// - /// Total results are stored in sequential order - /// - /// - public ConcurrentDictionary Results { get; private set; } - - /// - /// - /// - public ConcurrentDictionary ResultCollectionDictionary { get; private set; } - - /// - /// Test results stores all the summary and the details of every results in hierarchical order. - /// - public TestRunDetails TestRunDetails { get; private set; } - - /// - /// Total passed tests in the test results. - /// - public int PassedTests { get; private set; } - - /// - /// Total failed tests in the test results. - /// - public int FailedTests { get; private set; } - - /// - /// Total tests in the results. - /// - public int TotalTests { get; private set; } - - /// - /// Total skipped tests in the results. - /// - public int SkippedTests { get; private set; } - - /// - /// Path to the xml file. - /// - public string XmlFilePath { get; private set; } - - /// - /// path to html file. - /// - public string HtmlFilePath { get; private set; } - - /// - public void Initialize(TestLoggerEvents events, string testResultsDirPath) - { - if (events == null) - { - throw new ArgumentNullException(nameof(events)); - } + /// + /// Test results stores all the summary and the details of every results in hierarchical order. + /// + public TestRunDetails TestRunDetails { get; private set; } - if (string.IsNullOrEmpty(testResultsDirPath)) - { - throw new ArgumentNullException(nameof(testResultsDirPath)); - } + /// + /// Total passed tests in the test results. + /// + public int PassedTests { get; private set; } + + /// + /// Total failed tests in the test results. + /// + public int FailedTests { get; private set; } + + /// + /// Total tests in the results. + /// + public int TotalTests { get; private set; } - // Register for the events. - events.TestRunMessage += TestMessageHandler; - events.TestResult += TestResultHandler; - events.TestRunComplete += TestRunCompleteHandler; + /// + /// Total skipped tests in the results. + /// + public int SkippedTests { get; private set; } + + /// + /// Path to the xml file. + /// + public string XmlFilePath { get; private set; } - TestResultsDirPath = testResultsDirPath; - TestRunDetails = new TestRunDetails(); - Results = new ConcurrentDictionary(); - ResultCollectionDictionary = new ConcurrentDictionary(); + /// + /// path to html file. + /// + public string HtmlFilePath { get; private set; } - // Ensure test results directory exists. - Directory.CreateDirectory(testResultsDirPath); + /// + public void Initialize(TestLoggerEvents events, string testResultsDirPath) + { + if (events == null) + { + throw new ArgumentNullException(nameof(events)); } - /// - public void Initialize(TestLoggerEvents events, Dictionary parameters) + if (string.IsNullOrEmpty(testResultsDirPath)) { - if (parameters == null) - { - throw new ArgumentNullException(nameof(parameters)); - } + throw new ArgumentNullException(nameof(testResultsDirPath)); + } - if (parameters.Count == 0) - { - throw new ArgumentException("No default parameters added", nameof(parameters)); - } + // Register for the events. + events.TestRunMessage += TestMessageHandler; + events.TestResult += TestResultHandler; + events.TestRunComplete += TestRunCompleteHandler; - parametersDictionary = parameters; + TestResultsDirPath = testResultsDirPath; + TestRunDetails = new TestRunDetails(); + Results = new ConcurrentDictionary(); + ResultCollectionDictionary = new ConcurrentDictionary(); - if (parameters.TryGetValue(HtmlLoggerConstants.LogFilePrefixKey, out string logFilePrefixValue) && parameters.TryGetValue(HtmlLoggerConstants.LogFileNameKey, out string logFileNameValue)) - { - var htmlParameterErrorMsg = string.Format(CultureInfo.CurrentCulture, HtmlResource.PrefixAndNameProvidedError); - EqtTrace.Error(htmlParameterErrorMsg); - throw new ArgumentException(htmlParameterErrorMsg); - } + // Ensure test results directory exists. + Directory.CreateDirectory(testResultsDirPath); + } - this.Initialize(events, parameters[DefaultLoggerParameterNames.TestRunDirectory]); + /// + public void Initialize(TestLoggerEvents events, Dictionary parameters) + { + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); } - /// - /// Handles the message level information like warnings, errors etc.. - /// - /// - /// - public void TestMessageHandler(object sender, TestRunMessageEventArgs e) + if (parameters.Count == 0) { - ValidateArg.NotNull(sender, nameof(sender)); - ValidateArg.NotNull(e, nameof(e)); - - switch (e.Level) - { - case TestMessageLevel.Informational: - if (TestRunDetails.RunLevelMessageInformational == null) - { - TestRunDetails.RunLevelMessageInformational = new List(); - } - - TestRunDetails.RunLevelMessageInformational.Add(e.Message); - break; - case TestMessageLevel.Warning: - case TestMessageLevel.Error: - if (TestRunDetails.RunLevelMessageErrorAndWarning == null) - { - TestRunDetails.RunLevelMessageErrorAndWarning = new List(); - } - - TestRunDetails.RunLevelMessageErrorAndWarning.Add(e.Message); - break; - default: - EqtTrace.Info("htmlLogger.TestMessageHandler: The test message level is unrecognized: {0}", - e.Level.ToString()); - break; - } + throw new ArgumentException("No default parameters added", nameof(parameters)); } - /// - /// Handles the result coming from vs test and store it in test results. - /// - /// - /// - public void TestResultHandler(object sender, TestResultEventArgs e) + _parametersDictionary = parameters; + if (parameters.TryGetValue(HtmlLoggerConstants.LogFilePrefixKey, out _) && parameters.TryGetValue(HtmlLoggerConstants.LogFileNameKey, out _)) { - ValidateArg.NotNull(sender, nameof(sender)); - ValidateArg.NotNull(e, nameof(e)); + var htmlParameterErrorMsg = string.Format(CultureInfo.CurrentCulture, HtmlResource.PrefixAndNameProvidedError); + EqtTrace.Error(htmlParameterErrorMsg); + throw new ArgumentException(htmlParameterErrorMsg); + } - var testResult = new ObjectModel.TestResult - { - DisplayName = e.Result.DisplayName ?? e.Result.TestCase.FullyQualifiedName, - FullyQualifiedName = e.Result.TestCase.FullyQualifiedName, - ErrorStackTrace = e.Result.ErrorStackTrace, - ErrorMessage = e.Result.ErrorMessage, - TestResultId = e.Result.TestCase.Id, - Duration = GetFormattedDurationString(e.Result.Duration), - ResultOutcome = e.Result.Outcome - }; + Initialize(events, parameters[DefaultLoggerParameterNames.TestRunDirectory]); + } - var executionId = GetExecutionId(e.Result); - var parentExecutionId = GetParentExecutionId(e.Result); + /// + /// Handles the message level information like warnings, errors etc.. + /// + /// + /// + public void TestMessageHandler(object sender, TestRunMessageEventArgs e) + { + ValidateArg.NotNull(sender, nameof(sender)); + ValidateArg.NotNull(e, nameof(e)); - ResultCollectionDictionary.TryGetValue(e.Result.TestCase.Source, out var testResultCollection); - if (testResultCollection == null) - { - testResultCollection = new TestResultCollection(e.Result.TestCase.Source) + switch (e.Level) + { + case TestMessageLevel.Informational: + if (TestRunDetails.RunLevelMessageInformational == null) { - ResultList = new List(), - FailedResultList = new List(), - }; - ResultCollectionDictionary.TryAdd(e.Result.TestCase.Source, testResultCollection); - TestRunDetails.ResultCollectionList.Add(testResultCollection); - } - - TotalTests++; - switch (e.Result.Outcome) - { - case TestOutcome.Failed: - FailedTests++; - break; - case TestOutcome.Passed: - PassedTests++; - break; - case TestOutcome.Skipped: - SkippedTests++; - break; - default: - break; - } - - Results.TryAdd(executionId, testResult); + TestRunDetails.RunLevelMessageInformational = new List(); + } - // Check for parent execution id to store the test results in hierarchical way - if (parentExecutionId == Guid.Empty) - { - if (e.Result.Outcome == TestOutcome.Failed) + TestRunDetails.RunLevelMessageInformational.Add(e.Message); + break; + case TestMessageLevel.Warning: + case TestMessageLevel.Error: + if (TestRunDetails.RunLevelMessageErrorAndWarning == null) { - testResultCollection.FailedResultList.Add(testResult); + TestRunDetails.RunLevelMessageErrorAndWarning = new List(); } - testResultCollection.ResultList.Add(testResult); - } - else - { - AddToParentResult(parentExecutionId, testResult); - } + TestRunDetails.RunLevelMessageErrorAndWarning.Add(e.Message); + break; + default: + EqtTrace.Info("htmlLogger.TestMessageHandler: The test message level is unrecognized: {0}", + e.Level.ToString()); + break; } + } - private void AddToParentResult(Guid parentExecutionId, ObjectModel.TestResult testResult) + /// + /// Handles the result coming from vs test and store it in test results. + /// + /// + /// + public void TestResultHandler(object sender, TestResultEventArgs e) + { + ValidateArg.NotNull(sender, nameof(sender)); + ValidateArg.NotNull(e, nameof(e)); + + var testResult = new ObjectModel.TestResult + { + DisplayName = e.Result.DisplayName ?? e.Result.TestCase.FullyQualifiedName, + FullyQualifiedName = e.Result.TestCase.FullyQualifiedName, + ErrorStackTrace = e.Result.ErrorStackTrace, + ErrorMessage = e.Result.ErrorMessage, + TestResultId = e.Result.TestCase.Id, + Duration = GetFormattedDurationString(e.Result.Duration), + ResultOutcome = e.Result.Outcome + }; + + var executionId = GetExecutionId(e.Result); + var parentExecutionId = GetParentExecutionId(e.Result); + + ResultCollectionDictionary.TryGetValue(e.Result.TestCase.Source, out var testResultCollection); + if (testResultCollection == null) { - if (Results.TryGetValue(parentExecutionId, out var parentTestResult)) + testResultCollection = new TestResultCollection(e.Result.TestCase.Source) { - if (parentTestResult.InnerTestResults == null) - parentTestResult.InnerTestResults = new List(); + ResultList = new List(), + FailedResultList = new List(), + }; + ResultCollectionDictionary.TryAdd(e.Result.TestCase.Source, testResultCollection); + TestRunDetails.ResultCollectionList.Add(testResultCollection); + } - parentTestResult.InnerTestResults.Add(testResult); - } + TotalTests++; + switch (e.Result.Outcome) + { + case TestOutcome.Failed: + FailedTests++; + break; + case TestOutcome.Passed: + PassedTests++; + break; + case TestOutcome.Skipped: + SkippedTests++; + break; + default: + break; } - /// - /// Creates a summary of tests and populates the html file by transforming the xml file with help of xslt file. - /// - /// - /// - public void TestRunCompleteHandler(object sender, TestRunCompleteEventArgs e) + Results.TryAdd(executionId, testResult); + + // Check for parent execution id to store the test results in hierarchical way + if (parentExecutionId == Guid.Empty) { - TestRunDetails.Summary = new TestRunSummary - { - FailedTests = FailedTests, - PassedTests = PassedTests, - TotalTests = TotalTests, - SkippedTests = SkippedTests, - PassPercentage = TotalTests == 0 ? 0 : PassedTests * 100 / TotalTests, - TotalRunTime = GetFormattedDurationString(e.ElapsedTimeInRunningTests), - }; - if (this.parametersDictionary.TryGetValue(HtmlLoggerConstants.LogFilePrefixKey, out string logFilePrefixValue) && !string.IsNullOrWhiteSpace(logFilePrefixValue)) + if (e.Result.Outcome == TestOutcome.Failed) { - var framework = this.parametersDictionary[DefaultLoggerParameterNames.TargetFramework]; - if (framework != null) - { - framework = NuGetFramework.Parse(framework).GetShortFolderName(); - logFilePrefixValue = logFilePrefixValue + "_" + framework; - } - - logFilePrefixValue = logFilePrefixValue + DateTime.Now.ToString("_yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo) + $".{HtmlLoggerConstants.HtmlFileExtension}"; - this.HtmlFilePath = Path.Combine(TestResultsDirPath, logFilePrefixValue); + testResultCollection.FailedResultList.Add(testResult); } - else + + testResultCollection.ResultList.Add(testResult); + } + else + { + AddToParentResult(parentExecutionId, testResult); + } + } + + private void AddToParentResult(Guid parentExecutionId, ObjectModel.TestResult testResult) + { + if (Results.TryGetValue(parentExecutionId, out var parentTestResult)) + { + if (parentTestResult.InnerTestResults == null) + parentTestResult.InnerTestResults = new List(); + + parentTestResult.InnerTestResults.Add(testResult); + } + } + + /// + /// Creates a summary of tests and populates the html file by transforming the xml file with help of xslt file. + /// + /// + /// + public void TestRunCompleteHandler(object sender, TestRunCompleteEventArgs e) + { + TestRunDetails.Summary = new TestRunSummary + { + FailedTests = FailedTests, + PassedTests = PassedTests, + TotalTests = TotalTests, + SkippedTests = SkippedTests, + PassPercentage = TotalTests == 0 ? 0 : PassedTests * 100 / TotalTests, + TotalRunTime = GetFormattedDurationString(e.ElapsedTimeInRunningTests), + }; + if (_parametersDictionary.TryGetValue(HtmlLoggerConstants.LogFilePrefixKey, out string logFilePrefixValue) && !string.IsNullOrWhiteSpace(logFilePrefixValue)) + { + var framework = _parametersDictionary[DefaultLoggerParameterNames.TargetFramework]; + if (framework != null) { - if (parametersDictionary.TryGetValue(HtmlLoggerConstants.LogFileNameKey, out string logFileNameValue) && !string.IsNullOrWhiteSpace(logFileNameValue)) - { - this.HtmlFilePath = Path.Combine(TestResultsDirPath, logFileNameValue); - } + framework = NuGetFramework.Parse(framework).GetShortFolderName(); + logFilePrefixValue = logFilePrefixValue + "_" + framework; } - PopulateHtmlFile(); + logFilePrefixValue = logFilePrefixValue + DateTime.Now.ToString("_yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo) + $".{HtmlLoggerConstants.HtmlFileExtension}"; + HtmlFilePath = Path.Combine(TestResultsDirPath, logFilePrefixValue); } - - private void PopulateHtmlFile() + else { - try + if (_parametersDictionary.TryGetValue(HtmlLoggerConstants.LogFileNameKey, out string logFileNameValue) && !string.IsNullOrWhiteSpace(logFileNameValue)) { - var fileName = string.Format(CultureInfo.CurrentCulture, "{0}_{1}_{2}", - Environment.GetEnvironmentVariable("UserName"), Environment.MachineName, - FormatDateTimeForRunName(DateTime.Now)); + HtmlFilePath = Path.Combine(TestResultsDirPath, logFileNameValue); + } + } - XmlFilePath = GetFilePath(HtmlLoggerConstants.XmlFileExtension, fileName); + PopulateHtmlFile(); + } - using (var xmlStream = fileHelper.GetStream(XmlFilePath, FileMode.Create)) - { - xmlSerializer.WriteObject(xmlStream, TestRunDetails); - } + private void PopulateHtmlFile() + { + try + { + var fileName = string.Format(CultureInfo.CurrentCulture, "{0}_{1}_{2}", + Environment.GetEnvironmentVariable("UserName"), Environment.MachineName, + FormatDateTimeForRunName(DateTime.Now)); - if (string.IsNullOrEmpty(HtmlFilePath)) - { - HtmlFilePath = GetFilePath(HtmlLoggerConstants.HtmlFileExtension, fileName); - } + XmlFilePath = GetFilePath(HtmlLoggerConstants.XmlFileExtension, fileName); - htmlTransformer.Transform(XmlFilePath, HtmlFilePath); - } - catch (Exception ex) + using (var xmlStream = _fileHelper.GetStream(XmlFilePath, FileMode.Create)) { - EqtTrace.Error("HtmlLogger : Failed to populate html file. Exception : {0}", - ex.ToString()); - ConsoleOutput.Instance.Error(false, string.Concat(HtmlResource.HtmlLoggerError), ex.Message); - return; + _xmlSerializer.WriteObject(xmlStream, TestRunDetails); } - finally + + if (string.IsNullOrEmpty(HtmlFilePath)) { - if (XmlFilePath != null) - { - this.fileHelper.Delete(XmlFilePath); - } + HtmlFilePath = GetFilePath(HtmlLoggerConstants.HtmlFileExtension, fileName); } - var htmlFilePathMessage = string.Format(CultureInfo.CurrentCulture, HtmlResource.HtmlFilePath, HtmlFilePath); - EqtTrace.Info(htmlFilePathMessage); - ConsoleOutput.Instance.Information(false, htmlFilePathMessage); + _htmlTransformer.Transform(XmlFilePath, HtmlFilePath); } - - private string GetFilePath(string fileExtension, string fileName) + catch (Exception ex) { - var fullFileFormat = $".{fileExtension}"; - return Path.Combine(TestResultsDirPath, string.Concat("TestResult_", fileName, fullFileFormat)); + EqtTrace.Error("HtmlLogger : Failed to populate html file. Exception : {0}", + ex.ToString()); + ConsoleOutput.Instance.Error(false, string.Concat(HtmlResource.HtmlLoggerError), ex.Message); + return; } - - private string FormatDateTimeForRunName(DateTime timeStamp) + finally { - return timeStamp.ToString("yyyyMMdd_HHmmss", DateTimeFormatInfo.InvariantInfo); + if (XmlFilePath != null) + { + _fileHelper.Delete(XmlFilePath); + } } - /// - /// Gives the parent execution id of a TestResult. - /// - /// - /// - private Guid GetParentExecutionId(TestPlatform.ObjectModel.TestResult testResult) - { - var parentExecutionIdProperty = testResult.Properties.FirstOrDefault(property => - property.Id.Equals(HtmlLoggerConstants.ParentExecutionIdPropertyIdentifier)); - return parentExecutionIdProperty == null - ? Guid.Empty - : testResult.GetPropertyValue(parentExecutionIdProperty, Guid.Empty); - } + var htmlFilePathMessage = string.Format(CultureInfo.CurrentCulture, HtmlResource.HtmlFilePath, HtmlFilePath); + EqtTrace.Info(htmlFilePathMessage); + ConsoleOutput.Instance.Information(false, htmlFilePathMessage); + } + + private string GetFilePath(string fileExtension, string fileName) + { + var fullFileFormat = $".{fileExtension}"; + return Path.Combine(TestResultsDirPath, string.Concat("TestResult_", fileName, fullFileFormat)); + } + + private string FormatDateTimeForRunName(DateTime timeStamp) + { + return timeStamp.ToString("yyyyMMdd_HHmmss", DateTimeFormatInfo.InvariantInfo); + } + + /// + /// Gives the parent execution id of a TestResult. + /// + /// + /// + private Guid GetParentExecutionId(TestPlatform.ObjectModel.TestResult testResult) + { + var parentExecutionIdProperty = testResult.Properties.FirstOrDefault(property => + property.Id.Equals(HtmlLoggerConstants.ParentExecutionIdPropertyIdentifier)); + return parentExecutionIdProperty == null + ? Guid.Empty + : testResult.GetPropertyValue(parentExecutionIdProperty, Guid.Empty); + } - /// - /// Gives the execution id of a TestResult. - /// - /// - /// - private Guid GetExecutionId(TestPlatform.ObjectModel.TestResult testResult) + /// + /// Gives the execution id of a TestResult. + /// + /// + /// + private Guid GetExecutionId(TestPlatform.ObjectModel.TestResult testResult) + { + var executionIdProperty = testResult.Properties.FirstOrDefault(property => + property.Id.Equals(HtmlLoggerConstants.ExecutionIdPropertyIdentifier)); + var executionId = Guid.Empty; + + if (executionIdProperty != null) { - var executionIdProperty = testResult.Properties.FirstOrDefault(property => - property.Id.Equals(HtmlLoggerConstants.ExecutionIdPropertyIdentifier)); - var executionId = Guid.Empty; + executionId = testResult.GetPropertyValue(executionIdProperty, Guid.Empty); + } - if (executionIdProperty != null) - { - executionId = testResult.GetPropertyValue(executionIdProperty, Guid.Empty); - } + return executionId.Equals(Guid.Empty) ? Guid.NewGuid() : executionId; + } - return executionId.Equals(Guid.Empty) ? Guid.NewGuid() : executionId; + /// + /// Converts the time span format to readable string. + /// + /// + /// + internal string GetFormattedDurationString(TimeSpan duration) + { + if (duration == default) + { + return null; } - /// - /// Converts the time span format to readable string. - /// - /// - /// - internal string GetFormattedDurationString(TimeSpan duration) + var time = new List(); + if (duration.Days > 0) + { + time.Add("> 1d"); + } + else { - if (duration == default(TimeSpan)) + if (duration.Hours > 0) { - return null; + time.Add(duration.Hours + "h"); } - var time = new List(); - if (duration.Days > 0) + if (duration.Minutes > 0) { - time.Add("> 1d"); + time.Add(duration.Minutes + "m"); } - else - { - if (duration.Hours > 0) - { - time.Add(duration.Hours + "h"); - } - if (duration.Minutes > 0) + if (duration.Hours == 0) + { + if (duration.Seconds > 0) { - time.Add(duration.Minutes + "m"); + time.Add(duration.Seconds + "s"); } - if (duration.Hours == 0) + if (duration.Milliseconds > 0 && duration.Minutes == 0) { - if (duration.Seconds > 0) - { - time.Add(duration.Seconds + "s"); - } - - if (duration.Milliseconds > 0 && duration.Minutes == 0) - { - time.Add(duration.Milliseconds + "ms"); - } + time.Add(duration.Milliseconds + "ms"); } } - - return time.Count == 0 ? "< 1ms" : string.Join(" ", time); } + + return time.Count == 0 ? "< 1ms" : string.Join(" ", time); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.HtmlLogger/HtmlTransformer.cs b/src/Microsoft.TestPlatform.Extensions.HtmlLogger/HtmlTransformer.cs index ffe5dd467e..eefef4e75f 100644 --- a/src/Microsoft.TestPlatform.Extensions.HtmlLogger/HtmlTransformer.cs +++ b/src/Microsoft.TestPlatform.Extensions.HtmlLogger/HtmlTransformer.cs @@ -3,33 +3,32 @@ using System; -namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger +namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger; + +using System.Xml; +using System.Xml.Xsl; + +/// +/// Html transformer transforms the xml file to html file using xslt file. +/// +internal class HtmlTransformer : IHtmlTransformer { - using System.Xml; - using System.Xml.Xsl; + private readonly XslCompiledTransform _xslTransform; /// - /// Html transformer transforms the xml file to html file using xslt file. + /// The following function invokes the compiled transform and Loads the xslt file. /// - internal class HtmlTransformer : IHtmlTransformer + public HtmlTransformer() { - private readonly XslCompiledTransform xslTransform; - - /// - /// The following function invokes the compiled transform and Loads the xslt file. - /// - public HtmlTransformer() - { - xslTransform = new XslCompiledTransform(); - xslTransform.Load(XmlReader.Create(this.GetType().Assembly.GetManifestResourceStream("Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger.Html.xslt") ?? throw new InvalidOperationException())); - } + _xslTransform = new XslCompiledTransform(); + _xslTransform.Load(XmlReader.Create(GetType().Assembly.GetManifestResourceStream("Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger.Html.xslt") ?? throw new InvalidOperationException())); + } - /// - /// It transforms the xml file to html file. - /// - public void Transform(string xmlFile, string htmlFile) - { - xslTransform.Transform(xmlFile, htmlFile); - } + /// + /// It transforms the xml file to html file. + /// + public void Transform(string xmlFile, string htmlFile) + { + _xslTransform.Transform(xmlFile, htmlFile); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.HtmlLogger/IHtmlTransformer.cs b/src/Microsoft.TestPlatform.Extensions.HtmlLogger/IHtmlTransformer.cs index 225c56190d..ae92d91812 100644 --- a/src/Microsoft.TestPlatform.Extensions.HtmlLogger/IHtmlTransformer.cs +++ b/src/Microsoft.TestPlatform.Extensions.HtmlLogger/IHtmlTransformer.cs @@ -1,15 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger +namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger; + +public interface IHtmlTransformer { - public interface IHtmlTransformer - { - /// - /// It transforms the xml file to html file. - /// - /// - /// - void Transform(string xmlFile, string htmlFile); - } + /// + /// It transforms the xml file to html file. + /// + /// + /// + void Transform(string xmlFile, string htmlFile); } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/HtmlTestResult.cs b/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/HtmlTestResult.cs index ddb996abdd..800406267f 100644 --- a/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/HtmlTestResult.cs +++ b/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/HtmlTestResult.cs @@ -3,56 +3,56 @@ using System.Runtime.Serialization; -namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger.ObjectModel; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.Collections.Generic; + +/// +/// Test results stores the relevant information to show on html file +/// +[DataContract] +public class TestResult { - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using System; - using System.Collections.Generic; - - /// - /// Test results stores the relevant information to show on html file - /// - [DataContract] - public class TestResult - { - /// - /// Fully qualified name of the Test Result. - /// - [DataMember] public string FullyQualifiedName { get; set; } - - /// - /// Unique identifier for test result - /// - [DataMember] public Guid TestResultId { get; set; } - - /// - /// Display Name for the particular Test Result - /// - [DataMember] public string DisplayName { get; set; } - - /// - /// The error stack trace of the Test Result. - /// - [DataMember] public string ErrorStackTrace { get; set; } - - /// - /// Error message of the Test Result. - /// - [DataMember] public string ErrorMessage { get; set; } - - /// - /// Enum that determines the outcome of the test case - /// - [DataMember] public TestOutcome ResultOutcome { get; set; } - - /// - /// Total timespan of the TestResult - /// - [DataMember] public string Duration { get; set; } - - /// - /// The list of TestResults that are children to the current Test Result. - /// - [DataMember] public List InnerTestResults { get; set; } - } -} + /// + /// Fully qualified name of the Test Result. + /// + [DataMember] public string FullyQualifiedName { get; set; } + + /// + /// Unique identifier for test result + /// + [DataMember] public Guid TestResultId { get; set; } + + /// + /// Display Name for the particular Test Result + /// + [DataMember] public string DisplayName { get; set; } + + /// + /// The error stack trace of the Test Result. + /// + [DataMember] public string ErrorStackTrace { get; set; } + + /// + /// Error message of the Test Result. + /// + [DataMember] public string ErrorMessage { get; set; } + + /// + /// Enum that determines the outcome of the test case + /// + [DataMember] public TestOutcome ResultOutcome { get; set; } + + /// + /// Total timespan of the TestResult + /// + [DataMember] public string Duration { get; set; } + + /// + /// The list of TestResults that are children to the current Test Result. + /// + [DataMember] public List InnerTestResults { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/TestResultCollection.cs b/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/TestResultCollection.cs index b4b5d2ad4a..6351d816fe 100644 --- a/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/TestResultCollection.cs +++ b/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/TestResultCollection.cs @@ -1,48 +1,49 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger.ObjectModel; + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; + +/// +/// Stores the list of failed results and list of all results corresponding to the source. +/// +[DataContract] +public class TestResultCollection { - using System; - using System.Collections.Generic; - using System.Runtime.Serialization; + private readonly string _source; + + public TestResultCollection(string source) => _source = source ?? throw new ArgumentNullException(nameof(source)); + + /// + /// Source of the test dll. + /// + [DataMember] + public string Source + { + get => _source; + private set { } + } /// - /// Stores the list of failed results and list of all results corresponding to the source. + /// Hash id of source. /// - [DataContract] - public class TestResultCollection + [DataMember] + public int Id { - private readonly string source; - - public TestResultCollection(string source) => this.source = source ?? throw new ArgumentNullException(nameof(source)); - - /// - /// Source of the test dll. - /// - [DataMember] public string Source - { - get => this.source; - private set { } - } - - /// - /// Hash id of source. - /// - [DataMember] public int Id - { - get => this.source.GetHashCode(); - private set { } - } - - /// - /// List of test results. - /// - [DataMember] public List ResultList { get; set; } - - /// - /// List of failed test results. - /// - [DataMember] public List FailedResultList { get; set; } + get => _source.GetHashCode(); + private set { } } -} + + /// + /// List of test results. + /// + [DataMember] public List ResultList { get; set; } + + /// + /// List of failed test results. + /// + [DataMember] public List FailedResultList { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/TestRunDetails.cs b/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/TestRunDetails.cs index fd724e922d..987028f2f4 100644 --- a/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/TestRunDetails.cs +++ b/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/TestRunDetails.cs @@ -1,35 +1,34 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger.ObjectModel -{ - using System.Collections.Generic; - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger.ObjectModel; + +using System.Collections.Generic; +using System.Runtime.Serialization; +/// +/// It stores the all relevant information of the test run. +/// +[DataContract] +public sealed class TestRunDetails +{ /// - /// It stores the all relevant information of the test run. + /// Test run summary of all test results. /// - [DataContract] - public sealed class TestRunDetails - { - /// - /// Test run summary of all test results. - /// - [DataMember] public TestRunSummary Summary { get; set; } + [DataMember] public TestRunSummary Summary { get; set; } - /// - /// List of informational run level messages. - /// - [DataMember] public List RunLevelMessageInformational; + /// + /// List of informational run level messages. + /// + [DataMember] public List RunLevelMessageInformational; - /// - /// List of error and warning messages. - /// - [DataMember] public List RunLevelMessageErrorAndWarning; + /// + /// List of error and warning messages. + /// + [DataMember] public List RunLevelMessageErrorAndWarning; - /// - /// List of all the results - /// - [DataMember] public List ResultCollectionList = new List(); - } -} + /// + /// List of all the results + /// + [DataMember] public List ResultCollectionList = new(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/TestRunSummary.cs b/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/TestRunSummary.cs index fdd693946f..8911cf0163 100644 --- a/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/TestRunSummary.cs +++ b/src/Microsoft.TestPlatform.Extensions.HtmlLogger/ObjectModel/TestRunSummary.cs @@ -3,42 +3,41 @@ using System.Runtime.Serialization; -namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger.ObjectModel; + +/// +/// Test run summary collects the relevant summary information. +/// +[DataContract] +public class TestRunSummary { /// - /// Test run summary collects the relevant summary information. + /// Indicates the pass percentage + /// + [DataMember] public int PassPercentage { get; set; } + + /// + /// Total test run time. + /// + [DataMember] public string TotalRunTime { get; set; } + + /// + /// Total tests of a test run. + /// + [DataMember] public int TotalTests { get; set; } + + /// + /// Passed tests of test run. + /// + [DataMember] public int PassedTests { get; set; } + + /// + /// Failed Tests of test run. + /// + [DataMember] public int FailedTests { get; set; } + + /// + /// Skipped Tests of test run. /// - [DataContract] - public class TestRunSummary - { - /// - /// Indicates the pass percentage - /// - [DataMember] public int PassPercentage { get; set; } - - /// - /// Total test run time. - /// - [DataMember] public string TotalRunTime { get; set; } - - /// - /// Total tests of a test run. - /// - [DataMember] public int TotalTests { get; set; } - - /// - /// Passed tests of test run. - /// - [DataMember] public int PassedTests { get; set; } - - /// - /// Failed Tests of test run. - /// - [DataMember] public int FailedTests { get; set; } - - /// - /// Skipped Tests of test run. - /// - [DataMember] public int SkippedTests { get; set; } - } + [DataMember] public int SkippedTests { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/IDataAttachment.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/IDataAttachment.cs index cae4bcd6c8..e068ef2c59 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/IDataAttachment.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/IDataAttachment.cs @@ -1,16 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +/// +/// Interface used to define a data attachment. +/// +internal interface IDataAttachment { /// - /// Interface used to define a data attachment. + /// Gets the description for the attachment. /// - internal interface IDataAttachment - { - /// - /// Gets the description for the attachment. - /// - string Description { get; } - } -} + string Description { get; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/ITestAggregation.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/ITestAggregation.cs index 8a5b372067..01d3aa29e0 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/ITestAggregation.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/ITestAggregation.cs @@ -1,13 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel -{ - using System; - using System.Collections.Generic; +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System; +using System.Collections.Generic; - internal interface ITestAggregation : ITestElement - { - Dictionary TestLinks { get; } - } -} +internal interface ITestAggregation : ITestElement +{ + Dictionary TestLinks { get; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/ITestElement.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/ITestElement.cs index 39121ae3e0..f4dd7fa834 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/ITestElement.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/ITestElement.cs @@ -1,22 +1,21 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +internal interface ITestElement { - internal interface ITestElement - { - TestId Id { get; } - string Name { get; set; } - string Owner { get; set; } - string Storage { get; set; } - string Adapter { get; } - int Priority { get; set; } - bool IsRunnable { get; } - TestExecId ExecutionId { get; set; } - TestExecId ParentExecutionId { get; set; } - TestListCategoryId CategoryId { get; set; } - TestCategoryItemCollection TestCategories { get; } - WorkItemCollection WorkItems { get; set; } - TestType TestType { get; } - } -} + TestId Id { get; } + string Name { get; set; } + string Owner { get; set; } + string Storage { get; set; } + string Adapter { get; } + int Priority { get; set; } + bool IsRunnable { get; } + TestExecId ExecutionId { get; set; } + TestExecId ParentExecutionId { get; set; } + TestListCategoryId CategoryId { get; set; } + TestCategoryItemCollection TestCategories { get; } + WorkItemCollection WorkItems { get; set; } + TestType TestType { get; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/ITestResult.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/ITestResult.cs index f1242fb377..a6f4e72420 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/ITestResult.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/ITestResult.cs @@ -1,27 +1,26 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel -{ - using System; +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System; - internal interface ITestResult - { - TestResultId Id { get; } - string ResultType { get; set; } - string StdOut { get; set; } - string StdErr { get; set; } - string DebugTrace { get; set; } - string TestResultsDirectory { get; } - string RelativeTestResultsDirectory { get; } - string ErrorMessage { get; set; } - string ErrorStackTrace { get; set; } - string ComputerName { get; } - string[] TextMessages { get; set; } - int DataRowInfo { get; set; } - DateTime StartTime { get; set; } - DateTime EndTime { get; set; } - TimeSpan Duration { get; set; } - TestOutcome Outcome { get; set; } - } -} +internal interface ITestResult +{ + TestResultId Id { get; } + string ResultType { get; set; } + string StdOut { get; set; } + string StdErr { get; set; } + string DebugTrace { get; set; } + string TestResultsDirectory { get; } + string RelativeTestResultsDirectory { get; } + string ErrorMessage { get; set; } + string ErrorStackTrace { get; set; } + string ComputerName { get; } + string[] TextMessages { get; set; } + int DataRowInfo { get; set; } + DateTime StartTime { get; set; } + DateTime EndTime { get; set; } + TimeSpan Duration { get; set; } + TestOutcome Outcome { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/ITestResultAggregation.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/ITestResultAggregation.cs index 7ee85e3e4c..aff36b1f59 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/ITestResultAggregation.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/ITestResultAggregation.cs @@ -1,12 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel -{ - using System.Collections.Generic; +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System.Collections.Generic; - internal interface ITestResultAggregation : ITestResult - { - List InnerResults { get; } - } -} +internal interface ITestResultAggregation : ITestResult +{ + List InnerResults { get; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/IXmlTestStore.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/IXmlTestStore.cs index cb020b977d..21985c9619 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/IXmlTestStore.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/IXmlTestStore.cs @@ -1,21 +1,20 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel -{ - using System.Xml; +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System.Xml; +/// +/// Implementing this interface indicates a custom persistence logic is provided. +/// The attribute based persistence is ignored in such a case. +/// +internal interface IXmlTestStore +{ /// - /// Implementing this interface indicates a custom persistence logic is provided. - /// The attribute based persistence is ignored in such a case. + /// Saves the class under the XmlElement. /// - internal interface IXmlTestStore - { - /// - /// Saves the class under the XmlElement. - /// - /// XmlElement element - /// XmlTestStoreParameters parameters - void Save(XmlElement element, XmlTestStoreParameters parameters); - } -} + /// XmlElement element + /// XmlTestStoreParameters parameters + void Save(XmlElement element, XmlTestStoreParameters parameters); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/IXmlTestStoreCustom.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/IXmlTestStoreCustom.cs index 7ff25b9fc0..fae7c15218 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/IXmlTestStoreCustom.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/IXmlTestStoreCustom.cs @@ -1,24 +1,19 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.XML +namespace Microsoft.TestPlatform.Extensions.TrxLogger.XML; +/// +/// Implementing this interface allows you to customize XmlStore persistence. +/// +internal interface IXmlTestStoreCustom { - using System.Diagnostics.CodeAnalysis; - /// - /// Implementing this interface allows you to customize XmlStore persistence. + /// Gets the name of the tag to use to persist this object. /// - internal interface IXmlTestStoreCustom - { - /// - /// Gets the name of the tag to use to persist this object. - /// - string ElementName { get; } + string ElementName { get; } - /// - /// Gets the xml namespace to use when creating the element - /// - [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "Reviewed. Suppression is OK here.")] - string NamespaceUri { get; } - } -} + /// + /// Gets the xml namespace to use when creating the element + /// + string NamespaceUri { get; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/XmlTestStoreParameters.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/XmlTestStoreParameters.cs index f89b6e93ea..d4992ef72d 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/XmlTestStoreParameters.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/XmlTestStoreParameters.cs @@ -1,49 +1,46 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System.Collections.Generic; + +/// +/// Optional parameters to the persistence process. A class implementing IPersistable can +/// use the parameter values to alter its load/save behavior. +/// +/// +/// Example: a class has a summary and details fields. Details are large, so they're only +/// saved when 'MyClass.SaveDetails' parameter is set to 'true'. +/// +internal sealed class XmlTestStoreParameters : Dictionary { - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; + private XmlTestStoreParameters() + { + } /// - /// Optional parameters to the persistence process. A class implementing IPersistable can - /// use the parameter values to alter its load/save behavior. + /// To create XmlTestStoreParameters object /// - /// - /// Example: a class has a summary and details fields. Details are large, so they're only - /// saved when 'MyClass.SaveDetails' parameter is set to 'true'. - /// - [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is ok here.")] - internal sealed class XmlTestStoreParameters : Dictionary + /// + /// The . + /// + public static XmlTestStoreParameters GetParameters() { - private XmlTestStoreParameters() - { - } - - /// - /// To create XmlTestStoreParameters object - /// - /// - /// The . - /// - public static XmlTestStoreParameters GetParameters() - { - return new XmlTestStoreParameters(); - } + return new XmlTestStoreParameters(); + } - /// - /// Check for the parameter - /// - /// - /// The parameter. - /// - /// - /// The . - /// - public bool Contains(string parameter) - { - return this.ContainsKey(parameter); - } + /// + /// Check for the parameter + /// + /// + /// The parameter. + /// + /// + /// The . + /// + public bool Contains(string parameter) + { + return ContainsKey(parameter); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/CollectorDataEntry.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/CollectorDataEntry.cs index d07a0e2e03..d062290801 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/CollectorDataEntry.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/CollectorDataEntry.cs @@ -1,240 +1,238 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Xml; + +using Utility; + +using XML; + +/// +/// Data entry from a collector along with information what this collector is and what agent it was collected on. +/// Instances are created by Agent and sent to Controller. Then controller puts agent names in. +/// The user is not supposed to create instances of this. +/// +internal class CollectorDataEntry : IXmlTestStore { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Xml; + #region Private Fields + + /// + /// List of data attachments. These attachments can be things such as files that the + /// collector wants to make available to the publishers. + /// + private readonly List _attachments; - using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; + /// + /// Name of the agent from which we received the data + /// + private string _agentName; /// - /// Data entry from a collector along with information what this collector is and what agent it was collected on. - /// Instances are created by Agent and sent to Controller. Then controller puts agent names in. - /// The user is not supposed to create instances of this. + /// Display name of the agent from which we received the data /// - internal class CollectorDataEntry : IXmlTestStore + private string _agentDisplayName; + + /// + /// Flag indicating whether this data is coming from a remote (not hosted) agent + /// + private bool _isFromRemoteAgent; + + /// + /// URI of the collector. + /// + private Uri _uri; + + /// + /// Name of the collector that should be displayed to the user. + /// + private string _collectorDisplayName; + + #endregion + + #region Constructor + + /// + /// Used by the aggregator to put collector Uri, agentName, string agentDisplayName, whether it's remote data, and + /// Attachments. + /// + /// + /// The uri. + /// + /// + /// The collector Display Name. + /// + /// + /// The agent Name. + /// + /// + /// The agent Display Name. + /// + /// + /// Is From Remote Agent. + /// + /// + /// The attachments. + /// + public CollectorDataEntry(Uri uri, string collectorDisplayName, string agentName, string agentDisplayName, bool isFromRemoteAgent, IList attachments) + : this() { - #region Private Fields - - /// - /// List of data attachments. These attachments can be things such as files that the - /// collector wants to make available to the publishers. - /// - private readonly List attachments; - - /// - /// Name of the agent from which we received the data - /// - private string agentName; - - /// - /// Display name of the agent from which we received the data - /// - private string agentDisplayName; - - /// - /// Flag indicating whether this data is coming from a remote (not hosted) agent - /// - private bool isFromRemoteAgent; - - /// - /// URI of the collector. - /// - private Uri uri; - - /// - /// Name of the collector that should be displayed to the user. - /// - private string collectorDisplayName; - - #endregion - - #region Constructor - - /// - /// Used by the aggregator to put collector Uri, agentName, string agentDisplayName, whether it's remote data, and - /// Attachments. - /// - /// - /// The uri. - /// - /// - /// The collector Display Name. - /// - /// - /// The agent Name. - /// - /// - /// The agent Display Name. - /// - /// - /// Is From Remote Agent. - /// - /// - /// The attachments. - /// - public CollectorDataEntry(Uri uri, string collectorDisplayName, string agentName, string agentDisplayName, bool isFromRemoteAgent, IList attachments) - : this() - { - this.Initialize(uri, collectorDisplayName, agentName, agentDisplayName, isFromRemoteAgent, attachments); - } + Initialize(uri, collectorDisplayName, agentName, agentDisplayName, isFromRemoteAgent, attachments); + } - /// - /// Initializes a new instance of the class. - /// - /// - /// For XML persistence - /// - internal CollectorDataEntry() - { - this.attachments = new List(); - } + /// + /// Initializes a new instance of the class. + /// + /// + /// For XML persistence + /// + internal CollectorDataEntry() + { + _attachments = new List(); + } - /// - /// Copies the specified collector data entry, making the paths in the data attachments absolute or relative, with - /// respect to the results directory - /// - /// The instance to copy from - /// The results directory to use to make paths in the data attachments relative or absolute - /// True to use absolute paths in this instance, false to use relative paths - private CollectorDataEntry(CollectorDataEntry other, string resultsDirectory, bool useAbsolutePaths) - { - Debug.Assert(other != null, "'other' is null"); - Debug.Assert(other.attachments != null, "'other.m_attachments' is null"); - Debug.Assert(!string.IsNullOrEmpty(resultsDirectory), "'resultsDirectory' is null or empty"); + /// + /// Copies the specified collector data entry, making the paths in the data attachments absolute or relative, with + /// respect to the results directory + /// + /// The instance to copy from + /// The results directory to use to make paths in the data attachments relative or absolute + /// True to use absolute paths in this instance, false to use relative paths + private CollectorDataEntry(CollectorDataEntry other, string resultsDirectory, bool useAbsolutePaths) + { + Debug.Assert(other != null, "'other' is null"); + Debug.Assert(other._attachments != null, "'other.m_attachments' is null"); + Debug.Assert(!string.IsNullOrEmpty(resultsDirectory), "'resultsDirectory' is null or empty"); + + _attachments = new List(other._attachments.Count); + Initialize(other._uri, other._collectorDisplayName, other._agentName, other._agentDisplayName, other._isFromRemoteAgent, null); - this.attachments = new List(other.attachments.Count); - this.Initialize(other.uri, other.collectorDisplayName, other.agentName, other.agentDisplayName, other.isFromRemoteAgent, null); + // Clone the attachments + foreach (IDataAttachment attachment in other._attachments) + { + Debug.Assert(attachment != null, "'attachment' is null"); - // Clone the attachments - foreach (IDataAttachment attachment in other.attachments) + if (attachment is UriDataAttachment uriDataAttachment) + { + _attachments.Add(uriDataAttachment.Clone(resultsDirectory, useAbsolutePaths)); + } + else { - Debug.Assert(attachment != null, "'attachment' is null"); - - UriDataAttachment uriDataAttachment = attachment as UriDataAttachment; - if (uriDataAttachment != null) - { - this.attachments.Add(uriDataAttachment.Clone(resultsDirectory, useAbsolutePaths)); - } - else - { - this.attachments.Add(attachment); - } + _attachments.Add(attachment); } } + } - #endregion + #endregion - #region Public Properties + #region Public Properties - /// - /// Gets the read-only list of data attachments - /// - public IList Attachments + /// + /// Gets the read-only list of data attachments + /// + public IList Attachments + { + get { - get - { - return this.attachments.AsReadOnly(); - } + return _attachments.AsReadOnly(); } + } - #endregion + #endregion - #region IXmlTestStore Members + #region IXmlTestStore Members - /// - /// Saves the state to the XML element - /// - /// The XML element to save to - /// Parameters to customize the save behavior - public void Save(XmlElement element, XmlTestStoreParameters parameters) - { - EqtAssert.ParameterNotNull(element, nameof(element)); + /// + /// Saves the state to the XML element + /// + /// The XML element to save to + /// Parameters to customize the save behavior + public void Save(XmlElement element, XmlTestStoreParameters parameters) + { + EqtAssert.ParameterNotNull(element, nameof(element)); - XmlPersistence helper = new XmlPersistence(); - helper.SaveSimpleField(element, "@agentName", this.agentName, null); - helper.SaveSimpleField(element, "@agentDisplayName", this.agentDisplayName, this.agentName); - helper.SaveSimpleField(element, "@isFromRemoteAgent", this.isFromRemoteAgent, false); - helper.SaveSimpleField(element, "@uri", this.uri.AbsoluteUri, null); - helper.SaveSimpleField(element, "@collectorDisplayName", this.collectorDisplayName, string.Empty); + XmlPersistence helper = new(); + helper.SaveSimpleField(element, "@agentName", _agentName, null); + helper.SaveSimpleField(element, "@agentDisplayName", _agentDisplayName, _agentName); + helper.SaveSimpleField(element, "@isFromRemoteAgent", _isFromRemoteAgent, false); + helper.SaveSimpleField(element, "@uri", _uri.AbsoluteUri, null); + helper.SaveSimpleField(element, "@collectorDisplayName", _collectorDisplayName, string.Empty); - IList uriAttachments = new List(); - foreach (IDataAttachment attachment in this.Attachments) + IList uriAttachments = new List(); + foreach (IDataAttachment attachment in Attachments) + { + if (attachment is UriDataAttachment uriAtt) { - UriDataAttachment uriAtt = attachment as UriDataAttachment; - if (uriAtt != null) - { - uriAttachments.Add(uriAtt); - } + uriAttachments.Add(uriAtt); } - - helper.SaveIEnumerable(uriAttachments, element, "UriAttachments", "A", "UriAttachment", parameters); } - #endregion + helper.SaveIEnumerable(uriAttachments, element, "UriAttachments", "A", "UriAttachment", parameters); + } - #region Internal Methods + #endregion - /// - /// Adds a data attachment to the list of data attachments - /// - /// The attachment to add - internal void AddAttachment(IDataAttachment attachment) - { - if (attachment == null) - { - throw new ArgumentNullException(nameof(attachment)); - } + #region Internal Methods - this.attachments.Add(attachment); + /// + /// Adds a data attachment to the list of data attachments + /// + /// The attachment to add + internal void AddAttachment(IDataAttachment attachment) + { + if (attachment == null) + { + throw new ArgumentNullException(nameof(attachment)); } - /// - /// Clones the instance and attachments, with file paths in file attachments absolute or relative as specified - /// - /// The results directory to use to make paths in the data attachments relative or absolute - /// True to use absolute paths in this instance, false to use relative paths - /// A clone of the instance containing cloned attachments with file paths made absolute or relative - internal CollectorDataEntry Clone(string resultsDirectory, bool useAbsolutePaths) - { - Debug.Assert(!string.IsNullOrEmpty(resultsDirectory), "'resultsDirectory' is null or empty"); - Debug.Assert(resultsDirectory == resultsDirectory.Trim(), "'resultsDirectory' contains whitespace at the ends"); + _attachments.Add(attachment); + } - return new CollectorDataEntry(this, resultsDirectory, useAbsolutePaths); - } + /// + /// Clones the instance and attachments, with file paths in file attachments absolute or relative as specified + /// + /// The results directory to use to make paths in the data attachments relative or absolute + /// True to use absolute paths in this instance, false to use relative paths + /// A clone of the instance containing cloned attachments with file paths made absolute or relative + internal CollectorDataEntry Clone(string resultsDirectory, bool useAbsolutePaths) + { + Debug.Assert(!string.IsNullOrEmpty(resultsDirectory), "'resultsDirectory' is null or empty"); + Debug.Assert(resultsDirectory == resultsDirectory.Trim(), "'resultsDirectory' contains whitespace at the ends"); - #endregion + return new CollectorDataEntry(this, resultsDirectory, useAbsolutePaths); + } - #region Private Methods + #endregion - private void Initialize(Uri uri, string collectorDisplayName, string agentName, string agentDisplayName, bool isFromRemoteAgent, IEnumerable attachments) - { - EqtAssert.ParameterNotNull(uri, nameof(uri)); - EqtAssert.StringNotNullOrEmpty(collectorDisplayName, nameof(collectorDisplayName)); - EqtAssert.StringNotNullOrEmpty(agentName, nameof(agentName)); - EqtAssert.StringNotNullOrEmpty(agentDisplayName, nameof(agentDisplayName)); + #region Private Methods - if (null != attachments) + private void Initialize(Uri uri, string collectorDisplayName, string agentName, string agentDisplayName, bool isFromRemoteAgent, IEnumerable attachments) + { + EqtAssert.ParameterNotNull(uri, nameof(uri)); + EqtAssert.StringNotNullOrEmpty(collectorDisplayName, nameof(collectorDisplayName)); + EqtAssert.StringNotNullOrEmpty(agentName, nameof(agentName)); + EqtAssert.StringNotNullOrEmpty(agentDisplayName, nameof(agentDisplayName)); + + if (null != attachments) + { + // Copy the attachments + foreach (IDataAttachment attachment in attachments) { - // Copy the attachments - foreach (IDataAttachment attachment in attachments) - { - this.AddAttachment(attachment); - } + AddAttachment(attachment); } - - // Note that the data can be null. - this.uri = uri; - this.collectorDisplayName = collectorDisplayName; - this.agentName = agentName.Trim(); - this.agentDisplayName = agentDisplayName.Trim(); - this.isFromRemoteAgent = isFromRemoteAgent; } - #endregion + // Note that the data can be null. + _uri = uri; + _collectorDisplayName = collectorDisplayName; + _agentName = agentName.Trim(); + _agentDisplayName = agentDisplayName.Trim(); + _isFromRemoteAgent = isFromRemoteAgent; } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/OrderedTestElement.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/OrderedTestElement.cs index 907b14bc6d..0592665926 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/OrderedTestElement.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/OrderedTestElement.cs @@ -1,35 +1,36 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System; + +using Utility; + +using XML; + +/// +/// Ordered test element. +/// +internal class OrderedTestElement : TestElementAggregation, IXmlTestStoreCustom { - using System; - using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; + public OrderedTestElement(Guid id, string name, string adapter) : base(id, name, adapter) { } + + string IXmlTestStoreCustom.ElementName + { + get { return Constants.OrderedTestElementName; } + } + + string IXmlTestStoreCustom.NamespaceUri + { + get { return null; } + } /// - /// Ordered test element. + /// Gets the test type. /// - internal class OrderedTestElement : TestElementAggregation, IXmlTestStoreCustom + public override TestType TestType { - public OrderedTestElement(Guid id, string name, string adapter) : base(id, name, adapter) { } - - string IXmlTestStoreCustom.ElementName - { - get { return Constants.OrderedTestElementName; } - } - - string IXmlTestStoreCustom.NamespaceUri - { - get { return null; } - } - - /// - /// Gets the test type. - /// - public override TestType TestType - { - get { return Constants.OrderedTestType; } - } + get { return Constants.OrderedTestType; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/RunInfo.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/RunInfo.cs index 8318c7a16a..b6913ae6a2 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/RunInfo.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/RunInfo.cs @@ -1,85 +1,84 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System; +using System.Diagnostics; +using System.Xml; + +using XML; + +/// +/// This is a record about one run-level event that happened at run execution or around it. +/// +internal sealed class RunInfo : IXmlTestStore { - using System; - using System.Diagnostics; - using System.Xml; + #region Fields + + [StoreXmlSimpleField("Text", "")] + private readonly string _text; + + private readonly Exception _exception; + + [StoreXmlSimpleField("@computerName", "")] + private readonly string _computer; + + [StoreXmlSimpleField("@outcome")] + private readonly TestOutcome _outcome; + + [StoreXmlSimpleField("@timestamp")] + private readonly DateTime _timestamp; + + #endregion - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; + #region Constructors /// - /// This is a record about one run-level event that happened at run execution or around it. + /// Initializes a new instance of the class. /// - internal sealed class RunInfo : IXmlTestStore + /// + /// The text message. + /// + /// + /// The exception + /// + /// + /// The computer. + /// + /// + /// The outcome. + /// + public RunInfo(string textMessage, Exception ex, string computer, TestOutcome outcome) { - #region Fields - - [StoreXmlSimpleField("Text", "")] - private string text; - - private Exception exception; - - [StoreXmlSimpleField("@computerName", "")] - private string computer; - - [StoreXmlSimpleField("@outcome")] - private TestOutcome outcome; - - [StoreXmlSimpleField] - private DateTime timestamp; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// - /// The text message. - /// - /// - /// The exception - /// - /// - /// The computer. - /// - /// - /// The outcome. - /// - public RunInfo(string textMessage, Exception ex, string computer, TestOutcome outcome) - { - Debug.Assert(computer != null, "computer is null"); - - this.text = textMessage; - this.exception = ex; - this.computer = computer; - this.outcome = outcome; - this.timestamp = DateTime.UtcNow; - } - - #endregion - - #region IXmlTestStore Members - - /// - /// Saves the class under the XmlElement.. - /// - /// - /// The parent xml. - /// - /// - /// The parameters. - /// - public void Save(XmlElement element, XmlTestStoreParameters parameters) - { - XmlPersistence helper = new XmlPersistence(); - helper.SaveSingleFields(element, this, parameters); - helper.SaveSimpleField(element, "Exception", this.exception, null); - } - - #endregion + Debug.Assert(computer != null, "computer is null"); + + _text = textMessage; + _exception = ex; + _computer = computer; + _outcome = outcome; + _timestamp = DateTime.UtcNow; } -} + + #endregion + + #region IXmlTestStore Members + + /// + /// Saves the class under the XmlElement.. + /// + /// + /// The parent xml. + /// + /// + /// The parameters. + /// + public void Save(XmlElement element, XmlTestStoreParameters parameters) + { + XmlPersistence helper = new(); + helper.SaveSingleFields(element, this, parameters); + helper.SaveSimpleField(element, "Exception", _exception, null); + } + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestCategoryItems.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestCategoryItems.cs index 8d10ecdf3c..7d1dec415a 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestCategoryItems.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestCategoryItems.cs @@ -1,268 +1,266 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System; +using System.Diagnostics; +using System.Text; + +using Utility; + +using XML; + +#region TestCategoryItem +/// +/// Stores a string which categorizes the Test +/// +internal sealed class TestCategoryItem : IXmlTestStore { - using System; - using System.Diagnostics; - using System.Text; + #region Fields + [StoreXmlSimpleField(Location = "@TestCategory", DefaultValue = "")] + private readonly string _category = string.Empty; - using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; + #endregion - #region TestCategoryItem + #region Constructors /// - /// Stores a string which categorizes the Test + /// Create a new item with the category set /// - internal sealed class TestCategoryItem : IXmlTestStore + /// The category. + public TestCategoryItem(string category) { - #region Fields - [StoreXmlSimpleField(Location = "@TestCategory", DefaultValue = "")] - private string category = string.Empty; - - #endregion - - #region Constructors - /// - /// Create a new item with the category set - /// - /// The category. - public TestCategoryItem(string category) + // Treat null as empty. + if (category == null) { - // Treat null as empty. - if (category == null) - { - category = String.Empty; - } + category = String.Empty; + } - this.category = this.StripIllegalChars(category); - } + _category = StripIllegalChars(category); + } - #endregion + #endregion - #region Properties/Methods - /// - /// Gets the category for this TestCategory - /// - public string TestCategory + #region Properties/Methods + /// + /// Gets the category for this TestCategory + /// + public string TestCategory + { + get { - get - { - return this.category; - } + return _category; } + } - private string StripIllegalChars(string category) - { - string ret = category.Trim(); - ret = ret.Replace("&", String.Empty); - ret = ret.Replace("|", String.Empty); - ret = ret.Replace("!", String.Empty); - ret = ret.Replace(",", String.Empty); - return ret; - } + private string StripIllegalChars(string category) + { + string ret = category.Trim(); + ret = ret.Replace("&", String.Empty); + ret = ret.Replace("|", String.Empty); + ret = ret.Replace("!", String.Empty); + ret = ret.Replace(",", String.Empty); + return ret; + } - #endregion + #endregion - #region Methods - overrides - /// - /// Compare the values of the items - /// - /// Value being compared to. - /// True if the values are the same and false otherwise. - public override bool Equals(object other) + #region Methods - overrides + /// + /// Compare the values of the items + /// + /// Value being compared to. + /// True if the values are the same and false otherwise. + public override bool Equals(object other) + { + if (other is not TestCategoryItem otherItem) { - TestCategoryItem otherItem = other as TestCategoryItem; - if (otherItem == null) - { - return false; - } - Debug.Assert(this.category != null, "category is null"); - return String.Equals(this.category, otherItem.category, StringComparison.OrdinalIgnoreCase); + return false; } + Debug.Assert(_category != null, "category is null"); + return String.Equals(_category, otherItem._category, StringComparison.OrdinalIgnoreCase); + } - /// - /// Convert the category name to a hashcode - /// - /// Hashcode of the category. - public override int GetHashCode() - { - Debug.Assert(this.category != null, "category is null"); - return this.category.ToUpperInvariant().GetHashCode(); - } + /// + /// Convert the category name to a hashcode + /// + /// Hashcode of the category. + public override int GetHashCode() + { + Debug.Assert(_category != null, "category is null"); + return _category.ToUpperInvariant().GetHashCode(); + } - /// - /// Convert the category name to a string - /// - /// The category. - public override string ToString() - { - Debug.Assert(this.category != null, "category is null"); - return this.category; - } - #endregion + /// + /// Convert the category name to a string + /// + /// The category. + public override string ToString() + { + Debug.Assert(_category != null, "category is null"); + return _category; + } + #endregion - #region IXmlTestStore Members + #region IXmlTestStore Members - /// - /// Saves the class under the XmlElement. - /// - /// XmlElement element - /// XmlTestStoreParameters parameters - public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) + /// + /// Saves the class under the XmlElement. + /// + /// XmlElement element + /// XmlTestStoreParameters parameters + public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) + { + new XmlPersistence().SaveSingleFields(element, this, parameters); + } + + #endregion +} +#endregion + +#region TestCategoryItemCollection +/// +/// A collection of strings which categorize the test. +/// +internal sealed class TestCategoryItemCollection : EqtBaseCollection +{ + #region Constructors + /// + /// Creates an empty TestCategoryItemCollection. + /// + public TestCategoryItemCollection() + { + } + + /// + /// Create a new TestCategoryItemCollection based on the string array. + /// + /// Add these items to the collection. + public TestCategoryItemCollection(string[] items) + { + EqtAssert.ParameterNotNull(items, nameof(items)); + foreach (string s in items) { - new XmlPersistence().SaveSingleFields(element, this, parameters); + Add(s); } - - #endregion } + #endregion - #region TestCategoryItemCollection + #region Methods + + /// + /// Adds the category. + /// + /// Category to be added. + public void Add(string item) + { + Add(new TestCategoryItem(item)); + } + /// - /// A collection of strings which categorize the test. + /// Adds the category. /// - internal sealed class TestCategoryItemCollection : EqtBaseCollection + /// Category to be added. + public override void Add(TestCategoryItem item) { - #region Constructors - /// - /// Creates an empty TestCategoryItemCollection. - /// - public TestCategoryItemCollection() + EqtAssert.ParameterNotNull(item, nameof(item)); + + // Don't add empty items. + if (!String.IsNullOrEmpty(item.TestCategory)) { + base.Add(item); } + } - /// - /// Create a new TestCategoryItemCollection based on the string array. - /// - /// Add these items to the collection. - public TestCategoryItemCollection(string[] items) + /// + /// Convert the TestCategoryItemCollection to a string. + /// each item is surrounded by a comma (,) + /// + /// + public override string ToString() + { + StringBuilder returnString = new(); + if (Count > 0) { - EqtAssert.ParameterNotNull(items, nameof(items)); - foreach (string s in items) + returnString.Append(","); + foreach (TestCategoryItem item in this) { - this.Add(s); + returnString.Append(item.TestCategory); + returnString.Append(","); } } - #endregion + return returnString.ToString(); + } - #region Methods + /// + /// Convert the TestCategoryItemCollection to an array of strings. + /// + /// Array of strings containing the test categories. + public string[] ToArray() + { + string[] result = new string[Count]; - /// - /// Adds the category. - /// - /// Category to be added. - public void Add(string item) + int i = 0; + foreach (TestCategoryItem item in this) { - this.Add(new TestCategoryItem(item)); + result[i++] = item.TestCategory; } - /// - /// Adds the category. - /// - /// Category to be added. - public override void Add(TestCategoryItem item) - { - EqtAssert.ParameterNotNull(item, nameof(item)); + return result; + } - // Don't add empty items. - if (!String.IsNullOrEmpty(item.TestCategory)) - { - base.Add(item); - } - } + /// + /// Compare the collection items + /// + /// other collection + /// true if the collections contain the same items + public override bool Equals(object obj) + { + bool result = false; - /// - /// Convert the TestCategoryItemCollection to a string. - /// each item is surrounded by a comma (,) - /// - /// - public override string ToString() + if (obj is not TestCategoryItemCollection other) { - StringBuilder returnString = new StringBuilder(); - if (this.Count > 0) - { - returnString.Append(","); - foreach (TestCategoryItem item in this) - { - returnString.Append(item.TestCategory); - returnString.Append(","); - } - } - - return returnString.ToString(); + // Other object is not a TestCategoryItemCollection. + result = false; } - - /// - /// Convert the TestCategoryItemCollection to an array of strings. - /// - /// Array of strings containing the test categories. - public string[] ToArray() + else if (ReferenceEquals(this, other)) { - string[] result = new string[this.Count]; - - int i = 0; - foreach (TestCategoryItem item in this) - { - result[i++] = item.TestCategory; - } - - return result; + // The other object is the same object as this one. + result = true; } - - /// - /// Compare the collection items - /// - /// other collection - /// true if the collections contain the same items - public override bool Equals(object obj) + else if (Count != other.Count) { - TestCategoryItemCollection other = obj as TestCategoryItemCollection; - bool result = false; - - if (other == null) - { - // Other object is not a TestCategoryItemCollection. - result = false; - } - else if (Object.ReferenceEquals(this, other)) - { - // The other object is the same object as this one. - result = true; - } - else if (this.Count != other.Count) - { - // The count of categories in the other object does not - // match this one, so they are not equal. - result = false; - } - else + // The count of categories in the other object does not + // match this one, so they are not equal. + result = false; + } + else + { + // Check each item and return on the first mismatch. + foreach (TestCategoryItem item in this) { - // Check each item and return on the first mismatch. - foreach (TestCategoryItem item in this) + if (!other.Contains(item)) { - if (!other.Contains(item)) - { - result = false; - break; - } + result = false; + break; } } - - return result; } - /// - /// Return the hash code of this collection - /// - /// The hashcode. - public override int GetHashCode() - { - return base.GetHashCode(); - } - #endregion + return result; + } + + /// + /// Return the hash code of this collection + /// + /// The hashcode. + public override int GetHashCode() + { + return base.GetHashCode(); } #endregion } +#endregion \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestElement.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestElement.cs index df809ad642..c6040f3a90 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestElement.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestElement.cs @@ -1,269 +1,268 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel -{ - using System; - using System.Diagnostics; - using System.Globalization; - using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; - using TrxLoggerResources = Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.Resources.TrxResource; +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System; +using System.Diagnostics; +using System.Globalization; + +using Utility; + +using XML; +using TrxLoggerResources = VisualStudio.TestPlatform.Extensions.TrxLogger.Resources.TrxResource; + +/// +/// Test element. +/// +internal abstract class TestElement : ITestElement, IXmlTestStore +{ /// - /// Test element. + /// Default priority for a test method that does not specify a priority /// - internal abstract class TestElement : ITestElement, IXmlTestStore + protected const int DefaultPriority = int.MaxValue; + + protected TestId _id; + protected string _name; + protected string _owner; + protected string _storage; + protected string _adapter; + protected int _priority; + protected bool _isRunnable; + protected TestExecId _executionId; + protected TestExecId _parentExecutionId; + protected TestCategoryItemCollection _testCategories; + protected WorkItemCollection _workItems; + protected TestListCategoryId _catId; + + public TestElement(Guid id, string name, string adapter) { - /// - /// Default priority for a test method that does not specify a priority - /// - protected const int DefaultPriority = int.MaxValue; - - protected TestId id; - protected string name; - protected string owner; - protected string storage; - protected string adapter; - protected int priority; - protected bool isRunnable; - protected TestExecId executionId; - protected TestExecId parentExecutionId; - protected TestCategoryItemCollection testCategories; - protected WorkItemCollection workItems; - protected TestListCategoryId catId; - - public TestElement(Guid id, string name, string adapter) - { - Debug.Assert(!string.IsNullOrEmpty(name), "name is null"); - Debug.Assert(!string.IsNullOrEmpty(adapter), "adapter is null"); + Debug.Assert(!string.IsNullOrEmpty(name), "name is null"); + Debug.Assert(!string.IsNullOrEmpty(adapter), "adapter is null"); - this.Initialize(); + Initialize(); - this.id = new TestId(id); - this.name = name; - this.adapter = adapter; - } - - /// - /// Gets the id. - /// - public TestId Id - { - get { return this.id; } - } + _id = new TestId(id); + _name = name; + _adapter = adapter; + } - /// - /// Gets or sets the name. - /// - public string Name - { - get { return this.name; } + /// + /// Gets the id. + /// + public TestId Id + { + get { return _id; } + } - set - { - EqtAssert.ParameterNotNull(value, "Name"); - this.name = value; - } - } + /// + /// Gets or sets the name. + /// + public string Name + { + get { return _name; } - /// - /// Gets or sets the owner. - /// - public string Owner + set { - get { return this.owner; } - - set - { - EqtAssert.ParameterNotNull(value, "Owner"); - this.owner = value; - } + EqtAssert.ParameterNotNull(value, "Name"); + _name = value; } + } - /// - /// Gets or sets the priority. - /// - public int Priority - { - get { return this.priority; } - set { this.priority = value; } - } + /// + /// Gets or sets the owner. + /// + public string Owner + { + get { return _owner; } - /// - /// Gets or sets the storage. - /// - public string Storage + set { - get { return this.storage; } - - set - { - EqtAssert.StringNotNullOrEmpty(value, "Storage"); - this.storage = value.ToLowerInvariant(); - } + EqtAssert.ParameterNotNull(value, "Owner"); + _owner = value; } + } - /// - /// Gets or sets the execution id. - /// - public TestExecId ExecutionId - { - get { return this.executionId; } - set { this.executionId = value; } - } + /// + /// Gets or sets the priority. + /// + public int Priority + { + get { return _priority; } + set { _priority = value; } + } - /// - /// Gets or sets the parent execution id. - /// - public TestExecId ParentExecutionId - { - get { return this.parentExecutionId; } - set { this.parentExecutionId = value; } - } + /// + /// Gets or sets the storage. + /// + public string Storage + { + get { return _storage; } - /// - /// Gets the isRunnable value. - /// - public bool IsRunnable + set { - get { return this.isRunnable; } + EqtAssert.StringNotNullOrEmpty(value, "Storage"); + _storage = value.ToLowerInvariant(); } + } - /// - /// Gets or sets the category id. - /// - /// - /// Instead of setting to null use TestListCategoryId.Uncategorized - /// - public TestListCategoryId CategoryId - { - get { return this.catId; } + /// + /// Gets or sets the execution id. + /// + public TestExecId ExecutionId + { + get { return _executionId; } + set { _executionId = value; } + } - set - { - EqtAssert.ParameterNotNull(value, "CategoryId"); - this.catId = value; - } - } + /// + /// Gets or sets the parent execution id. + /// + public TestExecId ParentExecutionId + { + get { return _parentExecutionId; } + set { _parentExecutionId = value; } + } - /// - /// Gets or sets the test categories. - /// - public TestCategoryItemCollection TestCategories - { - get { return this.testCategories; } + /// + /// Gets the isRunnable value. + /// + public bool IsRunnable + { + get { return _isRunnable; } + } - set - { - EqtAssert.ParameterNotNull(value, "value"); - this.testCategories = value; - } - } + /// + /// Gets or sets the category id. + /// + /// + /// Instead of setting to null use TestListCategoryId.Uncategorized + /// + public TestListCategoryId CategoryId + { + get { return _catId; } - /// - /// Gets or sets the work items. - /// - public WorkItemCollection WorkItems + set { - get { return this.workItems; } - - set - { - EqtAssert.ParameterNotNull(value, "value"); - this.workItems = value; - } + EqtAssert.ParameterNotNull(value, "CategoryId"); + _catId = value; } + } + + /// + /// Gets or sets the test categories. + /// + public TestCategoryItemCollection TestCategories + { + get { return _testCategories; } - /// - /// Gets the adapter name. - /// - public string Adapter + set { - get { return adapter; } + EqtAssert.ParameterNotNull(value, "value"); + _testCategories = value; } + } - /// - /// Gets the test type. - /// - public abstract TestType TestType { get; } + /// + /// Gets or sets the work items. + /// + public WorkItemCollection WorkItems + { + get { return _workItems; } - /// - /// Override for ToString. - /// - /// String representation of test element. - public override string ToString() + set { - return string.Format( - CultureInfo.InvariantCulture, - "'{0}' {1}", - this.name ?? TrxLoggerResources.Common_NullInMessages, - this.id != null ? this.id.ToString() : TrxLoggerResources.Common_NullInMessages); + EqtAssert.ParameterNotNull(value, "value"); + _workItems = value; } + } - /// - /// Override for Equals. - /// - /// - /// The object to compare. - /// - /// - /// The . - /// - public override bool Equals(object other) - { - TestElement otherTest = other as TestElement; - return (otherTest == null) ? - false : - this.id.Equals(otherTest.id); - } + /// + /// Gets the adapter name. + /// + public string Adapter + { + get { return _adapter; } + } - /// - /// Override for GetHashCode - /// - /// - /// The . - /// - public override int GetHashCode() - { - return this.id.GetHashCode(); - } + /// + /// Gets the test type. + /// + public abstract TestType TestType { get; } - public virtual void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) - { - XmlPersistence h = new XmlPersistence(); + /// + /// Override for ToString. + /// + /// String representation of test element. + public override string ToString() + { + return string.Format( + CultureInfo.InvariantCulture, + "'{0}' {1}", + _name ?? TrxLoggerResources.Common_NullInMessages, + _id != null ? _id.ToString() : TrxLoggerResources.Common_NullInMessages); + } + + /// + /// Override for Equals. + /// + /// + /// The object to compare. + /// + /// + /// The . + /// + public override bool Equals(object other) + { + return other is TestElement otherTest && _id.Equals(otherTest._id); + } - h.SaveSimpleField(element, "@name", this.name, null); - h.SaveSimpleField(element, "@storage", this.storage, string.Empty); - h.SaveSimpleField(element, "@priority", this.priority, DefaultPriority); - h.SaveSimpleField(element, "Owners/Owner/@name", this.owner, string.Empty); - h.SaveObject(this.testCategories, element, "TestCategory", parameters); + /// + /// Override for GetHashCode + /// + /// + /// The . + /// + public override int GetHashCode() + { + return _id.GetHashCode(); + } - if (this.executionId != null) - h.SaveGuid(element, "Execution/@id", this.executionId.Id); - if (this.parentExecutionId != null) - h.SaveGuid(element, "Execution/@parentId", this.parentExecutionId.Id); + public virtual void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) + { + XmlPersistence h = new(); - h.SaveObject(this.workItems, element, "Workitems", parameters); + h.SaveSimpleField(element, "@name", _name, null); + h.SaveSimpleField(element, "@storage", _storage, string.Empty); + h.SaveSimpleField(element, "@priority", _priority, DefaultPriority); + h.SaveSimpleField(element, "Owners/Owner/@name", _owner, string.Empty); + h.SaveObject(_testCategories, element, "TestCategory", parameters); - XmlTestStoreParameters testIdParameters = XmlTestStoreParameters.GetParameters(); - testIdParameters[TestId.IdLocationKey] = "@id"; - h.SaveObject(this.id, element, testIdParameters); - } + if (_executionId != null) + h.SaveGuid(element, "Execution/@id", _executionId.Id); + if (_parentExecutionId != null) + h.SaveGuid(element, "Execution/@parentId", _parentExecutionId.Id); - private void Initialize() - { - this.id = TestId.Empty; - this.name = string.Empty; - this.owner = string.Empty; - this.priority = DefaultPriority; - this.storage = string.Empty; - this.executionId = TestExecId.Empty; - this.parentExecutionId = TestExecId.Empty; - this.testCategories = new TestCategoryItemCollection(); - this.workItems = new WorkItemCollection(); - this.isRunnable = true; - this.catId = TestListCategoryId.Uncategorized; - } + h.SaveObject(_workItems, element, "Workitems", parameters); + + XmlTestStoreParameters testIdParameters = XmlTestStoreParameters.GetParameters(); + testIdParameters[TestId.IdLocationKey] = "@id"; + h.SaveObject(_id, element, testIdParameters); + } + + private void Initialize() + { + _id = TestId.Empty; + _name = string.Empty; + _owner = string.Empty; + _priority = DefaultPriority; + _storage = string.Empty; + _executionId = TestExecId.Empty; + _parentExecutionId = TestExecId.Empty; + _testCategories = new TestCategoryItemCollection(); + _workItems = new WorkItemCollection(); + _isRunnable = true; + _catId = TestListCategoryId.Uncategorized; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestElementAggregation.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestElementAggregation.cs index d814acaee6..f34c900c98 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestElementAggregation.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestElementAggregation.cs @@ -1,38 +1,38 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System; +using System.Collections.Generic; + +using XML; + +/// +/// Test aggregation element. +/// +internal abstract class TestElementAggregation : TestElement, ITestAggregation { - using System; - using System.Collections.Generic; - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; + protected Dictionary _testLinks = new(); + + public TestElementAggregation(Guid id, string name, string adapter) : base(id, name, adapter) { } /// - /// Test aggregation element. + /// Test links. /// - internal abstract class TestElementAggregation : TestElement, ITestAggregation + public Dictionary TestLinks { - protected Dictionary testLinks = new Dictionary(); - - public TestElementAggregation(Guid id, string name, string adapter) : base(id, name, adapter) { } + get { return _testLinks; } + } - /// - /// Test links. - /// - public Dictionary TestLinks - { - get { return testLinks; } - } + public override void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) + { + base.Save(element, parameters); - public override void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) + XmlPersistence h = new(); + if (_testLinks.Count > 0) { - base.Save(element, parameters); - - XmlPersistence h = new XmlPersistence(); - if (testLinks.Count > 0) - { - h.SaveIEnumerable(testLinks.Values, element, "TestLinks", ".", "TestLink", parameters); - } + h.SaveIEnumerable(_testLinks.Values, element, "TestLinks", ".", "TestLink", parameters); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestEntry.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestEntry.cs index d693dde8fb..bff991b0f5 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestEntry.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestEntry.cs @@ -1,158 +1,136 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System; +using System.Collections.Generic; +using System.Diagnostics; + +using XML; + +/// +/// The test entry. +/// +internal sealed class TestEntry : IXmlTestStore { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Diagnostics.CodeAnalysis; - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; + #region Fields + + private readonly TestId _testId; + private readonly TestListCategoryId _categoryId; + private List _testEntries; + + #endregion + + #region Constructors /// - /// The test entry. + /// Constructor. + /// Note that using this constructor has different effect as setting CategoryId property. + /// When using this constructor, catId is used as specified, which CategoryId.set changes null to the root cat. /// - internal sealed class TestEntry : IXmlTestStore + /// Test Id. + /// Category Id. This gets into . + public TestEntry(TestId testId, TestListCategoryId catId) { - #region Fields - - private TestId testId; - private Guid executionId; - private Guid parentExecutionId; - private TestListCategoryId categoryId; - private List testEntries; - - #endregion - - #region Constructors - - /// - /// Constructor. - /// Note that using this constructor has different effect as setting CategoryId property. - /// When using this constructor, catId is used as specified, which CategoryId.set changes null to the root cat. - /// - /// Test Id. - /// Category Id. This gets into . - public TestEntry(TestId testId, TestListCategoryId catId) - { - this.testId = testId; - this.categoryId = catId; - } + _testId = testId; + _categoryId = catId; + } - #endregion + #endregion - #region Properties + #region Properties - /// - /// Gets or sets the exec id. - /// - public Guid ExecutionId - { - get { return this.executionId; } + /// + /// Gets or sets the exec id. + /// + public Guid ExecutionId { get; set; } - set - { - this.executionId = value; - } - } + /// + /// Gets or sets the parent exec id. + /// + public Guid ParentExecutionId { get; set; } - /// - /// Gets or sets the parent exec id. - /// - public Guid ParentExecutionId + public List TestEntries + { + get { - get { return this.parentExecutionId; } - - set + if (_testEntries == null) { - this.parentExecutionId = value; + _testEntries = new List(); } - } - - public List TestEntries - { - get - { - if (this.testEntries == null) - { - this.testEntries = new List(); - } - return this.testEntries; - } + return _testEntries; } + } - #endregion - - #region Overrides - - /// - /// Override function for Equals. - /// - /// - /// The object to compare. - /// - /// - /// The . - /// - [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1405:DebugAssertMustProvideMessageText", Justification = "Reviewed. Suppression is OK here.")] - public override bool Equals(object obj) - { - TestEntry e = obj as TestEntry; - - if (e == null) - { - return false; - } + #endregion - if (!this.executionId.Equals(e.executionId)) - { - return false; - } + #region Overrides - Debug.Assert(object.Equals(this.testId, e.testId)); - Debug.Assert(object.Equals(this.categoryId, e.categoryId)); - return true; + /// + /// Override function for Equals. + /// + /// + /// The object to compare. + /// + /// + /// The . + /// + public override bool Equals(object obj) + { + if (obj is not TestEntry e) + { + return false; } - /// - /// Override function for GetHashCode. - /// - /// - /// The . - /// - public override int GetHashCode() + if (!ExecutionId.Equals(e.ExecutionId)) { - return this.executionId.GetHashCode(); + return false; } - #endregion + Debug.Assert(Equals(_testId, e._testId)); + Debug.Assert(Equals(_categoryId, e._categoryId)); + return true; + } - #region IXmlTestStore Members + /// + /// Override function for GetHashCode. + /// + /// + /// The . + /// + public override int GetHashCode() + { + return ExecutionId.GetHashCode(); + } - /// - /// Saves the class under the XmlElement.. - /// - /// - /// The parent xml. - /// - /// - /// The parameters. - /// - public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) - { - XmlPersistence helper = new XmlPersistence(); - helper.SaveSingleFields(element, this, parameters); - - helper.SaveObject(this.testId, element, null); - helper.SaveGuid(element, "@executionId", this.executionId); - if (parentExecutionId != Guid.Empty) - helper.SaveGuid(element, "@parentExecutionId", this.parentExecutionId); - helper.SaveGuid(element, "@testListId", this.categoryId.Id); - if (this.TestEntries.Count > 0) - helper.SaveIEnumerable(TestEntries, element, "TestEntries", ".", "TestEntry", parameters); - } + #endregion - #endregion + #region IXmlTestStore Members + + /// + /// Saves the class under the XmlElement.. + /// + /// + /// The parent xml. + /// + /// + /// The parameters. + /// + public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) + { + XmlPersistence helper = new(); + helper.SaveSingleFields(element, this, parameters); + + helper.SaveObject(_testId, element, null); + helper.SaveGuid(element, "@executionId", ExecutionId); + if (ParentExecutionId != Guid.Empty) + helper.SaveGuid(element, "@parentExecutionId", ParentExecutionId); + helper.SaveGuid(element, "@testListId", _categoryId.Id); + if (TestEntries.Count > 0) + helper.SaveIEnumerable(TestEntries, element, "TestEntries", ".", "TestEntry", parameters); } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestExecId.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestExecId.cs index 11ed280e86..ebb69c875a 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestExecId.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestExecId.cs @@ -1,98 +1,80 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel -{ - using System; - using System.Globalization; +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System; +using System.Globalization; +/// +/// Class identifying test execution id. +/// Execution ID is assigned to test at run creation time and is guaranteed to be unique within that run. +/// +internal sealed class TestExecId +{ /// - /// Class identifying test execution id. - /// Execution ID is assigned to test at run creation time and is guaranteed to be unique within that run. + /// Initializes a new instance of the class. /// - internal sealed class TestExecId + public TestExecId() { - private static TestExecId emptyId = new TestExecId(Guid.Empty); - - private Guid execId; - - /// - /// Initializes a new instance of the class. - /// - public TestExecId() - { - this.execId = Guid.NewGuid(); - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// The id. - /// - public TestExecId(Guid id) - { - this.execId = id; - } - - /// - /// Gets an object of class which empty GUID - /// - public static TestExecId Empty - { - get { return emptyId; } - } + Id = Guid.NewGuid(); + } - /// - /// Gets the id. - /// - public Guid Id - { - get { return this.execId; } - } + /// + /// Initializes a new instance of the class. + /// + /// + /// The id. + /// + public TestExecId(Guid id) + { + Id = id; + } - /// - /// Override function of Equals. - /// - /// - /// The object to compare. - /// - /// - /// The . - /// - public override bool Equals(object obj) - { - TestExecId id = obj as TestExecId; + /// + /// Gets an object of class which empty GUID + /// + public static TestExecId Empty { get; } = new TestExecId(Guid.Empty); - if (id == null) - { - return false; - } + /// + /// Gets the id. + /// + public Guid Id { get; } - return this.execId.Equals(id.execId); - } + /// + /// Override function of Equals. + /// + /// + /// The object to compare. + /// + /// + /// The . + /// + public override bool Equals(object obj) + { + return obj is TestExecId id && Id.Equals(id.Id); + } - /// - /// Override function of GetHashCode - /// - /// - /// The . - /// - public override int GetHashCode() - { - return this.execId.GetHashCode(); - } + /// + /// Override function of GetHashCode + /// + /// + /// The . + /// + public override int GetHashCode() + { + return Id.GetHashCode(); + } - /// - /// Override function of ToString. - /// - /// - /// The . - /// - public override string ToString() - { - string s = this.execId.ToString("B"); - return string.Format(CultureInfo.InvariantCulture, s); - } + /// + /// Override function of ToString. + /// + /// + /// The . + /// + public override string ToString() + { + string s = Id.ToString("B"); + return string.Format(CultureInfo.InvariantCulture, s); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestId.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestId.cs index e4e55f62d6..9b80caff0d 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestId.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestId.cs @@ -1,275 +1,247 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel -{ - using System; - using System.Diagnostics; - using System.Globalization; - using System.Xml; +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; +using System; +using System.Diagnostics; +using System.Globalization; +using System.Xml; - #region TestId - /// - /// Class that uniquely identifies a test. - /// - internal sealed class TestId : IEquatable, IComparable, IComparable, IXmlTestStore - { - #region Constants +using XML; - /// - /// Key in for specifying the location where the test ID is stored, under an XML element - /// - internal static readonly string IdLocationKey = "IdLocation"; - - /// - /// Location where the test ID is stored, under an XML element - /// - private const string DefaultIdLocation = "@testId"; - - /// - /// Represents an empty test ID - /// - private static readonly TestId EmptyId = new TestId(Guid.Empty); +#region TestId +/// +/// Class that uniquely identifies a test. +/// +internal sealed class TestId : IEquatable, IComparable, IComparable, IXmlTestStore +{ + #region Constants - #endregion + /// + /// Key in for specifying the location where the test ID is stored, under an XML element + /// + internal static readonly string IdLocationKey = "IdLocation"; - #region Fields + /// + /// Location where the test ID is stored, under an XML element + /// + private const string DefaultIdLocation = "@testId"; - /// - /// The test ID - /// - private Guid id; + #endregion - #endregion + #region Constructors - #region Constructors + /// + /// Generates a new test ID + /// + public TestId() + : this(Guid.NewGuid()) + { + } - /// - /// Generates a new test ID - /// - public TestId() - : this(Guid.NewGuid()) - { - } + /// + /// Stores the specified ID + /// + /// GUID of the test + public TestId(Guid id) + { + Id = id; + } - /// - /// Stores the specified ID - /// - /// GUID of the test - public TestId(Guid id) - { - this.id = id; - } + #endregion - #endregion + #region Properties - #region Properties + /// + /// Gets an empty test ID + /// + public static TestId Empty { get; } = new TestId(Guid.Empty); - /// - /// Gets an empty test ID - /// - public static TestId Empty - { - get { return EmptyId; } - } + /// + /// Gets test ID + /// + public Guid Id { get; } - /// - /// Gets test ID - /// - public Guid Id - { - get { return this.id; } - } + #endregion - #endregion + #region IXmlTestStore Members - #region IXmlTestStore Members + /// + /// Saves the state to the XML element + /// + /// The XML element to save to + /// Parameters to customize the save behavior + void IXmlTestStore.Save(XmlElement element, XmlTestStoreParameters parameters) + { + Debug.Assert(element != null, "element is null"); - /// - /// Saves the state to the XML element - /// - /// The XML element to save to - /// Parameters to customize the save behavior - void IXmlTestStore.Save(XmlElement element, XmlTestStoreParameters parameters) - { - Debug.Assert(element != null, "element is null"); + GetIdLocation(parameters, out string idLocation); - string idLocation; - this.GetIdLocation(parameters, out idLocation); + XmlPersistence helper = new(); + helper.SaveGuid(element, idLocation, Id); + } - XmlPersistence helper = new XmlPersistence(); - helper.SaveGuid(element, idLocation, this.id); - } + /// + /// Gets the location of the test ID under an XML element, based on the specified parameters. + /// This method is needed to parse the parameters sent by the caller of Save and Load. + /// We need to support different locations for saving the test ID, because previously, TestEntry and TestResult stored the test ID to @testId + /// (which is now the default location the TestId class' Save and Load methods), but TestElement was storing it to @id. + /// Since we can't change the location where the ID is stored in XML, we support custom locations in the TestId class. + /// + /// The parameters specifying the locations + /// The test ID location + private void GetIdLocation(XmlTestStoreParameters parameters, out string idLocation) + { + // Initialize to the default ID location + idLocation = DefaultIdLocation; - /// - /// Gets the location of the test ID under an XML element, based on the specified parameters. - /// This method is needed to parse the parameters sent by the caller of Save and Load. - /// We need to support different locations for saving the test ID, because previously, TestEntry and TestResult stored the test ID to @testId - /// (which is now the default location the TestId class' Save and Load methods), but TestElement was storing it to @id. - /// Since we can't change the location where the ID is stored in XML, we support custom locations in the TestId class. - /// - /// The parameters specifying the locations - /// The test ID location - private void GetIdLocation(XmlTestStoreParameters parameters, out string idLocation) + // If any parameters are specified, see if we need to override the defaults + if (parameters != null) { - // Initialize to the default ID location - idLocation = DefaultIdLocation; - - // If any parameters are specified, see if we need to override the defaults - if (parameters != null) + if (parameters.TryGetValue(IdLocationKey, out object idLocationObj)) { - object idLocationObj; - if (parameters.TryGetValue(IdLocationKey, out idLocationObj)) - { - idLocation = idLocationObj as string ?? idLocation; - } + idLocation = idLocationObj as string ?? idLocation; } } + } - #endregion - - #region Equality - - #region IEquatable Members + #endregion - /// - /// Compares this instance with the other test ID for value equality - /// - /// The other test ID to compare with - /// True if the test IDs are equal in value, false otherwise - public bool Equals(TestId other) - { - // Check reference equality first, as it is faster than comparing value equality when the references are equal - return object.ReferenceEquals(this, other) || this.ValueEquals(other); - } + #region Equality - /// - /// Compares this instance with the other test ID for value equality. This method does not check reference equality first. - /// - /// The other test ID to compare with - /// True if the test IDs are equal in value, false otherwise - private bool ValueEquals(TestId other) - { - // Avoid calling of "!= null", as the != operator has been overloaded. - return !object.ReferenceEquals(other, null) && this.id == other.id; - } + #region IEquatable Members - #endregion + /// + /// Compares this instance with the other test ID for value equality + /// + /// The other test ID to compare with + /// True if the test IDs are equal in value, false otherwise + public bool Equals(TestId other) + { + // Check reference equality first, as it is faster than comparing value equality when the references are equal + return ReferenceEquals(this, other) || ValueEquals(other); + } - #region Overrides + /// + /// Compares this instance with the other test ID for value equality. This method does not check reference equality first. + /// + /// The other test ID to compare with + /// True if the test IDs are equal in value, false otherwise + private bool ValueEquals(TestId other) + { + // Avoid calling of "!= null", as the != operator has been overloaded. + return other is not null && Id == other.Id; + } - /// - /// Compares this instance with the other test ID for value equality - /// - /// The other test ID to compare with - /// True if the test IDs are equal in value, false otherwise - public override bool Equals(object other) - { - return this.Equals(other as TestId); - } + #endregion - /// - /// Gets a hash code representing the state of the instance - /// - /// The hash code - public override int GetHashCode() - { - return this.id.GetHashCode(); - } + #region Overrides - #endregion + /// + /// Compares this instance with the other test ID for value equality + /// + /// The other test ID to compare with + /// True if the test IDs are equal in value, false otherwise + public override bool Equals(object other) + { + return Equals(other as TestId); + } - #region Operators + /// + /// Gets a hash code representing the state of the instance + /// + /// The hash code + public override int GetHashCode() + { + return Id.GetHashCode(); + } - /// - /// Compares the two test IDs for value equality - /// - /// The test ID on the left of the operator - /// The test ID on the right of the operator - /// True if the test IDs are equal in value, false otherwise - public static bool operator ==(TestId left, TestId right) - { - return - object.ReferenceEquals(left, right) || - (!object.ReferenceEquals(left, null) && left.ValueEquals(right)); - } + #endregion - /// - /// Compares the two test IDs for value inequality - /// - /// The test ID on the left of the operator - /// The test ID on the right of the operator - /// True if the test IDs are unequal in value, false otherwise - public static bool operator !=(TestId left, TestId right) - { - return !(left == right); - } + #region Operators - #endregion + /// + /// Compares the two test IDs for value equality + /// + /// The test ID on the left of the operator + /// The test ID on the right of the operator + /// True if the test IDs are equal in value, false otherwise + public static bool operator ==(TestId left, TestId right) + { + return + ReferenceEquals(left, right) || + (left is not null && left.ValueEquals(right)); + } - #endregion + /// + /// Compares the two test IDs for value inequality + /// + /// The test ID on the left of the operator + /// The test ID on the right of the operator + /// True if the test IDs are unequal in value, false otherwise + public static bool operator !=(TestId left, TestId right) + { + return !(left == right); + } - #region Comparison + #endregion - #region IComparable Members + #endregion - /// - /// Compares this instance with the other test ID - /// - /// The other test ID to compare with - /// - /// 0 if this instance is equal in value to the other test ID, < 0 if this instance is lesser than the other test ID, - /// or > 0 if this instance is greater than the other test ID - /// - public int CompareTo(TestId other) - { - if (other == null) - { - throw new ArgumentNullException(nameof(other)); - } + #region Comparison - return this.id.CompareTo(other.id); - } + #region IComparable Members - #endregion + /// + /// Compares this instance with the other test ID + /// + /// The other test ID to compare with + /// + /// 0 if this instance is equal in value to the other test ID, < 0 if this instance is lesser than the other test ID, + /// or > 0 if this instance is greater than the other test ID + /// + public int CompareTo(TestId other) + { + return other == null ? throw new ArgumentNullException(nameof(other)) : Id.CompareTo(other.Id); + } - #region IComparable Members + #endregion - /// - /// Compares this instance with the other test ID - /// - /// The other test ID to compare with - /// - /// 0 if this instance is equal in value to the other test ID, < 0 if this instance is less than the other test ID, - /// or > 0 if this instance is greater than the other test ID - /// - public int CompareTo(object other) - { - return CompareTo(other as TestId); - } + #region IComparable Members - #endregion + /// + /// Compares this instance with the other test ID + /// + /// The other test ID to compare with + /// + /// 0 if this instance is equal in value to the other test ID, < 0 if this instance is less than the other test ID, + /// or > 0 if this instance is greater than the other test ID + /// + public int CompareTo(object other) + { + return CompareTo(other as TestId); + } - #endregion + #endregion - #region Overrides + #endregion - /// - /// Override ToString - /// - /// - /// The . - /// - public override string ToString() - { - // "B" adds curly braces around guid - string s = this.id.ToString("B"); - return string.Format(CultureInfo.InvariantCulture, s); - } + #region Overrides - #endregion + /// + /// Override ToString + /// + /// + /// The . + /// + public override string ToString() + { + // "B" adds curly braces around guid + string s = Id.ToString("B"); + return string.Format(CultureInfo.InvariantCulture, s); } - #endregion TestId + + #endregion } +#endregion TestId \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestLink.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestLink.cs index 5b4709b460..6d3a8151c5 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestLink.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestLink.cs @@ -1,114 +1,97 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel -{ - using System; - using System.Globalization; - using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; - /// - /// Test link. - /// - internal sealed class TestLink : IXmlTestStore - { - private Guid id; - private string name = string.Empty; - private string storage = string.Empty; +using System; +using System.Globalization; - public TestLink(Guid id, string name, string storage) - { - if (id == Guid.Empty) - { - throw new ArgumentException("ID cant be empty"); - } - - EqtAssert.StringNotNullOrEmpty(name, nameof(name)); - EqtAssert.ParameterNotNull(storage, nameof(storage)); +using Utility; - this.id = id; - this.name = name; - this.storage = storage; - } +using XML; - /// - /// Gets the id. - /// - public Guid Id +/// +/// Test link. +/// +internal sealed class TestLink : IXmlTestStore +{ + public TestLink(Guid id, string name, string storage) + { + if (id == Guid.Empty) { - get { return this.id; } + throw new ArgumentException("ID cant be empty"); } - /// - /// Gets the name. - /// - public string Name - { - get { return this.name; } - } + EqtAssert.StringNotNullOrEmpty(name, nameof(name)); + EqtAssert.ParameterNotNull(storage, nameof(storage)); - /// - /// Gets the storage. - /// - public string Storage - { - get { return this.storage; } - } + Id = id; + Name = name; + Storage = storage; + } - /// - /// Whether this Link is equal to other Link. Compares by Id. - /// - public override bool Equals(object other) - { - TestLink link = other as TestLink; - return (link == null) ? - false : - this.id.Equals(link.id); - } + /// + /// Gets the id. + /// + public Guid Id { get; } - /// - /// Whether this Link is exactly the same as other Link. Compares all fields. - /// - public bool IsSame(TestLink other) - { - if (other == null) - return false; + /// + /// Gets the name. + /// + public string Name { get; private set; } = string.Empty; - return this.id.Equals(other.id) && - this.name.Equals(other.name) && - this.storage.Equals(other.storage); - } + /// + /// Gets the storage. + /// + public string Storage { get; private set; } = string.Empty; - /// - /// Override for GetHashCode. - /// - /// - public override int GetHashCode() - { - return this.id.GetHashCode(); - } + /// + /// Whether this Link is equal to other Link. Compares by Id. + /// + public override bool Equals(object other) + { + return other is TestLink link && Id.Equals(link.Id); + } - /// - /// Override for ToString. - /// - /// - public override string ToString() - { - return string.Format( - CultureInfo.InvariantCulture, - "Link to '{0}' {1} '{2}'.", - this.name ?? "(null)", - this.id.ToString("B"), - this.storage ?? "(null)"); - } + /// + /// Whether this Link is exactly the same as other Link. Compares all fields. + /// + public bool IsSame(TestLink other) + { + return other != null + && Id.Equals(other.Id) && + Name.Equals(other.Name) && + Storage.Equals(other.Storage); + } - public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) - { - XmlPersistence h = new XmlPersistence(); - h.SaveGuid(element, "@id", this.Id); - h.SaveSimpleField(element, "@name", this.name, null); - h.SaveSimpleField(element, "@storage", this.storage, string.Empty); - } + /// + /// Override for GetHashCode. + /// + /// + public override int GetHashCode() + { + return Id.GetHashCode(); + } + + /// + /// Override for ToString. + /// + /// + public override string ToString() + { + return string.Format( + CultureInfo.InvariantCulture, + "Link to '{0}' {1} '{2}'.", + Name ?? "(null)", + Id.ToString("B"), + Storage ?? "(null)"); + } + + public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) + { + XmlPersistence h = new(); + h.SaveGuid(element, "@id", Id); + h.SaveSimpleField(element, "@name", Name, null); + h.SaveSimpleField(element, "@storage", Storage, string.Empty); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestListCategory.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestListCategory.cs index 7e90adf154..5e6b824cd4 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestListCategory.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestListCategory.cs @@ -1,200 +1,193 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel -{ - using System.Diagnostics; +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; - using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; +using System.Diagnostics; - using TrxLoggerResources = Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.Resources.TrxResource; +using Utility; - /// - /// The test list category. - /// - internal class TestListCategory : IXmlTestStore - { - #region Fields +using XML; - private static TestListCategory uncategorizedResults; +using TrxLoggerResources = VisualStudio.TestPlatform.Extensions.TrxLogger.Resources.TrxResource; - private static TestListCategory allResults; +/// +/// The test list category. +/// +internal class TestListCategory : IXmlTestStore +{ + #region Fields - private static object reservedCategoryLock = new object(); + private static TestListCategory s_uncategorizedResults; - private TestListCategoryId id = new TestListCategoryId(); + private static TestListCategory s_allResults; - [StoreXmlSimpleField(DefaultValue = "")] - private string name = string.Empty; + private static readonly object ReservedCategoryLock = new(); + [StoreXmlSimpleField("@name", DefaultValue = "")] + private readonly string _name = string.Empty; - private TestListCategoryId parentCategoryId; + private TestListCategoryId _parentCategoryId; - #endregion + #endregion - /// - /// Constructor for TestListCategory . - /// - /// The name of new category. - /// Id of parent category. Use TestListCategoryId.Root for top level categories. - public TestListCategory(string name, TestListCategoryId parentCategoryId) - { - EqtAssert.StringNotNullOrEmpty(name, nameof(name)); - EqtAssert.ParameterNotNull(parentCategoryId, nameof(parentCategoryId)); + /// + /// Constructor for TestListCategory . + /// + /// The name of new category. + /// Id of parent category. Use TestListCategoryId.Root for top level categories. + public TestListCategory(string name, TestListCategoryId parentCategoryId) + { + EqtAssert.StringNotNullOrEmpty(name, nameof(name)); + EqtAssert.ParameterNotNull(parentCategoryId, nameof(parentCategoryId)); - this.name = name; - this.parentCategoryId = parentCategoryId; - } + _name = name; + _parentCategoryId = parentCategoryId; + } - /// - /// Used internally for fake uncategorized category. - /// - /// - /// Category name. - /// - /// - /// Category id. - /// - /// - /// The parent Id. - /// - private TestListCategory(string name, TestListCategoryId id, TestListCategoryId parentId) : this(name, parentId) - { - EqtAssert.ParameterNotNull(id, nameof(id)); - this.id = id; - } + /// + /// Used internally for fake uncategorized category. + /// + /// + /// Category name. + /// + /// + /// Category id. + /// + /// + /// The parent Id. + /// + private TestListCategory(string name, TestListCategoryId id, TestListCategoryId parentId) : this(name, parentId) + { + EqtAssert.ParameterNotNull(id, nameof(id)); + Id = id; + } - #region Properties + #region Properties - /// - /// Gets the uncategorized results. - /// - public static TestListCategory UncategorizedResults + /// + /// Gets the uncategorized results. + /// + public static TestListCategory UncategorizedResults + { + get { - get + if (s_uncategorizedResults == null) { - if (uncategorizedResults == null) + lock (ReservedCategoryLock) { - lock (reservedCategoryLock) + if (s_uncategorizedResults == null) { - if (uncategorizedResults == null) - { - uncategorizedResults = new TestListCategory( - TrxLoggerResources.TS_UncategorizedResults, TestListCategoryId.Uncategorized, TestListCategoryId.Root); - } + s_uncategorizedResults = new TestListCategory( + TrxLoggerResources.TS_UncategorizedResults, TestListCategoryId.Uncategorized, TestListCategoryId.Root); } } - - return uncategorizedResults; } + + return s_uncategorizedResults; } + } - /// - /// Gets the all results. - /// - public static TestListCategory AllResults + /// + /// Gets the all results. + /// + public static TestListCategory AllResults + { + get { - get + if (s_allResults == null) { - if (allResults == null) + lock (ReservedCategoryLock) { - lock (reservedCategoryLock) + if (s_allResults == null) { - if (allResults == null) - { - allResults = new TestListCategory( - TrxLoggerResources.TS_AllResults, TestListCategoryId.AllItems, TestListCategoryId.Root); - } + s_allResults = new TestListCategory( + TrxLoggerResources.TS_AllResults, TestListCategoryId.AllItems, TestListCategoryId.Root); } } - - return allResults; } + + return s_allResults; } + } + + /// + /// Gets the id. + /// + public TestListCategoryId Id { get; private set; } = new TestListCategoryId(); - /// - /// Gets the id. - /// - public TestListCategoryId Id + /// + /// Gets or sets id of parent category. Use TestCategoryId.Root for top level categories. + /// We do not keep category children in Object Model, only parent. + /// + public TestListCategoryId ParentCategoryId + { + get { - get { return this.id; } + return _parentCategoryId; } - /// - /// Gets or sets id of parent category. Use TestCategoryId.Root for top level categories. - /// We do not keep category children in Object Model, only parent. - /// - public TestListCategoryId ParentCategoryId + set { - get - { - return this.parentCategoryId; - } - - set - { - EqtAssert.ParameterNotNull(value, "ParentCategoryId.value"); - this.parentCategoryId = value; - } + EqtAssert.ParameterNotNull(value, "ParentCategoryId.value"); + _parentCategoryId = value; } + } - #endregion + #endregion - #region Overrides + #region Overrides - /// - /// Override function for Equals. - /// - /// - /// The object to compare. - /// - /// - /// The . - /// - public override bool Equals(object obj) + /// + /// Override function for Equals. + /// + /// + /// The object to compare. + /// + /// + /// The . + /// + public override bool Equals(object obj) + { + if (obj is not TestListCategory cat) { - TestListCategory cat = obj as TestListCategory; - if (cat == null) - { - return false; - } - - Debug.Assert(this.id != null, "id is null"); - return this.id.Equals(cat.id); + return false; } - /// - /// Override function for GetHashCode. - /// - /// - /// The . - /// - public override int GetHashCode() - { - return this.id.GetHashCode(); - } - #endregion - - #region IXmlTestStore Members - - /// - /// Saves the class under the XmlElement.. - /// - /// - /// The parent xml. - /// - /// - /// The parameter - /// - public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) - { - XmlPersistence h = new XmlPersistence(); + Debug.Assert(Id != null, "id is null"); + return Id.Equals(cat.Id); + } - h.SaveSingleFields(element, this, parameters); - h.SaveGuid(element, "@id", this.Id.Id); - h.SaveGuid(element, "@parentListId", this.ParentCategoryId.Id); - } + /// + /// Override function for GetHashCode. + /// + /// + /// The . + /// + public override int GetHashCode() + { + return Id.GetHashCode(); + } + #endregion + + #region IXmlTestStore Members - #endregion + /// + /// Saves the class under the XmlElement.. + /// + /// + /// The parent xml. + /// + /// + /// The parameter + /// + public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) + { + XmlPersistence h = new(); + + h.SaveSingleFields(element, this, parameters); + h.SaveGuid(element, "@id", Id.Id); + h.SaveGuid(element, "@parentListId", ParentCategoryId.Id); } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestListCategoryId.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestListCategoryId.cs index d50fd06cf8..7a8a4714dd 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestListCategoryId.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestListCategoryId.cs @@ -1,134 +1,102 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel -{ - using System; - using System.Globalization; +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System; +using System.Globalization; +/// +/// Class to categorize the tests. +/// +internal sealed class TestListCategoryId +{ /// - /// Class to categorize the tests. + /// Initializes a new instance of the class. /// - internal sealed class TestListCategoryId + public TestListCategoryId() { - private static TestListCategoryId emptyId = new TestListCategoryId(Guid.Empty); - - private static TestListCategoryId uncategorizedId = new TestListCategoryId(new Guid("8C84FA94-04C1-424b-9868-57A2D4851A1D")); - - private static TestListCategoryId categoriesId = new TestListCategoryId(new Guid("8C43106B-9DC1-4907-A29F-AA66A61BF5B6")); - - private static TestListCategoryId all = new TestListCategoryId(new Guid("19431567-8539-422a-85D7-44EE4E166BDA")); - - private Guid id; - - /// - /// Initializes a new instance of the class. - /// - public TestListCategoryId() - { - this.id = Guid.NewGuid(); - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// The id (GUID). - /// - public TestListCategoryId(Guid id) - { - this.id = id; - } + Id = Guid.NewGuid(); + } + /// + /// Initializes a new instance of the class. + /// + /// + /// The id (GUID). + /// + public TestListCategoryId(Guid id) + { + Id = id; + } - /// - /// Gets the Id of very root category - parent of all categories (fake, not real category). - /// - public static TestListCategoryId Root - { - get { return emptyId; } - } - /// - /// Gets an object of class with empty GUID. - /// - public static TestListCategoryId Empty - { - get { return emptyId; } - } + /// + /// Gets the Id of very root category - parent of all categories (fake, not real category). + /// + public static TestListCategoryId Root { get; } = new TestListCategoryId(Guid.Empty); - /// - /// Gets an object of class with GUID which represent uncategorized. - /// - public static TestListCategoryId Uncategorized - { - get { return uncategorizedId; } - } + /// + /// Gets an object of class with empty GUID. + /// + public static TestListCategoryId Empty + { + get { return Root; } + } - /// - /// Gets an object of class with GUID which represent categorize. - /// - public static TestListCategoryId Categories - { - get { return categoriesId; } - } + /// + /// Gets an object of class with GUID which represent uncategorized. + /// + public static TestListCategoryId Uncategorized { get; } = new(new Guid("8C84FA94-04C1-424b-9868-57A2D4851A1D")); - /// - /// Gets the id. - /// - public Guid Id - { - get { return this.id; } - } + /// + /// Gets an object of class with GUID which represent categorize. + /// + public static TestListCategoryId Categories { get; } = new TestListCategoryId(new Guid("8C43106B-9DC1-4907-A29F-AA66A61BF5B6")); - public static TestListCategoryId AllItems - { - get { return all; } - } + /// + /// Gets the id. + /// + public Guid Id { get; } + public static TestListCategoryId AllItems { get; } = new(new Guid("19431567-8539-422a-85D7-44EE4E166BDA")); - /// - /// Override function for Equals. - /// - /// - /// The object to compare. - /// - /// - /// The . - /// - public override bool Equals(object other) - { - TestListCategoryId testListCategoryId = other as TestListCategoryId; - if (testListCategoryId == null) - { - return false; - } - return this.id.Equals(testListCategoryId.id); - } + /// + /// Override function for Equals. + /// + /// + /// The object to compare. + /// + /// + /// The . + /// + public override bool Equals(object other) + { + return other is TestListCategoryId testListCategoryId && Id.Equals(testListCategoryId.Id); + } - /// - /// Override function for GetHashCode. - /// - /// - /// The . - /// - public override int GetHashCode() - { - return this.id.GetHashCode(); - } + /// + /// Override function for GetHashCode. + /// + /// + /// The . + /// + public override int GetHashCode() + { + return Id.GetHashCode(); + } - /// - /// Override function for ToString. - /// - /// - /// The . - /// - public override string ToString() - { - // "B" adds curly braces around guid - string s = this.id.ToString("B"); - return string.Format(CultureInfo.InvariantCulture, s); - } + /// + /// Override function for ToString. + /// + /// + /// The . + /// + public override string ToString() + { + // "B" adds curly braces around guid + string s = Id.ToString("B"); + return string.Format(CultureInfo.InvariantCulture, s); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestMethod.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestMethod.cs index 2bd3830e05..3e40bcb132 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestMethod.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestMethod.cs @@ -1,117 +1,88 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System.Diagnostics; +using System.Xml; + +using XML; +/// +/// TestMethod contains information about a unit test method that needs to be executed +/// +internal sealed class TestMethod : IXmlTestStore { - using System.Diagnostics; - using System.Xml; + public TestMethod(string name, string className) + { + Debug.Assert(!string.IsNullOrEmpty(name), "name is null"); + Debug.Assert(!string.IsNullOrEmpty(className), "className is null"); + Name = name; + ClassName = className; + } - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; - using System; /// - /// TestMethod contains information about a unit test method that needs to be executed + /// Gets the name. /// - internal sealed class TestMethod : IXmlTestStore - { - private string className; - private string name; // test method name - private bool isValid; - - public TestMethod(string name, string className) - { - Debug.Assert(!string.IsNullOrEmpty(name), "name is null"); - Debug.Assert(!string.IsNullOrEmpty(className), "className is null"); - this.name = name; - this.className = className; - } + public string Name { get; private set; } - /// - /// Gets the name. - /// - public string Name - { - get - { - return this.name; - } - } - - /// - /// Gets the class name. - /// - public string ClassName - { - get - { - return this.className; - } - } - - /// - /// Gets or sets a value indicating whether is valid. - /// - public bool IsValid - { - get - { - return this.isValid; - } - set - { - this.isValid = value; - } - } + /// + /// Gets the class name. + /// + public string ClassName { get; private set; } - #region Override + /// + /// Gets or sets a value indicating whether is valid. + /// + public bool IsValid { get; set; } - /// - /// Override function for Equals. - /// - /// - /// The object to compare. - /// - /// - /// The . - /// - public override bool Equals(object obj) - { - TestMethod otherTestMethod = obj as TestMethod; - return otherTestMethod != null && this.name == otherTestMethod.name - && this.className == otherTestMethod.className && this.isValid == otherTestMethod.isValid; - } + #region Override - /// - /// Override function for GetHashCode. - /// - /// - /// The . - /// - public override int GetHashCode() - { - return this.Name?.GetHashCode() ?? 0; - } + /// + /// Override function for Equals. + /// + /// + /// The object to compare. + /// + /// + /// The . + /// + public override bool Equals(object obj) + { + return obj is TestMethod otherTestMethod && Name == otherTestMethod.Name + && ClassName == otherTestMethod.ClassName && IsValid == otherTestMethod.IsValid; + } - #endregion Override + /// + /// Override function for GetHashCode. + /// + /// + /// The . + /// + public override int GetHashCode() + { + return Name?.GetHashCode() ?? 0; + } - #region IXmlTestStore Members + #endregion Override - /// - /// Saves the class under the XmlElement.. - /// - /// - /// The parent xml. - /// - /// - /// The parameter - /// - public void Save(XmlElement element, XmlTestStoreParameters parameters) - { - XmlPersistence helper = new XmlPersistence(); - helper.SaveSimpleField(element, "@className", this.className, string.Empty); - helper.SaveSimpleField(element, "@name", this.name, string.Empty); - helper.SaveSimpleField(element, "isValid", this.isValid, false); - } + #region IXmlTestStore Members - #endregion + /// + /// Saves the class under the XmlElement.. + /// + /// + /// The parent xml. + /// + /// + /// The parameter + /// + public void Save(XmlElement element, XmlTestStoreParameters parameters) + { + XmlPersistence helper = new(); + helper.SaveSimpleField(element, "@className", ClassName, string.Empty); + helper.SaveSimpleField(element, "@name", Name, string.Empty); + helper.SaveSimpleField(element, "isValid", IsValid, false); } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestOutcome.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestOutcome.cs index 4ba33477af..2f36e01089 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestOutcome.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestOutcome.cs @@ -1,106 +1,99 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; +/// +/// Outcome of a test or a run. +/// If a new successful state needs to be added you will need to modify +/// RunResultAndStatistics in TestRun.cs and TestOutcomeHelper below. +/// ---------------------------------------------------------------- +/// NOTE: the order is important and is used for computing outcome for aggregations. +/// More important outcomes come first. See TestOutcomeHelper.GetAggregationOutcome. +/// +internal enum TestOutcome { - using System.Diagnostics.CodeAnalysis; - - /// - /// Outcome of a test or a run. - /// If a new successful state needs to be added you will need to modify - /// RunResultAndStatistics in TestRun.cs and TestOutcomeHelper below. - /// ---------------------------------------------------------------- - /// NOTE: the order is important and is used for computing outcome for aggregations. - /// More important outcomes come first. See TestOutcomeHelper.GetAggregationOutcome. - /// - internal enum TestOutcome - { - /// - /// There was a system error while we were trying to execute a test. - /// - Error, - - /// - /// Test was executed, but there were issues. - /// Issues may involve exceptions or failed assertions. - /// - Failed, - - /// - /// The test timed out - /// - Timeout, - - /// - /// Test was aborted. - /// This was not caused by a user gesture, but rather by a framework decision. - /// - Aborted, - - /// - /// Test has completed, but we can't say if it passed or failed. - /// May be used for aborted tests... - /// - Inconclusive, - - /// - /// Test was executed w/o any issues, but run was aborted. - /// - PassedButRunAborted, - - /// - /// Test had it chance for been executed but was not, as ITestElement.IsRunnable == false. - /// - NotRunnable, - - /// - /// Test was not executed. - /// This was caused by a user gesture - e.g. user hit stop button. - /// - NotExecuted, - - /// - /// Test run was disconnected before it finished running. - /// - Disconnected, - - /// - /// To be used by Run level results. - /// This is not a failure. - /// - Warning, - - /// - /// Test was executed w/o any issues. - /// - Passed, - - /// - /// Test has completed, but there is no qualitative measure of completeness. - /// - Completed, - - /// - /// Test is currently executing. - /// - InProgress, - - /// - /// Test is in the execution queue, was not started yet. - /// - Pending, - - /// - /// The min value of this enum - /// - [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is OK here.")] - Min = Error, - - /// - /// The max value of this enum - /// - [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", - Justification = "Reviewed. Suppression is OK here.")] - Max = Pending - } -} + /// + /// There was a system error while we were trying to execute a test. + /// + Error, + + /// + /// Test was executed, but there were issues. + /// Issues may involve exceptions or failed assertions. + /// + Failed, + + /// + /// The test timed out + /// + Timeout, + + /// + /// Test was aborted. + /// This was not caused by a user gesture, but rather by a framework decision. + /// + Aborted, + + /// + /// Test has completed, but we can't say if it passed or failed. + /// May be used for aborted tests... + /// + Inconclusive, + + /// + /// Test was executed w/o any issues, but run was aborted. + /// + PassedButRunAborted, + + /// + /// Test had it chance for been executed but was not, as ITestElement.IsRunnable == false. + /// + NotRunnable, + + /// + /// Test was not executed. + /// This was caused by a user gesture - e.g. user hit stop button. + /// + NotExecuted, + + /// + /// Test run was disconnected before it finished running. + /// + Disconnected, + + /// + /// To be used by Run level results. + /// This is not a failure. + /// + Warning, + + /// + /// Test was executed w/o any issues. + /// + Passed, + + /// + /// Test has completed, but there is no qualitative measure of completeness. + /// + Completed, + + /// + /// Test is currently executing. + /// + InProgress, + + /// + /// Test is in the execution queue, was not started yet. + /// + Pending, + + /// + /// The min value of this enum + /// + Min = Error, + + /// + /// The max value of this enum + /// + Max = Pending +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestResult.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestResult.cs index 207c5a248a..9aa48d842b 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestResult.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestResult.cs @@ -1,616 +1,556 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; + +using Utility; +using XML; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using TrxLoggerResources = VisualStudio.TestPlatform.Extensions.TrxLogger.Resources.TrxResource; + +/// +/// Class to uniquely identify test results +/// +internal sealed class TestResultId : IXmlTestStore { - using System; - using System.Collections; - using System.Collections.Generic; - using System.Diagnostics; - using System.Globalization; - using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using TrxLoggerResources = Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.Resources.TrxResource; + #region Fields + + private Guid _runId; + + #endregion + + #region Constructor /// - /// Class to uniquely identify test results + /// Initializes a new instance of the class. /// - internal sealed class TestResultId : IXmlTestStore + /// + /// The run id. + /// + /// + /// The execution id. + /// + /// + /// The parent execution id. + /// + /// + /// The test id. + /// + public TestResultId(Guid runId, Guid executionId, Guid parentExecutionId, Guid testId) { - #region Fields - - private Guid runId; - private Guid executionId; - private Guid parentExecutionId; - private Guid testId; - - #endregion - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - /// - /// The run id. - /// - /// - /// The execution id. - /// - /// - /// The parent execution id. - /// - /// - /// The test id. - /// - public TestResultId(Guid runId, Guid executionId, Guid parentExecutionId, Guid testId) - { - this.runId = runId; - this.executionId = executionId; - this.parentExecutionId = parentExecutionId; - this.testId = testId; - } + _runId = runId; + ExecutionId = executionId; + ParentExecutionId = parentExecutionId; + TestId = testId; + } - #endregion + #endregion - #region properties + #region properties - /// - /// Gets the execution id. - /// - public Guid ExecutionId - { - get { return this.executionId; } - } + /// + /// Gets the execution id. + /// + public Guid ExecutionId { get; } - /// - /// Gets the parent execution id. - /// - public Guid ParentExecutionId - { - get { return this.parentExecutionId; } - } + /// + /// Gets the parent execution id. + /// + public Guid ParentExecutionId { get; } - /// - /// Gets the test id. - /// - public Guid TestId - { - get { return this.testId; } - } + /// + /// Gets the test id. + /// + public Guid TestId { get; } - #endregion + #endregion - #region Overrides + #region Overrides - /// - /// Override function for Equals - /// - /// - /// The object to compare - /// - /// - /// The . - /// - public override bool Equals(object obj) - { - TestResultId tmpId = obj as TestResultId; - if (tmpId == null) - { - return false; - } + /// + /// Override function for Equals + /// + /// + /// The object to compare + /// + /// + /// The . + /// + public override bool Equals(object obj) + { + return obj is TestResultId tmpId && _runId.Equals(tmpId._runId) && ExecutionId.Equals((object)tmpId.ExecutionId); + } - return this.runId.Equals(tmpId.runId) && this.executionId.Equals((object)tmpId.executionId); - } + /// + /// Override function for GetHashCode. + /// + /// + /// The . + /// + public override int GetHashCode() + { + return _runId.GetHashCode() ^ ExecutionId.GetHashCode(); + } - /// - /// Override function for GetHashCode. - /// - /// - /// The . - /// - public override int GetHashCode() - { - return this.runId.GetHashCode() ^ this.executionId.GetHashCode(); - } + /// + /// Override function for ToString. + /// + /// + /// The . + /// + public override string ToString() + { + return ExecutionId.ToString("B"); + } + #endregion - /// - /// Override function for ToString. - /// - /// - /// The . - /// - public override string ToString() - { - return this.executionId.ToString("B"); - } - #endregion - - #region IXmlTestStore Members - - /// - /// Saves the class under the XmlElement.. - /// - /// - /// The parent xml. - /// - /// - /// The parameter - /// - public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) - { - XmlPersistence helper = new XmlPersistence(); + #region IXmlTestStore Members - if (this.executionId != Guid.Empty) - helper.SaveGuid(element, "@executionId", this.executionId); - if (this.parentExecutionId != Guid.Empty) - helper.SaveGuid(element, "@parentExecutionId", this.parentExecutionId); + /// + /// Saves the class under the XmlElement.. + /// + /// + /// The parent xml. + /// + /// + /// The parameter + /// + public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) + { + XmlPersistence helper = new(); - helper.SaveGuid(element, "@testId", this.testId); - } + if (ExecutionId != Guid.Empty) + helper.SaveGuid(element, "@executionId", ExecutionId); + if (ParentExecutionId != Guid.Empty) + helper.SaveGuid(element, "@parentExecutionId", ParentExecutionId); - #endregion + helper.SaveGuid(element, "@testId", TestId); } + #endregion +} + +/// +/// The test result error info class. +/// +internal sealed class TestResultErrorInfo : IXmlTestStore +{ + [StoreXmlSimpleField("Message", "")] + private string _message; + + [StoreXmlSimpleField("StackTrace", "")] + private string _stackTrace; + + /// - /// The test result error info class. + /// Gets or sets the message. /// - internal sealed class TestResultErrorInfo : IXmlTestStore + public string Message { - [StoreXmlSimpleField("Message", "")] - private string message; + get { return _message; } + set { _message = value; } + } - [StoreXmlSimpleField("StackTrace", "")] - private string stackTrace; + /// + /// Gets or sets the stack trace. + /// + public string StackTrace + { + get { return _stackTrace; } + set { _stackTrace = value; } + } + #region IXmlTestStore Members - /// - /// Gets or sets the message. - /// - public string Message - { - get { return this.message; } - set { this.message = value; } - } + /// + /// Saves the class under the XmlElement.. + /// + /// + /// The parent xml. + /// + /// + /// The parameter + /// + public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) + { + XmlPersistence.SaveUsingReflection(element, this, typeof(TestResultErrorInfo), parameters); + } - /// - /// Gets or sets the stack trace. - /// - public string StackTrace - { - get { return this.stackTrace; } - set { this.stackTrace = value; } - } + #endregion +} - #region IXmlTestStore Members - - /// - /// Saves the class under the XmlElement.. - /// - /// - /// The parent xml. - /// - /// - /// The parameter - /// - public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) - { - XmlPersistence.SaveUsingReflection(element, this, typeof(TestResultErrorInfo), parameters); - } +/// +/// Class for test result. +/// +internal class TestResult : ITestResult, IXmlTestStore +{ + #region Fields + + private readonly string _resultName; + private string _stdOut; + private string _stdErr; + private string _debugTrace; + private TimeSpan _duration; + private readonly TestType _testType; + private TestRun _testRun; + private TestResultErrorInfo _errorInfo; + private readonly TestListCategoryId _categoryId; + private ArrayList _textMessages; + private readonly TrxFileHelper _trxFileHelper; - #endregion - } + /// + /// Paths to test result files, relative to the test results folder, sorted in increasing order + /// + private readonly SortedList _resultFiles = new(StringComparer.OrdinalIgnoreCase); /// - /// Class for test result. + /// Information provided by data collectors for the test case /// - internal class TestResult : ITestResult, IXmlTestStore - { - #region Fields - - private TestResultId id; - private string resultName; - private string computerInfo; - private string stdOut; - private string stdErr; - private string debugTrace; - private string resultType; - private int dataRowInfo; - private TimeSpan duration; - private DateTime startTime; - private DateTime endTime; - private TestType testType; - private TestOutcome outcome; - private TestRun testRun; - private TestResultErrorInfo errorInfo; - private TestListCategoryId categoryId; - private ArrayList textMessages; - - /// - /// Directory containing the test result files, relative to the root test results directory - /// - private string relativeTestResultsDirectory; - private readonly TrxFileHelper trxFileHelper; - - /// - /// Paths to test result files, relative to the test results folder, sorted in increasing order - /// - private SortedList resultFiles = new SortedList(StringComparer.OrdinalIgnoreCase); - - /// - /// Information provided by data collectors for the test case - /// - private List collectorDataEntries = new List(); - - #endregion - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - /// - /// The computer name. - /// - /// - /// The run id. - /// - /// - /// The test. - /// - /// - /// The outcome. - /// - public TestResult( - Guid runId, - Guid testId, - Guid executionId, - Guid parentExecutionId, - string resultName, - string computerName, - TestOutcome outcome, - TestType testType, - TestListCategoryId testCategoryId, - TrxFileHelper trxFileHelper) - { - Debug.Assert(computerName != null, "computername is null"); - Debug.Assert(!Guid.Empty.Equals(executionId), "ExecutionId is empty"); - Debug.Assert(!Guid.Empty.Equals(testId), "TestId is empty"); - - this.Initialize(); - - this.id = new TestResultId(runId, executionId, parentExecutionId, testId); - this.resultName = resultName; - this.testType = testType; - this.computerInfo = computerName; - this.outcome = outcome; - this.categoryId = testCategoryId; - this.relativeTestResultsDirectory = TestRunDirectories.GetRelativeTestResultsDirectory(executionId); - this.trxFileHelper = trxFileHelper; - } + private readonly List _collectorDataEntries = new(); - #endregion + #endregion - #region properties + #region Constructor - /// - /// Gets or sets the end time. - /// - public DateTime EndTime - { - get { return this.endTime; } - set { this.endTime = value; } - } + /// + /// Initializes a new instance of the class. + /// + /// + /// The computer name. + /// + /// + /// The run id. + /// + /// + /// The test. + /// + /// + /// The outcome. + /// + public TestResult( + Guid runId, + Guid testId, + Guid executionId, + Guid parentExecutionId, + string resultName, + string computerName, + TestOutcome outcome, + TestType testType, + TestListCategoryId testCategoryId, + TrxFileHelper trxFileHelper) + { + Debug.Assert(computerName != null, "computername is null"); + Debug.Assert(!Guid.Empty.Equals(executionId), "ExecutionId is empty"); + Debug.Assert(!Guid.Empty.Equals(testId), "TestId is empty"); + + Initialize(); + + Id = new TestResultId(runId, executionId, parentExecutionId, testId); + _resultName = resultName; + _testType = testType; + ComputerName = computerName; + Outcome = outcome; + _categoryId = testCategoryId; + RelativeTestResultsDirectory = TestRunDirectories.GetRelativeTestResultsDirectory(executionId); + _trxFileHelper = trxFileHelper; + } - /// - /// Gets or sets the start time. - /// - public DateTime StartTime - { - get { return this.startTime; } - set { this.startTime = value; } - } + #endregion - /// - /// Gets or sets the duration. - /// - public TimeSpan Duration - { - get { return this.duration; } + #region properties - set - { - // On some hardware the Stopwatch.Elapsed can return a negative number. This tends - // to happen when the duration of the test is very short and it is hardware dependent - // (seems to happen most on virtual machines or machines with AMD processors). To prevent - // reporting a negative duration, use TimeSpan.Zero when the elapsed time is less than zero. - EqtTrace.WarningIf(value < TimeSpan.Zero, "TestResult.Duration: The duration is being set to {0}. Since the duration is negative the duration will be updated to zero.", value); - this.duration = value > TimeSpan.Zero ? value : TimeSpan.Zero; - } - } + /// + /// Gets or sets the end time. + /// + public DateTime EndTime { get; set; } - /// - /// Gets the computer name. - /// - public string ComputerName - { - get { return this.computerInfo; } - } + /// + /// Gets or sets the start time. + /// + public DateTime StartTime { get; set; } - /// - /// Gets or sets the outcome. - /// - public TestOutcome Outcome + /// + /// Gets or sets the duration. + /// + public TimeSpan Duration + { + get { return _duration; } + + set { - get { return this.outcome; } - set { this.outcome = value; } + // On some hardware the Stopwatch.Elapsed can return a negative number. This tends + // to happen when the duration of the test is very short and it is hardware dependent + // (seems to happen most on virtual machines or machines with AMD processors). To prevent + // reporting a negative duration, use TimeSpan.Zero when the elapsed time is less than zero. + EqtTrace.WarningIf(value < TimeSpan.Zero, "TestResult.Duration: The duration is being set to {0}. Since the duration is negative the duration will be updated to zero.", value); + _duration = value > TimeSpan.Zero ? value : TimeSpan.Zero; } + } + /// + /// Gets the computer name. + /// + public string ComputerName { get; private set; } - /// - /// Gets or sets the id. - /// - public TestResultId Id - { - get { return this.id; } - internal set { this.id = value; } - } + /// + /// Gets or sets the outcome. + /// + public TestOutcome Outcome { get; set; } - /// - /// Gets or sets the error message. - /// - public string ErrorMessage - { - get { return this.errorInfo?.Message ?? string.Empty; } - set - { - if (this.errorInfo == null) - this.errorInfo = new TestResultErrorInfo(); - this.errorInfo.Message = value; - } - } + /// + /// Gets or sets the id. + /// + public TestResultId Id { get; internal set; } - /// - /// Gets or sets the error stack trace. - /// - public string ErrorStackTrace + /// + /// Gets or sets the error message. + /// + public string ErrorMessage + { + get { return _errorInfo?.Message ?? string.Empty; } + set { - get { return this.errorInfo?.StackTrace ?? string.Empty; } - - set - { - if (this.errorInfo == null) - this.errorInfo = new TestResultErrorInfo(); + if (_errorInfo == null) + _errorInfo = new TestResultErrorInfo(); - this.errorInfo.StackTrace = value; - } + _errorInfo.Message = value; } + } - /// - /// Gets the text messages. - /// - /// - /// Additional information messages from TestTextResultMessage, e.g. generated by TestOutcome.WriteLine. - /// Avoid using this property in the following way: for (int i=0; i<prop.Length; i++) { ... prop[i] ...} - /// - public string[] TextMessages + /// + /// Gets or sets the error stack trace. + /// + public string ErrorStackTrace + { + get { return _errorInfo?.StackTrace ?? string.Empty; } + + set { - get { return (string[])this.textMessages.ToArray(typeof(string)); } + if (_errorInfo == null) + _errorInfo = new TestResultErrorInfo(); - set - { - if (value != null) - this.textMessages = new ArrayList(value); - else - this.textMessages.Clear(); - } + _errorInfo.StackTrace = value; } + } - /// - /// Gets or sets the standard out. - /// - public string StdOut - { - get { return this.stdOut ?? string.Empty; } - set { this.stdOut = value; } - } + /// + /// Gets the text messages. + /// + /// + /// Additional information messages from TestTextResultMessage, e.g. generated by TestOutcome.WriteLine. + /// Avoid using this property in the following way: for (int i=0; i<prop.Length; i++) { ... prop[i] ...} + /// + public string[] TextMessages + { + get { return (string[])_textMessages.ToArray(typeof(string)); } - /// - /// Gets or sets the standard err. - /// - public string StdErr + set { - get { return this.stdErr ?? string.Empty; } - set { this.stdErr = value; } + if (value != null) + _textMessages = new ArrayList(value); + else + _textMessages.Clear(); } + } - /// - /// Gets or sets the debug trace. - /// - public string DebugTrace - { - get { return this.debugTrace ?? string.Empty; } - set { this.debugTrace = value; } - } + /// + /// Gets or sets the standard out. + /// + public string StdOut + { + get { return _stdOut ?? string.Empty; } + set { _stdOut = value; } + } + + /// + /// Gets or sets the standard err. + /// + public string StdErr + { + get { return _stdErr ?? string.Empty; } + set { _stdErr = value; } + } + + /// + /// Gets or sets the debug trace. + /// + public string DebugTrace + { + get { return _debugTrace ?? string.Empty; } + set { _debugTrace = value; } + } - /// - /// Gets the path to the test results directory - /// - public string TestResultsDirectory + /// + /// Gets the path to the test results directory + /// + public string TestResultsDirectory + { + get { - get + if (_testRun == null) { - if (this.testRun == null) - { - Debug.Fail("'m_testRun' is null"); - throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, TrxLoggerResources.Common_MissingRunInResult)); - } - - return this.testRun.GetResultFilesDirectory(this); + Debug.Fail("'m_testRun' is null"); + throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, TrxLoggerResources.Common_MissingRunInResult)); } - } - /// - /// Gets the directory containing the test result files, relative to the root results directory - /// - public string RelativeTestResultsDirectory - { - get { return this.relativeTestResultsDirectory; } + return _testRun.GetResultFilesDirectory(this); } + } - /// - /// Gets or sets the data row info. - /// - public int DataRowInfo - { - get { return this.dataRowInfo; } - set { this.dataRowInfo = value; } - } + /// + /// Gets the directory containing the test result files, relative to the root results directory + /// + public string RelativeTestResultsDirectory { get; private set; } - /// - /// Gets or sets the result type. - /// - public string ResultType - { - get { return this.resultType; } - set { this.resultType = value; } - } + /// + /// Gets or sets the data row info. + /// + public int DataRowInfo { get; set; } - #endregion + /// + /// Gets or sets the result type. + /// + public string ResultType { get; set; } - #region Overrides - public override bool Equals(object obj) - { - TestResult trm = obj as TestResult; - if (trm == null) - { - return false; - } - Debug.Assert(this.id != null, "id is null"); - Debug.Assert(trm.id != null, "test result message id is null"); - return this.id.Equals(trm.id); - } + #endregion - public override int GetHashCode() + #region Overrides + public override bool Equals(object obj) + { + if (obj is not TestResult trm) { - Debug.Assert(this.id != null, "id is null"); - return this.id.GetHashCode(); + return false; } + Debug.Assert(Id != null, "id is null"); + Debug.Assert(trm.Id != null, "test result message id is null"); + return Id.Equals(trm.Id); + } - #endregion + public override int GetHashCode() + { + Debug.Assert(Id != null, "id is null"); + return Id.GetHashCode(); + } - /// - /// Helper function to add a text message info to the test result - /// - /// Message to be added - public void AddTextMessage(string text) - { - EqtAssert.ParameterNotNull(text, nameof(text)); - this.textMessages.Add(text); - } + #endregion - /// - /// Sets the test run the test was executed in - /// - /// The test run the test was executed in - internal virtual void SetTestRun(TestRun testRun) - { - Debug.Assert(testRun != null, "'testRun' is null"); - this.testRun = testRun; - } + /// + /// Helper function to add a text message info to the test result + /// + /// Message to be added + public void AddTextMessage(string text) + { + EqtAssert.ParameterNotNull(text, nameof(text)); + _textMessages.Add(text); + } - /// - /// Adds result files to the collection - /// - /// Paths to the result files - internal void AddResultFiles(IEnumerable resultFileList) - { - Debug.Assert(resultFileList != null, "'resultFileList' is null"); + /// + /// Sets the test run the test was executed in + /// + /// The test run the test was executed in + internal virtual void SetTestRun(TestRun testRun) + { + Debug.Assert(testRun != null, "'testRun' is null"); + _testRun = testRun; + } - string testResultsDirectory = this.TestResultsDirectory; - foreach (string resultFile in resultFileList) - { - Debug.Assert(!string.IsNullOrEmpty(resultFile), "'resultFile' is null or empty"); - Debug.Assert(resultFile.Trim() == resultFile, "'resultFile' has whitespace at the ends"); + /// + /// Adds result files to the collection + /// + /// Paths to the result files + internal void AddResultFiles(IEnumerable resultFileList) + { + Debug.Assert(resultFileList != null, "'resultFileList' is null"); - this.resultFiles[trxFileHelper.MakePathRelative(resultFile, testResultsDirectory)] = null; - } + string testResultsDirectory = TestResultsDirectory; + foreach (string resultFile in resultFileList) + { + Debug.Assert(!string.IsNullOrEmpty(resultFile), "'resultFile' is null or empty"); + Debug.Assert(resultFile.Trim() == resultFile, "'resultFile' has whitespace at the ends"); + + _resultFiles[_trxFileHelper.MakePathRelative(resultFile, testResultsDirectory)] = null; } + } - /// - /// Adds collector data entries to the collection - /// - /// The collector data entry to add - internal void AddCollectorDataEntries(IEnumerable collectorDataEntryList) - { - Debug.Assert(collectorDataEntryList != null, "'collectorDataEntryList' is null"); + /// + /// Adds collector data entries to the collection + /// + /// The collector data entry to add + internal void AddCollectorDataEntries(IEnumerable collectorDataEntryList) + { + Debug.Assert(collectorDataEntryList != null, "'collectorDataEntryList' is null"); - string testResultsDirectory = this.TestResultsDirectory; - foreach (CollectorDataEntry collectorDataEntry in collectorDataEntryList) - { - Debug.Assert(collectorDataEntry != null, "'collectorDataEntry' is null"); - Debug.Assert(!this.collectorDataEntries.Contains(collectorDataEntry), "The collector data entry already exists in the collection"); + string testResultsDirectory = TestResultsDirectory; + foreach (CollectorDataEntry collectorDataEntry in collectorDataEntryList) + { + Debug.Assert(collectorDataEntry != null, "'collectorDataEntry' is null"); + Debug.Assert(!_collectorDataEntries.Contains(collectorDataEntry), "The collector data entry already exists in the collection"); - this.collectorDataEntries.Add(collectorDataEntry.Clone(testResultsDirectory, false)); - } + _collectorDataEntries.Add(collectorDataEntry.Clone(testResultsDirectory, false)); } + } - #region IXmlTestStore Members + #region IXmlTestStore Members - /// - /// Saves the class under the XmlElement.. - /// - /// - /// The parent xml. - /// - /// - /// The parameter - /// - public virtual void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) - { - XmlPersistence helper = new XmlPersistence(); - - helper.SaveObject(this.id, element, ".", parameters); - helper.SaveSimpleField(element, "@testName", this.resultName, string.Empty); - helper.SaveSimpleField(element, "@computerName", this.computerInfo, string.Empty); - helper.SaveSimpleField(element, "@duration", this.duration, default(TimeSpan)); - helper.SaveSimpleField(element, "@startTime", this.startTime, default(DateTime)); - helper.SaveSimpleField(element, "@endTime", this.endTime, default(DateTime)); - helper.SaveGuid(element, "@testType", this.testType.Id); - - if (this.stdOut != null) - this.stdOut = this.stdOut.Trim(); - - if (this.stdErr != null) - this.stdErr = this.stdErr.Trim(); - - helper.SaveSimpleField(element, "@outcome", this.outcome, default(TestOutcome)); - helper.SaveSimpleField(element, "Output/StdOut", this.stdOut, string.Empty); - helper.SaveSimpleField(element, "Output/StdErr", this.stdErr, string.Empty); - helper.SaveSimpleField(element, "Output/DebugTrace", this.debugTrace, string.Empty); - helper.SaveObject(this.errorInfo, element, "Output/ErrorInfo", parameters); - helper.SaveGuid(element, "@testListId", this.categoryId.Id); - helper.SaveIEnumerable(this.textMessages, element, "Output/TextMessages", ".", "Message", parameters); - helper.SaveSimpleField(element, "@relativeResultsDirectory", this.relativeTestResultsDirectory, null); - helper.SaveIEnumerable(this.resultFiles.Keys, element, "ResultFiles", "@path", "ResultFile", parameters); - helper.SaveIEnumerable(this.collectorDataEntries, element, "CollectorDataEntries", ".", "Collector", parameters); - - if (this.dataRowInfo >= 0) - helper.SaveSimpleField(element, "@dataRowInfo", this.dataRowInfo, -1); - - if (!string.IsNullOrEmpty(this.resultType)) - helper.SaveSimpleField(element, "@resultType", this.resultType, string.Empty); - } + /// + /// Saves the class under the XmlElement.. + /// + /// + /// The parent xml. + /// + /// + /// The parameter + /// + public virtual void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) + { + XmlPersistence helper = new(); + + helper.SaveObject(Id, element, ".", parameters); + helper.SaveSimpleField(element, "@testName", _resultName, string.Empty); + helper.SaveSimpleField(element, "@computerName", ComputerName, string.Empty); + helper.SaveSimpleField(element, "@duration", _duration, default(TimeSpan)); + helper.SaveSimpleField(element, "@startTime", StartTime, default(DateTime)); + helper.SaveSimpleField(element, "@endTime", EndTime, default(DateTime)); + helper.SaveGuid(element, "@testType", _testType.Id); + + if (_stdOut != null) + _stdOut = _stdOut.Trim(); + + if (_stdErr != null) + _stdErr = _stdErr.Trim(); + + helper.SaveSimpleField(element, "@outcome", Outcome, default(TestOutcome)); + helper.SaveSimpleField(element, "Output/StdOut", _stdOut, string.Empty); + helper.SaveSimpleField(element, "Output/StdErr", _stdErr, string.Empty); + helper.SaveSimpleField(element, "Output/DebugTrace", _debugTrace, string.Empty); + helper.SaveObject(_errorInfo, element, "Output/ErrorInfo", parameters); + helper.SaveGuid(element, "@testListId", _categoryId.Id); + helper.SaveIEnumerable(_textMessages, element, "Output/TextMessages", ".", "Message", parameters); + helper.SaveSimpleField(element, "@relativeResultsDirectory", RelativeTestResultsDirectory, null); + helper.SaveIEnumerable(_resultFiles.Keys, element, "ResultFiles", "@path", "ResultFile", parameters); + helper.SaveIEnumerable(_collectorDataEntries, element, "CollectorDataEntries", ".", "Collector", parameters); + + if (DataRowInfo >= 0) + helper.SaveSimpleField(element, "@dataRowInfo", DataRowInfo, -1); + + if (!string.IsNullOrEmpty(ResultType)) + helper.SaveSimpleField(element, "@resultType", ResultType, string.Empty); + } - #endregion + #endregion - private void Initialize() - { - this.textMessages = new ArrayList(); - this.dataRowInfo = -1; - } + private void Initialize() + { + _textMessages = new ArrayList(); + DataRowInfo = -1; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestResultAggregation.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestResultAggregation.cs index 8c06d8ec58..4477132934 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestResultAggregation.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestResultAggregation.cs @@ -1,54 +1,55 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System; +using System.Collections.Generic; + +using Utility; + +using XML; + +/// +/// Test result aggregation. +/// +internal class TestResultAggregation : TestResult, ITestResultAggregation { - using System; - using System.Collections.Generic; - using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; + protected List _innerResults; + + public TestResultAggregation( + Guid runId, + Guid testId, + Guid executionId, + Guid parentExecutionId, + string resultName, + string computerName, + TestOutcome outcome, + TestType testType, + TestListCategoryId testCategoryId, + TrxFileHelper trxFileHelper) : base(runId, testId, executionId, parentExecutionId, resultName, computerName, outcome, testType, testCategoryId, trxFileHelper) { } /// - /// Test result aggregation. + /// Gets the inner results. /// - internal class TestResultAggregation : TestResult, ITestResultAggregation + public List InnerResults { - protected List innerResults; - - public TestResultAggregation( - Guid runId, - Guid testId, - Guid executionId, - Guid parentExecutionId, - string resultName, - string computerName, - TestOutcome outcome, - TestType testType, - TestListCategoryId testCategoryId, - TrxFileHelper trxFileHelper) : base(runId, testId, executionId, parentExecutionId, resultName, computerName, outcome, testType, testCategoryId, trxFileHelper) { } - - /// - /// Gets the inner results. - /// - public List InnerResults + get { - get + if (_innerResults == null) { - if (innerResults == null) - { - innerResults = new List(); - } - return innerResults; + _innerResults = new List(); } + return _innerResults; } + } - public override void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) - { - base.Save(element, parameters); + public override void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) + { + base.Save(element, parameters); - XmlPersistence helper = new XmlPersistence(); - if (this.InnerResults.Count > 0) - helper.SaveIEnumerable(this.InnerResults, element, "InnerResults", ".", null, parameters); - } + XmlPersistence helper = new(); + if (InnerResults.Count > 0) + helper.SaveIEnumerable(InnerResults, element, "InnerResults", ".", null, parameters); } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRun.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRun.cs index eec01d3e69..f3fc7f118f 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRun.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRun.cs @@ -1,218 +1,218 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel -{ - using System; - using System.Diagnostics; - using System.Globalization; - using System.IO; - using System.Security.Principal; +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; - using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; +using System; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Security.Principal; - using TrxLoggerResources = Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.Resources.TrxResource; +using Utility; - /// - /// Class having information about a test run. - /// - internal sealed class TestRun - { - #region Fields +using XML; - #region Summary fields +using TrxLoggerResources = VisualStudio.TestPlatform.Extensions.TrxLogger.Resources.TrxResource; - // These fields will be valid when the test run summary is loaded from a results file. - // The summary fields need to be first in the class so they get serialized first. When we - // read the summary we don't want to parse the XML tags for other fields because they can - // be quite large. - // - // When reading the results file, the summary is considered complete when all summary fields - // are non-null. Any new summary fields that are initialized in the constructor should be - // placed before the last non-initialized field. - // - // The summary parsing code is in XmlTestReader.ReadTestRunSummary. - [StoreXmlSimpleField] - private Guid id; +/// +/// Class having information about a test run. +/// +internal sealed class TestRun +{ + #region Fields - [StoreXmlSimpleField] - private string name; + #region Summary fields - [StoreXmlSimpleField("@runUser", "")] - private string runUser; + // These fields will be valid when the test run summary is loaded from a results file. + // The summary fields need to be first in the class so they get serialized first. When we + // read the summary we don't want to parse the XML tags for other fields because they can + // be quite large. + // + // When reading the results file, the summary is considered complete when all summary fields + // are non-null. Any new summary fields that are initialized in the constructor should be + // placed before the last non-initialized field. + // + // The summary parsing code is in XmlTestReader.ReadTestRunSummary. + [StoreXmlSimpleField("@id")] + private Guid _id; - private TestRunConfiguration runConfig; + [StoreXmlSimpleField("@name")] + private string _name; - #endregion Summary fields + [StoreXmlSimpleField("@runUser", "")] + private string _runUser; - #region Non-summary fields - [StoreXmlSimpleField("Times/@creation")] - private DateTime created; + private TestRunConfiguration _runConfig; - [StoreXmlSimpleField("Times/@queuing")] - private DateTime queued; + #endregion Summary fields - [StoreXmlSimpleField("Times/@start")] - private DateTime started; + #region Non-summary fields + [StoreXmlSimpleField("Times/@creation")] + private DateTime _created; - [StoreXmlSimpleField("Times/@finish")] - private DateTime finished; + [StoreXmlSimpleField("Times/@queuing")] + private DateTime _queued; - #endregion + [StoreXmlSimpleField("Times/@start")] + private DateTime _started; - #endregion + [StoreXmlSimpleField("Times/@finish")] + private DateTime _finished; - #region Constructors + #endregion - /// - /// Initializes a new instance of the class. - /// - /// - /// The run id. - /// - internal TestRun(Guid runId) - { - this.Initialize(); + #endregion - EqtAssert.IsTrue(!Guid.Empty.Equals(runId), "Can't use Guid.Empty for run ID."); - this.id = runId; - } + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// + /// The run id. + /// + internal TestRun(Guid runId) + { + Initialize(); + + EqtAssert.IsTrue(!Guid.Empty.Equals(runId), "Can't use Guid.Empty for run ID."); + _id = runId; + } - #endregion Constructors + #endregion Constructors - /// - /// Gets or sets the run configuration. - /// - internal TestRunConfiguration RunConfiguration + /// + /// Gets or sets the run configuration. + /// + internal TestRunConfiguration RunConfiguration + { + get { - get - { - return this.runConfig; - } - - set - { - EqtAssert.ParameterNotNull(value, "RunConfiguration"); - this.runConfig = value; - } + return _runConfig; } - /// - /// Gets or sets the start time. - /// - internal DateTime Started + set { - get - { - return this.started; - } - - set - { - this.started = value; - } + EqtAssert.ParameterNotNull(value, "RunConfiguration"); + _runConfig = value; } + } - /// - /// Gets or sets the finished time of Test run. - /// - internal DateTime Finished + /// + /// Gets or sets the start time. + /// + internal DateTime Started + { + get { - get { return this.finished; } - set { this.finished = value; } + return _started; } - /// - /// Gets or sets the name. - /// - internal string Name + set { - get - { - return this.name; - } - - set - { - EqtAssert.StringNotNullOrEmpty(value, "Name"); - this.name = value; - } + _started = value; } + } + + /// + /// Gets or sets the finished time of Test run. + /// + internal DateTime Finished + { + get { return _finished; } + set { _finished = value; } + } - /// - /// Gets the id. - /// - internal Guid Id + /// + /// Gets or sets the name. + /// + internal string Name + { + get { - get { return this.id; } + return _name; } - /// - /// WARNING: do not use from inside Test Adapters, use from only on HA by UI etc. - /// Returns directory on HA for dependent files for TestResult. XmlPersistence method for UI. - /// Throws on error (e.g. if deployment directory was not set for test run). - /// - /// - /// Test Result to get dependent files directory for. - /// - /// - /// Result directory. - /// - internal string GetResultFilesDirectory(TestResult result) + set { - EqtAssert.ParameterNotNull(result, nameof(result)); - return Path.Combine(this.GetResultsDirectory(), result.RelativeTestResultsDirectory); + EqtAssert.StringNotNullOrEmpty(value, "Name"); + _name = value; } + } + + /// + /// Gets the id. + /// + internal Guid Id + { + get { return _id; } + } + + /// + /// WARNING: do not use from inside Test Adapters, use from only on HA by UI etc. + /// Returns directory on HA for dependent files for TestResult. XmlPersistence method for UI. + /// Throws on error (e.g. if deployment directory was not set for test run). + /// + /// + /// Test Result to get dependent files directory for. + /// + /// + /// Result directory. + /// + internal string GetResultFilesDirectory(TestResult result) + { + EqtAssert.ParameterNotNull(result, nameof(result)); + return Path.Combine(GetResultsDirectory(), result.RelativeTestResultsDirectory); + } - /// - /// Gets the results directory, which is the run deployment In directory - /// - /// The results directory - /// This method is called by public properties/methods, so it needs to throw on error - internal string GetResultsDirectory() + /// + /// Gets the results directory, which is the run deployment In directory + /// + /// The results directory + /// This method is called by public properties/methods, so it needs to throw on error + internal string GetResultsDirectory() + { + if (RunConfiguration == null) { - if (this.RunConfiguration == null) - { - Debug.Fail("'RunConfiguration' is null"); - throw new Exception(String.Format(CultureInfo.CurrentCulture, TrxLoggerResources.Common_MissingRunConfigInRun)); - } - - if (string.IsNullOrEmpty(this.RunConfiguration.RunDeploymentRootDirectory)) - { - Debug.Fail("'RunConfiguration.RunDeploymentRootDirectory' is null or empty"); - throw new Exception(String.Format(CultureInfo.CurrentCulture, TrxLoggerResources.Common_MissingRunDeploymentRootInRunConfig)); - } - - return this.RunConfiguration.RunDeploymentInDirectory; + Debug.Fail("'RunConfiguration' is null"); + throw new Exception(String.Format(CultureInfo.CurrentCulture, TrxLoggerResources.Common_MissingRunConfigInRun)); } - private static string FormatDateTimeForRunName(DateTime timeStamp) + if (string.IsNullOrEmpty(RunConfiguration.RunDeploymentRootDirectory)) { - // We use custom format string to make sure that runs are sorted in the same way on all intl machines. - // This is both for directory names and for Data Warehouse. - return timeStamp.ToString("yyyy-MM-dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo); + Debug.Fail("'RunConfiguration.RunDeploymentRootDirectory' is null or empty"); + throw new Exception(String.Format(CultureInfo.CurrentCulture, TrxLoggerResources.Common_MissingRunDeploymentRootInRunConfig)); } - private void Initialize() + return RunConfiguration.RunDeploymentInDirectory; + } + + private static string FormatDateTimeForRunName(DateTime timeStamp) + { + // We use custom format string to make sure that runs are sorted in the same way on all intl machines. + // This is both for directory names and for Data Warehouse. + return timeStamp.ToString("yyyy-MM-dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo); + } + + private void Initialize() + { + _id = Guid.NewGuid(); + _name = String.Format(CultureInfo.CurrentCulture, TrxLoggerResources.Common_TestRunName, Environment.GetEnvironmentVariable("UserName"), Environment.MachineName, FormatDateTimeForRunName(DateTime.Now)); + + // Fix for issue (https://github.com/Microsoft/vstest/issues/213). Since there is no way to find current user in linux machine. + // We are catching PlatformNotSupportedException for non windows machine. + try + { + _runUser = WindowsIdentity.GetCurrent().Name; + } + catch (PlatformNotSupportedException) { - this.id = Guid.NewGuid(); - this.name = String.Format(CultureInfo.CurrentCulture, TrxLoggerResources.Common_TestRunName, Environment.GetEnvironmentVariable("UserName"), Environment.MachineName, FormatDateTimeForRunName(DateTime.Now)); - - // Fix for issue (https://github.com/Microsoft/vstest/issues/213). Since there is no way to find current user in linux machine. - // We are catching PlatformNotSupportedException for non windows machine. - try - { - this.runUser = WindowsIdentity.GetCurrent().Name; - } - catch (PlatformNotSupportedException) - { - this.runUser = string.Empty; - } - this.created = DateTime.UtcNow; - this.queued = DateTime.UtcNow; - this.started = DateTime.UtcNow; - this.finished = DateTime.UtcNow; + _runUser = string.Empty; } + _created = DateTime.UtcNow; + _queued = DateTime.UtcNow; + _started = DateTime.UtcNow; + _finished = DateTime.UtcNow; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRunConfiguration.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRunConfiguration.cs index 0605acb7f7..41fa75be26 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRunConfiguration.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRunConfiguration.cs @@ -1,161 +1,160 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System; +using System.Diagnostics; +using System.IO; +using System.Xml; + +using Utility; + +using XML; + +/// +/// The test run configuration. +/// +internal class TestRunConfiguration : IXmlTestStore, IXmlTestStoreCustom { - using System; - using System.Diagnostics; - using System.IO; - using System.Xml; + internal static readonly string DeploymentInDirectorySuffix = "In"; + + #region Fields + private readonly TestRunConfigurationId _id; + private readonly TrxFileHelper _trxFileHelper; - using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; + [StoreXmlSimpleField("@name", DefaultValue = "")] + private readonly string _name; + + private string _runDeploymentRoot; + + #endregion /// - /// The test run configuration. + /// Initializes a new instance of the class. /// - internal class TestRunConfiguration : IXmlTestStore, IXmlTestStoreCustom + /// + /// The name of Run Configuration. + /// + /// + /// InternalFileHelper instance to use in file operations. + /// + internal TestRunConfiguration(string name, TrxFileHelper trxFileHelper) { - internal static readonly string DeploymentInDirectorySuffix = "In"; - - #region Fields - private TestRunConfigurationId id; - private readonly TrxFileHelper trxFileHelper; + EqtAssert.ParameterNotNull(name, nameof(name)); - [StoreXmlSimpleField(DefaultValue = "")] - private string name; - - private string runDeploymentRoot; + _name = name; + _runDeploymentRoot = string.Empty; + _id = new TestRunConfigurationId(); + _trxFileHelper = trxFileHelper; + } - #endregion + #region IXmlTestStoreCustom Members - /// - /// Initializes a new instance of the class. - /// - /// - /// The name of Run Configuration. - /// - /// - /// InternalFileHelper instance to use in file operations. - /// - internal TestRunConfiguration(string name, TrxFileHelper trxFileHelper) + /// + /// Gets the element name. + /// + public string ElementName + { + get { - EqtAssert.ParameterNotNull(name, nameof(name)); + return "TestSettings"; + } + } - this.name = name; - this.runDeploymentRoot = string.Empty; - this.id = new TestRunConfigurationId(); - this.trxFileHelper = trxFileHelper; + /// + /// Gets the namespace uri. + /// + public string NamespaceUri + { + get + { + return @"http://microsoft.com/schemas/VisualStudio/TeamTest/2010"; } + } - #region IXmlTestStoreCustom Members + #endregion - /// - /// Gets the element name. - /// - public string ElementName + /// + /// Gets directory that receives reverse-deployed files from Controller. + /// + public string RunDeploymentInDirectory + { + get { - get - { - return "TestSettings"; - } + Debug.Assert(_runDeploymentRoot != null, "runDeploymentRoot is null"); + return Path.Combine(_runDeploymentRoot, DeploymentInDirectorySuffix); } + } - /// - /// Gets the namespace uri. - /// - public string NamespaceUri + /// + /// Gets or sets RunDeploymentRootDirectory + /// INTERNAL PROPERTY. DO NOT USE (except execution). + /// Run-level deployment root directory, already inside RunId directory, parent of In and Out directories. + /// + internal string RunDeploymentRootDirectory + { + get { - get - { - return @"http://microsoft.com/schemas/VisualStudio/TeamTest/2010"; - } + return _runDeploymentRoot; } - #endregion - - /// - /// Gets directory that receives reverse-deployed files from Controller. - /// - public string RunDeploymentInDirectory + set { - get - { - Debug.Assert(this.runDeploymentRoot != null, "runDeploymentRoot is null"); - return Path.Combine(this.runDeploymentRoot, DeploymentInDirectorySuffix); - } + Debug.Assert(!string.IsNullOrEmpty(value), "RunDeploymentRootDirectory.value should not be null or empty."); + _runDeploymentRoot = value; } + } + + #region IXmlTestStore Members - /// - /// Gets or sets RunDeploymentRootDirectory - /// INTERNAL PROPERTY. DO NOT USE (except execution). - /// Run-level deployment root directory, already inside RunId directory, parent of In and Out directories. - /// - internal string RunDeploymentRootDirectory + /// + /// Saves the class under the XmlElement.. + /// + /// + /// The parent xml. + /// + /// + /// The parameters. + /// + public void Save(XmlElement element, XmlTestStoreParameters parameters) + { + XmlPersistence helper = new(); + + // Save all fields marked as StoreXmlSimpleField. + helper.SaveSingleFields(element, this, parameters); + + helper.SaveGuid(element, "@id", _id.Id); + + // When saving and loading a TRX file, we want to use the run deployment root directory based on where the TRX file + // is being saved to or loaded from + if (parameters.TryGetValue(XmlFilePersistence.RootObjectType, out object filePersistenceRootObjectType) && + (Type)filePersistenceRootObjectType == typeof(TestRun)) { - get - { - return this.runDeploymentRoot; - } - - set - { - Debug.Assert(!string.IsNullOrEmpty(value), "RunDeploymentRootDirectory.value should not be null or empty."); - this.runDeploymentRoot = value; - } + Debug.Assert( + parameters.ContainsKey(XmlFilePersistence.DirectoryPath), + "TestRun is the type of the root object being saved to a file, but the DirectoryPath was not specified in the XML test store parameters"); + + Debug.Assert( + !string.IsNullOrEmpty(_runDeploymentRoot), + "TestRun is the type of the root object being saved to a file, but the run deployment root directory is null or empty"); + + // We are saving a TestRun object as the root element in a file (TRX file), so just save the test run directory + // name (last directory in the run deployment root), which is the relative path to the run deployment root + // directory from the directory where the TRX file exists + helper.SaveSimpleField( + element, + "Deployment/@runDeploymentRoot", + _trxFileHelper.MakePathRelative(_runDeploymentRoot, Path.GetDirectoryName(_runDeploymentRoot)), + string.Empty); } - - #region IXmlTestStore Members - - /// - /// Saves the class under the XmlElement.. - /// - /// - /// The parent xml. - /// - /// - /// The parameters. - /// - public void Save(XmlElement element, XmlTestStoreParameters parameters) + else { - XmlPersistence helper = new XmlPersistence(); - - // Save all fields marked as StoreXmlSimpleField. - helper.SaveSingleFields(element, this, parameters); - - helper.SaveGuid(element, "@id", this.id.Id); - - // When saving and loading a TRX file, we want to use the run deployment root directory based on where the TRX file - // is being saved to or loaded from - object filePersistenceRootObjectType; - if (parameters.TryGetValue(XmlFilePersistence.RootObjectType, out filePersistenceRootObjectType) && - (Type)filePersistenceRootObjectType == typeof(TestRun)) - { - Debug.Assert( - parameters.ContainsKey(XmlFilePersistence.DirectoryPath), - "TestRun is the type of the root object being saved to a file, but the DirectoryPath was not specified in the XML test store parameters"); - - Debug.Assert( - !string.IsNullOrEmpty(this.runDeploymentRoot), - "TestRun is the type of the root object being saved to a file, but the run deployment root directory is null or empty"); - - // We are saving a TestRun object as the root element in a file (TRX file), so just save the test run directory - // name (last directory in the run deployment root), which is the relative path to the run deployment root - // directory from the directory where the TRX file exists - helper.SaveSimpleField( - element, - "Deployment/@runDeploymentRoot", - trxFileHelper.MakePathRelative(this.runDeploymentRoot, Path.GetDirectoryName(this.runDeploymentRoot)), - string.Empty); - } - else - { - // We are not saving a TestRun object as the root element in a file (i.e., we're not saving a TRX file), so just - // save the run deployment root directory as is - helper.SaveSimpleField(element, "Deployment/@runDeploymentRoot", this.runDeploymentRoot, string.Empty); - } + // We are not saving a TestRun object as the root element in a file (i.e., we're not saving a TRX file), so just + // save the run deployment root directory as is + helper.SaveSimpleField(element, "Deployment/@runDeploymentRoot", _runDeploymentRoot, string.Empty); } - - #endregion } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRunConfigurationId.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRunConfigurationId.cs index a79ddad425..62f50a5dcd 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRunConfigurationId.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRunConfigurationId.cs @@ -1,31 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel -{ - using System; +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System; +/// +/// The test run configuration id. +/// +internal sealed class TestRunConfigurationId +{ /// - /// The test run configuration id. + /// Initializes a new instance of the class. /// - internal sealed class TestRunConfigurationId + public TestRunConfigurationId() { - private Guid id; - - /// - /// Initializes a new instance of the class. - /// - public TestRunConfigurationId() - { - this.id = Guid.NewGuid(); - } - - /// - /// Gets the id. - /// - public Guid Id - { - get { return this.id; } - } + Id = Guid.NewGuid(); } -} + + /// + /// Gets the id. + /// + public Guid Id { get; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRunSummary.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRunSummary.cs index d0e95888b0..4a0f80fa61 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRunSummary.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRunSummary.cs @@ -1,192 +1,156 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System; +using System.Collections.Generic; +using System.Xml; + +using XML; + +/// +/// XML object for saving test summary - Outcome and counts (passed, failed etc) +/// +internal class TestRunSummary : IXmlTestStore { - using System; - using System.Collections.Generic; - using System.Xml; + #region Fields + + [StoreXmlSimpleField("Counters/@total")] + private readonly int _totalTests; + [StoreXmlSimpleField("Counters/@executed")] + private readonly int _executedTests; + [StoreXmlSimpleField("Counters/@passed")] + private readonly int _passedTests; + [StoreXmlSimpleField("Counters/@failed")] + private readonly int _failedTests; + [StoreXmlSimpleField("Counters/@error")] + private readonly int _errorTests; + [StoreXmlSimpleField("Counters/@timeout")] + private readonly int _timeoutTests; + [StoreXmlSimpleField("Counters/@aborted")] + private readonly int _abortedTests; + [StoreXmlSimpleField("Counters/@inconclusive")] + private readonly int _inconclusiveTests; + [StoreXmlSimpleField("Counters/@passedButRunAborted")] + private readonly int _passedButRunAborted; + [StoreXmlSimpleField("Counters/@notRunnable")] + private readonly int _notRunnable; + [StoreXmlSimpleField("Counters/@notExecuted")] + private readonly int _notExecuted; + [StoreXmlSimpleField("Counters/@disconnected")] + private readonly int _disconnected; + [StoreXmlSimpleField("Counters/@warning")] + private readonly int _warning; + [StoreXmlSimpleField("Counters/@completed")] + private readonly int _completed; + [StoreXmlSimpleField("Counters/@inProgress")] + private readonly int _inProgress; + [StoreXmlSimpleField("Counters/@pending")] + private readonly int _pending; + [StoreXmlSimpleField("@outcome")] + private readonly TestOutcome _outcome = TestOutcome.Pending; + [StoreXmlSimpleField("Output/StdOut", "")] + private readonly string _stdOut = string.Empty; + + private readonly List _runLevelErrorsAndWarnings; + + private readonly List _collectorDataEntries; + + private readonly IList _resultFiles; + + #endregion + + #region constructor + + /// + /// Initializes a new instance of the class. + /// + /// + /// The total number of tests discover in this run. + /// + /// + /// The executed tests. + /// + /// + /// The pass tests. + /// + /// + /// The fail tests. + /// + /// + /// The outcome. + /// + /// + /// The run messages. + /// + /// + /// The standard out. + /// + /// + /// The result files. + /// + /// + /// The data collectors. + /// + public TestRunSummary( + int total, + int executed, + int pass, + int fail, + TestOutcome outcome, + List runMessages, + string stdOut, + IList resultFiles, + List dataCollectors) + { + _totalTests = total; + _executedTests = executed; + _passedTests = pass; + _failedTests = fail; + int countForNonExistingResults = 0; // if below values are assigned constants 0, compiler gives warning CS0414 + _abortedTests = countForNonExistingResults; + _errorTests = countForNonExistingResults; + _timeoutTests = countForNonExistingResults; + _inconclusiveTests = countForNonExistingResults; + _passedButRunAborted = countForNonExistingResults; + _notRunnable = countForNonExistingResults; + _notExecuted = countForNonExistingResults; + _disconnected = countForNonExistingResults; + _warning = countForNonExistingResults; + _completed = countForNonExistingResults; + _inProgress = countForNonExistingResults; + _pending = countForNonExistingResults; + + _outcome = outcome; + _stdOut = stdOut; + + _runLevelErrorsAndWarnings = runMessages; + _resultFiles = resultFiles; + _collectorDataEntries = dataCollectors; + } - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; + #endregion + + #region IXmlTestStore Members /// - /// XML object for saving test summary - Outcome and counts (passed, failed etc) + /// Saves the class under the XmlElement.. /// - internal class TestRunSummary : IXmlTestStore + /// + /// The parent xml. + /// + /// + /// The parameter + /// + public void Save(XmlElement element, XmlTestStoreParameters parameters) { - #region Fields - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Reviewed. Suppression is ok here.")] - [StoreXmlSimpleField("Counters/@total")] - private int totalTests; - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Reviewed. Suppression is ok here.")] - [StoreXmlSimpleField("Counters/@executed")] - private int executedTests; - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Reviewed. Suppression is ok here.")] - [StoreXmlSimpleField("Counters/@passed")] - private int passedTests; - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Reviewed. Suppression is ok here.")] - [StoreXmlSimpleField("Counters/@failed")] - private int failedTests; - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Reviewed. Suppression is ok here.")] - [StoreXmlSimpleField("Counters/@error")] - private int errorTests; - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Reviewed. Suppression is ok here.")] - [StoreXmlSimpleField("Counters/@timeout")] - private int timeoutTests; - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Reviewed. Suppression is ok here.")] - [StoreXmlSimpleField("Counters/@aborted")] - private int abortedTests; - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Reviewed. Suppression is ok here.")] - [StoreXmlSimpleField("Counters/@inconclusive")] - private int inconclusiveTests; - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Reviewed. Suppression is ok here.")] - [StoreXmlSimpleField("Counters/@passedButRunAborted")] - private int passedButRunAborted; - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Reviewed. Suppression is ok here.")] - [StoreXmlSimpleField("Counters/@notRunnable")] - private int notRunnable; - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Reviewed. Suppression is ok here.")] - [StoreXmlSimpleField("Counters/@notExecuted")] - private int notExecuted; - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Reviewed. Suppression is ok here.")] - [StoreXmlSimpleField("Counters/@disconnected")] - private int disconnected; - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Reviewed. Suppression is ok here.")] - [StoreXmlSimpleField("Counters/@warning")] - private int warning; - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Reviewed. Suppression is ok here.")] - [StoreXmlSimpleField("Counters/@completed")] - private int completed; - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Reviewed. Suppression is ok here.")] - [StoreXmlSimpleField("Counters/@inProgress")] - private int inProgress; - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Reviewed. Suppression is ok here.")] - [StoreXmlSimpleField("Counters/@pending")] - private int pending; - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Reviewed. Suppression is ok here.")] - [StoreXmlSimpleField] - private TestOutcome outcome = TestOutcome.Pending; - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "Reviewed. Suppression is ok here.")] - [StoreXmlSimpleField("Output/StdOut", "")] - private string stdOut = string.Empty; - - private List runLevelErrorsAndWarnings; - - private List collectorDataEntries; - - private IList resultFiles; - - #endregion - - #region constructor - - /// - /// Initializes a new instance of the class. - /// - /// - /// The total number of tests discover in this run. - /// - /// - /// The executed tests. - /// - /// - /// The pass tests. - /// - /// - /// The fail tests. - /// - /// - /// The outcome. - /// - /// - /// The run messages. - /// - /// - /// The standard out. - /// - /// - /// The result files. - /// - /// - /// The data collectors. - /// - public TestRunSummary( - int total, - int executed, - int pass, - int fail, - TestOutcome outcome, - List runMessages, - string stdOut, - IList resultFiles, - List dataCollectors) - { - this.totalTests = total; - this.executedTests = executed; - this.passedTests = pass; - this.failedTests = fail; - int countForNonExistingResults = 0; // if below values are assigned constants 0, compiler gives warning CS0414 - this.abortedTests = countForNonExistingResults; - this.errorTests = countForNonExistingResults; - this.timeoutTests = countForNonExistingResults; - this.inconclusiveTests = countForNonExistingResults; - this.passedButRunAborted = countForNonExistingResults; - this.notRunnable = countForNonExistingResults; - this.notExecuted = countForNonExistingResults; - this.disconnected = countForNonExistingResults; - this.warning = countForNonExistingResults; - this.completed = countForNonExistingResults; - this.inProgress = countForNonExistingResults; - this.pending = countForNonExistingResults; - - this.outcome = outcome; - this.stdOut = stdOut; - - this.runLevelErrorsAndWarnings = runMessages; - this.resultFiles = resultFiles; - this.collectorDataEntries = dataCollectors; - } - - #endregion - - #region IXmlTestStore Members - - /// - /// Saves the class under the XmlElement.. - /// - /// - /// The parent xml. - /// - /// - /// The parameter - /// - public void Save(XmlElement element, XmlTestStoreParameters parameters) - { - XmlPersistence helper = new XmlPersistence(); - helper.SaveSingleFields(element, this, parameters); - helper.SaveIEnumerable(this.runLevelErrorsAndWarnings, element, "RunInfos", ".", "RunInfo", parameters); - helper.SaveIEnumerable(this.resultFiles, element, "ResultFiles", "@path", "ResultFile", parameters); - helper.SaveIEnumerable(this.collectorDataEntries, element, "CollectorDataEntries", ".", "Collector", parameters); - } - - #endregion + XmlPersistence helper = new(); + helper.SaveSingleFields(element, this, parameters); + helper.SaveIEnumerable(_runLevelErrorsAndWarnings, element, "RunInfos", ".", "RunInfo", parameters); + helper.SaveIEnumerable(_resultFiles, element, "ResultFiles", "@path", "ResultFile", parameters); + helper.SaveIEnumerable(_collectorDataEntries, element, "CollectorDataEntries", ".", "Collector", parameters); } + + #endregion } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestType.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestType.cs index 6edc4e3e60..7d64539160 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestType.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestType.cs @@ -1,69 +1,61 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel -{ - using System; +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; +using System; - /// - /// Class identifying test type. - /// - internal sealed class TestType : IXmlTestStore - { - [StoreXmlSimpleField(".")] - private Guid typeId; +using XML; - public TestType(Guid id) - { - if (id == Guid.Empty) - { - throw new ArgumentNullException(nameof(id)); - } - - this.typeId = id; - } +/// +/// Class identifying test type. +/// +internal sealed class TestType : IXmlTestStore +{ + [StoreXmlSimpleField(".")] + private Guid _typeId; - public Guid Id + public TestType(Guid id) + { + if (id == Guid.Empty) { - get { return this.typeId; } + throw new ArgumentNullException(nameof(id)); } - public override bool Equals(object obj) - { - TestType tt = obj as TestType; - - if (tt == null) - { - return false; - } + _typeId = id; + } - return this.typeId.Equals(tt.typeId); - } + public Guid Id + { + get { return _typeId; } + } + public override bool Equals(object obj) + { + return obj is TestType tt && _typeId.Equals(tt._typeId); + } - public override int GetHashCode() - { - return this.typeId.GetHashCode(); - } - #region IXmlTestStore Members + public override int GetHashCode() + { + return _typeId.GetHashCode(); + } - /// - /// Saves the class under the XmlElement.. - /// - /// - /// The parent xml. - /// - /// - /// The parameter - /// - public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) - { - XmlPersistence.SaveUsingReflection(element, this, null, parameters); - } + #region IXmlTestStore Members - #endregion + /// + /// Saves the class under the XmlElement.. + /// + /// + /// The parent xml. + /// + /// + /// The parameter + /// + public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) + { + XmlPersistence.SaveUsingReflection(element, this, null, parameters); } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/UnitTestElement.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/UnitTestElement.cs index aa13af40c4..a288b1686e 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/UnitTestElement.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/UnitTestElement.cs @@ -1,91 +1,88 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System; +using System.Diagnostics; + +using Utility; + +using XML; + +/// +/// Unit test element. +/// +internal class UnitTestElement : TestElement, IXmlTestStoreCustom { - using System; - using System.Diagnostics; - using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; + private string _codeBase; - /// - /// Unit test element. - /// - internal class UnitTestElement : TestElement, IXmlTestStoreCustom + public UnitTestElement( + Guid id, + string name, + string adapter, + TestMethod testMethod) : base(id, name, adapter) { - private string codeBase; - private TestMethod testMethod; + Debug.Assert(!string.IsNullOrEmpty(adapter), "adapter is null"); + Debug.Assert(testMethod != null, "testMethod is null"); + Debug.Assert(testMethod != null && testMethod.ClassName != null, "className is null"); - public UnitTestElement( - Guid id, - string name, - string adapter, - TestMethod testMethod) : base(id, name, adapter) - { - Debug.Assert(!string.IsNullOrEmpty(adapter), "adapter is null"); - Debug.Assert(testMethod != null, "testMethod is null"); - Debug.Assert(testMethod != null && testMethod.ClassName != null, "className is null"); + TestMethod = testMethod; + } - this.testMethod = testMethod; - } + string IXmlTestStoreCustom.ElementName + { + get { return Constants.UnitTestElementName; } + } - string IXmlTestStoreCustom.ElementName - { - get { return Constants.UnitTestElementName; } - } + string IXmlTestStoreCustom.NamespaceUri + { + get { return null; } + } - string IXmlTestStoreCustom.NamespaceUri - { - get { return null; } - } + /// + /// Gets the test type. + /// + public override TestType TestType + { + get { return Constants.UnitTestType; } + } - /// - /// Gets the test type. - /// - public override TestType TestType - { - get { return Constants.UnitTestType; } - } + /// + /// Gets the test method. + /// + public TestMethod TestMethod { get; private set; } - /// - /// Gets the test method. - /// - public TestMethod TestMethod - { - get { return this.testMethod; } - } + /// + /// Gets or sets the storage. + /// + public string CodeBase + { + get { return _codeBase; } - /// - /// Gets or sets the storage. - /// - public string CodeBase + set { - get { return this.codeBase; } - - set - { - EqtAssert.StringNotNullOrEmpty(value, "CodeBase"); - this.codeBase = value; - } + EqtAssert.StringNotNullOrEmpty(value, "CodeBase"); + _codeBase = value; } + } - /// - /// Saves the class under the XmlElement.. - /// - /// - /// The parent xml. - /// - /// - /// The parameter - /// - public override void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) - { - base.Save(element, parameters); - XmlPersistence h = new XmlPersistence(); + /// + /// Saves the class under the XmlElement.. + /// + /// + /// The parent xml. + /// + /// + /// The parameter + /// + public override void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) + { + base.Save(element, parameters); + XmlPersistence h = new(); - h.SaveSimpleField(element, "TestMethod/@codeBase", this.codeBase, string.Empty); - h.SaveSimpleField(element, "TestMethod/@adapterTypeName", this.adapter, string.Empty); - h.SaveObject(this.testMethod, element, "TestMethod", parameters); - } + h.SaveSimpleField(element, "TestMethod/@codeBase", _codeBase, string.Empty); + h.SaveSimpleField(element, "TestMethod/@adapterTypeName", _adapter, string.Empty); + h.SaveObject(TestMethod, element, "TestMethod", parameters); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/UnitTestResult.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/UnitTestResult.cs index d37352497c..ffe8f9f318 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/UnitTestResult.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/UnitTestResult.cs @@ -1,27 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel -{ - using System; - using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System; - /// - /// Class for unit test result. - /// - internal class UnitTestResult: TestResultAggregation - { - public UnitTestResult( - Guid runId, - Guid testId, - Guid executionId, - Guid parentExecutionId, - string resultName, - string computerName, - TestOutcome outcome, - TestType testType, - TestListCategoryId testCategoryId, - TrxFileHelper trxFileHelper - ) : base(runId, testId, executionId, parentExecutionId, resultName, computerName, outcome, testType, testCategoryId, trxFileHelper) { } - } -} +using Utility; + +/// +/// Class for unit test result. +/// +internal class UnitTestResult : TestResultAggregation +{ + public UnitTestResult( + Guid runId, + Guid testId, + Guid executionId, + Guid parentExecutionId, + string resultName, + string computerName, + TestOutcome outcome, + TestType testType, + TestListCategoryId testCategoryId, + TrxFileHelper trxFileHelper + ) : base(runId, testId, executionId, parentExecutionId, resultName, computerName, outcome, testType, testCategoryId, trxFileHelper) { } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/UriDataAttachment.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/UriDataAttachment.cs index 891f48850f..f6caa543ca 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/UriDataAttachment.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/UriDataAttachment.cs @@ -1,153 +1,128 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + +using System; +using System.Diagnostics; +using System.IO; +using System.Xml; + +using Utility; + +using XML; + +/// +/// Class that provides a basic implementation of IUriAttachment, which can be used by plugin +/// writers to send any resource accessible by a URI as an attachment. +/// +internal class UriDataAttachment : IDataAttachment, IXmlTestStore { - using System; - using System.Diagnostics; - using System.IO; - using System.Xml; + private readonly TrxFileHelper _trxFileHelper; + #region Private fields - using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; + /// + /// The name for the attachment + /// + + #endregion /// - /// Class that provides a basic implementation of IUriAttachment, which can be used by plugin - /// writers to send any resource accessible by a URI as an attachment. + /// Initializes the URI data attachment /// - internal class UriDataAttachment : IDataAttachment, IXmlTestStore + /// Short description for the attachment + /// The URI pointing to the resource + /// InternalFileHelper class instance to use in file operations. + /// 'name' is null or empty + /// 'uri' is null + public UriDataAttachment(string description, Uri uri, TrxFileHelper trxFileHelper) { - private readonly TrxFileHelper trxFileHelper; - #region Private fields - - /// - /// The name for the attachment - /// - private string description; - - /// - /// The URI pointing to the resource that forms the data for this attachment - /// - private Uri uri; - - #endregion - - /// - /// Initializes the URI data attachment - /// - /// Short description for the attachment - /// The URI pointing to the resource - /// InternalFileHelper class instance to use in file operations. - /// 'name' is null or empty - /// 'uri' is null - public UriDataAttachment(string description, Uri uri, TrxFileHelper trxFileHelper) - { - this.trxFileHelper = trxFileHelper; + _trxFileHelper = trxFileHelper; - Initialize(description, uri); - } + Initialize(description, uri); + } - #region IDataAttachment Members + #region IDataAttachment Members - /// - /// Gets short description for the attachment. - /// - public string Description - { - get - { - return this.description; - } - } + /// + /// Gets short description for the attachment. + /// + public string Description { get; private set; } - /// - /// Gets the URI that can be used to obtain the data of this attachment - /// - public Uri Uri - { - get - { - return this.uri; - } - } + /// + /// Gets the URI that can be used to obtain the data of this attachment + /// + public Uri Uri { get; private set; } - #endregion + #endregion - #region IXmlTestStore Members + #region IXmlTestStore Members - /// - /// Saves the class under the XmlElement. - /// - /// - /// The parent xml. - /// - /// - /// The parameter - /// - public void Save(XmlElement element, XmlTestStoreParameters parameters) - { - EqtAssert.ParameterNotNull(element, nameof(element)); - - XmlPersistence helper = new XmlPersistence(); - helper.SaveSimpleField(element, ".", this.description, null); - - // The URI is not a true URI, it must always be a local path represented as a URI. Also, the URI can be absolute or - // relative. We use OriginalString because: - // - ToString gets a string in the form "file://..." for an absolute URI and what was passed in for a relative URI - // - AbsoluteUri only works for an absolute URI naturally - // - LocalPath only works for an absolute URI - // Due to the above assumption, that it is always an absolute or relative local path to a file, it's simplest and - // safest to treat the URI as a string and just use OriginalString. - helper.SaveSimpleField(element, "@href", this.uri.OriginalString, null); - } + /// + /// Saves the class under the XmlElement. + /// + /// + /// The parent xml. + /// + /// + /// The parameter + /// + public void Save(XmlElement element, XmlTestStoreParameters parameters) + { + EqtAssert.ParameterNotNull(element, nameof(element)); + + XmlPersistence helper = new(); + helper.SaveSimpleField(element, ".", Description, null); + + // The URI is not a true URI, it must always be a local path represented as a URI. Also, the URI can be absolute or + // relative. We use OriginalString because: + // - ToString gets a string in the form "file://..." for an absolute URI and what was passed in for a relative URI + // - AbsoluteUri only works for an absolute URI naturally + // - LocalPath only works for an absolute URI + // Due to the above assumption, that it is always an absolute or relative local path to a file, it's simplest and + // safest to treat the URI as a string and just use OriginalString. + helper.SaveSimpleField(element, "@href", Uri.OriginalString, null); + } + + #endregion - #endregion + #region Internal Methods - #region Internal Methods + /// + /// Clones the instance and makes the URI in the clone absolute using the specified base directory + /// + /// The base directory to use to make the URI absolute + /// True to use an absolute URI in the clone, false to use a relative URI + /// A clone of the instance, with the URI made absolute + internal UriDataAttachment Clone(string baseDirectory, bool useAbsoluteUri) + { + Debug.Assert(!string.IsNullOrEmpty(baseDirectory), "'baseDirectory' is null or empty"); + Debug.Assert(baseDirectory == baseDirectory.Trim(), "'baseDirectory' contains whitespace at the ends"); - /// - /// Clones the instance and makes the URI in the clone absolute using the specified base directory - /// - /// The base directory to use to make the URI absolute - /// True to use an absolute URI in the clone, false to use a relative URI - /// A clone of the instance, with the URI made absolute - internal UriDataAttachment Clone(string baseDirectory, bool useAbsoluteUri) + if (useAbsoluteUri != Uri.IsAbsoluteUri) { - Debug.Assert(!string.IsNullOrEmpty(baseDirectory), "'baseDirectory' is null or empty"); - Debug.Assert(baseDirectory == baseDirectory.Trim(), "'baseDirectory' contains whitespace at the ends"); - - if (useAbsoluteUri != this.uri.IsAbsoluteUri) - { - Uri uriToUse; - if (useAbsoluteUri) - { - uriToUse = new Uri(Path.Combine(baseDirectory, this.uri.OriginalString), UriKind.Absolute); - } - else - { - uriToUse = new Uri(trxFileHelper.MakePathRelative(this.uri.OriginalString, baseDirectory), UriKind.Relative); - } - - return new UriDataAttachment(this.description, uriToUse, trxFileHelper); - } - - // The URI in this instance is already how we want it, and since this class is immutable, no need to clone - return this; + Uri uriToUse = useAbsoluteUri + ? new Uri(Path.Combine(baseDirectory, Uri.OriginalString), UriKind.Absolute) + : new Uri(_trxFileHelper.MakePathRelative(Uri.OriginalString, baseDirectory), UriKind.Relative); + return new UriDataAttachment(Description, uriToUse, _trxFileHelper); } - #endregion + // The URI in this instance is already how we want it, and since this class is immutable, no need to clone + return this; + } - #region Private Methods + #endregion - private void Initialize(string desc, Uri uri) - { - EqtAssert.ParameterNotNull(desc, nameof(desc)); - EqtAssert.ParameterNotNull(uri, nameof(uri)); + #region Private Methods - this.description = desc; - this.uri = uri; - } + private void Initialize(string desc, Uri uri) + { + EqtAssert.ParameterNotNull(desc, nameof(desc)); + EqtAssert.ParameterNotNull(uri, nameof(uri)); - #endregion + Description = desc; + Uri = uri; } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/WorkItems.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/WorkItems.cs index 7a087f322b..947b584af2 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/WorkItems.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/WorkItems.cs @@ -1,243 +1,236 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel +namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; +using System.Globalization; +using System.Text; +using System.Xml; + +using Utility; + +using XML; + +#region WorkItem +/// +/// Stores an int which represents a workitem +/// +internal sealed class WorkItem : IXmlTestStore { - using System; - using System.Globalization; - using System.Text; - using System.Xml; - using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; - - #region WorkItem + #region Fields + [StoreXmlField(Location = ".")] + private readonly int _id = 0; + + #endregion + + #region Constructors /// - /// Stores an int which represents a workitem + /// Create a new item with the workitem set /// - internal sealed class WorkItem : IXmlTestStore + /// The workitem. + public WorkItem(int workitemId) { - #region Fields - [StoreXmlField(Location = ".")] - private int id = 0; - - #endregion - - #region Constructors - /// - /// Create a new item with the workitem set - /// - /// The workitem. - public WorkItem(int workitemId) - { - this.id = workitemId; - } + _id = workitemId; + } - #endregion + #endregion - #region Properties/Methods - /// - /// Gets the id for this WorkItem - /// - public int Id + #region Properties/Methods + /// + /// Gets the id for this WorkItem + /// + public int Id + { + get { - get - { - return this.id; - } + return _id; } + } - #endregion - - #region Methods - overrides - /// - /// Compare the values of the items - /// - /// Value being compared to. - /// True if the values are the same and false otherwise. - public override bool Equals(object other) - { - WorkItem otherItem = other as WorkItem; - if (otherItem == null) - { - return false; - } - return this.id == otherItem.id; - } + #endregion - /// - /// Convert the workitem to a hashcode - /// - /// Hashcode of the workitem. - public override int GetHashCode() - { - return this.id.GetHashCode(); - } + #region Methods - overrides + /// + /// Compare the values of the items + /// + /// Value being compared to. + /// True if the values are the same and false otherwise. + public override bool Equals(object other) + { + return other is WorkItem otherItem && _id == otherItem._id; + } - /// - /// Convert the workitem to a string - /// - /// The workitem. - public override string ToString() - { - return this.id.ToString(CultureInfo.InvariantCulture); - } - #endregion + /// + /// Convert the workitem to a hashcode + /// + /// Hashcode of the workitem. + public override int GetHashCode() + { + return _id.GetHashCode(); + } - #region IXmlTestStore Members + /// + /// Convert the workitem to a string + /// + /// The workitem. + public override string ToString() + { + return _id.ToString(CultureInfo.InvariantCulture); + } + #endregion - /// - /// Saves the class under the XmlElement. - /// - /// XmlElement element - /// XmlTestStoreParameters parameters - public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) - { - new XmlPersistence().SaveSingleFields(element, this, parameters); - } + #region IXmlTestStore Members - #endregion + /// + /// Saves the class under the XmlElement. + /// + /// XmlElement element + /// XmlTestStoreParameters parameters + public void Save(XmlElement element, XmlTestStoreParameters parameters) + { + new XmlPersistence().SaveSingleFields(element, this, parameters); } + #endregion +} +#endregion + +#region WorkItemCollection +/// +/// A collection of ints represent the workitems +/// +internal sealed class WorkItemCollection : EqtBaseCollection +{ + #region Constructors + /// + /// Creates an empty WorkItemCollection. + /// + public WorkItemCollection() + { + } - #region WorkItemCollection /// - /// A collection of ints represent the workitems + /// Create a new WorkItemCollection based on the int array. /// - internal sealed class WorkItemCollection : EqtBaseCollection + /// Add these items to the collection. + public WorkItemCollection(int[] items) { - #region Constructors - /// - /// Creates an empty WorkItemCollection. - /// - public WorkItemCollection() + EqtAssert.ParameterNotNull(items, nameof(items)); + foreach (int i in items) { + Add(new WorkItem(i)); } + } + + #endregion - /// - /// Create a new WorkItemCollection based on the int array. - /// - /// Add these items to the collection. - public WorkItemCollection(int[] items) + #region Methods + /// + /// Adds the workitem. + /// + /// WorkItem to be added. + public void Add(int item) + { + Add(new WorkItem(item)); + } + + /// + /// Adds the workitem. + /// + /// WorkItem to be added. + public override void Add(WorkItem item) + { + EqtAssert.ParameterNotNull(item, nameof(item)); + base.Add(item); + } + + /// + /// Convert the WorkItemCollection to a string. + /// each item is separated by a comma (,) + /// + /// + public override string ToString() + { + StringBuilder returnString = new(); + if (Count > 0) { - EqtAssert.ParameterNotNull(items, nameof(items)); - foreach (int i in items) + returnString.Append(","); + foreach (WorkItem item in this) { - this.Add(new WorkItem(i)); + returnString.Append(item); + returnString.Append(","); } } - #endregion + return returnString.ToString(); + } - #region Methods - /// - /// Adds the workitem. - /// - /// WorkItem to be added. - public void Add(int item) + /// + /// Convert the WorkItemCollection to an array of ints. + /// + /// Array of ints containing the workitems. + public int[] ToArray() + { + int[] result = new int[Count]; + + int i = 0; + foreach (WorkItem item in this) { - this.Add(new WorkItem(item)); + result[i++] = item.Id; } - /// - /// Adds the workitem. - /// - /// WorkItem to be added. - public override void Add(WorkItem item) + return result; + } + + /// + /// Compare the collection items + /// + /// other collection + /// true if the collections contain the same items + public override bool Equals(object obj) + { + bool result = false; + + if (obj is not WorkItemCollection other) { - EqtAssert.ParameterNotNull(item, nameof(item)); - base.Add(item); + result = false; } - - /// - /// Convert the WorkItemCollection to a string. - /// each item is separated by a comma (,) - /// - /// - public override string ToString() + else if (ReferenceEquals(this, other)) { - StringBuilder returnString = new StringBuilder(); - if (this.Count > 0) - { - returnString.Append(","); - foreach (WorkItem item in this) - { - returnString.Append(item); - returnString.Append(","); - } - } - - return returnString.ToString(); + result = true; } - - /// - /// Convert the WorkItemCollection to an array of ints. - /// - /// Array of ints containing the workitems. - public int[] ToArray() + else if (Count != other.Count) { - int[] result = new int[this.Count]; - - int i = 0; - foreach (WorkItem item in this) - { - result[i++] = item.Id; - } - - return result; + result = false; } - - /// - /// Compare the collection items - /// - /// other collection - /// true if the collections contain the same items - public override bool Equals(object obj) + else { - WorkItemCollection other = obj as WorkItemCollection; - bool result = false; - - if (other == null) - { - result = false; - } - else if (object.ReferenceEquals(this, other)) - { - result = true; - } - else if (this.Count != other.Count) - { - result = false; - } - else + foreach (WorkItem item in this) { - foreach (WorkItem item in this) + if (!other.Contains(item)) { - if (!other.Contains(item)) - { - result = false; - break; - } + result = false; + break; } } - - return result; } - /// - /// Return the hash code of this collection - /// - /// The hashcode. - public override int GetHashCode() - { - return base.GetHashCode(); - } + return result; + } - public override void Save(XmlElement element, XmlTestStoreParameters parameters) - { - XmlPersistence xmlPersistence = new XmlPersistence(); - xmlPersistence.SaveHashtable(this.container, element, ".", ".", null, "Workitem", parameters); - } - #endregion + /// + /// Return the hash code of this collection + /// + /// The hashcode. + public override int GetHashCode() + { + return base.GetHashCode(); + } + + public override void Save(XmlElement element, XmlTestStoreParameters parameters) + { + XmlPersistence xmlPersistence = new(); + xmlPersistence.SaveHashtable(_container, element, ".", ".", null, "Workitem", parameters); } #endregion } +#endregion \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/TrxLogger.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/TrxLogger.cs index 2d726a4a6f..07a5be4a83 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/TrxLogger.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/TrxLogger.cs @@ -1,779 +1,753 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger +namespace Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger; + +using Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; +using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; +using Microsoft.TestPlatform.Extensions.TrxLogger.XML; +using ObjectModel; +using ObjectModel.Client; +using Utilities; +using Utilities.Helpers.Interfaces; + +using NuGet.Frameworks; + +using ObjectModel.Logging; + +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Text; +using System.Xml; + +using ObjectModelConstants = ObjectModel.Constants; +using TrxLoggerConstants = Microsoft.TestPlatform.Extensions.TrxLogger.Utility.Constants; +using TrxLoggerObjectModel = Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; +using TrxLoggerResources = Resources.TrxResource; + +/// +/// Logger for Generating TRX +/// +[FriendlyName(TrxLoggerConstants.FriendlyName)] +[ExtensionUri(TrxLoggerConstants.ExtensionUri)] +public class TrxLogger : ITestLoggerWithParameters { - using Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; - using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using NuGet.Frameworks; - using ObjectModel.Logging; - using System; - using System.Collections.Concurrent; - using System.Collections.Generic; - using System.Diagnostics; - using System.Diagnostics.CodeAnalysis; - using System.Globalization; - using System.IO; - using System.Text; - using System.Xml; - using ObjectModelConstants = ObjectModel.Constants; - using TrxLoggerConstants = Microsoft.TestPlatform.Extensions.TrxLogger.Utility.Constants; - using TrxLoggerObjectModel = Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; - using TrxLoggerResources = Resources.TrxResource; + #region Constructor /// - /// Logger for Generating TRX + /// Initializes a new instance of the class. /// - [FriendlyName(TrxLoggerConstants.FriendlyName)] - [ExtensionUri(TrxLoggerConstants.ExtensionUri)] - public class TrxLogger : ITestLoggerWithParameters - { - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - public TrxLogger() : this(new Utilities.Helpers.FileHelper()) { } + public TrxLogger() : this(new Utilities.Helpers.FileHelper()) { } - /// - /// Initializes a new instance of the class. - /// Constructor with Dependency injection. Used for unit testing. - /// - /// The file helper interface. - protected TrxLogger(IFileHelper fileHelper) : this(fileHelper, new TrxFileHelper()) { } + /// + /// Initializes a new instance of the class. + /// Constructor with Dependency injection. Used for unit testing. + /// + /// The file helper interface. + protected TrxLogger(IFileHelper fileHelper) : this(fileHelper, new TrxFileHelper()) { } - internal TrxLogger(IFileHelper fileHelper, TrxFileHelper trxFileHelper) - { - this.converter = new Converter(fileHelper, trxFileHelper); - this.trxFileHelper = trxFileHelper; - } + internal TrxLogger(IFileHelper fileHelper, TrxFileHelper trxFileHelper) + { + _converter = new Converter(fileHelper, trxFileHelper); + _trxFileHelper = trxFileHelper; + } - #endregion + #endregion - #region Fields + #region Fields - /// - /// Cache the TRX file path - /// - private string trxFilePath; + /// + /// Cache the TRX file path + /// + private string _trxFilePath; - // The converter class - private Converter converter; + // The converter class + private readonly Converter _converter; + private ConcurrentDictionary _results; + private ConcurrentDictionary _testElements; + private ConcurrentDictionary _entries; - private TestRun testRun; - private ConcurrentDictionary results; - private ConcurrentDictionary testElements; - private ConcurrentDictionary entries; + // Caching results and inner test entries for constant time lookup for inner parents. + private ConcurrentDictionary _innerResults; + private ConcurrentDictionary _innerTestEntries; - // Caching results and inner test entries for constant time lookup for inner parents. - private ConcurrentDictionary innerResults; - private ConcurrentDictionary innerTestEntries; + private readonly TrxFileHelper _trxFileHelper; - private readonly TrxFileHelper trxFileHelper; + /// + /// Specifies the run level "out" messages + /// + private StringBuilder _runLevelStdOut; - /// - /// Specifies the run level "out" messages - /// - private StringBuilder runLevelStdOut; + // List of run level errors and warnings generated. These are logged in the Trx in the Results Summary. + private List _runLevelErrorsAndWarnings; + private readonly string _trxFileExtension = ".trx"; - // List of run level errors and warnings generated. These are logged in the Trx in the Results Summary. - private List runLevelErrorsAndWarnings; + /// + /// Parameters dictionary for logger. Ex: {"LogFileName":"TestResults.trx"}. + /// + private Dictionary _parametersDictionary; - private TrxLoggerObjectModel.TestOutcome testRunOutcome = TrxLoggerObjectModel.TestOutcome.Passed; + /// + /// Gets the directory under which default trx file and test results attachments should be saved. + /// + private string _testResultsDirPath; - private int totalTests, passTests, failTests; + #endregion - private DateTime testRunStartTime; + #region ITestLogger - private string trxFileExtension = ".trx"; + /// + public void Initialize(TestLoggerEvents events, string testResultsDirPath) + { + if (events == null) + { + throw new ArgumentNullException(nameof(events)); + } - /// - /// Parameters dictionary for logger. Ex: {"LogFileName":"TestResults.trx"}. - /// - private Dictionary parametersDictionary; + if (string.IsNullOrEmpty(testResultsDirPath)) + { + throw new ArgumentNullException(nameof(testResultsDirPath)); + } - /// - /// Gets the directory under which default trx file and test results attachments should be saved. - /// - private string testResultsDirPath; + // Register for the events. + events.TestRunMessage += TestMessageHandler; + events.TestResult += TestResultHandler; + events.TestRunComplete += TestRunCompleteHandler; - #endregion + _testResultsDirPath = testResultsDirPath; + InitializeInternal(); + } - #region ITestLogger + /// + public void Initialize(TestLoggerEvents events, Dictionary parameters) + { + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } - /// - public void Initialize(TestLoggerEvents events, string testResultsDirPath) + if (parameters.Count == 0) { - if (events == null) - { - throw new ArgumentNullException(nameof(events)); - } + throw new ArgumentException("No default parameters added", nameof(parameters)); + } - if (string.IsNullOrEmpty(testResultsDirPath)) - { - throw new ArgumentNullException(nameof(testResultsDirPath)); - } + var isLogFilePrefixParameterExists = parameters.TryGetValue(TrxLoggerConstants.LogFilePrefixKey, out _); + var isLogFileNameParameterExists = parameters.TryGetValue(TrxLoggerConstants.LogFileNameKey, out _); - // Register for the events. - events.TestRunMessage += this.TestMessageHandler; - events.TestResult += this.TestResultHandler; - events.TestRunComplete += this.TestRunCompleteHandler; + if (isLogFilePrefixParameterExists && isLogFileNameParameterExists) + { + var trxParameterErrorMsg = string.Format(CultureInfo.CurrentCulture, + TrxLoggerResources.PrefixAndNameProvidedError); - this.testResultsDirPath = testResultsDirPath; - this.InitializeInternal(); + EqtTrace.Error(trxParameterErrorMsg); + throw new ArgumentException(trxParameterErrorMsg); } - /// - public void Initialize(TestLoggerEvents events, Dictionary parameters) - { - if (parameters == null) - { - throw new ArgumentNullException(nameof(parameters)); - } + _parametersDictionary = parameters; + Initialize(events, _parametersDictionary[DefaultLoggerParameterNames.TestRunDirectory]); + } + #endregion - if (parameters.Count == 0) - { - throw new ArgumentException("No default parameters added", nameof(parameters)); - } + #region ForTesting - var isLogFilePrefixParameterExists = parameters.TryGetValue(TrxLoggerConstants.LogFilePrefixKey, out string logFilePrefixValue); - var isLogFileNameParameterExists = parameters.TryGetValue(TrxLoggerConstants.LogFileNameKey, out string logFileNameValue); + internal string GetRunLevelInformationalMessage() + { + return _runLevelStdOut.ToString(); + } - if (isLogFilePrefixParameterExists && isLogFileNameParameterExists) - { - var trxParameterErrorMsg = string.Format(CultureInfo.CurrentCulture, - TrxLoggerResources.PrefixAndNameProvidedError); + internal List GetRunLevelErrorsAndWarnings() + { + return _runLevelErrorsAndWarnings; + } - EqtTrace.Error(trxParameterErrorMsg); - throw new ArgumentException(trxParameterErrorMsg); - } + internal DateTime TestRunStartTime { get; private set; } - this.parametersDictionary = parameters; - this.Initialize(events, this.parametersDictionary[DefaultLoggerParameterNames.TestRunDirectory]); - } - #endregion + internal TestRun LoggerTestRun { get; private set; } - #region ForTesting + internal int TotalTestCount { get; private set; } - internal string GetRunLevelInformationalMessage() - { - return this.runLevelStdOut.ToString(); - } + internal int PassedTestCount { get; private set; } - internal List GetRunLevelErrorsAndWarnings() - { - return this.runLevelErrorsAndWarnings; - } + internal int FailedTestCount { get; private set; } - internal DateTime TestRunStartTime - { - get { return this.testRunStartTime; } - } + internal int TestResultCount + { + get { return _results.Count; } + } - internal TestRun LoggerTestRun - { - get { return this.testRun; } - } + internal int UnitTestElementCount + { + get { return _testElements.Count; } + } - internal int TotalTestCount - { - get { return totalTests; } - } + internal int TestEntryCount + { + get { return _entries.Count; } + } - internal int PassedTestCount - { - get { return passTests; } - } + internal TrxLoggerObjectModel.TestOutcome TestResultOutcome { get; private set; } = TrxLoggerObjectModel.TestOutcome.Passed; - internal int FailedTestCount - { - get { return failTests; } - } + #endregion - internal int TestResultCount - { - get { return this.results.Count; } + #region Event Handlers + + /// + /// Called when a test message is received. + /// + /// + /// The sender. + /// + /// + /// Event args + /// + internal void TestMessageHandler(object sender, TestRunMessageEventArgs e) + { + ValidateArg.NotNull(sender, nameof(sender)); + ValidateArg.NotNull(e, nameof(e)); + + RunInfo runMessage; + + switch (e.Level) + { + case TestMessageLevel.Informational: + AddRunLevelInformationalMessage(e.Message); + break; + case TestMessageLevel.Warning: + runMessage = new RunInfo(e.Message, null, Environment.MachineName, TrxLoggerObjectModel.TestOutcome.Warning); + _runLevelErrorsAndWarnings.Add(runMessage); + break; + case TestMessageLevel.Error: + TestResultOutcome = TrxLoggerObjectModel.TestOutcome.Failed; + runMessage = new RunInfo(e.Message, null, Environment.MachineName, TrxLoggerObjectModel.TestOutcome.Error); + _runLevelErrorsAndWarnings.Add(runMessage); + break; + default: + Debug.Fail("TrxLogger.TestMessageHandler: The test message level is unrecognized: {0}", e.Level.ToString()); + break; } + } + + /// + /// Called when a test result is received. + /// + /// + /// The sender. + /// + /// + /// The eventArgs. + /// + internal void TestResultHandler(object sender, TestResultEventArgs e) + { + // Create test run + if (LoggerTestRun == null) + CreateTestRun(); + + // Convert skipped test to a log entry as that is the behavior of mstest. + if (e.Result.Outcome == ObjectModel.TestOutcome.Skipped) + HandleSkippedTest(e.Result); - internal int UnitTestElementCount + var testType = _converter.GetTestType(e.Result); + var executionId = _converter.GetExecutionId(e.Result); + + // Setting parent properties like parent result, parent test element, parent execution id. + var parentExecutionId = _converter.GetParentExecutionId(e.Result); + var parentTestResult = GetTestResult(parentExecutionId); + var parentTestElement = (parentTestResult != null) ? GetTestElement(parentTestResult.Id.TestId) : null; + + // Switch to flat test results in case any parent related information is missing. + if (parentTestResult == null || parentTestElement == null || parentExecutionId == Guid.Empty) { - get { return this.testElements.Count; } + parentTestResult = null; + parentTestElement = null; + parentExecutionId = Guid.Empty; } - internal int TestEntryCount + // Create trx test element from rocksteady test case + var testElement = GetOrCreateTestElement(executionId, parentExecutionId, testType, parentTestElement, e.Result); + + // Update test links. Test Links are updated in case of Ordered test. + UpdateTestLinks(testElement, parentTestElement); + + // Convert the rocksteady result to trx test result + var testResult = CreateTestResult(executionId, parentExecutionId, testType, testElement, parentTestElement, parentTestResult, e.Result); + + // Update test entries + UpdateTestEntries(executionId, parentExecutionId, testElement, parentTestElement); + + // Set various counts (passed tests, failed tests, total tests) + TotalTestCount++; + if (testResult.Outcome == TrxLoggerObjectModel.TestOutcome.Failed) { - get { return this.entries.Count; } + TestResultOutcome = TrxLoggerObjectModel.TestOutcome.Failed; + FailedTestCount++; } - - internal TrxLoggerObjectModel.TestOutcome TestResultOutcome + else if (testResult.Outcome == TrxLoggerObjectModel.TestOutcome.Passed) { - get { return this.testRunOutcome; } + PassedTestCount++; } + } - #endregion + /// + /// Called when a test run is completed. + /// + /// + /// The sender. + /// + /// + /// Test run complete events arguments. + /// + internal void TestRunCompleteHandler(object sender, TestRunCompleteEventArgs e) + { + // Create test run + // If abort occurs there is no call to TestResultHandler which results in testRun not created. + // This happens when some test aborts in the first batch of execution. + if (LoggerTestRun == null) + CreateTestRun(); - #region Event Handlers + XmlPersistence helper = new(); + XmlTestStoreParameters parameters = XmlTestStoreParameters.GetParameters(); + XmlElement rootElement = helper.CreateRootElement("TestRun"); - /// - /// Called when a test message is received. - /// - /// - /// The sender. - /// - /// - /// Event args - /// - internal void TestMessageHandler(object sender, TestRunMessageEventArgs e) - { - ValidateArg.NotNull(sender, nameof(sender)); - ValidateArg.NotNull(e, nameof(e)); + // Save runId/username/creation time etc. + LoggerTestRun.Finished = DateTime.UtcNow; + helper.SaveSingleFields(rootElement, LoggerTestRun, parameters); - RunInfo runMessage; + // Save test settings + helper.SaveObject(LoggerTestRun.RunConfiguration, rootElement, "TestSettings", parameters); - switch (e.Level) - { - case TestMessageLevel.Informational: - this.AddRunLevelInformationalMessage(e.Message); - break; - case TestMessageLevel.Warning: - runMessage = new RunInfo(e.Message, null, Environment.MachineName, TrxLoggerObjectModel.TestOutcome.Warning); - this.runLevelErrorsAndWarnings.Add(runMessage); - break; - case TestMessageLevel.Error: - this.testRunOutcome = TrxLoggerObjectModel.TestOutcome.Failed; - runMessage = new RunInfo(e.Message, null, Environment.MachineName, TrxLoggerObjectModel.TestOutcome.Error); - this.runLevelErrorsAndWarnings.Add(runMessage); - break; - default: - Debug.Fail("TrxLogger.TestMessageHandler: The test message level is unrecognized: {0}", e.Level.ToString()); - break; - } - } + // Save test results + helper.SaveIEnumerable(_results.Values, rootElement, "Results", ".", null, parameters); + + // Save test definitions + helper.SaveIEnumerable(_testElements.Values, rootElement, "TestDefinitions", ".", null, parameters); - /// - /// Called when a test result is received. - /// - /// - /// The sender. - /// - /// - /// The eventArgs. - /// - internal void TestResultHandler(object sender, TestResultEventArgs e) + // Save test entries + helper.SaveIEnumerable(_entries.Values, rootElement, "TestEntries", ".", "TestEntry", parameters); + + // Save default categories + List categories = new() { - // Create test run - if (this.testRun == null) - CreateTestRun(); + TestListCategory.UncategorizedResults, + TestListCategory.AllResults + }; + helper.SaveList(categories, rootElement, "TestLists", ".", "TestList", parameters); - // Convert skipped test to a log entry as that is the behavior of mstest. - if (e.Result.Outcome == ObjectModel.TestOutcome.Skipped) - this.HandleSkippedTest(e.Result); + // Save summary + if (TestResultOutcome == TrxLoggerObjectModel.TestOutcome.Passed) + { + TestResultOutcome = TrxLoggerObjectModel.TestOutcome.Completed; + } - var testType = this.converter.GetTestType(e.Result); - var executionId = this.converter.GetExecutionId(e.Result); + TestResultOutcome = ChangeTestOutcomeIfNecessary(TestResultOutcome); - // Setting parent properties like parent result, parent test element, parent execution id. - var parentExecutionId = this.converter.GetParentExecutionId(e.Result); - var parentTestResult = GetTestResult(parentExecutionId); - var parentTestElement = (parentTestResult != null) ? GetTestElement(parentTestResult.Id.TestId) : null; + List errorMessages = new(); + List collectorEntries = _converter.ToCollectionEntries(e.AttachmentSets, LoggerTestRun, _testResultsDirPath); + IList resultFiles = _converter.ToResultFiles(e.AttachmentSets, LoggerTestRun, _testResultsDirPath, errorMessages); - // Switch to flat test results in case any parent related information is missing. - if (parentTestResult == null || parentTestElement == null || parentExecutionId == Guid.Empty) + if (errorMessages.Count > 0) + { + // Got some errors while attaching files, report them and set the outcome of testrun to be Error... + TestResultOutcome = TrxLoggerObjectModel.TestOutcome.Error; + foreach (string msg in errorMessages) { - parentTestResult = null; - parentTestElement = null; - parentExecutionId = Guid.Empty; + RunInfo runMessage = new(msg, null, Environment.MachineName, TrxLoggerObjectModel.TestOutcome.Error); + _runLevelErrorsAndWarnings.Add(runMessage); } + } - // Create trx test element from rocksteady test case - var testElement = GetOrCreateTestElement(executionId, parentExecutionId, testType, parentTestElement, e.Result); - - // Update test links. Test Links are updated in case of Ordered test. - UpdateTestLinks(testElement, parentTestElement); + TestRunSummary runSummary = new( + TotalTestCount, + PassedTestCount + FailedTestCount, + PassedTestCount, + FailedTestCount, + TestResultOutcome, + _runLevelErrorsAndWarnings, + _runLevelStdOut.ToString(), + resultFiles, + collectorEntries); - // Convert the rocksteady result to trx test result - var testResult = CreateTestResult(executionId, parentExecutionId, testType, testElement, parentTestElement, parentTestResult, e.Result); + helper.SaveObject(runSummary, rootElement, "ResultSummary", parameters); - // Update test entries - UpdateTestEntries(executionId, parentExecutionId, testElement, parentTestElement); + ReserveTrxFilePath(); + PopulateTrxFile(_trxFilePath, rootElement); + } - // Set various counts (passed tests, failed tests, total tests) - this.totalTests++; - if (testResult.Outcome == TrxLoggerObjectModel.TestOutcome.Failed) - { - this.testRunOutcome = TrxLoggerObjectModel.TestOutcome.Failed; - this.failTests++; - } - else if (testResult.Outcome == TrxLoggerObjectModel.TestOutcome.Passed) + /// + /// populate trx file from the xml element + /// + /// + /// Trx full path + /// + /// + /// XmlElement. + /// + internal virtual void PopulateTrxFile(string trxFileName, XmlElement rootElement) + { + try + { + using (var fs = File.Open(trxFileName, FileMode.Truncate)) { - this.passTests++; + using XmlWriter writer = XmlWriter.Create(fs, new XmlWriterSettings { NewLineHandling = NewLineHandling.Entitize, Indent = true }); + rootElement.OwnerDocument.Save(writer); + writer.Flush(); } - } - /// - /// Called when a test run is completed. - /// - /// - /// The sender. - /// - /// - /// Test run complete events arguments. - /// - internal void TestRunCompleteHandler(object sender, TestRunCompleteEventArgs e) + string resultsFileMessage = string.Format(CultureInfo.CurrentCulture, TrxLoggerResources.TrxLoggerResultsFile, trxFileName); + ConsoleOutput.Instance.Information(false, resultsFileMessage); + EqtTrace.Info(resultsFileMessage); + } + catch (UnauthorizedAccessException fileWriteException) { - // Create test run - // If abort occurs there is no call to TestResultHandler which results in testRun not created. - // This happens when some test aborts in the first batch of execution. - if (this.testRun == null) - CreateTestRun(); - - XmlPersistence helper = new XmlPersistence(); - XmlTestStoreParameters parameters = XmlTestStoreParameters.GetParameters(); - XmlElement rootElement = helper.CreateRootElement("TestRun"); - - // Save runId/username/creation time etc. - this.testRun.Finished = DateTime.UtcNow; - helper.SaveSingleFields(rootElement, this.testRun, parameters); + ConsoleOutput.Instance.Error(false, fileWriteException.Message); + } + } - // Save test settings - helper.SaveObject(this.testRun.RunConfiguration, rootElement, "TestSettings", parameters); + // Initializes trx logger cache. + private void InitializeInternal() + { + _results = new ConcurrentDictionary(); + _innerResults = new ConcurrentDictionary(); + _testElements = new ConcurrentDictionary(); + _entries = new ConcurrentDictionary(); + _innerTestEntries = new ConcurrentDictionary(); + _runLevelErrorsAndWarnings = new List(); + LoggerTestRun = null; + TotalTestCount = 0; + PassedTestCount = 0; + FailedTestCount = 0; + _runLevelStdOut = new StringBuilder(); + TestRunStartTime = DateTime.UtcNow; + } - // Save test results - helper.SaveIEnumerable(this.results.Values, rootElement, "Results", ".", null, parameters); + /// + /// Add run level informational message + /// + /// + /// The message. + /// + private void AddRunLevelInformationalMessage(string message) + { + _runLevelStdOut.AppendLine(message); + } - // Save test definitions - helper.SaveIEnumerable(this.testElements.Values, rootElement, "TestDefinitions", ".", null, parameters); + // Handle the skipped test result + private void HandleSkippedTest(ObjectModel.TestResult rsTestResult) + { + Debug.Assert(rsTestResult.Outcome == ObjectModel.TestOutcome.Skipped, "Test Result should be skipped but it is " + rsTestResult.Outcome); - // Save test entries - helper.SaveIEnumerable(this.entries.Values, rootElement, "TestEntries", ".", "TestEntry", parameters); + TestCase testCase = rsTestResult.TestCase; + string testCaseName = !string.IsNullOrEmpty(testCase.DisplayName) ? testCase.DisplayName : testCase.FullyQualifiedName; + string message = string.Format(CultureInfo.CurrentCulture, TrxLoggerResources.MessageForSkippedTests, testCaseName); + AddRunLevelInformationalMessage(message); + } - // Save default categories - List categories = new List(); - categories.Add(TestListCategory.UncategorizedResults); - categories.Add(TestListCategory.AllResults); - helper.SaveList(categories, rootElement, "TestLists", ".", "TestList", parameters); + private void ReserveTrxFilePath() + { + for (short retries = 0; retries != short.MaxValue; retries++) + { + var filePath = AcquireTrxFileNamePath(out var shouldOverwrite); - // Save summary - if (this.testRunOutcome == TrxLoggerObjectModel.TestOutcome.Passed) + if (shouldOverwrite && File.Exists(filePath)) { - this.testRunOutcome = TrxLoggerObjectModel.TestOutcome.Completed; + var overwriteWarningMsg = string.Format(CultureInfo.CurrentCulture, TrxLoggerResources.TrxLoggerResultsFileOverwriteWarning, filePath); + ConsoleOutput.Instance.Warning(false, overwriteWarningMsg); + EqtTrace.Warning(overwriteWarningMsg); } - - testRunOutcome = ChangeTestOutcomeIfNecessary(testRunOutcome); - - List errorMessages = new List(); - List collectorEntries = this.converter.ToCollectionEntries(e.AttachmentSets, this.testRun, this.testResultsDirPath); - IList resultFiles = this.converter.ToResultFiles(e.AttachmentSets, this.testRun, this.testResultsDirPath, errorMessages); - - if (errorMessages.Count > 0) + else { - // Got some errors while attaching files, report them and set the outcome of testrun to be Error... - this.testRunOutcome = TrxLoggerObjectModel.TestOutcome.Error; - foreach (string msg in errorMessages) + try { - RunInfo runMessage = new RunInfo(msg, null, Environment.MachineName, TrxLoggerObjectModel.TestOutcome.Error); - this.runLevelErrorsAndWarnings.Add(runMessage); + using var fs = File.Open(filePath, FileMode.CreateNew); + } + catch (IOException) + { + // File already exists, try again! + continue; } } - TestRunSummary runSummary = new TestRunSummary( - this.totalTests, - this.passTests + this.failTests, - this.passTests, - this.failTests, - this.testRunOutcome, - this.runLevelErrorsAndWarnings, - this.runLevelStdOut.ToString(), - resultFiles, - collectorEntries); - - helper.SaveObject(runSummary, rootElement, "ResultSummary", parameters); - - this.ReserveTrxFilePath(); - this.PopulateTrxFile(this.trxFilePath, rootElement); + _trxFilePath = filePath; + return; } + } - /// - /// populate trx file from the xml element - /// - /// - /// Trx full path - /// - /// - /// XmlElement. - /// - internal virtual void PopulateTrxFile(string trxFileName, XmlElement rootElement) - { - try - { - using (var fs = File.Open(trxFileName, FileMode.Truncate)) - { - using (XmlWriter writer = XmlWriter.Create(fs, new XmlWriterSettings { NewLineHandling = NewLineHandling.Entitize, Indent = true })) - { - rootElement.OwnerDocument.Save(writer); - writer.Flush(); - } - } + private string AcquireTrxFileNamePath(out bool shouldOverwrite) + { + shouldOverwrite = false; + var isLogFileNameParameterExists = _parametersDictionary.TryGetValue(TrxLoggerConstants.LogFileNameKey, out string logFileNameValue) && !string.IsNullOrWhiteSpace(logFileNameValue); + var isLogFilePrefixParameterExists = _parametersDictionary.TryGetValue(TrxLoggerConstants.LogFilePrefixKey, out string logFilePrefixValue) && !string.IsNullOrWhiteSpace(logFilePrefixValue); - string resultsFileMessage = string.Format(CultureInfo.CurrentCulture, TrxLoggerResources.TrxLoggerResultsFile, trxFileName); - ConsoleOutput.Instance.Information(false, resultsFileMessage); - EqtTrace.Info(resultsFileMessage); - } - catch (UnauthorizedAccessException fileWriteException) + string filePath = null; + + if (isLogFilePrefixParameterExists) + { + if (_parametersDictionary.TryGetValue(DefaultLoggerParameterNames.TargetFramework, out var framework) && framework != null) { - ConsoleOutput.Instance.Error(false, fileWriteException.Message); + framework = NuGetFramework.Parse(framework).GetShortFolderName(); + logFilePrefixValue = logFilePrefixValue + "_" + framework; } - } - // Initializes trx logger cache. - private void InitializeInternal() - { - this.results = new ConcurrentDictionary(); - this.innerResults = new ConcurrentDictionary(); - this.testElements = new ConcurrentDictionary(); - this.entries = new ConcurrentDictionary(); - this.innerTestEntries = new ConcurrentDictionary(); - this.runLevelErrorsAndWarnings = new List(); - this.testRun = null; - this.totalTests = 0; - this.passTests = 0; - this.failTests = 0; - this.runLevelStdOut = new StringBuilder(); - this.testRunStartTime = DateTime.UtcNow; + filePath = _trxFileHelper.GetNextTimestampFileName(_testResultsDirPath, logFilePrefixValue + _trxFileExtension, "_yyyyMMddHHmmss"); } - - /// - /// Add run level informational message - /// - /// - /// The message. - /// - private void AddRunLevelInformationalMessage(string message) + else if (isLogFileNameParameterExists) { - this.runLevelStdOut.AppendLine(message); + filePath = Path.Combine(_testResultsDirPath, logFileNameValue); + shouldOverwrite = true; } - // Handle the skipped test result - [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1305:FieldNamesMustNotUseHungarianNotation", Justification = "Reviewed. Suppression is OK here.")] - private void HandleSkippedTest(ObjectModel.TestResult rsTestResult) - { - Debug.Assert(rsTestResult.Outcome == ObjectModel.TestOutcome.Skipped, "Test Result should be skipped but it is " + rsTestResult.Outcome); + filePath ??= SetDefaultTrxFilePath(); - TestCase testCase = rsTestResult.TestCase; - string testCaseName = !string.IsNullOrEmpty(testCase.DisplayName) ? testCase.DisplayName : testCase.FullyQualifiedName; - string message = string.Format(CultureInfo.CurrentCulture, TrxLoggerResources.MessageForSkippedTests, testCaseName); - this.AddRunLevelInformationalMessage(message); - } + var trxFileDirPath = Path.GetDirectoryName(filePath); - private void ReserveTrxFilePath() + if (!Directory.Exists(trxFileDirPath)) { - for (short retries = 0; retries != short.MaxValue; retries++) - { - var filePath = AcquireTrxFileNamePath(out var shouldOverwrite); - - if (shouldOverwrite && File.Exists(filePath)) - { - var overwriteWarningMsg = string.Format(CultureInfo.CurrentCulture, TrxLoggerResources.TrxLoggerResultsFileOverwriteWarning, filePath); - ConsoleOutput.Instance.Warning(false, overwriteWarningMsg); - EqtTrace.Warning(overwriteWarningMsg); - } - else - { - try - { - using (var fs = File.Open(filePath, FileMode.CreateNew)) { } - } - catch (IOException) - { - // File already exists, try again! - continue; - } - } - - trxFilePath = filePath; - return; - } + Directory.CreateDirectory(trxFileDirPath); } - private string AcquireTrxFileNamePath(out bool shouldOverwrite) - { - shouldOverwrite = false; - var isLogFileNameParameterExists = parametersDictionary.TryGetValue(TrxLoggerConstants.LogFileNameKey, out string logFileNameValue) && !string.IsNullOrWhiteSpace(logFileNameValue); - var isLogFilePrefixParameterExists = parametersDictionary.TryGetValue(TrxLoggerConstants.LogFilePrefixKey, out string logFilePrefixValue) && !string.IsNullOrWhiteSpace(logFilePrefixValue); - - string filePath = null; - - if (isLogFilePrefixParameterExists) - { - if (parametersDictionary.TryGetValue(DefaultLoggerParameterNames.TargetFramework, out var framework) && framework != null) - { - framework = NuGetFramework.Parse(framework).GetShortFolderName(); - logFilePrefixValue = logFilePrefixValue + "_" + framework; - } - - filePath = trxFileHelper.GetNextTimestampFileName(this.testResultsDirPath, logFilePrefixValue + this.trxFileExtension, "_yyyyMMddHHmmss"); - } - else if (isLogFileNameParameterExists) - { - filePath = Path.Combine(this.testResultsDirPath, logFileNameValue); - shouldOverwrite = true; - } + return filePath; + } - filePath = filePath ?? this.SetDefaultTrxFilePath(); + /// + /// Returns an auto generated Trx file name under test results directory. + /// + private string SetDefaultTrxFilePath() + { + var defaultTrxFileName = LoggerTestRun.RunConfiguration.RunDeploymentRootDirectory + ".trx"; - var trxFileDirPath = Path.GetDirectoryName(filePath); + return _trxFileHelper.GetNextIterationFileName(_testResultsDirPath, defaultTrxFileName, false); + } - if (!Directory.Exists(trxFileDirPath)) - { - Directory.CreateDirectory(trxFileDirPath); - } + /// + /// Creates test run. + /// + private void CreateTestRun() + { + // Skip run creation if already exists. + if (LoggerTestRun != null) + return; + + Guid runId = Guid.NewGuid(); + LoggerTestRun = new TestRun(runId); + + // We cannot rely on the StartTime for the first test result + // In case of parallel, first test result is the fastest test and not the one which started first. + // Setting Started to DateTime.Now in Initialize will make sure we include the startup cost, which was being ignored earlier. + // This is in parity with the way we set this.testRun.Finished + LoggerTestRun.Started = TestRunStartTime; + + // Save default test settings + string runDeploymentRoot = _trxFileHelper.ReplaceInvalidFileNameChars(LoggerTestRun.Name); + TestRunConfiguration testrunConfig = new("default", _trxFileHelper); + testrunConfig.RunDeploymentRootDirectory = runDeploymentRoot; + LoggerTestRun.RunConfiguration = testrunConfig; + } - return filePath; - } + /// + /// Gets test result from stored test results. + /// + /// + /// Test result + private ITestResult GetTestResult(Guid executionId) + { + ITestResult testResult = null; - /// - /// Returns an auto generated Trx file name under test results directory. - /// - private string SetDefaultTrxFilePath() + if (executionId != Guid.Empty) { - var defaultTrxFileName = this.testRun.RunConfiguration.RunDeploymentRootDirectory + ".trx"; + _results.TryGetValue(executionId, out testResult); - return trxFileHelper.GetNextIterationFileName(this.testResultsDirPath, defaultTrxFileName, false); + if (testResult == null) + _innerResults.TryGetValue(executionId, out testResult); } - /// - /// Creates test run. - /// - private void CreateTestRun() - { - // Skip run creation if already exists. - if (testRun != null) - return; - - Guid runId = Guid.NewGuid(); - this.testRun = new TestRun(runId); - - // We cannot rely on the StartTime for the first test result - // In case of parallel, first test result is the fastest test and not the one which started first. - // Setting Started to DateTime.Now in Initialize will make sure we include the startup cost, which was being ignored earlier. - // This is in parity with the way we set this.testRun.Finished - this.testRun.Started = this.testRunStartTime; - - // Save default test settings - string runDeploymentRoot = trxFileHelper.ReplaceInvalidFileNameChars(this.testRun.Name); - TestRunConfiguration testrunConfig = new TestRunConfiguration("default", trxFileHelper); - testrunConfig.RunDeploymentRootDirectory = runDeploymentRoot; - this.testRun.RunConfiguration = testrunConfig; - } - - /// - /// Gets test result from stored test results. - /// - /// - /// Test result - private ITestResult GetTestResult(Guid executionId) - { - ITestResult testResult = null; - - if (executionId != Guid.Empty) - { - this.results.TryGetValue(executionId, out testResult); + return testResult; + } - if (testResult == null) - this.innerResults.TryGetValue(executionId, out testResult); - } + /// + /// Gets test element from stored test elements. + /// + /// + /// + private ITestElement GetTestElement(Guid testId) + { + _testElements.TryGetValue(testId, out var testElement); + return testElement; + } - return testResult; - } + /// + /// Gets or creates test element. + /// + /// + /// + /// + /// + /// + /// Trx test element + private ITestElement GetOrCreateTestElement(Guid executionId, Guid parentExecutionId, TestType testType, ITestElement parentTestElement, ObjectModel.TestResult rockSteadyTestResult) + { + ITestElement testElement = parentTestElement; - /// - /// Gets test element from stored test elements. - /// - /// - /// - private ITestElement GetTestElement(Guid testId) + // For scenarios like data driven tests, test element is same as parent test element. + if (parentTestElement != null && !parentTestElement.TestType.Equals(TrxLoggerConstants.OrderedTestType)) { - this.testElements.TryGetValue(testId, out var testElement); return testElement; } - /// - /// Gets or creates test element. - /// - /// - /// - /// - /// - /// - /// Trx test element - private ITestElement GetOrCreateTestElement(Guid executionId, Guid parentExecutionId, TestType testType, ITestElement parentTestElement, ObjectModel.TestResult rockSteadyTestResult) + TestCase testCase = rockSteadyTestResult.TestCase; + Guid testId = _converter.GetTestId(testCase); + + // Scenario for inner test case when parent test element is not present. + var testName = testCase.DisplayName; + var adapter = testCase.ExecutorUri.ToString(); + if (adapter.Contains(TrxLoggerConstants.MstestAdapterString) && + parentTestElement == null && + !string.IsNullOrEmpty(rockSteadyTestResult.DisplayName)) { - ITestElement testElement = parentTestElement; + // Note: For old mstest adapters hierarchical support was not present. Thus inner result of data driven was identified using test result display name. + // Non null test result display name means its a inner result of data driven/ordered test. + // Changing GUID to keep supporting old mstest adapters. + testId = Guid.NewGuid(); + testName = rockSteadyTestResult.DisplayName; + } - // For scenarios like data driven tests, test element is same as parent test element. - if (parentTestElement != null && !parentTestElement.TestType.Equals(TrxLoggerConstants.OrderedTestType)) - { - return testElement; - } + // Get test element + testElement = GetTestElement(testId); - TestCase testCase = rockSteadyTestResult.TestCase; - Guid testId = this.converter.GetTestId(testCase); + // Create test element + if (testElement == null) + { + testElement = _converter.ToTestElement(testId, executionId, parentExecutionId, testName, testType, testCase); + _testElements.TryAdd(testId, testElement); + } - // Scenario for inner test case when parent test element is not present. - var testName = testCase.DisplayName; - var adapter = testCase.ExecutorUri.ToString(); - if (adapter.Contains(TrxLoggerConstants.MstestAdapterString) && - parentTestElement == null && - !string.IsNullOrEmpty(rockSteadyTestResult.DisplayName)) - { - // Note: For old mstest adapters hierarchical support was not present. Thus inner result of data driven was identified using test result display name. - // Non null test result display name means its a inner result of data driven/ordered test. - // Changing GUID to keep supporting old mstest adapters. - testId = Guid.NewGuid(); - testName = rockSteadyTestResult.DisplayName; - } + return testElement; + } - // Get test element - testElement = GetTestElement(testId); + /// + /// Update test links + /// + /// + /// + private void UpdateTestLinks(ITestElement testElement, ITestElement parentTestElement) + { + if (parentTestElement != null && + parentTestElement.TestType.Equals(TrxLoggerConstants.OrderedTestType) && + !(parentTestElement as OrderedTestElement).TestLinks.ContainsKey(testElement.Id.Id)) + { + (parentTestElement as OrderedTestElement).TestLinks.Add(testElement.Id.Id, new TestLink(testElement.Id.Id, testElement.Name, testElement.Storage)); + } + } - // Create test element - if (testElement == null) - { - testElement = this.converter.ToTestElement(testId, executionId, parentExecutionId, testName, testType, testCase); - testElements.TryAdd(testId, testElement); - } + /// + /// Creates test result + /// + /// + /// + /// + /// + /// + /// + /// + /// Trx test result + private ITestResult CreateTestResult(Guid executionId, Guid parentExecutionId, TestType testType, + ITestElement testElement, ITestElement parentTestElement, ITestResult parentTestResult, ObjectModel.TestResult rocksteadyTestResult) + { + // Create test result + TrxLoggerObjectModel.TestOutcome testOutcome = _converter.ToOutcome(rocksteadyTestResult.Outcome); + var testResult = _converter.ToTestResult(testElement.Id.Id, executionId, parentExecutionId, testElement.Name, + _testResultsDirPath, testType, testElement.CategoryId, testOutcome, LoggerTestRun, rocksteadyTestResult); - return testElement; + // Normal result scenario + if (parentTestResult == null) + { + _results.TryAdd(executionId, testResult); + return testResult; } - /// - /// Update test links - /// - /// - /// - private void UpdateTestLinks(ITestElement testElement, ITestElement parentTestElement) + // Ordered test inner result scenario + if (parentTestElement != null && parentTestElement.TestType.Equals(TrxLoggerConstants.OrderedTestType)) { - if (parentTestElement != null && - parentTestElement.TestType.Equals(TrxLoggerConstants.OrderedTestType) && - !(parentTestElement as OrderedTestElement).TestLinks.ContainsKey(testElement.Id.Id)) - { - (parentTestElement as OrderedTestElement).TestLinks.Add(testElement.Id.Id, new TestLink(testElement.Id.Id, testElement.Name, testElement.Storage)); - } + (parentTestResult as TestResultAggregation).InnerResults.Add(testResult); + _innerResults.TryAdd(executionId, testResult); + return testResult; } - /// - /// Creates test result - /// - /// - /// - /// - /// - /// - /// - /// - /// Trx test result - private ITestResult CreateTestResult(Guid executionId, Guid parentExecutionId, TestType testType, - ITestElement testElement, ITestElement parentTestElement, ITestResult parentTestResult, ObjectModel.TestResult rocksteadyTestResult) + // Data driven inner result scenario + if (parentTestElement != null && parentTestElement.TestType.Equals(TrxLoggerConstants.UnitTestType)) { - // Create test result - TrxLoggerObjectModel.TestOutcome testOutcome = this.converter.ToOutcome(rocksteadyTestResult.Outcome); - var testResult = this.converter.ToTestResult(testElement.Id.Id, executionId, parentExecutionId, testElement.Name, - this.testResultsDirPath, testType, testElement.CategoryId, testOutcome, this.testRun, rocksteadyTestResult); - - // Normal result scenario - if (parentTestResult == null) - { - this.results.TryAdd(executionId, testResult); - return testResult; - } + (parentTestResult as TestResultAggregation).InnerResults.Add(testResult); + testResult.DataRowInfo = (parentTestResult as TestResultAggregation).InnerResults.Count; + testResult.ResultType = TrxLoggerConstants.InnerDataDrivenResultType; + parentTestResult.ResultType = TrxLoggerConstants.ParentDataDrivenResultType; + return testResult; + } - // Ordered test inner result scenario - if (parentTestElement != null && parentTestElement.TestType.Equals(TrxLoggerConstants.OrderedTestType)) - { - (parentTestResult as TestResultAggregation).InnerResults.Add(testResult); - this.innerResults.TryAdd(executionId, testResult); - return testResult; - } + return testResult; + } - // Data driven inner result scenario - if (parentTestElement != null && parentTestElement.TestType.Equals(TrxLoggerConstants.UnitTestType)) - { - (parentTestResult as TestResultAggregation).InnerResults.Add(testResult); - testResult.DataRowInfo = (parentTestResult as TestResultAggregation).InnerResults.Count; - testResult.ResultType = TrxLoggerConstants.InnerDataDrivenResultType; - parentTestResult.ResultType = TrxLoggerConstants.ParentDataDrivenResultType; - return testResult; - } + /// + /// Update test entries + /// + /// + /// + /// + /// + private void UpdateTestEntries(Guid executionId, Guid parentExecutionId, ITestElement testElement, ITestElement parentTestElement) + { + TestEntry te = new(testElement.Id, TestListCategory.UncategorizedResults.Id); + te.ExecutionId = executionId; - return testResult; + if (parentTestElement == null) + { + _entries.TryAdd(executionId, te); } - - /// - /// Update test entries - /// - /// - /// - /// - /// - private void UpdateTestEntries(Guid executionId, Guid parentExecutionId, ITestElement testElement, ITestElement parentTestElement) + else if (parentTestElement.TestType.Equals(TrxLoggerConstants.OrderedTestType)) { - TestEntry te = new TestEntry(testElement.Id, TestListCategory.UncategorizedResults.Id); - te.ExecutionId = executionId; - - if (parentTestElement == null) - { - this.entries.TryAdd(executionId, te); - } - else if (parentTestElement.TestType.Equals(TrxLoggerConstants.OrderedTestType)) - { - te.ParentExecutionId = parentExecutionId; + te.ParentExecutionId = parentExecutionId; - var parentTestEntry = GetTestEntry(parentExecutionId); - if (parentTestEntry != null) - parentTestEntry.TestEntries.Add(te); + var parentTestEntry = GetTestEntry(parentExecutionId); + if (parentTestEntry != null) + parentTestEntry.TestEntries.Add(te); - this.innerTestEntries.TryAdd(executionId, te); - } + _innerTestEntries.TryAdd(executionId, te); } + } - /// - /// Gets test entry from stored test entries. - /// - /// - /// Test entry - private TestEntry GetTestEntry(Guid executionId) - { - TestEntry testEntry = null; - - if (executionId != Guid.Empty) - { - this.entries.TryGetValue(executionId, out testEntry); + /// + /// Gets test entry from stored test entries. + /// + /// + /// Test entry + private TestEntry GetTestEntry(Guid executionId) + { + TestEntry testEntry = null; - if (testEntry == null) - this.innerTestEntries.TryGetValue(executionId, out testEntry); - } + if (executionId != Guid.Empty) + { + _entries.TryGetValue(executionId, out testEntry); - return testEntry; + if (testEntry == null) + _innerTestEntries.TryGetValue(executionId, out testEntry); } - private TrxLoggerObjectModel.TestOutcome ChangeTestOutcomeIfNecessary (TrxLoggerObjectModel.TestOutcome outcome) - { - // If no tests discovered/executed and TreatNoTestsAsError was set to True - // We will return ResultSummary as Failed - // Note : we only send the value of TreatNoTestsAsError if it is "True" - if (totalTests == 0 && parametersDictionary.ContainsKey(ObjectModelConstants.TreatNoTestsAsError)) - { - outcome = TrxLoggerObjectModel.TestOutcome.Failed; - } + return testEntry; + } - return outcome; + private TrxLoggerObjectModel.TestOutcome ChangeTestOutcomeIfNecessary(TrxLoggerObjectModel.TestOutcome outcome) + { + // If no tests discovered/executed and TreatNoTestsAsError was set to True + // We will return ResultSummary as Failed + // Note : we only send the value of TreatNoTestsAsError if it is "True" + if (TotalTestCount == 0 && _parametersDictionary.ContainsKey(ObjectModelConstants.TreatNoTestsAsError)) + { + outcome = TrxLoggerObjectModel.TestOutcome.Failed; } - #endregion + return outcome; } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Collection.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Collection.cs index d4e1074fc1..7ad22686e5 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Collection.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Collection.cs @@ -1,207 +1,201 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.Utility -{ - using System.Collections; - using System.Collections.Generic; - using System.Diagnostics; +namespace Microsoft.TestPlatform.Extensions.TrxLogger.Utility; + +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; - using Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; - using System.Xml; +using XML; +using ObjectModel; +using System.Xml; +/// +/// Base class for Eqt Collections. +/// Fast collection, default implementations (Add/Remove/etc) do not allow null items and ignore duplicates. +/// +internal class EqtBaseCollection : ICollection, IXmlTestStore +{ + #region private classes /// - /// Base class for Eqt Collections. - /// Fast collection, default implementations (Add/Remove/etc) do not allow null items and ignore duplicates. + /// Wraps non-generic enumerator. /// - internal class EqtBaseCollection : ICollection, IXmlTestStore - { - #region private classes - /// - /// Wraps non-generic enumerator. - /// - /// - private sealed class EqtBaseCollectionEnumerator : IEnumerator - { - private IEnumerator enumerator; - - internal EqtBaseCollectionEnumerator(IEnumerator e) - { - Debug.Assert(e != null, "e is null"); - this.enumerator = e; - } - - public TemplateType Current - { - get { return (TemplateType)this.enumerator.Current; } - } - - object IEnumerator.Current - { - get { return this.enumerator.Current; } - } - - public bool MoveNext() - { - return this.enumerator.MoveNext(); - } - - public void Reset() - { - this.enumerator.Reset(); - } + /// + private sealed class EqtBaseCollectionEnumerator : IEnumerator + { + private readonly IEnumerator _enumerator; - public void Dispose() - { - } + internal EqtBaseCollectionEnumerator(IEnumerator e) + { + Debug.Assert(e != null, "e is null"); + _enumerator = e; } - #endregion - - #region Fields - protected Hashtable container; - - private string childElementName; - #endregion - #region Constructors - protected EqtBaseCollection() + public TemplateType Current { - this.container = new Hashtable(); + get { return (TemplateType)_enumerator.Current; } } - /// - /// Constructor. - /// - /// For case insensitive comparison use StringComparer.InvariantCultureIgnoreCase. - protected EqtBaseCollection(IEqualityComparer comparer) + object IEnumerator.Current { - this.container = new Hashtable(0, comparer); // Ad default Hashtable() constructor creates table with 0 items. + get { return _enumerator.Current; } } - /// - /// Copy constructor. Shallow copy. - /// - /// The object to copy items from. - protected EqtBaseCollection(EqtBaseCollection other) + public bool MoveNext() { - EqtAssert.ParameterNotNull(other, nameof(other)); - this.container = new Hashtable(other.container); + return _enumerator.MoveNext(); } - #endregion - #region Methods: ICollection - // TODO: Consider putting check for null to derived classes. - public virtual void Add(T item) + public void Reset() { - EqtAssert.ParameterNotNull(item, nameof(item)); - - if (!this.container.Contains(item)) - { - this.container.Add(item, null); // Do not want to xml-persist the value. - } + _enumerator.Reset(); } - public virtual bool Contains(T item) + public void Dispose() { - if (item == null) - { - return false; - } - - return this.container.Contains(item); } + } + #endregion - /// - /// Removes specified item from collection. - /// - /// The item to remove. - /// True if collection contained the item, otherwise false. - public virtual bool Remove(T item) - { - EqtAssert.ParameterNotNull(item, nameof(item)); // This is to be consistent with Add... - if (this.container.Contains(item)) - { - this.container.Remove(item); - return true; - } + #region Fields + protected Hashtable _container; - return false; - } + private string _childElementName; + #endregion - public virtual void Clear() - { - this.container.Clear(); - } + #region Constructors + protected EqtBaseCollection() + { + _container = new Hashtable(); + } - /// - /// Shallow copy. Assumes that items are immutable. Override if your items are mutable. - /// - public virtual object Clone() - { - return new EqtBaseCollection(this); - } + /// + /// Constructor. + /// + /// For case insensitive comparison use StringComparer.InvariantCultureIgnoreCase. + protected EqtBaseCollection(IEqualityComparer comparer) + { + _container = new Hashtable(0, comparer); // Ad default Hashtable() constructor creates table with 0 items. + } - public virtual int Count - { - get { return this.container.Count; } - } + /// + /// Copy constructor. Shallow copy. + /// + /// The object to copy items from. + protected EqtBaseCollection(EqtBaseCollection other) + { + EqtAssert.ParameterNotNull(other, nameof(other)); + _container = new Hashtable(other._container); + } + #endregion - /// - /// Copies all items to the array. - /// As FxCop recommends, this is an explicit implementation and derived classes need to define strongly typed CopyTo. - /// - public virtual void CopyTo(T[] array, int index) - { - EqtAssert.ParameterNotNull(array, nameof(array)); - this.container.Keys.CopyTo(array, index); - } + #region Methods: ICollection + // TODO: Consider putting check for null to derived classes. + public virtual void Add(T item) + { + EqtAssert.ParameterNotNull(item, nameof(item)); - public bool IsReadOnly + if (!_container.Contains(item)) { - get { return false; } + _container.Add(item, null); // Do not want to xml-persist the value. } - #endregion + } - #region IEnumerable - public virtual IEnumerator GetEnumerator() - { - return this.container.Keys.GetEnumerator(); - } + public virtual bool Contains(T item) + { + return item != null && _container.Contains(item); + } - IEnumerator IEnumerable.GetEnumerator() + /// + /// Removes specified item from collection. + /// + /// The item to remove. + /// True if collection contained the item, otherwise false. + public virtual bool Remove(T item) + { + EqtAssert.ParameterNotNull(item, nameof(item)); // This is to be consistent with Add... + if (_container.Contains(item)) { - return new EqtBaseCollectionEnumerator(this.GetEnumerator()); + _container.Remove(item); + return true; } - #endregion - #region IXmlTestStore Members + return false; + } - /// - /// Default behavior is to create child elements with name same as name of type T. - /// Does not respect IXmlTestStoreCustom. - /// - public virtual void Save(XmlElement element, XmlTestStoreParameters parameters) - { - XmlPersistence xmlPersistence = new XmlPersistence(); - xmlPersistence.SaveHashtable(this.container, element, ".", ".", null, ChildElementName, parameters); - } + public virtual void Clear() + { + _container.Clear(); + } + + /// + /// Shallow copy. Assumes that items are immutable. Override if your items are mutable. + /// + public virtual object Clone() + { + return new EqtBaseCollection(this); + } - #endregion + public virtual int Count + { + get { return _container.Count; } + } + + /// + /// Copies all items to the array. + /// As FxCop recommends, this is an explicit implementation and derived classes need to define strongly typed CopyTo. + /// + public virtual void CopyTo(T[] array, int index) + { + EqtAssert.ParameterNotNull(array, nameof(array)); + _container.Keys.CopyTo(array, index); + } + + public bool IsReadOnly + { + get { return false; } + } + #endregion + + #region IEnumerable + public virtual IEnumerator GetEnumerator() + { + return _container.Keys.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return new EqtBaseCollectionEnumerator(GetEnumerator()); + } + #endregion + + #region IXmlTestStore Members + + /// + /// Default behavior is to create child elements with name same as name of type T. + /// Does not respect IXmlTestStoreCustom. + /// + public virtual void Save(XmlElement element, XmlTestStoreParameters parameters) + { + XmlPersistence xmlPersistence = new(); + xmlPersistence.SaveHashtable(_container, element, ".", ".", null, ChildElementName, parameters); + } + + #endregion - #region Private - private string ChildElementName + #region Private + private string ChildElementName + { + get { - get + if (_childElementName == null) { - if (this.childElementName == null) - { - // All we can do here is to delegate to T. Cannot cast T to IXmlTestStoreCustom as T is a type, not an instance. - this.childElementName = typeof(T).Name; - } - return this.childElementName; + // All we can do here is to delegate to T. Cannot cast T to IXmlTestStoreCustom as T is a type, not an instance. + _childElementName = typeof(T).Name; } + return _childElementName; } - #endregion } -} + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Constants.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Constants.cs index 36d426fc85..97c97dcbbf 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Constants.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Constants.cs @@ -1,111 +1,105 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.Utility +namespace Microsoft.TestPlatform.Extensions.TrxLogger.Utility; + +using System; + +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; + +internal static class Constants { - using System; - using Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - - internal static class Constants - { - /// - /// Uri used to uniquely identify the TRX logger. - /// - public const string ExtensionUri = "logger://Microsoft/TestPlatform/TrxLogger/v1"; - - /// - /// Alternate user friendly string to uniquely identify the console logger. - /// - public const string FriendlyName = "Trx"; - - /// - /// Prefix of the data collector - /// - public const string DataCollectorUriPrefix = "dataCollector://"; - - /// - /// Log file parameter key - /// - public const string LogFileNameKey = "LogFileName"; - - /// - /// Log file prefix key - /// - public const string LogFilePrefixKey = "LogFilePrefix"; - - /// - /// Ordered test element name - /// - public const string OrderedTestElementName = "OrderedTest"; - - /// - /// Unit test element name - /// - public const string UnitTestElementName = "UnitTest"; - - /// - /// Property Id storing the ExecutionId. - /// - public const string ExecutionIdPropertyIdentifier = "ExecutionId"; - - /// - /// Property Id storing the ParentExecutionId. - /// - public const string ParentExecutionIdPropertyIdentifier = "ParentExecId"; - - /// - /// Property If storing the TestType. - /// - public const string TestTypePropertyIdentifier = "TestType"; - - /// - /// Parent data driven result type. - /// - public const string ParentDataDrivenResultType = "DataDrivenTest"; - - /// - /// Inner data driven result type. - /// - public const string InnerDataDrivenResultType = "DataDrivenDataRow"; - - /// - /// Property Id storing the TMITestId. - /// - public const string TmiTestIdPropertyIdentifier = "MSTestDiscoverer.TmiTestId"; - - /// - /// Mstest adapter string - /// - public const string MstestAdapterString = "mstestadapter"; - - /// - /// Ordered test type guid - /// - public static readonly Guid OrderedTestTypeGuid = new Guid("ec4800e8-40e5-4ab3-8510-b8bf29b1904d"); - - /// - /// Ordered test type - /// - public static readonly TestType OrderedTestType = new TestType(OrderedTestTypeGuid); - - /// - /// Unit test type guid - /// - public static readonly Guid UnitTestTypeGuid = new Guid("13CDC9D9-DDB5-4fa4-A97D-D965CCFC6D4B"); - - /// - /// Unit test type - /// - public static readonly TestType UnitTestType = new TestType(UnitTestTypeGuid); - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly TestProperty ExecutionIdProperty = TestProperty.Register("ExecutionId", ExecutionIdPropertyIdentifier, typeof(Guid), TestPropertyAttributes.Hidden, typeof(ObjectModel.TestResult)); - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly TestProperty ParentExecIdProperty = TestProperty.Register("ParentExecId", ParentExecutionIdPropertyIdentifier, typeof(Guid), TestPropertyAttributes.Hidden, typeof(ObjectModel.TestResult)); - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly TestProperty TestTypeProperty = TestProperty.Register("TestType", TestTypePropertyIdentifier, typeof(Guid), TestPropertyAttributes.Hidden, typeof(ObjectModel.TestResult)); - } -} + /// + /// Uri used to uniquely identify the TRX logger. + /// + public const string ExtensionUri = "logger://Microsoft/TestPlatform/TrxLogger/v1"; + + /// + /// Alternate user friendly string to uniquely identify the console logger. + /// + public const string FriendlyName = "Trx"; + + /// + /// Prefix of the data collector + /// + public const string DataCollectorUriPrefix = "dataCollector://"; + + /// + /// Log file parameter key + /// + public const string LogFileNameKey = "LogFileName"; + + /// + /// Log file prefix key + /// + public const string LogFilePrefixKey = "LogFilePrefix"; + + /// + /// Ordered test element name + /// + public const string OrderedTestElementName = "OrderedTest"; + + /// + /// Unit test element name + /// + public const string UnitTestElementName = "UnitTest"; + + /// + /// Property Id storing the ExecutionId. + /// + public const string ExecutionIdPropertyIdentifier = "ExecutionId"; + + /// + /// Property Id storing the ParentExecutionId. + /// + public const string ParentExecutionIdPropertyIdentifier = "ParentExecId"; + + /// + /// Property If storing the TestType. + /// + public const string TestTypePropertyIdentifier = "TestType"; + + /// + /// Parent data driven result type. + /// + public const string ParentDataDrivenResultType = "DataDrivenTest"; + + /// + /// Inner data driven result type. + /// + public const string InnerDataDrivenResultType = "DataDrivenDataRow"; + + /// + /// Property Id storing the TMITestId. + /// + public const string TmiTestIdPropertyIdentifier = "MSTestDiscoverer.TmiTestId"; + + /// + /// Mstest adapter string + /// + public const string MstestAdapterString = "mstestadapter"; + + /// + /// Ordered test type guid + /// + public static readonly Guid OrderedTestTypeGuid = new("ec4800e8-40e5-4ab3-8510-b8bf29b1904d"); + + /// + /// Ordered test type + /// + public static readonly TestType OrderedTestType = new(OrderedTestTypeGuid); + + /// + /// Unit test type guid + /// + public static readonly Guid UnitTestTypeGuid = new("13CDC9D9-DDB5-4fa4-A97D-D965CCFC6D4B"); + + /// + /// Unit test type + /// + public static readonly TestType UnitTestType = new(UnitTestTypeGuid); + public static readonly TestProperty ExecutionIdProperty = TestProperty.Register("ExecutionId", ExecutionIdPropertyIdentifier, typeof(Guid), TestPropertyAttributes.Hidden, typeof(ObjectModel.TestResult)); + public static readonly TestProperty ParentExecIdProperty = TestProperty.Register("ParentExecId", ParentExecutionIdPropertyIdentifier, typeof(Guid), TestPropertyAttributes.Hidden, typeof(ObjectModel.TestResult)); + public static readonly TestProperty TestTypeProperty = TestProperty.Register("TestType", TestTypePropertyIdentifier, typeof(Guid), TestPropertyAttributes.Hidden, typeof(ObjectModel.TestResult)); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs index 3876a5b992..e26b44f53a 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs @@ -1,733 +1,723 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.Utility +namespace Microsoft.TestPlatform.Extensions.TrxLogger.Utility; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; + +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +using ObjectModel = VisualStudio.TestPlatform.ObjectModel; +using TrxLoggerResources = VisualStudio.TestPlatform.Extensions.TrxLogger.Resources.TrxResource; +using TrxObjectModel = ObjectModel; + +/// +/// The converter class. +/// +internal class Converter { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Diagnostics.CodeAnalysis; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Text; - using Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using ObjectModel = Microsoft.VisualStudio.TestPlatform.ObjectModel; - using TrxLoggerResources = Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.Resources.TrxResource; - using TrxObjectModel = Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; + private readonly TrxFileHelper _trxFileHelper; + private readonly IFileHelper _fileHelper; /// - /// The converter class. + /// Initializes a new instance of the class. /// - internal class Converter + public Converter(IFileHelper fileHelper, TrxFileHelper trxFileHelper) { - private readonly TrxFileHelper trxFileHelper; - private IFileHelper fileHelper; + _trxFileHelper = trxFileHelper; + _fileHelper = fileHelper; + } + + /// + /// Converts platform test case to trx test element. + /// + /// + /// + /// + /// + /// + /// + /// Trx test element + public ITestElement ToTestElement( + Guid testId, + Guid executionId, + Guid parentExecutionId, + string testName, + TestType testType, + TestCase rockSteadyTestCase) + { + var testElement = CreateTestElement(testId, testName, rockSteadyTestCase.FullyQualifiedName, rockSteadyTestCase.ExecutorUri.ToString(), rockSteadyTestCase.Source, testType); - /// - /// Initializes a new instance of the class. - /// - public Converter(IFileHelper fileHelper, TrxFileHelper trxFileHelper) + testElement.Storage = rockSteadyTestCase.Source; + testElement.Priority = GetPriority(rockSteadyTestCase); + testElement.Owner = GetOwner(rockSteadyTestCase); + testElement.ExecutionId = new TestExecId(executionId); + testElement.ParentExecutionId = new TestExecId(parentExecutionId); + + var testCategories = GetCustomPropertyValueFromTestCase(rockSteadyTestCase, "MSTestDiscoverer.TestCategory"); + foreach (string testCategory in testCategories) { - this.trxFileHelper = trxFileHelper; - this.fileHelper = fileHelper; + testElement.TestCategories.Add(testCategory); } - /// - /// Converts platform test case to trx test element. - /// - /// - /// - /// - /// - /// - /// - /// Trx test element - public ITestElement ToTestElement( - Guid testId, - Guid executionId, - Guid parentExecutionId, - string testName, - TestType testType, - TestCase rockSteadyTestCase) + var workItems = GetCustomPropertyValueFromTestCase(rockSteadyTestCase, "WorkItemIds") + .Select(workItem => int.Parse(workItem)); + foreach (int workItem in workItems) { - var testElement = CreateTestElement(testId, testName, rockSteadyTestCase.FullyQualifiedName, rockSteadyTestCase.ExecutorUri.ToString(), rockSteadyTestCase.Source, testType); - - testElement.Storage = rockSteadyTestCase.Source; - testElement.Priority = GetPriority(rockSteadyTestCase); - testElement.Owner = GetOwner(rockSteadyTestCase); - testElement.ExecutionId = new TestExecId(executionId); - testElement.ParentExecutionId = new TestExecId(parentExecutionId); - - var testCategories = GetCustomPropertyValueFromTestCase(rockSteadyTestCase, "MSTestDiscoverer.TestCategory"); - foreach (string testCategory in testCategories) - { - testElement.TestCategories.Add(testCategory); - } + testElement.WorkItems.Add(workItem); + } - var workItems = GetCustomPropertyValueFromTestCase(rockSteadyTestCase, "WorkItemIds") - .Select(workItem => int.Parse(workItem)); - foreach (int workItem in workItems) - { - testElement.WorkItems.Add(workItem); - } + return testElement; + } - return testElement; - } + /// + /// Converts the rockSteady result to unit test result + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Trx test result object + public ITestResult ToTestResult( + Guid testId, + Guid executionId, + Guid parentExecutionId, + string testName, + string trxFileDirectory, + TestType testType, + TestListCategoryId testCategoryId, + TrxObjectModel.TestOutcome testOutcome, + TestRun testRun, + ObjectModel.TestResult rockSteadyTestResult) + { + var resultName = !string.IsNullOrEmpty(rockSteadyTestResult.DisplayName) ? rockSteadyTestResult.DisplayName : testName; + var testResult = CreateTestResult(testRun.Id, testId, executionId, parentExecutionId, resultName, testOutcome, testType, testCategoryId); - /// - /// Converts the rockSteady result to unit test result - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// Trx test result object - public ITestResult ToTestResult( - Guid testId, - Guid executionId, - Guid parentExecutionId, - string testName, - string trxFileDirectory, - TestType testType, - TestListCategoryId testCategoryId, - TrxObjectModel.TestOutcome testOutcome, - TestRun testRun, - ObjectModel.TestResult rockSteadyTestResult) - { - var resultName = !string.IsNullOrEmpty(rockSteadyTestResult.DisplayName) ? rockSteadyTestResult.DisplayName : testName; - var testResult = CreateTestResult(testRun.Id, testId, executionId, parentExecutionId, resultName, testOutcome, testType, testCategoryId); + if (rockSteadyTestResult.ErrorMessage != null) + testResult.ErrorMessage = rockSteadyTestResult.ErrorMessage; - if (rockSteadyTestResult.ErrorMessage != null) - testResult.ErrorMessage = rockSteadyTestResult.ErrorMessage; + if (rockSteadyTestResult.ErrorStackTrace != null) + testResult.ErrorStackTrace = rockSteadyTestResult.ErrorStackTrace; - if (rockSteadyTestResult.ErrorStackTrace != null) - testResult.ErrorStackTrace = rockSteadyTestResult.ErrorStackTrace; + if (rockSteadyTestResult.EndTime != default) + testResult.EndTime = rockSteadyTestResult.EndTime.UtcDateTime; - if (rockSteadyTestResult.EndTime != default(DateTimeOffset)) - testResult.EndTime = rockSteadyTestResult.EndTime.UtcDateTime; + if (rockSteadyTestResult.StartTime != default) + testResult.StartTime = rockSteadyTestResult.StartTime.UtcDateTime; - if (rockSteadyTestResult.StartTime != default(DateTimeOffset)) - testResult.StartTime = rockSteadyTestResult.StartTime.UtcDateTime; + if (rockSteadyTestResult.Duration != default) + testResult.Duration = rockSteadyTestResult.Duration; - if (rockSteadyTestResult.Duration != default(TimeSpan)) - testResult.Duration = rockSteadyTestResult.Duration; + // Clear existing messages and store rocksteady result messages. + testResult.TextMessages = null; + UpdateResultMessages(testResult, rockSteadyTestResult); - // Clear existing messages and store rocksteady result messages. - testResult.TextMessages = null; - UpdateResultMessages(testResult, rockSteadyTestResult); + // Save result attachments to target location. + UpdateTestResultAttachments(rockSteadyTestResult, testResult, testRun, trxFileDirectory, true); - // Save result attachments to target location. - UpdateTestResultAttachments(rockSteadyTestResult, testResult, testRun, trxFileDirectory, true); + return testResult; + } - return testResult; - } + /// + /// converts ObjectModel.TestOutcome type to TrxLogger.TestOutcome type + /// + /// + /// The rockSteady Outcome. + /// + /// + /// The . + /// + public TrxObjectModel.TestOutcome ToOutcome(ObjectModel.TestOutcome rockSteadyOutcome) + { + TrxObjectModel.TestOutcome outcome = TrxObjectModel.TestOutcome.Failed; - /// - /// converts ObjectModel.TestOutcome type to TrxLogger.TestOutcome type - /// - /// - /// The rockSteady Outcome. - /// - /// - /// The . - /// - [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is OK here.")] - public TrxObjectModel.TestOutcome ToOutcome(ObjectModel.TestOutcome rockSteadyOutcome) + switch (rockSteadyOutcome) { - TrxObjectModel.TestOutcome outcome = TrxObjectModel.TestOutcome.Failed; + case ObjectModel.TestOutcome.Failed: + outcome = TrxObjectModel.TestOutcome.Failed; + break; + case ObjectModel.TestOutcome.Passed: + outcome = TrxObjectModel.TestOutcome.Passed; + break; + case ObjectModel.TestOutcome.Skipped: + case ObjectModel.TestOutcome.None: + case ObjectModel.TestOutcome.NotFound: + outcome = TrxObjectModel.TestOutcome.NotExecuted; + break; + default: + Debug.Fail("Unexpected Outcome."); + break; + } - switch (rockSteadyOutcome) - { - case ObjectModel.TestOutcome.Failed: - outcome = TrxObjectModel.TestOutcome.Failed; - break; - case ObjectModel.TestOutcome.Passed: - outcome = TrxObjectModel.TestOutcome.Passed; - break; - case ObjectModel.TestOutcome.Skipped: - case ObjectModel.TestOutcome.None: - case ObjectModel.TestOutcome.NotFound: - outcome = TrxObjectModel.TestOutcome.NotExecuted; - break; - default: - Debug.Fail("Unexpected Outcome."); - break; - } + return outcome; + } - return outcome; + public List ToCollectionEntries(IEnumerable attachmentSets, TestRun testRun, string trxFileDirectory) + { + List collectorEntries = new(); + if (attachmentSets == null) + { + EqtTrace.Info($"Converter.ToCollectionEntries: Received {nameof(attachmentSets)} as null returning empty collection entries."); + return collectorEntries; } - public List ToCollectionEntries(IEnumerable attachmentSets, TestRun testRun, string trxFileDirectory) + if (EqtTrace.IsInfoEnabled) { - List collectorEntries = new List(); - if (attachmentSets == null) - { - EqtTrace.Info($"Converter.ToCollectionEntries: Received {nameof(attachmentSets)} as null returning empty collection entries."); - return collectorEntries; - } + EqtTrace.Info($"Converter.ToCollectionEntries: Converting attachmentSets {string.Join(",", attachmentSets)} to collection entries."); + } - if (EqtTrace.IsInfoEnabled) + foreach (var attachmentSet in attachmentSets) + { + if (attachmentSet.Uri.AbsoluteUri.StartsWith(Constants.DataCollectorUriPrefix, StringComparison.OrdinalIgnoreCase)) { - EqtTrace.Info($"Converter.ToCollectionEntries: Converting attachmentSets {string.Join(",", attachmentSets)} to collection entries."); + CollectorDataEntry collectorEntry = ToCollectorEntry(attachmentSet, Guid.Empty, testRun, trxFileDirectory); + collectorEntries.Add(collectorEntry); } + } - foreach (var attachmentSet in attachmentSets) - { - if (attachmentSet.Uri.AbsoluteUri.StartsWith(Constants.DataCollectorUriPrefix, StringComparison.OrdinalIgnoreCase)) - { - CollectorDataEntry collectorEntry = ToCollectorEntry(attachmentSet, Guid.Empty, testRun, trxFileDirectory); - collectorEntries.Add(collectorEntry); - } - } + return collectorEntries; + } - return collectorEntries; + public IList ToResultFiles(IEnumerable attachmentSets, TestRun testRun, string trxFileDirectory, + List errorMessages) + { + List resultFiles = new(); + if (attachmentSets == null) + { + return resultFiles; } - public IList ToResultFiles(IEnumerable attachmentSets, TestRun testRun, string trxFileDirectory, - List errorMessages) + foreach (var attachmentSet in attachmentSets) { - List resultFiles = new List(); - if (attachmentSets == null) - { - return resultFiles; - } - - foreach (var attachmentSet in attachmentSets) + if (!attachmentSet.Uri.AbsoluteUri.StartsWith(Constants.DataCollectorUriPrefix, StringComparison.OrdinalIgnoreCase)) { - if (!attachmentSet.Uri.AbsoluteUri.StartsWith(Constants.DataCollectorUriPrefix, StringComparison.OrdinalIgnoreCase)) + try { - try - { - IList testResultFiles = ToResultFiles(attachmentSet, Guid.Empty, testRun, trxFileDirectory); - resultFiles.AddRange(testResultFiles); - } - catch (Exception e) + IList testResultFiles = ToResultFiles(attachmentSet, Guid.Empty, testRun, trxFileDirectory); + resultFiles.AddRange(testResultFiles); + } + catch (Exception e) + { + string errorMsg = string.Format( + CultureInfo.CurrentCulture, + TrxLoggerResources.FailureToAttach, + attachmentSet.DisplayName, + e.GetType().ToString(), + e); + + if (EqtTrace.IsErrorEnabled) { - string errorMsg = string.Format( - CultureInfo.CurrentCulture, - TrxLoggerResources.FailureToAttach, - attachmentSet.DisplayName, - e.GetType().ToString(), - e); - - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("Converter: ToResultFiles: " + errorMsg); - } - - errorMessages.Add(errorMsg); + EqtTrace.Error("Converter: ToResultFiles: " + errorMsg); } + + errorMessages.Add(errorMsg); } } - return resultFiles; } + return resultFiles; + } - /// - /// Copies the result messages to unitTestResult - /// - /// TRX TestResult - /// rock steady test result - private void UpdateResultMessages(TrxObjectModel.TestResult unitTestResult, ObjectModel.TestResult testResult) - { - StringBuilder debugTrace = new StringBuilder(); - StringBuilder stdErr = new StringBuilder(); - StringBuilder stdOut = new StringBuilder(); + /// + /// Copies the result messages to unitTestResult + /// + /// TRX TestResult + /// rock steady test result + private void UpdateResultMessages(TrxObjectModel.TestResult unitTestResult, ObjectModel.TestResult testResult) + { + StringBuilder debugTrace = new(); + StringBuilder stdErr = new(); + StringBuilder stdOut = new(); - foreach (TestResultMessage message in testResult.Messages) + foreach (TestResultMessage message in testResult.Messages) + { + if (TestResultMessage.AdditionalInfoCategory.Equals(message.Category, StringComparison.OrdinalIgnoreCase)) { - if (TestResultMessage.AdditionalInfoCategory.Equals(message.Category, StringComparison.OrdinalIgnoreCase)) - { - unitTestResult.AddTextMessage(message.Text); - } - else if (TestResultMessage.DebugTraceCategory.Equals(message.Category, StringComparison.OrdinalIgnoreCase)) - { - debugTrace.AppendLine(message.Text); - } - else if (TestResultMessage.StandardErrorCategory.Equals(message.Category, StringComparison.OrdinalIgnoreCase)) - { - stdErr.AppendLine(message.Text); - } - else if (TestResultMessage.StandardOutCategory.Equals(message.Category, StringComparison.OrdinalIgnoreCase)) - { - stdOut.AppendLine(message.Text); - } - else - { - EqtTrace.Warning("The message category " + message.Category + " does not match any predefined category."); - } + unitTestResult.AddTextMessage(message.Text); + } + else if (TestResultMessage.DebugTraceCategory.Equals(message.Category, StringComparison.OrdinalIgnoreCase)) + { + debugTrace.AppendLine(message.Text); + } + else if (TestResultMessage.StandardErrorCategory.Equals(message.Category, StringComparison.OrdinalIgnoreCase)) + { + stdErr.AppendLine(message.Text); + } + else if (TestResultMessage.StandardOutCategory.Equals(message.Category, StringComparison.OrdinalIgnoreCase)) + { + stdOut.AppendLine(message.Text); + } + else + { + EqtTrace.Warning("The message category " + message.Category + " does not match any predefined category."); } - - unitTestResult.DebugTrace = debugTrace.ToString(); - unitTestResult.StdErr = stdErr.ToString(); - unitTestResult.StdOut = stdOut.ToString(); } - /// - /// Get Custom property values from test cases. - /// - /// TestCase object extracted from the TestResult - /// Property Name from the list of properties in TestCase - /// list of properties - public List GetCustomPropertyValueFromTestCase(TestCase testCase, string categoryID) - { - var customProperty = testCase.Properties.FirstOrDefault(t => t.Id.Equals(categoryID)); + unitTestResult.DebugTrace = debugTrace.ToString(); + unitTestResult.StdErr = stdErr.ToString(); + unitTestResult.StdOut = stdOut.ToString(); + } - if (customProperty != null) - { - var cateogryValues = (string[])testCase.GetPropertyValue(customProperty); - if (cateogryValues != null) - { - return cateogryValues.ToList(); - } - else - { - return Enumerable.Empty().ToList(); - } - } + /// + /// Get Custom property values from test cases. + /// + /// TestCase object extracted from the TestResult + /// Property Name from the list of properties in TestCase + /// list of properties + public List GetCustomPropertyValueFromTestCase(TestCase testCase, string categoryId) + { + var customProperty = testCase.Properties.FirstOrDefault(t => t.Id.Equals(categoryId)); - return Enumerable.Empty().ToList(); + if (customProperty != null) + { + var cateogryValues = (string[])testCase.GetPropertyValue(customProperty); + return cateogryValues != null ? cateogryValues.ToList() : Enumerable.Empty().ToList(); } - /// - /// Gets test id. - /// Return TMI Test id when available for TestPlatform test case. - /// - /// - /// Test id - public Guid GetTestId(TestCase rockSteadyTestCase) - { - Guid testId = Guid.Empty; + return Enumerable.Empty().ToList(); + } - // Setting test id to tmi test id. - TestProperty tmiTestIdProperty = rockSteadyTestCase.Properties.FirstOrDefault( - property => property.Id.Equals(Constants.TmiTestIdPropertyIdentifier)); + /// + /// Gets test id. + /// Return TMI Test id when available for TestPlatform test case. + /// + /// + /// Test id + public Guid GetTestId(TestCase rockSteadyTestCase) + { + Guid testId = Guid.Empty; - if (tmiTestIdProperty != null) - testId = rockSteadyTestCase.GetPropertyValue(tmiTestIdProperty, Guid.Empty); + // Setting test id to tmi test id. + TestProperty tmiTestIdProperty = rockSteadyTestCase.Properties.FirstOrDefault( + property => property.Id.Equals(Constants.TmiTestIdPropertyIdentifier)); - // If tmi test id not present, picking from platform test id. - if (Guid.Empty.Equals(testId)) - testId = rockSteadyTestCase.Id; + if (tmiTestIdProperty != null) + testId = rockSteadyTestCase.GetPropertyValue(tmiTestIdProperty, Guid.Empty); - return testId; - } + // If tmi test id not present, picking from platform test id. + if (Guid.Empty.Equals(testId)) + testId = rockSteadyTestCase.Id; - /// - /// Gets parent execution id of test result. - /// - /// - /// Parent execution id. - public Guid GetParentExecutionId(ObjectModel.TestResult testResult) - { - TestProperty parentExecutionIdProperty = testResult.Properties.FirstOrDefault( - property => property.Id.Equals(Constants.ParentExecutionIdPropertyIdentifier)); + return testId; + } - return parentExecutionIdProperty == null ? - Guid.Empty : - testResult.GetPropertyValue(parentExecutionIdProperty, Guid.Empty); - } + /// + /// Gets parent execution id of test result. + /// + /// + /// Parent execution id. + public Guid GetParentExecutionId(ObjectModel.TestResult testResult) + { + TestProperty parentExecutionIdProperty = testResult.Properties.FirstOrDefault( + property => property.Id.Equals(Constants.ParentExecutionIdPropertyIdentifier)); - /// - /// Gets execution Id of test result. Creates new id if not present in test result properties. - /// - /// - /// Execution id. - public Guid GetExecutionId(ObjectModel.TestResult testResult) - { - TestProperty executionIdProperty = testResult.Properties.FirstOrDefault( - property => property.Id.Equals(Constants.ExecutionIdPropertyIdentifier)); + return parentExecutionIdProperty == null ? + Guid.Empty : + testResult.GetPropertyValue(parentExecutionIdProperty, Guid.Empty); + } - var executionId = Guid.Empty; - if (executionIdProperty != null) - executionId = testResult.GetPropertyValue(executionIdProperty, Guid.Empty); + /// + /// Gets execution Id of test result. Creates new id if not present in test result properties. + /// + /// + /// Execution id. + public Guid GetExecutionId(ObjectModel.TestResult testResult) + { + TestProperty executionIdProperty = testResult.Properties.FirstOrDefault( + property => property.Id.Equals(Constants.ExecutionIdPropertyIdentifier)); - return executionId.Equals(Guid.Empty) ? Guid.NewGuid() : executionId; - } + var executionId = Guid.Empty; + if (executionIdProperty != null) + executionId = testResult.GetPropertyValue(executionIdProperty, Guid.Empty); - /// - /// Gets test type of test result. - /// Currently trx supports ordered test and unit test. All tests except ordered test are modified as unit test type. - /// - /// - /// Test type - public TestType GetTestType(ObjectModel.TestResult testResult) - { - var testTypeGuid = Constants.UnitTestTypeGuid; + return executionId.Equals(Guid.Empty) ? Guid.NewGuid() : executionId; + } - // Get test type from property. default to unit test type. - TestProperty testTypeProperty = testResult.Properties.FirstOrDefault(property => property.Id.Equals(Constants.TestTypePropertyIdentifier)); - testTypeGuid = (testTypeProperty == null) ? testTypeGuid : testResult.GetPropertyValue(testTypeProperty, testTypeGuid); + /// + /// Gets test type of test result. + /// Currently trx supports ordered test and unit test. All tests except ordered test are modified as unit test type. + /// + /// + /// Test type + public TestType GetTestType(ObjectModel.TestResult testResult) + { + var testTypeGuid = Constants.UnitTestTypeGuid; - // Currently trx supports ordered test and unit test. All tests except ordered test are modified as unit test type. - return (testTypeGuid.Equals(Constants.OrderedTestTypeGuid)) ? - Constants.OrderedTestType : - Constants.UnitTestType; - } + // Get test type from property. default to unit test type. + TestProperty testTypeProperty = testResult.Properties.FirstOrDefault(property => property.Id.Equals(Constants.TestTypePropertyIdentifier)); + testTypeGuid = (testTypeProperty == null) ? testTypeGuid : testResult.GetPropertyValue(testTypeProperty, testTypeGuid); - /// - /// Updates test result attachments. - /// - /// - /// - /// - /// - /// - private void UpdateTestResultAttachments(ObjectModel.TestResult rockSteadyTestResult, TrxObjectModel.TestResult testResult, TestRun testRun, string trxFileDirectory, bool addAttachments) + // Currently trx supports ordered test and unit test. All tests except ordered test are modified as unit test type. + return (testTypeGuid.Equals(Constants.OrderedTestTypeGuid)) ? + Constants.OrderedTestType : + Constants.UnitTestType; + } + + /// + /// Updates test result attachments. + /// + /// + /// + /// + /// + /// + private void UpdateTestResultAttachments(ObjectModel.TestResult rockSteadyTestResult, TrxObjectModel.TestResult testResult, TestRun testRun, string trxFileDirectory, bool addAttachments) + { + if (rockSteadyTestResult.Attachments == null || rockSteadyTestResult.Attachments.Count == 0) { - if (rockSteadyTestResult.Attachments == null || rockSteadyTestResult.Attachments.Count == 0) - { - return; - } + return; + } - // the testResult needs to have the testRun property set. Otherwise Data Collector entries can't be added. - testResult.SetTestRun(testRun); + // the testResult needs to have the testRun property set. Otherwise Data Collector entries can't be added. + testResult.SetTestRun(testRun); - // result files - List resultFiles = new List(); + // result files + List resultFiles = new(); - // data collection files - List collectorEntries = new List(); + // data collection files + List collectorEntries = new(); - foreach (AttachmentSet attachmentSet in rockSteadyTestResult.Attachments) + foreach (AttachmentSet attachmentSet in rockSteadyTestResult.Attachments) + { + try { - try + // If the attachment is from data collector + if (attachmentSet.Uri.AbsoluteUri.StartsWith(Constants.DataCollectorUriPrefix, StringComparison.OrdinalIgnoreCase)) { - // If the attachment is from data collector - if (attachmentSet.Uri.AbsoluteUri.StartsWith(Constants.DataCollectorUriPrefix, StringComparison.OrdinalIgnoreCase)) - { - CollectorDataEntry collectorEntry = ToCollectorEntry(attachmentSet, testResult.Id.ExecutionId, testRun, trxFileDirectory); - collectorEntries.Add(collectorEntry); - } - else - { - IList testResultFiles = ToResultFiles(attachmentSet, testResult.Id.ExecutionId, testRun, trxFileDirectory); - resultFiles.AddRange(testResultFiles); - } + CollectorDataEntry collectorEntry = ToCollectorEntry(attachmentSet, testResult.Id.ExecutionId, testRun, trxFileDirectory); + collectorEntries.Add(collectorEntry); } - catch (Exception e) + else { - string errorMsg = string.Format( - CultureInfo.CurrentCulture, - TrxLoggerResources.FailureToAttach, - attachmentSet.DisplayName, - e.GetType().ToString(), - e); - - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("Converter: UpdateTestResultAttachments: " + errorMsg); - } - - StringBuilder stdErr = new StringBuilder(testResult.StdErr); - stdErr.AppendLine(errorMsg); - - testResult.StdErr = stdErr.ToString(); - testResult.Outcome = TrxObjectModel.TestOutcome.Error; + IList testResultFiles = ToResultFiles(attachmentSet, testResult.Id.ExecutionId, testRun, trxFileDirectory); + resultFiles.AddRange(testResultFiles); } } - - if (addAttachments) + catch (Exception e) { - if (resultFiles.Count > 0) - { - testResult.AddResultFiles(resultFiles); - } + string errorMsg = string.Format( + CultureInfo.CurrentCulture, + TrxLoggerResources.FailureToAttach, + attachmentSet.DisplayName, + e.GetType().ToString(), + e); - if (collectorEntries.Count > 0) + if (EqtTrace.IsErrorEnabled) { - testResult.AddCollectorDataEntries(collectorEntries); + EqtTrace.Error("Converter: UpdateTestResultAttachments: " + errorMsg); } + + StringBuilder stdErr = new(testResult.StdErr); + stdErr.AppendLine(errorMsg); + + testResult.StdErr = stdErr.ToString(); + testResult.Outcome = TrxObjectModel.TestOutcome.Error; } } - // Returns a list of collector entry - private CollectorDataEntry ToCollectorEntry(AttachmentSet attachmentSet, Guid testResultExecutionId, TestRun testRun, string trxFileDirectory) + if (addAttachments) { - string runDirectoryName = Path.Combine(trxFileDirectory, testRun.RunConfiguration.RunDeploymentRootDirectory); - string inDirectory = Path.Combine(runDirectoryName, "In"); - - string targetDirectory = inDirectory; - if (!testResultExecutionId.Equals(Guid.Empty)) + if (resultFiles.Count > 0) { - targetDirectory = Path.Combine(inDirectory, testResultExecutionId.ToString()); + testResult.AddResultFiles(resultFiles); } - targetDirectory = Path.Combine(targetDirectory, Environment.MachineName); - - if (!Directory.Exists(targetDirectory)) + if (collectorEntries.Count > 0) { - Directory.CreateDirectory(targetDirectory); + testResult.AddCollectorDataEntries(collectorEntries); } + } + } - List uriDataAttachments = new List(); - foreach (ObjectModel.UriDataAttachment uriDataAttachment in attachmentSet.Attachments) - { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("TrxLogger: ToCollectorEntry: Got attachment " + uriDataAttachment.Uri + " with description " + uriDataAttachment.Description); - } - - string sourceFile = uriDataAttachment.Uri.LocalPath; - - var rooted = (Path.GetFullPath(sourceFile) == sourceFile); - Debug.Assert(Path.IsPathRooted(sourceFile), "Source file is not rooted"); - - // copy the source file to the target location - string targetFileName = trxFileHelper.GetNextIterationFileName(targetDirectory, Path.GetFileName(sourceFile), false); - - try - { - CopyFile(sourceFile, targetFileName); + // Returns a list of collector entry + private CollectorDataEntry ToCollectorEntry(AttachmentSet attachmentSet, Guid testResultExecutionId, TestRun testRun, string trxFileDirectory) + { + string runDirectoryName = Path.Combine(trxFileDirectory, testRun.RunConfiguration.RunDeploymentRootDirectory); + string inDirectory = Path.Combine(runDirectoryName, "In"); - // Add the target file name to the collector files list. - // (Trx viewer automatically adds In\ to the collected file. - string fileName = Path.Combine(Environment.MachineName, Path.GetFileName(targetFileName)); - Uri sourceFileUri = new Uri(fileName, UriKind.Relative); - TrxObjectModel.UriDataAttachment dataAttachment = new TrxObjectModel.UriDataAttachment(uriDataAttachment.Description, sourceFileUri, trxFileHelper); + string targetDirectory = inDirectory; + if (!testResultExecutionId.Equals(Guid.Empty)) + { + targetDirectory = Path.Combine(inDirectory, testResultExecutionId.ToString()); + } - uriDataAttachments.Add(dataAttachment); - } - catch(Exception ex) - { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("Trxlogger: ToCollectorEntry: " + ex); - } - } - } + targetDirectory = Path.Combine(targetDirectory, Environment.MachineName); - return new CollectorDataEntry( - attachmentSet.Uri, - attachmentSet.DisplayName, - Environment.MachineName, - Environment.MachineName, - false, - uriDataAttachments); + if (!Directory.Exists(targetDirectory)) + { + Directory.CreateDirectory(targetDirectory); } - // Get the path to the result files - private IList ToResultFiles(AttachmentSet attachmentSet, Guid testResultExecutionId, TestRun testRun, string trxFileDirectory) + List uriDataAttachments = new(); + foreach (ObjectModel.UriDataAttachment uriDataAttachment in attachmentSet.Attachments) { - string runDirectoryName = Path.Combine(trxFileDirectory, testRun.RunConfiguration.RunDeploymentRootDirectory); - string testResultDirectory = Path.Combine(runDirectoryName, "In"); - - if (!Guid.Equals(testResultExecutionId, Guid.Empty)) + if (EqtTrace.IsVerboseEnabled) { - testResultDirectory = Path.Combine(testResultDirectory, testResultExecutionId.ToString()); + EqtTrace.Verbose("TrxLogger: ToCollectorEntry: Got attachment " + uriDataAttachment.Uri + " with description " + uriDataAttachment.Description); } - testResultDirectory = Path.Combine(testResultDirectory, Environment.MachineName); + string sourceFile = uriDataAttachment.Uri.LocalPath; + _ = (Path.GetFullPath(sourceFile) == sourceFile); + Debug.Assert(Path.IsPathRooted(sourceFile), "Source file is not rooted"); - if (!Directory.Exists(testResultDirectory)) - { - Directory.CreateDirectory(testResultDirectory); - } + // copy the source file to the target location + string targetFileName = _trxFileHelper.GetNextIterationFileName(targetDirectory, Path.GetFileName(sourceFile), false); - List resultFiles = new List(); - foreach (ObjectModel.UriDataAttachment uriDataAttachment in attachmentSet.Attachments) + try { - string sourceFile = uriDataAttachment.Uri.IsAbsoluteUri ? uriDataAttachment.Uri.LocalPath : uriDataAttachment.Uri.ToString(); + CopyFile(sourceFile, targetFileName); - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("TrxLogger: ToResultFiles: Got attachment " + uriDataAttachment.Uri + " with local path " + sourceFile); - } + // Add the target file name to the collector files list. + // (Trx viewer automatically adds In\ to the collected file. + string fileName = Path.Combine(Environment.MachineName, Path.GetFileName(targetFileName)); + Uri sourceFileUri = new(fileName, UriKind.Relative); + TrxObjectModel.UriDataAttachment dataAttachment = new(uriDataAttachment.Description, sourceFileUri, _trxFileHelper); - Debug.Assert(Path.IsPathRooted(sourceFile), "Source file is not rooted"); - // copy the source file to the target location - string targetFileName = trxFileHelper.GetNextIterationFileName(testResultDirectory, Path.GetFileName(sourceFile), false); - - try - { - CopyFile(sourceFile, targetFileName); - - // Add the target file name to the result files list. - // (Trx viewer automatically adds In\ to the result file. - string fileName = Path.Combine(Environment.MachineName, Path.GetFileName(targetFileName)); - resultFiles.Add(fileName); - } - catch(Exception ex) - { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("Trxlogger: ToResultFiles: " + ex); - } - } - } - - return resultFiles; - } - - private void CopyFile(string sourceFile, string targetFile) - { - try - { - this.fileHelper.CopyFile(sourceFile, targetFile); + uriDataAttachments.Add(dataAttachment); } catch (Exception ex) { if (EqtTrace.IsErrorEnabled) { - EqtTrace.Error("Trxlogger: Failed to copy file {0} to {1}. Reason:{2}", sourceFile, targetFile, ex); + EqtTrace.Error("Trxlogger: ToCollectorEntry: " + ex); } - - throw; } } - /// - /// Gets priority of test. - /// - /// - /// Priority - private int GetPriority(TestCase rockSteadyTestCase) - { - int priority = int.MaxValue; - - Trait priorityTrait = rockSteadyTestCase.Traits?.FirstOrDefault(t => t.Name.Equals("Priority")); - if (priorityTrait != null && int.TryParse(priorityTrait.Value, out int priorityValue)) - priority = priorityValue; + return new CollectorDataEntry( + attachmentSet.Uri, + attachmentSet.DisplayName, + Environment.MachineName, + Environment.MachineName, + false, + uriDataAttachments); + } - return priority; - } + // Get the path to the result files + private IList ToResultFiles(AttachmentSet attachmentSet, Guid testResultExecutionId, TestRun testRun, string trxFileDirectory) + { + string runDirectoryName = Path.Combine(trxFileDirectory, testRun.RunConfiguration.RunDeploymentRootDirectory); + string testResultDirectory = Path.Combine(runDirectoryName, "In"); - /// - /// Gets owner of test. - /// - /// - /// Owner - private string GetOwner(TestCase rockSteadyTestCase) + if (!Equals(testResultExecutionId, Guid.Empty)) { - string owner = null; + testResultDirectory = Path.Combine(testResultDirectory, testResultExecutionId.ToString()); + } - Trait ownerTrait = rockSteadyTestCase.Traits?.FirstOrDefault(t => t.Name.Equals("Owner")); - if (ownerTrait != null) - owner = ownerTrait.Value; + testResultDirectory = Path.Combine(testResultDirectory, Environment.MachineName); - return owner ?? string.Empty; + if (!Directory.Exists(testResultDirectory)) + { + Directory.CreateDirectory(testResultDirectory); } - /// - /// Gets test class name. - /// - /// Test name. - /// Fully qualified name. - /// Source. - /// Test class name. - private string GetTestClassName(string testName, string fullyQualifiedName, string source) + List resultFiles = new(); + foreach (ObjectModel.UriDataAttachment uriDataAttachment in attachmentSet.Attachments) { - var className = "DefaultClassName"; + string sourceFile = uriDataAttachment.Uri.IsAbsoluteUri ? uriDataAttachment.Uri.LocalPath : uriDataAttachment.Uri.ToString(); - // In case, fullyQualifiedName ends with testName, className is checked within remaining value of fullyQualifiedName. - // Example: In case, testName = TestMethod1(2, 3, 4.0d) and fullyQualifiedName = TestProject1.Class1.TestMethod1(2, 3, 4.0d), className will be checked within 'TestProject1.Class1.' only - var nameToCheck = !fullyQualifiedName.Equals(testName, StringComparison.OrdinalIgnoreCase) && fullyQualifiedName.EndsWith(testName) ? - fullyQualifiedName.Substring(0, fullyQualifiedName.Length - testName.Length) : - fullyQualifiedName; - - // C# test case scenario. - if (nameToCheck.Contains(".")) + if (EqtTrace.IsVerboseEnabled) { - return nameToCheck.Substring(0, nameToCheck.LastIndexOf('.')); + EqtTrace.Verbose("TrxLogger: ToResultFiles: Got attachment " + uriDataAttachment.Uri + " with local path " + sourceFile); } - // C++ test case scenario (we would have a "::" instead of a '.') - if (nameToCheck.Contains("::")) + Debug.Assert(Path.IsPathRooted(sourceFile), "Source file is not rooted"); + // copy the source file to the target location + string targetFileName = _trxFileHelper.GetNextIterationFileName(testResultDirectory, Path.GetFileName(sourceFile), false); + + try { - className = nameToCheck.Substring(0, nameToCheck.LastIndexOf("::")); + CopyFile(sourceFile, targetFileName); - // rename for a consistent behavior for all tests. - return className.Replace("::", "."); + // Add the target file name to the result files list. + // (Trx viewer automatically adds In\ to the result file. + string fileName = Path.Combine(Environment.MachineName, Path.GetFileName(targetFileName)); + resultFiles.Add(fileName); } - - // Ordered test, web test scenario (Setting class name as source name if FQDn doesn't have . or ::) - try + catch (Exception ex) { - string testCaseSource = Path.GetFileNameWithoutExtension(source); - if (!string.IsNullOrEmpty(testCaseSource)) + if (EqtTrace.IsErrorEnabled) { - return testCaseSource; + EqtTrace.Error("Trxlogger: ToResultFiles: " + ex); } } - catch (ArgumentException ex) + } + + return resultFiles; + } + + private void CopyFile(string sourceFile, string targetFile) + { + try + { + _fileHelper.CopyFile(sourceFile, targetFile); + } + catch (Exception ex) + { + if (EqtTrace.IsErrorEnabled) { - // If source is not valid file path, then className will continue to point default value. - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("Converter: GetTestClassName: " + ex); - } + EqtTrace.Error("Trxlogger: Failed to copy file {0} to {1}. Reason:{2}", sourceFile, targetFile, ex); } - return className; + throw; } + } - /// - /// Create test element. - /// Currently trx supports only UnitTest and OrderedTest. All tests except OrderedTest all converted to UnitTest. - /// - /// - /// - /// - /// - /// - /// - /// Trx test element - private TestElement CreateTestElement(Guid testId, string name, string fullyQualifiedName, string adapter, string source, TestType testType) + /// + /// Gets priority of test. + /// + /// + /// Priority + private int GetPriority(TestCase rockSteadyTestCase) + { + int priority = int.MaxValue; + + Trait priorityTrait = rockSteadyTestCase.Traits?.FirstOrDefault(t => t.Name.Equals("Priority")); + if (priorityTrait != null && int.TryParse(priorityTrait.Value, out int priorityValue)) + priority = priorityValue; + + return priority; + } + + /// + /// Gets owner of test. + /// + /// + /// Owner + private string GetOwner(TestCase rockSteadyTestCase) + { + string owner = null; + + Trait ownerTrait = rockSteadyTestCase.Traits?.FirstOrDefault(t => t.Name.Equals("Owner")); + if (ownerTrait != null) + owner = ownerTrait.Value; + + return owner ?? string.Empty; + } + + /// + /// Gets test class name. + /// + /// Test name. + /// Fully qualified name. + /// Source. + /// Test class name. + private string GetTestClassName(string testName, string fullyQualifiedName, string source) + { + var className = "DefaultClassName"; + + // In case, fullyQualifiedName ends with testName, className is checked within remaining value of fullyQualifiedName. + // Example: In case, testName = TestMethod1(2, 3, 4.0d) and fullyQualifiedName = TestProject1.Class1.TestMethod1(2, 3, 4.0d), className will be checked within 'TestProject1.Class1.' only + var nameToCheck = !fullyQualifiedName.Equals(testName, StringComparison.OrdinalIgnoreCase) && fullyQualifiedName.EndsWith(testName) ? + fullyQualifiedName.Substring(0, fullyQualifiedName.Length - testName.Length) : + fullyQualifiedName; + + // C# test case scenario. + if (nameToCheck.Contains(".")) { - TestElement testElement = null; + return nameToCheck.Substring(0, nameToCheck.LastIndexOf('.')); + } - if (testType.Equals(Constants.OrderedTestType)) + // C++ test case scenario (we would have a "::" instead of a '.') + if (nameToCheck.Contains("::")) + { + className = nameToCheck.Substring(0, nameToCheck.LastIndexOf("::")); + + // rename for a consistent behavior for all tests. + return className.Replace("::", "."); + } + + // Ordered test, web test scenario (Setting class name as source name if FQDn doesn't have . or ::) + try + { + string testCaseSource = Path.GetFileNameWithoutExtension(source); + if (!string.IsNullOrEmpty(testCaseSource)) { - testElement = new OrderedTestElement(testId, name, adapter); + return testCaseSource; } - else + } + catch (ArgumentException ex) + { + // If source is not valid file path, then className will continue to point default value. + if (EqtTrace.IsVerboseEnabled) { - var codeBase = source; - var className = GetTestClassName(name, fullyQualifiedName, source); - var testMethodName = fullyQualifiedName.StartsWith($"{className}.") ? fullyQualifiedName.Remove(0, $"{className}.".Length) : fullyQualifiedName; - var testMethod = new TestMethod(testMethodName, className); - - testElement = new UnitTestElement(testId, name, adapter, testMethod); - (testElement as UnitTestElement).CodeBase = codeBase; + EqtTrace.Verbose("Converter: GetTestClassName: " + ex); } - - return testElement; } - /// - /// Create test result. - /// Currently trx supports only UnitTest and OrderedTest. All tests except OrderedTest all converted to unit test result. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// Trx test result - private TrxObjectModel.TestResult CreateTestResult( - Guid runId, - Guid testId, - Guid executionId, - Guid parentExecutionId, - string resultName, - TrxObjectModel.TestOutcome outcome, - TestType testType, - TestListCategoryId testCategoryId) + return className; + } + + /// + /// Create test element. + /// Currently trx supports only UnitTest and OrderedTest. All tests except OrderedTest all converted to UnitTest. + /// + /// + /// + /// + /// + /// + /// + /// Trx test element + private TestElement CreateTestElement(Guid testId, string name, string fullyQualifiedName, string adapter, string source, TestType testType) + { + TestElement testElement; + if (testType.Equals(Constants.OrderedTestType)) { - return testType.Equals(Constants.OrderedTestType) ? - new TestResultAggregation(runId, testId, executionId, parentExecutionId, resultName, Environment.MachineName, outcome, testType, testCategoryId, trxFileHelper) : - new UnitTestResult(runId, testId, executionId, parentExecutionId, resultName, Environment.MachineName, outcome, testType, testCategoryId, trxFileHelper); + testElement = new OrderedTestElement(testId, name, adapter); } + else + { + var codeBase = source; + var className = GetTestClassName(name, fullyQualifiedName, source); + var testMethodName = fullyQualifiedName.StartsWith($"{className}.") ? fullyQualifiedName.Remove(0, $"{className}.".Length) : fullyQualifiedName; + var testMethod = new TestMethod(testMethodName, className); + + testElement = new UnitTestElement(testId, name, adapter, testMethod); + (testElement as UnitTestElement).CodeBase = codeBase; + } + + return testElement; + } + + /// + /// Create test result. + /// Currently trx supports only UnitTest and OrderedTest. All tests except OrderedTest all converted to unit test result. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Trx test result + private TrxObjectModel.TestResult CreateTestResult( + Guid runId, + Guid testId, + Guid executionId, + Guid parentExecutionId, + string resultName, + TrxObjectModel.TestOutcome outcome, + TestType testType, + TestListCategoryId testCategoryId) + { + return testType.Equals(Constants.OrderedTestType) ? + new TestResultAggregation(runId, testId, executionId, parentExecutionId, resultName, Environment.MachineName, outcome, testType, testCategoryId, _trxFileHelper) : + new UnitTestResult(runId, testId, executionId, parentExecutionId, resultName, Environment.MachineName, outcome, testType, testCategoryId, _trxFileHelper); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/EqtAssert.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/EqtAssert.cs index 718d891574..1cae901cbd 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/EqtAssert.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/EqtAssert.cs @@ -1,78 +1,77 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.Utility -{ - using System; - using System.Diagnostics; - using System.Globalization; +namespace Microsoft.TestPlatform.Extensions.TrxLogger.Utility; + +using System; +using System.Diagnostics; +using System.Globalization; - using TrxLoggerResources = Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.Resources.TrxResource; +using TrxLoggerResources = VisualStudio.TestPlatform.Extensions.TrxLogger.Resources.TrxResource; +/// +/// Class to be used for parameter verification. +/// +internal sealed class EqtAssert +{ /// - /// Class to be used for parameter verification. + /// Do not instantiate. /// - internal sealed class EqtAssert + private EqtAssert() { - /// - /// Do not instantiate. - /// - private EqtAssert() - { - } + } - /// - /// Verifies that the specified parameter is not null, Debug.Asserts and throws. - /// - /// Expression to check - /// Comment to write - public static void IsTrue(bool expression, string comment) + /// + /// Verifies that the specified parameter is not null, Debug.Asserts and throws. + /// + /// Expression to check + /// Comment to write + public static void IsTrue(bool expression, string comment) + { + Debug.Assert(expression, comment); + if (!expression) { - Debug.Assert(expression, comment); - if (!expression) - { - throw new Exception(comment); - } + throw new Exception(comment); } + } - /// - /// Verifies that the specified parameter is not null, Debug.Asserts and throws. - /// - /// Parameter to check - /// String - parameter name - public static void ParameterNotNull(object parameter, string parameterName) + /// + /// Verifies that the specified parameter is not null, Debug.Asserts and throws. + /// + /// Parameter to check + /// String - parameter name + public static void ParameterNotNull(object parameter, string parameterName) + { + AssertParameterNameNotNullOrEmpty(parameterName); + Debug.Assert(parameter != null, string.Format(CultureInfo.InvariantCulture, "'{0}' is null", parameterName)); + if (parameter == null) { - AssertParameterNameNotNullOrEmpty(parameterName); - Debug.Assert(parameter != null, string.Format(CultureInfo.InvariantCulture, "'{0}' is null", parameterName)); - if (parameter == null) - { - throw new ArgumentNullException(parameterName); - } + throw new ArgumentNullException(parameterName); } + } - /// - /// Verifies that the specified string parameter is neither null nor empty, Debug.Asserts and throws. - /// - /// Parameter to check - /// String - parameter name - public static void StringNotNullOrEmpty(string parameter, string parameterName) + /// + /// Verifies that the specified string parameter is neither null nor empty, Debug.Asserts and throws. + /// + /// Parameter to check + /// String - parameter name + public static void StringNotNullOrEmpty(string parameter, string parameterName) + { + AssertParameterNameNotNullOrEmpty(parameterName); + Debug.Assert(!string.IsNullOrEmpty(parameter), string.Format(CultureInfo.InvariantCulture, "'{0}' is null or empty", parameterName)); + if (string.IsNullOrEmpty(parameter)) { - AssertParameterNameNotNullOrEmpty(parameterName); - Debug.Assert(!string.IsNullOrEmpty(parameter), string.Format(CultureInfo.InvariantCulture, "'{0}' is null or empty", parameterName)); - if (string.IsNullOrEmpty(parameter)) - { - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, TrxLoggerResources.Common_CannotBeNullOrEmpty)); - } + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, TrxLoggerResources.Common_CannotBeNullOrEmpty)); } + } - /// - /// Asserts that the parameter name is not null or empty - /// - /// The parameter name to verify - [Conditional("DEBUG")] - private static void AssertParameterNameNotNullOrEmpty(string parameterName) - { - Debug.Assert(!string.IsNullOrEmpty(parameterName), "'parameterName' is null or empty"); - } + /// + /// Asserts that the parameter name is not null or empty + /// + /// The parameter name to verify + [Conditional("DEBUG")] + private static void AssertParameterNameNotNullOrEmpty(string parameterName) + { + Debug.Assert(!string.IsNullOrEmpty(parameterName), "'parameterName' is null or empty"); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/TestRunDirectories.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/TestRunDirectories.cs index b76cf3ab2c..6b1f7e339c 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/TestRunDirectories.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/TestRunDirectories.cs @@ -1,25 +1,24 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.Utility -{ - using System; +namespace Microsoft.TestPlatform.Extensions.TrxLogger.Utility; + +using System; +/// +/// Class to deal with directories. +/// +internal sealed class TestRunDirectories +{ /// - /// Class to deal with directories. + /// Computes the test results directory, relative to the root results directory (whatever that may be) /// - internal sealed class TestRunDirectories + /// The test's execution ID + /// + /// The test results directory (<testExecutionId>), under which test-specific result files should be stored + /// + public static string GetRelativeTestResultsDirectory(Guid testExecutionId) { - /// - /// Computes the test results directory, relative to the root results directory (whatever that may be) - /// - /// The test's execution ID - /// - /// The test results directory (<testExecutionId>), under which test-specific result files should be stored - /// - public static string GetRelativeTestResultsDirectory(Guid testExecutionId) - { - return testExecutionId.ToString(); - } + return testExecutionId.ToString(); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/TrxFileHelper.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/TrxFileHelper.cs index e1a0fadd6f..4bebd1bd66 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/TrxFileHelper.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/TrxFileHelper.cs @@ -1,417 +1,402 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.Utility +namespace Microsoft.TestPlatform.Extensions.TrxLogger.Utility; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; + +using TrxLoggerResources = VisualStudio.TestPlatform.Extensions.TrxLogger.Resources.TrxResource; + +/// +/// Helper function to deal with file name. +/// +internal class TrxFileHelper + { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Diagnostics.CodeAnalysis; - using System.Globalization; - using System.IO; - using System.Text; - using System.Text.RegularExpressions; - using TrxLoggerResources = Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.Resources.TrxResource; + private const string RelativeDirectorySeparator = ".."; - /// - /// Helper function to deal with file name. - /// - internal class TrxFileHelper + private static readonly HashSet InvalidFileNameChars; + private static readonly Regex ReservedFileNamesRegex = new(@"(?i:^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9]|CLOCK\$)(\..*)?)$"); + private readonly Func _timeProvider; + + #region Constructors + + // Have to init InvalidFileNameChars dynamically. + static TrxFileHelper() + { + // Create a hash table of invalid chars. On Windows, this should match the contents of System.IO.Path.GetInvalidFileNameChars. + // See https://github.com/dotnet/coreclr/blob/8e99cd8031b2f568ea69116e7cf96d55e32cb7f5/src/mscorlib/shared/System/IO/Path.Windows.cs#L12-L19 + // These are manually listed here to avoid characters that may be valid on Linux but would make a filename invalid when copying the file to Windows. + // Path.GetInvalidFileNameChars on Linux only contains { \0, / } + InvalidFileNameChars = new HashSet + { + '\"', '<', '>', '|', '\0', + (char)1, (char)2, (char)3, (char)4, (char)5, (char)6, (char)7, (char)8, (char)9, (char)10, + (char)11, (char)12, (char)13, (char)14, (char)15, (char)16, (char)17, (char)18, (char)19, (char)20, + (char)21, (char)22, (char)23, (char)24, (char)25, (char)26, (char)27, (char)28, (char)29, (char)30, + (char)31, ':', '*', '?', '\\', '/' + }; + + // Needed because when kicking off qtsetup.bat cmd.exe is used. '@' is a special character + // for cmd so must be removed from the path to the bat file + InvalidFileNameChars.Add('@'); + InvalidFileNameChars.Add('('); + InvalidFileNameChars.Add(')'); + InvalidFileNameChars.Add('^'); + + // Replace white space with underscore from folder/file name to make it command line friendly + // Related issues https://github.com/Microsoft/vstest/issues/244 & https://devdiv.visualstudio.com/DevDiv/_workitems?id=507982&_a=edit + InvalidFileNameChars.Add(' '); + } + + public TrxFileHelper() : this(() => DateTime.Now) { } + public TrxFileHelper(Func timeProvider) { - private const string RelativeDirectorySeparator = ".."; + _timeProvider = timeProvider ?? (() => DateTime.Now); + } - private static readonly HashSet InvalidFileNameChars; - private static readonly Regex ReservedFileNamesRegex = new Regex(@"(?i:^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9]|CLOCK\$)(\..*)?)$"); - private readonly Func TimeProvider; + #endregion - #region Constructors - [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline", Justification = "Reviewed. Suppression is OK here.")] + /// + /// Replaces invalid file name chars in the specified string and changes it if it is a reserved file name. + /// + /// the name of the file + /// Replaced string. + public string ReplaceInvalidFileNameChars(string fileName) + { + EqtAssert.StringNotNullOrEmpty(fileName, nameof(fileName)); - // Have to init InvalidFileNameChars dynamically. - static TrxFileHelper() + // Replace bad chars by this. + char replacementChar = '_'; + StringBuilder result = new(fileName.Length); + result.Length = fileName.Length; + + // Replace each invalid char with replacement char. + for (int i = 0; i < fileName.Length; ++i) { - // Create a hash table of invalid chars. On Windows, this should match the contents of System.IO.Path.GetInvalidFileNameChars. - // See https://github.com/dotnet/coreclr/blob/8e99cd8031b2f568ea69116e7cf96d55e32cb7f5/src/mscorlib/shared/System/IO/Path.Windows.cs#L12-L19 - // These are manually listed here to avoid characters that may be valid on Linux but would make a filename invalid when copying the file to Windows. - // Path.GetInvalidFileNameChars on Linux only contains { \0, / } - InvalidFileNameChars = new HashSet - { - '\"', '<', '>', '|', '\0', - (char)1, (char)2, (char)3, (char)4, (char)5, (char)6, (char)7, (char)8, (char)9, (char)10, - (char)11, (char)12, (char)13, (char)14, (char)15, (char)16, (char)17, (char)18, (char)19, (char)20, - (char)21, (char)22, (char)23, (char)24, (char)25, (char)26, (char)27, (char)28, (char)29, (char)30, - (char)31, ':', '*', '?', '\\', '/' - }; - - // Needed because when kicking off qtsetup.bat cmd.exe is used. '@' is a special character - // for cmd so must be removed from the path to the bat file - InvalidFileNameChars.Add('@'); - InvalidFileNameChars.Add('('); - InvalidFileNameChars.Add(')'); - InvalidFileNameChars.Add('^'); - - // Replace white space with underscore from folder/file name to make it command line friendly - // Related issues https://github.com/Microsoft/vstest/issues/244 & https://devdiv.visualstudio.com/DevDiv/_workitems?id=507982&_a=edit - InvalidFileNameChars.Add(' '); + result[i] = InvalidFileNameChars.Contains(fileName[i]) ? replacementChar : fileName[i]; } - public TrxFileHelper() : this(() => DateTime.Now) { } + // We trim spaces in the end because CreateFile/Dir trim those. + string replaced = result.ToString().TrimEnd(); + if (replaced.Length == 0) + { + Debug.Fail(string.Format(CultureInfo.InvariantCulture, "After replacing invalid chars in file '{0}' there's nothing left...", fileName)); + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, TrxLoggerResources.Common_NothingLeftAfterReplaciingBadCharsInName, fileName)); + } - public TrxFileHelper(Func timeProvider) + if (IsReservedFileName(replaced)) { - TimeProvider = timeProvider ?? (() => DateTime.Now); + replaced = replacementChar + replaced; // Cannot add to the end because it can have extensions. } - #endregion + return replaced; + } - /// - /// Replaces invalid file name chars in the specified string and changes it if it is a reserved file name. - /// - /// the name of the file - /// Replaced string. - public string ReplaceInvalidFileNameChars(string fileName) + /// + /// Checks whether file with specified name exists in the specified directory. + /// If it exits, adds (1),(2)... to the file name and checks again. + /// Returns full file name (with path) of the iteration when the file does not exist. + /// + /// + /// The directory where to check. + /// + /// + /// The original file (that we would add (1),(2),.. in the end of if needed) name to check. + /// + /// + /// If true, and directory with filename without extension exists, try next iteration. + /// + /// + /// The . + /// + public string GetNextIterationFileName(string parentDirectoryName, string originalFileName, bool checkMatchingDirectory) + { + EqtAssert.StringNotNullOrEmpty(parentDirectoryName, nameof(parentDirectoryName)); + EqtAssert.StringNotNullOrEmpty(originalFileName, nameof(originalFileName)); + return GetNextIterationNameHelper(parentDirectoryName, originalFileName, new FileIterationHelper(checkMatchingDirectory)); + } + + /// + /// Constructs and returns first available timestamped file name. + /// This does not checks for the file permissions. + /// + /// Directory to try timestamped file names in. + /// Filename (with extension) of the desired file. Timestamp will be added just before extension. + /// Timestamp format to be passed into DateTime.ToString method. + /// First available filename with the format of `FileName{Timestamp}.ext`. + /// + /// GetNextTimestampFileName("c:\data", "log.txt", "_yyyyMMddHHmmss") will return "c:\data\log_20200801185521.txt", if available. + /// + public string GetNextTimestampFileName(string directoryName, string fileName, string timestampFormat) + { + EqtAssert.StringNotNullOrEmpty(directoryName, "parentDirectoryName"); + EqtAssert.StringNotNullOrEmpty(fileName, nameof(fileName)); + EqtAssert.StringNotNullOrEmpty(timestampFormat, nameof(timestampFormat)); + + ushort iteration = 0; + var iterationStamp = _timeProvider(); + var fileNamePrefix = Path.GetFileNameWithoutExtension(fileName); + var extension = Path.GetExtension(fileName); + do { - EqtAssert.StringNotNullOrEmpty(fileName, nameof(fileName)); + var tryMe = fileNamePrefix + iterationStamp.ToString(timestampFormat, DateTimeFormatInfo.InvariantInfo) + extension; - // Replace bad chars by this. - char replacementChar = '_'; - StringBuilder result = new StringBuilder(fileName.Length); - result.Length = fileName.Length; + string tryMePath = Path.Combine(directoryName, tryMe); - // Replace each invalid char with replacement char. - for (int i = 0; i < fileName.Length; ++i) + if (!File.Exists(tryMePath)) { - if (InvalidFileNameChars.Contains(fileName[i])) - { - result[i] = replacementChar; - } - else - { - result[i] = fileName[i]; - } + return tryMePath; } - // We trim spaces in the end because CreateFile/Dir trim those. - string replaced = result.ToString().TrimEnd(); - if (replaced.Length == 0) - { - Debug.Fail(string.Format(CultureInfo.InvariantCulture, "After replacing invalid chars in file '{0}' there's nothing left...", fileName)); - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, TrxLoggerResources.Common_NothingLeftAfterReplaciingBadCharsInName, fileName)); - } + iterationStamp = iterationStamp.AddSeconds(1); + ++iteration; + } + while (iteration != ushort.MaxValue); - if (IsReservedFileName(replaced)) - { - replaced = replacementChar + replaced; // Cannot add to the end because it can have extensions. - } + throw new Exception(string.Format(CultureInfo.CurrentCulture, TrxLoggerResources.Common_CannotGetNextTimestampFileName, fileName, directoryName, timestampFormat)); + } - return replaced; - } + public string MakePathRelative(string path, string basePath) + { + EqtAssert.StringNotNullOrEmpty(path, nameof(path)); - /// - /// Checks whether file with specified name exists in the specified directory. - /// If it exits, adds (1),(2)... to the file name and checks again. - /// Returns full file name (with path) of the iteration when the file does not exist. - /// - /// - /// The directory where to check. - /// - /// - /// The original file (that we would add (1),(2),.. in the end of if needed) name to check. - /// - /// - /// If true, and directory with filename without extension exists, try next iteration. - /// - /// - /// The . - /// - public string GetNextIterationFileName(string parentDirectoryName, string originalFileName, bool checkMatchingDirectory) + // Can't be relative to nothing + if (string.IsNullOrEmpty(basePath)) { - EqtAssert.StringNotNullOrEmpty(parentDirectoryName, nameof(parentDirectoryName)); - EqtAssert.StringNotNullOrEmpty(originalFileName, nameof(originalFileName)); - return GetNextIterationNameHelper(parentDirectoryName, originalFileName, new FileIterationHelper(checkMatchingDirectory)); + return path; } - /// - /// Constructs and returns first available timestamped file name. - /// This does not checks for the file permissions. - /// - /// Directory to try timestamped file names in. - /// Filename (with extension) of the desired file. Timestamp will be added just before extension. - /// Timestamp format to be passed into DateTime.ToString method. - /// First available filename with the format of `FileName{Timestamp}.ext`. - /// - /// GetNextTimestampFileName("c:\data", "log.txt", "_yyyyMMddHHmmss") will return "c:\data\log_20200801185521.txt", if available. - /// - public string GetNextTimestampFileName(string directoryName, string fileName, string timestampFormat) + // Canonicalize those paths: + + if (!Path.IsPathRooted(path)) { - EqtAssert.StringNotNullOrEmpty(directoryName, "parentDirectoryName"); - EqtAssert.StringNotNullOrEmpty(fileName, nameof(fileName)); - EqtAssert.StringNotNullOrEmpty(timestampFormat, nameof(timestampFormat)); - - ushort iteration = 0; - var iterationStamp = TimeProvider(); - var fileNamePrefix = Path.GetFileNameWithoutExtension(fileName); - var extension = Path.GetExtension(fileName); - do - { - var tryMe = fileNamePrefix + iterationStamp.ToString(timestampFormat, DateTimeFormatInfo.InvariantInfo) + extension; + //If path is relative, we combine it with base path before canonicalizing. + //Else Path.GetFullPath is going to use the process worker directory (e.g. e:\binariesy.x86\bin\i386). + path = Path.Combine(basePath, path); + } + path = Path.GetFullPath(path); + basePath = Path.GetFullPath(basePath); - string tryMePath = Path.Combine(directoryName, tryMe); + char[] delimiters = new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }; - if (!File.Exists(tryMePath)) - { - return tryMePath; - } + basePath = basePath.TrimEnd(delimiters); + path = path.TrimEnd(delimiters); - iterationStamp = iterationStamp.AddSeconds(1); - ++iteration; - } - while (iteration != ushort.MaxValue); + string[] pathTokens = path.Split(delimiters); + string[] basePathTokens = basePath.Split(delimiters); - throw new Exception(string.Format(CultureInfo.CurrentCulture, TrxLoggerResources.Common_CannotGetNextTimestampFileName, fileName, directoryName, timestampFormat)); - } + Debug.Assert(pathTokens.Length > 0 && basePathTokens.Length > 0); + int max = Math.Min(pathTokens.Length, basePathTokens.Length); - public string MakePathRelative(string path, string basePath) + // Skip all of the empty tokens that result from things like "\dir1" + // and "\\dir1". We need to compare the first non-null token + // to know if we've got differences. + int i; + for (i = 0; i < max && pathTokens[i].Length == 0 && basePathTokens[i].Length == 0; i++) { - EqtAssert.StringNotNullOrEmpty(path, nameof(path)); + } - // Can't be relative to nothing - if (string.IsNullOrEmpty(basePath)) - { - return path; - } + if (i >= max) + { + // At least one of these strings is too short to work with + return path; + } - // Canonicalize those paths: + if (!pathTokens[i].Equals(basePathTokens[i], StringComparison.OrdinalIgnoreCase)) + { + // These differ from the very start - just return the original path + return path; + } - if (!Path.IsPathRooted(path)) + for (++i; i < max; i++) + { + if (!pathTokens[i].Equals(basePathTokens[i], StringComparison.OrdinalIgnoreCase)) { - //If path is relative, we combine it with base path before canonicalizing. - //Else Path.GetFullPath is going to use the process worker directory (e.g. e:\binariesy.x86\bin\i386). - path = Path.Combine(basePath, path); + // We've found a non-matching token + break; } - path = Path.GetFullPath(path); - basePath = Path.GetFullPath(basePath); - - char[] delimiters = new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }; - - basePath = basePath.TrimEnd(delimiters); - path = path.TrimEnd(delimiters); + } - string[] pathTokens = path.Split(delimiters); - string[] basePathTokens = basePath.Split(delimiters); + // i should point to first non-matching token. - Debug.Assert(pathTokens.Length > 0 && basePathTokens.Length > 0); - int max = Math.Min(pathTokens.Length, basePathTokens.Length); + StringBuilder newPath = new(); - // Skip all of the empty tokens that result from things like "\dir1" - // and "\\dir1". We need to compare the first non-null token - // to know if we've got differences. - int i = 0; - for (i = 0; i < max && pathTokens[i].Length == 0 && basePathTokens[i].Length == 0; i++) + // ok, for each remaining token in the base path, + // add ..\ to the string. + for (int j = i; j < basePathTokens.Length; j++) + { + if (newPath.Length > 0) { + newPath.Append(Path.DirectorySeparatorChar); } + newPath.Append(RelativeDirectorySeparator); + } - if (i >= max) - { - // At least one of these strings is too short to work with - return path; - } + // And now, for every remaining token in the path, + // add it to the string, separated by the directory + // separator. - if (!pathTokens[i].Equals(basePathTokens[i], StringComparison.OrdinalIgnoreCase)) + for (int j = i; j < pathTokens.Length; j++) + { + if (newPath.Length > 0) { - // These differ from the very start - just return the original path - return path; + newPath.Append(Path.DirectorySeparatorChar); } + newPath.Append(pathTokens[j]); + } - for (++i; i < max; i++) - { - if (!pathTokens[i].Equals(basePathTokens[i], StringComparison.OrdinalIgnoreCase)) - { - // We've found a non-matching token - break; - } - } + return newPath.ToString(); + } - // i should point to first non-matching token. + /// + /// Returns true if the file name specified is Windows reserved file name. + /// + /// + /// The name of the file. Note: only a file name, does not expect to contain directory separators. + /// + /// + /// The True if yes else False. + /// + private static bool IsReservedFileName(string fileName) + { + Debug.Assert(!string.IsNullOrEmpty(fileName), "FileHelper.IsReservedFileName: the argument is null or empty string!"); + if (string.IsNullOrEmpty(fileName)) + { + return false; + } - StringBuilder newPath = new StringBuilder(); + // CreateFile: + // The following reserved device names cannot be used as the name of a file: + // CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, + // LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. + // Also avoid these names followed by an extension, for example, NUL.tx7. + // Windows NT: CLOCK$ is also a reserved device name. + return ReservedFileNamesRegex.Match(fileName).Success; + } - // ok, for each remaining token in the base path, - // add ..\ to the string. - for (int j = i; j < basePathTokens.Length; j++) - { - if (newPath.Length > 0) - { - newPath.Append(Path.DirectorySeparatorChar); - } - newPath.Append(RelativeDirectorySeparator); - } + /// + /// Helper to get next iteration (1),(2),.. names. + /// Note that we don't check for security permissions: + /// If the file exists and you have access to the dir you will get File.Exist = true + /// If the file exists and you don't have access to the dir, you will not be able to create the file anyway. + /// Result.trx -> Result(1).trx, Result(2).trx, etc. + /// + /// + /// Base directory to try iteration in. + /// + /// + /// The name to start the iterations from. + /// + /// + /// An instance of IterationHelper. + /// + /// + /// Next valid iteration name. + /// + private static string GetNextIterationNameHelper( + string baseDirectoryName, + string originalName, + IterationHelper helper) + { + Debug.Assert(!string.IsNullOrEmpty(baseDirectoryName), "baseDirectoryname is null"); + Debug.Assert(!string.IsNullOrEmpty(originalName), "originalName is Null"); + Debug.Assert(helper != null, "helper is null"); - // And now, for every remaining token in the path, - // add it to the string, separated by the directory - // separator. + uint iteration = 0; + do + { + var tryMe = iteration == 0 ? originalName : helper.NextIteration(originalName, iteration); - for (int j = i; j < pathTokens.Length; j++) + string tryMePath = Path.Combine(baseDirectoryName, tryMe); + if (helper.IsValidIteration(tryMePath)) { - if (newPath.Length > 0) - { - newPath.Append(Path.DirectorySeparatorChar); - } - newPath.Append(pathTokens[j]); + return tryMePath; } - return newPath.ToString(); + ++iteration; } + while (iteration != uint.MaxValue); - /// - /// Returns true if the file name specified is Windows reserved file name. - /// - /// - /// The name of the file. Note: only a file name, does not expect to contain directory separators. - /// - /// - /// The True if yes else False. - /// - private static bool IsReservedFileName(string fileName) - { - Debug.Assert(!string.IsNullOrEmpty(fileName), "FileHelper.IsReservedFileName: the argument is null or empty string!"); - if (string.IsNullOrEmpty(fileName)) - { - return false; - } - - // CreateFile: - // The following reserved device names cannot be used as the name of a file: - // CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, - // LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. - // Also avoid these names followed by an extension, for example, NUL.tx7. - // Windows NT: CLOCK$ is also a reserved device name. - return ReservedFileNamesRegex.Match(fileName).Success; - } + throw new Exception(string.Format(CultureInfo.CurrentCulture, TrxLoggerResources.Common_CannotGetNextIterationName, originalName, baseDirectoryName)); + } + private abstract class IterationHelper + { /// - /// Helper to get next iteration (1),(2),.. names. - /// Note that we don't check for security permissions: - /// If the file exists and you have access to the dir you will get File.Exist = true - /// If the file exists and you don't have access to the dir, you will not be able to create the file anyway. - /// Result.trx -> Result(1).trx, Result(2).trx, etc. + /// Formats iteration like baseName[1]. /// - /// - /// Base directory to try iteration in. + /// + /// Base name for the iteration. /// - /// - /// The name to start the iterations from. - /// - /// - /// An instance of IterationHelper. + /// + /// The iteration number /// /// - /// Next valid iteration name. + /// The formatted string. /// - [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is OK here.")] - private static string GetNextIterationNameHelper( - string baseDirectoryName, - string originalName, - IterationHelper helper) + internal static string FormatIteration(string baseName, uint iteration) { - Debug.Assert(!string.IsNullOrEmpty(baseDirectoryName), "baseDirectoryname is null"); - Debug.Assert(!string.IsNullOrEmpty(originalName), "originalName is Null"); - Debug.Assert(helper != null, "helper is null"); + Debug.Assert(!string.IsNullOrEmpty(baseName), "basename is null"); + + var tryMe = string.Format( + CultureInfo.InvariantCulture, + "{0}[{1}]", + baseName, + iteration.ToString(CultureInfo.InvariantCulture)); + return tryMe; + } - uint iteration = 0; - do - { - var tryMe = iteration == 0 ? originalName : helper.NextIteration(originalName, iteration); + internal abstract string NextIteration(string baseName, uint iteration); - string tryMePath = Path.Combine(baseDirectoryName, tryMe); - if (helper.IsValidIteration(tryMePath)) - { - return tryMePath; - } + internal abstract bool IsValidIteration(string name); + } - ++iteration; - } - while (iteration != uint.MaxValue); + private class FileIterationHelper : IterationHelper + { + private readonly bool _checkMatchingDirectory; - throw new Exception(string.Format(CultureInfo.CurrentCulture, TrxLoggerResources.Common_CannotGetNextIterationName, originalName, baseDirectoryName)); + /// + /// Constructor for class checkMatchingDirectory. + /// + /// If true, and directory with filename without extension exists, try next iteration. + internal FileIterationHelper(bool checkMatchingDirectory) + { + _checkMatchingDirectory = checkMatchingDirectory; } - private abstract class IterationHelper + internal override string NextIteration(string baseName, uint iteration) { - /// - /// Formats iteration like baseName[1]. - /// - /// - /// Base name for the iteration. - /// - /// - /// The iteration number - /// - /// - /// The formatted string. - /// - internal static string FormatIteration(string baseName, uint iteration) + Debug.Assert(!string.IsNullOrEmpty(baseName), "baseName is null"); + + string withoutExtensionName = Path.GetFileNameWithoutExtension(baseName); + string tryMe = FormatIteration(withoutExtensionName, iteration); + if (Path.HasExtension(baseName)) { - Debug.Assert(!string.IsNullOrEmpty(baseName), "basename is null"); - - var tryMe = string.Format( - CultureInfo.InvariantCulture, - "{0}[{1}]", - baseName, - iteration.ToString(CultureInfo.InvariantCulture)); - return tryMe; + tryMe += Path.GetExtension(baseName); // Path.GetExtension already returns the leading ".". } - internal abstract string NextIteration(string baseName, uint iteration); - - internal abstract bool IsValidIteration(string name); + return tryMe; } - private class FileIterationHelper : IterationHelper + internal override bool IsValidIteration(string path) { - private readonly bool checkMatchingDirectory; + Debug.Assert(!string.IsNullOrEmpty(path), "path is null"); - /// - /// Constructor for class checkMatchingDirectory. - /// - /// If true, and directory with filename without extension exists, try next iteration. - internal FileIterationHelper(bool checkMatchingDirectory) + if (File.Exists(path) || Directory.Exists(path)) { - this.checkMatchingDirectory = checkMatchingDirectory; - } - - internal override string NextIteration(string baseName, uint iteration) - { - Debug.Assert(!string.IsNullOrEmpty(baseName), "baseName is null"); - - string withoutExtensionName = Path.GetFileNameWithoutExtension(baseName); - string tryMe = FormatIteration(withoutExtensionName, iteration); - if (Path.HasExtension(baseName)) - { - tryMe += Path.GetExtension(baseName); // Path.GetExtension already returns the leading ".". - } - - return tryMe; + return false; } - internal override bool IsValidIteration(string path) - { - Debug.Assert(!string.IsNullOrEmpty(path), "path is null"); - - if (File.Exists(path) || Directory.Exists(path)) - { - return false; - } - - // Path.ChangeExtension for "" returns trailing dot but Directory.Exists works the same for dir with and without trailing dot. - if (this.checkMatchingDirectory && Path.HasExtension(path) && Directory.Exists(Path.ChangeExtension(path, string.Empty))) - { - return false; - } - - return true; - } + // Path.ChangeExtension for "" returns trailing dot but Directory.Exists works the same for dir with and without trailing dot. + return !_checkMatchingDirectory || !Path.HasExtension(path) || !Directory.Exists(Path.ChangeExtension(path, string.Empty)); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/Attributes.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/Attributes.cs index 16c91d8f4a..a81133e0cb 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/Attributes.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/Attributes.cs @@ -1,142 +1,135 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.XML +namespace Microsoft.TestPlatform.Extensions.TrxLogger.XML; + +using System; + +/// +/// Additional data needed to describe a field for automatic xml storage +/// +[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] +internal abstract class StoreXmlAttribute : Attribute { - using System; - using System.Diagnostics.CodeAnalysis; + /// + /// simple xpath location. only element and attribute names can be used. + /// + public string Location; /// - /// Additional data needed to describe a field for automatic xml storage + /// Initializes a new instance of the class. /// - [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] - internal abstract class StoreXmlAttribute : Attribute + public StoreXmlAttribute() { - /// - /// simple xpath location. only element and attribute names can be used. - /// - [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter", Justification = "Reviewed. Suppression is ok here.")] - [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Reviewed. Suppression is ok here.")] - public string Location; - - /// - /// Initializes a new instance of the class. - /// - public StoreXmlAttribute() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// The location. - /// - public StoreXmlAttribute(string location) - { - this.Location = location; - } } /// - /// Additional info for storing simple fields with default value + /// Initializes a new instance of the class. /// - [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] - internal sealed class StoreXmlSimpleFieldAttribute : StoreXmlAttribute + /// + /// The location. + /// + public StoreXmlAttribute(string location) { - [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Reviewed. Suppression is ok here.")] - [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Reviewed. Suppression is ok here.")] - public object DefaultValue; + Location = location; + } +} - /// - /// Initializes a new instance of the class. - /// - public StoreXmlSimpleFieldAttribute() - { - } +/// +/// Additional info for storing simple fields with default value +/// +[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] +internal sealed class StoreXmlSimpleFieldAttribute : StoreXmlAttribute +{ + public object DefaultValue; - /// - /// Initializes a new instance of the class. - /// - /// - /// The location. - /// - public StoreXmlSimpleFieldAttribute(string location) : base(location) - { - } + /// + /// Initializes a new instance of the class. + /// + public StoreXmlSimpleFieldAttribute() + { + } - /// - /// Initializes a new instance of the class. - /// - /// - /// The default value. - /// - public StoreXmlSimpleFieldAttribute(object defaultValue) : this(null, defaultValue) - { - } + /// + /// Initializes a new instance of the class. + /// + /// + /// The location. + /// + public StoreXmlSimpleFieldAttribute(string location) : base(location) + { + } - /// - /// Initializes a new instance of the class. - /// - /// - /// The location. - /// - /// - /// The default value. - /// - public StoreXmlSimpleFieldAttribute(string location, object defaultValue) - : base(location) - { - this.DefaultValue = defaultValue; - } + /// + /// Initializes a new instance of the class. + /// + /// + /// The default value. + /// + public StoreXmlSimpleFieldAttribute(object defaultValue) : this(null, defaultValue) + { } /// - /// Storing of fields that support IXmlTestStore + /// Initializes a new instance of the class. /// - [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] - internal sealed class StoreXmlFieldAttribute : StoreXmlAttribute + /// + /// The location. + /// + /// + /// The default value. + /// + public StoreXmlSimpleFieldAttribute(string location, object defaultValue) + : base(location) { - /// - /// If there's no xml for the field a default instance is created or not. - /// - [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Reviewed. Suppression is ok here.")] - public bool CreateDefaultInstance = CreateDefaultInstanceDefault; + DefaultValue = defaultValue; + } +} + +/// +/// Storing of fields that support IXmlTestStore +/// +[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] +internal sealed class StoreXmlFieldAttribute : StoreXmlAttribute +{ + /// + /// If there's no xml for the field a default instance is created or not. + /// + public bool CreateDefaultInstance = CreateDefaultInstanceDefault; - /// - /// Default value - /// - internal static readonly bool CreateDefaultInstanceDefault = true; + /// + /// Default value + /// + internal static readonly bool CreateDefaultInstanceDefault = true; - /// - /// Initializes a new instance of the class. - /// - public StoreXmlFieldAttribute() - { - } + /// + /// Initializes a new instance of the class. + /// + public StoreXmlFieldAttribute() + { + } - /// - /// Initializes a new instance of the class. - /// - /// - /// The location. - /// - /// - /// The create default instance. - /// - public StoreXmlFieldAttribute(string location, bool createDefaultInstance) : base(location) - { - this.CreateDefaultInstance = createDefaultInstance; - } + /// + /// Initializes a new instance of the class. + /// + /// + /// The location. + /// + /// + /// The create default instance. + /// + public StoreXmlFieldAttribute(string location, bool createDefaultInstance) : base(location) + { + CreateDefaultInstance = createDefaultInstance; + } - /// - /// Initializes a new instance of the class. - /// - /// - /// The location. - /// - public StoreXmlFieldAttribute(string location) : this(location, true) - { - } + /// + /// Initializes a new instance of the class. + /// + /// + /// The location. + /// + public StoreXmlFieldAttribute(string location) : this(location, true) + { } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/XmlFilePersistence.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/XmlFilePersistence.cs index e6f72a1c71..66233b3bba 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/XmlFilePersistence.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/XmlFilePersistence.cs @@ -1,22 +1,21 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.XML +namespace Microsoft.TestPlatform.Extensions.TrxLogger.XML; + +internal class XmlFilePersistence : XmlPersistence { - internal class XmlFilePersistence: XmlPersistence - { - #region Constants + #region Constants - /// - /// Type of the object that is persisted to the file, the object that represents the root element - /// - public const string RootObjectType = "RootObjectType"; + /// + /// Type of the object that is persisted to the file, the object that represents the root element + /// + public const string RootObjectType = "RootObjectType"; - /// - /// The directory to where the file is being saved, or from where the file is being loaded - /// - public const string DirectoryPath = "DirectoryPath"; + /// + /// The directory to where the file is being saved, or from where the file is being loaded + /// + public const string DirectoryPath = "DirectoryPath"; - #endregion - } -} + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/XmlPersistence.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/XmlPersistence.cs index 1d3e312721..a5da559264 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/XmlPersistence.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/XmlPersistence.cs @@ -1,899 +1,875 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.XML +namespace Microsoft.TestPlatform.Extensions.TrxLogger.XML; + +using ObjectModel; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.ComponentModel; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using System.Reflection; +using System.Text.RegularExpressions; +using System.Xml; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using TrxObjectModel = ObjectModel; +using System.Text; + +/// +/// The xml persistence class. +/// +internal class XmlPersistence { - using ObjectModel; - using System; - using System.Collections; - using System.Collections.Generic; - using System.Collections.Specialized; - using System.ComponentModel; - using System.Diagnostics; - using System.Diagnostics.CodeAnalysis; - using System.Globalization; - using System.Linq; - using System.Reflection; - using System.Text.RegularExpressions; - using System.Xml; - - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - - using TrxObjectModel = ObjectModel; - using System.Text; + #region Types /// - /// The xml persistence class. + /// The exception type that is thrown when a duplicate key is added to a hashtable or + /// dictionary /// - internal class XmlPersistence + public class DuplicateKeyLoadException : Exception { - #region Types + #region Constructors /// - /// The exception type that is thrown when a duplicate key is added to a hashtable or - /// dictionary + /// Initializes the instance /// - public class DuplicateKeyLoadException : Exception + /// Key that was a duplicate + /// The duplicate-key exception message + public DuplicateKeyLoadException(object key, string message) + : this(key, message, null) { - #region Constructors - - /// - /// Initializes the instance - /// - /// Key that was a duplicate - /// The duplicate-key exception message - public DuplicateKeyLoadException(object key, string message) - : this(key, message, null) - { - } - - /// - /// Initializes the instance - /// - /// Key that was a duplicate - /// The duplicate-key exception message - /// The inner exception - public DuplicateKeyLoadException(object key, string message, Exception innerException) - : base(message, innerException) - { - this.Key = key; - } + } - #endregion + /// + /// Initializes the instance + /// + /// Key that was a duplicate + /// The duplicate-key exception message + /// The inner exception + public DuplicateKeyLoadException(object key, string message, Exception innerException) + : base(message, innerException) + { + Key = key; + } - #region Properties + #endregion - /// - /// Gets the key that was a duplicate - /// - public object Key - { - get; - private set; - } + #region Properties - #endregion + /// + /// Gets the key that was a duplicate + /// + public object Key + { + get; + private set; } #endregion + } - #region Fields + #endregion - /// This is how we persist date time except DateTime.MinValue. - private const string DateTimePersistenceFormat = "yyyy'-'MM'-'ddTHH':'mm':'ss'.'fffffffzzz"; + #region Fields - /// Special case to persist DateTime.MinValue. - private const string DateTimeUtcPersistenceFormat = "u"; + /// This is how we persist date time except DateTime.MinValue. + private const string DateTimePersistenceFormat = "yyyy'-'MM'-'ddTHH':'mm':'ss'.'fffffffzzz"; - private const string DefaultNamespacePrefixEquivalent = "dpe"; + /// Special case to persist DateTime.MinValue. + private const string DateTimeUtcPersistenceFormat = "u"; - private static readonly string EmptyGuidString = Guid.Empty.ToString(); + private const string DefaultNamespacePrefixEquivalent = "dpe"; - private static readonly Type BoolType = typeof(bool); - private static readonly Type ByteArrayType = typeof(byte[]); - private static readonly Type DateTimeType = typeof(DateTime); + private static readonly string EmptyGuidString = Guid.Empty.ToString(); - /// - /// this is the top level cache: Type->field information - /// - private static Dictionary> typeToPersistenceInfoCache = - new Dictionary>(); + private static readonly Type BoolType = typeof(bool); + private static readonly Type ByteArrayType = typeof(byte[]); + private static readonly Type DateTimeType = typeof(DateTime); - /// - /// Optimization: avoid re-parsing same query multiple times - /// - private static Dictionary queryCache = new Dictionary(); - - private string prefix; - private string namespaceUri; - private XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(new NameTable()); - - #endregion Fields + /// + /// this is the top level cache: Type->field information + /// + private static readonly Dictionary> TypeToPersistenceInfoCache = + new(); - #region Constructors + /// + /// Optimization: avoid re-parsing same query multiple times + /// + private static readonly Dictionary QueryCache = new(); - /// - /// Initializes a new instance of the class. - /// - public XmlPersistence() - { - this.prefix = string.Empty; - this.namespaceUri = "http://microsoft.com/schemas/VisualStudio/TeamTest/2010"; + private readonly string _prefix; + private readonly string _namespaceUri; + private readonly XmlNamespaceManager _xmlNamespaceManager = new(new NameTable()); - if (!string.IsNullOrEmpty(this.prefix)) - { - // Register the specified prefix with the specified namespace - this.xmlNamespaceManager.AddNamespace(this.prefix, this.namespaceUri); - } + #endregion Fields - if (!string.IsNullOrEmpty(this.namespaceUri)) - { - // Register a prefix for the namespace. This is needed for XPath queries, since an element in an XPath - // expression without a prefix is assumed to be in the empty namespace, and NOT in the provided XML namespace - // manager's default namespace (for some reason). So, we need to register a prefix that we will prepend to - // elements that are in this namespace (if it is not already the empty namespace) in XPath queries so that we - // will be able to find elements, and so that callers will not need to provide the appropriate prefixes. - // - // See the documentation for the 'XmlNamespaceManager.AddNamespace' method, specifically the Note for the - // 'prefix' parameter. - this.xmlNamespaceManager.AddNamespace(DefaultNamespacePrefixEquivalent, this.namespaceUri); - } - } + #region Constructors - #endregion Constructors + /// + /// Initializes a new instance of the class. + /// + public XmlPersistence() + { + _prefix = string.Empty; + _namespaceUri = "http://microsoft.com/schemas/VisualStudio/TeamTest/2010"; - /// - /// Create root element. - /// - /// - /// Name of the root element - /// - /// - /// The . - /// - public XmlElement CreateRootElement(string name) + if (!string.IsNullOrEmpty(_prefix)) { - return this.CreateRootElement(name, this.namespaceUri); + // Register the specified prefix with the specified namespace + _xmlNamespaceManager.AddNamespace(_prefix, _namespaceUri); } - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", - Justification = "XmlDocument.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] - private XmlElement CreateRootElement(string name, string namespaceUri) + if (!string.IsNullOrEmpty(_namespaceUri)) { - if (namespaceUri == null) - { - namespaceUri = this.namespaceUri; - } - - XmlDocument dom = new XmlDocument(); - dom.AppendChild(dom.CreateXmlDeclaration("1.0", "UTF-8", null)); - return (XmlElement)dom.AppendChild(dom.CreateElement(this.prefix, name, namespaceUri)); + // Register a prefix for the namespace. This is needed for XPath queries, since an element in an XPath + // expression without a prefix is assumed to be in the empty namespace, and NOT in the provided XML namespace + // manager's default namespace (for some reason). So, we need to register a prefix that we will prepend to + // elements that are in this namespace (if it is not already the empty namespace) in XPath queries so that we + // will be able to find elements, and so that callers will not need to provide the appropriate prefixes. + // + // See the documentation for the 'XmlNamespaceManager.AddNamespace' method, specifically the Note for the + // 'prefix' parameter. + _xmlNamespaceManager.AddNamespace(DefaultNamespacePrefixEquivalent, _namespaceUri); } + } - #region PublicSaveDataInTrx + #endregion Constructors - /// - /// Save single fields. - /// - /// - /// The parent xml. - /// - /// - /// The instance. - /// - /// - /// The parameters. - /// - public void SaveSingleFields(XmlElement parentXml, object instance, XmlTestStoreParameters parameters) + /// + /// Create root element. + /// + /// + /// Name of the root element + /// + /// + /// The . + /// + public XmlElement CreateRootElement(string name) + { + return CreateRootElement(name, _namespaceUri); + } + + private XmlElement CreateRootElement(string name, string namespaceUri) + { + if (namespaceUri == null) { - this.SaveSingleFields(parentXml, instance, null, parameters); + namespaceUri = _namespaceUri; } - /// - /// Based on the StoreXml* attributes saves simple fields - /// - /// - /// Parent xml - /// - /// - /// object to save - /// - /// - /// The requested Type. - /// - /// - /// The parameters. - /// - public void SaveSingleFields(XmlElement parentXml, object instance, Type requestedType, XmlTestStoreParameters parameters) - { - if (instance == null) - { - return; // nothing to do - } + XmlDocument dom = new(); + dom.AppendChild(dom.CreateXmlDeclaration("1.0", "UTF-8", null)); + return (XmlElement)dom.AppendChild(dom.CreateElement(_prefix, name, namespaceUri)); + } - Type type = requestedType ?? instance.GetType(); + #region PublicSaveDataInTrx - foreach (FieldPersistenceInfo info in GetFieldInfos(type)) - { - object fieldValue = info.FieldInfo.GetValue(instance); - if (fieldValue != null) - { - if (info.FieldAttribute != null) - { - this.SaveObject(fieldValue, parentXml, info.Location, parameters); - } - else if (info.SimpleFieldAttribute != null) - { - this.SaveSimpleField(parentXml, info.Location, fieldValue, info.SimpleFieldAttribute.DefaultValue); - } - } - } + /// + /// Save single fields. + /// + /// + /// The parent xml. + /// + /// + /// The instance. + /// + /// + /// The parameters. + /// + public void SaveSingleFields(XmlElement parentXml, object instance, XmlTestStoreParameters parameters) + { + SaveSingleFields(parentXml, instance, null, parameters); + } + + /// + /// Based on the StoreXml* attributes saves simple fields + /// + /// + /// Parent xml + /// + /// + /// object to save + /// + /// + /// The requested Type. + /// + /// + /// The parameters. + /// + public void SaveSingleFields(XmlElement parentXml, object instance, Type requestedType, XmlTestStoreParameters parameters) + { + if (instance == null) + { + return; // nothing to do } - /// - /// Based on the StoreXml* attributes saves simple fields - /// - /// - /// The object to save. - /// - /// - /// The parent xml. - /// - /// - /// The location. - /// - /// - /// The parameters. - /// - public void SaveObject(object objectToSave, XmlElement parentXml, string location, XmlTestStoreParameters parameters) - { - if (objectToSave != null && location != null) + Type type = requestedType ?? instance.GetType(); + + foreach (FieldPersistenceInfo info in GetFieldInfos(type)) + { + object fieldValue = info.FieldInfo.GetValue(instance); + if (fieldValue != null) { - string nameSpaceUri = this.namespaceUri; - if (objectToSave is IXmlTestStoreCustom customStore) + if (info.FieldAttribute != null) { - nameSpaceUri = customStore.NamespaceUri; + SaveObject(fieldValue, parentXml, info.Location, parameters); } - - XmlNode xmlNode = this.EnsureLocationExists(parentXml, location, nameSpaceUri); - this.SaveObject(objectToSave, xmlNode, parameters); - - if (xmlNode is XmlElement element && - !element.HasAttributes && - !element.HasChildNodes && - string.IsNullOrEmpty(element.InnerText)) + else if (info.SimpleFieldAttribute != null) { - element.ParentNode.RemoveChild(element); // get rid of empty elements to keep the xml clean + SaveSimpleField(parentXml, info.Location, fieldValue, info.SimpleFieldAttribute.DefaultValue); } } } + } - /// - /// Save object. - /// - /// - /// The object to save. - /// - /// - /// The node to save at. - /// - /// - /// The parameters. - /// - public void SaveObject(object objectToSave, XmlNode nodeToSaveAt, XmlTestStoreParameters parameters) + /// + /// Based on the StoreXml* attributes saves simple fields + /// + /// + /// The object to save. + /// + /// + /// The parent xml. + /// + /// + /// The location. + /// + /// + /// The parameters. + /// + public void SaveObject(object objectToSave, XmlElement parentXml, string location, XmlTestStoreParameters parameters) + { + if (objectToSave != null && location != null) { - this.SaveObject(objectToSave, nodeToSaveAt, parameters, null); - } + string nameSpaceUri = _namespaceUri; + if (objectToSave is IXmlTestStoreCustom customStore) + { + nameSpaceUri = customStore.NamespaceUri; + } - /// - /// Save the object. - /// - /// - /// The object to save. - /// - /// - /// The node to save at. - /// - /// - /// The parameters. - /// - /// - /// The default value. - /// - public void SaveObject(object objectToSave, XmlNode nodeToSaveAt, XmlTestStoreParameters parameters, object defaultValue) - { - if (objectToSave != null) + XmlNode xmlNode = EnsureLocationExists(parentXml, location, nameSpaceUri); + SaveObject(objectToSave, xmlNode, parameters); + + if (xmlNode is XmlElement element && + !element.HasAttributes && + !element.HasChildNodes && + string.IsNullOrEmpty(element.InnerText)) { - if (objectToSave is IXmlTestStore persistable) - { - persistable.Save((XmlElement)nodeToSaveAt, parameters); - } - else - { - this.SaveSimpleData(objectToSave, nodeToSaveAt, defaultValue); - } + element.ParentNode.RemoveChild(element); // get rid of empty elements to keep the xml clean } } + } - /// - /// Save simple field. - /// - /// - /// The xml. - /// - /// - /// The location. - /// - /// - /// The value. - /// - /// - /// The default value. - /// - public void SaveSimpleField(XmlElement xml, string location, object value, object defaultValue) - { - if (value == null || value.Equals(defaultValue)) + /// + /// Save object. + /// + /// + /// The object to save. + /// + /// + /// The node to save at. + /// + /// + /// The parameters. + /// + public void SaveObject(object objectToSave, XmlNode nodeToSaveAt, XmlTestStoreParameters parameters) + { + SaveObject(objectToSave, nodeToSaveAt, parameters, null); + } + + /// + /// Save the object. + /// + /// + /// The object to save. + /// + /// + /// The node to save at. + /// + /// + /// The parameters. + /// + /// + /// The default value. + /// + public void SaveObject(object objectToSave, XmlNode nodeToSaveAt, XmlTestStoreParameters parameters, object defaultValue) + { + if (objectToSave != null) + { + if (objectToSave is IXmlTestStore persistable) { - return; + persistable.Save((XmlElement)nodeToSaveAt, parameters); + } + else + { + SaveSimpleData(objectToSave, nodeToSaveAt, defaultValue); } - - XmlNode saveTarget = this.EnsureLocationExists(xml, location); - this.SaveSimpleData(value, saveTarget, defaultValue); } + } - /// - /// Save GUID. - /// - /// - /// The xml. - /// - /// - /// The location. - /// - /// - /// The GUID. - /// - public void SaveGuid(XmlElement xml, string location, Guid guid) + /// + /// Save simple field. + /// + /// + /// The xml. + /// + /// + /// The location. + /// + /// + /// The value. + /// + /// + /// The default value. + /// + public void SaveSimpleField(XmlElement xml, string location, object value, object defaultValue) + { + if (value == null || value.Equals(defaultValue)) { - this.SaveSimpleField(xml, location, guid.ToString(), EmptyGuidString); + return; } - public void SaveHashtable(Hashtable ht, XmlElement element, string location, string keyLocation, string valueLocation, string itemElementName, XmlTestStoreParameters parameters) + XmlNode saveTarget = EnsureLocationExists(xml, location); + SaveSimpleData(value, saveTarget, defaultValue); + } + + /// + /// Save GUID. + /// + /// + /// The xml. + /// + /// + /// The location. + /// + /// + /// The GUID. + /// + public void SaveGuid(XmlElement xml, string location, Guid guid) + { + SaveSimpleField(xml, location, guid.ToString(), EmptyGuidString); + } + + public void SaveHashtable(Hashtable ht, XmlElement element, string location, string keyLocation, string valueLocation, string itemElementName, XmlTestStoreParameters parameters) + { + if (ht != null && ht.Count > 0) { - if (ht != null && ht.Count > 0) + XmlElement dictionaryElement = (XmlElement)EnsureLocationExists(element, location); + foreach (DictionaryEntry de in ht) { - XmlElement dictionaryElement = (XmlElement)this.EnsureLocationExists(element, location); - foreach (DictionaryEntry de in ht) - { - XmlElement itemXml = this.CreateElement(dictionaryElement, itemElementName); + XmlElement itemXml = CreateElement(dictionaryElement, itemElementName); - this.SaveObject(de.Key, itemXml, keyLocation, parameters); - this.SaveObject(de.Value, itemXml, valueLocation, parameters); - } + SaveObject(de.Key, itemXml, keyLocation, parameters); + SaveObject(de.Value, itemXml, valueLocation, parameters); } } + } - public void SaveStringDictionary(StringDictionary dict, XmlElement element, string location, string keyLocation, string valueLocation, string itemElementName, XmlTestStoreParameters parameters) + public void SaveStringDictionary(StringDictionary dict, XmlElement element, string location, string keyLocation, string valueLocation, string itemElementName, XmlTestStoreParameters parameters) + { + if (dict != null && dict.Count > 0) { - if (dict != null && dict.Count > 0) + XmlElement dictionaryElement = (XmlElement)EnsureLocationExists(element, location); + foreach (DictionaryEntry de in dict) { - XmlElement dictionaryElement = (XmlElement)EnsureLocationExists(element, location); - foreach (DictionaryEntry de in dict) - { - XmlElement itemXml = this.CreateElement(dictionaryElement, itemElementName); + XmlElement itemXml = CreateElement(dictionaryElement, itemElementName); - this.SaveObject(de.Key, itemXml, keyLocation, parameters); - this.SaveObject(de.Value, itemXml, valueLocation, parameters); - } + SaveObject(de.Key, itemXml, keyLocation, parameters); + SaveObject(de.Value, itemXml, valueLocation, parameters); } } + } - #region Lists - /// - /// Save list of object . - /// - /// - /// The list. - /// - /// - /// The parent element. - /// - /// - /// The list xml element. - /// - /// - /// The item location. - /// - /// - /// The item element name. - /// - /// - /// The parameters. - /// - public void SaveIEnumerable(IEnumerable list, XmlElement element, string listXmlElement, string itemLocation, string itemElementName, XmlTestStoreParameters parameters) - { - if (list != null && list.GetEnumerator().MoveNext()) + #region Lists + /// + /// Save list of object . + /// + /// + /// The list. + /// + /// + /// The parent element. + /// + /// + /// The list xml element. + /// + /// + /// The item location. + /// + /// + /// The item element name. + /// + /// + /// The parameters. + /// + public void SaveIEnumerable(IEnumerable list, XmlElement element, string listXmlElement, string itemLocation, string itemElementName, XmlTestStoreParameters parameters) + { + if (list != null && list.GetEnumerator().MoveNext()) + { + XmlElement listElement = (XmlElement)EnsureLocationExists(element, listXmlElement); + foreach (object item in list) { - XmlElement listElement = (XmlElement)this.EnsureLocationExists(element, listXmlElement); - foreach (object item in list) - { - XmlElement itemXml = this.CreateElement(listElement, itemElementName, item); - this.SaveObject(item, itemXml, itemLocation, parameters); - } + XmlElement itemXml = CreateElement(listElement, itemElementName, item); + SaveObject(item, itemXml, itemLocation, parameters); } } + } - /// - /// Save list. - /// - /// - /// The list. - /// - /// - /// The element. - /// - /// - /// The list xml element. - /// - /// - /// The item location. - /// - /// - /// The item element name. - /// - /// - /// The parameters. - /// - /// Generic parameter - /// - public void SaveList(IList list, XmlElement element, string listXmlElement, string itemLocation, string itemElementName, XmlTestStoreParameters parameters) - { - if (list != null && list.Count > 0) + /// + /// Save list. + /// + /// + /// The list. + /// + /// + /// The element. + /// + /// + /// The list xml element. + /// + /// + /// The item location. + /// + /// + /// The item element name. + /// + /// + /// The parameters. + /// + /// Generic parameter + /// + public void SaveList(IList list, XmlElement element, string listXmlElement, string itemLocation, string itemElementName, XmlTestStoreParameters parameters) + { + if (list != null && list.Count > 0) + { + XmlElement listElement = (XmlElement)EnsureLocationExists(element, listXmlElement); + foreach (V item in list) { - XmlElement listElement = (XmlElement)this.EnsureLocationExists(element, listXmlElement); - foreach (V item in list) - { - XmlElement itemXml = this.CreateElement(listElement, itemElementName, item); - this.SaveObject(item, itemXml, itemLocation, parameters); - } + XmlElement itemXml = CreateElement(listElement, itemElementName, item); + SaveObject(item, itemXml, itemLocation, parameters); } } + } - #region Counters + #region Counters - [SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")] - public void SaveCounters(XmlElement xml, string location, int[] counters) - { - xml = (XmlElement)LocationToXmlNode(xml, location); + public void SaveCounters(XmlElement xml, string location, int[] counters) + { + xml = (XmlElement)LocationToXmlNode(xml, location); - for (int i = 0; i < counters.Length; i++) - { - TrxObjectModel.TestOutcome outcome = (TrxObjectModel.TestOutcome)i; - string attributeName = outcome.ToString(); - attributeName = attributeName.Substring(0, 1).ToLowerInvariant() + attributeName.Substring(1); + for (int i = 0; i < counters.Length; i++) + { + TrxObjectModel.TestOutcome outcome = (TrxObjectModel.TestOutcome)i; + string attributeName = outcome.ToString(); + attributeName = attributeName.Substring(0, 1).ToLowerInvariant() + attributeName.Substring(1); - xml.SetAttribute(attributeName, counters[i].ToString(CultureInfo.InvariantCulture)); - } + xml.SetAttribute(attributeName, counters[i].ToString(CultureInfo.InvariantCulture)); } + } - #endregion Counters + #endregion Counters - #endregion List + #endregion List - internal static void SaveUsingReflection(XmlElement element, object instance, Type requestedType, XmlTestStoreParameters parameters) - { - XmlPersistence helper = new XmlPersistence(); - helper.SaveSingleFields(element, instance, requestedType, parameters); - } + internal static void SaveUsingReflection(XmlElement element, object instance, Type requestedType, XmlTestStoreParameters parameters) + { + XmlPersistence helper = new(); + helper.SaveSingleFields(element, instance, requestedType, parameters); + } - #endregion PublicSaveDataInTrx + #endregion PublicSaveDataInTrx - #region Utilities + #region Utilities - #region Optimization: Reflection caching + #region Optimization: Reflection caching - /// - /// Updates the cache if needed and gets the field info collection - /// - /// - /// The type. - /// - /// - /// The . - /// - private static IEnumerable GetFieldInfos(Type type) - { - if (!typeToPersistenceInfoCache.TryGetValue(type, out var toReturn)) + /// + /// Updates the cache if needed and gets the field info collection + /// + /// + /// The type. + /// + /// + /// The . + /// + private static IEnumerable GetFieldInfos(Type type) + { + if (!TypeToPersistenceInfoCache.TryGetValue(type, out var toReturn)) + { + toReturn = ReflectFields(type); + lock (TypeToPersistenceInfoCache) { - toReturn = ReflectFields(type); - lock (typeToPersistenceInfoCache) + if (!TypeToPersistenceInfoCache.TryGetValue(type, out var checkCache)) { - if (!typeToPersistenceInfoCache.TryGetValue(type, out var checkCache)) - { - typeToPersistenceInfoCache.Add(type, toReturn); - } + TypeToPersistenceInfoCache.Add(type, toReturn); } } - - return toReturn; } - /// - /// EXPENSIVE! Uses reflection to build a cache item of information about the type and its fields - /// - /// the type to reflect on - /// collection of field information - private static IEnumerable ReflectFields(Type type) - { - List toReturn = new List(); - - foreach ( - FieldInfo reflectedFieldInfo in - type.GetTypeInfo().GetFields( - BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly)) - { - FieldPersistenceInfo info = new FieldPersistenceInfo(reflectedFieldInfo); - - // only fields with known location need to be persisted - if (!string.IsNullOrEmpty(info.Location)) - { - toReturn.Add(info); - } - } + return toReturn; + } - return toReturn; - } + /// + /// EXPENSIVE! Uses reflection to build a cache item of information about the type and its fields + /// + /// the type to reflect on + /// collection of field information + private static IEnumerable ReflectFields(Type type) + { + List toReturn = new(); - #endregion Optimization: Reflection caching + foreach ( + FieldInfo reflectedFieldInfo in + type.GetTypeInfo().GetFields( + BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly)) + { + FieldPersistenceInfo info = new(reflectedFieldInfo); - /// - /// Convert dateTime to string. - /// - /// - /// The date time. - /// - /// - /// The . - /// - private static string DateTimeToString(DateTime dateTime) - { - if (dateTime == DateTime.MinValue) - { - // DateTime.MinValue has Kind.Unspecified and thus it does not make any sense to convert it to local/universal. - // Also note that we use format w/o time zones to persist DateTime.MinValue. - return dateTime.ToString(DateTimeUtcPersistenceFormat, CultureInfo.InvariantCulture.DateTimeFormat); - } - else + // only fields with known location need to be persisted + if (!string.IsNullOrEmpty(info.Location)) { - // Ensure that the datetime value is in local time.. - // This is needed as the persistence format we use needs the datetime to be in local time.. - DateTime localDateTime = dateTime.ToLocalTime(); - return localDateTime.ToString(DateTimePersistenceFormat, CultureInfo.InvariantCulture.DateTimeFormat); + toReturn.Add(info); } } - private static string GetFieldLocation(FieldInfo fieldInfo) - { - string location = null; + return toReturn; + } - StoreXmlAttribute locationAttribute = GetAttribute(fieldInfo); - if (locationAttribute != null) - { - location = locationAttribute.Location ?? GetDefaultFieldLocation(fieldInfo); - } + #endregion Optimization: Reflection caching - return location; + /// + /// Convert dateTime to string. + /// + /// + /// The date time. + /// + /// + /// The . + /// + private static string DateTimeToString(DateTime dateTime) + { + if (dateTime == DateTime.MinValue) + { + // DateTime.MinValue has Kind.Unspecified and thus it does not make any sense to convert it to local/universal. + // Also note that we use format w/o time zones to persist DateTime.MinValue. + return dateTime.ToString(DateTimeUtcPersistenceFormat, CultureInfo.InvariantCulture.DateTimeFormat); } - - private static string GetDefaultFieldLocation(FieldInfo fieldInfo) + else { - string fieldName = fieldInfo.Name; - string defaultFieldLocation = fieldName.StartsWith("m_", StringComparison.Ordinal) ? fieldName.Substring(2, fieldName.Length - 2) : fieldName; + // Ensure that the datetime value is in local time.. + // This is needed as the persistence format we use needs the datetime to be in local time.. + DateTime localDateTime = dateTime.ToLocalTime(); + return localDateTime.ToString(DateTimePersistenceFormat, CultureInfo.InvariantCulture.DateTimeFormat); + } + } - if (!ImplementsIXmlTestStore(fieldInfo.FieldType)) - { - defaultFieldLocation = '@' + defaultFieldLocation; - } + private static string GetFieldLocation(FieldInfo fieldInfo) + { + string location = null; - return defaultFieldLocation; + StoreXmlAttribute locationAttribute = GetAttribute(fieldInfo); + if (locationAttribute != null) + { + location = locationAttribute.Location ?? GetDefaultFieldLocation(fieldInfo); } - private static bool ImplementsIXmlTestStore(Type type) + return location; + } + + private static string GetDefaultFieldLocation(FieldInfo fieldInfo) + { + string fieldName = fieldInfo.Name; + string defaultFieldLocation = fieldName.StartsWith("m_", StringComparison.Ordinal) ? fieldName.Substring(2, fieldName.Length - 2) : fieldName; + + if (!ImplementsIXmlTestStore(fieldInfo.FieldType)) { - return type.GetTypeInfo().GetInterface(typeof(IXmlTestStore).Name) != null; + defaultFieldLocation = '@' + defaultFieldLocation; } - private static T GetAttribute(FieldInfo fieldInfo) where T : Attribute - { - var attributes = fieldInfo.GetCustomAttributes(typeof(T), false).ToArray(); + return defaultFieldLocation; + } - if (attributes.Length > 0) - { - return (T)attributes[0]; - } + private static bool ImplementsIXmlTestStore(Type type) + { + return type.GetTypeInfo().GetInterface(typeof(IXmlTestStore).Name) != null; + } - return default; - } + private static T GetAttribute(FieldInfo fieldInfo) where T : Attribute + { + var attributes = fieldInfo.GetCustomAttributes(typeof(T), false).ToArray(); + + return attributes.Length > 0 ? (T)attributes[0] : default; + } - [SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "Reviewed. Suppression is OK here.")] - private void SaveSimpleData(object value, XmlNode nodeToSaveAt, object defaultValue) + private void SaveSimpleData(object value, XmlNode nodeToSaveAt, object defaultValue) + { + if (value == null || value.Equals(defaultValue)) { - if (value == null || value.Equals(defaultValue)) - { - return; - } + return; + } - Type valueType = value.GetType(); + Type valueType = value.GetType(); - string valueToSave; - if (valueType == BoolType) - { - valueToSave = value.ToString().ToLowerInvariant(); - } - else if (valueType == ByteArrayType) - { - // Use only for Arrays, Collections and Lists. E.g. string is also IEnumerable. - valueToSave = Convert.ToBase64String(value as byte[]); - } - else if (valueType == DateTimeType) - { - // always save as a sortable date time with fractional seconds. - valueToSave = DateTimeToString((DateTime)value); - } - else - { - // use the appropriate type converter to get a culture invariant string. - try - { - TypeConverter convert = TypeDescriptor.GetConverter(valueType); - valueToSave = convert.ConvertToInvariantString(value); - } - catch (NotSupportedException nosupportEx) - { - EqtTrace.Info("TypeConverter not supported for {0} : NotSupportedException: {1}", value.ToString(), nosupportEx); - valueToSave = value.ToString(); - } - } - - // Remove invalid char if any - valueToSave = RemoveInvalidXmlChar(valueToSave); - if (nodeToSaveAt is XmlElement elementToSaveAt) + string valueToSave; + if (valueType == BoolType) + { + valueToSave = value.ToString().ToLowerInvariant(); + } + else if (valueType == ByteArrayType) + { + // Use only for Arrays, Collections and Lists. E.g. string is also IEnumerable. + valueToSave = Convert.ToBase64String(value as byte[]); + } + else if (valueType == DateTimeType) + { + // always save as a sortable date time with fractional seconds. + valueToSave = DateTimeToString((DateTime)value); + } + else + { + // use the appropriate type converter to get a culture invariant string. + try { - elementToSaveAt.InnerText = valueToSave; + TypeConverter convert = TypeDescriptor.GetConverter(valueType); + valueToSave = convert.ConvertToInvariantString(value); } - else + catch (NotSupportedException nosupportEx) { - nodeToSaveAt.Value = valueToSave; + EqtTrace.Info("TypeConverter not supported for {0} : NotSupportedException: {1}", value.ToString(), nosupportEx); + valueToSave = value.ToString(); } } - public XmlNode EnsureLocationExists(XmlElement xml, string location) + // Remove invalid char if any + valueToSave = RemoveInvalidXmlChar(valueToSave); + if (nodeToSaveAt is XmlElement elementToSaveAt) { - return this.EnsureLocationExists(xml, location, this.namespaceUri); + elementToSaveAt.InnerText = valueToSave; } + else + { + nodeToSaveAt.Value = valueToSave; + } + } - private static string RemoveInvalidXmlChar(string str) + public XmlNode EnsureLocationExists(XmlElement xml, string location) + { + return EnsureLocationExists(xml, location, _namespaceUri); + } + + private static string RemoveInvalidXmlChar(string str) + { + if (str != null) { - if (str != null) - { - // From xml spec (http://www.w3.org/TR/xml/#charsets) valid chars: - // #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] - - // we are handling only #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] - // because C# support unicode character in range \u0000 to \uFFFF - MatchEvaluator evaluator = new MatchEvaluator(ReplaceInvalidCharacterWithUniCodeEscapeSequence); - string invalidChar = @"[^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD]"; - return Regex.Replace(str, invalidChar, evaluator); - } + // From xml spec (http://www.w3.org/TR/xml/#charsets) valid chars: + // #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] - return str; + // we are handling only #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] + // because C# support unicode character in range \u0000 to \uFFFF + MatchEvaluator evaluator = new(ReplaceInvalidCharacterWithUniCodeEscapeSequence); + string invalidChar = @"[^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD]"; + return Regex.Replace(str, invalidChar, evaluator); } - private static string ReplaceInvalidCharacterWithUniCodeEscapeSequence(Match match) + return str; + } + + private static string ReplaceInvalidCharacterWithUniCodeEscapeSequence(Match match) + { + char x = match.Value[0]; + return string.Format(@"\u{0:x4}", (ushort)x); + } + + private XmlNode EnsureLocationExists(XmlElement xml, string location, string nameSpaceUri) + { + XmlNode node = LocationToXmlNode(xml, location); + if (node != null) { - char x = match.Value[0]; - return string.Format(@"\u{0:x4}", (ushort)x); + return node; } - private XmlNode EnsureLocationExists(XmlElement xml, string location, string nameSpaceUri) + if (location.StartsWith("@", StringComparison.Ordinal)) { - XmlNode node = this.LocationToXmlNode(xml, location); - if (node != null) - { - return node; - } + string attributeName = location.Substring(1, location.Length - 1); + return xml.HasAttribute(attributeName) + ? xml.GetAttributeNode(attributeName) + : (XmlNode)xml.Attributes.Append(xml.OwnerDocument.CreateAttribute(attributeName)); + } + else + { + string[] parts = location.Split(new char[] { '/' }, 2); + string firstPart = parts[0]; - if (location.StartsWith("@", StringComparison.Ordinal)) + XmlNode firstChild = LocationToXmlNode(xml, firstPart); + if (firstChild == null) { - string attributeName = location.Substring(1, location.Length - 1); - if (xml.HasAttribute(attributeName)) - { - return xml.GetAttributeNode(attributeName); - } - else - { - return xml.Attributes.Append(xml.OwnerDocument.CreateAttribute(attributeName)); - } + firstChild = CreateElement(xml, firstPart, GetNamespaceUriOrDefault(nameSpaceUri)); } - else - { - string[] parts = location.Split(new char[] { '/' }, 2); - string firstPart = parts[0]; - XmlNode firstChild = this.LocationToXmlNode(xml, firstPart); - if (firstChild == null) - { - firstChild = this.CreateElement(xml, firstPart, this.GetNamespaceUriOrDefault(nameSpaceUri)); - } - - if (parts.Length > 1) - { - return this.EnsureLocationExists((XmlElement)firstChild, parts[1]); - } - else - { - return firstChild; - } - } + return parts.Length > 1 ? EnsureLocationExists((XmlElement)firstChild, parts[1]) : firstChild; } + } + + private string GetNamespaceUriOrDefault(string nameSpaceUri) + { + return nameSpaceUri ?? _namespaceUri; + } - private string GetNamespaceUriOrDefault(string nameSpaceUri) + /// + /// Creates a new element with the given name in the current (of this instance of XmlPersistence namespace) + /// + /// parent xml + /// element name + /// a new XmlElement attached to the parent + private XmlElement CreateElement(XmlElement xml, string name) + { + return CreateElement(xml, name, _namespaceUri); + } + + private XmlElement CreateElement(XmlElement xml, string name, string elementNamespaceUri) + { + return (XmlElement)xml.AppendChild(xml.OwnerDocument.CreateElement(_prefix, name, elementNamespaceUri)); + } + + /// + /// Accepts name == null + /// + /// parent xml + /// The local name of the new element. + /// the object for which element has to create + /// a new XmlElement attached to the parent + private XmlElement CreateElement(XmlElement parent, string name, object instance) + { + if (name != null) { - return nameSpaceUri ?? this.namespaceUri; + return CreateElement(parent, name); } - - /// - /// Creates a new element with the given name in the current (of this instance of XmlPersistence namespace) - /// - /// parent xml - /// element name - /// a new XmlElement attached to the parent - private XmlElement CreateElement(XmlElement xml, string name) + else { - return this.CreateElement(xml, name, this.namespaceUri); + NewElementCreateData createData = GetElementCreateData(instance); + return CreateElement(parent, createData.ElementName, createData.NamespaceUri); } + } + + private NewElementCreateData GetElementCreateData(object persistee) + { + Debug.Assert(persistee != null, "persistee is null"); - private XmlElement CreateElement(XmlElement xml, string name, string elementNamespaceUri) + NewElementCreateData toReturn = new(); + if (persistee is IXmlTestStoreCustom custom) { - return (XmlElement)xml.AppendChild(xml.OwnerDocument.CreateElement(this.prefix, name, elementNamespaceUri)); + toReturn.ElementName = custom.ElementName; + toReturn.NamespaceUri = custom.NamespaceUri; } - /// - /// Accepts name == null - /// - /// parent xml - /// The local name of the new element. - /// the object for which element has to create - /// a new XmlElement attached to the parent - private XmlElement CreateElement(XmlElement parent, string name, object instance) + if (toReturn.ElementName == null) { - if (name != null) - { - return this.CreateElement(parent, name); - } - else - { - NewElementCreateData createData = this.GetElementCreateData(instance); - return this.CreateElement(parent, createData.ElementName, createData.NamespaceUri); - } + toReturn.ElementName = persistee.GetType().Name; } - private NewElementCreateData GetElementCreateData(object persistee) + if (toReturn.NamespaceUri == null) { - Debug.Assert(persistee != null, "persistee is null"); - - NewElementCreateData toReturn = new NewElementCreateData(); - if (persistee is IXmlTestStoreCustom custom) - { - toReturn.ElementName = custom.ElementName; - toReturn.NamespaceUri = custom.NamespaceUri; - } + toReturn.NamespaceUri = _namespaceUri; + } - if (toReturn.ElementName == null) - { - toReturn.ElementName = persistee.GetType().Name; - } + return toReturn; + } - if (toReturn.NamespaceUri == null) - { - toReturn.NamespaceUri = this.namespaceUri; - } + private XmlNode LocationToXmlNode(XmlElement element, string location) + { + location = ProcessXPathQuery(location); - return toReturn; + try + { + return element.SelectSingleNode(location, _xmlNamespaceManager); + } + catch (System.Xml.XPath.XPathException e) + { + throw new Exception("The persistence location is invalid. Element: '" + element.Name + "', location: '" + location + "'", e); } + } - private XmlNode LocationToXmlNode(XmlElement element, string location) + private string ProcessXPathQuery(string queryIn) + { + // If we are working with the empty namespace, there is no need to decorate elements in the XPath expression, since + // elements in the XPath expression that don't have a prefix will be searched for in the empty namespace. + if (string.IsNullOrEmpty(_namespaceUri)) { - location = this.ProcessXPathQuery(location); + return queryIn; + } - try - { - return element.SelectSingleNode(location, this.xmlNamespaceManager); - } - catch (System.Xml.XPath.XPathException e) - { - throw new Exception("The persistence location is invalid. Element: '" + element.Name + "', location: '" + location + "'", e); - } + if (QueryCache.ContainsKey(queryIn)) + { + return QueryCache[queryIn]; } - private string ProcessXPathQuery(string queryIn) + // fix the empty namespaces to a temp prefix, so xpath query can understand them + string[] parts = queryIn.Split(new char[] { '/' }, StringSplitOptions.None); + + StringBuilder query = new(); + + foreach (string part in parts) { - // If we are working with the empty namespace, there is no need to decorate elements in the XPath expression, since - // elements in the XPath expression that don't have a prefix will be searched for in the empty namespace. - if (string.IsNullOrEmpty(this.namespaceUri)) + if (query.Length > 0 || queryIn.StartsWith("/", StringComparison.Ordinal)) { - return queryIn; + query.Append('/'); } - if (queryCache.ContainsKey(queryIn)) + if (part != "." && part != ".." && !part.Contains(":") && (part.Length > 0) && (!part.StartsWith("@", StringComparison.Ordinal))) { - return queryCache[queryIn]; + query.Append(DefaultNamespacePrefixEquivalent + ":"); } - // fix the empty namespaces to a temp prefix, so xpath query can understand them - string[] parts = queryIn.Split(new char[] { '/' }, StringSplitOptions.None); - - StringBuilder query = new StringBuilder(); - - foreach (string part in parts) - { - if (query.Length > 0 || queryIn.StartsWith("/", StringComparison.Ordinal)) - { - query.Append('/'); - } - - if (part != "." && part != ".." && !part.Contains(":") && (part.Length > 0) && (!part.StartsWith("@", StringComparison.Ordinal))) - { - query.Append(DefaultNamespacePrefixEquivalent + ":"); - } - - query.Append(part); - } + query.Append(part); + } - string queryString = query.ToString(); - queryCache[queryIn] = queryString; + string queryString = query.ToString(); + QueryCache[queryIn] = queryString; - return queryString; - } + return queryString; + } - #endregion Utilities + #endregion Utilities - #region Types + #region Types - private class NewElementCreateData - { - public string NamespaceUri { get; set; } + private class NewElementCreateData + { + public string NamespaceUri { get; set; } - public string ElementName { get; set; } - } + public string ElementName { get; set; } + } - /// - /// caches information about a field - /// - [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Reviewed. Suppression is OK here.")] - private class FieldPersistenceInfo - { - internal FieldInfo FieldInfo; + /// + /// caches information about a field + /// + private class FieldPersistenceInfo + { + internal readonly FieldInfo FieldInfo; - internal string Location; + internal readonly string Location; - internal StoreXmlAttribute Attribute; + internal readonly StoreXmlAttribute Attribute; - internal StoreXmlSimpleFieldAttribute SimpleFieldAttribute; + internal readonly StoreXmlSimpleFieldAttribute SimpleFieldAttribute; - internal StoreXmlFieldAttribute FieldAttribute; + internal readonly StoreXmlFieldAttribute FieldAttribute; - internal FieldPersistenceInfo(FieldInfo fieldInfo) - { - this.FieldInfo = fieldInfo; - this.Location = GetFieldLocation(fieldInfo); + internal FieldPersistenceInfo(FieldInfo fieldInfo) + { + FieldInfo = fieldInfo; + Location = GetFieldLocation(fieldInfo); - this.Attribute = GetAttribute(fieldInfo); - this.SimpleFieldAttribute = this.Attribute as StoreXmlSimpleFieldAttribute; - this.FieldAttribute = this.Attribute as StoreXmlFieldAttribute; - } + Attribute = GetAttribute(fieldInfo); + SimpleFieldAttribute = Attribute as StoreXmlSimpleFieldAttribute; + FieldAttribute = Attribute as StoreXmlFieldAttribute; } - - #endregion } + + #endregion } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IDiscoveryContext.cs b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IDiscoveryContext.cs index c08b35be01..68127280f4 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IDiscoveryContext.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IDiscoveryContext.cs @@ -1,16 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + +/// +/// Specifies the user specified RunSettings and framework provided context of the discovery. +/// +public interface IDiscoveryContext { /// - /// Specifies the user specified RunSettings and framework provided context of the discovery. + /// Runsettings specified for this request. /// - public interface IDiscoveryContext - { - /// - /// Runsettings specified for this request. - /// - IRunSettings RunSettings { get; } - } -} + IRunSettings RunSettings { get; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IFrameworkHandle.cs b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IFrameworkHandle.cs index 4e71e2e870..0873a3b66f 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IFrameworkHandle.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IFrameworkHandle.cs @@ -1,31 +1,31 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter -{ - using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + +using System.Collections.Generic; + +using Logging; +/// +/// Handle to the framework which is passed to the test executors. +/// +public interface IFrameworkHandle : ITestExecutionRecorder, IMessageLogger +{ /// - /// Handle to the framework which is passed to the test executors. + /// Gets or sets a value indicating whether the execution framework enables the shutdown of execution process after the test run is complete. This should be used only in out of process test runs when IRunContext.KeepAlive is true + /// and should be used only when absolutely required as using it degrades the performance of the subsequent run. + /// It throws InvalidOperationException when it is attempted to be enabled when keepAlive is false. /// - public interface IFrameworkHandle : ITestExecutionRecorder, IMessageLogger - { - /// - /// Gets or sets a value indicating whether the execution framework enables the shutdown of execution process after the test run is complete. This should be used only in out of process test runs when IRunContext.KeepAlive is true - /// and should be used only when absolutely required as using it degrades the performance of the subsequent run. - /// It throws InvalidOperationException when it is attempted to be enabled when keepAlive is false. - /// - bool EnableShutdownAfterTestRun { get; set; } + bool EnableShutdownAfterTestRun { get; set; } - /// - /// Launch the specified process with the debugger attached. - /// - /// File path to the exe to launch. - /// Working directory that process should use. - /// Command line arguments the process should be launched with. - /// Environment variables to be set in target process - /// Process ID of the started process. - int LaunchProcessWithDebuggerAttached(string filePath, string workingDirectory, string arguments, IDictionary environmentVariables); - } + /// + /// Launch the specified process with the debugger attached. + /// + /// File path to the exe to launch. + /// Working directory that process should use. + /// Command line arguments the process should be launched with. + /// Environment variables to be set in target process + /// Process ID of the started process. + int LaunchProcessWithDebuggerAttached(string filePath, string workingDirectory, string arguments, IDictionary environmentVariables); } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IFrameworkHandle2.cs b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IFrameworkHandle2.cs index 9f656b590c..112790652c 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IFrameworkHandle2.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IFrameworkHandle2.cs @@ -1,18 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + +/// +/// Handle to the framework which is passed to the test executors. +/// +public interface IFrameworkHandle2 : IFrameworkHandle { /// - /// Handle to the framework which is passed to the test executors. + /// Attach debugger to an already running process. /// - public interface IFrameworkHandle2 : IFrameworkHandle - { - /// - /// Attach debugger to an already running process. - /// - /// Process ID of the process to which the debugger should be attached. - /// if the debugger was successfully attached to the requested process, otherwise. - bool AttachDebuggerToProcess(int pid); - } -} + /// Process ID of the process to which the debugger should be attached. + /// if the debugger was successfully attached to the requested process, otherwise. + bool AttachDebuggerToProcess(int pid); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IRunContext.cs b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IRunContext.cs index f80729e30c..c2effb79c9 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IRunContext.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IRunContext.cs @@ -1,51 +1,50 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + +using System; +using System.Collections.Generic; + +/// +/// It provides user specified runSettings and framework provided context of the run. +/// +public interface IRunContext : IDiscoveryContext { - using System; - using System.Collections.Generic; + /// + /// Whether the execution process should be kept alive after the run is finished or not. + /// + bool KeepAlive { get; } + + /// + /// Whether the execution is happening in InProc or outOfProc + /// + bool InIsolation { get; } + + /// + /// Whether the data collection is enabled or not + /// + bool IsDataCollectionEnabled { get; } + + /// + /// Whether the test is being debugged or not. + /// + bool IsBeingDebugged { get; } + + /// + /// Test case filter for user specified criteria which has been validated for 'supportedProperties'. + /// It is used only with sources. With specific test cases it will always be null. + /// If there is a parsing error or filter expression has unsupported properties, TestPlatformFormatException() is thrown. + /// + ITestCaseFilterExpression GetTestCaseFilter(IEnumerable supportedProperties, Func propertyProvider); + + /// + /// Directory which should be used for storing result files/deployment files etc. + /// + string TestRunDirectory { get; } /// - /// It provides user specified runSettings and framework provided context of the run. + /// Solution Directory. /// - public interface IRunContext : IDiscoveryContext - { - /// - /// Whether the execution process should be kept alive after the run is finished or not. - /// - bool KeepAlive { get; } - - /// - /// Whether the execution is happening in InProc or outOfProc - /// - bool InIsolation { get; } - - /// - /// Whether the data collection is enabled or not - /// - bool IsDataCollectionEnabled { get; } - - /// - /// Whether the test is being debugged or not. - /// - bool IsBeingDebugged { get; } - - /// - /// Test case filter for user specified criteria which has been validated for 'supportedProperties'. - /// It is used only with sources. With specific test cases it will always be null. - /// If there is a parsing error or filter expression has unsupported properties, TestPlatformFormatException() is thrown. - /// - ITestCaseFilterExpression GetTestCaseFilter(IEnumerable supportedProperties, Func propertyProvider); - - /// - /// Directory which should be used for storing result files/deployment files etc. - /// - string TestRunDirectory { get; } - - /// - /// Solution Directory. - /// - string SolutionDirectory { get; } - } -} + string SolutionDirectory { get; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IRunSettings.cs b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IRunSettings.cs index 847836f17c..9dff80a59c 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IRunSettings.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/IRunSettings.cs @@ -1,23 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + +/// +/// Used for loading settings for a run. +/// +public interface IRunSettings { /// - /// Used for loading settings for a run. + /// Get the settings for the provided settings name. /// - public interface IRunSettings - { - /// - /// Get the settings for the provided settings name. - /// - /// Name of the settings section to get. - /// The settings provider for the settings or null if one was not found. - ISettingsProvider GetSettings(string settingsName); + /// Name of the settings section to get. + /// The settings provider for the settings or null if one was not found. + ISettingsProvider GetSettings(string settingsName); - /// - /// Settings used for this run. - /// - string SettingsXml { get; } - } -} + /// + /// Settings used for this run. + /// + string SettingsXml { get; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ISettingsProvider.cs b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ISettingsProvider.cs index 95549db334..3f7ae770b8 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ISettingsProvider.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ISettingsProvider.cs @@ -1,21 +1,20 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter -{ - using System.Xml; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + +using System.Xml; +/// +/// Interface implemented to provide a section in the run settings. A class that +/// implements this interface will be available for use if it exports its type via +/// MEF, and if its containing assembly is placed in the Extensions folder. +/// +public interface ISettingsProvider +{ /// - /// Interface implemented to provide a section in the run settings. A class that - /// implements this interface will be available for use if it exports its type via - /// MEF, and if its containing assembly is placed in the Extensions folder. + /// Load the settings from the reader. /// - public interface ISettingsProvider - { - /// - /// Load the settings from the reader. - /// - /// Reader to load the settings from. - void Load(XmlReader reader); - } -} + /// Reader to load the settings from. + void Load(XmlReader reader); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestCaseDiscoverySink.cs b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestCaseDiscoverySink.cs index 2852239af9..60f43ff33e 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestCaseDiscoverySink.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestCaseDiscoverySink.cs @@ -1,19 +1,18 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + +/// +/// TestCaseDiscovery sink is used by discovery extensions to communicate test cases as they are being discovered, +/// and various discovery related events. +/// +public interface ITestCaseDiscoverySink { /// - /// TestCaseDiscovery sink is used by discovery extensions to communicate test cases as they are being discovered, - /// and various discovery related events. + /// Callback used by discovery extensions to send back testcases as they are being discovered. /// - public interface ITestCaseDiscoverySink - { - /// - /// Callback used by discovery extensions to send back testcases as they are being discovered. - /// - /// New test discovered since last invocation. - void SendTestCase(TestCase discoveredTest); + /// New test discovered since last invocation. + void SendTestCase(TestCase discoveredTest); - } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestCaseFilterExpression.cs b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestCaseFilterExpression.cs index fb9932fc71..9826908f24 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestCaseFilterExpression.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestCaseFilterExpression.cs @@ -1,23 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + +using System; +/// +/// It represents expression for filtering test cases. +/// +public interface ITestCaseFilterExpression +{ /// - /// It represents expression for filtering test cases. + /// Gets original string for test case filter. /// - public interface ITestCaseFilterExpression - { - /// - /// Gets original string for test case filter. - /// - string TestCaseFilterValue { get; } + string TestCaseFilterValue { get; } - /// - /// Matched test case with test case filtering criteria. - /// - bool MatchTestCase(TestCase testCase, Func propertyValueProvider); - } + /// + /// Matched test case with test case filtering criteria. + /// + bool MatchTestCase(TestCase testCase, Func propertyValueProvider); } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestDiscoverer.cs b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestDiscoverer.cs index aa8b710962..269b11d9f5 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestDiscoverer.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestDiscoverer.cs @@ -1,26 +1,26 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter -{ - using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + +using System.Collections.Generic; +using Logging; + +/// +/// Interface implemented to provide tests to the test platform. A class that +// implements this interface will be available for use if its containing +// assembly is either placed in the Extensions folder or is marked as a 'UnitTestExtension' type +// in the vsix package. +/// +public interface ITestDiscoverer +{ /// - /// Interface implemented to provide tests to the test platform. A class that - // implements this interface will be available for use if its containing - // assembly is either placed in the Extensions folder or is marked as a 'UnitTestExtension' type - // in the vsix package. + /// Discovers the tests available from the provided source. /// - public interface ITestDiscoverer - { - /// - /// Discovers the tests available from the provided source. - /// - /// Collection of test containers. - /// Context in which discovery is being performed. - /// Logger used to log messages. - /// Used to send testcases and discovery related events back to Discoverer manager. - void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink); - } -} + /// Collection of test containers. + /// Context in which discovery is being performed. + /// Logger used to log messages. + /// Used to send testcases and discovery related events back to Discoverer manager. + void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestExecutor.cs b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestExecutor.cs index e77686a419..d3ef967d8f 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestExecutor.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestExecutor.cs @@ -1,38 +1,37 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + +using System.Collections.Generic; +/// +/// Defines the test executor which provides capability to run tests. +/// +/// A class that implements this interface will be available for use if its containing +// assembly is either placed in the Extensions folder or is marked as a 'UnitTestExtension' type +// in the vsix package. +/// +public interface ITestExecutor +{ /// - /// Defines the test executor which provides capability to run tests. - /// - /// A class that implements this interface will be available for use if its containing - // assembly is either placed in the Extensions folder or is marked as a 'UnitTestExtension' type - // in the vsix package. + /// Runs only the tests specified by parameter 'tests'. /// - public interface ITestExecutor - { - /// - /// Runs only the tests specified by parameter 'tests'. - /// - /// Tests to be run. - /// Context to use when executing the tests. - /// Handle to the framework to record results and to do framework operations. - void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle); + /// Tests to be run. + /// Context to use when executing the tests. + /// Handle to the framework to record results and to do framework operations. + void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle); - /// - /// Runs 'all' the tests present in the specified 'sources'. - /// - /// Path to test container files to look for tests in. - /// Context to use when executing the tests. - /// Handle to the framework to record results and to do framework operations. - void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle); + /// + /// Runs 'all' the tests present in the specified 'sources'. + /// + /// Path to test container files to look for tests in. + /// Context to use when executing the tests. + /// Handle to the framework to record results and to do framework operations. + void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle); - /// - /// Cancel the execution of the tests. - /// - void Cancel(); - } -} + /// + /// Cancel the execution of the tests. + /// + void Cancel(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestExecutor2.cs b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestExecutor2.cs index 2f3ac9b402..ea3e7abf82 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestExecutor2.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestExecutor2.cs @@ -1,40 +1,38 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter -{ - using System; - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + +using System.Collections.Generic; +/// +/// Defines the test executor which provides capability to run tests. +/// +/// A class that implements this interface will be available for use if its containing +/// assembly is either placed in the Extensions folder or is marked as a 'UnitTestExtension' type +/// in the vsix package. +/// +public interface ITestExecutor2 : ITestExecutor +{ /// - /// Defines the test executor which provides capability to run tests. - /// - /// A class that implements this interface will be available for use if its containing - // assembly is either placed in the Extensions folder or is marked as a 'UnitTestExtension' type - // in the vsix package. + /// Indicates whether or not the default test host process should be attached to. /// - public interface ITestExecutor2 : ITestExecutor - { - /// - /// Indicates whether or not the default test host process should be attached to. - /// - /// Path to test container files to look for tests in. - /// Context to use when executing the tests. - /// - /// if the default test host process should be attached to, - /// otherwise. - /// - bool ShouldAttachToTestHost(IEnumerable sources, IRunContext runContext); + /// Path to test container files to look for tests in. + /// Context to use when executing the tests. + /// + /// if the default test host process should be attached to, + /// otherwise. + /// + bool ShouldAttachToTestHost(IEnumerable sources, IRunContext runContext); - /// - /// Indicates whether or not the default test host process should be attached to. - /// - /// Tests to be run. - /// Context to use when executing the tests. - /// - /// if the default test host process should be attached to, - /// otherwise. - /// - bool ShouldAttachToTestHost(IEnumerable tests, IRunContext runContext); - } -} + /// + /// Indicates whether or not the default test host process should be attached to. + /// + /// Tests to be run. + /// Context to use when executing the tests. + /// + /// if the default test host process should be attached to, + /// otherwise. + /// + bool ShouldAttachToTestHost(IEnumerable tests, IRunContext runContext); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestLog.cs b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestLog.cs index 01a61c541f..c25813f5af 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestLog.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Adapter/Interfaces/ITestLog.cs @@ -1,46 +1,46 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + +using System.Collections.Generic; + +using Logging; + +/// +/// Used for recording test results and test messages. +/// +public interface ITestExecutionRecorder : IMessageLogger { - using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + /// + /// Notify the framework about the test result. + /// + /// Test Result to be sent to the framework. + /// Exception thrown by the framework when an executor attempts to send + /// test result to the framework when the test(s) is canceled. + void RecordResult(TestResult testResult); + + + /// + /// Notify the framework about starting of the test case. + /// Framework sends this event to data collectors enabled in the run. If no data collector is enabled, then the event is ignored. + /// + /// testcase which will be started. + void RecordStart(TestCase testCase); /// - /// Used for recording test results and test messages. + /// Notify the framework about completion of the test case. + /// Framework sends this event to data collectors enabled in the run. If no data collector is enabled, then the event is ignored. /// - public interface ITestExecutionRecorder : IMessageLogger - { - /// - /// Notify the framework about the test result. - /// - /// Test Result to be sent to the framework. - /// Exception thrown by the framework when an executor attempts to send - /// test result to the framework when the test(s) is canceled. - void RecordResult(TestResult testResult); - - - /// - /// Notify the framework about starting of the test case. - /// Framework sends this event to data collectors enabled in the run. If no data collector is enabled, then the event is ignored. - /// - /// testcase which will be started. - void RecordStart(TestCase testCase); - - /// - /// Notify the framework about completion of the test case. - /// Framework sends this event to data collectors enabled in the run. If no data collector is enabled, then the event is ignored. - /// - /// testcase which has completed. - /// outcome of the test case. - void RecordEnd(TestCase testCase, TestOutcome outcome); - - - /// - /// Notify the framework about run level attachments. - /// - /// attachments produced in this run. - void RecordAttachments(IList attachmentSets); - - } -} + /// testcase which has completed. + /// outcome of the test case. + void RecordEnd(TestCase testCase, TestOutcome outcome); + + + /// + /// Notify the framework about run level attachments. + /// + /// attachments produced in this run. + void RecordAttachments(IList attachmentSets); + +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Adapter/TestPlatformFormatException.cs b/src/Microsoft.TestPlatform.ObjectModel/Adapter/TestPlatformFormatException.cs index 65fa9f9de8..da50e59f46 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Adapter/TestPlatformFormatException.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Adapter/TestPlatformFormatException.cs @@ -1,100 +1,101 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + +using System; +#if NETFRAMEWORK +using System.Runtime.Serialization; +#endif + +/// +/// Exception thrown on parsing error in user provided filter expression. +/// This can happen when filter has invalid format or has unsupported properties. +/// +#if NETFRAMEWORK +[Serializable] +#endif +public class TestPlatformFormatException : Exception { - using System; - using System.Runtime.Serialization; + #region Constructors /// - /// Exception thrown on parsing error in user provided filter expression. - /// This can happen when filter has invalid format or has unsupported properties. + /// Creates a new TestPlatformFormatException /// -#if NETFRAMEWORK - [Serializable] -#endif - public class TestPlatformFormatException : Exception + public TestPlatformFormatException() + : base() { - #region Constructors - - /// - /// Creates a new TestPlatformFormatException - /// - public TestPlatformFormatException() - : base() - { - } + } - /// - /// Initializes with the message. - /// - /// Message for the exception. - public TestPlatformFormatException(string message) - : base(message) - { - } + /// + /// Initializes with the message. + /// + /// Message for the exception. + public TestPlatformFormatException(string message) + : base(message) + { + } - /// - /// Initializes with the message and filter string. - /// - /// Message for the exception. - /// Filter expression. - public TestPlatformFormatException(string message, string filterValue) - : base(message) - { - FilterValue = filterValue; - } + /// + /// Initializes with the message and filter string. + /// + /// Message for the exception. + /// Filter expression. + public TestPlatformFormatException(string message, string filterValue) + : base(message) + { + FilterValue = filterValue; + } - /// - /// Initializes with message and inner exception. - /// - /// Message for the exception. - /// The inner exception. - public TestPlatformFormatException(string message, Exception innerException) - : base(message, innerException) - { - } + /// + /// Initializes with message and inner exception. + /// + /// Message for the exception. + /// The inner exception. + public TestPlatformFormatException(string message, Exception innerException) + : base(message, innerException) + { + } #if NETFRAMEWORK - /// - /// Serialization constructor. - /// - protected TestPlatformFormatException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - ValidateArg.NotNull(info, nameof(info)); - // Save the basic properties. - this.FilterValue = info.GetString("FilterValue"); - } + /// + /// Serialization constructor. + /// + protected TestPlatformFormatException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + ValidateArg.NotNull(info, nameof(info)); + // Save the basic properties. + FilterValue = info.GetString("FilterValue"); + } #endif - #endregion + #endregion - /// - /// Filter expression. - /// - public string FilterValue - { - get; - private set; - } + /// + /// Filter expression. + /// + public string FilterValue + { + get; + private set; + } #if NETFRAMEWORK - /// - /// Serialization helper. - /// - /// Serialization info to add to - /// not used - public override void GetObjectData(SerializationInfo info, StreamingContext context) + /// + /// Serialization helper. + /// + /// Serialization info to add to + /// not used + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + if (info == null) { - if (info == null) - { - throw new ArgumentNullException(nameof(info)); - } - - base.GetObjectData(info, context); - info.AddValue("FilterValue", this.FilterValue); + throw new ArgumentNullException(nameof(info)); } -#endif + + base.GetObjectData(info, context); + info.AddValue("FilterValue", FilterValue); } -} +#endif +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Adapter/TestsCanceledException.cs b/src/Microsoft.TestPlatform.ObjectModel/Adapter/TestsCanceledException.cs index 5b09bce3ec..9b83d2fb36 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Adapter/TestsCanceledException.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Adapter/TestsCanceledException.cs @@ -1,61 +1,60 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; + +using System; #if NETFRAMEWORK - using System.Runtime.Serialization; +using System.Runtime.Serialization; #endif - /// - /// Exception thrown by the framework when an executor attempts to send - /// test result to the framework when the test is canceled. - /// +/// +/// Exception thrown by the framework when an executor attempts to send +/// test result to the framework when the test is canceled. +/// #if NETFRAMEWORK - [Serializable] +[Serializable] #endif - public class TestCanceledException : Exception +public class TestCanceledException : Exception +{ + #region Constructors + + /// + /// Creates a new TestCanceledException + /// + public TestCanceledException() + { + } + + /// + /// Initializes with the message. + /// + /// Message for the exception. + public TestCanceledException(string message) + : base(message) + { + } + + /// + /// Initializes with message and inner exception. + /// + /// Message for the exception. + /// The inner exception. + public TestCanceledException(string message, Exception innerException) + : base(message, innerException) { -#region Constructors - - /// - /// Creates a new TestCanceledException - /// - public TestCanceledException() - { - } - - /// - /// Initializes with the message. - /// - /// Message for the exception. - public TestCanceledException(string message) - : base(message) - { - } - - /// - /// Initializes with message and inner exception. - /// - /// Message for the exception. - /// The inner exception. - public TestCanceledException(string message, Exception innerException) - : base(message, innerException) - { - } + } #if NETFRAMEWORK - /// - /// Serialization constructor. - /// - protected TestCanceledException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } + /// + /// Serialization constructor. + /// + protected TestCanceledException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } #endif -#endregion - } -} + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Architecture.cs b/src/Microsoft.TestPlatform.ObjectModel/Architecture.cs index 8d3fc386e0..58de3ae0ed 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Architecture.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Architecture.cs @@ -1,15 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +public enum Architecture { - public enum Architecture - { - Default, - X86, - X64, - ARM, - AnyCPU, - ARM64, - } -} + Default, + X86, + X64, + ARM, + AnyCPU, + ARM64, +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/AttachmentSet.cs b/src/Microsoft.TestPlatform.ObjectModel/AttachmentSet.cs index 3cdd52665a..edad6d815f 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/AttachmentSet.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/AttachmentSet.cs @@ -1,87 +1,86 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; - using System.Collections.Generic; - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +/// +/// Represents a set of attachments. +/// +[DataContract] +public class AttachmentSet +{ /// - /// Represents a set of attachments. + /// URI of the sender. + /// If a data-collector is sending this set, then it should be uri of the data collector. Also if an + /// executor is sending this attachment, then it should be uri of executor. /// - [DataContract] - public class AttachmentSet - { - /// - /// URI of the sender. - /// If a data-collector is sending this set, then it should be uri of the data collector. Also if an - /// executor is sending this attachment, then it should be uri of executor. - /// - [DataMember] - public Uri Uri {get; private set;} + [DataMember] + public Uri Uri { get; private set; } - /// - /// Name of the sender. - /// - [DataMember] - public string DisplayName {get; private set;} + /// + /// Name of the sender. + /// + [DataMember] + public string DisplayName { get; private set; } - /// - /// List of data attachments. - /// These attachments can be things such as files that the collector/adapter wants to make available to the publishers. - /// - [DataMember] - public IList Attachments {get; private set;} + /// + /// List of data attachments. + /// These attachments can be things such as files that the collector/adapter wants to make available to the publishers. + /// + [DataMember] + public IList Attachments { get; private set; } - public AttachmentSet(Uri uri, string displayName) - { - Uri = uri; - DisplayName = displayName; - Attachments = new List(); - } + public AttachmentSet(Uri uri, string displayName) + { + Uri = uri; + DisplayName = displayName; + Attachments = new List(); + } - public override string ToString() - { - return $"{nameof(Uri)}: {Uri.AbsoluteUri}, {nameof(DisplayName)}: {DisplayName}, {nameof(Attachments)}: [{ string.Join(",", Attachments)}]"; - } + public override string ToString() + { + return $"{nameof(Uri)}: {Uri.AbsoluteUri}, {nameof(DisplayName)}: {DisplayName}, {nameof(Attachments)}: [{ string.Join(",", Attachments)}]"; } +} +/// +/// Defines the data attachment. +/// Dev10 equivalent is UriDataAttachment. +/// +[DataContract] +public class UriDataAttachment +{ /// - /// Defines the data attachment. - /// Dev10 equivalent is UriDataAttachment. + /// Description of the attachment. /// - [DataContract] - public class UriDataAttachment - { - /// - /// Description of the attachment. - /// - [DataMember] - public string Description { get; private set; } + [DataMember] + public string Description { get; private set; } - /// - /// Uri of the attachment. - /// - [DataMember] - public Uri Uri { get; private set; } + /// + /// Uri of the attachment. + /// + [DataMember] + public Uri Uri { get; private set; } - public UriDataAttachment(Uri uri, string description) - { - Uri = uri; - Description = description; - } + public UriDataAttachment(Uri uri, string description) + { + Uri = uri; + Description = description; + } - public override string ToString() - { - return $"{nameof(Uri)}: {Uri.AbsoluteUri}, {nameof(Description)}: {Description}"; - } + public override string ToString() + { + return $"{nameof(Uri)}: {Uri.AbsoluteUri}, {nameof(Description)}: {Description}"; + } - public static UriDataAttachment CreateFrom(string localFilePath, string description) - { - var uri = new UriBuilder() { Scheme = "file", Host = "", Path = localFilePath }.Uri; - return new UriDataAttachment(uri, description); - } + public static UriDataAttachment CreateFrom(string localFilePath, string description) + { + var uri = new UriBuilder() { Scheme = "file", Host = "", Path = localFilePath }.Uri; + return new UriDataAttachment(uri, description); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/DiscoveryCriteria.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/DiscoveryCriteria.cs index b9b53c21c3..5493f897be 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/DiscoveryCriteria.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/DiscoveryCriteria.cs @@ -1,188 +1,189 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +using Resources; + +/// +/// Defines the discovery criterion. +/// +[DataContract] +public class DiscoveryCriteria { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Runtime.Serialization; + /// + /// Initializes a new instance of the class. + /// + /// This constructor doesn't perform any parameter validation, it is meant to be used for serialization."/> + public DiscoveryCriteria() + { + // Parameterless constructor is used for Serialization. + } - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources; + /// + /// Initializes a new instance of the class. + /// + /// + /// Sources from which the tests should be discovered. + /// + /// + /// Frequency of discovered test event. This is used for batching discovered tests. + /// + /// + /// Test configuration provided by user. + /// + public DiscoveryCriteria( + IEnumerable sources, + long frequencyOfDiscoveredTestsEvent, + string testSettings) + : this( + sources, + frequencyOfDiscoveredTestsEvent, + TimeSpan.MaxValue, + testSettings) + { } /// - /// Defines the discovery criterion. + /// Initializes a new instance of the class. /// - [DataContract] - public class DiscoveryCriteria + /// + /// Sources from which the tests should be discovered + /// + /// + /// Frequency of discovered test event. This is used for batching discovered tests. + /// + /// + /// Timeout that triggers the discovered test event regardless of cache size. + /// + /// + /// Run Settings for the discovery. + /// + public DiscoveryCriteria( + IEnumerable sources, + long frequencyOfDiscoveredTestsEvent, + TimeSpan discoveredTestEventTimeout, + string runSettings) + : this( + sources, + frequencyOfDiscoveredTestsEvent, + discoveredTestEventTimeout, + runSettings, + testSessionInfo: null) + { } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Sources from which the tests should be discovered + /// + /// + /// Frequency of discovered test event. This is used for batching discovered tests. + /// + /// + /// Timeout that triggers the discovered test event regardless of cache size. + /// + /// + /// Run Settings for the discovery. + /// + /// The test session info object. + public DiscoveryCriteria( + IEnumerable sources, + long frequencyOfDiscoveredTestsEvent, + TimeSpan discoveredTestEventTimeout, + string runSettings, + TestSessionInfo testSessionInfo) { - /// - /// Initializes a new instance of the class. - /// - /// This constructor doesn't perform any parameter validation, it is meant to be used for serialization."/> - public DiscoveryCriteria() + ValidateArg.NotNullOrEmpty(sources, nameof(sources)); + if (frequencyOfDiscoveredTestsEvent <= 0) { - // Parameterless constructor is used for Serialization. + throw new ArgumentOutOfRangeException( + nameof(frequencyOfDiscoveredTestsEvent), + Resources.NotificationFrequencyIsNotPositive); } - /// - /// Initializes a new instance of the class. - /// - /// - /// Sources from which the tests should be discovered. - /// - /// - /// Frequency of discovered test event. This is used for batching discovered tests. - /// - /// - /// Test configuration provided by user. - /// - public DiscoveryCriteria( - IEnumerable sources, - long frequencyOfDiscoveredTestsEvent, - string testSettings) - : this( - sources, - frequencyOfDiscoveredTestsEvent, - TimeSpan.MaxValue, - testSettings) - { } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Sources from which the tests should be discovered - /// - /// - /// Frequency of discovered test event. This is used for batching discovered tests. - /// - /// - /// Timeout that triggers the discovered test event regardless of cache size. - /// - /// - /// Run Settings for the discovery. - /// - public DiscoveryCriteria( - IEnumerable sources, - long frequencyOfDiscoveredTestsEvent, - TimeSpan discoveredTestEventTimeout, - string runSettings) - : this( - sources, - frequencyOfDiscoveredTestsEvent, - discoveredTestEventTimeout, - runSettings, - testSessionInfo: null) - { } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Sources from which the tests should be discovered - /// - /// - /// Frequency of discovered test event. This is used for batching discovered tests. - /// - /// - /// Timeout that triggers the discovered test event regardless of cache size. - /// - /// - /// Run Settings for the discovery. - /// - /// The test session info object. - public DiscoveryCriteria( - IEnumerable sources, - long frequencyOfDiscoveredTestsEvent, - TimeSpan discoveredTestEventTimeout, - string runSettings, - TestSessionInfo testSessionInfo) + if (discoveredTestEventTimeout <= TimeSpan.MinValue) { - ValidateArg.NotNullOrEmpty(sources, nameof(sources)); - if (frequencyOfDiscoveredTestsEvent <= 0) - { - throw new ArgumentOutOfRangeException( - nameof(frequencyOfDiscoveredTestsEvent), - Resources.NotificationFrequencyIsNotPositive); - } - - if (discoveredTestEventTimeout <= TimeSpan.MinValue) - { - throw new ArgumentOutOfRangeException(nameof(discoveredTestEventTimeout), Resources.NotificationTimeoutIsZero); - } - - this.AdapterSourceMap = new Dictionary>(); - this.AdapterSourceMap.Add(Constants.UnspecifiedAdapterPath, sources); - this.FrequencyOfDiscoveredTestsEvent = frequencyOfDiscoveredTestsEvent; - this.DiscoveredTestEventTimeout = discoveredTestEventTimeout; - - this.RunSettings = runSettings; - this.TestSessionInfo = testSessionInfo; + throw new ArgumentOutOfRangeException(nameof(discoveredTestEventTimeout), Resources.NotificationTimeoutIsZero); } - /// - /// Gets the test Containers (e.g. DLL/EXE/artifacts to scan) - /// - [IgnoreDataMember] - public IEnumerable Sources + AdapterSourceMap = new Dictionary> { - get - { - IEnumerable sources = new List(); - return this.AdapterSourceMap.Values.Aggregate(sources, (current, enumerable) => current.Concat(enumerable)); - } - } + { Constants.UnspecifiedAdapterPath, sources } + }; + FrequencyOfDiscoveredTestsEvent = frequencyOfDiscoveredTestsEvent; + DiscoveredTestEventTimeout = discoveredTestEventTimeout; - /// - /// Gets the test Containers (e.g. .appx, .appxrecipie) - /// - [DataMember] - public string Package { get; set; } - - /// - /// Gets the test adapter and source map which would look like below: - /// - /// { C:\temp\testAdapter1.dll : [ source1.dll, source2.dll ], C:\temp\testadapter2.dll : [ source3.dll, source2.dll ] - /// - /// - [DataMember] - public Dictionary> AdapterSourceMap { get; private set; } - - /// - /// Gets the frequency of discovered test event. - /// - /// - /// Discovered test event will be raised after discovering these number of tests. - /// Note that this event is raised asynchronously and the underlying discovery process is not - /// paused during the listener invocation. So if the event handler, you try to query the - /// next set of tests, you may get more than 'FrequencyOfDiscoveredTestsEvent'. - /// - [DataMember] - public long FrequencyOfDiscoveredTestsEvent { get; private set; } - - /// - /// Gets the timeout that triggers the discovered test event regardless of cache size. - /// - [DataMember] - public TimeSpan DiscoveredTestEventTimeout { get; private set; } - - /// - /// Gets the test settings used for the discovery request. - /// - [DataMember] - public string RunSettings { get; private set; } - - /// - /// Gets or sets the criteria for filtering test cases. - /// - [DataMember] - public string TestCaseFilter { get; set; } - - /// - /// Gets or sets the test session info object. - /// - [DataMember] - public TestSessionInfo TestSessionInfo { get; set; } + RunSettings = runSettings; + TestSessionInfo = testSessionInfo; + } + + /// + /// Gets the test Containers (e.g. DLL/EXE/artifacts to scan) + /// + [IgnoreDataMember] + public IEnumerable Sources + { + get + { + IEnumerable sources = new List(); + return AdapterSourceMap.Values.Aggregate(sources, (current, enumerable) => current.Concat(enumerable)); + } } -} + + /// + /// Gets the test Containers (e.g. .appx, .appxrecipie) + /// + [DataMember] + public string Package { get; set; } + + /// + /// Gets the test adapter and source map which would look like below: + /// + /// { C:\temp\testAdapter1.dll : [ source1.dll, source2.dll ], C:\temp\testadapter2.dll : [ source3.dll, source2.dll ] + /// + /// + [DataMember] + public Dictionary> AdapterSourceMap { get; private set; } + + /// + /// Gets the frequency of discovered test event. + /// + /// + /// Discovered test event will be raised after discovering these number of tests. + /// Note that this event is raised asynchronously and the underlying discovery process is not + /// paused during the listener invocation. So if the event handler, you try to query the + /// next set of tests, you may get more than 'FrequencyOfDiscoveredTestsEvent'. + /// + [DataMember] + public long FrequencyOfDiscoveredTestsEvent { get; private set; } + + /// + /// Gets the timeout that triggers the discovered test event regardless of cache size. + /// + [DataMember] + public TimeSpan DiscoveredTestEventTimeout { get; private set; } + + /// + /// Gets the test settings used for the discovery request. + /// + [DataMember] + public string RunSettings { get; private set; } + + /// + /// Gets or sets the criteria for filtering test cases. + /// + [DataMember] + public string TestCaseFilter { get; set; } + + /// + /// Gets or sets the test session info object. + /// + [DataMember] + public TestSessionInfo TestSessionInfo { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/DiscoveredTestsEventArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/DiscoveredTestsEventArgs.cs index 2517c56372..83c8a3fea9 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/DiscoveredTestsEventArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/DiscoveredTestsEventArgs.cs @@ -1,23 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System; - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - /// - /// Event arguments used to notify the availability of new tests - /// - public partial class DiscoveredTestsEventArgs : EventArgs +using System; +using System.Collections.Generic; + +/// +/// Event arguments used to notify the availability of new tests +/// +public partial class DiscoveredTestsEventArgs : EventArgs +{ + public DiscoveredTestsEventArgs(IEnumerable discoveredTestCases) { - public DiscoveredTestsEventArgs(IEnumerable discoveredTestCases) - { - DiscoveredTestCases = discoveredTestCases; - } - /// - /// Tests discovered in this discovery request - /// - public IEnumerable DiscoveredTestCases { get; private set; } + DiscoveredTestCases = discoveredTestCases; } -} + /// + /// Tests discovered in this discovery request + /// + public IEnumerable DiscoveredTestCases { get; private set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/DiscoveryCompleteEventArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/DiscoveryCompleteEventArgs.cs index a17323a347..ed3127e6b8 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/DiscoveryCompleteEventArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/DiscoveryCompleteEventArgs.cs @@ -1,46 +1,45 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System; - using System.Collections.Generic; - using System.Diagnostics; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +/// +/// Event arguments used on completion of discovery +/// +public class DiscoveryCompleteEventArgs : EventArgs +{ /// - /// Event arguments used on completion of discovery + /// Constructor for creating event args object /// - public class DiscoveryCompleteEventArgs : EventArgs + /// Total tests which got discovered + /// Specifies if discovery has been aborted. + public DiscoveryCompleteEventArgs(long totalTests, bool isAborted) { - /// - /// Constructor for creating event args object - /// - /// Total tests which got discovered - /// Specifies if discovery has been aborted. - public DiscoveryCompleteEventArgs(long totalTests, bool isAborted) - { - // This event is always raised from the client side, while the total count of tests is maintained - // only at the testhost end. In case of a discovery abort (various reasons including crash), it is - // not possible to get a list of total tests from testhost. Hence we enforce a -1 count. - Debug.Assert((isAborted ? -1 == totalTests : true), "If discovery request is aborted totalTest should be -1."); + // This event is always raised from the client side, while the total count of tests is maintained + // only at the testhost end. In case of a discovery abort (various reasons including crash), it is + // not possible to get a list of total tests from testhost. Hence we enforce a -1 count. + Debug.Assert((!isAborted || -1 == totalTests), "If discovery request is aborted totalTest should be -1."); - this.TotalCount = totalTests; - this.IsAborted = isAborted; - } + TotalCount = totalTests; + IsAborted = isAborted; + } - /// - /// Indicates the total tests which got discovered in this request. - /// - public long TotalCount { get; private set; } + /// + /// Indicates the total tests which got discovered in this request. + /// + public long TotalCount { get; private set; } - /// - /// Specifies if discovery has been aborted. If true TotalCount is also set to -1. - /// - public bool IsAborted { get; private set; } + /// + /// Specifies if discovery has been aborted. If true TotalCount is also set to -1. + /// + public bool IsAborted { get; private set; } - /// - /// Metrics - /// - public IDictionary Metrics { get; set; } - } -} + /// + /// Metrics + /// + public IDictionary Metrics { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/DiscoveryStartEventArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/DiscoveryStartEventArgs.cs index 2a84ef9258..50d970bdad 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/DiscoveryStartEventArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/DiscoveryStartEventArgs.cs @@ -1,27 +1,26 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System; +/// +/// Event arguments used when test discovery starts +/// +public class DiscoveryStartEventArgs : EventArgs +{ /// - /// Event arguments used when test discovery starts + /// Constructor for creating event args object /// - public class DiscoveryStartEventArgs : EventArgs + /// Discovery criteria to be used for test discovery. + public DiscoveryStartEventArgs(DiscoveryCriteria discoveryCriteria) { - /// - /// Constructor for creating event args object - /// - /// Discovery criteria to be used for test discovery. - public DiscoveryStartEventArgs(DiscoveryCriteria discoveryCriteria) - { - DiscoveryCriteria = discoveryCriteria; - } - - /// - /// Discovery criteria to be used for test discovery - /// - public DiscoveryCriteria DiscoveryCriteria { get; private set; } + DiscoveryCriteria = discoveryCriteria; } -} + + /// + /// Discovery criteria to be used for test discovery + /// + public DiscoveryCriteria DiscoveryCriteria { get; private set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunAttachmentsProcessingCompleteEventArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunAttachmentsProcessingCompleteEventArgs.cs index b5e446ff68..dcce08c0bd 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunAttachmentsProcessingCompleteEventArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunAttachmentsProcessingCompleteEventArgs.cs @@ -1,42 +1,41 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System; - using System.Collections.Generic; - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; - [DataContract] - public class TestRunAttachmentsProcessingCompleteEventArgs : EventArgs +[DataContract] +public class TestRunAttachmentsProcessingCompleteEventArgs : EventArgs +{ + /// + /// Default constructor. + /// + /// Specifies whether the attachments processing is canceled. + /// Specifies the error encountered during the execution of the attachments processing. + public TestRunAttachmentsProcessingCompleteEventArgs(bool isCanceled, Exception error) { - /// - /// Default constructor. - /// - /// Specifies whether the attachments processing is canceled. - /// Specifies the error encountered during the execution of the attachments processing. - public TestRunAttachmentsProcessingCompleteEventArgs(bool isCanceled, Exception error) - { - this.IsCanceled = isCanceled; - this.Error = error; - } + IsCanceled = isCanceled; + Error = error; + } - /// - /// Gets a value indicating whether the attachments processing is canceled or not. - /// - [DataMember] - public bool IsCanceled { get; private set; } + /// + /// Gets a value indicating whether the attachments processing is canceled or not. + /// + [DataMember] + public bool IsCanceled { get; private set; } - /// - /// Gets the error encountered during the attachments processing of the test runs. Null if there is no error. - /// - [DataMember] - public Exception Error { get; private set; } + /// + /// Gets the error encountered during the attachments processing of the test runs. Null if there is no error. + /// + [DataMember] + public Exception Error { get; private set; } - /// - /// Get or Sets the Metrics (used for telemetry) - /// - [DataMember] - public IDictionary Metrics { get; set; } - } -} + /// + /// Get or Sets the Metrics (used for telemetry) + /// + [DataMember] + public IDictionary Metrics { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunAttachmentsProcessingProgressEventArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunAttachmentsProcessingProgressEventArgs.cs index 8218336e5b..7ce71945fe 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunAttachmentsProcessingProgressEventArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunAttachmentsProcessingProgressEventArgs.cs @@ -1,52 +1,51 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System; - using System.Collections.Generic; - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; - [DataContract] - public class TestRunAttachmentsProcessingProgressEventArgs : EventArgs +[DataContract] +public class TestRunAttachmentsProcessingProgressEventArgs : EventArgs +{ + /// + /// Default constructor. + /// + /// Specifies current attachment processor index. + /// Specifies current processor Uris. + /// Specifies current processor progress. + /// Specifies the overall number of processors. + public TestRunAttachmentsProcessingProgressEventArgs(long currentAttachmentProcessorIndex, ICollection currentAttachmentProcessorUris, long currentAttachmentProcessorProgress, long attachmentProcessorsCount) { - /// - /// Default constructor. - /// - /// Specifies current attachment processor index. - /// Specifies current processor Uris. - /// Specifies current processor progress. - /// Specifies the overall number of processors. - public TestRunAttachmentsProcessingProgressEventArgs(long currentAttachmentProcessorIndex, ICollection currentAttachmentProcessorUris, long currentAttachmentProcessorProgress, long attachmentProcessorsCount) - { - CurrentAttachmentProcessorIndex = currentAttachmentProcessorIndex; - CurrentAttachmentProcessorUris = currentAttachmentProcessorUris; - CurrentAttachmentProcessorProgress = currentAttachmentProcessorProgress; - AttachmentProcessorsCount = attachmentProcessorsCount; - } + CurrentAttachmentProcessorIndex = currentAttachmentProcessorIndex; + CurrentAttachmentProcessorUris = currentAttachmentProcessorUris; + CurrentAttachmentProcessorProgress = currentAttachmentProcessorProgress; + AttachmentProcessorsCount = attachmentProcessorsCount; + } - /// - /// Gets a current attachment processor index. - /// - [DataMember] - public long CurrentAttachmentProcessorIndex { get; private set; } + /// + /// Gets a current attachment processor index. + /// + [DataMember] + public long CurrentAttachmentProcessorIndex { get; private set; } - /// - /// Gets a current attachment processor URI. - /// - [DataMember] - public ICollection CurrentAttachmentProcessorUris { get; private set; } + /// + /// Gets a current attachment processor URI. + /// + [DataMember] + public ICollection CurrentAttachmentProcessorUris { get; private set; } - /// - /// Gets a current attachment processor progress. - /// - [DataMember] - public long CurrentAttachmentProcessorProgress { get; private set; } + /// + /// Gets a current attachment processor progress. + /// + [DataMember] + public long CurrentAttachmentProcessorProgress { get; private set; } - /// - /// Gets the overall number of attachment processors. - /// - [DataMember] - public long AttachmentProcessorsCount { get; private set; } - } -} + /// + /// Gets the overall number of attachment processors. + /// + [DataMember] + public long AttachmentProcessorsCount { get; private set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunChangedEventArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunChangedEventArgs.cs index 89b672193e..13f283cb40 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunChangedEventArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunChangedEventArgs.cs @@ -1,47 +1,46 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System; - using System.Collections.Generic; - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +/// +/// The test run changed event args that provides the test results available. +/// +[DataContract] +public class TestRunChangedEventArgs : EventArgs +{ /// - /// The test run changed event args that provides the test results available. + /// Initializes a new instance of the class. /// - [DataContract] - public class TestRunChangedEventArgs : EventArgs + /// The stats. + /// The new test results. + /// The active tests. + public TestRunChangedEventArgs(ITestRunStatistics stats, IEnumerable newTestResults, IEnumerable activeTests) { - /// - /// Initializes a new instance of the class. - /// - /// The stats. - /// The new test results. - /// The active tests. - public TestRunChangedEventArgs(ITestRunStatistics stats, IEnumerable newTestResults, IEnumerable activeTests) - { - this.TestRunStatistics = stats; - this.NewTestResults = newTestResults; - this.ActiveTests = activeTests; - } + TestRunStatistics = stats; + NewTestResults = newTestResults; + ActiveTests = activeTests; + } - /// - /// Gets the new test results. - /// - [DataMember] - public IEnumerable NewTestResults { get; private set; } + /// + /// Gets the new test results. + /// + [DataMember] + public IEnumerable NewTestResults { get; private set; } - /// - /// Gets the test run statistics. - /// - [DataMember] - public ITestRunStatistics TestRunStatistics { get; private set; } + /// + /// Gets the test run statistics. + /// + [DataMember] + public ITestRunStatistics TestRunStatistics { get; private set; } - /// - /// Gets the active tests. - /// - [DataMember] - public IEnumerable ActiveTests { get; private set; } - } -} + /// + /// Gets the active tests. + /// + [DataMember] + public IEnumerable ActiveTests { get; private set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunCompleteEventArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunCompleteEventArgs.cs index cd371d0aac..f8607441d8 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunCompleteEventArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunCompleteEventArgs.cs @@ -1,108 +1,107 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; + +/// +/// Event arguments used when a test run has completed. +/// +[DataContract] +public class TestRunCompleteEventArgs : EventArgs { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Runtime.Serialization; + // We have more than one ctor for backward-compatibility reason but we don't want to add dependency on Newtosoft([JsonConstructor]) + // We want to fallback to the non-public default constructor https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_ConstructorHandling.htm during deserialization + private TestRunCompleteEventArgs() + { + AttachmentSets = new Collection(); + InvokedDataCollectors = new Collection(); + } /// - /// Event arguments used when a test run has completed. + /// Default constructor. /// - [DataContract] - public class TestRunCompleteEventArgs : EventArgs - { - // We have more than one ctor for backward-compatibility reason but we don't want to add dependency on Newtosoft([JsonConstructor]) - // We want to fallback to the non-public default constructor https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_ConstructorHandling.htm during deserialization - private TestRunCompleteEventArgs() - { - this.AttachmentSets = new Collection(); - this.InvokedDataCollectors = new Collection(); - } - - /// - /// Default constructor. - /// - /// The final stats for the test run. This parameter is only set for communications between the test host and the clients (like VS) - /// Specifies whether the test run is canceled. - /// Specifies whether the test run is aborted. - /// Specifies the error encountered during the execution of the test run. - /// Attachment sets associated with the run. - /// Time elapsed in just running tests - public TestRunCompleteEventArgs(ITestRunStatistics stats, bool isCanceled, bool isAborted, Exception error, Collection attachmentSets, TimeSpan elapsedTime) - : this(stats, isCanceled, isAborted, error, attachmentSets, null, elapsedTime) - { } + /// The final stats for the test run. This parameter is only set for communications between the test host and the clients (like VS) + /// Specifies whether the test run is canceled. + /// Specifies whether the test run is aborted. + /// Specifies the error encountered during the execution of the test run. + /// Attachment sets associated with the run. + /// Time elapsed in just running tests + public TestRunCompleteEventArgs(ITestRunStatistics stats, bool isCanceled, bool isAborted, Exception error, Collection attachmentSets, TimeSpan elapsedTime) + : this(stats, isCanceled, isAborted, error, attachmentSets, null, elapsedTime) + { } - /// - /// Default constructor. - /// - /// The final stats for the test run. This parameter is only set for communications between the test host and the clients (like VS) - /// Specifies whether the test run is canceled. - /// Specifies whether the test run is aborted. - /// Specifies the error encountered during the execution of the test run. - /// Attachment sets associated with the run. - /// Invoked data collectors - /// Time elapsed in just running tests - public TestRunCompleteEventArgs(ITestRunStatistics stats, bool isCanceled, bool isAborted, Exception error, Collection attachmentSets, Collection invokedDataCollectors, TimeSpan elapsedTime) - { - this.TestRunStatistics = stats; - this.IsCanceled = isCanceled; - this.IsAborted = isAborted; - this.Error = error; - this.AttachmentSets = attachmentSets ?? new Collection(); // Ensuring attachmentSets are not null, so that new attachmentSets can be combined whenever required. - this.InvokedDataCollectors = invokedDataCollectors ?? new Collection(); // Ensuring that invoked data collectors are not null. - this.ElapsedTimeInRunningTests = elapsedTime; - } + /// + /// Default constructor. + /// + /// The final stats for the test run. This parameter is only set for communications between the test host and the clients (like VS) + /// Specifies whether the test run is canceled. + /// Specifies whether the test run is aborted. + /// Specifies the error encountered during the execution of the test run. + /// Attachment sets associated with the run. + /// Invoked data collectors + /// Time elapsed in just running tests + public TestRunCompleteEventArgs(ITestRunStatistics stats, bool isCanceled, bool isAborted, Exception error, Collection attachmentSets, Collection invokedDataCollectors, TimeSpan elapsedTime) + { + TestRunStatistics = stats; + IsCanceled = isCanceled; + IsAborted = isAborted; + Error = error; + AttachmentSets = attachmentSets ?? new Collection(); // Ensuring attachmentSets are not null, so that new attachmentSets can be combined whenever required. + InvokedDataCollectors = invokedDataCollectors ?? new Collection(); // Ensuring that invoked data collectors are not null. + ElapsedTimeInRunningTests = elapsedTime; + } - /// - /// Gets the statistics on the state of the test run. - /// - [DataMember] - public ITestRunStatistics TestRunStatistics { get; private set; } + /// + /// Gets the statistics on the state of the test run. + /// + [DataMember] + public ITestRunStatistics TestRunStatistics { get; private set; } - /// - /// Gets a value indicating whether the test run is canceled or not. - /// - [DataMember] - public bool IsCanceled { get; private set; } + /// + /// Gets a value indicating whether the test run is canceled or not. + /// + [DataMember] + public bool IsCanceled { get; private set; } - /// - /// Gets a value indicating whether the test run is aborted. - /// - [DataMember] - public bool IsAborted { get; private set; } + /// + /// Gets a value indicating whether the test run is aborted. + /// + [DataMember] + public bool IsAborted { get; private set; } - /// - /// Gets the error encountered during the execution of the test run. Null if there is no error. - /// - [DataMember] - public Exception Error { get; private set; } + /// + /// Gets the error encountered during the execution of the test run. Null if there is no error. + /// + [DataMember] + public Exception Error { get; private set; } - /// - /// Gets the attachment sets associated with the test run. - /// - [DataMember] - public Collection AttachmentSets { get; private set; } + /// + /// Gets the attachment sets associated with the test run. + /// + [DataMember] + public Collection AttachmentSets { get; private set; } - /// - /// Gets the invoked data collectors for the test session. - /// - [DataMember] - public Collection InvokedDataCollectors { get; private set; } + /// + /// Gets the invoked data collectors for the test session. + /// + [DataMember] + public Collection InvokedDataCollectors { get; private set; } - /// - /// Gets the time elapsed in just running the tests. - /// Value is set to TimeSpan.Zero in case of any error. - /// - [DataMember] - public TimeSpan ElapsedTimeInRunningTests { get; private set; } + /// + /// Gets the time elapsed in just running the tests. + /// Value is set to TimeSpan.Zero in case of any error. + /// + [DataMember] + public TimeSpan ElapsedTimeInRunningTests { get; private set; } - /// - /// Get or Sets the Metrics - /// - [DataMember] - public IDictionary Metrics { get; set; } - } -} + /// + /// Get or Sets the Metrics + /// + [DataMember] + public IDictionary Metrics { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunStartEventArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunStartEventArgs.cs index 06320f58a9..ab6ae2a89e 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunStartEventArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/TestRunStartEventArgs.cs @@ -1,27 +1,26 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System; +/// +/// Event arguments used when test run starts +/// +public class TestRunStartEventArgs : EventArgs +{ /// - /// Event arguments used when test run starts + /// Constructor for creating event args object /// - public class TestRunStartEventArgs : EventArgs + /// Test run criteria to be used for test run. + public TestRunStartEventArgs(TestRunCriteria testRunCriteria) { - /// - /// Constructor for creating event args object - /// - /// Test run criteria to be used for test run. - public TestRunStartEventArgs(TestRunCriteria testRunCriteria) - { - TestRunCriteria = testRunCriteria; - } - - /// - /// Test run criteria to be used for test run - /// - public TestRunCriteria TestRunCriteria { get; private set; } + TestRunCriteria = testRunCriteria; } -} + + /// + /// Test run criteria to be used for test run + /// + public TestRunCriteria TestRunCriteria { get; private set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/FilterOptions.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/FilterOptions.cs index 01c7e3bfea..becd1d40ac 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/FilterOptions.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/FilterOptions.cs @@ -1,59 +1,58 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System.Globalization; +using System.Runtime.Serialization; +using System.Text; + +/// +/// Filter options to be passed into the Test Platform during Discovery/Execution. +/// +[DataContract] +public class FilterOptions { - using System.Globalization; - using System.Runtime.Serialization; - using System.Text; + /// + /// Gets or sets the regular expression that will be applied on the property before matching. + /// + [DataMember] + public string FilterRegEx { get; set; } /// - /// Filter options to be passed into the Test Platform during Discovery/Execution. + /// Gets or sets the optional regular expression replacement string. When this property is set, + /// will be called upon property value instead of before matching. /// - [DataContract] - public class FilterOptions + [DataMember] + public string FilterRegExReplacement { get; set; } + + /// + public override string ToString() { - /// - /// Gets or sets the regular expression that will be applied on the property before matching. - /// - [DataMember] - public string FilterRegEx { get; set; } - - /// - /// Gets or sets the optional regular expression replacement string. When this property is set, - /// will be called upon property value instead of before matching. - /// - [DataMember] - public string FilterRegExReplacement { get; set; } - - /// - public override string ToString() - { - StringBuilder sb = new StringBuilder(); - sb.AppendLine(string.Format(CultureInfo.CurrentCulture, "FilterOptions:")); - sb.AppendLine(string.Format(CultureInfo.CurrentCulture, - " FilterRegEx={0} FilterRegExReplacement={1}", - this.FilterRegEx ?? string.Empty, - this.FilterRegExReplacement ?? string.Empty)); - return sb.ToString(); - } + StringBuilder sb = new(); + sb.AppendLine(string.Format(CultureInfo.CurrentCulture, "FilterOptions:")); + sb.AppendLine(string.Format(CultureInfo.CurrentCulture, + " FilterRegEx={0} FilterRegExReplacement={1}", + FilterRegEx ?? string.Empty, + FilterRegExReplacement ?? string.Empty)); + return sb.ToString(); + } - protected bool Equals(FilterOptions other) => - other != null && - string.Equals(this.FilterRegEx, other.FilterRegEx) && - string.Equals(this.FilterRegExReplacement, other.FilterRegExReplacement); + protected bool Equals(FilterOptions other) => + other != null && + string.Equals(FilterRegEx, other.FilterRegEx) && + string.Equals(FilterRegExReplacement, other.FilterRegExReplacement); - /// - public override bool Equals(object obj) => Equals(obj as FilterOptions); + /// + public override bool Equals(object obj) => Equals(obj as FilterOptions); - /// - public override int GetHashCode() + /// + public override int GetHashCode() + { + unchecked { - unchecked - { - var hashCode = this.FilterRegEx.GetHashCode(); - return (hashCode * 397) ^ (this.FilterRegExReplacement != null ? this.FilterRegExReplacement.GetHashCode() : 0); - } + var hashCode = FilterRegEx.GetHashCode(); + return (hashCode * 397) ^ (FilterRegExReplacement != null ? FilterRegExReplacement.GetHashCode() : 0); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IBaseProxy.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IBaseProxy.cs index 838f6d8807..92b1843c33 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IBaseProxy.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IBaseProxy.cs @@ -1,20 +1,19 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +/// +/// Provides basic functionality for the Proxy Operation Manager. +/// +public interface IBaseProxy { /// - /// Provides basic functionality for the Proxy Operation Manager. + /// Updates the test process start info. /// - public interface IBaseProxy - { - /// - /// Updates the test process start info. - /// - /// - /// The test process start info to be updated. - /// - /// The updated test process start info. - TestProcessStartInfo UpdateTestProcessStartInfo(TestProcessStartInfo testProcessStartInfo); - } -} + /// + /// The test process start info to be updated. + /// + /// The updated test process start info. + TestProcessStartInfo UpdateTestProcessStartInfo(TestProcessStartInfo testProcessStartInfo); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IDiscoveryRequest.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IDiscoveryRequest.cs index ce3ab28efc..c93d733c28 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IDiscoveryRequest.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IDiscoveryRequest.cs @@ -1,53 +1,53 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System; + +using Logging; + +/// +/// IDiscoverTestsRequest returned after calling GetDiscoveredTestsAsync +/// +public interface IDiscoveryRequest : IRequest { - using System; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + /// + /// Handler for notifying discovery process is started + /// + event EventHandler OnDiscoveryStart; + + /// + /// Handler for notifying discovery process is complete + /// + event EventHandler OnDiscoveryComplete; + + /// + /// Handler for notifying when newly found tests are available for UI to fetch. + /// + event EventHandler OnDiscoveredTests; /// - /// IDiscoverTestsRequest returned after calling GetDiscoveredTestsAsync + /// Handler for receiving error during fetching/execution. This is used for when abnormal error + /// occurs; equivalent of IRunMessageLogger in the current RockSteady core /// - public interface IDiscoveryRequest : IRequest + event EventHandler OnDiscoveryMessage; + + /// + /// Gets the discovery criterion. + /// + DiscoveryCriteria DiscoveryCriteria { - /// - /// Handler for notifying discovery process is started - /// - event EventHandler OnDiscoveryStart; - - /// - /// Handler for notifying discovery process is complete - /// - event EventHandler OnDiscoveryComplete; - - /// - /// Handler for notifying when newly found tests are available for UI to fetch. - /// - event EventHandler OnDiscoveredTests; - - /// - /// Handler for receiving error during fetching/execution. This is used for when abnormal error - /// occurs; equivalent of IRunMessageLogger in the current RockSteady core - /// - event EventHandler OnDiscoveryMessage; - - /// - /// Gets the discovery criterion. - /// - DiscoveryCriteria DiscoveryCriteria - { - get; - } - - /// - /// Starts tests discovery async. - /// - void DiscoverAsync(); - - /// - /// Aborts the discovery request - /// - void Abort(); + get; } -} + + /// + /// Starts tests discovery async. + /// + void DiscoverAsync(); + + /// + /// Aborts the discovery request + /// + void Abort(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IMetricsCollection.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IMetricsCollection.cs index 91cba93e84..8d0e951f1b 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IMetricsCollection.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IMetricsCollection.cs @@ -1,26 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System.Collections.Generic; +/// +/// This Interface Provides API's to Collect Metrics. +/// +public interface IMetricsCollection +{ /// - /// This Interface Provides API's to Collect Metrics. + /// Add Metric in the Metrics Cache /// - public interface IMetricsCollection - { - /// - /// Add Metric in the Metrics Cache - /// - /// Metric Message - /// Value associated with Metric - void Add(string metric, object value); + /// Metric Message + /// Value associated with Metric + void Add(string metric, object value); - /// - /// Get Metrics - /// - /// Returns the Telemetry Data Points - IDictionary Metrics { get; } - } + /// + /// Get Metrics + /// + /// Returns the Telemetry Data Points + IDictionary Metrics { get; } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IRequest.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IRequest.cs index f9b8613e0b..09eb2453b6 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IRequest.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IRequest.cs @@ -1,43 +1,42 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System; - using System.Threading; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System; +using System.Threading; +/// +/// Represents any request to discover or run tests. +/// +public interface IRequest : IDisposable +{ /// - /// Represents any request to discover or run tests. + /// Handler for receiving raw messages directly from host without any deserialization or morphing + /// This is required if one wants to re-direct the message over the process boundary without any processing overhead + /// All events should come as raw messages as well as actual serialized events /// - public interface IRequest : IDisposable - { - /// - /// Handler for receiving raw messages directly from host without any deserialization or morphing - /// This is required if one wants to re-direct the message over the process boundary without any processing overhead - /// All events should come as raw messages as well as actual serialized events - /// - event EventHandler OnRawMessageReceived; + event EventHandler OnRawMessageReceived; - /// - /// Waits for the request to complete - /// - /// Time out - /// True if the request timeouts - bool WaitForCompletion(int timeout); - } + /// + /// Waits for the request to complete + /// + /// Time out + /// True if the request timeouts + bool WaitForCompletion(int timeout); +} +/// +/// Extensions for . +/// +public static class RequestExtensions +{ /// - /// Extensions for . + /// Waits for the request to complete. /// - public static class RequestExtensions + /// Request to wait on. + public static void WaitForCompletion(this IRequest request) { - /// - /// Waits for the request to complete. - /// - /// Request to wait on. - public static void WaitForCompletion(this IRequest request) - { - request.WaitForCompletion(Timeout.Infinite); - } + request.WaitForCompletion(Timeout.Infinite); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IRequestData.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IRequestData.cs index 64d6a35d60..b3516ac979 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IRequestData.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IRequestData.cs @@ -1,26 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +/// +/// Provide common services and data for a discovery/run request. +/// +public interface IRequestData { /// - /// Provide common services and data for a discovery/run request. + /// Gets an instance of . /// - public interface IRequestData - { - /// - /// Gets an instance of . - /// - IMetricsCollection MetricsCollection { get; set; } + IMetricsCollection MetricsCollection { get; set; } - /// - /// Gets or sets the ProtocolConfig - /// - ProtocolConfig ProtocolConfig { get; set; } + /// + /// Gets or sets the ProtocolConfig + /// + ProtocolConfig ProtocolConfig { get; set; } - /// - /// Gets or sets a value indicating whether is telemetry opted in. - /// - bool IsTelemetryOptedIn { get; set; } - } -} + /// + /// Gets or sets a value indicating whether is telemetry opted in. + /// + bool IsTelemetryOptedIn { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestDiscoveryEventsHandler.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestDiscoveryEventsHandler.cs index 5e31a3a3dc..8833f24d24 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestDiscoveryEventsHandler.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestDiscoveryEventsHandler.cs @@ -1,28 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System.Collections.Generic; +/// +/// Interface contract for handling discovery events during test discovery operation +/// +public interface ITestDiscoveryEventsHandler : ITestMessageEventHandler +{ /// - /// Interface contract for handling discovery events during test discovery operation + /// Dispatch DiscoveryComplete event to listeners. /// - public interface ITestDiscoveryEventsHandler : ITestMessageEventHandler - { - /// - /// Dispatch DiscoveryComplete event to listeners. - /// - /// Total number of tests discovered. - /// Last set of test cases discovered. - /// True if the discovery operation is aborted. - void HandleDiscoveryComplete(long totalTests, IEnumerable lastChunk, bool isAborted); + /// Total number of tests discovered. + /// Last set of test cases discovered. + /// True if the discovery operation is aborted. + void HandleDiscoveryComplete(long totalTests, IEnumerable lastChunk, bool isAborted); - /// - /// Dispatch DiscoveredTest event to listeners. - /// - /// Discovered test cases. - void HandleDiscoveredTests(IEnumerable discoveredTestCases); - } + /// + /// Dispatch DiscoveredTest event to listeners. + /// + /// Discovered test cases. + void HandleDiscoveredTests(IEnumerable discoveredTestCases); } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestDiscoveryEventsHandler2.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestDiscoveryEventsHandler2.cs index 4b504b3257..ae13f3501a 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestDiscoveryEventsHandler2.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestDiscoveryEventsHandler2.cs @@ -1,26 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System.Collections.Generic; +/// +/// Interface contract for handling discovery events during test discovery operation +/// +public interface ITestDiscoveryEventsHandler2 : ITestMessageEventHandler +{ /// - /// Interface contract for handling discovery events during test discovery operation + /// Dispatch DiscoveryComplete event to listeners. /// - public interface ITestDiscoveryEventsHandler2 : ITestMessageEventHandler - { - /// - /// Dispatch DiscoveryComplete event to listeners. - /// - /// Discovery Complete Event Args - /// Last set of test cases discovered. - void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk); + /// Discovery Complete Event Args + /// Last set of test cases discovered. + void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk); - /// - /// Dispatch DiscoveredTest event to listeners. - /// - /// Discovered test cases. - void HandleDiscoveredTests(IEnumerable discoveredTestCases); - } -} + /// + /// Dispatch DiscoveredTest event to listeners. + /// + /// Discovered test cases. + void HandleDiscoveredTests(IEnumerable discoveredTestCases); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestHostLauncher.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestHostLauncher.cs index b49eaa7a86..0d9554c67f 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestHostLauncher.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestHostLauncher.cs @@ -3,31 +3,30 @@ using System.Threading; -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; + +/// +/// Interface defining contract for custom test host implementations +/// +public interface ITestHostLauncher { /// - /// Interface defining contract for custom test host implementations + /// Gets a value indicating whether this is a debug launcher. /// - public interface ITestHostLauncher - { - /// - /// Gets a value indicating whether this is a debug launcher. - /// - bool IsDebug { get; } + bool IsDebug { get; } - /// - /// Launches custom test host using the default test process start info - /// - /// Default TestHost Process Info - /// Process id of the launched test host - int LaunchTestHost(TestProcessStartInfo defaultTestHostStartInfo); + /// + /// Launches custom test host using the default test process start info + /// + /// Default TestHost Process Info + /// Process id of the launched test host + int LaunchTestHost(TestProcessStartInfo defaultTestHostStartInfo); - /// - /// Launches custom test host using the default test process start info - /// - /// Default TestHost Process Info - /// The cancellation Token. - /// Process id of the launched test host - int LaunchTestHost(TestProcessStartInfo defaultTestHostStartInfo, CancellationToken cancellationToken); - } -} + /// + /// Launches custom test host using the default test process start info + /// + /// Default TestHost Process Info + /// The cancellation Token. + /// Process id of the launched test host + int LaunchTestHost(TestProcessStartInfo defaultTestHostStartInfo, CancellationToken cancellationToken); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestHostLauncher2.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestHostLauncher2.cs index 641c6cbba7..a5b5a1474e 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestHostLauncher2.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestHostLauncher2.cs @@ -3,26 +3,25 @@ using System.Threading; -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; + +/// +/// Interface defining contract for custom test host implementations +/// +public interface ITestHostLauncher2 : ITestHostLauncher { /// - /// Interface defining contract for custom test host implementations + /// Attach debugger to already running custom test host process. /// - public interface ITestHostLauncher2 : ITestHostLauncher - { - /// - /// Attach debugger to already running custom test host process. - /// - /// Process ID of the process to which the debugger should be attached. - /// if the debugger was successfully attached to the requested process, otherwise. - bool AttachDebuggerToProcess(int pid); + /// Process ID of the process to which the debugger should be attached. + /// if the debugger was successfully attached to the requested process, otherwise. + bool AttachDebuggerToProcess(int pid); - /// - /// Attach debugger to already running custom test host process. - /// - /// Process ID of the process to which the debugger should be attached. - /// The cancellation token. - /// if the debugger was successfully attached to the requested process, otherwise. - bool AttachDebuggerToProcess(int pid, CancellationToken cancellationToken); - } -} + /// + /// Attach debugger to already running custom test host process. + /// + /// Process ID of the process to which the debugger should be attached. + /// The cancellation token. + /// if the debugger was successfully attached to the requested process, otherwise. + bool AttachDebuggerToProcess(int pid, CancellationToken cancellationToken); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestPlatform.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestPlatform.cs index 4f487a02f7..7fc5474137 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestPlatform.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestPlatform.cs @@ -1,78 +1,77 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System; - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System; +using System.Collections.Generic; +/// +/// Defines the functionality of the test platform. +/// +public interface ITestPlatform : IDisposable +{ /// - /// Defines the functionality of the test platform. + /// Updates the extensions to be used by the test service. /// - public interface ITestPlatform : IDisposable - { - /// - /// Updates the extensions to be used by the test service. - /// - /// - /// - /// Specifies the path to unit test extensions. If no additional extension is available, - /// then specify null or empty list. - /// - /// - /// Flag indicating if we should skip the default adapters initialization. - /// - void UpdateExtensions( - IEnumerable pathToAdditionalExtensions, - bool skipExtensionFilters); + /// + /// + /// Specifies the path to unit test extensions. If no additional extension is available, + /// then specify null or empty list. + /// + /// + /// Flag indicating if we should skip the default adapters initialization. + /// + void UpdateExtensions( + IEnumerable pathToAdditionalExtensions, + bool skipExtensionFilters); - /// - /// Clears the extensions. - /// - void ClearExtensions(); + /// + /// Clears the extensions. + /// + void ClearExtensions(); - /// - /// Creates a discovery request. - /// - /// - /// Providing common services and data for discovery. - /// Specifies the discovery parameters. - /// Test platform options. - /// - /// A DiscoveryRequest object. - IDiscoveryRequest CreateDiscoveryRequest( - IRequestData requestData, - DiscoveryCriteria discoveryCriteria, - TestPlatformOptions options); + /// + /// Creates a discovery request. + /// + /// + /// Providing common services and data for discovery. + /// Specifies the discovery parameters. + /// Test platform options. + /// + /// A DiscoveryRequest object. + IDiscoveryRequest CreateDiscoveryRequest( + IRequestData requestData, + DiscoveryCriteria discoveryCriteria, + TestPlatformOptions options); - /// - /// Creates a test run request. - /// - /// - /// Providing common services and data for execution. - /// Specifies the test run criteria. - /// Test platform options. - /// - /// A RunRequest object. - ITestRunRequest CreateTestRunRequest( - IRequestData requestData, - TestRunCriteria testRunCriteria, - TestPlatformOptions options); + /// + /// Creates a test run request. + /// + /// + /// Providing common services and data for execution. + /// Specifies the test run criteria. + /// Test platform options. + /// + /// A RunRequest object. + ITestRunRequest CreateTestRunRequest( + IRequestData requestData, + TestRunCriteria testRunCriteria, + TestPlatformOptions options); - /// - /// Starts a test session. - /// - /// - /// - /// Providing common services and data for test session start. - /// - /// Specifies the start test session criteria. - /// Events handler for handling session events. - /// - /// True if the operation succeeded, false otherwise. - bool StartTestSession( - IRequestData requestData, - StartTestSessionCriteria criteria, - ITestSessionEventsHandler eventsHandler); - } -} + /// + /// Starts a test session. + /// + /// + /// + /// Providing common services and data for test session start. + /// + /// Specifies the start test session criteria. + /// Events handler for handling session events. + /// + /// True if the operation succeeded, false otherwise. + bool StartTestSession( + IRequestData requestData, + StartTestSessionCriteria criteria, + ITestSessionEventsHandler eventsHandler); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestPlatformCapabilities.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestPlatformCapabilities.cs index 9202bea31a..83abefedb3 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestPlatformCapabilities.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestPlatformCapabilities.cs @@ -1,32 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System.Diagnostics.CodeAnalysis; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +/// +/// Basic metadata for ITestPlaform. +/// +/// +/// This interface is only public due to limitations in MEF which require metadata interfaces +/// to be public. This interface is not intended for external consumption. +/// +public interface ITestPlatformCapabilities +{ /// - /// Basic metadata for ITestPlaform. + /// Type of testPlatform /// - /// - /// This interface is only public due to limitations in MEF which require metadata interfaces - /// to be public. This interface is not intended for external consumption. - /// - [SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes", Justification = "This interface is only public due to limitations in MEF which require metadata interfaces to be public.")] - public interface ITestPlatformCapabilities - { - /// - /// Type of testPlatform - /// - TestPlatformType TestPlatformType { get; } - } - - public enum TestPlatformType - { - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")] - InProc, - - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")] - OutOfProc - } + TestPlatformType TestPlatformType { get; } } + +public enum TestPlatformType +{ + InProc, + OutOfProc +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunAttachmentsProcessingEventsHandler.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunAttachmentsProcessingEventsHandler.cs index f6235a92e9..c8223aaf15 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunAttachmentsProcessingEventsHandler.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunAttachmentsProcessingEventsHandler.cs @@ -3,30 +3,31 @@ using System.Collections.Generic; -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +/// +/// Interface contract for handling test run attachments processing events +/// +public interface ITestRunAttachmentsProcessingEventsHandler : ITestMessageEventHandler { /// - /// Interface contract for handling test run attachments processing events + /// Dispatch TestRunAttachmentsProcessingComplete event to listeners. + /// + /// AttachmentsProcessing Complete event args. + /// Last set of processed attachment sets. + void HandleTestRunAttachmentsProcessingComplete(TestRunAttachmentsProcessingCompleteEventArgs attachmentsProcessingCompleteEventArgs, IEnumerable lastChunk); + + /// + /// Dispatch ProcessedAttachmentsChunk event to listeners. /// - public interface ITestRunAttachmentsProcessingEventsHandler : ITestMessageEventHandler - { - /// - /// Dispatch TestRunAttachmentsProcessingComplete event to listeners. - /// - /// AttachmentsProcessing Complete event args. - /// Last set of processed attachment sets. - void HandleTestRunAttachmentsProcessingComplete(TestRunAttachmentsProcessingCompleteEventArgs attachmentsProcessingCompleteEventArgs, IEnumerable lastChunk); + /// Processed attachment sets. + void HandleProcessedAttachmentsChunk(IEnumerable attachments); - /// - /// Dispatch ProcessedAttachmentsChunk event to listeners. - /// - /// Processed attachment sets. - void HandleProcessedAttachmentsChunk(IEnumerable attachments); - /// - /// Dispatch TestRunAttachmentsProcessingProgress event to listeners. - /// - /// AttachmentsProcessing Progress event args. - void HandleTestRunAttachmentsProcessingProgress(TestRunAttachmentsProcessingProgressEventArgs AttachmentsProcessingProgressEventArgs); - } + /// + /// Dispatch TestRunAttachmentsProcessingProgress event to listeners. + /// + /// AttachmentsProcessing Progress event args. + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Part of the public API.")] + void HandleTestRunAttachmentsProcessingProgress(TestRunAttachmentsProcessingProgressEventArgs AttachmentsProcessingProgressEventArgs); } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunConfiguration.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunConfiguration.cs index cc81408b5b..20b8745a62 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunConfiguration.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunConfiguration.cs @@ -1,40 +1,39 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System.Collections.Generic; +/// +/// Defines common test run configuration APIs +/// +public interface ITestRunConfiguration +{ /// - /// Defines common test run configuration APIs + /// Defines the frequency of run stats test event. /// - public interface ITestRunConfiguration - { - /// - /// Defines the frequency of run stats test event. - /// - /// - /// Run stats change event will be raised after completion of these number of tests. - /// - /// Note that this event is raised asynchronously and the underlying execution process is not - /// paused during the listener invocation. So if the event handler, you try to query the - /// next set of results, you may get more than 'FrequencyOfRunStatsChangeEvent'. - /// - long FrequencyOfRunStatsChangeEvent { get; } + /// + /// Run stats change event will be raised after completion of these number of tests. + /// + /// Note that this event is raised asynchronously and the underlying execution process is not + /// paused during the listener invocation. So if the event handler, you try to query the + /// next set of results, you may get more than 'FrequencyOfRunStatsChangeEvent'. + /// + long FrequencyOfRunStatsChangeEvent { get; } - /// - /// Returns whether the run is configured to run specific tests - /// - bool HasSpecificTests { get; } + /// + /// Returns whether the run is configured to run specific tests + /// + bool HasSpecificTests { get; } - /// - /// Returns whether the run is configured to run specific sources - /// - bool HasSpecificSources { get; } + /// + /// Returns whether the run is configured to run specific sources + /// + bool HasSpecificSources { get; } - /// - /// The specific tests for this test run if any. - /// - IEnumerable Tests { get; } - } -} + /// + /// The specific tests for this test run if any. + /// + IEnumerable Tests { get; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunEventsHandler.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunEventsHandler.cs index ecd37b85c7..fc4e90cd32 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunEventsHandler.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunEventsHandler.cs @@ -1,57 +1,57 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System.Collections.Generic; + +using Logging; + +/// +/// Interface contract for handling test run events during run operation +/// +public interface ITestRunEventsHandler : ITestMessageEventHandler { - using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + /// + /// Handle the TestRunCompletion event from a test engine + /// + /// TestRunCompletion Data + /// Last set of test results + /// Attachments of the test run + /// ExecutorURIs of the adapters involved in test run + void HandleTestRunComplete(TestRunCompleteEventArgs testRunCompleteArgs, TestRunChangedEventArgs lastChunkArgs, ICollection runContextAttachments, ICollection executorUris); + + /// + /// Handle a change in TestRun i.e. new testresults and stats + /// + /// TestRunChanged Data + void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChangedArgs); + + /// + /// Launches a process with a given process info under debugger + /// Adapter get to call into this to launch any additional processes under debugger + /// + /// Process start info + /// ProcessId of the launched process + int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo); +} +/// +/// Interface for handling generic message events during various operations +/// +public interface ITestMessageEventHandler +{ /// - /// Interface contract for handling test run events during run operation + /// Raw Message from the host directly /// - public interface ITestRunEventsHandler : ITestMessageEventHandler - { - /// - /// Handle the TestRunCompletion event from a test engine - /// - /// TestRunCompletion Data - /// Last set of test results - /// Attachments of the test run - /// ExecutorURIs of the adapters involved in test run - void HandleTestRunComplete(TestRunCompleteEventArgs testRunCompleteArgs, TestRunChangedEventArgs lastChunkArgs, ICollection runContextAttachments, ICollection executorUris); - - /// - /// Handle a change in TestRun i.e. new testresults and stats - /// - /// TestRunChanged Data - void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChangedArgs); - - /// - /// Launches a process with a given process info under debugger - /// Adapter get to call into this to launch any additional processes under debugger - /// - /// Process start info - /// ProcessId of the launched process - int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo); - } + /// raw message args from host + void HandleRawMessage(string rawMessage); /// - /// Interface for handling generic message events during various operations + /// Handle a IMessageLogger message event from Adapter + /// Whenever adapters call IMessageLogger.SendMessage, TestEngine notifies client with this event /// - public interface ITestMessageEventHandler - { - /// - /// Raw Message from the host directly - /// - /// raw message args from host - void HandleRawMessage(string rawMessage); - - /// - /// Handle a IMessageLogger message event from Adapter - /// Whenever adapters call IMessageLogger.SendMessage, TestEngine notifies client with this event - /// - /// Message Level - /// string message - void HandleLogMessage(TestMessageLevel level, string message); - } + /// Message Level + /// string message + void HandleLogMessage(TestMessageLevel level, string message); } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunEventsHandler2.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunEventsHandler2.cs index a8ff3e742f..920138768b 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunEventsHandler2.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunEventsHandler2.cs @@ -1,18 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +/// +/// Interface contract for handling test run events during run operation. +/// +public interface ITestRunEventsHandler2 : ITestRunEventsHandler { /// - /// Interface contract for handling test run events during run operation. + /// Attach debugger to an already running process. /// - public interface ITestRunEventsHandler2 : ITestRunEventsHandler - { - /// - /// Attach debugger to an already running process. - /// - /// Process ID of the process to which the debugger should be attached. - /// if the debugger was successfully attached to the requested process, otherwise. - bool AttachDebuggerToProcess(int pid); - } -} + /// Process ID of the process to which the debugger should be attached. + /// if the debugger was successfully attached to the requested process, otherwise. + bool AttachDebuggerToProcess(int pid); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunRequest.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunRequest.cs index 43840f7f5d..0b73c9925d 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunRequest.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunRequest.cs @@ -1,69 +1,69 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System; +using Logging; + +/// +/// The request that a RunTests API returns. +/// +public interface ITestRunRequest : IRequest +{ /// - /// The request that a RunTests API returns. + /// Start the current RunTestAsync API call. /// - public interface ITestRunRequest : IRequest - { - /// - /// Start the current RunTestAsync API call. - /// - /// Id of the executor process - int ExecuteAsync(); + /// Id of the executor process + int ExecuteAsync(); - /// - /// Cancel the current RunTestsAsync API call. This can be used when making async RunTestsAsync call. - /// - void CancelAsync(); + /// + /// Cancel the current RunTestsAsync API call. This can be used when making async RunTestsAsync call. + /// + void CancelAsync(); - /// - /// Aborts the test run execution process. - /// - void Abort(); + /// + /// Aborts the test run execution process. + /// + void Abort(); - /// - /// Specifies the test run criteria - /// - ITestRunConfiguration TestRunConfiguration - { - get; - } + /// + /// Specifies the test run criteria + /// + ITestRunConfiguration TestRunConfiguration + { + get; + } - /// - /// State of the test run - /// - TestRunState State { get; } + /// + /// State of the test run + /// + TestRunState State { get; } - /// - /// Handler for notifying when test results came back from the agent! - /// - event EventHandler OnRunStatsChange; + /// + /// Handler for notifying when test results came back from the agent! + /// + event EventHandler OnRunStatsChange; - /// - /// Handler for notifying test run started - /// - event EventHandler OnRunStart; + /// + /// Handler for notifying test run started + /// + event EventHandler OnRunStart; - /// - /// Handler for notifying test run is complete - /// - event EventHandler OnRunCompletion; + /// + /// Handler for notifying test run is complete + /// + event EventHandler OnRunCompletion; - /// - /// Handler for receiving error during fetching/execution. This is used for when abnormal error - /// occurs; equivalent of IRunMessageLogger in the current RockSteady core - /// - event EventHandler TestRunMessage; + /// + /// Handler for receiving error during fetching/execution. This is used for when abnormal error + /// occurs; equivalent of IRunMessageLogger in the current RockSteady core + /// + event EventHandler TestRunMessage; - /// - /// Handler for receiving data collection messages. - /// - event EventHandler DataCollectionMessage; - } -} + /// + /// Handler for receiving data collection messages. + /// + event EventHandler DataCollectionMessage; +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunStatistics.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunStatistics.cs index 43d6b52b70..f1a92b3500 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunStatistics.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunStatistics.cs @@ -1,31 +1,29 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System.Collections.Generic; +/// +/// Stats on the test run state +/// +public interface ITestRunStatistics +{ /// - /// Stats on the test run state + /// The number of tests that have the specified value of TestOutcome /// - public interface ITestRunStatistics - { - /// - /// The number of tests that have the specified value of TestOutcome - /// - /// - /// - long this[TestOutcome testOutcome] { get; } - - /// - /// TestOutcome - Test count map - /// - IDictionary Stats { get; } + /// + /// + long this[TestOutcome testOutcome] { get; } - /// - /// Number of tests that have been run. - /// - long ExecutedTests { get; } - } + /// + /// TestOutcome - Test count map + /// + IDictionary Stats { get; } -} + /// + /// Number of tests that have been run. + /// + long ExecutedTests { get; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestSessionEventsHandler.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestSessionEventsHandler.cs index fc3dea783a..a69fa86a82 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestSessionEventsHandler.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestSessionEventsHandler.cs @@ -1,30 +1,29 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +/// +/// Interface contract for handling test session events. +/// +public interface ITestSessionEventsHandler : ITestMessageEventHandler { /// - /// Interface contract for handling test session events. + /// Dispatch StartTestSession complete event to listeners. /// - public interface ITestSessionEventsHandler : ITestMessageEventHandler - { - /// - /// Dispatch StartTestSession complete event to listeners. - /// - /// - /// The test session info. - void HandleStartTestSessionComplete(TestSessionInfo testSessionInfo); + /// + /// The test session info. + void HandleStartTestSessionComplete(TestSessionInfo testSessionInfo); - /// - /// Dispatch StopTestSession complete event to listeners. - /// - /// - /// - /// The test session info for the session that was stopped. - /// - /// - /// True if the session was successfully stopped, false otherwise. - /// - void HandleStopTestSessionComplete(TestSessionInfo testSessionInfo, bool stopped); - } -} + /// + /// Dispatch StopTestSession complete event to listeners. + /// + /// + /// + /// The test session info for the session that was stopped. + /// + /// + /// True if the session was successfully stopped, false otherwise. + /// + void HandleStopTestSessionComplete(TestSessionInfo testSessionInfo, bool stopped); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/CustomHostLaunchAckPayload.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/CustomHostLaunchAckPayload.cs index 60cae27735..1e2737a3d8 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/CustomHostLaunchAckPayload.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/CustomHostLaunchAckPayload.cs @@ -1,25 +1,24 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System.Runtime.Serialization; +/// +/// Class used to define the CustomHostLaunchAckPayload sent by the Vstest.console translation layers into design mode +/// +public class CustomHostLaunchAckPayload +{ /// - /// Class used to define the CustomHostLaunchAckPayload sent by the Vstest.console translation layers into design mode + /// ProcessId of the TestHost launched by Clients like IDE, LUT etc. /// - public class CustomHostLaunchAckPayload - { - /// - /// ProcessId of the TestHost launched by Clients like IDE, LUT etc. - /// - [DataMember] - public int HostProcessId { get; set; } + [DataMember] + public int HostProcessId { get; set; } - /// - /// ErrorMessage, in cases where custom launch fails - /// - [DataMember] - public string ErrorMessage { get; set; } - } -} + /// + /// ErrorMessage, in cases where custom launch fails + /// + [DataMember] + public string ErrorMessage { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/DiscoveryRequestPayload.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/DiscoveryRequestPayload.cs index c8a69408ca..9465c9b937 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/DiscoveryRequestPayload.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/DiscoveryRequestPayload.cs @@ -1,43 +1,42 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System.Collections.Generic; - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System.Collections.Generic; +using System.Runtime.Serialization; +/// +/// Class used to define the DiscoveryRequestPayload sent by the Vstest.console translation layers into design mode +/// +[DataContract] +public class DiscoveryRequestPayload +{ /// - /// Class used to define the DiscoveryRequestPayload sent by the Vstest.console translation layers into design mode + /// Settings used for the discovery request. /// - [DataContract] - public class DiscoveryRequestPayload - { - /// - /// Settings used for the discovery request. - /// - [DataMember] - public IEnumerable Sources { get; set; } + [DataMember] + public IEnumerable Sources { get; set; } - /// - /// Settings used for the discovery request. - /// - [DataMember] - public string RunSettings { get; set; } - - /// - /// Gets or sets the test platform options - /// - [DataMember] - public TestPlatformOptions TestPlatformOptions - { - get; - set; - } + /// + /// Settings used for the discovery request. + /// + [DataMember] + public string RunSettings { get; set; } - /// - /// Gets or sets the test session info. - /// - [DataMember] - public TestSessionInfo TestSessionInfo { get; set; } + /// + /// Gets or sets the test platform options + /// + [DataMember] + public TestPlatformOptions TestPlatformOptions + { + get; + set; } -} + + /// + /// Gets or sets the test session info. + /// + [DataMember] + public TestSessionInfo TestSessionInfo { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/EditorAttachDebuggerAckPayload.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/EditorAttachDebuggerAckPayload.cs index 268ccd1d6b..8005885594 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/EditorAttachDebuggerAckPayload.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/EditorAttachDebuggerAckPayload.cs @@ -1,26 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System.Runtime.Serialization; +/// +/// Class used to define the sent by the +/// vstest.console translation layers into design mode. +/// +public class EditorAttachDebuggerAckPayload +{ /// - /// Class used to define the sent by the - /// vstest.console translation layers into design mode. + /// A value indicating if the debugger has successfully attached. /// - public class EditorAttachDebuggerAckPayload - { - /// - /// A value indicating if the debugger has successfully attached. - /// - [DataMember] - public bool Attached { get; set; } + [DataMember] + public bool Attached { get; set; } - /// - /// ErrorMessage, in cases where attaching the debugger fails. - /// - [DataMember] - public string ErrorMessage { get; set; } - } -} + /// + /// ErrorMessage, in cases where attaching the debugger fails. + /// + [DataMember] + public string ErrorMessage { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/StartTestSessionAckPayload.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/StartTestSessionAckPayload.cs index 5ec1bc5c79..ccee67e56e 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/StartTestSessionAckPayload.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/StartTestSessionAckPayload.cs @@ -1,20 +1,19 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads -{ - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; + +using System.Runtime.Serialization; +/// +/// Class used to define the start test session ack payload sent by the design mode client +/// back to the vstest.console translation layers. +/// +public class StartTestSessionAckPayload +{ /// - /// Class used to define the start test session ack payload sent by the design mode client - /// back to the vstest.console translation layers. + /// Gets or sets the test session info. /// - public class StartTestSessionAckPayload - { - /// - /// Gets or sets the test session info. - /// - [DataMember] - public TestSessionInfo TestSessionInfo { get; set; } - } -} + [DataMember] + public TestSessionInfo TestSessionInfo { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/StartTestSessionPayload.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/StartTestSessionPayload.cs index cf25fe44a7..e78282fb1f 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/StartTestSessionPayload.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/StartTestSessionPayload.cs @@ -1,45 +1,44 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads -{ - using System.Collections.Generic; - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; + +using System.Collections.Generic; +using System.Runtime.Serialization; +/// +/// Class used to define the start test session payload sent by the vstest.console translation +/// layers into design mode. +/// +public class StartTestSessionPayload +{ /// - /// Class used to define the start test session payload sent by the vstest.console translation - /// layers into design mode. + /// Gets or sets the sources used for starting the test session. /// - public class StartTestSessionPayload - { - /// - /// Gets or sets the sources used for starting the test session. - /// - [DataMember] - public IList Sources { get; set; } + [DataMember] + public IList Sources { get; set; } - /// - /// Gets or sets the run settings used for starting the test session. - /// - [DataMember] - public string RunSettings { get; set; } + /// + /// Gets or sets the run settings used for starting the test session. + /// + [DataMember] + public string RunSettings { get; set; } - /// - /// Gets or sets a flag indicating if debugging is enabled. - /// - [DataMember] - public bool IsDebuggingEnabled { get; set; } + /// + /// Gets or sets a flag indicating if debugging is enabled. + /// + [DataMember] + public bool IsDebuggingEnabled { get; set; } - /// - /// Gets or sets a flag indicating if a custom host launcher should be used. - /// - [DataMember] - public bool HasCustomHostLauncher { get; set; } + /// + /// Gets or sets a flag indicating if a custom host launcher should be used. + /// + [DataMember] + public bool HasCustomHostLauncher { get; set; } - /// - /// Gets or sets the test platform options. - /// - [DataMember] - public TestPlatformOptions TestPlatformOptions { get; set; } - } -} + /// + /// Gets or sets the test platform options. + /// + [DataMember] + public TestPlatformOptions TestPlatformOptions { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/StopTestSessionAckPayload.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/StopTestSessionAckPayload.cs index ecca18eafd..08cdb4bebe 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/StopTestSessionAckPayload.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/StopTestSessionAckPayload.cs @@ -1,26 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads -{ - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; + +using System.Runtime.Serialization; +/// +/// Class used to define the stop test session ack payload sent by the design mode client +/// back to the vstest.console translation layers. +/// +public class StopTestSessionAckPayload +{ /// - /// Class used to define the stop test session ack payload sent by the design mode client - /// back to the vstest.console translation layers. + /// Gets or sets the test session info. /// - public class StopTestSessionAckPayload - { - /// - /// Gets or sets the test session info. - /// - [DataMember] - public TestSessionInfo TestSessionInfo { get; set; } + [DataMember] + public TestSessionInfo TestSessionInfo { get; set; } - /// - /// Gets or sets a value indicating if the session was successfully stopped or not. - /// - [DataMember] - public bool IsStopped { get; set; } - } -} + /// + /// Gets or sets a value indicating if the session was successfully stopped or not. + /// + [DataMember] + public bool IsStopped { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/TestRunAttachmentsProcessingPayload.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/TestRunAttachmentsProcessingPayload.cs index 8d160b4080..05e65421c9 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/TestRunAttachmentsProcessingPayload.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/TestRunAttachmentsProcessingPayload.cs @@ -1,38 +1,37 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System.Collections.Generic; - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System.Collections.Generic; +using System.Runtime.Serialization; +/// +/// Class used to define the TestRunAttachmentsProcessingPayload sent by the Vstest.console translation layers into design mode +/// +public class TestRunAttachmentsProcessingPayload +{ /// - /// Class used to define the TestRunAttachmentsProcessingPayload sent by the Vstest.console translation layers into design mode + /// Collection of attachments. /// - public class TestRunAttachmentsProcessingPayload - { - /// - /// Collection of attachments. - /// - [DataMember] - public IEnumerable Attachments { get; set; } + [DataMember] + public IEnumerable Attachments { get; set; } - /// - /// Collection of the invoked data collectors. - /// - [DataMember] - public IEnumerable InvokedDataCollectors { get; set; } + /// + /// Collection of the invoked data collectors. + /// + [DataMember] + public IEnumerable InvokedDataCollectors { get; set; } - /// - /// Gets or sets the settings used for the test run request. - /// - [DataMember] - public string RunSettings { get; set; } + /// + /// Gets or sets the settings used for the test run request. + /// + [DataMember] + public string RunSettings { get; set; } - /// - /// Gets or sets whether Metrics should be collected or not. - /// - [DataMember] - public bool CollectMetrics { get; set; } - } -} + /// + /// Gets or sets whether Metrics should be collected or not. + /// + [DataMember] + public bool CollectMetrics { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/TestRunRequestPayload.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/TestRunRequestPayload.cs index 2c37f3e086..4d3dc2b359 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/TestRunRequestPayload.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Payloads/TestRunRequestPayload.cs @@ -1,64 +1,63 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System.Collections.Generic; - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System.Collections.Generic; +using System.Runtime.Serialization; +/// +/// Class used to define the TestRunRequestPayload sent by the Vstest.console translation layers into design mode +/// +public class TestRunRequestPayload +{ /// - /// Class used to define the TestRunRequestPayload sent by the Vstest.console translation layers into design mode + /// Gets or sets the sources for the test run request. /// - public class TestRunRequestPayload - { - /// - /// Gets or sets the sources for the test run request. - /// - /// - /// Making this a list instead of an IEnumerable because the json serializer fails to deserialize - /// if a linq query outputs the IEnumerable. - /// - [DataMember] - public List Sources { get; set; } + /// + /// Making this a list instead of an IEnumerable because the json serializer fails to deserialize + /// if a linq query outputs the IEnumerable. + /// + [DataMember] + public List Sources { get; set; } - /// - /// Gets or sets the test cases for the test run request. - /// - /// - /// Making this a list instead of an IEnumerable because the json serializer fails to deserialize - /// if a linq query outputs the IEnumerable. - /// - [DataMember] - public List TestCases { get; set; } + /// + /// Gets or sets the test cases for the test run request. + /// + /// + /// Making this a list instead of an IEnumerable because the json serializer fails to deserialize + /// if a linq query outputs the IEnumerable. + /// + [DataMember] + public List TestCases { get; set; } - /// - /// Gets or sets the settings used for the test run request. - /// - [DataMember] - public string RunSettings { get; set; } + /// + /// Gets or sets the settings used for the test run request. + /// + [DataMember] + public string RunSettings { get; set; } - /// - /// Settings used for the Run request. - /// - [DataMember] - public bool KeepAlive { get; set; } + /// + /// Settings used for the Run request. + /// + [DataMember] + public bool KeepAlive { get; set; } - /// - /// Is Debugging enabled - /// - [DataMember] - public bool DebuggingEnabled { get; set; } + /// + /// Is Debugging enabled + /// + [DataMember] + public bool DebuggingEnabled { get; set; } - /// - /// Gets or sets the testplatform options - /// - [DataMember] - public TestPlatformOptions TestPlatformOptions { get; set; } + /// + /// Gets or sets the testplatform options + /// + [DataMember] + public TestPlatformOptions TestPlatformOptions { get; set; } - /// - /// Gets or sets the test session info. - /// - [DataMember] - public TestSessionInfo TestSessionInfo { get; set; } - } -} + /// + /// Gets or sets the test session info. + /// + [DataMember] + public TestSessionInfo TestSessionInfo { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/ProtocolConfig.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/ProtocolConfig.cs index 81adb6b394..90e8c9f9ae 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/ProtocolConfig.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/ProtocolConfig.cs @@ -1,16 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +/// +/// Class for Protocol related information +/// +public class ProtocolConfig { /// - /// Class for Protocol related information + /// Get or Set the version of protocol /// - public class ProtocolConfig - { - /// - /// Get or Set the version of protocol - /// - public int Version { get; set; } - } -} + public int Version { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/StartTestSessionCriteria.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/StartTestSessionCriteria.cs index 9970b20d5f..49074a6eaa 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/StartTestSessionCriteria.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/StartTestSessionCriteria.cs @@ -1,34 +1,34 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using System.Collections.Generic; - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using Interfaces; +using System.Collections.Generic; +using System.Runtime.Serialization; + +/// +/// Class used to define the start test session criteria. +/// +[DataContract] +public class StartTestSessionCriteria +{ /// - /// Class used to define the start test session criteria. + /// Gets or sets the sources used for starting the test session. /// - [DataContract] - public class StartTestSessionCriteria - { - /// - /// Gets or sets the sources used for starting the test session. - /// - [DataMember] - public IList Sources { get; set; } + [DataMember] + public IList Sources { get; set; } - /// - /// Gets or sets the run settings used for starting the test session. - /// - [DataMember] - public string RunSettings { get; set; } + /// + /// Gets or sets the run settings used for starting the test session. + /// + [DataMember] + public string RunSettings { get; set; } - /// - /// Gets or sets the test host launcher used for starting the test session. - /// - [DataMember] - public ITestHostLauncher TestHostLauncher { get; set; } - } -} + /// + /// Gets or sets the test host launcher used for starting the test session. + /// + [DataMember] + public ITestHostLauncher TestHostLauncher { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/TestPlatformOptions.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/TestPlatformOptions.cs index ea7597419e..c9165db250 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/TestPlatformOptions.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/TestPlatformOptions.cs @@ -1,46 +1,45 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System.Runtime.Serialization; +/// +/// Options to be passed into the Test Platform during Discovery/Execution. +/// +[DataContract] +public class TestPlatformOptions +{ /// - /// Options to be passed into the Test Platform during Discovery/Execution. + /// Gets or sets the filter criteria for test cases. /// - [DataContract] - public class TestPlatformOptions - { - /// - /// Gets or sets the filter criteria for test cases. - /// - /// - /// - /// This is only used when running tests with sources. - /// - [DataMember] - public string TestCaseFilter { get; set; } + /// + /// + /// This is only used when running tests with sources. + /// + [DataMember] + public string TestCaseFilter { get; set; } - /// - /// Gets or sets the filter options if there are any. - /// - /// - /// - /// This will be valid only if TestCase filter is present. - /// - [DataMember] - public FilterOptions FilterOptions { get; set; } + /// + /// Gets or sets the filter options if there are any. + /// + /// + /// + /// This will be valid only if TestCase filter is present. + /// + [DataMember] + public FilterOptions FilterOptions { get; set; } - /// - /// Gets or sets whether metrics should be collected or not. - /// - [DataMember] - public bool CollectMetrics { get; set; } + /// + /// Gets or sets whether metrics should be collected or not. + /// + [DataMember] + public bool CollectMetrics { get; set; } - /// - /// Gets or sets whether default adapters should be skipped or not. - /// - [DataMember] - public bool SkipDefaultAdapters { get; set; } - } -} + /// + /// Gets or sets whether default adapters should be skipped or not. + /// + [DataMember] + public bool SkipDefaultAdapters { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/TestRunCriteria.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/TestRunCriteria.cs index 1e23577f93..2ef6d18fe8 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/TestRunCriteria.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/TestRunCriteria.cs @@ -1,873 +1,867 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; + +using Interfaces; + +using Resources; + +/// +/// Defines the test run criterion. +/// +public class TestRunCriteria : BaseTestRunCriteria, ITestRunConfiguration { - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Linq; - using System.Runtime.Serialization; - using System.Text; - - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources; - - /// - /// Defines the test run criterion. - /// - public class TestRunCriteria : BaseTestRunCriteria, ITestRunConfiguration - { - private string testCaseFilter; - private FilterOptions filterOptions; - - /// - /// Initializes a new instance of the class. - /// - /// - /// Sources which contains tests that should be executed. - /// Frequency of run stats event. - public TestRunCriteria( - IEnumerable sources, - long frequencyOfRunStatsChangeEvent) - : this( - sources, - frequencyOfRunStatsChangeEvent, - keepAlive: true) - { - } + private string _testCaseFilter; + private FilterOptions _filterOptions; - /// - /// Initializes a new instance of the class. - /// - /// - /// Sources which contains tests that should be executed. - /// Frequency of run stats event. - /// - /// Whether the execution process should be kept alive after the run is finished or not. - /// - public TestRunCriteria( - IEnumerable sources, - long frequencyOfRunStatsChangeEvent, - bool keepAlive) - : this( - sources, - frequencyOfRunStatsChangeEvent, - keepAlive, - testSettings: string.Empty) - { - } + /// + /// Initializes a new instance of the class. + /// + /// + /// Sources which contains tests that should be executed. + /// Frequency of run stats event. + public TestRunCriteria( + IEnumerable sources, + long frequencyOfRunStatsChangeEvent) + : this( + sources, + frequencyOfRunStatsChangeEvent, + keepAlive: true) + { + } - /// - /// Initializes a new instance of the class. - /// - /// - /// Sources which contains tests that should be executed. - /// Frequency of run stats event. - /// - /// Whether the execution process should be kept alive after the run is finished or not. - /// - /// Settings used for this run. - public TestRunCriteria( - IEnumerable sources, - long frequencyOfRunStatsChangeEvent, - bool keepAlive, - string testSettings) - : this( - sources, - frequencyOfRunStatsChangeEvent, - keepAlive, - testSettings, - TimeSpan.MaxValue) - { - } + /// + /// Initializes a new instance of the class. + /// + /// + /// Sources which contains tests that should be executed. + /// Frequency of run stats event. + /// + /// Whether the execution process should be kept alive after the run is finished or not. + /// + public TestRunCriteria( + IEnumerable sources, + long frequencyOfRunStatsChangeEvent, + bool keepAlive) + : this( + sources, + frequencyOfRunStatsChangeEvent, + keepAlive, + testSettings: string.Empty) + { + } - /// - /// Initializes a new instance of the class. - /// - /// - /// Sources which contains tests that should be executed. - /// Frequency of run stats event. - /// - /// Whether the execution process should be kept alive after the run is finished or not. - /// - /// Settings used for this run. - /// - /// Timeout that triggers sending results regardless of cache size. - /// - public TestRunCriteria( - IEnumerable sources, - long frequencyOfRunStatsChangeEvent, - bool keepAlive, - string testSettings, - TimeSpan runStatsChangeEventTimeout) - : this( - sources, - frequencyOfRunStatsChangeEvent, - keepAlive, - testSettings, - runStatsChangeEventTimeout, - testHostLauncher: null) - { - } + /// + /// Initializes a new instance of the class. + /// + /// + /// Sources which contains tests that should be executed. + /// Frequency of run stats event. + /// + /// Whether the execution process should be kept alive after the run is finished or not. + /// + /// Settings used for this run. + public TestRunCriteria( + IEnumerable sources, + long frequencyOfRunStatsChangeEvent, + bool keepAlive, + string testSettings) + : this( + sources, + frequencyOfRunStatsChangeEvent, + keepAlive, + testSettings, + TimeSpan.MaxValue) + { + } - /// - /// Initializes a new instance of the class. - /// - /// - /// Sources which contains tests that should be executed. - /// Frequency of run stats event. - /// - /// Whether the execution process should be kept alive after the run is finished or not. - /// - /// Settings used for this run. - /// - /// Timeout that triggers sending results regardless of cache size. - /// - /// - /// Test host launcher. If null then default will be used. - /// - public TestRunCriteria( - IEnumerable sources, - long frequencyOfRunStatsChangeEvent, - bool keepAlive, - string testSettings, - TimeSpan runStatsChangeEventTimeout, - ITestHostLauncher testHostLauncher) - : this( - sources, - frequencyOfRunStatsChangeEvent, - keepAlive, - testSettings, - runStatsChangeEventTimeout, - testHostLauncher, - testCaseFilter: null, - filterOptions: null) - { - } + /// + /// Initializes a new instance of the class. + /// + /// + /// Sources which contains tests that should be executed. + /// Frequency of run stats event. + /// + /// Whether the execution process should be kept alive after the run is finished or not. + /// + /// Settings used for this run. + /// + /// Timeout that triggers sending results regardless of cache size. + /// + public TestRunCriteria( + IEnumerable sources, + long frequencyOfRunStatsChangeEvent, + bool keepAlive, + string testSettings, + TimeSpan runStatsChangeEventTimeout) + : this( + sources, + frequencyOfRunStatsChangeEvent, + keepAlive, + testSettings, + runStatsChangeEventTimeout, + testHostLauncher: null) + { + } - /// - /// Initializes a new instance of the class. - /// - /// - /// Sources which contains tests that should be executed. - /// Frequency of run stats event. - /// - /// Whether the execution process should be kept alive after the run is finished or not. - /// - /// Settings used for this run. - /// - /// Timeout that triggers sending results regardless of cache size. - /// - /// - /// Test host launcher. If null then default will be used. - /// - /// Test case filter. - /// Filter options. - public TestRunCriteria( - IEnumerable sources, - long frequencyOfRunStatsChangeEvent, - bool keepAlive, - string testSettings, - TimeSpan runStatsChangeEventTimeout, - ITestHostLauncher testHostLauncher, - string testCaseFilter, - FilterOptions filterOptions) - : this( - sources, - frequencyOfRunStatsChangeEvent, - keepAlive, - testSettings, - runStatsChangeEventTimeout, - testHostLauncher, - testCaseFilter, - filterOptions, - testSessionInfo: null, - debugEnabledForTestSession: false) - { - } + /// + /// Initializes a new instance of the class. + /// + /// + /// Sources which contains tests that should be executed. + /// Frequency of run stats event. + /// + /// Whether the execution process should be kept alive after the run is finished or not. + /// + /// Settings used for this run. + /// + /// Timeout that triggers sending results regardless of cache size. + /// + /// + /// Test host launcher. If null then default will be used. + /// + public TestRunCriteria( + IEnumerable sources, + long frequencyOfRunStatsChangeEvent, + bool keepAlive, + string testSettings, + TimeSpan runStatsChangeEventTimeout, + ITestHostLauncher testHostLauncher) + : this( + sources, + frequencyOfRunStatsChangeEvent, + keepAlive, + testSettings, + runStatsChangeEventTimeout, + testHostLauncher, + testCaseFilter: null, + filterOptions: null) + { + } - /// - /// Initializes a new instance of the class. - /// - /// - /// Sources which contains tests that should be executed. - /// Frequency of run stats event. - /// - /// Whether the execution process should be kept alive after the run is finished or not. - /// - /// Settings used for this run. - /// - /// Timeout that triggers sending results regardless of cache size. - /// - /// - /// Test host launcher. If null then default will be used. - /// - /// Test case filter. - /// Filter options. - /// The test session info object. - /// - /// Indicates if debugging should be enabled when we have test session info available. - /// - public TestRunCriteria( - IEnumerable sources, - long frequencyOfRunStatsChangeEvent, - bool keepAlive, - string testSettings, - TimeSpan runStatsChangeEventTimeout, - ITestHostLauncher testHostLauncher, - string testCaseFilter, - FilterOptions filterOptions, - TestSessionInfo testSessionInfo, - bool debugEnabledForTestSession) - : base( - frequencyOfRunStatsChangeEvent, - keepAlive, - testSettings, - runStatsChangeEventTimeout, - testHostLauncher) + /// + /// Initializes a new instance of the class. + /// + /// + /// Sources which contains tests that should be executed. + /// Frequency of run stats event. + /// + /// Whether the execution process should be kept alive after the run is finished or not. + /// + /// Settings used for this run. + /// + /// Timeout that triggers sending results regardless of cache size. + /// + /// + /// Test host launcher. If null then default will be used. + /// + /// Test case filter. + /// Filter options. + public TestRunCriteria( + IEnumerable sources, + long frequencyOfRunStatsChangeEvent, + bool keepAlive, + string testSettings, + TimeSpan runStatsChangeEventTimeout, + ITestHostLauncher testHostLauncher, + string testCaseFilter, + FilterOptions filterOptions) + : this( + sources, + frequencyOfRunStatsChangeEvent, + keepAlive, + testSettings, + runStatsChangeEventTimeout, + testHostLauncher, + testCaseFilter, + filterOptions, + testSessionInfo: null, + debugEnabledForTestSession: false) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Sources which contains tests that should be executed. + /// Frequency of run stats event. + /// + /// Whether the execution process should be kept alive after the run is finished or not. + /// + /// Settings used for this run. + /// + /// Timeout that triggers sending results regardless of cache size. + /// + /// + /// Test host launcher. If null then default will be used. + /// + /// Test case filter. + /// Filter options. + /// The test session info object. + /// + /// Indicates if debugging should be enabled when we have test session info available. + /// + public TestRunCriteria( + IEnumerable sources, + long frequencyOfRunStatsChangeEvent, + bool keepAlive, + string testSettings, + TimeSpan runStatsChangeEventTimeout, + ITestHostLauncher testHostLauncher, + string testCaseFilter, + FilterOptions filterOptions, + TestSessionInfo testSessionInfo, + bool debugEnabledForTestSession) + : base( + frequencyOfRunStatsChangeEvent, + keepAlive, + testSettings, + runStatsChangeEventTimeout, + testHostLauncher) + { + var testSources = sources as IList ?? sources.ToList(); + ValidateArg.NotNullOrEmpty(testSources, nameof(sources)); + + AdapterSourceMap = new Dictionary> { - var testSources = sources as IList ?? sources.ToList(); - ValidateArg.NotNullOrEmpty(testSources, nameof(sources)); + { Constants.UnspecifiedAdapterPath, testSources } + }; - this.AdapterSourceMap = new Dictionary>(); - this.AdapterSourceMap.Add(Constants.UnspecifiedAdapterPath, testSources); + TestCaseFilter = testCaseFilter; + FilterOptions = filterOptions; - this.TestCaseFilter = testCaseFilter; - this.FilterOptions = filterOptions; + TestSessionInfo = testSessionInfo; + DebugEnabledForTestSession = debugEnabledForTestSession; + } - this.TestSessionInfo = testSessionInfo; - this.DebugEnabledForTestSession = debugEnabledForTestSession; - } + /// + /// Initializes a new instance of the class. + /// Create the TestRunCriteria for a test run. + /// + /// + /// Sources which contains tests that should be executed. + /// The test run criteria. + public TestRunCriteria( + IEnumerable sources, + TestRunCriteria testRunCriteria) + : base(testRunCriteria) + { + var testSources = sources as IList ?? sources.ToArray(); + ValidateArg.NotNullOrEmpty(testSources, nameof(sources)); - /// - /// Initializes a new instance of the class. - /// Create the TestRunCriteria for a test run. - /// - /// - /// Sources which contains tests that should be executed. - /// The test run criteria. - public TestRunCriteria( - IEnumerable sources, - TestRunCriteria testRunCriteria) - : base(testRunCriteria) + AdapterSourceMap = new Dictionary> { - var testSources = sources as IList ?? sources.ToArray(); - ValidateArg.NotNullOrEmpty(testSources, nameof(sources)); + { Constants.UnspecifiedAdapterPath, testSources } + }; - this.AdapterSourceMap = new Dictionary>(); - this.AdapterSourceMap.Add(Constants.UnspecifiedAdapterPath, testSources); + TestCaseFilter = testRunCriteria._testCaseFilter; + FilterOptions = testRunCriteria._filterOptions; + } - this.TestCaseFilter = testRunCriteria.testCaseFilter; - this.FilterOptions = testRunCriteria.filterOptions; - } + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// Sources which contains tests that should be executed. + /// + /// Frequency of run stats event. + /// + /// Whether the execution process should be kept alive after the run is finished or not. + /// + /// Settings used for this run. + /// + /// Timeout that triggers sending results regardless of cache size. + /// + /// + /// Test host launcher. If null then default will be used. + /// + public TestRunCriteria( + Dictionary> adapterSourceMap, + long frequencyOfRunStatsChangeEvent, + bool keepAlive, + string testSettings, + TimeSpan runStatsChangeEventTimeout, + ITestHostLauncher testHostLauncher) + : base( + frequencyOfRunStatsChangeEvent, + keepAlive, + testSettings, + runStatsChangeEventTimeout, + testHostLauncher) + { + ValidateArg.NotNullOrEmpty(adapterSourceMap, nameof(adapterSourceMap)); - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// Sources which contains tests that should be executed. - /// - /// Frequency of run stats event. - /// - /// Whether the execution process should be kept alive after the run is finished or not. - /// - /// Settings used for this run. - /// - /// Timeout that triggers sending results regardless of cache size. - /// - /// - /// Test host launcher. If null then default will be used. - /// - public TestRunCriteria( - Dictionary> adapterSourceMap, - long frequencyOfRunStatsChangeEvent, - bool keepAlive, - string testSettings, - TimeSpan runStatsChangeEventTimeout, - ITestHostLauncher testHostLauncher) - : base( - frequencyOfRunStatsChangeEvent, - keepAlive, - testSettings, - runStatsChangeEventTimeout, - testHostLauncher) - { - ValidateArg.NotNullOrEmpty(adapterSourceMap, nameof(adapterSourceMap)); + AdapterSourceMap = adapterSourceMap; + } - this.AdapterSourceMap = adapterSourceMap; - } + /// + /// Initializes a new instance of the class. + /// + /// + /// Tests which should be executed. + /// Frequency of run stats event. + public TestRunCriteria( + IEnumerable tests, + long frequencyOfRunStatsChangeEvent) + : this( + tests, + frequencyOfRunStatsChangeEvent, + false) + { + } - /// - /// Initializes a new instance of the class. - /// - /// - /// Tests which should be executed. - /// Frequency of run stats event. - public TestRunCriteria( - IEnumerable tests, - long frequencyOfRunStatsChangeEvent) - : this( - tests, - frequencyOfRunStatsChangeEvent, - false) - { - } + /// + /// Initializes a new instance of the class. + /// + /// + /// Tests which should be executed. + /// Frequency of run stats event. + /// + /// Whether or not to keep the test executor process alive after run completion. + /// + public TestRunCriteria( + IEnumerable tests, + long frequencyOfRunStatsChangeEvent, + bool keepAlive) + : this( + tests, + frequencyOfRunStatsChangeEvent, + keepAlive, + string.Empty) + { + } - /// - /// Initializes a new instance of the class. - /// - /// - /// Tests which should be executed. - /// Frequency of run stats event. - /// - /// Whether or not to keep the test executor process alive after run completion. - /// - public TestRunCriteria( - IEnumerable tests, - long frequencyOfRunStatsChangeEvent, - bool keepAlive) - : this( - tests, - frequencyOfRunStatsChangeEvent, - keepAlive, - string.Empty) - { - } + /// + /// Initializes a new instance of the class. + /// + /// + /// Tests which should be executed. + /// Frequency of run stats event. + /// + /// Whether or not to keep the test executor process alive after run completion. + /// + /// Settings used for this run. + public TestRunCriteria( + IEnumerable tests, + long frequencyOfRunStatsChangeEvent, + bool keepAlive, + string testSettings) + : this( + tests, + frequencyOfRunStatsChangeEvent, + keepAlive, + testSettings, + TimeSpan.MaxValue) + { + } - /// - /// Initializes a new instance of the class. - /// - /// - /// Tests which should be executed. - /// Frequency of run stats event. - /// - /// Whether or not to keep the test executor process alive after run completion. - /// - /// Settings used for this run. - public TestRunCriteria( - IEnumerable tests, - long frequencyOfRunStatsChangeEvent, - bool keepAlive, - string testSettings) - : this( - tests, - frequencyOfRunStatsChangeEvent, - keepAlive, - testSettings, - TimeSpan.MaxValue) - { - } + /// + /// Initializes a new instance of the class. + /// + /// + /// Tests which should be executed. + /// Frequency of run stats event. + /// + /// Whether or not to keep the test executor process alive after run completion. + /// + /// Settings used for this run. + /// + /// Timeout that triggers sending results regardless of cache size. + /// + public TestRunCriteria( + IEnumerable tests, + long frequencyOfRunStatsChangeEvent, + bool keepAlive, + string testSettings, + TimeSpan runStatsChangeEventTimeout) + : this( + tests, + frequencyOfRunStatsChangeEvent, + keepAlive, + testSettings, + runStatsChangeEventTimeout, + null) + { + } - /// - /// Initializes a new instance of the class. - /// - /// - /// Tests which should be executed. - /// Frequency of run stats event. - /// - /// Whether or not to keep the test executor process alive after run completion. - /// - /// Settings used for this run. - /// - /// Timeout that triggers sending results regardless of cache size. - /// - public TestRunCriteria( - IEnumerable tests, - long frequencyOfRunStatsChangeEvent, - bool keepAlive, - string testSettings, - TimeSpan runStatsChangeEventTimeout) - : this( - tests, - frequencyOfRunStatsChangeEvent, - keepAlive, - testSettings, - runStatsChangeEventTimeout, - null) - { - } + /// + /// Initializes a new instance of the class. + /// + /// + /// Tests which should be executed. + /// The base test run criteria. + public TestRunCriteria(IEnumerable tests, BaseTestRunCriteria baseTestRunCriteria) + : base(baseTestRunCriteria) + { + var testCases = tests as IList ?? tests.ToList(); + ValidateArg.NotNullOrEmpty(testCases, nameof(tests)); - /// - /// Initializes a new instance of the class. - /// - /// - /// Tests which should be executed. - /// The base test run criteria. - public TestRunCriteria(IEnumerable tests, BaseTestRunCriteria baseTestRunCriteria) - : base(baseTestRunCriteria) - { - var testCases = tests as IList ?? tests.ToList(); - ValidateArg.NotNullOrEmpty(testCases, nameof(tests)); + Tests = testCases; + } - this.Tests = testCases; - } + /// + /// Initializes a new instance of the class. + /// + /// + /// Tests which should be executed. + /// Frequency of run stats event. + /// + /// Whether or not to keep the test executor process alive after run completion. + /// + /// Settings used for this run. + /// + /// Timeout that triggers sending results regardless of cache size. + /// + /// + /// Test host launcher. If null then default will be used. + /// + public TestRunCriteria( + IEnumerable tests, + long frequencyOfRunStatsChangeEvent, + bool keepAlive, + string testSettings, + TimeSpan runStatsChangeEventTimeout, + ITestHostLauncher testHostLauncher) + : this( + tests, + frequencyOfRunStatsChangeEvent, + keepAlive, + testSettings, + runStatsChangeEventTimeout, + testHostLauncher, + testSessionInfo: null, + debugEnabledForTestSession: false) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Tests which should be executed. + /// Frequency of run stats event. + /// + /// Whether or not to keep the test executor process alive after run completion. + /// + /// Settings used for this run. + /// + /// Timeout that triggers sending results regardless of cache size. + /// + /// + /// Test host launcher. If null then default will be used. + /// + /// The test session info object. + /// + /// Indicates if debugging should be enabled when we have test session info available. + /// + public TestRunCriteria( + IEnumerable tests, + long frequencyOfRunStatsChangeEvent, + bool keepAlive, + string testSettings, + TimeSpan runStatsChangeEventTimeout, + ITestHostLauncher testHostLauncher, + TestSessionInfo testSessionInfo, + bool debugEnabledForTestSession) + : base( + frequencyOfRunStatsChangeEvent, + keepAlive, + testSettings, + runStatsChangeEventTimeout, + testHostLauncher) + { + var testCases = tests as IList ?? tests.ToList(); + ValidateArg.NotNullOrEmpty(testCases, nameof(tests)); + + Tests = testCases; + TestSessionInfo = testSessionInfo; + DebugEnabledForTestSession = debugEnabledForTestSession; + } - /// - /// Initializes a new instance of the class. - /// - /// - /// Tests which should be executed. - /// Frequency of run stats event. - /// - /// Whether or not to keep the test executor process alive after run completion. - /// - /// Settings used for this run. - /// - /// Timeout that triggers sending results regardless of cache size. - /// - /// - /// Test host launcher. If null then default will be used. - /// - public TestRunCriteria( - IEnumerable tests, - long frequencyOfRunStatsChangeEvent, - bool keepAlive, - string testSettings, - TimeSpan runStatsChangeEventTimeout, - ITestHostLauncher testHostLauncher) - : this( - tests, - frequencyOfRunStatsChangeEvent, - keepAlive, - testSettings, - runStatsChangeEventTimeout, - testHostLauncher, - testSessionInfo: null, - debugEnabledForTestSession: false) + /// + /// Gets the test containers (e.g. DLL/EXE/artifacts to scan). + /// + [IgnoreDataMember] + public IEnumerable Sources + { + get { + IEnumerable sources = new List(); + return AdapterSourceMap?.Values?.Aggregate( + sources, + (current, enumerable) => current.Concat(enumerable)); } + } - /// - /// Initializes a new instance of the class. - /// - /// - /// Tests which should be executed. - /// Frequency of run stats event. - /// - /// Whether or not to keep the test executor process alive after run completion. - /// - /// Settings used for this run. - /// - /// Timeout that triggers sending results regardless of cache size. - /// - /// - /// Test host launcher. If null then default will be used. - /// - /// The test session info object. - /// - /// Indicates if debugging should be enabled when we have test session info available. - /// - public TestRunCriteria( - IEnumerable tests, - long frequencyOfRunStatsChangeEvent, - bool keepAlive, - string testSettings, - TimeSpan runStatsChangeEventTimeout, - ITestHostLauncher testHostLauncher, - TestSessionInfo testSessionInfo, - bool debugEnabledForTestSession) - : base( - frequencyOfRunStatsChangeEvent, - keepAlive, - testSettings, - runStatsChangeEventTimeout, - testHostLauncher) - { - var testCases = tests as IList ?? tests.ToList(); - ValidateArg.NotNullOrEmpty(testCases, nameof(tests)); + /// + /// Gets the test adapter and source map which would look like below: + /// + /// { C:\temp\testAdapter1.dll : [ source1.dll, source2.dll ], C:\temp\testadapter2.dll : [ source3.dll, source2.dll ] + /// + /// + [DataMember] + public Dictionary> AdapterSourceMap { get; private set; } - this.Tests = testCases; - this.TestSessionInfo = testSessionInfo; - this.DebugEnabledForTestSession = debugEnabledForTestSession; - } + /// + /// Gets the tests that need to executed in this test run. + /// This will be null if test run is created with specific test containers. + /// + [DataMember] + public IEnumerable Tests { get; private set; } - /// - /// Gets the test containers (e.g. DLL/EXE/artifacts to scan). - /// - [IgnoreDataMember] - public IEnumerable Sources + /// + /// Gets or sets the criteria for filtering test cases. + /// + /// This is only for with sources. + [DataMember] + public string TestCaseFilter + { + get { - get - { - IEnumerable sources = new List(); - return this.AdapterSourceMap?.Values?.Aggregate( - sources, - (current, enumerable) => current.Concat(enumerable)); - } + return _testCaseFilter; } - /// - /// Gets the test adapter and source map which would look like below: - /// - /// { C:\temp\testAdapter1.dll : [ source1.dll, source2.dll ], C:\temp\testadapter2.dll : [ source3.dll, source2.dll ] - /// - /// - [DataMember] - public Dictionary> AdapterSourceMap { get; private set; } - - /// - /// Gets the tests that need to executed in this test run. - /// This will be null if test run is created with specific test containers. - /// - [DataMember] - public IEnumerable Tests { get; private set; } - - /// - /// Gets or sets the criteria for filtering test cases. - /// - /// This is only for with sources. - [DataMember] - public string TestCaseFilter + private set { - get + if (value != null && !HasSpecificSources) { - return this.testCaseFilter; + throw new InvalidOperationException(Resources.NoTestCaseFilterForSpecificTests); } - private set - { - if (value != null && !this.HasSpecificSources) - { - throw new InvalidOperationException(Resources.NoTestCaseFilterForSpecificTests); - } + _testCaseFilter = value; + } + } - this.testCaseFilter = value; - } + /// + /// Gets or sets the filter options. + /// + /// This is only applicable when TestCaseFilter is present. + [DataMember] + public FilterOptions FilterOptions + { + get + { + return _filterOptions; } - /// - /// Gets or sets the filter options. - /// - /// This is only applicable when TestCaseFilter is present. - [DataMember] - public FilterOptions FilterOptions + private set { - get + if (value != null && !HasSpecificSources) { - return this.filterOptions; + throw new InvalidOperationException(Resources.NoTestCaseFilterForSpecificTests); } - private set - { - if (value != null && !this.HasSpecificSources) - { - throw new InvalidOperationException(Resources.NoTestCaseFilterForSpecificTests); - } - - this.filterOptions = value; - } + _filterOptions = value; } + } - /// - /// Gets or sets the test session info object. - /// - public TestSessionInfo TestSessionInfo { get; set; } - - /// - /// Gets or sets a flag indicating if debugging should be enabled when we have test session - /// info available. - /// - public bool DebugEnabledForTestSession { get; set; } - - /// - /// Gets a value indicating whether run criteria is based on specific tests. - /// - public bool HasSpecificTests - { - get { return this.Tests != null; } - } + /// + /// Gets or sets the test session info object. + /// + public TestSessionInfo TestSessionInfo { get; set; } - /// - /// Gets a value indicating whether run criteria is based on specific sources. - /// - [DataMember] - public bool HasSpecificSources - { - get { return this.Sources != null; } - } + /// + /// Gets or sets a flag indicating if debugging should be enabled when we have test session + /// info available. + /// + public bool DebugEnabledForTestSession { get; set; } + + /// + /// Gets a value indicating whether run criteria is based on specific tests. + /// + public bool HasSpecificTests + { + get { return Tests != null; } + } + + /// + /// Gets a value indicating whether run criteria is based on specific sources. + /// + [DataMember] + public bool HasSpecificSources + { + get { return Sources != null; } + } + + /// + public override string ToString() + { + StringBuilder sb = new(); + sb.AppendLine(string.Format(CultureInfo.CurrentCulture, "TestRunCriteria:")); + sb.AppendLine(string.Format( + CultureInfo.CurrentCulture, + " KeepAlive={0},FrequencyOfRunStatsChangeEvent={1},RunStatsChangeEventTimeout={2},TestCaseFilter={3},TestExecutorLauncher={4}", + KeepAlive, + FrequencyOfRunStatsChangeEvent, + RunStatsChangeEventTimeout, + TestCaseFilter, + TestHostLauncher)); + sb.AppendLine(string.Format(CultureInfo.CurrentCulture, " Settingsxml={0}", TestRunSettings)); + + return sb.ToString(); + } + + protected bool Equals(TestRunCriteria other) + { + return base.Equals(other) + && string.Equals(TestCaseFilter, other.TestCaseFilter) + && Equals(FilterOptions, other.FilterOptions); + } - /// - public override string ToString() + /// + public override bool Equals(object obj) + { + if (obj is null) { - StringBuilder sb = new StringBuilder(); - sb.AppendLine(string.Format(CultureInfo.CurrentCulture, "TestRunCriteria:")); - sb.AppendLine(string.Format( - CultureInfo.CurrentCulture, - " KeepAlive={0},FrequencyOfRunStatsChangeEvent={1},RunStatsChangeEventTimeout={2},TestCaseFilter={3},TestExecutorLauncher={4}", - this.KeepAlive, - this.FrequencyOfRunStatsChangeEvent, - this.RunStatsChangeEventTimeout, - this.TestCaseFilter, - this.TestHostLauncher)); - sb.AppendLine(string.Format(CultureInfo.CurrentCulture, " Settingsxml={0}", this.TestRunSettings)); - - return sb.ToString(); + return false; } - protected bool Equals(TestRunCriteria other) + if (ReferenceEquals(this, obj)) { - return base.Equals(other) - && string.Equals(this.TestCaseFilter, other.TestCaseFilter) - && string.Equals(this.FilterOptions, other.FilterOptions); + return true; } - /// - public override bool Equals(object obj) + return obj.GetType() == GetType() && Equals((TestRunCriteria)obj); + } + + /// + public override int GetHashCode() + { + unchecked { - if (object.ReferenceEquals(null, obj)) - { - return false; - } + int hashCode = base.GetHashCode(); + hashCode = (hashCode * 397) ^ (_testCaseFilter != null ? _testCaseFilter.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (AdapterSourceMap != null ? AdapterSourceMap.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (Tests != null ? Tests.GetHashCode() : 0); + return hashCode; + } + } +} - if (object.ReferenceEquals(this, obj)) - { - return true; - } +/// +/// Defines the base test run criterion. +/// +public class BaseTestRunCriteria +{ + /// + /// Initializes a new instance of the class. + /// + /// + /// Run criteria to clone. + public BaseTestRunCriteria(BaseTestRunCriteria runCriteria) + { + ValidateArg.NotNull(runCriteria, nameof(runCriteria)); - if (obj.GetType() != this.GetType()) - { - return false; - } + FrequencyOfRunStatsChangeEvent = runCriteria.FrequencyOfRunStatsChangeEvent; + KeepAlive = runCriteria.KeepAlive; + TestRunSettings = runCriteria.TestRunSettings; + RunStatsChangeEventTimeout = runCriteria.RunStatsChangeEventTimeout; + TestHostLauncher = runCriteria.TestHostLauncher; + } - return this.Equals((TestRunCriteria)obj); - } + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// Frequency of TestRunChangedEvent. + /// + public BaseTestRunCriteria(long frequencyOfRunStatsChangeEvent) + : this(frequencyOfRunStatsChangeEvent, true) + { + } - /// - public override int GetHashCode() - { - unchecked - { - int hashCode = base.GetHashCode(); - hashCode = (hashCode * 397) ^ (this.testCaseFilter != null ? this.testCaseFilter.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.AdapterSourceMap != null ? this.AdapterSourceMap.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.Tests != null ? this.Tests.GetHashCode() : 0); - return hashCode; - } - } + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// Frequency of TestRunChangedEvent. + /// + /// + /// Specify if the test host process should be stay alive after run. + /// + public BaseTestRunCriteria(long frequencyOfRunStatsChangeEvent, bool keepAlive) + : this(frequencyOfRunStatsChangeEvent, keepAlive, string.Empty) + { } /// - /// Defines the base test run criterion. + /// Initializes a new instance of the class. /// - public class BaseTestRunCriteria + /// + /// + /// Frequency of TestRunChangedEvent. + /// + /// + /// Specify if the test host process should be stay alive after run. + /// + /// Test run settings. + public BaseTestRunCriteria( + long frequencyOfRunStatsChangeEvent, + bool keepAlive, + string testSettings) + : this( + frequencyOfRunStatsChangeEvent, + keepAlive, + testSettings, + TimeSpan.MaxValue) { - /// - /// Initializes a new instance of the class. - /// - /// - /// Run criteria to clone. - public BaseTestRunCriteria(BaseTestRunCriteria runCriteria) - { - ValidateArg.NotNull(runCriteria, nameof(runCriteria)); + } - this.FrequencyOfRunStatsChangeEvent = runCriteria.FrequencyOfRunStatsChangeEvent; - this.KeepAlive = runCriteria.KeepAlive; - this.TestRunSettings = runCriteria.TestRunSettings; - this.RunStatsChangeEventTimeout = runCriteria.RunStatsChangeEventTimeout; - this.TestHostLauncher = runCriteria.TestHostLauncher; - } + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// Frequency of TestRunChangedEvent. + /// + /// + /// Specify if the test host process should be stay alive after run. + /// + /// Test run settings. + /// + /// Timeout for a TestRunChangedEvent. + /// + public BaseTestRunCriteria( + long frequencyOfRunStatsChangeEvent, + bool keepAlive, + string testSettings, + TimeSpan runStatsChangeEventTimeout) + : this( + frequencyOfRunStatsChangeEvent, + keepAlive, + testSettings, + runStatsChangeEventTimeout, + null) + { + } - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// Frequency of TestRunChangedEvent. - /// - public BaseTestRunCriteria(long frequencyOfRunStatsChangeEvent) - : this(frequencyOfRunStatsChangeEvent, true) + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// Frequency of TestRunChangedEvent. + /// + /// + /// Specify if the test host process should be stay alive after run. + /// + /// Test run settings. + /// + /// Timeout for a TestRunChangedEvent. + /// + /// Test host launcher. + public BaseTestRunCriteria( + long frequencyOfRunStatsChangeEvent, + bool keepAlive, + string testSettings, + TimeSpan runStatsChangeEventTimeout, + ITestHostLauncher testHostLauncher) + { + if (frequencyOfRunStatsChangeEvent <= 0) { + throw new ArgumentOutOfRangeException( + nameof(frequencyOfRunStatsChangeEvent), + Resources.NotificationFrequencyIsNotPositive); } - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// Frequency of TestRunChangedEvent. - /// - /// - /// Specify if the test host process should be stay alive after run. - /// - public BaseTestRunCriteria(long frequencyOfRunStatsChangeEvent, bool keepAlive) - : this(frequencyOfRunStatsChangeEvent, keepAlive, string.Empty) + if (runStatsChangeEventTimeout <= TimeSpan.MinValue) { + throw new ArgumentOutOfRangeException( + nameof(runStatsChangeEventTimeout), + Resources.NotificationTimeoutIsZero); } - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// Frequency of TestRunChangedEvent. - /// - /// - /// Specify if the test host process should be stay alive after run. - /// - /// Test run settings. - public BaseTestRunCriteria( - long frequencyOfRunStatsChangeEvent, - bool keepAlive, - string testSettings) - : this( - frequencyOfRunStatsChangeEvent, - keepAlive, - testSettings, - TimeSpan.MaxValue) - { - } + FrequencyOfRunStatsChangeEvent = frequencyOfRunStatsChangeEvent; + KeepAlive = keepAlive; + TestRunSettings = testSettings; + RunStatsChangeEventTimeout = runStatsChangeEventTimeout; + TestHostLauncher = testHostLauncher; + } - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// Frequency of TestRunChangedEvent. - /// - /// - /// Specify if the test host process should be stay alive after run. - /// - /// Test run settings. - /// - /// Timeout for a TestRunChangedEvent. - /// - public BaseTestRunCriteria( - long frequencyOfRunStatsChangeEvent, - bool keepAlive, - string testSettings, - TimeSpan runStatsChangeEventTimeout) - : this( - frequencyOfRunStatsChangeEvent, - keepAlive, - testSettings, - runStatsChangeEventTimeout, - null) - { - } + /// + /// Gets a value indicating whether the test executor process should remain alive after + /// run completion. + /// + [DataMember] + public bool KeepAlive { get; private set; } - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// Frequency of TestRunChangedEvent. - /// - /// - /// Specify if the test host process should be stay alive after run. - /// - /// Test run settings. - /// - /// Timeout for a TestRunChangedEvent. - /// - /// Test host launcher. - public BaseTestRunCriteria( - long frequencyOfRunStatsChangeEvent, - bool keepAlive, - string testSettings, - TimeSpan runStatsChangeEventTimeout, - ITestHostLauncher testHostLauncher) - { - if (frequencyOfRunStatsChangeEvent <= 0) - { - throw new ArgumentOutOfRangeException( - nameof(frequencyOfRunStatsChangeEvent), - Resources.NotificationFrequencyIsNotPositive); - } + /// + /// Gets the settings used for this run. + /// + [DataMember] + public string TestRunSettings { get; private set; } - if (runStatsChangeEventTimeout <= TimeSpan.MinValue) - { - throw new ArgumentOutOfRangeException( - nameof(runStatsChangeEventTimeout), - Resources.NotificationTimeoutIsZero); - } + /// + /// Gets the custom launcher for test executor. + /// + [DataMember] + public ITestHostLauncher TestHostLauncher { get; private set; } - this.FrequencyOfRunStatsChangeEvent = frequencyOfRunStatsChangeEvent; - this.KeepAlive = keepAlive; - this.TestRunSettings = testSettings; - this.RunStatsChangeEventTimeout = runStatsChangeEventTimeout; - this.TestHostLauncher = testHostLauncher; - } + /// + /// Gets the frequency of run stats test event. + /// + /// + /// + /// Run stats change event will be raised after completion of these number of tests. + /// Note that this event is raised asynchronously and the underlying execution process is not + /// paused during the listener invocation. So if the event handler, you try to query the + /// next set of results, you may get more than 'FrequencyOfRunStatsChangeEvent'. + /// + [DataMember] + public long FrequencyOfRunStatsChangeEvent { get; private set; } + + /// + /// Gets the timeout that triggers sending results regardless of cache size. + /// + [DataMember] + public TimeSpan RunStatsChangeEventTimeout { get; private set; } - /// - /// Gets a value indicating whether the test executor process should remain alive after - /// run completion. - /// - [DataMember] - public bool KeepAlive { get; private set; } - - /// - /// Gets the settings used for this run. - /// - [DataMember] - public string TestRunSettings { get; private set; } - - /// - /// Gets the custom launcher for test executor. - /// - [DataMember] - public ITestHostLauncher TestHostLauncher { get; private set; } - - /// - /// Gets the frequency of run stats test event. - /// - /// - /// - /// Run stats change event will be raised after completion of these number of tests. - /// Note that this event is raised asynchronously and the underlying execution process is not - /// paused during the listener invocation. So if the event handler, you try to query the - /// next set of results, you may get more than 'FrequencyOfRunStatsChangeEvent'. - /// - [DataMember] - public long FrequencyOfRunStatsChangeEvent { get; private set; } - - /// - /// Gets the timeout that triggers sending results regardless of cache size. - /// - [DataMember] - public TimeSpan RunStatsChangeEventTimeout { get; private set; } - - protected bool Equals(BaseTestRunCriteria other) + protected bool Equals(BaseTestRunCriteria other) + { + return KeepAlive == other.KeepAlive + && string.Equals(TestRunSettings, other.TestRunSettings) + && FrequencyOfRunStatsChangeEvent == other.FrequencyOfRunStatsChangeEvent + && RunStatsChangeEventTimeout.Equals(other.RunStatsChangeEventTimeout); + } + + /// + public override bool Equals(object obj) + { + if (obj is null) { - return this.KeepAlive == other.KeepAlive - && string.Equals(this.TestRunSettings, other.TestRunSettings) - && this.FrequencyOfRunStatsChangeEvent == other.FrequencyOfRunStatsChangeEvent - && this.RunStatsChangeEventTimeout.Equals(other.RunStatsChangeEventTimeout); + return false; } - /// - public override bool Equals(object obj) + if (ReferenceEquals(this, obj)) { - if (object.ReferenceEquals(null, obj)) - { - return false; - } - - if (object.ReferenceEquals(this, obj)) - { - return true; - } - - if (obj.GetType() != this.GetType()) - { - return false; - } - - return this.Equals((BaseTestRunCriteria)obj); + return true; } - /// - public override int GetHashCode() + return obj.GetType() == GetType() && Equals((BaseTestRunCriteria)obj); + } + + /// + public override int GetHashCode() + { + unchecked { - unchecked - { - var hashCode = this.KeepAlive.GetHashCode(); - hashCode = (hashCode * 397) ^ (this.TestRunSettings != null ? this.TestRunSettings.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ this.FrequencyOfRunStatsChangeEvent.GetHashCode(); - hashCode = (hashCode * 397) ^ this.RunStatsChangeEventTimeout.GetHashCode(); - return hashCode; - } + var hashCode = KeepAlive.GetHashCode(); + hashCode = (hashCode * 397) ^ (TestRunSettings != null ? TestRunSettings.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ FrequencyOfRunStatsChangeEvent.GetHashCode(); + hashCode = (hashCode * 397) ^ RunStatsChangeEventTimeout.GetHashCode(); + return hashCode; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/TestRunState.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/TestRunState.cs index 4016fa14a0..006bd2f729 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/TestRunState.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/TestRunState.cs @@ -1,41 +1,40 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +/// +/// States of the TestRun +/// +public enum TestRunState { /// - /// States of the TestRun + /// Status is not known /// - public enum TestRunState - { - /// - /// Status is not known - /// - None = 0, + None = 0, - /// - /// The run is still being created. No tests have started yet. - /// - Pending = 1, + /// + /// The run is still being created. No tests have started yet. + /// + Pending = 1, - /// - /// Tests are running. - /// - InProgress = 2, + /// + /// Tests are running. + /// + InProgress = 2, - /// - /// All tests have completed or been skipped. - /// - Completed = 3, + /// + /// All tests have completed or been skipped. + /// + Completed = 3, - /// - /// Run is canceled and remaining tests have been aborted - /// - Canceled = 4, + /// + /// Run is canceled and remaining tests have been aborted + /// + Canceled = 4, - /// - /// Run is aborted - /// - Aborted = 5 - } -} + /// + /// Run is aborted + /// + Aborted = 5 +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/TestRunStatistics.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/TestRunStatistics.cs index 9c9cf381a7..9b35be9fd2 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/TestRunStatistics.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/TestRunStatistics.cs @@ -1,75 +1,69 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System.Collections.Generic; - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System.Collections.Generic; +using System.Runtime.Serialization; +/// +/// Defines the test run stats header +/// +[DataContract] +public class TestRunStatistics : ITestRunStatistics +{ /// - /// Defines the test run stats header + /// Initializes a new instance of the class. /// - [DataContract] - public class TestRunStatistics : ITestRunStatistics + /// This constructor doesn't perform any parameter validation, it is meant to be used for serialization."/> + public TestRunStatistics() { - /// - /// Initializes a new instance of the class. - /// - /// This constructor doesn't perform any parameter validation, it is meant to be used for serialization."/> - public TestRunStatistics() - { - // Default constructor for Serialization. - } + // Default constructor for Serialization. + } - /// - /// Initializes a new instance of the class. - /// - /// The stats. - public TestRunStatistics(IDictionary stats) - { - this.Stats = stats; - } + /// + /// Initializes a new instance of the class. + /// + /// The stats. + public TestRunStatistics(IDictionary stats) + { + Stats = stats; + } - /// - /// Initializes a new instance of the class. - /// - /// The executed tests. - /// The stats. - /// This constructor is only needed to reconstruct the object during deserialization. - public TestRunStatistics(long executedTests, IDictionary stats) - { - this.ExecutedTests = executedTests; - this.Stats = stats; - } + /// + /// Initializes a new instance of the class. + /// + /// The executed tests. + /// The stats. + /// This constructor is only needed to reconstruct the object during deserialization. + public TestRunStatistics(long executedTests, IDictionary stats) + { + ExecutedTests = executedTests; + Stats = stats; + } - /// - /// Gets or sets the number of tests that have been run. - /// - [DataMember] - public long ExecutedTests { get; set; } + /// + /// Gets or sets the number of tests that have been run. + /// + [DataMember] + public long ExecutedTests { get; set; } - /// - /// Gets the test stats which is the test outcome versus its state. - /// - [DataMember] - public IDictionary Stats { get; private set; } + /// + /// Gets the test stats which is the test outcome versus its state. + /// + [DataMember] + public IDictionary Stats { get; private set; } - /// - /// Gets the number of tests with a specified outcome. - /// - /// The test outcome. - /// The number of tests with this outcome. - public long this[TestOutcome testOutcome] + /// + /// Gets the number of tests with a specified outcome. + /// + /// The test outcome. + /// The number of tests with this outcome. + public long this[TestOutcome testOutcome] + { + get { - get - { - if (this.Stats.TryGetValue(testOutcome, out var count)) - { - return count; - } - - return 0; - } + return Stats.TryGetValue(testOutcome, out var count) ? count : 0; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/TestSessionInfo.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/TestSessionInfo.cs index ab502d0645..ad108bf22f 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/TestSessionInfo.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/TestSessionInfo.cs @@ -1,64 +1,63 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System; - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System; +using System.Runtime.Serialization; +/// +/// Defines the test session info object to be passed around between vstest.console and +/// vstest.console wrapper in order to identify the current session. +/// +[DataContract] +public class TestSessionInfo : IEquatable +{ /// - /// Defines the test session info object to be passed around between vstest.console and - /// vstest.console wrapper in order to identify the current session. + /// Creates an instance of the current class. /// - [DataContract] - public class TestSessionInfo : IEquatable + public TestSessionInfo() { - /// - /// Creates an instance of the current class. - /// - public TestSessionInfo() - { - this.Id = Guid.NewGuid(); - } + Id = Guid.NewGuid(); + } - /// - /// Gets the session id. - /// - [DataMember] - public Guid Id { get; private set; } + /// + /// Gets the session id. + /// + [DataMember] + public Guid Id { get; private set; } - /// - /// Calculates the hash code for the current object. - /// - /// - /// An integer representing the computed hashcode value. - public override int GetHashCode() - { - return this.Id.GetHashCode(); - } + /// + /// Calculates the hash code for the current object. + /// + /// + /// An integer representing the computed hashcode value. + public override int GetHashCode() + { + return Id.GetHashCode(); + } - /// - /// Checks if the specified object is equal to the current instance. - /// - /// - /// The object to be checked. - /// - /// True if the two objects are equal, false otherwise. - public override bool Equals(object obj) - { - return this.Equals(obj as TestSessionInfo); - } + /// + /// Checks if the specified object is equal to the current instance. + /// + /// + /// The object to be checked. + /// + /// True if the two objects are equal, false otherwise. + public override bool Equals(object obj) + { + return Equals(obj as TestSessionInfo); + } - /// - /// Checks if the specified session is equal to the current instance. - /// - /// - /// The session to be checked. - /// - /// True if the two sessions are equal, false otherwise. - public bool Equals(TestSessionInfo other) - { - return other != null && this.Id == other.Id; - } + /// + /// Checks if the specified session is equal to the current instance. + /// + /// + /// The session to be checked. + /// + /// True if the two sessions are equal, false otherwise. + public bool Equals(TestSessionInfo other) + { + return other != null && Id == other.Id; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/CodeCoverage/TestSDKAutoGeneratedCode.cs b/src/Microsoft.TestPlatform.ObjectModel/CodeCoverage/TestSDKAutoGeneratedCode.cs index 9f17f5f3f5..2a079da57e 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/CodeCoverage/TestSDKAutoGeneratedCode.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/CodeCoverage/TestSDKAutoGeneratedCode.cs @@ -1,13 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform +namespace Microsoft.VisualStudio.TestPlatform; + +using System; +/// +/// Only to be used to Test platform, to exclude auto generated code from CodeCoverage +/// +public class TestSDKAutoGeneratedCode : Attribute { - using System; - /// - /// Only to be used to Test platform, to exclude auto generated code from CodeCoverage - /// - public class TestSDKAutoGeneratedCode : Attribute - { - } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/ConnectionInfo/TestRunnerConnectionInfo.cs b/src/Microsoft.TestPlatform.ObjectModel/ConnectionInfo/TestRunnerConnectionInfo.cs index 98d812c488..1a663928fa 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/ConnectionInfo/TestRunnerConnectionInfo.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/ConnectionInfo/TestRunnerConnectionInfo.cs @@ -1,119 +1,118 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +/// +/// Details of EndPoint address for connection b/w test runtime, test runner +/// +public struct TestHostConnectionInfo { /// - /// Details of EndPoint address for connection b/w test runtime, test runner + /// Endpoint where the service is hosted, This endpoint is specific to Transport + /// e.g. 127.0.0.0:8080 for sockets /// - public struct TestHostConnectionInfo + public string Endpoint { - /// - /// Endpoint where the service is hosted, This endpoint is specific to Transport - /// e.g. 127.0.0.0:8080 for sockets - /// - public string Endpoint - { - get; - set; - } - - /// - /// Gets or sets the role played by TestRuntime during communication. - /// - public ConnectionRole Role - { - get; - set; - } - - /// - /// Gets or sets the transport protocol supported by test runtime - /// - public Transport Transport - { - get; - set; - } + get; + set; } /// - /// Specifies the role of application, whether as host or client + /// Gets or sets the role played by TestRuntime during communication. /// - public enum ConnectionRole + public ConnectionRole Role { - /// - /// Act as server host - /// - Host = 0, - - /// - /// Act as client - /// - Client = 1 + get; + set; } /// - /// Specifies the underneath Transport channel to be used - /// E.g. For UWP/Desktop it is Sockets, for Android it could be SSH + /// Gets or sets the transport protocol supported by test runtime /// - public enum Transport + public Transport Transport { - /// - /// Act as server host - /// - Sockets = 0, + get; + set; } +} + +/// +/// Specifies the role of application, whether as host or client +/// +public enum ConnectionRole +{ + /// + /// Act as server host + /// + Host = 0, + + /// + /// Act as client + /// + Client = 1 +} + +/// +/// Specifies the underneath Transport channel to be used +/// E.g. For UWP/Desktop it is Sockets, for Android it could be SSH +/// +public enum Transport +{ + /// + /// Act as server host + /// + Sockets = 0, +} +/// +/// Connection information for a test host to communicate with test runner. +/// +public struct TestRunnerConnectionInfo +{ /// - /// Connection information for a test host to communicate with test runner. + /// Gets or sets the port for runner to connect to + /// Needed for backward compatibility /// - public struct TestRunnerConnectionInfo + public int Port { - /// - /// Gets or sets the port for runner to connect to - /// Needed for backward compatibility - /// - public int Port - { - get; - set; - } + get; + set; + } - /// - /// Gets or sets the details of endpoint by test runner for host communication. - /// - public TestHostConnectionInfo ConnectionInfo - { - get; - set; - } + /// + /// Gets or sets the details of endpoint by test runner for host communication. + /// + public TestHostConnectionInfo ConnectionInfo + { + get; + set; + } - /// - /// Gets or sets the diagnostics log file. - /// - public string LogFile - { - get; - set; - } + /// + /// Gets or sets the diagnostics log file. + /// + public string LogFile + { + get; + set; + } - /// - /// Gets or sets the trace level of logs. - /// - public int TraceLevel - { - get; - set; - } + /// + /// Gets or sets the trace level of logs. + /// + public int TraceLevel + { + get; + set; + } - /// - /// Gets or sets the runner process id. - /// - public int RunnerProcessId - { - get; - set; - } + /// + /// Gets or sets the runner process id. + /// + public int RunnerProcessId + { + get; + set; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/ConnectionInfo/TestRunnerConnectionInfoExtensions.cs b/src/Microsoft.TestPlatform.ObjectModel/ConnectionInfo/TestRunnerConnectionInfoExtensions.cs index 87ef7f5789..5e163560a4 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/ConnectionInfo/TestRunnerConnectionInfoExtensions.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/ConnectionInfo/TestRunnerConnectionInfoExtensions.cs @@ -1,28 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +/// +/// Extension methods for . +/// +public static class TestRunnerConnectionInfoExtensions { /// - /// Extension methods for . + /// Creates a default command line options string from . /// - public static class TestRunnerConnectionInfoExtensions + /// Connection info for the test host. + /// Command line option string. + public static string ToCommandLineOptions(this TestRunnerConnectionInfo connectionInfo) { - /// - /// Creates a default command line options string from . - /// - /// Connection info for the test host. - /// Command line option string. - public static string ToCommandLineOptions(this TestRunnerConnectionInfo connectionInfo) + var options = "--port " + connectionInfo.Port + " --endpoint " + connectionInfo.ConnectionInfo.Endpoint + " --role " + (connectionInfo.ConnectionInfo.Role == ConnectionRole.Client ? "client" : "host") + " --parentprocessid " + connectionInfo.RunnerProcessId; + if (!string.IsNullOrEmpty(connectionInfo.LogFile)) { - var options = "--port " + connectionInfo.Port + " --endpoint " + connectionInfo.ConnectionInfo.Endpoint + " --role " + (connectionInfo.ConnectionInfo.Role == ConnectionRole.Client ? "client" : "host") + " --parentprocessid " + connectionInfo.RunnerProcessId; - if (!string.IsNullOrEmpty(connectionInfo.LogFile)) - { - options += " --diag " + connectionInfo.LogFile; - options += " --tracelevel " + connectionInfo.TraceLevel; - } - - return options; + options += " --diag " + connectionInfo.LogFile; + options += " --tracelevel " + connectionInfo.TraceLevel; } + + return options; } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Constants.cs b/src/Microsoft.TestPlatform.ObjectModel/Constants.cs index 8b1d57bbb8..ce5d28342d 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Constants.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Constants.cs @@ -1,252 +1,250 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.IO; + +using Utilities; +using Client; +using PlatformAbstractions; + +/// +/// Defines the defaults/constants used across different components. +/// +public static class Constants { - using System; - using System.IO; - - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - - /// - /// Defines the defaults/constants used across different components. - /// - public static class Constants - { - /// - /// The in process data collection run settings name. - /// - public const string InProcDataCollectionRunSettingsName = "InProcDataCollectionRunSettings"; - - /// - /// The in process data collector setting name. - /// - public const string InProcDataCollectorSettingName = "InProcDataCollector"; - - /// - /// The in process data collectors setting name. - /// - public const string InProcDataCollectorsSettingName = "InProcDataCollectors"; - - /// - /// Name of collect dump option for blame. - /// - public const string BlameCollectDumpKey = "CollectDump"; - - /// - /// Name of collect dump option for blame. - /// - public const string BlameCollectHangDumpKey = "CollectHangDump"; - - /// - /// Name of collect hang dump option for blame. - /// - public const string CollectDumpOnTestSessionHang = "CollectDumpOnTestSessionHang"; - - /// - /// Name of data collection settings node in RunSettings. - /// - public const string DataCollectionRunSettingsName = "DataCollectionRunSettings"; - - /// - /// Name of logger run settings node in RunSettings. - /// - public const string LoggerRunSettingsName = "LoggerRunSettings"; - - /// - /// Name of loggers node in RunSettings. - /// - public const string LoggersSettingName = "Loggers"; - - /// - /// Name of logger node in RunSettings. - /// - public const string LoggerSettingName = "Logger"; - - /// - /// Name of friendlyName attribute of logger node. - /// - public const string LoggerFriendlyName = "friendlyName"; - - /// - /// Name of friendlyName attribute of logger node in lower case. - /// - public const string LoggerFriendlyNameLower = "friendlyname"; - - /// - /// Name of uri attribute of logger node. - /// - public const string LoggerUriName = "uri"; - - /// - /// Name of assemblyQualifiedName attribute of logger node. - /// - public const string LoggerAssemblyQualifiedName = "assemblyQualifiedName"; - - /// - /// Name of assemblyQualifiedName attribute of logger node in lower case. - /// - public const string LoggerAssemblyQualifiedNameLower = "assemblyqualifiedname"; - - /// - /// Name of codeBase attribute of logger node. - /// - public const string LoggerCodeBase = "codeBase"; - - /// - /// Name of codeBase attribute of logger node in lower case. - /// - public const string LoggerCodeBaseLower = "codebase"; - - /// - /// Name of enabled attribute of logger node. - /// - public const string LoggerEnabledName = "enabled"; - - /// - /// Name of configuration element of logger node. - /// - public const string LoggerConfigurationName = "Configuration"; - - /// - /// Name of configuration element of logger node in lower case. - /// - public const string LoggerConfigurationNameLower = "configuration"; - - /// - /// Name of TreatNoTestsAsError parameter - /// - public const string TreatNoTestsAsError = "TreatNoTestsAsError"; - - /// - /// Name of RunConfiguration settings node in RunSettings. - /// - public const string RunConfigurationSettingsName = "RunConfiguration"; - - /// - /// Default testrunner if testrunner is not specified - /// - public const string UnspecifiedAdapterPath = "_none_"; - - public const string DataCollectorsSettingName = "DataCollectors"; - - public const string RunSettingsName = "RunSettings"; - - public const string DataCollectorSettingName = "DataCollector"; - - /// - /// Pattern used to find test run parameter node. - /// - public const string TestRunParametersName = "TestRunParameters"; - - /// - /// Type of the unit test extension. (Extension author will use this name while authoring their Vsix) - /// - public const string UnitTestExtensionType = "UnitTestExtension"; - - /// - /// Maximum size of the trace log file (in kilobytes). - /// - public const string TraceLogMaxFileSizeInKB = "TraceLogMaxFileSizeInKb"; - - public const string EmptyRunSettings = @""; - - public static readonly Architecture DefaultPlatform = XmlRunSettingsUtilities.OSArchitecture; - - /// - /// Adding this for compatibility - /// - public const FrameworkVersion DefaultFramework = FrameworkVersion.Framework40; - - /// - /// Default option for parallel execution - /// - public const int DefaultCpuCount = 1; - - /// - /// The default batch size. - /// - public const long DefaultBatchSize = 10; - - /// - /// The default protocol version - /// - public static readonly ProtocolConfig DefaultProtocolConfig = new ProtocolConfig { Version = 5 }; - - /// - /// The minimum protocol version that has debug support - /// - public const int MinimumProtocolVersionWithDebugSupport = 3; - - /// - /// Name of the results directory - /// - public const string ResultsDirectoryName = "TestResults"; - - /// - /// Default results directory. - /// - public static readonly string DefaultResultsDirectory = + /// + /// The in process data collection run settings name. + /// + public const string InProcDataCollectionRunSettingsName = "InProcDataCollectionRunSettings"; + + /// + /// The in process data collector setting name. + /// + public const string InProcDataCollectorSettingName = "InProcDataCollector"; + + /// + /// The in process data collectors setting name. + /// + public const string InProcDataCollectorsSettingName = "InProcDataCollectors"; + + /// + /// Name of collect dump option for blame. + /// + public const string BlameCollectDumpKey = "CollectDump"; + + /// + /// Name of collect dump option for blame. + /// + public const string BlameCollectHangDumpKey = "CollectHangDump"; + + /// + /// Name of collect hang dump option for blame. + /// + public const string CollectDumpOnTestSessionHang = "CollectDumpOnTestSessionHang"; + + /// + /// Name of data collection settings node in RunSettings. + /// + public const string DataCollectionRunSettingsName = "DataCollectionRunSettings"; + + /// + /// Name of logger run settings node in RunSettings. + /// + public const string LoggerRunSettingsName = "LoggerRunSettings"; + + /// + /// Name of loggers node in RunSettings. + /// + public const string LoggersSettingName = "Loggers"; + + /// + /// Name of logger node in RunSettings. + /// + public const string LoggerSettingName = "Logger"; + + /// + /// Name of friendlyName attribute of logger node. + /// + public const string LoggerFriendlyName = "friendlyName"; + + /// + /// Name of friendlyName attribute of logger node in lower case. + /// + public const string LoggerFriendlyNameLower = "friendlyname"; + + /// + /// Name of uri attribute of logger node. + /// + public const string LoggerUriName = "uri"; + + /// + /// Name of assemblyQualifiedName attribute of logger node. + /// + public const string LoggerAssemblyQualifiedName = "assemblyQualifiedName"; + + /// + /// Name of assemblyQualifiedName attribute of logger node in lower case. + /// + public const string LoggerAssemblyQualifiedNameLower = "assemblyqualifiedname"; + + /// + /// Name of codeBase attribute of logger node. + /// + public const string LoggerCodeBase = "codeBase"; + + /// + /// Name of codeBase attribute of logger node in lower case. + /// + public const string LoggerCodeBaseLower = "codebase"; + + /// + /// Name of enabled attribute of logger node. + /// + public const string LoggerEnabledName = "enabled"; + + /// + /// Name of configuration element of logger node. + /// + public const string LoggerConfigurationName = "Configuration"; + + /// + /// Name of configuration element of logger node in lower case. + /// + public const string LoggerConfigurationNameLower = "configuration"; + + /// + /// Name of TreatNoTestsAsError parameter + /// + public const string TreatNoTestsAsError = "TreatNoTestsAsError"; + + /// + /// Name of RunConfiguration settings node in RunSettings. + /// + public const string RunConfigurationSettingsName = "RunConfiguration"; + + /// + /// Default testrunner if testrunner is not specified + /// + public const string UnspecifiedAdapterPath = "_none_"; + + public const string DataCollectorsSettingName = "DataCollectors"; + + public const string RunSettingsName = "RunSettings"; + + public const string DataCollectorSettingName = "DataCollector"; + + /// + /// Pattern used to find test run parameter node. + /// + public const string TestRunParametersName = "TestRunParameters"; + + /// + /// Type of the unit test extension. (Extension author will use this name while authoring their Vsix) + /// + public const string UnitTestExtensionType = "UnitTestExtension"; + + /// + /// Maximum size of the trace log file (in kilobytes). + /// + public const string TraceLogMaxFileSizeInKB = "TraceLogMaxFileSizeInKb"; + + public const string EmptyRunSettings = @""; + + public static readonly Architecture DefaultPlatform = XmlRunSettingsUtilities.OSArchitecture; + + /// + /// Adding this for compatibility + /// + public const FrameworkVersion DefaultFramework = FrameworkVersion.Framework40; + + /// + /// Default option for parallel execution + /// + public const int DefaultCpuCount = 1; + + /// + /// The default batch size. + /// + public const long DefaultBatchSize = 10; + + /// + /// The default protocol version + /// + public static readonly ProtocolConfig DefaultProtocolConfig = new() { Version = 5 }; + + /// + /// The minimum protocol version that has debug support + /// + public const int MinimumProtocolVersionWithDebugSupport = 3; + + /// + /// Name of the results directory + /// + public const string ResultsDirectoryName = "TestResults"; + + /// + /// Default results directory. + /// + public static readonly string DefaultResultsDirectory = #if NETSTANDARD1_0 Path.Combine(".", ResultsDirectoryName); #else - Path.Combine(Directory.GetCurrentDirectory(), ResultsDirectoryName); + Path.Combine(Directory.GetCurrentDirectory(), ResultsDirectoryName); #endif - /// - /// Default treatment of error from test adapters. - /// - public const bool DefaultTreatTestAdapterErrorsAsWarnings = false; + /// + /// Default treatment of error from test adapters. + /// + public const bool DefaultTreatTestAdapterErrorsAsWarnings = false; - /// - /// The default execution thread apartment state. - /// - [CLSCompliant(false)] + /// + /// The default execution thread apartment state. + /// + [CLSCompliant(false)] #if NETFRAMEWORK - // Keeping default STA thread for desktop tests for UI/Functional test scenarios - public static readonly PlatformApartmentState DefaultExecutionThreadApartmentState = PlatformApartmentState.STA; + // Keeping default STA thread for desktop tests for UI/Functional test scenarios + public static readonly PlatformApartmentState DefaultExecutionThreadApartmentState = PlatformApartmentState.STA; #else - // STA threads are not supported for net core, default to MTA - public static readonly PlatformApartmentState DefaultExecutionThreadApartmentState = PlatformApartmentState.MTA; + // STA threads are not supported for net core, default to MTA + public static readonly PlatformApartmentState DefaultExecutionThreadApartmentState = PlatformApartmentState.MTA; #endif - /// - /// Constants for detecting .net framework. - /// - public const string TargetFrameworkAttributeFullName = "System.Runtime.Versioning.TargetFrameworkAttribute"; - - public const string DotNetFrameWorkStringPrefix = ".NETFramework,Version="; + /// + /// Constants for detecting .net framework. + /// + public const string TargetFrameworkAttributeFullName = "System.Runtime.Versioning.TargetFrameworkAttribute"; - public const string DotNetFramework35 = ".NETFramework,Version=v3.5"; + public const string DotNetFrameWorkStringPrefix = ".NETFramework,Version="; - public const string DotNetFramework40 = ".NETFramework,Version=v4.0"; + public const string DotNetFramework35 = ".NETFramework,Version=v3.5"; - public const string DotNetFramework45 = ".NETFramework,Version=v4.5"; + public const string DotNetFramework40 = ".NETFramework,Version=v4.0"; - public const string DotNetFramework451 = ".NETFramework,Version=v4.5.1"; + public const string DotNetFramework45 = ".NETFramework,Version=v4.5"; - public const string DotNetFramework46 = ".NETFramework,Version=v4.6"; + public const string DotNetFramework451 = ".NETFramework,Version=v4.5.1"; - public const string DotNetFrameworkCore10 = ".NETCoreApp,Version=v1.0"; + public const string DotNetFramework46 = ".NETFramework,Version=v4.6"; - public const string DotNetFrameworkUap10 = "UAP,Version=v10.0"; + public const string DotNetFrameworkCore10 = ".NETCoreApp,Version=v1.0"; - public const string TargetFrameworkName = "TargetFrameworkName"; - } + public const string DotNetFrameworkUap10 = "UAP,Version=v10.0"; - /// - /// Default parameters to be passed onto all loggers. - /// - public static class DefaultLoggerParameterNames - { - // Denotes target location for test run results - // For ex. TrxLogger saves test run results at this target - public const string TestRunDirectory = "TestRunDirectory"; + public const string TargetFrameworkName = "TargetFrameworkName"; +} - // Denotes target framework for the tests. - public const string TargetFramework = "TargetFramework"; - } +/// +/// Default parameters to be passed onto all loggers. +/// +public static class DefaultLoggerParameterNames +{ + // Denotes target location for test run results + // For ex. TrxLogger saves test run results at this target + public const string TestRunDirectory = "TestRunDirectory"; -} + // Denotes target framework for the tests. + public const string TargetFramework = "TargetFramework"; +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Attributes/DataCollectorAttachmentProcessor.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Attributes/DataCollectorAttachmentProcessor.cs index 3688d0c2e0..bc3d3d6e00 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Attributes/DataCollectorAttachmentProcessor.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Attributes/DataCollectorAttachmentProcessor.cs @@ -1,29 +1,28 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +using System; +/// +/// Registers an attachment processor for a data collector. +/// +public class DataCollectorAttachmentProcessorAttribute : Attribute +{ /// - /// Registers an attachment processor for a data collector. + /// Initializes a new instance of the class. /// - public class DataCollectorAttachmentProcessorAttribute : Attribute + /// + /// The type of the attachement data processor. + /// + public DataCollectorAttachmentProcessorAttribute(Type type) { - /// - /// Initializes a new instance of the class. - /// - /// - /// The type of the attachment data processor. - /// - public DataCollectorAttachmentProcessorAttribute(Type type) - { - this.Type = type; - } - - /// - /// Gets the data collector type uri. - /// - public Type Type { get; private set; } + Type = type; } -} + + /// + /// Gets the data collector type uri. + /// + public Type Type { get; private set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Attributes/DataCollectorFriendlyNameAttribute.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Attributes/DataCollectorFriendlyNameAttribute.cs index 90617e7a48..45fb73cf6f 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Attributes/DataCollectorFriendlyNameAttribute.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Attributes/DataCollectorFriendlyNameAttribute.cs @@ -1,29 +1,28 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +using System; +/// +/// Provides a friendly name for the data collector. +/// +public class DataCollectorFriendlyNameAttribute : Attribute +{ /// - /// Provides a friendly name for the data collector. + /// Initializes a new instance of the class. /// - public class DataCollectorFriendlyNameAttribute : Attribute + /// + /// The friendly name. + /// + public DataCollectorFriendlyNameAttribute(string friendlyName) { - /// - /// Initializes a new instance of the class. - /// - /// - /// The friendly name. - /// - public DataCollectorFriendlyNameAttribute(string friendlyName) - { - this.FriendlyName = friendlyName; - } - - /// - /// Gets the friendly name. - /// - public string FriendlyName { get; private set; } + FriendlyName = friendlyName; } -} + + /// + /// Gets the friendly name. + /// + public string FriendlyName { get; private set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Attributes/DataCollectorTypeUriAttribute.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Attributes/DataCollectorTypeUriAttribute.cs index 02571871a3..6a7ac91861 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Attributes/DataCollectorTypeUriAttribute.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Attributes/DataCollectorTypeUriAttribute.cs @@ -1,30 +1,29 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +using System; +/// +/// Provides unique identification of a data collector in the form of a URI. +/// Recommended format: 'datacollector://Company/Product/Version' +/// +public class DataCollectorTypeUriAttribute : Attribute +{ /// - /// Provides unique identification of a data collector in the form of a URI. - /// Recommended format: 'datacollector://Company/Product/Version' + /// Initializes a new instance of the class. /// - public class DataCollectorTypeUriAttribute : Attribute + /// + /// The type uri. + /// + public DataCollectorTypeUriAttribute(string typeUri) { - /// - /// Initializes a new instance of the class. - /// - /// - /// The type uri. - /// - public DataCollectorTypeUriAttribute(string typeUri) - { - this.TypeUri = typeUri; - } - - /// - /// Gets the data collector type uri. - /// - public string TypeUri { get; private set; } + TypeUri = typeUri; } -} + + /// + /// Gets the data collector type uri. + /// + public string TypeUri { get; private set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/DataCollectorMessageLevel.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/DataCollectorMessageLevel.cs index f7ce5b90fc..10032c6c47 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/DataCollectorMessageLevel.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/DataCollectorMessageLevel.cs @@ -1,16 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +/// +/// Severity levels at which a DataCollectionTextMessage can be logged. +/// +public enum DataCollectorMessageLevel { - /// - /// Severity levels at which a DataCollectionTextMessage can be logged. - /// - public enum DataCollectorMessageLevel - { - Error = 0, - Warning = 1, - Info = 2, - Data = 3, - } -} + Error = 0, + Warning = 1, + Info = 2, + Data = 3, +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/FileHelper.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/FileHelper.cs index 7dc96331c6..8ccd93491d 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/FileHelper.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/FileHelper.cs @@ -1,85 +1,82 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Text.RegularExpressions; + +internal sealed class FileHelper { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Diagnostics.CodeAnalysis; - using System.IO; - using System.Text.RegularExpressions; + private static readonly Dictionary InvalidFileNameChars; + private static readonly Regex ReservedFileNamesRegex = new(@"(?i:^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9]|CLOCK\$)(\..*)?)$"); - internal sealed class FileHelper + #region Constructors + static FileHelper() { - private static Dictionary invalidFileNameChars; - private static Regex ReservedFileNamesRegex = new Regex(@"(?i:^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9]|CLOCK\$)(\..*)?)$"); - - #region Constructors - [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")] // Have to init invalidFileNameChars dynamically. - static FileHelper() + // Create a hash table of invalid chars. + char[] invalidCharsArray = Path.GetInvalidFileNameChars(); + InvalidFileNameChars = new Dictionary(invalidCharsArray.Length); + foreach (char c in invalidCharsArray) { - // Create a hash table of invalid chars. - char[] invalidCharsArray = Path.GetInvalidFileNameChars(); - invalidFileNameChars = new Dictionary(invalidCharsArray.Length); - foreach (char c in invalidCharsArray) - { - invalidFileNameChars.Add(c, null); - } + InvalidFileNameChars.Add(c, null); } + } - private FileHelper() - { - } - #endregion + private FileHelper() + { + } + #endregion - #region Fields - /// - /// Determines if a file name has invalid characters. - /// - /// File name to check. - /// Invalid characters which were found in the file name. - /// True if the file name is valid and false if the filename contains invalid characters. - public static bool IsValidFileName(string fileName, out string invalidCharacters) - { - bool result = true; - //EqtAssert.StringNotNullOrEmpty(fileName, "fileName"); + #region Fields + /// + /// Determines if a file name has invalid characters. + /// + /// File name to check. + /// Invalid characters which were found in the file name. + /// True if the file name is valid and false if the filename contains invalid characters. + public static bool IsValidFileName(string fileName, out string invalidCharacters) + { + bool result = true; + //EqtAssert.StringNotNullOrEmpty(fileName, "fileName"); - // Find all of the invalid characters in the file name. - invalidCharacters = null; - for (int i = 0; i < fileName.Length; i++) + // Find all of the invalid characters in the file name. + invalidCharacters = null; + for (int i = 0; i < fileName.Length; i++) + { + if (InvalidFileNameChars.ContainsKey(fileName[i])) { - if (invalidFileNameChars.ContainsKey(fileName[i])) - { - invalidCharacters = String.Concat(invalidCharacters, fileName[i]); - result = false; - } + invalidCharacters = String.Concat(invalidCharacters, fileName[i]); + result = false; } - - return result; } - /// - /// Returns true if the file name specified is Windows reserved file name. - /// - /// The name of the file. Note: only a file name, does not expect to contain directory separators. - internal static bool IsReservedFileName(string fileName) - { - Debug.Assert(!string.IsNullOrEmpty(fileName), "FileHelper.IsReservedFileName: the argument is null or empty string!"); - if (string.IsNullOrEmpty(fileName)) - { - return false; - } + return result; + } - // CreateFile: - // The following reserved device names cannot be used as the name of a file: - // CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, - // LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. - // Also avoid these names followed by an extension, for example, NUL.tx7. - // Windows NT: CLOCK$ is also a reserved device name. - return ReservedFileNamesRegex.Match(fileName).Success; + /// + /// Returns true if the file name specified is Windows reserved file name. + /// + /// The name of the file. Note: only a file name, does not expect to contain directory separators. + internal static bool IsReservedFileName(string fileName) + { + Debug.Assert(!string.IsNullOrEmpty(fileName), "FileHelper.IsReservedFileName: the argument is null or empty string!"); + if (string.IsNullOrEmpty(fileName)) + { + return false; } - #endregion + // CreateFile: + // The following reserved device names cannot be used as the name of a file: + // CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, + // LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. + // Also avoid these names followed by an extension, for example, NUL.tx7. + // Windows NT: CLOCK$ is also a reserved device name. + return ReservedFileNamesRegex.Match(fileName).Success; } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/RequestId.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/RequestId.cs index 32b530d20d..3104543fa6 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/RequestId.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/RequestId.cs @@ -1,209 +1,195 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +using System; +using System.Runtime.Serialization; + +using Resources; + +/// +/// Wrapper class for a request ID that can be used for messages or events for identification +/// purposes +/// +[DataContract] +public sealed class RequestId : IEquatable, IComparable, IComparable { - using System; - using System.Diagnostics.CodeAnalysis; - using System.Runtime.Serialization; + #region Constants - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources; + /// + /// A request ID with an empty GUID + /// + public static readonly RequestId Empty = new(Guid.Empty); + + #endregion + + #region Constructors /// - /// Wrapper class for a request ID that can be used for messages or events for identification - /// purposes + /// Initializes the instance by creating a new GUID /// - [DataContract] - [SuppressMessage("Microsoft.Design", "CA1036:OverrideMethodsOnComparableTypes", - Justification = "Guid does not define < and > operators")] - public sealed class RequestId : IEquatable, IComparable, IComparable + internal RequestId() { - #region Constants + Id = Guid.NewGuid(); + } - /// - /// A request ID with an empty GUID - /// - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - Justification = "RequestId is immutable")] - public static readonly RequestId Empty = new RequestId(Guid.Empty); + /// + /// Initializes the instance with the provided GUID + /// + /// The GUID to use as the underlying ID + internal RequestId(Guid id) + { + Id = id; + } - #endregion + #endregion - #region Constructors + #region Overrides - /// - /// Initializes the instance by creating a new GUID - /// - internal RequestId() + /// + /// Compares this instance with the provided object for value equality + /// + /// The object to compare to + /// True if equal, false otherwise + public override bool Equals(object obj) + { + if (obj == null) { - Id = Guid.NewGuid(); + return false; } - /// - /// Initializes the instance with the provided GUID - /// - /// The GUID to use as the underlying ID - internal RequestId(Guid id) + if (ReferenceEquals(this, obj)) { - Id = id; + return true; } - #endregion - - #region Overrides - - /// - /// Compares this instance with the provided object for value equality - /// - /// The object to compare to - /// True if equal, false otherwise - public override bool Equals(object obj) - { - if (obj == null) - { - return false; - } - - if (object.ReferenceEquals(this, obj)) - { - return true; - } - - RequestId other = obj as RequestId; - if (other == null) - { - return false; - } - - return Id == other.Id; - } + RequestId other = obj as RequestId; + return other != null && Id == other.Id; + } - /// - /// Gets a hash code for this instance - /// - /// The underlying GUID's hash code - public override int GetHashCode() - { - return Id.GetHashCode(); - } + /// + /// Gets a hash code for this instance + /// + /// The underlying GUID's hash code + public override int GetHashCode() + { + return Id.GetHashCode(); + } - /// - /// Converts the instance to a string in lower-case registry format - /// - /// A lower-case string in registry format representing the underlying GUID - public override string ToString() - { - return Id.ToString("B"); - } + /// + /// Converts the instance to a string in lower-case registry format + /// + /// A lower-case string in registry format representing the underlying GUID + public override string ToString() + { + return Id.ToString("B"); + } - #endregion + #endregion - #region Interface implementations + #region Interface implementations - #region IEquatable Members + #region IEquatable Members - /// - /// Compares this instance with the provided request ID for value equality - /// - /// The request ID to compare to - /// True if equal, false otherwise - public bool Equals(RequestId other) - { - return - other != null && ( - object.ReferenceEquals(this, other) || - Id == other.Id - ); - } + /// + /// Compares this instance with the provided request ID for value equality + /// + /// The request ID to compare to + /// True if equal, false otherwise + public bool Equals(RequestId other) + { + return + other != null && ( + ReferenceEquals(this, other) || + Id == other.Id + ); + } - #endregion + #endregion - #region IComparable Members + #region IComparable Members - /// - /// Compares this instance with the provided request ID - /// - /// The request ID to compare to - /// An indication of the two request IDs' relative values - public int CompareTo(RequestId other) - { - return other == null ? 1 : Id.CompareTo(other.Id); - } + /// + /// Compares this instance with the provided request ID + /// + /// The request ID to compare to + /// An indication of the two request IDs' relative values + public int CompareTo(RequestId other) + { + return other == null ? 1 : Id.CompareTo(other.Id); + } - #endregion + #endregion - #region IComparable Members + #region IComparable Members - /// - /// Compares this instance with the provided object - /// - /// The object to compare to - /// An indication of the two objects' relative values - /// - /// 'obj' is not null and not an instance of - /// - public int CompareTo(object obj) + /// + /// Compares this instance with the provided object + /// + /// The object to compare to + /// An indication of the two objects' relative values + /// + /// 'obj' is not null and not an instance of + /// + public int CompareTo(object obj) + { + if (obj == null) { - if (obj == null) - { - return 1; - } - - RequestId other = obj as RequestId; - if (other == null) - { - throw new ArgumentException(string.Format(Resources.Common_ObjectMustBeOfType, new object[] { typeof(RequestId).Name }), nameof(obj)); - } - - return Id.CompareTo(other.Id); + return 1; } - #endregion + RequestId other = obj as RequestId; + return other == null + ? throw new ArgumentException(string.Format(Resources.Common_ObjectMustBeOfType, new object[] { typeof(RequestId).Name }), nameof(obj)) + : Id.CompareTo(other.Id); + } - #endregion + #endregion - #region Operators + #endregion - /// - /// Compares the two request IDs for value equality - /// - /// The left-hand request ID - /// The right-hand request ID - /// True if equal, false otherwise - public static bool operator ==(RequestId left, RequestId right) - { - return - object.ReferenceEquals(left, right) || - !object.ReferenceEquals(left, null) && - !object.ReferenceEquals(right, null) && - left.Id == right.Id; - } + #region Operators - /// - /// Compares two request IDs for value inequality - /// - /// The left-hand request ID - /// The right-hand request ID - /// True if unequal, false otherwise - public static bool operator !=(RequestId left, RequestId right) - { - return !(left == right); - } + /// + /// Compares the two request IDs for value equality + /// + /// The left-hand request ID + /// The right-hand request ID + /// True if equal, false otherwise + public static bool operator ==(RequestId left, RequestId right) + { + return + ReferenceEquals(left, right) || + left is not null && + right is not null && + left.Id == right.Id; + } - #endregion + /// + /// Compares two request IDs for value inequality + /// + /// The left-hand request ID + /// The right-hand request ID + /// True if unequal, false otherwise + public static bool operator !=(RequestId left, RequestId right) + { + return !(left == right); + } - #region Properties + #endregion - /// - /// Gets the underlying GUID that represents the request ID - /// - [DataMember] - public Guid Id - { - get; - private set; - } + #region Properties - #endregion + /// + /// Gets the underlying GUID that represents the request ID + /// + [DataMember] + public Guid Id + { + get; + private set; } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/Session.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/Session.cs index 3f9bafdd9b..49bcfa6940 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/Session.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/Session.cs @@ -1,63 +1,45 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +using System; +using System.Runtime.Serialization; + +/// +/// Class identifying a session. +/// +[DataContract] +public sealed class SessionId { - using System; - using System.Runtime.Serialization; - - /// - /// Class identifying a session. - /// - [DataContract] - public sealed class SessionId + public SessionId() + { + Id = Guid.NewGuid(); + } + + public SessionId(Guid id) + { + Id = id; + } + + [DataMember] + public static SessionId Empty { get; } = new SessionId(Guid.Empty); + + [DataMember] + public Guid Id { get; } + + public override bool Equals(object obj) + { + return obj is SessionId sessionId && Id.Equals(sessionId.Id); + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + + public override string ToString() { - private Guid sessionId; - - private static SessionId empty = new SessionId(Guid.Empty); - - public SessionId() - { - sessionId = Guid.NewGuid(); - } - - public SessionId(Guid id) - { - sessionId = id; - } - - [DataMember] - public static SessionId Empty - { - get { return empty; } - } - - [DataMember] - public Guid Id - { - get { return sessionId; } - } - - public override bool Equals(object obj) - { - SessionId id = obj as SessionId; - - if (id == null) - { - return false; - } - - return sessionId.Equals(id.sessionId); - } - - public override int GetHashCode() - { - return sessionId.GetHashCode(); - } - - public override string ToString() - { - return sessionId.ToString("B"); - } + return Id.ToString("B"); } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/TestCaseFailureType.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/TestCaseFailureType.cs index 5f50be9872..e4355822eb 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/TestCaseFailureType.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/TestCaseFailureType.cs @@ -1,18 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +/// +/// Type of test case failure which occurred. +/// +public enum TestCaseFailureType { - /// - /// Type of test case failure which occurred. - /// - public enum TestCaseFailureType - { - None = 0, - Assertion = 1, - UnhandledException = 2, - UnexpectedException = 3, - MissingException = 4, - Other = 5, - } -} + None = 0, + Assertion = 1, + UnhandledException = 2, + UnexpectedException = 3, + MissingException = 4, + Other = 5, +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/TestExecId.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/TestExecId.cs index a79813433f..fe75991c09 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/TestExecId.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/TestExecId.cs @@ -1,64 +1,46 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection -{ - using System; - using System.Runtime.Serialization; - - /// - /// Class identifying test execution id. - /// Execution ID is assigned to test at run creation time and is guaranteed to be unique within that run. - /// - [DataContract] - public sealed class TestExecId - { - private Guid execId; - - private static TestExecId empty = new TestExecId(Guid.Empty); +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - public TestExecId() - { - execId = Guid.NewGuid(); - } +using System; +using System.Runtime.Serialization; - public TestExecId(Guid id) - { - execId = id; - } - - [DataMember] - public static TestExecId Empty - { - get { return empty; } - } +/// +/// Class identifying test execution id. +/// Execution ID is assigned to test at run creation time and is guaranteed to be unique within that run. +/// +[DataContract] +public sealed class TestExecId +{ + public TestExecId() + { + Id = Guid.NewGuid(); + } - [DataMember] - public Guid Id - { - get { return execId; } - } + public TestExecId(Guid id) + { + Id = id; + } - public override bool Equals(object obj) - { - TestExecId id = obj as TestExecId; + [DataMember] + public static TestExecId Empty { get; } = new TestExecId(Guid.Empty); - if (id == null) - { - return false; - } + [DataMember] + public Guid Id { get; } - return execId.Equals(id.execId); - } + public override bool Equals(object obj) + { + return obj is TestExecId testExecId && Id.Equals(testExecId.Id); + } - public override int GetHashCode() - { - return execId.GetHashCode(); - } + public override int GetHashCode() + { + return Id.GetHashCode(); + } - public override string ToString() - { - return execId.ToString("B"); - } + public override string ToString() + { + return Id.ToString("B"); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionContext.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionContext.cs index 93cd1d125a..6415d83aca 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionContext.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionContext.cs @@ -1,179 +1,159 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +using System.Runtime.Serialization; + +/// +/// Class representing the context in which data collection occurs. +/// +[DataContract] +public class DataCollectionContext { - using System; - using System.Runtime.Serialization; + #region Constructors + + // NOTE: These constructors are protected internal to allow 3rd parties to + // do unit testing of their data collectors. + // + // We do not want to make the constructors of this class public as it + // would lead to a great deal of user error when they start creating + // their own data collection context instances to log errors/warnings + // or send files with. The potential for this type of error still + // exists by having the protected constructor, but it is less likely + // and we have added safeguards in our DataCollectinLogger and + // DataCollectionDataSink to safeguard against derived types being + // passed to us. + // + // In order to create mock instances of the DataCollectionContext for + // unit testing purposes, 3rd parties can derive from this class and + // have public constructors. This will allow them to instantiate their + // class and pass to us for creating data collection events. /// - /// Class representing the context in which data collection occurs. + /// Constructs DataCollection Context for in process data collectors /// - [DataContract] - public class DataCollectionContext + /// test case to identify the context + public DataCollectionContext(TestCase testCase) { - #region Constructors - - // NOTE: These constructors are protected internal to allow 3rd parties to - // do unit testing of their data collectors. - // - // We do not want to make the constructors of this class public as it - // would lead to a great deal of user error when they start creating - // their own data collection context instances to log errors/warnings - // or send files with. The potential for this type of error still - // exists by having the protected constructor, but it is less likely - // and we have added safeguards in our DataCollectinLogger and - // DataCollectionDataSink to safeguard against derived types being - // passed to us. - // - // In order to create mock instances of the DataCollectionContext for - // unit testing purposes, 3rd parties can derive from this class and - // have public constructors. This will allow them to instantiate their - // class and pass to us for creating data collection events. - - /// - /// Constructs DataCollection Context for in process data collectors - /// - /// test case to identify the context - public DataCollectionContext(TestCase testCase) - { - this.TestCase = testCase; - } - - /// - /// Constructs a DataCollectionContext indicating that there is a session, - /// but no executing test, in context. - /// - /// The session under which the data collection occurs. Cannot be null. - protected internal DataCollectionContext(SessionId sessionId) - : this(sessionId, (TestExecId)null) - { - } - - /// - /// Constructs a DataCollectionContext indicating that there is a session and an executing test, - /// but no test step, in context. - /// - /// The session under which the data collection occurs. Cannot be null. - /// The test execution under which the data collection occurs, - /// or null if no executing test case is in context - protected internal DataCollectionContext(SessionId sessionId, TestExecId testExecId) - { - //TODO - //EqtAssert.ParameterNotNull(sessionId, "sessionId"); + TestCase = testCase; + } - this.sessionId = sessionId; - this.testExecId = testExecId; - this.hashCode = ComputeHashCode(); - } + /// + /// Constructs a DataCollectionContext indicating that there is a session, + /// but no executing test, in context. + /// + /// The session under which the data collection occurs. Cannot be null. + protected internal DataCollectionContext(SessionId sessionId) + : this(sessionId, (TestExecId)null) + { + } - protected internal DataCollectionContext(SessionId sessionId, TestCase testCase) : this(sessionId, new TestExecId(testCase.Id)) - { - this.TestCase = testCase; + /// + /// Constructs a DataCollectionContext indicating that there is a session and an executing test, + /// but no test step, in context. + /// + /// The session under which the data collection occurs. Cannot be null. + /// The test execution under which the data collection occurs, + /// or null if no executing test case is in context + protected internal DataCollectionContext(SessionId sessionId, TestExecId testExecId) + { + //TODO + //EqtAssert.ParameterNotNull(sessionId, "sessionId"); - } - #endregion + SessionId = sessionId; + TestExecId = testExecId; + _hashCode = ComputeHashCode(); + } - #region Properties + protected internal DataCollectionContext(SessionId sessionId, TestCase testCase) : this(sessionId, new TestExecId(testCase.Id)) + { + TestCase = testCase; - /// - /// Gets test case. - /// - [DataMember] - public TestCase TestCase { get; private set; } + } + #endregion - /// - /// Identifies the session under which the data collection occurs. Will not be null. - /// - [DataMember] - public SessionId SessionId - { - get - { - return sessionId; - } - } + #region Properties - /// - /// Identifies the test execution under which the data collection occurs, - /// or null if no such test exists. - /// - [DataMember] - public TestExecId TestExecId - { - get - { - return testExecId; - } - } + /// + /// Gets test case. + /// + [DataMember] + public TestCase TestCase { get; private set; } - /// - /// Returns true if there is an executing test case associated with this context. - /// - [DataMember] - public bool HasTestCase - { - get { return testExecId != null; } - } + /// + /// Identifies the session under which the data collection occurs. Will not be null. + /// + [DataMember] + public SessionId SessionId { get; private set; } - #endregion + /// + /// Identifies the test execution under which the data collection occurs, + /// or null if no such test exists. + /// + [DataMember] + public TestExecId TestExecId { get; private set; } - #region Equals and Hashcode + /// + /// Returns true if there is an executing test case associated with this context. + /// + [DataMember] + public bool HasTestCase + { + get { return TestExecId != null; } + } - public static bool operator ==(DataCollectionContext context1, DataCollectionContext context2) - { - return object.Equals(context1, context2); - } + #endregion - public static bool operator !=(DataCollectionContext context1, DataCollectionContext context2) - { - return !(context1 == context2); - } + #region Equals and Hashcode - public override bool Equals(object obj) - { - DataCollectionContext other = obj as DataCollectionContext; + public static bool operator ==(DataCollectionContext context1, DataCollectionContext context2) + { + return Equals(context1, context2); + } - if (other == null) - { - return false; - } + public static bool operator !=(DataCollectionContext context1, DataCollectionContext context2) + { + return !(context1 == context2); + } - return sessionId.Equals(other.sessionId) - && (testExecId == null ? other.testExecId == null : testExecId.Equals(other.testExecId)); - } + public override bool Equals(object obj) + { + DataCollectionContext other = obj as DataCollectionContext; - public override int GetHashCode() - { - return hashCode; - } + return other != null + && SessionId.Equals(other.SessionId) + && (TestExecId == null ? other.TestExecId == null : TestExecId.Equals(other.TestExecId)); + } - #endregion + public override int GetHashCode() + { + return _hashCode; + } - #region Private Methods + #endregion - private int ComputeHashCode() - { - int hashCode = 17; + #region Private Methods - hashCode = 31 * hashCode + sessionId.GetHashCode(); + private int ComputeHashCode() + { + int hashCode = 17; - if (testExecId != null) - { - hashCode = 31 * hashCode + testExecId.GetHashCode(); - } + hashCode = 31 * hashCode + SessionId.GetHashCode(); - return hashCode; + if (TestExecId != null) + { + hashCode = 31 * hashCode + TestExecId.GetHashCode(); } - #endregion + return hashCode; + } - #region Private Fields + #endregion - private readonly SessionId sessionId; - private readonly TestExecId testExecId; - private readonly int hashCode; + #region Private Fields - #endregion - } -} + private readonly int _hashCode; + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionEnvironmentContext.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionEnvironmentContext.cs index 612b8b09cb..538d13e977 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionEnvironmentContext.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionEnvironmentContext.cs @@ -1,88 +1,76 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection -{ +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + #if NETFRAMEWORK - using System; +using System; #endif - /// - /// Encapsulates the context of the environment a data collector is being hosted in. - /// +/// +/// Encapsulates the context of the environment a data collector is being hosted in. +/// #if NETFRAMEWORK - [Serializable] +[Serializable] #endif - public sealed class DataCollectionEnvironmentContext - { - #region Fields - /// - /// DataCollectionContext for the session. - /// - private DataCollectionContext sessionDataCollectionContext; +public sealed class DataCollectionEnvironmentContext +{ + #region Fields + /// + /// DataCollectionContext for the session. + /// - #endregion + #endregion - #region Constructors and initialization + #region Constructors and initialization - /// - /// Default Constructor - /// - internal DataCollectionEnvironmentContext() - : this(null) - { - } + /// + /// Default Constructor + /// + internal DataCollectionEnvironmentContext() + : this(null) + { + } - /// - /// Initializes with the DataCollectionContext - /// - public DataCollectionEnvironmentContext(DataCollectionContext sessionDataCollectionContext) - { - SessionDataCollectionContext = sessionDataCollectionContext; - } + /// + /// Initializes with the DataCollectionContext + /// + public DataCollectionEnvironmentContext(DataCollectionContext sessionDataCollectionContext) + { + SessionDataCollectionContext = sessionDataCollectionContext; + } - /// - /// Creates an environment context for a local (hosted) agent and controller - /// - /// An environment context for a local (hosted) agent and controller - public static DataCollectionEnvironmentContext CreateForLocalEnvironment() - { - return CreateForLocalEnvironment(null); - } + /// + /// Creates an environment context for a local (hosted) agent and controller + /// + /// An environment context for a local (hosted) agent and controller + public static DataCollectionEnvironmentContext CreateForLocalEnvironment() + { + return CreateForLocalEnvironment(null); + } - /// - /// Creates an environment context for a local (hosted) agent and controller - /// - /// Session level data collection context. - /// An environment context for a local (hosted) agent and controller - public static DataCollectionEnvironmentContext CreateForLocalEnvironment(DataCollectionContext sessionDataCollectionContext) - { - var dataCollectionEnvironmentContext = new DataCollectionEnvironmentContext(); - dataCollectionEnvironmentContext.SessionDataCollectionContext = sessionDataCollectionContext; + /// + /// Creates an environment context for a local (hosted) agent and controller + /// + /// Session level data collection context. + /// An environment context for a local (hosted) agent and controller + public static DataCollectionEnvironmentContext CreateForLocalEnvironment(DataCollectionContext sessionDataCollectionContext) + { + var dataCollectionEnvironmentContext = new DataCollectionEnvironmentContext(); + dataCollectionEnvironmentContext.SessionDataCollectionContext = sessionDataCollectionContext; - return dataCollectionEnvironmentContext; - } + return dataCollectionEnvironmentContext; + } - #endregion + #endregion - #region Properties + #region Properties - /// - /// DataCollectionContext for the session. - /// - public DataCollectionContext SessionDataCollectionContext - { - get - { - return sessionDataCollectionContext; - } - internal set - { - sessionDataCollectionContext = value; - } - } + /// + /// DataCollectionContext for the session. + /// + public DataCollectionContext SessionDataCollectionContext { get; internal set; } - #endregion - } -} + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionLogger.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionLogger.cs index 27f8f76964..a9e1f13c33 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionLogger.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionLogger.cs @@ -1,81 +1,80 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +using System; +/// +/// Class used by data collectors to send messages to the client (e.g. Manual Test Runner, Visual Studio IDE, MSTest). +/// +public abstract class DataCollectionLogger +{ /// - /// Class used by data collectors to send messages to the client (e.g. Manual Test Runner, Visual Studio IDE, MSTest). + /// Constructs a DataCollectionLogger /// - public abstract class DataCollectionLogger + protected DataCollectionLogger() { - /// - /// Constructs a DataCollectionLogger - /// - protected DataCollectionLogger() - { - } - - #region Public Members + } - /// - /// Logs an error message. - /// - /// The context in which the message is being sent. - /// The error text. Cannot be null. - /// - /// When a Data Collector invokes this method, Client would get called on OnCollectionError( ) with a CollectionErrorMessageEventArgs. - /// - public abstract void LogError(DataCollectionContext context, string text); + #region Public Members - /// - /// Logs an error message for an exception. - /// - /// The context in which the message is being sent. - /// The exception. Cannot be null. - /// - /// When a Data Collector invokes this method, Client would get called on OnCollectionError( ) with a CollectionErrorMessageEventArgs. - /// - public void LogError(DataCollectionContext context, Exception exception) - { - LogError(context, string.Empty, exception); - } + /// + /// Logs an error message. + /// + /// The context in which the message is being sent. + /// The error text. Cannot be null. + /// + /// When a Data Collector invokes this method, Client would get called on OnCollectionError( ) with a CollectionErrorMessageEventArgs. + /// + public abstract void LogError(DataCollectionContext context, string text); - /// - /// Logs an error message for an exception. - /// - /// The context in which the message is being sent. - /// Text explaining the exception. Cannot be null. - /// The exception. Cannot be null. - /// - /// When a Data Collector invokes this method, Client would get called on OnCollectionError( ) with a CollectionErrorMessageEventArgs. - /// - public abstract void LogError(DataCollectionContext context, string text, Exception exception); + /// + /// Logs an error message for an exception. + /// + /// The context in which the message is being sent. + /// The exception. Cannot be null. + /// + /// When a Data Collector invokes this method, Client would get called on OnCollectionError( ) with a CollectionErrorMessageEventArgs. + /// + public void LogError(DataCollectionContext context, Exception exception) + { + LogError(context, string.Empty, exception); + } - /// - /// Logs a warning. - /// - /// The context in which the message is being sent. - /// The warning text. Cannot be null. - /// - /// When a Data Collector invokes this method, Client would get called on OnCollectionWarning( ) with a CollectionWarningMessageEventArgs. - /// - public abstract void LogWarning(DataCollectionContext context, string text); + /// + /// Logs an error message for an exception. + /// + /// The context in which the message is being sent. + /// Text explaining the exception. Cannot be null. + /// The exception. Cannot be null. + /// + /// When a Data Collector invokes this method, Client would get called on OnCollectionError( ) with a CollectionErrorMessageEventArgs. + /// + public abstract void LogError(DataCollectionContext context, string text, Exception exception); - /// - /// Logs and given exception to the client. - /// - /// - /// The exception to be logged - /// Is the exception at warning level or error level. - /// - /// When a Data Collector invokes this method, Client would get called on OnCollectionException( ) with a CollectionExceptionMessageEventArgs. - /// - public virtual void LogException(DataCollectionContext context, Exception ex, DataCollectorMessageLevel level) - { - } + /// + /// Logs a warning. + /// + /// The context in which the message is being sent. + /// The warning text. Cannot be null. + /// + /// When a Data Collector invokes this method, Client would get called on OnCollectionWarning( ) with a CollectionWarningMessageEventArgs. + /// + public abstract void LogWarning(DataCollectionContext context, string text); - #endregion + /// + /// Logs and given exception to the client. + /// + /// + /// The exception to be logged + /// Is the exception at warning level or error level. + /// + /// When a Data Collector invokes this method, Client would get called on OnCollectionException( ) with a CollectionExceptionMessageEventArgs. + /// + public virtual void LogException(DataCollectionContext context, Exception ex, DataCollectorMessageLevel level) + { } + + #endregion } diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionRunSettings.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionRunSettings.cs index fe86e4fbdd..dbab473408 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionRunSettings.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionRunSettings.cs @@ -1,233 +1,229 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Globalization; +using System.Linq; +using System.Xml; + +/// +/// The in procedure data collection run settings. +/// +public class DataCollectionRunSettings : TestRunSettings { - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Diagnostics.CodeAnalysis; - using System.Globalization; - using System.Linq; - using System.Xml; + private readonly string _dataCollectionRootName = string.Empty; + + private readonly string _dataCollectionsName = string.Empty; + + private readonly string _dataCollectorName = string.Empty; /// - /// The in procedure data collection run settings. + /// Initializes a new instance of the class. /// - public class DataCollectionRunSettings : TestRunSettings + public DataCollectionRunSettings() : base(Constants.DataCollectionRunSettingsName) { - private string dataCollectionRootName = string.Empty; - - private string dataCollectionsName = string.Empty; + DataCollectorSettingsList = new Collection(); + _dataCollectionRootName = Constants.DataCollectionRunSettingsName; + _dataCollectionsName = Constants.DataCollectorsSettingName; + _dataCollectorName = Constants.DataCollectorSettingName; + } - private string dataCollectorName = string.Empty; + /// + /// Initializes a new instance of the class. + /// + /// + /// The data collection root name. + /// + /// + /// The data collections name. + /// + /// + /// The data collector name. + /// + public DataCollectionRunSettings( + string dataCollectionRootName, + string dataCollectionsName, + string dataCollectorName) + : base(dataCollectionRootName) + { + _dataCollectionRootName = dataCollectionRootName; + _dataCollectionsName = dataCollectionsName; + _dataCollectorName = dataCollectorName; + DataCollectorSettingsList = new Collection(); + } - /// - /// Initializes a new instance of the class. - /// - public DataCollectionRunSettings() : base(Constants.DataCollectionRunSettingsName) - { - this.DataCollectorSettingsList = new Collection(); - this.dataCollectionRootName = Constants.DataCollectionRunSettingsName; - this.dataCollectionsName = Constants.DataCollectorsSettingName; - this.dataCollectorName = Constants.DataCollectorSettingName; - } + /// + /// Gets the in procedure data collector settings list. + /// + public Collection DataCollectorSettingsList + { + get; + private set; + } - /// - /// Initializes a new instance of the class. - /// - /// - /// The data collection root name. - /// - /// - /// The data collections name. - /// - /// - /// The data collector name. - /// - public DataCollectionRunSettings( - string dataCollectionRootName, - string dataCollectionsName, - string dataCollectorName) - : base(dataCollectionRootName) + /// + /// Gets a value indicating whether is in procedure data collection enabled. + /// + public bool IsCollectionEnabled + { + get { - this.dataCollectionRootName = dataCollectionRootName; - this.dataCollectionsName = dataCollectionsName; - this.dataCollectorName = dataCollectorName; - this.DataCollectorSettingsList = new Collection(); + return DataCollectorSettingsList.Any(setting => setting.IsEnabled); } + } - /// - /// Gets the in procedure data collector settings list. - /// - public Collection DataCollectorSettingsList - { - get; - private set; - } + /// + /// The to xml. + /// + /// + /// The . + /// + public override XmlElement ToXml() + { + XmlDocument doc = new(); + XmlElement root = doc.CreateElement(_dataCollectionRootName); + XmlElement subRoot = doc.CreateElement(_dataCollectionsName); + root.AppendChild(subRoot); - /// - /// Gets a value indicating whether is in procedure data collection enabled. - /// - public bool IsCollectionEnabled + foreach (var collectorSettings in DataCollectorSettingsList) { - get - { - return this.DataCollectorSettingsList.Any(setting => setting.IsEnabled); - } + XmlNode child = doc.ImportNode(collectorSettings.ToXml(_dataCollectorName), true); + subRoot.AppendChild(child); } - /// - /// The to xml. - /// - /// - /// The . - /// - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", - Justification = "XmlDocument.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] - public override XmlElement ToXml() - { - XmlDocument doc = new XmlDocument(); - XmlElement root = doc.CreateElement(this.dataCollectionRootName); - XmlElement subRoot = doc.CreateElement(this.dataCollectionsName); - root.AppendChild(subRoot); + return root; + } - foreach (var collectorSettings in this.DataCollectorSettingsList) - { - XmlNode child = doc.ImportNode(collectorSettings.ToXml(this.dataCollectorName), true); - subRoot.AppendChild(child); - } + /// + /// The from xml. + /// + /// + /// The reader. + /// + /// + /// The . + /// + /// + /// Settings exception + /// + public static DataCollectionRunSettings FromXml(XmlReader reader) + { + return CreateDataCollectionRunSettings( + reader, + Constants.DataCollectionRunSettingsName, + Constants.DataCollectorsSettingName, + Constants.DataCollectorSettingName); + } - return root; - } + public static DataCollectionRunSettings FromXml(XmlReader reader, string dataCollectionName, string dataCollectorsName, string dataCollectorName) + { + return CreateDataCollectionRunSettings(reader, dataCollectionName, dataCollectorsName, dataCollectorName); + } - /// - /// The from xml. - /// - /// - /// The reader. - /// - /// - /// The . - /// - /// - /// Settings exception - /// - public static DataCollectionRunSettings FromXml(XmlReader reader) - { - return CreateDataCollectionRunSettings( - reader, - Constants.DataCollectionRunSettingsName, - Constants.DataCollectorsSettingName, - Constants.DataCollectorSettingName); - } + public static DataCollectionRunSettings CreateDataCollectionRunSettings( + XmlReader reader, string dataCollectionName, + string dataCollectorsName, string dataCollectorName) + { + ValidateArg.NotNull(reader, nameof(reader)); + ValidateArg.NotNull(dataCollectorsName, nameof(dataCollectorsName)); + ValidateArg.NotNull(dataCollectorName, nameof(dataCollectorName)); - public static DataCollectionRunSettings FromXml(XmlReader reader, string dataCollectionName, string dataCollectorsName, string dataCollectorName) + DataCollectionRunSettings settings = new(dataCollectionName, dataCollectorsName, dataCollectorName); + bool empty = reader.IsEmptyElement; + if (reader.HasAttributes) { - return CreateDataCollectionRunSettings(reader, dataCollectionName, dataCollectorsName, dataCollectorName); + reader.MoveToNextAttribute(); + throw new SettingsException( + string.Format( + CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsXmlAttribute, + dataCollectorsName, + reader.Name)); } - public static DataCollectionRunSettings CreateDataCollectionRunSettings( - XmlReader reader, string dataCollectionName, - string dataCollectorsName, string dataCollectorName) + // Process the fields in Xml elements + reader.Read(); + if (!empty) { - ValidateArg.NotNull(reader, nameof(reader)); - ValidateArg.NotNull(dataCollectorsName, nameof(dataCollectorsName)); - ValidateArg.NotNull(dataCollectorName, nameof(dataCollectorName)); - - DataCollectionRunSettings settings = new DataCollectionRunSettings(dataCollectionName, dataCollectorsName, dataCollectorName); - bool empty = reader.IsEmptyElement; - if (reader.HasAttributes) - { - reader.MoveToNextAttribute(); - throw new SettingsException( - string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsXmlAttribute, - dataCollectorsName, - reader.Name)); - } - - // Process the fields in Xml elements - reader.Read(); - if (!empty) + while (reader.NodeType == XmlNodeType.Element) { - while (reader.NodeType == XmlNodeType.Element) + if (reader.Name.Equals(dataCollectorsName)) { - if (reader.Name.Equals(dataCollectorsName)) - { - var items = ReadListElementFromXml(reader, dataCollectorName); - foreach (var item in items) - { - settings.DataCollectorSettingsList.Add(item); - } - } - else + var items = ReadListElementFromXml(reader, dataCollectorName); + foreach (var item in items) { - throw new SettingsException( - string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsXmlElement, - dataCollectorsName, - reader.Name)); + settings.DataCollectorSettingsList.Add(item); } } - - reader.ReadEndElement(); + else + { + throw new SettingsException( + string.Format( + CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsXmlElement, + dataCollectorsName, + reader.Name)); + } } - return settings; + reader.ReadEndElement(); } - /// - /// The read list element from xml. - /// - /// - /// The reader. - /// - /// - /// The . - /// - /// - /// - internal static List ReadListElementFromXml(XmlReader reader, string dataCollectorsName) + return settings; + } + + /// + /// The read list element from xml. + /// + /// + /// The reader. + /// + /// + /// The . + /// + /// + /// + internal static List ReadListElementFromXml(XmlReader reader, string dataCollectorsName) + { + List settings = new(); + bool empty = reader.IsEmptyElement; + if (reader.HasAttributes) { - List settings = new List(); - bool empty = reader.IsEmptyElement; - if (reader.HasAttributes) - { - reader.MoveToNextAttribute(); - throw new SettingsException( - string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsXmlAttribute, - dataCollectorsName, - reader.Name)); - } + reader.MoveToNextAttribute(); + throw new SettingsException( + string.Format( + CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsXmlAttribute, + dataCollectorsName, + reader.Name)); + } - reader.Read(); - if (!empty) + reader.Read(); + if (!empty) + { + while (reader.NodeType == XmlNodeType.Element) { - while (reader.NodeType == XmlNodeType.Element) + if (reader.Name.Equals(dataCollectorsName)) { - if (reader.Name.Equals(dataCollectorsName)) - { - settings.Add(DataCollectorSettings.FromXml(reader)); - } - else - { - throw new SettingsException( - string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsXmlElement, - dataCollectorsName, - reader.Name)); - } + settings.Add(DataCollectorSettings.FromXml(reader)); + } + else + { + throw new SettingsException( + string.Format( + CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsXmlElement, + dataCollectorsName, + reader.Name)); } - - reader.ReadEndElement(); } - return settings; + reader.ReadEndElement(); } + + return settings; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionSink.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionSink.cs index 8a790b9310..ec8333c9c3 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionSink.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionSink.cs @@ -1,70 +1,67 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using System.ComponentModel; + +/// +/// Class used by data collectors to send data to up-stream components +/// +public abstract class DataCollectionSink { - using System; - using System.ComponentModel; + #region Constructor /// - /// Class used by data collectors to send data to up-stream components + /// Initializes a new instance of the class. /// - public abstract class DataCollectionSink + protected DataCollectionSink() { - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - protected DataCollectionSink() - { - } + } - #endregion + #endregion - #region Events + #region Events - /// - /// Called when sending of a file has completed. - /// - public abstract event AsyncCompletedEventHandler SendFileCompleted; + /// + /// Called when sending of a file has completed. + /// + public abstract event AsyncCompletedEventHandler SendFileCompleted; - #endregion + #endregion - #region SendFileAsync + #region SendFileAsync - /// - /// Sends a file to up-stream components. - /// - /// The context in which the file is being sent. Cannot be null. - /// the path to the file on the local file system - /// True to automatically have the file removed after sending it. - public void SendFileAsync(DataCollectionContext context, string path, bool deleteFile) - { - this.SendFileAsync(context, path, string.Empty, deleteFile); - } + /// + /// Sends a file to up-stream components. + /// + /// The context in which the file is being sent. Cannot be null. + /// the path to the file on the local file system + /// True to automatically have the file removed after sending it. + public void SendFileAsync(DataCollectionContext context, string path, bool deleteFile) + { + SendFileAsync(context, path, string.Empty, deleteFile); + } - /// - /// Sends a file to up-stream components. - /// - /// The context in which the file is being sent. Cannot be null. - /// the path to the file on the local file system - /// A short description of the data being sent. - /// True to automatically have the file removed after sending it. - public void SendFileAsync(DataCollectionContext context, string path, string description, bool deleteFile) - { - var fileInfo = new FileTransferInformation(context, path, deleteFile); - fileInfo.Description = description; + /// + /// Sends a file to up-stream components. + /// + /// The context in which the file is being sent. Cannot be null. + /// the path to the file on the local file system + /// A short description of the data being sent. + /// True to automatically have the file removed after sending it. + public void SendFileAsync(DataCollectionContext context, string path, string description, bool deleteFile) + { + var fileInfo = new FileTransferInformation(context, path, deleteFile); + fileInfo.Description = description; - this.SendFileAsync(fileInfo); - } + SendFileAsync(fileInfo); + } - /// - /// Sends a file to up-stream components - /// - /// Information about the file to be transferred. - public abstract void SendFileAsync(FileTransferInformation fileTransferInformation); + /// + /// Sends a file to up-stream components + /// + /// Information about the file to be transferred. + public abstract void SendFileAsync(FileTransferInformation fileTransferInformation); - #endregion - } -} + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollector.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollector.cs index 52644065ab..29e6aa12e3 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollector.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollector.cs @@ -1,62 +1,59 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +using System; +using System.Xml; + +/// +/// Interface for data collector add-ins +/// +public abstract class DataCollector : IDisposable { - using System; - using System.Diagnostics.CodeAnalysis; - using System.Xml; + #region Methods + + /// + /// Initializes the data collector + /// + /// + /// The XML element containing configuration information for the data collector. Can be + /// null if the add-in does not have any configuration information. + /// + /// + /// Object containing the execution events the data collector can register for + /// + /// The sink used by the data collector to send its data + /// + /// Used by the data collector to send warnings, errors, or other messages + /// + /// Provides contextual information about the agent environment + public abstract void Initialize( + XmlElement configurationElement, + DataCollectionEvents events, + DataCollectionSink dataSink, + DataCollectionLogger logger, + DataCollectionEnvironmentContext environmentContext + ); + + /// + /// Disposes the data collector. + /// + public void Dispose() + { + Dispose(true); + + // Suppress Finalize in case a subclass implements a finalizer. + GC.SuppressFinalize(this); + } /// - /// Interface for data collector add-ins + /// Called to perform cleanup when the instance is being disposed. /// - public abstract class DataCollector : IDisposable + /// True when being called from the Dispose method and false when being called during finalization. + protected virtual void Dispose(bool disposing) { - #region Methods - - /// - /// Initializes the data collector - /// - /// - /// The XML element containing configuration information for the data collector. Can be - /// null if the add-in does not have any configuration information. - /// - /// - /// Object containing the execution events the data collector can register for - /// - /// The sink used by the data collector to send its data - /// - /// Used by the data collector to send warnings, errors, or other messages - /// - /// Provides contextual information about the agent environment - [SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes", MessageId = "System.Xml.XmlNode")] - public abstract void Initialize( - XmlElement configurationElement, - DataCollectionEvents events, - DataCollectionSink dataSink, - DataCollectionLogger logger, - DataCollectionEnvironmentContext environmentContext - ); - - /// - /// Disposes the data collector. - /// - public void Dispose() - { - Dispose(true); - - // Suppress Finalize in case a subclass implements a finalizer. - GC.SuppressFinalize(this); - } - - /// - /// Called to perform cleanup when the instance is being disposed. - /// - /// True when being called from the Dispose method and false when being called during finalization. - protected virtual void Dispose(bool disposing) - { - } - - #endregion } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectorSettings.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectorSettings.cs index b9f754bffd..985b1fb189 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectorSettings.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectorSettings.cs @@ -1,239 +1,231 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.Globalization; +using System.Xml; + +/// +/// The in procedure data collector settings. +/// +public class DataCollectorSettings { - using System; - using System.Diagnostics.CodeAnalysis; - using System.Globalization; - using System.Xml; + /// + /// Gets or sets the uri. + /// + public Uri Uri + { + get; + set; + } /// - /// The in procedure data collector settings. + /// Gets or sets the assembly qualified name. /// - public class DataCollectorSettings + public string AssemblyQualifiedName { - /// - /// Gets or sets the uri. - /// - public Uri Uri - { - get; - set; - } + get; + set; + } - /// - /// Gets or sets the assembly qualified name. - /// - public string AssemblyQualifiedName - { - get; - set; - } + /// + /// Gets or sets the friendly name. + /// + public string FriendlyName + { + get; + set; + } - /// - /// Gets or sets the friendly name. - /// - public string FriendlyName - { - get; - set; - } + /// + /// Gets or sets a value indicating whether is enabled. + /// + public bool IsEnabled + { + get; + set; + } - /// - /// Gets or sets a value indicating whether is enabled. - /// - public bool IsEnabled - { - get; - set; - } + /// + /// Gets or sets value CodeBase of collector DLL. The syntax is same as Code Base in AssemblyName class. + /// + public string CodeBase + { + get; + set; + } + + /// + /// Gets or sets the configuration. + /// + public XmlElement Configuration + { + get; + set; + } + + /// + /// The to xml. + /// + /// + /// The . + /// + public XmlElement ToXml() + { + XmlDocument doc = new(); + XmlElement root = doc.CreateElement(Constants.DataCollectorSettingName); + AppendAttribute(doc, root, "uri", Uri.ToString()); + AppendAttribute(doc, root, "assemblyQualifiedName", AssemblyQualifiedName); + AppendAttribute(doc, root, "friendlyName", FriendlyName); + + root.AppendChild(doc.ImportNode(Configuration, true)); - /// - /// Gets or sets value CodeBase of collector DLL. The syntax is same as Code Base in AssemblyName class. - /// - public string CodeBase + return root; + } + + /// + /// The to xml. + /// + /// + /// The data collector name. + /// + /// + /// The . + /// + public XmlElement ToXml(string dataCollectorName) + { + XmlDocument doc = new(); + XmlElement root = doc.CreateElement(dataCollectorName); + if (Uri != null) { - get; - set; + AppendAttribute(doc, root, "uri", Uri.ToString()); } - /// - /// Gets or sets the configuration. - /// - public XmlElement Configuration + if (!string.IsNullOrWhiteSpace(AssemblyQualifiedName)) { - get; - set; + AppendAttribute(doc, root, "assemblyQualifiedName", AssemblyQualifiedName); } - /// - /// The to xml. - /// - /// - /// The . - /// - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", - Justification = "XmlDocument.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] - public XmlElement ToXml() + if (!string.IsNullOrWhiteSpace(FriendlyName)) { - XmlDocument doc = new XmlDocument(); - XmlElement root = doc.CreateElement(Constants.DataCollectorSettingName); - AppendAttribute(doc, root, "uri", this.Uri.ToString()); - AppendAttribute(doc, root, "assemblyQualifiedName", this.AssemblyQualifiedName); - AppendAttribute(doc, root, "friendlyName", this.FriendlyName); + AppendAttribute(doc, root, "friendlyName", FriendlyName); + } - root.AppendChild(doc.ImportNode(this.Configuration, true)); + AppendAttribute(doc, root, "enabled", IsEnabled.ToString()); - return root; + if (!string.IsNullOrWhiteSpace(CodeBase)) + { + AppendAttribute(doc, root, "codebase", CodeBase); } - /// - /// The to xml. - /// - /// - /// The data collector name. - /// - /// - /// The . - /// - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", - Justification = "XmlDocument.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] - public XmlElement ToXml(string dataCollectorName) + if (Configuration != null) { - XmlDocument doc = new XmlDocument(); - XmlElement root = doc.CreateElement(dataCollectorName); - if (this.Uri != null) - { - AppendAttribute(doc, root, "uri", this.Uri.ToString()); - } - - if (!string.IsNullOrWhiteSpace(this.AssemblyQualifiedName)) - { - AppendAttribute(doc, root, "assemblyQualifiedName", this.AssemblyQualifiedName); - } - - if (!string.IsNullOrWhiteSpace(this.FriendlyName)) - { - AppendAttribute(doc, root, "friendlyName", this.FriendlyName); - } - - AppendAttribute(doc, root, "enabled", this.IsEnabled.ToString()); - - if (!string.IsNullOrWhiteSpace(this.CodeBase)) - { - AppendAttribute(doc, root, "codebase", this.CodeBase); - } - - if (this.Configuration != null) - { - root.AppendChild(doc.ImportNode(this.Configuration, true)); - } - - return root; + root.AppendChild(doc.ImportNode(Configuration, true)); } - /// - /// The from xml. - /// - /// - /// The reader. - /// - /// - /// The . - /// - /// - /// Settings exception - /// - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", - Justification = "XmlDocument.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] - internal static DataCollectorSettings FromXml(XmlReader reader) + return root; + } + + /// + /// The from xml. + /// + /// + /// The reader. + /// + /// + /// The . + /// + /// + /// Settings exception + /// + internal static DataCollectorSettings FromXml(XmlReader reader) + { + DataCollectorSettings settings = new(); + settings.IsEnabled = true; + bool empty = reader.IsEmptyElement; + if (reader.HasAttributes) { - DataCollectorSettings settings = new DataCollectorSettings(); - settings.IsEnabled = true; - bool empty = reader.IsEmptyElement; - if (reader.HasAttributes) + while (reader.MoveToNextAttribute()) { - while (reader.MoveToNextAttribute()) + switch (reader.Name) { - switch (reader.Name) - { - case "uri": - ValidateArg.NotNullOrEmpty(reader.Value, "uri"); - try - { - settings.Uri = new Uri(reader.Value); - } - catch (UriFormatException) - { - throw new SettingsException(String.Format(CultureInfo.CurrentCulture, Resources.Resources.InvalidDataCollectorUriInSettings, reader.Value)); - } - - break; - - case "assemblyQualifiedName": - ValidateArg.NotNullOrEmpty(reader.Value, "assemblyQualifiedName"); - settings.AssemblyQualifiedName = reader.Value; - break; - - case "friendlyName": - ValidateArg.NotNullOrEmpty(reader.Value, "FriendlyName"); - settings.FriendlyName = reader.Value; - break; - - case "enabled": - settings.IsEnabled = bool.Parse(reader.Value); - break; - - case "codebase": - settings.CodeBase = reader.Value; // Optional. - break; - - default: - throw new SettingsException( - String.Format( - CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsXmlAttribute, - Constants.DataCollectionRunSettingsName, - reader.Name)); - } + case "uri": + ValidateArg.NotNullOrEmpty(reader.Value, "uri"); + try + { + settings.Uri = new Uri(reader.Value); + } + catch (UriFormatException) + { + throw new SettingsException(String.Format(CultureInfo.CurrentCulture, Resources.Resources.InvalidDataCollectorUriInSettings, reader.Value)); + } + + break; + + case "assemblyQualifiedName": + ValidateArg.NotNullOrEmpty(reader.Value, "assemblyQualifiedName"); + settings.AssemblyQualifiedName = reader.Value; + break; + + case "friendlyName": + ValidateArg.NotNullOrEmpty(reader.Value, "FriendlyName"); + settings.FriendlyName = reader.Value; + break; + + case "enabled": + settings.IsEnabled = bool.Parse(reader.Value); + break; + + case "codebase": + settings.CodeBase = reader.Value; // Optional. + break; + + default: + throw new SettingsException( + String.Format( + CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsXmlAttribute, + Constants.DataCollectionRunSettingsName, + reader.Name)); } - } - reader.Read(); - if (!empty) + } + + reader.Read(); + if (!empty) + { + while (reader.NodeType == XmlNodeType.Element) { - while (reader.NodeType == XmlNodeType.Element) + switch (reader.Name) { - switch (reader.Name) - { - case "Configuration": - XmlDocument doc = new XmlDocument(); - XmlElement element = doc.CreateElement("Configuration"); - element.InnerXml = reader.ReadInnerXml(); - settings.Configuration = element; - break; - - default: - throw new SettingsException( - String.Format( - CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsXmlElement, - Constants.DataCollectionRunSettingsName, - reader.Name)); - } + case "Configuration": + XmlDocument doc = new(); + XmlElement element = doc.CreateElement("Configuration"); + element.InnerXml = reader.ReadInnerXml(); + settings.Configuration = element; + break; + + default: + throw new SettingsException( + String.Format( + CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsXmlElement, + Constants.DataCollectionRunSettingsName, + reader.Name)); } - reader.ReadEndElement(); } - return settings; + reader.ReadEndElement(); } + return settings; + } - private static void AppendAttribute(XmlDocument doc, XmlElement owner, string attributeName, string attributeValue) - { - XmlAttribute attribute = doc.CreateAttribute(attributeName); - attribute.Value = attributeValue; - owner.Attributes.Append(attribute); - } + private static void AppendAttribute(XmlDocument doc, XmlElement owner, string attributeName, string attributeValue) + { + XmlAttribute attribute = doc.CreateAttribute(attributeName); + attribute.Value = attributeValue; + owner.Attributes.Append(attribute); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/DataCollectionEventArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/DataCollectionEventArgs.cs index 37596ceffc..8cbb896431 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/DataCollectionEventArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/DataCollectionEventArgs.cs @@ -1,70 +1,69 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +using System; +using System.Diagnostics; + +/// +/// Base class for all execution event arguments +/// +#if NETFRAMEWORK +[Serializable] +#endif +public abstract class DataCollectionEventArgs : EventArgs { - using System; - using System.Diagnostics; + #region Constructor /// - /// Base class for all execution event arguments + /// Default constructor added for serialization/deserialization. /// -#if NETFRAMEWORK - [Serializable] -#endif - public abstract class DataCollectionEventArgs : EventArgs + public DataCollectionEventArgs() { - #region Constructor - - /// - /// Default constructor added for serialization/deserialization. - /// - public DataCollectionEventArgs() - { - } - - /// - /// Initializes the instance by storing the given information - /// - /// Context information for the event - protected DataCollectionEventArgs(DataCollectionContext context) - { - Context = context; - } + } - #endregion + /// + /// Initializes the instance by storing the given information + /// + /// Context information for the event + protected DataCollectionEventArgs(DataCollectionContext context) + { + Context = context; + } - #region Public properties + #endregion - /// - /// Gets the context information for the event - /// - public DataCollectionContext Context - { - get; - internal set; - } + #region Public properties - #endregion + /// + /// Gets the context information for the event + /// + public DataCollectionContext Context + { + get; + internal set; + } - #region Private Methods + #endregion - /// - /// Updates the data collection context stored by this instance. - /// - /// Context to update with. - /// - /// Generally the data collection context is known in advance, however there - /// are cases around custom notifications where it is not necessarily known - /// until the event is being sent. This is used for updating the context when - /// sending the event. - /// - internal void UpdateDataCollectionContext(DataCollectionContext context) - { - Debug.Assert(context != null, "'context' cannot be null."); - Context = context; - } + #region Private Methods - #endregion + /// + /// Updates the data collection context stored by this instance. + /// + /// Context to update with. + /// + /// Generally the data collection context is known in advance, however there + /// are cases around custom notifications where it is not necessarily known + /// until the event is being sent. This is used for updating the context when + /// sending the event. + /// + internal void UpdateDataCollectionContext(DataCollectionContext context) + { + Debug.Assert(context != null, "'context' cannot be null."); + Context = context; } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/DataCollectionEvents.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/DataCollectionEvents.cs index f7dadc2a29..e9894984e8 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/DataCollectionEvents.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/DataCollectionEvents.cs @@ -1,53 +1,52 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +using System; + +/// +/// Class defining execution events that will be registered for by collectors +/// +public abstract class DataCollectionEvents { - using System; + #region Constructor /// - /// Class defining execution events that will be registered for by collectors + /// Initializes a new instance of the class. /// - public abstract class DataCollectionEvents + protected DataCollectionEvents() { - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - protected DataCollectionEvents() - { - } + } - #endregion + #endregion - #region Events + #region Events - /// - /// Raised when test host initialized - /// - public abstract event EventHandler TestHostLaunched; + /// + /// Raised when test host initialized + /// + public abstract event EventHandler TestHostLaunched; - /// - /// Raised when a session is starting - /// - public abstract event EventHandler SessionStart; + /// + /// Raised when a session is starting + /// + public abstract event EventHandler SessionStart; - /// - /// Raised when a session is ending - /// - public abstract event EventHandler SessionEnd; + /// + /// Raised when a session is ending + /// + public abstract event EventHandler SessionEnd; - /// - /// Raised when a test case is starting - /// - public abstract event EventHandler TestCaseStart; + /// + /// Raised when a test case is starting + /// + public abstract event EventHandler TestCaseStart; - /// - /// Raised when a test case is ending - /// - public abstract event EventHandler TestCaseEnd; + /// + /// Raised when a test case is ending + /// + public abstract event EventHandler TestCaseEnd; - #endregion - } -} + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/SessionEvents.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/SessionEvents.cs index 99a9cace15..450e6010bf 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/SessionEvents.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/SessionEvents.cs @@ -1,135 +1,134 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.Serialization; + +/// +/// Session Start event arguments +/// +[DataContract] +public sealed class SessionStartEventArgs : DataCollectionEventArgs { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Runtime.Serialization; + private readonly IDictionary _properties; + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// + /// Default constructor with empty properties and default DataCollectionContext. + /// DataCollectionContext with empty session signifies that is it irrelevant in the current context. + /// + public SessionStartEventArgs() : this(new DataCollectionContext(new SessionId(Guid.Empty)), new Dictionary()) + { + + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// constructor with properties and default DataCollectionContext. + /// DataCollectionContext with empty session signifies that is it irrelevant in the current context. + /// + public SessionStartEventArgs(IDictionary properties) : this(new DataCollectionContext(new SessionId(Guid.Empty)), properties) + { + + } /// - /// Session Start event arguments + /// Initializes a new instance of the class. /// - [DataContract] - public sealed class SessionStartEventArgs : DataCollectionEventArgs + /// + /// Context information for the session + /// + public SessionStartEventArgs(DataCollectionContext context, IDictionary properties) + : base(context) { - private IDictionary Properties; - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - /// - /// Default constructor with empty properties and default DataCollectionContext. - /// DataCollectionContext with empty session signifies that is it irrelevant in the current context. - /// - public SessionStartEventArgs() : this(new DataCollectionContext(new SessionId(Guid.Empty)), new Dictionary()) - { - - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// constructor with properties and default DataCollectionContext. - /// DataCollectionContext with empty session signifies that is it irrelevant in the current context. - /// - public SessionStartEventArgs(IDictionary properties) : this(new DataCollectionContext(new SessionId(Guid.Empty)), properties) - { - - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Context information for the session - /// - public SessionStartEventArgs(DataCollectionContext context, IDictionary properties) - : base(context) - { - this.Properties = properties; - Debug.Assert(!context.HasTestCase, "Session event has test a case context"); - } - - #endregion - - #region Public Methods - - /// - /// Gets session start properties enumerator - /// - public IEnumerator> GetProperties() - { - return this.Properties.GetEnumerator(); - } - - /// - /// Gets property value - /// - /// - /// Property name - /// - public T GetPropertyValue(string property) - { - ValidateArg.NotNullOrEmpty(property, nameof(property)); - - return this.Properties.ContainsKey(property) ? (T)this.Properties[property] : default(T); - } - - /// - /// Gets property value - /// - /// - /// Property name - /// - public object GetPropertyValue(string property) - { - ValidateArg.NotNullOrEmpty(property, nameof(property)); - - this.Properties.TryGetValue(property, out var propertyValue); - - return propertyValue; - } - - #endregion + _properties = properties; + Debug.Assert(!context.HasTestCase, "Session event has test a case context"); } + #endregion + + #region Public Methods + /// - /// Session End event arguments + /// Gets session start properties enumerator /// - [DataContract] - public sealed class SessionEndEventArgs : DataCollectionEventArgs + public IEnumerator> GetProperties() { - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - /// - /// Default constructor with default DataCollectionContext. - /// DataCollectionContext with empty session signifies that is it irrelevant in the current context. - /// - public SessionEndEventArgs() : this(new DataCollectionContext(new SessionId(Guid.Empty))) - { - - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Context information for the session - /// - public SessionEndEventArgs(DataCollectionContext context) - : base(context) - { - Debug.Assert(!context.HasTestCase, "Session event has test a case context"); - } - - #endregion + return _properties.GetEnumerator(); } + + /// + /// Gets property value + /// + /// + /// Property name + /// + public T GetPropertyValue(string property) + { + ValidateArg.NotNullOrEmpty(property, nameof(property)); + + return _properties.ContainsKey(property) ? (T)_properties[property] : default; + } + + /// + /// Gets property value + /// + /// + /// Property name + /// + public object GetPropertyValue(string property) + { + ValidateArg.NotNullOrEmpty(property, nameof(property)); + + _properties.TryGetValue(property, out var propertyValue); + + return propertyValue; + } + + #endregion } + +/// +/// Session End event arguments +/// +[DataContract] +public sealed class SessionEndEventArgs : DataCollectionEventArgs +{ + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// + /// Default constructor with default DataCollectionContext. + /// DataCollectionContext with empty session signifies that is it irrelevant in the current context. + /// + public SessionEndEventArgs() : this(new DataCollectionContext(new SessionId(Guid.Empty))) + { + + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Context information for the session + /// + public SessionEndEventArgs(DataCollectionContext context) + : base(context) + { + Debug.Assert(!context.HasTestCase, "Session event has test a case context"); + } + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/TestCaseEvents.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/TestCaseEvents.cs index c48cc90489..ab4e721f17 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/TestCaseEvents.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/TestCaseEvents.cs @@ -1,437 +1,436 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +using System; +using System.Diagnostics; +using System.Runtime.Serialization; + +/// +/// Base class for all test case event arguments. +/// +[DataContract] +public abstract class TestCaseEventArgs : DataCollectionEventArgs +{ + #region Constructor + + /// + /// Default constructor added for serialization/deserialization. + /// + public TestCaseEventArgs() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Context information for the test case + /// + /// + /// The test case ID + /// + /// + /// The test case name + /// + /// + /// True if this is a child test case, false if this is a top-level test case. + /// + protected TestCaseEventArgs( + DataCollectionContext context, + Guid testCaseId, + string testCaseName, + bool isChildTestCase) + : base(context) + { + TestCaseId = testCaseId; + TestCaseName = testCaseName ?? string.Empty; + IsChildTestCase = isChildTestCase; + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Context information for the test case + /// + /// + /// The test element of the test that this event is for. + /// + protected TestCaseEventArgs( + DataCollectionContext context, + TestCase testElement) + : this(context, Guid.Empty, null, false) + { + // NOTE: ONLY USE FOR UNIT TESTING! + // This overload is only here for 3rd parties to use for unit testing + // their data collectors. Internally we should not be passing the test element + // around in the events as this is extra information that needs to be serialized + // and the Execution Plugin Manager will fill this in for us before the event + // is sent to the data collector when running in a production environment. + + // TODO + // EqtAssert.ParameterNotNull(testElement, "testElement"); + + TestElement = testElement; + TestCaseId = testElement.Id; + TestCaseName = testElement.DisplayName; + // IsChildTestCase = testElement != null && + // !testElement.ParentExecId.Equals(TestExecId.Empty); + } + + #endregion + + #region Public properties + + /// + /// Gets the test case ID + /// + [DataMember] + public Guid TestCaseId + { + get; + private set; + } + + /// + /// Gets the test case name + /// + [DataMember] + public string TestCaseName + { + get; + private set; + } + + /// + /// Gets a value indicating whether this is a child test case, false if this is a top-level test case + /// + [DataMember] + public bool IsChildTestCase + { + get; + private set; + } + + /// + /// Gets test element of the test this event is for. + /// + [DataMember] + public TestCase TestElement + { + get; + internal set; + } + + #endregion +} + +/// +/// Test Case Start event arguments. +/// +[DataContract] +public sealed class TestCaseStartEventArgs : TestCaseEventArgs +{ + #region Constructor + + /// + /// Default constructor for serialization/deserialization + /// + public TestCaseStartEventArgs() + { + } + + /// + /// Initializes a new instance of the class with default datacollection context. + /// + /// + /// The test element. + /// + public TestCaseStartEventArgs(TestCase testElement) : this(new DataCollectionContext(new SessionId(Guid.Empty)), testElement) + { + } + + /// + /// Initializes a new instance of the class. + /// Initializes the instance by storing the given information. + /// + /// + /// Context information for the test case + /// + /// + /// The test element of the test that this event is for. + /// + public TestCaseStartEventArgs( + DataCollectionContext context, + TestCase testElement) + : base(context, testElement) + { + // NOTE: ONLY USE FOR UNIT TESTING! + // This overload is only here for 3rd parties to use for unit testing + // their data collectors. Internally we should not be passing the test element + // around in the events as this is extra information that needs to be serialized + // and the Execution Plugin Manager will fill this in for us before the event + // is sent to the data collector when running in a production environment. + } + + /// + /// Initializes a new instance of the class. + /// Initializes the instance by storing the given information + /// + /// + /// Context information for the test case + /// + /// + /// The test case ID + /// + /// + /// The test case name + /// + /// + /// True if this is a child test case, false if this is a top-level test case + /// + internal TestCaseStartEventArgs( + DataCollectionContext context, + Guid testCaseId, + string testCaseName, + bool isChildTestCase) + : base(context, testCaseId, testCaseName, isChildTestCase) + { + Debug.Assert(context.HasTestCase, "Context is not for a test case"); + } + + #endregion +} + +/// +/// Test Case End event arguments. +/// +[DataContract] +public sealed class TestCaseEndEventArgs : TestCaseEventArgs +{ + #region Constructor + /// + /// Default constructor added for serialization/deserialization. + /// + public TestCaseEndEventArgs() + { + } + + /// + /// Initializes a new instance of the class with default data collection context. + /// + /// + /// The test element. + /// + /// + /// The test outcome. + /// + /// + /// Default constructor with default DataCollectionContext. + /// DataCollectionContext with empty session signifies that is it irrelevant in the current context. + /// + public TestCaseEndEventArgs(TestCase testElement, TestOutcome testOutcome) : this(new DataCollectionContext(new SessionId(Guid.Empty)), testElement, testOutcome) + { + } + + /// + /// Initializes a new instance of the class. + /// Initializes the instance by storing the given information. + /// + /// + /// Context information for the test case + /// + /// + /// The test element of the test that this event is for. + /// + /// + /// The outcome of the test case. + /// + public TestCaseEndEventArgs( + DataCollectionContext context, + TestCase testElement, + TestOutcome testOutcome) + : base(context, testElement) + { + // NOTE: ONLY USE FOR UNIT TESTING! + // This overload is only here for 3rd parties to use for unit testing + // their data collectors. Internally we should not be passing the test element + // around in the events as this is extra information that needs to be serialized + // and the Execution Plugin Manager will fill this in for us before the event + // is sent to the data collector when running in a production environment. + TestOutcome = testOutcome; + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Context information for the test case + /// + /// + /// The test case ID + /// + /// + /// The test case name + /// + /// + /// True if this is a child test case, false if this is a top-level test case + /// + internal TestCaseEndEventArgs( + DataCollectionContext context, + Guid testCaseId, + string testCaseName, + bool isChildTestCase) + : this(context, testCaseId, testCaseName, isChildTestCase, TestOutcome.Failed) + { + } + + /// + /// Initializes a new instance of the class. + /// Initializes the instance by storing the given information + /// + /// + /// Context information for the test case + /// + /// + /// The test case ID + /// + /// + /// The test case name + /// + /// + /// True if this is a child test case, false if this is a top-level test case + /// + /// + /// The outcome of the test case. + /// + internal TestCaseEndEventArgs( + DataCollectionContext context, + Guid testCaseId, + string testCaseName, + bool isChildTestCase, + TestOutcome testOutcome) + : base(context, testCaseId, testCaseName, isChildTestCase) + { + Debug.Assert(context.HasTestCase, "Context is not for a test case"); + TestOutcome = testOutcome; + } + + #endregion + + #region Properties + + /// + /// Gets the outcome of the test. + /// + [DataMember] + public TestOutcome TestOutcome + { + get; + private set; + } + #endregion +} + +/// +/// Test Case Result event arguments. +/// +[DataContract] +public sealed class TestResultEventArgs : TestCaseEventArgs { - using System; - using System.Diagnostics; - using System.Runtime.Serialization; + #region Constructor /// - /// Base class for all test case event arguments. + /// Default constructor for serialization/deserialization /// - [DataContract] - public abstract class TestCaseEventArgs : DataCollectionEventArgs + public TestResultEventArgs() { - #region Constructor - - /// - /// Default constructor added for serialization/deserialization. - /// - public TestCaseEventArgs() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Context information for the test case - /// - /// - /// The test case ID - /// - /// - /// The test case name - /// - /// - /// True if this is a child test case, false if this is a top-level test case. - /// - protected TestCaseEventArgs( - DataCollectionContext context, - Guid testCaseId, - string testCaseName, - bool isChildTestCase) - : base(context) - { - this.TestCaseId = testCaseId; - this.TestCaseName = testCaseName ?? string.Empty; - this.IsChildTestCase = isChildTestCase; - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Context information for the test case - /// - /// - /// The test element of the test that this event is for. - /// - protected TestCaseEventArgs( - DataCollectionContext context, - TestCase testElement) - : this(context, Guid.Empty, null, false) - { - // NOTE: ONLY USE FOR UNIT TESTING! - // This overload is only here for 3rd parties to use for unit testing - // their data collectors. Internally we should not be passing the test element - // around in the events as this is extra information that needs to be serialized - // and the Execution Plugin Manager will fill this in for us before the event - // is sent to the data collector when running in a production environment. - - // TODO - // EqtAssert.ParameterNotNull(testElement, "testElement"); - - this.TestElement = testElement; - this.TestCaseId = testElement.Id; - this.TestCaseName = testElement.DisplayName; - // IsChildTestCase = testElement != null && - // !testElement.ParentExecId.Equals(TestExecId.Empty); - } - - #endregion - - #region Public properties - - /// - /// Gets the test case ID - /// - [DataMember] - public Guid TestCaseId - { - get; - private set; - } - - /// - /// Gets the test case name - /// - [DataMember] - public string TestCaseName - { - get; - private set; - } - - /// - /// Gets a value indicating whether this is a child test case, false if this is a top-level test case - /// - [DataMember] - public bool IsChildTestCase - { - get; - private set; - } - - /// - /// Gets test element of the test this event is for. - /// - [DataMember] - public TestCase TestElement - { - get; - internal set; - } - - #endregion } /// - /// Test Case Start event arguments. + /// Initializes a new instance of the class with default data collection context. /// - [DataContract] - public sealed class TestCaseStartEventArgs : TestCaseEventArgs + /// + /// The test result. + /// + /// + /// Default constructor with default DataCollectionContext. + /// DataCollectionContext with empty session signifies that is it irrelevant in the current context. + /// + public TestResultEventArgs(TestResult testResult) + : this(new DataCollectionContext(new SessionId(Guid.Empty)), testResult) { - #region Constructor - - /// - /// Default constructor for serialization/deserialization - /// - public TestCaseStartEventArgs() - { - } - - /// - /// Initializes a new instance of the class with default datacollection context. - /// - /// - /// The test element. - /// - public TestCaseStartEventArgs(TestCase testElement) : this(new DataCollectionContext(new SessionId(Guid.Empty)), testElement) - { - } - - /// - /// Initializes a new instance of the class. - /// Initializes the instance by storing the given information. - /// - /// - /// Context information for the test case - /// - /// - /// The test element of the test that this event is for. - /// - public TestCaseStartEventArgs( - DataCollectionContext context, - TestCase testElement) - : base(context, testElement) - { - // NOTE: ONLY USE FOR UNIT TESTING! - // This overload is only here for 3rd parties to use for unit testing - // their data collectors. Internally we should not be passing the test element - // around in the events as this is extra information that needs to be serialized - // and the Execution Plugin Manager will fill this in for us before the event - // is sent to the data collector when running in a production environment. - } - - /// - /// Initializes a new instance of the class. - /// Initializes the instance by storing the given information - /// - /// - /// Context information for the test case - /// - /// - /// The test case ID - /// - /// - /// The test case name - /// - /// - /// True if this is a child test case, false if this is a top-level test case - /// - internal TestCaseStartEventArgs( - DataCollectionContext context, - Guid testCaseId, - string testCaseName, - bool isChildTestCase) - : base(context, testCaseId, testCaseName, isChildTestCase) - { - Debug.Assert(context.HasTestCase, "Context is not for a test case"); - } - - #endregion } /// - /// Test Case End event arguments. + /// Initializes a new instance of the class. + /// Initializes the instance by storing the given information. /// - [DataContract] - public sealed class TestCaseEndEventArgs : TestCaseEventArgs + /// + /// Context information for the test case + /// + /// + /// The test Result. + /// + public TestResultEventArgs( + DataCollectionContext context, + TestResult testResult) + : base(context, testResult.TestCase) { - #region Constructor - /// - /// Default constructor added for serialization/deserialization. - /// - public TestCaseEndEventArgs() - { - } - - /// - /// Initializes a new instance of the class with default data collection context. - /// - /// - /// The test element. - /// - /// - /// The test outcome. - /// - /// - /// Default constructor with default DataCollectionContext. - /// DataCollectionContext with empty session signifies that is it irrelevant in the current context. - /// - public TestCaseEndEventArgs(TestCase testElement, TestOutcome testOutcome) : this(new DataCollectionContext(new SessionId(Guid.Empty)), testElement, testOutcome) - { - } - - /// - /// Initializes a new instance of the class. - /// Initializes the instance by storing the given information. - /// - /// - /// Context information for the test case - /// - /// - /// The test element of the test that this event is for. - /// - /// - /// The outcome of the test case. - /// - public TestCaseEndEventArgs( - DataCollectionContext context, - TestCase testElement, - TestOutcome testOutcome) - : base(context, testElement) - { - // NOTE: ONLY USE FOR UNIT TESTING! - // This overload is only here for 3rd parties to use for unit testing - // their data collectors. Internally we should not be passing the test element - // around in the events as this is extra information that needs to be serialized - // and the Execution Plugin Manager will fill this in for us before the event - // is sent to the data collector when running in a production environment. - this.TestOutcome = testOutcome; - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Context information for the test case - /// - /// - /// The test case ID - /// - /// - /// The test case name - /// - /// - /// True if this is a child test case, false if this is a top-level test case - /// - internal TestCaseEndEventArgs( - DataCollectionContext context, - Guid testCaseId, - string testCaseName, - bool isChildTestCase) - : this(context, testCaseId, testCaseName, isChildTestCase, TestOutcome.Failed) - { - } - - /// - /// Initializes a new instance of the class. - /// Initializes the instance by storing the given information - /// - /// - /// Context information for the test case - /// - /// - /// The test case ID - /// - /// - /// The test case name - /// - /// - /// True if this is a child test case, false if this is a top-level test case - /// - /// - /// The outcome of the test case. - /// - internal TestCaseEndEventArgs( - DataCollectionContext context, - Guid testCaseId, - string testCaseName, - bool isChildTestCase, - TestOutcome testOutcome) - : base(context, testCaseId, testCaseName, isChildTestCase) - { - Debug.Assert(context.HasTestCase, "Context is not for a test case"); - this.TestOutcome = testOutcome; - } - - #endregion - - #region Properties - - /// - /// Gets the outcome of the test. - /// - [DataMember] - public TestOutcome TestOutcome - { - get; - private set; - } - #endregion + // NOTE: ONLY USE FOR UNIT TESTING! + // This overload is only here for 3rd parties to use for unit testing + // their data collectors. Internally we should not be passing the test element + // around in the events as this is extra information that needs to be serialized + // and the Execution Plugin Manager will fill this in for us before the event + // is sent to the data collector when running in a production environment. + TestResult = testResult; } /// - /// Test Case Result event arguments. + /// Initializes a new instance of the class. + /// Initializes the instance by storing the given information + /// + /// + /// Context information for the test case + /// + /// + /// The test case ID + /// + /// + /// The test case name + /// + /// + /// True if this is a child test case, false if this is a top-level test case + /// + /// + /// The test Result. + /// + internal TestResultEventArgs( + DataCollectionContext context, + Guid testCaseId, + string testCaseName, + bool isChildTestCase, + TestResult testResult) + : base(context, testCaseId, testCaseName, isChildTestCase) + { + Debug.Assert(context.HasTestCase, "Context is not for a test case"); + TestResult = testResult; + } + + #endregion + + #region Properties + + /// + /// Gets the outcome of the test. /// - [DataContract] - public sealed class TestResultEventArgs : TestCaseEventArgs + [DataMember] + public TestResult TestResult { - #region Constructor - - /// - /// Default constructor for serialization/deserialization - /// - public TestResultEventArgs() - { - } - - /// - /// Initializes a new instance of the class with default data collection context. - /// - /// - /// The test result. - /// - /// - /// Default constructor with default DataCollectionContext. - /// DataCollectionContext with empty session signifies that is it irrelevant in the current context. - /// - public TestResultEventArgs(TestResult testResult) - : this(new DataCollectionContext(new SessionId(Guid.Empty)), testResult) - { - } - - /// - /// Initializes a new instance of the class. - /// Initializes the instance by storing the given information. - /// - /// - /// Context information for the test case - /// - /// - /// The test Result. - /// - public TestResultEventArgs( - DataCollectionContext context, - TestResult testResult) - : base(context, testResult.TestCase) - { - // NOTE: ONLY USE FOR UNIT TESTING! - // This overload is only here for 3rd parties to use for unit testing - // their data collectors. Internally we should not be passing the test element - // around in the events as this is extra information that needs to be serialized - // and the Execution Plugin Manager will fill this in for us before the event - // is sent to the data collector when running in a production environment. - this.TestResult = testResult; - } - - /// - /// Initializes a new instance of the class. - /// Initializes the instance by storing the given information - /// - /// - /// Context information for the test case - /// - /// - /// The test case ID - /// - /// - /// The test case name - /// - /// - /// True if this is a child test case, false if this is a top-level test case - /// - /// - /// The test Result. - /// - internal TestResultEventArgs( - DataCollectionContext context, - Guid testCaseId, - string testCaseName, - bool isChildTestCase, - TestResult testResult) - : base(context, testCaseId, testCaseName, isChildTestCase) - { - Debug.Assert(context.HasTestCase, "Context is not for a test case"); - this.TestResult = testResult; - } - - #endregion - - #region Properties - - /// - /// Gets the outcome of the test. - /// - [DataMember] - public TestResult TestResult - { - get; - private set; - } - #endregion + get; + private set; } + #endregion } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/TestHostLaunchedEvent.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/TestHostLaunchedEvent.cs index 10aa6d93b8..1d784764b7 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/TestHostLaunchedEvent.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/TestHostLaunchedEvent.cs @@ -1,54 +1,45 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +using System.Runtime.Serialization; + +/// +/// Session End event arguments +/// +[DataContract] +public sealed class TestHostLaunchedEventArgs : DataCollectionEventArgs { - using System.Runtime.Serialization; + #region Private members + + /// + /// Process id of the test host + /// + #endregion + + #region Public properties + + public int TestHostProcessId { get; private set; } + + #endregion + + #region Constructor /// - /// Session End event arguments + /// Initializes a new instance of the class. /// - [DataContract] - public sealed class TestHostLaunchedEventArgs : DataCollectionEventArgs + /// + /// Data collection context + /// + /// + /// Process id of test host + /// + public TestHostLaunchedEventArgs(DataCollectionContext context, int processId) + : base(context) { - #region Private members - - /// - /// Process id of the test host - /// - private int processId; - - #endregion - - #region Public properties - - public int TestHostProcessId - { - get - { - return processId; - } - } - - #endregion - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - /// - /// Data collection context - /// - /// - /// Process id of test host - /// - public TestHostLaunchedEventArgs(DataCollectionContext context, int processId) - : base(context) - { - this.processId = processId; - } - - #endregion + TestHostProcessId = processId; } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectionSink.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectionSink.cs index ef97e673e4..ee9526634d 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectionSink.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectionSink.cs @@ -1,28 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +/// +/// Class used by data collectors to send data to up-stream components +/// (agent, controller, client, etc). +/// +public interface IDataCollectionSink { /// - /// Class used by data collectors to send data to up-stream components - /// (agent, controller, client, etc). + /// The send data will send the data collection data to upstream applications. + /// Key will be set as TestProperty in TestResult and value as corresponding value. /// - public interface IDataCollectionSink - { - /// - /// The send data will send the data collection data to upstream applications. - /// Key will be set as TestProperty in TestResult and value as corresponding value. - /// - /// - /// The data collection context. - /// - /// - /// The key should be unique for a data collector. - /// - /// - /// The value should be a string or an object serialized into a JSON string. - /// - void SendData(DataCollectionContext dataCollectionContext, string key, string value); + /// + /// The data collection context. + /// + /// + /// The key should be unique for a data collector. + /// + /// + /// The value should be a string or an object serialized into a JSON string. + /// + void SendData(DataCollectionContext dataCollectionContext, string key, string value); - } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectorAttachmentProcessor.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectorAttachmentProcessor.cs index 37565e3d89..a280c415a5 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectorAttachmentProcessor.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectorAttachmentProcessor.cs @@ -1,51 +1,51 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection -{ - using System; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - using System.Xml; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using System.Xml; +using Logging; + +/// +/// Interface for data collectors add-ins that choose to reprocess generated attachments +/// +public interface IDataCollectorAttachmentProcessor +{ /// - /// Interface for data collectors add-ins that choose to reprocess generated attachments + /// Gets the attachments Uris, which are handled by attachment processor /// - public interface IDataCollectorAttachmentProcessor - { - /// - /// Gets the attachments Uris, which are handled by attachment processor - /// - IEnumerable GetExtensionUris(); + IEnumerable GetExtensionUris(); - /// - /// Indicates whether attachment processor is supporting incremental processing of attachments - /// - /// - /// `SupportsIncrementalProcessing` should indicate if attachment processor is supporting incremental processing of attachments. It means that `ProcessAttachmentSetsAsync` should be [associative](https://en.wikipedia.org/wiki/Associative_property). - /// By default `SupportsIncrementalProcessing` should be `False`, unless processing can take longer time and it's beneficial to start the process as soon as possible. - /// - /// If `SupportsIncrementalProcessing` is `True` Test Platform may try to speed up whole process by reprocessing data collector attachments as soon as possible when any two test executions are done.For example let's assume we have 5 test executions which are generating 5 data collector attachments: `a1`, `a2`, `a3`, `a4` and `a5`. Test platform could perform invocations: - /// * `var result1 = await ProcessAttachmentSetsAsync([a1, a2, a3], ...);` when first 3 executions are done - /// * `var result2 = await ProcessAttachmentSetsAsync(result1.Concat([a4]), ...);` when 4th execution is done - /// * `var finalResult = await ProcessAttachmentSetsAsync(result2.Concat([a5]), ...);` when last test execution is done - /// - /// If `SupportsIncrementalProcessing` is `False` then Test Platform will wait for all test executions to finish and call `ProcessAttachmentSetsAsync` only once: - /// * `var finalResult = await ProcessAttachmentSetsAsync([a1, a2, a3, a4, a5], ...);` - /// - bool SupportsIncrementalProcessing { get; } + /// + /// Indicates whether attachment processor is supporting incremental processing of attachments + /// + /// + /// `SupportsIncrementalProcessing` should indicate if attachment processor is supporting incremental processing of attachments. It means that `ProcessAttachmentSetsAsync` should be [associative](https://en.wikipedia.org/wiki/Associative_property). + /// By default `SupportsIncrementalProcessing` should be `False`, unless processing can take longer time and it's beneficial to start the process as soon as possible. + /// + /// If `SupportsIncrementalProcessing` is `True` Test Platform may try to speed up whole process by reprocessing data collector attachments as soon as possible when any two test executions are done.For example let's assume we have 5 test executions which are generating 5 data collector attachments: `a1`, `a2`, `a3`, `a4` and `a5`. Test platform could perform invocations: + /// * `var result1 = await ProcessAttachmentSetsAsync([a1, a2, a3], ...);` when first 3 executions are done + /// * `var result2 = await ProcessAttachmentSetsAsync(result1.Concat([a4]), ...);` when 4th execution is done + /// * `var finalResult = await ProcessAttachmentSetsAsync(result2.Concat([a5]), ...);` when last test execution is done + /// + /// If `SupportsIncrementalProcessing` is `False` then Test Platform will wait for all test executions to finish and call `ProcessAttachmentSetsAsync` only once: + /// * `var finalResult = await ProcessAttachmentSetsAsync([a1, a2, a3, a4, a5], ...);` + /// + bool SupportsIncrementalProcessing { get; } - /// - /// Reprocess attachments generated by independent test executions - /// - /// Configuration of the attachment processor. Will be the same as the data collector that registers it. - /// Attachments to be processed - /// Progress reporter. Accepts integers from 0 to 100 - /// Message logger - /// Cancellation token - /// Attachments after reprocessing - Task> ProcessAttachmentSetsAsync(XmlElement configurationElement, ICollection attachments, IProgress progressReporter, IMessageLogger logger, CancellationToken cancellationToken); - } -} + /// + /// Reprocess attachments generated by independent test executions + /// + /// Configuration of the attachment processor. Will be the same as the data collector that registers it. + /// Attachments to be processed + /// Progress reporter. Accepts integers from 0 to 100 + /// Message logger + /// Cancellation token + /// Attachments after reprocessing + Task> ProcessAttachmentSetsAsync(XmlElement configurationElement, ICollection attachments, IProgress progressReporter, IMessageLogger logger, CancellationToken cancellationToken); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectorAttachments.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectorAttachments.cs index a342d74ea6..0799b226ce 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectorAttachments.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectorAttachments.cs @@ -1,26 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection -{ - using System; - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +using System; +using System.Collections.Generic; +/// +/// Interface for data collectors add-ins that choose to handle attachment(s) generated +/// +[Obsolete("Interface is deprecated. Please use IDataCollectorAttachmentProcessor instead")] +public interface IDataCollectorAttachments +{ /// - /// Interface for data collectors add-ins that choose to handle attachment(s) generated + /// Gets the attachment set after Test Run Session /// - [Obsolete("Interface is deprecated. Please use IDataCollectorAttachmentProcessor instead")] - public interface IDataCollectorAttachments - { - /// - /// Gets the attachment set after Test Run Session - /// - /// Gets the attachment set after Test Run Session - ICollection HandleDataCollectionAttachmentSets(ICollection dataCollectionAttachments); + /// Gets the attachment set after Test Run Session + ICollection HandleDataCollectionAttachmentSets(ICollection dataCollectionAttachments); - /// - /// Gets the attachment Uri, which is handled by current Collector - /// - Uri GetExtensionUri(); - } -} + /// + /// Gets the attachment Uri, which is handled by current Collector + /// + Uri GetExtensionUri(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/ITestExecutionEnvironmentSpecifier.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/ITestExecutionEnvironmentSpecifier.cs index 462a15d078..1ee9cce579 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/ITestExecutionEnvironmentSpecifier.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/ITestExecutionEnvironmentSpecifier.cs @@ -1,20 +1,19 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +using System.Collections.Generic; +/// +/// Interface for data collectors add-ins that choose to specify some information about how the test execution environment +/// should be set up +/// +public interface ITestExecutionEnvironmentSpecifier +{ /// - /// Interface for data collectors add-ins that choose to specify some information about how the test execution environment - /// should be set up + /// Gets environment variables that should be set in the test execution environment /// - public interface ITestExecutionEnvironmentSpecifier - { - /// - /// Gets environment variables that should be set in the test execution environment - /// - /// Environment variables that should be set in the test execution environment - IEnumerable> GetTestExecutionEnvironmentVariables(); - } -} + /// Environment variables that should be set in the test execution environment + IEnumerable> GetTestExecutionEnvironmentVariables(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/InProcDataCollectionArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/InProcDataCollectionArgs.cs index adad4514da..18159963c0 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/InProcDataCollectionArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/InProcDataCollectionArgs.cs @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; + +/// +/// The InProcDataCollectionArgs interface. +/// +[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Interface is part of the public API.")] +public interface InProcDataCollectionArgs { - /// - /// The InProcDataCollectionArgs interface. - /// - public interface InProcDataCollectionArgs - { - } } diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/InProcDataCollector.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/InProcDataCollector.cs index 18eb7a78fb..de4d4370d2 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/InProcDataCollector.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/InProcDataCollector.cs @@ -1,52 +1,52 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.InProcDataCollector -{ - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.InProcDataCollector; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; +/// +/// Listener interface for external exe from test host +/// +[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Interface is part of the public API.")] +public interface InProcDataCollection +{ /// - /// Listener interface for external exe from test host + /// Initializes the In Process DataCollection with the DataCollectionSink /// - public interface InProcDataCollection - { - /// - /// Initializes the In Process DataCollection with the DataCollectionSink - /// - /// data collection sink object - void Initialize(IDataCollectionSink dataCollectionSink); + /// data collection sink object + void Initialize(IDataCollectionSink dataCollectionSink); - /// - /// Called when test session starts - /// - /// - /// The test Session Start Args. - /// - void TestSessionStart(TestSessionStartArgs testSessionStartArgs); + /// + /// Called when test session starts + /// + /// + /// The test Session Start Args. + /// + void TestSessionStart(TestSessionStartArgs testSessionStartArgs); - /// - /// Called when test case starts - /// - /// - /// Test Case start args - /// - void TestCaseStart(TestCaseStartArgs testCaseStartArgs); + /// + /// Called when test case starts + /// + /// + /// Test Case start args + /// + void TestCaseStart(TestCaseStartArgs testCaseStartArgs); - /// - /// Called when test case end - /// - /// - /// The test Case End Args. - /// - void TestCaseEnd(TestCaseEndArgs testCaseEndArgs); + /// + /// Called when test case end + /// + /// + /// The test Case End Args. + /// + void TestCaseEnd(TestCaseEndArgs testCaseEndArgs); - /// - /// Called when test session end - /// - /// - /// The test Session End Args. - /// - void TestSessionEnd(TestSessionEndArgs testSessionEndArgs); - } + /// + /// Called when test session end + /// + /// + /// The test Session End Args. + /// + void TestSessionEnd(TestSessionEndArgs testSessionEndArgs); } diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestCaseEndArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestCaseEndArgs.cs index 3e4887263b..1edd4aa0b2 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestCaseEndArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestCaseEndArgs.cs @@ -1,38 +1,37 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector -{ - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; + +using DataCollection; +/// +/// The test case end args. +/// +public class TestCaseEndArgs : InProcDataCollectionArgs +{ /// - /// The test case end args. + /// Initializes a new instance of the class. /// - public class TestCaseEndArgs : InProcDataCollectionArgs + /// + /// The data Collection Context. + /// + /// + /// The outcome. + /// + public TestCaseEndArgs(DataCollectionContext dataCollectionContext, TestOutcome outcome) { - /// - /// Initializes a new instance of the class. - /// - /// - /// The data Collection Context. - /// - /// - /// The outcome. - /// - public TestCaseEndArgs(DataCollectionContext dataCollectionContext, TestOutcome outcome) - { - this.TestOutcome = outcome; - this.DataCollectionContext = dataCollectionContext; - } + TestOutcome = outcome; + DataCollectionContext = dataCollectionContext; + } - /// - /// Gets the outcome. - /// - public TestOutcome TestOutcome { get; private set; } + /// + /// Gets the outcome. + /// + public TestOutcome TestOutcome { get; private set; } - /// - /// Gets the data collection context. - /// - public DataCollectionContext DataCollectionContext { get; private set; } - } -} + /// + /// Gets the data collection context. + /// + public DataCollectionContext DataCollectionContext { get; private set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestCaseStartArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestCaseStartArgs.cs index f4734db8c5..cbfcff1f4f 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestCaseStartArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestCaseStartArgs.cs @@ -1,27 +1,26 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; + +/// +/// The test case start args. +/// +public class TestCaseStartArgs : InProcDataCollectionArgs { /// - /// The test case start args. + /// Initializes a new instance of the class. /// - public class TestCaseStartArgs : InProcDataCollectionArgs + /// + /// The test case. + /// + public TestCaseStartArgs(TestCase testCase) { - /// - /// Initializes a new instance of the class. - /// - /// - /// The test case. - /// - public TestCaseStartArgs(TestCase testCase) - { - this.TestCase = testCase; - } - - /// - /// Gets the test case. - /// - public TestCase TestCase { get; private set; } + TestCase = testCase; } -} + + /// + /// Gets the test case. + /// + public TestCase TestCase { get; private set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestSessionEndArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestSessionEndArgs.cs index 158c660b69..5ab60e8471 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestSessionEndArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestSessionEndArgs.cs @@ -1,12 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; + +/// +/// The test session end args. +/// +public class TestSessionEndArgs : InProcDataCollectionArgs { - /// - /// The test session end args. - /// - public class TestSessionEndArgs : InProcDataCollectionArgs - { - } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestSessionStartArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestSessionStartArgs.cs index e546b11713..d166527d28 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestSessionStartArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestSessionStartArgs.cs @@ -1,88 +1,87 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; + +using System; +using System.Collections.Generic; + +/// +/// The test session start args. +/// +public class TestSessionStartArgs : InProcDataCollectionArgs { - using System; - using System.Collections.Generic; + private readonly IDictionary _properties; /// - /// The test session start args. + /// Initializes a new instance of the class. /// - public class TestSessionStartArgs : InProcDataCollectionArgs + public TestSessionStartArgs() { - private IDictionary Properties; - - /// - /// Initializes a new instance of the class. - /// - public TestSessionStartArgs() - { - this.Configuration = String.Empty; - } + Configuration = String.Empty; + } - /// - /// Initializes a new instance of the class. - /// - /// - /// Properties. - /// - public TestSessionStartArgs(IDictionary properties) - { - this.Configuration = String.Empty; - this.Properties = properties; - } + /// + /// Initializes a new instance of the class. + /// + /// + /// Properties. + /// + public TestSessionStartArgs(IDictionary properties) + { + Configuration = String.Empty; + _properties = properties; + } - /// - /// Initializes a new instance of the class. - /// - /// - /// The configuration. - /// - public TestSessionStartArgs(string configuration) - { - this.Configuration = configuration; - } + /// + /// Initializes a new instance of the class. + /// + /// + /// The configuration. + /// + public TestSessionStartArgs(string configuration) + { + Configuration = configuration; + } - /// - /// Gets or sets the configuration. - /// - public string Configuration { get; set; } + /// + /// Gets or sets the configuration. + /// + public string Configuration { get; set; } - /// - /// Gets session start properties enumerator - /// - public IEnumerator> GetProperties() - { - return this.Properties.GetEnumerator(); - } + /// + /// Gets session start properties enumerator + /// + public IEnumerator> GetProperties() + { + return _properties.GetEnumerator(); + } - /// - /// Gets property value - /// - /// - /// Property name - /// - public T GetPropertyValue(string property) - { - ValidateArg.NotNullOrEmpty(property, nameof(property)); + /// + /// Gets property value + /// + /// + /// Property name + /// + public T GetPropertyValue(string property) + { + ValidateArg.NotNullOrEmpty(property, nameof(property)); - return this.Properties.ContainsKey(property) ? (T)this.Properties[property] : default(T); - } + return _properties.ContainsKey(property) ? (T)_properties[property] : default; + } - /// - /// Gets property value - /// - /// - /// Property name - /// - public object GetPropertyValue(string property) - { - ValidateArg.NotNullOrEmpty(property, nameof(property)); + /// + /// Gets property value + /// + /// + /// Property name + /// + public object GetPropertyValue(string property) + { + ValidateArg.NotNullOrEmpty(property, nameof(property)); - this.Properties.TryGetValue(property, out var propertyValue); + _properties.TryGetValue(property, out var propertyValue); - return propertyValue; - } + return propertyValue; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/TransferInformation/BaseTransferInformation.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/TransferInformation/BaseTransferInformation.cs index 0f982750bd..4512fcdcb1 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/TransferInformation/BaseTransferInformation.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/TransferInformation/BaseTransferInformation.cs @@ -1,103 +1,95 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +/// +/// Collects the required and optional information needed for requesting a file transfer from a data collector. +/// +public abstract class BasicTransferInformation { - /// - /// Collects the required and optional information needed for requesting a file transfer from a data collector. - /// - public abstract class BasicTransferInformation - { - #region Fields + #region Fields - private string description; + private string _description; - #endregion + #endregion - #region Constructor + #region Constructor - /// - /// Initializes a new instance of the class. - /// - /// - /// The data collection context for the transfer. - /// - protected BasicTransferInformation(DataCollectionContext context) - { - //EqtAssert.ParameterNotNull(context, "context"); - this.Context = context; - this.Description = string.Empty; - } + /// + /// Initializes a new instance of the class. + /// + /// + /// The data collection context for the transfer. + /// + protected BasicTransferInformation(DataCollectionContext context) + { + //EqtAssert.ParameterNotNull(context, "context"); + Context = context; + Description = string.Empty; + } - #endregion + #endregion - #region Required Parameters. + #region Required Parameters. - /// - /// Gets the data collection context the transfer will be associated with. - /// - public DataCollectionContext Context { get; private set; } + /// + /// Gets the data collection context the transfer will be associated with. + /// + public DataCollectionContext Context { get; private set; } - #endregion + #endregion - #region Optional Parameters. + #region Optional Parameters. - /// - /// Gets or sets a short description of the data being sent. - /// - public string Description + /// + /// Gets or sets a short description of the data being sent. + /// + public string Description + { + get { - get - { - return this.description; - } - - set - { - // If we don't have a description, use an empty string. - if (value == null) - { - this.description = string.Empty; - } - else - { - this.description = value; - } - } + return _description; } - /// - /// Gets or sets the token which will be included with the callback to identify this file transfer. - /// - public object UserToken { get; set; } - - /// - /// Gets or sets the ID of the request that this file should be associated with. This is used - /// for sending transient data which will be associated only with this - /// data request and not the session or test cases that are currently running. - /// - public RequestId RequestId { get; set; } - - /// - /// Gets a value indicating whether cleanup should be performed after transferring the resource. This - /// can be known by different names in the derived classes so it is protected internal - /// so that we can refer to it in a consistent way. - /// - protected internal abstract bool PerformCleanup + set { - get; + // If we don't have a description, use an empty string. + _description = value ?? string.Empty; } + } - /// - /// Gets the name of the file to use on the client machine. This - /// can be known by different names in the derived classes so it is protected internal - /// so that we can refer to it in a consistent way. - /// - protected internal abstract string FileName - { - get; - } + /// + /// Gets or sets the token which will be included with the callback to identify this file transfer. + /// + public object UserToken { get; set; } + + /// + /// Gets or sets the ID of the request that this file should be associated with. This is used + /// for sending transient data which will be associated only with this + /// data request and not the session or test cases that are currently running. + /// + public RequestId RequestId { get; set; } + + /// + /// Gets a value indicating whether cleanup should be performed after transferring the resource. This + /// can be known by different names in the derived classes so it is protected internal + /// so that we can refer to it in a consistent way. + /// + protected internal abstract bool PerformCleanup + { + get; + } - #endregion + /// + /// Gets the name of the file to use on the client machine. This + /// can be known by different names in the derived classes so it is protected internal + /// so that we can refer to it in a consistent way. + /// + protected internal abstract string FileName + { + get; } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/TransferInformation/FileTransferInformation.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/TransferInformation/FileTransferInformation.cs index d6cc636665..f34a1b6bcc 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/TransferInformation/FileTransferInformation.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/TransferInformation/FileTransferInformation.cs @@ -1,93 +1,92 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection -{ - using System; - using System.IO; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +using System; +using System.IO; + +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +/// +/// Represents required and optional information needed for requesting a file transfer. +/// +public class FileTransferInformation : BasicTransferInformation +{ + private readonly IFileHelper _fileHelper; + #region Constructor /// - /// Represents required and optional information needed for requesting a file transfer. + /// Initializes a new instance of the class. /// - public class FileTransferInformation : BasicTransferInformation + /// + /// The context in which the file is being sent. Cannot be null. + /// + /// + /// The path to the file on the local file system + /// + /// + /// True to automatically have the file removed after sending it. + /// + public FileTransferInformation(DataCollectionContext context, string path, bool deleteFile) + : this(context, path, deleteFile, new TestPlatform.Utilities.Helpers.FileHelper()) { - private readonly IFileHelper fileHelper; - - #region Constructor - /// - /// Initializes a new instance of the class. - /// - /// - /// The context in which the file is being sent. Cannot be null. - /// - /// - /// The path to the file on the local file system - /// - /// - /// True to automatically have the file removed after sending it. - /// - public FileTransferInformation(DataCollectionContext context, string path, bool deleteFile) - : this(context, path, deleteFile, new TestPlatform.Utilities.Helpers.FileHelper()) - { - } + } - /// - /// Initializes a new instance of the class. - /// - /// - /// The context in which the file is being sent. Cannot be null. - /// - /// - /// The path to the file on the local file system - /// - /// - /// True to automatically have the file removed after sending it. - /// - /// - /// The file Helper. - /// - [CLSCompliant(false)] - public FileTransferInformation(DataCollectionContext context, string path, bool deleteFile, IFileHelper fileHelper) - : base(context) - { - this.fileHelper = fileHelper; + /// + /// Initializes a new instance of the class. + /// + /// + /// The context in which the file is being sent. Cannot be null. + /// + /// + /// The path to the file on the local file system + /// + /// + /// True to automatically have the file removed after sending it. + /// + /// + /// The file Helper. + /// + [CLSCompliant(false)] + public FileTransferInformation(DataCollectionContext context, string path, bool deleteFile, IFileHelper fileHelper) + : base(context) + { + _fileHelper = fileHelper; - // Expand environment variables in the path - path = Environment.ExpandEnvironmentVariables(path); + // Expand environment variables in the path + path = Environment.ExpandEnvironmentVariables(path); - // Make sure the file exists. - if (!this.fileHelper.Exists(path)) - { - throw new FileNotFoundException(string.Format(Resources.Resources.Common_FileNotExist, new object[] { path }), path); - } + // Make sure the file exists. + if (!_fileHelper.Exists(path)) + { + throw new FileNotFoundException(string.Format(Resources.Resources.Common_FileNotExist, new object[] { path }), path); + } - // Make sure the path we have is a full path (not relative). - this.Path = this.fileHelper.GetFullPath(path); + // Make sure the path we have is a full path (not relative). + Path = _fileHelper.GetFullPath(path); - this.PerformCleanup = deleteFile; - } + PerformCleanup = deleteFile; + } - #endregion + #endregion - #region Required Parameters. + #region Required Parameters. - /// - /// Gets the path to the file on the local file system. - /// - public string Path { get; private set; } + /// + /// Gets the path to the file on the local file system. + /// + public string Path { get; private set; } - /// - /// Indicates if cleanup should be performed after transferring the resource. - /// - protected internal override bool PerformCleanup { get; } + /// + /// Indicates if cleanup should be performed after transferring the resource. + /// + protected internal override bool PerformCleanup { get; } - /// - /// The name of the file to use on the client machine. - /// - protected internal override string FileName => this.Path; + /// + /// The name of the file to use on the client machine. + /// + protected internal override string FileName => Path; - #endregion - } -} + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/DefaultExecutorUriAttribute.cs b/src/Microsoft.TestPlatform.ObjectModel/DefaultExecutorUriAttribute.cs index 5f6caabacd..87b59153e2 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DefaultExecutorUriAttribute.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DefaultExecutorUriAttribute.cs @@ -1,44 +1,43 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; + +using Resources; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources; +/// +/// This attribute is applied on the discoverers to inform the framework about their default executor. +/// +[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] +public sealed class DefaultExecutorUriAttribute : Attribute +{ + #region Constructor /// - /// This attribute is applied on the discoverers to inform the framework about their default executor. + /// Initializes with the Uri of the executor. /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] - public sealed class DefaultExecutorUriAttribute : Attribute + /// The Uri of the executor + public DefaultExecutorUriAttribute(string executorUri) { - #region Constructor - - /// - /// Initializes with the Uri of the executor. - /// - /// The Uri of the executor - public DefaultExecutorUriAttribute(string executorUri) + if (string.IsNullOrWhiteSpace(executorUri)) { - if (string.IsNullOrWhiteSpace(executorUri)) - { - throw new ArgumentException(CommonResources.CannotBeNullOrEmpty, nameof(executorUri)); - } - - ExecutorUri = executorUri; + throw new ArgumentException(CommonResources.CannotBeNullOrEmpty, nameof(executorUri)); } - #endregion + ExecutorUri = executorUri; + } - #region Properties + #endregion - /// - /// The Uri of the Test Executor. - /// - public string ExecutorUri { get; private set; } + #region Properties - #endregion + /// + /// The Uri of the Test Executor. + /// + public string ExecutorUri { get; private set; } - } -} + #endregion + +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/ExceptionConverter.cs b/src/Microsoft.TestPlatform.ObjectModel/ExceptionConverter.cs index 61742d9bc5..e5098f6532 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/ExceptionConverter.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/ExceptionConverter.cs @@ -1,30 +1,28 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; - using System.Diagnostics.CodeAnalysis; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; - /// - /// Base exception for all Rocksteady service exceptions - /// +using System; + +/// +/// Base exception for all Rocksteady service exceptions +/// #if NETFRAMEWORK - [Serializable] +[Serializable] #endif - [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] - public class TestPlatformException : Exception +public class TestPlatformException : Exception +{ + public TestPlatformException(String message) + : base(message) { - public TestPlatformException(String message) - : base(message) - { - } + } - public TestPlatformException(string message, Exception innerException) - : base(message, innerException) - { - } + public TestPlatformException(string message, Exception innerException) + : base(message, innerException) + { } +} #if FullCLR /// @@ -97,12 +95,10 @@ private static Exception ConvertException(String exceptionType, String message, #endif #if NETFRAMEWORK - [Serializable] +[Serializable] #endif - [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] - public class ProcessExitedException : TestPlatformException - { - public ProcessExitedException(string message) : base(message) { } - public ProcessExitedException(string message, Exception inner) : base(message, inner) { } - } -} +public class ProcessExitedException : TestPlatformException +{ + public ProcessExitedException(string message) : base(message) { } + public ProcessExitedException(string message, Exception inner) : base(message, inner) { } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/ExtensionUriAttribute.cs b/src/Microsoft.TestPlatform.ObjectModel/ExtensionUriAttribute.cs index e03a1cd33c..af93dafce0 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/ExtensionUriAttribute.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/ExtensionUriAttribute.cs @@ -1,47 +1,46 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; + +using Resources; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources; +/// +/// This attribute is applied to extensions so they can be uniquely identified. +/// It indicates the Uri which uniquely identifies the extension. If this attribute +/// is not provided on the extensions such as the Test Executor or Test Logger, then +/// the extensions will not be used. +/// +[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] +public sealed class ExtensionUriAttribute : Attribute +{ + #region Constructor /// - /// This attribute is applied to extensions so they can be uniquely identified. - /// It indicates the Uri which uniquely identifies the extension. If this attribute - /// is not provided on the extensions such as the Test Executor or Test Logger, then - /// the extensions will not be used. + /// Initializes with the Uri of the extension. /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] - public sealed class ExtensionUriAttribute : Attribute + /// The Uri of the extension + public ExtensionUriAttribute(string extensionUri) { - #region Constructor - - /// - /// Initializes with the Uri of the extension. - /// - /// The Uri of the extension - public ExtensionUriAttribute(string extensionUri) + if (string.IsNullOrWhiteSpace(extensionUri)) { - if (string.IsNullOrWhiteSpace(extensionUri)) - { - throw new ArgumentException(CommonResources.CannotBeNullOrEmpty, nameof(extensionUri)); - } - - ExtensionUri = extensionUri; + throw new ArgumentException(CommonResources.CannotBeNullOrEmpty, nameof(extensionUri)); } - #endregion + ExtensionUri = extensionUri; + } - #region Properties + #endregion - /// - /// The Uri of the Test Executor. - /// - public string ExtensionUri { get; private set; } + #region Properties - #endregion + /// + /// The Uri of the Test Executor. + /// + public string ExtensionUri { get; private set; } - } -} + #endregion + +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/FileExtensionAttribute.cs b/src/Microsoft.TestPlatform.ObjectModel/FileExtensionAttribute.cs index 1a540dc47f..5cb47d4dd4 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/FileExtensionAttribute.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/FileExtensionAttribute.cs @@ -1,47 +1,46 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources; +using Resources; + +/// +/// This attribute is applied to ITestDiscoverers. It indicates +/// which file extensions the test discoverer knows how to process. +/// If this attribute is not provided on the test discoverer it will be +/// called for all file types. +/// +[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] +public sealed class FileExtensionAttribute : Attribute +{ + #region Constructor /// - /// This attribute is applied to ITestDiscoverers. It indicates - /// which file extensions the test discoverer knows how to process. - /// If this attribute is not provided on the test discoverer it will be - /// called for all file types. + /// Initializes with a file extension that the test discoverer can process tests from. + /// For example ".dll" or ".exe". /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] - public sealed class FileExtensionAttribute : Attribute + /// The file extensions that the test discoverer can process tests from. + public FileExtensionAttribute(string fileExtension) { - #region Constructor - - /// - /// Initializes with a file extension that the test discoverer can process tests from. - /// For example ".dll" or ".exe". - /// - /// The file extensions that the test discoverer can process tests from. - public FileExtensionAttribute(string fileExtension) + if (string.IsNullOrWhiteSpace(fileExtension)) { - if (string.IsNullOrWhiteSpace(fileExtension)) - { - throw new ArgumentException(CommonResources.CannotBeNullOrEmpty, nameof(fileExtension)); - } - - FileExtension = fileExtension; + throw new ArgumentException(CommonResources.CannotBeNullOrEmpty, nameof(fileExtension)); } - #endregion + FileExtension = fileExtension; + } - #region Properties + #endregion - /// - /// A file extensions that the test discoverer can process tests from. For example ".dll" or ".exe". - /// - public string FileExtension { get; private set; } + #region Properties - #endregion - } -} + /// + /// A file extensions that the test discoverer can process tests from. For example ".dll" or ".exe". + /// + public string FileExtension { get; private set; } + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Framework.cs b/src/Microsoft.TestPlatform.ObjectModel/Framework.cs index 280719ff98..bdaa2abf0f 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Framework.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Framework.cs @@ -1,130 +1,131 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + #if !NETSTANDARD1_0 - using NuGet.Frameworks; - using static NuGet.Frameworks.FrameworkConstants; +using NuGet.Frameworks; + +using static NuGet.Frameworks.FrameworkConstants; #endif +/// +/// Class for target Framework for the test container +/// +public class Framework +{ + private Framework() + { + } + /// - /// Class for target Framework for the test container + /// Default .Net target framework. /// - public class Framework - { + public static Framework DefaultFramework { get; } = #if NETFRAMEWORK - private static readonly Framework Default = Framework.FromString(".NETFramework,Version=v4.0"); + Framework.FromString(".NETFramework,Version=v4.0"); #elif NETSTANDARD1_0 - private static readonly Framework Default = null; + null; #else - private static readonly Framework Default = Framework.FromString(".NETCoreApp,Version=v1.0"); + Framework.FromString(".NETCoreApp,Version=v1.0"); #endif - private Framework() - { - } + /// + /// Gets the FullName of framework. + /// + public string Name { get; private set; } - /// - /// Default .Net target framework. - /// - public static Framework DefaultFramework => Framework.Default; - - /// - /// Gets the FullName of framework. - /// - public string Name { get; private set; } - - /// - /// Gets the framework version. - /// - public string Version { get; private set; } - - /// - /// Returns a valid framework else returns null - /// - /// Framework name - /// A framework object - public static Framework FromString(string frameworkString) - { + /// + /// Gets the framework version. + /// + public string Version { get; private set; } + + /// + /// Returns a valid framework else returns null + /// + /// Framework name + /// A framework object + public static Framework FromString(string frameworkString) + { #if NETSTANDARD1_0 - var CommonFrameworks = new - { - Net35 = new { DotNetFrameworkName = Constants.DotNetFramework35, Version = "3.5.0.0" }, - Net4 = new { DotNetFrameworkName = Constants.DotNetFramework40, Version = "4.0.0.0" }, - Net45 = new { DotNetFrameworkName = Constants.DotNetFramework45, Version = "4.5.0.0" }, - NetCoreApp10 = new { DotNetFrameworkName = Constants.DotNetFrameworkCore10, Version = "1.0.0.0" }, - UAP10 = new { DotNetFrameworkName = Constants.DotNetFrameworkUap10, Version = "10.0.0.0" }, - }; +#pragma warning disable IDE1006 // Naming Styles + var CommonFrameworks = new +#pragma warning restore IDE1006 // Naming Styles + { + Net35 = new { DotNetFrameworkName = Constants.DotNetFramework35, Version = "3.5.0.0" }, + Net4 = new { DotNetFrameworkName = Constants.DotNetFramework40, Version = "4.0.0.0" }, + Net45 = new { DotNetFrameworkName = Constants.DotNetFramework45, Version = "4.5.0.0" }, + NetCoreApp10 = new { DotNetFrameworkName = Constants.DotNetFrameworkCore10, Version = "1.0.0.0" }, + UAP10 = new { DotNetFrameworkName = Constants.DotNetFrameworkUap10, Version = "10.0.0.0" }, + }; #endif - if (string.IsNullOrWhiteSpace(frameworkString)) - { - return null; - } + if (string.IsNullOrWhiteSpace(frameworkString)) + { + return null; + } - string name, version; - try + string name, version; + try + { + // IDE always sends framework in form of ENUM, which always throws exception + // This throws up in first chance exception, refer Bug https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems/edit/591142 + switch (frameworkString.Trim().ToLower()) { - // IDE always sends framework in form of ENUM, which always throws exception - // This throws up in first chance exception, refer Bug https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems/edit/591142 - switch (frameworkString.Trim().ToLower()) - { - case "framework35": - name = CommonFrameworks.Net35.DotNetFrameworkName; - version = CommonFrameworks.Net35.Version.ToString(); - break; - - case "framework40": - name = CommonFrameworks.Net4.DotNetFrameworkName; - version = CommonFrameworks.Net4.Version.ToString(); - break; - - case "framework45": - name = CommonFrameworks.Net45.DotNetFrameworkName; - version = CommonFrameworks.Net45.Version.ToString(); - break; - - case "frameworkcore10": - name = CommonFrameworks.NetCoreApp10.DotNetFrameworkName; - version = CommonFrameworks.NetCoreApp10.Version.ToString(); - break; - - case "frameworkuap10": - name = CommonFrameworks.UAP10.DotNetFrameworkName; - version = CommonFrameworks.UAP10.Version.ToString(); - break; - - default: + case "framework35": + name = CommonFrameworks.Net35.DotNetFrameworkName; + version = CommonFrameworks.Net35.Version.ToString(); + break; + + case "framework40": + name = CommonFrameworks.Net4.DotNetFrameworkName; + version = CommonFrameworks.Net4.Version.ToString(); + break; + + case "framework45": + name = CommonFrameworks.Net45.DotNetFrameworkName; + version = CommonFrameworks.Net45.Version.ToString(); + break; + + case "frameworkcore10": + name = CommonFrameworks.NetCoreApp10.DotNetFrameworkName; + version = CommonFrameworks.NetCoreApp10.Version.ToString(); + break; + + case "frameworkuap10": + name = CommonFrameworks.UAP10.DotNetFrameworkName; + version = CommonFrameworks.UAP10.Version.ToString(); + break; + + default: #if NETSTANDARD1_0 - return null; + return null; #else - var nugetFramework = NuGetFramework.Parse(frameworkString); - if (nugetFramework.IsUnsupported) - return null; + var nugetFramework = NuGetFramework.Parse(frameworkString); + if (nugetFramework.IsUnsupported) + return null; - name = nugetFramework.DotNetFrameworkName; - version = nugetFramework.Version.ToString(); + name = nugetFramework.DotNetFrameworkName; + version = nugetFramework.Version.ToString(); - break; + break; #endif - } } - catch - { - return null; - } - - return new Framework() { Name = name, Version = version }; } - - /// - /// Returns full name of the framework. - /// - /// String presentation of the object. - public override string ToString() + catch { - return this.Name; + return null; } + + return new Framework() { Name = name, Version = version }; + } + + /// + /// Returns full name of the framework. + /// + /// String presentation of the object. + public override string ToString() + { + return Name; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/FrameworkVersion.cs b/src/Microsoft.TestPlatform.ObjectModel/FrameworkVersion.cs index f5748d1c02..65268e3f50 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/FrameworkVersion.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/FrameworkVersion.cs @@ -1,18 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +/// +/// This holds the major desktop framework versions. This is just to maintain compatibility with older runsettings files. +/// +public enum FrameworkVersion { - /// - /// This holds the major desktop framework versions. This is just to maintain compatibility with older runsettings files. - /// - public enum FrameworkVersion - { - None, - Framework35, - Framework40, - Framework45, - FrameworkCore10, - FrameworkUap10 - } -} + None, + Framework35, + Framework40, + Framework45, + FrameworkCore10, + FrameworkUap10 +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/FriendlyNameAttribute.cs b/src/Microsoft.TestPlatform.ObjectModel/FriendlyNameAttribute.cs index b7b8c90681..5ab29bf8a7 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/FriendlyNameAttribute.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/FriendlyNameAttribute.cs @@ -1,46 +1,45 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; + +using Resources; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources; +/// +/// This attribute is applied to Loggers so they can be uniquely identified. +/// It indicates the Friendly Name which uniquely identifies the extension. +/// This attribute is optional. +/// +[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] +public sealed class FriendlyNameAttribute : Attribute +{ + #region Constructor /// - /// This attribute is applied to Loggers so they can be uniquely identified. - /// It indicates the Friendly Name which uniquely identifies the extension. - /// This attribute is optional. + /// Initializes with the Friendly Name of the logger. /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] - public sealed class FriendlyNameAttribute : Attribute + /// The friendly name of the Logger + public FriendlyNameAttribute(string friendlyName) { - #region Constructor - - /// - /// Initializes with the Friendly Name of the logger. - /// - /// The friendly name of the Logger - public FriendlyNameAttribute(string friendlyName) + if (string.IsNullOrWhiteSpace(friendlyName)) { - if (string.IsNullOrWhiteSpace(friendlyName)) - { - throw new ArgumentException(CommonResources.CannotBeNullOrEmpty, nameof(friendlyName)); - } - - FriendlyName = friendlyName; + throw new ArgumentException(CommonResources.CannotBeNullOrEmpty, nameof(friendlyName)); } - #endregion + FriendlyName = friendlyName; + } - #region Properties + #endregion - /// - /// The friendly Name of the Test Logger. - /// - public string FriendlyName { get; private set; } + #region Properties - #endregion + /// + /// The friendly Name of the Test Logger. + /// + public string FriendlyName { get; private set; } - } -} + #endregion + +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Host/ITestRunTimeProvider.cs b/src/Microsoft.TestPlatform.ObjectModel/Host/ITestRunTimeProvider.cs index 8106cc91f4..44d965e2b9 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Host/ITestRunTimeProvider.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Host/ITestRunTimeProvider.cs @@ -1,140 +1,140 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Host +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +using Client.Interfaces; + +using Logging; + +/// +/// Interface for TestRuntimeProvider which manages test host processes for test engine. +/// +public interface ITestRuntimeProvider { - using System; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; + #region events + /// + /// Raised when host is launched successfully + /// Consumed by TestPlatform to initialize connection b/w test host and test platform + /// + event EventHandler HostLaunched; + + /// + /// Raised when host is cleaned up and removes all it's dependencies + /// + event EventHandler HostExited; + + #endregion + + /// + /// Gets a value indicating whether the test host is specific to a test source. If yes, each test source + /// is launched in a separate host process. + /// + bool Shared { get; } - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + /// + /// Sets a Message Logger + /// + /// provide logger to runtimes + /// provide runsettings to runtimes for initialization + void Initialize(IMessageLogger logger, string runsettingsXml); /// - /// Interface for TestRuntimeProvider which manages test host processes for test engine. + /// Gets a value indicating whether the test host is specific to a test source. If yes, each test source + /// is launched in a separate host process. /// - public interface ITestRuntimeProvider + /// + /// The run Configuration. + /// + /// + /// The . + /// + bool CanExecuteCurrentRunConfiguration(string runsettingsXml); + + /// + /// Sets a custom launcher + /// + /// Custom launcher to set + void SetCustomLauncher(ITestHostLauncher customLauncher); + + /// + /// Gets the end point address and behavior of TestRuntime + /// E.g. for phone device EndPoint:127.0.0.1:8080, ConnectionRole Host, TransportProtocol: Sockets + /// + /// Socket where the service is hosted by TestRuntime + TestHostConnectionInfo GetTestHostConnectionInfo(); + + /// + /// Launches the test host for discovery/execution. + /// + /// Start parameters for the test host. + /// + /// Returns whether the test host launched successfully or not. + Task LaunchTestHostAsync(TestProcessStartInfo testHostStartInfo, CancellationToken cancellationToken); + + /// + /// Gets the start parameters for the test host. + /// + /// Test source paths. + /// Set of environment variables for the test host process. + /// Set of connection parameters for the test host process to communicate with test runner. + /// ProcessStartInfo of the test host. + TestProcessStartInfo GetTestHostProcessStartInfo(IEnumerable sources, IDictionary environmentVariables, TestRunnerConnectionInfo connectionInfo); + + /// + /// Gets paths of any additional extensions. + /// A test host manager may choose to provide a custom extensions acquisition and discovery + /// mechanism. E.g. for .net core, extensions are discovered from the testproject.deps.json file. + /// + /// List of test sources. + /// + /// List of paths to extension assemblies. + IEnumerable GetTestPlatformExtensions(IEnumerable sources, IEnumerable extensions); + + /// + /// Gets path of test sources, based on RuntimeProvider, and where the test is actually deployed(Remote Scenario). + /// A test host manager may choose to accept input source as XML file, and provide appropriate source(dll/exe) which the adapters can actually consume + /// E.g. for UWP, input source could be "appx recipe" file, which gives information about actual source exe. + /// + /// List of test sources. + /// Updated List of test sources based on remote/local scenario. + IEnumerable GetTestSources(IEnumerable sources); + + /// + /// Cleanup the test host process and it's dependencies. + /// + /// + /// Cancellation token. + /// + /// + /// The . + /// + Task CleanTestHostAsync(CancellationToken cancellationToken); +} + +public class HostProviderEventArgs : EventArgs +{ + public HostProviderEventArgs(string message) { - #region events - /// - /// Raised when host is launched successfully - /// Consumed by TestPlatform to initialize connection b/w test host and test platform - /// - event EventHandler HostLaunched; - - /// - /// Raised when host is cleaned up and removes all it's dependencies - /// - event EventHandler HostExited; - - #endregion - - /// - /// Gets a value indicating whether the test host is specific to a test source. If yes, each test source - /// is launched in a separate host process. - /// - bool Shared { get; } - - /// - /// Sets a Message Logger - /// - /// provide logger to runtimes - /// provide runsettings to runtimes for initialization - void Initialize(IMessageLogger logger, string runsettingsXml); - - /// - /// Gets a value indicating whether the test host is specific to a test source. If yes, each test source - /// is launched in a separate host process. - /// - /// - /// The run Configuration. - /// - /// - /// The . - /// - bool CanExecuteCurrentRunConfiguration(string runsettingsXml); - - /// - /// Sets a custom launcher - /// - /// Custom launcher to set - void SetCustomLauncher(ITestHostLauncher customLauncher); - - /// - /// Gets the end point address and behavior of TestRuntime - /// E.g. for phone device EndPoint:127.0.0.1:8080, ConnectionRole Host, TransportProtocol: Sockets - /// - /// Socket where the service is hosted by TestRuntime - TestHostConnectionInfo GetTestHostConnectionInfo(); - - /// - /// Launches the test host for discovery/execution. - /// - /// Start parameters for the test host. - /// - /// Returns whether the test host launched successfully or not. - Task LaunchTestHostAsync(TestProcessStartInfo testHostStartInfo, CancellationToken cancellationToken); - - /// - /// Gets the start parameters for the test host. - /// - /// Test source paths. - /// Set of environment variables for the test host process. - /// Set of connection parameters for the test host process to communicate with test runner. - /// ProcessStartInfo of the test host. - TestProcessStartInfo GetTestHostProcessStartInfo(IEnumerable sources, IDictionary environmentVariables, TestRunnerConnectionInfo connectionInfo); - - /// - /// Gets paths of any additional extensions. - /// A test host manager may choose to provide a custom extensions acquisition and discovery - /// mechanism. E.g. for .net core, extensions are discovered from the testproject.deps.json file. - /// - /// List of test sources. - /// - /// List of paths to extension assemblies. - IEnumerable GetTestPlatformExtensions(IEnumerable sources, IEnumerable extensions); - - /// - /// Gets path of test sources, based on RuntimeProvider, and where the test is actually deployed(Remote Scenario). - /// A test host manager may choose to accept input source as XML file, and provide appropriate source(dll/exe) which the adapters can actually consume - /// E.g. for UWP, input source could be "appx recipe" file, which gives information about actual source exe. - /// - /// List of test sources. - /// Updated List of test sources based on remote/local scenario. - IEnumerable GetTestSources(IEnumerable sources); - - /// - /// Cleanup the test host process and it's dependencies. - /// - /// - /// Cancellation token. - /// - /// - /// The . - /// - Task CleanTestHostAsync(CancellationToken cancellationToken); + Data = message; + ErrroCode = 0; } - public class HostProviderEventArgs : EventArgs + public HostProviderEventArgs(string message, int errorCode, int processId) { - public HostProviderEventArgs(string message) - { - this.Data = message; - this.ErrroCode = 0; - } - - public HostProviderEventArgs(string message, int errorCode, int processId) - { - this.Data = message; - this.ErrroCode = errorCode; - this.ProcessId = processId; - } + Data = message; + ErrroCode = errorCode; + ProcessId = processId; + } - public string Data { get; set; } + public string Data { get; set; } - public int ErrroCode { get; set; } + public int ErrroCode { get; set; } - public int ProcessId { get; set; } - } -} + public int ProcessId { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Host/ITestRuntimeProvider2.cs b/src/Microsoft.TestPlatform.ObjectModel/Host/ITestRuntimeProvider2.cs index 170c1e8343..6a25c7aa71 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Host/ITestRuntimeProvider2.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Host/ITestRuntimeProvider2.cs @@ -1,21 +1,20 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Host +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; + +/// +/// Interface to define a TestRuntimeProvider with support for attaching the debugger to the +/// default testhost process. +/// +public interface ITestRuntimeProvider2 : ITestRuntimeProvider { /// - /// Interface to define a TestRuntimeProvider with support for attaching the debugger to the - /// default testhost process. + /// Attach the debugger to an already running testhost process. /// - public interface ITestRuntimeProvider2 : ITestRuntimeProvider - { - /// - /// Attach the debugger to an already running testhost process. - /// - /// - /// if the debugger was successfully attached to the running testhost - /// process, otherwise. - /// - bool AttachDebuggerToTestHost(); - } -} + /// + /// if the debugger was successfully attached to the running testhost + /// process, otherwise. + /// + bool AttachDebuggerToTestHost(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/InvokedDataCollector.cs b/src/Microsoft.TestPlatform.ObjectModel/InvokedDataCollector.cs index dacdfc6f9e..8658f98349 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/InvokedDataCollector.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/InvokedDataCollector.cs @@ -1,108 +1,103 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; - public sealed class InvokedDataCollector : IEquatable - { - /// - /// Initialize an InvokedDataCollector - /// - /// Data collector Uri - /// Data collector assembly qualified name - /// Data collector file path - /// True if data collector registers an attachment processor - public InvokedDataCollector(Uri uri, string friendlyName, string assemblyQualifiedName, string filePath, bool hasAttachmentProcessor) - { - this.Uri = uri ?? throw new ArgumentException(nameof(uri)); - this.FriendlyName = friendlyName ?? throw new ArgumentException(nameof(friendlyName)); - this.AssemblyQualifiedName = assemblyQualifiedName ?? throw new ArgumentException(nameof(assemblyQualifiedName)); ; - this.FilePath = filePath ?? throw new ArgumentException(nameof(filePath)); ; - this.HasAttachmentProcessor = hasAttachmentProcessor; - } +using System; +using System.Runtime.Serialization; - /// - /// DataCollector uri. - /// - [DataMember] - public Uri Uri { get; private set; } +public sealed class InvokedDataCollector : IEquatable +{ + /// + /// Initialize an InvokedDataCollector + /// + /// Data collector Uri + /// Data collector assembly qualified name + /// Data collector file path + /// True if data collector registers an attachment processor + public InvokedDataCollector(Uri uri, string friendlyName, string assemblyQualifiedName, string filePath, bool hasAttachmentProcessor) + { + Uri = uri ?? throw new ArgumentException(nameof(uri)); + FriendlyName = friendlyName ?? throw new ArgumentException(nameof(friendlyName)); + AssemblyQualifiedName = assemblyQualifiedName ?? throw new ArgumentException(nameof(assemblyQualifiedName)); ; + FilePath = filePath ?? throw new ArgumentException(nameof(filePath)); ; + HasAttachmentProcessor = hasAttachmentProcessor; + } - /// - /// DataCollector FriendlyName. - /// - [DataMember] - public string FriendlyName { get; private set; } + /// + /// DataCollector uri. + /// + [DataMember] + public Uri Uri { get; private set; } - /// - /// AssemblyQualifiedName of data collector. - /// - [DataMember] - public string AssemblyQualifiedName { get; private set; } + /// + /// DataCollector FriendlyName. + /// + [DataMember] + public string FriendlyName { get; private set; } - /// - /// Data collector file path. - /// - [DataMember] - public string FilePath { get; private set; } + /// + /// AssemblyQualifiedName of data collector. + /// + [DataMember] + public string AssemblyQualifiedName { get; private set; } - /// - /// True if the collector registers an attachments processor. - /// - [DataMember] - public bool HasAttachmentProcessor { get; private set; } + /// + /// Data collector file path. + /// + [DataMember] + public string FilePath { get; private set; } - /// - /// Compares InvokedDataCollector instances for equality. - /// - /// InvokedDataCollector instance - /// True if objects are equal - public bool Equals(InvokedDataCollector other) - { - if (other is null) - { - return false; - } + /// + /// True if the collector registers an attachments processor. + /// + [DataMember] + public bool HasAttachmentProcessor { get; private set; } - return this.HasAttachmentProcessor == other.HasAttachmentProcessor && - this.Uri.AbsoluteUri == other.Uri.AbsoluteUri && - this.FriendlyName == other.FriendlyName && - this.AssemblyQualifiedName == other.AssemblyQualifiedName && - this.FilePath == other.FilePath; - } + /// + /// Compares InvokedDataCollector instances for equality. + /// + /// InvokedDataCollector instance + /// True if objects are equal + public bool Equals(InvokedDataCollector other) + { + return other is not null + && HasAttachmentProcessor == other.HasAttachmentProcessor && + Uri.AbsoluteUri == other.Uri.AbsoluteUri && + FriendlyName == other.FriendlyName && + AssemblyQualifiedName == other.AssemblyQualifiedName && + FilePath == other.FilePath; + } - /// - /// Compares InvokedDataCollector instances for equality. - /// - /// InvokedDataCollector instance - /// True if objects are equal - public override bool Equals(object obj) - => this.Equals(obj as InvokedDataCollector); + /// + /// Compares InvokedDataCollector instances for equality. + /// + /// InvokedDataCollector instance + /// True if objects are equal + public override bool Equals(object obj) + => Equals(obj as InvokedDataCollector); - /// - /// Returns the object hashcode - /// - /// Hashcode value - public override int GetHashCode() + /// + /// Returns the object hashcode + /// + /// Hashcode value + public override int GetHashCode() + { + unchecked { - unchecked - { - var hashCode = this.Uri.GetHashCode(); - hashCode = (hashCode * 397) ^ this.FriendlyName.GetHashCode(); - hashCode = (hashCode * 397) ^ this.AssemblyQualifiedName.GetHashCode(); - hashCode = (hashCode * 397) ^ (this.FilePath != null ? this.FilePath.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ this.HasAttachmentProcessor.GetHashCode(); - return hashCode; - } + var hashCode = Uri.GetHashCode(); + hashCode = (hashCode * 397) ^ FriendlyName.GetHashCode(); + hashCode = (hashCode * 397) ^ AssemblyQualifiedName.GetHashCode(); + hashCode = (hashCode * 397) ^ (FilePath != null ? FilePath.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ HasAttachmentProcessor.GetHashCode(); + return hashCode; } - - /// - /// Return string representation for the current object - /// - /// String representation - public override string ToString() - => $"Uri: '{Uri}' FriendlyName: '{FriendlyName}' AssemblyQualifiedName: '{AssemblyQualifiedName}' FilePath: '{FilePath}' HasAttachmentProcessor: '{HasAttachmentProcessor}'"; } -} + + /// + /// Return string representation for the current object + /// + /// String representation + public override string ToString() + => $"Uri: '{Uri}' FriendlyName: '{FriendlyName}' AssemblyQualifiedName: '{AssemblyQualifiedName}' FilePath: '{FilePath}' HasAttachmentProcessor: '{HasAttachmentProcessor}'"; +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/LazyPropertyValue.cs b/src/Microsoft.TestPlatform.ObjectModel/LazyPropertyValue.cs index a2cab09f3d..fae0410f58 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/LazyPropertyValue.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/LazyPropertyValue.cs @@ -1,61 +1,60 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +/// +/// Represents a lazy value calculation for a TestObject +/// +internal interface ILazyPropertyValue +{ /// - /// Represents a lazy value calculation for a TestObject + /// Forces calculation of the value /// - internal interface ILazyPropertyValue + object Value { get; } +} + +/// +/// Represents a lazy value calculation for a TestObject +/// +/// The type of the value to be calculated +public sealed class LazyPropertyValue : ILazyPropertyValue +{ + private T _value; + private readonly Func _getValue; + private bool _isValueCreated; + + public LazyPropertyValue(Func getValue) { - /// - /// Forces calculation of the value - /// - object Value { get; } + _isValueCreated = false; + _value = default; + _getValue = getValue; } /// - /// Represents a lazy value calculation for a TestObject + /// Forces calculation of the value /// - /// The type of the value to be calculated - public sealed class LazyPropertyValue : ILazyPropertyValue + public T Value { - private T value; - private Func getValue; - private bool isValueCreated; - - public LazyPropertyValue(Func getValue) - { - this.isValueCreated = false; - this.value = default(T); - this.getValue = getValue; - } - - /// - /// Forces calculation of the value - /// - public T Value + get { - get + if (!_isValueCreated) { - if (!isValueCreated) - { - this.value = this.getValue(); - isValueCreated = true; - } - - return this.value; + _value = _getValue(); + _isValueCreated = true; } + + return _value; } + } - object ILazyPropertyValue.Value + object ILazyPropertyValue.Value + { + get { - get - { - return this.Value; - } + return Value; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Logger/ITestLogger.cs b/src/Microsoft.TestPlatform.ObjectModel/Logger/ITestLogger.cs index cf547de114..bdab1e13c0 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Logger/ITestLogger.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Logger/ITestLogger.cs @@ -1,20 +1,19 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +/// +/// Interface implemented to log messages and results from tests. A class that +/// implements this interface will be available for use if it exports its type via +/// MEF, and if its containing assembly is placed in the Extensions folder. +/// +public interface ITestLogger { /// - /// Interface implemented to log messages and results from tests. A class that - /// implements this interface will be available for use if it exports its type via - /// MEF, and if its containing assembly is placed in the Extensions folder. + /// Initializes the Test Logger. /// - public interface ITestLogger - { - /// - /// Initializes the Test Logger. - /// - /// Events that can be registered for. - /// Test Run Directory - void Initialize(TestLoggerEvents events, string testRunDirectory); - } -} + /// Events that can be registered for. + /// Test Run Directory + void Initialize(TestLoggerEvents events, string testRunDirectory); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Logger/ITestLoggerWithParams.cs b/src/Microsoft.TestPlatform.ObjectModel/Logger/ITestLoggerWithParams.cs index a133c56e7d..44cf25462b 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Logger/ITestLoggerWithParams.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Logger/ITestLoggerWithParams.cs @@ -1,22 +1,21 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System.Collections.Generic; +/// +/// This Interface extends ITestLogger and adds capability to pass +/// parameters to loggers such as TfsPublisher. +/// Currently it is marked for internal consumption (ex: TfsPublisher) +/// +public interface ITestLoggerWithParameters : ITestLogger +{ /// - /// This Interface extends ITestLogger and adds capability to pass - /// parameters to loggers such as TfsPublisher. - /// Currently it is marked for internal consumption (ex: TfsPublisher) + /// Initializes the Test Logger with given parameters. /// - public interface ITestLoggerWithParameters : ITestLogger - { - /// - /// Initializes the Test Logger with given parameters. - /// - /// Events that can be registered for. - /// Collection of parameters - void Initialize(TestLoggerEvents events, Dictionary parameters); - } + /// Events that can be registered for. + /// Collection of parameters + void Initialize(TestLoggerEvents events, Dictionary parameters); } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Logger/LoggerRunSettings.cs b/src/Microsoft.TestPlatform.ObjectModel/Logger/LoggerRunSettings.cs index dc543b3e45..96a36b7669 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Logger/LoggerRunSettings.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Logger/LoggerRunSettings.cs @@ -6,219 +6,219 @@ using System.Collections.ObjectModel; using System.Globalization; using System.Xml; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +/// +/// The logger run settings. +/// +public class LoggerRunSettings : TestRunSettings { + private readonly string _loggerRunSettingsName = string.Empty; + private readonly string _loggersSettingName = string.Empty; + private readonly string _loggerSettingName = string.Empty; + /// - /// The logger run settings. + /// Initializes a new instance of the class. /// - public class LoggerRunSettings : TestRunSettings + public LoggerRunSettings() : base(Constants.LoggerRunSettingsName) { - private string loggerRunSettingsName = string.Empty; - private string loggersSettingName = string.Empty; - private string loggerSettingName = string.Empty; - - /// - /// Initializes a new instance of the class. - /// - public LoggerRunSettings() : base(Constants.LoggerRunSettingsName) - { - this.LoggerSettingsList = new Collection(); - this.loggerRunSettingsName = Constants.LoggerRunSettingsName; - this.loggersSettingName = Constants.LoggersSettingName; - this.loggerSettingName = Constants.LoggerSettingName; - } + LoggerSettingsList = new Collection(); + _loggerRunSettingsName = Constants.LoggerRunSettingsName; + _loggersSettingName = Constants.LoggersSettingName; + _loggerSettingName = Constants.LoggerSettingName; + } - /// - /// Gets the logger settings list. - /// - public Collection LoggerSettingsList - { - get; - private set; - } + /// + /// Gets the logger settings list. + /// + public Collection LoggerSettingsList + { + get; + private set; + } #if !NETSTANDARD1_0 - public override XmlElement ToXml() - { - var doc = new XmlDocument(); - var root = doc.CreateElement(this.loggerRunSettingsName); - var subRoot = doc.CreateElement(this.loggersSettingName); - root.AppendChild(subRoot); - - foreach (var loggerSettings in this.LoggerSettingsList) - { - XmlNode child = doc.ImportNode(loggerSettings.ToXml(this.loggerSettingName), true); - subRoot.AppendChild(child); - } + public override XmlElement ToXml() + { + var doc = new XmlDocument(); + var root = doc.CreateElement(_loggerRunSettingsName); + var subRoot = doc.CreateElement(_loggersSettingName); + root.AppendChild(subRoot); - return root; + foreach (var loggerSettings in LoggerSettingsList) + { + XmlNode child = doc.ImportNode(loggerSettings.ToXml(_loggerSettingName), true); + subRoot.AppendChild(child); } + + return root; + } #endif - /// - /// The from xml. - /// - /// - /// The reader. - /// - /// - /// The . - /// - /// - /// Settings exception - /// - internal static LoggerRunSettings FromXml(XmlReader reader) - { - ValidateArg.NotNull(reader, nameof(reader)); + /// + /// The from xml. + /// + /// + /// The reader. + /// + /// + /// The . + /// + /// + /// Settings exception + /// + internal static LoggerRunSettings FromXml(XmlReader reader) + { + ValidateArg.NotNull(reader, nameof(reader)); - return FromXml(reader, - Constants.LoggersSettingName, - Constants.LoggerSettingName); - } + return FromXml(reader, + Constants.LoggersSettingName, + Constants.LoggerSettingName); + } - /// - /// The from xml. - /// - /// - /// The reader. - /// - /// - /// Loggers setting name. - /// - /// - /// Logger setting name. - /// - /// - /// The - /// - private static LoggerRunSettings FromXml(XmlReader reader, string loggersSettingName, string loggerSettingName) - { - // Validation. - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + /// + /// The from xml. + /// + /// + /// The reader. + /// + /// + /// Loggers setting name. + /// + /// + /// Logger setting name. + /// + /// + /// The + /// + private static LoggerRunSettings FromXml(XmlReader reader, string loggersSettingName, string loggerSettingName) + { + // Validation. + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - var elementName = reader.Name; - var empty = reader.IsEmptyElement; - var settings = new LoggerRunSettings(); + var elementName = reader.Name; + var empty = reader.IsEmptyElement; + var settings = new LoggerRunSettings(); - // Move to next node. - reader.Read(); + // Move to next node. + reader.Read(); - // Return empty settings if previous element empty. - if (empty) - { - return settings; - } + // Return empty settings if previous element empty. + if (empty) + { + return settings; + } - // Read inner nodes. - while (reader.NodeType == XmlNodeType.Element) + // Read inner nodes. + while (reader.NodeType == XmlNodeType.Element) + { + if (reader.Name.Equals(loggersSettingName, StringComparison.OrdinalIgnoreCase)) { - if (reader.Name.Equals(loggersSettingName, StringComparison.OrdinalIgnoreCase)) - { - var items = ReadListElementFromXml(reader, loggerSettingName); - foreach (var item in items) - { - settings.LoggerSettingsList.Add(item); - } - } - else + var items = ReadListElementFromXml(reader, loggerSettingName); + foreach (var item in items) { - throw new SettingsException( - string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsXmlElement, - elementName, - reader.Name)); + settings.LoggerSettingsList.Add(item); } } - reader.ReadEndElement(); - - return settings; + else + { + throw new SettingsException( + string.Format( + CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsXmlElement, + elementName, + reader.Name)); + } } + reader.ReadEndElement(); - /// - /// Reads logger settings list from runSettings - /// - /// - /// The reader. - /// - /// - /// Logger setting name. - /// - /// - /// LoggerSettings List - /// - private static List ReadListElementFromXml(XmlReader reader, string loggerSettingName) - { - // Validation. - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + return settings; + } + + /// + /// Reads logger settings list from runSettings + /// + /// + /// The reader. + /// + /// + /// Logger setting name. + /// + /// + /// LoggerSettings List + /// + private static List ReadListElementFromXml(XmlReader reader, string loggerSettingName) + { + // Validation. + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - var elementName = reader.Name; - var empty = reader.IsEmptyElement; - var settings = new List(); + var elementName = reader.Name; + var empty = reader.IsEmptyElement; + var settings = new List(); - // Move to next node - reader.Read(); + // Move to next node + reader.Read(); - // Return empty settings if previous element is empty. - if (empty) + // Return empty settings if previous element is empty. + if (empty) + { + return settings; + } + + // Read inner nodes. + while (reader.NodeType == XmlNodeType.Element) + { + if (reader.Name.Equals(loggerSettingName, StringComparison.OrdinalIgnoreCase)) { - return settings; + settings.Add(LoggerSettings.FromXml(reader)); } - - // Read inner nodes. - while (reader.NodeType == XmlNodeType.Element) + else { - if (reader.Name.Equals(loggerSettingName, StringComparison.OrdinalIgnoreCase)) - { - settings.Add(LoggerSettings.FromXml(reader)); - } - else - { - throw new SettingsException( - string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsXmlElement, - elementName, - reader.Name)); - } + throw new SettingsException( + string.Format( + CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsXmlElement, + elementName, + reader.Name)); } - - return settings; } - /// - /// Gets existing logger index. - /// - /// Logger settings. - /// Index of given logger settings. - public int GetExistingLoggerIndex(LoggerSettings loggerSettings) - { - var existingLoggerIndex = -1; + return settings; + } - for (int i = 0; i < LoggerSettingsList.Count; i++) - { - var logger = LoggerSettingsList[i]; + /// + /// Gets existing logger index. + /// + /// Logger settings. + /// Index of given logger settings. + public int GetExistingLoggerIndex(LoggerSettings loggerSettings) + { + var existingLoggerIndex = -1; - if (logger.FriendlyName != null && - loggerSettings.FriendlyName != null && - logger.FriendlyName.Equals(loggerSettings.FriendlyName, StringComparison.OrdinalIgnoreCase)) - { - existingLoggerIndex = i; - break; - } + for (int i = 0; i < LoggerSettingsList.Count; i++) + { + var logger = LoggerSettingsList[i]; - if (logger.Uri?.ToString() != null && - loggerSettings.Uri?.ToString() != null && - logger.Uri.ToString().Equals(loggerSettings.Uri.ToString(), StringComparison.OrdinalIgnoreCase)) - { - existingLoggerIndex = i; - break; - } + if (logger.FriendlyName != null && + loggerSettings.FriendlyName != null && + logger.FriendlyName.Equals(loggerSettings.FriendlyName, StringComparison.OrdinalIgnoreCase)) + { + existingLoggerIndex = i; + break; } - return existingLoggerIndex; + if (logger.Uri?.ToString() != null && + loggerSettings.Uri?.ToString() != null && + logger.Uri.ToString().Equals(loggerSettings.Uri.ToString(), StringComparison.OrdinalIgnoreCase)) + { + existingLoggerIndex = i; + break; + } } + + return existingLoggerIndex; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Logger/LoggerSettings.cs b/src/Microsoft.TestPlatform.ObjectModel/Logger/LoggerSettings.cs index a2e1fae963..6361bff4e9 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Logger/LoggerSettings.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Logger/LoggerSettings.cs @@ -1,235 +1,234 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; - using System.Globalization; - using System.Xml; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.Globalization; +using System.Xml; +/// +/// The logger settings. +/// +public class LoggerSettings +{ /// - /// The logger settings. + /// Gets or sets the uri. /// - public class LoggerSettings + public Uri Uri { - /// - /// Gets or sets the uri. - /// - public Uri Uri - { - get; - set; - } + get; + set; + } - /// - /// Gets or sets the assembly qualified name. - /// - public string AssemblyQualifiedName - { - get; - set; - } + /// + /// Gets or sets the assembly qualified name. + /// + public string AssemblyQualifiedName + { + get; + set; + } - /// - /// Gets or sets value CodeBase of logger DLL. The syntax is same as Code Base in AssemblyName class. - /// - public string CodeBase - { - get; - set; - } + /// + /// Gets or sets value CodeBase of logger DLL. The syntax is same as Code Base in AssemblyName class. + /// + public string CodeBase + { + get; + set; + } - /// - /// Gets or sets the friendly name. - /// - public string FriendlyName - { - get; - set; - } + /// + /// Gets or sets the friendly name. + /// + public string FriendlyName + { + get; + set; + } - /// - /// Gets or sets a value indicating whether is enabled. - /// - public bool IsEnabled - { - get; - set; - } + /// + /// Gets or sets a value indicating whether is enabled. + /// + public bool IsEnabled + { + get; + set; + } #if !NETSTANDARD1_0 - /// - /// Gets or sets the configuration. - /// - public XmlElement Configuration - { - get; - set; - } - - /// - /// The to xml. - /// - /// - /// The . - /// - public XmlElement ToXml() - { - return ToXml(Constants.LoggerSettingName); - } + /// + /// Gets or sets the configuration. + /// + public XmlElement Configuration + { + get; + set; + } - /// - /// The to xml. - /// - /// - /// The logger name. - /// - /// - /// The . - /// - public XmlElement ToXml(string loggerName) - { - var doc = new XmlDocument(); - var root = doc.CreateElement(loggerName); + /// + /// The to xml. + /// + /// + /// The . + /// + public XmlElement ToXml() + { + return ToXml(Constants.LoggerSettingName); + } - AppendAttribute(doc, root, Constants.LoggerFriendlyName, this.FriendlyName); - AppendAttribute(doc, root, Constants.LoggerUriName, this.Uri?.ToString()); - AppendAttribute(doc, root, Constants.LoggerAssemblyQualifiedName, this.AssemblyQualifiedName); - AppendAttribute(doc, root, Constants.LoggerCodeBase, this.CodeBase); - AppendAttribute(doc, root, Constants.LoggerEnabledName, this.IsEnabled.ToString()); + /// + /// The to xml. + /// + /// + /// The logger name. + /// + /// + /// The . + /// + public XmlElement ToXml(string loggerName) + { + var doc = new XmlDocument(); + var root = doc.CreateElement(loggerName); - if (Configuration != null) - { - root.AppendChild(doc.ImportNode(Configuration, true)); - } + AppendAttribute(doc, root, Constants.LoggerFriendlyName, FriendlyName); + AppendAttribute(doc, root, Constants.LoggerUriName, Uri?.ToString()); + AppendAttribute(doc, root, Constants.LoggerAssemblyQualifiedName, AssemblyQualifiedName); + AppendAttribute(doc, root, Constants.LoggerCodeBase, CodeBase); + AppendAttribute(doc, root, Constants.LoggerEnabledName, IsEnabled.ToString()); - return root; + if (Configuration != null) + { + root.AppendChild(doc.ImportNode(Configuration, true)); } - private static void AppendAttribute(XmlDocument doc, XmlElement owner, string attributeName, string attributeValue) - { - if (string.IsNullOrWhiteSpace(attributeValue)) - { - return; - } + return root; + } - XmlAttribute attribute = doc.CreateAttribute(attributeName); - attribute.Value = attributeValue; - owner.Attributes.Append(attribute); + private static void AppendAttribute(XmlDocument doc, XmlElement owner, string attributeName, string attributeValue) + { + if (string.IsNullOrWhiteSpace(attributeValue)) + { + return; } + + XmlAttribute attribute = doc.CreateAttribute(attributeName); + attribute.Value = attributeValue; + owner.Attributes.Append(attribute); + } #endif - internal static LoggerSettings FromXml(XmlReader reader) + internal static LoggerSettings FromXml(XmlReader reader) + { + var elementName = reader.Name; + var empty = reader.IsEmptyElement; + var settings = new LoggerSettings { - var elementName = reader.Name; - var empty = reader.IsEmptyElement; - var settings = new LoggerSettings - { - IsEnabled = true - }; + IsEnabled = true + }; - // Read attributes. - if (reader.HasAttributes) + // Read attributes. + if (reader.HasAttributes) + { + while (reader.MoveToNextAttribute()) { - while (reader.MoveToNextAttribute()) + switch (reader.Name.ToLowerInvariant()) { - switch (reader.Name.ToLowerInvariant()) - { - case Constants.LoggerFriendlyNameLower: - settings.FriendlyName = reader.Value; - break; - - case Constants.LoggerUriName: - try - { - settings.Uri = new Uri(reader.Value); - } + case Constants.LoggerFriendlyNameLower: + settings.FriendlyName = reader.Value; + break; + + case Constants.LoggerUriName: + try + { + settings.Uri = new Uri(reader.Value); + } #if NETSTANDARD1_0 - catch + catch #else - catch (UriFormatException) + catch (UriFormatException) #endif - { - throw new SettingsException( - string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.InvalidUriInSettings, - reader.Value, - elementName)); - } - break; - - case Constants.LoggerAssemblyQualifiedNameLower: - settings.AssemblyQualifiedName = reader.Value; - break; - - case Constants.LoggerCodeBaseLower: - settings.CodeBase = reader.Value; - break; - - case Constants.LoggerEnabledName: - bool.TryParse(reader.Value, out var value); - settings.IsEnabled = value; - break; - - default: + { throw new SettingsException( string.Format( CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsXmlAttribute, - elementName, - reader.Name)); - } - } - } - - // Check for required attributes. - if (string.IsNullOrWhiteSpace(settings.FriendlyName) && - string.IsNullOrWhiteSpace(settings.Uri?.ToString()) && - string.IsNullOrWhiteSpace(settings.AssemblyQualifiedName)) - { - throw new SettingsException( - string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.MissingLoggerAttributes, - elementName, - Constants.LoggerFriendlyName)); - } + Resources.Resources.InvalidUriInSettings, + reader.Value, + elementName)); + } + break; - // Move to next node. - reader.Read(); + case Constants.LoggerAssemblyQualifiedNameLower: + settings.AssemblyQualifiedName = reader.Value; + break; - // Return empty settings if previous element is empty. - if (empty) - { - return settings; - } + case Constants.LoggerCodeBaseLower: + settings.CodeBase = reader.Value; + break; - // Read inner elements. - while (reader.NodeType == XmlNodeType.Element) - { - switch (reader.Name.ToLowerInvariant()) - { -#if !NETSTANDARD1_0 - case Constants.LoggerConfigurationNameLower: - var document = new XmlDocument(); - var element = document.CreateElement(reader.Name); - element.InnerXml = reader.ReadInnerXml(); - settings.Configuration = element; + case Constants.LoggerEnabledName: + bool.TryParse(reader.Value, out var value); + settings.IsEnabled = value; break; -#endif + default: throw new SettingsException( string.Format( CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsXmlElement, + Resources.Resources.InvalidSettingsXmlAttribute, elementName, reader.Name)); } } - reader.ReadEndElement(); + } + // Check for required attributes. + if (string.IsNullOrWhiteSpace(settings.FriendlyName) && + string.IsNullOrWhiteSpace(settings.Uri?.ToString()) && + string.IsNullOrWhiteSpace(settings.AssemblyQualifiedName)) + { + throw new SettingsException( + string.Format( + CultureInfo.CurrentCulture, + Resources.Resources.MissingLoggerAttributes, + elementName, + Constants.LoggerFriendlyName)); + } + + // Move to next node. + reader.Read(); + + // Return empty settings if previous element is empty. + if (empty) + { return settings; } + + // Read inner elements. + while (reader.NodeType == XmlNodeType.Element) + { + switch (reader.Name.ToLowerInvariant()) + { +#if !NETSTANDARD1_0 + case Constants.LoggerConfigurationNameLower: + var document = new XmlDocument(); + var element = document.CreateElement(reader.Name); + element.InnerXml = reader.ReadInnerXml(); + settings.Configuration = element; + break; +#endif + default: + throw new SettingsException( + string.Format( + CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsXmlElement, + elementName, + reader.Name)); + } + } + reader.ReadEndElement(); + + return settings; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Logger/TestLoggerEvents.cs b/src/Microsoft.TestPlatform.ObjectModel/Logger/TestLoggerEvents.cs index c544ae418e..efedc78a28 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Logger/TestLoggerEvents.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Logger/TestLoggerEvents.cs @@ -1,69 +1,69 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using System; + +using Logging; + +/// +/// Exposes events that Test Loggers can register for. +/// +public abstract class TestLoggerEvents { - using System; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + #region Constructor /// - /// Exposes events that Test Loggers can register for. + /// Default constructor. /// - public abstract class TestLoggerEvents + protected TestLoggerEvents() { - #region Constructor - - /// - /// Default constructor. - /// - protected TestLoggerEvents() - { - } - - #endregion - - #region Events - - /// - /// Raised when a test message is received. - /// - public abstract event EventHandler TestRunMessage; - - /// - /// Raised when a test run starts. - /// - public abstract event EventHandler TestRunStart; - - /// - /// Raised when a test result is received. - /// - public abstract event EventHandler TestResult; - - /// - /// Raised when a test run is complete. - /// - public abstract event EventHandler TestRunComplete; - - /// - /// Raised when test discovery starts - /// - public abstract event EventHandler DiscoveryStart; - - /// - /// Raised when a discovery message is received. - /// - public abstract event EventHandler DiscoveryMessage; - - /// - /// Raised when discovered tests are received - /// - public abstract event EventHandler DiscoveredTests; - - /// - /// Raised when test discovery is complete - /// - public abstract event EventHandler DiscoveryComplete; - - #endregion } -} + + #endregion + + #region Events + + /// + /// Raised when a test message is received. + /// + public abstract event EventHandler TestRunMessage; + + /// + /// Raised when a test run starts. + /// + public abstract event EventHandler TestRunStart; + + /// + /// Raised when a test result is received. + /// + public abstract event EventHandler TestResult; + + /// + /// Raised when a test run is complete. + /// + public abstract event EventHandler TestRunComplete; + + /// + /// Raised when test discovery starts + /// + public abstract event EventHandler DiscoveryStart; + + /// + /// Raised when a discovery message is received. + /// + public abstract event EventHandler DiscoveryMessage; + + /// + /// Raised when discovered tests are received + /// + public abstract event EventHandler DiscoveredTests; + + /// + /// Raised when test discovery is complete + /// + public abstract event EventHandler DiscoveryComplete; + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Logging/Events/DataCollectionMessageEventArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/Logging/Events/DataCollectionMessageEventArgs.cs index d5332da80b..924b79effe 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Logging/Events/DataCollectionMessageEventArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Logging/Events/DataCollectionMessageEventArgs.cs @@ -1,61 +1,60 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +using System; +using System.Runtime.Serialization; + +/// +/// EventArg used for raising data collector message event. +/// +[DataContract] +public class DataCollectionMessageEventArgs : TestRunMessageEventArgs { - using System; - using System.Runtime.Serialization; + #region Constructor + /// + /// Constructor + /// + /// Level at which message should be logged. + /// Text message. + public DataCollectionMessageEventArgs(TestMessageLevel level, string message) : base(level, message) + { + } + #endregion + + #region Properties /// - /// EventArg used for raising data collector message event. + /// Friendly name of collector /// - [DataContract] - public class DataCollectionMessageEventArgs : TestRunMessageEventArgs + [DataMember] + public string FriendlyName { - #region Constructor - /// - /// Constructor - /// - /// Level at which message should be logged. - /// Text message. - public DataCollectionMessageEventArgs(TestMessageLevel level, string message) : base(level, message) - { - } - #endregion - - #region Properties - - /// - /// Friendly name of collector - /// - [DataMember] - public string FriendlyName - { - get; - set; - } - - - /// - /// Uri of collector. - /// - [DataMember] - public Uri Uri - { - get; - set; - } - - /// - /// Test case id if the message is generated by test case collection. - /// - [DataMember] - public Guid TestCaseId - { - get; - set; - } - - #endregion + get; + set; } -} + + + /// + /// Uri of collector. + /// + [DataMember] + public Uri Uri + { + get; + set; + } + + /// + /// Test case id if the message is generated by test case collection. + /// + [DataMember] + public Guid TestCaseId + { + get; + set; + } + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Logging/Events/TestResultEventArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/Logging/Events/TestResultEventArgs.cs index 9d125592f6..e0cef57fb9 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Logging/Events/TestResultEventArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Logging/Events/TestResultEventArgs.cs @@ -1,37 +1,36 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +using System; + +/// +/// Event arguments used for raising Test Result events. +/// +public class TestResultEventArgs : EventArgs { - using System; + #region Constructor /// - /// Event arguments used for raising Test Result events. + /// Initializes a new instance of the class. /// - public class TestResultEventArgs : EventArgs + /// + /// Test Result for the event. + /// + public TestResultEventArgs(TestResult result) { - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - /// - /// Test Result for the event. - /// - public TestResultEventArgs(TestResult result) - { - this.Result = result ?? throw new ArgumentNullException(nameof(result)); - } + Result = result ?? throw new ArgumentNullException(nameof(result)); + } - #endregion + #endregion - #region Properties + #region Properties - /// - /// Gets the Test Result. - /// - public TestResult Result { get; private set; } + /// + /// Gets the Test Result. + /// + public TestResult Result { get; private set; } - #endregion - } -} + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Logging/Events/TestRunMessageEventArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/Logging/Events/TestRunMessageEventArgs.cs index e9d4c4e511..d2ced46829 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Logging/Events/TestRunMessageEventArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Logging/Events/TestRunMessageEventArgs.cs @@ -1,58 +1,57 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging -{ - using System; - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +using System; +using System.Runtime.Serialization; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources; +using Resources; + +/// +/// Event arguments used for raising Test Run Message events. +/// +[DataContract] +public class TestRunMessageEventArgs : EventArgs +{ + #region Constructor /// - /// Event arguments used for raising Test Run Message events. + /// Initializes with the level and the message for the event. /// - [DataContract] - public class TestRunMessageEventArgs : EventArgs + /// Level of the message. + /// The message. + public TestRunMessageEventArgs(TestMessageLevel level, string message) { - #region Constructor - - /// - /// Initializes with the level and the message for the event. - /// - /// Level of the message. - /// The message. - public TestRunMessageEventArgs(TestMessageLevel level, string message) + if (string.IsNullOrWhiteSpace(message)) + { + throw new ArgumentException(CommonResources.CannotBeNullOrEmpty, nameof(message)); + } + + if (level < TestMessageLevel.Informational || level > TestMessageLevel.Error) { - if (string.IsNullOrWhiteSpace(message)) - { - throw new ArgumentException(CommonResources.CannotBeNullOrEmpty, nameof(message)); - } - - if (level < TestMessageLevel.Informational || level > TestMessageLevel.Error) - { - throw new ArgumentOutOfRangeException(nameof(level)); - } - - Level = level; - Message = message; + throw new ArgumentOutOfRangeException(nameof(level)); } - #endregion + Level = level; + Message = message; + } - #region Properties + #endregion - /// - /// The message. - /// - [DataMember] - public string Message { get; set; } + #region Properties - /// - /// Level of the message. - /// - [DataMember] - public TestMessageLevel Level { get; set; } + /// + /// The message. + /// + [DataMember] + public string Message { get; set; } - #endregion - } -} + /// + /// Level of the message. + /// + [DataMember] + public TestMessageLevel Level { get; set; } + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Logging/Events/TestRunStartedEventArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/Logging/Events/TestRunStartedEventArgs.cs index d612d47b68..045d807341 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Logging/Events/TestRunStartedEventArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Logging/Events/TestRunStartedEventArgs.cs @@ -1,27 +1,26 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +using System; + +/// +/// Event arguments used for raising TestRunStarted events. +/// Mainly contains the process Id of the test execution process running the tests. +/// +public class TestRunStartedEventArgs : EventArgs { - using System; + public int ProcessId { get; private set; } - /// - /// Event arguments used for raising TestRunStarted events. - /// Mainly contains the process Id of the test execution process running the tests. - /// - public class TestRunStartedEventArgs : EventArgs + /// The process Id of the test execution process running the tests. + public TestRunStartedEventArgs(int processId) { - public int ProcessId { get; private set; } - - /// The process Id of the test execution process running the tests. - public TestRunStartedEventArgs(int processId) - { - ProcessId = processId; - } + ProcessId = processId; + } - public override string ToString() - { - return "ProcessId = " + ProcessId; - } + public override string ToString() + { + return "ProcessId = " + ProcessId; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Logging/Interfaces/IMessageLogger.cs b/src/Microsoft.TestPlatform.ObjectModel/Logging/Interfaces/IMessageLogger.cs index c9028c09f9..f4fb5d68b4 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Logging/Interfaces/IMessageLogger.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Logging/Interfaces/IMessageLogger.cs @@ -1,19 +1,18 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +/// +/// Used for logging error warning and informational messages. +/// +public interface IMessageLogger { /// - /// Used for logging error warning and informational messages. + /// Sends a message to the enabled loggers. /// - public interface IMessageLogger - { - /// - /// Sends a message to the enabled loggers. - /// - /// Level of the message. - /// The message to be sent. - void SendMessage(TestMessageLevel testMessageLevel, string message); + /// Level of the message. + /// The message to be sent. + void SendMessage(TestMessageLevel testMessageLevel, string message); - } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Logging/TestMessageLevel.cs b/src/Microsoft.TestPlatform.ObjectModel/Logging/TestMessageLevel.cs index 0b0cd6d004..3443650ef9 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Logging/TestMessageLevel.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Logging/TestMessageLevel.cs @@ -1,26 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +/// +/// Levels for test messages. +/// +public enum TestMessageLevel { /// - /// Levels for test messages. + /// Informational message. /// - public enum TestMessageLevel - { - /// - /// Informational message. - /// - Informational = 0, + Informational = 0, - /// - /// Warning message. - /// - Warning = 1, + /// + /// Warning message. + /// + Warning = 1, - /// - /// Error message. - /// - Error = 2 - } -} + /// + /// Error message. + /// + Error = 2 +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Navigation/DiaNavigationData.cs b/src/Microsoft.TestPlatform.ObjectModel/Navigation/DiaNavigationData.cs index 0752a50ef5..4f87c078c6 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Navigation/DiaNavigationData.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Navigation/DiaNavigationData.cs @@ -1,29 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; - using System.Diagnostics.CodeAnalysis; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Navigation; +using Navigation; - /// - /// A struct that stores the information needed by the navigation: file name, line number, column number. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Justification = "Dia is a specific name.")] - public class DiaNavigationData : INavigationData - { - public string FileName { get; set; } +/// +/// A struct that stores the information needed by the navigation: file name, line number, column number. +/// +public class DiaNavigationData : INavigationData +{ + public string FileName { get; set; } - public int MinLineNumber { get; set; } + public int MinLineNumber { get; set; } - public int MaxLineNumber { get; set; } + public int MaxLineNumber { get; set; } - public DiaNavigationData(string fileName, int minLineNumber, int maxLineNumber) - { - this.FileName = fileName; - this.MinLineNumber = minLineNumber; - this.MaxLineNumber = maxLineNumber; - } + public DiaNavigationData(string fileName, int minLineNumber, int maxLineNumber) + { + FileName = fileName; + MinLineNumber = minLineNumber; + MaxLineNumber = maxLineNumber; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Navigation/DiaSession.cs b/src/Microsoft.TestPlatform.ObjectModel/Navigation/DiaSession.cs index 469063eaf2..53120e45e6 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Navigation/DiaSession.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Navigation/DiaSession.cs @@ -1,113 +1,110 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System.Diagnostics.CodeAnalysis; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Navigation; +using System.IO; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; + +/// +/// The class that enables us to get debug information from both managed and native binaries. +/// +[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", + Justification = "Dia is a specific name.")] +public class DiaSession : INavigationSession { - using System.Diagnostics.CodeAnalysis; + /// + /// Characters that should be stripped off the end of test names. + /// + private static readonly char[] TestNameStripChars = { '(', ')', ' ' }; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Navigation; - using System.IO; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; + /// + /// The symbol reader. + /// + private readonly ISymbolReader _symbolReader; /// - /// The class that enables us to get debug information from both managed and native binaries. + /// Initializes a new instance of the class. /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", - Justification = "Dia is a specific name.")] - public class DiaSession : INavigationSession + /// + /// The binary path. + /// + public DiaSession(string binaryPath) + : this(binaryPath, null) { - /// - /// Characters that should be stripped off the end of test names. - /// - private static readonly char[] TestNameStripChars = { '(', ')', ' ' }; + } - /// - /// The symbol reader. - /// - private readonly ISymbolReader symbolReader; + /// + /// Initializes a new instance of the class. + /// + /// + /// The binary path is assembly path Ex: \path\to\bin\Debug\simpleproject.dll + /// + /// + /// search path. + /// + public DiaSession(string binaryPath, string searchPath) + : this(binaryPath, searchPath, GetSymbolReader(binaryPath)) + { + } - /// - /// Initializes a new instance of the class. - /// - /// - /// The binary path. - /// - public DiaSession(string binaryPath) - : this(binaryPath, null) - { - } + internal DiaSession(string binaryPath, string searchPath, ISymbolReader symbolReader) + { + _symbolReader = symbolReader; + ValidateArg.NotNullOrEmpty(binaryPath, nameof(binaryPath)); + _symbolReader.CacheSymbols(binaryPath, searchPath); + } - /// - /// Initializes a new instance of the class. - /// - /// - /// The binary path is assembly path Ex: \path\to\bin\Debug\simpleproject.dll - /// - /// - /// search path. - /// - public DiaSession(string binaryPath, string searchPath) - : this(binaryPath, searchPath, GetSymbolReader(binaryPath)) - { - } + /// + /// Dispose symbol reader + /// + public void Dispose() + { + _symbolReader?.Dispose(); + } - internal DiaSession(string binaryPath, string searchPath, ISymbolReader symbolReader) - { - this.symbolReader = symbolReader; - ValidateArg.NotNullOrEmpty(binaryPath, nameof(binaryPath)); - this.symbolReader.CacheSymbols(binaryPath, searchPath); - } + /// + /// Gets the navigation data for a method declared in a type. + /// + /// The declaring type name. + /// The method name. + /// The for that method. + /// Leaving this method in place to preserve back compatibility. + public DiaNavigationData GetNavigationData(string declaringTypeName, string methodName) + { + return (DiaNavigationData)GetNavigationDataForMethod(declaringTypeName, methodName); + } - /// - /// Dispose symbol reader - /// - public void Dispose() - { - this.symbolReader?.Dispose(); - } + /// + /// Gets the navigation data for a method declared in a type. + /// + /// The declaring type name. + /// The method name. + /// The for that method. + public INavigationData GetNavigationDataForMethod(string declaringTypeName, string methodName) + { + ValidateArg.NotNullOrEmpty(declaringTypeName, nameof(declaringTypeName)); + ValidateArg.NotNullOrEmpty(methodName, nameof(methodName)); + methodName = methodName.TrimEnd(TestNameStripChars); + return _symbolReader.GetNavigationData(declaringTypeName, methodName); + } - /// - /// Gets the navigation data for a method declared in a type. - /// - /// The declaring type name. - /// The method name. - /// The for that method. - /// Leaving this method in place to preserve back compatibility. - public DiaNavigationData GetNavigationData(string declaringTypeName, string methodName) - { - return (DiaNavigationData)this.GetNavigationDataForMethod(declaringTypeName, methodName); - } + private static ISymbolReader GetSymbolReader(string binaryPath) + { + var pdbFilePath = Path.ChangeExtension(binaryPath, ".pdb"); - /// - /// Gets the navigation data for a method declared in a type. - /// - /// The declaring type name. - /// The method name. - /// The for that method. - public INavigationData GetNavigationDataForMethod(string declaringTypeName, string methodName) + // For remote scenario, also look for pdb in current directory, (esp for UWP) + // The alternate search path should be an input from Adapters, but since it is not so currently adding a HACK + pdbFilePath = !File.Exists(pdbFilePath) ? Path.Combine(Directory.GetCurrentDirectory(), Path.GetFileName(pdbFilePath)) : pdbFilePath; + using var stream = new FileHelper().GetStream(pdbFilePath, FileMode.Open, FileAccess.Read); + if (PortablePdbReader.IsPortable(stream)) { - ValidateArg.NotNullOrEmpty(declaringTypeName, nameof(declaringTypeName)); - ValidateArg.NotNullOrEmpty(methodName, nameof(methodName)); - methodName = methodName.TrimEnd(TestNameStripChars); - return this.symbolReader.GetNavigationData(declaringTypeName, methodName); + return new PortableSymbolReader(); } - private static ISymbolReader GetSymbolReader(string binaryPath) - { - var pdbFilePath = Path.ChangeExtension(binaryPath, ".pdb"); - - // For remote scenario, also look for pdb in current directory, (esp for UWP) - // The alternate search path should be an input from Adapters, but since it is not so currently adding a HACK - pdbFilePath = !File.Exists(pdbFilePath) ? Path.Combine(Directory.GetCurrentDirectory(), Path.GetFileName(pdbFilePath)) : pdbFilePath; - using (var stream = new FileHelper().GetStream(pdbFilePath, FileMode.Open, FileAccess.Read)) - { - if (PortablePdbReader.IsPortable(stream)) - { - return new PortableSymbolReader(); - } - - return new FullSymbolReader(); - } - } + return new FullSymbolReader(); } -} \ No newline at end of file +} diff --git a/src/Microsoft.TestPlatform.ObjectModel/Navigation/FullSymbolReader.cs b/src/Microsoft.TestPlatform.ObjectModel/Navigation/FullSymbolReader.cs index ea90a03b6f..dc8bdade65 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Navigation/FullSymbolReader.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Navigation/FullSymbolReader.cs @@ -1,516 +1,514 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Navigation +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Navigation; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; + +/// +/// To get method's file name, startline and endline from desktop assembly file. +/// +internal class FullSymbolReader : ISymbolReader { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.IO; - using System.Runtime.InteropServices; + /// + /// To check isDisposed + /// + private bool _isDisposed; + + private IDiaDataSource _source; + private IDiaSession _session; /// - /// To get method's file name, startline and endline from desktop assembly file. + /// Holds type symbols available in the source. /// - internal class FullSymbolReader : ISymbolReader + private Dictionary _typeSymbols = new(); + + /// + /// Holds method symbols for all types in the source. + /// Methods in different types can have same name, hence separated dictionary is created for each type. + /// Bug: Method overrides in same type are not handled (not a regression) + /// ToDo(Solution): Use method token along with as identifier, this will always give unique method.The adapters would need to send this token to us to correct the behavior. + /// + private Dictionary> _methodSymbols = new(); + + /// + /// dispose caches + /// + public void Dispose() { - /// - /// To check isDisposed - /// - private bool isDisposed; - - private IDiaDataSource source; - private IDiaSession session; - - /// - /// Holds type symbols available in the source. - /// - private Dictionary typeSymbols = new Dictionary(); - - /// - /// Holds method symbols for all types in the source. - /// Methods in different types can have same name, hence separated dictionary is created for each type. - /// Bug: Method overrides in same type are not handled (not a regression) - /// ToDo(Solution): Use method token along with as identifier, this will always give unique method.The adapters would need to send this token to us to correct the behavior. - /// - private Dictionary> methodSymbols = new Dictionary>(); - - /// - /// dispose caches - /// - public void Dispose() - { - this.Dispose(true); + Dispose(true); - // Use SupressFinalize in case a subclass - // of this type implements a finalizer. - GC.SuppressFinalize(this); - } + // Use SupressFinalize in case a subclass + // of this type implements a finalizer. + GC.SuppressFinalize(this); + } - /// - /// Cache symbols from binary path - /// - /// - /// The binary path is assembly path Ex: \path\to\bin\Debug\simpleproject.dll - /// - /// - /// search path. - /// - public void CacheSymbols(string binaryPath, string searchPath) + /// + /// Cache symbols from binary path + /// + /// + /// The binary path is assembly path Ex: \path\to\bin\Debug\simpleproject.dll + /// + /// + /// search path. + /// + public void CacheSymbols(string binaryPath, string searchPath) + { + try { - try - { - if(OpenSession(binaryPath, searchPath)) - { - this.PopulateCacheForTypeAndMethodSymbols(); - } - } - catch (COMException) + if (OpenSession(binaryPath, searchPath)) { - this.Dispose(); - throw; + PopulateCacheForTypeAndMethodSymbols(); } } + catch (COMException) + { + Dispose(); + throw; + } + } + + /// + /// Gets Navigation data from caches + /// + /// + /// Type name Ex: MyNameSpace.MyType + /// + /// + /// Method name in declaringTypeName Ex: Method1 + /// + /// + /// . + /// Returns INavigationData which contains filename and line number. + /// + public INavigationData GetNavigationData(string declaringTypeName, string methodName) + { + INavigationData navigationData = null; + IDiaSymbol typeSymbol = GetTypeSymbol(declaringTypeName, SymTagEnum.SymTagCompiland); + IDiaSymbol methodSymbol; + if (typeSymbol != null) + { + methodSymbol = GetMethodSymbol(typeSymbol, methodName); + } + else + { + // May be a managed C++ test assembly... + string fullMethodName = declaringTypeName.Replace(".", "::"); + fullMethodName = fullMethodName + "::" + methodName; - /// - /// Gets Navigation data from caches - /// - /// - /// Type name Ex: MyNameSpace.MyType - /// - /// - /// Method name in declaringTypeName Ex: Method1 - /// - /// - /// . - /// Returns INavigationData which contains filename and line number. - /// - public INavigationData GetNavigationData(string declaringTypeName, string methodName) + methodSymbol = GetTypeSymbol(fullMethodName, SymTagEnum.SymTagFunction); + } + + if (methodSymbol != null) { - INavigationData navigationData = null; - IDiaSymbol methodSymbol = null; + navigationData = GetSymbolNavigationData(methodSymbol); + } - IDiaSymbol typeSymbol = this.GetTypeSymbol(declaringTypeName, SymTagEnum.SymTagCompiland); - if (typeSymbol != null) + return navigationData; + } + + private bool OpenSession(string filename, string searchPath) + { + try + { + // Activate the DIA data source COM object + _source = DiaSourceObject.GetDiaSourceObject(); + + if (_source == null) { - methodSymbol = this.GetMethodSymbol(typeSymbol, methodName); + return false; } - else - { - // May be a managed C++ test assembly... - string fullMethodName = declaringTypeName.Replace(".", "::"); - fullMethodName = fullMethodName + "::" + methodName; - methodSymbol = this.GetTypeSymbol(fullMethodName, SymTagEnum.SymTagFunction); + // UWP(App model) scenario + if (!Path.IsPathRooted(filename)) + { + filename = Path.Combine(Directory.GetCurrentDirectory(), filename); + if (string.IsNullOrEmpty(searchPath)) + { + searchPath = Directory.GetCurrentDirectory(); + } } - if (methodSymbol != null) + // Load the data for the executable + int hResult = _source.LoadDataForExe(filename, searchPath, IntPtr.Zero); + if (HResult.Failed(hResult)) { - navigationData = this.GetSymbolNavigationData(methodSymbol); + throw new COMException(string.Format(Resources.Resources.FailedToCreateDiaSession, hResult)); } - return navigationData; + // Open the session and return it + if (HResult.Failed(_source.OpenSession(out _session))) + { + return false; + } } - - private bool OpenSession(string filename, string searchPath) + catch (COMException) + { + throw; + } + finally { - try + if (_source != null) { - // Activate the DIA data source COM object - this.source = DiaSourceObject.GetDiaSourceObject(); + Marshal.FinalReleaseComObject(_source); + } + } - if (this.source == null) - { - return false; - } + return true; + } - // UWP(App model) scenario - if (!Path.IsPathRooted(filename)) - { - filename = Path.Combine(Directory.GetCurrentDirectory(), filename); - if (string.IsNullOrEmpty(searchPath)) - { - searchPath = Directory.GetCurrentDirectory(); - } - } + private DiaNavigationData GetSymbolNavigationData(IDiaSymbol symbol) + { + ValidateArg.NotNull(symbol, nameof(symbol)); - // Load the data for the executable - int hResult = this.source.LoadDataForExe(filename, searchPath, IntPtr.Zero); - if (HResult.Failed(hResult)) - { - throw new COMException(string.Format(Resources.Resources.FailedToCreateDiaSession, hResult)); - } + DiaNavigationData navigationData = new(null, int.MaxValue, int.MinValue); - // Open the session and return it - if (HResult.Failed(this.source.OpenSession(out this.session))) - { - return false; - } - } - catch (COMException) + IDiaEnumLineNumbers lines = null; + + try + { + // Get the address section + if (HResult.Failed(symbol.GetAddressSection(out uint section))) { - throw; + return navigationData; } - finally + + // Get the address offset + if (HResult.Failed(symbol.GetAddressOffset(out uint offset))) { - if (this.source != null) - { - Marshal.FinalReleaseComObject(this.source); - } + return navigationData; } - return true; - } - - private DiaNavigationData GetSymbolNavigationData(IDiaSymbol symbol) - { - ValidateArg.NotNull(symbol, nameof(symbol)); - - DiaNavigationData navigationData = new DiaNavigationData(null, int.MaxValue, int.MinValue); + // Get the length of the symbol + if (HResult.Failed(symbol.GetLength(out long length))) + { + return navigationData; + } - IDiaEnumLineNumbers lines = null; + _session.FindLinesByAddress(section, offset, (uint)length, out lines); - try + while (true) { - // Get the address section - if (HResult.Failed(symbol.GetAddressSection(out uint section))) - { - return navigationData; - } + lines.GetNext(1, out IDiaLineNumber lineNumber, out uint celt); - // Get the address offset - if (HResult.Failed(symbol.GetAddressOffset(out uint offset))) + if (celt != 1) { - return navigationData; + break; } - // Get the length of the symbol - if (HResult.Failed(symbol.GetLength(out long length))) + IDiaSourceFile sourceFile = null; + try { - return navigationData; - } + lineNumber.GetSourceFile(out sourceFile); - this.session.FindLinesByAddress(section, offset, (uint)length, out lines); + // Get startline + lineNumber.GetLineNumber(out uint startLine); - while (true) - { - lines.GetNext(1, out IDiaLineNumber lineNumber, out uint celt); + // Get endline + lineNumber.GetLineNumberEnd(out uint endLine); - if (celt != 1) + // The magic hex constant below works around weird data reported from GetSequencePoints. + // The constant comes from ILDASM's source code, which performs essentially the same test. + const uint magic = 0xFEEFEE; + if (startLine >= magic || endLine >= magic) { - break; + continue; } - IDiaSourceFile sourceFile = null; - try - { - lineNumber.GetSourceFile(out sourceFile); - - // Get startline - lineNumber.GetLineNumber(out uint startLine); + sourceFile.GetFilename(out var srcFileName); - // Get endline - lineNumber.GetLineNumberEnd(out uint endLine); - - // The magic hex constant below works around weird data reported from GetSequencePoints. - // The constant comes from ILDASM's source code, which performs essentially the same test. - const uint Magic = 0xFEEFEE; - if (startLine >= Magic || endLine >= Magic) - { - continue; - } - - sourceFile.GetFilename(out var srcFileName); - - navigationData.FileName = srcFileName; - navigationData.MinLineNumber = Math.Min(navigationData.MinLineNumber, (int)startLine); - navigationData.MaxLineNumber = Math.Max(navigationData.MaxLineNumber, (int)endLine); - } - finally - { - ReleaseComObject(ref sourceFile); - ReleaseComObject(ref lineNumber); - } + navigationData.FileName = srcFileName; + navigationData.MinLineNumber = Math.Min(navigationData.MinLineNumber, (int)startLine); + navigationData.MaxLineNumber = Math.Max(navigationData.MaxLineNumber, (int)endLine); + } + finally + { + ReleaseComObject(ref sourceFile); + ReleaseComObject(ref lineNumber); } } - finally - { - ReleaseComObject(ref lines); - } - - return navigationData; + } + finally + { + ReleaseComObject(ref lines); } - private void PopulateCacheForTypeAndMethodSymbols() + return navigationData; + } + + private void PopulateCacheForTypeAndMethodSymbols() + { + IDiaEnumSymbols enumTypeSymbols = null; + IDiaSymbol global = null; + try { - IDiaEnumSymbols enumTypeSymbols = null; - IDiaSymbol global = null; - try + _session.GetGlobalScope(out global); + global.FindChildren(SymTagEnum.SymTagCompiland, null, 0, out enumTypeSymbols); + + // NOTE:: + // If foreach loop is used instead of Enumerator iterator, for some reason it leaves + // the reference to pdb active, which prevents pdb from being rebuilt (in VS IDE scenario). + enumTypeSymbols.GetNext(1, out IDiaSymbol typeSymbol, out uint celtTypeSymbol); + while (celtTypeSymbol == 1 && typeSymbol != null) { - this.session.GetGlobalScope(out global); - global.FindChildren(SymTagEnum.SymTagCompiland, null, 0, out enumTypeSymbols); - - // NOTE:: - // If foreach loop is used instead of Enumerator iterator, for some reason it leaves - // the reference to pdb active, which prevents pdb from being rebuilt (in VS IDE scenario). - enumTypeSymbols.GetNext(1, out IDiaSymbol typeSymbol, out uint celtTypeSymbol); - while (celtTypeSymbol == 1 && typeSymbol != null) - { - typeSymbol.GetName(out var name); - this.typeSymbols[name] = typeSymbol; - - IDiaEnumSymbols enumMethodSymbols = null; - try - { - Dictionary methodSymbolsForType = new Dictionary(); - typeSymbol.FindChildren(SymTagEnum.SymTagFunction, null, 0, out enumMethodSymbols); + typeSymbol.GetName(out var name); + _typeSymbols[name] = typeSymbol; - enumMethodSymbols.GetNext(1, out IDiaSymbol methodSymbol, out uint celtMethodSymbol); - while (celtMethodSymbol == 1 && methodSymbol != null) - { - methodSymbol.GetName(out var methodName); - UpdateMethodSymbolCache(methodName, methodSymbol, methodSymbolsForType); - enumMethodSymbols.GetNext(1, out methodSymbol, out celtMethodSymbol); - } + IDiaEnumSymbols enumMethodSymbols = null; + try + { + Dictionary methodSymbolsForType = new(); + typeSymbol.FindChildren(SymTagEnum.SymTagFunction, null, 0, out enumMethodSymbols); - this.methodSymbols[name] = methodSymbolsForType; - } - catch (Exception ex) + enumMethodSymbols.GetNext(1, out IDiaSymbol methodSymbol, out uint celtMethodSymbol); + while (celtMethodSymbol == 1 && methodSymbol != null) { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error( - "Ignoring the exception while iterating method symbols:{0} for type:{1}", - ex, - name); - } + methodSymbol.GetName(out var methodName); + UpdateMethodSymbolCache(methodName, methodSymbol, methodSymbolsForType); + enumMethodSymbols.GetNext(1, out methodSymbol, out celtMethodSymbol); } - finally + + _methodSymbols[name] = methodSymbolsForType; + } + catch (Exception ex) + { + if (EqtTrace.IsErrorEnabled) { - ReleaseComObject(ref enumMethodSymbols); + EqtTrace.Error( + "Ignoring the exception while iterating method symbols:{0} for type:{1}", + ex, + name); } - - enumTypeSymbols.GetNext(1, out typeSymbol, out celtTypeSymbol); } - } - catch (Exception ex) - { - if (EqtTrace.IsErrorEnabled) + finally { - EqtTrace.Error("Ignoring the exception while iterating type symbols:{0}", ex); + ReleaseComObject(ref enumMethodSymbols); } + + enumTypeSymbols.GetNext(1, out typeSymbol, out celtTypeSymbol); } - finally + } + catch (Exception ex) + { + if (EqtTrace.IsErrorEnabled) { - ReleaseComObject(ref enumTypeSymbols); - ReleaseComObject(ref global); + EqtTrace.Error("Ignoring the exception while iterating type symbols:{0}", ex); } } - - private IDiaSymbol GetTypeSymbol(string typeName, SymTagEnum symTag) + finally { - ValidateArg.NotNullOrEmpty(typeName, nameof(typeName)); + ReleaseComObject(ref enumTypeSymbols); + ReleaseComObject(ref global); + } + } + + private IDiaSymbol GetTypeSymbol(string typeName, SymTagEnum symTag) + { + ValidateArg.NotNullOrEmpty(typeName, nameof(typeName)); - IDiaEnumSymbols enumSymbols = null; - IDiaSymbol typeSymbol = null; - IDiaSymbol global = null; + IDiaEnumSymbols enumSymbols = null; + IDiaSymbol typeSymbol = null; + IDiaSymbol global = null; - try + try + { + typeName = typeName.Replace('+', '.'); + if (_typeSymbols.ContainsKey(typeName)) { - typeName = typeName.Replace('+', '.'); - if (this.typeSymbols.ContainsKey(typeName)) - { - return this.typeSymbols[typeName]; - } + return _typeSymbols[typeName]; + } - this.session.GetGlobalScope(out global); - global.FindChildren(symTag, typeName, 0, out enumSymbols); + _session.GetGlobalScope(out global); + global.FindChildren(symTag, typeName, 0, out enumSymbols); - enumSymbols.GetNext(1, out typeSymbol, out uint celt); + enumSymbols.GetNext(1, out typeSymbol, out uint celt); #if DEBUG - if (typeSymbol == null) + if (typeSymbol == null) + { + IDiaEnumSymbols enumAllSymbols = null; + try { - IDiaEnumSymbols enumAllSymbols = null; - try - { - global.FindChildren(symTag, null, 0, out enumAllSymbols); - List children = new List(); + global.FindChildren(symTag, null, 0, out enumAllSymbols); + List children = new(); - while (true) + while (true) + { + enumAllSymbols.GetNext(1, out IDiaSymbol childSymbol, out uint fetchedCount); + if (fetchedCount == 0 || childSymbol == null) { - enumAllSymbols.GetNext(1, out IDiaSymbol childSymbol, out uint fetchedCount); - if (fetchedCount == 0 || childSymbol == null) - { - break; - } - - childSymbol.GetName(out var childSymbolName); - children.Add(childSymbolName); - ReleaseComObject(ref childSymbol); + break; } - Debug.Assert(children.Count > 0); - } - finally - { - ReleaseComObject(ref enumAllSymbols); + childSymbol.GetName(out var childSymbolName); + children.Add(childSymbolName); + ReleaseComObject(ref childSymbol); } - } -#endif - } - finally - { - ReleaseComObject(ref enumSymbols); - ReleaseComObject(ref global); - } - - if (typeSymbol != null) - { - this.typeSymbols[typeName] = typeSymbol; + Debug.Assert(children.Count > 0); + } + finally + { + ReleaseComObject(ref enumAllSymbols); + } } - return typeSymbol; +#endif + } + finally + { + ReleaseComObject(ref enumSymbols); + ReleaseComObject(ref global); } - private IDiaSymbol GetMethodSymbol(IDiaSymbol typeSymbol, string methodName) + if (typeSymbol != null) { - ValidateArg.NotNull(typeSymbol, nameof(typeSymbol)); - ValidateArg.NotNullOrEmpty(methodName, nameof(methodName)); + _typeSymbols[typeName] = typeSymbol; + } + + return typeSymbol; + } + + private IDiaSymbol GetMethodSymbol(IDiaSymbol typeSymbol, string methodName) + { + ValidateArg.NotNull(typeSymbol, nameof(typeSymbol)); + ValidateArg.NotNullOrEmpty(methodName, nameof(methodName)); - IDiaEnumSymbols enumSymbols = null; - IDiaSymbol methodSymbol = null; - Dictionary methodSymbolsForType; + IDiaEnumSymbols enumSymbols = null; + IDiaSymbol methodSymbol = null; + Dictionary methodSymbolsForType; - try + try + { + typeSymbol.GetName(out string symbolName); + if (_methodSymbols.ContainsKey(symbolName)) { - typeSymbol.GetName(out string symbolName); - if (this.methodSymbols.ContainsKey(symbolName)) - { - methodSymbolsForType = this.methodSymbols[symbolName]; - if (methodSymbolsForType.ContainsKey(methodName)) - { - return methodSymbolsForType[methodName]; - } - } - else + methodSymbolsForType = _methodSymbols[symbolName]; + if (methodSymbolsForType.ContainsKey(methodName)) { - methodSymbolsForType = new Dictionary(); - this.methodSymbols[symbolName] = methodSymbolsForType; + return methodSymbolsForType[methodName]; } + } + else + { + methodSymbolsForType = new Dictionary(); + _methodSymbols[symbolName] = methodSymbolsForType; + } - typeSymbol.FindChildren(SymTagEnum.SymTagFunction, methodName, 0, out enumSymbols); + typeSymbol.FindChildren(SymTagEnum.SymTagFunction, methodName, 0, out enumSymbols); - enumSymbols.GetNext(1, out methodSymbol, out uint celtFetched); + enumSymbols.GetNext(1, out methodSymbol, out uint celtFetched); #if DEBUG - if (methodSymbol == null) + if (methodSymbol == null) + { + IDiaEnumSymbols enumAllSymbols = null; + try { - IDiaEnumSymbols enumAllSymbols = null; - try - { - typeSymbol.FindChildren(SymTagEnum.SymTagFunction, null, 0, out enumAllSymbols); - List children = new List(); + typeSymbol.FindChildren(SymTagEnum.SymTagFunction, null, 0, out enumAllSymbols); + List children = new(); - while (true) + while (true) + { + enumAllSymbols.GetNext(1, out IDiaSymbol childSymbol, out uint fetchedCount); + if (fetchedCount == 0 || childSymbol == null) { - enumAllSymbols.GetNext(1, out IDiaSymbol childSymbol, out uint fetchedCount); - if (fetchedCount == 0 || childSymbol == null) - { - break; - } - - childSymbol.GetName(out string childSymbolName); - children.Add(childSymbolName); - ReleaseComObject(ref childSymbol); + break; } - Debug.Assert(children.Count > 0); - } - finally - { - ReleaseComObject(ref enumAllSymbols); + childSymbol.GetName(out string childSymbolName); + children.Add(childSymbolName); + ReleaseComObject(ref childSymbol); } - } -#endif - } - finally - { - ReleaseComObject(ref enumSymbols); - } - - if (methodSymbol != null) - { - methodSymbolsForType[methodName] = methodSymbol; + Debug.Assert(children.Count > 0); + } + finally + { + ReleaseComObject(ref enumAllSymbols); + } } - return methodSymbol; +#endif + } + finally + { + ReleaseComObject(ref enumSymbols); } - /// - /// Update the method symbol cache. - /// - private static void UpdateMethodSymbolCache(string methodName, IDiaSymbol methodSymbol, Dictionary methodSymbolCache) + if (methodSymbol != null) { - Debug.Assert(!string.IsNullOrEmpty(methodName), "MethodName cannot be empty."); - Debug.Assert(methodSymbol != null, "Method symbol cannot be null."); - Debug.Assert(methodSymbolCache != null, "Method symbol cache cannot be null."); + methodSymbolsForType[methodName] = methodSymbol; + } - // #827589, In case a type has overloaded methods, then there could be a method already in the - // cache which should be disposed. - if (methodSymbolCache.TryGetValue(methodName, out IDiaSymbol oldSymbol)) - { - ReleaseComObject(ref oldSymbol); - } + return methodSymbol; + } + + /// + /// Update the method symbol cache. + /// + private static void UpdateMethodSymbolCache(string methodName, IDiaSymbol methodSymbol, Dictionary methodSymbolCache) + { + Debug.Assert(!string.IsNullOrEmpty(methodName), "MethodName cannot be empty."); + Debug.Assert(methodSymbol != null, "Method symbol cannot be null."); + Debug.Assert(methodSymbolCache != null, "Method symbol cache cannot be null."); - methodSymbolCache[methodName] = methodSymbol; + // #827589, In case a type has overloaded methods, then there could be a method already in the + // cache which should be disposed. + if (methodSymbolCache.TryGetValue(methodName, out IDiaSymbol oldSymbol)) + { + ReleaseComObject(ref oldSymbol); } - private static void ReleaseComObject(ref T obj) - where T : class + methodSymbolCache[methodName] = methodSymbol; + } + + private static void ReleaseComObject(ref T obj) + where T : class + { + if (obj != null) { - if (obj != null) - { - Marshal.FinalReleaseComObject(obj); - obj = null; - } + Marshal.FinalReleaseComObject(obj); + obj = null; } + } - private void Dispose(bool disposing) + private void Dispose(bool disposing) + { + if (!_isDisposed) { - if (!this.isDisposed) + if (disposing) { - if (disposing) + foreach (Dictionary methodSymbolsForType in _methodSymbols.Values) { - foreach (Dictionary methodSymbolsForType in this.methodSymbols.Values) - { - foreach (IDiaSymbol methodSymbol in methodSymbolsForType.Values) - { - IDiaSymbol symToRelease = methodSymbol; - ReleaseComObject(ref symToRelease); - } - - methodSymbolsForType.Clear(); - } - - this.methodSymbols.Clear(); - this.methodSymbols = null; - foreach (IDiaSymbol typeSymbol in this.typeSymbols.Values) + foreach (IDiaSymbol methodSymbol in methodSymbolsForType.Values) { - IDiaSymbol symToRelease = typeSymbol; + IDiaSymbol symToRelease = methodSymbol; ReleaseComObject(ref symToRelease); } - this.typeSymbols.Clear(); - this.typeSymbols = null; - ReleaseComObject(ref this.session); - ReleaseComObject(ref this.source); + methodSymbolsForType.Clear(); + } + + _methodSymbols.Clear(); + _methodSymbols = null; + foreach (IDiaSymbol typeSymbol in _typeSymbols.Values) + { + IDiaSymbol symToRelease = typeSymbol; + ReleaseComObject(ref symToRelease); } - this.isDisposed = true; + _typeSymbols.Clear(); + _typeSymbols = null; + ReleaseComObject(ref _session); + ReleaseComObject(ref _source); } + + _isDisposed = true; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Navigation/INavigationData.cs b/src/Microsoft.TestPlatform.ObjectModel/Navigation/INavigationData.cs index 9b1a88418f..ab3c3edba2 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Navigation/INavigationData.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Navigation/INavigationData.cs @@ -1,26 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Navigation +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Navigation; + +/// +/// Stores the navigation data associated with the .exe/.dll file +/// +public interface INavigationData { /// - /// Stores the navigation data associated with the .exe/.dll file + /// Gets or sets the file name of the file containing the method being navigated. /// - public interface INavigationData - { - /// - /// Gets or sets the file name of the file containing the method being navigated. - /// - string FileName { get; set; } + string FileName { get; set; } - /// - /// Gets or sets the min line number of the method being navigated in the file. - /// - int MinLineNumber { get; set; } + /// + /// Gets or sets the min line number of the method being navigated in the file. + /// + int MinLineNumber { get; set; } - /// - /// Gets or sets the max line number of the method being navigated in the file. - /// - int MaxLineNumber { get; set; } - } -} + /// + /// Gets or sets the max line number of the method being navigated in the file. + /// + int MaxLineNumber { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Navigation/INavigationSession.cs b/src/Microsoft.TestPlatform.ObjectModel/Navigation/INavigationSession.cs index f5a2cee0e6..60ee48c6f1 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Navigation/INavigationSession.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Navigation/INavigationSession.cs @@ -1,21 +1,20 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Navigation -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Navigation; + +using System; +/// +/// Manages the debug data associated with the .exe/.dll file +/// +public interface INavigationSession : IDisposable +{ /// - /// Manages the debug data associated with the .exe/.dll file + /// Gets the navigation data for a method. /// - public interface INavigationSession : IDisposable - { - /// - /// Gets the navigation data for a method. - /// - /// The declaring type name. - /// The method name. - /// The to get to the method. - INavigationData GetNavigationDataForMethod(string declaringTypeName, string methodName); - } -} + /// The declaring type name. + /// The method name. + /// The to get to the method. + INavigationData GetNavigationDataForMethod(string declaringTypeName, string methodName); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Navigation/ISymbolReader.cs b/src/Microsoft.TestPlatform.ObjectModel/Navigation/ISymbolReader.cs index 6aa582b52a..5b5f77d61c 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Navigation/ISymbolReader.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Navigation/ISymbolReader.cs @@ -1,39 +1,38 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Navigation -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Navigation; + +using System; +/// +/// Caches filename and line number for symbols in assembly. +/// +internal interface ISymbolReader : IDisposable +{ /// - /// Caches filename and line number for symbols in assembly. + /// Cache symbols from binary path /// - internal interface ISymbolReader : IDisposable - { - /// - /// Cache symbols from binary path - /// - /// - /// The binary path is assembly path Ex: \path\to\bin\Debug\simpleproject.dll - /// - /// - /// search path. - /// - void CacheSymbols(string binaryPath, string searchPath); + /// + /// The binary path is assembly path Ex: \path\to\bin\Debug\simpleproject.dll + /// + /// + /// search path. + /// + void CacheSymbols(string binaryPath, string searchPath); - /// - /// Gets Navigation data from caches - /// - /// - /// Type name Ex: MyNameSpace.MyType - /// - /// - /// Method name in declaringTypeName Ex: Method1 - /// - /// - /// . - /// Returns INavigationData which contains file name and line number. - /// - INavigationData GetNavigationData(string declaringTypeName, string methodName); - } -} + /// + /// Gets Navigation data from caches + /// + /// + /// Type name Ex: MyNameSpace.MyType + /// + /// + /// Method name in declaringTypeName Ex: Method1 + /// + /// + /// . + /// Returns INavigationData which contains file name and line number. + /// + INavigationData GetNavigationData(string declaringTypeName, string methodName); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Navigation/NativeMethods.cs b/src/Microsoft.TestPlatform.ObjectModel/Navigation/NativeMethods.cs index 8987e22311..c6858354af 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Navigation/NativeMethods.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Navigation/NativeMethods.cs @@ -1,642 +1,642 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -// ReSharper disable StyleCop.SA1602 -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Navigation -{ - using System; - using System.IO; - using System.Runtime.InteropServices; - using PlatformAbstractions; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Navigation; - internal static class HResult - { - public static bool Failed(int hr) - { - return hr < 0; - } +using System; +using System.IO; +using System.Runtime.InteropServices; - public static bool Succeeded(int hr) - { - return !Failed(hr); - } - } +using PlatformAbstractions; - /// - /// Some GUID constants we use to instantiate COM objects. - /// - internal static class Guids +internal static class HResult +{ + public static bool Failed(int hr) { - internal static Guid CLSID_DiaSource = new Guid("79F1BB5F-B66E-48E5-B6A9-1545C323CA3D"); + return hr < 0; } - /// - /// DIA's IDiaEnumLineNumbers used for enumerating a symbol's line numbers. - /// - [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("FE30E878-54AC-44f1-81BA-39DE940F6052")] - internal interface IDiaEnumLineNumbers + public static bool Succeeded(int hr) { - int Stub1(); + return !Failed(hr); + } +} - [PreserveSig] - int GetCount(out uint count); +/// +/// Some GUID constants we use to instantiate COM objects. +/// +internal static class Guids +{ + internal static Guid CLSID_DiaSource = new("79F1BB5F-B66E-48E5-B6A9-1545C323CA3D"); +} - [PreserveSig] - int GetItem(uint index, out IDiaLineNumber line); +/// +/// DIA's IDiaEnumLineNumbers used for enumerating a symbol's line numbers. +/// +[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("FE30E878-54AC-44f1-81BA-39DE940F6052")] +internal interface IDiaEnumLineNumbers +{ + int Stub1(); - [PreserveSig] - int GetNext(uint celt, out IDiaLineNumber rgelt, out uint pceltFetched); + [PreserveSig] + int GetCount(out uint count); - int Stub5(); + [PreserveSig] + int GetItem(uint index, out IDiaLineNumber line); - int Stub6(); + [PreserveSig] + int GetNext(uint celt, out IDiaLineNumber rgelt, out uint pceltFetched); - int Stub7(); - } + int Stub5(); - /// - /// DIA's IDiaLineNumber used for retrieving line information. - /// - [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("B388EB14-BE4D-421d-A8A1-6CF7AB057086")] - internal interface IDiaLineNumber - { - int Stub1(); + int Stub6(); - [PreserveSig] - int GetSourceFile(out IDiaSourceFile file); + int Stub7(); +} - [PreserveSig] - int GetLineNumber(out uint line); +/// +/// DIA's IDiaLineNumber used for retrieving line information. +/// +[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("B388EB14-BE4D-421d-A8A1-6CF7AB057086")] +internal interface IDiaLineNumber +{ + int Stub1(); - [PreserveSig] - int GetLineNumberEnd(out uint line); + [PreserveSig] + int GetSourceFile(out IDiaSourceFile file); - [PreserveSig] - int GetColumnNumber(out uint line); + [PreserveSig] + int GetLineNumber(out uint line); - int Stub6(); + [PreserveSig] + int GetLineNumberEnd(out uint line); - int Stub7(); + [PreserveSig] + int GetColumnNumber(out uint line); - int Stub8(); + int Stub6(); - int Stub9(); + int Stub7(); - int Stub10(); + int Stub8(); - int Stub11(); + int Stub9(); - int Stub12(); + int Stub10(); - int Stub13(); + int Stub11(); - int Stub14(); - } + int Stub12(); - /// - /// DIA's IDiaSession used for locating symbols. - /// - [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("2F609EE1-D1C8-4E24-8288-3326BADCD211")] - internal interface IDiaSession - { - int Stub1(); + int Stub13(); - int Stub2(); + int Stub14(); +} - [PreserveSig] - int GetGlobalScope(out IDiaSymbol diaSymbol); +/// +/// DIA's IDiaSession used for locating symbols. +/// +[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("2F609EE1-D1C8-4E24-8288-3326BADCD211")] +internal interface IDiaSession +{ + int Stub1(); - int Stub4(); + int Stub2(); - int Stub5(); + [PreserveSig] + int GetGlobalScope(out IDiaSymbol diaSymbol); - int Stub6(); + int Stub4(); - int Stub7(); + int Stub5(); - int Stub8(); + int Stub6(); - int Stub9(); + int Stub7(); - int Stub10(); + int Stub8(); - int Stub11(); + int Stub9(); - int Stub12(); + int Stub10(); - int Stub13(); + int Stub11(); - [PreserveSig] - int FindSymbolByToken(uint token, SymTagEnum tag, out IDiaSymbol symbol); + int Stub12(); - int Stub15(); + int Stub13(); - int Stub16(); + [PreserveSig] + int FindSymbolByToken(uint token, SymTagEnum tag, out IDiaSymbol symbol); - int Stub17(); + int Stub15(); - int Stub18(); + int Stub16(); - int Stub19(); + int Stub17(); - int Stub20(); + int Stub18(); - int Stub21(); + int Stub19(); - [PreserveSig] - int FindLinesByAddress(uint section, uint offset, uint length, out IDiaEnumLineNumbers enumerator); + int Stub20(); - int Stub23(); + int Stub21(); - int Stub24(); + [PreserveSig] + int FindLinesByAddress(uint section, uint offset, uint length, out IDiaEnumLineNumbers enumerator); - int Stub25(); + int Stub23(); - int Stub26(); + int Stub24(); - int Stub27(); - } + int Stub25(); - /// - /// DIA's IDiaSourceFile used for getting source filenames. - /// - [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("A2EF5353-F5A8-4eb3-90D2-CB526ACB3CDD")] - internal interface IDiaSourceFile - { - int Stub1(); + int Stub26(); - [PreserveSig] - int GetFilename([MarshalAs(UnmanagedType.BStr)] out string filename); + int Stub27(); +} - int Stub3(); +/// +/// DIA's IDiaSourceFile used for getting source filenames. +/// +[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("A2EF5353-F5A8-4eb3-90D2-CB526ACB3CDD")] +internal interface IDiaSourceFile +{ + int Stub1(); - int Stub4(); + [PreserveSig] + int GetFilename([MarshalAs(UnmanagedType.BStr)] out string filename); - int Stub5(); - } + int Stub3(); - /// - /// Represents the DIA symbol tags. - /// - internal enum SymTagEnum : uint - { - SymTagNull, - SymTagExe, - SymTagCompiland, - SymTagCompilandDetails, - SymTagCompilandEnv, - SymTagFunction, - SymTagBlock, - SymTagData, - SymTagAnnotation, - SymTagLabel, - SymTagPublicSymbol, - SymTagUDT, - SymTagEnum, - SymTagFunctionType, - SymTagPointerType, - SymTagArrayType, - SymTagBaseType, - SymTagTypedef, - SymTagBaseClass, - SymTagFriend, - SymTagFunctionArgType, - SymTagFuncDebugStart, - SymTagFuncDebugEnd, - SymTagUsingNamespace, - SymTagVTableShape, - SymTagVTable, - SymTagCustom, - SymTagThunk, - SymTagCustomType, - SymTagManagedType, - SymTagDimension - } + int Stub4(); - /// - /// DIA's IDiaSymbol used for getting the address of function symbols. - /// - [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("cb787b2f-bd6c-4635-ba52-933126bd2dcd")] - internal interface IDiaSymbol - { - int Stub1(); + int Stub5(); +} - [PreserveSig] - int GetSymTag(out SymTagEnum tag); +/// +/// Represents the DIA symbol tags. +/// +internal enum SymTagEnum : uint +{ + SymTagNull, + SymTagExe, + SymTagCompiland, + SymTagCompilandDetails, + SymTagCompilandEnv, + SymTagFunction, + SymTagBlock, + SymTagData, + SymTagAnnotation, + SymTagLabel, + SymTagPublicSymbol, + SymTagUDT, + SymTagEnum, + SymTagFunctionType, + SymTagPointerType, + SymTagArrayType, + SymTagBaseType, + SymTagTypedef, + SymTagBaseClass, + SymTagFriend, + SymTagFunctionArgType, + SymTagFuncDebugStart, + SymTagFuncDebugEnd, + SymTagUsingNamespace, + SymTagVTableShape, + SymTagVTable, + SymTagCustom, + SymTagThunk, + SymTagCustomType, + SymTagManagedType, + SymTagDimension +} - int GetName(out string name); +/// +/// DIA's IDiaSymbol used for getting the address of function symbols. +/// +[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("cb787b2f-bd6c-4635-ba52-933126bd2dcd")] +internal interface IDiaSymbol +{ + int Stub1(); - int Stub4(); + [PreserveSig] + int GetSymTag(out SymTagEnum tag); - int Stub5(); + int GetName(out string name); - int Stub6(); + int Stub4(); - int Stub7(); + int Stub5(); - int Stub8(); + int Stub6(); - [PreserveSig] - int GetAddressSection(out uint section); + int Stub7(); - [PreserveSig] - int GetAddressOffset(out uint offset); + int Stub8(); - int Stub11(); + [PreserveSig] + int GetAddressSection(out uint section); - int Stub12(); + [PreserveSig] + int GetAddressOffset(out uint offset); - int Stub13(); + int Stub11(); - int Stub14(); + int Stub12(); - [PreserveSig] - int GetLength(out long length); + int Stub13(); - int Stub16(); + int Stub14(); - int Stub17(); + [PreserveSig] + int GetLength(out long length); - int Stub18(); + int Stub16(); - int Stub19(); + int Stub17(); - int Stub20(); + int Stub18(); - int Stub21(); + int Stub19(); - int Stub22(); + int Stub20(); - int Stub23(); + int Stub21(); - int Stub24(); + int Stub22(); - int Stub25(); + int Stub23(); - int Stub26(); + int Stub24(); - int Stub27(); + int Stub25(); - int Stub28(); + int Stub26(); - int Stub29(); + int Stub27(); - int Stub30(); + int Stub28(); - int Stub31(); + int Stub29(); - int Stub32(); + int Stub30(); - int Stub33(); + int Stub31(); - int Stub34(); + int Stub32(); - int Stub35(); + int Stub33(); - int Stub36(); + int Stub34(); - int Stub37(); + int Stub35(); - int Stub38(); + int Stub36(); - int Stub39(); + int Stub37(); - int Stub40(); + int Stub38(); - int Stub41(); + int Stub39(); - int Stub42(); + int Stub40(); - int Stub43(); + int Stub41(); - int Stub44(); + int Stub42(); - int Stub45(); + int Stub43(); - int Stub46(); + int Stub44(); - int Stub47(); + int Stub45(); - int Stub48(); + int Stub46(); - int Stub49(); + int Stub47(); - int Stub50(); + int Stub48(); - int Stub51(); + int Stub49(); - int Stub52(); + int Stub50(); - int Stub53(); + int Stub51(); - int Stub54(); + int Stub52(); - int Stub55(); + int Stub53(); - int Stub56(); + int Stub54(); - int Stub57(); + int Stub55(); - int Stub58(); + int Stub56(); - int Stub59(); + int Stub57(); - int Stub60(); + int Stub58(); - int Stub61(); + int Stub59(); - int Stub62(); + int Stub60(); - int Stub63(); + int Stub61(); - int Stub64(); + int Stub62(); - int Stub65(); + int Stub63(); - int Stub66(); + int Stub64(); - int Stub67(); + int Stub65(); - int Stub68(); + int Stub66(); - int Stub69(); + int Stub67(); - int Stub70(); + int Stub68(); - int Stub71(); + int Stub69(); - int Stub72(); + int Stub70(); - int Stub73(); + int Stub71(); - int Stub74(); + int Stub72(); - int Stub75(); + int Stub73(); - int Stub76(); + int Stub74(); - int Stub77(); + int Stub75(); - int Stub78(); + int Stub76(); - int Stub79(); + int Stub77(); - int Stub80(); + int Stub78(); - int Stub81(); + int Stub79(); - int Stub82(); + int Stub80(); - [PreserveSig] - int FindChildren(SymTagEnum tag, string str, int flags, out IDiaEnumSymbols symbol); + int Stub81(); - int Stub84(); + int Stub82(); - int Stub85(); + [PreserveSig] + int FindChildren(SymTagEnum tag, string str, int flags, out IDiaEnumSymbols symbol); - int Stub86(); + int Stub84(); - int Stub87(); + int Stub85(); - int Stub88(); + int Stub86(); - int Stub89(); + int Stub87(); - int Stub90(); + int Stub88(); - int Stub91(); + int Stub89(); - int Stub92(); + int Stub90(); - int Stub93(); + int Stub91(); - int Stub94(); + int Stub92(); - int Stub95(); + int Stub93(); - int Stub96(); + int Stub94(); - int Stub97(); + int Stub95(); - int Stub98(); + int Stub96(); - int Stub99(); + int Stub97(); - int Stub100(); + int Stub98(); - int Stub101(); + int Stub99(); - int Stub102(); + int Stub100(); - int Stub103(); + int Stub101(); - int Stub104(); + int Stub102(); - int Stub105(); + int Stub103(); - int Stub106(); + int Stub104(); - int Stub107(); + int Stub105(); - int Stub108(); + int Stub106(); - int Stub109(); + int Stub107(); - int Stub110(); + int Stub108(); - int Stub111(); + int Stub109(); - int Stub112(); + int Stub110(); - int Stub113(); + int Stub111(); - int Stub114(); + int Stub112(); - int Stub115(); + int Stub113(); - int Stub116(); + int Stub114(); - int Stub117(); + int Stub115(); - int Stub118(); + int Stub116(); - int Stub119(); + int Stub117(); - int Stub120(); + int Stub118(); - int Stub121(); + int Stub119(); - int Stub122(); + int Stub120(); - int Stub123(); + int Stub121(); - int Stub124(); + int Stub122(); - int Stub125(); + int Stub123(); - int Stub126(); + int Stub124(); - int Stub127(); + int Stub125(); - int Stub128(); + int Stub126(); - int Stub129(); + int Stub127(); - int Stub130(); + int Stub128(); - int Stub131(); + int Stub129(); - int Stub132(); + int Stub130(); - int Stub133(); + int Stub131(); - int Stub134(); + int Stub132(); - int Stub135(); + int Stub133(); - int Stub136(); + int Stub134(); - int Stub137(); + int Stub135(); - int Stub138(); + int Stub136(); - int Stub139(); + int Stub137(); - int Stub140(); + int Stub138(); - int Stub141(); + int Stub139(); - int Stub142(); + int Stub140(); - int Stub143(); + int Stub141(); - int Stub144(); + int Stub142(); - int Stub145(); + int Stub143(); - int Stub146(); + int Stub144(); - int Stub147(); + int Stub145(); - int Stub148(); + int Stub146(); - int Stub149(); + int Stub147(); - int Stub150(); + int Stub148(); - int Stub151(); + int Stub149(); - int Stub152(); + int Stub150(); - int Stub153(); + int Stub151(); - int Stub154(); + int Stub152(); - int Stub155(); - } + int Stub153(); - // The definition for DiaSource COM object is present InternalApis\vctools\inc\dia2.h - // The GUID here must match what is present in dia2.h - [ComImport, CoClass(typeof(DiaSourceClass)), Guid("79F1BB5F-B66E-48E5-B6A9-1545C323CA3D")] - internal interface DiaSource : IDiaDataSource - { - } + int Stub154(); - // The definition for DiaSourceClass COM object is present InternalApis\vctools\inc\dia2.h - // The GUID here must match what is present in dia2.h - [ComImport, ClassInterface((short)0), Guid("E6756135-1E65-4D17-8576-610761398C3C")] - internal class DiaSourceClass - { - } + int Stub155(); +} - internal static class DiaSourceObject - { - [DllImport("kernel32.dll", SetLastError = true)] - public static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hReservedNull, int dwFlags); +// The definition for DiaSource COM object is present InternalApis\vctools\inc\dia2.h +// The GUID here must match what is present in dia2.h +[ComImport, CoClass(typeof(DiaSourceClass)), Guid("79F1BB5F-B66E-48E5-B6A9-1545C323CA3D")] +[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "COM interface.")] +internal interface DiaSource : IDiaDataSource +{ +} - public static IDiaDataSource GetDiaSourceObject() - { - var nativeDllDirectory = new ProcessHelper().GetNativeDllDirectory(); +// The definition for DiaSourceClass COM object is present InternalApis\vctools\inc\dia2.h +// The GUID here must match what is present in dia2.h +[ComImport, ClassInterface((short)0), Guid("E6756135-1E65-4D17-8576-610761398C3C")] +internal class DiaSourceClass +{ +} - IntPtr modHandle = LoadLibraryEx(Path.Combine(nativeDllDirectory, "msdia140.dll"), IntPtr.Zero, 0); +internal static class DiaSourceObject +{ + [DllImport("kernel32.dll", SetLastError = true)] + public static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hReservedNull, int dwFlags); - if (modHandle == IntPtr.Zero) - { - throw new COMException(string.Format(Resources.Resources.FailedToLoadMsDia)); - } + public static IDiaDataSource GetDiaSourceObject() + { + var nativeDllDirectory = new ProcessHelper().GetNativeDllDirectory(); - var diaSourceClassGuid = new Guid("{E6756135-1E65-4D17-8576-610761398C3C}"); - var comClassFactory = (IClassFactory)DllGetClassObject(diaSourceClassGuid, new Guid("00000001-0000-0000-C000-000000000046")); + IntPtr modHandle = LoadLibraryEx(Path.Combine(nativeDllDirectory, "msdia140.dll"), IntPtr.Zero, 0); - Guid iDataDataSourceGuid = new Guid("79F1BB5F-B66E-48E5-B6A9-1545C323CA3D"); - comClassFactory.CreateInstance(null, ref iDataDataSourceGuid, out object comObject); - return (comObject as IDiaDataSource); + if (modHandle == IntPtr.Zero) + { + throw new COMException(string.Format(Resources.Resources.FailedToLoadMsDia)); } - #region Private + var diaSourceClassGuid = new Guid("{E6756135-1E65-4D17-8576-610761398C3C}"); + var comClassFactory = (IClassFactory)DllGetClassObject(diaSourceClassGuid, new Guid("00000001-0000-0000-C000-000000000046")); - [ComImport, ComVisible(false), Guid("00000001-0000-0000-C000-000000000046"), - InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - private interface IClassFactory - { - void CreateInstance( - [MarshalAs(UnmanagedType.Interface)] object aggregator, - ref Guid refiid, - [MarshalAs(UnmanagedType.Interface)] out object createdObject); + Guid iDataDataSourceGuid = new("79F1BB5F-B66E-48E5-B6A9-1545C323CA3D"); + comClassFactory.CreateInstance(null, ref iDataDataSourceGuid, out object comObject); + return (comObject as IDiaDataSource); + } - void LockServer(bool incrementRefCount); - } + #region Private - [return: MarshalAs(UnmanagedType.Interface)] - [DllImport("msdia140.dll", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)] - internal static extern object DllGetClassObject( - [In, MarshalAs(UnmanagedType.LPStruct)] Guid rclsid, - [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); + [ComImport, ComVisible(false), Guid("00000001-0000-0000-C000-000000000046"), + InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + private interface IClassFactory + { + void CreateInstance( + [MarshalAs(UnmanagedType.Interface)] object aggregator, + ref Guid refiid, + [MarshalAs(UnmanagedType.Interface)] out object createdObject); - #endregion + void LockServer(bool incrementRefCount); } - /// - /// DIA's IDiaDataSource used for opening symbols. - /// - [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("79F1BB5F-B66E-48E5-B6A9-1545C323CA3D")] - internal interface IDiaDataSource - { - int Stub1(); + [return: MarshalAs(UnmanagedType.Interface)] + [DllImport("msdia140.dll", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)] + internal static extern object DllGetClassObject( + [In, MarshalAs(UnmanagedType.LPStruct)] Guid rclsid, + [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); - int Stub2(); + #endregion +} - int Stub3(); +/// +/// DIA's IDiaDataSource used for opening symbols. +/// +[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("79F1BB5F-B66E-48E5-B6A9-1545C323CA3D")] +internal interface IDiaDataSource +{ + int Stub1(); - [PreserveSig] - int LoadDataForExe( - [MarshalAs(UnmanagedType.LPWStr)] string executable, - [MarshalAs(UnmanagedType.LPWStr)] string searchPath, - IntPtr callback); + int Stub2(); - int Stub5(); + int Stub3(); - [PreserveSig] - int OpenSession(out IDiaSession session); - } + [PreserveSig] + int LoadDataForExe( + [MarshalAs(UnmanagedType.LPWStr)] string executable, + [MarshalAs(UnmanagedType.LPWStr)] string searchPath, + IntPtr callback); - [ComImport, Guid("CAB72C48-443B-48F5-9B0B-42F0820AB29A"), InterfaceType(1)] - internal interface IDiaEnumSymbols - { - int Stub1(); + int Stub5(); - [PreserveSig] - int GetCount(out uint count); + [PreserveSig] + int OpenSession(out IDiaSession session); +} - [PreserveSig] - int GetItem(uint index, out IDiaSymbol symbol); +[ComImport, Guid("CAB72C48-443B-48F5-9B0B-42F0820AB29A"), InterfaceType(1)] +internal interface IDiaEnumSymbols +{ + int Stub1(); - int GetNext(uint index, out IDiaSymbol symbol, out uint pceltFetched); + [PreserveSig] + int GetCount(out uint count); - int Stub5(); + [PreserveSig] + int GetItem(uint index, out IDiaSymbol symbol); - int Stub6(); + int GetNext(uint index, out IDiaSymbol symbol, out uint pceltFetched); - int Stub7(); - } + int Stub5(); + + int Stub6(); + + int Stub7(); } diff --git a/src/Microsoft.TestPlatform.ObjectModel/Navigation/PortablePdbReader.cs b/src/Microsoft.TestPlatform.ObjectModel/Navigation/PortablePdbReader.cs index 7bda8a6e56..7be8b58ac7 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Navigation/PortablePdbReader.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Navigation/PortablePdbReader.cs @@ -1,168 +1,167 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Navigation +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Navigation; + +using System; +using System.IO; +using System.Reflection; +using System.Reflection.Metadata; +using System.Reflection.Metadata.Ecma335; + +/// +/// The portable pdb reader. +/// +internal class PortablePdbReader : IDisposable { - using System; - using System.IO; - using System.Reflection; - using System.Reflection.Metadata; - using System.Reflection.Metadata.Ecma335; + /// + /// Use to get method token + /// + private static readonly PropertyInfo MethodInfoMethodTokenProperty = + typeof(MethodInfo).GetProperty("MetadataToken"); /// - /// The portable pdb reader. + /// Metadata reader provider from portable pdb stream + /// To get Metadata reader /// - internal class PortablePdbReader : IDisposable - { - /// - /// Use to get method token - /// - private static readonly PropertyInfo MethodInfoMethodTokenProperty = - typeof(MethodInfo).GetProperty("MetadataToken"); - - /// - /// Metadata reader provider from portable pdb stream - /// To get Metadata reader - /// - private MetadataReaderProvider provider; - - /// - /// Metadata reader from portable pdb stream - /// To get method debug info from method info - /// - private MetadataReader reader; - - /// - /// Initializes a new instance of the class. - /// - /// - /// Portable pdb stream - /// - /// - /// Raises Exception on given stream is not portable pdb stream - /// - public PortablePdbReader(Stream stream) - { - if (!IsPortable(stream)) - { - throw new Exception("Given stream is not portable stream"); - } + private MetadataReaderProvider _provider; - this.provider = MetadataReaderProvider.FromPortablePdbStream(stream); - this.reader = this.provider.GetMetadataReader(); - } + /// + /// Metadata reader from portable pdb stream + /// To get method debug info from method info + /// + private MetadataReader _reader; - /// - /// Dispose Metadata reader - /// - public void Dispose() + /// + /// Initializes a new instance of the class. + /// + /// + /// Portable pdb stream + /// + /// + /// Raises Exception on given stream is not portable pdb stream + /// + public PortablePdbReader(Stream stream) + { + if (!IsPortable(stream)) { - this.provider?.Dispose(); - this.provider = null; - this.reader = null; + throw new Exception("Given stream is not portable stream"); } - /// - /// Gets dia navigation data from Metadata reader - /// - /// - /// Method info. - /// - /// - /// The . - /// - public DiaNavigationData GetDiaNavigationData(MethodInfo methodInfo) - { - if (methodInfo == null) - { - return null; - } - - var handle = GetMethodDebugInformationHandle(methodInfo); + _provider = MetadataReaderProvider.FromPortablePdbStream(stream); + _reader = _provider.GetMetadataReader(); + } - return this.GetDiaNavigationData(handle); - } + /// + /// Dispose Metadata reader + /// + public void Dispose() + { + _provider?.Dispose(); + _provider = null; + _reader = null; + } - /// - /// Checks gives stream is from portable pdb or not - /// - /// - /// Stream. - /// - /// - /// The . - /// - internal static bool IsPortable(Stream stream) + /// + /// Gets dia navigation data from Metadata reader + /// + /// + /// Method info. + /// + /// + /// The . + /// + public DiaNavigationData GetDiaNavigationData(MethodInfo methodInfo) + { + if (methodInfo == null) { - // First four bytes should be 'BSJB' - var result = (stream.ReadByte() == 'B') && (stream.ReadByte() == 'S') && (stream.ReadByte() == 'J') - && (stream.ReadByte() == 'B'); - stream.Position = 0; - return result; + return null; } - internal static MethodDebugInformationHandle GetMethodDebugInformationHandle(MethodInfo methodInfo) - { - var methodToken = (int)MethodInfoMethodTokenProperty.GetValue(methodInfo); - var handle = ((MethodDefinitionHandle)MetadataTokens.Handle(methodToken)).ToDebugInformationHandle(); - return handle; - } + var handle = GetMethodDebugInformationHandle(methodInfo); + + return GetDiaNavigationData(handle); + } - private static void GetMethodMinAndMaxLineNumber( - MethodDebugInformation methodDebugDefinition, - out int minLineNumber, - out int maxLineNumber) + /// + /// Checks gives stream is from portable pdb or not + /// + /// + /// Stream. + /// + /// + /// The . + /// + internal static bool IsPortable(Stream stream) + { + // First four bytes should be 'BSJB' + var result = (stream.ReadByte() == 'B') && (stream.ReadByte() == 'S') && (stream.ReadByte() == 'J') + && (stream.ReadByte() == 'B'); + stream.Position = 0; + return result; + } + + internal static MethodDebugInformationHandle GetMethodDebugInformationHandle(MethodInfo methodInfo) + { + var methodToken = (int)MethodInfoMethodTokenProperty.GetValue(methodInfo); + var handle = ((MethodDefinitionHandle)MetadataTokens.Handle(methodToken)).ToDebugInformationHandle(); + return handle; + } + + private static void GetMethodMinAndMaxLineNumber( + MethodDebugInformation methodDebugDefinition, + out int minLineNumber, + out int maxLineNumber) + { + minLineNumber = int.MaxValue; + maxLineNumber = int.MinValue; + var orderedSequencePoints = methodDebugDefinition.GetSequencePoints(); + foreach (var sequencePoint in orderedSequencePoints) { - minLineNumber = int.MaxValue; - maxLineNumber = int.MinValue; - var orderedSequencePoints = methodDebugDefinition.GetSequencePoints(); - foreach (var sequencePoint in orderedSequencePoints) + if (sequencePoint.IsHidden) { - if (sequencePoint.IsHidden) - { - // Special sequence point with startLine is Magic number 0xFEEFEE - // Magic number comes from Potable CodeGen source code - continue; - } - minLineNumber = Math.Min(minLineNumber, sequencePoint.StartLine); - maxLineNumber = Math.Max(maxLineNumber, sequencePoint.StartLine); + // Special sequence point with startLine is Magic number 0xFEEFEE + // Magic number comes from Potable CodeGen source code + continue; } + minLineNumber = Math.Min(minLineNumber, sequencePoint.StartLine); + maxLineNumber = Math.Max(maxLineNumber, sequencePoint.StartLine); } + } - private DiaNavigationData GetDiaNavigationData(MethodDebugInformationHandle handle) + private DiaNavigationData GetDiaNavigationData(MethodDebugInformationHandle handle) + { + if (_reader == null) { - if (this.reader == null) - { - throw new ObjectDisposedException(nameof(PortablePdbReader)); - } - - DiaNavigationData diaNavigationData = null; - try - { - var methodDebugDefinition = this.reader.GetMethodDebugInformation(handle); - var fileName = this.GetMethodFileName(methodDebugDefinition); - GetMethodMinAndMaxLineNumber(methodDebugDefinition, out var minLineNumber, out var maxLineNumber); + throw new ObjectDisposedException(nameof(PortablePdbReader)); + } - diaNavigationData = new DiaNavigationData(fileName, minLineNumber, maxLineNumber); - } - catch (BadImageFormatException exception) - { - EqtTrace.Error("failed to get dia navigation data: {0}", exception); - } + DiaNavigationData diaNavigationData = null; + try + { + var methodDebugDefinition = _reader.GetMethodDebugInformation(handle); + var fileName = GetMethodFileName(methodDebugDefinition); + GetMethodMinAndMaxLineNumber(methodDebugDefinition, out var minLineNumber, out var maxLineNumber); - return diaNavigationData; + diaNavigationData = new DiaNavigationData(fileName, minLineNumber, maxLineNumber); } - - private string GetMethodFileName(MethodDebugInformation methodDebugDefinition) + catch (BadImageFormatException exception) { - var fileName = string.Empty; - if (!methodDebugDefinition.Document.IsNil) - { - var document = this.reader.GetDocument(methodDebugDefinition.Document); - fileName = this.reader.GetString(document.Name); - } + EqtTrace.Error("failed to get dia navigation data: {0}", exception); + } + + return diaNavigationData; + } - return fileName; + private string GetMethodFileName(MethodDebugInformation methodDebugDefinition) + { + var fileName = string.Empty; + if (!methodDebugDefinition.Document.IsNil) + { + var document = _reader.GetDocument(methodDebugDefinition.Document); + fileName = _reader.GetString(document.Name); } + + return fileName; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Navigation/PortableSymbolReader.cs b/src/Microsoft.TestPlatform.ObjectModel/Navigation/PortableSymbolReader.cs index ba03fecb79..eeb4ff1bd7 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Navigation/PortableSymbolReader.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Navigation/PortableSymbolReader.cs @@ -1,152 +1,149 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Navigation -{ - using System; - using System.Collections.Generic; - using System.IO; - using System.Reflection; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Navigation; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using PlatformAbstractions; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +/// +/// The portable symbol reader. +/// +internal class PortableSymbolReader : ISymbolReader +{ /// - /// The portable symbol reader. + /// Key in first dict is Type FullName + /// Key in second dict is method name /// - internal class PortableSymbolReader : ISymbolReader + private Dictionary> _methodsNavigationDataForType = + new(); + + /// + /// The cache symbols. + /// + /// + /// The binary path. + /// + /// + /// The search path. + /// + public void CacheSymbols(string binaryPath, string searchPath) { - /// - /// Key in first dict is Type FullName - /// Key in second dict is method name - /// - private Dictionary> methodsNavigationDataForType = - new Dictionary>(); + PopulateCacheForTypeAndMethodSymbols(binaryPath); + } - /// - /// The cache symbols. - /// - /// - /// The binary path. - /// - /// - /// The search path. - /// - public void CacheSymbols(string binaryPath, string searchPath) + /// + /// The dispose. + /// + public void Dispose() + { + foreach (var methodsNavigationData in _methodsNavigationDataForType.Values) { - this.PopulateCacheForTypeAndMethodSymbols(binaryPath); + methodsNavigationData.Clear(); } - /// - /// The dispose. - /// - public void Dispose() + _methodsNavigationDataForType.Clear(); + _methodsNavigationDataForType = null; + } + + /// + /// The get navigation data. + /// + /// + /// The declaring type name. + /// + /// + /// The method name. + /// + /// + /// The . + /// + public INavigationData GetNavigationData(string declaringTypeName, string methodName) + { + INavigationData navigationData = null; + if (_methodsNavigationDataForType.ContainsKey(declaringTypeName)) { - foreach (var methodsNavigationData in this.methodsNavigationDataForType.Values) + var methodDict = _methodsNavigationDataForType[declaringTypeName]; + if (methodDict.ContainsKey(methodName)) { - methodsNavigationData.Clear(); + navigationData = methodDict[methodName]; } - - this.methodsNavigationDataForType.Clear(); - this.methodsNavigationDataForType = null; } - /// - /// The get navigation data. - /// - /// - /// The declaring type name. - /// - /// - /// The method name. - /// - /// - /// The . - /// - public INavigationData GetNavigationData(string declaringTypeName, string methodName) + return navigationData; + } + + /// + /// The populate cache for type and method symbols. + /// + /// + /// The binary path. + /// + private void PopulateCacheForTypeAndMethodSymbols(string binaryPath) + { + try { - INavigationData navigationData = null; - if (this.methodsNavigationDataForType.ContainsKey(declaringTypeName)) + var pdbFilePath = Path.ChangeExtension(binaryPath, ".pdb"); + using var pdbReader = new PortablePdbReader(new FileHelper().GetStream(pdbFilePath, FileMode.Open, FileAccess.Read)); + // At this point, the assembly should be already loaded into the load context. We query for a reference to + // find the types and cache the symbol information. Let the loader follow default lookup order instead of + // forcing load from a specific path. + Assembly asm; + try { - var methodDict = this.methodsNavigationDataForType[declaringTypeName]; - if (methodDict.ContainsKey(methodName)) - { - navigationData = methodDict[methodName]; - } + asm = Assembly.Load(new PlatformAssemblyLoadContext().GetAssemblyNameFromPath(binaryPath)); + } + catch (FileNotFoundException) + { +#if !NETSTANDARD1_3 && !WINDOWS_UWP && !NETCOREAPP1_0 + // fallback when the assembly is not loaded + asm = Assembly.LoadFile(binaryPath); +#else + // fallback is not supported + throw; +#endif } - return navigationData; - } - - /// - /// The populate cache for type and method symbols. - /// - /// - /// The binary path. - /// - private void PopulateCacheForTypeAndMethodSymbols(string binaryPath) - { - try + foreach (var type in asm.GetTypes()) { - var pdbFilePath = Path.ChangeExtension(binaryPath, ".pdb"); - using (var pdbReader = new PortablePdbReader(new FileHelper().GetStream(pdbFilePath, FileMode.Open, FileAccess.Read))) + // Get declared method infos + var methodInfoList = type.GetTypeInfo().DeclaredMethods; + var methodsNavigationData = new Dictionary(); + + foreach (var methodInfo in methodInfoList) { - // At this point, the assembly should be already loaded into the load context. We query for a reference to - // find the types and cache the symbol information. Let the loader follow default lookup order instead of - // forcing load from a specific path. - Assembly asm; - try + var diaNavigationData = pdbReader.GetDiaNavigationData(methodInfo); + if (diaNavigationData != null) { - asm = Assembly.Load(new PlatformAssemblyLoadContext().GetAssemblyNameFromPath(binaryPath)); + methodsNavigationData[methodInfo.Name] = diaNavigationData; } - catch (FileNotFoundException) + else { -#if !NETSTANDARD1_3 && !WINDOWS_UWP && !NETCOREAPP1_0 - // fallback when the assembly is not loaded - asm = Assembly.LoadFile(binaryPath); -#else - // fallback is not supported - throw; -#endif + EqtTrace.Error( + string.Format( + "Unable to find source information for method: {0} type: {1}", + methodInfo.Name, + type.FullName)); } + } - foreach (var type in asm.GetTypes()) - { - // Get declared method infos - var methodInfoList = type.GetTypeInfo().DeclaredMethods; - var methodsNavigationData = new Dictionary(); - - foreach (var methodInfo in methodInfoList) - { - var diaNavigationData = pdbReader.GetDiaNavigationData(methodInfo); - if (diaNavigationData != null) - { - methodsNavigationData[methodInfo.Name] = diaNavigationData; - } - else - { - EqtTrace.Error( - string.Format( - "Unable to find source information for method: {0} type: {1}", - methodInfo.Name, - type.FullName)); - } - } - - if (methodsNavigationData.Count != 0) - { - this.methodsNavigationDataForType[type.FullName] = methodsNavigationData; - } - } + if (methodsNavigationData.Count != 0) + { + _methodsNavigationDataForType[type.FullName] = methodsNavigationData; } } - catch (Exception ex) - { - EqtTrace.Error("PortableSymbolReader: Failed to load symbols for binary: {0}", binaryPath); - EqtTrace.Error(ex); - this.Dispose(); - throw; - } + } + catch (Exception ex) + { + EqtTrace.Error("PortableSymbolReader: Failed to load symbols for binary: {0}", binaryPath); + EqtTrace.Error(ex); + Dispose(); + throw; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/RegistryFreeActivationContext.cs b/src/Microsoft.TestPlatform.ObjectModel/RegistryFreeActivationContext.cs index 4c9600f246..6baed432d8 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/RegistryFreeActivationContext.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/RegistryFreeActivationContext.cs @@ -1,151 +1,153 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. + #if NETFRAMEWORK -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +/// +/// Enable registry-free COM context +/// +internal class RegistryFreeActivationContext : IDisposable { - using System; - using System.ComponentModel; - using System.Runtime.InteropServices; - - /// - /// Enable registry-free COM context - /// - internal class RegistryFreeActivationContext : IDisposable - { - private IntPtr cookie = IntPtr.Zero; + private IntPtr _cookie = IntPtr.Zero; + + private IntPtr _hActCtx = IntPtr.Zero; + + private bool _disposed = false; - private IntPtr hActCtx = IntPtr.Zero; + private readonly string _manifestFilePath = string.Empty; - private bool disposed = false; + /// + /// Initializes a new instance of RegistryFreeActivationContext class. + /// + ///Manifest file path. + public RegistryFreeActivationContext(string manifest) + { + _manifestFilePath = manifest; + } - private string manifestFilePath = string.Empty; + /// + /// Finalize an instance of RegistryFreeActivationContext class. + /// + ~RegistryFreeActivationContext() + { + Dispose(false); + } - /// - /// Initializes a new instance of RegistryFreeActivationContext class. - /// - ///Manifest file path. - public RegistryFreeActivationContext(string manifest) + /// + /// Load manifest to enable registry-free COM context. + /// + public void ActivateContext() + { + if (_cookie != IntPtr.Zero || _hActCtx != IntPtr.Zero) { - this.manifestFilePath = manifest; + return; } - /// - /// Finalize an instance of RegistryFreeActivationContext class. - /// - ~RegistryFreeActivationContext() + ActivationContextNativeMethods.ACTCTX context = new(); + context.cbSize = Marshal.SizeOf(typeof(ActivationContextNativeMethods.ACTCTX)); + + context.lpSource = _manifestFilePath; + + _hActCtx = ActivationContextNativeMethods.CreateActCtx(ref context); + if (_hActCtx == (IntPtr)(-1)) { - this.Dispose(false); + throw new Win32Exception(Marshal.GetLastWin32Error(), "Fail to create registry-free COM context"); } - - /// - /// Load manifest to enable registry-free COM context. - /// - public void ActivateContext() + if (!ActivationContextNativeMethods.ActivateActCtx(_hActCtx, out _cookie)) { - if (cookie != IntPtr.Zero || hActCtx != IntPtr.Zero) - { - return; - } - - ActivationContextNativeMethods.ACTCTX context = new ActivationContextNativeMethods.ACTCTX(); - context.cbSize = Marshal.SizeOf(typeof(ActivationContextNativeMethods.ACTCTX)); + throw new Win32Exception(Marshal.GetLastWin32Error(), "Fail to activate registry-free COM context"); + } + } - context.lpSource = this.manifestFilePath; + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - hActCtx = ActivationContextNativeMethods.CreateActCtx(ref context); - if (hActCtx == (IntPtr)(-1)) - { - throw new Win32Exception(Marshal.GetLastWin32Error(), "Fail to create registry-free COM context"); - } - if (!ActivationContextNativeMethods.ActivateActCtx(hActCtx, out cookie)) + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) { - throw new Win32Exception(Marshal.GetLastWin32Error(), "Fail to activate registry-free COM context"); + // No managed resources to release } + + DeactivateContext(); + _disposed = true; } + } - public void Dispose() + /// + /// Disable registry-free COM context. + /// + private void DeactivateContext() + { + if (_cookie == IntPtr.Zero && _hActCtx == IntPtr.Zero) { - Dispose(true); - GC.SuppressFinalize(this); + return; } - protected virtual void Dispose(bool disposing) + try { - if (!disposed) - { - if (disposing) - { - // No managed resources to release - } - - this.DeactivateContext(); - disposed = true; - } + ActivationContextNativeMethods.DeactivateActCtx(0, _cookie); + ActivationContextNativeMethods.ReleaseActCtx(_hActCtx); + _cookie = IntPtr.Zero; + _hActCtx = IntPtr.Zero; } - - /// - /// Disable registry-free COM context. - /// - private void DeactivateContext() + catch (Exception ex) { - if (cookie == IntPtr.Zero && hActCtx == IntPtr.Zero) + // Log any exceptions during deactivation. + if (EqtTrace.IsErrorEnabled) { - return; - } - - try - { - ActivationContextNativeMethods.DeactivateActCtx(0, cookie); - ActivationContextNativeMethods.ReleaseActCtx(hActCtx); - cookie = IntPtr.Zero; - hActCtx = IntPtr.Zero; - } - catch (Exception ex) - { - // Log any exceptions during deactivation. - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error(ex); - } + EqtTrace.Error(ex); } } } +} - /// ActivationContextNativeMethods class needed for registry-free context - /// - internal static class ActivationContextNativeMethods - { - // Activation Context API Functions - [DllImport("Kernel32.dll", SetLastError = true, EntryPoint = "CreateActCtxW")] - public extern static IntPtr CreateActCtx(ref ACTCTX actctx); +/// ActivationContextNativeMethods class needed for registry-free context +/// +internal static class ActivationContextNativeMethods +{ + // Activation Context API Functions + [DllImport("Kernel32.dll", SetLastError = true, EntryPoint = "CreateActCtxW")] + public extern static IntPtr CreateActCtx(ref ACTCTX actctx); - [DllImport("Kernel32.dll", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool ActivateActCtx(IntPtr hActCtx, out IntPtr lpCookie); + [DllImport("Kernel32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ActivateActCtx(IntPtr hActCtx, out IntPtr lpCookie); - [DllImport("kernel32.dll", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool DeactivateActCtx(int dwFlags, IntPtr lpCookie); + [DllImport("kernel32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool DeactivateActCtx(int dwFlags, IntPtr lpCookie); - [DllImport("Kernel32.dll", SetLastError = true)] - public static extern void ReleaseActCtx(IntPtr hActCtx); + [DllImport("Kernel32.dll", SetLastError = true)] + public static extern void ReleaseActCtx(IntPtr hActCtx); - // Activation context structure - [StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Unicode)] - public struct ACTCTX - { - public Int32 cbSize; - public UInt32 dwFlags; - public string lpSource; - public UInt16 wProcessorArchitecture; - public UInt16 wLangId; - public string lpAssemblyDirectory; - public string lpResourceName; - public string lpApplicationName; - public IntPtr hModule; - } + // Activation context structure + [StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Unicode)] + [SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Layout struct")] + public struct ACTCTX + { + public Int32 cbSize; + public UInt32 dwFlags; + public string lpSource; + public UInt16 wProcessorArchitecture; + public UInt16 wLangId; + public string lpAssemblyDirectory; + public string lpResourceName; + public string lpApplicationName; + public IntPtr hModule; } } diff --git a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs index bee3c87e8d..ebefdc3772 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs @@ -1,963 +1,893 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using Utilities; +using PlatformAbstractions; + +using System; +using System.Globalization; +using System.Xml; + +/// +/// Stores information about a test settings. +/// +public class RunConfiguration : TestRunSettings { - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + #region Private Fields - using System; - using System.Diagnostics.CodeAnalysis; - using System.Globalization; - using System.IO; - using System.Xml; + /// + /// Platform architecture which rocksteady should use for discovery/execution + /// + private Architecture _platform; /// - /// Stores information about a test settings. + /// Maximum number of cores that the engine can use to run tests in parallel /// - public class RunConfiguration : TestRunSettings - { - #region Private Fields - - /// - /// Platform architecture which rocksteady should use for discovery/execution - /// - private Architecture platform; - - /// - /// Maximum number of cores that the engine can use to run tests in parallel - /// - private int maxCpuCount; - - /// - /// .Net framework which rocksteady should use for discovery/execution - /// - private Framework framework; - - /// - /// Specifies the frequency of the runStats/discoveredTests event - /// - private long batchSize; - - /// - /// Specifies the Test Session Timeout in milliseconds - /// - private long testSessionTimeout; - - /// - /// Directory in which rocksteady/adapter should keep their run specific data. - /// - private string resultsDirectory; - - /// - /// Paths at which rocksteady should look for test adapters - /// - private string testAdaptersPaths; - - /// - /// Indication to adapters to disable app domain. - /// - private bool disableAppDomain; - - /// - /// Indication to adapters to disable parallelization. - /// - private bool disableParallelization; - - /// - /// True if test run is triggered - /// - private bool designMode; - - /// - /// Specify to run tests in isolation - /// - private bool inIsolation; - - /// - /// False indicates that the test adapter should not collect source information for discovered tests - /// - private bool shouldCollectSourceInformation; - - /// - /// Gets the targetDevice IP for UWP app deployment - /// - private string targetDevice; - - #endregion - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - public RunConfiguration() : base(Constants.RunConfigurationSettingsName) - { - // Set defaults for target platform, framework version type and results directory. - this.platform = Constants.DefaultPlatform; - this.framework = Framework.DefaultFramework; - this.resultsDirectory = Constants.DefaultResultsDirectory; - this.SolutionDirectory = null; - this.TreatTestAdapterErrorsAsWarnings = Constants.DefaultTreatTestAdapterErrorsAsWarnings; - this.BinariesRoot = null; - this.testAdaptersPaths = null; - this.maxCpuCount = Constants.DefaultCpuCount; - this.batchSize = Constants.DefaultBatchSize; - this.testSessionTimeout = 0; - this.disableAppDomain = false; - this.disableParallelization = false; - this.designMode = false; - this.inIsolation = false; - this.shouldCollectSourceInformation = false; - this.targetDevice = null; - this.ExecutionThreadApartmentState = Constants.DefaultExecutionThreadApartmentState; - } + private int _maxCpuCount; - #endregion + /// + /// .Net framework which rocksteady should use for discovery/execution + /// + private Framework _framework; - #region Properties + /// + /// Specifies the frequency of the runStats/discoveredTests event + /// + private long _batchSize; - /// - /// Gets or sets the solution directory. - /// - public string SolutionDirectory - { - get; - set; - } + /// + /// Directory in which rocksteady/adapter should keep their run specific data. + /// + private string _resultsDirectory; - /// - /// Gets or sets the results directory. - /// - public string ResultsDirectory - { - get - { - return this.resultsDirectory; - } + /// + /// Paths at which rocksteady should look for test adapters + /// + private string _testAdaptersPaths; - set - { - this.resultsDirectory = value; - this.ResultsDirectorySet = true; - } - } + /// + /// Indication to adapters to disable app domain. + /// + private bool _disableAppDomain; - /// - /// Gets or sets the Parallel execution option. Should be non-negative integer. - /// - public int MaxCpuCount - { - get - { - return this.maxCpuCount; - } - set - { - this.maxCpuCount = value; - this.MaxCpuCountSet = true; - } - } + /// + /// Indication to adapters to disable parallelization. + /// + private bool _disableParallelization; - /// - /// Gets or sets the frequency of the runStats/discoveredTests event. Should be non-negative integer. - /// - public long BatchSize - { - get - { - return this.batchSize; - } - set - { - this.batchSize = value; - this.BatchSizeSet = true; - } - } + /// + /// True if test run is triggered + /// + private bool _designMode; - /// - /// Gets or sets the testSessionTimeout. Should be non-negative integer. - /// - public long TestSessionTimeout - { - get - { - return this.testSessionTimeout; - } - set - { - this.testSessionTimeout = value; - } - } + /// + /// False indicates that the test adapter should not collect source information for discovered tests + /// + private bool _shouldCollectSourceInformation; - /// - /// Gets or sets the design mode value. - /// - public bool DesignMode - { - get - { - return this.designMode; - } + #endregion - set - { - this.designMode = value; - this.DesignModeSet = true; - } - } + #region Constructor - /// - /// Gets or sets a value indicating whether to run tests in isolation or not. - /// - public bool InIsolation - { - get - { - return this.inIsolation; - } + /// + /// Initializes a new instance of the class. + /// + public RunConfiguration() : base(Constants.RunConfigurationSettingsName) + { + // Set defaults for target platform, framework version type and results directory. + _platform = Constants.DefaultPlatform; + _framework = Framework.DefaultFramework; + _resultsDirectory = Constants.DefaultResultsDirectory; + SolutionDirectory = null; + TreatTestAdapterErrorsAsWarnings = Constants.DefaultTreatTestAdapterErrorsAsWarnings; + BinariesRoot = null; + _testAdaptersPaths = null; + _maxCpuCount = Constants.DefaultCpuCount; + _batchSize = Constants.DefaultBatchSize; + TestSessionTimeout = 0; + _disableAppDomain = false; + _disableParallelization = false; + _designMode = false; + InIsolation = false; + _shouldCollectSourceInformation = false; + TargetDevice = null; + ExecutionThreadApartmentState = Constants.DefaultExecutionThreadApartmentState; + } - set - { - this.inIsolation = value; - } - } + #endregion - /// - /// Gets a value indicating whether test adapter needs to collect source information for discovered tests - /// - public bool ShouldCollectSourceInformation - { - get - { - return (this.CollectSourceInformationSet) ? this.shouldCollectSourceInformation : this.designMode; - } + #region Properties - set - { - this.shouldCollectSourceInformation = value; - this.CollectSourceInformationSet = true; - } - } + /// + /// Gets or sets the solution directory. + /// + public string SolutionDirectory + { + get; + set; + } - /// - /// Gets or sets a value indicating whether app domain creation should be disabled. - /// - public bool DisableAppDomain + /// + /// Gets or sets the results directory. + /// + public string ResultsDirectory + { + get { - get - { - return this.disableAppDomain; - } - - set - { - this.disableAppDomain = value; - this.DisableAppDomainSet = true; - } + return _resultsDirectory; } - /// - /// Gets a value indicating whether parallelism needs to be disabled by the adapters. - /// - public bool DisableParallelization + set { - get - { - return this.disableParallelization; - } - - set - { - this.disableParallelization = value; - this.DisableParallelizationSet = true; - } + _resultsDirectory = value; + ResultsDirectorySet = true; } + } - /// - /// Gets or sets the Target platform this run is targeting. Possible values are x86|x64|arm|anycpu. - /// - public Architecture TargetPlatform + /// + /// Gets or sets the Parallel execution option. Should be non-negative integer. + /// + public int MaxCpuCount + { + get { - get - { - return this.platform; - } - - set - { - this.platform = value; - this.TargetPlatformSet = true; - } + return _maxCpuCount; } - - /// - /// Gets or sets the target Framework this run is targeting. - /// - public Framework TargetFramework + set { - get - { - return this.framework; - } + _maxCpuCount = value; + MaxCpuCountSet = true; + } + } - set - { - this.framework = value; - this.TargetFrameworkSet = true; - } + /// + /// Gets or sets the frequency of the runStats/discoveredTests event. Should be non-negative integer. + /// + public long BatchSize + { + get + { + return _batchSize; } - /// - /// Gets or sets value indicating exit code when no tests are discovered or executed - /// - public bool TreatNoTestsAsError - { - get; - set; + set + { + _batchSize = value; + BatchSizeSet = true; } + } - /// - /// Gets or sets the target Framework this run is targeting. Possible values are Framework3.5|Framework4.0|Framework4.5 - /// - [Obsolete("Use TargetFramework instead")] - public FrameworkVersion TargetFrameworkVersion - { - get - { - switch (this.framework?.Name) - { - case Constants.DotNetFramework35: - return FrameworkVersion.Framework35; - case Constants.DotNetFramework40: - return FrameworkVersion.Framework40; - case Constants.DotNetFramework45: - return FrameworkVersion.Framework45; - case Constants.DotNetFrameworkCore10: - return FrameworkVersion.FrameworkCore10; - case Constants.DotNetFrameworkUap10: - return FrameworkVersion.FrameworkUap10; - default: - return Constants.DefaultFramework; - } - } + /// + /// Gets or sets the testSessionTimeout. Should be non-negative integer. + /// + public long TestSessionTimeout { get; set; } - set - { - this.framework = Framework.FromString(value.ToString()); - this.TargetFrameworkSet = true; - } + /// + /// Gets or sets the design mode value. + /// + public bool DesignMode + { + get + { + return _designMode; } - /// - /// Gets or sets the target device IP. For Phone this value is Device, for emulators "Mobile Emulator 10.0.15063.0 WVGA 4 inch 1GB" - /// - public string TargetDevice + set { - get - { - return this.targetDevice; - } - - set - { - this.targetDevice = value; - } + _designMode = value; + DesignModeSet = true; } + } - /// - /// Gets or sets the paths used for test adapters lookup in test platform. - /// - public string TestAdaptersPaths - { - get - { - return this.testAdaptersPaths; - } + /// + /// Gets or sets a value indicating whether to run tests in isolation or not. + /// + public bool InIsolation { get; set; } - set - { - this.testAdaptersPaths = value; + /// + /// Gets a value indicating whether test adapter needs to collect source information for discovered tests + /// + public bool ShouldCollectSourceInformation + { + get + { + return (CollectSourceInformationSet) ? _shouldCollectSourceInformation : _designMode; + } - if (this.testAdaptersPaths != null) - { - this.TestAdaptersPathsSet = true; - } - } + set + { + _shouldCollectSourceInformation = value; + CollectSourceInformationSet = true; } + } - /// - /// Gets or sets the execution thread apartment state. - /// - [CLSCompliant(false)] - public PlatformApartmentState ExecutionThreadApartmentState + /// + /// Gets or sets a value indicating whether app domain creation should be disabled. + /// + public bool DisableAppDomain + { + get { - get; - set; + return _disableAppDomain; } - /// - /// Gets or sets a value indicating whether to treat the errors from test adapters as warnings. - /// - public bool TreatTestAdapterErrorsAsWarnings + set { - get; - set; + _disableAppDomain = value; + DisableAppDomainSet = true; } + } - /// - /// Gets a value indicating whether target platform set. - /// - public bool TargetPlatformSet + /// + /// Gets a value indicating whether parallelism needs to be disabled by the adapters. + /// + public bool DisableParallelization + { + get { - get; - private set; + return _disableParallelization; } - /// - /// Gets a value indicating whether maximum parallelization count is set. - /// - public bool MaxCpuCountSet + set { - get; - private set; + _disableParallelization = value; + DisableParallelizationSet = true; } + } - /// - /// Gets a value indicating batch size is set - /// - public bool BatchSizeSet + /// + /// Gets or sets the Target platform this run is targeting. Possible values are x86|x64|arm|anycpu. + /// + public Architecture TargetPlatform + { + get { - get; - private set; + return _platform; } - /// - /// Gets a value indicating whether design mode is set. - /// - public bool DesignModeSet + set { - get; - private set; + _platform = value; + TargetPlatformSet = true; } + } - /// - /// Gets a value indicating whether disable appdomain is set. - /// - public bool DisableAppDomainSet + /// + /// Gets or sets the target Framework this run is targeting. + /// + public Framework TargetFramework + { + get { - get; - private set; + return _framework; } - /// - /// Gets a value indicating whether parallelism needs to be disabled by the adapters. - /// - public bool DisableParallelizationSet + set { - get; - private set; + _framework = value; + TargetFrameworkSet = true; } + } + /// + /// Gets or sets value indicating exit code when no tests are discovered or executed + /// + public bool TreatNoTestsAsError + { + get; + set; + } - /// - /// Gets a value indicating whether target framework set. - /// - public bool TargetFrameworkSet + /// + /// Gets or sets the target Framework this run is targeting. Possible values are Framework3.5|Framework4.0|Framework4.5 + /// + [Obsolete("Use TargetFramework instead")] + public FrameworkVersion TargetFrameworkVersion + { + get => (_framework?.Name) switch + { + Constants.DotNetFramework35 => FrameworkVersion.Framework35, + Constants.DotNetFramework40 => FrameworkVersion.Framework40, + Constants.DotNetFramework45 => FrameworkVersion.Framework45, + Constants.DotNetFrameworkCore10 => FrameworkVersion.FrameworkCore10, + Constants.DotNetFrameworkUap10 => FrameworkVersion.FrameworkUap10, + _ => Constants.DefaultFramework, + }; + + set { - get; - private set; + _framework = Framework.FromString(value.ToString()); + TargetFrameworkSet = true; } + } - /// - /// Gets a value indicating whether test adapters paths set. - /// - public bool TestAdaptersPathsSet + /// + /// Gets or sets the target device IP. For Phone this value is Device, for emulators "Mobile Emulator 10.0.15063.0 WVGA 4 inch 1GB" + /// + public string TargetDevice { get; set; } + + /// + /// Gets or sets the paths used for test adapters lookup in test platform. + /// + public string TestAdaptersPaths + { + get { - get; - private set; + return _testAdaptersPaths; } - /// - /// Gets a value indicating whether results directory is set. - /// - public bool ResultsDirectorySet + set { - get; - private set; + _testAdaptersPaths = value; + + if (_testAdaptersPaths != null) + { + TestAdaptersPathsSet = true; + } } + } - /// - /// Gets the binaries root. - /// - public string BinariesRoot { get; private set; } + /// + /// Gets or sets the execution thread apartment state. + /// + [CLSCompliant(false)] + public PlatformApartmentState ExecutionThreadApartmentState + { + get; + set; + } - /// - /// Collect source information - /// - public bool CollectSourceInformationSet { get; private set; } = false; + /// + /// Gets or sets a value indicating whether to treat the errors from test adapters as warnings. + /// + public bool TreatTestAdapterErrorsAsWarnings + { + get; + set; + } - /// - /// Default filter to use to filter tests - /// - public string TestCaseFilter { get; private set; } + /// + /// Gets a value indicating whether target platform set. + /// + public bool TargetPlatformSet + { + get; + private set; + } - /// Path to dotnet executable to be used to invoke testhost.dll. Specifying this will skip looking up testhost.exe and will force usage of the testhost.dll. - /// - public string DotnetHostPath { get; private set; } + /// + /// Gets a value indicating whether maximum parallelization count is set. + /// + public bool MaxCpuCountSet + { + get; + private set; + } - #endregion + /// + /// Gets a value indicating batch size is set + /// + public bool BatchSizeSet + { + get; + private set; + } -#if !NETSTANDARD1_0 - /// - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", - Justification = "XmlDocument.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] - public override XmlElement ToXml() - { - XmlDocument doc = new XmlDocument(); + /// + /// Gets a value indicating whether design mode is set. + /// + public bool DesignModeSet + { + get; + private set; + } - XmlElement root = doc.CreateElement(Constants.RunConfigurationSettingsName); + /// + /// Gets a value indicating whether disable appdomain is set. + /// + public bool DisableAppDomainSet + { + get; + private set; + } - XmlElement resultDirectory = doc.CreateElement("ResultsDirectory"); - resultDirectory.InnerXml = this.ResultsDirectory; - root.AppendChild(resultDirectory); + /// + /// Gets a value indicating whether parallelism needs to be disabled by the adapters. + /// + public bool DisableParallelizationSet + { + get; + private set; + } - XmlElement targetPlatform = doc.CreateElement("TargetPlatform"); - targetPlatform.InnerXml = this.TargetPlatform.ToString(); - root.AppendChild(targetPlatform); + /// + /// Gets a value indicating whether target framework set. + /// + public bool TargetFrameworkSet + { + get; + private set; + } - XmlElement maxCpuCount = doc.CreateElement("MaxCpuCount"); - maxCpuCount.InnerXml = this.MaxCpuCount.ToString(); - root.AppendChild(maxCpuCount); + /// + /// Gets a value indicating whether test adapters paths set. + /// + public bool TestAdaptersPathsSet + { + get; + private set; + } - XmlElement batchSize = doc.CreateElement("BatchSize"); - batchSize.InnerXml = this.BatchSize.ToString(); - root.AppendChild(batchSize); + /// + /// Gets a value indicating whether results directory is set. + /// + public bool ResultsDirectorySet + { + get; + private set; + } - XmlElement testSessionTimeout = doc.CreateElement("TestSessionTimeout"); - testSessionTimeout.InnerXml = this.TestSessionTimeout.ToString(); - root.AppendChild(testSessionTimeout); + /// + /// Gets the binaries root. + /// + public string BinariesRoot { get; private set; } - XmlElement designMode = doc.CreateElement("DesignMode"); - designMode.InnerXml = this.DesignMode.ToString(); - root.AppendChild(designMode); + /// + /// Collect source information + /// + public bool CollectSourceInformationSet { get; private set; } = false; - XmlElement inIsolation = doc.CreateElement("InIsolation"); - inIsolation.InnerXml = this.InIsolation.ToString(); - root.AppendChild(inIsolation); + /// + /// Default filter to use to filter tests + /// + public string TestCaseFilter { get; private set; } - XmlElement collectSourceInformation = doc.CreateElement("CollectSourceInformation"); - collectSourceInformation.InnerXml = this.ShouldCollectSourceInformation.ToString(); - root.AppendChild(collectSourceInformation); + /// Path to dotnet executable to be used to invoke testhost.dll. Specifying this will skip looking up testhost.exe and will force usage of the testhost.dll. + /// + public string DotnetHostPath { get; private set; } - XmlElement disableAppDomain = doc.CreateElement("DisableAppDomain"); - disableAppDomain.InnerXml = this.DisableAppDomain.ToString(); - root.AppendChild(disableAppDomain); + #endregion - XmlElement disableParallelization = doc.CreateElement("DisableParallelization"); - disableParallelization.InnerXml = this.DisableParallelization.ToString(); - root.AppendChild(disableParallelization); +#if !NETSTANDARD1_0 + /// + public override XmlElement ToXml() + { + XmlDocument doc = new(); - XmlElement targetFrameworkVersion = doc.CreateElement("TargetFrameworkVersion"); - targetFrameworkVersion.InnerXml = this.TargetFramework.ToString(); - root.AppendChild(targetFrameworkVersion); + XmlElement root = doc.CreateElement(Constants.RunConfigurationSettingsName); - XmlElement executionThreadApartmentState = doc.CreateElement("ExecutionThreadApartmentState"); - executionThreadApartmentState.InnerXml = this.ExecutionThreadApartmentState.ToString(); - root.AppendChild(executionThreadApartmentState); + XmlElement resultDirectory = doc.CreateElement("ResultsDirectory"); + resultDirectory.InnerXml = ResultsDirectory; + root.AppendChild(resultDirectory); - if (this.TestAdaptersPaths != null) - { - XmlElement testAdaptersPaths = doc.CreateElement("TestAdaptersPaths"); - testAdaptersPaths.InnerXml = this.TestAdaptersPaths; - root.AppendChild(testAdaptersPaths); - } + XmlElement targetPlatform = doc.CreateElement("TargetPlatform"); + targetPlatform.InnerXml = TargetPlatform.ToString(); + root.AppendChild(targetPlatform); - XmlElement treatTestAdapterErrorsAsWarnings = doc.CreateElement("TreatTestAdapterErrorsAsWarnings"); - treatTestAdapterErrorsAsWarnings.InnerXml = this.TreatTestAdapterErrorsAsWarnings.ToString(); - root.AppendChild(treatTestAdapterErrorsAsWarnings); + XmlElement maxCpuCount = doc.CreateElement("MaxCpuCount"); + maxCpuCount.InnerXml = MaxCpuCount.ToString(); + root.AppendChild(maxCpuCount); - if (this.BinariesRoot != null) - { - XmlElement binariesRoot = doc.CreateElement("BinariesRoot"); - binariesRoot.InnerXml = this.BinariesRoot; - root.AppendChild(binariesRoot); - } + XmlElement batchSize = doc.CreateElement("BatchSize"); + batchSize.InnerXml = BatchSize.ToString(); + root.AppendChild(batchSize); - if(!string.IsNullOrEmpty(this.TargetDevice)) - { - XmlElement targetDevice = doc.CreateElement("TargetDevice"); - targetDevice.InnerXml = this.TargetDevice; - root.AppendChild(targetDevice); - } + XmlElement testSessionTimeout = doc.CreateElement("TestSessionTimeout"); + testSessionTimeout.InnerXml = TestSessionTimeout.ToString(); + root.AppendChild(testSessionTimeout); - if (!string.IsNullOrEmpty(this.TestCaseFilter)) - { - XmlElement testCaseFilter = doc.CreateElement(nameof(TestCaseFilter)); - testCaseFilter.InnerXml = this.TestCaseFilter; - root.AppendChild(testCaseFilter); - } - - if (!string.IsNullOrEmpty(this.DotnetHostPath)) - { - XmlElement dotnetHostPath = doc.CreateElement(nameof(DotnetHostPath)); - dotnetHostPath.InnerXml = this.DotnetHostPath; - root.AppendChild(dotnetHostPath); - } + XmlElement designMode = doc.CreateElement("DesignMode"); + designMode.InnerXml = DesignMode.ToString(); + root.AppendChild(designMode); - if (this.TreatNoTestsAsError) - { - XmlElement treatAsError = doc.CreateElement(nameof(TreatNoTestsAsError)); - treatAsError.InnerText = this.TreatNoTestsAsError.ToString(); - root.AppendChild(treatAsError); - } + XmlElement inIsolation = doc.CreateElement("InIsolation"); + inIsolation.InnerXml = InIsolation.ToString(); + root.AppendChild(inIsolation); - return root; - } -#endif + XmlElement collectSourceInformation = doc.CreateElement("CollectSourceInformation"); + collectSourceInformation.InnerXml = ShouldCollectSourceInformation.ToString(); + root.AppendChild(collectSourceInformation); - /// - /// Loads RunConfiguration from XmlReader. - /// - /// XmlReader having run configuration node. - /// - public static RunConfiguration FromXml(XmlReader reader) - { - ValidateArg.NotNull(reader, nameof(reader)); - var runConfiguration = new RunConfiguration(); - var empty = reader.IsEmptyElement; + XmlElement disableAppDomain = doc.CreateElement("DisableAppDomain"); + disableAppDomain.InnerXml = DisableAppDomain.ToString(); + root.AppendChild(disableAppDomain); - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + XmlElement disableParallelization = doc.CreateElement("DisableParallelization"); + disableParallelization.InnerXml = DisableParallelization.ToString(); + root.AppendChild(disableParallelization); - // Process the fields in Xml elements - reader.Read(); - if (!empty) - { - while (reader.NodeType == XmlNodeType.Element) - { - string elementName = reader.Name; - switch (elementName) - { - case "ResultsDirectory": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - - string resultsDir = reader.ReadElementContentAsString(); - if (string.IsNullOrEmpty(resultsDir)) - { - throw new SettingsException( - string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsIncorrectValue, - Constants.RunConfigurationSettingsName, - resultsDir, - elementName)); - } + XmlElement targetFrameworkVersion = doc.CreateElement("TargetFrameworkVersion"); + targetFrameworkVersion.InnerXml = TargetFramework.ToString(); + root.AppendChild(targetFrameworkVersion); - runConfiguration.ResultsDirectory = resultsDir; - break; + XmlElement executionThreadApartmentState = doc.CreateElement("ExecutionThreadApartmentState"); + executionThreadApartmentState.InnerXml = ExecutionThreadApartmentState.ToString(); + root.AppendChild(executionThreadApartmentState); - case "CollectSourceInformation": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - string collectSourceInformationStr = reader.ReadElementContentAsString(); + if (TestAdaptersPaths != null) + { + XmlElement testAdaptersPaths = doc.CreateElement("TestAdaptersPaths"); + testAdaptersPaths.InnerXml = TestAdaptersPaths; + root.AppendChild(testAdaptersPaths); + } - bool bCollectSourceInformation = true; - if (!bool.TryParse(collectSourceInformationStr, out bCollectSourceInformation)) - { - throw new SettingsException(String.Format(CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, bCollectSourceInformation, elementName)); - } + XmlElement treatTestAdapterErrorsAsWarnings = doc.CreateElement("TreatTestAdapterErrorsAsWarnings"); + treatTestAdapterErrorsAsWarnings.InnerXml = TreatTestAdapterErrorsAsWarnings.ToString(); + root.AppendChild(treatTestAdapterErrorsAsWarnings); - runConfiguration.ShouldCollectSourceInformation = bCollectSourceInformation; - break; + if (BinariesRoot != null) + { + XmlElement binariesRoot = doc.CreateElement("BinariesRoot"); + binariesRoot.InnerXml = BinariesRoot; + root.AppendChild(binariesRoot); + } - case "MaxCpuCount": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + if (!string.IsNullOrEmpty(TargetDevice)) + { + XmlElement targetDevice = doc.CreateElement("TargetDevice"); + targetDevice.InnerXml = TargetDevice; + root.AppendChild(targetDevice); + } - string cpuCount = reader.ReadElementContentAsString(); - int count; - if (!int.TryParse(cpuCount, out count) || count < 0) - { - throw new SettingsException( - string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsIncorrectValue, - Constants.RunConfigurationSettingsName, - cpuCount, - elementName)); - } + if (!string.IsNullOrEmpty(TestCaseFilter)) + { + XmlElement testCaseFilter = doc.CreateElement(nameof(TestCaseFilter)); + testCaseFilter.InnerXml = TestCaseFilter; + root.AppendChild(testCaseFilter); + } - runConfiguration.MaxCpuCount = count; - break; + if (!string.IsNullOrEmpty(DotnetHostPath)) + { + XmlElement dotnetHostPath = doc.CreateElement(nameof(DotnetHostPath)); + dotnetHostPath.InnerXml = DotnetHostPath; + root.AppendChild(dotnetHostPath); + } - case "BatchSize": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + if (TreatNoTestsAsError) + { + XmlElement treatAsError = doc.CreateElement(nameof(TreatNoTestsAsError)); + treatAsError.InnerText = TreatNoTestsAsError.ToString(); + root.AppendChild(treatAsError); + } - string batchSize = reader.ReadElementContentAsString(); - long size; - if (!long.TryParse(batchSize, out size) || size < 0) + return root; + } +#endif + + /// + /// Loads RunConfiguration from XmlReader. + /// + /// XmlReader having run configuration node. + /// + public static RunConfiguration FromXml(XmlReader reader) + { + ValidateArg.NotNull(reader, nameof(reader)); + var runConfiguration = new RunConfiguration(); + var empty = reader.IsEmptyElement; + + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + + // Process the fields in Xml elements + reader.Read(); + if (!empty) + { + while (reader.NodeType == XmlNodeType.Element) + { + string elementName = reader.Name; + switch (elementName) + { + case "ResultsDirectory": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + + string resultsDir = reader.ReadElementContentAsString(); + if (string.IsNullOrEmpty(resultsDir)) + { + throw new SettingsException( + string.Format( + CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsIncorrectValue, + Constants.RunConfigurationSettingsName, + resultsDir, + elementName)); + } + + runConfiguration.ResultsDirectory = resultsDir; + break; + + case "CollectSourceInformation": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + string collectSourceInformationStr = reader.ReadElementContentAsString(); + + bool bCollectSourceInformation = true; + if (!bool.TryParse(collectSourceInformationStr, out bCollectSourceInformation)) + { + throw new SettingsException(String.Format(CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, bCollectSourceInformation, elementName)); + } + + runConfiguration.ShouldCollectSourceInformation = bCollectSourceInformation; + break; + + case "MaxCpuCount": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + + string cpuCount = reader.ReadElementContentAsString(); + if (!int.TryParse(cpuCount, out int count) || count < 0) + { + throw new SettingsException( + string.Format( + CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsIncorrectValue, + Constants.RunConfigurationSettingsName, + cpuCount, + elementName)); + } + + runConfiguration.MaxCpuCount = count; + break; + + case "BatchSize": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + + string batchSize = reader.ReadElementContentAsString(); + if (!long.TryParse(batchSize, out long size) || size < 0) + { + throw new SettingsException( + string.Format( + CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsIncorrectValue, + Constants.RunConfigurationSettingsName, + batchSize, + elementName)); + } + + runConfiguration.BatchSize = size; + break; + + case "TestSessionTimeout": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + + string testSessionTimeout = reader.ReadElementContentAsString(); + if (!long.TryParse(testSessionTimeout, out long sessionTimeout) || sessionTimeout < 0) + { + throw new SettingsException( + string.Format( + CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsIncorrectValue, + Constants.RunConfigurationSettingsName, + testSessionTimeout, + elementName)); + } + + runConfiguration.TestSessionTimeout = sessionTimeout; + break; + + case "DesignMode": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + + string designModeValueString = reader.ReadElementContentAsString(); + if (!bool.TryParse(designModeValueString, out bool designMode)) + { + throw new SettingsException(String.Format(CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, designModeValueString, elementName)); + } + runConfiguration.DesignMode = designMode; + break; + + case "InIsolation": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + + string inIsolationValueString = reader.ReadElementContentAsString(); + if (!bool.TryParse(inIsolationValueString, out bool inIsolation)) + { + throw new SettingsException(String.Format(CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, inIsolationValueString, elementName)); + } + runConfiguration.InIsolation = inIsolation; + break; + + case "DisableAppDomain": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + + string disableAppDomainValueString = reader.ReadElementContentAsString(); + if (!bool.TryParse(disableAppDomainValueString, out bool disableAppDomainCheck)) + { + throw new SettingsException(String.Format(CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, disableAppDomainValueString, elementName)); + } + runConfiguration.DisableAppDomain = disableAppDomainCheck; + break; + + case "DisableParallelization": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + + string disableParallelizationValueString = reader.ReadElementContentAsString(); + if (!bool.TryParse(disableParallelizationValueString, out bool disableParallelizationCheck)) + { + throw new SettingsException(string.Format(CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, disableParallelizationValueString, elementName)); + } + runConfiguration.DisableParallelization = disableParallelizationCheck; + break; + + case "TargetPlatform": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + Architecture archType; + string value = reader.ReadElementContentAsString(); + try + { + archType = (Architecture)Enum.Parse(typeof(Architecture), value, true); + // Ensure that the parsed value is actually in the enum, and that Default or AnyCpu are not provided. + if (!Enum.IsDefined(typeof(Architecture), archType) || Architecture.Default == archType || Architecture.AnyCPU == archType) { throw new SettingsException( string.Format( CultureInfo.CurrentCulture, Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, - batchSize, + value, elementName)); } - - runConfiguration.BatchSize = size; - break; - - case "TestSessionTimeout": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - - string testSessionTimeout = reader.ReadElementContentAsString(); - long sessionTimeout; - if (!long.TryParse(testSessionTimeout, out sessionTimeout) || sessionTimeout < 0) + } + catch (ArgumentException) + { + throw new SettingsException(string.Format(CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, value, elementName)); + } + + runConfiguration.TargetPlatform = archType; + break; + + case "TargetFrameworkVersion": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + Framework frameworkType; + value = reader.ReadElementContentAsString(); + try + { + frameworkType = Framework.FromString(value); + + if (frameworkType == null) { throw new SettingsException( string.Format( CultureInfo.CurrentCulture, Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, - testSessionTimeout, + value, elementName)); } - - runConfiguration.TestSessionTimeout = sessionTimeout; - break; - - case "DesignMode": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - - string designModeValueString = reader.ReadElementContentAsString(); - bool designMode; - if (!bool.TryParse(designModeValueString, out designMode)) - { - throw new SettingsException(String.Format(CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, designModeValueString, elementName)); - } - runConfiguration.DesignMode = designMode; - break; - - case "InIsolation": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - - string inIsolationValueString = reader.ReadElementContentAsString(); - bool inIsolation; - if (!bool.TryParse(inIsolationValueString, out inIsolation)) - { - throw new SettingsException(String.Format(CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, inIsolationValueString, elementName)); - } - runConfiguration.InIsolation = inIsolation; - break; - - case "DisableAppDomain": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - - string disableAppDomainValueString = reader.ReadElementContentAsString(); - bool disableAppDomainCheck; - if (!bool.TryParse(disableAppDomainValueString, out disableAppDomainCheck)) - { - throw new SettingsException(String.Format(CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, disableAppDomainValueString, elementName)); - } - runConfiguration.DisableAppDomain = disableAppDomainCheck; - break; - - case "DisableParallelization": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - - string disableParallelizationValueString = reader.ReadElementContentAsString(); - bool disableParallelizationCheck; - if (!bool.TryParse(disableParallelizationValueString, out disableParallelizationCheck)) - { - throw new SettingsException(string.Format(CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, disableParallelizationValueString, elementName)); - } - runConfiguration.DisableParallelization = disableParallelizationCheck; - break; - - case "TargetPlatform": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - Architecture archType; - string value = reader.ReadElementContentAsString(); - try - { - archType = (Architecture)Enum.Parse(typeof(Architecture), value, true); - // Ensure that the parsed value is actually in the enum, and that Default or AnyCpu are not provided. - if (!Enum.IsDefined(typeof(Architecture), archType) || Architecture.Default == archType || Architecture.AnyCPU == archType) - { - throw new SettingsException( - string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsIncorrectValue, - Constants.RunConfigurationSettingsName, - value, - elementName)); - } - } - catch (ArgumentException) - { - throw new SettingsException(string.Format(CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, value, elementName)); - } - - runConfiguration.TargetPlatform = archType; - break; - - case "TargetFrameworkVersion": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - Framework frameworkType; - value = reader.ReadElementContentAsString(); - try - { - frameworkType = Framework.FromString(value); - - if (frameworkType == null) - { - throw new SettingsException( - string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsIncorrectValue, - Constants.RunConfigurationSettingsName, - value, - elementName)); - } - } - catch (ArgumentException) - { - throw new SettingsException(string.Format(CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, value, elementName)); - } - - runConfiguration.TargetFramework = frameworkType; - break; - - case "TestAdaptersPaths": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - runConfiguration.TestAdaptersPaths = reader.ReadElementContentAsString(); - break; - - case "TreatTestAdapterErrorsAsWarnings": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - bool treatTestAdapterErrorsAsWarnings = false; - - value = reader.ReadElementContentAsString(); - - try - { - treatTestAdapterErrorsAsWarnings = bool.Parse(value); - } - catch (ArgumentException) - { - throw new SettingsException(string.Format(CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, value, elementName)); - } - catch (FormatException) - { - throw new SettingsException(string.Format(CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, value, elementName)); - } - - runConfiguration.TreatTestAdapterErrorsAsWarnings = treatTestAdapterErrorsAsWarnings; - break; - - case "SolutionDirectory": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - string solutionDirectory = reader.ReadElementContentAsString(); + } + catch (ArgumentException) + { + throw new SettingsException(string.Format(CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, value, elementName)); + } + + runConfiguration.TargetFramework = frameworkType; + break; + + case "TestAdaptersPaths": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + runConfiguration.TestAdaptersPaths = reader.ReadElementContentAsString(); + break; + + case "TreatTestAdapterErrorsAsWarnings": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + bool treatTestAdapterErrorsAsWarnings = false; + + value = reader.ReadElementContentAsString(); + + try + { + treatTestAdapterErrorsAsWarnings = bool.Parse(value); + } + catch (ArgumentException) + { + throw new SettingsException(string.Format(CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, value, elementName)); + } + catch (FormatException) + { + throw new SettingsException(string.Format(CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, value, elementName)); + } + + runConfiguration.TreatTestAdapterErrorsAsWarnings = treatTestAdapterErrorsAsWarnings; + break; + + case "SolutionDirectory": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + string solutionDirectory = reader.ReadElementContentAsString(); #if !NETSTANDARD1_0 - solutionDirectory = Environment.ExpandEnvironmentVariables(solutionDirectory); + solutionDirectory = Environment.ExpandEnvironmentVariables(solutionDirectory); #endif - if (string.IsNullOrEmpty(solutionDirectory) + if (string.IsNullOrEmpty(solutionDirectory) #if !NETSTANDARD1_0 - || !Directory.Exists(solutionDirectory) + || !System.IO.Directory.Exists(solutionDirectory) #endif - ) - { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error(string.Format(CultureInfo.CurrentCulture, Resources.Resources.SolutionDirectoryNotExists, solutionDirectory)); - } - - solutionDirectory = null; - } - - runConfiguration.SolutionDirectory = solutionDirectory; - - break; - - case "BinariesRoot": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - runConfiguration.BinariesRoot = reader.ReadElementContentAsString(); - break; - - case "ExecutionThreadApartmentState": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - string executionThreadApartmentState = reader.ReadElementContentAsString(); - PlatformApartmentState apartmentState; - if (!Enum.TryParse(executionThreadApartmentState, out apartmentState)) + ) + { + if (EqtTrace.IsErrorEnabled) { - throw new SettingsException( - string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsIncorrectValue, - Constants.RunConfigurationSettingsName, - executionThreadApartmentState, - elementName)); + EqtTrace.Error(string.Format(CultureInfo.CurrentCulture, Resources.Resources.SolutionDirectoryNotExists, solutionDirectory)); } - runConfiguration.ExecutionThreadApartmentState = apartmentState; - break; - - case "TargetDevice": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - runConfiguration.TargetDevice = reader.ReadElementContentAsString(); - break; - - case "TestCaseFilter": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - runConfiguration.TestCaseFilter = reader.ReadElementContentAsString(); - break; - - case "DotNetHostPath": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - runConfiguration.DotnetHostPath = reader.ReadElementContentAsString(); - break; - case "TreatNoTestsAsError": - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - string treatNoTestsAsErrorValueString = reader.ReadElementContentAsString(); - bool treatNoTestsAsError; - if (!bool.TryParse(treatNoTestsAsErrorValueString, out treatNoTestsAsError)) - { - throw new SettingsException(string.Format(CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, treatNoTestsAsErrorValueString, elementName)); - } - runConfiguration.TreatNoTestsAsError = treatNoTestsAsError; - break; + solutionDirectory = null; + } + + runConfiguration.SolutionDirectory = solutionDirectory; + + break; + + case "BinariesRoot": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + runConfiguration.BinariesRoot = reader.ReadElementContentAsString(); + break; + + case "ExecutionThreadApartmentState": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + string executionThreadApartmentState = reader.ReadElementContentAsString(); + if (!Enum.TryParse(executionThreadApartmentState, out PlatformApartmentState apartmentState)) + { + throw new SettingsException( + string.Format( + CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsIncorrectValue, + Constants.RunConfigurationSettingsName, + executionThreadApartmentState, + elementName)); + } + + runConfiguration.ExecutionThreadApartmentState = apartmentState; + break; + + case "TargetDevice": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + runConfiguration.TargetDevice = reader.ReadElementContentAsString(); + break; + + case "TestCaseFilter": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + runConfiguration.TestCaseFilter = reader.ReadElementContentAsString(); + break; + + case "DotNetHostPath": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + runConfiguration.DotnetHostPath = reader.ReadElementContentAsString(); + break; + case "TreatNoTestsAsError": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + string treatNoTestsAsErrorValueString = reader.ReadElementContentAsString(); + if (!bool.TryParse(treatNoTestsAsErrorValueString, out bool treatNoTestsAsError)) + { + throw new SettingsException(string.Format(CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, treatNoTestsAsErrorValueString, elementName)); + } + runConfiguration.TreatNoTestsAsError = treatNoTestsAsError; + break; - default: - // Ignore a runsettings element that we don't understand. It could occur in the case - // the test runner is of a newer version, but the test host is of an earlier version. - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Warning( - string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsXmlElement, - Constants.RunConfigurationSettingsName, - reader.Name)); - } - reader.Skip(); - break; - } + default: + // Ignore a runsettings element that we don't understand. It could occur in the case + // the test runner is of a newer version, but the test host is of an earlier version. + if (EqtTrace.IsErrorEnabled) + { + EqtTrace.Warning( + string.Format( + CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsXmlElement, + Constants.RunConfigurationSettingsName, + reader.Name)); + } + reader.Skip(); + break; } - - reader.ReadEndElement(); } - return runConfiguration; + reader.ReadEndElement(); } + + return runConfiguration; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/SettingsException.cs b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/SettingsException.cs index 4bc746f0c2..1ed71f876f 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/SettingsException.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/SettingsException.cs @@ -1,61 +1,60 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; #if NETFRAMEWORK - using System.Runtime.Serialization; +using System.Runtime.Serialization; #endif - /// - /// Exception thrown by Run Settings when an error with a settings provider - /// is encountered. - /// +/// +/// Exception thrown by Run Settings when an error with a settings provider +/// is encountered. +/// #if NETFRAMEWORK - [Serializable] +[Serializable] #endif - public class SettingsException : Exception +public class SettingsException : Exception +{ + #region Constructors + + /// + /// Default Constructor + /// + public SettingsException() : base() + { + } + + /// + /// Initializes with the message. + /// + /// Message for the exception. + public SettingsException(string message) + : base(message) + { + } + + /// + /// Initializes with message and inner exception. + /// + /// Message for the exception. + /// The inner exception. + public SettingsException(string message, Exception innerException) + : base(message, innerException) { - #region Constructors - - /// - /// Default Constructor - /// - public SettingsException() : base() - { - } - - /// - /// Initializes with the message. - /// - /// Message for the exception. - public SettingsException(string message) - : base(message) - { - } - - /// - /// Initializes with message and inner exception. - /// - /// Message for the exception. - /// The inner exception. - public SettingsException(string message, Exception innerException) - : base(message, innerException) - { - } + } #if NETFRAMEWORK - /// - /// Serialization constructor. - /// - protected SettingsException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } + /// + /// Serialization constructor. + /// + protected SettingsException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } #endif - #endregion - } -} + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/SettingsNameAttribute.cs b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/SettingsNameAttribute.cs index 8218511cd7..22c3783451 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/SettingsNameAttribute.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/SettingsNameAttribute.cs @@ -1,44 +1,43 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; + +using Resources; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources; +/// +/// Attribute applied to ISettingsProviders to associate it with a settings +/// name. This name will be used to request the settings from the RunSettings. +/// +[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] +public sealed class SettingsNameAttribute : Attribute +{ + #region Constructor /// - /// Attribute applied to ISettingsProviders to associate it with a settings - /// name. This name will be used to request the settings from the RunSettings. + /// Initializes with the name of the settings. /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] - public sealed class SettingsNameAttribute : Attribute + /// Name of the settings + public SettingsNameAttribute(string settingsName) { - #region Constructor - - /// - /// Initializes with the name of the settings. - /// - /// Name of the settings - public SettingsNameAttribute(string settingsName) + if (string.IsNullOrWhiteSpace(settingsName)) { - if (string.IsNullOrWhiteSpace(settingsName)) - { - throw new ArgumentException(CommonResources.CannotBeNullOrEmpty, nameof(settingsName)); - } - - SettingsName = settingsName; + throw new ArgumentException(CommonResources.CannotBeNullOrEmpty, nameof(settingsName)); } - #endregion + SettingsName = settingsName; + } - #region Properties + #endregion - /// - /// The name of the settings. - /// - public string SettingsName { get; private set; } + #region Properties - #endregion - } -} + /// + /// The name of the settings. + /// + public string SettingsName { get; private set; } + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/TestRunParameters.cs b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/TestRunParameters.cs index b263ee864c..fbc1a00a06 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/TestRunParameters.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/TestRunParameters.cs @@ -1,76 +1,75 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Xml; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Xml; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using Utilities; +/// +/// This class deals with the run settings, Test Run Parameters node and the extracting of Key Value Pair's from the parameters listed. +/// +internal class TestRunParameters +{ /// - /// This class deals with the run settings, Test Run Parameters node and the extracting of Key Value Pair's from the parameters listed. + /// Get the test run parameters from the provided reader. /// - internal class TestRunParameters + /// The reader. + /// The dictionary of test run parameters. + /// Throws when format is incorrect. + internal static Dictionary FromXml(XmlReader reader) { - /// - /// Get the test run parameters from the provided reader. - /// - /// The reader. - /// The dictionary of test run parameters. - /// Throws when format is incorrect. - internal static Dictionary FromXml(XmlReader reader) + var testParameters = new Dictionary(); + + if (!reader.IsEmptyElement) { - var testParameters = new Dictionary(); + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + reader.Read(); - if (!reader.IsEmptyElement) + while (reader.NodeType == XmlNodeType.Element) { - XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - reader.Read(); - - while (reader.NodeType == XmlNodeType.Element) + string elementName = reader.Name; + switch (elementName) { - string elementName = reader.Name; - switch (elementName) - { - case "Parameter": - string paramName = null; - string paramValue = null; - for (int attIndex = 0; attIndex < reader.AttributeCount; attIndex++) + case "Parameter": + string paramName = null; + string paramValue = null; + for (int attIndex = 0; attIndex < reader.AttributeCount; attIndex++) + { + reader.MoveToAttribute(attIndex); + if (string.Equals(reader.Name, "Name", StringComparison.OrdinalIgnoreCase)) { - reader.MoveToAttribute(attIndex); - if (string.Equals(reader.Name, "Name", StringComparison.OrdinalIgnoreCase)) - { - paramName = reader.Value; - } - else if (string.Equals(reader.Name, "Value", StringComparison.OrdinalIgnoreCase)) - { - paramValue = reader.Value; - } + paramName = reader.Value; } - - if (paramName != null && paramValue != null) + else if (string.Equals(reader.Name, "Value", StringComparison.OrdinalIgnoreCase)) { - testParameters[paramName] = paramValue; + paramValue = reader.Value; } + } - break; - default: - throw new SettingsException( - string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsXmlElement, - Constants.TestRunParametersName, - reader.Name)); - } + if (paramName != null && paramValue != null) + { + testParameters[paramName] = paramValue; + } - reader.Read(); + break; + default: + throw new SettingsException( + string.Format( + CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsXmlElement, + Constants.TestRunParametersName, + reader.Name)); } - } - return testParameters; + reader.Read(); + } } + + return testParameters; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/TestRunSettings.cs b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/TestRunSettings.cs index 1efd70b7a9..574760a702 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/TestRunSettings.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/TestRunSettings.cs @@ -1,52 +1,51 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +#if !NETSTANDARD1_0 +using System.Xml; +#endif + +/// +/// Stores information about a test settings. +/// +public abstract class TestRunSettings { - using System.Xml; + + #region Constructor /// - /// Stores information about a test settings. + /// Initializes with the name of the test case. /// - public abstract class TestRunSettings + /// The name of the test case. + protected TestRunSettings(string name) { - private string name; - - #region Constructor - - /// - /// Initializes with the name of the test case. - /// - /// The name of the test case. - protected TestRunSettings(string name) - { - ValidateArg.NotNullOrEmpty(name, nameof(name)); + ValidateArg.NotNullOrEmpty(name, nameof(name)); - this.name = name; - } + Name = name; + } - #endregion + #endregion - #region Properties + #region Properties - /// - /// Gets the name of the test settings. - /// Do not put a private setter on this - /// Chutzpah adapter checks for setters of all properties and it throws error if its private - /// during RunSettings.LoadSection() call - /// TODO: Communicate to Chutzpah and fix it - /// - public string Name => name; + /// + /// Gets the name of the test settings. + /// Do not put a private setter on this + /// Chutzpah adapter checks for setters of all properties and it throws error if its private + /// during RunSettings.LoadSection() call + /// TODO: Communicate to Chutzpah and fix it + /// + public string Name { get; private set; } - #endregion + #endregion #if !NETSTANDARD1_0 - /// - /// Converter the setting to be an XmlElement. - /// - /// The Xml element for the run settings provided. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes", Justification = "XmlElement is required in the data collector.")] - public abstract XmlElement ToXml(); + /// + /// Converter the setting to be an XmlElement. + /// + /// The Xml element for the run settings provided. + public abstract XmlElement ToXml(); #endif - } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/TestCase.cs b/src/Microsoft.TestPlatform.ObjectModel/TestCase.cs index 809f559abf..199e81952a 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/TestCase.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/TestCase.cs @@ -1,433 +1,417 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.IO; +using System.Runtime.Serialization; +using System.Collections.Generic; +using System.Linq; + +using Utilities; + +/// +/// Stores information about a test case. +/// +[DataContract] +public sealed class TestCase : TestObject { - using System; - using System.IO; - using System.Runtime.Serialization; - using System.Collections.Generic; - using System.Linq; + private Guid _defaultId = Guid.Empty; + private Guid _id; + private string _displayName; + private string _fullyQualifiedName; + private string _source; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; + #region Constructor /// - /// Stores information about a test case. + /// Initializes a new instance of the class. /// - [DataContract] - public sealed class TestCase : TestObject + /// This constructor doesn't perform any parameter validation, it is meant to be used for serialization."/> + public TestCase() { - /// - /// LocalExtensionData which can be used by Adapter developers for local transfer of extended properties. - /// Note that this data is available only for in-Proc execution, and may not be available for OutProc executors - /// - private object localExtensionData; - - private Guid defaultId = Guid.Empty; - private Guid id; - private string displayName; - private string fullyQualifiedName; - private string source; - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - /// This constructor doesn't perform any parameter validation, it is meant to be used for serialization."/> - public TestCase() - { - // Default constructor for Serialization. - } + // Default constructor for Serialization. + } - /// - /// Initializes a new instance of the class. - /// - /// - /// Fully qualified name of the test case. - /// - /// - /// The Uri of the executor to use for running this test. - /// - /// - /// Test container source from which the test is discovered. - /// - public TestCase(string fullyQualifiedName, Uri executorUri, string source) - { - ValidateArg.NotNullOrEmpty(fullyQualifiedName, nameof(fullyQualifiedName)); - ValidateArg.NotNull(executorUri, nameof(executorUri)); - ValidateArg.NotNullOrEmpty(source, nameof(source)); - - this.FullyQualifiedName = fullyQualifiedName; - this.ExecutorUri = executorUri; - this.Source = source; - this.LineNumber = -1; - } - #endregion + /// + /// Initializes a new instance of the class. + /// + /// + /// Fully qualified name of the test case. + /// + /// + /// The Uri of the executor to use for running this test. + /// + /// + /// Test container source from which the test is discovered. + /// + public TestCase(string fullyQualifiedName, Uri executorUri, string source) + { + ValidateArg.NotNullOrEmpty(fullyQualifiedName, nameof(fullyQualifiedName)); + ValidateArg.NotNull(executorUri, nameof(executorUri)); + ValidateArg.NotNullOrEmpty(source, nameof(source)); + + FullyQualifiedName = fullyQualifiedName; + ExecutorUri = executorUri; + Source = source; + LineNumber = -1; + } + #endregion - #region Properties + #region Properties - /// - /// LocalExtensionData which can be used by Adapter developers for local transfer of extended properties. - /// Note that this data is available only for in-Proc execution, and may not be available for OutProc executors - /// - public object LocalExtensionData - { - get { return localExtensionData; } - set { localExtensionData = value; } - } + /// + /// LocalExtensionData which can be used by Adapter developers for local transfer of extended properties. + /// Note that this data is available only for in-Proc execution, and may not be available for OutProc executors + /// + public object LocalExtensionData { get; set; } - /// - /// Gets or sets the id of the test case. - /// - [DataMember] - public Guid Id + /// + /// Gets or sets the id of the test case. + /// + [DataMember] + public Guid Id + { + get { - get + if (_id == Guid.Empty) { - if (this.id == Guid.Empty) + if (_defaultId == Guid.Empty) { - if (this.defaultId == Guid.Empty) - { - this.defaultId = this.GetTestId(); - } - - return this.defaultId; + _defaultId = GetTestId(); } - return this.id; + return _defaultId; } - set - { - this.id = value; - } + return _id; } - /// - /// Gets or sets the fully qualified name of the test case. - /// - [DataMember] - public string FullyQualifiedName + set { - get => fullyQualifiedName; - - // defaultId should be reset as it is based on FullyQualifiedName and Source. - set => SetVariableAndResetId(ref fullyQualifiedName, value); + _id = value; } + } - /// - /// Gets or sets the display name of the test case. - /// - [DataMember] - public string DisplayName - { - get - { - if (string.IsNullOrEmpty(this.displayName)) - { - return this.GetFullyQualifiedName(); - } + /// + /// Gets or sets the fully qualified name of the test case. + /// + [DataMember] + public string FullyQualifiedName + { + get => _fullyQualifiedName; - return this.displayName; - } - set - { - this.displayName = value; - } - } + // defaultId should be reset as it is based on FullyQualifiedName and Source. + set => SetVariableAndResetId(ref _fullyQualifiedName, value); + } - /// - /// Gets or sets the Uri of the Executor to use for running this test. - /// - [DataMember] - public Uri ExecutorUri + /// + /// Gets or sets the display name of the test case. + /// + [DataMember] + public string DisplayName + { + get { - get; set; + return string.IsNullOrEmpty(_displayName) ? GetFullyQualifiedName() : _displayName; } + set + { + _displayName = value; + } + } + + /// + /// Gets or sets the Uri of the Executor to use for running this test. + /// + [DataMember] + public Uri ExecutorUri + { + get; set; + } - /// - /// Gets the test container source from which the test is discovered. - /// - [DataMember] - public string Source + /// + /// Gets the test container source from which the test is discovered. + /// + [DataMember] + public string Source + { + get { - get - { - return this.source; - } - set - { - this.source = value; + return _source; + } + set + { + _source = value; - // defaultId should be reset as it is based on FullyQualifiedName and Source. - this.defaultId = Guid.Empty; - } + // defaultId should be reset as it is based on FullyQualifiedName and Source. + _defaultId = Guid.Empty; } + } + + /// + /// Gets or sets the source code file path of the test. + /// + [DataMember] + public string CodeFilePath + { + get; set; + } - /// - /// Gets or sets the source code file path of the test. - /// - [DataMember] - public string CodeFilePath + /// + /// Gets or sets the line number of the test. + /// + [DataMember] + public int LineNumber + { + get; set; + } + + /// + /// Returns the TestProperties currently specified in this TestObject. + /// + public override IEnumerable Properties + { + get { - get; set; + return TestCaseProperties.Properties.Concat(base.Properties); } + } + + #endregion + + #region private methods - /// - /// Gets or sets the line number of the test. - /// - [DataMember] - public int LineNumber + /// + /// Creates a Id of TestCase + /// + /// Guid test id + private Guid GetTestId() + { + // To generate id hash "ExecutorUri + source + Name"; + + // If source is a file name then just use the filename for the identifier since the + // file might have moved between discovery and execution (in appx mode for example) + // This is not elegant because the Source contents should be a black box to the framework. + // For example in the database adapter case this is not a file path. + string source = Source; + + // As discussed with team, we found no scenario for netcore, & fullclr where the Source is not present where ID is generated, + // which means we would always use FileName to generate ID. In cases where somehow Source Path contained garbage character the API Path.GetFileName() + // we are simply returning original input. + // For UWP where source during discovery, & during execution can be on different machine, in such case we should always use Path.GetFileName() + try { - get; set; + // If source name is malformed, GetFileName API will throw exception, so use same input malformed string to generate ID + source = Path.GetFileName(source); } - - /// - /// Returns the TestProperties currently specified in this TestObject. - /// - public override IEnumerable Properties + catch { - get - { - return TestCaseProperties.Properties.Concat(base.Properties); - } + // do nothing } - #endregion + // We still need to handle parameters in the case of a Theory or TestGroup of test cases that are only + // distinguished by parameters. + var testcaseFullName = ExecutorUri + source; - #region private methods + // If ManagedType and ManagedMethod properties are filled than TestId should be based on those. + testcaseFullName += GetFullyQualifiedName(); - /// - /// Creates a Id of TestCase - /// - /// Guid test id - private Guid GetTestId() - { - // To generate id hash "ExecutorUri + source + Name"; - - // If source is a file name then just use the filename for the identifier since the - // file might have moved between discovery and execution (in appx mode for example) - // This is not elegant because the Source contents should be a black box to the framework. - // For example in the database adapter case this is not a file path. - string source = this.Source; - - // As discussed with team, we found no scenario for netcore, & fullclr where the Source is not present where ID is generated, - // which means we would always use FileName to generate ID. In cases where somehow Source Path contained garbage character the API Path.GetFileName() - // we are simply returning original input. - // For UWP where source during discovery, & during execution can be on different machine, in such case we should always use Path.GetFileName() - try - { - // If source name is malformed, GetFileName API will throw exception, so use same input malformed string to generate ID - source = Path.GetFileName(source); - } - catch - { - // do nothing - } + return EqtHash.GuidFromString(testcaseFullName); + } + + private void SetVariableAndResetId(ref T variable, T value) + { + variable = value; + _defaultId = Guid.Empty; + } - // We still need to handle parameters in the case of a Theory or TestGroup of test cases that are only - // distinguished by parameters. - var testcaseFullName = this.ExecutorUri + source; + private void SetPropertyAndResetId(TestProperty property, T value) + { + SetPropertyValue(property, value); + _defaultId = Guid.Empty; + } - // If ManagedType and ManagedMethod properties are filled than TestId should be based on those. - testcaseFullName += this.GetFullyQualifiedName(); + #endregion - return EqtHash.GuidFromString(testcaseFullName); - } + #region Protected Methods - private void SetVariableAndResetId(ref T variable, T value) - { - variable = value; - this.defaultId = Guid.Empty; - } + /// + /// Return TestProperty's value + /// + /// + protected override object ProtectedGetPropertyValue(TestProperty property, object defaultValue) + { + ValidateArg.NotNull(property, nameof(property)); - private void SetPropertyAndResetId(TestProperty property, T value) + switch (property.Id) { - SetPropertyValue(property, value); - this.defaultId = Guid.Empty; + case "TestCase.CodeFilePath": + return CodeFilePath; + case "TestCase.DisplayName": + return DisplayName; + case "TestCase.ExecutorUri": + return ExecutorUri; + case "TestCase.FullyQualifiedName": + return FullyQualifiedName; + case "TestCase.Id": + return Id; + case "TestCase.LineNumber": + return LineNumber; + case "TestCase.Source": + return Source; } - #endregion + // It is a custom test case property. Should be retrieved from the TestObject store. + return base.ProtectedGetPropertyValue(property, defaultValue); + } - #region Protected Methods + /// + /// Set TestProperty's value + /// + protected override void ProtectedSetPropertyValue(TestProperty property, object value) + { + ValidateArg.NotNull(property, nameof(property)); - /// - /// Return TestProperty's value - /// - /// - protected override object ProtectedGetPropertyValue(TestProperty property, object defaultValue) + switch (property.Id) { - ValidateArg.NotNull(property, nameof(property)); + case "TestCase.CodeFilePath": + CodeFilePath = value as string; + return; - switch (property.Id) - { - case "TestCase.CodeFilePath": - return this.CodeFilePath; - case "TestCase.DisplayName": - return this.DisplayName; - case "TestCase.ExecutorUri": - return this.ExecutorUri; - case "TestCase.FullyQualifiedName": - return this.FullyQualifiedName; - case "TestCase.Id": - return this.Id; - case "TestCase.LineNumber": - return this.LineNumber; - case "TestCase.Source": - return this.Source; - } + case "TestCase.DisplayName": + DisplayName = value as string; + return; - // It is a custom test case property. Should be retrieved from the TestObject store. - return base.ProtectedGetPropertyValue(property, defaultValue); - } + case "TestCase.ExecutorUri": + ExecutorUri = value as Uri ?? new Uri(value as string); + return; - /// - /// Set TestProperty's value - /// - protected override void ProtectedSetPropertyValue(TestProperty property, object value) - { - ValidateArg.NotNull(property, nameof(property)); + case "TestCase.FullyQualifiedName": + FullyQualifiedName = value as string; + return; - switch (property.Id) - { - case "TestCase.CodeFilePath": - this.CodeFilePath = value as string; - return; + case "TestCase.Id": + Id = value is Guid guid ? guid : Guid.Parse(value as string); + return; - case "TestCase.DisplayName": - this.DisplayName = value as string; - return; + case "TestCase.LineNumber": + LineNumber = (int)value; + return; - case "TestCase.ExecutorUri": - this.ExecutorUri = value as Uri ?? new Uri(value as string); - return; + case "TestCase.Source": + Source = value as string; + return; + } - case "TestCase.FullyQualifiedName": - this.FullyQualifiedName = value as string; - return; + // It is a custom test case property. Should be set in the TestObject store. + base.ProtectedSetPropertyValue(property, value); + } - case "TestCase.Id": - this.Id = value is Guid ? (Guid)value : Guid.Parse(value as string); - return; + #endregion - case "TestCase.LineNumber": - this.LineNumber = (int)value; - return; + #region ManagedName and ManagedType implementations - case "TestCase.Source": - this.Source = value as string; - return; - } + private static readonly TestProperty ManagedTypeProperty = TestProperty.Register("TestCase.ManagedType", "ManagedType", string.Empty, string.Empty, typeof(string), o => !string.IsNullOrWhiteSpace(o as string), TestPropertyAttributes.Hidden, typeof(TestCase)); + private static readonly TestProperty ManagedMethodProperty = TestProperty.Register("TestCase.ManagedMethod", "ManagedMethod", string.Empty, string.Empty, typeof(string), o => !string.IsNullOrWhiteSpace(o as string), TestPropertyAttributes.Hidden, typeof(TestCase)); - // It is a custom test case property. Should be set in the TestObject store. - base.ProtectedSetPropertyValue(property, value); - } + private bool ContainsManagedMethodAndType => !string.IsNullOrWhiteSpace(ManagedMethod) && !string.IsNullOrWhiteSpace(ManagedType); - #endregion + private string ManagedType + { + get => GetPropertyValue(ManagedTypeProperty, null); + set => SetPropertyAndResetId(ManagedTypeProperty, value); + } - #region ManagedName and ManagedType implementations + private string ManagedMethod + { + get => GetPropertyValue(ManagedMethodProperty, null); + set => SetPropertyAndResetId(ManagedMethodProperty, value); + } - private static readonly TestProperty ManagedTypeProperty = TestProperty.Register("TestCase.ManagedType", "ManagedType", string.Empty, string.Empty, typeof(string), o => !string.IsNullOrWhiteSpace(o as string), TestPropertyAttributes.Hidden, typeof(TestCase)); - private static readonly TestProperty ManagedMethodProperty = TestProperty.Register("TestCase.ManagedMethod", "ManagedMethod", string.Empty, string.Empty, typeof(string), o => !string.IsNullOrWhiteSpace(o as string), TestPropertyAttributes.Hidden, typeof(TestCase)); + private string GetFullyQualifiedName() => ContainsManagedMethodAndType ? $"{ManagedType}.{ManagedMethod}" : FullyQualifiedName; - private bool ContainsManagedMethodAndType => !string.IsNullOrWhiteSpace(ManagedMethod) && !string.IsNullOrWhiteSpace(ManagedType); + #endregion - private string ManagedType - { - get => GetPropertyValue(ManagedTypeProperty, null); - set => SetPropertyAndResetId(ManagedTypeProperty, value); - } + /// + public override string ToString() => GetFullyQualifiedName(); +} - private string ManagedMethod - { - get => GetPropertyValue(ManagedMethodProperty, null); - set => SetPropertyAndResetId(ManagedMethodProperty, value); - } +/// +/// Well-known TestCase properties +/// +public static class TestCaseProperties +{ + #region Private Constants - private string GetFullyQualifiedName() => ContainsManagedMethodAndType ? $"{ManagedType}.{ManagedMethod}" : FullyQualifiedName; + /// + /// These are the core Test properties and may be available in commandline/TeamBuild to filter tests. + /// These Property names should not be localized. + /// + private const string IdLabel = "Id"; + private const string FullyQualifiedNameLabel = "FullyQualifiedName"; + private const string NameLabel = "Name"; + private const string ExecutorUriLabel = "Executor Uri"; + private const string SourceLabel = "Source"; + private const string FilePathLabel = "File Path"; + private const string LineNumberLabel = "Line Number"; + + #endregion + + public static readonly TestProperty Id = TestProperty.Register("TestCase.Id", IdLabel, string.Empty, string.Empty, typeof(Guid), ValidateGuid, TestPropertyAttributes.Hidden, typeof(TestCase)); + public static readonly TestProperty FullyQualifiedName = TestProperty.Register("TestCase.FullyQualifiedName", FullyQualifiedNameLabel, string.Empty, string.Empty, typeof(string), ValidateName, TestPropertyAttributes.Hidden, typeof(TestCase)); + public static readonly TestProperty DisplayName = TestProperty.Register("TestCase.DisplayName", NameLabel, string.Empty, string.Empty, typeof(string), ValidateDisplay, TestPropertyAttributes.None, typeof(TestCase)); + public static readonly TestProperty ExecutorUri = TestProperty.Register("TestCase.ExecutorUri", ExecutorUriLabel, string.Empty, string.Empty, typeof(Uri), ValidateExecutorUri, TestPropertyAttributes.Hidden, typeof(TestCase)); + public static readonly TestProperty Source = TestProperty.Register("TestCase.Source", SourceLabel, typeof(string), typeof(TestCase)); + public static readonly TestProperty CodeFilePath = TestProperty.Register("TestCase.CodeFilePath", FilePathLabel, typeof(string), typeof(TestCase)); + public static readonly TestProperty LineNumber = TestProperty.Register("TestCase.LineNumber", LineNumberLabel, typeof(int), TestPropertyAttributes.Hidden, typeof(TestCase)); + + internal static TestProperty[] Properties { get; } = + { + CodeFilePath, + DisplayName, + ExecutorUri, + FullyQualifiedName, + Id, + LineNumber, + Source + }; + + private static bool ValidateName(object value) + { + return !string.IsNullOrWhiteSpace((string)value); + } - #endregion + private static bool ValidateDisplay(object value) + { + // only check for null and pass the rest up to UI for validation + return value != null; + } - /// - public override string ToString() => this.GetFullyQualifiedName(); + private static bool ValidateExecutorUri(object value) + { + return value != null; } - /// - /// Well-known TestCase properties - /// - public static class TestCaseProperties + private static bool ValidateGuid(object value) { - #region Private Constants - - /// - /// These are the core Test properties and may be available in commandline/TeamBuild to filter tests. - /// These Property names should not be localized. - /// - private const string IdLabel = "Id"; - private const string FullyQualifiedNameLabel = "FullyQualifiedName"; - private const string NameLabel = "Name"; - private const string ExecutorUriLabel = "Executor Uri"; - private const string SourceLabel = "Source"; - private const string FilePathLabel = "File Path"; - private const string LineNumberLabel = "Line Number"; - - #endregion - - public static readonly TestProperty Id = TestProperty.Register("TestCase.Id", IdLabel, string.Empty, string.Empty, typeof(Guid), ValidateGuid, TestPropertyAttributes.Hidden, typeof(TestCase)); - public static readonly TestProperty FullyQualifiedName = TestProperty.Register("TestCase.FullyQualifiedName", FullyQualifiedNameLabel, string.Empty, string.Empty, typeof(string), ValidateName, TestPropertyAttributes.Hidden, typeof(TestCase)); - public static readonly TestProperty DisplayName = TestProperty.Register("TestCase.DisplayName", NameLabel, string.Empty, string.Empty, typeof(string), ValidateDisplay, TestPropertyAttributes.None, typeof(TestCase)); - public static readonly TestProperty ExecutorUri = TestProperty.Register("TestCase.ExecutorUri", ExecutorUriLabel, string.Empty, string.Empty, typeof(Uri), ValidateExecutorUri, TestPropertyAttributes.Hidden, typeof(TestCase)); - public static readonly TestProperty Source = TestProperty.Register("TestCase.Source", SourceLabel, typeof(string), typeof(TestCase)); - public static readonly TestProperty CodeFilePath = TestProperty.Register("TestCase.CodeFilePath", FilePathLabel, typeof(string), typeof(TestCase)); - public static readonly TestProperty LineNumber = TestProperty.Register("TestCase.LineNumber", LineNumberLabel, typeof(int), TestPropertyAttributes.Hidden, typeof(TestCase)); - - internal static TestProperty[] Properties { get; } = + try { - CodeFilePath, - DisplayName, - ExecutorUri, - FullyQualifiedName, - Id, - LineNumber, - Source - }; - - private static bool ValidateName(object value) - { - return !string.IsNullOrWhiteSpace((string)value); + new Guid(value.ToString()); + return true; } - - private static bool ValidateDisplay(object value) + catch (ArgumentNullException) { - // only check for null and pass the rest up to UI for validation - return value != null; + return false; } - - private static bool ValidateExecutorUri(object value) + catch (FormatException) { - return value != null; + return false; } - - private static bool ValidateGuid(object value) + catch (OverflowException) { - try - { - new Guid(value.ToString()); - return true; - } - catch (ArgumentNullException) - { - return false; - } - catch (FormatException) - { - return false; - } - catch (OverflowException) - { - return false; - } + return false; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/TestObject.cs b/src/Microsoft.TestPlatform.ObjectModel/TestObject.cs index 4fd29c1043..d9c923a125 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/TestObject.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/TestObject.cs @@ -1,386 +1,378 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Globalization; +using System.Linq; +using System.Reflection; +using System.Runtime.Serialization; + +/// +/// Base class for test related classes. +/// +[DataContract] +public abstract class TestObject { - using System; - using System.Collections.Generic; - using System.ComponentModel; - using System.Globalization; - using System.Linq; - using System.Reflection; - using System.Runtime.Serialization; + #region Fields + + private static readonly CustomKeyValueConverter KeyValueConverter = new(); + private static readonly CustomStringArrayConverter StringArrayConverter = new(); + + /// + /// The store for all the properties registered. + /// + private readonly Dictionary _store; /// - /// Base class for test related classes. + /// Property used for Json (de)serialization of store dictionary. Serialization of dictionaries + /// by default doesn't provide the required object representation. List of KeyValuePair on the + /// other hand provides a clean Key, Value entries for TestProperty and it's value. /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1012:AbstractTypesShouldNotHaveConstructors")] - [DataContract] - public abstract class TestObject + [DataMember(Name = "Properties")] + private List> StoreKeyValuePairs { - #region Fields - - private static CustomKeyValueConverter keyValueConverter = new CustomKeyValueConverter(); - private static CustomStringArrayConverter stringArrayConverter = new CustomStringArrayConverter(); - - /// - /// The store for all the properties registered. - /// - private readonly Dictionary store; - - /// - /// Property used for Json (de)serialization of store dictionary. Serialization of dictionaries - /// by default doesn't provide the required object representation. List of KeyValuePair on the - /// other hand provides a clean Key, Value entries for TestProperty and it's value. - /// - [DataMember(Name = "Properties")] - private List> StoreKeyValuePairs + get { - get - { - return this.store.ToList(); - } + return _store.ToList(); + } - set + set + { + // Receive the key value pairs from deserialized entity. + // Store each property and value in the property data store. + foreach (var property in value) { - // Receive the key value pairs from deserialized entity. - // Store each property and value in the property data store. - foreach (var property in value) - { - TestProperty.Register( - property.Key.Id, - property.Key.Label, - property.Key.Category, - property.Key.Description, - property.Key.GetValueType(), - null, - property.Key.Attributes, - typeof(TestObject)); - - // Do not call SetPropertyValue(TestProperty property, object value) as it does not - // invoke ConvertPropertyFrom and does not store the properties in correct types. - this.SetPropertyValue(property.Key, property.Value, CultureInfo.InvariantCulture); - } + TestProperty.Register( + property.Key.Id, + property.Key.Label, + property.Key.Category, + property.Key.Description, + property.Key.GetValueType(), + null, + property.Key.Attributes, + typeof(TestObject)); + + // Do not call SetPropertyValue(TestProperty property, object value) as it does not + // invoke ConvertPropertyFrom and does not store the properties in correct types. + SetPropertyValue(property.Key, property.Value, CultureInfo.InvariantCulture); } } + } - public IEnumerable> GetProperties() - { - return this.store; - } + public IEnumerable> GetProperties() + { + return _store; + } - #endregion Fields + #endregion Fields - #region Constructors + #region Constructors - protected TestObject() - { - this.store = new Dictionary(); - } + protected TestObject() + { + _store = new Dictionary(); + } - [OnSerializing] + [OnSerializing] #if FullCLR private void CacheLazyValuesOnSerializing(StreamingContext context) #else - public void CacheLazyValuesOnSerializing(StreamingContext context) + public void CacheLazyValuesOnSerializing(StreamingContext context) #endif + { + var lazyValues = _store.Where(kvp => kvp.Value is ILazyPropertyValue).ToArray(); + + foreach (var kvp in lazyValues) { - var lazyValues = this.store.Where(kvp => kvp.Value is ILazyPropertyValue).ToArray(); + var lazyValue = (ILazyPropertyValue)kvp.Value; + var value = lazyValue.Value; + _store.Remove(kvp.Key); - foreach (var kvp in lazyValues) + if (value != null) { - var lazyValue = (ILazyPropertyValue)kvp.Value; - var value = lazyValue.Value; - this.store.Remove(kvp.Key); - - if (value != null) - { - this.store.Add(kvp.Key, value); - } + _store.Add(kvp.Key, value); } } + } - #endregion Constructors + #endregion Constructors - #region Properties + #region Properties - /// - /// Returns the TestProperties currently specified in this TestObject. - /// - public virtual IEnumerable Properties + /// + /// Returns the TestProperties currently specified in this TestObject. + /// + public virtual IEnumerable Properties + { + get { return _store.Keys; } + } + + /// + /// Returns property value of the specify TestProperty + /// + /// TestObject's TestProperty + /// property value + public object GetPropertyValue(TestProperty property) + { + ValidateArg.NotNull(property, nameof(property)); + + object defaultValue = null; + var valueType = property.GetValueType(); + + if (valueType != null && valueType.GetTypeInfo().IsValueType) { - get { return this.store.Keys; } + defaultValue = Activator.CreateInstance(valueType); } - /// - /// Returns property value of the specify TestProperty - /// - /// TestObject's TestProperty - /// property value - public object GetPropertyValue(TestProperty property) - { - ValidateArg.NotNull(property, nameof(property)); + return ProtectedGetPropertyValue(property, defaultValue); + } - object defaultValue = null; - var valueType = property.GetValueType(); + /// + /// Returns property value of the specify TestProperty + /// + /// Property value type + /// TestObject's TestProperty + /// default property value if property is not present + /// property value + public T GetPropertyValue(TestProperty property, T defaultValue) + { + return GetPropertyValue(property, defaultValue, CultureInfo.InvariantCulture); + } - if (valueType != null && valueType.GetTypeInfo().IsValueType) - { - defaultValue = Activator.CreateInstance(valueType); - } + /// + /// Set TestProperty's value + /// + /// Property value type + /// TestObject's TestProperty + /// value to be set + public void SetPropertyValue(TestProperty property, T value) + { + SetPropertyValue(property, value, CultureInfo.InvariantCulture); + } - return this.ProtectedGetPropertyValue(property, defaultValue); - } + /// + /// Set TestProperty's value + /// + /// Property value type + /// TestObject's TestProperty + /// value to be set + public void SetPropertyValue(TestProperty property, LazyPropertyValue value) + { + SetPropertyValue(property, value, CultureInfo.InvariantCulture); + } - /// - /// Returns property value of the specify TestProperty - /// - /// Property value type - /// TestObject's TestProperty - /// default property value if property is not present - /// property value - public T GetPropertyValue(TestProperty property, T defaultValue) - { - return this.GetPropertyValue(property, defaultValue, CultureInfo.InvariantCulture); - } + /// + /// Set TestProperty's value + /// + /// TestObject's TestProperty + /// value to be set + public void SetPropertyValue(TestProperty property, object value) + { + ProtectedSetPropertyValue(property, value); + } - /// - /// Set TestProperty's value - /// - /// Property value type - /// TestObject's TestProperty - /// value to be set - public void SetPropertyValue(TestProperty property, T value) + /// + /// Remove test property from the current TestObject. + /// + /// + public void RemovePropertyValue(TestProperty property) + { + ValidateArg.NotNull(property, nameof(property)); + if (_store.TryGetValue(property, out _)) { - this.SetPropertyValue(property, value, CultureInfo.InvariantCulture); + _store.Remove(property); } + } - /// - /// Set TestProperty's value - /// - /// Property value type - /// TestObject's TestProperty - /// value to be set - public void SetPropertyValue(TestProperty property, LazyPropertyValue value) - { - this.SetPropertyValue(property, value, CultureInfo.InvariantCulture); - } + /// + /// Returns TestProperty's value + /// + /// property's value. default value is returned if the property is not present + public T GetPropertyValue(TestProperty property, T defaultValue, CultureInfo culture) + { + ValidateArg.NotNull(property, nameof(property)); + ValidateArg.NotNull(culture, nameof(culture)); - /// - /// Set TestProperty's value - /// - /// TestObject's TestProperty - /// value to be set - public void SetPropertyValue(TestProperty property, object value) - { - this.ProtectedSetPropertyValue(property, value); - } + object objValue = ProtectedGetPropertyValue(property, defaultValue); - /// - /// Remove test property from the current TestObject. - /// - /// - public void RemovePropertyValue(TestProperty property) - { - ValidateArg.NotNull(property, nameof(property)); + return ConvertPropertyTo(property, culture, objValue); + } - if (this.store.TryGetValue(property, out var value)) - { - this.store.Remove(property); - } - } + /// + /// Set TestProperty's value to the specified value T. + /// + public void SetPropertyValue(TestProperty property, T value, CultureInfo culture) + { + ValidateArg.NotNull(property, nameof(property)); + ValidateArg.NotNull(culture, nameof(culture)); - /// - /// Returns TestProperty's value - /// - /// property's value. default value is returned if the property is not present - public T GetPropertyValue(TestProperty property, T defaultValue, CultureInfo culture) - { - ValidateArg.NotNull(property, nameof(property)); - ValidateArg.NotNull(culture, nameof(culture)); + object objValue = ConvertPropertyFrom(property, culture, value); - object objValue = this.ProtectedGetPropertyValue(property, defaultValue); + ProtectedSetPropertyValue(property, objValue); + } - return ConvertPropertyTo(property, culture, objValue); - } + /// + /// Set TestProperty's value to the specified value T. + /// + public void SetPropertyValue(TestProperty property, LazyPropertyValue value, CultureInfo culture) + { + ValidateArg.NotNull(property, nameof(property)); + ValidateArg.NotNull(culture, nameof(culture)); - /// - /// Set TestProperty's value to the specified value T. - /// - public void SetPropertyValue(TestProperty property, T value, CultureInfo culture) - { - ValidateArg.NotNull(property, nameof(property)); - ValidateArg.NotNull(culture, nameof(culture)); + object objValue = ConvertPropertyFrom(property, culture, value); - object objValue = ConvertPropertyFrom(property, culture, value); + ProtectedSetPropertyValue(property, objValue); + } - this.ProtectedSetPropertyValue(property, objValue); - } + #endregion Property Values - /// - /// Set TestProperty's value to the specified value T. - /// - public void SetPropertyValue(TestProperty property, LazyPropertyValue value, CultureInfo culture) - { - ValidateArg.NotNull(property, nameof(property)); - ValidateArg.NotNull(culture, nameof(culture)); + #region Helpers - object objValue = ConvertPropertyFrom(property, culture, value); + /// + /// Return TestProperty's value + /// + /// + protected virtual object ProtectedGetPropertyValue(TestProperty property, object defaultValue) + { + ValidateArg.NotNull(property, nameof(property)); - this.ProtectedSetPropertyValue(property, objValue); + if (!_store.TryGetValue(property, out var value)) + { + value = defaultValue; } - #endregion Property Values + return value; + } - #region Helpers + /// + /// Set TestProperty's value + /// + protected virtual void ProtectedSetPropertyValue(TestProperty property, object value) + { + ValidateArg.NotNull(property, nameof(property)); - /// - /// Return TestProperty's value - /// - /// - protected virtual object ProtectedGetPropertyValue(TestProperty property, object defaultValue) - { - ValidateArg.NotNull(property, nameof(property)); + _store[property] = property.ValidateValueCallback == null || property.ValidateValueCallback(value) + ? value + : throw new ArgumentException(property.Label); + } - if (!this.store.TryGetValue(property, out var value)) - { - value = defaultValue; - } + /// + /// Convert passed in value from TestProperty's specified value type. + /// + /// Converted object + private static object ConvertPropertyFrom(TestProperty property, CultureInfo culture, object value) + { + ValidateArg.NotNull(property, nameof(property)); + ValidateArg.NotNull(culture, nameof(culture)); + + var valueType = property.GetValueType(); + // Do not try conversion if the object is already of the type we're trying to convert. + // Note that typeof(T) may be object in case the value is getting deserialized via the StoreKvpList, however + // the de-serializer could have converted it already, hence the runtime type check. + if (valueType != null && (valueType.GetTypeInfo().IsAssignableFrom(typeof(T).GetTypeInfo()) || valueType.GetTypeInfo().IsAssignableFrom(value?.GetType().GetTypeInfo()))) + { return value; } - /// - /// Set TestProperty's value - /// - protected virtual void ProtectedSetPropertyValue(TestProperty property, object value) + // Traits are KeyValuePair based. Use the custom converter in that case. + if (valueType == typeof(KeyValuePair[])) { - ValidateArg.NotNull(property, nameof(property)); - - if (property.ValidateValueCallback == null || property.ValidateValueCallback(value)) - { - this.store[property] = value; - } - else - { - throw new ArgumentException(property.Label); - } + return KeyValueConverter.ConvertFrom(null, culture, (string)value); } - /// - /// Convert passed in value from TestProperty's specified value type. - /// - /// Converted object - private static object ConvertPropertyFrom(TestProperty property, CultureInfo culture, object value) + // Use a custom string array converter for string[] types. + if (valueType == typeof(string[])) { - ValidateArg.NotNull(property, nameof(property)); - ValidateArg.NotNull(culture, nameof(culture)); - - var valueType = property.GetValueType(); + return StringArrayConverter.ConvertFrom(null, culture, (string)value); + } - // Do not try conversion if the object is already of the type we're trying to convert. - // Note that typeof(T) may be object in case the value is getting deserialized via the StoreKvpList, however - // the de-serializer could have converted it already, hence the runtime type check. - if (valueType != null && (valueType.GetTypeInfo().IsAssignableFrom(typeof(T).GetTypeInfo()) || valueType.GetTypeInfo().IsAssignableFrom(value?.GetType().GetTypeInfo()))) - { - return value; - } + TypeConverter converter = TypeDescriptor.GetConverter(valueType); + if (converter == null) + { + throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.Resources.ConverterNotSupported, valueType.Name)); + } - // Traits are KeyValuePair based. Use the custom converter in that case. - if (valueType == typeof(KeyValuePair[])) - { - return keyValueConverter.ConvertFrom(null, culture, (string)value); - } + try + { + return converter.ConvertFrom(null, culture, value); + } + catch (FormatException) + { + throw; + } + catch (Exception e) + { + // some type converters throw strange exceptions (e.g.: System.Exception by Int32Converter) + throw new FormatException(e.Message, e); + } + } - // Use a custom string array converter for string[] types. - if (valueType == typeof(string[])) - { - return stringArrayConverter.ConvertFrom(null, culture, (string)value); - } + /// + /// Convert passed in value into the specified type when property is registered. + /// + /// Converted object + private static T ConvertPropertyTo(TestProperty property, CultureInfo culture, object value) + { + ValidateArg.NotNull(property, nameof(property)); + ValidateArg.NotNull(culture, nameof(culture)); - TypeConverter converter = TypeDescriptor.GetConverter(valueType); - if (converter == null) - { - throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.Resources.ConverterNotSupported, valueType.Name)); - } - try - { - return converter.ConvertFrom(null, culture, value); - } - catch (FormatException) - { - throw; - } - catch (Exception e) - { - // some type converters throw strange exceptions (e.g.: System.Exception by Int32Converter) - throw new FormatException(e.Message, e); - } + if (value == null) + { + return default; } - - /// - /// Convert passed in value into the specified type when property is registered. - /// - /// Converted object - private static T ConvertPropertyTo(TestProperty property, CultureInfo culture, object value) + else if (value is T t) { - ValidateArg.NotNull(property, nameof(property)); - ValidateArg.NotNull(culture, nameof(culture)); - - - if (value == null) - { - return default; - } - else if (value is T t) - { - return t; - } - else if (value is LazyPropertyValue lazyValue) - { - return lazyValue.Value; - } + return t; + } + else if (value is LazyPropertyValue lazyValue) + { + return lazyValue.Value; + } - var valueType = property.GetValueType(); + var valueType = property.GetValueType(); - TypeConverter converter = TypeDescriptor.GetConverter(valueType); + TypeConverter converter = TypeDescriptor.GetConverter(valueType); - if (converter == null) - { - throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.Resources.ConverterNotSupported, valueType.Name)); - } + if (converter == null) + { + throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.Resources.ConverterNotSupported, valueType.Name)); + } - try - { - return (T)converter.ConvertTo(null, culture, value, typeof(T)); - } - catch (FormatException) - { - throw; - } - catch (Exception e) - { - // some type converters throw strange exceptions (e.g.: System.Exception by Int32Converter) - throw new FormatException(e.Message, e); - } + try + { + return (T)converter.ConvertTo(null, culture, value, typeof(T)); + } + catch (FormatException) + { + throw; + } + catch (Exception e) + { + // some type converters throw strange exceptions (e.g.: System.Exception by Int32Converter) + throw new FormatException(e.Message, e); } + } - #endregion Helpers + #endregion Helpers - private TraitCollection traits; + private TraitCollection _traits; - public TraitCollection Traits + public TraitCollection Traits + { + get { - get + if (_traits == null) { - if (this.traits == null) - { - this.traits = new TraitCollection(this); - } - - return this.traits; + _traits = new TraitCollection(this); } + + return _traits; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/TestOutcome.cs b/src/Microsoft.TestPlatform.ObjectModel/TestOutcome.cs index d77e505c50..497d6ab853 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/TestOutcome.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/TestOutcome.cs @@ -1,36 +1,35 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +/// +/// Represents the outcomes of a test case. +/// +public enum TestOutcome { /// - /// Represents the outcomes of a test case. + /// Test Case Does Not Have an outcome. /// - public enum TestOutcome - { - /// - /// Test Case Does Not Have an outcome. - /// - None = 0, + None = 0, - /// - /// Test Case Passed - /// - Passed = 1, + /// + /// Test Case Passed + /// + Passed = 1, - /// - /// Test Case Failed - /// - Failed = 2, + /// + /// Test Case Failed + /// + Failed = 2, - /// - /// Test Case Skipped - /// - Skipped = 3, + /// + /// Test Case Skipped + /// + Skipped = 3, - /// - /// Test Case Not found - /// - NotFound = 4, - } -} + /// + /// Test Case Not found + /// + NotFound = 4, +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/TestOutcomeHelper.cs b/src/Microsoft.TestPlatform.ObjectModel/TestOutcomeHelper.cs index 65e5fec5e5..b863b8ae2a 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/TestOutcomeHelper.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/TestOutcomeHelper.cs @@ -1,46 +1,44 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +/// +/// Helper methods for working with the TestOutcome enum. +/// +public static class TestOutcomeHelper +{ /// - /// Helper methods for working with the TestOutcome enum. + /// Converts the outcome into its localized string representation. /// - public static class TestOutcomeHelper + /// The outcome to get the string for. + /// The localized outcome string. + public static string GetOutcomeString(TestOutcome outcome) { - /// - /// Converts the outcome into its localized string representation. - /// - /// The outcome to get the string for. - /// The localized outcome string. - public static string GetOutcomeString(TestOutcome outcome) + string result; + switch (outcome) { - string result = null; - - switch (outcome) - { - case TestOutcome.None: - result = Resources.Resources.TestOutcomeNone; - break; - case TestOutcome.Passed: - result = Resources.Resources.TestOutcomePassed; - break; - case TestOutcome.Failed: - result = Resources.Resources.TestOutcomeFailed; - break; - case TestOutcome.Skipped: - result = Resources.Resources.TestOutcomeSkipped; - break; - case TestOutcome.NotFound: - result = Resources.Resources.TestOutcomeNotFound; - break; - default: - throw new ArgumentOutOfRangeException(nameof(outcome)); - } - - return result; + case TestOutcome.None: + result = Resources.Resources.TestOutcomeNone; + break; + case TestOutcome.Passed: + result = Resources.Resources.TestOutcomePassed; + break; + case TestOutcome.Failed: + result = Resources.Resources.TestOutcomeFailed; + break; + case TestOutcome.Skipped: + result = Resources.Resources.TestOutcomeSkipped; + break; + case TestOutcome.NotFound: + result = Resources.Resources.TestOutcomeNotFound; + break; + default: + throw new ArgumentOutOfRangeException(nameof(outcome)); } + + return result; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/TestProcessAttachDebuggerPayload.cs b/src/Microsoft.TestPlatform.ObjectModel/TestProcessAttachDebuggerPayload.cs index 371a0dd65f..5c5ba4dbda 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/TestProcessAttachDebuggerPayload.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/TestProcessAttachDebuggerPayload.cs @@ -1,29 +1,28 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System.Runtime.Serialization; +/// +/// The test process info payload. +/// +[DataContract] +public class TestProcessAttachDebuggerPayload +{ /// - /// The test process info payload. + /// Creates a new instance of this class. /// - [DataContract] - public class TestProcessAttachDebuggerPayload + /// The process id the debugger should attach to. + public TestProcessAttachDebuggerPayload(int pid) { - /// - /// Creates a new instance of this class. - /// - /// The process id the debugger should attach to. - public TestProcessAttachDebuggerPayload(int pid) - { - this.ProcessID = pid; - } - - /// - /// The process id the debugger should attach to. - /// - [DataMember] - public int ProcessID { get; set; } + ProcessID = pid; } -} + + /// + /// The process id the debugger should attach to. + /// + [DataMember] + public int ProcessID { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/TestProcessStartInfo.cs b/src/Microsoft.TestPlatform.ObjectModel/TestProcessStartInfo.cs index 64f5861df3..3dd12f3ff9 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/TestProcessStartInfo.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/TestProcessStartInfo.cs @@ -1,46 +1,45 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System.Collections.Generic; - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System.Collections.Generic; +using System.Runtime.Serialization; +/// +/// The start info of the test runner +/// +[DataContract] +public class TestProcessStartInfo +{ /// - /// The start info of the test runner + /// The name of the test runner exe /// - [DataContract] - public class TestProcessStartInfo - { - /// - /// The name of the test runner exe - /// - [DataMember] - public string FileName { get; set; } + [DataMember] + public string FileName { get; set; } - /// - /// The arguments for the test runner - /// - [DataMember] - public string Arguments { get; set; } + /// + /// The arguments for the test runner + /// + [DataMember] + public string Arguments { get; set; } - /// - /// The working directory for the test runner - /// - [DataMember] - public string WorkingDirectory { get; set; } + /// + /// The working directory for the test runner + /// + [DataMember] + public string WorkingDirectory { get; set; } - /// - /// The associated environment variables - /// - [DataMember] - public IDictionary EnvironmentVariables { get; set; } + /// + /// The associated environment variables + /// + [DataMember] + public IDictionary EnvironmentVariables { get; set; } - /// - /// Any additional custom properties that might be required for the launch - /// For example - emulator ID, remote machine details etc. - /// - [DataMember] - public IDictionary CustomProperties { get; set; } - } + /// + /// Any additional custom properties that might be required for the launch + /// For example - emulator ID, remote machine details etc. + /// + [DataMember] + public IDictionary CustomProperties { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/TestProperty/CustomKeyValueConverter.cs b/src/Microsoft.TestPlatform.ObjectModel/TestProperty/CustomKeyValueConverter.cs index 6183496e9e..73dfd60b70 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/TestProperty/CustomKeyValueConverter.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/TestProperty/CustomKeyValueConverter.cs @@ -1,67 +1,59 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; + +/// +/// Converts a json representation of to an object. +/// +internal class CustomKeyValueConverter : TypeConverter { - using System; - using System.Collections.Generic; - using System.ComponentModel; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Text; + /// + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + return sourceType == typeof(string); + } - /// - /// Converts a json representation of to an object. - /// - internal class CustomKeyValueConverter : TypeConverter + /// + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { - /// - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) - { - return sourceType == typeof(string); - } + return value is KeyValuePair[] keyValuePairs + ? keyValuePairs + : base.ConvertTo(context, culture, value, destinationType); + } - /// - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + /// + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + // KeyValuePairs are used for traits. + if (value is string data) { - var keyValuePairs = value as KeyValuePair[]; - if (keyValuePairs != null) - { - return keyValuePairs; - } + using var stream = new MemoryStream(Encoding.Unicode.GetBytes(data)); + // Converting Json data to array of KeyValuePairs with duplicate keys. + var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(TraitObject[])); + var listOfTraitObjects = serializer.ReadObject(stream) as TraitObject[]; - return base.ConvertTo(context, culture, value, destinationType); + return listOfTraitObjects.Select(i => new KeyValuePair(i.Key, i.Value)).ToArray(); } - /// - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) - { - // KeyValuePairs are used for traits. - var data = value as string; - if (data != null) - { - using (var stream = new MemoryStream(Encoding.Unicode.GetBytes(data))) - { - // Converting Json data to array of KeyValuePairs with duplicate keys. - var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(TraitObject[])); - var listOfTraitObjects = serializer.ReadObject(stream) as TraitObject[]; - - return listOfTraitObjects.Select(i => new KeyValuePair(i.Key, i.Value)).ToArray(); - } - } - - return null; - } + return null; + } - [System.Runtime.Serialization.DataContract] - private class TraitObject - { - [System.Runtime.Serialization.DataMember(Name = "Key")] - public string Key { get; set; } + [System.Runtime.Serialization.DataContract] + private class TraitObject + { + [System.Runtime.Serialization.DataMember(Name = "Key")] + public string Key { get; set; } - [System.Runtime.Serialization.DataMember(Name = "Value")] - public string Value { get; set; } - } + [System.Runtime.Serialization.DataMember(Name = "Value")] + public string Value { get; set; } } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/TestProperty/CustomStringArrayConverter.cs b/src/Microsoft.TestPlatform.ObjectModel/TestProperty/CustomStringArrayConverter.cs index 254562555a..f4d9e89153 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/TestProperty/CustomStringArrayConverter.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/TestProperty/CustomStringArrayConverter.cs @@ -1,51 +1,41 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.ComponentModel; +using System.Globalization; +using System.IO; +using System.Text; + +internal class CustomStringArrayConverter : TypeConverter { - using System; - using System.ComponentModel; - using System.Globalization; - using System.IO; - using System.Text; + /// + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + return sourceType == typeof(string); + } - internal class CustomStringArrayConverter : TypeConverter + /// + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { - /// - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) - { - return sourceType == typeof(string); - } + return value is string[] strings ? strings : base.ConvertTo(context, culture, value, destinationType); + } - /// - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + /// + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + // String[] are used by adapters. E.g. TestCategory[] + if (value is string data) { - var strings = value as string[]; - if (strings != null) - { - return strings; - } + using var stream = new MemoryStream(Encoding.Unicode.GetBytes(data)); + var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(string[])); + var strings = serializer.ReadObject(stream) as string[]; - return base.ConvertTo(context, culture, value, destinationType); + return strings; } - /// - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) - { - // String[] are used by adapters. E.g. TestCategory[] - var data = value as string; - if (data != null) - { - using (var stream = new MemoryStream(Encoding.Unicode.GetBytes(data))) - { - var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(string[])); - var strings = serializer.ReadObject(stream) as string[]; - - return strings; - } - } - - return null; - } + return null; } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/TestProperty/TestProperty.cs b/src/Microsoft.TestPlatform.ObjectModel/TestProperty/TestProperty.cs index fcdcf8ecd5..a0694da779 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/TestProperty/TestProperty.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/TestProperty/TestProperty.cs @@ -1,404 +1,396 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Reflection; - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; - public delegate bool ValidateValueCallback(object value); +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Reflection; +using System.Runtime.Serialization; - [DataContract] - public class TestProperty : IEquatable - { - #region Fields +public delegate bool ValidateValueCallback(object value); - private Type valueType; +[DataContract] +public class TestProperty : IEquatable +{ + #region Fields - #endregion Fields + private Type _valueType; - #region Constructors + #endregion Fields - /// - /// Initializes a new instance of the class. - /// - private TestProperty() - { - // Default constructor for Serialization. - } + #region Constructors - private TestProperty(string id, string label, string category, string description, Type valueType, ValidateValueCallback validateValueCallback, TestPropertyAttributes attributes) - { - ValidateArg.NotNullOrEmpty(id, nameof(id)); - ValidateArg.NotNull(label, nameof(label)); - ValidateArg.NotNull(category, nameof(category)); - ValidateArg.NotNull(description, nameof(description)); - ValidateArg.NotNull(valueType, nameof(valueType)); - - // If the type of property is unexpected, then fail as otherwise we will not be to serialize it over the wcf channel and serialize it in db. - if (valueType == typeof(KeyValuePair[])) - { - this.ValueType = "System.Collections.Generic.KeyValuePair`2[[System.String],[System.String]][]"; - } - else if (valueType == typeof(string) - || valueType == typeof(Uri) - || valueType == typeof(string[]) - || valueType.AssemblyQualifiedName.Contains("System.Private") - || valueType.AssemblyQualifiedName.Contains("mscorlib")) - { - // This comparison is a check to ensure assembly information is not embedded in data. - // Use type.FullName instead of type.AssemblyQualifiedName since the internal assemblies - // are different in desktop and coreclr. Thus AQN in coreclr includes System.Private.CoreLib which - // is not available on the desktop. - // Note that this doesn't handle generic types. Such types will fail during serialization. - this.ValueType = valueType.FullName; - } - else if (valueType.GetTypeInfo().IsValueType) - { - // In case of custom types, let the assembly qualified name be available to help - // deserialization on the client. - this.ValueType = valueType.AssemblyQualifiedName; - } - else - { - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Resources.UnexpectedTypeOfProperty, valueType, id)); - } + /// + /// Initializes a new instance of the class. + /// + private TestProperty() + { + // Default constructor for Serialization. + } - this.Id = id; - this.Label = label; - this.Category = category; - this.Description = description; - this.ValidateValueCallback = validateValueCallback; - this.Attributes = attributes; - this.valueType = valueType; + private TestProperty(string id, string label, string category, string description, Type valueType, ValidateValueCallback validateValueCallback, TestPropertyAttributes attributes) + { + ValidateArg.NotNullOrEmpty(id, nameof(id)); + ValidateArg.NotNull(label, nameof(label)); + ValidateArg.NotNull(category, nameof(category)); + ValidateArg.NotNull(description, nameof(description)); + ValidateArg.NotNull(valueType, nameof(valueType)); + + // If the type of property is unexpected, then fail as otherwise we will not be to serialize it over the wcf channel and serialize it in db. + if (valueType == typeof(KeyValuePair[])) + { + ValueType = "System.Collections.Generic.KeyValuePair`2[[System.String],[System.String]][]"; } - - #endregion Constructors - - #region Properties - - /// - /// Gets or sets the Id for the property. - /// - [DataMember] - public string Id { get; set; } - - /// - /// Gets or sets a label for the property. - /// - [DataMember] - public string Label { get; set; } - - /// - /// Gets or sets a category for the property. - /// - [DataMember] - public string Category { get; set; } - - /// - /// Gets or sets a description for the property. - /// - [DataMember] - public string Description { get; set; } - - /// - /// Gets the callback for validation of property value. - /// - /// This property is not required at the client side. - [IgnoreDataMember] - public ValidateValueCallback ValidateValueCallback { get; } - - /// - /// Gets or sets the attributes for this property. - /// - [DataMember] - public TestPropertyAttributes Attributes { get; set; } - - /// - /// Gets or sets a string representation of the type for value. - /// - [DataMember] - public string ValueType { get; set; } - - #endregion Properties - - #region IEquatable - - /// - public override int GetHashCode() + else if (valueType == typeof(string) + || valueType == typeof(Uri) + || valueType == typeof(string[]) + || valueType.AssemblyQualifiedName.Contains("System.Private") + || valueType.AssemblyQualifiedName.Contains("mscorlib")) { - return this.Id.GetHashCode(); + // This comparison is a check to ensure assembly information is not embedded in data. + // Use type.FullName instead of type.AssemblyQualifiedName since the internal assemblies + // are different in desktop and coreclr. Thus AQN in coreclr includes System.Private.CoreLib which + // is not available on the desktop. + // Note that this doesn't handle generic types. Such types will fail during serialization. + ValueType = valueType.FullName; } - - /// - public override bool Equals(object obj) + else if (valueType.GetTypeInfo().IsValueType) { - return base.Equals(obj as TestProperty); + // In case of custom types, let the assembly qualified name be available to help + // deserialization on the client. + ValueType = valueType.AssemblyQualifiedName; } - - /// - public bool Equals(TestProperty other) + else { - return (other != null) && (this.Id == other.Id); + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Resources.UnexpectedTypeOfProperty, valueType, id)); } - #endregion IEquatable + Id = id; + Label = label; + Category = category; + Description = description; + ValidateValueCallback = validateValueCallback; + Attributes = attributes; + _valueType = valueType; + } + + #endregion Constructors + + #region Properties + + /// + /// Gets or sets the Id for the property. + /// + [DataMember] + public string Id { get; set; } + + /// + /// Gets or sets a label for the property. + /// + [DataMember] + public string Label { get; set; } + + /// + /// Gets or sets a category for the property. + /// + [DataMember] + public string Category { get; set; } + + /// + /// Gets or sets a description for the property. + /// + [DataMember] + public string Description { get; set; } + + /// + /// Gets the callback for validation of property value. + /// + /// This property is not required at the client side. + [IgnoreDataMember] + public ValidateValueCallback ValidateValueCallback { get; } + + /// + /// Gets or sets the attributes for this property. + /// + [DataMember] + public TestPropertyAttributes Attributes { get; set; } + + /// + /// Gets or sets a string representation of the type for value. + /// + [DataMember] + public string ValueType { get; set; } + + #endregion Properties + + #region IEquatable + + /// + public override int GetHashCode() + { + return Id.GetHashCode(); + } + + /// + public override bool Equals(object obj) + { + return base.Equals(obj as TestProperty); + } + + /// + public bool Equals(TestProperty other) + { + return (other != null) && (Id == other.Id); + } + + #endregion IEquatable + + #region Methods - #region Methods + /// + public override string ToString() + { + return Id; + } - /// - public override string ToString() + /// + /// Gets the valueType. + /// + /// Only works for the valueType that is in the currently executing assembly or in Mscorlib.dll. The default valueType is of string valueType. + /// The valueType of the test property + public Type GetValueType() + { + if (_valueType == null) { - return this.Id; + _valueType = GetType(ValueType); } - /// - /// Gets the valueType. - /// - /// Only works for the valueType that is in the currently executing assembly or in Mscorlib.dll. The default valueType is of string valueType. - /// The valueType of the test property - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "This could take a bit time, is not simple enough to be a property.")] - public Type GetValueType() - { - if (this.valueType == null) - { - this.valueType = this.GetType(this.ValueType); - } + return _valueType; + } - return this.valueType; - } + private Type GetType(string typeName) + { + ValidateArg.NotNull(typeName, nameof(typeName)); - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "Use this in the body in debug mode")] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "We use the default type whenever exception thrown")] - private Type GetType(string typeName) - { - ValidateArg.NotNull(typeName, nameof(typeName)); + Type type = null; - Type type = null; + try + { + // This only works for the type is in the currently executing assembly or in Mscorlib.dll. + type = Type.GetType(typeName); - try + if (type == null) { - // This only works for the type is in the currently executing assembly or in Mscorlib.dll. - type = Type.GetType(typeName); - - if (type == null) - { - type = Type.GetType(typeName.Replace("Version=4.0.0.0", "Version=2.0.0.0")); // Try 2.0 version as discovery returns version of 4.0 for all cases - } + type = Type.GetType(typeName.Replace("Version=4.0.0.0", "Version=2.0.0.0")); // Try 2.0 version as discovery returns version of 4.0 for all cases + } - // For UAP the type namespace for System.Uri,System.TimeSpan and System.DateTimeOffset differs from the desktop version. - if (type == null && typeName.StartsWith("System.Uri")) - { - type = typeof(System.Uri); - } - else if (type == null && typeName.StartsWith("System.TimeSpan")) - { - type = typeof(System.TimeSpan); - } - else if (type == null && typeName.StartsWith("System.DateTimeOffset")) - { - type = typeof(System.DateTimeOffset); - } - else if (type == null && typeName.StartsWith("System.Int16")) - { - // For LineNumber property - Int is required - type = typeof(System.Int16); - } - else if (type == null && typeName.StartsWith("System.Int32")) - { - type = typeof(System.Int32); - } - else if (type == null && typeName.StartsWith("System.Int64")) - { - type = typeof(System.Int64); - } + // For UAP the type namespace for System.Uri,System.TimeSpan and System.DateTimeOffset differs from the desktop version. + if (type == null && typeName.StartsWith("System.Uri")) + { + type = typeof(Uri); + } + else if (type == null && typeName.StartsWith("System.TimeSpan")) + { + type = typeof(TimeSpan); + } + else if (type == null && typeName.StartsWith("System.DateTimeOffset")) + { + type = typeof(DateTimeOffset); + } + else if (type == null && typeName.StartsWith("System.Int16")) + { + // For LineNumber property - Int is required + type = typeof(Int16); } - catch (Exception) + else if (type == null && typeName.StartsWith("System.Int32")) { + type = typeof(Int32); + } + else if (type == null && typeName.StartsWith("System.Int64")) + { + type = typeof(Int64); + } + } + catch (Exception) + { #if FullCLR - // Try to see if the typeName contains Windows Phone PKT in that case load it from - // desktop side - if (typeName.Contains(s_windowsPhonePKT)) - { - type = this.GetType(typeName.Replace(s_windowsPhonePKT, s_visualStudioPKT)); - } + // Try to see if the typeName contains Windows Phone PKT in that case load it from + // desktop side + if (typeName.Contains(s_windowsPhonePKT)) + { + type = GetType(typeName.Replace(s_windowsPhonePKT, s_visualStudioPKT)); + } - if (type == null) - { - System.Diagnostics.Debug.Fail("The test property type " + typeName + " of property " + this.id + "is not supported."); + if (type == null) + { + System.Diagnostics.Debug.Fail("The test property type " + typeName + " of property " + Id + "is not supported."); #else - System.Diagnostics.Debug.WriteLine("The test property type " + typeName + " of property " + this.Id + "is not supported."); + System.Diagnostics.Debug.WriteLine("The test property type " + typeName + " of property " + Id + "is not supported."); #endif #if FullCLR - } -#endif } - finally +#endif + } + finally + { + // default is of string type. + if (type == null) { - // default is of string type. - if (type == null) - { - type = typeof(string); - } + type = typeof(string); } - - return type; } - #endregion Methods + return type; + } - #region Static Fields + #endregion Methods - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA908:AvoidTypesThatRequireJitCompilationInPrecompiledAssemblies")] - private static Dictionary>> s_properties = new Dictionary>>(); + #region Static Fields + + private static readonly Dictionary>> Properties = new(); #if FullCLR - private static string s_visualStudioPKT = "b03f5f7f11d50a3a"; - private static string s_windowsPhonePKT = "7cec85d7bea7798e"; + private static string s_visualStudioPKT = "b03f5f7f11d50a3a"; + private static string s_windowsPhonePKT = "7cec85d7bea7798e"; #endif - #endregion Static Fields + #endregion Static Fields - #region Static Methods + #region Static Methods - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA908:AvoidTypesThatRequireJitCompilationInPrecompiledAssemblies")] - public static void ClearRegisteredProperties() + public static void ClearRegisteredProperties() + { + lock (Properties) { - lock (s_properties) - { - s_properties.Clear(); - } + Properties.Clear(); } + } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA908:AvoidTypesThatRequireJitCompilationInPrecompiledAssemblies")] - public static TestProperty Find(string id) - { - ValidateArg.NotNull(id, nameof(id)); + public static TestProperty Find(string id) + { + ValidateArg.NotNull(id, nameof(id)); - TestProperty result = null; + TestProperty result = null; - lock (s_properties) + lock (Properties) + { + if (Properties.TryGetValue(id, out var propertyTypePair)) { - if (s_properties.TryGetValue(id, out var propertyTypePair)) - { - result = propertyTypePair.Key; - } + result = propertyTypePair.Key; } - - return result; } - public static TestProperty Register(string id, string label, Type valueType, Type owner) - { - ValidateArg.NotNullOrEmpty(id, nameof(id)); - ValidateArg.NotNull(label, nameof(label)); - ValidateArg.NotNull(valueType, nameof(valueType)); - ValidateArg.NotNull(owner, nameof(owner)); + return result; + } - return Register(id, label, string.Empty, string.Empty, valueType, null, TestPropertyAttributes.None, owner); - } + public static TestProperty Register(string id, string label, Type valueType, Type owner) + { + ValidateArg.NotNullOrEmpty(id, nameof(id)); + ValidateArg.NotNull(label, nameof(label)); + ValidateArg.NotNull(valueType, nameof(valueType)); + ValidateArg.NotNull(owner, nameof(owner)); - public static TestProperty Register(string id, string label, Type valueType, TestPropertyAttributes attributes, Type owner) - { - ValidateArg.NotNullOrEmpty(id, nameof(id)); - ValidateArg.NotNull(label, nameof(label)); - ValidateArg.NotNull(valueType, nameof(valueType)); - ValidateArg.NotNull(owner, nameof(owner)); + return Register(id, label, string.Empty, string.Empty, valueType, null, TestPropertyAttributes.None, owner); + } - return Register(id, label, string.Empty, string.Empty, valueType, null, attributes, owner); - } + public static TestProperty Register(string id, string label, Type valueType, TestPropertyAttributes attributes, Type owner) + { + ValidateArg.NotNullOrEmpty(id, nameof(id)); + ValidateArg.NotNull(label, nameof(label)); + ValidateArg.NotNull(valueType, nameof(valueType)); + ValidateArg.NotNull(owner, nameof(owner)); - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA908:AvoidTypesThatRequireJitCompilationInPrecompiledAssemblies")] - public static TestProperty Register(string id, string label, string category, string description, Type valueType, ValidateValueCallback validateValueCallback, TestPropertyAttributes attributes, Type owner) - { - ValidateArg.NotNullOrEmpty(id, nameof(id)); - ValidateArg.NotNull(label, nameof(label)); - ValidateArg.NotNull(category, nameof(category)); - ValidateArg.NotNull(description, nameof(description)); - ValidateArg.NotNull(valueType, nameof(valueType)); - ValidateArg.NotNull(owner, nameof(owner)); + return Register(id, label, string.Empty, string.Empty, valueType, null, attributes, owner); + } - TestProperty result; + public static TestProperty Register(string id, string label, string category, string description, Type valueType, ValidateValueCallback validateValueCallback, TestPropertyAttributes attributes, Type owner) + { + ValidateArg.NotNullOrEmpty(id, nameof(id)); + ValidateArg.NotNull(label, nameof(label)); + ValidateArg.NotNull(category, nameof(category)); + ValidateArg.NotNull(description, nameof(description)); + ValidateArg.NotNull(valueType, nameof(valueType)); + ValidateArg.NotNull(owner, nameof(owner)); - lock (s_properties) + TestProperty result; + + lock (Properties) + { + if (Properties.TryGetValue(id, out var propertyTypePair)) { - if (s_properties.TryGetValue(id, out var propertyTypePair)) + // verify the data valueType is valid + if (propertyTypePair.Key.ValueType == valueType.AssemblyQualifiedName + || propertyTypePair.Key.ValueType == valueType.FullName + || propertyTypePair.Key._valueType == valueType) { - // verify the data valueType is valid - if (propertyTypePair.Key.ValueType == valueType.AssemblyQualifiedName - || propertyTypePair.Key.ValueType == valueType.FullName - || propertyTypePair.Key.valueType == valueType) - { - // add the owner to set of owners for this GraphProperty object - propertyTypePair.Value.Add(owner); - result = propertyTypePair.Key; - } - else - { - // not the data valueType we expect, throw an exception - string message = string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.Exception_RegisteredTestPropertyHasDifferentValueType, - id, - valueType.ToString(), - propertyTypePair.Key.ValueType); - - throw new InvalidOperationException(message); - } + // add the owner to set of owners for this GraphProperty object + propertyTypePair.Value.Add(owner); + result = propertyTypePair.Key; } else { - // create a new TestProperty object - result = new TestProperty(id, label, category, description, valueType, validateValueCallback, attributes); - - // setup the data pair used to track owners of this GraphProperty - propertyTypePair = new KeyValuePair>(result, new HashSet()); - propertyTypePair.Value.Add(owner); - - // add to the dictionary - s_properties[id] = propertyTypePair; + // not the data valueType we expect, throw an exception + string message = string.Format( + CultureInfo.CurrentCulture, + Resources.Resources.Exception_RegisteredTestPropertyHasDifferentValueType, + id, + valueType.ToString(), + propertyTypePair.Key.ValueType); + + throw new InvalidOperationException(message); } } + else + { + // create a new TestProperty object + result = new TestProperty(id, label, category, description, valueType, validateValueCallback, attributes); - return result; - } - - public static bool TryUnregister(string id, out KeyValuePair> propertyTypePair) - { - ValidateArg.NotNullOrEmpty(id, nameof(id)); + // setup the data pair used to track owners of this GraphProperty + propertyTypePair = new KeyValuePair>(result, new HashSet()); + propertyTypePair.Value.Add(owner); - lock (s_properties) - { - if (s_properties.TryGetValue(id, out propertyTypePair)) - { - return s_properties.Remove(id); - } + // add to the dictionary + Properties[id] = propertyTypePair; } - return false; } - #endregion Static Methods + return result; + } + + public static bool TryUnregister(string id, out KeyValuePair> propertyTypePair) + { + ValidateArg.NotNullOrEmpty(id, nameof(id)); - public object GetRealObject(StreamingContext context) + lock (Properties) { - var registeredProperty = TestProperty.Find(this.Id); - if (registeredProperty == null) + if (Properties.TryGetValue(id, out propertyTypePair)) { - registeredProperty = TestProperty.Register( - this.Id, - this.Label, - this.Category, - this.Description, - this.GetValueType(), - this.ValidateValueCallback, - this.Attributes, - typeof(TestObject)); + return Properties.Remove(id); } + } + return false; + } - return registeredProperty; + #endregion Static Methods + + public object GetRealObject(StreamingContext context) + { + var registeredProperty = Find(Id); + if (registeredProperty == null) + { + registeredProperty = Register( + Id, + Label, + Category, + Description, + GetValueType(), + ValidateValueCallback, + Attributes, + typeof(TestObject)); } + + return registeredProperty; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/TestProperty/TestPropertyAttributes.cs b/src/Microsoft.TestPlatform.ObjectModel/TestProperty/TestPropertyAttributes.cs index 9388e922f5..ae25e6305b 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/TestProperty/TestPropertyAttributes.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/TestProperty/TestPropertyAttributes.cs @@ -1,17 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; - [Flags] - public enum TestPropertyAttributes - { - None = 0x00, // Default - Hidden = 0x01, - Immutable = 0x02, - [Obsolete("Use TestObject.Traits collection to create traits")] - Trait = 0x04, - } -} +[Flags] +public enum TestPropertyAttributes +{ + None = 0x00, // Default + Hidden = 0x01, + Immutable = 0x02, + [Obsolete("Use TestObject.Traits collection to create traits")] + Trait = 0x04, +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/TestResult.cs b/src/Microsoft.TestPlatform.ObjectModel/TestResult.cs index b01a6fb8eb..3c8b112d4c 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/TestResult.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/TestResult.cs @@ -1,338 +1,323 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Globalization; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; + +/// +/// Represents the result of a test case. +/// +[DataContract] +public sealed class TestResult : TestObject { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Globalization; - using System.Linq; - using System.Runtime.Serialization; - using System.Text; + #region Constructor /// - /// Represents the result of a test case. + /// Initializes a new instance of the class. /// - [DataContract] - public sealed class TestResult : TestObject + /// The test case the result is for. + public TestResult(TestCase testCase) { - #region Constructor + TestCase = testCase ?? throw new ArgumentNullException(nameof(testCase)); + Messages = new Collection(); + Attachments = new Collection(); + + // Default start and end time values for a test result are initialized to current time stamp + // to maintain compatibility. + StartTime = DateTimeOffset.UtcNow; + EndTime = DateTimeOffset.UtcNow; + } - /// - /// Initializes a new instance of the class. - /// - /// The test case the result is for. - public TestResult(TestCase testCase) - { - this.TestCase = testCase ?? throw new ArgumentNullException(nameof(testCase)); - this.Messages = new Collection(); - this.Attachments = new Collection(); - - // Default start and end time values for a test result are initialized to current time stamp - // to maintain compatibility. - this.StartTime = DateTimeOffset.UtcNow; - this.EndTime = DateTimeOffset.UtcNow; - } + #endregion - #endregion - - #region Properties - - /// - /// Gets the test case that this result is for. - /// - [DataMember] - public TestCase TestCase { get; private set; } - - /// - /// Gets the list of attachment sets for this TestResult. - /// - [DataMember] - public Collection Attachments { get; private set; } - - /// - /// Gets or sets the outcome of a test case. - /// - [DataMember] - public TestOutcome Outcome { get; set; } - - /// - /// Gets or sets the exception message. - /// - [DataMember] - public string ErrorMessage { get; set; } - - /// - /// Gets or sets the exception stack trace. - /// - [DataMember] - public string ErrorStackTrace { get; set; } - - /// - /// Gets or sets the TestResult Display name. Used for Data Driven Test (i.e. Data Driven Test. E.g. InlineData in xUnit) - /// - [DataMember] - public string DisplayName { get; set; } - - /// - /// Gets the test messages. - /// - [DataMember] - public Collection Messages { get; private set; } - - /// - /// Gets or sets test result ComputerName. - /// - [DataMember] - public string ComputerName { get; set; } - - /// - /// Gets or sets the test result Duration. - /// - [DataMember] - public TimeSpan Duration { get; set; } - - /// - /// Gets or sets the test result StartTime. - /// - [DataMember] - public DateTimeOffset StartTime { get; set; } - - /// - /// Gets or sets test result EndTime. - /// - [DataMember] - public DateTimeOffset EndTime { get; set; } - - /// - /// Returns the TestProperties currently specified in this TestObject. - /// - public override IEnumerable Properties - { - get - { - return TestResultProperties.Properties.Concat(base.Properties); - } - } + #region Properties - #endregion + /// + /// Gets the test case that this result is for. + /// + [DataMember] + public TestCase TestCase { get; private set; } - #region Methods + /// + /// Gets the list of attachment sets for this TestResult. + /// + [DataMember] + public Collection Attachments { get; private set; } - /// - public override string ToString() - { - StringBuilder result = new StringBuilder(); + /// + /// Gets or sets the outcome of a test case. + /// + [DataMember] + public TestOutcome Outcome { get; set; } - // Add the outcome of the test and the name of the test. - result.AppendFormat( - CultureInfo.CurrentUICulture, - Resources.Resources.BasicTestResultFormat, - this.TestCase.DisplayName, - TestOutcomeHelper.GetOutcomeString(this.Outcome)); + /// + /// Gets or sets the exception message. + /// + [DataMember] + public string ErrorMessage { get; set; } - // Add the error message and stack trace if this is a test failure. - if (this.Outcome == TestOutcome.Failed) - { - // Add Error message. - result.AppendLine(); - result.AppendFormat(CultureInfo.CurrentUICulture, Resources.Resources.TestFailureMessageFormat, this.ErrorMessage); + /// + /// Gets or sets the exception stack trace. + /// + [DataMember] + public string ErrorStackTrace { get; set; } - // Add stack trace if we have one. - if (!string.IsNullOrWhiteSpace(this.ErrorStackTrace)) - { - result.AppendLine(); - result.AppendFormat( - CultureInfo.CurrentUICulture, - Resources.Resources.TestFailureStackTraceFormat, - this.ErrorStackTrace); - } - } + /// + /// Gets or sets the TestResult Display name. Used for Data Driven Test (i.e. Data Driven Test. E.g. InlineData in xUnit) + /// + [DataMember] + public string DisplayName { get; set; } - // Add any text messages we have. - if (this.Messages.Count > 0) - { - StringBuilder testMessages = new StringBuilder(); - foreach (TestResultMessage message in this.Messages) - { - if (!string.IsNullOrEmpty(message?.Category) && !string.IsNullOrEmpty(message.Text)) - { - testMessages.AppendFormat( - CultureInfo.CurrentUICulture, - Resources.Resources.TestResultMessageFormat, - message.Category, - message.Text); - } - } + /// + /// Gets the test messages. + /// + [DataMember] + public Collection Messages { get; private set; } - result.AppendLine(); - result.AppendFormat( - CultureInfo.CurrentUICulture, - Resources.Resources.TestResultTextMessagesFormat, - testMessages.ToString()); - } + /// + /// Gets or sets test result ComputerName. + /// + [DataMember] + public string ComputerName { get; set; } + + /// + /// Gets or sets the test result Duration. + /// + [DataMember] + public TimeSpan Duration { get; set; } + + /// + /// Gets or sets the test result StartTime. + /// + [DataMember] + public DateTimeOffset StartTime { get; set; } - return result.ToString(); + /// + /// Gets or sets test result EndTime. + /// + [DataMember] + public DateTimeOffset EndTime { get; set; } + + /// + /// Returns the TestProperties currently specified in this TestObject. + /// + public override IEnumerable Properties + { + get + { + return TestResultProperties.Properties.Concat(base.Properties); } + } + + #endregion - #endregion + #region Methods + + /// + public override string ToString() + { + StringBuilder result = new(); - #region Protected Methods + // Add the outcome of the test and the name of the test. + result.AppendFormat( + CultureInfo.CurrentUICulture, + Resources.Resources.BasicTestResultFormat, + TestCase.DisplayName, + TestOutcomeHelper.GetOutcomeString(Outcome)); - /// - /// Return TestProperty's value - /// - /// - protected override object ProtectedGetPropertyValue(TestProperty property, object defaultValue) + // Add the error message and stack trace if this is a test failure. + if (Outcome == TestOutcome.Failed) { - ValidateArg.NotNull(property, nameof(property)); + // Add Error message. + result.AppendLine(); + result.AppendFormat(CultureInfo.CurrentUICulture, Resources.Resources.TestFailureMessageFormat, ErrorMessage); - switch (property.Id) + // Add stack trace if we have one. + if (!string.IsNullOrWhiteSpace(ErrorStackTrace)) { - case "TestResult.ComputerName": - return this.ComputerName; - case "TestResult.DisplayName": - return this.DisplayName; - case "TestResult.Duration": - return this.Duration; - case "TestResult.EndTime": - return this.EndTime; - case "TestResult.ErrorMessage": - return this.ErrorMessage; - case "TestResult.ErrorStackTrace": - return this.ErrorStackTrace; - case "TestResult.Outcome": - return this.Outcome; - case "TestResult.StartTime": - return this.StartTime; + result.AppendLine(); + result.AppendFormat( + CultureInfo.CurrentUICulture, + Resources.Resources.TestFailureStackTraceFormat, + ErrorStackTrace); } - - return base.ProtectedGetPropertyValue(property, defaultValue); } - /// - /// Set TestProperty's value - /// - protected override void ProtectedSetPropertyValue(TestProperty property, object value) + // Add any text messages we have. + if (Messages.Count > 0) { - ValidateArg.NotNull(property, nameof(property)); - - switch (property.Id) + StringBuilder testMessages = new(); + foreach (TestResultMessage message in Messages) { - case "TestResult.ComputerName": - this.ComputerName = (string)value; return; - case "TestResult.DisplayName": - this.DisplayName = (string)value; return; - case "TestResult.Duration": - this.Duration = (TimeSpan)value; return; - case "TestResult.EndTime": - this.EndTime = (DateTimeOffset)value; return; - case "TestResult.ErrorMessage": - this.ErrorMessage = (string)value; return; - case "TestResult.ErrorStackTrace": - this.ErrorStackTrace = (string)value; return; - case "TestResult.Outcome": - this.Outcome = (TestOutcome)value; return; - case "TestResult.StartTime": - this.StartTime = (DateTimeOffset)value; return; + if (!string.IsNullOrEmpty(message?.Category) && !string.IsNullOrEmpty(message.Text)) + { + testMessages.AppendFormat( + CultureInfo.CurrentUICulture, + Resources.Resources.TestResultMessageFormat, + message.Category, + message.Text); + } } - base.ProtectedSetPropertyValue(property, value); + + result.AppendLine(); + result.AppendFormat( + CultureInfo.CurrentUICulture, + Resources.Resources.TestResultTextMessagesFormat, + testMessages.ToString()); } - #endregion + return result.ToString(); } + #endregion + + #region Protected Methods + /// - /// Represents the test result message. + /// Return TestProperty's value /// - [DataContract] - public class TestResultMessage + /// + protected override object ProtectedGetPropertyValue(TestProperty property, object defaultValue) { - // Bugfix: 297759 Moving the category from the resources to the code - // so that it works on machines which has eng OS & non-eng VS and vice versa. - - /// - /// Standard Output Message Category - /// - public static readonly string StandardOutCategory = "StdOutMsgs"; - - /// - /// Standard Error Message Category - /// - public static readonly string StandardErrorCategory = "StdErrMsgs"; - - /// - /// Debug Trace Message Category - /// - public static readonly string DebugTraceCategory = "DbgTrcMsgs"; - - /// - /// Additional Information Message Category - /// - public static readonly string AdditionalInfoCategory = "AdtnlInfo"; - - /// - /// Initializes a new instance of the class. - /// - /// Category of the message. - /// Text of the message. - public TestResultMessage(string category, string text) - { - this.Category = category; - this.Text = text; - } + ValidateArg.NotNull(property, nameof(property)); - /// - /// Gets the message category - /// - [DataMember] - public string Category + switch (property.Id) { - get; - private set; + case "TestResult.ComputerName": + return ComputerName; + case "TestResult.DisplayName": + return DisplayName; + case "TestResult.Duration": + return Duration; + case "TestResult.EndTime": + return EndTime; + case "TestResult.ErrorMessage": + return ErrorMessage; + case "TestResult.ErrorStackTrace": + return ErrorStackTrace; + case "TestResult.Outcome": + return Outcome; + case "TestResult.StartTime": + return StartTime; } - /// - /// Gets the message text - /// - [DataMember] - public string Text + return base.ProtectedGetPropertyValue(property, defaultValue); + } + + /// + /// Set TestProperty's value + /// + protected override void ProtectedSetPropertyValue(TestProperty property, object value) + { + ValidateArg.NotNull(property, nameof(property)); + + switch (property.Id) { - get; - private set; + case "TestResult.ComputerName": + ComputerName = (string)value; return; + case "TestResult.DisplayName": + DisplayName = (string)value; return; + case "TestResult.Duration": + Duration = (TimeSpan)value; return; + case "TestResult.EndTime": + EndTime = (DateTimeOffset)value; return; + case "TestResult.ErrorMessage": + ErrorMessage = (string)value; return; + case "TestResult.ErrorStackTrace": + ErrorStackTrace = (string)value; return; + case "TestResult.Outcome": + Outcome = (TestOutcome)value; return; + case "TestResult.StartTime": + StartTime = (DateTimeOffset)value; return; } + base.ProtectedSetPropertyValue(property, value); } + #endregion +} + +/// +/// Represents the test result message. +/// +[DataContract] +public class TestResultMessage +{ + // Bugfix: 297759 Moving the category from the resources to the code + // so that it works on machines which has eng OS & non-eng VS and vice versa. + /// - /// Well-known TestResult properties + /// Standard Output Message Category /// - public static class TestResultProperties - { -#if !FullCLR - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly TestProperty DisplayName = TestProperty.Register("TestResult.DisplayName", "TestResult Display Name", typeof(string), TestPropertyAttributes.Hidden, typeof(TestResult)); + public static readonly string StandardOutCategory = "StdOutMsgs"; - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly TestProperty ComputerName = TestProperty.Register("TestResult.ComputerName", "Computer Name", typeof(string), TestPropertyAttributes.None, typeof(TestResult)); + /// + /// Standard Error Message Category + /// + public static readonly string StandardErrorCategory = "StdErrMsgs"; - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly TestProperty Outcome = TestProperty.Register("TestResult.Outcome", "Outcome", string.Empty, string.Empty, typeof(TestOutcome), ValidateOutcome, TestPropertyAttributes.None, typeof(TestResult)); + /// + /// Debug Trace Message Category + /// + public static readonly string DebugTraceCategory = "DbgTrcMsgs"; - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly TestProperty Duration = TestProperty.Register("TestResult.Duration", "Duration", typeof(TimeSpan), typeof(TestResult)); + /// + /// Additional Information Message Category + /// + public static readonly string AdditionalInfoCategory = "AdtnlInfo"; - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly TestProperty StartTime = TestProperty.Register("TestResult.StartTime", "Start Time", typeof(DateTimeOffset), typeof(TestResult)); + /// + /// Initializes a new instance of the class. + /// + /// Category of the message. + /// Text of the message. + public TestResultMessage(string category, string text) + { + Category = category; + Text = text; + } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly TestProperty EndTime = TestProperty.Register("TestResult.EndTime", "End Time", typeof(DateTimeOffset), typeof(TestResult)); + /// + /// Gets the message category + /// + [DataMember] + public string Category + { + get; + private set; + } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly TestProperty ErrorMessage = TestProperty.Register("TestResult.ErrorMessage", "Error Message", typeof(string), typeof(TestResult)); + /// + /// Gets the message text + /// + [DataMember] + public string Text + { + get; + private set; + } +} - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly TestProperty ErrorStackTrace = TestProperty.Register("TestResult.ErrorStackTrace", "Error Stack Trace", typeof(string), typeof(TestResult)); +/// +/// Well-known TestResult properties +/// +public static class TestResultProperties +{ +#if !FullCLR + public static readonly TestProperty DisplayName = TestProperty.Register("TestResult.DisplayName", "TestResult Display Name", typeof(string), TestPropertyAttributes.Hidden, typeof(TestResult)); + public static readonly TestProperty ComputerName = TestProperty.Register("TestResult.ComputerName", "Computer Name", typeof(string), TestPropertyAttributes.None, typeof(TestResult)); + public static readonly TestProperty Outcome = TestProperty.Register("TestResult.Outcome", "Outcome", string.Empty, string.Empty, typeof(TestOutcome), ValidateOutcome, TestPropertyAttributes.None, typeof(TestResult)); + public static readonly TestProperty Duration = TestProperty.Register("TestResult.Duration", "Duration", typeof(TimeSpan), typeof(TestResult)); + public static readonly TestProperty StartTime = TestProperty.Register("TestResult.StartTime", "Start Time", typeof(DateTimeOffset), typeof(TestResult)); + public static readonly TestProperty EndTime = TestProperty.Register("TestResult.EndTime", "End Time", typeof(DateTimeOffset), typeof(TestResult)); + public static readonly TestProperty ErrorMessage = TestProperty.Register("TestResult.ErrorMessage", "Error Message", typeof(string), typeof(TestResult)); + public static readonly TestProperty ErrorStackTrace = TestProperty.Register("TestResult.ErrorStackTrace", "Error Stack Trace", typeof(string), typeof(TestResult)); #else [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] public static readonly TestProperty DisplayName = TestProperty.Register("TestResult.DisplayName", Resources.Resources.TestResultPropertyDisplayNameLabel, typeof(string), TestPropertyAttributes.Hidden, typeof(TestResult)); @@ -358,21 +343,20 @@ public static class TestResultProperties [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] public static readonly TestProperty ErrorStackTrace = TestProperty.Register("TestResult.ErrorStackTrace", Resources.Resources.TestResultPropertyErrorStackTraceLabel, typeof(string), typeof(TestResult)); #endif - internal static TestProperty[] Properties { get; } = - { - ComputerName, - DisplayName, - Duration, - EndTime, - ErrorMessage, - ErrorStackTrace, - Outcome, - StartTime - }; - - private static bool ValidateOutcome(object value) - { - return (TestOutcome)value <= TestOutcome.NotFound && (TestOutcome)value >= TestOutcome.None; - } + internal static TestProperty[] Properties { get; } = + { + ComputerName, + DisplayName, + Duration, + EndTime, + ErrorMessage, + ErrorStackTrace, + Outcome, + StartTime + }; + + private static bool ValidateOutcome(object value) + { + return (TestOutcome)value <= TestOutcome.NotFound && (TestOutcome)value >= TestOutcome.None; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Trait.cs b/src/Microsoft.TestPlatform.ObjectModel/Trait.cs index 5d28417880..c326cd308a 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Trait.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Trait.cs @@ -1,41 +1,40 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + #if NETFRAMEWORK - using System; +using System; #endif - using System.Collections.Generic; - using System.Runtime.Serialization; +using System.Collections.Generic; +using System.Runtime.Serialization; - /// - /// Class that holds Trait. - /// A traits is Name, Value pair. - /// +/// +/// Class that holds Trait. +/// A traits is Name, Value pair. +/// #if NETFRAMEWORK - [Serializable] +[Serializable] #endif - [DataContract] - public class Trait - { - [DataMember(Name = "Key")] - public string Name { get; set; } +[DataContract] +public class Trait +{ + [DataMember(Name = "Key")] + public string Name { get; set; } - [DataMember(Name = "Value")] - public string Value { get; set; } + [DataMember(Name = "Value")] + public string Value { get; set; } - internal Trait(KeyValuePair data) - : this(data.Key, data.Value) - { - } + internal Trait(KeyValuePair data) + : this(data.Key, data.Value) + { + } - public Trait(string name, string value) - { - ValidateArg.NotNull(name, nameof(name)); + public Trait(string name, string value) + { + ValidateArg.NotNull(name, nameof(name)); - this.Name = name; - this.Value = value; - } + Name = name; + Value = value; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/TraitCollection.cs b/src/Microsoft.TestPlatform.ObjectModel/TraitCollection.cs index 7bd21fdcd1..b99b644906 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/TraitCollection.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/TraitCollection.cs @@ -1,103 +1,103 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Class that holds collection of traits - /// +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + #if NETFRAMEWORK - [Serializable] +using System; #endif - public class TraitCollection : IEnumerable - { - internal const string TraitPropertyId = "TestObject.Traits"; - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - private static readonly TestProperty TraitsProperty = TestProperty.Register( - TraitPropertyId, +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +/// +/// Class that holds collection of traits +/// +#if NETFRAMEWORK +[Serializable] +#endif +public class TraitCollection : IEnumerable +{ + internal const string TraitPropertyId = "TestObject.Traits"; + private static readonly TestProperty TraitsProperty = TestProperty.Register( + TraitPropertyId, #if !NET451 - // TODO: Fix this with proper resourcing for UWP and Win 8.1 Apps - // Trying to access resources will throw "MissingManifestResourceException" percolated as "TypeInitialization" exception - "Traits", + // TODO: Fix this with proper resourcing for UWP and Win 8.1 Apps + // Trying to access resources will throw "MissingManifestResourceException" percolated as "TypeInitialization" exception + "Traits", #else - Resources.Resources.TestCasePropertyTraitsLabel, + Resources.Resources.TestCasePropertyTraitsLabel, #endif - typeof(KeyValuePair[]), + typeof(KeyValuePair[]), #pragma warning disable 618 - TestPropertyAttributes.Hidden | TestPropertyAttributes.Trait, + TestPropertyAttributes.Hidden | TestPropertyAttributes.Trait, #pragma warning restore 618 - typeof(TestObject)); + typeof(TestObject)); #if NETFRAMEWORK - [NonSerialized] + [NonSerialized] #endif - private readonly TestObject testObject; + private readonly TestObject _testObject; - internal TraitCollection(TestObject testObject) - { - ValidateArg.NotNull(testObject, nameof(testObject)); + internal TraitCollection(TestObject testObject) + { + ValidateArg.NotNull(testObject, nameof(testObject)); - this.testObject = testObject; - } + _testObject = testObject; + } - public void Add(Trait trait) - { - ValidateArg.NotNull(trait, nameof(trait)); + public void Add(Trait trait) + { + ValidateArg.NotNull(trait, nameof(trait)); - this.AddRange(new[] { trait }); - } + AddRange(new[] { trait }); + } - public void Add(string name, string value) - { - ValidateArg.NotNull(name, nameof(name)); + public void Add(string name, string value) + { + ValidateArg.NotNull(name, nameof(name)); - this.Add(new Trait(name, value)); - } + Add(new Trait(name, value)); + } - public void AddRange(IEnumerable traits) - { - ValidateArg.NotNull(traits, nameof(traits)); + public void AddRange(IEnumerable traits) + { + ValidateArg.NotNull(traits, nameof(traits)); - var existingTraits = this.GetTraits(); - this.Add(existingTraits, traits); - } + var existingTraits = GetTraits(); + Add(existingTraits, traits); + } - public IEnumerator GetEnumerator() - { - var enumerable = this.GetTraits(); - return enumerable.GetEnumerator(); - } + public IEnumerator GetEnumerator() + { + var enumerable = GetTraits(); + return enumerable.GetEnumerator(); + } - IEnumerator IEnumerable.GetEnumerator() - { - return this.GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } - private IEnumerable GetTraits() + private IEnumerable GetTraits() + { + if (!_testObject.Properties.Contains(TraitsProperty)) { - if (!this.testObject.Properties.Contains(TraitsProperty)) - { - yield break; - } - - var traits = this.testObject.GetPropertyValue(TraitsProperty, Enumerable.Empty>().ToArray()); - - foreach (var trait in traits) - { - yield return new Trait(trait); - } + yield break; } - private void Add(IEnumerable traits, IEnumerable newTraits) + var traits = _testObject.GetPropertyValue(TraitsProperty, Enumerable.Empty>().ToArray()); + + foreach (var trait in traits) { - var newValue = traits.Union(newTraits); - var newPairs = newValue.Select(t => new KeyValuePair(t.Name, t.Value)).ToArray(); - this.testObject.SetPropertyValue[]>(TraitsProperty, newPairs); + yield return new Trait(trait); } } -} + + private void Add(IEnumerable traits, IEnumerable newTraits) + { + var newValue = traits.Union(newTraits); + var newPairs = newValue.Select(t => new KeyValuePair(t.Name, t.Value)).ToArray(); + _testObject.SetPropertyValue(TraitsProperty, newPairs); + } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/UapConstants.cs b/src/Microsoft.TestPlatform.ObjectModel/UapConstants.cs index ab8a0bd267..06fed078a7 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/UapConstants.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/UapConstants.cs @@ -1,21 +1,20 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +/// +/// Defines the constants used during UWP app execution. +/// +public static class UapConstants { /// - /// Defines the constants used during UWP app execution. + /// The UWP PackageName after it is deployed. /// - public static class UapConstants - { - /// - /// The UWP PackageName after it is deployed. - /// - public static readonly string UapPackageFullName = "PackageFullName"; + public static readonly string UapPackageFullName = "PackageFullName"; - /// - /// The UWP Package ID after it is deployed. - /// - public static readonly string UapAppUserModeId = "AppUserModeId"; - } -} + /// + /// The UWP Package ID after it is deployed. + /// + public static readonly string UapAppUserModeId = "AppUserModeId"; +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Utilities/AssemblyHelper.cs b/src/Microsoft.TestPlatform.ObjectModel/Utilities/AssemblyHelper.cs index 080532c492..d497c0896e 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Utilities/AssemblyHelper.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Utilities/AssemblyHelper.cs @@ -1,187 +1,253 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities -{ - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +#if NETFRAMEWORK +using Adapter; +#endif - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.IO; - using System.Linq; - using System.Reflection; +using System; +using System.Collections.Generic; +#if NETFRAMEWORK +using System.Diagnostics; +using System.IO; +#endif +using System.Linq; +using System.Reflection; + +/// +/// Implementation of finding assembly references using "managed route", i.e. Assembly.Load. +/// +public static class AssemblyHelper +{ +#if NETFRAMEWORK + private static readonly Version DefaultVersion = new(); + private static readonly Version Version45 = new("4.5"); /// - /// Implementation of finding assembly references using "managed route", i.e. Assembly.Load. + /// Checks whether the source assembly directly references given assembly or not. + /// Only assembly name and public key token are match. Version is ignored for matching. + /// Returns null if not able to check if source references assembly. /// - public static class AssemblyHelper + public static bool? DoesReferencesAssembly(string source, AssemblyName referenceAssembly) { -#if NETFRAMEWORK - private static Version defaultVersion = new Version(); - private static Version version45 = new Version("4.5"); - - /// - /// Checks whether the source assembly directly references given assembly or not. - /// Only assembly name and public key token are match. Version is ignored for matching. - /// Returns null if not able to check if source references assembly. - /// - public static bool? DoesReferencesAssembly(string source, AssemblyName referenceAssembly) + try { - try - { - ValidateArg.NotNullOrEmpty(source, nameof(source)); - ValidateArg.NotNull(referenceAssembly, nameof(referenceAssembly)); + ValidateArg.NotNullOrEmpty(source, nameof(source)); + ValidateArg.NotNull(referenceAssembly, nameof(referenceAssembly)); - Debug.Assert(!string.IsNullOrEmpty(source)); + Debug.Assert(!string.IsNullOrEmpty(source)); - var referenceAssemblyName = referenceAssembly.Name; - var referenceAssemblyPublicKeyToken = referenceAssembly.GetPublicKeyToken(); + var referenceAssemblyName = referenceAssembly.Name; + var referenceAssemblyPublicKeyToken = referenceAssembly.GetPublicKeyToken(); - var setupInfo = new AppDomainSetup(); - setupInfo.ApplicationBase = Path.GetDirectoryName(Path.GetFullPath(source)); + var setupInfo = new AppDomainSetup(); + setupInfo.ApplicationBase = Path.GetDirectoryName(Path.GetFullPath(source)); - // In Dev10 by devenv uses its own app domain host which has default optimization to share everything. - // Set LoaderOptimization to MultiDomainHost which means: - // Indicates that the application will probably host unique code in multiple domains, - // and the loader must share resources across application domains only for globally available (strong-named) - // assemblies that have been added to the global assembly cache. - setupInfo.LoaderOptimization = LoaderOptimization.MultiDomainHost; + // In Dev10 by devenv uses its own app domain host which has default optimization to share everything. + // Set LoaderOptimization to MultiDomainHost which means: + // Indicates that the application will probably host unique code in multiple domains, + // and the loader must share resources across application domains only for globally available (strong-named) + // assemblies that have been added to the global assembly cache. + setupInfo.LoaderOptimization = LoaderOptimization.MultiDomainHost; - AppDomain ad = null; - try + AppDomain ad = null; + try + { + ad = AppDomain.CreateDomain("Dependency finder domain", null, setupInfo); + + var assemblyLoadWorker = typeof(AssemblyLoadWorker); + AssemblyLoadWorker worker = null; + if (assemblyLoadWorker.Assembly.GlobalAssemblyCache) { - ad = AppDomain.CreateDomain("Dependency finder domain", null, setupInfo); - - var assemblyLoadWorker = typeof(AssemblyLoadWorker); - AssemblyLoadWorker worker = null; - if (assemblyLoadWorker.Assembly.GlobalAssemblyCache) - { - worker = (AssemblyLoadWorker)ad.CreateInstanceAndUnwrap( - assemblyLoadWorker.Assembly.FullName, - assemblyLoadWorker.FullName, - false, BindingFlags.Default, null, - null, null, null); - } - else - { - // This has to be LoadFrom, otherwise we will have to use AssemblyResolver to find self. - worker = (AssemblyLoadWorker)ad.CreateInstanceFromAndUnwrap( - assemblyLoadWorker.Assembly.Location, - assemblyLoadWorker.FullName, - false, BindingFlags.Default, null, - null, null, null); - } - - return worker.CheckAssemblyReference(source, referenceAssemblyName, referenceAssemblyPublicKeyToken); + worker = (AssemblyLoadWorker)ad.CreateInstanceAndUnwrap( + assemblyLoadWorker.Assembly.FullName, + assemblyLoadWorker.FullName, + false, BindingFlags.Default, null, + null, null, null); } - finally + else { - if (ad != null) - { - AppDomain.Unload(ad); - } + // This has to be LoadFrom, otherwise we will have to use AssemblyResolver to find self. + worker = (AssemblyLoadWorker)ad.CreateInstanceFromAndUnwrap( + assemblyLoadWorker.Assembly.Location, + assemblyLoadWorker.FullName, + false, BindingFlags.Default, null, + null, null, null); } + + return worker.CheckAssemblyReference(source, referenceAssemblyName, referenceAssemblyPublicKeyToken); } - catch + finally { - return null; // Return null if something goes wrong. + if (ad != null) + { + AppDomain.Unload(ad); + } } } + catch + { + return null; // Return null if something goes wrong. + } + } - /// - /// Finds platform and .Net framework version for a given test container. - /// If there is an error while inferring this information, defaults (AnyCPU, None) are returned - /// for faulting container. - /// - /// - /// - public static KeyValuePair GetFrameworkVersionAndArchitectureForSource(string testSource) + /// + /// Finds platform and .Net framework version for a given test container. + /// If there is an error while inferring this information, defaults (AnyCPU, None) are returned + /// for faulting container. + /// + /// + /// + public static KeyValuePair GetFrameworkVersionAndArchitectureForSource(string testSource) + { + ValidateArg.NotNullOrEmpty(testSource, nameof(testSource)); + + var sourceDirectory = Path.GetDirectoryName(testSource); + var setupInfo = new AppDomainSetup(); + setupInfo.ApplicationBase = sourceDirectory; + setupInfo.LoaderOptimization = LoaderOptimization.MultiDomainHost; + AppDomain ad = null; + try { - ValidateArg.NotNullOrEmpty(testSource, nameof(testSource)); + ad = AppDomain.CreateDomain("Multiargeting settings domain", null, setupInfo); - var sourceDirectory = Path.GetDirectoryName(testSource); - var setupInfo = new AppDomainSetup(); - setupInfo.ApplicationBase = sourceDirectory; - setupInfo.LoaderOptimization = LoaderOptimization.MultiDomainHost; - AppDomain ad = null; - try + Type assemblyLoadWorker = typeof(AssemblyLoadWorker); + AssemblyLoadWorker worker = null; + + // This has to be LoadFrom, otherwise we will have to use AssemblyResolver to find self. + worker = (AssemblyLoadWorker)ad.CreateInstanceFromAndUnwrap( + assemblyLoadWorker.Assembly.Location, + assemblyLoadWorker.FullName, + false, BindingFlags.Default, null, + null, null, null); + + worker.GetPlatformAndFrameworkSettings(testSource, out var procArchType, out var frameworkVersion); + + Architecture targetPlatform = (Architecture)Enum.Parse(typeof(Architecture), procArchType); + var targetFramework = frameworkVersion.ToUpperInvariant() switch { - ad = AppDomain.CreateDomain("Multiargeting settings domain", null, setupInfo); + "V4.5" => FrameworkVersion.Framework45, + "V4.0" => FrameworkVersion.Framework40, + "V3.5" or "V2.0" => FrameworkVersion.Framework35, + _ => FrameworkVersion.None, + }; + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("Inferred Multi-Targeting settings:{0} Platform:{1} FrameworkVersion:{2}", testSource, targetPlatform, targetFramework); + } + return new KeyValuePair(targetPlatform, targetFramework); - Type assemblyLoadWorker = typeof(AssemblyLoadWorker); - AssemblyLoadWorker worker = null; + } + finally + { + if (ad != null) + { + AppDomain.Unload(ad); + } + } + } + /// + /// Returns the full name (AssemblyName.FullName) of the referenced assemblies by the assembly on the specified path. + /// + /// Returns null on failure and an empty array if there is no reference in the project. + /// + /// Full path to the assembly to get dependencies for. + public static string[] GetReferencedAssemblies(string source) + { + Debug.Assert(!string.IsNullOrEmpty(source)); + + var setupInfo = new AppDomainSetup(); + setupInfo.ApplicationBase = Path.GetDirectoryName(Path.GetFullPath(source)); + + // In Dev10 by devenv uses its own app domain host which has default optimization to share everything. + // Set LoaderOptimization to MultiDomainHost which means: + // Indicates that the application will probably host unique code in multiple domains, + // and the loader must share resources across application domains only for globally available (strong-named) + // assemblies that have been added to the global assembly cache. + setupInfo.LoaderOptimization = LoaderOptimization.MultiDomainHost; + + AppDomain ad = null; + try + { + ad = AppDomain.CreateDomain("Dependency finder domain", null, setupInfo); + + var assemblyLoadWorker = typeof(AssemblyLoadWorker); + AssemblyLoadWorker worker = null; + if (assemblyLoadWorker.Assembly.GlobalAssemblyCache) + { + worker = (AssemblyLoadWorker)ad.CreateInstanceAndUnwrap( + assemblyLoadWorker.Assembly.FullName, + assemblyLoadWorker.FullName, + false, BindingFlags.Default, null, + null, null, null); + } + else + { // This has to be LoadFrom, otherwise we will have to use AssemblyResolver to find self. worker = (AssemblyLoadWorker)ad.CreateInstanceFromAndUnwrap( assemblyLoadWorker.Assembly.Location, assemblyLoadWorker.FullName, false, BindingFlags.Default, null, null, null, null); + } - worker.GetPlatformAndFrameworkSettings(testSource, out var procArchType, out var frameworkVersion); + return worker.GetReferencedAssemblies(source); + } + finally + { + if (ad != null) + { + AppDomain.Unload(ad); + } + } + } - Architecture targetPlatform = (Architecture)Enum.Parse(typeof(Architecture), procArchType); - FrameworkVersion targetFramework = FrameworkVersion.Framework45; - switch (frameworkVersion.ToUpperInvariant()) - { - case "V4.5": - targetFramework = FrameworkVersion.Framework45; - break; - - case "V4.0": - targetFramework = FrameworkVersion.Framework40; - break; - - case "V3.5": - case "V2.0": - targetFramework = FrameworkVersion.Framework35; - break; - - default: - targetFramework = FrameworkVersion.None; - break; - } - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("Inferred Multi-Targeting settings:{0} Platform:{1} FrameworkVersion:{2}", testSource, targetPlatform, targetFramework); - } - return new KeyValuePair(targetPlatform, targetFramework); + /// + /// Set the target framework for app domain setup if target framework of dll is > 4.5 + /// + /// AppdomainSetup for app domain creation + /// path of test file + public static void SetAppDomainFrameworkVersionBasedOnTestSource(AppDomainSetup setup, string testSource) + { + string assemblyVersionString = GetTargetFrameworkVersionString(testSource); - } - finally + if (GetTargetFrameworkVersionFromVersionString(assemblyVersionString).CompareTo(Version45) > 0) + { + var pInfo = typeof(AppDomainSetup).GetProperty(Constants.TargetFrameworkName); + if (null != pInfo) { - if (ad != null) - { - AppDomain.Unload(ad); - } + pInfo.SetValue(setup, assemblyVersionString, null); } } + } - /// - /// Returns the full name (AssemblyName.FullName) of the referenced assemblies by the assembly on the specified path. - /// - /// Returns null on failure and an empty array if there is no reference in the project. - /// - /// Full path to the assembly to get dependencies for. - public static string[] GetReferencedAssemblies(string source) - { - Debug.Assert(!string.IsNullOrEmpty(source)); + /// + /// Get the target dot net framework string for the assembly + /// + /// Path of the assembly file + /// String representation of the target dot net framework e.g. .NETFramework,Version=v4.0 + internal static string GetTargetFrameworkVersionString(string path) + { + Debug.Assert(!string.IsNullOrEmpty(path)); - var setupInfo = new AppDomainSetup(); - setupInfo.ApplicationBase = Path.GetDirectoryName(Path.GetFullPath(source)); + var setupInfo = new AppDomainSetup(); + setupInfo.ApplicationBase = Path.GetDirectoryName(Path.GetFullPath(path)); - // In Dev10 by devenv uses its own app domain host which has default optimization to share everything. - // Set LoaderOptimization to MultiDomainHost which means: - // Indicates that the application will probably host unique code in multiple domains, - // and the loader must share resources across application domains only for globally available (strong-named) - // assemblies that have been added to the global assembly cache. - setupInfo.LoaderOptimization = LoaderOptimization.MultiDomainHost; + // In Dev10 by devenv uses its own app domain host which has default optimization to share everything. + // Set LoaderOptimization to MultiDomainHost which means: + // Indicates that the application will probably host unique code in multiple domains, + // and the loader must share resources across application domains only for globally available (strong-named) + // assemblies that have been added to the global assembly cache. + setupInfo.LoaderOptimization = LoaderOptimization.MultiDomainHost; + if (File.Exists(path)) + { AppDomain ad = null; try { - ad = AppDomain.CreateDomain("Dependency finder domain", null, setupInfo); + ad = AppDomain.CreateDomain("Framework Version String Domain", null, setupInfo); var assemblyLoadWorker = typeof(AssemblyLoadWorker); AssemblyLoadWorker worker = null; @@ -203,7 +269,7 @@ public static string[] GetReferencedAssemblies(string source) null, null, null); } - return worker.GetReferencedAssemblies(source); + return worker.GetTargetFrameworkVersionStringFromPath(path); } finally { @@ -214,144 +280,63 @@ public static string[] GetReferencedAssemblies(string source) } } - /// - /// Set the target framework for app domain setup if target framework of dll is > 4.5 - /// - /// AppdomainSetup for app domain creation - /// path of test file - public static void SetAppDomainFrameworkVersionBasedOnTestSource(AppDomainSetup setup, string testSource) - { - string assemblyVersionString = GetTargetFrameworkVersionString(testSource); - - if (GetTargetFrameworkVersionFromVersionString(assemblyVersionString).CompareTo(version45) > 0) - { - var pInfo = typeof(AppDomainSetup).GetProperty(Constants.TargetFrameworkName); - if (null != pInfo) - { - pInfo.SetValue(setup, assemblyVersionString, null); - } - } - } + return string.Empty; + } - /// - /// Get the target dot net framework string for the assembly - /// - /// Path of the assembly file - /// String representation of the target dot net framework e.g. .NETFramework,Version=v4.0 - internal static string GetTargetFrameworkVersionString(string path) + /// + /// Get the Version for the target framework version string + /// + /// Target framework string + /// Framework Version + internal static Version GetTargetFrameworkVersionFromVersionString(string version) + { + if (version.Length > Constants.DotNetFrameWorkStringPrefix.Length + 1) { - Debug.Assert(!string.IsNullOrEmpty(path)); - - var setupInfo = new AppDomainSetup(); - setupInfo.ApplicationBase = Path.GetDirectoryName(Path.GetFullPath(path)); - - // In Dev10 by devenv uses its own app domain host which has default optimization to share everything. - // Set LoaderOptimization to MultiDomainHost which means: - // Indicates that the application will probably host unique code in multiple domains, - // and the loader must share resources across application domains only for globally available (strong-named) - // assemblies that have been added to the global assembly cache. - setupInfo.LoaderOptimization = LoaderOptimization.MultiDomainHost; - - if (File.Exists(path)) - { - AppDomain ad = null; - try - { - ad = AppDomain.CreateDomain("Framework Version String Domain", null, setupInfo); - - var assemblyLoadWorker = typeof(AssemblyLoadWorker); - AssemblyLoadWorker worker = null; - if (assemblyLoadWorker.Assembly.GlobalAssemblyCache) - { - worker = (AssemblyLoadWorker)ad.CreateInstanceAndUnwrap( - assemblyLoadWorker.Assembly.FullName, - assemblyLoadWorker.FullName, - false, BindingFlags.Default, null, - null, null, null); - } - else - { - // This has to be LoadFrom, otherwise we will have to use AssemblyResolver to find self. - worker = (AssemblyLoadWorker)ad.CreateInstanceFromAndUnwrap( - assemblyLoadWorker.Assembly.Location, - assemblyLoadWorker.FullName, - false, BindingFlags.Default, null, - null, null, null); - } - - return worker.GetTargetFrameworkVersionStringFromPath(path); - } - finally - { - if (ad != null) - { - AppDomain.Unload(ad); - } - } - } - - return string.Empty; + string versionPart = version.Substring(Constants.DotNetFrameWorkStringPrefix.Length + 1); + return new Version(versionPart); } - /// - /// Get the Version for the target framework version string - /// - /// Target framework string - /// Framework Version - internal static Version GetTargetFrameworkVersionFromVersionString(string version) - { - if (version.Length > Constants.DotNetFrameWorkStringPrefix.Length + 1) - { - string versionPart = version.Substring(Constants.DotNetFrameWorkStringPrefix.Length + 1); - return new Version(versionPart); - } - - return defaultVersion; - } + return DefaultVersion; + } - /// - /// When test run is targeted for .Net4.0, set target framework of test appdomain to be v4.0. - /// With this done tests would be executed in 4.0 compatibility mode even when .Net4.5 is installed. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Failure to set this property should be ignored.")] - internal static void SetNETFrameworkCompatiblityMode(AppDomainSetup setup, IRunContext runContext) + /// + /// When test run is targeted for .Net4.0, set target framework of test appdomain to be v4.0. + /// With this done tests would be executed in 4.0 compatibility mode even when .Net4.5 is installed. + /// + internal static void SetNETFrameworkCompatiblityMode(AppDomainSetup setup, IRunContext runContext) + { + try { - try + RunConfiguration runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runContext.RunSettings.SettingsXml); + if (null != runConfiguration && (Equals(runConfiguration.TargetFramework, FrameworkVersion.Framework40) || + string.Equals(runConfiguration.TargetFramework.ToString(), Constants.DotNetFramework40, StringComparison.OrdinalIgnoreCase))) { - RunConfiguration runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runContext.RunSettings.SettingsXml); - if (null != runConfiguration && (Enum.Equals(runConfiguration.TargetFramework, FrameworkVersion.Framework40) || - string.Equals(runConfiguration.TargetFramework.ToString(), Constants.DotNetFramework40, StringComparison.OrdinalIgnoreCase))) + if (EqtTrace.IsVerboseEnabled) { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("AssemblyHelper.SetNETFrameworkCompatiblityMode: setting .NetFramework,Version=v4.0 compatibility mode."); - } - setup.TargetFrameworkName = Constants.DotNetFramework40; + EqtTrace.Verbose("AssemblyHelper.SetNETFrameworkCompatiblityMode: setting .NetFramework,Version=v4.0 compatibility mode."); } + setup.TargetFrameworkName = Constants.DotNetFramework40; } - catch (Exception e) + } + catch (Exception e) + { + if (EqtTrace.IsErrorEnabled) { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("AssemblyHelper:SetNETFrameworkCompatiblityMode: Caught an exception:{0}", e); - } + EqtTrace.Error("AssemblyHelper:SetNETFrameworkCompatiblityMode: Caught an exception:{0}", e); } } + } #endif - public static IEnumerable GetCustomAttributes(this Assembly assembly, string fullyQualifiedName) - { - ValidateArg.NotNull(assembly, nameof(assembly)); - ValidateArg.NotNullOrWhiteSpace(fullyQualifiedName, nameof(fullyQualifiedName)); - - if(assembly.GetType(fullyQualifiedName) is Type attribute) - { - return assembly.GetCustomAttributes(attribute); - } + public static IEnumerable GetCustomAttributes(this Assembly assembly, string fullyQualifiedName) + { + ValidateArg.NotNull(assembly, nameof(assembly)); + ValidateArg.NotNullOrWhiteSpace(fullyQualifiedName, nameof(fullyQualifiedName)); - return assembly + return assembly.GetType(fullyQualifiedName) is Type attribute + ? assembly.GetCustomAttributes(attribute) + : assembly .GetCustomAttributes() .Where(i => i.GetType().FullName == fullyQualifiedName); - } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Utilities/AssemblyLoadWorker.cs b/src/Microsoft.TestPlatform.ObjectModel/Utilities/AssemblyLoadWorker.cs index 6ce8754042..a8d95532e9 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Utilities/AssemblyLoadWorker.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Utilities/AssemblyLoadWorker.cs @@ -1,385 +1,372 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities -{ +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; #if NETFRAMEWORK - using System; - using System.Diagnostics; - using System.IO; - using System.Linq; - using System.Reflection; - +using System; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; + +/// +/// Does the real work of finding references using Assembly.ReflectionOnlyLoadFrom. +/// The caller is supposed to create AppDomain and create instance of given class in there. +/// +internal class AssemblyLoadWorker : MarshalByRefObject +{ /// - /// Does the real work of finding references using Assembly.ReflectionOnlyLoadFrom. - /// The caller is supposed to create AppDomain and create instance of given class in there. + /// Get the target dot net framework string for the assembly /// - internal class AssemblyLoadWorker : MarshalByRefObject + /// Path of the assembly file + /// String representation of the target dot net framework e.g. .NETFramework,Version=v4.0 + public string GetTargetFrameworkVersionStringFromPath(string path) { - /// - /// Get the target dot net framework string for the assembly - /// - /// Path of the assembly file - /// String representation of the target dot net framework e.g. .NETFramework,Version=v4.0 - public string GetTargetFrameworkVersionStringFromPath(string path) + if (!File.Exists(path)) { - if (!File.Exists(path)) - { - return string.Empty; - } + return string.Empty; + } - try - { - var a = Assembly.ReflectionOnlyLoadFrom(path); - return GetTargetFrameworkStringFromAssembly(a); - } - catch (BadImageFormatException) + try + { + var a = Assembly.ReflectionOnlyLoadFrom(path); + return GetTargetFrameworkStringFromAssembly(a); + } + catch (BadImageFormatException) + { + if (EqtTrace.IsErrorEnabled) { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("AssemblyLoadWorker:GetTargetFrameworkVersionString() caught BadImageFormatException. Falling to native binary."); - } + EqtTrace.Error("AssemblyLoadWorker:GetTargetFrameworkVersionString() caught BadImageFormatException. Falling to native binary."); } - catch (Exception ex) + } + catch (Exception ex) + { + if (EqtTrace.IsErrorEnabled) { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("AssemblyLoadWorker:GetTargetFrameworkVersionString() Returning default. Unhandled exception: {0}.", ex); - } + EqtTrace.Error("AssemblyLoadWorker:GetTargetFrameworkVersionString() Returning default. Unhandled exception: {0}.", ex); } - - return string.Empty; } - /// - /// Get the target dot net framework string for the assembly - /// - /// Assembly - /// String representation of the target dot net framework e.g. .NETFramework,Version=v4.0 - internal static string GetTargetFrameworkStringFromAssembly(Assembly assembly) + return string.Empty; + } + + /// + /// Get the target dot net framework string for the assembly + /// + /// Assembly + /// String representation of the target dot net framework e.g. .NETFramework,Version=v4.0 + internal static string GetTargetFrameworkStringFromAssembly(Assembly assembly) + { + var dotNetVersion = string.Empty; + foreach (var data in CustomAttributeData.GetCustomAttributes(assembly)) { - var dotNetVersion = string.Empty; - foreach (var data in CustomAttributeData.GetCustomAttributes(assembly)) + if (data.NamedArguments?.Count > 0) { - if (data.NamedArguments?.Count > 0) + string attributeName = data.NamedArguments[0].MemberInfo.DeclaringType.FullName; + if (string.Equals(attributeName, Constants.TargetFrameworkAttributeFullName, StringComparison.OrdinalIgnoreCase)) { - string attributeName = data.NamedArguments[0].MemberInfo.DeclaringType.FullName; - if (string.Equals(attributeName, Constants.TargetFrameworkAttributeFullName, StringComparison.OrdinalIgnoreCase)) - { - dotNetVersion = data.ConstructorArguments[0].Value.ToString(); - break; - } + dotNetVersion = data.ConstructorArguments[0].Value.ToString(); + break; } } - - return dotNetVersion; } - /// - /// Returns the full name of the referenced assemblies by the assembly on the specified path. - /// - /// Returns null on failure and an empty array if there is no reference in the project. - /// - /// Path to the assembly file to load from. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "Being created in a separate app-domain"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - public string[] GetReferencedAssemblies(string path) - { - Debug.Assert(!string.IsNullOrEmpty(path)); - - Assembly a = null; - try - { - // ReflectionOnlyLoadFrom does not use the probing paths and loads from the - // specified path only and does not let code to be executed by the assembly - // in the loaded context. - a = Assembly.ReflectionOnlyLoadFrom(path); - } - catch - { - return null; - } - Debug.Assert(a != null); + return dotNetVersion; + } - AssemblyName[] assemblies = a.GetReferencedAssemblies(); - if (assemblies == null || assemblies.Length == 0) - { - return new string[0]; - } + /// + /// Returns the full name of the referenced assemblies by the assembly on the specified path. + /// + /// Returns null on failure and an empty array if there is no reference in the project. + /// + /// Path to the assembly file to load from. + public string[] GetReferencedAssemblies(string path) + { + Debug.Assert(!string.IsNullOrEmpty(path)); - return (from assembly in assemblies - select assembly.FullName).ToArray(); + Assembly a = null; + try + { + // ReflectionOnlyLoadFrom does not use the probing paths and loads from the + // specified path only and does not let code to be executed by the assembly + // in the loaded context. + a = Assembly.ReflectionOnlyLoadFrom(path); + } + catch + { + return null; } + Debug.Assert(a != null); + + AssemblyName[] assemblies = a.GetReferencedAssemblies(); + return assemblies == null || assemblies.Length == 0 + ? (new string[0]) + : (from assembly in assemblies + select assembly.FullName).ToArray(); + } - /// - /// Returns true if given assembly matched name and public key token. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "Being created in a separate app-domain"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - public bool? CheckAssemblyReference(string path, string referenceAssemblyName, byte[] publicKeyToken) + /// + /// Returns true if given assembly matched name and public key token. + /// + public bool? CheckAssemblyReference(string path, string referenceAssemblyName, byte[] publicKeyToken) + { + try { - Assembly a = null; - try - { - // ReflectionOnlyLoadFrom does not use the probing paths and loads from the - // specified path only and does not let code to be executed by the assembly - // in the loaded context. - // - a = Assembly.ReflectionOnlyLoadFrom(path); + // ReflectionOnlyLoadFrom does not use the probing paths and loads from the + // specified path only and does not let code to be executed by the assembly + // in the loaded context. + // + Assembly a = Assembly.ReflectionOnlyLoadFrom(path); - Debug.Assert(a != null); + Debug.Assert(a != null); - AssemblyName[] assemblies = a.GetReferencedAssemblies(); + AssemblyName[] assemblies = a.GetReferencedAssemblies(); - foreach (AssemblyName referencedAssembly in assemblies) + foreach (AssemblyName referencedAssembly in assemblies) + { + // Check without version. Only name and public key token. + if (string.Equals(referencedAssembly.Name, referenceAssemblyName, StringComparison.OrdinalIgnoreCase)) { - // Check without version. Only name and public key token. - if (string.Equals(referencedAssembly.Name, referenceAssemblyName, StringComparison.OrdinalIgnoreCase)) - { - byte[] publicKeyToken1 = referencedAssembly.GetPublicKeyToken(); + byte[] publicKeyToken1 = referencedAssembly.GetPublicKeyToken(); - bool isMatch = true; - if (publicKeyToken1.Length != publicKeyToken.Length) - { - continue; - } + bool isMatch = true; + if (publicKeyToken1.Length != publicKeyToken.Length) + { + continue; + } - for (int i = 0; i < publicKeyToken1.Length; ++i) + for (int i = 0; i < publicKeyToken1.Length; ++i) + { + if (publicKeyToken1[i] != publicKeyToken[i]) { - if (publicKeyToken1[i] != publicKeyToken[i]) - { - isMatch = false; - break; - } + isMatch = false; + break; } + } - if (isMatch) - { - return true; - } + if (isMatch) + { + return true; } } } - catch - { - return null; // return null if not able to check. - } - - return false; + } + catch + { + return null; // return null if not able to check. } - /// - /// Finds platform and .Net framework version for a given container. - /// In case of errors defaults are returned. - /// - /// - /// - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "Being created in a separate app-domain")] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - public void GetPlatformAndFrameworkSettings(string path, out string procArchType, out string frameworkVersion) + return false; + } + + /// + /// Finds platform and .Net framework version for a given container. + /// In case of errors defaults are returned. + /// + /// + /// + /// + public void GetPlatformAndFrameworkSettings(string path, out string procArchType, out string frameworkVersion) + { + procArchType = nameof(Architecture.Default); + frameworkVersion = String.Empty; + + try { - procArchType = nameof(Architecture.Default); - frameworkVersion = String.Empty; + // ReflectionOnlyLoadFrom does not use the probing paths and loads from the + // specified path only and does not let code to be executed by the assembly + // in the loaded context. - try + var a = Assembly.ReflectionOnlyLoadFrom(path); + Debug.Assert(a != null); + a.ManifestModule.GetPEKind(out var peKind, out var machine); + + // conversion to string type is needed for below reason + // -- PortableExecutableKinds.Preferred32Bit and ImageFileMachine.ARM is available only + // in .Net4.0 and above. Below code is compiled with .Net3.5 but runs in .Net4.0 + string peKindString = peKind.ToString(); + string machineTypeString = machine.ToString(); + if (string.Equals(machineTypeString, "I386", StringComparison.OrdinalIgnoreCase)) { - // ReflectionOnlyLoadFrom does not use the probing paths and loads from the - // specified path only and does not let code to be executed by the assembly - // in the loaded context. - - var a = Assembly.ReflectionOnlyLoadFrom(path); - Debug.Assert(a != null); - a.ManifestModule.GetPEKind(out var peKind, out var machine); - - // conversion to string type is needed for below reason - // -- PortableExecutableKinds.Preferred32Bit and ImageFileMachine.ARM is available only - // in .Net4.0 and above. Below code is compiled with .Net3.5 but runs in .Net4.0 - string peKindString = peKind.ToString(); - string machineTypeString = machine.ToString(); - if (string.Equals(machineTypeString, "I386", StringComparison.OrdinalIgnoreCase)) + if (peKindString.Contains("Preferred32Bit") || peKindString.Contains("Required32Bit")) { - if (peKindString.Contains("Preferred32Bit") || peKindString.Contains("Required32Bit")) - { - procArchType = "X86"; - } - else if (string.Equals(peKindString, "ILOnly", StringComparison.OrdinalIgnoreCase)) - { - procArchType = "AnyCPU"; - } + procArchType = "X86"; } - else if (string.Equals(machineTypeString, "AMD64", StringComparison.OrdinalIgnoreCase) || - string.Equals(machineTypeString, "IA64", StringComparison.OrdinalIgnoreCase)) + else if (string.Equals(peKindString, "ILOnly", StringComparison.OrdinalIgnoreCase)) { - if (string.Equals(peKindString, "ILOnly, PE32Plus", StringComparison.OrdinalIgnoreCase)) - { - procArchType = "X64"; - } + procArchType = "AnyCPU"; } - else if (string.Equals(machineTypeString, "ARM", StringComparison.OrdinalIgnoreCase)) + } + else if (string.Equals(machineTypeString, "AMD64", StringComparison.OrdinalIgnoreCase) || + string.Equals(machineTypeString, "IA64", StringComparison.OrdinalIgnoreCase)) + { + if (string.Equals(peKindString, "ILOnly, PE32Plus", StringComparison.OrdinalIgnoreCase)) { - if (string.Equals(peKindString, "ILOnly", StringComparison.OrdinalIgnoreCase)) - { - procArchType = "ARM"; - } + procArchType = "X64"; + } + } + else if (string.Equals(machineTypeString, "ARM", StringComparison.OrdinalIgnoreCase)) + { + if (string.Equals(peKindString, "ILOnly", StringComparison.OrdinalIgnoreCase)) + { + procArchType = "ARM"; } + } - if (string.IsNullOrEmpty(procArchType)) + if (string.IsNullOrEmpty(procArchType)) + { + if (EqtTrace.IsVerboseEnabled) { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("Unable to find the platform type for image:{0} with PEKind:{1}, Machine:{2}. Returning Default:{3}", path, peKindString, machineTypeString, "AnyCPU"); - } - procArchType = "AnyCPU"; + EqtTrace.Verbose("Unable to find the platform type for image:{0} with PEKind:{1}, Machine:{2}. Returning Default:{3}", path, peKindString, machineTypeString, "AnyCPU"); } + procArchType = "AnyCPU"; + } - frameworkVersion = a.ImageRuntimeVersion.Substring(0, 4).ToUpperInvariant(); + frameworkVersion = a.ImageRuntimeVersion.Substring(0, 4).ToUpperInvariant(); - // ImageRuntimeVersion for v4.0 & v4.5 are same and it return v4.0 - // Since there is behavioral difference in both its important to differentiate them - // Using TargetFrameworkAttribute for the purpose. - if (string.Equals(frameworkVersion, "v4.0", StringComparison.OrdinalIgnoreCase)) + // ImageRuntimeVersion for v4.0 & v4.5 are same and it return v4.0 + // Since there is behavioral difference in both its important to differentiate them + // Using TargetFrameworkAttribute for the purpose. + if (string.Equals(frameworkVersion, "v4.0", StringComparison.OrdinalIgnoreCase)) + { + // Try to determine the exact .NET framework by inspecting custom attributes on assembly. + string dotNetVersion = GetTargetFrameworkStringFromAssembly(a); + if (dotNetVersion.StartsWith(Constants.DotNetFramework40, StringComparison.OrdinalIgnoreCase)) { - // Try to determine the exact .NET framework by inspecting custom attributes on assembly. - string dotNetVersion = GetTargetFrameworkStringFromAssembly(a); - if (dotNetVersion.StartsWith(Constants.DotNetFramework40, StringComparison.OrdinalIgnoreCase)) - { - frameworkVersion = "v4.0"; - } - else if (dotNetVersion.StartsWith(Constants.DotNetFramework45, StringComparison.OrdinalIgnoreCase)) - { - frameworkVersion = "v4.5"; - } - else if (dotNetVersion.Length > Constants.DotNetFrameWorkStringPrefix.Length) - { - frameworkVersion = dotNetVersion.Substring(Constants.DotNetFrameWorkStringPrefix.Length); - } + frameworkVersion = "v4.0"; } - - } - catch (BadImageFormatException) - { - if (EqtTrace.IsErrorEnabled) + else if (dotNetVersion.StartsWith(Constants.DotNetFramework45, StringComparison.OrdinalIgnoreCase)) { - EqtTrace.Error("AssemblyLoadWorker:GetPlatformAndFrameworkSettings() caught BadImageFormatException. Falling to native binary."); + frameworkVersion = "v4.5"; } - procArchType = GetArchitectureForSource(path); - } - catch (Exception ex) - { - if (EqtTrace.IsErrorEnabled) + else if (dotNetVersion.Length > Constants.DotNetFrameWorkStringPrefix.Length) { - EqtTrace.Error("AssemblyLoadWorker:GetPlatformAndFrameworkSettings() Returning default. Unhandled exception: {0}.", ex); + frameworkVersion = dotNetVersion.Substring(Constants.DotNetFrameWorkStringPrefix.Length); } - return; } - } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - private static string GetArchitectureForSource(string imagePath) + } + catch (BadImageFormatException) { - // For details refer to below code available on MSDN. - // http://code.msdn.microsoft.com/CSCheckExeType-aab06100/sourcecode?fileId=22010&pathId=1874010322 + if (EqtTrace.IsErrorEnabled) + { + EqtTrace.Error("AssemblyLoadWorker:GetPlatformAndFrameworkSettings() caught BadImageFormatException. Falling to native binary."); + } + procArchType = GetArchitectureForSource(path); + } + catch (Exception ex) + { + if (EqtTrace.IsErrorEnabled) + { + EqtTrace.Error("AssemblyLoadWorker:GetPlatformAndFrameworkSettings() Returning default. Unhandled exception: {0}.", ex); + } + return; + } + } + + private static string GetArchitectureForSource(string imagePath) + { + // For details refer to below code available on MSDN. + // http://code.msdn.microsoft.com/CSCheckExeType-aab06100/sourcecode?fileId=22010&pathId=1874010322 - string archType = "AnyCPU"; - ushort machine = 0; + string archType = "AnyCPU"; + ushort machine = 0; - uint peHeader; - const int IMAGE_FILE_MACHINE_AMD64 = 0x8664; - const int IMAGE_FILE_MACHINE_IA64 = 0x200; - const int IMAGE_FILE_MACHINE_I386 = 0x14c; - const int IMAGE_FILE_MACHINE_ARM = 0x01c0; // ARM Little-Endian - const int IMAGE_FILE_MACHINE_THUMB = 0x01c2; // ARM Thumb/Thumb-2 Little-Endian - const int IMAGE_FILE_MACHINE_ARMNT = 0x01c4; // ARM Thumb-2 Little-Endian + uint peHeader; + const int imageFileMachineAmd64 = 0x8664; + const int imageFileMachineIa64 = 0x200; + const int imageFileMachineI386 = 0x14c; + const int imageFileMachineArm = 0x01c0; // ARM Little-Endian + const int imageFileMachineThumb = 0x01c2; // ARM Thumb/Thumb-2 Little-Endian + const int imageFileMachineArmnt = 0x01c4; // ARM Thumb-2 Little-Endian - try + try + { + //get the input stream + using Stream fs = new FileStream(imagePath, FileMode.Open, FileAccess.Read); + bool validImage = true; + + BinaryReader reader = new(fs); + //PE Header starts @ 0x3C (60). Its a 4 byte header. + fs.Position = 0x3C; + peHeader = reader.ReadUInt32(); + + // Check if the offset is invalid + if (peHeader > fs.Length - 5) { - //get the input stream - using (Stream fs = new FileStream(imagePath, FileMode.Open, FileAccess.Read)) - { - bool validImage = true; + validImage = false; + } + if (validImage) + { + //Moving to PE Header start location... + fs.Position = peHeader; - BinaryReader reader = new BinaryReader(fs); - //PE Header starts @ 0x3C (60). Its a 4 byte header. - fs.Position = 0x3C; - peHeader = reader.ReadUInt32(); + UInt32 signature = reader.ReadUInt32(); //peHeaderSignature + // 0x00004550 is the letters "PE" followed by two terminating zeros. + if (signature != 0x00004550) + { + validImage = false; + } - // Check if the offset is invalid - if (peHeader > fs.Length - 5) + if (validImage) + { + //Read the image file header. + machine = reader.ReadUInt16(); + reader.ReadUInt16(); //NumberOfSections + reader.ReadUInt32(); //TimeDateStamp + reader.ReadUInt32(); //PointerToSymbolTable + reader.ReadUInt32(); //NumberOfSymbols + reader.ReadUInt16(); //SizeOfOptionalHeader + reader.ReadUInt16(); //Characteristics + + // magic number.32bit or 64bit assembly. + UInt16 magic = reader.ReadUInt16(); + if (magic != 0x010B && magic != 0x020B) { validImage = false; } - if (validImage) - { - //Moving to PE Header start location... - fs.Position = peHeader; - - UInt32 signature = reader.ReadUInt32(); //peHeaderSignature - // 0x00004550 is the letters "PE" followed by two terminating zeros. - if (signature != 0x00004550) - { - validImage = false; - } - - if (validImage) - { - //Read the image file header. - machine = reader.ReadUInt16(); - reader.ReadUInt16(); //NumberOfSections - reader.ReadUInt32(); //TimeDateStamp - reader.ReadUInt32(); //PointerToSymbolTable - reader.ReadUInt32(); //NumberOfSymbols - reader.ReadUInt16(); //SizeOfOptionalHeader - reader.ReadUInt16(); //Characteristics - - // magic number.32bit or 64bit assembly. - UInt16 magic = reader.ReadUInt16(); - if (magic != 0x010B && magic != 0x020B) - { - validImage = false; - } - } + } - if (validImage) - { - switch (machine) - { - case IMAGE_FILE_MACHINE_I386: - archType = "X86"; - break; - - case IMAGE_FILE_MACHINE_AMD64: - case IMAGE_FILE_MACHINE_IA64: - archType = "X64"; - break; - - case IMAGE_FILE_MACHINE_ARM: - case IMAGE_FILE_MACHINE_THUMB: - case IMAGE_FILE_MACHINE_ARMNT: - archType = "ARM"; - break; - } - } - else - { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("Source path {0} is not a valid image path. Returning default proc arch type {1}.", imagePath, "AnyCPU"); - } - } + if (validImage) + { + switch (machine) + { + case imageFileMachineI386: + archType = "X86"; + break; + + case imageFileMachineAmd64: + case imageFileMachineIa64: + archType = "X64"; + break; + + case imageFileMachineArm: + case imageFileMachineThumb: + case imageFileMachineArmnt: + archType = "ARM"; + break; } } - } - catch (Exception ex) - { - //Ignore all exception - if (EqtTrace.IsErrorEnabled) + else { - EqtTrace.Error("AssemblyLoadWorker:GetArchitectureForSource() Returning default:{0}. Unhandled exception: {1}.", "AnyCPU", ex.ToString()); + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("Source path {0} is not a valid image path. Returning default proc arch type {1}.", imagePath, "AnyCPU"); + } } } - - return archType; } + catch (Exception ex) + { + //Ignore all exception + if (EqtTrace.IsErrorEnabled) + { + EqtTrace.Error("AssemblyLoadWorker:GetArchitectureForSource() Returning default:{0}. Unhandled exception: {1}.", "AnyCPU", ex.ToString()); + } + } + + return archType; } -#endif } +#endif \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Utilities/EqtHash.cs b/src/Microsoft.TestPlatform.ObjectModel/Utilities/EqtHash.cs index 4c04e6b13d..fd01364164 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Utilities/EqtHash.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Utilities/EqtHash.cs @@ -1,46 +1,39 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities -{ - using System; - using System.Diagnostics; - using System.Diagnostics.CodeAnalysis; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; -#if !NETSTANDARD1_0 - using System.Security.Cryptography; -#endif +using System; +using System.Diagnostics; +/// +/// Wrapper class for cryptographic hashing. +/// This class uses SHA1 instead of MD5 in order to conform to the FIPS standard. +/// +public static class EqtHash +{ /// - /// Wrapper class for cryptographic hashing. - /// This class uses SHA1 instead of MD5 in order to conform to the FIPS standard. + /// Calculates a hash of the string and copies the first 128 bits of the hash + /// to a new Guid. /// - public static class EqtHash + public static Guid GuidFromString(string data) { - /// - /// Calculates a hash of the string and copies the first 128 bits of the hash - /// to a new Guid. - /// - [SuppressMessage("Microsoft.Cryptographic.Standard", "CA5354:SHA1CannotBeUsed", Justification = "Hash Algorithm is used only to generate unique testcase id.")] - public static Guid GuidFromString(string data) - { - Debug.Assert(data != null); + Debug.Assert(data != null); - // Do NOT change the algorithm ever as this will have compat implications - // TC-TA team has a feature in VS where workitems are associated based on TestCase Ids - // If Algorithm changes, then all the bugs/workitems filed in TFS Server against a given TestCase become unassociated if IDs change - // Any algorithm or logic change must require a sign off from feature owners of above - // Also, TPV2 and TPV1 must use same Algorithm until the time TPV1 is completely deleted to be on-par - // If LUT or .Net core scenario uses TPV2 to discover, but if it uses TPV1 in Devenv, then there will be testcase matching issues - byte[] hash = Sha1Helper.ComputeSha1(System.Text.Encoding.Unicode.GetBytes(data)); + // Do NOT change the algorithm ever as this will have compat implications + // TC-TA team has a feature in VS where workitems are associated based on TestCase Ids + // If Algorithm changes, then all the bugs/workitems filed in TFS Server against a given TestCase become unassociated if IDs change + // Any algorithm or logic change must require a sign off from feature owners of above + // Also, TPV2 and TPV1 must use same Algorithm until the time TPV1 is completely deleted to be on-par + // If LUT or .Net core scenario uses TPV2 to discover, but if it uses TPV1 in Devenv, then there will be testcase matching issues + byte[] hash = Sha1Helper.ComputeSha1(System.Text.Encoding.Unicode.GetBytes(data)); - // Guid is always 16 bytes - Debug.Assert(Guid.Empty.ToByteArray().Length == 16, "Expected Guid to be 16 bytes"); + // Guid is always 16 bytes + Debug.Assert(Guid.Empty.ToByteArray().Length == 16, "Expected Guid to be 16 bytes"); - byte[] toGuid = new byte[16]; - Array.Copy(hash, toGuid, 16); + byte[] toGuid = new byte[16]; + Array.Copy(hash, toGuid, 16); - return new Guid(toGuid); - } + return new Guid(toGuid); } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Utilities/FilterHelper.cs b/src/Microsoft.TestPlatform.ObjectModel/Utilities/FilterHelper.cs index 7f7408b936..9d8b259f99 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Utilities/FilterHelper.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Utilities/FilterHelper.cs @@ -1,88 +1,88 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; + +using Resources; + +public static class FilterHelper { - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Text; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources; + public const char EscapeCharacter = '\\'; + private static readonly char[] SpecialCharacters = { '\\', '(', ')', '&', '|', '=', '!', '~' }; + private static readonly HashSet SpecialCharactersSet = new(SpecialCharacters); - public static class FilterHelper + /// + /// Escapes a set of special characters for filter (%, (, ), &, |, =, !, ~) by replacing them with their escape sequences. + /// + /// The input string that contains the text to convert. + /// A string of characters with special characters converted to their escaped form. + public static string Escape(string str) { - public const char EscapeCharacter = '\\'; - private static readonly char[] SpecialCharacters = { '\\', '(', ')', '&', '|', '=', '!', '~' }; - private static readonly HashSet SpecialCharactersSet = new HashSet(SpecialCharacters); + if (str == null) + { + throw new ArgumentNullException(nameof(str)); + } - /// - /// Escapes a set of special characters for filter (%, (, ), &, |, =, !, ~) by replacing them with their escape sequences. - /// - /// The input string that contains the text to convert. - /// A string of characters with special characters converted to their escaped form. - public static string Escape(string str) + if (str.IndexOfAny(SpecialCharacters) < 0) { - if (str == null) - { - throw new ArgumentNullException(nameof(str)); - } + return str; + } - if (str.IndexOfAny(SpecialCharacters) < 0) + var builder = new StringBuilder(); + for (int i = 0; i < str.Length; ++i) + { + var currentChar = str[i]; + if (SpecialCharactersSet.Contains(currentChar)) { - return str; + builder.Append(EscapeCharacter); } + builder.Append(currentChar); + } - var builder = new StringBuilder(); - for (int i = 0; i < str.Length; ++i) - { - var currentChar = str[i]; - if (SpecialCharactersSet.Contains(currentChar)) - { - builder.Append(EscapeCharacter); - } - builder.Append(currentChar); - } + return builder.ToString(); + } - return builder.ToString(); + /// + /// Converts any escaped characters in the input filter string. + /// + /// The input string that contains the text to convert. + /// A filter string of characters with any escaped characters converted to their un-escaped form. + public static string Unescape(string str) + { + if (str == null) + { + throw new ArgumentNullException(nameof(str)); } - /// - /// Converts any escaped characters in the input filter string. - /// - /// The input string that contains the text to convert. - /// A filter string of characters with any escaped characters converted to their un-escaped form. - public static string Unescape(string str) + if (str.IndexOf(EscapeCharacter) < 0) { - if (str == null) - { - throw new ArgumentNullException(nameof(str)); - } - - if (str.IndexOf(EscapeCharacter) < 0) - { - return str; - } + return str; + } - var builder = new StringBuilder(); - for (int i = 0; i < str.Length; ++i) + var builder = new StringBuilder(); + for (int i = 0; i < str.Length; ++i) + { + var currentChar = str[i]; + if (currentChar == EscapeCharacter) { - var currentChar = str[i]; - if (currentChar == EscapeCharacter) + if (++i == str.Length || !SpecialCharactersSet.Contains(currentChar = str[i])) { - if (++i == str.Length || !SpecialCharactersSet.Contains(currentChar = str[i])) - { - // "\" should be followed by a special character. - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.TestCaseFilterEscapeException, str)); - } + // "\" should be followed by a special character. + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.TestCaseFilterEscapeException, str)); } - - // Strictly speaking, string to be un-escaped shouldn't contain any of the special characters, - // other than being part of escape sequence, but we will ignore that to avoid additional overhead. - - builder.Append(currentChar); } - return builder.ToString(); + // Strictly speaking, string to be un-escaped shouldn't contain any of the special characters, + // other than being part of escape sequence, but we will ignore that to avoid additional overhead. + + builder.Append(currentChar); } + + return builder.ToString(); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Utilities/Sha1Helper.cs b/src/Microsoft.TestPlatform.ObjectModel/Utilities/Sha1Helper.cs index 9acf17ebae..836ae138be 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Utilities/Sha1Helper.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Utilities/Sha1Helper.cs @@ -1,269 +1,253 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities -{ - using System; - using System.Diagnostics.CodeAnalysis; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; + +using System; #if !NETSTANDARD1_0 - using System.Security.Cryptography; -#endif +using System.Security.Cryptography; +#endif - /// - /// Used to calculate SHA1 hash. - /// - /// https://tools.ietf.org/html/rfc3174 - /// - internal static class Sha1Helper +/// +/// Used to calculate SHA1 hash. +/// +/// https://tools.ietf.org/html/rfc3174 +/// +internal static class Sha1Helper +{ + public static byte[] ComputeSha1(byte[] message) { - [SuppressMessage("Microsoft.Cryptographic.Standard", "CA5354:SHA1CannotBeUsed", Justification = "Hash Algorithm is used only to generate unique testcase id.")] - public static byte[] ComputeSha1(byte[] message) - { #if NETSTANDARD1_0 - var hasher = new Sha1Implementation(); + var hasher = new Sha1Implementation(); - return hasher.ComputeHash(message); + return hasher.ComputeHash(message); #else - using (HashAlgorithm provider = SHA1.Create()) - { - byte[] hash = provider.ComputeHash(message); + using HashAlgorithm provider = SHA1.Create(); + byte[] hash = provider.ComputeHash(message); - return hash; - } + return hash; #endif - } + } + + /// + /// SHA-1 Implementation as in https://tools.ietf.org/html/rfc3174 + /// + /// + /// This implementation only works with messages with a length + /// that is a multiple of the size of 8-bits. + /// + internal class Sha1Implementation + { + /* + * Many of the variable, function and parameter names in this code + * were used because those were the names used in the publication. + * + * For more information please refer to https://tools.ietf.org/html/rfc3174. + */ + + private const int BlockBits = 512; + private const int DigestBits = 160; + private const int BlockBytes = BlockBits / 8; + private const int DigestBytes = DigestBits / 8; /// - /// SHA-1 Implementation as in https://tools.ietf.org/html/rfc3174 + /// A sequence of logical functions to be used in SHA-1. + /// Each f(t), 0 <= t <= 79, operates on three 32-bit words B, C, D and produces a 32-bit word as output. /// - /// - /// This implementation only works with messages with a length - /// that is a multiple of the size of 8-bits. - /// - internal class Sha1Implementation + /// Function index. 0 <= t <= 79 + /// Word B + /// Word C + /// Word D + /// + /// f(t;B,C,D) = (B AND C) OR ((NOT B) AND D) ( 0 <= t <= 19) + /// f(t;B,C,D) = B XOR C XOR D (20 <= t <= 39) + /// f(t;B,C,D) = (B AND C) OR (B AND D) OR (C AND D) (40 <= t <= 59) + /// f(t;B,C,D) = B XOR C XOR D (60 <= t <= 79) + /// + private static uint F(int t, uint b, uint c, uint d) { - /* - * Many of the variable, function and parameter names in this code - * were used because those were the names used in the publication. - * - * For more information please refer to https://tools.ietf.org/html/rfc3174. - */ - - private const int BlockBits = 512; - private const int DigestBits = 160; - private const int BlockBytes = BlockBits / 8; - private const int DigestBytes = DigestBits / 8; - - /// - /// A sequence of logical functions to be used in SHA-1. - /// Each f(t), 0 <= t <= 79, operates on three 32-bit words B, C, D and produces a 32-bit word as output. - /// - /// Function index. 0 <= t <= 79 - /// Word B - /// Word C - /// Word D - /// - /// f(t;B,C,D) = (B AND C) OR ((NOT B) AND D) ( 0 <= t <= 19) - /// f(t;B,C,D) = B XOR C XOR D (20 <= t <= 39) - /// f(t;B,C,D) = (B AND C) OR (B AND D) OR (C AND D) (40 <= t <= 59) - /// f(t;B,C,D) = B XOR C XOR D (60 <= t <= 79) - /// - private static uint F(int t, uint B, uint C, uint D) + if (t >= 0 && t <= 19) { - if (t >= 0 && t <= 19) - { - return (B & C) | (~B & D); - } - else if ((t >= 20 && t <= 39) || (t >= 60 && t <= 79)) - { - return B ^ C ^ D; - } - else if (t >= 40 && t <= 59) - { - return (B & C) | (B & D) | (C & D); - } - else - { - throw new ArgumentException("Argument out of bounds! 0 <= t < 80", nameof(t)); - } + return (b & c) | (~b & d); } - - /// - /// Returns a constant word K(t) which is used in the SHA-1. - /// - /// Word index. - /// - /// K(t) = 0x5A827999 ( 0 <= t <= 19) - /// K(t) = 0x6ED9EBA1 (20 <= t <= 39) - /// K(t) = 0x8F1BBCDC (40 <= t <= 59) - /// K(t) = 0xCA62C1D6 (60 <= t <= 79) - /// - private static uint K(int t) + else if ((t >= 20 && t <= 39) || (t >= 60 && t <= 79)) { - - if (t >= 0 && t <= 19) - { - return 0x5A827999u; - } - else if (t >= 20 && t <= 39) - { - return 0x6ED9EBA1u; - } - else if (t >= 40 && t <= 59) - { - return 0x8F1BBCDCu; - } - else if (t >= 60 && t <= 79) - { - return 0xCA62C1D6u; - } - else - { - throw new ArgumentException("Argument out of bounds! 0 <= t < 80", nameof(t)); - } + return b ^ c ^ d; } - - /// - /// The circular left shift operation. - /// - /// An uint word. - /// 0 <= n < 32 - /// S^n(X) = (X << n) OR (X >> 32-n) - private static uint S(uint X, byte n) + else { - if (n > 32) - { - throw new ArgumentOutOfRangeException(nameof(n)); - } - - return (X << n) | (X >> (32 - n)); + return t >= 40 && t <= 59 + ? (b & c) | (b & d) | (c & d) + : throw new ArgumentException("Argument out of bounds! 0 <= t < 80", nameof(t)); } + } - /// - /// Ensures that given bytes are in big endian notation. - /// - /// An array of bytes - private static void EnsureBigEndian(ref byte[] array) + /// + /// Returns a constant word K(t) which is used in the SHA-1. + /// + /// Word index. + /// + /// K(t) = 0x5A827999 ( 0 <= t <= 19) + /// K(t) = 0x6ED9EBA1 (20 <= t <= 39) + /// K(t) = 0x8F1BBCDC (40 <= t <= 59) + /// K(t) = 0xCA62C1D6 (60 <= t <= 79) + /// + private static uint K(int t) + { + + if (t >= 0 && t <= 19) + { + return 0x5A827999u; + } + else if (t >= 20 && t <= 39) { - ValidateArg.NotNull(array, nameof(array)); + return 0x6ED9EBA1u; + } + else if (t >= 40 && t <= 59) + { + return 0x8F1BBCDCu; + } + else + { + return t >= 60 && t <= 79 ? 0xCA62C1D6u : throw new ArgumentException("Argument out of bounds! 0 <= t < 80", nameof(t)); + } + } - if (BitConverter.IsLittleEndian) - { - Array.Reverse(array); - } + /// + /// The circular left shift operation. + /// + /// An uint word. + /// 0 <= n < 32 + /// S^n(X) = (X << n) OR (X >> 32-n) + private static uint S(uint x, byte n) + { + return n > 32 ? throw new ArgumentOutOfRangeException(nameof(n)) : (x << n) | (x >> (32 - n)); + } + + /// + /// Ensures that given bytes are in big endian notation. + /// + /// An array of bytes + private static void EnsureBigEndian(ref byte[] array) + { + ValidateArg.NotNull(array, nameof(array)); + + if (BitConverter.IsLittleEndian) + { + Array.Reverse(array); } + } - private readonly uint[] H = new uint[5]; + private readonly uint[] _h = new uint[5]; - private void Reset() + private void Reset() + { + // as defined in https://tools.ietf.org/html/rfc3174#section-6.1 + _h[0] = 0x67452301u; + _h[1] = 0xEFCDAB89u; + _h[2] = 0x98BADCFEu; + _h[3] = 0x10325476u; + _h[4] = 0xC3D2E1F0u; + } + + public byte[] ComputeHash(byte[] message) + { + ValidateArg.NotNull(message, nameof(message)); + + Reset(); + PadMessage(ref message); + + var messageCount = message.Length / BlockBytes; + for (var i = 0; i < messageCount; ++i) { - // as defined in https://tools.ietf.org/html/rfc3174#section-6.1 - H[0] = 0x67452301u; - H[1] = 0xEFCDAB89u; - H[2] = 0x98BADCFEu; - H[3] = 0x10325476u; - H[4] = 0xC3D2E1F0u; + ProcessBlock(message, i * BlockBytes, BlockBytes); } - public byte[] ComputeHash(byte[] message) + var digest = new byte[DigestBytes]; + for (int t = 0; t < _h.Length; t++) { - ValidateArg.NotNull(message, nameof(message)); + var hi = BitConverter.GetBytes(_h[t]); + EnsureBigEndian(ref hi); - Reset(); - PadMessage(ref message); + Buffer.BlockCopy(hi, 0, digest, t * hi.Length, hi.Length); + } - var messageCount = message.Length / BlockBytes; - for (var i = 0; i < messageCount; ++i) - { - ProcessBlock(message, i * BlockBytes, BlockBytes); - } + return digest; + } - var digest = new byte[DigestBytes]; - for (int t = 0; t < H.Length; t++) - { - var hi = BitConverter.GetBytes(H[t]); - EnsureBigEndian(ref hi); + private void PadMessage(ref byte[] message) + { + var length = message.Length; + var paddingBytes = BlockBytes - (length % BlockBytes); - Buffer.BlockCopy(hi, 0, digest, t * hi.Length, hi.Length); - } + // 64bit uint message size will be appended to end of the padding, making sure we have space for it. + if (paddingBytes <= 8) + paddingBytes += BlockBytes; - return digest; - } + var padding = new byte[paddingBytes]; + padding[0] = 0b10000000; - private void PadMessage(ref byte[] message) - { - var length = message.Length; - var paddingBytes = BlockBytes - (length % BlockBytes); + var messageBits = (ulong)message.Length << 3; + var messageSize = BitConverter.GetBytes(messageBits); + EnsureBigEndian(ref messageSize); + + Buffer.BlockCopy(messageSize, 0, padding, padding.Length - messageSize.Length, messageSize.Length); - // 64bit uint message size will be appended to end of the padding, making sure we have space for it. - if (paddingBytes <= 8) - paddingBytes += BlockBytes; + Array.Resize(ref message, message.Length + padding.Length); + Buffer.BlockCopy(padding, 0, message, length, padding.Length); + } + + private void ProcessBlock(byte[] message, int start, int length) + { + if (start + length > message.Length) + { + throw new ArgumentOutOfRangeException(nameof(length)); + } + if (length != BlockBytes) + { + throw new ArgumentException($"Invalid block size. Actual: {length}, Expected: {BlockBytes}", nameof(length)); + } - var padding = new byte[paddingBytes]; - padding[0] = 0b10000000; + var w = new uint[80]; - var messageBits = (ulong)message.Length << 3; - var messageSize = BitConverter.GetBytes(messageBits); - EnsureBigEndian(ref messageSize); + // Get W(0) .. W(15) + for (int t = 0; t <= 15; t++) + { + var wordBytes = new byte[sizeof(uint)]; + Buffer.BlockCopy(message, start + (t * sizeof(uint)), wordBytes, 0, sizeof(uint)); + EnsureBigEndian(ref wordBytes); - Buffer.BlockCopy(messageSize, 0, padding, padding.Length - messageSize.Length, messageSize.Length); + w[t] = BitConverter.ToUInt32(wordBytes, 0); + } - Array.Resize(ref message, message.Length + padding.Length); - Buffer.BlockCopy(padding, 0, message, length, padding.Length); + // Calculate W(16) .. W(79) + for (int t = 16; t <= 79; t++) + { + w[t] = S(w[t - 3] ^ w[t - 8] ^ w[t - 14] ^ w[t - 16], 1); } - private void ProcessBlock(byte[] message, int start, int length) + uint a = _h[0], + b = _h[1], + c = _h[2], + d = _h[3], + e = _h[4]; + + for (int t = 0; t < 80; t++) { - if (start + length > message.Length) - { - throw new ArgumentOutOfRangeException(nameof(length)); - } - if (length != BlockBytes) - { - throw new ArgumentException($"Invalid block size. Actual: {length}, Expected: {BlockBytes}", nameof(length)); - } - - var W = new uint[80]; - - // Get W(0) .. W(15) - for (int t = 0; t <= 15; t++) - { - var wordBytes = new byte[sizeof(uint)]; - Buffer.BlockCopy(message, start + (t * sizeof(uint)), wordBytes, 0, sizeof(uint)); - EnsureBigEndian(ref wordBytes); - - W[t] = BitConverter.ToUInt32(wordBytes, 0); - } - - // Calculate W(16) .. W(79) - for (int t = 16; t <= 79; t++) - { - W[t] = S(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1); - } - - uint A = H[0], - B = H[1], - C = H[2], - D = H[3], - E = H[4]; - - for (int t = 0; t < 80; t++) - { - var temp = S(A, 5) + F(t, B, C, D) + E + W[t] + K(t); - E = D; - D = C; - C = S(B, 30); - B = A; - A = temp; - } - - H[0] += A; - H[1] += B; - H[2] += C; - H[3] += D; - H[4] += E; + var temp = S(a, 5) + F(t, b, c, d) + e + w[t] + K(t); + e = d; + d = c; + c = S(b, 30); + b = a; + a = temp; } + + _h[0] += a; + _h[1] += b; + _h[2] += c; + _h[3] += d; + _h[4] += e; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Utilities/StringUtilities.cs b/src/Microsoft.TestPlatform.ObjectModel/Utilities/StringUtilities.cs index a3e145ae3c..154d1214b9 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Utilities/StringUtilities.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Utilities/StringUtilities.cs @@ -1,47 +1,46 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; + +using System; +/// +/// Utility methods for manipulating strings. +/// +public static class StringUtilities +{ /// - /// Utility methods for manipulating strings. + /// Prepares the string for output by converting null values to the "(null)" string + /// and removing any trailing new lines. /// - public static class StringUtilities + /// The input string. + /// The string that is prepared for output. + public static string PrepareForOutput(string input) { - /// - /// Prepares the string for output by converting null values to the "(null)" string - /// and removing any trailing new lines. - /// - /// The input string. - /// The string that is prepared for output. - public static string PrepareForOutput(string input) + string result = input; + if (input == null) { - string result = input; - if (input == null) - { - result = Resources.Resources.NullString; - } + result = Resources.Resources.NullString; + } - result = result.TrimEnd(Environment.NewLine.ToCharArray()); + result = result.TrimEnd(Environment.NewLine.ToCharArray()); - return result; - } + return result; + } - /// - /// Checks if given string is null or a whitespace. - /// - /// string to check - /// True if string is null or a whitespace, false otherwise - public static bool IsNullOrWhiteSpace(string input) + /// + /// Checks if given string is null or a whitespace. + /// + /// string to check + /// True if string is null or a whitespace, false otherwise + public static bool IsNullOrWhiteSpace(string input) + { + if (input != null) { - if (input != null) - { - input = input.Trim(); - } - - return string.IsNullOrEmpty(input); + input = input.Trim(); } + + return string.IsNullOrEmpty(input); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Utilities/SuspendCodeCoverage.cs b/src/Microsoft.TestPlatform.ObjectModel/Utilities/SuspendCodeCoverage.cs index bc1ea0354f..be15a133db 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Utilities/SuspendCodeCoverage.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Utilities/SuspendCodeCoverage.cs @@ -1,72 +1,62 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities -{ +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; #if NETFRAMEWORK - using System; +using System; + +/// +/// Suspends the instrumentation (for code coverage) of the modules which are loaded +/// during this object is created and disposed +/// exceeded. +/// +public class SuspendCodeCoverage : IDisposable +{ + private const string SuspendCodeCoverageEnvVarName = "__VANGUARD_SUSPEND_INSTRUMENT__"; + private const string SuspendCodeCoverageEnvVarTrueValue = "TRUE"; + + private readonly string _prevEnvValue; /// - /// Suspends the instrumentation (for code coverage) of the modules which are loaded - /// during this object is created and disposed - /// exceeded. + /// Whether the object is disposed or not. /// - public class SuspendCodeCoverage : IDisposable - { - #region Private Variables - - private const string SuspendCodeCoverageEnvVarName = "__VANGUARD_SUSPEND_INSTRUMENT__"; - private const string SuspendCodeCoverageEnvVarTrueValue = "TRUE"; - - private string prevEnvValue; - - /// - /// Whether the object is disposed or not. - /// - private bool isDisposed = false; - - #endregion + private bool _isDisposed = false; - /// - /// Constructor. Code Coverage instrumentation of the modules, which are loaded - /// during this object is created and disposed, is disabled. - /// - public SuspendCodeCoverage() - { - this.prevEnvValue = Environment.GetEnvironmentVariable(SuspendCodeCoverageEnvVarName, EnvironmentVariableTarget.Process); - Environment.SetEnvironmentVariable(SuspendCodeCoverageEnvVarName, SuspendCodeCoverageEnvVarTrueValue, EnvironmentVariableTarget.Process); - } - - #region IDisposable + /// + /// Constructor. Code Coverage instrumentation of the modules, which are loaded + /// during this object is created and disposed, is disabled. + /// + public SuspendCodeCoverage() + { + _prevEnvValue = Environment.GetEnvironmentVariable(SuspendCodeCoverageEnvVarName, EnvironmentVariableTarget.Process); + Environment.SetEnvironmentVariable(SuspendCodeCoverageEnvVarName, SuspendCodeCoverageEnvVarTrueValue, EnvironmentVariableTarget.Process); + } - /// - /// Disposes this instance - /// - public void Dispose() - { - this.Dispose(true); - GC.SuppressFinalize(this); - } + /// + /// Disposes this instance + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - /// - /// Disposes instance. - /// - /// Should dispose. - internal void Dispose(bool disposing) + /// + /// Disposes instance. + /// + /// Should dispose. + internal void Dispose(bool disposing) + { + if (!_isDisposed) { - if (!this.isDisposed) + if (disposing) { - if (disposing) - { - Environment.SetEnvironmentVariable(SuspendCodeCoverageEnvVarName, this.prevEnvValue, EnvironmentVariableTarget.Process); - } - - this.isDisposed = true; + Environment.SetEnvironmentVariable(SuspendCodeCoverageEnvVarName, _prevEnvValue, EnvironmentVariableTarget.Process); } - } - #endregion IDisposable + _isDisposed = true; + } } - -#endif } + +#endif \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Utilities/XmlReaderUtilities.cs b/src/Microsoft.TestPlatform.ObjectModel/Utilities/XmlReaderUtilities.cs index 024e17996d..0e6e936856 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Utilities/XmlReaderUtilities.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Utilities/XmlReaderUtilities.cs @@ -1,74 +1,71 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities -{ - using System; - using System.Globalization; - using System.Xml; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using System.Globalization; +using System.Xml; - /// - /// Utility methods for working with an XmlReader. - /// - public static class XmlReaderUtilities - { - #region Constants +/// +/// Utility methods for working with an XmlReader. +/// +public static class XmlReaderUtilities +{ + #region Constants - private const string RunSettingsRootNodeName = "RunSettings"; + private const string RunSettingsRootNodeName = "RunSettings"; - #endregion + #endregion - #region Utility Methods + #region Utility Methods - /// - /// Reads up to the next Element in the document. - /// - /// Reader to move to the next element. - public static void ReadToNextElement(this XmlReader reader) + /// + /// Reads up to the next Element in the document. + /// + /// Reader to move to the next element. + public static void ReadToNextElement(this XmlReader reader) + { + ValidateArg.NotNull(reader, nameof(reader)); + while (!reader.EOF && reader.Read() && reader.NodeType != XmlNodeType.Element) { - ValidateArg.NotNull(reader, nameof(reader)); - while (!reader.EOF && reader.Read() && reader.NodeType != XmlNodeType.Element) - { - } } + } - /// - /// Skips the current element and moves to the next Element in the document. - /// - /// Reader to move to the next element. - public static void SkipToNextElement(this XmlReader reader) - { - ValidateArg.NotNull(reader, nameof(reader)); - reader.Skip(); + /// + /// Skips the current element and moves to the next Element in the document. + /// + /// Reader to move to the next element. + public static void SkipToNextElement(this XmlReader reader) + { + ValidateArg.NotNull(reader, nameof(reader)); + reader.Skip(); - if (reader.NodeType != XmlNodeType.Element) - { - reader.ReadToNextElement(); - } + if (reader.NodeType != XmlNodeType.Element) + { + reader.ReadToNextElement(); } + } - /// - /// Reads to the root node of the run settings and verifies that it is a "RunSettings" node. - /// - /// Path to the file. - /// XmlReader for the file. - public static void ReadToRootNode(XmlReader reader) - { - ValidateArg.NotNull(reader, nameof(reader)); + /// + /// Reads to the root node of the run settings and verifies that it is a "RunSettings" node. + /// + /// Path to the file. + /// XmlReader for the file. + public static void ReadToRootNode(XmlReader reader) + { + ValidateArg.NotNull(reader, nameof(reader)); - // Read to the root node. - reader.ReadToNextElement(); + // Read to the root node. + reader.ReadToNextElement(); - // Verify that it is a "RunSettings" node. - if (reader.Name != RunSettingsRootNodeName) - { - throw new SettingsException( - string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.InvalidRunSettingsRootNode)); - } + // Verify that it is a "RunSettings" node. + if (reader.Name != RunSettingsRootNodeName) + { + throw new SettingsException( + string.Format( + CultureInfo.CurrentCulture, + Resources.Resources.InvalidRunSettingsRootNode)); } - - #endregion } -} + + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/Utilities/XmlRunSettingsUtilities.cs b/src/Microsoft.TestPlatform.ObjectModel/Utilities/XmlRunSettingsUtilities.cs index c0e21ac443..e1fa2ae851 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Utilities/XmlRunSettingsUtilities.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Utilities/XmlRunSettingsUtilities.cs @@ -1,469 +1,436 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Globalization; - using System.IO; - using System.Xml; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Xml; #if !NETSTANDARD1_0 - using System.Xml.XPath; -#endif +using System.Xml.XPath; +#endif - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using ObjectModelResources = Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources.Resources; +using PlatformAbstractions; +using ObjectModelResources = Resources.Resources; + +/// +/// Utilities for the run settings XML. +/// +public static class XmlRunSettingsUtilities +{ /// - /// Utilities for the run settings XML. + /// Gets the os architecture of the machine where this application is running /// - public static class XmlRunSettingsUtilities + public static Architecture OSArchitecture { - /// - /// Gets the os architecture of the machine where this application is running - /// - public static ObjectModel.Architecture OSArchitecture + get { - get - { - var arch = new PlatformEnvironment().Architecture; + var arch = new PlatformEnvironment().Architecture; - switch (arch) - { - case PlatformArchitecture.X64: - return ObjectModel.Architecture.X64; - case PlatformArchitecture.X86: - return ObjectModel.Architecture.X86; - case PlatformArchitecture.ARM64: - return ObjectModel.Architecture.ARM64; - case PlatformArchitecture.ARM: - return ObjectModel.Architecture.ARM; - default: - return ObjectModel.Architecture.X64; - } - } + return arch switch + { + PlatformArchitecture.X64 => Architecture.X64, + PlatformArchitecture.X86 => Architecture.X86, + PlatformArchitecture.ARM64 => Architecture.ARM64, + PlatformArchitecture.ARM => Architecture.ARM, + _ => Architecture.X64, + }; } + } - /// - /// Gets the settings to be used while creating XmlReader for runsettings. - /// - public static XmlReaderSettings ReaderSettings + /// + /// Gets the settings to be used while creating XmlReader for runsettings. + /// + public static XmlReaderSettings ReaderSettings + { + get { - get - { - return new XmlReaderSettings { IgnoreComments = true, IgnoreWhitespace = true, DtdProcessing = DtdProcessing.Prohibit }; - } + return new XmlReaderSettings { IgnoreComments = true, IgnoreWhitespace = true, DtdProcessing = DtdProcessing.Prohibit }; } + } #if !NETSTANDARD1_0 - /// - /// Examines the given XPathNavigable representation of a runsettings file and determines if it has a configuration node - /// for the data collector (used for Fakes and CodeCoverage) - /// - /// XPathNavigable representation of a runsettings file - /// The data Collector Uri. - /// True if there is a datacollector configured. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")] - public static bool ContainsDataCollector(IXPathNavigable runSettingDocument, string dataCollectorUri) + /// + /// Examines the given XPathNavigable representation of a runsettings file and determines if it has a configuration node + /// for the data collector (used for Fakes and CodeCoverage) + /// + /// XPathNavigable representation of a runsettings file + /// The data Collector Uri. + /// True if there is a datacollector configured. + public static bool ContainsDataCollector(IXPathNavigable runSettingDocument, string dataCollectorUri) + { + if (runSettingDocument == null) { - if (runSettingDocument == null) - { - throw new ArgumentNullException(nameof(runSettingDocument)); - } + throw new ArgumentNullException(nameof(runSettingDocument)); + } - if (dataCollectorUri == null) - { - throw new ArgumentNullException(nameof(dataCollectorUri)); - } + if (dataCollectorUri == null) + { + throw new ArgumentNullException(nameof(dataCollectorUri)); + } - var navigator = runSettingDocument.CreateNavigator(); - var nodes = navigator.Select("/RunSettings/DataCollectionRunSettings/DataCollectors/DataCollector"); + var navigator = runSettingDocument.CreateNavigator(); + var nodes = navigator.Select("/RunSettings/DataCollectionRunSettings/DataCollectors/DataCollector"); - foreach (XPathNavigator dataCollectorNavigator in nodes) + foreach (XPathNavigator dataCollectorNavigator in nodes) + { + var uri = dataCollectorNavigator.GetAttribute("uri", string.Empty); + if (string.Equals(dataCollectorUri, uri, StringComparison.OrdinalIgnoreCase)) { - var uri = dataCollectorNavigator.GetAttribute("uri", string.Empty); - if (string.Equals(dataCollectorUri, uri, StringComparison.OrdinalIgnoreCase)) - { - return true; - } + return true; } - - return false; } - /// - /// Get the list of friendly name of all data collector present in runsettings. - /// - /// runsettings xml string - /// List of friendly name - public static IList GetDataCollectorsFriendlyName(string runsettingsXml) + return false; + } + + /// + /// Get the list of friendly name of all data collector present in runsettings. + /// + /// runsettings xml string + /// List of friendly name + public static IList GetDataCollectorsFriendlyName(string runsettingsXml) + { + var friendlyNameList = new List(); + if (!string.IsNullOrWhiteSpace(runsettingsXml)) { - var friendlyNameList = new List(); - if (!string.IsNullOrWhiteSpace(runsettingsXml)) - { - using (var stream = new StringReader(runsettingsXml)) - using (var reader = XmlReader.Create(stream, XmlRunSettingsUtilities.ReaderSettings)) - { - var document = new XmlDocument(); - document.Load(reader); + using var stream = new StringReader(runsettingsXml); + using var reader = XmlReader.Create(stream, ReaderSettings); + var document = new XmlDocument(); + document.Load(reader); - var runSettingsNavigator = document.CreateNavigator(); - var nodes = runSettingsNavigator.Select("/RunSettings/DataCollectionRunSettings/DataCollectors/DataCollector"); + var runSettingsNavigator = document.CreateNavigator(); + var nodes = runSettingsNavigator.Select("/RunSettings/DataCollectionRunSettings/DataCollectors/DataCollector"); - foreach (XPathNavigator dataCollectorNavigator in nodes) - { - var friendlyName = dataCollectorNavigator.GetAttribute("friendlyName", string.Empty); - friendlyNameList.Add(friendlyName); - } - } + foreach (XPathNavigator dataCollectorNavigator in nodes) + { + var friendlyName = dataCollectorNavigator.GetAttribute("friendlyName", string.Empty); + friendlyNameList.Add(friendlyName); } - - return friendlyNameList; } - /// - /// Inserts a data collector settings in the file - /// - /// runSettingDocument - /// settings - public static void InsertDataCollectorsNode(IXPathNavigable runSettingDocument, DataCollectorSettings settings) + return friendlyNameList; + } + + /// + /// Inserts a data collector settings in the file + /// + /// runSettingDocument + /// settings + public static void InsertDataCollectorsNode(IXPathNavigable runSettingDocument, DataCollectorSettings settings) + { + if (runSettingDocument == null) { - if (runSettingDocument == null) - { - throw new ArgumentNullException(nameof(runSettingDocument)); - } + throw new ArgumentNullException(nameof(runSettingDocument)); + } - if (settings == null) - { - throw new ArgumentNullException(nameof(settings)); - } + if (settings == null) + { + throw new ArgumentNullException(nameof(settings)); + } - var navigator = runSettingDocument.CreateNavigator(); - MoveToDataCollectorsNode(ref navigator); + var navigator = runSettingDocument.CreateNavigator(); + MoveToDataCollectorsNode(ref navigator); - var settingsXml = settings.ToXml(); - var dataCollectorNode = settingsXml.CreateNavigator(); - dataCollectorNode.MoveToRoot(); + var settingsXml = settings.ToXml(); + var dataCollectorNode = settingsXml.CreateNavigator(); + dataCollectorNode.MoveToRoot(); - navigator.AppendChild(dataCollectorNode); - } + navigator.AppendChild(dataCollectorNode); + } #endif - /// - /// Returns RunConfiguration from settingsXml. - /// - /// The run settings. - /// The RunConfiguration node as defined in the settings xml. - public static RunConfiguration GetRunConfigurationNode(string settingsXml) + /// + /// Returns RunConfiguration from settingsXml. + /// + /// The run settings. + /// The RunConfiguration node as defined in the settings xml. + public static RunConfiguration GetRunConfigurationNode(string settingsXml) + { + var nodeValue = GetNodeValue(settingsXml, Constants.RunConfigurationSettingsName, RunConfiguration.FromXml); + if (nodeValue == default(RunConfiguration)) { - var nodeValue = GetNodeValue(settingsXml, Constants.RunConfigurationSettingsName, RunConfiguration.FromXml); - if (nodeValue == default(RunConfiguration)) - { - // Return default one. - nodeValue = new RunConfiguration(); - } - - return nodeValue; + // Return default one. + nodeValue = new RunConfiguration(); } - /// - /// Gets the set of user defined test run parameters from settings xml as key value pairs. - /// - /// The run settings xml. - /// The test run parameters defined in the run settings. - /// If there is no test run parameters section defined in the settings xml a blank dictionary is returned. - public static Dictionary GetTestRunParameters(string settingsXml) - { - var nodeValue = GetNodeValue>(settingsXml, Constants.TestRunParametersName, TestRunParameters.FromXml); - if (nodeValue == default(Dictionary)) - { - // Return default. - nodeValue = new Dictionary(); - } + return nodeValue; + } - return nodeValue; + /// + /// Gets the set of user defined test run parameters from settings xml as key value pairs. + /// + /// The run settings xml. + /// The test run parameters defined in the run settings. + /// If there is no test run parameters section defined in the settings xml a blank dictionary is returned. + public static Dictionary GetTestRunParameters(string settingsXml) + { + var nodeValue = GetNodeValue(settingsXml, Constants.TestRunParametersName, TestRunParameters.FromXml); + if (nodeValue == default(Dictionary)) + { + // Return default. + nodeValue = new Dictionary(); } + return nodeValue; + } + #if !NETSTANDARD1_0 - /// - /// Create a default run settings - /// - /// - /// The . - /// - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", - Justification = "XmlReaderSettings.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] - public static XmlDocument CreateDefaultRunSettings() - { - // Create a new default xml doc that looks like this: - // - // - // - // - // - // - // - var doc = new XmlDocument(); - var xmlDeclaration = doc.CreateNode(XmlNodeType.XmlDeclaration, string.Empty, string.Empty); - - doc.AppendChild(xmlDeclaration); - var runSettingsNode = doc.CreateElement(Constants.RunSettingsName); - doc.AppendChild(runSettingsNode); - - var dataCollectionRunSettingsNode = doc.CreateElement(Constants.DataCollectionRunSettingsName); - runSettingsNode.AppendChild(dataCollectionRunSettingsNode); - - var dataCollectorsNode = doc.CreateElement(Constants.DataCollectorsSettingName); - dataCollectionRunSettingsNode.AppendChild(dataCollectorsNode); - - return doc; - } + /// + /// Create a default run settings + /// + /// + /// The . + /// + public static XmlDocument CreateDefaultRunSettings() + { + // Create a new default xml doc that looks like this: + // + // + // + // + // + // + // + var doc = new XmlDocument(); + var xmlDeclaration = doc.CreateNode(XmlNodeType.XmlDeclaration, string.Empty, string.Empty); + + doc.AppendChild(xmlDeclaration); + var runSettingsNode = doc.CreateElement(Constants.RunSettingsName); + doc.AppendChild(runSettingsNode); + + var dataCollectionRunSettingsNode = doc.CreateElement(Constants.DataCollectionRunSettingsName); + runSettingsNode.AppendChild(dataCollectionRunSettingsNode); + + var dataCollectorsNode = doc.CreateElement(Constants.DataCollectorsSettingName); + dataCollectionRunSettingsNode.AppendChild(dataCollectorsNode); + + return doc; + } - /// - /// Returns whether data collection is enabled in the parameter settings xml or not - /// - /// The run Settings Xml. - /// True if data collection is enabled. - public static bool IsDataCollectionEnabled(string runSettingsXml) - { - var dataCollectionRunSettings = GetDataCollectionRunSettings(runSettingsXml); + /// + /// Returns whether data collection is enabled in the parameter settings xml or not + /// + /// The run Settings Xml. + /// True if data collection is enabled. + public static bool IsDataCollectionEnabled(string runSettingsXml) + { + var dataCollectionRunSettings = GetDataCollectionRunSettings(runSettingsXml); - if (dataCollectionRunSettings == null || !dataCollectionRunSettings.IsCollectionEnabled) - { - return false; - } + return dataCollectionRunSettings != null && dataCollectionRunSettings.IsCollectionEnabled; + } + + /// + /// Returns whether in-proc data collection is enabled in the parameter settings xml or not + /// + /// The run Settings Xml. + /// True if data collection is enabled. + public static bool IsInProcDataCollectionEnabled(string runSettingsXml) + { + var dataCollectionRunSettings = GetInProcDataCollectionRunSettings(runSettingsXml); + + return dataCollectionRunSettings != null && dataCollectionRunSettings.IsCollectionEnabled; + } - return true; + /// + /// Get DataCollection Run settings from the settings XML. + /// + /// The run Settings Xml. + /// The . + public static DataCollectionRunSettings GetDataCollectionRunSettings(string runSettingsXml) + { + // use XmlReader to avoid loading of the plugins in client code (mainly from VS). + if (string.IsNullOrWhiteSpace(runSettingsXml)) + { + return null; } - /// - /// Returns whether in-proc data collection is enabled in the parameter settings xml or not - /// - /// The run Settings Xml. - /// True if data collection is enabled. - public static bool IsInProcDataCollectionEnabled(string runSettingsXml) + try { - var dataCollectionRunSettings = GetInProcDataCollectionRunSettings(runSettingsXml); + using var stringReader = new StringReader(runSettingsXml); + var reader = XmlReader.Create(stringReader, ReaderSettings); + + // read to the fist child + XmlReaderUtilities.ReadToRootNode(reader); + reader.ReadToNextElement(); - if (dataCollectionRunSettings == null || !dataCollectionRunSettings.IsCollectionEnabled) + // Read till we reach DC element or reach EOF + while (!string.Equals(reader.Name, Constants.DataCollectionRunSettingsName) && !reader.EOF) { - return false; + reader.SkipToNextElement(); } - return true; - } - - /// - /// Get DataCollection Run settings from the settings XML. - /// - /// The run Settings Xml. - /// The . - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", - Justification = "XmlReaderSettings.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] - public static DataCollectionRunSettings GetDataCollectionRunSettings(string runSettingsXml) - { - // use XmlReader to avoid loading of the plugins in client code (mainly from VS). - if (string.IsNullOrWhiteSpace(runSettingsXml)) + // If reached EOF => DC element not there + if (reader.EOF) { return null; } - try - { - using (var stringReader = new StringReader(runSettingsXml)) - { - var reader = XmlReader.Create(stringReader, ReaderSettings); - - // read to the fist child - XmlReaderUtilities.ReadToRootNode(reader); - reader.ReadToNextElement(); - - // Read till we reach DC element or reach EOF - while (!string.Equals(reader.Name, Constants.DataCollectionRunSettingsName) && !reader.EOF) - { - reader.SkipToNextElement(); - } - - // If reached EOF => DC element not there - if (reader.EOF) - { - return null; - } - - // Reached here => DC element present. - return DataCollectionRunSettings.FromXml(reader); - } - } - catch (XmlException ex) - { - throw new SettingsException(string.Format(CultureInfo.CurrentCulture, "{0} {1}", Resources.CommonResources.MalformedRunSettingsFile, ex.Message), ex); - } + // Reached here => DC element present. + return DataCollectionRunSettings.FromXml(reader); } - - /// - /// Get InProc DataCollection Run settings - /// - /// - /// The run Settings Xml. - /// - /// Data collection run settings. - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", - Justification = "XmlReaderSettings.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] - public static DataCollectionRunSettings GetInProcDataCollectionRunSettings(string runSettingsXml) + catch (XmlException ex) { - // use XmlReader to avoid loading of the plugins in client code (mainly from VS). - if (string.IsNullOrWhiteSpace(runSettingsXml)) - { - return null; - } + throw new SettingsException(string.Format(CultureInfo.CurrentCulture, "{0} {1}", Resources.CommonResources.MalformedRunSettingsFile, ex.Message), ex); + } + } - runSettingsXml = runSettingsXml.Trim(); - using (StringReader stringReader1 = new StringReader(runSettingsXml)) - { - XmlReader reader = XmlReader.Create(stringReader1, ReaderSettings); + /// + /// Get InProc DataCollection Run settings + /// + /// + /// The run Settings Xml. + /// + /// Data collection run settings. + public static DataCollectionRunSettings GetInProcDataCollectionRunSettings(string runSettingsXml) + { + // use XmlReader to avoid loading of the plugins in client code (mainly from VS). + if (string.IsNullOrWhiteSpace(runSettingsXml)) + { + return null; + } - // read to the fist child - XmlReaderUtilities.ReadToRootNode(reader); - reader.ReadToNextElement(); + runSettingsXml = runSettingsXml.Trim(); + using StringReader stringReader1 = new(runSettingsXml); + XmlReader reader = XmlReader.Create(stringReader1, ReaderSettings); - // Read till we reach In Proc IDC element or reach EOF - while (!string.Equals(reader.Name, Constants.InProcDataCollectionRunSettingsName) && !reader.EOF) - { - reader.SkipToNextElement(); - } + // read to the fist child + XmlReaderUtilities.ReadToRootNode(reader); + reader.ReadToNextElement(); - // If reached EOF => IDC element not there - if (reader.EOF) - { - return null; - } + // Read till we reach In Proc IDC element or reach EOF + while (!string.Equals(reader.Name, Constants.InProcDataCollectionRunSettingsName) && !reader.EOF) + { + reader.SkipToNextElement(); + } - // Reached here => In Proc IDC element present. - return DataCollectionRunSettings.FromXml(reader, Constants.InProcDataCollectionRunSettingsName, Constants.InProcDataCollectorsSettingName, Constants.InProcDataCollectorSettingName); - } + // If reached EOF => IDC element not there + if (reader.EOF) + { + return null; } + // Reached here => In Proc IDC element present. + return DataCollectionRunSettings.FromXml(reader, Constants.InProcDataCollectionRunSettingsName, Constants.InProcDataCollectorsSettingName, Constants.InProcDataCollectorSettingName); + } + #endif - /// - /// Get logger run settings from the settings XML. - /// - /// The run Settings Xml. - /// The . - public static LoggerRunSettings GetLoggerRunSettings(String runSettings) - { - return GetNodeValue( - runSettings, - Constants.LoggerRunSettingsName, - LoggerRunSettings.FromXml); - } + /// + /// Get logger run settings from the settings XML. + /// + /// The run Settings Xml. + /// The . + public static LoggerRunSettings GetLoggerRunSettings(String runSettings) + { + return GetNodeValue( + runSettings, + Constants.LoggerRunSettingsName, + LoggerRunSettings.FromXml); + } - /// - /// Throws a settings exception if the node the reader is on has attributes defined. - /// - /// The xml reader. - internal static void ThrowOnHasAttributes(XmlReader reader) - { - if (!reader.HasAttributes) return; + /// + /// Throws a settings exception if the node the reader is on has attributes defined. + /// + /// The xml reader. + internal static void ThrowOnHasAttributes(XmlReader reader) + { + if (!reader.HasAttributes) return; - string elementName = reader.Name; - reader.MoveToNextAttribute(); + string elementName = reader.Name; + reader.MoveToNextAttribute(); - throw new SettingsException( - string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsXmlAttribute, - elementName, - reader.Name)); - } + throw new SettingsException( + string.Format( + CultureInfo.CurrentCulture, + ObjectModelResources.InvalidSettingsXmlAttribute, + elementName, + reader.Name)); + } - /// - /// Throws a settings exception if the node the reader is on doesn't have attributes defined. - /// - /// The xml reader. - internal static void ThrowOnNoAttributes(XmlReader reader) - { - if (reader.HasAttributes) return; + /// + /// Throws a settings exception if the node the reader is on doesn't have attributes defined. + /// + /// The xml reader. + internal static void ThrowOnNoAttributes(XmlReader reader) + { + if (reader.HasAttributes) return; - throw new SettingsException( - string.Format( - CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsXmlAttribute, - reader.Name)); - } + throw new SettingsException( + string.Format( + CultureInfo.CurrentCulture, + ObjectModelResources.InvalidSettingsXmlAttribute, + reader.Name)); + } - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", - Justification = "XmlReaderSettings.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] - private static T GetNodeValue(string settingsXml, string nodeName, Func nodeParser) + private static T GetNodeValue(string settingsXml, string nodeName, Func nodeParser) + { + // use XmlReader to avoid loading of the plugins in client code (mainly from VS). + if (!string.IsNullOrWhiteSpace(settingsXml)) { - // use XmlReader to avoid loading of the plugins in client code (mainly from VS). - if (!string.IsNullOrWhiteSpace(settingsXml)) + try { - try + using var stringReader = new StringReader(settingsXml); + XmlReader reader = XmlReader.Create(stringReader, ReaderSettings); + + // read to the fist child + XmlReaderUtilities.ReadToRootNode(reader); + reader.ReadToNextElement(); + + // Read till we reach nodeName element or reach EOF + while (!string.Equals(reader.Name, nodeName, StringComparison.OrdinalIgnoreCase) + && + !reader.EOF) { - using (var stringReader = new StringReader(settingsXml)) - { - XmlReader reader = XmlReader.Create(stringReader, ReaderSettings); - - // read to the fist child - XmlReaderUtilities.ReadToRootNode(reader); - reader.ReadToNextElement(); - - // Read till we reach nodeName element or reach EOF - while (!string.Equals(reader.Name, nodeName, StringComparison.OrdinalIgnoreCase) - && - !reader.EOF) - { - reader.SkipToNextElement(); - } - - if (!reader.EOF) - { - // read nodeName element. - return nodeParser(reader); - } - } + reader.SkipToNextElement(); } - catch (XmlException ex) + + if (!reader.EOF) { - throw new SettingsException( - string.Format(CultureInfo.CurrentCulture, "{0} {1}", Resources.CommonResources.MalformedRunSettingsFile, ex.Message), - ex); + // read nodeName element. + return nodeParser(reader); } } - - return default(T); + catch (XmlException ex) + { + throw new SettingsException( + string.Format(CultureInfo.CurrentCulture, "{0} {1}", Resources.CommonResources.MalformedRunSettingsFile, ex.Message), + ex); + } } + return default; + } + #if !NETSTANDARD1_0 - /// - /// Moves the given runsettings file navigator to the DataCollectors node in the runsettings xml. - /// Throws XmlException if it was unable to find the DataCollectors node. - /// - /// XPathNavigator for a runsettings xml document. - private static void MoveToDataCollectorsNode(ref XPathNavigator runSettingsNavigator) + /// + /// Moves the given runsettings file navigator to the DataCollectors node in the runsettings xml. + /// Throws XmlException if it was unable to find the DataCollectors node. + /// + /// XPathNavigator for a runsettings xml document. + private static void MoveToDataCollectorsNode(ref XPathNavigator runSettingsNavigator) + { + runSettingsNavigator.MoveToRoot(); + if (!runSettingsNavigator.MoveToChild("RunSettings", string.Empty)) { - runSettingsNavigator.MoveToRoot(); - if (!runSettingsNavigator.MoveToChild("RunSettings", string.Empty)) - { - throw new XmlException(string.Format(CultureInfo.CurrentCulture, ObjectModelResources.CouldNotFindXmlNode, "RunSettings")); - } + throw new XmlException(string.Format(CultureInfo.CurrentCulture, ObjectModelResources.CouldNotFindXmlNode, "RunSettings")); + } - if (!runSettingsNavigator.MoveToChild("DataCollectionRunSettings", string.Empty)) - { - runSettingsNavigator.AppendChildElement(string.Empty, "DataCollectionRunSettings", string.Empty, string.Empty); - runSettingsNavigator.MoveToChild("DataCollectionRunSettings", string.Empty); - } + if (!runSettingsNavigator.MoveToChild("DataCollectionRunSettings", string.Empty)) + { + runSettingsNavigator.AppendChildElement(string.Empty, "DataCollectionRunSettings", string.Empty, string.Empty); + runSettingsNavigator.MoveToChild("DataCollectionRunSettings", string.Empty); + } - if (!runSettingsNavigator.MoveToChild("DataCollectors", string.Empty)) - { - runSettingsNavigator.AppendChildElement(string.Empty, "DataCollectors", string.Empty, string.Empty); - runSettingsNavigator.MoveToChild("DataCollectors", string.Empty); - } + if (!runSettingsNavigator.MoveToChild("DataCollectors", string.Empty)) + { + runSettingsNavigator.AppendChildElement(string.Empty, "DataCollectors", string.Empty, string.Empty); + runSettingsNavigator.MoveToChild("DataCollectors", string.Empty); } -#endif } +#endif } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/IO/IStream.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/IO/IStream.cs index 2dca8f26db..7067be9bb9 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/IO/IStream.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/IO/IStream.cs @@ -1,21 +1,20 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces -{ - using System.IO; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; + +using System.IO; +/// +/// Helper class to return platform specific stream. +/// +public interface IStream +{ /// - /// Helper class to return platform specific stream. + /// Returns platform specific Buffered Stream with desired buffer size. /// - public interface IStream - { - /// - /// Returns platform specific Buffered Stream with desired buffer size. - /// - /// Input Stream - /// Buffer Size - /// Buffered Stream - Stream CreateBufferedStream(Stream stream, int bufferSize); - } + /// Input Stream + /// Buffer Size + /// Buffered Stream + Stream CreateBufferedStream(Stream stream, int bufferSize); } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Runtime/IAssemblyLoadContext.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Runtime/IAssemblyLoadContext.cs index ad41df795b..9cea9bd4f7 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Runtime/IAssemblyLoadContext.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Runtime/IAssemblyLoadContext.cs @@ -1,27 +1,26 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces -{ - using System.Reflection; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; + +using System.Reflection; +/// +/// Abstraction for Assembly Methods +/// +public interface IAssemblyLoadContext +{ /// - /// Abstraction for Assembly Methods + /// Loads assembly from given path /// - public interface IAssemblyLoadContext - { - /// - /// Loads assembly from given path - /// - /// Assembly path - /// Assembly from given path - Assembly LoadAssemblyFromPath(string assemblyPath); + /// Assembly path + /// Assembly from given path + Assembly LoadAssemblyFromPath(string assemblyPath); - /// - /// Gets Assembly Name from given path - /// - /// Assembly path - /// AssemblyName from given path - AssemblyName GetAssemblyNameFromPath(string assemblyPath); - } -} + /// + /// Gets Assembly Name from given path + /// + /// Assembly path + /// AssemblyName from given path + AssemblyName GetAssemblyNameFromPath(string assemblyPath); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Runtime/IAssemblyResolver.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Runtime/IAssemblyResolver.cs index 13d1e70faf..7a63088a6f 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Runtime/IAssemblyResolver.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Runtime/IAssemblyResolver.cs @@ -1,50 +1,49 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces -{ - using System; - using System.Reflection; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; + +using System; +using System.Reflection; + +/// +/// Represents a method that handles the AssemblyResolve event of an Platform. +/// +/// The source of the event. +/// The event data. +/// The assembly that resolves the type, assembly, or resource; or null if the assembly +/// cannot be resolved. +/// +public delegate Assembly AssemblyResolveEventHandler(object sender, AssemblyResolveEventArgs args); +/// +/// The AssemblyResolver interface. +/// +public interface IAssemblyResolver : IDisposable +{ /// - /// Represents a method that handles the AssemblyResolve event of an Platform. + /// Occurs when the resolution of an assembly fails /// - /// The source of the event. - /// The event data. - /// The assembly that resolves the type, assembly, or resource; or null if the assembly - /// cannot be resolved. - /// - public delegate Assembly AssemblyResolveEventHandler(object sender, AssemblyResolveEventArgs args); + event AssemblyResolveEventHandler AssemblyResolve; +} +/// +/// Provides data for loader resolution events, such as the AppDomain.AssemblyResolve events. +/// +public class AssemblyResolveEventArgs : EventArgs +{ /// - /// The AssemblyResolver interface. + /// Initializes a new instance of the class. + /// name of the item to resolve. /// - public interface IAssemblyResolver : IDisposable + /// The Full name of an assembly to resolve. + public AssemblyResolveEventArgs(string name) { - /// - /// Occurs when the resolution of an assembly fails - /// - event AssemblyResolveEventHandler AssemblyResolve; + Name = name; } /// - /// Provides data for loader resolution events, such as the AppDomain.AssemblyResolve events. + /// Gets or sets the name of the item to resolve. /// - public class AssemblyResolveEventArgs : EventArgs - { - /// - /// Initializes a new instance of the class. - /// name of the item to resolve. - /// - /// The Full name of an assembly to resolve. - public AssemblyResolveEventArgs(string name) - { - this.Name = name; - } - - /// - /// Gets or sets the name of the item to resolve. - /// - public string Name { get; set; } - } -} + public string Name { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/IEnvironment.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/IEnvironment.cs index 5ddff59101..d3e147c925 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/IEnvironment.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/IEnvironment.cs @@ -1,38 +1,37 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; + +/// +/// Operating system environment abstractions. +/// +public interface IEnvironment { /// - /// Operating system environment abstractions. + /// Gets the Operating System architecture. /// - public interface IEnvironment - { - /// - /// Gets the Operating System architecture. - /// - PlatformArchitecture Architecture { get; } + PlatformArchitecture Architecture { get; } - /// - /// Gets the Operating System name. - /// - PlatformOperatingSystem OperatingSystem { get; } + /// + /// Gets the Operating System name. + /// + PlatformOperatingSystem OperatingSystem { get; } - /// - /// Gets the Operating System Version - /// - string OperatingSystemVersion { get; } + /// + /// Gets the Operating System Version + /// + string OperatingSystemVersion { get; } - /// - /// Exits the current process as per Operating System - /// - /// Exit code set by user - void Exit(int exitcode); + /// + /// Exits the current process as per Operating System + /// + /// Exit code set by user + void Exit(int exitcode); - /// - /// Returns Operating System managed thread Id - /// - /// Returns the thread Id - int GetCurrentManagedThreadId(); - } -} + /// + /// Returns Operating System managed thread Id + /// + /// Returns the thread Id + int GetCurrentManagedThreadId(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/IProcessHelper.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/IProcessHelper.cs index d64f5c8132..1b23128ac4 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/IProcessHelper.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/IProcessHelper.cs @@ -1,115 +1,114 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; + +using System; +using System.Collections.Generic; + +/// +/// Interface for any process related functionality. This is needed for clean unit-testing. +/// +public interface IProcessHelper { - using System; - using System.Collections.Generic; + /// + /// Launches the process with the given arguments. + /// + /// The full file name of the process. + /// The command-line arguments. + /// The working directory for this process. + /// Environment variables to set while bootstrapping the process. + /// Call back for to read error stream data + /// Call back for on process exit + /// Call back for on process output + /// The process created. + object LaunchProcess(string processPath, string arguments, string workingDirectory, IDictionary environmentVariables, Action errorCallback, Action exitCallBack, Action outputCallback); + + /// + /// Gets the current process file path. + /// + /// The current process file path. + string GetCurrentProcessFileName(); + + /// + /// Gets the current process location. + /// + /// The current process location. + string GetCurrentProcessLocation(); + + /// + /// Gets the location of test engine. + /// + /// Location of test engine. + string GetTestEngineDirectory(); + + /// + /// Gets the location of native dll's, depending on current process architecture.. + /// + /// Location of native dll's + string GetNativeDllDirectory(); + + /// + /// Gets current process architecture + /// + /// Process Architecture + PlatformArchitecture GetCurrentProcessArchitecture(); + + /// + /// Gets the process id of test engine. + /// + /// process id of test engine. + int GetCurrentProcessId(); + + /// + /// Gets the process id of input process. + /// + /// process parameter + /// process id. + int GetProcessId(object process); + + /// + /// Gets the process name for given process id. + /// + /// process id + /// Name of process + string GetProcessName(int processId); + + /// + /// False if process has not exited, True otherwise. Set exitCode only if process has exited. + /// + /// process parameter + /// return value of exitCode + /// False if process has not exited, True otherwise + bool TryGetExitCode(object process, out int exitCode); + + /// + /// Sets the process exit callback. + /// + /// + /// The process id. + /// + /// + /// Callback on process exit. + /// + void SetExitCallback(int processId, Action callbackAction); + + /// + /// Terminates a process. + /// + /// Reference of process to terminate. + void TerminateProcess(object process); + + /// + /// Wait for process to exit + /// + /// Reference to process + void WaitForProcessExit(object process); /// - /// Interface for any process related functionality. This is needed for clean unit-testing. + /// Gets the process handle for given process Id. /// - public interface IProcessHelper - { - /// - /// Launches the process with the given arguments. - /// - /// The full file name of the process. - /// The command-line arguments. - /// The working directory for this process. - /// Environment variables to set while bootstrapping the process. - /// Call back for to read error stream data - /// Call back for on process exit - /// Call back for on process output - /// The process created. - object LaunchProcess(string processPath, string arguments, string workingDirectory, IDictionary environmentVariables, Action errorCallback, Action exitCallBack, Action outputCallback); - - /// - /// Gets the current process file path. - /// - /// The current process file path. - string GetCurrentProcessFileName(); - - /// - /// Gets the current process location. - /// - /// The current process location. - string GetCurrentProcessLocation(); - - /// - /// Gets the location of test engine. - /// - /// Location of test engine. - string GetTestEngineDirectory(); - - /// - /// Gets the location of native dll's, depending on current process architecture.. - /// - /// Location of native dll's - string GetNativeDllDirectory(); - - /// - /// Gets current process architecture - /// - /// Process Architecture - PlatformArchitecture GetCurrentProcessArchitecture(); - - /// - /// Gets the process id of test engine. - /// - /// process id of test engine. - int GetCurrentProcessId(); - - /// - /// Gets the process id of input process. - /// - /// process parameter - /// process id. - int GetProcessId(object process); - - /// - /// Gets the process name for given process id. - /// - /// process id - /// Name of process - string GetProcessName(int processId); - - /// - /// False if process has not exited, True otherwise. Set exitCode only if process has exited. - /// - /// process parameter - /// return value of exitCode - /// False if process has not exited, True otherwise - bool TryGetExitCode(object process, out int exitCode); - - /// - /// Sets the process exit callback. - /// - /// - /// The process id. - /// - /// - /// Callback on process exit. - /// - void SetExitCallback(int processId, Action callbackAction); - - /// - /// Terminates a process. - /// - /// Reference of process to terminate. - void TerminateProcess(object process); - - /// - /// Wait for process to exit - /// - /// Reference to process - void WaitForProcessExit(object process); - - /// - /// Gets the process handle for given process Id. - /// - /// process id - /// Process Handle - IntPtr GetProcessHandle(int processId); - } -} + /// process id + /// Process Handle + IntPtr GetProcessHandle(int processId); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/IThread.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/IThread.cs index a003f1cb5c..878828ab52 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/IThread.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/IThread.cs @@ -1,19 +1,18 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; + +using System; - public interface IThread - { - /// - /// Runs the action in a thread with given apartment state. - /// - /// The Action to be called. No-Op if action is null. - /// The apartment state. - /// True for running in Sync, False for running in Async - /// When thread apartment state not supported for platform. > - void Run(Action action, PlatformApartmentState apartmentState, bool waitForCompletion); - } -} +public interface IThread +{ + /// + /// Runs the action in a thread with given apartment state. + /// + /// The Action to be called. No-Op if action is null. + /// The apartment state. + /// True for running in Sync, False for running in Async + /// When thread apartment state not supported for platform. > + void Run(Action action, PlatformApartmentState apartmentState, bool waitForCompletion); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/PlatformApartmentState.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/PlatformApartmentState.cs index be6d472f66..67efc07d78 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/PlatformApartmentState.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/PlatformApartmentState.cs @@ -1,14 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +/// +/// Available apartment states for test platform. +/// +public enum PlatformApartmentState { - /// - /// Available apartment states for test platform. - /// - public enum PlatformApartmentState - { - MTA, - STA - } -} + MTA, + STA, +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/PlatformArchitecture.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/PlatformArchitecture.cs index 2c7db68f75..10915a8091 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/PlatformArchitecture.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/PlatformArchitecture.cs @@ -1,17 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +/// +/// Available architectures for test platform. +/// +public enum PlatformArchitecture { - /// - /// Available architectures for test platform. - /// - public enum PlatformArchitecture - { - X86, - X64, - ARM, - ARM64, - S390x - } -} + X86, + X64, + ARM, + ARM64, + S390x, +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/PlatformOperationSystem.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/PlatformOperatingSystem.cs similarity index 56% rename from src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/PlatformOperationSystem.cs rename to src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/PlatformOperatingSystem.cs index 16679783b2..a539a64f1d 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/PlatformOperationSystem.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/PlatformOperatingSystem.cs @@ -1,15 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +/// +/// Available operating systems. +/// +public enum PlatformOperatingSystem { - /// - /// Available operating systems. - /// - public enum PlatformOperatingSystem - { - Windows, - Unix, - OSX - } -} + Windows, + Unix, + OSX, +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/ThreadApartmentStateNotSupportedException.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/ThreadApartmentStateNotSupportedException.cs index 6824252767..bc1ddbed1f 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/ThreadApartmentStateNotSupportedException.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/ThreadApartmentStateNotSupportedException.cs @@ -1,48 +1,47 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System; + +/// +/// Thread apartment state not supported exception. +/// +public class ThreadApartmentStateNotSupportedException : Exception { - using System; + #region Constructors /// - /// Thread apartment state not supported exception. + /// Initializes a new instance of the class. + /// Initializes with the message. /// - public class ThreadApartmentStateNotSupportedException : Exception + /// Message for the exception. + public ThreadApartmentStateNotSupportedException() { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// Initializes with the message. - /// - /// Message for the exception. - public ThreadApartmentStateNotSupportedException() - { - } - - /// - /// Initializes a new instance of the class. - /// Initializes with the message. - /// - /// Message for the exception. - public ThreadApartmentStateNotSupportedException(string message) - : base(message) - { - } - - /// - /// Initializes a new instance of the class. - /// Initializes with message and inner exception. - /// - /// Message for the exception. - /// The inner exception. - public ThreadApartmentStateNotSupportedException(string message, Exception innerException) - : base(message, innerException) - { - } - - #endregion + } + /// + /// Initializes a new instance of the class. + /// Initializes with the message. + /// + /// Message for the exception. + public ThreadApartmentStateNotSupportedException(string message) + : base(message) + { } -} + + /// + /// Initializes a new instance of the class. + /// Initializes with message and inner exception. + /// + /// Message for the exception. + /// The inner exception. + public ThreadApartmentStateNotSupportedException(string message, Exception innerException) + : base(message, innerException) + { + } + + #endregion + +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Tracing/IPlatformEqtTrace.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Tracing/IPlatformEqtTrace.cs index 6e815a4697..756dd17e3c 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Tracing/IPlatformEqtTrace.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Tracing/IPlatformEqtTrace.cs @@ -1,78 +1,77 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +/// +/// Specifies what messages to output for the System.Diagnostics.Debug, System.Diagnostics.Trace +/// and System.Diagnostics.TraceSwitch classes. +/// +public partial interface IPlatformEqtTrace { - /// - /// Specifies what messages to output for the System.Diagnostics.Debug, System.Diagnostics.Trace - /// and System.Diagnostics.TraceSwitch classes. - /// - public partial interface IPlatformEqtTrace + // This is added to ensure that tracing for testhost/datacollector should not be instantiated if not enabled via --diag switch. + bool DoNotInitialize { - // This is added to ensure that tracing for testhost/datacollector should not be instantiated if not enabled via --diag switch. - bool DoNotInitialize - { - get; - set; - } + get; + set; + } - /// - /// Adds the message to the trace log. - /// The line becomes: - /// [I, PID, ThreadID, 2003/06/11 11:56:07.445] CallingAssemblyName: message. - /// - /// Trace level. - /// The message to add to trace. - void WriteLine(PlatformTraceLevel level, string message); + /// + /// Adds the message to the trace log. + /// The line becomes: + /// [I, PID, ThreadID, 2003/06/11 11:56:07.445] CallingAssemblyName: message. + /// + /// Trace level. + /// The message to add to trace. + void WriteLine(PlatformTraceLevel level, string message); - /// - /// Initializes the verbose tracing with custom log file - /// And overrides if any trace is set before - /// - /// - /// A custom log file for trace messages. - /// - /// - /// The . - /// - bool InitializeVerboseTrace(string customLogFile); + /// + /// Initializes the verbose tracing with custom log file + /// And overrides if any trace is set before + /// + /// + /// A custom log file for trace messages. + /// + /// + /// The . + /// + bool InitializeVerboseTrace(string customLogFile); - /// - /// Initializes the tracing with custom log file and trace level. - /// Overrides if any trace is set before. - /// - /// Custom log file for trace messages. - /// Trace level. - /// Trace initialized flag. - bool InitializeTrace(string customLogFile, PlatformTraceLevel traceLevel); + /// + /// Initializes the tracing with custom log file and trace level. + /// Overrides if any trace is set before. + /// + /// Custom log file for trace messages. + /// Trace level. + /// Trace initialized flag. + bool InitializeTrace(string customLogFile, PlatformTraceLevel traceLevel); - /// - /// Gets a value indicating if tracing is enabled for a trace level. - /// - /// Trace level. - /// True if tracing is enabled. - bool ShouldTrace(PlatformTraceLevel traceLevel); + /// + /// Gets a value indicating if tracing is enabled for a trace level. + /// + /// Trace level. + /// True if tracing is enabled. + bool ShouldTrace(PlatformTraceLevel traceLevel); - /// - /// Gets file path for trace log file. - /// - /// True if tracing is enabled. - string GetLogFile(); + /// + /// Gets file path for trace log file. + /// + /// True if tracing is enabled. + string GetLogFile(); - /// - /// Sets platform specific trace value for tracing verbosity. - /// - /// - /// The value. - /// - void SetTraceLevel(PlatformTraceLevel value); + /// + /// Sets platform specific trace value for tracing verbosity. + /// + /// + /// The value. + /// + void SetTraceLevel(PlatformTraceLevel value); - /// - /// Gets platform specific trace value for tracing verbosity. - /// - /// - /// The . - /// - PlatformTraceLevel GetTraceLevel(); - } + /// + /// Gets platform specific trace value for tracing verbosity. + /// + /// + /// The . + /// + PlatformTraceLevel GetTraceLevel(); } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Tracing/PlatformTraceLevel.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Tracing/PlatformTraceLevel.cs index 341829721e..c648b71df3 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Tracing/PlatformTraceLevel.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Tracing/PlatformTraceLevel.cs @@ -1,33 +1,32 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +public enum PlatformTraceLevel { - public enum PlatformTraceLevel - { - /// - /// Output no tracing and debugging messages.. - /// - Off = 0, + /// + /// Output no tracing and debugging messages.. + /// + Off = 0, - /// - /// Output error-handling messages. - /// - Error = 1, + /// + /// Output error-handling messages. + /// + Error = 1, - /// - /// Output warnings and error-handling messages. - /// - Warning = 2, + /// + /// Output warnings and error-handling messages. + /// + Warning = 2, - /// - /// Output informational messages, warnings, and error-handling messages.. - /// - Info = 3, + /// + /// Output informational messages, warnings, and error-handling messages.. + /// + Info = 3, - /// - /// Output all debugging and tracing messages.. - /// - Verbose = 4 - } + /// + /// Output all debugging and tracing messages.. + /// + Verbose = 4 } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/common/IO/PlatformStream.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/common/IO/PlatformStream.cs index ce58abfd9c..8b50dd6a19 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/common/IO/PlatformStream.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/common/IO/PlatformStream.cs @@ -3,20 +3,19 @@ #if NETFRAMEWORK || NETCOREAPP || NETSTANDARD2_0 -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System.IO; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System.IO; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Interfaces; +/// +public class PlatformStream : IStream +{ /// - public class PlatformStream : IStream + public Stream CreateBufferedStream(Stream stream, int bufferSize) { - /// - public Stream CreateBufferedStream(Stream stream, int bufferSize) - { - return new BufferedStream(stream, bufferSize); - } + return new BufferedStream(stream, bufferSize); } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/common/System/ProcessHelper.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/common/System/ProcessHelper.cs index 64070fddb5..c10815e652 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/common/System/ProcessHelper.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/common/System/ProcessHelper.cs @@ -3,209 +3,212 @@ #if NETFRAMEWORK || NETCOREAPP || NETSTANDARD2_0 -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Reflection; + +using Interfaces; + +/// +/// Helper class to deal with process related functionality. +/// +public partial class ProcessHelper : IProcessHelper { - using System; - using System.Collections.Generic; - using System.ComponentModel; - using System.Diagnostics; - using System.IO; - using System.Reflection; - - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - - /// - /// Helper class to deal with process related functionality. - /// - public partial class ProcessHelper : IProcessHelper + private static readonly string Arm = "arm"; + + /// + public object LaunchProcess(string processPath, string arguments, string workingDirectory, IDictionary envVariables, Action errorCallback, Action exitCallBack, Action outputCallBack) { - private static readonly string ARM = "arm"; + if (!File.Exists(processPath)) + { + throw new FileNotFoundException("Path does not exist: " + processPath, processPath); + } - /// - public object LaunchProcess(string processPath, string arguments, string workingDirectory, IDictionary envVariables, Action errorCallback, Action exitCallBack, Action outputCallBack) + var process = new Process(); + try { - var process = new Process(); - try - { - process.StartInfo.UseShellExecute = false; - process.StartInfo.CreateNoWindow = true; - process.StartInfo.WorkingDirectory = workingDirectory; + InitializeAndStart(); + } + catch (Exception) + { + process.Dispose(); + process = null; - process.StartInfo.FileName = processPath; - process.StartInfo.Arguments = arguments; - process.StartInfo.RedirectStandardError = true; + //EqtTrace.Error("TestHost Object {0} failed to launch with the following exception: {1}", processPath, exception.Message); + throw; + } - process.EnableRaisingEvents = true; + return process; - if (envVariables != null) - { - foreach (var kvp in envVariables) - { - process.StartInfo.AddEnvironmentVariable(kvp.Key, kvp.Value); - } - } + // Local functions + void InitializeAndStart() + { + process.StartInfo.UseShellExecute = false; + process.StartInfo.CreateNoWindow = true; + process.StartInfo.WorkingDirectory = workingDirectory; - if (outputCallBack != null) - { - process.StartInfo.RedirectStandardOutput = true; - process.OutputDataReceived += (sender, args) => outputCallBack(sender as Process, args.Data); - } + process.StartInfo.FileName = processPath; + process.StartInfo.Arguments = arguments; + process.StartInfo.RedirectStandardError = true; - if (errorCallback != null) - { - process.ErrorDataReceived += (sender, args) => errorCallback(sender as Process, args.Data); - } + process.EnableRaisingEvents = true; - if (exitCallBack != null) + if (envVariables != null) + { + foreach (var kvp in envVariables) { - process.Exited += (sender, args) => - { - // Call WaitForExit without again to ensure all streams are flushed, - var p = sender as Process; - try - { - // Add timeout to avoid indefinite waiting on child process exit. - p.WaitForExit(500); - } - catch (InvalidOperationException) - { - } - - // If exit callback has code that access Process object, ensure that the exceptions handling should be done properly. - exitCallBack(p); - }; + process.StartInfo.AddEnvironmentVariable(kvp.Key, kvp.Value); } + } - // EqtTrace.Verbose("ProcessHelper: Starting process '{0}' with command line '{1}'", processPath, arguments); - // TODO: Enable logging here, and consider wrapping Win32Exeception into another that shows the path of the process. - process.Start(); + if (outputCallBack != null) + { + process.StartInfo.RedirectStandardOutput = true; + process.OutputDataReceived += (sender, args) => outputCallBack(sender as Process, args.Data); + } - if (errorCallback != null) - { - process.BeginErrorReadLine(); - } + if (errorCallback != null) + { + process.ErrorDataReceived += (sender, args) => errorCallback(sender as Process, args.Data); + } - if (outputCallBack != null) + if (exitCallBack != null) + { + process.Exited += (sender, args) => { - process.BeginOutputReadLine(); - } + // Call WaitForExit without again to ensure all streams are flushed, + var p = sender as Process; + try + { + // Add timeout to avoid indefinite waiting on child process exit. + p.WaitForExit(500); + } + catch (InvalidOperationException) + { + } + + // If exit callback has code that access Process object, ensure that the exceptions handling should be done properly. + exitCallBack(p); + }; } - catch (Exception) - { - process.Dispose(); - process = null; - // EqtTrace.Error("TestHost Object {0} failed to launch with the following exception: {1}", processPath, exception.Message); - throw; + // EqtTrace.Verbose("ProcessHelper: Starting process '{0}' with command line '{1}'", processPath, arguments); + // TODO: Enable logging here, and consider wrapping Win32Exception into another that shows the path of the process. + process.Start(); + + if (errorCallback != null) + { + process.BeginErrorReadLine(); } - return process as object; + if (outputCallBack != null) + { + process.BeginOutputReadLine(); + } } + } - /// - public string GetCurrentProcessFileName() - { - return Process.GetCurrentProcess().MainModule.FileName; - } + /// + public string GetCurrentProcessFileName() + { + return Process.GetCurrentProcess().MainModule.FileName; + } - /// - public string GetTestEngineDirectory() - { - return Path.GetDirectoryName(typeof(ProcessHelper).GetTypeInfo().Assembly.Location); - } + /// + public string GetTestEngineDirectory() + { + return Path.GetDirectoryName(typeof(ProcessHelper).GetTypeInfo().Assembly.Location); + } - /// - public int GetCurrentProcessId() - { - return Process.GetCurrentProcess().Id; - } + /// + public int GetCurrentProcessId() + { + return Process.GetCurrentProcess().Id; + } - /// - public string GetProcessName(int processId) - { - return Process.GetProcessById(processId).ProcessName; - } + /// + public string GetProcessName(int processId) + { + return Process.GetProcessById(processId).ProcessName; + } - /// - public bool TryGetExitCode(object process, out int exitCode) + /// + public bool TryGetExitCode(object process, out int exitCode) + { + try { - var proc = process as Process; - try - { - if (proc != null && proc.HasExited) - { - exitCode = proc.ExitCode; - return true; - } - } - catch (InvalidOperationException) + if (process is Process proc && proc.HasExited) { + exitCode = proc.ExitCode; + return true; } - - exitCode = 0; - return false; } - - /// - public void SetExitCallback(int processId, Action callbackAction) + catch (InvalidOperationException) { - try - { - var process = Process.GetProcessById(processId); - process.EnableRaisingEvents = true; - process.Exited += (sender, args) => callbackAction?.Invoke(sender); - } - catch (ArgumentException) - { - // Process.GetProcessById() throws ArgumentException if process is not running(identifier might be expired). - // Invoke callback immediately. - callbackAction?.Invoke(null); - } } - /// - public void TerminateProcess(object process) + exitCode = 0; + return false; + } + + /// + public void SetExitCallback(int processId, Action callbackAction) + { + try { - var proc = process as Process; - try - { - if (proc != null && !proc.HasExited) - { - proc.Kill(); - } - } - catch (InvalidOperationException) - { - } + var process = Process.GetProcessById(processId); + process.EnableRaisingEvents = true; + process.Exited += (sender, args) => callbackAction?.Invoke(sender); } - - /// - public int GetProcessId(object process) + catch (ArgumentException) { - var proc = process as Process; - return proc?.Id ?? -1; + // Process.GetProcessById() throws ArgumentException if process is not running(identifier might be expired). + // Invoke callback immediately. + callbackAction?.Invoke(null); } + } - /// - public string GetNativeDllDirectory() + /// + public void TerminateProcess(object process) + { + try { - var osArchitecture = new PlatformEnvironment().Architecture; - if (osArchitecture == PlatformArchitecture.ARM || osArchitecture == PlatformArchitecture.ARM64) + if (process is Process proc && !proc.HasExited) { - return Path.Combine(this.GetCurrentProcessLocation(), this.GetCurrentProcessArchitecture().ToString().ToLower(), ARM); + proc.Kill(); } - - return Path.Combine(this.GetCurrentProcessLocation(), this.GetCurrentProcessArchitecture().ToString().ToLower()); } + catch (InvalidOperationException) + { + } + } + + /// + public int GetProcessId(object process) + { + var proc = process as Process; + return proc?.Id ?? -1; + } - /// - public void WaitForProcessExit(object process) + /// + public string GetNativeDllDirectory() + { + var osArchitecture = new PlatformEnvironment().Architecture; + return osArchitecture == PlatformArchitecture.ARM || osArchitecture == PlatformArchitecture.ARM64 + ? Path.Combine(GetCurrentProcessLocation(), GetCurrentProcessArchitecture().ToString().ToLower(), Arm) + : Path.Combine(GetCurrentProcessLocation(), GetCurrentProcessArchitecture().ToString().ToLower()); + } + + /// + public void WaitForProcessExit(object process) + { + if (process is Process proc && !proc.HasExited) { - var proc = process as Process; - if (proc != null && !proc.HasExited) - { - proc.WaitForExit(); - } + proc.WaitForExit(); } } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/common/Tracing/PlatformEqtTrace.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/common/Tracing/PlatformEqtTrace.cs index a23b471d01..472bd96413 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/common/Tracing/PlatformEqtTrace.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/common/Tracing/PlatformEqtTrace.cs @@ -3,439 +3,433 @@ #if NETFRAMEWORK || NETCOREAPP || NETSTANDARD2_0 -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Threading; + +/// +/// Wrapper class for tracing. +/// - Shortcut-methods for Error, Warning, Info, Verbose. +/// - Adds additional information to the trace: calling process name, PID, ThreadID, Time. +/// - Uses custom switch EqtTraceLevel from .config file. +/// - By default tracing if OFF. +/// - Our build environment always sets the /d:TRACE so this class is always enabled, +/// the Debug class is enabled only in debug builds (/d:DEBUG). +/// - We ignore exceptions thrown by underlying TraceSwitch (e.g. due to config file error). +/// We log ignored exceptions to system Application log. +/// We pass through exceptions thrown due to incorrect arguments to EqtTrace methods. +/// Usage: EqtTrace.Info("Here's how to trace info"); +/// +public partial class PlatformEqtTrace : IPlatformEqtTrace { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Globalization; - using System.IO; - using System.Threading; + /// + /// Name of the trace listener. + /// + private const string ListenerName = "TptTraceListener"; /// - /// Wrapper class for tracing. - /// - Shortcut-methods for Error, Warning, Info, Verbose. - /// - Adds additional information to the trace: calling process name, PID, ThreadID, Time. - /// - Uses custom switch EqtTraceLevel from .config file. - /// - By default tracing if OFF. - /// - Our build environment always sets the /d:TRACE so this class is always enabled, - /// the Debug class is enabled only in debug builds (/d:DEBUG). - /// - We ignore exceptions thrown by underlying TraceSwitch (e.g. due to config file error). - /// We log ignored exceptions to system Application log. - /// We pass through exceptions thrown due to incorrect arguments to EqtTrace methods. - /// Usage: EqtTrace.Info("Here's how to trace info"); + /// Create static maps for TraceLevel to SourceLevels. The APIs need to provide TraceLevel + /// for backward compatibility with older versions of Object Model. /// - public partial class PlatformEqtTrace : IPlatformEqtTrace - { - /// - /// Name of the trace listener. - /// - private const string ListenerName = "TptTraceListener"; - - /// - /// Create static maps for TraceLevel to SourceLevels. The APIs need to provide TraceLevel - /// for backward compatibility with older versions of Object Model. - /// - private static readonly Dictionary TraceSourceLevelsMap = - new Dictionary - { - { TraceLevel.Error, SourceLevels.Error }, - { TraceLevel.Info, SourceLevels.Information }, - { TraceLevel.Off, SourceLevels.Off }, - { TraceLevel.Verbose, SourceLevels.Verbose }, - { TraceLevel.Warning, SourceLevels.Warning } - }; - - /// - /// Create static maps for SourceLevels to TraceLevel. The APIs need to provide TraceLevel - /// for backward compatibility with older versions of Object Model. - /// - private static readonly Dictionary SourceTraceLevelsMap = - new Dictionary - { - { SourceLevels.Error, TraceLevel.Error }, - { SourceLevels.Information, TraceLevel.Info }, - { SourceLevels.Off, TraceLevel.Off }, - { SourceLevels.Verbose, TraceLevel.Verbose }, - { SourceLevels.Warning, TraceLevel.Warning }, - { SourceLevels.All, TraceLevel.Verbose } - }; - - /// - /// Create static maps for SourceLevels to TraceLevel. The APIs need to provide TraceLevel - /// for backward compatibility with older versions of Object Model. - /// - private static readonly Dictionary TraceLevelEventTypeMap = - new Dictionary - { - { TraceLevel.Error, TraceEventType.Error }, - { TraceLevel.Info, TraceEventType.Information }, - { TraceLevel.Verbose, TraceEventType.Verbose }, - { TraceLevel.Warning, TraceEventType.Warning } - }; + private static readonly Dictionary TraceSourceLevelsMap = + new() + { + { TraceLevel.Error, SourceLevels.Error }, + { TraceLevel.Info, SourceLevels.Information }, + { TraceLevel.Off, SourceLevels.Off }, + { TraceLevel.Verbose, SourceLevels.Verbose }, + { TraceLevel.Warning, SourceLevels.Warning } + }; + + /// + /// Create static maps for SourceLevels to TraceLevel. The APIs need to provide TraceLevel + /// for backward compatibility with older versions of Object Model. + /// + private static readonly Dictionary SourceTraceLevelsMap = + new() + { + { SourceLevels.Error, TraceLevel.Error }, + { SourceLevels.Information, TraceLevel.Info }, + { SourceLevels.Off, TraceLevel.Off }, + { SourceLevels.Verbose, TraceLevel.Verbose }, + { SourceLevels.Warning, TraceLevel.Warning }, + { SourceLevels.All, TraceLevel.Verbose } + }; - // Current process name/id that called trace so that it's easier to read logs. - // We cache them for performance reason. - private static readonly string ProcessName = GetProcessName(); + /// + /// Create static maps for SourceLevels to TraceLevel. The APIs need to provide TraceLevel + /// for backward compatibility with older versions of Object Model. + /// + private static readonly Dictionary TraceLevelEventTypeMap = + new() + { + { TraceLevel.Error, TraceEventType.Error }, + { TraceLevel.Info, TraceEventType.Information }, + { TraceLevel.Verbose, TraceEventType.Verbose }, + { TraceLevel.Warning, TraceEventType.Warning } + }; - private static readonly int ProcessId = GetProcessId(); + // Current process name/id that called trace so that it's easier to read logs. + // We cache them for performance reason. + private static readonly string ProcessName = GetProcessName(); - private static object lockObject = new object(); + private static readonly int ProcessId = GetProcessId(); - private static TraceSource traceSource; + private static readonly object LockObject = new(); - /// - /// Specifies whether the trace is initialized or not - /// - private static bool isInitialized = false; + private static TraceSource s_traceSource; - /// - /// Lock over initialization - /// - private static object isInitializationLock = new object(); + /// + /// Specifies whether the trace is initialized or not + /// + private static bool s_isInitialized = false; - private static int traceFileSize = 0; - private static int defaultTraceFileSize = 10240; // 10Mb. + /// + /// Lock over initialization + /// + private static readonly object IsInitializationLock = new(); + + private static int s_traceFileSize = 0; + private static readonly int DefaultTraceFileSize = 10240; // 10Mb. + + public static string LogFile + { + get; + private set; + } - public static string LogFile + /// + /// Gets or sets the trace level. + /// + public static TraceLevel TraceLevel + { + get { - get; - private set; + return SourceTraceLevelsMap[Source.Switch.Level]; } - /// - /// Gets or sets the trace level. - /// - public static TraceLevel TraceLevel + set { - get + try { - return SourceTraceLevelsMap[Source.Switch.Level]; + Source.Switch.Level = TraceSourceLevelsMap[value]; } - - set + catch (ArgumentException e) { - try - { - Source.Switch.Level = TraceSourceLevelsMap[value]; - } - catch (ArgumentException e) - { - LogIgnoredException(e); - } + LogIgnoredException(e); } } + } - public static string ErrorOnInitialization - { - get; - set; - } + public static string ErrorOnInitialization + { + get; + set; + } - // This is added to ensure that traceSource should not be instantiated in when creating appdomains if EqtTrace is not enabled. - public bool DoNotInitialize - { - get; - set; - } + // This is added to ensure that traceSource should not be instantiated in when creating appdomains if EqtTrace is not enabled. + public bool DoNotInitialize + { + get; + set; + } - /// - /// Gets a custom trace source. This doesn't pollute the default tracing for user applications. - /// - private static TraceSource Source + /// + /// Gets a custom trace source. This doesn't pollute the default tracing for user applications. + /// + private static TraceSource Source + { + get { - get + if (s_traceSource == null) { - if (traceSource == null) + lock (LockObject) { - lock (lockObject) + if (s_traceSource == null) { - if (traceSource == null) - { - traceSource = new TraceSource("TpTrace", SourceLevels.Off); - } + s_traceSource = new TraceSource("TpTrace", SourceLevels.Off); } } - - return traceSource; } - } - /// - public bool InitializeVerboseTrace(string customLogFile) - { - return this.InitializeTrace(customLogFile, PlatformTraceLevel.Verbose); + return s_traceSource; } + } - /// - public bool InitializeTrace(string customLogFile, PlatformTraceLevel platformTraceLevel) - { - isInitialized = false; + /// + public bool InitializeVerboseTrace(string customLogFile) + { + return InitializeTrace(customLogFile, PlatformTraceLevel.Verbose); + } - LogFile = customLogFile; - TraceLevel = this.MapPlatformTraceToTrace(platformTraceLevel); - Source.Switch.Level = TraceSourceLevelsMap[TraceLevel]; + /// + public bool InitializeTrace(string customLogFile, PlatformTraceLevel platformTraceLevel) + { + s_isInitialized = false; - // Ensure trace is initialized - return EnsureTraceIsInitialized(); - } + LogFile = customLogFile; + TraceLevel = MapPlatformTraceToTrace(platformTraceLevel); + Source.Switch.Level = TraceSourceLevelsMap[TraceLevel]; - /// - public bool ShouldTrace(PlatformTraceLevel traceLevel) - { - if (this.DoNotInitialize) - { - return false; - } + // Ensure trace is initialized + return EnsureTraceIsInitialized(); + } - switch (traceLevel) - { - case PlatformTraceLevel.Off: - return false; - case PlatformTraceLevel.Error: - return Source.Switch.ShouldTrace(TraceEventType.Error); - case PlatformTraceLevel.Warning: - return Source.Switch.ShouldTrace(TraceEventType.Warning); - case PlatformTraceLevel.Info: - return Source.Switch.ShouldTrace(TraceEventType.Information); - case PlatformTraceLevel.Verbose: - return Source.Switch.ShouldTrace(TraceEventType.Verbose); - default: - Debug.Fail("Should never get here!"); - return false; - } + /// + public bool ShouldTrace(PlatformTraceLevel traceLevel) + { + if (DoNotInitialize) + { + return false; } - /// - public string GetLogFile() + switch (traceLevel) { - return LogFile; + case PlatformTraceLevel.Off: + return false; + case PlatformTraceLevel.Error: + return Source.Switch.ShouldTrace(TraceEventType.Error); + case PlatformTraceLevel.Warning: + return Source.Switch.ShouldTrace(TraceEventType.Warning); + case PlatformTraceLevel.Info: + return Source.Switch.ShouldTrace(TraceEventType.Information); + case PlatformTraceLevel.Verbose: + return Source.Switch.ShouldTrace(TraceEventType.Verbose); + default: + Debug.Fail("Should never get here!"); + return false; } + } + + /// + public string GetLogFile() + { + return LogFile; + } + + /// + public void WriteLine(PlatformTraceLevel level, string message) + { + Debug.Assert(message != null, "message != null"); + Debug.Assert(!string.IsNullOrEmpty(ProcessName), "!string.IsNullOrEmpty(ProcessName)"); - /// - public void WriteLine(PlatformTraceLevel level, string message) + if (EnsureTraceIsInitialized()) { - Debug.Assert(message != null, "message != null"); - Debug.Assert(!string.IsNullOrEmpty(ProcessName), "!string.IsNullOrEmpty(ProcessName)"); + // The format below is a CSV so that Excel could be used easily to + // view/filter the logs. + var log = string.Format( + CultureInfo.InvariantCulture, + "{0}, {1}, {2:yyyy}/{2:MM}/{2:dd}, {2:HH}:{2:mm}:{2:ss}.{2:fff}, {5}, {3}, {4}", + ProcessId, + Thread.CurrentThread.ManagedThreadId, + DateTime.Now, + ProcessName, + message, + Stopwatch.GetTimestamp()); - if (EnsureTraceIsInitialized()) + try { - // The format below is a CSV so that Excel could be used easily to - // view/filter the logs. - var log = string.Format( - CultureInfo.InvariantCulture, - "{0}, {1}, {2:yyyy}/{2:MM}/{2:dd}, {2:HH}:{2:mm}:{2:ss}.{2:fff}, {5}, {3}, {4}", - ProcessId, - Thread.CurrentThread.ManagedThreadId, - DateTime.Now, - ProcessName, - message, - Stopwatch.GetTimestamp()); - - try - { - Source.TraceEvent(TraceLevelEventTypeMap[this.MapPlatformTraceToTrace(level)], 0, log); - Source.Flush(); - } - catch (Exception e) - { - // valid suppress - // Log exception from tracing into event viewer. - LogIgnoredException(e); - } + Source.TraceEvent(TraceLevelEventTypeMap[MapPlatformTraceToTrace(level)], 0, log); + Source.Flush(); + } + catch (Exception e) + { + // valid suppress + // Log exception from tracing into event viewer. + LogIgnoredException(e); } } + } - /// - public void SetTraceLevel(PlatformTraceLevel value) - { - Source.Switch.Level = TraceSourceLevelsMap[this.MapPlatformTraceToTrace(value)]; - } + /// + public void SetTraceLevel(PlatformTraceLevel value) + { + Source.Switch.Level = TraceSourceLevelsMap[MapPlatformTraceToTrace(value)]; + } - public PlatformTraceLevel GetTraceLevel() + public PlatformTraceLevel GetTraceLevel() + { + return (PlatformTraceLevel)SourceTraceLevelsMap[Source.Switch.Level]; + } + + public TraceLevel MapPlatformTraceToTrace(PlatformTraceLevel traceLevel) + { + switch (traceLevel) { - return (PlatformTraceLevel)SourceTraceLevelsMap[Source.Switch.Level]; + case PlatformTraceLevel.Off: + return TraceLevel.Off; + case PlatformTraceLevel.Error: + return TraceLevel.Error; + case PlatformTraceLevel.Warning: + return TraceLevel.Warning; + case PlatformTraceLevel.Info: + return TraceLevel.Info; + case PlatformTraceLevel.Verbose: + return TraceLevel.Verbose; + default: + Debug.Fail("Should never get here!"); + return TraceLevel.Verbose; } + } - public TraceLevel MapPlatformTraceToTrace(PlatformTraceLevel traceLevel) + /// + /// Setup trace listeners. It should be called when setting trace listener for child domain. + /// + /// New listener. + internal static void SetupRemoteListeners(TraceListener listener) + { + lock (IsInitializationLock) { - switch (traceLevel) + // Add new listeners. + if (listener != null) { - case PlatformTraceLevel.Off: - return TraceLevel.Off; - case PlatformTraceLevel.Error: - return TraceLevel.Error; - case PlatformTraceLevel.Warning: - return TraceLevel.Warning; - case PlatformTraceLevel.Info: - return TraceLevel.Info; - case PlatformTraceLevel.Verbose: - return TraceLevel.Verbose; - default: - Debug.Fail("Should never get here!"); - return TraceLevel.Verbose; + Source.Listeners.Add(listener); } + + s_isInitialized = true; } + } + + /// + /// Auxiliary method: logs the exception that is being ignored. + /// + /// The exception to log. + private static void LogIgnoredException(Exception e) + { + Debug.Assert(e != null, "e != null"); - /// - /// Setup trace listeners. It should be called when setting trace listener for child domain. - /// - /// New listener. - internal static void SetupRemoteListeners(TraceListener listener) + try { - lock (isInitializationLock) - { - // Add new listeners. - if (listener != null) - { - Source.Listeners.Add(listener); - } + EnsureTraceIsInitialized(); - isInitialized = true; - } + // Note: Debug.WriteLine may throw if there is a problem in .config file. + Debug.WriteLine("Ignore exception: " + e); } - - /// - /// Auxiliary method: logs the exception that is being ignored. - /// - /// The exception to log. - private static void LogIgnoredException(Exception e) + catch { - Debug.Assert(e != null, "e != null"); - - try - { - EnsureTraceIsInitialized(); + // Ignore everything at this point. + } + } - // Note: Debug.WriteLine may throw if there is a problem in .config file. - Debug.WriteLine("Ignore exception: " + e); - } - catch - { - // Ignore everything at this point. - } + /// + /// Ensure the trace is initialized + /// + /// + /// The . + /// + private static bool EnsureTraceIsInitialized() + { + if (s_isInitialized) + { + return true; } - /// - /// Ensure the trace is initialized - /// - /// - /// The . - /// - private static bool EnsureTraceIsInitialized() + lock (IsInitializationLock) { - if (isInitialized) + if (s_isInitialized) { return true; } - lock (isInitializationLock) - { - if (isInitialized) - { - return true; - } - - string logsDirectory = Path.GetTempPath(); - - // Set the trace level and add the trace listener - if (LogFile == null) - { - using (var process = Process.GetCurrentProcess()) - { - // In case of parallel execution, there may be several processes with same name. - // Add a process id to make the traces unique. - LogFile = Path.Combine( - logsDirectory, - Path.GetFileNameWithoutExtension(process.MainModule.FileName) + "." + process.Id + ".TpTrace.log"); - } - } + string logsDirectory = Path.GetTempPath(); - // Add a default listener - traceFileSize = defaultTraceFileSize; - try - { - Source.Listeners.Add(new RollingFileTraceListener(LogFile, ListenerName, traceFileSize)); - } - catch (Exception e) - { - UnInitializeTrace(); - ErrorOnInitialization = e.ToString(); - return false; - } + // Set the trace level and add the trace listener + if (LogFile == null) + { + using var process = Process.GetCurrentProcess(); - isInitialized = true; - return true; + // In case of parallel execution, there may be several processes with same name. + // Add a process id to make the traces unique. + LogFile = Path.Combine( + logsDirectory, + Path.GetFileNameWithoutExtension(process.MainModule.FileName) + "." + process.Id + ".TpTrace.log"); } - } - /// - /// Get the process name. Note: we cache it, use m_processName. - /// - /// Name of the process. - private static string GetProcessName() - { + // Add a default listener + s_traceFileSize = DefaultTraceFileSize; try { - string processName = null; - - string[] args = Environment.GetCommandLineArgs(); - - if (args != null && args.Length != 0) - { - // Leave the extension if specified, otherwise don't add it (e.g. case a.exe.exe). - // It seems that if .exe suffix is not specified Framework adds .EXE to args[0]. - processName = Path.GetFileName(args[0]); - } - - // If we still have not got process name from command line - use the slow way. - // This should never happen unless the process is called from execv with empty cmdline. - if (string.IsNullOrEmpty(processName)) - { - Debug.Fail("Could not get process name from command line, will try to use the slow way."); - using (var process = Process.GetCurrentProcess()) - { - processName = process.ProcessName; - } - } - - return processName; + Source.Listeners.Add(new RollingFileTraceListener(LogFile, ListenerName, s_traceFileSize)); } catch (Exception e) { - // valid suppress - Debug.Fail("Could not get process name: " + e); - LogIgnoredException(e); - return e.Message; + UnInitializeTrace(); + ErrorOnInitialization = e.ToString(); + return false; } + + s_isInitialized = true; + return true; } + } - private static int GetProcessId() + /// + /// Get the process name. Note: we cache it, use m_processName. + /// + /// Name of the process. + private static string GetProcessName() + { + try { - try + string processName = null; + + string[] args = Environment.GetCommandLineArgs(); + + if (args != null && args.Length != 0) { - using (var process = Process.GetCurrentProcess()) - { - return process.Id; - } + // Leave the extension if specified, otherwise don't add it (e.g. case a.exe.exe). + // It seems that if .exe suffix is not specified Framework adds .EXE to args[0]. + processName = Path.GetFileName(args[0]); } - catch (InvalidOperationException e) + + // If we still have not got process name from command line - use the slow way. + // This should never happen unless the process is called from execv with empty cmdline. + if (string.IsNullOrEmpty(processName)) { - Debug.Fail("Could not get process id: " + e); - LogIgnoredException(e); - return -1; + Debug.Fail("Could not get process name from command line, will try to use the slow way."); + using var process = Process.GetCurrentProcess(); + processName = process.ProcessName; } - } - private static void UnInitializeTrace() + return processName; + } + catch (Exception e) { - isInitialized = false; + // valid suppress + Debug.Fail("Could not get process name: " + e); + LogIgnoredException(e); + return e.Message; + } + } - LogFile = null; - TraceLevel = TraceLevel.Off; - Source.Switch.Level = SourceLevels.Off; + private static int GetProcessId() + { + try + { + using var process = Process.GetCurrentProcess(); + return process.Id; + } + catch (InvalidOperationException e) + { + Debug.Fail("Could not get process id: " + e); + LogIgnoredException(e); + return -1; } } + + private static void UnInitializeTrace() + { + s_isInitialized = false; + + LogFile = null; + TraceLevel = TraceLevel.Off; + Source.Switch.Level = SourceLevels.Off; + } } #endif diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/common/Tracing/RollingFileTraceListener.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/common/Tracing/RollingFileTraceListener.cs index b431bff37c..040d4c7d35 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/common/Tracing/RollingFileTraceListener.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/common/Tracing/RollingFileTraceListener.cs @@ -3,474 +3,462 @@ #if NETFRAMEWORK || NETCOREAPP || NETSTANDARD2_0 -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.Diagnostics; +using System.IO; +using System.Text; + +/// +/// Performs logging to a file and rolls the output file when either time or size thresholds are +/// exceeded. +/// +public class RollingFileTraceListener : TextWriterTraceListener { - using System; - using System.Diagnostics; - using System.Diagnostics.CodeAnalysis; - using System.IO; - using System.Text; + private readonly int _rollSizeInBytes; /// - /// Performs logging to a file and rolls the output file when either time or size thresholds are - /// exceeded. + /// Initializes a new instance of the class. /// - public class RollingFileTraceListener : TextWriterTraceListener + /// The filename where the entries will be logged. + /// Name of the trace listener. + /// The maximum file size (KB) before rolling. + public RollingFileTraceListener( + string fileName, + string name, + int rollSizeKB) + : base(OpenTextWriter(fileName), name) { - private readonly StreamWriterRollingHelper rollingHelper; - - private readonly int rollSizeInBytes; + if (string.IsNullOrWhiteSpace(fileName)) + { + throw new ArgumentException("fileName was null or whitespace", nameof(fileName)); + } - /// - /// Initializes a new instance of the class. - /// - /// The filename where the entries will be logged. - /// Name of the trace listener. - /// The maximum file size (KB) before rolling. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "the fileStream is passed into the TextWriterTraceListener")] - public RollingFileTraceListener( - string fileName, - string name, - int rollSizeKB) - : base(OpenTextWriter(fileName), name) + if (rollSizeKB <= 0) { - if (string.IsNullOrWhiteSpace(fileName)) - { - throw new ArgumentException("fileName was null or whitespace", nameof(fileName)); - } + throw new ArgumentOutOfRangeException(nameof(rollSizeKB)); + } - if (rollSizeKB <= 0) - { - throw new ArgumentOutOfRangeException(nameof(rollSizeKB)); - } + TraceFileName = fileName; + _rollSizeInBytes = rollSizeKB * 1024; + RollingHelper = new StreamWriterRollingHelper(this); + } - this.TraceFileName = fileName; - this.rollSizeInBytes = rollSizeKB * 1024; - this.rollingHelper = new StreamWriterRollingHelper(this); - } + /// + /// Gets name of the Trace file. + /// + internal string TraceFileName + { + get; + private set; + } + /// + /// Gets the for the flat file. + /// + /// + /// The for the flat file. + /// + internal StreamWriterRollingHelper RollingHelper { get; private set; } + + /// + /// Writes the trace messages to the file. + /// + /// Trace message string + public override void WriteLine(string message) + { + RollingHelper.RollIfNecessary(); + base.WriteLine(message); + } + + /// + /// Opens specified file and returns text writer. + /// + /// The file to open. + /// A instance. + internal static TallyKeepingFileStreamWriter OpenTextWriter(string fileName) + { + return new TallyKeepingFileStreamWriter( + File.Open(fileName, FileMode.Append, FileAccess.Write, FileShare.ReadWrite), + GetEncodingWithFallback()); + } + + /// + protected override void Dispose(bool disposing) + { + RollingHelper?.Dispose(); + + base.Dispose(disposing); + } + + private static Encoding GetEncodingWithFallback() + { + Encoding encoding = (Encoding)new UTF8Encoding(false).Clone(); +#if TODO + encoding.EncoderFallback = EncoderFallback.ReplacementFallback; + encoding.DecoderFallback = DecoderFallback.ReplacementFallback; +#endif + return encoding; + } + + /// + /// Encapsulates the logic to perform rolls. + /// + /// + /// If no rolling behavior has been configured no further processing will be performed. + /// + internal sealed class StreamWriterRollingHelper : IDisposable + { /// - /// Gets name of the Trace file. + /// Synchronization lock. /// - internal string TraceFileName - { - get; - private set; - } + private readonly object _synclock = new(); /// - /// Gets the for the flat file. + /// Whether the object is disposed or not. /// - /// - /// The for the flat file. - /// - internal StreamWriterRollingHelper RollingHelper - { - get { return this.rollingHelper; } - } + private bool _disposed = false; /// - /// Writes the trace messages to the file. + /// A tally keeping writer used when file size rolling is configured. + /// The original stream writer from the base trace listener will be replaced with + /// this listener. /// - /// Trace message string - public override void WriteLine(string message) - { - this.rollingHelper.RollIfNecessary(); - base.WriteLine(message); - } + private TallyKeepingFileStreamWriter _managedWriter; /// - /// Opens specified file and returns text writer. + /// The trace listener for which rolling is being managed. /// - /// The file to open. - /// A instance. - internal static TallyKeepingFileStreamWriter OpenTextWriter(string fileName) - { - return new TallyKeepingFileStreamWriter( - File.Open(fileName, FileMode.Append, FileAccess.Write, FileShare.ReadWrite), - GetEncodingWithFallback()); - } + private readonly RollingFileTraceListener _owner; - /// - protected override void Dispose(bool disposing) - { - this.rollingHelper?.Dispose(); - - base.Dispose(disposing); - } - - private static Encoding GetEncodingWithFallback() + /// + /// Initializes a new instance of the class. + /// + /// + /// The to use. + /// + public StreamWriterRollingHelper(RollingFileTraceListener owner) { - Encoding encoding = (Encoding)new UTF8Encoding(false).Clone(); -#if TODO - encoding.EncoderFallback = EncoderFallback.ReplacementFallback; - encoding.DecoderFallback = DecoderFallback.ReplacementFallback; -#endif - return encoding; + _owner = owner; + _managedWriter = owner.Writer as TallyKeepingFileStreamWriter; } /// - /// Encapsulates the logic to perform rolls. + /// Checks whether rolling should be performed, and returns the date to use when performing the roll. /// + /// The date roll to use if performing a roll, or if no rolling should occur. /// - /// If no rolling behavior has been configured no further processing will be performed. + /// Defer request for the roll date until it is necessary to avoid overhead. + /// Information used for rolling checks should be set by now. /// - internal sealed class StreamWriterRollingHelper : IDisposable + public DateTime? CheckIsRollNecessary() { - /// - /// Synchronization lock. - /// - private object synclock = new object(); - - /// - /// Whether the object is disposed or not. - /// - private bool disposed = false; - - /// - /// A tally keeping writer used when file size rolling is configured. - /// The original stream writer from the base trace listener will be replaced with - /// this listener. - /// - private TallyKeepingFileStreamWriter managedWriter; - - /// - /// The trace listener for which rolling is being managed. - /// - private RollingFileTraceListener owner; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The to use. - /// - public StreamWriterRollingHelper(RollingFileTraceListener owner) + // check for size roll, if enabled. + if (_managedWriter != null && _managedWriter.Tally > _owner._rollSizeInBytes) { - this.owner = owner; - this.managedWriter = owner.Writer as TallyKeepingFileStreamWriter; + return DateTime.Now; } - /// - /// Checks whether rolling should be performed, and returns the date to use when performing the roll. - /// - /// The date roll to use if performing a roll, or if no rolling should occur. - /// - /// Defer request for the roll date until it is necessary to avoid overhead. - /// Information used for rolling checks should be set by now. - /// - public DateTime? CheckIsRollNecessary() - { - // check for size roll, if enabled. - if (this.managedWriter != null && this.managedWriter.Tally > this.owner.rollSizeInBytes) - { - return DateTime.Now; - } - - // no roll is necessary, return a null roll date - return null; - } + // no roll is necessary, return a null roll date + return null; + } - /// - /// Perform the roll for the next date. - /// - /// The roll date. - public void PerformRoll(DateTime rollDateTime) - { - string actualFileName = ((FileStream)((StreamWriter)this.owner.Writer).BaseStream).Name; + /// + /// Perform the roll for the next date. + /// + /// The roll date. + public void PerformRoll(DateTime rollDateTime) + { + string actualFileName = ((FileStream)((StreamWriter)_owner.Writer).BaseStream).Name; - // calculate archive name - string directory = Path.GetDirectoryName(actualFileName); - string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(actualFileName); - string extension = Path.GetExtension(actualFileName); + // calculate archive name + string directory = Path.GetDirectoryName(actualFileName); + string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(actualFileName); + string extension = Path.GetExtension(actualFileName); - StringBuilder fileNameBuilder = new StringBuilder(fileNameWithoutExtension); - fileNameBuilder.Append('.'); - fileNameBuilder.Append("bak"); - fileNameBuilder.Append(extension); + StringBuilder fileNameBuilder = new(fileNameWithoutExtension); + fileNameBuilder.Append('.'); + fileNameBuilder.Append("bak"); + fileNameBuilder.Append(extension); - string archiveFileName = Path.Combine(directory, fileNameBuilder.ToString()); + string archiveFileName = Path.Combine(directory, fileNameBuilder.ToString()); #if TODO // close file owner.Writer.Close(); #endif - // move file - SafeMove(actualFileName, archiveFileName, rollDateTime); + // move file + SafeMove(actualFileName, archiveFileName, rollDateTime); - // update writer - let TWTL open the file as needed to keep consistency - this.owner.Writer = null; - this.managedWriter = null; - this.UpdateRollingInformationIfNecessary(); - } + // update writer - let TWTL open the file as needed to keep consistency + _owner.Writer = null; + _managedWriter = null; + UpdateRollingInformationIfNecessary(); + } - /// - /// Rolls the file if necessary. - /// - public void RollIfNecessary() + /// + /// Rolls the file if necessary. + /// + public void RollIfNecessary() + { + if (!UpdateRollingInformationIfNecessary()) { - if (!this.UpdateRollingInformationIfNecessary()) - { - // an error was detected while handling roll information - avoid further processing - return; - } + // an error was detected while handling roll information - avoid further processing + return; + } - DateTime? rollDateTime; - if ((rollDateTime = this.CheckIsRollNecessary()) != null) + DateTime? rollDateTime; + if ((rollDateTime = CheckIsRollNecessary()) != null) + { + lock (_synclock) { - lock (this.synclock) + // double check if the roll is still required and do it... + if ((rollDateTime = CheckIsRollNecessary()) != null) { - // double check if the roll is still required and do it... - if ((rollDateTime = this.CheckIsRollNecessary()) != null) - { - this.PerformRoll(rollDateTime.Value); - } + PerformRoll(rollDateTime.Value); } } } + } - /// - /// Updates book keeping information necessary for rolling, as required by the specified - /// rolling configuration. - /// - /// true if update was successful, false if an error occurred. - public bool UpdateRollingInformationIfNecessary() + /// + /// Updates book keeping information necessary for rolling, as required by the specified + /// rolling configuration. + /// + /// true if update was successful, false if an error occurred. + public bool UpdateRollingInformationIfNecessary() + { + // replace writer with the tally keeping version if necessary for size rolling + if (_managedWriter == null) { - // replace writer with the tally keeping version if necessary for size rolling - if (this.managedWriter == null) + try { - try - { - this.managedWriter = OpenTextWriter(this.owner.TraceFileName); - } - catch (Exception) - { - // there's a slight chance of error here - abort if this occurs and just let TWTL handle it without attempting to roll - return false; - } - - this.owner.Writer = this.managedWriter; + _managedWriter = OpenTextWriter(_owner.TraceFileName); + } + catch (Exception) + { + // there's a slight chance of error here - abort if this occurs and just let TWTL handle it without attempting to roll + return false; } - return true; + _owner.Writer = _managedWriter; } - /// - /// Disposes this instance - /// - public void Dispose() + return true; + } + + /// + /// Disposes this instance + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private static void SafeMove(string actualFileName, string archiveFileName, DateTime currentDateTime) + { + try { - this.Dispose(true); - GC.SuppressFinalize(this); - } + if (File.Exists(archiveFileName)) + { + File.Delete(archiveFileName); + } - private static void SafeMove(string actualFileName, string archiveFileName, DateTime currentDateTime) + // take care of tunneling issues http://support.microsoft.com/kb/172190 + File.SetCreationTime(actualFileName, currentDateTime); + File.Move(actualFileName, archiveFileName); + } + catch (IOException) { + // catch errors and attempt move to a new file with a GUID + archiveFileName += Guid.NewGuid().ToString(); + try { - if (File.Exists(archiveFileName)) - { - File.Delete(archiveFileName); - } - - // take care of tunneling issues http://support.microsoft.com/kb/172190 - File.SetCreationTime(actualFileName, currentDateTime); File.Move(actualFileName, archiveFileName); } catch (IOException) { - // catch errors and attempt move to a new file with a GUID - archiveFileName += Guid.NewGuid().ToString(); - - try - { - File.Move(actualFileName, archiveFileName); - } - catch (IOException) - { - } } } + } - private void Dispose(bool disposing) + private void Dispose(bool disposing) + { + if (!_disposed) { - if (!this.disposed) + if (disposing && _managedWriter != null) { - if (disposing && this.managedWriter != null) - { #if TODO managedWriter.Close(); #endif - } - - this.disposed = true; } + + _disposed = true; } } + } + + /// + /// Represents a file stream writer that keeps a tally of the length of the file. + /// + internal sealed class TallyKeepingFileStreamWriter : StreamWriter + { /// - /// Represents a file stream writer that keeps a tally of the length of the file. + /// Initializes a new instance of the class. /// - internal sealed class TallyKeepingFileStreamWriter : StreamWriter + /// + /// The to write to. + /// + public TallyKeepingFileStreamWriter(FileStream stream) + : base(stream) { - private long tally; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The to write to. - /// - public TallyKeepingFileStreamWriter(FileStream stream) - : base(stream) + if (stream == null) { - if (stream == null) - { - throw new ArgumentNullException(nameof(stream)); - } - - this.tally = stream.Length; + throw new ArgumentNullException(nameof(stream)); } - /// - /// Initializes a new instance of the class. - /// - /// - /// The to write to. - /// - /// - /// The to use. - /// - public TallyKeepingFileStreamWriter(FileStream stream, Encoding encoding) - : base(stream, encoding) - { - if (stream == null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (encoding == null) - { - throw new ArgumentNullException(nameof(encoding)); - } - - this.tally = stream.Length; - } + Tally = stream.Length; + } - /// - /// Gets the tally of the length of the string. - /// - /// - /// The tally of the length of the string. - /// - public long Tally + /// + /// Initializes a new instance of the class. + /// + /// + /// The to write to. + /// + /// + /// The to use. + /// + public TallyKeepingFileStreamWriter(FileStream stream, Encoding encoding) + : base(stream, encoding) + { + if (stream == null) { - get { return this.tally; } + throw new ArgumentNullException(nameof(stream)); } - /// - /// Writes a character to the stream. - /// - /// - /// The character to write to the text stream. - /// - /// - /// is true or thebuffer is full, and current writer is closed. - /// - /// - /// is true or thebuffer is full, and the contents of the buffer cannot be written to the underlying fixed size stream because theis at the end the stream. - /// - /// - /// An I/O error occurs. - /// - /// 1 - public override void Write(char value) + if (encoding == null) { - base.Write(value); - this.tally += this.Encoding.GetByteCount(new[] { value }); + throw new ArgumentNullException(nameof(encoding)); } - /// - /// Writes a character array to the stream. - /// - /// - /// A character array containing the data to write. If buffer is null, nothing is written. - /// - /// - /// is true or thebuffer is full, and current writer is closed. - /// - /// - /// is true or thebuffer is full, and the contents of the buffer cannot be written to the underlying fixed size stream because theis at the end the stream. - /// - /// - /// An I/O error occurs. - /// - /// 1 - public override void Write(char[] buffer) - { - base.Write(buffer); - this.tally += this.Encoding.GetByteCount(buffer); - } + Tally = stream.Length; + } - /// - /// Writes an array of characters to the stream. - /// - /// - /// A character array containing the data to write. - /// - /// - /// The index into buffer at which to begin writing. - /// - /// - /// The number of characters to read from buffer. - /// - /// - /// An I/O error occurs. - /// - /// - /// is true or thebuffer is full, and current writer is closed. - /// - /// - /// is true or thebuffer is full, and the contents of the buffer cannot be written to the underlying fixed size stream because theis at the end the stream. - /// - /// - /// index or count is negative. - /// - /// - /// The buffer length minus index is less than count. - /// - /// - /// buffer is null. - /// - /// 1 - public override void Write(char[] buffer, int index, int count) - { - base.Write(buffer, index, count); - this.tally += this.Encoding.GetByteCount(buffer, index, count); - } + /// + /// Gets the tally of the length of the string. + /// + /// + /// The tally of the length of the string. + /// + public long Tally { get; private set; } - /// - /// Writes a string to the stream. - /// - /// - /// The string to write to the stream. If value is null, nothing is written. - /// - /// - /// is true or thebuffer is full, and current writer is closed. - /// - /// - /// is true or thebuffer is full, and the contents of the buffer cannot be written to the underlying fixed size stream because theis at the end the stream. - /// - /// - /// An I/O error occurs. - /// - /// 1 - public override void Write(string value) - { - base.Write(value); - this.tally += this.Encoding.GetByteCount(value); - } + /// + /// Writes a character to the stream. + /// + /// + /// The character to write to the text stream. + /// + /// + /// is true or thebuffer is full, and current writer is closed. + /// + /// + /// is true or thebuffer is full, and the contents of the buffer cannot be written to the underlying fixed size stream because theis at the end the stream. + /// + /// + /// An I/O error occurs. + /// + /// 1 + public override void Write(char value) + { + base.Write(value); + Tally += Encoding.GetByteCount(new[] { value }); + } + + /// + /// Writes a character array to the stream. + /// + /// + /// A character array containing the data to write. If buffer is null, nothing is written. + /// + /// + /// is true or thebuffer is full, and current writer is closed. + /// + /// + /// is true or thebuffer is full, and the contents of the buffer cannot be written to the underlying fixed size stream because theis at the end the stream. + /// + /// + /// An I/O error occurs. + /// + /// 1 + public override void Write(char[] buffer) + { + base.Write(buffer); + Tally += Encoding.GetByteCount(buffer); + } + + /// + /// Writes an array of characters to the stream. + /// + /// + /// A character array containing the data to write. + /// + /// + /// The index into buffer at which to begin writing. + /// + /// + /// The number of characters to read from buffer. + /// + /// + /// An I/O error occurs. + /// + /// + /// is true or thebuffer is full, and current writer is closed. + /// + /// + /// is true or thebuffer is full, and the contents of the buffer cannot be written to the underlying fixed size stream because theis at the end the stream. + /// + /// + /// index or count is negative. + /// + /// + /// The buffer length minus index is less than count. + /// + /// + /// buffer is null. + /// + /// 1 + public override void Write(char[] buffer, int index, int count) + { + base.Write(buffer, index, count); + Tally += Encoding.GetByteCount(buffer, index, count); + } + + /// + /// Writes a string to the stream. + /// + /// + /// The string to write to the stream. If value is null, nothing is written. + /// + /// + /// is true or thebuffer is full, and current writer is closed. + /// + /// + /// is true or thebuffer is full, and the contents of the buffer cannot be written to the underlying fixed size stream because theis at the end the stream. + /// + /// + /// An I/O error occurs. + /// + /// 1 + public override void Write(string value) + { + base.Write(value); + Tally += Encoding.GetByteCount(value); } } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Interfaces/Tracing/IPlatformEqtTrace.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Interfaces/Tracing/IPlatformEqtTrace.cs index 446d7f9966..53fac83ea1 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Interfaces/Tracing/IPlatformEqtTrace.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Interfaces/Tracing/IPlatformEqtTrace.cs @@ -3,29 +3,28 @@ #if NETFRAMEWORK -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; - using System.Diagnostics; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.Diagnostics; - public partial interface IPlatformEqtTrace - { - /// - /// Setup remote trace listener in the child domain. - /// If calling domain, doesn't have tracing enabled nothing is done. - /// - /// Child AppDomain. - void SetupRemoteEqtTraceListeners(AppDomain childDomain); +public partial interface IPlatformEqtTrace +{ + /// + /// Setup remote trace listener in the child domain. + /// If calling domain, doesn't have tracing enabled nothing is done. + /// + /// Child AppDomain. + void SetupRemoteEqtTraceListeners(AppDomain childDomain); - /// - /// Setup a custom trace listener instead of default trace listener created by test platform. - /// This is needed by DTA Agent where it needs to listen test platform traces but doesn't use test platform listener. - /// - /// - /// The listener. - /// - void SetupListener(TraceListener listener); - } + /// + /// Setup a custom trace listener instead of default trace listener created by test platform. + /// This is needed by DTA Agent where it needs to listen test platform traces but doesn't use test platform listener. + /// + /// + /// The listener. + /// + void SetupListener(TraceListener listener); } #endif diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Runtime/PlatformAssemblyExtensions.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Runtime/PlatformAssemblyExtensions.cs index 764f020ba2..db646dd167 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Runtime/PlatformAssemblyExtensions.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Runtime/PlatformAssemblyExtensions.cs @@ -3,24 +3,23 @@ #if NETFRAMEWORK || NETSTANDARD2_0 -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System.Reflection; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System.Reflection; +/// +/// Assembly Extensions +/// +public static class PlatformAssemblyExtensions +{ /// - /// Assembly Extensions + /// Get current assembly location as per current platform /// - public static class PlatformAssemblyExtensions + /// Assembly + /// Returns Assembly location as per platform + public static string GetAssemblyLocation(this Assembly assembly) { - /// - /// Get current assembly location as per current platform - /// - /// Assembly - /// Returns Assembly location as per platform - public static string GetAssemblyLocation(this Assembly assembly) - { - return assembly.Location; - } + return assembly.Location; } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Runtime/PlatformAssemblyLoadContext.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Runtime/PlatformAssemblyLoadContext.cs index ab1e63f3ce..d72230e774 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Runtime/PlatformAssemblyLoadContext.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Runtime/PlatformAssemblyLoadContext.cs @@ -3,25 +3,24 @@ #if NETFRAMEWORK || NETSTANDARD2_0 -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System.Reflection; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System.Reflection; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Interfaces; +/// +public class PlatformAssemblyLoadContext : IAssemblyLoadContext +{ /// - public class PlatformAssemblyLoadContext : IAssemblyLoadContext + public AssemblyName GetAssemblyNameFromPath(string assemblyPath) { - /// - public AssemblyName GetAssemblyNameFromPath(string assemblyPath) - { - return AssemblyName.GetAssemblyName(assemblyPath); - } + return AssemblyName.GetAssemblyName(assemblyPath); + } - public Assembly LoadAssemblyFromPath(string assemblyPath) - { - return Assembly.LoadFrom(assemblyPath); - } + public Assembly LoadAssemblyFromPath(string assemblyPath) + { + return Assembly.LoadFrom(assemblyPath); } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Runtime/PlatformAssemblyResolver.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Runtime/PlatformAssemblyResolver.cs index 359ed112b2..7d15faa6a4 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Runtime/PlatformAssemblyResolver.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Runtime/PlatformAssemblyResolver.cs @@ -3,80 +3,75 @@ #if NETFRAMEWORK || NETSTANDARD2_0 -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System; - using System.Reflection; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using System; +using System.Reflection; - /// - public class PlatformAssemblyResolver : IAssemblyResolver - { - /// - /// Specifies whether the resolver is disposed or not - /// - private bool disposed; +using Interfaces; - /// - /// Initializes a new instance of the class. - /// - public PlatformAssemblyResolver() - { - AppDomain.CurrentDomain.AssemblyResolve += this.AssemblyResolverEvent; - } +/// +public class PlatformAssemblyResolver : IAssemblyResolver +{ + /// + /// Specifies whether the resolver is disposed or not + /// + private bool _disposed; - ~PlatformAssemblyResolver() - { - this.Dispose(false); - } + /// + /// Initializes a new instance of the class. + /// + public PlatformAssemblyResolver() + { + AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolverEvent; + } - /// - public event AssemblyResolveEventHandler AssemblyResolve; + ~PlatformAssemblyResolver() + { + Dispose(false); + } - public void Dispose() - { - this.Dispose(true); + /// + public event AssemblyResolveEventHandler AssemblyResolve; - // Use SupressFinalize in case a subclass - // of this type implements a finalizer. - GC.SuppressFinalize(this); - } + public void Dispose() + { + Dispose(true); - protected void Dispose(bool disposing) + // Use SupressFinalize in case a subclass + // of this type implements a finalizer. + GC.SuppressFinalize(this); + } + + protected void Dispose(bool disposing) + { + if (!_disposed) { - if (!this.disposed) + if (disposing) { - if (disposing) - { - AppDomain.CurrentDomain.AssemblyResolve -= this.AssemblyResolverEvent; - } - - this.disposed = true; + AppDomain.CurrentDomain.AssemblyResolve -= AssemblyResolverEvent; } - } - - /// - /// Assembly Resolve event handler for App Domain - called when CLR loader cannot resolve assembly. - /// - /// - /// The sender. - /// - /// - /// The event Args. - /// - /// - /// The . - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Justification")] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods", MessageId = "System.Reflection.Assembly.LoadFrom", Justification = "Justification")] - private Assembly AssemblyResolverEvent(object sender, object eventArgs) - { - ResolveEventArgs args = eventArgs as ResolveEventArgs; - return args == null ? null : this.AssemblyResolve(this, new AssemblyResolveEventArgs(args.Name)); + _disposed = true; } } + + /// + /// Assembly Resolve event handler for App Domain - called when CLR loader cannot resolve assembly. + /// + /// + /// The sender. + /// + /// + /// The event Args. + /// + /// + /// The . + /// + private Assembly AssemblyResolverEvent(object sender, object eventArgs) + { + return eventArgs is not ResolveEventArgs args ? null : AssemblyResolve(this, new AssemblyResolveEventArgs(args.Name)); + } } #endif diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/System/PlatformEnvironment.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/System/PlatformEnvironment.cs index be6fc31982..ba32edce04 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/System/PlatformEnvironment.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/System/PlatformEnvironment.cs @@ -3,67 +3,61 @@ #if NETFRAMEWORK || NETSTANDARD2_0 -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System; - using System.Threading; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System; +using System.Threading; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Interfaces; +/// +public class PlatformEnvironment : IEnvironment +{ /// - public class PlatformEnvironment : IEnvironment + public PlatformArchitecture Architecture { - /// - public PlatformArchitecture Architecture + get { - get - { - // On Mono System.Runtime.InteropServices.RuntimeInformation breaks - // See https://github.com/dotnet/corefx/issues/15112 - // Support just x86 and x64 for now, likely our solution for ARM is going to be - // netcore based. - return Environment.Is64BitOperatingSystem ? PlatformArchitecture.X64 : PlatformArchitecture.X86; - } + // On Mono System.Runtime.InteropServices.RuntimeInformation breaks + // See https://github.com/dotnet/corefx/issues/15112 + // Support just x86 and x64 for now, likely our solution for ARM is going to be + // netcore based. + return Environment.Is64BitOperatingSystem ? PlatformArchitecture.X64 : PlatformArchitecture.X86; } + } - /// - public PlatformOperatingSystem OperatingSystem + /// + public PlatformOperatingSystem OperatingSystem + { + get { - get - { - // Ensure the value is detected appropriately for Desktop CLR, Mono CLR 1.x and Mono - // CLR 2.x. See below link for more information: - // http://www.mono-project.com/docs/faq/technical/#how-to-detect-the-execution-platform - int p = (int)System.Environment.OSVersion.Platform; - if ((p == 4) || (p == 6) || (p == 128)) - { - return PlatformOperatingSystem.Unix; - } - - return PlatformOperatingSystem.Windows; - } + // Ensure the value is detected appropriately for Desktop CLR, Mono CLR 1.x and Mono + // CLR 2.x. See below link for more information: + // http://www.mono-project.com/docs/faq/technical/#how-to-detect-the-execution-platform + int p = (int)Environment.OSVersion.Platform; + return (p == 4) || (p == 6) || (p == 128) ? PlatformOperatingSystem.Unix : PlatformOperatingSystem.Windows; } + } - /// - public string OperatingSystemVersion + /// + public string OperatingSystemVersion + { + get { - get - { - return System.Environment.OSVersion.ToString(); - } + return Environment.OSVersion.ToString(); } + } - /// - public void Exit(int exitcode) - { - Environment.Exit(exitcode); - } + /// + public void Exit(int exitcode) + { + Environment.Exit(exitcode); + } - /// - public int GetCurrentManagedThreadId() - { - return Thread.CurrentThread.ManagedThreadId; - } + /// + public int GetCurrentManagedThreadId() + { + return Thread.CurrentThread.ManagedThreadId; } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/System/PlatformThread.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/System/PlatformThread.cs index f03199043a..adb8cdaaa3 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/System/PlatformThread.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/System/PlatformThread.cs @@ -3,49 +3,48 @@ #if NETFRAMEWORK || NETSTANDARD2_0 -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System; - using System.Runtime.ExceptionServices; - using System.Threading; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System; +using System.Runtime.ExceptionServices; +using System.Threading; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Interfaces; - public class PlatformThread : IThread +public class PlatformThread : IThread +{ + /// + public void Run(Action action, PlatformApartmentState apartmentState, bool waitForCompletion) { - /// - public void Run(Action action, PlatformApartmentState apartmentState, bool waitForCompletion) + if (action == null) + { + return; + } + + Exception exThrown = null; + var thread = new Thread(() => { - if (action == null) + try { - return; + action(); } - - Exception exThrown = null; - var thread = new System.Threading.Thread(() => + catch (Exception e) { - try - { - action(); - } - catch (Exception e) - { - exThrown = e; - } - }); - - ApartmentState state = Enum.TryParse(apartmentState.ToString(), out state) ? state : ApartmentState.MTA; - thread.SetApartmentState(state); - thread.IsBackground = true; - thread.Start(); - if (waitForCompletion) + exThrown = e; + } + }); + + ApartmentState state = Enum.TryParse(apartmentState.ToString(), out state) ? state : ApartmentState.MTA; + thread.SetApartmentState(state); + thread.IsBackground = true; + thread.Start(); + if (waitForCompletion) + { + thread.Join(); + if (exThrown != null) { - thread.Join(); - if (exThrown != null) - { - // Preserve the stacktrace when re-throwing the exception. - ExceptionDispatchInfo.Capture(exThrown).Throw(); - } + // Preserve the stacktrace when re-throwing the exception. + ExceptionDispatchInfo.Capture(exThrown).Throw(); } } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/System/ProcessHelper.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/System/ProcessHelper.cs index bbe8abb06d..30267e5cdf 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/System/ProcessHelper.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/System/ProcessHelper.cs @@ -3,37 +3,31 @@ #if NETFRAMEWORK || NETSTANDARD2_0 -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System; +using System.Diagnostics; +using System.IO; + +using Interfaces; + +public partial class ProcessHelper : IProcessHelper { - using System; - using System.Diagnostics; - using System.IO; + /// + public string GetCurrentProcessLocation() + { + return Path.GetDirectoryName(GetCurrentProcessFileName()); + } - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; + public IntPtr GetProcessHandle(int processId) + { + return Process.GetProcessById(processId).Handle; + } - public partial class ProcessHelper : IProcessHelper + /// + public PlatformArchitecture GetCurrentProcessArchitecture() { - /// - public string GetCurrentProcessLocation() - { - return Path.GetDirectoryName(this.GetCurrentProcessFileName()); - } - - public IntPtr GetProcessHandle(int processId) - { - return Process.GetProcessById(processId).Handle; - } - - /// - public PlatformArchitecture GetCurrentProcessArchitecture() - { - if (IntPtr.Size == 8) - { - return PlatformArchitecture.X64; - } - - return PlatformArchitecture.X86; - } + return IntPtr.Size == 8 ? PlatformArchitecture.X64 : PlatformArchitecture.X86; } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/System/ProcessStartInfoExtensions.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/System/ProcessStartInfoExtensions.cs index e0b3b47169..d188a758bc 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/System/ProcessStartInfoExtensions.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/System/ProcessStartInfoExtensions.cs @@ -3,22 +3,21 @@ #if NETFRAMEWORK || NETSTANDARD2_0 -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System.Diagnostics; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System.Diagnostics; - public static class ProcessStartInfoExtensions +public static class ProcessStartInfoExtensions +{ + /// + /// Add environment variable that apply to this process and child processes. + /// + /// The process start info + /// Environment Variable name. + /// Environment Variable value. + public static void AddEnvironmentVariable(this ProcessStartInfo startInfo, string name, string value) { - /// - /// Add environment variable that apply to this process and child processes. - /// - /// The process start info - /// Environment Variable name. - /// Environment Variable value. - public static void AddEnvironmentVariable(this ProcessStartInfo startInfo, string name, string value) - { - startInfo.EnvironmentVariables[name] = value; - } + startInfo.EnvironmentVariables[name] = value; } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Tracing/PlatformEqtTrace.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Tracing/PlatformEqtTrace.cs index ab24a8a303..58b63d9535 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Tracing/PlatformEqtTrace.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Tracing/PlatformEqtTrace.cs @@ -3,76 +3,75 @@ #if NETFRAMEWORK -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; - using System.Diagnostics; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.Diagnostics; +/// +/// Wrapper class for tracing. +/// - Shortcut-methods for Error, Warning, Info, Verbose. +/// - Adds additional information to the trace: calling process name, PID, ThreadID, Time. +/// - Uses custom switch EqtTraceLevel from .config file. +/// - By default tracing if OFF. +/// - Our build environment always sets the /d:TRACE so this class is always enabled, +/// the Debug class is enabled only in debug builds (/d:DEBUG). +/// - We ignore exceptions thrown by underlying TraceSwitch (e.g. due to config file error). +/// We log ignored exceptions to system Application log. +/// We pass through exceptions thrown due to incorrect arguments to EqtTrace methods. +/// Usage: EqtTrace.Info("Here's how to trace info"); +/// +public partial class PlatformEqtTrace : IPlatformEqtTrace +{ /// - /// Wrapper class for tracing. - /// - Shortcut-methods for Error, Warning, Info, Verbose. - /// - Adds additional information to the trace: calling process name, PID, ThreadID, Time. - /// - Uses custom switch EqtTraceLevel from .config file. - /// - By default tracing if OFF. - /// - Our build environment always sets the /d:TRACE so this class is always enabled, - /// the Debug class is enabled only in debug builds (/d:DEBUG). - /// - We ignore exceptions thrown by underlying TraceSwitch (e.g. due to config file error). - /// We log ignored exceptions to system Application log. - /// We pass through exceptions thrown due to incorrect arguments to EqtTrace methods. - /// Usage: EqtTrace.Info("Here's how to trace info"); + /// Setup remote trace listener in the child domain. + /// If calling domain, doesn't have tracing enabled nothing is done. /// - public partial class PlatformEqtTrace : IPlatformEqtTrace + /// Child AppDomain. + public void SetupRemoteEqtTraceListeners(AppDomain childDomain) { - /// - /// Setup remote trace listener in the child domain. - /// If calling domain, doesn't have tracing enabled nothing is done. - /// - /// Child AppDomain. - public void SetupRemoteEqtTraceListeners(AppDomain childDomain) + Debug.Assert(childDomain != null, "domain"); + if (childDomain != null) { - Debug.Assert(childDomain != null, "domain"); - if (childDomain != null) + RemoteEqtTrace remoteEqtTrace = (RemoteEqtTrace)childDomain.CreateInstanceFromAndUnwrap( + typeof(RemoteEqtTrace).Assembly.Location, + typeof(RemoteEqtTrace).FullName); + + if (!Equals(TraceLevel, TraceLevel.Off)) { - RemoteEqtTrace remoteEqtTrace = (RemoteEqtTrace)childDomain.CreateInstanceFromAndUnwrap( - typeof(RemoteEqtTrace).Assembly.Location, - typeof(RemoteEqtTrace).FullName); + remoteEqtTrace.TraceLevel = TraceLevel; - if (!Enum.Equals(TraceLevel, TraceLevel.Off)) + TraceListener tptListner = null; + foreach (TraceListener listener in Trace.Listeners) { - remoteEqtTrace.TraceLevel = TraceLevel; - - TraceListener tptListner = null; - foreach (TraceListener listener in Trace.Listeners) + if (string.Equals(listener.Name, ListenerName, StringComparison.OrdinalIgnoreCase)) { - if (string.Equals(listener.Name, ListenerName, StringComparison.OrdinalIgnoreCase)) - { - Debug.Assert(tptListner == null, "Multiple TptListeners found."); - tptListner = listener; - } + Debug.Assert(tptListner == null, "Multiple TptListeners found."); + tptListner = listener; } - - remoteEqtTrace.SetupRemoteListeners(tptListner); - } - else - { - this.DoNotInitialize = true; } + + remoteEqtTrace.SetupRemoteListeners(tptListner); + } + else + { + DoNotInitialize = true; } } + } - /// - public void SetupListener(TraceListener listener) + /// + public void SetupListener(TraceListener listener) + { + lock (IsInitializationLock) { - lock (isInitializationLock) + // Add new listeners. + if (listener != null) { - // Add new listeners. - if (listener != null) - { - Source.Listeners.Add(listener); - } - - isInitialized = true; + Source.Listeners.Add(listener); } + + s_isInitialized = true; } } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Tracing/RemoteEqtTrace.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Tracing/RemoteEqtTrace.cs index fa0ce155bb..00e34f8a42 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Tracing/RemoteEqtTrace.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/net451/Tracing/RemoteEqtTrace.cs @@ -3,43 +3,40 @@ #if NETFRAMEWORK -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel -{ - using System; - using System.Diagnostics; - using System.Diagnostics.CodeAnalysis; +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.Diagnostics; +/// +/// A class used to expose EqtTrace functionality across AppDomains. +/// +public sealed class RemoteEqtTrace : MarshalByRefObject +{ /// - /// A class used to expose EqtTrace functionality across AppDomains. + /// Gets or sets the trace level. /// - public sealed class RemoteEqtTrace : MarshalByRefObject + public TraceLevel TraceLevel { - /// - /// Gets or sets the trace level. - /// - public TraceLevel TraceLevel + get { - get - { - return PlatformEqtTrace.TraceLevel; - } - - set - { - PlatformEqtTrace.TraceLevel = value; - } + return PlatformEqtTrace.TraceLevel; } - /// - /// Register listeners from parent domain in current domain. - /// - /// Trace listener instance. - [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "Used in remote objects.")] - internal void SetupRemoteListeners(TraceListener listener) + set { - PlatformEqtTrace.SetupRemoteListeners(listener); + PlatformEqtTrace.TraceLevel = value; } } + + /// + /// Register listeners from parent domain in current domain. + /// + /// Trace listener instance. + internal void SetupRemoteListeners(TraceListener listener) + { + PlatformEqtTrace.SetupRemoteListeners(listener); + } } #endif diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/Runtime/PlatformAssemblyExtensions.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/Runtime/PlatformAssemblyExtensions.cs index fd8a665908..6b19f3b55f 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/Runtime/PlatformAssemblyExtensions.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/Runtime/PlatformAssemblyExtensions.cs @@ -3,24 +3,23 @@ #if NETCOREAPP -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System.Reflection; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System.Reflection; +/// +/// Assembly Extensions +/// +public static class PlatformAssemblyExtensions +{ /// - /// Assembly Extensions + /// Get current assembly location as per current platform /// - public static class PlatformAssemblyExtensions + /// Assembly + /// Returns Assembly location as per platform + public static string GetAssemblyLocation(this Assembly assembly) { - /// - /// Get current assembly location as per current platform - /// - /// Assembly - /// Returns Assembly location as per platform - public static string GetAssemblyLocation(this Assembly assembly) - { - return assembly.Location; - } + return assembly.Location; } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/Runtime/PlatformAssemblyLoadContext.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/Runtime/PlatformAssemblyLoadContext.cs index e364274b1b..4d8eccc6f3 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/Runtime/PlatformAssemblyLoadContext.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/Runtime/PlatformAssemblyLoadContext.cs @@ -3,26 +3,25 @@ #if NETCOREAPP -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System.Reflection; - using System.Runtime.Loader; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System.Reflection; +using System.Runtime.Loader; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Interfaces; +/// +public class PlatformAssemblyLoadContext : IAssemblyLoadContext +{ /// - public class PlatformAssemblyLoadContext : IAssemblyLoadContext + public AssemblyName GetAssemblyNameFromPath(string assemblyPath) { - /// - public AssemblyName GetAssemblyNameFromPath(string assemblyPath) - { - return AssemblyLoadContext.GetAssemblyName(assemblyPath); - } + return AssemblyLoadContext.GetAssemblyName(assemblyPath); + } - public Assembly LoadAssemblyFromPath(string assemblyPath) - { - return AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyPath); - } + public Assembly LoadAssemblyFromPath(string assemblyPath) + { + return AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyPath); } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/Runtime/PlatformAssemblyResolver.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/Runtime/PlatformAssemblyResolver.cs index cf530b492c..89ef5b5142 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/Runtime/PlatformAssemblyResolver.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/Runtime/PlatformAssemblyResolver.cs @@ -3,81 +3,77 @@ #if NETCOREAPP -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System; +using System.Reflection; +using System.Runtime.Loader; + +using Interfaces; + +/// +public class PlatformAssemblyResolver : IAssemblyResolver { - using System; - using System.Reflection; - using System.Runtime.Loader; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; + /// + /// Specifies whether the resolver is disposed or not + /// + private bool _disposed; - /// - public class PlatformAssemblyResolver : IAssemblyResolver + /// + /// Initializes a new instance of the class. + /// + /// The search directories. + public PlatformAssemblyResolver() { - /// - /// Specifies whether the resolver is disposed or not - /// - private bool disposed; - - /// - /// Initializes a new instance of the class. - /// - /// The search directories. - public PlatformAssemblyResolver() - { - AssemblyLoadContext.Default.Resolving += this.AssemblyResolverEvent; - } + AssemblyLoadContext.Default.Resolving += AssemblyResolverEvent; + } - ~PlatformAssemblyResolver() - { - this.Dispose(false); - } + ~PlatformAssemblyResolver() + { + Dispose(false); + } - /// - public event AssemblyResolveEventHandler AssemblyResolve; + /// + public event AssemblyResolveEventHandler AssemblyResolve; - public void Dispose() - { - this.Dispose(true); + public void Dispose() + { + Dispose(true); - // Use SupressFinalize in case a subclass - // of this type implements a finalizer. - GC.SuppressFinalize(this); - } + // Use SupressFinalize in case a subclass + // of this type implements a finalizer. + GC.SuppressFinalize(this); + } - protected void Dispose(bool disposing) + protected void Dispose(bool disposing) + { + if (!_disposed) { - if (!this.disposed) + if (disposing) { - if (disposing) - { - AssemblyLoadContext.Default.Resolving -= this.AssemblyResolverEvent; - } - - this.disposed = true; + AssemblyLoadContext.Default.Resolving -= AssemblyResolverEvent; } - } - - /// - /// Assembly Resolve event handler for App Domain - called when CLR loader cannot resolve assembly. - /// - /// - /// The sender. - /// - /// - /// The event Args. - /// - /// - /// The . - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "")] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods", MessageId = "System.Reflection.Assembly.LoadFrom", Justification = "")] - private Assembly AssemblyResolverEvent(object sender, object eventArgs) - { - AssemblyName args = eventArgs as AssemblyName; - return args == null ? null : this.AssemblyResolve(this, new AssemblyResolveEventArgs(args.Name)); + _disposed = true; } } + + /// + /// Assembly Resolve event handler for App Domain - called when CLR loader cannot resolve assembly. + /// + /// + /// The sender. + /// + /// + /// The event Args. + /// + /// + /// The . + /// + private Assembly AssemblyResolverEvent(object sender, object eventArgs) + { + return eventArgs is not AssemblyName args ? null : AssemblyResolve(this, new AssemblyResolveEventArgs(args.Name)); + } } #endif diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/System/PlatformEnvironment.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/System/PlatformEnvironment.cs index e96c3aaf9b..60bf675e34 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/System/PlatformEnvironment.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/System/PlatformEnvironment.cs @@ -3,82 +3,77 @@ #if NETCOREAPP -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System; - using System.Runtime.InteropServices; - using System.Threading; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System; +using System.Runtime.InteropServices; +using System.Threading; +using Interfaces; + +/// +public class PlatformEnvironment : IEnvironment +{ /// - public class PlatformEnvironment : IEnvironment + public PlatformArchitecture Architecture { - /// - public PlatformArchitecture Architecture + get { - get + switch (RuntimeInformation.OSArchitecture) { - switch (RuntimeInformation.OSArchitecture) - { - case System.Runtime.InteropServices.Architecture.X86: - return PlatformArchitecture.X86; - case System.Runtime.InteropServices.Architecture.X64: - return PlatformArchitecture.X64; - case System.Runtime.InteropServices.Architecture.Arm: - return PlatformArchitecture.ARM; - case System.Runtime.InteropServices.Architecture.Arm64: - return PlatformArchitecture.ARM64; + case System.Runtime.InteropServices.Architecture.X86: + return PlatformArchitecture.X86; + case System.Runtime.InteropServices.Architecture.X64: + return PlatformArchitecture.X64; + case System.Runtime.InteropServices.Architecture.Arm: + return PlatformArchitecture.ARM; + case System.Runtime.InteropServices.Architecture.Arm64: + return PlatformArchitecture.ARM64; - // The symbolic value is only available with .NET 6 - // preview 6 or later, so use the numerical value for now. - // case System.Runtime.InteropServices.Architecture.S390x: - case (Architecture)5: - return PlatformArchitecture.S390x; - default: - throw new NotSupportedException(); - } + // The symbolic value is only available with .NET 6 + // preview 6 or later, so use the numerical value for now. + // case System.Runtime.InteropServices.Architecture.S390x: + case (Architecture)5: + return PlatformArchitecture.S390x; + default: + throw new NotSupportedException(); } } + } - /// - public PlatformOperatingSystem OperatingSystem + /// + public PlatformOperatingSystem OperatingSystem + { + get { - get + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return PlatformOperatingSystem.Windows; - } - - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - return PlatformOperatingSystem.OSX; - } - - return PlatformOperatingSystem.Unix; + return PlatformOperatingSystem.Windows; } - } - /// - public string OperatingSystemVersion - { - get - { - return RuntimeInformation.OSDescription; - } + return RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? PlatformOperatingSystem.OSX : PlatformOperatingSystem.Unix; } + } - /// - public void Exit(int exitcode) + /// + public string OperatingSystemVersion + { + get { - Environment.Exit(exitcode); + return RuntimeInformation.OSDescription; } + } - /// - public int GetCurrentManagedThreadId() - { - return Thread.CurrentThread.ManagedThreadId; - } + /// + public void Exit(int exitcode) + { + Environment.Exit(exitcode); + } + + /// + public int GetCurrentManagedThreadId() + { + return Thread.CurrentThread.ManagedThreadId; } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/System/PlatformThread.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/System/PlatformThread.cs index 69e0416896..9d29c9dc20 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/System/PlatformThread.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/System/PlatformThread.cs @@ -3,52 +3,52 @@ #if NETCOREAPP -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System; - using System.Runtime.ExceptionServices; - using System.Threading; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System; +using System.Runtime.ExceptionServices; +using System.Threading; - public class PlatformThread : IThread +using Interfaces; + +public class PlatformThread : IThread +{ + /// + public void Run(Action action, PlatformApartmentState apartmentState, bool waitForCompletion) { - /// - public void Run(Action action, PlatformApartmentState apartmentState, bool waitForCompletion) + if (apartmentState == PlatformApartmentState.STA) + { + throw new ThreadApartmentStateNotSupportedException(); + } + + if (action == null) { - if (apartmentState == PlatformApartmentState.STA) + return; + } + + Exception exThrown = null; + var thread = new Thread(() => + { + try { - throw new ThreadApartmentStateNotSupportedException(); + action(); } - - if (action == null) + catch (Exception e) { - return; + exThrown = e; } + }); - Exception exThrown = null; - var thread = new Thread(() => - { - try - { - action(); - } - catch (Exception e) - { - exThrown = e; - } - }); - - // ApartmentState is not supported in netcoreapp1.0. - thread.IsBackground = true; - thread.Start(); - if (waitForCompletion) + // ApartmentState is not supported in netcoreapp1.0. + thread.IsBackground = true; + thread.Start(); + if (waitForCompletion) + { + thread.Join(); + if (exThrown != null) { - thread.Join(); - if (exThrown != null) - { - // Preserve the stacktrace when re-throwing the exception. - ExceptionDispatchInfo.Capture(exThrown).Throw(); - } + // Preserve the stacktrace when re-throwing the exception. + ExceptionDispatchInfo.Capture(exThrown).Throw(); } } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/System/ProcessHelper.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/System/ProcessHelper.cs index a952145341..38a17c64a6 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/System/ProcessHelper.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/System/ProcessHelper.cs @@ -3,52 +3,52 @@ #if NETCOREAPP -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System; +using System.Diagnostics; +using System.IO; +using System.Reflection; +using System.Runtime.InteropServices; + +using Interfaces; + +public partial class ProcessHelper : IProcessHelper { - using System; - using System.Diagnostics; - using System.IO; - using System.Reflection; - using System.Runtime.InteropServices; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - - public partial class ProcessHelper : IProcessHelper + /// + public string GetCurrentProcessLocation() { - /// - public string GetCurrentProcessLocation() - { - return Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); - } + return Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + } - /// - public IntPtr GetProcessHandle(int processId) - { - // An IntPtr representing the value of the handle field. - // If the handle has been marked invalid with SetHandleAsInvalid, this method still returns the original handle value, which can be a stale value. - return Process.GetProcessById(processId).SafeHandle.DangerousGetHandle(); - } + /// + public IntPtr GetProcessHandle(int processId) + { + // An IntPtr representing the value of the handle field. + // If the handle has been marked invalid with SetHandleAsInvalid, this method still returns the original handle value, which can be a stale value. + return Process.GetProcessById(processId).SafeHandle.DangerousGetHandle(); + } - public PlatformArchitecture GetCurrentProcessArchitecture() + public PlatformArchitecture GetCurrentProcessArchitecture() + { + switch (RuntimeInformation.ProcessArchitecture) { - switch (RuntimeInformation.ProcessArchitecture) - { - case Architecture.X86: - return PlatformArchitecture.X86; - case Architecture.X64: - return PlatformArchitecture.X64; - case Architecture.Arm: - return PlatformArchitecture.ARM; - case Architecture.Arm64: - return PlatformArchitecture.ARM64; - - // The symbolic value is only available with .NET 6 - // preview 6 or later, so use the numerical value for now. - // case System.Runtime.InteropServices.Architecture.S390x: - case (Architecture)5: - return PlatformArchitecture.S390x; - default: - throw new NotSupportedException(); - } + case Architecture.X86: + return PlatformArchitecture.X86; + case Architecture.X64: + return PlatformArchitecture.X64; + case Architecture.Arm: + return PlatformArchitecture.ARM; + case Architecture.Arm64: + return PlatformArchitecture.ARM64; + + // The symbolic value is only available with .NET 6 + // preview 6 or later, so use the numerical value for now. + // case System.Runtime.InteropServices.Architecture.S390x: + case (Architecture)5: + return PlatformArchitecture.S390x; + default: + throw new NotSupportedException(); } } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/System/ProcessStartInfoExtensions.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/System/ProcessStartInfoExtensions.cs index 51c821d981..50976a0a61 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/System/ProcessStartInfoExtensions.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/System/ProcessStartInfoExtensions.cs @@ -3,22 +3,21 @@ #if NETCOREAPP -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System.Diagnostics; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System.Diagnostics; - public static class ProcessStartInfoExtensions +public static class ProcessStartInfoExtensions +{ + /// + /// Add environment variable that apply to this process and child processes. + /// + /// The process start info + /// Environment Variable name. + /// Environment Variable value. + public static void AddEnvironmentVariable(this ProcessStartInfo startInfo, string name, string value) { - /// - /// Add environment variable that apply to this process and child processes. - /// - /// The process start info - /// Environment Variable name. - /// Environment Variable value. - public static void AddEnvironmentVariable(this ProcessStartInfo startInfo, string name, string value) - { - startInfo.Environment[name] = value; - } + startInfo.Environment[name] = value; } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/IO/PlatformStream.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/IO/PlatformStream.cs index b29af08dda..2d525386c2 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/IO/PlatformStream.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/IO/PlatformStream.cs @@ -3,20 +3,20 @@ #if NETSTANDARD && !NETSTANDARD2_0 -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System; - using System.IO; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System; +using System.IO; +using Interfaces; + +/// +public class PlatformStream : IStream +{ /// - public class PlatformStream : IStream + public Stream CreateBufferedStream(Stream stream, int bufferSize) { - /// - public Stream CreateBufferedStream(Stream stream, int bufferSize) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/Runtime/PlatformAssemblyExtensions.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/Runtime/PlatformAssemblyExtensions.cs index 86f514ff9d..b83e4e4875 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/Runtime/PlatformAssemblyExtensions.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/Runtime/PlatformAssemblyExtensions.cs @@ -3,17 +3,16 @@ #if NETSTANDARD && !NETSTANDARD2_0 -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System; - using System.Reflection; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System; +using System.Reflection; - public static class PlatformAssemblyExtensions +public static class PlatformAssemblyExtensions +{ + public static string GetAssemblyLocation(this Assembly assembly) { - public static string GetAssemblyLocation(this Assembly assembly) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/Runtime/PlatformAssemblyLoadContext.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/Runtime/PlatformAssemblyLoadContext.cs index 794d6c2782..9fa3015dab 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/Runtime/PlatformAssemblyLoadContext.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/Runtime/PlatformAssemblyLoadContext.cs @@ -3,25 +3,25 @@ #if NETSTANDARD && !NETSTANDARD2_0 -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System.Reflection; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System.Reflection; +using Interfaces; + +/// +public class PlatformAssemblyLoadContext : IAssemblyLoadContext +{ /// - public class PlatformAssemblyLoadContext : IAssemblyLoadContext + public AssemblyName GetAssemblyNameFromPath(string assemblyPath) { - /// - public AssemblyName GetAssemblyNameFromPath(string assemblyPath) - { - throw new System.NotImplementedException(); - } + throw new System.NotImplementedException(); + } - /// - public Assembly LoadAssemblyFromPath(string assemblyPath) - { - throw new System.NotImplementedException(); - } + /// + public Assembly LoadAssemblyFromPath(string assemblyPath) + { + throw new System.NotImplementedException(); } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/Runtime/PlatformAssemblyResolver.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/Runtime/PlatformAssemblyResolver.cs index 8e6bdfd9d2..301937ffed 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/Runtime/PlatformAssemblyResolver.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/Runtime/PlatformAssemblyResolver.cs @@ -3,31 +3,31 @@ #if NETSTANDARD && !NETSTANDARD2_0 -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System; + +using Interfaces; + +/// +public class PlatformAssemblyResolver : IAssemblyResolver { - using System; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; + public PlatformAssemblyResolver() + { + throw new NotImplementedException(); + } /// - public class PlatformAssemblyResolver : IAssemblyResolver + public event AssemblyResolveEventHandler AssemblyResolve; + + public void Dispose() + { + throw new NotImplementedException(); + } + + private void DummyEventThrower() { - public PlatformAssemblyResolver() - { - throw new NotImplementedException(); - } - - /// - public event AssemblyResolveEventHandler AssemblyResolve; - - public void Dispose() - { - throw new NotImplementedException(); - } - - private void DummyEventThrower() - { - this.AssemblyResolve(this, null); - } + AssemblyResolve(this, null); } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/System/PlatformEnvironment.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/System/PlatformEnvironment.cs index 85dba7ead8..d0eec7a4ef 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/System/PlatformEnvironment.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/System/PlatformEnvironment.cs @@ -3,53 +3,53 @@ #if NETSTANDARD && !NETSTANDARD2_0 -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - /// - public class PlatformEnvironment : IEnvironment - { - /// - public PlatformArchitecture Architecture - { - get - { - throw new NotImplementedException(); - } - } +using System; - /// - public PlatformOperatingSystem OperatingSystem - { - get - { - throw new NotImplementedException(); - } - } +using Interfaces; - /// - public string OperatingSystemVersion +/// +public class PlatformEnvironment : IEnvironment +{ + /// + public PlatformArchitecture Architecture + { + get { - get - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } + } - /// - public void Exit(int exitcode) + /// + public PlatformOperatingSystem OperatingSystem + { + get { throw new NotImplementedException(); } + } - /// - public int GetCurrentManagedThreadId() + /// + public string OperatingSystemVersion + { + get { throw new NotImplementedException(); } } + + /// + public void Exit(int exitcode) + { + throw new NotImplementedException(); + } + + /// + public int GetCurrentManagedThreadId() + { + throw new NotImplementedException(); + } } #endif diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/System/PlatformThread.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/System/PlatformThread.cs index 38c4968766..f3470348d4 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/System/PlatformThread.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/System/PlatformThread.cs @@ -3,19 +3,19 @@ #if NETSTANDARD && !NETSTANDARD2_0 -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System; +using Interfaces; + +/// +public class PlatformThread : IThread +{ /// - public class PlatformThread : IThread + public void Run(Action action, PlatformApartmentState platformApartmentState, bool waitForCompletion) { - /// - public void Run(Action action, PlatformApartmentState platformApartmentState, bool waitForCompletion) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/System/ProcessHelper.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/System/ProcessHelper.cs index 2d07d938eb..d257a063ee 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/System/ProcessHelper.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/System/ProcessHelper.cs @@ -3,111 +3,111 @@ #if NETSTANDARD && !NETSTANDARD2_0 -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System; +using System.Collections.Generic; + +using Interfaces; + +/// +/// Helper class to deal with process related functionality. +/// +public class ProcessHelper : IProcessHelper { - using System; - using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - - /// - /// Helper class to deal with process related functionality. - /// - public class ProcessHelper : IProcessHelper + /// + public object LaunchProcess( + string processPath, + string arguments, + string workingDirectory, + IDictionary environmentVariables, + Action errorCallback, + Action exitCallBack, + Action ouputCallBack) + { + throw new NotImplementedException(); + } + + /// + public string GetCurrentProcessFileName() + { + throw new NotImplementedException(); + } + + /// + public string GetCurrentProcessLocation() + { + throw new NotImplementedException(); + } + + /// + public string GetTestEngineDirectory() + { + throw new NotImplementedException(); + } + + /// + public int GetCurrentProcessId() + { + throw new NotImplementedException(); + } + + /// + public string GetProcessName(int processId) + { + throw new NotImplementedException(); + } + + /// + public bool TryGetExitCode(object process, out int exitCode) + { + throw new NotImplementedException(); + } + + /// + public void SetExitCallback(int parentProcessId, Action callbackAction) + { + throw new NotImplementedException(); + } + + /// + public void TerminateProcess(object process) + { + throw new NotImplementedException(); + } + + /// + public int GetProcessId(object process) + { + throw new NotImplementedException(); + } + + /// + public string GetNativeDllDirectory() + { + throw new NotImplementedException(); + } + + /// + public PlatformArchitecture GetCurrentProcessArchitecture() + { + throw new NotImplementedException(); + } + + /// + public void WaitForProcessExit(object process) + { + throw new NotImplementedException(); + } + + public IntPtr GetProcessHandle(int processId) + { + throw new NotImplementedException(); + } + + public object GetProcessById(int processId) { - /// - public object LaunchProcess( - string processPath, - string arguments, - string workingDirectory, - IDictionary environmentVariables, - Action errorCallback, - Action exitCallBack, - Action ouputCallBack) - { - throw new NotImplementedException(); - } - - /// - public string GetCurrentProcessFileName() - { - throw new NotImplementedException(); - } - - /// - public string GetCurrentProcessLocation() - { - throw new NotImplementedException(); - } - - /// - public string GetTestEngineDirectory() - { - throw new NotImplementedException(); - } - - /// - public int GetCurrentProcessId() - { - throw new NotImplementedException(); - } - - /// - public string GetProcessName(int processId) - { - throw new NotImplementedException(); - } - - /// - public bool TryGetExitCode(object process, out int exitCode) - { - throw new NotImplementedException(); - } - - /// - public void SetExitCallback(int parentProcessId, Action callbackAction) - { - throw new NotImplementedException(); - } - - /// - public void TerminateProcess(object process) - { - throw new NotImplementedException(); - } - - /// - public int GetProcessId(object process) - { - throw new NotImplementedException(); - } - - /// - public string GetNativeDllDirectory() - { - throw new NotImplementedException(); - } - - /// - public PlatformArchitecture GetCurrentProcessArchitecture() - { - throw new NotImplementedException(); - } - - /// - public void WaitForProcessExit(object process) - { - throw new NotImplementedException(); - } - - public IntPtr GetProcessHandle(int processId) - { - throw new NotImplementedException(); - } - - public object GetProcessById(int processId) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/Tracing/PlatformEqtTrace.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/Tracing/PlatformEqtTrace.cs index 8333c5c1ff..37544eeb21 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/Tracing/PlatformEqtTrace.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard/Tracing/PlatformEqtTrace.cs @@ -3,74 +3,68 @@ #if NETSTANDARD && !NETSTANDARD2_0 -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.Diagnostics; + +/// +/// Wrapper class for tracing. +/// - Shortcut-methods for Error, Warning, Info, Verbose. +/// - Adds additional information to the trace: calling process name, PID, ThreadID, Time. +/// - Uses custom switch EqtTraceLevel from .config file. +/// - By default tracing if OFF. +/// - Our build environment always sets the /d:TRACE so this class is always enabled, +/// the Debug class is enabled only in debug builds (/d:DEBUG). +/// - We ignore exceptions thrown by underlying TraceSwitch (e.g. due to config file error). +/// We log ignored exceptions to system Application log. +/// We pass through exceptions thrown due to incorrect arguments to EqtTrace methods. +/// Usage: EqtTrace.Info("Here's how to trace info"); +/// +public class PlatformEqtTrace : IPlatformEqtTrace { - using System; - using System.Diagnostics; - - /// - /// Wrapper class for tracing. - /// - Shortcut-methods for Error, Warning, Info, Verbose. - /// - Adds additional information to the trace: calling process name, PID, ThreadID, Time. - /// - Uses custom switch EqtTraceLevel from .config file. - /// - By default tracing if OFF. - /// - Our build environment always sets the /d:TRACE so this class is always enabled, - /// the Debug class is enabled only in debug builds (/d:DEBUG). - /// - We ignore exceptions thrown by underlying TraceSwitch (e.g. due to config file error). - /// We log ignored exceptions to system Application log. - /// We pass through exceptions thrown due to incorrect arguments to EqtTrace methods. - /// Usage: EqtTrace.Info("Here's how to trace info"); - /// - public class PlatformEqtTrace : IPlatformEqtTrace - { - private PlatformTraceLevel traceLevel = PlatformTraceLevel.Off; - - public static string ErrorOnInitialization { get; set; } - - public bool DoNotInitialize { get; set; } + private PlatformTraceLevel _traceLevel = PlatformTraceLevel.Off; - public void WriteLine(PlatformTraceLevel traceLevel, string message) - { - if (!this.ShouldTrace(traceLevel)) - { - return; - } + public static string ErrorOnInitialization { get; set; } - var level = Enum.GetName(typeof(PlatformTraceLevel), traceLevel); - Debug.WriteLine($"[{level}] {message}"); - } + public bool DoNotInitialize { get; set; } - public bool InitializeVerboseTrace(string customLogFile) + public void WriteLine(PlatformTraceLevel traceLevel, string message) + { + if (!ShouldTrace(traceLevel)) { - return false; + return; } - public bool InitializeTrace(string customLogFile, PlatformTraceLevel traceLevel) - { - this.traceLevel = traceLevel; + var level = Enum.GetName(typeof(PlatformTraceLevel), traceLevel); + Debug.WriteLine($"[{level}] {message}"); + } - return false; - } + public bool InitializeVerboseTrace(string customLogFile) + { + return false; + } - public bool ShouldTrace(PlatformTraceLevel traceLevel) - { - if (this.DoNotInitialize) - { - return false; - } + public bool InitializeTrace(string customLogFile, PlatformTraceLevel traceLevel) + { + _traceLevel = traceLevel; - return (int)this.traceLevel >= (int)traceLevel; - } + return false; + } - public string GetLogFile() => string.Empty; + public bool ShouldTrace(PlatformTraceLevel traceLevel) + { + return !DoNotInitialize && (int)_traceLevel >= (int)traceLevel; + } - public void SetTraceLevel(PlatformTraceLevel value) - { - this.traceLevel = value; - } + public string GetLogFile() => string.Empty; - public PlatformTraceLevel GetTraceLevel() => this.traceLevel; + public void SetTraceLevel(PlatformTraceLevel value) + { + _traceLevel = value; } + + public PlatformTraceLevel GetTraceLevel() => _traceLevel; } #endif diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/IO/PlatformStream.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/IO/PlatformStream.cs index 7ed4956de3..2b7d4e39c4 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/IO/PlatformStream.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/IO/PlatformStream.cs @@ -3,19 +3,19 @@ #if WINDOWS_UWP -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System.IO; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System.IO; +using Interfaces; + +/// +public class PlatformStream : IStream +{ /// - public class PlatformStream : IStream + public Stream CreateBufferedStream(Stream stream, int bufferSize) { - /// - public Stream CreateBufferedStream(Stream stream, int bufferSize) - { - return stream; - } + return stream; } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Runtime/PlatformAssemblyExtensions.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Runtime/PlatformAssemblyExtensions.cs index 71c6da95cc..06f3d74ad3 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Runtime/PlatformAssemblyExtensions.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Runtime/PlatformAssemblyExtensions.cs @@ -3,26 +3,25 @@ #if WINDOWS_UWP -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System.IO; - using System.Reflection; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System.IO; +using System.Reflection; +/// +/// Assembly Extensions +/// +public static class PlatformAssemblyExtensions +{ /// - /// Assembly Extensions + /// Get current assembly location as per current platform /// - public static class PlatformAssemblyExtensions + /// Assembly + /// Returns Assembly location as per platform + public static string GetAssemblyLocation(this Assembly assembly) { - /// - /// Get current assembly location as per current platform - /// - /// Assembly - /// Returns Assembly location as per platform - public static string GetAssemblyLocation(this Assembly assembly) - { - // In UWP all assemblies are packages inside Appx folder, so we return location of current directory - return Directory.GetCurrentDirectory(); - } + // In UWP all assemblies are packages inside Appx folder, so we return location of current directory + return Directory.GetCurrentDirectory(); } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Runtime/PlatformAssemblyLoadContext.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Runtime/PlatformAssemblyLoadContext.cs index e7858222f6..1676ca52c6 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Runtime/PlatformAssemblyLoadContext.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Runtime/PlatformAssemblyLoadContext.cs @@ -3,27 +3,27 @@ #if WINDOWS_UWP -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System.IO; - using System.Reflection; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System.IO; +using System.Reflection; +using Interfaces; + +/// +public class PlatformAssemblyLoadContext : IAssemblyLoadContext +{ /// - public class PlatformAssemblyLoadContext : IAssemblyLoadContext + public AssemblyName GetAssemblyNameFromPath(string assemblyPath) { - /// - public AssemblyName GetAssemblyNameFromPath(string assemblyPath) - { - string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(assemblyPath); - return new AssemblyName(fileNameWithoutExtension); - } + string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(assemblyPath); + return new AssemblyName(fileNameWithoutExtension); + } - /// - public Assembly LoadAssemblyFromPath(string assemblyPath) - { - return Assembly.Load(this.GetAssemblyNameFromPath(assemblyPath)); - } + /// + public Assembly LoadAssemblyFromPath(string assemblyPath) + { + return Assembly.Load(GetAssemblyNameFromPath(assemblyPath)); } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Runtime/PlatformAssemblyResolver.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Runtime/PlatformAssemblyResolver.cs index dfcf702806..30d50a6767 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Runtime/PlatformAssemblyResolver.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Runtime/PlatformAssemblyResolver.cs @@ -3,29 +3,28 @@ #if WINDOWS_UWP -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using Interfaces; + +/// +public class PlatformAssemblyResolver : IAssemblyResolver { - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; + public PlatformAssemblyResolver() + { + } /// - public class PlatformAssemblyResolver : IAssemblyResolver + public event AssemblyResolveEventHandler AssemblyResolve; + + public void Dispose() + { + } + + private void DummyEventThrower() { - public PlatformAssemblyResolver() - { - } - - /// - public event AssemblyResolveEventHandler AssemblyResolve; - - public void Dispose() - { - } - - private void DummyEventThrower() - { - // need to raise this event, else compiler throws error - this.AssemblyResolve(this, null); - } + // need to raise this event, else compiler throws error + AssemblyResolve(this, null); } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/System/PlatformEnvironment.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/System/PlatformEnvironment.cs index 3952010753..46632f199d 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/System/PlatformEnvironment.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/System/PlatformEnvironment.cs @@ -3,70 +3,65 @@ #if WINDOWS_UWP -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System; - using System.Runtime.InteropServices; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System; +using System.Runtime.InteropServices; +using Interfaces; + +/// +public class PlatformEnvironment : IEnvironment +{ /// - public class PlatformEnvironment : IEnvironment + public PlatformArchitecture Architecture { - /// - public PlatformArchitecture Architecture + get { - get + switch (RuntimeInformation.OSArchitecture) { - switch (RuntimeInformation.OSArchitecture) - { - case System.Runtime.InteropServices.Architecture.X86: - return PlatformArchitecture.X86; - case System.Runtime.InteropServices.Architecture.X64: - return PlatformArchitecture.X64; - case System.Runtime.InteropServices.Architecture.Arm: - return PlatformArchitecture.ARM; - case System.Runtime.InteropServices.Architecture.Arm64: - return PlatformArchitecture.ARM64; - default: - throw new NotSupportedException(); - } + case System.Runtime.InteropServices.Architecture.X86: + return PlatformArchitecture.X86; + case System.Runtime.InteropServices.Architecture.X64: + return PlatformArchitecture.X64; + case System.Runtime.InteropServices.Architecture.Arm: + return PlatformArchitecture.ARM; + case System.Runtime.InteropServices.Architecture.Arm64: + return PlatformArchitecture.ARM64; + default: + throw new NotSupportedException(); } } + } - /// - public PlatformOperatingSystem OperatingSystem + /// + public PlatformOperatingSystem OperatingSystem + { + get { - get - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return PlatformOperatingSystem.Windows; - } - - return PlatformOperatingSystem.Unix; - } + return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? PlatformOperatingSystem.Windows : PlatformOperatingSystem.Unix; } + } - /// - public string OperatingSystemVersion + /// + public string OperatingSystemVersion + { + get { - get - { - return RuntimeInformation.OSDescription; - } + return RuntimeInformation.OSDescription; } + } - /// - public void Exit(int exitcode) - { - Environment.FailFast("Process terminating with exit code: " + exitcode); - } + /// + public void Exit(int exitcode) + { + Environment.FailFast("Process terminating with exit code: " + exitcode); + } - /// - public int GetCurrentManagedThreadId() - { - return Environment.CurrentManagedThreadId; - } + /// + public int GetCurrentManagedThreadId() + { + return Environment.CurrentManagedThreadId; } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/System/PlatformThread.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/System/PlatformThread.cs index 5ceba42402..f0eff6ade3 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/System/PlatformThread.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/System/PlatformThread.cs @@ -3,32 +3,32 @@ #if WINDOWS_UWP -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions -{ - using System; - using System.Threading.Tasks; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System; +using System.Threading.Tasks; + +using Interfaces; - public class PlatformThread : IThread +public class PlatformThread : IThread +{ + /// + public void Run(Action action, PlatformApartmentState apartmentState, bool waitForCompletion) { - /// - public void Run(Action action, PlatformApartmentState apartmentState, bool waitForCompletion) + if (apartmentState == PlatformApartmentState.STA) + { + throw new ThreadApartmentStateNotSupportedException(); + } + + if (action == null) + { + return; + } + + Task task = Task.Run(action); + if (waitForCompletion) { - if (apartmentState == PlatformApartmentState.STA) - { - throw new ThreadApartmentStateNotSupportedException(); - } - - if (action == null) - { - return; - } - - Task task = Task.Run(action); - if (waitForCompletion) - { - task.Wait(); - } + task.Wait(); } } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/System/ProcessHelper.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/System/ProcessHelper.cs index d3fb928707..d11ac3e44b 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/System/ProcessHelper.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/System/ProcessHelper.cs @@ -3,117 +3,112 @@ #if WINDOWS_UWP -namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions +namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using System; +using System.Collections.Generic; +using System.IO; + +using Interfaces; + +/// +/// Helper class to deal with process related functionality. +/// +public partial class ProcessHelper : IProcessHelper { - using System; - using System.Collections.Generic; - using System.IO; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - - /// - /// Helper class to deal with process related functionality. - /// - public partial class ProcessHelper : IProcessHelper + /// + public object LaunchProcess( + string processPath, + string arguments, + string workingDirectory, + IDictionary environmentVariables, + Action errorCallback, + Action exitCallBack, + Action outputCallback) + { + throw new NotImplementedException(); + } + + /// + public string GetCurrentProcessFileName() + { + throw new NotImplementedException(); + } + + /// + public string GetCurrentProcessLocation() + { + return Directory.GetCurrentDirectory(); + } + + /// + public string GetTestEngineDirectory() + { + throw new NotImplementedException(); + } + + /// + public int GetCurrentProcessId() + { + return -1; + } + + /// + public string GetProcessName(int processId) + { + return string.Empty; + } + + /// + public bool TryGetExitCode(object process, out int exitCode) + { + throw new NotImplementedException(); + } + + /// + public void SetExitCallback(int parentProcessId, Action callbackAction) + { + } + + /// + public void TerminateProcess(object process) + { + throw new NotImplementedException(); + } + + /// + public int GetProcessId(object process) + { + return -1; + } + + /// + public PlatformArchitecture GetCurrentProcessArchitecture() + { + return IntPtr.Size == 8 ? PlatformArchitecture.X64 : PlatformArchitecture.X86; + } + + /// + public string GetNativeDllDirectory() + { + // For UWP the native dll's are to be kept in same directory + return GetCurrentProcessLocation(); + } + + /// + public void WaitForProcessExit(object process) + { + throw new NotImplementedException(); + } + + public IntPtr GetProcessHandle(int processId) + { + throw new NotImplementedException(); + } + + public object GetProcessById(int processId) { - /// - public object LaunchProcess( - string processPath, - string arguments, - string workingDirectory, - IDictionary environmentVariables, - Action errorCallback, - Action exitCallBack, - Action outputCallback) - { - throw new NotImplementedException(); - } - - /// - public string GetCurrentProcessFileName() - { - throw new NotImplementedException(); - } - - /// - public string GetCurrentProcessLocation() - { - return Directory.GetCurrentDirectory(); - } - - /// - public string GetTestEngineDirectory() - { - throw new NotImplementedException(); - } - - /// - public int GetCurrentProcessId() - { - return -1; - } - - /// - public string GetProcessName(int processId) - { - return string.Empty; - } - - /// - public bool TryGetExitCode(object process, out int exitCode) - { - throw new NotImplementedException(); - } - - /// - public void SetExitCallback(int parentProcessId, Action callbackAction) - { - } - - /// - public void TerminateProcess(object process) - { - throw new NotImplementedException(); - } - - /// - public int GetProcessId(object process) - { - return -1; - } - - /// - public PlatformArchitecture GetCurrentProcessArchitecture() - { - if (IntPtr.Size == 8) - { - return PlatformArchitecture.X64; - } - - return PlatformArchitecture.X86; - } - - /// - public string GetNativeDllDirectory() - { - // For UWP the native dll's are to be kept in same directory - return this.GetCurrentProcessLocation(); - } - - /// - public void WaitForProcessExit(object process) - { - throw new NotImplementedException(); - } - - public IntPtr GetProcessHandle(int processId) - { - throw new NotImplementedException(); - } - - public object GetProcessById(int processId) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Tracing/FileEventListener.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Tracing/FileEventListener.cs index 206a43dd05..ddcd05e7df 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Tracing/FileEventListener.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Tracing/FileEventListener.cs @@ -3,97 +3,96 @@ #if WINDOWS_UWP -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Diagnostics.Tracing; +using System.IO; +using System.Threading; +using System.Threading.Tasks; + +internal sealed class FileEventListener : EventListener { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Diagnostics.Tracing; - using System.IO; - using System.Threading; - using System.Threading.Tasks; - - internal sealed class FileEventListener : EventListener - { - /// - /// Storage file to be used to write logs - /// - private FileStream fileStream = null; + /// + /// Storage file to be used to write logs + /// + private FileStream _fileStream = null; - /// - /// StreamWriter to write logs to file - /// - private StreamWriter streamWriter = null; + /// + /// StreamWriter to write logs to file + /// + private StreamWriter _streamWriter = null; - /// - /// Name of the current log file - /// - private string fileName; + /// + /// Name of the current log file + /// + private readonly string _fileName; - /// - /// The format to be used by logging. - /// - private string format = "{0:yyyy-MM-dd HH\\:mm\\:ss\\:ffff}\tType: {1}\tId: {2}\tMessage: '{3}'"; + /// + /// The format to be used by logging. + /// + private readonly string _format = "{0:yyyy-MM-dd HH\\:mm\\:ss\\:ffff}\tType: {1}\tId: {2}\tMessage: '{3}'"; - private SemaphoreSlim semaphoreSlim = new SemaphoreSlim(1); + private readonly SemaphoreSlim _semaphoreSlim = new(1); - public FileEventListener(string name) - { - this.fileName = name; + public FileEventListener(string name) + { + _fileName = name; - this.AssignLocalFile(); - } + AssignLocalFile(); + } - protected override void OnEventWritten(EventWrittenEventArgs eventData) + protected override void OnEventWritten(EventWrittenEventArgs eventData) + { + if (_streamWriter == null) { - if (this.streamWriter == null) - { - return; - } + return; + } - var lines = new List(); + var lines = new List(); - var newFormatedLine = string.Format(this.format, DateTime.Now, eventData.Level, eventData.EventId, eventData.Payload[0]); + var newFormatedLine = string.Format(_format, DateTime.Now, eventData.Level, eventData.EventId, eventData.Payload[0]); - Debug.WriteLine(newFormatedLine); + Debug.WriteLine(newFormatedLine); - lines.Add(newFormatedLine); + lines.Add(newFormatedLine); - this.WriteToFile(lines); - } + WriteToFile(lines); + } - private void AssignLocalFile() + private void AssignLocalFile() + { + _fileStream = new FileStream(_fileName, FileMode.Append | FileMode.OpenOrCreate); + _streamWriter = new StreamWriter(_fileStream) { - this.fileStream = new FileStream(this.fileName, FileMode.Append | FileMode.OpenOrCreate); - this.streamWriter = new StreamWriter(this.fileStream) - { - AutoFlush = true - }; - } + AutoFlush = true + }; + } - private async void WriteToFile(IEnumerable lines) - { - await this.semaphoreSlim.WaitAsync(); + private async void WriteToFile(IEnumerable lines) + { + await _semaphoreSlim.WaitAsync(); - await Task.Run(async () => + await Task.Run(async () => + { + try { - try - { - foreach (var line in lines) - { - await this.streamWriter.WriteLineAsync(line); - } - } - catch (Exception) + foreach (var line in lines) { - // Ignore + await _streamWriter.WriteLineAsync(line); } - finally - { - this.semaphoreSlim.Release(); - } - }); - } + } + catch (Exception) + { + // Ignore + } + finally + { + _semaphoreSlim.Release(); + } + }); } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Tracing/PlatformEqtTrace.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Tracing/PlatformEqtTrace.cs index 15cd7306ce..bed6fc590d 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Tracing/PlatformEqtTrace.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Tracing/PlatformEqtTrace.cs @@ -3,181 +3,180 @@ #if WINDOWS_UWP -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System; +using System.Diagnostics.Tracing; +using System.IO; + +/// +/// Wrapper class for tracing. +/// - Shortcut-methods for Error, Warning, Info, Verbose. +/// - Adds additional information to the trace: calling process name, PID, ThreadID, Time. +/// - Uses custom switch EqtTraceLevel from .config file. +/// - By default tracing if OFF. +/// - Our build environment always sets the /d:TRACE so this class is always enabled, +/// the Debug class is enabled only in debug builds (/d:DEBUG). +/// - We ignore exceptions thrown by underlying TraceSwitch (e.g. due to config file error). +/// We log ignored exceptions to system Application log. +/// We pass through exceptions thrown due to incorrect arguments to EqtTrace methods. +/// Usage: EqtTrace.Info("Here's how to trace info"); +/// +public class PlatformEqtTrace : IPlatformEqtTrace { - using System; - using System.Diagnostics.Tracing; - using System.IO; + private static readonly object InitLock = new(); - /// - /// Wrapper class for tracing. - /// - Shortcut-methods for Error, Warning, Info, Verbose. - /// - Adds additional information to the trace: calling process name, PID, ThreadID, Time. - /// - Uses custom switch EqtTraceLevel from .config file. - /// - By default tracing if OFF. - /// - Our build environment always sets the /d:TRACE so this class is always enabled, - /// the Debug class is enabled only in debug builds (/d:DEBUG). - /// - We ignore exceptions thrown by underlying TraceSwitch (e.g. due to config file error). - /// We log ignored exceptions to system Application log. - /// We pass through exceptions thrown due to incorrect arguments to EqtTrace methods. - /// Usage: EqtTrace.Info("Here's how to trace info"); - /// - public class PlatformEqtTrace : IPlatformEqtTrace - { - private static object initLock = new object(); - - private static bool isInitialized = false; + private static bool s_isInitialized = false; - public static string ErrorOnInitialization { get; set; } + public static string ErrorOnInitialization { get; set; } - public static string LogFile { get; set; } + public static string LogFile { get; set; } - public bool DoNotInitialize - { - get; - set; - } + public bool DoNotInitialize + { + get; + set; + } - private static PlatformTraceLevel TraceLevel { get; set; } + private static PlatformTraceLevel TraceLevel { get; set; } - /// - public void WriteLine(PlatformTraceLevel level, string message) + /// + public void WriteLine(PlatformTraceLevel level, string message) + { + if (TraceInitialized() && TraceLevel > PlatformTraceLevel.Off) { - if (this.TraceInitialized() && TraceLevel > PlatformTraceLevel.Off) + switch (level) { - switch (level) - { - case PlatformTraceLevel.Off: - break; + case PlatformTraceLevel.Off: + break; - case PlatformTraceLevel.Error: - UnitTestEventSource.Log.Error(message); - break; + case PlatformTraceLevel.Error: + UnitTestEventSource.Log.Error(message); + break; - case PlatformTraceLevel.Warning: - UnitTestEventSource.Log.Warn(message); - break; + case PlatformTraceLevel.Warning: + UnitTestEventSource.Log.Warn(message); + break; - case PlatformTraceLevel.Info: - UnitTestEventSource.Log.Info(message); - break; + case PlatformTraceLevel.Info: + UnitTestEventSource.Log.Info(message); + break; - case PlatformTraceLevel.Verbose: - UnitTestEventSource.Log.Verbose(message); - break; - } + case PlatformTraceLevel.Verbose: + UnitTestEventSource.Log.Verbose(message); + break; } } + } + + /// + public bool InitializeVerboseTrace(string customLogFile) + { + return InitializeTrace(customLogFile, PlatformTraceLevel.Verbose); + } - /// - public bool InitializeVerboseTrace(string customLogFile) + /// + public bool InitializeTrace(string customLogFile, PlatformTraceLevel traceLevel) + { + string logFileName; + try { - return this.InitializeTrace(customLogFile, PlatformTraceLevel.Verbose); + logFileName = Path.GetFileNameWithoutExtension(customLogFile.TrimStart('"').TrimEnd('"')).Replace(" ", "_"); } - - /// - public bool InitializeTrace(string customLogFile, PlatformTraceLevel traceLevel) + catch { - string logFileName = string.Empty; - try - { - logFileName = Path.GetFileNameWithoutExtension(customLogFile.TrimStart('"').TrimEnd('"')).Replace(" ", "_"); - } - catch - { - logFileName = Guid.NewGuid().ToString(); - } + logFileName = Guid.NewGuid().ToString(); + } - LogFile = Path.Combine(Path.GetTempPath(), logFileName + ".TpTrace.log"); - TraceLevel = traceLevel; + LogFile = Path.Combine(Path.GetTempPath(), logFileName + ".TpTrace.log"); + TraceLevel = traceLevel; - return this.TraceInitialized(); - } + return TraceInitialized(); + } - /// - public bool ShouldTrace(PlatformTraceLevel traceLevel) - { - return isInitialized; - } + /// + public bool ShouldTrace(PlatformTraceLevel traceLevel) + { + return s_isInitialized; + } - /// - public string GetLogFile() - { - return LogFile; - } + /// + public string GetLogFile() + { + return LogFile; + } - /// - public void SetTraceLevel(PlatformTraceLevel value) - { - TraceLevel = value; - } + /// + public void SetTraceLevel(PlatformTraceLevel value) + { + TraceLevel = value; + } - /// - public PlatformTraceLevel GetTraceLevel() - { - return TraceLevel; - } + /// + public PlatformTraceLevel GetTraceLevel() + { + return TraceLevel; + } - /// - /// Initializes Tracing based on Trace Level - /// - /// - /// The . - /// - private bool TraceInitialized() + /// + /// Initializes Tracing based on Trace Level + /// + /// + /// The . + /// + private bool TraceInitialized() + { + lock (InitLock) { - lock (initLock) + if (s_isInitialized) + { + return s_isInitialized; + } + + try { - if (isInitialized) + var eventListener = new FileEventListener(string.IsNullOrEmpty(LogFile) ? "UnitTestLog" : LogFile); + + PlatformTraceLevel traceLevel = GetTraceLevel(); + if (traceLevel > PlatformTraceLevel.Off) { - return isInitialized; + eventListener.EnableEvents(UnitTestEventSource.Log, EventLevel.Error); } - try + if (traceLevel > PlatformTraceLevel.Error) { - var eventListener = new FileEventListener(string.IsNullOrEmpty(LogFile) ? "UnitTestLog" : LogFile); - - PlatformTraceLevel traceLevel = this.GetTraceLevel(); - if (traceLevel > PlatformTraceLevel.Off) - { - eventListener.EnableEvents(UnitTestEventSource.Log, EventLevel.Error); - } - - if (traceLevel > PlatformTraceLevel.Error) - { - eventListener.EnableEvents(UnitTestEventSource.Log, EventLevel.Warning); - } - - if (traceLevel > PlatformTraceLevel.Warning) - { - eventListener.EnableEvents(UnitTestEventSource.Log, EventLevel.Informational); - } - - if (traceLevel > PlatformTraceLevel.Info) - { - eventListener.EnableEvents(UnitTestEventSource.Log, EventLevel.Verbose); - } - - isInitialized = true; + eventListener.EnableEvents(UnitTestEventSource.Log, EventLevel.Warning); } - catch (Exception ex) + + if (traceLevel > PlatformTraceLevel.Warning) + { + eventListener.EnableEvents(UnitTestEventSource.Log, EventLevel.Informational); + } + + if (traceLevel > PlatformTraceLevel.Info) { - this.UnInitializeTrace(); - ErrorOnInitialization = ex.Message; - return false; + eventListener.EnableEvents(UnitTestEventSource.Log, EventLevel.Verbose); } - return isInitialized; + s_isInitialized = true; + } + catch (Exception ex) + { + UnInitializeTrace(); + ErrorOnInitialization = ex.Message; + return false; } - } - private void UnInitializeTrace() - { - isInitialized = false; - LogFile = null; - TraceLevel = PlatformTraceLevel.Off; + return s_isInitialized; } } + + private void UnInitializeTrace() + { + s_isInitialized = false; + LogFile = null; + TraceLevel = PlatformTraceLevel.Off; + } } #endif diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Tracing/UnitTestEventSource.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Tracing/UnitTestEventSource.cs index 7bf7fb4fb8..c20af92945 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Tracing/UnitTestEventSource.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/Tracing/UnitTestEventSource.cs @@ -3,51 +3,42 @@ #if WINDOWS_UWP -namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using System.Diagnostics.Tracing; + +internal sealed class UnitTestEventSource : EventSource { - using System.Diagnostics.Tracing; + public static UnitTestEventSource Log { get; } = new UnitTestEventSource(); + + [Event(1, Level = EventLevel.Verbose)] + public void Verbose(string message) + { + WriteEvent(1, message); + } + + [Event(2, Level = EventLevel.Informational)] + public void Info(string message) + { + WriteEvent(2, message); + } + + [Event(3, Level = EventLevel.Warning)] + public void Warn(string message) + { + WriteEvent(3, message); + } + + [Event(4, Level = EventLevel.Error)] + public void Error(string message) + { + WriteEvent(4, message); + } - internal sealed class UnitTestEventSource : EventSource + [Event(5, Level = EventLevel.Critical)] + public void Critical(string message) { - private static UnitTestEventSource log = new UnitTestEventSource(); - - public static UnitTestEventSource Log - { - get - { - return log; - } - } - - [Event(1, Level = EventLevel.Verbose)] - public void Verbose(string message) - { - this.WriteEvent(1, message); - } - - [Event(2, Level = EventLevel.Informational)] - public void Info(string message) - { - this.WriteEvent(2, message); - } - - [Event(3, Level = EventLevel.Warning)] - public void Warn(string message) - { - this.WriteEvent(3, message); - } - - [Event(4, Level = EventLevel.Error)] - public void Error(string message) - { - this.WriteEvent(4, message); - } - - [Event(5, Level = EventLevel.Critical)] - public void Critical(string message) - { - this.WriteEvent(5, message); - } + WriteEvent(5, message); } } diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/AppxManifestFile.cs b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/AppxManifestFile.cs index 8e68f0c076..5bb3bc66ba 100644 --- a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/AppxManifestFile.cs +++ b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/AppxManifestFile.cs @@ -1,33 +1,32 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.DesktopTestHostRuntimeProvider -{ - using System.IO; - using System.Xml.Linq; +namespace Microsoft.VisualStudio.TestPlatform.DesktopTestHostRuntimeProvider; + +using System.IO; +using System.Xml.Linq; - /// Wrapper for an appx manifest file. - internal static class AppxManifestFile +/// Wrapper for an appx manifest file. +internal static class AppxManifestFile +{ + /// Gets the app's exe name. + /// + /// AppxManifest filePath + /// + /// ExecutableName + public static string GetApplicationExecutableName(string filePath) { - /// Gets the app's exe name. - /// - /// AppxManifest filePath - /// - /// ExecutableName - public static string GetApplicationExecutableName(string filePath) + if (File.Exists(filePath)) { - if (File.Exists(filePath)) - { - var doc = XDocument.Load(filePath); - var ns = doc.Root.Name.Namespace; + var doc = XDocument.Load(filePath); + var ns = doc.Root.Name.Namespace; - return doc.Element(ns + "Package"). - Element(ns + "Applications"). - Element(ns + "Application"). - Attribute("Executable").Value; - } - - return null; + return doc.Element(ns + "Package"). + Element(ns + "Applications"). + Element(ns + "Application"). + Attribute("Executable").Value; } + + return null; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DefaultTestHostManager.cs b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DefaultTestHostManager.cs index a35763c775..233f2020bf 100644 --- a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DefaultTestHostManager.cs +++ b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DefaultTestHostManager.cs @@ -1,445 +1,433 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Xml.Linq; + +using Microsoft.TestPlatform.TestHostProvider.Hosting; +using Microsoft.TestPlatform.TestHostProvider.Resources; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; +using Helpers; +using Helpers.Interfaces; +using DesktopTestHostRuntimeProvider; +using ObjectModel; +using ObjectModel.Client.Interfaces; +using ObjectModel.Host; +using ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using PlatformAbstractions; +using PlatformAbstractions.Interfaces; +using Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +/// +/// The default test host launcher for the engine. +/// This works for Desktop local scenarios +/// +[ExtensionUri(DefaultTestHostUri)] +[FriendlyName(DefaultTestHostFriendlyName)] +public class DefaultTestHostManager : ITestRuntimeProvider2 { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Reflection; - using System.Text; - using System.Threading; - using System.Threading.Tasks; - using System.Xml.Linq; - using Microsoft.TestPlatform.TestHostProvider.Hosting; - using Microsoft.TestPlatform.TestHostProvider.Resources; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.Interfaces; - using Microsoft.VisualStudio.TestPlatform.DesktopTestHostRuntimeProvider; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + private const string X64TestHostProcessName = "testhost{0}.exe"; + private const string X86TestHostProcessName = "testhost{0}.x86.exe"; + + private const string DefaultTestHostUri = "HostProvider://DefaultTestHost"; + private const string DefaultTestHostFriendlyName = "DefaultTestHost"; + private const string TestAdapterEndsWithPattern = @"TestAdapter.dll"; + + private Architecture _architecture; + private Framework _targetFramework; + private readonly IProcessHelper _processHelper; + private readonly IFileHelper _fileHelper; + private readonly IEnvironment _environment; + private readonly IDotnetHostHelper _dotnetHostHelper; + + private ITestHostLauncher _customTestHostLauncher; + private Process _testHostProcess; + private StringBuilder _testHostProcessStdError; + private IMessageLogger _messageLogger; + private bool _hostExitedEventRaised; /// - /// The default test host launcher for the engine. - /// This works for Desktop local scenarios + /// Initializes a new instance of the class. /// - [ExtensionUri(DefaultTestHostUri)] - [FriendlyName(DefaultTestHostFriendlyName)] - public class DefaultTestHostManager : ITestRuntimeProvider2 + public DefaultTestHostManager() + : this(new ProcessHelper(), new FileHelper(), new PlatformEnvironment(), new DotnetHostHelper()) { - private const string X64TestHostProcessName = "testhost{0}.exe"; - private const string X86TestHostProcessName = "testhost{0}.x86.exe"; - - private const string DefaultTestHostUri = "HostProvider://DefaultTestHost"; - private const string DefaultTestHostFriendlyName = "DefaultTestHost"; - private const string TestAdapterEndsWithPattern = @"TestAdapter.dll"; - - private Architecture architecture; - private Framework targetFramework; - private IProcessHelper processHelper; - private IFileHelper fileHelper; - private IEnvironment environment; - private IDotnetHostHelper dotnetHostHelper; - - private ITestHostLauncher customTestHostLauncher; - private Process testHostProcess; - private StringBuilder testHostProcessStdError; - private IMessageLogger messageLogger; - private bool hostExitedEventRaised; - - /// - /// Initializes a new instance of the class. - /// - public DefaultTestHostManager() - : this(new ProcessHelper(), new FileHelper(), new PlatformEnvironment(), new DotnetHostHelper()) - { - } + } - /// - /// Initializes a new instance of the class. - /// - /// Process helper instance. - /// File helper instance. - /// Instance of platform environment. - /// Instance of dotnet host helper. - internal DefaultTestHostManager(IProcessHelper processHelper, IFileHelper fileHelper, IEnvironment environment, IDotnetHostHelper dotnetHostHelper) - { - this.processHelper = processHelper; - this.fileHelper = fileHelper; - this.environment = environment; - this.dotnetHostHelper = dotnetHostHelper; - } + /// + /// Initializes a new instance of the class. + /// + /// Process helper instance. + /// File helper instance. + /// Instance of platform environment. + /// Instance of dotnet host helper. + internal DefaultTestHostManager(IProcessHelper processHelper, IFileHelper fileHelper, IEnvironment environment, IDotnetHostHelper dotnetHostHelper) + { + _processHelper = processHelper; + _fileHelper = fileHelper; + _environment = environment; + _dotnetHostHelper = dotnetHostHelper; + } - /// - public event EventHandler HostLaunched; + /// + public event EventHandler HostLaunched; - /// - public event EventHandler HostExited; + /// + public event EventHandler HostExited; - /// - public bool Shared { get; private set; } + /// + public bool Shared { get; private set; } - /// - /// Gets the properties of the test executor launcher. These could be the targetID for emulator/phone specific scenarios. - /// - public IDictionary Properties => new Dictionary(); + /// + /// Gets the properties of the test executor launcher. These could be the targetID for emulator/phone specific scenarios. + /// + public IDictionary Properties => new Dictionary(); - /// - /// Gets callback on process exit - /// - private Action ExitCallBack => (process) => - { - TestHostManagerCallbacks.ExitCallBack(this.processHelper, process, this.testHostProcessStdError, this.OnHostExited); - }; + /// + /// Gets callback on process exit + /// + private Action ExitCallBack => (process) => TestHostManagerCallbacks.ExitCallBack(_processHelper, process, _testHostProcessStdError, OnHostExited); - /// - /// Gets callback to read from process error stream - /// - private Action ErrorReceivedCallback => (process, data) => - { - TestHostManagerCallbacks.ErrorReceivedCallback(this.testHostProcessStdError, data); - }; + /// + /// Gets callback to read from process error stream + /// + private Action ErrorReceivedCallback => (process, data) => TestHostManagerCallbacks.ErrorReceivedCallback(_testHostProcessStdError, data); + + /// + public void SetCustomLauncher(ITestHostLauncher customLauncher) + { + _customTestHostLauncher = customLauncher; + } + + /// + public TestHostConnectionInfo GetTestHostConnectionInfo() + { + return new TestHostConnectionInfo { Endpoint = "127.0.0.1:0", Role = ConnectionRole.Client, Transport = Transport.Sockets }; + } + + /// + public async Task LaunchTestHostAsync(TestProcessStartInfo testHostStartInfo, CancellationToken cancellationToken) + { + return await Task.Run(() => LaunchHost(testHostStartInfo, cancellationToken), cancellationToken); + } - /// - public void SetCustomLauncher(ITestHostLauncher customLauncher) + /// + public virtual TestProcessStartInfo GetTestHostProcessStartInfo( + IEnumerable sources, + IDictionary environmentVariables, + TestRunnerConnectionInfo connectionInfo) + { + string testHostProcessName; + if (_targetFramework.Name.StartsWith(".NETFramework,Version=v")) { - this.customTestHostLauncher = customLauncher; - } + var targetFrameworkMoniker = "net" + _targetFramework.Name.Replace(".NETFramework,Version=v", string.Empty).Replace(".", string.Empty); - /// - public TestHostConnectionInfo GetTestHostConnectionInfo() + // Net451 or older will use the default testhost.exe that is compiled against net451. + var isSupportedNetTarget = new[] { "net452", "net46", "net461", "net462", "net47", "net471", "net472", "net48" }.Contains(targetFrameworkMoniker); + var targetFrameworkSuffix = isSupportedNetTarget ? $".{targetFrameworkMoniker}" : string.Empty; + + // Default test host manager supports shared test sources + testHostProcessName = string.Format(_architecture == Architecture.X86 ? X86TestHostProcessName : X64TestHostProcessName, targetFrameworkSuffix); + } + else { - return new TestHostConnectionInfo { Endpoint = "127.0.0.1:0", Role = ConnectionRole.Client, Transport = Transport.Sockets }; + // This path is probably happening only in our tests, because otherwise we are first running CanExecuteCurrentRunConfiguration + // which would disqualify anything that is not netframework. + testHostProcessName = string.Format(_architecture == Architecture.X86 ? X86TestHostProcessName : X64TestHostProcessName, string.Empty); } - /// - public async Task LaunchTestHostAsync(TestProcessStartInfo testHostStartInfo, CancellationToken cancellationToken) + var currentWorkingDirectory = Path.Combine(Path.GetDirectoryName(typeof(DefaultTestHostManager).GetTypeInfo().Assembly.Location), "..//"); + var argumentsString = " " + connectionInfo.ToCommandLineOptions(); + + // check in current location for testhost exe + var testhostProcessPath = Path.Combine(currentWorkingDirectory, testHostProcessName); + + if (!File.Exists(testhostProcessPath)) { - return await Task.Run(() => this.LaunchHost(testHostStartInfo, cancellationToken), cancellationToken); + // "TestHost" is the name of the folder which contain Full CLR built testhost package assemblies. + testHostProcessName = Path.Combine("TestHost", testHostProcessName); + testhostProcessPath = Path.Combine(currentWorkingDirectory, testHostProcessName); } - /// - public virtual TestProcessStartInfo GetTestHostProcessStartInfo( - IEnumerable sources, - IDictionary environmentVariables, - TestRunnerConnectionInfo connectionInfo) + if (!Shared) { - string testHostProcessName; - if (this.targetFramework.Name.StartsWith(".NETFramework,Version=v")) - { - var targetFrameworkMoniker = "net" + this.targetFramework.Name.Replace(".NETFramework,Version=v", string.Empty).Replace(".", string.Empty); - - // Net451 or older will use the default testhost.exe that is compiled against net451. - var isSupportedNetTarget = new[] { "net452", "net46", "net461", "net462", "net47", "net471", "net472", "net48" }.Contains(targetFrameworkMoniker); - var targetFrameworkSuffix = isSupportedNetTarget ? $".{targetFrameworkMoniker}" : string.Empty; - - // Default test host manager supports shared test sources - testHostProcessName = string.Format(this.architecture == Architecture.X86 ? X86TestHostProcessName : X64TestHostProcessName, targetFrameworkSuffix); - } - else - { - // This path is probably happening only in our tests, because otherwise we are first running CanExecuteCurrentRunConfiguration - // which would disqualify anything that is not netframework. - testHostProcessName = string.Format(this.architecture == Architecture.X86 ? X86TestHostProcessName : X64TestHostProcessName, string.Empty); - } + // Not sharing the host which means we need to pass the test assembly path as argument + // so that the test host can create an appdomain on startup (Main method) and set appbase + argumentsString += " --testsourcepath " + sources.FirstOrDefault().AddDoubleQuote(); + } - var currentWorkingDirectory = Path.Combine(Path.GetDirectoryName(typeof(DefaultTestHostManager).GetTypeInfo().Assembly.Location), "..//"); - var argumentsString = " " + connectionInfo.ToCommandLineOptions(); + EqtTrace.Verbose("DefaultTestHostmanager: Full path of {0} is {1}", testHostProcessName, testhostProcessPath); - // check in current location for testhost exe - var testhostProcessPath = Path.Combine(currentWorkingDirectory, testHostProcessName); + var launcherPath = testhostProcessPath; + if (!_environment.OperatingSystem.Equals(PlatformOperatingSystem.Windows) && + !_processHelper.GetCurrentProcessFileName().EndsWith(DotnetHostHelper.MONOEXENAME, StringComparison.OrdinalIgnoreCase)) + { + launcherPath = _dotnetHostHelper.GetMonoPath(); + argumentsString = testhostProcessPath.AddDoubleQuote() + " " + argumentsString; + } - if (!File.Exists(testhostProcessPath)) - { - // "TestHost" is the name of the folder which contain Full CLR built testhost package assemblies. - testHostProcessName = Path.Combine("TestHost", testHostProcessName); - testhostProcessPath = Path.Combine(currentWorkingDirectory, testHostProcessName); - } + // For IDEs and other scenario, current directory should be the + // working directory (not the vstest.console.exe location). + // For VS - this becomes the solution directory for example + // "TestResults" directory will be created at "current directory" of test host + var processWorkingDirectory = Directory.GetCurrentDirectory(); - if (!this.Shared) - { - // Not sharing the host which means we need to pass the test assembly path as argument - // so that the test host can create an appdomain on startup (Main method) and set appbase - argumentsString += " --testsourcepath " + sources.FirstOrDefault().AddDoubleQuote(); - } + return new TestProcessStartInfo + { + FileName = launcherPath, + Arguments = argumentsString, + EnvironmentVariables = environmentVariables ?? new Dictionary(), + WorkingDirectory = processWorkingDirectory + }; + } - EqtTrace.Verbose("DefaultTestHostmanager: Full path of {0} is {1}", testHostProcessName, testhostProcessPath); + /// + public IEnumerable GetTestPlatformExtensions(IEnumerable sources, IEnumerable extensions) + { + if (sources != null && sources.Any()) + { + extensions = extensions.Concat(sources.SelectMany(s => _fileHelper.EnumerateFiles(Path.GetDirectoryName(s), SearchOption.TopDirectoryOnly, TestAdapterEndsWithPattern))); + } - var launcherPath = testhostProcessPath; - if (!this.environment.OperatingSystem.Equals(PlatformOperatingSystem.Windows) && - !this.processHelper.GetCurrentProcessFileName().EndsWith(DotnetHostHelper.MONOEXENAME, StringComparison.OrdinalIgnoreCase)) - { - launcherPath = this.dotnetHostHelper.GetMonoPath(); - argumentsString = testhostProcessPath.AddDoubleQuote() + " " + argumentsString; - } + extensions = FilterExtensionsBasedOnVersion(extensions); - // For IDEs and other scenario, current directory should be the - // working directory (not the vstest.console.exe location). - // For VS - this becomes the solution directory for example - // "TestResults" directory will be created at "current directory" of test host - var processWorkingDirectory = Directory.GetCurrentDirectory(); + return extensions; + } - return new TestProcessStartInfo - { - FileName = launcherPath, - Arguments = argumentsString, - EnvironmentVariables = environmentVariables ?? new Dictionary(), - WorkingDirectory = processWorkingDirectory - }; - } + /// + public IEnumerable GetTestSources(IEnumerable sources) + { + // We are doing this specifically for UWP, should we extract it out to some other utility? + // Why? Lets say if we have to do same for some other source extension, would we just add another if check? + var uwpSources = sources.Where(source => source.EndsWith(".appxrecipe", StringComparison.OrdinalIgnoreCase)); - /// - public IEnumerable GetTestPlatformExtensions(IEnumerable sources, IEnumerable extensions) + if (uwpSources.Any()) { - if (sources != null && sources.Any()) + List actualSources = new(); + foreach (var uwpSource in uwpSources) { - extensions = extensions.Concat(sources.SelectMany(s => this.fileHelper.EnumerateFiles(Path.GetDirectoryName(s), SearchOption.TopDirectoryOnly, TestAdapterEndsWithPattern))); + actualSources.Add(Path.Combine(Path.GetDirectoryName(uwpSource), GetUwpSources(uwpSource))); } - extensions = this.FilterExtensionsBasedOnVersion(extensions); - - return extensions; + return actualSources; } - /// - public IEnumerable GetTestSources(IEnumerable sources) - { - // We are doing this specifically for UWP, should we extract it out to some other utility? - // Why? Lets say if we have to do same for some other source extension, would we just add another if check? - var uwpSources = sources.Where(source => source.EndsWith(".appxrecipe", StringComparison.OrdinalIgnoreCase)); + return sources; + } - if (uwpSources.Any()) - { - List actualSources = new List(); - foreach (var uwpSource in uwpSources) - { - actualSources.Add(Path.Combine(Path.GetDirectoryName(uwpSource), this.GetUwpSources(uwpSource))); - } + /// + public bool CanExecuteCurrentRunConfiguration(string runsettingsXml) + { + var config = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettingsXml); + var framework = config.TargetFramework; - return actualSources; - } + // This is expected to be called once every run so returning a new instance every time. + return framework.Name.IndexOf("NETFramework", StringComparison.OrdinalIgnoreCase) >= 0; + } - return sources; - } + /// + public void Initialize(IMessageLogger logger, string runsettingsXml) + { + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettingsXml); - /// - public bool CanExecuteCurrentRunConfiguration(string runsettingsXml) - { - var config = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettingsXml); - var framework = config.TargetFramework; + _messageLogger = logger; + _architecture = runConfiguration.TargetPlatform; + _targetFramework = runConfiguration.TargetFramework; + _testHostProcess = null; - // This is expected to be called once every run so returning a new instance every time. - if (framework.Name.IndexOf("NETFramework", StringComparison.OrdinalIgnoreCase) >= 0) - { - return true; - } + Shared = !runConfiguration.DisableAppDomain; + _hostExitedEventRaised = false; + } - return false; + /// + public Task CleanTestHostAsync(CancellationToken cancellationToken) + { + try + { + _processHelper.TerminateProcess(_testHostProcess); } - - /// - public void Initialize(IMessageLogger logger, string runsettingsXml) + catch (Exception ex) { - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettingsXml); - - this.messageLogger = logger; - this.architecture = runConfiguration.TargetPlatform; - this.targetFramework = runConfiguration.TargetFramework; - this.testHostProcess = null; - - this.Shared = !runConfiguration.DisableAppDomain; - this.hostExitedEventRaised = false; + EqtTrace.Warning("DefaultTestHostManager: Unable to terminate test host process: " + ex); } - /// - public Task CleanTestHostAsync(CancellationToken cancellationToken) - { - try - { - this.processHelper.TerminateProcess(this.testHostProcess); - } - catch (Exception ex) - { - EqtTrace.Warning("DefaultTestHostManager: Unable to terminate test host process: " + ex); - } + _testHostProcess?.Dispose(); - this.testHostProcess?.Dispose(); + return Task.FromResult(true); + } - return Task.FromResult(true); - } + /// + public bool AttachDebuggerToTestHost() + { + return _customTestHostLauncher is ITestHostLauncher2 launcher + && launcher.AttachDebuggerToProcess(_testHostProcess.Id); + } - /// - public bool AttachDebuggerToTestHost() - { - return this.customTestHostLauncher is ITestHostLauncher2 launcher - ? launcher.AttachDebuggerToProcess(this.testHostProcess.Id) - : false; - } + /// + /// Filter duplicate extensions, include only the highest versioned extension + /// + /// Entire list of extensions + /// Filtered list of extensions + private IEnumerable FilterExtensionsBasedOnVersion(IEnumerable extensions) + { + Dictionary selectedExtensions = new(); + Dictionary highestFileVersions = new(); + Dictionary conflictingExtensions = new(); - /// - /// Filter duplicate extensions, include only the highest versioned extension - /// - /// Entire list of extensions - /// Filtered list of extensions - private IEnumerable FilterExtensionsBasedOnVersion(IEnumerable extensions) + foreach (var extensionFullPath in extensions) { - Dictionary selectedExtensions = new Dictionary(); - Dictionary highestFileVersions = new Dictionary(); - Dictionary conflictingExtensions = new Dictionary(); + // assemblyName is the key + var extensionAssemblyName = Path.GetFileNameWithoutExtension(extensionFullPath); - foreach (var extensionFullPath in extensions) + if (selectedExtensions.TryGetValue(extensionAssemblyName, out var oldExtensionPath)) { - // assemblyName is the key - var extensionAssemblyName = Path.GetFileNameWithoutExtension(extensionFullPath); + // This extension is duplicate + var currentVersion = GetAndLogFileVersion(extensionFullPath); - if (selectedExtensions.TryGetValue(extensionAssemblyName, out var oldExtensionPath)) + var oldVersionFound = highestFileVersions.TryGetValue(extensionAssemblyName, out var oldVersion); + if (!oldVersionFound) { - // This extension is duplicate - var currentVersion = this.GetAndLogFileVersion(extensionFullPath); + oldVersion = GetAndLogFileVersion(oldExtensionPath); + } - var oldVersionFound = highestFileVersions.TryGetValue(extensionAssemblyName, out var oldVersion); - if (!oldVersionFound) + // If the version of current file is higher than the one in the map + // replace the older with the current file + if (currentVersion > oldVersion) + { + highestFileVersions[extensionAssemblyName] = currentVersion; + conflictingExtensions[extensionAssemblyName] = currentVersion; + selectedExtensions[extensionAssemblyName] = extensionFullPath; + } + else + { + if (currentVersion < oldVersion) { - oldVersion = this.GetAndLogFileVersion(oldExtensionPath); + conflictingExtensions[extensionAssemblyName] = oldVersion; } - // If the version of current file is higher than the one in the map - // replace the older with the current file - if (currentVersion > oldVersion) - { - highestFileVersions[extensionAssemblyName] = currentVersion; - conflictingExtensions[extensionAssemblyName] = currentVersion; - selectedExtensions[extensionAssemblyName] = extensionFullPath; - } - else + if (!oldVersionFound) { - if (currentVersion < oldVersion) - { - conflictingExtensions[extensionAssemblyName] = oldVersion; - } - - if (!oldVersionFound) - { - highestFileVersions.Add(extensionAssemblyName, oldVersion); - } + highestFileVersions.Add(extensionAssemblyName, oldVersion); } } - else - { - selectedExtensions.Add(extensionAssemblyName, extensionFullPath); - } } - - // Log warning if conflicting version extensions are found - if (conflictingExtensions.Any()) + else { - var extensionsString = string.Join("\n", conflictingExtensions.Select(kv => string.Format(" {0} : {1}", kv.Key, kv.Value))); - string message = string.Format(CultureInfo.CurrentCulture, Resources.MultipleFileVersions, extensionsString); - this.messageLogger.SendMessage(TestMessageLevel.Warning, message); + selectedExtensions.Add(extensionAssemblyName, extensionFullPath); } - - return selectedExtensions.Values; } - private Version GetAndLogFileVersion(string path) + // Log warning if conflicting version extensions are found + if (conflictingExtensions.Any()) { - var fileVersion = this.fileHelper.GetFileVersion(path); - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("FileVersion for {0} : {1}", path, fileVersion); - } - - return fileVersion; + var extensionsString = string.Join("\n", conflictingExtensions.Select(kv => string.Format(" {0} : {1}", kv.Key, kv.Value))); + string message = string.Format(CultureInfo.CurrentCulture, Resources.MultipleFileVersions, extensionsString); + _messageLogger.SendMessage(TestMessageLevel.Warning, message); } - /// - /// Raises HostLaunched event - /// - /// host provider event args - private void OnHostLaunched(HostProviderEventArgs e) + return selectedExtensions.Values; + } + + private Version GetAndLogFileVersion(string path) + { + var fileVersion = _fileHelper.GetFileVersion(path); + if (EqtTrace.IsVerboseEnabled) { - this.HostLaunched.SafeInvoke(this, e, "HostProviderEvents.OnHostLaunched"); + EqtTrace.Verbose("FileVersion for {0} : {1}", path, fileVersion); } - /// - /// Raises HostExited event - /// - /// host provider event args - private void OnHostExited(HostProviderEventArgs e) + return fileVersion; + } + + /// + /// Raises HostLaunched event + /// + /// host provider event args + private void OnHostLaunched(HostProviderEventArgs e) + { + HostLaunched.SafeInvoke(this, e, "HostProviderEvents.OnHostLaunched"); + } + + /// + /// Raises HostExited event + /// + /// host provider event args + private void OnHostExited(HostProviderEventArgs e) + { + if (!_hostExitedEventRaised) { - if (!this.hostExitedEventRaised) - { - this.hostExitedEventRaised = true; - this.HostExited.SafeInvoke(this, e, "HostProviderEvents.OnHostExited"); - } + _hostExitedEventRaised = true; + HostExited.SafeInvoke(this, e, "HostProviderEvents.OnHostExited"); } + } - private bool LaunchHost(TestProcessStartInfo testHostStartInfo, CancellationToken cancellationToken) + private bool LaunchHost(TestProcessStartInfo testHostStartInfo, CancellationToken cancellationToken) + { + _testHostProcessStdError = new StringBuilder(0, CoreUtilities.Constants.StandardErrorMaxLength); + EqtTrace.Verbose("Launching default test Host Process {0} with arguments {1}", testHostStartInfo.FileName, testHostStartInfo.Arguments); + + // We launch the test host process here if we're on the normal test running workflow. + // If we're debugging and we have access to the newest version of the testhost launcher + // interface we launch it here as well, but we expect to attach later to the test host + // process by using its PID. + // For every other workflow (e.g.: profiling) we ask the IDE to launch the custom test + // host for us. In the profiling case this is needed because then the IDE sets some + // additional environmental variables for us to help with probing. + if ((_customTestHostLauncher == null) + || (_customTestHostLauncher.IsDebug + && _customTestHostLauncher is ITestHostLauncher2)) { - this.testHostProcessStdError = new StringBuilder(0, CoreUtilities.Constants.StandardErrorMaxLength); - EqtTrace.Verbose("Launching default test Host Process {0} with arguments {1}", testHostStartInfo.FileName, testHostStartInfo.Arguments); - - // We launch the test host process here if we're on the normal test running workflow. - // If we're debugging and we have access to the newest version of the testhost launcher - // interface we launch it here as well, but we expect to attach later to the test host - // process by using its PID. - // For every other workflow (e.g.: profiling) we ask the IDE to launch the custom test - // host for us. In the profiling case this is needed because then the IDE sets some - // additional environmental variables for us to help with probing. - if ((this.customTestHostLauncher == null) - || (this.customTestHostLauncher.IsDebug - && this.customTestHostLauncher is ITestHostLauncher2)) - { - EqtTrace.Verbose("DefaultTestHostManager: Starting process '{0}' with command line '{1}'", testHostStartInfo.FileName, testHostStartInfo.Arguments); - cancellationToken.ThrowIfCancellationRequested(); - this.testHostProcess = this.processHelper.LaunchProcess( - testHostStartInfo.FileName, - testHostStartInfo.Arguments, - testHostStartInfo.WorkingDirectory, - testHostStartInfo.EnvironmentVariables, - this.ErrorReceivedCallback, - this.ExitCallBack, - null) as Process; - } - else - { - int processId = this.customTestHostLauncher.LaunchTestHost(testHostStartInfo, cancellationToken); - this.testHostProcess = Process.GetProcessById(processId); - this.processHelper.SetExitCallback(processId, this.ExitCallBack); - } - - this.OnHostLaunched(new HostProviderEventArgs("Test Runtime launched", 0, this.testHostProcess.Id)); - return this.testHostProcess != null; + EqtTrace.Verbose("DefaultTestHostManager: Starting process '{0}' with command line '{1}'", testHostStartInfo.FileName, testHostStartInfo.Arguments); + cancellationToken.ThrowIfCancellationRequested(); + _testHostProcess = _processHelper.LaunchProcess( + testHostStartInfo.FileName, + testHostStartInfo.Arguments, + testHostStartInfo.WorkingDirectory, + testHostStartInfo.EnvironmentVariables, + ErrorReceivedCallback, + ExitCallBack, + null) as Process; } - - private string GetUwpSources(string uwpSource) + else { - var doc = XDocument.Load(uwpSource); - var ns = doc.Root.Name.Namespace; + int processId = _customTestHostLauncher.LaunchTestHost(testHostStartInfo, cancellationToken); + _testHostProcess = Process.GetProcessById(processId); + _processHelper.SetExitCallback(processId, ExitCallBack); + } - string appxManifestPath = doc.Element(ns + "Project"). - Element(ns + "ItemGroup"). - Element(ns + "AppXManifest"). - Attribute("Include").Value; + OnHostLaunched(new HostProviderEventArgs("Test Runtime launched", 0, _testHostProcess.Id)); + return _testHostProcess != null; + } - if (!Path.IsPathRooted(appxManifestPath)) - { - appxManifestPath = Path.Combine(Path.GetDirectoryName(uwpSource), appxManifestPath); - } + private string GetUwpSources(string uwpSource) + { + var doc = XDocument.Load(uwpSource); + var ns = doc.Root.Name.Namespace; + + string appxManifestPath = doc.Element(ns + "Project"). + Element(ns + "ItemGroup"). + Element(ns + "AppXManifest"). + Attribute("Include").Value; - return AppxManifestFile.GetApplicationExecutableName(appxManifestPath); + if (!Path.IsPathRooted(appxManifestPath)) + { + appxManifestPath = Path.Combine(Path.GetDirectoryName(uwpSource), appxManifestPath); } + + return AppxManifestFile.GetApplicationExecutableName(appxManifestPath); } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs index 93f01cae5b..0a1c8e5238 100644 --- a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs +++ b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs @@ -1,814 +1,785 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +using Extensions.DependencyModel; +using Microsoft.TestPlatform.TestHostProvider.Hosting; +using Microsoft.TestPlatform.TestHostProvider.Resources; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; +using Helpers; +using Helpers.Interfaces; +using ObjectModel; +using ObjectModel.Client.Interfaces; +using ObjectModel.Host; +using ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using PlatformAbstractions; +using PlatformAbstractions.Interfaces; +using Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Win32; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +/// +/// A host manager for dotnet core runtime. +/// +/// +/// Note that some functionality of this entity overlaps with that of . That is +/// intentional since we want to move this to a separate assembly (with some runtime extensibility discovery). +/// +[ExtensionUri(DotnetTestHostUri)] +[FriendlyName(DotnetTestHostFriendlyName)] +public class DotnetTestHostManager : ITestRuntimeProvider2 { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Reflection; - using System.Text; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.Extensions.DependencyModel; - using Microsoft.TestPlatform.TestHostProvider.Hosting; - using Microsoft.TestPlatform.TestHostProvider.Resources; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.Win32; - using Newtonsoft.Json; - using Newtonsoft.Json.Linq; + private const string DotnetTestHostUri = "HostProvider://DotnetTestHost"; + private const string DotnetTestHostFriendlyName = "DotnetTestHost"; + private const string TestAdapterRegexPattern = @"TestAdapter.dll"; - /// - /// A host manager for dotnet core runtime. - /// - /// - /// Note that some functionality of this entity overlaps with that of . That is - /// intentional since we want to move this to a separate assembly (with some runtime extensibility discovery). - /// - [ExtensionUri(DotnetTestHostUri)] - [FriendlyName(DotnetTestHostFriendlyName)] - public class DotnetTestHostManager : ITestRuntimeProvider2 - { - private const string DotnetTestHostUri = "HostProvider://DotnetTestHost"; - private const string DotnetTestHostFriendlyName = "DotnetTestHost"; - private const string TestAdapterRegexPattern = @"TestAdapter.dll"; + private readonly IDotnetHostHelper _dotnetHostHelper; + private readonly IEnvironment _platformEnvironment; + private readonly IProcessHelper _processHelper; + private readonly IRunSettingsHelper _runsettingHelper; + private readonly IFileHelper _fileHelper; + private readonly IWindowsRegistryHelper _windowsRegistryHelper; + private readonly IEnvironmentVariableHelper _environmentVariableHelper; + + private ITestHostLauncher _customTestHostLauncher; + + private Process _testHostProcess; + + private StringBuilder _testHostProcessStdError; - private IDotnetHostHelper dotnetHostHelper; - private IEnvironment platformEnvironment; - private IProcessHelper processHelper; - private IRunSettingsHelper runsettingHelper; - private IFileHelper fileHelper; - private IWindowsRegistryHelper windowsRegistryHelper; - private IEnvironmentVariableHelper environmentVariableHelper; + private IMessageLogger _messageLogger; - private ITestHostLauncher customTestHostLauncher; + private bool _hostExitedEventRaised; - private Process testHostProcess; + private string _hostPackageVersion = "15.0.0"; - private StringBuilder testHostProcessStdError; + private Architecture _architecture; + private Framework _targetFramework; + private bool _isVersionCheckRequired = true; - private IMessageLogger messageLogger; + private string _dotnetHostPath; - private bool hostExitedEventRaised; + /// + /// Initializes a new instance of the class. + /// + public DotnetTestHostManager() + : this( + new ProcessHelper(), + new FileHelper(), + new DotnetHostHelper(), + new PlatformEnvironment(), + RunSettingsHelper.Instance, + new WindowsRegistryHelper(), + new EnvironmentVariableHelper()) + { + } - private string hostPackageVersion = "15.0.0"; + /// + /// Initializes a new instance of the class. + /// + /// Process helper instance. + /// File helper instance. + /// DotnetHostHelper helper instance. + /// Platform Environment + /// RunsettingHelper instance + /// WindowsRegistryHelper instance + /// EnvironmentVariableHelper instance + internal DotnetTestHostManager( + IProcessHelper processHelper, + IFileHelper fileHelper, + IDotnetHostHelper dotnetHostHelper, + IEnvironment platformEnvironment, + IRunSettingsHelper runsettingHelper, + IWindowsRegistryHelper windowsRegistryHelper, + IEnvironmentVariableHelper environmentVariableHelper) + { + _processHelper = processHelper; + _fileHelper = fileHelper; + _dotnetHostHelper = dotnetHostHelper; + _platformEnvironment = platformEnvironment; + _runsettingHelper = runsettingHelper; + _windowsRegistryHelper = windowsRegistryHelper; + _environmentVariableHelper = environmentVariableHelper; + } - private Architecture architecture; - private Framework targetFramework; - private bool isVersionCheckRequired = true; + /// + public event EventHandler HostLaunched; - private string dotnetHostPath; + /// + public event EventHandler HostExited; - /// - /// Initializes a new instance of the class. - /// - public DotnetTestHostManager() - : this( - new ProcessHelper(), - new FileHelper(), - new DotnetHostHelper(), - new PlatformEnvironment(), - RunSettingsHelper.Instance, - new WindowsRegistryHelper(), - new EnvironmentVariableHelper()) + /// + /// Gets a value indicating whether gets a value indicating if the test host can be shared for multiple sources. + /// + /// + /// Dependency resolution for .net core projects are pivoted by the test project. Hence each test + /// project must be launched in a separate test host process. + /// + public bool Shared => false; + + /// + /// Gets a value indicating whether the test host supports protocol version check + /// By default this is set to true. For host package version 15.0.0, this will be set to false; + /// + internal virtual bool IsVersionCheckRequired + { + get { + return _isVersionCheckRequired; } - /// - /// Initializes a new instance of the class. - /// - /// Process helper instance. - /// File helper instance. - /// DotnetHostHelper helper instance. - /// Platform Environment - /// RunsettingHelper instance - /// WindowsRegistryHelper instance - /// EnvironmentVariableHelper instance - internal DotnetTestHostManager( - IProcessHelper processHelper, - IFileHelper fileHelper, - IDotnetHostHelper dotnetHostHelper, - IEnvironment platformEnvironment, - IRunSettingsHelper runsettingHelper, - IWindowsRegistryHelper windowsRegistryHelper, - IEnvironmentVariableHelper environmentVariableHelper) + private set { - this.processHelper = processHelper; - this.fileHelper = fileHelper; - this.dotnetHostHelper = dotnetHostHelper; - this.platformEnvironment = platformEnvironment; - this.runsettingHelper = runsettingHelper; - this.windowsRegistryHelper = windowsRegistryHelper; - this.environmentVariableHelper = environmentVariableHelper; + _isVersionCheckRequired = value; } + } - /// - public event EventHandler HostLaunched; - - /// - public event EventHandler HostExited; - - /// - /// Gets a value indicating whether gets a value indicating if the test host can be shared for multiple sources. - /// - /// - /// Dependency resolution for .net core projects are pivoted by the test project. Hence each test - /// project must be launched in a separate test host process. - /// - public bool Shared => false; - - /// - /// Gets a value indicating whether the test host supports protocol version check - /// By default this is set to true. For host package version 15.0.0, this will be set to false; - /// - internal virtual bool IsVersionCheckRequired - { - get - { - return this.isVersionCheckRequired; - } + /// + /// Gets a value indicating whether the test host supports protocol version check + /// + internal bool MakeRunsettingsCompatible => _hostPackageVersion.StartsWith("15.0.0-preview"); - private set - { - this.isVersionCheckRequired = value; - } - } + /// + /// Gets callback on process exit + /// + private Action ExitCallBack => (process) => TestHostManagerCallbacks.ExitCallBack(_processHelper, process, _testHostProcessStdError, OnHostExited); - /// - /// Gets a value indicating whether the test host supports protocol version check - /// - internal bool MakeRunsettingsCompatible => this.hostPackageVersion.StartsWith("15.0.0-preview"); + /// + /// Gets callback to read from process error stream + /// + private Action ErrorReceivedCallback => (process, data) => TestHostManagerCallbacks.ErrorReceivedCallback(_testHostProcessStdError, data); - /// - /// Gets callback on process exit - /// - private Action ExitCallBack => (process) => - { - TestHostManagerCallbacks.ExitCallBack(this.processHelper, process, this.testHostProcessStdError, this.OnHostExited); - }; + /// + public void Initialize(IMessageLogger logger, string runsettingsXml) + { + _messageLogger = logger; + _hostExitedEventRaised = false; - /// - /// Gets callback to read from process error stream - /// - private Action ErrorReceivedCallback => (process, data) => - { - TestHostManagerCallbacks.ErrorReceivedCallback(this.testHostProcessStdError, data); - }; + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettingsXml); + _architecture = runConfiguration.TargetPlatform; + _targetFramework = runConfiguration.TargetFramework; + _dotnetHostPath = runConfiguration.DotnetHostPath; + } - /// - public void Initialize(IMessageLogger logger, string runsettingsXml) - { - this.messageLogger = logger; - this.hostExitedEventRaised = false; + /// + public void SetCustomLauncher(ITestHostLauncher customLauncher) + { + _customTestHostLauncher = customLauncher; + } - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettingsXml); - this.architecture = runConfiguration.TargetPlatform; - this.targetFramework = runConfiguration.TargetFramework; - this.dotnetHostPath = runConfiguration.DotnetHostPath; - } + /// + public TestHostConnectionInfo GetTestHostConnectionInfo() + { + return new TestHostConnectionInfo { Endpoint = "127.0.0.1:0", Role = ConnectionRole.Client, Transport = Transport.Sockets }; + } - /// - public void SetCustomLauncher(ITestHostLauncher customLauncher) + /// + public async Task LaunchTestHostAsync(TestProcessStartInfo testHostStartInfo, CancellationToken cancellationToken) + { + return await Task.Run(() => LaunchHost(testHostStartInfo, cancellationToken), cancellationToken); + } + + /// + public virtual TestProcessStartInfo GetTestHostProcessStartInfo( + IEnumerable sources, + IDictionary environmentVariables, + TestRunnerConnectionInfo connectionInfo) + { + EqtTrace.Verbose($"DotnetTestHostmanager.GetTestHostProcessStartInfo: Platform environment '{_platformEnvironment.Architecture}' target architecture '{_architecture}' framework '{_targetFramework}' OS '{_platformEnvironment.OperatingSystem}'"); + + var startInfo = new TestProcessStartInfo(); + + // .NET core host manager is not a shared host. It will expect a single test source to be provided. + // TODO: Throw an exception when we get 0 or more than 1 source, that explains what happened, instead of .Single throwing a generic exception? + var args = string.Empty; + var sourcePath = sources.Single(); + var sourceFile = Path.GetFileNameWithoutExtension(sourcePath); + var sourceDirectory = Path.GetDirectoryName(sourcePath); + + // Probe for runtime config and deps file for the test source + var runtimeConfigPath = Path.Combine(sourceDirectory, string.Concat(sourceFile, ".runtimeconfig.json")); + var runtimeConfigFound = false; + if (_fileHelper.Exists(runtimeConfigPath)) { - this.customTestHostLauncher = customLauncher; + runtimeConfigFound = true; + string argsToAdd = " --runtimeconfig " + runtimeConfigPath.AddDoubleQuote(); + args += argsToAdd; + EqtTrace.Verbose("DotnetTestHostmanager: Adding {0} in args", argsToAdd); } - - /// - public TestHostConnectionInfo GetTestHostConnectionInfo() + else { - return new TestHostConnectionInfo { Endpoint = "127.0.0.1:0", Role = ConnectionRole.Client, Transport = Transport.Sockets }; + EqtTrace.Verbose("DotnetTestHostmanager: File {0}, does not exist", runtimeConfigPath); } - /// - public async Task LaunchTestHostAsync(TestProcessStartInfo testHostStartInfo, CancellationToken cancellationToken) + // Use the deps.json for test source + var depsFilePath = Path.Combine(sourceDirectory, string.Concat(sourceFile, ".deps.json")); + if (_fileHelper.Exists(depsFilePath)) { - return await Task.Run(() => this.LaunchHost(testHostStartInfo, cancellationToken), cancellationToken); + string argsToAdd = " --depsfile " + depsFilePath.AddDoubleQuote(); + args += argsToAdd; + EqtTrace.Verbose("DotnetTestHostmanager: Adding {0} in args", argsToAdd); } - - /// - public virtual TestProcessStartInfo GetTestHostProcessStartInfo( - IEnumerable sources, - IDictionary environmentVariables, - TestRunnerConnectionInfo connectionInfo) + else { - EqtTrace.Verbose($"DotnetTestHostmanager.GetTestHostProcessStartInfo: Platform environment '{this.platformEnvironment.Architecture}' target architecture '{this.architecture}' framework '{this.targetFramework}' OS '{this.platformEnvironment.OperatingSystem}'"); + EqtTrace.Verbose("DotnetTestHostmanager: File {0}, does not exist", depsFilePath); + } - var startInfo = new TestProcessStartInfo(); + var runtimeConfigDevPath = Path.Combine(sourceDirectory, string.Concat(sourceFile, ".runtimeconfig.dev.json")); + string testHostPath = string.Empty; + bool useCustomDotnetHostpath = !string.IsNullOrEmpty(_dotnetHostPath); - // .NET core host manager is not a shared host. It will expect a single test source to be provided. - // TODO: Throw an exception when we get 0 or more than 1 source, that explains what happened, instead of .Single throwing a generic exception? - var args = string.Empty; - var sourcePath = sources.Single(); - var sourceFile = Path.GetFileNameWithoutExtension(sourcePath); - var sourceDirectory = Path.GetDirectoryName(sourcePath); + if (useCustomDotnetHostpath) + { + EqtTrace.Verbose("DotnetTestHostmanager: User specified custom path to dotnet host: '{0}'.", _dotnetHostPath); + } - // Probe for runtime config and deps file for the test source - var runtimeConfigPath = Path.Combine(sourceDirectory, string.Concat(sourceFile, ".runtimeconfig.json")); - var runtimeConfigFound = false; - if (this.fileHelper.Exists(runtimeConfigPath)) - { - runtimeConfigFound = true; - string argsToAdd = " --runtimeconfig " + runtimeConfigPath.AddDoubleQuote(); - args += argsToAdd; - EqtTrace.Verbose("DotnetTestHostmanager: Adding {0} in args", argsToAdd); - } - else - { - EqtTrace.Verbose("DotnetTestHostmanager: File {0}, does not exist", runtimeConfigPath); - } + // Try find testhost.exe (or the architecture specific version). We ship those ngened executables for Windows because they have faster startup time. We ship them only for some platforms. + // When user specified path to dotnet.exe don't try to find the exexutable, because we will always use the testhost.dll together with their dotnet.exe. + // We use dotnet.exe on Windows/ARM. + bool testHostExeFound = false; + if (!useCustomDotnetHostpath + && _platformEnvironment.OperatingSystem.Equals(PlatformOperatingSystem.Windows) - // Use the deps.json for test source - var depsFilePath = Path.Combine(sourceDirectory, string.Concat(sourceFile, ".deps.json")); - if (this.fileHelper.Exists(depsFilePath)) - { - string argsToAdd = " --depsfile " + depsFilePath.AddDoubleQuote(); - args += argsToAdd; - EqtTrace.Verbose("DotnetTestHostmanager: Adding {0} in args", argsToAdd); - } - else - { - EqtTrace.Verbose("DotnetTestHostmanager: File {0}, does not exist", depsFilePath); - } + // testhost*.exe are build for netcoreapp2.1 and are not able to search for the correct runtime in case of x64/x86 on arm because the new logic(registry lookup) + // was added in since netcoreapp3.0. On arm we cannot rely on apphost and we'll use dotnet.exe muxer + && !IsWinOnArm()) + { + // testhost.exe is 64-bit and has no suffix other versions have architecture suffix. + var exeName = _architecture == Architecture.X64 || _architecture == Architecture.Default || _architecture == Architecture.AnyCPU + ? "testhost.exe" + : $"testhost.{_architecture.ToString().ToLowerInvariant()}.exe"; - var runtimeConfigDevPath = Path.Combine(sourceDirectory, string.Concat(sourceFile, ".runtimeconfig.dev.json")); - string testHostPath = string.Empty; - bool useCustomDotnetHostpath = !string.IsNullOrEmpty(this.dotnetHostPath); + var fullExePath = Path.Combine(sourceDirectory, exeName); - if (useCustomDotnetHostpath) + // check for testhost.exe in sourceDirectory. If not found, check in nuget folder. + if (_fileHelper.Exists(fullExePath)) { - EqtTrace.Verbose("DotnetTestHostmanager: User specified custom path to dotnet host: '{0}'.", this.dotnetHostPath); + EqtTrace.Verbose($"DotnetTestHostManager: {exeName} found at path: " + fullExePath); + startInfo.FileName = fullExePath; + testHostExeFound = true; } - - // Try find testhost.exe (or the architecture specific version). We ship those ngened executables for Windows because they have faster startup time. We ship them only for some platforms. - // When user specified path to dotnet.exe don't try to find the exexutable, because we will always use the testhost.dll together with their dotnet.exe. - // We use dotnet.exe on Windows/ARM. - bool testHostExeFound = false; - if (!useCustomDotnetHostpath - && this.platformEnvironment.OperatingSystem.Equals(PlatformOperatingSystem.Windows) - - // testhost*.exe are build for netcoreapp2.1 and are not able to search for the correct runtime in case of x64/x86 on arm because the new logic(registry lookup) - // was added in since netcoreapp3.0. On arm we cannot rely on apphost and we'll use dotnet.exe muxer - && !IsWinOnArm()) + else { - // testhost.exe is 64-bit and has no suffix other versions have architecture suffix. - var exeName = this.architecture == Architecture.X64 || this.architecture == Architecture.Default || this.architecture == Architecture.AnyCPU - ? "testhost.exe" - : $"testhost.{this.architecture.ToString().ToLowerInvariant()}.exe"; - - var fullExePath = Path.Combine(sourceDirectory, exeName); - - // check for testhost.exe in sourceDirectory. If not found, check in nuget folder. - if (this.fileHelper.Exists(fullExePath)) - { - EqtTrace.Verbose($"DotnetTestHostManager: {exeName} found at path: " + fullExePath); - startInfo.FileName = fullExePath; - testHostExeFound = true; - } - else + // Check if testhost.dll is found in nuget folder or next to the test.dll, and use that to locate testhost.exe that is in the build folder in the same Nuget package. + testHostPath = GetTestHostPath(runtimeConfigDevPath, depsFilePath, sourceDirectory); + if (!string.IsNullOrWhiteSpace(testHostPath) && testHostPath.IndexOf("microsoft.testplatform.testhost", StringComparison.OrdinalIgnoreCase) >= 0) { - // Check if testhost.dll is found in nuget folder or next to the test.dll, and use that to locate testhost.exe that is in the build folder in the same Nuget package. - testHostPath = this.GetTestHostPath(runtimeConfigDevPath, depsFilePath, sourceDirectory); - if (!string.IsNullOrWhiteSpace(testHostPath) && testHostPath.IndexOf("microsoft.testplatform.testhost", StringComparison.OrdinalIgnoreCase) >= 0) - { - // testhost.dll is present in path {testHostNugetRoot}\lib\netcoreapp2.1\testhost.dll - // testhost.(x86).exe is present in location {testHostNugetRoot}\build\netcoreapp2.1\{x86/x64}\{testhost.x86.exe/testhost.exe} - var folderName = this.architecture == Architecture.X64 || this.architecture == Architecture.Default || this.architecture == Architecture.AnyCPU - ? Architecture.X64.ToString().ToLowerInvariant() - : this.architecture.ToString().ToLowerInvariant(); + // testhost.dll is present in path {testHostNugetRoot}\lib\netcoreapp2.1\testhost.dll + // testhost.(x86).exe is present in location {testHostNugetRoot}\build\netcoreapp2.1\{x86/x64}\{testhost.x86.exe/testhost.exe} + var folderName = _architecture == Architecture.X64 || _architecture == Architecture.Default || _architecture == Architecture.AnyCPU + ? Architecture.X64.ToString().ToLowerInvariant() + : _architecture.ToString().ToLowerInvariant(); - var testHostNugetRoot = new DirectoryInfo(testHostPath).Parent.Parent.Parent; + var testHostNugetRoot = new DirectoryInfo(testHostPath).Parent.Parent.Parent; #if DOTNET_BUILD_FROM_SOURCE - var testHostExeNugetPath = Path.Combine(testHostNugetRoot.FullName, "build", "net6.0", folderName, exeName); + var testHostExeNugetPath = Path.Combine(testHostNugetRoot.FullName, "build", "net6.0", folderName, exeName); #else - var testHostExeNugetPath = Path.Combine(testHostNugetRoot.FullName, "build", "netcoreapp2.1", folderName, exeName); + var testHostExeNugetPath = Path.Combine(testHostNugetRoot.FullName, "build", "netcoreapp2.1", folderName, exeName); #endif - if (this.fileHelper.Exists(testHostExeNugetPath)) - { - EqtTrace.Verbose("DotnetTestHostManager: Testhost.exe/testhost.x86.exe found at path: " + testHostExeNugetPath); - startInfo.FileName = testHostExeNugetPath; - testHostExeFound = true; - } + if (_fileHelper.Exists(testHostExeNugetPath)) + { + EqtTrace.Verbose("DotnetTestHostManager: Testhost.exe/testhost.x86.exe found at path: " + testHostExeNugetPath); + startInfo.FileName = testHostExeNugetPath; + testHostExeFound = true; } } } + } - if (!testHostExeFound) + if (!testHostExeFound) + { + // We did not find testhost.exe, either it did not exist, or we are not on Windows, or the user forced a custom path to dotnet. So we will try + // to find testhost.dll from the runtime config and deps.json. + if (string.IsNullOrEmpty(testHostPath)) { - // We did not find testhost.exe, either it did not exist, or we are not on Windows, or the user forced a custom path to dotnet. So we will try - // to find testhost.dll from the runtime config and deps.json. - if (string.IsNullOrEmpty(testHostPath)) - { - testHostPath = this.GetTestHostPath(runtimeConfigDevPath, depsFilePath, sourceDirectory); - } + testHostPath = GetTestHostPath(runtimeConfigDevPath, depsFilePath, sourceDirectory); + } - if (string.IsNullOrEmpty(testHostPath)) - { - // We still did not find testhost.dll. Try finding it next to vstest.console, (or in next to vstest.console ./TestHost for .NET Framework) + if (string.IsNullOrEmpty(testHostPath)) + { + // We still did not find testhost.dll. Try finding it next to vstest.console, (or in next to vstest.console ./TestHost for .NET Framework) #if NETFRAMEWORK - var testHostNextToRunner = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "TestHost", "testhost.dll"); + var testHostNextToRunner = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "TestHost", "testhost.dll"); #else - var testHostNextToRunner = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "testhost.dll"); + var testHostNextToRunner = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "testhost.dll"); #endif - if (this.fileHelper.Exists(testHostNextToRunner)) + if (_fileHelper.Exists(testHostNextToRunner)) + { + EqtTrace.Verbose("DotnetTestHostManager: Found testhost.dll next to runner executable: {0}.", testHostNextToRunner); + testHostPath = testHostNextToRunner; + + // Because we could not find the testhost based on the project reference, or next to the tested dll, + // it is most likely not referenced from it, or the .dll is unmanaged. + // + // Add additional deps, that describes the dependencies of testhost.dll, which will merge with deps.json + // if the process provided any, or will be used by itself if none was provided. + var testhostDeps = Path.Combine(Path.GetDirectoryName(testHostNextToRunner), "testhost.deps.json"); + string argsToAdd = " --additional-deps " + testhostDeps.AddDoubleQuote(); + args += argsToAdd; + EqtTrace.Verbose("DotnetTestHostmanager: Adding {0} in args", argsToAdd); + + // Additional deps will contain relative paths, tell the process to search for the dlls also + // next to the testhost.dll. The additional deps file is specially crafted to keep all the + // .dlls in the root folder, by only referencing libraries, and setting the path to "/". + // Without this, e.g. using the normal deps.json that is generated when testhost.dll is built, + // dotnet would consider additional deps path as the root of a Nuget package source, + // and would try to locate the dlls in a more complicated folder structure, and would fail to + // find those dependencies. + // + // If they were in the base path (where the test dll is) it would work + // fine, because in base folder, dotnet searches directly in that folder, but not in probing paths. + var testHostProbingPath = Path.GetDirectoryName(testHostNextToRunner); + argsToAdd = " --additionalprobingpath " + testHostProbingPath.AddDoubleQuote(); + args += argsToAdd; + EqtTrace.Verbose("DotnetTestHostmanager: Adding {0} in args", argsToAdd); + + if (!runtimeConfigFound) { - EqtTrace.Verbose("DotnetTestHostManager: Found testhost.dll next to runner executable: {0}.", testHostNextToRunner); - testHostPath = testHostNextToRunner; - - // Because we could not find the testhost based on the project reference, or next to the tested dll, - // it is most likely not referenced from it, or the .dll is unmanaged. + // When runtime config is not found, we don't know which version exactly should be selected for the runtime. + // This can happen when the test project is .NET (Core) but does not have EXE output type, or when the dll is native. + // + // When the project is .NET (Core) we can look at the TargetFramework and gather the rough version from there. We then + // provide a runtime config targetting that version. It rolls forward on the minor version by default, so the latest + // version that is present will be selected in that range. Same as if you had EXE and no special settings. + // E.g. the dll targets netcoreapp3.1, we get 3.1 from the attribute in the Dll, and provide testhost-3.1.runtimeconfig.json + // this will resolve to 3.1.17 runtime because that is the latest installed on the system. + // + // + // In the other case, where the Dll is native, we take the a runtime config that will roll forward to the latest version + // because we don't care on which version we will run, and rolling forward gives us the best chance of findind some runtime. // - // Add additional deps, that describes the dependencies of testhost.dll, which will merge with deps.json - // if the process provided any, or will be used by itself if none was provided. - var testhostDeps = Path.Combine(Path.GetDirectoryName(testHostNextToRunner), "testhost.deps.json"); - string argsToAdd = " --additional-deps " + testhostDeps.AddDoubleQuote(); - args += argsToAdd; - EqtTrace.Verbose("DotnetTestHostmanager: Adding {0} in args", argsToAdd); - - // Additional deps will contain relative paths, tell the process to search for the dlls also - // next to the testhost.dll. The additional deps file is specially crafted to keep all the - // .dlls in the root folder, by only referencing libraries, and setting the path to "/". - // Without this, e.g. using the normal deps.json that is generated when testhost.dll is built, - // dotnet would consider additional deps path as the root of a Nuget package source, - // and would try to locate the dlls in a more complicated folder structure, and would fail to - // find those dependencies. // - // If they were in the base path (where the test dll is) it would work - // fine, because in base folder, dotnet searches directly in that folder, but not in probing paths. - var testHostProbingPath = Path.GetDirectoryName(testHostNextToRunner); - argsToAdd = " --additionalprobingpath " + testHostProbingPath.AddDoubleQuote(); + // There are 2 options how to provide the runtime version. Using --runtimeconfig, and --fx-version. The --fx-version does + // not roll forward even when the --roll-forward option is provided (or --roll-forward-on-no-candidate-fx for netcoreapp2.1) + // and we don't know the exact version we want to use. So the only option for us is to use the runtimeconfig.json. + // + // + // TODO: This version check is a hack, when the target framework is figured out it tries to unify to a single common framework + // even if there are incompatible frameworks (e.g any .NET Framwork assembly and any .NET (Core) assembly). Those incompatibilities + // will fall back to a common default framework. And that framework (stored in Framework.DefaultFramework) depends on compile time variables + // so depending on the version of vstest.console you are using, you will get a different value. This value for vstest.console.exe (under VS) + // is .NET Framework 4, but for vstest.console.dll (under dotnet test) is .NET Core 1.0. Those values are also valid values, so we have no idea + // if user actually provided a .NET Core 1.0 dll, or we are using fallback because we are running under vstest.console, and there is conflict, + // or if user provided native dll which does not have the attribute (that we read via PEReader). + // + // Another aspect of this is that we are unifying the dlls, so until we add per assembly data, this would be less accurate than using runtimeconfig.json + // but we can work around that by 1) changing how we schedule runners, to make sure we can process more that 1 type of assembly in vstest.console and + // 2) making sure we still make the project executable (and so we actually do get runtimeconfig unless the user tries hard to not make the test and EXE). + var suffix = _targetFramework.Version == "1.0.0.0" ? "latest" : $"{new Version(_targetFramework.Version).Major}.{new Version(_targetFramework.Version).Minor}"; + var testhostRuntimeConfig = Path.Combine(Path.GetDirectoryName(testHostNextToRunner), $"testhost-{suffix}.runtimeconfig.json"); + argsToAdd = " --runtimeconfig " + testhostRuntimeConfig.AddDoubleQuote(); args += argsToAdd; EqtTrace.Verbose("DotnetTestHostmanager: Adding {0} in args", argsToAdd); - - if (!runtimeConfigFound) - { - // When runtime config is not found, we don't know which version exactly should be selected for the runtime. - // This can happen when the test project is .NET (Core) but does not have EXE output type, or when the dll is native. - // - // When the project is .NET (Core) we can look at the TargetFramework and gather the rough version from there. We then - // provide a runtime config targetting that version. It rolls forward on the minor version by default, so the latest - // version that is present will be selected in that range. Same as if you had EXE and no special settings. - // E.g. the dll targets netcoreapp3.1, we get 3.1 from the attribute in the Dll, and provide testhost-3.1.runtimeconfig.json - // this will resolve to 3.1.17 runtime because that is the latest installed on the system. - // - // - // In the other case, where the Dll is native, we take the a runtime config that will roll forward to the latest version - // because we don't care on which version we will run, and rolling forward gives us the best chance of findind some runtime. - // - // - // There are 2 options how to provide the runtime version. Using --runtimeconfig, and --fx-version. The --fx-version does - // not roll forward even when the --roll-forward option is provided (or --roll-forward-on-no-candidate-fx for netcoreapp2.1) - // and we don't know the exact version we want to use. So the only option for us is to use the runtimeconfig.json. - // - // - // TODO: This version check is a hack, when the target framework is figured out it tries to unify to a single common framework - // even if there are incompatible frameworks (e.g any .NET Framwork assembly and any .NET (Core) assembly). Those incompatibilities - // will fall back to a common default framework. And that framework (stored in Framework.DefaultFramework) depends on compile time variables - // so depending on the version of vstest.console you are using, you will get a different value. This value for vstest.console.exe (under VS) - // is .NET Framework 4, but for vstest.console.dll (under dotnet test) is .NET Core 1.0. Those values are also valid values, so we have no idea - // if user actually provided a .NET Core 1.0 dll, or we are using fallback because we are running under vstest.console, and there is conflict, - // or if user provided native dll which does not have the attribute (that we read via PEReader). - // - // Another aspect of this is that we are unifying the dlls, so until we add per assembly data, this would be less accurate than using runtimeconfig.json - // but we can work around that by 1) changing how we schedule runners, to make sure we can process more that 1 type of assembly in vstest.console and - // 2) making sure we still make the project executable (and so we actually do get runtimeconfig unless the user tries hard to not make the test and EXE). - var suffix = this.targetFramework.Version == "1.0.0.0" ? "latest" : $"{new Version(this.targetFramework.Version).Major}.{new Version(this.targetFramework.Version).Minor}"; - var testhostRuntimeConfig = Path.Combine(Path.GetDirectoryName(testHostNextToRunner), $"testhost-{suffix}.runtimeconfig.json"); - argsToAdd = " --runtimeconfig " + testhostRuntimeConfig.AddDoubleQuote(); - args += argsToAdd; - EqtTrace.Verbose("DotnetTestHostmanager: Adding {0} in args", argsToAdd); - } } } + } - if (string.IsNullOrEmpty(testHostPath)) - { - throw new TestPlatformException("Could not find testhost"); - } + if (string.IsNullOrEmpty(testHostPath)) + { + throw new TestPlatformException("Could not find testhost"); + } - // We silently force x64 only if the target architecture is the default one and is not specified by user - // through --arch or runsettings or -- RunConfiguration.TargetPlatform=arch - bool forceToX64 = SilentlyForceToX64() && this.runsettingHelper.IsDefaultTargetArchitecture; - EqtTrace.Verbose($"DotnetTestHostmanager: Current process architetcure '{this.processHelper.GetCurrentProcessArchitecture()}'"); - bool isSameArchitecture = IsSameArchitecture(this.architecture, this.processHelper.GetCurrentProcessArchitecture()); - var currentProcessPath = this.processHelper.GetCurrentProcessFileName(); - bool isRunningWithDotnetMuxer = IsRunningWithDotnetMuxer(currentProcessPath); - if (useCustomDotnetHostpath) - { - startInfo.FileName = this.dotnetHostPath; - } + // We silently force x64 only if the target architecture is the default one and is not specified by user + // through --arch or runsettings or -- RunConfiguration.TargetPlatform=arch + bool forceToX64 = SilentlyForceToX64() && _runsettingHelper.IsDefaultTargetArchitecture; + EqtTrace.Verbose($"DotnetTestHostmanager: Current process architetcure '{_processHelper.GetCurrentProcessArchitecture()}'"); + bool isSameArchitecture = IsSameArchitecture(_architecture, _processHelper.GetCurrentProcessArchitecture()); + var currentProcessPath = _processHelper.GetCurrentProcessFileName(); + bool isRunningWithDotnetMuxer = IsRunningWithDotnetMuxer(currentProcessPath); + if (useCustomDotnetHostpath) + { + startInfo.FileName = _dotnetHostPath; + } - // If already running with the dotnet executable and the architecture is compatible, use it; otherwise search the correct muxer architecture on disk. - else if (isRunningWithDotnetMuxer && isSameArchitecture && !forceToX64) + // If already running with the dotnet executable and the architecture is compatible, use it; otherwise search the correct muxer architecture on disk. + else if (isRunningWithDotnetMuxer && isSameArchitecture && !forceToX64) + { + EqtTrace.Verbose("DotnetTestHostmanager.LaunchTestHostAsync: Compatible muxer architecture of running process '{0}' and target architecture '{1}'", _processHelper.GetCurrentProcessArchitecture(), _architecture); + startInfo.FileName = currentProcessPath; + } + else + { + PlatformArchitecture targetArchitecture = TranslateToPlatformArchitecture(_architecture); + EqtTrace.Verbose($"DotnetTestHostmanager: Searching muxer for the architecture '{targetArchitecture}', OS '{_platformEnvironment.OperatingSystem}' framework '{_targetFramework}' SDK platform architecture '{_platformEnvironment.Architecture}'"); + if (forceToX64) { - EqtTrace.Verbose("DotnetTestHostmanager.LaunchTestHostAsync: Compatible muxer architecture of running process '{0}' and target architecture '{1}'", this.processHelper.GetCurrentProcessArchitecture(), this.architecture); - startInfo.FileName = currentProcessPath; + EqtTrace.Verbose($"DotnetTestHostmanager: Forcing the search to x64 architecure, IsDefaultTargetArchitecture '{_runsettingHelper.IsDefaultTargetArchitecture}' OS '{_platformEnvironment.OperatingSystem}' framework '{_targetFramework}'"); } - else - { - PlatformArchitecture targetArchitecture = TranslateToPlatformArchitecture(this.architecture); - EqtTrace.Verbose($"DotnetTestHostmanager: Searching muxer for the architecture '{targetArchitecture}', OS '{this.platformEnvironment.OperatingSystem}' framework '{this.targetFramework}' SDK platform architecture '{this.platformEnvironment.Architecture}'"); - if (forceToX64) - { - EqtTrace.Verbose($"DotnetTestHostmanager: Forcing the search to x64 architecure, IsDefaultTargetArchitecture '{this.runsettingHelper.IsDefaultTargetArchitecture}' OS '{this.platformEnvironment.OperatingSystem}' framework '{this.targetFramework}'"); - } - - PlatformArchitecture finalTargetArchitecture = forceToX64 ? PlatformArchitecture.X64 : targetArchitecture; - if (!this.dotnetHostHelper.TryGetDotnetPathByArchitecture(finalTargetArchitecture, out string muxerPath)) - { - string message = string.Format(Resources.NoDotnetMuxerFoundForArchitecture, $"dotnet{(this.platformEnvironment.OperatingSystem == PlatformOperatingSystem.Windows ? ".exe" : string.Empty)}", finalTargetArchitecture.ToString()); - EqtTrace.Error(message); - throw new TestPlatformException(message); - } - startInfo.FileName = muxerPath; + PlatformArchitecture finalTargetArchitecture = forceToX64 ? PlatformArchitecture.X64 : targetArchitecture; + if (!_dotnetHostHelper.TryGetDotnetPathByArchitecture(finalTargetArchitecture, out string muxerPath)) + { + string message = string.Format(Resources.NoDotnetMuxerFoundForArchitecture, $"dotnet{(_platformEnvironment.OperatingSystem == PlatformOperatingSystem.Windows ? ".exe" : string.Empty)}", finalTargetArchitecture.ToString()); + EqtTrace.Error(message); + throw new TestPlatformException(message); } - EqtTrace.Verbose("DotnetTestHostmanager: Full path of testhost.dll is {0}", testHostPath); - args = "exec" + args; - args += " " + testHostPath.AddDoubleQuote(); + startInfo.FileName = muxerPath; } - EqtTrace.Verbose("DotnetTestHostmanager: Full path of host exe is {0}", startInfo.FileName); + EqtTrace.Verbose("DotnetTestHostmanager: Full path of testhost.dll is {0}", testHostPath); + args = "exec" + args; + args += " " + testHostPath.AddDoubleQuote(); + } + + EqtTrace.Verbose("DotnetTestHostmanager: Full path of host exe is {0}", startInfo.FileName); - args += " " + connectionInfo.ToCommandLineOptions(); + args += " " + connectionInfo.ToCommandLineOptions(); - // Create a additional probing path args with Nuget.Client - // args += "--additionalprobingpath xxx" - // TODO this may be required in ASP.net, requires validation + // Create a additional probing path args with Nuget.Client + // args += "--additionalprobingpath xxx" + // TODO this may be required in ASP.net, requires validation - // Sample command line for the spawned test host - // "D:\dd\gh\Microsoft\vstest\tools\dotnet\dotnet.exe" exec - // --runtimeconfig G:\tmp\netcore-test\bin\Debug\netcoreapp1.0\netcore-test.runtimeconfig.json - // --depsfile G:\tmp\netcore-test\bin\Debug\netcoreapp1.0\netcore-test.deps.json - // --additionalprobingpath C:\Users\username\.nuget\packages\ - // G:\nuget-package-path\microsoft.testplatform.testhost\version\**\testhost.dll - // G:\tmp\netcore-test\bin\Debug\netcoreapp1.0\netcore-test.dll - startInfo.Arguments = args; - startInfo.EnvironmentVariables = environmentVariables ?? new Dictionary(); + // Sample command line for the spawned test host + // "D:\dd\gh\Microsoft\vstest\tools\dotnet\dotnet.exe" exec + // --runtimeconfig G:\tmp\netcore-test\bin\Debug\netcoreapp1.0\netcore-test.runtimeconfig.json + // --depsfile G:\tmp\netcore-test\bin\Debug\netcoreapp1.0\netcore-test.deps.json + // --additionalprobingpath C:\Users\username\.nuget\packages\ + // G:\nuget-package-path\microsoft.testplatform.testhost\version\**\testhost.dll + // G:\tmp\netcore-test\bin\Debug\netcoreapp1.0\netcore-test.dll + startInfo.Arguments = args; + startInfo.EnvironmentVariables = environmentVariables ?? new Dictionary(); - // If we're running using custom apphost we need to set DOTNET_ROOT/DOTNET_ROOT(x86) - // We're setting it inside SDK to support private install scenario. - // i.e. I've got only private install and no global installation, in this case apphost needs to use env var to locate runtime. - if (testHostExeFound) + // If we're running using custom apphost we need to set DOTNET_ROOT/DOTNET_ROOT(x86) + // We're setting it inside SDK to support private install scenario. + // i.e. I've got only private install and no global installation, in this case apphost needs to use env var to locate runtime. + if (testHostExeFound) + { + string prefix = "VSTEST_WINAPPHOST_"; + string dotnetRootEnvName = $"{prefix}DOTNET_ROOT(x86)"; + var dotnetRoot = _environmentVariableHelper.GetEnvironmentVariable(dotnetRootEnvName); + if (dotnetRoot is null) { - string prefix = "VSTEST_WINAPPHOST_"; - string dotnetRootEnvName = $"{prefix}DOTNET_ROOT(x86)"; - var dotnetRoot = this.environmentVariableHelper.GetEnvironmentVariable(dotnetRootEnvName); - if (dotnetRoot is null) - { - dotnetRootEnvName = $"{prefix}DOTNET_ROOT"; - dotnetRoot = this.environmentVariableHelper.GetEnvironmentVariable(dotnetRootEnvName); - } + dotnetRootEnvName = $"{prefix}DOTNET_ROOT"; + dotnetRoot = _environmentVariableHelper.GetEnvironmentVariable(dotnetRootEnvName); + } - if (dotnetRoot != null) - { - EqtTrace.Verbose($"DotnetTestHostmanager.LaunchTestHostAsync: Found '{dotnetRootEnvName}' in env variables, value '{dotnetRoot}', forwarding to '{dotnetRootEnvName.Replace(prefix, string.Empty)}'"); - startInfo.EnvironmentVariables.Add(dotnetRootEnvName.Replace(prefix, string.Empty), dotnetRoot); - } - else - { - EqtTrace.Verbose($"DotnetTestHostmanager.LaunchTestHostAsync: Prefix '{prefix}*' not found in env variables"); - } + if (dotnetRoot != null) + { + EqtTrace.Verbose($"DotnetTestHostmanager.LaunchTestHostAsync: Found '{dotnetRootEnvName}' in env variables, value '{dotnetRoot}', forwarding to '{dotnetRootEnvName.Replace(prefix, string.Empty)}'"); + startInfo.EnvironmentVariables.Add(dotnetRootEnvName.Replace(prefix, string.Empty), dotnetRoot); } + else + { + EqtTrace.Verbose($"DotnetTestHostmanager.LaunchTestHostAsync: Prefix '{prefix}*' not found in env variables"); + } + } - startInfo.WorkingDirectory = sourceDirectory; + startInfo.WorkingDirectory = sourceDirectory; - return startInfo; + return startInfo; - bool IsRunningWithDotnetMuxer(string currentProcessPath) - => currentProcessPath.EndsWith("dotnet", StringComparison.OrdinalIgnoreCase) || - currentProcessPath.EndsWith("dotnet.exe", StringComparison.OrdinalIgnoreCase); + bool IsRunningWithDotnetMuxer(string currentProcessPath) + => currentProcessPath.EndsWith("dotnet", StringComparison.OrdinalIgnoreCase) || + currentProcessPath.EndsWith("dotnet.exe", StringComparison.OrdinalIgnoreCase); - bool IsWinOnArm() + bool IsWinOnArm() + { + bool isWinOnArm = false; + if (_platformEnvironment.OperatingSystem == PlatformOperatingSystem.Windows) { - bool isWinOnArm = false; - if (this.platformEnvironment.OperatingSystem == PlatformOperatingSystem.Windows) + using IRegistryKey hklm = _windowsRegistryHelper.OpenBaseKey(RegistryHive.LocalMachine, Environment.Is64BitProcess ? RegistryView.Registry64 : RegistryView.Registry32); + if (hklm != null) { - using (IRegistryKey hklm = this.windowsRegistryHelper.OpenBaseKey(RegistryHive.LocalMachine, Environment.Is64BitProcess ? RegistryView.Registry64 : RegistryView.Registry32)) + using IRegistryKey environment = hklm.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Session Manager\Environment"); + if (environment != null) { - if (hklm != null) + var processorArchitecture = environment.GetValue("PROCESSOR_ARCHITECTURE"); + if (processorArchitecture != null) { - using (IRegistryKey environment = hklm.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Session Manager\Environment")) - { - if (environment != null) - { - var processorArchitecture = environment.GetValue("PROCESSOR_ARCHITECTURE"); - if (processorArchitecture != null) - { - EqtTrace.Verbose($"DotnetTestHostmanager.IsWinOnArm: Current PROCESSOR_ARCHITECTURE from registry '{processorArchitecture}'"); - isWinOnArm = processorArchitecture.ToString().ToLowerInvariant().Contains("arm"); - } - } - } + EqtTrace.Verbose($"DotnetTestHostmanager.IsWinOnArm: Current PROCESSOR_ARCHITECTURE from registry '{processorArchitecture}'"); + isWinOnArm = processorArchitecture.ToString().ToLowerInvariant().Contains("arm"); } } } - - EqtTrace.Verbose($"DotnetTestHostmanager.IsWinOnArm: Is Windows on ARM '{isWinOnArm}'"); - return isWinOnArm; } - PlatformArchitecture TranslateToPlatformArchitecture(Architecture targetArchitecture) - { - switch (targetArchitecture) - { - case Architecture.X86: - return PlatformArchitecture.X86; - case Architecture.X64: - return PlatformArchitecture.X64; - case Architecture.ARM: - return PlatformArchitecture.ARM; - case Architecture.ARM64: - return PlatformArchitecture.ARM64; - case Architecture.AnyCPU: - case Architecture.Default: - default: - break; - } - - throw new TestPlatformException($"Invalid target architecture '{targetArchitecture}'"); - } + EqtTrace.Verbose($"DotnetTestHostmanager.IsWinOnArm: Is Windows on ARM '{isWinOnArm}'"); + return isWinOnArm; + } - bool IsSameArchitecture(Architecture targetArchitecture, PlatformArchitecture platformAchitecture) + PlatformArchitecture TranslateToPlatformArchitecture(Architecture targetArchitecture) + { + switch (targetArchitecture) { - switch (targetArchitecture) - { - case Architecture.X86: - return platformAchitecture == PlatformArchitecture.X86; - case Architecture.X64: - return platformAchitecture == PlatformArchitecture.X64; - case Architecture.ARM: - return platformAchitecture == PlatformArchitecture.ARM; - case Architecture.ARM64: - return platformAchitecture == PlatformArchitecture.ARM64; - case Architecture.AnyCPU: - case Architecture.Default: - default: - throw new TestPlatformException($"Invalid target architecture '{targetArchitecture}'"); - } + case Architecture.X86: + return PlatformArchitecture.X86; + case Architecture.X64: + return PlatformArchitecture.X64; + case Architecture.ARM: + return PlatformArchitecture.ARM; + case Architecture.ARM64: + return PlatformArchitecture.ARM64; + case Architecture.AnyCPU: + case Architecture.Default: + default: + break; } - bool SilentlyForceToX64() - { - // We need to force x64 in some scenario - // https://github.com/dotnet/sdk/blob/main/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets#L140-L143 - - // If we are running on an M1 with a native SDK and the TFM is < 6.0, we have to use a x64 apphost since there are no osx-arm64 apphosts previous to .NET 6.0. - if (this.platformEnvironment.OperatingSystem == PlatformOperatingSystem.OSX && - this.platformEnvironment.Architecture == PlatformArchitecture.ARM64 && - new Version(this.targetFramework.Version).Major < 6) - { - return true; - } - - // If we are running on win-arm64 and the TFM is < 5.0, we have to use a x64 apphost since there are no win-arm64 apphosts previous to .NET 5.0. - if (this.platformEnvironment.OperatingSystem == PlatformOperatingSystem.Windows && - this.platformEnvironment.Architecture == PlatformArchitecture.ARM64 && - new Version(this.targetFramework.Version).Major < 5) - { - return true; - } - - return false; - } + throw new TestPlatformException($"Invalid target architecture '{targetArchitecture}'"); } - /// - public IEnumerable GetTestPlatformExtensions(IEnumerable sources, IEnumerable extensions) + static bool IsSameArchitecture(Architecture targetArchitecture, PlatformArchitecture platformAchitecture) + => targetArchitecture switch + { + Architecture.X86 => platformAchitecture == PlatformArchitecture.X86, + Architecture.X64 => platformAchitecture == PlatformArchitecture.X64, + Architecture.ARM => platformAchitecture == PlatformArchitecture.ARM, + Architecture.ARM64 => platformAchitecture == PlatformArchitecture.ARM64, + _ => throw new TestPlatformException($"Invalid target architecture '{targetArchitecture}'"), + }; + + bool SilentlyForceToX64() { - List extensionPaths = new List(); - var sourceDirectory = Path.GetDirectoryName(sources.Single()); + // We need to force x64 in some scenario + // https://github.com/dotnet/sdk/blob/main/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets#L140-L143 - if (!string.IsNullOrEmpty(sourceDirectory) && this.fileHelper.DirectoryExists(sourceDirectory)) + // If we are running on an M1 with a native SDK and the TFM is < 6.0, we have to use a x64 apphost since there are no osx-arm64 apphosts previous to .NET 6.0. + if (_platformEnvironment.OperatingSystem == PlatformOperatingSystem.OSX && + _platformEnvironment.Architecture == PlatformArchitecture.ARM64 && + new Version(_targetFramework.Version).Major < 6) { - extensionPaths.AddRange(this.fileHelper.EnumerateFiles(sourceDirectory, SearchOption.TopDirectoryOnly, TestAdapterRegexPattern)); + return true; } - return extensionPaths; + // If we are running on win-arm64 and the TFM is < 5.0, we have to use a x64 apphost since there are no win-arm64 apphosts previous to .NET 5.0. + return _platformEnvironment.OperatingSystem == PlatformOperatingSystem.Windows && + _platformEnvironment.Architecture == PlatformArchitecture.ARM64 && + new Version(_targetFramework.Version).Major < 5; } + } - /// - public IEnumerable GetTestSources(IEnumerable sources) + /// + public IEnumerable GetTestPlatformExtensions(IEnumerable sources, IEnumerable extensions) + { + List extensionPaths = new(); + var sourceDirectory = Path.GetDirectoryName(sources.Single()); + + if (!string.IsNullOrEmpty(sourceDirectory) && _fileHelper.DirectoryExists(sourceDirectory)) { - // We do not have scenario where netcore tests are deployed to remote machine, so no need to update sources - return sources; + extensionPaths.AddRange(_fileHelper.EnumerateFiles(sourceDirectory, SearchOption.TopDirectoryOnly, TestAdapterRegexPattern)); } - /// - public bool CanExecuteCurrentRunConfiguration(string runsettingsXml) - { - var config = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettingsXml); - var framework = config.TargetFramework; + return extensionPaths; + } - // This is expected to be called once every run so returning a new instance every time. - if (framework.Name.IndexOf("netstandard", StringComparison.OrdinalIgnoreCase) >= 0 - || framework.Name.IndexOf("netcoreapp", StringComparison.OrdinalIgnoreCase) >= 0 - || framework.Name.IndexOf("net5", StringComparison.OrdinalIgnoreCase) >= 0) - { - return true; - } + /// + public IEnumerable GetTestSources(IEnumerable sources) + { + // We do not have scenario where netcore tests are deployed to remote machine, so no need to update sources + return sources; + } - return false; - } + /// + public bool CanExecuteCurrentRunConfiguration(string runsettingsXml) + { + var config = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettingsXml); + var framework = config.TargetFramework; - /// - public Task CleanTestHostAsync(CancellationToken cancellationToken) + // This is expected to be called once every run so returning a new instance every time. + return framework.Name.IndexOf("netstandard", StringComparison.OrdinalIgnoreCase) >= 0 + || framework.Name.IndexOf("netcoreapp", StringComparison.OrdinalIgnoreCase) >= 0 + || framework.Name.IndexOf("net5", StringComparison.OrdinalIgnoreCase) >= 0; + } + + /// + public Task CleanTestHostAsync(CancellationToken cancellationToken) + { + try { - try - { - this.processHelper.TerminateProcess(this.testHostProcess); - } - catch (Exception ex) - { - EqtTrace.Warning("DotnetTestHostManager: Unable to terminate test host process: " + ex); - } + _processHelper.TerminateProcess(_testHostProcess); + } + catch (Exception ex) + { + EqtTrace.Warning("DotnetTestHostManager: Unable to terminate test host process: " + ex); + } - this.testHostProcess?.Dispose(); + _testHostProcess?.Dispose(); - return Task.FromResult(true); - } + return Task.FromResult(true); + } + + /// + public bool AttachDebuggerToTestHost() + { + return _customTestHostLauncher is ITestHostLauncher2 launcher + && launcher.AttachDebuggerToProcess(_testHostProcess.Id); + } + + /// + /// Raises HostLaunched event + /// + /// host provider event args + private void OnHostLaunched(HostProviderEventArgs e) + { + HostLaunched.SafeInvoke(this, e, "HostProviderEvents.OnHostLaunched"); + } - /// - public bool AttachDebuggerToTestHost() + /// + /// Raises HostExited event + /// + /// host provider event args + private void OnHostExited(HostProviderEventArgs e) + { + if (!_hostExitedEventRaised) { - return this.customTestHostLauncher is ITestHostLauncher2 launcher - && launcher.AttachDebuggerToProcess(this.testHostProcess.Id); + _hostExitedEventRaised = true; + EqtTrace.Verbose("DotnetTestHostManager.OnHostExited: invoking OnHostExited callback"); + HostExited.SafeInvoke(this, e, "HostProviderEvents.OnHostExited"); } - - /// - /// Raises HostLaunched event - /// - /// host provider event args - private void OnHostLaunched(HostProviderEventArgs e) + else { - this.HostLaunched.SafeInvoke(this, e, "HostProviderEvents.OnHostLaunched"); + EqtTrace.Verbose("DotnetTestHostManager.OnHostExited: exit event was already raised, skipping"); } + } - /// - /// Raises HostExited event - /// - /// host provider event args - private void OnHostExited(HostProviderEventArgs e) + private bool LaunchHost(TestProcessStartInfo testHostStartInfo, CancellationToken cancellationToken) + { + _testHostProcessStdError = new StringBuilder(0, CoreUtilities.Constants.StandardErrorMaxLength); + + // We launch the test host process here if we're on the normal test running workflow. + // If we're debugging and we have access to the newest version of the testhost launcher + // interface we launch it here as well, but we expect to attach later to the test host + // process by using its PID. + // For every other workflow (e.g.: profiling) we ask the IDE to launch the custom test + // host for us. In the profiling case this is needed because then the IDE sets some + // additional environmental variables for us to help with probing. + if ((_customTestHostLauncher == null) + || (_customTestHostLauncher.IsDebug + && _customTestHostLauncher is ITestHostLauncher2)) { - if (!this.hostExitedEventRaised) - { - this.hostExitedEventRaised = true; - EqtTrace.Verbose("DotnetTestHostManager.OnHostExited: invoking OnHostExited callback"); - this.HostExited.SafeInvoke(this, e, "HostProviderEvents.OnHostExited"); - } - else - { - EqtTrace.Verbose("DotnetTestHostManager.OnHostExited: exit event was already raised, skipping"); - } + EqtTrace.Verbose("DotnetTestHostManager: Starting process '{0}' with command line '{1}'", testHostStartInfo.FileName, testHostStartInfo.Arguments); + + cancellationToken.ThrowIfCancellationRequested(); + _testHostProcess = _processHelper.LaunchProcess( + testHostStartInfo.FileName, + testHostStartInfo.Arguments, + testHostStartInfo.WorkingDirectory, + testHostStartInfo.EnvironmentVariables, + ErrorReceivedCallback, + ExitCallBack, + null) as Process; } - - private bool LaunchHost(TestProcessStartInfo testHostStartInfo, CancellationToken cancellationToken) + else { - this.testHostProcessStdError = new StringBuilder(0, CoreUtilities.Constants.StandardErrorMaxLength); - - // We launch the test host process here if we're on the normal test running workflow. - // If we're debugging and we have access to the newest version of the testhost launcher - // interface we launch it here as well, but we expect to attach later to the test host - // process by using its PID. - // For every other workflow (e.g.: profiling) we ask the IDE to launch the custom test - // host for us. In the profiling case this is needed because then the IDE sets some - // additional environmental variables for us to help with probing. - if ((this.customTestHostLauncher == null) - || (this.customTestHostLauncher.IsDebug - && this.customTestHostLauncher is ITestHostLauncher2)) - { - EqtTrace.Verbose("DotnetTestHostManager: Starting process '{0}' with command line '{1}'", testHostStartInfo.FileName, testHostStartInfo.Arguments); - - cancellationToken.ThrowIfCancellationRequested(); - this.testHostProcess = this.processHelper.LaunchProcess( - testHostStartInfo.FileName, - testHostStartInfo.Arguments, - testHostStartInfo.WorkingDirectory, - testHostStartInfo.EnvironmentVariables, - this.ErrorReceivedCallback, - this.ExitCallBack, - null) as Process; - } - else - { - var processId = this.customTestHostLauncher.LaunchTestHost(testHostStartInfo, cancellationToken); - this.testHostProcess = Process.GetProcessById(processId); - this.processHelper.SetExitCallback(processId, this.ExitCallBack); - } + var processId = _customTestHostLauncher.LaunchTestHost(testHostStartInfo, cancellationToken); + _testHostProcess = Process.GetProcessById(processId); + _processHelper.SetExitCallback(processId, ExitCallBack); + } - this.OnHostLaunched(new HostProviderEventArgs("Test Runtime launched", 0, this.testHostProcess.Id)); + OnHostLaunched(new HostProviderEventArgs("Test Runtime launched", 0, _testHostProcess.Id)); - return this.testHostProcess != null; - } + return _testHostProcess != null; + } - private string GetTestHostPath(string runtimeConfigDevPath, string depsFilePath, string sourceDirectory) - { - string testHostPackageName = "microsoft.testplatform.testhost"; - string testHostPath = null; + private string GetTestHostPath(string runtimeConfigDevPath, string depsFilePath, string sourceDirectory) + { + string testHostPackageName = "microsoft.testplatform.testhost"; + string testHostPath = null; - if (this.fileHelper.Exists(depsFilePath)) + if (_fileHelper.Exists(depsFilePath)) + { + if (_fileHelper.Exists(runtimeConfigDevPath)) { - if (this.fileHelper.Exists(runtimeConfigDevPath)) + EqtTrace.Verbose("DotnetTestHostmanager: Reading file {0} to get path of testhost.dll", depsFilePath); + + // Get testhost relative path + using (var stream = _fileHelper.GetStream(depsFilePath, FileMode.Open, FileAccess.Read)) { - EqtTrace.Verbose("DotnetTestHostmanager: Reading file {0} to get path of testhost.dll", depsFilePath); + var context = new DependencyContextJsonReader().Read(stream); + var testhostPackage = context.RuntimeLibraries.FirstOrDefault(lib => lib.Name.Equals(testHostPackageName, StringComparison.OrdinalIgnoreCase)); - // Get testhost relative path - using (var stream = this.fileHelper.GetStream(depsFilePath, FileMode.Open, FileAccess.Read)) + if (testhostPackage != null) { - var context = new DependencyContextJsonReader().Read(stream); - var testhostPackage = context.RuntimeLibraries.FirstOrDefault(lib => lib.Name.Equals(testHostPackageName, StringComparison.OrdinalIgnoreCase)); - - if (testhostPackage != null) + foreach (var runtimeAssemblyGroup in testhostPackage.RuntimeAssemblyGroups) { - foreach (var runtimeAssemblyGroup in testhostPackage.RuntimeAssemblyGroups) + foreach (var path in runtimeAssemblyGroup.AssetPaths) { - foreach (var path in runtimeAssemblyGroup.AssetPaths) + if (path.EndsWith("testhost.dll", StringComparison.OrdinalIgnoreCase)) { - if (path.EndsWith("testhost.dll", StringComparison.OrdinalIgnoreCase)) - { - testHostPath = path; - break; - } + testHostPath = path; + break; } } - - testHostPath = Path.Combine(testhostPackage.Path, testHostPath); - this.hostPackageVersion = testhostPackage.Version; - this.IsVersionCheckRequired = !this.hostPackageVersion.StartsWith("15.0.0"); - EqtTrace.Verbose("DotnetTestHostmanager: Relative path of testhost.dll with respect to package folder is {0}", testHostPath); } + + testHostPath = Path.Combine(testhostPackage.Path, testHostPath); + _hostPackageVersion = testhostPackage.Version; + IsVersionCheckRequired = !_hostPackageVersion.StartsWith("15.0.0"); + EqtTrace.Verbose("DotnetTestHostmanager: Relative path of testhost.dll with respect to package folder is {0}", testHostPath); } + } - // Get probing path - using (StreamReader file = new StreamReader(this.fileHelper.GetStream(runtimeConfigDevPath, FileMode.Open, FileAccess.Read))) - using (JsonTextReader reader = new JsonTextReader(file)) + // Get probing path + using (StreamReader file = new(_fileHelper.GetStream(runtimeConfigDevPath, FileMode.Open, FileAccess.Read))) + using (JsonTextReader reader = new(file)) + { + JObject context = (JObject)JToken.ReadFrom(reader); + JObject runtimeOptions = (JObject)context.GetValue("runtimeOptions"); + JToken additionalProbingPaths = runtimeOptions.GetValue("additionalProbingPaths"); + foreach (var x in additionalProbingPaths) { - JObject context = (JObject)JToken.ReadFrom(reader); - JObject runtimeOptions = (JObject)context.GetValue("runtimeOptions"); - JToken additionalProbingPaths = runtimeOptions.GetValue("additionalProbingPaths"); - foreach (var x in additionalProbingPaths) + EqtTrace.Verbose("DotnetTestHostmanager: Looking for path {0} in folder {1}", testHostPath, x.ToString()); + string testHostFullPath; + try { - EqtTrace.Verbose("DotnetTestHostmanager: Looking for path {0} in folder {1}", testHostPath, x.ToString()); - string testHostFullPath; - try - { - testHostFullPath = Path.Combine(x.ToString(), testHostPath); - } - catch (ArgumentException) - { - // https://github.com/Microsoft/vstest/issues/847 - // skip any invalid paths and continue checking the others - continue; - } + testHostFullPath = Path.Combine(x.ToString(), testHostPath); + } + catch (ArgumentException) + { + // https://github.com/Microsoft/vstest/issues/847 + // skip any invalid paths and continue checking the others + continue; + } - if (this.fileHelper.Exists(testHostFullPath)) - { - EqtTrace.Verbose("DotnetTestHostmanager: Found testhost.dll in {0}", testHostFullPath); - return testHostFullPath; - } + if (_fileHelper.Exists(testHostFullPath)) + { + EqtTrace.Verbose("DotnetTestHostmanager: Found testhost.dll in {0}", testHostFullPath); + return testHostFullPath; } } } - else - { - EqtTrace.Verbose("DotnetTestHostmanager: Runtimeconfig.dev.json {0} does not exist.", runtimeConfigDevPath); - } } else { - EqtTrace.Verbose("DotnetTestHostmanager: Deps file {0} does not exist.", depsFilePath); - } - - // If we are here it means it couldn't resolve testhost.dll from nuget cache. - // Try resolving testhost from output directory of test project. This is required if user has published the test project - // and is running tests in an isolated machine. A second scenario is self test: test platform unit tests take a project - // dependency on testhost (instead of nuget dependency), this drops testhost to output path. - var testHostNextToTestProject = Path.Combine(sourceDirectory, "testhost.dll"); - if (this.fileHelper.Exists(testHostNextToTestProject)) - { - EqtTrace.Verbose("DotnetTestHostManager: Found testhost.dll in source directory: {0}.", testHostNextToTestProject); - return testHostNextToTestProject; + EqtTrace.Verbose("DotnetTestHostmanager: Runtimeconfig.dev.json {0} does not exist.", runtimeConfigDevPath); } + } + else + { + EqtTrace.Verbose("DotnetTestHostmanager: Deps file {0} does not exist.", depsFilePath); + } - return testHostPath; + // If we are here it means it couldn't resolve testhost.dll from nuget cache. + // Try resolving testhost from output directory of test project. This is required if user has published the test project + // and is running tests in an isolated machine. A second scenario is self test: test platform unit tests take a project + // dependency on testhost (instead of nuget dependency), this drops testhost to output path. + var testHostNextToTestProject = Path.Combine(sourceDirectory, "testhost.dll"); + if (_fileHelper.Exists(testHostNextToTestProject)) + { + EqtTrace.Verbose("DotnetTestHostManager: Found testhost.dll in source directory: {0}.", testHostNextToTestProject); + return testHostNextToTestProject; } + + return testHostPath; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/TestHostManagerCallbacks.cs b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/TestHostManagerCallbacks.cs index 3edb5873de..eb50e77710 100644 --- a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/TestHostManagerCallbacks.cs +++ b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/TestHostManagerCallbacks.cs @@ -1,59 +1,59 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.TestHostProvider.Hosting +namespace Microsoft.TestPlatform.TestHostProvider.Hosting; + +using System; +using System.Diagnostics; +using System.Text; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; + +using VisualStudio.TestPlatform.CoreUtilities.Extensions; + +internal class TestHostManagerCallbacks { - using System; - using System.Diagnostics; - using System.Text; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using VisualStudio.TestPlatform.CoreUtilities.Extensions; - - internal class TestHostManagerCallbacks + public static void ErrorReceivedCallback(StringBuilder testHostProcessStdError, string data) { - public static void ErrorReceivedCallback(StringBuilder testHostProcessStdError, string data) - { - // Log all standard error message because on too much data we ignore starting part. - // This is helpful in abnormal failure of testhost. - EqtTrace.Warning("TestHostManagerCallbacks.ErrorReceivedCallback Test host standard error line: {0}", data); + // Log all standard error message because on too much data we ignore starting part. + // This is helpful in abnormal failure of testhost. + EqtTrace.Warning("TestHostManagerCallbacks.ErrorReceivedCallback Test host standard error line: {0}", data); + + testHostProcessStdError.AppendSafeWithNewLine(data); + } + + public static void ExitCallBack( + IProcessHelper processHelper, + object process, + StringBuilder testHostProcessStdError, + Action onHostExited) + { + EqtTrace.Verbose("TestHostProvider.ExitCallBack: Host exited starting callback."); + var testHostProcessStdErrorStr = testHostProcessStdError.ToString(); + + processHelper.TryGetExitCode(process, out int exitCode); - testHostProcessStdError.AppendSafeWithNewLine(data); + int procId = -1; + try + { + procId = (process as Process).Id; + } + catch (InvalidOperationException ex) + { + EqtTrace.Error("TestHostProvider.ExitCallBack: could not get proccess id from process, error: {0}.", ex); } - public static void ExitCallBack( - IProcessHelper processHelper, - object process, - StringBuilder testHostProcessStdError, - Action onHostExited) + if (exitCode != 0) + { + EqtTrace.Error("TestHostManagerCallbacks.ExitCallBack: Testhost processId: {0} exited with exitcode: {1} error: '{2}'", procId, exitCode, testHostProcessStdErrorStr); + } + else { - EqtTrace.Verbose("TestHostProvider.ExitCallBack: Host exited starting callback."); - var exitCode = 0; - var testHostProcessStdErrorStr = testHostProcessStdError.ToString(); - - processHelper.TryGetExitCode(process, out exitCode); - - int procId = -1; - try - { - procId = (process as Process).Id; - } - catch (InvalidOperationException ex) - { - EqtTrace.Error("TestHostProvider.ExitCallBack: could not get proccess id from process, error: {0}.", ex); - } - - if (exitCode != 0) - { - EqtTrace.Error("TestHostManagerCallbacks.ExitCallBack: Testhost processId: {0} exited with exitcode: {1} error: '{2}'", procId, exitCode, testHostProcessStdErrorStr); - } - else - { - EqtTrace.Info("TestHostManagerCallbacks.ExitCallBack: Testhost processId: {0} exited with exitcode: 0 error: '{1}'", procId, testHostProcessStdErrorStr); - } - - onHostExited(new HostProviderEventArgs(testHostProcessStdErrorStr, exitCode, procId)); + EqtTrace.Info("TestHostManagerCallbacks.ExitCallBack: Testhost processId: {0} exited with exitcode: 0 error: '{1}'", procId, testHostProcessStdErrorStr); } + + onHostExited(new HostProviderEventArgs(testHostProcessStdErrorStr, exitCode, procId)); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Properties/TestExtensionTypesAttribute.cs b/src/Microsoft.TestPlatform.TestHostProvider/Properties/TestExtensionTypesAttribute.cs index 4cce7e2fbc..5772f9ded9 100644 --- a/src/Microsoft.TestPlatform.TestHostProvider/Properties/TestExtensionTypesAttribute.cs +++ b/src/Microsoft.TestPlatform.TestHostProvider/Properties/TestExtensionTypesAttribute.cs @@ -1,21 +1,20 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform; - /// - /// Custom Attribute to specify the exact types which should be loaded from assembly - /// - [AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = false)] - internal sealed class TestExtensionTypesAttribute : Attribute - { - public TestExtensionTypesAttribute(params Type[] types) - { - this.Types = types; - } +using System; - public Type[] Types { get; } +/// +/// Custom Attribute to specify the exact types which should be loaded from assembly +/// +[AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = false)] +internal sealed class TestExtensionTypesAttribute : Attribute +{ + public TestExtensionTypesAttribute(params Type[] types) + { + Types = types; } + + public Type[] Types { get; } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Utilities/ClientUtilities.cs b/src/Microsoft.TestPlatform.Utilities/ClientUtilities.cs index 7cad5e447d..6260b68942 100644 --- a/src/Microsoft.TestPlatform.Utilities/ClientUtilities.cs +++ b/src/Microsoft.TestPlatform.Utilities/ClientUtilities.cs @@ -1,78 +1,75 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Utilities +namespace Microsoft.VisualStudio.TestPlatform.Utilities; + +using System; +using System.IO; +using System.Xml; + +/// +/// Utilities used by the client to understand the environment of the current run. +/// +public static class ClientUtilities { - using System; - using System.Diagnostics.CodeAnalysis; - using System.IO; - using System.Xml; + private const string TestSettingsFileXPath = "RunSettings/MSTest/SettingsFile"; + private const string ResultsDirectoryXPath = "RunSettings/RunConfiguration/ResultsDirectory"; + private const string RunsettingsDirectory = "RunSettingsDirectory"; /// - /// Utilities used by the client to understand the environment of the current run. + /// Converts the relative paths in a runsetting file to absolute ones. /// - public static class ClientUtilities + /// Xml Document containing Runsettings xml + /// Path of the .runsettings xml file + public static void FixRelativePathsInRunSettings(XmlDocument xmlDocument, string path) { - private const string TestSettingsFileXPath = "RunSettings/MSTest/SettingsFile"; - private const string ResultsDirectoryXPath = "RunSettings/RunConfiguration/ResultsDirectory"; - private const string RunsettingsDirectory = "RunSettingsDirectory"; - - /// - /// Converts the relative paths in a runsetting file to absolute ones. - /// - /// Xml Document containing Runsettings xml - /// Path of the .runsettings xml file - [SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes")] - public static void FixRelativePathsInRunSettings(XmlDocument xmlDocument, string path) + if (xmlDocument == null) { - if (xmlDocument == null) - { - throw new ArgumentNullException(nameof(xmlDocument)); - } - - if (string.IsNullOrEmpty(path)) - { - throw new ArgumentNullException(nameof(path)); - } + throw new ArgumentNullException(nameof(xmlDocument)); + } - string root = Path.GetDirectoryName(path); + if (string.IsNullOrEmpty(path)) + { + throw new ArgumentNullException(nameof(path)); + } - AddRunSettingsDirectoryNode(xmlDocument, root); + string root = Path.GetDirectoryName(path); - var testRunSettingsNode = xmlDocument.SelectSingleNode(TestSettingsFileXPath); - if (testRunSettingsNode != null) - { - FixNodeFilePath(testRunSettingsNode, root); - } + AddRunSettingsDirectoryNode(xmlDocument, root); - var resultsDirectoryNode = xmlDocument.SelectSingleNode(ResultsDirectoryXPath); - if (resultsDirectoryNode != null) - { - FixNodeFilePath(resultsDirectoryNode, root); - } + var testRunSettingsNode = xmlDocument.SelectSingleNode(TestSettingsFileXPath); + if (testRunSettingsNode != null) + { + FixNodeFilePath(testRunSettingsNode, root); } - private static void AddRunSettingsDirectoryNode(XmlDocument doc, string path) + var resultsDirectoryNode = xmlDocument.SelectSingleNode(ResultsDirectoryXPath); + if (resultsDirectoryNode != null) { - var node = doc.CreateNode(XmlNodeType.Element, RunsettingsDirectory, string.Empty); - node.InnerXml = path; - doc.DocumentElement.AppendChild(node); + FixNodeFilePath(resultsDirectoryNode, root); } + } - private static void FixNodeFilePath(XmlNode node, string root) - { - string fileName = node.InnerXml; - fileName = Environment.ExpandEnvironmentVariables(fileName); + private static void AddRunSettingsDirectoryNode(XmlDocument doc, string path) + { + var node = doc.CreateNode(XmlNodeType.Element, RunsettingsDirectory, string.Empty); + node.InnerXml = path; + doc.DocumentElement.AppendChild(node); + } - if (!string.IsNullOrEmpty(fileName) - && !Path.IsPathRooted(fileName)) - { - // We have a relative file path... - fileName = Path.Combine(root, fileName); - fileName = Path.GetFullPath(fileName); - } + private static void FixNodeFilePath(XmlNode node, string root) + { + string fileName = node.InnerXml; + fileName = Environment.ExpandEnvironmentVariables(fileName); - node.InnerXml = fileName; + if (!string.IsNullOrEmpty(fileName) + && !Path.IsPathRooted(fileName)) + { + // We have a relative file path... + fileName = Path.Combine(root, fileName); + fileName = Path.GetFullPath(fileName); } + + node.InnerXml = fileName; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs b/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs index e4a2fd4210..c3291d3236 100644 --- a/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs +++ b/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs @@ -1,165 +1,166 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Utilities -{ - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.IO; - using System.Linq; - using System.Reflection; - using System.Threading; - using System.Threading.Tasks; - using System.Xml; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - - public class CodeCoverageDataAttachmentsHandler : IDataCollectorAttachmentProcessor - { - private const string CoverageUri = "datacollector://microsoft/CodeCoverage/2.0"; - private const string CoverageFileExtension = ".coverage"; - private const string XmlFileExtension = ".xml"; - private const string CoverageFriendlyName = "Code Coverage"; +namespace Microsoft.VisualStudio.TestPlatform.Utilities; - private const string CodeCoverageIOAssemblyName = "Microsoft.VisualStudio.Coverage.IO"; - private const string CoverageFileUtilityTypeName = "CoverageFileUtility"; - private const string MergeMethodName = "MergeCoverageReportsAsync"; - private const string CoverageMergeOperationName = "CoverageMergeOperation"; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Threading; +using System.Threading.Tasks; +using System.Xml; - private static readonly Uri CodeCoverageDataCollectorUri = new Uri(CoverageUri); - private static Assembly CodeCoverageAssembly; - private static object ClassInstance; - private static MethodInfo MergeMethodInfo; - private static Array MergeOperationEnumValues; +using ObjectModel; +using ObjectModel.DataCollection; +using ObjectModel.Logging; - public bool SupportsIncrementalProcessing => true; +using PlatformAbstractions; - public IEnumerable GetExtensionUris() - { - yield return CodeCoverageDataCollectorUri; - } +public class CodeCoverageDataAttachmentsHandler : IDataCollectorAttachmentProcessor +{ + private const string CoverageUri = "datacollector://microsoft/CodeCoverage/2.0"; + private const string CoverageFileExtension = ".coverage"; + private const string XmlFileExtension = ".xml"; + private const string CoverageFriendlyName = "Code Coverage"; - public async Task> ProcessAttachmentSetsAsync(XmlElement configurationElement, ICollection attachments, IProgress progressReporter, IMessageLogger logger, CancellationToken cancellationToken) - { - if ((attachments?.Any()) != true) - return new Collection(); + private const string CodeCoverageIoAssemblyName = "Microsoft.VisualStudio.Coverage.IO"; + private const string CoverageFileUtilityTypeName = "CoverageFileUtility"; + private const string MergeMethodName = "MergeCoverageReportsAsync"; + private const string CoverageMergeOperationName = "CoverageMergeOperation"; - var coverageReportFilePaths = new List(); - var coverageOtherFilePaths = new List(); + private static readonly Uri CodeCoverageDataCollectorUri = new(CoverageUri); + private static Assembly s_codeCoverageAssembly; + private static object s_classInstance; + private static MethodInfo s_mergeMethodInfo; + private static Array s_mergeOperationEnumValues; - foreach (var attachmentSet in attachments) - { - foreach (var attachment in attachmentSet.Attachments) - { - if (attachment.Uri.LocalPath.EndsWith(CoverageFileExtension, StringComparison.OrdinalIgnoreCase) || - attachment.Uri.LocalPath.EndsWith(XmlFileExtension, StringComparison.OrdinalIgnoreCase)) - { - coverageReportFilePaths.Add(attachment.Uri.LocalPath); - } - else - { - coverageOtherFilePaths.Add(attachment.Uri.LocalPath); - } - } - } + public bool SupportsIncrementalProcessing => true; - if (coverageReportFilePaths.Count > 1) - { - var mergedCoverageReports = await this.MergeCodeCoverageFilesAsync(coverageReportFilePaths, progressReporter, cancellationToken).ConfigureAwait(false); - var resultAttachmentSet = new AttachmentSet(CodeCoverageDataCollectorUri, CoverageFriendlyName); + public IEnumerable GetExtensionUris() + { + yield return CodeCoverageDataCollectorUri; + } + + public async Task> ProcessAttachmentSetsAsync(XmlElement configurationElement, ICollection attachments, IProgress progressReporter, IMessageLogger logger, CancellationToken cancellationToken) + { + if ((attachments?.Any()) != true) + return new Collection(); + + var coverageReportFilePaths = new List(); + var coverageOtherFilePaths = new List(); - foreach (var coverageReport in mergedCoverageReports) + foreach (var attachmentSet in attachments) + { + foreach (var attachment in attachmentSet.Attachments) + { + if (attachment.Uri.LocalPath.EndsWith(CoverageFileExtension, StringComparison.OrdinalIgnoreCase) || + attachment.Uri.LocalPath.EndsWith(XmlFileExtension, StringComparison.OrdinalIgnoreCase)) { - resultAttachmentSet.Attachments.Add(UriDataAttachment.CreateFrom(coverageReport, CoverageFriendlyName)); + coverageReportFilePaths.Add(attachment.Uri.LocalPath); } - - foreach (var coverageOtherFilePath in coverageOtherFilePaths) + else { - resultAttachmentSet.Attachments.Add(UriDataAttachment.CreateFrom(coverageOtherFilePath, string.Empty)); + coverageOtherFilePaths.Add(attachment.Uri.LocalPath); } - - return new Collection { resultAttachmentSet }; } - - return attachments; } - private async Task> MergeCodeCoverageFilesAsync(IList files, IProgress progressReporter, CancellationToken cancellationToken) + if (coverageReportFilePaths.Count > 1) { - try - { - // Warning: Don't remove this method call. - // - // We took a dependency on Coverage.CoreLib.Net. In the unlikely case it cannot be - // resolved, this method call will throw an exception that will be caught and - // absorbed here. - var result = await this.MergeCodeCoverageFilesAsync(files, cancellationToken).ConfigureAwait(false); - progressReporter?.Report(100); - return result; - } - catch (OperationCanceledException) + var mergedCoverageReports = await MergeCodeCoverageFilesAsync(coverageReportFilePaths, progressReporter, cancellationToken).ConfigureAwait(false); + var resultAttachmentSet = new AttachmentSet(CodeCoverageDataCollectorUri, CoverageFriendlyName); + + foreach (var coverageReport in mergedCoverageReports) { - // Occurs due to cancellation, ok to re-throw. - throw; + resultAttachmentSet.Attachments.Add(UriDataAttachment.CreateFrom(coverageReport, CoverageFriendlyName)); } - catch (Exception ex) + + foreach (var coverageOtherFilePath in coverageOtherFilePaths) { - EqtTrace.Error( - "CodeCoverageDataCollectorAttachmentsHandler: Failed to load datacollector. Error: {0}", - ex.ToString()); + resultAttachmentSet.Attachments.Add(UriDataAttachment.CreateFrom(coverageOtherFilePath, string.Empty)); } - return null; + return new Collection { resultAttachmentSet }; } - private async Task> MergeCodeCoverageFilesAsync(IList files, CancellationToken cancellationToken) + return attachments; + } + + private async Task> MergeCodeCoverageFilesAsync(IList files, IProgress progressReporter, CancellationToken cancellationToken) + { + try + { + // Warning: Don't remove this method call. + // + // We took a dependency on Coverage.CoreLib.Net. In the unlikely case it cannot be + // resolved, this method call will throw an exception that will be caught and + // absorbed here. + var result = await MergeCodeCoverageFilesAsync(files, cancellationToken).ConfigureAwait(false); + progressReporter?.Report(100); + return result; + } + catch (OperationCanceledException) { - cancellationToken.ThrowIfCancellationRequested(); + // Occurs due to cancellation, ok to re-throw. + throw; + } + catch (Exception ex) + { + EqtTrace.Error( + "CodeCoverageDataCollectorAttachmentsHandler: Failed to load datacollector. Error: {0}", + ex.ToString()); + } - // Invoke methods - LoadCodeCoverageAssembly(); - var task = (Task)MergeMethodInfo.Invoke(ClassInstance, new object[] { files[0], files, MergeOperationEnumValues.GetValue(0), true, cancellationToken }); - await task.ConfigureAwait(false); - var coverageData = task.GetType().GetProperty("Result").GetValue(task, null); - var mergedResults = coverageData as IList; + return null; + } - // Delete original files and keep merged file only - foreach (var file in files) - { - if (mergedResults.Contains(file)) - continue; + private async Task> MergeCodeCoverageFilesAsync(IList files, CancellationToken cancellationToken) + { + cancellationToken.ThrowIfCancellationRequested(); - try - { - File.Delete(file); - } - catch (Exception ex) - { - EqtTrace.Error($"CodeCoverageDataCollectorAttachmentsHandler: Failed to remove {file}. Error: {ex}"); - } - } + // Invoke methods + LoadCodeCoverageAssembly(); + var task = (Task)s_mergeMethodInfo.Invoke(s_classInstance, new object[] { files[0], files, s_mergeOperationEnumValues.GetValue(0), true, cancellationToken }); + await task.ConfigureAwait(false); + var coverageData = task.GetType().GetProperty("Result").GetValue(task, null); + var mergedResults = coverageData as IList; + + // Delete original files and keep merged file only + foreach (var file in files) + { + if (mergedResults.Contains(file)) + continue; - return mergedResults; + try + { + File.Delete(file); + } + catch (Exception ex) + { + EqtTrace.Error($"CodeCoverageDataCollectorAttachmentsHandler: Failed to remove {file}. Error: {ex}"); + } } - private void LoadCodeCoverageAssembly() - { - if (CodeCoverageAssembly != null) - return; + return mergedResults; + } - var assemblyPath = Path.Combine(Path.GetDirectoryName(typeof(CodeCoverageDataAttachmentsHandler).GetTypeInfo().Assembly.GetAssemblyLocation()), CodeCoverageIOAssemblyName + ".dll"); - CodeCoverageAssembly = new PlatformAssemblyLoadContext().LoadAssemblyFromPath(assemblyPath); + private void LoadCodeCoverageAssembly() + { + if (s_codeCoverageAssembly != null) + return; - var classType = CodeCoverageAssembly.GetType($"{CodeCoverageIOAssemblyName}.{CoverageFileUtilityTypeName}"); - ClassInstance = Activator.CreateInstance(classType); + var assemblyPath = Path.Combine(Path.GetDirectoryName(typeof(CodeCoverageDataAttachmentsHandler).GetTypeInfo().Assembly.GetAssemblyLocation()), CodeCoverageIoAssemblyName + ".dll"); + s_codeCoverageAssembly = new PlatformAssemblyLoadContext().LoadAssemblyFromPath(assemblyPath); - var types = CodeCoverageAssembly.GetTypes(); - var mergeOperationEnum = Array.Find(types, d => d.Name == CoverageMergeOperationName); - MergeOperationEnumValues = Enum.GetValues(mergeOperationEnum); - MergeMethodInfo = classType?.GetMethod(MergeMethodName, new[] { typeof(string), typeof(IList), mergeOperationEnum, typeof(bool), typeof(CancellationToken) }); - } + var classType = s_codeCoverageAssembly.GetType($"{CodeCoverageIoAssemblyName}.{CoverageFileUtilityTypeName}"); + s_classInstance = Activator.CreateInstance(classType); + + var types = s_codeCoverageAssembly.GetTypes(); + var mergeOperationEnum = Array.Find(types, d => d.Name == CoverageMergeOperationName); + s_mergeOperationEnumValues = Enum.GetValues(mergeOperationEnum); + s_mergeMethodInfo = classType?.GetMethod(MergeMethodName, new[] { typeof(string), typeof(IList), mergeOperationEnum, typeof(bool), typeof(CancellationToken) }); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Utilities/CodeCoverageRunSettingsProcessor.cs b/src/Microsoft.TestPlatform.Utilities/CodeCoverageRunSettingsProcessor.cs index 402e68eca8..0ab67e659e 100644 --- a/src/Microsoft.TestPlatform.Utilities/CodeCoverageRunSettingsProcessor.cs +++ b/src/Microsoft.TestPlatform.Utilities/CodeCoverageRunSettingsProcessor.cs @@ -1,313 +1,307 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Utilities +namespace Microsoft.VisualStudio.TestPlatform.Utilities; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Xml; +using System.Xml.XPath; + +using ObjectModel; + +/// +/// Represents the run settings processor for code coverage data collectors. +/// +public class CodeCoverageRunSettingsProcessor { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Xml; - using System.Xml.XPath; + #region Members + /// + /// Represents the default settings loaded as an . + /// + private readonly XmlNode _defaultSettingsRootNode; + #endregion - using Microsoft.VisualStudio.TestPlatform.ObjectModel; + #region Constructors & Helpers + /// + /// Constructs an object. + /// + /// + /// The default settings root node. + public CodeCoverageRunSettingsProcessor(XmlNode defaultSettingsRootNode) + { + _defaultSettingsRootNode = defaultSettingsRootNode ?? throw new ArgumentNullException(nameof(defaultSettingsRootNode), "Default settings root node is null."); + } + #endregion + #region Public Interface /// - /// Represents the run settings processor for code coverage data collectors. + /// Processes the current settings for the code coverage data collector. /// - public class CodeCoverageRunSettingsProcessor + /// + /// The code coverage settings. + /// + /// An updated version of the current run settings. + public XmlNode Process(string currentSettings) { - #region Members - /// - /// Represents the default settings loaded as an . - /// - private XmlNode defaultSettingsRootNode; - #endregion - - #region Constructors & Helpers - /// - /// Constructs an object. - /// - /// - /// The default settings root node. - public CodeCoverageRunSettingsProcessor(XmlNode defaultSettingsRootNode) + if (string.IsNullOrEmpty(currentSettings)) { - this.defaultSettingsRootNode = defaultSettingsRootNode ?? throw new ArgumentNullException(nameof(defaultSettingsRootNode), "Default settings root node is null."); + return null; } - #endregion - - #region Public Interface - /// - /// Processes the current settings for the code coverage data collector. - /// - /// - /// The code coverage settings. - /// - /// An updated version of the current run settings. - public XmlNode Process(string currentSettings) - { - if (string.IsNullOrEmpty(currentSettings)) - { - return null; - } - // Load current settings from string. - var document = new XmlDocument(); - document.LoadXml(currentSettings); + // Load current settings from string. + var document = new XmlDocument(); + document.LoadXml(currentSettings); - return this.Process(document.DocumentElement); - } + return Process(document.DocumentElement); + } - /// - /// Processes the current settings for the code coverage data collector. - /// - /// - /// - /// The code coverage settings document. - /// - /// - /// An updated version of the current run settings. - public XmlNode Process(XmlDocument currentSettingsDocument) - { - if (currentSettingsDocument == null) - { - return null; - } + /// + /// Processes the current settings for the code coverage data collector. + /// + /// + /// + /// The code coverage settings document. + /// + /// + /// An updated version of the current run settings. + public XmlNode Process(XmlDocument currentSettingsDocument) + { + return currentSettingsDocument == null ? null : Process(currentSettingsDocument.DocumentElement); + } - return this.Process(currentSettingsDocument.DocumentElement); + /// + /// Processes the current settings for the code coverage data collector. + /// + /// + /// The code coverage root element. + /// + /// An updated version of the current run settings. + public XmlNode Process(XmlNode currentSettingsRootNode) + { + if (currentSettingsRootNode == null) + { + return null; } - /// - /// Processes the current settings for the code coverage data collector. - /// - /// - /// The code coverage root element. - /// - /// An updated version of the current run settings. - public XmlNode Process(XmlNode currentSettingsRootNode) + // Get the code coverage node from the current settings. If unable to get any + // particular component down the path just add the default values for that component + // from the default settings document and return since there's nothing else to be done. + var codeCoveragePathComponents = new List() { "CodeCoverage" }; + var currentCodeCoverageNode = SelectNodeOrAddDefaults( + currentSettingsRootNode, + _defaultSettingsRootNode, + codeCoveragePathComponents); + + // Cannot extract current code coverage node from the given settings so we bail out. + // However, the default code coverage node has already been added to the document's + // root. + if (currentCodeCoverageNode == null) { - if (currentSettingsRootNode == null) - { - return null; - } - - // Get the code coverage node from the current settings. If unable to get any - // particular component down the path just add the default values for that component - // from the default settings document and return since there's nothing else to be done. - var codeCoveragePathComponents = new List() { "CodeCoverage" }; - var currentCodeCoverageNode = this.SelectNodeOrAddDefaults( - currentSettingsRootNode, - this.defaultSettingsRootNode, - codeCoveragePathComponents); - - // Cannot extract current code coverage node from the given settings so we bail out. - // However, the default code coverage node has already been added to the document's - // root. - if (currentCodeCoverageNode == null) - { - return currentSettingsRootNode; - } + return currentSettingsRootNode; + } - // Get the code coverage node from the default settings. - var defaultCodeCoverageNode = this.ExtractNode( - this.defaultSettingsRootNode, - this.BuildPath(codeCoveragePathComponents)); + // Get the code coverage node from the default settings. + var defaultCodeCoverageNode = ExtractNode( + _defaultSettingsRootNode, + BuildPath(codeCoveragePathComponents)); - // Create the exclusion type list. - var exclusions = new List> - { - new List { "ModulePaths", "Exclude" }, - new List { "Attributes", "Exclude" }, - new List { "Sources", "Exclude" }, - new List { "Functions", "Exclude" } - }; + // Create the exclusion type list. + var exclusions = new List> + { + new List { "ModulePaths", "Exclude" }, + new List { "Attributes", "Exclude" }, + new List { "Sources", "Exclude" }, + new List { "Functions", "Exclude" } + }; - foreach (var exclusion in exclusions) + foreach (var exclusion in exclusions) + { + // Get the node for the current exclusion type. If unable to get any + // particular component down the path just add the default values for that + // component from the default settings document and continue since there's nothing + // else to be done. + var currentNode = SelectNodeOrAddDefaults( + currentCodeCoverageNode, + defaultCodeCoverageNode, + exclusion); + + // Check if the node extraction was successful and we should process the current + // node in order to merge the current exclusion rules with the default ones. + if (currentNode == null) { - // Get the node for the current exclusion type. If unable to get any - // particular component down the path just add the default values for that - // component from the default settings document and continue since there's nothing - // else to be done. - var currentNode = this.SelectNodeOrAddDefaults( - currentCodeCoverageNode, - defaultCodeCoverageNode, - exclusion); - - // Check if the node extraction was successful and we should process the current - // node in order to merge the current exclusion rules with the default ones. - if (currentNode == null) - { - continue; - } - - // Extract the node from the default settings. - var defaultNode = this.ExtractNode( - defaultCodeCoverageNode, - this.BuildPath(exclusion)); - - // Merge the current and default settings for the current exclusion rule. - this.MergeNodes(currentNode, defaultNode); + continue; } - return currentSettingsRootNode; + // Extract the node from the default settings. + var defaultNode = ExtractNode( + defaultCodeCoverageNode, + BuildPath(exclusion)); + + // Merge the current and default settings for the current exclusion rule. + MergeNodes(currentNode, defaultNode); } - #endregion - - #region Private Methods - /// - /// Selects the node from the current settings node using the given - /// style path. If unable to select the requested node it adds - /// default settings along the path. - /// - /// - /// - /// The root node from the current settings document for the extraction. - /// - /// - /// The corresponding root node from the default settings document. - /// - /// The path components. - /// - /// The requested node if successful, otherwise. - private XmlNode SelectNodeOrAddDefaults( - XmlNode currentRootNode, - XmlNode defaultRootNode, - IList pathComponents) - { - var currentNode = currentRootNode; - var partialPath = new StringBuilder(); - partialPath.Append('.'); + return currentSettingsRootNode; + } + #endregion - foreach (var component in pathComponents) - { - var currentPathComponent = "/" + component; + #region Private Methods + /// + /// Selects the node from the current settings node using the given + /// style path. If unable to select the requested node it adds + /// default settings along the path. + /// + /// + /// + /// The root node from the current settings document for the extraction. + /// + /// + /// The corresponding root node from the default settings document. + /// + /// The path components. + /// + /// The requested node if successful, otherwise. + private XmlNode SelectNodeOrAddDefaults( + XmlNode currentRootNode, + XmlNode defaultRootNode, + IList pathComponents) + { + var currentNode = currentRootNode; + var partialPath = new StringBuilder(); + + partialPath.Append('.'); - // Append the current path component to the partial path. - partialPath.Append(currentPathComponent); + foreach (var component in pathComponents) + { + var currentPathComponent = "/" + component; - // Extract the node corresponding to the latest path component. - var tempNode = this.ExtractNode(currentNode, "." + currentPathComponent); + // Append the current path component to the partial path. + partialPath.Append(currentPathComponent); - // Extraction is pruned here because we shouldn't be processing the current node. - if (tempNode != null && !this.ShouldProcessCurrentExclusion(tempNode)) - { - return null; - } + // Extract the node corresponding to the latest path component. + var tempNode = ExtractNode(currentNode, "." + currentPathComponent); - // If the current node extraction is unsuccessful then add the corresponding - // default settings node and bail out. - if (tempNode == null) - { - var defaultNode = this.ExtractNode( - defaultRootNode, - partialPath.ToString()); + // Extraction is pruned here because we shouldn't be processing the current node. + if (tempNode != null && !ShouldProcessCurrentExclusion(tempNode)) + { + return null; + } - var importedChild = currentNode.OwnerDocument.ImportNode(defaultNode, true); - currentNode.AppendChild(importedChild); + // If the current node extraction is unsuccessful then add the corresponding + // default settings node and bail out. + if (tempNode == null) + { + var defaultNode = ExtractNode( + defaultRootNode, + partialPath.ToString()); - return null; - } + var importedChild = currentNode.OwnerDocument.ImportNode(defaultNode, true); + currentNode.AppendChild(importedChild); - // Node corresponding to the latest path component is the new root node for the - // next extraction. - currentNode = tempNode; + return null; } - return currentNode; + // Node corresponding to the latest path component is the new root node for the + // next extraction. + currentNode = tempNode; } - /// - /// Checks if we should process the current exclusion node. - /// - /// - /// The current exclusion node. - /// - /// - /// if the node should be processed, otherwise. - /// - private bool ShouldProcessCurrentExclusion(XmlNode node) - { - const string attributeName = "mergeDefaults"; + return currentNode; + } - foreach (XmlAttribute attribute in node.Attributes) + /// + /// Checks if we should process the current exclusion node. + /// + /// + /// The current exclusion node. + /// + /// + /// if the node should be processed, otherwise. + /// + private bool ShouldProcessCurrentExclusion(XmlNode node) + { + const string attributeName = "mergeDefaults"; + + foreach (XmlAttribute attribute in node.Attributes) + { + // If the attribute is present and set on 'false' we skip processing for the + // current exclusion. + if (attribute.Name == attributeName + && bool.TryParse(attribute.Value, out var value) + && !value) { - // If the attribute is present and set on 'false' we skip processing for the - // current exclusion. - if (attribute.Name == attributeName - && bool.TryParse(attribute.Value, out var value) - && !value) - { - return false; - } + return false; } - - return true; } - /// - /// Assembles a relative path from the path given as components. - /// - /// - /// A relative path built from path components. - private string BuildPath(IList pathComponents) + return true; + } + + /// + /// Assembles a relative path from the path given as components. + /// + /// + /// A relative path built from path components. + private string BuildPath(IList pathComponents) + { + return string.Join("/", new[] { "." }.Concat(pathComponents)); + } + + /// + /// Extracts the node specified by the current path using the provided node as root. + /// + /// + /// The root to be used for extraction. + /// The path used to specify the requested node. + /// + /// The extracted node if successful, otherwise. + private XmlNode ExtractNode(XmlNode node, string path) + { + try { - return string.Join("/", new[] { "." }.Concat(pathComponents)); + return node.SelectSingleNode(path); } - - /// - /// Extracts the node specified by the current path using the provided node as root. - /// - /// - /// The root to be used for extraction. - /// The path used to specify the requested node. - /// - /// The extracted node if successful, otherwise. - private XmlNode ExtractNode(XmlNode node, string path) + catch (XPathException ex) { - try - { - return node.SelectSingleNode(path); - } - catch (XPathException ex) - { - EqtTrace.Error( - "CodeCoverageRunSettingsProcessor.ExtractNode: Cannot select single node \"{0}\".", - ex.Message); - } - - return null; + EqtTrace.Error( + "CodeCoverageRunSettingsProcessor.ExtractNode: Cannot select single node \"{0}\".", + ex.Message); } - /// - /// Merges the current settings rules with the default settings rules. - /// - /// - /// The current settings root node. - /// The default settings root node. - private void MergeNodes(XmlNode currentNode, XmlNode defaultNode) + return null; + } + + /// + /// Merges the current settings rules with the default settings rules. + /// + /// + /// The current settings root node. + /// The default settings root node. + private void MergeNodes(XmlNode currentNode, XmlNode defaultNode) + { + var exclusionCache = new HashSet(); + + // Add current exclusions to the exclusion cache. + foreach (XmlNode child in currentNode.ChildNodes) { - var exclusionCache = new HashSet(); + exclusionCache.Add(child.OuterXml); + } - // Add current exclusions to the exclusion cache. - foreach (XmlNode child in currentNode.ChildNodes) + // Iterate through default exclusions and import missing ones. + foreach (XmlNode child in defaultNode.ChildNodes) + { + if (exclusionCache.Contains(child.OuterXml)) { - exclusionCache.Add(child.OuterXml); + continue; } - // Iterate through default exclusions and import missing ones. - foreach (XmlNode child in defaultNode.ChildNodes) - { - if (exclusionCache.Contains(child.OuterXml)) - { - continue; - } - - // Import missing default exclusions. - var importedChild = currentNode.OwnerDocument.ImportNode(child, true); - currentNode.AppendChild(importedChild); - } + // Import missing default exclusions. + var importedChild = currentNode.OwnerDocument.ImportNode(child, true); + currentNode.AppendChild(importedChild); } - #endregion } -} + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Utilities/CommandLineUtilities.cs b/src/Microsoft.TestPlatform.Utilities/CommandLineUtilities.cs index ea6c283009..757daff637 100644 --- a/src/Microsoft.TestPlatform.Utilities/CommandLineUtilities.cs +++ b/src/Microsoft.TestPlatform.Utilities/CommandLineUtilities.cs @@ -1,107 +1,107 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Utilities -{ - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Text; +namespace Microsoft.VisualStudio.TestPlatform.Utilities; + +using ObjectModel; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; - public static class CommandLineUtilities +public static class CommandLineUtilities +{ + public static bool SplitCommandLineIntoArguments(string args, out string[] arguments) { - public static bool SplitCommandLineIntoArguments(string args, out string[] arguments) - { - bool hadError = false; - var argArray = new List(); - var currentArg = new StringBuilder(); - bool inQuotes = false; - int index = 0; + bool hadError = false; + var argArray = new List(); + var currentArg = new StringBuilder(); + bool inQuotes = false; + int index = 0; - try + try + { + while (true) { - while (true) + // skip whitespace + while (char.IsWhiteSpace(args[index])) { - // skip whitespace - while (char.IsWhiteSpace(args[index])) + index++; + } + + // # - comment to end of line + if (args[index] == '#') + { + index++; + while (args[index] != '\n') { index++; } + continue; + } - // # - comment to end of line - if (args[index] == '#') + // do one argument + do + { + if (args[index] == '\\') { + int cSlashes = 1; index++; - while (args[index] != '\n') + while (index == args.Length && args[index] == '\\') { - index++; + cSlashes++; } - continue; - } - // do one argument - do - { - if (args[index] == '\\') + if (index == args.Length || args[index] != '"') { - int cSlashes = 1; - index++; - while (index == args.Length && args[index] == '\\') - { - cSlashes++; - } - - if (index == args.Length || args[index] != '"') + currentArg.Append('\\', cSlashes); + } + else + { + currentArg.Append('\\', (cSlashes >> 1)); + if (0 != (cSlashes & 1)) { - currentArg.Append('\\', cSlashes); + currentArg.Append('"'); } else { - currentArg.Append('\\', (cSlashes >> 1)); - if (0 != (cSlashes & 1)) - { - currentArg.Append('"'); - } - else - { - inQuotes = !inQuotes; - } + inQuotes = !inQuotes; } } - else if (args[index] == '"') - { - inQuotes = !inQuotes; - index++; - } - else - { - currentArg.Append(args[index]); - index++; - } - } while (!char.IsWhiteSpace(args[index]) || inQuotes); - argArray.Add(currentArg.ToString()); - currentArg.Clear(); - } + } + else if (args[index] == '"') + { + inQuotes = !inQuotes; + index++; + } + else + { + currentArg.Append(args[index]); + index++; + } + } while (!char.IsWhiteSpace(args[index]) || inQuotes); + argArray.Add(currentArg.ToString()); + currentArg.Clear(); } - catch (IndexOutOfRangeException) + } + catch (IndexOutOfRangeException) + { + // got EOF + if (inQuotes) { - // got EOF - if (inQuotes) - { - EqtTrace.Verbose("Executor.Execute: Exiting with exit code of {0}", 1); - EqtTrace.Error(string.Format(CultureInfo.InvariantCulture, "Error: Unbalanced '\"' in command line argument file")); - hadError = true; - } - else if (currentArg.Length > 0) - { - // valid argument can be terminated by EOF - argArray.Add(currentArg.ToString()); - } + EqtTrace.Verbose("Executor.Execute: Exiting with exit code of {0}", 1); + EqtTrace.Error(string.Format(CultureInfo.InvariantCulture, "Error: Unbalanced '\"' in command line argument file")); + hadError = true; + } + else if (currentArg.Length > 0) + { + // valid argument can be terminated by EOF + argArray.Add(currentArg.ToString()); } - - arguments = argArray.ToArray(); - return hadError; } + + arguments = argArray.ToArray(); + return hadError; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs index 1993fc734c..b5c406e463 100644 --- a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs +++ b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs @@ -1,755 +1,732 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Utilities +namespace Microsoft.VisualStudio.TestPlatform.Utilities; + +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Text; +using System.Xml; +using System.Xml.XPath; + +using OMResources = ObjectModel.Resources.CommonResources; +using UtilitiesResources = Resources.Resources; + +/// +/// Utility class for Inferring the runsettings from the current environment and the user specified command line switches. +/// +public class InferRunSettingsHelper { - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using System; - using System.Collections.Generic; - using System.Globalization; - using System.IO; - using System.Text; - using System.Xml; - using System.Xml.XPath; - using OMResources = Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources.CommonResources; - using UtilitiesResources = Microsoft.VisualStudio.TestPlatform.Utilities.Resources.Resources; + private const string DesignModeNodeName = "DesignMode"; + private const string CollectSourceInformationNodeName = "CollectSourceInformation"; + private const string RunSettingsNodeName = "RunSettings"; + private const string RunConfigurationNodeName = "RunConfiguration"; + private const string ResultsDirectoryNodeName = "ResultsDirectory"; + private const string TargetPlatformNodeName = "TargetPlatform"; + private const string TargetFrameworkNodeName = "TargetFrameworkVersion"; + private const string TargetDevice = "TargetDevice"; + + private const string DesignModeNodePath = @"/RunSettings/RunConfiguration/DesignMode"; + private const string CollectSourceInformationNodePath = @"/RunSettings/RunConfiguration/CollectSourceInformation"; + private const string RunConfigurationNodePath = @"/RunSettings/RunConfiguration"; + private const string TargetPlatformNodePath = @"/RunSettings/RunConfiguration/TargetPlatform"; + private const string TargetFrameworkNodePath = @"/RunSettings/RunConfiguration/TargetFrameworkVersion"; + private const string ResultsDirectoryNodePath = @"/RunSettings/RunConfiguration/ResultsDirectory"; + private const string TargetDeviceNodePath = @"/RunSettings/RunConfiguration/TargetDevice"; + private const string EnvironmentVariablesNodePath = @"/RunSettings/RunConfiguration/EnvironmentVariables"; + private const string MultiTargetingForwardLink = @"https://aka.ms/tp/vstest/multitargetingdoc?view=vs-2019"; + + // To make things compatible for older runsettings + private const string MsTestTargetDeviceNodePath = @"/RunSettings/MSPhoneTest/TargetDevice"; + + private const string CodeCoverageCollectorUri = @"datacollector://microsoft/CodeCoverage/2.0"; + private const string FakesCollectorUri = @"datacollector://microsoft/unittestisolation/1.0"; + private const string CodeCoverageFriendlyName = "Code Coverage"; + private const string FakesFriendlyName = "UnitTestIsolation"; + + private const string LegacyElementsString = "Elements"; + private const string DeploymentAttributesString = "DeploymentAttributes"; + private const string ExecutionAttributesString = "ExecutionAttributes"; + private static readonly List ExecutionNodesPaths = new() { @"/RunSettings/LegacySettings/Execution/TestTypeSpecific/UnitTestRunConfig/AssemblyResolution", @"/RunSettings/LegacySettings/Execution/Timeouts", @"/RunSettings/LegacySettings/Execution/Hosts" }; /// - /// Utility class for Inferring the runsettings from the current environment and the user specified command line switches. + /// Make runsettings compatible with testhost of version 15.0.0-preview + /// Due to bug https://github.com/Microsoft/vstest/issues/970 we need this function /// - public class InferRunSettingsHelper + /// string content of runsettings + /// compatible runsettings + public static string MakeRunsettingsCompatible(string runsettingsXml) { - private const string DesignModeNodeName = "DesignMode"; - private const string CollectSourceInformationNodeName = "CollectSourceInformation"; - private const string RunSettingsNodeName = "RunSettings"; - private const string RunConfigurationNodeName = "RunConfiguration"; - private const string ResultsDirectoryNodeName = "ResultsDirectory"; - private const string TargetPlatformNodeName = "TargetPlatform"; - private const string TargetFrameworkNodeName = "TargetFrameworkVersion"; - private const string TargetDevice = "TargetDevice"; - - private const string DesignModeNodePath = @"/RunSettings/RunConfiguration/DesignMode"; - private const string CollectSourceInformationNodePath = @"/RunSettings/RunConfiguration/CollectSourceInformation"; - private const string RunConfigurationNodePath = @"/RunSettings/RunConfiguration"; - private const string TargetPlatformNodePath = @"/RunSettings/RunConfiguration/TargetPlatform"; - private const string TargetFrameworkNodePath = @"/RunSettings/RunConfiguration/TargetFrameworkVersion"; - private const string ResultsDirectoryNodePath = @"/RunSettings/RunConfiguration/ResultsDirectory"; - private const string TargetDeviceNodePath = @"/RunSettings/RunConfiguration/TargetDevice"; - private const string EnvironmentVariablesNodePath = @"/RunSettings/RunConfiguration/EnvironmentVariables"; - private const string multiTargettingForwardLink = @"https://aka.ms/tp/vstest/multitargetingdoc?view=vs-2019"; - - // To make things compatible for older runsettings - private const string MsTestTargetDeviceNodePath = @"/RunSettings/MSPhoneTest/TargetDevice"; - - private const string CodeCoverageCollectorUri = @"datacollector://microsoft/CodeCoverage/2.0"; - private const string FakesCollectorUri = @"datacollector://microsoft/unittestisolation/1.0"; - private const string CodeCoverageFriendlyName = "Code Coverage"; - private const string FakesFriendlyName = "UnitTestIsolation"; - - private const string LegacyElementsString = "Elements"; - private const string DeploymentAttributesString = "DeploymentAttributes"; - private const string ExecutionAttributesString = "ExecutionAttributes"; - private static readonly List ExecutionNodesPaths = new List { @"/RunSettings/LegacySettings/Execution/TestTypeSpecific/UnitTestRunConfig/AssemblyResolution", @"/RunSettings/LegacySettings/Execution/Timeouts", @"/RunSettings/LegacySettings/Execution/Hosts" }; - - /// - /// Make runsettings compatible with testhost of version 15.0.0-preview - /// Due to bug https://github.com/Microsoft/vstest/issues/970 we need this function - /// - /// string content of runsettings - /// compatible runsettings - public static string MakeRunsettingsCompatible(string runsettingsXml) + // These are the list of valid RunConfiguration setting name which old testhost understand. + var listOfValidRunConfigurationSettings = new HashSet { - // These are the list of valid RunConfiguration setting name which old testhost understand. - var listOfValidRunConfigurationSettings = new HashSet - { - "TargetPlatform", - "TargetFrameworkVersion", - "TestAdaptersPaths", - "ResultsDirectory", - "SolutionDirectory", - "MaxCpuCount", - "DisableParallelization", - "DisableAppDomain" - }; - return MakeRunsettingsCompatible(runsettingsXml, listOfValidRunConfigurationSettings, null); - } + "TargetPlatform", + "TargetFrameworkVersion", + "TestAdaptersPaths", + "ResultsDirectory", + "SolutionDirectory", + "MaxCpuCount", + "DisableParallelization", + "DisableAppDomain" + }; + return MakeRunsettingsCompatible(runsettingsXml, listOfValidRunConfigurationSettings, null); + } - private static string MakeRunsettingsCompatible(string runsettingsXml, HashSet listOfValidRunConfigurationSettings, HashSet listOfInValidRunConfigurationSettings) + private static string MakeRunsettingsCompatible(string runsettingsXml, HashSet listOfValidRunConfigurationSettings, HashSet listOfInValidRunConfigurationSettings) + { + var updatedRunSettingsXml = runsettingsXml; + + if (!string.IsNullOrWhiteSpace(runsettingsXml)) { - var updatedRunSettingsXml = runsettingsXml; + using var stream = new StringReader(runsettingsXml); + using var reader = XmlReader.Create(stream, XmlRunSettingsUtilities.ReaderSettings); + var document = new XmlDocument(); + document.Load(reader); + + var runSettingsNavigator = document.CreateNavigator(); - if (!string.IsNullOrWhiteSpace(runsettingsXml)) + // Move navigator to RunConfiguration node + if (!runSettingsNavigator.MoveToChild(RunSettingsNodeName, string.Empty) || + !runSettingsNavigator.MoveToChild(RunConfigurationNodeName, string.Empty)) { - using (var stream = new StringReader(runsettingsXml)) - using (var reader = XmlReader.Create(stream, XmlRunSettingsUtilities.ReaderSettings)) + EqtTrace.Error("InferRunSettingsHelper.MakeRunsettingsCompatible: Unable to navigate to RunConfiguration. Current node: " + runSettingsNavigator.LocalName); + } + else if (runSettingsNavigator.HasChildren) + { + if (listOfInValidRunConfigurationSettings is null) { - var document = new XmlDocument(); - document.Load(reader); - - var runSettingsNavigator = document.CreateNavigator(); + listOfInValidRunConfigurationSettings = new HashSet(); + } - // Move navigator to RunConfiguration node - if (!runSettingsNavigator.MoveToChild(RunSettingsNodeName, string.Empty) || - !runSettingsNavigator.MoveToChild(RunConfigurationNodeName, string.Empty)) - { - EqtTrace.Error("InferRunSettingsHelper.MakeRunsettingsCompatible: Unable to navigate to RunConfiguration. Current node: " + runSettingsNavigator.LocalName); - } - else if (runSettingsNavigator.HasChildren) + // Find all invalid RunConfiguration Settings + runSettingsNavigator.MoveToFirstChild(); + if (listOfValidRunConfigurationSettings != null) + { + do { - if (listOfInValidRunConfigurationSettings is null) + if (!listOfValidRunConfigurationSettings.Contains(runSettingsNavigator.LocalName)) { - listOfInValidRunConfigurationSettings = new HashSet(); + listOfInValidRunConfigurationSettings.Add(runSettingsNavigator.LocalName); } + } while (runSettingsNavigator.MoveToNext()); + } - // Find all invalid RunConfiguration Settings - runSettingsNavigator.MoveToFirstChild(); - if (listOfValidRunConfigurationSettings != null) - { - do - { - if (!listOfValidRunConfigurationSettings.Contains(runSettingsNavigator.LocalName)) - { - listOfInValidRunConfigurationSettings.Add(runSettingsNavigator.LocalName); - } - } while (runSettingsNavigator.MoveToNext()); - } + // Delete all invalid RunConfiguration Settings + if (listOfInValidRunConfigurationSettings.Count > 0) + { + if (EqtTrace.IsWarningEnabled) + { + string settingsName = string.Join(", ", listOfInValidRunConfigurationSettings); + EqtTrace.Warning(string.Format("InferRunSettingsHelper.MakeRunsettingsCompatible: Removing the following settings: {0} from RunSettings file. To use those settings please move to latest version of Microsoft.NET.Test.Sdk", settingsName)); + } - // Delete all invalid RunConfiguration Settings - if (listOfInValidRunConfigurationSettings.Count > 0) - { - if (EqtTrace.IsWarningEnabled) - { - string settingsName = string.Join(", ", listOfInValidRunConfigurationSettings); - EqtTrace.Warning(string.Format("InferRunSettingsHelper.MakeRunsettingsCompatible: Removing the following settings: {0} from RunSettings file. To use those settings please move to latest version of Microsoft.NET.Test.Sdk", settingsName)); - } - - // move navigator to RunConfiguration node - runSettingsNavigator.MoveToParent(); - - foreach (var s in listOfInValidRunConfigurationSettings) - { - var nodePath = RunConfigurationNodePath + "/" + s; - XmlUtilities.RemoveChildNode(runSettingsNavigator, nodePath, s); - } - - runSettingsNavigator.MoveToRoot(); - updatedRunSettingsXml = runSettingsNavigator.OuterXml; - } + // move navigator to RunConfiguration node + runSettingsNavigator.MoveToParent(); + + foreach (var s in listOfInValidRunConfigurationSettings) + { + var nodePath = RunConfigurationNodePath + "/" + s; + XmlUtilities.RemoveChildNode(runSettingsNavigator, nodePath, s); } + + runSettingsNavigator.MoveToRoot(); + updatedRunSettingsXml = runSettingsNavigator.OuterXml; } } - - return updatedRunSettingsXml; } - public static string RemoveTargetPlatformElement(string runsettingsXml) - => MakeRunsettingsCompatible(runsettingsXml, null, new HashSet { "TargetPlatform" }); - - /// - /// Updates the run settings XML with the specified values. - /// - /// The XmlDocument of the XML. - /// The architecture. - /// The framework. - /// The results directory. - public static void UpdateRunSettingsWithUserProvidedSwitches(XmlDocument runSettingsDocument, Architecture architecture, Framework framework, string resultsDirectory) - { - var runSettingsNavigator = runSettingsDocument.CreateNavigator(); + return updatedRunSettingsXml; + } - ValidateRunConfiguration(runSettingsNavigator); + public static string RemoveTargetPlatformElement(string runsettingsXml) + => MakeRunsettingsCompatible(runsettingsXml, null, new HashSet { "TargetPlatform" }); - // when runsettings specifies platform, that takes precedence over the user specified platform via command line arguments. - var shouldUpdatePlatform = true; + /// + /// Updates the run settings XML with the specified values. + /// + /// The XmlDocument of the XML. + /// The architecture. + /// The framework. + /// The results directory. + public static void UpdateRunSettingsWithUserProvidedSwitches(XmlDocument runSettingsDocument, Architecture architecture, Framework framework, string resultsDirectory) + { + var runSettingsNavigator = runSettingsDocument.CreateNavigator(); - TryGetPlatformXml(runSettingsNavigator, out var nodeXml); - if (!string.IsNullOrEmpty(nodeXml)) - { - architecture = (Architecture)Enum.Parse(typeof(Architecture), nodeXml, true); - shouldUpdatePlatform = false; - } + ValidateRunConfiguration(runSettingsNavigator); - // when runsettings specifies framework, that takes precedence over the user specified input framework via the command line arguments. - var shouldUpdateFramework = true; - TryGetFrameworkXml(runSettingsNavigator, out nodeXml); + // when runsettings specifies platform, that takes precedence over the user specified platform via command line arguments. + var shouldUpdatePlatform = true; - if (!string.IsNullOrEmpty(nodeXml)) - { - framework = Framework.FromString(nodeXml); - shouldUpdateFramework = false; - } + TryGetPlatformXml(runSettingsNavigator, out var nodeXml); + if (!string.IsNullOrEmpty(nodeXml)) + { + architecture = (Architecture)Enum.Parse(typeof(Architecture), nodeXml, true); + shouldUpdatePlatform = false; + } - EqtTrace.Verbose("Using effective platform:{0} effective framework:{1}", architecture, framework); + // when runsettings specifies framework, that takes precedence over the user specified input framework via the command line arguments. + var shouldUpdateFramework = true; + TryGetFrameworkXml(runSettingsNavigator, out nodeXml); - // check if platform is compatible with current system architecture. - VerifyCompatibilityWithOSArchitecture(architecture); + if (!string.IsNullOrEmpty(nodeXml)) + { + framework = Framework.FromString(nodeXml); + shouldUpdateFramework = false; + } - // Check if inputRunSettings has results directory configured. - var hasResultsDirectory = runSettingsDocument.SelectSingleNode(ResultsDirectoryNodePath) != null; + EqtTrace.Verbose("Using effective platform:{0} effective framework:{1}", architecture, framework); - // Regenerate the effective settings. - if (shouldUpdatePlatform || shouldUpdateFramework || !hasResultsDirectory) - { - UpdateRunConfiguration(runSettingsDocument, architecture, framework, resultsDirectory); - } - } + // check if platform is compatible with current system architecture. + VerifyCompatibilityWithOsArchitecture(architecture); - /// - /// Updates the RunConfiguration.DesignMode value for a run settings. Doesn't do anything if the value is already set. - /// - /// Document for runsettings xml - /// Value to set - public static void UpdateDesignMode(XmlDocument runSettingsDocument, bool designModeValue) - { - AddNodeIfNotPresent(runSettingsDocument, DesignModeNodePath, DesignModeNodeName, designModeValue); - } + // Check if inputRunSettings has results directory configured. + var hasResultsDirectory = runSettingsDocument.SelectSingleNode(ResultsDirectoryNodePath) != null; - /// - /// Updates the RunConfiguration.CollectSourceInformation value for a run settings. Doesn't do anything if the value is already set. - /// - /// Navigator for runsettings xml - /// Value to set - public static void UpdateCollectSourceInformation(XmlDocument runSettingsDocument, bool collectSourceInformationValue) + // Regenerate the effective settings. + if (shouldUpdatePlatform || shouldUpdateFramework || !hasResultsDirectory) { - AddNodeIfNotPresent(runSettingsDocument, CollectSourceInformationNodePath, CollectSourceInformationNodeName, collectSourceInformationValue); + UpdateRunConfiguration(runSettingsDocument, architecture, framework, resultsDirectory); } + } - /// - /// Updates the RunConfiguration.TargetDevice value for a run settings. Doesn't do anything if the value is already set. - /// - /// XmlDocument for runsettings xml - /// Value to set - public static void UpdateTargetDevice(XmlDocument runSettingsDocument, string targetDevice) - { - AddNodeIfNotPresent(runSettingsDocument, TargetDeviceNodePath, TargetDevice, targetDevice); - } + /// + /// Updates the RunConfiguration.DesignMode value for a run settings. Doesn't do anything if the value is already set. + /// + /// Document for runsettings xml + /// Value to set + public static void UpdateDesignMode(XmlDocument runSettingsDocument, bool designModeValue) + { + AddNodeIfNotPresent(runSettingsDocument, DesignModeNodePath, DesignModeNodeName, designModeValue); + } + + /// + /// Updates the RunConfiguration.CollectSourceInformation value for a run settings. Doesn't do anything if the value is already set. + /// + /// Navigator for runsettings xml + /// Value to set + public static void UpdateCollectSourceInformation(XmlDocument runSettingsDocument, bool collectSourceInformationValue) + { + AddNodeIfNotPresent(runSettingsDocument, CollectSourceInformationNodePath, CollectSourceInformationNodeName, collectSourceInformationValue); + } + + /// + /// Updates the RunConfiguration.TargetDevice value for a run settings. Doesn't do anything if the value is already set. + /// + /// XmlDocument for runsettings xml + /// Value to set + public static void UpdateTargetDevice(XmlDocument runSettingsDocument, string targetDevice) + { + AddNodeIfNotPresent(runSettingsDocument, TargetDeviceNodePath, TargetDevice, targetDevice); + } + + /// + /// Updates the RunConfiguration.TargetFrameworkVersion value for a run settings. if the value is already set, behavior depends on overwrite. + /// + /// XmlDocument for runsettings xml + /// Value to set + /// Overwrite option. + public static void UpdateTargetFramework(XmlDocument runSettingsDocument, string framework, bool overwrite = false) + { + AddNodeIfNotPresent(runSettingsDocument, TargetFrameworkNodePath, TargetFrameworkNodeName, framework, overwrite); + } - /// - /// Updates the RunConfiguration.TargetFrameworkVersion value for a run settings. if the value is already set, behavior depends on overwrite. - /// - /// XmlDocument for runsettings xml - /// Value to set - /// Overwrite option. - public static void UpdateTargetFramework(XmlDocument runSettingsDocument, string framework, bool overwrite = false) + /// + /// Validates the collectors in runsettings when an in-lined testsettings is specified + /// + /// RunSettings used for the run + /// True if an incompatible collector is found + public static bool AreRunSettingsCollectorsIncompatibleWithTestSettings(string runsettings) + { + // If there's no embedded testsettings.. bail out + if (!IsTestSettingsEnabled(runsettings)) { - AddNodeIfNotPresent(runSettingsDocument, TargetFrameworkNodePath, TargetFrameworkNodeName, framework, overwrite); + return false; } - /// - /// Validates the collectors in runsettings when an in-lined testsettings is specified - /// - /// RunSettings used for the run - /// True if an incompatible collector is found - public static bool AreRunSettingsCollectorsIncompatibleWithTestSettings(string runsettings) + // Explicitly blocking usage of data collectors through modes runsettings and testsettings except + // for couple of scenarios where the IDE generates the collector settings in the runsettings file even when + // it has an embedded testsettings file. Longterm runsettings will be the single run configuration source + // In-proc collectors are incompatible with testsettings + var inprocDataCollectionSettings = XmlRunSettingsUtilities.GetInProcDataCollectionRunSettings(runsettings); + if (inprocDataCollectionSettings != null && inprocDataCollectionSettings.IsCollectionEnabled && inprocDataCollectionSettings.DataCollectorSettingsList != null) { - // If there's no embedded testsettings.. bail out - if (!IsTestSettingsEnabled(runsettings)) - { - return false; - } - - // Explicitly blocking usage of data collectors through modes runsettings and testsettings except - // for couple of scenarios where the IDE generates the collector settings in the runsettings file even when - // it has an embedded testsettings file. Longterm runsettings will be the single run configuration source - // In-proc collectors are incompatible with testsettings - var inprocDataCollectionSettings = XmlRunSettingsUtilities.GetInProcDataCollectionRunSettings(runsettings); - if (inprocDataCollectionSettings != null && inprocDataCollectionSettings.IsCollectionEnabled && inprocDataCollectionSettings.DataCollectorSettingsList != null) - { - foreach (var collectorSettings in inprocDataCollectionSettings.DataCollectorSettingsList) - { - if (collectorSettings.IsEnabled) - { - EqtTrace.Warning($"Incompatible collector found. {collectorSettings.FriendlyName} : {collectorSettings.Uri}"); - return true; - } - } - } - - // TestSettings and collection is enabled in runsetttings.. the only allowed collectors are code coverage and fakes - var datacollectionSettings = XmlRunSettingsUtilities.GetDataCollectionRunSettings(runsettings); - if (datacollectionSettings != null && datacollectionSettings.IsCollectionEnabled && datacollectionSettings.DataCollectorSettingsList != null) + foreach (var collectorSettings in inprocDataCollectionSettings.DataCollectorSettingsList) { - foreach (var collectorRef in datacollectionSettings.DataCollectorSettingsList) + if (collectorSettings.IsEnabled) { - // Ignore disabled collector - if (!collectorRef.IsEnabled) - { - continue; - } - - // If the configured collector is code coverage or fakes.. ignore - if (!string.IsNullOrWhiteSpace(collectorRef.FriendlyName) && - (FakesFriendlyName.Equals(collectorRef.FriendlyName, StringComparison.OrdinalIgnoreCase) || - CodeCoverageFriendlyName.Equals(collectorRef.FriendlyName, StringComparison.OrdinalIgnoreCase))) - { - continue; - } - - // If the configured collector is code coverage or fakes.. ignore - if (collectorRef.Uri != null && - (CodeCoverageCollectorUri.Equals(collectorRef.Uri.ToString(), StringComparison.OrdinalIgnoreCase) || - FakesCollectorUri.Equals(collectorRef.Uri.ToString(), StringComparison.OrdinalIgnoreCase))) - { - continue; - } - - EqtTrace.Warning($"Incompatible collector found. {collectorRef.FriendlyName} : {collectorRef.Uri}"); + EqtTrace.Warning($"Incompatible collector found. {collectorSettings.FriendlyName} : {collectorSettings.Uri}"); return true; } } - - return false; } - /// - /// Returns true if legacy settings node is present in runsettings - /// - /// The run settings xml string - /// The telemetry data that needs to be captured - /// - public static bool TryGetLegacySettingElements(string runsettingsXml, out Dictionary legacySettingsTelemetry) + // TestSettings and collection is enabled in runsetttings.. the only allowed collectors are code coverage and fakes + var datacollectionSettings = XmlRunSettingsUtilities.GetDataCollectionRunSettings(runsettings); + if (datacollectionSettings != null && datacollectionSettings.IsCollectionEnabled && datacollectionSettings.DataCollectorSettingsList != null) { - legacySettingsTelemetry = new Dictionary(); - try + foreach (var collectorRef in datacollectionSettings.DataCollectorSettingsList) { - using (var stream = new StringReader(runsettingsXml)) - using (var reader = XmlReader.Create(stream, XmlRunSettingsUtilities.ReaderSettings)) + // Ignore disabled collector + if (!collectorRef.IsEnabled) { - var document = new XmlDocument(); - document.Load(reader); - var runSettingsNavigator = document.CreateNavigator(); - - var node = runSettingsNavigator.SelectSingleNode(@"/RunSettings/LegacySettings"); - if (node == null) - { - return false; - } + continue; + } - var childNodes = node.SelectChildren(XPathNodeType.Element); + // If the configured collector is code coverage or fakes.. ignore + if (!string.IsNullOrWhiteSpace(collectorRef.FriendlyName) && + (FakesFriendlyName.Equals(collectorRef.FriendlyName, StringComparison.OrdinalIgnoreCase) || + CodeCoverageFriendlyName.Equals(collectorRef.FriendlyName, StringComparison.OrdinalIgnoreCase))) + { + continue; + } - var legacySettingElements = new List(); - while (childNodes.MoveNext()) - { - legacySettingElements.Add(childNodes.Current.Name); - } + // If the configured collector is code coverage or fakes.. ignore + if (collectorRef.Uri != null && + (CodeCoverageCollectorUri.Equals(collectorRef.Uri.ToString(), StringComparison.OrdinalIgnoreCase) || + FakesCollectorUri.Equals(collectorRef.Uri.ToString(), StringComparison.OrdinalIgnoreCase))) + { + continue; + } - foreach (var executionNodePath in ExecutionNodesPaths) - { - var executionNode = runSettingsNavigator.SelectSingleNode(executionNodePath); - if (executionNode != null) - { - legacySettingElements.Add(executionNode.Name); - } - } + EqtTrace.Warning($"Incompatible collector found. {collectorRef.FriendlyName} : {collectorRef.Uri}"); + return true; + } + } - if (legacySettingElements.Count > 0) - { - legacySettingsTelemetry.Add(LegacyElementsString, string.Join(", ", legacySettingElements)); - } + return false; + } - var deploymentNode = runSettingsNavigator.SelectSingleNode(@"/RunSettings/LegacySettings/Deployment"); - var deploymentAttributes = GetNodeAttributes(deploymentNode); - if (deploymentAttributes != null) - { - legacySettingsTelemetry.Add(DeploymentAttributesString, string.Join(", ", deploymentAttributes)); - } + /// + /// Returns true if legacy settings node is present in runsettings + /// + /// The run settings xml string + /// The telemetry data that needs to be captured + /// + public static bool TryGetLegacySettingElements(string runsettingsXml, out Dictionary legacySettingsTelemetry) + { + legacySettingsTelemetry = new Dictionary(); + try + { + using var stream = new StringReader(runsettingsXml); + using var reader = XmlReader.Create(stream, XmlRunSettingsUtilities.ReaderSettings); + var document = new XmlDocument(); + document.Load(reader); + var runSettingsNavigator = document.CreateNavigator(); - var executiontNode = runSettingsNavigator.SelectSingleNode(@"/RunSettings/LegacySettings/Execution"); - var executiontAttributes = GetNodeAttributes(executiontNode); - if (executiontAttributes != null) - { - legacySettingsTelemetry.Add(ExecutionAttributesString, string.Join(", ", executiontAttributes)); - } - } - } - catch (Exception ex) + var node = runSettingsNavigator.SelectSingleNode(@"/RunSettings/LegacySettings"); + if (node == null) { - EqtTrace.Error("Error while trying to read legacy settings. Message: {0}", ex.ToString()); return false; } - return true; - } + var childNodes = node.SelectChildren(XPathNodeType.Element); - private static List GetNodeAttributes(XPathNavigator node) - { - if (node != null && node.HasAttributes) + var legacySettingElements = new List(); + while (childNodes.MoveNext()) { - var attributes = new List(); - node.MoveToFirstAttribute(); - attributes.Add(node.Name); - while (node.MoveToNextAttribute()) - { - attributes.Add(node.Name); - } - return attributes; + legacySettingElements.Add(childNodes.Current.Name); } - return null; - } - - /// - /// Returns a dictionary of environment variables given in run settings - /// - /// The run settings xml string - /// Environment Variables Dictionary - public static Dictionary GetEnvironmentVariables(string runSettings) - { - Dictionary environmentVariables = null; - try + foreach (var executionNodePath in ExecutionNodesPaths) { - using (var stream = new StringReader(runSettings)) - using (var reader = XmlReader.Create(stream, XmlRunSettingsUtilities.ReaderSettings)) + var executionNode = runSettingsNavigator.SelectSingleNode(executionNodePath); + if (executionNode != null) { - var document = new XmlDocument(); - document.Load(reader); - var runSettingsNavigator = document.CreateNavigator(); - - var node = runSettingsNavigator.SelectSingleNode(EnvironmentVariablesNodePath); - if (node == null) - { - return null; - } - - environmentVariables = new Dictionary(); - var childNodes = node.SelectChildren(XPathNodeType.Element); - - while (childNodes.MoveNext()) - { - if (!environmentVariables.ContainsKey(childNodes.Current.Name)) - { - environmentVariables.Add(childNodes.Current.Name, childNodes.Current?.Value); - } - } + legacySettingElements.Add(executionNode.Name); } } - catch (Exception ex) + + if (legacySettingElements.Count > 0) { - EqtTrace.Error("Error while trying to read environment variables settings. Message: {0}", ex.ToString()); - return null; + legacySettingsTelemetry.Add(LegacyElementsString, string.Join(", ", legacySettingElements)); } - return environmentVariables; - } + var deploymentNode = runSettingsNavigator.SelectSingleNode(@"/RunSettings/LegacySettings/Deployment"); + var deploymentAttributes = GetNodeAttributes(deploymentNode); + if (deploymentAttributes != null) + { + legacySettingsTelemetry.Add(DeploymentAttributesString, string.Join(", ", deploymentAttributes)); + } - /// - /// Updates the RunConfiguration.TargetPlatform value for a run settings. if the value is already set, behavior depends on overwrite. - /// - /// Navigator for runsettings xml - /// Value to set - /// Overwrite option. - public static void UpdateTargetPlatform(XmlDocument runSettingsDocument, string platform, bool overwrite = false) + var executiontNode = runSettingsNavigator.SelectSingleNode(@"/RunSettings/LegacySettings/Execution"); + var executiontAttributes = GetNodeAttributes(executiontNode); + if (executiontAttributes != null) + { + legacySettingsTelemetry.Add(ExecutionAttributesString, string.Join(", ", executiontAttributes)); + } + } + catch (Exception ex) { - AddNodeIfNotPresent(runSettingsDocument, TargetPlatformNodePath, TargetPlatformNodeName, platform, overwrite); + EqtTrace.Error("Error while trying to read legacy settings. Message: {0}", ex.ToString()); + return false; } - public static bool TryGetDeviceXml(XPathNavigator runSettingsNavigator, out String deviceXml) - { - ValidateArg.NotNull(runSettingsNavigator, nameof(runSettingsNavigator)); + return true; + } - deviceXml = null; - XPathNavigator targetDeviceNode = runSettingsNavigator.SelectSingleNode(MsTestTargetDeviceNodePath); - if (targetDeviceNode != null) + private static List GetNodeAttributes(XPathNavigator node) + { + if (node != null && node.HasAttributes) + { + var attributes = new List(); + node.MoveToFirstAttribute(); + attributes.Add(node.Name); + while (node.MoveToNextAttribute()) { - deviceXml = targetDeviceNode.InnerXml; - return true; + attributes.Add(node.Name); } - return false; + return attributes; } - /// - /// Check if testsettings in configured using runsettings. - /// - /// xml string of runsetting - /// - public static bool IsTestSettingsEnabled(string runsettingsXml) + return null; + } + + /// + /// Returns a dictionary of environment variables given in run settings + /// + /// The run settings xml string + /// Environment Variables Dictionary + public static Dictionary GetEnvironmentVariables(string runSettings) + { + Dictionary environmentVariables = null; + try { - if (string.IsNullOrWhiteSpace(runsettingsXml)) - { - return false; - } + using var stream = new StringReader(runSettings); + using var reader = XmlReader.Create(stream, XmlRunSettingsUtilities.ReaderSettings); + var document = new XmlDocument(); + document.Load(reader); + var runSettingsNavigator = document.CreateNavigator(); - using (var stream = new StringReader(runsettingsXml)) - using (var reader = XmlReader.Create(stream, XmlRunSettingsUtilities.ReaderSettings)) + var node = runSettingsNavigator.SelectSingleNode(EnvironmentVariablesNodePath); + if (node == null) { - var document = new XmlDocument(); - document.Load(reader); + return null; + } - var runSettingsNavigator = document.CreateNavigator(); + environmentVariables = new Dictionary(); + var childNodes = node.SelectChildren(XPathNodeType.Element); - // Move navigator to MSTest node - if (!runSettingsNavigator.MoveToChild(RunSettingsNodeName, string.Empty) || - !runSettingsNavigator.MoveToChild("MSTest", string.Empty)) - { - EqtTrace.Info("InferRunSettingsHelper.IsTestSettingsEnabled: Unable to navigate to RunSettings/MSTest. Current node: " + runSettingsNavigator.LocalName); - return false; - } - - var node = runSettingsNavigator.SelectSingleNode(@"/RunSettings/MSTest/SettingsFile"); - if (node != null && !string.IsNullOrEmpty(node.InnerXml)) + while (childNodes.MoveNext()) + { + if (!environmentVariables.ContainsKey(childNodes.Current.Name)) { - return true; + environmentVariables.Add(childNodes.Current.Name, childNodes.Current?.Value); } } + } + catch (Exception ex) + { + EqtTrace.Error("Error while trying to read environment variables settings. Message: {0}", ex.ToString()); + return null; + } + + return environmentVariables; + } + + /// + /// Updates the RunConfiguration.TargetPlatform value for a run settings. if the value is already set, behavior depends on overwrite. + /// + /// Navigator for runsettings xml + /// Value to set + /// Overwrite option. + public static void UpdateTargetPlatform(XmlDocument runSettingsDocument, string platform, bool overwrite = false) + { + AddNodeIfNotPresent(runSettingsDocument, TargetPlatformNodePath, TargetPlatformNodeName, platform, overwrite); + } + public static bool TryGetDeviceXml(XPathNavigator runSettingsNavigator, out String deviceXml) + { + ValidateArg.NotNull(runSettingsNavigator, nameof(runSettingsNavigator)); + + deviceXml = null; + XPathNavigator targetDeviceNode = runSettingsNavigator.SelectSingleNode(MsTestTargetDeviceNodePath); + if (targetDeviceNode != null) + { + deviceXml = targetDeviceNode.InnerXml; + return true; + } + return false; + } + + /// + /// Check if testsettings in configured using runsettings. + /// + /// xml string of runsetting + /// + public static bool IsTestSettingsEnabled(string runsettingsXml) + { + if (string.IsNullOrWhiteSpace(runsettingsXml)) + { return false; } - /// - /// Adds node under RunConfiguration setting. No op if node is already present. - /// - private static void AddNodeIfNotPresent(XmlDocument xmlDocument, string nodePath, string nodeName, T nodeValue, bool overwrite = false) + using (var stream = new StringReader(runsettingsXml)) + using (var reader = XmlReader.Create(stream, XmlRunSettingsUtilities.ReaderSettings)) { - // Navigator should be at Root of runsettings xml, attempt to move to /RunSettings/RunConfiguration - var root = xmlDocument.DocumentElement; + var document = new XmlDocument(); + document.Load(reader); - if (root.SelectSingleNode(RunConfigurationNodePath) == null) + var runSettingsNavigator = document.CreateNavigator(); + + // Move navigator to MSTest node + if (!runSettingsNavigator.MoveToChild(RunSettingsNodeName, string.Empty) || + !runSettingsNavigator.MoveToChild("MSTest", string.Empty)) { - EqtTrace.Error("InferRunSettingsHelper.UpdateNodeIfNotPresent: Unable to navigate to RunConfiguration. Current node: " + xmlDocument.LocalName); - return; + EqtTrace.Info("InferRunSettingsHelper.IsTestSettingsEnabled: Unable to navigate to RunSettings/MSTest. Current node: " + runSettingsNavigator.LocalName); + return false; } - var node = xmlDocument.SelectSingleNode(nodePath); - if (node == null || overwrite) + var node = runSettingsNavigator.SelectSingleNode(@"/RunSettings/MSTest/SettingsFile"); + if (node != null && !string.IsNullOrEmpty(node.InnerXml)) { - XmlUtilities.AppendOrModifyChild(xmlDocument, nodePath, nodeName, nodeValue.ToString()); + return true; } } - /// - /// Validates the RunConfiguration setting in run settings. - /// - private static void ValidateRunConfiguration(XPathNavigator runSettingsNavigator) + return false; + } + + /// + /// Adds node under RunConfiguration setting. No op if node is already present. + /// + private static void AddNodeIfNotPresent(XmlDocument xmlDocument, string nodePath, string nodeName, T nodeValue, bool overwrite = false) + { + // Navigator should be at Root of runsettings xml, attempt to move to /RunSettings/RunConfiguration + var root = xmlDocument.DocumentElement; + + if (root.SelectSingleNode(RunConfigurationNodePath) == null) { - if (!runSettingsNavigator.MoveToChild(RunSettingsNodeName, string.Empty)) + EqtTrace.Error("InferRunSettingsHelper.UpdateNodeIfNotPresent: Unable to navigate to RunConfiguration. Current node: " + xmlDocument.LocalName); + return; + } + + var node = xmlDocument.SelectSingleNode(nodePath); + if (node == null || overwrite) + { + XmlUtilities.AppendOrModifyChild(xmlDocument, nodePath, nodeName, nodeValue.ToString()); + } + } + + /// + /// Validates the RunConfiguration setting in run settings. + /// + private static void ValidateRunConfiguration(XPathNavigator runSettingsNavigator) + { + if (!runSettingsNavigator.MoveToChild(RunSettingsNodeName, string.Empty)) + { + throw new XmlException( + string.Format( + CultureInfo.CurrentCulture, + UtilitiesResources.RunSettingsParseError, + UtilitiesResources.MissingRunSettingsNode)); + } + + if (runSettingsNavigator.MoveToChild(RunConfigurationNodeName, string.Empty)) + { + if (!TryGetPlatformXml(runSettingsNavigator, out var nodeXml)) { throw new XmlException( string.Format( CultureInfo.CurrentCulture, UtilitiesResources.RunSettingsParseError, - UtilitiesResources.MissingRunSettingsNode)); - } - - if (runSettingsNavigator.MoveToChild(RunConfigurationNodeName, string.Empty)) - { - if (!TryGetPlatformXml(runSettingsNavigator, out var nodeXml)) - { - throw new XmlException( string.Format( CultureInfo.CurrentCulture, - UtilitiesResources.RunSettingsParseError, - string.Format( - CultureInfo.CurrentCulture, - UtilitiesResources.InvalidSettingsIncorrectValue, - Constants.RunConfigurationSettingsName, - nodeXml, - TargetPlatformNodeName))); - } + UtilitiesResources.InvalidSettingsIncorrectValue, + Constants.RunConfigurationSettingsName, + nodeXml, + TargetPlatformNodeName))); + } - if (!TryGetFrameworkXml(runSettingsNavigator, out nodeXml)) - { - throw new XmlException( + if (!TryGetFrameworkXml(runSettingsNavigator, out nodeXml)) + { + throw new XmlException( + string.Format( + CultureInfo.CurrentCulture, + UtilitiesResources.RunSettingsParseError, string.Format( CultureInfo.CurrentCulture, - UtilitiesResources.RunSettingsParseError, - string.Format( - CultureInfo.CurrentCulture, - UtilitiesResources.InvalidSettingsIncorrectValue, - Constants.RunConfigurationSettingsName, - nodeXml, - TargetFrameworkNodeName))); - } + UtilitiesResources.InvalidSettingsIncorrectValue, + Constants.RunConfigurationSettingsName, + nodeXml, + TargetFrameworkNodeName))); } } + } + + /// + /// Throws SettingsException if platform is incompatible with system architecture. + /// + /// + private static void VerifyCompatibilityWithOsArchitecture(Architecture architecture) + { + var osArchitecture = XmlRunSettingsUtilities.OSArchitecture; - /// - /// Throws SettingsException if platform is incompatible with system architecture. - /// - /// - private static void VerifyCompatibilityWithOSArchitecture(Architecture architecture) + if (architecture == Architecture.X86 && osArchitecture == Architecture.X64) { - var osArchitecture = XmlRunSettingsUtilities.OSArchitecture; + return; + } - if (architecture == Architecture.X86 && osArchitecture == Architecture.X64) - { - return; - } + if (architecture == osArchitecture) + { + return; + } - if (architecture == osArchitecture) - { - return; - } + throw new SettingsException(string.Format(CultureInfo.CurrentCulture, UtilitiesResources.SystemArchitectureIncompatibleWithTargetPlatform, architecture, osArchitecture)); + } - throw new SettingsException(string.Format(CultureInfo.CurrentCulture, UtilitiesResources.SystemArchitectureIncompatibleWithTargetPlatform, architecture, osArchitecture)); + /// + /// Regenerates the RunConfiguration node with new values under runsettings. + /// + private static void UpdateRunConfiguration( + XmlDocument xmlDocument, + Architecture effectivePlatform, + Framework effectiveFramework, + string resultsDirectory) + { + var childNode = xmlDocument.SelectSingleNode(ResultsDirectoryNodePath); + if (childNode != null) + { + resultsDirectory = childNode.InnerXml; } - /// - /// Regenerates the RunConfiguration node with new values under runsettings. - /// - private static void UpdateRunConfiguration( - XmlDocument xmlDocument, - Architecture effectivePlatform, - Framework effectiveFramework, - string resultsDirectory) - { - var childNode = xmlDocument.SelectSingleNode(ResultsDirectoryNodePath); - if (childNode != null) - { - resultsDirectory = childNode.InnerXml; - } + XmlUtilities.AppendOrModifyChild(xmlDocument, RunConfigurationNodePath, RunConfigurationNodeName, null); + XmlUtilities.AppendOrModifyChild(xmlDocument, ResultsDirectoryNodePath, ResultsDirectoryNodeName, resultsDirectory); - XmlUtilities.AppendOrModifyChild(xmlDocument, RunConfigurationNodePath, RunConfigurationNodeName, null); - XmlUtilities.AppendOrModifyChild(xmlDocument, ResultsDirectoryNodePath, ResultsDirectoryNodeName, resultsDirectory); + XmlUtilities.AppendOrModifyChild(xmlDocument, TargetPlatformNodePath, TargetPlatformNodeName, effectivePlatform.ToString()); + XmlUtilities.AppendOrModifyChild(xmlDocument, TargetFrameworkNodePath, TargetFrameworkNodeName, effectiveFramework.ToString()); + } - XmlUtilities.AppendOrModifyChild(xmlDocument, TargetPlatformNodePath, TargetPlatformNodeName, effectivePlatform.ToString()); - XmlUtilities.AppendOrModifyChild(xmlDocument, TargetFrameworkNodePath, TargetFrameworkNodeName, effectiveFramework.ToString()); - } + public static bool TryGetPlatformXml(XPathNavigator runSettingsNavigator, out string platformXml) + { + platformXml = XmlUtilities.GetNodeXml(runSettingsNavigator, TargetPlatformNodePath); - public static bool TryGetPlatformXml(XPathNavigator runSettingsNavigator, out string platformXml) + if (platformXml == null) { - platformXml = XmlUtilities.GetNodeXml(runSettingsNavigator, TargetPlatformNodePath); + return true; + } - if (platformXml == null) - { - return true; - } + Func validator = (string xml) => + { + var value = (Architecture)Enum.Parse(typeof(Architecture), xml, true); - Func validator = (string xml) => - { - var value = (Architecture)Enum.Parse(typeof(Architecture), xml, true); + return Enum.IsDefined(typeof(Architecture), value) && value != Architecture.Default && value != Architecture.AnyCPU; + }; - if (!Enum.IsDefined(typeof(Architecture), value) || value == Architecture.Default || value == Architecture.AnyCPU) - { - return false; - } + return XmlUtilities.IsValidNodeXmlValue(platformXml, validator); + } - return true; - }; + /// + /// Validate if TargetFrameworkVersion in run settings has valid value. + /// + public static bool TryGetFrameworkXml(XPathNavigator runSettingsNavigator, out string frameworkXml) + { + frameworkXml = XmlUtilities.GetNodeXml(runSettingsNavigator, TargetFrameworkNodePath); - return XmlUtilities.IsValidNodeXmlValue(platformXml, validator); + if (frameworkXml == null) + { + return true; } - /// - /// Validate if TargetFrameworkVersion in run settings has valid value. - /// - public static bool TryGetFrameworkXml(XPathNavigator runSettingsNavigator, out string frameworkXml) + Func validator = (string xml) => { - frameworkXml = XmlUtilities.GetNodeXml(runSettingsNavigator, TargetFrameworkNodePath); - - if (frameworkXml == null) + if (Framework.FromString(xml) != null) { + // Allow TargetFrameworkMoniker values like .NETFramework,Version=v4.5, ".NETCoreApp,Version=v1.0 return true; } - Func validator = (string xml) => - { - if (Framework.FromString(xml) != null) - { - // Allow TargetFrameworkMoniker values like .NETFramework,Version=v4.5, ".NETCoreApp,Version=v1.0 - return true; - } - - var value = (FrameworkVersion)Enum.Parse(typeof(FrameworkVersion), xml, true); + var value = (FrameworkVersion)Enum.Parse(typeof(FrameworkVersion), xml, true); - if (!Enum.IsDefined(typeof(FrameworkVersion), value) || value == FrameworkVersion.None) - { - return false; - } + return Enum.IsDefined(typeof(FrameworkVersion), value) && value != FrameworkVersion.None; + }; - return true; - }; - - return XmlUtilities.IsValidNodeXmlValue(frameworkXml, validator); - } + return XmlUtilities.IsValidNodeXmlValue(frameworkXml, validator); + } - /// - /// Returns the sources matching the specified platform and framework settings. - /// For incompatible sources, warning is added to incompatibleSettingWarning. - /// - public static IEnumerable FilterCompatibleSources(Architecture chosenPlatform, Architecture defaultArchitecture, Framework chosenFramework, IDictionary sourcePlatforms, IDictionary sourceFrameworks, out String incompatibleSettingWarning) + /// + /// Returns the sources matching the specified platform and framework settings. + /// For incompatible sources, warning is added to incompatibleSettingWarning. + /// + public static IEnumerable FilterCompatibleSources(Architecture chosenPlatform, Architecture defaultArchitecture, Framework chosenFramework, IDictionary sourcePlatforms, IDictionary sourceFrameworks, out String incompatibleSettingWarning) + { + incompatibleSettingWarning = string.Empty; + List compatibleSources = new(); + StringBuilder warnings = new(); + warnings.AppendLine(); + bool incompatiblityFound = false; + foreach (var source in sourcePlatforms.Keys) { - incompatibleSettingWarning = string.Empty; - List compatibleSources = new List(); - StringBuilder warnings = new StringBuilder(); - warnings.AppendLine(); - bool incompatiblityFound = false; - foreach (var source in sourcePlatforms.Keys) - { - Architecture actualPlatform = sourcePlatforms[source]; - Framework actualFramework = sourceFrameworks[source]; - bool isSettingIncompatible = IsSettingIncompatible(actualPlatform, chosenPlatform, actualFramework, chosenFramework); - if (isSettingIncompatible) - { - string incompatiblityMessage; - var onlyFileName = Path.GetFileName(source); - // Add message for incompatible sources. - incompatiblityMessage = string.Format(CultureInfo.CurrentCulture, OMResources.SourceIncompatible, onlyFileName, actualFramework.Name, actualPlatform); - - warnings.AppendLine(incompatiblityMessage); - incompatiblityFound = true; - } - else - { - compatibleSources.Add(source); - } + Architecture actualPlatform = sourcePlatforms[source]; + Framework actualFramework = sourceFrameworks[source]; + bool isSettingIncompatible = IsSettingIncompatible(actualPlatform, chosenPlatform, actualFramework, chosenFramework); + if (isSettingIncompatible) + { + string incompatiblityMessage; + var onlyFileName = Path.GetFileName(source); + // Add message for incompatible sources. + incompatiblityMessage = string.Format(CultureInfo.CurrentCulture, OMResources.SourceIncompatible, onlyFileName, actualFramework.Name, actualPlatform); + + warnings.AppendLine(incompatiblityMessage); + incompatiblityFound = true; } - - if (incompatiblityFound) + else { - incompatibleSettingWarning = string.Format(CultureInfo.CurrentCulture, OMResources.DisplayChosenSettings, chosenFramework, defaultArchitecture, warnings.ToString(), multiTargettingForwardLink); + compatibleSources.Add(source); } - - return compatibleSources; } - /// - /// Returns true if source settings are incompatible with target settings. - /// - private static bool IsSettingIncompatible(Architecture sourcePlatform, - Architecture targetPlatform, - Framework sourceFramework, - Framework targetFramework) + if (incompatiblityFound) { - return IsPlatformIncompatible(sourcePlatform, targetPlatform) || IsFrameworkIncompatible(sourceFramework, targetFramework); + incompatibleSettingWarning = string.Format(CultureInfo.CurrentCulture, OMResources.DisplayChosenSettings, chosenFramework, defaultArchitecture, warnings.ToString(), MultiTargetingForwardLink); } - /// - /// Returns true if source Platform is incompatible with target platform. - /// - private static bool IsPlatformIncompatible(Architecture sourcePlatform, Architecture targetPlatform) - { - if (sourcePlatform == Architecture.Default || - sourcePlatform == Architecture.AnyCPU) - { - return false; - } - if (targetPlatform == Architecture.X64 && !Is64BitOperatingSystem()) - { - return true; - } - return sourcePlatform != targetPlatform; + return compatibleSources; + } - bool Is64BitOperatingSystem() - { + /// + /// Returns true if source settings are incompatible with target settings. + /// + private static bool IsSettingIncompatible(Architecture sourcePlatform, + Architecture targetPlatform, + Framework sourceFramework, + Framework targetFramework) + { + return IsPlatformIncompatible(sourcePlatform, targetPlatform) || IsFrameworkIncompatible(sourceFramework, targetFramework); + } + + /// + /// Returns true if source Platform is incompatible with target platform. + /// + private static bool IsPlatformIncompatible(Architecture sourcePlatform, Architecture targetPlatform) + { + if (sourcePlatform == Architecture.Default || + sourcePlatform == Architecture.AnyCPU) + { + return false; + } + return targetPlatform == Architecture.X64 && !Is64BitOperatingSystem() || sourcePlatform != targetPlatform; + static bool Is64BitOperatingSystem() + { #if !NETSTANDARD1_3 - return Environment.Is64BitOperatingSystem; + return Environment.Is64BitOperatingSystem; #else - // In the absence of APIs to check, assume the majority case - return true; + // In the absence of APIs to check, assume the majority case + return true; #endif - } } + } - /// - /// Returns true if source FrameworkVersion is incompatible with target FrameworkVersion. - /// - private static bool IsFrameworkIncompatible(Framework sourceFramework, Framework targetFramework) - { - if (sourceFramework.Name.Equals(Framework.DefaultFramework.Name, StringComparison.OrdinalIgnoreCase)) - { - return false; - } - return !sourceFramework.Name.Equals(targetFramework.Name, StringComparison.OrdinalIgnoreCase); - } + /// + /// Returns true if source FrameworkVersion is incompatible with target FrameworkVersion. + /// + private static bool IsFrameworkIncompatible(Framework sourceFramework, Framework targetFramework) + { + return !sourceFramework.Name.Equals(Framework.DefaultFramework.Name, StringComparison.OrdinalIgnoreCase) + && !sourceFramework.Name.Equals(targetFramework.Name, StringComparison.OrdinalIgnoreCase); } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Utilities/MSTestSettingsUtilities.cs b/src/Microsoft.TestPlatform.Utilities/MSTestSettingsUtilities.cs index e0cb77acf2..f7d8086299 100644 --- a/src/Microsoft.TestPlatform.Utilities/MSTestSettingsUtilities.cs +++ b/src/Microsoft.TestPlatform.Utilities/MSTestSettingsUtilities.cs @@ -1,96 +1,90 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Utilities -{ - using System; - using System.Diagnostics.CodeAnalysis; - using System.Globalization; - using System.IO; - using System.Xml; +namespace Microsoft.VisualStudio.TestPlatform.Utilities; + +using System; +using System.Globalization; +using System.IO; +using System.Xml; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using ObjectModel; - using UtilitiesResources = Microsoft.VisualStudio.TestPlatform.Utilities.Resources.Resources; +using UtilitiesResources = Resources.Resources; +/// +/// The legacy mstest.exe settings utilities. +/// +public static class MSTestSettingsUtilities +{ /// - /// The legacy mstest.exe settings utilities. + /// Imports the parameter settings file in the default runsettings. /// - public static class MSTestSettingsUtilities + /// + /// Settings file which need to be imported. The file extension of the settings file will be specified by property. + /// + /// Input RunSettings document to which settings file need to be imported. + /// Updated RunSetting Xml document with imported settings. + public static XmlDocument Import(string settingsFile, XmlDocument defaultRunSettings) { - /// - /// Imports the parameter settings file in the default runsettings. - /// - /// - /// Settings file which need to be imported. The file extension of the settings file will be specified by property. - /// - /// Input RunSettings document to which settings file need to be imported. - /// Updated RunSetting Xml document with imported settings. - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", - Justification = "XmlDocument.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] - public static XmlDocument Import(string settingsFile, XmlDocument defaultRunSettings) - { - ValidateArg.NotNull(settingsFile, nameof(settingsFile)); - ValidateArg.NotNull(defaultRunSettings, nameof(defaultRunSettings)); - - if (IsLegacyTestSettingsFile(settingsFile) == false) - { - throw new XmlException(string.Format(CultureInfo.CurrentCulture, UtilitiesResources.UnExpectedSettingsFile)); - } + ValidateArg.NotNull(settingsFile, nameof(settingsFile)); + ValidateArg.NotNull(defaultRunSettings, nameof(defaultRunSettings)); - var navigator = defaultRunSettings.CreateNavigator(); + if (IsLegacyTestSettingsFile(settingsFile) == false) + { + throw new XmlException(string.Format(CultureInfo.CurrentCulture, UtilitiesResources.UnExpectedSettingsFile)); + } - if (!navigator.MoveToChild(Constants.RunSettingsName, string.Empty)) - { - throw new XmlException(UtilitiesResources.NoRunSettingsNodeFound); - } + var navigator = defaultRunSettings.CreateNavigator(); - var settingsNode = GenerateMSTestXml(settingsFile); + if (!navigator.MoveToChild(Constants.RunSettingsName, string.Empty)) + { + throw new XmlException(UtilitiesResources.NoRunSettingsNodeFound); + } - defaultRunSettings.DocumentElement.PrependChild(defaultRunSettings.ImportNode(settingsNode, true)); + var settingsNode = GenerateMsTestXml(settingsFile); - // Adding RunConfig - if (!navigator.MoveToChild(Constants.RunConfigurationSettingsName, string.Empty)) - { - var doc = new XmlDocument(); - var runConfigurationNode = doc.CreateElement(Constants.RunConfigurationSettingsName); + defaultRunSettings.DocumentElement.PrependChild(defaultRunSettings.ImportNode(settingsNode, true)); - defaultRunSettings.DocumentElement.PrependChild(defaultRunSettings.ImportNode(runConfigurationNode, true)); - } + // Adding RunConfig + if (!navigator.MoveToChild(Constants.RunConfigurationSettingsName, string.Empty)) + { + var doc = new XmlDocument(); + var runConfigurationNode = doc.CreateElement(Constants.RunConfigurationSettingsName); - return defaultRunSettings; + defaultRunSettings.DocumentElement.PrependChild(defaultRunSettings.ImportNode(runConfigurationNode, true)); } - public static bool IsLegacyTestSettingsFile(string settingsFile) - { - return string.Equals(Path.GetExtension(settingsFile), ".testSettings", StringComparison.OrdinalIgnoreCase) - || string.Equals(Path.GetExtension(settingsFile), ".testrunConfig", StringComparison.OrdinalIgnoreCase) - || string.Equals(Path.GetExtension(settingsFile), ".vsmdi", StringComparison.OrdinalIgnoreCase); - } + return defaultRunSettings; + } - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", - Justification = "XmlDocument.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] - private static XmlElement GenerateMSTestXml(string settingsFile) - { - // Generate the MSTest xml - // - // - // C:\local.testsettings - // true - // - // - XmlDocument doc = new XmlDocument(); - XmlElement mstestNode = doc.CreateElement("MSTest"); - - XmlElement testSettingsFileNode = doc.CreateElement("SettingsFile"); - testSettingsFileNode.InnerXml = settingsFile; - mstestNode.AppendChild(testSettingsFileNode); - - XmlElement forcedLegacyModeNode = doc.CreateElement("ForcedLegacyMode"); - forcedLegacyModeNode.InnerXml = "true"; - mstestNode.AppendChild(forcedLegacyModeNode); - - return mstestNode; - } + public static bool IsLegacyTestSettingsFile(string settingsFile) + { + return string.Equals(Path.GetExtension(settingsFile), ".testSettings", StringComparison.OrdinalIgnoreCase) + || string.Equals(Path.GetExtension(settingsFile), ".testrunConfig", StringComparison.OrdinalIgnoreCase) + || string.Equals(Path.GetExtension(settingsFile), ".vsmdi", StringComparison.OrdinalIgnoreCase); + } + + private static XmlElement GenerateMsTestXml(string settingsFile) + { + // Generate the MSTest xml + // + // + // C:\local.testsettings + // true + // + // + XmlDocument doc = new(); + XmlElement mstestNode = doc.CreateElement("MSTest"); + + XmlElement testSettingsFileNode = doc.CreateElement("SettingsFile"); + testSettingsFileNode.InnerXml = settingsFile; + mstestNode.AppendChild(testSettingsFileNode); + + XmlElement forcedLegacyModeNode = doc.CreateElement("ForcedLegacyMode"); + forcedLegacyModeNode.InnerXml = "true"; + mstestNode.AppendChild(forcedLegacyModeNode); + + return mstestNode; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Utilities/ParallelRunSettingsUtilities.cs b/src/Microsoft.TestPlatform.Utilities/ParallelRunSettingsUtilities.cs index a6961b9dee..738f0db890 100644 --- a/src/Microsoft.TestPlatform.Utilities/ParallelRunSettingsUtilities.cs +++ b/src/Microsoft.TestPlatform.Utilities/ParallelRunSettingsUtilities.cs @@ -1,54 +1,50 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Utilities +namespace Microsoft.VisualStudio.TestPlatform.Utilities; +using System.Xml.XPath; + +/// +/// Utility class for MaxCpuCount element of RunSetting +/// +public static class ParallelRunSettingsUtilities { - using System.Diagnostics.CodeAnalysis; - using System.Xml.XPath; + private static readonly string XpathOfRunSettings = @"/RunSettings"; + private static readonly string XpathOfRunConfiguration = @"/RunSettings/RunConfiguration"; + private static readonly string XpathOfMaxCpuCount = @"/RunSettings/RunConfiguration/MaxCpuCount"; /// - /// Utility class for MaxCpuCount element of RunSetting + /// The MaxCpuCount setting template. /// - [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is OK here.")] - public static class ParallelRunSettingsUtilities - { - private static string XpathOfRunSettings = @"/RunSettings"; - private static string XpathOfRunConfiguration = @"/RunSettings/RunConfiguration"; - private static string XpathOfMaxCpuCount = @"/RunSettings/RunConfiguration/MaxCpuCount"; - - /// - /// The MaxCpuCount setting template. - /// - private static readonly string MaxCpuCountSettingTemplate = @"0"; + private static readonly string MaxCpuCountSettingTemplate = @"0"; - /// - /// The RunConfiguration with MaxCpuCount setting template. - /// - private static readonly string RunConfigurationWithMaxCpuCountSettingTemplate = @" + /// + /// The RunConfiguration with MaxCpuCount setting template. + /// + private static readonly string RunConfigurationWithMaxCpuCountSettingTemplate = @" 0 "; - /// - /// This will update the RunSetting with MaxCpuCount 0 if RunSetting doesn't configured with this setting. - /// - /// RunSetting file. - public static void UpdateRunSettingsWithParallelSettingIfNotConfigured(XPathNavigator navigator) + /// + /// This will update the RunSetting with MaxCpuCount 0 if RunSetting doesn't configured with this setting. + /// + /// RunSetting file. + public static void UpdateRunSettingsWithParallelSettingIfNotConfigured(XPathNavigator navigator) + { + var node = navigator.SelectSingleNode(XpathOfMaxCpuCount); + // run settings given by user takes precedence over parallel switch + if (node == null) { - var node = navigator.SelectSingleNode(XpathOfMaxCpuCount); - // run settings given by user takes precedence over parallel switch - if (node == null) + var runConfigurationNavigator = navigator.SelectSingleNode(XpathOfRunConfiguration); + if (runConfigurationNavigator != null) + { + runConfigurationNavigator.AppendChild(MaxCpuCountSettingTemplate); + } + else { - var runConfigurationNavigator = navigator.SelectSingleNode(XpathOfRunConfiguration); - if (runConfigurationNavigator != null) - { - runConfigurationNavigator.AppendChild(MaxCpuCountSettingTemplate); - } - else - { - runConfigurationNavigator = navigator.SelectSingleNode(XpathOfRunSettings); - runConfigurationNavigator?.AppendChild(RunConfigurationWithMaxCpuCountSettingTemplate); - } + runConfigurationNavigator = navigator.SelectSingleNode(XpathOfRunSettings); + runConfigurationNavigator?.AppendChild(RunConfigurationWithMaxCpuCountSettingTemplate); } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Utilities/StringUtilities.cs b/src/Microsoft.TestPlatform.Utilities/StringUtilities.cs index f71f809976..ef48665e11 100644 --- a/src/Microsoft.TestPlatform.Utilities/StringUtilities.cs +++ b/src/Microsoft.TestPlatform.Utilities/StringUtilities.cs @@ -1,47 +1,46 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Utilities -{ - using System.Collections.Generic; - using System.Text; +namespace Microsoft.VisualStudio.TestPlatform.Utilities; + +using System.Collections.Generic; +using System.Text; - public static class StringExtensions +public static class StringExtensions +{ + public static IEnumerable Tokenize(this string input, char separator, char escape) { - public static IEnumerable Tokenize(this string input, char separator, char escape) - { - if (string.IsNullOrEmpty(input)) yield break; + if (string.IsNullOrEmpty(input)) yield break; - var buffer = new StringBuilder(); - var escaping = false; - foreach (var c in input) + var buffer = new StringBuilder(); + var escaping = false; + foreach (var c in input) + { + if (escaping) + { + buffer.Append(c); + escaping = false; + } + else if (c == escape) { - if (escaping) - { - buffer.Append(c); - escaping = false; - } - else if (c == escape) - { - escaping = true; - } - else if (c == separator) - { - yield return buffer.Flush(); - } - else - { - buffer.Append(c); - } + escaping = true; + } + else if (c == separator) + { + yield return buffer.Flush(); + } + else + { + buffer.Append(c); } - if (buffer.Length > 0 || input[input.Length - 1] == separator) yield return buffer.Flush(); } + if (buffer.Length > 0 || input[input.Length - 1] == separator) yield return buffer.Flush(); + } - private static string Flush(this StringBuilder stringBuilder) - { - var result = stringBuilder.ToString(); - stringBuilder.Clear(); - return result; - } + private static string Flush(this StringBuilder stringBuilder) + { + var result = stringBuilder.ToString(); + stringBuilder.Clear(); + return result; } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Utilities/XmlUtilities.cs b/src/Microsoft.TestPlatform.Utilities/XmlUtilities.cs index ed6f6220d7..74ffd53208 100644 --- a/src/Microsoft.TestPlatform.Utilities/XmlUtilities.cs +++ b/src/Microsoft.TestPlatform.Utilities/XmlUtilities.cs @@ -1,99 +1,95 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Utilities -{ - using System; - using System.Diagnostics.CodeAnalysis; +namespace Microsoft.VisualStudio.TestPlatform.Utilities; + +using System; #if NETFRAMEWORK - using System.Security; +using System.Security; #endif - using System.Xml; - using System.Xml.XPath; +using System.Xml; +using System.Xml.XPath; + +/// +/// Utilities class to read and operate on Xml content. +/// +internal class XmlUtilities +{ + /// + /// Gets the Inner XML of the specified node. + /// + /// The xml navigator. + /// The xPath of the node. + /// + internal static string GetNodeXml(XPathNavigator runSettingsNavigator, string nodeXPath) + { + var node = runSettingsNavigator.SelectSingleNode(nodeXPath); + return node?.InnerXml; + } /// - /// Utilities class to read and operate on Xml content. + /// Validates if the Node value is correct according to the provided validator. /// - internal class XmlUtilities + /// The node value. + /// The validator. + /// + internal static bool IsValidNodeXmlValue(string xmlNodeValue, Func validator) { - /// - /// Gets the Inner XML of the specified node. - /// - /// The xml navigator. - /// The xPath of the node. - /// - internal static string GetNodeXml(XPathNavigator runSettingsNavigator, string nodeXPath) + try { - var node = runSettingsNavigator.SelectSingleNode(nodeXPath); - return node?.InnerXml; + return validator.Invoke(xmlNodeValue); } - - /// - /// Validates if the Node value is correct according to the provided validator. - /// - /// The node value. - /// The validator. - /// - internal static bool IsValidNodeXmlValue(string xmlNodeValue, Func validator) + catch (ArgumentException) { - try - { - return validator.Invoke(xmlNodeValue); - } - catch (ArgumentException) - { - return false; - } + return false; } + } - /// - /// If xml node exists with given path, its value is set to innerXml, otherwise a new node is created. - /// - /// Ensure that the navigator is set to right parent. - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", - Justification = "XmlDocument.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] - internal static void AppendOrModifyChild( - XmlDocument xmlDocument, - string nodeXPath, - string nodeName, - string innerXml) - { - var childNode = xmlDocument.SelectSingleNode(nodeXPath); + /// + /// If xml node exists with given path, its value is set to innerXml, otherwise a new node is created. + /// + /// Ensure that the navigator is set to right parent. + internal static void AppendOrModifyChild( + XmlDocument xmlDocument, + string nodeXPath, + string nodeName, + string innerXml) + { + var childNode = xmlDocument.SelectSingleNode(nodeXPath); - // TODO: There isn't an equivalent API to SecurityElement.Escape in Core yet. - // So trusting that the XML is always valid for now. + // TODO: There isn't an equivalent API to SecurityElement.Escape in Core yet. + // So trusting that the XML is always valid for now. #if NETFRAMEWORK - var secureInnerXml = SecurityElement.Escape(innerXml); + var secureInnerXml = SecurityElement.Escape(innerXml); #else - // fixing manually as we currently target to netcore 1.1 and we don't have default implementation for Escape functionality - var secureInnerXml = string.IsNullOrEmpty(innerXml) ? innerXml : innerXml.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("\"", """).Replace("'", "'"); + // fixing manually as we currently target to netcore 1.1 and we don't have default implementation for Escape functionality + var secureInnerXml = string.IsNullOrEmpty(innerXml) ? innerXml : innerXml.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("\"", """).Replace("'", "'"); #endif - if (childNode == null) - { - var childElement = xmlDocument.CreateElement(nodeName); - - if (!string.IsNullOrEmpty(innerXml)) - { - childElement.InnerXml = secureInnerXml; - } + if (childNode == null) + { + var childElement = xmlDocument.CreateElement(nodeName); - var parentNode = xmlDocument.SelectSingleNode(nodeXPath.Substring(0, nodeXPath.LastIndexOf('/'))); - parentNode?.AppendChild(childElement); - } - else if (!string.IsNullOrEmpty(innerXml)) + if (!string.IsNullOrEmpty(innerXml)) { - childNode.InnerXml = secureInnerXml; + childElement.InnerXml = secureInnerXml; } + + var parentNode = xmlDocument.SelectSingleNode(nodeXPath.Substring(0, nodeXPath.LastIndexOf('/'))); + parentNode?.AppendChild(childElement); + } + else if (!string.IsNullOrEmpty(innerXml)) + { + childNode.InnerXml = secureInnerXml; } + } - internal static void RemoveChildNode(XPathNavigator parentNavigator, string nodeXPath, string childName) + internal static void RemoveChildNode(XPathNavigator parentNavigator, string nodeXPath, string childName) + { + var childNodeNavigator = parentNavigator.SelectSingleNode(nodeXPath); + if (childNodeNavigator != null) { - var childNodeNavigator = parentNavigator.SelectSingleNode(nodeXPath); - if (childNodeNavigator != null) - { - parentNavigator.MoveToChild(childName, string.Empty); - parentNavigator.DeleteSelf(); - } + parentNavigator.MoveToChild(childName, string.Empty); + parentNavigator.DeleteSelf(); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/ConsoleParameters.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/ConsoleParameters.cs index a694cc2b3b..d968ded573 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/ConsoleParameters.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/ConsoleParameters.cs @@ -1,97 +1,94 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer -{ - using System; +namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer; #if NETFRAMEWORK - using System.Collections.Generic; +using System.Collections.Generic; #endif - using System.Diagnostics; - using System.IO; +using System.Diagnostics; +using System.IO; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - /// - /// Class which defines additional specifiable parameters for vstest.console.exe - /// - public class ConsoleParameters - { - internal static readonly ConsoleParameters Default = new ConsoleParameters(); +/// +/// Class which defines additional specifiable parameters for vstest.console.exe +/// +public class ConsoleParameters +{ + internal static readonly ConsoleParameters Default = new(); - private string logFilePath = null; - private IFileHelper fileHelper; + private string _logFilePath = null; + private readonly IFileHelper _fileHelper; - /// - /// Create instance of - /// - public ConsoleParameters() : this(new FileHelper()) - { } + /// + /// Create instance of + /// + public ConsoleParameters() : this(new FileHelper()) + { } - /// - /// Create instance of - /// - /// Object of type - public ConsoleParameters(IFileHelper fileHelper) - { - this.fileHelper = fileHelper; - } + /// + /// Create instance of + /// + /// Object of type + public ConsoleParameters(IFileHelper fileHelper) + { + _fileHelper = fileHelper; + } #if NETFRAMEWORK - /// - /// TODO: Remove the #if when project is targeted to netstandard2.0 - /// Environment variables to be set for the process - /// - public Dictionary EnvironmentVariables { get; set; } + /// + /// TODO: Remove the #if when project is targeted to netstandard2.0 + /// Environment variables to be set for the process + /// + public Dictionary EnvironmentVariables { get; set; } #endif - /// - /// Trace level for logs. - /// - public TraceLevel TraceLevel { get; set; } = TraceLevel.Verbose; + /// + /// Trace level for logs. + /// + public TraceLevel TraceLevel { get; set; } = TraceLevel.Verbose; + + /// + /// Full path for the log file + /// + public string LogFilePath + { + get + { + return _logFilePath; + } - /// - /// Full path for the log file - /// - public string LogFilePath + set { - get + ValidateArg.NotNullOrEmpty(value, "LogFilePath"); + var directoryPath = Path.GetDirectoryName(value); + if (!string.IsNullOrEmpty(directoryPath) && !_fileHelper.DirectoryExists(directoryPath)) { - return logFilePath; + Directory.CreateDirectory(directoryPath); } - set - { - ValidateArg.NotNullOrEmpty(value, "LogFilePath"); - var directoryPath = Path.GetDirectoryName(value); - if (!string.IsNullOrEmpty(directoryPath) && !fileHelper.DirectoryExists(directoryPath)) - { - Directory.CreateDirectory(directoryPath); - } - - // Ensure path is double quoted. if path has white space then it can create problem. - this.logFilePath = value.AddDoubleQuote(); - } + // Ensure path is double quoted. if path has white space then it can create problem. + _logFilePath = value.AddDoubleQuote(); } + } - /// - /// Port Number for communication - /// vstest.console will need this port number to communicate with this component - translation layer - /// Currently Internal as we are not intentionally exposing this to consumers of translation layer - /// - internal int PortNumber { get; set; } + /// + /// Port Number for communication + /// vstest.console will need this port number to communicate with this component - translation layer + /// Currently Internal as we are not intentionally exposing this to consumers of translation layer + /// + internal int PortNumber { get; set; } - /// - /// Parent Process ID of the process whose lifetime should dictate the life time of vstest.console.exe - /// vstest.console will need this process ID to know when the process exits. - /// If parent process dies/crashes without invoking EndSession, vstest.console should exit immediately - /// Currently Internal as we are not intentionally exposing this to consumers of translation layer - /// - internal int ParentProcessId { get; set; } - } -} + /// + /// Parent Process ID of the process whose lifetime should dictate the life time of vstest.console.exe + /// vstest.console will need this process ID to know when the process exits. + /// If parent process dies/crashes without invoking EndSession, vstest.console should exit immediately + /// Currently Internal as we are not intentionally exposing this to consumers of translation layer + /// + internal int ParentProcessId { get; set; } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/DiscoveryEventsHandleConverter.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/DiscoveryEventsHandleConverter.cs index 9312163b83..2a3320fcf5 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/DiscoveryEventsHandleConverter.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/DiscoveryEventsHandleConverter.cs @@ -1,69 +1,68 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer -{ - using System; - using System.Collections.Generic; +namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer; + +using System; +using System.Collections.Generic; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +/// +/// The Discovery Events Handler Converter. +/// Converts the ITestDiscoveryEventsHandler to ITestDiscoveryEventsHandler2 +/// +public class DiscoveryEventsHandleConverter : ITestDiscoveryEventsHandler2 +{ + private readonly ITestDiscoveryEventsHandler _testDiscoveryEventsHandler; /// - /// The Discovery Events Handler Converter. + /// The Discovery Complete Handler. /// Converts the ITestDiscoveryEventsHandler to ITestDiscoveryEventsHandler2 /// - public class DiscoveryEventsHandleConverter : ITestDiscoveryEventsHandler2 + /// + public DiscoveryEventsHandleConverter(ITestDiscoveryEventsHandler testDiscoveryEventsHandler) { - private ITestDiscoveryEventsHandler testDiscoveryEventsHandler; - - /// - /// The Discovery Complete Handler. - /// Converts the ITestDiscoveryEventsHandler to ITestDiscoveryEventsHandler2 - /// - /// - public DiscoveryEventsHandleConverter(ITestDiscoveryEventsHandler testDiscoveryEventsHandler) - { - this.testDiscoveryEventsHandler = testDiscoveryEventsHandler ?? throw new ArgumentNullException(nameof(testDiscoveryEventsHandler)); - } + _testDiscoveryEventsHandler = testDiscoveryEventsHandler ?? throw new ArgumentNullException(nameof(testDiscoveryEventsHandler)); + } - /// - /// Handles Raw Message - /// - /// - public void HandleRawMessage(string rawMessage) - { - this.testDiscoveryEventsHandler.HandleRawMessage(rawMessage); - } + /// + /// Handles Raw Message + /// + /// + public void HandleRawMessage(string rawMessage) + { + _testDiscoveryEventsHandler.HandleRawMessage(rawMessage); + } - /// - /// Handles Log Message - /// - /// - /// - public void HandleLogMessage(TestMessageLevel level, string message) - { - this.testDiscoveryEventsHandler.HandleLogMessage(level, message); - } + /// + /// Handles Log Message + /// + /// + /// + public void HandleLogMessage(TestMessageLevel level, string message) + { + _testDiscoveryEventsHandler.HandleLogMessage(level, message); + } - /// - /// Handle Discovery Complete - /// - /// - /// - public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk) - { - this.testDiscoveryEventsHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs.TotalCount, lastChunk, discoveryCompleteEventArgs.IsAborted); - } + /// + /// Handle Discovery Complete + /// + /// + /// + public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk) + { + _testDiscoveryEventsHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs.TotalCount, lastChunk, discoveryCompleteEventArgs.IsAborted); + } - /// - /// Handles Discovery Tests - /// - /// - public void HandleDiscoveredTests(IEnumerable discoveredTestCases) - { - this.testDiscoveryEventsHandler.HandleDiscoveredTests(discoveredTestCases); - } + /// + /// Handles Discovery Tests + /// + /// + public void HandleDiscoveredTests(IEnumerable discoveredTestCases) + { + _testDiscoveryEventsHandler.HandleDiscoveredTests(discoveredTestCases); } } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/IProcessManager.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/IProcessManager.cs index 82c71a1eef..cb4eedf9da 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/IProcessManager.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/IProcessManager.cs @@ -1,34 +1,33 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces -{ - using System; +namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; + +using System; +/// +/// Defines the interface that can manage a process +/// +internal interface IProcessManager +{ /// - /// Defines the interface that can manage a process + /// Starts the Process /// - internal interface IProcessManager - { - /// - /// Starts the Process - /// - void StartProcess(ConsoleParameters consoleParameters); + void StartProcess(ConsoleParameters consoleParameters); - /// - /// Is Process Initialized - /// - /// True, if process initialized - bool IsProcessInitialized(); + /// + /// Is Process Initialized + /// + /// True, if process initialized + bool IsProcessInitialized(); - /// - /// Shutdown Process - /// - void ShutdownProcess(); + /// + /// Shutdown Process + /// + void ShutdownProcess(); - /// - /// Raise event on process exit - /// - event EventHandler ProcessExited; - } -} + /// + /// Raise event on process exit + /// + event EventHandler ProcessExited; +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/ITestSession.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/ITestSession.cs index 2fbb324371..61a3c7855c 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/ITestSession.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/ITestSession.cs @@ -1,210 +1,209 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.VsTestConsole.TranslationLayer.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; + +using System; +using System.Collections.Generic; + +using ObjectModel; +using ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; + +/// +/// Defines a test session that can be used to make calls to the vstest.console +/// process. +/// +[Obsolete("This API is not final yet and is subject to changes.", false)] +public interface ITestSession : IDisposable, ITestSessionAsync { - using System; - using System.Collections.Generic; - - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - - /// - /// Defines a test session that can be used to make calls to the vstest.console - /// process. - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public interface ITestSession : IDisposable, ITestSessionAsync - { - /// - /// Gets the underlying test session info object. - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - TestSessionInfo TestSessionInfo { get; } - - /// - /// Starts test discovery. - /// - /// - /// The list of source assemblies for the discovery. - /// The run settings for the discovery. - /// The discovery event handler. - [Obsolete("This API is not final yet and is subject to changes.", false)] - void DiscoverTests( - IEnumerable sources, - string discoverySettings, - ITestDiscoveryEventsHandler discoveryEventsHandler); - - /// - /// Starts test discovery. - /// - /// - /// The list of source assemblies for the discovery. - /// The run settings for the discovery. - /// The test platform options. - /// The discovery event handler. - [Obsolete("This API is not final yet and is subject to changes.", false)] - void DiscoverTests( - IEnumerable sources, - string discoverySettings, - TestPlatformOptions options, - ITestDiscoveryEventsHandler2 discoveryEventsHandler); - - /// - /// Cancels the last discovery request. - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - new void CancelDiscovery(); - - /// - /// Starts a test run. - /// - /// - /// The list of source assemblies for the test run. - /// The run settings for the run. - /// The run event handler. - [Obsolete("This API is not final yet and is subject to changes.", false)] - void RunTests( - IEnumerable sources, - string runSettings, - ITestRunEventsHandler testRunEventsHandler); - - /// - /// Starts a test run. - /// - /// - /// The list of source assemblies for the test run. - /// The run settings for the run. - /// The test platform options. - /// The run event handler. - [Obsolete("This API is not final yet and is subject to changes.", false)] - void RunTests( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler); - - /// - /// Starts a test run. - /// - /// - /// The list of test cases for the test run. - /// The run settings for the run. - /// The run event handler. - [Obsolete("This API is not final yet and is subject to changes.", false)] - void RunTests( - IEnumerable testCases, - string runSettings, - ITestRunEventsHandler testRunEventsHandler); - - /// - /// Starts a test run. - /// - /// - /// The list of test cases for the test run. - /// The run settings for the run. - /// The test platform options. - /// The run event handler. - [Obsolete("This API is not final yet and is subject to changes.", false)] - void RunTests( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler); - - /// - /// Starts a test run. - /// - /// - /// The list of source assemblies for the test run. - /// The run settings for the run. - /// The run event handler. - /// The custom host launcher. - [Obsolete("This API is not final yet and is subject to changes.", false)] - void RunTestsWithCustomTestHost( - IEnumerable sources, - string runSettings, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); - - /// - /// Starts a test run. - /// - /// - /// The list of source assemblies for the test run. - /// The run settings for the run. - /// The test platform options. - /// The run event handler. - /// The custom host launcher. - [Obsolete("This API is not final yet and is subject to changes.", false)] - void RunTestsWithCustomTestHost( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); - - /// - /// Starts a test run. - /// - /// - /// The list of test cases for the test run. - /// The run settings for the run. - /// The run event handler. - /// The custom host launcher. - [Obsolete("This API is not final yet and is subject to changes.", false)] - void RunTestsWithCustomTestHost( - IEnumerable testCases, - string runSettings, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); - - /// - /// Starts a test run. - /// - /// - /// The list of test cases for the test run. - /// The run settings for the run. - /// The test platform options. - /// The run event handler. - /// The custom host launcher. - [Obsolete("This API is not final yet and is subject to changes.", false)] - void RunTestsWithCustomTestHost( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); - - /// - /// Stops the test session. - /// - /// - /// True if the session was successfuly stopped, false otherwise. - [Obsolete("This API is not final yet and is subject to changes.", false)] - bool StopTestSession(); - - /// - /// Stops the test session. - /// - /// - /// The session event handler. - /// - /// True if the session was successfuly stopped, false otherwise. - [Obsolete("This API is not final yet and is subject to changes.", false)] - bool StopTestSession(ITestSessionEventsHandler eventsHandler); - - /// - /// Cancels the last test run. - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - new void CancelTestRun(); - - /// - /// Aborts the last test run. - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - new void AbortTestRun(); - } -} + /// + /// Gets the underlying test session info object. + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + TestSessionInfo TestSessionInfo { get; } + + /// + /// Starts test discovery. + /// + /// + /// The list of source assemblies for the discovery. + /// The run settings for the discovery. + /// The discovery event handler. + [Obsolete("This API is not final yet and is subject to changes.", false)] + void DiscoverTests( + IEnumerable sources, + string discoverySettings, + ITestDiscoveryEventsHandler discoveryEventsHandler); + + /// + /// Starts test discovery. + /// + /// + /// The list of source assemblies for the discovery. + /// The run settings for the discovery. + /// The test platform options. + /// The discovery event handler. + [Obsolete("This API is not final yet and is subject to changes.", false)] + void DiscoverTests( + IEnumerable sources, + string discoverySettings, + TestPlatformOptions options, + ITestDiscoveryEventsHandler2 discoveryEventsHandler); + + /// + /// Cancels the last discovery request. + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + new void CancelDiscovery(); + + /// + /// Starts a test run. + /// + /// + /// The list of source assemblies for the test run. + /// The run settings for the run. + /// The run event handler. + [Obsolete("This API is not final yet and is subject to changes.", false)] + void RunTests( + IEnumerable sources, + string runSettings, + ITestRunEventsHandler testRunEventsHandler); + + /// + /// Starts a test run. + /// + /// + /// The list of source assemblies for the test run. + /// The run settings for the run. + /// The test platform options. + /// The run event handler. + [Obsolete("This API is not final yet and is subject to changes.", false)] + void RunTests( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler); + + /// + /// Starts a test run. + /// + /// + /// The list of test cases for the test run. + /// The run settings for the run. + /// The run event handler. + [Obsolete("This API is not final yet and is subject to changes.", false)] + void RunTests( + IEnumerable testCases, + string runSettings, + ITestRunEventsHandler testRunEventsHandler); + + /// + /// Starts a test run. + /// + /// + /// The list of test cases for the test run. + /// The run settings for the run. + /// The test platform options. + /// The run event handler. + [Obsolete("This API is not final yet and is subject to changes.", false)] + void RunTests( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler); + + /// + /// Starts a test run. + /// + /// + /// The list of source assemblies for the test run. + /// The run settings for the run. + /// The run event handler. + /// The custom host launcher. + [Obsolete("This API is not final yet and is subject to changes.", false)] + void RunTestsWithCustomTestHost( + IEnumerable sources, + string runSettings, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); + + /// + /// Starts a test run. + /// + /// + /// The list of source assemblies for the test run. + /// The run settings for the run. + /// The test platform options. + /// The run event handler. + /// The custom host launcher. + [Obsolete("This API is not final yet and is subject to changes.", false)] + void RunTestsWithCustomTestHost( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); + + /// + /// Starts a test run. + /// + /// + /// The list of test cases for the test run. + /// The run settings for the run. + /// The run event handler. + /// The custom host launcher. + [Obsolete("This API is not final yet and is subject to changes.", false)] + void RunTestsWithCustomTestHost( + IEnumerable testCases, + string runSettings, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); + + /// + /// Starts a test run. + /// + /// + /// The list of test cases for the test run. + /// The run settings for the run. + /// The test platform options. + /// The run event handler. + /// The custom host launcher. + [Obsolete("This API is not final yet and is subject to changes.", false)] + void RunTestsWithCustomTestHost( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); + + /// + /// Stops the test session. + /// + /// + /// True if the session was successfuly stopped, false otherwise. + [Obsolete("This API is not final yet and is subject to changes.", false)] + bool StopTestSession(); + + /// + /// Stops the test session. + /// + /// + /// The session event handler. + /// + /// True if the session was successfuly stopped, false otherwise. + [Obsolete("This API is not final yet and is subject to changes.", false)] + bool StopTestSession(ITestSessionEventsHandler eventsHandler); + + /// + /// Cancels the last test run. + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + new void CancelTestRun(); + + /// + /// Aborts the last test run. + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + new void AbortTestRun(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/ITestSessionAsync.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/ITestSessionAsync.cs index 6846ca7788..03b3fe7023 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/ITestSessionAsync.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/ITestSessionAsync.cs @@ -1,207 +1,206 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.VsTestConsole.TranslationLayer.Interfaces +namespace Microsoft.VisualStudio.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +using ObjectModel; +using ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; + +/// +/// Defines a test session that can be used to make async calls to the vstest.console +/// process. +/// +[Obsolete("This API is not final yet and is subject to changes.", false)] +public interface ITestSessionAsync : IDisposable { - using System; - using System.Collections.Generic; - using System.Threading.Tasks; + /// + /// Starts test discovery. + /// + /// + /// The list of source assemblies for the discovery. + /// The run settings for the discovery. + /// The discovery event handler. + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + Task DiscoverTestsAsync( + IEnumerable sources, + string discoverySettings, + ITestDiscoveryEventsHandler discoveryEventsHandler); + + /// + /// Starts test discovery. + /// + /// + /// The list of source assemblies for the discovery. + /// The run settings for the discovery. + /// The test platform options. + /// The discovery event handler. + [Obsolete("This API is not final yet and is subject to changes.", false)] + Task DiscoverTestsAsync( + IEnumerable sources, + string discoverySettings, + TestPlatformOptions options, + ITestDiscoveryEventsHandler2 discoveryEventsHandler); + + /// + /// Cancels the last discovery request. + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + void CancelDiscovery(); + + /// + /// Starts a test run. + /// + /// + /// The list of source assemblies for the test run. + /// The run settings for the run. + /// The run event handler. + [Obsolete("This API is not final yet and is subject to changes.", false)] + Task RunTestsAsync( + IEnumerable sources, + string runSettings, + ITestRunEventsHandler testRunEventsHandler); + + /// + /// Starts a test run. + /// + /// + /// The list of source assemblies for the test run. + /// The run settings for the run. + /// The test platform options. + /// The run event handler. + [Obsolete("This API is not final yet and is subject to changes.", false)] + Task RunTestsAsync( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler); + + /// + /// Starts a test run. + /// + /// + /// The list of test cases for the test run. + /// The run settings for the run. + /// The run event handler. + [Obsolete("This API is not final yet and is subject to changes.", false)] + Task RunTestsAsync( + IEnumerable testCases, + string runSettings, + ITestRunEventsHandler testRunEventsHandler); + + /// + /// Starts a test run. + /// + /// + /// The list of test cases for the test run. + /// The run settings for the run. + /// The test platform options. + /// The run event handler. + [Obsolete("This API is not final yet and is subject to changes.", false)] + Task RunTestsAsync( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler); - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; + /// + /// Starts a test run. + /// + /// + /// The list of source assemblies for the test run. + /// The run settings for the run. + /// The run event handler. + /// The custom host launcher. + [Obsolete("This API is not final yet and is subject to changes.", false)] + Task RunTestsWithCustomTestHostAsync( + IEnumerable sources, + string runSettings, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); + + /// + /// Starts a test run. + /// + /// + /// The list of source assemblies for the test run. + /// The run settings for the run. + /// The test platform options. + /// The run event handler. + /// The custom host launcher. + [Obsolete("This API is not final yet and is subject to changes.", false)] + Task RunTestsWithCustomTestHostAsync( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); + + /// + /// Starts a test run. + /// + /// + /// The list of test cases for the test run. + /// The run settings for the run. + /// The run event handler. + /// The custom host launcher. + [Obsolete("This API is not final yet and is subject to changes.", false)] + Task RunTestsWithCustomTestHostAsync( + IEnumerable testCases, + string runSettings, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); + + /// + /// Starts a test run. + /// + /// + /// The list of test cases for the test run. + /// The run settings for the run. + /// The test platform options. + /// The run event handler. + /// The custom host launcher. + [Obsolete("This API is not final yet and is subject to changes.", false)] + Task RunTestsWithCustomTestHostAsync( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); + + /// + /// Stops the test session. + /// + /// + /// True if the session was successfuly stopped, false otherwise. + [Obsolete("This API is not final yet and is subject to changes.", false)] + Task StopTestSessionAsync(); + + /// + /// Stops the test session. + /// + /// + /// The session event handler. + /// + /// True if the session was successfuly stopped, false otherwise. + [Obsolete("This API is not final yet and is subject to changes.", false)] + Task StopTestSessionAsync( + ITestSessionEventsHandler eventsHandler); + + /// + /// Cancels the last test run. + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + void CancelTestRun(); /// - /// Defines a test session that can be used to make async calls to the vstest.console - /// process. + /// Aborts the last test run. /// [Obsolete("This API is not final yet and is subject to changes.", false)] - public interface ITestSessionAsync : IDisposable - { - /// - /// Starts test discovery. - /// - /// - /// The list of source assemblies for the discovery. - /// The run settings for the discovery. - /// The discovery event handler. - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - Task DiscoverTestsAsync( - IEnumerable sources, - string discoverySettings, - ITestDiscoveryEventsHandler discoveryEventsHandler); - - /// - /// Starts test discovery. - /// - /// - /// The list of source assemblies for the discovery. - /// The run settings for the discovery. - /// The test platform options. - /// The discovery event handler. - [Obsolete("This API is not final yet and is subject to changes.", false)] - Task DiscoverTestsAsync( - IEnumerable sources, - string discoverySettings, - TestPlatformOptions options, - ITestDiscoveryEventsHandler2 discoveryEventsHandler); - - /// - /// Cancels the last discovery request. - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - void CancelDiscovery(); - - /// - /// Starts a test run. - /// - /// - /// The list of source assemblies for the test run. - /// The run settings for the run. - /// The run event handler. - [Obsolete("This API is not final yet and is subject to changes.", false)] - Task RunTestsAsync( - IEnumerable sources, - string runSettings, - ITestRunEventsHandler testRunEventsHandler); - - /// - /// Starts a test run. - /// - /// - /// The list of source assemblies for the test run. - /// The run settings for the run. - /// The test platform options. - /// The run event handler. - [Obsolete("This API is not final yet and is subject to changes.", false)] - Task RunTestsAsync( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler); - - /// - /// Starts a test run. - /// - /// - /// The list of test cases for the test run. - /// The run settings for the run. - /// The run event handler. - [Obsolete("This API is not final yet and is subject to changes.", false)] - Task RunTestsAsync( - IEnumerable testCases, - string runSettings, - ITestRunEventsHandler testRunEventsHandler); - - /// - /// Starts a test run. - /// - /// - /// The list of test cases for the test run. - /// The run settings for the run. - /// The test platform options. - /// The run event handler. - [Obsolete("This API is not final yet and is subject to changes.", false)] - Task RunTestsAsync( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler); - - /// - /// Starts a test run. - /// - /// - /// The list of source assemblies for the test run. - /// The run settings for the run. - /// The run event handler. - /// The custom host launcher. - [Obsolete("This API is not final yet and is subject to changes.", false)] - Task RunTestsWithCustomTestHostAsync( - IEnumerable sources, - string runSettings, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); - - /// - /// Starts a test run. - /// - /// - /// The list of source assemblies for the test run. - /// The run settings for the run. - /// The test platform options. - /// The run event handler. - /// The custom host launcher. - [Obsolete("This API is not final yet and is subject to changes.", false)] - Task RunTestsWithCustomTestHostAsync( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); - - /// - /// Starts a test run. - /// - /// - /// The list of test cases for the test run. - /// The run settings for the run. - /// The run event handler. - /// The custom host launcher. - [Obsolete("This API is not final yet and is subject to changes.", false)] - Task RunTestsWithCustomTestHostAsync( - IEnumerable testCases, - string runSettings, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); - - /// - /// Starts a test run. - /// - /// - /// The list of test cases for the test run. - /// The run settings for the run. - /// The test platform options. - /// The run event handler. - /// The custom host launcher. - [Obsolete("This API is not final yet and is subject to changes.", false)] - Task RunTestsWithCustomTestHostAsync( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); - - /// - /// Stops the test session. - /// - /// - /// True if the session was successfuly stopped, false otherwise. - [Obsolete("This API is not final yet and is subject to changes.", false)] - Task StopTestSessionAsync(); - - /// - /// Stops the test session. - /// - /// - /// The session event handler. - /// - /// True if the session was successfuly stopped, false otherwise. - [Obsolete("This API is not final yet and is subject to changes.", false)] - Task StopTestSessionAsync( - ITestSessionEventsHandler eventsHandler); - - /// - /// Cancels the last test run. - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - void CancelTestRun(); - - /// - /// Aborts the last test run. - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - void AbortTestRun(); - } -} + void AbortTestRun(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/ITranslationLayerRequestSender.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/ITranslationLayerRequestSender.cs index d4b19d826a..37f2edea05 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/ITranslationLayerRequestSender.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/ITranslationLayerRequestSender.cs @@ -1,182 +1,182 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces +namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; + +using System; +using System.Collections.Generic; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; + +/// +/// Defines contract to send test platform requests to test host +/// +internal interface ITranslationLayerRequestSender : IDisposable, ITranslationLayerRequestSenderAsync { - using System; - using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - - /// - /// Defines contract to send test platform requests to test host - /// - internal interface ITranslationLayerRequestSender : IDisposable, ITranslationLayerRequestSenderAsync - { - /// - /// Initializes communication with the vstest.console.exe process. - /// Hosts a communication channel and asynchronously connects to vstest.console.exe. - /// - /// - /// Port number of the hosted server on this side. - int InitializeCommunication(); - - /// - /// Waits for the request handler to be connected. - /// - /// - /// Time to wait for connection. - /// - /// True if the handler has connected, false otherwise. - bool WaitForRequestHandlerConnection(int connectionTimeout); - - /// - /// Closes the sender. - /// - void Close(); - - /// - /// Initializes the extensions while probing additional extension paths. - /// - /// - /// Paths to check for additional extensions. - void InitializeExtensions(IEnumerable pathToAdditionalExtensions); - - /// - /// Discovers the tests - /// - /// - /// Sources for discovering tests. - /// Run settings for discovering tests. - /// Options to be passed into the platform. - /// Test session info. - /// Event handler for discovery events. - void DiscoverTests( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestDiscoveryEventsHandler2 discoveryEventsHandler); - - /// - /// Starts the test run with given sources and criteria. - /// - /// - /// Sources for test run. - /// Run settings for test run. - /// Options to be passed into the platform. - /// Test session info. - /// Event handler for test run events. - void StartTestRun( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler runEventsHandler); - - /// - /// Starts the test run with given sources and criteria. - /// - /// - /// Test cases to run. - /// Run settings for test run. - /// Options to be passed into the platform. - /// Test session info. - /// Event handler for test run events. - void StartTestRun( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler runEventsHandler); - - /// - /// Starts the test run with given sources and criteria and a custom launcher. - /// - /// - /// Sources for test run. - /// Run settings for test run. - /// Options to be passed into the platform. - /// Test session info. - /// Event handler for test run events. - /// Custom test host launcher. - void StartTestRunWithCustomHost( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler runEventsHandler, - ITestHostLauncher customTestHostLauncher); - - /// - /// Starts the test run with given sources and criteria and a custom launcher. - /// - /// - /// Test cases to run. - /// Run settings for test run. - /// Options to be passed into the platform. - /// Test session info. - /// Event handler for test run events. - /// Custom test host launcher. - void StartTestRunWithCustomHost( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler runEventsHandler, - ITestHostLauncher customTestHostLauncher); - - /// - /// Starts a new test session. - /// - /// - /// Sources for test run. - /// Run settings for test run. - /// Options to be passed into the platform. - /// Event handler for test session events. - /// Custom test host launcher. - /// - TestSessionInfo StartTestSession( - IList sources, - string runSettings, - TestPlatformOptions options, - ITestSessionEventsHandler eventsHandler, - ITestHostLauncher testHostLauncher); - - /// - /// Stops the test session. - /// - /// - /// Test session info. - /// Event handler for test session events. - bool StopTestSession( - TestSessionInfo testSessionInfo, - ITestSessionEventsHandler eventsHandler); - - /// - /// Ends the session. - /// - void EndSession(); - - /// - /// Cancels the test run. - /// - void CancelTestRun(); - - /// - /// Aborts the test run. - /// - void AbortTestRun(); - - /// - /// On process exit unblocks communication waiting calls. - /// - void OnProcessExited(); - - /// - /// Cancels the discovery of tests. - /// - void CancelDiscovery(); - } -} + /// + /// Initializes communication with the vstest.console.exe process. + /// Hosts a communication channel and asynchronously connects to vstest.console.exe. + /// + /// + /// Port number of the hosted server on this side. + int InitializeCommunication(); + + /// + /// Waits for the request handler to be connected. + /// + /// + /// Time to wait for connection. + /// + /// True if the handler has connected, false otherwise. + bool WaitForRequestHandlerConnection(int connectionTimeout); + + /// + /// Closes the sender. + /// + void Close(); + + /// + /// Initializes the extensions while probing additional extension paths. + /// + /// + /// Paths to check for additional extensions. + void InitializeExtensions(IEnumerable pathToAdditionalExtensions); + + /// + /// Discovers the tests + /// + /// + /// Sources for discovering tests. + /// Run settings for discovering tests. + /// Options to be passed into the platform. + /// Test session info. + /// Event handler for discovery events. + void DiscoverTests( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestDiscoveryEventsHandler2 discoveryEventsHandler); + + /// + /// Starts the test run with given sources and criteria. + /// + /// + /// Sources for test run. + /// Run settings for test run. + /// Options to be passed into the platform. + /// Test session info. + /// Event handler for test run events. + void StartTestRun( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler runEventsHandler); + + /// + /// Starts the test run with given sources and criteria. + /// + /// + /// Test cases to run. + /// Run settings for test run. + /// Options to be passed into the platform. + /// Test session info. + /// Event handler for test run events. + void StartTestRun( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler runEventsHandler); + + /// + /// Starts the test run with given sources and criteria and a custom launcher. + /// + /// + /// Sources for test run. + /// Run settings for test run. + /// Options to be passed into the platform. + /// Test session info. + /// Event handler for test run events. + /// Custom test host launcher. + void StartTestRunWithCustomHost( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler runEventsHandler, + ITestHostLauncher customTestHostLauncher); + + /// + /// Starts the test run with given sources and criteria and a custom launcher. + /// + /// + /// Test cases to run. + /// Run settings for test run. + /// Options to be passed into the platform. + /// Test session info. + /// Event handler for test run events. + /// Custom test host launcher. + void StartTestRunWithCustomHost( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler runEventsHandler, + ITestHostLauncher customTestHostLauncher); + + /// + /// Starts a new test session. + /// + /// + /// Sources for test run. + /// Run settings for test run. + /// Options to be passed into the platform. + /// Event handler for test session events. + /// Custom test host launcher. + /// + TestSessionInfo StartTestSession( + IList sources, + string runSettings, + TestPlatformOptions options, + ITestSessionEventsHandler eventsHandler, + ITestHostLauncher testHostLauncher); + + /// + /// Stops the test session. + /// + /// + /// Test session info. + /// Event handler for test session events. + bool StopTestSession( + TestSessionInfo testSessionInfo, + ITestSessionEventsHandler eventsHandler); + + /// + /// Ends the session. + /// + void EndSession(); + + /// + /// Cancels the test run. + /// + void CancelTestRun(); + + /// + /// Aborts the test run. + /// + void AbortTestRun(); + + /// + /// On process exit unblocks communication waiting calls. + /// + void OnProcessExited(); + + /// + /// Cancels the discovery of tests. + /// + void CancelDiscovery(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/ITranslationLayerRequestSenderAsync.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/ITranslationLayerRequestSenderAsync.cs index d8acafe788..4075358c3a 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/ITranslationLayerRequestSenderAsync.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/ITranslationLayerRequestSenderAsync.cs @@ -1,152 +1,151 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces -{ - using System; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; +namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +/// +/// Asynchronous equivalent of . +/// +internal interface ITranslationLayerRequestSenderAsync : IDisposable +{ /// - /// Asynchronous equivalent of . + /// Asynchronous equivalent of + /// and . /// - internal interface ITranslationLayerRequestSenderAsync : IDisposable - { - /// - /// Asynchronous equivalent of - /// and . - /// - Task InitializeCommunicationAsync(int clientConnectionTimeout); + Task InitializeCommunicationAsync(int clientConnectionTimeout); - /// - /// Asynchronous equivalent of ITranslationLayerRequestSender.DiscoverTests/>. - /// - Task DiscoverTestsAsync( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestDiscoveryEventsHandler2 discoveryEventsHandler); + /// + /// Asynchronous equivalent of ITranslationLayerRequestSender.DiscoverTests/>. + /// + Task DiscoverTestsAsync( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestDiscoveryEventsHandler2 discoveryEventsHandler); - /// - /// Asynchronous equivalent of . - /// - Task StartTestRunAsync( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler runEventsHandler); + /// + /// Asynchronous equivalent of . + /// + Task StartTestRunAsync( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler runEventsHandler); - /// - /// Asynchronous equivalent of . - /// - Task StartTestRunAsync( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler runEventsHandler); + /// + /// Asynchronous equivalent of . + /// + Task StartTestRunAsync( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler runEventsHandler); - /// - /// Asynchronous equivalent of . - /// - Task StartTestRunWithCustomHostAsync( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler runEventsHandler, - ITestHostLauncher customTestHostLauncher); + /// + /// Asynchronous equivalent of . + /// + Task StartTestRunWithCustomHostAsync( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler runEventsHandler, + ITestHostLauncher customTestHostLauncher); - /// - /// Asynchronous equivalent of . - /// - Task StartTestRunWithCustomHostAsync( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler runEventsHandler, - ITestHostLauncher customTestHostLauncher); + /// + /// Asynchronous equivalent of . + /// + Task StartTestRunWithCustomHostAsync( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler runEventsHandler, + ITestHostLauncher customTestHostLauncher); - /// - /// Asynchronous equivalent of . - /// - Task StartTestSessionAsync( - IList sources, - string runSettings, - TestPlatformOptions options, - ITestSessionEventsHandler eventsHandler, - ITestHostLauncher testHostLauncher); + /// + /// Asynchronous equivalent of . + /// + Task StartTestSessionAsync( + IList sources, + string runSettings, + TestPlatformOptions options, + ITestSessionEventsHandler eventsHandler, + ITestHostLauncher testHostLauncher); - /// - /// Asynchronous equivalent of . - /// - Task StopTestSessionAsync( - TestSessionInfo testSessionInfo, - ITestSessionEventsHandler eventsHandler); + /// + /// Asynchronous equivalent of . + /// + Task StopTestSessionAsync( + TestSessionInfo testSessionInfo, + ITestSessionEventsHandler eventsHandler); - /// - /// Provides back all attachments to test platform for additional processing (for example - /// merging). - /// - /// - /// Collection of attachments. - /// Collection of invoked data collectors. - /// RunSettings configuration - /// Enables metrics collection. - /// Events handler. - /// Cancellation token. - Task ProcessTestRunAttachmentsAsync( - IEnumerable attachments, - IEnumerable invokedDataCollectors, - string runSettings, - bool collectMetrics, - ITestRunAttachmentsProcessingEventsHandler testRunAttachmentsProcessingCompleteEventsHandler, - CancellationToken cancellationToken); - } -} + /// + /// Provides back all attachments to test platform for additional processing (for example + /// merging). + /// + /// + /// Collection of attachments. + /// Collection of invoked data collectors. + /// RunSettings configuration + /// Enables metrics collection. + /// Events handler. + /// Cancellation token. + Task ProcessTestRunAttachmentsAsync( + IEnumerable attachments, + IEnumerable invokedDataCollectors, + string runSettings, + bool collectMetrics, + ITestRunAttachmentsProcessingEventsHandler testRunAttachmentsProcessingCompleteEventsHandler, + CancellationToken cancellationToken); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/IVsTestConsoleWrapper.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/IVsTestConsoleWrapper.cs index 23dde8cbae..1425b31acf 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/IVsTestConsoleWrapper.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/IVsTestConsoleWrapper.cs @@ -1,337 +1,337 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces -{ - using System; - using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; +namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; + +using System; +using System.Collections.Generic; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using Microsoft.VisualStudio.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; + +/// +/// Controller for various test operations on the test runner. +/// +public interface IVsTestConsoleWrapper : IVsTestConsoleWrapperAsync +{ /// - /// Controller for various test operations on the test runner. + /// Starts the test runner process and readies for requests. /// - public interface IVsTestConsoleWrapper : IVsTestConsoleWrapperAsync - { - /// - /// Starts the test runner process and readies for requests. - /// - void StartSession(); + void StartSession(); - /// - /// Starts a new test session. - /// - /// - /// The list of source assemblies for the test run. - /// The run settings for the run. - /// The session event handler. - /// - /// A test session info object. - [Obsolete("This API is not final yet and is subject to changes.", false)] - ITestSession StartTestSession( - IList sources, - string runSettings, - ITestSessionEventsHandler eventsHandler); + /// + /// Starts a new test session. + /// + /// + /// The list of source assemblies for the test run. + /// The run settings for the run. + /// The session event handler. + /// + /// A test session info object. + [Obsolete("This API is not final yet and is subject to changes.", false)] + ITestSession StartTestSession( + IList sources, + string runSettings, + ITestSessionEventsHandler eventsHandler); - /// - /// Starts a new test session. - /// - /// - /// The list of source assemblies for the test run. - /// The run settings for the run. - /// The test platform options. - /// The session event handler. - /// - /// A test session info object. - [Obsolete("This API is not final yet and is subject to changes.", false)] - ITestSession StartTestSession( - IList sources, - string runSettings, - TestPlatformOptions options, - ITestSessionEventsHandler eventsHandler); + /// + /// Starts a new test session. + /// + /// + /// The list of source assemblies for the test run. + /// The run settings for the run. + /// The test platform options. + /// The session event handler. + /// + /// A test session info object. + [Obsolete("This API is not final yet and is subject to changes.", false)] + ITestSession StartTestSession( + IList sources, + string runSettings, + TestPlatformOptions options, + ITestSessionEventsHandler eventsHandler); - /// - /// Starts a new test session. - /// - /// - /// The list of source assemblies for the test run. - /// The run settings for the run. - /// The test platform options. - /// The session event handler. - /// The custom host launcher. - /// - /// A test session info object. - [Obsolete("This API is not final yet and is subject to changes.", false)] - ITestSession StartTestSession( - IList sources, - string runSettings, - TestPlatformOptions options, - ITestSessionEventsHandler eventsHandler, - ITestHostLauncher testHostLauncher); + /// + /// Starts a new test session. + /// + /// + /// The list of source assemblies for the test run. + /// The run settings for the run. + /// The test platform options. + /// The session event handler. + /// The custom host launcher. + /// + /// A test session info object. + [Obsolete("This API is not final yet and is subject to changes.", false)] + ITestSession StartTestSession( + IList sources, + string runSettings, + TestPlatformOptions options, + ITestSessionEventsHandler eventsHandler, + ITestHostLauncher testHostLauncher); - /// - /// Stops the test session. - /// - /// - /// The test session info object. - /// The session event handler. - /// - /// True if the session was successfuly stopped, false otherwise. - [Obsolete("This API is not final yet and is subject to changes.", false)] - bool StopTestSession( - TestSessionInfo testSessionInfo, - ITestSessionEventsHandler eventsHandler); + /// + /// Stops the test session. + /// + /// + /// The test session info object. + /// The session event handler. + /// + /// True if the session was successfuly stopped, false otherwise. + [Obsolete("This API is not final yet and is subject to changes.", false)] + bool StopTestSession( + TestSessionInfo testSessionInfo, + ITestSessionEventsHandler eventsHandler); - /// - /// Initializes the test platform with paths to extensions like adapters, loggers and any - /// other extensions. - /// - /// - /// Full paths to extension DLLs. - void InitializeExtensions(IEnumerable pathToAdditionalExtensions); + /// + /// Initializes the test platform with paths to extensions like adapters, loggers and any + /// other extensions. + /// + /// + /// Full paths to extension DLLs. + void InitializeExtensions(IEnumerable pathToAdditionalExtensions); - /// - /// Starts test discovery. - /// - /// - /// The list of source assemblies for the discovery. - /// The run settings for the discovery. - /// The discovery event handler. - void DiscoverTests( - IEnumerable sources, - string discoverySettings, - ITestDiscoveryEventsHandler discoveryEventsHandler); + /// + /// Starts test discovery. + /// + /// + /// The list of source assemblies for the discovery. + /// The run settings for the discovery. + /// The discovery event handler. + void DiscoverTests( + IEnumerable sources, + string discoverySettings, + ITestDiscoveryEventsHandler discoveryEventsHandler); - /// - /// Starts test discovery. - /// - /// - /// The list of source assemblies for the discovery. - /// The run settings for the discovery. - /// The test platform options. - /// The discovery event handler. - void DiscoverTests( - IEnumerable sources, - string discoverySettings, - TestPlatformOptions options, - ITestDiscoveryEventsHandler2 discoveryEventsHandler); + /// + /// Starts test discovery. + /// + /// + /// The list of source assemblies for the discovery. + /// The run settings for the discovery. + /// The test platform options. + /// The discovery event handler. + void DiscoverTests( + IEnumerable sources, + string discoverySettings, + TestPlatformOptions options, + ITestDiscoveryEventsHandler2 discoveryEventsHandler); - /// - /// Starts test discovery. - /// - /// - /// The list of source assemblies for the discovery. - /// The run settings for the discovery. - /// The test platform options. - /// The test session info object. - /// The discovery event handler. - void DiscoverTests( - IEnumerable sources, - string discoverySettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestDiscoveryEventsHandler2 discoveryEventsHandler); + /// + /// Starts test discovery. + /// + /// + /// The list of source assemblies for the discovery. + /// The run settings for the discovery. + /// The test platform options. + /// The test session info object. + /// The discovery event handler. + void DiscoverTests( + IEnumerable sources, + string discoverySettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestDiscoveryEventsHandler2 discoveryEventsHandler); - /// - /// Cancels the last discovery request. - /// - new void CancelDiscovery(); + /// + /// Cancels the last discovery request. + /// + new void CancelDiscovery(); - /// - /// Starts a test run. - /// - /// - /// The list of source assemblies for the test run. - /// The run settings for the run. - /// The run event handler. - void RunTests( - IEnumerable sources, - string runSettings, - ITestRunEventsHandler testRunEventsHandler); + /// + /// Starts a test run. + /// + /// + /// The list of source assemblies for the test run. + /// The run settings for the run. + /// The run event handler. + void RunTests( + IEnumerable sources, + string runSettings, + ITestRunEventsHandler testRunEventsHandler); - /// - /// Starts a test run. - /// - /// - /// The list of source assemblies for the test run. - /// The run settings for the run. - /// The test platform options. - /// The run event handler. - void RunTests( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler); + /// + /// Starts a test run. + /// + /// + /// The list of source assemblies for the test run. + /// The run settings for the run. + /// The test platform options. + /// The run event handler. + void RunTests( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler); - /// - /// Starts a test run. - /// - /// - /// The list of source assemblies for the test run. - /// The run settings for the run. - /// The test platform options. - /// The test session info object. - /// The run event handler. - void RunTests( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler testRunEventsHandler); + /// + /// Starts a test run. + /// + /// + /// The list of source assemblies for the test run. + /// The run settings for the run. + /// The test platform options. + /// The test session info object. + /// The run event handler. + void RunTests( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler testRunEventsHandler); - /// - /// Starts a test run. - /// - /// - /// The list of test cases for the test run. - /// The run settings for the run. - /// The run event handler. - void RunTests( - IEnumerable testCases, - string runSettings, - ITestRunEventsHandler testRunEventsHandler); + /// + /// Starts a test run. + /// + /// + /// The list of test cases for the test run. + /// The run settings for the run. + /// The run event handler. + void RunTests( + IEnumerable testCases, + string runSettings, + ITestRunEventsHandler testRunEventsHandler); - /// - /// Starts a test run. - /// - /// - /// The list of test cases for the test run. - /// The run settings for the run. - /// The test platform options. - /// The run event handler. - void RunTests( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler); + /// + /// Starts a test run. + /// + /// + /// The list of test cases for the test run. + /// The run settings for the run. + /// The test platform options. + /// The run event handler. + void RunTests( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler); - /// - /// Starts a test run. - /// - /// - /// The list of test cases for the test run. - /// The run settings for the run. - /// The test platform options. - /// The test session info object. - /// The run event handler. - void RunTests( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler testRunEventsHandler); + /// + /// Starts a test run. + /// + /// + /// The list of test cases for the test run. + /// The run settings for the run. + /// The test platform options. + /// The test session info object. + /// The run event handler. + void RunTests( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler testRunEventsHandler); - /// - /// Starts a test run. - /// - /// - /// The list of source assemblies for the test run. - /// The run settings for the run. - /// The run event handler. - /// The custom host launcher. - void RunTestsWithCustomTestHost( - IEnumerable sources, - string runSettings, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); + /// + /// Starts a test run. + /// + /// + /// The list of source assemblies for the test run. + /// The run settings for the run. + /// The run event handler. + /// The custom host launcher. + void RunTestsWithCustomTestHost( + IEnumerable sources, + string runSettings, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); - /// - /// Starts a test run. - /// - /// - /// The list of source assemblies for the test run. - /// The run settings for the run. - /// The test platform options. - /// The run event handler. - /// The custom host launcher. - void RunTestsWithCustomTestHost( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); + /// + /// Starts a test run. + /// + /// + /// The list of source assemblies for the test run. + /// The run settings for the run. + /// The test platform options. + /// The run event handler. + /// The custom host launcher. + void RunTestsWithCustomTestHost( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); - /// - /// Starts a test run. - /// - /// - /// The list of source assemblies for the test run. - /// The run settings for the run. - /// The test platform options. - /// The test session info object. - /// The run event handler. - /// The custom host launcher. - void RunTestsWithCustomTestHost( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); + /// + /// Starts a test run. + /// + /// + /// The list of source assemblies for the test run. + /// The run settings for the run. + /// The test platform options. + /// The test session info object. + /// The run event handler. + /// The custom host launcher. + void RunTestsWithCustomTestHost( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); - /// - /// Starts a test run. - /// - /// - /// The list of test cases for the test run. - /// The run settings for the run. - /// The run event handler. - /// The custom host launcher. - void RunTestsWithCustomTestHost( - IEnumerable testCases, - string runSettings, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); + /// + /// Starts a test run. + /// + /// + /// The list of test cases for the test run. + /// The run settings for the run. + /// The run event handler. + /// The custom host launcher. + void RunTestsWithCustomTestHost( + IEnumerable testCases, + string runSettings, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); - /// - /// Starts a test run. - /// - /// - /// The list of test cases for the test run. - /// The run settings for the run. - /// The test platform options. - /// The run event handler. - /// The custom host launcher. - void RunTestsWithCustomTestHost( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); + /// + /// Starts a test run. + /// + /// + /// The list of test cases for the test run. + /// The run settings for the run. + /// The test platform options. + /// The run event handler. + /// The custom host launcher. + void RunTestsWithCustomTestHost( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); - /// - /// Starts a test run. - /// - /// - /// The list of test cases for the test run. - /// The run settings for the run. - /// The test platform options. - /// The test session info object. - /// The run event handler. - /// The custom host launcher. - void RunTestsWithCustomTestHost( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); + /// + /// Starts a test run. + /// + /// + /// The list of test cases for the test run. + /// The run settings for the run. + /// The test platform options. + /// The test session info object. + /// The run event handler. + /// The custom host launcher. + void RunTestsWithCustomTestHost( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); - /// - /// Cancels the last test run. - /// - new void CancelTestRun(); + /// + /// Cancels the last test run. + /// + new void CancelTestRun(); - /// - /// Aborts the last test run. - /// - new void AbortTestRun(); + /// + /// Aborts the last test run. + /// + new void AbortTestRun(); - /// - /// Ends the test session and stops processing requests. - /// - new void EndSession(); - } -} + /// + /// Ends the test session and stops processing requests. + /// + new void EndSession(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/IVsTestConsoleWrapperAsync.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/IVsTestConsoleWrapperAsync.cs index 478b44fa25..a18b05632a 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/IVsTestConsoleWrapperAsync.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Interfaces/IVsTestConsoleWrapperAsync.cs @@ -1,373 +1,372 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces -{ - using System; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; +namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using Microsoft.VisualStudio.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; +/// +/// Asynchronous equivalent of . +/// +public interface IVsTestConsoleWrapperAsync +{ /// - /// Asynchronous equivalent of . + /// Asynchronous equivalent of . /// - public interface IVsTestConsoleWrapperAsync - { - /// - /// Asynchronous equivalent of . - /// - Task StartSessionAsync(); + Task StartSessionAsync(); - /// - /// Asynchronous equivalent of . - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - Task StartTestSessionAsync( - IList sources, - string runSettings, - ITestSessionEventsHandler eventsHandler); + /// + /// Asynchronous equivalent of . + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + Task StartTestSessionAsync( + IList sources, + string runSettings, + ITestSessionEventsHandler eventsHandler); - /// - /// Asynchronous equivalent of . - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - Task StartTestSessionAsync( - IList sources, - string runSettings, - TestPlatformOptions options, - ITestSessionEventsHandler eventsHandler); + /// + /// Asynchronous equivalent of . + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + Task StartTestSessionAsync( + IList sources, + string runSettings, + TestPlatformOptions options, + ITestSessionEventsHandler eventsHandler); - /// - /// Asynchronous equivalent of . - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - Task StartTestSessionAsync( - IList sources, - string runSettings, - TestPlatformOptions options, - ITestSessionEventsHandler eventsHandler, - ITestHostLauncher testHostLauncher); + /// + /// Asynchronous equivalent of . + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + Task StartTestSessionAsync( + IList sources, + string runSettings, + TestPlatformOptions options, + ITestSessionEventsHandler eventsHandler, + ITestHostLauncher testHostLauncher); - /// - /// Asynchronous equivalent of . - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - Task StopTestSessionAsync( - TestSessionInfo testSessionInfo, - ITestSessionEventsHandler eventsHandler); + /// + /// Asynchronous equivalent of . + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + Task StopTestSessionAsync( + TestSessionInfo testSessionInfo, + ITestSessionEventsHandler eventsHandler); - /// - /// Asynchronous equivalent of . - /// - Task InitializeExtensionsAsync(IEnumerable pathToAdditionalExtensions); + /// + /// Asynchronous equivalent of . + /// + Task InitializeExtensionsAsync(IEnumerable pathToAdditionalExtensions); - /// - /// Asynchronous equivalent of . - /// - Task DiscoverTestsAsync( - IEnumerable sources, - string discoverySettings, - ITestDiscoveryEventsHandler discoveryEventsHandler); + /// + /// Asynchronous equivalent of . + /// + Task DiscoverTestsAsync( + IEnumerable sources, + string discoverySettings, + ITestDiscoveryEventsHandler discoveryEventsHandler); - /// - /// Asynchronous equivalent of . - /// - Task DiscoverTestsAsync( - IEnumerable sources, - string discoverySettings, - TestPlatformOptions options, - ITestDiscoveryEventsHandler2 discoveryEventsHandler); + /// + /// Asynchronous equivalent of . + /// + Task DiscoverTestsAsync( + IEnumerable sources, + string discoverySettings, + TestPlatformOptions options, + ITestDiscoveryEventsHandler2 discoveryEventsHandler); - /// - /// Asynchronous equivalent of . - /// - Task DiscoverTestsAsync( - IEnumerable sources, - string discoverySettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestDiscoveryEventsHandler2 discoveryEventsHandler); + /// + /// Asynchronous equivalent of . + /// + Task DiscoverTestsAsync( + IEnumerable sources, + string discoverySettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestDiscoveryEventsHandler2 discoveryEventsHandler); - /// - /// See . - /// - void CancelDiscovery(); + /// + /// See . + /// + void CancelDiscovery(); - /// - /// Asynchronous equivalent of . - /// - Task RunTestsAsync( - IEnumerable sources, - string runSettings, - ITestRunEventsHandler testRunEventsHandler); + /// + /// Asynchronous equivalent of . + /// + Task RunTestsAsync( + IEnumerable sources, + string runSettings, + ITestRunEventsHandler testRunEventsHandler); - /// - /// Asynchronous equivalent of . - /// - Task RunTestsAsync( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler); + /// + /// Asynchronous equivalent of . + /// + Task RunTestsAsync( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler); - /// - /// Asynchronous equivalent of . - /// - Task RunTestsAsync( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler testRunEventsHandler); + /// + /// Asynchronous equivalent of . + /// + Task RunTestsAsync( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler testRunEventsHandler); - /// - /// Asynchronous equivalent of . - /// - Task RunTestsAsync( - IEnumerable testCases, - string runSettings, - ITestRunEventsHandler testRunEventsHandler); + /// + /// Asynchronous equivalent of . + /// + Task RunTestsAsync( + IEnumerable testCases, + string runSettings, + ITestRunEventsHandler testRunEventsHandler); - /// - /// Asynchronous equivalent of . - /// - Task RunTestsAsync( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler); + /// + /// Asynchronous equivalent of . + /// + Task RunTestsAsync( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler); - /// - /// Asynchronous equivalent of . - /// - Task RunTestsAsync( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler testRunEventsHandler); + /// + /// Asynchronous equivalent of . + /// + Task RunTestsAsync( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler testRunEventsHandler); - /// - /// Asynchronous equivalent of . - /// - Task RunTestsWithCustomTestHostAsync( - IEnumerable sources, - string runSettings, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); + /// + /// Asynchronous equivalent of . + /// + Task RunTestsWithCustomTestHostAsync( + IEnumerable sources, + string runSettings, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); - /// - /// Asynchronous equivalent of . - /// - Task RunTestsWithCustomTestHostAsync( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); + /// + /// Asynchronous equivalent of . + /// + Task RunTestsWithCustomTestHostAsync( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); - /// - /// Asynchronous equivalent of . - /// - Task RunTestsWithCustomTestHostAsync( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); + /// + /// Asynchronous equivalent of . + /// + Task RunTestsWithCustomTestHostAsync( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); - /// - /// Asynchronous equivalent of . - /// - Task RunTestsWithCustomTestHostAsync( - IEnumerable testCases, - string runSettings, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); + /// + /// Asynchronous equivalent of . + /// + Task RunTestsWithCustomTestHostAsync( + IEnumerable testCases, + string runSettings, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); - /// - /// Asynchronous equivalent of . - /// - Task RunTestsWithCustomTestHostAsync( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); + /// + /// Asynchronous equivalent of . + /// + Task RunTestsWithCustomTestHostAsync( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); - /// - /// Asynchronous equivalent of . - /// - Task RunTestsWithCustomTestHostAsync( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher); + /// + /// Asynchronous equivalent of . + /// + Task RunTestsWithCustomTestHostAsync( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher); - /// - /// See . - /// - void CancelTestRun(); + /// + /// See . + /// + void CancelTestRun(); - /// - /// See . - /// - void AbortTestRun(); + /// + /// See . + /// + void AbortTestRun(); - /// - /// Gets back all attachments to test platform for additional processing (for example merging). - /// - /// - /// Collection of attachments. - /// XML processing settings. - /// - /// Indicates that all test executions are done and all data is provided. - /// - /// Enables metrics collection (used for telemetry). - /// Event handler to receive session complete event. - /// Cancellation token. - Task ProcessTestRunAttachmentsAsync( - IEnumerable attachments, - string processingSettings, - bool isLastBatch, - bool collectMetrics, - ITestRunAttachmentsProcessingEventsHandler eventsHandler, - CancellationToken cancellationToken); + /// + /// Gets back all attachments to test platform for additional processing (for example merging). + /// + /// + /// Collection of attachments. + /// XML processing settings. + /// + /// Indicates that all test executions are done and all data is provided. + /// + /// Enables metrics collection (used for telemetry). + /// Event handler to receive session complete event. + /// Cancellation token. + Task ProcessTestRunAttachmentsAsync( + IEnumerable attachments, + string processingSettings, + bool isLastBatch, + bool collectMetrics, + ITestRunAttachmentsProcessingEventsHandler eventsHandler, + CancellationToken cancellationToken); - /// - /// Gets back all attachments to test platform for additional processing (for example merging). - /// - /// - /// Collection of attachments. - /// Collection of invoked data collectors. - /// XML processing settings. - /// - /// Indicates that all test executions are done and all data is provided. - /// - /// Enables metrics collection (used for telemetry). - /// Event handler to receive session complete event. - /// Cancellation token. - Task ProcessTestRunAttachmentsAsync( - IEnumerable attachments, - IEnumerable invokedDataCollectors, - string processingSettings, - bool isLastBatch, - bool collectMetrics, - ITestRunAttachmentsProcessingEventsHandler eventsHandler, - CancellationToken cancellationToken); + /// + /// Gets back all attachments to test platform for additional processing (for example merging). + /// + /// + /// Collection of attachments. + /// Collection of invoked data collectors. + /// XML processing settings. + /// + /// Indicates that all test executions are done and all data is provided. + /// + /// Enables metrics collection (used for telemetry). + /// Event handler to receive session complete event. + /// Cancellation token. + Task ProcessTestRunAttachmentsAsync( + IEnumerable attachments, + IEnumerable invokedDataCollectors, + string processingSettings, + bool isLastBatch, + bool collectMetrics, + ITestRunAttachmentsProcessingEventsHandler eventsHandler, + CancellationToken cancellationToken); - /// - /// See . - /// - void EndSession(); - } -} + /// + /// See . + /// + void EndSession(); +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Properties/AssemblyInfo.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Properties/AssemblyInfo.cs index a68e7c5899..700e408f79 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Properties/AssemblyInfo.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Properties/AssemblyInfo.cs @@ -23,8 +23,8 @@ [assembly: Guid("b5e3af48-222f-4378-9ed9-f0238e2a278e")] //To make visible internal interface to unittests -[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=00240000048000009"+ - "40000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a360"+ - "2f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0ba"+ - "c1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924"+ +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=00240000048000009" + + "40000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a360" + + "2f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0ba" + + "c1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924" + "cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/TestSession.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/TestSession.cs index 9db1bf6fc3..90bac8c08f 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/TestSession.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/TestSession.cs @@ -1,483 +1,483 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer +namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer; + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +using Interfaces; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using Microsoft.VisualStudio.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; + +/// +/// Defines a test session object that can be used to make calls to the vstest.console +/// process. +/// +[Obsolete("This API is not final yet and is subject to changes.", false)] +public class TestSession : ITestSession { - using System; - using System.Collections.Generic; - using System.Threading.Tasks; + private bool _disposed = false; + + private readonly ITestSessionEventsHandler _eventsHandler; + private readonly IVsTestConsoleWrapper _consoleWrapper; - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; + #region Properties + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public TestSessionInfo TestSessionInfo { get; private set; } + #endregion + #region Constructors /// - /// Defines a test session object that can be used to make calls to the vstest.console - /// process. + /// Initializes a new instance of the class. /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public class TestSession : ITestSession + /// + /// The test session info object. + /// The session event handler. + /// The encapsulated console wrapper. + public TestSession( + TestSessionInfo testSessionInfo, + ITestSessionEventsHandler eventsHandler, + IVsTestConsoleWrapper consoleWrapper) { - private bool disposed = false; - - private readonly ITestSessionEventsHandler eventsHandler; - private readonly IVsTestConsoleWrapper consoleWrapper; - - #region Properties - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public TestSessionInfo TestSessionInfo { get; private set; } - #endregion - - #region Constructors - /// - /// Initializes a new instance of the class. - /// - /// - /// The test session info object. - /// The session event handler. - /// The encapsulated console wrapper. - public TestSession( - TestSessionInfo testSessionInfo, - ITestSessionEventsHandler eventsHandler, - IVsTestConsoleWrapper consoleWrapper) - { - this.TestSessionInfo = testSessionInfo; - this.eventsHandler = eventsHandler; - this.consoleWrapper = consoleWrapper; - } + TestSessionInfo = testSessionInfo; + _eventsHandler = eventsHandler; + _consoleWrapper = consoleWrapper; + } + + /// + /// Destroys the current instance of the class. + /// + ~TestSession() => Dispose(false); - /// - /// Destroys the current instance of the class. - /// - ~TestSession() => this.Dispose(false); + /// + /// Disposes of the current instance of the class. + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - /// - /// Disposes of the current instance of the class. - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public void Dispose() + /// + /// Disposes of the current instance of the class. + /// + /// + /// Indicates if managed resources should be disposed. + protected virtual void Dispose(bool disposing) + { + if (_disposed) { - this.Dispose(true); - GC.SuppressFinalize(this); + return; } - /// - /// Disposes of the current instance of the class. - /// - /// - /// Indicates if managed resources should be disposed. - protected virtual void Dispose(bool disposing) - { - if (this.disposed) - { - return; - } + StopTestSession(); + _disposed = true; + } + #endregion - this.StopTestSession(); - this.disposed = true; - } - #endregion + #region ITestSession + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public void AbortTestRun() + { + _consoleWrapper.AbortTestRun(); + } - #region ITestSession - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public void AbortTestRun() - { - this.consoleWrapper.AbortTestRun(); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public void CancelDiscovery() + { + _consoleWrapper.CancelDiscovery(); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public void CancelDiscovery() - { - this.consoleWrapper.CancelDiscovery(); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public void CancelTestRun() + { + _consoleWrapper.CancelTestRun(); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public void CancelTestRun() - { - this.consoleWrapper.CancelTestRun(); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public void DiscoverTests( + IEnumerable sources, + string discoverySettings, + ITestDiscoveryEventsHandler discoveryEventsHandler) + { + DiscoverTests( + sources, + discoverySettings, + options: null, + discoveryEventsHandler: new DiscoveryEventsHandleConverter(discoveryEventsHandler)); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public void DiscoverTests( - IEnumerable sources, - string discoverySettings, - ITestDiscoveryEventsHandler discoveryEventsHandler) - { - this.DiscoverTests( - sources, - discoverySettings, - options: null, - discoveryEventsHandler: new DiscoveryEventsHandleConverter(discoveryEventsHandler)); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public void DiscoverTests( + IEnumerable sources, + string discoverySettings, + TestPlatformOptions options, + ITestDiscoveryEventsHandler2 discoveryEventsHandler) + { + _consoleWrapper.DiscoverTests( + sources, + discoverySettings, + options, + TestSessionInfo, + discoveryEventsHandler); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public void DiscoverTests( - IEnumerable sources, - string discoverySettings, - TestPlatformOptions options, - ITestDiscoveryEventsHandler2 discoveryEventsHandler) - { - this.consoleWrapper.DiscoverTests( - sources, - discoverySettings, - options, - this.TestSessionInfo, - discoveryEventsHandler); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public void RunTests( + IEnumerable sources, + string runSettings, + ITestRunEventsHandler testRunEventsHandler) + { + RunTests( + sources, + runSettings, + options: null, + testRunEventsHandler); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public void RunTests( - IEnumerable sources, - string runSettings, - ITestRunEventsHandler testRunEventsHandler) - { - this.RunTests( - sources, - runSettings, - options: null, - testRunEventsHandler); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public void RunTests( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler) + { + _consoleWrapper.RunTests( + sources, + runSettings, + options, + TestSessionInfo, + testRunEventsHandler); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public void RunTests( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler) - { - this.consoleWrapper.RunTests( - sources, - runSettings, - options, - this.TestSessionInfo, - testRunEventsHandler); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public void RunTests( + IEnumerable testCases, + string runSettings, + ITestRunEventsHandler testRunEventsHandler) + { + RunTests( + testCases, + runSettings, + options: null, + testRunEventsHandler); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public void RunTests( - IEnumerable testCases, - string runSettings, - ITestRunEventsHandler testRunEventsHandler) - { - this.RunTests( - testCases, - runSettings, - options: null, - testRunEventsHandler); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public void RunTests( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler) + { + _consoleWrapper.RunTests( + testCases, + runSettings, + options, + TestSessionInfo, + testRunEventsHandler); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public void RunTests( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler) - { - this.consoleWrapper.RunTests( - testCases, - runSettings, - options, - this.TestSessionInfo, - testRunEventsHandler); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public void RunTestsWithCustomTestHost( + IEnumerable sources, + string runSettings, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + RunTestsWithCustomTestHost( + sources, + runSettings, + options: null, + testRunEventsHandler, + customTestHostLauncher); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public void RunTestsWithCustomTestHost( - IEnumerable sources, - string runSettings, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) - { - this.RunTestsWithCustomTestHost( - sources, - runSettings, - options: null, - testRunEventsHandler, - customTestHostLauncher); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public void RunTestsWithCustomTestHost( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + _consoleWrapper.RunTestsWithCustomTestHost( + sources, + runSettings, + options, + TestSessionInfo, + testRunEventsHandler, + customTestHostLauncher); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public void RunTestsWithCustomTestHost( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) - { - this.consoleWrapper.RunTestsWithCustomTestHost( - sources, - runSettings, - options, - this.TestSessionInfo, - testRunEventsHandler, - customTestHostLauncher); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public void RunTestsWithCustomTestHost( + IEnumerable testCases, + string runSettings, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + RunTestsWithCustomTestHost( + testCases, + runSettings, + options: null, + testRunEventsHandler, + customTestHostLauncher); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public void RunTestsWithCustomTestHost( - IEnumerable testCases, - string runSettings, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) - { - this.RunTestsWithCustomTestHost( - testCases, - runSettings, - options: null, - testRunEventsHandler, - customTestHostLauncher); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public void RunTestsWithCustomTestHost( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + _consoleWrapper.RunTestsWithCustomTestHost( + testCases, + runSettings, + options, + TestSessionInfo, + testRunEventsHandler, + customTestHostLauncher); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public void RunTestsWithCustomTestHost( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) - { - this.consoleWrapper.RunTestsWithCustomTestHost( - testCases, - runSettings, - options, - this.TestSessionInfo, - testRunEventsHandler, - customTestHostLauncher); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public bool StopTestSession() + { + return StopTestSession(_eventsHandler); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public bool StopTestSession() + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public bool StopTestSession(ITestSessionEventsHandler eventsHandler) + { + if (TestSessionInfo == null) { - return this.StopTestSession(this.eventsHandler); + return true; } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public bool StopTestSession(ITestSessionEventsHandler eventsHandler) + try { - if (this.TestSessionInfo == null) - { - return true; - } - - try - { - return this.consoleWrapper.StopTestSession( - this.TestSessionInfo, - eventsHandler); - } - finally - { - this.TestSessionInfo = null; - } + return _consoleWrapper.StopTestSession( + TestSessionInfo, + eventsHandler); } - #endregion - - #region ITestSessionAsync - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task DiscoverTestsAsync( - IEnumerable sources, - string discoverySettings, - ITestDiscoveryEventsHandler discoveryEventsHandler) + finally { - await this.DiscoverTestsAsync( - sources, - discoverySettings, - options: null, - discoveryEventsHandler: - new DiscoveryEventsHandleConverter(discoveryEventsHandler)) - .ConfigureAwait(false); + TestSessionInfo = null; } + } + #endregion - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task DiscoverTestsAsync( - IEnumerable sources, - string discoverySettings, - TestPlatformOptions options, - ITestDiscoveryEventsHandler2 discoveryEventsHandler) - { - await this.consoleWrapper.DiscoverTestsAsync( + #region ITestSessionAsync + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task DiscoverTestsAsync( + IEnumerable sources, + string discoverySettings, + ITestDiscoveryEventsHandler discoveryEventsHandler) + { + await DiscoverTestsAsync( sources, discoverySettings, - options, - this.TestSessionInfo, - discoveryEventsHandler).ConfigureAwait(false); - } - - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task RunTestsAsync( - IEnumerable sources, - string runSettings, - ITestRunEventsHandler testRunEventsHandler) - { - await this.RunTestsAsync( - sources, - runSettings, options: null, - testRunEventsHandler).ConfigureAwait(false); - } + discoveryEventsHandler: + new DiscoveryEventsHandleConverter(discoveryEventsHandler)) + .ConfigureAwait(false); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task RunTestsAsync( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler) - { - await this.consoleWrapper.RunTestsAsync( - sources, - runSettings, - options, - this.TestSessionInfo, - testRunEventsHandler).ConfigureAwait(false); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task DiscoverTestsAsync( + IEnumerable sources, + string discoverySettings, + TestPlatformOptions options, + ITestDiscoveryEventsHandler2 discoveryEventsHandler) + { + await _consoleWrapper.DiscoverTestsAsync( + sources, + discoverySettings, + options, + TestSessionInfo, + discoveryEventsHandler).ConfigureAwait(false); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task RunTestsAsync( - IEnumerable testCases, - string runSettings, - ITestRunEventsHandler testRunEventsHandler) - { - await this.RunTestsAsync( - testCases, - runSettings, - options: null, - testRunEventsHandler).ConfigureAwait(false); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task RunTestsAsync( + IEnumerable sources, + string runSettings, + ITestRunEventsHandler testRunEventsHandler) + { + await RunTestsAsync( + sources, + runSettings, + options: null, + testRunEventsHandler).ConfigureAwait(false); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task RunTestsAsync( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler) - { - await this.consoleWrapper.RunTestsAsync( - testCases, - runSettings, - options, - this.TestSessionInfo, - testRunEventsHandler).ConfigureAwait(false); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task RunTestsAsync( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler) + { + await _consoleWrapper.RunTestsAsync( + sources, + runSettings, + options, + TestSessionInfo, + testRunEventsHandler).ConfigureAwait(false); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task RunTestsWithCustomTestHostAsync( - IEnumerable sources, - string runSettings, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) - { - await this.RunTestsWithCustomTestHostAsync( - sources, - runSettings, - options: null, - testRunEventsHandler, - customTestHostLauncher).ConfigureAwait(false); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task RunTestsAsync( + IEnumerable testCases, + string runSettings, + ITestRunEventsHandler testRunEventsHandler) + { + await RunTestsAsync( + testCases, + runSettings, + options: null, + testRunEventsHandler).ConfigureAwait(false); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task RunTestsWithCustomTestHostAsync( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) - { - await this.consoleWrapper.RunTestsWithCustomTestHostAsync( - sources, - runSettings, - options, - this.TestSessionInfo, - testRunEventsHandler, - customTestHostLauncher).ConfigureAwait(false); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task RunTestsAsync( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler) + { + await _consoleWrapper.RunTestsAsync( + testCases, + runSettings, + options, + TestSessionInfo, + testRunEventsHandler).ConfigureAwait(false); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task RunTestsWithCustomTestHostAsync( - IEnumerable testCases, - string runSettings, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) - { - await this.RunTestsWithCustomTestHostAsync( - testCases, - runSettings, - options: null, - testRunEventsHandler, - customTestHostLauncher).ConfigureAwait(false); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task RunTestsWithCustomTestHostAsync( + IEnumerable sources, + string runSettings, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + await RunTestsWithCustomTestHostAsync( + sources, + runSettings, + options: null, + testRunEventsHandler, + customTestHostLauncher).ConfigureAwait(false); + } + + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task RunTestsWithCustomTestHostAsync( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + await _consoleWrapper.RunTestsWithCustomTestHostAsync( + sources, + runSettings, + options, + TestSessionInfo, + testRunEventsHandler, + customTestHostLauncher).ConfigureAwait(false); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task RunTestsWithCustomTestHostAsync( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task RunTestsWithCustomTestHostAsync( + IEnumerable testCases, + string runSettings, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + await RunTestsWithCustomTestHostAsync( + testCases, + runSettings, + options: null, + testRunEventsHandler, + customTestHostLauncher).ConfigureAwait(false); + } + + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task RunTestsWithCustomTestHostAsync( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + await _consoleWrapper.RunTestsWithCustomTestHostAsync( + testCases, + runSettings, + options, + TestSessionInfo, + testRunEventsHandler, + customTestHostLauncher).ConfigureAwait(false); + } + + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task StopTestSessionAsync() + { + return await StopTestSessionAsync(_eventsHandler).ConfigureAwait(false); + } + + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task StopTestSessionAsync(ITestSessionEventsHandler eventsHandler) + { + if (TestSessionInfo == null) { - await this.consoleWrapper.RunTestsWithCustomTestHostAsync( - testCases, - runSettings, - options, - this.TestSessionInfo, - testRunEventsHandler, - customTestHostLauncher).ConfigureAwait(false); + return true; } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task StopTestSessionAsync() + try { - return await this.StopTestSessionAsync(this.eventsHandler).ConfigureAwait(false); + return await _consoleWrapper.StopTestSessionAsync( + TestSessionInfo, + eventsHandler).ConfigureAwait(false); } - - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task StopTestSessionAsync(ITestSessionEventsHandler eventsHandler) + finally { - if (this.TestSessionInfo == null) - { - return true; - } - - try - { - return await this.consoleWrapper.StopTestSessionAsync( - this.TestSessionInfo, - eventsHandler).ConfigureAwait(false); - } - finally - { - this.TestSessionInfo = null; - } + TestSessionInfo = null; } - #endregion } -} + #endregion +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/TransationLayerException.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/TransationLayerException.cs index ae69a20db0..a0a818b186 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/TransationLayerException.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/TransationLayerException.cs @@ -1,32 +1,31 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer -{ - using System; +namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer; + +using System; +/// +/// Specialized exception for TranslationLayer +/// +public class TransationLayerException : Exception +{ /// - /// Specialized exception for TranslationLayer + /// Initializes a new instance of the TransationLayerException class. /// - public class TransationLayerException : Exception + /// The message that describes the error. + public TransationLayerException(string message) + : base(message) { - /// - /// Initializes a new instance of the TransationLayerException class. - /// - /// The message that describes the error. - public TransationLayerException(string message) - : base(message) - { - } + } - /// - /// Initializes a new instance of the TransationLayerException class. - /// - /// The error message that explains the reason for the exception. - /// The exception that is the cause of the current exception. - public TransationLayerException(string message, Exception innerException) - : base(message, innerException) - { - } + /// + /// Initializes a new instance of the TransationLayerException class. + /// + /// The error message that explains the reason for the exception. + /// The exception that is the cause of the current exception. + public TransationLayerException(string message, Exception innerException) + : base(message, innerException) + { } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleProcessManager.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleProcessManager.cs index 6ff06235b2..4009c0fade 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleProcessManager.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleProcessManager.cs @@ -1,254 +1,255 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer +namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer; + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Threading; + +using Interfaces; + +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +using Resources = VisualStudio.TestPlatform.VsTestConsole.TranslationLayer.Resources.Resources; + +/// +/// Vstest.console process manager +/// +internal class VsTestConsoleProcessManager : IProcessManager { - using Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using System; - using System.Collections.Generic; - using System.ComponentModel; - using System.Diagnostics; - using System.Globalization; - using System.IO; - using System.Threading; - using Resources = Microsoft.VisualStudio.TestPlatform.VsTestConsole.TranslationLayer.Resources.Resources; + #region Private Members /// - /// Vstest.console process manager + /// Port number for communicating with Vstest CLI /// - internal class VsTestConsoleProcessManager : IProcessManager + private const string PortArgument = "/port:{0}"; + + /// + /// Process Id of the Current Process which is launching Vstest CLI + /// Helps Vstest CLI in auto-exit if current process dies without notifying it + /// + private const string ParentProcessidArgument = "/parentprocessid:{0}"; + + /// + /// Diagnostics argument for Vstest CLI + /// Enables Diagnostic logging for Vstest CLI and TestHost - Optional + /// + private const string DiagArgument = "/diag:{0};tracelevel={1}"; + + /// + /// EndSession timeout + /// + private const int Endsessiontimeout = 1000; + + private readonly string _vstestConsolePath; + private readonly object _syncObject = new(); + private bool _vstestConsoleStarted = false; + private bool _vstestConsoleExited = false; + private readonly bool _isNetCoreRunner; + private readonly string _dotnetExePath; + private Process _process; + private readonly ManualResetEvent _processExitedEvent = new(false); + + internal IFileHelper FileHelper { get; set; } + + #endregion + + /// + public event EventHandler ProcessExited; + + #region Constructor + + /// + /// Creates an instance of VsTestConsoleProcessManager class. + /// + /// The full path to vstest.console + public VsTestConsoleProcessManager(string vstestConsolePath) { - #region Private Members - - /// - /// Port number for communicating with Vstest CLI - /// - private const string PORT_ARGUMENT = "/port:{0}"; - - /// - /// Process Id of the Current Process which is launching Vstest CLI - /// Helps Vstest CLI in auto-exit if current process dies without notifying it - /// - private const string PARENT_PROCESSID_ARGUMENT = "/parentprocessid:{0}"; - - /// - /// Diagnostics argument for Vstest CLI - /// Enables Diagnostic logging for Vstest CLI and TestHost - Optional - /// - private const string DIAG_ARGUMENT = "/diag:{0};tracelevel={1}"; - - /// - /// EndSession timeout - /// - private const int ENDSESSIONTIMEOUT = 1000; - - private string vstestConsolePath; - private object syncObject = new object(); - private bool vstestConsoleStarted = false; - private bool vstestConsoleExited = false; - private readonly bool isNetCoreRunner; - private string dotnetExePath; - private Process process; - private ManualResetEvent processExitedEvent = new ManualResetEvent(false); - - internal IFileHelper FileHelper { get; set; } - - #endregion - - /// - public event EventHandler ProcessExited; - - #region Constructor - - /// - /// Creates an instance of VsTestConsoleProcessManager class. - /// - /// The full path to vstest.console - public VsTestConsoleProcessManager(string vstestConsolePath) - { - this.FileHelper = new FileHelper(); - if (!this.FileHelper.Exists(vstestConsolePath)) - { - EqtTrace.Error("Invalid File Path: {0}", vstestConsolePath); - throw new Exception(string.Format(CultureInfo.CurrentCulture, Resources.InvalidFilePath, vstestConsolePath)); - } - this.vstestConsolePath = vstestConsolePath; - isNetCoreRunner = vstestConsolePath.EndsWith(".dll"); + FileHelper = new FileHelper(); + if (!FileHelper.Exists(vstestConsolePath)) + { + EqtTrace.Error("Invalid File Path: {0}", vstestConsolePath); + throw new Exception(string.Format(CultureInfo.CurrentCulture, Resources.InvalidFilePath, vstestConsolePath)); } + _vstestConsolePath = vstestConsolePath; + _isNetCoreRunner = vstestConsolePath.EndsWith(".dll"); + } + + public VsTestConsoleProcessManager(string vstestConsolePath, string dotnetExePath) : this(vstestConsolePath) + { + _dotnetExePath = dotnetExePath; + } - public VsTestConsoleProcessManager(string vstestConsolePath, string dotnetExePath) : this(vstestConsolePath) + #endregion Constructor + + /// + /// Checks if the process has been initialized. + /// + /// True if process is successfully initialized + public bool IsProcessInitialized() + { + lock (_syncObject) { - this.dotnetExePath = dotnetExePath; + return _vstestConsoleStarted && !_vstestConsoleExited && _process != null; } + } - #endregion Constructor + /// + /// Call vstest.console with the parameters previously specified + /// + public void StartProcess(ConsoleParameters consoleParameters) + { + var consoleRunnerPath = GetConsoleRunner(); - /// - /// Checks if the process has been initialized. - /// - /// True if process is successfully initialized - public bool IsProcessInitialized() + // The console runner path we retrieve might have been escaped so we need to remove the + // extra double quotes before testing whether the file exists. + if (!File.Exists(consoleRunnerPath.Trim('"'))) { - lock (syncObject) - { - return this.vstestConsoleStarted && !vstestConsoleExited && - this.process != null; - } + throw new FileNotFoundException(string.Format(Resources.CannotFindConsoleRunner, consoleRunnerPath), consoleRunnerPath); } - /// - /// Call vstest.console with the parameters previously specified - /// - public void StartProcess(ConsoleParameters consoleParameters) + var arguments = string.Join(" ", BuildArguments(consoleParameters)); + var info = new ProcessStartInfo(consoleRunnerPath, arguments) { - var consoleRunnerPath = GetConsoleRunner(); - - // The console runner path we retrieve might have been escaped so we need to remove the - // extra double quotes before testing whether the file exists. - if (!File.Exists(consoleRunnerPath.Trim('"'))) - { - throw new FileNotFoundException(string.Format(Resources.CannotFindConsoleRunner, consoleRunnerPath), consoleRunnerPath); - } - - var arguments = string.Join(" ", BuildArguments(consoleParameters)); - var info = new ProcessStartInfo(consoleRunnerPath, arguments) - { - UseShellExecute = false, - CreateNoWindow = true, - RedirectStandardOutput = true, - RedirectStandardError = true - }; + UseShellExecute = false, + CreateNoWindow = true, + RedirectStandardOutput = true, + RedirectStandardError = true + }; - EqtTrace.Verbose("VsTestCommandLineWrapper: Process Start Info {0} {1}", info.FileName, info.Arguments); + EqtTrace.Verbose("VsTestCommandLineWrapper: Process Start Info {0} {1}", info.FileName, info.Arguments); #if NETFRAMEWORK - if (consoleParameters.EnvironmentVariables != null) + if (consoleParameters.EnvironmentVariables != null) + { + info.EnvironmentVariables.Clear(); + foreach (var envVariable in consoleParameters.EnvironmentVariables) { - info.EnvironmentVariables.Clear(); - foreach (var envVariable in consoleParameters.EnvironmentVariables) + if (envVariable.Key != null) { - if (envVariable.Key != null) - { - info.EnvironmentVariables.Add(envVariable.Key, envVariable.Value?.ToString()); - } + info.EnvironmentVariables.Add(envVariable.Key, envVariable.Value?.ToString()); } } + } #endif - try - { - this.process = Process.Start(info); - } - catch (Win32Exception ex) - { - throw new Exception(string.Format(Resources.ProcessStartWin32Failure, consoleRunnerPath, arguments), ex); - } + try + { + _process = Process.Start(info); + } + catch (Win32Exception ex) + { + throw new Exception(string.Format(Resources.ProcessStartWin32Failure, consoleRunnerPath, arguments), ex); + } - lock (syncObject) - { - vstestConsoleExited = false; - vstestConsoleStarted = true; - } + lock (_syncObject) + { + _vstestConsoleExited = false; + _vstestConsoleStarted = true; + } - this.process.EnableRaisingEvents = true; - this.process.Exited += Process_Exited; + _process.EnableRaisingEvents = true; + _process.Exited += Process_Exited; - this.process.OutputDataReceived += Process_OutputDataReceived; - this.process.ErrorDataReceived += Process_ErrorDataReceived; - this.process.BeginOutputReadLine(); - this.process.BeginErrorReadLine(); - processExitedEvent.Reset(); - } + _process.OutputDataReceived += Process_OutputDataReceived; + _process.ErrorDataReceived += Process_ErrorDataReceived; + _process.BeginOutputReadLine(); + _process.BeginErrorReadLine(); + _processExitedEvent.Reset(); + } - /// - /// Shutdown the vstest.console process - /// - public void ShutdownProcess() + /// + /// Shutdown the vstest.console process + /// + public void ShutdownProcess() + { + // Ideally process should die by itself + if (!_processExitedEvent.WaitOne(Endsessiontimeout) && IsProcessInitialized()) { - // Ideally process should die by itself - if (!processExitedEvent.WaitOne(ENDSESSIONTIMEOUT) && IsProcessInitialized()) - { - EqtTrace.Info($"VsTestConsoleProcessManager.ShutDownProcess : Terminating vstest.console process after waiting for {ENDSESSIONTIMEOUT} milliseconds."); - vstestConsoleExited = true; - this.process.OutputDataReceived -= Process_OutputDataReceived; - this.process.ErrorDataReceived -= Process_ErrorDataReceived; - SafelyTerminateProcess(); - this.process.Dispose(); - this.process = null; - } + EqtTrace.Info($"VsTestConsoleProcessManager.ShutDownProcess : Terminating vstest.console process after waiting for {Endsessiontimeout} milliseconds."); + _vstestConsoleExited = true; + _process.OutputDataReceived -= Process_OutputDataReceived; + _process.ErrorDataReceived -= Process_ErrorDataReceived; + SafelyTerminateProcess(); + _process.Dispose(); + _process = null; } + } - private void SafelyTerminateProcess() + private void SafelyTerminateProcess() + { + try { - try - { - if (this.process != null && !this.process.HasExited) - { - this.process.Kill(); - } - } - catch (InvalidOperationException ex) + if (_process != null && !_process.HasExited) { - EqtTrace.Info("VsTestCommandLineWrapper: Error While Terminating Process {0} ", ex.Message); + _process.Kill(); } } - - private void Process_Exited(object sender, EventArgs e) + catch (InvalidOperationException ex) { - lock (syncObject) - { - processExitedEvent.Set(); - vstestConsoleExited = true; - this.ProcessExited?.Invoke(sender, e); - } + EqtTrace.Info("VsTestCommandLineWrapper: Error While Terminating Process {0} ", ex.Message); } + } - private void Process_ErrorDataReceived(object sender, DataReceivedEventArgs e) + private void Process_Exited(object sender, EventArgs e) + { + lock (_syncObject) { - if (e.Data != null) - { - EqtTrace.Error(e.Data); - } + _processExitedEvent.Set(); + _vstestConsoleExited = true; + ProcessExited?.Invoke(sender, e); } + } - private void Process_OutputDataReceived(object sender, DataReceivedEventArgs e) + private void Process_ErrorDataReceived(object sender, DataReceivedEventArgs e) + { + if (e.Data != null) { - if (e.Data != null) - { - EqtTrace.Verbose(e.Data); - } + EqtTrace.Error(e.Data); } + } - private string[] BuildArguments(ConsoleParameters parameters) + private void Process_OutputDataReceived(object sender, DataReceivedEventArgs e) + { + if (e.Data != null) { - var args = new List - { - // Start Vstest.console with args: --parentProcessId|/parentprocessid: --port|/port: - string.Format(CultureInfo.InvariantCulture, PARENT_PROCESSID_ARGUMENT, parameters.ParentProcessId), - string.Format(CultureInfo.InvariantCulture, PORT_ARGUMENT, parameters.PortNumber) - }; - - if (!string.IsNullOrEmpty(parameters.LogFilePath)) - { - // Extra args: --diag|/diag:;tracelevel= - args.Add(string.Format(CultureInfo.InvariantCulture, DIAG_ARGUMENT, parameters.LogFilePath, parameters.TraceLevel)); - } + EqtTrace.Verbose(e.Data); + } + } - if (isNetCoreRunner) - { - args.Insert(0, GetEscapeSequencedPath(vstestConsolePath)); - } + private string[] BuildArguments(ConsoleParameters parameters) + { + var args = new List + { + // Start Vstest.console with args: --parentProcessId|/parentprocessid: --port|/port: + string.Format(CultureInfo.InvariantCulture, ParentProcessidArgument, parameters.ParentProcessId), + string.Format(CultureInfo.InvariantCulture, PortArgument, parameters.PortNumber) + }; - return args.ToArray(); + if (!string.IsNullOrEmpty(parameters.LogFilePath)) + { + // Extra args: --diag|/diag:;tracelevel= + args.Add(string.Format(CultureInfo.InvariantCulture, DiagArgument, parameters.LogFilePath, parameters.TraceLevel)); } - private string GetConsoleRunner() - => isNetCoreRunner ? (string.IsNullOrEmpty(this.dotnetExePath) ? new DotnetHostHelper().GetDotnetPath() : this.dotnetExePath) : GetEscapeSequencedPath(this.vstestConsolePath); + if (_isNetCoreRunner) + { + args.Insert(0, GetEscapeSequencedPath(_vstestConsolePath)); + } - private string GetEscapeSequencedPath(string path) - => string.IsNullOrEmpty(path) ? path : $"\"{path.Trim('"')}\""; + return args.ToArray(); } + + private string GetConsoleRunner() + => _isNetCoreRunner ? (string.IsNullOrEmpty(_dotnetExePath) ? new DotnetHostHelper().GetDotnetPath() : _dotnetExePath) : GetEscapeSequencedPath(_vstestConsolePath); + + private string GetEscapeSequencedPath(string path) + => string.IsNullOrEmpty(path) ? path : $"\"{path.Trim('"')}\""; } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleRequestSender.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleRequestSender.cs index ef1853a361..1323c22c14 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleRequestSender.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleRequestSender.cs @@ -1,1537 +1,1526 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer +namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Threading; +using System.Threading.Tasks; + +using Interfaces; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +using TranslationLayerResources = VisualStudio.TestPlatform.VsTestConsole.TranslationLayer.Resources.Resources; + +/// +/// Vstest console request sender for sending requests to vstest.console.exe +/// +internal class VsTestConsoleRequestSender : ITranslationLayerRequestSender { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Threading; - using System.Threading.Tasks; - - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - - using TranslationLayerResources = Microsoft.VisualStudio.TestPlatform.VsTestConsole.TranslationLayer.Resources.Resources; - /// - /// Vstest console request sender for sending requests to vstest.console.exe + /// The minimum protocol version that has test session support. /// - internal class VsTestConsoleRequestSender : ITranslationLayerRequestSender - { - /// - /// The minimum protocol version that has test session support. - /// - private const int MinimumProtocolVersionWithTestSessionSupport = 5; + private const int MinimumProtocolVersionWithTestSessionSupport = 5; - private readonly ICommunicationManager communicationManager; + private readonly ICommunicationManager _communicationManager; - private readonly IDataSerializer dataSerializer; - private readonly ITestPlatformEventSource testPlatformEventSource; + private readonly IDataSerializer _dataSerializer; + private readonly ITestPlatformEventSource _testPlatformEventSource; - private readonly ManualResetEvent handShakeComplete = new ManualResetEvent(false); + private readonly ManualResetEvent _handShakeComplete = new(false); - private bool handShakeSuccessful = false; + private bool _handShakeSuccessful = false; - private int protocolVersion = 5; + private int _protocolVersion = 5; - /// - /// Used to cancel blocking tasks associated with the vstest.console process. - /// - private CancellationTokenSource processExitCancellationTokenSource; + /// + /// Used to cancel blocking tasks associated with the vstest.console process. + /// + private CancellationTokenSource _processExitCancellationTokenSource; - #region Constructor + #region Constructor - /// - /// Initializes a new instance of the class. - /// - public VsTestConsoleRequestSender() - : this( - new SocketCommunicationManager(), - JsonDataSerializer.Instance, - TestPlatformEventSource.Instance) - { - } + /// + /// Initializes a new instance of the class. + /// + public VsTestConsoleRequestSender() + : this( + new SocketCommunicationManager(), + JsonDataSerializer.Instance, + TestPlatformEventSource.Instance) + { + } - /// - /// Initializes a new instance of the class. - /// - /// - /// The communication manager. - /// The data serializer. - /// The test platform event source. - internal VsTestConsoleRequestSender( - ICommunicationManager communicationManager, - IDataSerializer dataSerializer, - ITestPlatformEventSource testPlatformEventSource) - { - this.communicationManager = communicationManager; - this.dataSerializer = dataSerializer; - this.testPlatformEventSource = testPlatformEventSource; - } + /// + /// Initializes a new instance of the class. + /// + /// + /// The communication manager. + /// The data serializer. + /// The test platform event source. + internal VsTestConsoleRequestSender( + ICommunicationManager communicationManager, + IDataSerializer dataSerializer, + ITestPlatformEventSource testPlatformEventSource) + { + _communicationManager = communicationManager; + _dataSerializer = dataSerializer; + _testPlatformEventSource = testPlatformEventSource; + } - #endregion + #endregion - #region ITranslationLayerRequestSender + #region ITranslationLayerRequestSender - /// - public int InitializeCommunication() + /// + public int InitializeCommunication() + { + if (EqtTrace.IsInfoEnabled) { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("VsTestConsoleRequestSender.InitializeCommunication: Started."); - } - - this.processExitCancellationTokenSource = new CancellationTokenSource(); - this.handShakeSuccessful = false; - this.handShakeComplete.Reset(); - int port = -1; - try - { - port = this.communicationManager.HostServer(new IPEndPoint(IPAddress.Loopback, 0)).Port; - this.communicationManager.AcceptClientAsync(); + EqtTrace.Info("VsTestConsoleRequestSender.InitializeCommunication: Started."); + } - Task.Run(() => - { - this.communicationManager.WaitForClientConnection(Timeout.Infinite); - this.handShakeSuccessful = this.HandShakeWithVsTestConsole(); - this.handShakeComplete.Set(); - }); - } - catch (Exception ex) - { - EqtTrace.Error( - "VsTestConsoleRequestSender.InitializeCommunication: Error initializing communication with VstestConsole: {0}", - ex); - this.handShakeComplete.Set(); - } + _processExitCancellationTokenSource = new CancellationTokenSource(); + _handShakeSuccessful = false; + _handShakeComplete.Reset(); + int port = -1; + try + { + port = _communicationManager.HostServer(new IPEndPoint(IPAddress.Loopback, 0)).Port; + _communicationManager.AcceptClientAsync(); - if (EqtTrace.IsInfoEnabled) + Task.Run(() => { - EqtTrace.Info("VsTestConsoleRequestSender.InitializeCommunication: Ended."); - } - - return port; + _communicationManager.WaitForClientConnection(Timeout.Infinite); + _handShakeSuccessful = HandShakeWithVsTestConsole(); + _handShakeComplete.Set(); + }); } - - /// - public bool WaitForRequestHandlerConnection(int clientConnectionTimeout) + catch (Exception ex) { - var waitSucess = this.handShakeComplete.WaitOne(clientConnectionTimeout); - return waitSucess && this.handShakeSuccessful; + EqtTrace.Error( + "VsTestConsoleRequestSender.InitializeCommunication: Error initializing communication with VstestConsole: {0}", + ex); + _handShakeComplete.Set(); } - /// - public async Task InitializeCommunicationAsync(int clientConnectionTimeout) + if (EqtTrace.IsInfoEnabled) { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info($"VsTestConsoleRequestSender.InitializeCommunicationAsync: Started with client connection timeout {clientConnectionTimeout} milliseconds."); - } - - this.processExitCancellationTokenSource = new CancellationTokenSource(); - this.handShakeSuccessful = false; - this.handShakeComplete.Reset(); - int port = -1; - try - { - port = this.communicationManager.HostServer(new IPEndPoint(IPAddress.Loopback, 0)).Port; - var timeoutSource = new CancellationTokenSource(clientConnectionTimeout); - await Task.Run(() => - this.communicationManager.AcceptClientAsync(), timeoutSource.Token).ConfigureAwait(false); + EqtTrace.Info("VsTestConsoleRequestSender.InitializeCommunication: Ended."); + } - this.handShakeSuccessful = await this.HandShakeWithVsTestConsoleAsync().ConfigureAwait(false); - this.handShakeComplete.Set(); - } - catch (Exception ex) - { - EqtTrace.Error( - "VsTestConsoleRequestSender.InitializeCommunicationAsync: Error initializing communication with VstestConsole: {0}", - ex); - this.handShakeComplete.Set(); - } + return port; + } - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("VsTestConsoleRequestSender.InitializeCommunicationAsync: Ended."); - } + /// + public bool WaitForRequestHandlerConnection(int clientConnectionTimeout) + { + var waitSucess = _handShakeComplete.WaitOne(clientConnectionTimeout); + return waitSucess && _handShakeSuccessful; + } - return this.handShakeSuccessful ? port : -1; + /// + public async Task InitializeCommunicationAsync(int clientConnectionTimeout) + { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info($"VsTestConsoleRequestSender.InitializeCommunicationAsync: Started with client connection timeout {clientConnectionTimeout} milliseconds."); } - /// - public void InitializeExtensions(IEnumerable pathToAdditionalExtensions) + _processExitCancellationTokenSource = new CancellationTokenSource(); + _handShakeSuccessful = false; + _handShakeComplete.Reset(); + int port = -1; + try { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info($"VsTestConsoleRequestSender.InitializeExtensions: Initializing extensions with additional extensions path {string.Join(",", pathToAdditionalExtensions.ToList())}."); - } + port = _communicationManager.HostServer(new IPEndPoint(IPAddress.Loopback, 0)).Port; + var timeoutSource = new CancellationTokenSource(clientConnectionTimeout); + await Task.Run(() => + _communicationManager.AcceptClientAsync(), timeoutSource.Token).ConfigureAwait(false); - this.communicationManager.SendMessage( - MessageType.ExtensionsInitialize, - pathToAdditionalExtensions, - this.protocolVersion); + _handShakeSuccessful = await HandShakeWithVsTestConsoleAsync().ConfigureAwait(false); + _handShakeComplete.Set(); } - - /// - public void DiscoverTests( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestDiscoveryEventsHandler2 eventHandler) + catch (Exception ex) { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("VsTestConsoleRequestSender.DiscoverTests: Starting test discovery."); - } - - this.SendMessageAndListenAndReportTestCases( - sources, - runSettings, - options, - testSessionInfo, - eventHandler); + EqtTrace.Error( + "VsTestConsoleRequestSender.InitializeCommunicationAsync: Error initializing communication with VstestConsole: {0}", + ex); + _handShakeComplete.Set(); } - /// - public async Task DiscoverTestsAsync( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestDiscoveryEventsHandler2 eventHandler) + if (EqtTrace.IsInfoEnabled) { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("VsTestConsoleRequestSender.DiscoverTestsAsync: Starting test discovery."); - } - - await this.SendMessageAndListenAndReportTestCasesAsync( - sources, - runSettings, - options, - testSessionInfo, - eventHandler).ConfigureAwait(false); + EqtTrace.Info("VsTestConsoleRequestSender.InitializeCommunicationAsync: Ended."); } - /// - public void StartTestRun( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler runEventsHandler) - { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("VsTestConsoleRequestSender.StartTestRun: Starting test run."); - } + return _handShakeSuccessful ? port : -1; + } - this.SendMessageAndListenAndReportTestResults( - MessageType.TestRunAllSourcesWithDefaultHost, - new TestRunRequestPayload() - { - Sources = sources.ToList(), - RunSettings = runSettings, - TestPlatformOptions = options, - TestSessionInfo = testSessionInfo - }, - runEventsHandler, - null); + /// + public void InitializeExtensions(IEnumerable pathToAdditionalExtensions) + { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info($"VsTestConsoleRequestSender.InitializeExtensions: Initializing extensions with additional extensions path {string.Join(",", pathToAdditionalExtensions.ToList())}."); } - /// - public async Task StartTestRunAsync( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler runEventsHandler) - { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunAsync: Starting test run."); - } + _communicationManager.SendMessage( + MessageType.ExtensionsInitialize, + pathToAdditionalExtensions, + _protocolVersion); + } - await this.SendMessageAndListenAndReportTestResultsAsync( - MessageType.TestRunAllSourcesWithDefaultHost, - new TestRunRequestPayload() - { - Sources = sources.ToList(), - RunSettings = runSettings, - TestPlatformOptions = options, - TestSessionInfo = testSessionInfo - }, - runEventsHandler, - null).ConfigureAwait(false); + /// + public void DiscoverTests( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestDiscoveryEventsHandler2 eventHandler) + { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.DiscoverTests: Starting test discovery."); } - /// - public void StartTestRun( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler runEventsHandler) - { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("VsTestConsoleRequestSender.StartTestRun: Starting test run."); - } + SendMessageAndListenAndReportTestCases( + sources, + runSettings, + options, + testSessionInfo, + eventHandler); + } - this.SendMessageAndListenAndReportTestResults( - MessageType.TestRunAllSourcesWithDefaultHost, - new TestRunRequestPayload() - { - TestCases = testCases.ToList(), - RunSettings = runSettings, - TestPlatformOptions = options, - TestSessionInfo = testSessionInfo - }, - runEventsHandler, - null); + /// + public async Task DiscoverTestsAsync( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestDiscoveryEventsHandler2 eventHandler) + { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.DiscoverTestsAsync: Starting test discovery."); } - /// - public async Task StartTestRunAsync( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler runEventsHandler) - { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunAsync: Starting test run."); - } + await SendMessageAndListenAndReportTestCasesAsync( + sources, + runSettings, + options, + testSessionInfo, + eventHandler).ConfigureAwait(false); + } - await this.SendMessageAndListenAndReportTestResultsAsync( - MessageType.TestRunAllSourcesWithDefaultHost, - new TestRunRequestPayload() - { - TestCases = testCases.ToList(), - RunSettings = runSettings, - TestPlatformOptions = options, - TestSessionInfo = testSessionInfo - }, - runEventsHandler, - null).ConfigureAwait(false); + /// + public void StartTestRun( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler runEventsHandler) + { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.StartTestRun: Starting test run."); } - /// - public void StartTestRunWithCustomHost( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler runEventsHandler, - ITestHostLauncher customHostLauncher) - { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunWithCustomHost: Starting test run."); - } + SendMessageAndListenAndReportTestResults( + MessageType.TestRunAllSourcesWithDefaultHost, + new TestRunRequestPayload() + { + Sources = sources.ToList(), + RunSettings = runSettings, + TestPlatformOptions = options, + TestSessionInfo = testSessionInfo + }, + runEventsHandler, + null); + } - this.SendMessageAndListenAndReportTestResults( - MessageType.GetTestRunnerProcessStartInfoForRunAll, - new TestRunRequestPayload() - { - Sources = sources.ToList(), - RunSettings = runSettings, - DebuggingEnabled = customHostLauncher.IsDebug, - TestPlatformOptions = options, - TestSessionInfo = testSessionInfo - }, - runEventsHandler, - customHostLauncher); + /// + public async Task StartTestRunAsync( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler runEventsHandler) + { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunAsync: Starting test run."); } - /// - public async Task StartTestRunWithCustomHostAsync( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler runEventsHandler, - ITestHostLauncher customHostLauncher) - { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunWithCustomHostAsync: Starting test run."); - } + await SendMessageAndListenAndReportTestResultsAsync( + MessageType.TestRunAllSourcesWithDefaultHost, + new TestRunRequestPayload() + { + Sources = sources.ToList(), + RunSettings = runSettings, + TestPlatformOptions = options, + TestSessionInfo = testSessionInfo + }, + runEventsHandler, + null).ConfigureAwait(false); + } - await this.SendMessageAndListenAndReportTestResultsAsync( - MessageType.GetTestRunnerProcessStartInfoForRunAll, - new TestRunRequestPayload() - { - Sources = sources.ToList(), - RunSettings = runSettings, - DebuggingEnabled = customHostLauncher.IsDebug, - TestPlatformOptions = options, - TestSessionInfo = testSessionInfo - }, - runEventsHandler, - customHostLauncher).ConfigureAwait(false); + /// + public void StartTestRun( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler runEventsHandler) + { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.StartTestRun: Starting test run."); } - /// - public void StartTestRunWithCustomHost( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler runEventsHandler, - ITestHostLauncher customHostLauncher) + SendMessageAndListenAndReportTestResults( + MessageType.TestRunAllSourcesWithDefaultHost, + new TestRunRequestPayload() + { + TestCases = testCases.ToList(), + RunSettings = runSettings, + TestPlatformOptions = options, + TestSessionInfo = testSessionInfo + }, + runEventsHandler, + null); + } + + /// + public async Task StartTestRunAsync( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler runEventsHandler) + { + if (EqtTrace.IsInfoEnabled) { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunWithCustomHost: Starting test run."); - } + EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunAsync: Starting test run."); + } - this.SendMessageAndListenAndReportTestResults( - MessageType.GetTestRunnerProcessStartInfoForRunSelected, - new TestRunRequestPayload - { - TestCases = testCases.ToList(), - RunSettings = runSettings, - DebuggingEnabled = customHostLauncher.IsDebug, - TestPlatformOptions = options, - TestSessionInfo = testSessionInfo - }, - runEventsHandler, - customHostLauncher); + await SendMessageAndListenAndReportTestResultsAsync( + MessageType.TestRunAllSourcesWithDefaultHost, + new TestRunRequestPayload() + { + TestCases = testCases.ToList(), + RunSettings = runSettings, + TestPlatformOptions = options, + TestSessionInfo = testSessionInfo + }, + runEventsHandler, + null).ConfigureAwait(false); + } + + /// + public void StartTestRunWithCustomHost( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler runEventsHandler, + ITestHostLauncher customHostLauncher) + { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunWithCustomHost: Starting test run."); } - /// - public async Task StartTestRunWithCustomHostAsync( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler runEventsHandler, - ITestHostLauncher customHostLauncher) + SendMessageAndListenAndReportTestResults( + MessageType.GetTestRunnerProcessStartInfoForRunAll, + new TestRunRequestPayload() + { + Sources = sources.ToList(), + RunSettings = runSettings, + DebuggingEnabled = customHostLauncher.IsDebug, + TestPlatformOptions = options, + TestSessionInfo = testSessionInfo + }, + runEventsHandler, + customHostLauncher); + } + + /// + public async Task StartTestRunWithCustomHostAsync( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler runEventsHandler, + ITestHostLauncher customHostLauncher) + { + if (EqtTrace.IsInfoEnabled) { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunWithCustomHostAsync: Starting test run."); - } + EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunWithCustomHostAsync: Starting test run."); + } - await this.SendMessageAndListenAndReportTestResultsAsync( - MessageType.GetTestRunnerProcessStartInfoForRunSelected, - new TestRunRequestPayload() - { - TestCases = testCases.ToList(), - RunSettings = runSettings, - DebuggingEnabled = customHostLauncher.IsDebug, - TestPlatformOptions = options, - TestSessionInfo = testSessionInfo - }, - runEventsHandler, - customHostLauncher).ConfigureAwait(false); - } - - /// - public TestSessionInfo StartTestSession( - IList sources, - string runSettings, - TestPlatformOptions options, - ITestSessionEventsHandler eventsHandler, - ITestHostLauncher testHostLauncher) - { - // Make sure vstest.console knows how to handle start/stop test session messages. - // Bail out if it doesn't, otherwise we'll hang waiting for a reply from the console - // that will never come. - if (this.protocolVersion < MinimumProtocolVersionWithTestSessionSupport) - { - eventsHandler?.HandleStartTestSessionComplete(null); - return null; - } + await SendMessageAndListenAndReportTestResultsAsync( + MessageType.GetTestRunnerProcessStartInfoForRunAll, + new TestRunRequestPayload() + { + Sources = sources.ToList(), + RunSettings = runSettings, + DebuggingEnabled = customHostLauncher.IsDebug, + TestPlatformOptions = options, + TestSessionInfo = testSessionInfo + }, + runEventsHandler, + customHostLauncher).ConfigureAwait(false); + } - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("VsTestConsoleRequestSender.StartTestSession: Starting test session."); - } + /// + public void StartTestRunWithCustomHost( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler runEventsHandler, + ITestHostLauncher customHostLauncher) + { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunWithCustomHost: Starting test run."); + } - try - { - var payload = new StartTestSessionPayload - { - // TODO (copoiena): When sharing the test host between test discovery and test - // execution, should we use the test host launcher to launch it ? What side - // effects does this have ? - // - // This is useful for profiling and maybe for launching hosts other than the - // ones managed by us (i.e., the default host and the dotnet host), examples - // including UWP and other hosts that don't implement the ITestRuntimeProvider2 - // interface and/or are not aware of the possibility of attaching to an already - // running process. - Sources = sources, - RunSettings = runSettings, - HasCustomHostLauncher = testHostLauncher != null, - IsDebuggingEnabled = (testHostLauncher != null) - && testHostLauncher.IsDebug, - TestPlatformOptions = options - }; - - this.communicationManager.SendMessage( - MessageType.StartTestSession, - payload, - this.protocolVersion); - - while (true) - { - var message = this.TryReceiveMessage(); + SendMessageAndListenAndReportTestResults( + MessageType.GetTestRunnerProcessStartInfoForRunSelected, + new TestRunRequestPayload + { + TestCases = testCases.ToList(), + RunSettings = runSettings, + DebuggingEnabled = customHostLauncher.IsDebug, + TestPlatformOptions = options, + TestSessionInfo = testSessionInfo + }, + runEventsHandler, + customHostLauncher); + } - switch (message.MessageType) - { - case MessageType.StartTestSessionCallback: - var ackPayload = this.dataSerializer - .DeserializePayload(message); - eventsHandler?.HandleStartTestSessionComplete( - ackPayload.TestSessionInfo); - return ackPayload.TestSessionInfo; - - case MessageType.CustomTestHostLaunch: - this.HandleCustomHostLaunch(testHostLauncher, message); - break; - - case MessageType.EditorAttachDebugger: - this.AttachDebuggerToProcess(testHostLauncher, message); - break; - - case MessageType.TestMessage: - var testMessagePayload = this.dataSerializer - .DeserializePayload(message); - eventsHandler?.HandleLogMessage( - testMessagePayload.MessageLevel, - testMessagePayload.Message); - break; - - default: - EqtTrace.Warning( - "VsTestConsoleRequestSender.StartTestSession: Unexpected message received: {0}", - message.MessageType); - break; - } - } - } - catch (Exception exception) - { - EqtTrace.Error( - "Aborting StartTestSession operation due to error: {0}", - exception); - eventsHandler?.HandleLogMessage( - TestMessageLevel.Error, - TranslationLayerResources.AbortedStartTestSession); + /// + public async Task StartTestRunWithCustomHostAsync( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler runEventsHandler, + ITestHostLauncher customHostLauncher) + { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunWithCustomHostAsync: Starting test run."); + } - eventsHandler?.HandleStartTestSessionComplete(null); - } - finally - { - this.testPlatformEventSource.TranslationLayerStartTestSessionStop(); - } + await SendMessageAndListenAndReportTestResultsAsync( + MessageType.GetTestRunnerProcessStartInfoForRunSelected, + new TestRunRequestPayload() + { + TestCases = testCases.ToList(), + RunSettings = runSettings, + DebuggingEnabled = customHostLauncher.IsDebug, + TestPlatformOptions = options, + TestSessionInfo = testSessionInfo + }, + runEventsHandler, + customHostLauncher).ConfigureAwait(false); + } + /// + public TestSessionInfo StartTestSession( + IList sources, + string runSettings, + TestPlatformOptions options, + ITestSessionEventsHandler eventsHandler, + ITestHostLauncher testHostLauncher) + { + // Make sure vstest.console knows how to handle start/stop test session messages. + // Bail out if it doesn't, otherwise we'll hang waiting for a reply from the console + // that will never come. + if (_protocolVersion < MinimumProtocolVersionWithTestSessionSupport) + { + eventsHandler?.HandleStartTestSessionComplete(null); return null; } - /// - public async Task StartTestSessionAsync( - IList sources, - string runSettings, - TestPlatformOptions options, - ITestSessionEventsHandler eventsHandler, - ITestHostLauncher testHostLauncher) + if (EqtTrace.IsInfoEnabled) { - // Make sure vstest.console knows how to handle start/stop test session messages. - // Bail out if it doesn't, otherwise we'll hang waiting for a reply from the console - // that will never come. - if (this.protocolVersion < MinimumProtocolVersionWithTestSessionSupport) - { - eventsHandler?.HandleStartTestSessionComplete(null); - return await Task.FromResult((TestSessionInfo)null); - } + EqtTrace.Info("VsTestConsoleRequestSender.StartTestSession: Starting test session."); + } - if (EqtTrace.IsInfoEnabled) + try + { + var payload = new StartTestSessionPayload { - EqtTrace.Info("VsTestConsoleRequestSender.StartTestSession: Starting test session."); - } + // TODO (copoiena): When sharing the test host between test discovery and test + // execution, should we use the test host launcher to launch it ? What side + // effects does this have ? + // + // This is useful for profiling and maybe for launching hosts other than the + // ones managed by us (i.e., the default host and the dotnet host), examples + // including UWP and other hosts that don't implement the ITestRuntimeProvider2 + // interface and/or are not aware of the possibility of attaching to an already + // running process. + Sources = sources, + RunSettings = runSettings, + HasCustomHostLauncher = testHostLauncher != null, + IsDebuggingEnabled = (testHostLauncher != null) + && testHostLauncher.IsDebug, + TestPlatformOptions = options + }; - try - { - var payload = new StartTestSessionPayload - { - // TODO (copoiena): When sharing the test host between test discovery and test - // execution, should we use the test host launcher to launch it ? What side - // effects does this have ? - // - // This is useful for profiling and maybe for launching hosts other than the - // ones managed by us (i.e., the default host and the dotnet host), examples - // including UWP and other hosts that don't implement the ITestRuntimeProvider2 - // interface and/or are not aware of the possibility of attaching to an already - // running process. - Sources = sources, - RunSettings = runSettings, - HasCustomHostLauncher = testHostLauncher != null, - IsDebuggingEnabled = (testHostLauncher != null) && testHostLauncher.IsDebug, - TestPlatformOptions = options - }; + _communicationManager.SendMessage( + MessageType.StartTestSession, + payload, + _protocolVersion); - this.communicationManager.SendMessage( - MessageType.StartTestSession, - payload, - this.protocolVersion); + while (true) + { + var message = TryReceiveMessage(); - while (true) + switch (message.MessageType) { - var message = await this.TryReceiveMessageAsync().ConfigureAwait(false); + case MessageType.StartTestSessionCallback: + var ackPayload = _dataSerializer + .DeserializePayload(message); + eventsHandler?.HandleStartTestSessionComplete( + ackPayload.TestSessionInfo); + return ackPayload.TestSessionInfo; + + case MessageType.CustomTestHostLaunch: + HandleCustomHostLaunch(testHostLauncher, message); + break; + + case MessageType.EditorAttachDebugger: + AttachDebuggerToProcess(testHostLauncher, message); + break; + + case MessageType.TestMessage: + var testMessagePayload = _dataSerializer + .DeserializePayload(message); + eventsHandler?.HandleLogMessage( + testMessagePayload.MessageLevel, + testMessagePayload.Message); + break; - switch (message.MessageType) - { - case MessageType.StartTestSessionCallback: - var ackPayload = this.dataSerializer - .DeserializePayload(message); - eventsHandler?.HandleStartTestSessionComplete( - ackPayload.TestSessionInfo); - return ackPayload.TestSessionInfo; - - case MessageType.CustomTestHostLaunch: - this.HandleCustomHostLaunch(testHostLauncher, message); - break; - - case MessageType.EditorAttachDebugger: - this.AttachDebuggerToProcess(testHostLauncher, message); - break; - - case MessageType.TestMessage: - var testMessagePayload = this.dataSerializer - .DeserializePayload(message); - eventsHandler?.HandleLogMessage( - testMessagePayload.MessageLevel, - testMessagePayload.Message); - break; - - default: - EqtTrace.Warning( - "VsTestConsoleRequestSender.StartTestSession: Unexpected message received: {0}", - message.MessageType); - break; - } + default: + EqtTrace.Warning( + "VsTestConsoleRequestSender.StartTestSession: Unexpected message received: {0}", + message.MessageType); + break; } } - catch (Exception exception) - { - EqtTrace.Error("Aborting StartTestSession operation due to error: {0}", exception); - eventsHandler?.HandleLogMessage( - TestMessageLevel.Error, - TranslationLayerResources.AbortedStartTestSession); + } + catch (Exception exception) + { + EqtTrace.Error( + "Aborting StartTestSession operation due to error: {0}", + exception); + eventsHandler?.HandleLogMessage( + TestMessageLevel.Error, + TranslationLayerResources.AbortedStartTestSession); + + eventsHandler?.HandleStartTestSessionComplete(null); + } + finally + { + _testPlatformEventSource.TranslationLayerStartTestSessionStop(); + } - eventsHandler?.HandleStartTestSessionComplete(null); - } - finally - { - this.testPlatformEventSource.TranslationLayerStartTestSessionStop(); - } + return null; + } - return null; + /// + public async Task StartTestSessionAsync( + IList sources, + string runSettings, + TestPlatformOptions options, + ITestSessionEventsHandler eventsHandler, + ITestHostLauncher testHostLauncher) + { + // Make sure vstest.console knows how to handle start/stop test session messages. + // Bail out if it doesn't, otherwise we'll hang waiting for a reply from the console + // that will never come. + if (_protocolVersion < MinimumProtocolVersionWithTestSessionSupport) + { + eventsHandler?.HandleStartTestSessionComplete(null); + return await Task.FromResult((TestSessionInfo)null); } - /// - public bool StopTestSession( - TestSessionInfo testSessionInfo, - ITestSessionEventsHandler eventsHandler) + if (EqtTrace.IsInfoEnabled) { - // Make sure vstest.console knows how to handle start/stop test session messages. - // Bail out if it doesn't, otherwise we'll hang waiting for a reply from the console - // that will never come. - if (this.protocolVersion < MinimumProtocolVersionWithTestSessionSupport) - { - eventsHandler?.HandleStopTestSessionComplete(testSessionInfo, false); - return false; - } + EqtTrace.Info("VsTestConsoleRequestSender.StartTestSession: Starting test session."); + } - if (EqtTrace.IsInfoEnabled) + try + { + var payload = new StartTestSessionPayload { - EqtTrace.Info("VsTestConsoleRequestSender.StopTestSession: Stop test session."); - } + // TODO (copoiena): When sharing the test host between test discovery and test + // execution, should we use the test host launcher to launch it ? What side + // effects does this have ? + // + // This is useful for profiling and maybe for launching hosts other than the + // ones managed by us (i.e., the default host and the dotnet host), examples + // including UWP and other hosts that don't implement the ITestRuntimeProvider2 + // interface and/or are not aware of the possibility of attaching to an already + // running process. + Sources = sources, + RunSettings = runSettings, + HasCustomHostLauncher = testHostLauncher != null, + IsDebuggingEnabled = (testHostLauncher != null) && testHostLauncher.IsDebug, + TestPlatformOptions = options + }; - // Due to various considertaions it is possible to end up with a null test session - // after doing the start test session call. However, we should filter out requests - // to stop such a session as soon as possible, at the request sender level. - // - // We do this here instead of on the wrapper level in order to benefit from the - // testplatform events being fired still. - if (testSessionInfo == null) - { - this.testPlatformEventSource.TranslationLayerStopTestSessionStop(); - return true; - } + _communicationManager.SendMessage( + MessageType.StartTestSession, + payload, + _protocolVersion); - try + while (true) { - this.communicationManager.SendMessage( - MessageType.StopTestSession, - testSessionInfo, - this.protocolVersion); + var message = await TryReceiveMessageAsync().ConfigureAwait(false); - while (true) + switch (message.MessageType) { - var message = this.TryReceiveMessage(); + case MessageType.StartTestSessionCallback: + var ackPayload = _dataSerializer + .DeserializePayload(message); + eventsHandler?.HandleStartTestSessionComplete( + ackPayload.TestSessionInfo); + return ackPayload.TestSessionInfo; + + case MessageType.CustomTestHostLaunch: + HandleCustomHostLaunch(testHostLauncher, message); + break; + + case MessageType.EditorAttachDebugger: + AttachDebuggerToProcess(testHostLauncher, message); + break; + + case MessageType.TestMessage: + var testMessagePayload = _dataSerializer + .DeserializePayload(message); + eventsHandler?.HandleLogMessage( + testMessagePayload.MessageLevel, + testMessagePayload.Message); + break; - switch (message.MessageType) - { - case MessageType.StopTestSessionCallback: - var payload = this.dataSerializer.DeserializePayload(message); - eventsHandler?.HandleStopTestSessionComplete(payload.TestSessionInfo, payload.IsStopped); - return payload.IsStopped; - - case MessageType.TestMessage: - var testMessagePayload = this.dataSerializer - .DeserializePayload(message); - eventsHandler?.HandleLogMessage( - testMessagePayload.MessageLevel, - testMessagePayload.Message); - break; - - default: - EqtTrace.Warning( - "VsTestConsoleRequestSender.StopTestSession: Unexpected message received: {0}", - message.MessageType); - break; - } + default: + EqtTrace.Warning( + "VsTestConsoleRequestSender.StartTestSession: Unexpected message received: {0}", + message.MessageType); + break; } } - catch (Exception exception) - { - EqtTrace.Error( - "Aborting StopTestSession operation for id {0} due to error: {1}", - testSessionInfo?.Id, - exception); - eventsHandler?.HandleLogMessage( - TestMessageLevel.Error, - TranslationLayerResources.AbortedStopTestSession); - - eventsHandler?.HandleStopTestSessionComplete(testSessionInfo, false); - } - finally - { - this.testPlatformEventSource.TranslationLayerStopTestSessionStop(); - } + } + catch (Exception exception) + { + EqtTrace.Error("Aborting StartTestSession operation due to error: {0}", exception); + eventsHandler?.HandleLogMessage( + TestMessageLevel.Error, + TranslationLayerResources.AbortedStartTestSession); + + eventsHandler?.HandleStartTestSessionComplete(null); + } + finally + { + _testPlatformEventSource.TranslationLayerStartTestSessionStop(); + } + return null; + } + + /// + public bool StopTestSession( + TestSessionInfo testSessionInfo, + ITestSessionEventsHandler eventsHandler) + { + // Make sure vstest.console knows how to handle start/stop test session messages. + // Bail out if it doesn't, otherwise we'll hang waiting for a reply from the console + // that will never come. + if (_protocolVersion < MinimumProtocolVersionWithTestSessionSupport) + { + eventsHandler?.HandleStopTestSessionComplete(testSessionInfo, false); return false; } - /// - public async Task StopTestSessionAsync( - TestSessionInfo testSessionInfo, - ITestSessionEventsHandler eventsHandler) + if (EqtTrace.IsInfoEnabled) { - // Make sure vstest.console knows how to handle start/stop test session messages. - // Bail out if it doesn't, otherwise we'll hang waiting for a reply from the console - // that will never come. - if (this.protocolVersion < MinimumProtocolVersionWithTestSessionSupport) - { - eventsHandler?.HandleStopTestSessionComplete(testSessionInfo, false); - return await Task.FromResult(false); - } + EqtTrace.Info("VsTestConsoleRequestSender.StopTestSession: Stop test session."); + } - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("VsTestConsoleRequestSender.StopTestSession: Stop test session."); - } + // Due to various considertaions it is possible to end up with a null test session + // after doing the start test session call. However, we should filter out requests + // to stop such a session as soon as possible, at the request sender level. + // + // We do this here instead of on the wrapper level in order to benefit from the + // testplatform events being fired still. + if (testSessionInfo == null) + { + _testPlatformEventSource.TranslationLayerStopTestSessionStop(); + return true; + } - // Due to various considertaions it is possible to end up with a null test session - // after doing the start test session call. However, we should filter out requests - // to stop such a session as soon as possible, at the request sender level. - // - // We do this here instead of on the wrapper level in order to benefit from the - // testplatform events being fired still. - if (testSessionInfo == null) - { - this.testPlatformEventSource.TranslationLayerStopTestSessionStop(); - return true; - } + try + { + _communicationManager.SendMessage( + MessageType.StopTestSession, + testSessionInfo, + _protocolVersion); - try + while (true) { - this.communicationManager.SendMessage( - MessageType.StopTestSession, - testSessionInfo, - this.protocolVersion); + var message = TryReceiveMessage(); - while (true) + switch (message.MessageType) { - var message = await this.TryReceiveMessageAsync().ConfigureAwait(false); + case MessageType.StopTestSessionCallback: + var payload = _dataSerializer.DeserializePayload(message); + eventsHandler?.HandleStopTestSessionComplete(payload.TestSessionInfo, payload.IsStopped); + return payload.IsStopped; - switch (message.MessageType) - { - case MessageType.StopTestSessionCallback: - var payload = this.dataSerializer.DeserializePayload(message); - eventsHandler?.HandleStopTestSessionComplete(payload.TestSessionInfo, payload.IsStopped); - return payload.IsStopped; - - case MessageType.TestMessage: - var testMessagePayload = this.dataSerializer - .DeserializePayload(message); - eventsHandler?.HandleLogMessage( - testMessagePayload.MessageLevel, - testMessagePayload.Message); - break; - - default: - EqtTrace.Warning( - "VsTestConsoleRequestSender.StopTestSession: Unexpected message received: {0}", - message.MessageType); - break; - } + case MessageType.TestMessage: + var testMessagePayload = _dataSerializer + .DeserializePayload(message); + eventsHandler?.HandleLogMessage( + testMessagePayload.MessageLevel, + testMessagePayload.Message); + break; + + default: + EqtTrace.Warning( + "VsTestConsoleRequestSender.StopTestSession: Unexpected message received: {0}", + message.MessageType); + break; } } - catch (Exception exception) - { - EqtTrace.Error( - "Aborting StopTestSession operation for id {0} due to error: {1}", - testSessionInfo?.Id, - exception); - eventsHandler?.HandleLogMessage( - TestMessageLevel.Error, - TranslationLayerResources.AbortedStopTestSession); - - eventsHandler?.HandleStopTestSessionComplete(testSessionInfo, false); - } - finally - { - this.testPlatformEventSource.TranslationLayerStopTestSessionStop(); - } - - return false; } - - /// - public void CancelTestRun() + catch (Exception exception) { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("VsTestConsoleRequestSender.CancelTestRun: Canceling test run."); - } + EqtTrace.Error( + "Aborting StopTestSession operation for id {0} due to error: {1}", + testSessionInfo?.Id, + exception); + eventsHandler?.HandleLogMessage( + TestMessageLevel.Error, + TranslationLayerResources.AbortedStopTestSession); + + eventsHandler?.HandleStopTestSessionComplete(testSessionInfo, false); + } + finally + { + _testPlatformEventSource.TranslationLayerStopTestSessionStop(); + } + + return false; + } - this.communicationManager.SendMessage(MessageType.CancelTestRun); + /// + public async Task StopTestSessionAsync( + TestSessionInfo testSessionInfo, + ITestSessionEventsHandler eventsHandler) + { + // Make sure vstest.console knows how to handle start/stop test session messages. + // Bail out if it doesn't, otherwise we'll hang waiting for a reply from the console + // that will never come. + if (_protocolVersion < MinimumProtocolVersionWithTestSessionSupport) + { + eventsHandler?.HandleStopTestSessionComplete(testSessionInfo, false); + return await Task.FromResult(false); } - /// - public void AbortTestRun() + if (EqtTrace.IsInfoEnabled) { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("VsTestConsoleRequestSender.AbortTestRun: Aborting test run."); - } + EqtTrace.Info("VsTestConsoleRequestSender.StopTestSession: Stop test session."); + } - this.communicationManager.SendMessage(MessageType.AbortTestRun); + // Due to various considertaions it is possible to end up with a null test session + // after doing the start test session call. However, we should filter out requests + // to stop such a session as soon as possible, at the request sender level. + // + // We do this here instead of on the wrapper level in order to benefit from the + // testplatform events being fired still. + if (testSessionInfo == null) + { + _testPlatformEventSource.TranslationLayerStopTestSessionStop(); + return true; } - /// - public void CancelDiscovery() + try { - if (EqtTrace.IsInfoEnabled) + _communicationManager.SendMessage( + MessageType.StopTestSession, + testSessionInfo, + _protocolVersion); + + while (true) { - EqtTrace.Info("VsTestConsoleRequestSender.CancelDiscovery: Canceling test discovery."); - } + var message = await TryReceiveMessageAsync().ConfigureAwait(false); - this.communicationManager.SendMessage(MessageType.CancelDiscovery); - } + switch (message.MessageType) + { + case MessageType.StopTestSessionCallback: + var payload = _dataSerializer.DeserializePayload(message); + eventsHandler?.HandleStopTestSessionComplete(payload.TestSessionInfo, payload.IsStopped); + return payload.IsStopped; - /// - public void OnProcessExited() + case MessageType.TestMessage: + var testMessagePayload = _dataSerializer + .DeserializePayload(message); + eventsHandler?.HandleLogMessage( + testMessagePayload.MessageLevel, + testMessagePayload.Message); + break; + + default: + EqtTrace.Warning( + "VsTestConsoleRequestSender.StopTestSession: Unexpected message received: {0}", + message.MessageType); + break; + } + } + } + catch (Exception exception) { - this.processExitCancellationTokenSource.Cancel(); + EqtTrace.Error( + "Aborting StopTestSession operation for id {0} due to error: {1}", + testSessionInfo?.Id, + exception); + eventsHandler?.HandleLogMessage( + TestMessageLevel.Error, + TranslationLayerResources.AbortedStopTestSession); + + eventsHandler?.HandleStopTestSessionComplete(testSessionInfo, false); + } + finally + { + _testPlatformEventSource.TranslationLayerStopTestSessionStop(); } - /// - public void Close() + return false; + } + + /// + public void CancelTestRun() + { + if (EqtTrace.IsInfoEnabled) { - this.Dispose(); + EqtTrace.Info("VsTestConsoleRequestSender.CancelTestRun: Canceling test run."); } - /// - public void EndSession() + _communicationManager.SendMessage(MessageType.CancelTestRun); + } + + /// + public void AbortTestRun() + { + if (EqtTrace.IsInfoEnabled) { - this.communicationManager.SendMessage(MessageType.SessionEnd); + EqtTrace.Info("VsTestConsoleRequestSender.AbortTestRun: Aborting test run."); } - /// - public Task ProcessTestRunAttachmentsAsync( - IEnumerable attachments, - IEnumerable invokedDataCollectors, - string runSettings, - bool collectMetrics, - ITestRunAttachmentsProcessingEventsHandler testSessionEventsHandler, - CancellationToken cancellationToken) + _communicationManager.SendMessage(MessageType.AbortTestRun); + } + + /// + public void CancelDiscovery() + { + if (EqtTrace.IsInfoEnabled) { - return this.SendMessageAndListenAndReportAttachmentsProcessingResultAsync( - attachments, - invokedDataCollectors, - runSettings, - collectMetrics, - testSessionEventsHandler, - cancellationToken); + EqtTrace.Info("VsTestConsoleRequestSender.CancelDiscovery: Canceling test discovery."); } - /// - public void Dispose() + _communicationManager.SendMessage(MessageType.CancelDiscovery); + } + + /// + public void OnProcessExited() + { + _processExitCancellationTokenSource.Cancel(); + } + + /// + public void Close() + { + Dispose(); + } + + /// + public void EndSession() + { + _communicationManager.SendMessage(MessageType.SessionEnd); + } + + /// + public Task ProcessTestRunAttachmentsAsync( + IEnumerable attachments, + IEnumerable invokedDataCollectors, + string runSettings, + bool collectMetrics, + ITestRunAttachmentsProcessingEventsHandler testSessionEventsHandler, + CancellationToken cancellationToken) + { + return SendMessageAndListenAndReportAttachmentsProcessingResultAsync( + attachments, + invokedDataCollectors, + runSettings, + collectMetrics, + testSessionEventsHandler, + cancellationToken); + } + + /// + public void Dispose() + { + _communicationManager?.StopServer(); + } + + #endregion + + private bool HandShakeWithVsTestConsole() + { + var success = false; + var message = _communicationManager.ReceiveMessage(); + + if (message.MessageType == MessageType.SessionConnected) { - this.communicationManager?.StopServer(); + _communicationManager.SendMessage( + MessageType.VersionCheck, + _protocolVersion); + + message = _communicationManager.ReceiveMessage(); + + if (message.MessageType == MessageType.VersionCheck) + { + _protocolVersion = _dataSerializer + .DeserializePayload(message); + success = true; + } + else if (message.MessageType == MessageType.ProtocolError) + { + // TODO : Payload for ProtocolError needs to finalized. + EqtTrace.Error( + "VsTestConsoleRequestSender.HandShakeWithVsTestConsole: Version Check failed. ProtolError was received from the runner"); + } + else + { + EqtTrace.Error( + "VsTestConsoleRequestSender.HandShakeWithVsTestConsole: VersionCheck Message Expected but different message received: Received MessageType: {0}", + message.MessageType); + } + } + else + { + EqtTrace.Error( + "VsTestConsoleRequestSender.HandShakeWithVsTestConsole: SessionConnected Message Expected but different message received: Received MessageType: {0}", + message.MessageType); } - #endregion + return success; + } + + private async Task HandShakeWithVsTestConsoleAsync() + { + var success = false; + var message = await _communicationManager.ReceiveMessageAsync( + _processExitCancellationTokenSource.Token).ConfigureAwait(false); - private bool HandShakeWithVsTestConsole() + if (message.MessageType == MessageType.SessionConnected) { - var success = false; - var message = this.communicationManager.ReceiveMessage(); - - if (message.MessageType == MessageType.SessionConnected) - { - this.communicationManager.SendMessage( - MessageType.VersionCheck, - this.protocolVersion); + _communicationManager.SendMessage( + MessageType.VersionCheck, + _protocolVersion); - message = this.communicationManager.ReceiveMessage(); + message = await _communicationManager.ReceiveMessageAsync( + _processExitCancellationTokenSource.Token).ConfigureAwait(false); - if (message.MessageType == MessageType.VersionCheck) - { - this.protocolVersion = this.dataSerializer - .DeserializePayload(message); - success = true; - } - else if (message.MessageType == MessageType.ProtocolError) - { - // TODO : Payload for ProtocolError needs to finalized. - EqtTrace.Error( - "VsTestConsoleRequestSender.HandShakeWithVsTestConsole: Version Check failed. ProtolError was received from the runner"); - } - else - { - EqtTrace.Error( - "VsTestConsoleRequestSender.HandShakeWithVsTestConsole: VersionCheck Message Expected but different message received: Received MessageType: {0}", - message.MessageType); - } + if (message.MessageType == MessageType.VersionCheck) + { + _protocolVersion = _dataSerializer.DeserializePayload(message); + success = true; + } + else if (message.MessageType == MessageType.ProtocolError) + { + // TODO : Payload for ProtocolError needs to finalized. + EqtTrace.Error( + "VsTestConsoleRequestSender.HandShakeWithVsTestConsoleAsync: Version Check failed. ProtolError was received from the runner"); } else { EqtTrace.Error( - "VsTestConsoleRequestSender.HandShakeWithVsTestConsole: SessionConnected Message Expected but different message received: Received MessageType: {0}", + "VsTestConsoleRequestSender.HandShakeWithVsTestConsoleAsync: VersionCheck Message Expected but different message received: Received MessageType: {0}", message.MessageType); } - - return success; + } + else + { + EqtTrace.Error( + "VsTestConsoleRequestSender.HandShakeWithVsTestConsoleAsync: SessionConnected Message Expected but different message received: Received MessageType: {0}", + message.MessageType); } - private async Task HandShakeWithVsTestConsoleAsync() + return success; + } + + private void SendMessageAndListenAndReportTestCases( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestDiscoveryEventsHandler2 eventHandler) + { + try { - var success = false; - var message = await this.communicationManager.ReceiveMessageAsync( - this.processExitCancellationTokenSource.Token).ConfigureAwait(false); + _communicationManager.SendMessage( + MessageType.StartDiscovery, + new DiscoveryRequestPayload() + { + Sources = sources, + RunSettings = runSettings, + TestPlatformOptions = options, + TestSessionInfo = testSessionInfo + }, + _protocolVersion); + var isDiscoveryComplete = false; - if (message.MessageType == MessageType.SessionConnected) + // Cycle through the messages that vstest.console sends. + // Currently each operation is not a separate task since it should not take that + // much time to complete. + // + // This is just a notification. + while (!isDiscoveryComplete) { - this.communicationManager.SendMessage( - MessageType.VersionCheck, - this.protocolVersion); + var message = TryReceiveMessage(); - message = await this.communicationManager.ReceiveMessageAsync( - this.processExitCancellationTokenSource.Token).ConfigureAwait(false); - - if (message.MessageType == MessageType.VersionCheck) + if (string.Equals(MessageType.TestCasesFound, message.MessageType)) { - this.protocolVersion = this.dataSerializer.DeserializePayload(message); - success = true; + var testCases = _dataSerializer + .DeserializePayload>(message); + + eventHandler.HandleDiscoveredTests(testCases); } - else if (message.MessageType == MessageType.ProtocolError) + else if (string.Equals(MessageType.DiscoveryComplete, message.MessageType)) { - // TODO : Payload for ProtocolError needs to finalized. - EqtTrace.Error( - "VsTestConsoleRequestSender.HandShakeWithVsTestConsoleAsync: Version Check failed. ProtolError was received from the runner"); + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info( + "VsTestConsoleRequestSender.SendMessageAndListenAndReportTestCases: Discovery complete."); + } + + var discoveryCompletePayload = + _dataSerializer + .DeserializePayload(message); + + var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs( + discoveryCompletePayload.TotalTests, + discoveryCompletePayload.IsAborted); + + // Adding metrics from vstest.console. + discoveryCompleteEventArgs.Metrics = discoveryCompletePayload.Metrics; + + eventHandler.HandleDiscoveryComplete( + discoveryCompleteEventArgs, + discoveryCompletePayload.LastDiscoveredTests); + isDiscoveryComplete = true; } - else + else if (string.Equals(MessageType.TestMessage, message.MessageType)) { - EqtTrace.Error( - "VsTestConsoleRequestSender.HandShakeWithVsTestConsoleAsync: VersionCheck Message Expected but different message received: Received MessageType: {0}", - message.MessageType); + var testMessagePayload = _dataSerializer + .DeserializePayload(message); + eventHandler.HandleLogMessage( + testMessagePayload.MessageLevel, + testMessagePayload.Message); } } - else - { - EqtTrace.Error( - "VsTestConsoleRequestSender.HandShakeWithVsTestConsoleAsync: SessionConnected Message Expected but different message received: Received MessageType: {0}", - message.MessageType); - } - - return success; } + catch (Exception exception) + { + EqtTrace.Error("Aborting Test Discovery Operation: {0}", exception); + eventHandler.HandleLogMessage( + TestMessageLevel.Error, + TranslationLayerResources.AbortedTestsDiscovery); + var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(-1, true); + eventHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, null); + + // Earlier we were closing the connection with vstest.console in case of exceptions. + // Removing that code because vstest.console might be in a healthy state and letting + // the client know of the error, so that the TL can wait for the next instruction + // from the client itself. + // Also, connection termination might not kill the process which could result in + // files being locked by testhost. + } + + _testPlatformEventSource.TranslationLayerDiscoveryStop(); + } - private void SendMessageAndListenAndReportTestCases( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestDiscoveryEventsHandler2 eventHandler) + private async Task SendMessageAndListenAndReportTestCasesAsync( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestDiscoveryEventsHandler2 eventHandler) + { + try { - try + _communicationManager.SendMessage( + MessageType.StartDiscovery, + new DiscoveryRequestPayload() + { + Sources = sources, + RunSettings = runSettings, + TestPlatformOptions = options, + TestSessionInfo = testSessionInfo + }, + _protocolVersion); + var isDiscoveryComplete = false; + + // Cycle through the messages that vstest.console sends. + // Currently each operation is not a separate task since it should not take that + // much time to complete. + // + // This is just a notification. + while (!isDiscoveryComplete) { - this.communicationManager.SendMessage( - MessageType.StartDiscovery, - new DiscoveryRequestPayload() - { - Sources = sources, - RunSettings = runSettings, - TestPlatformOptions = options, - TestSessionInfo = testSessionInfo - }, - this.protocolVersion); - var isDiscoveryComplete = false; + var message = await TryReceiveMessageAsync().ConfigureAwait(false); - // Cycle through the messages that vstest.console sends. - // Currently each operation is not a separate task since it should not take that - // much time to complete. - // - // This is just a notification. - while (!isDiscoveryComplete) + if (string.Equals(MessageType.TestCasesFound, message.MessageType)) { - var message = this.TryReceiveMessage(); + var testCases = _dataSerializer + .DeserializePayload>(message); - if (string.Equals(MessageType.TestCasesFound, message.MessageType)) + eventHandler.HandleDiscoveredTests(testCases); + } + else if (string.Equals(MessageType.DiscoveryComplete, message.MessageType)) + { + if (EqtTrace.IsInfoEnabled) { - var testCases = this.dataSerializer - .DeserializePayload>(message); - - eventHandler.HandleDiscoveredTests(testCases); + EqtTrace.Info( + "VsTestConsoleRequestSender.SendMessageAndListenAndReportTestCasesAsync: Discovery complete."); } - else if (string.Equals(MessageType.DiscoveryComplete, message.MessageType)) - { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info( - "VsTestConsoleRequestSender.SendMessageAndListenAndReportTestCases: Discovery complete."); - } - var discoveryCompletePayload = - this.dataSerializer - .DeserializePayload(message); + var discoveryCompletePayload = + _dataSerializer.DeserializePayload(message); - var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs( - discoveryCompletePayload.TotalTests, - discoveryCompletePayload.IsAborted); + var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs( + discoveryCompletePayload.TotalTests, + discoveryCompletePayload.IsAborted); - // Adding metrics from vstest.console. - discoveryCompleteEventArgs.Metrics = discoveryCompletePayload.Metrics; + // Adding Metrics from VsTestConsole + discoveryCompleteEventArgs.Metrics = discoveryCompletePayload.Metrics; - eventHandler.HandleDiscoveryComplete( - discoveryCompleteEventArgs, - discoveryCompletePayload.LastDiscoveredTests); - isDiscoveryComplete = true; - } - else if (string.Equals(MessageType.TestMessage, message.MessageType)) - { - var testMessagePayload = this.dataSerializer - .DeserializePayload(message); - eventHandler.HandleLogMessage( - testMessagePayload.MessageLevel, - testMessagePayload.Message); - } + eventHandler.HandleDiscoveryComplete( + discoveryCompleteEventArgs, + discoveryCompletePayload.LastDiscoveredTests); + isDiscoveryComplete = true; + } + else if (string.Equals(MessageType.TestMessage, message.MessageType)) + { + var testMessagePayload = _dataSerializer + .DeserializePayload(message); + eventHandler.HandleLogMessage( + testMessagePayload.MessageLevel, + testMessagePayload.Message); } } - catch (Exception exception) - { - EqtTrace.Error("Aborting Test Discovery Operation: {0}", exception); - eventHandler.HandleLogMessage( - TestMessageLevel.Error, - TranslationLayerResources.AbortedTestsDiscovery); - var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(-1, true); - eventHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, null); - - // Earlier we were closing the connection with vstest.console in case of exceptions. - // Removing that code because vstest.console might be in a healthy state and letting - // the client know of the error, so that the TL can wait for the next instruction - // from the client itself. - // Also, connection termination might not kill the process which could result in - // files being locked by testhost. - } - - this.testPlatformEventSource.TranslationLayerDiscoveryStop(); } - - private async Task SendMessageAndListenAndReportTestCasesAsync( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestDiscoveryEventsHandler2 eventHandler) + catch (Exception exception) { - try - { - this.communicationManager.SendMessage( - MessageType.StartDiscovery, - new DiscoveryRequestPayload() - { - Sources = sources, - RunSettings = runSettings, - TestPlatformOptions = options, - TestSessionInfo = testSessionInfo - }, - this.protocolVersion); - var isDiscoveryComplete = false; + EqtTrace.Error("Aborting Test Discovery Operation: {0}", exception); - // Cycle through the messages that vstest.console sends. - // Currently each operation is not a separate task since it should not take that - // much time to complete. - // - // This is just a notification. - while (!isDiscoveryComplete) - { - var message = await this.TryReceiveMessageAsync().ConfigureAwait(false); + eventHandler.HandleLogMessage( + TestMessageLevel.Error, + TranslationLayerResources.AbortedTestsDiscovery); - if (string.Equals(MessageType.TestCasesFound, message.MessageType)) - { - var testCases = this.dataSerializer - .DeserializePayload>(message); + var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(-1, true); + eventHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, null); - eventHandler.HandleDiscoveredTests(testCases); - } - else if (string.Equals(MessageType.DiscoveryComplete, message.MessageType)) - { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info( - "VsTestConsoleRequestSender.SendMessageAndListenAndReportTestCasesAsync: Discovery complete."); - } + // Earlier we were closing the connection with vstest.console in case of exceptions. + // Removing that code because vstest.console might be in a healthy state and letting + // the client know of the error, so that the TL can wait for the next instruction + // from the client itself. + // Also, connection termination might not kill the process which could result in + // files being locked by testhost. + } - var discoveryCompletePayload = - this.dataSerializer.DeserializePayload(message); + _testPlatformEventSource.TranslationLayerDiscoveryStop(); + } - var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs( - discoveryCompletePayload.TotalTests, - discoveryCompletePayload.IsAborted); + private void SendMessageAndListenAndReportTestResults( + string messageType, + object payload, + ITestRunEventsHandler eventHandler, + ITestHostLauncher customHostLauncher) + { + try + { + _communicationManager.SendMessage(messageType, payload, _protocolVersion); + var isTestRunComplete = false; - // Adding Metrics from VsTestConsole - discoveryCompleteEventArgs.Metrics = discoveryCompletePayload.Metrics; + // Cycle through the messages that vstest.console sends. + // Currently each operation is not a separate task since it should not take that + // much time to complete. + // + // This is just a notification. + while (!isTestRunComplete) + { + var message = TryReceiveMessage(); - eventHandler.HandleDiscoveryComplete( - discoveryCompleteEventArgs, - discoveryCompletePayload.LastDiscoveredTests); - isDiscoveryComplete = true; - } - else if (string.Equals(MessageType.TestMessage, message.MessageType)) + if (string.Equals(MessageType.TestRunStatsChange, message.MessageType)) + { + var testRunChangedArgs = _dataSerializer + .DeserializePayload( + message); + eventHandler.HandleTestRunStatsChange(testRunChangedArgs); + } + else if (string.Equals(MessageType.ExecutionComplete, message.MessageType)) + { + if (EqtTrace.IsInfoEnabled) { - var testMessagePayload = this.dataSerializer - .DeserializePayload(message); - eventHandler.HandleLogMessage( - testMessagePayload.MessageLevel, - testMessagePayload.Message); + EqtTrace.Info( + "VsTestConsoleRequestSender.SendMessageAndListenAndReportTestResults: Execution complete."); } - } - } - catch (Exception exception) - { - EqtTrace.Error("Aborting Test Discovery Operation: {0}", exception); - - eventHandler.HandleLogMessage( - TestMessageLevel.Error, - TranslationLayerResources.AbortedTestsDiscovery); - var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(-1, true); - eventHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, null); + var testRunCompletePayload = _dataSerializer + .DeserializePayload(message); - // Earlier we were closing the connection with vstest.console in case of exceptions. - // Removing that code because vstest.console might be in a healthy state and letting - // the client know of the error, so that the TL can wait for the next instruction - // from the client itself. - // Also, connection termination might not kill the process which could result in - // files being locked by testhost. + eventHandler.HandleTestRunComplete( + testRunCompletePayload.TestRunCompleteArgs, + testRunCompletePayload.LastRunTests, + testRunCompletePayload.RunAttachments, + testRunCompletePayload.ExecutorUris); + isTestRunComplete = true; + } + else if (string.Equals(MessageType.TestMessage, message.MessageType)) + { + var testMessagePayload = _dataSerializer + .DeserializePayload(message); + eventHandler.HandleLogMessage( + testMessagePayload.MessageLevel, + testMessagePayload.Message); + } + else if (string.Equals(MessageType.CustomTestHostLaunch, message.MessageType)) + { + HandleCustomHostLaunch(customHostLauncher, message); + } + else if (string.Equals(MessageType.EditorAttachDebugger, message.MessageType)) + { + AttachDebuggerToProcess(customHostLauncher, message); + } } - - this.testPlatformEventSource.TranslationLayerDiscoveryStop(); } + catch (Exception exception) + { + EqtTrace.Error("Aborting Test Run Operation: {0}", exception); + eventHandler.HandleLogMessage( + TestMessageLevel.Error, + TranslationLayerResources.AbortedTestsRun); + var completeArgs = new TestRunCompleteEventArgs( + null, false, true, exception, null, null, TimeSpan.Zero); + eventHandler.HandleTestRunComplete(completeArgs, null, null, null); + + // Earlier we were closing the connection with vstest.console in case of exceptions. + // Removing that code because vstest.console might be in a healthy state and letting + // the client know of the error, so that the TL can wait for the next instruction + // from the client itself. + // Also, connection termination might not kill the process which could result in + // files being locked by testhost. + } + + _testPlatformEventSource.TranslationLayerExecutionStop(); + } - private void SendMessageAndListenAndReportTestResults( - string messageType, - object payload, - ITestRunEventsHandler eventHandler, - ITestHostLauncher customHostLauncher) + private async Task SendMessageAndListenAndReportTestResultsAsync( + string messageType, + object payload, + ITestRunEventsHandler eventHandler, + ITestHostLauncher customHostLauncher) + { + try { - try + _communicationManager.SendMessage(messageType, payload, _protocolVersion); + var isTestRunComplete = false; + + // Cycle through the messages that vstest.console sends. + // Currently each operation is not a separate task since it should not take that + // much time to complete. + // + // This is just a notification. + while (!isTestRunComplete) { - this.communicationManager.SendMessage(messageType, payload, this.protocolVersion); - var isTestRunComplete = false; + var message = await TryReceiveMessageAsync().ConfigureAwait(false); - // Cycle through the messages that vstest.console sends. - // Currently each operation is not a separate task since it should not take that - // much time to complete. - // - // This is just a notification. - while (!isTestRunComplete) + if (string.Equals(MessageType.TestRunStatsChange, message.MessageType)) { - var message = this.TryReceiveMessage(); - - if (string.Equals(MessageType.TestRunStatsChange, message.MessageType)) + var testRunChangedArgs = _dataSerializer + .DeserializePayload(message); + eventHandler.HandleTestRunStatsChange(testRunChangedArgs); + } + else if (string.Equals(MessageType.ExecutionComplete, message.MessageType)) + { + if (EqtTrace.IsInfoEnabled) { - var testRunChangedArgs = this.dataSerializer - .DeserializePayload( - message); - eventHandler.HandleTestRunStatsChange(testRunChangedArgs); + EqtTrace.Info( + "VsTestConsoleRequestSender.SendMessageAndListenAndReportTestResultsAsync: Execution complete."); } - else if (string.Equals(MessageType.ExecutionComplete, message.MessageType)) - { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info( - "VsTestConsoleRequestSender.SendMessageAndListenAndReportTestResults: Execution complete."); - } - var testRunCompletePayload = this.dataSerializer - .DeserializePayload(message); + var testRunCompletePayload = _dataSerializer + .DeserializePayload(message); - eventHandler.HandleTestRunComplete( - testRunCompletePayload.TestRunCompleteArgs, - testRunCompletePayload.LastRunTests, - testRunCompletePayload.RunAttachments, - testRunCompletePayload.ExecutorUris); - isTestRunComplete = true; - } - else if (string.Equals(MessageType.TestMessage, message.MessageType)) - { - var testMessagePayload = this.dataSerializer - .DeserializePayload(message); - eventHandler.HandleLogMessage( - testMessagePayload.MessageLevel, - testMessagePayload.Message); - } - else if (string.Equals(MessageType.CustomTestHostLaunch, message.MessageType)) - { - this.HandleCustomHostLaunch(customHostLauncher, message); - } - else if (string.Equals(MessageType.EditorAttachDebugger, message.MessageType)) - { - this.AttachDebuggerToProcess(customHostLauncher, message); - } + eventHandler.HandleTestRunComplete( + testRunCompletePayload.TestRunCompleteArgs, + testRunCompletePayload.LastRunTests, + testRunCompletePayload.RunAttachments, + testRunCompletePayload.ExecutorUris); + isTestRunComplete = true; + } + else if (string.Equals(MessageType.TestMessage, message.MessageType)) + { + var testMessagePayload = _dataSerializer + .DeserializePayload(message); + eventHandler.HandleLogMessage( + testMessagePayload.MessageLevel, + testMessagePayload.Message); + } + else if (string.Equals(MessageType.CustomTestHostLaunch, message.MessageType)) + { + HandleCustomHostLaunch(customHostLauncher, message); + } + else if (string.Equals(MessageType.EditorAttachDebugger, message.MessageType)) + { + AttachDebuggerToProcess(customHostLauncher, message); } } - catch (Exception exception) - { - EqtTrace.Error("Aborting Test Run Operation: {0}", exception); - eventHandler.HandleLogMessage( - TestMessageLevel.Error, - TranslationLayerResources.AbortedTestsRun); - var completeArgs = new TestRunCompleteEventArgs( - null, false, true, exception, null, null, TimeSpan.Zero); - eventHandler.HandleTestRunComplete(completeArgs, null, null, null); - - // Earlier we were closing the connection with vstest.console in case of exceptions. - // Removing that code because vstest.console might be in a healthy state and letting - // the client know of the error, so that the TL can wait for the next instruction - // from the client itself. - // Also, connection termination might not kill the process which could result in - // files being locked by testhost. - } - - this.testPlatformEventSource.TranslationLayerExecutionStop(); + } + catch (Exception exception) + { + EqtTrace.Error("Aborting Test Run Operation: {0}", exception); + eventHandler.HandleLogMessage( + TestMessageLevel.Error, + TranslationLayerResources.AbortedTestsRun); + var completeArgs = new TestRunCompleteEventArgs( + null, false, true, exception, null, null, TimeSpan.Zero); + eventHandler.HandleTestRunComplete(completeArgs, null, null, null); + + // Earlier we were closing the connection with vstest.console in case of exceptions. + // Removing that code because vstest.console might be in a healthy state and letting + // the client know of the error, so that the TL can wait for the next instruction + // from the client itself. + // Also, connection termination might not kill the process which could result in + // files being locked by testhost. } - private async Task SendMessageAndListenAndReportTestResultsAsync( - string messageType, - object payload, - ITestRunEventsHandler eventHandler, - ITestHostLauncher customHostLauncher) + _testPlatformEventSource.TranslationLayerExecutionStop(); + } + + private async Task SendMessageAndListenAndReportAttachmentsProcessingResultAsync( + IEnumerable attachments, + IEnumerable invokedDataCollectors, + string runSettings, + bool collectMetrics, + ITestRunAttachmentsProcessingEventsHandler eventHandler, + CancellationToken cancellationToken) + { + try { - try + var payload = new TestRunAttachmentsProcessingPayload { - this.communicationManager.SendMessage(messageType, payload, this.protocolVersion); - var isTestRunComplete = false; + Attachments = attachments, + InvokedDataCollectors = invokedDataCollectors, + RunSettings = runSettings, + CollectMetrics = collectMetrics + }; + _communicationManager.SendMessage( + MessageType.TestRunAttachmentsProcessingStart, + payload); + var isTestRunAttachmentsProcessingComplete = false; + + using (cancellationToken.Register(() => + _communicationManager.SendMessage(MessageType.TestRunAttachmentsProcessingCancel))) + { // Cycle through the messages that vstest.console sends. // Currently each operation is not a separate task since it should not take that // much time to complete. // // This is just a notification. - while (!isTestRunComplete) + while (!isTestRunAttachmentsProcessingComplete) { - var message = await this.TryReceiveMessageAsync().ConfigureAwait(false); + var message = await TryReceiveMessageAsync().ConfigureAwait(false); - if (string.Equals(MessageType.TestRunStatsChange, message.MessageType)) - { - var testRunChangedArgs = this.dataSerializer - .DeserializePayload(message); - eventHandler.HandleTestRunStatsChange(testRunChangedArgs); - } - else if (string.Equals(MessageType.ExecutionComplete, message.MessageType)) + if (string.Equals( + MessageType.TestRunAttachmentsProcessingComplete, + message.MessageType)) { if (EqtTrace.IsInfoEnabled) { EqtTrace.Info( - "VsTestConsoleRequestSender.SendMessageAndListenAndReportTestResultsAsync: Execution complete."); + "VsTestConsoleRequestSender.SendMessageAndListenAndReportAttachments: Process complete."); } - var testRunCompletePayload = this.dataSerializer - .DeserializePayload(message); + var testRunAttachmentsProcessingCompletePayload = _dataSerializer + .DeserializePayload(message); - eventHandler.HandleTestRunComplete( - testRunCompletePayload.TestRunCompleteArgs, - testRunCompletePayload.LastRunTests, - testRunCompletePayload.RunAttachments, - testRunCompletePayload.ExecutorUris); - isTestRunComplete = true; + eventHandler.HandleTestRunAttachmentsProcessingComplete( + testRunAttachmentsProcessingCompletePayload.AttachmentsProcessingCompleteEventArgs, + testRunAttachmentsProcessingCompletePayload.Attachments); + isTestRunAttachmentsProcessingComplete = true; + } + else if (string.Equals( + MessageType.TestRunAttachmentsProcessingProgress, + message.MessageType)) + { + var testRunAttachmentsProcessingProgressPayload = _dataSerializer + .DeserializePayload(message); + eventHandler.HandleTestRunAttachmentsProcessingProgress( + testRunAttachmentsProcessingProgressPayload.AttachmentsProcessingProgressEventArgs); } else if (string.Equals(MessageType.TestMessage, message.MessageType)) { - var testMessagePayload = this.dataSerializer + var testMessagePayload = _dataSerializer .DeserializePayload(message); eventHandler.HandleLogMessage( testMessagePayload.MessageLevel, testMessagePayload.Message); } - else if (string.Equals(MessageType.CustomTestHostLaunch, message.MessageType)) + else { - this.HandleCustomHostLaunch(customHostLauncher, message); - } - else if (string.Equals(MessageType.EditorAttachDebugger, message.MessageType)) - { - this.AttachDebuggerToProcess(customHostLauncher, message); + EqtTrace.Warning( + $"VsTestConsoleRequestSender.SendMessageAndListenAndReportAttachments: Unexpected message received {message.MessageType}."); } } } - catch (Exception exception) - { - EqtTrace.Error("Aborting Test Run Operation: {0}", exception); - eventHandler.HandleLogMessage( - TestMessageLevel.Error, - TranslationLayerResources.AbortedTestsRun); - var completeArgs = new TestRunCompleteEventArgs( - null, false, true, exception, null, null, TimeSpan.Zero); - eventHandler.HandleTestRunComplete(completeArgs, null, null, null); - - // Earlier we were closing the connection with vstest.console in case of exceptions. - // Removing that code because vstest.console might be in a healthy state and letting - // the client know of the error, so that the TL can wait for the next instruction - // from the client itself. - // Also, connection termination might not kill the process which could result in - // files being locked by testhost. - } - - this.testPlatformEventSource.TranslationLayerExecutionStop(); } + catch (Exception exception) + { + EqtTrace.Error("Aborting Test Session End Operation: {0}", exception); + eventHandler.HandleLogMessage( + TestMessageLevel.Error, + TranslationLayerResources.AbortedTestRunAttachmentsProcessing); + eventHandler.HandleTestRunAttachmentsProcessingComplete( + new TestRunAttachmentsProcessingCompleteEventArgs(false, exception), + null); - private async Task SendMessageAndListenAndReportAttachmentsProcessingResultAsync( - IEnumerable attachments, - IEnumerable invokedDataCollectors, - string runSettings, - bool collectMetrics, - ITestRunAttachmentsProcessingEventsHandler eventHandler, - CancellationToken cancellationToken) + // Earlier we were closing the connection with vstest.console in case of exceptions. + // Removing that code because vstest.console might be in a healthy state and letting + // the client know of the error, so that the TL can wait for the next instruction + // from the client itself. + // Also, connection termination might not kill the process which could result in + // files being locked by testhost. + } + finally { - try - { - var payload = new TestRunAttachmentsProcessingPayload - { - Attachments = attachments, - InvokedDataCollectors = invokedDataCollectors, - RunSettings = runSettings, - CollectMetrics = collectMetrics - }; + _testPlatformEventSource.TranslationLayerTestRunAttachmentsProcessingStop(); + } + } - this.communicationManager.SendMessage( - MessageType.TestRunAttachmentsProcessingStart, - payload); - var isTestRunAttachmentsProcessingComplete = false; + private Message TryReceiveMessage() + { + var receiverMessageTask = _communicationManager.ReceiveMessageAsync( + _processExitCancellationTokenSource.Token); + receiverMessageTask.Wait(); + Message message = receiverMessageTask.Result; - using (cancellationToken.Register(() => - this.communicationManager.SendMessage(MessageType.TestRunAttachmentsProcessingCancel))) - { - // Cycle through the messages that vstest.console sends. - // Currently each operation is not a separate task since it should not take that - // much time to complete. - // - // This is just a notification. - while (!isTestRunAttachmentsProcessingComplete) - { - var message = await this.TryReceiveMessageAsync().ConfigureAwait(false); + return message ?? throw new TransationLayerException( + TranslationLayerResources.FailedToReceiveMessage); + } - if (string.Equals( - MessageType.TestRunAttachmentsProcessingComplete, - message.MessageType)) - { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info( - "VsTestConsoleRequestSender.SendMessageAndListenAndReportAttachments: Process complete."); - } - - var testRunAttachmentsProcessingCompletePayload = this.dataSerializer - .DeserializePayload(message); - - eventHandler.HandleTestRunAttachmentsProcessingComplete( - testRunAttachmentsProcessingCompletePayload.AttachmentsProcessingCompleteEventArgs, - testRunAttachmentsProcessingCompletePayload.Attachments); - isTestRunAttachmentsProcessingComplete = true; - } - else if (string.Equals( - MessageType.TestRunAttachmentsProcessingProgress, - message.MessageType)) - { - var testRunAttachmentsProcessingProgressPayload = this.dataSerializer - .DeserializePayload(message); - eventHandler.HandleTestRunAttachmentsProcessingProgress( - testRunAttachmentsProcessingProgressPayload.AttachmentsProcessingProgressEventArgs); - } - else if (string.Equals(MessageType.TestMessage, message.MessageType)) - { - var testMessagePayload = this.dataSerializer - .DeserializePayload(message); - eventHandler.HandleLogMessage( - testMessagePayload.MessageLevel, - testMessagePayload.Message); - } - else - { - EqtTrace.Warning( - $"VsTestConsoleRequestSender.SendMessageAndListenAndReportAttachments: Unexpected message received {message.MessageType}."); - } - } - } - } - catch (Exception exception) - { - EqtTrace.Error("Aborting Test Session End Operation: {0}", exception); - eventHandler.HandleLogMessage( - TestMessageLevel.Error, - TranslationLayerResources.AbortedTestRunAttachmentsProcessing); - eventHandler.HandleTestRunAttachmentsProcessingComplete( - new TestRunAttachmentsProcessingCompleteEventArgs(false, exception), - null); - - // Earlier we were closing the connection with vstest.console in case of exceptions. - // Removing that code because vstest.console might be in a healthy state and letting - // the client know of the error, so that the TL can wait for the next instruction - // from the client itself. - // Also, connection termination might not kill the process which could result in - // files being locked by testhost. - } - finally - { - this.testPlatformEventSource.TranslationLayerTestRunAttachmentsProcessingStop(); - } - } + private async Task TryReceiveMessageAsync() + { + Message message = await _communicationManager.ReceiveMessageAsync( + _processExitCancellationTokenSource.Token).ConfigureAwait(false); + + return message ?? throw new TransationLayerException( + TranslationLayerResources.FailedToReceiveMessage); + } - private Message TryReceiveMessage() + private void HandleCustomHostLaunch(ITestHostLauncher customHostLauncher, Message message) + { + var ackPayload = new CustomHostLaunchAckPayload() { - Message message = null; - var receiverMessageTask = this.communicationManager.ReceiveMessageAsync( - this.processExitCancellationTokenSource.Token); - receiverMessageTask.Wait(); - message = receiverMessageTask.Result; + HostProcessId = -1, + ErrorMessage = null + }; - if (message == null) - { - throw new TransationLayerException( - TranslationLayerResources.FailedToReceiveMessage); - } + try + { + var testProcessStartInfo = _dataSerializer + .DeserializePayload(message); - return message; + ackPayload.HostProcessId = customHostLauncher != null + ? customHostLauncher.LaunchTestHost(testProcessStartInfo) + : -1; } - - private async Task TryReceiveMessageAsync() + catch (Exception ex) { - Message message = await this.communicationManager.ReceiveMessageAsync( - this.processExitCancellationTokenSource.Token).ConfigureAwait(false); + EqtTrace.Error("Error while launching custom host: {0}", ex); - if (message == null) - { - throw new TransationLayerException( - TranslationLayerResources.FailedToReceiveMessage); - } - - return message; + // Vstest.console will send the abort message properly while cleaning up all the + // flow, so do not abort here. + // Let the ack go through and let vstest.console handle the error. + ackPayload.ErrorMessage = ex.Message; } - - private void HandleCustomHostLaunch(ITestHostLauncher customHostLauncher, Message message) + finally { - var ackPayload = new CustomHostLaunchAckPayload() - { - HostProcessId = -1, - ErrorMessage = null - }; - - try - { - var testProcessStartInfo = this.dataSerializer - .DeserializePayload(message); - - ackPayload.HostProcessId = customHostLauncher != null - ? customHostLauncher.LaunchTestHost(testProcessStartInfo) - : -1; - } - catch (Exception ex) - { - EqtTrace.Error("Error while launching custom host: {0}", ex); - - // Vstest.console will send the abort message properly while cleaning up all the - // flow, so do not abort here. - // Let the ack go through and let vstest.console handle the error. - ackPayload.ErrorMessage = ex.Message; - } - finally - { - // Always unblock the vstest.console thread which is indefinitely waiting on this - // ACK. - this.communicationManager.SendMessage( - MessageType.CustomTestHostLaunchCallback, - ackPayload, - this.protocolVersion); - } + // Always unblock the vstest.console thread which is indefinitely waiting on this + // ACK. + _communicationManager.SendMessage( + MessageType.CustomTestHostLaunchCallback, + ackPayload, + _protocolVersion); } + } - private void AttachDebuggerToProcess(ITestHostLauncher customHostLauncher, Message message) + private void AttachDebuggerToProcess(ITestHostLauncher customHostLauncher, Message message) + { + var ackPayload = new EditorAttachDebuggerAckPayload() { - var ackPayload = new EditorAttachDebuggerAckPayload() - { - Attached = false, - ErrorMessage = null - }; - - try - { - var pid = this.dataSerializer.DeserializePayload(message); + Attached = false, + ErrorMessage = null + }; - ackPayload.Attached = customHostLauncher is ITestHostLauncher2 launcher - && launcher.AttachDebuggerToProcess(pid); - } - catch (Exception ex) - { - EqtTrace.Error( - "VsTestConsoleRequestSender.AttachDebuggerToProcess: Error while attaching debugger to process: {0}", - ex); + try + { + var pid = _dataSerializer.DeserializePayload(message); - // vstest.console will send the abort message properly while cleaning up all the - // flow, so do not abort here. - // Let the ack go through and let vstest.console handle the error. - ackPayload.ErrorMessage = ex.Message; - } - finally - { - // Always unblock the vstest.console thread which is indefintitely waiting on this - // ACK. - this.communicationManager.SendMessage( - MessageType.EditorAttachDebuggerCallback, - ackPayload, - this.protocolVersion); - } + ackPayload.Attached = customHostLauncher is ITestHostLauncher2 launcher + && launcher.AttachDebuggerToProcess(pid); + } + catch (Exception ex) + { + EqtTrace.Error( + "VsTestConsoleRequestSender.AttachDebuggerToProcess: Error while attaching debugger to process: {0}", + ex); + + // vstest.console will send the abort message properly while cleaning up all the + // flow, so do not abort here. + // Let the ack go through and let vstest.console handle the error. + ackPayload.ErrorMessage = ex.Message; + } + finally + { + // Always unblock the vstest.console thread which is indefintitely waiting on this + // ACK. + _communicationManager.SendMessage( + MessageType.EditorAttachDebuggerCallback, + ackPayload, + _protocolVersion); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleWrapper.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleWrapper.cs index 7911508244..d5a7ed5cd3 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleWrapper.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleWrapper.cs @@ -1,1027 +1,1027 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer +namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +using Interfaces; + +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; + +using CommunicationUtilitiesResources = VisualStudio.TestPlatform.CommunicationUtilities.Resources.Resources; +using CoreUtilitiesConstants = VisualStudio.TestPlatform.CoreUtilities.Constants; + +/// +/// An implementation of to invoke test operations +/// via the vstest.console test runner. +/// +public class VsTestConsoleWrapper : IVsTestConsoleWrapper { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Globalization; - using System.Linq; - using System.Threading; - using System.Threading.Tasks; - - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - - using CommunicationUtilitiesResources = Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources.Resources; - using CoreUtilitiesConstants = Microsoft.VisualStudio.TestPlatform.CoreUtilities.Constants; + #region Private Members - /// - /// An implementation of to invoke test operations - /// via the vstest.console test runner. - /// - public class VsTestConsoleWrapper : IVsTestConsoleWrapper - { - #region Private Members + private readonly IProcessManager _vstestConsoleProcessManager; - private readonly IProcessManager vstestConsoleProcessManager; + private readonly ITranslationLayerRequestSender _requestSender; - private readonly ITranslationLayerRequestSender requestSender; + private readonly IProcessHelper _processHelper; - private readonly IProcessHelper processHelper; + private bool _sessionStarted; - private bool sessionStarted; - - /// - /// Path to additional extensions to reinitialize vstest.console - /// - private IEnumerable pathToAdditionalExtensions; + /// + /// Path to additional extensions to reinitialize vstest.console + /// + private IEnumerable _pathToAdditionalExtensions; - /// - /// Additional parameters for vstest.console.exe - /// - private readonly ConsoleParameters consoleParameters; + /// + /// Additional parameters for vstest.console.exe + /// + private readonly ConsoleParameters _consoleParameters; - private readonly ITestPlatformEventSource testPlatformEventSource; + private readonly ITestPlatformEventSource _testPlatformEventSource; - #endregion + #endregion - #region Constructor + #region Constructor - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// Path to the test runner vstest.console.exe. - /// - public VsTestConsoleWrapper( - string vstestConsolePath) - : this( - vstestConsolePath, - ConsoleParameters.Default) - { - } + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// Path to the test runner vstest.console.exe. + /// + public VsTestConsoleWrapper( + string vstestConsolePath) + : this( + vstestConsolePath, + ConsoleParameters.Default) + { + } - /// - /// Initializes a new instance of the class. - /// - /// - /// Path to the test runner vstest.console.exe. - /// The parameters to be passed onto the runner process. - public VsTestConsoleWrapper( - string vstestConsolePath, - ConsoleParameters consoleParameters) - : this( - new VsTestConsoleRequestSender(), - new VsTestConsoleProcessManager(vstestConsolePath), - consoleParameters, - TestPlatformEventSource.Instance, - new ProcessHelper()) - { - } + /// + /// Initializes a new instance of the class. + /// + /// + /// Path to the test runner vstest.console.exe. + /// The parameters to be passed onto the runner process. + public VsTestConsoleWrapper( + string vstestConsolePath, + ConsoleParameters consoleParameters) + : this( + new VsTestConsoleRequestSender(), + new VsTestConsoleProcessManager(vstestConsolePath), + consoleParameters, + TestPlatformEventSource.Instance, + new ProcessHelper()) + { + } - /// - /// Initializes a new instance of the class. - /// - /// - /// Defined for testing purposes. - /// - /// Path to the test runner vstest.console.exe. - /// Path to dotnet exe, needed for CI builds. - /// The parameters to be passed onto the runner process. - internal VsTestConsoleWrapper( - string vstestConsolePath, - string dotnetExePath, - ConsoleParameters consoleParameters) - : this( - new VsTestConsoleRequestSender(), - new VsTestConsoleProcessManager(vstestConsolePath, dotnetExePath), - consoleParameters, - TestPlatformEventSource.Instance, - new ProcessHelper()) - { - } + /// + /// Initializes a new instance of the class. + /// + /// + /// Defined for testing purposes. + /// + /// Path to the test runner vstest.console.exe. + /// Path to dotnet exe, needed for CI builds. + /// The parameters to be passed onto the runner process. + internal VsTestConsoleWrapper( + string vstestConsolePath, + string dotnetExePath, + ConsoleParameters consoleParameters) + : this( + new VsTestConsoleRequestSender(), + new VsTestConsoleProcessManager(vstestConsolePath, dotnetExePath), + consoleParameters, + TestPlatformEventSource.Instance, + new ProcessHelper()) + { + } - /// - /// Initializes a new instance of the class. - /// - /// - /// Sender for test messages. - /// Process manager. - /// The parameters to be passed onto the runner process. - /// Performance event source. - /// Helper for process related utilities. - internal VsTestConsoleWrapper( - ITranslationLayerRequestSender requestSender, - IProcessManager processManager, - ConsoleParameters consoleParameters, - ITestPlatformEventSource testPlatformEventSource, - IProcessHelper processHelper) - { - this.requestSender = requestSender; - this.vstestConsoleProcessManager = processManager; - this.consoleParameters = consoleParameters; - this.testPlatformEventSource = testPlatformEventSource; - this.processHelper = processHelper; - this.pathToAdditionalExtensions = new List(); - - this.vstestConsoleProcessManager.ProcessExited += (sender, args) => this.requestSender.OnProcessExited(); - this.sessionStarted = false; - } + /// + /// Initializes a new instance of the class. + /// + /// + /// Sender for test messages. + /// Process manager. + /// The parameters to be passed onto the runner process. + /// Performance event source. + /// Helper for process related utilities. + internal VsTestConsoleWrapper( + ITranslationLayerRequestSender requestSender, + IProcessManager processManager, + ConsoleParameters consoleParameters, + ITestPlatformEventSource testPlatformEventSource, + IProcessHelper processHelper) + { + _requestSender = requestSender; + _vstestConsoleProcessManager = processManager; + _consoleParameters = consoleParameters; + _testPlatformEventSource = testPlatformEventSource; + _processHelper = processHelper; + _pathToAdditionalExtensions = new List(); + + _vstestConsoleProcessManager.ProcessExited += (sender, args) => _requestSender.OnProcessExited(); + _sessionStarted = false; + } - #endregion + #endregion - #region IVsTestConsoleWrapper + #region IVsTestConsoleWrapper - /// - public void StartSession() + /// + public void StartSession() + { + if (EqtTrace.IsInfoEnabled) { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("VsTestConsoleWrapper.StartSession: Starting VsTestConsoleWrapper session."); - } + EqtTrace.Info("VsTestConsoleWrapper.StartSession: Starting VsTestConsoleWrapper session."); + } - this.testPlatformEventSource.TranslationLayerInitializeStart(); + _testPlatformEventSource.TranslationLayerInitializeStart(); - // Start communication - var port = this.requestSender.InitializeCommunication(); + // Start communication + var port = _requestSender.InitializeCommunication(); - if (port > 0) - { - // Fill the parameters - this.consoleParameters.ParentProcessId = Process.GetCurrentProcess().Id; - this.consoleParameters.PortNumber = port; + if (port > 0) + { + // Fill the parameters + _consoleParameters.ParentProcessId = Process.GetCurrentProcess().Id; + _consoleParameters.PortNumber = port; - // Start vstest.console.exe process - this.vstestConsoleProcessManager.StartProcess(this.consoleParameters); - } - else - { - // Close the sender as it failed to host server - this.requestSender.Close(); - throw new TransationLayerException("Error hosting communication channel"); - } + // Start vstest.console.exe process + _vstestConsoleProcessManager.StartProcess(_consoleParameters); } - - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public ITestSession StartTestSession( - IList sources, - string runSettings, - ITestSessionEventsHandler eventsHandler) + else { - return this.StartTestSession( - sources, - runSettings, - options: null, - eventsHandler); + // Close the sender as it failed to host server + _requestSender.Close(); + throw new TransationLayerException("Error hosting communication channel"); } + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public ITestSession StartTestSession( - IList sources, - string runSettings, - TestPlatformOptions options, - ITestSessionEventsHandler eventsHandler) - { - return this.StartTestSession( - sources, - runSettings, - options, - eventsHandler, - testHostLauncher: null); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public ITestSession StartTestSession( + IList sources, + string runSettings, + ITestSessionEventsHandler eventsHandler) + { + return StartTestSession( + sources, + runSettings, + options: null, + eventsHandler); + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public ITestSession StartTestSession( - IList sources, - string runSettings, - TestPlatformOptions options, - ITestSessionEventsHandler eventsHandler, - ITestHostLauncher testHostLauncher) - { - this.testPlatformEventSource.TranslationLayerStartTestSessionStart(); + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public ITestSession StartTestSession( + IList sources, + string runSettings, + TestPlatformOptions options, + ITestSessionEventsHandler eventsHandler) + { + return StartTestSession( + sources, + runSettings, + options, + eventsHandler, + testHostLauncher: null); + } - this.EnsureInitialized(); + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public ITestSession StartTestSession( + IList sources, + string runSettings, + TestPlatformOptions options, + ITestSessionEventsHandler eventsHandler, + ITestHostLauncher testHostLauncher) + { + _testPlatformEventSource.TranslationLayerStartTestSessionStart(); - var testSessionInfo = this.requestSender.StartTestSession( - sources, - runSettings, - options, - eventsHandler, - testHostLauncher); - - return (testSessionInfo != null) - ? new TestSession( - testSessionInfo, - eventsHandler, - this) - : null; - } + EnsureInitialized(); - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public bool StopTestSession( - TestSessionInfo testSessionInfo, - ITestSessionEventsHandler eventsHandler) - { - this.testPlatformEventSource.TranslationLayerStopTestSessionStart(); + var testSessionInfo = _requestSender.StartTestSession( + sources, + runSettings, + options, + eventsHandler, + testHostLauncher); - this.EnsureInitialized(); - return this.requestSender.StopTestSession( + return (testSessionInfo != null) + ? new TestSession( testSessionInfo, - eventsHandler); - } - - /// - public void InitializeExtensions(IEnumerable pathToAdditionalExtensions) - { - this.EnsureInitialized(); + eventsHandler, + this) + : null; + } - this.pathToAdditionalExtensions = pathToAdditionalExtensions.ToList(); - this.requestSender.InitializeExtensions(this.pathToAdditionalExtensions); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public bool StopTestSession( + TestSessionInfo testSessionInfo, + ITestSessionEventsHandler eventsHandler) + { + _testPlatformEventSource.TranslationLayerStopTestSessionStart(); - /// - public void DiscoverTests( - IEnumerable sources, - string discoverySettings, - ITestDiscoveryEventsHandler discoveryEventsHandler) - { - this.DiscoverTests( - sources, - discoverySettings, - options: null, - discoveryEventsHandler: new DiscoveryEventsHandleConverter(discoveryEventsHandler)); - } + EnsureInitialized(); + return _requestSender.StopTestSession( + testSessionInfo, + eventsHandler); + } - /// - public void DiscoverTests( - IEnumerable sources, - string discoverySettings, - TestPlatformOptions options, - ITestDiscoveryEventsHandler2 discoveryEventsHandler) - { - this.DiscoverTests( - sources, - discoverySettings, - options, - testSessionInfo: null, - discoveryEventsHandler); - } + /// + public void InitializeExtensions(IEnumerable pathToAdditionalExtensions) + { + EnsureInitialized(); - /// - public void DiscoverTests( - IEnumerable sources, - string discoverySettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestDiscoveryEventsHandler2 discoveryEventsHandler) - { - this.testPlatformEventSource.TranslationLayerDiscoveryStart(); + _pathToAdditionalExtensions = pathToAdditionalExtensions.ToList(); + _requestSender.InitializeExtensions(_pathToAdditionalExtensions); + } - this.EnsureInitialized(); - this.requestSender.DiscoverTests( - sources, - discoverySettings, - options, - testSessionInfo, - discoveryEventsHandler); - } + /// + public void DiscoverTests( + IEnumerable sources, + string discoverySettings, + ITestDiscoveryEventsHandler discoveryEventsHandler) + { + DiscoverTests( + sources, + discoverySettings, + options: null, + discoveryEventsHandler: new DiscoveryEventsHandleConverter(discoveryEventsHandler)); + } - /// - public void CancelDiscovery() - { - this.requestSender.CancelDiscovery(); - } + /// + public void DiscoverTests( + IEnumerable sources, + string discoverySettings, + TestPlatformOptions options, + ITestDiscoveryEventsHandler2 discoveryEventsHandler) + { + DiscoverTests( + sources, + discoverySettings, + options, + testSessionInfo: null, + discoveryEventsHandler); + } - /// - public void RunTests( - IEnumerable sources, - string runSettings, - ITestRunEventsHandler testRunEventsHandler) - { - this.RunTests( - sources, - runSettings, - options: null, - testRunEventsHandler: testRunEventsHandler); - } + /// + public void DiscoverTests( + IEnumerable sources, + string discoverySettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestDiscoveryEventsHandler2 discoveryEventsHandler) + { + _testPlatformEventSource.TranslationLayerDiscoveryStart(); + + EnsureInitialized(); + _requestSender.DiscoverTests( + sources, + discoverySettings, + options, + testSessionInfo, + discoveryEventsHandler); + } - /// - public void RunTests( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler) - { - this.RunTests( - sources, - runSettings, - options, - testSessionInfo: null, - testRunEventsHandler); - } + /// + public void CancelDiscovery() + { + _requestSender.CancelDiscovery(); + } - /// - public void RunTests( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler testRunEventsHandler) - { - var sourceList = sources.ToList(); - this.testPlatformEventSource.TranslationLayerExecutionStart( - 0, - sourceList.Count, - 0, - runSettings ?? string.Empty); - - this.EnsureInitialized(); - this.requestSender.StartTestRun( - sourceList, - runSettings, - options, - testSessionInfo, - testRunEventsHandler); - } + /// + public void RunTests( + IEnumerable sources, + string runSettings, + ITestRunEventsHandler testRunEventsHandler) + { + RunTests( + sources, + runSettings, + options: null, + testRunEventsHandler: testRunEventsHandler); + } - /// - public void RunTests( - IEnumerable testCases, - string runSettings, - ITestRunEventsHandler testRunEventsHandler) - { - this.RunTests( - testCases, - runSettings, - options: null, - testRunEventsHandler); - } + /// + public void RunTests( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler) + { + RunTests( + sources, + runSettings, + options, + testSessionInfo: null, + testRunEventsHandler); + } - /// - public void RunTests( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler) - { - this.RunTests( - testCases, - runSettings, - options, - testSessionInfo: null, - testRunEventsHandler); - } + /// + public void RunTests( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler testRunEventsHandler) + { + var sourceList = sources.ToList(); + _testPlatformEventSource.TranslationLayerExecutionStart( + 0, + sourceList.Count, + 0, + runSettings ?? string.Empty); + + EnsureInitialized(); + _requestSender.StartTestRun( + sourceList, + runSettings, + options, + testSessionInfo, + testRunEventsHandler); + } - /// - public void RunTests( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler testRunEventsHandler) - { - var testCaseList = testCases.ToList(); - this.testPlatformEventSource.TranslationLayerExecutionStart( - 0, - 0, - testCaseList.Count, - runSettings ?? string.Empty); - - this.EnsureInitialized(); - this.requestSender.StartTestRun( - testCaseList, - runSettings, - options, - testSessionInfo, - testRunEventsHandler); - } + /// + public void RunTests( + IEnumerable testCases, + string runSettings, + ITestRunEventsHandler testRunEventsHandler) + { + RunTests( + testCases, + runSettings, + options: null, + testRunEventsHandler); + } - /// - public void RunTestsWithCustomTestHost( - IEnumerable sources, - string runSettings, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) - { - this.RunTestsWithCustomTestHost( - sources, - runSettings, - options: null, - testRunEventsHandler: testRunEventsHandler, - customTestHostLauncher: customTestHostLauncher); - } + /// + public void RunTests( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler) + { + RunTests( + testCases, + runSettings, + options, + testSessionInfo: null, + testRunEventsHandler); + } - /// - public void RunTestsWithCustomTestHost( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) - { - this.RunTestsWithCustomTestHost( - sources, - runSettings, - options, - testSessionInfo: null, - testRunEventsHandler, - customTestHostLauncher); - } + /// + public void RunTests( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler testRunEventsHandler) + { + var testCaseList = testCases.ToList(); + _testPlatformEventSource.TranslationLayerExecutionStart( + 0, + 0, + testCaseList.Count, + runSettings ?? string.Empty); + + EnsureInitialized(); + _requestSender.StartTestRun( + testCaseList, + runSettings, + options, + testSessionInfo, + testRunEventsHandler); + } - /// - public void RunTestsWithCustomTestHost( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) - { - var sourceList = sources.ToList(); - this.testPlatformEventSource.TranslationLayerExecutionStart( - 1, - sourceList.Count, - 0, - runSettings ?? string.Empty); - - this.EnsureInitialized(); - this.requestSender.StartTestRunWithCustomHost( - sourceList, - runSettings, - options, - testSessionInfo, - testRunEventsHandler, - customTestHostLauncher); - } + /// + public void RunTestsWithCustomTestHost( + IEnumerable sources, + string runSettings, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + RunTestsWithCustomTestHost( + sources, + runSettings, + options: null, + testRunEventsHandler: testRunEventsHandler, + customTestHostLauncher: customTestHostLauncher); + } - /// - public void RunTestsWithCustomTestHost( - IEnumerable testCases, - string runSettings, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) - { - this.RunTestsWithCustomTestHost( - testCases, - runSettings, - options: null, - testRunEventsHandler, - customTestHostLauncher); - } + /// + public void RunTestsWithCustomTestHost( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + RunTestsWithCustomTestHost( + sources, + runSettings, + options, + testSessionInfo: null, + testRunEventsHandler, + customTestHostLauncher); + } - /// - public void RunTestsWithCustomTestHost( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) - { - this.RunTestsWithCustomTestHost( - testCases, - runSettings, - options, - testSessionInfo: null, - testRunEventsHandler, - customTestHostLauncher); - } + /// + public void RunTestsWithCustomTestHost( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + var sourceList = sources.ToList(); + _testPlatformEventSource.TranslationLayerExecutionStart( + 1, + sourceList.Count, + 0, + runSettings ?? string.Empty); + + EnsureInitialized(); + _requestSender.StartTestRunWithCustomHost( + sourceList, + runSettings, + options, + testSessionInfo, + testRunEventsHandler, + customTestHostLauncher); + } - /// - public void RunTestsWithCustomTestHost( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) - { - var testCaseList = testCases.ToList(); - this.testPlatformEventSource.TranslationLayerExecutionStart( - 1, - 0, - testCaseList.Count, - runSettings ?? string.Empty); - - this.EnsureInitialized(); - this.requestSender.StartTestRunWithCustomHost( - testCaseList, - runSettings, - options, - testSessionInfo, - testRunEventsHandler, - customTestHostLauncher); - } + /// + public void RunTestsWithCustomTestHost( + IEnumerable testCases, + string runSettings, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + RunTestsWithCustomTestHost( + testCases, + runSettings, + options: null, + testRunEventsHandler, + customTestHostLauncher); + } - /// - public void CancelTestRun() - { - this.requestSender.CancelTestRun(); - } + /// + public void RunTestsWithCustomTestHost( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + RunTestsWithCustomTestHost( + testCases, + runSettings, + options, + testSessionInfo: null, + testRunEventsHandler, + customTestHostLauncher); + } - /// - public void AbortTestRun() - { - this.requestSender.AbortTestRun(); - } + /// + public void RunTestsWithCustomTestHost( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + var testCaseList = testCases.ToList(); + _testPlatformEventSource.TranslationLayerExecutionStart( + 1, + 0, + testCaseList.Count, + runSettings ?? string.Empty); + + EnsureInitialized(); + _requestSender.StartTestRunWithCustomHost( + testCaseList, + runSettings, + options, + testSessionInfo, + testRunEventsHandler, + customTestHostLauncher); + } - /// - public void EndSession() - { - EqtTrace.Info("VsTestConsoleWrapper.EndSession: Ending VsTestConsoleWrapper session"); + /// + public void CancelTestRun() + { + _requestSender.CancelTestRun(); + } - this.requestSender.EndSession(); - this.requestSender.Close(); + /// + public void AbortTestRun() + { + _requestSender.AbortTestRun(); + } - // If vstest.console is still hanging around, it should be explicitly killed. - this.vstestConsoleProcessManager.ShutdownProcess(); + /// + public void EndSession() + { + EqtTrace.Info("VsTestConsoleWrapper.EndSession: Ending VsTestConsoleWrapper session"); - this.sessionStarted = false; - } + _requestSender.EndSession(); + _requestSender.Close(); - #endregion + // If vstest.console is still hanging around, it should be explicitly killed. + _vstestConsoleProcessManager.ShutdownProcess(); - #region IVsTestConsoleWrapperAsync + _sessionStarted = false; + } - /// - public async Task StartSessionAsync() - { - EqtTrace.Info("VsTestConsoleWrapperAsync.StartSessionAsync: Starting VsTestConsoleWrapper session"); + #endregion - this.testPlatformEventSource.TranslationLayerInitializeStart(); + #region IVsTestConsoleWrapperAsync - var timeout = EnvironmentHelper.GetConnectionTimeout(); - // Start communication - var port = await this.requestSender.InitializeCommunicationAsync(timeout * 1000).ConfigureAwait(false); + /// + public async Task StartSessionAsync() + { + EqtTrace.Info("VsTestConsoleWrapperAsync.StartSessionAsync: Starting VsTestConsoleWrapper session"); - if (port > 0) - { - // Fill the parameters - this.consoleParameters.ParentProcessId = Process.GetCurrentProcess().Id; - this.consoleParameters.PortNumber = port; + _testPlatformEventSource.TranslationLayerInitializeStart(); - // Start vstest.console.exe process - this.vstestConsoleProcessManager.StartProcess(this.consoleParameters); - } - else - { - // Close the sender as it failed to host server - this.requestSender.Close(); - throw new TransationLayerException("Error hosting communication channel and connecting to console"); - } - } + var timeout = EnvironmentHelper.GetConnectionTimeout(); + // Start communication + var port = await _requestSender.InitializeCommunicationAsync(timeout * 1000).ConfigureAwait(false); - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task StartTestSessionAsync( - IList sources, - string runSettings, - ITestSessionEventsHandler eventsHandler) + if (port > 0) { - return await this.StartTestSessionAsync( - sources, - runSettings, - options: null, - eventsHandler).ConfigureAwait(false); - } + // Fill the parameters + _consoleParameters.ParentProcessId = Process.GetCurrentProcess().Id; + _consoleParameters.PortNumber = port; - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task StartTestSessionAsync( - IList sources, - string runSettings, - TestPlatformOptions options, - ITestSessionEventsHandler eventsHandler) + // Start vstest.console.exe process + _vstestConsoleProcessManager.StartProcess(_consoleParameters); + } + else { - return await this.StartTestSessionAsync( - sources, - runSettings, - options, - eventsHandler, - testHostLauncher: null).ConfigureAwait(false); + // Close the sender as it failed to host server + _requestSender.Close(); + throw new TransationLayerException("Error hosting communication channel and connecting to console"); } + } - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task StartTestSessionAsync( - IList sources, - string runSettings, - TestPlatformOptions options, - ITestSessionEventsHandler eventsHandler, - ITestHostLauncher testHostLauncher) - { - this.testPlatformEventSource.TranslationLayerStartTestSessionStart(); + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task StartTestSessionAsync( + IList sources, + string runSettings, + ITestSessionEventsHandler eventsHandler) + { + return await StartTestSessionAsync( + sources, + runSettings, + options: null, + eventsHandler).ConfigureAwait(false); + } - await this.EnsureInitializedAsync().ConfigureAwait(false); + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task StartTestSessionAsync( + IList sources, + string runSettings, + TestPlatformOptions options, + ITestSessionEventsHandler eventsHandler) + { + return await StartTestSessionAsync( + sources, + runSettings, + options, + eventsHandler, + testHostLauncher: null).ConfigureAwait(false); + } - var testSessionInfo = await this.requestSender.StartTestSessionAsync( - sources, - runSettings, - options, - eventsHandler, - testHostLauncher).ConfigureAwait(false); - - return (testSessionInfo != null) - ? new TestSession( - testSessionInfo, - eventsHandler, - this) - : null; - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task StartTestSessionAsync( + IList sources, + string runSettings, + TestPlatformOptions options, + ITestSessionEventsHandler eventsHandler, + ITestHostLauncher testHostLauncher) + { + _testPlatformEventSource.TranslationLayerStartTestSessionStart(); - /// - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task StopTestSessionAsync( - TestSessionInfo testSessionInfo, - ITestSessionEventsHandler eventsHandler) - { - this.testPlatformEventSource.TranslationLayerStopTestSessionStart(); + await EnsureInitializedAsync().ConfigureAwait(false); + + var testSessionInfo = await _requestSender.StartTestSessionAsync( + sources, + runSettings, + options, + eventsHandler, + testHostLauncher).ConfigureAwait(false); - await this.EnsureInitializedAsync().ConfigureAwait(false); - return await this.requestSender.StopTestSessionAsync( + return (testSessionInfo != null) + ? new TestSession( testSessionInfo, - eventsHandler).ConfigureAwait(false); - } + eventsHandler, + this) + : null; + } - /// - public async Task InitializeExtensionsAsync(IEnumerable pathToAdditionalExtensions) - { - await this.EnsureInitializedAsync().ConfigureAwait(false); - this.pathToAdditionalExtensions = pathToAdditionalExtensions.ToList(); - this.requestSender.InitializeExtensions(this.pathToAdditionalExtensions); - } + /// + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task StopTestSessionAsync( + TestSessionInfo testSessionInfo, + ITestSessionEventsHandler eventsHandler) + { + _testPlatformEventSource.TranslationLayerStopTestSessionStart(); - /// - public async Task DiscoverTestsAsync( - IEnumerable sources, - string discoverySettings, - ITestDiscoveryEventsHandler discoveryEventsHandler) - { - await this.DiscoverTestsAsync( - sources, - discoverySettings, - options: null, - discoveryEventsHandler: new DiscoveryEventsHandleConverter(discoveryEventsHandler)) - .ConfigureAwait(false); - } + await EnsureInitializedAsync().ConfigureAwait(false); + return await _requestSender.StopTestSessionAsync( + testSessionInfo, + eventsHandler).ConfigureAwait(false); + } - /// - public async Task DiscoverTestsAsync( - IEnumerable sources, - string discoverySettings, - TestPlatformOptions options, - ITestDiscoveryEventsHandler2 discoveryEventsHandler) - { - await this.DiscoverTestsAsync( + /// + public async Task InitializeExtensionsAsync(IEnumerable pathToAdditionalExtensions) + { + await EnsureInitializedAsync().ConfigureAwait(false); + _pathToAdditionalExtensions = pathToAdditionalExtensions.ToList(); + _requestSender.InitializeExtensions(_pathToAdditionalExtensions); + } + + /// + public async Task DiscoverTestsAsync( + IEnumerable sources, + string discoverySettings, + ITestDiscoveryEventsHandler discoveryEventsHandler) + { + await DiscoverTestsAsync( sources, discoverySettings, - options, - testSessionInfo: null, - discoveryEventsHandler).ConfigureAwait(false); - } + options: null, + discoveryEventsHandler: new DiscoveryEventsHandleConverter(discoveryEventsHandler)) + .ConfigureAwait(false); + } - /// - public async Task DiscoverTestsAsync( - IEnumerable sources, - string discoverySettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestDiscoveryEventsHandler2 discoveryEventsHandler) - { - this.testPlatformEventSource.TranslationLayerDiscoveryStart(); + /// + public async Task DiscoverTestsAsync( + IEnumerable sources, + string discoverySettings, + TestPlatformOptions options, + ITestDiscoveryEventsHandler2 discoveryEventsHandler) + { + await DiscoverTestsAsync( + sources, + discoverySettings, + options, + testSessionInfo: null, + discoveryEventsHandler).ConfigureAwait(false); + } - await this.EnsureInitializedAsync().ConfigureAwait(false); - await this.requestSender.DiscoverTestsAsync( - sources, - discoverySettings, - options, - testSessionInfo, - discoveryEventsHandler).ConfigureAwait(false); - } + /// + public async Task DiscoverTestsAsync( + IEnumerable sources, + string discoverySettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestDiscoveryEventsHandler2 discoveryEventsHandler) + { + _testPlatformEventSource.TranslationLayerDiscoveryStart(); + + await EnsureInitializedAsync().ConfigureAwait(false); + await _requestSender.DiscoverTestsAsync( + sources, + discoverySettings, + options, + testSessionInfo, + discoveryEventsHandler).ConfigureAwait(false); + } - /// - public async Task RunTestsAsync( - IEnumerable sources, - string runSettings, - ITestRunEventsHandler testRunEventsHandler) - { - await this.RunTestsAsync( - sources, - runSettings, - options: null, - testRunEventsHandler).ConfigureAwait(false); - } + /// + public async Task RunTestsAsync( + IEnumerable sources, + string runSettings, + ITestRunEventsHandler testRunEventsHandler) + { + await RunTestsAsync( + sources, + runSettings, + options: null, + testRunEventsHandler).ConfigureAwait(false); + } - /// - public async Task RunTestsAsync( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler) - { - await this.RunTestsAsync( - sources, - runSettings, - options, - testSessionInfo: null, - testRunEventsHandler).ConfigureAwait(false); - } + /// + public async Task RunTestsAsync( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler) + { + await RunTestsAsync( + sources, + runSettings, + options, + testSessionInfo: null, + testRunEventsHandler).ConfigureAwait(false); + } - /// - public async Task RunTestsAsync( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler testRunEventsHandler) - { - var sourceList = sources.ToList(); - this.testPlatformEventSource.TranslationLayerExecutionStart( - 0, - sourceList.Count, - 0, - runSettings ?? string.Empty); - - await this.EnsureInitializedAsync().ConfigureAwait(false); - await this.requestSender.StartTestRunAsync( - sourceList, - runSettings, - options, - testSessionInfo, - testRunEventsHandler).ConfigureAwait(false); - } + /// + public async Task RunTestsAsync( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler testRunEventsHandler) + { + var sourceList = sources.ToList(); + _testPlatformEventSource.TranslationLayerExecutionStart( + 0, + sourceList.Count, + 0, + runSettings ?? string.Empty); + + await EnsureInitializedAsync().ConfigureAwait(false); + await _requestSender.StartTestRunAsync( + sourceList, + runSettings, + options, + testSessionInfo, + testRunEventsHandler).ConfigureAwait(false); + } - /// - public async Task RunTestsAsync( - IEnumerable testCases, - string runSettings, - ITestRunEventsHandler testRunEventsHandler) - { - await this.RunTestsAsync( - testCases, - runSettings, - options: null, - testRunEventsHandler).ConfigureAwait(false); - } + /// + public async Task RunTestsAsync( + IEnumerable testCases, + string runSettings, + ITestRunEventsHandler testRunEventsHandler) + { + await RunTestsAsync( + testCases, + runSettings, + options: null, + testRunEventsHandler).ConfigureAwait(false); + } - /// - public async Task RunTestsAsync( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler) - { - await this.RunTestsAsync( - testCases, - runSettings, - options, - testSessionInfo: null, - testRunEventsHandler).ConfigureAwait(false); - } + /// + public async Task RunTestsAsync( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler) + { + await RunTestsAsync( + testCases, + runSettings, + options, + testSessionInfo: null, + testRunEventsHandler).ConfigureAwait(false); + } - /// - public async Task RunTestsAsync( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler testRunEventsHandler) - { - var testCaseList = testCases.ToList(); - this.testPlatformEventSource.TranslationLayerExecutionStart( - 0, - 0, - testCaseList.Count, - runSettings ?? string.Empty); - - await this.EnsureInitializedAsync().ConfigureAwait(false); - await this.requestSender.StartTestRunAsync( - testCaseList, - runSettings, - options, - testSessionInfo, - testRunEventsHandler).ConfigureAwait(false); - } + /// + public async Task RunTestsAsync( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler testRunEventsHandler) + { + var testCaseList = testCases.ToList(); + _testPlatformEventSource.TranslationLayerExecutionStart( + 0, + 0, + testCaseList.Count, + runSettings ?? string.Empty); + + await EnsureInitializedAsync().ConfigureAwait(false); + await _requestSender.StartTestRunAsync( + testCaseList, + runSettings, + options, + testSessionInfo, + testRunEventsHandler).ConfigureAwait(false); + } - /// - public async Task RunTestsWithCustomTestHostAsync( - IEnumerable sources, - string runSettings, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) - { - await this.RunTestsWithCustomTestHostAsync( - sources, - runSettings, - options: null, - testRunEventsHandler, - customTestHostLauncher).ConfigureAwait(false); - } + /// + public async Task RunTestsWithCustomTestHostAsync( + IEnumerable sources, + string runSettings, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + await RunTestsWithCustomTestHostAsync( + sources, + runSettings, + options: null, + testRunEventsHandler, + customTestHostLauncher).ConfigureAwait(false); + } - /// - public async Task RunTestsWithCustomTestHostAsync( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) - { - await this.RunTestsWithCustomTestHostAsync( - sources, - runSettings, - options, - testSessionInfo: null, - testRunEventsHandler, - customTestHostLauncher).ConfigureAwait(false); - } + /// + public async Task RunTestsWithCustomTestHostAsync( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + await RunTestsWithCustomTestHostAsync( + sources, + runSettings, + options, + testSessionInfo: null, + testRunEventsHandler, + customTestHostLauncher).ConfigureAwait(false); + } - /// - public async Task RunTestsWithCustomTestHostAsync( - IEnumerable sources, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) - { - var sourceList = sources.ToList(); - this.testPlatformEventSource.TranslationLayerExecutionStart( - 1, - sourceList.Count, - 0, - runSettings ?? string.Empty); - - await this.EnsureInitializedAsync().ConfigureAwait(false); - await this.requestSender.StartTestRunWithCustomHostAsync( - sourceList, - runSettings, - options, - testSessionInfo, - testRunEventsHandler, - customTestHostLauncher).ConfigureAwait(false); - } + /// + public async Task RunTestsWithCustomTestHostAsync( + IEnumerable sources, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + var sourceList = sources.ToList(); + _testPlatformEventSource.TranslationLayerExecutionStart( + 1, + sourceList.Count, + 0, + runSettings ?? string.Empty); + + await EnsureInitializedAsync().ConfigureAwait(false); + await _requestSender.StartTestRunWithCustomHostAsync( + sourceList, + runSettings, + options, + testSessionInfo, + testRunEventsHandler, + customTestHostLauncher).ConfigureAwait(false); + } - /// - public async Task RunTestsWithCustomTestHostAsync( - IEnumerable testCases, - string runSettings, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) - { - await this.RunTestsWithCustomTestHostAsync( - testCases, - runSettings, - options: null, - testRunEventsHandler, - customTestHostLauncher).ConfigureAwait(false); - } + /// + public async Task RunTestsWithCustomTestHostAsync( + IEnumerable testCases, + string runSettings, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + await RunTestsWithCustomTestHostAsync( + testCases, + runSettings, + options: null, + testRunEventsHandler, + customTestHostLauncher).ConfigureAwait(false); + } - /// - public async Task RunTestsWithCustomTestHostAsync( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) - { - await this.RunTestsWithCustomTestHostAsync( - testCases, - runSettings, - options, - testSessionInfo: null, - testRunEventsHandler, - customTestHostLauncher).ConfigureAwait(false); - } + /// + public async Task RunTestsWithCustomTestHostAsync( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + await RunTestsWithCustomTestHostAsync( + testCases, + runSettings, + options, + testSessionInfo: null, + testRunEventsHandler, + customTestHostLauncher).ConfigureAwait(false); + } - /// - public async Task RunTestsWithCustomTestHostAsync( - IEnumerable testCases, - string runSettings, - TestPlatformOptions options, - TestSessionInfo testSessionInfo, - ITestRunEventsHandler testRunEventsHandler, - ITestHostLauncher customTestHostLauncher) - { - var testCaseList = testCases.ToList(); - this.testPlatformEventSource.TranslationLayerExecutionStart( - 1, - 0, - testCaseList.Count, - runSettings ?? string.Empty); - - await this.EnsureInitializedAsync().ConfigureAwait(false); - await this.requestSender.StartTestRunWithCustomHostAsync( - testCaseList, - runSettings, - options, - testSessionInfo, - testRunEventsHandler, - customTestHostLauncher).ConfigureAwait(false); - } + /// + public async Task RunTestsWithCustomTestHostAsync( + IEnumerable testCases, + string runSettings, + TestPlatformOptions options, + TestSessionInfo testSessionInfo, + ITestRunEventsHandler testRunEventsHandler, + ITestHostLauncher customTestHostLauncher) + { + var testCaseList = testCases.ToList(); + _testPlatformEventSource.TranslationLayerExecutionStart( + 1, + 0, + testCaseList.Count, + runSettings ?? string.Empty); + + await EnsureInitializedAsync().ConfigureAwait(false); + await _requestSender.StartTestRunWithCustomHostAsync( + testCaseList, + runSettings, + options, + testSessionInfo, + testRunEventsHandler, + customTestHostLauncher).ConfigureAwait(false); + } - /// - public async Task ProcessTestRunAttachmentsAsync( - IEnumerable attachments, - IEnumerable invokedDataCollectors, - string processingSettings, - bool isLastBatch, - bool collectMetrics, - ITestRunAttachmentsProcessingEventsHandler testSessionEventsHandler, - CancellationToken cancellationToken) - { - this.testPlatformEventSource.TranslationLayerTestRunAttachmentsProcessingStart(); - - await this.EnsureInitializedAsync().ConfigureAwait(false); - await requestSender.ProcessTestRunAttachmentsAsync( - attachments, - invokedDataCollectors, - processingSettings, - collectMetrics, - testSessionEventsHandler, - cancellationToken).ConfigureAwait(false); - } + /// + public async Task ProcessTestRunAttachmentsAsync( + IEnumerable attachments, + IEnumerable invokedDataCollectors, + string processingSettings, + bool isLastBatch, + bool collectMetrics, + ITestRunAttachmentsProcessingEventsHandler testSessionEventsHandler, + CancellationToken cancellationToken) + { + _testPlatformEventSource.TranslationLayerTestRunAttachmentsProcessingStart(); + + await EnsureInitializedAsync().ConfigureAwait(false); + await _requestSender.ProcessTestRunAttachmentsAsync( + attachments, + invokedDataCollectors, + processingSettings, + collectMetrics, + testSessionEventsHandler, + cancellationToken).ConfigureAwait(false); + } - /// - public Task ProcessTestRunAttachmentsAsync( - IEnumerable attachments, - string processingSettings, - bool isLastBatch, - bool collectMetrics, - ITestRunAttachmentsProcessingEventsHandler testSessionEventsHandler, - CancellationToken cancellationToken) - => ProcessTestRunAttachmentsAsync(attachments, Enumerable.Empty(), processingSettings, isLastBatch, collectMetrics, testSessionEventsHandler, cancellationToken); + /// + public Task ProcessTestRunAttachmentsAsync( + IEnumerable attachments, + string processingSettings, + bool isLastBatch, + bool collectMetrics, + ITestRunAttachmentsProcessingEventsHandler testSessionEventsHandler, + CancellationToken cancellationToken) + => ProcessTestRunAttachmentsAsync(attachments, Enumerable.Empty(), processingSettings, isLastBatch, collectMetrics, testSessionEventsHandler, cancellationToken); - #endregion + #endregion - private void EnsureInitialized() + private void EnsureInitialized() + { + if (!_vstestConsoleProcessManager.IsProcessInitialized()) { - if (!this.vstestConsoleProcessManager.IsProcessInitialized()) - { - EqtTrace.Info("VsTestConsoleWrapper.EnsureInitialized: Process is not started."); - this.StartSession(); - this.sessionStarted = this.WaitForConnection(); - - if (this.sessionStarted) - { - EqtTrace.Info("VsTestConsoleWrapper.EnsureInitialized: Send a request to initialize extensions."); - this.requestSender.InitializeExtensions(this.pathToAdditionalExtensions); - } - } + EqtTrace.Info("VsTestConsoleWrapper.EnsureInitialized: Process is not started."); + StartSession(); + _sessionStarted = WaitForConnection(); - if (!this.sessionStarted && this.requestSender != null) + if (_sessionStarted) { - EqtTrace.Info("VsTestConsoleWrapper.EnsureInitialized: Process Started."); - this.sessionStarted = this.WaitForConnection(); + EqtTrace.Info("VsTestConsoleWrapper.EnsureInitialized: Send a request to initialize extensions."); + _requestSender.InitializeExtensions(_pathToAdditionalExtensions); } } - private async Task EnsureInitializedAsync() + if (!_sessionStarted && _requestSender != null) { - if (!this.vstestConsoleProcessManager.IsProcessInitialized()) - { - EqtTrace.Info("VsTestConsoleWrapper.EnsureInitializedAsync: Process is not started."); - await this.StartSessionAsync().ConfigureAwait(false); - - EqtTrace.Info("VsTestConsoleWrapper.EnsureInitializedAsync: Send a request to initialize extensions."); - this.requestSender.InitializeExtensions(this.pathToAdditionalExtensions); - } + EqtTrace.Info("VsTestConsoleWrapper.EnsureInitialized: Process Started."); + _sessionStarted = WaitForConnection(); } + } - private bool WaitForConnection() + private async Task EnsureInitializedAsync() + { + if (!_vstestConsoleProcessManager.IsProcessInitialized()) { - EqtTrace.Info("VsTestConsoleWrapper.WaitForConnection: Waiting for connection to command line runner."); + EqtTrace.Info("VsTestConsoleWrapper.EnsureInitializedAsync: Process is not started."); + await StartSessionAsync().ConfigureAwait(false); - var timeout = EnvironmentHelper.GetConnectionTimeout(); - if (!this.requestSender.WaitForRequestHandlerConnection(timeout * 1000)) - { - var processName = this.processHelper.GetCurrentProcessFileName(); - throw new TransationLayerException( - string.Format( - CultureInfo.CurrentUICulture, - CommunicationUtilitiesResources.ConnectionTimeoutErrorMessage, - processName, - CoreUtilitiesConstants.VstestConsoleProcessName, - timeout, - EnvironmentHelper.VstestConnectionTimeout) - ); - } + EqtTrace.Info("VsTestConsoleWrapper.EnsureInitializedAsync: Send a request to initialize extensions."); + _requestSender.InitializeExtensions(_pathToAdditionalExtensions); + } + } - this.testPlatformEventSource.TranslationLayerInitializeStop(); - return true; + private bool WaitForConnection() + { + EqtTrace.Info("VsTestConsoleWrapper.WaitForConnection: Waiting for connection to command line runner."); + + var timeout = EnvironmentHelper.GetConnectionTimeout(); + if (!_requestSender.WaitForRequestHandlerConnection(timeout * 1000)) + { + var processName = _processHelper.GetCurrentProcessFileName(); + throw new TransationLayerException( + string.Format( + CultureInfo.CurrentUICulture, + CommunicationUtilitiesResources.ConnectionTimeoutErrorMessage, + processName, + CoreUtilitiesConstants.VstestConsoleProcessName, + timeout, + EnvironmentHelper.VstestConnectionTimeout) + ); } + + _testPlatformEventSource.TranslationLayerInitializeStop(); + return true; } -} +} \ No newline at end of file diff --git a/src/SettingsMigrator/Migrator.cs b/src/SettingsMigrator/Migrator.cs index d558d52d17..755321b0b4 100644 --- a/src/SettingsMigrator/Migrator.cs +++ b/src/SettingsMigrator/Migrator.cs @@ -1,396 +1,394 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.SettingsMigrator +namespace Microsoft.VisualStudio.TestPlatform.SettingsMigrator; + +using System; +using System.Globalization; +using System.IO; +using System.Xml; + +using CommandLineResources = Resources.Resources; + +/// +/// Migrator used to migrate test settings and run settings with embedded testsettings to run settings. +/// +public class Migrator { - using System; - using System.Globalization; - using System.IO; - using System.Xml; - using CommandLineResources = Resources.Resources; + private const string TestTimeoutAttributeName = "testTimeout"; - /// - /// Migrator used to migrate test settings and run settings with embedded testsettings to run settings. - /// - public class Migrator - { - private const string TestTimeoutAttributeName = "testTimeout"; + private const string ParallelTestCountAttributeName = "parallelTestCount"; - private const string ParallelTestCountAttributeName = "parallelTestCount"; + private const string HostProcessPlatformAttributeName = "hostProcessPlatform"; - private const string HostProcessPlatformAttributeName = "hostProcessPlatform"; + private const string RunTimeoutAttributeName = "runTimeout"; - private const string RunTimeoutAttributeName = "runTimeout"; + private const string LegacySettingsNodeName = "LegacySettings"; - private const string LegacySettingsNodeName = "LegacySettings"; + private const string MSTestNodeName = "MSTest"; - private const string MSTestNodeName = "MSTest"; + private const string ForcedLegacyModeName = "ForcedLegacyMode"; - private const string ForcedLegacyModeName = "ForcedLegacyMode"; + private const string ExecutionNodeName = "Execution"; - private const string ExecutionNodeName = "Execution"; + private const string TimeoutsNodeName = "Timeouts"; - private const string TimeoutsNodeName = "Timeouts"; + private const string TestTypeSpecificNodeName = "TestTypeSpecific"; - private const string TestTypeSpecificNodeName = "TestTypeSpecific"; + private const string RunConfigurationNodeName = "RunConfiguration"; - private const string RunConfigurationNodeName = "RunConfiguration"; + private const string TestSessionTimeoutNodeName = "TestSessionTimeout"; - private const string TestSessionTimeoutNodeName = "TestSessionTimeout"; + private const string DataCollectionRunSettingsNodeName = "DataCollectionRunSettings"; - private const string DataCollectionRunSettingsNodeName = "DataCollectionRunSettings"; + private const string DataCollectorsNodeName = "DataCollectors"; - private const string DataCollectorsNodeName = "DataCollectors"; + private const string SampleRunSettingsContent = "" + + ""; - private const string SampleRunSettingsContent = "" + - ""; + private const string AgentNotRespondingTimeoutAttribute = "agentNotRespondingTimeout"; - private const string AgentNotRespondingTimeoutAttribute = "agentNotRespondingTimeout"; + private const string DeploymentTimeoutAttribute = "deploymentTimeout"; - private const string DeploymentTimeoutAttribute = "deploymentTimeout"; + private const string ScriptTimeoutAttribute = "scriptTimeout"; - private const string ScriptTimeoutAttribute = "scriptTimeout"; + private const string TestSettingsExtension = ".testsettings"; - private const string TestSettingsExtension = ".testsettings"; + private const string RunSettingsExtension = ".runsettings"; - private const string RunSettingsExtension = ".runsettings"; + /// + /// Migrates the nodes from given settings to run settings format. + /// + /// Path to old file + /// Path to new file + public void Migrate(string oldFilePath, string newFilePath) + { + if (!Path.IsPathRooted(oldFilePath)) + { + Console.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.ValidUsage)); + } - /// - /// Migrates the nodes from given settings to run settings format. - /// - /// Path to old file - /// Path to new file - public void Migrate(string oldFilePath, string newFilePath) + if (string.Equals(Path.GetExtension(oldFilePath), TestSettingsExtension, StringComparison.OrdinalIgnoreCase)) { - if (!Path.IsPathRooted(oldFilePath)) - { - Console.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.ValidUsage)); - } + MigrateTestSettings(oldFilePath, newFilePath); + } + else if (string.Equals(Path.GetExtension(oldFilePath), RunSettingsExtension, StringComparison.OrdinalIgnoreCase)) + { + MigrateRunSettings(oldFilePath, newFilePath); + } + else + { + Console.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.ValidUsage)); + } + } - if (string.Equals(Path.GetExtension(oldFilePath), TestSettingsExtension, StringComparison.OrdinalIgnoreCase)) - { - this.MigrateTestSettings(oldFilePath, newFilePath); - } - else if (string.Equals(Path.GetExtension(oldFilePath), RunSettingsExtension, StringComparison.OrdinalIgnoreCase)) - { - this.MigrateRunSettings(oldFilePath, newFilePath); - } - else - { - Console.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.ValidUsage)); - } + /// + /// Given a runSettings with an embedded testSettings, converts it to runSettings. + /// + /// Path to old runsettings. + /// Path to new runsettings. + private void MigrateRunSettings(string oldRunSettingsPath, string newRunSettingsPath) + { + string testSettingsPath = null; + using XmlTextReader reader = new(oldRunSettingsPath); + reader.Namespaces = false; + + var runSettingsXmlDoc = new XmlDocument(); + runSettingsXmlDoc.Load(reader); + var root = runSettingsXmlDoc.DocumentElement; + + var testSettingsNode = root.SelectSingleNode(@"/RunSettings/MSTest/SettingsFile"); + + if (testSettingsNode != null) + { + testSettingsPath = testSettingsNode.InnerText; } - /// - /// Given a runSettings with an embedded testSettings, converts it to runSettings. - /// - /// Path to old runsettings. - /// Path to new runsettings. - private void MigrateRunSettings(string oldRunSettingsPath, string newRunSettingsPath) + if (!string.IsNullOrWhiteSpace(testSettingsPath)) { - string testSettingsPath = null; - using (XmlTextReader reader = new XmlTextReader(oldRunSettingsPath)) + // Expand path relative to runSettings location. + if (!Path.IsPathRooted(testSettingsPath)) { - reader.Namespaces = false; - - var runSettingsXmlDoc = new XmlDocument(); - runSettingsXmlDoc.Load(reader); - var root = runSettingsXmlDoc.DocumentElement; - - var testSettingsNode = root.SelectSingleNode(@"/RunSettings/MSTest/SettingsFile"); - - if (testSettingsNode != null) - { - testSettingsPath = testSettingsNode.InnerText; - } - - if (!string.IsNullOrWhiteSpace(testSettingsPath)) - { - // Expand path relative to runSettings location. - if (!Path.IsPathRooted(testSettingsPath)) - { - testSettingsPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(oldRunSettingsPath), testSettingsPath)); - } - - // Remove the embedded testSettings node if it exists. - this.RemoveEmbeddedTestSettings(runSettingsXmlDoc); - - this.MigrateTestSettingsNodesToRunSettings(testSettingsPath, runSettingsXmlDoc); - - runSettingsXmlDoc.Save(newRunSettingsPath); - Console.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.RunSettingsCreated, newRunSettingsPath)); - } - else - { - Console.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.NoEmbeddedSettings)); - } + testSettingsPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(oldRunSettingsPath), testSettingsPath)); } - } - /// - /// Given a testSettings, converts it to runSettings. - /// - /// Path to old testsettings. - /// Path to new runsettings. - private void MigrateTestSettings(string oldTestSettingsPath, string newRunSettingsPath) - { - var runSettingsXmlDoc = new XmlDocument(); - runSettingsXmlDoc.LoadXml(SampleRunSettingsContent); + // Remove the embedded testSettings node if it exists. + RemoveEmbeddedTestSettings(runSettingsXmlDoc); - this.MigrateTestSettingsNodesToRunSettings(oldTestSettingsPath, runSettingsXmlDoc); + MigrateTestSettingsNodesToRunSettings(testSettingsPath, runSettingsXmlDoc); runSettingsXmlDoc.Save(newRunSettingsPath); Console.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.RunSettingsCreated, newRunSettingsPath)); } - - /// - /// Given a testSettings, converts it to runSettings - /// - /// Path to test settings - /// Runsettings Xml - private void MigrateTestSettingsNodesToRunSettings(string testSettingsPath, XmlDocument runSettingsXmlDoc) + else { - var testSettingsNodes = this.ReadTestSettingsNodes(testSettingsPath); + Console.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.NoEmbeddedSettings)); + } + } - string testTimeout = null; - if (testSettingsNodes.Timeout != null && testSettingsNodes.Timeout.Attributes[TestTimeoutAttributeName] != null) - { - testTimeout = testSettingsNodes.Timeout.Attributes[TestTimeoutAttributeName].Value; - } + /// + /// Given a testSettings, converts it to runSettings. + /// + /// Path to old testsettings. + /// Path to new runsettings. + private void MigrateTestSettings(string oldTestSettingsPath, string newRunSettingsPath) + { + var runSettingsXmlDoc = new XmlDocument(); + runSettingsXmlDoc.LoadXml(SampleRunSettingsContent); - string runTimeout = null; - if (testSettingsNodes.Timeout != null && testSettingsNodes.Timeout.Attributes[RunTimeoutAttributeName] != null) - { - runTimeout = testSettingsNodes.Timeout.Attributes[RunTimeoutAttributeName].Value; - } + MigrateTestSettingsNodesToRunSettings(oldTestSettingsPath, runSettingsXmlDoc); - string parallelTestCount = null; - if (testSettingsNodes.Execution != null && testSettingsNodes.Execution.Attributes[ParallelTestCountAttributeName] != null) - { - parallelTestCount = testSettingsNodes.Execution.Attributes[ParallelTestCountAttributeName].Value; - } + runSettingsXmlDoc.Save(newRunSettingsPath); + Console.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.RunSettingsCreated, newRunSettingsPath)); + } - string hostProcessPlatform = null; - if (testSettingsNodes.Execution != null && testSettingsNodes.Execution.Attributes[HostProcessPlatformAttributeName] != null) - { - hostProcessPlatform = testSettingsNodes.Execution.Attributes[HostProcessPlatformAttributeName].Value; - } + /// + /// Given a testSettings, converts it to runSettings + /// + /// Path to test settings + /// Runsettings Xml + private void MigrateTestSettingsNodesToRunSettings(string testSettingsPath, XmlDocument runSettingsXmlDoc) + { + var testSettingsNodes = ReadTestSettingsNodes(testSettingsPath); - // WebTestRunConfiguration node. - if (testSettingsNodes.WebSettings != null) - { - runSettingsXmlDoc.DocumentElement.AppendChild(runSettingsXmlDoc.ImportNode(testSettingsNodes.WebSettings, deep: true)); - } + string testTimeout = null; + if (testSettingsNodes.Timeout != null && testSettingsNodes.Timeout.Attributes[TestTimeoutAttributeName] != null) + { + testTimeout = testSettingsNodes.Timeout.Attributes[TestTimeoutAttributeName].Value; + } - // LegacySettings node. - this.AddLegacyNodes(testSettingsNodes, testTimeout, parallelTestCount, hostProcessPlatform, runSettingsXmlDoc); + string runTimeout = null; + if (testSettingsNodes.Timeout != null && testSettingsNodes.Timeout.Attributes[RunTimeoutAttributeName] != null) + { + runTimeout = testSettingsNodes.Timeout.Attributes[RunTimeoutAttributeName].Value; + } - // TestSessionTimeout node. - if (!string.IsNullOrEmpty(runTimeout)) - { - this.AddRunTimeoutNode(runTimeout, runSettingsXmlDoc); - } + string parallelTestCount = null; + if (testSettingsNodes.Execution != null && testSettingsNodes.Execution.Attributes[ParallelTestCountAttributeName] != null) + { + parallelTestCount = testSettingsNodes.Execution.Attributes[ParallelTestCountAttributeName].Value; + } - // DataCollectors node. - if (testSettingsNodes.Datacollectors != null && testSettingsNodes.Datacollectors.Count > 0) - { - this.AddDataCollectorNodes(testSettingsNodes.Datacollectors, runSettingsXmlDoc); - } + string hostProcessPlatform = null; + if (testSettingsNodes.Execution != null && testSettingsNodes.Execution.Attributes[HostProcessPlatformAttributeName] != null) + { + hostProcessPlatform = testSettingsNodes.Execution.Attributes[HostProcessPlatformAttributeName].Value; } - private TestSettingsNodes ReadTestSettingsNodes(string testSettingsPath) + // WebTestRunConfiguration node. + if (testSettingsNodes.WebSettings != null) { - var testSettingsNodes = new TestSettingsNodes(); + runSettingsXmlDoc.DocumentElement.AppendChild(runSettingsXmlDoc.ImportNode(testSettingsNodes.WebSettings, deep: true)); + } - using (XmlTextReader reader = new XmlTextReader(testSettingsPath)) - { - reader.Namespaces = false; - - var testSettingsXmlDoc = new XmlDocument(); - testSettingsXmlDoc.Load(reader); - var testSettingsRoot = testSettingsXmlDoc.DocumentElement; - - // Select the interesting nodes from the xml. - testSettingsNodes.Deployment = testSettingsRoot.SelectSingleNode(@"/TestSettings/Deployment"); - testSettingsNodes.Script = testSettingsRoot.SelectSingleNode(@"/TestSettings/Scripts"); - testSettingsNodes.WebSettings = testSettingsRoot.SelectSingleNode(@"/TestSettings/Execution/TestTypeSpecific/WebTestRunConfiguration"); - testSettingsNodes.Datacollectors = testSettingsRoot.SelectNodes(@"/TestSettings/Execution/AgentRule/DataCollectors/DataCollector"); - testSettingsNodes.Timeout = testSettingsRoot.SelectSingleNode(@"/TestSettings/Execution/Timeouts"); - testSettingsNodes.UnitTestConfig = testSettingsRoot.SelectSingleNode(@"/TestSettings/Execution/TestTypeSpecific/UnitTestRunConfig"); - testSettingsNodes.Hosts = testSettingsRoot.SelectSingleNode(@"/TestSettings/Execution/Hosts"); - testSettingsNodes.Execution = testSettingsRoot.SelectSingleNode(@"/TestSettings/Execution"); - - if (testSettingsNodes.Timeout != null && (testSettingsNodes.Timeout.Attributes[AgentNotRespondingTimeoutAttribute] != null || - testSettingsNodes.Timeout.Attributes[DeploymentTimeoutAttribute] != null || testSettingsNodes.Timeout.Attributes[ScriptTimeoutAttribute] != null)) - { - Console.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.UnsupportedAttributes)); - } - } + // LegacySettings node. + AddLegacyNodes(testSettingsNodes, testTimeout, parallelTestCount, hostProcessPlatform, runSettingsXmlDoc); - return testSettingsNodes; + // TestSessionTimeout node. + if (!string.IsNullOrEmpty(runTimeout)) + { + AddRunTimeoutNode(runTimeout, runSettingsXmlDoc); } - /// - /// Removes the embedded testSettings node if present. - /// - /// Xml doc to process - private void RemoveEmbeddedTestSettings(XmlDocument newXmlDoc) + // DataCollectors node. + if (testSettingsNodes.Datacollectors != null && testSettingsNodes.Datacollectors.Count > 0) { - var testSettingsNode = newXmlDoc.DocumentElement.SelectSingleNode(@"/RunSettings/MSTest/SettingsFile"); - if (testSettingsNode != null) - { - testSettingsNode.ParentNode.RemoveChild(testSettingsNode); - } + AddDataCollectorNodes(testSettingsNodes.Datacollectors, runSettingsXmlDoc); } + } - /// - /// Adds the legacy nodes to runSettings xml. - /// - /// testSettingsNodes - /// testTimeout - /// parallelTestCount - /// hostProcessPlatform - /// newXmlDoc - private void AddLegacyNodes(TestSettingsNodes testSettingsNodes, string testTimeout, string parallelTestCount, string hostProcessPlatform, XmlDocument newXmlDoc) + private TestSettingsNodes ReadTestSettingsNodes(string testSettingsPath) + { + var testSettingsNodes = new TestSettingsNodes(); + + using (XmlTextReader reader = new(testSettingsPath)) { - if (testSettingsNodes.Deployment == null && testSettingsNodes.Script == null && testSettingsNodes.UnitTestConfig == null && - string.IsNullOrEmpty(parallelTestCount) && string.IsNullOrEmpty(testTimeout) && string.IsNullOrEmpty(hostProcessPlatform) && testSettingsNodes.Hosts == null) + reader.Namespaces = false; + + var testSettingsXmlDoc = new XmlDocument(); + testSettingsXmlDoc.Load(reader); + var testSettingsRoot = testSettingsXmlDoc.DocumentElement; + + // Select the interesting nodes from the xml. + testSettingsNodes.Deployment = testSettingsRoot.SelectSingleNode(@"/TestSettings/Deployment"); + testSettingsNodes.Script = testSettingsRoot.SelectSingleNode(@"/TestSettings/Scripts"); + testSettingsNodes.WebSettings = testSettingsRoot.SelectSingleNode(@"/TestSettings/Execution/TestTypeSpecific/WebTestRunConfiguration"); + testSettingsNodes.Datacollectors = testSettingsRoot.SelectNodes(@"/TestSettings/Execution/AgentRule/DataCollectors/DataCollector"); + testSettingsNodes.Timeout = testSettingsRoot.SelectSingleNode(@"/TestSettings/Execution/Timeouts"); + testSettingsNodes.UnitTestConfig = testSettingsRoot.SelectSingleNode(@"/TestSettings/Execution/TestTypeSpecific/UnitTestRunConfig"); + testSettingsNodes.Hosts = testSettingsRoot.SelectSingleNode(@"/TestSettings/Execution/Hosts"); + testSettingsNodes.Execution = testSettingsRoot.SelectSingleNode(@"/TestSettings/Execution"); + + if (testSettingsNodes.Timeout != null && (testSettingsNodes.Timeout.Attributes[AgentNotRespondingTimeoutAttribute] != null || + testSettingsNodes.Timeout.Attributes[DeploymentTimeoutAttribute] != null || testSettingsNodes.Timeout.Attributes[ScriptTimeoutAttribute] != null)) { - return; + Console.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.UnsupportedAttributes)); } + } - // Add ForcedLegacy node. - var mstestNode = newXmlDoc.DocumentElement.SelectSingleNode(@"/RunSettings/MSTest"); - XmlNode forcedLegacyNode; - if (mstestNode == null) - { - mstestNode = newXmlDoc.CreateNode(XmlNodeType.Element, MSTestNodeName, null); - newXmlDoc.DocumentElement.AppendChild(mstestNode); - mstestNode = newXmlDoc.DocumentElement.SelectSingleNode(@"/RunSettings/MSTest"); - } + return testSettingsNodes; + } + + /// + /// Removes the embedded testSettings node if present. + /// + /// Xml doc to process + private void RemoveEmbeddedTestSettings(XmlDocument newXmlDoc) + { + var testSettingsNode = newXmlDoc.DocumentElement.SelectSingleNode(@"/RunSettings/MSTest/SettingsFile"); + if (testSettingsNode != null) + { + testSettingsNode.ParentNode.RemoveChild(testSettingsNode); + } + } + /// + /// Adds the legacy nodes to runSettings xml. + /// + /// testSettingsNodes + /// testTimeout + /// parallelTestCount + /// hostProcessPlatform + /// newXmlDoc + private void AddLegacyNodes(TestSettingsNodes testSettingsNodes, string testTimeout, string parallelTestCount, string hostProcessPlatform, XmlDocument newXmlDoc) + { + if (testSettingsNodes.Deployment == null && testSettingsNodes.Script == null && testSettingsNodes.UnitTestConfig == null && + string.IsNullOrEmpty(parallelTestCount) && string.IsNullOrEmpty(testTimeout) && string.IsNullOrEmpty(hostProcessPlatform) && testSettingsNodes.Hosts == null) + { + return; + } + + // Add ForcedLegacy node. + var mstestNode = newXmlDoc.DocumentElement.SelectSingleNode(@"/RunSettings/MSTest"); + XmlNode forcedLegacyNode; + if (mstestNode == null) + { + mstestNode = newXmlDoc.CreateNode(XmlNodeType.Element, MSTestNodeName, null); + newXmlDoc.DocumentElement.AppendChild(mstestNode); + mstestNode = newXmlDoc.DocumentElement.SelectSingleNode(@"/RunSettings/MSTest"); + } + + forcedLegacyNode = newXmlDoc.DocumentElement.SelectSingleNode(@"/RunSettings/MSTest/ForcedLegacyMode"); + if (forcedLegacyNode == null) + { + forcedLegacyNode = newXmlDoc.CreateNode(XmlNodeType.Element, ForcedLegacyModeName, null); + mstestNode.AppendChild(newXmlDoc.ImportNode(forcedLegacyNode, deep: true)); forcedLegacyNode = newXmlDoc.DocumentElement.SelectSingleNode(@"/RunSettings/MSTest/ForcedLegacyMode"); - if (forcedLegacyNode == null) - { - forcedLegacyNode = newXmlDoc.CreateNode(XmlNodeType.Element, ForcedLegacyModeName, null); - mstestNode.AppendChild(newXmlDoc.ImportNode(forcedLegacyNode, deep: true)); - forcedLegacyNode = newXmlDoc.DocumentElement.SelectSingleNode(@"/RunSettings/MSTest/ForcedLegacyMode"); - } + } - forcedLegacyNode.InnerText = "true"; + forcedLegacyNode.InnerText = "true"; - // Remove if the legacy node already exists. - var legacyNode = newXmlDoc.DocumentElement.SelectSingleNode(@"/RunSettings/LegacySettings"); - if (legacyNode != null) - { - Console.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.IgnoringLegacySettings)); - legacyNode.ParentNode.RemoveChild(legacyNode); - } + // Remove if the legacy node already exists. + var legacyNode = newXmlDoc.DocumentElement.SelectSingleNode(@"/RunSettings/LegacySettings"); + if (legacyNode != null) + { + Console.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.IgnoringLegacySettings)); + legacyNode.ParentNode.RemoveChild(legacyNode); + } - legacyNode = newXmlDoc.CreateNode(XmlNodeType.Element, LegacySettingsNodeName, null); + legacyNode = newXmlDoc.CreateNode(XmlNodeType.Element, LegacySettingsNodeName, null); - if (testSettingsNodes.Deployment != null) - { - legacyNode.AppendChild(newXmlDoc.ImportNode(testSettingsNodes.Deployment, deep: true)); - } + if (testSettingsNodes.Deployment != null) + { + legacyNode.AppendChild(newXmlDoc.ImportNode(testSettingsNodes.Deployment, deep: true)); + } + + if (testSettingsNodes.Script != null) + { + legacyNode.AppendChild(newXmlDoc.ImportNode(testSettingsNodes.Script, deep: true)); + } + + // Execution node. + if (testSettingsNodes.UnitTestConfig != null || !string.IsNullOrEmpty(parallelTestCount) || !string.IsNullOrEmpty(testTimeout) || testSettingsNodes.Hosts != null) + { + var newExecutionNode = newXmlDoc.CreateNode(XmlNodeType.Element, ExecutionNodeName, null); - if (testSettingsNodes.Script != null) + if (!string.IsNullOrEmpty(parallelTestCount)) { - legacyNode.AppendChild(newXmlDoc.ImportNode(testSettingsNodes.Script, deep: true)); + var paralellAttribute = newXmlDoc.CreateAttribute(ParallelTestCountAttributeName); + paralellAttribute.Value = parallelTestCount; + newExecutionNode.Attributes.Append(paralellAttribute); } - // Execution node. - if (testSettingsNodes.UnitTestConfig != null || !string.IsNullOrEmpty(parallelTestCount) || !string.IsNullOrEmpty(testTimeout) || testSettingsNodes.Hosts != null) + if (!string.IsNullOrEmpty(hostProcessPlatform)) { - var newExecutionNode = newXmlDoc.CreateNode(XmlNodeType.Element, ExecutionNodeName, null); - - if (!string.IsNullOrEmpty(parallelTestCount)) - { - var paralellAttribute = newXmlDoc.CreateAttribute(ParallelTestCountAttributeName); - paralellAttribute.Value = parallelTestCount; - newExecutionNode.Attributes.Append(paralellAttribute); - } - - if (!string.IsNullOrEmpty(hostProcessPlatform)) - { - var hostProcessPlatformAttribute = newXmlDoc.CreateAttribute(HostProcessPlatformAttributeName); - hostProcessPlatformAttribute.Value = hostProcessPlatform; - newExecutionNode.Attributes.Append(hostProcessPlatformAttribute); - } - - if (!string.IsNullOrEmpty(testTimeout)) - { - var newTimeoutsNode = newXmlDoc.CreateNode(XmlNodeType.Element, TimeoutsNodeName, null); - var testtimeoutattribute = newXmlDoc.CreateAttribute(TestTimeoutAttributeName); - testtimeoutattribute.Value = testTimeout; - newTimeoutsNode.Attributes.Append(testtimeoutattribute); - newExecutionNode.AppendChild(newXmlDoc.ImportNode(newTimeoutsNode, deep: true)); - } - - if (testSettingsNodes.Hosts != null) - { - newExecutionNode.AppendChild(newXmlDoc.ImportNode(testSettingsNodes.Hosts, deep: true)); - } - - if (testSettingsNodes.UnitTestConfig != null) - { - var testTypeSpecificNode = newXmlDoc.CreateNode(XmlNodeType.Element, TestTypeSpecificNodeName, null); - testTypeSpecificNode.AppendChild(newXmlDoc.ImportNode(testSettingsNodes.UnitTestConfig, deep: true)); - newExecutionNode.AppendChild(newXmlDoc.ImportNode(testTypeSpecificNode, deep: true)); - } - - legacyNode.AppendChild(newXmlDoc.ImportNode(newExecutionNode, deep: true)); + var hostProcessPlatformAttribute = newXmlDoc.CreateAttribute(HostProcessPlatformAttributeName); + hostProcessPlatformAttribute.Value = hostProcessPlatform; + newExecutionNode.Attributes.Append(hostProcessPlatformAttribute); } - newXmlDoc.DocumentElement.AppendChild(legacyNode); - } - - /// - /// Adds the datacollector nodes to the runSettings xml. - /// - /// Datacollector Nodes - /// Xml doc to process - private void AddDataCollectorNodes(XmlNodeList oldDatacollectorNodes, XmlDocument newXmlDoc) - { - var dataCollectionRunSettingsNode = newXmlDoc.DocumentElement.SelectSingleNode(@"/RunSettings/DataCollectionRunSettings"); - if (dataCollectionRunSettingsNode == null) + if (!string.IsNullOrEmpty(testTimeout)) { - dataCollectionRunSettingsNode = newXmlDoc.CreateNode(XmlNodeType.Element, DataCollectionRunSettingsNodeName, null); + var newTimeoutsNode = newXmlDoc.CreateNode(XmlNodeType.Element, TimeoutsNodeName, null); + var testtimeoutattribute = newXmlDoc.CreateAttribute(TestTimeoutAttributeName); + testtimeoutattribute.Value = testTimeout; + newTimeoutsNode.Attributes.Append(testtimeoutattribute); + newExecutionNode.AppendChild(newXmlDoc.ImportNode(newTimeoutsNode, deep: true)); } - var dataCollectorsNode = newXmlDoc.DocumentElement.SelectSingleNode(@"/RunSettings/DataCollectionRunSettings/DataCollectors"); - if (dataCollectorsNode == null) + if (testSettingsNodes.Hosts != null) { - dataCollectorsNode = newXmlDoc.CreateNode(XmlNodeType.Element, DataCollectorsNodeName, null); - dataCollectionRunSettingsNode.AppendChild(newXmlDoc.ImportNode(dataCollectorsNode, deep: true)); - newXmlDoc.DocumentElement.AppendChild(dataCollectionRunSettingsNode); - dataCollectorsNode = newXmlDoc.DocumentElement.SelectSingleNode(@"/RunSettings/DataCollectionRunSettings/DataCollectors"); + newExecutionNode.AppendChild(newXmlDoc.ImportNode(testSettingsNodes.Hosts, deep: true)); } - foreach (XmlNode datacollector in oldDatacollectorNodes) + if (testSettingsNodes.UnitTestConfig != null) { - dataCollectorsNode.AppendChild(newXmlDoc.ImportNode(datacollector, deep: true)); + var testTypeSpecificNode = newXmlDoc.CreateNode(XmlNodeType.Element, TestTypeSpecificNodeName, null); + testTypeSpecificNode.AppendChild(newXmlDoc.ImportNode(testSettingsNodes.UnitTestConfig, deep: true)); + newExecutionNode.AppendChild(newXmlDoc.ImportNode(testTypeSpecificNode, deep: true)); } + + legacyNode.AppendChild(newXmlDoc.ImportNode(newExecutionNode, deep: true)); } - /// - /// Adds run session timeout node. - /// - /// Run Timeout - /// Xml doc to process - private void AddRunTimeoutNode(string runTimeout, XmlDocument newXmlDoc) + newXmlDoc.DocumentElement.AppendChild(legacyNode); + } + + /// + /// Adds the datacollector nodes to the runSettings xml. + /// + /// Datacollector Nodes + /// Xml doc to process + private void AddDataCollectorNodes(XmlNodeList oldDatacollectorNodes, XmlDocument newXmlDoc) + { + var dataCollectionRunSettingsNode = newXmlDoc.DocumentElement.SelectSingleNode(@"/RunSettings/DataCollectionRunSettings"); + if (dataCollectionRunSettingsNode == null) { - var runConfigurationNode = newXmlDoc.DocumentElement.SelectSingleNode(@"/RunSettings/RunConfiguration"); - if (runConfigurationNode == null) - { - runConfigurationNode = newXmlDoc.CreateNode(XmlNodeType.Element, RunConfigurationNodeName, null); - } + dataCollectionRunSettingsNode = newXmlDoc.CreateNode(XmlNodeType.Element, DataCollectionRunSettingsNodeName, null); + } - var testSessionTimeoutNode = newXmlDoc.CreateNode(XmlNodeType.Element, TestSessionTimeoutNodeName, null); - testSessionTimeoutNode.InnerText = runTimeout; - runConfigurationNode.AppendChild(newXmlDoc.ImportNode(testSessionTimeoutNode, deep: true)); + var dataCollectorsNode = newXmlDoc.DocumentElement.SelectSingleNode(@"/RunSettings/DataCollectionRunSettings/DataCollectors"); + if (dataCollectorsNode == null) + { + dataCollectorsNode = newXmlDoc.CreateNode(XmlNodeType.Element, DataCollectorsNodeName, null); + dataCollectionRunSettingsNode.AppendChild(newXmlDoc.ImportNode(dataCollectorsNode, deep: true)); + newXmlDoc.DocumentElement.AppendChild(dataCollectionRunSettingsNode); + dataCollectorsNode = newXmlDoc.DocumentElement.SelectSingleNode(@"/RunSettings/DataCollectionRunSettings/DataCollectors"); + } + + foreach (XmlNode datacollector in oldDatacollectorNodes) + { + dataCollectorsNode.AppendChild(newXmlDoc.ImportNode(datacollector, deep: true)); + } + } - newXmlDoc.DocumentElement.AppendChild(runConfigurationNode); + /// + /// Adds run session timeout node. + /// + /// Run Timeout + /// Xml doc to process + private void AddRunTimeoutNode(string runTimeout, XmlDocument newXmlDoc) + { + var runConfigurationNode = newXmlDoc.DocumentElement.SelectSingleNode(@"/RunSettings/RunConfiguration"); + if (runConfigurationNode == null) + { + runConfigurationNode = newXmlDoc.CreateNode(XmlNodeType.Element, RunConfigurationNodeName, null); } + + var testSessionTimeoutNode = newXmlDoc.CreateNode(XmlNodeType.Element, TestSessionTimeoutNodeName, null); + testSessionTimeoutNode.InnerText = runTimeout; + runConfigurationNode.AppendChild(newXmlDoc.ImportNode(testSessionTimeoutNode, deep: true)); + + newXmlDoc.DocumentElement.AppendChild(runConfigurationNode); } } \ No newline at end of file diff --git a/src/SettingsMigrator/PathResolver.cs b/src/SettingsMigrator/PathResolver.cs index b363428112..a935bf790c 100644 --- a/src/SettingsMigrator/PathResolver.cs +++ b/src/SettingsMigrator/PathResolver.cs @@ -1,47 +1,46 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.SettingsMigrator +namespace Microsoft.VisualStudio.TestPlatform.SettingsMigrator; + +using System; +using System.IO; + +/// +/// Used to resolve the inputs provided by the user to paths needed by migrator. +/// +public class PathResolver { - using System; - using System.IO; + private const string RunSettingsExtension = ".runsettings"; /// - /// Used to resolve the inputs provided by the user to paths needed by migrator. + /// Gets the target path based on user inputs. /// - public class PathResolver + /// User inputs + /// New file path to create + public string GetTargetPath(string[] args) { - private const string RunSettingsExtension = ".runsettings"; - - /// - /// Gets the target path based on user inputs. - /// - /// User inputs - /// New file path to create - public string GetTargetPath(string[] args) + string newFilePath = null; + if (args.Length < 1 || !Path.IsPathRooted(args[0])) { - string newFilePath = null; - if (args.Length < 1 || !Path.IsPathRooted(args[0])) - { - return newFilePath; - } + return newFilePath; + } - if (args.Length == 1) - { - var oldFilePath = args[0]; - var newFileName = string.Concat(Path.GetFileNameWithoutExtension(oldFilePath), "_", DateTime.Now.ToString("MM-dd-yyyy_hh-mm-ss"), RunSettingsExtension); - newFilePath = Path.Combine(Path.GetDirectoryName(oldFilePath), newFileName); - } - else if (args.Length == 2) + if (args.Length == 1) + { + var oldFilePath = args[0]; + var newFileName = string.Concat(Path.GetFileNameWithoutExtension(oldFilePath), "_", DateTime.Now.ToString("MM-dd-yyyy_hh-mm-ss"), RunSettingsExtension); + newFilePath = Path.Combine(Path.GetDirectoryName(oldFilePath), newFileName); + } + else if (args.Length == 2) + { + newFilePath = args[1]; + if (!Path.IsPathRooted(newFilePath) || !string.Equals(Path.GetExtension(newFilePath), RunSettingsExtension, StringComparison.OrdinalIgnoreCase)) { - newFilePath = args[1]; - if (!Path.IsPathRooted(newFilePath) || !string.Equals(Path.GetExtension(newFilePath), RunSettingsExtension, StringComparison.OrdinalIgnoreCase)) - { - newFilePath = null; - } + newFilePath = null; } - - return newFilePath; } + + return newFilePath; } } \ No newline at end of file diff --git a/src/SettingsMigrator/Program.cs b/src/SettingsMigrator/Program.cs index 93218beef7..d3f497d1d8 100644 --- a/src/SettingsMigrator/Program.cs +++ b/src/SettingsMigrator/Program.cs @@ -1,40 +1,40 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.SettingsMigrator -{ - using System; - using System.Globalization; - using CommandLineResources = Resources.Resources; +namespace Microsoft.VisualStudio.TestPlatform.SettingsMigrator; + +using System; +using System.Globalization; + +using CommandLineResources = Resources.Resources; +/// +/// Entry point for SettingsMigrator. +/// +public static class Program +{ /// - /// Entry point for SettingsMigrator. + /// Main entry point. Hands off execution to Migrator. /// - public static class Program + /// Arguments on the command line + /// Exit code + public static int Main(string[] args) { - /// - /// Main entry point. Hands off execution to Migrator. - /// - /// Arguments on the command line - /// Exit code - public static int Main(string[] args) - { - var pathResolver = new PathResolver(); - string newFilePath = pathResolver.GetTargetPath(args); + var pathResolver = new PathResolver(); + string newFilePath = pathResolver.GetTargetPath(args); - if (!string.IsNullOrEmpty(newFilePath)) - { - string oldFilePath = args[0]; - var migrator = new Migrator(); - migrator.Migrate(oldFilePath, newFilePath); - } - else - { - Console.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.ValidUsage)); - return 1; - } - - return 0; + if (!string.IsNullOrEmpty(newFilePath)) + { + string oldFilePath = args[0]; + var migrator = new Migrator(); + migrator.Migrate(oldFilePath, newFilePath); } + else + { + Console.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.ValidUsage)); + return 1; + } + + return 0; } } \ No newline at end of file diff --git a/src/SettingsMigrator/TestSettingsNodes.cs b/src/SettingsMigrator/TestSettingsNodes.cs index c0e3271366..728dc8169d 100644 --- a/src/SettingsMigrator/TestSettingsNodes.cs +++ b/src/SettingsMigrator/TestSettingsNodes.cs @@ -1,29 +1,28 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.SettingsMigrator -{ - using System.Xml; +namespace Microsoft.VisualStudio.TestPlatform.SettingsMigrator; + +using System.Xml; - /// - /// Contains the test settings nodes that need to be converted. - /// - public class TestSettingsNodes - { - public XmlNode Deployment { get; set; } +/// +/// Contains the test settings nodes that need to be converted. +/// +public class TestSettingsNodes +{ + public XmlNode Deployment { get; set; } - public XmlNode Script { get; set; } + public XmlNode Script { get; set; } - public XmlNode WebSettings { get; set; } + public XmlNode WebSettings { get; set; } - public XmlNodeList Datacollectors { get; set; } + public XmlNodeList Datacollectors { get; set; } - public XmlNode Timeout { get; set; } + public XmlNode Timeout { get; set; } - public XmlNode UnitTestConfig { get; set; } + public XmlNode UnitTestConfig { get; set; } - public XmlNode Hosts { get; set; } + public XmlNode Hosts { get; set; } - public XmlNode Execution { get; set; } - } -} + public XmlNode Execution { get; set; } +} \ No newline at end of file diff --git a/src/datacollector/DataCollectorMain.cs b/src/datacollector/DataCollectorMain.cs index 9bfbeeffd3..201897e7ce 100644 --- a/src/datacollector/DataCollectorMain.cs +++ b/src/datacollector/DataCollectorMain.cs @@ -1,171 +1,177 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.DataCollector -{ - using System; - using System.Globalization; - using System.Reflection; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Execution; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using PlatformAbstractions.Interfaces; - using CommunicationUtilitiesResources = Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources.Resources; - using CoreUtilitiesConstants = Microsoft.VisualStudio.TestPlatform.CoreUtilities.Constants; - - public class DataCollectorMain - { - /// - /// Port number used to communicate with test runner process. - /// - private const string PortArgument = "--port"; - - /// - /// Parent process Id argument to monitor parent process. - /// - private const string ParentProcessArgument = "--parentprocessid"; - - /// - /// Log file for writing eqt trace logs. - /// - private const string LogFileArgument = "--diag"; - - /// - /// Trace level for logs. - /// - private const string TraceLevelArgument = "--tracelevel"; - - private IProcessHelper processHelper; - - private IEnvironment environment; - private IDataCollectionRequestHandler requestHandler; - - public DataCollectorMain(): - this( - new ProcessHelper(), - new PlatformEnvironment(), - DataCollectionRequestHandler.Create(new SocketCommunicationManager(), new MessageSink()) - ) - { - } +namespace Microsoft.VisualStudio.TestPlatform.DataCollector; - internal DataCollectorMain(IProcessHelper processHelper, IEnvironment environment, IDataCollectionRequestHandler requestHandler) - { - this.processHelper = processHelper; - this.environment = environment; - this.requestHandler = requestHandler; - } +using System; +using System.Globalization; +using System.Reflection; - public void Run(string[] args) - { - DebuggerBreakpoint.AttachVisualStudioDebugger("VSTEST_DATACOLLECTOR_DEBUG_ATTACHVS"); - DebuggerBreakpoint.WaitForDebugger("VSTEST_DATACOLLECTOR_DEBUG"); +using CommunicationUtilities; +using CommunicationUtilities.DataCollection; +using CommunicationUtilities.DataCollection.Interfaces; - var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args); +using CoreUtilities.Helpers; - // Setup logging if enabled - if (argsDictionary.TryGetValue(LogFileArgument, out var logFile)) - { - var traceLevelInt = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, TraceLevelArgument); - var isTraceLevelArgValid = Enum.IsDefined(typeof(PlatformTraceLevel), traceLevelInt); +using Execution; - // In case traceLevelInt is not defined in PlatfromTraceLevel, default it to verbose. - var traceLevel = isTraceLevelArgValid ? (PlatformTraceLevel)traceLevelInt : PlatformTraceLevel.Verbose; +using ObjectModel; +using ObjectModel.Logging; - // Initialize trace. - EqtTrace.InitializeTrace(logFile, traceLevel); +using PlatformAbstractions; +using PlatformAbstractions.Interfaces; - // Log warning in case tracelevel passed in arg is invalid - if (!isTraceLevelArgValid) - { - EqtTrace.Warning("DataCollectorMain.Run: Invalid trace level: {0}, defaulting to verbose tracelevel.", traceLevelInt); - } - } - else - { - EqtTrace.DoNotInitailize = true; - } +using CommunicationUtilitiesResources = CommunicationUtilities.Resources.Resources; +using CoreUtilitiesConstants = CoreUtilities.Constants; - if (EqtTrace.IsVerboseEnabled) - { - var version = typeof(DataCollectorMain) - .GetTypeInfo() - .Assembly - .GetCustomAttribute()?.InformationalVersion; - EqtTrace.Verbose($"Version: { version }"); - } +public class DataCollectorMain +{ + /// + /// Port number used to communicate with test runner process. + /// + private const string PortArgument = "--port"; + + /// + /// Parent process Id argument to monitor parent process. + /// + private const string ParentProcessArgument = "--parentprocessid"; + + /// + /// Log file for writing eqt trace logs. + /// + private const string LogFileArgument = "--diag"; + + /// + /// Trace level for logs. + /// + private const string TraceLevelArgument = "--tracelevel"; + + private readonly IProcessHelper _processHelper; + + private readonly IEnvironment _environment; + private readonly IDataCollectionRequestHandler _requestHandler; + + public DataCollectorMain() : + this( + new ProcessHelper(), + new PlatformEnvironment(), + DataCollectionRequestHandler.Create(new SocketCommunicationManager(), new MessageSink()) + ) + { + } - UILanguageOverride.SetCultureSpecifiedByUser(); + internal DataCollectorMain(IProcessHelper processHelper, IEnvironment environment, IDataCollectionRequestHandler requestHandler) + { + _processHelper = processHelper; + _environment = environment; + _requestHandler = requestHandler; + } - EqtTrace.Info("DataCollectorMain.Run: Starting data collector run with args: {0}", string.Join(",", args)); + public void Run(string[] args) + { + DebuggerBreakpoint.AttachVisualStudioDebugger("VSTEST_DATACOLLECTOR_DEBUG_ATTACHVS"); + DebuggerBreakpoint.WaitForDebugger("VSTEST_DATACOLLECTOR_DEBUG"); + + var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args); - // Attach to exit of parent process - var parentProcessId = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, ParentProcessArgument); - EqtTrace.Info("DataCollector: Monitoring parent process with id: '{0}'", parentProcessId); + // Setup logging if enabled + if (argsDictionary.TryGetValue(LogFileArgument, out var logFile)) + { + var traceLevelInt = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, TraceLevelArgument); + var isTraceLevelArgValid = Enum.IsDefined(typeof(PlatformTraceLevel), traceLevelInt); - this.processHelper.SetExitCallback( - parentProcessId, - (obj) => - { - EqtTrace.Info("DataCollector: ParentProcess '{0}' Exited.", parentProcessId); - this.environment.Exit(1); - }); + // In case traceLevelInt is not defined in PlatfromTraceLevel, default it to verbose. + var traceLevel = isTraceLevelArgValid ? (PlatformTraceLevel)traceLevelInt : PlatformTraceLevel.Verbose; - // Get server port and initialize communication. - int port = argsDictionary.TryGetValue(PortArgument, out var portValue) ? int.Parse(portValue) : 0; + // Initialize trace. + EqtTrace.InitializeTrace(logFile, traceLevel); - if (port <= 0) + + // Log warning in case tracelevel passed in arg is invalid + if (!isTraceLevelArgValid) { - throw new ArgumentException("Incorrect/No Port number"); + EqtTrace.Warning("DataCollectorMain.Run: Invalid trace level: {0}, defaulting to verbose tracelevel.", traceLevelInt); } + } + else + { + EqtTrace.DoNotInitailize = true; + } + + if (EqtTrace.IsVerboseEnabled) + { + var version = typeof(DataCollectorMain) + .GetTypeInfo() + .Assembly + .GetCustomAttribute()?.InformationalVersion; + EqtTrace.Verbose($"Version: { version }"); + } + + UiLanguageOverride.SetCultureSpecifiedByUser(); - this.requestHandler.InitializeCommunication(port); + EqtTrace.Info("DataCollectorMain.Run: Starting data collector run with args: {0}", string.Join(",", args)); - // Can only do this after InitializeCommunication because datacollector cannot "Send Log" unless communications are initialized - if (!string.IsNullOrEmpty(EqtTrace.LogFile)) + // Attach to exit of parent process + var parentProcessId = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, ParentProcessArgument); + EqtTrace.Info("DataCollector: Monitoring parent process with id: '{0}'", parentProcessId); + + _processHelper.SetExitCallback( + parentProcessId, + (obj) => { - (this.requestHandler as DataCollectionRequestHandler)?.SendDataCollectionMessage(new DataCollectionMessageEventArgs(TestMessageLevel.Informational, string.Format("Logging DataCollector Diagnostics in file: {0}", EqtTrace.LogFile))); - } + EqtTrace.Info("DataCollector: ParentProcess '{0}' Exited.", parentProcessId); + _environment.Exit(1); + }); + + // Get server port and initialize communication. + int port = argsDictionary.TryGetValue(PortArgument, out var portValue) ? int.Parse(portValue) : 0; - // Start processing async in a different task - EqtTrace.Info("DataCollector: Start Request Processing."); - StartProcessing(); + if (port <= 0) + { + throw new ArgumentException("Incorrect/No Port number"); } + _requestHandler.InitializeCommunication(port); - private void StartProcessing() + // Can only do this after InitializeCommunication because datacollector cannot "Send Log" unless communications are initialized + if (!string.IsNullOrEmpty(EqtTrace.LogFile)) { - var timeout = EnvironmentHelper.GetConnectionTimeout(); + (_requestHandler as DataCollectionRequestHandler)?.SendDataCollectionMessage(new DataCollectionMessageEventArgs(TestMessageLevel.Informational, string.Format("Logging DataCollector Diagnostics in file: {0}", EqtTrace.LogFile))); + } - // Wait for the connection to the sender and start processing requests from sender - if (this.requestHandler.WaitForRequestSenderConnection(timeout * 1000)) - { - this.requestHandler.ProcessRequests(); - } - else - { - EqtTrace.Error( - "DataCollectorMain.StartProcessing: RequestHandler timed out while connecting to the Sender, timeout: {0} seconds.", - timeout); - - this.requestHandler.Close(); - - throw new TestPlatformException( - string.Format( - CultureInfo.CurrentUICulture, - CommunicationUtilitiesResources.ConnectionTimeoutErrorMessage, - CoreUtilitiesConstants.DatacollectorProcessName, - CoreUtilitiesConstants.VstestConsoleProcessName, - timeout, - EnvironmentHelper.VstestConnectionTimeout) - ); - } + // Start processing async in a different task + EqtTrace.Info("DataCollector: Start Request Processing."); + StartProcessing(); + } + + + private void StartProcessing() + { + var timeout = EnvironmentHelper.GetConnectionTimeout(); + + // Wait for the connection to the sender and start processing requests from sender + if (_requestHandler.WaitForRequestSenderConnection(timeout * 1000)) + { + _requestHandler.ProcessRequests(); + } + else + { + EqtTrace.Error( + "DataCollectorMain.StartProcessing: RequestHandler timed out while connecting to the Sender, timeout: {0} seconds.", + timeout); + + _requestHandler.Close(); + + throw new TestPlatformException( + string.Format( + CultureInfo.CurrentUICulture, + CommunicationUtilitiesResources.ConnectionTimeoutErrorMessage, + CoreUtilitiesConstants.DatacollectorProcessName, + CoreUtilitiesConstants.VstestConsoleProcessName, + timeout, + EnvironmentHelper.VstestConnectionTimeout) + ); } } } \ No newline at end of file diff --git a/src/datacollector/MessageSink.cs b/src/datacollector/MessageSink.cs index e6499dd201..65e82958a4 100644 --- a/src/datacollector/MessageSink.cs +++ b/src/datacollector/MessageSink.cs @@ -1,22 +1,23 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.DataCollector -{ - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +namespace Microsoft.VisualStudio.TestPlatform.DataCollector; + +using CommunicationUtilities.DataCollection; + +using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; - /// - internal class MessageSink : IMessageSink +using ObjectModel.Logging; + +/// +internal class MessageSink : IMessageSink +{ + /// + /// Data collection message as sent by DataCollectionLogger. + /// + /// Data collection message event args. + public void SendMessage(DataCollectionMessageEventArgs args) { - /// - /// Data collection message as sent by DataCollectionLogger. - /// - /// Data collection message event args. - public void SendMessage(DataCollectionMessageEventArgs args) - { - DataCollectionRequestHandler.Instance.SendDataCollectionMessage(args); - } + DataCollectionRequestHandler.Instance.SendDataCollectionMessage(args); } -} +} \ No newline at end of file diff --git a/src/datacollector/Program.cs b/src/datacollector/Program.cs index 3554b2c75d..4f90f93c17 100644 --- a/src/datacollector/Program.cs +++ b/src/datacollector/Program.cs @@ -1,37 +1,37 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.DataCollector -{ - using System; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +namespace Microsoft.VisualStudio.TestPlatform.DataCollector; + +using System; +using ObjectModel; + +/// +/// The program. +/// +public class Program +{ /// - /// The program. + /// The main. /// - public class Program + /// + /// The args. + /// + public static void Main(string[] args) { - /// - /// The main. - /// - /// - /// The args. - /// - public static void Main(string[] args) + try + { + new DataCollectorMain().Run(args); + } + catch (Exception ex) + { + EqtTrace.Error("Program.Main: Error occurred during initialization of Datacollector : {0}", ex); + throw; + } + finally { - try - { - new DataCollectorMain().Run(args); - } - catch (Exception ex) - { - EqtTrace.Error("Program.Main: Error occurred during initialization of Datacollector : {0}", ex); - throw; - } - finally - { - EqtTrace.Info("Program.Main: exiting datacollector process."); - } + EqtTrace.Info("Program.Main: exiting datacollector process."); } } } \ No newline at end of file diff --git a/src/testhost.x86/AppDomainEngineInvoker.cs b/src/testhost.x86/AppDomainEngineInvoker.cs index 1586cdcbfe..ae391f074d 100644 --- a/src/testhost.x86/AppDomainEngineInvoker.cs +++ b/src/testhost.x86/AppDomainEngineInvoker.cs @@ -1,308 +1,307 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.TestHost -{ -#if NETFRAMEWORK - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing; +namespace Microsoft.VisualStudio.TestPlatform.TestHost; - using System; - using System.IO; - using System.Linq; - using System.Reflection; - using System.Xml.Linq; - using System.Collections.Generic; - using System.Globalization; +#if NETFRAMEWORK +using ObjectModel; +using CoreUtilities.Tracing; + +using System; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Xml.Linq; +using System.Collections.Generic; +using System.Globalization; + +/// +/// Implementation for the Invoker which invokes engine in a new AppDomain +/// Type of the engine must be a marshalable object for app domain calls and also must have a parameterless constructor +/// +internal class AppDomainEngineInvoker : IEngineInvoker where T : MarshalByRefObject, IEngineInvoker, new() +{ + private const string XmlNamespace = "urn:schemas-microsoft-com:asm.v1"; - /// - /// Implementation for the Invoker which invokes engine in a new AppDomain - /// Type of the engine must be a marshalable object for app domain calls and also must have a parameterless constructor - /// - internal class AppDomainEngineInvoker : IEngineInvoker where T : MarshalByRefObject, IEngineInvoker, new() - { - private const string XmlNamespace = "urn:schemas-microsoft-com:asm.v1"; + protected readonly AppDomain _appDomain; - protected readonly AppDomain appDomain; + protected readonly IEngineInvoker _actualInvoker; - protected readonly IEngineInvoker actualInvoker; + private string _mergedTempConfigFile = null; - private string mergedTempConfigFile = null; + public AppDomainEngineInvoker(string testSourcePath) + { + TestPlatformEventSource.Instance.TestHostAppDomainCreationStart(); - public AppDomainEngineInvoker(string testSourcePath) - { - TestPlatformEventSource.Instance.TestHostAppDomainCreationStart(); + _appDomain = CreateNewAppDomain(testSourcePath); + _actualInvoker = CreateInvokerInAppDomain(_appDomain); - this.appDomain = CreateNewAppDomain(testSourcePath); - this.actualInvoker = CreateInvokerInAppDomain(appDomain); + TestPlatformEventSource.Instance.TestHostAppDomainCreationStop(); + } - TestPlatformEventSource.Instance.TestHostAppDomainCreationStop(); + /// + /// Invokes the Engine with the arguments + /// + /// Arguments for the engine + public void Invoke(IDictionary argsDictionary) + { + try + { + _actualInvoker.Invoke(argsDictionary); } - - /// - /// Invokes the Engine with the arguments - /// - /// Arguments for the engine - public void Invoke(IDictionary argsDictionary) + finally { try { - this.actualInvoker.Invoke(argsDictionary); - } - finally - { - try + //if(appDomain != null) + //{ + // Do not unload appdomain as there are lot is issues reported against appdomain unload + // any ways the process is going to die off. + // AppDomain.Unload(appDomain); + //} + + if (!string.IsNullOrWhiteSpace(_mergedTempConfigFile) && File.Exists(_mergedTempConfigFile)) { - //if(appDomain != null) - //{ - // Do not unload appdomain as there are lot is issues reported against appdomain unload - // any ways the process is going to die off. - // AppDomain.Unload(appDomain); - //} - - if (!string.IsNullOrWhiteSpace(this.mergedTempConfigFile) && File.Exists(mergedTempConfigFile)) - { - File.Delete(mergedTempConfigFile); - } - } - catch - { - // ignore + File.Delete(_mergedTempConfigFile); } } + catch + { + // ignore + } } + } - private AppDomain CreateNewAppDomain(string testSourcePath) - { - var appDomainSetup = new AppDomainSetup(); - var testSourceFolder = Path.GetDirectoryName(testSourcePath); + private AppDomain CreateNewAppDomain(string testSourcePath) + { + var appDomainSetup = new AppDomainSetup(); + var testSourceFolder = Path.GetDirectoryName(testSourcePath); - // Set AppBase to TestAssembly location - appDomainSetup.ApplicationBase = testSourceFolder; - appDomainSetup.LoaderOptimization = LoaderOptimization.MultiDomainHost; + // Set AppBase to TestAssembly location + appDomainSetup.ApplicationBase = testSourceFolder; + appDomainSetup.LoaderOptimization = LoaderOptimization.MultiDomainHost; - // Set User Config file as app domain config - SetConfigurationFile(appDomainSetup, testSourcePath, testSourceFolder); + // Set User Config file as app domain config + SetConfigurationFile(appDomainSetup, testSourcePath, testSourceFolder); - // Create new AppDomain - var appDomain = AppDomain.CreateDomain("TestHostAppDomain", null, appDomainSetup); - - return appDomain; - } + // Create new AppDomain + var appDomain = AppDomain.CreateDomain("TestHostAppDomain", null, appDomainSetup); - /// - /// Create the Engine Invoker in new AppDomain based on test source path - /// - /// Test Source to run/discover tests for - /// Merged config file if there is any merging of test config and test host config - /// - private IEngineInvoker CreateInvokerInAppDomain(AppDomain appDomain) - { - // Create CustomAssembly setup that sets a custom assembly resolver to be able to resolve TestPlatform assemblies - // and also sets the correct UI culture to propagate the dotnet or VS culture to the adapters running in the app domain - appDomain.CreateInstanceFromAndUnwrap( - typeof(CustomAssemblySetup).Assembly.Location, - typeof(CustomAssemblySetup).FullName, - false, - BindingFlags.Default, - null, - new object[] { CultureInfo.DefaultThreadCurrentUICulture?.Name, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) }, - null, - null); - - // Create Invoker object in new appdomain - var invokerType = typeof(T); - return (IEngineInvoker)appDomain.CreateInstanceFromAndUnwrap( - invokerType.Assembly.Location, - invokerType.FullName, - false, - BindingFlags.Default, - null, - null, - null, - null); - } + return appDomain; + } + + /// + /// Create the Engine Invoker in new AppDomain based on test source path + /// + /// Test Source to run/discover tests for + /// Merged config file if there is any merging of test config and test host config + /// + private IEngineInvoker CreateInvokerInAppDomain(AppDomain appDomain) + { + // Create CustomAssembly setup that sets a custom assembly resolver to be able to resolve TestPlatform assemblies + // and also sets the correct UI culture to propagate the dotnet or VS culture to the adapters running in the app domain + appDomain.CreateInstanceFromAndUnwrap( + typeof(CustomAssemblySetup).Assembly.Location, + typeof(CustomAssemblySetup).FullName, + false, + BindingFlags.Default, + null, + new object[] { CultureInfo.DefaultThreadCurrentUICulture?.Name, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) }, + null, + null); + + // Create Invoker object in new appdomain + var invokerType = typeof(T); + return (IEngineInvoker)appDomain.CreateInstanceFromAndUnwrap( + invokerType.Assembly.Location, + invokerType.FullName, + false, + BindingFlags.Default, + null, + null, + null, + null); + } + + private void SetConfigurationFile(AppDomainSetup appDomainSetup, string testSource, string testSourceFolder) + { + var userConfigFile = GetConfigFile(testSource, testSourceFolder); + var testHostAppConfigFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile; - private void SetConfigurationFile(AppDomainSetup appDomainSetup, string testSource, string testSourceFolder) + if (!string.IsNullOrEmpty(userConfigFile)) { - var userConfigFile = GetConfigFile(testSource, testSourceFolder); - var testHostAppConfigFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile; + var userConfigDoc = XDocument.Load(userConfigFile); + var testHostConfigDoc = XDocument.Load(testHostAppConfigFile); - if (!string.IsNullOrEmpty(userConfigFile)) - { - var userConfigDoc = XDocument.Load(userConfigFile); - var testHostConfigDoc = XDocument.Load(testHostAppConfigFile); + // Merge user's config file and testHost config file and use merged one + var mergedConfigDocument = MergeApplicationConfigFiles(userConfigDoc, testHostConfigDoc); - // Merge user's config file and testHost config file and use merged one - var mergedConfigDocument = MergeApplicationConfigFiles(userConfigDoc, testHostConfigDoc); + // Create a temp file with config + _mergedTempConfigFile = Path.GetTempFileName(); + mergedConfigDocument.Save(_mergedTempConfigFile); - // Create a temp file with config - this.mergedTempConfigFile = Path.GetTempFileName(); - mergedConfigDocument.Save(this.mergedTempConfigFile); + // Set config file to merged one + appDomainSetup.ConfigurationFile = _mergedTempConfigFile; + } + else + { + // Use the current domains configuration setting. + appDomainSetup.ConfigurationFile = testHostAppConfigFile; + } + } - // Set config file to merged one - appDomainSetup.ConfigurationFile = this.mergedTempConfigFile; - } - else + private static string GetConfigFile(string testSource, string testSourceFolder) + { + string configFile = null; + + if (File.Exists(testSource + ".config")) + { + // Path to config file cannot be bad: storage is already checked, and extension is valid. + configFile = testSource + ".config"; + } + else + { + var netAppConfigFile = Path.Combine(testSourceFolder, "App.Config"); + if (File.Exists(netAppConfigFile)) { - // Use the current domains configuration setting. - appDomainSetup.ConfigurationFile = testHostAppConfigFile; + configFile = netAppConfigFile; } } - private static string GetConfigFile(string testSource, string testSourceFolder) - { - string configFile = null; + return configFile; + } - if (File.Exists(testSource + ".config")) - { - // Path to config file cannot be bad: storage is already checked, and extension is valid. - configFile = testSource + ".config"; - } - else - { - var netAppConfigFile = Path.Combine(testSourceFolder, "App.Config"); - if (File.Exists(netAppConfigFile)) - { - configFile = netAppConfigFile; - } - } + protected static XDocument MergeApplicationConfigFiles(XDocument userConfigDoc, XDocument testHostConfigDoc) + { + // Start with User's config file as the base + var mergedDoc = new XDocument(userConfigDoc); - return configFile; + // Take testhost.exe Startup node + var startupNode = testHostConfigDoc.Descendants("startup")?.FirstOrDefault(); + if (startupNode != null) + { + // Remove user's startup and add ours which supports NET35 + mergedDoc.Descendants("startup")?.Remove(); + mergedDoc.Root.Add(startupNode); } - protected static XDocument MergeApplicationConfigFiles(XDocument userConfigDoc, XDocument testHostConfigDoc) + // Runtime node must be merged which contains assembly redirections + var runtimeTestHostNode = testHostConfigDoc.Descendants("runtime")?.FirstOrDefault(); + if (runtimeTestHostNode != null) { - // Start with User's config file as the base - var mergedDoc = new XDocument(userConfigDoc); - - // Take testhost.exe Startup node - var startupNode = testHostConfigDoc.Descendants("startup")?.FirstOrDefault(); - if (startupNode != null) + var runTimeNode = mergedDoc.Descendants("runtime")?.FirstOrDefault(); + if (runTimeNode == null) { - // Remove user's startup and add ours which supports NET35 - mergedDoc.Descendants("startup")?.Remove(); - mergedDoc.Root.Add(startupNode); - } + // remove test host relative probing paths' element + // TestHost Probing Paths do not make sense since we are setting "AppBase" to user's test assembly location + runtimeTestHostNode.Descendants().Where((element) => string.Equals(element.Name.LocalName, "probing")).Remove(); - // Runtime node must be merged which contains assembly redirections - var runtimeTestHostNode = testHostConfigDoc.Descendants("runtime")?.FirstOrDefault(); - if (runtimeTestHostNode != null) + // no runtime node exists in user's config - just add ours entirely + mergedDoc.Root.Add(runtimeTestHostNode); + } + else { - var runTimeNode = mergedDoc.Descendants("runtime")?.FirstOrDefault(); - if (runTimeNode == null) - { - // remove test host relative probing paths' element - // TestHost Probing Paths do not make sense since we are setting "AppBase" to user's test assembly location - runtimeTestHostNode.Descendants().Where((element) => string.Equals(element.Name.LocalName, "probing")).Remove(); + var assemblyBindingXName = XName.Get("assemblyBinding", XmlNamespace); + var mergedDocAssemblyBindingNode = mergedDoc.Descendants(assemblyBindingXName)?.FirstOrDefault(); + var testHostAssemblyBindingNode = runtimeTestHostNode.Descendants(assemblyBindingXName)?.FirstOrDefault(); - // no runtime node exists in user's config - just add ours entirely - mergedDoc.Root.Add(runtimeTestHostNode); - } - else + if (testHostAssemblyBindingNode != null) { - var assemblyBindingXName = XName.Get("assemblyBinding", XmlNamespace); - var mergedDocAssemblyBindingNode = mergedDoc.Descendants(assemblyBindingXName)?.FirstOrDefault(); - var testHostAssemblyBindingNode = runtimeTestHostNode.Descendants(assemblyBindingXName)?.FirstOrDefault(); - - if (testHostAssemblyBindingNode != null) + if (mergedDocAssemblyBindingNode == null) { - if (mergedDocAssemblyBindingNode == null) - { - // add another assemblyBinding element as none exists in user's config - runTimeNode.Add(testHostAssemblyBindingNode); - } - else - { - var dependentAssemblyXName = XName.Get("dependentAssembly", XmlNamespace); - var redirections = testHostAssemblyBindingNode.Descendants(dependentAssemblyXName); + // add another assemblyBinding element as none exists in user's config + runTimeNode.Add(testHostAssemblyBindingNode); + } + else + { + var dependentAssemblyXName = XName.Get("dependentAssembly", XmlNamespace); + var redirections = testHostAssemblyBindingNode.Descendants(dependentAssemblyXName); - if (redirections != null) - { - mergedDocAssemblyBindingNode.Add(redirections); - } + if (redirections != null) + { + mergedDocAssemblyBindingNode.Add(redirections); } } } } - - return mergedDoc; } + + return mergedDoc; } +} - /// - /// Custom domain setup that sets UICulture and an Assembly resolver for child app domain to resolve testplatform assemblies - /// - // The normal AppDomainInitializer api was not used to do this because it cannot load the assemblies for testhost. --JJR - internal class CustomAssemblySetup : MarshalByRefObject - { - private readonly IDictionary resolvedAssemblies; +/// +/// Custom domain setup that sets UICulture and an Assembly resolver for child app domain to resolve testplatform assemblies +/// +// The normal AppDomainInitializer api was not used to do this because it cannot load the assemblies for testhost. --JJR +internal class CustomAssemblySetup : MarshalByRefObject +{ + private readonly IDictionary _resolvedAssemblies; - private readonly string[] resolverPaths; + private readonly string[] _resolverPaths; - public CustomAssemblySetup(string uiCulture, string testPlatformPath) + public CustomAssemblySetup(string uiCulture, string testPlatformPath) + { + if (uiCulture != null) { - if (uiCulture != null) - { - CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.CreateSpecificCulture(uiCulture); - } - - this.resolverPaths = new string[] { testPlatformPath, Path.Combine(testPlatformPath, "Extensions") }; - this.resolvedAssemblies = new Dictionary(); - AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; + CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.CreateSpecificCulture(uiCulture); } - private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) - { - var assemblyName = new AssemblyName(args.Name); + _resolverPaths = new string[] { testPlatformPath, Path.Combine(testPlatformPath, "Extensions") }; + _resolvedAssemblies = new Dictionary(); + AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; + } + + private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) + { + var assemblyName = new AssemblyName(args.Name); - Assembly assembly = null; - lock (resolvedAssemblies) + Assembly assembly = null; + lock (_resolvedAssemblies) + { + try { - try - { - EqtTrace.Verbose("CurrentDomain_AssemblyResolve: Resolving assembly '{0}'.", args.Name); + EqtTrace.Verbose("CurrentDomain_AssemblyResolve: Resolving assembly '{0}'.", args.Name); - if (resolvedAssemblies.TryGetValue(args.Name, out assembly)) - { - return assembly; - } + if (_resolvedAssemblies.TryGetValue(args.Name, out assembly)) + { + return assembly; + } - // Put it in the resolved assembly so that if below Assembly.Load call - // triggers another assembly resolution, then we don't end up in stack overflow - resolvedAssemblies[args.Name] = null; + // Put it in the resolved assembly so that if below Assembly.Load call + // triggers another assembly resolution, then we don't end up in stack overflow + _resolvedAssemblies[args.Name] = null; - foreach (var path in resolverPaths) + foreach (var path in _resolverPaths) + { + var testPlatformFilePath = Path.Combine(path, assemblyName.Name) + ".dll"; + if (File.Exists(testPlatformFilePath)) { - var testPlatformFilePath = Path.Combine(path, assemblyName.Name) + ".dll"; - if (File.Exists(testPlatformFilePath)) + try { - try - { - assembly = Assembly.LoadFrom(testPlatformFilePath); - break; - } - catch (Exception) - { - // ignore - } + assembly = Assembly.LoadFrom(testPlatformFilePath); + break; + } + catch (Exception) + { + // ignore } } + } - // Replace the value with the loaded assembly - resolvedAssemblies[args.Name] = assembly; + // Replace the value with the loaded assembly + _resolvedAssemblies[args.Name] = assembly; - return assembly; - } - finally + return assembly; + } + finally + { + if (null == assembly) { - if (null == assembly) - { - EqtTrace.Verbose("CurrentDomainAssemblyResolve: Failed to resolve assembly '{0}'.", args.Name); - } + EqtTrace.Verbose("CurrentDomainAssemblyResolve: Failed to resolve assembly '{0}'.", args.Name); } } } } -#endif -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/testhost.x86/DebugAssertException.cs b/src/testhost.x86/DebugAssertException.cs index 1255f5898e..8bbd30b28a 100644 --- a/src/testhost.x86/DebugAssertException.cs +++ b/src/testhost.x86/DebugAssertException.cs @@ -1,17 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.TestHost -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.TestHost; - internal sealed class DebugAssertException : Exception - { - public DebugAssertException(string message, string stackTrace) : base(message) - { - StackTrace = stackTrace; - } +using System; - public override string StackTrace { get; } +internal sealed class DebugAssertException : Exception +{ + public DebugAssertException(string message, string stackTrace) : base(message) + { + StackTrace = stackTrace; } -} + + public override string StackTrace { get; } +} \ No newline at end of file diff --git a/src/testhost.x86/DefaultEngineInvoker.cs b/src/testhost.x86/DefaultEngineInvoker.cs index dc36ca08ea..6a92b2a6d8 100644 --- a/src/testhost.x86/DefaultEngineInvoker.cs +++ b/src/testhost.x86/DefaultEngineInvoker.cs @@ -1,306 +1,313 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.TestHost -{ - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Net; - using System.Reflection; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using PlatformAbstractions.Interfaces; - using CommunicationUtilitiesResources = - Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources.Resources; - using CoreUtilitiesConstants = Microsoft.VisualStudio.TestPlatform.CoreUtilities.Constants; - - internal class DefaultEngineInvoker : +namespace Microsoft.VisualStudio.TestPlatform.TestHost; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Net; +using System.Reflection; +using System.Threading; +using System.Threading.Tasks; + +using Common; +using Common.Telemetry; + +using CommunicationUtilities; +using CommunicationUtilities.Interfaces; + +using CoreUtilities.Helpers; + +using CrossPlatEngine; + +using ObjectModel; +using ObjectModel.Client; +using ObjectModel.Engine.TesthostProtocol; + +using PlatformAbstractions; + +using PlatformAbstractions.Interfaces; + +using CommunicationUtilitiesResources = + CommunicationUtilities.Resources.Resources; +using CoreUtilitiesConstants = CoreUtilities.Constants; + +internal class DefaultEngineInvoker : #if NETFRAMEWORK - MarshalByRefObject, + MarshalByRefObject, #endif - IEngineInvoker - { - /// - /// The timeout for the client to connect to the server. - /// Increasing Timeout to allow client to connect, not always the client can connect within 5 seconds - /// - private const int ClientListenTimeOut = Timeout.Infinite; + IEngineInvoker +{ + /// + /// The timeout for the client to connect to the server. + /// Increasing Timeout to allow client to connect, not always the client can connect within 5 seconds + /// + private const int ClientListenTimeOut = Timeout.Infinite; - private const string EndpointArgument = "--endpoint"; + private const string EndpointArgument = "--endpoint"; - private const string RoleArgument = "--role"; + private const string RoleArgument = "--role"; - private const string ParentProcessIdArgument = "--parentprocessid"; + private const string ParentProcessIdArgument = "--parentprocessid"; - private const string LogFileArgument = "--diag"; + private const string LogFileArgument = "--diag"; - private const string TraceLevelArgument = "--tracelevel"; + private const string TraceLevelArgument = "--tracelevel"; - private const string DataCollectionPortArgument = "--datacollectionport"; + private const string DataCollectionPortArgument = "--datacollectionport"; - private const string TelemetryOptedIn = "--telemetryoptedin"; + private const string TelemetryOptedIn = "--telemetryoptedin"; - private ITestRequestHandler requestHandler; + private readonly ITestRequestHandler _requestHandler; - private IDataCollectionTestCaseEventSender dataCollectionTestCaseEventSender; + private readonly IDataCollectionTestCaseEventSender _dataCollectionTestCaseEventSender; - private IProcessHelper processHelper; + private readonly IProcessHelper _processHelper; - public DefaultEngineInvoker() : this(new TestRequestHandler(), DataCollectionTestCaseEventSender.Create(), new ProcessHelper()) - { - } + public DefaultEngineInvoker() : this(new TestRequestHandler(), DataCollectionTestCaseEventSender.Create(), new ProcessHelper()) + { + } + + internal DefaultEngineInvoker(ITestRequestHandler requestHandler, + IDataCollectionTestCaseEventSender dataCollectionTestCaseEventSender, IProcessHelper processHelper) + { + _processHelper = processHelper; + _requestHandler = requestHandler; + _dataCollectionTestCaseEventSender = dataCollectionTestCaseEventSender; + } + + public void Invoke(IDictionary argsDictionary) + { + InitializeEqtTrace(argsDictionary); - internal DefaultEngineInvoker(ITestRequestHandler requestHandler, - IDataCollectionTestCaseEventSender dataCollectionTestCaseEventSender, IProcessHelper processHelper) + if (EqtTrace.IsVerboseEnabled) { - this.processHelper = processHelper; - this.requestHandler = requestHandler; - this.dataCollectionTestCaseEventSender = dataCollectionTestCaseEventSender; + var version = typeof(DefaultEngineInvoker) + .GetTypeInfo() + .Assembly + .GetCustomAttribute()?.InformationalVersion; + EqtTrace.Verbose($"Version: { version }"); } - public void Invoke(IDictionary argsDictionary) + if (EqtTrace.IsInfoEnabled) { - DefaultEngineInvoker.InitializeEqtTrace(argsDictionary); - - if (EqtTrace.IsVerboseEnabled) - { - var version = typeof(DefaultEngineInvoker) - .GetTypeInfo() - .Assembly - .GetCustomAttribute()?.InformationalVersion; - EqtTrace.Verbose($"Version: { version }"); - } - - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DefaultEngineInvoker.Invoke: Testhost process started with args :{0}", - string.Join(",", argsDictionary)); + EqtTrace.Info("DefaultEngineInvoker.Invoke: Testhost process started with args :{0}", + string.Join(",", argsDictionary)); #if NETFRAMEWORK - var appConfigText = - System.IO.File.ReadAllText(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); - EqtTrace.Info("DefaultEngineInvoker: Using Application Configuration: '{0}'", appConfigText); + var appConfigText = + System.IO.File.ReadAllText(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); + EqtTrace.Info("DefaultEngineInvoker: Using Application Configuration: '{0}'", appConfigText); #endif - } + } #if NETCOREAPP - TestHostTraceListener.Setup(); + TestHostTraceListener.Setup(); #endif - this.SetParentProcessExitCallback(argsDictionary); + SetParentProcessExitCallback(argsDictionary); - this.requestHandler.ConnectionInfo = - DefaultEngineInvoker.GetConnectionInfo(argsDictionary); + _requestHandler.ConnectionInfo = + GetConnectionInfo(argsDictionary); - // Initialize Communication with vstest.console - this.requestHandler.InitializeCommunication(); + // Initialize Communication with vstest.console + _requestHandler.InitializeCommunication(); - // skipping because 0 is the default value, and also the value the the callers use when they - // call with the parameter specified, but without providing an actual port - var dcPort = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, DataCollectionPortArgument); - if (dcPort > 0) - { - this.ConnectToDatacollector(dcPort); - } + // skipping because 0 is the default value, and also the value the the callers use when they + // call with the parameter specified, but without providing an actual port + var dcPort = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, DataCollectionPortArgument); + if (dcPort > 0) + { + ConnectToDatacollector(dcPort); + } - var requestData = DefaultEngineInvoker.GetRequestData(argsDictionary); + var requestData = GetRequestData(argsDictionary); - // Start processing async in a different task - EqtTrace.Info("DefaultEngineInvoker.Invoke: Start Request Processing."); - try - { - this.StartProcessingAsync(requestHandler, new TestHostManagerFactory(requestData)).Wait(); - } - finally - { - if (dcPort > 0) - { - // Close datacollector communication. - this.dataCollectionTestCaseEventSender.Close(); - } - - this.requestHandler.Dispose(); - } + // Start processing async in a different task + EqtTrace.Info("DefaultEngineInvoker.Invoke: Start Request Processing."); + try + { + StartProcessingAsync(_requestHandler, new TestHostManagerFactory(requestData)).Wait(); } - - private static RequestData GetRequestData(IDictionary argsDictionary) + finally { - // Checks for Telemetry Opted in or not from Command line Arguments. - // By Default opting out in Test Host to handle scenario when user running old version of vstest.console - var telemetryStatus = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, TelemetryOptedIn); - var telemetryOptedIn = false; - if (!string.IsNullOrWhiteSpace(telemetryStatus)) + if (dcPort > 0) { - if (telemetryStatus.Equals("true", StringComparison.Ordinal)) - { - telemetryOptedIn = true; - } + // Close datacollector communication. + _dataCollectionTestCaseEventSender.Close(); } - var requestData = new RequestData - { - MetricsCollection = - telemetryOptedIn - ? (IMetricsCollection)new MetricsCollection() - : new NoOpMetricsCollection(), - IsTelemetryOptedIn = telemetryOptedIn - }; - return requestData; + _requestHandler.Dispose(); } + } - private void ConnectToDatacollector(int dcPort) + private static RequestData GetRequestData(IDictionary argsDictionary) + { + // Checks for Telemetry Opted in or not from Command line Arguments. + // By Default opting out in Test Host to handle scenario when user running old version of vstest.console + var telemetryStatus = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, TelemetryOptedIn); + var telemetryOptedIn = false; + if (!string.IsNullOrWhiteSpace(telemetryStatus)) { - EqtTrace.Info("DefaultEngineInvoker.ConnectToDatacollector: Connecting to datacollector, port: {0}", - dcPort); - this.dataCollectionTestCaseEventSender.InitializeCommunication(dcPort); - - // It's possible that connection to vstest.console happens, but to datacollector fails, why? - // DataCollector keeps the server alive for testhost only for 15secs(increased to 90 now), - // if somehow(on slower machines, with Profiler Enabled) testhost can take considerable time to launch, - // in such scenario dc.exe would have killed the server, but testhost will wait infinitely to connect to it, - // hence do not wait to connect to datacollector process infinitely, as it will cause process hang. - var timeout = EnvironmentHelper.GetConnectionTimeout(); - if (!this.dataCollectionTestCaseEventSender.WaitForRequestSenderConnection(timeout * 1000)) + if (telemetryStatus.Equals("true", StringComparison.Ordinal)) { - EqtTrace.Error( - "DefaultEngineInvoker.ConnectToDatacollector: Connection to DataCollector failed: '{0}', DataCollection will not happen in this session", - dcPort); - throw new TestPlatformException( - string.Format( - CultureInfo.CurrentUICulture, - CommunicationUtilitiesResources.ConnectionTimeoutErrorMessage, - CoreUtilitiesConstants.TesthostProcessName, - CoreUtilitiesConstants.DatacollectorProcessName, - timeout, - EnvironmentHelper.VstestConnectionTimeout) - ); + telemetryOptedIn = true; } } - private void SetParentProcessExitCallback(IDictionary argsDictionary) + var requestData = new RequestData { - // Attach to exit of parent process - var hasParentProcessArgument = CommandLineArgumentsHelper.TryGetIntArgFromDict(argsDictionary, ParentProcessIdArgument, out var parentProcessId); + MetricsCollection = + telemetryOptedIn + ? (IMetricsCollection)new MetricsCollection() + : new NoOpMetricsCollection(), + IsTelemetryOptedIn = telemetryOptedIn + }; + return requestData; + } - if (!hasParentProcessArgument) - { - throw new ArgumentException($"Argument {ParentProcessIdArgument} was not specified."); - } + private void ConnectToDatacollector(int dcPort) + { + EqtTrace.Info("DefaultEngineInvoker.ConnectToDatacollector: Connecting to datacollector, port: {0}", + dcPort); + _dataCollectionTestCaseEventSender.InitializeCommunication(dcPort); + + // It's possible that connection to vstest.console happens, but to datacollector fails, why? + // DataCollector keeps the server alive for testhost only for 15secs(increased to 90 now), + // if somehow(on slower machines, with Profiler Enabled) testhost can take considerable time to launch, + // in such scenario dc.exe would have killed the server, but testhost will wait infinitely to connect to it, + // hence do not wait to connect to datacollector process infinitely, as it will cause process hang. + var timeout = EnvironmentHelper.GetConnectionTimeout(); + if (!_dataCollectionTestCaseEventSender.WaitForRequestSenderConnection(timeout * 1000)) + { + EqtTrace.Error( + "DefaultEngineInvoker.ConnectToDatacollector: Connection to DataCollector failed: '{0}', DataCollection will not happen in this session", + dcPort); + throw new TestPlatformException( + string.Format( + CultureInfo.CurrentUICulture, + CommunicationUtilitiesResources.ConnectionTimeoutErrorMessage, + CoreUtilitiesConstants.TesthostProcessName, + CoreUtilitiesConstants.DatacollectorProcessName, + timeout, + EnvironmentHelper.VstestConnectionTimeout) + ); + } + } - EqtTrace.Info("DefaultEngineInvoker.SetParentProcessExitCallback: Monitoring parent process with id: '{0}'", parentProcessId); + private void SetParentProcessExitCallback(IDictionary argsDictionary) + { + // Attach to exit of parent process + var hasParentProcessArgument = CommandLineArgumentsHelper.TryGetIntArgFromDict(argsDictionary, ParentProcessIdArgument, out var parentProcessId); - if (parentProcessId == -1) - { - // In remote scenario we cannot monitor parent process, so we expect user to pass parentProcessId as -1 - return; - } + if (!hasParentProcessArgument) + { + throw new ArgumentException($"Argument {ParentProcessIdArgument} was not specified."); + } - if (parentProcessId == 0) - { - //TODO: should there be a warning / error in this case, on windows and linux we are most likely not started by this PID 0, because it's Idle process on Windows, and Swapper on Linux, and similarly in docker - // Trying to attach to 0 will cause access denied error on Windows - } + EqtTrace.Info("DefaultEngineInvoker.SetParentProcessExitCallback: Monitoring parent process with id: '{0}'", parentProcessId); - this.processHelper.SetExitCallback( - parentProcessId, - (obj) => - { - EqtTrace.Info("DefaultEngineInvoker.SetParentProcessExitCallback: ParentProcess '{0}' Exited.", - parentProcessId); - new PlatformEnvironment().Exit(1); - }); + if (parentProcessId == -1) + { + // In remote scenario we cannot monitor parent process, so we expect user to pass parentProcessId as -1 + return; } - private static TestHostConnectionInfo GetConnectionInfo(IDictionary argsDictionary) + if (parentProcessId == 0) { - // vstest.console < 15.5 won't send endpoint and role arguments. - // So derive endpoint from port argument and Make connectionRole as Client. - var endpoint = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, EndpointArgument); - if (string.IsNullOrWhiteSpace(endpoint)) - { - var port = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, "--port"); - endpoint = IPAddress.Loopback + ":" + port; - } - - EqtTrace.Info("DefaultEngineInvoker.GetConnectionInfo: Initialize communication on endpoint address: '{0}'", endpoint); + //TODO: should there be a warning / error in this case, on windows and linux we are most likely not started by this PID 0, because it's Idle process on Windows, and Swapper on Linux, and similarly in docker + // Trying to attach to 0 will cause access denied error on Windows + } - var connectionRole = ConnectionRole.Client; - string role = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, RoleArgument); - if (!string.IsNullOrWhiteSpace(role) && string.Equals(role, "host", StringComparison.OrdinalIgnoreCase)) + _processHelper.SetExitCallback( + parentProcessId, + (obj) => { - connectionRole = ConnectionRole.Host; - } + EqtTrace.Info("DefaultEngineInvoker.SetParentProcessExitCallback: ParentProcess '{0}' Exited.", + parentProcessId); + new PlatformEnvironment().Exit(1); + }); + } - // Start Processing of requests - var connectionInfo = new TestHostConnectionInfo - { - Endpoint = endpoint, - Role = connectionRole, - Transport = Transport.Sockets - }; + private static TestHostConnectionInfo GetConnectionInfo(IDictionary argsDictionary) + { + // vstest.console < 15.5 won't send endpoint and role arguments. + // So derive endpoint from port argument and Make connectionRole as Client. + var endpoint = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, EndpointArgument); + if (string.IsNullOrWhiteSpace(endpoint)) + { + var port = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, "--port"); + endpoint = IPAddress.Loopback + ":" + port; + } + + EqtTrace.Info("DefaultEngineInvoker.GetConnectionInfo: Initialize communication on endpoint address: '{0}'", endpoint); - return connectionInfo; + var connectionRole = ConnectionRole.Client; + string role = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, RoleArgument); + if (!string.IsNullOrWhiteSpace(role) && string.Equals(role, "host", StringComparison.OrdinalIgnoreCase)) + { + connectionRole = ConnectionRole.Host; } - private static void InitializeEqtTrace(IDictionary argsDictionary) + // Start Processing of requests + var connectionInfo = new TestHostConnectionInfo { - // Setup logging if enabled - if (argsDictionary.TryGetValue(LogFileArgument, out var logFile)) - { - var traceLevelInt = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, TraceLevelArgument); + Endpoint = endpoint, + Role = connectionRole, + Transport = Transport.Sockets + }; - // In case traceLevelInt is not defined in PlatfromTraceLevel, default it to verbose. - var traceLevel = Enum.IsDefined(typeof(PlatformTraceLevel), traceLevelInt) ? - (PlatformTraceLevel)traceLevelInt : - PlatformTraceLevel.Verbose; + return connectionInfo; + } - EqtTrace.InitializeTrace(logFile, traceLevel); - } - else - { - EqtTrace.DoNotInitailize = true; - } - } + private static void InitializeEqtTrace(IDictionary argsDictionary) + { + // Setup logging if enabled + if (argsDictionary.TryGetValue(LogFileArgument, out var logFile)) + { + var traceLevelInt = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, TraceLevelArgument); - private Task StartProcessingAsync(ITestRequestHandler requestHandler, ITestHostManagerFactory managerFactory) + // In case traceLevelInt is not defined in PlatfromTraceLevel, default it to verbose. + var traceLevel = Enum.IsDefined(typeof(PlatformTraceLevel), traceLevelInt) ? + (PlatformTraceLevel)traceLevelInt : + PlatformTraceLevel.Verbose; + + EqtTrace.InitializeTrace(logFile, traceLevel); + } + else { - var task = new Task( - () => - { - // Wait for the connection to the sender and start processing requests from sender - // Note that we are waiting here infinitely to connect to vstest.console, but at the same time vstest.console doesn't wait infinitely. - // It has a default timeout of 60secs(which is configurable), & then it kills testhost.exe - // The reason to wait infinitely, was remote debugging scenarios of UWP app, - // in such cases after the app gets launched, VS debugger takes control of it, & causes a lot of delay, which frequently causes timeout with vstest.console. - // One fix would be just double this timeout, but there is no telling how much time it can actually take. - // Hence we are waiting here indefinitely, to avoid such guessed timeouts, & letting user kill the debugging if they feel it is taking too much time. - // In other cases if vstest.console's timeout exceeds it will definitely such down the app. - if (requestHandler.WaitForRequestSenderConnection(ClientListenTimeOut)) - { - EqtTrace.Info("DefaultEngineInvoker.StartProcessingAsync: Connected to vstest.console, Starting process requests."); - requestHandler.ProcessRequests(managerFactory); - } - else - { - EqtTrace.Info( - "DefaultEngineInvoker.StartProcessingAsync: RequestHandler timed out while connecting to the Sender."); - throw new TimeoutException(); - } - }, - TaskCreationOptions.LongRunning); - - task.Start(); - return task; + EqtTrace.DoNotInitailize = true; } } + + private Task StartProcessingAsync(ITestRequestHandler requestHandler, ITestHostManagerFactory managerFactory) + { + var task = new Task( + () => + { + // Wait for the connection to the sender and start processing requests from sender + // Note that we are waiting here infinitely to connect to vstest.console, but at the same time vstest.console doesn't wait infinitely. + // It has a default timeout of 60secs(which is configurable), & then it kills testhost.exe + // The reason to wait infinitely, was remote debugging scenarios of UWP app, + // in such cases after the app gets launched, VS debugger takes control of it, & causes a lot of delay, which frequently causes timeout with vstest.console. + // One fix would be just double this timeout, but there is no telling how much time it can actually take. + // Hence we are waiting here indefinitely, to avoid such guessed timeouts, & letting user kill the debugging if they feel it is taking too much time. + // In other cases if vstest.console's timeout exceeds it will definitely such down the app. + if (requestHandler.WaitForRequestSenderConnection(ClientListenTimeOut)) + { + EqtTrace.Info("DefaultEngineInvoker.StartProcessingAsync: Connected to vstest.console, Starting process requests."); + requestHandler.ProcessRequests(managerFactory); + } + else + { + EqtTrace.Info( + "DefaultEngineInvoker.StartProcessingAsync: RequestHandler timed out while connecting to the Sender."); + throw new TimeoutException(); + } + }, + TaskCreationOptions.LongRunning); + + task.Start(); + return task; + } } \ No newline at end of file diff --git a/src/testhost.x86/IEngineInvoker.cs b/src/testhost.x86/IEngineInvoker.cs index c37ddf0cb2..03bad5f507 100644 --- a/src/testhost.x86/IEngineInvoker.cs +++ b/src/testhost.x86/IEngineInvoker.cs @@ -1,19 +1,18 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.TestHost -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.TestHost; + +using System.Collections.Generic; +/// +/// Interface contract for invoking the engine +/// +public interface IEngineInvoker +{ /// - /// Interface contract for invoking the engine + /// Invokes the Engine with the arguments /// - public interface IEngineInvoker - { - /// - /// Invokes the Engine with the arguments - /// - /// Arguments for the engine - void Invoke(IDictionary argsDictionary); - } -} + /// Arguments for the engine + void Invoke(IDictionary argsDictionary); +} \ No newline at end of file diff --git a/src/testhost.x86/Program.cs b/src/testhost.x86/Program.cs index 7b97a43d3f..6f4c477eef 100644 --- a/src/testhost.x86/Program.cs +++ b/src/testhost.x86/Program.cs @@ -1,87 +1,84 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.TestHost +namespace Microsoft.VisualStudio.TestPlatform.TestHost; + +using System; +using System.Collections.Generic; + +using CoreUtilities.Helpers; +using CoreUtilities.Tracing; + +using Execution; + +using ObjectModel; + +/// +/// The program. +/// +public class Program { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Globalization; - using System.Runtime.InteropServices; - using System.Threading.Tasks; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing; - using Microsoft.VisualStudio.TestPlatform.Execution; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + private const string TestSourceArgumentString = "--testsourcepath"; /// - /// The program. + /// The main. /// - public class Program + /// + /// The args. + /// + public static void Main(string[] args) { - private const string TestSourceArgumentString = "--testsourcepath"; - - /// - /// The main. - /// - /// - /// The args. - /// - public static void Main(string[] args) + try { - try - { - TestPlatformEventSource.Instance.TestHostStart(); - Run(args); - } - catch (Exception ex) - { - EqtTrace.Error("TestHost: Error occurred during initialization of TestHost : {0}", ex); - - // Throw exception so that vstest.console get the exception message. - throw; - } - finally - { - TestPlatformEventSource.Instance.TestHostStop(); - EqtTrace.Info("Testhost process exiting."); - } + TestPlatformEventSource.Instance.TestHostStart(); + Run(args); } - - // In UWP(App models) Run will act as entry point from Application end, so making this method public - public static void Run(string[] args) + catch (Exception ex) { - DebuggerBreakpoint.AttachVisualStudioDebugger("VSTEST_HOST_DEBUG_ATTACHVS"); - DebuggerBreakpoint.WaitForNativeDebugger("VSTEST_HOST_NATIVE_DEBUG"); - DebuggerBreakpoint.WaitForDebugger("VSTEST_HOST_DEBUG"); - UILanguageOverride.SetCultureSpecifiedByUser(); - var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args); + EqtTrace.Error("TestHost: Error occurred during initialization of TestHost : {0}", ex); - // Invoke the engine with arguments - GetEngineInvoker(argsDictionary).Invoke(argsDictionary); + // Throw exception so that vstest.console get the exception message. + throw; } - - private static IEngineInvoker GetEngineInvoker(IDictionary argsDictionary) + finally { - IEngineInvoker invoker = null; + TestPlatformEventSource.Instance.TestHostStop(); + EqtTrace.Info("Testhost process exiting."); + } + } + + // In UWP(App models) Run will act as entry point from Application end, so making this method public + public static void Run(string[] args) + { + DebuggerBreakpoint.AttachVisualStudioDebugger("VSTEST_HOST_DEBUG_ATTACHVS"); + DebuggerBreakpoint.WaitForNativeDebugger("VSTEST_HOST_NATIVE_DEBUG"); + DebuggerBreakpoint.WaitForDebugger("VSTEST_HOST_DEBUG"); + UiLanguageOverride.SetCultureSpecifiedByUser(); + var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args); + + // Invoke the engine with arguments + GetEngineInvoker(argsDictionary).Invoke(argsDictionary); + } + + private static IEngineInvoker GetEngineInvoker(IDictionary argsDictionary) + { + IEngineInvoker invoker = null; #if NETFRAMEWORK - // If Args contains test source argument, invoker Engine in new appdomain - if (argsDictionary.TryGetValue(TestSourceArgumentString, out var testSourcePath) && !string.IsNullOrWhiteSpace(testSourcePath)) - { - // remove the test source arg from dictionary - argsDictionary.Remove(TestSourceArgumentString); + // If Args contains test source argument, invoker Engine in new appdomain + if (argsDictionary.TryGetValue(TestSourceArgumentString, out var testSourcePath) && !string.IsNullOrWhiteSpace(testSourcePath)) + { + // remove the test source arg from dictionary + argsDictionary.Remove(TestSourceArgumentString); - // Only DLLs and EXEs can have app.configs or ".exe.config" or ".dll.config" - if (System.IO.File.Exists(testSourcePath) && - (testSourcePath.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) - || testSourcePath.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))) - { - invoker = new AppDomainEngineInvoker(testSourcePath); - } + // Only DLLs and EXEs can have app.configs or ".exe.config" or ".dll.config" + if (System.IO.File.Exists(testSourcePath) && + (testSourcePath.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) + || testSourcePath.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))) + { + invoker = new AppDomainEngineInvoker(testSourcePath); } -#endif - return invoker ?? new DefaultEngineInvoker(); } +#endif + return invoker ?? new DefaultEngineInvoker(); } -} +} \ No newline at end of file diff --git a/src/testhost.x86/TestHostTraceListener.cs b/src/testhost.x86/TestHostTraceListener.cs index 423dc1a947..9ca611f8fb 100644 --- a/src/testhost.x86/TestHostTraceListener.cs +++ b/src/testhost.x86/TestHostTraceListener.cs @@ -2,129 +2,128 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.TestHost -{ +namespace Microsoft.VisualStudio.TestPlatform.TestHost; #if NETCOREAPP - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using System; - using System.Diagnostics; - using System.Linq; - using System.Reflection; +using ObjectModel; + +using System; +using System.Diagnostics; +using System.Linq; +using System.Reflection; - internal class TestHostTraceListener : DefaultTraceListener +internal class TestHostTraceListener : DefaultTraceListener +{ + public static void Setup() { - public static void Setup() + EqtTrace.Info("Setting up debug trace listener."); + // in the majority of cases there will be only a single DefaultTraceListener in this collection + // and we will replace that with our listener, in case there are listeners of different types we keep + // them as is + for (var i = 0; i < Trace.Listeners.Count; i++) { - EqtTrace.Info("Setting up debug trace listener."); - // in the majority of cases there will be only a single DefaultTraceListener in this collection - // and we will replace that with our listener, in case there are listeners of different types we keep - // them as is - for (var i = 0; i < Trace.Listeners.Count; i++) + var listener = Trace.Listeners[i]; + if (listener is DefaultTraceListener) { - var listener = Trace.Listeners[i]; - if (listener is DefaultTraceListener) - { - EqtTrace.Verbose($"TestPlatformTraceListener.Setup: Replacing listener {0} with { nameof(TestHostTraceListener) }.", Trace.Listeners[i]); - Trace.Listeners[i] = new TestHostTraceListener(); - } + EqtTrace.Verbose($"TestPlatformTraceListener.Setup: Replacing listener {0} with { nameof(TestHostTraceListener) }.", Trace.Listeners[i]); + Trace.Listeners[i] = new TestHostTraceListener(); } + } - EqtTrace.Verbose("TestPlatformTraceListener.Setup: Added test platform trace listener."); + EqtTrace.Verbose("TestPlatformTraceListener.Setup: Added test platform trace listener."); - // this is a netcoreapp2.1 only fix, but because we always compile against netcoreapp2.1 - // and upgrade the executable as necessary this needs to be a runtime check and not a compile time - // check. This call returns ".NET Core 4.6.xxx" on netcore 2.1 and older, and ".NET Core 3.1.xxx" - // or the respective version on the newer runtimes - if (System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription.StartsWith(".NET Core 4.6")) + // this is a netcoreapp2.1 only fix, but because we always compile against netcoreapp2.1 + // and upgrade the executable as necessary this needs to be a runtime check and not a compile time + // check. This call returns ".NET Core 4.6.xxx" on netcore 2.1 and older, and ".NET Core 3.1.xxx" + // or the respective version on the newer runtimes + if (System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription.StartsWith(".NET Core 4.6")) + { + try { - try + // workaround for netcoreapp2.1 where the trace listener api is not called when + // Debug.Assert fails. This method is internal, but the class is on purpose keeping the + // callback settable so tests can set the callback + var field = typeof(Debug).GetField("s_ShowDialog", BindingFlags.Static | BindingFlags.NonPublic); + if (field != null) { - // workaround for netcoreapp2.1 where the trace listener api is not called when - // Debug.Assert fails. This method is internal, but the class is on purpose keeping the - // callback settable so tests can set the callback - var field = typeof(Debug).GetField("s_ShowDialog", BindingFlags.Static | BindingFlags.NonPublic); - if (field != null) - { - var value = field.GetValue(null); - field.SetValue(null, (Action)ShowDialog); - } - } - catch (Exception ex) - { - EqtTrace.Error("TestPlatformTraceListener.Setup: Failed to replace inner callback to ShowDialog in Debug.Assert. Calls to Debug.Assert with crash the test host process. {0}", ex); + var value = field.GetValue(null); + field.SetValue(null, (Action)ShowDialog); } } + catch (Exception ex) + { + EqtTrace.Error("TestPlatformTraceListener.Setup: Failed to replace inner callback to ShowDialog in Debug.Assert. Calls to Debug.Assert with crash the test host process. {0}", ex); + } } + } - public override void Fail(string message) - { - throw GetException(message); - } + public override void Fail(string message) + { + throw GetException(message); + } - public override void Fail(string message, string detailMessage) - { - throw GetException((message + Environment.NewLine + detailMessage)); - } + public override void Fail(string message, string detailMessage) + { + throw GetException((message + Environment.NewLine + detailMessage)); + } + + public static void ShowDialog(string stackTrace, string message, string detailMessage, string _) + { + var text = !string.IsNullOrEmpty(message) + ? !string.IsNullOrEmpty(detailMessage) + ? (message + Environment.NewLine + detailMessage) + : message + : null; + throw GetException(text); + } - public static void ShowDialog(string stackTrace, string message, string detailMessage, string _) + private static DebugAssertException GetException(string message) + { + var debugTypes = new Type[] { typeof(Debug), typeof(Trace) }; +#if NETCOREAPP1_0 + Exception exceptionForStack; + try { - var text = !string.IsNullOrEmpty(message) - ? !string.IsNullOrEmpty(detailMessage) - ? (message + Environment.NewLine + detailMessage) - : message - : null; - throw GetException(text); + throw new Exception(); } - - private static DebugAssertException GetException(string message) + catch (Exception e) { - var debugTypes = new Type[] { typeof(Debug), typeof(Trace) }; -#if NETCOREAPP1_0 - Exception exceptionForStack; - try - { - throw new Exception(); - } - catch (Exception e) - { - exceptionForStack = e; - } + exceptionForStack = e; + } - var stack = new StackTrace(exceptionForStack, true); + var stack = new StackTrace(exceptionForStack, true); #else - var stack = new StackTrace(true); + var stack = new StackTrace(true); #endif - var debugMethodFound = false; - var frameCount = 0; - MethodBase method = null; - foreach (var f in stack.GetFrames()) + var debugMethodFound = false; + var frameCount = 0; + MethodBase method = null; + foreach (var f in stack.GetFrames()) + { + var m = f.GetMethod(); + var declaringType = m?.DeclaringType; + if (!debugMethodFound && (declaringType == typeof(Debug) || declaringType == typeof(Trace))) { - var m = f.GetMethod(); - var declaringType = m?.DeclaringType; - if (!debugMethodFound && (declaringType == typeof(Debug) || declaringType == typeof(Trace))) - { - method = m; - debugMethodFound = true; - } + method = m; + debugMethodFound = true; + } - if (debugMethodFound) - { - frameCount++; - } + if (debugMethodFound) + { + frameCount++; } + } #if NETCOREAPP1_0 - var stackTrace = string.Join(Environment.NewLine, stack.ToString().Replace(Environment.NewLine, "\n").Split('\n').Reverse().Take(frameCount).Reverse()); + var stackTrace = string.Join(Environment.NewLine, stack.ToString().Replace(Environment.NewLine, "\n").Split('\n').Reverse().Take(frameCount).Reverse()); #else - var stackTrace = string.Join(Environment.NewLine, stack.ToString().Split(Environment.NewLine).TakeLast(frameCount)); + var stackTrace = string.Join(Environment.NewLine, stack.ToString().Split(Environment.NewLine).TakeLast(frameCount)); #endif - var methodName = method != null ? $"{method.DeclaringType.Name}.{method.Name}" : ""; - var wholeMessage = $"Method {methodName} failed with '{message}', and was translated to { typeof(DebugAssertException).FullName } to avoid terminating the process hosting the test."; + var methodName = method != null ? $"{method.DeclaringType.Name}.{method.Name}" : ""; + var wholeMessage = $"Method {methodName} failed with '{message}', and was translated to { typeof(DebugAssertException).FullName } to avoid terminating the process hosting the test."; - return new DebugAssertException(wholeMessage, stackTrace); - } + return new DebugAssertException(wholeMessage, stackTrace); } +} -#endif -} \ No newline at end of file +#endif \ No newline at end of file diff --git a/src/testhost.x86/UnitTestClient.cs b/src/testhost.x86/UnitTestClient.cs index ee1e02d6bc..c75c3f8cd4 100644 --- a/src/testhost.x86/UnitTestClient.cs +++ b/src/testhost.x86/UnitTestClient.cs @@ -1,63 +1,60 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.TestExecutor +namespace Microsoft.VisualStudio.TestPlatform.TestExecutor; + +using System.Threading.Tasks; + +using TestHost; + +/// +/// Initialization point for Old UWP application +/// +public static class UnitTestClient { - using System.Threading.Tasks; - using Microsoft.VisualStudio.TestPlatform.TestHost; + /// + /// Create default UI for UWP app + /// + public static void CreateDefaultUI() + { + } /// - /// Initialization point for Old UWP application + /// Entry point for testhost, in App Model(UWP) scenario /// - public static class UnitTestClient + /// testhost initialization arguments + public static void Run(string arguments) { - /// - /// Create default UI for UWP app - /// - public static void CreateDefaultUI() - { - } + Task.Run(() => Program.Run(SplitArguments(arguments))); + } - /// - /// Entry point for testhost, in App Model(UWP) scenario - /// - /// testhost initialization arguments - public static void Run(string arguments) - { - Task.Run(() => - { - Program.Run(SplitArguments(arguments)); - }); - } + /// + /// Split Arguments on space, if they are not inside Single/Double Quotes + /// + /// + /// + internal static string[] SplitArguments(string commandLine) + { + var parmChars = commandLine.ToCharArray(); + var inDoubleQuote = false; + var inSingleQuote = false; - /// - /// Split Arguments on space, if they are not inside Single/Double Quotes - /// - /// - /// - internal static string[] SplitArguments(string commandLine) + for (var index = 0; index < parmChars.Length; index++) { - var parmChars = commandLine.ToCharArray(); - var inDoubleQuote = false; - var inSingleQuote = false; + if (parmChars[index] == '"' && !inSingleQuote) + { + inDoubleQuote = !inDoubleQuote; + } - for (var index = 0; index < parmChars.Length; index++) + if (parmChars[index] == '\'' && !inDoubleQuote) { - if (parmChars[index] == '"' && !inSingleQuote) - { - inDoubleQuote = !inDoubleQuote; - } - - if (parmChars[index] == '\'' && !inDoubleQuote) - { - inSingleQuote = !inSingleQuote; - } - - if (!inSingleQuote && !inDoubleQuote && parmChars[index] == ' ') - parmChars[index] = '\n'; + inSingleQuote = !inSingleQuote; } - return (new string(parmChars)).Split(new[] { '\n' }); + if (!inSingleQuote && !inDoubleQuote && parmChars[index] == ' ') + parmChars[index] = '\n'; } + + return (new string(parmChars)).Split(new[] { '\n' }); } } \ No newline at end of file diff --git a/src/vstest.console/CommandLine/AssemblyMetadataProvider.cs b/src/vstest.console/CommandLine/AssemblyMetadataProvider.cs index 2424097983..c6db757459 100644 --- a/src/vstest.console/CommandLine/AssemblyMetadataProvider.cs +++ b/src/vstest.console/CommandLine/AssemblyMetadataProvider.cs @@ -1,297 +1,294 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; + +using System; +using System.IO; +using System.Reflection; +using System.Reflection.Metadata; +using System.Reflection.PortableExecutable; +using System.Runtime.Versioning; +using System.Text; + +using ObjectModel; + +using TestPlatform.Utilities.Helpers; +using TestPlatform.Utilities.Helpers.Interfaces; + +internal class AssemblyMetadataProvider : IAssemblyMetadataProvider { - using System; - using System.IO; - using System.Reflection; - using System.Reflection.Metadata; - using System.Reflection.PortableExecutable; - using System.Runtime.Versioning; - using System.Text; - using ObjectModel; - using TestPlatform.Utilities.Helpers; - using TestPlatform.Utilities.Helpers.Interfaces; - - internal class AssemblyMetadataProvider : IAssemblyMetadataProvider + private static AssemblyMetadataProvider s_instance; + private readonly IFileHelper _fileHelper; + + /// + /// Gets the instance. + /// + public static AssemblyMetadataProvider Instance => s_instance ??= new AssemblyMetadataProvider(new FileHelper()); + + internal AssemblyMetadataProvider(IFileHelper fileHelper) { - private static AssemblyMetadataProvider instance; - private IFileHelper fileHelper; + _fileHelper = fileHelper; + } - /// - /// Gets the instance. - /// - public static AssemblyMetadataProvider Instance => instance ?? (instance = new AssemblyMetadataProvider(new FileHelper())); + /// + public FrameworkName GetFrameWork(string filePath) + { + FrameworkName frameworkName = new(Framework.DefaultFramework.Name); + try + { + using var assemblyStream = _fileHelper.GetStream(filePath, FileMode.Open, FileAccess.Read); + frameworkName = GetFrameworkNameFromAssemblyMetadata(assemblyStream); + } + catch (Exception ex) + { + EqtTrace.Warning("AssemblyMetadataProvider.GetFrameWork: failed to determine TargetFrameworkVersion exception: {0} for assembly: {1}", ex, filePath); + } - internal AssemblyMetadataProvider(IFileHelper fileHelper) + if (EqtTrace.IsInfoEnabled) { - this.fileHelper = fileHelper; + EqtTrace.Info("AssemblyMetadataProvider.GetFrameWork: Determined framework:'{0}' for source: '{1}'", frameworkName, filePath); } - /// - public FrameworkName GetFrameWork(string filePath) + return frameworkName; + } + + /// + public Architecture GetArchitecture(string assemblyPath) + { + Architecture archType = Architecture.AnyCPU; + try { - FrameworkName frameworkName = new FrameworkName(Framework.DefaultFramework.Name); - try - { - using (var assemblyStream = this.fileHelper.GetStream(filePath, FileMode.Open, FileAccess.Read)) - { - frameworkName = AssemblyMetadataProvider.GetFrameworkNameFromAssemblyMetadata(assemblyStream); - } - } - catch (Exception ex) - { - EqtTrace.Warning("AssemblyMetadataProvider.GetFrameWork: failed to determine TargetFrameworkVersion exception: {0} for assembly: {1}", ex, filePath); - } + // AssemblyName won't load the assembly into current domain. + var assemblyName = AssemblyName.GetAssemblyName(assemblyPath); + archType = MapToArchitecture(assemblyName.ProcessorArchitecture, assemblyPath); + } + catch (Exception ex) + { + // AssemblyName will throw Exception if assembly contains native code or no manifest. - if (EqtTrace.IsInfoEnabled) + if (EqtTrace.IsVerboseEnabled) { - EqtTrace.Info("AssemblyMetadataProvider.GetFrameWork: Determined framework:'{0}' for source: '{1}'", frameworkName, filePath); + EqtTrace.Verbose("AssemblyMetadataProvider.GetArchitecture: Failed get ProcessorArchitecture using AssemblyName API with exception: {0}", ex); } - return frameworkName; - } - - /// - public Architecture GetArchitecture(string assemblyPath) - { - Architecture archType = Architecture.AnyCPU; try { - // AssemblyName won't load the assembly into current domain. - var assemblyName = AssemblyName.GetAssemblyName(assemblyPath); - archType = MapToArchitecture(assemblyName.ProcessorArchitecture, assemblyPath); + archType = GetArchitectureForSource(assemblyPath); } - catch (Exception ex) + catch (Exception e) { - // AssemblyName will throw Exception if assembly contains native code or no manifest. - - if (EqtTrace.IsVerboseEnabled) + if (EqtTrace.IsInfoEnabled) { - EqtTrace.Verbose("AssemblyMetadataProvider.GetArchitecture: Failed get ProcessorArchitecture using AssemblyName API with exception: {0}", ex); - } - - try - { - archType = GetArchitectureForSource(assemblyPath); - } - catch (Exception e) - { - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("AssemblyMetadataProvider.GetArchitecture: Failed to determine Assembly Architecture with exception: {0}", e); - } + EqtTrace.Info("AssemblyMetadataProvider.GetArchitecture: Failed to determine Assembly Architecture with exception: {0}", e); } } + } - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("AssemblyMetadataProvider.GetArchitecture: Determined architecture:{0} info for assembly: {1}", archType, - assemblyPath); - } - - return archType; + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("AssemblyMetadataProvider.GetArchitecture: Determined architecture:{0} info for assembly: {1}", archType, + assemblyPath); } - private Architecture GetArchitectureFromAssemblyMetadata(string path) + return archType; + } + + private Architecture GetArchitectureFromAssemblyMetadata(string path) + { + Architecture arch = Architecture.AnyCPU; + using (Stream stream = _fileHelper.GetStream(path, FileMode.Open, FileAccess.Read)) + using (PEReader peReader = new(stream)) { - Architecture arch = Architecture.AnyCPU; - using (Stream stream = this.fileHelper.GetStream(path, FileMode.Open, FileAccess.Read)) - using (PEReader peReader = new PEReader(stream)) + switch (peReader.PEHeaders.CoffHeader.Machine) { - switch (peReader.PEHeaders.CoffHeader.Machine) - { - case Machine.Amd64: - return Architecture.X64; - case Machine.IA64: - return Architecture.X64; - case Machine.Arm64: - return Architecture.ARM64; - case Machine.Arm: - return Architecture.ARM; - case Machine.I386: - return Architecture.X86; - default: - break; - } + case Machine.Amd64: + return Architecture.X64; + case Machine.IA64: + return Architecture.X64; + case Machine.Arm64: + return Architecture.ARM64; + case Machine.Arm: + return Architecture.ARM; + case Machine.I386: + return Architecture.X86; + default: + break; } - - return arch; } - private static FrameworkName GetFrameworkNameFromAssemblyMetadata(Stream assemblyStream) + return arch; + } + + private static FrameworkName GetFrameworkNameFromAssemblyMetadata(Stream assemblyStream) + { + FrameworkName frameworkName = new(Framework.DefaultFramework.Name); + using (var peReader = new PEReader(assemblyStream)) { - FrameworkName frameworkName = new FrameworkName(Framework.DefaultFramework.Name); - using (var peReader = new PEReader(assemblyStream)) - { - var metadataReader = peReader.GetMetadataReader(); + var metadataReader = peReader.GetMetadataReader(); - foreach (var customAttributeHandle in metadataReader.CustomAttributes) + foreach (var customAttributeHandle in metadataReader.CustomAttributes) + { + var attr = metadataReader.GetCustomAttribute(customAttributeHandle); + var result = Encoding.UTF8.GetString(metadataReader.GetBlobBytes(attr.Value)); + if (result.Contains(".NET") && result.Contains(",Version=")) { - var attr = metadataReader.GetCustomAttribute(customAttributeHandle); - var result = Encoding.UTF8.GetString(metadataReader.GetBlobBytes(attr.Value)); - if (result.Contains(".NET") && result.Contains(",Version=")) + var fxStartIndex = result.IndexOf(".NET", StringComparison.Ordinal); + var fxEndIndex = result.IndexOf("\u0001", fxStartIndex, StringComparison.Ordinal); + if (fxStartIndex > -1 && fxEndIndex > fxStartIndex) { - var fxStartIndex = result.IndexOf(".NET", StringComparison.Ordinal); - var fxEndIndex = result.IndexOf("\u0001", fxStartIndex, StringComparison.Ordinal); - if (fxStartIndex > -1 && fxEndIndex > fxStartIndex) - { - // Using -3 because custom attribute values separated by unicode characters. - result = result.Substring(fxStartIndex, fxEndIndex - 3); - frameworkName = new FrameworkName(result); - break; - } + // Using -3 because custom attribute values separated by unicode characters. + result = result.Substring(fxStartIndex, fxEndIndex - 3); + frameworkName = new FrameworkName(result); + break; } } } - - return frameworkName; } - private Architecture MapToArchitecture(ProcessorArchitecture processorArchitecture, string assemblyPath) - { - Architecture arch = Architecture.AnyCPU; - // Mapping to Architecture based on https://msdn.microsoft.com/en-us/library/system.reflection.processorarchitecture(v=vs.110).aspx + return frameworkName; + } - if (processorArchitecture.Equals(ProcessorArchitecture.Amd64) - || processorArchitecture.Equals(ProcessorArchitecture.IA64)) - { - arch = Architecture.X64; - } - else if (processorArchitecture.Equals(ProcessorArchitecture.X86)) - { - arch = Architecture.X86; - } - else if (processorArchitecture.Equals(ProcessorArchitecture.MSIL)) - { - arch = Architecture.AnyCPU; - } - else if (processorArchitecture.Equals(ProcessorArchitecture.Arm)) - { - arch = Architecture.ARM; - } - else if (processorArchitecture.Equals(ProcessorArchitecture.None)) - { - // In case of None we fallback to PEReader - // We don't use only PEReader for back compatibility. - // An AnyCPU returned by AssemblyName.GetAssemblyName(assemblyPath) will result in a I386 for PEReader. - // Also MSIL processor architecture is missing with PEReader. - // For now it should fix the issue for the missing ARM64 architecture. - arch = GetArchitectureFromAssemblyMetadata(assemblyPath); - } - else - { - EqtTrace.Info("Unable to map to Architecture, using platform: {0}", arch); - } + private Architecture MapToArchitecture(ProcessorArchitecture processorArchitecture, string assemblyPath) + { + Architecture arch = Architecture.AnyCPU; + // Mapping to Architecture based on https://msdn.microsoft.com/en-us/library/system.reflection.processorarchitecture(v=vs.110).aspx - return arch; + if (processorArchitecture.Equals(ProcessorArchitecture.Amd64) + || processorArchitecture.Equals(ProcessorArchitecture.IA64)) + { + arch = Architecture.X64; } - - public Architecture GetArchitectureForSource(string imagePath) + else if (processorArchitecture.Equals(ProcessorArchitecture.X86)) + { + arch = Architecture.X86; + } + else if (processorArchitecture.Equals(ProcessorArchitecture.MSIL)) + { + arch = Architecture.AnyCPU; + } + else if (processorArchitecture.Equals(ProcessorArchitecture.Arm)) + { + arch = Architecture.ARM; + } + else if (processorArchitecture.Equals(ProcessorArchitecture.None)) + { + // In case of None we fallback to PEReader + // We don't use only PEReader for back compatibility. + // An AnyCPU returned by AssemblyName.GetAssemblyName(assemblyPath) will result in a I386 for PEReader. + // Also MSIL processor architecture is missing with PEReader. + // For now it should fix the issue for the missing ARM64 architecture. + arch = GetArchitectureFromAssemblyMetadata(assemblyPath); + } + else { - // For details refer to below code available on MSDN. - //https://code.msdn.microsoft.com/windowsapps/CSCheckExeType-aab06100#content + EqtTrace.Info("Unable to map to Architecture, using platform: {0}", arch); + } - var archType = Architecture.AnyCPU; - ushort machine = 0; + return arch; + } - uint peHeader; - const int IMAGE_FILE_MACHINE_AMD64 = 0x8664; - const int IMAGE_FILE_MACHINE_IA64 = 0x200; - const int IMAGE_FILE_MACHINE_I386 = 0x14c; - const int IMAGE_FILE_MACHINE_ARM = 0x01c0; // ARM Little-Endian - const int IMAGE_FILE_MACHINE_THUMB = 0x01c2; // ARM Thumb/Thumb-2 Little-Endian - const int IMAGE_FILE_MACHINE_ARMNT = 0x01c4; // ARM Thumb-2 Little-Endian + public Architecture GetArchitectureForSource(string imagePath) + { + // For details refer to below code available on MSDN. + //https://code.msdn.microsoft.com/windowsapps/CSCheckExeType-aab06100#content + var archType = Architecture.AnyCPU; + ushort machine = 0; - try + uint peHeader; + const int imageFileMachineAmd64 = 0x8664; + const int imageFileMachineIa64 = 0x200; + const int imageFileMachineI386 = 0x14c; + const int imageFileMachineArm = 0x01c0; // ARM Little-Endian + const int imageFileMachineThumb = 0x01c2; // ARM Thumb/Thumb-2 Little-Endian + const int imageFileMachineArmnt = 0x01c4; // ARM Thumb-2 Little-Endian + + + try + { + //get the input stream + using Stream fs = _fileHelper.GetStream(imagePath, FileMode.Open, FileAccess.Read); + using var reader = new BinaryReader(fs); + var validImage = true; + + //PE Header starts @ 0x3C (60). Its a 4 byte header. + fs.Position = 0x3C; + peHeader = reader.ReadUInt32(); + + // Check if the offset is invalid + if (peHeader > fs.Length - 5) { - //get the input stream - using (Stream fs = this.fileHelper.GetStream(imagePath, FileMode.Open, FileAccess.Read)) - using (var reader = new BinaryReader(fs)) - { - var validImage = true; + validImage = false; + } - //PE Header starts @ 0x3C (60). Its a 4 byte header. - fs.Position = 0x3C; - peHeader = reader.ReadUInt32(); + if (validImage) + { + //Moving to PE Header start location... + fs.Position = peHeader; + + var signature = reader.ReadUInt32(); //peHeaderSignature + // 0x00004550 is the letters "PE" followed by two terminating zeros. + if (signature != 0x00004550) + { + validImage = false; + } - // Check if the offset is invalid - if (peHeader > fs.Length - 5) + if (validImage) + { + //Read the image file header. + machine = reader.ReadUInt16(); + reader.ReadUInt16(); //NumberOfSections + reader.ReadUInt32(); //TimeDateStamp + reader.ReadUInt32(); //PointerToSymbolTable + reader.ReadUInt32(); //NumberOfSymbols + reader.ReadUInt16(); //SizeOfOptionalHeader + reader.ReadUInt16(); //Characteristics + + // magic number.32bit or 64bit assembly. + var magic = reader.ReadUInt16(); + if (magic != 0x010B && magic != 0x020B) { validImage = false; } + } - if (validImage) + if (validImage) + { + switch (machine) { - //Moving to PE Header start location... - fs.Position = peHeader; - - var signature = reader.ReadUInt32(); //peHeaderSignature - // 0x00004550 is the letters "PE" followed by two terminating zeros. - if (signature != 0x00004550) - { - validImage = false; - } - - if (validImage) - { - //Read the image file header. - machine = reader.ReadUInt16(); - reader.ReadUInt16(); //NumberOfSections - reader.ReadUInt32(); //TimeDateStamp - reader.ReadUInt32(); //PointerToSymbolTable - reader.ReadUInt32(); //NumberOfSymbols - reader.ReadUInt16(); //SizeOfOptionalHeader - reader.ReadUInt16(); //Characteristics - - // magic number.32bit or 64bit assembly. - var magic = reader.ReadUInt16(); - if (magic != 0x010B && magic != 0x020B) - { - validImage = false; - } - } - - if (validImage) - { - switch (machine) - { - case IMAGE_FILE_MACHINE_I386: - archType = Architecture.X86; - break; - - case IMAGE_FILE_MACHINE_AMD64: - case IMAGE_FILE_MACHINE_IA64: - archType = Architecture.X64; - break; - - case IMAGE_FILE_MACHINE_ARM: - case IMAGE_FILE_MACHINE_THUMB: - case IMAGE_FILE_MACHINE_ARMNT: - archType = Architecture.ARM; - break; - } - } - else - { - EqtTrace.Info( - "GetArchitectureForSource: Source path {0} is not a valid image path. Returning default proc arch type: {1}.", - imagePath, archType); - } + case imageFileMachineI386: + archType = Architecture.X86; + break; + + case imageFileMachineAmd64: + case imageFileMachineIa64: + archType = Architecture.X64; + break; + + case imageFileMachineArm: + case imageFileMachineThumb: + case imageFileMachineArmnt: + archType = Architecture.ARM; + break; } } + else + { + EqtTrace.Info( + "GetArchitectureForSource: Source path {0} is not a valid image path. Returning default proc arch type: {1}.", + imagePath, archType); + } } - catch (Exception ex) - { - //Ignore all exception - EqtTrace.Info( - "GetArchitectureForSource: Returning default:{0}. Unhandled exception: {1}.", - archType, ex); - } - - return archType; } + catch (Exception ex) + { + //Ignore all exception + EqtTrace.Info( + "GetArchitectureForSource: Returning default:{0}. Unhandled exception: {1}.", + archType, ex); + } + + return archType; } -} +} \ No newline at end of file diff --git a/src/vstest.console/CommandLine/CommandArgumentPair.cs b/src/vstest.console/CommandLine/CommandArgumentPair.cs index aa8f8bfb19..a6c1cfbc96 100644 --- a/src/vstest.console/CommandLine/CommandArgumentPair.cs +++ b/src/vstest.console/CommandLine/CommandArgumentPair.cs @@ -1,109 +1,108 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine -{ - using System; - using System.Diagnostics.Contracts; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine; + +using System; +using System.Diagnostics.Contracts; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; +using CommandLineResources = Resources.Resources; + +/// +/// Breaks a string down into command and argument based on the following format: +/// /command:argument. +/// +internal class CommandArgumentPair +{ + #region Constants /// - /// Breaks a string down into command and argument based on the following format: - /// /command:argument. + /// The separator. /// - internal class CommandArgumentPair - { - #region Constants - - /// - /// The separator. - /// - internal const string Separator = ":"; + internal const string Separator = ":"; - #endregion + #endregion - #region Properties + #region Properties - /// - /// The command portion of the input. - /// - public string Command { get; private set; } + /// + /// The command portion of the input. + /// + public string Command { get; private set; } - /// - /// The argument portion of the input. - /// - public string Argument { get; private set; } + /// + /// The argument portion of the input. + /// + public string Argument { get; private set; } - #endregion + #endregion - #region Constructor + #region Constructor - /// - /// Breaks the provided command line switch into the command and argument pair. - /// - /// Input to break up. - public CommandArgumentPair(string input) + /// + /// Breaks the provided command line switch into the command and argument pair. + /// + /// Input to break up. + public CommandArgumentPair(string input) + { + if (String.IsNullOrWhiteSpace(input)) { - if (String.IsNullOrWhiteSpace(input)) - { - throw new ArgumentException(CommandLineResources.CannotBeNullOrEmpty, nameof(input)); - } - Contract.Ensures(!String.IsNullOrWhiteSpace(Command)); - - this.Parse(input); + throw new ArgumentException(CommandLineResources.CannotBeNullOrEmpty, nameof(input)); } + Contract.Ensures(!String.IsNullOrWhiteSpace(Command)); + + Parse(input); + } - /// - /// Stores the provided command and argument pair. - /// - /// The command portion of the input. - /// The argument portion of the input. - public CommandArgumentPair(string command, string argument) + /// + /// Stores the provided command and argument pair. + /// + /// The command portion of the input. + /// The argument portion of the input. + public CommandArgumentPair(string command, string argument) + { + if (String.IsNullOrWhiteSpace(command)) { - if (String.IsNullOrWhiteSpace(command)) - { - throw new ArgumentException(CommandLineResources.CannotBeNullOrEmpty, nameof(command)); - } + throw new ArgumentException(CommandLineResources.CannotBeNullOrEmpty, nameof(command)); + } - Contract.Ensures(Command == command); - Contract.Ensures(Argument == argument); + Contract.Ensures(Command == command); + Contract.Ensures(Argument == argument); - this.Command = command; - this.Argument = argument; - } + Command = command; + Argument = argument; + } - #endregion + #endregion - #region Private Methods + #region Private Methods - /// - /// Parses the input into the command and argument parts. - /// - /// Input string to parse. - private void Parse(string input) + /// + /// Parses the input into the command and argument parts. + /// + /// Input string to parse. + private void Parse(string input) + { + Contract.Requires(!String.IsNullOrWhiteSpace(input)); + Contract.Ensures(!String.IsNullOrWhiteSpace(Command)); + Contract.Ensures(Argument != null); + + // Find the index of the separator (":") + int index = input.IndexOf(Separator, StringComparison.OrdinalIgnoreCase); + + if (index == -1) { - Contract.Requires(!String.IsNullOrWhiteSpace(input)); - Contract.Ensures(!String.IsNullOrWhiteSpace(Command)); - Contract.Ensures(Argument != null); - - // Find the index of the separator (":") - int index = input.IndexOf(CommandArgumentPair.Separator, StringComparison.OrdinalIgnoreCase); - - if (index == -1) - { - // No separator was found, so use the input as the command. - this.Command = input; - this.Argument = String.Empty; - } - else - { - // Separator was found, so separate the command and the input. - this.Command = input.Substring(0, index); - this.Argument = input.Substring(index + 1); - } + // No separator was found, so use the input as the command. + Command = input; + Argument = String.Empty; + } + else + { + // Separator was found, so separate the command and the input. + Command = input.Substring(0, index); + Argument = input.Substring(index + 1); } - -#endregion } -} + + #endregion +} \ No newline at end of file diff --git a/src/vstest.console/CommandLine/CommandLineException.cs b/src/vstest.console/CommandLine/CommandLineException.cs index 4defc252ba..6da069523c 100644 --- a/src/vstest.console/CommandLine/CommandLineException.cs +++ b/src/vstest.console/CommandLine/CommandLineException.cs @@ -1,44 +1,43 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine +namespace Microsoft.VisualStudio.TestPlatform.CommandLine; + +using System; + +/// +/// Exception thrown by argument processors when they encounter an error with +/// the command line arguments. +/// +public class CommandLineException : Exception { - using System; + #region Constructors /// - /// Exception thrown by argument processors when they encounter an error with - /// the command line arguments. + /// Creates a new CommandLineException /// - public class CommandLineException : Exception + public CommandLineException() { - #region Constructors - - /// - /// Creates a new CommandLineException - /// - public CommandLineException() - { - } - - /// - /// Initializes with the message. - /// - /// Message for the exception. - public CommandLineException(string message) - : base(message) - { - } + } - /// - /// Initializes with message and inner exception. - /// - /// Message for the exception. - /// The inner exception. - public CommandLineException(string message, Exception innerException) - : base(message, innerException) - { - } + /// + /// Initializes with the message. + /// + /// Message for the exception. + public CommandLineException(string message) + : base(message) + { + } - #endregion + /// + /// Initializes with message and inner exception. + /// + /// Message for the exception. + /// The inner exception. + public CommandLineException(string message, Exception innerException) + : base(message, innerException) + { } -} + + #endregion +} \ No newline at end of file diff --git a/src/vstest.console/CommandLine/CommandLineOptions.cs b/src/vstest.console/CommandLine/CommandLineOptions.cs index 4edd13929b..56bce9bc70 100644 --- a/src/vstest.console/CommandLine/CommandLineOptions.cs +++ b/src/vstest.console/CommandLine/CommandLineOptions.cs @@ -1,321 +1,320 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine -{ - using System; - using System.Collections.Generic; - using System.Linq; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine; + +using System; +using System.Collections.Generic; +using System.Linq; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using ObjectModel; - using Utilities.Helpers; - using Utilities.Helpers.Interfaces; +using Utilities.Helpers; +using Utilities.Helpers.Interfaces; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; - using vstest.console.Internal; - using System.Globalization; +using CommandLineResources = Resources.Resources; +using vstest.console.Internal; +using System.Globalization; + +/// +/// Provides access to the command-line options. +/// +internal class CommandLineOptions +{ + #region Constants/Readonly /// - /// Provides access to the command-line options. + /// The default batch size. /// - internal class CommandLineOptions - { - #region Constants/Readonly + public const long DefaultBatchSize = 10; - /// - /// The default batch size. - /// - public const long DefaultBatchSize = 10; - - /// - /// The use vsix extensions key. - /// - public const string UseVsixExtensionsKey = "UseVsixExtensions"; + /// + /// The use vsix extensions key. + /// + public const string UseVsixExtensionsKey = "UseVsixExtensions"; - /// - /// The default use vsix extensions value. - /// - public const bool DefaultUseVsixExtensionsValue = false; + /// + /// The default use vsix extensions value. + /// + public const bool DefaultUseVsixExtensionsValue = false; - /// - /// The default retrieval timeout for fetching of test results or test cases - /// - private readonly TimeSpan DefaultRetrievalTimeout = new TimeSpan(0, 0, 0, 1, 500); + /// + /// The default retrieval timeout for fetching of test results or test cases + /// + private readonly TimeSpan _defaultRetrievalTimeout = new(0, 0, 0, 1, 500); - #endregion + #endregion - #region PrivateMembers + #region PrivateMembers - private static CommandLineOptions instance; + private static CommandLineOptions s_instance; - private List sources = new List(); + private List _sources = new(); - private Architecture architecture; + private Architecture _architecture; - private Framework frameworkVersion; + private Framework _frameworkVersion; - #endregion + #endregion - /// - /// Gets the instance. - /// - internal static CommandLineOptions Instance + /// + /// Gets the instance. + /// + internal static CommandLineOptions Instance + { + get { - get + if (s_instance == null) { - if (instance == null) - { - instance = new CommandLineOptions(); - } - - return instance; + s_instance = new CommandLineOptions(); } + + return s_instance; } + } - #region Constructor + #region Constructor - /// - /// Default constructor. - /// - protected CommandLineOptions() - { - this.BatchSize = DefaultBatchSize; - this.TestStatsEventTimeout = this.DefaultRetrievalTimeout; - this.FileHelper = new FileHelper(); - this.FilePatternParser = new FilePatternParser(); + /// + /// Default constructor. + /// + protected CommandLineOptions() + { + BatchSize = DefaultBatchSize; + TestStatsEventTimeout = _defaultRetrievalTimeout; + FileHelper = new FileHelper(); + FilePatternParser = new FilePatternParser(); #if TODO UseVsixExtensions = Utilities.GetAppSettingValue(UseVsixExtensionsKey, false); #endif - } + } - #endregion + #endregion - #region Properties + #region Properties - /// - /// Specifies whether parallel execution is on or off. - /// - public bool Parallel { get; set; } + /// + /// Specifies whether parallel execution is on or off. + /// + public bool Parallel { get; set; } - /// - /// Specifies whether InIsolation is on or off. - /// - public bool InIsolation { get; set; } + /// + /// Specifies whether InIsolation is on or off. + /// + public bool InIsolation { get; set; } - /// - /// Read only collection of all available test sources - /// - public IEnumerable Sources + /// + /// Read only collection of all available test sources + /// + public IEnumerable Sources + { + get { - get - { - return this.sources.AsReadOnly(); - } + return _sources.AsReadOnly(); } + } - /// - /// Specifies whether dynamic code coverage diagnostic data adapter needs to be configured. - /// - public bool EnableCodeCoverage { get; set; } - - /// - /// Specifies whether the Fakes automatic configuration should be disabled. - /// - public bool DisableAutoFakes { get; set; } = false; - - /// - /// Specifies whether vsixExtensions is enabled or not. - /// - public bool UseVsixExtensions { get; set; } - - /// - /// Path to the custom test adapters. - /// - public string TestAdapterPath { get; set; } - - /// - /// Process Id of the process which launched vstest runner - /// - public int ParentProcessId { get; set; } - - /// - /// Port IDE process is listening to - /// - public int Port { get; set; } - - /// - /// Configuration the project is built for e.g. Debug/Release - /// - public string Configuration { get; set; } - - /// - /// Directory containing the temporary outputs - /// - public string BuildBasePath { get; set; } - - /// - /// Directory containing the binaries to run - /// - public string Output { get; set; } - - /// - /// Specifies the frequency of the runStats/discoveredTests event - /// - public long BatchSize { get; set; } - - /// - /// Specifies the timeout of the test stats cache timeout event - /// - public TimeSpan TestStatsEventTimeout { get; set; } - - /// - /// Test case filter value for run with sources. - /// - public string TestCaseFilterValue { get; set; } - - /// - /// Target Path used by ListFullyQualifiedTests option - /// - public string ListTestsTargetPath { get; set; } - - /// - /// Specifies the Target Device - /// - public string TargetDevice { get; set; } - - /// - /// Specifies whether the target device has a Windows Phone context or not - /// - public bool HasPhoneContext + /// + /// Specifies whether dynamic code coverage diagnostic data adapter needs to be configured. + /// + public bool EnableCodeCoverage { get; set; } + + /// + /// Specifies whether the Fakes automatic configuration should be disabled. + /// + public bool DisableAutoFakes { get; set; } = false; + + /// + /// Specifies whether vsixExtensions is enabled or not. + /// + public bool UseVsixExtensions { get; set; } + + /// + /// Path to the custom test adapters. + /// + public string TestAdapterPath { get; set; } + + /// + /// Process Id of the process which launched vstest runner + /// + public int ParentProcessId { get; set; } + + /// + /// Port IDE process is listening to + /// + public int Port { get; set; } + + /// + /// Configuration the project is built for e.g. Debug/Release + /// + public string Configuration { get; set; } + + /// + /// Directory containing the temporary outputs + /// + public string BuildBasePath { get; set; } + + /// + /// Directory containing the binaries to run + /// + public string Output { get; set; } + + /// + /// Specifies the frequency of the runStats/discoveredTests event + /// + public long BatchSize { get; set; } + + /// + /// Specifies the timeout of the test stats cache timeout event + /// + public TimeSpan TestStatsEventTimeout { get; set; } + + /// + /// Test case filter value for run with sources. + /// + public string TestCaseFilterValue { get; set; } + + /// + /// Target Path used by ListFullyQualifiedTests option + /// + public string ListTestsTargetPath { get; set; } + + /// + /// Specifies the Target Device + /// + public string TargetDevice { get; set; } + + /// + /// Specifies whether the target device has a Windows Phone context or not + /// + public bool HasPhoneContext + { + get { - get - { - return !string.IsNullOrEmpty(TargetDevice); - } + return !string.IsNullOrEmpty(TargetDevice); } + } - /// - /// Specifies the target platform type for test run. - /// - public Architecture TargetArchitecture + /// + /// Specifies the target platform type for test run. + /// + public Architecture TargetArchitecture + { + get { - get - { - return this.architecture; - } - set - { - this.architecture = value; - this.ArchitectureSpecified = true; - } + return _architecture; } - - /// - /// True indicates the test run is started from an Editor or IDE. - /// Defaults to false. - /// - public bool IsDesignMode + set { - get; - set; + _architecture = value; + ArchitectureSpecified = true; } + } - /// - /// If not already set from IDE in the runSettings, ShouldCollectSourceInformation defaults to IsDesignMode value - /// - public bool ShouldCollectSourceInformation + /// + /// True indicates the test run is started from an Editor or IDE. + /// Defaults to false. + /// + public bool IsDesignMode + { + get; + set; + } + + /// + /// If not already set from IDE in the runSettings, ShouldCollectSourceInformation defaults to IsDesignMode value + /// + public bool ShouldCollectSourceInformation + { + get { - get - { - return IsDesignMode; - } + return IsDesignMode; } + } - /// - /// Specifies if /Platform has been specified on command line or not. - /// - internal bool ArchitectureSpecified { get; private set; } + /// + /// Specifies if /Platform has been specified on command line or not. + /// + internal bool ArchitectureSpecified { get; private set; } - internal IFileHelper FileHelper { get; set; } + internal IFileHelper FileHelper { get; set; } - internal FilePatternParser FilePatternParser { get; set; } + internal FilePatternParser FilePatternParser { get; set; } - /// - /// Gets or sets the target Framework version for test run. - /// - internal Framework TargetFrameworkVersion + /// + /// Gets or sets the target Framework version for test run. + /// + internal Framework TargetFrameworkVersion + { + get { - get - { - return this.frameworkVersion; - } - set - { - this.frameworkVersion = value; - this.FrameworkVersionSpecified = true; - } + return _frameworkVersion; } + set + { + _frameworkVersion = value; + FrameworkVersionSpecified = true; + } + } - /// - /// Gets a value indicating whether /Framework has been specified on command line or not. - /// - internal bool FrameworkVersionSpecified { get; private set; } + /// + /// Gets a value indicating whether /Framework has been specified on command line or not. + /// + internal bool FrameworkVersionSpecified { get; private set; } - /// - /// Gets or sets the results directory for test run. - /// - internal string ResultsDirectory { get; set; } + /// + /// Gets or sets the results directory for test run. + /// + internal string ResultsDirectory { get; set; } - /// - /// Gets or sets the /setting switch value. i.e path to settings file. - /// - internal string SettingsFile { get; set; } + /// + /// Gets or sets the /setting switch value. i.e path to settings file. + /// + internal string SettingsFile { get; set; } - #endregion + #endregion - #region Public Methods + #region Public Methods - /// - /// Adds a source file to look for tests in. - /// - /// Path to source file to look for tests in. - public void AddSource(string source) + /// + /// Adds a source file to look for tests in. + /// + /// Path to source file to look for tests in. + public void AddSource(string source) + { + if (String.IsNullOrWhiteSpace(source)) { - if (String.IsNullOrWhiteSpace(source)) - { - throw new TestSourceException(CommandLineResources.CannotBeNullOrEmpty); - } - - source = source.Trim(); - - List matchingFiles; - try - { - // Get matching files from file pattern parser - matchingFiles = FilePatternParser.GetMatchingFiles(source); - } - catch(TestSourceException ex) when (source.StartsWith("-") || source.StartsWith("/")) - { - throw new TestSourceException( - string.Format(CultureInfo.CurrentUICulture, CommandLineResources.InvalidArgument, source), ex); - } - // Add the matching files to source list - this.sources = this.sources.Union(matchingFiles).ToList(); + throw new TestSourceException(CommandLineResources.CannotBeNullOrEmpty); } - #endregion + source = source.Trim(); - #region Internal Methods - - /// - /// Resets the options. Clears the sources. - /// - internal void Reset() + List matchingFiles; + try { - instance = null; + // Get matching files from file pattern parser + matchingFiles = FilePatternParser.GetMatchingFiles(source); } + catch (TestSourceException ex) when (source.StartsWith("-") || source.StartsWith("/")) + { + throw new TestSourceException( + string.Format(CultureInfo.CurrentUICulture, CommandLineResources.InvalidArgument, source), ex); + } + // Add the matching files to source list + _sources = _sources.Union(matchingFiles).ToList(); + } + + #endregion + + #region Internal Methods - #endregion + /// + /// Resets the options. Clears the sources. + /// + internal void Reset() + { + s_instance = null; } -} + + #endregion +} \ No newline at end of file diff --git a/src/vstest.console/CommandLine/Executor.cs b/src/vstest.console/CommandLine/Executor.cs index 225798cd6d..35f2f48b4a 100644 --- a/src/vstest.console/CommandLine/Executor.cs +++ b/src/vstest.console/CommandLine/Executor.cs @@ -21,356 +21,248 @@ // Required // Single or multiple -namespace Microsoft.VisualStudio.TestPlatform.CommandLine +namespace Microsoft.VisualStudio.TestPlatform.CommandLine; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Diagnostics.Contracts; +using System.Globalization; +using System.IO; +using System.Linq; + +using Internal; +using Processors; +using TestPlatformHelpers; +using Common; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using CoreUtilities.Tracing; +using CoreUtilities.Tracing.Interfaces; +using ObjectModel; +using Utilities; + +using CommandLineResources = Resources.Resources; + +/// +/// Performs the execution based on the arguments provided. +/// +internal class Executor { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Diagnostics.Contracts; - using System.Globalization; - using System.IO; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Execution; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; + private readonly ITestPlatformEventSource _testPlatformEventSource; + private bool _showHelp; + + #region Constructor /// - /// Performs the execution based on the arguments provided. + /// Default constructor. /// - internal class Executor + public Executor(IOutput output) : this(output, TestPlatformEventSource.Instance) { - private ITestPlatformEventSource testPlatformEventSource; - private bool showHelp; + } - #region Constructor + internal Executor(IOutput output, ITestPlatformEventSource testPlatformEventSource) + { + Output = output; + _testPlatformEventSource = testPlatformEventSource; + _showHelp = true; + } - /// - /// Default constructor. - /// - public Executor(IOutput output) : this(output, TestPlatformEventSource.Instance) - { - } + #endregion - internal Executor(IOutput output, ITestPlatformEventSource testPlatformEventSource) - { - this.Output = output; - this.testPlatformEventSource = testPlatformEventSource; - this.showHelp = true; - } + #region Properties - #endregion + /// + /// Instance to use for sending output. + /// + private IOutput Output { get; set; } - #region Properties + #endregion - /// - /// Instance to use for sending output. - /// - private IOutput Output { get; set; } + #region Methods - #endregion + /// + /// Performs the execution based on the arguments provided. + /// + /// + /// Arguments provided to perform execution with. + /// + /// + /// Exit Codes - Zero (for successful command execution), One (for bad command) + /// + internal int Execute(params string[] args) + { + _testPlatformEventSource.VsTestConsoleStart(); - #region Methods + var isDiag = args != null && args.Any(arg => arg.StartsWith("--diag", StringComparison.OrdinalIgnoreCase)); - /// - /// Performs the execution based on the arguments provided. - /// - /// - /// Arguments provided to perform execution with. - /// - /// - /// Exit Codes - Zero (for successful command execution), One (for bad command) - /// - internal int Execute(params string[] args) + // If User specifies --nologo via dotnet, do not print splat screen + if (args != null && args.Length != 0 && args.Contains("--nologo")) { - this.testPlatformEventSource.VsTestConsoleStart(); - - var isDiag = args != null && args.Any(arg => arg.StartsWith("--diag", StringComparison.OrdinalIgnoreCase)); - - // If User specifies --nologo via dotnet, do not print splat screen - if (args != null && args.Length !=0 && args.Contains("--nologo")) - { - // Sanitizing this list, as I don't think we should write Argument processor for this. - args = args.Where(val => val != "--nologo").ToArray(); - } - else - { - this.PrintSplashScreen(isDiag); - } + // Sanitizing this list, as I don't think we should write Argument processor for this. + args = args.Where(val => val != "--nologo").ToArray(); + } + else + { + PrintSplashScreen(isDiag); + } - int exitCode = 0; + int exitCode = 0; - // If we have no arguments, set exit code to 1, add a message, and include the help processor in the args. - if (args == null || args.Length == 0 || args.Any(string.IsNullOrWhiteSpace)) - { - this.Output.Error(true, CommandLineResources.NoArgumentsProvided); - args = new string[] { HelpArgumentProcessor.CommandName }; - exitCode = 1; - } + // If we have no arguments, set exit code to 1, add a message, and include the help processor in the args. + if (args == null || args.Length == 0 || args.Any(string.IsNullOrWhiteSpace)) + { + Output.Error(true, CommandLineResources.NoArgumentsProvided); + args = new string[] { HelpArgumentProcessor.CommandName }; + exitCode = 1; + } - if (!isDiag) + if (!isDiag) + { + // This takes a path to log directory and log.txt file. Same as the --diag parameter, e.g. VSTEST_DIAG="logs\log.txt" + var diag = Environment.GetEnvironmentVariable("VSTEST_DIAG"); + // This takes Verbose, Info (not Information), Warning, and Error. + var diagVerbosity = Environment.GetEnvironmentVariable("VSTEST_DIAG_VERBOSITY"); + if (!string.IsNullOrWhiteSpace(diag)) { - // This takes a path to log directory and log.txt file. Same as the --diag parameter, e.g. VSTEST_DIAG="logs\log.txt" - var diag = Environment.GetEnvironmentVariable("VSTEST_DIAG"); - // This takes Verbose, Info (not Information), Warning, and Error. - var diagVerbosity = Environment.GetEnvironmentVariable("VSTEST_DIAG_VERBOSITY"); - if (!string.IsNullOrWhiteSpace(diag)) + var verbosity = TraceLevel.Verbose; + if (diagVerbosity != null) { - var verbosity = TraceLevel.Verbose; - if (diagVerbosity != null) + if (Enum.TryParse(diagVerbosity, ignoreCase: true, out var parsedVerbosity)) { - if (Enum.TryParse(diagVerbosity, ignoreCase: true, out var parsedVerbosity)) - { - verbosity = parsedVerbosity; - } + verbosity = parsedVerbosity; } - - args = args.Concat(new[] { $"--diag:{diag};TraceLevel={verbosity}" }).ToArray(); } + + args = args.Concat(new[] { $"--diag:{diag};TraceLevel={verbosity}" }).ToArray(); } + } - // Flatten arguments and process response files. - string[] flattenedArguments; - exitCode |= this.FlattenArguments(args, out flattenedArguments); + // Flatten arguments and process response files. + exitCode |= FlattenArguments(args, out var flattenedArguments); - // Get the argument processors for the arguments. - List argumentProcessors; - exitCode |= this.GetArgumentProcessors(flattenedArguments, out argumentProcessors); + // Get the argument processors for the arguments. + exitCode |= GetArgumentProcessors(flattenedArguments, out List argumentProcessors); - // Verify that the arguments are valid. - exitCode |= this.IdentifyDuplicateArguments(argumentProcessors); + // Verify that the arguments are valid. + exitCode |= IdentifyDuplicateArguments(argumentProcessors); - // Quick exit for syntax error - if (exitCode == 1 - && argumentProcessors.All( - processor => processor.Metadata.Value.CommandName != HelpArgumentProcessor.CommandName)) - { - this.testPlatformEventSource.VsTestConsoleStop(); - return exitCode; - } + // Quick exit for syntax error + if (exitCode == 1 + && argumentProcessors.All( + processor => processor.Metadata.Value.CommandName != HelpArgumentProcessor.CommandName)) + { + _testPlatformEventSource.VsTestConsoleStop(); + return exitCode; + } - // Execute all argument processors - foreach (var processor in argumentProcessors) + // Execute all argument processors + foreach (var processor in argumentProcessors) + { + if (!ExecuteArgumentProcessor(processor, ref exitCode)) { - if (!this.ExecuteArgumentProcessor(processor, ref exitCode)) - { - break; - } + break; } + } - // Use the test run result aggregator to update the exit code. - exitCode |= (TestRunResultAggregator.Instance.Outcome == TestOutcome.Passed) ? 0 : 1; + // Use the test run result aggregator to update the exit code. + exitCode |= (TestRunResultAggregator.Instance.Outcome == TestOutcome.Passed) ? 0 : 1; - EqtTrace.Verbose("Executor.Execute: Exiting with exit code of {0}", exitCode); + EqtTrace.Verbose("Executor.Execute: Exiting with exit code of {0}", exitCode); - this.testPlatformEventSource.VsTestConsoleStop(); + _testPlatformEventSource.VsTestConsoleStop(); - this.testPlatformEventSource.MetricsDisposeStart(); + _testPlatformEventSource.MetricsDisposeStart(); - // Disposing Metrics Publisher when VsTestConsole ends - TestRequestManager.Instance.Dispose(); + // Disposing Metrics Publisher when VsTestConsole ends + TestRequestManager.Instance.Dispose(); - this.testPlatformEventSource.MetricsDisposeStop(); - return exitCode; - } + _testPlatformEventSource.MetricsDisposeStop(); + return exitCode; + } - #endregion + #endregion - #region Private Methods + #region Private Methods - /// - /// Get the list of argument processors for the arguments. - /// - /// Arguments provided to perform execution with. - /// List of argument processors for the arguments. - /// 0 if all of the processors were created successfully and 1 otherwise. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "processorInstance", Justification = "Done on purpose to force the instances to be created")] - private int GetArgumentProcessors(string[] args, out List processors) + /// + /// Get the list of argument processors for the arguments. + /// + /// Arguments provided to perform execution with. + /// List of argument processors for the arguments. + /// 0 if all of the processors were created successfully and 1 otherwise. + private int GetArgumentProcessors(string[] args, out List processors) + { + processors = new List(); + int result = 0; + var processorFactory = ArgumentProcessorFactory.Create(); + for (var index = 0; index < args.Length; index++) { - processors = new List(); - int result = 0; - var processorFactory = ArgumentProcessorFactory.Create(); - for (var index = 0; index < args.Length; index++) + var arg = args[index]; + // If argument is '--', following arguments are key=value pairs for run settings. + if (arg.Equals("--")) { - var arg = args[index]; - // If argument is '--', following arguments are key=value pairs for run settings. - if (arg.Equals("--")) - { - var cliRunSettingsProcessor = processorFactory.CreateArgumentProcessor(arg, args.Skip(index + 1).ToArray()); - processors.Add(cliRunSettingsProcessor); - break; - } - - var processor = processorFactory.CreateArgumentProcessor(arg); - - if (processor != null) - { - processors.Add(processor); - } - else - { - // No known processor was found, report an error and continue - this.Output.Error(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.NoArgumentProcessorFound, arg)); - - // Add the help processor - if (result == 0) - { - result = 1; - processors.Add(processorFactory.CreateArgumentProcessor(HelpArgumentProcessor.CommandName)); - } - } + var cliRunSettingsProcessor = processorFactory.CreateArgumentProcessor(arg, args.Skip(index + 1).ToArray()); + processors.Add(cliRunSettingsProcessor); + break; } - // Add the internal argument processors that should always be executed. - // Examples: processors to enable loggers that are statically configured, and to start logging, - // should always be executed. - var processorsToAlwaysExecute = processorFactory.GetArgumentProcessorsToAlwaysExecute(); - processors.AddRange(processorsToAlwaysExecute); - - // Initialize Runsettings with defaults - RunSettingsManager.Instance.AddDefaultRunSettings(); - - // Ensure we have an action argument. - this.EnsureActionArgumentIsPresent(processors, processorFactory); + var processor = processorFactory.CreateArgumentProcessor(arg); - // Instantiate and initialize the processors in priority order. - processors.Sort((p1, p2) => Comparer.Default.Compare(p1.Metadata.Value.Priority, p2.Metadata.Value.Priority)); - foreach (var processor in processors) + if (processor != null) { - IArgumentExecutor executorInstance; - try - { - // Ensure the instance is created. Note that the Lazy not only instantiates - // the argument processor, but also initializes it. - executorInstance = processor.Executor.Value; - } - catch (Exception ex) - { - if (ex is CommandLineException || ex is TestPlatformException || ex is SettingsException) - { - this.Output.Error(false, ex.Message); - result = 1; - this.showHelp = false; - } - else if(ex is TestSourceException) - { - this.Output.Error(false, ex.Message); - result = 1; - this.showHelp = false; - break; - } - else - { - // Let it throw - User must see crash and report it with stack trace! - // No need for recoverability as user will start a new vstest.console anyway - throw; - } - } + processors.Add(processor); } - - // If some argument was invalid, add help argument processor in beginning(i.e. at highest priority) - if (result == 1 && this.showHelp && processors.First().Metadata.Value.CommandName != HelpArgumentProcessor.CommandName) + else { - processors.Insert(0, processorFactory.CreateArgumentProcessor(HelpArgumentProcessor.CommandName)); - } - return result; - } - - /// - /// Verify that the arguments are valid. - /// - /// Processors to verify against. - /// 0 if successful and 1 otherwise. - private int IdentifyDuplicateArguments(IEnumerable argumentProcessors) - { - int result = 0; + // No known processor was found, report an error and continue + Output.Error(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.NoArgumentProcessorFound, arg)); - // Used to keep track of commands that are only allowed to show up once. The first time it is seen - // an entry for the command will be added to the dictionary and the value will be set to 1. If we - // see the command again and the value is 1 (meaning this is the second time we have seen the command), - // we will output an error and increment the count. This ensures that the error message will only be - // displayed once even if the user does something like /ListDiscoverers /ListDiscoverers /ListDiscoverers. - var commandSeenCount = new Dictionary(StringComparer.OrdinalIgnoreCase); - - // Check each processor. - foreach (var processor in argumentProcessors) - { - if (!processor.Metadata.Value.AllowMultiple) + // Add the help processor + if (result == 0) { - int count; - if (!commandSeenCount.TryGetValue(processor.Metadata.Value.CommandName, out count)) - { - commandSeenCount.Add(processor.Metadata.Value.CommandName, 1); - } - else if (count == 1) - { - result = 1; - - // Update the count so we do not print the error out for this argument multiple times. - commandSeenCount[processor.Metadata.Value.CommandName] = ++count; - this.Output.Error(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.DuplicateArgumentError, processor.Metadata.Value.CommandName)); - } + result = 1; + processors.Add(processorFactory.CreateArgumentProcessor(HelpArgumentProcessor.CommandName)); } } - return result; } - /// - /// Ensures that an action argument is present and if one is not, then the default action argument is added. - /// - /// The arguments that are being processed. - /// A factory for creating argument processors. - private void EnsureActionArgumentIsPresent(List argumentProcessors, ArgumentProcessorFactory processorFactory) - { - Contract.Requires(argumentProcessors != null); - Contract.Requires(processorFactory != null); + // Add the internal argument processors that should always be executed. + // Examples: processors to enable loggers that are statically configured, and to start logging, + // should always be executed. + var processorsToAlwaysExecute = processorFactory.GetArgumentProcessorsToAlwaysExecute(); + processors.AddRange(processorsToAlwaysExecute); - // Determine if any of the argument processors are actions. - var isActionIncluded = argumentProcessors.Any((processor) => processor.Metadata.Value.IsAction); + // Initialize Runsettings with defaults + RunSettingsManager.Instance.AddDefaultRunSettings(); - // If no action arguments have been provided, then add the default action argument. - if (!isActionIncluded) - { - argumentProcessors.Add(processorFactory.CreateDefaultActionArgumentProcessor()); - } - } + // Ensure we have an action argument. + EnsureActionArgumentIsPresent(processors, processorFactory); - /// - /// Executes the argument processor - /// - /// Argument processor to execute. - /// Exit status of Argument processor - /// true if continue execution, false otherwise. - private bool ExecuteArgumentProcessor(IArgumentProcessor processor, ref int exitCode) + // Instantiate and initialize the processors in priority order. + processors.Sort((p1, p2) => Comparer.Default.Compare(p1.Metadata.Value.Priority, p2.Metadata.Value.Priority)); + foreach (var processor in processors) { - var continueExecution = true; - ArgumentProcessorResult result; + IArgumentExecutor executorInstance; try { - result = processor.Executor.Value.Execute(); + // Ensure the instance is created. Note that the Lazy not only instantiates + // the argument processor, but also initializes it. + executorInstance = processor.Executor.Value; } catch (Exception ex) { - if (ex is CommandLineException || ex is TestPlatformException || ex is SettingsException || ex is InvalidOperationException) + if (ex is CommandLineException || ex is TestPlatformException || ex is SettingsException) { - EqtTrace.Error("ExecuteArgumentProcessor: failed to execute argument process: {0}", ex); - this.Output.Error(false, ex.Message); - result = ArgumentProcessorResult.Fail; - - // Send inner exception only when its message is different to avoid duplicate. - if (ex is TestPlatformException && - ex.InnerException != null && - !string.Equals(ex.InnerException.Message, ex.Message, StringComparison.CurrentCultureIgnoreCase)) - { - this.Output.Error(false, ex.InnerException.Message); - } + Output.Error(false, ex.Message); + result = 1; + _showHelp = false; + } + else if (ex is TestSourceException) + { + Output.Error(false, ex.Message); + result = 1; + _showHelp = false; + break; } else { @@ -379,125 +271,224 @@ private bool ExecuteArgumentProcessor(IArgumentProcessor processor, ref int exit throw; } } + } - Debug.Assert( - result >= ArgumentProcessorResult.Success && result <= ArgumentProcessorResult.Abort, - "Invalid argument processor result."); + // If some argument was invalid, add help argument processor in beginning(i.e. at highest priority) + if (result == 1 && _showHelp && processors.First().Metadata.Value.CommandName != HelpArgumentProcessor.CommandName) + { + processors.Insert(0, processorFactory.CreateArgumentProcessor(HelpArgumentProcessor.CommandName)); + } + return result; + } - if (result == ArgumentProcessorResult.Fail) - { - exitCode = 1; - } + /// + /// Verify that the arguments are valid. + /// + /// Processors to verify against. + /// 0 if successful and 1 otherwise. + private int IdentifyDuplicateArguments(IEnumerable argumentProcessors) + { + int result = 0; - if (result == ArgumentProcessorResult.Abort) - { - continueExecution = false; - } - return continueExecution; - } + // Used to keep track of commands that are only allowed to show up once. The first time it is seen + // an entry for the command will be added to the dictionary and the value will be set to 1. If we + // see the command again and the value is 1 (meaning this is the second time we have seen the command), + // we will output an error and increment the count. This ensures that the error message will only be + // displayed once even if the user does something like /ListDiscoverers /ListDiscoverers /ListDiscoverers. + var commandSeenCount = new Dictionary(StringComparer.OrdinalIgnoreCase); - /// - /// Displays the Company and Copyright splash title info immediately after launch - /// - private void PrintSplashScreen(bool isDiag) + // Check each processor. + foreach (var processor in argumentProcessors) { - string assemblyVersion = Product.Version; - if (!isDiag) + if (!processor.Metadata.Value.AllowMultiple) { - var end = Product.Version?.IndexOf("-release"); - - if (end >= 0) + if (!commandSeenCount.TryGetValue(processor.Metadata.Value.CommandName, out int count)) { - assemblyVersion = Product.Version?.Substring(0, end.Value); + commandSeenCount.Add(processor.Metadata.Value.CommandName, 1); } - } + else if (count == 1) + { + result = 1; - string commandLineBanner = string.Format(CultureInfo.CurrentUICulture, CommandLineResources.MicrosoftCommandLineTitle, assemblyVersion); - this.Output.WriteLine(commandLineBanner, OutputLevel.Information); - this.Output.WriteLine(CommandLineResources.CopyrightCommandLineTitle, OutputLevel.Information); - this.Output.WriteLine(string.Empty, OutputLevel.Information); + // Update the count so we do not print the error out for this argument multiple times. + commandSeenCount[processor.Metadata.Value.CommandName] = ++count; + Output.Error(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.DuplicateArgumentError, processor.Metadata.Value.CommandName)); + } + } } + return result; + } - /// - /// Flattens command line arguments by processing response files. - /// - /// Arguments provided to perform execution with. - /// Array of flattened arguments. - /// 0 if successful and 1 otherwise. - private int FlattenArguments(IEnumerable arguments, out string[] flattenedArguments) + /// + /// Ensures that an action argument is present and if one is not, then the default action argument is added. + /// + /// The arguments that are being processed. + /// A factory for creating argument processors. + private void EnsureActionArgumentIsPresent(List argumentProcessors, ArgumentProcessorFactory processorFactory) + { + Contract.Requires(argumentProcessors != null); + Contract.Requires(processorFactory != null); + + // Determine if any of the argument processors are actions. + var isActionIncluded = argumentProcessors.Any((processor) => processor.Metadata.Value.IsAction); + + // If no action arguments have been provided, then add the default action argument. + if (!isActionIncluded) { - List outputArguments = new List(); - int result = 0; + argumentProcessors.Add(processorFactory.CreateDefaultActionArgumentProcessor()); + } + } - foreach (var arg in arguments) + /// + /// Executes the argument processor + /// + /// Argument processor to execute. + /// Exit status of Argument processor + /// true if continue execution, false otherwise. + private bool ExecuteArgumentProcessor(IArgumentProcessor processor, ref int exitCode) + { + var continueExecution = true; + ArgumentProcessorResult result; + try + { + result = processor.Executor.Value.Execute(); + } + catch (Exception ex) + { + if (ex is CommandLineException || ex is TestPlatformException || ex is SettingsException || ex is InvalidOperationException) { - if (arg.StartsWith("@", StringComparison.Ordinal)) + EqtTrace.Error("ExecuteArgumentProcessor: failed to execute argument process: {0}", ex); + Output.Error(false, ex.Message); + result = ArgumentProcessorResult.Fail; + + // Send inner exception only when its message is different to avoid duplicate. + if (ex is TestPlatformException && + ex.InnerException != null && + !string.Equals(ex.InnerException.Message, ex.Message, StringComparison.CurrentCultureIgnoreCase)) { - // response file: - string path = arg.Substring(1).TrimEnd(null); - var hadError = this.ReadArgumentsAndSanitize(path, out var responseFileArgs, out var nestedArgs); - - if (hadError) - { - result |= 1; - } - else - { - this.Output.WriteLine(string.Format("vstest.console.exe {0}", responseFileArgs), OutputLevel.Information); - outputArguments.AddRange(nestedArgs); - } - } - else - { - outputArguments.Add(arg); + Output.Error(false, ex.InnerException.Message); } } + else + { + // Let it throw - User must see crash and report it with stack trace! + // No need for recoverability as user will start a new vstest.console anyway + throw; + } + } - flattenedArguments = outputArguments.ToArray(); - return result; + Debug.Assert( + result >= ArgumentProcessorResult.Success && result <= ArgumentProcessorResult.Abort, + "Invalid argument processor result."); + + if (result == ArgumentProcessorResult.Fail) + { + exitCode = 1; } - /// - /// Read and sanitize the arguments. - /// - /// File provided by user. - /// argument in the file as string. - /// Modified argument after sanitizing the contents of the file. - /// 0 if successful and 1 otherwise. - public bool ReadArgumentsAndSanitize(string fileName, out string args, out string[] arguments) + if (result == ArgumentProcessorResult.Abort) { - arguments = null; - if (GetContentUsingFile(fileName, out args)) - { - return true; - } + continueExecution = false; + } + return continueExecution; + } - if (string.IsNullOrEmpty(args)) + /// + /// Displays the Company and Copyright splash title info immediately after launch + /// + private void PrintSplashScreen(bool isDiag) + { + string assemblyVersion = Product.Version; + if (!isDiag) + { + var end = Product.Version?.IndexOf("-release"); + + if (end >= 0) { - return false; + assemblyVersion = Product.Version?.Substring(0, end.Value); } - - return CommandLineUtilities.SplitCommandLineIntoArguments(args, out arguments); } - private bool GetContentUsingFile(string fileName, out string contents) + string commandLineBanner = string.Format(CultureInfo.CurrentUICulture, CommandLineResources.MicrosoftCommandLineTitle, assemblyVersion); + Output.WriteLine(commandLineBanner, OutputLevel.Information); + Output.WriteLine(CommandLineResources.CopyrightCommandLineTitle, OutputLevel.Information); + Output.WriteLine(string.Empty, OutputLevel.Information); + } + + /// + /// Flattens command line arguments by processing response files. + /// + /// Arguments provided to perform execution with. + /// Array of flattened arguments. + /// 0 if successful and 1 otherwise. + private int FlattenArguments(IEnumerable arguments, out string[] flattenedArguments) + { + List outputArguments = new(); + int result = 0; + + foreach (var arg in arguments) { - contents = null; - try + if (arg.StartsWith("@", StringComparison.Ordinal)) { - contents = File.ReadAllText(fileName); + // response file: + string path = arg.Substring(1).TrimEnd(null); + var hadError = ReadArgumentsAndSanitize(path, out var responseFileArgs, out var nestedArgs); + + if (hadError) + { + result |= 1; + } + else + { + Output.WriteLine(string.Format("vstest.console.exe {0}", responseFileArgs), OutputLevel.Information); + outputArguments.AddRange(nestedArgs); + } } - catch (Exception e) + else { - EqtTrace.Verbose("Executor.Execute: Exiting with exit code of {0}", 1); - EqtTrace.Error(string.Format(CultureInfo.InvariantCulture, "Error: Can't open command line argument file '{0}' : '{1}'", fileName, e.Message)); - this.Output.Error(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.OpenResponseFileError, fileName)); - return true; + outputArguments.Add(arg); } + } + + flattenedArguments = outputArguments.ToArray(); + return result; + } + + /// + /// Read and sanitize the arguments. + /// + /// File provided by user. + /// argument in the file as string. + /// Modified argument after sanitizing the contents of the file. + /// 0 if successful and 1 otherwise. + public bool ReadArgumentsAndSanitize(string fileName, out string args, out string[] arguments) + { + arguments = null; + if (GetContentUsingFile(fileName, out args)) + { + return true; + } + + return !string.IsNullOrEmpty(args) && CommandLineUtilities.SplitCommandLineIntoArguments(args, out arguments); + } - return false; + private bool GetContentUsingFile(string fileName, out string contents) + { + contents = null; + try + { + contents = File.ReadAllText(fileName); + } + catch (Exception e) + { + EqtTrace.Verbose("Executor.Execute: Exiting with exit code of {0}", 1); + EqtTrace.Error(string.Format(CultureInfo.InvariantCulture, "Error: Can't open command line argument file '{0}' : '{1}'", fileName, e.Message)); + Output.Error(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.OpenResponseFileError, fileName)); + return true; } - #endregion + return false; } + + #endregion } \ No newline at end of file diff --git a/src/vstest.console/CommandLine/GenerateFakesUtilities.cs b/src/vstest.console/CommandLine/GenerateFakesUtilities.cs index eb46ffc394..149d33418f 100644 --- a/src/vstest.console/CommandLine/GenerateFakesUtilities.cs +++ b/src/vstest.console/CommandLine/GenerateFakesUtilities.cs @@ -1,24 +1,24 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLineUtilities -{ - using System.Collections.Generic; - using System.Linq; +namespace Microsoft.VisualStudio.TestPlatform.CommandLineUtilities; + +using System.Collections.Generic; +using System.Linq; - using Microsoft.VisualStudio.TestPlatform.CommandLine; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using CommandLine; - public static class GenerateFakesUtilities +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; + +public static class GenerateFakesUtilities +{ + internal static void GenerateFakesSettings(CommandLineOptions commandLineOptions, IEnumerable sources, ref string runSettingsXml) { - internal static void GenerateFakesSettings(CommandLineOptions commandLineOptions, IEnumerable sources, ref string runSettingsXml) + // dynamically compute the fakes datacollector settings + // This runs with or without design mode. + if (commandLineOptions == null || !commandLineOptions.DisableAutoFakes) { - // dynamically compute the fakes datacollector settings - // This runs with or without design mode. - if (commandLineOptions == null || !commandLineOptions.DisableAutoFakes) - { - runSettingsXml = FakesUtilities.GenerateFakesSettingsForRunConfiguration(sources.ToArray(), runSettingsXml); - } + runSettingsXml = FakesUtilities.GenerateFakesSettingsForRunConfiguration(sources.ToArray(), runSettingsXml); } } -} +} \ No newline at end of file diff --git a/src/vstest.console/CommandLine/InferHelper.cs b/src/vstest.console/CommandLine/InferHelper.cs index 5b0d6c4835..fe8699ee20 100644 --- a/src/vstest.console/CommandLine/InferHelper.cs +++ b/src/vstest.console/CommandLine/InferHelper.cs @@ -1,185 +1,184 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLineUtilities +namespace Microsoft.VisualStudio.TestPlatform.CommandLineUtilities; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Runtime.Versioning; + +using CommandLine.Processors; + +using ObjectModel; + +internal class InferHelper { - using System; - using System.Collections.Generic; - using System.IO; - using System.Runtime.Versioning; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - - internal class InferHelper - { - private IAssemblyMetadataProvider assemblyMetadataProvider; + private readonly IAssemblyMetadataProvider _assemblyMetadataProvider; - internal InferHelper(IAssemblyMetadataProvider assemblyMetadataProvider) - { - this.assemblyMetadataProvider = assemblyMetadataProvider; - } + internal InferHelper(IAssemblyMetadataProvider assemblyMetadataProvider) + { + _assemblyMetadataProvider = assemblyMetadataProvider; + } - /// - /// Determines Architecture from sources. - /// - public Architecture AutoDetectArchitecture(IList sources, IDictionary sourcePlatforms, Architecture defaultArchitecture) + /// + /// Determines Architecture from sources. + /// + public Architecture AutoDetectArchitecture(IList sources, IDictionary sourcePlatforms, Architecture defaultArchitecture) + { + var architecture = defaultArchitecture; + try { - var architecture = defaultArchitecture; - try + if (sources != null && sources.Count > 0) { - if (sources != null && sources.Count > 0) + Architecture? finalArch = null; + foreach (string source in sources) { - Architecture? finalArch = null; - foreach (string source in sources) + Architecture arch; + if (IsDotNetAssembly(source)) + { + arch = _assemblyMetadataProvider.GetArchitecture(source); + } + else + { + // Set AnyCPU for non dotnet test sources (js, py and other). Otherwise warning will + // show up if there is mismatch with user provided platform. + arch = Architecture.AnyCPU; + } + EqtTrace.Info("Determined platform for source '{0}' is '{1}'", source, arch); + sourcePlatforms[source] = arch; + + if (Architecture.AnyCPU.Equals(arch)) + { + // If arch is AnyCPU ignore it. + continue; + } + + if (finalArch == null) { - Architecture arch; - if (IsDotNETAssembly(source)) - { - arch = assemblyMetadataProvider.GetArchitecture(source); - } - else - { - // Set AnyCPU for non dotnet test sources (js, py and other). Otherwise warning will - // show up if there is mismatch with user provided platform. - arch = Architecture.AnyCPU; - } - EqtTrace.Info("Determined platform for source '{0}' is '{1}'", source, arch); - sourcePlatforms[source]= arch; - - if (Architecture.AnyCPU.Equals(arch)) - { - // If arch is AnyCPU ignore it. - continue; - } - - if (finalArch == null) - { - finalArch = arch; - continue; - } - - if (!finalArch.Equals(arch)) - { - finalArch = defaultArchitecture; - EqtTrace.Info("Conflict in platform architecture, using default platform:{0}", finalArch); - } + finalArch = arch; + continue; } - if (finalArch != null) + if (!finalArch.Equals(arch)) { - architecture = (Architecture)finalArch; + finalArch = defaultArchitecture; + EqtTrace.Info("Conflict in platform architecture, using default platform:{0}", finalArch); } } - } - catch (Exception ex) - { - EqtTrace.Error("Failed to determine platform: {0}, using default: {1}", ex, architecture); - } - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("Determined platform for all sources: {0}", architecture); + if (finalArch != null) + { + architecture = (Architecture)finalArch; + } } + } + catch (Exception ex) + { + EqtTrace.Error("Failed to determine platform: {0}, using default: {1}", ex, architecture); + } - return architecture; + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("Determined platform for all sources: {0}", architecture); } - /// - /// Determines Framework from sources. - /// - public Framework AutoDetectFramework(IList sources, IDictionary sourceFrameworkVersions) + return architecture; + } + + /// + /// Determines Framework from sources. + /// + public Framework AutoDetectFramework(IList sources, IDictionary sourceFrameworkVersions) + { + Framework framework = Framework.DefaultFramework; + try { - Framework framework = Framework.DefaultFramework; - try + if (sources != null && sources.Count > 0) { - if (sources != null && sources.Count > 0) + var finalFx = DetermineFrameworkName(sources, sourceFrameworkVersions, out var conflictInFxIdentifier); + framework = Framework.FromString(finalFx.FullName); + if (conflictInFxIdentifier && EqtTrace.IsInfoEnabled) { - var finalFx = DetermineFrameworkName(sources, sourceFrameworkVersions, out var conflictInFxIdentifier); - framework = Framework.FromString(finalFx.FullName); - if (conflictInFxIdentifier && EqtTrace.IsInfoEnabled) - { - // TODO Log to console and client. - EqtTrace.Info( - "conflicts in Framework identifier of provided sources(test assemblies), using default framework:{0}", - framework); - } + // TODO Log to console and client. + EqtTrace.Info( + "conflicts in Framework identifier of provided sources(test assemblies), using default framework:{0}", + framework); } } - catch (Exception ex) - { - EqtTrace.Error("Failed to determine framework:{0}, using default: {1}", ex, framework); - } - - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("Determined framework for all sources: {0}", framework); - } + } + catch (Exception ex) + { + EqtTrace.Error("Failed to determine framework:{0}, using default: {1}", ex, framework); + } - return framework; + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("Determined framework for all sources: {0}", framework); } - private FrameworkName DetermineFrameworkName(IEnumerable sources, IDictionary sourceFrameworkVersions, out bool conflictInFxIdentifier) + return framework; + } + + private FrameworkName DetermineFrameworkName(IEnumerable sources, IDictionary sourceFrameworkVersions, out bool conflictInFxIdentifier) + { + FrameworkName finalFx = null; + conflictInFxIdentifier = false; + foreach (string source in sources) { - FrameworkName finalFx = null; - conflictInFxIdentifier = false; - foreach (string source in sources) + FrameworkName fx; + if (IsDotNetAssembly(source)) { - FrameworkName fx; - if (IsDotNETAssembly(source)) + fx = _assemblyMetadataProvider.GetFrameWork(source); + } + else + { + // TODO What else to do with appx, js and other? + var extension = Path.GetExtension(source); + if (extension.Equals(".js", StringComparison.OrdinalIgnoreCase)) { - fx = assemblyMetadataProvider.GetFrameWork(source); + // Currently to run tests for .NET Core, assembly need dependency to Microsoft.NET.Test.Sdk. Which is not + // possible for js files. So using default .NET Full framework version. + fx = new FrameworkName(Constants.DotNetFramework40); } else { - // TODO What else to do with appx, js and other? - var extension = Path.GetExtension(source); - if (extension.Equals(".js", StringComparison.OrdinalIgnoreCase)) - { - // Currently to run tests for .NET Core, assembly need dependency to Microsoft.NET.Test.Sdk. Which is not - // possible for js files. So using default .NET Full framework version. - fx = new FrameworkName(Constants.DotNetFramework40); - } - else if (extension.Equals(".appx", StringComparison.OrdinalIgnoreCase) - || extension.Equals(".msix", StringComparison.OrdinalIgnoreCase) - || extension.Equals(".appxrecipe", StringComparison.OrdinalIgnoreCase)) - { - fx = new FrameworkName(Constants.DotNetFrameworkUap10); - } - else - { - fx = new FrameworkName(Framework.DefaultFramework.Name); - } + fx = extension.Equals(".appx", StringComparison.OrdinalIgnoreCase) + || extension.Equals(".msix", StringComparison.OrdinalIgnoreCase) + || extension.Equals(".appxrecipe", StringComparison.OrdinalIgnoreCase) + ? new FrameworkName(Constants.DotNetFrameworkUap10) + : new FrameworkName(Framework.DefaultFramework.Name); } - sourceFrameworkVersions[source] = Framework.FromString(fx.FullName); + } + sourceFrameworkVersions[source] = Framework.FromString(fx.FullName); - if (finalFx == null) - { - finalFx = fx; - continue; - } + if (finalFx == null) + { + finalFx = fx; + continue; + } - if (finalFx.Identifier.Equals(fx.Identifier)) - { - // Use latest version. - if (finalFx.Version < fx.Version) - { - finalFx = fx; - } - } - else + if (finalFx.Identifier.Equals(fx.Identifier)) + { + // Use latest version. + if (finalFx.Version < fx.Version) { - conflictInFxIdentifier = true; - finalFx = new FrameworkName(Framework.DefaultFramework.Name); + finalFx = fx; } } - return finalFx; + else + { + conflictInFxIdentifier = true; + finalFx = new FrameworkName(Framework.DefaultFramework.Name); + } } + return finalFx; + } - private bool IsDotNETAssembly(string filePath) - { - var extType = Path.GetExtension(filePath); - return extType != null && (extType.Equals(".dll", StringComparison.OrdinalIgnoreCase) || - extType.Equals(".exe", StringComparison.OrdinalIgnoreCase)); - } + private bool IsDotNetAssembly(string filePath) + { + var extType = Path.GetExtension(filePath); + return extType != null && (extType.Equals(".dll", StringComparison.OrdinalIgnoreCase) || + extType.Equals(".exe", StringComparison.OrdinalIgnoreCase)); } -} +} \ No newline at end of file diff --git a/src/vstest.console/CommandLine/Interfaces/IAssemblyMetadataProvider.cs b/src/vstest.console/CommandLine/Interfaces/IAssemblyMetadataProvider.cs index 03f55c077b..cc3b44968c 100644 --- a/src/vstest.console/CommandLine/Interfaces/IAssemblyMetadataProvider.cs +++ b/src/vstest.console/CommandLine/Interfaces/IAssemblyMetadataProvider.cs @@ -1,24 +1,24 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors -{ - using System.Runtime.Versioning; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System.Runtime.Versioning; + +using ObjectModel; +/// +/// Defines interface for assembly properties. +/// +internal interface IAssemblyMetadataProvider +{ /// - /// Defines interface for assembly properties. + /// Determines FrameworkName from filePath. /// - internal interface IAssemblyMetadataProvider - { - /// - /// Determines FrameworkName from filePath. - /// - FrameworkName GetFrameWork(string filePath); + FrameworkName GetFrameWork(string filePath); - /// - /// Determines Architecture from filePath. - /// - Architecture GetArchitecture(string filePath); - } -} + /// + /// Determines Architecture from filePath. + /// + Architecture GetArchitecture(string filePath); +} \ No newline at end of file diff --git a/src/vstest.console/CommandLine/TestRunResultAggregator.cs b/src/vstest.console/CommandLine/TestRunResultAggregator.cs index 726d321b99..02ea92fa2f 100644 --- a/src/vstest.console/CommandLine/TestRunResultAggregator.cs +++ b/src/vstest.console/CommandLine/TestRunResultAggregator.cs @@ -1,133 +1,132 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine +namespace Microsoft.VisualStudio.TestPlatform.CommandLine; + +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Logging; + +/// +/// Aggregates test messages and test results received to determine the test run result. +/// +internal class TestRunResultAggregator { - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + private static TestRunResultAggregator s_instance = null; + + #region Constructor /// - /// Aggregates test messages and test results received to determine the test run result. + /// Initializes the TestRunResultAggregator /// - internal class TestRunResultAggregator + /// Constructor is private since the factory method should be used to get the instance. + protected TestRunResultAggregator() { - private static TestRunResultAggregator instance = null; - - #region Constructor - - /// - /// Initializes the TestRunResultAggregator - /// - /// Constructor is private since the factory method should be used to get the instance. - protected TestRunResultAggregator() - { - // Outcome is passed until we see a failure. - this.Outcome = TestOutcome.Passed; - } + // Outcome is passed until we see a failure. + Outcome = TestOutcome.Passed; + } - #endregion + #endregion - #region Static Methods + #region Static Methods - /// - /// Gets the instance of the test run result aggregator. - /// - /// Instance of the test run result aggregator. - public static TestRunResultAggregator Instance + /// + /// Gets the instance of the test run result aggregator. + /// + /// Instance of the test run result aggregator. + public static TestRunResultAggregator Instance + { + get { - get + if (s_instance == null) { - if(instance == null) - { - instance = new TestRunResultAggregator(); - } - - return instance; + s_instance = new TestRunResultAggregator(); } + + return s_instance; } + } - #endregion + #endregion - #region Properties + #region Properties - /// - /// The current test run outcome. - /// - public TestOutcome Outcome { get; private set; } + /// + /// The current test run outcome. + /// + public TestOutcome Outcome { get; private set; } - #endregion + #endregion - #region Event Handlers + #region Event Handlers - /// - /// Registers to receive events from the provided test run request. - /// These events will then be broadcast to any registered loggers. - /// - /// The run request to register for events on. - public void RegisterTestRunEvents(ITestRunRequest testRunRequest) - { - ValidateArg.NotNull(testRunRequest, nameof(testRunRequest)); + /// + /// Registers to receive events from the provided test run request. + /// These events will then be broadcast to any registered loggers. + /// + /// The run request to register for events on. + public void RegisterTestRunEvents(ITestRunRequest testRunRequest) + { + ValidateArg.NotNull(testRunRequest, nameof(testRunRequest)); - // Register for the events. - testRunRequest.TestRunMessage += TestRunMessageHandler; - testRunRequest.OnRunCompletion += TestRunCompletionHandler; - } + // Register for the events. + testRunRequest.TestRunMessage += TestRunMessageHandler; + testRunRequest.OnRunCompletion += TestRunCompletionHandler; + } - /// - /// Unregisters from the provided test run request to stop receiving events. - /// - /// The run request from which events should be unregistered. - public void UnregisterTestRunEvents(ITestRunRequest testRunRequest) - { - ValidateArg.NotNull(testRunRequest, nameof(testRunRequest)); + /// + /// Unregisters from the provided test run request to stop receiving events. + /// + /// The run request from which events should be unregistered. + public void UnregisterTestRunEvents(ITestRunRequest testRunRequest) + { + ValidateArg.NotNull(testRunRequest, nameof(testRunRequest)); - testRunRequest.TestRunMessage -= TestRunMessageHandler; - testRunRequest.OnRunCompletion -= TestRunCompletionHandler; - } + testRunRequest.TestRunMessage -= TestRunMessageHandler; + testRunRequest.OnRunCompletion -= TestRunCompletionHandler; + } - /// - /// To mark the test run as failed. - /// - public void MarkTestRunFailed() - { - this.Outcome = TestOutcome.Failed; - } + /// + /// To mark the test run as failed. + /// + public void MarkTestRunFailed() + { + Outcome = TestOutcome.Failed; + } + + /// + /// Resets the outcome to default state i.e. Passed + /// + public void Reset() + { + Outcome = TestOutcome.Passed; + } - /// - /// Resets the outcome to default state i.e. Passed - /// - public void Reset() + /// + /// Called when a test run is complete. + /// + private void TestRunCompletionHandler(object sender, TestRunCompleteEventArgs e) + { + if (e.TestRunStatistics == null || e.IsCanceled || e.IsAborted) { - this.Outcome = TestOutcome.Passed; + Outcome = TestOutcome.Failed; } - - /// - /// Called when a test run is complete. - /// - private void TestRunCompletionHandler(object sender, TestRunCompleteEventArgs e) + else if (e.TestRunStatistics[TestOutcome.Failed] > 0) { - if (e.TestRunStatistics == null || e.IsCanceled || e.IsAborted) - { - this.Outcome = TestOutcome.Failed; - } - else if (e.TestRunStatistics[TestOutcome.Failed] > 0) - { - this.Outcome = TestOutcome.Failed; - } + Outcome = TestOutcome.Failed; } + } - /// - /// Called when a test run message is sent. - /// - private void TestRunMessageHandler(object sender, TestRunMessageEventArgs e) + /// + /// Called when a test run message is sent. + /// + private void TestRunMessageHandler(object sender, TestRunMessageEventArgs e) + { + if (e.Level == TestMessageLevel.Error) { - if (e.Level == TestMessageLevel.Error) - { - this.Outcome = TestOutcome.Failed; - } + Outcome = TestOutcome.Failed; } - - #endregion } -} + + #endregion +} \ No newline at end of file diff --git a/src/vstest.console/CommandLine/TestSourceException.cs b/src/vstest.console/CommandLine/TestSourceException.cs index 05f5e734f2..fa72a7a504 100644 --- a/src/vstest.console/CommandLine/TestSourceException.cs +++ b/src/vstest.console/CommandLine/TestSourceException.cs @@ -1,44 +1,43 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine +namespace Microsoft.VisualStudio.TestPlatform.CommandLine; + +using System; + +/// +/// Exception thrown by argument processors when they encounter an error with test source +/// arguments. +/// +public class TestSourceException : Exception { - using System; + #region Constructors /// - /// Exception thrown by argument processors when they encounter an error with test source - /// arguments. + /// Creates a new TestSourceException /// - public class TestSourceException : Exception + public TestSourceException() { - #region Constructors - - /// - /// Creates a new TestSourceException - /// - public TestSourceException() - { - } - - /// - /// Initializes with the message. - /// - /// Message for the exception. - public TestSourceException(string message) - : this(message, innerException: null) - { - } + } - /// - /// Initializes with the message and innerException. - /// - /// Message for the exception. - /// The exception that is the cause of the current exception, or a null reference. - public TestSourceException(string message, Exception innerException) - : base(message, innerException) - { - } + /// + /// Initializes with the message. + /// + /// Message for the exception. + public TestSourceException(string message) + : this(message, innerException: null) + { + } - #endregion + /// + /// Initializes with the message and innerException. + /// + /// Message for the exception. + /// The exception that is the cause of the current exception, or a null reference. + public TestSourceException(string message, Exception innerException) + : base(message, innerException) + { } -} + + #endregion +} \ No newline at end of file diff --git a/src/vstest.console/Internal/ConsoleHelper.cs b/src/vstest.console/Internal/ConsoleHelper.cs index 73ad3975c4..fdbdd829ad 100644 --- a/src/vstest.console/Internal/ConsoleHelper.cs +++ b/src/vstest.console/Internal/ConsoleHelper.cs @@ -1,25 +1,24 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; - internal class ConsoleHelper : IConsoleHelper - { - /// - public int CursorLeft => Console.CursorLeft; +using System; - /// - public int CursorTop => Console.CursorTop; +internal class ConsoleHelper : IConsoleHelper +{ + /// + public int CursorLeft => Console.CursorLeft; - /// - public int WindowWidth => Console.WindowWidth; + /// + public int CursorTop => Console.CursorTop; - /// - public void SetCursorPosition(int left, int top) - { - Console.SetCursorPosition(left, top); - } + /// + public int WindowWidth => Console.WindowWidth; + + /// + public void SetCursorPosition(int left, int top) + { + Console.SetCursorPosition(left, top); } -} +} \ No newline at end of file diff --git a/src/vstest.console/Internal/ConsoleLogger.cs b/src/vstest.console/Internal/ConsoleLogger.cs index a12fde8bcb..10ba3b13a8 100644 --- a/src/vstest.console/Internal/ConsoleLogger.cs +++ b/src/vstest.console/Internal/ConsoleLogger.cs @@ -1,849 +1,829 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; + +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using System.Text; + +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Logging; +using Utilities; + +using NuGet.Frameworks; + +using CommandLineResources = Resources.Resources; +/// +/// Logger for sending output to the console. +/// All the console logger messages prints to Standard Output with respective color, except OutputLevel.Error messages +/// from adapters and test run result on failed. +/// +[FriendlyName(FriendlyName)] +[ExtensionUri(ExtensionUri)] +internal class ConsoleLogger : ITestLoggerWithParameters { - using System; - using System.Collections.Concurrent; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Diagnostics; - using System.Globalization; - using System.Linq; - using System.Text; - using System.Xml.XPath; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using NuGet.Frameworks; - using CommandLineResources = Resources.Resources; + #region Constants + private const string TestMessageFormattingPrefix = " "; + /// - /// Logger for sending output to the console. - /// All the console logger messages prints to Standard Output with respective color, except OutputLevel.Error messages - /// from adapters and test run result on failed. + /// Prefix used for formatting the result output /// - [FriendlyName(ConsoleLogger.FriendlyName)] - [ExtensionUri(ConsoleLogger.ExtensionUri)] - internal class ConsoleLogger : ITestLoggerWithParameters - { - #region Constants - private const string TestMessageFormattingPrefix = " "; - - /// - /// Prefix used for formatting the result output - /// - private const string TestResultPrefix = " "; - - /// - /// Bool to decide whether Verbose level should be added as prefix or not in log messages. - /// - internal static bool AppendPrefix; - - /// - /// Bool to decide whether progress indicator should be enabled. - /// - internal static bool EnableProgress; - - /// - /// Uri used to uniquely identify the console logger. - /// - public const string ExtensionUri = "logger://Microsoft/TestPlatform/ConsoleLogger/v1"; - - /// - /// Alternate user friendly string to uniquely identify the console logger. - /// - public const string FriendlyName = "Console"; - - /// - /// Parameter for Verbosity - /// - public const string VerbosityParam = "verbosity"; - - /// - /// Parameter for log message prefix - /// - public const string PrefixParam = "prefix"; - - /// - /// Parameter for disabling progress - /// - public const string ProgressIndicatorParam = "progress"; - - /// - /// Property Id storing the ParentExecutionId. - /// - public const string ParentExecutionIdPropertyIdentifier = "ParentExecId"; - - /// - /// Property Id storing the ExecutionId. - /// - public const string ExecutionIdPropertyIdentifier = "ExecutionId"; - - // Figure out the longest result string (+1 for ! where applicable), so we don't - // get misaligned output on non-english systems - private static int LongestResultIndicator = new[] - { - CommandLineResources.FailedTestIndicator.Length + 1, - CommandLineResources.PassedTestIndicator.Length + 1, - CommandLineResources.SkippedTestIndicator.Length + 1, - CommandLineResources.None.Length - }.Max(); - - #endregion - - internal enum Verbosity - { - Quiet, - Minimal, - Normal, - Detailed - } - - #region Fields - - /// - /// Level of verbosity - /// -#if NETFRAMEWORK - private Verbosity verbosityLevel = Verbosity.Normal; -#else - // Keep default verbosity for x-plat command line as minimal - private Verbosity verbosityLevel = Verbosity.Minimal; -#endif + private const string TestResultPrefix = " "; - private bool testRunHasErrorMessages = false; + /// + /// Bool to decide whether Verbose level should be added as prefix or not in log messages. + /// + internal static bool AppendPrefix; - /// - /// Framework on which the test runs. - /// - private string targetFramework; + /// + /// Bool to decide whether progress indicator should be enabled. + /// + internal static bool EnableProgress; - #endregion + /// + /// Uri used to uniquely identify the console logger. + /// + public const string ExtensionUri = "logger://Microsoft/TestPlatform/ConsoleLogger/v1"; - #region Constructor + /// + /// Alternate user friendly string to uniquely identify the console logger. + /// + public const string FriendlyName = "Console"; - /// - /// Default constructor. - /// - public ConsoleLogger() - { - } + /// + /// Parameter for Verbosity + /// + public const string VerbosityParam = "verbosity"; - /// - /// Constructor added for testing purpose - /// - /// - internal ConsoleLogger(IOutput output, IProgressIndicator progressIndicator) - { - ConsoleLogger.Output = output; - this.progressIndicator = progressIndicator; - } + /// + /// Parameter for log message prefix + /// + public const string PrefixParam = "prefix"; - #endregion + /// + /// Parameter for disabling progress + /// + public const string ProgressIndicatorParam = "progress"; - #region Properties + /// + /// Property Id storing the ParentExecutionId. + /// + public const string ParentExecutionIdPropertyIdentifier = "ParentExecId"; - /// - /// Gets instance of IOutput used for sending output. - /// - /// Protected so this can be detoured for testing purposes. - protected static IOutput Output - { - get; - private set; - } + /// + /// Property Id storing the ExecutionId. + /// + public const string ExecutionIdPropertyIdentifier = "ExecutionId"; - private IProgressIndicator progressIndicator; + // Figure out the longest result string (+1 for ! where applicable), so we don't + // get misaligned output on non-english systems + private static readonly int LongestResultIndicator = new[] + { + CommandLineResources.FailedTestIndicator.Length + 1, + CommandLineResources.PassedTestIndicator.Length + 1, + CommandLineResources.SkippedTestIndicator.Length + 1, + CommandLineResources.None.Length + }.Max(); - /// - /// Get the verbosity level for the console logger - /// - public Verbosity VerbosityLevel => verbosityLevel; + #endregion - /// - /// Tracks leaf test outcomes per source. This is needed to correctly count hierarchical tests as well as - /// tracking counts per source for the minimal and quiet output. - /// - private ConcurrentDictionary LeafTestResults { get; set; } + internal enum Verbosity + { + Quiet, + Minimal, + Normal, + Detailed + } - #endregion + #region Fields - #region ITestLoggerWithParameters + private bool _testRunHasErrorMessages = false; - /// - /// Initializes the Test Logger. - /// - /// Events that can be registered for. - /// Test Run Directory - public void Initialize(TestLoggerEvents events, string testRunDirectory) - { - if (events == null) - { - throw new ArgumentNullException(nameof(events)); - } + /// + /// Framework on which the test runs. + /// + private string _targetFramework; - if (ConsoleLogger.Output == null) - { - ConsoleLogger.Output = ConsoleOutput.Instance; - } + #endregion - if (this.progressIndicator == null && !Console.IsOutputRedirected && EnableProgress) - { - // Progress indicator needs to be displayed only for cli experience. - this.progressIndicator = new ProgressIndicator(Output, new ConsoleHelper()); - } + #region Constructor - // Register for the events. - events.TestRunMessage += this.TestMessageHandler; - events.TestResult += this.TestResultHandler; - events.TestRunComplete += this.TestRunCompleteHandler; - events.TestRunStart += this.TestRunStartHandler; + /// + /// Default constructor. + /// + public ConsoleLogger() + { + } - // Register for the discovery events. - events.DiscoveryMessage += this.TestMessageHandler; - this.LeafTestResults = new ConcurrentDictionary(); + /// + /// Constructor added for testing purpose + /// + /// + internal ConsoleLogger(IOutput output, IProgressIndicator progressIndicator) + { + Output = output; + _progressIndicator = progressIndicator; + } - // TODO Get changes from https://github.com/Microsoft/vstest/pull/1111/ - // events.DiscoveredTests += DiscoveredTestsHandler; - } + #endregion - public void Initialize(TestLoggerEvents events, Dictionary parameters) - { - if (parameters == null) - { - throw new ArgumentNullException(nameof(parameters)); - } + #region Properties - if (parameters.Count == 0) - { - throw new ArgumentException("No default parameters added", nameof(parameters)); - } + /// + /// Gets instance of IOutput used for sending output. + /// + /// Protected so this can be detoured for testing purposes. + protected static IOutput Output + { + get; + private set; + } - var verbosityExists = parameters.TryGetValue(ConsoleLogger.VerbosityParam, out var verbosity); - if (verbosityExists && Enum.TryParse(verbosity, true, out Verbosity verbosityLevel)) - { - this.verbosityLevel = verbosityLevel; - } + private IProgressIndicator _progressIndicator; - var prefixExists = parameters.TryGetValue(ConsoleLogger.PrefixParam, out var prefix); - if (prefixExists) - { - bool.TryParse(prefix, out AppendPrefix); - } + /// + /// Get the verbosity level for the console logger + /// - var progressArgExists = parameters.TryGetValue(ConsoleLogger.ProgressIndicatorParam, out var enableProgress); - if (progressArgExists) - { - bool.TryParse(enableProgress, out EnableProgress); - } + public Verbosity VerbosityLevel { get; private set; } = +#if NETFRAMEWORK + Verbosity.Normal; +#else + // Keep default verbosity for x-plat command line as minimal + Verbosity.Minimal; +#endif - parameters.TryGetValue(DefaultLoggerParameterNames.TargetFramework, out this.targetFramework); - this.targetFramework = !string.IsNullOrEmpty(this.targetFramework) ? NuGetFramework.Parse(this.targetFramework).GetShortFolderName() : this.targetFramework; + /// + /// Tracks leaf test outcomes per source. This is needed to correctly count hierarchical tests as well as + /// tracking counts per source for the minimal and quiet output. + /// + private ConcurrentDictionary LeafTestResults { get; set; } - Initialize(events, String.Empty); - } - #endregion + #endregion - #region Private Methods + #region ITestLoggerWithParameters - /// - /// Prints the timespan onto console. - /// - private static void PrintTimeSpan(TimeSpan timeSpan) + /// + /// Initializes the Test Logger. + /// + /// Events that can be registered for. + /// Test Run Directory + public void Initialize(TestLoggerEvents events, string testRunDirectory) + { + if (events == null) { - if (timeSpan.TotalDays >= 1) - { - Output.Information(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.ExecutionTimeFormatString, timeSpan.TotalDays, CommandLineResources.Days)); - } - else if (timeSpan.TotalHours >= 1) - { - Output.Information(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.ExecutionTimeFormatString, timeSpan.TotalHours, CommandLineResources.Hours)); - } - else if (timeSpan.TotalMinutes >= 1) - { - Output.Information(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.ExecutionTimeFormatString, timeSpan.TotalMinutes, CommandLineResources.Minutes)); - } - else - { - Output.Information(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.ExecutionTimeFormatString, timeSpan.TotalSeconds, CommandLineResources.Seconds)); - } + throw new ArgumentNullException(nameof(events)); } - /// - /// Constructs a well formatted string using the given prefix before every message content on each line. - /// - private static string GetFormattedOutput(Collection testMessageCollection) + if (Output == null) { - if (testMessageCollection != null) - { - var sb = new StringBuilder(); - foreach (var message in testMessageCollection) - { - var prefix = String.Format(CultureInfo.CurrentCulture, "{0}{1}", Environment.NewLine, TestMessageFormattingPrefix); - var messageText = message.Text?.Replace(Environment.NewLine, prefix).TrimEnd(TestMessageFormattingPrefix.ToCharArray()); + Output = ConsoleOutput.Instance; + } - if (!string.IsNullOrWhiteSpace(messageText)) - { - sb.AppendFormat(CultureInfo.CurrentCulture, "{0}{1}", TestMessageFormattingPrefix, messageText); - } - } - return sb.ToString(); - } - return String.Empty; + if (_progressIndicator == null && !Console.IsOutputRedirected && EnableProgress) + { + // Progress indicator needs to be displayed only for cli experience. + _progressIndicator = new ProgressIndicator(Output, new ConsoleHelper()); } - /// - /// Collects all the messages of a particular category(Standard Output/Standard Error/Debug Traces) and returns a collection. - /// - private static Collection GetTestMessages(Collection Messages, string requiredCategory) + // Register for the events. + events.TestRunMessage += TestMessageHandler; + events.TestResult += TestResultHandler; + events.TestRunComplete += TestRunCompleteHandler; + events.TestRunStart += TestRunStartHandler; + + // Register for the discovery events. + events.DiscoveryMessage += TestMessageHandler; + LeafTestResults = new ConcurrentDictionary(); + + // TODO Get changes from https://github.com/Microsoft/vstest/pull/1111/ + // events.DiscoveredTests += DiscoveredTestsHandler; + } + + public void Initialize(TestLoggerEvents events, Dictionary parameters) + { + if (parameters == null) { - var selectedMessages = Messages.Where(msg => msg.Category.Equals(requiredCategory, StringComparison.OrdinalIgnoreCase)); - var requiredMessageCollection = new Collection(selectedMessages.ToList()); - return requiredMessageCollection; + throw new ArgumentNullException(nameof(parameters)); } - /// - /// outputs the Error messages, Stack Trace, and other messages for the parameter test. - /// - private static void DisplayFullInformation(TestResult result) + if (parameters.Count == 0) { + throw new ArgumentException("No default parameters added", nameof(parameters)); + } - // Add newline if it is not in given output data. - var addAdditionalNewLine = false; + var verbosityExists = parameters.TryGetValue(VerbosityParam, out var verbosity); + if (verbosityExists && Enum.TryParse(verbosity, true, out Verbosity verbosityLevel)) + { + VerbosityLevel = verbosityLevel; + } - Debug.Assert(result != null, "a null result can not be displayed"); - if (!String.IsNullOrEmpty(result.ErrorMessage)) - { - addAdditionalNewLine = true; - Output.Information(false, ConsoleColor.Red, string.Format("{0}{1}", TestResultPrefix, CommandLineResources.ErrorMessageBanner)); - var errorMessage = String.Format(CultureInfo.CurrentCulture, "{0}{1}{2}", TestResultPrefix, TestMessageFormattingPrefix, result.ErrorMessage); - Output.Information(false, ConsoleColor.Red, errorMessage); - } + var prefixExists = parameters.TryGetValue(PrefixParam, out var prefix); + if (prefixExists) + { + bool.TryParse(prefix, out AppendPrefix); + } - if (!String.IsNullOrEmpty(result.ErrorStackTrace)) - { - addAdditionalNewLine = false; - Output.Information(false, ConsoleColor.Red, string.Format("{0}{1}", TestResultPrefix, CommandLineResources.StacktraceBanner)); - var stackTrace = String.Format(CultureInfo.CurrentCulture, "{0}{1}", TestResultPrefix, result.ErrorStackTrace); - Output.Information(false, ConsoleColor.Red, stackTrace); - } + var progressArgExists = parameters.TryGetValue(ProgressIndicatorParam, out var enableProgress); + if (progressArgExists) + { + bool.TryParse(enableProgress, out EnableProgress); + } - var stdOutMessagesCollection = GetTestMessages(result.Messages, TestResultMessage.StandardOutCategory); - if (stdOutMessagesCollection.Count > 0) - { - addAdditionalNewLine = true; - var stdOutMessages = GetFormattedOutput(stdOutMessagesCollection); + parameters.TryGetValue(DefaultLoggerParameterNames.TargetFramework, out _targetFramework); + _targetFramework = !string.IsNullOrEmpty(_targetFramework) ? NuGetFramework.Parse(_targetFramework).GetShortFolderName() : _targetFramework; - if (!string.IsNullOrEmpty(stdOutMessages)) - { - Output.Information(false, string.Format("{0}{1}", TestResultPrefix, CommandLineResources.StdOutMessagesBanner)); - Output.Information(false, stdOutMessages); - } - } + Initialize(events, String.Empty); + } + #endregion - var stdErrMessagesCollection = GetTestMessages(result.Messages, TestResultMessage.StandardErrorCategory); - if (stdErrMessagesCollection.Count > 0) - { - addAdditionalNewLine = false; - var stdErrMessages = GetFormattedOutput(stdErrMessagesCollection); + #region Private Methods - if (!string.IsNullOrEmpty(stdErrMessages)) - { - Output.Information(false, ConsoleColor.Red, string.Format("{0}{1}", TestResultPrefix, CommandLineResources.StdErrMessagesBanner)); - Output.Information(false, ConsoleColor.Red, stdErrMessages); - } - } + /// + /// Prints the timespan onto console. + /// + private static void PrintTimeSpan(TimeSpan timeSpan) + { + if (timeSpan.TotalDays >= 1) + { + Output.Information(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.ExecutionTimeFormatString, timeSpan.TotalDays, CommandLineResources.Days)); + } + else if (timeSpan.TotalHours >= 1) + { + Output.Information(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.ExecutionTimeFormatString, timeSpan.TotalHours, CommandLineResources.Hours)); + } + else if (timeSpan.TotalMinutes >= 1) + { + Output.Information(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.ExecutionTimeFormatString, timeSpan.TotalMinutes, CommandLineResources.Minutes)); + } + else + { + Output.Information(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.ExecutionTimeFormatString, timeSpan.TotalSeconds, CommandLineResources.Seconds)); + } + } - var DbgTrcMessagesCollection = GetTestMessages(result.Messages, TestResultMessage.DebugTraceCategory); - if (DbgTrcMessagesCollection.Count > 0) + /// + /// Constructs a well formatted string using the given prefix before every message content on each line. + /// + private static string GetFormattedOutput(Collection testMessageCollection) + { + if (testMessageCollection != null) + { + var sb = new StringBuilder(); + foreach (var message in testMessageCollection) { - addAdditionalNewLine = false; - var dbgTrcMessages = GetFormattedOutput(DbgTrcMessagesCollection); + var prefix = String.Format(CultureInfo.CurrentCulture, "{0}{1}", Environment.NewLine, TestMessageFormattingPrefix); + var messageText = message.Text?.Replace(Environment.NewLine, prefix).TrimEnd(TestMessageFormattingPrefix.ToCharArray()); - if (!string.IsNullOrEmpty(dbgTrcMessages)) + if (!string.IsNullOrWhiteSpace(messageText)) { - Output.Information(false, string.Format("{0}{1}", TestResultPrefix, CommandLineResources.DbgTrcMessagesBanner)); - Output.Information(false, dbgTrcMessages); + sb.AppendFormat(CultureInfo.CurrentCulture, "{0}{1}", TestMessageFormattingPrefix, messageText); } } + return sb.ToString(); + } + return String.Empty; + } - var addnlInfoMessagesCollection = GetTestMessages(result.Messages, TestResultMessage.AdditionalInfoCategory); - if (addnlInfoMessagesCollection.Count > 0) - { - addAdditionalNewLine = false; - var addnlInfoMessages = GetFormattedOutput(addnlInfoMessagesCollection); + /// + /// Collects all the messages of a particular category(Standard Output/Standard Error/Debug Traces) and returns a collection. + /// + private static Collection GetTestMessages(Collection messages, string requiredCategory) + { + var selectedMessages = messages.Where(msg => msg.Category.Equals(requiredCategory, StringComparison.OrdinalIgnoreCase)); + var requiredMessageCollection = new Collection(selectedMessages.ToList()); + return requiredMessageCollection; + } - if (!string.IsNullOrEmpty(addnlInfoMessages)) - { - Output.Information(false, string.Format("{0}{1}", TestResultPrefix, CommandLineResources.AddnlInfoMessagesBanner)); - Output.Information(false, addnlInfoMessages); - } - } + /// + /// outputs the Error messages, Stack Trace, and other messages for the parameter test. + /// + private static void DisplayFullInformation(TestResult result) + { - if (addAdditionalNewLine) - { - Output.WriteLine(String.Empty, OutputLevel.Information); - } + // Add newline if it is not in given output data. + var addAdditionalNewLine = false; + + Debug.Assert(result != null, "a null result can not be displayed"); + if (!String.IsNullOrEmpty(result.ErrorMessage)) + { + addAdditionalNewLine = true; + Output.Information(false, ConsoleColor.Red, string.Format("{0}{1}", TestResultPrefix, CommandLineResources.ErrorMessageBanner)); + var errorMessage = String.Format(CultureInfo.CurrentCulture, "{0}{1}{2}", TestResultPrefix, TestMessageFormattingPrefix, result.ErrorMessage); + Output.Information(false, ConsoleColor.Red, errorMessage); } - /// - /// Returns the parent Execution id of given test result. - /// - /// - /// - private Guid GetParentExecutionId(TestResult testResult) + if (!String.IsNullOrEmpty(result.ErrorStackTrace)) { - var parentExecutionIdProperty = testResult.Properties.FirstOrDefault(property => - property.Id.Equals(ParentExecutionIdPropertyIdentifier)); - return parentExecutionIdProperty == null - ? Guid.Empty - : testResult.GetPropertyValue(parentExecutionIdProperty, Guid.Empty); + addAdditionalNewLine = false; + Output.Information(false, ConsoleColor.Red, string.Format("{0}{1}", TestResultPrefix, CommandLineResources.StacktraceBanner)); + var stackTrace = String.Format(CultureInfo.CurrentCulture, "{0}{1}", TestResultPrefix, result.ErrorStackTrace); + Output.Information(false, ConsoleColor.Red, stackTrace); } - /// - /// Returns execution id of given test result - /// - /// - /// - private Guid GetExecutionId(TestResult testResult) + var stdOutMessagesCollection = GetTestMessages(result.Messages, TestResultMessage.StandardOutCategory); + if (stdOutMessagesCollection.Count > 0) { - var executionIdProperty = testResult.Properties.FirstOrDefault(property => - property.Id.Equals(ExecutionIdPropertyIdentifier)); - var executionId = Guid.Empty; + addAdditionalNewLine = true; + var stdOutMessages = GetFormattedOutput(stdOutMessagesCollection); - if (executionIdProperty != null) + if (!string.IsNullOrEmpty(stdOutMessages)) { - executionId = testResult.GetPropertyValue(executionIdProperty, Guid.Empty); + Output.Information(false, string.Format("{0}{1}", TestResultPrefix, CommandLineResources.StdOutMessagesBanner)); + Output.Information(false, stdOutMessages); } - - return executionId.Equals(Guid.Empty) ? Guid.NewGuid() : executionId; } - #endregion + var stdErrMessagesCollection = GetTestMessages(result.Messages, TestResultMessage.StandardErrorCategory); + if (stdErrMessagesCollection.Count > 0) + { + addAdditionalNewLine = false; + var stdErrMessages = GetFormattedOutput(stdErrMessagesCollection); - #region Event Handlers + if (!string.IsNullOrEmpty(stdErrMessages)) + { + Output.Information(false, ConsoleColor.Red, string.Format("{0}{1}", TestResultPrefix, CommandLineResources.StdErrMessagesBanner)); + Output.Information(false, ConsoleColor.Red, stdErrMessages); + } + } - /// - /// Called when a test run start is received - /// - private void TestRunStartHandler(object sender, TestRunStartEventArgs e) + var dbgTrcMessagesCollection = GetTestMessages(result.Messages, TestResultMessage.DebugTraceCategory); + if (dbgTrcMessagesCollection.Count > 0) { - ValidateArg.NotNull(sender, nameof(sender)); - ValidateArg.NotNull(e, nameof(e)); + addAdditionalNewLine = false; + var dbgTrcMessages = GetFormattedOutput(dbgTrcMessagesCollection); - // Print all test containers. - Output.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestSourcesDiscovered, CommandLineOptions.Instance.Sources.Count()), OutputLevel.Information); - if (verbosityLevel == Verbosity.Detailed) + if (!string.IsNullOrEmpty(dbgTrcMessages)) { - foreach (var source in CommandLineOptions.Instance.Sources) - { - Output.WriteLine(source, OutputLevel.Information); - } + Output.Information(false, string.Format("{0}{1}", TestResultPrefix, CommandLineResources.DbgTrcMessagesBanner)); + Output.Information(false, dbgTrcMessages); } } - /// - /// Called when a test message is received. - /// - private void TestMessageHandler(object sender, TestRunMessageEventArgs e) + var addnlInfoMessagesCollection = GetTestMessages(result.Messages, TestResultMessage.AdditionalInfoCategory); + if (addnlInfoMessagesCollection.Count > 0) { - ValidateArg.NotNull(sender, nameof(sender)); - ValidateArg.NotNull(e, nameof(e)); + addAdditionalNewLine = false; + var addnlInfoMessages = GetFormattedOutput(addnlInfoMessagesCollection); - switch (e.Level) + if (!string.IsNullOrEmpty(addnlInfoMessages)) { - case TestMessageLevel.Informational: - { - if (verbosityLevel == Verbosity.Quiet || verbosityLevel == Verbosity.Minimal) - { - break; - } + Output.Information(false, string.Format("{0}{1}", TestResultPrefix, CommandLineResources.AddnlInfoMessagesBanner)); + Output.Information(false, addnlInfoMessages); + } + } - // Pause the progress indicator to print the message - this.progressIndicator?.Pause(); + if (addAdditionalNewLine) + { + Output.WriteLine(String.Empty, OutputLevel.Information); + } + } - Output.Information(AppendPrefix, e.Message); + /// + /// Returns the parent Execution id of given test result. + /// + /// + /// + private Guid GetParentExecutionId(TestResult testResult) + { + var parentExecutionIdProperty = testResult.Properties.FirstOrDefault(property => + property.Id.Equals(ParentExecutionIdPropertyIdentifier)); + return parentExecutionIdProperty == null + ? Guid.Empty + : testResult.GetPropertyValue(parentExecutionIdProperty, Guid.Empty); + } - // Resume the progress indicator after printing the message - this.progressIndicator?.Start(); + /// + /// Returns execution id of given test result + /// + /// + /// + private Guid GetExecutionId(TestResult testResult) + { + var executionIdProperty = testResult.Properties.FirstOrDefault(property => + property.Id.Equals(ExecutionIdPropertyIdentifier)); + var executionId = Guid.Empty; - break; - } + if (executionIdProperty != null) + { + executionId = testResult.GetPropertyValue(executionIdProperty, Guid.Empty); + } - case TestMessageLevel.Warning: - { - if (verbosityLevel == Verbosity.Quiet) - { - break; - } + return executionId.Equals(Guid.Empty) ? Guid.NewGuid() : executionId; + } - // Pause the progress indicator to print the message - this.progressIndicator?.Pause(); + #endregion - Output.Warning(AppendPrefix, e.Message); + #region Event Handlers - // Resume the progress indicator after printing the message - this.progressIndicator?.Start(); + /// + /// Called when a test run start is received + /// + private void TestRunStartHandler(object sender, TestRunStartEventArgs e) + { + ValidateArg.NotNull(sender, nameof(sender)); + ValidateArg.NotNull(e, nameof(e)); + + // Print all test containers. + Output.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestSourcesDiscovered, CommandLineOptions.Instance.Sources.Count()), OutputLevel.Information); + if (VerbosityLevel == Verbosity.Detailed) + { + foreach (var source in CommandLineOptions.Instance.Sources) + { + Output.WriteLine(source, OutputLevel.Information); + } + } + } + + /// + /// Called when a test message is received. + /// + private void TestMessageHandler(object sender, TestRunMessageEventArgs e) + { + ValidateArg.NotNull(sender, nameof(sender)); + ValidateArg.NotNull(e, nameof(e)); + switch (e.Level) + { + case TestMessageLevel.Informational: + { + if (VerbosityLevel == Verbosity.Quiet || VerbosityLevel == Verbosity.Minimal) + { break; } - case TestMessageLevel.Error: - { - // Pause the progress indicator to print the message - this.progressIndicator?.Pause(); + // Pause the progress indicator to print the message + _progressIndicator?.Pause(); - this.testRunHasErrorMessages = true; - Output.Error(AppendPrefix, e.Message); + Output.Information(AppendPrefix, e.Message); - // Resume the progress indicator after printing the message - this.progressIndicator?.Start(); + // Resume the progress indicator after printing the message + _progressIndicator?.Start(); + break; + } + + case TestMessageLevel.Warning: + { + if (VerbosityLevel == Verbosity.Quiet) + { break; } - default: - EqtTrace.Warning("ConsoleLogger.TestMessageHandler: The test message level is unrecognized: {0}", e.Level.ToString()); + + // Pause the progress indicator to print the message + _progressIndicator?.Pause(); + + Output.Warning(AppendPrefix, e.Message); + + // Resume the progress indicator after printing the message + _progressIndicator?.Start(); + break; - } - } + } - /// - /// Called when a test result is received. - /// - private void TestResultHandler(object sender, TestResultEventArgs e) - { - ValidateArg.NotNull(sender, nameof(sender)); - ValidateArg.NotNull(e, nameof(e)); + case TestMessageLevel.Error: + { + // Pause the progress indicator to print the message + _progressIndicator?.Pause(); - var testDisplayName = e.Result.DisplayName; + _testRunHasErrorMessages = true; + Output.Error(AppendPrefix, e.Message); - if (string.IsNullOrWhiteSpace(e.Result.DisplayName)) - { - testDisplayName = e.Result.TestCase.DisplayName; - } + // Resume the progress indicator after printing the message + _progressIndicator?.Start(); - string formattedDuration = this.GetFormattedDurationString(e.Result.Duration); - if (!string.IsNullOrEmpty(formattedDuration)) - { - testDisplayName = string.Format("{0} [{1}]", testDisplayName, formattedDuration); - } + break; + } + default: + EqtTrace.Warning("ConsoleLogger.TestMessageHandler: The test message level is unrecognized: {0}", e.Level.ToString()); + break; + } + } - var executionId = GetExecutionId(e.Result); - var parentExecutionId = GetParentExecutionId(e.Result); + /// + /// Called when a test result is received. + /// + private void TestResultHandler(object sender, TestResultEventArgs e) + { + ValidateArg.NotNull(sender, nameof(sender)); + ValidateArg.NotNull(e, nameof(e)); - if (parentExecutionId != Guid.Empty) - { - // Not checking the result value. - // This would return false if the id did not exist, - // or true if it did exist. In either case the id is not in the dictionary - // which is our goal. - LeafTestResults.TryRemove(parentExecutionId, out _); - } + var testDisplayName = e.Result.DisplayName; - if (!LeafTestResults.TryAdd(executionId, new MinimalTestResult(e.Result))) - { - // This would happen if the key already exists. This should not happen, because we are - // inserting by GUID key, so this would mean an error in our code. - throw new InvalidOperationException($"ExecutionId {executionId} already exists."); - } + if (string.IsNullOrWhiteSpace(e.Result.DisplayName)) + { + testDisplayName = e.Result.TestCase.DisplayName; + } - switch (e.Result.Outcome) - { - case TestOutcome.Skipped: - { - if (this.verbosityLevel == Verbosity.Quiet) - { - break; - } + string formattedDuration = GetFormattedDurationString(e.Result.Duration); + if (!string.IsNullOrEmpty(formattedDuration)) + { + testDisplayName = string.Format("{0} [{1}]", testDisplayName, formattedDuration); + } - // Pause the progress indicator before displaying test result information - this.progressIndicator?.Pause(); + var executionId = GetExecutionId(e.Result); + var parentExecutionId = GetParentExecutionId(e.Result); - Output.Write(string.Format("{0}{1} ", TestResultPrefix, CommandLineResources.SkippedTestIndicator), OutputLevel.Information, ConsoleColor.Yellow); - Output.WriteLine(testDisplayName, OutputLevel.Information); - if (this.verbosityLevel == Verbosity.Detailed) - { - DisplayFullInformation(e.Result); - } + if (parentExecutionId != Guid.Empty) + { + // Not checking the result value. + // This would return false if the id did not exist, + // or true if it did exist. In either case the id is not in the dictionary + // which is our goal. + LeafTestResults.TryRemove(parentExecutionId, out _); + } - // Resume the progress indicator after displaying the test result information - this.progressIndicator?.Start(); + if (!LeafTestResults.TryAdd(executionId, new MinimalTestResult(e.Result))) + { + // This would happen if the key already exists. This should not happen, because we are + // inserting by GUID key, so this would mean an error in our code. + throw new InvalidOperationException($"ExecutionId {executionId} already exists."); + } + switch (e.Result.Outcome) + { + case TestOutcome.Skipped: + { + if (VerbosityLevel == Verbosity.Quiet) + { break; } - case TestOutcome.Failed: - { - if (this.verbosityLevel == Verbosity.Quiet) - { - break; - } + // Pause the progress indicator before displaying test result information + _progressIndicator?.Pause(); - // Pause the progress indicator before displaying test result information - this.progressIndicator?.Pause(); - - Output.Write(string.Format("{0}{1} ", TestResultPrefix, CommandLineResources.FailedTestIndicator), OutputLevel.Information, ConsoleColor.Red); - Output.WriteLine(testDisplayName, OutputLevel.Information); + Output.Write(string.Format("{0}{1} ", TestResultPrefix, CommandLineResources.SkippedTestIndicator), OutputLevel.Information, ConsoleColor.Yellow); + Output.WriteLine(testDisplayName, OutputLevel.Information); + if (VerbosityLevel == Verbosity.Detailed) + { DisplayFullInformation(e.Result); + } - // Resume the progress indicator after displaying the test result information - this.progressIndicator?.Start(); + // Resume the progress indicator after displaying the test result information + _progressIndicator?.Start(); - break; - } + break; + } - case TestOutcome.Passed: + case TestOutcome.Failed: + { + if (VerbosityLevel == Verbosity.Quiet) { - if (this.verbosityLevel == Verbosity.Normal || this.verbosityLevel == Verbosity.Detailed) - { - // Pause the progress indicator before displaying test result information - this.progressIndicator?.Pause(); - - Output.Write(string.Format("{0}{1} ", TestResultPrefix, CommandLineResources.PassedTestIndicator), OutputLevel.Information, ConsoleColor.Green); - Output.WriteLine(testDisplayName, OutputLevel.Information); - if (this.verbosityLevel == Verbosity.Detailed) - { - DisplayFullInformation(e.Result); - } - - // Resume the progress indicator after displaying the test result information - this.progressIndicator?.Start(); - } - break; } - default: - { - if (this.verbosityLevel == Verbosity.Quiet) - { - break; - } + // Pause the progress indicator before displaying test result information + _progressIndicator?.Pause(); + + Output.Write(string.Format("{0}{1} ", TestResultPrefix, CommandLineResources.FailedTestIndicator), OutputLevel.Information, ConsoleColor.Red); + Output.WriteLine(testDisplayName, OutputLevel.Information); + DisplayFullInformation(e.Result); + + // Resume the progress indicator after displaying the test result information + _progressIndicator?.Start(); + + break; + } + case TestOutcome.Passed: + { + if (VerbosityLevel == Verbosity.Normal || VerbosityLevel == Verbosity.Detailed) + { // Pause the progress indicator before displaying test result information - this.progressIndicator?.Pause(); + _progressIndicator?.Pause(); - Output.Write(string.Format("{0}{1} ", TestResultPrefix, CommandLineResources.SkippedTestIndicator), OutputLevel.Information, ConsoleColor.Yellow); + Output.Write(string.Format("{0}{1} ", TestResultPrefix, CommandLineResources.PassedTestIndicator), OutputLevel.Information, ConsoleColor.Green); Output.WriteLine(testDisplayName, OutputLevel.Information); - if (this.verbosityLevel == Verbosity.Detailed) + if (VerbosityLevel == Verbosity.Detailed) { DisplayFullInformation(e.Result); } // Resume the progress indicator after displaying the test result information - this.progressIndicator?.Start(); + _progressIndicator?.Start(); + } + break; + } + + default: + { + if (VerbosityLevel == Verbosity.Quiet) + { break; } - } + + // Pause the progress indicator before displaying test result information + _progressIndicator?.Pause(); + + Output.Write(string.Format("{0}{1} ", TestResultPrefix, CommandLineResources.SkippedTestIndicator), OutputLevel.Information, ConsoleColor.Yellow); + Output.WriteLine(testDisplayName, OutputLevel.Information); + if (VerbosityLevel == Verbosity.Detailed) + { + DisplayFullInformation(e.Result); + } + + // Resume the progress indicator after displaying the test result information + _progressIndicator?.Start(); + + break; + } } + } - private string GetFormattedDurationString(TimeSpan duration) + private string GetFormattedDurationString(TimeSpan duration) + { + if (duration == default) { - if (duration == default(TimeSpan)) - { - return null; - } + return null; + } + + var time = new List(); + if (duration.Hours > 0) + { + time.Add(duration.Hours + " h"); + } - var time = new List(); - if (duration.Hours > 0) + if (duration.Minutes > 0) + { + time.Add(duration.Minutes + " m"); + } + + if (duration.Hours == 0) + { + if (duration.Seconds > 0) { - time.Add(duration.Hours + " h"); + time.Add(duration.Seconds + " s"); } - if (duration.Minutes > 0) + if (duration.Milliseconds > 0 && duration.Minutes == 0 && duration.Seconds == 0) { - time.Add(duration.Minutes + " m"); + time.Add(duration.Milliseconds + " ms"); } + } - if (duration.Hours == 0) - { - if (duration.Seconds > 0) - { - time.Add(duration.Seconds + " s"); - } + return time.Count == 0 ? "< 1 ms" : string.Join(" ", time); + } - if (duration.Milliseconds > 0 && duration.Minutes == 0 && duration.Seconds == 0) + /// + /// Called when a test run is completed. + /// + private void TestRunCompleteHandler(object sender, TestRunCompleteEventArgs e) + { + // Stop the progress indicator as we are about to print the summary + _progressIndicator?.Stop(); + var passedTests = 0; + var failedTests = 0; + var skippedTests = 0; + var totalTests = 0; + Output.WriteLine(string.Empty, OutputLevel.Information); + + // Printing Run-level Attachments + var runLevelAttachementCount = (e.AttachmentSets == null) ? 0 : e.AttachmentSets.Sum(attachmentSet => attachmentSet.Attachments.Count); + if (runLevelAttachementCount > 0) + { + Output.Information(false, CommandLineResources.AttachmentsBanner); + foreach (var attachmentSet in e.AttachmentSets) + { + foreach (var uriDataAttachment in attachmentSet.Attachments) { - time.Add(duration.Milliseconds + " ms"); + var attachmentOutput = string.Format(CultureInfo.CurrentCulture, CommandLineResources.AttachmentOutputFormat, uriDataAttachment.Uri.LocalPath); + Output.Information(false, attachmentOutput); } } - - return time.Count == 0 ? "< 1 ms" : string.Join(" ", time); } - /// - /// Called when a test run is completed. - /// - private void TestRunCompleteHandler(object sender, TestRunCompleteEventArgs e) + var leafTestResultsPerSource = LeafTestResults.Select(p => p.Value).GroupBy(r => r.TestCase.Source); + foreach (var sd in leafTestResultsPerSource) { - // Stop the progress indicator as we are about to print the summary - this.progressIndicator?.Stop(); - var passedTests = 0; - var failedTests = 0; - var skippedTests = 0; - var totalTests = 0; - Output.WriteLine(string.Empty, OutputLevel.Information); + var source = sd.Key; + var sourceSummary = new SourceSummary(); - // Printing Run-level Attachments - var runLevelAttachementCount = (e.AttachmentSets == null) ? 0 : e.AttachmentSets.Sum(attachmentSet => attachmentSet.Attachments.Count); - if (runLevelAttachementCount > 0) + var results = sd.ToArray(); + // duration of the whole source is the difference between the test that ended last and the one that started first + sourceSummary.Duration = !results.Any() ? TimeSpan.Zero : results.Max(r => r.EndTime) - results.Min(r => r.StartTime); + foreach (var result in results) { - Output.Information(false, CommandLineResources.AttachmentsBanner); - foreach (var attachmentSet in e.AttachmentSets) + switch (result.Outcome) { - foreach (var uriDataAttachment in attachmentSet.Attachments) - { - var attachmentOutput = string.Format(CultureInfo.CurrentCulture, CommandLineResources.AttachmentOutputFormat, uriDataAttachment.Uri.LocalPath); - Output.Information(false, attachmentOutput); - } + case TestOutcome.Passed: + sourceSummary.TotalTests++; + sourceSummary.PassedTests++; + break; + case TestOutcome.Failed: + sourceSummary.TotalTests++; + sourceSummary.FailedTests++; + break; + case TestOutcome.Skipped: + sourceSummary.TotalTests++; + sourceSummary.SkippedTests++; + break; + default: + break; } } - var leafTestResultsPerSource = this.LeafTestResults.Select(p => p.Value).GroupBy(r => r.TestCase.Source); - foreach (var sd in leafTestResultsPerSource) + if (VerbosityLevel == Verbosity.Quiet || VerbosityLevel == Verbosity.Minimal) { - var source = sd.Key; - var sourceSummary = new SourceSummary(); - - var results = sd.ToArray(); - // duration of the whole source is the difference between the test that ended last and the one that started first - sourceSummary.Duration = !results.Any() ? TimeSpan.Zero : results.Max(r => r.EndTime) - results.Min(r => r.StartTime); - foreach (var result in results) + TestOutcome sourceOutcome = TestOutcome.None; + if (sourceSummary.FailedTests > 0) { - switch (result.Outcome) - { - case TestOutcome.Passed: - sourceSummary.TotalTests++; - sourceSummary.PassedTests++; - break; - case TestOutcome.Failed: - sourceSummary.TotalTests++; - sourceSummary.FailedTests++; - break; - case TestOutcome.Skipped: - sourceSummary.TotalTests++; - sourceSummary.SkippedTests++; - break; - default: - break; - } + sourceOutcome = TestOutcome.Failed; } - - if (verbosityLevel == Verbosity.Quiet || verbosityLevel == Verbosity.Minimal) + else if (sourceSummary.PassedTests > 0) { - TestOutcome sourceOutcome = TestOutcome.None; - if (sourceSummary.FailedTests > 0) - { - sourceOutcome = TestOutcome.Failed; - } - else if (sourceSummary.PassedTests > 0) - { - sourceOutcome = TestOutcome.Passed; - } - else if (sourceSummary.SkippedTests > 0) - { - sourceOutcome = TestOutcome.Skipped; - } - - - string resultString; - switch (sourceOutcome) - { - case TestOutcome.Failed: - resultString = (CommandLineResources.FailedTestIndicator + "!").PadRight(LongestResultIndicator); - break; - case TestOutcome.Passed: - resultString = (CommandLineResources.PassedTestIndicator + "!").PadRight(LongestResultIndicator); - break; - case TestOutcome.Skipped: - resultString = (CommandLineResources.SkippedTestIndicator + "!").PadRight(LongestResultIndicator); - break; - default: - resultString = CommandLineResources.None.PadRight(LongestResultIndicator); - break; - } + sourceOutcome = TestOutcome.Passed; + } + else if (sourceSummary.SkippedTests > 0) + { + sourceOutcome = TestOutcome.Skipped; + } - var failed = sourceSummary.FailedTests.ToString().PadLeft(5); - var passed = sourceSummary.PassedTests.ToString().PadLeft(5); - var skipped = sourceSummary.SkippedTests.ToString().PadLeft(5); - var total = sourceSummary.TotalTests.ToString().PadLeft(5); + string resultString; + switch (sourceOutcome) + { + case TestOutcome.Failed: + resultString = (CommandLineResources.FailedTestIndicator + "!").PadRight(LongestResultIndicator); + break; + case TestOutcome.Passed: + resultString = (CommandLineResources.PassedTestIndicator + "!").PadRight(LongestResultIndicator); + break; + case TestOutcome.Skipped: + resultString = (CommandLineResources.SkippedTestIndicator + "!").PadRight(LongestResultIndicator); + break; + default: + resultString = CommandLineResources.None.PadRight(LongestResultIndicator); + break; + } - var frameworkString = string.IsNullOrEmpty(targetFramework) - ? string.Empty - : $"({targetFramework})"; + var failed = sourceSummary.FailedTests.ToString().PadLeft(5); + var passed = sourceSummary.PassedTests.ToString().PadLeft(5); + var skipped = sourceSummary.SkippedTests.ToString().PadLeft(5); + var total = sourceSummary.TotalTests.ToString().PadLeft(5); - var duration = GetFormattedDurationString(sourceSummary.Duration); - var sourceName = sd.Key.Split('\\').Last(); - var outputLine = string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummary, - resultString, - failed, - passed, - skipped, - total, - duration, - sourceName, - frameworkString); + var frameworkString = string.IsNullOrEmpty(_targetFramework) + ? string.Empty + : $"({_targetFramework})"; + var duration = GetFormattedDurationString(sourceSummary.Duration); + var sourceName = sd.Key.Split('\\').Last(); - ConsoleColor? color = null; - if (sourceOutcome == TestOutcome.Failed) - { - color = ConsoleColor.Red; - } - else if (sourceOutcome == TestOutcome.Passed) - { - color = ConsoleColor.Green; - } - else if (sourceOutcome == TestOutcome.Skipped) - { - color = ConsoleColor.Yellow; - } + var outputLine = string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummary, + resultString, + failed, + passed, + skipped, + total, + duration, + sourceName, + frameworkString); - if (color != null) - { - Output.Write(outputLine, OutputLevel.Information, color.Value); - } - else - { - Output.Write(outputLine, OutputLevel.Information); - } - Output.Information(false, CommandLineResources.TestRunSummaryAssemblyAndFramework, - sourceName, - frameworkString); + ConsoleColor? color = null; + if (sourceOutcome == TestOutcome.Failed) + { + color = ConsoleColor.Red; + } + else if (sourceOutcome == TestOutcome.Passed) + { + color = ConsoleColor.Green; + } + else if (sourceOutcome == TestOutcome.Skipped) + { + color = ConsoleColor.Yellow; } - passedTests += sourceSummary.PassedTests; - failedTests += sourceSummary.FailedTests; - skippedTests += sourceSummary.SkippedTests; - totalTests += sourceSummary.TotalTests; - } - - if (verbosityLevel == Verbosity.Quiet || verbosityLevel == Verbosity.Minimal) - { - if (e.IsCanceled) + if (color != null) { - Output.Error(false, CommandLineResources.TestRunCanceled); + Output.Write(outputLine, OutputLevel.Information, color.Value); } - else if (e.IsAborted) + else { - if (e.Error == null) - { - Output.Error(false, CommandLineResources.TestRunAborted); - } - else - { - Output.Error(false, CommandLineResources.TestRunAbortedWithError, e.Error); - } + Output.Write(outputLine, OutputLevel.Information); } - return; + Output.Information(false, CommandLineResources.TestRunSummaryAssemblyAndFramework, + sourceName, + frameworkString); } + passedTests += sourceSummary.PassedTests; + failedTests += sourceSummary.FailedTests; + skippedTests += sourceSummary.SkippedTests; + totalTests += sourceSummary.TotalTests; + } + + if (VerbosityLevel == Verbosity.Quiet || VerbosityLevel == Verbosity.Minimal) + { if (e.IsCanceled) { Output.Error(false, CommandLineResources.TestRunCanceled); @@ -859,77 +839,95 @@ private void TestRunCompleteHandler(object sender, TestRunCompleteEventArgs e) Output.Error(false, CommandLineResources.TestRunAbortedWithError, e.Error); } } - else if (failedTests > 0 || this.testRunHasErrorMessages) + + return; + } + + if (e.IsCanceled) + { + Output.Error(false, CommandLineResources.TestRunCanceled); + } + else if (e.IsAborted) + { + if (e.Error == null) { - Output.Error(false, CommandLineResources.TestRunFailed); + Output.Error(false, CommandLineResources.TestRunAborted); } - else if (totalTests > 0) + else { - Output.Information(false, ConsoleColor.Green, CommandLineResources.TestRunSuccessful); + Output.Error(false, CommandLineResources.TestRunAbortedWithError, e.Error); } + } + else if (failedTests > 0 || _testRunHasErrorMessages) + { + Output.Error(false, CommandLineResources.TestRunFailed); + } + else if (totalTests > 0) + { + Output.Information(false, ConsoleColor.Green, CommandLineResources.TestRunSuccessful); + } - // Output a summary. - if (totalTests > 0) - { - string totalTestsformat = (e.IsAborted || e.IsCanceled) ? CommandLineResources.TestRunSummaryForCanceledOrAbortedRun : CommandLineResources.TestRunSummaryTotalTests; - Output.Information(false, string.Format(CultureInfo.CurrentCulture, totalTestsformat, totalTests)); + // Output a summary. + if (totalTests > 0) + { + string totalTestsformat = (e.IsAborted || e.IsCanceled) ? CommandLineResources.TestRunSummaryForCanceledOrAbortedRun : CommandLineResources.TestRunSummaryTotalTests; + Output.Information(false, string.Format(CultureInfo.CurrentCulture, totalTestsformat, totalTests)); - if (passedTests > 0) - { - Output.Information(false, ConsoleColor.Green, string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryPassedTests, passedTests)); - } - if (failedTests > 0) - { - Output.Information(false, ConsoleColor.Red, string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryFailedTests, failedTests)); - } - if (skippedTests > 0) - { - Output.Information(false, ConsoleColor.Yellow, string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummarySkippedTests, skippedTests)); - } + if (passedTests > 0) + { + Output.Information(false, ConsoleColor.Green, string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryPassedTests, passedTests)); } - - if (totalTests > 0) + if (failedTests > 0) { - if (e.ElapsedTimeInRunningTests.Equals(TimeSpan.Zero)) - { - EqtTrace.Info("Skipped printing test execution time on console because it looks like the test run had faced some errors"); - } - else - { - PrintTimeSpan(e.ElapsedTimeInRunningTests); - } + Output.Information(false, ConsoleColor.Red, string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryFailedTests, failedTests)); + } + if (skippedTests > 0) + { + Output.Information(false, ConsoleColor.Yellow, string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummarySkippedTests, skippedTests)); } } - #endregion - /// - /// Raises test run warning occurred before console logger starts listening warning events. - /// - /// - public static void RaiseTestRunWarning(string warningMessage) + if (totalTests > 0) { - if (ConsoleLogger.Output == null) + if (e.ElapsedTimeInRunningTests.Equals(TimeSpan.Zero)) { - ConsoleLogger.Output = ConsoleOutput.Instance; + EqtTrace.Info("Skipped printing test execution time on console because it looks like the test run had faced some errors"); + } + else + { + PrintTimeSpan(e.ElapsedTimeInRunningTests); } - - Output.Warning(AppendPrefix, warningMessage); } + } + #endregion - private class MinimalTestResult + /// + /// Raises test run warning occurred before console logger starts listening warning events. + /// + /// + public static void RaiseTestRunWarning(string warningMessage) + { + if (Output == null) { - public MinimalTestResult(TestResult testResult) - { - TestCase = testResult.TestCase; - Outcome = testResult.Outcome; - StartTime = testResult.StartTime; - EndTime = testResult.EndTime; - } + Output = ConsoleOutput.Instance; + } + + Output.Warning(AppendPrefix, warningMessage); + } - public TestCase TestCase { get; } - public TestOutcome Outcome { get; } - public DateTimeOffset StartTime { get; } - public DateTimeOffset EndTime { get; } + private class MinimalTestResult + { + public MinimalTestResult(TestResult testResult) + { + TestCase = testResult.TestCase; + Outcome = testResult.Outcome; + StartTime = testResult.StartTime; + EndTime = testResult.EndTime; } + + public TestCase TestCase { get; } + public TestOutcome Outcome { get; } + public DateTimeOffset StartTime { get; } + public DateTimeOffset EndTime { get; } } -} +} \ No newline at end of file diff --git a/src/vstest.console/Internal/FilePatternParser.cs b/src/vstest.console/Internal/FilePatternParser.cs index 7c1fdb2eb5..f16374294a 100644 --- a/src/vstest.console/Internal/FilePatternParser.cs +++ b/src/vstest.console/Internal/FilePatternParser.cs @@ -1,105 +1,107 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace vstest.console.Internal +#pragma warning disable IDE1006 // Naming Styles +namespace vstest.console.Internal; +#pragma warning restore IDE1006 // Naming Styles + +using Microsoft.Extensions.FileSystemGlobbing; +using Microsoft.Extensions.FileSystemGlobbing.Abstractions; +using Microsoft.VisualStudio.TestPlatform.CommandLine; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; + +using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; + +/// +/// Class for getting matching files from wild card pattern file name +/// Microsoft.Extensions.FileSystemGlobbing methods used to get matching file names +/// +public class FilePatternParser { - using Microsoft.Extensions.FileSystemGlobbing; - using Microsoft.Extensions.FileSystemGlobbing.Abstractions; - using Microsoft.VisualStudio.TestPlatform.CommandLine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using System; - using System.Collections.Generic; - using System.Globalization; - using System.IO; - - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; + private readonly Matcher _matcher; + private readonly IFileHelper _fileHelper; + private readonly char[] _wildCardCharacters = { '*' }; + + public FilePatternParser() + : this(new Matcher(), new FileHelper()) + { + } + + internal FilePatternParser(Matcher matcher, IFileHelper fileHelper) + { + _matcher = matcher; + _fileHelper = fileHelper; + } /// - /// Class for getting matching files from wild card pattern file name - /// Microsoft.Extensions.FileSystemGlobbing methods used to get matching file names + /// Used to get matching files with pattern /// - public class FilePatternParser + /// Returns the list of matching files + public List GetMatchingFiles(string filePattern) { - private Matcher matcher; - private IFileHelper fileHelper; - private char[] wildCardCharacters = { '*' }; - - public FilePatternParser() - : this(new Matcher(), new FileHelper()) - { - } + var matchingFiles = new List(); - internal FilePatternParser(Matcher matcher, IFileHelper fileHelper) + // Convert the relative path to absolute path + if (!Path.IsPathRooted(filePattern)) { - this.matcher = matcher; - this.fileHelper = fileHelper; + filePattern = Path.Combine(_fileHelper.GetCurrentDirectory(), filePattern); } - /// - /// Used to get matching files with pattern - /// - /// Returns the list of matching files - public List GetMatchingFiles(string filePattern) + // If there is no wild card simply add the file to the list of matching files. + if (filePattern.IndexOfAny(_wildCardCharacters) == -1) { - var matchingFiles = new List(); + EqtTrace.Info($"FilePatternParser: The given file {filePattern} is a full path."); - // Convert the relative path to absolute path - if (!Path.IsPathRooted(filePattern)) + // Check if the file exists. + if (!_fileHelper.Exists(filePattern)) { - filePattern = Path.Combine(this.fileHelper.GetCurrentDirectory(), filePattern); + throw new TestSourceException( + string.Format(CultureInfo.CurrentUICulture, CommandLineResources.TestSourceFileNotFound, filePattern)); } - // If there is no wild card simply add the file to the list of matching files. - if (filePattern.IndexOfAny(wildCardCharacters) == -1) - { - EqtTrace.Info($"FilePatternParser: The given file {filePattern} is a full path."); - - // Check if the file exists. - if (!this.fileHelper.Exists(filePattern)) - { - throw new TestSourceException( - string.Format(CultureInfo.CurrentUICulture, CommandLineResources.TestSourceFileNotFound, filePattern)); - } - - matchingFiles.Add(filePattern); - - return matchingFiles; - } + matchingFiles.Add(filePattern); - // Split the given wild card into search directory and pattern to be searched. - var splitPattern = SplitFilePatternOnWildCard(filePattern); - EqtTrace.Info($"FilePatternParser: Matching file pattern '{splitPattern.Item2}' within directory '{splitPattern.Item1}'"); + return matchingFiles; + } - this.matcher.AddInclude(splitPattern.Item2); + // Split the given wild card into search directory and pattern to be searched. + var splitPattern = SplitFilePatternOnWildCard(filePattern); + EqtTrace.Info($"FilePatternParser: Matching file pattern '{splitPattern.Item2}' within directory '{splitPattern.Item1}'"); - // Execute the given pattern in the search directory. - var matches = this.matcher.Execute(new DirectoryInfoWrapper(new DirectoryInfo(splitPattern.Item1))); + _matcher.AddInclude(splitPattern.Item2); - // Add all the files to the list of matching files. - foreach (var match in matches.Files) - { - matchingFiles.Add(Path.Combine(splitPattern.Item1, match.Path)); - } + // Execute the given pattern in the search directory. + var matches = _matcher.Execute(new DirectoryInfoWrapper(new DirectoryInfo(splitPattern.Item1))); - return matchingFiles; + // Add all the files to the list of matching files. + foreach (var match in matches.Files) + { + matchingFiles.Add(Path.Combine(splitPattern.Item1, match.Path)); } - /// - /// Splits full pattern into search directory and pattern. - /// - private Tuple SplitFilePatternOnWildCard(string filePattern) - { - // Split the pattern based on first wild card character found. - var splitOnWildCardIndex = filePattern.IndexOfAny(wildCardCharacters); - var directorySeparatorIndex = filePattern.Substring(0, splitOnWildCardIndex).LastIndexOf(Path.DirectorySeparatorChar); + return matchingFiles; + } + + /// + /// Splits full pattern into search directory and pattern. + /// + private Tuple SplitFilePatternOnWildCard(string filePattern) + { + // Split the pattern based on first wild card character found. + var splitOnWildCardIndex = filePattern.IndexOfAny(_wildCardCharacters); + var directorySeparatorIndex = filePattern.Substring(0, splitOnWildCardIndex).LastIndexOf(Path.DirectorySeparatorChar); - string searchDir = filePattern.Substring(0, directorySeparatorIndex); - string pattern = filePattern.Substring(directorySeparatorIndex + 1); + string searchDir = filePattern.Substring(0, directorySeparatorIndex); + string pattern = filePattern.Substring(directorySeparatorIndex + 1); - Tuple splitPattern = new Tuple(searchDir, pattern); - return splitPattern; - } + Tuple splitPattern = new(searchDir, pattern); + return splitPattern; } -} +} \ No newline at end of file diff --git a/src/vstest.console/Internal/Interfaces/IConsoleHelper.cs b/src/vstest.console/Internal/Interfaces/IConsoleHelper.cs index fbed8bb99d..99175935b6 100644 --- a/src/vstest.console/Internal/Interfaces/IConsoleHelper.cs +++ b/src/vstest.console/Internal/Interfaces/IConsoleHelper.cs @@ -1,33 +1,32 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; + +/// +/// Interface for wrapping the Console class +/// +internal interface IConsoleHelper { /// - /// Interface for wrapping the Console class + /// Returns the left position of the cursor /// - internal interface IConsoleHelper - { - /// - /// Returns the left position of the cursor - /// - int CursorLeft { get; } + int CursorLeft { get; } - /// - /// Returns the right position of the cursor - /// - int CursorTop { get; } + /// + /// Returns the right position of the cursor + /// + int CursorTop { get; } - /// - /// Returns the width of the console window - /// - int WindowWidth { get; } + /// + /// Returns the width of the console window + /// + int WindowWidth { get; } - /// - /// Sets the cursor position based on the left and top values - /// - /// - /// - void SetCursorPosition(int left, int top); - } -} + /// + /// Sets the cursor position based on the left and top values + /// + /// + /// + void SetCursorPosition(int left, int top); +} \ No newline at end of file diff --git a/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs b/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs index 79110adbd1..04f1c1767c 100644 --- a/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs +++ b/src/vstest.console/Internal/Interfaces/IProgressIndicator.cs @@ -1,23 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; + +internal interface IProgressIndicator { - internal interface IProgressIndicator - { - /// - /// Marks the start of the progress indicator - /// - void Start(); + /// + /// Marks the start of the progress indicator + /// + void Start(); - /// - /// Pause the progress indicator - /// - void Pause(); + /// + /// Pause the progress indicator + /// + void Pause(); - /// - /// Stop the progress indicator - /// - void Stop(); - } -} + /// + /// Stop the progress indicator + /// + void Stop(); +} \ No newline at end of file diff --git a/src/vstest.console/Internal/Product.cs b/src/vstest.console/Internal/Product.cs index 93bdcdfe21..61c3f0d297 100644 --- a/src/vstest.console/Internal/Product.cs +++ b/src/vstest.console/Internal/Product.cs @@ -1,21 +1,20 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; + +using System.Reflection; + +public class Product { - using System.Reflection; + public static readonly string Version = GetProductVersion(); - public class Product + private static string GetProductVersion() { - public static readonly string Version = GetProductVersion(); - - private static string GetProductVersion() - { - var attr = typeof(Product) - .GetTypeInfo() - .Assembly - .GetCustomAttribute(); - return attr?.InformationalVersion; - } + var attr = typeof(Product) + .GetTypeInfo() + .Assembly + .GetCustomAttribute(); + return attr?.InformationalVersion; } -} +} \ No newline at end of file diff --git a/src/vstest.console/Internal/ProgressIndicator.cs b/src/vstest.console/Internal/ProgressIndicator.cs index 429fab10fe..9f0f045eb9 100644 --- a/src/vstest.console/Internal/ProgressIndicator.cs +++ b/src/vstest.console/Internal/ProgressIndicator.cs @@ -1,117 +1,118 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; + +using System.Globalization; + +using Utilities; + +using Timer = System.Timers.Timer; + +/// +/// Indicates the test run progress +/// +internal class ProgressIndicator : IProgressIndicator { - using System.Globalization; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Timer = System.Timers.Timer; + private readonly object _syncObject = new(); + private int _dotCounter; + private Timer _timer; + private readonly string _testRunProgressString; + + /// + /// Used to output to the console + /// + public IOutput ConsoleOutput { get; private set; } + + /// + /// Wrapper over the System Console class + /// + public IConsoleHelper ConsoleHelper { get; private set; } /// - /// Indicates the test run progress + /// True is the indicator is to be displayed /// - internal class ProgressIndicator : IProgressIndicator + public bool IsRunning { get; private set; } + + public ProgressIndicator(IOutput output, IConsoleHelper consoleHelper) { - private object syncObject = new object(); - private int dotCounter; - private Timer timer; - private string testRunProgressString; - - /// - /// Used to output to the console - /// - public IOutput ConsoleOutput { get; private set; } - - /// - /// Wrapper over the System Console class - /// - public IConsoleHelper ConsoleHelper { get; private set; } - - /// - /// True is the indicator is to be displayed - /// - public bool IsRunning { get; private set; } - - public ProgressIndicator(IOutput output, IConsoleHelper consoleHelper) - { - this.ConsoleOutput = output; - this.ConsoleHelper = consoleHelper; - this.testRunProgressString = string.Format(CultureInfo.CurrentCulture, "{0}...", Resources.Resources.ProgressIndicatorString); - } + ConsoleOutput = output; + ConsoleHelper = consoleHelper; + _testRunProgressString = string.Format(CultureInfo.CurrentCulture, "{0}...", Resources.Resources.ProgressIndicatorString); + } - /// - public void Start() + /// + public void Start() + { + lock (_syncObject) { - lock (syncObject) + if (_timer == null) { - if (timer == null) - { - this.timer = new Timer(1000); - this.timer.Elapsed += Timer_Elapsed; - this.timer.Start(); - } - - // Print the string based on the previous state, that is dotCounter - // This is required for smooth transition - this.ConsoleOutput.Write(testRunProgressString.Substring(0, testRunProgressString.Length + dotCounter - 2), OutputLevel.Information); - this.IsRunning = true; + _timer = new Timer(1000); + _timer.Elapsed += Timer_Elapsed; + _timer.Start(); } - } - /// - // Get the current cursor position - // Clear the console starting given position - // Reset the cursor position back - /// - /// the starting position - private void Clear(int startPos) - { - var currentLineCursor = this.ConsoleHelper.CursorTop; - this.ConsoleHelper.SetCursorPosition(startPos, this.ConsoleHelper.CursorTop); - this.ConsoleOutput.Write(new string(' ', this.ConsoleHelper.WindowWidth - startPos), OutputLevel.Information); - this.ConsoleHelper.SetCursorPosition(startPos, currentLineCursor); + // Print the string based on the previous state, that is dotCounter + // This is required for smooth transition + ConsoleOutput.Write(_testRunProgressString.Substring(0, _testRunProgressString.Length + _dotCounter - 2), OutputLevel.Information); + IsRunning = true; } + } - /// - /// Sets the isRunning flag to false so that indicator is not shown. - /// - public void Pause() + /// + // Get the current cursor position + // Clear the console starting given position + // Reset the cursor position back + /// + /// the starting position + private void Clear(int startPos) + { + var currentLineCursor = ConsoleHelper.CursorTop; + ConsoleHelper.SetCursorPosition(startPos, ConsoleHelper.CursorTop); + ConsoleOutput.Write(new string(' ', ConsoleHelper.WindowWidth - startPos), OutputLevel.Information); + ConsoleHelper.SetCursorPosition(startPos, currentLineCursor); + } + + /// + /// Sets the isRunning flag to false so that indicator is not shown. + /// + public void Pause() + { + lock (_syncObject) { - lock (syncObject) - { - this.IsRunning = false; - this.Clear(0); - } + IsRunning = false; + Clear(0); } + } - /// - /// Stops the indicator and clears the current line. - /// - public void Stop() + /// + /// Stops the indicator and clears the current line. + /// + public void Stop() + { + lock (_syncObject) { - lock (syncObject) - { - this.IsRunning = false; - this.timer?.Stop(); - this.Clear(0); - } + IsRunning = false; + _timer?.Stop(); + Clear(0); } + } - private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) + private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) + { + if (IsRunning) { - if (IsRunning) + // If running, prints dot every second. + ConsoleOutput.Write(".", OutputLevel.Information); + _dotCounter = ++_dotCounter % 3; + + // When counter reaches 3, that is 3 dots have been printed + // Clear and start printing again + if (_dotCounter == 0) { - // If running, prints dot every second. - this.ConsoleOutput.Write(".", OutputLevel.Information); - dotCounter = ++dotCounter % 3; - - // When counter reaches 3, that is 3 dots have been printed - // Clear and start printing again - if (dotCounter == 0) - { - this.Clear(this.ConsoleHelper.CursorLeft - 3); - } + Clear(ConsoleHelper.CursorLeft - 3); } } } -} +} \ No newline at end of file diff --git a/src/vstest.console/Internal/SourceSummary.cs b/src/vstest.console/Internal/SourceSummary.cs index d0f228b6de..532eaefe07 100644 --- a/src/vstest.console/Internal/SourceSummary.cs +++ b/src/vstest.console/Internal/SourceSummary.cs @@ -1,38 +1,37 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; + +using System; +/// +/// Summary of test results per source. +/// +internal class SourceSummary +{ /// - /// Summary of test results per source. + /// Total tests of a test run. /// - internal class SourceSummary - { - /// - /// Total tests of a test run. - /// - public int TotalTests { get; set; } + public int TotalTests { get; set; } - /// - /// Passed tests of a test run. - /// - public int PassedTests { get; set; } + /// + /// Passed tests of a test run. + /// + public int PassedTests { get; set; } - /// - /// Failed tests of a test run. - /// - public int FailedTests { get; set; } + /// + /// Failed tests of a test run. + /// + public int FailedTests { get; set; } - /// - /// Skipped tests of a test run. - /// - public int SkippedTests { get; set; } + /// + /// Skipped tests of a test run. + /// + public int SkippedTests { get; set; } - /// - /// Duration of the test run. - /// - public TimeSpan Duration { get; set; } - } -} + /// + /// Duration of the test run. + /// + public TimeSpan Duration { get; set; } +} \ No newline at end of file diff --git a/src/vstest.console/Processors/CLIRunSettingsArgumentProcessor.cs b/src/vstest.console/Processors/CLIRunSettingsArgumentProcessor.cs index 88575c2254..4321eb36d2 100644 --- a/src/vstest.console/Processors/CLIRunSettingsArgumentProcessor.cs +++ b/src/vstest.console/Processors/CLIRunSettingsArgumentProcessor.cs @@ -1,265 +1,264 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors -{ - using System; - using System.Diagnostics.Contracts; - using System.Xml.XPath; - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Diagnostics.Contracts; +using System.Xml.XPath; +using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Common; +using Common.Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using CommandLineResources = Resources.Resources; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; + +/// +/// The argument processor for runsettings passed as argument through cli +/// +internal class CliRunSettingsArgumentProcessor : IArgumentProcessor +{ + #region Constants /// - /// The argument processor for runsettings passed as argument through cli + /// The name of the command line argument that the PortArgumentExecutor handles. /// - internal class CLIRunSettingsArgumentProcessor : IArgumentProcessor - { - #region Constants - - /// - /// The name of the command line argument that the PortArgumentExecutor handles. - /// - public const string CommandName = "--"; + public const string CommandName = "--"; - #endregion + #endregion - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - /// - /// Gets the metadata. - /// - public Lazy Metadata + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new CLIRunSettingsArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new CliRunSettingsArgumentProcessorCapabilities()); } + + return _metadata; } + } - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => new CLIRunSettingsArgumentExecutor(RunSettingsManager.Instance, CommandLineOptions.Instance)); - } - - return this.executor; + _executor = new Lazy(() => new CliRunSettingsArgumentExecutor(RunSettingsManager.Instance, CommandLineOptions.Instance)); } - set - { - this.executor = value; - } + return _executor; + } + + set + { + _executor = value; } } +} - internal class CLIRunSettingsArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => CLIRunSettingsArgumentProcessor.CommandName; +internal class CliRunSettingsArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => CliRunSettingsArgumentProcessor.CommandName; + + public override bool AllowMultiple => false; - public override bool AllowMultiple => false; + public override bool IsAction => false; - public override bool IsAction => false; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.CliRunSettings; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.CLIRunSettings; + public override string HelpContentResourceName => CommandLineResources.CLIRunSettingsArgumentHelp; - public override string HelpContentResourceName => CommandLineResources.CLIRunSettingsArgumentHelp; + public override HelpContentPriority HelpPriority => HelpContentPriority.CliRunSettingsArgumentProcessorHelpPriority; +} - public override HelpContentPriority HelpPriority => HelpContentPriority.CLIRunSettingsArgumentProcessorHelpPriority; +internal class CliRunSettingsArgumentExecutor : IArgumentsExecutor +{ + private readonly IRunSettingsProvider _runSettingsManager; + private readonly CommandLineOptions _commandLineOptions; + + internal CliRunSettingsArgumentExecutor(IRunSettingsProvider runSettingsManager, CommandLineOptions commandLineOptions) + { + _runSettingsManager = runSettingsManager; + _commandLineOptions = commandLineOptions; } - internal class CLIRunSettingsArgumentExecutor : IArgumentsExecutor + public void Initialize(string argument) { - private IRunSettingsProvider runSettingsManager; - private CommandLineOptions commandLineOptions; + throw new NotImplementedException(); + } - internal CLIRunSettingsArgumentExecutor(IRunSettingsProvider runSettingsManager, CommandLineOptions commandLineOptions) + public void Initialize(string[] arguments) + { + // if argument is null or doesn't contain any element, don't do anything. + if (arguments == null || arguments.Length == 0) { - this.runSettingsManager = runSettingsManager; - this.commandLineOptions = commandLineOptions; + return; } - public void Initialize(string argument) + Contract.EndContractBlock(); + + // Load up the run settings and set it as the active run settings. + try { - throw new NotImplementedException(); + // Append / Override run settings supplied in CLI + CreateOrOverwriteRunSettings(_runSettingsManager, arguments); } - - public void Initialize(string[] arguments) + catch (XPathException exception) { - // if argument is null or doesn't contain any element, don't do anything. - if (arguments == null || arguments.Length == 0) - { - return; - } - - Contract.EndContractBlock(); - - // Load up the run settings and set it as the active run settings. - try - { - // Append / Override run settings supplied in CLI - CreateOrOverwriteRunSettings(this.runSettingsManager, arguments); - } - catch (XPathException exception) - { - throw new CommandLineException(CommandLineResources.MalformedRunSettingsKey, exception); - } - catch (SettingsException exception) - { - throw new CommandLineException(exception.Message, exception); - } + throw new CommandLineException(CommandLineResources.MalformedRunSettingsKey, exception); } - - public ArgumentProcessorResult Execute() + catch (SettingsException exception) { - // Nothing to do here, the work was done in initialization. - return ArgumentProcessorResult.Success; + throw new CommandLineException(exception.Message, exception); } + } - private void CreateOrOverwriteRunSettings(IRunSettingsProvider runSettingsProvider, string[] args) - { - var mergedArgs = new List(); - var mergedArg = string.Empty; - var merge = false; + public ArgumentProcessorResult Execute() + { + // Nothing to do here, the work was done in initialization. + return ArgumentProcessorResult.Success; + } - foreach (var arg in args) - { - // when we see that the parameter begins with TestRunParameters - // but does not end with ") we start merging the params - if (arg.StartsWith("TestRunParameters", StringComparison.OrdinalIgnoreCase)) - { - if (arg.EndsWith("\")")) - { - // this parameter is complete - mergedArgs.Add(arg); - } - else - { - // this parameter needs merging - merge = true; - } - } + private void CreateOrOverwriteRunSettings(IRunSettingsProvider runSettingsProvider, string[] args) + { + var mergedArgs = new List(); + var mergedArg = string.Empty; + var merge = false; - // we merge as long as the flag is set - // hoping that we find the end of the parameter - if (merge) - { - mergedArg += string.IsNullOrWhiteSpace(mergedArg) ? arg : $" {arg}"; - } - else + foreach (var arg in args) + { + // when we see that the parameter begins with TestRunParameters + // but does not end with ") we start merging the params + if (arg.StartsWith("TestRunParameters", StringComparison.OrdinalIgnoreCase)) + { + if (arg.EndsWith("\")")) { - // if we are not merging just pass the param as is + // this parameter is complete mergedArgs.Add(arg); } - - // once we detect the end we add the whole parameter to the args - if (merge && arg.EndsWith("\")")) + else { - mergedArgs.Add(mergedArg); - mergedArg = string.Empty; - merge = false; + // this parameter needs merging + merge = true; } } + // we merge as long as the flag is set + // hoping that we find the end of the parameter if (merge) { - // we tried to merge but never found the end of that - // test paramter, add what we merged up until now - mergedArgs.Add(mergedArg); + mergedArg += string.IsNullOrWhiteSpace(mergedArg) ? arg : $" {arg}"; } - - - var length = mergedArgs.Count; - - for (int index = 0; index < length; index++) + else { - var arg = mergedArgs[index]; + // if we are not merging just pass the param as is + mergedArgs.Add(arg); + } - if (UpdateTestRunParameterNode(runSettingsProvider, arg)) - { - continue; - } + // once we detect the end we add the whole parameter to the args + if (merge && arg.EndsWith("\")")) + { + mergedArgs.Add(mergedArg); + mergedArg = string.Empty; + merge = false; + } + } - var indexOfSeparator = arg.IndexOf("="); + if (merge) + { + // we tried to merge but never found the end of that + // test paramter, add what we merged up until now + mergedArgs.Add(mergedArg); + } - if (indexOfSeparator <= 0 || indexOfSeparator >= arg.Length - 1) - { - continue; - } - var key = arg.Substring(0, indexOfSeparator).Trim(); - var value = arg.Substring(indexOfSeparator + 1); + var length = mergedArgs.Count; - if (string.IsNullOrWhiteSpace(key)) - { - continue; - } - - // To determine whether to infer framework and platform. - UpdateFrameworkAndPlatform(key, value); + for (int index = 0; index < length; index++) + { + var arg = mergedArgs[index]; - runSettingsProvider.UpdateRunSettingsNode(key, value); + if (UpdateTestRunParameterNode(runSettingsProvider, arg)) + { + continue; } - } - private bool UpdateTestRunParameterNode(IRunSettingsProvider runSettingsProvider, string node) - { - if (!node.Contains(Constants.TestRunParametersName)) + var indexOfSeparator = arg.IndexOf("="); + + if (indexOfSeparator <= 0 || indexOfSeparator >= arg.Length - 1) { - return false; + continue; } - var match = runSettingsProvider.GetTestRunParameterNodeMatch(node); + var key = arg.Substring(0, indexOfSeparator).Trim(); + var value = arg.Substring(indexOfSeparator + 1); - if (string.Compare(match.Value, node) == 0) + if (string.IsNullOrWhiteSpace(key)) { - runSettingsProvider.UpdateTestRunParameterSettingsNode(match); - return true; + continue; } - var exceptionMessage = string.Format(CommandLineResources.InvalidTestRunParameterArgument, node); - throw new CommandLineException(exceptionMessage); + // To determine whether to infer framework and platform. + UpdateFrameworkAndPlatform(key, value); + + runSettingsProvider.UpdateRunSettingsNode(key, value); + } + } + + private bool UpdateTestRunParameterNode(IRunSettingsProvider runSettingsProvider, string node) + { + if (!node.Contains(Constants.TestRunParametersName)) + { + return false; + } + + var match = runSettingsProvider.GetTestRunParameterNodeMatch(node); + + if (string.Compare(match.Value, node) == 0) + { + runSettingsProvider.UpdateTestRunParameterSettingsNode(match); + return true; } - private void UpdateFrameworkAndPlatform(string key, string value) + var exceptionMessage = string.Format(CommandLineResources.InvalidTestRunParameterArgument, node); + throw new CommandLineException(exceptionMessage); + } + + private void UpdateFrameworkAndPlatform(string key, string value) + { + if (key.Equals(FrameworkArgumentExecutor.RunSettingsPath)) { - if (key.Equals(FrameworkArgumentExecutor.RunSettingsPath)) + Framework framework = Framework.FromString(value); + if (framework != null) { - Framework framework = Framework.FromString(value); - if (framework != null) - { - this.commandLineOptions.TargetFrameworkVersion = framework; - } + _commandLineOptions.TargetFrameworkVersion = framework; } + } - if (key.Equals(PlatformArgumentExecutor.RunSettingsPath)) + if (key.Equals(PlatformArgumentExecutor.RunSettingsPath)) + { + bool success = Enum.TryParse(value, true, out var architecture); + if (success) { - bool success = Enum.TryParse(value, true, out var architecture); - if (success) - { - RunSettingsHelper.Instance.IsDefaultTargetArchitecture = false; - this.commandLineOptions.TargetArchitecture = architecture; - } + RunSettingsHelper.Instance.IsDefaultTargetArchitecture = false; + _commandLineOptions.TargetArchitecture = architecture; } } } -} +} \ No newline at end of file diff --git a/src/vstest.console/Processors/CollectArgumentProcessor.cs b/src/vstest.console/Processors/CollectArgumentProcessor.cs index 99f6dfebce..d1a7f8a241 100644 --- a/src/vstest.console/Processors/CollectArgumentProcessor.cs +++ b/src/vstest.console/Processors/CollectArgumentProcessor.cs @@ -1,331 +1,330 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Xml; + +using Utilities; +using Common; +using Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +using CommandLineResources = Resources.Resources; + +/// +/// The argument processor for enabling data collectors. +/// +internal class CollectArgumentProcessor : IArgumentProcessor { - using System; - using System.Collections.Generic; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Xml; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; + #region Constants /// - /// The argument processor for enabling data collectors. + /// The name of command for enabling code coverage. /// - internal class CollectArgumentProcessor : IArgumentProcessor - { - #region Constants - - /// - /// The name of command for enabling code coverage. - /// - public const string CommandName = "/Collect"; + public const string CommandName = "/Collect"; - #endregion + #endregion - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - /// - /// Gets the metadata. - /// - public Lazy Metadata + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new CollectArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new CollectArgumentProcessorCapabilities()); } + + return _metadata; } + } - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => new CollectArgumentExecutor(RunSettingsManager.Instance, new FileHelper())); - } - - return this.executor; + _executor = new Lazy(() => new CollectArgumentExecutor(RunSettingsManager.Instance, new FileHelper())); } - set - { - this.executor = value; - } + return _executor; + } + + set + { + _executor = value; } } +} - internal class CollectArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => CollectArgumentProcessor.CommandName; +internal class CollectArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => CollectArgumentProcessor.CommandName; + + public override bool AllowMultiple => true; - public override bool AllowMultiple => true; + public override bool IsAction => false; - public override bool IsAction => false; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; + public override string HelpContentResourceName => CommandLineResources.CollectArgumentHelp; - public override string HelpContentResourceName => CommandLineResources.CollectArgumentHelp; + public override HelpContentPriority HelpPriority => HelpContentPriority.CollectArgumentProcessorHelpPriority; +} - public override HelpContentPriority HelpPriority => HelpContentPriority.CollectArgumentProcessorHelpPriority; +/// +internal class CollectArgumentExecutor : IArgumentExecutor +{ + private readonly IRunSettingsProvider _runSettingsManager; + private readonly IFileHelper _fileHelper; + internal static List EnabledDataCollectors = new(); + internal CollectArgumentExecutor(IRunSettingsProvider runSettingsManager, IFileHelper fileHelper) + { + _runSettingsManager = runSettingsManager; + _fileHelper = fileHelper; } /// - internal class CollectArgumentExecutor : IArgumentExecutor + public void Initialize(string argument) { - private readonly IRunSettingsProvider runSettingsManager; - private readonly IFileHelper fileHelper; - internal static List EnabledDataCollectors = new List(); - internal CollectArgumentExecutor(IRunSettingsProvider runSettingsManager, IFileHelper fileHelper) + // 1. Disable all other data collectors. Enable only those data collectors that are explicitly specified by user. + // 2. Check if Code Coverage Data Collector is specified in runsettings, if not add it and also set enable to true. + + string exceptionMessage = string.Format(CultureInfo.CurrentUICulture, CommandLineResources.DataCollectorFriendlyNameInvalid, argument); + + // if argument is null or doesn't contain any element, don't do anything. + if (string.IsNullOrWhiteSpace(argument)) { - this.runSettingsManager = runSettingsManager; - this.fileHelper = fileHelper; + throw new CommandLineException(exceptionMessage); } - /// - public void Initialize(string argument) + // Get collect argument list. + var collectArgumentList = ArgumentProcessorUtilities.GetArgumentList(argument, ArgumentProcessorUtilities.SemiColonArgumentSeparator, exceptionMessage); + + // First argument is collector name. Remaining are key value pairs for configurations. + if (collectArgumentList[0].Contains("=")) { - // 1. Disable all other data collectors. Enable only those data collectors that are explicitly specified by user. - // 2. Check if Code Coverage Data Collector is specified in runsettings, if not add it and also set enable to true. + throw new CommandLineException(exceptionMessage); + } - string exceptionMessage = string.Format(CultureInfo.CurrentUICulture, CommandLineResources.DataCollectorFriendlyNameInvalid, argument); + if (InferRunSettingsHelper.IsTestSettingsEnabled(_runSettingsManager.ActiveRunSettings.SettingsXml)) + { + throw new SettingsException(string.Format(CommandLineResources.CollectWithTestSettingErrorMessage, argument)); + } + AddDataCollectorToRunSettings(collectArgumentList, _runSettingsManager, _fileHelper, exceptionMessage); + } - // if argument is null or doesn't contain any element, don't do anything. - if (string.IsNullOrWhiteSpace(argument)) + /// + /// Returns coverlet code base searching coverlet.collector.dll assembly inside adaptersPaths + /// + private static string GetCoverletCodeBasePath(IRunSettingsProvider runSettingProvider, IFileHelper fileHelper) + { + foreach (string adapterPath in RunSettingsUtilities.GetTestAdaptersPaths(runSettingProvider.ActiveRunSettings.SettingsXml)) + { + string collectorPath = Path.Combine(adapterPath, CoverletConstants.CoverletDataCollectorCodebase); + if (fileHelper.Exists(collectorPath)) { - throw new CommandLineException(exceptionMessage); + EqtTrace.Verbose("CoverletDataCollector in-process codeBase path '{0}'", collectorPath); + return collectorPath; } + } - // Get collect argument list. - var collectArgumentList = ArgumentProcessorUtilities.GetArgumentList(argument, ArgumentProcessorUtilities.SemiColonArgumentSeparator, exceptionMessage); + return null; + } - // First argument is collector name. Remaining are key value pairs for configurations. - if (collectArgumentList[0].Contains("=")) - { - throw new CommandLineException(exceptionMessage); - } + /// + public ArgumentProcessorResult Execute() + { + return ArgumentProcessorResult.Success; + } - if (InferRunSettingsHelper.IsTestSettingsEnabled(this.runSettingsManager.ActiveRunSettings.SettingsXml)) - { - throw new SettingsException(string.Format(CommandLineResources.CollectWithTestSettingErrorMessage, argument)); - } - AddDataCollectorToRunSettings(collectArgumentList, this.runSettingsManager, this.fileHelper, exceptionMessage); - } + internal static DataCollectorSettings EnableDataCollectorUsingFriendlyName(string argument, DataCollectionRunSettings dataCollectionRunSettings) + { - /// - /// Returns coverlet code base searching coverlet.collector.dll assembly inside adaptersPaths - /// - private static string GetCoverletCodeBasePath(IRunSettingsProvider runSettingProvider, IFileHelper fileHelper) + if (!DoesDataCollectorSettingsExist(argument, dataCollectionRunSettings, out DataCollectorSettings dataCollectorSettings)) { - foreach (string adapterPath in RunSettingsUtilities.GetTestAdaptersPaths(runSettingProvider.ActiveRunSettings.SettingsXml)) - { - string collectorPath = Path.Combine(adapterPath, CoverletConstants.CoverletDataCollectorCodebase); - if (fileHelper.Exists(collectorPath)) - { - EqtTrace.Verbose("CoverletDataCollector in-process codeBase path '{0}'", collectorPath); - return collectorPath; - } - } - - return null; + dataCollectorSettings = new DataCollectorSettings(); + dataCollectorSettings.FriendlyName = argument; + dataCollectorSettings.IsEnabled = true; + dataCollectionRunSettings.DataCollectorSettingsList.Add(dataCollectorSettings); + } + else + { + dataCollectorSettings.IsEnabled = true; } - /// - public ArgumentProcessorResult Execute() + return dataCollectorSettings; + } + + private static void AddDataCollectorConfigurations(string[] configurations, DataCollectorSettings dataCollectorSettings, string exceptionMessage) + { + if (dataCollectorSettings.Configuration == null) { - return ArgumentProcessorResult.Success; + XmlDocument doc = new(); + dataCollectorSettings.Configuration = doc.CreateElement("Configuration"); } - internal static DataCollectorSettings EnableDataCollectorUsingFriendlyName(string argument, DataCollectionRunSettings dataCollectionRunSettings) + foreach (var configuration in configurations) { - DataCollectorSettings dataCollectorSettings = null; + var keyValuePair = ArgumentProcessorUtilities.GetArgumentList(configuration, ArgumentProcessorUtilities.EqualNameValueSeparator, exceptionMessage); - if (!DoesDataCollectorSettingsExist(argument, dataCollectionRunSettings, out dataCollectorSettings)) + if (keyValuePair.Length == 2) { - dataCollectorSettings = new DataCollectorSettings(); - dataCollectorSettings.FriendlyName = argument; - dataCollectorSettings.IsEnabled = true; - dataCollectionRunSettings.DataCollectorSettingsList.Add(dataCollectorSettings); + AddOrUpdateConfiguration(dataCollectorSettings.Configuration, keyValuePair[0], keyValuePair[1]); } else { - dataCollectorSettings.IsEnabled = true; + throw new CommandLineException(exceptionMessage); } - - return dataCollectorSettings; } + } - private static void AddDataCollectorConfigurations(string[] configurations, DataCollectorSettings dataCollectorSettings, string exceptionMessage) - { - if (dataCollectorSettings.Configuration == null) - { - XmlDocument doc = new XmlDocument(); - dataCollectorSettings.Configuration = doc.CreateElement("Configuration"); - } - - foreach (var configuration in configurations) - { - var keyValuePair = ArgumentProcessorUtilities.GetArgumentList(configuration, ArgumentProcessorUtilities.EqualNameValueSeparator, exceptionMessage); - - if (keyValuePair.Length == 2) - { - AddOrUpdateConfiguration(dataCollectorSettings.Configuration, keyValuePair[0], keyValuePair[1]); - } - else - { - throw new CommandLineException(exceptionMessage); - } - } - } + private static void AddOrUpdateConfiguration(XmlElement configuration, string configurationName, string configurationValue) + { + var existingConfigurations = configuration.GetElementsByTagName(configurationName); - private static void AddOrUpdateConfiguration(XmlElement configuration, string configurationName, string configurationValue) + // Update existing configuration if present. + if (existingConfigurations.Count == 0) { - var existingConfigurations = configuration.GetElementsByTagName(configurationName); - - // Update existing configuration if present. - if (existingConfigurations.Count == 0) - { - XmlElement newConfiguration = configuration.OwnerDocument.CreateElement(configurationName); - newConfiguration.InnerText = configurationValue; - configuration.AppendChild(newConfiguration); - return; - } - - foreach (XmlNode existingConfiguration in existingConfigurations) - { - existingConfiguration.InnerText = configurationValue; - } + XmlElement newConfiguration = configuration.OwnerDocument.CreateElement(configurationName); + newConfiguration.InnerText = configurationValue; + configuration.AppendChild(newConfiguration); + return; } - /// - /// Enables coverlet in-proc datacollector - /// - internal static void EnableCoverletInProcDataCollector(string argument, DataCollectionRunSettings dataCollectionRunSettings, IRunSettingsProvider runSettingProvider, IFileHelper fileHelper) + foreach (XmlNode existingConfiguration in existingConfigurations) { - DataCollectorSettings dataCollectorSettings = null; - - if (!DoesDataCollectorSettingsExist(argument, dataCollectionRunSettings, out dataCollectorSettings)) - { - // Create a new setting with default values - dataCollectorSettings = new DataCollectorSettings(); - dataCollectorSettings.FriendlyName = argument; - dataCollectorSettings.AssemblyQualifiedName = CoverletConstants.CoverletDataCollectorAssemblyQualifiedName; - dataCollectorSettings.CodeBase = GetCoverletCodeBasePath(runSettingProvider, fileHelper) ?? CoverletConstants.CoverletDataCollectorCodebase; - dataCollectorSettings.IsEnabled = true; - dataCollectionRunSettings.DataCollectorSettingsList.Add(dataCollectorSettings); - } - else - { - // Set Assembly qualified name and code base if not already set - dataCollectorSettings.AssemblyQualifiedName = dataCollectorSettings.AssemblyQualifiedName ?? CoverletConstants.CoverletDataCollectorAssemblyQualifiedName; - dataCollectorSettings.CodeBase = (dataCollectorSettings.CodeBase ?? GetCoverletCodeBasePath(runSettingProvider, fileHelper)) ?? CoverletConstants.CoverletDataCollectorCodebase; - dataCollectorSettings.IsEnabled = true; - } + existingConfiguration.InnerText = configurationValue; } + } - private static bool DoesDataCollectorSettingsExist(string friendlyName, - DataCollectionRunSettings dataCollectionRunSettings, - out DataCollectorSettings dataCollectorSettings) - { - dataCollectorSettings = null; - foreach (var dataCollectorSetting in dataCollectionRunSettings.DataCollectorSettingsList) - { - if (dataCollectorSetting.FriendlyName.Equals(friendlyName, StringComparison.OrdinalIgnoreCase)) - { - dataCollectorSettings = dataCollectorSetting; - return true; - } - } + /// + /// Enables coverlet in-proc datacollector + /// + internal static void EnableCoverletInProcDataCollector(string argument, DataCollectionRunSettings dataCollectionRunSettings, IRunSettingsProvider runSettingProvider, IFileHelper fileHelper) + { - return false; + if (!DoesDataCollectorSettingsExist(argument, dataCollectionRunSettings, out DataCollectorSettings dataCollectorSettings)) + { + // Create a new setting with default values + dataCollectorSettings = new DataCollectorSettings(); + dataCollectorSettings.FriendlyName = argument; + dataCollectorSettings.AssemblyQualifiedName = CoverletConstants.CoverletDataCollectorAssemblyQualifiedName; + dataCollectorSettings.CodeBase = GetCoverletCodeBasePath(runSettingProvider, fileHelper) ?? CoverletConstants.CoverletDataCollectorCodebase; + dataCollectorSettings.IsEnabled = true; + dataCollectionRunSettings.DataCollectorSettingsList.Add(dataCollectorSettings); } - - internal static void AddDataCollectorToRunSettings(string arguments, IRunSettingsProvider runSettingsManager, IFileHelper fileHelper) + else { - AddDataCollectorToRunSettings(new string[] { arguments }, runSettingsManager, fileHelper, string.Empty); + // Set Assembly qualified name and code base if not already set + dataCollectorSettings.AssemblyQualifiedName ??= CoverletConstants.CoverletDataCollectorAssemblyQualifiedName; + dataCollectorSettings.CodeBase = (dataCollectorSettings.CodeBase ?? GetCoverletCodeBasePath(runSettingProvider, fileHelper)) ?? CoverletConstants.CoverletDataCollectorCodebase; + dataCollectorSettings.IsEnabled = true; } + } - internal static void AddDataCollectorToRunSettings(string[] arguments, IRunSettingsProvider runSettingsManager, IFileHelper fileHelper, string exceptionMessage) + private static bool DoesDataCollectorSettingsExist(string friendlyName, + DataCollectionRunSettings dataCollectionRunSettings, + out DataCollectorSettings dataCollectorSettings) + { + dataCollectorSettings = null; + foreach (var dataCollectorSetting in dataCollectionRunSettings.DataCollectorSettingsList) { - var collectorName = arguments[0]; - var additionalConfigurations = arguments.Skip(1).ToArray(); - EnabledDataCollectors.Add(collectorName.ToLower()); - - var settings = runSettingsManager.ActiveRunSettings?.SettingsXml; - if (settings == null) + if (dataCollectorSetting.FriendlyName.Equals(friendlyName, StringComparison.OrdinalIgnoreCase)) { - runSettingsManager.AddDefaultRunSettings(); - settings = runSettingsManager.ActiveRunSettings?.SettingsXml; + dataCollectorSettings = dataCollectorSetting; + return true; } + } - var dataCollectionRunSettings = XmlRunSettingsUtilities.GetDataCollectionRunSettings(settings) ?? new DataCollectionRunSettings(); - var inProcDataCollectionRunSettings = XmlRunSettingsUtilities.GetInProcDataCollectionRunSettings(settings) - ?? new DataCollectionRunSettings( - Constants.InProcDataCollectionRunSettingsName, - Constants.InProcDataCollectorsSettingName, - Constants.InProcDataCollectorSettingName); - - // Add data collectors if not already present, enable if already present. - var dataCollectorSettings = EnableDataCollectorUsingFriendlyName(collectorName, dataCollectionRunSettings); + return false; + } - if (additionalConfigurations.Length > 0) - { - AddDataCollectorConfigurations(additionalConfigurations, dataCollectorSettings, exceptionMessage); - } + internal static void AddDataCollectorToRunSettings(string arguments, IRunSettingsProvider runSettingsManager, IFileHelper fileHelper) + { + AddDataCollectorToRunSettings(new string[] { arguments }, runSettingsManager, fileHelper, string.Empty); + } - runSettingsManager.UpdateRunSettingsNodeInnerXml(Constants.DataCollectionRunSettingsName, dataCollectionRunSettings.ToXml().InnerXml); + internal static void AddDataCollectorToRunSettings(string[] arguments, IRunSettingsProvider runSettingsManager, IFileHelper fileHelper, string exceptionMessage) + { + var collectorName = arguments[0]; + var additionalConfigurations = arguments.Skip(1).ToArray(); + EnabledDataCollectors.Add(collectorName.ToLower()); - if (string.Equals(collectorName, CoverletConstants.CoverletDataCollectorFriendlyName, StringComparison.OrdinalIgnoreCase)) - { - // Add in-proc data collector to runsettings if coverlet code coverage is enabled - EnableCoverletInProcDataCollector(collectorName, inProcDataCollectionRunSettings, runSettingsManager, fileHelper); - runSettingsManager.UpdateRunSettingsNodeInnerXml(Constants.InProcDataCollectionRunSettingsName, inProcDataCollectionRunSettings.ToXml().InnerXml); - } + var settings = runSettingsManager.ActiveRunSettings?.SettingsXml; + if (settings == null) + { + runSettingsManager.AddDefaultRunSettings(); + settings = runSettingsManager.ActiveRunSettings?.SettingsXml; } - internal static void AddDataCollectorFriendlyName(string friendlyName) + var dataCollectionRunSettings = XmlRunSettingsUtilities.GetDataCollectionRunSettings(settings) ?? new DataCollectionRunSettings(); + var inProcDataCollectionRunSettings = XmlRunSettingsUtilities.GetInProcDataCollectionRunSettings(settings) + ?? new DataCollectionRunSettings( + Constants.InProcDataCollectionRunSettingsName, + Constants.InProcDataCollectorsSettingName, + Constants.InProcDataCollectorSettingName); + + // Add data collectors if not already present, enable if already present. + var dataCollectorSettings = EnableDataCollectorUsingFriendlyName(collectorName, dataCollectionRunSettings); + + if (additionalConfigurations.Length > 0) { - EnabledDataCollectors.Add(friendlyName.ToLower()); + AddDataCollectorConfigurations(additionalConfigurations, dataCollectorSettings, exceptionMessage); } - internal static class CoverletConstants + runSettingsManager.UpdateRunSettingsNodeInnerXml(Constants.DataCollectionRunSettingsName, dataCollectionRunSettings.ToXml().InnerXml); + + if (string.Equals(collectorName, CoverletConstants.CoverletDataCollectorFriendlyName, StringComparison.OrdinalIgnoreCase)) { - /// - /// Coverlet in-proc data collector friendly name - /// - public const string CoverletDataCollectorFriendlyName = "XPlat Code Coverage"; - - /// - /// Coverlet in-proc data collector assembly qualified name - /// - public const string CoverletDataCollectorAssemblyQualifiedName = "Coverlet.Collector.DataCollection.CoverletInProcDataCollector, coverlet.collector, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"; - - /// - /// Coverlet in-proc data collector code base - /// - public const string CoverletDataCollectorCodebase = "coverlet.collector.dll"; + // Add in-proc data collector to runsettings if coverlet code coverage is enabled + EnableCoverletInProcDataCollector(collectorName, inProcDataCollectionRunSettings, runSettingsManager, fileHelper); + runSettingsManager.UpdateRunSettingsNodeInnerXml(Constants.InProcDataCollectionRunSettingsName, inProcDataCollectionRunSettings.ToXml().InnerXml); } } + + internal static void AddDataCollectorFriendlyName(string friendlyName) + { + EnabledDataCollectors.Add(friendlyName.ToLower()); + } + + internal static class CoverletConstants + { + /// + /// Coverlet in-proc data collector friendly name + /// + public const string CoverletDataCollectorFriendlyName = "XPlat Code Coverage"; + + /// + /// Coverlet in-proc data collector assembly qualified name + /// + public const string CoverletDataCollectorAssemblyQualifiedName = "Coverlet.Collector.DataCollection.CoverletInProcDataCollector, coverlet.collector, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"; + + /// + /// Coverlet in-proc data collector code base + /// + public const string CoverletDataCollectorCodebase = "coverlet.collector.dll"; + } } \ No newline at end of file diff --git a/src/vstest.console/Processors/DisableAutoFakesArgumentProcessor.cs b/src/vstest.console/Processors/DisableAutoFakesArgumentProcessor.cs index 90396805ef..e9455a8507 100644 --- a/src/vstest.console/Processors/DisableAutoFakesArgumentProcessor.cs +++ b/src/vstest.console/Processors/DisableAutoFakesArgumentProcessor.cs @@ -1,108 +1,104 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; +using System; - /// - /// An argument processor that allows the user to disable fakes - /// from the command line using the --DisableAutoFakes|/DisableAutoFakes command line switch. - /// - internal class DisableAutoFakesArgumentProcessor : IArgumentProcessor - { - #region Constants +using CommandLineResources = Resources.Resources; - public const string CommandName = "/DisableAutoFakes"; +/// +/// An argument processor that allows the user to disable fakes +/// from the command line using the --DisableAutoFakes|/DisableAutoFakes command line switch. +/// +internal class DisableAutoFakesArgumentProcessor : IArgumentProcessor +{ + #region Constants + + public const string CommandName = "/DisableAutoFakes"; - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - #endregion + #endregion - public Lazy Executor + public Lazy Executor + { + get { - get - { - return this.executor ?? (this.executor = - new Lazy( - () => new DisableAutoFakesArgumentExecutor( - CommandLineOptions.Instance))); - } - - set => this.executor = value; + return _executor ??= new Lazy( + () => new DisableAutoFakesArgumentExecutor( + CommandLineOptions.Instance)); } - public Lazy Metadata + set => _executor = value; + } + + public Lazy Metadata + { + get { - get - { - return this.metadata ?? (this.metadata = - new Lazy( - () => new DisableAutoFakesArgumentProcessorCapabilities())); - } + return _metadata ??= new Lazy( + () => new DisableAutoFakesArgumentProcessorCapabilities()); } } +} - internal class DisableAutoFakesArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override bool AllowMultiple => false; +internal class DisableAutoFakesArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override bool AllowMultiple => false; - public override string CommandName => DisableAutoFakesArgumentProcessor.CommandName; + public override string CommandName => DisableAutoFakesArgumentProcessor.CommandName; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; - public override HelpContentPriority HelpPriority => HelpContentPriority.DisableAutoFakesArgumentProcessorHelpPriority; - } + public override HelpContentPriority HelpPriority => HelpContentPriority.DisableAutoFakesArgumentProcessorHelpPriority; +} - internal class DisableAutoFakesArgumentExecutor : IArgumentExecutor - { - private readonly CommandLineOptions commandLineOptions; +internal class DisableAutoFakesArgumentExecutor : IArgumentExecutor +{ + private readonly CommandLineOptions _commandLineOptions; - #region Constructors - public DisableAutoFakesArgumentExecutor(CommandLineOptions commandLineOptions) - { - this.commandLineOptions = commandLineOptions; - } - #endregion + #region Constructors + public DisableAutoFakesArgumentExecutor(CommandLineOptions commandLineOptions) + { + _commandLineOptions = commandLineOptions; + } + #endregion - #region IArgumentProcessor + #region IArgumentProcessor - /// - /// Initializes with the argument that was provided with the command. - /// - /// Argument that was provided with the command. - public void Initialize(string argument) + /// + /// Initializes with the argument that was provided with the command. + /// + /// Argument that was provided with the command. + public void Initialize(string argument) + { + if (string.IsNullOrWhiteSpace(argument)) { - if (string.IsNullOrWhiteSpace(argument)) - { - throw new CommandLineException(CommandLineResources.DisableAutoFakesUsage); - } - - bool value; - if (!bool.TryParse(argument, out value)) - { - throw new CommandLineException(CommandLineResources.DisableAutoFakesUsage); - } - - this.commandLineOptions.DisableAutoFakes = value; + throw new CommandLineException(CommandLineResources.DisableAutoFakesUsage); } - /// - /// Execute. - /// - /// - /// The . - /// - public ArgumentProcessorResult Execute() + if (!bool.TryParse(argument, out bool value)) { - // Nothing to do since we updated the parameter during initialize parameter - return ArgumentProcessorResult.Success; + throw new CommandLineException(CommandLineResources.DisableAutoFakesUsage); } - #endregion + _commandLineOptions.DisableAutoFakes = value; } + + /// + /// Execute. + /// + /// + /// The . + /// + public ArgumentProcessorResult Execute() + { + // Nothing to do since we updated the parameter during initialize parameter + return ArgumentProcessorResult.Success; + } + + #endregion } \ No newline at end of file diff --git a/src/vstest.console/Processors/EnableBlameArgumentProcessor.cs b/src/vstest.console/Processors/EnableBlameArgumentProcessor.cs index d96d48f569..8dee31a5ed 100644 --- a/src/vstest.console/Processors/EnableBlameArgumentProcessor.cs +++ b/src/vstest.console/Processors/EnableBlameArgumentProcessor.cs @@ -1,388 +1,388 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Xml; + +using Utilities; +using Common; +using Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using PlatformAbstractions; +using PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +using CommandLineResources = Resources.Resources; + +internal class EnableBlameArgumentProcessor : IArgumentProcessor { - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Linq; - using System.Xml; - - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; - - internal class EnableBlameArgumentProcessor : IArgumentProcessor - { - /// - /// The name of the command line argument that the ListTestsArgumentExecutor handles. - /// - public const string CommandName = "/Blame"; + /// + /// The name of the command line argument that the ListTestsArgumentExecutor handles. + /// + public const string CommandName = "/Blame"; - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - /// - /// Initializes a new instance of the class. - /// - public EnableBlameArgumentProcessor() - { - } + /// + /// Initializes a new instance of the class. + /// + public EnableBlameArgumentProcessor() + { + } - public Lazy Metadata + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new EnableBlameArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new EnableBlameArgumentProcessorCapabilities()); } + + return _metadata; } + } - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => new EnableBlameArgumentExecutor(RunSettingsManager.Instance, new PlatformEnvironment(), new FileHelper())); - } - - return this.executor; - } - set - { - this.executor = value; + _executor = new Lazy(() => new EnableBlameArgumentExecutor(RunSettingsManager.Instance, new PlatformEnvironment(), new FileHelper())); } + + return _executor; + } + set + { + _executor = value; } } +} - /// - /// The argument capabilities. - /// - internal class EnableBlameArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => EnableBlameArgumentProcessor.CommandName; +/// +/// The argument capabilities. +/// +internal class EnableBlameArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => EnableBlameArgumentProcessor.CommandName; - public override bool AllowMultiple => false; + public override bool AllowMultiple => false; - public override bool IsAction => false; + public override bool IsAction => false; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Logging; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Logging; - public override string HelpContentResourceName => CommandLineResources.EnableBlameUsage; + public override string HelpContentResourceName => CommandLineResources.EnableBlameUsage; - public override HelpContentPriority HelpPriority => HelpContentPriority.EnableDiagArgumentProcessorHelpPriority; - } + public override HelpContentPriority HelpPriority => HelpContentPriority.EnableDiagArgumentProcessorHelpPriority; +} +/// +/// The argument executor. +/// +internal class EnableBlameArgumentExecutor : IArgumentExecutor +{ /// - /// The argument executor. + /// Blame logger and data collector friendly name /// - internal class EnableBlameArgumentExecutor : IArgumentExecutor - { - /// - /// Blame logger and data collector friendly name - /// - private static string BlameFriendlyName = "blame"; + private static readonly string BlameFriendlyName = "blame"; - /// - /// Run settings manager - /// - private IRunSettingsProvider runSettingsManager; + /// + /// Run settings manager + /// + private readonly IRunSettingsProvider _runSettingsManager; - /// - /// Platform environment - /// - private IEnvironment environment; + /// + /// Platform environment + /// + private readonly IEnvironment _environment; - /// - /// For file related operation - /// - private readonly IFileHelper fileHelper; + /// + /// For file related operation + /// + private readonly IFileHelper _fileHelper; - #region Constructor + #region Constructor - internal EnableBlameArgumentExecutor(IRunSettingsProvider runSettingsManager, IEnvironment environment, IFileHelper fileHelper) - { - this.runSettingsManager = runSettingsManager; - this.environment = environment; - this.Output = ConsoleOutput.Instance; - this.fileHelper = fileHelper; - } + internal EnableBlameArgumentExecutor(IRunSettingsProvider runSettingsManager, IEnvironment environment, IFileHelper fileHelper) + { + _runSettingsManager = runSettingsManager; + _environment = environment; + Output = ConsoleOutput.Instance; + _fileHelper = fileHelper; + } + + #endregion - #endregion + #region Properties - #region Properties + internal IOutput Output { get; set; } - internal IOutput Output { get; set; } + #endregion - #endregion + #region IArgumentExecutor - #region IArgumentExecutor + /// + /// Initializes with the argument that was provided with the command. + /// + /// Argument that was provided with the command. + public void Initialize(string argument) + { + var enableDump = false; + var enableHangDump = false; + var exceptionMessage = string.Format(CultureInfo.CurrentUICulture, CommandLineResources.InvalidBlameArgument, argument); + Dictionary collectDumpParameters = null; - /// - /// Initializes with the argument that was provided with the command. - /// - /// Argument that was provided with the command. - public void Initialize(string argument) + if (!string.IsNullOrWhiteSpace(argument)) { - var enableDump = false; - var enableHangDump = false; - var exceptionMessage = string.Format(CultureInfo.CurrentUICulture, CommandLineResources.InvalidBlameArgument, argument); - Dictionary collectDumpParameters = null; + // Get blame argument list. + var blameArgumentList = ArgumentProcessorUtilities.GetArgumentList(argument, ArgumentProcessorUtilities.SemiColonArgumentSeparator, exceptionMessage); + Func isDumpCollect = a => Constants.BlameCollectDumpKey.Equals(a, StringComparison.OrdinalIgnoreCase); + Func isHangDumpCollect = a => Constants.BlameCollectHangDumpKey.Equals(a, StringComparison.OrdinalIgnoreCase); + + // Get collect dump key. + var hasCollectDumpKey = blameArgumentList.Any(isDumpCollect); + var hasCollectHangDumpKey = blameArgumentList.Any(isHangDumpCollect); + + // Check if dump should be enabled or not. + enableDump = hasCollectDumpKey && IsDumpCollectionSupported(); + + // Check if dump should be enabled or not. + enableHangDump = hasCollectHangDumpKey && IsHangDumpCollectionSupported(); - if (!string.IsNullOrWhiteSpace(argument)) + if (!enableDump && !enableHangDump) { - // Get blame argument list. - var blameArgumentList = ArgumentProcessorUtilities.GetArgumentList(argument, ArgumentProcessorUtilities.SemiColonArgumentSeparator, exceptionMessage); - Func isDumpCollect = a => Constants.BlameCollectDumpKey.Equals(a, StringComparison.OrdinalIgnoreCase); - Func isHangDumpCollect = a => Constants.BlameCollectHangDumpKey.Equals(a, StringComparison.OrdinalIgnoreCase); + Output.Warning(false, string.Format(CultureInfo.CurrentUICulture, CommandLineResources.BlameIncorrectOption, argument)); + } + else + { + // Get collect dump parameters. + var collectDumpParameterArgs = blameArgumentList.Where(a => !isDumpCollect(a) && !isHangDumpCollect(a)); + collectDumpParameters = ArgumentProcessorUtilities.GetArgumentParameters(collectDumpParameterArgs, ArgumentProcessorUtilities.EqualNameValueSeparator, exceptionMessage); + } + } - // Get collect dump key. - var hasCollectDumpKey = blameArgumentList.Any(isDumpCollect); - var hasCollectHangDumpKey = blameArgumentList.Any(isHangDumpCollect); + // Initialize blame. + InitializeBlame(enableDump, enableHangDump, collectDumpParameters); + } - // Check if dump should be enabled or not. - enableDump = hasCollectDumpKey && IsDumpCollectionSupported(); + /// + /// Executes the argument processor. + /// + /// The . + public ArgumentProcessorResult Execute() + { + // Nothing to do since we updated the logger and data collector list in initialize + return ArgumentProcessorResult.Success; + } - // Check if dump should be enabled or not. - enableHangDump = hasCollectHangDumpKey && IsHangDumpCollectionSupported(); + /// + /// Initialize blame. + /// + /// Enable dump. + /// Blame parameters. + private void InitializeBlame(bool enableCrashDump, bool enableHangDump, Dictionary collectDumpParameters) + { + // Add Blame Logger + LoggerUtilities.AddLoggerToRunSettings(BlameFriendlyName, null, _runSettingsManager); - if (!enableDump && !enableHangDump) - { - Output.Warning(false, string.Format(CultureInfo.CurrentUICulture, CommandLineResources.BlameIncorrectOption, argument)); - } - else - { - // Get collect dump parameters. - var collectDumpParameterArgs = blameArgumentList.Where(a => !isDumpCollect(a) && !isHangDumpCollect(a)); - collectDumpParameters = ArgumentProcessorUtilities.GetArgumentParameters(collectDumpParameterArgs, ArgumentProcessorUtilities.EqualNameValueSeparator, exceptionMessage); - } - } + // Add Blame Data Collector + CollectArgumentExecutor.AddDataCollectorToRunSettings(BlameFriendlyName, _runSettingsManager, _fileHelper); - // Initialize blame. - InitializeBlame(enableDump, enableHangDump, collectDumpParameters); - } - /// - /// Executes the argument processor. - /// - /// The . - public ArgumentProcessorResult Execute() + // Add default run settings if required. + if (_runSettingsManager.ActiveRunSettings?.SettingsXml == null) { - // Nothing to do since we updated the logger and data collector list in initialize - return ArgumentProcessorResult.Success; + _runSettingsManager.AddDefaultRunSettings(); } + var settings = _runSettingsManager.ActiveRunSettings?.SettingsXml; + + // Get results directory from RunSettingsManager + var resultsDirectory = GetResultsDirectory(settings); - /// - /// Initialize blame. - /// - /// Enable dump. - /// Blame parameters. - private void InitializeBlame(bool enableCrashDump, bool enableHangDump, Dictionary collectDumpParameters) + // Get data collection run settings. Create if not present. + var dataCollectionRunSettings = XmlRunSettingsUtilities.GetDataCollectionRunSettings(settings); + if (dataCollectionRunSettings == null) { - // Add Blame Logger - LoggerUtilities.AddLoggerToRunSettings(BlameFriendlyName, null, this.runSettingsManager); + dataCollectionRunSettings = new DataCollectionRunSettings(); + } - // Add Blame Data Collector - CollectArgumentExecutor.AddDataCollectorToRunSettings(BlameFriendlyName, this.runSettingsManager, this.fileHelper); + // Create blame configuration element. + var xmlDocument = new XmlDocument(); + var outernode = xmlDocument.CreateElement("Configuration"); + var node = xmlDocument.CreateElement("ResultsDirectory"); + outernode.AppendChild(node); + node.InnerText = resultsDirectory; + // Add collect dump node in configuration element. + if (enableCrashDump) + { + var dumpParameters = collectDumpParameters + .Where(p => new[] { "CollectAlways", "DumpType" }.Contains(p.Key, StringComparer.OrdinalIgnoreCase)) + .ToDictionary(p => p.Key, p => p.Value, StringComparer.OrdinalIgnoreCase); - // Add default run settings if required. - if (this.runSettingsManager.ActiveRunSettings?.SettingsXml == null) + if (!dumpParameters.ContainsKey("DumpType")) { - this.runSettingsManager.AddDefaultRunSettings(); + dumpParameters.Add("DumpType", "Full"); } - var settings = this.runSettingsManager.ActiveRunSettings?.SettingsXml; - - // Get results directory from RunSettingsManager - var resultsDirectory = GetResultsDirectory(settings); - // Get data collection run settings. Create if not present. - var dataCollectionRunSettings = XmlRunSettingsUtilities.GetDataCollectionRunSettings(settings); - if (dataCollectionRunSettings == null) - { - dataCollectionRunSettings = new DataCollectionRunSettings(); - } + AddCollectDumpNode(dumpParameters, xmlDocument, outernode); + } - // Create blame configuration element. - var XmlDocument = new XmlDocument(); - var outernode = XmlDocument.CreateElement("Configuration"); - var node = XmlDocument.CreateElement("ResultsDirectory"); - outernode.AppendChild(node); - node.InnerText = resultsDirectory; + // Add collect hang dump node in configuration element. + if (enableHangDump) + { + var hangDumpParameters = collectDumpParameters + .Where(p => new[] { "TestTimeout", "HangDumpType" }.Contains(p.Key, StringComparer.OrdinalIgnoreCase)) + .ToDictionary(p => p.Key, p => p.Value, StringComparer.OrdinalIgnoreCase); - // Add collect dump node in configuration element. - if (enableCrashDump) + if (!hangDumpParameters.ContainsKey("TestTimeout")) { - var dumpParameters = collectDumpParameters - .Where(p => new[] { "CollectAlways", "DumpType" }.Contains(p.Key, StringComparer.OrdinalIgnoreCase)) - .ToDictionary(p => p.Key, p => p.Value, StringComparer.OrdinalIgnoreCase); - - if (!dumpParameters.ContainsKey("DumpType")) - { - dumpParameters.Add("DumpType", "Full"); - } - - AddCollectDumpNode(dumpParameters, XmlDocument, outernode); + hangDumpParameters.Add("TestTimeout", TimeSpan.FromHours(1).TotalMilliseconds.ToString()); } - // Add collect hang dump node in configuration element. - if (enableHangDump) + if (!hangDumpParameters.ContainsKey("HangDumpType")) { - var hangDumpParameters = collectDumpParameters - .Where(p => new[] { "TestTimeout", "HangDumpType" }.Contains(p.Key, StringComparer.OrdinalIgnoreCase)) - .ToDictionary(p => p.Key, p => p.Value, StringComparer.OrdinalIgnoreCase); - - if (!hangDumpParameters.ContainsKey("TestTimeout")) - { - hangDumpParameters.Add("TestTimeout", TimeSpan.FromHours(1).TotalMilliseconds.ToString()); - } - - if (!hangDumpParameters.ContainsKey("HangDumpType")) - { - hangDumpParameters.Add("HangDumpType", "Full"); - } - - AddCollectHangDumpNode(hangDumpParameters, XmlDocument, outernode); + hangDumpParameters.Add("HangDumpType", "Full"); } - // Add blame configuration element to blame collector. - foreach (var item in dataCollectionRunSettings.DataCollectorSettingsList) + AddCollectHangDumpNode(hangDumpParameters, xmlDocument, outernode); + } + + // Add blame configuration element to blame collector. + foreach (var item in dataCollectionRunSettings.DataCollectorSettingsList) + { + if (item.FriendlyName.Equals(BlameFriendlyName)) { - if (item.FriendlyName.Equals(BlameFriendlyName)) - { - item.Configuration = outernode; - } + item.Configuration = outernode; } - - // Update run settings. - runSettingsManager.UpdateRunSettingsNodeInnerXml(Constants.DataCollectionRunSettingsName, dataCollectionRunSettings.ToXml().InnerXml); } - /// - /// Get results directory. - /// - /// Settings xml. - /// Results directory. - private string GetResultsDirectory(string settings) + // Update run settings. + _runSettingsManager.UpdateRunSettingsNodeInnerXml(Constants.DataCollectionRunSettingsName, dataCollectionRunSettings.ToXml().InnerXml); + } + + /// + /// Get results directory. + /// + /// Settings xml. + /// Results directory. + private string GetResultsDirectory(string settings) + { + string resultsDirectory = null; + if (settings != null) { - string resultsDirectory = null; - if (settings != null) + try { - try - { - RunConfiguration runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(settings); - resultsDirectory = RunSettingsUtilities.GetTestResultsDirectory(runConfiguration); - } - catch (SettingsException se) + RunConfiguration runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(settings); + resultsDirectory = RunSettingsUtilities.GetTestResultsDirectory(runConfiguration); + } + catch (SettingsException se) + { + if (EqtTrace.IsErrorEnabled) { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("EnableBlameArgumentProcessor: Unable to get the test results directory: Error {0}", se); - } + EqtTrace.Error("EnableBlameArgumentProcessor: Unable to get the test results directory: Error {0}", se); } } - - return resultsDirectory; } - /// - /// Checks if crash dump collection is supported. - /// - /// Dump collection supported flag. - private bool IsDumpCollectionSupported() - { - var dumpCollectionSupported = - this.environment.OperatingSystem == PlatformOperatingSystem.Unix || - this.environment.OperatingSystem == PlatformOperatingSystem.OSX || - (this.environment.OperatingSystem == PlatformOperatingSystem.Windows - && this.environment.Architecture != PlatformArchitecture.ARM64 - && this.environment.Architecture != PlatformArchitecture.ARM); - - if (!dumpCollectionSupported) - { - Output.Warning(false, CommandLineResources.BlameCollectDumpNotSupportedForPlatform); - } + return resultsDirectory; + } - return dumpCollectionSupported; + /// + /// Checks if crash dump collection is supported. + /// + /// Dump collection supported flag. + private bool IsDumpCollectionSupported() + { + var dumpCollectionSupported = + _environment.OperatingSystem == PlatformOperatingSystem.Unix || + _environment.OperatingSystem == PlatformOperatingSystem.OSX || + (_environment.OperatingSystem == PlatformOperatingSystem.Windows + && _environment.Architecture != PlatformArchitecture.ARM64 + && _environment.Architecture != PlatformArchitecture.ARM); + + if (!dumpCollectionSupported) + { + Output.Warning(false, CommandLineResources.BlameCollectDumpNotSupportedForPlatform); } - /// - /// Checks if hang dump collection is supported. - /// - /// Dump collection supported flag. - private bool IsHangDumpCollectionSupported() - { - var dumpCollectionSupported = true; + return dumpCollectionSupported; + } - if (!dumpCollectionSupported) - { - Output.Warning(false, CommandLineResources.BlameCollectDumpTestTimeoutNotSupportedForPlatform); - } + /// + /// Checks if hang dump collection is supported. + /// + /// Dump collection supported flag. + private bool IsHangDumpCollectionSupported() + { + var dumpCollectionSupported = true; - return dumpCollectionSupported; + if (!dumpCollectionSupported) + { + Output.Warning(false, CommandLineResources.BlameCollectDumpTestTimeoutNotSupportedForPlatform); } - /// - /// Adds collect dump node in outer node. - /// - /// Parameters. - /// Xml document. - /// Outer node. - private void AddCollectDumpNode(Dictionary parameters, XmlDocument XmlDocument, XmlElement outernode) + return dumpCollectionSupported; + } + + /// + /// Adds collect dump node in outer node. + /// + /// Parameters. + /// Xml document. + /// Outer node. + private void AddCollectDumpNode(Dictionary parameters, XmlDocument xmlDocument, XmlElement outernode) + { + var dumpNode = xmlDocument.CreateElement(Constants.BlameCollectDumpKey); + if (parameters != null && parameters.Count > 0) { - var dumpNode = XmlDocument.CreateElement(Constants.BlameCollectDumpKey); - if (parameters != null && parameters.Count > 0) + foreach (KeyValuePair entry in parameters) { - foreach (KeyValuePair entry in parameters) - { - var attribute = XmlDocument.CreateAttribute(entry.Key); - attribute.Value = entry.Value; - dumpNode.Attributes.Append(attribute); - } + var attribute = xmlDocument.CreateAttribute(entry.Key); + attribute.Value = entry.Value; + dumpNode.Attributes.Append(attribute); } - outernode.AppendChild(dumpNode); } + outernode.AppendChild(dumpNode); + } - /// - /// Adds collect dump node in outer node. - /// - /// Parameters. - /// Xml document. - /// Outer node. - private void AddCollectHangDumpNode(Dictionary parameters, XmlDocument XmlDocument, XmlElement outernode) + /// + /// Adds collect dump node in outer node. + /// + /// Parameters. + /// Xml document. + /// Outer node. + private void AddCollectHangDumpNode(Dictionary parameters, XmlDocument xmlDocument, XmlElement outernode) + { + var dumpNode = xmlDocument.CreateElement(Constants.CollectDumpOnTestSessionHang); + if (parameters != null && parameters.Count > 0) { - var dumpNode = XmlDocument.CreateElement(Constants.CollectDumpOnTestSessionHang); - if (parameters != null && parameters.Count > 0) + foreach (KeyValuePair entry in parameters) { - foreach (KeyValuePair entry in parameters) - { - var attribute = XmlDocument.CreateAttribute(entry.Key); - attribute.Value = entry.Value; - dumpNode.Attributes.Append(attribute); - } + var attribute = xmlDocument.CreateAttribute(entry.Key); + attribute.Value = entry.Value; + dumpNode.Attributes.Append(attribute); } - outernode.AppendChild(dumpNode); } - - #endregion + outernode.AppendChild(dumpNode); } -} + + #endregion +} \ No newline at end of file diff --git a/src/vstest.console/Processors/EnableCodeCoverageArgumentProcessor.cs b/src/vstest.console/Processors/EnableCodeCoverageArgumentProcessor.cs index a77e320fce..3cd0816d50 100644 --- a/src/vstest.console/Processors/EnableCodeCoverageArgumentProcessor.cs +++ b/src/vstest.console/Processors/EnableCodeCoverageArgumentProcessor.cs @@ -1,339 +1,338 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Globalization; +using System.IO; +using System.Xml; +using System.Xml.XPath; + +using Common; +using Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +/// +/// The argument processor for enabling data collectors. +/// +internal class EnableCodeCoverageArgumentProcessor : IArgumentProcessor { - using System; - using System.Globalization; - using System.IO; - using System.Xml; - using System.Xml.XPath; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + #region Constants /// - /// The argument processor for enabling data collectors. + /// The name of command for enabling code coverage. /// - internal class EnableCodeCoverageArgumentProcessor : IArgumentProcessor - { - #region Constants - - /// - /// The name of command for enabling code coverage. - /// - public const string CommandName = "/EnableCodeCoverage"; + public const string CommandName = "/EnableCodeCoverage"; - #endregion + #endregion - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - /// - /// Gets the metadata. - /// - public Lazy Metadata + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new EnableCodeCoverageArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new EnableCodeCoverageArgumentProcessorCapabilities()); } + + return _metadata; } + } - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => new EnableCodeCoverageArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, new FileHelper())); - } - - return this.executor; + _executor = new Lazy(() => new EnableCodeCoverageArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, new FileHelper())); } - set - { - this.executor = value; - } + return _executor; + } + + set + { + _executor = value; } } +} - /// - internal class EnableCodeCoverageArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => EnableCodeCoverageArgumentProcessor.CommandName; +/// +internal class EnableCodeCoverageArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => EnableCodeCoverageArgumentProcessor.CommandName; - public override bool AllowMultiple => false; + public override bool AllowMultiple => false; - public override bool IsAction => false; + public override bool IsAction => false; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; - //public override string HelpContentResourceName => CommandLineResources.EnableCodeCoverageArgumentProcessorHelp; + //public override string HelpContentResourceName => CommandLineResources.EnableCodeCoverageArgumentProcessorHelp; - //public override HelpContentPriority HelpPriority => HelpContentPriority.EnableCodeCoverageArgumentProcessorHelpPriority; + //public override HelpContentPriority HelpPriority => HelpContentPriority.EnableCodeCoverageArgumentProcessorHelpPriority; +} + +/// +/// The enable code coverage argument executor. +/// +internal class EnableCodeCoverageArgumentExecutor : IArgumentExecutor +{ + #region private variables + + private readonly IRunSettingsProvider _runSettingsManager; + private readonly CommandLineOptions _commandLineOptions; + private readonly IFileHelper _fileHelper; + + internal const string FriendlyName = "Code Coverage"; + + private static readonly string XPathSeperator = "/"; + private static readonly string[] NodeNames = new string[] { Constants.RunSettingsName, Constants.DataCollectionRunSettingsName, Constants.DataCollectorsSettingName, Constants.DataCollectorSettingName }; + + #region Default CodeCoverage Settings String + + private static readonly string CodeCoverageCollectorSettingsTemplate = + @" " + Environment.NewLine + + @" " + Environment.NewLine + + @" " + Environment.NewLine + + @" " + Environment.NewLine + + @" " + Environment.NewLine + + @" .*CPPUnitTestFramework.*" + Environment.NewLine + + @" .*vstest.console.*" + Environment.NewLine + + @" .*microsoft.intellitrace.*" + Environment.NewLine + + @" .*testhost.*" + Environment.NewLine + + @" .*datacollector.*" + Environment.NewLine + + @" .*microsoft.teamfoundation.testplatform.*" + Environment.NewLine + + @" .*microsoft.visualstudio.testplatform.*" + Environment.NewLine + + @" .*microsoft.visualstudio.testwindow.*" + Environment.NewLine + + @" .*microsoft.visualstudio.mstest.*" + Environment.NewLine + + @" .*microsoft.visualstudio.qualitytools.*" + Environment.NewLine + + @" .*microsoft.vssdk.testhostadapter.*" + Environment.NewLine + + @" .*microsoft.vssdk.testhostframework.*" + Environment.NewLine + + @" .*qtagent32.*" + Environment.NewLine + + @" .*msvcr.*dll$" + Environment.NewLine + + @" .*msvcp.*dll$" + Environment.NewLine + + @" .*clr.dll$" + Environment.NewLine + + @" .*clr.ni.dll$" + Environment.NewLine + + @" .*clrjit.dll$" + Environment.NewLine + + @" .*clrjit.ni.dll$" + Environment.NewLine + + @" .*mscoree.dll$" + Environment.NewLine + + @" .*mscoreei.dll$" + Environment.NewLine + + @" .*mscoreei.ni.dll$" + Environment.NewLine + + @" .*mscorlib.dll$" + Environment.NewLine + + @" .*mscorlib.ni.dll$" + Environment.NewLine + + @" " + Environment.NewLine + + @" " + Environment.NewLine + + @" True" + Environment.NewLine + + @" True" + Environment.NewLine + + @" True" + Environment.NewLine + + @" false" + Environment.NewLine + + @" " + Environment.NewLine + + @" " + Environment.NewLine + + @" " + Environment.NewLine + + @" ^std::.*" + Environment.NewLine + + @" ^ATL::.*" + Environment.NewLine + + @" .*::__GetTestMethodInfo.*" + Environment.NewLine + + @" .*__CxxPureMSILEntry.*" + Environment.NewLine + + @" ^Microsoft::VisualStudio::CppCodeCoverageFramework::.*" + Environment.NewLine + + @" ^Microsoft::VisualStudio::CppUnitTestFramework::.*" + Environment.NewLine + + @" .*::YOU_CAN_ONLY_DESIGNATE_ONE_.*" + Environment.NewLine + + @" ^__.*" + Environment.NewLine + + @" .*::__.*" + Environment.NewLine + + @" " + Environment.NewLine + + @" " + Environment.NewLine + + @" " + Environment.NewLine + + @" " + Environment.NewLine + + @" ^System.Diagnostics.DebuggerHiddenAttribute$" + Environment.NewLine + + @" ^System.Diagnostics.DebuggerNonUserCodeAttribute$" + Environment.NewLine + + @" ^System.Runtime.CompilerServices.CompilerGeneratedAttribute$" + Environment.NewLine + + @" ^System.CodeDom.Compiler.GeneratedCodeAttribute$" + Environment.NewLine + + @" ^System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute$" + Environment.NewLine + + @" ^Microsoft.VisualStudio.TestPlatform.TestSDKAutoGeneratedCode.*" + Environment.NewLine + + @" " + Environment.NewLine + + @" " + Environment.NewLine + + @" " + Environment.NewLine + + @" " + Environment.NewLine + + @" .*\\atlmfc\\.*" + Environment.NewLine + + @" .*\\vctools\\.*" + Environment.NewLine + + @" .*\\public\\sdk\\.*" + Environment.NewLine + + @" .*\\externalapis\\.*" + Environment.NewLine + + @" .*\\microsoft sdks\\.*" + Environment.NewLine + + @" .*\\vc\\include\\.*" + Environment.NewLine + + @" .*\\msclr\\.*" + Environment.NewLine + + @" .*\\ucrt\\.*" + Environment.NewLine + + @" " + Environment.NewLine + + @" " + Environment.NewLine + + @" " + Environment.NewLine + + @" " + Environment.NewLine + + @" " + Environment.NewLine + + @" " + Environment.NewLine + + @" "; + + #endregion + + #endregion + + internal EnableCodeCoverageArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsManager, IFileHelper fileHelper) + { + _commandLineOptions = options; + _runSettingsManager = runSettingsManager; + _fileHelper = fileHelper; + } + + /// + public void Initialize(string argument) + { + _commandLineOptions.EnableCodeCoverage = true; + + // Add this enabled data collectors list, this will ensure Code Coverage isn't disabled when other DCs are configured using /Collect. + CollectArgumentExecutor.AddDataCollectorFriendlyName(FriendlyName); + try + { + UpdateWithCodeCoverageSettingsIfNotConfigured(); + } + catch (XPathException e) + { + throw new SettingsException( + string.Format(CultureInfo.CurrentCulture, "{0} {1}", ObjectModel.Resources.CommonResources.MalformedRunSettingsFile, e.Message), e); + } + } + + /// + public ArgumentProcessorResult Execute() + { + return ArgumentProcessorResult.Success; } /// - /// The enable code coverage argument executor. + /// Updates with code coverage settings if not configured. /// - internal class EnableCodeCoverageArgumentExecutor : IArgumentExecutor + /// The run settings document. + private void UpdateWithCodeCoverageSettingsIfNotConfigured() { - #region private variables - - private IRunSettingsProvider runSettingsManager; - private CommandLineOptions commandLineOptions; - private IFileHelper fileHelper; - - internal const string FriendlyName = "Code Coverage"; - - private static string xPathSeperator = "/"; - private static string[] nodeNames = new string[] { Constants.RunSettingsName, Constants.DataCollectionRunSettingsName, Constants.DataCollectorsSettingName, Constants.DataCollectorSettingName }; - - #region Default CodeCoverage Settings String - - private static string codeCoverageCollectorSettingsTemplate = -@" " + Environment.NewLine + -@" " + Environment.NewLine + -@" " + Environment.NewLine + -@" " + Environment.NewLine + -@" " + Environment.NewLine + -@" .*CPPUnitTestFramework.*" + Environment.NewLine + -@" .*vstest.console.*" + Environment.NewLine + -@" .*microsoft.intellitrace.*" + Environment.NewLine + -@" .*testhost.*" + Environment.NewLine + -@" .*datacollector.*" + Environment.NewLine + -@" .*microsoft.teamfoundation.testplatform.*" + Environment.NewLine + -@" .*microsoft.visualstudio.testplatform.*" + Environment.NewLine + -@" .*microsoft.visualstudio.testwindow.*" + Environment.NewLine + -@" .*microsoft.visualstudio.mstest.*" + Environment.NewLine + -@" .*microsoft.visualstudio.qualitytools.*" + Environment.NewLine + -@" .*microsoft.vssdk.testhostadapter.*" + Environment.NewLine + -@" .*microsoft.vssdk.testhostframework.*" + Environment.NewLine + -@" .*qtagent32.*" + Environment.NewLine + -@" .*msvcr.*dll$" + Environment.NewLine + -@" .*msvcp.*dll$" + Environment.NewLine + -@" .*clr.dll$" + Environment.NewLine + -@" .*clr.ni.dll$" + Environment.NewLine + -@" .*clrjit.dll$" + Environment.NewLine + -@" .*clrjit.ni.dll$" + Environment.NewLine + -@" .*mscoree.dll$" + Environment.NewLine + -@" .*mscoreei.dll$" + Environment.NewLine + -@" .*mscoreei.ni.dll$" + Environment.NewLine + -@" .*mscorlib.dll$" + Environment.NewLine + -@" .*mscorlib.ni.dll$" + Environment.NewLine + -@" " + Environment.NewLine + -@" " + Environment.NewLine + -@" True" + Environment.NewLine + -@" True" + Environment.NewLine + -@" True" + Environment.NewLine + -@" false" + Environment.NewLine + -@" " + Environment.NewLine + -@" " + Environment.NewLine + -@" " + Environment.NewLine + -@" ^std::.*" + Environment.NewLine + -@" ^ATL::.*" + Environment.NewLine + -@" .*::__GetTestMethodInfo.*" + Environment.NewLine + -@" .*__CxxPureMSILEntry.*" + Environment.NewLine + -@" ^Microsoft::VisualStudio::CppCodeCoverageFramework::.*" + Environment.NewLine + -@" ^Microsoft::VisualStudio::CppUnitTestFramework::.*" + Environment.NewLine + -@" .*::YOU_CAN_ONLY_DESIGNATE_ONE_.*" + Environment.NewLine + -@" ^__.*" + Environment.NewLine + -@" .*::__.*" + Environment.NewLine + -@" " + Environment.NewLine + -@" " + Environment.NewLine + -@" " + Environment.NewLine + -@" " + Environment.NewLine + -@" ^System.Diagnostics.DebuggerHiddenAttribute$" + Environment.NewLine + -@" ^System.Diagnostics.DebuggerNonUserCodeAttribute$" + Environment.NewLine + -@" ^System.Runtime.CompilerServices.CompilerGeneratedAttribute$" + Environment.NewLine + -@" ^System.CodeDom.Compiler.GeneratedCodeAttribute$" + Environment.NewLine + -@" ^System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute$" + Environment.NewLine + -@" ^Microsoft.VisualStudio.TestPlatform.TestSDKAutoGeneratedCode.*" + Environment.NewLine + -@" " + Environment.NewLine + -@" " + Environment.NewLine + -@" " + Environment.NewLine + -@" " + Environment.NewLine + -@" .*\\atlmfc\\.*" + Environment.NewLine + -@" .*\\vctools\\.*" + Environment.NewLine + -@" .*\\public\\sdk\\.*" + Environment.NewLine + -@" .*\\externalapis\\.*" + Environment.NewLine + -@" .*\\microsoft sdks\\.*" + Environment.NewLine + -@" .*\\vc\\include\\.*" + Environment.NewLine + -@" .*\\msclr\\.*" + Environment.NewLine + -@" .*\\ucrt\\.*" + Environment.NewLine + -@" " + Environment.NewLine + -@" " + Environment.NewLine + -@" " + Environment.NewLine + -@" " + Environment.NewLine + -@" " + Environment.NewLine + -@" " + Environment.NewLine + -@" "; - - #endregion - - #endregion - - internal EnableCodeCoverageArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsManager, IFileHelper fileHelper) + var runsettingsXml = _runSettingsManager.ActiveRunSettings?.SettingsXml; + if (runsettingsXml == null) { - this.commandLineOptions = options; - this.runSettingsManager = runSettingsManager; - this.fileHelper = fileHelper; + _runSettingsManager.AddDefaultRunSettings(); + runsettingsXml = _runSettingsManager.ActiveRunSettings?.SettingsXml; } - /// - public void Initialize(string argument) + IXPathNavigable runSettingsDocument; + using (var stream = new StringReader(runsettingsXml)) + using (var reader = XmlReader.Create(stream, XmlRunSettingsUtilities.ReaderSettings)) { - this.commandLineOptions.EnableCodeCoverage = true; - - // Add this enabled data collectors list, this will ensure Code Coverage isn't disabled when other DCs are configured using /Collect. - CollectArgumentExecutor.AddDataCollectorFriendlyName(FriendlyName); - try - { - this.UpdateWithCodeCoverageSettingsIfNotConfigured(); - } - catch (XPathException e) - { - throw new SettingsException( - string.Format(CultureInfo.CurrentCulture, "{0} {1}", ObjectModel.Resources.CommonResources.MalformedRunSettingsFile, e.Message), e); - } + var document = new XmlDocument(); + document.Load(reader); + runSettingsDocument = document; } - /// - public ArgumentProcessorResult Execute() + var runSettingsNavigator = runSettingsDocument.CreateNavigator(); + + if (ContainsDataCollectorWithFriendlyName(runSettingsNavigator, FriendlyName)) { - return ArgumentProcessorResult.Success; + // runsettings already has Code coverage data collector, just enable it. + CollectArgumentExecutor.AddDataCollectorToRunSettings(FriendlyName, _runSettingsManager, _fileHelper); } - - /// - /// Updates with code coverage settings if not configured. - /// - /// The run settings document. - private void UpdateWithCodeCoverageSettingsIfNotConfigured() + else { - var runsettingsXml = this.runSettingsManager.ActiveRunSettings?.SettingsXml; - if (runsettingsXml == null) + var existingPath = string.Empty; + var xpaths = new string[] { - this.runSettingsManager.AddDefaultRunSettings(); - runsettingsXml = this.runSettingsManager.ActiveRunSettings?.SettingsXml; - } - - IXPathNavigable runSettingsDocument; - using (var stream = new StringReader(runsettingsXml)) - using (var reader = XmlReader.Create(stream, XmlRunSettingsUtilities.ReaderSettings)) - { - var document = new XmlDocument(); - document.Load(reader); - runSettingsDocument = document; - } - - var runSettingsNavigator = runSettingsDocument.CreateNavigator(); + string.Join(XPathSeperator, NodeNames, 0, 1), + string.Join(XPathSeperator, NodeNames, 0, 2), + string.Join(XPathSeperator, NodeNames, 0, 3) + }; - if (ContainsDataCollectorWithFriendlyName(runSettingsNavigator, FriendlyName)) + foreach (var xpath in xpaths) { - // runsettings already has Code coverage data collector, just enable it. - CollectArgumentExecutor.AddDataCollectorToRunSettings(FriendlyName, this.runSettingsManager, this.fileHelper); - } - else - { - var existingPath = string.Empty; - var xpaths = new string[] - { - string.Join(xPathSeperator, nodeNames, 0, 1), - string.Join(xPathSeperator, nodeNames, 0, 2), - string.Join(xPathSeperator, nodeNames, 0, 3) - }; - - foreach (var xpath in xpaths) + if (runSettingsNavigator.SelectSingleNode(xpath) != null) { - if (runSettingsNavigator.SelectSingleNode(xpath) != null) - { - existingPath = xpath; - } - else - { - break; - } + existingPath = xpath; } - - // If any nodes are missing to add code coverage default settings, add the missing xml nodes. - XPathNavigator dataCollectorsNavigator; - if (existingPath.Equals(xpaths[2]) == false) + else { - dataCollectorsNavigator = runSettingsNavigator.SelectSingleNode(existingPath); - var missingNodesText = GetMissingNodesTextIfAny(existingPath, xpaths[2]); - dataCollectorsNavigator.AppendChild(missingNodesText); + break; } + } - dataCollectorsNavigator = runSettingsNavigator.SelectSingleNode(xpaths[2]); - dataCollectorsNavigator.AppendChild(codeCoverageCollectorSettingsTemplate); - - this.runSettingsManager.UpdateRunSettings(runSettingsDocument.CreateNavigator().OuterXml); + // If any nodes are missing to add code coverage default settings, add the missing xml nodes. + XPathNavigator dataCollectorsNavigator; + if (existingPath.Equals(xpaths[2]) == false) + { + dataCollectorsNavigator = runSettingsNavigator.SelectSingleNode(existingPath); + var missingNodesText = GetMissingNodesTextIfAny(existingPath, xpaths[2]); + dataCollectorsNavigator.AppendChild(missingNodesText); } + + dataCollectorsNavigator = runSettingsNavigator.SelectSingleNode(xpaths[2]); + dataCollectorsNavigator.AppendChild(CodeCoverageCollectorSettingsTemplate); + + _runSettingsManager.UpdateRunSettings(runSettingsDocument.CreateNavigator().OuterXml); } + } + + private static string GetMissingNodesTextIfAny(string existingPath, string fullpath) + { + var xmlText = "{0}"; + var nonExistingPath = fullpath.Substring(existingPath.Length); + var requiredNodeNames = nonExistingPath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); + var format = "<{0}>{1}"; - private static string GetMissingNodesTextIfAny(string existingPath, string fullpath) + foreach (var nodeName in requiredNodeNames) { - var xmlText = "{0}"; - var nonExistingPath = fullpath.Substring(existingPath.Length); - var requiredNodeNames = nonExistingPath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); - var format = "<{0}>{1}"; + xmlText = string.Format(CultureInfo.InvariantCulture, xmlText, string.Format(CultureInfo.InvariantCulture, format, nodeName, "{0}")); + } - foreach (var nodeName in requiredNodeNames) - { - xmlText = string.Format(CultureInfo.InvariantCulture, xmlText, string.Format(CultureInfo.InvariantCulture, format, nodeName, "{0}")); - } + xmlText = string.Format(CultureInfo.InvariantCulture, xmlText, string.Empty); + return xmlText; + } - xmlText = string.Format(CultureInfo.InvariantCulture, xmlText, string.Empty); - return xmlText; + /// + /// Check data collector exist with friendly name + /// + /// XPathNavigable representation of a runsettings file + /// The data Collector friendly name. + /// True if there is a datacollector configured. + private static bool ContainsDataCollectorWithFriendlyName(IXPathNavigable runSettingDocument, string dataCollectorFriendlyName) + { + if (runSettingDocument == null) + { + throw new ArgumentNullException(nameof(runSettingDocument)); } - /// - /// Check data collector exist with friendly name - /// - /// XPathNavigable representation of a runsettings file - /// The data Collector friendly name. - /// True if there is a datacollector configured. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")] - private static bool ContainsDataCollectorWithFriendlyName(IXPathNavigable runSettingDocument, string dataCollectorFriendlyName) + if (dataCollectorFriendlyName == null) { - if (runSettingDocument == null) - { - throw new ArgumentNullException(nameof(runSettingDocument)); - } - - if (dataCollectorFriendlyName == null) - { - throw new ArgumentNullException(nameof(dataCollectorFriendlyName)); - } + throw new ArgumentNullException(nameof(dataCollectorFriendlyName)); + } - var navigator = runSettingDocument.CreateNavigator(); - var nodes = navigator.Select("/RunSettings/DataCollectionRunSettings/DataCollectors/DataCollector"); + var navigator = runSettingDocument.CreateNavigator(); + var nodes = navigator.Select("/RunSettings/DataCollectionRunSettings/DataCollectors/DataCollector"); - foreach (XPathNavigator dataCollectorNavigator in nodes) + foreach (XPathNavigator dataCollectorNavigator in nodes) + { + var fn = dataCollectorNavigator.GetAttribute("friendlyName", string.Empty); + if (string.Equals(dataCollectorFriendlyName, fn, StringComparison.OrdinalIgnoreCase)) { - var fn = dataCollectorNavigator.GetAttribute("friendlyName", string.Empty); - if (string.Equals(dataCollectorFriendlyName, fn, StringComparison.OrdinalIgnoreCase)) - { - return true; - } + return true; } - - return false; } + + return false; } -} +} \ No newline at end of file diff --git a/src/vstest.console/Processors/EnableDiagArgumentProcessor.cs b/src/vstest.console/Processors/EnableDiagArgumentProcessor.cs index 39b24dbea1..91ef57320a 100644 --- a/src/vstest.console/Processors/EnableDiagArgumentProcessor.cs +++ b/src/vstest.console/Processors/EnableDiagArgumentProcessor.cs @@ -1,252 +1,252 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; + +using Internal; +using Utilities; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +using CommandLineResources = Resources.Resources; + +internal class EnableDiagArgumentProcessor : IArgumentProcessor { - using System; - using System.Collections.Generic; - using System.Globalization; - using System.IO; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; - - internal class EnableDiagArgumentProcessor : IArgumentProcessor - { - /// - /// The name of the command line argument that the ListTestsArgumentExecutor handles. - /// - public const string CommandName = "/Diag"; + /// + /// The name of the command line argument that the ListTestsArgumentExecutor handles. + /// + public const string CommandName = "/Diag"; - private readonly IFileHelper fileHelper; + private readonly IFileHelper _fileHelper; - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - /// - /// Initializes a new instance of the class. - /// - public EnableDiagArgumentProcessor() : this(new FileHelper()) - { - } + /// + /// Initializes a new instance of the class. + /// + public EnableDiagArgumentProcessor() : this(new FileHelper()) + { + } - /// - /// Initializes a new instance of the class. - /// - /// A file helper instance. - protected EnableDiagArgumentProcessor(IFileHelper fileHelper) - { - this.fileHelper = fileHelper; - } + /// + /// Initializes a new instance of the class. + /// + /// A file helper instance. + protected EnableDiagArgumentProcessor(IFileHelper fileHelper) + { + _fileHelper = fileHelper; + } - public Lazy Metadata + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new EnableDiagArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new EnableDiagArgumentProcessorCapabilities()); } + + return _metadata; } + } - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => new EnableDiagArgumentExecutor(this.fileHelper)); - } - - return this.executor; + _executor = new Lazy(() => new EnableDiagArgumentExecutor(_fileHelper)); } - set - { - this.executor = value; - } + return _executor; + } + + set + { + _executor = value; } } +} - /// - /// The argument capabilities. - /// - internal class EnableDiagArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => EnableDiagArgumentProcessor.CommandName; +/// +/// The argument capabilities. +/// +internal class EnableDiagArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => EnableDiagArgumentProcessor.CommandName; - public override bool AllowMultiple => false; + public override bool AllowMultiple => false; - public override bool IsAction => false; + public override bool IsAction => false; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Diag; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Diag; - public override string HelpContentResourceName => CommandLineResources.EnableDiagUsage; + public override string HelpContentResourceName => CommandLineResources.EnableDiagUsage; - public override HelpContentPriority HelpPriority => HelpContentPriority.EnableDiagArgumentProcessorHelpPriority; - } + public override HelpContentPriority HelpPriority => HelpContentPriority.EnableDiagArgumentProcessorHelpPriority; +} + +/// +/// The argument executor. +/// +internal class EnableDiagArgumentExecutor : IArgumentExecutor +{ + private readonly IFileHelper _fileHelper; + + /// + /// Parameter for trace level + /// + public const string TraceLevelParam = "tracelevel"; + + #region Constructor /// - /// The argument executor. + /// Default constructor. /// - internal class EnableDiagArgumentExecutor : IArgumentExecutor + /// The file helper. + public EnableDiagArgumentExecutor(IFileHelper fileHelper) { - private readonly IFileHelper fileHelper; + _fileHelper = fileHelper; + } - /// - /// Parameter for trace level - /// - public const string TraceLevelParam = "tracelevel"; + #endregion - #region Constructor + #region IArgumentExecutor - /// - /// Default constructor. - /// - /// The file helper. - public EnableDiagArgumentExecutor(IFileHelper fileHelper) + /// + /// Initializes with the argument that was provided with the command. + /// + /// Argument that was provided with the command. + public void Initialize(string argument) + { + string exceptionMessage = string.Format(CultureInfo.CurrentUICulture, CommandLineResources.InvalidDiagArgument, argument); + + // Throw error if argument is null or empty. + if (string.IsNullOrWhiteSpace(argument)) { - this.fileHelper = fileHelper; + throw new CommandLineException(exceptionMessage); } - #endregion - - #region IArgumentExecutor + // Get diag argument list. + var diagArgumentList = ArgumentProcessorUtilities.GetArgumentList(argument, ArgumentProcessorUtilities.SemiColonArgumentSeparator, exceptionMessage); - /// - /// Initializes with the argument that was provided with the command. - /// - /// Argument that was provided with the command. - public void Initialize(string argument) - { - string exceptionMessage = string.Format(CultureInfo.CurrentUICulture, CommandLineResources.InvalidDiagArgument, argument); + // Get diag file path. + // Note: Even though semi colon is valid file path, we are not respecting the file name having semi-colon [As we are separating arguments based on semi colon]. + var diagFilePathArg = diagArgumentList[0]; + var diagFilePath = GetDiagFilePath(diagFilePathArg); - // Throw error if argument is null or empty. - if (string.IsNullOrWhiteSpace(argument)) - { - throw new CommandLineException(exceptionMessage); - } + // Get diag parameters. + var diagParameterArgs = diagArgumentList.Skip(1); + var diagParameters = ArgumentProcessorUtilities.GetArgumentParameters(diagParameterArgs, ArgumentProcessorUtilities.EqualNameValueSeparator, exceptionMessage); - // Get diag argument list. - var diagArgumentList = ArgumentProcessorUtilities.GetArgumentList(argument, ArgumentProcessorUtilities.SemiColonArgumentSeparator, exceptionMessage); + // Initialize diag logging. + InitializeDiagLogging(diagFilePath, diagParameters); - // Get diag file path. - // Note: Even though semi colon is valid file path, we are not respecting the file name having semi-colon [As we are separating arguments based on semi colon]. - var diagFilePathArg = diagArgumentList[0]; - var diagFilePath = GetDiagFilePath(diagFilePathArg); + // Write version to the log here, because that is the + // first place where we know if we log or not. + EqtTrace.Verbose($"Version: {Product.Version}"); + } - // Get diag parameters. - var diagParameterArgs = diagArgumentList.Skip(1); - var diagParameters = ArgumentProcessorUtilities.GetArgumentParameters(diagParameterArgs, ArgumentProcessorUtilities.EqualNameValueSeparator, exceptionMessage); + /// + /// Executes the argument processor. + /// + /// The . + public ArgumentProcessorResult Execute() + { + // Nothing to do since we updated the parameter during initialize parameter + return ArgumentProcessorResult.Success; + } - // Initialize diag logging. - InitializeDiagLogging(diagFilePath, diagParameters); + /// + /// Initialize diag logging. + /// + /// Diag file path. + /// Diag parameters + private void InitializeDiagLogging(string diagFilePath, Dictionary diagParameters) + { + // Get trace level from diag parameters. + var traceLevel = GetDiagTraceLevel(diagParameters); - // Write version to the log here, because that is the - // first place where we know if we log or not. - EqtTrace.Verbose($"Version: {Product.Version}"); - } + // Initialize trace. + // Trace initialized is false in case of any exception at time of initialization like Catch exception(UnauthorizedAccessException, PathTooLongException...) + var traceInitialized = EqtTrace.InitializeTrace(diagFilePath, traceLevel); - /// - /// Executes the argument processor. - /// - /// The . - public ArgumentProcessorResult Execute() + // Show console warning in case trace is not initialized. + if (!traceInitialized && !string.IsNullOrEmpty(EqtTrace.ErrorOnInitialization)) { - // Nothing to do since we updated the parameter during initialize parameter - return ArgumentProcessorResult.Success; + ConsoleOutput.Instance.Warning(false, EqtTrace.ErrorOnInitialization); } + } - /// - /// Initialize diag logging. - /// - /// Diag file path. - /// Diag parameters - private void InitializeDiagLogging(string diagFilePath, Dictionary diagParameters) + /// + /// Gets diag trace level. + /// + /// Diag parameters. + /// Diag trace level. + private PlatformTraceLevel GetDiagTraceLevel(Dictionary diagParameters) + { + // If diag parameters is null, set value of trace level as verbose. + if (diagParameters == null) { - // Get trace level from diag parameters. - var traceLevel = GetDiagTraceLevel(diagParameters); - - // Initialize trace. - // Trace initialized is false in case of any exception at time of initialization like Catch exception(UnauthorizedAccessException, PathTooLongException...) - var traceInitialized = EqtTrace.InitializeTrace(diagFilePath, traceLevel); - - // Show console warning in case trace is not initialized. - if (!traceInitialized && !string.IsNullOrEmpty(EqtTrace.ErrorOnInitialization)) - { - ConsoleOutput.Instance.Warning(false, EqtTrace.ErrorOnInitialization); - } + return PlatformTraceLevel.Verbose; } - /// - /// Gets diag trace level. - /// - /// Diag parameters. - /// Diag trace level. - private PlatformTraceLevel GetDiagTraceLevel(Dictionary diagParameters) + // Get trace level from diag parameters. + var traceLevelExists = diagParameters.TryGetValue(TraceLevelParam, out var traceLevelStr); + if (traceLevelExists && Enum.TryParse(traceLevelStr, true, out PlatformTraceLevel traceLevel)) { - // If diag parameters is null, set value of trace level as verbose. - if (diagParameters == null) - { - return PlatformTraceLevel.Verbose; - } - - // Get trace level from diag parameters. - var traceLevelExists = diagParameters.TryGetValue(TraceLevelParam, out var traceLevelStr); - if (traceLevelExists && Enum.TryParse(traceLevelStr, true, out PlatformTraceLevel traceLevel)) - { - return traceLevel; - } - - // Default value of diag trace level is verbose. - return PlatformTraceLevel.Verbose; + return traceLevel; } - /// - /// Gets diag file path. - /// - /// Diag file path argument. - /// Diag file path. - private string GetDiagFilePath(string diagFilePathArgument) - { - // Remove double quotes if present. - diagFilePathArgument = diagFilePathArgument.Replace("\"", ""); + // Default value of diag trace level is verbose. + return PlatformTraceLevel.Verbose; + } - // Create base directory for diag file path (if doesn't exist) - CreateDirectoryIfNotExists(diagFilePathArgument); + /// + /// Gets diag file path. + /// + /// Diag file path argument. + /// Diag file path. + private string GetDiagFilePath(string diagFilePathArgument) + { + // Remove double quotes if present. + diagFilePathArgument = diagFilePathArgument.Replace("\"", ""); - // return full diag file path. (This is done so that vstest and testhost create logs at same location.) - return Path.GetFullPath(diagFilePathArgument); - } + // Create base directory for diag file path (if doesn't exist) + CreateDirectoryIfNotExists(diagFilePathArgument); + + // return full diag file path. (This is done so that vstest and testhost create logs at same location.) + return Path.GetFullPath(diagFilePathArgument); + } - /// - /// Create directory if not exists. - /// - /// File path. - private void CreateDirectoryIfNotExists(string filePath) + /// + /// Create directory if not exists. + /// + /// File path. + private void CreateDirectoryIfNotExists(string filePath) + { + // Create the base directory of file path if doesn't exist. + // Directory could be empty if just a filename is provided. E.g. log.txt + var directory = Path.GetDirectoryName(filePath); + if (!string.IsNullOrEmpty(directory) && !_fileHelper.DirectoryExists(directory)) { - // Create the base directory of file path if doesn't exist. - // Directory could be empty if just a filename is provided. E.g. log.txt - var directory = Path.GetDirectoryName(filePath); - if (!string.IsNullOrEmpty(directory) && !this.fileHelper.DirectoryExists(directory)) - { - this.fileHelper.CreateDirectory(directory); - } + _fileHelper.CreateDirectory(directory); } - - #endregion } -} + + #endregion +} \ No newline at end of file diff --git a/src/vstest.console/Processors/EnableLoggerArgumentProcessor.cs b/src/vstest.console/Processors/EnableLoggerArgumentProcessor.cs index d05365dc88..cbc2842cc5 100644 --- a/src/vstest.console/Processors/EnableLoggerArgumentProcessor.cs +++ b/src/vstest.console/Processors/EnableLoggerArgumentProcessor.cs @@ -1,182 +1,182 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors -{ - using System; - using System.Diagnostics.Contracts; - using System.Globalization; - using System.Linq; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Diagnostics.Contracts; +using System.Globalization; +using System.Linq; + +using Utilities; +using Common; +using Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; +using CommandLineResources = Resources.Resources; + +/// +/// An argument processor that allows the user to enable a specific logger +/// from the command line using the --Logger|/Logger command line switch. +/// +internal class EnableLoggerArgumentProcessor : IArgumentProcessor +{ + #region Constants /// - /// An argument processor that allows the user to enable a specific logger - /// from the command line using the --Logger|/Logger command line switch. + /// The command name. /// - internal class EnableLoggerArgumentProcessor : IArgumentProcessor - { - #region Constants - - /// - /// The command name. - /// - public const string CommandName = "/Logger"; + public const string CommandName = "/Logger"; - #endregion + #endregion - #region Fields + #region Fields - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => new EnableLoggerArgumentExecutor(RunSettingsManager.Instance)); - } - - return this.executor; + _executor = new Lazy(() => new EnableLoggerArgumentExecutor(RunSettingsManager.Instance)); } - set - { - this.executor = value; - } + return _executor; } - /// - /// Gets the metadata. - /// - public Lazy Metadata + set { - get - { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new EnableLoggerArgumentProcessorCapabilities()); - } - - return this.metadata; - } + _executor = value; } - - #endregion } - internal class EnableLoggerArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities + /// + /// Gets the metadata. + /// + public Lazy Metadata { - /// - /// Gets the command name. - /// - public override string CommandName => EnableLoggerArgumentProcessor.CommandName; - - /// - /// Gets a value indicating whether allow multiple. - /// - public override bool AllowMultiple => true; - - /// - /// Gets a value indicating whether is action. - /// - public override bool IsAction => false; - - /// - /// Gets the priority. - /// - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Logging; - - /// - /// Gets the help content resource name. - /// -#if NETFRAMEWORK - public override string HelpContentResourceName => CommandLineResources.EnableLoggersArgumentHelp; -#else - public override string HelpContentResourceName => CommandLineResources.EnableLoggerArgumentsInNetCore; -#endif + get + { + if (_metadata == null) + { + _metadata = new Lazy(() => new EnableLoggerArgumentProcessorCapabilities()); + } - /// - /// Gets the help priority. - /// - public override HelpContentPriority HelpPriority => HelpContentPriority.EnableLoggerArgumentProcessorHelpPriority; + return _metadata; + } } + #endregion +} + +internal class EnableLoggerArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ /// - /// The argument executor. + /// Gets the command name. /// - internal class EnableLoggerArgumentExecutor : IArgumentExecutor - { - private readonly IRunSettingsProvider runSettingsManager; + public override string CommandName => EnableLoggerArgumentProcessor.CommandName; -#region Constructors + /// + /// Gets a value indicating whether allow multiple. + /// + public override bool AllowMultiple => true; - /// - /// Initializes a new instance of the class. - /// - public EnableLoggerArgumentExecutor(IRunSettingsProvider runSettingsManager) - { - Contract.Requires(runSettingsManager != null); - this.runSettingsManager = runSettingsManager; - } + /// + /// Gets a value indicating whether is action. + /// + public override bool IsAction => false; -#endregion + /// + /// Gets the priority. + /// + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Logging; -#region IArgumentProcessor + /// + /// Gets the help content resource name. + /// +#if NETFRAMEWORK + public override string HelpContentResourceName => CommandLineResources.EnableLoggersArgumentHelp; +#else + public override string HelpContentResourceName => CommandLineResources.EnableLoggerArgumentsInNetCore; +#endif - /// - /// Initializes with the argument that was provided with the command. - /// - /// Argument that was provided with the command. - public void Initialize(string argument) - { - string exceptionMessage = string.Format(CultureInfo.CurrentUICulture, CommandLineResources.LoggerUriInvalid, argument); + /// + /// Gets the help priority. + /// + public override HelpContentPriority HelpPriority => HelpContentPriority.EnableLoggerArgumentProcessorHelpPriority; +} - // Throw error in case logger argument null or empty. - if (string.IsNullOrWhiteSpace(argument)) - { - throw new CommandLineException(exceptionMessage); - } +/// +/// The argument executor. +/// +internal class EnableLoggerArgumentExecutor : IArgumentExecutor +{ + private readonly IRunSettingsProvider _runSettingsManager; - // Get logger argument list. - var loggerArgumentList = ArgumentProcessorUtilities.GetArgumentList(argument, ArgumentProcessorUtilities.SemiColonArgumentSeparator, exceptionMessage); + #region Constructors - // Get logger identifier. - var loggerIdentifier = loggerArgumentList[0]; - if (loggerIdentifier.Contains("=")) - { - throw new CommandLineException(exceptionMessage); - } + /// + /// Initializes a new instance of the class. + /// + public EnableLoggerArgumentExecutor(IRunSettingsProvider runSettingsManager) + { + Contract.Requires(runSettingsManager != null); + _runSettingsManager = runSettingsManager; + } + + #endregion - // Get logger parameters - var loggerParameterArgs = loggerArgumentList.Skip(1); - var loggerParameters = ArgumentProcessorUtilities.GetArgumentParameters(loggerParameterArgs, ArgumentProcessorUtilities.EqualNameValueSeparator, exceptionMessage); + #region IArgumentProcessor - // Add logger to run settings. - LoggerUtilities.AddLoggerToRunSettings(loggerIdentifier, loggerParameters, runSettingsManager); + /// + /// Initializes with the argument that was provided with the command. + /// + /// Argument that was provided with the command. + public void Initialize(string argument) + { + string exceptionMessage = string.Format(CultureInfo.CurrentUICulture, CommandLineResources.LoggerUriInvalid, argument); + + // Throw error in case logger argument null or empty. + if (string.IsNullOrWhiteSpace(argument)) + { + throw new CommandLineException(exceptionMessage); } - /// - /// Execute logger argument. - /// - /// - /// The . - /// - public ArgumentProcessorResult Execute() + // Get logger argument list. + var loggerArgumentList = ArgumentProcessorUtilities.GetArgumentList(argument, ArgumentProcessorUtilities.SemiColonArgumentSeparator, exceptionMessage); + + // Get logger identifier. + var loggerIdentifier = loggerArgumentList[0]; + if (loggerIdentifier.Contains("=")) { - // Nothing to do since we enabled the logger in the initialize method. - return ArgumentProcessorResult.Success; + throw new CommandLineException(exceptionMessage); } -#endregion + // Get logger parameters + var loggerParameterArgs = loggerArgumentList.Skip(1); + var loggerParameters = ArgumentProcessorUtilities.GetArgumentParameters(loggerParameterArgs, ArgumentProcessorUtilities.EqualNameValueSeparator, exceptionMessage); + + // Add logger to run settings. + LoggerUtilities.AddLoggerToRunSettings(loggerIdentifier, loggerParameters, _runSettingsManager); } -} + + /// + /// Execute logger argument. + /// + /// + /// The . + /// + public ArgumentProcessorResult Execute() + { + // Nothing to do since we enabled the logger in the initialize method. + return ArgumentProcessorResult.Success; + } + + #endregion +} \ No newline at end of file diff --git a/src/vstest.console/Processors/EnvironmentArgumentProcessor.cs b/src/vstest.console/Processors/EnvironmentArgumentProcessor.cs index 2ea77d84a7..4917b02763 100644 --- a/src/vstest.console/Processors/EnvironmentArgumentProcessor.cs +++ b/src/vstest.console/Processors/EnvironmentArgumentProcessor.cs @@ -1,145 +1,148 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors -{ - using System; - using System.Diagnostics.Contracts; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Diagnostics.Contracts; + +using Common; +using Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities; + +using CommandLineResources = Resources.Resources; + +/// +/// Argument Executor for the "-e|--Environment|/e|/Environment" command line argument. +/// +internal class EnvironmentArgumentProcessor : IArgumentProcessor +{ + #region Constants /// - /// Argument Executor for the "-e|--Environment|/e|/Environment" command line argument. + /// The short name of the command line argument that the EnvironmentArgumentProcessor handles. /// - internal class EnvironmentArgumentProcessor : IArgumentProcessor - { - #region Constants - /// - /// The short name of the command line argument that the EnvironmentArgumentProcessor handles. - /// - public const string ShortCommandName = "/e"; + public const string ShortCommandName = "/e"; - /// - /// The name of the command line argument that the EnvironmentArgumentProcessor handles. - /// - public const string CommandName = "/Environment"; - #endregion + /// + /// The name of the command line argument that the EnvironmentArgumentProcessor handles. + /// + public const string CommandName = "/Environment"; + #endregion - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - public Lazy Executor + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy( - () => new ArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, ConsoleOutput.Instance) - ); - } - - return this.executor; - } - set - { - this.executor = value; + _executor = new Lazy( + () => new ArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, ConsoleOutput.Instance) + ); } + + return _executor; } + set + { + _executor = value; + } + } - public Lazy Metadata + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new ArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new ArgumentProcessorCapabilities()); } + + return _metadata; } + } + + internal class ArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities + { + public override string CommandName => EnvironmentArgumentProcessor.CommandName; + public override string ShortCommandName => EnvironmentArgumentProcessor.ShortCommandName; + public override bool AllowMultiple => true; + public override bool IsAction => false; + public override string HelpContentResourceName => CommandLineResources.EnvironmentArgumentHelp; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; + public override HelpContentPriority HelpPriority => HelpContentPriority.EnvironmentArgumentProcessorHelpPriority; + } + + internal class ArgumentExecutor : IArgumentExecutor + { + #region Fields + /// + /// Used when warning about overriden environment variables. + /// + private readonly IOutput _output; + + /// + /// Used when setting Environemnt variables. + /// + private readonly IRunSettingsProvider _runSettingsProvider; - internal class ArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities + /// + /// Used when checking and forcing InIsolation mode. + /// + private readonly CommandLineOptions _commandLineOptions; + #endregion + + public ArgumentExecutor(CommandLineOptions commandLineOptions, IRunSettingsProvider runSettingsProvider, IOutput output) { - public override string CommandName => EnvironmentArgumentProcessor.CommandName; - public override string ShortCommandName => EnvironmentArgumentProcessor.ShortCommandName; - public override bool AllowMultiple => true; - public override bool IsAction => false; - public override string HelpContentResourceName => CommandLineResources.EnvironmentArgumentHelp; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; - public override HelpContentPriority HelpPriority => HelpContentPriority.EnvironmentArgumentProcessorHelpPriority; + _commandLineOptions = commandLineOptions; + _output = output; + _runSettingsProvider = runSettingsProvider; } - internal class ArgumentExecutor : IArgumentExecutor + /// + /// Set the environment variables in RunSettings.xml + /// + /// + /// Environment variable to set. + /// + public void Initialize(string argument) { - #region Fields - /// - /// Used when warning about overriden environment variables. - /// - private IOutput output; - - /// - /// Used when setting Environemnt variables. - /// - private IRunSettingsProvider runSettingsProvider; - - /// - /// Used when checking and forcing InIsolation mode. - /// - private CommandLineOptions commandLineOptions; - #endregion - - public ArgumentExecutor(CommandLineOptions commandLineOptions, IRunSettingsProvider runSettingsProvider, IOutput output) + Contract.Assert(!string.IsNullOrWhiteSpace(argument)); + Contract.Assert(_output != null); + Contract.Assert(_commandLineOptions != null); + Contract.Assert(!string.IsNullOrWhiteSpace(_runSettingsProvider.ActiveRunSettings.SettingsXml)); + Contract.EndContractBlock(); + + var key = argument; + var value = string.Empty; + + if (key.Contains("=")) { - this.commandLineOptions = commandLineOptions; - this.output = output; - this.runSettingsProvider = runSettingsProvider; + value = key.Substring(key.IndexOf("=") + 1); + key = key.Substring(0, key.IndexOf("=")); } - /// - /// Set the environment variables in RunSettings.xml - /// - /// - /// Environment variable to set. - /// - public void Initialize(string argument) + var node = _runSettingsProvider.QueryRunSettingsNode($"RunConfiguration.EnvironmentVariables.{key}"); + if (node != null) { - Contract.Assert(!string.IsNullOrWhiteSpace(argument)); - Contract.Assert(this.output != null); - Contract.Assert(this.commandLineOptions != null); - Contract.Assert(!string.IsNullOrWhiteSpace(this.runSettingsProvider.ActiveRunSettings.SettingsXml)); - Contract.EndContractBlock(); - - var key = argument; - var value = string.Empty; - - if(key.Contains("=")) - { - value = key.Substring(key.IndexOf("=") + 1); - key = key.Substring(0, key.IndexOf("=")); - } - - var node = this.runSettingsProvider.QueryRunSettingsNode($"RunConfiguration.EnvironmentVariables.{key}"); - if(node != null) - { - output.Warning(true, CommandLineResources.EnvironmentVariableXIsOverriden, key); - } - - this.runSettingsProvider.UpdateRunSettingsNode($"RunConfiguration.EnvironmentVariables.{key}", value); - - if(!this.commandLineOptions.InIsolation) { - this.commandLineOptions.InIsolation = true; - this.runSettingsProvider.UpdateRunSettingsNode(InIsolationArgumentExecutor.RunSettingsPath, "true"); - } + _output.Warning(true, CommandLineResources.EnvironmentVariableXIsOverriden, key); } - // Nothing to do here, the work was done in initialization. - public ArgumentProcessorResult Execute() => ArgumentProcessorResult.Success; + _runSettingsProvider.UpdateRunSettingsNode($"RunConfiguration.EnvironmentVariables.{key}", value); + + if (!_commandLineOptions.InIsolation) + { + _commandLineOptions.InIsolation = true; + _runSettingsProvider.UpdateRunSettingsNode(InIsolationArgumentExecutor.RunSettingsPath, "true"); + } } + + // Nothing to do here, the work was done in initialization. + public ArgumentProcessorResult Execute() => ArgumentProcessorResult.Success; } -} +} \ No newline at end of file diff --git a/src/vstest.console/Processors/FrameworkArgumentProcessor.cs b/src/vstest.console/Processors/FrameworkArgumentProcessor.cs index fcce28a2dc..17570dfa69 100644 --- a/src/vstest.console/Processors/FrameworkArgumentProcessor.cs +++ b/src/vstest.console/Processors/FrameworkArgumentProcessor.cs @@ -1,177 +1,176 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors -{ - using System; - using System.Diagnostics.Contracts; - using System.Globalization; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Diagnostics.Contracts; +using System.Globalization; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities; +using Common; +using Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; +using CommandLineResources = Resources.Resources; + +/// +/// An argument processor that allows the user to specify the target platform architecture +/// for test run. +/// +internal class FrameworkArgumentProcessor : IArgumentProcessor +{ + #region Constants /// - /// An argument processor that allows the user to specify the target platform architecture - /// for test run. + /// The name of the command line argument that the OutputArgumentExecutor handles. /// - internal class FrameworkArgumentProcessor : IArgumentProcessor - { - #region Constants - - /// - /// The name of the command line argument that the OutputArgumentExecutor handles. - /// - public const string CommandName = "/Framework"; + public const string CommandName = "/Framework"; - #endregion + #endregion - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - /// - /// Gets the metadata. - /// - public Lazy Metadata + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new FrameworkArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new FrameworkArgumentProcessorCapabilities()); } + + return _metadata; } + } - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => new FrameworkArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance)); - } - - return this.executor; + _executor = new Lazy(() => new FrameworkArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance)); } - set - { - this.executor = value; - } + return _executor; + } + + set + { + _executor = value; } } +} - internal class FrameworkArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => FrameworkArgumentProcessor.CommandName; +internal class FrameworkArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => FrameworkArgumentProcessor.CommandName; - public override bool AllowMultiple => false; + public override bool AllowMultiple => false; - public override bool IsAction => false; + public override bool IsAction => false; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; - public override string HelpContentResourceName => CommandLineResources.FrameworkArgumentHelp; + public override string HelpContentResourceName => CommandLineResources.FrameworkArgumentHelp; - public override HelpContentPriority HelpPriority => HelpContentPriority.FrameworkArgumentProcessorHelpPriority; - } + public override HelpContentPriority HelpPriority => HelpContentPriority.FrameworkArgumentProcessorHelpPriority; +} + +/// +/// Argument Executor for the "/Platform" command line argument. +/// +internal class FrameworkArgumentExecutor : IArgumentExecutor +{ + #region Fields /// - /// Argument Executor for the "/Platform" command line argument. + /// Used for getting sources. /// - internal class FrameworkArgumentExecutor : IArgumentExecutor - { - #region Fields + private readonly CommandLineOptions _commandLineOptions; - /// - /// Used for getting sources. - /// - private CommandLineOptions commandLineOptions; + private readonly IRunSettingsProvider _runSettingsManager; - private IRunSettingsProvider runSettingsManager; + public const string RunSettingsPath = "RunConfiguration.TargetFrameworkVersion"; - public const string RunSettingsPath = "RunConfiguration.TargetFrameworkVersion"; + #endregion - #endregion + #region Constructor - #region Constructor - - /// - /// Default constructor. - /// - /// The options. - /// The runsettings manager. - public FrameworkArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsManager) - { - Contract.Requires(options != null); - Contract.Requires(runSettingsManager != null); - this.commandLineOptions = options; - this.runSettingsManager = runSettingsManager; - } + /// + /// Default constructor. + /// + /// The options. + /// The runsettings manager. + public FrameworkArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsManager) + { + Contract.Requires(options != null); + Contract.Requires(runSettingsManager != null); + _commandLineOptions = options; + _runSettingsManager = runSettingsManager; + } - #endregion + #endregion - #region IArgumentExecutor + #region IArgumentExecutor - /// - /// Initializes with the argument that was provided with the command. - /// - /// Argument that was provided with the command. - public void Initialize(string argument) + /// + /// Initializes with the argument that was provided with the command. + /// + /// Argument that was provided with the command. + public void Initialize(string argument) + { + if (string.IsNullOrWhiteSpace(argument)) { - if (string.IsNullOrWhiteSpace(argument)) - { - throw new CommandLineException(CommandLineResources.FrameworkVersionRequired); - } + throw new CommandLineException(CommandLineResources.FrameworkVersionRequired); + } - var validFramework = Framework.FromString(argument); - this.commandLineOptions.TargetFrameworkVersion = validFramework ?? throw new CommandLineException( - string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidFrameworkVersion, argument)); + var validFramework = Framework.FromString(argument); + _commandLineOptions.TargetFrameworkVersion = validFramework ?? throw new CommandLineException( + string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidFrameworkVersion, argument)); - if (this.commandLineOptions.TargetFrameworkVersion != Framework.DefaultFramework - && !string.IsNullOrWhiteSpace(this.commandLineOptions.SettingsFile) - && MSTestSettingsUtilities.IsLegacyTestSettingsFile(this.commandLineOptions.SettingsFile)) - { - // Legacy testsettings file support only default target framework. - IOutput output = ConsoleOutput.Instance; - output.Warning( - false, - CommandLineResources.TestSettingsFrameworkMismatch, - this.commandLineOptions.TargetFrameworkVersion.ToString(), - Framework.DefaultFramework.ToString()); - } - else - { - this.runSettingsManager.UpdateRunSettingsNode(FrameworkArgumentExecutor.RunSettingsPath, - validFramework.ToString()); - } - - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("Using .Net Framework version:{0}", commandLineOptions.TargetFrameworkVersion); - } + if (_commandLineOptions.TargetFrameworkVersion != Framework.DefaultFramework + && !string.IsNullOrWhiteSpace(_commandLineOptions.SettingsFile) + && MSTestSettingsUtilities.IsLegacyTestSettingsFile(_commandLineOptions.SettingsFile)) + { + // Legacy testsettings file support only default target framework. + IOutput output = ConsoleOutput.Instance; + output.Warning( + false, + CommandLineResources.TestSettingsFrameworkMismatch, + _commandLineOptions.TargetFrameworkVersion.ToString(), + Framework.DefaultFramework.ToString()); + } + else + { + _runSettingsManager.UpdateRunSettingsNode(RunSettingsPath, + validFramework.ToString()); } - /// - /// The output path is already set, return success. - /// - /// The Success - public ArgumentProcessorResult Execute() + if (EqtTrace.IsInfoEnabled) { - return ArgumentProcessorResult.Success; + EqtTrace.Info("Using .Net Framework version:{0}", _commandLineOptions.TargetFrameworkVersion); } + } - #endregion + /// + /// The output path is already set, return success. + /// + /// The Success + public ArgumentProcessorResult Execute() + { + return ArgumentProcessorResult.Success; } -} + + #endregion +} \ No newline at end of file diff --git a/src/vstest.console/Processors/HelpArgumentProcessor.cs b/src/vstest.console/Processors/HelpArgumentProcessor.cs index a6d0171e02..555a399139 100644 --- a/src/vstest.console/Processors/HelpArgumentProcessor.cs +++ b/src/vstest.console/Processors/HelpArgumentProcessor.cs @@ -1,205 +1,205 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors -{ - using System; - using System.Collections.Generic; - using System.Globalization; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; +using System; +using System.Collections.Generic; +using System.Globalization; - // - // Argument Executor for the "-?|--Help|/?|/Help" Help command line argument. - // - internal class HelpArgumentProcessor : IArgumentProcessor - { - #region Constants +using Microsoft.VisualStudio.TestPlatform.Utilities; - /// - /// The name of the command line argument that the HelpArgumentExecutor handles. - /// - public const string CommandName = "/Help"; +using CommandLineResources = Resources.Resources; - /// - /// The short name of the command line argument that the HelpArgumentExecutor handles. - /// - public const string ShortCommandName = "/?"; +// +// Argument Executor for the "-?|--Help|/?|/Help" Help command line argument. +// +internal class HelpArgumentProcessor : IArgumentProcessor +{ + #region Constants + /// + /// The name of the command line argument that the HelpArgumentExecutor handles. + /// + public const string CommandName = "/Help"; - #endregion + /// + /// The short name of the command line argument that the HelpArgumentExecutor handles. + /// + public const string ShortCommandName = "/?"; - private Lazy metadata; - private Lazy executor; + #endregion - /// - /// Gets the metadata. - /// - public Lazy Metadata - { - get - { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new HelpArgumentProcessorCapabilities()); - } + private Lazy _metadata; - return this.metadata; - } - } + private Lazy _executor; - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => new HelpArgumentExecutor()); - } - - return this.executor; + _metadata = new Lazy(() => new HelpArgumentProcessorCapabilities()); } - set - { - this.executor = value; - } + return _metadata; } } /// - /// The help argument processor capabilities. + /// Gets or sets the executor. /// - internal class HelpArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities + public Lazy Executor { - public override string CommandName => HelpArgumentProcessor.CommandName; + get + { + if (_executor == null) + { + _executor = new Lazy(() => new HelpArgumentExecutor()); + } - public override string ShortCommandName => HelpArgumentProcessor.ShortCommandName; + return _executor; + } - public override string HelpContentResourceName => CommandLineResources.HelpArgumentHelp; + set + { + _executor = value; + } + } +} + +/// +/// The help argument processor capabilities. +/// +internal class HelpArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => HelpArgumentProcessor.CommandName; - public override HelpContentPriority HelpPriority => HelpContentPriority.HelpArgumentProcessorHelpPriority; + public override string ShortCommandName => HelpArgumentProcessor.ShortCommandName; - public override bool IsAction => false; + public override string HelpContentResourceName => CommandLineResources.HelpArgumentHelp; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Help; - } + public override HelpContentPriority HelpPriority => HelpContentPriority.HelpArgumentProcessorHelpPriority; + + public override bool IsAction => false; + + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Help; +} + +/// +/// Argument Executor for the "/?" Help command line argument. +/// +internal class HelpArgumentExecutor : IArgumentExecutor +{ + #region Constructor /// - /// Argument Executor for the "/?" Help command line argument. + /// Constructs the HelpArgumentExecutor /// - internal class HelpArgumentExecutor : IArgumentExecutor + public HelpArgumentExecutor() { - #region Constructor + Output = ConsoleOutput.Instance; + } - /// - /// Constructs the HelpArgumentExecutor - /// - public HelpArgumentExecutor() - { - this.Output = ConsoleOutput.Instance; - } + #endregion - #endregion + #region Properties - #region Properties + /// + /// Gets the output object + /// + internal IOutput Output { get; set; } - /// - /// Gets the output object - /// - internal IOutput Output { get; set; } + #endregion - #endregion + #region IArgumentExecutor Members - #region IArgumentExecutor Members + public void Initialize(string argument) + { + } - public void Initialize(string argument) + public ArgumentProcessorResult Execute() + { + // Output the stock output text + OutputSection(CommandLineResources.HelpUsageText); + OutputSection(CommandLineResources.HelpDescriptionText); + OutputSection(CommandLineResources.HelpArgumentsText); + + var argumentProcessorFactory = ArgumentProcessorFactory.Create(); + List processors = new(); + processors.AddRange(argumentProcessorFactory.AllArgumentProcessors); + processors.Sort((p1, p2) => Comparer.Default.Compare(p1.Metadata.Value.HelpPriority, p2.Metadata.Value.HelpPriority)); + + // Output the help description for RunTestsArgumentProcessor + IArgumentProcessor runTestsArgumentProcessor = processors.Find(p1 => p1.GetType() == typeof(RunTestsArgumentProcessor)); + processors.Remove(runTestsArgumentProcessor); + var helpDescription = LookupHelpDescription(runTestsArgumentProcessor); + if (helpDescription != null) { + OutputSection(helpDescription); } - public ArgumentProcessorResult Execute() + // Output the help description for each available argument processor + OutputSection(CommandLineResources.HelpOptionsText); + foreach (var argumentProcessor in processors) { - // Output the stock output text - OutputSection(CommandLineResources.HelpUsageText); - OutputSection(CommandLineResources.HelpDescriptionText); - OutputSection(CommandLineResources.HelpArgumentsText); - - var argumentProcessorFactory = ArgumentProcessorFactory.Create(); - List processors = new List(); - processors.AddRange(argumentProcessorFactory.AllArgumentProcessors); - processors.Sort((p1, p2) => Comparer.Default.Compare(p1.Metadata.Value.HelpPriority, p2.Metadata.Value.HelpPriority)); - - // Output the help description for RunTestsArgumentProcessor - IArgumentProcessor runTestsArgumentProcessor = processors.Find(p1 => p1.GetType() == typeof(RunTestsArgumentProcessor)); - processors.Remove(runTestsArgumentProcessor); - var helpDescription = LookupHelpDescription(runTestsArgumentProcessor); + helpDescription = LookupHelpDescription(argumentProcessor); if (helpDescription != null) { OutputSection(helpDescription); } + } + OutputSection(CommandLineResources.Examples); - // Output the help description for each available argument processor - OutputSection(CommandLineResources.HelpOptionsText); - foreach (var argumentProcessor in processors) - { - helpDescription = LookupHelpDescription(argumentProcessor); - if (helpDescription != null) - { - OutputSection(helpDescription); - } - } - OutputSection(CommandLineResources.Examples); + // When Help has finished abort any subsequent argument processor operations + return ArgumentProcessorResult.Abort; + } - // When Help has finished abort any subsequent argument processor operations - return ArgumentProcessorResult.Abort; - } + #endregion - #endregion + #region Private Methods - #region Private Methods + /// + /// Lookup the help description for the argument processor. + /// + /// The argument processor for which to discover any help content + /// The formatted string containing the help description if found null otherwise + private string LookupHelpDescription(IArgumentProcessor argumentProcessor) + { + string result = null; - /// - /// Lookup the help description for the argument processor. - /// - /// The argument processor for which to discover any help content - /// The formatted string containing the help description if found null otherwise - private string LookupHelpDescription(IArgumentProcessor argumentProcessor) + if (argumentProcessor.Metadata.Value.HelpContentResourceName != null) { - string result = null; - - if (argumentProcessor.Metadata.Value.HelpContentResourceName != null) + try { - try - { - result = string.Format( - CultureInfo.CurrentUICulture, - argumentProcessor.Metadata.Value.HelpContentResourceName); - //ResourceHelper.GetString(argumentProcessor.Metadata.HelpContentResourceName, assembly, CultureInfo.CurrentUICulture); - } - catch (Exception e) - { - Output.Warning(false, e.Message); - } + result = string.Format( + CultureInfo.CurrentUICulture, + argumentProcessor.Metadata.Value.HelpContentResourceName); + //ResourceHelper.GetString(argumentProcessor.Metadata.HelpContentResourceName, assembly, CultureInfo.CurrentUICulture); + } + catch (Exception e) + { + Output.Warning(false, e.Message); } - - return result; } - /// - /// Output a section followed by an empty line. - /// - /// Message to output. - private void OutputSection(string message) - { - Output.WriteLine(message, OutputLevel.Information); - Output.WriteLine(string.Empty, OutputLevel.Information); - } + return result; + } - #endregion + /// + /// Output a section followed by an empty line. + /// + /// Message to output. + private void OutputSection(string message) + { + Output.WriteLine(message, OutputLevel.Information); + Output.WriteLine(string.Empty, OutputLevel.Information); } -} + + #endregion +} \ No newline at end of file diff --git a/src/vstest.console/Processors/InIsolationArgumentProcessor.cs b/src/vstest.console/Processors/InIsolationArgumentProcessor.cs index ab886429cb..b8cbc5336d 100644 --- a/src/vstest.console/Processors/InIsolationArgumentProcessor.cs +++ b/src/vstest.console/Processors/InIsolationArgumentProcessor.cs @@ -1,136 +1,138 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors -{ - using System; - using System.Diagnostics.Contracts; - using System.Globalization; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - /// - /// An argument processor that allows the user to specify whether the execution - /// should happen in the current vstest.console.exe process or a new different process. - /// - internal class InIsolationArgumentProcessor : IArgumentProcessor - { - #region Constants +using System; +using System.Diagnostics.Contracts; +using System.Globalization; - public const string CommandName = "/InIsolation"; +using Common; +using Common.Interfaces; - #endregion +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; + +using CommandLineResources = Resources.Resources; + +/// +/// An argument processor that allows the user to specify whether the execution +/// should happen in the current vstest.console.exe process or a new different process. +/// +internal class InIsolationArgumentProcessor : IArgumentProcessor +{ + #region Constants - private Lazy metadata; + public const string CommandName = "/InIsolation"; - private Lazy executor; + #endregion - /// - /// Gets the metadata. - /// - public Lazy Metadata + private Lazy _metadata; + + private Lazy _executor; + + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new InIsolationArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new InIsolationArgumentProcessorCapabilities()); } + + return _metadata; } + } - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = - new Lazy( - () => + _executor = + new Lazy( + () => new InIsolationArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance)); - } - - return this.executor; } - set - { - this.executor = value; - } + return _executor; + } + + set + { + _executor = value; } } +} - internal class InIsolationArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => InIsolationArgumentProcessor.CommandName; +internal class InIsolationArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => InIsolationArgumentProcessor.CommandName; - public override bool AllowMultiple => false; + public override bool AllowMultiple => false; - public override bool IsAction => false; + public override bool IsAction => false; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; - public override string HelpContentResourceName => CommandLineResources.InIsolationHelp; + public override string HelpContentResourceName => CommandLineResources.InIsolationHelp; - public override HelpContentPriority HelpPriority => HelpContentPriority.InIsolationArgumentProcessorHelpPriority; - } + public override HelpContentPriority HelpPriority => HelpContentPriority.InIsolationArgumentProcessorHelpPriority; +} - internal class InIsolationArgumentExecutor : IArgumentExecutor - { - private CommandLineOptions commandLineOptions; - private IRunSettingsProvider runSettingsManager; - - public const string RunSettingsPath = "RunConfiguration.InIsolation"; - - #region Constructors - /// - /// Constructor - /// - /// Command line options - /// the runsettings manager - public InIsolationArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsManager) - { - Contract.Requires(options != null); - this.commandLineOptions = options; - this.runSettingsManager = runSettingsManager; - } - #endregion +internal class InIsolationArgumentExecutor : IArgumentExecutor +{ + private readonly CommandLineOptions _commandLineOptions; + private readonly IRunSettingsProvider _runSettingsManager; - #region IArgumentProcessor + public const string RunSettingsPath = "RunConfiguration.InIsolation"; - /// - /// Initializes with the argument that was provided with the command. - /// - /// Argument that was provided with the command. - public void Initialize(string argument) - { - // InIsolation does not require any argument, throws exception if argument specified - if (!string.IsNullOrWhiteSpace(argument)) - { - throw new CommandLineException( - string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidInIsolationCommand, argument)); - } + #region Constructors + /// + /// Constructor + /// + /// Command line options + /// the runsettings manager + public InIsolationArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsManager) + { + Contract.Requires(options != null); + _commandLineOptions = options; + _runSettingsManager = runSettingsManager; + } + #endregion - this.commandLineOptions.InIsolation = true; - this.runSettingsManager.UpdateRunSettingsNode(InIsolationArgumentExecutor.RunSettingsPath, "true"); - } + #region IArgumentProcessor - /// - /// Execute. - /// - public ArgumentProcessorResult Execute() + /// + /// Initializes with the argument that was provided with the command. + /// + /// Argument that was provided with the command. + public void Initialize(string argument) + { + // InIsolation does not require any argument, throws exception if argument specified + if (!string.IsNullOrWhiteSpace(argument)) { - // Nothing to do since we updated the parameter during initialize parameter - return ArgumentProcessorResult.Success; + throw new CommandLineException( + string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidInIsolationCommand, argument)); } - #endregion + _commandLineOptions.InIsolation = true; + _runSettingsManager.UpdateRunSettingsNode(RunSettingsPath, "true"); } -} + + /// + /// Execute. + /// + public ArgumentProcessorResult Execute() + { + // Nothing to do since we updated the parameter during initialize parameter + return ArgumentProcessorResult.Success; + } + + #endregion +} \ No newline at end of file diff --git a/src/vstest.console/Processors/Interfaces/IArgumentExector.cs b/src/vstest.console/Processors/Interfaces/IArgumentExector.cs index 8e0881336b..157e345a30 100644 --- a/src/vstest.console/Processors/Interfaces/IArgumentExector.cs +++ b/src/vstest.console/Processors/Interfaces/IArgumentExector.cs @@ -1,26 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +/// +/// Defines interface for interacting with a command line argument executor. +/// Items exporting this interface will be used in processing command line arguments. +/// +internal interface IArgumentExecutor { /// - /// Defines interface for interacting with a command line argument executor. - /// Items exporting this interface will be used in processing command line arguments. + /// Initializes the Argument Processor with the argument that was provided with the command. /// - internal interface IArgumentExecutor - { - /// - /// Initializes the Argument Processor with the argument that was provided with the command. - /// - /// Argument that was provided with the command. - void Initialize(string argument); + /// Argument that was provided with the command. + void Initialize(string argument); - /// - /// Perform the action associated with the argument processor. - /// - /// - /// The . - /// - ArgumentProcessorResult Execute(); - } -} + /// + /// Perform the action associated with the argument processor. + /// + /// + /// The . + /// + ArgumentProcessorResult Execute(); +} \ No newline at end of file diff --git a/src/vstest.console/Processors/Interfaces/IArgumentProcessor.cs b/src/vstest.console/Processors/Interfaces/IArgumentProcessor.cs index 0b4099c620..e3932e851c 100644 --- a/src/vstest.console/Processors/Interfaces/IArgumentProcessor.cs +++ b/src/vstest.console/Processors/Interfaces/IArgumentProcessor.cs @@ -1,24 +1,23 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +/// +/// Defines interface for interacting with a command line argument processor. +/// Items exporting this interface will be used in processing command line arguments. +/// +internal interface IArgumentProcessor +{ /// - /// Defines interface for interacting with a command line argument processor. - /// Items exporting this interface will be used in processing command line arguments. + /// Gets or sets the executor. /// - internal interface IArgumentProcessor - { - /// - /// Gets or sets the executor. - /// - Lazy Executor { get; set; } + Lazy Executor { get; set; } - /// - /// Gets the metadata. - /// - Lazy Metadata { get; } - } -} + /// + /// Gets the metadata. + /// + Lazy Metadata { get; } +} \ No newline at end of file diff --git a/src/vstest.console/Processors/Interfaces/IArgumentProcessorCapabilities.cs b/src/vstest.console/Processors/Interfaces/IArgumentProcessorCapabilities.cs index 69a61f27f9..6db5253fe8 100644 --- a/src/vstest.console/Processors/Interfaces/IArgumentProcessorCapabilities.cs +++ b/src/vstest.console/Processors/Interfaces/IArgumentProcessorCapabilities.cs @@ -1,58 +1,57 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +/// +/// Represents capabilities for an Argument Executor +/// +internal interface IArgumentProcessorCapabilities { /// - /// Represents capabilities for an Argument Executor - /// - internal interface IArgumentProcessorCapabilities - { - /// - /// The short name of the command the ArgumentProcessor handles. For example "/t". - /// - string ShortCommandName { get; } - - /// - /// The long name of the command the ArgumentProcessor handles. For example "/tests". - /// - string CommandName { get; } - - /// - /// Indicates if multiple of the command are allowed. - /// - bool AllowMultiple { get; } - - /// - /// Indicates if the command is a special command. Special commands can not - /// be specified directly on the command line (like run tests). - /// - bool IsSpecialCommand { get; } - - /// - /// Indicates if the command should always be executed. - /// - bool AlwaysExecute { get; } - - /// - /// Indicates if the argument processor is a primary action. - /// - bool IsAction { get; } - - /// - /// Indicates the priority of the argument processor. - /// The priority determines the order in which processors are initialized and executed. - /// - ArgumentProcessorPriority Priority { get; } - - /// - /// The resource identifier for the Help Content associated with the decorated argument processor - /// - string HelpContentResourceName { get; } - - /// - /// Based on this enum, corresponding help text will be shown. - /// - HelpContentPriority HelpPriority { get; } - } -} + /// The short name of the command the ArgumentProcessor handles. For example "/t". + /// + string ShortCommandName { get; } + + /// + /// The long name of the command the ArgumentProcessor handles. For example "/tests". + /// + string CommandName { get; } + + /// + /// Indicates if multiple of the command are allowed. + /// + bool AllowMultiple { get; } + + /// + /// Indicates if the command is a special command. Special commands can not + /// be specified directly on the command line (like run tests). + /// + bool IsSpecialCommand { get; } + + /// + /// Indicates if the command should always be executed. + /// + bool AlwaysExecute { get; } + + /// + /// Indicates if the argument processor is a primary action. + /// + bool IsAction { get; } + + /// + /// Indicates the priority of the argument processor. + /// The priority determines the order in which processors are initialized and executed. + /// + ArgumentProcessorPriority Priority { get; } + + /// + /// The resource identifier for the Help Content associated with the decorated argument processor + /// + string HelpContentResourceName { get; } + + /// + /// Based on this enum, corresponding help text will be shown. + /// + HelpContentPriority HelpPriority { get; } +} \ No newline at end of file diff --git a/src/vstest.console/Processors/Interfaces/IArgumentsExecutor.cs b/src/vstest.console/Processors/Interfaces/IArgumentsExecutor.cs index 2c1e968eab..a0ac2833d7 100644 --- a/src/vstest.console/Processors/Interfaces/IArgumentsExecutor.cs +++ b/src/vstest.console/Processors/Interfaces/IArgumentsExecutor.cs @@ -1,18 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +/// +/// Defines interface for interacting with a command line arguments executor. +/// Items exporting this interface will be used in processing command line arguments. +/// +internal interface IArgumentsExecutor : IArgumentExecutor { /// - /// Defines interface for interacting with a command line arguments executor. - /// Items exporting this interface will be used in processing command line arguments. + /// Initializes the Argument Processor with the arguments that was provided with the command. /// - internal interface IArgumentsExecutor : IArgumentExecutor - { - /// - /// Initializes the Argument Processor with the arguments that was provided with the command. - /// - /// Arguments that are provided with the command. - void Initialize(string[] arguments); - } -} + /// Arguments that are provided with the command. + void Initialize(string[] arguments); +} \ No newline at end of file diff --git a/src/vstest.console/Processors/ListExtensionsArgumentProcessor.cs b/src/vstest.console/Processors/ListExtensionsArgumentProcessor.cs index b3f775722d..9a1633690b 100644 --- a/src/vstest.console/Processors/ListExtensionsArgumentProcessor.cs +++ b/src/vstest.console/Processors/ListExtensionsArgumentProcessor.cs @@ -1,235 +1,235 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors -{ - using System; - using System.Globalization; - - using Microsoft.VisualStudio.TestPlatform.Client; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.SettingsProvider; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - internal class ListExtensionsArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - private string commandName; +using System; +using System.Globalization; - /// - /// Initializes a new instance of the class. - /// - /// Name of the command - public ListExtensionsArgumentProcessorCapabilities(string commandName) - { - this.commandName = commandName; - } +using Client; +using Common.ExtensionFramework; +using Common.SettingsProvider; +using ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.Utilities; - public override string CommandName => this.commandName; +using CommandLineResources = Resources.Resources; - /// - public override bool AllowMultiple => false; +internal class ListExtensionsArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + private readonly string _commandName; - /// - public override bool IsAction => true; + /// + /// Initializes a new instance of the class. + /// + /// Name of the command + public ListExtensionsArgumentProcessorCapabilities(string commandName) + { + _commandName = commandName; } - internal abstract class ListExtensionsArgumentProcessor : IArgumentProcessor - { - private Lazy metadata; - private Lazy executor; - private Func getExecutor; - private Func getCapabilities; + public override string CommandName => _commandName; - public ListExtensionsArgumentProcessor(Func getExecutor, Func getCapabilities) - { - this.getExecutor = getExecutor; - this.getCapabilities = getCapabilities; - } + /// + public override bool AllowMultiple => false; - public Lazy Executor - { - get - { - if (this.executor == null) - { - this.executor = new Lazy(getExecutor); - } + /// + public override bool IsAction => true; +} - return this.executor; - } +internal abstract class ListExtensionsArgumentProcessor : IArgumentProcessor +{ + private Lazy _metadata; + private Lazy _executor; + private readonly Func _getExecutor; + private readonly Func _getCapabilities; - set - { - this.executor = value; - } - } + public ListExtensionsArgumentProcessor(Func getExecutor, Func getCapabilities) + { + _getExecutor = getExecutor; + _getCapabilities = getCapabilities; + } - public Lazy Metadata + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(getCapabilities); - } - - return this.metadata; + _executor = new Lazy(_getExecutor); } - } - } - #region List discoverers - /// - /// Argument Executor for the "/ListDiscoverers" command line argument. - /// - internal class ListDiscoverersArgumentProcessor : ListExtensionsArgumentProcessor - { - private const string CommandName = "/ListDiscoverers"; + return _executor; + } - public ListDiscoverersArgumentProcessor() - : base(() => new ListDiscoverersArgumentExecutor(), () => new ListExtensionsArgumentProcessorCapabilities(CommandName)) + set { + _executor = value; } } - internal class ListDiscoverersArgumentExecutor : IArgumentExecutor + public Lazy Metadata { - public void Initialize(string argument) + get { - } - - public ArgumentProcessorResult Execute() - { - ConsoleOutput.Instance.WriteLine(CommandLineResources.AvailableDiscoverersHeaderMessage, OutputLevel.Information); - var testPlatform = TestPlatformFactory.GetTestPlatform(); - var extensionManager = TestDiscoveryExtensionManager.Create(); - foreach (var extension in extensionManager.Discoverers) + if (_metadata == null) { - ConsoleOutput.Instance.WriteLine(extension.Value.GetType().FullName, OutputLevel.Information); - ConsoleOutput.Instance.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.UriOfDefaultExecutor, extension.Metadata.DefaultExecutorUri), OutputLevel.Information); - ConsoleOutput.Instance.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.SupportedFileTypesIndicator + " " + string.Join(", ", extension.Metadata.FileExtension)), OutputLevel.Information); + _metadata = new Lazy(_getCapabilities); } - return ArgumentProcessorResult.Success; + return _metadata; } } - #endregion +} - #region List executors - /// - /// Argument Executor for the "/ListExecutors" command line argument. - /// - internal class ListExecutorsArgumentProcessor : ListExtensionsArgumentProcessor +#region List discoverers +/// +/// Argument Executor for the "/ListDiscoverers" command line argument. +/// +internal class ListDiscoverersArgumentProcessor : ListExtensionsArgumentProcessor +{ + private const string CommandName = "/ListDiscoverers"; + + public ListDiscoverersArgumentProcessor() + : base(() => new ListDiscoverersArgumentExecutor(), () => new ListExtensionsArgumentProcessorCapabilities(CommandName)) { - private const string CommandName = "/ListExecutors"; + } +} - public ListExecutorsArgumentProcessor() - : base(() => new ListExecutorsArgumentExecutor(), () => new ListExtensionsArgumentProcessorCapabilities(CommandName)) - { - } +internal class ListDiscoverersArgumentExecutor : IArgumentExecutor +{ + public void Initialize(string argument) + { } - internal class ListExecutorsArgumentExecutor : IArgumentExecutor + public ArgumentProcessorResult Execute() { - public void Initialize(string argument) + ConsoleOutput.Instance.WriteLine(CommandLineResources.AvailableDiscoverersHeaderMessage, OutputLevel.Information); + _ = TestPlatformFactory.GetTestPlatform(); + var extensionManager = TestDiscoveryExtensionManager.Create(); + foreach (var extension in extensionManager.Discoverers) { + ConsoleOutput.Instance.WriteLine(extension.Value.GetType().FullName, OutputLevel.Information); + ConsoleOutput.Instance.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.UriOfDefaultExecutor, extension.Metadata.DefaultExecutorUri), OutputLevel.Information); + ConsoleOutput.Instance.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.SupportedFileTypesIndicator + " " + string.Join(", ", extension.Metadata.FileExtension)), OutputLevel.Information); } - public ArgumentProcessorResult Execute() - { - ConsoleOutput.Instance.WriteLine(CommandLineResources.AvailableExecutorsHeaderMessage, OutputLevel.Information); - var testPlatform = TestPlatformFactory.GetTestPlatform(); - var extensionManager = TestExecutorExtensionManager.Create(); - foreach (var extension in extensionManager.TestExtensions) - { - ConsoleOutput.Instance.WriteLine(extension.Value.GetType().FullName, OutputLevel.Information); - ConsoleOutput.Instance.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.AvailableExtensionsMetadataFormat, "Uri", extension.Metadata.ExtensionUri), OutputLevel.Information); - } - - return ArgumentProcessorResult.Success; - } + return ArgumentProcessorResult.Success; } - #endregion +} +#endregion - #region List loggers - /// - /// Argument Executor for the "/ListLoggers" command line argument. - /// - internal class ListLoggersArgumentProcessor : ListExtensionsArgumentProcessor +#region List executors +/// +/// Argument Executor for the "/ListExecutors" command line argument. +/// +internal class ListExecutorsArgumentProcessor : ListExtensionsArgumentProcessor +{ + private const string CommandName = "/ListExecutors"; + + public ListExecutorsArgumentProcessor() + : base(() => new ListExecutorsArgumentExecutor(), () => new ListExtensionsArgumentProcessorCapabilities(CommandName)) { - private const string CommandName = "/ListLoggers"; + } +} - public ListLoggersArgumentProcessor() - : base(() => new ListLoggersArgumentExecutor(), () => new ListExtensionsArgumentProcessorCapabilities(CommandName)) - { - } +internal class ListExecutorsArgumentExecutor : IArgumentExecutor +{ + public void Initialize(string argument) + { } - internal class ListLoggersArgumentExecutor : IArgumentExecutor + public ArgumentProcessorResult Execute() { - public void Initialize(string argument) + ConsoleOutput.Instance.WriteLine(CommandLineResources.AvailableExecutorsHeaderMessage, OutputLevel.Information); + _ = TestPlatformFactory.GetTestPlatform(); + var extensionManager = TestExecutorExtensionManager.Create(); + foreach (var extension in extensionManager.TestExtensions) { + ConsoleOutput.Instance.WriteLine(extension.Value.GetType().FullName, OutputLevel.Information); + ConsoleOutput.Instance.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.AvailableExtensionsMetadataFormat, "Uri", extension.Metadata.ExtensionUri), OutputLevel.Information); } - public ArgumentProcessorResult Execute() - { - ConsoleOutput.Instance.WriteLine(CommandLineResources.AvailableLoggersHeaderMessage, OutputLevel.Information); - var testPlatform = TestPlatformFactory.GetTestPlatform(); - var extensionManager = TestLoggerExtensionManager.Create(new NullMessageLogger()); - foreach (var extension in extensionManager.TestExtensions) - { - ConsoleOutput.Instance.WriteLine(extension.Value.GetType().FullName, OutputLevel.Information); - ConsoleOutput.Instance.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.AvailableExtensionsMetadataFormat, "Uri", extension.Metadata.ExtensionUri), OutputLevel.Information); - ConsoleOutput.Instance.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.AvailableExtensionsMetadataFormat, "FriendlyName", string.Join(", ", extension.Metadata.FriendlyName)), OutputLevel.Information); - } + return ArgumentProcessorResult.Success; + } +} +#endregion - return ArgumentProcessorResult.Success; - } +#region List loggers +/// +/// Argument Executor for the "/ListLoggers" command line argument. +/// +internal class ListLoggersArgumentProcessor : ListExtensionsArgumentProcessor +{ + private const string CommandName = "/ListLoggers"; - private class NullMessageLogger : IMessageLogger - { - public void SendMessage(TestMessageLevel testMessageLevel, string message) - { - } - } + public ListLoggersArgumentProcessor() + : base(() => new ListLoggersArgumentExecutor(), () => new ListExtensionsArgumentProcessorCapabilities(CommandName)) + { } - #endregion +} - #region List settings providers - /// - /// Argument Executor for the "/ListSettingsProviders" command line argument. - /// - internal class ListSettingsProvidersArgumentProcessor : ListExtensionsArgumentProcessor +internal class ListLoggersArgumentExecutor : IArgumentExecutor +{ + public void Initialize(string argument) { - private const string CommandName = "/ListSettingsProviders"; + } - public ListSettingsProvidersArgumentProcessor() - : base(() => new ListSettingsProvidersArgumentExecutor(), () => new ListExtensionsArgumentProcessorCapabilities(CommandName)) + public ArgumentProcessorResult Execute() + { + ConsoleOutput.Instance.WriteLine(CommandLineResources.AvailableLoggersHeaderMessage, OutputLevel.Information); + _ = TestPlatformFactory.GetTestPlatform(); + var extensionManager = TestLoggerExtensionManager.Create(new NullMessageLogger()); + foreach (var extension in extensionManager.TestExtensions) { + ConsoleOutput.Instance.WriteLine(extension.Value.GetType().FullName, OutputLevel.Information); + ConsoleOutput.Instance.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.AvailableExtensionsMetadataFormat, "Uri", extension.Metadata.ExtensionUri), OutputLevel.Information); + ConsoleOutput.Instance.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.AvailableExtensionsMetadataFormat, "FriendlyName", string.Join(", ", extension.Metadata.FriendlyName)), OutputLevel.Information); } + + return ArgumentProcessorResult.Success; } - internal class ListSettingsProvidersArgumentExecutor : IArgumentExecutor + private class NullMessageLogger : IMessageLogger { - public void Initialize(string argument) + public void SendMessage(TestMessageLevel testMessageLevel, string message) { } + } +} +#endregion - public ArgumentProcessorResult Execute() - { - ConsoleOutput.Instance.WriteLine(CommandLineResources.AvailableSettingsProvidersHeaderMessage, OutputLevel.Information); - var testPlatform = TestPlatformFactory.GetTestPlatform(); - var extensionManager = SettingsProviderExtensionManager.Create(); - foreach (var extension in extensionManager.SettingsProvidersMap.Values) - { - ConsoleOutput.Instance.WriteLine(extension.Value.GetType().FullName, OutputLevel.Information); - ConsoleOutput.Instance.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.AvailableExtensionsMetadataFormat, "SettingName", extension.Metadata.SettingsName), OutputLevel.Information); - } +#region List settings providers +/// +/// Argument Executor for the "/ListSettingsProviders" command line argument. +/// +internal class ListSettingsProvidersArgumentProcessor : ListExtensionsArgumentProcessor +{ + private const string CommandName = "/ListSettingsProviders"; + + public ListSettingsProvidersArgumentProcessor() + : base(() => new ListSettingsProvidersArgumentExecutor(), () => new ListExtensionsArgumentProcessorCapabilities(CommandName)) + { + } +} + +internal class ListSettingsProvidersArgumentExecutor : IArgumentExecutor +{ + public void Initialize(string argument) + { + } - return ArgumentProcessorResult.Success; + public ArgumentProcessorResult Execute() + { + ConsoleOutput.Instance.WriteLine(CommandLineResources.AvailableSettingsProvidersHeaderMessage, OutputLevel.Information); + _ = TestPlatformFactory.GetTestPlatform(); + var extensionManager = SettingsProviderExtensionManager.Create(); + foreach (var extension in extensionManager.SettingsProvidersMap.Values) + { + ConsoleOutput.Instance.WriteLine(extension.Value.GetType().FullName, OutputLevel.Information); + ConsoleOutput.Instance.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.AvailableExtensionsMetadataFormat, "SettingName", extension.Metadata.SettingsName), OutputLevel.Information); } + + return ArgumentProcessorResult.Success; } - #endregion } +#endregion \ No newline at end of file diff --git a/src/vstest.console/Processors/ListFullyQualifiedTestsArgumentProcessor.cs b/src/vstest.console/Processors/ListFullyQualifiedTestsArgumentProcessor.cs index 273adce9cb..1b4a94ed23 100644 --- a/src/vstest.console/Processors/ListFullyQualifiedTestsArgumentProcessor.cs +++ b/src/vstest.console/Processors/ListFullyQualifiedTestsArgumentProcessor.cs @@ -1,471 +1,467 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Collections.Generic; +using System.Diagnostics.Contracts; +using System.Globalization; +using System.IO; +using System.Linq; + +using Client.RequestHelper; +using Internal; +using TestPlatformHelpers; +using Common; +using Common.Filtering; +using Common.Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.Utilities; + +using CommandLineResources = Resources.Resources; + +/// +/// Argument Executor for the "--ListFullyQualifiedTests|/ListFullyQualifiedTests" command line argument. +/// +internal class ListFullyQualifiedTestsArgumentProcessor : IArgumentProcessor { - using System; - using System.Collections.Generic; - using System.Diagnostics.Contracts; - using System.Globalization; - using System.IO; - using System.Linq; - - using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; - using Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Filtering; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; + #region Constants /// - /// Argument Executor for the "--ListFullyQualifiedTests|/ListFullyQualifiedTests" command line argument. + /// The name of the command line argument that the ListFullyQualifiedTestsArgumentProcessor handles. /// - internal class ListFullyQualifiedTestsArgumentProcessor : IArgumentProcessor - { - #region Constants - - /// - /// The name of the command line argument that the ListFullyQualifiedTestsArgumentProcessor handles. - /// - public const string CommandName = "/ListFullyQualifiedTests"; + public const string CommandName = "/ListFullyQualifiedTests"; - #endregion + #endregion - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - /// - /// Gets the metadata. - /// - public Lazy Metadata + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new ListFullyQualifiedTestsArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new ListFullyQualifiedTestsArgumentProcessorCapabilities()); } + + return _metadata; } + } - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = - new Lazy( - () => + _executor = + new Lazy( + () => new ListFullyQualifiedTestsArgumentExecutor( CommandLineOptions.Instance, RunSettingsManager.Instance, TestRequestManager.Instance)); - } - - return this.executor; } - set - { - this.executor = value; - } + return _executor; + } + + set + { + _executor = value; } } +} - internal class ListFullyQualifiedTestsArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => ListFullyQualifiedTestsArgumentProcessor.CommandName; +internal class ListFullyQualifiedTestsArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => ListFullyQualifiedTestsArgumentProcessor.CommandName; - public override bool AllowMultiple => false; + public override bool AllowMultiple => false; - public override bool IsAction => true; + public override bool IsAction => true; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; - } + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; +} + +/// +/// Argument Executor for the "/ListTests" command line argument. +/// +internal class ListFullyQualifiedTestsArgumentExecutor : IArgumentExecutor +{ + #region Fields /// - /// Argument Executor for the "/ListTests" command line argument. + /// Used for getting sources. /// - internal class ListFullyQualifiedTestsArgumentExecutor : IArgumentExecutor - { - #region Fields + private readonly CommandLineOptions _commandLineOptions; - /// - /// Used for getting sources. - /// - private CommandLineOptions commandLineOptions; + /// + /// Used for getting tests. + /// + private readonly ITestRequestManager _testRequestManager; - /// - /// Used for getting tests. - /// - private ITestRequestManager testRequestManager; + /// + /// Used for sending output. + /// + internal IOutput Output; - /// - /// Used for sending output. - /// - internal IOutput output; + /// + /// RunSettingsManager to get currently active run settings. + /// + private readonly IRunSettingsProvider _runSettingsManager; - /// - /// RunSettingsManager to get currently active run settings. - /// - private IRunSettingsProvider runSettingsManager; + /// + /// Registers for discovery events during discovery + /// + private readonly ITestDiscoveryEventsRegistrar _discoveryEventsRegistrar; - /// - /// Registers for discovery events during discovery - /// - private ITestDiscoveryEventsRegistrar discoveryEventsRegistrar; + /// + /// Test case filter instance + /// + private readonly TestCaseFilter _testCasefilter; - /// - /// Test case filter instance - /// - private TestCaseFilter testCasefilter; + /// + /// List to store the discovered tests + /// + private readonly List _discoveredTests = new(); - /// - /// List to store the discovered tests - /// - private List discoveredTests = new List(); + #endregion - #endregion + #region Constructor - #region Constructor + /// + /// Default constructor. + /// + /// + /// The options. + /// + public ListFullyQualifiedTestsArgumentExecutor( + CommandLineOptions options, + IRunSettingsProvider runSettingsProvider, + ITestRequestManager testRequestManager) : + this(options, runSettingsProvider, testRequestManager, ConsoleOutput.Instance) + { + } - /// - /// Default constructor. - /// - /// - /// The options. - /// - public ListFullyQualifiedTestsArgumentExecutor( - CommandLineOptions options, - IRunSettingsProvider runSettingsProvider, - ITestRequestManager testRequestManager) : - this(options, runSettingsProvider, testRequestManager, ConsoleOutput.Instance) + /// + /// Default constructor. + /// + /// + /// The options. + /// + internal ListFullyQualifiedTestsArgumentExecutor( + CommandLineOptions options, + IRunSettingsProvider runSettingsProvider, + ITestRequestManager testRequestManager, + IOutput output) + { + Contract.Requires(options != null); + + _commandLineOptions = options; + Output = output; + _testRequestManager = testRequestManager; + + _runSettingsManager = runSettingsProvider; + _testCasefilter = new TestCaseFilter(); + _discoveryEventsRegistrar = new DiscoveryEventsRegistrar(output, _testCasefilter, _discoveredTests, _commandLineOptions); + } + + #endregion + + #region IArgumentExecutor + + /// + /// Initializes with the argument that was provided with the command. + /// + /// Argument that was provided with the command. + public void Initialize(string argument) + { + if (!string.IsNullOrWhiteSpace(argument)) { + _commandLineOptions.AddSource(argument); } + } - /// - /// Default constructor. - /// - /// - /// The options. - /// - internal ListFullyQualifiedTestsArgumentExecutor( - CommandLineOptions options, - IRunSettingsProvider runSettingsProvider, - ITestRequestManager testRequestManager, - IOutput output) + /// + /// Lists out the available discoverers. + /// + public ArgumentProcessorResult Execute() + { + Contract.Assert(Output != null); + Contract.Assert(_commandLineOptions != null); + Contract.Assert(!string.IsNullOrWhiteSpace(_runSettingsManager?.ActiveRunSettings?.SettingsXml)); + + if (!_commandLineOptions.Sources.Any()) + { + throw new CommandLineException(string.Format(CultureInfo.CurrentUICulture, CommandLineResources.MissingTestSourceFile)); + } + + if (!string.IsNullOrEmpty(EqtTrace.LogFile)) { - Contract.Requires(options != null); + Output.Information(false, CommandLineResources.VstestDiagLogOutputPath, EqtTrace.LogFile); + } - this.commandLineOptions = options; - this.output = output; - this.testRequestManager = testRequestManager; + var runSettings = _runSettingsManager.ActiveRunSettings.SettingsXml; - this.runSettingsManager = runSettingsProvider; - this.testCasefilter = new TestCaseFilter(); - this.discoveryEventsRegistrar = new DiscoveryEventsRegistrar(output, this.testCasefilter, discoveredTests, this.commandLineOptions); + _testRequestManager.DiscoverTests( + new DiscoveryRequestPayload { Sources = _commandLineOptions.Sources, RunSettings = runSettings }, + _discoveryEventsRegistrar, Constants.DefaultProtocolConfig); + + if (string.IsNullOrEmpty(_commandLineOptions.ListTestsTargetPath)) + { + // This string does not need to go to Resources. Reason - only internal consumption + throw new CommandLineException("Target Path should be specified for listing FQDN tests!"); } - #endregion + File.WriteAllLines(_commandLineOptions.ListTestsTargetPath, _discoveredTests); + return ArgumentProcessorResult.Success; + } - #region IArgumentExecutor + #endregion - /// - /// Initializes with the argument that was provided with the command. - /// - /// Argument that was provided with the command. - public void Initialize(string argument) + private class DiscoveryEventsRegistrar : ITestDiscoveryEventsRegistrar + { + private readonly IOutput _output; + private readonly TestCaseFilter _testCasefilter; + private readonly List _discoveredTests; + private readonly CommandLineOptions _options; + + public DiscoveryEventsRegistrar(IOutput output, TestCaseFilter filter, List discoveredTests, CommandLineOptions cmdOptions) { - if (!string.IsNullOrWhiteSpace(argument)) - { - this.commandLineOptions.AddSource(argument); - } + _output = output; + _testCasefilter = filter; + _discoveredTests = discoveredTests; + _options = cmdOptions; } - /// - /// Lists out the available discoverers. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")] - public ArgumentProcessorResult Execute() + public void LogWarning(string message) { - Contract.Assert(this.output != null); - Contract.Assert(this.commandLineOptions != null); - Contract.Assert(!string.IsNullOrWhiteSpace(this.runSettingsManager?.ActiveRunSettings?.SettingsXml)); + ConsoleLogger.RaiseTestRunWarning(message); + } + public void RegisterDiscoveryEvents(IDiscoveryRequest discoveryRequest) + { + discoveryRequest.OnDiscoveredTests += DiscoveryRequest_OnDiscoveredTests; + } - if (!this.commandLineOptions.Sources.Any()) - { - throw new CommandLineException(string.Format(CultureInfo.CurrentUICulture, CommandLineResources.MissingTestSourceFile)); - } + public void UnregisterDiscoveryEvents(IDiscoveryRequest discoveryRequest) + { + discoveryRequest.OnDiscoveredTests -= DiscoveryRequest_OnDiscoveredTests; + } - if (!string.IsNullOrEmpty(EqtTrace.LogFile)) + private void DiscoveryRequest_OnDiscoveredTests(Object sender, DiscoveredTestsEventArgs args) + { + if (args == null) { - this.output.Information(false, CommandLineResources.VstestDiagLogOutputPath, EqtTrace.LogFile); + throw new TestPlatformException("DiscoveredTestsEventArgs cannot be null."); } - var runSettings = this.runSettingsManager.ActiveRunSettings.SettingsXml; + // Initializing the test case filter here because the filter value is read late. + _testCasefilter.Initialize(_options.TestCaseFilterValue); + var discoveredTests = args.DiscoveredTestCases.ToList(); + var filteredTests = _testCasefilter.FilterTests(discoveredTests).ToList(); + + // remove any duplicate tests + filteredTests = filteredTests.Select(test => test.FullyQualifiedName) + .Distinct() + .Select(fqdn => filteredTests.First(test => test.FullyQualifiedName == fqdn)) + .ToList(); + _discoveredTests.AddRange(filteredTests.Select(test => test.FullyQualifiedName)); + } + } - this.testRequestManager.DiscoverTests( - new DiscoveryRequestPayload { Sources = this.commandLineOptions.Sources, RunSettings = runSettings }, - this.discoveryEventsRegistrar, Constants.DefaultProtocolConfig); + private class TestCaseFilter + { + private static TestCaseFilterExpression s_filterExpression; + private const string TestCategory = "TestCategory"; + private const string Category = "Category"; + private const string Traits = "Traits"; - if (string.IsNullOrEmpty(this.commandLineOptions.ListTestsTargetPath)) - { - // This string does not need to go to Resources. Reason - only internal consumption - throw new CommandLineException("Target Path should be specified for listing FQDN tests!"); - } + public TestCaseFilter() + { - File.WriteAllLines(this.commandLineOptions.ListTestsTargetPath, this.discoveredTests); - return ArgumentProcessorResult.Success; } - #endregion + public void Initialize(string filterString) + { + ValidateFilter(filterString); + } - private class DiscoveryEventsRegistrar : ITestDiscoveryEventsRegistrar + /// + /// Filter tests + /// + public IEnumerable FilterTests(IEnumerable testCases) { - private IOutput output; - private TestCaseFilter testCasefilter; - private List discoveredTests; - private CommandLineOptions options; + EqtTrace.Verbose("TestCaseFilter.FilterTests : Test Filtering invoked."); - public DiscoveryEventsRegistrar(IOutput output, TestCaseFilter filter, List discoveredTests, CommandLineOptions cmdOptions) - { - this.output = output; - this.testCasefilter = filter; - this.discoveredTests = discoveredTests; - this.options = cmdOptions; - } + List filteredList; - public void LogWarning(string message) - { - ConsoleLogger.RaiseTestRunWarning(message); - } - public void RegisterDiscoveryEvents(IDiscoveryRequest discoveryRequest) + try { - discoveryRequest.OnDiscoveredTests += this.DiscoveryRequest_OnDiscoveredTests; + filteredList = GetFilteredTestCases(testCases); } - - public void UnregisterDiscoveryEvents(IDiscoveryRequest discoveryRequest) + catch (Exception ex) { - discoveryRequest.OnDiscoveredTests -= this.DiscoveryRequest_OnDiscoveredTests; + EqtTrace.Error("TestCaseFilter.FilterTests : Exception during filtering : {0}", ex.ToString()); + throw; } - private void DiscoveryRequest_OnDiscoveredTests(Object sender, DiscoveredTestsEventArgs args) - { - if (args == null) - { - throw new TestPlatformException("DiscoveredTestsEventArgs cannot be null."); - } - - // Initializing the test case filter here because the filter value is read late. - this.testCasefilter.Initialize(this.options.TestCaseFilterValue); - var discoveredTests = args.DiscoveredTestCases.ToList(); - var filteredTests = this.testCasefilter.FilterTests(discoveredTests).ToList(); - - // remove any duplicate tests - filteredTests = filteredTests.Select(test => test.FullyQualifiedName) - .Distinct() - .Select(fqdn => filteredTests.First(test => test.FullyQualifiedName == fqdn)) - .ToList(); - this.discoveredTests.AddRange(filteredTests.Select(test => test.FullyQualifiedName)); - } + return filteredList; } - private class TestCaseFilter + private static void ValidateFilter(string filterString) { - private static TestCaseFilterExpression filterExpression; - private const string TestCategory = "TestCategory"; - private const string Category = "Category"; - private const string Traits = "Traits"; - - public TestCaseFilter() + if (string.IsNullOrEmpty(filterString)) { - + s_filterExpression = null; + return; } - public void Initialize(string filterString) + var filterWrapper = new FilterExpressionWrapper(filterString); + + if (filterWrapper.ParseError != null) { - ValidateFilter(filterString); + var fe = new FormatException(String.Format("Invalid Test Case Filter: {0}", filterString)); + EqtTrace.Error("TestCaseFilter.ValidateFilter : Filtering failed with exception : " + fe.Message); + throw fe; } - /// - /// Filter tests - /// - public IEnumerable FilterTests(IEnumerable testCases) - { - EqtTrace.Verbose("TestCaseFilter.FilterTests : Test Filtering invoked."); + s_filterExpression = new TestCaseFilterExpression(filterWrapper); - List filteredList; + } - try - { - filteredList = GetFilteredTestCases(testCases); - } - catch (Exception ex) - { - EqtTrace.Error("TestCaseFilter.FilterTests : Exception during filtering : {0}", ex.ToString()); - throw; - } + /// + /// get list of test cases that satisfy the filter criteria + /// + private static List GetFilteredTestCases(IEnumerable testCases) + { + var filteredList = new List(); + if (s_filterExpression == null) + { + filteredList = testCases.ToList(); return filteredList; } - private static void ValidateFilter(string filterString) + foreach (var testCase in testCases) { - if (string.IsNullOrEmpty(filterString)) - { - filterExpression = null; - return; - } - - var filterWrapper = new FilterExpressionWrapper(filterString); + var traitDictionary = GetTestPropertiesInTraitDictionary(testCase);// Dictionary with trait key to value mapping + traitDictionary = GetTraitsInTraitDictionary(traitDictionary, testCase.Traits); - if (filterWrapper.ParseError != null) + // Skip test if not fitting filter criteria. + if (!s_filterExpression.MatchTestCase(testCase, p => PropertyValueProvider(p, traitDictionary))) { - var fe = new FormatException(String.Format("Invalid Test Case Filter: {0}", filterString)); - EqtTrace.Error("TestCaseFilter.ValidateFilter : Filtering failed with exception : " + fe.Message); - throw fe; + continue; } - filterExpression = new TestCaseFilterExpression(filterWrapper); - + filteredList.Add(testCase); } - /// - /// get list of test cases that satisfy the filter criteria - /// - private static List GetFilteredTestCases(IEnumerable testCases) + return filteredList; + } + + /// + /// fetch the test properties on this test method as traits and populate a trait dictionary + /// + private static Dictionary> GetTestPropertiesInTraitDictionary(TestCase testCase) + { + var traitDictionary = new Dictionary>(); + foreach (var testProperty in testCase.Properties) { - var filteredList = new List(); + string testPropertyKey = testProperty.Label; - if (filterExpression == null) + if (testPropertyKey.Equals(Traits)) { - filteredList = testCases.ToList(); - return filteredList; + // skip the "Traits" property. traits to be set separately + continue; } - foreach (var testCase in testCases) - { - var traitDictionary = GetTestPropertiesInTraitDictionary(testCase);// Dictionary with trait key to value mapping - traitDictionary = GetTraitsInTraitDictionary(traitDictionary, testCase.Traits); + var testPropertyValue = testCase.GetPropertyValue(testProperty); - // Skip test if not fitting filter criteria. - if (!filterExpression.MatchTestCase(testCase, p => PropertyValueProvider(p, traitDictionary))) + if (testPropertyKey.Equals(TestCategory)) + { + if (testPropertyValue is string[] testPropertyValueArray) { + var testPropertyValueList = new List(testPropertyValueArray); + traitDictionary.Add(testPropertyKey, testPropertyValueList); continue; } - - filteredList.Add(testCase); } - return filteredList; - } - - /// - /// fetch the test properties on this test method as traits and populate a trait dictionary - /// - private static Dictionary> GetTestPropertiesInTraitDictionary(TestCase testCase) - { - var traitDictionary = new Dictionary>(); - foreach (var testProperty in testCase.Properties) + //always return value as a list of string + if (testPropertyValue != null) { - string testPropertyKey = testProperty.Label; - - if (testPropertyKey.Equals(Traits)) - { - // skip the "Traits" property. traits to be set separately - continue; - } - - var testPropertyValue = testCase.GetPropertyValue(testProperty); - - if (testPropertyKey.Equals(TestCategory)) - { - var testPropertyValueArray = testPropertyValue as string[]; - if (testPropertyValueArray != null) - { - var testPropertyValueList = new List(testPropertyValueArray); - traitDictionary.Add(testPropertyKey, testPropertyValueList); - continue; - } - } - - //always return value as a list of string - if (testPropertyValue != null) - { - var multiValue = new List { testPropertyValue.ToString() }; - traitDictionary.Add(testPropertyKey, multiValue); - } + var multiValue = new List { testPropertyValue.ToString() }; + traitDictionary.Add(testPropertyKey, multiValue); } - - return traitDictionary; } - /// - /// fetch the traits on this test method and populate a trait dictionary - /// - private static Dictionary> GetTraitsInTraitDictionary(Dictionary> traitDictionary, TraitCollection traits) + return traitDictionary; + } + + /// + /// fetch the traits on this test method and populate a trait dictionary + /// + private static Dictionary> GetTraitsInTraitDictionary(Dictionary> traitDictionary, TraitCollection traits) + { + foreach (var trait in traits) { - foreach (var trait in traits) + var newTraitValueList = new List { trait.Value }; + if (!traitDictionary.TryGetValue(trait.Name, out List currentTraitValue)) + { + // if the current trait's key is not already present, add the current trait key-value pair + traitDictionary.Add(trait.Name, newTraitValueList); + } + else { - var newTraitValueList = new List { trait.Value }; - List currentTraitValue; - if (!traitDictionary.TryGetValue(trait.Name, out currentTraitValue)) + if (null == currentTraitValue) { - // if the current trait's key is not already present, add the current trait key-value pair - traitDictionary.Add(trait.Name, newTraitValueList); + // if the current trait's value is null, replace the previous value with the current value + traitDictionary[trait.Name] = newTraitValueList; } else { - if (null == currentTraitValue) - { - // if the current trait's value is null, replace the previous value with the current value - traitDictionary[trait.Name] = newTraitValueList; - } - else - { - // if the current trait's key is already present and is not null, append current value to the previous value list - List traitValueList = currentTraitValue; - traitValueList.Add(trait.Value); - } + // if the current trait's key is already present and is not null, append current value to the previous value list + List traitValueList = currentTraitValue; + traitValueList.Add(trait.Value); } } + } - //This is hack for NUnit, XUnit to understand test category -> This method is called only for NUnit/XUnit - if (!traitDictionary.ContainsKey(TestCategory) && traitDictionary.ContainsKey(Category)) - { - traitDictionary.TryGetValue(Category, out var categoryValue); - traitDictionary.Add(TestCategory, categoryValue); - } - - return traitDictionary; + //This is hack for NUnit, XUnit to understand test category -> This method is called only for NUnit/XUnit + if (!traitDictionary.ContainsKey(TestCategory) && traitDictionary.ContainsKey(Category)) + { + traitDictionary.TryGetValue(Category, out var categoryValue); + traitDictionary.Add(TestCategory, categoryValue); } - /// - /// Provides value for property name 'propertyName' as used in filter. - /// - private static string[] PropertyValueProvider(string propertyName, Dictionary> traitDictionary) + return traitDictionary; + } + + /// + /// Provides value for property name 'propertyName' as used in filter. + /// + private static string[] PropertyValueProvider(string propertyName, Dictionary> traitDictionary) + { + traitDictionary.TryGetValue(propertyName, out List propertyValueList); + if (propertyValueList != null) { - List propertyValueList; - traitDictionary.TryGetValue(propertyName, out propertyValueList); - if (propertyValueList != null) - { - var propertyValueArray = propertyValueList.ToArray(); + var propertyValueArray = propertyValueList.ToArray(); - return propertyValueArray; - } - return null; + return propertyValueArray; } + return null; } } -} +} \ No newline at end of file diff --git a/src/vstest.console/Processors/ListTestsArgumentProcessor.cs b/src/vstest.console/Processors/ListTestsArgumentProcessor.cs index b247c56b5c..f75db8e1db 100644 --- a/src/vstest.console/Processors/ListTestsArgumentProcessor.cs +++ b/src/vstest.console/Processors/ListTestsArgumentProcessor.cs @@ -1,262 +1,260 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Diagnostics.Contracts; +using System.Globalization; +using System.Linq; + +using Client.RequestHelper; +using Internal; +using TestPlatformHelpers; +using Common; +using Common.Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.Utilities; + +using CommandLineResources = Resources.Resources; + +/// +/// Argument Executor for the "-lt|--ListTests|/lt|/ListTests" command line argument. +/// +internal class ListTestsArgumentProcessor : IArgumentProcessor { - using System; - using System.Diagnostics.Contracts; - using System.Globalization; - using System.Linq; - - using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; - using Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.Utilities; - - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; + #region Constants /// - /// Argument Executor for the "-lt|--ListTests|/lt|/ListTests" command line argument. + /// The short name of the command line argument that the ListTestsArgumentExecutor handles. /// - internal class ListTestsArgumentProcessor : IArgumentProcessor - { - #region Constants - - /// - /// The short name of the command line argument that the ListTestsArgumentExecutor handles. - /// - public const string ShortCommandName = "/lt"; + public const string ShortCommandName = "/lt"; - /// - /// The name of the command line argument that the ListTestsArgumentExecutor handles. - /// - public const string CommandName = "/ListTests"; + /// + /// The name of the command line argument that the ListTestsArgumentExecutor handles. + /// + public const string CommandName = "/ListTests"; - #endregion + #endregion - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - /// - /// Gets the metadata. - /// - public Lazy Metadata + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new ListTestsArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new ListTestsArgumentProcessorCapabilities()); } + + return _metadata; } + } - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = - new Lazy( - () => + _executor = + new Lazy( + () => new ListTestsArgumentExecutor( CommandLineOptions.Instance, RunSettingsManager.Instance, TestRequestManager.Instance)); - } - - return this.executor; } - set - { - this.executor = value; - } + return _executor; + } + + set + { + _executor = value; } } +} - internal class ListTestsArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => ListTestsArgumentProcessor.CommandName; +internal class ListTestsArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => ListTestsArgumentProcessor.CommandName; - public override string ShortCommandName => ListTestsArgumentProcessor.ShortCommandName; + public override string ShortCommandName => ListTestsArgumentProcessor.ShortCommandName; - public override bool AllowMultiple => false; + public override bool AllowMultiple => false; - public override bool IsAction => true; + public override bool IsAction => true; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; - public override string HelpContentResourceName => CommandLineResources.ListTestsHelp; + public override string HelpContentResourceName => CommandLineResources.ListTestsHelp; - public override HelpContentPriority HelpPriority => HelpContentPriority.ListTestsArgumentProcessorHelpPriority; - } + public override HelpContentPriority HelpPriority => HelpContentPriority.ListTestsArgumentProcessorHelpPriority; +} + +/// +/// Argument Executor for the "/ListTests" command line argument. +/// +internal class ListTestsArgumentExecutor : IArgumentExecutor +{ + #region Fields + + /// + /// Used for getting sources. + /// + private readonly CommandLineOptions _commandLineOptions; + + /// + /// Used for getting tests. + /// + private readonly ITestRequestManager _testRequestManager; + + /// + /// Used for sending output. + /// + internal IOutput Output; /// - /// Argument Executor for the "/ListTests" command line argument. + /// RunSettingsManager to get currently active run settings. /// - internal class ListTestsArgumentExecutor : IArgumentExecutor + private readonly IRunSettingsProvider _runSettingsManager; + + /// + /// Registers for discovery events during discovery + /// + private readonly ITestDiscoveryEventsRegistrar _discoveryEventsRegistrar; + + #endregion + + #region Constructor + + /// + /// Default constructor. + /// + /// + /// The options. + /// + public ListTestsArgumentExecutor( + CommandLineOptions options, + IRunSettingsProvider runSettingsProvider, + ITestRequestManager testRequestManager) : + this(options, runSettingsProvider, testRequestManager, ConsoleOutput.Instance) { - #region Fields - - /// - /// Used for getting sources. - /// - private CommandLineOptions commandLineOptions; - - /// - /// Used for getting tests. - /// - private ITestRequestManager testRequestManager; - - /// - /// Used for sending output. - /// - internal IOutput output; - - /// - /// RunSettingsManager to get currently active run settings. - /// - private IRunSettingsProvider runSettingsManager; - - /// - /// Registers for discovery events during discovery - /// - private ITestDiscoveryEventsRegistrar discoveryEventsRegistrar; - - #endregion - - #region Constructor - - /// - /// Default constructor. - /// - /// - /// The options. - /// - public ListTestsArgumentExecutor( - CommandLineOptions options, - IRunSettingsProvider runSettingsProvider, - ITestRequestManager testRequestManager) : - this(options, runSettingsProvider, testRequestManager, ConsoleOutput.Instance) - { - } + } - /// - /// Default constructor. - /// - /// - /// The options. - /// - internal ListTestsArgumentExecutor( - CommandLineOptions options, - IRunSettingsProvider runSettingsProvider, - ITestRequestManager testRequestManager, - IOutput output) - { - Contract.Requires(options != null); + /// + /// Default constructor. + /// + /// + /// The options. + /// + internal ListTestsArgumentExecutor( + CommandLineOptions options, + IRunSettingsProvider runSettingsProvider, + ITestRequestManager testRequestManager, + IOutput output) + { + Contract.Requires(options != null); - this.commandLineOptions = options; - this.output = output; - this.testRequestManager = testRequestManager; + _commandLineOptions = options; + Output = output; + _testRequestManager = testRequestManager; - this.runSettingsManager = runSettingsProvider; - this.discoveryEventsRegistrar = new DiscoveryEventsRegistrar(output); - } + _runSettingsManager = runSettingsProvider; + _discoveryEventsRegistrar = new DiscoveryEventsRegistrar(output); + } - #endregion + #endregion - #region IArgumentExecutor + #region IArgumentExecutor - /// - /// Initializes with the argument that was provided with the command. - /// - /// Argument that was provided with the command. - public void Initialize(string argument) + /// + /// Initializes with the argument that was provided with the command. + /// + /// Argument that was provided with the command. + public void Initialize(string argument) + { + if (!string.IsNullOrWhiteSpace(argument)) { - if (!string.IsNullOrWhiteSpace(argument)) - { - this.commandLineOptions.AddSource(argument); - } + _commandLineOptions.AddSource(argument); } + } + + /// + /// Lists out the available discoverers. + /// + public ArgumentProcessorResult Execute() + { + Contract.Assert(Output != null); + Contract.Assert(_commandLineOptions != null); + Contract.Assert(!string.IsNullOrWhiteSpace(_runSettingsManager?.ActiveRunSettings?.SettingsXml)); - /// - /// Lists out the available discoverers. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")] - public ArgumentProcessorResult Execute() + if (!_commandLineOptions.Sources.Any()) { - Contract.Assert(this.output != null); - Contract.Assert(this.commandLineOptions != null); - Contract.Assert(!string.IsNullOrWhiteSpace(this.runSettingsManager?.ActiveRunSettings?.SettingsXml)); + throw new CommandLineException(string.Format(CultureInfo.CurrentUICulture, CommandLineResources.MissingTestSourceFile)); + } - if (!this.commandLineOptions.Sources.Any()) - { - throw new CommandLineException(string.Format(CultureInfo.CurrentUICulture, CommandLineResources.MissingTestSourceFile)); - } + Output.WriteLine(CommandLineResources.ListTestsHeaderMessage, OutputLevel.Information); + if (!string.IsNullOrEmpty(EqtTrace.LogFile)) + { + Output.Information(false, CommandLineResources.VstestDiagLogOutputPath, EqtTrace.LogFile); + } - this.output.WriteLine(CommandLineResources.ListTestsHeaderMessage, OutputLevel.Information); - if (!string.IsNullOrEmpty(EqtTrace.LogFile)) - { - this.output.Information(false, CommandLineResources.VstestDiagLogOutputPath, EqtTrace.LogFile); - } + var runSettings = _runSettingsManager.ActiveRunSettings.SettingsXml; - var runSettings = this.runSettingsManager.ActiveRunSettings.SettingsXml; + _testRequestManager.DiscoverTests( + new DiscoveryRequestPayload() { Sources = _commandLineOptions.Sources, RunSettings = runSettings }, + _discoveryEventsRegistrar, Constants.DefaultProtocolConfig); - this.testRequestManager.DiscoverTests( - new DiscoveryRequestPayload() { Sources = this.commandLineOptions.Sources, RunSettings = runSettings }, - this.discoveryEventsRegistrar, Constants.DefaultProtocolConfig); + return ArgumentProcessorResult.Success; + } - return ArgumentProcessorResult.Success; - } + #endregion - #endregion + private class DiscoveryEventsRegistrar : ITestDiscoveryEventsRegistrar + { + private readonly IOutput _output; - private class DiscoveryEventsRegistrar : ITestDiscoveryEventsRegistrar + public DiscoveryEventsRegistrar(IOutput output) { - private IOutput output; - - public DiscoveryEventsRegistrar(IOutput output) - { - this.output = output; - } + _output = output; + } - public void LogWarning(string message) - { - ConsoleLogger.RaiseTestRunWarning(message); - } + public void LogWarning(string message) + { + ConsoleLogger.RaiseTestRunWarning(message); + } - public void RegisterDiscoveryEvents(IDiscoveryRequest discoveryRequest) - { - discoveryRequest.OnDiscoveredTests += this.DiscoveryRequest_OnDiscoveredTests; - } + public void RegisterDiscoveryEvents(IDiscoveryRequest discoveryRequest) + { + discoveryRequest.OnDiscoveredTests += DiscoveryRequest_OnDiscoveredTests; + } - public void UnregisterDiscoveryEvents(IDiscoveryRequest discoveryRequest) - { - discoveryRequest.OnDiscoveredTests -= this.DiscoveryRequest_OnDiscoveredTests; - } + public void UnregisterDiscoveryEvents(IDiscoveryRequest discoveryRequest) + { + discoveryRequest.OnDiscoveredTests -= DiscoveryRequest_OnDiscoveredTests; + } - private void DiscoveryRequest_OnDiscoveredTests(Object sender, DiscoveredTestsEventArgs args) + private void DiscoveryRequest_OnDiscoveredTests(Object sender, DiscoveredTestsEventArgs args) + { + // List out each of the tests. + foreach (var test in args.DiscoveredTestCases) { - // List out each of the tests. - foreach (var test in args.DiscoveredTestCases) - { - this.output.WriteLine(String.Format(CultureInfo.CurrentUICulture, - CommandLineResources.AvailableTestsFormat, - test.DisplayName), - OutputLevel.Information); - } + _output.WriteLine(String.Format(CultureInfo.CurrentUICulture, + CommandLineResources.AvailableTestsFormat, + test.DisplayName), + OutputLevel.Information); } } } diff --git a/src/vstest.console/Processors/ListTestsTargetPathArgumentProcessor.cs b/src/vstest.console/Processors/ListTestsTargetPathArgumentProcessor.cs index 95e5d71f72..cf5fd6f832 100644 --- a/src/vstest.console/Processors/ListTestsTargetPathArgumentProcessor.cs +++ b/src/vstest.console/Processors/ListTestsTargetPathArgumentProcessor.cs @@ -1,129 +1,127 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors -{ - using System; - using System.Diagnostics.Contracts; - using System.Globalization; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - /// - // An argument processor to provide path to the file for listing fully qualified tests. - /// To be used only with ListFullyQualifiedTests - /// - internal class ListTestsTargetPathArgumentProcessor : IArgumentProcessor - { - #region Constants +using System; +using System.Diagnostics.Contracts; +using System.Globalization; + +/// +// An argument processor to provide path to the file for listing fully qualified tests. +/// To be used only with ListFullyQualifiedTests +/// +internal class ListTestsTargetPathArgumentProcessor : IArgumentProcessor +{ + #region Constants - public const string CommandName = "/ListTestsTargetPath"; + public const string CommandName = "/ListTestsTargetPath"; - #endregion + #endregion - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - /// - /// Gets the metadata. - /// - public Lazy Metadata + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new ListTestsTargetPathArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new ListTestsTargetPathArgumentProcessorCapabilities()); } + + return _metadata; } + } - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => new ListTestsTargetPathArgumentExecutor(CommandLineOptions.Instance)); - } - - return this.executor; + _executor = new Lazy(() => new ListTestsTargetPathArgumentExecutor(CommandLineOptions.Instance)); } - set - { - this.executor = value; - } + return _executor; + } + + set + { + _executor = value; } } +} - internal class ListTestsTargetPathArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => ListTestsTargetPathArgumentProcessor.CommandName; +internal class ListTestsTargetPathArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => ListTestsTargetPathArgumentProcessor.CommandName; - public override bool AllowMultiple => false; + public override bool AllowMultiple => false; - public override bool IsAction => false; + public override bool IsAction => false; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; - } + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; +} - internal class ListTestsTargetPathArgumentExecutor : IArgumentExecutor - { - #region Fields +internal class ListTestsTargetPathArgumentExecutor : IArgumentExecutor +{ + #region Fields - /// - /// Used for getting sources. - /// - private CommandLineOptions commandLineOptions; + /// + /// Used for getting sources. + /// + private readonly CommandLineOptions _commandLineOptions; - #endregion + #endregion - #region Constructor + #region Constructor - /// - /// Default constructor. - /// - /// - /// The options. - /// - public ListTestsTargetPathArgumentExecutor(CommandLineOptions options) - { - Contract.Requires(options != null); - this.commandLineOptions = options; - } - #endregion + /// + /// Default constructor. + /// + /// + /// The options. + /// + public ListTestsTargetPathArgumentExecutor(CommandLineOptions options) + { + Contract.Requires(options != null); + _commandLineOptions = options; + } + #endregion - #region IArgumentExecutor + #region IArgumentExecutor - /// - /// Initializes with the argument that was provided with the command. - /// - /// Argument that was provided with the command. - public void Initialize(string argument) + /// + /// Initializes with the argument that was provided with the command. + /// + /// Argument that was provided with the command. + public void Initialize(string argument) + { + if (string.IsNullOrWhiteSpace(argument)) { - if (string.IsNullOrWhiteSpace(argument)) - { - // Not adding this string to resources because this processor is only used internally. - throw new CommandLineException(string.Format(CultureInfo.CurrentUICulture, "ListTestsTargetPath is required with ListFullyQualifiedTests!")); - } - - this.commandLineOptions.ListTestsTargetPath = argument; + // Not adding this string to resources because this processor is only used internally. + throw new CommandLineException(string.Format(CultureInfo.CurrentUICulture, "ListTestsTargetPath is required with ListFullyQualifiedTests!")); } - /// - /// The ListTestsTargetPath is already set, return success. - /// - /// The Success - public ArgumentProcessorResult Execute() - { - return ArgumentProcessorResult.Success; - } - #endregion + _commandLineOptions.ListTestsTargetPath = argument; + } + + /// + /// The ListTestsTargetPath is already set, return success. + /// + /// The Success + public ArgumentProcessorResult Execute() + { + return ArgumentProcessorResult.Success; } + #endregion } \ No newline at end of file diff --git a/src/vstest.console/Processors/ParallelArgumentProcessor.cs b/src/vstest.console/Processors/ParallelArgumentProcessor.cs index 149b65d313..d0fd9d1e3f 100644 --- a/src/vstest.console/Processors/ParallelArgumentProcessor.cs +++ b/src/vstest.console/Processors/ParallelArgumentProcessor.cs @@ -1,150 +1,150 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors -{ - using System; - using System.Diagnostics.Contracts; - using System.Globalization; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using System; +using System.Diagnostics.Contracts; +using System.Globalization; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; +using Common; +using Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - /// - /// Parallel Option Argument processor that allows the user to specify if tests are to be run in parallel. - /// - internal class ParallelArgumentProcessor : IArgumentProcessor - { - #region Constants +using CommandLineResources = Resources.Resources; + + +/// +/// Parallel Option Argument processor that allows the user to specify if tests are to be run in parallel. +/// +internal class ParallelArgumentProcessor : IArgumentProcessor +{ + #region Constants - public const string CommandName = "/Parallel"; + public const string CommandName = "/Parallel"; - #endregion + #endregion - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - /// - /// Gets the metadata. - /// - public Lazy Metadata + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new ParallelArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new ParallelArgumentProcessorCapabilities()); } + + return _metadata; } + } - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => new ParallelArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance)); - } - - return this.executor; + _executor = new Lazy(() => new ParallelArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance)); } - set - { - this.executor = value; - } + return _executor; + } + + set + { + _executor = value; } } +} - internal class ParallelArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => ParallelArgumentProcessor.CommandName; +internal class ParallelArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => ParallelArgumentProcessor.CommandName; - public override bool AllowMultiple => false; + public override bool AllowMultiple => false; - public override bool IsAction => false; + public override bool IsAction => false; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; - public override string HelpContentResourceName => CommandLineResources.ParallelArgumentProcessorHelp; + public override string HelpContentResourceName => CommandLineResources.ParallelArgumentProcessorHelp; - public override HelpContentPriority HelpPriority => HelpContentPriority.ParallelArgumentProcessorHelpPriority; - } + public override HelpContentPriority HelpPriority => HelpContentPriority.ParallelArgumentProcessorHelpPriority; +} + +/// +/// Argument Executor for the "/Parallel" command line argument. +/// +internal class ParallelArgumentExecutor : IArgumentExecutor +{ + #region Fields /// - /// Argument Executor for the "/Parallel" command line argument. + /// Used for getting sources. /// - internal class ParallelArgumentExecutor : IArgumentExecutor - { - #region Fields + private readonly CommandLineOptions _commandLineOptions; - /// - /// Used for getting sources. - /// - private CommandLineOptions commandLineOptions; + private readonly IRunSettingsProvider _runSettingsManager; - private IRunSettingsProvider runSettingsManager; + public const string RunSettingsPath = "RunConfiguration.MaxCpuCount"; - public const string RunSettingsPath = "RunConfiguration.MaxCpuCount"; + #endregion - #endregion + #region Constructor - #region Constructor - - /// - /// Default constructor. - /// - /// The options. - /// The runsettings manager. - public ParallelArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsManager) - { - Contract.Requires(options != null); - Contract.Requires(runSettingsManager != null); - this.commandLineOptions = options; - this.runSettingsManager = runSettingsManager; - } + /// + /// Default constructor. + /// + /// The options. + /// The runsettings manager. + public ParallelArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsManager) + { + Contract.Requires(options != null); + Contract.Requires(runSettingsManager != null); + _commandLineOptions = options; + _runSettingsManager = runSettingsManager; + } - #endregion + #endregion - #region IArgumentExecutor + #region IArgumentExecutor - /// - /// Initializes with the argument that was provided with the command. - /// - /// Argument that was provided with the command. - public void Initialize(string argument) + /// + /// Initializes with the argument that was provided with the command. + /// + /// Argument that was provided with the command. + public void Initialize(string argument) + { + // parallel does not require any argument, throws exception if argument specified + if (!string.IsNullOrWhiteSpace(argument)) { - // parallel does not require any argument, throws exception if argument specified - if (!string.IsNullOrWhiteSpace(argument)) - { - throw new CommandLineException( - string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidParallelCommand, argument)); - } - - commandLineOptions.Parallel = true; - this.runSettingsManager.UpdateRunSettingsNode(RunSettingsPath, "0"); + throw new CommandLineException( + string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidParallelCommand, argument)); } - /// - /// The output path is already set, return success. - /// - /// The Success - public ArgumentProcessorResult Execute() - { - return ArgumentProcessorResult.Success; - } + _commandLineOptions.Parallel = true; + _runSettingsManager.UpdateRunSettingsNode(RunSettingsPath, "0"); + } - #endregion + /// + /// The output path is already set, return success. + /// + /// The Success + public ArgumentProcessorResult Execute() + { + return ArgumentProcessorResult.Success; } -} + + #endregion +} \ No newline at end of file diff --git a/src/vstest.console/Processors/ParentProcessIdArgumentProcessor.cs b/src/vstest.console/Processors/ParentProcessIdArgumentProcessor.cs index f782207dc8..ad89ccf9a8 100644 --- a/src/vstest.console/Processors/ParentProcessIdArgumentProcessor.cs +++ b/src/vstest.console/Processors/ParentProcessIdArgumentProcessor.cs @@ -1,138 +1,136 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors -{ - using System; - using System.Diagnostics.Contracts; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Diagnostics.Contracts; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; +using CommandLineResources = Resources.Resources; + +/// +/// Argument Processor for the "--ParentProcessId|/ParentProcessId" command line argument. +/// +internal class ParentProcessIdArgumentProcessor : IArgumentProcessor +{ + #region Constants /// - /// Argument Processor for the "--ParentProcessId|/ParentProcessId" command line argument. + /// The name of the command line argument that the ParentProcessIdArgumentExecutor handles. /// - internal class ParentProcessIdArgumentProcessor : IArgumentProcessor - { - #region Constants - - /// - /// The name of the command line argument that the ParentProcessIdArgumentExecutor handles. - /// - public const string CommandName = "/ParentProcessId"; + public const string CommandName = "/ParentProcessId"; - #endregion + #endregion - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - /// - /// Gets the metadata. - /// - public Lazy Metadata + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new ParentProcessIdArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new ParentProcessIdArgumentProcessorCapabilities()); } + + return _metadata; } + } - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => + _executor = new Lazy(() => new ParentProcessIdArgumentExecutor(CommandLineOptions.Instance)); - } - - return this.executor; } - set - { - this.executor = value; - } + return _executor; + } + + set + { + _executor = value; } } +} - internal class ParentProcessIdArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => ParentProcessIdArgumentProcessor.CommandName; +internal class ParentProcessIdArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => ParentProcessIdArgumentProcessor.CommandName; - public override bool AllowMultiple => false; + public override bool AllowMultiple => false; - public override bool IsAction => false; + public override bool IsAction => false; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.DesignMode; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.DesignMode; - public override string HelpContentResourceName => CommandLineResources.ParentProcessIdArgumentHelp; + public override string HelpContentResourceName => CommandLineResources.ParentProcessIdArgumentHelp; - public override HelpContentPriority HelpPriority => HelpContentPriority.ParentProcessIdArgumentProcessorHelpPriority; - } + public override HelpContentPriority HelpPriority => HelpContentPriority.ParentProcessIdArgumentProcessorHelpPriority; +} + +/// +/// Argument Executor for the "/ParentProcessId" command line argument. +/// +internal class ParentProcessIdArgumentExecutor : IArgumentExecutor +{ + #region Fields /// - /// Argument Executor for the "/ParentProcessId" command line argument. + /// Used for getting sources. /// - internal class ParentProcessIdArgumentExecutor : IArgumentExecutor - { - #region Fields + private readonly CommandLineOptions _commandLineOptions; - /// - /// Used for getting sources. - /// - private CommandLineOptions commandLineOptions; + #endregion - #endregion + #region Constructor - #region Constructor - - /// - /// Default constructor. - /// - /// - /// The options. - /// - public ParentProcessIdArgumentExecutor(CommandLineOptions options) - { - Contract.Requires(options != null); - this.commandLineOptions = options; - } + /// + /// Default constructor. + /// + /// + /// The options. + /// + public ParentProcessIdArgumentExecutor(CommandLineOptions options) + { + Contract.Requires(options != null); + _commandLineOptions = options; + } - #endregion + #endregion - /// - /// Initializes with the argument that was provided with the command. - /// - /// Argument that was provided with the command. - public void Initialize(string argument) + /// + /// Initializes with the argument that was provided with the command. + /// + /// Argument that was provided with the command. + public void Initialize(string argument) + { + if (string.IsNullOrWhiteSpace(argument) || !int.TryParse(argument, out int parentProcessId)) { - int parentProcessId; - if (string.IsNullOrWhiteSpace(argument) || !int.TryParse(argument, out parentProcessId)) - { - throw new CommandLineException(CommandLineResources.InvalidParentProcessIdArgument); - } - - this.commandLineOptions.ParentProcessId = parentProcessId; + throw new CommandLineException(CommandLineResources.InvalidParentProcessIdArgument); } - /// - /// ParentProcessId is already set, return success. - /// - /// The Success - public ArgumentProcessorResult Execute() - { - // Nothing to do here, the work was done in initialization. - return ArgumentProcessorResult.Success; - } + _commandLineOptions.ParentProcessId = parentProcessId; } -} + + /// + /// ParentProcessId is already set, return success. + /// + /// The Success + public ArgumentProcessorResult Execute() + { + // Nothing to do here, the work was done in initialization. + return ArgumentProcessorResult.Success; + } +} \ No newline at end of file diff --git a/src/vstest.console/Processors/PlatformArgumentProcessor.cs b/src/vstest.console/Processors/PlatformArgumentProcessor.cs index 0bc418de47..6cd4a65f56 100644 --- a/src/vstest.console/Processors/PlatformArgumentProcessor.cs +++ b/src/vstest.console/Processors/PlatformArgumentProcessor.cs @@ -1,180 +1,180 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Diagnostics.Contracts; +using System.Globalization; +using System.Linq; + +using Common; +using Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; + +using CommandLineResources = Resources.Resources; + +/// +/// An argument processor that allows the user to specify the target platform architecture +/// for test run. +/// +internal class PlatformArgumentProcessor : IArgumentProcessor { - using System; - using System.Diagnostics.Contracts; - using System.Globalization; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; + #region Constants /// - /// An argument processor that allows the user to specify the target platform architecture - /// for test run. + /// The name of the command line argument that the OutputArgumentExecutor handles. /// - internal class PlatformArgumentProcessor : IArgumentProcessor - { - #region Constants - - /// - /// The name of the command line argument that the OutputArgumentExecutor handles. - /// - public const string CommandName = "/Platform"; + public const string CommandName = "/Platform"; - #endregion + #endregion - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - /// - /// Gets the metadata. - /// - public Lazy Metadata + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new PlatformArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new PlatformArgumentProcessorCapabilities()); } + + return _metadata; } + } - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => new PlatformArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance)); - } - - return this.executor; + _executor = new Lazy(() => new PlatformArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance)); } - set - { - this.executor = value; - } + return _executor; + } + + set + { + _executor = value; } } +} - internal class PlatformArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => PlatformArgumentProcessor.CommandName; - public override bool AllowMultiple => false; +internal class PlatformArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => PlatformArgumentProcessor.CommandName; + public override bool AllowMultiple => false; - public override bool IsAction => false; + public override bool IsAction => false; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; - public override string HelpContentResourceName => CommandLineResources.PlatformArgumentHelp; + public override string HelpContentResourceName => CommandLineResources.PlatformArgumentHelp; - public override HelpContentPriority HelpPriority => HelpContentPriority.PlatformArgumentProcessorHelpPriority; - } + public override HelpContentPriority HelpPriority => HelpContentPriority.PlatformArgumentProcessorHelpPriority; +} + +/// +/// Argument Executor for the "/Platform" command line argument. +/// +internal class PlatformArgumentExecutor : IArgumentExecutor +{ + #region Fields /// - /// Argument Executor for the "/Platform" command line argument. + /// Used for getting sources. /// - internal class PlatformArgumentExecutor : IArgumentExecutor - { - #region Fields - - /// - /// Used for getting sources. - /// - private CommandLineOptions commandLineOptions; + private readonly CommandLineOptions _commandLineOptions; - private IRunSettingsProvider runSettingsManager; + private readonly IRunSettingsProvider _runSettingsManager; - public const string RunSettingsPath = "RunConfiguration.TargetPlatform"; + public const string RunSettingsPath = "RunConfiguration.TargetPlatform"; - #endregion + #endregion - #region Constructor + #region Constructor - /// - /// Default constructor. - /// - /// The options. - /// The runsettings manager. - public PlatformArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsManager) - { - Contract.Requires(options != null); - Contract.Requires(runSettingsManager != null); - this.commandLineOptions = options; - this.runSettingsManager = runSettingsManager; - } + /// + /// Default constructor. + /// + /// The options. + /// The runsettings manager. + public PlatformArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsManager) + { + Contract.Requires(options != null); + Contract.Requires(runSettingsManager != null); + _commandLineOptions = options; + _runSettingsManager = runSettingsManager; + } - #endregion + #endregion - #region IArgumentExecutor + #region IArgumentExecutor - /// - /// Initializes with the argument that was provided with the command. - /// - /// Argument that was provided with the command. - public void Initialize(string argument) + /// + /// Initializes with the argument that was provided with the command. + /// + /// Argument that was provided with the command. + public void Initialize(string argument) + { + if (string.IsNullOrWhiteSpace(argument)) { - if (string.IsNullOrWhiteSpace(argument)) - { - throw new CommandLineException(CommandLineResources.PlatformTypeRequired); - } - - var validPlatforms = Enum.GetValues(typeof(Architecture)).Cast() - .Where(e => e != Architecture.AnyCPU && e != Architecture.Default) - .ToList(); + throw new CommandLineException(CommandLineResources.PlatformTypeRequired); + } - Architecture platform; - var validPlatform = Enum.TryParse(argument, true, out platform); - if (validPlatform) - { - // Ensure that the case-insensitively parsed enum is in the list of valid platforms. - // This filters out: - // - values that parse correctly but the enum does not define them (e.g. "1" parses as valid enum value 1) - // - the Default or AnyCpu that are not valid target to provide via settings - validPlatform = validPlatforms.Contains(platform); - } + var validPlatforms = Enum.GetValues(typeof(Architecture)).Cast() + .Where(e => e != Architecture.AnyCPU && e != Architecture.Default) + .ToList(); - if (validPlatform) - { - RunSettingsHelper.Instance.IsDefaultTargetArchitecture = false; - this.commandLineOptions.TargetArchitecture = platform; - this.runSettingsManager.UpdateRunSettingsNode(PlatformArgumentExecutor.RunSettingsPath, platform.ToString()); - } - else - { - throw new CommandLineException( - string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidPlatformType, argument, string.Join(", ", validPlatforms))); - } + var validPlatform = Enum.TryParse(argument, true, out Architecture platform); + if (validPlatform) + { + // Ensure that the case-insensitively parsed enum is in the list of valid platforms. + // This filters out: + // - values that parse correctly but the enum does not define them (e.g. "1" parses as valid enum value 1) + // - the Default or AnyCpu that are not valid target to provide via settings + validPlatform = validPlatforms.Contains(platform); + } - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("Using platform:{0}", this.commandLineOptions.TargetArchitecture); - } + if (validPlatform) + { + RunSettingsHelper.Instance.IsDefaultTargetArchitecture = false; + _commandLineOptions.TargetArchitecture = platform; + _runSettingsManager.UpdateRunSettingsNode(RunSettingsPath, platform.ToString()); + } + else + { + throw new CommandLineException( + string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidPlatformType, argument, string.Join(", ", validPlatforms))); } - /// - /// The output path is already set, return success. - /// - /// The Success - public ArgumentProcessorResult Execute() + if (EqtTrace.IsInfoEnabled) { - return ArgumentProcessorResult.Success; + EqtTrace.Info("Using platform:{0}", _commandLineOptions.TargetArchitecture); } + } - #endregion + /// + /// The output path is already set, return success. + /// + /// The Success + public ArgumentProcessorResult Execute() + { + return ArgumentProcessorResult.Success; } -} + + #endregion +} \ No newline at end of file diff --git a/src/vstest.console/Processors/PortArgumentProcessor.cs b/src/vstest.console/Processors/PortArgumentProcessor.cs index 884cc7a55f..d8e7c82750 100644 --- a/src/vstest.console/Processors/PortArgumentProcessor.cs +++ b/src/vstest.console/Processors/PortArgumentProcessor.cs @@ -1,215 +1,216 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors -{ - using System; - using System.Diagnostics.Contracts; - using System.Globalization; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Diagnostics.Contracts; +using System.Globalization; + +using Client.DesignMode; +using Client.RequestHelper; - using Microsoft.VisualStudio.TestPlatform.Client.DesignMode; - using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using ObjectModel; - using TestPlatformHelpers; +using PlatformAbstractions; +using PlatformAbstractions.Interfaces; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; +using TestPlatformHelpers; + +using CommandLineResources = Resources.Resources; + +/// +/// Argument Processor for the "--Port|/Port" command line argument. +/// +internal class PortArgumentProcessor : IArgumentProcessor +{ + #region Constants /// - /// Argument Processor for the "--Port|/Port" command line argument. + /// The name of the command line argument that the PortArgumentExecutor handles. /// - internal class PortArgumentProcessor : IArgumentProcessor - { - #region Constants - - /// - /// The name of the command line argument that the PortArgumentExecutor handles. - /// - public const string CommandName = "/Port"; + public const string CommandName = "/Port"; - #endregion + #endregion - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - /// - /// Gets the metadata. - /// - public Lazy Metadata + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new PortArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new PortArgumentProcessorCapabilities()); } + + return _metadata; } + } - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => + _executor = new Lazy(() => new PortArgumentExecutor(CommandLineOptions.Instance, TestRequestManager.Instance)); - } - - return this.executor; } - set - { - this.executor = value; - } + return _executor; + } + + set + { + _executor = value; } } +} - internal class PortArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => PortArgumentProcessor.CommandName; +internal class PortArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => PortArgumentProcessor.CommandName; + + public override bool AllowMultiple => false; - public override bool AllowMultiple => false; + public override bool IsAction => false; - public override bool IsAction => false; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.DesignMode; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.DesignMode; + public override string HelpContentResourceName => CommandLineResources.PortArgumentHelp; - public override string HelpContentResourceName => CommandLineResources.PortArgumentHelp; + public override HelpContentPriority HelpPriority => HelpContentPriority.PortArgumentProcessorHelpPriority; +} + +/// +/// Argument Executor for the "/Port" command line argument. +/// +internal class PortArgumentExecutor : IArgumentExecutor +{ + #region Fields + + /// + /// Used for getting sources. + /// + private readonly CommandLineOptions _commandLineOptions; - public override HelpContentPriority HelpPriority => HelpContentPriority.PortArgumentProcessorHelpPriority; + /// + /// Test Request Manager + /// + private readonly ITestRequestManager _testRequestManager; + + /// + /// Initializes Design mode when called + /// + private readonly Func _designModeInitializer; + + /// + /// IDesignModeClient + /// + private IDesignModeClient _designModeClient; + + /// + /// Process helper for process management actions. + /// + private readonly IProcessHelper _processHelper; + + #endregion + + #region Constructor + + /// + /// Default constructor. + /// + /// + /// The options. + /// + /// Test request manager + public PortArgumentExecutor(CommandLineOptions options, ITestRequestManager testRequestManager) + : this(options, testRequestManager, InitializeDesignMode, new ProcessHelper()) + { } /// - /// Argument Executor for the "/Port" command line argument. + /// For Unit testing only /// - internal class PortArgumentExecutor : IArgumentExecutor + internal PortArgumentExecutor(CommandLineOptions options, ITestRequestManager testRequestManager, IProcessHelper processHelper) + : this(options, testRequestManager, InitializeDesignMode, processHelper) { - #region Fields - - /// - /// Used for getting sources. - /// - private CommandLineOptions commandLineOptions; - - /// - /// Test Request Manager - /// - private ITestRequestManager testRequestManager; - - /// - /// Initializes Design mode when called - /// - private Func designModeInitializer; - - /// - /// IDesignModeClient - /// - private IDesignModeClient designModeClient; - - /// - /// Process helper for process management actions. - /// - private IProcessHelper processHelper; - - #endregion - - #region Constructor - - /// - /// Default constructor. - /// - /// - /// The options. - /// - /// Test request manager - public PortArgumentExecutor(CommandLineOptions options, ITestRequestManager testRequestManager) - : this(options, testRequestManager, InitializeDesignMode, new ProcessHelper()) - { - } + } - /// - /// For Unit testing only - /// - internal PortArgumentExecutor(CommandLineOptions options, ITestRequestManager testRequestManager, IProcessHelper processHelper) - : this(options, testRequestManager, InitializeDesignMode, processHelper) - { - } + /// + /// For Unit testing only + /// + internal PortArgumentExecutor(CommandLineOptions options, ITestRequestManager testRequestManager, Func designModeInitializer, IProcessHelper processHelper) + { + Contract.Requires(options != null); + _commandLineOptions = options; + _testRequestManager = testRequestManager; + _designModeInitializer = designModeInitializer; + _processHelper = processHelper; + } - /// - /// For Unit testing only - /// - internal PortArgumentExecutor(CommandLineOptions options, ITestRequestManager testRequestManager, Func designModeInitializer, IProcessHelper processHelper) + #endregion + + #region IArgumentExecutor + + /// + /// Initializes with the argument that was provided with the command. + /// + /// Argument that was provided with the command. + public void Initialize(string argument) + { + if (string.IsNullOrWhiteSpace(argument) || !int.TryParse(argument, out int portNumber)) { - Contract.Requires(options != null); - this.commandLineOptions = options; - this.testRequestManager = testRequestManager; - this.designModeInitializer = designModeInitializer; - this.processHelper = processHelper; + throw new CommandLineException(CommandLineResources.InvalidPortArgument); } - #endregion - - #region IArgumentExecutor + _commandLineOptions.Port = portNumber; + _commandLineOptions.IsDesignMode = true; + _designModeClient = _designModeInitializer?.Invoke(_commandLineOptions.ParentProcessId, _processHelper); + } - /// - /// Initializes with the argument that was provided with the command. - /// - /// Argument that was provided with the command. - public void Initialize(string argument) + /// + /// Initialize the design mode client. + /// + /// The if initialization is successful. + public ArgumentProcessorResult Execute() + { + try { - if (string.IsNullOrWhiteSpace(argument) || !int.TryParse(argument, out int portNumber)) - { - throw new CommandLineException(CommandLineResources.InvalidPortArgument); - } - - this.commandLineOptions.Port = portNumber; - this.commandLineOptions.IsDesignMode = true; - this.designModeClient = this.designModeInitializer?.Invoke(this.commandLineOptions.ParentProcessId, this.processHelper); + _designModeClient?.ConnectToClientAndProcessRequests(_commandLineOptions.Port, _testRequestManager); } - - /// - /// Initialize the design mode client. - /// - /// The if initialization is successful. - public ArgumentProcessorResult Execute() + catch (TimeoutException ex) { - try - { - this.designModeClient?.ConnectToClientAndProcessRequests(this.commandLineOptions.Port, this.testRequestManager); - } - catch (TimeoutException ex) - { - throw new CommandLineException(string.Format(CultureInfo.CurrentUICulture, string.Format(CommandLineResources.DesignModeClientTimeoutError, this.commandLineOptions.Port)), ex); - } - - return ArgumentProcessorResult.Success; + throw new CommandLineException(string.Format(CultureInfo.CurrentUICulture, string.Format(CommandLineResources.DesignModeClientTimeoutError, _commandLineOptions.Port)), ex); } - #endregion + return ArgumentProcessorResult.Success; + } + + #endregion - private static IDesignModeClient InitializeDesignMode(int parentProcessId, IProcessHelper processHelper) + private static IDesignModeClient InitializeDesignMode(int parentProcessId, IProcessHelper processHelper) + { + if (parentProcessId > 0) { - if (parentProcessId > 0) + processHelper.SetExitCallback(parentProcessId, (obj) => { - processHelper.SetExitCallback(parentProcessId, (obj) => - { - EqtTrace.Info($"PortArgumentProcessor: parent process:{parentProcessId} exited."); - DesignModeClient.Instance?.HandleParentProcessExit(); - }); - } - - DesignModeClient.Initialize(); - return DesignModeClient.Instance; + EqtTrace.Info($"PortArgumentProcessor: parent process:{parentProcessId} exited."); + DesignModeClient.Instance?.HandleParentProcessExit(); + }); } + + DesignModeClient.Initialize(); + return DesignModeClient.Instance; } -} +} \ No newline at end of file diff --git a/src/vstest.console/Processors/ResponseFileArgumentProcessor.cs b/src/vstest.console/Processors/ResponseFileArgumentProcessor.cs index 5885abf0fe..009e7fe2a7 100644 --- a/src/vstest.console/Processors/ResponseFileArgumentProcessor.cs +++ b/src/vstest.console/Processors/ResponseFileArgumentProcessor.cs @@ -1,68 +1,67 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; +using CommandLineResources = Resources.Resources; + +/// +/// An argument processor that allows the user to specify additional arguments from a response file. +/// for test run. +/// +internal class ResponseFileArgumentProcessor : IArgumentProcessor +{ + #region Constants /// - /// An argument processor that allows the user to specify additional arguments from a response file. - /// for test run. + /// The name of the command line argument that the OutputArgumentExecutor handles. /// - internal class ResponseFileArgumentProcessor : IArgumentProcessor - { - #region Constants + public const string CommandName = "@"; - /// - /// The name of the command line argument that the OutputArgumentExecutor handles. - /// - public const string CommandName = "@"; + #endregion - #endregion + private Lazy _metadata; - private Lazy metadata; - - /// - /// Gets the metadata. - /// - public Lazy Metadata + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new ResponseFileArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new ResponseFileArgumentProcessorCapabilities()); } - } - /// - /// Gets or sets the executor. - /// - /// - /// As this manipulates the command line arguments themselves, this has no executor. - /// - public Lazy Executor { get; set; } + return _metadata; + } } - internal class ResponseFileArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => ResponseFileArgumentProcessor.CommandName; + /// + /// Gets or sets the executor. + /// + /// + /// As this manipulates the command line arguments themselves, this has no executor. + /// + public Lazy Executor { get; set; } +} - public override bool AllowMultiple => true; +internal class ResponseFileArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => ResponseFileArgumentProcessor.CommandName; - public override bool IsAction => false; + public override bool AllowMultiple => true; - public override bool IsSpecialCommand => true; + public override bool IsAction => false; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; + public override bool IsSpecialCommand => true; - public override string HelpContentResourceName => CommandLineResources.ResponseFileArgumentHelp; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; - public override HelpContentPriority HelpPriority => HelpContentPriority.ResponseFileArgumentProcessorHelpPriority; - } -} + public override string HelpContentResourceName => CommandLineResources.ResponseFileArgumentHelp; + + public override HelpContentPriority HelpPriority => HelpContentPriority.ResponseFileArgumentProcessorHelpPriority; +} \ No newline at end of file diff --git a/src/vstest.console/Processors/ResultsDirectoryArgumentProcessor.cs b/src/vstest.console/Processors/ResultsDirectoryArgumentProcessor.cs index 8d3648f1d7..06dc9451eb 100644 --- a/src/vstest.console/Processors/ResultsDirectoryArgumentProcessor.cs +++ b/src/vstest.console/Processors/ResultsDirectoryArgumentProcessor.cs @@ -1,170 +1,171 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors -{ - using System; - using System.Diagnostics.Contracts; - using System.IO; - using System.Security; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Diagnostics.Contracts; +using System.IO; +using System.Security; + +using Common; +using Common.Interfaces; + +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; +using CommandLineResources = Resources.Resources; + +/// +/// Allows the user to specify a path to save test results. +/// +internal class ResultsDirectoryArgumentProcessor : IArgumentProcessor +{ + #region Constants /// - /// Allows the user to specify a path to save test results. + /// The name of the command line argument that the ListTestsArgumentExecutor handles. /// - internal class ResultsDirectoryArgumentProcessor : IArgumentProcessor - { - #region Constants - - /// - /// The name of the command line argument that the ListTestsArgumentExecutor handles. - /// - public const string CommandName = "/ResultsDirectory"; + public const string CommandName = "/ResultsDirectory"; - private const string RunSettingsPath = "RunConfiguration.ResultsDirectory"; - #endregion + private const string RunSettingsPath = "RunConfiguration.ResultsDirectory"; + #endregion - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - /// - /// Gets the metadata. - /// - public Lazy Metadata + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new ResultsDirectoryArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new ResultsDirectoryArgumentProcessorCapabilities()); } + + return _metadata; } + } - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => new ResultsDirectoryArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance)); - } - - return this.executor; + _executor = new Lazy(() => new ResultsDirectoryArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance)); } - set - { - this.executor = value; - } + return _executor; + } + + set + { + _executor = value; } } +} - /// - /// The argument capabilities. - /// - internal class ResultsDirectoryArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => ResultsDirectoryArgumentProcessor.CommandName; +/// +/// The argument capabilities. +/// +internal class ResultsDirectoryArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => ResultsDirectoryArgumentProcessor.CommandName; - public override bool AllowMultiple => false; + public override bool AllowMultiple => false; - public override bool IsAction => false; + public override bool IsAction => false; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; - public override string HelpContentResourceName => CommandLineResources.ResultsDirectoryArgumentHelp; + public override string HelpContentResourceName => CommandLineResources.ResultsDirectoryArgumentHelp; - public override HelpContentPriority HelpPriority => HelpContentPriority.ResultsDirectoryArgumentProcessorHelpPriority; - } + public override HelpContentPriority HelpPriority => HelpContentPriority.ResultsDirectoryArgumentProcessorHelpPriority; +} + +/// +/// The argument executor. +/// +internal class ResultsDirectoryArgumentExecutor : IArgumentExecutor +{ + #region Fields /// - /// The argument executor. + /// Used for getting sources. /// - internal class ResultsDirectoryArgumentExecutor : IArgumentExecutor - { - #region Fields + private readonly CommandLineOptions _commandLineOptions; - /// - /// Used for getting sources. - /// - private CommandLineOptions commandLineOptions; + private readonly IRunSettingsProvider _runSettingsManager; - private IRunSettingsProvider runSettingsManager; + public const string RunSettingsPath = "RunConfiguration.ResultsDirectory"; - public const string RunSettingsPath = "RunConfiguration.ResultsDirectory"; + #endregion - #endregion + #region Constructor - #region Constructor - - /// - /// Default constructor. - /// - /// The options. - /// The test platform - public ResultsDirectoryArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsManager) - { - Contract.Requires(options != null); - Contract.Requires(runSettingsManager != null); + /// + /// Default constructor. + /// + /// The options. + /// The test platform + public ResultsDirectoryArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsManager) + { + Contract.Requires(options != null); + Contract.Requires(runSettingsManager != null); - this.commandLineOptions = options; - this.runSettingsManager = runSettingsManager; - } + _commandLineOptions = options; + _runSettingsManager = runSettingsManager; + } - #endregion + #endregion - #region IArgumentExecutor + #region IArgumentExecutor - /// - /// Initializes with the argument that was provided with the command. - /// - /// Argument that was provided with the command. - public void Initialize(string argument) + /// + /// Initializes with the argument that was provided with the command. + /// + /// Argument that was provided with the command. + public void Initialize(string argument) + { + if (string.IsNullOrWhiteSpace(argument)) { - if (string.IsNullOrWhiteSpace(argument)) - { - throw new CommandLineException(CommandLineResources.ResultsDirectoryValueRequired); - } - - try - { - if (!Path.IsPathRooted(argument)) - { - argument = Path.GetFullPath(argument); - } + throw new CommandLineException(CommandLineResources.ResultsDirectoryValueRequired); + } - var di = Directory.CreateDirectory(argument); - } - catch (Exception ex) when( ex is NotSupportedException || ex is SecurityException || ex is ArgumentException || ex is PathTooLongException || ex is IOException) + try + { + if (!Path.IsPathRooted(argument)) { - throw new CommandLineException(string.Format(CommandLineResources.InvalidResultsDirectoryPathCommand, argument, ex.Message)); + argument = Path.GetFullPath(argument); } - this.commandLineOptions.ResultsDirectory = argument; - this.runSettingsManager.UpdateRunSettingsNode(ResultsDirectoryArgumentExecutor.RunSettingsPath, argument); + var di = Directory.CreateDirectory(argument); } - - /// - /// Executes the argument processor. - /// - /// The . - public ArgumentProcessorResult Execute() + catch (Exception ex) when (ex is NotSupportedException || ex is SecurityException || ex is ArgumentException || ex is PathTooLongException || ex is IOException) { - // Nothing to do since we updated the parameter during initialize parameter - return ArgumentProcessorResult.Success; + throw new CommandLineException(string.Format(CommandLineResources.InvalidResultsDirectoryPathCommand, argument, ex.Message)); } - #endregion + _commandLineOptions.ResultsDirectory = argument; + _runSettingsManager.UpdateRunSettingsNode(RunSettingsPath, argument); } -} + + /// + /// Executes the argument processor. + /// + /// The . + public ArgumentProcessorResult Execute() + { + // Nothing to do since we updated the parameter during initialize parameter + return ArgumentProcessorResult.Success; + } + + #endregion +} \ No newline at end of file diff --git a/src/vstest.console/Processors/RunSettingsArgumentProcessor.cs b/src/vstest.console/Processors/RunSettingsArgumentProcessor.cs index b06ef8abf8..68b1e9b77b 100644 --- a/src/vstest.console/Processors/RunSettingsArgumentProcessor.cs +++ b/src/vstest.console/Processors/RunSettingsArgumentProcessor.cs @@ -1,216 +1,207 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Diagnostics.Contracts; +using System.Globalization; +using System.IO; +using System.Text; +using System.Xml; + +using Common; +using Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +using CommandLineResources = Resources.Resources; + +internal class RunSettingsArgumentProcessor : IArgumentProcessor { - using System; - using System.Diagnostics.CodeAnalysis; - using System.Diagnostics.Contracts; - using System.Globalization; - using System.IO; - using System.Text; - using System.Xml; - - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; - - internal class RunSettingsArgumentProcessor : IArgumentProcessor - { - #region Constants + #region Constants - /// - /// The name of the command line argument that the PortArgumentExecutor handles. - /// - public const string CommandName = "/Settings"; + /// + /// The name of the command line argument that the PortArgumentExecutor handles. + /// + public const string CommandName = "/Settings"; - #endregion + #endregion - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - /// - /// Gets the metadata. - /// - public Lazy Metadata + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new RunSettingsArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new RunSettingsArgumentProcessorCapabilities()); } + + return _metadata; } + } - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => new RunSettingsArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance)); - } - - return this.executor; + _executor = new Lazy(() => new RunSettingsArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance)); } - set - { - this.executor = value; - } + return _executor; + } + + set + { + _executor = value; } } +} - internal class RunSettingsArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => RunSettingsArgumentProcessor.CommandName; +internal class RunSettingsArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => RunSettingsArgumentProcessor.CommandName; - public override bool AllowMultiple => false; + public override bool AllowMultiple => false; - public override bool IsAction => false; + public override bool IsAction => false; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.RunSettings; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.RunSettings; - public override string HelpContentResourceName => CommandLineResources.RunSettingsArgumentHelp; + public override string HelpContentResourceName => CommandLineResources.RunSettingsArgumentHelp; - public override HelpContentPriority HelpPriority => HelpContentPriority.RunSettingsArgumentProcessorHelpPriority; - } + public override HelpContentPriority HelpPriority => HelpContentPriority.RunSettingsArgumentProcessorHelpPriority; +} - internal class RunSettingsArgumentExecutor : IArgumentExecutor - { - private CommandLineOptions commandLineOptions; - private IRunSettingsProvider runSettingsManager; +internal class RunSettingsArgumentExecutor : IArgumentExecutor +{ + private readonly CommandLineOptions _commandLineOptions; + private readonly IRunSettingsProvider _runSettingsManager; - internal IFileHelper FileHelper { get; set; } + internal IFileHelper FileHelper { get; set; } - internal RunSettingsArgumentExecutor(CommandLineOptions commandLineOptions, IRunSettingsProvider runSettingsManager) + internal RunSettingsArgumentExecutor(CommandLineOptions commandLineOptions, IRunSettingsProvider runSettingsManager) + { + _commandLineOptions = commandLineOptions; + _runSettingsManager = runSettingsManager; + FileHelper = new FileHelper(); + } + + public void Initialize(string argument) + { + if (string.IsNullOrWhiteSpace(argument)) { - this.commandLineOptions = commandLineOptions; - this.runSettingsManager = runSettingsManager; - this.FileHelper = new FileHelper(); + throw new CommandLineException(CommandLineResources.RunSettingsRequired); } - public void Initialize(string argument) + if (!FileHelper.Exists(argument)) { - if (string.IsNullOrWhiteSpace(argument)) - { - throw new CommandLineException(CommandLineResources.RunSettingsRequired); - } - - if (!this.FileHelper.Exists(argument)) - { - throw new CommandLineException( - string.Format( - CultureInfo.CurrentCulture, - CommandLineResources.RunSettingsFileNotFound, - argument)); - } - - Contract.EndContractBlock(); - - // Load up the run settings and set it as the active run settings. - try - { - XmlDocument document = this.GetRunSettingsDocument(argument); + throw new CommandLineException( + string.Format( + CultureInfo.CurrentCulture, + CommandLineResources.RunSettingsFileNotFound, + argument)); + } - this.runSettingsManager.UpdateRunSettings(document.OuterXml); + Contract.EndContractBlock(); - // To determine whether to infer framework and platform. - ExtractFrameworkAndPlatform(); + // Load up the run settings and set it as the active run settings. + try + { + XmlDocument document = GetRunSettingsDocument(argument); - //Add default runsettings values if not exists in given runsettings file. - this.runSettingsManager.AddDefaultRunSettings(); + _runSettingsManager.UpdateRunSettings(document.OuterXml); - this.commandLineOptions.SettingsFile = argument; + // To determine whether to infer framework and platform. + ExtractFrameworkAndPlatform(); - if (this.runSettingsManager.QueryRunSettingsNode("RunConfiguration.EnvironmentVariables") != null) - { - this.commandLineOptions.InIsolation = true; - this.runSettingsManager.UpdateRunSettingsNode(InIsolationArgumentExecutor.RunSettingsPath, "true"); - } + //Add default runsettings values if not exists in given runsettings file. + _runSettingsManager.AddDefaultRunSettings(); - var testCaseFilter = this.runSettingsManager.QueryRunSettingsNode("RunConfiguration.TestCaseFilter"); - if (testCaseFilter != null) - { - this.commandLineOptions.TestCaseFilterValue = testCaseFilter; - } - } - catch (XmlException exception) - { - throw new SettingsException( - string.Format(CultureInfo.CurrentCulture, "{0} {1}", ObjectModel.Resources.CommonResources.MalformedRunSettingsFile, exception.Message), - exception); - } - } + _commandLineOptions.SettingsFile = argument; - private void ExtractFrameworkAndPlatform() - { - var framworkStr = this.runSettingsManager.QueryRunSettingsNode(FrameworkArgumentExecutor.RunSettingsPath); - Framework framework = Framework.FromString(framworkStr); - if (framework != null) + if (_runSettingsManager.QueryRunSettingsNode("RunConfiguration.EnvironmentVariables") != null) { - this.commandLineOptions.TargetFrameworkVersion = framework; + _commandLineOptions.InIsolation = true; + _runSettingsManager.UpdateRunSettingsNode(InIsolationArgumentExecutor.RunSettingsPath, "true"); } - var platformStr = this.runSettingsManager.QueryRunSettingsNode(PlatformArgumentExecutor.RunSettingsPath); - if (Enum.TryParse(platformStr, true, out var architecture)) + var testCaseFilter = _runSettingsManager.QueryRunSettingsNode("RunConfiguration.TestCaseFilter"); + if (testCaseFilter != null) { - RunSettingsHelper.Instance.IsDefaultTargetArchitecture = false; - this.commandLineOptions.TargetArchitecture = architecture; + _commandLineOptions.TestCaseFilterValue = testCaseFilter; } } + catch (XmlException exception) + { + throw new SettingsException( + string.Format(CultureInfo.CurrentCulture, "{0} {1}", ObjectModel.Resources.CommonResources.MalformedRunSettingsFile, exception.Message), + exception); + } + } - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", - Justification = "XmlReaderSettings.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] - protected virtual XmlReader GetReaderForFile(string runSettingsFile) + private void ExtractFrameworkAndPlatform() + { + var framworkStr = _runSettingsManager.QueryRunSettingsNode(FrameworkArgumentExecutor.RunSettingsPath); + Framework framework = Framework.FromString(framworkStr); + if (framework != null) { - return XmlReader.Create(new StringReader(File.ReadAllText(runSettingsFile, Encoding.UTF8)), XmlRunSettingsUtilities.ReaderSettings); + _commandLineOptions.TargetFrameworkVersion = framework; } - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", - Justification = "XmlDocument.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] - private XmlDocument GetRunSettingsDocument(string runSettingsFile) + var platformStr = _runSettingsManager.QueryRunSettingsNode(PlatformArgumentExecutor.RunSettingsPath); + if (Enum.TryParse(platformStr, true, out var architecture)) { - XmlDocument runSettingsDocument; + RunSettingsHelper.Instance.IsDefaultTargetArchitecture = false; + _commandLineOptions.TargetArchitecture = architecture; + } + } - if (!MSTestSettingsUtilities.IsLegacyTestSettingsFile(runSettingsFile)) - { - using (XmlReader reader = this.GetReaderForFile(runSettingsFile)) - { - var settingsDocument = new XmlDocument(); - settingsDocument.Load(reader); - ClientUtilities.FixRelativePathsInRunSettings(settingsDocument, runSettingsFile); - runSettingsDocument = settingsDocument; - } - } - else - { - runSettingsDocument = XmlRunSettingsUtilities.CreateDefaultRunSettings(); - runSettingsDocument = MSTestSettingsUtilities.Import(runSettingsFile, runSettingsDocument); - } + protected virtual XmlReader GetReaderForFile(string runSettingsFile) + { + return XmlReader.Create(new StringReader(File.ReadAllText(runSettingsFile, Encoding.UTF8)), XmlRunSettingsUtilities.ReaderSettings); + } - return runSettingsDocument; - } + private XmlDocument GetRunSettingsDocument(string runSettingsFile) + { + XmlDocument runSettingsDocument; - public ArgumentProcessorResult Execute() + if (!MSTestSettingsUtilities.IsLegacyTestSettingsFile(runSettingsFile)) { - // Nothing to do here, the work was done in initialization. - return ArgumentProcessorResult.Success; + using XmlReader reader = GetReaderForFile(runSettingsFile); + var settingsDocument = new XmlDocument(); + settingsDocument.Load(reader); + ClientUtilities.FixRelativePathsInRunSettings(settingsDocument, runSettingsFile); + runSettingsDocument = settingsDocument; } + else + { + runSettingsDocument = XmlRunSettingsUtilities.CreateDefaultRunSettings(); + runSettingsDocument = MSTestSettingsUtilities.Import(runSettingsFile, runSettingsDocument); + } + + return runSettingsDocument; } -} + + public ArgumentProcessorResult Execute() + { + // Nothing to do here, the work was done in initialization. + return ArgumentProcessorResult.Success; + } +} \ No newline at end of file diff --git a/src/vstest.console/Processors/RunSpecificTestsArgumentProcessor.cs b/src/vstest.console/Processors/RunSpecificTestsArgumentProcessor.cs index 96e3e44223..781089dc2d 100644 --- a/src/vstest.console/Processors/RunSpecificTestsArgumentProcessor.cs +++ b/src/vstest.console/Processors/RunSpecificTestsArgumentProcessor.cs @@ -1,394 +1,388 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics.Contracts; +using System.Globalization; +using System.Linq; + +using Common; +using Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Client.RequestHelper; +using Internal; +using TestPlatformHelpers; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using CommandLineResources = Resources.Resources; + +internal class RunSpecificTestsArgumentProcessor : IArgumentProcessor { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Diagnostics.Contracts; - using System.Globalization; - using System.Linq; - - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; - using Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using CommandLineResources = Resources.Resources; - - internal class RunSpecificTestsArgumentProcessor : IArgumentProcessor - { - public const string CommandName = "/Tests"; + public const string CommandName = "/Tests"; - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - public Lazy Metadata + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new RunSpecificTestsArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new RunSpecificTestsArgumentProcessorCapabilities()); } + + return _metadata; } + } - public Lazy Executor + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => + _executor = new Lazy(() => new RunSpecificTestsArgumentExecutor( CommandLineOptions.Instance, RunSettingsManager.Instance, TestRequestManager.Instance, ConsoleOutput.Instance)); - } - - return this.executor; } - set - { - this.executor = value; - } + return _executor; } - } - - internal class RunSpecificTestsArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => RunSpecificTestsArgumentProcessor.CommandName; - - public override bool IsAction => true; - - public override bool AllowMultiple => false; - - public override string HelpContentResourceName => CommandLineResources.RunSpecificTestsHelp; - public override HelpContentPriority HelpPriority => HelpContentPriority.RunSpecificTestsArgumentProcessorHelpPriority; - - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; + set + { + _executor = value; + } } +} - internal class RunSpecificTestsArgumentExecutor : IArgumentExecutor - { - public const char SplitDelimiter = ','; - public const char EscapeDelimiter = '\\'; - - #region Fields +internal class RunSpecificTestsArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => RunSpecificTestsArgumentProcessor.CommandName; - /// - /// Used for getting sources. - /// - private CommandLineOptions commandLineOptions; + public override bool IsAction => true; - /// - /// The instance of testPlatforms - /// - private ITestRequestManager testRequestManager; + public override bool AllowMultiple => false; - /// - /// Used for sending output. - /// - internal IOutput output; + public override string HelpContentResourceName => CommandLineResources.RunSpecificTestsHelp; - /// - /// RunSettingsManager to get currently active run settings. - /// - private IRunSettingsProvider runSettingsManager; + public override HelpContentPriority HelpPriority => HelpContentPriority.RunSpecificTestsArgumentProcessorHelpPriority; - /// - /// Given Collection of strings for filtering test cases - /// - private Collection selectedTestNames; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; +} - /// - /// Used for tracking the total no. of tests discovered from the given sources. - /// - private long discoveredTestCount = 0; - - /// - /// Collection of test cases that match at least one of the given search strings - /// - private Collection selectedTestCases = new Collection(); - - /// - /// Effective run settings applicable to test run after inferring the multi-targeting settings. - /// - private string effectiveRunSettings = null; - - /// - /// List of filters that have not yet been discovered - /// - HashSet undiscoveredFilters = new HashSet(); +internal class RunSpecificTestsArgumentExecutor : IArgumentExecutor +{ + public const char SplitDelimiter = ','; + public const char EscapeDelimiter = '\\'; + + #region Fields + + /// + /// Used for getting sources. + /// + private readonly CommandLineOptions _commandLineOptions; + + /// + /// The instance of testPlatforms + /// + private readonly ITestRequestManager _testRequestManager; + + /// + /// Used for sending output. + /// + internal IOutput Output; + + /// + /// RunSettingsManager to get currently active run settings. + /// + private readonly IRunSettingsProvider _runSettingsManager; + + /// + /// Given Collection of strings for filtering test cases + /// + private Collection _selectedTestNames; + + /// + /// Used for tracking the total no. of tests discovered from the given sources. + /// + private long _discoveredTestCount = 0; + + /// + /// Collection of test cases that match at least one of the given search strings + /// + private readonly Collection _selectedTestCases = new(); + + /// + /// Effective run settings applicable to test run after inferring the multi-targeting settings. + /// + private string _effectiveRunSettings = null; + + /// + /// List of filters that have not yet been discovered + /// + HashSet _undiscoveredFilters = new(); + + /// + /// Registers for discovery events during discovery + /// + private readonly ITestDiscoveryEventsRegistrar _discoveryEventsRegistrar; + + /// + /// Registers and Unregisters for test run events before and after test run + /// + private readonly ITestRunEventsRegistrar _testRunEventsRegistrar; + + #endregion + + #region Constructor + + /// + /// Default constructor. + /// + public RunSpecificTestsArgumentExecutor( + CommandLineOptions options, + IRunSettingsProvider runSettingsProvider, + ITestRequestManager testRequestManager, + IOutput output) + { + Contract.Requires(options != null); + Contract.Requires(testRequestManager != null); - /// - /// Registers for discovery events during discovery - /// - private ITestDiscoveryEventsRegistrar discoveryEventsRegistrar; + _commandLineOptions = options; + _testRequestManager = testRequestManager; - /// - /// Registers and Unregisters for test run events before and after test run - /// - private ITestRunEventsRegistrar testRunEventsRegistrar; + _runSettingsManager = runSettingsProvider; + Output = output; + _discoveryEventsRegistrar = new DiscoveryEventsRegistrar(DiscoveryRequest_OnDiscoveredTests); + _testRunEventsRegistrar = new TestRunRequestEventsRegistrar(Output, _commandLineOptions); + } - #endregion + #endregion - #region Constructor + #region IArgumentProcessor - /// - /// Default constructor. - /// - public RunSpecificTestsArgumentExecutor( - CommandLineOptions options, - IRunSettingsProvider runSettingsProvider, - ITestRequestManager testRequestManager, - IOutput output) + /// + /// Splits given the search strings and adds to selectTestNamesCollection. + /// + /// + public void Initialize(string argument) + { + if (!string.IsNullOrWhiteSpace(argument)) { - Contract.Requires(options != null); - Contract.Requires(testRequestManager != null); - - this.commandLineOptions = options; - this.testRequestManager = testRequestManager; + _selectedTestNames = new Collection( + argument.Tokenize(SplitDelimiter, EscapeDelimiter) + .Where(x => !string.IsNullOrWhiteSpace(x)) + .Select(s => s.Trim()).ToList()); + } - this.runSettingsManager = runSettingsProvider; - this.output = output; - this.discoveryEventsRegistrar = new DiscoveryEventsRegistrar(this.DiscoveryRequest_OnDiscoveredTests); - this.testRunEventsRegistrar = new TestRunRequestEventsRegistrar(this.output, this.commandLineOptions); + if (_selectedTestNames == null || _selectedTestNames.Count <= 0) + { + throw new CommandLineException(CommandLineResources.SpecificTestsRequired); } - #endregion + // by default all filters are not discovered on launch + _undiscoveredFilters = new HashSet(_selectedTestNames); + } - #region IArgumentProcessor + /// + /// Execute specific tests that match any of the given strings. + /// + /// + public ArgumentProcessorResult Execute() + { + Contract.Assert(Output != null); + Contract.Assert(_commandLineOptions != null); + Contract.Assert(_testRequestManager != null); + Contract.Assert(!string.IsNullOrWhiteSpace(_runSettingsManager.ActiveRunSettings.SettingsXml)); - /// - /// Splits given the search strings and adds to selectTestNamesCollection. - /// - /// - public void Initialize(string argument) + if (!_commandLineOptions.Sources.Any()) { - if (!string.IsNullOrWhiteSpace(argument)) - { - this.selectedTestNames = new Collection( - argument.Tokenize(SplitDelimiter, EscapeDelimiter) - .Where(x => !string.IsNullOrWhiteSpace(x)) - .Select(s => s.Trim()).ToList()); - } - - if (this.selectedTestNames == null || this.selectedTestNames.Count <= 0) - { - throw new CommandLineException(CommandLineResources.SpecificTestsRequired); - } - - // by default all filters are not discovered on launch - this.undiscoveredFilters = new HashSet(this.selectedTestNames); + throw new CommandLineException(string.Format(CultureInfo.CurrentUICulture, CommandLineResources.MissingTestSourceFile)); } - /// - /// Execute specific tests that match any of the given strings. - /// - /// - public ArgumentProcessorResult Execute() - { - Contract.Assert(this.output != null); - Contract.Assert(this.commandLineOptions != null); - Contract.Assert(this.testRequestManager != null); - Contract.Assert(!string.IsNullOrWhiteSpace(this.runSettingsManager.ActiveRunSettings.SettingsXml)); + _effectiveRunSettings = _runSettingsManager.ActiveRunSettings.SettingsXml; - if (!this.commandLineOptions.Sources.Any()) - { - throw new CommandLineException(string.Format(CultureInfo.CurrentUICulture, CommandLineResources.MissingTestSourceFile)); - } + // Discover tests from sources and filter on every discovery reported. + DiscoverTestsAndSelectSpecified(_commandLineOptions.Sources); - this.effectiveRunSettings = this.runSettingsManager.ActiveRunSettings.SettingsXml; + // Now that tests are discovered and filtered, we run only those selected tests. + ExecuteSelectedTests(); - // Discover tests from sources and filter on every discovery reported. - this.DiscoverTestsAndSelectSpecified(this.commandLineOptions.Sources); + bool treatNoTestsAsError = RunSettingsUtilities.GetTreatNoTestsAsError(_effectiveRunSettings); - // Now that tests are discovered and filtered, we run only those selected tests. - this.ExecuteSelectedTests(); + return treatNoTestsAsError && _selectedTestCases.Count == 0 ? ArgumentProcessorResult.Fail : ArgumentProcessorResult.Success; + } - bool treatNoTestsAsError = RunSettingsUtilities.GetTreatNoTestsAsError(effectiveRunSettings); + #endregion - if (treatNoTestsAsError && this.selectedTestCases.Count == 0) - { - return ArgumentProcessorResult.Fail; - } + #region Private Methods - return ArgumentProcessorResult.Success; + /// + /// Discovers tests from the given sources and selects only specified tests. + /// + /// Test source assemblies paths. + private void DiscoverTestsAndSelectSpecified(IEnumerable sources) + { + Output.WriteLine(CommandLineResources.StartingDiscovery, OutputLevel.Information); + if (!string.IsNullOrEmpty(EqtTrace.LogFile)) + { + Output.Information(false, CommandLineResources.VstestDiagLogOutputPath, EqtTrace.LogFile); } - #endregion - - #region Private Methods + _testRequestManager.DiscoverTests( + new DiscoveryRequestPayload() { Sources = sources, RunSettings = _effectiveRunSettings }, _discoveryEventsRegistrar, Constants.DefaultProtocolConfig); + } - /// - /// Discovers tests from the given sources and selects only specified tests. - /// - /// Test source assemblies paths. - private void DiscoverTestsAndSelectSpecified(IEnumerable sources) + /// + /// Executes the selected tests + /// + private void ExecuteSelectedTests() + { + if (_selectedTestCases.Count > 0) { - this.output.WriteLine(CommandLineResources.StartingDiscovery, OutputLevel.Information); - if (!string.IsNullOrEmpty(EqtTrace.LogFile)) + if (_undiscoveredFilters.Count != 0) { - this.output.Information(false, CommandLineResources.VstestDiagLogOutputPath, EqtTrace.LogFile); + string missingFilters = string.Join(", ", _undiscoveredFilters); + string warningMessage = string.Format(CultureInfo.CurrentCulture, CommandLineResources.SomeTestsUnavailableAfterFiltering, _discoveredTestCount, missingFilters); + Output.Warning(false, warningMessage); } - this.testRequestManager.DiscoverTests( - new DiscoveryRequestPayload() { Sources = sources, RunSettings = this.effectiveRunSettings }, this.discoveryEventsRegistrar, Constants.DefaultProtocolConfig); - } + // for command line keep alive is always false. + bool keepAlive = false; - /// - /// Executes the selected tests - /// - private void ExecuteSelectedTests() + EqtTrace.Verbose("RunSpecificTestsArgumentProcessor:Execute: Test run is queued."); + var runRequestPayload = new TestRunRequestPayload() { TestCases = _selectedTestCases.ToList(), RunSettings = _effectiveRunSettings, KeepAlive = keepAlive, TestPlatformOptions = new TestPlatformOptions() { TestCaseFilter = _commandLineOptions.TestCaseFilterValue } }; + _testRequestManager.RunTests(runRequestPayload, null, _testRunEventsRegistrar, Constants.DefaultProtocolConfig); + } + else { - if (this.selectedTestCases.Count > 0) + string warningMessage; + if (_discoveredTestCount > 0) { - if (this.undiscoveredFilters.Count != 0) - { - string missingFilters = string.Join(", ", this.undiscoveredFilters); - string warningMessage = string.Format(CultureInfo.CurrentCulture, CommandLineResources.SomeTestsUnavailableAfterFiltering, this.discoveredTestCount, missingFilters); - this.output.Warning(false, warningMessage); - } - - // for command line keep alive is always false. - bool keepAlive = false; - - EqtTrace.Verbose("RunSpecificTestsArgumentProcessor:Execute: Test run is queued."); - var runRequestPayload = new TestRunRequestPayload() { TestCases = this.selectedTestCases.ToList(), RunSettings = this.effectiveRunSettings, KeepAlive = keepAlive, TestPlatformOptions = new TestPlatformOptions() { TestCaseFilter = this.commandLineOptions.TestCaseFilterValue }}; - this.testRequestManager.RunTests(runRequestPayload, null, this.testRunEventsRegistrar, Constants.DefaultProtocolConfig); + // No tests that matched any of the given strings. + warningMessage = string.Format(CultureInfo.CurrentCulture, CommandLineResources.NoTestsAvailableAfterFiltering, _discoveredTestCount, string.Join(", ", _selectedTestNames)); } else { - string warningMessage; - if (this.discoveredTestCount > 0) - { - // No tests that matched any of the given strings. - warningMessage = string.Format(CultureInfo.CurrentCulture, CommandLineResources.NoTestsAvailableAfterFiltering, this.discoveredTestCount, string.Join(", ", this.selectedTestNames)); - } - else - { - // No tests were discovered from the given sources. - warningMessage = string.Format(CultureInfo.CurrentUICulture, CommandLineResources.NoTestsAvailableInSources, string.Join(", ", this.commandLineOptions.Sources)); + // No tests were discovered from the given sources. + warningMessage = string.Format(CultureInfo.CurrentUICulture, CommandLineResources.NoTestsAvailableInSources, string.Join(", ", _commandLineOptions.Sources)); - if (string.IsNullOrEmpty(this.commandLineOptions.TestAdapterPath)) - { - warningMessage = string.Format(CultureInfo.CurrentCulture, CommandLineResources.StringFormatToJoinTwoStrings, warningMessage, CommandLineResources.SuggestTestAdapterPathIfNoTestsIsFound); - } + if (string.IsNullOrEmpty(_commandLineOptions.TestAdapterPath)) + { + warningMessage = string.Format(CultureInfo.CurrentCulture, CommandLineResources.StringFormatToJoinTwoStrings, warningMessage, CommandLineResources.SuggestTestAdapterPathIfNoTestsIsFound); } - - this.output.Warning(false, warningMessage); } + + Output.Warning(false, warningMessage); } + } - /// - /// Filter discovered tests and find matching tests from given search strings. - /// Any name of the test that can match multiple strings will be added only once. - /// - /// - /// - private void DiscoveryRequest_OnDiscoveredTests(object sender, DiscoveredTestsEventArgs args) + /// + /// Filter discovered tests and find matching tests from given search strings. + /// Any name of the test that can match multiple strings will be added only once. + /// + /// + /// + private void DiscoveryRequest_OnDiscoveredTests(object sender, DiscoveredTestsEventArgs args) + { + _discoveredTestCount += args.DiscoveredTestCases.Count(); + foreach (var testCase in args.DiscoveredTestCases) { - this.discoveredTestCount += args.DiscoveredTestCases.Count(); - foreach (var testCase in args.DiscoveredTestCases) + foreach (var nameCriteria in _selectedTestNames) { - foreach (var nameCriteria in this.selectedTestNames) + if (testCase.FullyQualifiedName.IndexOf(nameCriteria, StringComparison.OrdinalIgnoreCase) != -1) { - if (testCase.FullyQualifiedName.IndexOf(nameCriteria, StringComparison.OrdinalIgnoreCase) != -1) - { - this.selectedTestCases.Add(testCase); - - // If a testcase matched then a filter matched - so remove the filter from not found list - this.undiscoveredFilters.Remove(nameCriteria); - break; - } + _selectedTestCases.Add(testCase); + + // If a testcase matched then a filter matched - so remove the filter from not found list + _undiscoveredFilters.Remove(nameCriteria); + break; } } } + } - #endregion + #endregion - private class DiscoveryEventsRegistrar : ITestDiscoveryEventsRegistrar - { - private EventHandler discoveredTestsHandler; + private class DiscoveryEventsRegistrar : ITestDiscoveryEventsRegistrar + { + private readonly EventHandler _discoveredTestsHandler; - public DiscoveryEventsRegistrar(EventHandler discoveredTestsHandler) - { - this.discoveredTestsHandler = discoveredTestsHandler; - } + public DiscoveryEventsRegistrar(EventHandler discoveredTestsHandler) + { + _discoveredTestsHandler = discoveredTestsHandler; + } - public void LogWarning(string message) - { - ConsoleLogger.RaiseTestRunWarning(message); - } + public void LogWarning(string message) + { + ConsoleLogger.RaiseTestRunWarning(message); + } - public void RegisterDiscoveryEvents(IDiscoveryRequest discoveryRequest) - { - discoveryRequest.OnDiscoveredTests += this.discoveredTestsHandler; - } + public void RegisterDiscoveryEvents(IDiscoveryRequest discoveryRequest) + { + discoveryRequest.OnDiscoveredTests += _discoveredTestsHandler; + } - public void UnregisterDiscoveryEvents(IDiscoveryRequest discoveryRequest) - { - discoveryRequest.OnDiscoveredTests -= this.discoveredTestsHandler; - } + public void UnregisterDiscoveryEvents(IDiscoveryRequest discoveryRequest) + { + discoveryRequest.OnDiscoveredTests -= _discoveredTestsHandler; } + } - private class TestRunRequestEventsRegistrar : ITestRunEventsRegistrar + private class TestRunRequestEventsRegistrar : ITestRunEventsRegistrar + { + private readonly IOutput _output; + private readonly CommandLineOptions _commandLineOptions; + + public TestRunRequestEventsRegistrar(IOutput output, CommandLineOptions commandLineOptions) { - private IOutput output; - private CommandLineOptions commandLineOptions; + _output = output; + _commandLineOptions = commandLineOptions; + } - public TestRunRequestEventsRegistrar(IOutput output, CommandLineOptions commandLineOptions) - { - this.output = output; - this.commandLineOptions = commandLineOptions; - } + public void LogWarning(string message) + { + ConsoleLogger.RaiseTestRunWarning(message); + } - public void LogWarning(string message) - { - ConsoleLogger.RaiseTestRunWarning(message); - } + public void RegisterTestRunEvents(ITestRunRequest testRunRequest) + { + testRunRequest.OnRunCompletion += TestRunRequest_OnRunCompletion; + } - public void RegisterTestRunEvents(ITestRunRequest testRunRequest) - { - testRunRequest.OnRunCompletion += TestRunRequest_OnRunCompletion; - } + public void UnregisterTestRunEvents(ITestRunRequest testRunRequest) + { + testRunRequest.OnRunCompletion -= TestRunRequest_OnRunCompletion; + } - public void UnregisterTestRunEvents(ITestRunRequest testRunRequest) + /// + /// Handles the TestRunRequest complete event + /// + /// + /// RunCompletion args + private void TestRunRequest_OnRunCompletion(object sender, TestRunCompleteEventArgs e) + { + // If run is not aborted/canceled then check the count of executed tests. + // we need to check if there are any tests executed - to try show some help info to user to check for installed vsix extensions + if (!e.IsAborted && !e.IsCanceled) { - testRunRequest.OnRunCompletion -= TestRunRequest_OnRunCompletion; - } + var testsFoundInAnySource = e.TestRunStatistics != null && (e.TestRunStatistics.ExecutedTests > 0); - /// - /// Handles the TestRunRequest complete event - /// - /// - /// RunCompletion args - private void TestRunRequest_OnRunCompletion(object sender, TestRunCompleteEventArgs e) - { - // If run is not aborted/canceled then check the count of executed tests. - // we need to check if there are any tests executed - to try show some help info to user to check for installed vsix extensions - if (!e.IsAborted && !e.IsCanceled) + // Indicate the user to use testadapterpath command if there are no tests found + if (!testsFoundInAnySource && string.IsNullOrEmpty(CommandLineOptions.Instance.TestAdapterPath) && _commandLineOptions.TestCaseFilterValue == null) { - var testsFoundInAnySource = (e.TestRunStatistics == null) ? false : (e.TestRunStatistics.ExecutedTests > 0); - - // Indicate the user to use testadapterpath command if there are no tests found - if (!testsFoundInAnySource && string.IsNullOrEmpty(CommandLineOptions.Instance.TestAdapterPath) && this.commandLineOptions.TestCaseFilterValue == null) - { - this.output.Warning(false, CommandLineResources.SuggestTestAdapterPathIfNoTestsIsFound); - } + _output.Warning(false, CommandLineResources.SuggestTestAdapterPathIfNoTestsIsFound); } } } diff --git a/src/vstest.console/Processors/RunTestsArgumentProcessor.cs b/src/vstest.console/Processors/RunTestsArgumentProcessor.cs index 4e624019f2..45ad00adb7 100644 --- a/src/vstest.console/Processors/RunTestsArgumentProcessor.cs +++ b/src/vstest.console/Processors/RunTestsArgumentProcessor.cs @@ -1,268 +1,262 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Diagnostics.Contracts; +using System.Globalization; +using System.Linq; + +using Client.RequestHelper; +using Internal; +using TestPlatformHelpers; +using Common; +using Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.Utilities; + +using CommandLineResources = Resources.Resources; + +internal class RunTestsArgumentProcessor : IArgumentProcessor { - using System; - using System.Diagnostics.Contracts; - using System.Globalization; - using System.Linq; - - using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; - using Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.Utilities; - - using CommandLineResources = Resources.Resources; - - internal class RunTestsArgumentProcessor : IArgumentProcessor - { - public const string CommandName = "/RunTests"; + public const string CommandName = "/RunTests"; - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - public Lazy Metadata + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new RunTestsArgumentProcessorCapabilities()); - } - return this.metadata; + _metadata = new Lazy(() => new RunTestsArgumentProcessorCapabilities()); } + return _metadata; } + } - public Lazy Executor + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => + _executor = new Lazy(() => new RunTestsArgumentExecutor( CommandLineOptions.Instance, RunSettingsManager.Instance, TestRequestManager.Instance, ConsoleOutput.Instance)); - } - - return this.executor; - } - set - { - this.executor = value; } + + return _executor; + } + set + { + _executor = value; } } +} - internal class RunTestsArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => RunTestsArgumentProcessor.CommandName; +internal class RunTestsArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => RunTestsArgumentProcessor.CommandName; - public override bool AllowMultiple => false; + public override bool AllowMultiple => false; - public override bool IsAction => true; + public override bool IsAction => true; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; - public override string HelpContentResourceName => CommandLineResources.RunTestsArgumentHelp; + public override string HelpContentResourceName => CommandLineResources.RunTestsArgumentHelp; - public override HelpContentPriority HelpPriority => HelpContentPriority.RunTestsArgumentProcessorHelpPriority; + public override HelpContentPriority HelpPriority => HelpContentPriority.RunTestsArgumentProcessorHelpPriority; - public override bool IsSpecialCommand => true; + public override bool IsSpecialCommand => true; - public override bool AlwaysExecute => false; - } + public override bool AlwaysExecute => false; +} - internal class RunTestsArgumentExecutor : IArgumentExecutor +internal class RunTestsArgumentExecutor : IArgumentExecutor +{ + #region Fields + + /// + /// Used for getting tests to run. + /// + private readonly CommandLineOptions _commandLineOptions; + + /// + /// The instance of testPlatforms + /// + private readonly ITestRequestManager _testRequestManager; + + /// + /// Used for sending discovery messages. + /// + internal IOutput Output; + + /// + /// Settings manager to get currently active settings. + /// + private readonly IRunSettingsProvider _runSettingsManager; + + /// + /// Registers and Unregisters for test run events before and after test run + /// + private readonly ITestRunEventsRegistrar _testRunEventsRegistrar; + + /// + /// Shows the number of tests which were executed + /// + private static long s_numberOfExecutedTests; + + #endregion + + #region Constructor + + /// + /// Default constructor. + /// + public RunTestsArgumentExecutor( + CommandLineOptions commandLineOptions, + IRunSettingsProvider runSettingsProvider, + ITestRequestManager testRequestManager, + IOutput output) { - #region Fields - - /// - /// Used for getting tests to run. - /// - private CommandLineOptions commandLineOptions; + Contract.Requires(commandLineOptions != null); - /// - /// The instance of testPlatforms - /// - private ITestRequestManager testRequestManager; - - /// - /// Used for sending discovery messages. - /// - internal IOutput output; - - /// - /// Settings manager to get currently active settings. - /// - private IRunSettingsProvider runSettingsManager; + _commandLineOptions = commandLineOptions; + _runSettingsManager = runSettingsProvider; + _testRequestManager = testRequestManager; + Output = output; + _testRunEventsRegistrar = new TestRunRequestEventsRegistrar(Output, _commandLineOptions); + } - /// - /// Registers and Unregisters for test run events before and after test run - /// - private ITestRunEventsRegistrar testRunEventsRegistrar; - - /// - /// Shows the number of tests which were executed - /// - private static long numberOfExecutedTests; + #endregion - #endregion + public void Initialize(string argument) + { + // Nothing to do. + } - #region Constructor + /// + /// Execute all of the tests. + /// + public ArgumentProcessorResult Execute() + { + Contract.Assert(_commandLineOptions != null); + Contract.Assert(!string.IsNullOrWhiteSpace(_runSettingsManager?.ActiveRunSettings?.SettingsXml)); - /// - /// Default constructor. - /// - public RunTestsArgumentExecutor( - CommandLineOptions commandLineOptions, - IRunSettingsProvider runSettingsProvider, - ITestRequestManager testRequestManager, - IOutput output) + if (_commandLineOptions.IsDesignMode) { - Contract.Requires(commandLineOptions != null); - - this.commandLineOptions = commandLineOptions; - this.runSettingsManager = runSettingsProvider; - this.testRequestManager = testRequestManager; - this.output = output; - this.testRunEventsRegistrar = new TestRunRequestEventsRegistrar(this.output, this.commandLineOptions); + // Do not attempt execution in case of design mode. Expect execution to happen + // via the design mode client. + return ArgumentProcessorResult.Success; } - #endregion - - public void Initialize(string argument) + // Ensure a test source file was provided + var anySource = _commandLineOptions.Sources.FirstOrDefault(); + if (anySource == null) { - // Nothing to do. + throw new CommandLineException(string.Format(CultureInfo.CurrentUICulture, CommandLineResources.MissingTestSourceFile)); } - /// - /// Execute all of the tests. - /// - public ArgumentProcessorResult Execute() + Output.WriteLine(CommandLineResources.StartingExecution, OutputLevel.Information); + if (!string.IsNullOrEmpty(EqtTrace.LogFile)) { - Contract.Assert(this.commandLineOptions != null); - Contract.Assert(!string.IsNullOrWhiteSpace(this.runSettingsManager?.ActiveRunSettings?.SettingsXml)); - - if (this.commandLineOptions.IsDesignMode) - { - // Do not attempt execution in case of design mode. Expect execution to happen - // via the design mode client. - return ArgumentProcessorResult.Success; - } - - // Ensure a test source file was provided - var anySource = this.commandLineOptions.Sources.FirstOrDefault(); - if (anySource == null) - { - throw new CommandLineException(string.Format(CultureInfo.CurrentUICulture, CommandLineResources.MissingTestSourceFile)); - } - - this.output.WriteLine(CommandLineResources.StartingExecution, OutputLevel.Information); - if (!string.IsNullOrEmpty(EqtTrace.LogFile)) - { - this.output.Information(false, CommandLineResources.VstestDiagLogOutputPath, EqtTrace.LogFile); - } + Output.Information(false, CommandLineResources.VstestDiagLogOutputPath, EqtTrace.LogFile); + } - var runSettings = this.runSettingsManager.ActiveRunSettings.SettingsXml; + var runSettings = _runSettingsManager.ActiveRunSettings.SettingsXml; - if (this.commandLineOptions.Sources.Any()) - { - this.RunTests(runSettings); - } + if (_commandLineOptions.Sources.Any()) + { + RunTests(runSettings); + } - bool treatNoTestsAsError = RunSettingsUtilities.GetTreatNoTestsAsError(runSettings); + bool treatNoTestsAsError = RunSettingsUtilities.GetTreatNoTestsAsError(runSettings); - if (treatNoTestsAsError && numberOfExecutedTests == 0) - { - return ArgumentProcessorResult.Fail; - } + return treatNoTestsAsError && s_numberOfExecutedTests == 0 ? ArgumentProcessorResult.Fail : ArgumentProcessorResult.Success; + } - return ArgumentProcessorResult.Success; + private void RunTests(string runSettings) + { + // create/start test run + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("RunTestsArgumentProcessor:Execute: Test run is starting."); } - private void RunTests(string runSettings) + if (EqtTrace.IsVerboseEnabled) { - // create/start test run - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("RunTestsArgumentProcessor:Execute: Test run is starting."); - } - - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose("RunTestsArgumentProcessor:Execute: Queuing Test run."); - } + EqtTrace.Verbose("RunTestsArgumentProcessor:Execute: Queuing Test run."); + } - // for command line keep alive is always false. - // for Windows Store apps it should be false, as Windows Store apps executor should terminate after finishing the test execution. - var keepAlive = false; + // for command line keep alive is always false. + // for Windows Store apps it should be false, as Windows Store apps executor should terminate after finishing the test execution. + var keepAlive = false; - var runRequestPayload = new TestRunRequestPayload() { Sources = this.commandLineOptions.Sources.ToList(), RunSettings = runSettings, KeepAlive = keepAlive, TestPlatformOptions= new TestPlatformOptions() { TestCaseFilter = this.commandLineOptions.TestCaseFilterValue } }; - this.testRequestManager.RunTests(runRequestPayload, null, this.testRunEventsRegistrar, Constants.DefaultProtocolConfig); + var runRequestPayload = new TestRunRequestPayload() { Sources = _commandLineOptions.Sources.ToList(), RunSettings = runSettings, KeepAlive = keepAlive, TestPlatformOptions = new TestPlatformOptions() { TestCaseFilter = _commandLineOptions.TestCaseFilterValue } }; + _testRequestManager.RunTests(runRequestPayload, null, _testRunEventsRegistrar, Constants.DefaultProtocolConfig); - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("RunTestsArgumentProcessor:Execute: Test run is completed."); - } + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("RunTestsArgumentProcessor:Execute: Test run is completed."); } + } - private class TestRunRequestEventsRegistrar : ITestRunEventsRegistrar + private class TestRunRequestEventsRegistrar : ITestRunEventsRegistrar + { + private readonly IOutput _output; + private readonly CommandLineOptions _commandLineOptions; + + public TestRunRequestEventsRegistrar(IOutput output, CommandLineOptions commandLineOptions) { - private IOutput output; - private CommandLineOptions commandLineOptions; + _output = output; + _commandLineOptions = commandLineOptions; + } - public TestRunRequestEventsRegistrar(IOutput output, CommandLineOptions commandLineOptions) - { - this.output = output; - this.commandLineOptions = commandLineOptions; - } + public void LogWarning(string message) + { + ConsoleLogger.RaiseTestRunWarning(message); + } - public void LogWarning(string message) - { - ConsoleLogger.RaiseTestRunWarning(message); - } + public void RegisterTestRunEvents(ITestRunRequest testRunRequest) + { + testRunRequest.OnRunCompletion += TestRunRequest_OnRunCompletion; + } - public void RegisterTestRunEvents(ITestRunRequest testRunRequest) - { - testRunRequest.OnRunCompletion += TestRunRequest_OnRunCompletion; - } + public void UnregisterTestRunEvents(ITestRunRequest testRunRequest) + { + testRunRequest.OnRunCompletion -= TestRunRequest_OnRunCompletion; + } - public void UnregisterTestRunEvents(ITestRunRequest testRunRequest) + /// + /// Handles the TestRunRequest complete event + /// + /// + /// RunCompletion args + private void TestRunRequest_OnRunCompletion(object sender, TestRunCompleteEventArgs e) + { + // If run is not aborted/canceled then check the count of executed tests. + // we need to check if there are any tests executed - to try show some help info to user to check for installed vsix extensions + if (!e.IsAborted && !e.IsCanceled) { - testRunRequest.OnRunCompletion -= TestRunRequest_OnRunCompletion; - } + s_numberOfExecutedTests = e.TestRunStatistics.ExecutedTests; + var testsFoundInAnySource = e.TestRunStatistics != null && (e.TestRunStatistics.ExecutedTests > 0); - /// - /// Handles the TestRunRequest complete event - /// - /// - /// RunCompletion args - private void TestRunRequest_OnRunCompletion(object sender, TestRunCompleteEventArgs e) - { - // If run is not aborted/canceled then check the count of executed tests. - // we need to check if there are any tests executed - to try show some help info to user to check for installed vsix extensions - if (!e.IsAborted && !e.IsCanceled) + // Indicate the user to use test adapter path command if there are no tests found + if (!testsFoundInAnySource && string.IsNullOrEmpty(CommandLineOptions.Instance.TestAdapterPath) && _commandLineOptions.TestCaseFilterValue == null) { - numberOfExecutedTests = e.TestRunStatistics.ExecutedTests; - var testsFoundInAnySource = (e.TestRunStatistics == null) ? false : (e.TestRunStatistics.ExecutedTests > 0); - - // Indicate the user to use test adapter path command if there are no tests found - if (!testsFoundInAnySource && string.IsNullOrEmpty(CommandLineOptions.Instance.TestAdapterPath) && this.commandLineOptions.TestCaseFilterValue == null) - { - this.output.Warning(false, CommandLineResources.SuggestTestAdapterPathIfNoTestsIsFound); - } + _output.Warning(false, CommandLineResources.SuggestTestAdapterPathIfNoTestsIsFound); } } } } -} +} \ No newline at end of file diff --git a/src/vstest.console/Processors/TestAdapterPathArgumentProcessor.cs b/src/vstest.console/Processors/TestAdapterPathArgumentProcessor.cs index 120544e1c8..f7720e693e 100644 --- a/src/vstest.console/Processors/TestAdapterPathArgumentProcessor.cs +++ b/src/vstest.console/Processors/TestAdapterPathArgumentProcessor.cs @@ -1,241 +1,217 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.Contracts; - using System.Globalization; - using System.IO; - using System.Linq; - - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - /// - /// Allows the user to specify a path to load custom adapters from. - /// - internal class TestAdapterPathArgumentProcessor : IArgumentProcessor - { - #region Constants +using System; +using System.Collections.Generic; +using System.Diagnostics.Contracts; +using System.Globalization; +using System.IO; +using System.Linq; - /// - /// The name of the command line argument that the ListTestsArgumentExecutor handles. - /// - public const string CommandName = "/TestAdapterPath"; +using Common; +using Common.Interfaces; - #endregion +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - private Lazy metadata; +using CommandLineResources = Resources.Resources; - private Lazy executor; +/// +/// Allows the user to specify a path to load custom adapters from. +/// +internal class TestAdapterPathArgumentProcessor : IArgumentProcessor +{ + #region Constants - /// - /// Gets the metadata. - /// - public Lazy Metadata - { - get - { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new TestAdapterPathArgumentProcessorCapabilities()); - } + /// + /// The name of the command line argument that the ListTestsArgumentExecutor handles. + /// + public const string CommandName = "/TestAdapterPath"; - return this.metadata; - } - } + #endregion - /// - /// Gets or sets the executor. - /// - public Lazy Executor - { - get - { - if (this.executor == null) - { - this.executor = new Lazy(() => new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, ConsoleOutput.Instance, new FileHelper())); - } + private Lazy _metadata; - return this.executor; - } + private Lazy _executor; - set - { - this.executor = value; - } - } - } + /// + /// Gets the metadata. + /// + public Lazy Metadata + => _metadata ??= new Lazy(() => new TestAdapterPathArgumentProcessorCapabilities()); /// - /// The argument capabilities. + /// Gets or sets the executor. /// - internal class TestAdapterPathArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities + public Lazy Executor { - public override string CommandName => TestAdapterPathArgumentProcessor.CommandName; + get => _executor ??= new Lazy(() => + new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, + ConsoleOutput.Instance, new FileHelper())); + + set => _executor = value; + } +} - public override bool AllowMultiple => true; +/// +/// The argument capabilities. +/// +internal class TestAdapterPathArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => TestAdapterPathArgumentProcessor.CommandName; - public override bool IsAction => false; + public override bool AllowMultiple => true; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.TestAdapterPath; + public override bool IsAction => false; - public override string HelpContentResourceName => CommandLineResources.TestAdapterPathHelp; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.TestAdapterPath; - public override HelpContentPriority HelpPriority => HelpContentPriority.TestAdapterPathArgumentProcessorHelpPriority; - } + public override string HelpContentResourceName => CommandLineResources.TestAdapterPathHelp; + + public override HelpContentPriority HelpPriority => HelpContentPriority.TestAdapterPathArgumentProcessorHelpPriority; +} + +/// +/// The argument executor. +/// +internal class TestAdapterPathArgumentExecutor : IArgumentExecutor +{ + #region Fields /// - /// The argument executor. + /// Used for getting sources. /// - internal class TestAdapterPathArgumentExecutor : IArgumentExecutor - { - #region Fields - - /// - /// Used for getting sources. - /// - private CommandLineOptions commandLineOptions; - - /// - /// Run settings provider. - /// - private IRunSettingsProvider runSettingsManager; - - /// - /// Used for sending output. - /// - private IOutput output; - - /// - /// For file related operation - /// - private IFileHelper fileHelper; - - /// - /// Separators for multiple paths in argument. - /// - private readonly char[] argumentSeparators = new[] { ';' }; - - #endregion - - #region Constructor - - /// - /// Default constructor. - /// - /// The options. - /// The test platform - public TestAdapterPathArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsManager, IOutput output, IFileHelper fileHelper) - { - Contract.Requires(options != null); + private readonly CommandLineOptions _commandLineOptions; - this.commandLineOptions = options; - this.runSettingsManager = runSettingsManager; - this.output = output; - this.fileHelper = fileHelper; - } + /// + /// Run settings provider. + /// + private readonly IRunSettingsProvider _runSettingsManager; - #endregion + /// + /// Used for sending output. + /// + private readonly IOutput _output; - #region IArgumentExecutor + /// + /// For file related operation + /// + private readonly IFileHelper _fileHelper; - /// - /// Initializes with the argument that was provided with the command. - /// - /// Argument that was provided with the command. - public void Initialize(string argument) - { - string invalidAdapterPathArgument = argument; + /// + /// Separators for multiple paths in argument. + /// + private readonly char[] _argumentSeparators = new[] { ';' }; - if (string.IsNullOrWhiteSpace(argument)) - { - throw new CommandLineException( - string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestAdapterPathValueRequired)); - } + #endregion - string customAdaptersPath; + #region Constructor - try - { - var testAdapterPaths = new List(); - var testAdapterFullPaths = new List(); + /// + /// Default constructor. + /// + /// The options. + /// The test platform + public TestAdapterPathArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsManager, IOutput output, IFileHelper fileHelper) + { + Contract.Requires(options != null); - // VSTS task add double quotes around TestAdapterpath. For example if user has given TestAdapter path C:\temp, - // Then VSTS task will add TestAdapterPath as "/TestAdapterPath:\"C:\Temp\"". - // Remove leading and trailing ' " ' chars... - argument = argument.Trim().Trim(new char[] { '\"' }); + _commandLineOptions = options; + _runSettingsManager = runSettingsManager; + _output = output; + _fileHelper = fileHelper; + } - // Get test adapter paths from RunSettings. - var testAdapterPathsInRunSettings = this.runSettingsManager.QueryRunSettingsNode("RunConfiguration.TestAdaptersPaths"); + #endregion - if (!string.IsNullOrWhiteSpace(testAdapterPathsInRunSettings)) - { - testAdapterPaths.AddRange(SplitPaths(testAdapterPathsInRunSettings)); - } + #region IArgumentExecutor - testAdapterPaths.AddRange(SplitPaths(argument)); + /// + /// Initializes with the argument that was provided with the command. + /// + /// Argument that was provided with the command. + public void Initialize(string argument) + { + string invalidAdapterPathArgument = argument; - foreach (var testadapterPath in testAdapterPaths) - { - // TestAdaptersPaths could contain environment variables - var testAdapterFullPath = Path.GetFullPath(Environment.ExpandEnvironmentVariables(testadapterPath)); + if (string.IsNullOrWhiteSpace(argument)) + { + throw new CommandLineException( + string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestAdapterPathValueRequired)); + } - if (!this.fileHelper.DirectoryExists(testAdapterFullPath)) - { - invalidAdapterPathArgument = testadapterPath; - throw new DirectoryNotFoundException(CommandLineResources.TestAdapterPathDoesNotExist); - } + string customAdaptersPath; - testAdapterFullPaths.Add(testAdapterFullPath); - } + try + { + var testAdapterPaths = new List(); + var testAdapterFullPaths = new List(); - customAdaptersPath = string.Join(";", testAdapterFullPaths.Distinct().ToArray()); + // VSTS task add double quotes around TestAdapterpath. For example if user has given TestAdapter path C:\temp, + // Then VSTS task will add TestAdapterPath as "/TestAdapterPath:\"C:\Temp\"". + // Remove leading and trailing ' " ' chars... + argument = argument.Trim().Trim(new char[] { '\"' }); - this.runSettingsManager.UpdateRunSettingsNode("RunConfiguration.TestAdaptersPaths", customAdaptersPath); - } - catch (Exception e) + // Get test adapter paths from RunSettings. + var testAdapterPathsInRunSettings = _runSettingsManager.QueryRunSettingsNode("RunConfiguration.TestAdaptersPaths"); + + if (!string.IsNullOrWhiteSpace(testAdapterPathsInRunSettings)) { - throw new CommandLineException( - string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidTestAdapterPathCommand, invalidAdapterPathArgument, e.Message)); + testAdapterPaths.AddRange(SplitPaths(testAdapterPathsInRunSettings)); } - this.commandLineOptions.TestAdapterPath = customAdaptersPath; - } + testAdapterPaths.AddRange(SplitPaths(argument)); - /// - /// Splits provided paths into array. - /// - /// Source paths joined by semicolons. - /// Paths. - private string[] SplitPaths(string paths) - { - if (string.IsNullOrWhiteSpace(paths)) + foreach (var testAdapterPath in testAdapterPaths) { - return new string[] { }; + // TestAdaptersPaths could contain environment variables + var testAdapterFullPath = Path.GetFullPath(Environment.ExpandEnvironmentVariables(testAdapterPath)); + + if (!_fileHelper.DirectoryExists(testAdapterFullPath)) + { + invalidAdapterPathArgument = testAdapterPath; + throw new DirectoryNotFoundException(CommandLineResources.TestAdapterPathDoesNotExist); + } + + testAdapterFullPaths.Add(testAdapterFullPath); } - return paths.Split(argumentSeparators, StringSplitOptions.RemoveEmptyEntries); - } + customAdaptersPath = string.Join(";", testAdapterFullPaths.Distinct().ToArray()); - /// - /// Executes the argument processor. - /// - /// The . - public ArgumentProcessorResult Execute() + _runSettingsManager.UpdateRunSettingsNode("RunConfiguration.TestAdaptersPaths", customAdaptersPath); + } + catch (Exception e) { - // Nothing to do since we updated the parameter during initialize parameter - return ArgumentProcessorResult.Success; + throw new CommandLineException( + string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidTestAdapterPathCommand, invalidAdapterPathArgument, e.Message)); } - #endregion + _commandLineOptions.TestAdapterPath = customAdaptersPath; + } + + /// + /// Splits provided paths into array. + /// + /// Source paths joined by semicolons. + /// Paths. + private string[] SplitPaths(string paths) + { + return string.IsNullOrWhiteSpace(paths) ? (new string[] { }) : paths.Split(_argumentSeparators, StringSplitOptions.RemoveEmptyEntries); + } + + /// + /// Executes the argument processor. + /// + /// The . + public ArgumentProcessorResult Execute() + { + // Nothing to do since we updated the parameter during initialize parameter + return ArgumentProcessorResult.Success; } + + #endregion } \ No newline at end of file diff --git a/src/vstest.console/Processors/TestCaseFilterArgumentProcessor.cs b/src/vstest.console/Processors/TestCaseFilterArgumentProcessor.cs index 8eb75e0f05..6ed28c2908 100644 --- a/src/vstest.console/Processors/TestCaseFilterArgumentProcessor.cs +++ b/src/vstest.console/Processors/TestCaseFilterArgumentProcessor.cs @@ -1,149 +1,150 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Diagnostics.Contracts; +using System.Globalization; + +using CommandLine; + +using CommandLineResources = Resources.Resources; + +/// +/// Argument Executor for the "/TestCaseFilter" command line argument. +/// +internal class TestCaseFilterArgumentProcessor : IArgumentProcessor { - using System; - using System.Diagnostics.Contracts; - using System.Globalization; - using Microsoft.VisualStudio.TestPlatform.CommandLine; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; + #region Constants /// - /// Argument Executor for the "/TestCaseFilter" command line argument. + /// The name of the command line argument that the TestCaseFilterArgumentExecutor handles. /// - internal class TestCaseFilterArgumentProcessor : IArgumentProcessor - { - #region Constants - - /// - /// The name of the command line argument that the TestCaseFilterArgumentExecutor handles. - /// - public const string CommandName = "/TestCaseFilter"; + public const string CommandName = "/TestCaseFilter"; - #endregion + #endregion - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - /// - /// Gets the metadata. - /// - public Lazy Metadata + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new TestCaseFilterArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new TestCaseFilterArgumentProcessorCapabilities()); } + + return _metadata; } + } - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => new TestCaseFilterArgumentExecutor(CommandLineOptions.Instance)); - } - - return this.executor; + _executor = new Lazy(() => new TestCaseFilterArgumentExecutor(CommandLineOptions.Instance)); } - set - { - this.executor = value; - } + return _executor; + } + + set + { + _executor = value; } } +} - internal class TestCaseFilterArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => TestCaseFilterArgumentProcessor.CommandName; +internal class TestCaseFilterArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => TestCaseFilterArgumentProcessor.CommandName; - public override bool AllowMultiple => false; + public override bool AllowMultiple => false; - public override bool IsAction => false; + public override bool IsAction => false; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; - public override string HelpContentResourceName => CommandLineResources.TestCaseFilterArgumentHelp; + public override string HelpContentResourceName => CommandLineResources.TestCaseFilterArgumentHelp; - public override HelpContentPriority HelpPriority => HelpContentPriority.TestCaseFilterArgumentProcessorHelpPriority; - } + public override HelpContentPriority HelpPriority => HelpContentPriority.TestCaseFilterArgumentProcessorHelpPriority; +} + +/// +/// Argument Executor for the "/TestCaseFilter" command line argument. +/// +internal class TestCaseFilterArgumentExecutor : IArgumentExecutor +{ + #region Fields /// - /// Argument Executor for the "/TestCaseFilter" command line argument. + /// Used for getting sources. /// - internal class TestCaseFilterArgumentExecutor : IArgumentExecutor - { - #region Fields + private readonly CommandLineOptions _commandLineOptions; - /// - /// Used for getting sources. - /// - private CommandLineOptions commandLineOptions; + #endregion - #endregion + #region Constructor - #region Constructor + /// + /// Default constructor. + /// + /// + /// The options. + /// + public TestCaseFilterArgumentExecutor(CommandLineOptions options) + { + Contract.Requires(options != null); + _commandLineOptions = options; + } + #endregion - /// - /// Default constructor. - /// - /// - /// The options. - /// - public TestCaseFilterArgumentExecutor(CommandLineOptions options) - { - Contract.Requires(options != null); - this.commandLineOptions = options; - } - #endregion + #region IArgumentExecutor - #region IArgumentExecutor + /// + /// Initializes with the argument that was provided with the command. + /// + /// Argument that was provided with the command. + public void Initialize(string argument) + { + var defaultFilter = _commandLineOptions.TestCaseFilterValue; + var hasDefaultFilter = !string.IsNullOrWhiteSpace(defaultFilter); - /// - /// Initializes with the argument that was provided with the command. - /// - /// Argument that was provided with the command. - public void Initialize(string argument) + if (!hasDefaultFilter && string.IsNullOrWhiteSpace(argument)) { - var defaultFilter = this.commandLineOptions.TestCaseFilterValue; - var hasDefaultFilter = !string.IsNullOrWhiteSpace(defaultFilter); - - if (!hasDefaultFilter && string.IsNullOrWhiteSpace(argument)) - { - throw new CommandLineException(string.Format(CultureInfo.CurrentUICulture, CommandLineResources.TestCaseFilterValueRequired)); - } - - if (!hasDefaultFilter) - { - this.commandLineOptions.TestCaseFilterValue = argument; - } - else - { - // Merge default filter an provided filter by AND operator to have both the default filter and custom filter applied. - this.commandLineOptions.TestCaseFilterValue = $"({defaultFilter})&({argument})"; - } + throw new CommandLineException(string.Format(CultureInfo.CurrentUICulture, CommandLineResources.TestCaseFilterValueRequired)); } - /// - /// The TestCaseFilter is already set, return success. - /// - /// The Success - public ArgumentProcessorResult Execute() + if (!hasDefaultFilter) + { + _commandLineOptions.TestCaseFilterValue = argument; + } + else { - return ArgumentProcessorResult.Success; + // Merge default filter an provided filter by AND operator to have both the default filter and custom filter applied. + _commandLineOptions.TestCaseFilterValue = $"({defaultFilter})&({argument})"; } - #endregion } -} + + /// + /// The TestCaseFilter is already set, return success. + /// + /// The Success + public ArgumentProcessorResult Execute() + { + return ArgumentProcessorResult.Success; + } + #endregion +} \ No newline at end of file diff --git a/src/vstest.console/Processors/TestSourceArgumentProcessor.cs b/src/vstest.console/Processors/TestSourceArgumentProcessor.cs index f5f7fdfce0..2effc8df4f 100644 --- a/src/vstest.console/Processors/TestSourceArgumentProcessor.cs +++ b/src/vstest.console/Processors/TestSourceArgumentProcessor.cs @@ -1,133 +1,133 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Diagnostics.Contracts; + +using CommandLine; + +/// +/// Argument Executor which handles adding the source provided to the TestManager. +/// +internal class TestSourceArgumentProcessor : IArgumentProcessor { - using System; - using System.Diagnostics.Contracts; - using Microsoft.VisualStudio.TestPlatform.CommandLine; + #region Constants /// - /// Argument Executor which handles adding the source provided to the TestManager. + /// The command name. /// - internal class TestSourceArgumentProcessor : IArgumentProcessor - { - #region Constants + public const string CommandName = "/TestSource"; - /// - /// The command name. - /// - public const string CommandName = "/TestSource"; + #endregion - #endregion + private Lazy _metadata; - private Lazy metadata; + private Lazy _executor; - private Lazy executor; - - /// - /// Gets the metadata. - /// - public Lazy Metadata + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new TestSourceArgumentProcessorCapabilities()); - } - return this.metadata; + _metadata = new Lazy(() => new TestSourceArgumentProcessorCapabilities()); } + return _metadata; } + } - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => new TestSourceArgumentExecutor(CommandLineOptions.Instance)); - } - - return this.executor; - } - set - { - this.executor = value; + _executor = new Lazy(() => new TestSourceArgumentExecutor(CommandLineOptions.Instance)); } + + return _executor; + } + set + { + _executor = value; } } +} - /// - /// The test source argument processor capabilities. - /// - internal class TestSourceArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => TestSourceArgumentProcessor.CommandName; +/// +/// The test source argument processor capabilities. +/// +internal class TestSourceArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => TestSourceArgumentProcessor.CommandName; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; - public override bool IsSpecialCommand => true; - } + public override bool IsSpecialCommand => true; +} + +/// +/// Argument Executor which handles adding the source provided to the TestManager. +/// +internal class TestSourceArgumentExecutor : IArgumentExecutor +{ + #region Fields /// - /// Argument Executor which handles adding the source provided to the TestManager. + /// Used for adding sources to the test manager. /// - internal class TestSourceArgumentExecutor : IArgumentExecutor - { - #region Fields + private readonly CommandLineOptions _testSources; - /// - /// Used for adding sources to the test manager. - /// - private CommandLineOptions testSources; + #endregion - #endregion + #region Constructor - #region Constructor - - /// - /// Default constructor. - /// - /// - /// The test Sources. - /// - public TestSourceArgumentExecutor(CommandLineOptions testSources) - { - Contract.Requires(testSources != null); - this.testSources = testSources; - } + /// + /// Default constructor. + /// + /// + /// The test Sources. + /// + public TestSourceArgumentExecutor(CommandLineOptions testSources) + { + Contract.Requires(testSources != null); + _testSources = testSources; + } - #endregion + #endregion - #region IArgumentExecutor + #region IArgumentExecutor - /// - /// Initializes with the argument that was provided with the command. - /// - /// Argument that was provided with the command. - public void Initialize(string argument) - { - Contract.Assert(this.testSources != null); - this.testSources.AddSource(argument); - } + /// + /// Initializes with the argument that was provided with the command. + /// + /// Argument that was provided with the command. + public void Initialize(string argument) + { + Contract.Assert(_testSources != null); + _testSources.AddSource(argument); + } - /// - /// Executes the argument processor. - /// - /// - /// The . - /// - public ArgumentProcessorResult Execute() - { - // Nothing to do. Our work was done during initialize. - return ArgumentProcessorResult.Success; - } + /// + /// Executes the argument processor. + /// + /// + /// The . + /// + public ArgumentProcessorResult Execute() + { + // Nothing to do. Our work was done during initialize. + return ArgumentProcessorResult.Success; + } - #endregion + #endregion - } -} +} \ No newline at end of file diff --git a/src/vstest.console/Processors/UseVsixExtensionsArgumentProcessor.cs b/src/vstest.console/Processors/UseVsixExtensionsArgumentProcessor.cs index b3a29e6ee7..840690f346 100644 --- a/src/vstest.console/Processors/UseVsixExtensionsArgumentProcessor.cs +++ b/src/vstest.console/Processors/UseVsixExtensionsArgumentProcessor.cs @@ -1,138 +1,136 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; - using System.Globalization; - using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; - using Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using System.Globalization; +using Client.RequestHelper; +using TestPlatformHelpers; +using Common.ExtensionFramework; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities; +using CommandLineResources = Resources.Resources; +using Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities; + +/// +/// The argument processor for initializing the vsix based adapters. +/// +internal class UseVsixExtensionsArgumentProcessor : IArgumentProcessor +{ + #region Constants /// - /// The argument processor for initializing the vsix based adapters. + /// The name of command /// - internal class UseVsixExtensionsArgumentProcessor : IArgumentProcessor - { - #region Constants - - /// - /// The name of command - /// - public const string CommandName = "/UseVsixExtensions"; + public const string CommandName = "/UseVsixExtensions"; - #endregion + #endregion - private Lazy metadata; + private Lazy _metadata; - private Lazy executor; + private Lazy _executor; - /// - /// Gets the metadata. - /// - public Lazy Metadata + /// + /// Gets the metadata. + /// + public Lazy Metadata + { + get { - get + if (_metadata == null) { - if (this.metadata == null) - { - this.metadata = new Lazy(() => new UseVsixExtensionsArgumentProcessorCapabilities()); - } - - return this.metadata; + _metadata = new Lazy(() => new UseVsixExtensionsArgumentProcessorCapabilities()); } + + return _metadata; } + } - /// - /// Gets or sets the executor. - /// - public Lazy Executor + /// + /// Gets or sets the executor. + /// + public Lazy Executor + { + get { - get + if (_executor == null) { - if (this.executor == null) - { - this.executor = new Lazy(() => new UseVsixExtensionsArgumentExecutor(CommandLineOptions.Instance, TestRequestManager.Instance, new VSExtensionManager(), ConsoleOutput.Instance)); - } - - return this.executor; + _executor = new Lazy(() => new UseVsixExtensionsArgumentExecutor(CommandLineOptions.Instance, TestRequestManager.Instance, new VSExtensionManager(), ConsoleOutput.Instance)); } - set - { - this.executor = value; - } + return _executor; + } + + set + { + _executor = value; } } +} - /// - internal class UseVsixExtensionsArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities - { - public override string CommandName => UseVsixExtensionsArgumentProcessor.CommandName; +/// +internal class UseVsixExtensionsArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => UseVsixExtensionsArgumentProcessor.CommandName; - public override bool AllowMultiple => false; + public override bool AllowMultiple => false; - public override bool IsAction => false; + public override bool IsAction => false; - public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.AutoUpdateRunSettings; - // Commenting out the help for this processor as it on the deprecation path. - // public override string HelpContentResourceName => CommandLineResources.UseVsixExtensionsHelp; - // public override HelpContentPriority HelpPriority => HelpContentPriority.UseVsixArgumentProcessorHelpPriority; - } + // Commenting out the help for this processor as it on the deprecation path. + // public override string HelpContentResourceName => CommandLineResources.UseVsixExtensionsHelp; + // public override HelpContentPriority HelpPriority => HelpContentPriority.UseVsixArgumentProcessorHelpPriority; +} - /// - /// The use vsix extensions argument executor. - /// - internal class UseVsixExtensionsArgumentExecutor : IArgumentExecutor +/// +/// The use vsix extensions argument executor. +/// +internal class UseVsixExtensionsArgumentExecutor : IArgumentExecutor +{ + private readonly CommandLineOptions _commandLineOptions; + private readonly ITestRequestManager _testRequestManager; + private readonly IVSExtensionManager _extensionManager; + private readonly IOutput _output; + + internal UseVsixExtensionsArgumentExecutor(CommandLineOptions commandLineOptions, ITestRequestManager testRequestManager, IVSExtensionManager extensionManager, IOutput output) { - private CommandLineOptions commandLineOptions; - private ITestRequestManager testRequestManager; - private IVSExtensionManager extensionManager; - private IOutput output; + _commandLineOptions = commandLineOptions; + _testRequestManager = testRequestManager; + _extensionManager = extensionManager; + _output = output; + } - internal UseVsixExtensionsArgumentExecutor(CommandLineOptions commandLineOptions, ITestRequestManager testRequestManager, IVSExtensionManager extensionManager, IOutput output) + /// + public void Initialize(string argument) + { + if (string.IsNullOrWhiteSpace(argument)) { - this.commandLineOptions = commandLineOptions; - this.testRequestManager = testRequestManager; - this.extensionManager = extensionManager; - this.output = output; + throw new CommandLineException(string.Format(CultureInfo.CurrentCulture, CommandLineResources.UseVsixExtensionsValueRequired)); } - /// - public void Initialize(string argument) + if (!bool.TryParse(argument, out bool value)) { - if (string.IsNullOrWhiteSpace(argument)) - { - throw new CommandLineException(string.Format(CultureInfo.CurrentCulture, CommandLineResources.UseVsixExtensionsValueRequired)); - } - - bool value; - if (!bool.TryParse(argument, out value)) - { - throw new CommandLineException( - string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidUseVsixExtensionsCommand, argument)); - } - - this.output.Warning(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.UseVsixExtensionsDeprecation)); - commandLineOptions.UseVsixExtensions = value; - - if (commandLineOptions.UseVsixExtensions) - { - var vsixExtensions = extensionManager.GetUnitTestExtensions(); - testRequestManager.InitializeExtensions(vsixExtensions, skipExtensionFilters: true); - } + throw new CommandLineException( + string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidUseVsixExtensionsCommand, argument)); } - /// - public ArgumentProcessorResult Execute() + _output.Warning(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.UseVsixExtensionsDeprecation)); + _commandLineOptions.UseVsixExtensions = value; + + if (_commandLineOptions.UseVsixExtensions) { - return ArgumentProcessorResult.Success; + var vsixExtensions = _extensionManager.GetUnitTestExtensions(); + _testRequestManager.InitializeExtensions(vsixExtensions, skipExtensionFilters: true); } } -} + + /// + public ArgumentProcessorResult Execute() + { + return ArgumentProcessorResult.Success; + } +} \ No newline at end of file diff --git a/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs b/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs index 33b9729c6e..8864ac014c 100644 --- a/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs +++ b/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs @@ -1,385 +1,378 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using System; +using System.Collections.Generic; +using System.Diagnostics.Contracts; +using System.Linq; + +using ObjectModel; + +/// +/// Used to create the appropriate instance of an argument processor. +/// +internal class ArgumentProcessorFactory { - using System; - using System.Collections.Generic; - using System.Diagnostics.Contracts; - using System.Linq; + #region Constants - using Microsoft.VisualStudio.TestPlatform.ObjectModel; + /// + /// The command starter. + /// + internal const string CommandStarter = "/"; /// - /// Used to create the appropriate instance of an argument processor. + /// The xplat command starter. /// - internal class ArgumentProcessorFactory - { - #region Constants - - /// - /// The command starter. - /// - internal const string CommandStarter = "/"; - - /// - /// The xplat command starter. - /// - internal const string XplatCommandStarter = "-"; - - #endregion - - #region Fields - - /// - /// Available argument processors. - /// - private readonly IEnumerable argumentProcessors; - private Dictionary commandToProcessorMap; - private Dictionary specialCommandToProcessorMap; - - #endregion - - #region Constructor - - /// - /// Initializes the argument processor factory. - /// - /// - /// The argument Processors. - /// - /// - /// This is not public because the static Create method should be used to access the instance. - /// - protected ArgumentProcessorFactory(IEnumerable argumentProcessors) - { - Contract.Requires(argumentProcessors != null); - this.argumentProcessors = argumentProcessors; - } + internal const string XplatCommandStarter = "-"; - #endregion + #endregion - #region Static Methods + #region Fields - /// - /// Creates ArgumentProcessorFactory. - /// - /// ArgumentProcessorFactory. - internal static ArgumentProcessorFactory Create() - { - // Get the ArgumentProcessorFactory - return new ArgumentProcessorFactory(DefaultArgumentProcessors); - } + /// + /// Available argument processors. + /// + private Dictionary _commandToProcessorMap; + private Dictionary _specialCommandToProcessorMap; - #endregion + #endregion - #region Properties + #region Constructor - /// - /// Returns all of the available argument processors. - /// - public IEnumerable AllArgumentProcessors - { - get { return argumentProcessors; } - } + /// + /// Initializes the argument processor factory. + /// + /// + /// The argument Processors. + /// + /// + /// This is not public because the static Create method should be used to access the instance. + /// + protected ArgumentProcessorFactory(IEnumerable argumentProcessors) + { + Contract.Requires(argumentProcessors != null); + AllArgumentProcessors = argumentProcessors; + } - /// - /// Gets a mapping between command and Argument Executor. - /// - internal Dictionary CommandToProcessorMap - { - get - { - // Build the mapping if it does not already exist. - if (this.commandToProcessorMap == null) - { - BuildCommandMaps(); - } + #endregion - return this.commandToProcessorMap; - } - } + #region Static Methods - /// - /// Gets a mapping between special commands and their Argument Processors. - /// - internal Dictionary SpecialCommandToProcessorMap - { - get - { - // Build the mapping if it does not already exist. - if (this.specialCommandToProcessorMap == null) - { - BuildCommandMaps(); - } + /// + /// Creates ArgumentProcessorFactory. + /// + /// ArgumentProcessorFactory. + internal static ArgumentProcessorFactory Create() + { + // Get the ArgumentProcessorFactory + return new ArgumentProcessorFactory(DefaultArgumentProcessors); + } - return this.specialCommandToProcessorMap; - } - } + #endregion - #endregion + #region Properties - #region Public Methods + /// + /// Returns all of the available argument processors. + /// + public IEnumerable AllArgumentProcessors { get; private set; } - /// - /// Creates the argument processor associated with the provided command line argument. - /// The Lazy that is returned will initialize the underlying argument processor when it is first accessed. - /// - /// Command line argument to create the argument processor for. - /// The argument processor or null if one was not found. - public IArgumentProcessor CreateArgumentProcessor(string argument) + /// + /// Gets a mapping between command and Argument Executor. + /// + internal Dictionary CommandToProcessorMap + { + get { - if (String.IsNullOrWhiteSpace(argument)) + // Build the mapping if it does not already exist. + if (_commandToProcessorMap == null) { - throw new ArgumentException("Cannot be null or empty", nameof(argument)); + BuildCommandMaps(); } - Contract.EndContractBlock(); - - // Parse the input into its command and argument parts. - var pair = new CommandArgumentPair(argument); - - // Find the associated argument processor. - IArgumentProcessor argumentProcessor; - CommandToProcessorMap.TryGetValue(pair.Command, out argumentProcessor); - - // If an argument processor was not found for the command, then consider it as a test source argument. - if (argumentProcessor == null) - { - // Update the command pair since the command is actually the argument in the case of - // a test source. - pair = new CommandArgumentPair(TestSourceArgumentProcessor.CommandName, argument); - argumentProcessor = SpecialCommandToProcessorMap[TestSourceArgumentProcessor.CommandName]; - } + return _commandToProcessorMap; + } + } - if (argumentProcessor != null) + /// + /// Gets a mapping between special commands and their Argument Processors. + /// + internal Dictionary SpecialCommandToProcessorMap + { + get + { + // Build the mapping if it does not already exist. + if (_specialCommandToProcessorMap == null) { - argumentProcessor = WrapLazyProcessorToInitializeOnInstantiation(argumentProcessor, pair.Argument); + BuildCommandMaps(); } - return argumentProcessor; + return _specialCommandToProcessorMap; } + } - /// - /// Creates the argument processor associated with the provided command line argument. - /// The Lazy that is returned will initialize the underlying argument processor when it is first accessed. - /// - /// Command name of the argument processor. - /// Command line arguments to create the argument processor for. - /// The argument processor or null if one was not found. - public IArgumentProcessor CreateArgumentProcessor(string command, string[] arguments) + #endregion + + #region Public Methods + + /// + /// Creates the argument processor associated with the provided command line argument. + /// The Lazy that is returned will initialize the underlying argument processor when it is first accessed. + /// + /// Command line argument to create the argument processor for. + /// The argument processor or null if one was not found. + public IArgumentProcessor CreateArgumentProcessor(string argument) + { + if (String.IsNullOrWhiteSpace(argument)) { - if (arguments == null || arguments.Length == 0) - { - throw new ArgumentException("Cannot be null or empty", nameof(arguments)); - } - Contract.EndContractBlock(); + throw new ArgumentException("Cannot be null or empty", nameof(argument)); + } + Contract.EndContractBlock(); - // Find the associated argument processor. - IArgumentProcessor argumentProcessor; - CommandToProcessorMap.TryGetValue(command, out argumentProcessor); + // Parse the input into its command and argument parts. + var pair = new CommandArgumentPair(argument); - if (argumentProcessor != null) - { - argumentProcessor = WrapLazyProcessorToInitializeOnInstantiation(argumentProcessor, arguments); - } + // Find the associated argument processor. + CommandToProcessorMap.TryGetValue(pair.Command, out IArgumentProcessor argumentProcessor); + + // If an argument processor was not found for the command, then consider it as a test source argument. + if (argumentProcessor == null) + { + // Update the command pair since the command is actually the argument in the case of + // a test source. + pair = new CommandArgumentPair(TestSourceArgumentProcessor.CommandName, argument); - return argumentProcessor; + argumentProcessor = SpecialCommandToProcessorMap[TestSourceArgumentProcessor.CommandName]; } - /// - /// Creates the default action argument processor. - /// The Lazy that is returned will initialize the underlying argument processor when it is first accessed. - /// - /// The default action argument processor. - public IArgumentProcessor CreateDefaultActionArgumentProcessor() + if (argumentProcessor != null) { - var argumentProcessor = SpecialCommandToProcessorMap[RunTestsArgumentProcessor.CommandName]; - return WrapLazyProcessorToInitializeOnInstantiation(argumentProcessor); + argumentProcessor = WrapLazyProcessorToInitializeOnInstantiation(argumentProcessor, pair.Argument); } - /// - /// Gets the argument processors that are tagged as special and to be always executed. - /// The Lazy's that are returned will initialize the underlying argument processor when first accessed. - /// - /// The argument processors that are tagged as special and to be always executed. - public IEnumerable GetArgumentProcessorsToAlwaysExecute() + return argumentProcessor; + } + + /// + /// Creates the argument processor associated with the provided command line argument. + /// The Lazy that is returned will initialize the underlying argument processor when it is first accessed. + /// + /// Command name of the argument processor. + /// Command line arguments to create the argument processor for. + /// The argument processor or null if one was not found. + public IArgumentProcessor CreateArgumentProcessor(string command, string[] arguments) + { + if (arguments == null || arguments.Length == 0) { - return SpecialCommandToProcessorMap.Values - .Where(lazyProcessor => lazyProcessor.Metadata.Value.IsSpecialCommand && lazyProcessor.Metadata.Value.AlwaysExecute); + throw new ArgumentException("Cannot be null or empty", nameof(arguments)); } + Contract.EndContractBlock(); + + // Find the associated argument processor. + CommandToProcessorMap.TryGetValue(command, out IArgumentProcessor argumentProcessor); - #endregion - - #region Private Methods - - private static IEnumerable DefaultArgumentProcessors => new List { - new HelpArgumentProcessor(), - new TestSourceArgumentProcessor(), - new ListTestsArgumentProcessor(), - new RunTestsArgumentProcessor(), - new RunSpecificTestsArgumentProcessor(), - new TestAdapterPathArgumentProcessor(), - new TestCaseFilterArgumentProcessor(), - new ParentProcessIdArgumentProcessor(), - new PortArgumentProcessor(), - new RunSettingsArgumentProcessor(), - new PlatformArgumentProcessor(), - new FrameworkArgumentProcessor(), - new EnableLoggerArgumentProcessor(), - new ParallelArgumentProcessor(), - new EnableDiagArgumentProcessor(), - new CLIRunSettingsArgumentProcessor(), - new ResultsDirectoryArgumentProcessor(), - new InIsolationArgumentProcessor(), - new CollectArgumentProcessor(), - new EnableCodeCoverageArgumentProcessor(), - new DisableAutoFakesArgumentProcessor(), - new ResponseFileArgumentProcessor(), - new EnableBlameArgumentProcessor(), - new UseVsixExtensionsArgumentProcessor(), - new ListDiscoverersArgumentProcessor(), - new ListExecutorsArgumentProcessor(), - new ListLoggersArgumentProcessor(), - new ListSettingsProvidersArgumentProcessor(), - new ListFullyQualifiedTestsArgumentProcessor(), - new ListTestsTargetPathArgumentProcessor(), - new EnvironmentArgumentProcessor() - }; - - /// - /// Builds the command to processor map and special command to processor map. - /// - private void BuildCommandMaps() + if (argumentProcessor != null) { - this.commandToProcessorMap = new Dictionary(StringComparer.OrdinalIgnoreCase); - this.specialCommandToProcessorMap = new Dictionary(StringComparer.OrdinalIgnoreCase); + argumentProcessor = WrapLazyProcessorToInitializeOnInstantiation(argumentProcessor, arguments); + } - foreach (IArgumentProcessor argumentProcessor in this.argumentProcessors) - { - // Add the command to the appropriate dictionary. - var processorsMap = argumentProcessor.Metadata.Value.IsSpecialCommand - ? this.specialCommandToProcessorMap - : this.commandToProcessorMap; + return argumentProcessor; + } - string commandName = argumentProcessor.Metadata.Value.CommandName; - processorsMap.Add(commandName, argumentProcessor); + /// + /// Creates the default action argument processor. + /// The Lazy that is returned will initialize the underlying argument processor when it is first accessed. + /// + /// The default action argument processor. + public IArgumentProcessor CreateDefaultActionArgumentProcessor() + { + var argumentProcessor = SpecialCommandToProcessorMap[RunTestsArgumentProcessor.CommandName]; + return WrapLazyProcessorToInitializeOnInstantiation(argumentProcessor); + } - // Add xplat name for the command name - commandName = string.Concat("--", commandName.Remove(0, 1)); - processorsMap.Add(commandName, argumentProcessor); + /// + /// Gets the argument processors that are tagged as special and to be always executed. + /// The Lazy's that are returned will initialize the underlying argument processor when first accessed. + /// + /// The argument processors that are tagged as special and to be always executed. + public IEnumerable GetArgumentProcessorsToAlwaysExecute() + { + return SpecialCommandToProcessorMap.Values + .Where(lazyProcessor => lazyProcessor.Metadata.Value.IsSpecialCommand && lazyProcessor.Metadata.Value.AlwaysExecute); + } - if (!string.IsNullOrEmpty(argumentProcessor.Metadata.Value.ShortCommandName)) - { - string shortCommandName = argumentProcessor.Metadata.Value.ShortCommandName; - processorsMap.Add(shortCommandName, argumentProcessor); + #endregion + + #region Private Methods + + private static IEnumerable DefaultArgumentProcessors => new List { + new HelpArgumentProcessor(), + new TestSourceArgumentProcessor(), + new ListTestsArgumentProcessor(), + new RunTestsArgumentProcessor(), + new RunSpecificTestsArgumentProcessor(), + new TestAdapterPathArgumentProcessor(), + new TestCaseFilterArgumentProcessor(), + new ParentProcessIdArgumentProcessor(), + new PortArgumentProcessor(), + new RunSettingsArgumentProcessor(), + new PlatformArgumentProcessor(), + new FrameworkArgumentProcessor(), + new EnableLoggerArgumentProcessor(), + new ParallelArgumentProcessor(), + new EnableDiagArgumentProcessor(), + new CliRunSettingsArgumentProcessor(), + new ResultsDirectoryArgumentProcessor(), + new InIsolationArgumentProcessor(), + new CollectArgumentProcessor(), + new EnableCodeCoverageArgumentProcessor(), + new DisableAutoFakesArgumentProcessor(), + new ResponseFileArgumentProcessor(), + new EnableBlameArgumentProcessor(), + new UseVsixExtensionsArgumentProcessor(), + new ListDiscoverersArgumentProcessor(), + new ListExecutorsArgumentProcessor(), + new ListLoggersArgumentProcessor(), + new ListSettingsProvidersArgumentProcessor(), + new ListFullyQualifiedTestsArgumentProcessor(), + new ListTestsTargetPathArgumentProcessor(), + new EnvironmentArgumentProcessor() + }; - // Add xplat short name for the command name - shortCommandName = shortCommandName.Replace('/', '-'); - processorsMap.Add(shortCommandName, argumentProcessor); - } + /// + /// Builds the command to processor map and special command to processor map. + /// + private void BuildCommandMaps() + { + _commandToProcessorMap = new Dictionary(StringComparer.OrdinalIgnoreCase); + _specialCommandToProcessorMap = new Dictionary(StringComparer.OrdinalIgnoreCase); + + foreach (IArgumentProcessor argumentProcessor in AllArgumentProcessors) + { + // Add the command to the appropriate dictionary. + var processorsMap = argumentProcessor.Metadata.Value.IsSpecialCommand + ? _specialCommandToProcessorMap + : _commandToProcessorMap; + + string commandName = argumentProcessor.Metadata.Value.CommandName; + processorsMap.Add(commandName, argumentProcessor); + + // Add xplat name for the command name + commandName = string.Concat("--", commandName.Remove(0, 1)); + processorsMap.Add(commandName, argumentProcessor); + + if (!string.IsNullOrEmpty(argumentProcessor.Metadata.Value.ShortCommandName)) + { + string shortCommandName = argumentProcessor.Metadata.Value.ShortCommandName; + processorsMap.Add(shortCommandName, argumentProcessor); + + // Add xplat short name for the command name + shortCommandName = shortCommandName.Replace('/', '-'); + processorsMap.Add(shortCommandName, argumentProcessor); } } + } - /// - /// Decorates a lazy argument processor so that the real processor is initialized when the lazy value is obtained. - /// - /// The lazy processor. - /// The argument with which the real processor should be initialized. - /// The decorated lazy processor. - private static IArgumentProcessor WrapLazyProcessorToInitializeOnInstantiation( - IArgumentProcessor processor, - string initArg = null) + /// + /// Decorates a lazy argument processor so that the real processor is initialized when the lazy value is obtained. + /// + /// The lazy processor. + /// The argument with which the real processor should be initialized. + /// The decorated lazy processor. + private static IArgumentProcessor WrapLazyProcessorToInitializeOnInstantiation( + IArgumentProcessor processor, + string initArg = null) + { + var processorExecutor = processor.Executor; + var lazyArgumentProcessor = new Lazy(() => { - var processorExecutor = processor.Executor; - var lazyArgumentProcessor = new Lazy(() => + IArgumentExecutor instance = null; + try + { + instance = processorExecutor.Value; + } + catch (Exception e) + { + if (EqtTrace.IsErrorEnabled) + { + EqtTrace.Error("ArgumentProcessorFactory.WrapLazyProcessorToInitializeOnInstantiation: Exception creating argument processor: {0}", e); + } + throw; + } + + if (instance != null) { - IArgumentExecutor instance = null; try { - instance = processorExecutor.Value; + instance.Initialize(initArg); } catch (Exception e) { if (EqtTrace.IsErrorEnabled) { - EqtTrace.Error("ArgumentProcessorFactory.WrapLazyProcessorToInitializeOnInstantiation: Exception creating argument processor: {0}", e); + EqtTrace.Error("ArgumentProcessorFactory.WrapLazyProcessorToInitializeOnInstantiation: Exception initializing argument processor: {0}", e); } throw; } + } - if (instance != null) - { - try - { - instance.Initialize(initArg); - } - catch (Exception e) - { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("ArgumentProcessorFactory.WrapLazyProcessorToInitializeOnInstantiation: Exception initializing argument processor: {0}", e); - } - throw; - } - } - - return instance; - }, System.Threading.LazyThreadSafetyMode.PublicationOnly); - processor.Executor = lazyArgumentProcessor; + return instance; + }, System.Threading.LazyThreadSafetyMode.PublicationOnly); + processor.Executor = lazyArgumentProcessor; - return processor; - } + return processor; + } - /// - /// Decorates a lazy argument processor so that the real processor is initialized when the lazy value is obtained. - /// - /// The lazy processor. - /// The argument with which the real processor should be initialized. - /// The decorated lazy processor. - private static IArgumentProcessor WrapLazyProcessorToInitializeOnInstantiation( - IArgumentProcessor processor, - string[] initArgs) + /// + /// Decorates a lazy argument processor so that the real processor is initialized when the lazy value is obtained. + /// + /// The lazy processor. + /// The argument with which the real processor should be initialized. + /// The decorated lazy processor. + private static IArgumentProcessor WrapLazyProcessorToInitializeOnInstantiation( + IArgumentProcessor processor, + string[] initArgs) + { + var processorExecutor = processor.Executor; + var lazyArgumentProcessor = new Lazy(() => { - var processorExecutor = processor.Executor; - var lazyArgumentProcessor = new Lazy(() => + IArgumentsExecutor instance = null; + try + { + instance = (IArgumentsExecutor)processorExecutor.Value; + } + catch (Exception e) + { + if (EqtTrace.IsErrorEnabled) + { + EqtTrace.Error("ArgumentProcessorFactory.WrapLazyProcessorToInitializeOnInstantiation: Exception creating argument processor: {0}", e); + } + throw; + } + + if (instance != null) { - IArgumentsExecutor instance = null; try { - instance = (IArgumentsExecutor)processorExecutor.Value; + instance.Initialize(initArgs); } catch (Exception e) { if (EqtTrace.IsErrorEnabled) { - EqtTrace.Error("ArgumentProcessorFactory.WrapLazyProcessorToInitializeOnInstantiation: Exception creating argument processor: {0}", e); + EqtTrace.Error("ArgumentProcessorFactory.WrapLazyProcessorToInitializeOnInstantiation: Exception initializing argument processor: {0}", e); } throw; } + } + return instance; + }, System.Threading.LazyThreadSafetyMode.PublicationOnly); + processor.Executor = lazyArgumentProcessor; - if (instance != null) - { - try - { - instance.Initialize(initArgs); - } - catch (Exception e) - { - if (EqtTrace.IsErrorEnabled) - { - EqtTrace.Error("ArgumentProcessorFactory.WrapLazyProcessorToInitializeOnInstantiation: Exception initializing argument processor: {0}", e); - } - throw; - } - } - return instance; - }, System.Threading.LazyThreadSafetyMode.PublicationOnly); - processor.Executor = lazyArgumentProcessor; - - return processor; - } - - #endregion + return processor; } + + #endregion } \ No newline at end of file diff --git a/src/vstest.console/Processors/Utilities/ArgumentProcessorPriority.cs b/src/vstest.console/Processors/Utilities/ArgumentProcessorPriority.cs index eb14b21b87..e661cb2205 100644 --- a/src/vstest.console/Processors/Utilities/ArgumentProcessorPriority.cs +++ b/src/vstest.console/Processors/Utilities/ArgumentProcessorPriority.cs @@ -1,81 +1,80 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +/// +/// Defines the priority of argument processors. +/// +internal enum ArgumentProcessorPriority { /// - /// Defines the priority of argument processors. + /// Maximum priority for a processor. /// - internal enum ArgumentProcessorPriority - { - /// - /// Maximum priority for a processor. - /// - Maximum = 0, + Maximum = 0, - /// - /// Priority of the Help Content argument processor. - /// - Help = Maximum, + /// + /// Priority of the Help Content argument processor. + /// + Help = Maximum, - /// - /// Priority of the Diag processor. - /// - Diag = 1, + /// + /// Priority of the Diag processor. + /// + Diag = 1, - /// - /// Priority of processors related to design mode. This needs to be higher priority - /// since some of the functionalities (like logger) depend on this. - /// - DesignMode = 2, + /// + /// Priority of processors related to design mode. This needs to be higher priority + /// since some of the functionalities (like logger) depend on this. + /// + DesignMode = 2, - /// - /// Priority of UseVsixArgumentProcessor. - /// The priority of useVsix processor is more than the logger because logger initialization - /// loads the extensions which are incomplete if vsix processor is enabled - /// - VsixExtensions = 5, + /// + /// Priority of UseVsixArgumentProcessor. + /// The priority of useVsix processor is more than the logger because logger initialization + /// loads the extensions which are incomplete if vsix processor is enabled + /// + VsixExtensions = 5, - /// - /// Priority of processors related to Run Settings. - /// - RunSettings = 6, + /// + /// Priority of processors related to Run Settings. + /// + RunSettings = 6, - /// - /// Priority of TestAdapterPathArgumentProcessor. - /// The priority of TestAdapterPath processor is more than the logger because logger initialization - /// loads the extensions which are incomplete if custom test adapter is enabled - /// - TestAdapterPath = 10, + /// + /// Priority of TestAdapterPathArgumentProcessor. + /// The priority of TestAdapterPath processor is more than the logger because logger initialization + /// loads the extensions which are incomplete if custom test adapter is enabled + /// + TestAdapterPath = 10, - /// - /// Priority of processors that needs to update runsettings. - /// - AutoUpdateRunSettings = 11, + /// + /// Priority of processors that needs to update runsettings. + /// + AutoUpdateRunSettings = 11, - /// - /// Priority of processors related to CLI Run Settings. - /// - CLIRunSettings = 12, + /// + /// Priority of processors related to CLI Run Settings. + /// + CliRunSettings = 12, - /// - /// Priority of processors related to logging. - /// - Logging = 20, + /// + /// Priority of processors related to logging. + /// + Logging = 20, - /// - /// Priority of the StartLogging processor. - /// - StartLogging = 21, + /// + /// Priority of the StartLogging processor. + /// + StartLogging = 21, - /// - /// Priority of a typical processor. - /// - Normal = 50, + /// + /// Priority of a typical processor. + /// + Normal = 50, - /// - /// Minimum priority for a processor. - /// - Minimum = 100 - } -} + /// + /// Minimum priority for a processor. + /// + Minimum = 100 +} \ No newline at end of file diff --git a/src/vstest.console/Processors/Utilities/ArgumentProcessorResult.cs b/src/vstest.console/Processors/Utilities/ArgumentProcessorResult.cs index 99b192de76..a51736a180 100644 --- a/src/vstest.console/Processors/Utilities/ArgumentProcessorResult.cs +++ b/src/vstest.console/Processors/Utilities/ArgumentProcessorResult.cs @@ -1,26 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +/// +/// Return values from argument processors. +/// +public enum ArgumentProcessorResult { /// - /// Return values from argument processors. + /// Return value indicating no errors. /// - public enum ArgumentProcessorResult - { - /// - /// Return value indicating no errors. - /// - Success = 0, + Success = 0, - /// - /// Return value indicating an error occurred - /// - Fail = 1, + /// + /// Return value indicating an error occurred + /// + Fail = 1, - /// - /// Return value indicating that the current processor succeeded and subsequent processors should be skipped - /// - Abort = 2 - } -} + /// + /// Return value indicating that the current processor succeeded and subsequent processors should be skipped + /// + Abort = 2 +} \ No newline at end of file diff --git a/src/vstest.console/Processors/Utilities/ArgumentProcessorUtilities.cs b/src/vstest.console/Processors/Utilities/ArgumentProcessorUtilities.cs index b8ea8c0f9a..7a37ff0e6c 100644 --- a/src/vstest.console/Processors/Utilities/ArgumentProcessorUtilities.cs +++ b/src/vstest.console/Processors/Utilities/ArgumentProcessorUtilities.cs @@ -2,64 +2,56 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; + +using System; +using System.Collections.Generic; + +internal class ArgumentProcessorUtilities { - using System; - using System.Collections.Generic; - using System.Globalization; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; + public static readonly char[] SemiColonArgumentSeparator = { ';' }; + public static readonly char[] EqualNameValueSeparator = { '=' }; + + /// + /// Get argument list from raw argument using argument separator. + /// + /// Raw argument. + /// Argument separator. + /// Exception Message. + /// Argument list. + public static string[] GetArgumentList(string rawArgument, char[] argumentSeparator, string exceptionMessage) + { + var argumentList = rawArgument?.Split(argumentSeparator, StringSplitOptions.RemoveEmptyEntries); - internal class ArgumentProcessorUtilities + // Throw error in case of invalid argument. + return argumentList == null || argumentList.Length <= 0 ? throw new CommandLineException(exceptionMessage) : argumentList; + } + + /// + /// Get argument parameters. + /// + /// Parameter args. + /// Name value separator. + /// Exception message. + /// Parameters dictionary. + public static Dictionary GetArgumentParameters(IEnumerable parameterArgs, char[] nameValueSeparator, string exceptionMessage) { - public static readonly char[] SemiColonArgumentSeparator = { ';' }; - public static readonly char[] EqualNameValueSeparator = { '=' }; + var parameters = new Dictionary(StringComparer.OrdinalIgnoreCase); - /// - /// Get argument list from raw argument using argument separator. - /// - /// Raw argument. - /// Argument separator. - /// Exception Message. - /// Argument list. - public static string[] GetArgumentList(string rawArgument, char[] argumentSeparator, string exceptionMessage) + // Get parameters from parameterNameValuePairs. + // Throw error in case of invalid name value pairs. + foreach (string parameterArg in parameterArgs) { - var argumentList = rawArgument?.Split(argumentSeparator, StringSplitOptions.RemoveEmptyEntries); + var nameValuePair = parameterArg?.Split(nameValueSeparator, StringSplitOptions.RemoveEmptyEntries); - // Throw error in case of invalid argument. - if (argumentList == null || argumentList.Length <= 0) + if (nameValuePair.Length != 2) { throw new CommandLineException(exceptionMessage); } - return argumentList; + parameters[nameValuePair[0]] = nameValuePair[1]; } - /// - /// Get argument parameters. - /// - /// Parameter args. - /// Name value separator. - /// Exception message. - /// Parameters dictionary. - public static Dictionary GetArgumentParameters(IEnumerable parameterArgs, char[] nameValueSeparator, string exceptionMessage) - { - var parameters = new Dictionary(StringComparer.OrdinalIgnoreCase); - - // Get parameters from parameterNameValuePairs. - // Throw error in case of invalid name value pairs. - foreach (string parameterArg in parameterArgs) - { - var nameValuePair = parameterArg?.Split(nameValueSeparator, StringSplitOptions.RemoveEmptyEntries); - - if (nameValuePair.Length != 2) - { - throw new CommandLineException(exceptionMessage); - } - - parameters[nameValuePair[0]] = nameValuePair[1]; - } - - return parameters; - } + return parameters; } -} +} \ No newline at end of file diff --git a/src/vstest.console/Processors/Utilities/BaseArgumentProcessorCapabilities.cs b/src/vstest.console/Processors/Utilities/BaseArgumentProcessorCapabilities.cs index 2a892e8168..99a450e5ee 100644 --- a/src/vstest.console/Processors/Utilities/BaseArgumentProcessorCapabilities.cs +++ b/src/vstest.console/Processors/Utilities/BaseArgumentProcessorCapabilities.cs @@ -1,56 +1,55 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +/// +/// The base argument processor capabilities. +/// +internal abstract class BaseArgumentProcessorCapabilities : IArgumentProcessorCapabilities { /// - /// The base argument processor capabilities. - /// - internal abstract class BaseArgumentProcessorCapabilities : IArgumentProcessorCapabilities - { - /// - /// Gets a value indicating whether allow multiple. - /// - public virtual bool AllowMultiple => true; - - /// - /// Gets a value indicating whether always execute. - /// - public virtual bool AlwaysExecute => false; - - /// - /// Gets the command name. - /// - public abstract string CommandName { get; } - - /// - /// Gets the short command name. - /// - public virtual string ShortCommandName => null; - - /// - /// Gets the help content resource name. - /// - public virtual string HelpContentResourceName => null; - - /// - /// Gets the help priority. - /// - public virtual HelpContentPriority HelpPriority => HelpContentPriority.None; - - /// - /// Gets a value indicating whether is action. - /// - public virtual bool IsAction => false; - - /// - /// Gets a value indicating whether is special command. - /// - public virtual bool IsSpecialCommand => false; - - /// - /// Gets the priority. - /// - public virtual ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; - } -} + /// Gets a value indicating whether allow multiple. + /// + public virtual bool AllowMultiple => true; + + /// + /// Gets a value indicating whether always execute. + /// + public virtual bool AlwaysExecute => false; + + /// + /// Gets the command name. + /// + public abstract string CommandName { get; } + + /// + /// Gets the short command name. + /// + public virtual string ShortCommandName => null; + + /// + /// Gets the help content resource name. + /// + public virtual string HelpContentResourceName => null; + + /// + /// Gets the help priority. + /// + public virtual HelpContentPriority HelpPriority => HelpContentPriority.None; + + /// + /// Gets a value indicating whether is action. + /// + public virtual bool IsAction => false; + + /// + /// Gets a value indicating whether is special command. + /// + public virtual bool IsSpecialCommand => false; + + /// + /// Gets the priority. + /// + public virtual ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal; +} \ No newline at end of file diff --git a/src/vstest.console/Processors/Utilities/HelpContentPriority.cs b/src/vstest.console/Processors/Utilities/HelpContentPriority.cs index ecd57d18de..88ce7a9115 100644 --- a/src/vstest.console/Processors/Utilities/HelpContentPriority.cs +++ b/src/vstest.console/Processors/Utilities/HelpContentPriority.cs @@ -1,180 +1,179 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +/// +/// Attribute to be used for displaying the help content in required order. +/// +/// Order of settings display (based on lifecycle at https://blogs.msdn.microsoft.com/visualstudioalm/2016/07/25/evolving-the-visual-studio-test-platform-part-1/). +/// +/// Selection +/// --Tests +/// --TestCaseFilter +/// +/// Configure +/// --Framework +/// --Platform +/// --Settings +/// --CLI runsettings +/// +/// Run/Discover +/// --ListTests +/// --Parallel +/// --TestAdapterPath +/// +/// Diagnose/Report +/// --Diag +/// --Logger +/// --ResultsDirectory +/// +/// IDE Automation +/// --ParentProcessId +/// --Port +/// +/// Help +/// -Help +/// +internal enum HelpContentPriority { /// - /// Attribute to be used for displaying the help content in required order. - /// - /// Order of settings display (based on lifecycle at https://blogs.msdn.microsoft.com/visualstudioalm/2016/07/25/evolving-the-visual-studio-test-platform-part-1/). - /// - /// Selection - /// --Tests - /// --TestCaseFilter - /// - /// Configure - /// --Framework - /// --Platform - /// --Settings - /// --CLI runsettings - /// - /// Run/Discover - /// --ListTests - /// --Parallel - /// --TestAdapterPath - /// - /// Diagnose/Report - /// --Diag - /// --Logger - /// --ResultsDirectory - /// - /// IDE Automation - /// --ParentProcessId - /// --Port - /// - /// Help - /// -Help - /// - internal enum HelpContentPriority - { - /// - /// No Content to be shown - /// - None, - - /// - /// RunTestsArgumentProcessor Help - /// - RunTestsArgumentProcessorHelpPriority, - - /// - /// RunSpecificTestsArgumentProcessor Help - /// - RunSpecificTestsArgumentProcessorHelpPriority, - - /// - /// TestCaseFilterArgumentProcessor Help - /// - TestCaseFilterArgumentProcessorHelpPriority, - - /// - /// FrameworkArgumentProcessor Help - /// - FrameworkArgumentProcessorHelpPriority, - - /// - /// PlatformArgumentProcessor Help - /// - PlatformArgumentProcessorHelpPriority, - - /// - /// EnvironmentArgumentProcessor Help - /// - EnvironmentArgumentProcessorHelpPriority, - - /// - /// RunSettingsArgumentProcessor Help - /// - RunSettingsArgumentProcessorHelpPriority, - - /// - /// CLIRunSettingsArgumentProcessor Help - /// - CLIRunSettingsArgumentProcessorHelpPriority, - - /// - /// ListTestsArgumentExecutor Help - /// - ListTestsArgumentProcessorHelpPriority, - - /// - /// ParallelArgumentProcessor Help - /// - ParallelArgumentProcessorHelpPriority, - - /// - /// TestAdapterPathArgumentProcessor Help - /// - TestAdapterPathArgumentProcessorHelpPriority, - - /// - /// EnableDiagArgumentProcessor Help - /// - EnableDiagArgumentProcessorHelpPriority, - - /// - /// EnableLoggerArgumentProcessor Help - /// - EnableLoggerArgumentProcessorHelpPriority, - - /// - /// ResultsDirectoryArgumentProcessor Help - /// - ResultsDirectoryArgumentProcessorHelpPriority, - - /// - /// PortArgumentProcessor Help - /// - ParentProcessIdArgumentProcessorHelpPriority, - - /// - /// PortArgumentProcessor Help - /// - PortArgumentProcessorHelpPriority, - - /// - /// HelpArgumentExecutor - /// - HelpArgumentProcessorHelpPriority, - - /// - /// EnableCodeCoverageArgumentProcessor Help - /// - EnableCodeCoverageArgumentProcessorHelpPriority, - - /// - /// CollectArgumentProcessor Help - /// - CollectArgumentProcessorHelpPriority, - - /// - /// InIsolationArgumentProcessor Help - /// - InIsolationArgumentProcessorHelpPriority, - - /// - /// DisableAutoFakesArgumentProcessor Help - /// - DisableAutoFakesArgumentProcessorHelpPriority, - - /// - /// UseVsixArgumentProcessor Help - /// - UseVsixArgumentProcessorHelpPriority, - - /// - /// ListDiscoverersArgumentProcessor Help - /// - ListDiscoverersArgumentProcessorHelpPriority, - - /// - /// ListExecutorsArgumentProcessor Help - /// - ListExecutorsArgumentProcessorHelpPriority, - - /// - /// ListLoggersArgumentProcessor Help - /// - ListLoggersArgumentProcessorHelpPriority, - - /// - /// ListSettingProviderArgumentProcessor Help - /// - ListSettingsProvidersArgumentProcessorHelpPriority, - - /// - /// ResponseFileArgumentProcessor Help - /// - ResponseFileArgumentProcessorHelpPriority, - } -} + /// No Content to be shown + /// + None, + + /// + /// RunTestsArgumentProcessor Help + /// + RunTestsArgumentProcessorHelpPriority, + + /// + /// RunSpecificTestsArgumentProcessor Help + /// + RunSpecificTestsArgumentProcessorHelpPriority, + + /// + /// TestCaseFilterArgumentProcessor Help + /// + TestCaseFilterArgumentProcessorHelpPriority, + + /// + /// FrameworkArgumentProcessor Help + /// + FrameworkArgumentProcessorHelpPriority, + + /// + /// PlatformArgumentProcessor Help + /// + PlatformArgumentProcessorHelpPriority, + + /// + /// EnvironmentArgumentProcessor Help + /// + EnvironmentArgumentProcessorHelpPriority, + + /// + /// RunSettingsArgumentProcessor Help + /// + RunSettingsArgumentProcessorHelpPriority, + + /// + /// CLIRunSettingsArgumentProcessor Help + /// + CliRunSettingsArgumentProcessorHelpPriority, + + /// + /// ListTestsArgumentExecutor Help + /// + ListTestsArgumentProcessorHelpPriority, + + /// + /// ParallelArgumentProcessor Help + /// + ParallelArgumentProcessorHelpPriority, + + /// + /// TestAdapterPathArgumentProcessor Help + /// + TestAdapterPathArgumentProcessorHelpPriority, + + /// + /// EnableDiagArgumentProcessor Help + /// + EnableDiagArgumentProcessorHelpPriority, + + /// + /// EnableLoggerArgumentProcessor Help + /// + EnableLoggerArgumentProcessorHelpPriority, + + /// + /// ResultsDirectoryArgumentProcessor Help + /// + ResultsDirectoryArgumentProcessorHelpPriority, + + /// + /// PortArgumentProcessor Help + /// + ParentProcessIdArgumentProcessorHelpPriority, + + /// + /// PortArgumentProcessor Help + /// + PortArgumentProcessorHelpPriority, + + /// + /// HelpArgumentExecutor + /// + HelpArgumentProcessorHelpPriority, + + /// + /// EnableCodeCoverageArgumentProcessor Help + /// + EnableCodeCoverageArgumentProcessorHelpPriority, + + /// + /// CollectArgumentProcessor Help + /// + CollectArgumentProcessorHelpPriority, + + /// + /// InIsolationArgumentProcessor Help + /// + InIsolationArgumentProcessorHelpPriority, + + /// + /// DisableAutoFakesArgumentProcessor Help + /// + DisableAutoFakesArgumentProcessorHelpPriority, + + /// + /// UseVsixArgumentProcessor Help + /// + UseVsixArgumentProcessorHelpPriority, + + /// + /// ListDiscoverersArgumentProcessor Help + /// + ListDiscoverersArgumentProcessorHelpPriority, + + /// + /// ListExecutorsArgumentProcessor Help + /// + ListExecutorsArgumentProcessorHelpPriority, + + /// + /// ListLoggersArgumentProcessor Help + /// + ListLoggersArgumentProcessorHelpPriority, + + /// + /// ListSettingProviderArgumentProcessor Help + /// + ListSettingsProvidersArgumentProcessorHelpPriority, + + /// + /// ResponseFileArgumentProcessor Help + /// + ResponseFileArgumentProcessorHelpPriority, +} \ No newline at end of file diff --git a/src/vstest.console/Processors/Utilities/LoggerUtilities.cs b/src/vstest.console/Processors/Utilities/LoggerUtilities.cs index fd778c32d2..b4ec2371e0 100644 --- a/src/vstest.console/Processors/Utilities/LoggerUtilities.cs +++ b/src/vstest.console/Processors/Utilities/LoggerUtilities.cs @@ -2,82 +2,82 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities -{ - using System; - using System.Xml; - using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; + +using System; +using System.Xml; +using System.Collections.Generic; +using Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - internal class LoggerUtilities +internal class LoggerUtilities +{ + /// + /// Add logger to run settings. + /// + /// Logger Identifier. + /// Logger parameters. + /// Run settings manager. + public static void AddLoggerToRunSettings(string loggerIdentifier, Dictionary loggerParameters, IRunSettingsProvider runSettingsManager) { - /// - /// Add logger to run settings. - /// - /// Logger Identifier. - /// Logger parameters. - /// Run settings manager. - public static void AddLoggerToRunSettings(string loggerIdentifier, Dictionary loggerParameters, IRunSettingsProvider runSettingsManager) + // Creating default run settings if required. + var settings = runSettingsManager.ActiveRunSettings?.SettingsXml; + if (settings == null) { - // Creating default run settings if required. - var settings = runSettingsManager.ActiveRunSettings?.SettingsXml; - if (settings == null) - { - runSettingsManager.AddDefaultRunSettings(); - settings = runSettingsManager.ActiveRunSettings?.SettingsXml; - } + runSettingsManager.AddDefaultRunSettings(); + settings = runSettingsManager.ActiveRunSettings?.SettingsXml; + } - var logger = default(LoggerSettings); - var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(settings) ?? new LoggerRunSettings(); + var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(settings) ?? new LoggerRunSettings(); - try - { - // Logger as uri in command line. - var loggerUri = new Uri(loggerIdentifier); - logger = new LoggerSettings - { - Uri = loggerUri, - IsEnabled = true - }; - } - catch (UriFormatException) - { - // Logger as friendlyName in command line. - logger = new LoggerSettings - { - FriendlyName = loggerIdentifier, - IsEnabled = true - }; - } - // Converting logger console params to Configuration element - if (loggerParameters != null && loggerParameters.Count > 0) + LoggerSettings logger; + try + { + // Logger as uri in command line. + var loggerUri = new Uri(loggerIdentifier); + logger = new LoggerSettings { - var XmlDocument = new XmlDocument(); - var outerNode = XmlDocument.CreateElement("Configuration"); - foreach (KeyValuePair entry in loggerParameters) - { - var node = XmlDocument.CreateElement(entry.Key); - node.InnerText = entry.Value; - outerNode.AppendChild(node); - } - - logger.Configuration = outerNode; - } + Uri = loggerUri, + IsEnabled = true + }; + } + catch (UriFormatException) + { + // Logger as friendlyName in command line. + logger = new LoggerSettings + { + FriendlyName = loggerIdentifier, + IsEnabled = true + }; + } - // Remove existing logger. - var existingLoggerIndex = loggerRunSettings.GetExistingLoggerIndex(logger); - if (existingLoggerIndex >= 0) + // Converting logger console params to Configuration element + if (loggerParameters != null && loggerParameters.Count > 0) + { + var xmlDocument = new XmlDocument(); + var outerNode = xmlDocument.CreateElement("Configuration"); + foreach (KeyValuePair entry in loggerParameters) { - loggerRunSettings.LoggerSettingsList.RemoveAt(existingLoggerIndex); + var node = xmlDocument.CreateElement(entry.Key); + node.InnerText = entry.Value; + outerNode.AppendChild(node); } - loggerRunSettings.LoggerSettingsList.Add(logger); + logger.Configuration = outerNode; + } - runSettingsManager.UpdateRunSettingsNodeInnerXml(Constants.LoggerRunSettingsName, loggerRunSettings.ToXml().InnerXml); + // Remove existing logger. + var existingLoggerIndex = loggerRunSettings.GetExistingLoggerIndex(logger); + if (existingLoggerIndex >= 0) + { + loggerRunSettings.LoggerSettingsList.RemoveAt(existingLoggerIndex); } + + loggerRunSettings.LoggerSettingsList.Add(logger); + + runSettingsManager.UpdateRunSettingsNodeInnerXml(Constants.LoggerRunSettingsName, loggerRunSettings.ToXml().InnerXml); } -} +} \ No newline at end of file diff --git a/src/vstest.console/Program.cs b/src/vstest.console/Program.cs index d0a041b2ba..f2594629cc 100644 --- a/src/vstest.console/Program.cs +++ b/src/vstest.console/Program.cs @@ -1,28 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine -{ - using System; - using Microsoft.VisualStudio.TestPlatform.Execution; - using Microsoft.VisualStudio.TestPlatform.Utilities; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine; + +using Execution; +using Utilities; + +/// +/// Main entry point for the command line runner. +/// +public static class Program +{ /// - /// Main entry point for the command line runner. + /// Main entry point. Hands off execution to the executor class. /// - public static class Program + /// Arguments provided on the command line. + /// 0 if everything was successful and 1 otherwise. + public static int Main(string[] args) { - /// - /// Main entry point. Hands off execution to the executor class. - /// - /// Arguments provided on the command line. - /// 0 if everything was successful and 1 otherwise. - public static int Main(string[] args) - { - DebuggerBreakpoint.AttachVisualStudioDebugger("VSTEST_RUNNER_DEBUG_ATTACHVS"); - DebuggerBreakpoint.WaitForDebugger("VSTEST_RUNNER_DEBUG"); - UILanguageOverride.SetCultureSpecifiedByUser(); - return new Executor(ConsoleOutput.Instance).Execute(args); - } + DebuggerBreakpoint.AttachVisualStudioDebugger("VSTEST_RUNNER_DEBUG_ATTACHVS"); + DebuggerBreakpoint.WaitForDebugger("VSTEST_RUNNER_DEBUG"); + UiLanguageOverride.SetCultureSpecifiedByUser(); + return new Executor(ConsoleOutput.Instance).Execute(args); } -} +} \ No newline at end of file diff --git a/src/vstest.console/Properties/AssemblyInfo.cs b/src/vstest.console/Properties/AssemblyInfo.cs index 73f3d9c686..e5f2806186 100644 --- a/src/vstest.console/Properties/AssemblyInfo.cs +++ b/src/vstest.console/Properties/AssemblyInfo.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/src/vstest.console/Publisher/IMetricsPublisher.cs b/src/vstest.console/Publisher/IMetricsPublisher.cs index 045735bedb..45e30d0a25 100644 --- a/src/vstest.console/Publisher/IMetricsPublisher.cs +++ b/src/vstest.console/Publisher/IMetricsPublisher.cs @@ -1,21 +1,20 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Publisher -{ - using System; - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Publisher; + +using System; +using System.Collections.Generic; +/// +/// Publish the metrics +/// +public interface IMetricsPublisher : IDisposable +{ /// - /// Publish the metrics + /// Publish the Metrics /// - public interface IMetricsPublisher : IDisposable - { - /// - /// Publish the Metrics - /// - /// The event Name - /// Key/Value pair of Properties and Values - void PublishMetrics(string eventName, IDictionary metrics); - } -} + /// The event Name + /// Key/Value pair of Properties and Values + void PublishMetrics(string eventName, IDictionary metrics); +} \ No newline at end of file diff --git a/src/vstest.console/Publisher/MetricsPublisherFactory.cs b/src/vstest.console/Publisher/MetricsPublisherFactory.cs index 96d45ddef1..fdcfda8df9 100644 --- a/src/vstest.console/Publisher/MetricsPublisherFactory.cs +++ b/src/vstest.console/Publisher/MetricsPublisherFactory.cs @@ -1,33 +1,29 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Publisher -{ - using System; - using System.Threading.Tasks; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Publisher; + +using System; +using System.Threading.Tasks; +/// +/// Returns the Instance of on basis of given parameters. +/// +public class MetricsPublisherFactory +{ /// - /// Returns the Instance of on basis of given parameters. + /// Gets the Metrics Publisher /// - public class MetricsPublisherFactory + /// Is Telemetry opted in or not + /// Is Design Mode enabled or not + /// Returns Instance of Metrics Publisher + public static async Task GetMetricsPublisher(bool isTelemetryOptedIn, bool isDesignMode) { - /// - /// Gets the Metrics Publisher - /// - /// Is Telemetry opted in or not - /// Is Design Mode enabled or not - /// Returns Instance of Metrics Publisher - public static async Task GetMetricsPublisher(bool isTelemetryOptedIn, bool isDesignMode) - { - var logEnabled = Environment.GetEnvironmentVariable("VSTEST_LOGTELEMETRY"); - bool logTelemery = !string.IsNullOrEmpty(logEnabled) && logEnabled.Equals("1", StringComparison.Ordinal); - - if (isTelemetryOptedIn && !isDesignMode && logTelemery) - { - return await Task.FromResult(new TextFileTelemetryPublisher()); - } + var logEnabled = Environment.GetEnvironmentVariable("VSTEST_LOGTELEMETRY"); + bool logTelemery = !string.IsNullOrEmpty(logEnabled) && logEnabled.Equals("1", StringComparison.Ordinal); - return await Task.FromResult(new NoOpMetricsPublisher()); - } + return isTelemetryOptedIn && !isDesignMode && logTelemery + ? await Task.FromResult(new TextFileTelemetryPublisher()) + : await Task.FromResult(new NoOpMetricsPublisher()); } -} +} \ No newline at end of file diff --git a/src/vstest.console/Publisher/NoOpMetricsPublisher.cs b/src/vstest.console/Publisher/NoOpMetricsPublisher.cs index 6aeaf91569..53c1b6a1b2 100644 --- a/src/vstest.console/Publisher/NoOpMetricsPublisher.cs +++ b/src/vstest.console/Publisher/NoOpMetricsPublisher.cs @@ -1,31 +1,30 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Publisher -{ - using System.Collections.Generic; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Publisher; + +using System.Collections.Generic; +/// +/// This class will be initialized if Telemetry is opted out. +/// +public class NoOpMetricsPublisher : IMetricsPublisher +{ /// - /// This class will be initialized if Telemetry is opted out. + /// Will do NO-OP. /// - public class NoOpMetricsPublisher : IMetricsPublisher + /// + /// + public void PublishMetrics(string eventName, IDictionary metrics) { - /// - /// Will do NO-OP. - /// - /// - /// - public void PublishMetrics(string eventName, IDictionary metrics) - { - // No Operation - } + // No Operation + } - /// - /// Will do NO-OP - /// - public void Dispose() - { - // No operation - } + /// + /// Will do NO-OP + /// + public void Dispose() + { + // No operation } -} +} \ No newline at end of file diff --git a/src/vstest.console/Publisher/TextFileTelemetryPublisher.cs b/src/vstest.console/Publisher/TextFileTelemetryPublisher.cs index a5b2a19ba8..2ed45fefc7 100644 --- a/src/vstest.console/Publisher/TextFileTelemetryPublisher.cs +++ b/src/vstest.console/Publisher/TextFileTelemetryPublisher.cs @@ -1,75 +1,75 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Publisher +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Publisher; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +using ObjectModel; + +using Utilities.Helpers; +using Utilities.Helpers.Interfaces; + +/// +/// This class will be initialized if Telemetry is opted out. +/// +public class TextFileTelemetryPublisher : IMetricsPublisher { - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; + /// + /// Publishes telemetry to a file. + /// + /// + /// + public void PublishMetrics(string eventName, IDictionary metrics) + { + // Log to Text File + LogToFile(eventName, metrics, new FileHelper()); + } - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + /// + /// Will do NO-OP + /// + public void Dispose() + { + // No operation + } /// - /// This class will be initialized if Telemetry is opted out. + /// Log the telemetry to file. + /// For Testing purposes. /// - public class TextFileTelemetryPublisher : IMetricsPublisher + /// + /// The event Name. + /// + /// + /// Metrics + /// + /// + /// The file Helper. + /// + internal void LogToFile(string eventName, IDictionary metrics, IFileHelper fileHelper) { - /// - /// Publishes telemetry to a file. - /// - /// - /// - public void PublishMetrics(string eventName, IDictionary metrics) - { - // Log to Text File - this.LogToFile(eventName, metrics, new FileHelper()); - } + string resultDirectory = Environment.GetEnvironmentVariable("VSTEST_LOGTELEMETRY_PATH") + ?? Path.GetTempPath() + "TelemetryLogs"; + string resultFileName = Guid.NewGuid().ToString(); + string path = Path.Combine(resultDirectory, resultFileName); - /// - /// Will do NO-OP - /// - public void Dispose() + if (!fileHelper.DirectoryExists(resultDirectory)) { - // No operation + fileHelper.CreateDirectory(resultDirectory); } - /// - /// Log the telemetry to file. - /// For Testing purposes. - /// - /// - /// The event Name. - /// - /// - /// Metrics - /// - /// - /// The file Helper. - /// - internal void LogToFile(string eventName, IDictionary metrics, IFileHelper fileHelper) - { - string resultDirectory = Environment.GetEnvironmentVariable("VSTEST_LOGTELEMETRY_PATH") - ?? Path.GetTempPath() + "TelemetryLogs"; - string resultFileName = Guid.NewGuid().ToString(); - string path = Path.Combine(resultDirectory, resultFileName); - - if (!fileHelper.DirectoryExists(resultDirectory)) - { - fileHelper.CreateDirectory(resultDirectory); - } - - var telemetryData = string.Join(";", metrics.Select(x => x.Key + "=" + x.Value)); - var finalData = string.Concat(eventName, ";", telemetryData); - - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("TextFileTelemetryPublisher.LogToFile : Logging telemetry data points to file {0}", path); - } + var telemetryData = string.Join(";", metrics.Select(x => x.Key + "=" + x.Value)); + var finalData = string.Concat(eventName, ";", telemetryData); - fileHelper.WriteAllTextToFile(path, finalData); + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("TextFileTelemetryPublisher.LogToFile : Logging telemetry data points to file {0}", path); } + + fileHelper.WriteAllTextToFile(path, finalData); } -} +} \ No newline at end of file diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index 61f75604b1..dcac5c548b 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -1,1202 +1,1192 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers; + +using System; +using System.Xml; +using System.IO; +using System.Linq; +using System.Xml.XPath; +using System.Threading; +using System.Reflection; +using System.Threading.Tasks; +using System.Collections.Generic; + +using Client; +using Client.RequestHelper; +using Internal; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; +using Publisher; +using Resources; +using CommandLineUtilities; +using Common; +using Common.Interfaces; +using Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using CoreUtilities.Tracing; +using CoreUtilities.Tracing.Interfaces; +using CrossPlatEngine.TestRunAttachmentsProcessing; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using ObjectModel.Engine; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using PlatformAbstractions; +using PlatformAbstractions.Interfaces; +using Utilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; +using Utilities.Helpers; + +/// +/// Defines the test request manger which can fire off discovery and test run requests. +/// +internal class TestRequestManager : ITestRequestManager { - using System; - using System.Xml; - using System.IO; - using System.Linq; - using System.Xml.XPath; - using System.Threading; - using System.Reflection; - using System.Threading.Tasks; - using System.Collections.Generic; - - using Microsoft.VisualStudio.TestPlatform.Client; - using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Publisher; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Resources; - using Microsoft.VisualStudio.TestPlatform.CommandLineUtilities; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.TestRunAttachmentsProcessing; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; + private static ITestRequestManager s_testRequestManagerInstance; + + private const int RunRequestTimeout = 5000; + + private readonly ITestPlatform _testPlatform; + private readonly ITestPlatformEventSource _testPlatformEventSource; + private readonly Task _metricsPublisher; + private readonly object _syncObject = new(); + + private bool _isDisposed; + private bool _telemetryOptedIn; + private readonly CommandLineOptions _commandLineOptions; + private readonly TestRunResultAggregator _testRunResultAggregator; + private readonly InferHelper _inferHelper; + private readonly IProcessHelper _processHelper; + private readonly ITestRunAttachmentsProcessingManager _attachmentsProcessingManager; + + /// + /// Maintains the current active execution request. + /// Assumption: There can only be one active execution request. + /// + private ITestRunRequest _currentTestRunRequest; + + /// + /// Maintains the current active discovery request. + /// Assumption: There can only be one active discovery request. + /// + private IDiscoveryRequest _currentDiscoveryRequest; + + /// + /// Maintains the current active test run attachments processing cancellation token source. + /// Assumption: There can only be one active attachments processing request. + /// + private CancellationTokenSource _currentAttachmentsProcessingCancellationTokenSource; + + #region Constructor /// - /// Defines the test request manger which can fire off discovery and test run requests. + /// Initializes a new instance of the class. /// - internal class TestRequestManager : ITestRequestManager + public TestRequestManager() + : this( + CommandLineOptions.Instance, + TestPlatformFactory.GetTestPlatform(), + TestRunResultAggregator.Instance, + TestPlatformEventSource.Instance, + new InferHelper(AssemblyMetadataProvider.Instance), + MetricsPublisherFactory.GetMetricsPublisher( + IsTelemetryOptedIn(), + CommandLineOptions.Instance.IsDesignMode), + new ProcessHelper(), + new TestRunAttachmentsProcessingManager(TestPlatformEventSource.Instance, new DataCollectorAttachmentsProcessorsFactory())) { - private static ITestRequestManager testRequestManagerInstance; - - private const int runRequestTimeout = 5000; - - private readonly ITestPlatform testPlatform; - private readonly ITestPlatformEventSource testPlatformEventSource; - private readonly Task metricsPublisher; - private readonly object syncObject = new object(); - - private bool isDisposed; - private bool telemetryOptedIn; - private CommandLineOptions commandLineOptions; - private TestRunResultAggregator testRunResultAggregator; - private InferHelper inferHelper; - private IProcessHelper processHelper; - private ITestRunAttachmentsProcessingManager attachmentsProcessingManager; - - /// - /// Maintains the current active execution request. - /// Assumption: There can only be one active execution request. - /// - private ITestRunRequest currentTestRunRequest; - - /// - /// Maintains the current active discovery request. - /// Assumption: There can only be one active discovery request. - /// - private IDiscoveryRequest currentDiscoveryRequest; - - /// - /// Maintains the current active test run attachments processing cancellation token source. - /// Assumption: There can only be one active attachments processing request. - /// - private CancellationTokenSource currentAttachmentsProcessingCancellationTokenSource; - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - public TestRequestManager() - : this( - CommandLineOptions.Instance, - TestPlatformFactory.GetTestPlatform(), - TestRunResultAggregator.Instance, - TestPlatformEventSource.Instance, - new InferHelper(AssemblyMetadataProvider.Instance), - MetricsPublisherFactory.GetMetricsPublisher( - IsTelemetryOptedIn(), - CommandLineOptions.Instance.IsDesignMode), - new ProcessHelper(), - new TestRunAttachmentsProcessingManager(TestPlatformEventSource.Instance, new DataCollectorAttachmentsProcessorsFactory())) - { - } + } - internal TestRequestManager( - CommandLineOptions commandLineOptions, - ITestPlatform testPlatform, - TestRunResultAggregator testRunResultAggregator, - ITestPlatformEventSource testPlatformEventSource, - InferHelper inferHelper, - Task metricsPublisher, - IProcessHelper processHelper, - ITestRunAttachmentsProcessingManager attachmentsProcessingManager) - { - this.testPlatform = testPlatform; - this.commandLineOptions = commandLineOptions; - this.testRunResultAggregator = testRunResultAggregator; - this.testPlatformEventSource = testPlatformEventSource; - this.inferHelper = inferHelper; - this.metricsPublisher = metricsPublisher; - this.processHelper = processHelper; - this.attachmentsProcessingManager = attachmentsProcessingManager; - } + internal TestRequestManager( + CommandLineOptions commandLineOptions, + ITestPlatform testPlatform, + TestRunResultAggregator testRunResultAggregator, + ITestPlatformEventSource testPlatformEventSource, + InferHelper inferHelper, + Task metricsPublisher, + IProcessHelper processHelper, + ITestRunAttachmentsProcessingManager attachmentsProcessingManager) + { + _testPlatform = testPlatform; + _commandLineOptions = commandLineOptions; + _testRunResultAggregator = testRunResultAggregator; + _testPlatformEventSource = testPlatformEventSource; + _inferHelper = inferHelper; + _metricsPublisher = metricsPublisher; + _processHelper = processHelper; + _attachmentsProcessingManager = attachmentsProcessingManager; + } - #endregion + #endregion - /// - /// Gets the test request manager instance. - /// - public static ITestRequestManager Instance + /// + /// Gets the test request manager instance. + /// + public static ITestRequestManager Instance + { + get { - get + if (s_testRequestManagerInstance == null) { - if (testRequestManagerInstance == null) - { - testRequestManagerInstance = new TestRequestManager(); - } - - return testRequestManagerInstance; + s_testRequestManagerInstance = new TestRequestManager(); } + + return s_testRequestManagerInstance; } + } - #region ITestRequestManager + #region ITestRequestManager - /// - public void InitializeExtensions( - IEnumerable pathToAdditionalExtensions, - bool skipExtensionFilters) - { - // It is possible for an Editor/IDE to keep running the runner in design mode for long - // duration. We clear the extensions cache to ensure the extensions don't get reused - // across discovery/run requests. - EqtTrace.Info("TestRequestManager.InitializeExtensions: Initialize extensions started."); - this.testPlatform.ClearExtensions(); - this.testPlatform.UpdateExtensions(pathToAdditionalExtensions, skipExtensionFilters); - EqtTrace.Info("TestRequestManager.InitializeExtensions: Initialize extensions completed."); - } + /// + public void InitializeExtensions( + IEnumerable pathToAdditionalExtensions, + bool skipExtensionFilters) + { + // It is possible for an Editor/IDE to keep running the runner in design mode for long + // duration. We clear the extensions cache to ensure the extensions don't get reused + // across discovery/run requests. + EqtTrace.Info("TestRequestManager.InitializeExtensions: Initialize extensions started."); + _testPlatform.ClearExtensions(); + _testPlatform.UpdateExtensions(pathToAdditionalExtensions, skipExtensionFilters); + EqtTrace.Info("TestRequestManager.InitializeExtensions: Initialize extensions completed."); + } - /// - public void ResetOptions() - { - this.commandLineOptions.Reset(); - } + /// + public void ResetOptions() + { + _commandLineOptions.Reset(); + } - /// - public void DiscoverTests( - DiscoveryRequestPayload discoveryPayload, - ITestDiscoveryEventsRegistrar discoveryEventsRegistrar, - ProtocolConfig protocolConfig) - { - EqtTrace.Info("TestRequestManager.DiscoverTests: Discovery tests started."); + /// + public void DiscoverTests( + DiscoveryRequestPayload discoveryPayload, + ITestDiscoveryEventsRegistrar discoveryEventsRegistrar, + ProtocolConfig protocolConfig) + { + EqtTrace.Info("TestRequestManager.DiscoverTests: Discovery tests started."); - var runsettings = discoveryPayload.RunSettings; + var runsettings = discoveryPayload.RunSettings; - if (discoveryPayload.TestPlatformOptions != null) - { - this.telemetryOptedIn = discoveryPayload.TestPlatformOptions.CollectMetrics; - } + if (discoveryPayload.TestPlatformOptions != null) + { + _telemetryOptedIn = discoveryPayload.TestPlatformOptions.CollectMetrics; + } - var requestData = this.GetRequestData(protocolConfig); - if (this.UpdateRunSettingsIfRequired( + var requestData = GetRequestData(protocolConfig); + if (UpdateRunSettingsIfRequired( runsettings, discoveryPayload.Sources?.ToList(), discoveryEventsRegistrar, out string updatedRunsettings)) - { - runsettings = updatedRunsettings; - } + { + runsettings = updatedRunsettings; + } - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettings); - var batchSize = runConfiguration.BatchSize; - var testCaseFilterFromRunsettings = runConfiguration.TestCaseFilter; + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettings); + var batchSize = runConfiguration.BatchSize; + var testCaseFilterFromRunsettings = runConfiguration.TestCaseFilter; - if (requestData.IsTelemetryOptedIn) - { - // Collect metrics. - this.CollectMetrics(requestData, runConfiguration); + if (requestData.IsTelemetryOptedIn) + { + // Collect metrics. + CollectMetrics(requestData, runConfiguration); - // Collect commands. - this.LogCommandsTelemetryPoints(requestData); - } + // Collect commands. + LogCommandsTelemetryPoints(requestData); + } - // Create discovery request. - var criteria = new DiscoveryCriteria( - discoveryPayload.Sources, - batchSize, - this.commandLineOptions.TestStatsEventTimeout, - runsettings, - discoveryPayload.TestSessionInfo) - { - TestCaseFilter = this.commandLineOptions.TestCaseFilterValue - ?? testCaseFilterFromRunsettings - }; + // Create discovery request. + var criteria = new DiscoveryCriteria( + discoveryPayload.Sources, + batchSize, + _commandLineOptions.TestStatsEventTimeout, + runsettings, + discoveryPayload.TestSessionInfo) + { + TestCaseFilter = _commandLineOptions.TestCaseFilterValue + ?? testCaseFilterFromRunsettings + }; - // Make sure to run the run request inside a lock as the below section is not thread-safe. - // There can be only one discovery or execution request at a given point in time. - lock (this.syncObject) + // Make sure to run the run request inside a lock as the below section is not thread-safe. + // There can be only one discovery or execution request at a given point in time. + lock (_syncObject) + { + try { - try - { - EqtTrace.Info("TestRequestManager.DiscoverTests: Synchronization context taken"); + EqtTrace.Info("TestRequestManager.DiscoverTests: Synchronization context taken"); - this.currentDiscoveryRequest = this.testPlatform.CreateDiscoveryRequest( - requestData, - criteria, - discoveryPayload.TestPlatformOptions); - discoveryEventsRegistrar?.RegisterDiscoveryEvents(this.currentDiscoveryRequest); + _currentDiscoveryRequest = _testPlatform.CreateDiscoveryRequest( + requestData, + criteria, + discoveryPayload.TestPlatformOptions); + discoveryEventsRegistrar?.RegisterDiscoveryEvents(_currentDiscoveryRequest); - // Notify start of discovery start. - this.testPlatformEventSource.DiscoveryRequestStart(); + // Notify start of discovery start. + _testPlatformEventSource.DiscoveryRequestStart(); - // Start the discovery of tests and wait for completion. - this.currentDiscoveryRequest.DiscoverAsync(); - this.currentDiscoveryRequest.WaitForCompletion(); - } - finally + // Start the discovery of tests and wait for completion. + _currentDiscoveryRequest.DiscoverAsync(); + _currentDiscoveryRequest.WaitForCompletion(); + } + finally + { + if (_currentDiscoveryRequest != null) { - if (this.currentDiscoveryRequest != null) - { - // Dispose the discovery request and unregister for events. - discoveryEventsRegistrar?.UnregisterDiscoveryEvents(currentDiscoveryRequest); - this.currentDiscoveryRequest.Dispose(); - this.currentDiscoveryRequest = null; - } - - EqtTrace.Info("TestRequestManager.DiscoverTests: Discovery tests completed."); - this.testPlatformEventSource.DiscoveryRequestStop(); - - // Posts the discovery complete event. - this.metricsPublisher.Result.PublishMetrics( - TelemetryDataConstants.TestDiscoveryCompleteEvent, - requestData.MetricsCollection.Metrics); + // Dispose the discovery request and unregister for events. + discoveryEventsRegistrar?.UnregisterDiscoveryEvents(_currentDiscoveryRequest); + _currentDiscoveryRequest.Dispose(); + _currentDiscoveryRequest = null; } + + EqtTrace.Info("TestRequestManager.DiscoverTests: Discovery tests completed."); + _testPlatformEventSource.DiscoveryRequestStop(); + + // Posts the discovery complete event. + _metricsPublisher.Result.PublishMetrics( + TelemetryDataConstants.TestDiscoveryCompleteEvent, + requestData.MetricsCollection.Metrics); } } + } - /// - public void RunTests( - TestRunRequestPayload testRunRequestPayload, - ITestHostLauncher testHostLauncher, - ITestRunEventsRegistrar testRunEventsRegistrar, - ProtocolConfig protocolConfig) - { - EqtTrace.Info("TestRequestManager.RunTests: run tests started."); - - TestRunCriteria runCriteria = null; - var runsettings = testRunRequestPayload.RunSettings; + /// + public void RunTests( + TestRunRequestPayload testRunRequestPayload, + ITestHostLauncher testHostLauncher, + ITestRunEventsRegistrar testRunEventsRegistrar, + ProtocolConfig protocolConfig) + { + EqtTrace.Info("TestRequestManager.RunTests: run tests started."); + var runsettings = testRunRequestPayload.RunSettings; - if (testRunRequestPayload.TestPlatformOptions != null) - { - this.telemetryOptedIn = testRunRequestPayload.TestPlatformOptions.CollectMetrics; - } + if (testRunRequestPayload.TestPlatformOptions != null) + { + _telemetryOptedIn = testRunRequestPayload.TestPlatformOptions.CollectMetrics; + } - var requestData = this.GetRequestData(protocolConfig); + var requestData = GetRequestData(protocolConfig); - // Get sources to auto detect fx and arch for both run selected or run all scenario. - var sources = GetSources(testRunRequestPayload); + // Get sources to auto detect fx and arch for both run selected or run all scenario. + var sources = GetSources(testRunRequestPayload); - if (this.UpdateRunSettingsIfRequired( + if (UpdateRunSettingsIfRequired( runsettings, sources, testRunEventsRegistrar, out string updatedRunsettings)) - { - runsettings = updatedRunsettings; - } - - if (InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings(runsettings)) - { - throw new SettingsException( - string.Format( - Resources.RunsettingsWithDCErrorMessage, - runsettings)); - } + { + runsettings = updatedRunsettings; + } - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettings); - var batchSize = runConfiguration.BatchSize; + if (InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings(runsettings)) + { + throw new SettingsException( + string.Format( + Resources.RunsettingsWithDCErrorMessage, + runsettings)); + } - if (requestData.IsTelemetryOptedIn) - { - // Collect metrics. - this.CollectMetrics(requestData, runConfiguration); + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettings); + var batchSize = runConfiguration.BatchSize; - // Collect commands. - this.LogCommandsTelemetryPoints(requestData); + if (requestData.IsTelemetryOptedIn) + { + // Collect metrics. + CollectMetrics(requestData, runConfiguration); - // Collect data for legacy settings. - this.LogTelemetryForLegacySettings(requestData, runsettings); - } + // Collect commands. + LogCommandsTelemetryPoints(requestData); - // Get Fakes data collector settings. - if (!string.Equals(Environment.GetEnvironmentVariable("VSTEST_SKIP_FAKES_CONFIGURATION"), "1")) - { - // The commandline options do not have sources in design time mode, - // and so we fall back to using sources instead. - if (this.commandLineOptions.Sources.Any()) - { - GenerateFakesUtilities.GenerateFakesSettings( - this.commandLineOptions, - this.commandLineOptions.Sources.ToList(), - ref runsettings); - } - else if (sources.Any()) - { - GenerateFakesUtilities.GenerateFakesSettings( - this.commandLineOptions, - sources, - ref runsettings); - } - } + // Collect data for legacy settings. + LogTelemetryForLegacySettings(requestData, runsettings); + } - if (testRunRequestPayload.Sources != null && testRunRequestPayload.Sources.Any()) + // Get Fakes data collector settings. + if (!string.Equals(Environment.GetEnvironmentVariable("VSTEST_SKIP_FAKES_CONFIGURATION"), "1")) + { + // The commandline options do not have sources in design time mode, + // and so we fall back to using sources instead. + if (_commandLineOptions.Sources.Any()) { - runCriteria = new TestRunCriteria( - testRunRequestPayload.Sources, - batchSize, - testRunRequestPayload.KeepAlive, - runsettings, - this.commandLineOptions.TestStatsEventTimeout, - testHostLauncher, - testRunRequestPayload.TestPlatformOptions?.TestCaseFilter, - testRunRequestPayload.TestPlatformOptions?.FilterOptions, - testRunRequestPayload.TestSessionInfo, - debugEnabledForTestSession: testRunRequestPayload.TestSessionInfo != null - && testRunRequestPayload.DebuggingEnabled); + GenerateFakesUtilities.GenerateFakesSettings( + _commandLineOptions, + _commandLineOptions.Sources.ToList(), + ref runsettings); } - else + else if (sources.Any()) { - runCriteria = new TestRunCriteria( - testRunRequestPayload.TestCases, - batchSize, - testRunRequestPayload.KeepAlive, - runsettings, - this.commandLineOptions.TestStatsEventTimeout, - testHostLauncher, - testRunRequestPayload.TestSessionInfo, - debugEnabledForTestSession: testRunRequestPayload.TestSessionInfo != null - && testRunRequestPayload.DebuggingEnabled); + GenerateFakesUtilities.GenerateFakesSettings( + _commandLineOptions, + sources, + ref runsettings); } + } - // Run tests. - try - { - this.RunTests( - requestData, - runCriteria, - testRunEventsRegistrar, - testRunRequestPayload.TestPlatformOptions); - EqtTrace.Info("TestRequestManager.RunTests: run tests completed."); - } - finally - { - this.testPlatformEventSource.ExecutionRequestStop(); + TestRunCriteria runCriteria = testRunRequestPayload.Sources != null && testRunRequestPayload.Sources.Any() + ? new TestRunCriteria( + testRunRequestPayload.Sources, + batchSize, + testRunRequestPayload.KeepAlive, + runsettings, + _commandLineOptions.TestStatsEventTimeout, + testHostLauncher, + testRunRequestPayload.TestPlatformOptions?.TestCaseFilter, + testRunRequestPayload.TestPlatformOptions?.FilterOptions, + testRunRequestPayload.TestSessionInfo, + debugEnabledForTestSession: testRunRequestPayload.TestSessionInfo != null + && testRunRequestPayload.DebuggingEnabled) + : new TestRunCriteria( + testRunRequestPayload.TestCases, + batchSize, + testRunRequestPayload.KeepAlive, + runsettings, + _commandLineOptions.TestStatsEventTimeout, + testHostLauncher, + testRunRequestPayload.TestSessionInfo, + debugEnabledForTestSession: testRunRequestPayload.TestSessionInfo != null + && testRunRequestPayload.DebuggingEnabled); + + // Run tests. + try + { + RunTests( + requestData, + runCriteria, + testRunEventsRegistrar, + testRunRequestPayload.TestPlatformOptions); + EqtTrace.Info("TestRequestManager.RunTests: run tests completed."); + } + finally + { + _testPlatformEventSource.ExecutionRequestStop(); - // Post the run complete event - this.metricsPublisher.Result.PublishMetrics( - TelemetryDataConstants.TestExecutionCompleteEvent, - requestData.MetricsCollection.Metrics); - } + // Post the run complete event + _metricsPublisher.Result.PublishMetrics( + TelemetryDataConstants.TestExecutionCompleteEvent, + requestData.MetricsCollection.Metrics); } + } - /// - public void ProcessTestRunAttachments( - TestRunAttachmentsProcessingPayload attachmentsProcessingPayload, - ITestRunAttachmentsProcessingEventsHandler attachmentsProcessingEventsHandler, - ProtocolConfig protocolConfig) + /// + public void ProcessTestRunAttachments( + TestRunAttachmentsProcessingPayload attachmentsProcessingPayload, + ITestRunAttachmentsProcessingEventsHandler attachmentsProcessingEventsHandler, + ProtocolConfig protocolConfig) + { + EqtTrace.Info("TestRequestManager.ProcessTestRunAttachments: Test run attachments processing started."); + + _telemetryOptedIn = attachmentsProcessingPayload.CollectMetrics; + var requestData = GetRequestData(protocolConfig); + + // Make sure to run the run request inside a lock as the below section is not thread-safe. + // There can be only one discovery, execution or attachments processing request at a given + // point in time. + lock (_syncObject) { - EqtTrace.Info("TestRequestManager.ProcessTestRunAttachments: Test run attachments processing started."); + try + { + EqtTrace.Info("TestRequestManager.ProcessTestRunAttachments: Synchronization context taken."); + _testPlatformEventSource.TestRunAttachmentsProcessingRequestStart(); - this.telemetryOptedIn = attachmentsProcessingPayload.CollectMetrics; - var requestData = this.GetRequestData(protocolConfig); + _currentAttachmentsProcessingCancellationTokenSource = new CancellationTokenSource(); - // Make sure to run the run request inside a lock as the below section is not thread-safe. - // There can be only one discovery, execution or attachments processing request at a given - // point in time. - lock (this.syncObject) + Task task = _attachmentsProcessingManager.ProcessTestRunAttachmentsAsync( + attachmentsProcessingPayload.RunSettings, + requestData, + attachmentsProcessingPayload.Attachments, + attachmentsProcessingPayload.InvokedDataCollectors, + attachmentsProcessingEventsHandler, + _currentAttachmentsProcessingCancellationTokenSource.Token); + task.Wait(); + } + finally { - try - { - EqtTrace.Info("TestRequestManager.ProcessTestRunAttachments: Synchronization context taken."); - this.testPlatformEventSource.TestRunAttachmentsProcessingRequestStart(); - - this.currentAttachmentsProcessingCancellationTokenSource = new CancellationTokenSource(); - - Task task = this.attachmentsProcessingManager.ProcessTestRunAttachmentsAsync( - attachmentsProcessingPayload.RunSettings, - requestData, - attachmentsProcessingPayload.Attachments, - attachmentsProcessingPayload.InvokedDataCollectors, - attachmentsProcessingEventsHandler, - this.currentAttachmentsProcessingCancellationTokenSource.Token); - task.Wait(); - } - finally + if (_currentAttachmentsProcessingCancellationTokenSource != null) { - if (this.currentAttachmentsProcessingCancellationTokenSource != null) - { - this.currentAttachmentsProcessingCancellationTokenSource.Dispose(); - this.currentAttachmentsProcessingCancellationTokenSource = null; - } - - EqtTrace.Info("TestRequestManager.ProcessTestRunAttachments: Test run attachments processing completed."); - this.testPlatformEventSource.TestRunAttachmentsProcessingRequestStop(); - - // Post the attachments processing complete event. - this.metricsPublisher.Result.PublishMetrics( - TelemetryDataConstants.TestAttachmentsProcessingCompleteEvent, - requestData.MetricsCollection.Metrics); + _currentAttachmentsProcessingCancellationTokenSource.Dispose(); + _currentAttachmentsProcessingCancellationTokenSource = null; } + + EqtTrace.Info("TestRequestManager.ProcessTestRunAttachments: Test run attachments processing completed."); + _testPlatformEventSource.TestRunAttachmentsProcessingRequestStop(); + + // Post the attachments processing complete event. + _metricsPublisher.Result.PublishMetrics( + TelemetryDataConstants.TestAttachmentsProcessingCompleteEvent, + requestData.MetricsCollection.Metrics); } } + } - /// - public void StartTestSession( - StartTestSessionPayload payload, - ITestHostLauncher testHostLauncher, - ITestSessionEventsHandler eventsHandler, - ProtocolConfig protocolConfig) - { - EqtTrace.Info("TestRequestManager.StartTestSession: Starting test session."); + /// + public void StartTestSession( + StartTestSessionPayload payload, + ITestHostLauncher testHostLauncher, + ITestSessionEventsHandler eventsHandler, + ProtocolConfig protocolConfig) + { + EqtTrace.Info("TestRequestManager.StartTestSession: Starting test session."); - if (payload.TestPlatformOptions != null) - { - this.telemetryOptedIn = payload.TestPlatformOptions.CollectMetrics; - } + if (payload.TestPlatformOptions != null) + { + _telemetryOptedIn = payload.TestPlatformOptions.CollectMetrics; + } - var requestData = this.GetRequestData(protocolConfig); + var requestData = GetRequestData(protocolConfig); - if (this.UpdateRunSettingsIfRequired( + if (UpdateRunSettingsIfRequired( payload.RunSettings, payload.Sources, null, out string updatedRunsettings)) - { - payload.RunSettings = updatedRunsettings; - } + { + payload.RunSettings = updatedRunsettings; + } - if (InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings(payload.RunSettings)) - { - throw new SettingsException( - string.Format( - Resources.RunsettingsWithDCErrorMessage, - payload.RunSettings)); - } + if (InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings(payload.RunSettings)) + { + throw new SettingsException( + string.Format( + Resources.RunsettingsWithDCErrorMessage, + payload.RunSettings)); + } - // TODO (copoiena): Collect metrics ? + // TODO (copoiena): Collect metrics ? - lock (this.syncObject) + lock (_syncObject) + { + try { - try - { - EqtTrace.Info("TestRequestManager.StartTestRunner: Synchronization context taken."); - this.testPlatformEventSource.StartTestSessionStart(); - - var criteria = new StartTestSessionCriteria() - { - Sources = payload.Sources, - RunSettings = payload.RunSettings, - TestHostLauncher = testHostLauncher - }; - - if (!this.testPlatform.StartTestSession(requestData, criteria, eventsHandler)) - { - EqtTrace.Warning("TestRequestManager.StartTestSession: Unable to start test session."); - } - } - finally + EqtTrace.Info("TestRequestManager.StartTestRunner: Synchronization context taken."); + _testPlatformEventSource.StartTestSessionStart(); + + var criteria = new StartTestSessionCriteria() { - EqtTrace.Info("TestRequestManager.StartTestSession: Starting test session completed."); - this.testPlatformEventSource.StartTestSessionStop(); + Sources = payload.Sources, + RunSettings = payload.RunSettings, + TestHostLauncher = testHostLauncher + }; - // Post the attachments processing complete event. - this.metricsPublisher.Result.PublishMetrics( - TelemetryDataConstants.StartTestSessionCompleteEvent, - requestData.MetricsCollection.Metrics); + if (!_testPlatform.StartTestSession(requestData, criteria, eventsHandler)) + { + EqtTrace.Warning("TestRequestManager.StartTestSession: Unable to start test session."); } } + finally + { + EqtTrace.Info("TestRequestManager.StartTestSession: Starting test session completed."); + _testPlatformEventSource.StartTestSessionStop(); + + // Post the attachments processing complete event. + _metricsPublisher.Result.PublishMetrics( + TelemetryDataConstants.StartTestSessionCompleteEvent, + requestData.MetricsCollection.Metrics); + } } + } - private void LogTelemetryForLegacySettings(IRequestData requestData, string runsettings) - { - requestData.MetricsCollection.Add( - TelemetryDataConstants.TestSettingsUsed, - InferRunSettingsHelper.IsTestSettingsEnabled(runsettings)); + private void LogTelemetryForLegacySettings(IRequestData requestData, string runsettings) + { + requestData.MetricsCollection.Add( + TelemetryDataConstants.TestSettingsUsed, + InferRunSettingsHelper.IsTestSettingsEnabled(runsettings)); - if (InferRunSettingsHelper.TryGetLegacySettingElements( + if (InferRunSettingsHelper.TryGetLegacySettingElements( runsettings, out Dictionary legacySettingsTelemetry)) + { + foreach (var ciData in legacySettingsTelemetry) { - foreach (var ciData in legacySettingsTelemetry) - { - // We are collecting telemetry for the legacy nodes and attributes used in the runsettings. - requestData.MetricsCollection.Add( - string.Format( - "{0}.{1}", - TelemetryDataConstants.LegacySettingPrefix, - ciData.Key), - ciData.Value); - } + // We are collecting telemetry for the legacy nodes and attributes used in the runsettings. + requestData.MetricsCollection.Add( + string.Format( + "{0}.{1}", + TelemetryDataConstants.LegacySettingPrefix, + ciData.Key), + ciData.Value); } } + } - /// - public void CancelTestRun() - { - EqtTrace.Info("TestRequestManager.CancelTestRun: Sending cancel request."); - this.currentTestRunRequest?.CancelAsync(); - } + /// + public void CancelTestRun() + { + EqtTrace.Info("TestRequestManager.CancelTestRun: Sending cancel request."); + _currentTestRunRequest?.CancelAsync(); + } - /// - public void CancelDiscovery() - { - EqtTrace.Info("TestRequestManager.CancelTestDiscovery: Sending cancel request."); - this.currentDiscoveryRequest?.Abort(); - } + /// + public void CancelDiscovery() + { + EqtTrace.Info("TestRequestManager.CancelTestDiscovery: Sending cancel request."); + _currentDiscoveryRequest?.Abort(); + } - /// - public void AbortTestRun() - { - EqtTrace.Info("TestRequestManager.AbortTestRun: Sending abort request."); - this.currentTestRunRequest?.Abort(); - } + /// + public void AbortTestRun() + { + EqtTrace.Info("TestRequestManager.AbortTestRun: Sending abort request."); + _currentTestRunRequest?.Abort(); + } - /// - public void CancelTestRunAttachmentsProcessing() - { - EqtTrace.Info("TestRequestManager.CancelTestRunAttachmentsProcessing: Sending cancel request."); - this.currentAttachmentsProcessingCancellationTokenSource?.Cancel(); - } + /// + public void CancelTestRunAttachmentsProcessing() + { + EqtTrace.Info("TestRequestManager.CancelTestRunAttachmentsProcessing: Sending cancel request."); + _currentAttachmentsProcessingCancellationTokenSource?.Cancel(); + } - #endregion + #endregion - public void Dispose() - { - this.Dispose(true); + public void Dispose() + { + Dispose(true); - // Use SupressFinalize in case a subclass - // of this type implements a finalizer. - GC.SuppressFinalize(this); - } + // Use SupressFinalize in case a subclass + // of this type implements a finalizer. + GC.SuppressFinalize(this); + } - private void Dispose(bool disposing) + private void Dispose(bool disposing) + { + if (!_isDisposed) { - if (!this.isDisposed) + if (disposing) { - if (disposing) - { - this.metricsPublisher.Result.Dispose(); - } - - this.isDisposed = true; + _metricsPublisher.Result.Dispose(); } + + _isDisposed = true; } + } - private bool UpdateRunSettingsIfRequired( - string runsettingsXml, - IList sources, - IBaseTestEventsRegistrar registrar, - out string updatedRunSettingsXml) - { - bool settingsUpdated = false; - updatedRunSettingsXml = runsettingsXml; - var sourcePlatforms = new Dictionary(); - var sourceFrameworks = new Dictionary(); + private bool UpdateRunSettingsIfRequired( + string runsettingsXml, + IList sources, + IBaseTestEventsRegistrar registrar, + out string updatedRunSettingsXml) + { + bool settingsUpdated = false; + updatedRunSettingsXml = runsettingsXml; + var sourcePlatforms = new Dictionary(); + var sourceFrameworks = new Dictionary(); - if (!string.IsNullOrEmpty(runsettingsXml)) + if (!string.IsNullOrEmpty(runsettingsXml)) + { + // TargetFramework is full CLR. Set DesignMode based on current context. + using var stream = new StringReader(runsettingsXml); + using var reader = XmlReader.Create( + stream, + XmlRunSettingsUtilities.ReaderSettings); + var document = new XmlDocument(); + document.Load(reader); + var navigator = document.CreateNavigator(); + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettingsXml); + var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runsettingsXml) + ?? new LoggerRunSettings(); + + settingsUpdated |= UpdateFramework( + document, + navigator, + sources, + sourceFrameworks, + registrar, + out Framework chosenFramework); + + // Choose default architecture based on the framework. + // For .NET core, the default platform architecture should be based on the process. + Architecture defaultArchitecture = Architecture.X86; + if (chosenFramework.Name.IndexOf("netstandard", StringComparison.OrdinalIgnoreCase) >= 0 + || chosenFramework.Name.IndexOf("netcoreapp", StringComparison.OrdinalIgnoreCase) >= 0 + // This is a special case for 1 version of Nuget.Frameworks that was shipped with using identifier NET5 instead of NETCoreApp5 for .NET 5. + || chosenFramework.Name.IndexOf("net5", StringComparison.OrdinalIgnoreCase) >= 0) { - // TargetFramework is full CLR. Set DesignMode based on current context. - using (var stream = new StringReader(runsettingsXml)) - using (var reader = XmlReader.Create( - stream, - XmlRunSettingsUtilities.ReaderSettings)) - { - var document = new XmlDocument(); - document.Load(reader); - var navigator = document.CreateNavigator(); - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettingsXml); - var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runsettingsXml) - ?? new LoggerRunSettings(); - - settingsUpdated |= this.UpdateFramework( - document, - navigator, - sources, - sourceFrameworks, - registrar, - out Framework chosenFramework); - - // Choose default architecture based on the framework. - // For .NET core, the default platform architecture should be based on the process. - Architecture defaultArchitecture = Architecture.X86; - if (chosenFramework.Name.IndexOf("netstandard", StringComparison.OrdinalIgnoreCase) >= 0 - || chosenFramework.Name.IndexOf("netcoreapp", StringComparison.OrdinalIgnoreCase) >= 0 - // This is a special case for 1 version of Nuget.Frameworks that was shipped with using identifier NET5 instead of NETCoreApp5 for .NET 5. - || chosenFramework.Name.IndexOf("net5", StringComparison.OrdinalIgnoreCase) >= 0) - { #if NETCOREAPP - // We are running in vstest.console that is either started via dotnet.exe - // or via vstest.console.exe .NET Core executable. For AnyCPU dlls this - // should resolve 32-bit SDK when running from 32-bit dotnet process and - // 64-bit SDK when running from 64-bit dotnet process. - // As default architecture we specify the expected test host architecture, - // it can be specified by user on the command line with --arch or through runsettings. - // If it's not specified by user will be filled by current processor architecture; - // should be the same as SDK. - defaultArchitecture = RunSettingsHelper.Instance.IsDefaultTargetArchitecture ? - TranslateToArchitecture(processHelper.GetCurrentProcessArchitecture()) : - runConfiguration.TargetPlatform; + // We are running in vstest.console that is either started via dotnet.exe + // or via vstest.console.exe .NET Core executable. For AnyCPU dlls this + // should resolve 32-bit SDK when running from 32-bit dotnet process and + // 64-bit SDK when running from 64-bit dotnet process. + // As default architecture we specify the expected test host architecture, + // it can be specified by user on the command line with --arch or through runsettings. + // If it's not specified by user will be filled by current processor architecture; + // should be the same as SDK. + defaultArchitecture = RunSettingsHelper.Instance.IsDefaultTargetArchitecture ? + TranslateToArchitecture(_processHelper.GetCurrentProcessArchitecture()) : + runConfiguration.TargetPlatform; #else - // We are running in vstest.console.exe that was built against .NET - // Framework. This console prefers 32-bit because it needs to run as 32-bit - // to be compatible with QTAgent. It runs as 32-bit both under VS and in - // Developer console. Set the default architecture based on the OS - // architecture, to find 64-bit dotnet SDK when running AnyCPU dll on 64-bit - // system, and 32-bit SDK when running AnyCPU dll on 32-bit OS. - // We want to find 64-bit SDK because it is more likely to be installed. - defaultArchitecture = Environment.Is64BitOperatingSystem ? Architecture.X64 : Architecture.X86; + // We are running in vstest.console.exe that was built against .NET + // Framework. This console prefers 32-bit because it needs to run as 32-bit + // to be compatible with QTAgent. It runs as 32-bit both under VS and in + // Developer console. Set the default architecture based on the OS + // architecture, to find 64-bit dotnet SDK when running AnyCPU dll on 64-bit + // system, and 32-bit SDK when running AnyCPU dll on 32-bit OS. + // We want to find 64-bit SDK because it is more likely to be installed. + defaultArchitecture = Environment.Is64BitOperatingSystem ? Architecture.X64 : Architecture.X86; #endif - EqtTrace.Verbose($"Default architecture: {defaultArchitecture} IsDefaultTargetArchitecture: {RunSettingsHelper.Instance.IsDefaultTargetArchitecture}"); - } - - settingsUpdated |= this.UpdatePlatform( - document, - navigator, - sources, - sourcePlatforms, - defaultArchitecture, - out Architecture chosenPlatform); - this.CheckSourcesForCompatibility( - chosenFramework, - chosenPlatform, - defaultArchitecture, - sourcePlatforms, - sourceFrameworks, - registrar); - settingsUpdated |= this.UpdateDesignMode(document, runConfiguration); - settingsUpdated |= this.UpdateCollectSourceInformation(document, runConfiguration); - settingsUpdated |= this.UpdateTargetDevice(navigator, document, runConfiguration); - settingsUpdated |= this.AddOrUpdateConsoleLogger(document, runConfiguration, loggerRunSettings); - - updatedRunSettingsXml = navigator.OuterXml; - } + EqtTrace.Verbose($"Default architecture: {defaultArchitecture} IsDefaultTargetArchitecture: {RunSettingsHelper.Instance.IsDefaultTargetArchitecture}"); } - return settingsUpdated; - -#if NETCOREAPP - Architecture TranslateToArchitecture(PlatformArchitecture targetArchitecture) - { - switch (targetArchitecture) - { - case PlatformArchitecture.X86: - return Architecture.X86; - case PlatformArchitecture.X64: - return Architecture.X64; - case PlatformArchitecture.ARM: - return Architecture.ARM; - case PlatformArchitecture.ARM64: - return Architecture.ARM64; - default: - break; - } + settingsUpdated |= UpdatePlatform( + document, + navigator, + sources, + sourcePlatforms, + defaultArchitecture, + out Architecture chosenPlatform); + CheckSourcesForCompatibility( + chosenFramework, + chosenPlatform, + defaultArchitecture, + sourcePlatforms, + sourceFrameworks, + registrar); + settingsUpdated |= UpdateDesignMode(document, runConfiguration); + settingsUpdated |= UpdateCollectSourceInformation(document, runConfiguration); + settingsUpdated |= UpdateTargetDevice(navigator, document, runConfiguration); + settingsUpdated |= AddOrUpdateConsoleLogger(document, runConfiguration, loggerRunSettings); - throw new TestPlatformException($"Invalid target architecture '{targetArchitecture}'"); - } -#endif + updatedRunSettingsXml = navigator.OuterXml; } - private bool AddOrUpdateConsoleLogger( - XmlDocument document, - RunConfiguration runConfiguration, - LoggerRunSettings loggerRunSettings) + return settingsUpdated; + +#if NETCOREAPP + static Architecture TranslateToArchitecture(PlatformArchitecture targetArchitecture) { - // Update console logger settings. - bool consoleLoggerUpdated = this.UpdateConsoleLoggerIfExists(document, loggerRunSettings); - - // In case of CLI, add console logger if not already present. - bool designMode = runConfiguration.DesignModeSet - ? runConfiguration.DesignMode - : this.commandLineOptions.IsDesignMode; - if (!designMode && !consoleLoggerUpdated) + switch (targetArchitecture) { - this.AddConsoleLogger(document, loggerRunSettings); + case PlatformArchitecture.X86: + return Architecture.X86; + case PlatformArchitecture.X64: + return Architecture.X64; + case PlatformArchitecture.ARM: + return Architecture.ARM; + case PlatformArchitecture.ARM64: + return Architecture.ARM64; + default: + break; } - // Update is required: - // 1) in case of CLI; - // 2) in case of design mode if console logger is present in runsettings. - return !designMode || consoleLoggerUpdated; + throw new TestPlatformException($"Invalid target architecture '{targetArchitecture}'"); } +#endif + } - private bool UpdateTargetDevice( - XPathNavigator navigator, - XmlDocument document, - RunConfiguration runConfiguration) + private bool AddOrUpdateConsoleLogger( + XmlDocument document, + RunConfiguration runConfiguration, + LoggerRunSettings loggerRunSettings) + { + // Update console logger settings. + bool consoleLoggerUpdated = UpdateConsoleLoggerIfExists(document, loggerRunSettings); + + // In case of CLI, add console logger if not already present. + bool designMode = runConfiguration.DesignModeSet + ? runConfiguration.DesignMode + : _commandLineOptions.IsDesignMode; + if (!designMode && !consoleLoggerUpdated) { - bool updateRequired = InferRunSettingsHelper.TryGetDeviceXml(navigator, out string deviceXml); - if (updateRequired) - { - InferRunSettingsHelper.UpdateTargetDevice(document, deviceXml); - } - return updateRequired; + AddConsoleLogger(document, loggerRunSettings); } - private bool UpdateCollectSourceInformation( - XmlDocument document, - RunConfiguration runConfiguration) + // Update is required: + // 1) in case of CLI; + // 2) in case of design mode if console logger is present in runsettings. + return !designMode || consoleLoggerUpdated; + } + + private bool UpdateTargetDevice( + XPathNavigator navigator, + XmlDocument document, + RunConfiguration runConfiguration) + { + bool updateRequired = InferRunSettingsHelper.TryGetDeviceXml(navigator, out string deviceXml); + if (updateRequired) { - bool updateRequired = !runConfiguration.CollectSourceInformationSet; - if (updateRequired) - { - InferRunSettingsHelper.UpdateCollectSourceInformation( - document, - this.commandLineOptions.ShouldCollectSourceInformation); - } - return updateRequired; + InferRunSettingsHelper.UpdateTargetDevice(document, deviceXml); } + return updateRequired; + } - private bool UpdateDesignMode(XmlDocument document, RunConfiguration runConfiguration) + private bool UpdateCollectSourceInformation( + XmlDocument document, + RunConfiguration runConfiguration) + { + bool updateRequired = !runConfiguration.CollectSourceInformationSet; + if (updateRequired) { - // If user is already setting DesignMode via runsettings or CLI args; we skip. - bool updateRequired = !runConfiguration.DesignModeSet; - if (updateRequired) - { - InferRunSettingsHelper.UpdateDesignMode( - document, - this.commandLineOptions.IsDesignMode); - } - return updateRequired; + InferRunSettingsHelper.UpdateCollectSourceInformation( + document, + _commandLineOptions.ShouldCollectSourceInformation); } + return updateRequired; + } - private void CheckSourcesForCompatibility( - Framework chosenFramework, - Architecture chosenPlatform, - Architecture defaultArchitecture, - IDictionary sourcePlatforms, - IDictionary sourceFrameworks, - IBaseTestEventsRegistrar registrar) + private bool UpdateDesignMode(XmlDocument document, RunConfiguration runConfiguration) + { + // If user is already setting DesignMode via runsettings or CLI args; we skip. + bool updateRequired = !runConfiguration.DesignModeSet; + if (updateRequired) { - // Find compatible sources. - var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources( - chosenPlatform, - defaultArchitecture, - chosenFramework, - sourcePlatforms, - sourceFrameworks, - out var incompatibleSettingWarning); - - // Raise warnings for incompatible sources - if (!string.IsNullOrEmpty(incompatibleSettingWarning)) - { - EqtTrace.Warning(incompatibleSettingWarning); - registrar?.LogWarning(incompatibleSettingWarning); - } + InferRunSettingsHelper.UpdateDesignMode( + document, + _commandLineOptions.IsDesignMode); + } + return updateRequired; + } - // Log compatible sources - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("Compatible sources list : "); - EqtTrace.Info(string.Join("\n", compatibleSources.ToArray())); - } + private void CheckSourcesForCompatibility( + Framework chosenFramework, + Architecture chosenPlatform, + Architecture defaultArchitecture, + IDictionary sourcePlatforms, + IDictionary sourceFrameworks, + IBaseTestEventsRegistrar registrar) + { + // Find compatible sources. + var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources( + chosenPlatform, + defaultArchitecture, + chosenFramework, + sourcePlatforms, + sourceFrameworks, + out var incompatibleSettingWarning); + + // Raise warnings for incompatible sources + if (!string.IsNullOrEmpty(incompatibleSettingWarning)) + { + EqtTrace.Warning(incompatibleSettingWarning); + registrar?.LogWarning(incompatibleSettingWarning); } - private bool UpdatePlatform( - XmlDocument document, - XPathNavigator navigator, - IList sources, - IDictionary sourcePlatforms, - Architecture defaultArchitecture, - out Architecture chosenPlatform) + // Log compatible sources + if (EqtTrace.IsInfoEnabled) { - // Get platform from sources. - var inferedPlatform = inferHelper.AutoDetectArchitecture( - sources, - sourcePlatforms, - defaultArchitecture); + EqtTrace.Info("Compatible sources list : "); + EqtTrace.Info(string.Join("\n", compatibleSources.ToArray())); + } + } - EqtTrace.Info($"Infered platform '{inferedPlatform}'."); + private bool UpdatePlatform( + XmlDocument document, + XPathNavigator navigator, + IList sources, + IDictionary sourcePlatforms, + Architecture defaultArchitecture, + out Architecture chosenPlatform) + { + // Get platform from sources. + var inferedPlatform = _inferHelper.AutoDetectArchitecture( + sources, + sourcePlatforms, + defaultArchitecture); - // Get platform from runsettings. - bool updatePlatform = IsAutoPlatformDetectRequired(navigator, out chosenPlatform); + EqtTrace.Info($"Infered platform '{inferedPlatform}'."); - // Update platform if required. For command line scenario update happens in - // ArgumentProcessor. - if (updatePlatform) - { - EqtTrace.Info($"Platform update to '{inferedPlatform}' required."); - InferRunSettingsHelper.UpdateTargetPlatform( - document, - inferedPlatform.ToString(), - overwrite: true); - chosenPlatform = inferedPlatform; - } + // Get platform from runsettings. + bool updatePlatform = IsAutoPlatformDetectRequired(navigator, out chosenPlatform); - return updatePlatform; + // Update platform if required. For command line scenario update happens in + // ArgumentProcessor. + if (updatePlatform) + { + EqtTrace.Info($"Platform update to '{inferedPlatform}' required."); + InferRunSettingsHelper.UpdateTargetPlatform( + document, + inferedPlatform.ToString(), + overwrite: true); + chosenPlatform = inferedPlatform; } - private bool UpdateFramework( - XmlDocument document, - XPathNavigator navigator, - IList sources, - IDictionary sourceFrameworks, - IBaseTestEventsRegistrar registrar, - out Framework chosenFramework) - { - // Get framework from sources. - // This looks like you can optimize it by moving it down to if (updateFramework), but it has a side-effect of - // populating the sourceFrameworks, which is later checked when source compatibility check is done against the value - // that we either inferred as the common framework, or that is forced in runsettings. - var inferedFramework = inferHelper.AutoDetectFramework(sources, sourceFrameworks); - - // See if framework is forced by runsettings. If not autodetect it. - bool updateFramework = IsAutoFrameworkDetectRequired(navigator, out chosenFramework); - - // Update framework if required. For command line scenario update happens in - // ArgumentProcessor. - if (updateFramework) - { - InferRunSettingsHelper.UpdateTargetFramework( - document, - inferedFramework.ToString(), - overwrite: true); - chosenFramework = inferedFramework; - } + return updatePlatform; + } - // Raise warnings for unsupported frameworks. - if (Constants.DotNetFramework35.Equals(chosenFramework.Name)) - { - EqtTrace.Warning("TestRequestManager.UpdateRunSettingsIfRequired: throw warning on /Framework:Framework35 option."); - registrar.LogWarning(Resources.Framework35NotSupported); - } + private bool UpdateFramework( + XmlDocument document, + XPathNavigator navigator, + IList sources, + IDictionary sourceFrameworks, + IBaseTestEventsRegistrar registrar, + out Framework chosenFramework) + { + // Get framework from sources. + // This looks like you can optimize it by moving it down to if (updateFramework), but it has a side-effect of + // populating the sourceFrameworks, which is later checked when source compatibility check is done against the value + // that we either inferred as the common framework, or that is forced in runsettings. + var inferedFramework = _inferHelper.AutoDetectFramework(sources, sourceFrameworks); + + // See if framework is forced by runsettings. If not autodetect it. + bool updateFramework = IsAutoFrameworkDetectRequired(navigator, out chosenFramework); + + // Update framework if required. For command line scenario update happens in + // ArgumentProcessor. + if (updateFramework) + { + InferRunSettingsHelper.UpdateTargetFramework( + document, + inferedFramework.ToString(), + overwrite: true); + chosenFramework = inferedFramework; + } - return updateFramework; + // Raise warnings for unsupported frameworks. + if (Constants.DotNetFramework35.Equals(chosenFramework.Name)) + { + EqtTrace.Warning("TestRequestManager.UpdateRunSettingsIfRequired: throw warning on /Framework:Framework35 option."); + registrar.LogWarning(Resources.Framework35NotSupported); } - /// - /// Add console logger in runsettings. - /// - /// Runsettings document. - /// Logger run settings. - private void AddConsoleLogger(XmlDocument document, LoggerRunSettings loggerRunSettings) + return updateFramework; + } + + /// + /// Add console logger in runsettings. + /// + /// Runsettings document. + /// Logger run settings. + private void AddConsoleLogger(XmlDocument document, LoggerRunSettings loggerRunSettings) + { + var consoleLogger = new LoggerSettings { - var consoleLogger = new LoggerSettings - { - FriendlyName = ConsoleLogger.FriendlyName, - Uri = new Uri(ConsoleLogger.ExtensionUri), - AssemblyQualifiedName = typeof(ConsoleLogger).AssemblyQualifiedName, - CodeBase = typeof(ConsoleLogger).GetTypeInfo().Assembly.Location, - IsEnabled = true - }; - - loggerRunSettings.LoggerSettingsList.Add(consoleLogger); + FriendlyName = ConsoleLogger.FriendlyName, + Uri = new Uri(ConsoleLogger.ExtensionUri), + AssemblyQualifiedName = typeof(ConsoleLogger).AssemblyQualifiedName, + CodeBase = typeof(ConsoleLogger).GetTypeInfo().Assembly.Location, + IsEnabled = true + }; + + loggerRunSettings.LoggerSettingsList.Add(consoleLogger); + RunSettingsProviderExtensions.UpdateRunSettingsXmlDocumentInnerXml( + document, + Constants.LoggerRunSettingsName, + loggerRunSettings.ToXml().InnerXml); + } + + /// + /// Add console logger in runsettings if exists. + /// + /// Runsettings document. + /// Logger run settings. + /// True if updated console logger in runsettings successfully. + private bool UpdateConsoleLoggerIfExists( + XmlDocument document, + LoggerRunSettings loggerRunSettings) + { + var defaultConsoleLogger = new LoggerSettings + { + FriendlyName = ConsoleLogger.FriendlyName, + Uri = new Uri(ConsoleLogger.ExtensionUri) + }; + + var existingLoggerIndex = loggerRunSettings.GetExistingLoggerIndex(defaultConsoleLogger); + + // Update assemblyQualifiedName and codeBase of existing logger. + if (existingLoggerIndex >= 0) + { + var consoleLogger = loggerRunSettings.LoggerSettingsList[existingLoggerIndex]; + consoleLogger.AssemblyQualifiedName = typeof(ConsoleLogger).AssemblyQualifiedName; + consoleLogger.CodeBase = typeof(ConsoleLogger).GetTypeInfo().Assembly.Location; RunSettingsProviderExtensions.UpdateRunSettingsXmlDocumentInnerXml( document, Constants.LoggerRunSettingsName, loggerRunSettings.ToXml().InnerXml); + + return true; } - /// - /// Add console logger in runsettings if exists. - /// - /// Runsettings document. - /// Logger run settings. - /// True if updated console logger in runsettings successfully. - private bool UpdateConsoleLoggerIfExists( - XmlDocument document, - LoggerRunSettings loggerRunSettings) + return false; + } + + private void RunTests( + IRequestData requestData, + TestRunCriteria testRunCriteria, + ITestRunEventsRegistrar testRunEventsRegistrar, + TestPlatformOptions options) + { + // Make sure to run the run request inside a lock as the below section is not thread-safe. + // TranslationLayer can process faster as it directly gets the raw un-serialized messages + // whereas below logic needs to deserialize and do some cleanup. + // While this section is cleaning up, TranslationLayer can trigger run causing multiple + // threads to run the below section at the same time. + lock (_syncObject) { - var defaultConsoleLogger = new LoggerSettings + try { - FriendlyName = ConsoleLogger.FriendlyName, - Uri = new Uri(ConsoleLogger.ExtensionUri) - }; + _currentTestRunRequest = _testPlatform.CreateTestRunRequest( + requestData, + testRunCriteria, + options); - var existingLoggerIndex = loggerRunSettings.GetExistingLoggerIndex(defaultConsoleLogger); + _testRunResultAggregator.RegisterTestRunEvents(_currentTestRunRequest); + testRunEventsRegistrar?.RegisterTestRunEvents(_currentTestRunRequest); - // Update assemblyQualifiedName and codeBase of existing logger. - if (existingLoggerIndex >= 0) - { - var consoleLogger = loggerRunSettings.LoggerSettingsList[existingLoggerIndex]; - consoleLogger.AssemblyQualifiedName = typeof(ConsoleLogger).AssemblyQualifiedName; - consoleLogger.CodeBase = typeof(ConsoleLogger).GetTypeInfo().Assembly.Location; - RunSettingsProviderExtensions.UpdateRunSettingsXmlDocumentInnerXml( - document, - Constants.LoggerRunSettingsName, - loggerRunSettings.ToXml().InnerXml); - - return true; - } + _testPlatformEventSource.ExecutionRequestStart(); - return false; - } + _currentTestRunRequest.ExecuteAsync(); - private void RunTests( - IRequestData requestData, - TestRunCriteria testRunCriteria, - ITestRunEventsRegistrar testRunEventsRegistrar, - TestPlatformOptions options) - { - // Make sure to run the run request inside a lock as the below section is not thread-safe. - // TranslationLayer can process faster as it directly gets the raw un-serialized messages - // whereas below logic needs to deserialize and do some cleanup. - // While this section is cleaning up, TranslationLayer can trigger run causing multiple - // threads to run the below section at the same time. - lock (this.syncObject) + // Wait for the run completion event + _currentTestRunRequest.WaitForCompletion(); + } + catch (Exception ex) + { + EqtTrace.Error("TestRequestManager.RunTests: failed to run tests: {0}", ex); + _testRunResultAggregator.MarkTestRunFailed(); + throw; + } + finally { - try + if (_currentTestRunRequest != null) { - this.currentTestRunRequest = this.testPlatform.CreateTestRunRequest( - requestData, - testRunCriteria, - options); - - this.testRunResultAggregator.RegisterTestRunEvents(this.currentTestRunRequest); - testRunEventsRegistrar?.RegisterTestRunEvents(this.currentTestRunRequest); - - this.testPlatformEventSource.ExecutionRequestStart(); + _testRunResultAggregator.UnregisterTestRunEvents(_currentTestRunRequest); + testRunEventsRegistrar?.UnregisterTestRunEvents(_currentTestRunRequest); - this.currentTestRunRequest.ExecuteAsync(); - - // Wait for the run completion event - this.currentTestRunRequest.WaitForCompletion(); - } - catch (Exception ex) - { - EqtTrace.Error("TestRequestManager.RunTests: failed to run tests: {0}", ex); - testRunResultAggregator.MarkTestRunFailed(); - throw; - } - finally - { - if (this.currentTestRunRequest != null) - { - this.testRunResultAggregator.UnregisterTestRunEvents(this.currentTestRunRequest); - testRunEventsRegistrar?.UnregisterTestRunEvents(this.currentTestRunRequest); - - this.currentTestRunRequest.Dispose(); - this.currentTestRunRequest = null; - } + _currentTestRunRequest.Dispose(); + _currentTestRunRequest = null; } } } + } - private bool IsAutoFrameworkDetectRequired( - XPathNavigator navigator, - out Framework chosenFramework) + private bool IsAutoFrameworkDetectRequired( + XPathNavigator navigator, + out Framework chosenFramework) + { + bool required = true; + chosenFramework = null; + if (_commandLineOptions.IsDesignMode) { - bool required = true; - chosenFramework = null; - if (commandLineOptions.IsDesignMode) - { - bool isValidFx = - InferRunSettingsHelper.TryGetFrameworkXml( - navigator, - out var frameworkFromrunsettingsXml); - required = !isValidFx || string.IsNullOrWhiteSpace(frameworkFromrunsettingsXml); - if (!required) - { - chosenFramework = Framework.FromString(frameworkFromrunsettingsXml); - } - } - else if (!commandLineOptions.IsDesignMode - && commandLineOptions.FrameworkVersionSpecified) + bool isValidFx = + InferRunSettingsHelper.TryGetFrameworkXml( + navigator, + out var frameworkFromrunsettingsXml); + required = !isValidFx || string.IsNullOrWhiteSpace(frameworkFromrunsettingsXml); + if (!required) { - required = false; - chosenFramework = commandLineOptions.TargetFrameworkVersion; + chosenFramework = Framework.FromString(frameworkFromrunsettingsXml); } - - return required; + } + else if (!_commandLineOptions.IsDesignMode + && _commandLineOptions.FrameworkVersionSpecified) + { + required = false; + chosenFramework = _commandLineOptions.TargetFrameworkVersion; } - private bool IsAutoPlatformDetectRequired( - XPathNavigator navigator, - out Architecture chosenPlatform) + return required; + } + + private bool IsAutoPlatformDetectRequired( + XPathNavigator navigator, + out Architecture chosenPlatform) + { + bool required = true; + chosenPlatform = Architecture.Default; + if (_commandLineOptions.IsDesignMode) { - bool required = true; - chosenPlatform = Architecture.Default; - if (commandLineOptions.IsDesignMode) - { - bool isValidPlatform = InferRunSettingsHelper.TryGetPlatformXml( - navigator, - out var platformXml); + bool isValidPlatform = InferRunSettingsHelper.TryGetPlatformXml( + navigator, + out var platformXml); - required = !isValidPlatform || string.IsNullOrWhiteSpace(platformXml); - if (!required) - { - chosenPlatform = (Architecture)Enum.Parse( - typeof(Architecture), - platformXml, true); - } - } - else if (!commandLineOptions.IsDesignMode && commandLineOptions.ArchitectureSpecified) + required = !isValidPlatform || string.IsNullOrWhiteSpace(platformXml); + if (!required) { - required = false; - chosenPlatform = commandLineOptions.TargetArchitecture; + chosenPlatform = (Architecture)Enum.Parse( + typeof(Architecture), + platformXml, true); } - - return required; } + else if (!_commandLineOptions.IsDesignMode && _commandLineOptions.ArchitectureSpecified) + { + required = false; + chosenPlatform = _commandLineOptions.TargetArchitecture; + } + + return required; + } - /// - /// Collect metrics. - /// - /// Request data for common Discovery/Execution services. - /// Run configuration. - private void CollectMetrics(IRequestData requestData, RunConfiguration runConfiguration) + /// + /// Collect metrics. + /// + /// Request data for common Discovery/Execution services. + /// Run configuration. + private void CollectMetrics(IRequestData requestData, RunConfiguration runConfiguration) + { + // Collecting Target Framework. + requestData.MetricsCollection.Add( + TelemetryDataConstants.TargetFramework, + runConfiguration.TargetFramework.Name); + + // Collecting Target Platform. + requestData.MetricsCollection.Add( + TelemetryDataConstants.TargetPlatform, + runConfiguration.TargetPlatform.ToString()); + + // Collecting Max CPU count. + requestData.MetricsCollection.Add( + TelemetryDataConstants.MaxCPUcount, + runConfiguration.MaxCpuCount); + + // Collecting Target Device. Here, it will be updated run settings so, target device + // will be under run configuration only. + var targetDevice = runConfiguration.TargetDevice; + if (string.IsNullOrEmpty(targetDevice)) { - // Collecting Target Framework. requestData.MetricsCollection.Add( - TelemetryDataConstants.TargetFramework, - runConfiguration.TargetFramework.Name); - - // Collecting Target Platform. + TelemetryDataConstants.TargetDevice, + "Local Machine"); + } + else if (targetDevice.Equals("Device", StringComparison.Ordinal) + || targetDevice.Contains("Emulator")) + { requestData.MetricsCollection.Add( - TelemetryDataConstants.TargetPlatform, - runConfiguration.TargetPlatform.ToString()); - - // Collecting Max CPU count. + TelemetryDataConstants.TargetDevice, + targetDevice); + } + else + { + // For IOT scenarios. requestData.MetricsCollection.Add( - TelemetryDataConstants.MaxCPUcount, - runConfiguration.MaxCpuCount); + TelemetryDataConstants.TargetDevice, + "Other"); + } - // Collecting Target Device. Here, it will be updated run settings so, target device - // will be under run configuration only. - var targetDevice = runConfiguration.TargetDevice; - if (string.IsNullOrEmpty(targetDevice)) - { - requestData.MetricsCollection.Add( - TelemetryDataConstants.TargetDevice, - "Local Machine"); - } - else if (targetDevice.Equals("Device", StringComparison.Ordinal) - || targetDevice.Contains("Emulator")) - { - requestData.MetricsCollection.Add( - TelemetryDataConstants.TargetDevice, - targetDevice); - } - else - { - // For IOT scenarios. - requestData.MetricsCollection.Add( - TelemetryDataConstants.TargetDevice, - "Other"); - } + // Collecting TestPlatform version. + requestData.MetricsCollection.Add( + TelemetryDataConstants.TestPlatformVersion, + Product.Version); - // Collecting TestPlatform version. - requestData.MetricsCollection.Add( - TelemetryDataConstants.TestPlatformVersion, - Product.Version); + // Collecting TargetOS. + requestData.MetricsCollection.Add( + TelemetryDataConstants.TargetOS, + new PlatformEnvironment().OperatingSystemVersion); - // Collecting TargetOS. - requestData.MetricsCollection.Add( - TelemetryDataConstants.TargetOS, - new PlatformEnvironment().OperatingSystemVersion); + //Collecting DisableAppDomain. + requestData.MetricsCollection.Add( + TelemetryDataConstants.DisableAppDomain, + runConfiguration.DisableAppDomain); - //Collecting DisableAppDomain. - requestData.MetricsCollection.Add( - TelemetryDataConstants.DisableAppDomain, - runConfiguration.DisableAppDomain); + } + + /// + /// Checks whether Telemetry opted in or not. + /// By Default opting out + /// + /// Returns Telemetry Opted out or not + private static bool IsTelemetryOptedIn() + { + var telemetryStatus = Environment.GetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN"); + return !string.IsNullOrEmpty(telemetryStatus) + && telemetryStatus.Equals("1", StringComparison.Ordinal); + } + + /// + /// Log Command Line switches for Telemetry purposes + /// + /// Request Data providing common discovery/execution services. + private void LogCommandsTelemetryPoints(IRequestData requestData) + { + var commandsUsed = new List(); + var parallel = _commandLineOptions.Parallel; + if (parallel) + { + commandsUsed.Add("/Parallel"); } - /// - /// Checks whether Telemetry opted in or not. - /// By Default opting out - /// - /// Returns Telemetry Opted out or not - private static bool IsTelemetryOptedIn() + var platform = _commandLineOptions.ArchitectureSpecified; + if (platform) { - var telemetryStatus = Environment.GetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN"); - return !string.IsNullOrEmpty(telemetryStatus) - && telemetryStatus.Equals("1", StringComparison.Ordinal); + commandsUsed.Add("/Platform"); } - /// - /// Log Command Line switches for Telemetry purposes - /// - /// Request Data providing common discovery/execution services. - private void LogCommandsTelemetryPoints(IRequestData requestData) + var enableCodeCoverage = _commandLineOptions.EnableCodeCoverage; + if (enableCodeCoverage) { - var commandsUsed = new List(); + commandsUsed.Add("/EnableCodeCoverage"); + } - var parallel = this.commandLineOptions.Parallel; - if (parallel) - { - commandsUsed.Add("/Parallel"); - } + var inIsolation = _commandLineOptions.InIsolation; + if (inIsolation) + { + commandsUsed.Add("/InIsolation"); + } - var platform = this.commandLineOptions.ArchitectureSpecified; - if (platform) - { - commandsUsed.Add("/Platform"); - } + var useVsixExtensions = _commandLineOptions.UseVsixExtensions; + if (useVsixExtensions) + { + commandsUsed.Add("/UseVsixExtensions"); + } - var enableCodeCoverage = this.commandLineOptions.EnableCodeCoverage; - if (enableCodeCoverage) - { - commandsUsed.Add("/EnableCodeCoverage"); - } + var frameworkVersionSpecified = _commandLineOptions.FrameworkVersionSpecified; + if (frameworkVersionSpecified) + { + commandsUsed.Add("/Framework"); + } - var inIsolation = this.commandLineOptions.InIsolation; - if (inIsolation) + var settings = _commandLineOptions.SettingsFile; + if (!string.IsNullOrEmpty(settings)) + { + var extension = Path.GetExtension(settings); + if (string.Equals(extension, ".runsettings", StringComparison.OrdinalIgnoreCase)) { - commandsUsed.Add("/InIsolation"); + commandsUsed.Add("/settings//.RunSettings"); } - - var useVsixExtensions = this.commandLineOptions.UseVsixExtensions; - if (useVsixExtensions) + else if (string.Equals(extension, ".testsettings", StringComparison.OrdinalIgnoreCase)) { - commandsUsed.Add("/UseVsixExtensions"); + commandsUsed.Add("/settings//.TestSettings"); } - - var frameworkVersionSpecified = this.commandLineOptions.FrameworkVersionSpecified; - if (frameworkVersionSpecified) + else if (string.Equals(extension, ".vsmdi", StringComparison.OrdinalIgnoreCase)) { - commandsUsed.Add("/Framework"); + commandsUsed.Add("/settings//.vsmdi"); } - - var settings = this.commandLineOptions.SettingsFile; - if (!string.IsNullOrEmpty(settings)) + else if (string.Equals(extension, ".testrunConfig", StringComparison.OrdinalIgnoreCase)) { - var extension = Path.GetExtension(settings); - if (string.Equals(extension, ".runsettings", StringComparison.OrdinalIgnoreCase)) - { - commandsUsed.Add("/settings//.RunSettings"); - } - else if (string.Equals(extension, ".testsettings", StringComparison.OrdinalIgnoreCase)) - { - commandsUsed.Add("/settings//.TestSettings"); - } - else if (string.Equals(extension, ".vsmdi", StringComparison.OrdinalIgnoreCase)) - { - commandsUsed.Add("/settings//.vsmdi"); - } - else if (string.Equals(extension, ".testrunConfig", StringComparison.OrdinalIgnoreCase)) - { - commandsUsed.Add("/settings//.testrunConfig"); - } + commandsUsed.Add("/settings//.testrunConfig"); } - - requestData.MetricsCollection.Add( - TelemetryDataConstants.CommandLineSwitches, - string.Join(",", commandsUsed.ToArray())); } - /// - /// Gets request data. - /// - /// Protocol config. - /// Request data. - private IRequestData GetRequestData(ProtocolConfig protocolConfig) + requestData.MetricsCollection.Add( + TelemetryDataConstants.CommandLineSwitches, + string.Join(",", commandsUsed.ToArray())); + } + + /// + /// Gets request data. + /// + /// Protocol config. + /// Request data. + private IRequestData GetRequestData(ProtocolConfig protocolConfig) + { + return new RequestData { - return new RequestData - { - ProtocolConfig = protocolConfig, - MetricsCollection = - this.telemetryOptedIn || IsTelemetryOptedIn() - ? (IMetricsCollection)new MetricsCollection() - : new NoOpMetricsCollection(), - IsTelemetryOptedIn = this.telemetryOptedIn || IsTelemetryOptedIn() - }; - } + ProtocolConfig = protocolConfig, + MetricsCollection = + _telemetryOptedIn || IsTelemetryOptedIn() + ? (IMetricsCollection)new MetricsCollection() + : new NoOpMetricsCollection(), + IsTelemetryOptedIn = _telemetryOptedIn || IsTelemetryOptedIn() + }; + } - private List GetSources(TestRunRequestPayload testRunRequestPayload) + private List GetSources(TestRunRequestPayload testRunRequestPayload) + { + List sources = new(); + if (testRunRequestPayload.Sources != null + && testRunRequestPayload.Sources.Count > 0) { - List sources = new List(); - if (testRunRequestPayload.Sources != null - && testRunRequestPayload.Sources.Count > 0) - { - sources = testRunRequestPayload.Sources; - } - else if (testRunRequestPayload.TestCases != null - && testRunRequestPayload.TestCases.Count > 0) + sources = testRunRequestPayload.Sources; + } + else if (testRunRequestPayload.TestCases != null + && testRunRequestPayload.TestCases.Count > 0) + { + ISet sourcesSet = new HashSet(); + foreach (var testCase in testRunRequestPayload.TestCases) { - ISet sourcesSet = new HashSet(); - foreach (var testCase in testRunRequestPayload.TestCases) - { - sourcesSet.Add(testCase.Source); - } - sources = sourcesSet.ToList(); + sourcesSet.Add(testCase.Source); } - return sources; + sources = sourcesSet.ToList(); } + return sources; } -} +} \ No newline at end of file diff --git a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/CollectorNameValueConfigurationManagerTests.cs b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/CollectorNameValueConfigurationManagerTests.cs index 9ed8187b52..11c2832a8b 100644 --- a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/CollectorNameValueConfigurationManagerTests.cs +++ b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/CollectorNameValueConfigurationManagerTests.cs @@ -1,55 +1,55 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests -{ - using System.IO; - using System.Xml; - - using Microsoft.TestPlatform.Extensions.EventLogCollector; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests; - [TestClass] - public class CollectorNameValueConfigurationManagerTests - { - private const string ConfigurationString = - @""; +using System.IO; +using System.Xml; - private const string EmptyConfigurationString = - @""; +using EventLogCollector; - [TestMethod] - public void ConstructorShouldInitializeNameValuePairDictionary() - { - XmlDocument xmlDocument = new XmlDocument(); - using (XmlReader reader = XmlReader.Create(new StringReader(ConfigurationString))) - { - xmlDocument.Load(reader); - } +using VisualStudio.TestTools.UnitTesting; - var configManager = new CollectorNameValueConfigurationManager(xmlDocument.DocumentElement); +[TestClass] +public class CollectorNameValueConfigurationManagerTests +{ + private const string ConfigurationString = + @""; - Assert.AreEqual("value", configManager["key"]); - } + private const string EmptyConfigurationString = + @""; - [TestMethod] - public void ConstructorShouldNotInitializeNameValuePairIfEmptyXmlElementIsPassed() + [TestMethod] + public void ConstructorShouldInitializeNameValuePairDictionary() + { + XmlDocument xmlDocument = new(); + using (XmlReader reader = XmlReader.Create(new StringReader(ConfigurationString))) { - XmlDocument xmlDocument = new XmlDocument(); - using (XmlReader reader = XmlReader.Create(new StringReader(EmptyConfigurationString))) - { - xmlDocument.Load(reader); - } - - var configManager = new CollectorNameValueConfigurationManager(xmlDocument.DocumentElement); - Assert.AreEqual(0, configManager.NameValuePairs.Count); + xmlDocument.Load(reader); } - [TestMethod] - public void ConstructorShouldNotInitializeNameValuePairNullIsPassed() + var configManager = new CollectorNameValueConfigurationManager(xmlDocument.DocumentElement); + + Assert.AreEqual("value", configManager["key"]); + } + + [TestMethod] + public void ConstructorShouldNotInitializeNameValuePairIfEmptyXmlElementIsPassed() + { + XmlDocument xmlDocument = new(); + using (XmlReader reader = XmlReader.Create(new StringReader(EmptyConfigurationString))) { - var configManager = new CollectorNameValueConfigurationManager(null); - Assert.AreEqual(0, configManager.NameValuePairs.Count); + xmlDocument.Load(reader); } + + var configManager = new CollectorNameValueConfigurationManager(xmlDocument.DocumentElement); + Assert.AreEqual(0, configManager.NameValuePairs.Count); + } + + [TestMethod] + public void ConstructorShouldNotInitializeNameValuePairNullIsPassed() + { + var configManager = new CollectorNameValueConfigurationManager(null); + Assert.AreEqual(0, configManager.NameValuePairs.Count); } -} +} \ No newline at end of file diff --git a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogContainerTests.cs b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogContainerTests.cs index b6d03fbe33..de9321e09d 100644 --- a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogContainerTests.cs +++ b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogContainerTests.cs @@ -1,135 +1,135 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests -{ - using System; - using System.Collections.Generic; - using System.Diagnostics; +namespace Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using System.Diagnostics; - using Moq; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using VisualStudio.TestTools.UnitTesting; - using Resource = Microsoft.TestPlatform.Extensions.EventLogCollector.Resources.Resources; - using System.Globalization; +using Moq; - [TestClass] - public class EventLogContainerTests - { - private HashSet eventSources; +[TestClass] +public class EventLogContainerTests +{ + private readonly HashSet _eventSources; - private HashSet entryTypes; + private readonly HashSet _entryTypes; - private Mock logger; + private readonly Mock _logger; - private DataCollectionContext dataCollectionContext; + private readonly DataCollectionContext _dataCollectionContext; - private EventLog eventLog; + private readonly EventLog _eventLog; - private EventLogContainer eventLogContainer; + private EventLogContainer _eventLogContainer; - private EntryWrittenEventArgs entryWrittenEventArgs; + private readonly EntryWrittenEventArgs _entryWrittenEventArgs; - private string eventLogName = "Application"; + private readonly string _eventLogName = "Application"; - public EventLogContainerTests() + public EventLogContainerTests() + { + _eventSources = new HashSet { - this.eventSources = new HashSet(); - this.eventSources.Add("Application"); - this.entryTypes = new HashSet(); - this.entryTypes.Add(EventLogEntryType.Error); - - this.logger = new Mock(); - this.eventLog = new EventLog("Application"); - this.entryWrittenEventArgs = new EntryWrittenEventArgs(this.eventLog.Entries[this.eventLog.Entries.Count - 1]); - - this.dataCollectionContext = new DataCollectionContext(new SessionId(Guid.NewGuid())); - - this.eventLogContainer = new EventLogContainer( - this.eventLogName, - this.eventSources, - this.entryTypes, - int.MaxValue, - this.logger.Object, - this.dataCollectionContext); - } - - [TestMethod] - [Ignore] - public void OnEventLogEntryWrittenShouldAddLogs() + "Application" + }; + _entryTypes = new HashSet { - EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 234); - this.eventLogContainer.OnEventLogEntryWritten(this.eventLog, this.entryWrittenEventArgs); - var newCount = this.eventLogContainer.EventLogEntries.Count; + EventLogEntryType.Error + }; + + _logger = new Mock(); + _eventLog = new EventLog("Application"); + _entryWrittenEventArgs = new EntryWrittenEventArgs(_eventLog.Entries[_eventLog.Entries.Count - 1]); + + _dataCollectionContext = new DataCollectionContext(new SessionId(Guid.NewGuid())); + + _eventLogContainer = new EventLogContainer( + _eventLogName, + _eventSources, + _entryTypes, + int.MaxValue, + _logger.Object, + _dataCollectionContext); + } - Assert.IsTrue(newCount > 0); - } + [TestMethod] + [Ignore] + public void OnEventLogEntryWrittenShouldAddLogs() + { + EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 234); + _eventLogContainer.OnEventLogEntryWritten(_eventLog, _entryWrittenEventArgs); + var newCount = _eventLogContainer.EventLogEntries.Count; - [TestMethod] - public void OnEventLogEntryWrittenShouldNotAddLogsIfNoNewEntryIsPresent() - { - this.eventLogContainer.OnEventLogEntryWritten(this.eventLog, this.entryWrittenEventArgs); - var newCount = this.eventLogContainer.EventLogEntries.Count; + Assert.IsTrue(newCount > 0); + } - Assert.AreEqual(0, newCount); - } + [TestMethod] + public void OnEventLogEntryWrittenShouldNotAddLogsIfNoNewEntryIsPresent() + { + _eventLogContainer.OnEventLogEntryWritten(_eventLog, _entryWrittenEventArgs); + var newCount = _eventLogContainer.EventLogEntries.Count; - [TestMethod] - public void OnEventLogEntryWrittenShoulFilterLogsBasedOnEventTypeAndEventSource() - { - this.entryTypes.Add(EventLogEntryType.Warning); - this.eventSources.Add("Application"); + Assert.AreEqual(0, newCount); + } - EventLog.WriteEntry("Application", "Application", EventLogEntryType.Warning, 234); - this.eventLogContainer.OnEventLogEntryWritten(this.eventLog, this.entryWrittenEventArgs); - var newCount = this.eventLogContainer.EventLogEntries.Count; + [TestMethod] + public void OnEventLogEntryWrittenShoulFilterLogsBasedOnEventTypeAndEventSource() + { + _entryTypes.Add(EventLogEntryType.Warning); + _eventSources.Add("Application"); - Assert.AreEqual(1, newCount); - } + EventLog.WriteEntry("Application", "Application", EventLogEntryType.Warning, 234); + _eventLogContainer.OnEventLogEntryWritten(_eventLog, _entryWrittenEventArgs); + var newCount = _eventLogContainer.EventLogEntries.Count; - [TestMethod] - public void OnEventLogEntryWrittenShoulNotAddLogsIfEventSourceIsDifferent() - { - this.eventSources.Clear(); - this.eventSources.Add("Application1"); - this.eventLogContainer = new EventLogContainer( - this.eventLogName, - this.eventSources, - this.entryTypes, - int.MaxValue, - this.logger.Object, - this.dataCollectionContext); - EventLog.WriteEntry("Application", "Application", EventLogEntryType.Warning, 234); - this.eventLogContainer.OnEventLogEntryWritten(this.eventLog, this.entryWrittenEventArgs); - var newCount = this.eventLogContainer.EventLogEntries.Count; - - Assert.AreEqual(0, newCount); - } - - [TestMethod] - public void OnEventLogEntryWrittenShoulNotAddLogsIfEventTypeIsDifferent() - { - this.entryTypes.Clear(); - this.entryTypes.Add(EventLogEntryType.FailureAudit); - - this.eventSources.Add("Application1"); - this.eventLogContainer = new EventLogContainer( - this.eventLogName, - this.eventSources, - this.entryTypes, - int.MaxValue, - this.logger.Object, - this.dataCollectionContext); - - EventLog.WriteEntry("Application", "Application", EventLogEntryType.Warning, 234); - this.eventLogContainer.OnEventLogEntryWritten(this.eventLog, this.entryWrittenEventArgs); - var newCount = this.eventLogContainer.EventLogEntries.Count; - - Assert.AreEqual(0, newCount); - } + Assert.AreEqual(1, newCount); + } + + [TestMethod] + public void OnEventLogEntryWrittenShoulNotAddLogsIfEventSourceIsDifferent() + { + _eventSources.Clear(); + _eventSources.Add("Application1"); + _eventLogContainer = new EventLogContainer( + _eventLogName, + _eventSources, + _entryTypes, + int.MaxValue, + _logger.Object, + _dataCollectionContext); + EventLog.WriteEntry("Application", "Application", EventLogEntryType.Warning, 234); + _eventLogContainer.OnEventLogEntryWritten(_eventLog, _entryWrittenEventArgs); + var newCount = _eventLogContainer.EventLogEntries.Count; + + Assert.AreEqual(0, newCount); + } + + [TestMethod] + public void OnEventLogEntryWrittenShoulNotAddLogsIfEventTypeIsDifferent() + { + _entryTypes.Clear(); + _entryTypes.Add(EventLogEntryType.FailureAudit); + + _eventSources.Add("Application1"); + _eventLogContainer = new EventLogContainer( + _eventLogName, + _eventSources, + _entryTypes, + int.MaxValue, + _logger.Object, + _dataCollectionContext); + + EventLog.WriteEntry("Application", "Application", EventLogEntryType.Warning, 234); + _eventLogContainer.OnEventLogEntryWritten(_eventLog, _entryWrittenEventArgs); + var newCount = _eventLogContainer.EventLogEntries.Count; + + Assert.AreEqual(0, newCount); } -} +} \ No newline at end of file diff --git a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogDataCollectorTests.cs b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogDataCollectorTests.cs index 75099d3c41..1c81171119 100644 --- a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogDataCollectorTests.cs +++ b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogDataCollectorTests.cs @@ -1,504 +1,491 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests -{ - using System; - using System.Collections.Generic; - using System.ComponentModel; - using System.Diagnostics; - using System.Linq; - using System.Xml; - - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - [TestClass] - public class EventLogDataCollectorTests - { - private const string ConfigurationString = - @""; +namespace Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests; - private Mock mockDataCollectionEvents; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using System.Xml; - private TestableDataCollectionSink mockDataCollectionSink; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using VisualStudio.TestTools.UnitTesting; - private Mock mockDataCollectionLogger; +using Moq; - private DataCollectionEnvironmentContext dataCollectionEnvironmentContext; +[TestClass] +public class EventLogDataCollectorTests +{ + private readonly Mock _mockDataCollectionEvents; - private EventLogDataCollector eventLogDataCollector; + private readonly TestableDataCollectionSink _mockDataCollectionSink; - private Mock mockFileHelper; + private readonly Mock _mockDataCollectionLogger; - public EventLogDataCollectorTests() - { - this.mockDataCollectionEvents = new Mock(); - this.mockDataCollectionSink = new TestableDataCollectionSink(); - this.mockFileHelper = new Mock(); - TestCase tc = new TestCase(); - DataCollectionContext dataCollectionContext = - new DataCollectionContext(new SessionId(Guid.NewGuid())); - this.dataCollectionEnvironmentContext = new DataCollectionEnvironmentContext(dataCollectionContext); - this.mockDataCollectionLogger = new Mock(); - this.eventLogDataCollector = new EventLogDataCollector(this.mockFileHelper.Object); - } + private readonly DataCollectionEnvironmentContext _dataCollectionEnvironmentContext; - [TestMethod] - public void EventLoggerLogsErrorForInvalidEventSources() - { - string configurationString = + private readonly EventLogDataCollector _eventLogDataCollector; + + private readonly Mock _mockFileHelper; + + public EventLogDataCollectorTests() + { + _mockDataCollectionEvents = new Mock(); + _mockDataCollectionSink = new TestableDataCollectionSink(); + _mockFileHelper = new Mock(); + DataCollectionContext dataCollectionContext = + new(new SessionId(Guid.NewGuid())); + _dataCollectionEnvironmentContext = new DataCollectionEnvironmentContext(dataCollectionContext); + _mockDataCollectionLogger = new Mock(); + _eventLogDataCollector = new EventLogDataCollector(_mockFileHelper.Object); + } + + [TestMethod] + public void EventLoggerLogsErrorForInvalidEventSources() + { + string configurationString = @""; - XmlDocument expectedXmlDoc = new XmlDocument(); - expectedXmlDoc.LoadXml(configurationString); - var mockCollector = new Mock(); - mockCollector.Setup(m => m.LogError(It.IsAny(), It.Is(s => s.Contains(@"The event log 'MyEventName' on computer '.' does not exist.")), It.IsAny())); + XmlDocument expectedXmlDoc = new(); + expectedXmlDoc.LoadXml(configurationString); + var mockCollector = new Mock(); + mockCollector.Setup(m => m.LogError(It.IsAny(), It.Is(s => s.Contains(@"The event log 'MyEventName' on computer '.' does not exist.")), It.IsAny())); - var eventLogDataCollector = new EventLogDataCollector(); - eventLogDataCollector.Initialize(expectedXmlDoc.DocumentElement, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, mockCollector.Object, this.dataCollectionEnvironmentContext); + var eventLogDataCollector = new EventLogDataCollector(); + eventLogDataCollector.Initialize(expectedXmlDoc.DocumentElement, _mockDataCollectionEvents.Object, _mockDataCollectionSink, mockCollector.Object, _dataCollectionEnvironmentContext); - mockCollector.Verify(m => m.LogError(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); - } + mockCollector.Verify(m => m.LogError(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); + } - [TestMethod] - public void InitializeShouldThrowExceptionIfEventsIsNull() - { - Assert.ThrowsException( - () => - { - this.eventLogDataCollector.Initialize( - null, - null, - this.mockDataCollectionSink, - this.mockDataCollectionLogger.Object, - this.dataCollectionEnvironmentContext); - }); - } + [TestMethod] + public void InitializeShouldThrowExceptionIfEventsIsNull() + { + Assert.ThrowsException( + () => _eventLogDataCollector.Initialize( + null, + null, + _mockDataCollectionSink, + _mockDataCollectionLogger.Object, + _dataCollectionEnvironmentContext)); + } - [TestMethod] - public void InitializeShouldThrowExceptionIfCollectionSinkIsNull() - { - Assert.ThrowsException( - () => - { - this.eventLogDataCollector.Initialize( - null, - this.mockDataCollectionEvents.Object, - null, - this.mockDataCollectionLogger.Object, - this.dataCollectionEnvironmentContext); - }); - } + [TestMethod] + public void InitializeShouldThrowExceptionIfCollectionSinkIsNull() + { + Assert.ThrowsException( + () => _eventLogDataCollector.Initialize( + null, + _mockDataCollectionEvents.Object, + null, + _mockDataCollectionLogger.Object, + _dataCollectionEnvironmentContext)); + } - [TestMethod] - public void InitializeShouldThrowExceptionIfLoggerIsNull() - { - Assert.ThrowsException( - () => - { - this.eventLogDataCollector.Initialize( - null, - this.mockDataCollectionEvents.Object, - this.mockDataCollectionSink, - null, - this.dataCollectionEnvironmentContext); - }); - } + [TestMethod] + public void InitializeShouldThrowExceptionIfLoggerIsNull() + { + Assert.ThrowsException( + () => _eventLogDataCollector.Initialize( + null, + _mockDataCollectionEvents.Object, + _mockDataCollectionSink, + null, + _dataCollectionEnvironmentContext)); + } - [TestMethod] - public void InitializeShouldInitializeDefaultEventLogNames() + [TestMethod] + public void InitializeShouldInitializeDefaultEventLogNames() + { + List eventLogNames = new() { - List eventLogNames = new List(); - eventLogNames.Add("System"); - eventLogNames.Add("Application"); + "System", + "Application" + }; - this.eventLogDataCollector.Initialize(null, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext); + _eventLogDataCollector.Initialize(null, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext); - CollectionAssert.AreEqual(eventLogNames, this.eventLogDataCollector.EventLogNames.ToList()); - } + CollectionAssert.AreEqual(eventLogNames, _eventLogDataCollector.EventLogNames.ToList()); + } - [TestMethod] - public void InitializeShouldInitializeCustomEventLogNamesIfSpecifiedInConfiguration() - { - string configurationString = + [TestMethod] + public void InitializeShouldInitializeCustomEventLogNamesIfSpecifiedInConfiguration() + { + string configurationString = @""; - List eventLogNames = new List(); - eventLogNames.Add("MyEventName"); - eventLogNames.Add("MyEventName2"); + List eventLogNames = new() + { + "MyEventName", + "MyEventName2" + }; - XmlDocument expectedXmlDoc = new XmlDocument(); - expectedXmlDoc.LoadXml(configurationString); + XmlDocument expectedXmlDoc = new(); + expectedXmlDoc.LoadXml(configurationString); - this.eventLogDataCollector.Initialize(expectedXmlDoc.DocumentElement, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext); + _eventLogDataCollector.Initialize(expectedXmlDoc.DocumentElement, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext); - CollectionAssert.AreEqual(eventLogNames, this.eventLogDataCollector.EventLogNames.ToList()); - } + CollectionAssert.AreEqual(eventLogNames, _eventLogDataCollector.EventLogNames.ToList()); + } - [TestMethod] - public void InitializeShouldInitializeDefaultLogEntryTypes() + [TestMethod] + public void InitializeShouldInitializeDefaultLogEntryTypes() + { + List entryTypes = new() { - List entryTypes = new List(); - entryTypes.Add(EventLogEntryType.Error); - entryTypes.Add(EventLogEntryType.Warning); - entryTypes.Add(EventLogEntryType.FailureAudit); + EventLogEntryType.Error, + EventLogEntryType.Warning, + EventLogEntryType.FailureAudit + }; - this.eventLogDataCollector.Initialize(null, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext); + _eventLogDataCollector.Initialize(null, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext); - CollectionAssert.AreEqual(entryTypes, this.eventLogDataCollector.EntryTypes.ToList()); - } + CollectionAssert.AreEqual(entryTypes, _eventLogDataCollector.EntryTypes.ToList()); + } + + [TestMethod] + public void InitializeShouldInitializeEntryTypesIfSpecifiedInConfiguration() + { + string configurationString = + @""; - [TestMethod] - public void InitializeShouldInitializeEntryTypesIfSpecifiedInConfiguration() + List entryTypes = new() { - string configurationString = - @""; + EventLogEntryType.Error + }; - List entryTypes = new List(); - entryTypes.Add(EventLogEntryType.Error); + XmlDocument expectedXmlDoc = new(); + expectedXmlDoc.LoadXml(configurationString); + _eventLogDataCollector.Initialize(expectedXmlDoc.DocumentElement, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext); - XmlDocument expectedXmlDoc = new XmlDocument(); - expectedXmlDoc.LoadXml(configurationString); - this.eventLogDataCollector.Initialize(expectedXmlDoc.DocumentElement, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext); + CollectionAssert.AreEqual(entryTypes, _eventLogDataCollector.EntryTypes.ToList()); + } - CollectionAssert.AreEqual(entryTypes, this.eventLogDataCollector.EntryTypes.ToList()); - } + [TestMethod] + public void InitializeShouldInitializeEventSourcesIfSpecifiedInConfiguration() + { + string configurationString = + @""; - [TestMethod] - public void InitializeShouldInitializeEventSourcesIfSpecifiedInConfiguration() + List eventSources = new() { - string configurationString = - @""; + "MyEventSource" + }; - List eventSources = new List(); - eventSources.Add("MyEventSource"); + XmlDocument expectedXmlDoc = new(); + expectedXmlDoc.LoadXml(configurationString); + _eventLogDataCollector.Initialize(expectedXmlDoc.DocumentElement, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext); - XmlDocument expectedXmlDoc = new XmlDocument(); - expectedXmlDoc.LoadXml(configurationString); - this.eventLogDataCollector.Initialize(expectedXmlDoc.DocumentElement, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext); + CollectionAssert.AreEqual(eventSources, _eventLogDataCollector.EventSources.ToList()); + } - CollectionAssert.AreEqual(eventSources, this.eventLogDataCollector.EventSources.ToList()); - } + [TestMethod] + public void InitializeShouldNotInitializeEventSourcesByDefault() + { + _eventLogDataCollector.Initialize(null, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext); - [TestMethod] - public void InitializeShouldNotInitializeEventSourcesByDefault() - { - this.eventLogDataCollector.Initialize(null, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext); + Assert.IsNull(_eventLogDataCollector.EventSources); + } - Assert.IsNull(this.eventLogDataCollector.EventSources); - } + [TestMethod] + public void InitializeShouldInitializeMaxEntriesIfSpecifiedInConfiguration() + { + string configurationString = + @""; - [TestMethod] - public void InitializeShouldInitializeMaxEntriesIfSpecifiedInConfiguration() - { - string configurationString = - @""; + XmlDocument expectedXmlDoc = new(); + expectedXmlDoc.LoadXml(configurationString); + _eventLogDataCollector.Initialize(expectedXmlDoc.DocumentElement, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext); - XmlDocument expectedXmlDoc = new XmlDocument(); - expectedXmlDoc.LoadXml(configurationString); - this.eventLogDataCollector.Initialize(expectedXmlDoc.DocumentElement, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext); + Assert.AreEqual(20, _eventLogDataCollector.MaxEntries); + } - Assert.AreEqual(20, this.eventLogDataCollector.MaxEntries); - } + [TestMethod] + public void InitializeShouldSetDefaultMaxEntries() + { + _eventLogDataCollector.Initialize(null, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext); - [TestMethod] - public void InitializeShouldSetDefaultMaxEntries() - { - this.eventLogDataCollector.Initialize(null, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext); + Assert.AreEqual(50000, _eventLogDataCollector.MaxEntries); + } - Assert.AreEqual(50000, this.eventLogDataCollector.MaxEntries); - } + [TestMethod] + public void InitializeShouldSubscribeToDataCollectionEvents() + { + var testableDataCollectionEvents = new TestableDataCollectionEvents(); + _eventLogDataCollector.Initialize(null, testableDataCollectionEvents, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext); + Assert.AreEqual(1, testableDataCollectionEvents.GetTestHostLaunchedInvocationList().Length); + Assert.AreEqual(1, testableDataCollectionEvents.GetTestCaseStartInvocationList().Length); + Assert.AreEqual(1, testableDataCollectionEvents.GetTestCaseEndInvocationList().Length); + Assert.AreEqual(1, testableDataCollectionEvents.GetTestSessionEndInvocationList().Length); + Assert.AreEqual(1, testableDataCollectionEvents.GetTestSessionStartInvocationList().Length); + } - [TestMethod] - public void InitializeShouldSubscribeToDataCollectionEvents() - { - var testableDataCollectionEvents = new TestableDataCollectionEvents(); - this.eventLogDataCollector.Initialize(null, testableDataCollectionEvents, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext); - Assert.AreEqual(1, testableDataCollectionEvents.GetTestHostLaunchedInvocationList().Length); - Assert.AreEqual(1, testableDataCollectionEvents.GetTestCaseStartInvocationList().Length); - Assert.AreEqual(1, testableDataCollectionEvents.GetTestCaseEndInvocationList().Length); - Assert.AreEqual(1, testableDataCollectionEvents.GetTestSessionEndInvocationList().Length); - Assert.AreEqual(1, testableDataCollectionEvents.GetTestSessionStartInvocationList().Length); - } + [TestMethod] + public void TestSessionStartEventShouldCreateEventLogContainer() + { + var eventLogDataCollector = new EventLogDataCollector(); + Assert.AreEqual(0, eventLogDataCollector.ContextMap.Count); + eventLogDataCollector.Initialize(null, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext); + _mockDataCollectionEvents.Raise(x => x.SessionStart += null, new SessionStartEventArgs()); + Assert.AreEqual(1, eventLogDataCollector.ContextMap.Count); + } - [TestMethod] - public void TestSessionStartEventShouldCreateEventLogContainer() - { - var eventLogDataCollector = new EventLogDataCollector(); - Assert.AreEqual(0, eventLogDataCollector.ContextMap.Count); - eventLogDataCollector.Initialize(null, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext); - this.mockDataCollectionEvents.Raise(x => x.SessionStart += null, new SessionStartEventArgs()); - Assert.AreEqual(1, eventLogDataCollector.ContextMap.Count); - } + [TestMethod] + public void TestCaseStartEventShouldCreateEventLogContainer() + { + var eventLogDataCollector = new EventLogDataCollector(); + Assert.AreEqual(0, eventLogDataCollector.ContextMap.Count); - [TestMethod] - public void TestCaseStartEventShouldCreateEventLogContainer() - { - var eventLogDataCollector = new EventLogDataCollector(); - Assert.AreEqual(0, eventLogDataCollector.ContextMap.Count); + eventLogDataCollector.Initialize(null, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext); + _mockDataCollectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(new DataCollectionContext(new SessionId(Guid.NewGuid()), new TestExecId(Guid.NewGuid())), new TestCase())); + Assert.AreEqual(1, eventLogDataCollector.ContextMap.Count); + } - eventLogDataCollector.Initialize(null, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext); - this.mockDataCollectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(new DataCollectionContext(new SessionId(Guid.NewGuid()), new TestExecId(Guid.NewGuid())), new TestCase())); - Assert.AreEqual(1, eventLogDataCollector.ContextMap.Count); - } + [TestMethod] - [TestMethod] + public void TestCaseEndEventShouldWriteEventLogEntriesAndSendFile() + { + var eventLogDataCollector = new EventLogDataCollector(); + eventLogDataCollector.Initialize(null, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext); + var tc = new TestCase(); + var context = new DataCollectionContext(new SessionId(Guid.NewGuid()), new TestExecId(Guid.NewGuid())); + _mockDataCollectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(context, tc)); + _mockDataCollectionEvents.Raise(x => x.TestCaseEnd += null, new TestCaseEndEventArgs(context, tc, TestOutcome.Passed)); + Assert.IsTrue(_mockDataCollectionSink.IsSendFileAsyncInvoked); + } - public void TestCaseEndEventShouldWriteEventLogEntriesAndSendFile() - { - var eventLogDataCollector = new EventLogDataCollector(); - eventLogDataCollector.Initialize(null, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext); - var tc = new TestCase(); - var context = new DataCollectionContext(new SessionId(Guid.NewGuid()), new TestExecId(Guid.NewGuid())); - this.mockDataCollectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(context, tc)); - this.mockDataCollectionEvents.Raise(x => x.TestCaseEnd += null, new TestCaseEndEventArgs(context, tc, TestOutcome.Passed)); - Assert.IsTrue(this.mockDataCollectionSink.IsSendFileAsyncInvoked); - } + public void TestCaseEndEventShouldInvokeSendFileAsync() + { + var eventLogDataCollector = new EventLogDataCollector(); + eventLogDataCollector.Initialize(null, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext); + var tc = new TestCase(); + var context = new DataCollectionContext(new SessionId(Guid.NewGuid()), new TestExecId(Guid.NewGuid())); + _mockDataCollectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(context, tc)); + _mockDataCollectionEvents.Raise(x => x.TestCaseEnd += null, new TestCaseEndEventArgs(context, tc, TestOutcome.Passed)); + Assert.IsTrue(_mockDataCollectionSink.IsSendFileAsyncInvoked); + } - public void TestCaseEndEventShouldInvokeSendFileAsync() - { - var eventLogDataCollector = new EventLogDataCollector(); - eventLogDataCollector.Initialize(null, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext); - var tc = new TestCase(); - var context = new DataCollectionContext(new SessionId(Guid.NewGuid()), new TestExecId(Guid.NewGuid())); - this.mockDataCollectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(context, tc)); - this.mockDataCollectionEvents.Raise(x => x.TestCaseEnd += null, new TestCaseEndEventArgs(context, tc, TestOutcome.Passed)); - Assert.IsTrue(this.mockDataCollectionSink.IsSendFileAsyncInvoked); - } + [TestMethod] + public void TestCaseEndEventShouldThrowIfTestCaseStartIsNotInvoked() + { + var eventLogDataCollector = new EventLogDataCollector(); + eventLogDataCollector.Initialize(null, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext); + var tc = new TestCase(); + var context = new DataCollectionContext(new SessionId(Guid.NewGuid()), new TestExecId(Guid.NewGuid())); - [TestMethod] - public void TestCaseEndEventShouldThrowIfTestCaseStartIsNotInvoked() - { - var eventLogDataCollector = new EventLogDataCollector(); - eventLogDataCollector.Initialize(null, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext); - var tc = new TestCase(); - var context = new DataCollectionContext(new SessionId(Guid.NewGuid()), new TestExecId(Guid.NewGuid())); - - Assert.ThrowsException(() => - { - this.mockDataCollectionEvents.Raise(x => x.TestCaseEnd += null, new TestCaseEndEventArgs(context, tc, TestOutcome.Passed)); - }); - } + Assert.ThrowsException(() => _mockDataCollectionEvents.Raise(x => x.TestCaseEnd += null, new TestCaseEndEventArgs(context, tc, TestOutcome.Passed))); + } - public void SessionEndEventShouldThrowIfSessionStartEventtIsNotInvoked() - { - var eventLogDataCollector = new EventLogDataCollector(); - eventLogDataCollector.Initialize(null, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext); - var tc = new TestCase(); - - Assert.ThrowsException(() => - { - this.mockDataCollectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(this.dataCollectionEnvironmentContext.SessionDataCollectionContext)); - }); - } + public void SessionEndEventShouldThrowIfSessionStartEventtIsNotInvoked() + { + var eventLogDataCollector = new EventLogDataCollector(); + eventLogDataCollector.Initialize(null, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext); + var tc = new TestCase(); - [TestMethod] - public void TestSessionEndEventShouldWriteEventLogEntriesAndSendFile() - { - var eventLogDataCollector = new EventLogDataCollector(); - eventLogDataCollector.Initialize(null, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext); - var testcase = new TestCase() { Id = Guid.NewGuid() }; - this.mockDataCollectionEvents.Raise(x => x.SessionStart += null, new SessionStartEventArgs(this.dataCollectionEnvironmentContext.SessionDataCollectionContext, new Dictionary())); - this.mockDataCollectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(this.dataCollectionEnvironmentContext.SessionDataCollectionContext)); - Assert.IsTrue(this.mockDataCollectionSink.IsSendFileAsyncInvoked); - } + Assert.ThrowsException(() => _mockDataCollectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(_dataCollectionEnvironmentContext.SessionDataCollectionContext))); + } - [TestMethod] - public void WriteEventLogsShouldCreateXmlFile() - { - string configurationString = - @""; + [TestMethod] + public void TestSessionEndEventShouldWriteEventLogEntriesAndSendFile() + { + var eventLogDataCollector = new EventLogDataCollector(); + eventLogDataCollector.Initialize(null, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext); + var testcase = new TestCase() { Id = Guid.NewGuid() }; + _mockDataCollectionEvents.Raise(x => x.SessionStart += null, new SessionStartEventArgs(_dataCollectionEnvironmentContext.SessionDataCollectionContext, new Dictionary())); + _mockDataCollectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(_dataCollectionEnvironmentContext.SessionDataCollectionContext)); + Assert.IsTrue(_mockDataCollectionSink.IsSendFileAsyncInvoked); + } - XmlDocument expectedXmlDoc = new XmlDocument(); - expectedXmlDoc.LoadXml(configurationString); + [TestMethod] + public void WriteEventLogsShouldCreateXmlFile() + { + string configurationString = + @""; + + XmlDocument expectedXmlDoc = new(); + expectedXmlDoc.LoadXml(configurationString); + + _mockFileHelper.SetupSequence(x => x.Exists(It.IsAny())).Returns(false).Returns(true); + _eventLogDataCollector.Initialize(expectedXmlDoc.DocumentElement, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext); + _eventLogDataCollector.WriteEventLogs( + new List(), + 20, + _dataCollectionEnvironmentContext.SessionDataCollectionContext, + TimeSpan.MaxValue, + DateTime.Now); + + _mockFileHelper.Verify(x => x.WriteAllTextToFile(It.IsAny(), It.IsAny()), Times.Once); + } - this.mockFileHelper.SetupSequence(x => x.Exists(It.IsAny())).Returns(false).Returns(true); - this.eventLogDataCollector.Initialize(expectedXmlDoc.DocumentElement, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext); - this.eventLogDataCollector.WriteEventLogs( + [TestMethod] + public void WriteEventLogsShouldThrowExceptionIfThrownByFileHelper() + { + string configurationString = + @""; + + XmlDocument expectedXmlDoc = new(); + expectedXmlDoc.LoadXml(configurationString); + _mockFileHelper.Setup(x => x.Exists(It.IsAny())).Throws(); + Assert.ThrowsException( + () => _eventLogDataCollector.WriteEventLogs( new List(), 20, - this.dataCollectionEnvironmentContext.SessionDataCollectionContext, + _dataCollectionEnvironmentContext.SessionDataCollectionContext, TimeSpan.MaxValue, - DateTime.Now); - - this.mockFileHelper.Verify(x => x.WriteAllTextToFile(It.IsAny(), It.IsAny()), Times.Once); - } - - [TestMethod] - public void WriteEventLogsShouldThrowExceptionIfThrownByFileHelper() - { - string configurationString = - @""; - - XmlDocument expectedXmlDoc = new XmlDocument(); - expectedXmlDoc.LoadXml(configurationString); - this.mockFileHelper.Setup(x => x.Exists(It.IsAny())).Throws(); - Assert.ThrowsException( - () => - { - this.eventLogDataCollector.WriteEventLogs( - new List(), - 20, - this.dataCollectionEnvironmentContext.SessionDataCollectionContext, - TimeSpan.MaxValue, - DateTime.Now); - }); - } - - [TestMethod] - public void WriteEventLogsShouldFilterTestsBasedOnTimeAndMaxValue() - { - string configurationString = - @""; - - XmlDocument expectedXmlDoc = new XmlDocument(); - expectedXmlDoc.LoadXml(configurationString); + DateTime.Now)); + } - this.mockFileHelper.SetupSequence(x => x.Exists(It.IsAny())).Returns(false).Returns(true); - this.eventLogDataCollector.Initialize(expectedXmlDoc.DocumentElement, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext); + [TestMethod] + public void WriteEventLogsShouldFilterTestsBasedOnTimeAndMaxValue() + { + string configurationString = + @""; - var entries = new List(); + XmlDocument expectedXmlDoc = new(); + expectedXmlDoc.LoadXml(configurationString); - var eventLog = new EventLog("Application"); - int endIndex = eventLog.Entries[eventLog.Entries.Count - 1].Index; - int firstIndexInLog = eventLog.Entries[0].Index; - for (int i = endIndex; i > endIndex - 10; i--) - { - entries.Add(eventLog.Entries[i - firstIndexInLog]); - } + _mockFileHelper.SetupSequence(x => x.Exists(It.IsAny())).Returns(false).Returns(true); + _eventLogDataCollector.Initialize(expectedXmlDoc.DocumentElement, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext); - var filteredEntries = entries.Where(entry => entry.TimeGenerated > DateTime.MinValue && entry.TimeGenerated < DateTime.MaxValue) - .OrderBy(x => x.TimeGenerated).Take(5).ToList(); + var entries = new List(); - this.eventLogDataCollector.WriteEventLogs( - entries, - 5, - this.dataCollectionEnvironmentContext.SessionDataCollectionContext, - TimeSpan.MaxValue, - DateTime.Now); - - this.mockFileHelper.Verify( - x => x.WriteAllTextToFile( - It.IsAny(), - It.Is( - str => str.Contains(filteredEntries[0].InstanceId.ToString()) - && str.Contains(filteredEntries[1].InstanceId.ToString()) - && str.Contains(filteredEntries[2].InstanceId.ToString()) - && str.Contains(filteredEntries[3].InstanceId.ToString()) - && str.Contains(filteredEntries[4].InstanceId.ToString())))); - } - - [TestMethod] - public void WriteEventLogsShouldFilterTestIfMaxValueExceedsEntries() + var eventLog = new EventLog("Application"); + int endIndex = eventLog.Entries[eventLog.Entries.Count - 1].Index; + int firstIndexInLog = eventLog.Entries[0].Index; + for (int i = endIndex; i > endIndex - 10; i--) { - string configurationString = - @""; + entries.Add(eventLog.Entries[i - firstIndexInLog]); + } - XmlDocument expectedXmlDoc = new XmlDocument(); - expectedXmlDoc.LoadXml(configurationString); + var filteredEntries = entries.Where(entry => entry.TimeGenerated > DateTime.MinValue && entry.TimeGenerated < DateTime.MaxValue) + .OrderBy(x => x.TimeGenerated).Take(5).ToList(); + + _eventLogDataCollector.WriteEventLogs( + entries, + 5, + _dataCollectionEnvironmentContext.SessionDataCollectionContext, + TimeSpan.MaxValue, + DateTime.Now); + + _mockFileHelper.Verify( + x => x.WriteAllTextToFile( + It.IsAny(), + It.Is( + str => str.Contains(filteredEntries[0].InstanceId.ToString()) + && str.Contains(filteredEntries[1].InstanceId.ToString()) + && str.Contains(filteredEntries[2].InstanceId.ToString()) + && str.Contains(filteredEntries[3].InstanceId.ToString()) + && str.Contains(filteredEntries[4].InstanceId.ToString())))); + } - this.mockFileHelper.SetupSequence(x => x.Exists(It.IsAny())).Returns(false).Returns(true); - this.eventLogDataCollector.Initialize(expectedXmlDoc.DocumentElement, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext); + [TestMethod] + public void WriteEventLogsShouldFilterTestIfMaxValueExceedsEntries() + { + string configurationString = + @""; - var entries = new List(); + XmlDocument expectedXmlDoc = new(); + expectedXmlDoc.LoadXml(configurationString); - var eventLog = new EventLog("Application"); - int endIndex = eventLog.Entries[eventLog.Entries.Count - 1].Index; - int firstIndexInLog = eventLog.Entries[0].Index; - for (int i = endIndex; i > endIndex - 5; i--) - { - entries.Add(eventLog.Entries[i - firstIndexInLog]); - } + _mockFileHelper.SetupSequence(x => x.Exists(It.IsAny())).Returns(false).Returns(true); + _eventLogDataCollector.Initialize(expectedXmlDoc.DocumentElement, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext); - var filteredEntries = entries.Where(entry => entry.TimeGenerated > DateTime.MinValue && entry.TimeGenerated < DateTime.MaxValue) - .OrderBy(x => x.TimeGenerated).Take(10).ToList(); + var entries = new List(); - this.eventLogDataCollector.WriteEventLogs( - entries, - 5, - this.dataCollectionEnvironmentContext.SessionDataCollectionContext, - TimeSpan.MaxValue, - DateTime.Now); - - this.mockFileHelper.Verify( - x => x.WriteAllTextToFile( - It.IsAny(), - It.Is( - str => str.Contains(filteredEntries[0].InstanceId.ToString()) - && str.Contains(filteredEntries[1].InstanceId.ToString()) - && str.Contains(filteredEntries[2].InstanceId.ToString()) - && str.Contains(filteredEntries[3].InstanceId.ToString()) - && str.Contains(filteredEntries[4].InstanceId.ToString())))); + var eventLog = new EventLog("Application"); + int endIndex = eventLog.Entries[eventLog.Entries.Count - 1].Index; + int firstIndexInLog = eventLog.Entries[0].Index; + for (int i = endIndex; i > endIndex - 5; i--) + { + entries.Add(eventLog.Entries[i - firstIndexInLog]); } + + var filteredEntries = entries.Where(entry => entry.TimeGenerated > DateTime.MinValue && entry.TimeGenerated < DateTime.MaxValue) + .OrderBy(x => x.TimeGenerated).Take(10).ToList(); + + _eventLogDataCollector.WriteEventLogs( + entries, + 5, + _dataCollectionEnvironmentContext.SessionDataCollectionContext, + TimeSpan.MaxValue, + DateTime.Now); + + _mockFileHelper.Verify( + x => x.WriteAllTextToFile( + It.IsAny(), + It.Is( + str => str.Contains(filteredEntries[0].InstanceId.ToString()) + && str.Contains(filteredEntries[1].InstanceId.ToString()) + && str.Contains(filteredEntries[2].InstanceId.ToString()) + && str.Contains(filteredEntries[3].InstanceId.ToString()) + && str.Contains(filteredEntries[4].InstanceId.ToString())))); } +} - /// - /// The testable data collection events. - /// - public class TestableDataCollectionEvents : DataCollectionEvents - { - public override event EventHandler TestHostLaunched; +/// +/// The testable data collection events. +/// +public class TestableDataCollectionEvents : DataCollectionEvents +{ + public override event EventHandler TestHostLaunched; - public override event EventHandler SessionStart; + public override event EventHandler SessionStart; - public override event EventHandler SessionEnd; + public override event EventHandler SessionEnd; - public override event EventHandler TestCaseStart; + public override event EventHandler TestCaseStart; - public override event EventHandler TestCaseEnd; + public override event EventHandler TestCaseEnd; - public Delegate[] GetTestHostLaunchedInvocationList() - { - return this.TestHostLaunched.GetInvocationList(); - } + public Delegate[] GetTestHostLaunchedInvocationList() + { + return TestHostLaunched.GetInvocationList(); + } - public Delegate[] GetTestCaseStartInvocationList() - { - return this.TestCaseStart.GetInvocationList(); - } + public Delegate[] GetTestCaseStartInvocationList() + { + return TestCaseStart.GetInvocationList(); + } - public Delegate[] GetTestCaseEndInvocationList() - { - return this.TestCaseEnd.GetInvocationList(); - } + public Delegate[] GetTestCaseEndInvocationList() + { + return TestCaseEnd.GetInvocationList(); + } - public Delegate[] GetTestSessionStartInvocationList() - { - return this.SessionStart.GetInvocationList(); - } + public Delegate[] GetTestSessionStartInvocationList() + { + return SessionStart.GetInvocationList(); + } - public Delegate[] GetTestSessionEndInvocationList() - { - return this.SessionEnd.GetInvocationList(); - } + public Delegate[] GetTestSessionEndInvocationList() + { + return SessionEnd.GetInvocationList(); } +} +/// +/// The testable data collection sink. +/// +public class TestableDataCollectionSink : DataCollectionSink +{ /// - /// The testable data collection sink. + /// The send file completed. /// - public class TestableDataCollectionSink : DataCollectionSink - { - /// - /// The send file completed. - /// - public override event AsyncCompletedEventHandler SendFileCompleted; + public override event AsyncCompletedEventHandler SendFileCompleted; - /// - /// Gets or sets a value indicating whether is send file async invoked. - /// - public bool IsSendFileAsyncInvoked { get; set; } + /// + /// Gets or sets a value indicating whether is send file async invoked. + /// + public bool IsSendFileAsyncInvoked { get; set; } - public override void SendFileAsync(FileTransferInformation fileTransferInformation) + public override void SendFileAsync(FileTransferInformation fileTransferInformation) + { + IsSendFileAsyncInvoked = true; + if (SendFileCompleted == null) { - this.IsSendFileAsyncInvoked = true; - if (this.SendFileCompleted == null) - { - return; - } + return; } } -} +} \ No newline at end of file diff --git a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogSessionContextTests.cs b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogSessionContextTests.cs index 3fedfc1ef2..a11660bc06 100644 --- a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogSessionContextTests.cs +++ b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogSessionContextTests.cs @@ -1,96 +1,97 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests -{ - using System.Collections.Generic; - using System.Diagnostics; +namespace Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +using System.Diagnostics; - [TestClass] - public class EventLogSessionContextTests - { - private Dictionary eventLogContainersMap; +using VisualStudio.TestTools.UnitTesting; - private DummyEventLogContainer mockEventLogContainer; +[TestClass] +public class EventLogSessionContextTests +{ + private readonly Dictionary _eventLogContainersMap; - private EventLogSessionContext eventLogSessionContext; + private readonly DummyEventLogContainer _mockEventLogContainer; - public EventLogSessionContextTests() - { - this.mockEventLogContainer = new DummyEventLogContainer(true); - this.eventLogContainersMap = new Dictionary(); - this.eventLogContainersMap.Add("LogName", this.mockEventLogContainer); - } + private EventLogSessionContext _eventLogSessionContext; - [TestMethod] - public void CreateEventLogContainerStartIndexMapShouldCreateStartIndexMap() + public EventLogSessionContextTests() + { + _mockEventLogContainer = new DummyEventLogContainer(true); + _eventLogContainersMap = new Dictionary { - this.eventLogSessionContext = new EventLogSessionContext(this.eventLogContainersMap); - Assert.IsTrue(this.eventLogSessionContext.EventLogContainerStartIndexMap["LogName"] == 2); - } + { "LogName", _mockEventLogContainer } + }; + } - [TestMethod] - public void CreateEventLogContainerEndIndexMapShouldCreateEndIndexMap() - { - this.eventLogSessionContext = new EventLogSessionContext(this.eventLogContainersMap); - this.eventLogSessionContext.CreateEventLogContainerEndIndexMap(); - Assert.IsTrue(this.eventLogSessionContext.EventLogContainerEndIndexMap["LogName"] == 1); - } + [TestMethod] + public void CreateEventLogContainerStartIndexMapShouldCreateStartIndexMap() + { + _eventLogSessionContext = new EventLogSessionContext(_eventLogContainersMap); + Assert.IsTrue(_eventLogSessionContext.EventLogContainerStartIndexMap["LogName"] == 2); + } - [TestMethod] - public void CreateEventLogContainerShouldNotAddIndexEntriesIfEventLogContainerMapsIsEmpty() - { - this.eventLogSessionContext = new EventLogSessionContext(new Dictionary()); - this.eventLogSessionContext.CreateEventLogContainerStartIndexMap(); - this.eventLogSessionContext.CreateEventLogContainerEndIndexMap(); + [TestMethod] + public void CreateEventLogContainerEndIndexMapShouldCreateEndIndexMap() + { + _eventLogSessionContext = new EventLogSessionContext(_eventLogContainersMap); + _eventLogSessionContext.CreateEventLogContainerEndIndexMap(); + Assert.IsTrue(_eventLogSessionContext.EventLogContainerEndIndexMap["LogName"] == 1); + } - Assert.IsTrue(this.eventLogSessionContext.EventLogContainerStartIndexMap.Count == 0); - Assert.IsTrue(this.eventLogSessionContext.EventLogContainerEndIndexMap.Count == 0); - } + [TestMethod] + public void CreateEventLogContainerShouldNotAddIndexEntriesIfEventLogContainerMapsIsEmpty() + { + _eventLogSessionContext = new EventLogSessionContext(new Dictionary()); + _eventLogSessionContext.CreateEventLogContainerStartIndexMap(); + _eventLogSessionContext.CreateEventLogContainerEndIndexMap(); - [TestMethod] - public void CreateEventLogContainerShouldCreateNegativeEndIndexIfLogEntriesAreEmpty() - { - var dict = new Dictionary(); - var dummyEventLogContainer = new DummyEventLogContainer(false); - dict.Add("DummyEventLog", dummyEventLogContainer); + Assert.IsTrue(_eventLogSessionContext.EventLogContainerStartIndexMap.Count == 0); + Assert.IsTrue(_eventLogSessionContext.EventLogContainerEndIndexMap.Count == 0); + } - this.eventLogSessionContext = new EventLogSessionContext(dict); - this.eventLogSessionContext.CreateEventLogContainerStartIndexMap(); - this.eventLogSessionContext.CreateEventLogContainerEndIndexMap(); + [TestMethod] + public void CreateEventLogContainerShouldCreateNegativeEndIndexIfLogEntriesAreEmpty() + { + var dict = new Dictionary(); + var dummyEventLogContainer = new DummyEventLogContainer(false); + dict.Add("DummyEventLog", dummyEventLogContainer); - Assert.IsTrue(this.eventLogSessionContext.EventLogContainerStartIndexMap["DummyEventLog"] == 0); - Assert.IsTrue(this.eventLogSessionContext.EventLogContainerEndIndexMap["DummyEventLog"] == -1); - } + _eventLogSessionContext = new EventLogSessionContext(dict); + _eventLogSessionContext.CreateEventLogContainerStartIndexMap(); + _eventLogSessionContext.CreateEventLogContainerEndIndexMap(); + + Assert.IsTrue(_eventLogSessionContext.EventLogContainerStartIndexMap["DummyEventLog"] == 0); + Assert.IsTrue(_eventLogSessionContext.EventLogContainerEndIndexMap["DummyEventLog"] == -1); } +} - public class DummyEventLogContainer : IEventLogContainer +public class DummyEventLogContainer : IEventLogContainer +{ + public DummyEventLogContainer(bool initialize) { - public DummyEventLogContainer(bool initialize) - { - this.EventLogEntries = new List(10); - EventLog eventLog = new EventLog("Application"); - - if (initialize) - { - int currentIndex = eventLog.Entries[eventLog.Entries.Count - 1].Index - eventLog.Entries[0].Index; - this.EventLogEntries.Add(eventLog.Entries[currentIndex]); - this.EventLogEntries.Add(eventLog.Entries[currentIndex - 1]); - } - } + EventLogEntries = new List(10); + EventLog eventLog = new("Application"); - public void Dispose() + if (initialize) { + int currentIndex = eventLog.Entries[eventLog.Entries.Count - 1].Index - eventLog.Entries[0].Index; + EventLogEntries.Add(eventLog.Entries[currentIndex]); + EventLogEntries.Add(eventLog.Entries[currentIndex - 1]); } + } - public EventLog EventLog { get; } + public void Dispose() + { + } - public List EventLogEntries { get; set; } + public EventLog EventLog { get; } - public void OnEventLogEntryWritten(object source, EntryWrittenEventArgs e) - { - } + public List EventLogEntries { get; set; } + + public void OnEventLogEntryWritten(object source, EntryWrittenEventArgs e) + { } -} +} \ No newline at end of file diff --git a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogXmlWriterTests.cs b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogXmlWriterTests.cs index ea9db1ada7..12264412d0 100644 --- a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogXmlWriterTests.cs +++ b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogXmlWriterTests.cs @@ -1,59 +1,58 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests -{ - using System.Collections.Generic; - using System.Diagnostics; +namespace Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +using System.Diagnostics; - using Moq; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using VisualStudio.TestTools.UnitTesting; - [TestClass] - public class EventLogXmlWriterTests - { - private const string FileName = "Event Log.xml"; +using Moq; - private const string DefaultEventLog = @""; +[TestClass] +public class EventLogXmlWriterTests +{ + private const string FileName = "Event Log.xml"; - private EventLog eventLog; + private const string DefaultEventLog = @""; - private EventLogEntry eventLogEntry; + private readonly EventLog _eventLog; - private List eventLogEntries; + private readonly EventLogEntry _eventLogEntry; - private Mock mockFileHelper; + private readonly List _eventLogEntries; - public EventLogXmlWriterTests() - { - this.eventLog = new EventLog("Application"); - var count = this.eventLog.Entries.Count; - this.eventLogEntry = this.eventLog.Entries[count - 1]; - this.eventLogEntries = new List(); - this.mockFileHelper = new Mock(); - } + private readonly Mock _mockFileHelper; - [TestMethod] - public void WriteEventLogEntriesToXmlFileShouldWriteToXMLFile() - { - EventLogXmlWriter.WriteEventLogEntriesToXmlFile( - FileName, - this.eventLogEntries, - this.mockFileHelper.Object); + public EventLogXmlWriterTests() + { + _eventLog = new EventLog("Application"); + var count = _eventLog.Entries.Count; + _eventLogEntry = _eventLog.Entries[count - 1]; + _eventLogEntries = new List(); + _mockFileHelper = new Mock(); + } - this.mockFileHelper.Verify(x => x.WriteAllTextToFile(FileName, It.IsAny()), Times.Once); - } + [TestMethod] + public void WriteEventLogEntriesToXmlFileShouldWriteToXmlFile() + { + EventLogXmlWriter.WriteEventLogEntriesToXmlFile( + FileName, + _eventLogEntries, + _mockFileHelper.Object); + + _mockFileHelper.Verify(x => x.WriteAllTextToFile(FileName, It.IsAny()), Times.Once); + } - [TestMethod] - public void WriteEventLogEntriesToXmlFileShouldWriteLogEntryIfPresent() - { - this.eventLogEntries.Add(this.eventLogEntry); + [TestMethod] + public void WriteEventLogEntriesToXmlFileShouldWriteLogEntryIfPresent() + { + _eventLogEntries.Add(_eventLogEntry); - EventLogXmlWriter.WriteEventLogEntriesToXmlFile(FileName, this.eventLogEntries, this.mockFileHelper.Object); + EventLogXmlWriter.WriteEventLogEntriesToXmlFile(FileName, _eventLogEntries, _mockFileHelper.Object); - this.mockFileHelper.Verify(x => x.WriteAllTextToFile(FileName, It.Is(str => str.Contains(this.eventLogEntry.Message)))); - } + _mockFileHelper.Verify(x => x.WriteAllTextToFile(FileName, It.Is(str => str.Contains(_eventLogEntry.Message)))); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/AcceptanceTestBase.cs b/test/Microsoft.TestPlatform.AcceptanceTests/AcceptanceTestBase.cs index a59220a4eb..d9848e6e54 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/AcceptanceTestBase.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/AcceptanceTestBase.cs @@ -1,137 +1,110 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests +namespace Microsoft.TestPlatform.AcceptanceTests; + +using System; + +using Microsoft.TestPlatform.TestUtilities; + +public class AcceptanceTestBase : IntegrationTestBase { - using System; + public const string Net451TargetFramework = "net451"; + public const string Net452TargetFramework = "net452"; + public const string Net46TargetFramework = "net46"; + public const string Net461TargetFramework = "net461"; + public const string Net462TargetFramework = "net462"; + public const string Net47TargetFramework = "net47"; + public const string Net471TargetFramework = "net471"; + public const string Net472TargetFramework = "net472"; + public const string Net48TargetFramework = "net48"; + public const string DesktopTargetFramework = "net451"; + public const string Core21TargetFramework = "netcoreapp2.1"; + public const string Core31TargetFramework = "netcoreapp3.1"; + public const string Core50TargetFramework = "net5.0"; + public const string Core60TargetFramework = "net6.0"; + + public const string DesktopFrameworkArgValue = ".NETFramework,Version=v4.5.1"; + public const string Net451FrameworkArgValue = ".NETFramework,Version=v4.5.1"; + public const string Net452FrameworkArgValue = ".NETFramework,Version=v4.5.2"; + public const string Net46FrameworkArgValue = ".NETFramework,Version=v4.6"; + public const string Net461FrameworkArgValue = ".NETFramework,Version=v4.6.1"; + public const string Net462FrameworkArgValue = ".NETFramework,Version=v4.6.2"; + public const string Net47FrameworkArgValue = ".NETFramework,Version=v4.7"; + public const string Net471FrameworkArgValue = ".NETFramework,Version=v4.7.1"; + public const string Net472FrameworkArgValue = ".NETFramework,Version=v4.7.2"; + public const string Net48FrameworkArgValue = ".NETFramework,Version=v4.8"; + + public const string Core21FrameworkArgValue = ".NETCoreApp,Version=v2.1"; + public const string Core31FrameworkArgValue = ".NETCoreApp,Version=v3.1"; + public const string Core50FrameworkArgValue = ".NETCoreApp,Version=v5.0"; + public const string Core60FrameworkArgValue = ".NETCoreApp,Version=v6.0"; - using Microsoft.TestPlatform.TestUtilities; + public const string DesktopRunnerTargetRuntime = "win7-x64"; + public const string CoreRunnerTargetRuntime = ""; + public const string InIsolation = "/InIsolation"; - public class AcceptanceTestBase : IntegrationTestBase + public const string NETFX452_48 = "net452;net461;net472;net48"; + public const string NETFX451_48 = "net452;net461;net472;net48"; + public const string NETCORE21_50 = "netcoreapp2.1;netcoreapp3.1;net5.0"; + public const string NETFX452_NET50 = "net452;net461;net472;net48;netcoreapp2.1;netcoreapp3.1;net5.0"; + public const string NETFX452_NET31 = "net452;net461;net472;net48;netcoreapp2.1;netcoreapp3.1"; + + public static string And(string left, string right) { - public const string Net451TargetFramework = "net451"; - public const string Net452TargetFramework = "net452"; - public const string Net46TargetFramework = "net46"; - public const string Net461TargetFramework = "net461"; - public const string Net462TargetFramework = "net462"; - public const string Net47TargetFramework = "net47"; - public const string Net471TargetFramework = "net471"; - public const string Net472TargetFramework = "net472"; - public const string Net48TargetFramework = "net48"; - public const string DesktopTargetFramework = "net451"; - public const string Core21TargetFramework = "netcoreapp2.1"; - public const string Core31TargetFramework = "netcoreapp3.1"; - public const string Core50TargetFramework = "net5.0"; - public const string Core60TargetFramework = "net6.0"; - - public const string DesktopFrameworkArgValue = ".NETFramework,Version=v4.5.1"; - public const string Net451FrameworkArgValue = ".NETFramework,Version=v4.5.1"; - public const string Net452FrameworkArgValue = ".NETFramework,Version=v4.5.2"; - public const string Net46FrameworkArgValue = ".NETFramework,Version=v4.6"; - public const string Net461FrameworkArgValue = ".NETFramework,Version=v4.6.1"; - public const string Net462FrameworkArgValue = ".NETFramework,Version=v4.6.2"; - public const string Net47FrameworkArgValue = ".NETFramework,Version=v4.7"; - public const string Net471FrameworkArgValue = ".NETFramework,Version=v4.7.1"; - public const string Net472FrameworkArgValue = ".NETFramework,Version=v4.7.2"; - public const string Net48FrameworkArgValue = ".NETFramework,Version=v4.8"; - - public const string Core21FrameworkArgValue = ".NETCoreApp,Version=v2.1"; - public const string Core31FrameworkArgValue = ".NETCoreApp,Version=v3.1"; - public const string Core50FrameworkArgValue = ".NETCoreApp,Version=v5.0"; - public const string Core60FrameworkArgValue = ".NETCoreApp,Version=v6.0"; - - public const string DesktopRunnerTargetRuntime = "win7-x64"; - public const string CoreRunnerTargetRuntime = ""; - public const string InIsolation = "/InIsolation"; - - public const string NETFX452_48 = "net452;net461;net472;net48"; - public const string NETFX451_48 = "net452;net461;net472;net48"; - public const string NETCORE21_50 = "netcoreapp2.1;netcoreapp3.1;net5.0"; - public const string NETFX452_NET50 = "net452;net461;net472;net48;netcoreapp2.1;netcoreapp3.1;net5.0"; - public const string NETFX452_NET31 = "net452;net461;net472;net48;netcoreapp2.1;netcoreapp3.1"; - - public static string And(string left, string right) - { - return string.Join(";", left, right); - } + return string.Join(";", left, right); + } - protected string FrameworkArgValue => DeriveFrameworkArgValue(this.testEnvironment); + protected string FrameworkArgValue => DeriveFrameworkArgValue(_testEnvironment); - protected static void SetTestEnvironment(IntegrationTestEnvironment testEnvironment, RunnerInfo runnerInfo) - { - testEnvironment.RunnerFramework = runnerInfo.RunnerFramework; - testEnvironment.TargetFramework = runnerInfo.TargetFramework; - testEnvironment.InIsolationValue = runnerInfo.InIsolationValue; - } + protected static void SetTestEnvironment(IntegrationTestEnvironment testEnvironment, RunnerInfo runnerInfo) + { + testEnvironment.RunnerFramework = runnerInfo.RunnerFramework; + testEnvironment.TargetFramework = runnerInfo.TargetFramework; + testEnvironment.InIsolationValue = runnerInfo.InIsolationValue; + } - protected static string DeriveFrameworkArgValue(IntegrationTestEnvironment testEnvironment) - { - switch (testEnvironment.TargetFramework) - { - case Core21TargetFramework: - return Core21FrameworkArgValue; - case Core31TargetFramework: - return Core31FrameworkArgValue; - case Core50TargetFramework: - return Core50FrameworkArgValue; - case Core60TargetFramework: - return Core60FrameworkArgValue; - case Net451TargetFramework: - return Net451FrameworkArgValue; - case Net452TargetFramework: - return Net452FrameworkArgValue; - case Net46TargetFramework: - return Net46FrameworkArgValue; - case Net461TargetFramework: - return Net461FrameworkArgValue; - case Net462TargetFramework: - return Net462FrameworkArgValue; - case Net47TargetFramework: - return Net47FrameworkArgValue; - case Net471TargetFramework: - return Net471FrameworkArgValue; - case Net472TargetFramework: - return Net472FrameworkArgValue; - case Net48TargetFramework: - return Net48FrameworkArgValue; - default: - throw new NotSupportedException($"{testEnvironment.TargetFramework} is not supported TargetFramework value."); - } - } - - protected bool IsDesktopTargetFramework() + protected static string DeriveFrameworkArgValue(IntegrationTestEnvironment testEnvironment) + => testEnvironment.TargetFramework switch { - return this.testEnvironment.TargetFramework == AcceptanceTestBase.DesktopTargetFramework; - } + Core21TargetFramework => Core21FrameworkArgValue, + Core31TargetFramework => Core31FrameworkArgValue, + Core50TargetFramework => Core50FrameworkArgValue, + Core60TargetFramework => Core60FrameworkArgValue, + Net451TargetFramework => Net451FrameworkArgValue, + Net452TargetFramework => Net452FrameworkArgValue, + Net46TargetFramework => Net46FrameworkArgValue, + Net461TargetFramework => Net461FrameworkArgValue, + Net462TargetFramework => Net462FrameworkArgValue, + Net47TargetFramework => Net47FrameworkArgValue, + Net471TargetFramework => Net471FrameworkArgValue, + Net472TargetFramework => Net472FrameworkArgValue, + Net48TargetFramework => Net48FrameworkArgValue, + _ => throw new NotSupportedException($"{testEnvironment.TargetFramework} is not supported TargetFramework value."), + }; - protected string GetTargetFramworkForRunsettings() - { - var targetFramework = string.Empty; - if (this.testEnvironment.TargetFramework == DesktopTargetFramework) - { - targetFramework = "Framework45"; - } - else - { - targetFramework = "FrameworkCore10"; - } - - return targetFramework; - } - - /// - /// Default RunSettings - /// - /// - public string GetDefaultRunSettings() - { - string runSettingsXml = $@" + protected bool IsDesktopTargetFramework() + => _testEnvironment.TargetFramework == AcceptanceTestBase.DesktopTargetFramework; + + protected string GetTargetFramworkForRunsettings() + { + string targetFramework = _testEnvironment.TargetFramework == DesktopTargetFramework ? "Framework45" : "FrameworkCore10"; + + return targetFramework; + } + + /// + /// Default RunSettings + /// + /// + public string GetDefaultRunSettings() + { + string runSettingsXml = $@" {FrameworkArgValue} "; - return runSettingsXml; - } + return runSettingsXml; } } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/AppDomainTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/AppDomainTests.cs index c55ebf70ab..b7e51c2262 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/AppDomainTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/AppDomainTests.cs @@ -1,85 +1,85 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using System; - using System.Collections.Generic; - using System.IO; +namespace Microsoft.TestPlatform.AcceptanceTests; + +using System; +using System.Collections.Generic; +using System.IO; #if !NET451 - using System.Runtime.Loader; +using System.Runtime.Loader; #else - using System.Reflection; +using System.Reflection; #endif - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestClass] +[TestClass] +[TestCategory("Windows-Review")] +public class AppDomainTests : AcceptanceTestBase +{ + [TestMethod] [TestCategory("Windows-Review")] - public class AppDomainTests : AcceptanceTestBase + [NetFullTargetFrameworkDataSource] + public void RunTestExecutionWithDisableAppDomain(RunnerInfo runnerInfo) { - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - public void RunTestExecutionWithDisableAppDomain(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - var testAppDomainDetailFileName = Path.Combine(tempDir.Path, "appdomain_test.txt"); - var dataCollectorAppDomainDetailFileName = Path.Combine(tempDir.Path, "appdomain_datacollector.txt"); + using var tempDir = new TempDirectory(); + var testAppDomainDetailFileName = Path.Combine(tempDir.Path, "appdomain_test.txt"); + var dataCollectorAppDomainDetailFileName = Path.Combine(tempDir.Path, "appdomain_datacollector.txt"); - // Delete test output files if already exist - File.Delete(testAppDomainDetailFileName); - File.Delete(dataCollectorAppDomainDetailFileName); + // Delete test output files if already exist + File.Delete(testAppDomainDetailFileName); + File.Delete(dataCollectorAppDomainDetailFileName); - var runsettingsFilePath = this.GetInProcDataCollectionRunsettingsFile(true, tempDir); - var arguments = PrepareArguments( - this.GetSampleTestAssembly(), - this.GetTestAdapterPath(), - runsettingsFilePath, - this.FrameworkArgValue, - runnerInfo.InIsolationValue, - tempDir.Path); + var runsettingsFilePath = GetInProcDataCollectionRunsettingsFile(true, tempDir); + var arguments = PrepareArguments( + GetSampleTestAssembly(), + GetTestAdapterPath(), + runsettingsFilePath, + FrameworkArgValue, + runnerInfo.InIsolationValue, + tempDir.Path); - // Sets the environment variables used by the test project and test data collector. - var env = new Dictionary - { - ["TEST_ASSET_APPDOMAIN_TEST_PATH"] = testAppDomainDetailFileName, - ["TEST_ASSET_APPDOMAIN_COLLECTOR_PATH"] = dataCollectorAppDomainDetailFileName, - }; + // Sets the environment variables used by the test project and test data collector. + var env = new Dictionary + { + ["TEST_ASSET_APPDOMAIN_TEST_PATH"] = testAppDomainDetailFileName, + ["TEST_ASSET_APPDOMAIN_COLLECTOR_PATH"] = dataCollectorAppDomainDetailFileName, + }; - this.InvokeVsTest(arguments, env); + InvokeVsTest(arguments, env); - Assert.IsTrue( - IsFilesContentEqual(testAppDomainDetailFileName, dataCollectorAppDomainDetailFileName), - "Different AppDomains, test: {0} datacollector: {1}", - File.ReadAllText(testAppDomainDetailFileName), - File.ReadAllText(dataCollectorAppDomainDetailFileName)); - this.ValidateSummaryStatus(1, 1, 1); - File.Delete(runsettingsFilePath); - } + Assert.IsTrue( + IsFilesContentEqual(testAppDomainDetailFileName, dataCollectorAppDomainDetailFileName), + "Different AppDomains, test: {0} datacollector: {1}", + File.ReadAllText(testAppDomainDetailFileName), + File.ReadAllText(dataCollectorAppDomainDetailFileName)); + ValidateSummaryStatus(1, 1, 1); + File.Delete(runsettingsFilePath); + } - private static bool IsFilesContentEqual(string filePath1, string filePath2) - { - Assert.IsTrue(File.Exists(filePath1), "File doesn't exist: {0}.", filePath1); - Assert.IsTrue(File.Exists(filePath2), "File doesn't exist: {0}.", filePath2); - var content1 = File.ReadAllText(filePath1); - var content2 = File.ReadAllText(filePath2); - Assert.IsTrue(string.Equals(content1, content2, StringComparison.Ordinal), "Content mismatch{2}- file1 content:{2}{0}{2}- file2 content:{2}{1}{2}", content1, content2, Environment.NewLine); - return string.Equals(content1, content2, StringComparison.Ordinal); - } + private static bool IsFilesContentEqual(string filePath1, string filePath2) + { + Assert.IsTrue(File.Exists(filePath1), "File doesn't exist: {0}.", filePath1); + Assert.IsTrue(File.Exists(filePath2), "File doesn't exist: {0}.", filePath2); + var content1 = File.ReadAllText(filePath1); + var content2 = File.ReadAllText(filePath2); + Assert.IsTrue(string.Equals(content1, content2, StringComparison.Ordinal), "Content mismatch{2}- file1 content:{2}{0}{2}- file2 content:{2}{1}{2}", content1, content2, Environment.NewLine); + return string.Equals(content1, content2, StringComparison.Ordinal); + } - private string GetInProcDataCollectionRunsettingsFile(bool disableAppDomain, TempDirectory tempDirectory) - { - var runSettings = Path.Combine(tempDirectory.Path, "test_" + Guid.NewGuid() + ".runsettings"); - var inprocasm = this.testEnvironment.GetTestAsset("SimpleDataCollector.dll"); + private string GetInProcDataCollectionRunsettingsFile(bool disableAppDomain, TempDirectory tempDirectory) + { + var runSettings = Path.Combine(tempDirectory.Path, "test_" + Guid.NewGuid() + ".runsettings"); + var inprocasm = _testEnvironment.GetTestAsset("SimpleDataCollector.dll"); #if !NET451 - var assemblyName = AssemblyLoadContext.GetAssemblyName(inprocasm); + var assemblyName = AssemblyLoadContext.GetAssemblyName(inprocasm); #else - var assemblyName = AssemblyName.GetAssemblyName(inprocasm); + var assemblyName = AssemblyName.GetAssemblyName(inprocasm); #endif - var fileContents = @" + var fileContents = @" @@ -94,10 +94,9 @@ private string GetInProcDataCollectionRunsettingsFile(bool disableAppDomain, Tem "; - fileContents = string.Format(fileContents, assemblyName, inprocasm); - File.WriteAllText(runSettings, fileContents); + fileContents = string.Format(fileContents, assemblyName, inprocasm); + File.WriteAllText(runSettings, fileContents); - return runSettings; - } + return runSettings; } } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/ArgumentProcessorTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/ArgumentProcessorTests.cs index 4900e905f4..ed23db78c7 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/ArgumentProcessorTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/ArgumentProcessorTests.cs @@ -1,63 +1,62 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests +namespace Microsoft.TestPlatform.AcceptanceTests; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +[TestCategory("Windows-Review")] +public class ArgumentProcessorTests : AcceptanceTestBase { - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestClass] + [TestMethod] [TestCategory("Windows-Review")] - public class ArgumentProcessorTests : AcceptanceTestBase + [NetFullTargetFrameworkDataSource] + public void PassingNoArgumentsToVsTestConsoleShouldPrintHelpMessage(RunnerInfo runnerInfo) { + SetTestEnvironment(_testEnvironment, runnerInfo); - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - public void PassingNoArgumentsToVsTestConsoleShouldPrintHelpMessage(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - - this.InvokeVsTest(null); + InvokeVsTest(null); - //Check for help usage, description and arguments text. - this.StdOutputContains("Usage: vstest.console.exe"); - this.StdOutputContains("Description: Runs tests from the specified files."); - this.StdOutputContains("Arguments:"); + //Check for help usage, description and arguments text. + StdOutputContains("Usage: vstest.console.exe"); + StdOutputContains("Description: Runs tests from the specified files."); + StdOutputContains("Arguments:"); - //Check for help options text - this.StdOutputContains("Options:"); + //Check for help options text + StdOutputContains("Options:"); - //Check for help examples text - this.StdOutputContains("To run tests: >vstest.console.exe tests.dll"); - } + //Check for help examples text + StdOutputContains("To run tests: >vstest.console.exe tests.dll"); + } - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - public void PassingInvalidArgumentsToVsTestConsoleShouldNotPrintHelpMessage(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + public void PassingInvalidArgumentsToVsTestConsoleShouldNotPrintHelpMessage(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - var arguments = PrepareArguments(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /badArgument"); + using var tempDir = new TempDirectory(); + var arguments = PrepareArguments(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, FrameworkArgValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /badArgument"); - this.InvokeVsTest(arguments); + InvokeVsTest(arguments); - //Check for help usage, description and arguments text. - this.StdOutputDoesNotContains("Usage: vstest.console.exe"); - this.StdOutputDoesNotContains("Description: Runs tests from the specified files."); - this.StdOutputDoesNotContains("Arguments:"); + //Check for help usage, description and arguments text. + StdOutputDoesNotContains("Usage: vstest.console.exe"); + StdOutputDoesNotContains("Description: Runs tests from the specified files."); + StdOutputDoesNotContains("Arguments:"); - //Check for help options text - this.StdOutputDoesNotContains("Options:"); + //Check for help options text + StdOutputDoesNotContains("Options:"); - //Check for help examples text - this.StdOutputDoesNotContains("To run tests: >vstest.console.exe tests.dll"); + //Check for help examples text + StdOutputDoesNotContains("To run tests: >vstest.console.exe tests.dll"); - //Check for message which guides using help option - this.StdErrorContains("Please use the /help option to check the list of valid arguments"); - } + //Check for message which guides using help option + StdErrorContains("Please use the /help option to check the list of valid arguments"); } } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/BlameDataCollectorTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/BlameDataCollectorTests.cs index 360e790382..c18eabe2fd 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/BlameDataCollectorTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/BlameDataCollectorTests.cs @@ -1,360 +1,359 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests +namespace Microsoft.TestPlatform.AcceptanceTests; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Xml; + +[TestClass] +// this whole thing is complicated and depends on versions of OS and the target runtime +// keeping this for later +[TestCategory("Windows-Review")] +public class BlameDataCollectorTests : AcceptanceTestBase { - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Text; - using System.Xml; - - [TestClass] - // this whole thing is complicated and depends on versions of OS and the target runtime - // keeping this for later + public const string NETCOREANDFX = "net452;net472;netcoreapp3.1"; + public const string NET50 = "net5.0"; + + [TestMethod] + // netcoreapp2.1 dump is not supported on Linux [TestCategory("Windows-Review")] - public class BlameDataCollectorTests : AcceptanceTestBase + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void BlameDataCollectorShouldGiveCorrectTestCaseName(RunnerInfo runnerInfo) { - public const string NETCOREANDFX = "net452;net472;netcoreapp3.1"; - public const string NET50 = "net5.0"; - - [TestMethod] - // netcoreapp2.1 dump is not supported on Linux - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void BlameDataCollectorShouldGiveCorrectTestCaseName(RunnerInfo runnerInfo) - { - using var tempDir = new TempDirectory(); - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - var assemblyPaths = this.GetAssetFullPath("BlameUnitTestProject.dll"); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue); - arguments = string.Concat(arguments, $" /Blame"); - arguments = string.Concat(arguments, $" /ResultsDirectory:{tempDir.Path}"); - this.InvokeVsTest(arguments); - - this.VaildateOutput(tempDir, "BlameUnitTestProject.UnitTest1.TestMethod2"); - } + using var tempDir = new TempDirectory(); + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + var assemblyPaths = GetAssetFullPath("BlameUnitTestProject.dll"); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue); + arguments = string.Concat(arguments, $" /Blame"); + arguments = string.Concat(arguments, $" /ResultsDirectory:{tempDir.Path}"); + InvokeVsTest(arguments); + + VaildateOutput(tempDir, "BlameUnitTestProject.UnitTest1.TestMethod2"); + } - [TestMethod] - // netcoreapp2.1 dump is not supported on Linux - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void BlameDataCollectorShouldOutputDumpFile(RunnerInfo runnerInfo) + [TestMethod] + // netcoreapp2.1 dump is not supported on Linux + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void BlameDataCollectorShouldOutputDumpFile(RunnerInfo runnerInfo) + { + using var tempDir = new TempDirectory(); + + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject3.dll").Trim('\"'); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue); + arguments = string.Concat(arguments, $" /Blame:CollectDump"); + arguments = string.Concat(arguments, $" /ResultsDirectory:{tempDir.Path}"); + arguments = string.Concat(arguments, " /testcasefilter:ExitWithStackoverFlow"); + + var env = new Dictionary { - using var tempDir = new TempDirectory(); + ["PROCDUMP_PATH"] = Path.Combine(_testEnvironment.PackageDirectory, @"procdump\0.0.1\bin"), + }; - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject3.dll").Trim('\"'); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue); - arguments = string.Concat(arguments, $" /Blame:CollectDump"); - arguments = string.Concat(arguments, $" /ResultsDirectory:{tempDir.Path}"); - arguments = string.Concat(arguments, " /testcasefilter:ExitWithStackoverFlow"); + InvokeVsTest(arguments, env); - var env = new Dictionary - { - ["PROCDUMP_PATH"] = Path.Combine(this.testEnvironment.PackageDirectory, @"procdump\0.0.1\bin"), - }; + VaildateOutput(tempDir, "SampleUnitTestProject3.UnitTest1.ExitWithStackoverFlow", validateDumpFile: true); + } - this.InvokeVsTest(arguments, env); + [TestMethod] + // netcoreapp2.1 dump is not supported on Linux + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void BlameDataCollectorShouldNotOutputDumpFileWhenNoCrashOccurs(RunnerInfo runnerInfo) + { + using var tempDir = new TempDirectory(); - this.VaildateOutput(tempDir, "SampleUnitTestProject3.UnitTest1.ExitWithStackoverFlow", validateDumpFile: true); - } + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject.dll").Trim('\"'); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue); + arguments = string.Concat(arguments, $" /Blame:CollectDump"); + arguments = string.Concat(arguments, $" /ResultsDirectory:{tempDir.Path}"); + arguments = string.Concat(arguments, " /testcasefilter:PassingTest"); - [TestMethod] - // netcoreapp2.1 dump is not supported on Linux - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void BlameDataCollectorShouldNotOutputDumpFileWhenNoCrashOccurs(RunnerInfo runnerInfo) + var env = new Dictionary { - using var tempDir = new TempDirectory(); + ["PROCDUMP_PATH"] = Path.Combine(_testEnvironment.PackageDirectory, @"procdump\0.0.1\bin"), + }; - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject.dll").Trim('\"'); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue); - arguments = string.Concat(arguments, $" /Blame:CollectDump"); - arguments = string.Concat(arguments, $" /ResultsDirectory:{tempDir.Path}"); - arguments = string.Concat(arguments, " /testcasefilter:PassingTest"); + InvokeVsTest(arguments, env); - var env = new Dictionary - { - ["PROCDUMP_PATH"] = Path.Combine(this.testEnvironment.PackageDirectory, @"procdump\0.0.1\bin"), - }; + Assert.IsFalse(StdOut.Contains(".dmp"), "it should not collect a dump, because nothing crashed"); + } - this.InvokeVsTest(arguments, env); + [TestMethod] + // netcoreapp2.1 dump is not supported on Linux + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void BlameDataCollectorShouldOutputDumpFileWhenNoCrashOccursButCollectAlwaysIsEnabled(RunnerInfo runnerInfo) + { + using var tempDir = new TempDirectory(); - Assert.IsFalse(this.StdOut.Contains(".dmp"), "it should not collect a dump, because nothing crashed"); - } + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject.dll").Trim('\"'); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue); + arguments = string.Concat(arguments, $" /Blame:CollectDump;CollectAlways=True"); + arguments = string.Concat(arguments, $" /ResultsDirectory:{tempDir.Path}"); + arguments = string.Concat(arguments, " /testcasefilter:PassingTest"); - [TestMethod] - // netcoreapp2.1 dump is not supported on Linux - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void BlameDataCollectorShouldOutputDumpFileWhenNoCrashOccursButCollectAlwaysIsEnabled(RunnerInfo runnerInfo) + var env = new Dictionary { - using var tempDir = new TempDirectory(); + ["PROCDUMP_PATH"] = Path.Combine(_testEnvironment.PackageDirectory, @"procdump\0.0.1\bin"), + }; - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject.dll").Trim('\"'); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue); - arguments = string.Concat(arguments, $" /Blame:CollectDump;CollectAlways=True"); - arguments = string.Concat(arguments, $" /ResultsDirectory:{tempDir.Path}"); - arguments = string.Concat(arguments, " /testcasefilter:PassingTest"); + InvokeVsTest(arguments, env); - var env = new Dictionary - { - ["PROCDUMP_PATH"] = Path.Combine(this.testEnvironment.PackageDirectory, @"procdump\0.0.1\bin"), - }; - - this.InvokeVsTest(arguments, env); + Assert.IsTrue(StdOut.Contains(".dmp"), "it should collect dump, even if nothing crashed"); + } - Assert.IsTrue(this.StdOut.Contains(".dmp"), "it should collect dump, even if nothing crashed"); - } + [TestMethod] + [NetCoreRunner("net452;net472;netcoreapp3.1;net5.0")] + // should make no difference, keeping for easy debug + // [NetFrameworkRunner("net452;net472;netcoreapp3.1;net5.0")] + public void HangDumpOnTimeout(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + var assemblyPaths = GetAssetFullPath("timeout.dll"); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue); + arguments = string.Concat(arguments, $@" /Blame:""CollectHangDump;HangDumpType=full;TestTimeout=3s"""); - [TestMethod] - [NetCoreRunner("net452;net472;netcoreapp3.1;net5.0")] - // should make no difference, keeping for easy debug - // [NetFrameworkRunner("net452;net472;netcoreapp3.1;net5.0")] - public void HangDumpOnTimeout(RunnerInfo runnerInfo) + var env = new Dictionary { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - var assemblyPaths = this.GetAssetFullPath("timeout.dll"); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue); - arguments = string.Concat(arguments, $@" /Blame:""CollectHangDump;HangDumpType=full;TestTimeout=3s"""); + ["PROCDUMP_PATH"] = Path.Combine(_testEnvironment.PackageDirectory, @"procdump\0.0.1\bin"), + }; - var env = new Dictionary - { - ["PROCDUMP_PATH"] = Path.Combine(this.testEnvironment.PackageDirectory, @"procdump\0.0.1\bin"), - }; + InvokeVsTest(arguments, env); - this.InvokeVsTest(arguments, env); + ValidateDump(); + } - this.ValidateDump(); - } + [TestMethod] + // net5.0 does not support dump on exit + [NetCoreRunner("net452;net472;netcoreapp3.1")] + // should make no difference, keeping for easy debug + // [NetFrameworkRunner("net452;net472;netcoreapp3.1")] - [TestMethod] - // net5.0 does not support dump on exit - [NetCoreRunner("net452;net472;netcoreapp3.1")] - // should make no difference, keeping for easy debug - // [NetFrameworkRunner("net452;net472;netcoreapp3.1")] + public void CrashDumpWhenThereIsNoTimeout(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + var assemblyPaths = GetAssetFullPath("timeout.dll"); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue); + arguments = string.Concat(arguments, $@" /Blame:""CollectDump;DumpType=full;CollectAlways=true;CollectHangDump"""); - public void CrashDumpWhenThereIsNoTimeout(RunnerInfo runnerInfo) + var env = new Dictionary { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - var assemblyPaths = this.GetAssetFullPath("timeout.dll"); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue); - arguments = string.Concat(arguments, $@" /Blame:""CollectDump;DumpType=full;CollectAlways=true;CollectHangDump"""); + ["PROCDUMP_PATH"] = Path.Combine(_testEnvironment.PackageDirectory, @"procdump\0.0.1\bin"), + }; - var env = new Dictionary - { - ["PROCDUMP_PATH"] = Path.Combine(this.testEnvironment.PackageDirectory, @"procdump\0.0.1\bin"), - }; + InvokeVsTest(arguments, env); - this.InvokeVsTest(arguments, env); + ValidateDump(); + } - this.ValidateDump(); - } + [TestMethod] + // net5.0 does not support dump on exit + [NetCoreRunner("net452;net472;netcoreapp3.1")] + // should make no difference, keeping for easy debug + // [NetFrameworkRunner("net452;net472;netcoreapp3.1")] - [TestMethod] - // net5.0 does not support dump on exit - [NetCoreRunner("net452;net472;netcoreapp3.1")] - // should make no difference, keeping for easy debug - // [NetFrameworkRunner("net452;net472;netcoreapp3.1")] + public void CrashDumpOnExit(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + var assemblyPaths = GetAssetFullPath("timeout.dll"); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue); + arguments = string.Concat(arguments, $@" /Blame:""CollectDump;DumpType=full;CollectAlways=true"""); - public void CrashDumpOnExit(RunnerInfo runnerInfo) + var env = new Dictionary { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - var assemblyPaths = this.GetAssetFullPath("timeout.dll"); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue); - arguments = string.Concat(arguments, $@" /Blame:""CollectDump;DumpType=full;CollectAlways=true"""); + ["PROCDUMP_PATH"] = Path.Combine(_testEnvironment.PackageDirectory, @"procdump\0.0.1\bin"), + }; - var env = new Dictionary - { - ["PROCDUMP_PATH"] = Path.Combine(this.testEnvironment.PackageDirectory, @"procdump\0.0.1\bin"), - }; + InvokeVsTest(arguments, env); - this.InvokeVsTest(arguments, env); + ValidateDump(); + } - this.ValidateDump(); - } + [TestMethod] + [NetCoreRunner("net452;net472;netcoreapp3.1;net5.0")] + // should make no difference, keeping for easy debug + // [NetFrameworkRunner("net452;net472;netcoreapp3.1;net5.0")] + public void CrashDumpOnStackOverflow(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + var assemblyPaths = GetAssetFullPath("crash.dll"); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue); + arguments = string.Concat(arguments, $@" /Blame:""CollectDump;DumpType=full"""); - [TestMethod] - [NetCoreRunner("net452;net472;netcoreapp3.1;net5.0")] - // should make no difference, keeping for easy debug - // [NetFrameworkRunner("net452;net472;netcoreapp3.1;net5.0")] - public void CrashDumpOnStackOverflow(RunnerInfo runnerInfo) + var env = new Dictionary { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - var assemblyPaths = this.GetAssetFullPath("crash.dll"); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue); - arguments = string.Concat(arguments, $@" /Blame:""CollectDump;DumpType=full"""); + ["PROCDUMP_PATH"] = Path.Combine(_testEnvironment.PackageDirectory, @"procdump\0.0.1\bin"), + }; - var env = new Dictionary - { - ["PROCDUMP_PATH"] = Path.Combine(this.testEnvironment.PackageDirectory, @"procdump\0.0.1\bin"), - }; + InvokeVsTest(arguments, env); - this.InvokeVsTest(arguments, env); + ValidateDump(); + } - this.ValidateDump(); - } + [TestMethod] + [NetCoreRunner(NET50)] + // should make no difference, keeping for easy debug + // [NetFrameworkRunner(NET50)] + public void CrashDumpChildProcesses(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + var assemblyPaths = GetAssetFullPath("child-crash.dll"); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue); + arguments = string.Concat(arguments, $@" /Blame:""CollectDump;DumpType=full"""); + InvokeVsTest(arguments); - [TestMethod] - [NetCoreRunner(NET50)] - // should make no difference, keeping for easy debug - // [NetFrameworkRunner(NET50)] - public void CrashDumpChildProcesses(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - var assemblyPaths = this.GetAssetFullPath("child-crash.dll"); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue); - arguments = string.Concat(arguments, $@" /Blame:""CollectDump;DumpType=full"""); - this.InvokeVsTest(arguments); + ValidateDump(2); + } - this.ValidateDump(2); - } + [TestMethod] + [NetCoreRunner("net452;net472;netcoreapp3.1;net5.0")] + // should make no difference, keeping for easy debug + // [NetFrameworkRunner("net452;net472;netcoreapp3.1;net5.0")] + public void HangDumpChildProcesses(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + var assemblyPaths = GetAssetFullPath("child-hang.dll"); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue); + arguments = string.Concat(arguments, $@" /Blame:""CollectHangDump;HangDumpType=full;TestTimeout=15s"""); + InvokeVsTest(arguments); - [TestMethod] - [NetCoreRunner("net452;net472;netcoreapp3.1;net5.0")] - // should make no difference, keeping for easy debug - // [NetFrameworkRunner("net452;net472;netcoreapp3.1;net5.0")] - public void HangDumpChildProcesses(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - var assemblyPaths = this.GetAssetFullPath("child-hang.dll"); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue); - arguments = string.Concat(arguments, $@" /Blame:""CollectHangDump;HangDumpType=full;TestTimeout=15s"""); - this.InvokeVsTest(arguments); + ValidateDump(2); + } - this.ValidateDump(2); - } + private void ValidateDump(int expectedDumpCount = 1) + { + var attachments = StdOutWithWhiteSpace.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries) + .SkipWhile(l => !l.Contains("Attachments:")).Skip(1) + .Where(l => !string.IsNullOrWhiteSpace(l)) + .ToList(); - private void ValidateDump(int expectedDumpCount = 1) + var output = string.Join(Environment.NewLine, attachments); + if (!attachments.Any(a => a.Contains("Sequence_"))) { - var attachments = this.StdOutWithWhiteSpace.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries) - .SkipWhile(l => !l.Contains("Attachments:")).Skip(1) - .Where(l => !string.IsNullOrWhiteSpace(l)) - .ToList(); + // sequence file is pretty flaky, and easily substituted by diag log + // throw new AssertFailedException("Expected Sequence file in Attachments, but there was none." + // + Environment.NewLine + // + output); + } - var output = string.Join(Environment.NewLine, attachments); - if (!attachments.Any(a => a.Contains("Sequence_"))) - { - // sequence file is pretty flaky, and easily substituted by diag log - // throw new AssertFailedException("Expected Sequence file in Attachments, but there was none." - // + Environment.NewLine - // + output); - } + var dumps = attachments + .Where(a => a.EndsWith(".dmp")) + // On Windows we might collect conhost which tells us nothing + // or WerFault in case we would start hanging during crash + // we don't want these to make cross-platform checks more difficult + // so we filter them out. + .Where(a => !a.Contains("WerFault") && !a.Contains("conhost")) + .Select(a => a.Trim()).ToList(); - var dumps = attachments - .Where(a => a.EndsWith(".dmp")) - // On Windows we might collect conhost which tells us nothing - // or WerFault in case we would start hanging during crash - // we don't want these to make cross-platform checks more difficult - // so we filter them out. - .Where(a => !a.Contains("WerFault") && !a.Contains("conhost")) - .Select(a => a.Trim()).ToList(); + if (dumps.Count < expectedDumpCount) + { + throw new AssertFailedException($"Expected at least {expectedDumpCount} dump file in Attachments, but there were {dumps.Count}." + + Environment.NewLine + + string.Join(Environment.NewLine, dumps)); + } - if (dumps.Count < expectedDumpCount) + var nonExistingDumps = new List(); + var emptyDumps = new List(); + foreach (var dump in dumps) + { + if (!File.Exists(dump)) { - throw new AssertFailedException($"Expected at least {expectedDumpCount} dump file in Attachments, but there were {dumps.Count}." - + Environment.NewLine - + string.Join(Environment.NewLine, dumps)); + nonExistingDumps.Add(dump); } - - var nonExistingDumps = new List(); - var emptyDumps = new List(); - foreach (var dump in dumps) + else { - if (!File.Exists(dump)) - { - nonExistingDumps.Add(dump); - } - else + var file = new FileInfo(dump); + if (file.Length == 0) { - var file = new FileInfo(dump); - if (file.Length == 0) - { - emptyDumps.Add(dump); - } + emptyDumps.Add(dump); } } + } - // allow some child dumps to be missing, they manage to terminate early from time to time - if ((dumps.Count == 1 && nonExistingDumps.Any()) || (dumps.Count > 1 && nonExistingDumps.Count > 1) - || emptyDumps.Any()) + // allow some child dumps to be missing, they manage to terminate early from time to time + if ((dumps.Count == 1 && nonExistingDumps.Any()) || (dumps.Count > 1 && nonExistingDumps.Count > 1) + || emptyDumps.Any()) + { + var err = new StringBuilder(); + err.AppendLine("Expected all dumps in the list of attachments to exist, and not be empty, but:"); + if (nonExistingDumps.Any()) { - var err = new StringBuilder(); - err.AppendLine("Expected all dumps in the list of attachments to exist, and not be empty, but:"); - if (nonExistingDumps.Any()) - { - err.AppendLine($"{nonExistingDumps.Count} don't exist:") - .AppendLine(string.Join(Environment.NewLine, nonExistingDumps)); - } + err.AppendLine($"{nonExistingDumps.Count} don't exist:") + .AppendLine(string.Join(Environment.NewLine, nonExistingDumps)); + } - if (emptyDumps.Any()) - { - err.AppendLine($"{emptyDumps.Count} are empty:") - .AppendLine(string.Join(Environment.NewLine, emptyDumps)); - } + if (emptyDumps.Any()) + { + err.AppendLine($"{emptyDumps.Count} are empty:") + .AppendLine(string.Join(Environment.NewLine, emptyDumps)); + } - err.AppendLine("Reported attachments:") - .AppendLine(output); + err.AppendLine("Reported attachments:") + .AppendLine(output); - throw new AssertFailedException(err.ToString()); - } + throw new AssertFailedException(err.ToString()); } + } - private void VaildateOutput(TempDirectory tempDir, string testName, bool validateDumpFile = false) + private void VaildateOutput(TempDirectory tempDir, string testName, bool validateDumpFile = false) + { + bool isSequenceAttachmentReceived = false; + bool isDumpAttachmentReceived = false; + bool isValid = false; + StdErrorContains(testName); + StdOutputContains("Sequence_"); + var resultFiles = Directory.GetFiles(tempDir.Path, "*", SearchOption.AllDirectories); + + foreach (var file in resultFiles) { - bool isSequenceAttachmentReceived = false; - bool isDumpAttachmentReceived = false; - bool isValid = false; - this.StdErrorContains(testName); - this.StdOutputContains("Sequence_"); - var resultFiles = Directory.GetFiles(tempDir.Path, "*", SearchOption.AllDirectories); - - foreach (var file in resultFiles) + if (file.Contains("Sequence_")) { - if (file.Contains("Sequence_")) - { - isSequenceAttachmentReceived = true; - isValid = IsValidXml(file); - } - else if (validateDumpFile && file.Contains(".dmp")) - { - isDumpAttachmentReceived = true; - } + isSequenceAttachmentReceived = true; + isValid = IsValidXml(file); + } + else if (validateDumpFile && file.Contains(".dmp")) + { + isDumpAttachmentReceived = true; } - - Assert.IsTrue(isSequenceAttachmentReceived); - Assert.IsTrue(!validateDumpFile || isDumpAttachmentReceived); - Assert.IsTrue(isValid); } - private bool IsValidXml(string xmlFilePath) + Assert.IsTrue(isSequenceAttachmentReceived); + Assert.IsTrue(!validateDumpFile || isDumpAttachmentReceived); + Assert.IsTrue(isValid); + } + + private bool IsValidXml(string xmlFilePath) + { + var file = File.OpenRead(xmlFilePath); + var reader = XmlReader.Create(file); + try { - var file = File.OpenRead(xmlFilePath); - var reader = XmlReader.Create(file); - try - { - while (reader.Read()) - { - } - file.Dispose(); - return true; - } - catch (XmlException) + while (reader.Read()) { - file.Dispose(); - return false; } + file.Dispose(); + return true; + } + catch (XmlException) + { + file.Dispose(); + return false; } } } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/CUITTest.cs b/test/Microsoft.TestPlatform.AcceptanceTests/CUITTest.cs index 40c3dbe6de..4b6f8fc01f 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/CUITTest.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/CUITTest.cs @@ -1,38 +1,37 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.AcceptanceTests; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestClass] +[TestClass] +[TestCategory("Windows-Review")] +public class CuitTest : AcceptanceTestBase +{ + [TestMethod] [TestCategory("Windows-Review")] - public class CUITTest : AcceptanceTestBase + [NetFullTargetFrameworkDataSource] + public void CuitRunAllTests(RunnerInfo runnerInfo) { - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - public void CUITRunAllTests(RunnerInfo runnerInfo) - { - SetTestEnvironment(this.testEnvironment, runnerInfo); - CUITRunAll(runnerInfo.RunnerFramework); - } + SetTestEnvironment(_testEnvironment, runnerInfo); + CuitRunAll(runnerInfo.RunnerFramework); + } - private void CUITRunAll(string runnerFramework) + private void CuitRunAll(string runnerFramework) + { + if (runnerFramework.StartsWith("netcoreapp")) { - if (runnerFramework.StartsWith("netcoreapp")) - { - Assert.Inconclusive("CUIT tests are not supported with .Netcore runner."); - return; - } + Assert.Inconclusive("CUIT tests are not supported with .Netcore runner."); + return; + } - var assemblyAbsolutePath = testEnvironment.GetTestAsset("CUITTestProject.dll", "net451"); - using var tempDir = new TempDirectory(); - var arguments = PrepareArguments(assemblyAbsolutePath, string.Empty, string.Empty, this.FrameworkArgValue, resultsDirectory: tempDir.Path); + var assemblyAbsolutePath = _testEnvironment.GetTestAsset("CUITTestProject.dll", "net451"); + using var tempDir = new TempDirectory(); + var arguments = PrepareArguments(assemblyAbsolutePath, string.Empty, string.Empty, FrameworkArgValue, resultsDirectory: tempDir.Path); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 0, 0); - } + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 0, 0); } } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/CodeCoverageAcceptanceTestBase.cs b/test/Microsoft.TestPlatform.AcceptanceTests/CodeCoverageAcceptanceTestBase.cs index f133e5c2ca..b1c8e1a6df 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/CodeCoverageAcceptanceTestBase.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/CodeCoverageAcceptanceTestBase.cs @@ -1,137 +1,135 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using System; - using System.Diagnostics; - using System.IO; - using System.Xml; +namespace Microsoft.TestPlatform.AcceptanceTests; + +using System; +using System.Diagnostics; +using System.IO; +using System.Xml; + +using TestUtilities; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using VisualStudio.TestTools.UnitTesting; - public class CodeCoverageAcceptanceTestBase : AcceptanceTestBase +public class CodeCoverageAcceptanceTestBase : AcceptanceTestBase +{ + /* + * Below value is just safe coverage result for which all tests are passing. + * Inspecting this value gives us confidence that there is no big drop in overall coverage. + */ + protected const double ExpectedMinimalModuleCoverage = 30.0; + + protected string GetNetStandardAdapterPath() { - /* - * Below value is just safe coverage result for which all tests are passing. - * Inspecting this value gives us confidence that there is no big drop in overall coverage. - */ - protected const double ExpectedMinimalModuleCoverage = 30.0; + return Path.Combine(IntegrationTestEnvironment.TestPlatformRootDirectory, "artifacts", IntegrationTestEnvironment.BuildConfiguration, "Microsoft.CodeCoverage"); + } - protected string GetNetStandardAdapterPath() - { - return Path.Combine(IntegrationTestEnvironment.TestPlatformRootDirectory, "artifacts", IntegrationTestEnvironment.BuildConfiguration, "Microsoft.CodeCoverage"); - } + protected string GetNetFrameworkAdapterPath() + { + return Path.Combine(IntegrationTestEnvironment.TestPlatformRootDirectory, "artifacts", IntegrationTestEnvironment.BuildConfiguration, "net451", "win7-x64", "Extensions"); + } - protected string GetNetFrameworkAdapterPath() - { - return Path.Combine(IntegrationTestEnvironment.TestPlatformRootDirectory, "artifacts", IntegrationTestEnvironment.BuildConfiguration, "net451", "win7-x64", "Extensions"); - } + protected string GetCodeCoverageExePath() + { + return Path.Combine(GetNetStandardAdapterPath(), "CodeCoverage", "CodeCoverage.exe"); + } - protected string GetCodeCoverageExePath() - { - return Path.Combine(this.GetNetStandardAdapterPath(), "CodeCoverage", "CodeCoverage.exe"); - } + protected XmlNode GetModuleNode(XmlNode node, string name) + { + var moduleNode = GetNode(node, "module", name); - protected XmlNode GetModuleNode(XmlNode node, string name) + if (moduleNode == null) { - var moduleNode = this.GetNode(node, "module", name); + moduleNode = GetNode(node, "package", name); if (moduleNode == null) { - moduleNode = this.GetNode(node, "package", name); - - if (moduleNode == null) - { - moduleNode = this.GetNode(node, "package", Path.GetFileNameWithoutExtension(name)); - } + moduleNode = GetNode(node, "package", Path.GetFileNameWithoutExtension(name)); } - - return moduleNode; } - protected XmlNode GetNode(XmlNode node, string type, string name) - { - return node.SelectSingleNode($"//{type}[@name='{name}']"); - } + return moduleNode; + } - protected XmlDocument GetXmlCoverage(string coverageResult, TempDirectory tempDirectory) - { - XmlDocument coverage = new XmlDocument(); + protected XmlNode GetNode(XmlNode node, string type, string name) + { + return node.SelectSingleNode($"//{type}[@name='{name}']"); + } - if (coverageResult.EndsWith(".xml", StringComparison.OrdinalIgnoreCase)) - { - coverage.Load(coverageResult); - return coverage; - } + protected XmlDocument GetXmlCoverage(string coverageResult, TempDirectory tempDirectory) + { + var coverage = new XmlDocument(); - var codeCoverageExe = this.GetCodeCoverageExePath(); - var output = Path.Combine(tempDirectory.Path, Guid.NewGuid().ToString() + ".xml"); + if (coverageResult.EndsWith(".xml", StringComparison.OrdinalIgnoreCase)) + { + coverage.Load(coverageResult); + return coverage; + } - var watch = new Stopwatch(); + var codeCoverageExe = GetCodeCoverageExePath(); + var output = Path.Combine(tempDirectory.Path, Guid.NewGuid().ToString() + ".xml"); - Console.WriteLine($"Starting {codeCoverageExe}"); - watch.Start(); - var analyze = Process.Start(new ProcessStartInfo - { - FileName = codeCoverageExe, - Arguments = $"analyze /include_skipped_functions /include_skipped_modules /output:\"{output}\" \"{coverageResult}\"", - RedirectStandardOutput = true, - UseShellExecute = false - }); + var watch = new Stopwatch(); - string analysisOutput = analyze.StandardOutput.ReadToEnd(); + Console.WriteLine($"Starting {codeCoverageExe}"); + watch.Start(); + var analyze = Process.Start(new ProcessStartInfo + { + FileName = codeCoverageExe, + Arguments = $"analyze /include_skipped_functions /include_skipped_modules /output:\"{output}\" \"{coverageResult}\"", + RedirectStandardOutput = true, + UseShellExecute = false + }); - analyze.WaitForExit(); - watch.Stop(); - Console.WriteLine($"Total execution time: {watch.Elapsed.Duration()}"); + string analysisOutput = analyze.StandardOutput.ReadToEnd(); - Assert.IsTrue(0 == analyze.ExitCode, $"Code Coverage analyze failed: {analysisOutput}"); + analyze.WaitForExit(); + watch.Stop(); + Console.WriteLine($"Total execution time: {watch.Elapsed.Duration()}"); - coverage.Load(output); - return coverage; - } + Assert.IsTrue(0 == analyze.ExitCode, $"Code Coverage analyze failed: {analysisOutput}"); - protected void AssertCoverage(XmlNode node, double expectedCoverage) - { - var coverage = node.Attributes["block_coverage"] != null - ? double.Parse(node.Attributes["block_coverage"].Value) - : double.Parse(node.Attributes["line-rate"].Value) * 100; - Console.WriteLine($"Checking coverage for {node.Name} {node.Attributes["name"].Value}. Expected at least: {expectedCoverage}. Result: {coverage}"); - Assert.IsTrue(coverage > expectedCoverage, $"Coverage check failed for {node.Name} {node.Attributes["name"].Value}. Expected at least: {expectedCoverage}. Found: {coverage}"); - } + coverage.Load(output); + return coverage; + } - protected static string GetCoverageFileNameFromTrx(string trxFilePath, string resultsDirectory) + protected void AssertCoverage(XmlNode node, double expectedCoverage) + { + var coverage = node.Attributes["block_coverage"] != null + ? double.Parse(node.Attributes["block_coverage"].Value) + : double.Parse(node.Attributes["line-rate"].Value) * 100; + Console.WriteLine($"Checking coverage for {node.Name} {node.Attributes["name"].Value}. Expected at least: {expectedCoverage}. Result: {coverage}"); + Assert.IsTrue(coverage > expectedCoverage, $"Coverage check failed for {node.Name} {node.Attributes["name"].Value}. Expected at least: {expectedCoverage}. Found: {coverage}"); + } + + protected static string GetCoverageFileNameFromTrx(string trxFilePath, string resultsDirectory) + { + Assert.IsTrue(File.Exists(trxFilePath), "Trx file not found: {0}", trxFilePath); + XmlDocument doc = new(); + using var trxStream = new FileStream(trxFilePath, FileMode.Open, FileAccess.Read); + doc.Load(trxStream); + var deploymentElements = doc.GetElementsByTagName("Deployment"); + Assert.IsTrue(deploymentElements.Count == 1, + "None or more than one Deployment tags found in trx file:{0}", trxFilePath); + var deploymentDir = deploymentElements[0].Attributes.GetNamedItem("runDeploymentRoot")?.Value; + Assert.IsTrue(string.IsNullOrEmpty(deploymentDir) == false, + "runDeploymentRoot attribute not found in trx file:{0}", trxFilePath); + var collectors = doc.GetElementsByTagName("Collector"); + + string fileName = string.Empty; + for (int i = 0; i < collectors.Count; i++) { - Assert.IsTrue(File.Exists(trxFilePath), "Trx file not found: {0}", trxFilePath); - XmlDocument doc = new XmlDocument(); - using (var trxStream = new FileStream(trxFilePath, FileMode.Open, FileAccess.Read)) + if (string.Equals(collectors[i].Attributes.GetNamedItem("collectorDisplayName").Value, + "Code Coverage", StringComparison.OrdinalIgnoreCase)) { - doc.Load(trxStream); - var deploymentElements = doc.GetElementsByTagName("Deployment"); - Assert.IsTrue(deploymentElements.Count == 1, - "None or more than one Deployment tags found in trx file:{0}", trxFilePath); - var deploymentDir = deploymentElements[0].Attributes.GetNamedItem("runDeploymentRoot")?.Value; - Assert.IsTrue(string.IsNullOrEmpty(deploymentDir) == false, - "runDeploymentRoot attribute not found in trx file:{0}", trxFilePath); - var collectors = doc.GetElementsByTagName("Collector"); - - string fileName = string.Empty; - for (int i = 0; i < collectors.Count; i++) - { - if (string.Equals(collectors[i].Attributes.GetNamedItem("collectorDisplayName").Value, - "Code Coverage", StringComparison.OrdinalIgnoreCase)) - { - fileName = collectors[i].FirstChild?.FirstChild?.FirstChild?.Attributes.GetNamedItem("href") - ?.Value; - } - } - - Assert.IsTrue(string.IsNullOrEmpty(fileName) == false, "Coverage file name not found in trx file: {0}", - trxFilePath); - return Path.Combine(resultsDirectory, deploymentDir, "In", fileName); + fileName = collectors[i].FirstChild?.FirstChild?.FirstChild?.Attributes.GetNamedItem("href") + ?.Value; } } + + Assert.IsTrue(string.IsNullOrEmpty(fileName) == false, "Coverage file name not found in trx file: {0}", + trxFilePath); + return Path.Combine(resultsDirectory, deploymentDir, "In", fileName); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/CodeCoverageTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/CodeCoverageTests.cs index 3b467f1d14..3121773844 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/CodeCoverageTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/CodeCoverageTests.cs @@ -1,361 +1,361 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using System; - using System.IO; - using System.Xml; +namespace Microsoft.TestPlatform.AcceptanceTests; + +using System; +using System.IO; +using System.Xml; + +using TestUtilities; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using VisualStudio.TestTools.UnitTesting; - internal struct TestParameters +internal struct TestParameters +{ + public enum SettingsType { - public enum SettingsType - { - None = 0, - Default = 1, - Custom = 2, - XmlOutput = 3, - CoberturaOutput = 4 - } + None = 0, + Default = 1, + Custom = 2, + XmlOutput = 3, + CoberturaOutput = 4 + } - public string AssemblyName { get; set; } + public string AssemblyName { get; set; } - public string TargetPlatform { get; set; } + public string TargetPlatform { get; set; } - public SettingsType RunSettingsType { get; set; } + public SettingsType RunSettingsType { get; set; } - public string RunSettingsPath { get; set; } + public string RunSettingsPath { get; set; } - public int ExpectedPassedTests { get; set; } + public int ExpectedPassedTests { get; set; } - public int ExpectedSkippedTests { get; set; } + public int ExpectedSkippedTests { get; set; } - public int ExpectedFailedTests { get; set; } + public int ExpectedFailedTests { get; set; } - public bool CheckSkipped { get; set; } - } + public bool CheckSkipped { get; set; } +} - [TestClass] - //Code coverage only supported on windows (based on the message in output) - [TestCategory("Windows-Review")] - public class CodeCoverageTests : CodeCoverageAcceptanceTestBase +[TestClass] +//Code coverage only supported on windows (based on the message in output) +[TestCategory("Windows-Review")] +public class CodeCoverageTests : CodeCoverageAcceptanceTestBase +{ + [TestMethod] + [NetFullTargetFrameworkDataSource(useDesktopRunner: false)] + [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] + public void CollectCodeCoverageWithCollectOptionForx86(RunnerInfo runnerInfo) { - [TestMethod] - [NetFullTargetFrameworkDataSource(useDesktopRunner: false)] - [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] - public void CollectCodeCoverageWithCollectOptionForx86(RunnerInfo runnerInfo) + var parameters = new TestParameters() { - var parameters = new TestParameters() - { - AssemblyName = "SimpleTestProject.dll", - TargetPlatform = "x86", - RunSettingsPath = string.Empty, - RunSettingsType = TestParameters.SettingsType.None, - ExpectedPassedTests = 1, - ExpectedSkippedTests = 1, - ExpectedFailedTests = 1 - }; - - this.CollectCodeCoverage(runnerInfo, parameters); - } + AssemblyName = "SimpleTestProject.dll", + TargetPlatform = "x86", + RunSettingsPath = string.Empty, + RunSettingsType = TestParameters.SettingsType.None, + ExpectedPassedTests = 1, + ExpectedSkippedTests = 1, + ExpectedFailedTests = 1 + }; + + CollectCodeCoverage(runnerInfo, parameters); + } - [TestMethod] - [NetFullTargetFrameworkDataSource(useDesktopRunner: false)] - [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] - public void CollectCodeCoverageWithCollectOptionForx64(RunnerInfo runnerInfo) + [TestMethod] + [NetFullTargetFrameworkDataSource(useDesktopRunner: false)] + [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] + public void CollectCodeCoverageWithCollectOptionForx64(RunnerInfo runnerInfo) + { + var parameters = new TestParameters() { - var parameters = new TestParameters() - { - AssemblyName = "SimpleTestProject.dll", - TargetPlatform = "x64", - RunSettingsPath = string.Empty, - RunSettingsType = TestParameters.SettingsType.None, - ExpectedPassedTests = 1, - ExpectedSkippedTests = 1, - ExpectedFailedTests = 1 - }; - - this.CollectCodeCoverage(runnerInfo, parameters); - } + AssemblyName = "SimpleTestProject.dll", + TargetPlatform = "x64", + RunSettingsPath = string.Empty, + RunSettingsType = TestParameters.SettingsType.None, + ExpectedPassedTests = 1, + ExpectedSkippedTests = 1, + ExpectedFailedTests = 1 + }; + + CollectCodeCoverage(runnerInfo, parameters); + } - [TestMethod] - [NetFullTargetFrameworkDataSource(useDesktopRunner: false)] - [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] - public void CollectCodeCoverageX86WithRunSettings(RunnerInfo runnerInfo) + [TestMethod] + [NetFullTargetFrameworkDataSource(useDesktopRunner: false)] + [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] + public void CollectCodeCoverageX86WithRunSettings(RunnerInfo runnerInfo) + { + var parameters = new TestParameters() { - var parameters = new TestParameters() - { - AssemblyName = "SimpleTestProject.dll", - TargetPlatform = "x86", - RunSettingsPath = string.Empty, - RunSettingsType = TestParameters.SettingsType.Default, - ExpectedPassedTests = 1, - ExpectedSkippedTests = 1, - ExpectedFailedTests = 1 - }; - - this.CollectCodeCoverage(runnerInfo, parameters); - } + AssemblyName = "SimpleTestProject.dll", + TargetPlatform = "x86", + RunSettingsPath = string.Empty, + RunSettingsType = TestParameters.SettingsType.Default, + ExpectedPassedTests = 1, + ExpectedSkippedTests = 1, + ExpectedFailedTests = 1 + }; + + CollectCodeCoverage(runnerInfo, parameters); + } - [TestMethod] - [NetFullTargetFrameworkDataSource(useDesktopRunner: false)] - [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] - public void CollectCodeCoverageX64WithRunSettings(RunnerInfo runnerInfo) + [TestMethod] + [NetFullTargetFrameworkDataSource(useDesktopRunner: false)] + [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] + public void CollectCodeCoverageX64WithRunSettings(RunnerInfo runnerInfo) + { + var parameters = new TestParameters() { - var parameters = new TestParameters() - { - AssemblyName = "SimpleTestProject.dll", - TargetPlatform = "x64", - RunSettingsPath = string.Empty, - RunSettingsType = TestParameters.SettingsType.Default, - ExpectedPassedTests = 1, - ExpectedSkippedTests = 1, - ExpectedFailedTests = 1 - }; - - this.CollectCodeCoverage(runnerInfo, parameters); - } + AssemblyName = "SimpleTestProject.dll", + TargetPlatform = "x64", + RunSettingsPath = string.Empty, + RunSettingsType = TestParameters.SettingsType.Default, + ExpectedPassedTests = 1, + ExpectedSkippedTests = 1, + ExpectedFailedTests = 1 + }; + + CollectCodeCoverage(runnerInfo, parameters); + } - [TestMethod] - [NetFullTargetFrameworkDataSource(useDesktopRunner: false)] - [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] - public void CodeCoverageShouldAvoidExclusionsX86(RunnerInfo runnerInfo) + [TestMethod] + [NetFullTargetFrameworkDataSource(useDesktopRunner: false)] + [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] + public void CodeCoverageShouldAvoidExclusionsX86(RunnerInfo runnerInfo) + { + var parameters = new TestParameters() { - var parameters = new TestParameters() - { - AssemblyName = "CodeCoverageTest.dll", - TargetPlatform = "x86", - RunSettingsPath = Path.Combine( - IntegrationTestEnvironment.TestPlatformRootDirectory, - @"scripts", "vstest-codecoverage2.runsettings"), - RunSettingsType = TestParameters.SettingsType.Custom, - ExpectedPassedTests = 3, - ExpectedSkippedTests = 0, - ExpectedFailedTests = 0, - CheckSkipped = true - }; - - this.CollectCodeCoverage(runnerInfo, parameters); - } + AssemblyName = "CodeCoverageTest.dll", + TargetPlatform = "x86", + RunSettingsPath = Path.Combine( + IntegrationTestEnvironment.TestPlatformRootDirectory, + @"scripts", "vstest-codecoverage2.runsettings"), + RunSettingsType = TestParameters.SettingsType.Custom, + ExpectedPassedTests = 3, + ExpectedSkippedTests = 0, + ExpectedFailedTests = 0, + CheckSkipped = true + }; + + CollectCodeCoverage(runnerInfo, parameters); + } - [TestMethod] - [NetFullTargetFrameworkDataSource(useDesktopRunner: false)] - [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] - public void CodeCoverageShouldAvoidExclusionsX64(RunnerInfo runnerInfo) + [TestMethod] + [NetFullTargetFrameworkDataSource(useDesktopRunner: false)] + [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] + public void CodeCoverageShouldAvoidExclusionsX64(RunnerInfo runnerInfo) + { + var parameters = new TestParameters() { - var parameters = new TestParameters() - { - AssemblyName = "CodeCoverageTest.dll", - TargetPlatform = "x64", - RunSettingsPath = Path.Combine( - IntegrationTestEnvironment.TestPlatformRootDirectory, - @"scripts", "vstest-codecoverage2.runsettings"), - RunSettingsType = TestParameters.SettingsType.Custom, - ExpectedPassedTests = 3, - ExpectedSkippedTests = 0, - ExpectedFailedTests = 0, - CheckSkipped = true - }; - - this.CollectCodeCoverage(runnerInfo, parameters); - } + AssemblyName = "CodeCoverageTest.dll", + TargetPlatform = "x64", + RunSettingsPath = Path.Combine( + IntegrationTestEnvironment.TestPlatformRootDirectory, + @"scripts", "vstest-codecoverage2.runsettings"), + RunSettingsType = TestParameters.SettingsType.Custom, + ExpectedPassedTests = 3, + ExpectedSkippedTests = 0, + ExpectedFailedTests = 0, + CheckSkipped = true + }; + + CollectCodeCoverage(runnerInfo, parameters); + } - [TestMethod] - [NetFullTargetFrameworkDataSource(useDesktopRunner: false)] - [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] - public void CollectCodeCoverageSpecifyOutputFormatXml(RunnerInfo runnerInfo) + [TestMethod] + [NetFullTargetFrameworkDataSource(useDesktopRunner: false)] + [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] + public void CollectCodeCoverageSpecifyOutputFormatXml(RunnerInfo runnerInfo) + { + var parameters = new TestParameters() { - var parameters = new TestParameters() - { - AssemblyName = "SimpleTestProject.dll", - TargetPlatform = "x64", - RunSettingsPath = string.Empty, - RunSettingsType = TestParameters.SettingsType.XmlOutput, - ExpectedPassedTests = 1, - ExpectedSkippedTests = 1, - ExpectedFailedTests = 1 - }; - - this.CollectCodeCoverage(runnerInfo, parameters); - } + AssemblyName = "SimpleTestProject.dll", + TargetPlatform = "x64", + RunSettingsPath = string.Empty, + RunSettingsType = TestParameters.SettingsType.XmlOutput, + ExpectedPassedTests = 1, + ExpectedSkippedTests = 1, + ExpectedFailedTests = 1 + }; + + CollectCodeCoverage(runnerInfo, parameters); + } - [TestMethod] - [NetFullTargetFrameworkDataSource(useDesktopRunner: false)] - [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] - public void CollectCodeCoverageSpecifyOutputFormatCoberturaOverrideRunSettingsConfiguration(RunnerInfo runnerInfo) + [TestMethod] + [NetFullTargetFrameworkDataSource(useDesktopRunner: false)] + [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] + public void CollectCodeCoverageSpecifyOutputFormatCoberturaOverrideRunSettingsConfiguration(RunnerInfo runnerInfo) + { + var parameters = new TestParameters() { - var parameters = new TestParameters() - { - AssemblyName = "SimpleTestProject.dll", - TargetPlatform = "x64", - RunSettingsPath = Path.Combine( - IntegrationTestEnvironment.TestPlatformRootDirectory, - @"scripts", "vstest-codecoverage2.runsettings"), - RunSettingsType = TestParameters.SettingsType.CoberturaOutput, - ExpectedPassedTests = 1, - ExpectedSkippedTests = 1, - ExpectedFailedTests = 1 - }; - - this.CollectCodeCoverage(runnerInfo, parameters); - } + AssemblyName = "SimpleTestProject.dll", + TargetPlatform = "x64", + RunSettingsPath = Path.Combine( + IntegrationTestEnvironment.TestPlatformRootDirectory, + @"scripts", "vstest-codecoverage2.runsettings"), + RunSettingsType = TestParameters.SettingsType.CoberturaOutput, + ExpectedPassedTests = 1, + ExpectedSkippedTests = 1, + ExpectedFailedTests = 1 + }; + + CollectCodeCoverage(runnerInfo, parameters); + } - private void CollectCodeCoverage(RunnerInfo runnerInfo, TestParameters testParameters) - { - using var tempDir = new TempDirectory(); - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + private void CollectCodeCoverage(RunnerInfo runnerInfo, TestParameters testParameters) + { + using var tempDir = new TempDirectory(); + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); - var arguments = this.CreateArguments(tempDir, runnerInfo, testParameters, out var trxFilePath); + var arguments = CreateArguments(tempDir, runnerInfo, testParameters, out var trxFilePath); - this.InvokeVsTest(arguments); + InvokeVsTest(arguments); - this.ValidateSummaryStatus( - testParameters.ExpectedPassedTests, - testParameters.ExpectedSkippedTests, - testParameters.ExpectedFailedTests); + ValidateSummaryStatus( + testParameters.ExpectedPassedTests, + testParameters.ExpectedSkippedTests, + testParameters.ExpectedFailedTests); - var actualCoverageFile = CodeCoverageTests.GetCoverageFileNameFromTrx(trxFilePath, tempDir.Path); - Console.WriteLine($@"Coverage file: {actualCoverageFile} Results directory: {tempDir.Path} trxfile: {trxFilePath}"); - Assert.IsTrue(File.Exists(actualCoverageFile), "Coverage file not found: {0}", actualCoverageFile); + var actualCoverageFile = CodeCoverageTests.GetCoverageFileNameFromTrx(trxFilePath, tempDir.Path); + Console.WriteLine($@"Coverage file: {actualCoverageFile} Results directory: {tempDir.Path} trxfile: {trxFilePath}"); + Assert.IsTrue(File.Exists(actualCoverageFile), "Coverage file not found: {0}", actualCoverageFile); - if (testParameters.RunSettingsType == TestParameters.SettingsType.XmlOutput) - { - Assert.IsTrue(actualCoverageFile.EndsWith(".xml", StringComparison.InvariantCultureIgnoreCase)); - } - else if (testParameters.RunSettingsType == TestParameters.SettingsType.CoberturaOutput) - { - Assert.IsTrue(actualCoverageFile.EndsWith(".cobertura.xml", StringComparison.InvariantCultureIgnoreCase)); - } - else - { - Assert.IsTrue(actualCoverageFile.EndsWith(".coverage", StringComparison.InvariantCultureIgnoreCase)); - } - - var coverageDocument = this.GetXmlCoverage(actualCoverageFile, tempDir); - if (testParameters.CheckSkipped) - { - this.AssertSkippedMethod(coverageDocument); - } - - this.ValidateCoverageData(coverageDocument, testParameters.AssemblyName, testParameters.RunSettingsType != TestParameters.SettingsType.CoberturaOutput); + if (testParameters.RunSettingsType == TestParameters.SettingsType.XmlOutput) + { + Assert.IsTrue(actualCoverageFile.EndsWith(".xml", StringComparison.InvariantCultureIgnoreCase)); + } + else if (testParameters.RunSettingsType == TestParameters.SettingsType.CoberturaOutput) + { + Assert.IsTrue(actualCoverageFile.EndsWith(".cobertura.xml", StringComparison.InvariantCultureIgnoreCase)); + } + else + { + Assert.IsTrue(actualCoverageFile.EndsWith(".coverage", StringComparison.InvariantCultureIgnoreCase)); } - private string CreateArguments( - TempDirectory tempDir, - RunnerInfo runnerInfo, - TestParameters testParameters, - out string trxFilePath) + var coverageDocument = GetXmlCoverage(actualCoverageFile, tempDir); + if (testParameters.CheckSkipped) { - var assemblyPaths = this.GetAssetFullPath(testParameters.AssemblyName); + AssertSkippedMethod(coverageDocument); + } - string traceDataCollectorDir = Path.Combine(IntegrationTestEnvironment.TestPlatformRootDirectory, - "artifacts", IntegrationTestEnvironment.BuildConfiguration, "Microsoft.CodeCoverage"); + ValidateCoverageData(coverageDocument, testParameters.AssemblyName, testParameters.RunSettingsType != TestParameters.SettingsType.CoberturaOutput); + } - string diagFileName = Path.Combine(tempDir.Path, "diaglog.txt"); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, - this.FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); - arguments = string.Concat(arguments, $" /Diag:{diagFileName}", - $" /TestAdapterPath:{traceDataCollectorDir}"); - arguments = string.Concat(arguments, $" /Platform:{testParameters.TargetPlatform}"); + private string CreateArguments( + TempDirectory tempDir, + RunnerInfo runnerInfo, + TestParameters testParameters, + out string trxFilePath) + { + var assemblyPaths = GetAssetFullPath(testParameters.AssemblyName); - trxFilePath = Path.Combine(tempDir.Path, Guid.NewGuid() + ".trx"); - arguments = string.Concat(arguments, " /logger:trx;logfilename=" + trxFilePath); + string traceDataCollectorDir = Path.Combine(IntegrationTestEnvironment.TestPlatformRootDirectory, + "artifacts", IntegrationTestEnvironment.BuildConfiguration, "Microsoft.CodeCoverage"); - var defaultRunSettingsPath = Path.Combine( - IntegrationTestEnvironment.TestPlatformRootDirectory, - @"scripts", "vstest-codecoverage.runsettings"); + string diagFileName = Path.Combine(tempDir.Path, "diaglog.txt"); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, + FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); + arguments = string.Concat(arguments, $" /Diag:{diagFileName}", + $" /TestAdapterPath:{traceDataCollectorDir}"); + arguments = string.Concat(arguments, $" /Platform:{testParameters.TargetPlatform}"); - var runSettings = string.Empty; - switch (testParameters.RunSettingsType) - { - case TestParameters.SettingsType.None: - runSettings = $" /collect:\"Code Coverage\""; - break; - case TestParameters.SettingsType.Default: - runSettings = $" /settings:{defaultRunSettingsPath}"; - break; - case TestParameters.SettingsType.Custom: - runSettings = $" /settings:{testParameters.RunSettingsPath}"; - break; - case TestParameters.SettingsType.XmlOutput: - runSettings = $" /collect:\"Code Coverage;Format=Xml\""; - if (!string.IsNullOrWhiteSpace(testParameters.RunSettingsPath)) - { - runSettings += $" /settings:{testParameters.RunSettingsPath}"; - } - break; - case TestParameters.SettingsType.CoberturaOutput: - runSettings = $" /collect:\"Code Coverage;Format=Cobertura\""; - if (!string.IsNullOrWhiteSpace(testParameters.RunSettingsPath)) - { - runSettings += $" /settings:{testParameters.RunSettingsPath}"; - } - break; - } + trxFilePath = Path.Combine(tempDir.Path, Guid.NewGuid() + ".trx"); + arguments = string.Concat(arguments, " /logger:trx;logfilename=" + trxFilePath); - arguments = string.Concat(arguments, runSettings); + var defaultRunSettingsPath = Path.Combine( + IntegrationTestEnvironment.TestPlatformRootDirectory, + @"scripts", "vstest-codecoverage.runsettings"); - return arguments; + var runSettings = string.Empty; + switch (testParameters.RunSettingsType) + { + case TestParameters.SettingsType.None: + runSettings = $" /collect:\"Code Coverage\""; + break; + case TestParameters.SettingsType.Default: + runSettings = $" /settings:{defaultRunSettingsPath}"; + break; + case TestParameters.SettingsType.Custom: + runSettings = $" /settings:{testParameters.RunSettingsPath}"; + break; + case TestParameters.SettingsType.XmlOutput: + runSettings = $" /collect:\"Code Coverage;Format=Xml\""; + if (!string.IsNullOrWhiteSpace(testParameters.RunSettingsPath)) + { + runSettings += $" /settings:{testParameters.RunSettingsPath}"; + } + break; + case TestParameters.SettingsType.CoberturaOutput: + runSettings = $" /collect:\"Code Coverage;Format=Cobertura\""; + if (!string.IsNullOrWhiteSpace(testParameters.RunSettingsPath)) + { + runSettings += $" /settings:{testParameters.RunSettingsPath}"; + } + break; } - private void AssertSkippedMethod(XmlDocument document) - { - var module = this.GetModuleNode(document.DocumentElement, "codecoveragetest.dll"); - Assert.IsNotNull(module); + arguments = string.Concat(arguments, runSettings); - var coverage = double.Parse(module.Attributes["block_coverage"].Value); - Assert.IsTrue(coverage > CodeCoverageAcceptanceTestBase.ExpectedMinimalModuleCoverage); + return arguments; + } - var testSignFunction = this.GetNode(module, "skipped_function", "TestSign()"); - Assert.IsNotNull(testSignFunction); - Assert.AreEqual("name_excluded", testSignFunction.Attributes["reason"].Value); + private void AssertSkippedMethod(XmlDocument document) + { + var module = GetModuleNode(document.DocumentElement, "codecoveragetest.dll"); + Assert.IsNotNull(module); - var skippedTestMethod = this.GetNode(module, "skipped_function", "__CxxPureMSILEntry_Test()"); - Assert.IsNotNull(skippedTestMethod); - Assert.AreEqual("name_excluded", skippedTestMethod.Attributes["reason"].Value); + var coverage = double.Parse(module.Attributes["block_coverage"].Value); + Assert.IsTrue(coverage > ExpectedMinimalModuleCoverage); - var testAbsFunction = this.GetNode(module, "function", "TestAbs()"); - Assert.IsNotNull(testAbsFunction); - } + var testSignFunction = GetNode(module, "skipped_function", "TestSign()"); + Assert.IsNotNull(testSignFunction); + Assert.AreEqual("name_excluded", testSignFunction.Attributes["reason"].Value); - private void ValidateCoverageData(XmlDocument document, string moduleName, bool validateSourceFileNames) - { - var module = this.GetModuleNode(document.DocumentElement, moduleName.ToLower()); + var skippedTestMethod = GetNode(module, "skipped_function", "__CxxPureMSILEntry_Test()"); + Assert.IsNotNull(skippedTestMethod); + Assert.AreEqual("name_excluded", skippedTestMethod.Attributes["reason"].Value); - if (module == null) - { - module = this.GetModuleNode(document.DocumentElement, moduleName); - } - Assert.IsNotNull(module); + var testAbsFunction = GetNode(module, "function", "TestAbs()"); + Assert.IsNotNull(testAbsFunction); + } - this.AssertCoverage(module, CodeCoverageAcceptanceTestBase.ExpectedMinimalModuleCoverage); + private void ValidateCoverageData(XmlDocument document, string moduleName, bool validateSourceFileNames) + { + var module = GetModuleNode(document.DocumentElement, moduleName.ToLower()); - // In case of cobertura report. Cobertura report has different format. - if (validateSourceFileNames) - { - this.AssertSourceFileName(module); - } + if (module == null) + { + module = GetModuleNode(document.DocumentElement, moduleName); } + Assert.IsNotNull(module); + + AssertCoverage(module, ExpectedMinimalModuleCoverage); - private void AssertSourceFileName(XmlNode module) + // In case of cobertura report. Cobertura report has different format. + if (validateSourceFileNames) { - const string ExpectedFileName = "UnitTest1.cs"; + AssertSourceFileName(module); + } + } + + private void AssertSourceFileName(XmlNode module) + { + const string expectedFileName = "UnitTest1.cs"; - var found = false; - var sourcesNode = module.SelectSingleNode("./source_files"); - foreach (XmlNode node in sourcesNode.ChildNodes) + var found = false; + var sourcesNode = module.SelectSingleNode("./source_files"); + foreach (XmlNode node in sourcesNode.ChildNodes) + { + if (node.Attributes["path"].Value.Contains(expectedFileName)) { - if (node.Attributes["path"].Value.Contains(ExpectedFileName)) - { - found = true; - break; - } + found = true; + break; } - - Assert.IsTrue(found); } + + Assert.IsTrue(found); } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/DataCollectionTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/DataCollectionTests.cs index 13bdd4351b..54f6867356 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/DataCollectionTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/DataCollectionTests.cs @@ -1,265 +1,264 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests +namespace Microsoft.TestPlatform.AcceptanceTests; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using System.Xml; +using System.Xml.Linq; + +using TestUtilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class DataCollectionTests : AcceptanceTestBase { - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Text.RegularExpressions; - using System.Xml; - using System.Xml.Linq; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class DataCollectionTests : AcceptanceTestBase + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void ExecuteTestsWithDataCollection(RunnerInfo runnerInfo) { - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void ExecuteTestsWithDataCollection(RunnerInfo runnerInfo) + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); + string runSettings = GetRunsettingsFilePath(tempDir.Path); + string diagFileName = Path.Combine(tempDir.Path, "diaglog.txt"); + var extensionsPath = Path.Combine( + _testEnvironment.TestAssetsPath, + Path.GetFileNameWithoutExtension("OutOfProcDataCollector"), + "bin", + IntegrationTestEnvironment.BuildConfiguration, + _testEnvironment.RunnerFramework); + var arguments = PrepareArguments(assemblyPaths, null, runSettings, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, $" /Diag:{diagFileName}", $" /TestAdapterPath:{extensionsPath}"); + + var env = new Dictionary { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); - string runSettings = this.GetRunsettingsFilePath(tempDir.Path); - string diagFileName = Path.Combine(tempDir.Path, "diaglog.txt"); - var extensionsPath = Path.Combine( - this.testEnvironment.TestAssetsPath, - Path.GetFileNameWithoutExtension("OutOfProcDataCollector"), - "bin", - IntegrationTestEnvironment.BuildConfiguration, - this.testEnvironment.RunnerFramework); - var arguments = PrepareArguments(assemblyPaths, null, runSettings, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, $" /Diag:{diagFileName}", $" /TestAdapterPath:{extensionsPath}"); - - var env = new Dictionary - { - ["TEST_ASSET_SAMPLE_COLLECTOR_PATH"] = tempDir.Path, - }; + ["TEST_ASSET_SAMPLE_COLLECTOR_PATH"] = tempDir.Path, + }; - this.InvokeVsTest(arguments, env); + InvokeVsTest(arguments, env); - this.ValidateSummaryStatus(1, 1, 1); - this.VaildateDataCollectorOutput(tempDir.Path); - } + ValidateSummaryStatus(1, 1, 1); + VaildateDataCollectorOutput(tempDir.Path); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void ExecuteTestsWithDataCollectionUsingCollectArgument(RunnerInfo runnerInfo) + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void ExecuteTestsWithDataCollectionUsingCollectArgument(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + + using var tempDir = new TempDirectory(); + var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); + string diagFileName = Path.Combine(tempDir.Path, "diaglog.txt"); + var extensionsPath = Path.Combine( + _testEnvironment.TestAssetsPath, + Path.GetFileNameWithoutExtension("OutOfProcDataCollector"), + "bin", + IntegrationTestEnvironment.BuildConfiguration, + _testEnvironment.RunnerFramework); + + var arguments = PrepareArguments(assemblyPaths, null, null, FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); + arguments = string.Concat(arguments, $" /Diag:{diagFileName}", $" /Collect:SampleDataCollector", $" /TestAdapterPath:{extensionsPath}"); + + var env = new Dictionary { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - - using var tempDir = new TempDirectory(); - var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); - string diagFileName = Path.Combine(tempDir.Path, "diaglog.txt"); - var extensionsPath = Path.Combine( - this.testEnvironment.TestAssetsPath, - Path.GetFileNameWithoutExtension("OutOfProcDataCollector"), - "bin", - IntegrationTestEnvironment.BuildConfiguration, - this.testEnvironment.RunnerFramework); - - var arguments = PrepareArguments(assemblyPaths, null, null, this.FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); - arguments = string.Concat(arguments, $" /Diag:{diagFileName}", $" /Collect:SampleDataCollector", $" /TestAdapterPath:{extensionsPath}"); - - var env = new Dictionary - { - ["TEST_ASSET_SAMPLE_COLLECTOR_PATH"] = tempDir.Path, - }; + ["TEST_ASSET_SAMPLE_COLLECTOR_PATH"] = tempDir.Path, + }; - this.InvokeVsTest(arguments, env); + InvokeVsTest(arguments, env); - this.ValidateSummaryStatus(1, 1, 1); - this.VaildateDataCollectorOutput(tempDir.Path); - } + ValidateSummaryStatus(1, 1, 1); + VaildateDataCollectorOutput(tempDir.Path); + } - [TestMethod] - [NetCoreTargetFrameworkDataSource] - public void DataCollectorAssemblyLoadingShouldNotThrowErrorForNetCore(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + [TestMethod] + [NetCoreTargetFrameworkDataSource] + public void DataCollectorAssemblyLoadingShouldNotThrowErrorForNetCore(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - var arguments = PrepareArguments(GetAssetFullPath("AppDomainGetAssembliesTestProject.dll", "netcoreapp2.1"), string.Empty, string.Empty, this.FrameworkArgValue, resultsDirectory: tempDir.Path); + using var tempDir = new TempDirectory(); + var arguments = PrepareArguments(GetAssetFullPath("AppDomainGetAssembliesTestProject.dll", "netcoreapp2.1"), string.Empty, string.Empty, FrameworkArgValue, resultsDirectory: tempDir.Path); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 0, 0); - } + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 0, 0); + } - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - public void DataCollectorAssemblyLoadingShouldNotThrowErrorForFullFramework(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + public void DataCollectorAssemblyLoadingShouldNotThrowErrorForFullFramework(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - var arguments = PrepareArguments(GetAssetFullPath("AppDomainGetAssembliesTestProject.dll"), string.Empty, string.Empty, this.FrameworkArgValue, resultsDirectory: tempDir.Path); + using var tempDir = new TempDirectory(); + var arguments = PrepareArguments(GetAssetFullPath("AppDomainGetAssembliesTestProject.dll"), string.Empty, string.Empty, FrameworkArgValue, resultsDirectory: tempDir.Path); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 0, 0); - } + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 0, 0); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void DataCollectorAttachmentProcessor(RunnerInfo runnerInfo) + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void DataCollectorAttachmentProcessor(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + + using var tempDir = new TempDirectory(); + var assemblyPath = BuildMultipleAssemblyPath("SimpleTestProject.dll").Trim('\"'); + var secondAssemblyPath = BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); + string runSettings = GetRunsettingsFilePath(tempDir.Path); + string diagFileName = Path.Combine(tempDir.Path, "diaglog.txt"); + var extensionsPath = Path.Combine( + _testEnvironment.TestAssetsPath, + Path.GetFileNameWithoutExtension("AttachmentProcessorDataCollector"), + "bin", + IntegrationTestEnvironment.BuildConfiguration, + "netstandard2.0"); + var arguments = PrepareArguments(new string[] { assemblyPath, secondAssemblyPath }, null, runSettings, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, $" /Diag:{diagFileName}", $" /TestAdapterPath:{extensionsPath}"); + + XElement runSettingsXml = XElement.Load(runSettings); + + // Today we merge only in the case of ParallelProxyExecutionManager executor, that is chosen if: + // (parallelLevel > 1 || !testHostManager.Shared) -> "src\Microsoft.TestPlatform.CrossPlatEngine\TestEngine.cs" line ~248 + // So we'll merge always in case of DotnetTestHostManager(Shared = false) or in case of DefaultTestHostManager(DisableAppDomain = true) or if MaxCpuCount > 1 + // For NetFull test we need to have more than one test library and MaxCpuCount > 1 + runSettingsXml.Add(new XElement("RunConfiguration", new XElement("MaxCpuCount", 2))); + + // Set datacollector parameters + runSettingsXml.Element("DataCollectionRunSettings") + .Element("DataCollectors") + .Element("DataCollector") + .Add(new XElement("Configuration", new XElement("MergeFile", "MergedFile.txt"))); + runSettingsXml.Save(runSettings); + + var env = new Dictionary { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - - using var tempDir = new TempDirectory(); - var assemblyPath = this.BuildMultipleAssemblyPath("SimpleTestProject.dll").Trim('\"'); - var secondAssemblyPath = this.BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); - string runSettings = this.GetRunsettingsFilePath(tempDir.Path); - string diagFileName = Path.Combine(tempDir.Path, "diaglog.txt"); - var extensionsPath = Path.Combine( - this.testEnvironment.TestAssetsPath, - Path.GetFileNameWithoutExtension("AttachmentProcessorDataCollector"), - "bin", - IntegrationTestEnvironment.BuildConfiguration, - "netstandard2.0"); - var arguments = PrepareArguments(new string[] { assemblyPath, secondAssemblyPath }, null, runSettings, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, $" /Diag:{diagFileName}", $" /TestAdapterPath:{extensionsPath}"); - - XElement runSettingsXml = XElement.Load(runSettings); - - // Today we merge only in the case of ParallelProxyExecutionManager executor, that is chosen if: - // (parallelLevel > 1 || !testHostManager.Shared) -> "src\Microsoft.TestPlatform.CrossPlatEngine\TestEngine.cs" line ~248 - // So we'll merge always in case of DotnetTestHostManager(Shared = false) or in case of DefaultTestHostManager(DisableAppDomain = true) or if MaxCpuCount > 1 - // For NetFull test we need to have more than one test library and MaxCpuCount > 1 - runSettingsXml.Add(new XElement("RunConfiguration", new XElement("MaxCpuCount", 2))); - - // Set datacollector parameters - runSettingsXml.Element("DataCollectionRunSettings") - .Element("DataCollectors") - .Element("DataCollector") - .Add(new XElement("Configuration", new XElement("MergeFile", "MergedFile.txt"))); - runSettingsXml.Save(runSettings); - - var env = new Dictionary - { - ["SampleDataCollectorTempPath"] = tempDir.Path, - }; + ["SampleDataCollectorTempPath"] = tempDir.Path, + }; - this.InvokeVsTest(arguments, env); + InvokeVsTest(arguments, env); - this.ValidateSummaryStatus(2, 2, 2); + ValidateSummaryStatus(2, 2, 2); - string mergedFile = Directory.GetFiles(tempDir.Path, "MergedFile.txt", SearchOption.AllDirectories).Single(); - List fileContent = new List(); - using (StreamReader streamReader = new StreamReader(mergedFile)) + string mergedFile = Directory.GetFiles(tempDir.Path, "MergedFile.txt", SearchOption.AllDirectories).Single(); + var fileContent = new List(); + using (var streamReader = new StreamReader(mergedFile)) + { + while (!streamReader.EndOfStream) { - while (!streamReader.EndOfStream) - { - string line = streamReader.ReadLine(); - Assert.IsTrue(line.StartsWith("SessionEnded_Handler_")); - fileContent.Add(line); - } + string line = streamReader.ReadLine(); + Assert.IsTrue(line.StartsWith("SessionEnded_Handler_")); + fileContent.Add(line); } + } - Assert.AreEqual(2, fileContent.Distinct().Count()); + Assert.AreEqual(2, fileContent.Distinct().Count()); - var dataCollectorsLogs = Directory.GetFiles(tempDir.Path, "*.datacollector.*", SearchOption.TopDirectoryOnly); - Assert.AreEqual(2, dataCollectorsLogs.Distinct().Count()); - foreach (var dataCollectorLogFile in dataCollectorsLogs) - { - string dataCollectorLog = File.ReadAllText(dataCollectorLogFile); - Assert.IsTrue(dataCollectorLog.Contains("MetadataReaderExtensionsHelper: Valid extension found: extension type 'DataCollector' identifier 'my://sample/datacollector' implementation 'AttachmentProcessorDataCollector.SampleDataCollectorV1' version '1'")); - Assert.IsTrue(dataCollectorLog.Contains("MetadataReaderExtensionsHelper: Valid extension found: extension type 'DataCollector' identifier 'my://sample/datacollector' implementation 'AttachmentProcessorDataCollector.SampleDataCollectorV2' version '2'")); - Assert.IsTrue(Regex.IsMatch(dataCollectorLog, @"GetTestExtensionFromType: Discovered multiple test extensions with identifier data 'my://sample/datacollector' and type 'AttachmentProcessorDataCollector\.SampleDataCollectorV1, AttachmentProcessorDataCollector, Version=.*, Culture=neutral, PublicKeyToken=null' inside file '.*AttachmentProcessorDataCollector\.dll'; keeping the first one 'AttachmentProcessorDataCollector\.SampleDataCollectorV2, AttachmentProcessorDataCollector, Version=.*, Culture=neutral, PublicKeyToken=null'\.")); - } + var dataCollectorsLogs = Directory.GetFiles(tempDir.Path, "*.datacollector.*", SearchOption.TopDirectoryOnly); + Assert.AreEqual(2, dataCollectorsLogs.Distinct().Count()); + foreach (var dataCollectorLogFile in dataCollectorsLogs) + { + string dataCollectorLog = File.ReadAllText(dataCollectorLogFile); + Assert.IsTrue(dataCollectorLog.Contains("MetadataReaderExtensionsHelper: Valid extension found: extension type 'DataCollector' identifier 'my://sample/datacollector' implementation 'AttachmentProcessorDataCollector.SampleDataCollectorV1' version '1'")); + Assert.IsTrue(dataCollectorLog.Contains("MetadataReaderExtensionsHelper: Valid extension found: extension type 'DataCollector' identifier 'my://sample/datacollector' implementation 'AttachmentProcessorDataCollector.SampleDataCollectorV2' version '2'")); + Assert.IsTrue(Regex.IsMatch(dataCollectorLog, @"GetTestExtensionFromType: Discovered multiple test extensions with identifier data 'my://sample/datacollector' and type 'AttachmentProcessorDataCollector\.SampleDataCollectorV1, AttachmentProcessorDataCollector, Version=.*, Culture=neutral, PublicKeyToken=null' inside file '.*AttachmentProcessorDataCollector\.dll'; keeping the first one 'AttachmentProcessorDataCollector\.SampleDataCollectorV2, AttachmentProcessorDataCollector, Version=.*, Culture=neutral, PublicKeyToken=null'\.")); } + } - private static void CreateDataCollectionRunSettingsFile(string destinationRunsettingsPath, Dictionary dataCollectionAttributes) + private static void CreateDataCollectionRunSettingsFile(string destinationRunsettingsPath, Dictionary dataCollectionAttributes) + { + var doc = new XmlDocument(); + var xmlDeclaration = doc.CreateNode(XmlNodeType.XmlDeclaration, string.Empty, string.Empty); + + doc.AppendChild(xmlDeclaration); + var runSettingsNode = doc.CreateElement(Constants.RunSettingsName); + doc.AppendChild(runSettingsNode); + var dcConfigNode = doc.CreateElement(Constants.DataCollectionRunSettingsName); + runSettingsNode.AppendChild(dcConfigNode); + var dataCollectorsNode = doc.CreateElement(Constants.DataCollectorsSettingName); + dcConfigNode.AppendChild(dataCollectorsNode); + var dataCollectorNode = doc.CreateElement(Constants.DataCollectorSettingName); + dataCollectorsNode.AppendChild(dataCollectorNode); + + foreach (var kvp in dataCollectionAttributes) { - var doc = new XmlDocument(); - var xmlDeclaration = doc.CreateNode(XmlNodeType.XmlDeclaration, string.Empty, string.Empty); - - doc.AppendChild(xmlDeclaration); - var runSettingsNode = doc.CreateElement(Constants.RunSettingsName); - doc.AppendChild(runSettingsNode); - var dcConfigNode = doc.CreateElement(Constants.DataCollectionRunSettingsName); - runSettingsNode.AppendChild(dcConfigNode); - var dataCollectorsNode = doc.CreateElement(Constants.DataCollectorsSettingName); - dcConfigNode.AppendChild(dataCollectorsNode); - var dataCollectorNode = doc.CreateElement(Constants.DataCollectorSettingName); - dataCollectorsNode.AppendChild(dataCollectorNode); - - foreach (var kvp in dataCollectionAttributes) + dataCollectorNode.SetAttribute(kvp.Key, kvp.Value); + } + + using var stream = new FileHelper().GetStream(destinationRunsettingsPath, FileMode.Create); + doc.Save(stream); + } + + private void VaildateDataCollectorOutput(string resultsDir) + { + // Output of datacollection attachment. + StdOutputContains("filename.txt"); + StdOutputContains("TestCaseStarted"); + StdOutputContains("TestCaseEnded"); + StdOutputContains("SampleUnitTestProject2.UnitTest1.PassingTest2"); + StdOutputContains("SampleUnitTestProject2.UnitTest1.FailingTest2"); + StdOutputContains("Data collector 'SampleDataCollector' message: SessionStarted"); + StdOutputContains("Data collector 'SampleDataCollector' message: TestHostLaunched"); + StdOutputContains("Data collector 'SampleDataCollector' message: SessionEnded"); + StdOutputContains("Data collector 'SampleDataCollector' message: my warning"); + StdErrorContains("Data collector 'SampleDataCollector' message: Data collector caught an exception of type 'System.Exception': 'my exception'. More details:"); + StdOutputContains("Data collector 'SampleDataCollector' message: Dispose called."); + + // Verify attachments + var isTestRunLevelAttachmentFound = false; + var testCaseLevelAttachmentsCount = 0; + var diaglogsFileCount = 0; + + var resultFiles = Directory.GetFiles(resultsDir, "*.txt", SearchOption.AllDirectories); + + foreach (var file in resultFiles) + { + // Test Run level attachments are logged in standard output. + if (file.Contains("filename.txt")) { - dataCollectorNode.SetAttribute(kvp.Key, kvp.Value); + StdOutputContains(file); + isTestRunLevelAttachmentFound = true; } - using (var stream = new FileHelper().GetStream(destinationRunsettingsPath, FileMode.Create)) + if (file.Contains("testcasefilename")) { - doc.Save(stream); + testCaseLevelAttachmentsCount++; } - } - private void VaildateDataCollectorOutput(string resultsDir) - { - // Output of datacollection attachment. - this.StdOutputContains("filename.txt"); - this.StdOutputContains("TestCaseStarted"); - this.StdOutputContains("TestCaseEnded"); - this.StdOutputContains("SampleUnitTestProject2.UnitTest1.PassingTest2"); - this.StdOutputContains("SampleUnitTestProject2.UnitTest1.FailingTest2"); - this.StdOutputContains("Data collector 'SampleDataCollector' message: SessionStarted"); - this.StdOutputContains("Data collector 'SampleDataCollector' message: TestHostLaunched"); - this.StdOutputContains("Data collector 'SampleDataCollector' message: SessionEnded"); - this.StdOutputContains("Data collector 'SampleDataCollector' message: my warning"); - this.StdErrorContains("Data collector 'SampleDataCollector' message: Data collector caught an exception of type 'System.Exception': 'my exception'. More details:"); - this.StdOutputContains("Data collector 'SampleDataCollector' message: Dispose called."); - - // Verify attachments - var isTestRunLevelAttachmentFound = false; - var testCaseLevelAttachmentsCount = 0; - var diaglogsFileCount = 0; - - var resultFiles = Directory.GetFiles(resultsDir, "*.txt", SearchOption.AllDirectories); - - foreach (var file in resultFiles) + if (file.Contains("diaglog")) { - // Test Run level attachments are logged in standard output. - if (file.Contains("filename.txt")) - { - this.StdOutputContains(file); - isTestRunLevelAttachmentFound = true; - } - - if (file.Contains("testcasefilename")) - { - testCaseLevelAttachmentsCount++; - } - - if (file.Contains("diaglog")) - { - diaglogsFileCount++; - } + diaglogsFileCount++; } - - Assert.IsTrue(isTestRunLevelAttachmentFound); - Assert.AreEqual(3, testCaseLevelAttachmentsCount); - Assert.AreEqual(3, diaglogsFileCount); } - private string GetRunsettingsFilePath(string resultsDir) - { - var runsettingsPath = Path.Combine(resultsDir, "test_" + Guid.NewGuid() + ".runsettings"); - var dataCollectionAttributes = new Dictionary(); + Assert.IsTrue(isTestRunLevelAttachmentFound); + Assert.AreEqual(3, testCaseLevelAttachmentsCount); + Assert.AreEqual(3, diaglogsFileCount); + } - dataCollectionAttributes.Add("friendlyName", "SampleDataCollector"); - dataCollectionAttributes.Add("uri", "my://sample/datacollector"); + private string GetRunsettingsFilePath(string resultsDir) + { + var runsettingsPath = Path.Combine(resultsDir, "test_" + Guid.NewGuid() + ".runsettings"); + var dataCollectionAttributes = new Dictionary + { + { "friendlyName", "SampleDataCollector" }, + { "uri", "my://sample/datacollector" } + }; - CreateDataCollectionRunSettingsFile(runsettingsPath, dataCollectionAttributes); - return runsettingsPath; - } + CreateDataCollectionRunSettingsFile(runsettingsPath, dataCollectionAttributes); + return runsettingsPath; } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/DebugAssertTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/DebugAssertTests.cs index d21e588903..c24f60597b 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/DebugAssertTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/DebugAssertTests.cs @@ -1,32 +1,31 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.AcceptanceTests; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestClass] - public class DebugAssertTests : AcceptanceTestBase +[TestClass] +public class DebugAssertTests : AcceptanceTestBase +{ + [TestMethod] + // this is core only, there is nothing we can do about Debug.Assert crashing the process on framework + [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] + public void RunningTestWithAFailingDebugAssertDoesNotCrashTheHostingProcess(RunnerInfo runnerInfo) { - [TestMethod] - // this is core only, there is nothing we can do about Debug.Assert crashing the process on framework - [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] - public void RunningTestWithAFailingDebugAssertDoesNotCrashTheHostingProcess(RunnerInfo runnerInfo) - { - // when debugging this test in case it starts failing, be aware that the default behavior of Debug.Assert - // is to not crash the process when we are running in debug, and debugger is attached - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + // when debugging this test in case it starts failing, be aware that the default behavior of Debug.Assert + // is to not crash the process when we are running in debug, and debugger is attached + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - var assemblyPath = this.BuildMultipleAssemblyPath("CrashingOnDebugAssertTestProject.dll").Trim('\"'); - var arguments = PrepareArguments(assemblyPath, null, null, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - this.InvokeVsTest(arguments); + using var tempDir = new TempDirectory(); + var assemblyPath = BuildMultipleAssemblyPath("CrashingOnDebugAssertTestProject.dll").Trim('\"'); + var arguments = PrepareArguments(assemblyPath, null, null, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + InvokeVsTest(arguments); - // this will have failed tests when our trace listener works and crash the testhost process when it does not - // because crashing processes is what a failed Debug.Assert does by default, unless you have a debugger attached - this.ValidateSummaryStatus(passedTestsCount: 4, failedTestsCount: 4, 0); - StringAssert.Contains(this.StdOut, "threw exception: Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException:"); - } + // this will have failed tests when our trace listener works and crash the testhost process when it does not + // because crashing processes is what a failed Debug.Assert does by default, unless you have a debugger attached + ValidateSummaryStatus(passedTestsCount: 4, failedTestsCount: 4, 0); + StringAssert.Contains(StdOut, "threw exception: Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException:"); } -} \ No newline at end of file +} diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/DeprecateExtensionsPathWarningTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/DeprecateExtensionsPathWarningTests.cs index 7c36be33a8..86b0410b81 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/DeprecateExtensionsPathWarningTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/DeprecateExtensionsPathWarningTests.cs @@ -1,85 +1,87 @@ -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestTools.UnitTesting; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. - using System.Collections.Generic; - using System.IO; - using System.Reflection; +namespace Microsoft.TestPlatform.AcceptanceTests; - [TestClass] - [TestCategory("Windows-Review")] - public class DeprecateExtensionsPathWarningTests : AcceptanceTestBase - { - private IList adapterDependencies; - private IList copiedFiles; +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using System.Collections.Generic; +using System.IO; +using System.Reflection; + +[TestClass] +[TestCategory("Windows-Review")] +public class DeprecateExtensionsPathWarningTests : AcceptanceTestBase +{ + private IList _adapterDependencies; + private IList _copiedFiles; - private string BuildConfiguration + private string BuildConfiguration + { + get { - get - { #if DEBUG - return "Debug"; + return "Debug"; #else - return "Release"; + return "Release"; #endif - } } + } - [TestCleanup] - public void Cleanup() + [TestCleanup] + public void Cleanup() + { + try { - try + foreach (var file in _copiedFiles) { - foreach (var file in this.copiedFiles) - { - File.Delete(file); - } + File.Delete(file); } - catch - { + } + catch + { - } } + } - [TestInitialize] - public void CopyAdapterToExtensions() - { - this.copiedFiles = new List(); - var extensionsDir = Path.Combine(Path.GetDirectoryName(this.GetConsoleRunnerPath()), "Extensions"); - this.adapterDependencies = Directory.GetFiles(this.GetTestAdapterPath(), "*.dll", SearchOption.TopDirectoryOnly); + [TestInitialize] + public void CopyAdapterToExtensions() + { + _copiedFiles = new List(); + var extensionsDir = Path.Combine(Path.GetDirectoryName(GetConsoleRunnerPath()), "Extensions"); + _adapterDependencies = Directory.GetFiles(GetTestAdapterPath(), "*.dll", SearchOption.TopDirectoryOnly); - try - { - foreach (var file in this.adapterDependencies) - { - var fileCopied = Path.Combine(extensionsDir, Path.GetFileName(file)); - this.copiedFiles.Add(fileCopied); - File.Copy(file, fileCopied); - } - } - catch + try + { + foreach (var file in _adapterDependencies) { - + var fileCopied = Path.Combine(extensionsDir, Path.GetFileName(file)); + _copiedFiles.Add(fileCopied); + File.Copy(file, fileCopied); } } - - [TestMethod] - public void VerifyDeprecatedWarningIsThrownWhenAdaptersPickedFromExtensionDirectory() + catch { - using var tempDir = new TempDirectory(); - var arguments = PrepareArguments(this.GetSampleTestAssembly(), null, null, this.FrameworkArgValue, resultsDirectory: tempDir.Path); - this.InvokeVsTest(arguments); - this.StdOutputContains("Adapter lookup is being changed, please follow"); } + } - public override string GetConsoleRunnerPath() - { - DirectoryInfo currentDirectory = new DirectoryInfo(typeof(DeprecateExtensionsPathWarningTests).GetTypeInfo().Assembly.GetAssemblyLocation()).Parent.Parent.Parent.Parent.Parent.Parent; + [TestMethod] + public void VerifyDeprecatedWarningIsThrownWhenAdaptersPickedFromExtensionDirectory() + { + using var tempDir = new TempDirectory(); + var arguments = PrepareArguments(GetSampleTestAssembly(), null, null, FrameworkArgValue, resultsDirectory: tempDir.Path); - return Path.Combine(currentDirectory.FullName, "artifacts", BuildConfiguration, "net451", "win7-x64", "vstest.console.exe"); - } + InvokeVsTest(arguments); + StdOutputContains("Adapter lookup is being changed, please follow"); + } + + public override string GetConsoleRunnerPath() + { + DirectoryInfo currentDirectory = new DirectoryInfo(typeof(DeprecateExtensionsPathWarningTests).GetTypeInfo().Assembly.GetAssemblyLocation()).Parent.Parent.Parent.Parent.Parent.Parent; + + return Path.Combine(currentDirectory.FullName, "artifacts", BuildConfiguration, "net451", "win7-x64", "vstest.console.exe"); } -} \ No newline at end of file +} diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/DifferentTestFrameworkSimpleTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/DifferentTestFrameworkSimpleTests.cs index 0184ce68e0..e788e09f85 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/DifferentTestFrameworkSimpleTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/DifferentTestFrameworkSimpleTests.cs @@ -1,75 +1,75 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using System; - using System.IO; +namespace Microsoft.TestPlatform.AcceptanceTests; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.IO; - [TestClass] - [TestCategory("Windows-Review")] - public class DifferentTestFrameworkSimpleTests : AcceptanceTestBase +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +[TestCategory("Windows-Review")] +public class DifferentTestFrameworkSimpleTests : AcceptanceTestBase +{ + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + public void ChutzpahRunAllTestExecution(RunnerInfo runnerInfo) { - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - public void ChutzpahRunAllTestExecution(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - var testJSFileAbsolutePath = Path.Combine(this.testEnvironment.TestAssetsPath, "test.js"); - var arguments = PrepareArguments(testJSFileAbsolutePath, this.GetTestAdapterPath(UnitTestFramework.Chutzpah), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + var testJSFileAbsolutePath = Path.Combine(_testEnvironment.TestAssetsPath, "test.js"); + var arguments = PrepareArguments(testJSFileAbsolutePath, GetTestAdapterPath(UnitTestFramework.Chutzpah), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 1, 0); - } + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 1, 0); + } - [TestMethod] - // vstest.console is x64 now, but x86 run "in process" run should still succeed by being run in x86 testhost - // Skip .NET (Core) tests because we test them below. - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true, useCoreRunner: false)] - public void CPPRunAllTestExecutionNetFramework(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - CppRunAllTests(runnerInfo.RunnerFramework, "x86"); - } + [TestMethod] + // vstest.console is x64 now, but x86 run "in process" run should still succeed by being run in x86 testhost + // Skip .NET (Core) tests because we test them below. + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true, useCoreRunner: false)] + public void CPPRunAllTestExecutionNetFramework(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + CppRunAllTests(runnerInfo.RunnerFramework, "x86"); + } - [TestMethod] - [TestCategory("Windows-Review")] - // vstest.console is 64-bit now, run in process to test the 64-bit native dll - // Skip .NET (Core) tests because we test them below. - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true, useCoreRunner: false)] - public void CPPRunAllTestExecutionPlatformx64NetFramework(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - CppRunAllTests(runnerInfo.RunnerFramework, "x64"); - } + [TestMethod] + [TestCategory("Windows-Review")] + // vstest.console is 64-bit now, run in process to test the 64-bit native dll + // Skip .NET (Core) tests because we test them below. + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true, useCoreRunner: false)] + public void CPPRunAllTestExecutionPlatformx64NetFramework(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + CppRunAllTests(runnerInfo.RunnerFramework, "x64"); + } - [TestMethod] - // C++ tests cannot run in .NET Framework host under .NET Core, because we only ship .NET Standard CPP adapter in .NET Core - // We also don't test x86 for .NET Core, because the resolver there does not switch between x86 and x64 correctly, it just uses the parent process bitness. - // We run this on netcore31 and not the default netcore21 because netcore31 is the minimum tfm that has the runtime features we need, such as additionaldeps. - [NetCoreTargetFrameworkDataSource(useDesktopRunner: false, useCoreRunner: true, useNetCore21Target: false, useNetCore31Target: true)] - public void CPPRunAllTestExecutionPlatformx64Net(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - CppRunAllTests(runnerInfo.RunnerFramework, "x64"); - } + [TestMethod] + // C++ tests cannot run in .NET Framework host under .NET Core, because we only ship .NET Standard CPP adapter in .NET Core + // We also don't test x86 for .NET Core, because the resolver there does not switch between x86 and x64 correctly, it just uses the parent process bitness. + // We run this on netcore31 and not the default netcore21 because netcore31 is the minimum tfm that has the runtime features we need, such as additionaldeps. + [NetCoreTargetFrameworkDataSource(useDesktopRunner: false, useCoreRunner: true, useNetCore21Target: false, useNetCore31Target: true)] + public void CPPRunAllTestExecutionPlatformx64Net(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + CppRunAllTests(runnerInfo.RunnerFramework, "x64"); + } - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - public void WebTestRunAllTestsWithRunSettings(RunnerInfo runnerInfo) - { - using var tempDir = new TempDirectory(); - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - var runSettingsFilePath = Path.Combine(tempDir.Path, Guid.NewGuid() + ".runsettings"); + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + public void WebTestRunAllTestsWithRunSettings(RunnerInfo runnerInfo) + { + using var tempDir = new TempDirectory(); + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + var runSettingsFilePath = Path.Combine(tempDir.Path, Guid.NewGuid() + ".runsettings"); - //test the iterationCount setting for WebTestRunConfiguration in run settings - var runSettingsXml = $@" + //test the iterationCount setting for WebTestRunConfiguration in run settings + var runSettingsXml = $@" @@ -77,134 +77,133 @@ public void WebTestRunAllTestsWithRunSettings(RunnerInfo runnerInfo) "; - IntegrationTestBase.CreateRunSettingsFile(runSettingsFilePath, runSettingsXml); + IntegrationTestBase.CreateRunSettingsFile(runSettingsFilePath, runSettingsXml); - //minWebTestResultFileSizeInKB is set to 150 here as the web test has a iteration count set to 5 - //therefore, the test will run for 5 iterations resulting in web test result file size of at least 150 KB - WebTestRunAllTests(runnerInfo.RunnerFramework, runSettingsFilePath, 150); - } + //minWebTestResultFileSizeInKB is set to 150 here as the web test has a iteration count set to 5 + //therefore, the test will run for 5 iterations resulting in web test result file size of at least 150 KB + WebTestRunAllTests(runnerInfo.RunnerFramework, runSettingsFilePath, 150); + } - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - public void CodedWebTestRunAllTests(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - CodedWebTestRunAllTests(runnerInfo.RunnerFramework); - } + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + public void CodedWebTestRunAllTests(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + CodedWebTestRunAllTests(runnerInfo.RunnerFramework); + } + + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetCoreTargetFrameworkDataSource] + public void NUnitRunAllTestExecution(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + + using var tempDir = new TempDirectory(); + var arguments = PrepareArguments( + GetAssetFullPath("NUTestProject.dll"), + GetTestAdapterPath(UnitTestFramework.NUnit), + string.Empty, FrameworkArgValue, + runnerInfo.InIsolationValue, tempDir.Path); + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 1, 0); + } + + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetCoreTargetFrameworkDataSource] + public void XUnitRunAllTestExecution(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - [NetCoreTargetFrameworkDataSource] - public void NUnitRunAllTestExecution(RunnerInfo runnerInfo) + string testAssemblyPath; + // Xunit >= 2.2 won't support net451, Minimum target framework it supports is net452. + if (_testEnvironment.TargetFramework.Equals("net451")) { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - - using var tempDir = new TempDirectory(); - var arguments = PrepareArguments( - this.GetAssetFullPath("NUTestProject.dll"), - this.GetTestAdapterPath(UnitTestFramework.NUnit), - string.Empty, this.FrameworkArgValue, - runnerInfo.InIsolationValue, tempDir.Path); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 1, 0); + testAssemblyPath = _testEnvironment.GetTestAsset("XUTestProject.dll", "net46"); } - - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - [NetCoreTargetFrameworkDataSource] - public void XUnitRunAllTestExecution(RunnerInfo runnerInfo) + else { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - string testAssemblyPath; - // Xunit >= 2.2 won't support net451, Minimum target framework it supports is net452. - if (this.testEnvironment.TargetFramework.Equals("net451")) - { - testAssemblyPath = testEnvironment.GetTestAsset("XUTestProject.dll", "net46"); - } - else - { - testAssemblyPath = testEnvironment.GetTestAsset("XUTestProject.dll"); - } - - var arguments = PrepareArguments( - testAssemblyPath, - this.GetTestAdapterPath(UnitTestFramework.XUnit), - string.Empty, this.FrameworkArgValue, - runnerInfo.InIsolationValue, tempDir.Path); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 1, 0); + testAssemblyPath = _testEnvironment.GetTestAsset("XUTestProject.dll"); } - private void CppRunAllTests(string runnerFramework, string platform) + var arguments = PrepareArguments( + testAssemblyPath, + GetTestAdapterPath(UnitTestFramework.XUnit), + string.Empty, FrameworkArgValue, + runnerInfo.InIsolationValue, tempDir.Path); + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 1, 0); + } + + private void CppRunAllTests(string runnerFramework, string platform) + { + using var tempDir = new TempDirectory(); + string assemblyRelativePathFormat = + @"microsoft.testplatform.testasset.nativecpp\2.0.0\contentFiles\any\any\{0}\Microsoft.TestPlatform.TestAsset.NativeCPP.dll"; + var assemblyRelativePath = platform.Equals("x64", StringComparison.OrdinalIgnoreCase) + ? string.Format(assemblyRelativePathFormat, platform) + : string.Format(assemblyRelativePathFormat, ""); + var assemblyAbsolutePath = Path.Combine(_testEnvironment.PackageDirectory, assemblyRelativePath); + var arguments = PrepareArguments(assemblyAbsolutePath, string.Empty, string.Empty, FrameworkArgValue, _testEnvironment.InIsolationValue, resultsDirectory: tempDir.Path); + + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 1, 0); + } + + private void WebTestRunAllTests(string runnerFramework, string runSettingsFilePath = null, int minWebTestResultFileSizeInKB = 0) + { + if (runnerFramework.StartsWith("netcoreapp")) { - using var tempDir = new TempDirectory(); - string assemblyRelativePathFormat = - @"microsoft.testplatform.testasset.nativecpp\2.0.0\contentFiles\any\any\{0}\Microsoft.TestPlatform.TestAsset.NativeCPP.dll"; - var assemblyRelativePath = platform.Equals("x64", StringComparison.OrdinalIgnoreCase) - ? string.Format(assemblyRelativePathFormat, platform) - : string.Format(assemblyRelativePathFormat, ""); - var assemblyAbsolutePath = Path.Combine(this.testEnvironment.PackageDirectory, assemblyRelativePath); - var arguments = PrepareArguments(assemblyAbsolutePath, string.Empty, string.Empty, this.FrameworkArgValue, this.testEnvironment.InIsolationValue, resultsDirectory: tempDir.Path); - - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 1, 0); + Assert.Inconclusive("WebTests tests not supported with .Netcore runner."); + return; } - private void WebTestRunAllTests(string runnerFramework, string runSettingsFilePath = null, int minWebTestResultFileSizeInKB = 0) + string assemblyRelativePath = + @"microsoft.testplatform.qtools.assets\2.0.0\contentFiles\any\any\WebTestAssets\WebTest1.webtest"; + + var assemblyAbsolutePath = Path.Combine(_testEnvironment.PackageDirectory, assemblyRelativePath); + using var resultsDirectory = new TempDirectory(); + var arguments = PrepareArguments( + assemblyAbsolutePath, + string.Empty, + runSettingsFilePath, FrameworkArgValue, string.Empty, resultsDirectory.Path); + + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 0, 0); + + if (minWebTestResultFileSizeInKB > 0) { - if (runnerFramework.StartsWith("netcoreapp")) - { - Assert.Inconclusive("WebTests tests not supported with .Netcore runner."); - return; - } - - string assemblyRelativePath = - @"microsoft.testplatform.qtools.assets\2.0.0\contentFiles\any\any\WebTestAssets\WebTest1.webtest"; - - var assemblyAbsolutePath = Path.Combine(this.testEnvironment.PackageDirectory, assemblyRelativePath); - using var resultsDirectory = new TempDirectory(); - var arguments = PrepareArguments( - assemblyAbsolutePath, - string.Empty, - runSettingsFilePath, this.FrameworkArgValue, string.Empty, resultsDirectory.Path); - - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 0, 0); - - if (minWebTestResultFileSizeInKB > 0) - { - var dirInfo = new DirectoryInfo(resultsDirectory.Path); - var webtestResultFile = "WebTest1.webtestResult"; - var files = dirInfo.GetFiles(webtestResultFile, SearchOption.AllDirectories); - Assert.IsTrue(files.Length > 0, $"File {webtestResultFile} not found under results directory {resultsDirectory}"); - - var fileSizeInKB = files[0].Length / 1024; - Assert.IsTrue(fileSizeInKB > minWebTestResultFileSizeInKB, $"Size of the file {webtestResultFile} is {fileSizeInKB} KB. It is not greater than {minWebTestResultFileSizeInKB} KB indicating iterationCount in run settings not honored."); - } + var dirInfo = new DirectoryInfo(resultsDirectory.Path); + var webtestResultFile = "WebTest1.webtestResult"; + var files = dirInfo.GetFiles(webtestResultFile, SearchOption.AllDirectories); + Assert.IsTrue(files.Length > 0, $"File {webtestResultFile} not found under results directory {resultsDirectory}"); + + var fileSizeInKB = files[0].Length / 1024; + Assert.IsTrue(fileSizeInKB > minWebTestResultFileSizeInKB, $"Size of the file {webtestResultFile} is {fileSizeInKB} KB. It is not greater than {minWebTestResultFileSizeInKB} KB indicating iterationCount in run settings not honored."); } + } - private void CodedWebTestRunAllTests(string runnerFramework) + private void CodedWebTestRunAllTests(string runnerFramework) + { + if (runnerFramework.StartsWith("netcoreapp")) { - if (runnerFramework.StartsWith("netcoreapp")) - { - Assert.Inconclusive("WebTests tests not supported with .Netcore runner."); - return; - } - - using var tempDir = new TempDirectory(); - string assemblyRelativePath = - @"microsoft.testplatform.qtools.assets\2.0.0\contentFiles\any\any\WebTestAssets\BingWebTest.dll"; - var assemblyAbsolutePath = Path.Combine(this.testEnvironment.PackageDirectory, assemblyRelativePath); - var arguments = PrepareArguments( - assemblyAbsolutePath, - string.Empty, - string.Empty, this.FrameworkArgValue, resultsDirectory: tempDir.Path); - - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 0, 0); + Assert.Inconclusive("WebTests tests not supported with .Netcore runner."); + return; } + + using var tempDir = new TempDirectory(); + string assemblyRelativePath = + @"microsoft.testplatform.qtools.assets\2.0.0\contentFiles\any\any\WebTestAssets\BingWebTest.dll"; + var assemblyAbsolutePath = Path.Combine(_testEnvironment.PackageDirectory, assemblyRelativePath); + var arguments = PrepareArguments( + assemblyAbsolutePath, + string.Empty, + string.Empty, FrameworkArgValue, resultsDirectory: tempDir.Path); + + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 0, 0); } } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/DisableAppdomainTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/DisableAppdomainTests.cs index 8a49c8a205..b9b47407fb 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/DisableAppdomainTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/DisableAppdomainTests.cs @@ -1,73 +1,72 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.AcceptanceTests; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; - using System; - using System.Collections.Generic; - using System.IO; +using System; +using System.Collections.Generic; +using System.IO; - [TestClass] +[TestClass] +[TestCategory("Windows")] +public class DisableAppdomainTests : AcceptanceTestBase +{ + [TestMethod] [TestCategory("Windows")] - public class DisableAppdomainTests : AcceptanceTestBase + [NetFullTargetFrameworkDataSource] + public void DisableAppdomainTest(RunnerInfo runnerInfo) { - [TestMethod] - [TestCategory("Windows")] - [NetFullTargetFrameworkDataSource] - public void DisableAppdomainTest(RunnerInfo runnerInfo) - { - SetTestEnvironment(this.testEnvironment, runnerInfo); + SetTestEnvironment(_testEnvironment, runnerInfo); - var diableAppdomainTest1 = testEnvironment.GetTestAsset("DisableAppdomainTest1.dll", "net451"); - var diableAppdomainTest2 = testEnvironment.GetTestAsset("DisableAppdomainTest2.dll", "net451"); + var diableAppdomainTest1 = _testEnvironment.GetTestAsset("DisableAppdomainTest1.dll", "net451"); + var diableAppdomainTest2 = _testEnvironment.GetTestAsset("DisableAppdomainTest2.dll", "net451"); - RunTests(runnerInfo.RunnerFramework, string.Format("{0}\" \"{1}", diableAppdomainTest1, diableAppdomainTest2), 2); - } + RunTests(runnerInfo.RunnerFramework, string.Format("{0}\" \"{1}", diableAppdomainTest1, diableAppdomainTest2), 2); + } - [TestMethod] - [TestCategory("Windows")] - [NetFullTargetFrameworkDataSource] - public void NewtonSoftDependencyWithDisableAppdomainTest(RunnerInfo runnerInfo) - { - SetTestEnvironment(this.testEnvironment, runnerInfo); + [TestMethod] + [TestCategory("Windows")] + [NetFullTargetFrameworkDataSource] + public void NewtonSoftDependencyWithDisableAppdomainTest(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); - var newtonSoftDependnecyTest = testEnvironment.GetTestAsset("NewtonSoftDependency.dll", "net451"); + var newtonSoftDependnecyTest = _testEnvironment.GetTestAsset("NewtonSoftDependency.dll", "net451"); - RunTests(runnerInfo.RunnerFramework, newtonSoftDependnecyTest, 1); - } + RunTests(runnerInfo.RunnerFramework, newtonSoftDependnecyTest, 1); + } - private void RunTests(string runnerFramework, string testAssembly, int passedTestCount) + private void RunTests(string runnerFramework, string testAssembly, int passedTestCount) + { + if (runnerFramework.StartsWith("netcoreapp")) { - if (runnerFramework.StartsWith("netcoreapp")) - { - Assert.Inconclusive("This test is not meant for .netcore."); - return; - } + Assert.Inconclusive("This test is not meant for .netcore."); + return; + } - var runConfigurationDictionary = new Dictionary - { - { "DisableAppDomain", "true" } - }; + var runConfigurationDictionary = new Dictionary + { + { "DisableAppDomain", "true" } + }; - using var tempDir = new TempDirectory(); - var arguments = PrepareArguments( - testAssembly, - string.Empty, - GetRunsettingsFilePath(tempDir, runConfigurationDictionary), - this.FrameworkArgValue, resultsDirectory: tempDir.Path); + using var tempDir = new TempDirectory(); + var arguments = PrepareArguments( + testAssembly, + string.Empty, + GetRunsettingsFilePath(tempDir, runConfigurationDictionary), + FrameworkArgValue, resultsDirectory: tempDir.Path); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(passedTestCount, 0, 0); - } + InvokeVsTest(arguments); + ValidateSummaryStatus(passedTestCount, 0, 0); + } - private string GetRunsettingsFilePath(TempDirectory tempDir, Dictionary runConfigurationDictionary) - { - var runsettingsPath = Path.Combine(tempDir.Path, "test_" + Guid.NewGuid() + ".runsettings"); - CreateRunSettingsFile(runsettingsPath, runConfigurationDictionary); - return runsettingsPath; - } + private string GetRunsettingsFilePath(TempDirectory tempDir, Dictionary runConfigurationDictionary) + { + var runsettingsPath = Path.Combine(tempDir.Path, "test_" + Guid.NewGuid() + ".runsettings"); + CreateRunSettingsFile(runsettingsPath, runConfigurationDictionary); + return runsettingsPath; } } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/DiscoveryTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/DiscoveryTests.cs index f095329420..feafaf8f51 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/DiscoveryTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/DiscoveryTests.cs @@ -1,120 +1,120 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests +namespace Microsoft.TestPlatform.AcceptanceTests; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; + +[TestClass] +public class DiscoveryTests : AcceptanceTestBase { - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Reflection; - - [TestClass] - public class DiscoveryTests : AcceptanceTestBase + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetCoreTargetFrameworkDataSource] + public void DiscoverAllTests(RunnerInfo runnerInfo) { - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - [NetCoreTargetFrameworkDataSource] - public void DiscoverAllTests(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); - this.InvokeVsTestForDiscovery(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue); + InvokeVsTestForDiscovery(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, FrameworkArgValue); - var listOfTests = new[] { "SampleUnitTestProject.UnitTest1.PassingTest", "SampleUnitTestProject.UnitTest1.FailingTest", "SampleUnitTestProject.UnitTest1.SkippingTest" }; - this.ValidateDiscoveredTests(listOfTests); - this.ExitCodeEquals(0); - } + var listOfTests = new[] { "SampleUnitTestProject.UnitTest1.PassingTest", "SampleUnitTestProject.UnitTest1.FailingTest", "SampleUnitTestProject.UnitTest1.SkippingTest" }; + ValidateDiscoveredTests(listOfTests); + ExitCodeEquals(0); + } - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - [NetCoreTargetFrameworkDataSource] - public void MultipleSourcesDiscoverAllTests(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject.dll", "SimpleTestProject2.dll").Trim('\"'); - var listOfTests = new[] { - "SampleUnitTestProject.UnitTest1.PassingTest", - "SampleUnitTestProject.UnitTest1.FailingTest", - "SampleUnitTestProject.UnitTest1.SkippingTest", - "SampleUnitTestProject.UnitTest1.PassingTest2", - "SampleUnitTestProject.UnitTest1.FailingTest2", - "SampleUnitTestProject.UnitTest1.SkippingTest2" - }; - - this.InvokeVsTestForDiscovery(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue); - - this.ValidateDiscoveredTests(listOfTests); - this.ExitCodeEquals(0); - } + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetCoreTargetFrameworkDataSource] + public void MultipleSourcesDiscoverAllTests(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject.dll", "SimpleTestProject2.dll").Trim('\"'); + var listOfTests = new[] { + "SampleUnitTestProject.UnitTest1.PassingTest", + "SampleUnitTestProject.UnitTest1.FailingTest", + "SampleUnitTestProject.UnitTest1.SkippingTest", + "SampleUnitTestProject.UnitTest1.PassingTest2", + "SampleUnitTestProject.UnitTest1.FailingTest2", + "SampleUnitTestProject.UnitTest1.SkippingTest2" + }; + + InvokeVsTestForDiscovery(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue); + + ValidateDiscoveredTests(listOfTests); + ExitCodeEquals(0); + } - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - public void DiscoverFullyQualifiedTests(RunnerInfo runnerInfo) - { - using var tempDir = new TempDirectory(); - var dummyFilePath = Path.Combine(tempDir.Path, $"{Guid.NewGuid()}.txt"); + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + public void DiscoverFullyQualifiedTests(RunnerInfo runnerInfo) + { + using var tempDir = new TempDirectory(); + var dummyFilePath = Path.Combine(tempDir.Path, $"{Guid.NewGuid()}.txt"); - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); - var listOfTests = new[] { "SampleUnitTestProject.UnitTest1.PassingTest", "SampleUnitTestProject.UnitTest1.FailingTest", "SampleUnitTestProject.UnitTest1.SkippingTest" }; + var listOfTests = new[] { "SampleUnitTestProject.UnitTest1.PassingTest", "SampleUnitTestProject.UnitTest1.FailingTest", "SampleUnitTestProject.UnitTest1.SkippingTest" }; - var arguments = PrepareArguments(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, this.testEnvironment.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /ListFullyQualifiedTests", " /ListTestsTargetPath:\"" + dummyFilePath + "\""); - this.InvokeVsTest(arguments); + var arguments = PrepareArguments(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, FrameworkArgValue, _testEnvironment.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /ListFullyQualifiedTests", " /ListTestsTargetPath:\"" + dummyFilePath + "\""); + InvokeVsTest(arguments); - this.ValidateFullyQualifiedDiscoveredTests(dummyFilePath, listOfTests); - this.ExitCodeEquals(0); - } + ValidateFullyQualifiedDiscoveredTests(dummyFilePath, listOfTests); + ExitCodeEquals(0); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void DiscoverTestsShouldShowProperWarningIfNoTestsOnTestCaseFilter(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var assetFullPath = this.GetAssetFullPath("SimpleTestProject2.dll"); - var arguments = PrepareArguments(assetFullPath, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, this.testEnvironment.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /listtests"); - arguments = string.Concat(arguments, " /testcasefilter:NonExistTestCaseName"); - arguments = string.Concat(arguments, " /logger:\"console;prefix=true\""); - this.InvokeVsTest(arguments); - - StringAssert.Contains(this.StdOut, "Warning: No test matches the given testcase filter `NonExistTestCaseName` in"); - StringAssert.Contains(this.StdOut, "SimpleTestProject2.dll"); - this.ExitCodeEquals(0); - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void DiscoverTestsShouldShowProperWarningIfNoTestsOnTestCaseFilter(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var assetFullPath = GetAssetFullPath("SimpleTestProject2.dll"); + var arguments = PrepareArguments(assetFullPath, GetTestAdapterPath(), string.Empty, FrameworkArgValue, _testEnvironment.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /listtests"); + arguments = string.Concat(arguments, " /testcasefilter:NonExistTestCaseName"); + arguments = string.Concat(arguments, " /logger:\"console;prefix=true\""); + InvokeVsTest(arguments); + + StringAssert.Contains(StdOut, "Warning: No test matches the given testcase filter `NonExistTestCaseName` in"); + StringAssert.Contains(StdOut, "SimpleTestProject2.dll"); + ExitCodeEquals(0); + } - [TestMethod] - public void TypesToLoadAttributeTests() + [TestMethod] + public void TypesToLoadAttributeTests() + { + var environment = new IntegrationTestEnvironment(); + var extensionsDirectory = environment.ExtensionsDirectory; + var extensionsToVerify = new Dictionary + { + {"Microsoft.TestPlatform.Extensions.EventLogCollector.dll", new[] { "Microsoft.TestPlatform.Extensions.EventLogCollector.EventLogDataCollector"} }, + {"Microsoft.TestPlatform.Extensions.BlameDataCollector.dll", new[] { "Microsoft.TestPlatform.Extensions.BlameDataCollector.BlameLogger", "Microsoft.TestPlatform.Extensions.BlameDataCollector.BlameCollector" } }, + {"Microsoft.VisualStudio.TestPlatform.Extensions.Html.TestLogger.dll", new[] { "Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger.HtmlLogger" } }, + {"Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger.dll", new[] { "Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.TrxLogger" } }, + {"Microsoft.TestPlatform.TestHostRuntimeProvider.dll", new[] { "Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DefaultTestHostManager", "Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager" } } + }; + + foreach (var extension in extensionsToVerify.Keys) { - var environment = new IntegrationTestEnvironment(); - var extensionsDirectory = environment.ExtensionsDirectory; - var extensionsToVerify = new Dictionary - { - {"Microsoft.TestPlatform.Extensions.EventLogCollector.dll", new[] { "Microsoft.TestPlatform.Extensions.EventLogCollector.EventLogDataCollector"} }, - {"Microsoft.TestPlatform.Extensions.BlameDataCollector.dll", new[] { "Microsoft.TestPlatform.Extensions.BlameDataCollector.BlameLogger", "Microsoft.TestPlatform.Extensions.BlameDataCollector.BlameCollector" } }, - {"Microsoft.VisualStudio.TestPlatform.Extensions.Html.TestLogger.dll", new[] { "Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger.HtmlLogger" } }, - {"Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger.dll", new[] { "Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.TrxLogger" } }, - {"Microsoft.TestPlatform.TestHostRuntimeProvider.dll", new[] { "Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DefaultTestHostManager", "Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager" } } - }; - - foreach (var extension in extensionsToVerify.Keys) - { - var assemblyFile = Path.Combine(extensionsDirectory, extension); - var assembly = Assembly.LoadFrom(assemblyFile); - - var expected = extensionsToVerify[extension]; - var actual = TypesToLoadUtilities.GetTypesToLoad(assembly).Select(i => i.FullName).ToArray(); - - CollectionAssert.AreEquivalent(expected, actual, $"Specified types using TypesToLoadAttribute in \"{extension}\" assembly doesn't match the expected."); - } + var assemblyFile = Path.Combine(extensionsDirectory, extension); + var assembly = Assembly.LoadFrom(assemblyFile); + + var expected = extensionsToVerify[extension]; + var actual = TypesToLoadUtilities.GetTypesToLoad(assembly).Select(i => i.FullName).ToArray(); + + CollectionAssert.AreEquivalent(expected, actual, $"Specified types using TypesToLoadAttribute in \"{extension}\" assembly doesn't match the expected."); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureSwitchTests.Windows.cs b/test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureSwitchTests.Windows.cs index 7f16471bde..1b79bae252 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureSwitchTests.Windows.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureSwitchTests.Windows.cs @@ -3,48 +3,50 @@ #if !NET451 -namespace Microsoft.TestPlatform.AcceptanceTests +namespace Microsoft.TestPlatform.AcceptanceTests; + +using TestUtilities; +using VisualStudio.TestTools.UnitTesting; + +using Newtonsoft.Json.Linq; + +using System.Collections.Generic; +using System.IO; +using System.Linq; + +[TestClass] +[TestCategory("Windows-Review")] +public class DotnetArchitectureSwitchTestsWindowsOnly : AcceptanceTestBase { - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Newtonsoft.Json.Linq; - using System.Collections.Generic; - using System.IO; - using System.Linq; - - [TestClass] - [TestCategory("Windows-Review")] - public class DotnetArchitectureSwitchTestsWindowsOnly : AcceptanceTestBase + [TestMethod] + [DataRow("X64", "X86")] + [DataRow("X86", "X64")] + public void Use_EnvironmentVariables(string architectureFrom, string architectureTo) { - [TestMethod] - [DataRow("X64", "X86")] - [DataRow("X86", "X64")] - public void Use_EnvironmentVariables(string architectureFrom, string architectureTo) + using var workSpace = new TempDirectory(); + string dotnetPath = GetDownloadedDotnetMuxerFromTools(architectureFrom); + string dotnetPathTo = GetDownloadedDotnetMuxerFromTools(architectureTo); + var vstestConsolePath = GetDotnetRunnerPath(); + var dotnetRunnerPath = workSpace.CreateDirectory("dotnetrunner"); + workSpace.CopyAll(new DirectoryInfo(Path.GetDirectoryName(vstestConsolePath)), dotnetRunnerPath); + + // Patch the runner + string sdkVersion = GetLatestSdkVersion(dotnetPath); + string runtimeConfigFile = Path.Combine(dotnetRunnerPath.FullName, "vstest.console.runtimeconfig.json"); + JObject patchRuntimeConfig = JObject.Parse(File.ReadAllText(runtimeConfigFile)); + patchRuntimeConfig["runtimeOptions"]["framework"]["version"] = sdkVersion; + File.WriteAllText(runtimeConfigFile, patchRuntimeConfig.ToString()); + + var environmentVariables = new Dictionary { - using var workSpace = new TempDirectory(); - string dotnetPath = GetDownloadedDotnetMuxerFromTools(architectureFrom); - string dotnetPathTo = GetDownloadedDotnetMuxerFromTools(architectureTo); - var vstestConsolePath = GetDotnetRunnerPath(); - var dotnetRunnerPath = workSpace.CreateDirectory("dotnetrunner"); - workSpace.CopyAll(new DirectoryInfo(Path.GetDirectoryName(vstestConsolePath)), dotnetRunnerPath); - - // Patch the runner - string sdkVersion = GetLatestSdkVersion(dotnetPath); - string runtimeConfigFile = Path.Combine(dotnetRunnerPath.FullName, "vstest.console.runtimeconfig.json"); - JObject patchRuntimeConfig = JObject.Parse(File.ReadAllText(runtimeConfigFile)); - patchRuntimeConfig["runtimeOptions"]["framework"]["version"] = sdkVersion; - File.WriteAllText(runtimeConfigFile, patchRuntimeConfig.ToString()); - - var environmentVariables = new Dictionary - { - ["DOTNET_MULTILEVEL_LOOKUP"] = "0", - [$"DOTNET_ROOT_{architectureTo}"] = Path.GetDirectoryName(dotnetPathTo), - ["ExpectedArchitecture"] = architectureTo - }; - this.ExecuteApplication(dotnetPath, "new mstest", out string stdOut, out string stdError, out int exitCode, environmentVariables, workSpace.Path); - - // Patch test file - File.WriteAllText(Path.Combine(workSpace.Path, "UnitTest1.cs"), + ["DOTNET_MULTILEVEL_LOOKUP"] = "0", + [$"DOTNET_ROOT_{architectureTo}"] = Path.GetDirectoryName(dotnetPathTo), + ["ExpectedArchitecture"] = architectureTo + }; + ExecuteApplication(dotnetPath, "new mstest", out string stdOut, out string stdError, out int exitCode, environmentVariables, workSpace.Path); + + // Patch test file + File.WriteAllText(Path.Combine(workSpace.Path, "UnitTest1.cs"), @" using Microsoft.VisualStudio.TestTools.UnitTesting; using System; @@ -61,32 +63,31 @@ public void TestMethod1() } }"); - this.ExecuteApplication(dotnetPath, $"test -p:VsTestConsolePath=\"{Path.Combine(dotnetRunnerPath.FullName, Path.GetFileName(vstestConsolePath))}\" --arch {architectureTo.ToLower()} --diag:log.txt", out stdOut, out stdError, out exitCode, environmentVariables, workSpace.Path); - Assert.AreEqual(0, exitCode, stdOut); - - environmentVariables = new Dictionary - { - ["DOTNET_MULTILEVEL_LOOKUP"] = "0", - ["DOTNET_ROOT"] = Path.GetDirectoryName(dotnetPathTo), - ["ExpectedArchitecture"] = architectureTo - }; - this.ExecuteApplication(dotnetPath, $"test -p:VsTestConsolePath=\"{Path.Combine(dotnetRunnerPath.FullName, Path.GetFileName(vstestConsolePath))}\" --arch {architectureTo.ToLower()} --diag:log.txt", out stdOut, out stdError, out exitCode, environmentVariables, workSpace.Path); - Assert.AreEqual(0, exitCode, stdOut); - - environmentVariables = new Dictionary - { - ["DOTNET_MULTILEVEL_LOOKUP"] = "0", - [$"DOTNET_ROOT_{architectureTo}"] = Path.GetDirectoryName(dotnetPathTo), - ["DOTNET_ROOT"] = "WE SHOULD PICK THE ABOVE ONE BEFORE FALLBACK TO DOTNET_ROOT", - ["ExpectedArchitecture"] = architectureTo - }; - this.ExecuteApplication(dotnetPath, $"test -p:VsTestConsolePath=\"{Path.Combine(dotnetRunnerPath.FullName, Path.GetFileName(vstestConsolePath))}\" --arch {architectureTo.ToLower()} --diag:log.txt", out stdOut, out stdError, out exitCode, environmentVariables, workSpace.Path); - Assert.AreEqual(0, exitCode, stdOut); - } - - private string GetLatestSdkVersion(string dotnetPath) - => Path.GetFileName(Directory.GetDirectories(Path.Combine(Path.GetDirectoryName(dotnetPath), @"shared/Microsoft.NETCore.App")).OrderByDescending(x => x).First()); + ExecuteApplication(dotnetPath, $"test -p:VsTestConsolePath=\"{Path.Combine(dotnetRunnerPath.FullName, Path.GetFileName(vstestConsolePath))}\" --arch {architectureTo.ToLower()} --diag:log.txt", out stdOut, out stdError, out exitCode, environmentVariables, workSpace.Path); + Assert.AreEqual(0, exitCode, stdOut); + + environmentVariables = new Dictionary + { + ["DOTNET_MULTILEVEL_LOOKUP"] = "0", + ["DOTNET_ROOT"] = Path.GetDirectoryName(dotnetPathTo), + ["ExpectedArchitecture"] = architectureTo + }; + ExecuteApplication(dotnetPath, $"test -p:VsTestConsolePath=\"{Path.Combine(dotnetRunnerPath.FullName, Path.GetFileName(vstestConsolePath))}\" --arch {architectureTo.ToLower()} --diag:log.txt", out stdOut, out stdError, out exitCode, environmentVariables, workSpace.Path); + Assert.AreEqual(0, exitCode, stdOut); + + environmentVariables = new Dictionary + { + ["DOTNET_MULTILEVEL_LOOKUP"] = "0", + [$"DOTNET_ROOT_{architectureTo}"] = Path.GetDirectoryName(dotnetPathTo), + ["DOTNET_ROOT"] = "WE SHOULD PICK THE ABOVE ONE BEFORE FALLBACK TO DOTNET_ROOT", + ["ExpectedArchitecture"] = architectureTo + }; + ExecuteApplication(dotnetPath, $"test -p:VsTestConsolePath=\"{Path.Combine(dotnetRunnerPath.FullName, Path.GetFileName(vstestConsolePath))}\" --arch {architectureTo.ToLower()} --diag:log.txt", out stdOut, out stdError, out exitCode, environmentVariables, workSpace.Path); + Assert.AreEqual(0, exitCode, stdOut); } + + private string GetLatestSdkVersion(string dotnetPath) + => Path.GetFileName(Directory.GetDirectories(Path.Combine(Path.GetDirectoryName(dotnetPath), @"shared/Microsoft.NETCore.App")).OrderByDescending(x => x).First()); } #endif diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureSwitchTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureSwitchTests.cs index 3e1bdd3dd8..45ce6a7fcb 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureSwitchTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureSwitchTests.cs @@ -3,320 +3,328 @@ #if !NET451 -namespace Microsoft.TestPlatform.AcceptanceTests +namespace Microsoft.TestPlatform.AcceptanceTests; + +using System.IO; +using System.Text.RegularExpressions; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using VisualStudio.TestTools.UnitTesting; +using System; +using Microsoft.TestPlatform.TestUtilities; + +// This tests need specific sdks to be installed on arm machine +// >= ARM 6.0.2xx +// >= x64 6.0.2xx +// x64 5.0.4xx for Mac +// x64 3.1.4XX for Win +// Manual test './tools/.../dotnet test ./test/Microsoft.TestPlatform.AcceptanceTests/bin/Debug/netcoreapp2.1/Microsoft.TestPlatform.AcceptanceTests.dll --testcasefilter:"DotnetArchitectureSwitchTests"' +[TestClass] +[Ignore("Manual tests(for now). Tests in this class need some .NET SDK global installations")] +public class DotnetArchitectureSwitchTests : AcceptanceTestBase { - using System.IO; - using System.Text.RegularExpressions; - using System.Collections.Generic; - using System.Runtime.InteropServices; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System; - using Microsoft.TestPlatform.TestUtilities; - - // This tests need specific sdks to be installed on arm machine - // >= ARM 6.0.2xx - // >= x64 6.0.2xx - // x64 5.0.4xx for Mac - // x64 3.1.4XX for Win - // Manual test './tools/.../dotnet test ./test/Microsoft.TestPlatform.AcceptanceTests/bin/Debug/netcoreapp2.1/Microsoft.TestPlatform.AcceptanceTests.dll --testcasefilter:"DotnetArchitectureSwitchTests"' - [TestClass] - [Ignore("Manual tests(for now). Tests in this class need some .NET SDK global installations")] - public class DotnetArchitectureSwitchTests : AcceptanceTestBase + private static string s_privateX64Installation; + + [ClassInitialize] + public static void ClassInitialize(TestContext _) { - private static string privateX64Installation; + s_privateX64Installation = Path.Combine(new TempDirectory().Path, "x64"); + CopyAll(new DirectoryInfo(GetX64InstallationFolder), new DirectoryInfo(s_privateX64Installation)); + } - [ClassInitialize] - public static void ClassInitialize(TestContext context) - { - privateX64Installation = Path.Combine(new TempDirectory().Path, "x64"); - CopyAll(new DirectoryInfo(GetX64InstallationFolder), new DirectoryInfo(privateX64Installation)); - } + [ClassCleanup] + public static void ClassCleanup() + { + // Remove one level up because we are targeting a sub-folder of the temp directory. + TempDirectory.TryRemoveDirectory(new DirectoryInfo(s_privateX64Installation).Parent.FullName); + } - [ClassCleanup] - public static void ClassCleanup() + [TestMethod] + public void GlobalInstallation() + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { - // Remove one level up because we are targeting a sub-folder of the temp directory. - TempDirectory.TryRemoveDirectory(new DirectoryInfo(privateX64Installation).Parent.FullName); + return; } - [TestMethod] - public void GlobalInstallation() - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - return; - } + var projectName = "ArchitectureSwitch.csproj"; + var projectPath = GetProjectFullPath(projectName); + var projectDirectory = Path.GetDirectoryName(projectPath); - var projectName = "ArchitectureSwitch.csproj"; - var projectPath = this.GetProjectFullPath(projectName); - var projectDirectory = Path.GetDirectoryName(projectPath); - - var env = new Dictionary(); - env.Add("DOTNET_ROOT", null); - env.Add("DOTNET_MULTILEVEL_LOOKUP", "0"); - - // Verify native architecture - ExecuteApplication(GetDefaultDotnetMuxerLocation, $"test {projectPath} --framework net6.0", out string stdOut, out string stdError, out int exitCode, env, projectDirectory); - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + var env = new Dictionary { - Assert.IsTrue(stdOut.Contains("Runtime location: /usr/local/share/dotnet/shared/Microsoft.NETCore.App")); - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - Assert.IsTrue(stdOut.Contains($@"Runtime location: {Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet\shared\Microsoft.NETCore.App")); - } - Assert.IsTrue(stdOut.Contains("OSArchitecture: Arm64")); - Assert.IsTrue(stdOut.Contains("ProcessArchitecture: Arm64")); - - - // Verify switch using csproj - ExecuteApplication(GetDefaultDotnetMuxerLocation, $"test {projectPath} --framework net6.0 --arch x64", out stdOut, out stdError, out exitCode, env, projectDirectory); - AssertSwitch(stdOut); - - // Verify switch using test container - var buildAssemblyPath = GetAssetFullPath("ArchitectureSwitch.dll", "net6.0"); - ExecuteApplication(GetDefaultDotnetMuxerLocation, $"test {buildAssemblyPath} --arch x64", out stdOut, out stdError, out exitCode, env, projectDirectory); - AssertSwitch(stdOut); + { "DOTNET_ROOT", null }, + { "DOTNET_MULTILEVEL_LOOKUP", "0" } + }; - void AssertSwitch(string output) - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - Assert.IsTrue(output.Contains("Runtime location: /usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App")); - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - Assert.IsTrue(output.Contains($@"Runtime location: {Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet\x64\shared\Microsoft.NETCore.App")); - } - Assert.IsTrue(output.Contains("OSArchitecture: X64")); - Assert.IsTrue(output.Contains("ProcessArchitecture: X64")); - } + // Verify native architecture + ExecuteApplication(GetDefaultDotnetMuxerLocation, $"test {projectPath} --framework net6.0", out string stdOut, out _, out _, env, projectDirectory); + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + Assert.IsTrue(stdOut.Contains("Runtime location: /usr/local/share/dotnet/shared/Microsoft.NETCore.App")); } - - [TestMethod] - [DataRow(true, false)] - [DataRow(false, true)] - public void DOTNET_ROOTS_EnvironmentVariables(bool dotnetRoot, bool dotnetRootX64) + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - return; - } + Assert.IsTrue(stdOut.Contains($@"Runtime location: {Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet\shared\Microsoft.NETCore.App")); + } + Assert.IsTrue(stdOut.Contains("OSArchitecture: ARM64")); + Assert.IsTrue(stdOut.Contains("ProcessArchitecture: ARM64")); + - var env = new Dictionary(); - env["DOTNET_ROOT"] = null; - env["DOTNET_MULTILEVEL_LOOKUP"] = "0"; + // Verify switch using csproj + ExecuteApplication(GetDefaultDotnetMuxerLocation, $"test {projectPath} --framework net6.0 --arch x64", out stdOut, out _, out _, env, projectDirectory); + AssertSwitch(stdOut); - var projectName = "ArchitectureSwitch.csproj"; - var projectPath = this.GetProjectFullPath(projectName); - var projectDirectory = Path.GetDirectoryName(projectPath); + // Verify switch using test container + var buildAssemblyPath = GetAssetFullPath("ArchitectureSwitch.dll", "net6.0"); + ExecuteApplication(GetDefaultDotnetMuxerLocation, $"test {buildAssemblyPath} --arch x64", out stdOut, out _, out _, env, projectDirectory); + AssertSwitch(stdOut); - // Verify native architecture - ExecuteApplication(GetDefaultDotnetMuxerLocation, $"test {projectPath} --framework net6.0", out string stdOut, out string stdError, out int exitCode, env, projectDirectory); + static void AssertSwitch(string output) + { if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { - Assert.IsTrue(stdOut.Contains("Runtime location: /usr/local/share/dotnet/shared/Microsoft.NETCore.App"), "Unexpected runtime location"); + Assert.IsTrue(output.Contains("Runtime location: /usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App")); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - Assert.IsTrue(stdOut.Contains($@"Runtime location: {Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet\shared\Microsoft.NETCore.App")); - } - Assert.IsTrue(stdOut.Contains("OSArchitecture: Arm64"), "Unexpected OSArchitecture"); - Assert.IsTrue(stdOut.Contains("ProcessArchitecture: Arm64"), "Unexpected ProcessArchitecture"); - - env.Clear(); - env["DOTNET_ROOT"] = null; - env["DOTNET_MULTILEVEL_LOOKUP"] = "0"; - if (dotnetRoot) - { - env["DOTNET_ROOT"] = privateX64Installation; + Assert.IsTrue(output.Contains($@"Runtime location: {Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet\x64\shared\Microsoft.NETCore.App")); } + Assert.IsTrue(output.Contains("OSArchitecture: X64")); + Assert.IsTrue(output.Contains("ProcessArchitecture: X64")); + } + } - if (dotnetRootX64) - { - env.Add("DOTNET_ROOT_X64", privateX64Installation); - } + [TestMethod] + [DataRow(true, false)] + [DataRow(false, true)] + public void DOTNET_ROOTS_EnvironmentVariables(bool dotnetRoot, bool dotnetRootX64) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + return; + } - // Verify switch using csproj - ExecuteApplication($"{privateX64Installation}/{GetMuxerName}", $"test {projectPath} --framework net6.0 --arch x64", out stdOut, out stdError, out exitCode, env, projectDirectory); - AssertSwitch(stdOut); + var env = new Dictionary + { + ["DOTNET_ROOT"] = null, + ["DOTNET_MULTILEVEL_LOOKUP"] = "0" + }; - // Verify switch using test container - var buildAssemblyPath = GetAssetFullPath("ArchitectureSwitch.dll", "net6.0"); - ExecuteApplication($"{privateX64Installation}/{GetMuxerName}", $"test {buildAssemblyPath} --framework net6.0 --arch x64", out stdOut, out stdError, out exitCode, env, projectDirectory); - AssertSwitch(stdOut); + var projectName = "ArchitectureSwitch.csproj"; + var projectPath = GetProjectFullPath(projectName); + var projectDirectory = Path.GetDirectoryName(projectPath); - void AssertSwitch(string output) - { - Assert.IsTrue(Regex.IsMatch(output.Replace(@"\", "/"), $"Runtime location: .*{privateX64Installation.Replace(@"\", "/")}.*shared.*Microsoft.NETCore.App"), "Unexpected runtime location"); - Assert.IsTrue(output.Contains("OSArchitecture: X64"), "Unexpected OSArchitecture"); - Assert.IsTrue(output.Contains("ProcessArchitecture: X64"), "Unexpected ProcessArchitecture"); - Assert.IsTrue(dotnetRoot ? output.Contains($"DOTNET_ROOT: {privateX64Installation}") : true, "Unexpected DOTNET_ROOT var"); - Assert.IsTrue(dotnetRootX64 ? output.Contains($"DOTNET_ROOT_X64: {privateX64Installation}") : true, "Unexpected DOTNET_ROOT_X64 var"); - } + // Verify native architecture + ExecuteApplication(GetDefaultDotnetMuxerLocation, $"test {projectPath} --framework net6.0", out string stdOut, out _, out _, env, projectDirectory); + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + Assert.IsTrue(stdOut.Contains("Runtime location: /usr/local/share/dotnet/shared/Microsoft.NETCore.App"), "Unexpected runtime location"); } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + Assert.IsTrue(stdOut.Contains($@"Runtime location: {Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet\shared\Microsoft.NETCore.App")); + } + Assert.IsTrue(stdOut.Contains("OSArchitecture: ARM64"), "Unexpected OSArchitecture"); + Assert.IsTrue(stdOut.Contains("ProcessArchitecture: ARM64"), "Unexpected ProcessArchitecture"); - [TestMethod] - public void PrivateX64BuildToGlobalArmInstallation() + env.Clear(); + env["DOTNET_ROOT"] = null; + env["DOTNET_MULTILEVEL_LOOKUP"] = "0"; + if (dotnetRoot) { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - return; - } + env["DOTNET_ROOT"] = s_privateX64Installation; + } - var env = new Dictionary(); - env["DOTNET_ROOT"] = null; - env["DOTNET_MULTILEVEL_LOOKUP"] = "0"; - string privateInstallationMuxer = Path.Combine(privateX64Installation, GetMuxerName); + if (dotnetRootX64) + { + env.Add("DOTNET_ROOT_X64", s_privateX64Installation); + } - var projectName = "ArchitectureSwitch.csproj"; - var projectPath = this.GetProjectFullPath(projectName); - var projectDirectory = Path.GetDirectoryName(projectPath); + // Verify switch using csproj + ExecuteApplication($"{s_privateX64Installation}/{GetMuxerName}", $"test {projectPath} --framework net6.0 --arch x64", out stdOut, out _, out _, env, projectDirectory); + AssertSwitch(stdOut); - // Verify native architecture - ExecuteApplication(privateInstallationMuxer, $"test {projectPath} --framework net6.0", out string stdOut, out string stdError, out int exitCode, env, projectDirectory); - Assert.IsTrue(Regex.IsMatch(stdOut.Replace(@"\", "/"), $"Runtime location: .*{privateX64Installation.Replace(@"\", "/")}.*shared.*Microsoft.NETCore.App"), "Unexpected runtime location"); - Assert.IsTrue(stdOut.Contains("OSArchitecture: X64"), "Unexpected OSArchitecture"); - Assert.IsTrue(stdOut.Contains("ProcessArchitecture: X64"), "Unexpected ProcessArchitecture"); + // Verify switch using test container + var buildAssemblyPath = GetAssetFullPath("ArchitectureSwitch.dll", "net6.0"); + ExecuteApplication($"{s_privateX64Installation}/{GetMuxerName}", $"test {buildAssemblyPath} --framework net6.0 --arch x64", out stdOut, out _, out _, env, projectDirectory); + AssertSwitch(stdOut); - // Verify switch using csproj - ExecuteApplication($"{privateX64Installation}/{GetMuxerName}", $"test {projectPath} --framework net6.0 --arch arm64", out stdOut, out stdError, out exitCode, env, projectDirectory); - AssertSwitch(stdOut); + void AssertSwitch(string output) + { + Assert.IsTrue(Regex.IsMatch(output.Replace(@"\", "/"), $"Runtime location: .*{s_privateX64Installation.Replace(@"\", "/")}.*shared.*Microsoft.NETCore.App"), "Unexpected runtime location"); + Assert.IsTrue(output.Contains("OSArchitecture: X64"), "Unexpected OSArchitecture"); + Assert.IsTrue(output.Contains("ProcessArchitecture: X64"), "Unexpected ProcessArchitecture"); + Assert.IsTrue(!dotnetRoot || output.Contains($"DOTNET_ROOT: {s_privateX64Installation}"), "Unexpected DOTNET_ROOT var"); + Assert.IsTrue(!dotnetRootX64 || output.Contains($"DOTNET_ROOT_X64: {s_privateX64Installation}"), "Unexpected DOTNET_ROOT_X64 var"); + } + } - // Verify switch using test container - var buildAssemblyPath = GetAssetFullPath("ArchitectureSwitch.dll", "net6.0"); - ExecuteApplication($"{privateX64Installation}/{GetMuxerName}", $"test {buildAssemblyPath} --framework net6.0 --arch arm64", out stdOut, out stdError, out exitCode, env, projectDirectory); - AssertSwitch(stdOut); + [TestMethod] + public void PrivateX64BuildToGlobalArmInstallation() + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + return; + } - void AssertSwitch(string output) - { - Assert.IsTrue(Regex.IsMatch(output.Replace(@"\", "/"), $"Runtime location: .*{GetDefaultLocation.Replace(@"\", "/")}.*shared.*Microsoft.NETCore.App"), "Unexpected runtime location"); - Assert.IsTrue(output.Contains("OSArchitecture: Arm64"), "Unexpected OSArchitecture"); - Assert.IsTrue(output.Contains("ProcessArchitecture: Arm64"), "Unexpected ProcessArchitecture"); - } + var env = new Dictionary + { + ["DOTNET_ROOT"] = null, + ["DOTNET_MULTILEVEL_LOOKUP"] = "0" + }; + string privateInstallationMuxer = Path.Combine(s_privateX64Installation, GetMuxerName); + + var projectName = "ArchitectureSwitch.csproj"; + var projectPath = GetProjectFullPath(projectName); + var projectDirectory = Path.GetDirectoryName(projectPath); + + // Verify native architecture + ExecuteApplication(privateInstallationMuxer, $"test {projectPath} --framework net6.0", out string stdOut, out _, out _, env, projectDirectory); + Assert.IsTrue(Regex.IsMatch(stdOut.Replace(@"\", "/"), $"Runtime location: .*{s_privateX64Installation.Replace(@"\", "/")}.*shared.*Microsoft.NETCore.App"), "Unexpected runtime location"); + Assert.IsTrue(stdOut.Contains("OSArchitecture: X64"), "Unexpected OSArchitecture"); + Assert.IsTrue(stdOut.Contains("ProcessArchitecture: X64"), "Unexpected ProcessArchitecture"); + + // Verify switch using csproj + ExecuteApplication($"{s_privateX64Installation}/{GetMuxerName}", $"test {projectPath} --framework net6.0 --arch arm64", out stdOut, out _, out _, env, projectDirectory); + AssertSwitch(stdOut); + + // Verify switch using test container + var buildAssemblyPath = GetAssetFullPath("ArchitectureSwitch.dll", "net6.0"); + ExecuteApplication($"{s_privateX64Installation}/{GetMuxerName}", $"test {buildAssemblyPath} --framework net6.0 --arch arm64", out stdOut, out _, out _, env, projectDirectory); + AssertSwitch(stdOut); + + static void AssertSwitch(string output) + { + Assert.IsTrue(Regex.IsMatch(output.Replace(@"\", "/"), $"Runtime location: .*{GetDefaultLocation.Replace(@"\", "/")}.*shared.*Microsoft.NETCore.App"), "Unexpected runtime location"); + Assert.IsTrue(output.Contains("OSArchitecture: ARM64"), "Unexpected OSArchitecture"); + Assert.IsTrue(output.Contains("ProcessArchitecture: ARM64"), "Unexpected ProcessArchitecture"); } + } - [TestMethod] - [DataRow(true, false)] - [DataRow(false, true)] - public void PrivateX64BuildToDOTNET_ROOTS_EnvironmentVariables(bool dotnetRoot, bool dotnetRootARM64) + [TestMethod] + [DataRow(true, false)] + [DataRow(false, true)] + public void PrivateX64BuildToDOTNET_ROOTS_EnvironmentVariables(bool dotnetRoot, bool dotnetRootArm64) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - return; - } + return; + } - var env = new Dictionary(); - env["DOTNET_ROOT"] = null; - env["DOTNET_MULTILEVEL_LOOKUP"] = "0"; - string privateInstallationMuxer = Path.Combine(privateX64Installation, GetMuxerName); - - var projectName = "ArchitectureSwitch.csproj"; - var projectPath = this.GetProjectFullPath(projectName); - var projectDirectory = Path.GetDirectoryName(projectPath); - - // Verify native architecture - ExecuteApplication(privateInstallationMuxer, $"test {projectPath} --framework net6.0", out string stdOut, out string stdError, out int exitCode, env, projectDirectory); - Assert.IsTrue(Regex.IsMatch(stdOut.Replace(@"\", "/"), $"Runtime location: .*{privateX64Installation.Replace(@"\", "/")}.*shared.*Microsoft.NETCore.App"), "Unexpected runtime location"); - Assert.IsTrue(stdOut.Contains("OSArchitecture: X64"), "Unexpected OSArchitecture"); - Assert.IsTrue(stdOut.Contains("ProcessArchitecture: X64"), "Unexpected ProcessArchitecture"); - - env.Clear(); - env["DOTNET_ROOT"] = null; - env["DOTNET_MULTILEVEL_LOOKUP"] = "0"; - if (dotnetRoot) - { - env["DOTNET_ROOT"] = GetDefaultLocation; - } + var env = new Dictionary + { + ["DOTNET_ROOT"] = null, + ["DOTNET_MULTILEVEL_LOOKUP"] = "0" + }; + string privateInstallationMuxer = Path.Combine(s_privateX64Installation, GetMuxerName); + + var projectName = "ArchitectureSwitch.csproj"; + var projectPath = GetProjectFullPath(projectName); + var projectDirectory = Path.GetDirectoryName(projectPath); + + // Verify native architecture + ExecuteApplication(privateInstallationMuxer, $"test {projectPath} --framework net6.0", out string stdOut, out _, out _, env, projectDirectory); + Assert.IsTrue(Regex.IsMatch(stdOut.Replace(@"\", "/"), $"Runtime location: .*{s_privateX64Installation.Replace(@"\", "/")}.*shared.*Microsoft.NETCore.App"), "Unexpected runtime location"); + Assert.IsTrue(stdOut.Contains("OSArchitecture: X64"), "Unexpected OSArchitecture"); + Assert.IsTrue(stdOut.Contains("ProcessArchitecture: X64"), "Unexpected ProcessArchitecture"); + + env.Clear(); + env["DOTNET_ROOT"] = null; + env["DOTNET_MULTILEVEL_LOOKUP"] = "0"; + if (dotnetRoot) + { + env["DOTNET_ROOT"] = GetDefaultLocation; + } - if (dotnetRootARM64) - { - env["DOTNET_ROOT_ARM64"] = GetDefaultLocation; - } + if (dotnetRootArm64) + { + env["DOTNET_ROOT_ARM64"] = GetDefaultLocation; + } - // Verify switch using csproj - ExecuteApplication($"{privateX64Installation}/{GetMuxerName}", $"test {projectPath} --framework net6.0 --arch arm64", out stdOut, out stdError, out exitCode, env, projectDirectory); - AssertSwitch(stdOut); + // Verify switch using csproj + ExecuteApplication($"{s_privateX64Installation}/{GetMuxerName}", $"test {projectPath} --framework net6.0 --arch arm64", out stdOut, out _, out _, env, projectDirectory); + AssertSwitch(stdOut); - // Verify switch using test container - var buildAssemblyPath = GetAssetFullPath("ArchitectureSwitch.dll", "net6.0"); - ExecuteApplication($"{privateX64Installation}/{GetMuxerName}", $"test {buildAssemblyPath} --framework net6.0 --arch arm64", out stdOut, out stdError, out exitCode, env, projectDirectory); - AssertSwitch(stdOut); + // Verify switch using test container + var buildAssemblyPath = GetAssetFullPath("ArchitectureSwitch.dll", "net6.0"); + ExecuteApplication($"{s_privateX64Installation}/{GetMuxerName}", $"test {buildAssemblyPath} --framework net6.0 --arch arm64", out stdOut, out _, out _, env, projectDirectory); + AssertSwitch(stdOut); - void AssertSwitch(string output) - { - Assert.IsTrue(Regex.IsMatch(output.Replace(@"\", "/"), $"Runtime location: .*{GetDefaultLocation.Replace(@"\", "/")}.*shared.*Microsoft.NETCore.App"), "Unexpected runtime location"); - Assert.IsTrue(output.Contains("OSArchitecture: Arm64"), "Unexpected OSArchitecture"); - Assert.IsTrue(output.Contains("ProcessArchitecture: Arm64"), "Unexpected ProcessArchitecture"); - Assert.IsTrue(dotnetRoot ? output.Contains($"DOTNET_ROOT: {GetDefaultLocation}") : true, "Unexpected DOTNET_ROOT var"); - Assert.IsTrue(dotnetRootARM64 ? output.Contains($"DOTNET_ROOT_ARM64: {GetDefaultLocation}") : true, "Unexpected DOTNET_ROOT_ARM64 var"); - } + void AssertSwitch(string output) + { + Assert.IsTrue(Regex.IsMatch(output.Replace(@"\", "/"), $"Runtime location: .*{GetDefaultLocation.Replace(@"\", "/")}.*shared.*Microsoft.NETCore.App"), "Unexpected runtime location"); + Assert.IsTrue(output.Contains("OSArchitecture: ARM64"), "Unexpected OSArchitecture"); + Assert.IsTrue(output.Contains("ProcessArchitecture: ARM64"), "Unexpected ProcessArchitecture"); + Assert.IsTrue(!dotnetRoot || output.Contains($"DOTNET_ROOT: {GetDefaultLocation}"), "Unexpected DOTNET_ROOT var"); + Assert.IsTrue(!dotnetRootArm64 || output.Contains($"DOTNET_ROOT_ARM64: {GetDefaultLocation}"), "Unexpected DOTNET_ROOT_ARM64 var"); } + } - [TestMethod] - public void SilentlyForceX64() + [TestMethod] + public void SilentlyForceX64() + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - return; - } - - var projectName = "ArchitectureSwitch.csproj"; - var projectPath = this.GetProjectFullPath(projectName); - var projectDirectory = Path.GetDirectoryName(projectPath); + return; + } - var env = new Dictionary(); - env["DOTNET_ROOT"] = null; - env["DOTNET_MULTILEVEL_LOOKUP"] = "0"; + var projectName = "ArchitectureSwitch.csproj"; + var projectPath = GetProjectFullPath(projectName); + var projectDirectory = Path.GetDirectoryName(projectPath); - ExecuteApplication(GetDefaultDotnetMuxerLocation, $"test {projectPath} --framework {GetFrameworkVersionToForceToX64}", out string stdOut, out string stdError, out int exitCode, env, projectDirectory); - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - Assert.IsTrue(stdOut.Contains("Runtime location: /usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App")); - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - Assert.IsTrue(stdOut.Contains($@"Runtime location: {Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet\x64\shared\Microsoft.NETCore.App")); - } - Assert.IsTrue(stdOut.Contains("OSArchitecture: X64")); - Assert.IsTrue(stdOut.Contains("ProcessArchitecture: X64")); + var env = new Dictionary + { + ["DOTNET_ROOT"] = null, + ["DOTNET_MULTILEVEL_LOOKUP"] = "0" + }; + ExecuteApplication(GetDefaultDotnetMuxerLocation, $"test {projectPath} --framework {GetFrameworkVersionToForceToX64}", out string stdOut, out _, out _, env, projectDirectory); + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + Assert.IsTrue(stdOut.Contains("Runtime location: /usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App")); } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + Assert.IsTrue(stdOut.Contains($@"Runtime location: {Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet\x64\shared\Microsoft.NETCore.App")); + } + Assert.IsTrue(stdOut.Contains("OSArchitecture: X64")); + Assert.IsTrue(stdOut.Contains("ProcessArchitecture: X64")); + } - private static string GetMuxerName => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "dotnet" : "dotnet.exe"; + private static string GetMuxerName => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "dotnet" : "dotnet.exe"; - private static string GetX64InstallationFolder => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? - "/usr/local/share/dotnet/x64" : - $@"{Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet\x64"; + private static string GetX64InstallationFolder => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? + "/usr/local/share/dotnet/x64" : + $@"{Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet\x64"; - private static string GetFrameworkVersionToForceToX64 => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? - "net5.0" : - "netcoreapp3.1"; + private static string GetFrameworkVersionToForceToX64 => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? + "net5.0" : + "netcoreapp3.1"; - private static string GetDefaultLocation => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? - $"/usr/local/share/dotnet" : - $@"{Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet"; + private static string GetDefaultLocation => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? + $"/usr/local/share/dotnet" : + $@"{Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet"; - private static string GetDefaultDotnetMuxerLocation => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? - $"{GetDefaultLocation}/{GetMuxerName}" : - $@"{GetDefaultLocation}\{GetMuxerName}"; + private static string GetDefaultDotnetMuxerLocation => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? + $"{GetDefaultLocation}/{GetMuxerName}" : + $@"{GetDefaultLocation}\{GetMuxerName}"; - private static void CopyAll(DirectoryInfo source, DirectoryInfo target) - { - Directory.CreateDirectory(target.FullName); + private static void CopyAll(DirectoryInfo source, DirectoryInfo target) + { + Directory.CreateDirectory(target.FullName); - // Copy each file into the new directory. - foreach (FileInfo fi in source.GetFiles()) - { - fi.CopyTo(Path.Combine(target.FullName, fi.Name), true); - } + // Copy each file into the new directory. + foreach (FileInfo fi in source.GetFiles()) + { + fi.CopyTo(Path.Combine(target.FullName, fi.Name), true); + } - // Copy each subdirectory using recursion. - foreach (DirectoryInfo diSourceSubDir in source.GetDirectories()) - { - DirectoryInfo nextTargetSubDir = - target.CreateSubdirectory(diSourceSubDir.Name); - CopyAll(diSourceSubDir, nextTargetSubDir); - } + // Copy each subdirectory using recursion. + foreach (DirectoryInfo diSourceSubDir in source.GetDirectories()) + { + DirectoryInfo nextTargetSubDir = + target.CreateSubdirectory(diSourceSubDir.Name); + CopyAll(diSourceSubDir, nextTargetSubDir); } } } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/DotnetTestTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/DotnetTestTests.cs index de190cb17f..28363f50dd 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/DotnetTestTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/DotnetTestTests.cs @@ -1,78 +1,77 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.AcceptanceTests; + +using VisualStudio.TestTools.UnitTesting; - [TestClass] - public class DotnetTestTests : AcceptanceTestBase +[TestClass] +public class DotnetTestTests : AcceptanceTestBase +{ + [TestMethod] + // patched dotnet is not published on non-windows systems + [TestCategory("Windows-Review")] + [NetCoreTargetFrameworkDataSource] + public void RunDotnetTestWithCsproj(RunnerInfo runnerInfo) { - [TestMethod] - // patched dotnet is not published on non-windows systems - [TestCategory("Windows-Review")] - [NetCoreTargetFrameworkDataSource] - public void RunDotnetTestWithCsproj(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + SetTestEnvironment(_testEnvironment, runnerInfo); - var projectName = "SimpleTestProject.csproj"; - var projectPath = this.GetProjectFullPath(projectName); + var projectName = "SimpleTestProject.csproj"; + var projectPath = GetProjectFullPath(projectName); - this.InvokeDotnetTest($@"{projectPath} --logger:""Console;Verbosity=normal"""); + InvokeDotnetTest($@"{projectPath} --logger:""Console;Verbosity=normal"""); - // ensure our dev version is used - this.StdOutputContains("-dev"); - this.ValidateSummaryStatus(1, 1, 1); - this.ExitCodeEquals(1); - } + // ensure our dev version is used + StdOutputContains("-dev"); + ValidateSummaryStatus(1, 1, 1); + ExitCodeEquals(1); + } - [TestMethod] - // patched dotnet is not published on non-windows systems - [TestCategory("Windows-Review")] - [NetCoreTargetFrameworkDataSource] - public void RunDotnetTestWithDll(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + [TestMethod] + // patched dotnet is not published on non-windows systems + [TestCategory("Windows-Review")] + [NetCoreTargetFrameworkDataSource] + public void RunDotnetTestWithDll(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); - var assemblyPath = this.BuildMultipleAssemblyPath("SimpleTestProject.dll").Trim('\"'); - this.InvokeDotnetTest($@"{assemblyPath} --logger:""Console;Verbosity=normal"""); + var assemblyPath = BuildMultipleAssemblyPath("SimpleTestProject.dll").Trim('\"'); + InvokeDotnetTest($@"{assemblyPath} --logger:""Console;Verbosity=normal"""); - // ensure our dev version is used - this.StdOutputContains("-dev"); - this.ValidateSummaryStatus(1, 1, 1); - this.ExitCodeEquals(1); - } + // ensure our dev version is used + StdOutputContains("-dev"); + ValidateSummaryStatus(1, 1, 1); + ExitCodeEquals(1); + } - [TestMethod] - // patched dotnet is not published on non-windows systems - [TestCategory("Windows-Review")] - [NetCoreTargetFrameworkDataSource] - public void PassInlineSettings(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + [TestMethod] + // patched dotnet is not published on non-windows systems + [TestCategory("Windows-Review")] + [NetCoreTargetFrameworkDataSource] + public void PassInlineSettings(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); - var projectName = "ParametrizedTestProject.csproj"; - var projectPath = this.GetProjectFullPath(projectName); - this.InvokeDotnetTest($@"{projectPath} --logger:""Console;Verbosity=normal"" -- TestRunParameters.Parameter(name =\""weburl\"", value=\""http://localhost//def\"")"); - this.ValidateSummaryStatus(1, 0, 0); - this.ExitCodeEquals(0); - } + var projectName = "ParametrizedTestProject.csproj"; + var projectPath = GetProjectFullPath(projectName); + InvokeDotnetTest($@"{projectPath} --logger:""Console;Verbosity=normal"" -- TestRunParameters.Parameter(name =\""weburl\"", value=\""http://localhost//def\"")"); + ValidateSummaryStatus(1, 0, 0); + ExitCodeEquals(0); + } - [TestMethod] - // patched dotnet is not published on non-windows systems - [TestCategory("Windows-Review")] - [NetCoreTargetFrameworkDataSource] - public void PassInlineSettingsToDll(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + [TestMethod] + // patched dotnet is not published on non-windows systems + [TestCategory("Windows-Review")] + [NetCoreTargetFrameworkDataSource] + public void PassInlineSettingsToDll(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); - var assemblyPath = this.BuildMultipleAssemblyPath("ParametrizedTestProject.dll").Trim('\"'); - this.InvokeDotnetTest($@"{assemblyPath} --logger:""Console;Verbosity=normal"" -- TestRunParameters.Parameter(name=\""weburl\"", value=\""http://localhost//def\"")"); + var assemblyPath = BuildMultipleAssemblyPath("ParametrizedTestProject.dll").Trim('\"'); + InvokeDotnetTest($@"{assemblyPath} --logger:""Console;Verbosity=normal"" -- TestRunParameters.Parameter(name=\""weburl\"", value=\""http://localhost//def\"")"); - this.ValidateSummaryStatus(1, 0, 0); - this.ExitCodeEquals(0); - } + ValidateSummaryStatus(1, 0, 0); + ExitCodeEquals(0); } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/EventLogCollectorTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/EventLogCollectorTests.cs index b2f6f47ef3..4f8f416c34 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/EventLogCollectorTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/EventLogCollectorTests.cs @@ -1,71 +1,72 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.AcceptanceTests; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestClass] + +[TestClass] +[TestCategory("Windows-Review")] +public class EventLogCollectorTests : AcceptanceTestBase +{ + // Fails randomly https://ci.dot.net/job/Microsoft_vstest/job/master/job/Windows_NT_Release_prtest/2084/console + // https://ci.dot.net/job/Microsoft_vstest/job/master/job/Windows_NT_Debug_prtest/2085/console + [Ignore] + [TestMethod] [TestCategory("Windows-Review")] - public class EventLogCollectorTests : AcceptanceTestBase + [NetFullTargetFrameworkDataSource] + public void EventLogDataCollectorShoudCreateLogFileHavingEvents(RunnerInfo runnerInfo) { - // Fails randomly https://ci.dot.net/job/Microsoft_vstest/job/master/job/Windows_NT_Release_prtest/2084/console - // https://ci.dot.net/job/Microsoft_vstest/job/master/job/Windows_NT_Debug_prtest/2085/console - [Ignore] - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - public void EventLogDataCollectorShoudCreateLogFileHavingEvents(RunnerInfo runnerInfo) - { - SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - var assemblyPaths = this.testEnvironment.GetTestAsset("EventLogUnitTestProject.dll"); + SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + var assemblyPaths = _testEnvironment.GetTestAsset("EventLogUnitTestProject.dll"); - string runSettings = this.GetRunsettingsFilePath(tempDir); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), runSettings, this.FrameworkArgValue, resultsDirectory: tempDir.Path); + string runSettings = GetRunsettingsFilePath(tempDir); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), runSettings, FrameworkArgValue, resultsDirectory: tempDir.Path); - this.InvokeVsTest(arguments); + InvokeVsTest(arguments); - this.ValidateSummaryStatus(3, 0, 0); - this.VaildateDataCollectorOutput(tempDir); - this.StdOutputDoesNotContains("An exception occurred while collecting final entries from the event log"); - this.StdErrorDoesNotContains("event log has encountered an exception, some events might get lost"); - this.StdOutputDoesNotContains("event log may have been cleared during collection; some events may not have been collected"); - this.StdErrorDoesNotContains("Unable to read event log"); - } + ValidateSummaryStatus(3, 0, 0); + VaildateDataCollectorOutput(tempDir); + StdOutputDoesNotContains("An exception occurred while collecting final entries from the event log"); + StdErrorDoesNotContains("event log has encountered an exception, some events might get lost"); + StdOutputDoesNotContains("event log may have been cleared during collection; some events may not have been collected"); + StdErrorDoesNotContains("Unable to read event log"); + } - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - public void EventLogDataCollectorShoudCreateLogFileWithoutEventsIfEventsAreNotLogged(RunnerInfo runnerInfo) - { - SetTestEnvironment(this.testEnvironment, runnerInfo); - var assemblyPaths = this.testEnvironment.GetTestAsset("SimpleTestProject.dll"); - using var tempDir = new TempDirectory(); + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + public void EventLogDataCollectorShoudCreateLogFileWithoutEventsIfEventsAreNotLogged(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + var assemblyPaths = _testEnvironment.GetTestAsset("SimpleTestProject.dll"); + using var tempDir = new TempDirectory(); - string runSettings = this.GetRunsettingsFilePath(tempDir); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), runSettings, this.FrameworkArgValue, resultsDirectory: tempDir.Path); + string runSettings = GetRunsettingsFilePath(tempDir); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), runSettings, FrameworkArgValue, resultsDirectory: tempDir.Path); - this.InvokeVsTest(arguments); + InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 1, 1); - this.StdOutputDoesNotContains("An exception occurred while collecting final entries from the event log"); - this.StdErrorDoesNotContains("event log has encountered an exception, some events might get lost"); - this.StdOutputDoesNotContains("event log may have been cleared during collection; some events may not have been collected"); - this.StdErrorDoesNotContains("Unable to read event log"); - } + ValidateSummaryStatus(1, 1, 1); + StdOutputDoesNotContains("An exception occurred while collecting final entries from the event log"); + StdErrorDoesNotContains("event log has encountered an exception, some events might get lost"); + StdOutputDoesNotContains("event log may have been cleared during collection; some events may not have been collected"); + StdErrorDoesNotContains("Unable to read event log"); + } - private string GetRunsettingsFilePath(TempDirectory tempDirectory) - { - var runsettingsPath = Path.Combine(tempDirectory.Path, "test_" + Guid.NewGuid() + ".runsettings"); + private string GetRunsettingsFilePath(TempDirectory tempDirectory) + { + var runsettingsPath = Path.Combine(tempDirectory.Path, "test_" + Guid.NewGuid() + ".runsettings"); - string runSettingsXml = @" + string runSettingsXml = @" 0 @@ -81,69 +82,70 @@ private string GetRunsettingsFilePath(TempDirectory tempDirectory) "; - File.WriteAllText(runsettingsPath, runSettingsXml); - return runsettingsPath; - } + File.WriteAllText(runsettingsPath, runSettingsXml); + return runsettingsPath; + } - private void VaildateDataCollectorOutput(TempDirectory tempDir) + private void VaildateDataCollectorOutput(TempDirectory tempDir) + { + // Verify attachments + var di = new DirectoryInfo(tempDir.Path); + var resultFiles = di.EnumerateFiles("Event Log.xml", SearchOption.AllDirectories) + .OrderBy(d => d.CreationTime) + .Select(d => d.FullName) + .ToList(); + + Assert.AreEqual(4, resultFiles.Count); + StdOutputContains("Event Log.xml"); + + var fileContent1 = File.ReadAllText(resultFiles[0]); + var fileContent2 = File.ReadAllText(resultFiles[1]); + var fileContent3 = File.ReadAllText(resultFiles[2]); + var fileContent4 = File.ReadAllText(resultFiles[3]); + + var eventIdsDics = new Dictionary { - // Verify attachments - var di = new DirectoryInfo(tempDir.Path); - var resultFiles = di.EnumerateFiles("Event Log.xml", SearchOption.AllDirectories) - .OrderBy(d => d.CreationTime) - .Select(d => d.FullName) - .ToList(); - - Assert.AreEqual(4, resultFiles.Count); - this.StdOutputContains("Event Log.xml"); - - var fileContent1 = File.ReadAllText(resultFiles[0]); - var fileContent2 = File.ReadAllText(resultFiles[1]); - var fileContent3 = File.ReadAllText(resultFiles[2]); - var fileContent4 = File.ReadAllText(resultFiles[3]); - - var eventIdsDics = new Dictionary(); - eventIdsDics.Add(new[] { "110", "111", "112" }, false); - eventIdsDics.Add(new[] { "220", "221", "222", "223" }, false); - eventIdsDics.Add(new[] { "330", "331", "332" }, false); - - // Since there is no guaranty that test will run in a particular order, we will check file for all available list of ids - Assert.IsTrue(this.VerifyOrder2(fileContent1, eventIdsDics), string.Format("Event log file content: {0}", fileContent1)); - Assert.IsTrue(this.VerifyOrder2(fileContent2, eventIdsDics), string.Format("Event log file content: {0}", fileContent2)); - Assert.IsTrue(this.VerifyOrder2(fileContent3, eventIdsDics), string.Format("Event log file content: {0}", fileContent3)); - - Assert.IsTrue(this.VerifyOrder(fileContent4, new[] { "110", "111", "112", "220", "221", "222", "223", "330", "331", "332" }), string.Format("Event log file content: {0}", fileContent4)); - } + { new[] { "110", "111", "112" }, false }, + { new[] { "220", "221", "222", "223" }, false }, + { new[] { "330", "331", "332" }, false } + }; + + // Since there is no guaranty that test will run in a particular order, we will check file for all available list of ids + Assert.IsTrue(VerifyOrder2(fileContent1, eventIdsDics), string.Format("Event log file content: {0}", fileContent1)); + Assert.IsTrue(VerifyOrder2(fileContent2, eventIdsDics), string.Format("Event log file content: {0}", fileContent2)); + Assert.IsTrue(VerifyOrder2(fileContent3, eventIdsDics), string.Format("Event log file content: {0}", fileContent3)); + + Assert.IsTrue(VerifyOrder(fileContent4, new[] { "110", "111", "112", "220", "221", "222", "223", "330", "331", "332" }), string.Format("Event log file content: {0}", fileContent4)); + } - private bool VerifyOrder2(string content, Dictionary eventIdsDics) + private bool VerifyOrder2(string content, Dictionary eventIdsDics) + { + foreach (var eventIds in eventIdsDics) { - foreach (var eventIds in eventIdsDics) + if (eventIds.Value == false) { - if (eventIds.Value == false) + if (VerifyOrder(content, eventIds.Key)) { - if (VerifyOrder(content, eventIds.Key)) - { - eventIdsDics[eventIds.Key] = true; - return true; - } + eventIdsDics[eventIds.Key] = true; + return true; } } - return false; } + return false; + } - private bool VerifyOrder(string content, string[] eventIds) + private bool VerifyOrder(string content, string[] eventIds) + { + for (int i = 0; i < eventIds.Length; i++) { - for (int i = 0; i < eventIds.Length; i++) + int currentIndex = 0; + currentIndex = content.IndexOf(eventIds[i], currentIndex); + if (currentIndex == -1) { - int currentIndex = 0; - currentIndex = content.IndexOf(eventIds[i], currentIndex); - if (currentIndex == -1) - { - return false; - } + return false; } - - return true; } + + return true; } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs index ece914b184..ab2cb51c0c 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs @@ -1,354 +1,354 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests +namespace Microsoft.TestPlatform.AcceptanceTests; + +using System; +using System.IO; + +using global::TestPlatform.TestUtilities; + +using TestUtilities; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class ExecutionTests : AcceptanceTestBase { - using System; - using System.IO; + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetCoreTargetFrameworkDataSource] + public void RunMultipleTestAssemblies(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + + var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject.dll", "SimpleTestProject2.dll").Trim('\"'); - using global::TestPlatform.TestUtilities; + InvokeVsTestForExecution(assemblyPaths, GetTestAdapterPath(), FrameworkArgValue, string.Empty); - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; + ValidateSummaryStatus(2, 2, 2); + ExitCodeEquals(1); // failing tests + } - [TestClass] - public class ExecutionTests : AcceptanceTestBase + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetCoreTargetFrameworkDataSource] + public void RunMultipleTestAssembliesWithoutTestAdapterPath(RunnerInfo runnerInfo) { - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - [NetCoreTargetFrameworkDataSource] - public void RunMultipleTestAssemblies(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + SetTestEnvironment(_testEnvironment, runnerInfo); - var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject.dll", "SimpleTestProject2.dll").Trim('\"'); + var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject.dll").Trim('\"'); + var xunitAssemblyPath = _testEnvironment.TargetFramework.Equals("net451") ? + _testEnvironment.GetTestAsset("XUTestProject.dll", "net46") : + _testEnvironment.GetTestAsset("XUTestProject.dll"); - this.InvokeVsTestForExecution(assemblyPaths, this.GetTestAdapterPath(), this.FrameworkArgValue, string.Empty); + assemblyPaths = string.Concat(assemblyPaths, "\" \"", xunitAssemblyPath); + InvokeVsTestForExecution(assemblyPaths, string.Empty, FrameworkArgValue, string.Empty); - this.ValidateSummaryStatus(2, 2, 2); - this.ExitCodeEquals(1); // failing tests - } + ValidateSummaryStatus(2, 2, 1); + ExitCodeEquals(1); // failing tests + } - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - [NetCoreTargetFrameworkDataSource] - public void RunMultipleTestAssembliesWithoutTestAdapterPath(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + // We cannot run this test on Mac/Linux because we're trying to switch the arch between x64 and x86 + // and after --arch feature implementation we won't find correct muxer on CI. + [TestCategory("Windows")] + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunMultipleTestAssembliesInParallel(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject.dll", "SimpleTestProject2.dll").Trim('\"'); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /Parallel"); + arguments = string.Concat(arguments, " /Platform:x86"); + arguments += GetDiagArg(tempDir.Path); + + // for the desktop we will run testhost.x86 in two copies, but for core + // we will run a combination of testhost.x86 and dotnet, where the dotnet will be + // the test console, and sometimes it will be the test host (e.g dotnet, dotnet, testhost.x86, or dotnet, testhost.x86, testhost.x86) + // based on the target framework + int expectedNumOfProcessCreated = 2; + var testHostProcessNames = IsDesktopTargetFramework() + ? new[] { "testhost.x86", } + : new[] { "testhost.x86", "testhost", }; + + InvokeVsTest(arguments); + + AssertExpectedNumberOfHostProcesses(expectedNumOfProcessCreated, tempDir.Path, testHostProcessNames); + ValidateSummaryStatus(2, 2, 2); + ExitCodeEquals(1); // failing tests + } + + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetCoreTargetFrameworkDataSource] + public void TestSessionTimeOutTests(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var assemblyPaths = + BuildMultipleAssemblyPath("SimpleTestProject3.dll").Trim('\"'); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /TestCaseFilter:TestSessionTimeoutTest"); + + // set TestSessionTimeOut = 7 sec + arguments = string.Concat(arguments, " -- RunConfiguration.TestSessionTimeout=7000"); + InvokeVsTest(arguments); + + ExitCodeEquals(1); + StdErrorContains("Test Run Aborted."); + StdErrorContains("Aborting test run: test run timeout of 7000 milliseconds exceeded."); + StdOutputDoesNotContains("Total tests: 6"); + } - var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject.dll").Trim('\"'); - var xunitAssemblyPath = this.testEnvironment.TargetFramework.Equals("net451") ? - testEnvironment.GetTestAsset("XUTestProject.dll", "net46") : - testEnvironment.GetTestAsset("XUTestProject.dll"); + [TestMethod] + [NetCoreTargetFrameworkDataSource] + public void TestPlatformShouldBeCompatibleWithOldTestHost(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - assemblyPaths = string.Concat(assemblyPaths, "\" \"", xunitAssemblyPath); - this.InvokeVsTestForExecution(assemblyPaths, string.Empty, this.FrameworkArgValue, string.Empty); + var assemblyPaths = BuildMultipleAssemblyPath("SampleProjectWithOldTestHost.dll").Trim('\"'); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - this.ValidateSummaryStatus(2, 2, 1); - this.ExitCodeEquals(1); // failing tests - } + InvokeVsTest(arguments); - // We cannot run this test on Mac/Linux because we're trying to switch the arch between x64 and x86 - // and after --arch feature implementation we won't find correct muxer on CI. - [TestCategory("Windows")] - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunMultipleTestAssembliesInParallel(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject.dll", "SimpleTestProject2.dll").Trim('\"'); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /Parallel"); - arguments = string.Concat(arguments, " /Platform:x86"); - arguments += GetDiagArg(tempDir.Path); - - // for the desktop we will run testhost.x86 in two copies, but for core - // we will run a combination of testhost.x86 and dotnet, where the dotnet will be - // the test console, and sometimes it will be the test host (e.g dotnet, dotnet, testhost.x86, or dotnet, testhost.x86, testhost.x86) - // based on the target framework - int expectedNumOfProcessCreated = 2; - var testHostProcessNames = this.IsDesktopTargetFramework() - ? new[] { "testhost.x86", } - : new[] { "testhost.x86", "testhost", }; - - this.InvokeVsTest(arguments); - - AssertExpectedNumberOfHostProcesses(expectedNumOfProcessCreated, tempDir.Path, testHostProcessNames); - this.ValidateSummaryStatus(2, 2, 2); - this.ExitCodeEquals(1); // failing tests - } + ValidateSummaryStatus(1, 0, 0); + ExitCodeEquals(0); + } - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - [NetCoreTargetFrameworkDataSource] - public void TestSessionTimeOutTests(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var assemblyPaths = - this.BuildMultipleAssemblyPath("SimpleTestProject3.dll").Trim('\"'); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /TestCaseFilter:TestSessionTimeoutTest"); - - // set TestSessionTimeOut = 7 sec - arguments = string.Concat(arguments, " -- RunConfiguration.TestSessionTimeout=7000"); - this.InvokeVsTest(arguments); - - this.ExitCodeEquals(1); - this.StdErrorContains("Test Run Aborted."); - this.StdErrorContains("Aborting test run: test run timeout of 7000 milliseconds exceeded."); - this.StdOutputDoesNotContains("Total tests: 6"); - } + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetCoreTargetFrameworkDataSource] + public void WorkingDirectoryIsSourceDirectory(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - [TestMethod] - [NetCoreTargetFrameworkDataSource] - public void TestPlatformShouldBeCompatibleWithOldTestHost(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject3.dll").Trim('\"'); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /tests:WorkingDirectoryTest"); - var assemblyPaths = this.BuildMultipleAssemblyPath("SampleProjectWithOldTestHost.dll").Trim('\"'); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + InvokeVsTest(arguments); - this.InvokeVsTest(arguments); + ValidateSummaryStatus(1, 0, 0); + ExitCodeEquals(0); + } - this.ValidateSummaryStatus(1, 0, 0); - this.ExitCodeEquals(0); - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void StackOverflowExceptionShouldBeLoggedToConsoleAndDiagLogFile(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - [NetCoreTargetFrameworkDataSource] - public void WorkingDirectoryIsSourceDirectory(RunnerInfo runnerInfo) + if (IntegrationTestEnvironment.BuildConfiguration.Equals("release", StringComparison.OrdinalIgnoreCase)) { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + // On release, x64 builds, recursive calls may be replaced with loops (tail call optimization) + Assert.Inconclusive("On StackOverflowException testhost not exited in release configuration."); + return; + } - var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject3.dll").Trim('\"'); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /tests:WorkingDirectoryTest"); + var diagLogFilePath = Path.Combine(tempDir.Path, $"std_error_log_{Guid.NewGuid()}.txt"); + File.Delete(diagLogFilePath); - this.InvokeVsTest(arguments); + var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject3.dll").Trim('\"'); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /testcasefilter:ExitWithStackoverFlow"); + arguments = string.Concat(arguments, $" /diag:{diagLogFilePath}"); - this.ValidateSummaryStatus(1, 0, 0); - this.ExitCodeEquals(0); - } + InvokeVsTest(arguments); - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void StackOverflowExceptionShouldBeLoggedToConsoleAndDiagLogFile(RunnerInfo runnerInfo) + var errorMessage = "Process is terminated due to StackOverflowException."; + if (runnerInfo.TargetFramework.StartsWith("netcoreapp2.")) { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - if (IntegrationTestEnvironment.BuildConfiguration.Equals("release", StringComparison.OrdinalIgnoreCase)) - { - // On release, x64 builds, recursive calls may be replaced with loops (tail call optimization) - Assert.Inconclusive("On StackOverflowException testhost not exited in release configuration."); - return; - } - - var diagLogFilePath = Path.Combine(tempDir.Path, $"std_error_log_{Guid.NewGuid()}.txt"); - File.Delete(diagLogFilePath); - - var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject3.dll").Trim('\"'); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /testcasefilter:ExitWithStackoverFlow"); - arguments = string.Concat(arguments, $" /diag:{diagLogFilePath}"); - - this.InvokeVsTest(arguments); - - var errorMessage = "Process is terminated due to StackOverflowException."; - if (runnerInfo.TargetFramework.StartsWith("netcoreapp2.")) - { - errorMessage = "Process is terminating due to StackOverflowException."; - } - - this.ExitCodeEquals(1); - FileAssert.Contains(diagLogFilePath, errorMessage); - this.StdErrorContains(errorMessage); - File.Delete(diagLogFilePath); + errorMessage = "Process is terminating due to StackOverflowException."; } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void UnhandleExceptionExceptionShouldBeLoggedToDiagLogFile(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + ExitCodeEquals(1); + FileAssert.Contains(diagLogFilePath, errorMessage); + StdErrorContains(errorMessage); + File.Delete(diagLogFilePath); + } + + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void UnhandleExceptionExceptionShouldBeLoggedToDiagLogFile(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var diagLogFilePath = Path.Combine(tempDir.Path, $"std_error_log_{Guid.NewGuid()}.txt"); - File.Delete(diagLogFilePath); + var diagLogFilePath = Path.Combine(tempDir.Path, $"std_error_log_{Guid.NewGuid()}.txt"); + File.Delete(diagLogFilePath); - var assemblyPaths = - this.BuildMultipleAssemblyPath("SimpleTestProject3.dll").Trim('\"'); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /testcasefilter:ExitwithUnhandleException"); - arguments = string.Concat(arguments, $" /diag:{diagLogFilePath}"); + var assemblyPaths = + BuildMultipleAssemblyPath("SimpleTestProject3.dll").Trim('\"'); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /testcasefilter:ExitwithUnhandleException"); + arguments = string.Concat(arguments, $" /diag:{diagLogFilePath}"); - this.InvokeVsTest(arguments); + InvokeVsTest(arguments); - var errorFirstLine = "Test host standard error line: Unhandled Exception: System.InvalidOperationException: Operation is not valid due to the current state of the object."; - FileAssert.Contains(diagLogFilePath, errorFirstLine); - File.Delete(diagLogFilePath); - } + var errorFirstLine = "Test host standard error line: Unhandled Exception: System.InvalidOperationException: Operation is not valid due to the current state of the object."; + FileAssert.Contains(diagLogFilePath, errorFirstLine); + File.Delete(diagLogFilePath); + } - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - public void IncompatibleSourcesWarningShouldBeDisplayedInTheConsole(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + public void IncompatibleSourcesWarningShouldBeDisplayedInTheConsole(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var expectedWarningContains = @"Following DLL(s) do not match current settings, which are .NETFramework,Version=v4.5.1 framework and X86 platform. SimpleTestProject3.dll is built for Framework .NETFramework,Version=v4.5.1 and Platform X64"; - var assemblyPaths = - this.BuildMultipleAssemblyPath("SimpleTestProject3.dll", "SimpleTestProjectx86.dll").Trim('\"'); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /testcasefilter:PassingTestx86"); + var expectedWarningContains = @"Following DLL(s) do not match current settings, which are .NETFramework,Version=v4.5.1 framework and X86 platform. SimpleTestProject3.dll is built for Framework .NETFramework,Version=v4.5.1 and Platform X64"; + var assemblyPaths = + BuildMultipleAssemblyPath("SimpleTestProject3.dll", "SimpleTestProjectx86.dll").Trim('\"'); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /testcasefilter:PassingTestx86"); - this.InvokeVsTest(arguments); + InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 0, 0); - this.ExitCodeEquals(0); + ValidateSummaryStatus(1, 0, 0); + ExitCodeEquals(0); - // When both x64 & x86 DLL is passed x64 dll will be ignored. - this.StdOutputContains(expectedWarningContains); - } + // When both x64 & x86 DLL is passed x64 dll will be ignored. + StdOutputContains(expectedWarningContains); + } - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - public void NoIncompatibleSourcesWarningShouldBeDisplayedInTheConsole(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + public void NoIncompatibleSourcesWarningShouldBeDisplayedInTheConsole(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var expectedWarningContains = @"Following DLL(s) do not match current settings, which are .NETFramework,Version=v4.5.1 framework and X86 platform. SimpleTestProjectx86 is built for Framework .NETFramework,Version=v4.5.1 and Platform X86"; - var assemblyPaths = - this.BuildMultipleAssemblyPath("SimpleTestProjectx86.dll"); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + var expectedWarningContains = @"Following DLL(s) do not match current settings, which are .NETFramework,Version=v4.5.1 framework and X86 platform. SimpleTestProjectx86 is built for Framework .NETFramework,Version=v4.5.1 and Platform X86"; + var assemblyPaths = + BuildMultipleAssemblyPath("SimpleTestProjectx86.dll"); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - this.InvokeVsTest(arguments); + InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 0, 0); - this.ExitCodeEquals(0); + ValidateSummaryStatus(1, 0, 0); + ExitCodeEquals(0); - this.StdOutputDoesNotContains(expectedWarningContains); - } + StdOutputDoesNotContains(expectedWarningContains); + } + + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + public void IncompatibleSourcesWarningShouldBeDisplayedInTheConsoleOnlyWhenRunningIn32BitOS(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - public void IncompatibleSourcesWarningShouldBeDisplayedInTheConsoleOnlyWhenRunningIn32BitOS(RunnerInfo runnerInfo) + var expectedWarningContains = @"Following DLL(s) do not match current settings, which are .NETFramework,Version=v4.5.1 framework and X86 platform. SimpleTestProject2.dll is built for Framework .NETFramework,Version=v4.5.1 and Platform X64"; + var assemblyPaths = + BuildMultipleAssemblyPath("SimpleTestProject2.dll"); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + + InvokeVsTest(arguments); + + ValidateSummaryStatus(1, 1, 1); + ExitCodeEquals(1); + + // If we are running this test on 64 bit OS, it should not output any warning + if (Environment.Is64BitOperatingSystem) { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var expectedWarningContains = @"Following DLL(s) do not match current settings, which are .NETFramework,Version=v4.5.1 framework and X86 platform. SimpleTestProject2.dll is built for Framework .NETFramework,Version=v4.5.1 and Platform X64"; - var assemblyPaths = - this.BuildMultipleAssemblyPath("SimpleTestProject2.dll"); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - - this.InvokeVsTest(arguments); - - this.ValidateSummaryStatus(1, 1, 1); - this.ExitCodeEquals(1); - - // If we are running this test on 64 bit OS, it should not output any warning - if (Environment.Is64BitOperatingSystem) - { - this.StdOutputDoesNotContains(expectedWarningContains); - } - // If we are running this test on 32 bit OS, it should output warning message - else - { - this.StdOutputContains(expectedWarningContains); - } + StdOutputDoesNotContains(expectedWarningContains); } - - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - public void ExitCodeShouldReturnOneWhenTreatNoTestsAsErrorParameterSetToTrueAndNoTestMatchesFilter(RunnerInfo runnerInfo) + // If we are running this test on 32 bit OS, it should output warning message + else { - SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + StdOutputContains(expectedWarningContains); + } + } - var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + public void ExitCodeShouldReturnOneWhenTreatNoTestsAsErrorParameterSetToTrueAndNoTestMatchesFilter(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); - // Setting /TestCaseFilter to the test name, which does not exists in the assembly, so we will have 0 tests executed - arguments = string.Concat(arguments, " /TestCaseFilter:TestNameThatMatchesNoTestInTheAssembly"); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " -- RunConfiguration.TreatNoTestsAsError=true"); - this.InvokeVsTest(arguments); + // Setting /TestCaseFilter to the test name, which does not exists in the assembly, so we will have 0 tests executed + arguments = string.Concat(arguments, " /TestCaseFilter:TestNameThatMatchesNoTestInTheAssembly"); - this.ExitCodeEquals(1); - } + arguments = string.Concat(arguments, " -- RunConfiguration.TreatNoTestsAsError=true"); + InvokeVsTest(arguments); - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - public void ExitCodeShouldReturnZeroWhenTreatNoTestsAsErrorParameterSetToFalseAndNoTestMatchesFilter(RunnerInfo runnerInfo) - { - SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + ExitCodeEquals(1); + } - var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + public void ExitCodeShouldReturnZeroWhenTreatNoTestsAsErrorParameterSetToFalseAndNoTestMatchesFilter(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - // Setting /TestCaseFilter to the test name, which does not exists in the assembly, so we will have 0 tests executed - arguments = string.Concat(arguments, " /TestCaseFilter:TestNameThatMatchesNoTestInTheAssembly"); + var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " -- RunConfiguration.TreatNoTestsAsError=false"); - this.InvokeVsTest(arguments); + // Setting /TestCaseFilter to the test name, which does not exists in the assembly, so we will have 0 tests executed + arguments = string.Concat(arguments, " /TestCaseFilter:TestNameThatMatchesNoTestInTheAssembly"); - this.ExitCodeEquals(0); - } + arguments = string.Concat(arguments, " -- RunConfiguration.TreatNoTestsAsError=false"); + InvokeVsTest(arguments); - [TestMethod] - [TestCategory("Windows")] - [NetFullTargetFrameworkDataSource] - public void ExitCodeShouldNotDependOnTreatNoTestsAsErrorTrueValueWhenThereAreAnyTestsToRun(RunnerInfo runnerInfo) - { - SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + ExitCodeEquals(0); + } - var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); + [TestMethod] + [TestCategory("Windows")] + [NetFullTargetFrameworkDataSource] + public void ExitCodeShouldNotDependOnTreatNoTestsAsErrorTrueValueWhenThereAreAnyTestsToRun(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); - arguments = string.Concat(arguments, " -- RunConfiguration.TreatNoTestsAsError=true"); - this.InvokeVsTest(arguments); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - // Returning 1 because of failing test in test assembly (SimpleTestProject2.dll) - this.ExitCodeEquals(1); - } + arguments = string.Concat(arguments, " -- RunConfiguration.TreatNoTestsAsError=true"); + InvokeVsTest(arguments); - [TestMethod] - [TestCategory("Windows")] - [NetFullTargetFrameworkDataSource] - public void ExitCodeShouldNotDependOnFailTreatNoTestsAsErrorFalseValueWhenThereAreAnyTestsToRun(RunnerInfo runnerInfo) - { - SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + // Returning 1 because of failing test in test assembly (SimpleTestProject2.dll) + ExitCodeEquals(1); + } + + [TestMethod] + [TestCategory("Windows")] + [NetFullTargetFrameworkDataSource] + public void ExitCodeShouldNotDependOnFailTreatNoTestsAsErrorFalseValueWhenThereAreAnyTestsToRun(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " -- RunConfiguration.TreatNoTestsAsError=false"); - this.InvokeVsTest(arguments); + arguments = string.Concat(arguments, " -- RunConfiguration.TreatNoTestsAsError=false"); + InvokeVsTest(arguments); - // Returning 1 because of failing test in test assembly (SimpleTestProject2.dll) - this.ExitCodeEquals(1); - } + // Returning 1 because of failing test in test assembly (SimpleTestProject2.dll) + ExitCodeEquals(1); } } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionThreadApartmentStateTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionThreadApartmentStateTests.cs index ea4a540f5c..d594a81421 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionThreadApartmentStateTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionThreadApartmentStateTests.cs @@ -1,75 +1,74 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.AcceptanceTests; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestClass] - [TestCategory("Windows-Review")] - public class ExecutionThreadApartmentStateTests : AcceptanceTestBase +[TestClass] +[TestCategory("Windows-Review")] +public class ExecutionThreadApartmentStateTests : AcceptanceTestBase +{ + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + public void UITestShouldPassIfApartmentStateIsSTA(RunnerInfo runnerInfo) { - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - public void UITestShouldPassIfApartmentStateIsSTA(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject3.dll").Trim('\"'); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /testcasefilter:UITestMethod"); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 0, 0); - } + var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject3.dll").Trim('\"'); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /testcasefilter:UITestMethod"); + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 0, 0); + } - [TestMethod] - [NetCoreTargetFrameworkDataSource] - public void WarningShouldBeShownWhenValueIsSTAForNetCore(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + [TestMethod] + [NetCoreTargetFrameworkDataSource] + public void WarningShouldBeShownWhenValueIsSTAForNetCore(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var assemblyPaths = - this.BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /testcasefilter:PassingTest2 -- RunConfiguration.ExecutionThreadApartmentState=STA"); - this.InvokeVsTest(arguments); - this.StdOutputContains("ExecutionThreadApartmentState option not supported for framework:"); - this.ValidateSummaryStatus(1, 0, 0); - } + var assemblyPaths = + BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /testcasefilter:PassingTest2 -- RunConfiguration.ExecutionThreadApartmentState=STA"); + InvokeVsTest(arguments); + StdOutputContains("ExecutionThreadApartmentState option not supported for framework:"); + ValidateSummaryStatus(1, 0, 0); + } - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - public void UITestShouldFailWhenDefaultApartmentStateIsMTA(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + public void UITestShouldFailWhenDefaultApartmentStateIsMTA(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var assemblyPaths = - this.BuildMultipleAssemblyPath("SimpleTestProject3.dll").Trim('\"'); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /testcasefilter:UITestMethod -- RunConfiguration.ExecutionThreadApartmentState=MTA"); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(0, 1, 0); - } + var assemblyPaths = + BuildMultipleAssemblyPath("SimpleTestProject3.dll").Trim('\"'); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /testcasefilter:UITestMethod -- RunConfiguration.ExecutionThreadApartmentState=MTA"); + InvokeVsTest(arguments); + ValidateSummaryStatus(0, 1, 0); + } - [Ignore(@"Issue with TestSessionTimeout: https://github.com/Microsoft/vstest/issues/980")] - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - public void CancelTestExectionShouldWorkWhenApartmentStateIsSTA(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + [Ignore(@"Issue with TestSessionTimeout: https://github.com/Microsoft/vstest/issues/980")] + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + public void CancelTestExectionShouldWorkWhenApartmentStateIsSTA(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var assemblyPaths = - this.BuildMultipleAssemblyPath("SimpleTestProject3.dll").Trim('\"'); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /tests:UITestWithSleep1,UITestMethod -- RunConfiguration.ExecutionThreadApartmentState=STA RunConfiguration.TestSessionTimeout=2000"); - this.InvokeVsTest(arguments); - this.StdOutputContains("Canceling test run: test run timeout of"); - this.ValidateSummaryStatus(1, 0, 0); - } + var assemblyPaths = + BuildMultipleAssemblyPath("SimpleTestProject3.dll").Trim('\"'); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /tests:UITestWithSleep1,UITestMethod -- RunConfiguration.ExecutionThreadApartmentState=STA RunConfiguration.TestSessionTimeout=2000"); + InvokeVsTest(arguments); + StdOutputContains("Canceling test run: test run timeout of"); + ValidateSummaryStatus(1, 0, 0); } } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreRunner.cs b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreRunner.cs index 8a2374b802..55a651048e 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreRunner.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreRunner.cs @@ -1,50 +1,51 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Linq; - using System.Reflection; - using TestUtilities; - using VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.AcceptanceTests; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Reflection; + +using TestUtilities; + +using VisualStudio.TestTools.UnitTesting; +/// +/// Runs tests using the dotnet vstest.console.dll built against .NET Core 2.1. +/// Provide a list of target frameworks to run the tests from given as a ';' separated list, or using a constant containing that range such as +/// AcceptanceTestBase.NETFX452_NET50 = "net452;net472;net48;netcoreapp2.1;netcoreapp3.1;net5.0" to determine which target framework of the project +/// to test. The target project must list those TFMs in the TargetFrameworks property in csproj. +/// +public class NetCoreRunner : Attribute, ITestDataSource +{ /// - /// Runs tests using the dotnet vstest.console.dll built against .NET Core 2.1. - /// Provide a list of target frameworks to run the tests from given as a ';' separated list, or using a constant containing that range such as - /// AcceptanceTestBase.NETFX452_NET50 = "net452;net472;net48;netcoreapp2.1;netcoreapp3.1;net5.0" to determine which target framework of the project - /// to test. The target project must list those TFMs in the TargetFrameworks property in csproj. + /// Initializes a new instance of the class. /// - public class NetCoreRunner : Attribute, ITestDataSource + /// To run tests with desktop runner(vstest.console.exe), use AcceptanceTestBase.Net452TargetFramework or alike values. + public NetCoreRunner(string targetFrameworks = AcceptanceTestBase.NETFX452_NET50) { - /// - /// Initializes a new instance of the class. - /// - /// To run tests with desktop runner(vstest.console.exe), use AcceptanceTestBase.Net452TargetFramework or alike values. - public NetCoreRunner(string targetFrameworks = AcceptanceTestBase.NETFX452_NET50) + var isWindows = Environment.OSVersion.Platform.ToString().StartsWith("Win"); + // on non-windows we want to filter down only to netcoreapp runner, and net5.0 and newer. + Func filter = tfm => isWindows || !tfm.StartsWith("net4"); + foreach (var fmw in targetFrameworks.Split(';').Where(filter)) { - var isWindows = Environment.OSVersion.Platform.ToString().StartsWith("Win"); - // on non-windows we want to filter down only to netcoreapp runner, and net5.0 and newer. - Func filter = tfm => isWindows ? true : !tfm.StartsWith("net4"); - foreach (var fmw in targetFrameworks.Split(';').Where(filter)) - { - this.dataRows.Add(new object[] { new RunnerInfo(IntegrationTestBase.CoreRunnerFramework, fmw) }); - } - + _dataRows.Add(new object[] { new RunnerInfo(IntegrationTestBase.CoreRunnerFramework, fmw) }); } - private List dataRows = new List(); + } - public IEnumerable GetData(MethodInfo methodInfo) - { - return this.dataRows; - } + private readonly List _dataRows = new(); - public string GetDisplayName(MethodInfo methodInfo, object[] data) - { - return string.Format(CultureInfo.CurrentCulture, "{0} ({1})", methodInfo.Name, string.Join(",", data)); - } + public IEnumerable GetData(MethodInfo methodInfo) + { + return _dataRows; + } + + public string GetDisplayName(MethodInfo methodInfo, object[] data) + { + return string.Format(CultureInfo.CurrentCulture, "{0} ({1})", methodInfo.Name, string.Join(",", data)); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreTargetFrameworkDataSource.cs b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreTargetFrameworkDataSource.cs index 48242500fc..7c0c8b6b45 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreTargetFrameworkDataSource.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreTargetFrameworkDataSource.cs @@ -1,83 +1,84 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Reflection; - using TestUtilities; - using VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.AcceptanceTests; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Reflection; + +using TestUtilities; +using VisualStudio.TestTools.UnitTesting; + +/// +/// The attribute defining runner framework, target framework and target runtime for netcoreapp1.* +/// First Argument (Runner framework) = This decides who will run the tests. If runner framework is netcoreapp then "dotnet vstest.console.dll" will run the tests. +/// If runner framework is net46 then vstest.console.exe will run the tests. +/// Second argument (target framework) = The framework for which test will run +/// +public class NetCoreTargetFrameworkDataSource : Attribute, ITestDataSource +{ + private readonly List _dataRows = new(); /// - /// The attribute defining runner framework, target framework and target runtime for netcoreapp1.* - /// First Argument (Runner framework) = This decides who will run the tests. If runner framework is netcoreapp then "dotnet vstest.console.dll" will run the tests. - /// If runner framework is net46 then vstest.console.exe will run the tests. - /// Second argument (target framework) = The framework for which test will run + /// Initializes a new instance of the class. /// - public class NetCoreTargetFrameworkDataSource : Attribute, ITestDataSource + /// To run tests with desktop runner(vstest.console.exe) + /// To run tests with core runner(dotnet vstest.console.dll) + public NetCoreTargetFrameworkDataSource( + bool useDesktopRunner = true, + // adding another runner is not necessary until we need to start building against another + // sdk, because the netcoreapp2.1 executable is forward compatible + bool useCoreRunner = true, + bool useNetCore21Target = true, + // laying the ground work here for tests to be able to run against 3.1 but not enabling it for + // all tests to avoid changing all acceptance tests right now + bool useNetCore31Target = false) { - private List dataRows = new List(); - /// - /// Initializes a new instance of the class. - /// - /// To run tests with desktop runner(vstest.console.exe) - /// To run tests with core runner(dotnet vstest.console.dll) - public NetCoreTargetFrameworkDataSource( - bool useDesktopRunner = true, - // adding another runner is not necessary until we need to start building against another - // sdk, because the netcoreapp2.1 executable is forward compatible - bool useCoreRunner = true, - bool useNetCore21Target = true, - // laying the ground work here for tests to be able to run against 3.1 but not enabling it for - // all tests to avoid changing all acceptance tests right now - bool useNetCore31Target = false) + var isWindows = Environment.OSVersion.Platform.ToString().StartsWith("Win"); + if (useDesktopRunner && isWindows) { - var isWindows = Environment.OSVersion.Platform.ToString().StartsWith("Win"); - if (useDesktopRunner && isWindows) + var runnerFramework = IntegrationTestBase.DesktopRunnerFramework; + if (useNetCore21Target) { - var runnerFramework = IntegrationTestBase.DesktopRunnerFramework; - if (useNetCore21Target) - { - this.AddRunnerDataRow(runnerFramework, AcceptanceTestBase.Core21TargetFramework); - } - - if (useNetCore31Target) - { - this.AddRunnerDataRow(runnerFramework, AcceptanceTestBase.Core31TargetFramework); - } + AddRunnerDataRow(runnerFramework, AcceptanceTestBase.Core21TargetFramework); } - if (useCoreRunner) + if (useNetCore31Target) { - var runnerFramework = IntegrationTestBase.CoreRunnerFramework; - if (useNetCore21Target) - { - this.AddRunnerDataRow(runnerFramework, AcceptanceTestBase.Core21TargetFramework); - } - - if (useNetCore31Target) - { - this.AddRunnerDataRow(runnerFramework, AcceptanceTestBase.Core31TargetFramework); - } + AddRunnerDataRow(runnerFramework, AcceptanceTestBase.Core31TargetFramework); } } - private void AddRunnerDataRow(string runnerFramework, string targetFramework) + if (useCoreRunner) { - var runnerInfo = new RunnerInfo(runnerFramework, targetFramework); - this.dataRows.Add(new object[] { runnerInfo }); - } + var runnerFramework = IntegrationTestBase.CoreRunnerFramework; + if (useNetCore21Target) + { + AddRunnerDataRow(runnerFramework, AcceptanceTestBase.Core21TargetFramework); + } - public IEnumerable GetData(MethodInfo methodInfo) - { - return this.dataRows; + if (useNetCore31Target) + { + AddRunnerDataRow(runnerFramework, AcceptanceTestBase.Core31TargetFramework); + } } + } - public string GetDisplayName(MethodInfo methodInfo, object[] data) - { - return string.Format(CultureInfo.CurrentCulture, "{0} ({1})", methodInfo.Name, string.Join(",", data)); - } + private void AddRunnerDataRow(string runnerFramework, string targetFramework) + { + var runnerInfo = new RunnerInfo(runnerFramework, targetFramework); + _dataRows.Add(new object[] { runnerInfo }); + } + + public IEnumerable GetData(MethodInfo methodInfo) + { + return _dataRows; + } + + public string GetDisplayName(MethodInfo methodInfo, object[] data) + { + return string.Format(CultureInfo.CurrentCulture, "{0} ({1})", methodInfo.Name, string.Join(",", data)); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFrameworkRunner.cs b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFrameworkRunner.cs index 883a80968f..7bbac13655 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFrameworkRunner.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFrameworkRunner.cs @@ -1,52 +1,53 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Reflection; - using TestUtilities; - using VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.AcceptanceTests; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Reflection; + +using TestUtilities; +using VisualStudio.TestTools.UnitTesting; + +/// +/// Runs tests using the dotnet vstest.console.dll built against .NET Core 2.1. +/// Provide a list of target frameworks to run the tests from given as a ';' separated list, or using a constant containing that range such as +/// AcceptanceTestBase.NETFX452_NET50 = "net452;net472;net48;netcoreapp2.1;netcoreapp3.1;net5.0" to determine which target framework of the project +/// to test. The target project must list those TFMs in the TargetFrameworks property in csproj. +/// +public class NetFrameworkRunner : Attribute, ITestDataSource +{ /// - /// Runs tests using the dotnet vstest.console.dll built against .NET Core 2.1. - /// Provide a list of target frameworks to run the tests from given as a ';' separated list, or using a constant containing that range such as - /// AcceptanceTestBase.NETFX452_NET50 = "net452;net472;net48;netcoreapp2.1;netcoreapp3.1;net5.0" to determine which target framework of the project - /// to test. The target project must list those TFMs in the TargetFrameworks property in csproj. + /// Initializes a new instance of the class. /// - public class NetFrameworkRunner : Attribute, ITestDataSource + /// To run tests with desktop runner(vstest.console.exe), use AcceptanceTestBase.Net452TargetFramework or alike values. + public NetFrameworkRunner(string targetFrameworks = AcceptanceTestBase.NETFX452_NET50) { - /// - /// Initializes a new instance of the class. - /// - /// To run tests with desktop runner(vstest.console.exe), use AcceptanceTestBase.Net452TargetFramework or alike values. - public NetFrameworkRunner(string targetFrameworks = AcceptanceTestBase.NETFX452_NET50) + var isWindows = Environment.OSVersion.Platform.ToString().StartsWith("Win"); + if (!isWindows) { - var isWindows = Environment.OSVersion.Platform.ToString().StartsWith("Win"); - if (!isWindows) - { - return; - } - - foreach (var fmw in targetFrameworks.Split(';')) - { - this.dataRows.Add(new object[] { new RunnerInfo(IntegrationTestBase.DesktopRunnerFramework, fmw, AcceptanceTestBase.InIsolation) }); - } - + return; } - private List dataRows = new List(); - - public IEnumerable GetData(MethodInfo methodInfo) + foreach (var fmw in targetFrameworks.Split(';')) { - return this.dataRows; + _dataRows.Add(new object[] { new RunnerInfo(IntegrationTestBase.DesktopRunnerFramework, fmw, AcceptanceTestBase.InIsolation) }); } - public string GetDisplayName(MethodInfo methodInfo, object[] data) - { - return string.Format(CultureInfo.CurrentCulture, "{0} ({1})", methodInfo.Name, string.Join(",", data)); - } } -} + + private readonly List _dataRows = new(); + + public IEnumerable GetData(MethodInfo methodInfo) + { + return _dataRows; + } + + public string GetDisplayName(MethodInfo methodInfo, object[] data) + { + return string.Format(CultureInfo.CurrentCulture, "{0} ({1})", methodInfo.Name, string.Join(",", data)); + } +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFullTargetFrameworkDataSource.cs b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFullTargetFrameworkDataSource.cs index c69101f611..3a933e9b08 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFullTargetFrameworkDataSource.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFullTargetFrameworkDataSource.cs @@ -1,91 +1,92 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Reflection; - using TestUtilities; - using VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.AcceptanceTests; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Reflection; + +using TestUtilities; + +using VisualStudio.TestTools.UnitTesting; +/// +/// The attribute defining runner framework and target framework for net451. +/// First Argument (Runner framework) = This decides who will run the tests. If runner framework is netcoreapp then "dotnet vstest.console.dll" will run the tests. +/// If runner framework is net46 then vstest.console.exe will run the tests. +/// Second argument (target framework) = The framework for which test will run +/// +public class NetFullTargetFrameworkDataSource : Attribute, ITestDataSource +{ /// - /// The attribute defining runner framework and target framework for net451. - /// First Argument (Runner framework) = This decides who will run the tests. If runner framework is netcoreapp then "dotnet vstest.console.dll" will run the tests. - /// If runner framework is net46 then vstest.console.exe will run the tests. - /// Second argument (target framework) = The framework for which test will run + /// Initializes a new instance of the class. /// - public class NetFullTargetFrameworkDataSource : Attribute, ITestDataSource + /// Run test in isolation + /// Run tests in process + /// To run tests with desktop runner(vstest.console.exe) + /// To run tests with core runner(dotnet vstest.console.dll) + public NetFullTargetFrameworkDataSource(bool inIsolation = true, bool inProcess = false, bool useDesktopRunner = true, bool useCoreRunner = true) { - /// - /// Initializes a new instance of the class. - /// - /// Run test in isolation - /// Run tests in process - /// To run tests with desktop runner(vstest.console.exe) - /// To run tests with core runner(dotnet vstest.console.dll) - public NetFullTargetFrameworkDataSource(bool inIsolation = true, bool inProcess = false, bool useDesktopRunner = true, bool useCoreRunner = true) + _dataRows = new List(); + + var isWindows = Environment.OSVersion.Platform.ToString().StartsWith("Win"); + if (useCoreRunner && isWindows) { - this.dataRows = new List(); + _dataRows.Add(new object[] { new RunnerInfo(IntegrationTestBase.CoreRunnerFramework, AcceptanceTestBase.DesktopTargetFramework) }); + } - var isWindows = Environment.OSVersion.Platform.ToString().StartsWith("Win"); - if (useCoreRunner && isWindows) + if (useDesktopRunner && isWindows) + { + if (inIsolation) { - this.dataRows.Add(new object[] { new RunnerInfo(IntegrationTestBase.CoreRunnerFramework, AcceptanceTestBase.DesktopTargetFramework) }); + _dataRows.Add(new object[] { new RunnerInfo(IntegrationTestBase.DesktopRunnerFramework, AcceptanceTestBase.DesktopTargetFramework, AcceptanceTestBase.InIsolation) }); } - if (useDesktopRunner && isWindows) + if (inProcess) { - if (inIsolation) - { - this.dataRows.Add(new object[] { new RunnerInfo(IntegrationTestBase.DesktopRunnerFramework, AcceptanceTestBase.DesktopTargetFramework, AcceptanceTestBase.InIsolation) }); - } - - if (inProcess) - { - this.dataRows.Add(new object[] { new RunnerInfo(IntegrationTestBase.DesktopRunnerFramework, AcceptanceTestBase.DesktopTargetFramework) }); - } + _dataRows.Add(new object[] { new RunnerInfo(IntegrationTestBase.DesktopRunnerFramework, AcceptanceTestBase.DesktopTargetFramework) }); } } + } - /// - /// Initializes a new instance of the class. - /// - /// To run tests with desktop runner(vstest.console.exe), use AcceptanceTestBase.Net452TargetFramework or alike values. - public NetFullTargetFrameworkDataSource(string[] targetFrameworks, bool inIsolation = true, bool inProcess = false) + /// + /// Initializes a new instance of the class. + /// + /// To run tests with desktop runner(vstest.console.exe), use AcceptanceTestBase.Net452TargetFramework or alike values. + public NetFullTargetFrameworkDataSource(string[] targetFrameworks, bool inIsolation = true, bool inProcess = false) + { + if (inIsolation) { - if (inIsolation) + foreach (var fmw in targetFrameworks) { - foreach (var fmw in targetFrameworks) - { - this.dataRows.Add(new object[] { new RunnerInfo(IntegrationTestBase.DesktopRunnerFramework, fmw, AcceptanceTestBase.InIsolation) }); - } + _dataRows.Add(new object[] { new RunnerInfo(IntegrationTestBase.DesktopRunnerFramework, fmw, AcceptanceTestBase.InIsolation) }); } + } - if (inProcess) + if (inProcess) + { + foreach (var fmw in targetFrameworks) { - foreach (var fmw in targetFrameworks) - { - this.dataRows.Add(new object[] { new RunnerInfo(IntegrationTestBase.DesktopRunnerFramework, fmw) }); - } + _dataRows.Add(new object[] { new RunnerInfo(IntegrationTestBase.DesktopRunnerFramework, fmw) }); } } + } - /// - /// Gets or sets the data rows. - /// - private List dataRows = new List(); + /// + /// Gets or sets the data rows. + /// + private readonly List _dataRows = new(); - public IEnumerable GetData(MethodInfo methodInfo) - { - return this.dataRows; - } + public IEnumerable GetData(MethodInfo methodInfo) + { + return _dataRows; + } - public string GetDisplayName(MethodInfo methodInfo, object[] data) - { - return string.Format(CultureInfo.CurrentCulture, "{0} ({1})", methodInfo.Name, string.Join(",", data)); - } + public string GetDisplayName(MethodInfo methodInfo, object[] data) + { + return string.Format(CultureInfo.CurrentCulture, "{0} ({1})", methodInfo.Name, string.Join(",", data)); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/RunnnerInfo.cs b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/RunnnerInfo.cs index 0b4ba85361..d5373d8bbe 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/RunnnerInfo.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/RunnnerInfo.cs @@ -1,50 +1,49 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests +namespace Microsoft.TestPlatform.AcceptanceTests; + +public class RunnerInfo { - public class RunnerInfo + public RunnerInfo(string runnerType, string targetFramework) : this(runnerType, targetFramework, "") { - public RunnerInfo(string runnerType, string targetFramework): this(runnerType, targetFramework, "") - { - } + } - public RunnerInfo(string runnerType, string targetFramework, string inIsolation) - { - this.RunnerFramework = runnerType; - this.TargetFramework = targetFramework; - this.InIsolationValue = inIsolation; - } - /// - /// Gets the target framework. - /// - public string TargetFramework - { - get; - set; - } + public RunnerInfo(string runnerType, string targetFramework, string inIsolation) + { + RunnerFramework = runnerType; + TargetFramework = targetFramework; + InIsolationValue = inIsolation; + } + /// + /// Gets the target framework. + /// + public string TargetFramework + { + get; + set; + } - /// - /// Gets the inIsolation. - /// Supported values = /InIsolation. - /// - public string InIsolationValue - { - get; set; - } + /// + /// Gets the inIsolation. + /// Supported values = /InIsolation. + /// + public string InIsolationValue + { + get; set; + } - /// - /// Gets the application type. - /// - public string RunnerFramework - { - get; - set; - } + /// + /// Gets the application type. + /// + public string RunnerFramework + { + get; + set; + } - public override string ToString() - { - return string.Join(",", new[] { "RunnerFramework = " + RunnerFramework, " TargetFramework = " + TargetFramework, string.IsNullOrEmpty(InIsolationValue) ? " InProcess" : " InIsolation" }); - } + public override string ToString() + { + return string.Join(",", new[] { "RunnerFramework = " + RunnerFramework, " TargetFramework = " + TargetFramework, string.IsNullOrEmpty(InIsolationValue) ? " InProcess" : " InIsolation" }); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/FilePatternParserTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/FilePatternParserTests.cs index a7456ec8df..d89fdd0eab 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/FilePatternParserTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/FilePatternParserTests.cs @@ -1,107 +1,106 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information.using Microsoft.VisualStudio.TestTools.UnitTesting; +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests +namespace Microsoft.TestPlatform.AcceptanceTests; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using System.IO; + +[TestClass] +public class FilePatternParserTests : AcceptanceTestBase { - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void WildCardPatternShouldCorrectlyWorkOnFiles(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var testAssembly = GetSampleTestAssembly(); + testAssembly = testAssembly.Replace("SimpleTestProject.dll", "*TestProj*.dll"); - using System.IO; + var arguments = PrepareArguments( + testAssembly, + GetTestAdapterPath(), + string.Empty, FrameworkArgValue, + runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - [TestClass] - public class FilePatternParserTests : AcceptanceTestBase + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 1, 1); + } + + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void WildCardPatternShouldCorrectlyWorkOnArbitraryDepthDirectories(RunnerInfo runnerInfo) { - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void WildCardPatternShouldCorrectlyWorkOnFiles(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var testAssembly = this.GetSampleTestAssembly(); - testAssembly = testAssembly.Replace("SimpleTestProject.dll", "*TestProj*.dll"); - - var arguments = PrepareArguments( - testAssembly, - this.GetTestAdapterPath(), - string.Empty, this.FrameworkArgValue, - runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 1, 1); - } - - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void WildCardPatternShouldCorrectlyWorkOnArbitraryDepthDirectories(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var testAssembly = this.GetSampleTestAssembly(); - var oldAssemblyPath = Path.Combine("Debug", this.testEnvironment.TargetFramework, "SimpleTestProject.dll"); - var newAssemblyPath = Path.Combine("**", this.testEnvironment.TargetFramework, "*TestProj*.dll"); - testAssembly = testAssembly.Replace(oldAssemblyPath, newAssemblyPath); - - var arguments = PrepareArguments( - testAssembly, - this.GetTestAdapterPath(), - string.Empty, string.Empty, - runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 1, 1); - } - - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void WildCardPatternShouldCorrectlyWorkForRelativeAssemblyPath(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var testAssembly = this.GetSampleTestAssembly(); - testAssembly = testAssembly.Replace("SimpleTestProject.dll", "*TestProj*.dll"); - - var wildCardIndex = testAssembly.IndexOfAny(new char[] { '*' }); - var testAssemblyDirectory = testAssembly.Substring(0, wildCardIndex); - testAssembly = testAssembly.Substring(wildCardIndex); - - Directory.SetCurrentDirectory(testAssemblyDirectory); - - var arguments = PrepareArguments( - testAssembly, - this.GetTestAdapterPath(), - string.Empty, string.Empty, - runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 1, 1); - } - - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void WildCardPatternShouldCorrectlyWorkOnMultipleFiles(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var testAssembly = this.BuildMultipleAssemblyPath("SimpleTestProject.dll", "SimpleTestProject2.dll").Trim('\"'); - testAssembly = testAssembly.Replace("SimpleTestProject.dll", "*TestProj*.dll"); - testAssembly = testAssembly.Replace("SimpleTestProject2.dll", "*TestProj*.dll"); - - var arguments = PrepareArguments( - testAssembly, - this.GetTestAdapterPath(), - string.Empty, this.FrameworkArgValue, - runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(2, 2, 2); - } + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var testAssembly = GetSampleTestAssembly(); + var oldAssemblyPath = Path.Combine("Debug", _testEnvironment.TargetFramework, "SimpleTestProject.dll"); + var newAssemblyPath = Path.Combine("**", _testEnvironment.TargetFramework, "*TestProj*.dll"); + testAssembly = testAssembly.Replace(oldAssemblyPath, newAssemblyPath); + + var arguments = PrepareArguments( + testAssembly, + GetTestAdapterPath(), + string.Empty, string.Empty, + runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 1, 1); + } + + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void WildCardPatternShouldCorrectlyWorkForRelativeAssemblyPath(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var testAssembly = GetSampleTestAssembly(); + testAssembly = testAssembly.Replace("SimpleTestProject.dll", "*TestProj*.dll"); + + var wildCardIndex = testAssembly.IndexOfAny(new char[] { '*' }); + var testAssemblyDirectory = testAssembly.Substring(0, wildCardIndex); + testAssembly = testAssembly.Substring(wildCardIndex); + + Directory.SetCurrentDirectory(testAssemblyDirectory); + + var arguments = PrepareArguments( + testAssembly, + GetTestAdapterPath(), + string.Empty, string.Empty, + runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 1, 1); + } + + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void WildCardPatternShouldCorrectlyWorkOnMultipleFiles(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var testAssembly = BuildMultipleAssemblyPath("SimpleTestProject.dll", "SimpleTestProject2.dll").Trim('\"'); + testAssembly = testAssembly.Replace("SimpleTestProject.dll", "*TestProj*.dll"); + testAssembly = testAssembly.Replace("SimpleTestProject2.dll", "*TestProj*.dll"); + + var arguments = PrepareArguments( + testAssembly, + GetTestAdapterPath(), + string.Empty, FrameworkArgValue, + runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + + InvokeVsTest(arguments); + ValidateSummaryStatus(2, 2, 2); } } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs index 8891363a38..17cf2cc511 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs @@ -1,102 +1,101 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests +namespace Microsoft.TestPlatform.AcceptanceTests; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class FrameworkTests : AcceptanceTestBase { - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestClass] - public class FrameworkTests : AcceptanceTestBase + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void FrameworkArgumentShouldWork(RunnerInfo runnerInfo) { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void FrameworkArgumentShouldWork(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + var arguments = PrepareArguments(GetSampleTestAssembly(), string.Empty, string.Empty, string.Empty, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " ", $"/Framework:{FrameworkArgValue}"); - var arguments = PrepareArguments(GetSampleTestAssembly(), string.Empty, string.Empty, string.Empty, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " ", $"/Framework:{this.FrameworkArgValue}"); + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 1, 1); + } - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 1, 1); - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void FrameworkShortNameArgumentShouldWork(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void FrameworkShortNameArgumentShouldWork(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + var arguments = PrepareArguments(GetSampleTestAssembly(), string.Empty, string.Empty, string.Empty, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " ", $"/Framework:{_testEnvironment.TargetFramework}"); - var arguments = PrepareArguments(GetSampleTestAssembly(), string.Empty, string.Empty, string.Empty, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " ", $"/Framework:{this.testEnvironment.TargetFramework}"); + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 1, 1); + } - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 1, 1); + [TestMethod] + // framework runner not available on Linux + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource(useCoreRunner: false)] + //[NetCoreTargetFrameworkDataSource] + public void OnWrongFrameworkPassedTestRunShouldNotRun(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var arguments = PrepareArguments(GetSampleTestAssembly(), string.Empty, string.Empty, string.Empty, resultsDirectory: tempDir.Path); + if (runnerInfo.TargetFramework.Contains("netcore")) + { + arguments = string.Concat(arguments, " ", "/Framework:Framework45"); } + else + { + arguments = string.Concat(arguments, " ", "/Framework:FrameworkCore10"); + } + InvokeVsTest(arguments); - [TestMethod] - // framework runner not available on Linux - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource(useCoreRunner: false)] - //[NetCoreTargetFrameworkDataSource] - public void OnWrongFrameworkPassedTestRunShouldNotRun(RunnerInfo runnerInfo) + if (runnerInfo.TargetFramework.Contains("netcore")) + { + StdOutputContains("No test is available"); + } + else { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var arguments = PrepareArguments(GetSampleTestAssembly(), string.Empty, string.Empty, string.Empty, resultsDirectory: tempDir.Path); - if (runnerInfo.TargetFramework.Contains("netcore")) - { - arguments = string.Concat(arguments, " ", "/Framework:Framework45"); - } - else - { - arguments = string.Concat(arguments, " ", "/Framework:FrameworkCore10"); - } - this.InvokeVsTest(arguments); - - if (runnerInfo.TargetFramework.Contains("netcore")) - { - this.StdOutputContains("No test is available"); - } - else - { - // This test indirectly tests that we abort when incorrect framework is forced on a DLL, the failure message with the new fallback - // is uglier than then one before that suggests (incorrectly) to install Microsoft.NET.Test.Sdk into the project, which would work, - // but would not solve the problem. In either cases we should improve the message later. - this.StdErrorContains("Test Run Failed."); - } + // This test indirectly tests that we abort when incorrect framework is forced on a DLL, the failure message with the new fallback + // is uglier than then one before that suggests (incorrectly) to install Microsoft.NET.Test.Sdk into the project, which would work, + // but would not solve the problem. In either cases we should improve the message later. + StdErrorContains("Test Run Failed."); } + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunSpecificTestsShouldWorkWithFrameworkInCompatibleWarning(RunnerInfo runnerInfo) + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunSpecificTestsShouldWorkWithFrameworkInCompatibleWarning(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var arguments = PrepareArguments(GetSampleTestAssembly(), string.Empty, string.Empty, string.Empty, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " ", "/tests:PassingTest"); + arguments = string.Concat(arguments, " ", "/Framework:Framework40"); + + InvokeVsTest(arguments); + + if (runnerInfo.TargetFramework.Contains("netcore")) + { + StdOutputContains("No test is available"); + } + else { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var arguments = PrepareArguments(GetSampleTestAssembly(), string.Empty, string.Empty, string.Empty, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " ", "/tests:PassingTest"); - arguments = string.Concat(arguments, " ", "/Framework:Framework40"); - - this.InvokeVsTest(arguments); - - if (runnerInfo.TargetFramework.Contains("netcore")) - { - this.StdOutputContains("No test is available"); - } - else - { - this.StdOutputContains("Following DLL(s) do not match current settings, which are .NETFramework,Version=v4.0 framework and X86 platform."); - this.ValidateSummaryStatus(1, 0, 0); - } + StdOutputContains("Following DLL(s) do not match current settings, which are .NETFramework,Version=v4.0 framework and X86 platform."); + ValidateSummaryStatus(1, 0, 0); } } -} \ No newline at end of file +} diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/ListExtensionsTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/ListExtensionsTests.cs index f7deff210e..f73397d7cd 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/ListExtensionsTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/ListExtensionsTests.cs @@ -1,98 +1,97 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.AcceptanceTests; + +using VisualStudio.TestTools.UnitTesting; - [TestClass] - // this is tested only on .NET Framework - [TestCategory("Windows-Review")] - public class ListExtensionsTests : AcceptanceTestBase +[TestClass] +// this is tested only on .NET Framework +[TestCategory("Windows-Review")] +public class ListExtensionsTests : AcceptanceTestBase +{ + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: false, inProcess: true)] + public void ListDiscoverersShouldShowInboxDiscoverers(RunnerInfo runnerInfo) { - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: false, inProcess: true)] - public void ListDiscoverersShouldShowInboxDiscoverers(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + SetTestEnvironment(_testEnvironment, runnerInfo); - this.InvokeVsTest("/listDiscoverers"); + InvokeVsTest("/listDiscoverers"); - if (this.IsDesktopRunner()) - { - this.StdOutputContains("executor://codedwebtestadapter/v1"); - this.StdOutputContains("executor://mstestadapter/v1"); - this.StdOutputContains("executor://webtestadapter/v1"); - this.StdOutputContains(".Webtest"); - this.StdOutputContains("executor://cppunittestexecutor/v1"); - } - else - { - // There are no inbox adapters for dotnet core - this.StdOutputDoesNotContains("executor://codedwebtestadapter/v1"); - this.StdOutputDoesNotContains("executor://mstestadapter/v1"); - this.StdOutputDoesNotContains("executor://webtestadapter/v1"); - this.StdOutputDoesNotContains(".Webtest"); - this.StdOutputDoesNotContains("executor://cppunittestexecutor/v1"); - } + if (IsDesktopRunner()) + { + StdOutputContains("executor://codedwebtestadapter/v1"); + StdOutputContains("executor://mstestadapter/v1"); + StdOutputContains("executor://webtestadapter/v1"); + StdOutputContains(".Webtest"); + StdOutputContains("executor://cppunittestexecutor/v1"); } - - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: false, inProcess: true)] - public void ListExecutorsShouldShowInboxExecutors(RunnerInfo runnerInfo) + else { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + // There are no inbox adapters for dotnet core + StdOutputDoesNotContains("executor://codedwebtestadapter/v1"); + StdOutputDoesNotContains("executor://mstestadapter/v1"); + StdOutputDoesNotContains("executor://webtestadapter/v1"); + StdOutputDoesNotContains(".Webtest"); + StdOutputDoesNotContains("executor://cppunittestexecutor/v1"); + } + } + + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: false, inProcess: true)] + public void ListExecutorsShouldShowInboxExecutors(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); - this.InvokeVsTest("/listExecutors"); + InvokeVsTest("/listExecutors"); - if (this.IsDesktopRunner()) - { - this.StdOutputContains("executor://CodedWebTestAdapter/v1"); - this.StdOutputContains("executor://MSTestAdapter/v1"); - this.StdOutputContains("executor://WebTestAdapter/v1"); - this.StdOutputContains("executor://CppUnitTestExecutor/v1"); - this.StdOutputContains("executor://UAPCppExecutorIdentifier"); - } - else - { - // There are no inbox adapters for dotnet core - this.StdOutputDoesNotContains("executor://CodedWebTestAdapter/v1"); - this.StdOutputDoesNotContains("executor://MSTestAdapter/v1"); - this.StdOutputDoesNotContains("executor://WebTestAdapter/v1"); - this.StdOutputDoesNotContains("executor://CppUnitTestExecutor/v1"); - this.StdOutputDoesNotContains("executor://UAPCppExecutorIdentifier"); - } + if (IsDesktopRunner()) + { + StdOutputContains("executor://CodedWebTestAdapter/v1"); + StdOutputContains("executor://MSTestAdapter/v1"); + StdOutputContains("executor://WebTestAdapter/v1"); + StdOutputContains("executor://CppUnitTestExecutor/v1"); + StdOutputContains("executor://UAPCppExecutorIdentifier"); } - - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: false, inProcess: true)] - public void ListLoggersShouldShowInboxLoggers(RunnerInfo runnerInfo) + else { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + // There are no inbox adapters for dotnet core + StdOutputDoesNotContains("executor://CodedWebTestAdapter/v1"); + StdOutputDoesNotContains("executor://MSTestAdapter/v1"); + StdOutputDoesNotContains("executor://WebTestAdapter/v1"); + StdOutputDoesNotContains("executor://CppUnitTestExecutor/v1"); + StdOutputDoesNotContains("executor://UAPCppExecutorIdentifier"); + } + } - this.InvokeVsTest("/listLoggers"); + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: false, inProcess: true)] + public void ListLoggersShouldShowInboxLoggers(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); - this.StdOutputContains("logger://Microsoft/TestPlatform/Extensions/Blame/v1"); - this.StdOutputContains("logger://Microsoft/TestPlatform/TrxLogger/v1"); - } + InvokeVsTest("/listLoggers"); - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: false, inProcess: true)] - public void ListSettingsProvidersShouldShowInboxSettingsProviders(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + StdOutputContains("logger://Microsoft/TestPlatform/Extensions/Blame/v1"); + StdOutputContains("logger://Microsoft/TestPlatform/TrxLogger/v1"); + } - this.InvokeVsTest("/listSettingsProviders"); + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: false, inProcess: true)] + public void ListSettingsProvidersShouldShowInboxSettingsProviders(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + + InvokeVsTest("/listSettingsProviders"); - if (this.IsDesktopRunner()) - { - this.StdOutputContains("MSTestSettingsProvider"); - } - else - { - // There are no inbox adapters for dotnet core - this.StdOutputDoesNotContains("MSTestSettingsProvider"); - } + if (IsDesktopRunner()) + { + StdOutputContains("MSTestSettingsProvider"); + } + else + { + // There are no inbox adapters for dotnet core + StdOutputDoesNotContains("MSTestSettingsProvider"); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/LoggerTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/LoggerTests.cs index 3f5f7b4932..69f4c60750 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/LoggerTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/LoggerTests.cs @@ -1,226 +1,223 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests +namespace Microsoft.TestPlatform.AcceptanceTests; + +using System.Linq; +using System.Text; +using System.IO; +using System.Xml; + +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.TestPlatform.TestUtilities; + +[TestClass] +public class LoggerTests : AcceptanceTestBase { - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System.Linq; - using System.Text; - using System.IO; - using System.Xml; - using System; - using Microsoft.TestPlatform.TestUtilities; - - [TestClass] - public class LoggerTests : AcceptanceTestBase + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + public void TrxLoggerWithFriendlyNameShouldProperlyOverwriteFile(RunnerInfo runnerInfo) { - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - public void TrxLoggerWithFriendlyNameShouldProperlyOverwriteFile(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var arguments = PrepareArguments(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); - var trxFileName = "TestResults.trx"; - arguments = string.Concat(arguments, $" /logger:\"trx;LogFileName={trxFileName}\""); - this.InvokeVsTest(arguments); + var arguments = PrepareArguments(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); + var trxFileName = "TestResults.trx"; + arguments = string.Concat(arguments, $" /logger:\"trx;LogFileName={trxFileName}\""); + InvokeVsTest(arguments); - arguments = PrepareArguments(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); - arguments = string.Concat(arguments, $" /logger:\"trx;LogFileName={trxFileName}\""); - arguments = string.Concat(arguments, " /testcasefilter:Name~Pass"); - this.InvokeVsTest(arguments); + arguments = PrepareArguments(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); + arguments = string.Concat(arguments, $" /logger:\"trx;LogFileName={trxFileName}\""); + arguments = string.Concat(arguments, " /testcasefilter:Name~Pass"); + InvokeVsTest(arguments); - var trxFilePath = Path.Combine(tempDir.Path, trxFileName); - Assert.IsTrue(IsValidXml(trxFilePath), "Invalid content in Trx log file"); - } + var trxFilePath = Path.Combine(tempDir.Path, trxFileName); + Assert.IsTrue(IsValidXml(trxFilePath), "Invalid content in Trx log file"); + } - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - public void HtmlLoggerWithFriendlyNameShouldProperlyOverwriteFile(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + public void HtmlLoggerWithFriendlyNameShouldProperlyOverwriteFile(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var arguments = PrepareArguments(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); - var htmlFileName = "TestResults.html"; - arguments = string.Concat(arguments, $" /logger:\"html;LogFileName={htmlFileName}\""); - this.InvokeVsTest(arguments); + var arguments = PrepareArguments(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); + var htmlFileName = "TestResults.html"; + arguments = string.Concat(arguments, $" /logger:\"html;LogFileName={htmlFileName}\""); + InvokeVsTest(arguments); - arguments = PrepareArguments(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); - arguments = string.Concat(arguments, $" /logger:\"html;LogFileName={htmlFileName}\""); - arguments = string.Concat(arguments, " /testcasefilter:Name~Pass"); - this.InvokeVsTest(arguments); + arguments = PrepareArguments(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); + arguments = string.Concat(arguments, $" /logger:\"html;LogFileName={htmlFileName}\""); + arguments = string.Concat(arguments, " /testcasefilter:Name~Pass"); + InvokeVsTest(arguments); - var htmlLogFilePath = Path.Combine(tempDir.Path, htmlFileName); - IsFileAndContentEqual(htmlLogFilePath); - } + var htmlLogFilePath = Path.Combine(tempDir.Path, htmlFileName); + IsFileAndContentEqual(htmlLogFilePath); + } - [TestMethod] - [NetCoreTargetFrameworkDataSource] - public void TrxLoggerWithExecutorUriShouldProperlyOverwriteFile(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + [TestMethod] + [NetCoreTargetFrameworkDataSource] + public void TrxLoggerWithExecutorUriShouldProperlyOverwriteFile(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var arguments = PrepareArguments(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); - var trxFileName = "TestResults.trx"; - arguments = string.Concat(arguments, $" /logger:\"logger://Microsoft/TestPlatform/TrxLogger/v1;LogFileName={trxFileName}\""); - this.InvokeVsTest(arguments); + var arguments = PrepareArguments(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); + var trxFileName = "TestResults.trx"; + arguments = string.Concat(arguments, $" /logger:\"logger://Microsoft/TestPlatform/TrxLogger/v1;LogFileName={trxFileName}\""); + InvokeVsTest(arguments); - arguments = PrepareArguments(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); - arguments = string.Concat(arguments, $" /logger:\"logger://Microsoft/TestPlatform/TrxLogger/v1;LogFileName={trxFileName}\""); - arguments = string.Concat(arguments, " /testcasefilter:Name~Pass"); - this.InvokeVsTest(arguments); + arguments = PrepareArguments(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); + arguments = string.Concat(arguments, $" /logger:\"logger://Microsoft/TestPlatform/TrxLogger/v1;LogFileName={trxFileName}\""); + arguments = string.Concat(arguments, " /testcasefilter:Name~Pass"); + InvokeVsTest(arguments); - var trxLogFilePath = Path.Combine(tempDir.Path, trxFileName); - Assert.IsTrue(IsValidXml(trxLogFilePath), "Invalid content in Trx log file"); - } + var trxLogFilePath = Path.Combine(tempDir.Path, trxFileName); + Assert.IsTrue(IsValidXml(trxLogFilePath), "Invalid content in Trx log file"); + } - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - public void TrxLoggerWithLogFilePrefixShouldGenerateMultipleTrx(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - var trxFileNamePattern = "TestResults"; + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + public void TrxLoggerWithLogFilePrefixShouldGenerateMultipleTrx(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + var trxFileNamePattern = "TestResults"; - var arguments = PrepareArguments(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); - arguments = string.Concat(arguments, $" /logger:\"logger://Microsoft/TestPlatform/TrxLogger/v1;LogFilePrefix={trxFileNamePattern}\""); - this.InvokeVsTest(arguments); + var arguments = PrepareArguments(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); + arguments = string.Concat(arguments, $" /logger:\"logger://Microsoft/TestPlatform/TrxLogger/v1;LogFilePrefix={trxFileNamePattern}\""); + InvokeVsTest(arguments); - arguments = PrepareArguments(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); - arguments = string.Concat(arguments, $" /logger:\"logger://Microsoft/TestPlatform/TrxLogger/v1;LogFilePrefix={trxFileNamePattern}\""); - arguments = string.Concat(arguments, " /testcasefilter:Name~Pass"); - this.InvokeVsTest(arguments); + arguments = PrepareArguments(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); + arguments = string.Concat(arguments, $" /logger:\"logger://Microsoft/TestPlatform/TrxLogger/v1;LogFilePrefix={trxFileNamePattern}\""); + arguments = string.Concat(arguments, " /testcasefilter:Name~Pass"); + InvokeVsTest(arguments); - var trxFilePaths = Directory.EnumerateFiles(tempDir.Path, trxFileNamePattern + "_net*.trx"); - Assert.IsTrue(trxFilePaths.Count() > 1); - } + var trxFilePaths = Directory.EnumerateFiles(tempDir.Path, trxFileNamePattern + "_net*.trx"); + Assert.IsTrue(trxFilePaths.Count() > 1); + } - [TestMethod] - [NetCoreTargetFrameworkDataSource] - public void HtmlLoggerWithExecutorUriShouldProperlyOverwriteFile(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + [TestMethod] + [NetCoreTargetFrameworkDataSource] + public void HtmlLoggerWithExecutorUriShouldProperlyOverwriteFile(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var arguments = PrepareArguments(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); - var htmlFileName = "TestResults.html"; - arguments = string.Concat(arguments, $" /logger:\"logger://Microsoft/TestPlatform/htmlLogger/v1;LogFileName{htmlFileName}\""); - this.InvokeVsTest(arguments); + var arguments = PrepareArguments(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); + var htmlFileName = "TestResults.html"; + arguments = string.Concat(arguments, $" /logger:\"logger://Microsoft/TestPlatform/htmlLogger/v1;LogFileName{htmlFileName}\""); + InvokeVsTest(arguments); - arguments = PrepareArguments(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); - arguments = string.Concat(arguments, $" /logger:\"logger://Microsoft/TestPlatform/htmlLogger/v1;LogFileName={htmlFileName}\""); - arguments = string.Concat(arguments, " /testcasefilter:Name~Pass"); - this.InvokeVsTest(arguments); + arguments = PrepareArguments(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, tempDir.Path); + arguments = string.Concat(arguments, $" /logger:\"logger://Microsoft/TestPlatform/htmlLogger/v1;LogFileName={htmlFileName}\""); + arguments = string.Concat(arguments, " /testcasefilter:Name~Pass"); + InvokeVsTest(arguments); - var htmlLogFilePath = Path.Combine(tempDir.Path, htmlFileName); - IsFileAndContentEqual(htmlLogFilePath); - } + var htmlLogFilePath = Path.Combine(tempDir.Path, htmlFileName); + IsFileAndContentEqual(htmlLogFilePath); + } - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - public void TrxLoggerResultSummaryOutcomeValueShouldBeFailedIfNoTestsExecutedAndTreatNoTestsAsErrorIsTrue(RunnerInfo runnerInfo) - { - SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + public void TrxLoggerResultSummaryOutcomeValueShouldBeFailedIfNoTestsExecutedAndTreatNoTestsAsErrorIsTrue(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var arguments = PrepareArguments(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue); - var trxFilePath = Path.Combine(tempDir.Path, "TrxLogger.trx"); + var arguments = PrepareArguments(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue); + var trxFilePath = Path.Combine(tempDir.Path, "TrxLogger.trx"); - arguments = string.Concat(arguments, $" /logger:\"trx;LogFileName={trxFilePath}\""); + arguments = string.Concat(arguments, $" /logger:\"trx;LogFileName={trxFilePath}\""); - // Setting /TestCaseFilter to the test name, which does not exists in the assembly, so we will have 0 tests executed - arguments = string.Concat(arguments, " /TestCaseFilter:TestNameThatMatchesNoTestInTheAssembly"); - arguments = string.Concat(arguments, " -- RunConfiguration.TreatNoTestsAsError=true"); + // Setting /TestCaseFilter to the test name, which does not exists in the assembly, so we will have 0 tests executed + arguments = string.Concat(arguments, " /TestCaseFilter:TestNameThatMatchesNoTestInTheAssembly"); + arguments = string.Concat(arguments, " -- RunConfiguration.TreatNoTestsAsError=true"); - this.InvokeVsTest(arguments); + InvokeVsTest(arguments); - string outcomeValue = GetElementAtributeValueFromTrx(trxFilePath, "ResultSummary", "outcome"); + string outcomeValue = GetElementAtributeValueFromTrx(trxFilePath, "ResultSummary", "outcome"); - Assert.AreEqual("Failed", outcomeValue); - } + Assert.AreEqual("Failed", outcomeValue); + } - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - public void TrxLoggerResultSummaryOutcomeValueShouldNotChangeIfNoTestsExecutedAndTreatNoTestsAsErrorIsFalse(RunnerInfo runnerInfo) - { - SetTestEnvironment(this.testEnvironment, runnerInfo); + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + public void TrxLoggerResultSummaryOutcomeValueShouldNotChangeIfNoTestsExecutedAndTreatNoTestsAsErrorIsFalse(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var arguments = PrepareArguments(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue); - var trxFileName = "TrxLogger.trx"; + var arguments = PrepareArguments(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue); + var trxFilePath = Path.Combine(tempDir.Path, "TrxLogger.trx"); - arguments = string.Concat(arguments, $" /logger:\"trx;LogFileName={trxFileName}\""); + arguments = string.Concat(arguments, $" /logger:\"trx;LogFileName={trxFilePath}\""); - // Setting /TestCaseFilter to the test name, which does not exists in the assembly, so we will have 0 tests executed - arguments = string.Concat(arguments, " /TestCaseFilter:TestNameThatMatchesNoTestInTheAssembly"); - arguments = string.Concat(arguments, " -- RunConfiguration.TreatNoTestsAsError=false"); + // Setting /TestCaseFilter to the test name, which does not exists in the assembly, so we will have 0 tests executed + arguments = string.Concat(arguments, " /TestCaseFilter:TestNameThatMatchesNoTestInTheAssembly"); + arguments = string.Concat(arguments, " -- RunConfiguration.TreatNoTestsAsError=false"); - this.InvokeVsTest(arguments); + InvokeVsTest(arguments); - var trxLogFilePath = Path.Combine(Directory.GetCurrentDirectory(), "TestResults", trxFileName); - string outcomeValue = GetElementAtributeValueFromTrx(trxLogFilePath, "ResultSummary", "outcome"); + string outcomeValue = GetElementAtributeValueFromTrx(trxFilePath, "ResultSummary", "outcome"); - Assert.AreEqual("Completed", outcomeValue); - } + Assert.AreEqual("Completed", outcomeValue); + } - private bool IsValidXml(string xmlFilePath) + private bool IsValidXml(string xmlFilePath) + { + try { - try + using var file = File.OpenRead(xmlFilePath); + using var reader = XmlReader.Create(file); + while (reader.Read()) { - using (var file = File.OpenRead(xmlFilePath)) - using (var reader = XmlReader.Create(file)) - { - while (reader.Read()) - { - } - - return true; - } - } - catch (XmlException) - { - return false; } + + return true; + } + catch (XmlException) + { + return false; } + } - private void IsFileAndContentEqual(string filePath) + private void IsFileAndContentEqual(string filePath) + { + StringBuilder sb = new(); + using (var sr = new StreamReader(filePath)) { - StringBuilder sb = new StringBuilder(); - using (var sr = new StreamReader(filePath)) - { - sb.Append(sr.ReadToEnd()); - } + sb.Append(sr.ReadToEnd()); + } - string filePathContent = sb.ToString(); - string[] divs = { "Total tests", "Passed", "Failed", "Skipped", "Run duration", "Pass percentage", "SampleUnitTestProject.UnitTest1.PassingTest" }; - foreach (string str in divs) - { - StringAssert.Contains(filePathContent, str); - } + string filePathContent = sb.ToString(); + string[] divs = { "Total tests", "Passed", "Failed", "Skipped", "Run duration", "Pass percentage", "SampleUnitTestProject.UnitTest1.PassingTest" }; + foreach (string str in divs) + { + StringAssert.Contains(filePathContent, str); } + } - private static string GetElementAtributeValueFromTrx(string trxFileName, string fieldName, string attributeName) + private static string GetElementAtributeValueFromTrx(string trxFileName, string fieldName, string attributeName) + { + using (FileStream file = File.OpenRead(trxFileName)) + using (XmlReader reader = XmlReader.Create(file)) { - using (FileStream file = File.OpenRead(trxFileName)) - using (XmlReader reader = XmlReader.Create(file)) + while (reader.Read()) { - while (reader.Read()) + if (reader.Name.Equals(fieldName) && reader.NodeType == XmlNodeType.Element && reader.HasAttributes) { - if (reader.Name.Equals(fieldName) && reader.NodeType == XmlNodeType.Element && reader.HasAttributes) - { - return reader.GetAttribute(attributeName); - } + return reader.GetAttribute(attributeName); } } - - return null; } + + return null; } } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/MultitargetingTestHostTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/MultitargetingTestHostTests.cs index 02d3dd32a5..4780485676 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/MultitargetingTestHostTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/MultitargetingTestHostTests.cs @@ -1,30 +1,29 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.AcceptanceTests; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestClass] - public class MultitargetingTestHostTests : AcceptanceTestBase +[TestClass] +public class MultitargetingTestHostTests : AcceptanceTestBase +{ + [TestMethod] + [TestCategory("Windows-Review")] + // the underlying test is using xUnit to avoid AppDomain enhancements in MSTest that make this pass even without multitargetting + // xUnit supports net452 onwards, so that is why this starts at net452, I also don't test all framework versions + [NetCoreRunner(NETFX452_48)] + [NetFrameworkRunner(NETFX452_48)] + public void RunningTestWithAFailingDebugAssertDoesNotCrashTheHostingProcess(RunnerInfo runnerInfo) { - [TestMethod] - [TestCategory("Windows-Review")] - // the underlying test is using xUnit to avoid AppDomain enhancements in MSTest that make this pass even without multitargetting - // xUnit supports net452 onwards, so that is why this starts at net452, I also don't test all framework versions - [NetCoreRunner(NETFX452_48)] - [NetFrameworkRunner(NETFX452_48)] - public void RunningTestWithAFailingDebugAssertDoesNotCrashTheHostingProcess(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var assemblyPath = this.BuildMultipleAssemblyPath("MultitargetedNetFrameworkProject.dll").Trim('\"'); - var arguments = PrepareArguments(assemblyPath, null, null, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - this.InvokeVsTest(arguments); + var assemblyPath = BuildMultipleAssemblyPath("MultitargetedNetFrameworkProject.dll").Trim('\"'); + var arguments = PrepareArguments(assemblyPath, null, null, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + InvokeVsTest(arguments); - this.ValidateSummaryStatus(passedTestsCount: 1, failedTestsCount: 0, 0); - } + ValidateSummaryStatus(passedTestsCount: 1, failedTestsCount: 0, 0); } -} \ No newline at end of file +} diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/PlatformTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/PlatformTests.cs index 3ed4d18ae4..4dcdd8ed26 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/PlatformTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/PlatformTests.cs @@ -1,59 +1,58 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests +namespace Microsoft.TestPlatform.AcceptanceTests; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +// monitoring the processes does not work correctly +[TestCategory("Windows-Review")] +public class PlatformTests : AcceptanceTestBase { - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; + /// + /// The run test execution with platform x64. + /// + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunTestExecutionWithPlatformx64(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + + var platformArg = " /Platform:x64"; + RunTestExecutionWithPlatform(platformArg, "testhost", 1); + } + + /// + /// The run test execution with platform x86. + /// + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunTestExecutionWithPlatformx86(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + + var platformArg = " /Platform:x86"; + RunTestExecutionWithPlatform(platformArg, "testhost.x86", 1); + } - [TestClass] - // monitoring the processes does not work correctly - [TestCategory("Windows-Review")] - public class PlatformTests : AcceptanceTestBase + private void RunTestExecutionWithPlatform(string platformArg, string testhostProcessName, int expectedNumOfProcessCreated) { - /// - /// The run test execution with platform x64. - /// - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunTestExecutionWithPlatformx64(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - - var platformArg = " /Platform:x64"; - this.RunTestExecutionWithPlatform(platformArg, "testhost", 1); - } - - /// - /// The run test execution with platform x86. - /// - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunTestExecutionWithPlatformx86(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - - var platformArg = " /Platform:x86"; - this.RunTestExecutionWithPlatform(platformArg, "testhost.x86", 1); - } - - private void RunTestExecutionWithPlatform(string platformArg, string testhostProcessName, int expectedNumOfProcessCreated) - { - using var tempDir = new TempDirectory(); - - var arguments = PrepareArguments( - this.GetSampleTestAssembly(), - this.GetTestAdapterPath(), - string.Empty, this.FrameworkArgValue, - this.testEnvironment.InIsolationValue, resultsDirectory: tempDir.Path); - - arguments = string.Concat(arguments, platformArg, GetDiagArg(tempDir.Path)); - this.InvokeVsTest(arguments); - - AssertExpectedNumberOfHostProcesses(expectedNumOfProcessCreated, tempDir.Path, new[] { testhostProcessName }, arguments, this.GetConsoleRunnerPath()); - this.ValidateSummaryStatus(1, 1, 1); - } + using var tempDir = new TempDirectory(); + + var arguments = PrepareArguments( + GetSampleTestAssembly(), + GetTestAdapterPath(), + string.Empty, FrameworkArgValue, + _testEnvironment.InIsolationValue, resultsDirectory: tempDir.Path); + + arguments = string.Concat(arguments, platformArg, GetDiagArg(tempDir.Path)); + InvokeVsTest(arguments); + + AssertExpectedNumberOfHostProcesses(expectedNumOfProcessCreated, tempDir.Path, new[] { testhostProcessName }, arguments, GetConsoleRunnerPath()); + ValidateSummaryStatus(1, 1, 1); } } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/PortableNugetPackageTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/PortableNugetPackageTests.cs index 8429db6952..657970bfbf 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/PortableNugetPackageTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/PortableNugetPackageTests.cs @@ -1,100 +1,99 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using System.IO; - using System.IO.Compression; - using System.Linq; +namespace Microsoft.TestPlatform.AcceptanceTests; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.IO; +using System.IO.Compression; +using System.Linq; - [TestClass] - public class PortableNugetPackageTests : AcceptanceTestBase - { - private static string portablePackageFolder; +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; +using Microsoft.VisualStudio.TestTools.UnitTesting; - [ClassInitialize] - public static void ClassInit(TestContext _) - { - var packageLocation = Path.Combine(IntegrationTestEnvironment.TestPlatformRootDirectory, "artifacts", IntegrationTestEnvironment.BuildConfiguration, "packages"); - var nugetPackage = Directory.EnumerateFiles(packageLocation, "Microsoft.TestPlatform.Portable.*.nupkg").ToList(); - portablePackageFolder = Path.Combine(packageLocation, Path.GetFileNameWithoutExtension(nugetPackage[0])); - if (Directory.Exists(portablePackageFolder)) - { - Directory.Delete(portablePackageFolder, recursive: true); - } - ZipFile.ExtractToDirectory(nugetPackage[0], portablePackageFolder); - } +[TestClass] +public class PortableNugetPackageTests : AcceptanceTestBase +{ + private static string s_portablePackageFolder; - [ClassCleanup] - public static void ClassCleanup() + [ClassInitialize] + public static void ClassInit(TestContext _) + { + var packageLocation = Path.Combine(IntegrationTestEnvironment.TestPlatformRootDirectory, "artifacts", IntegrationTestEnvironment.BuildConfiguration, "packages"); + var nugetPackage = Directory.EnumerateFiles(packageLocation, "Microsoft.TestPlatform.Portable.*.nupkg").ToList(); + s_portablePackageFolder = Path.Combine(packageLocation, Path.GetFileNameWithoutExtension(nugetPackage[0])); + if (Directory.Exists(s_portablePackageFolder)) { - Directory.Delete(portablePackageFolder, true); + Directory.Delete(s_portablePackageFolder, recursive: true); } + ZipFile.ExtractToDirectory(nugetPackage[0], s_portablePackageFolder); + } - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - [NetCoreTargetFrameworkDataSource] - public void RunMultipleTestAssemblies(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + [ClassCleanup] + public static void ClassCleanup() + { + Directory.Delete(s_portablePackageFolder, true); + } - var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject.dll", "SimpleTestProject2.dll").Trim('\"'); + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetCoreTargetFrameworkDataSource] + public void RunMultipleTestAssemblies(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); - this.InvokeVsTestForExecution(assemblyPaths, this.GetTestAdapterPath(), this.FrameworkArgValue, string.Empty); + var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject.dll", "SimpleTestProject2.dll").Trim('\"'); - this.ValidateSummaryStatus(2, 2, 2); - this.ExitCodeEquals(1); // failing tests - } + InvokeVsTestForExecution(assemblyPaths, GetTestAdapterPath(), FrameworkArgValue, string.Empty); - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - [NetCoreTargetFrameworkDataSource] - public void DiscoverAllTests(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + ValidateSummaryStatus(2, 2, 2); + ExitCodeEquals(1); // failing tests + } - this.InvokeVsTestForDiscovery(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue); + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetCoreTargetFrameworkDataSource] + public void DiscoverAllTests(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); - var listOfTests = new[] { "SampleUnitTestProject.UnitTest1.PassingTest", "SampleUnitTestProject.UnitTest1.FailingTest", "SampleUnitTestProject.UnitTest1.SkippingTest" }; - this.ValidateDiscoveredTests(listOfTests); - this.ExitCodeEquals(0); - } + InvokeVsTestForDiscovery(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, FrameworkArgValue); + + var listOfTests = new[] { "SampleUnitTestProject.UnitTest1.PassingTest", "SampleUnitTestProject.UnitTest1.FailingTest", "SampleUnitTestProject.UnitTest1.SkippingTest" }; + ValidateDiscoveredTests(listOfTests); + ExitCodeEquals(0); + } - public override string GetConsoleRunnerPath() + public override string GetConsoleRunnerPath() + { + string consoleRunnerPath = string.Empty; + + if (IsDesktopRunner()) { - string consoleRunnerPath = string.Empty; - - if (this.IsDesktopRunner()) - { - consoleRunnerPath = Path.Combine(portablePackageFolder, "tools", "net451", "vstest.console.exe"); - } - else if (this.IsNetCoreRunner()) - { - var executablePath = IsWindows ? @"dotnet\dotnet.exe" : @"dotnet-linux/dotnet"; - consoleRunnerPath = Path.Combine(this.testEnvironment.ToolsDirectory, executablePath); - } - else - { - Assert.Fail("Unknown Runner framework - [{0}]", this.testEnvironment.RunnerFramework); - } - - Assert.IsTrue(File.Exists(consoleRunnerPath), "GetConsoleRunnerPath: Path not found: {0}", consoleRunnerPath); - return consoleRunnerPath; + consoleRunnerPath = Path.Combine(s_portablePackageFolder, "tools", "net451", "vstest.console.exe"); } - - protected override string SetVSTestConsoleDLLPathInArgs(string args) + else if (IsNetCoreRunner()) { - var vstestConsoleDll = Path.Combine(portablePackageFolder, "tools", "netcoreapp2.1", "vstest.console.dll"); - vstestConsoleDll = vstestConsoleDll.AddDoubleQuote(); - args = string.Concat( - vstestConsoleDll, - " ", - args); - return args; + var executablePath = IsWindows ? @"dotnet\dotnet.exe" : @"dotnet-linux/dotnet"; + consoleRunnerPath = Path.Combine(_testEnvironment.ToolsDirectory, executablePath); } + else + { + Assert.Fail("Unknown Runner framework - [{0}]", _testEnvironment.RunnerFramework); + } + + Assert.IsTrue(File.Exists(consoleRunnerPath), "GetConsoleRunnerPath: Path not found: {0}", consoleRunnerPath); + return consoleRunnerPath; + } + + protected override string SetVSTestConsoleDLLPathInArgs(string args) + { + var vstestConsoleDll = Path.Combine(s_portablePackageFolder, "tools", "netcoreapp2.1", "vstest.console.dll"); + vstestConsoleDll = vstestConsoleDll.AddDoubleQuote(); + args = string.Concat( + vstestConsoleDll, + " ", + args); + return args; } } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/Program.cs b/test/Microsoft.TestPlatform.AcceptanceTests/Program.cs index f51a7b7fe2..2b49b9440a 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/Program.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/Program.cs @@ -1,11 +1,13 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace testhost.UnitTests +#pragma warning disable IDE1006 // Naming Styles +namespace testhost.UnitTests; +#pragma warning restore IDE1006 // Naming Styles + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/Properties/AssemblyInfo.cs b/test/Microsoft.TestPlatform.AcceptanceTests/Properties/AssemblyInfo.cs index 38ee57f5f7..907e21e101 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/Properties/AssemblyInfo.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/Properties/AssemblyInfo.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Microsoft.VisualStudio.TestTools.UnitTesting; + using System.Reflection; using System.Runtime.InteropServices; @@ -22,4 +23,4 @@ [assembly: Guid("755996fa-672a-4272-9776-7f707a520058")] // Enable IAP at method level with as many threads as possible based on CPU and core count. -[assembly: Parallelize(Workers = 0, Scope = ExecutionScope.MethodLevel)] \ No newline at end of file +[assembly: Parallelize(Workers = 0, Scope = ExecutionScope.MethodLevel)] diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/ResultsDirectoryTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/ResultsDirectoryTests.cs index 06b19f8be0..a76cc6f2ec 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/ResultsDirectoryTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/ResultsDirectoryTests.cs @@ -1,62 +1,62 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using System.IO; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.AcceptanceTests; - [TestClass] - public class ResultsDirectoryTests : AcceptanceTestBase - { - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void TrxFileShouldBeCreatedInResultsDirectory(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); +using System.IO; - var arguments = PrepareArguments(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue); - var trxFileName = "TestResults.trx"; - using var tempDir = new TempDirectory(); - var trxFilePath = Path.Combine(tempDir.Path, trxFileName); - arguments = string.Concat(arguments, $" /logger:\"trx;LogFileName={trxFileName}\""); - arguments = string.Concat(arguments, $" /ResultsDirectory:{tempDir.Path}"); +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; - // Delete if already exists - TempDirectory.TryRemoveDirectory(tempDir.Path); +[TestClass] +public class ResultsDirectoryTests : AcceptanceTestBase +{ + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void TrxFileShouldBeCreatedInResultsDirectory(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); - this.InvokeVsTest(arguments); + var arguments = PrepareArguments(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue); + var trxFileName = "TestResults.trx"; + using var tempDir = new TempDirectory(); + var trxFilePath = Path.Combine(tempDir.Path, trxFileName); + arguments = string.Concat(arguments, $" /logger:\"trx;LogFileName={trxFileName}\""); + arguments = string.Concat(arguments, $" /ResultsDirectory:{tempDir.Path}"); - Assert.IsTrue(File.Exists(trxFilePath), $"Expected Trx file: {trxFilePath} not created in results directory"); - } + // Delete if already exists + TempDirectory.TryRemoveDirectory(tempDir.Path); - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void ResultsDirectoryRelativePathShouldWork(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + InvokeVsTest(arguments); - var arguments = PrepareArguments(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue); - var trxFileName = "TestResults.trx"; - var relativeDirectory = @"relative\directory"; - var resultsDirectory = Path.Combine(Directory.GetCurrentDirectory(), relativeDirectory); + Assert.IsTrue(File.Exists(trxFilePath), $"Expected Trx file: {trxFilePath} not created in results directory"); + } - var trxFilePath = Path.Combine(resultsDirectory, trxFileName); - arguments = string.Concat(arguments, $" /logger:\"trx;LogFileName={trxFileName}\""); - arguments = string.Concat(arguments, $" /ResultsDirectory:{relativeDirectory}"); + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void ResultsDirectoryRelativePathShouldWork(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); - if (Directory.Exists(resultsDirectory)) - { - Directory.Delete(resultsDirectory, true); - } + var arguments = PrepareArguments(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue); + var trxFileName = "TestResults.trx"; + var relativeDirectory = @"relative\directory"; + var resultsDirectory = Path.Combine(Directory.GetCurrentDirectory(), relativeDirectory); - this.InvokeVsTest(arguments); + var trxFilePath = Path.Combine(resultsDirectory, trxFileName); + arguments = string.Concat(arguments, $" /logger:\"trx;LogFileName={trxFileName}\""); + arguments = string.Concat(arguments, $" /ResultsDirectory:{relativeDirectory}"); - Assert.IsTrue(File.Exists(trxFilePath), $"Expected Trx file: {trxFilePath} not created in results directory"); - TempDirectory.TryRemoveDirectory(resultsDirectory); + if (Directory.Exists(resultsDirectory)) + { + Directory.Delete(resultsDirectory, true); } + + InvokeVsTest(arguments); + + Assert.IsTrue(File.Exists(trxFilePath), $"Expected Trx file: {trxFilePath} not created in results directory"); + TempDirectory.TryRemoveDirectory(resultsDirectory); } } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/RunsettingsTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/RunsettingsTests.cs index 27c1f62e50..8f10458467 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/RunsettingsTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/RunsettingsTests.cs @@ -1,274 +1,275 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests +namespace Microsoft.TestPlatform.AcceptanceTests; + +using System; +using System.Collections.Generic; +using System.IO; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +// monitoring the processes does not work correctly +[TestCategory("Windows-Review")] +public class RunsettingsTests : AcceptanceTestBase { - using System; - using System.Collections.Generic; - using System.IO; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - // monitoring the processes does not work correctly - [TestCategory("Windows-Review")] - public class RunsettingsTests : AcceptanceTestBase + #region Runsettings precedence tests + /// + /// Command line run settings should have high precedence among settings file, cli runsettings and cli switches + /// + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void CommandLineRunSettingsShouldWinAmongAllOptions(RunnerInfo runnerInfo) { - #region Runsettings precedence tests - /// - /// Command line run settings should have high precedence among settings file, cli runsettings and cli switches - /// - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void CommandLineRunSettingsShouldWinAmongAllOptions(RunnerInfo runnerInfo) + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + + var targetPlatform = "x86"; + var testhostProcessName = new[] { "testhost.x86" }; + var expectedNumOfProcessCreated = 1; + + // passing parallel + var runConfigurationDictionary = new Dictionary { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + { "MaxCpuCount", "0" }, + { "TargetFrameworkVersion", GetTargetFramworkForRunsettings() }, + { "TestAdaptersPaths", GetTestAdapterPath() } + }; + // passing different platform + var additionalArgs = "/Platform:x64"; + + var runSettingsArgs = String.Join( + " ", + new string[] + { + "RunConfiguration.MaxCpuCount=1", + string.Concat("RunConfiguration.TargetPlatform=",targetPlatform), + string.Concat("RunConfiguration.TargetFrameworkVersion=" , GetTargetFramworkForRunsettings()), + string.Concat("RunConfiguration.TestAdaptersPaths=" , GetTestAdapterPath()) + }); - var targetPlatform = "x86"; - var testhostProcessName = new[] { "testhost.x86" }; - var expectedNumOfProcessCreated = 1; + RunTestWithRunSettings(runConfigurationDictionary, runSettingsArgs, additionalArgs, testhostProcessName, expectedNumOfProcessCreated); + } - // passing parallel - var runConfigurationDictionary = new Dictionary - { - { "MaxCpuCount", "0" }, - { "TargetFrameworkVersion", this.GetTargetFramworkForRunsettings() }, - { "TestAdaptersPaths", this.GetTestAdapterPath() } - }; - // passing different platform - var additionalArgs = "/Platform:x64"; - - var runSettingsArgs = String.Join( - " ", - new string[] - { - "RunConfiguration.MaxCpuCount=1", - string.Concat("RunConfiguration.TargetPlatform=",targetPlatform), - string.Concat("RunConfiguration.TargetFrameworkVersion=" , this.GetTargetFramworkForRunsettings()), - string.Concat("RunConfiguration.TestAdaptersPaths=" , this.GetTestAdapterPath()) - }); - - this.RunTestWithRunSettings(runConfigurationDictionary, runSettingsArgs, additionalArgs, testhostProcessName, expectedNumOfProcessCreated); - } + /// + /// Command line run settings should have high precedence between cli runsettings and cli switches. + /// + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void CLIRunsettingsShouldWinBetweenCLISwitchesAndCLIRunsettings(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); - /// - /// Command line run settings should have high precedence between cli runsettings and cli switches. - /// - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void CLIRunsettingsShouldWinBetweenCLISwitchesAndCLIRunsettings(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - - var targetPlatform = "x86"; - var testhostProcessName = new[] { "testhost.x86" }; - var expectedNumOfProcessCreated = 1; - - // Pass parallel - var additionalArgs = "/Parallel"; - - // Pass non parallel - var runSettingsArgs = String.Join( - " ", - new string[] - { - "RunConfiguration.MaxCpuCount=1", - string.Concat("RunConfiguration.TargetPlatform=",targetPlatform), - string.Concat("RunConfiguration.TargetFrameworkVersion=" , this.GetTargetFramworkForRunsettings()), - string.Concat("RunConfiguration.TestAdaptersPaths=" , this.GetTestAdapterPath()) - }); - - this.RunTestWithRunSettings(null, runSettingsArgs, additionalArgs, testhostProcessName, expectedNumOfProcessCreated); - } + var targetPlatform = "x86"; + var testhostProcessName = new[] { "testhost.x86" }; + var expectedNumOfProcessCreated = 1; - /// - /// Command line switches should have high precedence if runsetting file and command line switch specified - /// - /// - /// - /// - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void CommandLineSwitchesShouldWinBetweenSettingsFileAndCommandLineSwitches(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + // Pass parallel + var additionalArgs = "/Parallel"; - var testhostProcessName = new[] { "testhost.x86" }; - var expectedNumOfProcessCreated = 1; + // Pass non parallel + var runSettingsArgs = String.Join( + " ", + new string[] + { + "RunConfiguration.MaxCpuCount=1", + string.Concat("RunConfiguration.TargetPlatform=",targetPlatform), + string.Concat("RunConfiguration.TargetFrameworkVersion=" , GetTargetFramworkForRunsettings()), + string.Concat("RunConfiguration.TestAdaptersPaths=" , GetTestAdapterPath()) + }); - // passing different platform - var runConfigurationDictionary = new Dictionary - { - { "MaxCpuCount", "1" }, - { "TargetPlatform", "x64" }, - { "TargetFrameworkVersion", this.GetTargetFramworkForRunsettings() }, - { "TestAdaptersPaths", this.GetTestAdapterPath() } - }; - var additionalArgs = "/Platform:x86"; + RunTestWithRunSettings(null, runSettingsArgs, additionalArgs, testhostProcessName, expectedNumOfProcessCreated); + } - this.RunTestWithRunSettings(runConfigurationDictionary, null, additionalArgs, testhostProcessName, expectedNumOfProcessCreated); - } + /// + /// Command line switches should have high precedence if runsetting file and command line switch specified + /// + /// + /// + /// + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void CommandLineSwitchesShouldWinBetweenSettingsFileAndCommandLineSwitches(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); - #endregion + var testhostProcessName = new[] { "testhost.x86" }; + var expectedNumOfProcessCreated = 1; - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunSettingsWithoutParallelAndPlatformX86(RunnerInfo runnerInfo) + // passing different platform + var runConfigurationDictionary = new Dictionary { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + { "MaxCpuCount", "1" }, + { "TargetPlatform", "x64" }, + { "TargetFrameworkVersion", GetTargetFramworkForRunsettings() }, + { "TestAdaptersPaths", GetTestAdapterPath() } + }; + var additionalArgs = "/Platform:x86"; + + RunTestWithRunSettings(runConfigurationDictionary, null, additionalArgs, testhostProcessName, expectedNumOfProcessCreated); + } - var targetPlatform = "x86"; - var testhostProcessNames = new[] { "testhost.x86" }; - var expectedNumOfProcessCreated = 1; + #endregion - var runConfigurationDictionary = new Dictionary - { - { "MaxCpuCount", "1" }, - { "TargetPlatform", targetPlatform }, - { "TargetFrameworkVersion", this.GetTargetFramworkForRunsettings() }, - { "TestAdaptersPaths", this.GetTestAdapterPath() } - }; - this.RunTestWithRunSettings(runConfigurationDictionary, null, null, testhostProcessNames, expectedNumOfProcessCreated); - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunSettingsWithoutParallelAndPlatformX86(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunSettingsParamsAsArguments(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - - var targetPlatform = "x86"; - var testhostProcessName = new[] { "testhost.x86" }; - var expectedNumOfProcessCreated = 1; - - var runSettingsArgs = String.Join( - " ", - new string[] - { - "RunConfiguration.MaxCpuCount=1", - string.Concat("RunConfiguration.TargetPlatform=",targetPlatform), - string.Concat("RunConfiguration.TargetFrameworkVersion=" , this.GetTargetFramworkForRunsettings()), - string.Concat("RunConfiguration.TestAdaptersPaths=" , this.GetTestAdapterPath()) - }); - - this.RunTestWithRunSettings(null, runSettingsArgs, null, testhostProcessName, expectedNumOfProcessCreated); - } + var targetPlatform = "x86"; + var testhostProcessNames = new[] { "testhost.x86" }; + var expectedNumOfProcessCreated = 1; - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunSettingsAndRunSettingsParamsAsArguments(RunnerInfo runnerInfo) + var runConfigurationDictionary = new Dictionary { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + { "MaxCpuCount", "1" }, + { "TargetPlatform", targetPlatform }, + { "TargetFrameworkVersion", GetTargetFramworkForRunsettings() }, + { "TestAdaptersPaths", GetTestAdapterPath() } + }; + RunTestWithRunSettings(runConfigurationDictionary, null, null, testhostProcessNames, expectedNumOfProcessCreated); + } - var targetPlatform = "x86"; - var testhostProcessName = new[] { "testhost.x86" }; - var expectedNumOfProcessCreated = 1; - var runConfigurationDictionary = new Dictionary - { - { "MaxCpuCount", "2" }, - { "TargetPlatform", targetPlatform }, - { "TargetFrameworkVersion", this.GetTargetFramworkForRunsettings() }, - { "TestAdaptersPaths", this.GetTestAdapterPath() } - }; + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunSettingsParamsAsArguments(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); - var runSettingsArgs = String.Join( - " ", - new string[] - { - "RunConfiguration.MaxCpuCount=1", - string.Concat("RunConfiguration.TargetPlatform=",targetPlatform), - string.Concat("RunConfiguration.TargetFrameworkVersion=" , this.GetTargetFramworkForRunsettings()), - string.Concat("RunConfiguration.TestAdaptersPaths=" , this.GetTestAdapterPath()) - }); - - this.RunTestWithRunSettings(runConfigurationDictionary, runSettingsArgs, null, testhostProcessName, expectedNumOfProcessCreated); - } + var targetPlatform = "x86"; + var testhostProcessName = new[] { "testhost.x86" }; + var expectedNumOfProcessCreated = 1; - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunSettingsWithParallelAndPlatformX64(RunnerInfo runnerInfo) + var runSettingsArgs = String.Join( + " ", + new string[] + { + "RunConfiguration.MaxCpuCount=1", + string.Concat("RunConfiguration.TargetPlatform=",targetPlatform), + string.Concat("RunConfiguration.TargetFrameworkVersion=" , GetTargetFramworkForRunsettings()), + string.Concat("RunConfiguration.TestAdaptersPaths=" , GetTestAdapterPath()) + }); + + RunTestWithRunSettings(null, runSettingsArgs, null, testhostProcessName, expectedNumOfProcessCreated); + } + + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunSettingsAndRunSettingsParamsAsArguments(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + + var targetPlatform = "x86"; + var testhostProcessName = new[] { "testhost.x86" }; + var expectedNumOfProcessCreated = 1; + var runConfigurationDictionary = new Dictionary { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + { "MaxCpuCount", "2" }, + { "TargetPlatform", targetPlatform }, + { "TargetFrameworkVersion", GetTargetFramworkForRunsettings() }, + { "TestAdaptersPaths", GetTestAdapterPath() } + }; + + var runSettingsArgs = String.Join( + " ", + new string[] + { + "RunConfiguration.MaxCpuCount=1", + string.Concat("RunConfiguration.TargetPlatform=",targetPlatform), + string.Concat("RunConfiguration.TargetFrameworkVersion=" , GetTargetFramworkForRunsettings()), + string.Concat("RunConfiguration.TestAdaptersPaths=" , GetTestAdapterPath()) + }); - var targetPlatform = "x64"; - var testhostProcessName = new[] { "testhost" }; - var expectedProcessCreated = 2; + RunTestWithRunSettings(runConfigurationDictionary, runSettingsArgs, null, testhostProcessName, expectedNumOfProcessCreated); + } - var runConfigurationDictionary = new Dictionary - { - { "MaxCpuCount", "2" }, - { "TargetPlatform", targetPlatform }, - { "TargetFrameworkVersion", this.GetTargetFramworkForRunsettings()}, - { "TestAdaptersPaths", this.GetTestAdapterPath() } - }; - this.RunTestWithRunSettings(runConfigurationDictionary, null, null, testhostProcessName, expectedProcessCreated); - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunSettingsWithParallelAndPlatformX64(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + + var targetPlatform = "x64"; + var testhostProcessName = new[] { "testhost" }; + var expectedProcessCreated = 2; - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - [NetCoreTargetFrameworkDataSource] - public void RunSettingsWithInvalidValueShouldLogError(RunnerInfo runnerInfo) + var runConfigurationDictionary = new Dictionary { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + { "MaxCpuCount", "2" }, + { "TargetPlatform", targetPlatform }, + { "TargetFrameworkVersion", GetTargetFramworkForRunsettings()}, + { "TestAdaptersPaths", GetTestAdapterPath() } + }; + RunTestWithRunSettings(runConfigurationDictionary, null, null, testhostProcessName, expectedProcessCreated); + } - var runConfigurationDictionary = new Dictionary + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetCoreTargetFrameworkDataSource] + public void RunSettingsWithInvalidValueShouldLogError(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var runConfigurationDictionary = new Dictionary { { "TargetPlatform", "123" } }; - var runsettingsFilePath = this.GetRunsettingsFilePath(runConfigurationDictionary, tempDir); - var arguments = PrepareArguments( - this.GetSampleTestAssembly(), - string.Empty, - runsettingsFilePath, this.FrameworkArgValue, - runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - this.InvokeVsTest(arguments); - this.StdErrorContains(@"Settings file provided does not conform to required format. An error occurred while loading the settings. Error: Invalid setting 'RunConfiguration'. Invalid value '123' specified for 'TargetPlatform'."); - } + var runsettingsFilePath = GetRunsettingsFilePath(runConfigurationDictionary, tempDir); + var arguments = PrepareArguments( + GetSampleTestAssembly(), + string.Empty, + runsettingsFilePath, FrameworkArgValue, + runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + InvokeVsTest(arguments); + StdErrorContains(@"Settings file provided does not conform to required format. An error occurred while loading the settings. Error: Invalid setting 'RunConfiguration'. Invalid value '123' specified for 'TargetPlatform'."); + } - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - [NetCoreTargetFrameworkDataSource] - public void TestAdapterPathFromRunSettings(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetCoreTargetFrameworkDataSource] + public void TestAdapterPathFromRunSettings(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var runConfigurationDictionary = new Dictionary + var runConfigurationDictionary = new Dictionary { - { "TestAdaptersPaths", this.GetTestAdapterPath() } + { "TestAdaptersPaths", GetTestAdapterPath() } }; - var runsettingsFilePath = this.GetRunsettingsFilePath(runConfigurationDictionary, tempDir); - var arguments = PrepareArguments( - this.GetSampleTestAssembly(), - string.Empty, - runsettingsFilePath, this.FrameworkArgValue, - runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 1, 1); - } + var runsettingsFilePath = GetRunsettingsFilePath(runConfigurationDictionary, tempDir); + var arguments = PrepareArguments( + GetSampleTestAssembly(), + string.Empty, + runsettingsFilePath, FrameworkArgValue, + runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 1, 1); + } - #region LegacySettings Tests + #region LegacySettings Tests - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource(inIsolation: true, useCoreRunner: false)] - public void LegacySettingsWithPlatform(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource(inIsolation: true, useCoreRunner: false)] + public void LegacySettingsWithPlatform(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var testAssemblyPath = this.GetAssetFullPath("LegacySettingsUnitTestProject.dll"); - var testAssemblyDirectory = Path.GetDirectoryName(testAssemblyPath); + var testAssemblyPath = GetAssetFullPath("LegacySettingsUnitTestProject.dll"); + _ = Path.GetDirectoryName(testAssemblyPath); - var runsettingsXml = @" + var runsettingsXml = @" true @@ -278,38 +279,38 @@ public void LegacySettingsWithPlatform(RunnerInfo runnerInfo) "; - var runsettingsFilePath = this.GetRunsettingsFilePath(null, tempDir); - File.WriteAllText(runsettingsFilePath, runsettingsXml); + var runsettingsFilePath = GetRunsettingsFilePath(null, tempDir); + File.WriteAllText(runsettingsFilePath, runsettingsXml); - var arguments = PrepareArguments( - testAssemblyPath, - string.Empty, - runsettingsFilePath, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(0, 0, 0); - } + var arguments = PrepareArguments( + testAssemblyPath, + string.Empty, + runsettingsFilePath, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + InvokeVsTest(arguments); + ValidateSummaryStatus(0, 0, 0); + } - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource(inIsolation: true, useCoreRunner: false)] - public void LegacySettingsWithScripts(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource(inIsolation: true, useCoreRunner: false)] + public void LegacySettingsWithScripts(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var testAssemblyPath = this.GetAssetFullPath("LegacySettingsUnitTestProject.dll"); + var testAssemblyPath = GetAssetFullPath("LegacySettingsUnitTestProject.dll"); - // Create the script files - var guid = Guid.NewGuid(); - var setupScriptName = "setupScript_" + guid + ".bat"; - var setupScriptPath = Path.Combine(tempDir.Path, setupScriptName); - File.WriteAllText(setupScriptPath, @"echo > %temp%\ScriptTestingFile.txt"); + // Create the script files + var guid = Guid.NewGuid(); + var setupScriptName = "setupScript_" + guid + ".bat"; + var setupScriptPath = Path.Combine(tempDir.Path, setupScriptName); + File.WriteAllText(setupScriptPath, @"echo > %temp%\ScriptTestingFile.txt"); - var cleanupScriptName = "cleanupScript_" + guid + ".bat"; - var cleanupScriptPath = Path.Combine(tempDir.Path, cleanupScriptName); - File.WriteAllText(cleanupScriptPath, @"del %temp%\ScriptTestingFile.txt"); + var cleanupScriptName = "cleanupScript_" + guid + ".bat"; + var cleanupScriptPath = Path.Combine(tempDir.Path, cleanupScriptName); + File.WriteAllText(cleanupScriptPath, @"del %temp%\ScriptTestingFile.txt"); - var runsettingsFormat = @" + var runsettingsFormat = @" true @@ -318,38 +319,38 @@ public void LegacySettingsWithScripts(RunnerInfo runnerInfo) "; - // Scripts have relative paths to temp directory where the runsettings is created. - var runsettingsXml = string.Format(runsettingsFormat, setupScriptName, cleanupScriptName); - var runsettingsPath = GetRunsettingsFilePath(null, tempDir); - File.WriteAllText(runsettingsPath, runsettingsXml); - - var arguments = PrepareArguments( - testAssemblyPath, - string.Empty, - runsettingsPath, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /testcasefilter:Name=ScriptsTest"); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 0, 0); - - // Validate cleanup script ran - var scriptPath = Path.Combine(tempDir.Path, "ScriptTestingFile.txt"); - Assert.IsFalse(File.Exists(scriptPath)); - } + // Scripts have relative paths to temp directory where the runsettings is created. + var runsettingsXml = string.Format(runsettingsFormat, setupScriptName, cleanupScriptName); + var runsettingsPath = GetRunsettingsFilePath(null, tempDir); + File.WriteAllText(runsettingsPath, runsettingsXml); + + var arguments = PrepareArguments( + testAssemblyPath, + string.Empty, + runsettingsPath, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /testcasefilter:Name=ScriptsTest"); + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 0, 0); + + // Validate cleanup script ran + var scriptPath = Path.Combine(tempDir.Path, "ScriptTestingFile.txt"); + Assert.IsFalse(File.Exists(scriptPath)); + } - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource(inIsolation: true, useCoreRunner: false)] - public void LegacySettingsWithDeploymentItem(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource(inIsolation: true, useCoreRunner: false)] + public void LegacySettingsWithDeploymentItem(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var testAssemblyPath = this.GetAssetFullPath("LegacySettingsUnitTestProject.dll"); - var testAssemblyDirectory = Path.GetDirectoryName(testAssemblyPath); + var testAssemblyPath = GetAssetFullPath("LegacySettingsUnitTestProject.dll"); + var testAssemblyDirectory = Path.GetDirectoryName(testAssemblyPath); - var deploymentItem = Path.Combine(testAssemblyDirectory, "Deployment", "DeploymentFile.xml"); + var deploymentItem = Path.Combine(testAssemblyDirectory, "Deployment", "DeploymentFile.xml"); - var runsettingsFormat = @" + var runsettingsFormat = @" true @@ -360,29 +361,29 @@ public void LegacySettingsWithDeploymentItem(RunnerInfo runnerInfo) "; - var runsettingsXml = string.Format(runsettingsFormat, deploymentItem); - var runsettingsPath = GetRunsettingsFilePath(null, tempDir); - File.WriteAllText(runsettingsPath, runsettingsXml); - - var arguments = PrepareArguments( - testAssemblyPath, - string.Empty, - runsettingsPath, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /testcasefilter:Name=DeploymentItemTest"); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 0, 0); - } + var runsettingsXml = string.Format(runsettingsFormat, deploymentItem); + var runsettingsPath = GetRunsettingsFilePath(null, tempDir); + File.WriteAllText(runsettingsPath, runsettingsXml); + + var arguments = PrepareArguments( + testAssemblyPath, + string.Empty, + runsettingsPath, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /testcasefilter:Name=DeploymentItemTest"); + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 0, 0); + } - [TestMethod] - [TestCategory("Windows")] - [NetFullTargetFrameworkDataSource(inIsolation: true, useCoreRunner: false)] - public void LegacySettingsTestTimeout(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + [TestMethod] + [TestCategory("Windows")] + [NetFullTargetFrameworkDataSource(inIsolation: true, useCoreRunner: false)] + public void LegacySettingsTestTimeout(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var testAssemblyPath = this.GetAssetFullPath("LegacySettingsUnitTestProject.dll"); - var runsettingsXml = @" + var testAssemblyPath = GetAssetFullPath("LegacySettingsUnitTestProject.dll"); + var runsettingsXml = @" true @@ -391,26 +392,26 @@ public void LegacySettingsTestTimeout(RunnerInfo runnerInfo) "; - var runsettingsPath = GetRunsettingsFilePath(null, tempDir); - File.WriteAllText(runsettingsPath, runsettingsXml); - var arguments = PrepareArguments(testAssemblyPath, string.Empty, runsettingsPath, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /testcasefilter:Name~TimeTest"); + var runsettingsPath = GetRunsettingsFilePath(null, tempDir); + File.WriteAllText(runsettingsPath, runsettingsXml); + var arguments = PrepareArguments(testAssemblyPath, string.Empty, runsettingsPath, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /testcasefilter:Name~TimeTest"); - this.InvokeVsTest(arguments); + InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 1, 0); - } + ValidateSummaryStatus(1, 1, 0); + } - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource(inIsolation: true, useCoreRunner: false)] - public void LegacySettingsAssemblyResolution(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource(inIsolation: true, useCoreRunner: false)] + public void LegacySettingsAssemblyResolution(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var testAssemblyPath = this.GetAssetFullPath("LegacySettingsUnitTestProject.dll"); - var runsettingsFormat = @" + var testAssemblyPath = GetAssetFullPath("LegacySettingsUnitTestProject.dll"); + var runsettingsFormat = @" true @@ -428,33 +429,33 @@ public void LegacySettingsAssemblyResolution(RunnerInfo runnerInfo) "; - var testAssemblyDirectory = Path.Combine(this.testEnvironment.TestAssetsPath, "LegacySettingsUnitTestProject", "DependencyAssembly"); - var runsettingsXml = string.Format(runsettingsFormat, testAssemblyDirectory); - var runsettingsPath = GetRunsettingsFilePath(null, tempDir); - File.WriteAllText(runsettingsPath, runsettingsXml); - var arguments = PrepareArguments(testAssemblyPath, string.Empty, runsettingsPath, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /testcasefilter:Name=DependencyTest"); + var testAssemblyDirectory = Path.Combine(_testEnvironment.TestAssetsPath, "LegacySettingsUnitTestProject", "DependencyAssembly"); + var runsettingsXml = string.Format(runsettingsFormat, testAssemblyDirectory); + var runsettingsPath = GetRunsettingsFilePath(null, tempDir); + File.WriteAllText(runsettingsPath, runsettingsXml); + var arguments = PrepareArguments(testAssemblyPath, string.Empty, runsettingsPath, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /testcasefilter:Name=DependencyTest"); - this.InvokeVsTest(arguments); + InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 0, 0); - } + ValidateSummaryStatus(1, 0, 0); + } - #endregion + #endregion - #region RunSettings With EnvironmentVariables Settings Tests + #region RunSettings With EnvironmentVariables Settings Tests - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void EnvironmentVariablesSettingsShouldSetEnvironmentVariables(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void EnvironmentVariablesSettingsShouldSetEnvironmentVariables(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - var testAssemblyPath = this.GetAssetFullPath("EnvironmentVariablesTestProject.dll"); + var testAssemblyPath = GetAssetFullPath("EnvironmentVariablesTestProject.dll"); - var runsettingsXml = @" + var runsettingsXml = @" C:\temp @@ -462,102 +463,101 @@ public void EnvironmentVariablesSettingsShouldSetEnvironmentVariables(RunnerInfo "; - var runsettingsPath = GetRunsettingsFilePath(null, tempDir); - File.WriteAllText(runsettingsPath, runsettingsXml); + var runsettingsPath = GetRunsettingsFilePath(null, tempDir); + File.WriteAllText(runsettingsPath, runsettingsXml); - var arguments = PrepareArguments( - testAssemblyPath, - string.Empty, - runsettingsPath, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 0, 0); - } + var arguments = PrepareArguments( + testAssemblyPath, + string.Empty, + runsettingsPath, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 0, 0); + } - #endregion - - #region RunSettings defined in project file - /// - /// RunSettingsFilePath can be specified in .csproj and should be honored by `dotnet test`, this test - /// checks that the settings were honored by translating an inconclusive test to failed "result", instead of the default "skipped". - /// This test depends on Microsoft.TestPlatform.Build\Microsoft.TestPlatform.targets being previously copied into the - /// artifacts/testArtifacts/dotnet folder. This will allow the local copy of dotnet to pickup the VSTest msbuild task. - /// - /// - [TestMethod] - // patched dotnet is not published on non-windows systems - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunSettingsAreLoadedFromProject(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - - var projectName = "ProjectFileRunSettingsTestProject.csproj"; - var projectPath = this.GetProjectFullPath(projectName); - this.InvokeDotnetTest($@"{projectPath} --logger:""Console;Verbosity=normal"""); - this.ValidateSummaryStatus(0, 1, 0); - - // make sure that we can revert the project settings back by providing a config from command line - // keeping this in the same test, because it is easier to see that we are reverting settings that - // are honored by dotnet test, instead of just using the default, which would produce the same - // result - var settingsPath = this.GetProjectAssetFullPath(projectName, "inconclusive.runsettings"); - this.InvokeDotnetTest($@"{projectPath} --settings {settingsPath} --logger:""Console;Verbosity=normal"""); - this.ValidateSummaryStatus(0, 0, 1); - } + #endregion + + #region RunSettings defined in project file + /// + /// RunSettingsFilePath can be specified in .csproj and should be honored by `dotnet test`, this test + /// checks that the settings were honored by translating an inconclusive test to failed "result", instead of the default "skipped". + /// This test depends on Microsoft.TestPlatform.Build\Microsoft.TestPlatform.targets being previously copied into the + /// artifacts/testArtifacts/dotnet folder. This will allow the local copy of dotnet to pickup the VSTest msbuild task. + /// + /// + [TestMethod] + // patched dotnet is not published on non-windows systems + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunSettingsAreLoadedFromProject(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + + var projectName = "ProjectFileRunSettingsTestProject.csproj"; + var projectPath = GetProjectFullPath(projectName); + InvokeDotnetTest($@"{projectPath} --logger:""Console;Verbosity=normal"""); + ValidateSummaryStatus(0, 1, 0); + + // make sure that we can revert the project settings back by providing a config from command line + // keeping this in the same test, because it is easier to see that we are reverting settings that + // are honored by dotnet test, instead of just using the default, which would produce the same + // result + var settingsPath = GetProjectAssetFullPath(projectName, "inconclusive.runsettings"); + InvokeDotnetTest($@"{projectPath} --settings {settingsPath} --logger:""Console;Verbosity=normal"""); + ValidateSummaryStatus(0, 0, 1); + } - #endregion + #endregion - private string GetRunsettingsFilePath(Dictionary runConfigurationDictionary, TempDirectory tempDirectory) + private string GetRunsettingsFilePath(Dictionary runConfigurationDictionary, TempDirectory tempDirectory) + { + var runsettingsPath = Path.Combine(tempDirectory.Path, "test_" + Guid.NewGuid() + ".runsettings"); + if (runConfigurationDictionary != null) { - var runsettingsPath = Path.Combine(tempDirectory.Path, "test_" + Guid.NewGuid() + ".runsettings"); - if (runConfigurationDictionary != null) - { - CreateRunSettingsFile(runsettingsPath, runConfigurationDictionary); - } - - return runsettingsPath; + CreateRunSettingsFile(runsettingsPath, runConfigurationDictionary); } - private void RunTestWithRunSettings(Dictionary runConfigurationDictionary, - string runSettingsArgs, string additionalArgs, IEnumerable testhostProcessNames, int expectedNumOfProcessCreated) - { - using var tempDir = new TempDirectory(); + return runsettingsPath; + } - var assemblyPaths = - this.BuildMultipleAssemblyPath("SimpleTestProject.dll", "SimpleTestProject2.dll").Trim('\"'); + private void RunTestWithRunSettings(Dictionary runConfigurationDictionary, + string runSettingsArgs, string additionalArgs, IEnumerable testhostProcessNames, int expectedNumOfProcessCreated) + { + using var tempDir = new TempDirectory(); - var runsettingsPath = string.Empty; + var assemblyPaths = + BuildMultipleAssemblyPath("SimpleTestProject.dll", "SimpleTestProject2.dll").Trim('\"'); - if (runConfigurationDictionary != null) - { - runsettingsPath = this.GetRunsettingsFilePath(runConfigurationDictionary, tempDir); - } + var runsettingsPath = string.Empty; - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), runsettingsPath, this.FrameworkArgValue, this.testEnvironment.InIsolationValue, resultsDirectory: tempDir.Path); - arguments += GetDiagArg(tempDir.Path); + if (runConfigurationDictionary != null) + { + runsettingsPath = GetRunsettingsFilePath(runConfigurationDictionary, tempDir); + } - if (!string.IsNullOrWhiteSpace(additionalArgs)) - { - arguments = string.Concat(arguments, " ", additionalArgs); - } + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), runsettingsPath, FrameworkArgValue, _testEnvironment.InIsolationValue, resultsDirectory: tempDir.Path); + arguments += GetDiagArg(tempDir.Path); - if (!string.IsNullOrWhiteSpace(runSettingsArgs)) - { - arguments = string.Concat(arguments, " -- ", runSettingsArgs); - } + if (!string.IsNullOrWhiteSpace(additionalArgs)) + { + arguments = string.Concat(arguments, " ", additionalArgs); + } + + if (!string.IsNullOrWhiteSpace(runSettingsArgs)) + { + arguments = string.Concat(arguments, " -- ", runSettingsArgs); + } - this.InvokeVsTest(arguments); + InvokeVsTest(arguments); - // assert - AssertExpectedNumberOfHostProcesses(expectedNumOfProcessCreated, tempDir.Path, testhostProcessNames, arguments, this.GetConsoleRunnerPath()); - this.ValidateSummaryStatus(2, 2, 2); + // assert + AssertExpectedNumberOfHostProcesses(expectedNumOfProcessCreated, tempDir.Path, testhostProcessNames, arguments, GetConsoleRunnerPath()); + ValidateSummaryStatus(2, 2, 2); - //cleanup - if (!string.IsNullOrWhiteSpace(runsettingsPath)) - { - File.Delete(runsettingsPath); - } + //cleanup + if (!string.IsNullOrWhiteSpace(runsettingsPath)) + { + File.Delete(runsettingsPath); } } } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/SelfContainedAppTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/SelfContainedAppTests.cs index 822cf29a27..3ffe39733b 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/SelfContainedAppTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/SelfContainedAppTests.cs @@ -1,36 +1,35 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.AcceptanceTests; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; - using System.IO; +using System.IO; - [TestClass] - public class SelfContainedAppTests : AcceptanceTestBase +[TestClass] +public class SelfContainedAppTests : AcceptanceTestBase +{ + [TestMethod] + [TestCategory("Windows-Review")] + // this is core 3.1 only, full framework and netcoreapp2.1 don't "publish" automatically during build + // but if you run it on 2.1 it will pass because we execute the test normally + [NetCoreTargetFrameworkDataSource(useDesktopRunner: false, useNetCore21Target: false, useNetCore31Target: true)] + public void RunningApplicationThatIsBuiltAsSelfContainedWillNotFailToFindHostpolicyDll(RunnerInfo runnerInfo) { - [TestMethod] - [TestCategory("Windows-Review")] - // this is core 3.1 only, full framework and netcoreapp2.1 don't "publish" automatically during build - // but if you run it on 2.1 it will pass because we execute the test normally - [NetCoreTargetFrameworkDataSource(useDesktopRunner: false, useNetCore21Target: false, useNetCore31Target: true)] - public void RunningApplicationThatIsBuiltAsSelfContainedWillNotFailToFindHostpolicyDll(RunnerInfo runnerInfo) - { - // when the application is self-contained which is dictated by the RuntimeIdentifier and OutputType project - // properties, the testhost.exe executable is given a runtimeconfig that instructs it to find a hostpolicy.dll and hostfxr.dll next to it - // that will fail if we run the testhost.exe from the .nuget location, but will work when we run it from the output folder - // see https://github.com/dotnet/runtime/issues/3569#issuecomment-595820524 and below for description of how it works - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); + // when the application is self-contained which is dictated by the RuntimeIdentifier and OutputType project + // properties, the testhost.exe executable is given a runtimeconfig that instructs it to find a hostpolicy.dll and hostfxr.dll next to it + // that will fail if we run the testhost.exe from the .nuget location, but will work when we run it from the output folder + // see https://github.com/dotnet/runtime/issues/3569#issuecomment-595820524 and below for description of how it works + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); - // the app is published to win10-x64 because of the runtime identifier in the project - var assemblyPath = this.BuildMultipleAssemblyPath($@"win10-x64{Path.DirectorySeparatorChar}SelfContainedAppTestProject.dll").Trim('\"'); - var arguments = PrepareArguments(assemblyPath, null, null, this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - this.InvokeVsTest(arguments); + // the app is published to win10-x64 because of the runtime identifier in the project + var assemblyPath = BuildMultipleAssemblyPath($@"win10-x64{Path.DirectorySeparatorChar}SelfContainedAppTestProject.dll").Trim('\"'); + var arguments = PrepareArguments(assemblyPath, null, null, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + InvokeVsTest(arguments); - this.ValidateSummaryStatus(passedTestsCount: 1, 0, 0); - } + ValidateSummaryStatus(passedTestsCount: 1, 0, 0); } -} \ No newline at end of file +} diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TelemetryTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TelemetryTests.cs index 03debcf357..779af61453 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TelemetryTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TelemetryTests.cs @@ -1,139 +1,139 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests +namespace Microsoft.TestPlatform.AcceptanceTests; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +[TestClass] +public class TelemetryTests : AcceptanceTestBase { - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - - [TestClass] - public class TelemetryTests : AcceptanceTestBase + private const string TELEMETRY_OPTEDIN = "VSTEST_TELEMETRY_OPTEDIN"; + private const string LOG_TELEMETRY = "VSTEST_LOGTELEMETRY"; + private const string LOG_TELEMETRY_PATH = "VSTEST_LOGTELEMETRY_PATH"; + + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetCoreTargetFrameworkDataSource] + public void RunTestsShouldPublishMetrics(RunnerInfo runnerInfo) { - private const string TELEMETRY_OPTEDIN = "VSTEST_TELEMETRY_OPTEDIN"; - private const string LOG_TELEMETRY = "VSTEST_LOGTELEMETRY"; - private const string LOG_TELEMETRY_PATH = "VSTEST_LOGTELEMETRY_PATH"; - - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - [NetCoreTargetFrameworkDataSource] - public void RunTestsShouldPublishMetrics(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); - this.RunTests(runnerInfo.RunnerFramework); - } + RunTests(runnerInfo.RunnerFramework); + } - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - [NetCoreTargetFrameworkDataSource] - public void DiscoverTestsShouldPublishMetrics(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetCoreTargetFrameworkDataSource] + public void DiscoverTestsShouldPublishMetrics(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); - this.DiscoverTests(runnerInfo.RunnerFramework); - } + DiscoverTests(runnerInfo.RunnerFramework); + } - private void RunTests(string runnerFramework) + private void RunTests(string runnerFramework) + { + if (runnerFramework.StartsWith("netcoreapp")) { - if (runnerFramework.StartsWith("netcoreapp")) - { - Assert.Inconclusive("Telemetry API is not supported for .NetCore runner"); - return; - } + Assert.Inconclusive("Telemetry API is not supported for .NetCore runner"); + return; + } - var assemblyPaths = this.GetAssetFullPath("SimpleTestProject2.dll"); + var assemblyPaths = GetAssetFullPath("SimpleTestProject2.dll"); - using var tempDir = new TempDirectory(); - var env = new Dictionary - { - [LOG_TELEMETRY_PATH] = tempDir.Path, - [TELEMETRY_OPTEDIN] = "1", - [LOG_TELEMETRY] = "1", - }; + using var tempDir = new TempDirectory(); + var env = new Dictionary + { + [LOG_TELEMETRY_PATH] = tempDir.Path, + [TELEMETRY_OPTEDIN] = "1", + [LOG_TELEMETRY] = "1", + }; - this.InvokeVsTestForExecution(assemblyPaths, this.GetTestAdapterPath(), this.FrameworkArgValue, string.Empty, env); - this.ValidateOutput("Execution", tempDir); - } + InvokeVsTestForExecution(assemblyPaths, GetTestAdapterPath(), FrameworkArgValue, string.Empty, env); + ValidateOutput("Execution", tempDir); + } - private void DiscoverTests(string runnerFramework) + private void DiscoverTests(string runnerFramework) + { + if (runnerFramework.StartsWith("netcoreapp")) { - if (runnerFramework.StartsWith("netcoreapp")) - { - Assert.Inconclusive("Telemetry API is not supported for .NetCore runner"); - return; - } + Assert.Inconclusive("Telemetry API is not supported for .NetCore runner"); + return; + } - var assemblyPaths = this.GetAssetFullPath("SimpleTestProject2.dll"); + var assemblyPaths = GetAssetFullPath("SimpleTestProject2.dll"); - using var tempDir = new TempDirectory(); - var env = new Dictionary - { - [LOG_TELEMETRY_PATH] = tempDir.Path, - [TELEMETRY_OPTEDIN] = "1", - [LOG_TELEMETRY] = "1", - }; + using var tempDir = new TempDirectory(); + var env = new Dictionary + { + [LOG_TELEMETRY_PATH] = tempDir.Path, + [TELEMETRY_OPTEDIN] = "1", + [LOG_TELEMETRY] = "1", + }; - this.InvokeVsTestForDiscovery(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, env); - this.ValidateOutput("Discovery", tempDir); - } + InvokeVsTestForDiscovery(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, env); + ValidateOutput("Discovery", tempDir); + } - private void ValidateOutput(string command, TempDirectory tempDir) + private void ValidateOutput(string command, TempDirectory tempDir) + { + if (!Directory.Exists(tempDir.Path)) { - if (!Directory.Exists(tempDir.Path)) - { - Assert.Fail("Could not find the telemetry logs folder at {0}", tempDir.Path); - } + Assert.Fail("Could not find the telemetry logs folder at {0}", tempDir.Path); + } - bool isValid = false; - var directory = new DirectoryInfo(tempDir.Path); - var file = directory.GetFiles().OrderByDescending(f => f.CreationTime).First(); + bool isValid = false; + var directory = new DirectoryInfo(tempDir.Path); + var file = directory.GetFiles().OrderByDescending(f => f.CreationTime).First(); - string[] lines = File.ReadAllLines(file.FullName); + string[] lines = File.ReadAllLines(file.FullName); - foreach (var line in lines) + foreach (var line in lines) + { + if (line.Contains(TelemetryDataConstants.TestExecutionCompleteEvent) && command.Equals("Execution", StringComparison.Ordinal)) { - if (line.Contains(TelemetryDataConstants.TestExecutionCompleteEvent) && command.Equals("Execution", StringComparison.Ordinal)) - { - var isPresent = line.Contains( - TelemetryDataConstants.NumberOfAdapterDiscoveredDuringExecution) - && line.Contains(TelemetryDataConstants.NumberOfAdapterUsedToRunTests) - && line.Contains(TelemetryDataConstants.ParallelEnabledDuringExecution + '=' + "False") - && line.Contains(TelemetryDataConstants.NumberOfSourcesSentForRun + '=' + "1") - && line.Contains(TelemetryDataConstants.RunState + '=' + "Completed") - && line.Contains(TelemetryDataConstants.TimeTakenByAllAdaptersInSec) - && line.Contains(TelemetryDataConstants.TotalTestsRun + '=' + "3") - && line.Contains(TelemetryDataConstants.TotalTestsRanByAdapter) - && line.Contains(TelemetryDataConstants.TimeTakenToRunTestsByAnAdapter); - - isValid = isPresent; - break; - } - else if (line.Contains(TelemetryDataConstants.TestDiscoveryCompleteEvent) && command.Equals("Discovery", StringComparison.Ordinal)) - { - var isPresent = line.Contains(TelemetryDataConstants.TotalTestsDiscovered + '=' + "3") - && line.Contains(TelemetryDataConstants.ParallelEnabledDuringDiscovery + '=' + "False") - && line.Contains(TelemetryDataConstants.TimeTakenInSecForDiscovery) - && line.Contains(TelemetryDataConstants.TimeTakenToLoadAdaptersInSec) - && line.Contains(TelemetryDataConstants.TimeTakenInSecByAllAdapters) - && line.Contains(TelemetryDataConstants.TotalTestsByAdapter) - && line.Contains(TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter) - && line.Contains(TelemetryDataConstants.DiscoveryState + "=Completed") - && line.Contains(TelemetryDataConstants.NumberOfSourcesSentForDiscovery + '=' + "1") - && line.Contains( - TelemetryDataConstants.NumberOfAdapterDiscoveredDuringDiscovery) - && line.Contains(TelemetryDataConstants.NumberOfAdapterUsedToDiscoverTests); - - isValid = isPresent; - break; - } + var isPresent = line.Contains( + TelemetryDataConstants.NumberOfAdapterDiscoveredDuringExecution) + && line.Contains(TelemetryDataConstants.NumberOfAdapterUsedToRunTests) + && line.Contains(TelemetryDataConstants.ParallelEnabledDuringExecution + '=' + "False") + && line.Contains(TelemetryDataConstants.NumberOfSourcesSentForRun + '=' + "1") + && line.Contains(TelemetryDataConstants.RunState + '=' + "Completed") + && line.Contains(TelemetryDataConstants.TimeTakenByAllAdaptersInSec) + && line.Contains(TelemetryDataConstants.TotalTestsRun + '=' + "3") + && line.Contains(TelemetryDataConstants.TotalTestsRanByAdapter) + && line.Contains(TelemetryDataConstants.TimeTakenToRunTestsByAnAdapter); + + isValid = isPresent; + break; + } + else if (line.Contains(TelemetryDataConstants.TestDiscoveryCompleteEvent) && command.Equals("Discovery", StringComparison.Ordinal)) + { + var isPresent = line.Contains(TelemetryDataConstants.TotalTestsDiscovered + '=' + "3") + && line.Contains(TelemetryDataConstants.ParallelEnabledDuringDiscovery + '=' + "False") + && line.Contains(TelemetryDataConstants.TimeTakenInSecForDiscovery) + && line.Contains(TelemetryDataConstants.TimeTakenToLoadAdaptersInSec) + && line.Contains(TelemetryDataConstants.TimeTakenInSecByAllAdapters) + && line.Contains(TelemetryDataConstants.TotalTestsByAdapter) + && line.Contains(TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter) + && line.Contains(TelemetryDataConstants.DiscoveryState + "=Completed") + && line.Contains(TelemetryDataConstants.NumberOfSourcesSentForDiscovery + '=' + "1") + && line.Contains( + TelemetryDataConstants.NumberOfAdapterDiscoveredDuringDiscovery) + && line.Contains(TelemetryDataConstants.NumberOfAdapterUsedToDiscoverTests); + + isValid = isPresent; + break; } - - Assert.IsTrue(isValid); } + + Assert.IsTrue(isValid); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TestCaseFilterTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TestCaseFilterTests.cs index 9f83b87b12..84bade3fa1 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TestCaseFilterTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TestCaseFilterTests.cs @@ -1,229 +1,229 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests +namespace Microsoft.TestPlatform.AcceptanceTests; + +using System.IO; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class TestCaseFilterTests : AcceptanceTestBase { - using System.IO; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; + [TestMethod] + [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetCoreTargetFrameworkDataSource] + public void RunSelectedTestsWithAndOperatorTrait(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var arguments = PrepareArguments( + GetSampleTestAssembly(), + GetTestAdapterPath(), + string.Empty, FrameworkArgValue, + runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /TestCaseFilter:\"(TestCategory=CategoryA&Priority=3)\""); + InvokeVsTest(arguments); + ValidateSummaryStatus(0, 1, 0); + } - [TestClass] - public class TestCaseFilterTests : AcceptanceTestBase + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunSelectedTestsWithCategoryTraitInMixCase(RunnerInfo runnerInfo) { - [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] - [NetCoreTargetFrameworkDataSource] - public void RunSelectedTestsWithAndOperatorTrait(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var arguments = PrepareArguments( - this.GetSampleTestAssembly(), - this.GetTestAdapterPath(), - string.Empty, this.FrameworkArgValue, - runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /TestCaseFilter:\"(TestCategory=CategoryA&Priority=3)\""); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(0, 1, 0); - } + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var arguments = PrepareArguments( + GetSampleTestAssembly(), + GetTestAdapterPath(), + string.Empty, FrameworkArgValue, + runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /TestCaseFilter:\"TestCategory=Categorya\""); + InvokeVsTest(arguments); + ValidateSummaryStatus(0, 1, 0); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunSelectedTestsWithCategoryTraitInMixCase(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var arguments = PrepareArguments( - this.GetSampleTestAssembly(), - this.GetTestAdapterPath(), - string.Empty, this.FrameworkArgValue, - runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /TestCaseFilter:\"TestCategory=Categorya\""); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(0, 1, 0); - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunSelectedTestsWithClassNameTrait(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var arguments = PrepareArguments( + GetSampleTestAssembly(), + GetTestAdapterPath(), + string.Empty, FrameworkArgValue, + runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /TestCaseFilter:\"ClassName=SampleUnitTestProject.UnitTest1\""); + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 1, 1); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunSelectedTestsWithClassNameTrait(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var arguments = PrepareArguments( - this.GetSampleTestAssembly(), - this.GetTestAdapterPath(), - string.Empty, this.FrameworkArgValue, - runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /TestCaseFilter:\"ClassName=SampleUnitTestProject.UnitTest1\""); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 1, 1); - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunSelectedTestsWithFullyQualifiedNameTrait(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var arguments = PrepareArguments( + GetSampleTestAssembly(), + GetTestAdapterPath(), + string.Empty, FrameworkArgValue, + runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat( + arguments, + " /TestCaseFilter:\"FullyQualifiedName=SampleUnitTestProject.UnitTest1.FailingTest\""); + InvokeVsTest(arguments); + ValidateSummaryStatus(0, 1, 0); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunSelectedTestsWithFullyQualifiedNameTrait(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var arguments = PrepareArguments( - this.GetSampleTestAssembly(), - this.GetTestAdapterPath(), - string.Empty, this.FrameworkArgValue, - runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat( - arguments, - " /TestCaseFilter:\"FullyQualifiedName=SampleUnitTestProject.UnitTest1.FailingTest\""); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(0, 1, 0); - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunSelectedTestsWithNameTrait(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var arguments = PrepareArguments( + GetSampleTestAssembly(), + GetTestAdapterPath(), + string.Empty, FrameworkArgValue, + runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /TestCaseFilter:\"Name=PassingTest\""); + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 0, 0); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunSelectedTestsWithNameTrait(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var arguments = PrepareArguments( - this.GetSampleTestAssembly(), - this.GetTestAdapterPath(), - string.Empty, this.FrameworkArgValue, - runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /TestCaseFilter:\"Name=PassingTest\""); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 0, 0); - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunSelectedTestsWithOrOperatorTrait(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var arguments = PrepareArguments( + GetSampleTestAssembly(), + GetTestAdapterPath(), + string.Empty, FrameworkArgValue, + runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /TestCaseFilter:\"(TestCategory=CategoryA|Priority=2)\""); + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 1, 0); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunSelectedTestsWithOrOperatorTrait(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var arguments = PrepareArguments( - this.GetSampleTestAssembly(), - this.GetTestAdapterPath(), - string.Empty, this.FrameworkArgValue, - runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /TestCaseFilter:\"(TestCategory=CategoryA|Priority=2)\""); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 1, 0); - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunSelectedTestsWithPriorityTrait(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var arguments = PrepareArguments( + GetSampleTestAssembly(), + GetTestAdapterPath(), + string.Empty, FrameworkArgValue, + runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /TestCaseFilter:\"Priority=2\""); + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 0, 0); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunSelectedTestsWithPriorityTrait(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var arguments = PrepareArguments( - this.GetSampleTestAssembly(), - this.GetTestAdapterPath(), - string.Empty, this.FrameworkArgValue, - runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /TestCaseFilter:\"Priority=2\""); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 0, 0); - } + /// + /// In case TestCaseFilter is provide without any property like Name or ClassName. ex. /TestCaseFilter:"UnitTest1" + /// this command should provide same results as /TestCaseFilter:"FullyQualifiedName~UnitTest1". + /// + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void TestCaseFilterShouldWorkIfOnlyPropertyValueGivenInExpression(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var arguments = PrepareArguments( + _testEnvironment.GetTestAsset("SimpleTestProject2.dll"), + GetTestAdapterPath(), + string.Empty, FrameworkArgValue, + runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /TestCaseFilter:UnitTest1"); + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 1, 1); + } - /// - /// In case TestCaseFilter is provide without any property like Name or ClassName. ex. /TestCaseFilter:"UnitTest1" - /// this command should provide same results as /TestCaseFilter:"FullyQualifiedName~UnitTest1". - /// - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void TestCaseFilterShouldWorkIfOnlyPropertyValueGivenInExpression(RunnerInfo runnerInfo) + /// + /// Discover tests using mstest v1 adapter with test case filters. + /// + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + public void DiscoverMstestV1TestsWithAndOperatorTrait(RunnerInfo runnerInfo) + { + if (runnerInfo.RunnerFramework.StartsWith("netcoreapp")) { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var arguments = PrepareArguments( - this.testEnvironment.GetTestAsset("SimpleTestProject2.dll"), - this.GetTestAdapterPath(), - string.Empty, this.FrameworkArgValue, - runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /TestCaseFilter:UnitTest1"); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 1, 1); + Assert.Inconclusive("Mstest v1 tests not supported with .Netcore runner."); + return; } - /// - /// Discover tests using mstest v1 adapter with test case filters. - /// - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - public void DiscoverMstestV1TestsWithAndOperatorTrait(RunnerInfo runnerInfo) - { - if (runnerInfo.RunnerFramework.StartsWith("netcoreapp")) - { - Assert.Inconclusive("Mstest v1 tests not supported with .Netcore runner."); - return; - } - - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - var arguments = PrepareArguments( - this.testEnvironment.GetTestAsset("MstestV1UnitTestProject.dll"), - this.GetTestAdapterPath(), - string.Empty, this.FrameworkArgValue, - runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - arguments = string.Concat(arguments, " /listtests /TestCaseFilter:\"(TestCategory!=CategoryA&Priority!=3)\""); - - this.InvokeVsTest(arguments); - var listOfTests = new string[] {"MstestV1UnitTestProject.UnitTest1.PassingTest1", "MstestV1UnitTestProject.UnitTest1.PassingTest2", + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + var arguments = PrepareArguments( + _testEnvironment.GetTestAsset("MstestV1UnitTestProject.dll"), + GetTestAdapterPath(), + string.Empty, FrameworkArgValue, + runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + arguments = string.Concat(arguments, " /listtests /TestCaseFilter:\"(TestCategory!=CategoryA&Priority!=3)\""); + + InvokeVsTest(arguments); + var listOfTests = new string[] {"MstestV1UnitTestProject.UnitTest1.PassingTest1", "MstestV1UnitTestProject.UnitTest1.PassingTest2", "MstestV1UnitTestProject.UnitTest1.FailingTest2", "MstestV1UnitTestProject.UnitTest1.SkippingTest" }; - var listOfNotDiscoveredTests = new string[] { "MstestV1UnitTestProject.UnitTest1.FailingTest1" }; - this.ValidateDiscoveredTests(listOfTests); - this.ValidateTestsNotDiscovered(listOfNotDiscoveredTests); - } + var listOfNotDiscoveredTests = new string[] { "MstestV1UnitTestProject.UnitTest1.FailingTest1" }; + ValidateDiscoveredTests(listOfTests); + ValidateTestsNotDiscovered(listOfNotDiscoveredTests); + } - /// - /// Discover tests using tmi adapter with test case filters. - /// - [TestMethod] - [TestCategory("Windows-Review")] - [Ignore("Temporary ignoring, because of incomplete interop work for legacy TP")] - [NetFullTargetFrameworkDataSource] - public void DiscoverTmiTestsWithOnlyPropertyValue(RunnerInfo runnerInfo) + /// + /// Discover tests using tmi adapter with test case filters. + /// + [TestMethod] + [TestCategory("Windows-Review")] + [Ignore("Temporary ignoring, because of incomplete interop work for legacy TP")] + [NetFullTargetFrameworkDataSource] + public void DiscoverTmiTestsWithOnlyPropertyValue(RunnerInfo runnerInfo) + { + if (runnerInfo.RunnerFramework.StartsWith("netcoreapp")) { - if (runnerInfo.RunnerFramework.StartsWith("netcoreapp")) - { - Assert.Inconclusive("Tmi tests not supported with .Netcore runner."); - return; - } - - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - using var tempDir = new TempDirectory(); - - string testAssemblyPath = this.testEnvironment.GetTestAsset("MstestV1UnitTestProject.dll"); - var arguments = PrepareArguments( - testAssemblyPath, - this.GetTestAdapterPath(), - string.Empty, this.FrameworkArgValue, - runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); - string testSettingsPath = Path.Combine(Path.GetDirectoryName(testAssemblyPath), "MstestV1UnitTestProjectTestSettings.testsettings"); - arguments = string.Concat(arguments, " /listtests /TestCaseFilter:PassingTest /settings:", testSettingsPath); - - this.InvokeVsTest(arguments); - var listOfTests = new string[] { "MstestV1UnitTestProject.UnitTest1.PassingTest1", "MstestV1UnitTestProject.UnitTest1.PassingTest2" }; - var listOfNotDiscoveredTests = new string[] { "MstestV1UnitTestProject.UnitTest1.FailingTest1", "MstestV1UnitTestProject.UnitTest1.FailingTest2", "MstestV1UnitTestProject.UnitTest1.SkippingTest" }; - this.ValidateDiscoveredTests(listOfTests); - this.ValidateTestsNotDiscovered(listOfNotDiscoveredTests); + Assert.Inconclusive("Tmi tests not supported with .Netcore runner."); + return; } + + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + using var tempDir = new TempDirectory(); + + string testAssemblyPath = _testEnvironment.GetTestAsset("MstestV1UnitTestProject.dll"); + var arguments = PrepareArguments( + testAssemblyPath, + GetTestAdapterPath(), + string.Empty, FrameworkArgValue, + runnerInfo.InIsolationValue, resultsDirectory: tempDir.Path); + string testSettingsPath = Path.Combine(Path.GetDirectoryName(testAssemblyPath), "MstestV1UnitTestProjectTestSettings.testsettings"); + arguments = string.Concat(arguments, " /listtests /TestCaseFilter:PassingTest /settings:", testSettingsPath); + + InvokeVsTest(arguments); + var listOfTests = new string[] { "MstestV1UnitTestProject.UnitTest1.PassingTest1", "MstestV1UnitTestProject.UnitTest1.PassingTest2" }; + var listOfNotDiscoveredTests = new string[] { "MstestV1UnitTestProject.UnitTest1.FailingTest1", "MstestV1UnitTestProject.UnitTest1.FailingTest2", "MstestV1UnitTestProject.UnitTest1.SkippingTest" }; + ValidateDiscoveredTests(listOfTests); + ValidateTestsNotDiscovered(listOfNotDiscoveredTests); } } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TestPlatformNugetPackageTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TestPlatformNugetPackageTests.cs index f5537c5e00..336b9dc62d 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TestPlatformNugetPackageTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TestPlatformNugetPackageTests.cs @@ -1,116 +1,115 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests -{ - using System; - using System.IO; - using System.IO.Compression; - using System.Linq; +namespace Microsoft.TestPlatform.AcceptanceTests; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.IO; +using System.IO.Compression; +using System.Linq; - [TestClass] - public class TestPlatformNugetPackageTests : CodeCoverageAcceptanceTestBase - { - private static string nugetPackageFolder; - private TempDirectory resultsDirectory; +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; - [ClassInitialize] - public static void ClassInit(TestContext _) - { - var packageLocation = Path.Combine(IntegrationTestEnvironment.TestPlatformRootDirectory, "artifacts", IntegrationTestEnvironment.BuildConfiguration, "packages"); - var nugetPackage = Directory.EnumerateFiles(packageLocation, "Microsoft.TestPlatform.*.nupkg").OrderBy(a => a).FirstOrDefault(); - nugetPackageFolder = Path.Combine(new TempDirectory().Path, Path.GetFileNameWithoutExtension(nugetPackage)); - ZipFile.ExtractToDirectory(nugetPackage, nugetPackageFolder); - - TryMoveDirectory( - sourceDirName: Path.Combine(nugetPackageFolder, "tools", "net451", "Team%20Tools"), - destDirName: Path.Combine(nugetPackageFolder, "tools", "net451", "Team Tools") - ); - - TryMoveDirectory( - sourceDirName: Path.Combine(nugetPackageFolder, "tools", "net451", "Team Tools", "Dynamic%20Code%20Coverage%20Tools"), - destDirName: Path.Combine(nugetPackageFolder, "tools", "net451", "Team Tools", "Dynamic Code Coverage Tools") - ); - } +[TestClass] +public class TestPlatformNugetPackageTests : CodeCoverageAcceptanceTestBase +{ + private static string s_nugetPackageFolder; + private TempDirectory _resultsDirectory; - [ClassCleanup] - public static void ClassCleanup() - { - Directory.Delete(nugetPackageFolder, true); - } + [ClassInitialize] + public static void ClassInit(TestContext _) + { + var packageLocation = Path.Combine(IntegrationTestEnvironment.TestPlatformRootDirectory, "artifacts", IntegrationTestEnvironment.BuildConfiguration, "packages"); + var nugetPackage = Directory.EnumerateFiles(packageLocation, "Microsoft.TestPlatform.*.nupkg").OrderBy(a => a).FirstOrDefault(); + s_nugetPackageFolder = Path.Combine(new TempDirectory().Path, Path.GetFileNameWithoutExtension(nugetPackage)); + ZipFile.ExtractToDirectory(nugetPackage, s_nugetPackageFolder); + + TryMoveDirectory( + sourceDirName: Path.Combine(s_nugetPackageFolder, "tools", "net451", "Team%20Tools"), + destDirName: Path.Combine(s_nugetPackageFolder, "tools", "net451", "Team Tools") + ); + + TryMoveDirectory( + sourceDirName: Path.Combine(s_nugetPackageFolder, "tools", "net451", "Team Tools", "Dynamic%20Code%20Coverage%20Tools"), + destDirName: Path.Combine(s_nugetPackageFolder, "tools", "net451", "Team Tools", "Dynamic Code Coverage Tools") + ); + } - [TestInitialize] - public void SetUp() - { - this.resultsDirectory = new TempDirectory(); - } + [ClassCleanup] + public static void ClassCleanup() + { + Directory.Delete(s_nugetPackageFolder, true); + } - [TestCleanup] - public void CleanUp() - { - this.resultsDirectory.Dispose(); - } + [TestInitialize] + public void SetUp() + { + _resultsDirectory = new TempDirectory(); + } - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource(useCoreRunner: false)] - [NetCoreTargetFrameworkDataSource(useCoreRunner: false)] - public void RunMultipleTestAssembliesWithCodeCoverage(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + [TestCleanup] + public void CleanUp() + { + _resultsDirectory.Dispose(); + } - var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject.dll", "SimpleTestProject2.dll").Trim('\"'); + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource(useCoreRunner: false)] + [NetCoreTargetFrameworkDataSource(useCoreRunner: false)] + public void RunMultipleTestAssembliesWithCodeCoverage(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); - var arguments = CreateCodeCoverageArguments(runnerInfo, assemblyPaths, out var trxFilePath); - this.InvokeVsTest(arguments); + var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject.dll", "SimpleTestProject2.dll").Trim('\"'); - this.ExitCodeEquals(1); // failing tests + var arguments = CreateCodeCoverageArguments(runnerInfo, assemblyPaths, out var trxFilePath); + InvokeVsTest(arguments); - var actualCoverageFile = CodeCoverageTests.GetCoverageFileNameFromTrx(trxFilePath, resultsDirectory.Path); - Console.WriteLine($@"Coverage file: {actualCoverageFile} Results directory: {resultsDirectory} trxfile: {trxFilePath}"); - Assert.IsTrue(File.Exists(actualCoverageFile), "Coverage file not found: {0}", actualCoverageFile); - } + ExitCodeEquals(1); // failing tests - public override string GetConsoleRunnerPath() - { - string consoleRunnerPath = string.Empty; + var actualCoverageFile = CodeCoverageTests.GetCoverageFileNameFromTrx(trxFilePath, _resultsDirectory.Path); + Console.WriteLine($@"Coverage file: {actualCoverageFile} Results directory: {_resultsDirectory} trxfile: {trxFilePath}"); + Assert.IsTrue(File.Exists(actualCoverageFile), "Coverage file not found: {0}", actualCoverageFile); + } - if (this.IsDesktopRunner()) - { - consoleRunnerPath = Path.Combine(nugetPackageFolder, "tools", "net451", "Common7", "IDE", "Extensions", "TestPlatform", "vstest.console.exe"); - } + public override string GetConsoleRunnerPath() + { + string consoleRunnerPath = string.Empty; - Assert.IsTrue(File.Exists(consoleRunnerPath), "GetConsoleRunnerPath: Path not found: {0}", consoleRunnerPath); - return consoleRunnerPath; + if (IsDesktopRunner()) + { + consoleRunnerPath = Path.Combine(s_nugetPackageFolder, "tools", "net451", "Common7", "IDE", "Extensions", "TestPlatform", "vstest.console.exe"); } - private string CreateCodeCoverageArguments( - RunnerInfo runnerInfo, - string assemblyPaths, - out string trxFilePath) - { - string diagFileName = Path.Combine(this.resultsDirectory.Path, "diaglog.txt"); + Assert.IsTrue(File.Exists(consoleRunnerPath), "GetConsoleRunnerPath: Path not found: {0}", consoleRunnerPath); + return consoleRunnerPath; + } + + private string CreateCodeCoverageArguments( + RunnerInfo runnerInfo, + string assemblyPaths, + out string trxFilePath) + { + string diagFileName = Path.Combine(_resultsDirectory.Path, "diaglog.txt"); - var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, - this.FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: resultsDirectory.Path); + var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, + FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: _resultsDirectory.Path); - arguments = string.Concat(arguments, $" /Diag:{diagFileName}", $" /EnableCodeCoverage"); + arguments = string.Concat(arguments, $" /Diag:{diagFileName}", $" /EnableCodeCoverage"); - trxFilePath = Path.Combine(this.resultsDirectory.Path, Guid.NewGuid() + ".trx"); - arguments = string.Concat(arguments, " /logger:trx;logfilename=" + trxFilePath); + trxFilePath = Path.Combine(_resultsDirectory.Path, Guid.NewGuid() + ".trx"); + arguments = string.Concat(arguments, " /logger:trx;logfilename=" + trxFilePath); - return arguments; - } + return arguments; + } - private static void TryMoveDirectory(string sourceDirName, string destDirName) + private static void TryMoveDirectory(string sourceDirName, string destDirName) + { + if (Directory.Exists(sourceDirName)) { - if (Directory.Exists(sourceDirName)) - { - Directory.Move(sourceDirName, destDirName); - } + Directory.Move(sourceDirName, destDirName); } } } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CodeCoverageTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CodeCoverageTests.cs index 02d690b1ed..dc48d20203 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CodeCoverageTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CodeCoverageTests.cs @@ -1,459 +1,461 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests +namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests; + +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; + +using Castle.Core.Internal; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +//Code coverage only supported on windows (based on the message in output) +[TestCategory("Windows-Review")] +public class CodeCoverageTests : CodeCoverageAcceptanceTestBase { - using System.Collections.Generic; - using System.Diagnostics; - using System.IO; - using System.Linq; - using System.Text.RegularExpressions; - using System.Threading; - using System.Threading.Tasks; - using Castle.Core.Internal; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - //Code coverage only supported on windows (based on the message in output) - [TestCategory("Windows-Review")] - public class CodeCoverageTests : CodeCoverageAcceptanceTestBase - { - private IVsTestConsoleWrapper vstestConsoleWrapper; - private TempDirectory tempDirectory; - private RunEventHandler runEventHandler; - private TestRunAttachmentsProcessingEventHandler testRunAttachmentsProcessingEventHandler; + private IVsTestConsoleWrapper _vstestConsoleWrapper; + private TempDirectory _tempDirectory; + private RunEventHandler _runEventHandler; + private TestRunAttachmentsProcessingEventHandler _testRunAttachmentsProcessingEventHandler; - private void Setup() - { - this.vstestConsoleWrapper = this.GetVsTestConsoleWrapper(out tempDirectory); - this.runEventHandler = new RunEventHandler(); - this.testRunAttachmentsProcessingEventHandler = new TestRunAttachmentsProcessingEventHandler(); - } + private void Setup() + { + _vstestConsoleWrapper = GetVsTestConsoleWrapper(out _tempDirectory); + _runEventHandler = new RunEventHandler(); + _testRunAttachmentsProcessingEventHandler = new TestRunAttachmentsProcessingEventHandler(); + } - [TestCleanup] - public void Cleanup() - { - this.vstestConsoleWrapper?.EndSession(); - } + [TestCleanup] + public void Cleanup() + { + _vstestConsoleWrapper?.EndSession(); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void TestRunWithCodeCoverage(RunnerInfo runnerInfo) - { - // arrange - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void TestRunWithCodeCoverage(RunnerInfo runnerInfo) + { + // arrange + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - // act - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies(), this.GetCodeCoverageRunSettings(1), new TestPlatformOptions { CollectMetrics = true }, this.runEventHandler); + // act + _vstestConsoleWrapper.RunTests(GetTestAssemblies(), GetCodeCoverageRunSettings(1), new TestPlatformOptions { CollectMetrics = true }, _runEventHandler); - // assert - Assert.AreEqual(6, this.runEventHandler.TestResults.Count); + // assert + Assert.AreEqual(6, _runEventHandler.TestResults.Count); - int expectedNumberOfAttachments = 1; - Assert.AreEqual(expectedNumberOfAttachments, this.runEventHandler.Attachments.Count); + int expectedNumberOfAttachments = 1; + Assert.AreEqual(expectedNumberOfAttachments, _runEventHandler.Attachments.Count); - AssertCoverageResults(this.runEventHandler.Attachments); + AssertCoverageResults(_runEventHandler.Attachments); - Assert.AreEqual("e5f256dc-7959-4dd6-8e4f-c11150ab28e0", this.runEventHandler.Metrics["VS.TestPlatform.DataCollector.CorProfiler.datacollector://microsoft/CodeCoverage/2.0"]); - Assert.AreEqual("e5f256dc-7959-4dd6-8e4f-c11150ab28e0", this.runEventHandler.Metrics["VS.TestPlatform.DataCollector.CoreClrProfiler.datacollector://microsoft/CodeCoverage/2.0"]); - } + Assert.AreEqual("e5f256dc-7959-4dd6-8e4f-c11150ab28e0", _runEventHandler.Metrics["VS.TestPlatform.DataCollector.CorProfiler.datacollector://microsoft/CodeCoverage/2.0"]); + Assert.AreEqual("e5f256dc-7959-4dd6-8e4f-c11150ab28e0", _runEventHandler.Metrics["VS.TestPlatform.DataCollector.CoreClrProfiler.datacollector://microsoft/CodeCoverage/2.0"]); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void TestRunWithCodeCoverageUsingClrIe(RunnerInfo runnerInfo) - { - // arrange - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void TestRunWithCodeCoverageUsingClrIe(RunnerInfo runnerInfo) + { + // arrange + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - // act - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies(), this.GetCodeCoverageRunSettings(1, true), new TestPlatformOptions { CollectMetrics = true }, this.runEventHandler); + // act + _vstestConsoleWrapper.RunTests(GetTestAssemblies(), GetCodeCoverageRunSettings(1, true), new TestPlatformOptions { CollectMetrics = true }, _runEventHandler); - // assert - Assert.AreEqual(6, this.runEventHandler.TestResults.Count); + // assert + Assert.AreEqual(6, _runEventHandler.TestResults.Count); - int expectedNumberOfAttachments = 1; - Assert.AreEqual(expectedNumberOfAttachments, this.runEventHandler.Attachments.Count); + int expectedNumberOfAttachments = 1; + Assert.AreEqual(expectedNumberOfAttachments, _runEventHandler.Attachments.Count); - AssertCoverageResults(this.runEventHandler.Attachments); + AssertCoverageResults(_runEventHandler.Attachments); - Assert.AreEqual("324f817a-7420-4e6d-b3c1-143fbed6d855", this.runEventHandler.Metrics["VS.TestPlatform.DataCollector.CorProfiler.datacollector://microsoft/CodeCoverage/2.0"]); - Assert.AreEqual("324f817a-7420-4e6d-b3c1-143fbed6d855", this.runEventHandler.Metrics["VS.TestPlatform.DataCollector.CoreClrProfiler.datacollector://microsoft/CodeCoverage/2.0"]); - } + Assert.AreEqual("324f817a-7420-4e6d-b3c1-143fbed6d855", _runEventHandler.Metrics["VS.TestPlatform.DataCollector.CorProfiler.datacollector://microsoft/CodeCoverage/2.0"]); + Assert.AreEqual("324f817a-7420-4e6d-b3c1-143fbed6d855", _runEventHandler.Metrics["VS.TestPlatform.DataCollector.CoreClrProfiler.datacollector://microsoft/CodeCoverage/2.0"]); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void TestRunWithCodeCoverageParallel(RunnerInfo runnerInfo) - { - // arrange - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void TestRunWithCodeCoverageParallel(RunnerInfo runnerInfo) + { + // arrange + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - // act - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies(), this.GetCodeCoverageRunSettings(4), new TestPlatformOptions { CollectMetrics = true }, this.runEventHandler); + // act + _vstestConsoleWrapper.RunTests(GetTestAssemblies(), GetCodeCoverageRunSettings(4), new TestPlatformOptions { CollectMetrics = true }, _runEventHandler); - // assert - Assert.AreEqual(6, this.runEventHandler.TestResults.Count); - Assert.AreEqual(1, this.runEventHandler.Attachments.Count); + // assert + Assert.AreEqual(6, _runEventHandler.TestResults.Count); + Assert.AreEqual(1, _runEventHandler.Attachments.Count); - AssertCoverageResults(this.runEventHandler.Attachments); + AssertCoverageResults(_runEventHandler.Attachments); - Assert.AreEqual("e5f256dc-7959-4dd6-8e4f-c11150ab28e0", this.runEventHandler.Metrics["VS.TestPlatform.DataCollector.CorProfiler.datacollector://microsoft/CodeCoverage/2.0"]); - Assert.AreEqual("e5f256dc-7959-4dd6-8e4f-c11150ab28e0", this.runEventHandler.Metrics["VS.TestPlatform.DataCollector.CoreClrProfiler.datacollector://microsoft/CodeCoverage/2.0"]); - } + Assert.AreEqual("e5f256dc-7959-4dd6-8e4f-c11150ab28e0", _runEventHandler.Metrics["VS.TestPlatform.DataCollector.CorProfiler.datacollector://microsoft/CodeCoverage/2.0"]); + Assert.AreEqual("e5f256dc-7959-4dd6-8e4f-c11150ab28e0", _runEventHandler.Metrics["VS.TestPlatform.DataCollector.CoreClrProfiler.datacollector://microsoft/CodeCoverage/2.0"]); + } - [TestMethod] - [NetFullTargetFrameworkDataSource()] - [NetCoreTargetFrameworkDataSource] - public async Task TestRunWithCodeCoverageAndAttachmentsProcessingWithInvokedDataCollectors(RunnerInfo runnerInfo) - => await TestRunWithCodeCoverageAndAttachmentsProcessingInternal(runnerInfo, true); + [TestMethod] + [NetFullTargetFrameworkDataSource()] + [NetCoreTargetFrameworkDataSource] + public async Task TestRunWithCodeCoverageAndAttachmentsProcessingWithInvokedDataCollectors(RunnerInfo runnerInfo) + => await TestRunWithCodeCoverageAndAttachmentsProcessingInternal(runnerInfo, true); - [TestMethod] - [NetFullTargetFrameworkDataSource()] - [NetCoreTargetFrameworkDataSource] - public async Task TestRunWithCodeCoverageAndAttachmentsProcessingWithoutInvokedDataCollectors(RunnerInfo runnerInfo) - => await TestRunWithCodeCoverageAndAttachmentsProcessingInternal(runnerInfo, false); + [TestMethod] + [NetFullTargetFrameworkDataSource()] + [NetCoreTargetFrameworkDataSource] + public async Task TestRunWithCodeCoverageAndAttachmentsProcessingWithoutInvokedDataCollectors(RunnerInfo runnerInfo) + => await TestRunWithCodeCoverageAndAttachmentsProcessingInternal(runnerInfo, false); - private async Task TestRunWithCodeCoverageAndAttachmentsProcessingInternal(RunnerInfo runnerInfo, bool withInvokedDataCollectors) - { - // arrange - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + private async Task TestRunWithCodeCoverageAndAttachmentsProcessingInternal(RunnerInfo runnerInfo, bool withInvokedDataCollectors) + { + // arrange + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Take(1), this.GetCodeCoverageRunSettings(1), this.runEventHandler); - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Skip(1), this.GetCodeCoverageRunSettings(1), this.runEventHandler); + _vstestConsoleWrapper.RunTests(GetTestAssemblies().Take(1), GetCodeCoverageRunSettings(1), _runEventHandler); + _vstestConsoleWrapper.RunTests(GetTestAssemblies().Skip(1), GetCodeCoverageRunSettings(1), _runEventHandler); - Assert.AreEqual(6, this.runEventHandler.TestResults.Count); - Assert.AreEqual(2, this.runEventHandler.Attachments.Count); - Assert.AreEqual(2, this.runEventHandler.InvokedDataCollectors.Count); + Assert.AreEqual(6, _runEventHandler.TestResults.Count); + Assert.AreEqual(2, _runEventHandler.Attachments.Count); + Assert.AreEqual(2, _runEventHandler.InvokedDataCollectors.Count); - // act - await this.vstestConsoleWrapper.ProcessTestRunAttachmentsAsync( - runEventHandler.Attachments, - withInvokedDataCollectors ? runEventHandler.InvokedDataCollectors : null, - withInvokedDataCollectors ? this.GetCodeCoverageRunSettings(1) : null, - true, - true, - testRunAttachmentsProcessingEventHandler, CancellationToken.None); + // act + await _vstestConsoleWrapper.ProcessTestRunAttachmentsAsync( + _runEventHandler.Attachments, + withInvokedDataCollectors ? _runEventHandler.InvokedDataCollectors : null, + withInvokedDataCollectors ? GetCodeCoverageRunSettings(1) : null, + true, + true, + _testRunAttachmentsProcessingEventHandler, CancellationToken.None); - // Assert - testRunAttachmentsProcessingEventHandler.EnsureSuccess(); - Assert.AreEqual(1, this.testRunAttachmentsProcessingEventHandler.Attachments.Count); + // Assert + _testRunAttachmentsProcessingEventHandler.EnsureSuccess(); + Assert.AreEqual(1, _testRunAttachmentsProcessingEventHandler.Attachments.Count); - AssertCoverageResults(this.testRunAttachmentsProcessingEventHandler.Attachments); + AssertCoverageResults(_testRunAttachmentsProcessingEventHandler.Attachments); - Assert.IsFalse(testRunAttachmentsProcessingEventHandler.CompleteArgs.IsCanceled); - Assert.IsNull(testRunAttachmentsProcessingEventHandler.CompleteArgs.Error); + Assert.IsFalse(_testRunAttachmentsProcessingEventHandler.CompleteArgs.IsCanceled); + Assert.IsNull(_testRunAttachmentsProcessingEventHandler.CompleteArgs.Error); - for (int i = 0; i < testRunAttachmentsProcessingEventHandler.ProgressArgs.Count; i++) + for (int i = 0; i < _testRunAttachmentsProcessingEventHandler.ProgressArgs.Count; i++) + { + VisualStudio.TestPlatform.ObjectModel.Client.TestRunAttachmentsProcessingProgressEventArgs progressArgs = _testRunAttachmentsProcessingEventHandler.ProgressArgs[i]; + Assert.AreEqual(i + 1, progressArgs.CurrentAttachmentProcessorIndex); + Assert.AreEqual(1, progressArgs.CurrentAttachmentProcessorUris.Count); + Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentAttachmentProcessorUris.First().AbsoluteUri); + Assert.AreEqual(withInvokedDataCollectors ? 2 : 1, progressArgs.AttachmentProcessorsCount); + if (_testRunAttachmentsProcessingEventHandler.ProgressArgs.Count == 2) { - VisualStudio.TestPlatform.ObjectModel.Client.TestRunAttachmentsProcessingProgressEventArgs progressArgs = testRunAttachmentsProcessingEventHandler.ProgressArgs[i]; - Assert.AreEqual(i + 1, progressArgs.CurrentAttachmentProcessorIndex); - Assert.AreEqual(1, progressArgs.CurrentAttachmentProcessorUris.Count); - Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentAttachmentProcessorUris.First().AbsoluteUri); - Assert.AreEqual(withInvokedDataCollectors ? 2 : 1, progressArgs.AttachmentProcessorsCount); - if (testRunAttachmentsProcessingEventHandler.ProgressArgs.Count == 2) - { - Assert.AreEqual(100, progressArgs.CurrentAttachmentProcessorProgress); - } + Assert.AreEqual(100, progressArgs.CurrentAttachmentProcessorProgress); } + } - Assert.AreEqual("Completed", testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.AttachmentsProcessingState]); - Assert.AreEqual(2L, testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsSentForProcessing]); - Assert.AreEqual(1L, testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsAfterProcessing]); - Assert.IsTrue(testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForAttachmentsProcessing)); + Assert.AreEqual("Completed", _testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.AttachmentsProcessingState]); + Assert.AreEqual(2L, _testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsSentForProcessing]); + Assert.AreEqual(1L, _testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsAfterProcessing]); + Assert.IsTrue(_testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForAttachmentsProcessing)); - Assert.IsTrue(File.Exists(runEventHandler.Attachments.First().Attachments.First().Uri.LocalPath)); - Assert.IsFalse(File.Exists(runEventHandler.Attachments.Last().Attachments.First().Uri.LocalPath)); - } + Assert.IsTrue(File.Exists(_runEventHandler.Attachments.First().Attachments.First().Uri.LocalPath)); + Assert.IsFalse(File.Exists(_runEventHandler.Attachments.Last().Attachments.First().Uri.LocalPath)); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public async Task TestRunWithCodeCoverageAndAttachmentsProcessingNoMetrics(RunnerInfo runnerInfo) - { - // arrange - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public async Task TestRunWithCodeCoverageAndAttachmentsProcessingNoMetrics(RunnerInfo runnerInfo) + { + // arrange + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Take(1), this.GetCodeCoverageRunSettings(1), this.runEventHandler); - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Skip(1), this.GetCodeCoverageRunSettings(1), this.runEventHandler); + _vstestConsoleWrapper.RunTests(GetTestAssemblies().Take(1), GetCodeCoverageRunSettings(1), _runEventHandler); + _vstestConsoleWrapper.RunTests(GetTestAssemblies().Skip(1), GetCodeCoverageRunSettings(1), _runEventHandler); - Assert.AreEqual(6, this.runEventHandler.TestResults.Count); - Assert.AreEqual(2, this.runEventHandler.Attachments.Count); - Assert.AreEqual(2, this.runEventHandler.InvokedDataCollectors.Count); + Assert.AreEqual(6, _runEventHandler.TestResults.Count); + Assert.AreEqual(2, _runEventHandler.Attachments.Count); + Assert.AreEqual(2, _runEventHandler.InvokedDataCollectors.Count); - // act - await this.vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(runEventHandler.Attachments, runEventHandler.InvokedDataCollectors, this.GetCodeCoverageRunSettings(1), true, false, testRunAttachmentsProcessingEventHandler, CancellationToken.None); + // act + await _vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(_runEventHandler.Attachments, _runEventHandler.InvokedDataCollectors, GetCodeCoverageRunSettings(1), true, false, _testRunAttachmentsProcessingEventHandler, CancellationToken.None); - // Assert - Assert.AreEqual(1, runEventHandler.InvokedDataCollectors.Select(x => x.FilePath).Distinct().Count()); - Assert.AreEqual(1, runEventHandler.InvokedDataCollectors.Select(x => x.AssemblyQualifiedName).Distinct().Count()); - Assert.IsTrue(Regex.IsMatch(runEventHandler.InvokedDataCollectors.Select(x => x.AssemblyQualifiedName).Distinct().Single(), - @"Microsoft\.VisualStudio\.Coverage\.DynamicCoverageDataCollectorWithAttachmentProcessor, Microsoft\.VisualStudio\.TraceDataCollector, Version=.*, Culture=neutral, PublicKeyToken=.*")); + // Assert + Assert.AreEqual(1, _runEventHandler.InvokedDataCollectors.Select(x => x.FilePath).Distinct().Count()); + Assert.AreEqual(1, _runEventHandler.InvokedDataCollectors.Select(x => x.AssemblyQualifiedName).Distinct().Count()); + Assert.IsTrue(Regex.IsMatch(_runEventHandler.InvokedDataCollectors.Select(x => x.AssemblyQualifiedName).Distinct().Single(), + @"Microsoft\.VisualStudio\.Coverage\.DynamicCoverageDataCollectorWithAttachmentProcessor, Microsoft\.VisualStudio\.TraceDataCollector, Version=.*, Culture=neutral, PublicKeyToken=.*")); - testRunAttachmentsProcessingEventHandler.EnsureSuccess(); - Assert.AreEqual(1, this.testRunAttachmentsProcessingEventHandler.Attachments.Count); + _testRunAttachmentsProcessingEventHandler.EnsureSuccess(); + Assert.AreEqual(1, _testRunAttachmentsProcessingEventHandler.Attachments.Count); - AssertCoverageResults(this.testRunAttachmentsProcessingEventHandler.Attachments); + AssertCoverageResults(_testRunAttachmentsProcessingEventHandler.Attachments); - Assert.IsFalse(testRunAttachmentsProcessingEventHandler.CompleteArgs.IsCanceled); - Assert.IsNull(testRunAttachmentsProcessingEventHandler.CompleteArgs.Error); + Assert.IsFalse(_testRunAttachmentsProcessingEventHandler.CompleteArgs.IsCanceled); + Assert.IsNull(_testRunAttachmentsProcessingEventHandler.CompleteArgs.Error); - for (int i = 0; i < testRunAttachmentsProcessingEventHandler.ProgressArgs.Count; i++) + for (int i = 0; i < _testRunAttachmentsProcessingEventHandler.ProgressArgs.Count; i++) + { + VisualStudio.TestPlatform.ObjectModel.Client.TestRunAttachmentsProcessingProgressEventArgs progressArgs = _testRunAttachmentsProcessingEventHandler.ProgressArgs[i]; + Assert.AreEqual(i + 1, progressArgs.CurrentAttachmentProcessorIndex); + Assert.AreEqual(1, progressArgs.CurrentAttachmentProcessorUris.Count); + Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentAttachmentProcessorUris.First().AbsoluteUri); + Assert.AreEqual(2, progressArgs.AttachmentProcessorsCount); + if (_testRunAttachmentsProcessingEventHandler.ProgressArgs.Count == 2) { - VisualStudio.TestPlatform.ObjectModel.Client.TestRunAttachmentsProcessingProgressEventArgs progressArgs = testRunAttachmentsProcessingEventHandler.ProgressArgs[i]; - Assert.AreEqual(i + 1, progressArgs.CurrentAttachmentProcessorIndex); - Assert.AreEqual(1, progressArgs.CurrentAttachmentProcessorUris.Count); - Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentAttachmentProcessorUris.First().AbsoluteUri); - Assert.AreEqual(2, progressArgs.AttachmentProcessorsCount); - if (testRunAttachmentsProcessingEventHandler.ProgressArgs.Count == 2) - { - Assert.AreEqual(100, progressArgs.CurrentAttachmentProcessorProgress); - } + Assert.AreEqual(100, progressArgs.CurrentAttachmentProcessorProgress); } + } - Assert.IsTrue(testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics.IsNullOrEmpty()); + Assert.IsTrue(_testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics.IsNullOrEmpty()); - Assert.IsTrue(File.Exists(runEventHandler.Attachments.First().Attachments.First().Uri.LocalPath)); - Assert.IsFalse(File.Exists(runEventHandler.Attachments.Last().Attachments.First().Uri.LocalPath)); - } + Assert.IsTrue(File.Exists(_runEventHandler.Attachments.First().Attachments.First().Uri.LocalPath)); + Assert.IsFalse(File.Exists(_runEventHandler.Attachments.Last().Attachments.First().Uri.LocalPath)); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public async Task TestRunWithCodeCoverageAndAttachmentsProcessingModuleDuplicated(RunnerInfo runnerInfo) - { - // arrange - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public async Task TestRunWithCodeCoverageAndAttachmentsProcessingModuleDuplicated(RunnerInfo runnerInfo) + { + // arrange + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Take(1), this.GetCodeCoverageRunSettings(1), this.runEventHandler); - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Skip(1), this.GetCodeCoverageRunSettings(1), this.runEventHandler); - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Skip(1), this.GetCodeCoverageRunSettings(1), this.runEventHandler); + _vstestConsoleWrapper.RunTests(GetTestAssemblies().Take(1), GetCodeCoverageRunSettings(1), _runEventHandler); + _vstestConsoleWrapper.RunTests(GetTestAssemblies().Skip(1), GetCodeCoverageRunSettings(1), _runEventHandler); + _vstestConsoleWrapper.RunTests(GetTestAssemblies().Skip(1), GetCodeCoverageRunSettings(1), _runEventHandler); - Assert.AreEqual(9, this.runEventHandler.TestResults.Count); - Assert.AreEqual(3, this.runEventHandler.Attachments.Count); - Assert.AreEqual(3, this.runEventHandler.InvokedDataCollectors.Count); + Assert.AreEqual(9, _runEventHandler.TestResults.Count); + Assert.AreEqual(3, _runEventHandler.Attachments.Count); + Assert.AreEqual(3, _runEventHandler.InvokedDataCollectors.Count); - // act - await this.vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(runEventHandler.Attachments, runEventHandler.InvokedDataCollectors, this.GetCodeCoverageRunSettings(1), true, true, testRunAttachmentsProcessingEventHandler, CancellationToken.None); + // act + await _vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(_runEventHandler.Attachments, _runEventHandler.InvokedDataCollectors, GetCodeCoverageRunSettings(1), true, true, _testRunAttachmentsProcessingEventHandler, CancellationToken.None); - // Assert - Assert.AreEqual(1, runEventHandler.InvokedDataCollectors.Select(x => x.FilePath).Distinct().Count()); - Assert.AreEqual(1, runEventHandler.InvokedDataCollectors.Select(x => x.AssemblyQualifiedName).Distinct().Count()); - Assert.IsTrue(Regex.IsMatch(runEventHandler.InvokedDataCollectors.Select(x => x.AssemblyQualifiedName).Distinct().Single(), - @"Microsoft\.VisualStudio\.Coverage\.DynamicCoverageDataCollectorWithAttachmentProcessor, Microsoft\.VisualStudio\.TraceDataCollector, Version=.*, Culture=neutral, PublicKeyToken=.*")); + // Assert + Assert.AreEqual(1, _runEventHandler.InvokedDataCollectors.Select(x => x.FilePath).Distinct().Count()); + Assert.AreEqual(1, _runEventHandler.InvokedDataCollectors.Select(x => x.AssemblyQualifiedName).Distinct().Count()); + Assert.IsTrue(Regex.IsMatch(_runEventHandler.InvokedDataCollectors.Select(x => x.AssemblyQualifiedName).Distinct().Single(), + @"Microsoft\.VisualStudio\.Coverage\.DynamicCoverageDataCollectorWithAttachmentProcessor, Microsoft\.VisualStudio\.TraceDataCollector, Version=.*, Culture=neutral, PublicKeyToken=.*")); - testRunAttachmentsProcessingEventHandler.EnsureSuccess(); - Assert.AreEqual(1, this.testRunAttachmentsProcessingEventHandler.Attachments.Count); + _testRunAttachmentsProcessingEventHandler.EnsureSuccess(); + Assert.AreEqual(1, _testRunAttachmentsProcessingEventHandler.Attachments.Count); - AssertCoverageResults(this.testRunAttachmentsProcessingEventHandler.Attachments); + AssertCoverageResults(_testRunAttachmentsProcessingEventHandler.Attachments); - Assert.IsFalse(testRunAttachmentsProcessingEventHandler.CompleteArgs.IsCanceled); - Assert.IsNull(testRunAttachmentsProcessingEventHandler.CompleteArgs.Error); + Assert.IsFalse(_testRunAttachmentsProcessingEventHandler.CompleteArgs.IsCanceled); + Assert.IsNull(_testRunAttachmentsProcessingEventHandler.CompleteArgs.Error); + + for (int i = 0; i < _testRunAttachmentsProcessingEventHandler.ProgressArgs.Count; i++) + { + VisualStudio.TestPlatform.ObjectModel.Client.TestRunAttachmentsProcessingProgressEventArgs progressArgs = _testRunAttachmentsProcessingEventHandler.ProgressArgs[i]; + Assert.AreEqual(i + 1, progressArgs.CurrentAttachmentProcessorIndex); + Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentAttachmentProcessorUris.First().AbsoluteUri); + Assert.AreEqual(2, progressArgs.AttachmentProcessorsCount); - for (int i = 0; i < testRunAttachmentsProcessingEventHandler.ProgressArgs.Count; i++) + if (_testRunAttachmentsProcessingEventHandler.ProgressArgs.Count == 2) { - VisualStudio.TestPlatform.ObjectModel.Client.TestRunAttachmentsProcessingProgressEventArgs progressArgs = testRunAttachmentsProcessingEventHandler.ProgressArgs[i]; - Assert.AreEqual(i + 1, progressArgs.CurrentAttachmentProcessorIndex); - Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentAttachmentProcessorUris.First().AbsoluteUri); - Assert.AreEqual(2, progressArgs.AttachmentProcessorsCount); - - if (testRunAttachmentsProcessingEventHandler.ProgressArgs.Count == 2) - { - Assert.AreEqual(100, progressArgs.CurrentAttachmentProcessorProgress); - } + Assert.AreEqual(100, progressArgs.CurrentAttachmentProcessorProgress); } + } - Assert.AreEqual("Completed", testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.AttachmentsProcessingState]); - Assert.AreEqual(3L, testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsSentForProcessing]); - Assert.AreEqual(1L, testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsAfterProcessing]); - Assert.IsTrue(testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForAttachmentsProcessing)); + Assert.AreEqual("Completed", _testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.AttachmentsProcessingState]); + Assert.AreEqual(3L, _testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsSentForProcessing]); + Assert.AreEqual(1L, _testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsAfterProcessing]); + Assert.IsTrue(_testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForAttachmentsProcessing)); - Assert.IsTrue(File.Exists(runEventHandler.Attachments.First().Attachments.First().Uri.LocalPath)); - Assert.IsFalse(File.Exists(runEventHandler.Attachments.Last().Attachments.First().Uri.LocalPath)); - } + Assert.IsTrue(File.Exists(_runEventHandler.Attachments.First().Attachments.First().Uri.LocalPath)); + Assert.IsFalse(File.Exists(_runEventHandler.Attachments.Last().Attachments.First().Uri.LocalPath)); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public async Task TestRunWithCodeCoverageAndAttachmentsProcessingSameReportFormat(RunnerInfo runnerInfo) - { - // arrange - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public async Task TestRunWithCodeCoverageAndAttachmentsProcessingSameReportFormat(RunnerInfo runnerInfo) + { + // arrange + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Take(1), this.GetCodeCoverageRunSettings(1, outputFormat: "Coverage"), this.runEventHandler); - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Skip(1), this.GetCodeCoverageRunSettings(1, outputFormat: "Coverage"), this.runEventHandler); + _vstestConsoleWrapper.RunTests(GetTestAssemblies().Take(1), GetCodeCoverageRunSettings(1, outputFormat: "Coverage"), _runEventHandler); + _vstestConsoleWrapper.RunTests(GetTestAssemblies().Skip(1), GetCodeCoverageRunSettings(1, outputFormat: "Coverage"), _runEventHandler); - Assert.AreEqual(6, this.runEventHandler.TestResults.Count); - Assert.AreEqual(2, this.runEventHandler.Attachments.Count); - Assert.AreEqual(2, this.runEventHandler.InvokedDataCollectors.Count); + Assert.AreEqual(6, _runEventHandler.TestResults.Count); + Assert.AreEqual(2, _runEventHandler.Attachments.Count); + Assert.AreEqual(2, _runEventHandler.InvokedDataCollectors.Count); - // act - await this.vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(runEventHandler.Attachments, runEventHandler.InvokedDataCollectors, this.GetCodeCoverageRunSettings(1), true, true, testRunAttachmentsProcessingEventHandler, CancellationToken.None); + // act + await _vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(_runEventHandler.Attachments, _runEventHandler.InvokedDataCollectors, GetCodeCoverageRunSettings(1), true, true, _testRunAttachmentsProcessingEventHandler, CancellationToken.None); - // Assert - Assert.AreEqual(1, runEventHandler.InvokedDataCollectors.Select(x => x.FilePath).Distinct().Count()); - Assert.AreEqual(1, runEventHandler.InvokedDataCollectors.Select(x => x.AssemblyQualifiedName).Distinct().Count()); - Assert.IsTrue(Regex.IsMatch(runEventHandler.InvokedDataCollectors.Select(x => x.AssemblyQualifiedName).Distinct().Single(), - @"Microsoft\.VisualStudio\.Coverage\.DynamicCoverageDataCollectorWithAttachmentProcessor, Microsoft\.VisualStudio\.TraceDataCollector, Version=.*, Culture=neutral, PublicKeyToken=.*")); + // Assert + Assert.AreEqual(1, _runEventHandler.InvokedDataCollectors.Select(x => x.FilePath).Distinct().Count()); + Assert.AreEqual(1, _runEventHandler.InvokedDataCollectors.Select(x => x.AssemblyQualifiedName).Distinct().Count()); + Assert.IsTrue(Regex.IsMatch(_runEventHandler.InvokedDataCollectors.Select(x => x.AssemblyQualifiedName).Distinct().Single(), + @"Microsoft\.VisualStudio\.Coverage\.DynamicCoverageDataCollectorWithAttachmentProcessor, Microsoft\.VisualStudio\.TraceDataCollector, Version=.*, Culture=neutral, PublicKeyToken=.*")); - testRunAttachmentsProcessingEventHandler.EnsureSuccess(); - Assert.AreEqual(1, this.testRunAttachmentsProcessingEventHandler.Attachments.Count); - Assert.AreEqual(1, this.testRunAttachmentsProcessingEventHandler.Attachments[0].Attachments.Count); - Assert.IsTrue(this.testRunAttachmentsProcessingEventHandler.Attachments[0].Attachments[0].Uri.LocalPath.Contains(".coverage")); + _testRunAttachmentsProcessingEventHandler.EnsureSuccess(); + Assert.AreEqual(1, _testRunAttachmentsProcessingEventHandler.Attachments.Count); + Assert.AreEqual(1, _testRunAttachmentsProcessingEventHandler.Attachments[0].Attachments.Count); + Assert.IsTrue(_testRunAttachmentsProcessingEventHandler.Attachments[0].Attachments[0].Uri.LocalPath.Contains(".coverage")); - AssertCoverageResults(this.testRunAttachmentsProcessingEventHandler.Attachments); + AssertCoverageResults(_testRunAttachmentsProcessingEventHandler.Attachments); - Assert.IsFalse(testRunAttachmentsProcessingEventHandler.CompleteArgs.IsCanceled); - Assert.IsNull(testRunAttachmentsProcessingEventHandler.CompleteArgs.Error); + Assert.IsFalse(_testRunAttachmentsProcessingEventHandler.CompleteArgs.IsCanceled); + Assert.IsNull(_testRunAttachmentsProcessingEventHandler.CompleteArgs.Error); - for (int i = 0; i < testRunAttachmentsProcessingEventHandler.ProgressArgs.Count; i++) + for (int i = 0; i < _testRunAttachmentsProcessingEventHandler.ProgressArgs.Count; i++) + { + VisualStudio.TestPlatform.ObjectModel.Client.TestRunAttachmentsProcessingProgressEventArgs progressArgs = _testRunAttachmentsProcessingEventHandler.ProgressArgs[i]; + Assert.AreEqual(i + 1, progressArgs.CurrentAttachmentProcessorIndex); + Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentAttachmentProcessorUris.First().AbsoluteUri); + Assert.AreEqual(2, progressArgs.AttachmentProcessorsCount); + + if (_testRunAttachmentsProcessingEventHandler.ProgressArgs.Count == 2) { - VisualStudio.TestPlatform.ObjectModel.Client.TestRunAttachmentsProcessingProgressEventArgs progressArgs = testRunAttachmentsProcessingEventHandler.ProgressArgs[i]; - Assert.AreEqual(i + 1, progressArgs.CurrentAttachmentProcessorIndex); - Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentAttachmentProcessorUris.First().AbsoluteUri); - Assert.AreEqual(2, progressArgs.AttachmentProcessorsCount); - - if (testRunAttachmentsProcessingEventHandler.ProgressArgs.Count == 2) - { - Assert.AreEqual(100, progressArgs.CurrentAttachmentProcessorProgress); - } + Assert.AreEqual(100, progressArgs.CurrentAttachmentProcessorProgress); } + } - Assert.AreEqual("Completed", testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.AttachmentsProcessingState]); - Assert.AreEqual(2L, testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsSentForProcessing]); - Assert.AreEqual(1L, testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsAfterProcessing]); - Assert.IsTrue(testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForAttachmentsProcessing)); + Assert.AreEqual("Completed", _testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.AttachmentsProcessingState]); + Assert.AreEqual(2L, _testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsSentForProcessing]); + Assert.AreEqual(1L, _testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsAfterProcessing]); + Assert.IsTrue(_testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForAttachmentsProcessing)); - Assert.IsTrue(File.Exists(runEventHandler.Attachments.First().Attachments.First().Uri.LocalPath)); - Assert.IsFalse(File.Exists(runEventHandler.Attachments.Last().Attachments.First().Uri.LocalPath)); - } + Assert.IsTrue(File.Exists(_runEventHandler.Attachments.First().Attachments.First().Uri.LocalPath)); + Assert.IsFalse(File.Exists(_runEventHandler.Attachments.Last().Attachments.First().Uri.LocalPath)); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public async Task TestRunWithCodeCoverageAndAttachmentsProcessingDifferentReportFormats(RunnerInfo runnerInfo) - { - // arrange - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public async Task TestRunWithCodeCoverageAndAttachmentsProcessingDifferentReportFormats(RunnerInfo runnerInfo) + { + // arrange + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Take(1), this.GetCodeCoverageRunSettings(1, outputFormat: "Coverage"), this.runEventHandler); - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Skip(1), this.GetCodeCoverageRunSettings(1, outputFormat: "Coverage"), this.runEventHandler); - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Take(1), this.GetCodeCoverageRunSettings(1, outputFormat: "Cobertura"), this.runEventHandler); - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Skip(1), this.GetCodeCoverageRunSettings(1, outputFormat: "Cobertura"), this.runEventHandler); + _vstestConsoleWrapper.RunTests(GetTestAssemblies().Take(1), GetCodeCoverageRunSettings(1, outputFormat: "Coverage"), _runEventHandler); + _vstestConsoleWrapper.RunTests(GetTestAssemblies().Skip(1), GetCodeCoverageRunSettings(1, outputFormat: "Coverage"), _runEventHandler); + _vstestConsoleWrapper.RunTests(GetTestAssemblies().Take(1), GetCodeCoverageRunSettings(1, outputFormat: "Cobertura"), _runEventHandler); + _vstestConsoleWrapper.RunTests(GetTestAssemblies().Skip(1), GetCodeCoverageRunSettings(1, outputFormat: "Cobertura"), _runEventHandler); - Assert.AreEqual(12, this.runEventHandler.TestResults.Count); - Assert.AreEqual(4, this.runEventHandler.Attachments.Count); - Assert.AreEqual(4, this.runEventHandler.InvokedDataCollectors.Count); + Assert.AreEqual(12, _runEventHandler.TestResults.Count); + Assert.AreEqual(4, _runEventHandler.Attachments.Count); + Assert.AreEqual(4, _runEventHandler.InvokedDataCollectors.Count); - // act - await this.vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(runEventHandler.Attachments, runEventHandler.InvokedDataCollectors, this.GetCodeCoverageRunSettings(1, outputFormat: "Coverage"), true, true, testRunAttachmentsProcessingEventHandler, CancellationToken.None); + // act + await _vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(_runEventHandler.Attachments, _runEventHandler.InvokedDataCollectors, GetCodeCoverageRunSettings(1, outputFormat: "Coverage"), true, true, _testRunAttachmentsProcessingEventHandler, CancellationToken.None); - // Assert - Assert.AreEqual(1, runEventHandler.InvokedDataCollectors.Select(x => x.FilePath).Distinct().Count()); - Assert.AreEqual(1, runEventHandler.InvokedDataCollectors.Select(x => x.AssemblyQualifiedName).Distinct().Count()); - Assert.IsTrue(Regex.IsMatch(runEventHandler.InvokedDataCollectors.Select(x => x.AssemblyQualifiedName).Distinct().Single(), - @"Microsoft\.VisualStudio\.Coverage\.DynamicCoverageDataCollectorWithAttachmentProcessor, Microsoft\.VisualStudio\.TraceDataCollector, Version=.*, Culture=neutral, PublicKeyToken=.*")); + // Assert + Assert.AreEqual(1, _runEventHandler.InvokedDataCollectors.Select(x => x.FilePath).Distinct().Count()); + Assert.AreEqual(1, _runEventHandler.InvokedDataCollectors.Select(x => x.AssemblyQualifiedName).Distinct().Count()); + Assert.IsTrue(Regex.IsMatch(_runEventHandler.InvokedDataCollectors.Select(x => x.AssemblyQualifiedName).Distinct().Single(), + @"Microsoft\.VisualStudio\.Coverage\.DynamicCoverageDataCollectorWithAttachmentProcessor, Microsoft\.VisualStudio\.TraceDataCollector, Version=.*, Culture=neutral, PublicKeyToken=.*")); - testRunAttachmentsProcessingEventHandler.EnsureSuccess(); - Assert.AreEqual(1, this.testRunAttachmentsProcessingEventHandler.Attachments.Count); - Assert.AreEqual(2, this.testRunAttachmentsProcessingEventHandler.Attachments[0].Attachments.Count); - Assert.IsTrue(this.testRunAttachmentsProcessingEventHandler.Attachments[0].Attachments[0].Uri.LocalPath.Contains(".cobertura.xml")); - Assert.IsTrue(this.testRunAttachmentsProcessingEventHandler.Attachments[0].Attachments[1].Uri.LocalPath.Contains(".coverage")); + _testRunAttachmentsProcessingEventHandler.EnsureSuccess(); + Assert.AreEqual(1, _testRunAttachmentsProcessingEventHandler.Attachments.Count); + Assert.AreEqual(2, _testRunAttachmentsProcessingEventHandler.Attachments[0].Attachments.Count); + Assert.IsTrue(_testRunAttachmentsProcessingEventHandler.Attachments[0].Attachments[0].Uri.LocalPath.Contains(".cobertura.xml")); + Assert.IsTrue(_testRunAttachmentsProcessingEventHandler.Attachments[0].Attachments[1].Uri.LocalPath.Contains(".coverage")); - AssertCoverageResults(this.testRunAttachmentsProcessingEventHandler.Attachments); + AssertCoverageResults(_testRunAttachmentsProcessingEventHandler.Attachments); - Assert.IsFalse(testRunAttachmentsProcessingEventHandler.CompleteArgs.IsCanceled); - Assert.IsNull(testRunAttachmentsProcessingEventHandler.CompleteArgs.Error); + Assert.IsFalse(_testRunAttachmentsProcessingEventHandler.CompleteArgs.IsCanceled); + Assert.IsNull(_testRunAttachmentsProcessingEventHandler.CompleteArgs.Error); - for (int i = 0; i < testRunAttachmentsProcessingEventHandler.ProgressArgs.Count; i++) - { - VisualStudio.TestPlatform.ObjectModel.Client.TestRunAttachmentsProcessingProgressEventArgs progressArgs = testRunAttachmentsProcessingEventHandler.ProgressArgs[i]; - Assert.AreEqual(i + 1, progressArgs.CurrentAttachmentProcessorIndex); - Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentAttachmentProcessorUris.First().AbsoluteUri); + for (int i = 0; i < _testRunAttachmentsProcessingEventHandler.ProgressArgs.Count; i++) + { + VisualStudio.TestPlatform.ObjectModel.Client.TestRunAttachmentsProcessingProgressEventArgs progressArgs = _testRunAttachmentsProcessingEventHandler.ProgressArgs[i]; + Assert.AreEqual(i + 1, progressArgs.CurrentAttachmentProcessorIndex); + Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentAttachmentProcessorUris.First().AbsoluteUri); - // We have two processor because we append always CodeCoverage attachment processor shipped with VSTest+Attachment processor shipped from code coverage repo. - Assert.AreEqual(2, progressArgs.AttachmentProcessorsCount); + // We have two processor because we append always CodeCoverage attachment processor shipped with VSTest+Attachment processor shipped from code coverage repo. + Assert.AreEqual(2, progressArgs.AttachmentProcessorsCount); - if (testRunAttachmentsProcessingEventHandler.ProgressArgs.Count == 2) - { - Assert.AreEqual(100, progressArgs.CurrentAttachmentProcessorProgress); - } + if (_testRunAttachmentsProcessingEventHandler.ProgressArgs.Count == 2) + { + Assert.AreEqual(100, progressArgs.CurrentAttachmentProcessorProgress); } + } - Assert.AreEqual("Completed", testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.AttachmentsProcessingState]); - Assert.AreEqual(4L, testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsSentForProcessing]); - Assert.AreEqual(1L, testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsAfterProcessing]); - Assert.IsTrue(testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForAttachmentsProcessing)); + Assert.AreEqual("Completed", _testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.AttachmentsProcessingState]); + Assert.AreEqual(4L, _testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsSentForProcessing]); + Assert.AreEqual(1L, _testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsAfterProcessing]); + Assert.IsTrue(_testRunAttachmentsProcessingEventHandler.CompleteArgs.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForAttachmentsProcessing)); - Assert.IsTrue(File.Exists(runEventHandler.Attachments.First().Attachments.First().Uri.LocalPath)); - Assert.IsFalse(File.Exists(runEventHandler.Attachments.Last().Attachments.First().Uri.LocalPath)); - } + Assert.IsTrue(File.Exists(_runEventHandler.Attachments.First().Attachments.First().Uri.LocalPath)); + Assert.IsFalse(File.Exists(_runEventHandler.Attachments.Last().Attachments.First().Uri.LocalPath)); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - [DoNotParallelize] - public async Task EndSessionShouldEnsureVstestConsoleProcessDies(RunnerInfo runnerInfo) - { - var numOfProcesses = Process.GetProcessesByName("vstest.console").Length; + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + [DoNotParallelize] + public async Task EndSessionShouldEnsureVstestConsoleProcessDies(RunnerInfo runnerInfo) + { + var numOfProcesses = Process.GetProcessesByName("vstest.console").Length; - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Take(1), this.GetCodeCoverageRunSettings(1), this.runEventHandler); - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Skip(1), this.GetCodeCoverageRunSettings(1), this.runEventHandler); + _vstestConsoleWrapper.RunTests(GetTestAssemblies().Take(1), GetCodeCoverageRunSettings(1), _runEventHandler); + _vstestConsoleWrapper.RunTests(GetTestAssemblies().Skip(1), GetCodeCoverageRunSettings(1), _runEventHandler); - Assert.AreEqual(6, this.runEventHandler.TestResults.Count); - Assert.AreEqual(2, this.runEventHandler.Attachments.Count); - Assert.AreEqual(2, this.runEventHandler.InvokedDataCollectors.Count); + Assert.AreEqual(6, _runEventHandler.TestResults.Count); + Assert.AreEqual(2, _runEventHandler.Attachments.Count); + Assert.AreEqual(2, _runEventHandler.InvokedDataCollectors.Count); - await this.vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(runEventHandler.Attachments, runEventHandler.InvokedDataCollectors, this.GetCodeCoverageRunSettings(1), true, true, testRunAttachmentsProcessingEventHandler, CancellationToken.None); + await _vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(_runEventHandler.Attachments, _runEventHandler.InvokedDataCollectors, GetCodeCoverageRunSettings(1), true, true, _testRunAttachmentsProcessingEventHandler, CancellationToken.None); - // act - this.vstestConsoleWrapper?.EndSession(); + // act + _vstestConsoleWrapper?.EndSession(); - // Assert - Assert.AreEqual(numOfProcesses, Process.GetProcessesByName("vstest.console").Length); + // Assert + Assert.AreEqual(numOfProcesses, Process.GetProcessesByName("vstest.console").Length); - this.vstestConsoleWrapper = null; - } + _vstestConsoleWrapper = null; + } - private IList GetTestAssemblies() - { - return GetProjects().Select(p => this.GetAssetFullPath(p)).ToList(); - } + private IList GetTestAssemblies() + { + return GetProjects().Select(p => GetAssetFullPath(p)).ToList(); + } - private IList GetProjects() - { - return new List { "SimpleTestProject.dll", "SimpleTestProject2.dll" }; - } + private IList GetProjects() + { + return new List { "SimpleTestProject.dll", "SimpleTestProject2.dll" }; + } - /// - /// Default RunSettings - /// - /// - private string GetCodeCoverageRunSettings(int cpuCount, bool useClrIeInstrumentationEngine = false, string outputFormat = "Coverage") - { - string runSettingsXml = $@" + /// + /// Default RunSettings + /// + /// + private string GetCodeCoverageRunSettings(int cpuCount, bool useClrIeInstrumentationEngine = false, string outputFormat = "Coverage") + { + string runSettingsXml = $@" {FrameworkArgValue} - {this.GetNetStandardAdapterPath()} + {GetNetStandardAdapterPath()} {cpuCount} @@ -481,21 +483,20 @@ private string GetCodeCoverageRunSettings(int cpuCount, bool useClrIeInstrumenta "; - return runSettingsXml; - } + return runSettingsXml; + } - private void AssertCoverageResults(IList attachments) + private void AssertCoverageResults(IList attachments) + { + if (attachments.Count == 1) { - if (attachments.Count == 1) - { - var xmlCoverage = this.GetXmlCoverage(attachments.First().Attachments.First().Uri.LocalPath, this.tempDirectory); + var xmlCoverage = GetXmlCoverage(attachments.First().Attachments.First().Uri.LocalPath, _tempDirectory); - foreach (var project in this.GetProjects()) - { - var moduleNode = this.GetModuleNode(xmlCoverage.DocumentElement, project.ToLower()); - this.AssertCoverage(moduleNode, CodeCoverageAcceptanceTestBase.ExpectedMinimalModuleCoverage); - } + foreach (var project in GetProjects()) + { + var moduleNode = GetModuleNode(xmlCoverage.DocumentElement, project.ToLower()); + AssertCoverage(moduleNode, ExpectedMinimalModuleCoverage); } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CustomTestHostLauncher.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CustomTestHostLauncher.cs index 7712b11c7c..db3f81848a 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CustomTestHostLauncher.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CustomTestHostLauncher.cs @@ -1,57 +1,52 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests +namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests; + +using System.Diagnostics; +using System.Threading; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; + +/// +/// The custom test host launcher. +/// +public class CustomTestHostLauncher : ITestHostLauncher2 { - using System.Diagnostics; - using System.Threading; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - - /// - /// The custom test host launcher. - /// - public class CustomTestHostLauncher : ITestHostLauncher2 + public int ProcessId { - public int ProcessId - { - get; - private set; - } + get; + private set; + } - /// - public bool IsDebug => true; + /// + public bool IsDebug => true; - public bool AttachDebuggerToProcess(int pid) => this.AttachDebuggerToProcess(pid, CancellationToken.None); + public bool AttachDebuggerToProcess(int pid) => AttachDebuggerToProcess(pid, CancellationToken.None); - public bool AttachDebuggerToProcess(int pid, CancellationToken cancellationToken) => true; + public bool AttachDebuggerToProcess(int pid, CancellationToken cancellationToken) => true; - /// - public int LaunchTestHost(TestProcessStartInfo defaultTestHostStartInfo) - { - return this.LaunchTestHost(defaultTestHostStartInfo, CancellationToken.None); - } + /// + public int LaunchTestHost(TestProcessStartInfo defaultTestHostStartInfo) + { + return LaunchTestHost(defaultTestHostStartInfo, CancellationToken.None); + } - /// - public int LaunchTestHost(TestProcessStartInfo defaultTestHostStartInfo, CancellationToken cancellationToken) + /// + public int LaunchTestHost(TestProcessStartInfo defaultTestHostStartInfo, CancellationToken cancellationToken) + { + var processInfo = new ProcessStartInfo( + defaultTestHostStartInfo.FileName, + defaultTestHostStartInfo.Arguments) { - var processInfo = new ProcessStartInfo( - defaultTestHostStartInfo.FileName, - defaultTestHostStartInfo.Arguments) - { - WorkingDirectory = defaultTestHostStartInfo.WorkingDirectory - }; - processInfo.UseShellExecute = false; - - var process = new Process { StartInfo = processInfo }; - process.Start(); - - if (process != null) - { - return process.Id; - } - - return -1; - } + WorkingDirectory = defaultTestHostStartInfo.WorkingDirectory + }; + processInfo.UseShellExecute = false; + + var process = new Process { StartInfo = processInfo }; + process.Start(); + + return process != null ? process.Id : -1; } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CustomTestHostTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CustomTestHostTests.cs index c0e0e6ff96..bc4c9ff91a 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CustomTestHostTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CustomTestHostTests.cs @@ -1,64 +1,64 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests +namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests; + +using VsTestConsole.TranslationLayer.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using VisualStudio.TestTools.UnitTesting; + +using System.Collections.Generic; +using System.Linq; + +/// +/// The Run Tests using VsTestConsoleWrapper API's +/// +[TestClass] +public class CustomTestHostTests : AcceptanceTestBase { - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System.Collections.Generic; - using System.Linq; + private IVsTestConsoleWrapper _vstestConsoleWrapper; + private RunEventHandler _runEventHandler; - /// - /// The Run Tests using VsTestConsoleWrapper API's - /// - [TestClass] - public class CustomTestHostTests : AcceptanceTestBase + private void Setup() { - private IVsTestConsoleWrapper vstestConsoleWrapper; - private RunEventHandler runEventHandler; - - private void Setup() - { - this.vstestConsoleWrapper = this.GetVsTestConsoleWrapper(out _); - this.runEventHandler = new RunEventHandler(); - } + _vstestConsoleWrapper = GetVsTestConsoleWrapper(out _); + _runEventHandler = new RunEventHandler(); + } - [TestCleanup] - public void Cleanup() - { - this.vstestConsoleWrapper?.EndSession(); - } + [TestCleanup] + public void Cleanup() + { + _vstestConsoleWrapper?.EndSession(); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunTestsWithCustomTestHostLaunch(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunTestsWithCustomTestHostLaunch(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - var customTestHostLauncher = new CustomTestHostLauncher(); - this.vstestConsoleWrapper.RunTestsWithCustomTestHost(this.GetTestAssemblies(), this.GetDefaultRunSettings(), this.runEventHandler, customTestHostLauncher); + var customTestHostLauncher = new CustomTestHostLauncher(); + _vstestConsoleWrapper.RunTestsWithCustomTestHost(GetTestAssemblies(), GetDefaultRunSettings(), _runEventHandler, customTestHostLauncher); - // Assert - Assert.AreEqual(6, this.runEventHandler.TestResults.Count); - Assert.IsTrue(customTestHostLauncher.ProcessId != -1); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Skipped)); - } + // Assert + Assert.AreEqual(6, _runEventHandler.TestResults.Count); + Assert.IsTrue(customTestHostLauncher.ProcessId != -1); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Skipped)); + } - private IList GetTestAssemblies() + private IList GetTestAssemblies() + { + var testAssemblies = new List { - var testAssemblies = new List - { - this.GetAssetFullPath("SimpleTestProject.dll"), - this.GetAssetFullPath("SimpleTestProject2.dll") - }; + GetAssetFullPath("SimpleTestProject.dll"), + GetAssetFullPath("SimpleTestProject2.dll") + }; - return testAssemblies; - } + return testAssemblies; } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/DifferentTestFrameworkSimpleTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/DifferentTestFrameworkSimpleTests.cs index d48e14b8fe..bde08290ed 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/DifferentTestFrameworkSimpleTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/DifferentTestFrameworkSimpleTests.cs @@ -1,154 +1,147 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests +namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests; + +using TestUtilities; +using VsTestConsole.TranslationLayer.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using VisualStudio.TestTools.UnitTesting; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +/// +/// The Run Tests using VsTestConsoleWrapper API's +/// +[TestClass] +public class DifferentTestFrameworkSimpleTests : AcceptanceTestBase { - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - - /// - /// The Run Tests using VsTestConsoleWrapper API's - /// - [TestClass] - public class DifferentTestFrameworkSimpleTests : AcceptanceTestBase + private IVsTestConsoleWrapper _vstestConsoleWrapper; + private RunEventHandler _runEventHandler; + + private void Setup() { - private IVsTestConsoleWrapper vstestConsoleWrapper; - private RunEventHandler runEventHandler; + _vstestConsoleWrapper = GetVsTestConsoleWrapper(out _); + _runEventHandler = new RunEventHandler(); + } + + [TestCleanup] + public void Cleanup() + { + _vstestConsoleWrapper?.EndSession(); + } - private void Setup() - { - this.vstestConsoleWrapper = this.GetVsTestConsoleWrapper(out _); - this.runEventHandler = new RunEventHandler(); - } - [TestCleanup] - public void Cleanup() + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunTestsWithNunitAdapter(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); + + var sources = new List { - this.vstestConsoleWrapper?.EndSession(); - } + GetAssetFullPath("NUTestProject.dll") + }; + _vstestConsoleWrapper.RunTests( + sources, + GetDefaultRunSettings(), + _runEventHandler); - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunTestsWithNunitAdapter(RunnerInfo runnerInfo) + var testCase = + _runEventHandler.TestResults.Where(tr => tr.TestCase.DisplayName.Equals("PassTestMethod1")); + + // Assert + Assert.AreEqual(2, _runEventHandler.TestResults.Count); + Assert.AreEqual(1, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); + Assert.AreEqual(1, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); + + // Release builds optimize code, hence line numbers are different. + if (IntegrationTestEnvironment.BuildConfiguration.StartsWith("release", StringComparison.OrdinalIgnoreCase)) { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); - - var sources = new List - { - this.GetAssetFullPath("NUTestProject.dll") - }; - - this.vstestConsoleWrapper.RunTests( - sources, - this.GetDefaultRunSettings(), - this.runEventHandler); - - var testCase = - this.runEventHandler.TestResults.Where(tr => tr.TestCase.DisplayName.Equals("PassTestMethod1")); - - // Assert - Assert.AreEqual(2, this.runEventHandler.TestResults.Count); - Assert.AreEqual(1, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); - Assert.AreEqual(1, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); - - // Release builds optimize code, hence line numbers are different. - if (IntegrationTestEnvironment.BuildConfiguration.StartsWith("release", StringComparison.OrdinalIgnoreCase)) - { - Assert.AreEqual(11, testCase.FirstOrDefault().TestCase.LineNumber); - } - else - { - Assert.AreEqual(10, testCase.FirstOrDefault().TestCase.LineNumber); - } + Assert.AreEqual(14, testCase.FirstOrDefault().TestCase.LineNumber); } - - [TestMethod] - // there are logs in the diagnostic log, it is failing with NullReferenceException because path is null - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunTestsWithXunitAdapter(RunnerInfo runnerInfo) + else { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); - - // Xunit >= 2.2 won't support net451, Minimum target framework it supports is net452. - string testAssemblyPath = null; - if (this.testEnvironment.TargetFramework.Equals("net451")) - { - testAssemblyPath = testEnvironment.GetTestAsset("XUTestProject.dll", "net46"); - } - else - { - testAssemblyPath = testEnvironment.GetTestAsset("XUTestProject.dll"); - } - - var sources = new List { testAssemblyPath }; - var testAdapterPath = Directory.EnumerateFiles(this.GetTestAdapterPath(UnitTestFramework.XUnit), "*.TestAdapter.dll").ToList(); - this.vstestConsoleWrapper.InitializeExtensions(new List() { testAdapterPath.FirstOrDefault() }); - - this.vstestConsoleWrapper.RunTests( - sources, - this.GetDefaultRunSettings(), - this.runEventHandler); - - var testCase = - this.runEventHandler.TestResults.Where(tr => tr.TestCase.DisplayName.Equals("xUnitTestProject.Class1.PassTestMethod1")); - - // Assert - Assert.AreEqual(2, this.runEventHandler.TestResults.Count); - Assert.AreEqual(1, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); - Assert.AreEqual(1, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); - - // Release builds optimize code, hence line numbers are different. - if (IntegrationTestEnvironment.BuildConfiguration.StartsWith("release", StringComparison.OrdinalIgnoreCase)) - { - Assert.AreEqual(16, testCase.FirstOrDefault().TestCase.LineNumber); - } - else - { - Assert.AreEqual(15, testCase.FirstOrDefault().TestCase.LineNumber); - } + Assert.AreEqual(13, testCase.FirstOrDefault().TestCase.LineNumber); } + } - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - public void RunTestsWithChutzpahAdapter(RunnerInfo runnerInfo) + [TestMethod] + // there are logs in the diagnostic log, it is failing with NullReferenceException because path is null + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunTestsWithXunitAdapter(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); + + // Xunit >= 2.2 won't support net451, Minimum target framework it supports is net452. + string testAssemblyPath = _testEnvironment.TargetFramework.Equals("net451") + ? _testEnvironment.GetTestAsset("XUTestProject.dll", "net46") + : _testEnvironment.GetTestAsset("XUTestProject.dll"); + var sources = new List { testAssemblyPath }; + var testAdapterPath = Directory.EnumerateFiles(GetTestAdapterPath(UnitTestFramework.XUnit), "*.TestAdapter.dll").ToList(); + _vstestConsoleWrapper.InitializeExtensions(new List() { testAdapterPath.FirstOrDefault() }); + + _vstestConsoleWrapper.RunTests( + sources, + GetDefaultRunSettings(), + _runEventHandler); + + var testCase = + _runEventHandler.TestResults.Where(tr => tr.TestCase.DisplayName.Equals("xUnitTestProject.Class1.PassTestMethod1")); + + // Assert + Assert.AreEqual(2, _runEventHandler.TestResults.Count); + Assert.AreEqual(1, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); + Assert.AreEqual(1, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); + + // Release builds optimize code, hence line numbers are different. + if (IntegrationTestEnvironment.BuildConfiguration.StartsWith("release", StringComparison.OrdinalIgnoreCase)) + { + Assert.AreEqual(15, testCase.FirstOrDefault().TestCase.LineNumber); + } + else { - SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); - - var sources = new List - { - Path.Combine(this.testEnvironment.TestAssetsPath, "test.js") - }; - - var testAdapterPath = Directory.EnumerateFiles(this.GetTestAdapterPath(UnitTestFramework.Chutzpah), "*.TestAdapter.dll").ToList(); - this.vstestConsoleWrapper.InitializeExtensions(new List() { testAdapterPath.FirstOrDefault() }); - - this.vstestConsoleWrapper.RunTests( - sources, - this.GetDefaultRunSettings(), - this.runEventHandler); - - var testCase = - this.runEventHandler.TestResults.Where(tr => tr.TestCase.DisplayName.Equals("TestMethod1")); - - // Assert - Assert.AreEqual(2, this.runEventHandler.TestResults.Count); - Assert.AreEqual(1, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); - Assert.AreEqual(1, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); - Assert.AreEqual(1, testCase.FirstOrDefault().TestCase.LineNumber); + Assert.AreEqual(14, testCase.FirstOrDefault().TestCase.LineNumber); } } + + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + public void RunTestsWithChutzpahAdapter(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); + + var sources = new List + { + Path.Combine(_testEnvironment.TestAssetsPath, "test.js") + }; + + var testAdapterPath = Directory.EnumerateFiles(GetTestAdapterPath(UnitTestFramework.Chutzpah), "*.TestAdapter.dll").ToList(); + _vstestConsoleWrapper.InitializeExtensions(new List() { testAdapterPath.FirstOrDefault() }); + + _vstestConsoleWrapper.RunTests( + sources, + GetDefaultRunSettings(), + _runEventHandler); + + var testCase = + _runEventHandler.TestResults.Where(tr => tr.TestCase.DisplayName.Equals("TestMethod1")); + + // Assert + Assert.AreEqual(2, _runEventHandler.TestResults.Count); + Assert.AreEqual(1, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); + Assert.AreEqual(1, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); + Assert.AreEqual(1, testCase.FirstOrDefault().TestCase.LineNumber); + } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/DiscoverTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/DiscoverTests.cs index 5b8348c522..2ed8ba50ee 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/DiscoverTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/DiscoverTests.cs @@ -1,222 +1,220 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests +namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +using TestUtilities; +using VsTestConsole.TranslationLayer.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class DiscoverTests : AcceptanceTestBase { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - - [TestClass] - public class DiscoverTests : AcceptanceTestBase - { - private IVsTestConsoleWrapper vstestConsoleWrapper; - private DiscoveryEventHandler discoveryEventHandler; - private DiscoveryEventHandler2 discoveryEventHandler2; + private IVsTestConsoleWrapper _vstestConsoleWrapper; + private DiscoveryEventHandler _discoveryEventHandler; + private DiscoveryEventHandler2 _discoveryEventHandler2; - public void Setup() - { - this.vstestConsoleWrapper = this.GetVsTestConsoleWrapper(out _); - this.discoveryEventHandler = new DiscoveryEventHandler(); - this.discoveryEventHandler2 = new DiscoveryEventHandler2(); - } + public void Setup() + { + _vstestConsoleWrapper = GetVsTestConsoleWrapper(out _); + _discoveryEventHandler = new DiscoveryEventHandler(); + _discoveryEventHandler2 = new DiscoveryEventHandler2(); + } - [TestCleanup] - public void Cleanup() - { - this.vstestConsoleWrapper?.EndSession(); - } + [TestCleanup] + public void Cleanup() + { + _vstestConsoleWrapper?.EndSession(); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void DiscoverTestsUsingDiscoveryEventHandler1(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void DiscoverTestsUsingDiscoveryEventHandler1(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); - this.Setup(); + Setup(); - this.vstestConsoleWrapper.DiscoverTests(this.GetTestAssemblies(), this.GetDefaultRunSettings(), this.discoveryEventHandler); + _vstestConsoleWrapper.DiscoverTests(GetTestAssemblies(), GetDefaultRunSettings(), _discoveryEventHandler); - // Assert. - Assert.AreEqual(6, this.discoveryEventHandler.DiscoveredTestCases.Count); - } + // Assert. + Assert.AreEqual(6, _discoveryEventHandler.DiscoveredTestCases.Count); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void DiscoverTestsUsingDiscoveryEventHandler2AndTelemetryOptedOut(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); - - this.vstestConsoleWrapper.DiscoverTests( - this.GetTestAssemblies(), - this.GetDefaultRunSettings(), - new TestPlatformOptions() { CollectMetrics = false }, - this.discoveryEventHandler2); - - // Assert. - Assert.AreEqual(6, this.discoveryEventHandler2.DiscoveredTestCases.Count); - Assert.AreEqual(0, this.discoveryEventHandler2.Metrics.Count); - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void DiscoverTestsUsingDiscoveryEventHandler2AndTelemetryOptedOut(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); + + _vstestConsoleWrapper.DiscoverTests( + GetTestAssemblies(), + GetDefaultRunSettings(), + new TestPlatformOptions() { CollectMetrics = false }, + _discoveryEventHandler2); + + // Assert. + Assert.AreEqual(6, _discoveryEventHandler2.DiscoveredTestCases.Count); + Assert.AreEqual(0, _discoveryEventHandler2.Metrics.Count); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void DiscoverTestsUsingDiscoveryEventHandler2AndTelemetryOptedIn(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); - - this.vstestConsoleWrapper.DiscoverTests(this.GetTestAssemblies(), this.GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true }, this.discoveryEventHandler2); - - // Assert. - Assert.AreEqual(6, this.discoveryEventHandler2.DiscoveredTestCases.Count); - Assert.IsTrue(this.discoveryEventHandler2.Metrics.ContainsKey(TelemetryDataConstants.TargetDevice)); - Assert.IsTrue(this.discoveryEventHandler2.Metrics.ContainsKey(TelemetryDataConstants.NumberOfAdapterUsedToDiscoverTests)); - Assert.IsTrue(this.discoveryEventHandler2.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecByAllAdapters)); - Assert.IsTrue(this.discoveryEventHandler2.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForDiscovery)); - Assert.IsTrue(this.discoveryEventHandler2.Metrics.ContainsKey(TelemetryDataConstants.DiscoveryState)); - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void DiscoverTestsUsingDiscoveryEventHandler2AndTelemetryOptedIn(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); + + _vstestConsoleWrapper.DiscoverTests(GetTestAssemblies(), GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true }, _discoveryEventHandler2); + + // Assert. + Assert.AreEqual(6, _discoveryEventHandler2.DiscoveredTestCases.Count); + Assert.IsTrue(_discoveryEventHandler2.Metrics.ContainsKey(TelemetryDataConstants.TargetDevice)); + Assert.IsTrue(_discoveryEventHandler2.Metrics.ContainsKey(TelemetryDataConstants.NumberOfAdapterUsedToDiscoverTests)); + Assert.IsTrue(_discoveryEventHandler2.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecByAllAdapters)); + Assert.IsTrue(_discoveryEventHandler2.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForDiscovery)); + Assert.IsTrue(_discoveryEventHandler2.Metrics.ContainsKey(TelemetryDataConstants.DiscoveryState)); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void DiscoverTestsUsingEventHandler2AndBatchSize(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void DiscoverTestsUsingEventHandler2AndBatchSize(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - var discoveryEventHandlerForBatchSize = new DiscoveryEventHandlerForBatchSize(); + var discoveryEventHandlerForBatchSize = new DiscoveryEventHandlerForBatchSize(); - string runSettingsXml = @" + string runSettingsXml = @" 3 "; - this.vstestConsoleWrapper.DiscoverTests( - this.GetTestAssemblies(), - runSettingsXml, - null, - discoveryEventHandlerForBatchSize); + _vstestConsoleWrapper.DiscoverTests( + GetTestAssemblies(), + runSettingsXml, + null, + discoveryEventHandlerForBatchSize); - // Assert. - Assert.AreEqual(6, discoveryEventHandlerForBatchSize.DiscoveredTestCases.Count); - Assert.AreEqual(3, discoveryEventHandlerForBatchSize.BatchSize); - } + // Assert. + Assert.AreEqual(6, discoveryEventHandlerForBatchSize.DiscoveredTestCases.Count); + Assert.AreEqual(3, discoveryEventHandlerForBatchSize.BatchSize); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void DiscoverTestsUsingEventHandler1AndBatchSize(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void DiscoverTestsUsingEventHandler1AndBatchSize(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - var discoveryEventHandlerForBatchSize = new DiscoveryEventHandlerForBatchSize(); + var discoveryEventHandlerForBatchSize = new DiscoveryEventHandlerForBatchSize(); - string runSettingsXml = @" + string runSettingsXml = @" 3 "; - this.vstestConsoleWrapper.DiscoverTests( - this.GetTestAssemblies(), - runSettingsXml, - discoveryEventHandlerForBatchSize); + _vstestConsoleWrapper.DiscoverTests( + GetTestAssemblies(), + runSettingsXml, + discoveryEventHandlerForBatchSize); - // Assert. - Assert.AreEqual(6, discoveryEventHandlerForBatchSize.DiscoveredTestCases.Count); - Assert.AreEqual(3, discoveryEventHandlerForBatchSize.BatchSize); - } + // Assert. + Assert.AreEqual(6, discoveryEventHandlerForBatchSize.DiscoveredTestCases.Count); + Assert.AreEqual(3, discoveryEventHandlerForBatchSize.BatchSize); + } + + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void DiscoverTestsUsingSourceNavigation(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void DiscoverTestsUsingSourceNavigation(RunnerInfo runnerInfo) + _vstestConsoleWrapper.DiscoverTests( + GetTestAssemblies(), + GetDefaultRunSettings(), + _discoveryEventHandler); + + // Assert. + var testCase = + _discoveryEventHandler.DiscoveredTestCases.Where(dt => dt.FullyQualifiedName.Equals("SampleUnitTestProject.UnitTest1.PassingTest")); + + // Release builds optimize code, hence line numbers are different. + if (IntegrationTestEnvironment.BuildConfiguration.StartsWith("release", StringComparison.OrdinalIgnoreCase)) { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); - - this.vstestConsoleWrapper.DiscoverTests( - this.GetTestAssemblies(), - this.GetDefaultRunSettings(), - this.discoveryEventHandler); - - // Assert. - var testCase = - this.discoveryEventHandler.DiscoveredTestCases.Where(dt => dt.FullyQualifiedName.Equals("SampleUnitTestProject.UnitTest1.PassingTest")); - - // Release builds optimize code, hence line numbers are different. - if (IntegrationTestEnvironment.BuildConfiguration.StartsWith("release", StringComparison.OrdinalIgnoreCase)) - { - Assert.AreEqual(25, testCase.FirstOrDefault().LineNumber); - } - else - { - Assert.AreEqual(24, testCase.FirstOrDefault().LineNumber); - } + Assert.AreEqual(25, testCase.FirstOrDefault().LineNumber); } - - [TestMethod] - // flaky on the desktop runner, desktop framework combo - [NetFullTargetFrameworkDataSource(useDesktopRunner: false)] - [NetCoreTargetFrameworkDataSource] - public void CancelTestDiscovery(RunnerInfo runnerInfo) + else { - // Setup - var testAssemblies = new List - { - this.GetAssetFullPath("DiscoveryTestProject.dll"), - this.GetAssetFullPath("SimpleTestProject.dll"), - this.GetAssetFullPath("SimpleTestProject2.dll") - }; - - SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); - - var discoveredTests = new List(); - var discoveryEvents = new Mock(); - discoveryEvents.Setup((events) => events.HandleDiscoveredTests(It.IsAny>())).Callback - ((IEnumerable testcases) => { discoveredTests.AddRange(testcases); }); - - // Act - var discoveryTask = Task.Run(() => - { - this.vstestConsoleWrapper.DiscoverTests(testAssemblies, this.GetDefaultRunSettings(), discoveryEvents.Object); - }); - - Task.Delay(2000).Wait(); - vstestConsoleWrapper.CancelDiscovery(); - discoveryTask.Wait(); - - // Assert. - int discoveredSources = discoveredTests.Select((testcase) => testcase.Source).Distinct().Count(); - Assert.AreNotEqual(testAssemblies.Count, discoveredSources, "All test assemblies discovered"); + Assert.AreEqual(24, testCase.FirstOrDefault().LineNumber); } + } - private IList GetTestAssemblies() + [TestMethod] + // flaky on the desktop runner, desktop framework combo + [NetFullTargetFrameworkDataSource(useDesktopRunner: false)] + [NetCoreTargetFrameworkDataSource] + public void CancelTestDiscovery(RunnerInfo runnerInfo) + { + // Setup + var testAssemblies = new List { - var testAssemblies = new List - { - this.GetAssetFullPath("SimpleTestProject.dll"), - this.GetAssetFullPath("SimpleTestProject2.dll") - }; + GetAssetFullPath("DiscoveryTestProject.dll"), + GetAssetFullPath("SimpleTestProject.dll"), + GetAssetFullPath("SimpleTestProject2.dll") + }; - return testAssemblies; - } + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); + + var discoveredTests = new List(); + var discoveryEvents = new Mock(); + discoveryEvents.Setup((events) => events.HandleDiscoveredTests(It.IsAny>())).Callback + ((IEnumerable testcases) => discoveredTests.AddRange(testcases)); + + // Act + var discoveryTask = Task.Run(() => _vstestConsoleWrapper.DiscoverTests(testAssemblies, GetDefaultRunSettings(), discoveryEvents.Object)); + + Task.Delay(2000).Wait(); + _vstestConsoleWrapper.CancelDiscovery(); + discoveryTask.Wait(); + + // Assert. + int discoveredSources = discoveredTests.Select((testcase) => testcase.Source).Distinct().Count(); + Assert.AreNotEqual(testAssemblies.Count, discoveredSources, "All test assemblies discovered"); + } + + private IList GetTestAssemblies() + { + var testAssemblies = new List + { + GetAssetFullPath("SimpleTestProject.dll"), + GetAssetFullPath("SimpleTestProject2.dll") + }; + + return testAssemblies; } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/EventHandler/DiscoveryEventHandler.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/EventHandler/DiscoveryEventHandler.cs index e6e72e7a24..aea81ba6eb 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/EventHandler/DiscoveryEventHandler.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/EventHandler/DiscoveryEventHandler.cs @@ -1,168 +1,167 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests -{ - using System.Collections.Generic; - using System.Linq; - - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests; - /// - public class DiscoveryEventHandler : ITestDiscoveryEventsHandler - { - /// - /// Gets the discovered test cases. - /// - public List DiscoveredTestCases { get;} +using System.Collections.Generic; +using System.Linq; - public DiscoveryEventHandler() - { - this.DiscoveredTestCases = new List(); - } +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - public void HandleDiscoveredTests(IEnumerable discoveredTestCases) - { - if (discoveredTestCases != null) - { - this.DiscoveredTestCases.AddRange(discoveredTestCases); - } - } +/// +public class DiscoveryEventHandler : ITestDiscoveryEventsHandler +{ + /// + /// Gets the discovered test cases. + /// + public List DiscoveredTestCases { get; } - public void HandleDiscoveryComplete(long totalTests, IEnumerable lastChunk, bool isAborted) - { - if (lastChunk != null) - { - this.DiscoveredTestCases.AddRange(lastChunk); - } - } + public DiscoveryEventHandler() + { + DiscoveredTestCases = new List(); + } - public void HandleLogMessage(TestMessageLevel level, string message) + public void HandleDiscoveredTests(IEnumerable discoveredTestCases) + { + if (discoveredTestCases != null) { - // No Op + DiscoveredTestCases.AddRange(discoveredTestCases); } + } - public void HandleRawMessage(string rawMessage) + public void HandleDiscoveryComplete(long totalTests, IEnumerable lastChunk, bool isAborted) + { + if (lastChunk != null) { - // No op + DiscoveredTestCases.AddRange(lastChunk); } } - public struct TestMessage + public void HandleLogMessage(TestMessageLevel level, string message) { - public TestMessageLevel testMessageLevel; - public string message; + // No Op + } - public TestMessage(TestMessageLevel testMessageLevel, string message) - { - this.testMessageLevel = testMessageLevel; - this.message = message; - } + public void HandleRawMessage(string rawMessage) + { + // No op } +} - /// - public class DiscoveryEventHandler2 : ITestDiscoveryEventsHandler2 +public struct TestMessage +{ + public TestMessageLevel TestMessageLevel; + public string Message; + + public TestMessage(TestMessageLevel testMessageLevel, string message) { - /// - /// Gets the discovered test cases. - /// - public List DiscoveredTestCases { get; } + TestMessageLevel = testMessageLevel; + Message = message; + } +} - public List testMessages; +/// +public class DiscoveryEventHandler2 : ITestDiscoveryEventsHandler2 +{ + /// + /// Gets the discovered test cases. + /// + public List DiscoveredTestCases { get; } - /// - /// Gets the metrics. - /// - public IDictionary Metrics { get; private set; } + public List TestMessages; - public DiscoveryEventHandler2() - { - this.DiscoveredTestCases = new List(); - this.testMessages = new List(); - } + /// + /// Gets the metrics. + /// + public IDictionary Metrics { get; private set; } - public void HandleRawMessage(string rawMessage) - { - // No Op - } + public DiscoveryEventHandler2() + { + DiscoveredTestCases = new List(); + TestMessages = new List(); + } - public void HandleLogMessage(TestMessageLevel level, string message) - { - this.testMessages.Add(new TestMessage(level, message)); - } + public void HandleRawMessage(string rawMessage) + { + // No Op + } - public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk) - { - if (lastChunk != null) - { - this.DiscoveredTestCases.AddRange(lastChunk); - } + public void HandleLogMessage(TestMessageLevel level, string message) + { + TestMessages.Add(new TestMessage(level, message)); + } - this.Metrics = discoveryCompleteEventArgs.Metrics; + public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk) + { + if (lastChunk != null) + { + DiscoveredTestCases.AddRange(lastChunk); } - public void HandleDiscoveredTests(IEnumerable discoveredTestCases) + Metrics = discoveryCompleteEventArgs.Metrics; + } + + public void HandleDiscoveredTests(IEnumerable discoveredTestCases) + { + if (discoveredTestCases != null) { - if (discoveredTestCases != null) - { - this.DiscoveredTestCases.AddRange(discoveredTestCases); - } + DiscoveredTestCases.AddRange(discoveredTestCases); } } +} - /// Discovery Event Handler for batch size - public class DiscoveryEventHandlerForBatchSize : ITestDiscoveryEventsHandler2, ITestDiscoveryEventsHandler - { - /// - /// Gets the batch size. - /// - public long BatchSize { get; private set; } +/// Discovery Event Handler for batch size +public class DiscoveryEventHandlerForBatchSize : ITestDiscoveryEventsHandler2, ITestDiscoveryEventsHandler +{ + /// + /// Gets the batch size. + /// + public long BatchSize { get; private set; } - /// - /// Gets the discovered test cases. - /// - public List DiscoveredTestCases { get; } + /// + /// Gets the discovered test cases. + /// + public List DiscoveredTestCases { get; } - public DiscoveryEventHandlerForBatchSize() - { - this.DiscoveredTestCases = new List(); - } + public DiscoveryEventHandlerForBatchSize() + { + DiscoveredTestCases = new List(); + } - public void HandleRawMessage(string rawMessage) - { - // No Op - } + public void HandleRawMessage(string rawMessage) + { + // No Op + } - public void HandleLogMessage(TestMessageLevel level, string message) - { - // No Op - } + public void HandleLogMessage(TestMessageLevel level, string message) + { + // No Op + } - public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk) + public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk) + { + if (lastChunk != null) { - if (lastChunk != null) - { - this.DiscoveredTestCases.AddRange(lastChunk); - } + DiscoveredTestCases.AddRange(lastChunk); } + } - public void HandleDiscoveryComplete(long totalTests, IEnumerable lastChunk, bool isAborted) + public void HandleDiscoveryComplete(long totalTests, IEnumerable lastChunk, bool isAborted) + { + if (lastChunk != null) { - if (lastChunk != null) - { - this.DiscoveredTestCases.AddRange(lastChunk); - } + DiscoveredTestCases.AddRange(lastChunk); } + } - public void HandleDiscoveredTests(IEnumerable discoveredTestCases) + public void HandleDiscoveredTests(IEnumerable discoveredTestCases) + { + if (discoveredTestCases != null && discoveredTestCases.Any()) { - if (discoveredTestCases != null && discoveredTestCases.Any()) - { - this.DiscoveredTestCases.AddRange(discoveredTestCases); - this.BatchSize = discoveredTestCases.Count(); - } + DiscoveredTestCases.AddRange(discoveredTestCases); + BatchSize = discoveredTestCases.Count(); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/EventHandler/RunEventHandler.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/EventHandler/RunEventHandler.cs index 10c9f7c40c..01a629f6f6 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/EventHandler/RunEventHandler.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/EventHandler/RunEventHandler.cs @@ -1,122 +1,123 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests +namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests; + +using System; +using System.Collections.Generic; +using System.Linq; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +/// +public class RunEventHandler : ITestRunEventsHandler2 { - using System; - using System.Collections.Generic; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - - /// - public class RunEventHandler : ITestRunEventsHandler2 + /// + /// Gets the test results. + /// + public List TestResults { get; private set; } + + /// + /// Gets the attachments. + /// + public List Attachments { get; private set; } + + /// + /// Gets the list of the invoked data collectors. + /// + public List InvokedDataCollectors { get; private set; } + + /// + /// Gets the metrics. + /// + public IDictionary Metrics { get; private set; } + + /// + /// Gets the log message. + /// + public string LogMessage { get; private set; } + + public List Errors { get; set; } + + /// + /// Gets the test message level. + /// + public TestMessageLevel TestMessageLevel { get; private set; } + + public RunEventHandler() { - /// - /// Gets the test results. - /// - public List TestResults { get; private set; } - - /// - /// Gets the attachments. - /// - public List Attachments { get; private set; } - - /// - /// Gets the list of the invoked data collectors. - /// - public List InvokedDataCollectors { get; private set; } - - /// - /// Gets the metrics. - /// - public IDictionary Metrics { get; private set; } - - /// - /// Gets the log message. - /// - public string LogMessage { get; private set; } - - public List Errors { get; set; } - - /// - /// Gets the test message level. - /// - public TestMessageLevel TestMessageLevel { get; private set; } - - public RunEventHandler() - { - this.TestResults = new List(); - this.Errors = new List(); - this.Attachments = new List(); - this.InvokedDataCollectors = new List(); - } + TestResults = new List(); + Errors = new List(); + Attachments = new List(); + InvokedDataCollectors = new List(); + } - public void EnsureSuccess() + public void EnsureSuccess() + { + if (Errors.Any()) { - if (this.Errors.Any()) - { - throw new InvalidOperationException($"Test run reported errors:{Environment.NewLine}{string.Join(Environment.NewLine + Environment.NewLine, this.Errors)}"); - } + throw new InvalidOperationException($"Test run reported errors:{Environment.NewLine}{string.Join(Environment.NewLine + Environment.NewLine, Errors)}"); } + } - public void HandleLogMessage(TestMessageLevel level, string message) + public void HandleLogMessage(TestMessageLevel level, string message) + { + LogMessage = message; + TestMessageLevel = level; + if (level == TestMessageLevel.Error) { - this.LogMessage = message; - this.TestMessageLevel = level; - if (level == TestMessageLevel.Error) { - this.Errors.Add(message); - } + Errors.Add(message); } + } - public void HandleTestRunComplete( - TestRunCompleteEventArgs testRunCompleteArgs, - TestRunChangedEventArgs lastChunkArgs, - ICollection runContextAttachments, - ICollection executorUris) + public void HandleTestRunComplete( + TestRunCompleteEventArgs testRunCompleteArgs, + TestRunChangedEventArgs lastChunkArgs, + ICollection runContextAttachments, + ICollection executorUris) + { + if (lastChunkArgs != null && lastChunkArgs.NewTestResults != null) { - if (lastChunkArgs != null && lastChunkArgs.NewTestResults != null) - { - this.TestResults.AddRange(lastChunkArgs.NewTestResults); - } - - if (testRunCompleteArgs.AttachmentSets != null) - { - this.Attachments.AddRange(testRunCompleteArgs.AttachmentSets); - } - - if (testRunCompleteArgs.InvokedDataCollectors != null) - { - this.InvokedDataCollectors.AddRange(testRunCompleteArgs.InvokedDataCollectors); - } - - this.Metrics = testRunCompleteArgs.Metrics; + TestResults.AddRange(lastChunkArgs.NewTestResults); } - public void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChangedArgs) + if (testRunCompleteArgs.AttachmentSets != null) { - if (testRunChangedArgs != null && testRunChangedArgs.NewTestResults != null) - { - this.TestResults.AddRange(testRunChangedArgs.NewTestResults); - } + Attachments.AddRange(testRunCompleteArgs.AttachmentSets); } - public void HandleRawMessage(string rawMessage) + if (testRunCompleteArgs.InvokedDataCollectors != null) { - // No op + InvokedDataCollectors.AddRange(testRunCompleteArgs.InvokedDataCollectors); } - public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) - { - // No op - return -1; - } + Metrics = testRunCompleteArgs.Metrics; + } - public bool AttachDebuggerToProcess(int pid) + public void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChangedArgs) + { + if (testRunChangedArgs != null && testRunChangedArgs.NewTestResults != null) { - // No op - return true; + TestResults.AddRange(testRunChangedArgs.NewTestResults); } } -} + + public void HandleRawMessage(string rawMessage) + { + // No op + } + + public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) + { + // No op + return -1; + } + + public bool AttachDebuggerToProcess(int pid) + { + // No op + return true; + } +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/EventHandler/TestRunAttachmentsProcessingEventHandler.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/EventHandler/TestRunAttachmentsProcessingEventHandler.cs index 8a0b6513c6..0da82cfeaf 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/EventHandler/TestRunAttachmentsProcessingEventHandler.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/EventHandler/TestRunAttachmentsProcessingEventHandler.cs @@ -1,109 +1,109 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests -{ - using System; - using System.Collections.Generic; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - - /// - public class TestRunAttachmentsProcessingEventHandler : ITestRunAttachmentsProcessingEventsHandler - { - public List Attachments { get; private set; } +namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests; - public TestRunAttachmentsProcessingCompleteEventArgs CompleteArgs { get; private set; } +using System; +using System.Collections.Generic; +using System.Linq; - public List ProgressArgs { get; private set; } +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - /// - /// Gets the log message. - /// - public string LogMessage { get; private set; } +/// +public class TestRunAttachmentsProcessingEventHandler : ITestRunAttachmentsProcessingEventsHandler +{ + public List Attachments { get; private set; } - public List Errors { get; set; } + public TestRunAttachmentsProcessingCompleteEventArgs CompleteArgs { get; private set; } - /// - /// Gets the test message level. - /// - public TestMessageLevel TestMessageLevel { get; private set; } + public List ProgressArgs { get; private set; } - public TestRunAttachmentsProcessingEventHandler() - { - this.Errors = new List(); - this.Attachments = new List(); - this.ProgressArgs = new List(); - } + /// + /// Gets the log message. + /// + public string LogMessage { get; private set; } - public void EnsureSuccess() - { - if (this.Errors.Any()) - { - throw new InvalidOperationException($"Test run reported errors:{Environment.NewLine}{string.Join(Environment.NewLine + Environment.NewLine, this.Errors)}"); - } - } + public List Errors { get; set; } - public void HandleLogMessage(TestMessageLevel level, string message) - { - this.LogMessage = message; - this.TestMessageLevel = level; - if (level == TestMessageLevel.Error) - { - this.Errors.Add(message); - } - } + /// + /// Gets the test message level. + /// + public TestMessageLevel TestMessageLevel { get; private set; } - public void HandleRawMessage(string rawMessage) - { - // No op - } + public TestRunAttachmentsProcessingEventHandler() + { + Errors = new List(); + Attachments = new List(); + ProgressArgs = new List(); + } - public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) + public void EnsureSuccess() + { + if (Errors.Any()) { - // No op - return -1; + throw new InvalidOperationException($"Test run reported errors:{Environment.NewLine}{string.Join(Environment.NewLine + Environment.NewLine, Errors)}"); } + } - public bool AttachDebuggerToProcess(int pid) + public void HandleLogMessage(TestMessageLevel level, string message) + { + LogMessage = message; + TestMessageLevel = level; + if (level == TestMessageLevel.Error) { - // No op - return true; + Errors.Add(message); } + } - public void HandleTestRunAttachmentsProcessingComplete(ICollection attachments) - { - if(attachments != null) - { - this.Attachments.AddRange(attachments); - } - } + public void HandleRawMessage(string rawMessage) + { + // No op + } - public void HandleTestRunAttachmentsProcessingComplete(TestRunAttachmentsProcessingCompleteEventArgs attachmentsProcessingCompleteEventArgs, IEnumerable lastChunk) - { - if (lastChunk != null) - { - this.Attachments.AddRange(lastChunk); - } + public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) + { + // No op + return -1; + } - if (attachmentsProcessingCompleteEventArgs.Error != null) - { - Errors.Add(attachmentsProcessingCompleteEventArgs.Error.Message); - } + public bool AttachDebuggerToProcess(int pid) + { + // No op + return true; + } - CompleteArgs = attachmentsProcessingCompleteEventArgs; + public void HandleTestRunAttachmentsProcessingComplete(ICollection attachments) + { + if (attachments != null) + { + Attachments.AddRange(attachments); } + } - public void HandleProcessedAttachmentsChunk(IEnumerable attachments) + public void HandleTestRunAttachmentsProcessingComplete(TestRunAttachmentsProcessingCompleteEventArgs attachmentsProcessingCompleteEventArgs, IEnumerable lastChunk) + { + if (lastChunk != null) { - throw new NotImplementedException(); + Attachments.AddRange(lastChunk); } - public void HandleTestRunAttachmentsProcessingProgress(TestRunAttachmentsProcessingProgressEventArgs AttachmentsProcessingProgressEventArgs) + if (attachmentsProcessingCompleteEventArgs.Error != null) { - ProgressArgs.Add(AttachmentsProcessingProgressEventArgs); + Errors.Add(attachmentsProcessingCompleteEventArgs.Error.Message); } + + CompleteArgs = attachmentsProcessingCompleteEventArgs; + } + + public void HandleProcessedAttachmentsChunk(IEnumerable attachments) + { + throw new NotImplementedException(); + } + + public void HandleTestRunAttachmentsProcessingProgress(TestRunAttachmentsProcessingProgressEventArgs attachmentsProcessingProgressEventArgs) + { + ProgressArgs.Add(attachmentsProcessingProgressEventArgs); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/LiveUnitTestingTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/LiveUnitTestingTests.cs index 42a995d408..b9977521b5 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/LiveUnitTestingTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/LiveUnitTestingTests.cs @@ -1,44 +1,45 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests +namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests; + +using VsTestConsole.TranslationLayer.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using VisualStudio.TestTools.UnitTesting; + +using System.Collections.Generic; +using System.Linq; + +[TestClass] +public class LiveUnitTestingTests : AcceptanceTestBase { - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System.Collections.Generic; - using System.Linq; - - [TestClass] - public class LiveUnitTestingTests : AcceptanceTestBase - { - private IVsTestConsoleWrapper vstestConsoleWrapper; - private DiscoveryEventHandler discoveryEventHandler; - private RunEventHandler runEventHandler; + private IVsTestConsoleWrapper _vstestConsoleWrapper; + private DiscoveryEventHandler _discoveryEventHandler; + private RunEventHandler _runEventHandler; - public void Setup() - { - this.vstestConsoleWrapper = this.GetVsTestConsoleWrapper(out _); - this.discoveryEventHandler = new DiscoveryEventHandler(); - this.runEventHandler = new RunEventHandler(); - } + public void Setup() + { + _vstestConsoleWrapper = GetVsTestConsoleWrapper(out _); + _discoveryEventHandler = new DiscoveryEventHandler(); + _runEventHandler = new RunEventHandler(); + } - [TestCleanup] - public void Cleanup() - { - this.vstestConsoleWrapper?.EndSession(); - } + [TestCleanup] + public void Cleanup() + { + _vstestConsoleWrapper?.EndSession(); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void DiscoverTestsUsingLiveUnitTesting(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void DiscoverTestsUsingLiveUnitTesting(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - string runSettingsXml = @" + string runSettingsXml = @" true @@ -46,24 +47,24 @@ public void DiscoverTestsUsingLiveUnitTesting(RunnerInfo runnerInfo) "; - this.vstestConsoleWrapper.DiscoverTests( - this.GetTestAssemblies(), - runSettingsXml, - this.discoveryEventHandler); + _vstestConsoleWrapper.DiscoverTests( + GetTestAssemblies(), + runSettingsXml, + _discoveryEventHandler); - // Assert - Assert.AreEqual(6, this.discoveryEventHandler.DiscoveredTestCases.Count); - } + // Assert + Assert.AreEqual(6, _discoveryEventHandler.DiscoveredTestCases.Count); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunTestsWithLiveUnitTesting(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunTestsWithLiveUnitTesting(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - string runSettingsXml = @" + string runSettingsXml = @" true @@ -71,27 +72,26 @@ public void RunTestsWithLiveUnitTesting(RunnerInfo runnerInfo) "; - this.vstestConsoleWrapper.RunTests( - this.GetTestAssemblies(), - runSettingsXml, - this.runEventHandler); + _vstestConsoleWrapper.RunTests( + GetTestAssemblies(), + runSettingsXml, + _runEventHandler); - // Assert - Assert.AreEqual(6, this.runEventHandler.TestResults.Count); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Skipped)); - } + // Assert + Assert.AreEqual(6, _runEventHandler.TestResults.Count); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Skipped)); + } - private IList GetTestAssemblies() + private IList GetTestAssemblies() + { + var testAssemblies = new List { - var testAssemblies = new List - { - this.GetAssetFullPath("SimpleTestProject.dll"), - this.GetAssetFullPath("SimpleTestProject2.dll") - }; - - return testAssemblies; - } + GetAssetFullPath("SimpleTestProject.dll"), + GetAssetFullPath("SimpleTestProject2.dll") + }; + + return testAssemblies; } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunSelectedTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunSelectedTests.cs index aeea54955c..ee75fac11c 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunSelectedTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunSelectedTests.cs @@ -1,92 +1,92 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests +namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests; + +using System.Collections.Generic; +using System.Linq; + +using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class RunSelectedTests : AcceptanceTestBase { - using System.Collections.Generic; - using System.Linq; - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class RunSelectedTests : AcceptanceTestBase + private IVsTestConsoleWrapper _vstestConsoleWrapper; + private RunEventHandler _runEventHandler; + private DiscoveryEventHandler _discoveryEventHandler; + + private void Setup() { - private IVsTestConsoleWrapper vstestConsoleWrapper; - private RunEventHandler runEventHandler; - private DiscoveryEventHandler discoveryEventHandler; + _vstestConsoleWrapper = GetVsTestConsoleWrapper(out _); + _runEventHandler = new RunEventHandler(); + _discoveryEventHandler = new DiscoveryEventHandler(); + } - private void Setup() - { - this.vstestConsoleWrapper = this.GetVsTestConsoleWrapper(out _); - this.runEventHandler = new RunEventHandler(); - this.discoveryEventHandler = new DiscoveryEventHandler(); - } + [TestCleanup] + public void Cleanup() + { + _vstestConsoleWrapper?.EndSession(); + } - [TestCleanup] - public void Cleanup() - { - this.vstestConsoleWrapper?.EndSession(); - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunSelectedTestsWithoutTestPlatformOptions(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunSelectedTestsWithoutTestPlatformOptions(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + _vstestConsoleWrapper.DiscoverTests(GetTestAssemblies(), GetDefaultRunSettings(), _discoveryEventHandler); + var testCases = _discoveryEventHandler.DiscoveredTestCases; - this.vstestConsoleWrapper.DiscoverTests(this.GetTestAssemblies(), this.GetDefaultRunSettings(), this.discoveryEventHandler); - var testCases = this.discoveryEventHandler.DiscoveredTestCases; + _vstestConsoleWrapper.RunTests(testCases, GetDefaultRunSettings(), _runEventHandler); - this.vstestConsoleWrapper.RunTests(testCases, this.GetDefaultRunSettings(), this.runEventHandler); + // Assert + Assert.AreEqual(6, _runEventHandler.TestResults.Count); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Skipped)); + } - // Assert - Assert.AreEqual(6, this.runEventHandler.TestResults.Count); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Skipped)); - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunSelectedTestsWithTestPlatformOptions(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunSelectedTestsWithTestPlatformOptions(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); - - this.vstestConsoleWrapper.DiscoverTests(this.GetTestAssemblies(), this.GetDefaultRunSettings(), this.discoveryEventHandler); - var testCases = this.discoveryEventHandler.DiscoveredTestCases; - - this.vstestConsoleWrapper.RunTests( - testCases, - this.GetDefaultRunSettings(), - new TestPlatformOptions() { CollectMetrics = true }, - this.runEventHandler); - - // Assert - Assert.AreEqual(6, this.runEventHandler.TestResults.Count); - Assert.IsTrue(this.runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TargetDevice)); - Assert.IsTrue(this.runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TargetFramework)); - Assert.IsTrue(this.runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TargetOS)); - Assert.IsTrue(this.runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForRun)); - Assert.IsTrue(this.runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringExecution)); - Assert.IsTrue(this.runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.RunState)); - } - - private IList GetTestAssemblies() + _vstestConsoleWrapper.DiscoverTests(GetTestAssemblies(), GetDefaultRunSettings(), _discoveryEventHandler); + var testCases = _discoveryEventHandler.DiscoveredTestCases; + + _vstestConsoleWrapper.RunTests( + testCases, + GetDefaultRunSettings(), + new TestPlatformOptions() { CollectMetrics = true }, + _runEventHandler); + + // Assert + Assert.AreEqual(6, _runEventHandler.TestResults.Count); + Assert.IsTrue(_runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TargetDevice)); + Assert.IsTrue(_runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TargetFramework)); + Assert.IsTrue(_runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TargetOS)); + Assert.IsTrue(_runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForRun)); + Assert.IsTrue(_runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringExecution)); + Assert.IsTrue(_runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.RunState)); + } + + private IList GetTestAssemblies() + { + var testAssemblies = new List { - var testAssemblies = new List - { - this.GetAssetFullPath("SimpleTestProject.dll"), - this.GetAssetFullPath("SimpleTestProject2.dll") - }; - - return testAssemblies; - } + GetAssetFullPath("SimpleTestProject.dll"), + GetAssetFullPath("SimpleTestProject2.dll") + }; + + return testAssemblies; } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTests.cs index 3c0a8a9609..db8645f06d 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTests.cs @@ -1,195 +1,195 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests +namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests; + +using TestUtilities; +using VsTestConsole.TranslationLayer.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using VisualStudio.TestTools.UnitTesting; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; + +using VisualStudio.TestPlatform.ObjectModel.Logging; + +/// +/// The Run Tests using VsTestConsoleWrapper API's +/// +[TestClass] +public class RunTests : AcceptanceTestBase { - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Linq; - using VisualStudio.TestPlatform.ObjectModel.Logging; - - /// - /// The Run Tests using VsTestConsoleWrapper API's - /// - [TestClass] - public class RunTests : AcceptanceTestBase + private IVsTestConsoleWrapper _vstestConsoleWrapper; + private RunEventHandler _runEventHandler; + + private void Setup() { - private IVsTestConsoleWrapper vstestConsoleWrapper; - private RunEventHandler runEventHandler; + _vstestConsoleWrapper = GetVsTestConsoleWrapper(out _); + _runEventHandler = new RunEventHandler(); + } - private void Setup() - { - this.vstestConsoleWrapper = this.GetVsTestConsoleWrapper(out _); - this.runEventHandler = new RunEventHandler(); - } + [TestCleanup] + public void Cleanup() + { + _vstestConsoleWrapper?.EndSession(); + } - [TestCleanup] - public void Cleanup() - { - this.vstestConsoleWrapper?.EndSession(); - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunAllTests(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunAllTests(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + _vstestConsoleWrapper.RunTests(GetTestAssemblies(), GetDefaultRunSettings(), _runEventHandler); - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies(), this.GetDefaultRunSettings(), this.runEventHandler); + // Assert + Assert.AreEqual(6, _runEventHandler.TestResults.Count); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Skipped)); + } - // Assert - Assert.AreEqual(6, this.runEventHandler.TestResults.Count); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Skipped)); - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + [DoNotParallelize] + public void EndSessionShouldEnsureVstestConsoleProcessDies(RunnerInfo runnerInfo) + { + var numOfProcesses = Process.GetProcessesByName("vstest.console").Length; - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - [DoNotParallelize] - public void EndSessionShouldEnsureVstestConsoleProcessDies(RunnerInfo runnerInfo) - { - var numOfProcesses = Process.GetProcessesByName("vstest.console").Length; + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + _vstestConsoleWrapper.RunTests(GetTestAssemblies(), GetDefaultRunSettings(), _runEventHandler); + _vstestConsoleWrapper?.EndSession(); - this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies(), this.GetDefaultRunSettings(), this.runEventHandler); - this.vstestConsoleWrapper?.EndSession(); + // Assert + Assert.AreEqual(numOfProcesses, Process.GetProcessesByName("vstest.console").Length); - // Assert - Assert.AreEqual(numOfProcesses, Process.GetProcessesByName("vstest.console").Length); + _vstestConsoleWrapper = null; + } - this.vstestConsoleWrapper = null; - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunTestsWithTelemetryOptedIn(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); + + _vstestConsoleWrapper.RunTests( + GetTestAssemblies(), + GetDefaultRunSettings(), + new TestPlatformOptions() { CollectMetrics = true }, + _runEventHandler); + + // Assert + Assert.AreEqual(6, _runEventHandler.TestResults.Count); + Assert.IsTrue(_runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TargetDevice)); + Assert.IsTrue(_runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TargetFramework)); + Assert.IsTrue(_runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TargetOS)); + Assert.IsTrue(_runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForRun)); + Assert.IsTrue(_runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringExecution)); + Assert.IsTrue(_runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.RunState)); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunTestsWithTelemetryOptedIn(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); - - this.vstestConsoleWrapper.RunTests( - this.GetTestAssemblies(), - this.GetDefaultRunSettings(), - new TestPlatformOptions() { CollectMetrics = true }, - this.runEventHandler); - - // Assert - Assert.AreEqual(6, this.runEventHandler.TestResults.Count); - Assert.IsTrue(this.runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TargetDevice)); - Assert.IsTrue(this.runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TargetFramework)); - Assert.IsTrue(this.runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TargetOS)); - Assert.IsTrue(this.runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForRun)); - Assert.IsTrue(this.runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringExecution)); - Assert.IsTrue(this.runEventHandler.Metrics.ContainsKey(TelemetryDataConstants.RunState)); - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunTestsWithTelemetryOptedOut(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); + + _vstestConsoleWrapper.RunTests( + GetTestAssemblies(), + GetDefaultRunSettings(), + new TestPlatformOptions() { CollectMetrics = false }, + _runEventHandler); + + // Assert + Assert.AreEqual(6, _runEventHandler.TestResults.Count); + Assert.AreEqual(0, _runEventHandler.Metrics.Count); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunTestsWithTelemetryOptedOut(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); - - this.vstestConsoleWrapper.RunTests( - this.GetTestAssemblies(), - this.GetDefaultRunSettings(), - new TestPlatformOptions() { CollectMetrics = false }, - this.runEventHandler); - - // Assert - Assert.AreEqual(6, this.runEventHandler.TestResults.Count); - Assert.AreEqual(0, this.runEventHandler.Metrics.Count); - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunTestsShouldThrowOnStackOverflowException(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - //[DoNotParallelize] - public void RunTestsShouldThrowOnStackOverflowException(RunnerInfo runnerInfo) + if (IntegrationTestEnvironment.BuildConfiguration.Equals("release", StringComparison.OrdinalIgnoreCase)) { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); - - if (IntegrationTestEnvironment.BuildConfiguration.Equals("release", StringComparison.OrdinalIgnoreCase)) - { - // On release, x64 builds, recursive calls may be replaced with loops (tail call optimization) - Assert.Inconclusive("On StackOverflowException testhost not exited in release configuration."); - return; - } + // On release, x64 builds, recursive calls may be replaced with loops (tail call optimization) + Assert.Inconclusive("On StackOverflowException testhost not exited in release configuration."); + return; + } - var source = new[] { this.GetAssetFullPath("SimpleTestProject3.dll") }; + var source = new[] { GetAssetFullPath("SimpleTestProject3.dll") }; - this.vstestConsoleWrapper.RunTests( - source, - this.GetDefaultRunSettings(), - new TestPlatformOptions() { TestCaseFilter = "ExitWithStackoverFlow" }, - this.runEventHandler); + _vstestConsoleWrapper.RunTests( + source, + GetDefaultRunSettings(), + new TestPlatformOptions() { TestCaseFilter = "ExitWithStackoverFlow" }, + _runEventHandler); - var errorMessage = runnerInfo.TargetFramework == "net451" - ? $"The active test run was aborted. Reason: Test host process crashed : Process is terminated due to StackOverflowException.{Environment.NewLine}" - : $"The active test run was aborted. Reason: Test host process crashed : Process is terminating due to StackOverflowException.{Environment.NewLine}"; + var errorMessage = runnerInfo.TargetFramework == "net451" + ? $"The active test run was aborted. Reason: Test host process crashed : Process is terminated due to StackOverflowException.{Environment.NewLine}" + : $"The active test run was aborted. Reason: Test host process crashed : Process is terminating due to StackOverflowException.{Environment.NewLine}"; - Assert.IsTrue(this.runEventHandler.Errors.Contains(errorMessage)); - } + Assert.IsTrue(_runEventHandler.Errors.Contains(errorMessage)); + } - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource(useCoreRunner: false)] - [NetCoreTargetFrameworkDataSource(useCoreRunner: false)] - public void RunTestsShouldShowProperWarningOnNoTestsForTestCaseFilter(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource(useCoreRunner: false)] + [NetCoreTargetFrameworkDataSource(useCoreRunner: false)] + public void RunTestsShouldShowProperWarningOnNoTestsForTestCaseFilter(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - var testAssemblyName = "SimpleTestProject2.dll"; - var source = new List() { this.GetAssetFullPath(testAssemblyName) }; + var testAssemblyName = "SimpleTestProject2.dll"; + var source = new List() { GetAssetFullPath(testAssemblyName) }; - var veryLongTestCaseFilter = - "FullyQualifiedName=VeryLongTestCaseNameeeeeeeeeeeeee" + - "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + - "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + - "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + - "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; + var veryLongTestCaseFilter = + "FullyQualifiedName=VeryLongTestCaseNameeeeeeeeeeeeee" + + "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + + "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + + "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + + "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; - this.vstestConsoleWrapper.RunTests( - source, - this.GetDefaultRunSettings(), - new TestPlatformOptions() { TestCaseFilter = veryLongTestCaseFilter }, - this.runEventHandler); + _vstestConsoleWrapper.RunTests( + source, + GetDefaultRunSettings(), + new TestPlatformOptions() { TestCaseFilter = veryLongTestCaseFilter }, + _runEventHandler); - var expectedFilter = veryLongTestCaseFilter.Substring(0, 256) + "..."; + var expectedFilter = veryLongTestCaseFilter.Substring(0, 256) + "..."; - // Assert - StringAssert.StartsWith(this.runEventHandler.LogMessage, $"No test matches the given testcase filter `{expectedFilter}` in"); - StringAssert.EndsWith(this.runEventHandler.LogMessage, testAssemblyName); + // Assert + StringAssert.StartsWith(_runEventHandler.LogMessage, $"No test matches the given testcase filter `{expectedFilter}` in"); + StringAssert.EndsWith(_runEventHandler.LogMessage, testAssemblyName); - Assert.AreEqual(TestMessageLevel.Warning, this.runEventHandler.TestMessageLevel); - } + Assert.AreEqual(TestMessageLevel.Warning, _runEventHandler.TestMessageLevel); + } - private IList GetTestAssemblies() + private IList GetTestAssemblies() + { + var testAssemblies = new List { - var testAssemblies = new List - { - this.GetAssetFullPath("SimpleTestProject.dll"), - this.GetAssetFullPath("SimpleTestProject2.dll") - }; + GetAssetFullPath("SimpleTestProject.dll"), + GetAssetFullPath("SimpleTestProject2.dll") + }; - return testAssemblies; - } + return testAssemblies; } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTestsWithDifferentConfigurationTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTestsWithDifferentConfigurationTests.cs index d657e30556..8316809323 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTestsWithDifferentConfigurationTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTestsWithDifferentConfigurationTests.cs @@ -1,77 +1,78 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests +namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +/// +/// The Run Tests using VsTestConsoleWrapper API's +/// +[TestClass] +public class RunTestsWithDifferentConfigurationTests : AcceptanceTestBase { - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Text; - - /// - /// The Run Tests using VsTestConsoleWrapper API's - /// - [TestClass] - public class RunTestsWithDifferentConfigurationTests : AcceptanceTestBase + private const string Netcoreapp = "netcoreapp"; + private const string Message = "VsTestConsoleWrapper does not support .Net Core Runner"; + + private IVsTestConsoleWrapper _vstestConsoleWrapper; + private TempDirectory _logsDir; + private RunEventHandler _runEventHandler; + + private void Setup() { - private const string Netcoreapp = "netcoreapp"; - private const string Message = "VsTestConsoleWrapper does not support .Net Core Runner"; + _vstestConsoleWrapper = GetVsTestConsoleWrapper(out var logsDir); + _logsDir = logsDir; + _runEventHandler = new RunEventHandler(); + } - private IVsTestConsoleWrapper vstestConsoleWrapper; - private TempDirectory logsDir; - private RunEventHandler runEventHandler; + [TestCleanup] + public void Cleanup() + { + _vstestConsoleWrapper?.EndSession(); + _logsDir?.Dispose(); + } - private void Setup() - { - this.vstestConsoleWrapper = this.GetVsTestConsoleWrapper(out var logsDir); - this.logsDir = logsDir; - this.runEventHandler = new RunEventHandler(); - } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunTestsWithTestAdapterPath(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); + + var testAdapterPath = Directory.EnumerateFiles(GetTestAdapterPath(), "*.TestAdapter.dll").ToList(); + _vstestConsoleWrapper.InitializeExtensions(new List() { testAdapterPath.FirstOrDefault() }); + + _vstestConsoleWrapper.RunTests( + GetTestAssemblies(), + GetDefaultRunSettings(), + _runEventHandler); + + // Assert + Assert.AreEqual(6, _runEventHandler.TestResults.Count); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Skipped)); + } - [TestCleanup] - public void Cleanup() - { - this.vstestConsoleWrapper?.EndSession(); - this.logsDir?.Dispose(); - } - - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunTestsWithTestAdapterPath(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); - - var testAdapterPath = Directory.EnumerateFiles(this.GetTestAdapterPath(), "*.TestAdapter.dll").ToList(); - this.vstestConsoleWrapper.InitializeExtensions(new List() { testAdapterPath.FirstOrDefault() }); - - this.vstestConsoleWrapper.RunTests( - this.GetTestAssemblies(), - this.GetDefaultRunSettings(), - this.runEventHandler); - - // Assert - Assert.AreEqual(6, this.runEventHandler.TestResults.Count); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Skipped)); - } - - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunTestsWithRunSettingsWithParallel(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunTestsWithRunSettingsWithParallel(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - string runSettingsXml = $@" + string runSettingsXml = $@" {FrameworkArgValue} @@ -79,93 +80,92 @@ public void RunTestsWithRunSettingsWithParallel(RunnerInfo runnerInfo) "; - var testHostNames = new[] { "testhost", "testhost.x86" }; - int expectedNumOfProcessCreated = 2; - - this.vstestConsoleWrapper.RunTests( - this.GetTestAssemblies(), - runSettingsXml, - this.runEventHandler); - - // Assert - this.runEventHandler.EnsureSuccess(); - Assert.AreEqual(6, this.runEventHandler.TestResults.Count); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Skipped)); - AssertExpectedNumberOfHostProcesses(expectedNumOfProcessCreated, this.logsDir.Path, testHostNames); - } - - [TestMethod] - [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource] - public void RunTestsWithTestSettings(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.ExecuteNotSupportedRunnerFrameworkTests(runnerInfo.RunnerFramework, Netcoreapp, Message); - this.Setup(); - - using var tempDir = new TempDirectory(); - var testsettingsFile = Path.Combine(tempDir.Path, "tempsettings.testsettings"); - string testSettingsXml = @""; - - File.WriteAllText(testsettingsFile, testSettingsXml, Encoding.UTF8); - var runSettings = $"{FrameworkArgValue}" + testsettingsFile + ""; - var sources = new List - { - this.GetAssetFullPath("MstestV1UnitTestProject.dll") - }; - - this.vstestConsoleWrapper.RunTests( - sources, - runSettings, - this.runEventHandler); - - // Assert - Assert.AreEqual(5, this.runEventHandler.TestResults.Count); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); - Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); - Assert.AreEqual(1, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Skipped)); - } - - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunTestsWithX64Source(RunnerInfo runnerInfo) + var testHostNames = new[] { "testhost", "testhost.x86" }; + int expectedNumOfProcessCreated = 2; + + _vstestConsoleWrapper.RunTests( + GetTestAssemblies(), + runSettingsXml, + _runEventHandler); + + // Assert + _runEventHandler.EnsureSuccess(); + Assert.AreEqual(6, _runEventHandler.TestResults.Count); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Skipped)); + AssertExpectedNumberOfHostProcesses(expectedNumOfProcessCreated, _logsDir.Path, testHostNames); + } + + [TestMethod] + [TestCategory("Windows-Review")] + [NetFullTargetFrameworkDataSource] + public void RunTestsWithTestSettings(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + ExecuteNotSupportedRunnerFrameworkTests(runnerInfo.RunnerFramework, Netcoreapp, Message); + Setup(); + + using var tempDir = new TempDirectory(); + var testsettingsFile = Path.Combine(tempDir.Path, "tempsettings.testsettings"); + string testSettingsXml = @""; + + File.WriteAllText(testsettingsFile, testSettingsXml, Encoding.UTF8); + var runSettings = $"{FrameworkArgValue}" + testsettingsFile + ""; + var sources = new List { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + GetAssetFullPath("MstestV1UnitTestProject.dll") + }; + + _vstestConsoleWrapper.RunTests( + sources, + runSettings, + _runEventHandler); + + // Assert + Assert.AreEqual(5, _runEventHandler.TestResults.Count); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); + Assert.AreEqual(2, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); + Assert.AreEqual(1, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Skipped)); + } - var sources = new List - { - this.GetAssetFullPath("SimpleTestProject3.dll") - }; + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunTestsWithX64Source(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); + + var sources = new List + { + GetAssetFullPath("SimpleTestProject3.dll") + }; - int expectedNumOfProcessCreated = 1; - var testhostProcessNames = new[] { "testhost" }; + int expectedNumOfProcessCreated = 1; + var testhostProcessNames = new[] { "testhost" }; - this.vstestConsoleWrapper.RunTests( - sources, - this.GetDefaultRunSettings(), - new TestPlatformOptions() { TestCaseFilter = "FullyQualifiedName = SampleUnitTestProject3.UnitTest1.WorkingDirectoryTest" }, - this.runEventHandler); + _vstestConsoleWrapper.RunTests( + sources, + GetDefaultRunSettings(), + new TestPlatformOptions() { TestCaseFilter = "FullyQualifiedName = SampleUnitTestProject3.UnitTest1.WorkingDirectoryTest" }, + _runEventHandler); - // Assert - Assert.AreEqual(1, this.runEventHandler.TestResults.Count); - Assert.AreEqual(1, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); - AssertExpectedNumberOfHostProcesses(expectedNumOfProcessCreated, this.logsDir.Path, testhostProcessNames); - } + // Assert + Assert.AreEqual(1, _runEventHandler.TestResults.Count); + Assert.AreEqual(1, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); + AssertExpectedNumberOfHostProcesses(expectedNumOfProcessCreated, _logsDir.Path, testhostProcessNames); + } - private IList GetTestAssemblies() + private IList GetTestAssemblies() + { + var testAssemblies = new List { - var testAssemblies = new List - { - this.GetAssetFullPath("SimpleTestProject.dll"), - this.GetAssetFullPath("SimpleTestProject2.dll") - }; - - return testAssemblies; - } + GetAssetFullPath("SimpleTestProject.dll"), + GetAssetFullPath("SimpleTestProject2.dll") + }; + + return testAssemblies; } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTestsWithFilterTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTestsWithFilterTests.cs index 5da4aaf012..2da9be9081 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTestsWithFilterTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTestsWithFilterTests.cs @@ -1,83 +1,83 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests +namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests; + +using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using System.Collections.Generic; +using System.Linq; + +/// +/// The Run Tests using VsTestConsoleWrapper API's +/// +[TestClass] +public class RunTestsWithFilterTests : AcceptanceTestBase { - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System.Collections.Generic; - using System.Linq; + private IVsTestConsoleWrapper _vstestConsoleWrapper; + private RunEventHandler _runEventHandler; - /// - /// The Run Tests using VsTestConsoleWrapper API's - /// - [TestClass] - public class RunTestsWithFilterTests : AcceptanceTestBase + private void Setup() { - private IVsTestConsoleWrapper vstestConsoleWrapper; - private RunEventHandler runEventHandler; - - private void Setup() - { - this.vstestConsoleWrapper = this.GetVsTestConsoleWrapper(out _); - this.runEventHandler = new RunEventHandler(); - } + _vstestConsoleWrapper = GetVsTestConsoleWrapper(out _); + _runEventHandler = new RunEventHandler(); + } - [TestCleanup] - public void Cleanup() - { - this.vstestConsoleWrapper?.EndSession(); - } + [TestCleanup] + public void Cleanup() + { + _vstestConsoleWrapper?.EndSession(); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunTestsWithTestCaseFilter(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunTestsWithTestCaseFilter(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - var sources = new List + var sources = new List { - this.GetAssetFullPath("SimpleTestProject.dll") + GetAssetFullPath("SimpleTestProject.dll") }; - this.vstestConsoleWrapper.RunTests( - sources, - this.GetDefaultRunSettings(), - new TestPlatformOptions() { TestCaseFilter = "FullyQualifiedName=SampleUnitTestProject.UnitTest1.PassingTest" }, - this.runEventHandler); + _vstestConsoleWrapper.RunTests( + sources, + GetDefaultRunSettings(), + new TestPlatformOptions() { TestCaseFilter = "FullyQualifiedName=SampleUnitTestProject.UnitTest1.PassingTest" }, + _runEventHandler); - // Assert - Assert.AreEqual(1, this.runEventHandler.TestResults.Count); - Assert.AreEqual(TestOutcome.Passed, this.runEventHandler.TestResults.FirstOrDefault().Outcome); - } + // Assert + Assert.AreEqual(1, _runEventHandler.TestResults.Count); + Assert.AreEqual(TestOutcome.Passed, _runEventHandler.TestResults.FirstOrDefault().Outcome); + } - [TestMethod] - [NetFullTargetFrameworkDataSource] - [NetCoreTargetFrameworkDataSource] - public void RunTestsWithFastFilter(RunnerInfo runnerInfo) - { - AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - this.Setup(); + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void RunTestsWithFastFilter(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(_testEnvironment, runnerInfo); + Setup(); - var sources = new List + var sources = new List { - this.GetAssetFullPath("SimpleTestProject.dll") + GetAssetFullPath("SimpleTestProject.dll") }; - this.vstestConsoleWrapper.RunTests( - sources, - this.GetDefaultRunSettings(), - new TestPlatformOptions() { TestCaseFilter = "FullyQualifiedName=SampleUnitTestProject.UnitTest1.PassingTest | FullyQualifiedName=SampleUnitTestProject.UnitTest1.FailingTest" }, - this.runEventHandler); + _vstestConsoleWrapper.RunTests( + sources, + GetDefaultRunSettings(), + new TestPlatformOptions() { TestCaseFilter = "FullyQualifiedName=SampleUnitTestProject.UnitTest1.PassingTest | FullyQualifiedName=SampleUnitTestProject.UnitTest1.FailingTest" }, + _runEventHandler); - // Assert - Assert.AreEqual(2, this.runEventHandler.TestResults.Count); - Assert.AreEqual(1, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); - Assert.AreEqual(1, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); - } + // Assert + Assert.AreEqual(2, _runEventHandler.TestResults.Count); + Assert.AreEqual(1, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed)); + Assert.AreEqual(1, _runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed)); } -} \ No newline at end of file +} diff --git a/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/FindMethodExtensions.cs b/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/FindMethodExtensions.cs index 8455bcb5f2..ebdb4a41d2 100644 --- a/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/FindMethodExtensions.cs +++ b/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/FindMethodExtensions.cs @@ -1,101 +1,100 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities.UnitTests +namespace Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities.UnitTests; + +using CodeAnalysis; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; + +internal static class FindMethodExtensions { - using Microsoft.CodeAnalysis; + private const BindingFlags PrivateBindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Linq; - using System.Reflection; + internal static MethodInfo FindMethod(this Type type, string signature) + => type.FindMembers(MemberTypes.Method, PrivateBindingFlags, + (mbr, sig) => mbr.ToString() == (string)sig, signature).FirstOrDefault() as MethodInfo; - internal static class FindMethodExtensions + internal static IMethodSymbol FindMethod( + this INamedTypeSymbol type, + string methodName, + int methodGenericArity = -1, + params ITypeSymbol[] methodParameterTypes) { - private const BindingFlags PrivateBindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; - - internal static MethodInfo FindMethod(this Type type, string signature) - => type.FindMembers(MemberTypes.Method, PrivateBindingFlags, - (mbr, sig) => mbr.ToString() == (string)sig, signature).FirstOrDefault() as MethodInfo; + var candidates = GetCandidateMethods(type, methodName); + if (candidates.Any() && !candidates.Skip(1).Any()) + { + return candidates.Single(); + } - internal static IMethodSymbol FindMethod( - this INamedTypeSymbol type, - string methodName, - int methodGenericArity = -1, - params ITypeSymbol[] methodParameterTypes) + if (methodGenericArity != -1) { - var candidates = GetCandidateMethods(type, methodName); + candidates = candidates.Where(m => m.Arity == methodGenericArity); if (candidates.Any() && !candidates.Skip(1).Any()) { return candidates.Single(); } - - if (methodGenericArity != -1) - { - candidates = candidates.Where(m => m.Arity == methodGenericArity); - if (candidates.Any() && !candidates.Skip(1).Any()) - { - return candidates.Single(); - } - } - - if (methodParameterTypes != null && methodParameterTypes.Length >= 0) - { - candidates = candidates.Where(m => m.Parameters.Length == methodParameterTypes.Length); - if (candidates.Any() && !candidates.Skip(1).Any()) - { - return candidates.Single(); - } - - candidates = candidates.Where(m => m.Parameters.Select(p => p.Type).SequenceEqual(methodParameterTypes)); - } - - Debug.Assert(candidates.Any() && !candidates.Skip(1).Any()); - return candidates.SingleOrDefault(); } - internal static IMethodSymbol FindMethod( - this INamedTypeSymbol type, - string methodName, - int methodGenericArity, - int methodParameterCount, - Func selector) + if (methodParameterTypes != null && methodParameterTypes.Length >= 0) { - var candidates = GetCandidateMethods(type, methodName); + candidates = candidates.Where(m => m.Parameters.Length == methodParameterTypes.Length); if (candidates.Any() && !candidates.Skip(1).Any()) { return candidates.Single(); } - candidates = candidates.Where(m => m.Arity == methodGenericArity); - if (candidates.Any() && !candidates.Skip(1).Any()) - { - return candidates.Single(); - } + candidates = candidates.Where(m => m.Parameters.Select(p => p.Type).SequenceEqual(methodParameterTypes)); + } - candidates = candidates.Where(m => m.Parameters.Length == methodParameterCount); - if (candidates.Any() && !candidates.Skip(1).Any()) - { - return candidates.Single(); - } + Debug.Assert(candidates.Any() && !candidates.Skip(1).Any()); + return candidates.SingleOrDefault(); + } - candidates = candidates.Where(selector); + internal static IMethodSymbol FindMethod( + this INamedTypeSymbol type, + string methodName, + int methodGenericArity, + int methodParameterCount, + Func selector) + { + var candidates = GetCandidateMethods(type, methodName); + if (candidates.Any() && !candidates.Skip(1).Any()) + { + return candidates.Single(); + } - Debug.Assert(candidates.Any() && !candidates.Skip(1).Any()); - return candidates.SingleOrDefault(); + candidates = candidates.Where(m => m.Arity == methodGenericArity); + if (candidates.Any() && !candidates.Skip(1).Any()) + { + return candidates.Single(); } - private static IEnumerable GetCandidateMethods(INamedTypeSymbol type, string methodName) + candidates = candidates.Where(m => m.Parameters.Length == methodParameterCount); + if (candidates.Any() && !candidates.Skip(1).Any()) { - var candidates = type.GetMembers(methodName).OfType(); + return candidates.Single(); + } - if (type.BaseType != null && type.BaseType.SpecialType != SpecialType.System_Object) - { - candidates = candidates.Union(GetCandidateMethods(type.BaseType, methodName)); - } + candidates = candidates.Where(selector); + + Debug.Assert(candidates.Any() && !candidates.Skip(1).Any()); + return candidates.SingleOrDefault(); + } - return candidates; + private static IEnumerable GetCandidateMethods(INamedTypeSymbol type, string methodName) + { + var candidates = type.GetMembers(methodName).OfType(); + + if (type.BaseType != null && type.BaseType.SpecialType != SpecialType.System_Object) + { + candidates = candidates.Union(GetCandidateMethods(type.BaseType, methodName)); } + + return candidates; } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/ManagedNameParserTests.cs b/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/ManagedNameParserTests.cs index 289d9d604a..b827e6b6c9 100644 --- a/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/ManagedNameParserTests.cs +++ b/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/ManagedNameParserTests.cs @@ -1,74 +1,74 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities.UnitTests -{ - using Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities.UnitTests; + +using ManagedNameUtilities; - [TestClass] - public class ManagedNameParserTests +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class ManagedNameParserTests +{ + [TestMethod] + public void ParseTypeName() { - [TestMethod] - public void ParseTypeName() + static (string, string) Parse(string managedTypeName) { - (string, string) Parse(string managedTypeName) - { - ManagedNameParser.ParseManagedTypeName(managedTypeName, out var namespaceName, out var typeName); - return (namespaceName, typeName); - } - - Assert.AreEqual(("NS", "Class"), Parse("NS.Class")); - Assert.AreEqual(("NS.NS", "Class"), Parse("NS.NS.Class")); - Assert.AreEqual(("NS.NS", "Class`2"), Parse("NS.NS.Class`2")); - Assert.AreEqual(("NS.NS", "ClassA`2+ClassInner"), Parse("NS.NS.ClassA`2+ClassInner")); - Assert.AreEqual(("NS.NS", "ClassA`2+ClassInner`1"), Parse("NS.NS.ClassA`2+ClassInner`1")); - Assert.AreEqual(("", "ClassA`2+ClassInner`1"), Parse("ClassA`2+ClassInner`1")); + ManagedNameParser.ParseManagedTypeName(managedTypeName, out var namespaceName, out var typeName); + return (namespaceName, typeName); } - [TestMethod] - public void ParseMethodName() - { - (string, int, string[]) Parse(string managedMethodName) - { - ManagedNameParser.ParseManagedMethodName(managedMethodName, out var method, out var arity, out var parameterTypes); - return (method, arity, parameterTypes); - } + Assert.AreEqual(("NS", "Class"), Parse("NS.Class")); + Assert.AreEqual(("NS.NS", "Class"), Parse("NS.NS.Class")); + Assert.AreEqual(("NS.NS", "Class`2"), Parse("NS.NS.Class`2")); + Assert.AreEqual(("NS.NS", "ClassA`2+ClassInner"), Parse("NS.NS.ClassA`2+ClassInner")); + Assert.AreEqual(("NS.NS", "ClassA`2+ClassInner`1"), Parse("NS.NS.ClassA`2+ClassInner`1")); + Assert.AreEqual(("", "ClassA`2+ClassInner`1"), Parse("ClassA`2+ClassInner`1")); + } - void AssertParse(string expectedMethod, int expectedArity, string[] expectedParams, string expression) - { - var (method, arity, parameters) = Parse(expression); - Assert.AreEqual(expectedMethod, method); - Assert.AreEqual(expectedArity, arity); - CollectionAssert.AreEqual(expectedParams, parameters, "parameter comparison"); - } + [TestMethod] + public void ParseMethodName() + { + (string, int, string[]) Parse(string managedMethodName) + { + ManagedNameParser.ParseManagedMethodName(managedMethodName, out var method, out var arity, out var parameterTypes); + return (method, arity, parameterTypes); + } - Assert.AreEqual(("Method", 0, null), Parse("Method")); - Assert.AreEqual(("Method", 0, null), Parse("Method()")); - Assert.AreEqual(("Method", 2, null), Parse("Method`2()")); - AssertParse("Method", 0, new string[] { "System.Int32" }, "Method(System.Int32)"); - AssertParse("Method", 0, new string[] { "TypeA", "List" }, "Method(TypeA,List)"); - AssertParse("Method", 1, new string[] { "B", "List" }, "Method`1(B,List)"); - AssertParse("Method", 0, new string[] { "B[]" }, "Method(B[])"); - AssertParse("Method", 0, new string[] { "A[,]", "B[,,][]" }, "Method(A[,],B[,,][])"); + void AssertParse(string expectedMethod, int expectedArity, string[] expectedParams, string expression) + { + var (method, arity, parameters) = Parse(expression); + Assert.AreEqual(expectedMethod, method); + Assert.AreEqual(expectedArity, arity); + CollectionAssert.AreEqual(expectedParams, parameters, "parameter comparison"); } - [TestMethod] - public void ParseInvalidMethodName() + Assert.AreEqual(("Method", 0, null), Parse("Method")); + Assert.AreEqual(("Method", 0, null), Parse("Method()")); + Assert.AreEqual(("Method", 2, null), Parse("Method`2()")); + AssertParse("Method", 0, new string[] { "System.Int32" }, "Method(System.Int32)"); + AssertParse("Method", 0, new string[] { "TypeA", "List" }, "Method(TypeA,List)"); + AssertParse("Method", 1, new string[] { "B", "List" }, "Method`1(B,List)"); + AssertParse("Method", 0, new string[] { "B[]" }, "Method(B[])"); + AssertParse("Method", 0, new string[] { "A[,]", "B[,,][]" }, "Method(A[,],B[,,][])"); + } + + [TestMethod] + public void ParseInvalidMethodName() + { + static (string, int, string[]) Parse(string methodName) { - (string, int, string[]) Parse(string methodName) - { - ManagedNameParser.ParseManagedMethodName(methodName, out var method, out var arity, out var parameterTypes); - return (method, arity, parameterTypes); - } + ManagedNameParser.ParseManagedMethodName(methodName, out var method, out var arity, out var parameterTypes); + return (method, arity, parameterTypes); + } - Assert.ThrowsException(() => Parse(" Method"), "Whitespace is not valid in a ManagedName (pos: 0)"); - Assert.ThrowsException(() => Parse("Method( List)"), "Whitespace is not valid in a ManagedName (pos: 7)"); + Assert.ThrowsException(() => Parse(" Method"), "Whitespace is not valid in a ManagedName (pos: 0)"); + Assert.ThrowsException(() => Parse("Method( List)"), "Whitespace is not valid in a ManagedName (pos: 7)"); - Assert.ThrowsException(() => Parse("Method(List)xa"), "Unexpected characters after the end of the ManagedName (pos: 7)"); + Assert.ThrowsException(() => Parse("Method(List)xa"), "Unexpected characters after the end of the ManagedName (pos: 7)"); - Assert.ThrowsException(() => Parse("Method("), "ManagedName is incomplete"); - Assert.ThrowsException(() => Parse("Method`4a"), "Method arity must be numeric"); - } + Assert.ThrowsException(() => Parse("Method("), "ManagedName is incomplete"); + Assert.ThrowsException(() => Parse("Method`4a"), "Method arity must be numeric"); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/ManagedNameRoundTripTests.cs b/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/ManagedNameRoundTripTests.cs index c6bfc854fa..22aaa977e6 100644 --- a/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/ManagedNameRoundTripTests.cs +++ b/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/ManagedNameRoundTripTests.cs @@ -1,938 +1,937 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities.UnitTests +namespace Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities.UnitTests; + +using CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using ManagedNameUtilities; +using VisualStudio.TestTools.UnitTesting; + +using System.IO; +using System.Linq; +using System.Reflection; + +[TestClass] +[DeploymentItem("TestClasses.cs")] +public partial class ManagedNameRoundTripTests { - using Microsoft.CodeAnalysis; - using Microsoft.CodeAnalysis.CSharp; - using Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using System.IO; - using System.Linq; - using System.Reflection; - - [TestClass] - [DeploymentItem("TestClasses.cs")] - public partial class ManagedNameRoundTripTests - { - private const BindingFlags PrivateBindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; - private Compilation _compilation; - - [TestInitialize] - public void Initialize() - => _compilation = CSharpCompilation.Create( - "Test.dll", - new[] { CSharpSyntaxTree.ParseText(File.ReadAllText("TestClasses.cs")) }, - new[] { MetadataReference.CreateFromFile(typeof(object).Assembly.Location) }); - - [TestMethod] - public void Simple1() - { - var outer = _compilation.GetTypeByMetadataName("TestClasses.Outer"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer).GetMethod("Method0"), - containingTypeSymbol: outer, - methodSymbol: outer.FindMethod("Method0"), - managedTypeName: "TestClasses.Outer", - managedMethodName: "Method0"); - } - - [TestMethod] - public void Simple2() - { - var outer = _compilation.GetTypeByMetadataName("TestClasses.Outer"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer).GetMethod("Method1"), - containingTypeSymbol: outer, - methodSymbol: outer.FindMethod("Method1"), - managedTypeName: "TestClasses.Outer", - managedMethodName: "Method1(System.Int32)"); - } - - [TestMethod] - public void Simple3() - { - var outer = _compilation.GetTypeByMetadataName("TestClasses.Outer"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer).GetMethod("Method2"), - containingTypeSymbol: outer, - methodSymbol: outer.FindMethod("Method2"), - managedTypeName: "TestClasses.Outer", - managedMethodName: "Method2(System.Collections.Generic.List`1)"); - } - - [TestMethod] - public void Simple4() - { - var outer = _compilation.GetTypeByMetadataName("TestClasses.Outer"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer).GetMethod("Method3"), - containingTypeSymbol: outer, - methodSymbol: outer.FindMethod("Method3"), - managedTypeName: "TestClasses.Outer", - managedMethodName: "Method3(System.String,System.Int32)"); - } - - [TestMethod] - public void Nested1() - { - var outerInner = _compilation.GetTypeByMetadataName("TestClasses.Outer+Inner"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer.Inner).GetMethod("Method0"), - containingTypeSymbol: outerInner, - methodSymbol: outerInner.FindMethod("Method0"), - managedTypeName: "TestClasses.Outer+Inner", - managedMethodName: "Method0"); - } - - [TestMethod] - public void Nested2() - { - var outerInner = _compilation.GetTypeByMetadataName("TestClasses.Outer+Inner"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer.Inner).GetMethod("Method1"), - containingTypeSymbol: outerInner, - methodSymbol: outerInner.FindMethod("Method1"), - managedTypeName: "TestClasses.Outer+Inner", - managedMethodName: "Method1(System.Int32)"); - } - - [TestMethod] - public void OpenGeneric1() - { - var outerT = _compilation.GetTypeByMetadataName("TestClasses.Outer`1"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer<>).GetMethod("Method0"), - containingTypeSymbol: outerT, - methodSymbol: outerT.FindMethod("Method0"), - managedTypeName: "TestClasses.Outer`1", - managedMethodName: "Method0"); - } - - [TestMethod] - public void OpenGeneric2() - { - var outerT = _compilation.GetTypeByMetadataName("TestClasses.Outer`1"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer<>).GetMethod("Method1"), - containingTypeSymbol: outerT, - methodSymbol: outerT.FindMethod("Method1"), - managedTypeName: "TestClasses.Outer`1", - managedMethodName: "Method1(!0)"); - } - - [TestMethod] - public void OpenGeneric3() - { - var outerT = _compilation.GetTypeByMetadataName("TestClasses.Outer`1"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer<>).GetMethod("Method2"), - containingTypeSymbol: outerT, - methodSymbol: outerT.FindMethod("Method2"), - managedTypeName: "TestClasses.Outer`1", - managedMethodName: "Method2`1(!!0[])"); - } - - [TestMethod] - public void OpenGeneric4() - { - var outerT = _compilation.GetTypeByMetadataName("TestClasses.Outer`1"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer<>).GetMethod("Method3"), - containingTypeSymbol: outerT, - methodSymbol: outerT.FindMethod("Method3"), - managedTypeName: "TestClasses.Outer`1", - managedMethodName: "Method3`1(!0,!!0)"); - } - - [TestMethod] - public void OpenGenericNested1() - { - var outerTInnterV = _compilation.GetTypeByMetadataName("TestClasses.Outer`1+Inner`1"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer<>.Inner<>).GetMethod("Method0"), - containingTypeSymbol: outerTInnterV, - methodSymbol: outerTInnterV.FindMethod("Method0"), - managedTypeName: "TestClasses.Outer`1+Inner`1", - managedMethodName: "Method0"); - } - - [TestMethod] - public void OpenGenericNested2() - { - var outerTInnterV = _compilation.GetTypeByMetadataName("TestClasses.Outer`1+Inner`1"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer<>.Inner<>).GetMethod("Method1"), - containingTypeSymbol: outerTInnterV, - methodSymbol: outerTInnterV.FindMethod("Method1"), - managedTypeName: "TestClasses.Outer`1+Inner`1", - managedMethodName: "Method1(!0)"); - } - - [TestMethod] - public void OpenGenericNested3() - { - var outerTInnterV = _compilation.GetTypeByMetadataName("TestClasses.Outer`1+Inner`1"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer<>.Inner<>).GetMethod("Method2"), - containingTypeSymbol: outerTInnterV, - methodSymbol: outerTInnterV.FindMethod("Method2"), - managedTypeName: "TestClasses.Outer`1+Inner`1", - managedMethodName: "Method2(!1)"); - } - - [TestMethod] - public void OpenGenericNested4() - { - var outerTInnterV = _compilation.GetTypeByMetadataName("TestClasses.Outer`1+Inner`1"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer<>.Inner<>).GetMethod("Method3"), - containingTypeSymbol: outerTInnterV, - methodSymbol: outerTInnterV.FindMethod("Method3"), - managedTypeName: "TestClasses.Outer`1+Inner`1", - managedMethodName: "Method3`1(!0,!!0,!1)"); - } - - [TestMethod] - public void OpenGenericNested5() - { - var outerTInnterV = _compilation.GetTypeByMetadataName("TestClasses.Outer`1+Inner`1"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer<>.Inner<>).GetMethod("Method4"), - containingTypeSymbol: outerTInnterV, - methodSymbol: outerTInnterV.FindMethod("Method4"), - managedTypeName: "TestClasses.Outer`1+Inner`1", - managedMethodName: "Method4`2(!!1,!!0)"); - } - - [TestMethod] - public void OpenGenericNested6() - { - var outerTInnerVMoreInnerI = _compilation.GetTypeByMetadataName("TestClasses.Outer`1+Inner`1+MoreInner`1"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer<>.Inner<>.MoreInner<>).GetMethod("Method0"), - containingTypeSymbol: outerTInnerVMoreInnerI, - methodSymbol: outerTInnerVMoreInnerI.FindMethod("Method0"), - managedTypeName: "TestClasses.Outer`1+Inner`1+MoreInner`1", - managedMethodName: "Method0`1(!0,!1,!2,!!0)"); - } - - [TestMethod] - public void ClosedGeneric1() - { - var @int = _compilation.GetSpecialType(SpecialType.System_Int32); - var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer).GetMethod("Method0"), - containingTypeSymbol: outerTInt, - methodSymbol: outerTInt.FindMethod("Method0"), - managedTypeName: "TestClasses.Outer`1", - managedMethodName: "Method0"); - } - - [TestMethod] - public void ClosedGeneric2() - { - var @int = _compilation.GetSpecialType(SpecialType.System_Int32); - var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer).GetMethod("Method1"), - containingTypeSymbol: outerTInt, - methodSymbol: outerTInt.FindMethod("Method1"), - managedTypeName: "TestClasses.Outer`1", - managedMethodName: "Method1(!0)"); - } - - [TestMethod] - public void ClosedGeneric3() - { - var @int = _compilation.GetSpecialType(SpecialType.System_Int32); - var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer).GetMethod("Method2"), - containingTypeSymbol: outerTInt, - methodSymbol: outerTInt.FindMethod("Method2"), - managedTypeName: "TestClasses.Outer`1", - managedMethodName: "Method2`1(!!0[])"); - } - - [TestMethod] - public void ClosedGeneric4() - { - var @int = _compilation.GetSpecialType(SpecialType.System_Int32); - var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer).GetMethod("Method3"), - containingTypeSymbol: outerTInt, - methodSymbol: outerTInt.FindMethod("Method3"), - managedTypeName: "TestClasses.Outer`1", - managedMethodName: "Method3`1(!0,!!0)"); - } - - [TestMethod] - public void ClosedGenericNested1() - { - var @int = _compilation.GetSpecialType(SpecialType.System_Int32); - var @string = _compilation.GetSpecialType(SpecialType.System_String); - var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); - var outerTIntInnerVString = outerTInt.GetTypeMembers().Single().Construct(@string); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer.Inner).GetMethod("Method0"), - containingTypeSymbol: outerTIntInnerVString, - methodSymbol: outerTIntInnerVString.FindMethod("Method0"), - managedTypeName: "TestClasses.Outer`1+Inner`1", - managedMethodName: "Method0"); - } - - [TestMethod] - public void ClosedGenericNested2() - { - var @int = _compilation.GetSpecialType(SpecialType.System_Int32); - var @string = _compilation.GetSpecialType(SpecialType.System_String); - var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); - var outerTIntInnerVString = outerTInt.GetTypeMembers().Single().Construct(@string); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer.Inner).GetMethod("Method1"), - containingTypeSymbol: outerTIntInnerVString, - methodSymbol: outerTIntInnerVString.FindMethod("Method1"), - managedTypeName: "TestClasses.Outer`1+Inner`1", - managedMethodName: "Method1(!0)"); - } - - [TestMethod] - public void ClosedGenericNested3() - { - var @int = _compilation.GetSpecialType(SpecialType.System_Int32); - var @string = _compilation.GetSpecialType(SpecialType.System_String); - var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); - var outerTIntInnerVString = outerTInt.GetTypeMembers().Single().Construct(@string); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer.Inner).GetMethod("Method2"), - containingTypeSymbol: outerTIntInnerVString, - methodSymbol: outerTIntInnerVString.FindMethod("Method2"), - managedTypeName: "TestClasses.Outer`1+Inner`1", - managedMethodName: "Method2(!1)"); - } - - [TestMethod] - public void ClosedGenericNested4() - { - var @int = _compilation.GetSpecialType(SpecialType.System_Int32); - var @string = _compilation.GetSpecialType(SpecialType.System_String); - var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); - var outerTIntInnerVString = outerTInt.GetTypeMembers().Single().Construct(@string); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer.Inner).GetMethod("Method3"), - containingTypeSymbol: outerTIntInnerVString, - methodSymbol: outerTIntInnerVString.FindMethod("Method3"), - managedTypeName: "TestClasses.Outer`1+Inner`1", - managedMethodName: "Method3`1(!0,!!0,!1)"); - } - - [TestMethod] - public void ClosedGenericNested5() - { - var @int = _compilation.GetSpecialType(SpecialType.System_Int32); - var @string = _compilation.GetSpecialType(SpecialType.System_String); - var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); - var outerTIntInnerVString = outerTInt.GetTypeMembers().Single().Construct(@string); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer.Inner).GetMethod("Method4"), - containingTypeSymbol: outerTIntInnerVString, - methodSymbol: outerTIntInnerVString.FindMethod("Method4"), - managedTypeName: "TestClasses.Outer`1+Inner`1", - managedMethodName: "Method4`2(!!1,!!0)"); - } - - [TestMethod] - public void ClosedGenericMethod1() - { - var @int = _compilation.GetSpecialType(SpecialType.System_Int32); - var @string = _compilation.GetSpecialType(SpecialType.System_String); - var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer).GetMethod("Method3").MakeGenericMethod(typeof(string)), - containingTypeSymbol: outerTInt, - methodSymbol: outerTInt.FindMethod("Method3").Construct(@string), - managedTypeName: "TestClasses.Outer`1", - managedMethodName: "Method3`1(!0,!!0)"); - } - - [TestMethod] - public void ClosedGenericMethod2() - { - var @int = _compilation.GetSpecialType(SpecialType.System_Int32); - var outerInner = _compilation.GetTypeByMetadataName("TestClasses.Outer+Inner"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer.Inner).GetMethod("Method2").MakeGenericMethod(typeof(int)), - containingTypeSymbol: outerInner, - methodSymbol: outerInner.FindMethod("Method2").Construct(@int), - managedTypeName: "TestClasses.Outer+Inner", - managedMethodName: "Method2`1(System.Int32)"); - } - - [TestMethod] - public void ClosedGenericMethod3() - { - var @int = _compilation.GetSpecialType(SpecialType.System_Int32); - var @float = _compilation.GetSpecialType(SpecialType.System_Single); - var @string = _compilation.GetSpecialType(SpecialType.System_String); - var outerInner = _compilation.GetTypeByMetadataName("TestClasses.Outer+Inner"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Outer.Inner).GetMethod("Method3").MakeGenericMethod(typeof(float), typeof(string)), - containingTypeSymbol: outerInner, - methodSymbol: outerInner.FindMethod("Method3").Construct(@float, @string), - managedTypeName: "TestClasses.Outer+Inner", - managedMethodName: "Method3`2(System.Int32)"); - } - - [TestMethod] - public void ExplicitInterfaceImplementation1() - { - var impl = _compilation.GetTypeByMetadataName("TestClasses.Impl"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Impl).GetMethod("TestClasses.IImplementation.ImplMethod0", PrivateBindingFlags), - containingTypeSymbol: impl, - methodSymbol: impl.FindMethod("TestClasses.IImplementation.ImplMethod0"), - managedTypeName: "TestClasses.Impl", - managedMethodName: "TestClasses.IImplementation.ImplMethod0"); - } - - [TestMethod] - public void ExplicitInterfaceImplementation2() - { - var impl = _compilation.GetTypeByMetadataName("TestClasses.Impl"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Impl).GetMethod("TestClasses.IImplementation.ImplMethod1", PrivateBindingFlags), - containingTypeSymbol: impl, - methodSymbol: impl.FindMethod("TestClasses.IImplementation.ImplMethod1"), - managedTypeName: "TestClasses.Impl", - managedMethodName: "TestClasses.IImplementation.ImplMethod1(System.Int32)"); - } - - [TestMethod] - public void GenericExplicitInterfaceImplementation1() - { - var implT = _compilation.GetTypeByMetadataName("TestClasses.Impl`1"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Impl<>).GetMethod("TestClasses.IImplementation.ImplMethod0", PrivateBindingFlags), - containingTypeSymbol: implT, - methodSymbol: implT.FindMethod("TestClasses.IImplementation.ImplMethod0"), - managedTypeName: "TestClasses.Impl`1", - managedMethodName: "'TestClasses.IImplementation.ImplMethod0'"); - } - - [TestMethod] - public void GenericExplicitInterfaceImplementation2() - { - var implT = _compilation.GetTypeByMetadataName("TestClasses.Impl`1"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Impl<>).GetMethod("TestClasses.IImplementation.ImplMethod1", PrivateBindingFlags), - containingTypeSymbol: implT, - methodSymbol: implT.FindMethod("TestClasses.IImplementation.ImplMethod1"), - managedTypeName: "TestClasses.Impl`1", - managedMethodName: "'TestClasses.IImplementation.ImplMethod1'(!0)"); - } - - [TestMethod] - public void GenericExplicitInterfaceImplementation3() - { - var implT = _compilation.GetTypeByMetadataName("TestClasses.Impl`1"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Impl<>).GetMethod("TestClasses.IImplementation.ImplMethod2", PrivateBindingFlags), - containingTypeSymbol: implT, - methodSymbol: implT.FindMethod("TestClasses.IImplementation.ImplMethod2"), - managedTypeName: "TestClasses.Impl`1", - managedMethodName: "'TestClasses.IImplementation.ImplMethod2'`1(!0,!!0,System.String)"); - } - - [TestMethod] - public void Inheritance1() - { - var outerPrime = _compilation.GetTypeByMetadataName("TestClasses.OuterPrime"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.OuterPrime).GetMethod("Method3"), - containingTypeSymbol: outerPrime, - methodSymbol: outerPrime.FindMethod("Method3"), - managedTypeName: "TestClasses.OuterPrime", - managedMethodName: "Method3(System.String,System.Int32)"); - } - - [TestMethod] - public void Inheritance2() - { - var outerPrimeZ = _compilation.GetTypeByMetadataName("TestClasses.OuterPrime`1"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.OuterPrime<>).GetMethod("Method3"), - containingTypeSymbol: outerPrimeZ, - methodSymbol: outerPrimeZ.FindMethod("Method3"), - managedTypeName: "TestClasses.OuterPrime`1", - managedMethodName: "Method3`1(!0,!!0)"); - } - - [TestMethod] - public void Inheritance3() - { - var outerPrimeYZ = _compilation.GetTypeByMetadataName("TestClasses.OuterPrime`2"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.OuterPrime<,>).GetMethod("Method3"), - containingTypeSymbol: outerPrimeYZ, - methodSymbol: outerPrimeYZ.FindMethod("Method3"), - managedTypeName: "TestClasses.OuterPrime`2", - managedMethodName: "Method3`1(!1,!!0)"); - } - - [TestMethod] - public void Inheritance4() - { - var outerString = _compilation.GetTypeByMetadataName("TestClasses.OuterString"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.OuterString).GetMethod("Method3"), - containingTypeSymbol: outerString, - methodSymbol: outerString.FindMethod("Method3"), - managedTypeName: "TestClasses.OuterString", - managedMethodName: "Method3`1(System.String,!!0)"); - } - - [TestMethod] - public void Overloads1() - { - var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0()"), - containingTypeSymbol: overloads, - methodSymbol: overloads.FindMethod("Overload0", 0), - managedTypeName: "TestClasses.Overloads", - managedMethodName: "Overload0"); - } - - [TestMethod] - public void Overloads2() - { - var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); - var @int = _compilation.GetSpecialType(SpecialType.System_Int32); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0(Int32)"), - containingTypeSymbol: overloads, - methodSymbol: overloads.FindMethod("Overload0", 0, @int), - managedTypeName: "TestClasses.Overloads", - managedMethodName: "Overload0(System.Int32)"); - } - - [TestMethod] - public void Overloads3() - { - var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); - var @int = _compilation.GetSpecialType(SpecialType.System_Int32); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0(Int32, TestClasses.Overloads)"), - containingTypeSymbol: overloads, - methodSymbol: overloads.FindMethod("Overload0", 0, @int, overloads), - managedTypeName: "TestClasses.Overloads", - managedMethodName: "Overload0(System.Int32,TestClasses.Overloads)"); - } - - [TestMethod] - public void Overloads4() - { - var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); - var @int = _compilation.GetSpecialType(SpecialType.System_Int32); - var intptr = _compilation.CreatePointerTypeSymbol(@int); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0(Int32*)"), - containingTypeSymbol: overloads, - methodSymbol: overloads.FindMethod("Overload0", 0, intptr), - managedTypeName: "TestClasses.Overloads", - managedMethodName: "Overload0(System.Int32*)"); - } - - [TestMethod] - public void Overloads5() - { - var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); - var dynamic = _compilation.DynamicType; - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0(System.Object)"), - containingTypeSymbol: overloads, - methodSymbol: overloads.FindMethod("Overload0", 0, dynamic), - managedTypeName: "TestClasses.Overloads", - managedMethodName: "Overload0(System.Object)"); - } - - [TestMethod] - public void Overloads6() - { - var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U](U)"), - containingTypeSymbol: overloads, - methodSymbol: overloads.FindMethod("Overload0", 1, 1, m => m.Parameters.Single().Type == m.TypeParameters.Single()), - managedTypeName: "TestClasses.Overloads", - managedMethodName: "Overload0`1(!!0)"); - } - - [TestMethod] - public void Overloads7() - { - var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U]()"), - containingTypeSymbol: overloads, - methodSymbol: overloads.FindMethod("Overload0", 1), - managedTypeName: "TestClasses.Overloads", - managedMethodName: "Overload0`1"); - } - - [TestMethod] - public void Overloads8() - { - var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U,T]()"), - containingTypeSymbol: overloads, - methodSymbol: overloads.FindMethod("Overload0", 2), - managedTypeName: "TestClasses.Overloads", - managedMethodName: "Overload0`2"); - } - - [TestMethod] - public void Overloads9() - { - var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U](U[])"), - containingTypeSymbol: overloads, - methodSymbol: overloads.FindMethod("Overload0", 1, 1, - m => m.Parameters.Single().Type is IArrayTypeSymbol arrayType && - arrayType.Rank == 1 && - arrayType.ElementType == m.TypeParameters.Single()), - managedTypeName: "TestClasses.Overloads", - managedMethodName: "Overload0`1(!!0[])"); - } - - [TestMethod] - public void Overloads10() - { - var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U](U[][])"), - containingTypeSymbol: overloads, - methodSymbol: overloads.FindMethod("Overload0", 1, 1, - m => m.Parameters.Single().Type is IArrayTypeSymbol arrayType && - arrayType.Rank == 1 && - arrayType.ElementType is IArrayTypeSymbol innerArrayType && - innerArrayType.Rank == 1 && - innerArrayType.ElementType == m.TypeParameters.Single()), - managedTypeName: "TestClasses.Overloads", - managedMethodName: "Overload0`1(!!0[][])"); - } - - [TestMethod] - public void Overloads11() - { - var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U](U[,])"), - containingTypeSymbol: overloads, - methodSymbol: overloads.FindMethod("Overload0", 1, 1, - m => m.Parameters.Single().Type is IArrayTypeSymbol arrayType && - arrayType.Rank == 2 && - arrayType.ElementType == m.TypeParameters.Single()), - managedTypeName: "TestClasses.Overloads", - managedMethodName: "Overload0`1(!!0[,])"); - } - - [TestMethod] - public void Overloads12() - { - var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U](U[,,])"), - containingTypeSymbol: overloads, - methodSymbol: overloads.FindMethod("Overload0", 1, 1, - m => m.Parameters.Single().Type is IArrayTypeSymbol arrayType && - arrayType.Rank == 3 && - arrayType.ElementType == m.TypeParameters.Single()), - managedTypeName: "TestClasses.Overloads", - managedMethodName: "Overload0`1(!!0[,,])"); - } - - [TestMethod] - public void Overloads13() - { - var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); - var @int = _compilation.GetSpecialType(SpecialType.System_Int32); - var listInt = _compilation.GetTypeByMetadataName("System.Collections.Generic.List`1").Construct(@int); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U](System.Collections.Generic.List`1[System.Int32])"), - containingTypeSymbol: overloads, - methodSymbol: overloads.FindMethod("Overload0", 1, listInt), - managedTypeName: "TestClasses.Overloads", - managedMethodName: "Overload0`1(System.Collections.Generic.List`1)"); - } - - [TestMethod] - public void Overloads14() - { - var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); - var list = _compilation.GetTypeByMetadataName("System.Collections.Generic.List`1"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U](System.Collections.Generic.List`1[U])"), - containingTypeSymbol: overloads, - methodSymbol: overloads.FindMethod("Overload0", 1, 1, - m => - m.Parameters.Single().Type is INamedTypeSymbol p && - p.OriginalDefinition == list && - p.TypeArguments.Single() == m.TypeParameters.Single()), - managedTypeName: "TestClasses.Overloads", - managedMethodName: "Overload0`1(System.Collections.Generic.List`1)"); - } - - [TestMethod] - public void Overloads15() - { - var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); - var tuple2 = _compilation.GetTypeByMetadataName("System.Tuple`2"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U,V](System.Tuple`2[U,V], System.Tuple`2[V,U])"), - containingTypeSymbol: overloads, - methodSymbol: overloads.FindMethod("Overload0", 2, 2, - m => - m.Parameters.First() is INamedTypeSymbol p1 && - p1.OriginalDefinition == tuple2 && - p1.TypeArguments.SequenceEqual(m.TypeParameters) && - m.Parameters.Last() is INamedTypeSymbol p2 && - p2.OriginalDefinition == tuple2 && - p2.TypeArguments.SequenceEqual(m.TypeParameters.Reverse())), - managedTypeName: "TestClasses.Overloads", - managedMethodName: "Overload0`2(System.Tuple`2,System.Tuple`2)"); - } - - [TestMethod] - public void Overloads16() - { - var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); - var tuple1 = _compilation.GetTypeByMetadataName("System.Tuple`1"); - var tuple2 = _compilation.GetTypeByMetadataName("System.Tuple`2"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0(System.Tuple`1[System.Tuple`2[System.String[,],System.Int32]])"), - containingTypeSymbol: overloads, - methodSymbol: overloads.FindMethod("Overload0", 0, 1, - m => - m.Parameters.Single().Type is INamedTypeSymbol p && - p.OriginalDefinition == tuple1 && - p.TypeArguments.Single() is INamedTypeSymbol t && - t.OriginalDefinition == tuple2), - managedTypeName: "TestClasses.Overloads", - managedMethodName: "Overload0(System.Tuple`1>)"); - } - - [TestMethod] - public void Overloads17() - { - var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); - var tuple1 = _compilation.GetTypeByMetadataName("System.Tuple`1"); - var tuple2 = _compilation.GetTypeByMetadataName("System.Tuple`2"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0(System.Tuple`2[System.Tuple`1[System.String],System.Tuple`1[System.Int32]])"), - containingTypeSymbol: overloads, - methodSymbol: overloads.FindMethod("Overload0", 0, 1, - m => - m.Parameters.Single().Type is INamedTypeSymbol p && - p.OriginalDefinition == tuple2 && - p.TypeArguments.All(t => t.OriginalDefinition == tuple1)), - managedTypeName: "TestClasses.Overloads", - managedMethodName: "Overload0(System.Tuple`2,System.Tuple`1>)"); - } - - [TestMethod] - public void Overloads18() - { - var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); - var tuple1 = _compilation.GetTypeByMetadataName("System.Tuple`1"); - - VerifyRoundTrip( - methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U](System.Tuple`1[System.Tuple`1[TestClasses.Outer`1+Inner`1[U,U]]])"), - containingTypeSymbol: overloads, - methodSymbol: overloads.FindMethod("Overload0", 1, 1, - m => - m.Parameters.Single().Type is INamedTypeSymbol p && - p.OriginalDefinition == tuple1 && - p.TypeArguments.Single() is INamedTypeSymbol t && - t.OriginalDefinition == tuple1), - managedTypeName: "TestClasses.Overloads", - managedMethodName: "Overload0`1(System.Tuple`1>>)"); - } - - #region Helpers - private void VerifyRoundTrip( - MethodInfo methodInfo, - INamedTypeSymbol containingTypeSymbol, - IMethodSymbol methodSymbol, - string managedTypeName, - string managedMethodName) - { - VerifyRoundTripFromMethodInfo(methodInfo, managedTypeName, managedMethodName); - VerifyRoundTripFromName(managedTypeName, managedMethodName, methodInfo); - // VerifyRoundTripFromMethodSymbol(containingTypeSymbol, methodSymbol, managedTypeName, managedMethodName); - // VerifyRoundTripFromName(managedTypeName, managedMethodName, containingTypeSymbol, methodSymbol); - } - - private void VerifyRoundTripFromMethodInfo( - MethodInfo methodInfo, - string expectedManagedTypeName, - string expectedManagedMethodName) - { - // Generate the fqn for the Reflection MethodInfo - ManagedNameHelper.GetManagedName(methodInfo, out var managedTypeName, out var managedMethodName, out var hierarchyValues); - - Assert.AreEqual(expectedManagedTypeName, managedTypeName); - Assert.AreEqual(expectedManagedMethodName, managedMethodName); - - // Lookup the Reflection MethodInfo using fullTypeName and fullMethodName - var roundTrippedMethodInfo = ManagedNameHelper.GetMethod( - Assembly.GetExecutingAssembly(), - managedTypeName, - managedMethodName); - - Assert.AreEqual(methodInfo.MetadataToken, roundTrippedMethodInfo.MetadataToken); - } - - private void VerifyRoundTripFromName( - string managedTypeName, - string managedMethodName, - MethodInfo expectedMethodInfo) - { - // Lookup the Reflection MethodInfo using fullTypeName and fullMethodName - var methodInfo = ManagedNameHelper.GetMethod( - Assembly.GetExecutingAssembly(), - managedTypeName, - managedMethodName); - - Assert.AreEqual(expectedMethodInfo.MetadataToken, methodInfo.MetadataToken); - - // Generate the fqn for the Reflection MethodInfo - ManagedNameHelper.GetManagedName( - methodInfo, - out var roundTrippedFullTypeName, - out var roundTrippedFullMethodName); - - Assert.AreEqual(managedTypeName, roundTrippedFullTypeName); - Assert.AreEqual(managedMethodName, roundTrippedFullMethodName); - } - - // private void VerifyRoundTripFromMethodSymbol( - // INamedTypeSymbol containingTypeSymbol, - // IMethodSymbol methodSymbol, - // string expectedFullTypeName, - // string expectedFullMethodName) - // { - // // Generate the fqn for the Roslyn IMethodSymbol - // FullyQualifiedNameHelper.GetFullyQualifiedName( - // containingTypeSymbol, - // methodSymbol, - // out var fullTypeName, - // out var fullMethodName); - - // Assert.AreEqual(expectedFullTypeName, fullTypeName); - // Assert.AreEqual(expectedFullMethodName, fullMethodName); - - // // Lookup the Roslyn ITypeSymbol and IMethodSymbol using fullTypeName and fullMethodName - // var roundTrippedContainingTypeSymbol = _compilation.GetTypeByMetadataName(fullTypeName); - - // Assert.AreEqual(containingTypeSymbol.OriginalDefinition, roundTrippedContainingTypeSymbol.OriginalDefinition); - - // var roundTrippedMethodSymbol = FullyQualifiedNameHelper.GetMethodFromFullyQualifiedName( - // _compilation, - // fullTypeName, - // fullMethodName); - - // Assert.AreEqual(methodSymbol.OriginalDefinition, roundTrippedMethodSymbol.OriginalDefinition); - // } - - // private void VerifyRoundTripFromName( - // string fullTypeName, - // string fullMethodName, - // INamedTypeSymbol expectedContainingTypeSymbol, - // IMethodSymbol expectedMethodSymbol) - // { - // // Lookup the Roslyn ITypeSymbol and IMethodSymbol using fullTypeName and fullMethodName - // var containingTypeSymbol = _compilation.GetTypeByMetadataName(fullTypeName); - // - // Assert.AreEqual(expectedContainingTypeSymbol.OriginalDefinition, containingTypeSymbol.OriginalDefinition); - // - // var methodSymbol = FullyQualifiedNameHelper.GetMethodFromFullyQualifiedName( - // _compilation, - // fullTypeName, - // fullMethodName); - // - // Assert.AreEqual(expectedMethodSymbol.OriginalDefinition, methodSymbol.OriginalDefinition); - // - // // Generate the fqn for the Roslyn IMethodSymbol - // FullyQualifiedNameHelper.GetFullyQualifiedName( - // containingTypeSymbol, - // methodSymbol, - // out var roundTrippedFullTypeName, - // out var roundTrippedFullMethodName); - // - // Assert.AreEqual(fullTypeName, roundTrippedFullTypeName); - // Assert.AreEqual(fullMethodName, roundTrippedFullMethodName); - // } - #endregion - } -} + private const BindingFlags PrivateBindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; + private Compilation _compilation; + + [TestInitialize] + public void Initialize() + => _compilation = CSharpCompilation.Create( + "Test.dll", + new[] { CSharpSyntaxTree.ParseText(File.ReadAllText("TestClasses.cs")) }, + new[] { MetadataReference.CreateFromFile(typeof(object).Assembly.Location) }); + + [TestMethod] + public void Simple1() + { + var outer = _compilation.GetTypeByMetadataName("TestClasses.Outer"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer).GetMethod("Method0"), + containingTypeSymbol: outer, + methodSymbol: outer.FindMethod("Method0"), + managedTypeName: "TestClasses.Outer", + managedMethodName: "Method0"); + } + + [TestMethod] + public void Simple2() + { + var outer = _compilation.GetTypeByMetadataName("TestClasses.Outer"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer).GetMethod("Method1"), + containingTypeSymbol: outer, + methodSymbol: outer.FindMethod("Method1"), + managedTypeName: "TestClasses.Outer", + managedMethodName: "Method1(System.Int32)"); + } + + [TestMethod] + public void Simple3() + { + var outer = _compilation.GetTypeByMetadataName("TestClasses.Outer"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer).GetMethod("Method2"), + containingTypeSymbol: outer, + methodSymbol: outer.FindMethod("Method2"), + managedTypeName: "TestClasses.Outer", + managedMethodName: "Method2(System.Collections.Generic.List`1)"); + } + + [TestMethod] + public void Simple4() + { + var outer = _compilation.GetTypeByMetadataName("TestClasses.Outer"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer).GetMethod("Method3"), + containingTypeSymbol: outer, + methodSymbol: outer.FindMethod("Method3"), + managedTypeName: "TestClasses.Outer", + managedMethodName: "Method3(System.String,System.Int32)"); + } + + [TestMethod] + public void Nested1() + { + var outerInner = _compilation.GetTypeByMetadataName("TestClasses.Outer+Inner"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer.Inner).GetMethod("Method0"), + containingTypeSymbol: outerInner, + methodSymbol: outerInner.FindMethod("Method0"), + managedTypeName: "TestClasses.Outer+Inner", + managedMethodName: "Method0"); + } + + [TestMethod] + public void Nested2() + { + var outerInner = _compilation.GetTypeByMetadataName("TestClasses.Outer+Inner"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer.Inner).GetMethod("Method1"), + containingTypeSymbol: outerInner, + methodSymbol: outerInner.FindMethod("Method1"), + managedTypeName: "TestClasses.Outer+Inner", + managedMethodName: "Method1(System.Int32)"); + } + + [TestMethod] + public void OpenGeneric1() + { + var outerT = _compilation.GetTypeByMetadataName("TestClasses.Outer`1"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer<>).GetMethod("Method0"), + containingTypeSymbol: outerT, + methodSymbol: outerT.FindMethod("Method0"), + managedTypeName: "TestClasses.Outer`1", + managedMethodName: "Method0"); + } + + [TestMethod] + public void OpenGeneric2() + { + var outerT = _compilation.GetTypeByMetadataName("TestClasses.Outer`1"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer<>).GetMethod("Method1"), + containingTypeSymbol: outerT, + methodSymbol: outerT.FindMethod("Method1"), + managedTypeName: "TestClasses.Outer`1", + managedMethodName: "Method1(!0)"); + } + + [TestMethod] + public void OpenGeneric3() + { + var outerT = _compilation.GetTypeByMetadataName("TestClasses.Outer`1"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer<>).GetMethod("Method2"), + containingTypeSymbol: outerT, + methodSymbol: outerT.FindMethod("Method2"), + managedTypeName: "TestClasses.Outer`1", + managedMethodName: "Method2`1(!!0[])"); + } + + [TestMethod] + public void OpenGeneric4() + { + var outerT = _compilation.GetTypeByMetadataName("TestClasses.Outer`1"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer<>).GetMethod("Method3"), + containingTypeSymbol: outerT, + methodSymbol: outerT.FindMethod("Method3"), + managedTypeName: "TestClasses.Outer`1", + managedMethodName: "Method3`1(!0,!!0)"); + } + + [TestMethod] + public void OpenGenericNested1() + { + var outerTInnterV = _compilation.GetTypeByMetadataName("TestClasses.Outer`1+Inner`1"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer<>.Inner<>).GetMethod("Method0"), + containingTypeSymbol: outerTInnterV, + methodSymbol: outerTInnterV.FindMethod("Method0"), + managedTypeName: "TestClasses.Outer`1+Inner`1", + managedMethodName: "Method0"); + } + + [TestMethod] + public void OpenGenericNested2() + { + var outerTInnterV = _compilation.GetTypeByMetadataName("TestClasses.Outer`1+Inner`1"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer<>.Inner<>).GetMethod("Method1"), + containingTypeSymbol: outerTInnterV, + methodSymbol: outerTInnterV.FindMethod("Method1"), + managedTypeName: "TestClasses.Outer`1+Inner`1", + managedMethodName: "Method1(!0)"); + } + + [TestMethod] + public void OpenGenericNested3() + { + var outerTInnterV = _compilation.GetTypeByMetadataName("TestClasses.Outer`1+Inner`1"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer<>.Inner<>).GetMethod("Method2"), + containingTypeSymbol: outerTInnterV, + methodSymbol: outerTInnterV.FindMethod("Method2"), + managedTypeName: "TestClasses.Outer`1+Inner`1", + managedMethodName: "Method2(!1)"); + } + + [TestMethod] + public void OpenGenericNested4() + { + var outerTInnterV = _compilation.GetTypeByMetadataName("TestClasses.Outer`1+Inner`1"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer<>.Inner<>).GetMethod("Method3"), + containingTypeSymbol: outerTInnterV, + methodSymbol: outerTInnterV.FindMethod("Method3"), + managedTypeName: "TestClasses.Outer`1+Inner`1", + managedMethodName: "Method3`1(!0,!!0,!1)"); + } + + [TestMethod] + public void OpenGenericNested5() + { + var outerTInnterV = _compilation.GetTypeByMetadataName("TestClasses.Outer`1+Inner`1"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer<>.Inner<>).GetMethod("Method4"), + containingTypeSymbol: outerTInnterV, + methodSymbol: outerTInnterV.FindMethod("Method4"), + managedTypeName: "TestClasses.Outer`1+Inner`1", + managedMethodName: "Method4`2(!!1,!!0)"); + } + + [TestMethod] + public void OpenGenericNested6() + { + var outerTInnerVMoreInnerI = _compilation.GetTypeByMetadataName("TestClasses.Outer`1+Inner`1+MoreInner`1"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer<>.Inner<>.MoreInner<>).GetMethod("Method0"), + containingTypeSymbol: outerTInnerVMoreInnerI, + methodSymbol: outerTInnerVMoreInnerI.FindMethod("Method0"), + managedTypeName: "TestClasses.Outer`1+Inner`1+MoreInner`1", + managedMethodName: "Method0`1(!0,!1,!2,!!0)"); + } + + [TestMethod] + public void ClosedGeneric1() + { + var @int = _compilation.GetSpecialType(SpecialType.System_Int32); + var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer).GetMethod("Method0"), + containingTypeSymbol: outerTInt, + methodSymbol: outerTInt.FindMethod("Method0"), + managedTypeName: "TestClasses.Outer`1", + managedMethodName: "Method0"); + } + + [TestMethod] + public void ClosedGeneric2() + { + var @int = _compilation.GetSpecialType(SpecialType.System_Int32); + var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer).GetMethod("Method1"), + containingTypeSymbol: outerTInt, + methodSymbol: outerTInt.FindMethod("Method1"), + managedTypeName: "TestClasses.Outer`1", + managedMethodName: "Method1(!0)"); + } + + [TestMethod] + public void ClosedGeneric3() + { + var @int = _compilation.GetSpecialType(SpecialType.System_Int32); + var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer).GetMethod("Method2"), + containingTypeSymbol: outerTInt, + methodSymbol: outerTInt.FindMethod("Method2"), + managedTypeName: "TestClasses.Outer`1", + managedMethodName: "Method2`1(!!0[])"); + } + + [TestMethod] + public void ClosedGeneric4() + { + var @int = _compilation.GetSpecialType(SpecialType.System_Int32); + var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer).GetMethod("Method3"), + containingTypeSymbol: outerTInt, + methodSymbol: outerTInt.FindMethod("Method3"), + managedTypeName: "TestClasses.Outer`1", + managedMethodName: "Method3`1(!0,!!0)"); + } + + [TestMethod] + public void ClosedGenericNested1() + { + var @int = _compilation.GetSpecialType(SpecialType.System_Int32); + var @string = _compilation.GetSpecialType(SpecialType.System_String); + var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); + var outerTIntInnerVString = outerTInt.GetTypeMembers().Single().Construct(@string); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer.Inner).GetMethod("Method0"), + containingTypeSymbol: outerTIntInnerVString, + methodSymbol: outerTIntInnerVString.FindMethod("Method0"), + managedTypeName: "TestClasses.Outer`1+Inner`1", + managedMethodName: "Method0"); + } + + [TestMethod] + public void ClosedGenericNested2() + { + var @int = _compilation.GetSpecialType(SpecialType.System_Int32); + var @string = _compilation.GetSpecialType(SpecialType.System_String); + var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); + var outerTIntInnerVString = outerTInt.GetTypeMembers().Single().Construct(@string); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer.Inner).GetMethod("Method1"), + containingTypeSymbol: outerTIntInnerVString, + methodSymbol: outerTIntInnerVString.FindMethod("Method1"), + managedTypeName: "TestClasses.Outer`1+Inner`1", + managedMethodName: "Method1(!0)"); + } + + [TestMethod] + public void ClosedGenericNested3() + { + var @int = _compilation.GetSpecialType(SpecialType.System_Int32); + var @string = _compilation.GetSpecialType(SpecialType.System_String); + var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); + var outerTIntInnerVString = outerTInt.GetTypeMembers().Single().Construct(@string); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer.Inner).GetMethod("Method2"), + containingTypeSymbol: outerTIntInnerVString, + methodSymbol: outerTIntInnerVString.FindMethod("Method2"), + managedTypeName: "TestClasses.Outer`1+Inner`1", + managedMethodName: "Method2(!1)"); + } + + [TestMethod] + public void ClosedGenericNested4() + { + var @int = _compilation.GetSpecialType(SpecialType.System_Int32); + var @string = _compilation.GetSpecialType(SpecialType.System_String); + var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); + var outerTIntInnerVString = outerTInt.GetTypeMembers().Single().Construct(@string); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer.Inner).GetMethod("Method3"), + containingTypeSymbol: outerTIntInnerVString, + methodSymbol: outerTIntInnerVString.FindMethod("Method3"), + managedTypeName: "TestClasses.Outer`1+Inner`1", + managedMethodName: "Method3`1(!0,!!0,!1)"); + } + + [TestMethod] + public void ClosedGenericNested5() + { + var @int = _compilation.GetSpecialType(SpecialType.System_Int32); + var @string = _compilation.GetSpecialType(SpecialType.System_String); + var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); + var outerTIntInnerVString = outerTInt.GetTypeMembers().Single().Construct(@string); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer.Inner).GetMethod("Method4"), + containingTypeSymbol: outerTIntInnerVString, + methodSymbol: outerTIntInnerVString.FindMethod("Method4"), + managedTypeName: "TestClasses.Outer`1+Inner`1", + managedMethodName: "Method4`2(!!1,!!0)"); + } + + [TestMethod] + public void ClosedGenericMethod1() + { + var @int = _compilation.GetSpecialType(SpecialType.System_Int32); + var @string = _compilation.GetSpecialType(SpecialType.System_String); + var outerTInt = _compilation.GetTypeByMetadataName("TestClasses.Outer`1").Construct(@int); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer).GetMethod("Method3").MakeGenericMethod(typeof(string)), + containingTypeSymbol: outerTInt, + methodSymbol: outerTInt.FindMethod("Method3").Construct(@string), + managedTypeName: "TestClasses.Outer`1", + managedMethodName: "Method3`1(!0,!!0)"); + } + + [TestMethod] + public void ClosedGenericMethod2() + { + var @int = _compilation.GetSpecialType(SpecialType.System_Int32); + var outerInner = _compilation.GetTypeByMetadataName("TestClasses.Outer+Inner"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer.Inner).GetMethod("Method2").MakeGenericMethod(typeof(int)), + containingTypeSymbol: outerInner, + methodSymbol: outerInner.FindMethod("Method2").Construct(@int), + managedTypeName: "TestClasses.Outer+Inner", + managedMethodName: "Method2`1(System.Int32)"); + } + + [TestMethod] + public void ClosedGenericMethod3() + { + _ = _compilation.GetSpecialType(SpecialType.System_Int32); + var @float = _compilation.GetSpecialType(SpecialType.System_Single); + var @string = _compilation.GetSpecialType(SpecialType.System_String); + var outerInner = _compilation.GetTypeByMetadataName("TestClasses.Outer+Inner"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Outer.Inner).GetMethod("Method3").MakeGenericMethod(typeof(float), typeof(string)), + containingTypeSymbol: outerInner, + methodSymbol: outerInner.FindMethod("Method3").Construct(@float, @string), + managedTypeName: "TestClasses.Outer+Inner", + managedMethodName: "Method3`2(System.Int32)"); + } + + [TestMethod] + public void ExplicitInterfaceImplementation1() + { + var impl = _compilation.GetTypeByMetadataName("TestClasses.Impl"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Impl).GetMethod("TestClasses.IImplementation.ImplMethod0", PrivateBindingFlags), + containingTypeSymbol: impl, + methodSymbol: impl.FindMethod("TestClasses.IImplementation.ImplMethod0"), + managedTypeName: "TestClasses.Impl", + managedMethodName: "TestClasses.IImplementation.ImplMethod0"); + } + + [TestMethod] + public void ExplicitInterfaceImplementation2() + { + var impl = _compilation.GetTypeByMetadataName("TestClasses.Impl"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Impl).GetMethod("TestClasses.IImplementation.ImplMethod1", PrivateBindingFlags), + containingTypeSymbol: impl, + methodSymbol: impl.FindMethod("TestClasses.IImplementation.ImplMethod1"), + managedTypeName: "TestClasses.Impl", + managedMethodName: "TestClasses.IImplementation.ImplMethod1(System.Int32)"); + } + + [TestMethod] + public void GenericExplicitInterfaceImplementation1() + { + var implT = _compilation.GetTypeByMetadataName("TestClasses.Impl`1"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Impl<>).GetMethod("TestClasses.IImplementation.ImplMethod0", PrivateBindingFlags), + containingTypeSymbol: implT, + methodSymbol: implT.FindMethod("TestClasses.IImplementation.ImplMethod0"), + managedTypeName: "TestClasses.Impl`1", + managedMethodName: "'TestClasses.IImplementation.ImplMethod0'"); + } + + [TestMethod] + public void GenericExplicitInterfaceImplementation2() + { + var implT = _compilation.GetTypeByMetadataName("TestClasses.Impl`1"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Impl<>).GetMethod("TestClasses.IImplementation.ImplMethod1", PrivateBindingFlags), + containingTypeSymbol: implT, + methodSymbol: implT.FindMethod("TestClasses.IImplementation.ImplMethod1"), + managedTypeName: "TestClasses.Impl`1", + managedMethodName: "'TestClasses.IImplementation.ImplMethod1'(!0)"); + } + + [TestMethod] + public void GenericExplicitInterfaceImplementation3() + { + var implT = _compilation.GetTypeByMetadataName("TestClasses.Impl`1"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Impl<>).GetMethod("TestClasses.IImplementation.ImplMethod2", PrivateBindingFlags), + containingTypeSymbol: implT, + methodSymbol: implT.FindMethod("TestClasses.IImplementation.ImplMethod2"), + managedTypeName: "TestClasses.Impl`1", + managedMethodName: "'TestClasses.IImplementation.ImplMethod2'`1(!0,!!0,System.String)"); + } + + [TestMethod] + public void Inheritance1() + { + var outerPrime = _compilation.GetTypeByMetadataName("TestClasses.OuterPrime"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.OuterPrime).GetMethod("Method3"), + containingTypeSymbol: outerPrime, + methodSymbol: outerPrime.FindMethod("Method3"), + managedTypeName: "TestClasses.OuterPrime", + managedMethodName: "Method3(System.String,System.Int32)"); + } + + [TestMethod] + public void Inheritance2() + { + var outerPrimeZ = _compilation.GetTypeByMetadataName("TestClasses.OuterPrime`1"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.OuterPrime<>).GetMethod("Method3"), + containingTypeSymbol: outerPrimeZ, + methodSymbol: outerPrimeZ.FindMethod("Method3"), + managedTypeName: "TestClasses.OuterPrime`1", + managedMethodName: "Method3`1(!0,!!0)"); + } + + [TestMethod] + public void Inheritance3() + { + var outerPrimeYz = _compilation.GetTypeByMetadataName("TestClasses.OuterPrime`2"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.OuterPrime<,>).GetMethod("Method3"), + containingTypeSymbol: outerPrimeYz, + methodSymbol: outerPrimeYz.FindMethod("Method3"), + managedTypeName: "TestClasses.OuterPrime`2", + managedMethodName: "Method3`1(!1,!!0)"); + } + + [TestMethod] + public void Inheritance4() + { + var outerString = _compilation.GetTypeByMetadataName("TestClasses.OuterString"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.OuterString).GetMethod("Method3"), + containingTypeSymbol: outerString, + methodSymbol: outerString.FindMethod("Method3"), + managedTypeName: "TestClasses.OuterString", + managedMethodName: "Method3`1(System.String,!!0)"); + } + + [TestMethod] + public void Overloads1() + { + var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0()"), + containingTypeSymbol: overloads, + methodSymbol: overloads.FindMethod("Overload0", 0), + managedTypeName: "TestClasses.Overloads", + managedMethodName: "Overload0"); + } + + [TestMethod] + public void Overloads2() + { + var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); + var @int = _compilation.GetSpecialType(SpecialType.System_Int32); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0(Int32)"), + containingTypeSymbol: overloads, + methodSymbol: overloads.FindMethod("Overload0", 0, @int), + managedTypeName: "TestClasses.Overloads", + managedMethodName: "Overload0(System.Int32)"); + } + + [TestMethod] + public void Overloads3() + { + var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); + var @int = _compilation.GetSpecialType(SpecialType.System_Int32); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0(Int32, TestClasses.Overloads)"), + containingTypeSymbol: overloads, + methodSymbol: overloads.FindMethod("Overload0", 0, @int, overloads), + managedTypeName: "TestClasses.Overloads", + managedMethodName: "Overload0(System.Int32,TestClasses.Overloads)"); + } + + [TestMethod] + public void Overloads4() + { + var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); + var @int = _compilation.GetSpecialType(SpecialType.System_Int32); + var intptr = _compilation.CreatePointerTypeSymbol(@int); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0(Int32*)"), + containingTypeSymbol: overloads, + methodSymbol: overloads.FindMethod("Overload0", 0, intptr), + managedTypeName: "TestClasses.Overloads", + managedMethodName: "Overload0(System.Int32*)"); + } + + [TestMethod] + public void Overloads5() + { + var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); + var dynamic = _compilation.DynamicType; + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0(System.Object)"), + containingTypeSymbol: overloads, + methodSymbol: overloads.FindMethod("Overload0", 0, dynamic), + managedTypeName: "TestClasses.Overloads", + managedMethodName: "Overload0(System.Object)"); + } + + [TestMethod] + public void Overloads6() + { + var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U](U)"), + containingTypeSymbol: overloads, + methodSymbol: overloads.FindMethod("Overload0", 1, 1, m => m.Parameters.Single().Type == m.TypeParameters.Single()), + managedTypeName: "TestClasses.Overloads", + managedMethodName: "Overload0`1(!!0)"); + } + + [TestMethod] + public void Overloads7() + { + var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U]()"), + containingTypeSymbol: overloads, + methodSymbol: overloads.FindMethod("Overload0", 1), + managedTypeName: "TestClasses.Overloads", + managedMethodName: "Overload0`1"); + } + + [TestMethod] + public void Overloads8() + { + var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U,T]()"), + containingTypeSymbol: overloads, + methodSymbol: overloads.FindMethod("Overload0", 2), + managedTypeName: "TestClasses.Overloads", + managedMethodName: "Overload0`2"); + } + + [TestMethod] + public void Overloads9() + { + var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U](U[])"), + containingTypeSymbol: overloads, + methodSymbol: overloads.FindMethod("Overload0", 1, 1, + m => m.Parameters.Single().Type is IArrayTypeSymbol arrayType && + arrayType.Rank == 1 && + arrayType.ElementType == m.TypeParameters.Single()), + managedTypeName: "TestClasses.Overloads", + managedMethodName: "Overload0`1(!!0[])"); + } + + [TestMethod] + public void Overloads10() + { + var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U](U[][])"), + containingTypeSymbol: overloads, + methodSymbol: overloads.FindMethod("Overload0", 1, 1, + m => m.Parameters.Single().Type is IArrayTypeSymbol arrayType && + arrayType.Rank == 1 && + arrayType.ElementType is IArrayTypeSymbol innerArrayType && + innerArrayType.Rank == 1 && + innerArrayType.ElementType == m.TypeParameters.Single()), + managedTypeName: "TestClasses.Overloads", + managedMethodName: "Overload0`1(!!0[][])"); + } + + [TestMethod] + public void Overloads11() + { + var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U](U[,])"), + containingTypeSymbol: overloads, + methodSymbol: overloads.FindMethod("Overload0", 1, 1, + m => m.Parameters.Single().Type is IArrayTypeSymbol arrayType && + arrayType.Rank == 2 && + arrayType.ElementType == m.TypeParameters.Single()), + managedTypeName: "TestClasses.Overloads", + managedMethodName: "Overload0`1(!!0[,])"); + } + + [TestMethod] + public void Overloads12() + { + var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U](U[,,])"), + containingTypeSymbol: overloads, + methodSymbol: overloads.FindMethod("Overload0", 1, 1, + m => m.Parameters.Single().Type is IArrayTypeSymbol arrayType && + arrayType.Rank == 3 && + arrayType.ElementType == m.TypeParameters.Single()), + managedTypeName: "TestClasses.Overloads", + managedMethodName: "Overload0`1(!!0[,,])"); + } + + [TestMethod] + public void Overloads13() + { + var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); + var @int = _compilation.GetSpecialType(SpecialType.System_Int32); + var listInt = _compilation.GetTypeByMetadataName("System.Collections.Generic.List`1").Construct(@int); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U](System.Collections.Generic.List`1[System.Int32])"), + containingTypeSymbol: overloads, + methodSymbol: overloads.FindMethod("Overload0", 1, listInt), + managedTypeName: "TestClasses.Overloads", + managedMethodName: "Overload0`1(System.Collections.Generic.List`1)"); + } + + [TestMethod] + public void Overloads14() + { + var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); + var list = _compilation.GetTypeByMetadataName("System.Collections.Generic.List`1"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U](System.Collections.Generic.List`1[U])"), + containingTypeSymbol: overloads, + methodSymbol: overloads.FindMethod("Overload0", 1, 1, + m => + m.Parameters.Single().Type is INamedTypeSymbol p && + p.OriginalDefinition == list && + p.TypeArguments.Single() == m.TypeParameters.Single()), + managedTypeName: "TestClasses.Overloads", + managedMethodName: "Overload0`1(System.Collections.Generic.List`1)"); + } + + [TestMethod] + public void Overloads15() + { + var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); + var tuple2 = _compilation.GetTypeByMetadataName("System.Tuple`2"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U,V](System.Tuple`2[U,V], System.Tuple`2[V,U])"), + containingTypeSymbol: overloads, + methodSymbol: overloads.FindMethod("Overload0", 2, 2, + m => + m.Parameters.First() is INamedTypeSymbol p1 && + p1.OriginalDefinition == tuple2 && + p1.TypeArguments.SequenceEqual(m.TypeParameters) && + m.Parameters.Last() is INamedTypeSymbol p2 && + p2.OriginalDefinition == tuple2 && + p2.TypeArguments.SequenceEqual(m.TypeParameters.Reverse())), + managedTypeName: "TestClasses.Overloads", + managedMethodName: "Overload0`2(System.Tuple`2,System.Tuple`2)"); + } + + [TestMethod] + public void Overloads16() + { + var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); + var tuple1 = _compilation.GetTypeByMetadataName("System.Tuple`1"); + var tuple2 = _compilation.GetTypeByMetadataName("System.Tuple`2"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0(System.Tuple`1[System.Tuple`2[System.String[,],System.Int32]])"), + containingTypeSymbol: overloads, + methodSymbol: overloads.FindMethod("Overload0", 0, 1, + m => + m.Parameters.Single().Type is INamedTypeSymbol p && + p.OriginalDefinition == tuple1 && + p.TypeArguments.Single() is INamedTypeSymbol t && + t.OriginalDefinition == tuple2), + managedTypeName: "TestClasses.Overloads", + managedMethodName: "Overload0(System.Tuple`1>)"); + } + + [TestMethod] + public void Overloads17() + { + var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); + var tuple1 = _compilation.GetTypeByMetadataName("System.Tuple`1"); + var tuple2 = _compilation.GetTypeByMetadataName("System.Tuple`2"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0(System.Tuple`2[System.Tuple`1[System.String],System.Tuple`1[System.Int32]])"), + containingTypeSymbol: overloads, + methodSymbol: overloads.FindMethod("Overload0", 0, 1, + m => + m.Parameters.Single().Type is INamedTypeSymbol p && + p.OriginalDefinition == tuple2 && + p.TypeArguments.All(t => t.OriginalDefinition == tuple1)), + managedTypeName: "TestClasses.Overloads", + managedMethodName: "Overload0(System.Tuple`2,System.Tuple`1>)"); + } + + [TestMethod] + public void Overloads18() + { + var overloads = _compilation.GetTypeByMetadataName("TestClasses.Overloads"); + var tuple1 = _compilation.GetTypeByMetadataName("System.Tuple`1"); + + VerifyRoundTrip( + methodInfo: typeof(TestClasses.Overloads).FindMethod("Void Overload0[U](System.Tuple`1[System.Tuple`1[TestClasses.Outer`1+Inner`1[U,U]]])"), + containingTypeSymbol: overloads, + methodSymbol: overloads.FindMethod("Overload0", 1, 1, + m => + m.Parameters.Single().Type is INamedTypeSymbol p && + p.OriginalDefinition == tuple1 && + p.TypeArguments.Single() is INamedTypeSymbol t && + t.OriginalDefinition == tuple1), + managedTypeName: "TestClasses.Overloads", + managedMethodName: "Overload0`1(System.Tuple`1>>)"); + } + + #region Helpers + private void VerifyRoundTrip( + MethodInfo methodInfo, + INamedTypeSymbol containingTypeSymbol, + IMethodSymbol methodSymbol, + string managedTypeName, + string managedMethodName) + { + VerifyRoundTripFromMethodInfo(methodInfo, managedTypeName, managedMethodName); + VerifyRoundTripFromName(managedTypeName, managedMethodName, methodInfo); + // VerifyRoundTripFromMethodSymbol(containingTypeSymbol, methodSymbol, managedTypeName, managedMethodName); + // VerifyRoundTripFromName(managedTypeName, managedMethodName, containingTypeSymbol, methodSymbol); + } + + private void VerifyRoundTripFromMethodInfo( + MethodInfo methodInfo, + string expectedManagedTypeName, + string expectedManagedMethodName) + { + // Generate the fqn for the Reflection MethodInfo + ManagedNameHelper.GetManagedName(methodInfo, out var managedTypeName, out var managedMethodName, out _); + + Assert.AreEqual(expectedManagedTypeName, managedTypeName); + Assert.AreEqual(expectedManagedMethodName, managedMethodName); + + // Lookup the Reflection MethodInfo using fullTypeName and fullMethodName + var roundTrippedMethodInfo = ManagedNameHelper.GetMethod( + Assembly.GetExecutingAssembly(), + managedTypeName, + managedMethodName); + + Assert.AreEqual(methodInfo.MetadataToken, roundTrippedMethodInfo.MetadataToken); + } + + private void VerifyRoundTripFromName( + string managedTypeName, + string managedMethodName, + MethodInfo expectedMethodInfo) + { + // Lookup the Reflection MethodInfo using fullTypeName and fullMethodName + var methodInfo = ManagedNameHelper.GetMethod( + Assembly.GetExecutingAssembly(), + managedTypeName, + managedMethodName); + + Assert.AreEqual(expectedMethodInfo.MetadataToken, methodInfo.MetadataToken); + + // Generate the fqn for the Reflection MethodInfo + ManagedNameHelper.GetManagedName( + methodInfo, + out var roundTrippedFullTypeName, + out var roundTrippedFullMethodName); + + Assert.AreEqual(managedTypeName, roundTrippedFullTypeName); + Assert.AreEqual(managedMethodName, roundTrippedFullMethodName); + } + + // private void VerifyRoundTripFromMethodSymbol( + // INamedTypeSymbol containingTypeSymbol, + // IMethodSymbol methodSymbol, + // string expectedFullTypeName, + // string expectedFullMethodName) + // { + // // Generate the fqn for the Roslyn IMethodSymbol + // FullyQualifiedNameHelper.GetFullyQualifiedName( + // containingTypeSymbol, + // methodSymbol, + // out var fullTypeName, + // out var fullMethodName); + + // Assert.AreEqual(expectedFullTypeName, fullTypeName); + // Assert.AreEqual(expectedFullMethodName, fullMethodName); + + // // Lookup the Roslyn ITypeSymbol and IMethodSymbol using fullTypeName and fullMethodName + // var roundTrippedContainingTypeSymbol = _compilation.GetTypeByMetadataName(fullTypeName); + + // Assert.AreEqual(containingTypeSymbol.OriginalDefinition, roundTrippedContainingTypeSymbol.OriginalDefinition); + + // var roundTrippedMethodSymbol = FullyQualifiedNameHelper.GetMethodFromFullyQualifiedName( + // _compilation, + // fullTypeName, + // fullMethodName); + + // Assert.AreEqual(methodSymbol.OriginalDefinition, roundTrippedMethodSymbol.OriginalDefinition); + // } + + // private void VerifyRoundTripFromName( + // string fullTypeName, + // string fullMethodName, + // INamedTypeSymbol expectedContainingTypeSymbol, + // IMethodSymbol expectedMethodSymbol) + // { + // // Lookup the Roslyn ITypeSymbol and IMethodSymbol using fullTypeName and fullMethodName + // var containingTypeSymbol = _compilation.GetTypeByMetadataName(fullTypeName); + // + // Assert.AreEqual(expectedContainingTypeSymbol.OriginalDefinition, containingTypeSymbol.OriginalDefinition); + // + // var methodSymbol = FullyQualifiedNameHelper.GetMethodFromFullyQualifiedName( + // _compilation, + // fullTypeName, + // fullMethodName); + // + // Assert.AreEqual(expectedMethodSymbol.OriginalDefinition, methodSymbol.OriginalDefinition); + // + // // Generate the fqn for the Roslyn IMethodSymbol + // FullyQualifiedNameHelper.GetFullyQualifiedName( + // containingTypeSymbol, + // methodSymbol, + // out var roundTrippedFullTypeName, + // out var roundTrippedFullMethodName); + // + // Assert.AreEqual(fullTypeName, roundTrippedFullTypeName); + // Assert.AreEqual(fullMethodName, roundTrippedFullMethodName); + // } + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/SpecialNameTests.cs b/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/SpecialNameTests.cs index 01e97719e4..0ca62c6aa7 100644 --- a/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/SpecialNameTests.cs +++ b/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/SpecialNameTests.cs @@ -1,43 +1,42 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities.UnitTests -{ - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities.UnitTests; + +using TestUtilities; +using VisualStudio.TestTools.UnitTesting; - using System.Reflection; +using System.Reflection; - [TestClass] - [TestCategory("Windows")] - [TestCategory("AcceptanceTests")] - public class SpecialNameTests +[TestClass] +[TestCategory("Windows")] +[TestCategory("AcceptanceTests")] +public class SpecialNameTests +{ + [TestMethod] + public void VerifyThatInvalidIdentifierNamesAreParsed() { - [TestMethod] - public void VerifyThatInvalidIdentifierNamesAreParsed() + var environment = new IntegrationTestEnvironment(); + var asset = environment.GetTestAsset("CILProject.dll", "net451"); + var assembly = Assembly.LoadFrom(asset); + var types = assembly.GetTypes(); + + foreach (var type in types) { - var environment = new IntegrationTestEnvironment(); - var asset = environment.GetTestAsset("CILProject.dll", "net451"); - var assembly = Assembly.LoadFrom(asset); - var types = assembly.GetTypes(); + var methods = type.GetMethods(); - foreach (var type in types) + foreach (var method in methods) { - var methods = type.GetMethods(); - - foreach (var method in methods) - { - if (method.DeclaringType != type) continue; + if (method.DeclaringType != type) continue; - ManagedNameHelper.GetManagedName(method, out var typeName, out var methodName); - var methodInfo = ManagedNameHelper.GetMethod(assembly, typeName, methodName); - ManagedNameHelper.GetManagedName(methodInfo, out var typeName2, out var methodName2); + ManagedNameHelper.GetManagedName(method, out var typeName, out var methodName); + var methodInfo = ManagedNameHelper.GetMethod(assembly, typeName, methodName); + ManagedNameHelper.GetManagedName(methodInfo, out var typeName2, out var methodName2); - Assert.IsTrue(method == methodInfo); - Assert.AreEqual(typeName, typeName2, $"Type parse roundtrip test failed: {method} ({typeName} != {typeName2})"); - Assert.AreEqual(methodName, methodName2, $"Method parse roundtrip test failed: {method} ({methodName} != {methodName2})"); - } + Assert.IsTrue(method == methodInfo); + Assert.AreEqual(typeName, typeName2, $"Type parse roundtrip test failed: {method} ({typeName} != {typeName2})"); + Assert.AreEqual(methodName, methodName2, $"Method parse roundtrip test failed: {method} ({methodName} != {methodName2})"); } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/Program.cs b/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/Program.cs index e6fb5d296f..458446f71b 100644 --- a/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/Program.cs +++ b/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/Program.cs @@ -1,12 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AdapterUtilities.UnitTests +namespace Microsoft.TestPlatform.AdapterUtilities.UnitTests; + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/TestClasses.cs b/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/TestClasses.cs index f40b044ec0..d9b0a301ea 100644 --- a/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/TestClasses.cs +++ b/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/TestClasses.cs @@ -1,102 +1,105 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestClasses -{ - using System; - using System.Collections.Generic; +namespace TestClasses; + +using System; +using System.Collections.Generic; - internal class Outer +#pragma warning disable IDE0060 // Remove unused parameter +#pragma warning disable CA1822 // Mark members as static +internal class Outer +{ + public void Method0() { } + public void Method1(int i) { } + public void Method2(List ls) { } + public void Method3(string p, int l) { } + internal class Inner { public void Method0() { } public void Method1(int i) { } - public void Method2(List ls) { } - public void Method3(string p, int l) { } - internal class Inner - { - public void Method0() { } - public void Method1(int i) { } - public void Method2(int i) { } - public void Method3(int i) { } - } + public void Method2(int i) { } + public void Method3(int i) { } } +} - internal class OuterPrime : Outer { } +internal class OuterPrime : Outer { } + +internal class Outer +{ + public void Method0() { } + public void Method1(T t) { } + public void Method2(U[] u) { } + public void Method3(T t, U u) { } - internal class Outer + internal class Inner { public void Method0() { } public void Method1(T t) { } - public void Method2(U[] u) { } - public void Method3(T t, U u) { } + public void Method2(V v) { } + public void Method3(T t, U u, V v) { } + public void Method4(X x, U u) { } + public void Method5(List x, U u) { } - internal class Inner + internal class MoreInner { - public void Method0() { } - public void Method1(T t) { } - public void Method2(V v) { } - public void Method3(T t, U u, V v) { } - public void Method4(X x, U u) { } - public void Method5(List x, U u) { } - - internal class MoreInner - { - public void Method0(T t, V v, I i, U u) { } - } + public void Method0(T t, V v, I i, U u) { } } } +} - internal class OuterPrime : Outer { } +internal class OuterPrime : Outer { } - internal class OuterPrime : Outer { } +internal class OuterPrime : Outer { } - internal class OuterString : Outer { } +internal class OuterString : Outer { } - internal interface IImplementation - { - void ImplMethod0(); - void ImplMethod1(int i); - } +internal interface IImplementation +{ + void ImplMethod0(); + void ImplMethod1(int i); +} - internal class Impl : IImplementation - { - void IImplementation.ImplMethod0() { } - void IImplementation.ImplMethod1(int i) { } - } +internal class Impl : IImplementation +{ + void IImplementation.ImplMethod0() { } + void IImplementation.ImplMethod1(int i) { } +} - internal interface IImplementation - { - void ImplMethod0(); - void ImplMethod1(T t); - void ImplMethod2(T t, U u, string s); - } +internal interface IImplementation +{ + void ImplMethod0(); + void ImplMethod1(T t); + void ImplMethod2(T t, U u, string s); +} - internal class Impl : IImplementation - { - void IImplementation.ImplMethod0() { } - void IImplementation.ImplMethod1(T t) { } - void IImplementation.ImplMethod2(T t, U u, string s) { } - } +internal class Impl : IImplementation +{ + void IImplementation.ImplMethod0() { } + void IImplementation.ImplMethod1(T t) { } + void IImplementation.ImplMethod2(T t, U u, string s) { } +} - internal class Overloads - { - public void Overload0() { } - public void Overload0(int i) { } - public void Overload0(int i, Overloads c) { } - public unsafe void Overload0(int* p) { } - public void Overload0(dynamic d) { } - public void Overload0(U u) { } - public void Overload0() { } - public void Overload0() { } - public void Overload0(U[] u) { } - public void Overload0(U[][] u) { } - public void Overload0(U[,] u) { } - public void Overload0(U[,,] u) { } - public void Overload0(List l) { } - public void Overload0(List l) { } - public void Overload0(Tuple t0, Tuple t1) { } - public void Overload0(Tuple> t0) { } - public void Overload0(Tuple, Tuple> t) { } - public void Overload0(Tuple.Inner>> t) { } - } +internal class Overloads +{ + public void Overload0() { } + public void Overload0(int i) { } + public void Overload0(int i, Overloads c) { } + public unsafe void Overload0(int* p) { } + public void Overload0(dynamic d) { } + public void Overload0(U u) { } + public void Overload0() { } + public void Overload0() { } + public void Overload0(U[] u) { } + public void Overload0(U[][] u) { } + public void Overload0(U[,] u) { } + public void Overload0(U[,,] u) { } + public void Overload0(List l) { } + public void Overload0(List l) { } + public void Overload0(Tuple t0, Tuple t1) { } + public void Overload0(Tuple> t0) { } + public void Overload0(Tuple, Tuple> t) { } + public void Overload0(Tuple.Inner>> t) { } } +#pragma warning restore IDE0060 // Remove unused parameter +#pragma warning restore CA1822 // Mark members as static \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/TestIdProvider/CompatibilityTests.cs b/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/TestIdProvider/CompatibilityTests.cs index 06220dc920..bdf3525c32 100644 --- a/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/TestIdProvider/CompatibilityTests.cs +++ b/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/TestIdProvider/CompatibilityTests.cs @@ -1,139 +1,138 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AdapterUtilities.UnitTests.TestIdProvider -{ - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.AdapterUtilities.UnitTests.TestIdProvider; - using System; - using System.Linq; +using VisualStudio.TestTools.UnitTesting; - [TestClass] - public class CompatibilityTests - { - [TestMethod] - [DataRow(new[] { "eea339da-6b5e-0d4b-3255-bfef95601890", "" })] - [DataRow(new[] { "740b9afc-3350-4257-ca01-5bd47799147d", "adapter://", "name1" })] // less than one block - [DataRow(new[] { "119c5b31-c0fb-1c12-6d1a-d617bb2bd996", "adapter://namesamplenam.testname" })] // 1 full block - [DataRow(new[] { "2a4c33ec-6115-4bd7-2e94-71f2fd3a5ee3", "adapter://namesamplenamespace.testname" })] // 1 full block and extra - [DataRow(new[] { "119c5b31-c0fb-1c12-6d1a-d617bb2bd996", "adapter://", "name", "samplenam", ".", "testname" })] // 1 full block - [DataRow(new[] { "2a4c33ec-6115-4bd7-2e94-71f2fd3a5ee3", "adapter://", "name", "samplenamespace", ".", "testname" })] // 1 full block and extra - [DataRow(new[] { "1fc07043-3d2d-1401-c732-3b507feec548", "adapter://namesamplenam.testnameaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" })] // 2 full blocks - [DataRow(new[] { "24e8a50b-2766-6a12-f461-9f8e4fa1cbb5", "adapter://namesamplenamespace.testnameaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" })] // 2 full blocks and extra - [DataRow(new[] { "1fc07043-3d2d-1401-c732-3b507feec548", "adapter://", "name", "samplenam", ".", "testname", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" })] // 2 full blocks - [DataRow(new[] { "24e8a50b-2766-6a12-f461-9f8e4fa1cbb5", "adapter://", "name", "samplenamespace", ".", "testname", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" })] // 2 full blocks and extra - public void IdCompatibilityTests(string[] data) - { - // Arrange - var expectedId = new Guid(data[0]); - - // Act - var idProvider = new AdapterUtilities.TestIdProvider(); - foreach (var d in data.Skip(1)) - { - idProvider.AppendString(d); - } - var id = idProvider.GetId(); - - // Assert - Assert.AreEqual(expectedId, id); - } +using System; +using System.Linq; +[TestClass] +public class CompatibilityTests +{ + [TestMethod] + [DataRow(new[] { "eea339da-6b5e-0d4b-3255-bfef95601890", "" })] + [DataRow(new[] { "740b9afc-3350-4257-ca01-5bd47799147d", "adapter://", "name1" })] // less than one block + [DataRow(new[] { "119c5b31-c0fb-1c12-6d1a-d617bb2bd996", "adapter://namesamplenam.testname" })] // 1 full block + [DataRow(new[] { "2a4c33ec-6115-4bd7-2e94-71f2fd3a5ee3", "adapter://namesamplenamespace.testname" })] // 1 full block and extra + [DataRow(new[] { "119c5b31-c0fb-1c12-6d1a-d617bb2bd996", "adapter://", "name", "samplenam", ".", "testname" })] // 1 full block + [DataRow(new[] { "2a4c33ec-6115-4bd7-2e94-71f2fd3a5ee3", "adapter://", "name", "samplenamespace", ".", "testname" })] // 1 full block and extra + [DataRow(new[] { "1fc07043-3d2d-1401-c732-3b507feec548", "adapter://namesamplenam.testnameaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" })] // 2 full blocks + [DataRow(new[] { "24e8a50b-2766-6a12-f461-9f8e4fa1cbb5", "adapter://namesamplenamespace.testnameaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" })] // 2 full blocks and extra + [DataRow(new[] { "1fc07043-3d2d-1401-c732-3b507feec548", "adapter://", "name", "samplenam", ".", "testname", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" })] // 2 full blocks + [DataRow(new[] { "24e8a50b-2766-6a12-f461-9f8e4fa1cbb5", "adapter://", "name", "samplenamespace", ".", "testname", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" })] // 2 full blocks and extra + public void IdCompatibilityTests(string[] data) + { + // Arrange + var expectedId = new Guid(data[0]); - [TestMethod] - public void IdGeneration_TestVectors_EmptyString() + // Act + var idProvider = new AdapterUtilities.TestIdProvider(); + foreach (var d in data.Skip(1)) { - IdGeneration_TestVector( - string.Empty, - "eea339da-6b5e-0d4b-3255-bfef95601890" - ); + idProvider.AppendString(d); } + var id = idProvider.GetId(); + // Assert + Assert.AreEqual(expectedId, id); + } - [TestMethod] - public void IdGeneration_TestVectors_abc() - { - IdGeneration_TestVector( - "abc", - "1af4049f-8584-1614-2050-e3d68c1a7abb" - ); - } - [TestMethod] - public void IdGeneration_TestVectors_448Bits() - { - IdGeneration_TestVector( - "abcdbcdecdefdefgefghfghighij", - "7610f6db-8808-4bb7-b076-96871a96329c" - ); - } + [TestMethod] + public void IdGeneration_TestVectors_EmptyString() + { + IdGeneration_TestVector( + string.Empty, + "eea339da-6b5e-0d4b-3255-bfef95601890" + ); + } - [TestMethod] - public void IdGeneration_TestVectors_896Bits() - { - IdGeneration_TestVector( - "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", - "76d8d751-c79a-402c-9c5b-0e3f69c60adc" - ); - } - [TestMethod] - public void IdGeneration_TestVectors_1Block() - { - IdGeneration_TestRepetitionVector( - "a", 512 / 16, - "99b1aec7-ff50-5229-a378-70ca37914c90" - ); - } + [TestMethod] + public void IdGeneration_TestVectors_abc() + { + IdGeneration_TestVector( + "abc", + "1af4049f-8584-1614-2050-e3d68c1a7abb" + ); + } - [TestMethod] - public void IdGeneration_ExtremelyLarge_TestVectors_100k_abc() - { - IdGeneration_TestRepetitionVector( - "abc", 100_000, - "11dbfc20-b34a-eef6-158e-ea8c201dfff9" - ); - } + [TestMethod] + public void IdGeneration_TestVectors_448Bits() + { + IdGeneration_TestVector( + "abcdbcdecdefdefgefghfghighij", + "7610f6db-8808-4bb7-b076-96871a96329c" + ); + } - [TestMethod] - public void IdGeneration_ExtremelyLarge_TestVectors_10M_abc() - { - IdGeneration_TestRepetitionVector( - "abc", 10_000_000, - "78640f07-8041-71bd-6461-3a7e4db52389" - ); - } + [TestMethod] + public void IdGeneration_TestVectors_896Bits() + { + IdGeneration_TestVector( + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "76d8d751-c79a-402c-9c5b-0e3f69c60adc" + ); + } - private void IdGeneration_TestVector(string testName, string expected) - { - // Arrange - expected = expected.Replace(" ", "").ToLowerInvariant(); - var idProvider = new AdapterUtilities.TestIdProvider(); + [TestMethod] + public void IdGeneration_TestVectors_1Block() + { + IdGeneration_TestRepetitionVector( + "a", 512 / 16, + "99b1aec7-ff50-5229-a378-70ca37914c90" + ); + } - // Act - idProvider.AppendString(testName); - var actual = idProvider.GetId().ToString(); + [TestMethod] + public void IdGeneration_ExtremelyLarge_TestVectors_100k_abc() + { + IdGeneration_TestRepetitionVector( + "abc", 100_000, + "11dbfc20-b34a-eef6-158e-ea8c201dfff9" + ); + } - // Assert - Assert.AreEqual(expected, actual, $"Test Id for '{testName}' is invalid!"); - } + [TestMethod] + public void IdGeneration_ExtremelyLarge_TestVectors_10M_abc() + { + IdGeneration_TestRepetitionVector( + "abc", 10_000_000, + "78640f07-8041-71bd-6461-3a7e4db52389" + ); + } - private void IdGeneration_TestRepetitionVector(string input, int repetition, string expected) - { - // Arrange - var idProvider = new AdapterUtilities.TestIdProvider(); + private void IdGeneration_TestVector(string testName, string expected) + { + // Arrange + expected = expected.Replace(" ", "").ToLowerInvariant(); + var idProvider = new AdapterUtilities.TestIdProvider(); + + // Act + idProvider.AppendString(testName); + var actual = idProvider.GetId().ToString(); - // Act - for (int i = 0; i < repetition; i++) - { - idProvider.AppendString(input); - } + // Assert + Assert.AreEqual(expected, actual, $"Test Id for '{testName}' is invalid!"); + } - var id = idProvider.GetId().ToString(); + private void IdGeneration_TestRepetitionVector(string input, int repetition, string expected) + { + // Arrange + var idProvider = new AdapterUtilities.TestIdProvider(); - // Assert - Assert.AreEqual(expected, id, $"Test id generation for vector '{input}'*{repetition} failed! (normal path)"); + // Act + for (int i = 0; i < repetition; i++) + { + idProvider.AppendString(input); } + var id = idProvider.GetId().ToString(); + + // Assert + Assert.AreEqual(expected, id, $"Test id generation for vector '{input}'*{repetition} failed! (normal path)"); } -} + +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/TestIdProvider/SHA1ImplTests.cs b/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/TestIdProvider/SHA1ImplTests.cs index 23bb10bef8..d3862ab58f 100644 --- a/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/TestIdProvider/SHA1ImplTests.cs +++ b/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/TestIdProvider/SHA1ImplTests.cs @@ -1,173 +1,170 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.AdapterUtilities.UnitTests.TestIdProvider +namespace Microsoft.TestPlatform.AdapterUtilities.UnitTests.TestIdProvider; + +using VisualStudio.TestTools.UnitTesting; + +using System; +using System.Linq; +using System.Text; + +[TestClass] +public class Sha1ImplTests { - using Microsoft.VisualStudio.TestTools.UnitTesting; + [TestMethod] + public void SHA1_TestVectors_EmptyString() + { + SHA1_TestVector( + string.Empty, + "da39a3ee5e6b4b0d3255bfef95601890afd80709" + ); + } - using System; - using System.Linq; - using System.Text; + [TestMethod] + public void SHA1_TestVectors_abc() + { + SHA1_TestVector( + "abc", + "a9993e364706816aba3e25717850c26c9cd0d89d" + ); + } - [TestClass] - public class SHA1ImplTests + [TestMethod] + public void SHA1_TestVectors_448Bits() { - [TestMethod] - public void SHA1_TestVectors_EmptyString() - { - SHA1_TestVector( - string.Empty, - "da39a3ee5e6b4b0d3255bfef95601890afd80709" - ); - } + SHA1_TestVector( + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "84983e441c3bd26ebaae4aa1f95129e5e54670f1" + ); + } - [TestMethod] - public void SHA1_TestVectors_abc() - { - SHA1_TestVector( - "abc", - "a9993e364706816aba3e25717850c26c9cd0d89d" - ); - } + [TestMethod] + public void SHA1_TestVectors_896Bits() + { + SHA1_TestVector( + "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", + "a49b2446a02c645bf419f995b67091253a04a259" + ); + } - [TestMethod] - public void SHA1_TestVectors_448Bits() - { - SHA1_TestVector( - "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", - "84983e441c3bd26ebaae4aa1f95129e5e54670f1" - ); - } + [TestMethod] + public void SHA1_TestVectors_1Block() + { + SHA1_TestRepetitionVector( + 'a', + 512 / 8 + ); + } - [TestMethod] - public void SHA1_TestVectors_896Bits() - { - SHA1_TestVector( - "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", - "a49b2446a02c645bf419f995b67091253a04a259" - ); - } + [TestMethod] + public void SHA1_ExtremelyLarge_TestVectors_500k_a() + { + SHA1_TestRepetitionVector( + 'a', + 500_000 + ); + } - [TestMethod] - public void SHA1_TestVectors_1Block() - { - SHA1_TestRepetitionVector( - 'a', - 512 / 8 - ); - } + [TestMethod] + public void SHA1_ExtremelyLarge_TestVectors_900k_a() + { + SHA1_TestRepetitionVector( + 'a', + 900_000 + ); + } - [TestMethod] - public void SHA1_ExtremelyLarge_TestVectors_500k_a() - { - SHA1_TestRepetitionVector( - 'a', - 500_000 - ); - } + [TestMethod] + public void SHA1_ExtremelyLarge_TestVectors_999999_a() + { + SHA1_TestRepetitionVector( + 'a', + 999_999 + ); + } - [TestMethod] - public void SHA1_ExtremelyLarge_TestVectors_900k_a() - { - SHA1_TestRepetitionVector( - 'a', - 900_000 - ); - } + [TestMethod] + public void SHA1_ExtremelyLarge_TestVectors_1M_a() + { + SHA1_TestRepetitionVector( + 'a', + 1_000_000, + "34aa973c d4c4daa4 f61eeb2b dbad2731 6534016f" + ); + } - [TestMethod] - public void SHA1_ExtremelyLarge_TestVectors_999999_a() - { - SHA1_TestRepetitionVector( - 'a', - 999_999 - ); - } + [TestMethod] + public void SHA1_ExtremelyLarge_TestVectors_10M_a() + { + SHA1_TestRepetitionVector( + 'a', + 10_000_000 + ); + } - [TestMethod] - public void SHA1_ExtremelyLarge_TestVectors_1M_a() + private void SHA1_TestVector(string message, string expected) + { + // Arrange + expected = expected.Replace(" ", "").ToLowerInvariant(); + var shaHasher1 = new AdapterUtilities.TestIdProvider.Sha1Implementation(); + + // Act + var bytes = Encoding.UTF8.GetBytes(message); + var digest1 = ToHex(shaHasher1.ComputeHash(bytes)); + + // Assert + Assert.AreEqual(expected, digest1, $"Test vector '{message}' failed!"); + } + + private void SHA1_TestRepetitionVector(char input, int repetition, string expected = null) + { + // Arrange + var shaHasher1 = new AdapterUtilities.TestIdProvider.Sha1Implementation(); + var shaHasher2 = new AdapterUtilities.TestIdProvider.Sha1Implementation(); + + var bytes = new byte[repetition]; + for (int i = 0; i < repetition; i++) { - SHA1_TestRepetitionVector( - 'a', - 1_000_000, - "34aa973c d4c4daa4 f61eeb2b dbad2731 6534016f" - ); + bytes[i] = (byte)input; } - [TestMethod] - public void SHA1_ExtremelyLarge_TestVectors_10M_a() + if (string.IsNullOrEmpty(expected)) { - SHA1_TestRepetitionVector( - 'a', - 10_000_000 - ); + using var hasher = System.Security.Cryptography.SHA1.Create(); + expected = ToHex(hasher.ComputeHash(bytes)); } - - private void SHA1_TestVector(string message, string expected) + else { - // Arrange expected = expected.Replace(" ", "").ToLowerInvariant(); - var shaHasher1 = new AdapterUtilities.TestIdProvider.Sha1Implementation(); - - // Act - var bytes = UTF8Encoding.UTF8.GetBytes(message); - var digest1 = ToHex(shaHasher1.ComputeHash(bytes)); + } - // Assert - Assert.AreEqual(expected, digest1, $"Test vector '{message}' failed!"); + // Act + var digest1 = ToHex(shaHasher1.ComputeHash(bytes)); + var blocks = bytes.Length / AdapterUtilities.TestIdProvider.BlockBytes; + byte[] block; + for (var i = 0; i < blocks; i += 1) + { + block = new byte[AdapterUtilities.TestIdProvider.BlockBytes]; + Buffer.BlockCopy(bytes, i * block.Length, block, 0, block.Length); + shaHasher2.ProcessBlock(block, 0, block.Length); } - private void SHA1_TestRepetitionVector(char input, int repetition, string expected = null) + var rest = bytes.Length - blocks * AdapterUtilities.TestIdProvider.BlockBytes; + if (rest != 0) { - // Arrange - var shaHasher1 = new AdapterUtilities.TestIdProvider.Sha1Implementation(); - var shaHasher2 = new AdapterUtilities.TestIdProvider.Sha1Implementation(); - - var bytes = new byte[repetition]; - for (int i = 0; i < repetition; i++) - { - bytes[i] = (byte)input; - } - - if (string.IsNullOrEmpty(expected)) - { - using (var hasher = System.Security.Cryptography.SHA1.Create()) - { - expected = ToHex(hasher.ComputeHash(bytes)); - } - } - else - { - expected = expected.Replace(" ", "").ToLowerInvariant(); - } - - // Act - var digest1 = ToHex(shaHasher1.ComputeHash(bytes)); - var blocks = bytes.Length / AdapterUtilities.TestIdProvider.BlockBytes; - byte[] block; - for (var i = 0; i < blocks; i += 1) - { - block = new byte[AdapterUtilities.TestIdProvider.BlockBytes]; - Buffer.BlockCopy(bytes, i * block.Length, block, 0, block.Length); - shaHasher2.ProcessBlock(block, 0, block.Length); - } - - var rest = bytes.Length - blocks * AdapterUtilities.TestIdProvider.BlockBytes; - if (rest != 0) - { - block = new byte[rest]; - Buffer.BlockCopy(bytes, blocks * block.Length, block, 0, block.Length); - shaHasher2.PadMessage(ref block, block.Length); - shaHasher2.ProcessBlock(block, 0, block.Length); - } - - var digest2 = ToHex(shaHasher2.ProcessFinalBlock()); - - // Assert - Assert.AreEqual(expected, digest1, $"Test vector '{input}'*{repetition} failed! (normal path)"); - Assert.AreEqual(expected, digest2, $"Test vector '{input}'*{repetition} failed! (padding path)"); + block = new byte[rest]; + Buffer.BlockCopy(bytes, blocks * block.Length, block, 0, block.Length); + shaHasher2.PadMessage(ref block, block.Length); + shaHasher2.ProcessBlock(block, 0, block.Length); } - private static string ToHex(byte[] digest) => string.Concat(digest.Select(i => i.ToString("x2"))); + var digest2 = ToHex(shaHasher2.ProcessFinalBlock()); + + // Assert + Assert.AreEqual(expected, digest1, $"Test vector '{input}'*{repetition} failed! (normal path)"); + Assert.AreEqual(expected, digest2, $"Test vector '{input}'*{repetition} failed! (padding path)"); } -} + + private static string ToHex(byte[] digest) => string.Concat(digest.Select(i => i.ToString("x2"))); +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Build.UnitTests/ArgumentEscaperTests.cs b/test/Microsoft.TestPlatform.Build.UnitTests/ArgumentEscaperTests.cs index e71cb67c55..9dfc31abcc 100644 --- a/test/Microsoft.TestPlatform.Build.UnitTests/ArgumentEscaperTests.cs +++ b/test/Microsoft.TestPlatform.Build.UnitTests/ArgumentEscaperTests.cs @@ -1,127 +1,127 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Build.Utils.UnitTests -{ - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.Build.Utils.UnitTests; + +using VisualStudio.TestTools.UnitTesting; - [TestClass] - public class ArgumentEscaperTests +[TestClass] +public class ArgumentEscaperTests +{ + [TestMethod] + public void EscapeArgForProcessStartShouldAddDoubleQuoteIfThereIsSpace() { - [TestMethod] - public void EscapeArgForProcessStartShouldAddDoubleQuoteIfThereIsSpace() - { - string stringWithSpace = "Some string"; + string stringWithSpace = "Some string"; - string expected = "\"Some string\""; - string result = ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(stringWithSpace); + string expected = "\"Some string\""; + string result = ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(stringWithSpace); - Assert.AreEqual(expected, result); - } + Assert.AreEqual(expected, result); + } - [TestMethod] - public void EscapeArgForProcessStartShouldAddDoubleQuoteIfThereIsSpaceAtEnd() - { - string stringWithSpaceAtEnd = "Some string "; + [TestMethod] + public void EscapeArgForProcessStartShouldAddDoubleQuoteIfThereIsSpaceAtEnd() + { + string stringWithSpaceAtEnd = "Some string "; - string expected = "\"Some string \""; - string result = ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(stringWithSpaceAtEnd); + string expected = "\"Some string \""; + string result = ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(stringWithSpaceAtEnd); - Assert.AreEqual(expected, result); - } + Assert.AreEqual(expected, result); + } - [TestMethod] - public void EscapeArgForProcessStartShouldHandleForwardSlash() - { - string stringWithForwardSlash = "Some/string"; + [TestMethod] + public void EscapeArgForProcessStartShouldHandleForwardSlash() + { + string stringWithForwardSlash = "Some/string"; - string expected = "Some/string"; - string result = ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(stringWithForwardSlash); + string expected = "Some/string"; + string result = ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(stringWithForwardSlash); - Assert.AreEqual(expected, result); - } + Assert.AreEqual(expected, result); + } - [TestMethod] - public void EscapeArgForProcessStartShouldPreserveDoubleQuote() - { - string stringWithDoubleQuote = "Some\"string"; + [TestMethod] + public void EscapeArgForProcessStartShouldPreserveDoubleQuote() + { + string stringWithDoubleQuote = "Some\"string"; - string expected = "Some\\\"string"; - string result = ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(stringWithDoubleQuote); + string expected = "Some\\\"string"; + string result = ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(stringWithDoubleQuote); - Assert.AreEqual(expected, result); - } + Assert.AreEqual(expected, result); + } - [TestMethod] - public void EscapeArgForProcessStartShouldPreserveSingleQuote() - { - string stringWithSingleQuote = "Some'string"; + [TestMethod] + public void EscapeArgForProcessStartShouldPreserveSingleQuote() + { + string stringWithSingleQuote = "Some'string"; - string expected = "Some'string"; - string result = ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(stringWithSingleQuote); + string expected = "Some'string"; + string result = ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(stringWithSingleQuote); - Assert.AreEqual(expected, result); - } + Assert.AreEqual(expected, result); + } - [TestMethod] - public void EscapeArgForProcessStartShouldPreserveBackSlash() - { - string stringWithBackSlash = @"Some\\string"; + [TestMethod] + public void EscapeArgForProcessStartShouldPreserveBackSlash() + { + string stringWithBackSlash = @"Some\\string"; - string expected = "Some\\\\string"; - string result = ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(stringWithBackSlash); + string expected = "Some\\\\string"; + string result = ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(stringWithBackSlash); - Assert.AreEqual(expected, result); - } + Assert.AreEqual(expected, result); + } - [TestMethod] - public void EscapeArgForProcessStartShouldPreserveBackSlashIfStringHasWhiteSpace() - { - string stringWithBackSlash = @"Some string With Space\\"; + [TestMethod] + public void EscapeArgForProcessStartShouldPreserveBackSlashIfStringHasWhiteSpace() + { + string stringWithBackSlash = @"Some string With Space\\"; - string expected = @"""Some string With Space\\\\"""; - string result = ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(stringWithBackSlash); + string expected = @"""Some string With Space\\\\"""; + string result = ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(stringWithBackSlash); - Assert.AreEqual(expected, result); - } + Assert.AreEqual(expected, result); + } - [TestMethod] - public void ShouldSurroundWithQuotesShouldReturnFalseIfAlreadySurroundWithQuotes() - { - string stringSurroundWithQuotes = "\"some string\""; + [TestMethod] + public void ShouldSurroundWithQuotesShouldReturnFalseIfAlreadySurroundWithQuotes() + { + string stringSurroundWithQuotes = "\"some string\""; - Assert.IsFalse(ArgumentEscaper.ShouldSurroundWithQuotes(stringSurroundWithQuotes)); - } + Assert.IsFalse(ArgumentEscaper.ShouldSurroundWithQuotes(stringSurroundWithQuotes)); + } - [TestMethod] - public void ShouldSurroundWithQuotesShouldReturnFalseIfItIsNotSurroundWithQuotesAndHasNoWhiteSpace() - { - string stringWithoutSpace = "someStringWithNoWhiteSpace"; + [TestMethod] + public void ShouldSurroundWithQuotesShouldReturnFalseIfItIsNotSurroundWithQuotesAndHasNoWhiteSpace() + { + string stringWithoutSpace = "someStringWithNoWhiteSpace"; - Assert.IsFalse(ArgumentEscaper.ShouldSurroundWithQuotes(stringWithoutSpace)); - } + Assert.IsFalse(ArgumentEscaper.ShouldSurroundWithQuotes(stringWithoutSpace)); + } - [TestMethod] - public void ShouldSurroundWithQuotesShouldReturnTrueIfItIsNotSurroundWithQuotesAndHasWhiteSpace() - { - string stringWithSpace = "some String With WhiteSpace"; + [TestMethod] + public void ShouldSurroundWithQuotesShouldReturnTrueIfItIsNotSurroundWithQuotesAndHasWhiteSpace() + { + string stringWithSpace = "some String With WhiteSpace"; - Assert.IsTrue(ArgumentEscaper.ShouldSurroundWithQuotes(stringWithSpace)); - } + Assert.IsTrue(ArgumentEscaper.ShouldSurroundWithQuotes(stringWithSpace)); + } - [TestMethod] - public void IsSurroundedWithQuotesShouldReturnTrueIfStringIsSurrondedByQuotes() - { - string stringSurroundWithQuotes = "\"some string\""; + [TestMethod] + public void IsSurroundedWithQuotesShouldReturnTrueIfStringIsSurrondedByQuotes() + { + string stringSurroundWithQuotes = "\"some string\""; - Assert.IsTrue(ArgumentEscaper.IsSurroundedWithQuotes(stringSurroundWithQuotes)); - } + Assert.IsTrue(ArgumentEscaper.IsSurroundedWithQuotes(stringSurroundWithQuotes)); + } - [TestMethod] - public void IsSurroundedWithQuotesShouldReturnFalseIfStringIsNotSurrondedByQuotes() - { - string stringNotSurroundWithQuotes = "some string"; + [TestMethod] + public void IsSurroundedWithQuotesShouldReturnFalseIfStringIsNotSurrondedByQuotes() + { + string stringNotSurroundWithQuotes = "some string"; - Assert.IsFalse(ArgumentEscaper.IsSurroundedWithQuotes(stringNotSurroundWithQuotes)); - } + Assert.IsFalse(ArgumentEscaper.IsSurroundedWithQuotes(stringNotSurroundWithQuotes)); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Build.UnitTests/Program.cs b/test/Microsoft.TestPlatform.Build.UnitTests/Program.cs index 6b68a1b2ad..c7fde095ee 100644 --- a/test/Microsoft.TestPlatform.Build.UnitTests/Program.cs +++ b/test/Microsoft.TestPlatform.Build.UnitTests/Program.cs @@ -1,11 +1,11 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Build.UnitTests +namespace Microsoft.TestPlatform.Build.UnitTests; + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Build.UnitTests/VsTestTaskTests.cs b/test/Microsoft.TestPlatform.Build.UnitTests/VsTestTaskTests.cs index c61451ec9a..e847000a47 100644 --- a/test/Microsoft.TestPlatform.Build.UnitTests/VsTestTaskTests.cs +++ b/test/Microsoft.TestPlatform.Build.UnitTests/VsTestTaskTests.cs @@ -1,329 +1,330 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Build.UnitTests -{ - using System; - using System.Linq; +namespace Microsoft.TestPlatform.Build.UnitTests; - using Microsoft.TestPlatform.Build.Tasks; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Linq; - [TestClass] - public class VSTestTaskTests - { - private readonly VSTestTask vsTestTask; +using Tasks; - public VSTestTaskTests() - { - this.vsTestTask = new VSTestTask - { - TestFileFullPath = @"C:\path\to\test-assembly.dll", - VSTestFramework = ".NETCoreapp,Version2.0" - }; - } - - [TestMethod] - public void CreateArgumentShouldAddOneEntryForCLIRunSettings() +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class VsTestTaskTests +{ + private readonly VSTestTask _vsTestTask; + + public VsTestTaskTests() + { + _vsTestTask = new VSTestTask { - const string arg1 = "RunConfiguration.ResultsDirectory=Path having Space"; - const string arg2 = "MSTest.DeploymentEnabled"; + TestFileFullPath = @"C:\path\to\test-assembly.dll", + VSTestFramework = ".NETCoreapp,Version2.0" + }; + } - this.vsTestTask.VSTestCLIRunSettings = new string[2]; - this.vsTestTask.VSTestCLIRunSettings[0] = arg1; - this.vsTestTask.VSTestCLIRunSettings[1] = arg2; + [TestMethod] + public void CreateArgumentShouldAddOneEntryForCLIRunSettings() + { + const string arg1 = "RunConfiguration.ResultsDirectory=Path having Space"; + const string arg2 = "MSTest.DeploymentEnabled"; - var result = this.vsTestTask.CreateArgument().ToArray(); + _vsTestTask.VSTestCLIRunSettings = new string[2]; + _vsTestTask.VSTestCLIRunSettings[0] = arg1; + _vsTestTask.VSTestCLIRunSettings[1] = arg2; - Assert.AreEqual(5, result.Length); + var result = _vsTestTask.CreateArgument().ToArray(); - // First, second and third args would be framework:".NETCoreapp,Version2.0", testfilepath and -- respectively. - Assert.AreEqual($"\"{arg1}\"", result[3]); - Assert.AreEqual($"{arg2}", result[4]); - } + Assert.AreEqual(5, result.Length); - [TestMethod] - public void CreateArgumentShouldAddCLIRunSettingsArgAtEnd() - { - const string codeCoverageOption = "Code Coverage"; + // First, second and third args would be framework:".NETCoreapp,Version2.0", testfilepath and -- respectively. + Assert.AreEqual($"\"{arg1}\"", result[3]); + Assert.AreEqual($"{arg2}", result[4]); + } - this.vsTestTask.VSTestCollect = new string[] { codeCoverageOption }; - this.vsTestTask.VSTestBlame = "Blame"; + [TestMethod] + public void CreateArgumentShouldAddCliRunSettingsArgAtEnd() + { + const string codeCoverageOption = "Code Coverage"; - const string arg1 = "RunConfiguration.ResultsDirectory=Path having Space"; - const string arg2 = "MSTest.DeploymentEnabled"; + _vsTestTask.VSTestCollect = new string[] { codeCoverageOption }; + _vsTestTask.VSTestBlame = "Blame"; - this.vsTestTask.VSTestCLIRunSettings = new string[2]; - this.vsTestTask.VSTestCLIRunSettings[0] = arg1; - this.vsTestTask.VSTestCLIRunSettings[1] = arg2; + const string arg1 = "RunConfiguration.ResultsDirectory=Path having Space"; + const string arg2 = "MSTest.DeploymentEnabled"; - var result = this.vsTestTask.CreateArgument().ToArray(); + _vsTestTask.VSTestCLIRunSettings = new string[2]; + _vsTestTask.VSTestCLIRunSettings[0] = arg1; + _vsTestTask.VSTestCLIRunSettings[1] = arg2; - Assert.AreEqual(7, result.Length); + var result = _vsTestTask.CreateArgument().ToArray(); - // Following are expected --framework:".NETCoreapp,Version2.0", testfilepath, blame, collect:"Code coverage" -- respectively. - Assert.AreEqual($"\"{arg1}\"", result[5]); - Assert.AreEqual($"{arg2}", result[6]); - } + Assert.AreEqual(7, result.Length); - [TestMethod] - public void CreateArgumentShouldPassResultsDirectoryCorrectly() - { - const string resultsDirectoryValue = @"C:\tmp\Results Directory"; - this.vsTestTask.VSTestResultsDirectory = resultsDirectoryValue; + // Following are expected --framework:".NETCoreapp,Version2.0", testfilepath, blame, collect:"Code coverage" -- respectively. + Assert.AreEqual($"\"{arg1}\"", result[5]); + Assert.AreEqual($"{arg2}", result[6]); + } - var result = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldPassResultsDirectoryCorrectly() + { + const string resultsDirectoryValue = @"C:\tmp\Results Directory"; + _vsTestTask.VSTestResultsDirectory = resultsDirectoryValue; - Assert.AreEqual($"--resultsDirectory:\"{resultsDirectoryValue}\"", result[1]); - } + var result = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldNotSetConsoleLoggerVerbosityIfConsoleLoggerIsGivenInArgs() - { - this.vsTestTask.VSTestVerbosity = "diag"; - this.vsTestTask.VSTestLogger = new string[] { "Console;Verbosity=quiet" }; + Assert.AreEqual($"--resultsDirectory:\"{resultsDirectoryValue}\"", result[1]); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldNotSetConsoleLoggerVerbosityIfConsoleLoggerIsGivenInArgs() + { + _vsTestTask.VSTestVerbosity = "diag"; + _vsTestTask.VSTestLogger = new string[] { "Console;Verbosity=quiet" }; - Assert.IsNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=normal"))); - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=quiet"))); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsn() - { - this.vsTestTask.VSTestVerbosity = "n"; + Assert.IsNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=normal"))); + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=quiet"))); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsn() + { + _vsTestTask.VSTestVerbosity = "n"; - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=normal"))); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsnormal() - { - this.vsTestTask.VSTestVerbosity = "normal"; + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=normal"))); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsnormal() + { + _vsTestTask.VSTestVerbosity = "normal"; - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=normal"))); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsd() - { - this.vsTestTask.VSTestVerbosity = "d"; + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=normal"))); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsd() + { + _vsTestTask.VSTestVerbosity = "d"; - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=normal"))); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsdetailed() - { - this.vsTestTask.VSTestVerbosity = "detailed"; + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=normal"))); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsdetailed() + { + _vsTestTask.VSTestVerbosity = "detailed"; - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=normal"))); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsdiag() - { - this.vsTestTask.VSTestVerbosity = "diag"; + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=normal"))); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsdiag() + { + _vsTestTask.VSTestVerbosity = "diag"; - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=normal"))); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsdiagnostic() - { - this.vsTestTask.VSTestVerbosity = "diagnostic"; + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=normal"))); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsdiagnostic() + { + _vsTestTask.VSTestVerbosity = "diagnostic"; - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=normal"))); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldSetConsoleLoggerVerbosityToQuietIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsq() - { - this.vsTestTask.VSTestVerbosity = "q"; + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=normal"))); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldSetConsoleLoggerVerbosityToQuietIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsq() + { + _vsTestTask.VSTestVerbosity = "q"; - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=quiet"))); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldSetConsoleLoggerVerbosityToQuietIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsquiet() - { - this.vsTestTask.VSTestVerbosity = "quiet"; + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=quiet"))); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldSetConsoleLoggerVerbosityToQuietIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsquiet() + { + _vsTestTask.VSTestVerbosity = "quiet"; - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=quiet"))); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldSetConsoleLoggerVerbosityToMinimalIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsm() - { - this.vsTestTask.VSTestVerbosity = "m"; + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=quiet"))); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldSetConsoleLoggerVerbosityToMinimalIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsm() + { + _vsTestTask.VSTestVerbosity = "m"; - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=minimal"))); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldSetConsoleLoggerVerbosityToMinimalIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsminimal() - { - this.vsTestTask.VSTestVerbosity = "minimal"; + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=minimal"))); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldSetConsoleLoggerVerbosityToMinimalIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsminimal() + { + _vsTestTask.VSTestVerbosity = "minimal"; - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=minimal"))); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsNormalWithCapitalN() - { - this.vsTestTask.VSTestVerbosity = "Normal"; + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=minimal"))); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsNormalWithCapitalN() + { + _vsTestTask.VSTestVerbosity = "Normal"; - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=normal"))); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldSetConsoleLoggerVerbosityToQuietIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsQuietWithCapitalQ() - { - this.vsTestTask.VSTestVerbosity = "Quiet"; + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=normal"))); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldSetConsoleLoggerVerbosityToQuietIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsQuietWithCapitalQ() + { + _vsTestTask.VSTestVerbosity = "Quiet"; - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=quiet"))); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldPreserveWhiteSpaceInLogger() - { - this.vsTestTask.VSTestLogger = new string[] { "trx;LogFileName=foo bar.trx" }; + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:Console;Verbosity=quiet"))); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldPreserveWhiteSpaceInLogger() + { + _vsTestTask.VSTestLogger = new string[] { "trx;LogFileName=foo bar.trx" }; - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:\"trx;LogFileName=foo bar.trx\""))); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldAddOneCollectArgumentForEachCollect() - { - this.vsTestTask.VSTestCollect = new string[2]; + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:\"trx;LogFileName=foo bar.trx\""))); + } - this.vsTestTask.VSTestCollect[0] = "name1"; - this.vsTestTask.VSTestCollect[1] = "name 2"; + [TestMethod] + public void CreateArgumentShouldAddOneCollectArgumentForEachCollect() + { + _vsTestTask.VSTestCollect = new string[2]; - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + _vsTestTask.VSTestCollect[0] = "name1"; + _vsTestTask.VSTestCollect[1] = "name 2"; - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--collect:name1"))); - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--collect:\"name 2\""))); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldAddMultipleTestAdapterPaths() - { - this.vsTestTask.VSTestTestAdapterPath = new string[] { "path1", "path2" }; + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--collect:name1"))); + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--collect:\"name 2\""))); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldAddMultipleTestAdapterPaths() + { + _vsTestTask.VSTestTestAdapterPath = new string[] { "path1", "path2" }; - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--testAdapterPath:path1"))); - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--testAdapterPath:path2"))); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldAddMultipleLoggers() - { - this.vsTestTask.VSTestLogger = new string[] { "trx;LogFileName=foo bar.trx", "console" }; - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--testAdapterPath:path1"))); + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--testAdapterPath:path2"))); + } - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:\"trx;LogFileName=foo bar.trx\""))); - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:console"))); - } + [TestMethod] + public void CreateArgumentShouldAddMultipleLoggers() + { + _vsTestTask.VSTestLogger = new string[] { "trx;LogFileName=foo bar.trx", "console" }; + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldAddTraceCollectorDirectoryPathAsTestAdapterForCodeCoverageCollect() - { - const string traceDataCollectorDirectoryPath = @"c:\path\to\tracedata collector"; - this.vsTestTask.VSTestTraceDataCollectorDirectoryPath = traceDataCollectorDirectoryPath; - this.vsTestTask.VSTestCollect = new string[] { "code coverage" }; + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:\"trx;LogFileName=foo bar.trx\""))); + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--logger:console"))); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldAddTraceCollectorDirectoryPathAsTestAdapterForCodeCoverageCollect() + { + const string traceDataCollectorDirectoryPath = @"c:\path\to\tracedata collector"; + _vsTestTask.VSTestTraceDataCollectorDirectoryPath = traceDataCollectorDirectoryPath; + _vsTestTask.VSTestCollect = new string[] { "code coverage" }; - const string expectedArg = "--testAdapterPath:\"c:\\path\\to\\tracedata collector\""; - CollectionAssert.Contains(allArguments, expectedArg, $"Expected argument: '''{expectedArg}''' not present in [{string.Join(", ", allArguments)}]"); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldAddTraceCollectorDirectoryPathAsTestAdapterForCodeCoverageCollectWithExtraConfigurations() - { - const string traceDataCollectorDirectoryPath = @"c:\path\to\tracedata collector"; - this.vsTestTask.VSTestTraceDataCollectorDirectoryPath = traceDataCollectorDirectoryPath; - this.vsTestTask.VSTestCollect = new string[] { "code coverage;someParameter=someValue" }; + const string expectedArg = "--testAdapterPath:\"c:\\path\\to\\tracedata collector\""; + CollectionAssert.Contains(allArguments, expectedArg, $"Expected argument: '''{expectedArg}''' not present in [{string.Join(", ", allArguments)}]"); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldAddTraceCollectorDirectoryPathAsTestAdapterForCodeCoverageCollectWithExtraConfigurations() + { + const string traceDataCollectorDirectoryPath = @"c:\path\to\tracedata collector"; + _vsTestTask.VSTestTraceDataCollectorDirectoryPath = traceDataCollectorDirectoryPath; + _vsTestTask.VSTestCollect = new string[] { "code coverage;someParameter=someValue" }; - const string expectedArg = "--testAdapterPath:\"c:\\path\\to\\tracedata collector\""; - CollectionAssert.Contains(allArguments, expectedArg, $"Expected argument: '''{expectedArg}''' not present in [{string.Join(", ", allArguments)}]"); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldNotAddTraceCollectorDirectoryPathAsTestAdapterForNonCodeCoverageCollect() - { - const string traceDataCollectorDirectoryPath = @"c:\path\to\tracedata collector"; - this.vsTestTask.VSTestTraceDataCollectorDirectoryPath = traceDataCollectorDirectoryPath; - this.vsTestTask.VSTestCollect = new string[] { "not code coverage" }; + const string expectedArg = "--testAdapterPath:\"c:\\path\\to\\tracedata collector\""; + CollectionAssert.Contains(allArguments, expectedArg, $"Expected argument: '''{expectedArg}''' not present in [{string.Join(", ", allArguments)}]"); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldNotAddTraceCollectorDirectoryPathAsTestAdapterForNonCodeCoverageCollect() + { + const string traceDataCollectorDirectoryPath = @"c:\path\to\tracedata collector"; + _vsTestTask.VSTestTraceDataCollectorDirectoryPath = traceDataCollectorDirectoryPath; + _vsTestTask.VSTestCollect = new string[] { "not code coverage" }; - const string notExpectedArg = "--testAdapterPath:\"c:\\path\\to\\tracedata collector\""; - CollectionAssert.DoesNotContain(allArguments, notExpectedArg, $"Not expected argument: '''{notExpectedArg}''' present in [{string.Join(", ", allArguments)}]"); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldAddTraceCollectorDirectoryPathAsTestAdapterIfSettingsGiven() - { - const string traceDataCollectorDirectoryPath = @"c:\path\to\tracedatacollector\"; - this.vsTestTask.VSTestTraceDataCollectorDirectoryPath = traceDataCollectorDirectoryPath; - this.vsTestTask.VSTestSetting = @"c:\path\to\sample.runsettings"; + const string notExpectedArg = "--testAdapterPath:\"c:\\path\\to\\tracedata collector\""; + CollectionAssert.DoesNotContain(allArguments, notExpectedArg, $"Not expected argument: '''{notExpectedArg}''' present in [{string.Join(", ", allArguments)}]"); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldAddTraceCollectorDirectoryPathAsTestAdapterIfSettingsGiven() + { + const string traceDataCollectorDirectoryPath = @"c:\path\to\tracedatacollector\"; + _vsTestTask.VSTestTraceDataCollectorDirectoryPath = traceDataCollectorDirectoryPath; + _vsTestTask.VSTestSetting = @"c:\path\to\sample.runsettings"; - const string expectedArg = "--testAdapterPath:c:\\path\\to\\tracedatacollector\\"; - CollectionAssert.Contains(allArguments, expectedArg, $"Expected argument: '''{expectedArg}''' not present in [{string.Join(", ", allArguments)}]"); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldNotAddTestAdapterPathIfVSTestTraceDataCollectorDirectoryPathIsEmpty() - { - this.vsTestTask.VSTestTraceDataCollectorDirectoryPath = string.Empty; - this.vsTestTask.VSTestSetting = @"c:\path\to\sample.runsettings"; - this.vsTestTask.VSTestCollect = new string[] { "code coverage" }; + const string expectedArg = "--testAdapterPath:c:\\path\\to\\tracedatacollector\\"; + CollectionAssert.Contains(allArguments, expectedArg, $"Expected argument: '''{expectedArg}''' not present in [{string.Join(", ", allArguments)}]"); + } - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + [TestMethod] + public void CreateArgumentShouldNotAddTestAdapterPathIfVsTestTraceDataCollectorDirectoryPathIsEmpty() + { + _vsTestTask.VSTestTraceDataCollectorDirectoryPath = string.Empty; + _vsTestTask.VSTestSetting = @"c:\path\to\sample.runsettings"; + _vsTestTask.VSTestCollect = new string[] { "code coverage" }; - Assert.IsNull(Array.Find(allArguments, arg => arg.Contains("--testAdapterPath:"))); - } + var allArguments = _vsTestTask.CreateArgument().ToArray(); - [TestMethod] - public void CreateArgumentShouldAddNoLogoOptionIfSpecifiedByUser() - { - this.vsTestTask.VSTestNoLogo = "--nologo"; - var allArguments = this.vsTestTask.CreateArgument().ToArray(); + Assert.IsNull(Array.Find(allArguments, arg => arg.Contains("--testAdapterPath:"))); + } + + [TestMethod] + public void CreateArgumentShouldAddNoLogoOptionIfSpecifiedByUser() + { + _vsTestTask.VSTestNoLogo = "--nologo"; + var allArguments = _vsTestTask.CreateArgument().ToArray(); - Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--nologo"))); - } + Assert.IsNotNull(Array.Find(allArguments, arg => arg.Contains("--nologo"))); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Client.UnitTests/AttachmentsProcessing/TestRunAttachmentsProcessingEventsHandlerTests.cs b/test/Microsoft.TestPlatform.Client.UnitTests/AttachmentsProcessing/TestRunAttachmentsProcessingEventsHandlerTests.cs index 2988e594c6..be0fb87d1d 100644 --- a/test/Microsoft.TestPlatform.Client.UnitTests/AttachmentsProcessing/TestRunAttachmentsProcessingEventsHandlerTests.cs +++ b/test/Microsoft.TestPlatform.Client.UnitTests/AttachmentsProcessing/TestRunAttachmentsProcessingEventsHandlerTests.cs @@ -1,67 +1,66 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Client.UnitTests.TestRunAttachmentsProcessing -{ - using Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.Client.UnitTests.TestRunAttachmentsProcessing; - using Moq; +using Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using VisualStudio.TestTools.UnitTesting; - [TestClass] - public class TestRunAttachmentsProcessingEventsHandlerTests - { - private readonly Mock mockCommunicationManager; - private readonly ITestRunAttachmentsProcessingEventsHandler handler; +using Moq; - public TestRunAttachmentsProcessingEventsHandlerTests() - { - this.mockCommunicationManager = new Mock(); - this.handler = new TestRunAttachmentsProcessingEventsHandler(mockCommunicationManager.Object); - } +[TestClass] +public class TestRunAttachmentsProcessingEventsHandlerTests +{ + private readonly Mock _mockCommunicationManager; + private readonly ITestRunAttachmentsProcessingEventsHandler _handler; - [TestMethod] - public void EventsHandlerHandleLogMessageShouldSendTestMessage() - { - string message = "error message"; + public TestRunAttachmentsProcessingEventsHandlerTests() + { + _mockCommunicationManager = new Mock(); + _handler = new TestRunAttachmentsProcessingEventsHandler(_mockCommunicationManager.Object); + } - handler.HandleLogMessage(TestMessageLevel.Error, message); + [TestMethod] + public void EventsHandlerHandleLogMessageShouldSendTestMessage() + { + string message = "error message"; - mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.Is(p => p.MessageLevel == TestMessageLevel.Error && p.Message == message))); - } + _handler.HandleLogMessage(TestMessageLevel.Error, message); - [TestMethod] - public void EventsHandlerHandleTestRunAttachmentsProcessingCompleteShouldSendAttachmentsProcessingCompleteMessage() - { - var attachments = new[] { new AttachmentSet(new System.Uri("http://www.bing.com/"), "code coverage") }; - var args = new TestRunAttachmentsProcessingCompleteEventArgs(false, null); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.Is(p => p.MessageLevel == TestMessageLevel.Error && p.Message == message))); + } - handler.HandleTestRunAttachmentsProcessingComplete(args, attachments); + [TestMethod] + public void EventsHandlerHandleTestRunAttachmentsProcessingCompleteShouldSendAttachmentsProcessingCompleteMessage() + { + var attachments = new[] { new AttachmentSet(new System.Uri("http://www.bing.com/"), "code coverage") }; + var args = new TestRunAttachmentsProcessingCompleteEventArgs(false, null); + + _handler.HandleTestRunAttachmentsProcessingComplete(args, attachments); - mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, It.Is(p => p.Attachments == attachments && p.AttachmentsProcessingCompleteEventArgs == args))); - } + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, It.Is(p => p.Attachments == attachments && p.AttachmentsProcessingCompleteEventArgs == args))); + } - [TestMethod] - public void EventsHandlerHandleTestRunAttachmentsProcessingProgressShouldSendAttachmentsProcessingProgressMessage() - { - var args = new TestRunAttachmentsProcessingProgressEventArgs(1, new[] { new System.Uri("http://www.bing.com/") }, 90, 2); + [TestMethod] + public void EventsHandlerHandleTestRunAttachmentsProcessingProgressShouldSendAttachmentsProcessingProgressMessage() + { + var args = new TestRunAttachmentsProcessingProgressEventArgs(1, new[] { new System.Uri("http://www.bing.com/") }, 90, 2); - handler.HandleTestRunAttachmentsProcessingProgress(args); + _handler.HandleTestRunAttachmentsProcessingProgress(args); - mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestRunAttachmentsProcessingProgress, It.Is(p => p.AttachmentsProcessingProgressEventArgs == args))); - } + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestRunAttachmentsProcessingProgress, It.Is(p => p.AttachmentsProcessingProgressEventArgs == args))); + } - [TestMethod] - public void EventsHandlerHandleRawMessageShouldDoNothing() - { - handler.HandleRawMessage("any"); + [TestMethod] + public void EventsHandlerHandleRawMessageShouldDoNothing() + { + _handler.HandleRawMessage("any"); - mockCommunicationManager.Verify(cm => cm.SendMessage(It.IsAny()), Times.Never); - mockCommunicationManager.Verify(cm => cm.SendMessage(It.IsAny(), It.IsAny()), Times.Never); - } + _mockCommunicationManager.Verify(cm => cm.SendMessage(It.IsAny()), Times.Never); + _mockCommunicationManager.Verify(cm => cm.SendMessage(It.IsAny(), It.IsAny()), Times.Never); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Client.UnitTests/DesignMode/DesignModeClientTests.cs b/test/Microsoft.TestPlatform.Client.UnitTests/DesignMode/DesignModeClientTests.cs index 9cf49fb843..6b43d17bfd 100644 --- a/test/Microsoft.TestPlatform.Client.UnitTests/DesignMode/DesignModeClientTests.cs +++ b/test/Microsoft.TestPlatform.Client.UnitTests/DesignMode/DesignModeClientTests.cs @@ -1,748 +1,741 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Client.UnitTests.DesignMode +namespace Microsoft.VisualStudio.TestPlatform.Client.UnitTests.DesignMode; + +using System; +using System.Linq; +using System.Net; +using System.Threading; +using System.Threading.Tasks; + +using Microsoft.VisualStudio.TestPlatform.Client.DesignMode; +using TestRunAttachmentsProcessing; +using RequestHelper; +using Common.Interfaces; +using CommunicationUtilities; +using CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using CrossPlatEngine; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using ObjectModel.Logging; +using PlatformAbstractions.Interfaces; +using TestTools.UnitTesting; + +using Moq; + +using Newtonsoft.Json.Linq; + +[TestClass] +public class DesignModeClientTests { - using System; - using System.Linq; - using System.Net; - using System.Threading; - using System.Threading.Tasks; - - using Microsoft.VisualStudio.TestPlatform.Client.DesignMode; - using Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing; - using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - using Newtonsoft.Json.Linq; - - [TestClass] - public class DesignModeClientTests + private const int Timeout = 15 * 1000; + + private const int PortNumber = 123; + + private readonly Mock _mockTestRequestManager; + + private readonly Mock _mockCommunicationManager; + + private readonly DesignModeClient _designModeClient; + + private readonly int _protocolVersion = 5; + + private readonly AutoResetEvent _completeEvent; + + private readonly Mock _mockPlatformEnvrironment; + + public DesignModeClientTests() { - private const int Timeout = 15 * 1000; + _mockTestRequestManager = new Mock(); + _mockCommunicationManager = new Mock(); + _mockPlatformEnvrironment = new Mock(); + _designModeClient = new DesignModeClient(_mockCommunicationManager.Object, JsonDataSerializer.Instance, _mockPlatformEnvrironment.Object); + _completeEvent = new AutoResetEvent(false); + } - private const int PortNumber = 123; + [TestMethod] + public void DesignModeClientBeforeConnectInstanceShouldReturnNull() + { + Assert.IsNull(DesignModeClient.Instance); + } - private readonly Mock mockTestRequestManager; + [TestMethod] + public void DesignModeClientInitializeShouldInstantiateClassAndCreateClient() + { + DesignModeClient.Initialize(); + Assert.IsNotNull(DesignModeClient.Instance); + } - private readonly Mock mockCommunicationManager; + [TestMethod] + public void TestRunMessageHandlerShouldCallCommmunicationManagerIfMessageisError() + { + _mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny())); - private readonly DesignModeClient designModeClient; + _designModeClient.TestRunMessageHandler(new object(), new TestRunMessageEventArgs(TestMessageLevel.Error, "message")); - private readonly int protocolVersion = 5; + _mockCommunicationManager.Verify(cm => cm.SendMessage(It.IsAny(), It.IsAny()), Times.Once()); + } - private readonly AutoResetEvent completeEvent; + [TestMethod] + public void TestRunMessageHandlerShouldCallCommmunicationManagerIfMessageisWarning() + { + _mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny())); - private readonly Mock mockPlatformEnvrironment; + _designModeClient.TestRunMessageHandler(new object(), new TestRunMessageEventArgs(TestMessageLevel.Warning, "message")); - public DesignModeClientTests() - { - this.mockTestRequestManager = new Mock(); - this.mockCommunicationManager = new Mock(); - this.mockPlatformEnvrironment = new Mock(); - this.designModeClient = new DesignModeClient(this.mockCommunicationManager.Object, JsonDataSerializer.Instance, this.mockPlatformEnvrironment.Object); - this.completeEvent = new AutoResetEvent(false); - } + _mockCommunicationManager.Verify(cm => cm.SendMessage(It.IsAny(), It.IsAny()), Times.Once()); + } - [TestMethod] - public void DesignModeClientBeforeConnectInstanceShouldReturnNull() - { - Assert.IsNull(DesignModeClient.Instance); - } + [TestMethod] + public void TestRunMessageHandlerShouldNotCallCommmunicationManagerIfMessageisInformational() + { + _mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny())); - [TestMethod] - public void DesignModeClientInitializeShouldInstantiateClassAndCreateClient() - { - DesignModeClient.Initialize(); - Assert.IsNotNull(DesignModeClient.Instance); - } + _designModeClient.TestRunMessageHandler(new object(), new TestRunMessageEventArgs(TestMessageLevel.Informational, "message")); - [TestMethod] - public void TestRunMessageHandlerShouldCallCommmunicationManagerIfMessageisError() - { - this.mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny())); + _mockCommunicationManager.Verify(cm => cm.SendMessage(It.IsAny(), It.IsAny()), Times.Never()); + } - this.designModeClient.TestRunMessageHandler(new object(), new TestRunMessageEventArgs(TestMessageLevel.Error, "message")); + [TestMethod] + public void DesignModeClientConnectShouldSetupChannel() + { + var verCheck = new Message { MessageType = MessageType.VersionCheck, Payload = _protocolVersion }; + var sessionEnd = new Message { MessageType = MessageType.SessionEnd }; + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); + _mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(verCheck).Returns(sessionEnd); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(It.IsAny(),It.IsAny()), Times.Once()); - } + _designModeClient.ConnectToClientAndProcessRequests(PortNumber, _mockTestRequestManager.Object); - [TestMethod] - public void TestRunMessageHandlerShouldCallCommmunicationManagerIfMessageisWarning() - { - this.mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny())); + _mockCommunicationManager.Verify(cm => cm.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, PortNumber)), Times.Once); + _mockCommunicationManager.Verify(cm => cm.WaitForServerConnection(It.IsAny()), Times.Once); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.SessionConnected), Times.Once()); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, _protocolVersion), Times.Once()); + } - this.designModeClient.TestRunMessageHandler(new object(), new TestRunMessageEventArgs(TestMessageLevel.Warning, "message")); + [TestMethod] + public void DesignModeClientConnectShouldNotSendConnectedIfServerConnectionTimesOut() + { + var verCheck = new Message { MessageType = MessageType.VersionCheck, Payload = _protocolVersion }; + var sessionEnd = new Message { MessageType = MessageType.SessionEnd }; + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(false); + _mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(verCheck).Returns(sessionEnd); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(It.IsAny(), It.IsAny()), Times.Once()); - } + Assert.ThrowsException(() => _designModeClient.ConnectToClientAndProcessRequests(PortNumber, _mockTestRequestManager.Object)); - [TestMethod] - public void TestRunMessageHandlerShouldNotCallCommmunicationManagerIfMessageisInformational() - { - this.mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny())); + _mockCommunicationManager.Verify(cm => cm.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, PortNumber)), Times.Once); + _mockCommunicationManager.Verify(cm => cm.WaitForServerConnection(It.IsAny()), Times.Once); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.SessionConnected), Times.Never); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, It.IsAny()), Times.Never); + } - this.designModeClient.TestRunMessageHandler(new object(), new TestRunMessageEventArgs(TestMessageLevel.Informational, "message")); + [TestMethod] + public void DesignModeClientDuringConnectShouldHighestCommonVersionWhenReceivedVersionIsGreaterThanSupportedVersion() + { + var verCheck = new Message { MessageType = MessageType.VersionCheck, Payload = 5 }; + var sessionEnd = new Message { MessageType = MessageType.SessionEnd }; + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); + _mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(verCheck).Returns(sessionEnd); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(It.IsAny(), It.IsAny()), Times.Never()); - } + _designModeClient.ConnectToClientAndProcessRequests(PortNumber, _mockTestRequestManager.Object); - [TestMethod] - public void DesignModeClientConnectShouldSetupChannel() - { - var verCheck = new Message { MessageType = MessageType.VersionCheck, Payload = this.protocolVersion }; - var sessionEnd = new Message { MessageType = MessageType.SessionEnd }; - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); - this.mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(verCheck).Returns(sessionEnd); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, _protocolVersion), Times.Once()); + } - this.designModeClient.ConnectToClientAndProcessRequests(PortNumber, this.mockTestRequestManager.Object); + [TestMethod] + public void DesignModeClientDuringConnectShouldHighestCommonVersionWhenReceivedVersionIsSmallerThanSupportedVersion() + { + var verCheck = new Message { MessageType = MessageType.VersionCheck, Payload = 1 }; + var sessionEnd = new Message { MessageType = MessageType.SessionEnd }; + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); + _mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(verCheck).Returns(sessionEnd); - this.mockCommunicationManager.Verify(cm => cm.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, PortNumber)), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.WaitForServerConnection(It.IsAny()), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.SessionConnected), Times.Once()); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, this.protocolVersion), Times.Once()); - } + _designModeClient.ConnectToClientAndProcessRequests(PortNumber, _mockTestRequestManager.Object); - [TestMethod] - public void DesignModeClientConnectShouldNotSendConnectedIfServerConnectionTimesOut() - { - var verCheck = new Message { MessageType = MessageType.VersionCheck, Payload = this.protocolVersion }; - var sessionEnd = new Message { MessageType = MessageType.SessionEnd }; - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(false); - this.mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(verCheck).Returns(sessionEnd); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, 1), Times.Once()); + } - Assert.ThrowsException(() => this.designModeClient.ConnectToClientAndProcessRequests(PortNumber, this.mockTestRequestManager.Object)); + [TestMethod] + public void DesignModeClientWithGetTestRunnerProcessStartInfoShouldDeserializeTestsWithTraitsCorrectly() + { + // Arrange. + var testCase = new TestCase("A.C.M", new Uri("d:\\executor"), "A.dll"); + testCase.Traits.Add(new Trait("foo", "bar")); - this.mockCommunicationManager.Verify(cm => cm.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, PortNumber)), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.WaitForServerConnection(It.IsAny()), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.SessionConnected), Times.Never); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, It.IsAny()), Times.Never); - } + var testList = new System.Collections.Generic.List { testCase }; + var testRunPayload = new TestRunRequestPayload { RunSettings = null, TestCases = testList }; - [TestMethod] - public void DesignModeClientDuringConnectShouldHighestCommonVersionWhenReceivedVersionIsGreaterThanSupportedVersion() + var getProcessStartInfoMessage = new Message { - var verCheck = new Message { MessageType = MessageType.VersionCheck, Payload = 5 }; - var sessionEnd = new Message { MessageType = MessageType.SessionEnd }; - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); - this.mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(verCheck).Returns(sessionEnd); + MessageType = MessageType.GetTestRunnerProcessStartInfoForRunSelected, + Payload = JToken.FromObject("random") + }; - this.designModeClient.ConnectToClientAndProcessRequests(PortNumber, this.mockTestRequestManager.Object); + var sessionEnd = new Message { MessageType = MessageType.SessionEnd }; + TestRunRequestPayload receivedTestRunPayload = null; + var allTasksComplete = new ManualResetEvent(false); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, this.protocolVersion), Times.Once()); - } + // Setup mocks. + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); + _mockCommunicationManager.Setup(cm => cm.DeserializePayload(getProcessStartInfoMessage)) + .Returns(testRunPayload); - [TestMethod] - public void DesignModeClientDuringConnectShouldHighestCommonVersionWhenReceivedVersionIsSmallerThanSupportedVersion() - { - var verCheck = new Message { MessageType = MessageType.VersionCheck, Payload = 1 }; - var sessionEnd = new Message { MessageType = MessageType.SessionEnd }; - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); - this.mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(verCheck).Returns(sessionEnd); + _mockTestRequestManager.Setup( + trm => + trm.RunTests( + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny())) + .Callback( + (TestRunRequestPayload trp, + ITestHostLauncher testHostManager, + ITestRunEventsRegistrar testRunEventsRegistrar, + ProtocolConfig config) => + { + receivedTestRunPayload = trp; + allTasksComplete.Set(); + }); - this.designModeClient.ConnectToClientAndProcessRequests(PortNumber, this.mockTestRequestManager.Object); + _mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()) + .Returns(getProcessStartInfoMessage) + .Returns(sessionEnd); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, 1), Times.Once()); - } + // Act. + _designModeClient.ConnectToClientAndProcessRequests(0, _mockTestRequestManager.Object); - [TestMethod] - public void DesignModeClientWithGetTestRunnerProcessStartInfoShouldDeserializeTestsWithTraitsCorrectly() - { - // Arrange. - var testCase = new TestCase("A.C.M", new Uri("d:\\executor"), "A.dll"); - testCase.Traits.Add(new Trait("foo", "bar")); - - var testList = new System.Collections.Generic.List { testCase }; - var testRunPayload = new TestRunRequestPayload { RunSettings = null, TestCases = testList }; - - var getProcessStartInfoMessage = new Message - { - MessageType = MessageType.GetTestRunnerProcessStartInfoForRunSelected, - Payload = JToken.FromObject("random") - }; - - var sessionEnd = new Message { MessageType = MessageType.SessionEnd }; - TestRunRequestPayload receivedTestRunPayload = null; - var allTasksComplete = new ManualResetEvent(false); - - // Setup mocks. - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); - this.mockCommunicationManager.Setup(cm => cm.DeserializePayload(getProcessStartInfoMessage)) - .Returns(testRunPayload); - - this.mockTestRequestManager.Setup( - trm => - trm.RunTests( - It.IsAny(), - It.IsAny(), - It.IsAny(), - It.IsAny())) - .Callback( - (TestRunRequestPayload trp, - ITestHostLauncher testHostManager, - ITestRunEventsRegistrar testRunEventsRegistrar, - ProtocolConfig config) => - { - receivedTestRunPayload = trp; - allTasksComplete.Set(); - }); - - this.mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()) - .Returns(getProcessStartInfoMessage) - .Returns(sessionEnd); - - // Act. - this.designModeClient.ConnectToClientAndProcessRequests(0, this.mockTestRequestManager.Object); - - // wait for the internal spawned of tasks to complete. - Assert.IsTrue(allTasksComplete.WaitOne(1000), "Timed out waiting for mock request manager."); - - // Assert. - Assert.IsNotNull(receivedTestRunPayload); - Assert.IsNotNull(receivedTestRunPayload.TestCases); - Assert.AreEqual(1, receivedTestRunPayload.TestCases.Count); - - // Validate traits - var traits = receivedTestRunPayload.TestCases.ToArray()[0].Traits; - Assert.AreEqual("foo", traits.ToArray()[0].Name); - Assert.AreEqual("bar", traits.ToArray()[0].Value); - } + // wait for the internal spawned of tasks to complete. + Assert.IsTrue(allTasksComplete.WaitOne(1000), "Timed out waiting for mock request manager."); + + // Assert. + Assert.IsNotNull(receivedTestRunPayload); + Assert.IsNotNull(receivedTestRunPayload.TestCases); + Assert.AreEqual(1, receivedTestRunPayload.TestCases.Count); - [TestMethod] - public void DesignModeClientWithRunSelectedTestCasesShouldDeserializeTestsWithTraitsCorrectly() + // Validate traits + var traits = receivedTestRunPayload.TestCases.ToArray()[0].Traits; + Assert.AreEqual("foo", traits.ToArray()[0].Name); + Assert.AreEqual("bar", traits.ToArray()[0].Value); + } + + [TestMethod] + public void DesignModeClientWithRunSelectedTestCasesShouldDeserializeTestsWithTraitsCorrectly() + { + // Arrange. + var testCase = new TestCase("A.C.M", new Uri("d:\\executor"), "A.dll"); + testCase.Traits.Add(new Trait("foo", "bar")); + + var testList = new System.Collections.Generic.List { testCase }; + var testRunPayload = new TestRunRequestPayload { RunSettings = null, TestCases = testList }; + + var getProcessStartInfoMessage = new Message { - // Arrange. - var testCase = new TestCase("A.C.M", new Uri("d:\\executor"), "A.dll"); - testCase.Traits.Add(new Trait("foo", "bar")); - - var testList = new System.Collections.Generic.List { testCase }; - var testRunPayload = new TestRunRequestPayload { RunSettings = null, TestCases = testList }; - - var getProcessStartInfoMessage = new Message - { - MessageType = MessageType.TestRunSelectedTestCasesDefaultHost, - Payload = JToken.FromObject("random") - }; - - var sessionEnd = new Message { MessageType = MessageType.SessionEnd }; - TestRunRequestPayload receivedTestRunPayload = null; - var allTasksComplete = new ManualResetEvent(false); - - // Setup mocks. - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); - this.mockCommunicationManager.Setup(cm => cm.DeserializePayload(getProcessStartInfoMessage)) - .Returns(testRunPayload); - this.mockTestRequestManager.Setup( + MessageType = MessageType.TestRunSelectedTestCasesDefaultHost, + Payload = JToken.FromObject("random") + }; + + var sessionEnd = new Message { MessageType = MessageType.SessionEnd }; + TestRunRequestPayload receivedTestRunPayload = null; + var allTasksComplete = new ManualResetEvent(false); + + // Setup mocks. + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); + _mockCommunicationManager.Setup(cm => cm.DeserializePayload(getProcessStartInfoMessage)) + .Returns(testRunPayload); + _mockTestRequestManager.Setup( trm => - trm.RunTests( - It.IsAny(), - It.IsAny(), - It.IsAny(), - It.IsAny())) - .Callback( - (TestRunRequestPayload trp, - ITestHostLauncher testHostManager, - ITestRunEventsRegistrar testRunEventsRegistrar, - ProtocolConfig config) => - { - receivedTestRunPayload = trp; - allTasksComplete.Set(); - }); - this.mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()) - .Returns(getProcessStartInfoMessage) - .Returns(sessionEnd); - - // Act. - this.designModeClient.ConnectToClientAndProcessRequests(0, this.mockTestRequestManager.Object); - - // wait for the internal spawned of tasks to complete. - allTasksComplete.WaitOne(1000); - - // Assert. - Assert.IsNotNull(receivedTestRunPayload); - Assert.IsNotNull(receivedTestRunPayload.TestCases); - Assert.AreEqual(1, receivedTestRunPayload.TestCases.Count); - - // Validate traits - var traits = receivedTestRunPayload.TestCases.ToArray()[0].Traits; - Assert.AreEqual("foo", traits.ToArray()[0].Name); - Assert.AreEqual("bar", traits.ToArray()[0].Value); - } + trm.RunTests( + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny())) + .Callback( + (TestRunRequestPayload trp, + ITestHostLauncher testHostManager, + ITestRunEventsRegistrar testRunEventsRegistrar, + ProtocolConfig config) => + { + receivedTestRunPayload = trp; + allTasksComplete.Set(); + }); + _mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()) + .Returns(getProcessStartInfoMessage) + .Returns(sessionEnd); - [TestMethod] - public void DesignModeClientOnBadConnectionShouldStopServerAndThrowTimeoutException() - { - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(false); + // Act. + _designModeClient.ConnectToClientAndProcessRequests(0, _mockTestRequestManager.Object); - var ex = Assert.ThrowsException(() => this.designModeClient.ConnectToClientAndProcessRequests(PortNumber, this.mockTestRequestManager.Object)); - Assert.AreEqual("vstest.console process failed to connect to translation layer process after 90 seconds. This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout.", ex.Message); + // wait for the internal spawned of tasks to complete. + allTasksComplete.WaitOne(1000); - this.mockCommunicationManager.Verify(cm => cm.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, PortNumber)), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.WaitForServerConnection(It.IsAny()), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.StopClient(), Times.Once); - } + // Assert. + Assert.IsNotNull(receivedTestRunPayload); + Assert.IsNotNull(receivedTestRunPayload.TestCases); + Assert.AreEqual(1, receivedTestRunPayload.TestCases.Count); - [TestMethod] - public void DesignModeClientShouldStopCommunicationOnParentProcessExit() - { - this.mockPlatformEnvrironment.Setup(pe => pe.Exit(It.IsAny())); - this.designModeClient.HandleParentProcessExit(); + // Validate traits + var traits = receivedTestRunPayload.TestCases.ToArray()[0].Traits; + Assert.AreEqual("foo", traits.ToArray()[0].Name); + Assert.AreEqual("bar", traits.ToArray()[0].Value); + } - this.mockCommunicationManager.Verify(cm => cm.StopClient(), Times.Once); - } + [TestMethod] + public void DesignModeClientOnBadConnectionShouldStopServerAndThrowTimeoutException() + { + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(false); - [TestMethod] - public void DesignModeClientLaunchCustomHostMustReturnIfAckComes() - { - var testableDesignModeClient = new TestableDesignModeClient(this.mockCommunicationManager.Object, JsonDataSerializer.Instance, this.mockPlatformEnvrironment.Object); + var ex = Assert.ThrowsException(() => _designModeClient.ConnectToClientAndProcessRequests(PortNumber, _mockTestRequestManager.Object)); + Assert.AreEqual("vstest.console process failed to connect to translation layer process after 90 seconds. This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout.", ex.Message); - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); + _mockCommunicationManager.Verify(cm => cm.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, PortNumber)), Times.Once); + _mockCommunicationManager.Verify(cm => cm.WaitForServerConnection(It.IsAny()), Times.Once); + _mockCommunicationManager.Verify(cm => cm.StopClient(), Times.Once); + } - var expectedProcessId = 1234; - Action sendMessageAction = () => - { - testableDesignModeClient.InvokeCustomHostLaunchAckCallback(expectedProcessId, null); - }; + [TestMethod] + public void DesignModeClientShouldStopCommunicationOnParentProcessExit() + { + _mockPlatformEnvrironment.Setup(pe => pe.Exit(It.IsAny())); + _designModeClient.HandleParentProcessExit(); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.CustomTestHostLaunch, It.IsAny())). - Callback(() => Task.Run(sendMessageAction)); + _mockCommunicationManager.Verify(cm => cm.StopClient(), Times.Once); + } - var info = new TestProcessStartInfo(); - var processId = testableDesignModeClient.LaunchCustomHost(info, CancellationToken.None); + [TestMethod] + public void DesignModeClientLaunchCustomHostMustReturnIfAckComes() + { + var testableDesignModeClient = new TestableDesignModeClient(_mockCommunicationManager.Object, JsonDataSerializer.Instance, _mockPlatformEnvrironment.Object); - Assert.AreEqual(expectedProcessId, processId); - } + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); - [TestMethod] - [ExpectedException(typeof(TestPlatformException))] - public void DesignModeClientLaunchCustomHostMustThrowIfInvalidAckComes() - { - var testableDesignModeClient = new TestableDesignModeClient(this.mockCommunicationManager.Object, JsonDataSerializer.Instance, this.mockPlatformEnvrironment.Object); + var expectedProcessId = 1234; + Action sendMessageAction = () => testableDesignModeClient.InvokeCustomHostLaunchAckCallback(expectedProcessId, null); - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); + _mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.CustomTestHostLaunch, It.IsAny())). + Callback(() => Task.Run(sendMessageAction)); - var expectedProcessId = -1; - Action sendMessageAction = () => - { - testableDesignModeClient.InvokeCustomHostLaunchAckCallback(expectedProcessId, "Dummy"); - }; + var info = new TestProcessStartInfo(); + var processId = testableDesignModeClient.LaunchCustomHost(info, CancellationToken.None); - this.mockCommunicationManager - .Setup(cm => cm.SendMessage(MessageType.CustomTestHostLaunch, It.IsAny())) - .Callback(() => Task.Run(sendMessageAction)); + Assert.AreEqual(expectedProcessId, processId); + } - var info = new TestProcessStartInfo(); - testableDesignModeClient.LaunchCustomHost(info, CancellationToken.None); - } + [TestMethod] + [ExpectedException(typeof(TestPlatformException))] + public void DesignModeClientLaunchCustomHostMustThrowIfInvalidAckComes() + { + var testableDesignModeClient = new TestableDesignModeClient(_mockCommunicationManager.Object, JsonDataSerializer.Instance, _mockPlatformEnvrironment.Object); - [TestMethod] - [ExpectedException(typeof(TestPlatformException))] - public void DesignModeClientLaunchCustomHostMustThrowIfCancellationOccursBeforeHostLaunch() - { - var testableDesignModeClient = new TestableDesignModeClient(this.mockCommunicationManager.Object, JsonDataSerializer.Instance, this.mockPlatformEnvrironment.Object); + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); - var info = new TestProcessStartInfo(); - var cancellationTokenSource = new CancellationTokenSource(); - cancellationTokenSource.Cancel(); + var expectedProcessId = -1; + Action sendMessageAction = () => testableDesignModeClient.InvokeCustomHostLaunchAckCallback(expectedProcessId, "Dummy"); - testableDesignModeClient.LaunchCustomHost(info, cancellationTokenSource.Token); - } + _mockCommunicationManager + .Setup(cm => cm.SendMessage(MessageType.CustomTestHostLaunch, It.IsAny())) + .Callback(() => Task.Run(sendMessageAction)); - [TestMethod] - public void DesignModeClientConnectShouldSendTestMessageAndDiscoverCompleteOnExceptionInDiscovery() - { - var payload = new DiscoveryRequestPayload(); - var startDiscovery = new Message { MessageType = MessageType.StartDiscovery, Payload = JToken.FromObject(payload) }; - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); - this.mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(startDiscovery); - this.mockCommunicationManager - .Setup(cm => cm.SendMessage(MessageType.DiscoveryComplete, It.IsAny())) - .Callback(() => completeEvent.Set()); - this.mockTestRequestManager.Setup( - rm => rm.DiscoverTests( - It.IsAny(), - It.IsAny(), - It.IsAny())) - .Throws(new Exception()); + var info = new TestProcessStartInfo(); + testableDesignModeClient.LaunchCustomHost(info, CancellationToken.None); + } - this.designModeClient.ConnectToClientAndProcessRequests(PortNumber, this.mockTestRequestManager.Object); + [TestMethod] + [ExpectedException(typeof(TestPlatformException))] + public void DesignModeClientLaunchCustomHostMustThrowIfCancellationOccursBeforeHostLaunch() + { + var testableDesignModeClient = new TestableDesignModeClient(_mockCommunicationManager.Object, JsonDataSerializer.Instance, _mockPlatformEnvrironment.Object); - Assert.IsTrue(this.completeEvent.WaitOne(Timeout), "Discovery not completed."); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.IsAny()), Times.Once()); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.DiscoveryComplete, It.IsAny()), Times.Once()); - } + var info = new TestProcessStartInfo(); + var cancellationTokenSource = new CancellationTokenSource(); + cancellationTokenSource.Cancel(); - [TestMethod] - public void DesignModeClientConnectShouldSendTestMessageAndDiscoverCompleteOnTestPlatformExceptionInDiscovery() - { - var payload = new DiscoveryRequestPayload(); - var startDiscovery = new Message { MessageType = MessageType.StartDiscovery, Payload = JToken.FromObject(payload) }; - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); - this.mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(startDiscovery); - this.mockCommunicationManager - .Setup(cm => cm.SendMessage(MessageType.DiscoveryComplete, It.IsAny())) - .Callback(() => completeEvent.Set()); - this.mockTestRequestManager.Setup( - rm => rm.DiscoverTests( - It.IsAny(), - It.IsAny(), - It.IsAny())) - .Throws(new TestPlatformException("Hello world")); + testableDesignModeClient.LaunchCustomHost(info, cancellationTokenSource.Token); + } - this.designModeClient.ConnectToClientAndProcessRequests(PortNumber, this.mockTestRequestManager.Object); + [TestMethod] + public void DesignModeClientConnectShouldSendTestMessageAndDiscoverCompleteOnExceptionInDiscovery() + { + var payload = new DiscoveryRequestPayload(); + var startDiscovery = new Message { MessageType = MessageType.StartDiscovery, Payload = JToken.FromObject(payload) }; + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); + _mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(startDiscovery); + _mockCommunicationManager + .Setup(cm => cm.SendMessage(MessageType.DiscoveryComplete, It.IsAny())) + .Callback(() => _completeEvent.Set()); + _mockTestRequestManager.Setup( + rm => rm.DiscoverTests( + It.IsAny(), + It.IsAny(), + It.IsAny())) + .Throws(new Exception()); - Assert.IsTrue(this.completeEvent.WaitOne(Timeout), "Discovery not completed."); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.IsAny()), Times.Once()); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.DiscoveryComplete, It.IsAny()), Times.Once()); - } + _designModeClient.ConnectToClientAndProcessRequests(PortNumber, _mockTestRequestManager.Object); - [TestMethod] - public void DesignModeClientConnectShouldSendTestMessageAndAttachmentsProcessingCompleteOnExceptionInAttachmentsProcessing() - { - var payload = new TestRunAttachmentsProcessingPayload(); - var startAttachmentsProcessing = new Message { MessageType = MessageType.TestRunAttachmentsProcessingStart, Payload = JToken.FromObject(payload) }; - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); - this.mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(startAttachmentsProcessing); - this.mockCommunicationManager - .Setup(cm => cm.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, It.IsAny())) - .Callback(() => completeEvent.Set()); - this.mockTestRequestManager.Setup( - rm => rm.ProcessTestRunAttachments( - It.IsAny(), - It.IsAny(), - It.IsAny())) - .Throws(new Exception()); + Assert.IsTrue(_completeEvent.WaitOne(Timeout), "Discovery not completed."); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.IsAny()), Times.Once()); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.DiscoveryComplete, It.IsAny()), Times.Once()); + } - this.designModeClient.ConnectToClientAndProcessRequests(PortNumber, this.mockTestRequestManager.Object); + [TestMethod] + public void DesignModeClientConnectShouldSendTestMessageAndDiscoverCompleteOnTestPlatformExceptionInDiscovery() + { + var payload = new DiscoveryRequestPayload(); + var startDiscovery = new Message { MessageType = MessageType.StartDiscovery, Payload = JToken.FromObject(payload) }; + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); + _mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(startDiscovery); + _mockCommunicationManager + .Setup(cm => cm.SendMessage(MessageType.DiscoveryComplete, It.IsAny())) + .Callback(() => _completeEvent.Set()); + _mockTestRequestManager.Setup( + rm => rm.DiscoverTests( + It.IsAny(), + It.IsAny(), + It.IsAny())) + .Throws(new TestPlatformException("Hello world")); - Assert.IsTrue(this.completeEvent.WaitOne(Timeout), "AttachmentsProcessing not completed."); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.IsAny()), Times.Once()); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, It.Is(p => p.Attachments == null)), Times.Once()); - } + _designModeClient.ConnectToClientAndProcessRequests(PortNumber, _mockTestRequestManager.Object); - [TestMethod] - public void DesignModeClientConnectShouldSendTestMessageAndDiscoverCompleteOnTestPlatformExceptionInAttachmentsProcessing() - { - var payload = new TestRunAttachmentsProcessingPayload(); - var startAttachmentsProcessing = new Message { MessageType = MessageType.TestRunAttachmentsProcessingStart, Payload = JToken.FromObject(payload) }; - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); - this.mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(startAttachmentsProcessing); - this.mockCommunicationManager - .Setup(cm => cm.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, It.IsAny())) - .Callback(() => completeEvent.Set()); - this.mockTestRequestManager.Setup( - rm => rm.ProcessTestRunAttachments( - It.IsAny(), - It.IsAny(), - It.IsAny())) - .Throws(new TestPlatformException("Hello world")); + Assert.IsTrue(_completeEvent.WaitOne(Timeout), "Discovery not completed."); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.IsAny()), Times.Once()); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.DiscoveryComplete, It.IsAny()), Times.Once()); + } - this.designModeClient.ConnectToClientAndProcessRequests(PortNumber, this.mockTestRequestManager.Object); + [TestMethod] + public void DesignModeClientConnectShouldSendTestMessageAndAttachmentsProcessingCompleteOnExceptionInAttachmentsProcessing() + { + var payload = new TestRunAttachmentsProcessingPayload(); + var startAttachmentsProcessing = new Message { MessageType = MessageType.TestRunAttachmentsProcessingStart, Payload = JToken.FromObject(payload) }; + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); + _mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(startAttachmentsProcessing); + _mockCommunicationManager + .Setup(cm => cm.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, It.IsAny())) + .Callback(() => _completeEvent.Set()); + _mockTestRequestManager.Setup( + rm => rm.ProcessTestRunAttachments( + It.IsAny(), + It.IsAny(), + It.IsAny())) + .Throws(new Exception()); - Assert.IsTrue(this.completeEvent.WaitOne(Timeout), "AttachmentsProcessing not completed."); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.IsAny()), Times.Once()); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, It.Is(p => p.Attachments == null)), Times.Once()); - } + _designModeClient.ConnectToClientAndProcessRequests(PortNumber, _mockTestRequestManager.Object); - [TestMethod] - public void DesignModeClientConnectShouldCallRequestManagerForAttachmentsProcessingStart() - { - var payload = new TestRunAttachmentsProcessingPayload(); - var startAttachmentsProcessing = new Message { MessageType = MessageType.TestRunAttachmentsProcessingStart, Payload = JToken.FromObject(payload) }; - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); - this.mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(startAttachmentsProcessing); - - this.mockTestRequestManager - .Setup( - rm => rm.ProcessTestRunAttachments( - It.IsAny(), - It.IsAny(), - It.IsAny())) - .Callback(() => completeEvent.Set()); + Assert.IsTrue(_completeEvent.WaitOne(Timeout), "AttachmentsProcessing not completed."); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.IsAny()), Times.Once()); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, It.Is(p => p.Attachments == null)), Times.Once()); + } - this.designModeClient.ConnectToClientAndProcessRequests(PortNumber, this.mockTestRequestManager.Object); + [TestMethod] + public void DesignModeClientConnectShouldSendTestMessageAndDiscoverCompleteOnTestPlatformExceptionInAttachmentsProcessing() + { + var payload = new TestRunAttachmentsProcessingPayload(); + var startAttachmentsProcessing = new Message { MessageType = MessageType.TestRunAttachmentsProcessingStart, Payload = JToken.FromObject(payload) }; + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); + _mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(startAttachmentsProcessing); + _mockCommunicationManager + .Setup(cm => cm.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, It.IsAny())) + .Callback(() => _completeEvent.Set()); + _mockTestRequestManager.Setup( + rm => rm.ProcessTestRunAttachments( + It.IsAny(), + It.IsAny(), + It.IsAny())) + .Throws(new TestPlatformException("Hello world")); - Assert.IsTrue(this.completeEvent.WaitOne(Timeout), "AttachmentsProcessing not completed."); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.IsAny()), Times.Never); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, It.IsAny()), Times.Never); - this.mockTestRequestManager.Verify(rm => rm.ProcessTestRunAttachments(It.IsAny(), It.IsAny(), It.IsAny())); - } + _designModeClient.ConnectToClientAndProcessRequests(PortNumber, _mockTestRequestManager.Object); - [TestMethod] - public void DesignModeClientConnectShouldCallRequestManagerForAttachmentsProcessingCancel() - { - var cancelAttachmentsProcessing = new Message { MessageType = MessageType.TestRunAttachmentsProcessingCancel }; - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); - this.mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(cancelAttachmentsProcessing); + Assert.IsTrue(_completeEvent.WaitOne(Timeout), "AttachmentsProcessing not completed."); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.IsAny()), Times.Once()); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, It.Is(p => p.Attachments == null)), Times.Once()); + } - this.designModeClient.ConnectToClientAndProcessRequests(PortNumber, this.mockTestRequestManager.Object); + [TestMethod] + public void DesignModeClientConnectShouldCallRequestManagerForAttachmentsProcessingStart() + { + var payload = new TestRunAttachmentsProcessingPayload(); + var startAttachmentsProcessing = new Message { MessageType = MessageType.TestRunAttachmentsProcessingStart, Payload = JToken.FromObject(payload) }; + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); + _mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(startAttachmentsProcessing); + + _mockTestRequestManager + .Setup( + rm => rm.ProcessTestRunAttachments( + It.IsAny(), + It.IsAny(), + It.IsAny())) + .Callback(() => _completeEvent.Set()); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.IsAny()), Times.Never); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, It.IsAny()), Times.Never); - this.mockTestRequestManager.Verify(rm => rm.CancelTestRunAttachmentsProcessing()); - } + _designModeClient.ConnectToClientAndProcessRequests(PortNumber, _mockTestRequestManager.Object); - [TestMethod] - public void DesignModeClientConnectShouldSendTestMessageAndExecutionCompleteOnExceptionInTestRun() - { - var payload = new TestRunRequestPayload(); - var testRunAll = new Message { MessageType = MessageType.TestRunAllSourcesWithDefaultHost, Payload = JToken.FromObject(payload) }; - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); - this.mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(testRunAll); - this.mockCommunicationManager - .Setup(cm => cm.SendMessage(MessageType.ExecutionComplete, It.IsAny())) - .Callback(() => this.completeEvent.Set()); - this.mockTestRequestManager.Setup( - rm => rm.RunTests( - It.IsAny(), - null, - It.IsAny(), + Assert.IsTrue(_completeEvent.WaitOne(Timeout), "AttachmentsProcessing not completed."); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.IsAny()), Times.Never); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, It.IsAny()), Times.Never); + _mockTestRequestManager.Verify(rm => rm.ProcessTestRunAttachments(It.IsAny(), It.IsAny(), It.IsAny())); + } + + [TestMethod] + public void DesignModeClientConnectShouldCallRequestManagerForAttachmentsProcessingCancel() + { + var cancelAttachmentsProcessing = new Message { MessageType = MessageType.TestRunAttachmentsProcessingCancel }; + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); + _mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(cancelAttachmentsProcessing); + + _designModeClient.ConnectToClientAndProcessRequests(PortNumber, _mockTestRequestManager.Object); + + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.IsAny()), Times.Never); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, It.IsAny()), Times.Never); + _mockTestRequestManager.Verify(rm => rm.CancelTestRunAttachmentsProcessing()); + } + + [TestMethod] + public void DesignModeClientConnectShouldSendTestMessageAndExecutionCompleteOnExceptionInTestRun() + { + var payload = new TestRunRequestPayload(); + var testRunAll = new Message { MessageType = MessageType.TestRunAllSourcesWithDefaultHost, Payload = JToken.FromObject(payload) }; + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); + _mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(testRunAll); + _mockCommunicationManager + .Setup(cm => cm.SendMessage(MessageType.ExecutionComplete, It.IsAny())) + .Callback(() => _completeEvent.Set()); + _mockTestRequestManager.Setup( + rm => rm.RunTests( + It.IsAny(), + null, + It.IsAny(), It.IsAny())).Throws(new Exception()); - this.designModeClient.ConnectToClientAndProcessRequests(PortNumber, this.mockTestRequestManager.Object); + _designModeClient.ConnectToClientAndProcessRequests(PortNumber, _mockTestRequestManager.Object); - Assert.IsTrue(this.completeEvent.WaitOne(Timeout), "Execution not completed."); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.IsAny()), Times.Once()); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.ExecutionComplete, It.IsAny()), Times.Once()); - } + Assert.IsTrue(_completeEvent.WaitOne(Timeout), "Execution not completed."); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.IsAny()), Times.Once()); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.ExecutionComplete, It.IsAny()), Times.Once()); + } - [TestMethod] - public void DesignModeClientConnectShouldSendTestMessageAndExecutionCompleteOnTestPlatformExceptionInTestRun() - { - var payload = new TestRunRequestPayload(); - var testRunAll = new Message { MessageType = MessageType.TestRunAllSourcesWithDefaultHost, Payload = JToken.FromObject(payload) }; - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); - this.mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(testRunAll); - this.mockCommunicationManager - .Setup(cm => cm.SendMessage(MessageType.ExecutionComplete, It.IsAny())) - .Callback(() => this.completeEvent.Set()); - this.mockTestRequestManager.Setup( - rm => rm.RunTests( - It.IsAny(), - null, - It.IsAny(), + [TestMethod] + public void DesignModeClientConnectShouldSendTestMessageAndExecutionCompleteOnTestPlatformExceptionInTestRun() + { + var payload = new TestRunRequestPayload(); + var testRunAll = new Message { MessageType = MessageType.TestRunAllSourcesWithDefaultHost, Payload = JToken.FromObject(payload) }; + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); + _mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(testRunAll); + _mockCommunicationManager + .Setup(cm => cm.SendMessage(MessageType.ExecutionComplete, It.IsAny())) + .Callback(() => _completeEvent.Set()); + _mockTestRequestManager.Setup( + rm => rm.RunTests( + It.IsAny(), + null, + It.IsAny(), It.IsAny())).Throws(new TestPlatformException("Hello world")); - this.designModeClient.ConnectToClientAndProcessRequests(PortNumber, this.mockTestRequestManager.Object); + _designModeClient.ConnectToClientAndProcessRequests(PortNumber, _mockTestRequestManager.Object); - Assert.IsTrue(this.completeEvent.WaitOne(Timeout), "Execution not completed."); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.IsAny()), Times.Once()); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.ExecutionComplete, It.IsAny()), Times.Once()); - } + Assert.IsTrue(_completeEvent.WaitOne(Timeout), "Execution not completed."); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.IsAny()), Times.Once()); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.ExecutionComplete, It.IsAny()), Times.Once()); + } - [TestMethod] - public void DesignModeClientConnectShouldReturnNullSessionWhenStartTestSessionThrows() + [TestMethod] + public void DesignModeClientConnectShouldReturnNullSessionWhenStartTestSessionThrows() + { + var payload = new StartTestSessionPayload(); + var startTestSessionMessage = new Message() { - var payload = new StartTestSessionPayload(); - var startTestSessionMessage = new Message() + MessageType = MessageType.StartTestSession, + Payload = JToken.FromObject(payload) + }; + + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); + _mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(startTestSessionMessage); + _mockCommunicationManager.Setup(cm => cm.SendMessage( + MessageType.StartTestSessionCallback, + It.IsAny())) + .Callback((string _, object actualPayload) => { - MessageType = MessageType.StartTestSession, - Payload = JToken.FromObject(payload) - }; - - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); - this.mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(startTestSessionMessage); - this.mockCommunicationManager.Setup(cm => cm.SendMessage( - MessageType.StartTestSessionCallback, - It.IsAny())) - .Callback((string _, object actualPayload) => - { - this.completeEvent.Set(); - Assert.IsNull(((StartTestSessionAckPayload)actualPayload).TestSessionInfo); - }); - this.mockCommunicationManager.Setup( + _completeEvent.Set(); + Assert.IsNull(((StartTestSessionAckPayload)actualPayload).TestSessionInfo); + }); + _mockCommunicationManager.Setup( cm => cm.DeserializePayload( startTestSessionMessage)) - .Returns(payload); - - this.mockTestRequestManager.Setup( - rm => rm.StartTestSession( - It.IsAny(), - It.IsAny(), - It.IsAny(), - It.IsAny())).Throws(new SettingsException("DummyException")); - - this.designModeClient.ConnectToClientAndProcessRequests(PortNumber, this.mockTestRequestManager.Object); - - Assert.IsTrue(this.completeEvent.WaitOne(Timeout), "Start test session not completed."); - this.mockCommunicationManager.Verify( - cm => cm.SendMessage( - MessageType.StartTestSessionCallback, - It.IsAny()), - Times.Once()); - } + .Returns(payload); + + _mockTestRequestManager.Setup( + rm => rm.StartTestSession( + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny())).Throws(new SettingsException("DummyException")); + + _designModeClient.ConnectToClientAndProcessRequests(PortNumber, _mockTestRequestManager.Object); + + Assert.IsTrue(_completeEvent.WaitOne(Timeout), "Start test session not completed."); + _mockCommunicationManager.Verify( + cm => cm.SendMessage( + MessageType.StartTestSessionCallback, + It.IsAny()), + Times.Once()); + } - [TestMethod] - public void DesignModeClientConnectShouldReturnFalseWhenStopTestSessionThrows() - { - var mockTestPool = new Mock(); - TestSessionPool.Instance = mockTestPool.Object; + [TestMethod] + public void DesignModeClientConnectShouldReturnFalseWhenStopTestSessionThrows() + { + var mockTestPool = new Mock(); + TestSessionPool.Instance = mockTestPool.Object; - var testSessionInfo = new TestSessionInfo(); - var stopTestSessionMessage = new Message() + var testSessionInfo = new TestSessionInfo(); + var stopTestSessionMessage = new Message() + { + MessageType = MessageType.StopTestSession, + Payload = JToken.FromObject(testSessionInfo) + }; + + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); + _mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(stopTestSessionMessage); + _mockCommunicationManager.Setup(cm => cm.SendMessage( + MessageType.StopTestSessionCallback, + It.IsAny())) + .Callback((string _, object actualPayload) => { - MessageType = MessageType.StopTestSession, - Payload = JToken.FromObject(testSessionInfo) - }; + _completeEvent.Set(); - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); - this.mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(stopTestSessionMessage); - this.mockCommunicationManager.Setup(cm => cm.SendMessage( - MessageType.StopTestSessionCallback, - It.IsAny())) - .Callback((string _, object actualPayload) => - { - this.completeEvent.Set(); - - Assert.AreEqual(((StopTestSessionAckPayload)actualPayload).TestSessionInfo, testSessionInfo); - Assert.IsFalse(((StopTestSessionAckPayload)actualPayload).IsStopped); - }); + Assert.AreEqual(((StopTestSessionAckPayload)actualPayload).TestSessionInfo, testSessionInfo); + Assert.IsFalse(((StopTestSessionAckPayload)actualPayload).IsStopped); + }); - this.mockCommunicationManager.Setup( + _mockCommunicationManager.Setup( cm => cm.DeserializePayload( stopTestSessionMessage)) - .Returns(testSessionInfo); + .Returns(testSessionInfo); - mockTestPool.Setup(tp => tp.KillSession(testSessionInfo)).Throws(new Exception("DummyException")); + mockTestPool.Setup(tp => tp.KillSession(testSessionInfo)).Throws(new Exception("DummyException")); - this.designModeClient.ConnectToClientAndProcessRequests(PortNumber, this.mockTestRequestManager.Object); + _designModeClient.ConnectToClientAndProcessRequests(PortNumber, _mockTestRequestManager.Object); - Assert.IsTrue(this.completeEvent.WaitOne(Timeout), "Start test session not completed."); - this.mockCommunicationManager.Verify( - cm => cm.SendMessage( - MessageType.StopTestSessionCallback, - It.IsAny()), - Times.Once()); - } + Assert.IsTrue(_completeEvent.WaitOne(Timeout), "Start test session not completed."); + _mockCommunicationManager.Verify( + cm => cm.SendMessage( + MessageType.StopTestSessionCallback, + It.IsAny()), + Times.Once()); + } - [TestMethod] - public void DesignModeClientConnectShouldReturnFalseWhenStopTestSessionReturnsFalse() - { - var mockTestPool = new Mock(); - TestSessionPool.Instance = mockTestPool.Object; + [TestMethod] + public void DesignModeClientConnectShouldReturnFalseWhenStopTestSessionReturnsFalse() + { + var mockTestPool = new Mock(); + TestSessionPool.Instance = mockTestPool.Object; - var testSessionInfo = new TestSessionInfo(); - var stopTestSessionMessage = new Message() + var testSessionInfo = new TestSessionInfo(); + var stopTestSessionMessage = new Message() + { + MessageType = MessageType.StopTestSession, + Payload = JToken.FromObject(testSessionInfo) + }; + + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); + _mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(stopTestSessionMessage); + _mockCommunicationManager.Setup(cm => cm.SendMessage( + MessageType.StopTestSessionCallback, + It.IsAny())) + .Callback((string _, object actualPayload) => { - MessageType = MessageType.StopTestSession, - Payload = JToken.FromObject(testSessionInfo) - }; - - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); - this.mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(stopTestSessionMessage); - this.mockCommunicationManager.Setup(cm => cm.SendMessage( - MessageType.StopTestSessionCallback, - It.IsAny())) - .Callback((string _, object actualPayload) => - { - this.completeEvent.Set(); + _completeEvent.Set(); - Assert.AreEqual(((StopTestSessionAckPayload)actualPayload).TestSessionInfo, testSessionInfo); - Assert.IsFalse(((StopTestSessionAckPayload)actualPayload).IsStopped); - }); + Assert.AreEqual(((StopTestSessionAckPayload)actualPayload).TestSessionInfo, testSessionInfo); + Assert.IsFalse(((StopTestSessionAckPayload)actualPayload).IsStopped); + }); - this.mockCommunicationManager.Setup( + _mockCommunicationManager.Setup( cm => cm.DeserializePayload( stopTestSessionMessage)) - .Returns(testSessionInfo); + .Returns(testSessionInfo); - mockTestPool.Setup(tp => tp.KillSession(testSessionInfo)).Returns(false); + mockTestPool.Setup(tp => tp.KillSession(testSessionInfo)).Returns(false); - this.designModeClient.ConnectToClientAndProcessRequests(PortNumber, this.mockTestRequestManager.Object); + _designModeClient.ConnectToClientAndProcessRequests(PortNumber, _mockTestRequestManager.Object); - Assert.IsTrue(this.completeEvent.WaitOne(Timeout), "Start test session not completed."); - this.mockCommunicationManager.Verify( - cm => cm.SendMessage( - MessageType.StopTestSessionCallback, - It.IsAny()), - Times.Once()); - } + Assert.IsTrue(_completeEvent.WaitOne(Timeout), "Start test session not completed."); + _mockCommunicationManager.Verify( + cm => cm.SendMessage( + MessageType.StopTestSessionCallback, + It.IsAny()), + Times.Once()); + } - [TestMethod] - public void DesignModeClientConnectShouldReturnTruenWhenStopTestSessionReturnsTrue() - { - var mockTestPool = new Mock(); - TestSessionPool.Instance = mockTestPool.Object; + [TestMethod] + public void DesignModeClientConnectShouldReturnTruenWhenStopTestSessionReturnsTrue() + { + var mockTestPool = new Mock(); + TestSessionPool.Instance = mockTestPool.Object; - var testSessionInfo = new TestSessionInfo(); - var stopTestSessionMessage = new Message() + var testSessionInfo = new TestSessionInfo(); + var stopTestSessionMessage = new Message() + { + MessageType = MessageType.StopTestSession, + Payload = JToken.FromObject(testSessionInfo) + }; + + _mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); + _mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(stopTestSessionMessage); + _mockCommunicationManager.Setup(cm => cm.SendMessage( + MessageType.StopTestSessionCallback, + It.IsAny())) + .Callback((string _, object actualPayload) => { - MessageType = MessageType.StopTestSession, - Payload = JToken.FromObject(testSessionInfo) - }; + _completeEvent.Set(); - this.mockCommunicationManager.Setup(cm => cm.WaitForServerConnection(It.IsAny())).Returns(true); - this.mockCommunicationManager.SetupSequence(cm => cm.ReceiveMessage()).Returns(stopTestSessionMessage); - this.mockCommunicationManager.Setup(cm => cm.SendMessage( - MessageType.StopTestSessionCallback, - It.IsAny())) - .Callback((string _, object actualPayload) => - { - this.completeEvent.Set(); + Assert.AreEqual(((StopTestSessionAckPayload)actualPayload).TestSessionInfo, testSessionInfo); + Assert.IsTrue(((StopTestSessionAckPayload)actualPayload).IsStopped); + }); - Assert.AreEqual(((StopTestSessionAckPayload)actualPayload).TestSessionInfo, testSessionInfo); - Assert.IsTrue(((StopTestSessionAckPayload)actualPayload).IsStopped); - }); - - this.mockCommunicationManager.Setup( + _mockCommunicationManager.Setup( cm => cm.DeserializePayload( stopTestSessionMessage)) - .Returns(testSessionInfo); + .Returns(testSessionInfo); - mockTestPool.Setup(tp => tp.KillSession(testSessionInfo)).Returns(true); + mockTestPool.Setup(tp => tp.KillSession(testSessionInfo)).Returns(true); - this.designModeClient.ConnectToClientAndProcessRequests(PortNumber, this.mockTestRequestManager.Object); + _designModeClient.ConnectToClientAndProcessRequests(PortNumber, _mockTestRequestManager.Object); - Assert.IsTrue(this.completeEvent.WaitOne(Timeout), "Start test session not completed."); - this.mockCommunicationManager.Verify( - cm => cm.SendMessage( - MessageType.StopTestSessionCallback, - It.IsAny()), - Times.Once()); - } + Assert.IsTrue(_completeEvent.WaitOne(Timeout), "Start test session not completed."); + _mockCommunicationManager.Verify( + cm => cm.SendMessage( + MessageType.StopTestSessionCallback, + It.IsAny()), + Times.Once()); + } - [TestMethod] - public void DesignModeClientSendTestMessageShouldSendTestMessage() - { - var testPayload = new TestMessagePayload { MessageLevel = ObjectModel.Logging.TestMessageLevel.Error, Message = "DummyMessage" }; + [TestMethod] + public void DesignModeClientSendTestMessageShouldSendTestMessage() + { + var testPayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = "DummyMessage" }; - this.designModeClient.SendTestMessage(testPayload.MessageLevel, testPayload.Message); + _designModeClient.SendTestMessage(testPayload.MessageLevel, testPayload.Message); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.IsAny()), Times.Once()); - } + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.IsAny()), Times.Once()); + } - private class TestableDesignModeClient : DesignModeClient + private class TestableDesignModeClient : DesignModeClient + { + internal TestableDesignModeClient( + ICommunicationManager communicationManager, + IDataSerializer dataSerializer, + IEnvironment platformEnvironment) + : base(communicationManager, dataSerializer, platformEnvironment) { - internal TestableDesignModeClient( - ICommunicationManager communicationManager, - IDataSerializer dataSerializer, - IEnvironment platformEnvironment) - : base(communicationManager, dataSerializer, platformEnvironment) - { - } + } - public void InvokeCustomHostLaunchAckCallback(int processId, string errorMessage) + public void InvokeCustomHostLaunchAckCallback(int processId, string errorMessage) + { + var payload = new CustomHostLaunchAckPayload() { - var payload = new CustomHostLaunchAckPayload() - { - HostProcessId = processId, - ErrorMessage = errorMessage - }; - this.onCustomTestHostLaunchAckReceived?.Invoke( - new Message() { MessageType = MessageType.CustomTestHostLaunchCallback, Payload = JToken.FromObject(payload) }); - } + HostProcessId = processId, + ErrorMessage = errorMessage + }; + onCustomTestHostLaunchAckReceived?.Invoke( + new Message() { MessageType = MessageType.CustomTestHostLaunchCallback, Payload = JToken.FromObject(payload) }); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Client.UnitTests/DesignMode/DesignModeTestHostLauncherFactoryTests.cs b/test/Microsoft.TestPlatform.Client.UnitTests/DesignMode/DesignModeTestHostLauncherFactoryTests.cs index 177d73d5f1..eccd80a8c7 100644 --- a/test/Microsoft.TestPlatform.Client.UnitTests/DesignMode/DesignModeTestHostLauncherFactoryTests.cs +++ b/test/Microsoft.TestPlatform.Client.UnitTests/DesignMode/DesignModeTestHostLauncherFactoryTests.cs @@ -1,35 +1,34 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Client.UnitTests.DesignMode -{ - using Microsoft.VisualStudio.TestPlatform.Client.DesignMode; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.VisualStudio.TestPlatform.Client.UnitTests.DesignMode; + +using Microsoft.VisualStudio.TestPlatform.Client.DesignMode; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using TestTools.UnitTesting; - using Moq; +using Moq; - [TestClass] - public class DesignModeTestHostLauncherFactoryTests +[TestClass] +public class DesignModeTestHostLauncherFactoryTests +{ + [TestMethod] + public void DesignModeTestHostFactoryShouldReturnNonDebugLauncherIfDebuggingDisabled() { - [TestMethod] - public void DesignModeTestHostFactoryShouldReturnNonDebugLauncherIfDebuggingDisabled() - { - var mockDesignModeClient = new Mock(); - var testRunRequestPayload = new TestRunRequestPayload { DebuggingEnabled = false }; - var launcher = DesignModeTestHostLauncherFactory.GetCustomHostLauncherForTestRun(mockDesignModeClient.Object, testRunRequestPayload.DebuggingEnabled); + var mockDesignModeClient = new Mock(); + var testRunRequestPayload = new TestRunRequestPayload { DebuggingEnabled = false }; + var launcher = DesignModeTestHostLauncherFactory.GetCustomHostLauncherForTestRun(mockDesignModeClient.Object, testRunRequestPayload.DebuggingEnabled); - Assert.IsFalse(launcher.IsDebug, "Factory must not return debug launcher if debugging is disabled."); - } + Assert.IsFalse(launcher.IsDebug, "Factory must not return debug launcher if debugging is disabled."); + } - [TestMethod] - public void DesignModeTestHostFactoryShouldReturnDebugLauncherIfDebuggingEnabled() - { - var mockDesignModeClient = new Mock(); - var testRunRequestPayload = new TestRunRequestPayload { DebuggingEnabled = true }; - var launcher = DesignModeTestHostLauncherFactory.GetCustomHostLauncherForTestRun(mockDesignModeClient.Object, testRunRequestPayload.DebuggingEnabled); + [TestMethod] + public void DesignModeTestHostFactoryShouldReturnDebugLauncherIfDebuggingEnabled() + { + var mockDesignModeClient = new Mock(); + var testRunRequestPayload = new TestRunRequestPayload { DebuggingEnabled = true }; + var launcher = DesignModeTestHostLauncherFactory.GetCustomHostLauncherForTestRun(mockDesignModeClient.Object, testRunRequestPayload.DebuggingEnabled); - Assert.IsTrue(launcher.IsDebug, "Factory must return non-debug launcher if debugging is enabled."); - } + Assert.IsTrue(launcher.IsDebug, "Factory must return non-debug launcher if debugging is enabled."); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Client.UnitTests/DesignMode/DesignModeTestHostLauncherTests.cs b/test/Microsoft.TestPlatform.Client.UnitTests/DesignMode/DesignModeTestHostLauncherTests.cs index 01f98448fb..4df6e61411 100644 --- a/test/Microsoft.TestPlatform.Client.UnitTests/DesignMode/DesignModeTestHostLauncherTests.cs +++ b/test/Microsoft.TestPlatform.Client.UnitTests/DesignMode/DesignModeTestHostLauncherTests.cs @@ -4,41 +4,41 @@ using Microsoft.VisualStudio.TestPlatform.Client.DesignMode; using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Moq; + using System.Threading; -namespace Microsoft.VisualStudio.TestPlatform.Client.UnitTests.DesignMode +namespace Microsoft.VisualStudio.TestPlatform.Client.UnitTests.DesignMode; + +[TestClass] +public class DesignModeTestHostLauncherTests { - [TestClass] - public class DesignModeTestHostLauncherTests + [TestMethod] + public void DesignModeTestHostLauncherLaunchTestHostShouldCallDesignModeClientToLaunchCustomHost() { - [TestMethod] - public void DesignModeTestHostLauncherLaunchTestHostShouldCallDesignModeClientToLaunchCustomHost() - { - var mockDesignModeClient = new Mock(); - var launcher = new DesignModeTestHostLauncher(mockDesignModeClient.Object); - Assert.IsFalse(launcher.IsDebug, "Default launcher must not implement debug launcher interface."); + var mockDesignModeClient = new Mock(); + var launcher = new DesignModeTestHostLauncher(mockDesignModeClient.Object); + Assert.IsFalse(launcher.IsDebug, "Default launcher must not implement debug launcher interface."); - var testProcessStartInfo = new TestProcessStartInfo(); + var testProcessStartInfo = new TestProcessStartInfo(); - launcher.LaunchTestHost(testProcessStartInfo); + launcher.LaunchTestHost(testProcessStartInfo); - mockDesignModeClient.Verify(md => md.LaunchCustomHost(testProcessStartInfo, It.IsAny()), Times.Once); - } + mockDesignModeClient.Verify(md => md.LaunchCustomHost(testProcessStartInfo, It.IsAny()), Times.Once); + } - [TestMethod] - public void DesignModeDebugTestHostLauncherLaunchTestHostShouldCallDesignModeClientToLaunchCustomHost() - { - var mockDesignModeClient = new Mock(); - var launcher = new DesignModeDebugTestHostLauncher(mockDesignModeClient.Object); - Assert.IsTrue(launcher.IsDebug, "Debug launcher must implement debug launcher interface."); + [TestMethod] + public void DesignModeDebugTestHostLauncherLaunchTestHostShouldCallDesignModeClientToLaunchCustomHost() + { + var mockDesignModeClient = new Mock(); + var launcher = new DesignModeDebugTestHostLauncher(mockDesignModeClient.Object); + Assert.IsTrue(launcher.IsDebug, "Debug launcher must implement debug launcher interface."); - var testProcessStartInfo = new TestProcessStartInfo(); + var testProcessStartInfo = new TestProcessStartInfo(); - launcher.LaunchTestHost(testProcessStartInfo); + launcher.LaunchTestHost(testProcessStartInfo); - mockDesignModeClient.Verify(md => md.LaunchCustomHost(testProcessStartInfo, It.IsAny()), Times.Once); - } + mockDesignModeClient.Verify(md => md.LaunchCustomHost(testProcessStartInfo, It.IsAny()), Times.Once); } -} - +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Client.UnitTests/Discovery/DiscoveryRequestTests.cs b/test/Microsoft.TestPlatform.Client.UnitTests/Discovery/DiscoveryRequestTests.cs index 3b80962f7b..45ba23aa63 100644 --- a/test/Microsoft.TestPlatform.Client.UnitTests/Discovery/DiscoveryRequestTests.cs +++ b/test/Microsoft.TestPlatform.Client.UnitTests/Discovery/DiscoveryRequestTests.cs @@ -1,291 +1,286 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Client.UnitTests.Discovery -{ - using System; - using System.Collections.Generic; - using System.Linq; +namespace Microsoft.VisualStudio.TestPlatform.Client.UnitTests.Discovery; + +using System; +using System.Collections.Generic; +using System.Linq; - using Client.Discovery; +using Client.Discovery; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; +using Common.Telemetry; +using CommunicationUtilities; +using CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using TestTools.UnitTesting; - using Moq; +using Moq; - [TestClass] - public class DiscoveryRequestTests +[TestClass] +public class DiscoveryRequestTests +{ + readonly DiscoveryRequest _discoveryRequest; + readonly Mock _discoveryManager; + private readonly Mock _loggerManager; + readonly DiscoveryCriteria _discoveryCriteria; + private readonly Mock _mockRequestData; + private readonly Mock _mockDataSerializer; + + public DiscoveryRequestTests() { - DiscoveryRequest discoveryRequest; - Mock discoveryManager; - private readonly Mock loggerManager; - DiscoveryCriteria discoveryCriteria; - private Mock mockRequestData; - private Mock mockDataSerializer; - - public DiscoveryRequestTests() - { - this.discoveryCriteria = new DiscoveryCriteria(new List { "foo" }, 1, null); - this.discoveryManager = new Mock(); - this.loggerManager = new Mock(); - this.mockRequestData = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new NoOpMetricsCollection()); - this.mockDataSerializer = new Mock(); - this.discoveryRequest = new DiscoveryRequest(this.mockRequestData.Object, this.discoveryCriteria, this.discoveryManager.Object, loggerManager.Object, this.mockDataSerializer.Object); - } + _discoveryCriteria = new DiscoveryCriteria(new List { "foo" }, 1, null); + _discoveryManager = new Mock(); + _loggerManager = new Mock(); + _mockRequestData = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new NoOpMetricsCollection()); + _mockDataSerializer = new Mock(); + _discoveryRequest = new DiscoveryRequest(_mockRequestData.Object, _discoveryCriteria, _discoveryManager.Object, _loggerManager.Object, _mockDataSerializer.Object); + } - [TestMethod] - public void ConstructorSetsDiscoveryCriteriaAndDiscoveryManager() - { - Assert.AreEqual(this.discoveryCriteria, this.discoveryRequest.DiscoveryCriteria); - Assert.AreEqual(this.discoveryManager.Object, (this.discoveryRequest as DiscoveryRequest).DiscoveryManager); - } + [TestMethod] + public void ConstructorSetsDiscoveryCriteriaAndDiscoveryManager() + { + Assert.AreEqual(_discoveryCriteria, _discoveryRequest.DiscoveryCriteria); + Assert.AreEqual(_discoveryManager.Object, (_discoveryRequest as DiscoveryRequest).DiscoveryManager); + } - [TestMethod] - public void DiscoveryAsycIfDiscoveryRequestIsDisposedThrowsObjectDisposedException() - { - this.discoveryRequest.Dispose(); + [TestMethod] + public void DiscoveryAsycIfDiscoveryRequestIsDisposedThrowsObjectDisposedException() + { + _discoveryRequest.Dispose(); - Assert.ThrowsException(() => this.discoveryRequest.DiscoverAsync()); - } + Assert.ThrowsException(() => _discoveryRequest.DiscoverAsync()); + } - [TestMethod] - public void DiscoverAsyncSetsDiscoveryInProgressAndCallManagerToDiscoverTests() - { - this.discoveryRequest.DiscoverAsync(); + [TestMethod] + public void DiscoverAsyncSetsDiscoveryInProgressAndCallManagerToDiscoverTests() + { + _discoveryRequest.DiscoverAsync(); - Assert.IsTrue((this.discoveryRequest as DiscoveryRequest).DiscoveryInProgress); - this.discoveryManager.Verify(dm => dm.DiscoverTests(this.discoveryCriteria, this.discoveryRequest as DiscoveryRequest), Times.Once); - } + Assert.IsTrue((_discoveryRequest as DiscoveryRequest).DiscoveryInProgress); + _discoveryManager.Verify(dm => dm.DiscoverTests(_discoveryCriteria, _discoveryRequest as DiscoveryRequest), Times.Once); + } - [TestMethod] - public void DiscoveryAsyncIfDiscoverTestsThrowsExceptionSetsDiscoveryInProgressToFalseAndThrowsThatException() + [TestMethod] + public void DiscoveryAsyncIfDiscoverTestsThrowsExceptionSetsDiscoveryInProgressToFalseAndThrowsThatException() + { + _discoveryManager.Setup(dm => dm.DiscoverTests(_discoveryCriteria, _discoveryRequest as DiscoveryRequest)).Throws(new Exception("DummyException")); + try { - this.discoveryManager.Setup(dm => dm.DiscoverTests(this.discoveryCriteria, this.discoveryRequest as DiscoveryRequest)).Throws(new Exception("DummyException")); - try - { - this.discoveryRequest.DiscoverAsync(); - } - catch (Exception ex) - { - Assert.IsTrue(ex is Exception); - Assert.AreEqual("DummyException", ex.Message); - Assert.IsFalse((this.discoveryRequest as DiscoveryRequest).DiscoveryInProgress); - } + _discoveryRequest.DiscoverAsync(); } - - [TestMethod] - public void AbortIfDiscoveryRequestDisposedShouldThrowObjectDisposedException() + catch (Exception ex) { - this.discoveryRequest.Dispose(); - Assert.ThrowsException(() => this.discoveryRequest.Abort()); + Assert.IsTrue(ex is Exception); + Assert.AreEqual("DummyException", ex.Message); + Assert.IsFalse((_discoveryRequest as DiscoveryRequest).DiscoveryInProgress); } + } - [TestMethod] - public void AbortIfDiscoveryIsinProgressShouldCallDiscoveryManagerAbort() - { - // Just to set the IsDiscoveryInProgress flag - this.discoveryRequest.DiscoverAsync(); + [TestMethod] + public void AbortIfDiscoveryRequestDisposedShouldThrowObjectDisposedException() + { + _discoveryRequest.Dispose(); + Assert.ThrowsException(() => _discoveryRequest.Abort()); + } - this.discoveryRequest.Abort(); - this.discoveryManager.Verify(dm => dm.Abort(), Times.Once); - } + [TestMethod] + public void AbortIfDiscoveryIsinProgressShouldCallDiscoveryManagerAbort() + { + // Just to set the IsDiscoveryInProgress flag + _discoveryRequest.DiscoverAsync(); - [TestMethod] - public void AbortIfDiscoveryIsNotInProgressShouldNotCallDiscoveryManagerAbort() - { - // DiscoveryAsync has not been called, discoveryInProgress should be false - this.discoveryRequest.Abort(); - this.discoveryManager.Verify(dm => dm.Abort(), Times.Never); - } + _discoveryRequest.Abort(); + _discoveryManager.Verify(dm => dm.Abort(), Times.Once); + } - [TestMethod] - public void WaitForCompletionIfDiscoveryRequestDisposedShouldThrowObjectDisposedException() - { - this.discoveryRequest.Dispose(); - Assert.ThrowsException(() => this.discoveryRequest.WaitForCompletion()); - } + [TestMethod] + public void AbortIfDiscoveryIsNotInProgressShouldNotCallDiscoveryManagerAbort() + { + // DiscoveryAsync has not been called, discoveryInProgress should be false + _discoveryRequest.Abort(); + _discoveryManager.Verify(dm => dm.Abort(), Times.Never); + } - [TestMethod] - public void HandleDiscoveryCompleteShouldCloseDiscoveryManager() - { - var eventsHandler = this.discoveryRequest as ITestDiscoveryEventsHandler2; + [TestMethod] + public void WaitForCompletionIfDiscoveryRequestDisposedShouldThrowObjectDisposedException() + { + _discoveryRequest.Dispose(); + Assert.ThrowsException(() => _discoveryRequest.WaitForCompletion()); + } - eventsHandler.HandleDiscoveryComplete(new DiscoveryCompleteEventArgs(1, false), Enumerable.Empty()); - this.discoveryManager.Verify(dm => dm.Close(), Times.Once); - } + [TestMethod] + public void HandleDiscoveryCompleteShouldCloseDiscoveryManager() + { + var eventsHandler = _discoveryRequest as ITestDiscoveryEventsHandler2; - [TestMethod] - public void HandleDiscoveryCompleteShouldCloseDiscoveryManagerBeforeRaiseDiscoveryComplete() - { - var events = new List(); - this.discoveryManager.Setup(dm => dm.Close()).Callback(() => events.Add("close")); - this.discoveryRequest.OnDiscoveryComplete += (s, e) => events.Add("complete"); - var eventsHandler = this.discoveryRequest as ITestDiscoveryEventsHandler2; + eventsHandler.HandleDiscoveryComplete(new DiscoveryCompleteEventArgs(1, false), Enumerable.Empty()); + _discoveryManager.Verify(dm => dm.Close(), Times.Once); + } - eventsHandler.HandleDiscoveryComplete(new DiscoveryCompleteEventArgs(1, false), Enumerable.Empty()); + [TestMethod] + public void HandleDiscoveryCompleteShouldCloseDiscoveryManagerBeforeRaiseDiscoveryComplete() + { + var events = new List(); + _discoveryManager.Setup(dm => dm.Close()).Callback(() => events.Add("close")); + _discoveryRequest.OnDiscoveryComplete += (s, e) => events.Add("complete"); + var eventsHandler = _discoveryRequest as ITestDiscoveryEventsHandler2; - Assert.AreEqual(2, events.Count); - Assert.AreEqual("close", events[0]); - Assert.AreEqual("complete", events[1]); - } + eventsHandler.HandleDiscoveryComplete(new DiscoveryCompleteEventArgs(1, false), Enumerable.Empty()); - /// - /// DiscoverAsync should invoke OnDiscoveryStart event. - /// - [TestMethod] - public void DiscoverAsyncShouldInvokeOnDiscoveryStart() - { - bool onDiscoveryStartHandlerCalled = false; - this.discoveryRequest.OnDiscoveryStart += (s, e) => onDiscoveryStartHandlerCalled = true; + Assert.AreEqual(2, events.Count); + Assert.AreEqual("close", events[0]); + Assert.AreEqual("complete", events[1]); + } - // Action - this.discoveryRequest.DiscoverAsync(); + /// + /// DiscoverAsync should invoke OnDiscoveryStart event. + /// + [TestMethod] + public void DiscoverAsyncShouldInvokeOnDiscoveryStart() + { + bool onDiscoveryStartHandlerCalled = false; + _discoveryRequest.OnDiscoveryStart += (s, e) => onDiscoveryStartHandlerCalled = true; - // Assert - Assert.IsTrue(onDiscoveryStartHandlerCalled, "DiscoverAsync should invoke OnDiscoveryStart event"); - } + // Action + _discoveryRequest.DiscoverAsync(); - [TestMethod] - public void DiscoverAsyncShouldInvokeHandleDiscoveryStartofLoggerManager() - { - // Action - this.discoveryRequest.DiscoverAsync(); + // Assert + Assert.IsTrue(onDiscoveryStartHandlerCalled, "DiscoverAsync should invoke OnDiscoveryStart event"); + } - // Assert - loggerManager.Verify(lm => lm.HandleDiscoveryStart(It.IsAny()), Times.Once); - } + [TestMethod] + public void DiscoverAsyncShouldInvokeHandleDiscoveryStartofLoggerManager() + { + // Action + _discoveryRequest.DiscoverAsync(); - [TestMethod] - public void HandleDiscoveryCompleteShouldCollectMetrics() + // Assert + _loggerManager.Verify(lm => lm.HandleDiscoveryStart(It.IsAny()), Times.Once); + } + + [TestMethod] + public void HandleDiscoveryCompleteShouldCollectMetrics() + { + var mockMetricsCollector = new Mock(); + var dict = new Dictionary { - var mockMetricsCollector = new Mock(); - var dict = new Dictionary(); - dict.Add("DummyMessage", "DummyValue"); + { "DummyMessage", "DummyValue" } + }; - mockMetricsCollector.Setup(mc => mc.Metrics).Returns(dict); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollector.Object); + mockMetricsCollector.Setup(mc => mc.Metrics).Returns(dict); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollector.Object); - var eventsHandler = this.discoveryRequest as ITestDiscoveryEventsHandler2; - var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(1, false); - discoveryCompleteEventArgs.Metrics = dict; + var eventsHandler = _discoveryRequest as ITestDiscoveryEventsHandler2; + var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(1, false); + discoveryCompleteEventArgs.Metrics = dict; - // Act - eventsHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, Enumerable.Empty()); + // Act + eventsHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, Enumerable.Empty()); - // Verify. - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenInSecForDiscovery, It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add("DummyMessage", "DummyValue"), Times.Once); - } + // Verify. + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenInSecForDiscovery, It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add("DummyMessage", "DummyValue"), Times.Once); + } - [TestMethod] - public void HandleRawMessageShouldHandleRawMessage() - { - bool onDiscoveryCompleteInvoked = false; - this.discoveryRequest.OnRawMessageReceived += (object sender, string e) => - { - onDiscoveryCompleteInvoked = true; - }; + [TestMethod] + public void HandleRawMessageShouldHandleRawMessage() + { + bool onDiscoveryCompleteInvoked = false; + _discoveryRequest.OnRawMessageReceived += (object sender, string e) => onDiscoveryCompleteInvoked = true; - this.discoveryRequest.HandleRawMessage(string.Empty); + _discoveryRequest.HandleRawMessage(string.Empty); - Assert.IsTrue(onDiscoveryCompleteInvoked); - } + Assert.IsTrue(onDiscoveryCompleteInvoked); + } - [TestMethod] - public void HandleRawMessageShouldAddVSTestDataPointsIfTelemetryOptedIn() - { - bool onDiscoveryCompleteInvoked = true; - this.mockRequestData.Setup(x => x.IsTelemetryOptedIn).Returns(true); - this.discoveryRequest.OnRawMessageReceived += (object sender, string e) => - { - onDiscoveryCompleteInvoked = true; - }; + [TestMethod] + public void HandleRawMessageShouldAddVsTestDataPointsIfTelemetryOptedIn() + { + bool onDiscoveryCompleteInvoked = true; + _mockRequestData.Setup(x => x.IsTelemetryOptedIn).Returns(true); + _discoveryRequest.OnRawMessageReceived += (object sender, string e) => onDiscoveryCompleteInvoked = true; - this.mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())) - .Returns(new Message() { MessageType = MessageType.DiscoveryComplete }); + _mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())) + .Returns(new Message() { MessageType = MessageType.DiscoveryComplete }); - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) - .Returns(new DiscoveryCompletePayload()); + _mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) + .Returns(new DiscoveryCompletePayload()); - this.discoveryRequest.HandleRawMessage(string.Empty); + _discoveryRequest.HandleRawMessage(string.Empty); - this.mockDataSerializer.Verify(x => x.SerializePayload(It.IsAny(), It.IsAny()), Times.Once); - this.mockRequestData.Verify(x => x.MetricsCollection, Times.AtLeastOnce); - Assert.IsTrue(onDiscoveryCompleteInvoked); - } + _mockDataSerializer.Verify(x => x.SerializePayload(It.IsAny(), It.IsAny()), Times.Once); + _mockRequestData.Verify(x => x.MetricsCollection, Times.AtLeastOnce); + Assert.IsTrue(onDiscoveryCompleteInvoked); + } - [TestMethod] - public void HandleRawMessageShouldInvokeHandleDiscoveryCompleteOfLoggerManager() - { - this.loggerManager.Setup(x => x.LoggersInitialized).Returns(true); - this.mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())) - .Returns(new Message() { MessageType = MessageType.DiscoveryComplete }); - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) - .Returns(new DiscoveryCompletePayload() - { - TotalTests = 1, - IsAborted = false, - LastDiscoveredTests = Enumerable.Empty() - }); - - this.discoveryRequest.HandleRawMessage(string.Empty); - - this.loggerManager.Verify(lm => lm.HandleDiscoveryComplete(It.IsAny()), Times.Once); - } + [TestMethod] + public void HandleRawMessageShouldInvokeHandleDiscoveryCompleteOfLoggerManager() + { + _loggerManager.Setup(x => x.LoggersInitialized).Returns(true); + _mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())) + .Returns(new Message() { MessageType = MessageType.DiscoveryComplete }); + _mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) + .Returns(new DiscoveryCompletePayload() + { + TotalTests = 1, + IsAborted = false, + LastDiscoveredTests = Enumerable.Empty() + }); - [TestMethod] - public void HandleDiscoveryCompleteShouldInvokeHandleDiscoveryCompleteOfLoggerManager() - { - var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(1, false); - var eventsHandler = this.discoveryRequest as ITestDiscoveryEventsHandler2; - eventsHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, Enumerable.Empty()); + _discoveryRequest.HandleRawMessage(string.Empty); - loggerManager.Verify(lm => lm.HandleDiscoveryComplete(discoveryCompleteEventArgs), Times.Once); - } + _loggerManager.Verify(lm => lm.HandleDiscoveryComplete(It.IsAny()), Times.Once); + } - [TestMethod] - public void HandleDiscoveryCompleteShouldNotInvokeHandleDiscoveredTestsIfLastChunkNotPresent() - { - var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(1, false); - var eventsHandler = this.discoveryRequest as ITestDiscoveryEventsHandler2; - eventsHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, Enumerable.Empty()); + [TestMethod] + public void HandleDiscoveryCompleteShouldInvokeHandleDiscoveryCompleteOfLoggerManager() + { + var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(1, false); + var eventsHandler = _discoveryRequest as ITestDiscoveryEventsHandler2; + eventsHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, Enumerable.Empty()); - loggerManager.Verify(lm => lm.HandleDiscoveredTests(It.IsAny()), Times.Never); - } + _loggerManager.Verify(lm => lm.HandleDiscoveryComplete(discoveryCompleteEventArgs), Times.Once); + } - [TestMethod] - public void HandleDiscoveryCompleteShouldInvokeHandleDiscoveredTestsIfLastChunkPresent() + [TestMethod] + public void HandleDiscoveryCompleteShouldNotInvokeHandleDiscoveredTestsIfLastChunkNotPresent() + { + var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(1, false); + var eventsHandler = _discoveryRequest as ITestDiscoveryEventsHandler2; + eventsHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, Enumerable.Empty()); + + _loggerManager.Verify(lm => lm.HandleDiscoveredTests(It.IsAny()), Times.Never); + } + + [TestMethod] + public void HandleDiscoveryCompleteShouldInvokeHandleDiscoveredTestsIfLastChunkPresent() + { + var activeTestCases = new List { - var activeTestCases = new List - { - new ObjectModel.TestCase( - "A.C.M2", - new Uri("executor://dummy"), - "A") - }; + new TestCase( + "A.C.M2", + new Uri("executor://dummy"), + "A") + }; - var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(1, false); - var eventsHandler = this.discoveryRequest as ITestDiscoveryEventsHandler2; - eventsHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, activeTestCases); + var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(1, false); + var eventsHandler = _discoveryRequest as ITestDiscoveryEventsHandler2; + eventsHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, activeTestCases); - loggerManager.Verify(lm => lm.HandleDiscoveredTests(It.IsAny()), Times.Once); - } + _loggerManager.Verify(lm => lm.HandleDiscoveredTests(It.IsAny()), Times.Once); + } - [TestMethod] - public void HandleDiscoveredTestsShouldInvokeHandleDiscoveredTestsOfLoggerManager() - { - discoveryRequest.HandleDiscoveredTests(null); + [TestMethod] + public void HandleDiscoveredTestsShouldInvokeHandleDiscoveredTestsOfLoggerManager() + { + _discoveryRequest.HandleDiscoveredTests(null); - loggerManager.Verify(lm => lm.HandleDiscoveredTests(It.IsAny()), Times.Once); - } + _loggerManager.Verify(lm => lm.HandleDiscoveredTests(It.IsAny()), Times.Once); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Client.UnitTests/Execution/TestRunRequestTests.cs b/test/Microsoft.TestPlatform.Client.UnitTests/Execution/TestRunRequestTests.cs index 15a5c2a44c..e4ca1e7f9e 100644 --- a/test/Microsoft.TestPlatform.Client.UnitTests/Execution/TestRunRequestTests.cs +++ b/test/Microsoft.TestPlatform.Client.UnitTests/Execution/TestRunRequestTests.cs @@ -1,682 +1,662 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Client.UnitTests.Execution -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading; +namespace Microsoft.VisualStudio.TestPlatform.Client.UnitTests.Execution; - using Client.Execution; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using Client.Execution; - using Moq; +using Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using ObjectModel.Logging; +using TestTools.UnitTesting; - using ObjectModel; - using ObjectModel.Client; - using ObjectModel.Engine; - using System.Collections.ObjectModel; +using Moq; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using ObjectModel; +using ObjectModel.Client; +using ObjectModel.Engine; +using System.Collections.ObjectModel; - [TestClass] - public class TestRunRequestTests - { - TestRunRequest testRunRequest; - Mock executionManager; - private readonly Mock loggerManager; - TestRunCriteria testRunCriteria; - private Mock mockRequestData; +using CommunicationUtilities; +using CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - private Mock mockDataSerializer; +[TestClass] +public class TestRunRequestTests +{ + TestRunRequest _testRunRequest; + Mock _executionManager; + private readonly Mock _loggerManager; + TestRunCriteria _testRunCriteria; + private readonly Mock _mockRequestData; - public TestRunRequestTests() - { - testRunCriteria = new TestRunCriteria(new List { "foo" }, 1); - executionManager = new Mock(); - this.loggerManager = new Mock(); - this.mockRequestData = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new NoOpMetricsCollection()); - this.mockDataSerializer = new Mock(); - testRunRequest = new TestRunRequest(this.mockRequestData.Object, testRunCriteria, executionManager.Object, loggerManager.Object, this.mockDataSerializer.Object); - } + private readonly Mock _mockDataSerializer; - [TestMethod] - public void ConstructorSetsTestRunCriteriaExecutionManagerAndState() - { - Assert.AreEqual(TestRunState.Pending, testRunRequest.State); - Assert.AreEqual(testRunCriteria, testRunRequest.TestRunConfiguration); - Assert.AreEqual(executionManager.Object, testRunRequest.ExecutionManager); - } + public TestRunRequestTests() + { + _testRunCriteria = new TestRunCriteria(new List { "foo" }, 1); + _executionManager = new Mock(); + _loggerManager = new Mock(); + _mockRequestData = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new NoOpMetricsCollection()); + _mockDataSerializer = new Mock(); + _testRunRequest = new TestRunRequest(_mockRequestData.Object, _testRunCriteria, _executionManager.Object, _loggerManager.Object, _mockDataSerializer.Object); + } - [TestMethod] - public void ExecuteAsycIfTestRunRequestIsDisposedThrowsObjectDisposedException() - { - testRunRequest.Dispose(); + [TestMethod] + public void ConstructorSetsTestRunCriteriaExecutionManagerAndState() + { + Assert.AreEqual(TestRunState.Pending, _testRunRequest.State); + Assert.AreEqual(_testRunCriteria, _testRunRequest.TestRunConfiguration); + Assert.AreEqual(_executionManager.Object, _testRunRequest.ExecutionManager); + } - Assert.ThrowsException(() => testRunRequest.ExecuteAsync()); - } + [TestMethod] + public void ExecuteAsycIfTestRunRequestIsDisposedThrowsObjectDisposedException() + { + _testRunRequest.Dispose(); - [TestMethod] - public void ExecuteAsycIfStateIsNotPendingThrowsInvalidOperationException() - { - testRunRequest.ExecuteAsync(); - Assert.ThrowsException(() => testRunRequest.ExecuteAsync()); - } + Assert.ThrowsException(() => _testRunRequest.ExecuteAsync()); + } - [TestMethod] - public void ExecuteAsyncSetsStateToInProgressAndCallManagerToStartTestRun() - { - testRunRequest.ExecuteAsync(); + [TestMethod] + public void ExecuteAsycIfStateIsNotPendingThrowsInvalidOperationException() + { + _testRunRequest.ExecuteAsync(); + Assert.ThrowsException(() => _testRunRequest.ExecuteAsync()); + } - Assert.AreEqual(TestRunState.InProgress, testRunRequest.State); - executionManager.Verify(em => em.StartTestRun(testRunCriteria, testRunRequest), Times.Once); - } + [TestMethod] + public void ExecuteAsyncSetsStateToInProgressAndCallManagerToStartTestRun() + { + _testRunRequest.ExecuteAsync(); - [TestMethod] - public void ExecuteAsyncIfStartTestRunThrowsExceptionSetsStateToPendingAndThrowsThatException() - { - executionManager.Setup(em => em.StartTestRun(testRunCriteria, testRunRequest)).Throws(new Exception("DummyException")); - try - { - testRunRequest.ExecuteAsync(); - } - catch (Exception ex) - { - Assert.IsTrue(ex is Exception); - Assert.AreEqual("DummyException", ex.Message); - Assert.AreEqual(TestRunState.Pending, testRunRequest.State); - } - } + Assert.AreEqual(TestRunState.InProgress, _testRunRequest.State); + _executionManager.Verify(em => em.StartTestRun(_testRunCriteria, _testRunRequest), Times.Once); + } - [TestMethod] - public void AbortIfTestRunRequestDisposedShouldNotThrowException() + [TestMethod] + public void ExecuteAsyncIfStartTestRunThrowsExceptionSetsStateToPendingAndThrowsThatException() + { + _executionManager.Setup(em => em.StartTestRun(_testRunCriteria, _testRunRequest)).Throws(new Exception("DummyException")); + try { - testRunRequest.Dispose(); - testRunRequest.Abort(); + _testRunRequest.ExecuteAsync(); } - - [TestMethod] - public void AbortIfTestRunStateIsNotInProgressShouldNotCallExecutionManagerAbort() + catch (Exception ex) { - //ExecuteAsync has not been called, so State is not InProgress - testRunRequest.Abort(); - executionManager.Verify(dm => dm.Abort(It.IsAny()), Times.Never); + Assert.IsTrue(ex is Exception); + Assert.AreEqual("DummyException", ex.Message); + Assert.AreEqual(TestRunState.Pending, _testRunRequest.State); } + } - [TestMethod] - public void AbortIfDiscoveryIsinProgressShouldCallDiscoveryManagerAbort() - { - // Set the State to InProgress - testRunRequest.ExecuteAsync(); + [TestMethod] + public void AbortIfTestRunRequestDisposedShouldNotThrowException() + { + _testRunRequest.Dispose(); + _testRunRequest.Abort(); + } - testRunRequest.Abort(); - executionManager.Verify(dm => dm.Abort(It.IsAny()), Times.Once); - } + [TestMethod] + public void AbortIfTestRunStateIsNotInProgressShouldNotCallExecutionManagerAbort() + { + //ExecuteAsync has not been called, so State is not InProgress + _testRunRequest.Abort(); + _executionManager.Verify(dm => dm.Abort(It.IsAny()), Times.Never); + } - [TestMethod] - public void WaitForCompletionIfTestRunRequestDisposedShouldThrowObjectDisposedException() - { - testRunRequest.Dispose(); - Assert.ThrowsException(() => testRunRequest.WaitForCompletion()); - } + [TestMethod] + public void AbortIfDiscoveryIsinProgressShouldCallDiscoveryManagerAbort() + { + // Set the State to InProgress + _testRunRequest.ExecuteAsync(); - [TestMethod] - public void WaitForCompletionIfTestRunStatePendingShouldThrowInvalidOperationException() - { - Assert.ThrowsException(() => testRunRequest.WaitForCompletion()); - } + _testRunRequest.Abort(); + _executionManager.Verify(dm => dm.Abort(It.IsAny()), Times.Once); + } - [TestMethod] - public void CancelAsyncIfTestRunRequestDisposedShouldNotThrowException() - { - testRunRequest.Dispose(); - testRunRequest.CancelAsync(); - } + [TestMethod] + public void WaitForCompletionIfTestRunRequestDisposedShouldThrowObjectDisposedException() + { + _testRunRequest.Dispose(); + Assert.ThrowsException(() => _testRunRequest.WaitForCompletion()); + } - [TestMethod] - public void CancelAsyncIfTestRunStateNotInProgressWillNotCallExecutionManagerCancel() - { - testRunRequest.CancelAsync(); - executionManager.Verify(dm => dm.Cancel(It.IsAny()), Times.Never); - } + [TestMethod] + public void WaitForCompletionIfTestRunStatePendingShouldThrowInvalidOperationException() + { + Assert.ThrowsException(() => _testRunRequest.WaitForCompletion()); + } - [TestMethod] - public void CancelAsyncIfTestRunStateInProgressCallsExecutionManagerCancel() - { - testRunRequest.ExecuteAsync(); - testRunRequest.CancelAsync(); - executionManager.Verify(dm => dm.Cancel(It.IsAny()), Times.Once); - } + [TestMethod] + public void CancelAsyncIfTestRunRequestDisposedShouldNotThrowException() + { + _testRunRequest.Dispose(); + _testRunRequest.CancelAsync(); + } - [TestMethod] - public void OnTestSessionTimeoutShouldCallAbort() - { - this.testRunRequest.ExecuteAsync(); - this.testRunRequest.OnTestSessionTimeout(null); - this.executionManager.Verify(o => o.Abort(It.IsAny()), Times.Once); - } + [TestMethod] + public void CancelAsyncIfTestRunStateNotInProgressWillNotCallExecutionManagerCancel() + { + _testRunRequest.CancelAsync(); + _executionManager.Verify(dm => dm.Cancel(It.IsAny()), Times.Never); + } - [TestMethod] - public void OnTestSessionTimeoutShouldLogMessage() - { - bool handleLogMessageCalled = false; - bool handleRawMessageCalled = false; + [TestMethod] + public void CancelAsyncIfTestRunStateInProgressCallsExecutionManagerCancel() + { + _testRunRequest.ExecuteAsync(); + _testRunRequest.CancelAsync(); + _executionManager.Verify(dm => dm.Cancel(It.IsAny()), Times.Once); + } - this.testRunRequest.TestRunMessage += (object sender, TestRunMessageEventArgs e) => - { - handleLogMessageCalled = true; - }; + [TestMethod] + public void OnTestSessionTimeoutShouldCallAbort() + { + _testRunRequest.ExecuteAsync(); + _testRunRequest.OnTestSessionTimeout(null); + _executionManager.Verify(o => o.Abort(It.IsAny()), Times.Once); + } - this.testRunRequest.OnRawMessageReceived += (object sender, string message) => - { - handleRawMessageCalled = true; - }; + [TestMethod] + public void OnTestSessionTimeoutShouldLogMessage() + { + bool handleLogMessageCalled = false; + bool handleRawMessageCalled = false; - this.testRunRequest.OnTestSessionTimeout(null); + _testRunRequest.TestRunMessage += (object sender, TestRunMessageEventArgs e) => handleLogMessageCalled = true; - Assert.IsTrue(handleLogMessageCalled, "OnTestSessionTimeout should call HandleLogMessage"); - Assert.IsTrue(handleRawMessageCalled, "OnTestSessionTimeout should call HandleRawMessage"); - } + _testRunRequest.OnRawMessageReceived += (object sender, string message) => handleRawMessageCalled = true; - [TestMethod] - public void OnTestSessionTimeoutShouldGetCalledWhenExecutionCrossedTestSessionTimeout() - { - string settingsXml = - @" + _testRunRequest.OnTestSessionTimeout(null); + + Assert.IsTrue(handleLogMessageCalled, "OnTestSessionTimeout should call HandleLogMessage"); + Assert.IsTrue(handleRawMessageCalled, "OnTestSessionTimeout should call HandleRawMessage"); + } + + [TestMethod] + public void OnTestSessionTimeoutShouldGetCalledWhenExecutionCrossedTestSessionTimeout() + { + string settingsXml = + @" 1000 "; - var testRunCriteria = new TestRunCriteria(new List { "foo" }, 1, true, settingsXml); - var executionManager = new Mock(); - var testRunRequest = new TestRunRequest(this.mockRequestData.Object, testRunCriteria, executionManager.Object, loggerManager.Object); + var testRunCriteria = new TestRunCriteria(new List { "foo" }, 1, true, settingsXml); + var executionManager = new Mock(); + var testRunRequest = new TestRunRequest(_mockRequestData.Object, testRunCriteria, executionManager.Object, _loggerManager.Object); - ManualResetEvent onTestSessionTimeoutCalled = new ManualResetEvent(true); - onTestSessionTimeoutCalled.Reset(); - executionManager.Setup(o => o.Abort(It.IsAny())).Callback(() => onTestSessionTimeoutCalled.Set()); + ManualResetEvent onTestSessionTimeoutCalled = new(true); + onTestSessionTimeoutCalled.Reset(); + executionManager.Setup(o => o.Abort(It.IsAny())).Callback(() => onTestSessionTimeoutCalled.Set()); - testRunRequest.ExecuteAsync(); - onTestSessionTimeoutCalled.WaitOne(20 * 1000); + testRunRequest.ExecuteAsync(); + onTestSessionTimeoutCalled.WaitOne(20 * 1000); - executionManager.Verify(o => o.Abort(It.IsAny()), Times.Once); - } + executionManager.Verify(o => o.Abort(It.IsAny()), Times.Once); + } - /// - /// Test session timeout should be infinity if TestSessionTimeout is 0. - /// - [TestMethod] - public void OnTestSessionTimeoutShouldNotGetCalledWhenTestSessionTimeoutIsZero() - { - string settingsXml = - @" + /// + /// Test session timeout should be infinity if TestSessionTimeout is 0. + /// + [TestMethod] + public void OnTestSessionTimeoutShouldNotGetCalledWhenTestSessionTimeoutIsZero() + { + string settingsXml = + @" 0 "; - var testRunCriteria = new TestRunCriteria(new List { "foo" }, 1, true, settingsXml); - var executionManager = new Mock(); - var testRunRequest = new TestRunRequest(this.mockRequestData.Object, testRunCriteria, executionManager.Object, loggerManager.Object); + var testRunCriteria = new TestRunCriteria(new List { "foo" }, 1, true, settingsXml); + var executionManager = new Mock(); + var testRunRequest = new TestRunRequest(_mockRequestData.Object, testRunCriteria, executionManager.Object, _loggerManager.Object); - executionManager.Setup(o => o.StartTestRun(It.IsAny(), It.IsAny())).Callback(() => System.Threading.Thread.Sleep(5 * 1000)); + executionManager.Setup(o => o.StartTestRun(It.IsAny(), It.IsAny())).Callback(() => Thread.Sleep(5 * 1000)); - testRunRequest.ExecuteAsync(); + testRunRequest.ExecuteAsync(); - executionManager.Verify(o => o.Abort(It.IsAny()), Times.Never); - } + executionManager.Verify(o => o.Abort(It.IsAny()), Times.Never); + } - [TestMethod] - public void HandleTestRunStatsChangeShouldInvokeListenersWithTestRunChangedEventArgs() - { - var mockStats = new Mock(); - - var testResults = new List - { - new ObjectModel.TestResult( - new ObjectModel.TestCase( - "A.C.M", - new Uri("executor://dummy"), - "A")) - }; - var activeTestCases = new List - { - new ObjectModel.TestCase( - "A.C.M2", - new Uri("executor://dummy"), - "A") - }; - var testRunChangedEventArgs = new TestRunChangedEventArgs(mockStats.Object, testResults, activeTestCases); - TestRunChangedEventArgs receivedArgs = null; - - testRunRequest.OnRunStatsChange += (object sender, TestRunChangedEventArgs e) => - { - receivedArgs = e; - }; - - // Act. - testRunRequest.HandleTestRunStatsChange(testRunChangedEventArgs); - - // Assert. - Assert.IsNotNull(receivedArgs); - Assert.AreEqual(testRunChangedEventArgs.TestRunStatistics, receivedArgs.TestRunStatistics); - CollectionAssert.AreEqual( - testRunChangedEventArgs.NewTestResults.ToList(), - receivedArgs.NewTestResults.ToList()); - CollectionAssert.AreEqual(testRunChangedEventArgs.ActiveTests.ToList(), receivedArgs.ActiveTests.ToList()); - } + [TestMethod] + public void HandleTestRunStatsChangeShouldInvokeListenersWithTestRunChangedEventArgs() + { + var mockStats = new Mock(); - [TestMethod] - public void HandleRawMessageShouldCallOnRawMessageReceived() + var testResults = new List { - string rawMessage = "HelloWorld"; - string messageReceived = null; - - // Call should NOT fail even if on raw message received is not registered. - testRunRequest.HandleRawMessage(rawMessage); + new ObjectModel.TestResult( + new TestCase( + "A.C.M", + new Uri("executor://dummy"), + "A")) + }; + var activeTestCases = new List + { + new TestCase( + "A.C.M2", + new Uri("executor://dummy"), + "A") + }; + var testRunChangedEventArgs = new TestRunChangedEventArgs(mockStats.Object, testResults, activeTestCases); + TestRunChangedEventArgs receivedArgs = null; + + _testRunRequest.OnRunStatsChange += (object sender, TestRunChangedEventArgs e) => receivedArgs = e; + + // Act. + _testRunRequest.HandleTestRunStatsChange(testRunChangedEventArgs); + + // Assert. + Assert.IsNotNull(receivedArgs); + Assert.AreEqual(testRunChangedEventArgs.TestRunStatistics, receivedArgs.TestRunStatistics); + CollectionAssert.AreEqual( + testRunChangedEventArgs.NewTestResults.ToList(), + receivedArgs.NewTestResults.ToList()); + CollectionAssert.AreEqual(testRunChangedEventArgs.ActiveTests.ToList(), receivedArgs.ActiveTests.ToList()); + } - EventHandler handler = (sender, e) => { messageReceived = e; }; - testRunRequest.OnRawMessageReceived += handler; + [TestMethod] + public void HandleRawMessageShouldCallOnRawMessageReceived() + { + string rawMessage = "HelloWorld"; + string messageReceived = null; - testRunRequest.HandleRawMessage(rawMessage); + // Call should NOT fail even if on raw message received is not registered. + _testRunRequest.HandleRawMessage(rawMessage); - Assert.AreEqual(rawMessage, messageReceived, "RunRequest should just pass the message as is."); - testRunRequest.OnRawMessageReceived -= handler; - } + EventHandler handler = (sender, e) => messageReceived = e; + _testRunRequest.OnRawMessageReceived += handler; - [TestMethod] - public void HandleRawMessageShouldAddVSTestDataPointsIfTelemetryOptedIn() - { - bool onDiscoveryCompleteInvoked = true; - this.mockRequestData.Setup(x => x.IsTelemetryOptedIn).Returns(true); - this.testRunRequest.OnRawMessageReceived += (object sender, string e) => - { - onDiscoveryCompleteInvoked = true; - }; - - this.mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())) - .Returns(new Message() { MessageType = MessageType.ExecutionComplete }); - - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) - .Returns(new TestRunCompletePayload() - { - TestRunCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.MinValue) - }); - - this.testRunRequest.HandleRawMessage(string.Empty); - - this.mockDataSerializer.Verify(x => x.SerializePayload(It.IsAny(), It.IsAny()), Times.Once); - this.mockRequestData.Verify(x => x.MetricsCollection, Times.AtLeastOnce); - Assert.IsTrue(onDiscoveryCompleteInvoked); - } + _testRunRequest.HandleRawMessage(rawMessage); - [TestMethod] - public void HandleRawMessageShouldInvokeHandleTestRunCompleteOfLoggerManager() - { - this.loggerManager.Setup(x => x.LoggersInitialized).Returns(true); - this.mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())) - .Returns(new Message() { MessageType = MessageType.ExecutionComplete }); - - var testRunCompleteEvent = new TestRunCompleteEventArgs(new TestRunStatistics(1, null), false, false, null, null, - null, TimeSpan.FromSeconds(0)); - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) - .Returns(new TestRunCompletePayload() - { - TestRunCompleteArgs = testRunCompleteEvent - }); - - this.testRunRequest.ExecuteAsync(); - this.testRunRequest.HandleRawMessage(string.Empty); - - this.loggerManager.Verify(lm => lm.HandleTestRunComplete(It.IsAny()), Times.Once); - } + Assert.AreEqual(rawMessage, messageReceived, "RunRequest should just pass the message as is."); + _testRunRequest.OnRawMessageReceived -= handler; + } - [TestMethod] - public void HandleRawMessageShouldNotInvokeHandleTestRunCompleteOfLoggerManagerWhenNoLoggersInitiailized() - { - this.loggerManager.Setup(x => x.LoggersInitialized).Returns(false); - this.mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())) - .Returns(new Message() { MessageType = MessageType.ExecutionComplete }); - - var testRunCompleteEvent = new TestRunCompleteEventArgs(new TestRunStatistics(1, null), false, false, null, null, - null, TimeSpan.FromSeconds(0)); - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) - .Returns(new TestRunCompletePayload() - { - TestRunCompleteArgs = testRunCompleteEvent - }); - - this.testRunRequest.ExecuteAsync(); - this.testRunRequest.HandleRawMessage(string.Empty); - - this.loggerManager.Verify(lm => lm.HandleTestRunComplete(It.IsAny()), Times.Never); - } + [TestMethod] + public void HandleRawMessageShouldAddVsTestDataPointsIfTelemetryOptedIn() + { + bool onDiscoveryCompleteInvoked = true; + _mockRequestData.Setup(x => x.IsTelemetryOptedIn).Returns(true); + _testRunRequest.OnRawMessageReceived += (object sender, string e) => onDiscoveryCompleteInvoked = true; - [TestMethod] - public void HandleRawMessageShouldInvokeShouldInvokeHandleTestRunStatsChangeOfLoggerManagerWhenLastChunkAvailable() - { - var mockStats = new Mock(); + _mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())) + .Returns(new Message() { MessageType = MessageType.ExecutionComplete }); - var testResults = new List + _mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) + .Returns(new TestRunCompletePayload() { - new ObjectModel.TestResult( - new ObjectModel.TestCase( - "A.C.M", - new Uri("executor://dummy"), - "A")) - }; - var activeTestCases = new List + TestRunCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.MinValue) + }); + + _testRunRequest.HandleRawMessage(string.Empty); + + _mockDataSerializer.Verify(x => x.SerializePayload(It.IsAny(), It.IsAny()), Times.Once); + _mockRequestData.Verify(x => x.MetricsCollection, Times.AtLeastOnce); + Assert.IsTrue(onDiscoveryCompleteInvoked); + } + + [TestMethod] + public void HandleRawMessageShouldInvokeHandleTestRunCompleteOfLoggerManager() + { + _loggerManager.Setup(x => x.LoggersInitialized).Returns(true); + _mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())) + .Returns(new Message() { MessageType = MessageType.ExecutionComplete }); + + var testRunCompleteEvent = new TestRunCompleteEventArgs(new TestRunStatistics(1, null), false, false, null, null, + null, TimeSpan.FromSeconds(0)); + _mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) + .Returns(new TestRunCompletePayload() { - new ObjectModel.TestCase( - "A.C.M2", - new Uri("executor://dummy"), - "A") - }; + TestRunCompleteArgs = testRunCompleteEvent + }); - this.loggerManager.Setup(x => x.LoggersInitialized).Returns(true); - this.mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())) - .Returns(new Message() { MessageType = MessageType.ExecutionComplete }); + _testRunRequest.ExecuteAsync(); + _testRunRequest.HandleRawMessage(string.Empty); - var testRunChangedEventArgs = new TestRunChangedEventArgs(mockStats.Object, testResults, activeTestCases); - var testRunCompleteEvent = new TestRunCompleteEventArgs(new TestRunStatistics(1, null), false, false, null, null, - null, TimeSpan.FromSeconds(0)); + _loggerManager.Verify(lm => lm.HandleTestRunComplete(It.IsAny()), Times.Once); + } - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) - .Returns(new TestRunCompletePayload() - { - TestRunCompleteArgs = testRunCompleteEvent, - LastRunTests = testRunChangedEventArgs - }); + [TestMethod] + public void HandleRawMessageShouldNotInvokeHandleTestRunCompleteOfLoggerManagerWhenNoLoggersInitiailized() + { + _loggerManager.Setup(x => x.LoggersInitialized).Returns(false); + _mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())) + .Returns(new Message() { MessageType = MessageType.ExecutionComplete }); + + var testRunCompleteEvent = new TestRunCompleteEventArgs(new TestRunStatistics(1, null), false, false, null, null, + null, TimeSpan.FromSeconds(0)); + _mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) + .Returns(new TestRunCompletePayload() + { + TestRunCompleteArgs = testRunCompleteEvent + }); - this.testRunRequest.ExecuteAsync(); - this.testRunRequest.HandleRawMessage(string.Empty); + _testRunRequest.ExecuteAsync(); + _testRunRequest.HandleRawMessage(string.Empty); - loggerManager.Verify(lm => lm.HandleTestRunStatsChange(testRunChangedEventArgs), Times.Once); - loggerManager.Verify(lm => lm.HandleTestRunComplete(It.IsAny()), Times.Once); - } + _loggerManager.Verify(lm => lm.HandleTestRunComplete(It.IsAny()), Times.Never); + } - [TestMethod] - public void HandleTestRunStatsChangeShouldInvokeHandleTestRunStatsChangeOfLoggerManager() - { - var mockStats = new Mock(); + [TestMethod] + public void HandleRawMessageShouldInvokeShouldInvokeHandleTestRunStatsChangeOfLoggerManagerWhenLastChunkAvailable() + { + var mockStats = new Mock(); - var testResults = new List - { - new ObjectModel.TestResult( - new ObjectModel.TestCase( - "A.C.M", - new Uri("executor://dummy"), - "A")) - }; - var activeTestCases = new List - { - new ObjectModel.TestCase( - "A.C.M2", + var testResults = new List + { + new ObjectModel.TestResult( + new TestCase( + "A.C.M", new Uri("executor://dummy"), - "A") - }; + "A")) + }; + var activeTestCases = new List + { + new TestCase( + "A.C.M2", + new Uri("executor://dummy"), + "A") + }; + + _loggerManager.Setup(x => x.LoggersInitialized).Returns(true); + _mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())) + .Returns(new Message() { MessageType = MessageType.ExecutionComplete }); + + var testRunChangedEventArgs = new TestRunChangedEventArgs(mockStats.Object, testResults, activeTestCases); + var testRunCompleteEvent = new TestRunCompleteEventArgs(new TestRunStatistics(1, null), false, false, null, null, + null, TimeSpan.FromSeconds(0)); + + _mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) + .Returns(new TestRunCompletePayload() + { + TestRunCompleteArgs = testRunCompleteEvent, + LastRunTests = testRunChangedEventArgs + }); - var testRunChangedEventArgs = new TestRunChangedEventArgs(mockStats.Object, testResults, activeTestCases); - testRunRequest.HandleTestRunStatsChange(testRunChangedEventArgs); + _testRunRequest.ExecuteAsync(); + _testRunRequest.HandleRawMessage(string.Empty); - loggerManager.Verify(lm => lm.HandleTestRunStatsChange(testRunChangedEventArgs), Times.Once); - } + _loggerManager.Verify(lm => lm.HandleTestRunStatsChange(testRunChangedEventArgs), Times.Once); + _loggerManager.Verify(lm => lm.HandleTestRunComplete(It.IsAny()), Times.Once); + } - [TestMethod] - public void HandleTestRunCompleteShouldInvokeHandleTestRunStatsChangeOfLoggerManagerWhenLastChunkAvailable() - { - var mockStats = new Mock(); + [TestMethod] + public void HandleTestRunStatsChangeShouldInvokeHandleTestRunStatsChangeOfLoggerManager() + { + var mockStats = new Mock(); - var testResults = new List - { - new ObjectModel.TestResult( - new ObjectModel.TestCase( - "A.C.M", - new Uri("executor://dummy"), - "A")) - }; - var activeTestCases = new List - { - new ObjectModel.TestCase( - "A.C.M2", + var testResults = new List + { + new ObjectModel.TestResult( + new TestCase( + "A.C.M", new Uri("executor://dummy"), - "A") - }; - var testRunChangedEventArgs = new TestRunChangedEventArgs(mockStats.Object, testResults, activeTestCases); - var testRunCompleteEvent = new TestRunCompleteEventArgs(new TestRunStatistics(1, null), false, false, null, null, - null, TimeSpan.FromSeconds(0)); + "A")) + }; + var activeTestCases = new List + { + new TestCase( + "A.C.M2", + new Uri("executor://dummy"), + "A") + }; - testRunRequest.ExecuteAsync(); - testRunRequest.HandleTestRunComplete(testRunCompleteEvent, testRunChangedEventArgs, null, null); + var testRunChangedEventArgs = new TestRunChangedEventArgs(mockStats.Object, testResults, activeTestCases); + _testRunRequest.HandleTestRunStatsChange(testRunChangedEventArgs); - loggerManager.Verify(lm => lm.HandleTestRunStatsChange(testRunChangedEventArgs), Times.Once); - loggerManager.Verify(lm => lm.HandleTestRunComplete(It.IsAny()), Times.Once); - } + _loggerManager.Verify(lm => lm.HandleTestRunStatsChange(testRunChangedEventArgs), Times.Once); + } - [TestMethod] - public void HandleTestRunCompleteShouldInvokeHandleTestRunCompleteOfLoggerManager() + [TestMethod] + public void HandleTestRunCompleteShouldInvokeHandleTestRunStatsChangeOfLoggerManagerWhenLastChunkAvailable() + { + var mockStats = new Mock(); + + var testResults = new List { - var testRunCompleteEvent = new TestRunCompleteEventArgs(new TestRunStatistics(1, null), false, false, null, null, - null, TimeSpan.FromSeconds(0)); + new ObjectModel.TestResult( + new TestCase( + "A.C.M", + new Uri("executor://dummy"), + "A")) + }; + var activeTestCases = new List + { + new TestCase( + "A.C.M2", + new Uri("executor://dummy"), + "A") + }; + var testRunChangedEventArgs = new TestRunChangedEventArgs(mockStats.Object, testResults, activeTestCases); + var testRunCompleteEvent = new TestRunCompleteEventArgs(new TestRunStatistics(1, null), false, false, null, null, + null, TimeSpan.FromSeconds(0)); + + _testRunRequest.ExecuteAsync(); + _testRunRequest.HandleTestRunComplete(testRunCompleteEvent, testRunChangedEventArgs, null, null); + + _loggerManager.Verify(lm => lm.HandleTestRunStatsChange(testRunChangedEventArgs), Times.Once); + _loggerManager.Verify(lm => lm.HandleTestRunComplete(It.IsAny()), Times.Once); + } - testRunRequest.ExecuteAsync(); - testRunRequest.HandleTestRunComplete(testRunCompleteEvent, null, null, null); + [TestMethod] + public void HandleTestRunCompleteShouldInvokeHandleTestRunCompleteOfLoggerManager() + { + var testRunCompleteEvent = new TestRunCompleteEventArgs(new TestRunStatistics(1, null), false, false, null, null, + null, TimeSpan.FromSeconds(0)); - loggerManager.Verify(lm => lm.HandleTestRunComplete(It.IsAny()), Times.Once); - } + _testRunRequest.ExecuteAsync(); + _testRunRequest.HandleTestRunComplete(testRunCompleteEvent, null, null, null); - [TestMethod] - public void HandleLogMessageShouldInvokeHandleLogMessageOfLoggerManager() - { - testRunRequest.HandleLogMessage(TestMessageLevel.Error, "hello"); - loggerManager.Verify(lm => lm.HandleTestRunMessage(It.IsAny()), Times.Once); - } + _loggerManager.Verify(lm => lm.HandleTestRunComplete(It.IsAny()), Times.Once); + } - [TestMethod] - public void HandleTestRunCompleteShouldCollectMetrics() - { - var mockMetricsCollector = new Mock(); - var dict = new Dictionary(); - dict.Add("DummyMessage", "DummyValue"); - - mockMetricsCollector.Setup(mc => mc.Metrics).Returns(dict); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollector.Object); - - this.testRunRequest.ExecuteAsync(); - var testRunCompeleteEventsArgs = new TestRunCompleteEventArgs( - new TestRunStatistics(1, null), - false, - false, - null, - null, - null, - TimeSpan.FromSeconds(0)); - testRunCompeleteEventsArgs.Metrics = dict; - - // Act - this.testRunRequest.HandleTestRunComplete(testRunCompeleteEventsArgs, null, null, null); - - // Verify. - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenInSecForRun, It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add("DummyMessage", "DummyValue"), Times.Once); - } + [TestMethod] + public void HandleLogMessageShouldInvokeHandleLogMessageOfLoggerManager() + { + _testRunRequest.HandleLogMessage(TestMessageLevel.Error, "hello"); + _loggerManager.Verify(lm => lm.HandleTestRunMessage(It.IsAny()), Times.Once); + } - [TestMethod] - public void HandleTestRunCompleteShouldHandleListAttachments() - { - bool attachmentsFound = false; - this.testRunRequest.OnRunCompletion += (s, e) => - { - attachmentsFound = e.AttachmentSets != null && e.AttachmentSets.Count == 1; - }; - - List attachmentSets = new List { new AttachmentSet(new Uri("datacollector://attachment"), "datacollectorAttachment") }; - - this.testRunRequest.ExecuteAsync(); - var testRunCompeleteEventsArgs = new TestRunCompleteEventArgs( - new TestRunStatistics(1, null), - false, - false, - null, - null, - null, - TimeSpan.FromSeconds(0)); - - // Act - this.testRunRequest.HandleTestRunComplete(testRunCompeleteEventsArgs, null, attachmentSets, null); - - // Verify. - Assert.IsTrue(attachmentsFound); - } + [TestMethod] + public void HandleTestRunCompleteShouldCollectMetrics() + { + var mockMetricsCollector = new Mock(); + var dict = new Dictionary + { + { "DummyMessage", "DummyValue" } + }; + + mockMetricsCollector.Setup(mc => mc.Metrics).Returns(dict); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollector.Object); + + _testRunRequest.ExecuteAsync(); + var testRunCompeleteEventsArgs = new TestRunCompleteEventArgs( + new TestRunStatistics(1, null), + false, + false, + null, + null, + null, + TimeSpan.FromSeconds(0)); + testRunCompeleteEventsArgs.Metrics = dict; + + // Act + _testRunRequest.HandleTestRunComplete(testRunCompeleteEventsArgs, null, null, null); + + // Verify. + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenInSecForRun, It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add("DummyMessage", "DummyValue"), Times.Once); + } - [TestMethod] - public void HandleTestRunCompleteShouldHandleCollectionAttachments() - { - bool attachmentsFound = false; - this.testRunRequest.OnRunCompletion += (s, e) => - { - attachmentsFound = e.AttachmentSets != null && e.AttachmentSets.Count == 1; - }; - - Collection attachmentSets = new Collection(new List { new AttachmentSet(new Uri("datacollector://attachment"), "datacollectorAttachment") }); - - this.testRunRequest.ExecuteAsync(); - var testRunCompeleteEventsArgs = new TestRunCompleteEventArgs( - new TestRunStatistics(1, null), - false, - false, - null, - null, - null, - TimeSpan.FromSeconds(0)); - - // Act - this.testRunRequest.HandleTestRunComplete(testRunCompeleteEventsArgs, null, attachmentSets, null); - - // Verify. - Assert.IsTrue(attachmentsFound); - } + [TestMethod] + public void HandleTestRunCompleteShouldHandleListAttachments() + { + bool attachmentsFound = false; + _testRunRequest.OnRunCompletion += (s, e) => attachmentsFound = e.AttachmentSets != null && e.AttachmentSets.Count == 1; + + List attachmentSets = new() { new AttachmentSet(new Uri("datacollector://attachment"), "datacollectorAttachment") }; + + _testRunRequest.ExecuteAsync(); + var testRunCompeleteEventsArgs = new TestRunCompleteEventArgs( + new TestRunStatistics(1, null), + false, + false, + null, + null, + null, + TimeSpan.FromSeconds(0)); + + // Act + _testRunRequest.HandleTestRunComplete(testRunCompeleteEventsArgs, null, attachmentSets, null); + + // Verify. + Assert.IsTrue(attachmentsFound); + } - [TestMethod] - public void HandleTestRunCompleteShouldHandleEmptyAttachments() - { - bool attachmentsFound = false; - this.testRunRequest.OnRunCompletion += (s, e) => - { - attachmentsFound = (e.AttachmentSets.Count == 0); - }; - - this.testRunRequest.ExecuteAsync(); - var testRunCompeleteEventsArgs = new TestRunCompleteEventArgs( - new TestRunStatistics(1, null), - false, - false, - null, - null, - null, - TimeSpan.FromSeconds(0)); - - // Act - this.testRunRequest.HandleTestRunComplete(testRunCompeleteEventsArgs, null, null, null); - - // Verify. - Assert.IsTrue(attachmentsFound); - } + [TestMethod] + public void HandleTestRunCompleteShouldHandleCollectionAttachments() + { + bool attachmentsFound = false; + _testRunRequest.OnRunCompletion += (s, e) => attachmentsFound = e.AttachmentSets != null && e.AttachmentSets.Count == 1; + + Collection attachmentSets = new(new List { new AttachmentSet(new Uri("datacollector://attachment"), "datacollectorAttachment") }); + + _testRunRequest.ExecuteAsync(); + var testRunCompeleteEventsArgs = new TestRunCompleteEventArgs( + new TestRunStatistics(1, null), + false, + false, + null, + null, + null, + TimeSpan.FromSeconds(0)); + + // Act + _testRunRequest.HandleTestRunComplete(testRunCompeleteEventsArgs, null, attachmentSets, null); + + // Verify. + Assert.IsTrue(attachmentsFound); + } - [TestMethod] - public void HandleTestRunCompleteShouldCloseExecutionManager() - { - var events = new List(); - this.executionManager.Setup(em => em.Close()).Callback(() => events.Add("close")); - this.testRunRequest.OnRunCompletion += (s, e) => events.Add("complete"); - this.testRunRequest.ExecuteAsync(); + [TestMethod] + public void HandleTestRunCompleteShouldHandleEmptyAttachments() + { + bool attachmentsFound = false; + _testRunRequest.OnRunCompletion += (s, e) => attachmentsFound = (e.AttachmentSets.Count == 0); + + _testRunRequest.ExecuteAsync(); + var testRunCompeleteEventsArgs = new TestRunCompleteEventArgs( + new TestRunStatistics(1, null), + false, + false, + null, + null, + null, + TimeSpan.FromSeconds(0)); + + // Act + _testRunRequest.HandleTestRunComplete(testRunCompeleteEventsArgs, null, null, null); + + // Verify. + Assert.IsTrue(attachmentsFound); + } - this.testRunRequest.HandleTestRunComplete(new TestRunCompleteEventArgs(new TestRunStatistics(1, null), false, false, null, null, null, TimeSpan.FromSeconds(0)), null, null, null); + [TestMethod] + public void HandleTestRunCompleteShouldCloseExecutionManager() + { + var events = new List(); + _executionManager.Setup(em => em.Close()).Callback(() => events.Add("close")); + _testRunRequest.OnRunCompletion += (s, e) => events.Add("complete"); + _testRunRequest.ExecuteAsync(); - Assert.AreEqual(2, events.Count); - Assert.AreEqual("close", events[0]); - Assert.AreEqual("complete", events[1]); - } + _testRunRequest.HandleTestRunComplete(new TestRunCompleteEventArgs(new TestRunStatistics(1, null), false, false, null, null, null, TimeSpan.FromSeconds(0)), null, null, null); - [TestMethod] - public void LaunchProcessWithDebuggerAttachedShouldNotCallCustomLauncherIfTestRunIsNotInProgress() - { - var mockCustomLauncher = new Mock(); - testRunCriteria = new TestRunCriteria(new List { "foo" }, 1, false, null, TimeSpan.Zero, mockCustomLauncher.Object); - executionManager = new Mock(); - testRunRequest = new TestRunRequest(this.mockRequestData.Object, testRunCriteria, executionManager.Object, loggerManager.Object); + Assert.AreEqual(2, events.Count); + Assert.AreEqual("close", events[0]); + Assert.AreEqual("complete", events[1]); + } - var testProcessStartInfo = new TestProcessStartInfo(); - testRunRequest.LaunchProcessWithDebuggerAttached(testProcessStartInfo); + [TestMethod] + public void LaunchProcessWithDebuggerAttachedShouldNotCallCustomLauncherIfTestRunIsNotInProgress() + { + var mockCustomLauncher = new Mock(); + _testRunCriteria = new TestRunCriteria(new List { "foo" }, 1, false, null, TimeSpan.Zero, mockCustomLauncher.Object); + _executionManager = new Mock(); + _testRunRequest = new TestRunRequest(_mockRequestData.Object, _testRunCriteria, _executionManager.Object, _loggerManager.Object); - mockCustomLauncher.Verify(ml => ml.LaunchTestHost(It.IsAny()), Times.Never); - } + var testProcessStartInfo = new TestProcessStartInfo(); + _testRunRequest.LaunchProcessWithDebuggerAttached(testProcessStartInfo); - [TestMethod] - public void LaunchProcessWithDebuggerAttachedShouldNotCallCustomLauncherIfLauncherIsNotDebug() - { - var mockCustomLauncher = new Mock(); - testRunCriteria = new TestRunCriteria(new List { "foo" }, 1, false, null, TimeSpan.Zero, mockCustomLauncher.Object); - executionManager = new Mock(); - testRunRequest = new TestRunRequest(this.mockRequestData.Object, testRunCriteria, executionManager.Object, loggerManager.Object); + mockCustomLauncher.Verify(ml => ml.LaunchTestHost(It.IsAny()), Times.Never); + } - testRunRequest.ExecuteAsync(); + [TestMethod] + public void LaunchProcessWithDebuggerAttachedShouldNotCallCustomLauncherIfLauncherIsNotDebug() + { + var mockCustomLauncher = new Mock(); + _testRunCriteria = new TestRunCriteria(new List { "foo" }, 1, false, null, TimeSpan.Zero, mockCustomLauncher.Object); + _executionManager = new Mock(); + _testRunRequest = new TestRunRequest(_mockRequestData.Object, _testRunCriteria, _executionManager.Object, _loggerManager.Object); - var testProcessStartInfo = new TestProcessStartInfo(); - testRunRequest.LaunchProcessWithDebuggerAttached(testProcessStartInfo); + _testRunRequest.ExecuteAsync(); - mockCustomLauncher.Verify(ml => ml.LaunchTestHost(It.IsAny()), Times.Never); - } + var testProcessStartInfo = new TestProcessStartInfo(); + _testRunRequest.LaunchProcessWithDebuggerAttached(testProcessStartInfo); - [TestMethod] - public void LaunchProcessWithDebuggerAttachedShouldCallCustomLauncherIfLauncherIsDebugAndRunInProgress() - { - var mockCustomLauncher = new Mock(); - testRunCriteria = new TestRunCriteria(new List { "foo" }, 1, false, null, TimeSpan.Zero, mockCustomLauncher.Object); - executionManager = new Mock(); - testRunRequest = new TestRunRequest(this.mockRequestData.Object, testRunCriteria, executionManager.Object, loggerManager.Object); + mockCustomLauncher.Verify(ml => ml.LaunchTestHost(It.IsAny()), Times.Never); + } - testRunRequest.ExecuteAsync(); + [TestMethod] + public void LaunchProcessWithDebuggerAttachedShouldCallCustomLauncherIfLauncherIsDebugAndRunInProgress() + { + var mockCustomLauncher = new Mock(); + _testRunCriteria = new TestRunCriteria(new List { "foo" }, 1, false, null, TimeSpan.Zero, mockCustomLauncher.Object); + _executionManager = new Mock(); + _testRunRequest = new TestRunRequest(_mockRequestData.Object, _testRunCriteria, _executionManager.Object, _loggerManager.Object); - var testProcessStartInfo = new TestProcessStartInfo(); - mockCustomLauncher.Setup(ml => ml.IsDebug).Returns(true); - testRunRequest.LaunchProcessWithDebuggerAttached(testProcessStartInfo); + _testRunRequest.ExecuteAsync(); - mockCustomLauncher.Verify(ml => ml.LaunchTestHost(testProcessStartInfo), Times.Once); - } + var testProcessStartInfo = new TestProcessStartInfo(); + mockCustomLauncher.Setup(ml => ml.IsDebug).Returns(true); + _testRunRequest.LaunchProcessWithDebuggerAttached(testProcessStartInfo); - /// - /// ExecuteAsync should invoke OnRunStart event. - /// - [TestMethod] - public void ExecuteAsyncShouldInvokeOnRunStart() - { - bool onRunStartHandlerCalled = false; - this.testRunRequest.OnRunStart += (s, e) => onRunStartHandlerCalled = true; + mockCustomLauncher.Verify(ml => ml.LaunchTestHost(testProcessStartInfo), Times.Once); + } - // Action - this.testRunRequest.ExecuteAsync(); + /// + /// ExecuteAsync should invoke OnRunStart event. + /// + [TestMethod] + public void ExecuteAsyncShouldInvokeOnRunStart() + { + bool onRunStartHandlerCalled = false; + _testRunRequest.OnRunStart += (s, e) => onRunStartHandlerCalled = true; - // Assert - Assert.IsTrue(onRunStartHandlerCalled, "ExecuteAsync should invoke OnRunstart event"); - } + // Action + _testRunRequest.ExecuteAsync(); - [TestMethod] - public void ExecuteAsyncShouldInvokeHandleTestRunStartOfLoggerManager() - { - this.testRunRequest.ExecuteAsync(); + // Assert + Assert.IsTrue(onRunStartHandlerCalled, "ExecuteAsync should invoke OnRunstart event"); + } - loggerManager.Verify(lm => lm.HandleTestRunStart(It.IsAny()), Times.Once); - } + [TestMethod] + public void ExecuteAsyncShouldInvokeHandleTestRunStartOfLoggerManager() + { + _testRunRequest.ExecuteAsync(); + + _loggerManager.Verify(lm => lm.HandleTestRunStart(It.IsAny()), Times.Once); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Client.UnitTests/Program.cs b/test/Microsoft.TestPlatform.Client.UnitTests/Program.cs index 220caa36c3..86eac1fd21 100644 --- a/test/Microsoft.TestPlatform.Client.UnitTests/Program.cs +++ b/test/Microsoft.TestPlatform.Client.UnitTests/Program.cs @@ -1,11 +1,11 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Client.UnitTests +namespace Microsoft.VisualStudio.TestPlatform.Client.UnitTests; + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Client.UnitTests/TestPlatformTests.cs b/test/Microsoft.TestPlatform.Client.UnitTests/TestPlatformTests.cs index a0402eaa98..af389a5d76 100644 --- a/test/Microsoft.TestPlatform.Client.UnitTests/TestPlatformTests.cs +++ b/test/Microsoft.TestPlatform.Client.UnitTests/TestPlatformTests.cs @@ -1,704 +1,703 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Client.UnitTests +namespace Microsoft.VisualStudio.TestPlatform.Client.UnitTests; + +using System; +using System.IO; +using System.Collections.Generic; + +using Microsoft.VisualStudio.TestPlatform.Client.Execution; +using Common.Hosting; +using Common.Logging; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using ObjectModel.Engine; +using ObjectModel.Host; +using Utilities.Helpers; +using Utilities.Helpers.Interfaces; +using TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class TestPlatformTests { - using System; - using System.IO; - using System.Collections.Generic; - - using Microsoft.VisualStudio.TestPlatform.Client.Execution; - using Microsoft.VisualStudio.TestPlatform.Common.Hosting; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - [TestClass] - public class TestPlatformTests - { - private readonly Mock testEngine; - private readonly Mock discoveryManager; - private readonly Mock extensionManager; - private readonly Mock hostManager; - private readonly Mock executionManager; - private readonly Mock loggerManager; - private readonly Mock mockFileHelper; - private Mock mockRequestData; - private Mock mockMetricsCollection; - - public TestPlatformTests() - { - this.testEngine = new Mock(); - this.discoveryManager = new Mock(); - this.extensionManager = new Mock(); - this.executionManager = new Mock(); - this.loggerManager = new Mock(); - this.hostManager = new Mock(); - this.mockFileHelper = new Mock(); - this.mockMetricsCollection = new Mock(); - this.mockRequestData = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(this.mockMetricsCollection.Object); - } + private readonly Mock _testEngine; + private readonly Mock _discoveryManager; + private readonly Mock _extensionManager; + private readonly Mock _hostManager; + private readonly Mock _executionManager; + private readonly Mock _loggerManager; + private readonly Mock _mockFileHelper; + private readonly Mock _mockRequestData; + private readonly Mock _mockMetricsCollection; + + public TestPlatformTests() + { + _testEngine = new Mock(); + _discoveryManager = new Mock(); + _extensionManager = new Mock(); + _executionManager = new Mock(); + _loggerManager = new Mock(); + _hostManager = new Mock(); + _mockFileHelper = new Mock(); + _mockMetricsCollection = new Mock(); + _mockRequestData = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(_mockMetricsCollection.Object); + } - [TestMethod] - public void CreateDiscoveryRequestShouldInitializeManagersAndCreateDiscoveryRequestWithGivenCriteriaAndReturnIt() - { - this.discoveryManager.Setup(dm => dm.Initialize(false)).Verifiable(); - var discoveryCriteria = new DiscoveryCriteria(new List { "foo" }, 1, null); - this.hostManager.Setup(hm => hm.GetTestSources(discoveryCriteria.Sources)) - .Returns(discoveryCriteria.Sources); + [TestMethod] + public void CreateDiscoveryRequestShouldInitializeManagersAndCreateDiscoveryRequestWithGivenCriteriaAndReturnIt() + { + _discoveryManager.Setup(dm => dm.Initialize(false)).Verifiable(); + var discoveryCriteria = new DiscoveryCriteria(new List { "foo" }, 1, null); + _hostManager.Setup(hm => hm.GetTestSources(discoveryCriteria.Sources)) + .Returns(discoveryCriteria.Sources); - this.testEngine.Setup(te => te.GetDiscoveryManager(this.mockRequestData.Object, this.hostManager.Object, It.IsAny())).Returns(this.discoveryManager.Object); - this.testEngine.Setup(te => te.GetExtensionManager()).Returns(this.extensionManager.Object); - this.testEngine.Setup(te => te.GetLoggerManager(this.mockRequestData.Object)).Returns(this.loggerManager.Object); - var tp = new TestableTestPlatform(this.testEngine.Object, this.hostManager.Object); + _testEngine.Setup(te => te.GetDiscoveryManager(_mockRequestData.Object, _hostManager.Object, It.IsAny())).Returns(_discoveryManager.Object); + _testEngine.Setup(te => te.GetExtensionManager()).Returns(_extensionManager.Object); + _testEngine.Setup(te => te.GetLoggerManager(_mockRequestData.Object)).Returns(_loggerManager.Object); + var tp = new TestableTestPlatform(_testEngine.Object, _hostManager.Object); - var discoveryRequest = tp.CreateDiscoveryRequest(this.mockRequestData.Object, discoveryCriteria, new TestPlatformOptions()); + var discoveryRequest = tp.CreateDiscoveryRequest(_mockRequestData.Object, discoveryCriteria, new TestPlatformOptions()); - this.hostManager.Verify(hm => hm.Initialize(It.IsAny(), It.IsAny()), Times.Once); - this.discoveryManager.Verify(dm => dm.Initialize(false), Times.Once); - Assert.AreEqual(discoveryCriteria, discoveryRequest.DiscoveryCriteria); - } + _hostManager.Verify(hm => hm.Initialize(It.IsAny(), It.IsAny()), Times.Once); + _discoveryManager.Verify(dm => dm.Initialize(false), Times.Once); + Assert.AreEqual(discoveryCriteria, discoveryRequest.DiscoveryCriteria); + } - [TestMethod] - public void CreateDiscoveryRequestShouldInitializeManagersWithFalseFlagWhenSkipDefaultAdaptersIsFalse() + [TestMethod] + public void CreateDiscoveryRequestShouldInitializeManagersWithFalseFlagWhenSkipDefaultAdaptersIsFalse() + { + var options = new TestPlatformOptions() { - var options = new TestPlatformOptions() - { - SkipDefaultAdapters = false - }; + SkipDefaultAdapters = false + }; - InvokeCreateDiscoveryRequest(options); + InvokeCreateDiscoveryRequest(options); - this.discoveryManager.Verify(dm => dm.Initialize(false), Times.Once); - } + _discoveryManager.Verify(dm => dm.Initialize(false), Times.Once); + } - [TestMethod] - public void CreateDiscoveryRequestShouldInitializeManagersWithTrueFlagWhenSkipDefaultAdaptersIsTrue() + [TestMethod] + public void CreateDiscoveryRequestShouldInitializeManagersWithTrueFlagWhenSkipDefaultAdaptersIsTrue() + { + var options = new TestPlatformOptions() { - var options = new TestPlatformOptions() - { - SkipDefaultAdapters = true - }; + SkipDefaultAdapters = true + }; - InvokeCreateDiscoveryRequest(options); + InvokeCreateDiscoveryRequest(options); - this.discoveryManager.Verify(dm => dm.Initialize(true), Times.Once); - } + _discoveryManager.Verify(dm => dm.Initialize(true), Times.Once); + } - [TestMethod] - public void CreateDiscoveryRequestShouldInitializeManagersWithFalseFlagWhenTestPlatformOptionsIsNull() - { - InvokeCreateDiscoveryRequest(); + [TestMethod] + public void CreateDiscoveryRequestShouldInitializeManagersWithFalseFlagWhenTestPlatformOptionsIsNull() + { + InvokeCreateDiscoveryRequest(); - this.discoveryManager.Verify(dm => dm.Initialize(false), Times.Once); - } + _discoveryManager.Verify(dm => dm.Initialize(false), Times.Once); + } - [TestMethod] - public void CreateDiscoveryRequestThrowsIfDiscoveryCriteriaIsNull() - { - TestPlatform tp = new TestPlatform(); + [TestMethod] + public void CreateDiscoveryRequestThrowsIfDiscoveryCriteriaIsNull() + { + TestPlatform tp = new(); - Assert.ThrowsException(() => tp.CreateDiscoveryRequest(this.mockRequestData.Object, null, new TestPlatformOptions())); - } + Assert.ThrowsException(() => tp.CreateDiscoveryRequest(_mockRequestData.Object, null, new TestPlatformOptions())); + } - [TestMethod] - public void UpdateExtensionsShouldUpdateTheEngineWithAdditionalExtensions() - { - this.testEngine.Setup(te => te.GetExtensionManager()).Returns(this.extensionManager.Object); - var tp = new TestableTestPlatform(this.testEngine.Object, this.hostManager.Object); - var additionalExtensions = new List { "e1.dll", "e2.dll" }; + [TestMethod] + public void UpdateExtensionsShouldUpdateTheEngineWithAdditionalExtensions() + { + _testEngine.Setup(te => te.GetExtensionManager()).Returns(_extensionManager.Object); + var tp = new TestableTestPlatform(_testEngine.Object, _hostManager.Object); + var additionalExtensions = new List { "e1.dll", "e2.dll" }; - tp.UpdateExtensions(additionalExtensions, skipExtensionFilters: true); + tp.UpdateExtensions(additionalExtensions, skipExtensionFilters: true); - this.extensionManager.Verify(em => em.UseAdditionalExtensions(additionalExtensions, true)); - } + _extensionManager.Verify(em => em.UseAdditionalExtensions(additionalExtensions, true)); + } - [TestMethod] - public void ClearExtensionsShouldClearTheExtensionsCachedInEngine() - { - this.testEngine.Setup(te => te.GetExtensionManager()).Returns(this.extensionManager.Object); - var tp = new TestableTestPlatform(this.testEngine.Object, this.hostManager.Object); + [TestMethod] + public void ClearExtensionsShouldClearTheExtensionsCachedInEngine() + { + _testEngine.Setup(te => te.GetExtensionManager()).Returns(_extensionManager.Object); + var tp = new TestableTestPlatform(_testEngine.Object, _hostManager.Object); - tp.ClearExtensions(); + tp.ClearExtensions(); - this.extensionManager.Verify(em => em.ClearExtensions()); - } + _extensionManager.Verify(em => em.ClearExtensions()); + } - [TestMethod] - public void CreateTestRunRequestShouldThrowExceptionIfNoTestHostproviderFound() - { - this.testEngine.Setup(te => te.GetLoggerManager(this.mockRequestData.Object)).Returns(this.loggerManager.Object); + [TestMethod] + public void CreateTestRunRequestShouldThrowExceptionIfNoTestHostproviderFound() + { + _testEngine.Setup(te => te.GetLoggerManager(_mockRequestData.Object)).Returns(_loggerManager.Object); - string settingsXml = - @" + string settingsXml = + @" .NETPortable,Version=v4.5 "; - var testRunCriteria = new TestRunCriteria(new List { @"x:dummy\foo.dll" }, 10, false, settingsXml, TimeSpan.Zero); - var tp = new TestableTestPlatform(this.testEngine.Object, this.mockFileHelper.Object, null); - bool exceptionThrown = false; - - try - { - tp.CreateTestRunRequest(this.mockRequestData.Object, testRunCriteria, new TestPlatformOptions()); - } - catch(TestPlatformException ex) - { - exceptionThrown = true; - Assert.AreEqual("No suitable test runtime provider found for this run.", ex.Message); - } - - Assert.IsTrue(exceptionThrown, "TestPlatformException should get thrown"); - } + var testRunCriteria = new TestRunCriteria(new List { @"x:dummy\foo.dll" }, 10, false, settingsXml, TimeSpan.Zero); + var tp = new TestableTestPlatform(_testEngine.Object, _mockFileHelper.Object, null); + bool exceptionThrown = false; - [TestMethod] - public void CreateTestRunRequestShouldUpdateLoggerExtensionWhenDesingModeIsFalseForRunAll() + try + { + tp.CreateTestRunRequest(_mockRequestData.Object, testRunCriteria, new TestPlatformOptions()); + } + catch (TestPlatformException ex) { - var additionalExtensions = new List { "foo.TestLogger.dll", "Joo.TestLogger.dll" }; - this.mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); - this.mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny(), System.IO.SearchOption.TopDirectoryOnly, It.IsAny())).Returns(additionalExtensions); - this.executionManager.Setup(dm => dm.Initialize(false)).Verifiable(); + exceptionThrown = true; + Assert.AreEqual("No suitable test runtime provider found for this run.", ex.Message); + } + + Assert.IsTrue(exceptionThrown, "TestPlatformException should get thrown"); + } + + [TestMethod] + public void CreateTestRunRequestShouldUpdateLoggerExtensionWhenDesingModeIsFalseForRunAll() + { + var additionalExtensions = new List { "foo.TestLogger.dll", "Joo.TestLogger.dll" }; + _mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); + _mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny(), SearchOption.TopDirectoryOnly, It.IsAny())).Returns(additionalExtensions); + _executionManager.Setup(dm => dm.Initialize(false)).Verifiable(); - string settingsXml = - @" + string settingsXml = + @" false "; - var temp = Path.GetTempPath(); - var testRunCriteria = new TestRunCriteria(new List { $@"{temp}foo.dll" }, 10, false, settingsXml, TimeSpan.Zero); - this.hostManager.Setup(hm => hm.GetTestSources(testRunCriteria.Sources)) - .Returns(testRunCriteria.Sources); + var temp = Path.GetTempPath(); + var testRunCriteria = new TestRunCriteria(new List { $@"{temp}foo.dll" }, 10, false, settingsXml, TimeSpan.Zero); + _hostManager.Setup(hm => hm.GetTestSources(testRunCriteria.Sources)) + .Returns(testRunCriteria.Sources); - this.testEngine.Setup(te => te.GetExecutionManager(this.mockRequestData.Object, this.hostManager.Object, It.IsAny())).Returns(this.executionManager.Object); - this.testEngine.Setup(te => te.GetExtensionManager()).Returns(this.extensionManager.Object); - this.testEngine.Setup(te => te.GetLoggerManager(this.mockRequestData.Object)).Returns(this.loggerManager.Object); + _testEngine.Setup(te => te.GetExecutionManager(_mockRequestData.Object, _hostManager.Object, It.IsAny())).Returns(_executionManager.Object); + _testEngine.Setup(te => te.GetExtensionManager()).Returns(_extensionManager.Object); + _testEngine.Setup(te => te.GetLoggerManager(_mockRequestData.Object)).Returns(_loggerManager.Object); - var tp = new TestableTestPlatform(this.testEngine.Object, this.mockFileHelper.Object, this.hostManager.Object); + var tp = new TestableTestPlatform(_testEngine.Object, _mockFileHelper.Object, _hostManager.Object); - var testRunRequest = tp.CreateTestRunRequest(this.mockRequestData.Object, testRunCriteria, new TestPlatformOptions()); - this.extensionManager.Verify(em => em.UseAdditionalExtensions(additionalExtensions, false)); - } + var testRunRequest = tp.CreateTestRunRequest(_mockRequestData.Object, testRunCriteria, new TestPlatformOptions()); + _extensionManager.Verify(em => em.UseAdditionalExtensions(additionalExtensions, false)); + } - [TestMethod] - public void CreateTestRunRequestShouldUpdateLoggerExtensionWhenDesignModeIsFalseForRunSelected() - { - var additionalExtensions = new List { "foo.TestLogger.dll", "Joo.TestLogger.dll" }; - this.mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); - this.mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny(), System.IO.SearchOption.TopDirectoryOnly, It.IsAny())).Returns(additionalExtensions); + [TestMethod] + public void CreateTestRunRequestShouldUpdateLoggerExtensionWhenDesignModeIsFalseForRunSelected() + { + var additionalExtensions = new List { "foo.TestLogger.dll", "Joo.TestLogger.dll" }; + _mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); + _mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny(), SearchOption.TopDirectoryOnly, It.IsAny())).Returns(additionalExtensions); - this.executionManager.Setup(dm => dm.Initialize(false)).Verifiable(); + _executionManager.Setup(dm => dm.Initialize(false)).Verifiable(); - string settingsXml = - @" + string settingsXml = + @" false "; - var testRunCriteria = new TestRunCriteria(new List { new TestCase("dll1.class1.test1", new Uri("hello://x/"), $"xyz{Path.DirectorySeparatorChar}1.dll") }, 10, false, settingsXml); + var testRunCriteria = new TestRunCriteria(new List { new TestCase("dll1.class1.test1", new Uri("hello://x/"), $"xyz{Path.DirectorySeparatorChar}1.dll") }, 10, false, settingsXml); - this.testEngine.Setup(te => te.GetExecutionManager(this.mockRequestData.Object, this.hostManager.Object, It.IsAny())).Returns(this.executionManager.Object); - this.testEngine.Setup(te => te.GetExtensionManager()).Returns(this.extensionManager.Object); - this.testEngine.Setup(te => te.GetLoggerManager(this.mockRequestData.Object)).Returns(this.loggerManager.Object); + _testEngine.Setup(te => te.GetExecutionManager(_mockRequestData.Object, _hostManager.Object, It.IsAny())).Returns(_executionManager.Object); + _testEngine.Setup(te => te.GetExtensionManager()).Returns(_extensionManager.Object); + _testEngine.Setup(te => te.GetLoggerManager(_mockRequestData.Object)).Returns(_loggerManager.Object); - var tp = new TestableTestPlatform(this.testEngine.Object, this.mockFileHelper.Object, this.hostManager.Object); + var tp = new TestableTestPlatform(_testEngine.Object, _mockFileHelper.Object, _hostManager.Object); - var testRunRequest = tp.CreateTestRunRequest(this.mockRequestData.Object, testRunCriteria, new TestPlatformOptions()); - this.extensionManager.Verify(em => em.UseAdditionalExtensions(additionalExtensions, false)); - } + var testRunRequest = tp.CreateTestRunRequest(_mockRequestData.Object, testRunCriteria, new TestPlatformOptions()); + _extensionManager.Verify(em => em.UseAdditionalExtensions(additionalExtensions, false)); + } - [TestMethod] - public void CreateTestRunRequestShouldNotUpdateTestSourcesIfSelectedTestAreRun() - { - var additionalExtensions = new List { "foo.TestLogger.dll", "Joo.TestLogger.dll" }; - this.mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); - this.mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny(), System.IO.SearchOption.TopDirectoryOnly, It.IsAny())).Returns(additionalExtensions); + [TestMethod] + public void CreateTestRunRequestShouldNotUpdateTestSourcesIfSelectedTestAreRun() + { + var additionalExtensions = new List { "foo.TestLogger.dll", "Joo.TestLogger.dll" }; + _mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); + _mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny(), SearchOption.TopDirectoryOnly, It.IsAny())).Returns(additionalExtensions); - this.executionManager.Setup(dm => dm.Initialize(false)).Verifiable(); + _executionManager.Setup(dm => dm.Initialize(false)).Verifiable(); - string settingsXml = - @" + string settingsXml = + @" false "; - var testRunCriteria = new TestRunCriteria(new List { new TestCase("dll1.class1.test1", new Uri("hello://x/"), $"xyz{Path.DirectorySeparatorChar}1.dll") }, 10, false, settingsXml); - this.hostManager.Setup(hm => hm.GetTestSources(It.IsAny>())) - .Returns(new List { $"xyz{Path.DirectorySeparatorChar}1.dll" }); + var testRunCriteria = new TestRunCriteria(new List { new TestCase("dll1.class1.test1", new Uri("hello://x/"), $"xyz{Path.DirectorySeparatorChar}1.dll") }, 10, false, settingsXml); + _hostManager.Setup(hm => hm.GetTestSources(It.IsAny>())) + .Returns(new List { $"xyz{Path.DirectorySeparatorChar}1.dll" }); - this.testEngine.Setup(te => te.GetExecutionManager(this.mockRequestData.Object, this.hostManager.Object, It.IsAny())).Returns(this.executionManager.Object); - this.testEngine.Setup(te => te.GetExtensionManager()).Returns(this.extensionManager.Object); - this.testEngine.Setup(te => te.GetLoggerManager(this.mockRequestData.Object)).Returns(this.loggerManager.Object); + _testEngine.Setup(te => te.GetExecutionManager(_mockRequestData.Object, _hostManager.Object, It.IsAny())).Returns(_executionManager.Object); + _testEngine.Setup(te => te.GetExtensionManager()).Returns(_extensionManager.Object); + _testEngine.Setup(te => te.GetLoggerManager(_mockRequestData.Object)).Returns(_loggerManager.Object); - var tp = new TestableTestPlatform(this.testEngine.Object, this.mockFileHelper.Object, this.hostManager.Object); + var tp = new TestableTestPlatform(_testEngine.Object, _mockFileHelper.Object, _hostManager.Object); - tp.CreateTestRunRequest(this.mockRequestData.Object, testRunCriteria, new TestPlatformOptions()); - this.extensionManager.Verify(em => em.UseAdditionalExtensions(additionalExtensions, false)); - this.hostManager.Verify(hm => hm.GetTestSources(It.IsAny>()), Times.Never); - } + tp.CreateTestRunRequest(_mockRequestData.Object, testRunCriteria, new TestPlatformOptions()); + _extensionManager.Verify(em => em.UseAdditionalExtensions(additionalExtensions, false)); + _hostManager.Verify(hm => hm.GetTestSources(It.IsAny>()), Times.Never); + } - [TestMethod] - public void CreateTestRunRequestShouldInitializeManagersAndCreateTestRunRequestWithSpecifiedCriteria() - { - this.executionManager.Setup(dm => dm.Initialize(false)).Verifiable(); - this.testEngine.Setup(te => te.GetExecutionManager(this.mockRequestData.Object, this.hostManager.Object, It.IsAny())).Returns(this.executionManager.Object); - this.testEngine.Setup(te => te.GetExtensionManager()).Returns(this.extensionManager.Object); - this.testEngine.Setup(te => te.GetLoggerManager(this.mockRequestData.Object)).Returns(this.loggerManager.Object); + [TestMethod] + public void CreateTestRunRequestShouldInitializeManagersAndCreateTestRunRequestWithSpecifiedCriteria() + { + _executionManager.Setup(dm => dm.Initialize(false)).Verifiable(); + _testEngine.Setup(te => te.GetExecutionManager(_mockRequestData.Object, _hostManager.Object, It.IsAny())).Returns(_executionManager.Object); + _testEngine.Setup(te => te.GetExtensionManager()).Returns(_extensionManager.Object); + _testEngine.Setup(te => te.GetLoggerManager(_mockRequestData.Object)).Returns(_loggerManager.Object); - var tp = new TestableTestPlatform(this.testEngine.Object, this.hostManager.Object); - var testRunCriteria = new TestRunCriteria(new List { "foo" }, 10); - this.hostManager.Setup(hm => hm.GetTestSources(testRunCriteria.Sources)) - .Returns(testRunCriteria.Sources); + var tp = new TestableTestPlatform(_testEngine.Object, _hostManager.Object); + var testRunCriteria = new TestRunCriteria(new List { "foo" }, 10); + _hostManager.Setup(hm => hm.GetTestSources(testRunCriteria.Sources)) + .Returns(testRunCriteria.Sources); - var testRunRequest = tp.CreateTestRunRequest(this.mockRequestData.Object, testRunCriteria, new TestPlatformOptions()); + var testRunRequest = tp.CreateTestRunRequest(_mockRequestData.Object, testRunCriteria, new TestPlatformOptions()); - var actualTestRunRequest = testRunRequest as TestRunRequest; + var actualTestRunRequest = testRunRequest as TestRunRequest; - this.hostManager.Verify(hm => hm.Initialize(It.IsAny(), It.IsAny()), Times.Once); - this.executionManager.Verify(em => em.Initialize(false), Times.Once); - Assert.AreEqual(testRunCriteria, actualTestRunRequest.TestRunCriteria); - } + _hostManager.Verify(hm => hm.Initialize(It.IsAny(), It.IsAny()), Times.Once); + _executionManager.Verify(em => em.Initialize(false), Times.Once); + Assert.AreEqual(testRunCriteria, actualTestRunRequest.TestRunCriteria); + } - [TestMethod] - public void CreateTestRunRequestShouldInitializeManagersWithFalseFlagWhenSkipDefaultAdaptersIsFalse() + [TestMethod] + public void CreateTestRunRequestShouldInitializeManagersWithFalseFlagWhenSkipDefaultAdaptersIsFalse() + { + var options = new TestPlatformOptions() { - var options = new TestPlatformOptions() - { - SkipDefaultAdapters = false - }; + SkipDefaultAdapters = false + }; - InvokeCreateTestRunRequest(options); + InvokeCreateTestRunRequest(options); - this.executionManager.Verify(dm => dm.Initialize(false), Times.Once); - } + _executionManager.Verify(dm => dm.Initialize(false), Times.Once); + } - [TestMethod] - public void CreateTestRunRequestShouldInitializeManagersWithTrueFlagWhenSkipDefaultAdaptersIsTrue() + [TestMethod] + public void CreateTestRunRequestShouldInitializeManagersWithTrueFlagWhenSkipDefaultAdaptersIsTrue() + { + var options = new TestPlatformOptions() { - var options = new TestPlatformOptions() - { - SkipDefaultAdapters = true - }; + SkipDefaultAdapters = true + }; - InvokeCreateTestRunRequest(options); + InvokeCreateTestRunRequest(options); - this.executionManager.Verify(dm => dm.Initialize(true), Times.Once); - } + _executionManager.Verify(dm => dm.Initialize(true), Times.Once); + } - [TestMethod] - public void CreateTestRunRequestShouldInitializeManagersWithFalseFlagWhenTestPlatformOptionsIsNull() - { - InvokeCreateTestRunRequest(); + [TestMethod] + public void CreateTestRunRequestShouldInitializeManagersWithFalseFlagWhenTestPlatformOptionsIsNull() + { + InvokeCreateTestRunRequest(); - this.executionManager.Verify(dm => dm.Initialize(false), Times.Once); - } + _executionManager.Verify(dm => dm.Initialize(false), Times.Once); + } - [TestMethod] - public void CreateTestRunRequestShouldSetCustomHostLauncherOnEngineDefaultLauncherIfSpecified() - { - var mockCustomLauncher = new Mock(); - this.executionManager.Setup(dm => dm.Initialize(false)).Verifiable(); - this.testEngine.Setup(te => te.GetExecutionManager(this.mockRequestData.Object, this.hostManager.Object, It.IsAny())).Returns(this.executionManager.Object); - this.testEngine.Setup(te => te.GetExtensionManager()).Returns(this.extensionManager.Object); - this.testEngine.Setup(te => te.GetLoggerManager(this.mockRequestData.Object)).Returns(this.loggerManager.Object); - - var tp = new TestableTestPlatform(this.testEngine.Object, this.hostManager.Object); - var testRunCriteria = new TestRunCriteria(new List { "foo" }, 10, false, null, TimeSpan.Zero, mockCustomLauncher.Object); - this.hostManager.Setup(hm => hm.GetTestSources(testRunCriteria.Sources)) - .Returns(testRunCriteria.Sources); - - var testRunRequest = tp.CreateTestRunRequest(this.mockRequestData.Object, testRunCriteria, new TestPlatformOptions()); - - var actualTestRunRequest = testRunRequest as TestRunRequest; - Assert.AreEqual(testRunCriteria, actualTestRunRequest.TestRunCriteria); - this.hostManager.Verify(hl => hl.SetCustomLauncher(mockCustomLauncher.Object), Times.Once); - } + [TestMethod] + public void CreateTestRunRequestShouldSetCustomHostLauncherOnEngineDefaultLauncherIfSpecified() + { + var mockCustomLauncher = new Mock(); + _executionManager.Setup(dm => dm.Initialize(false)).Verifiable(); + _testEngine.Setup(te => te.GetExecutionManager(_mockRequestData.Object, _hostManager.Object, It.IsAny())).Returns(_executionManager.Object); + _testEngine.Setup(te => te.GetExtensionManager()).Returns(_extensionManager.Object); + _testEngine.Setup(te => te.GetLoggerManager(_mockRequestData.Object)).Returns(_loggerManager.Object); + + var tp = new TestableTestPlatform(_testEngine.Object, _hostManager.Object); + var testRunCriteria = new TestRunCriteria(new List { "foo" }, 10, false, null, TimeSpan.Zero, mockCustomLauncher.Object); + _hostManager.Setup(hm => hm.GetTestSources(testRunCriteria.Sources)) + .Returns(testRunCriteria.Sources); + + var testRunRequest = tp.CreateTestRunRequest(_mockRequestData.Object, testRunCriteria, new TestPlatformOptions()); + + var actualTestRunRequest = testRunRequest as TestRunRequest; + Assert.AreEqual(testRunCriteria, actualTestRunRequest.TestRunCriteria); + _hostManager.Verify(hl => hl.SetCustomLauncher(mockCustomLauncher.Object), Times.Once); + } - [TestMethod] - public void CreateTestRunRequestThrowsIfTestRunCriteriaIsNull() - { - var tp = new TestPlatform(); + [TestMethod] + public void CreateTestRunRequestThrowsIfTestRunCriteriaIsNull() + { + var tp = new TestPlatform(); - Assert.ThrowsException(() => tp.CreateTestRunRequest(this.mockRequestData.Object, null, new TestPlatformOptions())); - } + Assert.ThrowsException(() => tp.CreateTestRunRequest(_mockRequestData.Object, null, new TestPlatformOptions())); + } - [TestMethod] - public void CreateDiscoveryRequestShouldThrowExceptionIfNoTestHostproviderFound() - { - this.testEngine.Setup(te => te.GetLoggerManager(this.mockRequestData.Object)) - .Returns(this.loggerManager.Object); + [TestMethod] + public void CreateDiscoveryRequestShouldThrowExceptionIfNoTestHostproviderFound() + { + _testEngine.Setup(te => te.GetLoggerManager(_mockRequestData.Object)) + .Returns(_loggerManager.Object); - string settingsXml = - @" + string settingsXml = + @" .NETPortable,Version=v4.5 "; - var discoveryCriteria = new DiscoveryCriteria(new List { @"x:dummy\foo.dll" }, 1, settingsXml); - var tp = new TestableTestPlatform(this.testEngine.Object, this.mockFileHelper.Object, null); - bool exceptionThrown = false; - - try - { - tp.CreateDiscoveryRequest(this.mockRequestData.Object, discoveryCriteria, new TestPlatformOptions()); - } - catch (TestPlatformException ex) - { - exceptionThrown = true; - Assert.AreEqual("No suitable test runtime provider found for this run.", ex.Message); - } - - Assert.IsTrue(exceptionThrown, "TestPlatformException should get thrown"); - } + var discoveryCriteria = new DiscoveryCriteria(new List { @"x:dummy\foo.dll" }, 1, settingsXml); + var tp = new TestableTestPlatform(_testEngine.Object, _mockFileHelper.Object, null); + bool exceptionThrown = false; - /// - /// Logger extensions should be updated when design mode is false. - /// - [TestMethod] - public void CreateDiscoveryRequestShouldUpdateLoggerExtensionWhenDesignModeIsFalse() + try { - var additionalExtensions = new List { "foo.TestLogger.dll", "Joo.TestLogger.dll" }; - this.mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); - this.mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny(), System.IO.SearchOption.TopDirectoryOnly, It.IsAny())).Returns(additionalExtensions); + tp.CreateDiscoveryRequest(_mockRequestData.Object, discoveryCriteria, new TestPlatformOptions()); + } + catch (TestPlatformException ex) + { + exceptionThrown = true; + Assert.AreEqual("No suitable test runtime provider found for this run.", ex.Message); + } + + Assert.IsTrue(exceptionThrown, "TestPlatformException should get thrown"); + } + + /// + /// Logger extensions should be updated when design mode is false. + /// + [TestMethod] + public void CreateDiscoveryRequestShouldUpdateLoggerExtensionWhenDesignModeIsFalse() + { + var additionalExtensions = new List { "foo.TestLogger.dll", "Joo.TestLogger.dll" }; + _mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); + _mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny(), SearchOption.TopDirectoryOnly, It.IsAny())).Returns(additionalExtensions); - this.discoveryManager.Setup(dm => dm.Initialize(false)).Verifiable(); + _discoveryManager.Setup(dm => dm.Initialize(false)).Verifiable(); - string settingsXml = - @" + string settingsXml = + @" false "; - var temp = Path.GetTempPath(); - var discoveryCriteria = new DiscoveryCriteria(new List { $@"{temp}foo.dll" }, 1, settingsXml); - this.hostManager.Setup(hm => hm.GetTestSources(discoveryCriteria.Sources)) - .Returns(discoveryCriteria.Sources); + var temp = Path.GetTempPath(); + var discoveryCriteria = new DiscoveryCriteria(new List { $@"{temp}foo.dll" }, 1, settingsXml); + _hostManager.Setup(hm => hm.GetTestSources(discoveryCriteria.Sources)) + .Returns(discoveryCriteria.Sources); - this.testEngine.Setup(te => te.GetDiscoveryManager(It.IsAny(), this.hostManager.Object, It.IsAny())).Returns(this.discoveryManager.Object); - this.testEngine.Setup(te => te.GetExtensionManager()).Returns(this.extensionManager.Object); - this.testEngine.Setup(te => te.GetLoggerManager(this.mockRequestData.Object)).Returns(this.loggerManager.Object); - var tp = new TestableTestPlatform(this.testEngine.Object, this.mockFileHelper.Object, this.hostManager.Object); + _testEngine.Setup(te => te.GetDiscoveryManager(It.IsAny(), _hostManager.Object, It.IsAny())).Returns(_discoveryManager.Object); + _testEngine.Setup(te => te.GetExtensionManager()).Returns(_extensionManager.Object); + _testEngine.Setup(te => te.GetLoggerManager(_mockRequestData.Object)).Returns(_loggerManager.Object); + var tp = new TestableTestPlatform(_testEngine.Object, _mockFileHelper.Object, _hostManager.Object); - // Action - var discoveryRequest = tp.CreateDiscoveryRequest(this.mockRequestData.Object, discoveryCriteria, new TestPlatformOptions()); + // Action + var discoveryRequest = tp.CreateDiscoveryRequest(_mockRequestData.Object, discoveryCriteria, new TestPlatformOptions()); - // Verify - this.extensionManager.Verify(em => em.UseAdditionalExtensions(additionalExtensions, false)); - } + // Verify + _extensionManager.Verify(em => em.UseAdditionalExtensions(additionalExtensions, false)); + } - /// - /// Create test run request should initialize logger manager for design mode. - /// - [TestMethod] - public void CreateTestRunRequestShouldInitializeLoggerManagerForDesignMode() - { - this.testEngine.Setup(te => te.GetExecutionManager(this.mockRequestData.Object, this.hostManager.Object, It.IsAny())).Returns(this.executionManager.Object); - this.testEngine.Setup(te => te.GetLoggerManager(this.mockRequestData.Object)).Returns(this.loggerManager.Object); + /// + /// Create test run request should initialize logger manager for design mode. + /// + [TestMethod] + public void CreateTestRunRequestShouldInitializeLoggerManagerForDesignMode() + { + _testEngine.Setup(te => te.GetExecutionManager(_mockRequestData.Object, _hostManager.Object, It.IsAny())).Returns(_executionManager.Object); + _testEngine.Setup(te => te.GetLoggerManager(_mockRequestData.Object)).Returns(_loggerManager.Object); - string settingsXml = - @" + string settingsXml = + @" True "; - var testRunCriteria = new TestRunCriteria(new List { @"x:dummy\foo.dll" }, 10, false, settingsXml); + var testRunCriteria = new TestRunCriteria(new List { @"x:dummy\foo.dll" }, 10, false, settingsXml); - var tp = new TestableTestPlatform(this.testEngine.Object, this.hostManager.Object); - tp.CreateTestRunRequest(this.mockRequestData.Object, testRunCriteria, new TestPlatformOptions()); + var tp = new TestableTestPlatform(_testEngine.Object, _hostManager.Object); + tp.CreateTestRunRequest(_mockRequestData.Object, testRunCriteria, new TestPlatformOptions()); - this.loggerManager.Verify(lm => lm.Initialize(settingsXml)); - } + _loggerManager.Verify(lm => lm.Initialize(settingsXml)); + } - /// - /// Create discovery request should initialize logger manager for design mode. - /// - [TestMethod] - public void CreateDiscoveryRequestShouldInitializeLoggerManagerForDesignMode() - { - this.testEngine.Setup(te => te.GetDiscoveryManager(this.mockRequestData.Object, this.hostManager.Object, It.IsAny())).Returns(this.discoveryManager.Object); - this.testEngine.Setup(te => te.GetLoggerManager(this.mockRequestData.Object)).Returns(this.loggerManager.Object); + /// + /// Create discovery request should initialize logger manager for design mode. + /// + [TestMethod] + public void CreateDiscoveryRequestShouldInitializeLoggerManagerForDesignMode() + { + _testEngine.Setup(te => te.GetDiscoveryManager(_mockRequestData.Object, _hostManager.Object, It.IsAny())).Returns(_discoveryManager.Object); + _testEngine.Setup(te => te.GetLoggerManager(_mockRequestData.Object)).Returns(_loggerManager.Object); - string settingsXml = - @" + string settingsXml = + @" True "; - var discoveryCriteria = new DiscoveryCriteria(new List { @"x:dummy\foo.dll" }, 10, settingsXml); + var discoveryCriteria = new DiscoveryCriteria(new List { @"x:dummy\foo.dll" }, 10, settingsXml); - var tp = new TestableTestPlatform(this.testEngine.Object, this.hostManager.Object); - tp.CreateDiscoveryRequest(this.mockRequestData.Object, discoveryCriteria, new TestPlatformOptions()); + var tp = new TestableTestPlatform(_testEngine.Object, _hostManager.Object); + tp.CreateDiscoveryRequest(_mockRequestData.Object, discoveryCriteria, new TestPlatformOptions()); - this.loggerManager.Verify(lm => lm.Initialize(settingsXml)); - } + _loggerManager.Verify(lm => lm.Initialize(settingsXml)); + } - /// - /// Create test run request should initialize logger manager for design mode. - /// - [TestMethod] - public void CreateTestRunRequestShouldInitializeLoggerManagerForNonDesignMode() - { - this.testEngine.Setup(te => te.GetExecutionManager(this.mockRequestData.Object, this.hostManager.Object, It.IsAny())).Returns(this.executionManager.Object); - this.testEngine.Setup(te => te.GetLoggerManager(this.mockRequestData.Object)).Returns(this.loggerManager.Object); + /// + /// Create test run request should initialize logger manager for design mode. + /// + [TestMethod] + public void CreateTestRunRequestShouldInitializeLoggerManagerForNonDesignMode() + { + _testEngine.Setup(te => te.GetExecutionManager(_mockRequestData.Object, _hostManager.Object, It.IsAny())).Returns(_executionManager.Object); + _testEngine.Setup(te => te.GetLoggerManager(_mockRequestData.Object)).Returns(_loggerManager.Object); - string settingsXml = - @" + string settingsXml = + @" False "; - var testRunCriteria = new TestRunCriteria(new List { "foo" }, 10, false, settingsXml); + var testRunCriteria = new TestRunCriteria(new List { "foo" }, 10, false, settingsXml); - var tp = new TestableTestPlatform(this.testEngine.Object, this.hostManager.Object); - tp.CreateTestRunRequest(this.mockRequestData.Object, testRunCriteria, new TestPlatformOptions()); + var tp = new TestableTestPlatform(_testEngine.Object, _hostManager.Object); + tp.CreateTestRunRequest(_mockRequestData.Object, testRunCriteria, new TestPlatformOptions()); - this.loggerManager.Verify(lm => lm.Initialize(settingsXml)); - } + _loggerManager.Verify(lm => lm.Initialize(settingsXml)); + } - /// - /// Create discovery request should initialize logger manager for design mode. - /// - [TestMethod] - public void CreateDiscoveryRequestShouldInitializeLoggerManagerForNonDesignMode() - { - this.testEngine.Setup(te => te.GetDiscoveryManager(this.mockRequestData.Object, this.hostManager.Object, It.IsAny())).Returns(this.discoveryManager.Object); - this.testEngine.Setup(te => te.GetLoggerManager(this.mockRequestData.Object)).Returns(this.loggerManager.Object); + /// + /// Create discovery request should initialize logger manager for design mode. + /// + [TestMethod] + public void CreateDiscoveryRequestShouldInitializeLoggerManagerForNonDesignMode() + { + _testEngine.Setup(te => te.GetDiscoveryManager(_mockRequestData.Object, _hostManager.Object, It.IsAny())).Returns(_discoveryManager.Object); + _testEngine.Setup(te => te.GetLoggerManager(_mockRequestData.Object)).Returns(_loggerManager.Object); - string settingsXml = - @" + string settingsXml = + @" False "; - var discoveryCriteria = new DiscoveryCriteria(new List { "foo" }, 10, settingsXml); + var discoveryCriteria = new DiscoveryCriteria(new List { "foo" }, 10, settingsXml); - var tp = new TestableTestPlatform(this.testEngine.Object, this.hostManager.Object); - tp.CreateDiscoveryRequest(this.mockRequestData.Object, discoveryCriteria, new TestPlatformOptions()); + var tp = new TestableTestPlatform(_testEngine.Object, _hostManager.Object); + tp.CreateDiscoveryRequest(_mockRequestData.Object, discoveryCriteria, new TestPlatformOptions()); - this.loggerManager.Verify(lm => lm.Initialize(settingsXml)); - } + _loggerManager.Verify(lm => lm.Initialize(settingsXml)); + } - [TestMethod] - public void StartTestSessionShouldThrowExceptionIfTestSessionCriteriaIsNull() - { - var tp = new TestableTestPlatform(this.testEngine.Object, this.hostManager.Object); + [TestMethod] + public void StartTestSessionShouldThrowExceptionIfTestSessionCriteriaIsNull() + { + var tp = new TestableTestPlatform(_testEngine.Object, _hostManager.Object); - Assert.ThrowsException(() => - tp.StartTestSession( - new Mock().Object, - null, - new Mock().Object)); - } + Assert.ThrowsException(() => + tp.StartTestSession( + new Mock().Object, + null, + new Mock().Object)); + } - [TestMethod] - public void StartTestSessionShouldReturnFalseIfDesignModeIsDisabled() - { - var tp = new TestableTestPlatform(this.testEngine.Object, this.hostManager.Object); + [TestMethod] + public void StartTestSessionShouldReturnFalseIfDesignModeIsDisabled() + { + var tp = new TestableTestPlatform(_testEngine.Object, _hostManager.Object); - var testSessionCriteria = new StartTestSessionCriteria() - { - RunSettings = @" + var testSessionCriteria = new StartTestSessionCriteria() + { + RunSettings = @" false " - }; + }; - Assert.IsFalse( - tp.StartTestSession( - new Mock().Object, - testSessionCriteria, - new Mock().Object)); - } + Assert.IsFalse( + tp.StartTestSession( + new Mock().Object, + testSessionCriteria, + new Mock().Object)); + } - [TestMethod] - public void StartTestSessionShouldReturnFalseIfTestSessionManagerIsNull() - { - this.testEngine.Setup( + [TestMethod] + public void StartTestSessionShouldReturnFalseIfTestSessionManagerIsNull() + { + _testEngine.Setup( te => te.GetTestSessionManager( It.IsAny(), It.IsAny())) - .Returns((IProxyTestSessionManager)null); + .Returns((IProxyTestSessionManager)null); - var tp = new TestableTestPlatform(this.testEngine.Object, this.hostManager.Object); - var mockEventsHandler = new Mock(); + var tp = new TestableTestPlatform(_testEngine.Object, _hostManager.Object); + var mockEventsHandler = new Mock(); - var testSessionCriteria = new StartTestSessionCriteria() - { - RunSettings = @" + var testSessionCriteria = new StartTestSessionCriteria() + { + RunSettings = @" true " - }; + }; - Assert.IsFalse( - tp.StartTestSession( - new Mock().Object, - testSessionCriteria, - mockEventsHandler.Object)); + Assert.IsFalse( + tp.StartTestSession( + new Mock().Object, + testSessionCriteria, + mockEventsHandler.Object)); - mockEventsHandler.Verify( - eh => eh.HandleStartTestSessionComplete(null), - Times.Once); - } + mockEventsHandler.Verify( + eh => eh.HandleStartTestSessionComplete(null), + Times.Once); + } - [TestMethod] - public void StartTestSessionShouldReturnTrueIfTestSessionManagerStartSessionReturnsTrue() - { - var tp = new TestableTestPlatform(this.testEngine.Object, this.hostManager.Object); + [TestMethod] + public void StartTestSessionShouldReturnTrueIfTestSessionManagerStartSessionReturnsTrue() + { + var tp = new TestableTestPlatform(_testEngine.Object, _hostManager.Object); - var testSessionCriteria = new StartTestSessionCriteria() - { - RunSettings = @" + var testSessionCriteria = new StartTestSessionCriteria() + { + RunSettings = @" true " - }; + }; - var mockEventsHandler = new Mock(); - var mockTestSessionManager = new Mock(); - mockTestSessionManager.Setup( + var mockEventsHandler = new Mock(); + var mockTestSessionManager = new Mock(); + mockTestSessionManager.Setup( tsm => tsm.StartSession(It.IsAny())) - .Returns(true); - this.testEngine.Setup( + .Returns(true); + _testEngine.Setup( te => te.GetTestSessionManager( It.IsAny(), It.IsAny())) - .Returns(mockTestSessionManager.Object); + .Returns(mockTestSessionManager.Object); - Assert.IsTrue( - tp.StartTestSession( - new Mock().Object, - testSessionCriteria, - mockEventsHandler.Object)); + Assert.IsTrue( + tp.StartTestSession( + new Mock().Object, + testSessionCriteria, + mockEventsHandler.Object)); - mockTestSessionManager.Verify( - tsm => tsm.StartSession(mockEventsHandler.Object)); - } + mockTestSessionManager.Verify( + tsm => tsm.StartSession(mockEventsHandler.Object)); + } - [TestMethod] - public void StartTestSessionShouldReturnFalseIfTestSessionManagerStartSessionReturnsFalse() - { - var tp = new TestableTestPlatform(this.testEngine.Object, this.hostManager.Object); + [TestMethod] + public void StartTestSessionShouldReturnFalseIfTestSessionManagerStartSessionReturnsFalse() + { + var tp = new TestableTestPlatform(_testEngine.Object, _hostManager.Object); - var testSessionCriteria = new StartTestSessionCriteria() - { - RunSettings = @" + var testSessionCriteria = new StartTestSessionCriteria() + { + RunSettings = @" true " - }; + }; - var mockEventsHandler = new Mock(); - var mockTestSessionManager = new Mock(); - mockTestSessionManager.Setup( + var mockEventsHandler = new Mock(); + var mockTestSessionManager = new Mock(); + mockTestSessionManager.Setup( tsm => tsm.StartSession(It.IsAny())) - .Returns(false); - this.testEngine.Setup( + .Returns(false); + _testEngine.Setup( te => te.GetTestSessionManager( It.IsAny(), It.IsAny())) - .Returns(mockTestSessionManager.Object); + .Returns(mockTestSessionManager.Object); - Assert.IsFalse( - tp.StartTestSession( - new Mock().Object, - testSessionCriteria, - mockEventsHandler.Object)); + Assert.IsFalse( + tp.StartTestSession( + new Mock().Object, + testSessionCriteria, + mockEventsHandler.Object)); - mockTestSessionManager.Verify( - tsm => tsm.StartSession(mockEventsHandler.Object)); - } + mockTestSessionManager.Verify( + tsm => tsm.StartSession(mockEventsHandler.Object)); + } - private void InvokeCreateDiscoveryRequest(TestPlatformOptions options = null) - { - this.discoveryManager.Setup(dm => dm.Initialize(false)).Verifiable(); - var discoveryCriteria = new DiscoveryCriteria(new List { "foo" }, 1, null); - this.hostManager.Setup(hm => hm.GetTestSources(discoveryCriteria.Sources)) - .Returns(discoveryCriteria.Sources); + private void InvokeCreateDiscoveryRequest(TestPlatformOptions options = null) + { + _discoveryManager.Setup(dm => dm.Initialize(false)).Verifiable(); + var discoveryCriteria = new DiscoveryCriteria(new List { "foo" }, 1, null); + _hostManager.Setup(hm => hm.GetTestSources(discoveryCriteria.Sources)) + .Returns(discoveryCriteria.Sources); - this.testEngine.Setup(te => te.GetDiscoveryManager(this.mockRequestData.Object, this.hostManager.Object, It.IsAny())).Returns(this.discoveryManager.Object); - this.testEngine.Setup(te => te.GetExtensionManager()).Returns(this.extensionManager.Object); - this.testEngine.Setup(te => te.GetLoggerManager(this.mockRequestData.Object)).Returns(this.loggerManager.Object); - var tp = new TestableTestPlatform(this.testEngine.Object, this.hostManager.Object); + _testEngine.Setup(te => te.GetDiscoveryManager(_mockRequestData.Object, _hostManager.Object, It.IsAny())).Returns(_discoveryManager.Object); + _testEngine.Setup(te => te.GetExtensionManager()).Returns(_extensionManager.Object); + _testEngine.Setup(te => te.GetLoggerManager(_mockRequestData.Object)).Returns(_loggerManager.Object); + var tp = new TestableTestPlatform(_testEngine.Object, _hostManager.Object); - tp.CreateDiscoveryRequest(this.mockRequestData.Object, discoveryCriteria, options); - } + tp.CreateDiscoveryRequest(_mockRequestData.Object, discoveryCriteria, options); + } - private void InvokeCreateTestRunRequest(TestPlatformOptions options = null) - { - this.executionManager.Setup(dm => dm.Initialize(false)).Verifiable(); - this.testEngine.Setup(te => te.GetExecutionManager(this.mockRequestData.Object, this.hostManager.Object, It.IsAny())).Returns(this.executionManager.Object); - this.testEngine.Setup(te => te.GetExtensionManager()).Returns(this.extensionManager.Object); - this.testEngine.Setup(te => te.GetLoggerManager(this.mockRequestData.Object)).Returns(this.loggerManager.Object); + private void InvokeCreateTestRunRequest(TestPlatformOptions options = null) + { + _executionManager.Setup(dm => dm.Initialize(false)).Verifiable(); + _testEngine.Setup(te => te.GetExecutionManager(_mockRequestData.Object, _hostManager.Object, It.IsAny())).Returns(_executionManager.Object); + _testEngine.Setup(te => te.GetExtensionManager()).Returns(_extensionManager.Object); + _testEngine.Setup(te => te.GetLoggerManager(_mockRequestData.Object)).Returns(_loggerManager.Object); - var tp = new TestableTestPlatform(this.testEngine.Object, this.hostManager.Object); - var testRunCriteria = new TestRunCriteria(new List { "foo" }, 10); - this.hostManager.Setup(hm => hm.GetTestSources(testRunCriteria.Sources)) - .Returns(testRunCriteria.Sources); + var tp = new TestableTestPlatform(_testEngine.Object, _hostManager.Object); + var testRunCriteria = new TestRunCriteria(new List { "foo" }, 10); + _hostManager.Setup(hm => hm.GetTestSources(testRunCriteria.Sources)) + .Returns(testRunCriteria.Sources); - tp.CreateTestRunRequest(this.mockRequestData.Object, testRunCriteria, options); + tp.CreateTestRunRequest(_mockRequestData.Object, testRunCriteria, options); + } + + private class TestableTestPlatform : TestPlatform + { + public TestableTestPlatform(ITestEngine testEngine, ITestRuntimeProvider hostProvider) : base(testEngine, new FileHelper(), new TestableTestRuntimeProviderManager(hostProvider)) + { } - private class TestableTestPlatform : TestPlatform + public TestableTestPlatform(ITestEngine testEngine, IFileHelper fileHelper, ITestRuntimeProvider hostProvider) : base(testEngine, fileHelper, new TestableTestRuntimeProviderManager(hostProvider)) { - public TestableTestPlatform(ITestEngine testEngine, ITestRuntimeProvider hostProvider) : base(testEngine, new FileHelper(), new TestableTestRuntimeProviderManager(hostProvider)) - { - } + } + } + + private class TestableTestRuntimeProviderManager : TestRuntimeProviderManager + { + private readonly ITestRuntimeProvider _hostProvider; - public TestableTestPlatform(ITestEngine testEngine, IFileHelper fileHelper, ITestRuntimeProvider hostProvider) : base(testEngine, fileHelper, new TestableTestRuntimeProviderManager(hostProvider)) - { - } + public TestableTestRuntimeProviderManager(ITestRuntimeProvider hostProvider) + : base(TestSessionMessageLogger.Instance) + { + _hostProvider = hostProvider; } - private class TestableTestRuntimeProviderManager : TestRuntimeProviderManager + public override ITestRuntimeProvider GetTestHostManagerByRunConfiguration(string runConfiguration) { - private readonly ITestRuntimeProvider hostProvider; - - public TestableTestRuntimeProviderManager(ITestRuntimeProvider hostProvider) - : base(TestSessionMessageLogger.Instance) - { - this.hostProvider = hostProvider; - } - - public override ITestRuntimeProvider GetTestHostManagerByRunConfiguration(string runConfiguration) - { - return this.hostProvider; - } + return _hostProvider; } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.PlatformTests/AssemblyPropertiesTests.cs b/test/Microsoft.TestPlatform.Common.PlatformTests/AssemblyPropertiesTests.cs index 15d97f4c96..b37bba08fc 100644 --- a/test/Microsoft.TestPlatform.Common.PlatformTests/AssemblyPropertiesTests.cs +++ b/test/Microsoft.TestPlatform.Common.PlatformTests/AssemblyPropertiesTests.cs @@ -1,77 +1,76 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.Utilities +namespace TestPlatform.Common.UnitTests.Utilities; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class AssemblyPropertiesTests : IntegrationTestBase { - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; + private readonly IAssemblyProperties _assemblyProperties; + + public AssemblyPropertiesTests() + { + _assemblyProperties = new AssemblyProperties(); + } + + [TestMethod] + [DataRow("net451")] + [DataRow("netcoreapp2.1")] + public void GetAssemblyTypeForManagedDll(string framework) + { + var assemblyPath = _testEnvironment.GetTestAsset("SimpleTestProject3.dll", framework); + var assemblyType = _assemblyProperties.GetAssemblyType(assemblyPath); + + Assert.AreEqual(AssemblyType.Managed, assemblyType); + } + + [TestMethod] + public void GetAssemblyTypeForNativeDll() + { + var assemblyPath = $@"{_testEnvironment.PackageDirectory}\microsoft.testplatform.testasset.nativecpp\2.0.0\contentFiles\any\any\Microsoft.TestPlatform.TestAsset.NativeCPP.dll"; + var assemblyType = _assemblyProperties.GetAssemblyType(assemblyPath); + + Assert.AreEqual(AssemblyType.Native, assemblyType); + } - [TestClass] - public class AssemblyPropertiesTests : IntegrationTestBase + [TestMethod] + public void GetAssemblyTypeForManagedExe() { - private IAssemblyProperties assemblyProperties; - - public AssemblyPropertiesTests() - { - this.assemblyProperties = new AssemblyProperties(); - } - - [TestMethod] - [DataRow("net451")] - [DataRow("netcoreapp2.1")] - public void GetAssemblyTypeForManagedDll(string framework) - { - var assemblyPath = this.testEnvironment.GetTestAsset("SimpleTestProject3.dll", framework); - var assemblyType = this.assemblyProperties.GetAssemblyType(assemblyPath); - - Assert.AreEqual(AssemblyType.Managed, assemblyType); - } - - [TestMethod] - public void GetAssemblyTypeForNativeDll() - { - var assemblyPath = $@"{this.testEnvironment.PackageDirectory}\microsoft.testplatform.testasset.nativecpp\2.0.0\contentFiles\any\any\Microsoft.TestPlatform.TestAsset.NativeCPP.dll"; - var assemblyType = this.assemblyProperties.GetAssemblyType(assemblyPath); - - Assert.AreEqual(AssemblyType.Native, assemblyType); - } - - [TestMethod] - public void GetAssemblyTypeForManagedExe() - { - var assemblyPath = this.testEnvironment.GetTestAsset("ConsoleManagedApp.exe", "net451"); - var assemblyType = this.assemblyProperties.GetAssemblyType(assemblyPath); - - Assert.AreEqual(AssemblyType.Managed, assemblyType); - } - - [TestMethod] - [DataRow("netcoreapp2.1")] - public void GetAssemblyTypeForNetCoreManagedExe(string framework) - { - var assemblyPath = this.testEnvironment.GetTestAsset("ConsoleManagedApp.dll", framework); - var assemblyType = this.assemblyProperties.GetAssemblyType(assemblyPath); - - Assert.AreEqual(AssemblyType.Managed, assemblyType); - } - - [TestMethod] - public void GetAssemblyTypeForNativeExe() - { - var assemblyPath = $@"{this.testEnvironment.PackageDirectory}\microsoft.testplatform.testasset.nativecpp\2.0.0\contentFiles\any\any\Microsoft.TestPlatform.TestAsset.ConsoleNativeApp.exe"; - var assemblyType = this.assemblyProperties.GetAssemblyType(assemblyPath); - - Assert.AreEqual(AssemblyType.Native, assemblyType); - } - - [TestMethod] - public void GetAssemblyTypeShouldReturnNoneInCaseOfError() - { - var assemblyType = this.assemblyProperties.GetAssemblyType("invalidFile.dll"); - - Assert.AreEqual(AssemblyType.None, assemblyType); - } + var assemblyPath = _testEnvironment.GetTestAsset("ConsoleManagedApp.exe", "net451"); + var assemblyType = _assemblyProperties.GetAssemblyType(assemblyPath); + + Assert.AreEqual(AssemblyType.Managed, assemblyType); + } + + [TestMethod] + [DataRow("netcoreapp2.1")] + public void GetAssemblyTypeForNetCoreManagedExe(string framework) + { + var assemblyPath = _testEnvironment.GetTestAsset("ConsoleManagedApp.dll", framework); + var assemblyType = _assemblyProperties.GetAssemblyType(assemblyPath); + + Assert.AreEqual(AssemblyType.Managed, assemblyType); + } + + [TestMethod] + public void GetAssemblyTypeForNativeExe() + { + var assemblyPath = $@"{_testEnvironment.PackageDirectory}\microsoft.testplatform.testasset.nativecpp\2.0.0\contentFiles\any\any\Microsoft.TestPlatform.TestAsset.ConsoleNativeApp.exe"; + var assemblyType = _assemblyProperties.GetAssemblyType(assemblyPath); + + Assert.AreEqual(AssemblyType.Native, assemblyType); + } + + [TestMethod] + public void GetAssemblyTypeShouldReturnNoneInCaseOfError() + { + var assemblyType = _assemblyProperties.GetAssemblyType("invalidFile.dll"); + + Assert.AreEqual(AssemblyType.None, assemblyType); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.PlatformTests/Program.cs b/test/Microsoft.TestPlatform.Common.PlatformTests/Program.cs index c14da13e69..97bd06b99b 100644 --- a/test/Microsoft.TestPlatform.Common.PlatformTests/Program.cs +++ b/test/Microsoft.TestPlatform.Common.PlatformTests/Program.cs @@ -1,11 +1,11 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.UnitTests +namespace Microsoft.VisualStudio.TestPlatform.Common.UnitTests; + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/DataCollectorExtensionManagerTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/DataCollectorExtensionManagerTests.cs index 00e193f6f7..3b186e7f8a 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/DataCollectorExtensionManagerTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/DataCollectorExtensionManagerTests.cs @@ -1,46 +1,45 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Common.UnitTests.ExtensionFramework -{ - using System; +namespace Microsoft.TestPlatform.Common.UnitTests.ExtensionFramework; + +using System; + +using TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.Logging; +using VisualStudio.TestTools.UnitTesting; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; +[TestClass] +public class DataCollectorExtensionManagerTests +{ + [TestInitialize] + public void Initialize() + { + TestPluginCacheHelper.SetupMockExtensions(typeof(DataCollectorExtensionManagerTests)); + } - [TestClass] - public class DataCollectorExtensionManagerTests + [TestMethod] + public void CreateShouldThrowExceptionIfMessageLoggerIsNull() { - [TestInitialize] - public void Initialize() + Assert.ThrowsException(() => { - TestPluginCacheHelper.SetupMockExtensions(typeof(DataCollectorExtensionManagerTests)); - } + var dataCollectionExtensionManager = DataCollectorExtensionManager.Create(null); + }); + } - [TestMethod] - public void CreateShouldThrowExceptionIfMessageLoggerIsNull() + [TestMethod] + public void CreateShouldReturnInstanceOfDataCollectorExtensionManager() + { + try { - Assert.ThrowsException(() => - { - var dataCollectionExtensionManager = DataCollectorExtensionManager.Create(null); - }); + var dataCollectorExtensionManager = DataCollectorExtensionManager.Create(TestSessionMessageLogger.Instance); + Assert.IsNotNull(dataCollectorExtensionManager); + Assert.IsInstanceOfType(dataCollectorExtensionManager, typeof(DataCollectorExtensionManager)); } - - [TestMethod] - public void CreateShouldReturnInstanceOfDataCollectorExtensionManager() + finally { - try - { - var dataCollectorExtensionManager = DataCollectorExtensionManager.Create(TestSessionMessageLogger.Instance); - Assert.IsNotNull(dataCollectorExtensionManager); - Assert.IsInstanceOfType(dataCollectorExtensionManager, typeof(DataCollectorExtensionManager)); - } - finally - { - TestSessionMessageLogger.Instance = null; - } + TestSessionMessageLogger.Instance = null; } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestDiscoveryExtensionManagerTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestDiscoveryExtensionManagerTests.cs index 7c69dfd0a1..80ca5280b0 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestDiscoveryExtensionManagerTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestDiscoveryExtensionManagerTests.cs @@ -1,138 +1,137 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.ExtensionFramework +namespace TestPlatform.Common.UnitTests.ExtensionFramework; + +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class TestDiscoveryExtensionManagerTests { - using System.Collections.Generic; - using System.Linq; - using System.Reflection; - using Microsoft.TestPlatform.Common; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class TestDiscoveryExtensionManagerTests + [TestCleanup] + public void TestCleanup() { - [TestCleanup] - public void TestCleanup() - { - TestDiscoveryExtensionManager.Destroy(); - } + TestDiscoveryExtensionManager.Destroy(); + } - [TestMethod] - public void CreateShouldDiscoverDiscovererExtensions() - { - TestPluginCacheHelper.SetupMockExtensions(typeof(TestDiscoveryExtensionManagerTests)); + [TestMethod] + public void CreateShouldDiscoverDiscovererExtensions() + { + TestPluginCacheHelper.SetupMockExtensions(typeof(TestDiscoveryExtensionManagerTests)); - var extensionManager = TestDiscoveryExtensionManager.Create(); + var extensionManager = TestDiscoveryExtensionManager.Create(); - Assert.IsNotNull(extensionManager.Discoverers); - Assert.IsTrue(extensionManager.Discoverers.Any()); - } + Assert.IsNotNull(extensionManager.Discoverers); + Assert.IsTrue(extensionManager.Discoverers.Any()); + } - [TestMethod] - public void CreateShouldCacheDiscoveredExtensions() - { - TestPluginCacheHelper.SetupMockExtensions(typeof(TestDiscoveryExtensionManagerTests), () => { }); + [TestMethod] + public void CreateShouldCacheDiscoveredExtensions() + { + TestPluginCacheHelper.SetupMockExtensions(typeof(TestDiscoveryExtensionManagerTests), () => { }); - var extensionManager = TestDiscoveryExtensionManager.Create(); - TestDiscoveryExtensionManager.Create(); + var extensionManager = TestDiscoveryExtensionManager.Create(); + TestDiscoveryExtensionManager.Create(); - Assert.IsNotNull(extensionManager.Discoverers); - Assert.IsTrue(extensionManager.Discoverers.Any()); - } + Assert.IsNotNull(extensionManager.Discoverers); + Assert.IsTrue(extensionManager.Discoverers.Any()); + } - [TestMethod] - public void GetDiscoveryExtensionManagerShouldReturnADiscoveryManagerWithExtensions() - { - var extensionManager = - TestDiscoveryExtensionManager.GetDiscoveryExtensionManager( - typeof(TestDiscoveryExtensionManagerTests).GetTypeInfo().Assembly.Location); + [TestMethod] + public void GetDiscoveryExtensionManagerShouldReturnADiscoveryManagerWithExtensions() + { + var extensionManager = + TestDiscoveryExtensionManager.GetDiscoveryExtensionManager( + typeof(TestDiscoveryExtensionManagerTests).GetTypeInfo().Assembly.Location); - Assert.IsNotNull(extensionManager.Discoverers); - Assert.IsTrue(extensionManager.Discoverers.Any()); - } + Assert.IsNotNull(extensionManager.Discoverers); + Assert.IsTrue(extensionManager.Discoverers.Any()); + } - #region LoadAndInitialize tests + #region LoadAndInitialize tests - [TestMethod] - public void LoadAndInitializeShouldInitializeAllExtensions() - { - TestPluginCacheHelper.SetupMockExtensions(typeof(TestDiscoveryExtensionManagerTests)); + [TestMethod] + public void LoadAndInitializeShouldInitializeAllExtensions() + { + TestPluginCacheHelper.SetupMockExtensions(typeof(TestDiscoveryExtensionManagerTests)); - TestDiscoveryExtensionManager.LoadAndInitializeAllExtensions(false); + TestDiscoveryExtensionManager.LoadAndInitializeAllExtensions(false); - var allDiscoverers = TestDiscoveryExtensionManager.Create().Discoverers; + var allDiscoverers = TestDiscoveryExtensionManager.Create().Discoverers; - foreach (var discoverer in allDiscoverers) - { - Assert.IsTrue(discoverer.IsExtensionCreated); - } + foreach (var discoverer in allDiscoverers) + { + Assert.IsTrue(discoverer.IsExtensionCreated); } - - #endregion } - [TestClass] - public class TestDiscovererMetadataTests + #endregion +} + +[TestClass] +public class TestDiscovererMetadataTests +{ + [TestMethod] + public void TestDiscovererMetadataCtorDoesNotThrowWhenFileExtensionsIsNull() { - [TestMethod] - public void TestDiscovererMetadataCtorDoesNotThrowWhenFileExtensionsIsNull() - { - var metadata = new TestDiscovererMetadata(null, null); + var metadata = new TestDiscovererMetadata(null, null); - Assert.IsNull(metadata.FileExtension); - } + Assert.IsNull(metadata.FileExtension); + } - [TestMethod] - public void TestDiscovererMetadataCtorDoesNotThrowWhenFileExtensionsIsEmpty() - { - var metadata = new TestDiscovererMetadata(new List(), null); + [TestMethod] + public void TestDiscovererMetadataCtorDoesNotThrowWhenFileExtensionsIsEmpty() + { + var metadata = new TestDiscovererMetadata(new List(), null); - Assert.IsNull(metadata.FileExtension); - } + Assert.IsNull(metadata.FileExtension); + } - [TestMethod] - public void TestDiscovererMetadataCtorDoesNotThrowWhenDefaultUriIsNull() - { - var metadata = new TestDiscovererMetadata(new List(), null); + [TestMethod] + public void TestDiscovererMetadataCtorDoesNotThrowWhenDefaultUriIsNull() + { + var metadata = new TestDiscovererMetadata(new List(), null); - Assert.IsNull(metadata.DefaultExecutorUri); - } + Assert.IsNull(metadata.DefaultExecutorUri); + } - [TestMethod] - public void TestDiscovererMetadataCtorDoesNotThrowWhenDefaultUriIsEmpty() - { - var metadata = new TestDiscovererMetadata(new List(), " "); + [TestMethod] + public void TestDiscovererMetadataCtorDoesNotThrowWhenDefaultUriIsEmpty() + { + var metadata = new TestDiscovererMetadata(new List(), " "); - Assert.IsNull(metadata.DefaultExecutorUri); - } + Assert.IsNull(metadata.DefaultExecutorUri); + } - [TestMethod] - public void TestDiscovererMetadataCtorSetsFileExtensions() - { - var extensions = new List { "csv", "dll" }; - var metadata = new TestDiscovererMetadata(extensions, null); + [TestMethod] + public void TestDiscovererMetadataCtorSetsFileExtensions() + { + var extensions = new List { "csv", "dll" }; + var metadata = new TestDiscovererMetadata(extensions, null); - CollectionAssert.AreEqual(extensions, metadata.FileExtension.ToList()); - } + CollectionAssert.AreEqual(extensions, metadata.FileExtension.ToList()); + } - [TestMethod] - public void TestDiscovererMetadataCtorSetsDefaultUri() - { - var metadata = new TestDiscovererMetadata(null, "executor://helloworld"); + [TestMethod] + public void TestDiscovererMetadataCtorSetsDefaultUri() + { + var metadata = new TestDiscovererMetadata(null, "executor://helloworld"); - Assert.AreEqual("executor://helloworld/", metadata.DefaultExecutorUri.AbsoluteUri); - } + Assert.AreEqual("executor://helloworld/", metadata.DefaultExecutorUri.AbsoluteUri); + } - [TestMethod] - public void TestDiscovererMetadataCtorSetsAssemblyType() - { - var metadata = new TestDiscovererMetadata(null, "executor://helloworld", AssemblyType.Native); + [TestMethod] + public void TestDiscovererMetadataCtorSetsAssemblyType() + { + var metadata = new TestDiscovererMetadata(null, "executor://helloworld", AssemblyType.Native); - Assert.AreEqual(AssemblyType.Native, metadata.AssemblyType); - } + Assert.AreEqual(AssemblyType.Native, metadata.AssemblyType); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestExecutorExtensionManagerTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestExecutorExtensionManagerTests.cs index 76c8142970..4f1ef9fe16 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestExecutorExtensionManagerTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestExecutorExtensionManagerTests.cs @@ -1,87 +1,86 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.ExtensionFramework -{ - using System.Linq; +namespace TestPlatform.Common.UnitTests.ExtensionFramework; + +using System.Linq; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System.Reflection; - using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Reflection; +using Microsoft.TestPlatform.TestUtilities; - [TestClass] - public class TestExecutorExtensionManagerTests +[TestClass] +public class TestExecutorExtensionManagerTests +{ + [TestCleanup] + public void TestCleanup() { - [TestCleanup] - public void TestCleanup() - { - TestExecutorExtensionManager.Destroy(); - } + TestExecutorExtensionManager.Destroy(); + } - [TestMethod] - public void CreateShouldDiscoverExecutorExtensions() - { - TestPluginCacheHelper.SetupMockExtensions(typeof(TestExecutorExtensionManagerTests)); + [TestMethod] + public void CreateShouldDiscoverExecutorExtensions() + { + TestPluginCacheHelper.SetupMockExtensions(typeof(TestExecutorExtensionManagerTests)); - var extensionManager = TestExecutorExtensionManager.Create(); + var extensionManager = TestExecutorExtensionManager.Create(); - Assert.IsNotNull(extensionManager.TestExtensions); - Assert.IsTrue(extensionManager.TestExtensions.Any()); - } + Assert.IsNotNull(extensionManager.TestExtensions); + Assert.IsTrue(extensionManager.TestExtensions.Any()); + } - [TestMethod] - public void CreateShouldCacheDiscoveredExtensions() - { - TestPluginCacheHelper.SetupMockExtensions(typeof(TestExecutorExtensionManagerTests), () => { }); + [TestMethod] + public void CreateShouldCacheDiscoveredExtensions() + { + TestPluginCacheHelper.SetupMockExtensions(typeof(TestExecutorExtensionManagerTests), () => { }); - var extensionManager = TestExecutorExtensionManager.Create(); - TestExecutorExtensionManager.Create(); + var extensionManager = TestExecutorExtensionManager.Create(); + TestExecutorExtensionManager.Create(); - Assert.IsNotNull(extensionManager.TestExtensions); - Assert.IsTrue(extensionManager.TestExtensions.Any()); - } + Assert.IsNotNull(extensionManager.TestExtensions); + Assert.IsTrue(extensionManager.TestExtensions.Any()); + } - [TestMethod] - public void GetExecutorExtensionManagerShouldReturnAnExecutionManagerWithExtensions() - { - var extensionManager = - TestExecutorExtensionManager.GetExecutionExtensionManager( - typeof(TestExecutorExtensionManagerTests).GetTypeInfo().Assembly.Location); + [TestMethod] + public void GetExecutorExtensionManagerShouldReturnAnExecutionManagerWithExtensions() + { + var extensionManager = + TestExecutorExtensionManager.GetExecutionExtensionManager( + typeof(TestExecutorExtensionManagerTests).GetTypeInfo().Assembly.Location); - Assert.IsNotNull(extensionManager.TestExtensions); - Assert.IsTrue(extensionManager.TestExtensions.Any()); - } + Assert.IsNotNull(extensionManager.TestExtensions); + Assert.IsTrue(extensionManager.TestExtensions.Any()); + } - #region LoadAndInitialize tests + #region LoadAndInitialize tests - [TestMethod] - public void LoadAndInitializeShouldInitializeAllExtensions() - { - TestPluginCacheHelper.SetupMockExtensions(typeof(TestExecutorExtensionManagerTests)); + [TestMethod] + public void LoadAndInitializeShouldInitializeAllExtensions() + { + TestPluginCacheHelper.SetupMockExtensions(typeof(TestExecutorExtensionManagerTests)); - TestExecutorExtensionManager.LoadAndInitializeAllExtensions(false); + TestExecutorExtensionManager.LoadAndInitializeAllExtensions(false); - var allExecutors = TestExecutorExtensionManager.Create().TestExtensions; + var allExecutors = TestExecutorExtensionManager.Create().TestExtensions; - foreach (var executor in allExecutors) - { - Assert.IsTrue(executor.IsExtensionCreated); - } + foreach (var executor in allExecutors) + { + Assert.IsTrue(executor.IsExtensionCreated); } - - #endregion } - [TestClass] - public class TestExecutorMetadataTests + #endregion +} + +[TestClass] +public class TestExecutorMetadataTests +{ + [TestMethod] + public void TestExecutorMetadataCtorShouldSetExtensionUri() { - [TestMethod] - public void TestExecutorMetadataCtorShouldSetExtensionUri() - { - var metadata = new TestExecutorMetadata("random"); + var metadata = new TestExecutorMetadata("random"); - Assert.AreEqual("random", metadata.ExtensionUri); - } + Assert.AreEqual("random", metadata.ExtensionUri); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestExtensionManagerTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestExtensionManagerTests.cs index 4a940c523b..c6bf3c8cee 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestExtensionManagerTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestExtensionManagerTests.cs @@ -1,122 +1,118 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.ExtensionFramework +namespace TestPlatform.Common.UnitTests.ExtensionFramework; + +using System; +using System.Collections.Generic; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Logging; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class TestExtensionManagerTests { - using System; - using System.Collections.Generic; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class TestExtensionManagerTests + private readonly IMessageLogger _messageLogger; + private TestExtensionManager _testExtensionManager; + private readonly IEnumerable> _filteredTestExtensions; + private readonly IEnumerable>> _unfilteredTestExtensions; + + public TestExtensionManagerTests() { - private IMessageLogger messageLogger; - private TestExtensionManager testExtensionManager; - private IEnumerable> filteredTestExtensions; - private IEnumerable>> unfilteredTestExtensions; + TestPluginCacheHelper.SetupMockExtensions(typeof(TestExtensionManagerTests)); + _messageLogger = TestSessionMessageLogger.Instance; + TestPluginManager.Instance.GetSpecificTestExtensions + (TestPlatformConstants.TestLoggerEndsWithPattern, out _unfilteredTestExtensions, out _filteredTestExtensions); + } - public TestExtensionManagerTests() - { - TestPluginCacheHelper.SetupMockExtensions(typeof(TestExtensionManagerTests)); - messageLogger = TestSessionMessageLogger.Instance; - TestPluginManager.Instance.GetSpecificTestExtensions - (TestPlatformConstants.TestLoggerEndsWithPattern, out unfilteredTestExtensions, out filteredTestExtensions); - } + [TestCleanup] + public void Cleanup() + { + TestSessionMessageLogger.Instance = null; + } - [TestCleanup] - public void Cleanup() - { - TestSessionMessageLogger.Instance = null; - } + [TestMethod] + public void TestExtensionManagerConstructorShouldThrowExceptionIfMessageLoggerIsNull() + { + Assert.ThrowsException(() => _testExtensionManager = new DummyTestExtensionManager(_unfilteredTestExtensions, _filteredTestExtensions, null)); + } - [TestMethod] - public void TestExtensionManagerConstructorShouldThrowExceptionIfMessageLoggerIsNull() - { - Assert.ThrowsException(() => - { - testExtensionManager = new DummyTestExtensionManager(unfilteredTestExtensions, filteredTestExtensions, null); - } - ); - } + [TestMethod] + public void TryGetTestExtensionShouldReturnExtensionWithCorrectUri() + { + _testExtensionManager = new DummyTestExtensionManager(_unfilteredTestExtensions, _filteredTestExtensions, _messageLogger); + var result = _testExtensionManager.TryGetTestExtension(new Uri("testlogger://logger")); - [TestMethod] - public void TryGetTestExtensionShouldReturnExtensionWithCorrectUri() - { - testExtensionManager = new DummyTestExtensionManager(unfilteredTestExtensions, filteredTestExtensions, messageLogger); - var result = testExtensionManager.TryGetTestExtension(new Uri("testlogger://logger")); + Assert.IsNotNull(result); + Assert.IsInstanceOfType(result.Value, typeof(ITestLogger)); + } - Assert.IsNotNull(result); - Assert.IsInstanceOfType(result.Value, typeof(ITestLogger)); - } + [TestMethod] + public void TryGetTestExtensionShouldThrowExceptionWithNullUri() + { + _testExtensionManager = new DummyTestExtensionManager(_unfilteredTestExtensions, _filteredTestExtensions, _messageLogger); + TestPluginCacheHelper.SetupMockAdditionalPathExtensions(typeof(TestExtensionManagerTests)); + Assert.ThrowsException(() => + { + var result = _testExtensionManager.TryGetTestExtension(default(Uri)); + } + ); + } + + [TestMethod] + public void TryGetTestExtensionShouldNotReturnExtensionWithIncorrectlUri() + { + _testExtensionManager = new DummyTestExtensionManager(_unfilteredTestExtensions, _filteredTestExtensions, _messageLogger); + var result = _testExtensionManager.TryGetTestExtension(""); + Assert.IsNull(result); + } - [TestMethod] - public void TryGetTestExtensionShouldThrowExceptionWithNullUri() + [TestMethod] + public void TryGetTestExtensionWithStringUriUnitTest() + { + _testExtensionManager = new DummyTestExtensionManager(_unfilteredTestExtensions, _filteredTestExtensions, _messageLogger); + var result = _testExtensionManager.TryGetTestExtension(new Uri("testlogger://logger").AbsoluteUri); + + Assert.IsNotNull(result); + Assert.IsInstanceOfType(result.Value, typeof(ITestLogger)); + } + + [ExtensionUri("testlogger://logger")] + [FriendlyName("TestLoggerExtension")] + private class ValidLogger3 : ITestLogger + { + public void Initialize(TestLoggerEvents events, string testRunDirectory) { - testExtensionManager = new DummyTestExtensionManager(unfilteredTestExtensions, filteredTestExtensions, messageLogger); - TestPluginCacheHelper.SetupMockAdditionalPathExtensions(typeof(TestExtensionManagerTests)); - Assert.ThrowsException(() => - { - var result = testExtensionManager.TryGetTestExtension(default(Uri)); - } - ); + events.TestRunMessage += TestMessageHandler; + events.TestRunComplete += Events_TestRunComplete; + events.TestResult += Events_TestResult; } - [TestMethod] - public void TryGetTestExtensionShouldNotReturnExtensionWithIncorrectlUri() + private void Events_TestResult(object sender, TestResultEventArgs e) { - testExtensionManager = new DummyTestExtensionManager(unfilteredTestExtensions, filteredTestExtensions, messageLogger); - var result = testExtensionManager.TryGetTestExtension(""); - Assert.IsNull(result); } - [TestMethod] - public void TryGetTestExtensionWithStringUriUnitTest() + private void Events_TestRunComplete(object sender, TestRunCompleteEventArgs e) { - testExtensionManager = new DummyTestExtensionManager(unfilteredTestExtensions, filteredTestExtensions, messageLogger); - var result = testExtensionManager.TryGetTestExtension(new Uri("testlogger://logger").AbsoluteUri); - - Assert.IsNotNull(result); - Assert.IsInstanceOfType(result.Value, typeof(ITestLogger)); } - [ExtensionUri("testlogger://logger")] - [FriendlyName("TestLoggerExtension")] - private class ValidLogger3 : ITestLogger + private void TestMessageHandler(object sender, TestRunMessageEventArgs e) { - public void Initialize(TestLoggerEvents events, string testRunDirectory) - { - events.TestRunMessage += TestMessageHandler; - events.TestRunComplete += Events_TestRunComplete; - events.TestResult += Events_TestResult; - } - - private void Events_TestResult(object sender, TestResultEventArgs e) - { - } - - private void Events_TestRunComplete(object sender, TestRunCompleteEventArgs e) - { - } - - private void TestMessageHandler(object sender, TestRunMessageEventArgs e) - { - } } } +} - internal class DummyTestExtensionManager : TestExtensionManager +internal class DummyTestExtensionManager : TestExtensionManager +{ + public DummyTestExtensionManager(IEnumerable>> unfilteredTestExtensions, IEnumerable> testExtensions, IMessageLogger logger) : base(unfilteredTestExtensions, testExtensions, logger) { - public DummyTestExtensionManager(IEnumerable>> unfilteredTestExtensions, IEnumerable> testExtensions, IMessageLogger logger) : base(unfilteredTestExtensions, testExtensions, logger) - { - } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestLoggerExtensionManagerTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestLoggerExtensionManagerTests.cs index 6a8f749dba..3c00835583 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestLoggerExtensionManagerTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestLoggerExtensionManagerTests.cs @@ -1,45 +1,45 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.ExtensionFramework +namespace TestPlatform.Common.UnitTests.ExtensionFramework; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using System; + +[TestClass] +public class TestLoggerExtensionManagerTests { - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System; + [TestInitialize] + public void Initialize() + { + TestPluginCacheHelper.SetupMockExtensions(typeof(TestLoggerExtensionManagerTests)); + } - [TestClass] - public class TestLoggerExtensionManagerTests + [TestMethod] + public void CreateShouldThrowExceptionIfMessageLoggerIsNull() { - [TestInitialize] - public void Initialize() + Assert.ThrowsException(() => { - TestPluginCacheHelper.SetupMockExtensions(typeof(TestLoggerExtensionManagerTests)); - } + var testLoggerExtensionManager = TestLoggerExtensionManager.Create(null); + }); + } - [TestMethod] - public void CreateShouldThrowExceptionIfMessageLoggerIsNull() + [TestMethod] + public void CreateShouldReturnInstanceOfTestLoggerExtensionManager() + { + try { - Assert.ThrowsException(() => - { - var testLoggerExtensionManager = TestLoggerExtensionManager.Create(null); - }); + var testLoggerExtensionManager = TestLoggerExtensionManager.Create(TestSessionMessageLogger.Instance); + Assert.IsNotNull(testLoggerExtensionManager); + Assert.IsInstanceOfType(testLoggerExtensionManager, typeof(TestLoggerExtensionManager)); } - - [TestMethod] - public void CreateShouldReturnInstanceOfTestLoggerExtensionManager() + finally { - try - { - var testLoggerExtensionManager = TestLoggerExtensionManager.Create(TestSessionMessageLogger.Instance); - Assert.IsNotNull(testLoggerExtensionManager); - Assert.IsInstanceOfType(testLoggerExtensionManager, typeof(TestLoggerExtensionManager)); - } - finally - { - TestSessionMessageLogger.Instance = null; - } + TestSessionMessageLogger.Instance = null; } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginCacheTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginCacheTests.cs index aee7e48b94..19af121031 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginCacheTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginCacheTests.cs @@ -1,383 +1,381 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.ExtensionFramework +namespace TestPlatform.Common.UnitTests.ExtensionFramework; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class TestPluginCacheTests { - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Reflection; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.SettingsProvider; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - [TestClass] - public class TestPluginCacheTests + private readonly Mock _mockFileHelper; + + private readonly TestableTestPluginCache _testablePluginCache; + + public TestPluginCacheTests() { - private readonly Mock mockFileHelper; + // Reset the singleton. + TestPluginCache.Instance = null; + _mockFileHelper = new Mock(); + _testablePluginCache = new TestableTestPluginCache(new List { typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location }); - private readonly TestableTestPluginCache testablePluginCache; + _mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); + } - public TestPluginCacheTests() - { - // Reset the singleton. - TestPluginCache.Instance = null; - this.mockFileHelper = new Mock(); - this.testablePluginCache = new TestableTestPluginCache(new List { typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location }); + #region Properties tests - this.mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); - } + [TestMethod] + public void InstanceShouldNotReturnANull() + { + Assert.IsNotNull(TestPluginCache.Instance); + } - #region Properties tests + [TestMethod] + public void TestExtensionsShouldBeNullByDefault() + { + Assert.IsNull(TestPluginCache.Instance.TestExtensions); + } - [TestMethod] - public void InstanceShouldNotReturnANull() - { - Assert.IsNotNull(TestPluginCache.Instance); - } + #endregion - [TestMethod] - public void TestExtensionsShouldBeNullByDefault() - { - Assert.IsNull(TestPluginCache.Instance.TestExtensions); - } + #region UpdateAdditionalExtensions tests - #endregion + [TestMethod] + public void UpdateAdditionalExtensionsShouldNotThrowIfExtensionPathIsNull() + { + TestPluginCache.Instance.UpdateExtensions(null, true); + Assert.IsFalse(TestPluginCache.Instance.GetExtensionPaths(string.Empty).Any()); + } - #region UpdateAdditionalExtensions tests + [TestMethod] + public void UpdateAdditionalExtensionsShouldNotThrowIfExtensionPathIsEmpty() + { + TestPluginCache.Instance.UpdateExtensions(new List(), true); + Assert.IsFalse(TestPluginCache.Instance.GetExtensionPaths(string.Empty).Any()); + } - [TestMethod] - public void UpdateAdditionalExtensionsShouldNotThrowIfExtensionPathIsNull() - { - TestPluginCache.Instance.UpdateExtensions(null, true); - Assert.IsFalse(TestPluginCache.Instance.GetExtensionPaths(string.Empty).Any()); - } + [TestMethod] + public void UpdateAdditionalExtensionsShouldUpdateAdditionalExtensions() + { + var additionalExtensions = new List { typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location }; + TestPluginCache.Instance.UpdateExtensions(additionalExtensions, false); + var updatedExtensions = TestPluginCache.Instance.GetExtensionPaths(string.Empty); - [TestMethod] - public void UpdateAdditionalExtensionsShouldNotThrowIfExtensionPathIsEmpty() - { - TestPluginCache.Instance.UpdateExtensions(new List(), true); - Assert.IsFalse(TestPluginCache.Instance.GetExtensionPaths(string.Empty).Any()); - } + Assert.IsNotNull(updatedExtensions); + CollectionAssert.AreEqual(additionalExtensions, updatedExtensions.ToList()); + } - [TestMethod] - public void UpdateAdditionalExtensionsShouldUpdateAdditionalExtensions() + [TestMethod] + public void UpdateAdditionalExtensionsShouldOnlyAddUniqueExtensionPaths() + { + var additionalExtensions = new List { - var additionalExtensions = new List { typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location }; - TestPluginCache.Instance.UpdateExtensions(additionalExtensions, false); - var updatedExtensions = TestPluginCache.Instance.GetExtensionPaths(string.Empty); + typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location, + typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location + }; + TestPluginCache.Instance.UpdateExtensions(additionalExtensions, false); + var updatedExtensions = TestPluginCache.Instance.GetExtensionPaths(string.Empty); + + Assert.IsNotNull(updatedExtensions); + Assert.AreEqual(1, updatedExtensions.Count); + CollectionAssert.AreEqual(new List { additionalExtensions.First() }, updatedExtensions); + } - Assert.IsNotNull(updatedExtensions); - CollectionAssert.AreEqual(additionalExtensions, updatedExtensions.ToList()); - } + [TestMethod] + public void UpdateAdditionalExtensionsShouldUpdatePathsThatDoNotExist() + { + var additionalExtensions = new List { "foo.dll" }; + TestPluginCache.Instance.UpdateExtensions(additionalExtensions, false); + var updatedExtensions = TestPluginCache.Instance.GetExtensionPaths(string.Empty); - [TestMethod] - public void UpdateAdditionalExtensionsShouldOnlyAddUniqueExtensionPaths() - { - var additionalExtensions = new List - { - typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location, - typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location - }; - TestPluginCache.Instance.UpdateExtensions(additionalExtensions, false); - var updatedExtensions = TestPluginCache.Instance.GetExtensionPaths(string.Empty); - - Assert.IsNotNull(updatedExtensions); - Assert.AreEqual(1, updatedExtensions.Count); - CollectionAssert.AreEqual(new List { additionalExtensions.First() }, updatedExtensions); - } - - [TestMethod] - public void UpdateAdditionalExtensionsShouldUpdatePathsThatDoNotExist() - { - var additionalExtensions = new List { "foo.dll" }; - TestPluginCache.Instance.UpdateExtensions(additionalExtensions, false); - var updatedExtensions = TestPluginCache.Instance.GetExtensionPaths(string.Empty); + Assert.IsNotNull(updatedExtensions); + Assert.AreEqual(1, updatedExtensions.Count); + } - Assert.IsNotNull(updatedExtensions); - Assert.AreEqual(1, updatedExtensions.Count); - } + [TestMethod] + public void UpdateAdditionalExtensionsShouldUpdateUnfilteredExtensionsListWhenSkipFilteringIsTrue() + { + var additionalExtensions = new List { "foo.dll" }; + TestPluginCache.Instance.UpdateExtensions(additionalExtensions, true); + var updatedExtensions = TestPluginCache.Instance.GetExtensionPaths("testadapter.dll"); - [TestMethod] - public void UpdateAdditionalExtensionsShouldUpdateUnfilteredExtensionsListWhenSkipFilteringIsTrue() - { - var additionalExtensions = new List { "foo.dll" }; - TestPluginCache.Instance.UpdateExtensions(additionalExtensions, true); - var updatedExtensions = TestPluginCache.Instance.GetExtensionPaths("testadapter.dll"); - - // Since the extension is unfiltered, above filter criteria doesn't filter it - Assert.IsNotNull(updatedExtensions); - Assert.AreEqual(1, updatedExtensions.Count); - } - - [Ignore] - [TestMethod] - public void UpdateAdditionalExtensionsShouldResetExtensionsDiscoveredFlag() - { - } + // Since the extension is unfiltered, above filter criteria doesn't filter it + Assert.IsNotNull(updatedExtensions); + Assert.AreEqual(1, updatedExtensions.Count); + } - #endregion + [Ignore] + [TestMethod] + public void UpdateAdditionalExtensionsShouldResetExtensionsDiscoveredFlag() + { + } - #region ClearExtensions + #endregion - [TestMethod] - public void ClearExtensionsShouldClearPathToExtensions() - { - TestPluginCache.Instance.UpdateExtensions(new List { @"oldExtension.dll" }, false); + #region ClearExtensions - TestPluginCache.Instance.ClearExtensions(); + [TestMethod] + public void ClearExtensionsShouldClearPathToExtensions() + { + TestPluginCache.Instance.UpdateExtensions(new List { @"oldExtension.dll" }, false); - Assert.AreEqual(0, TestPluginCache.Instance.GetExtensionPaths(string.Empty).Count); - } + TestPluginCache.Instance.ClearExtensions(); - #endregion + Assert.AreEqual(0, TestPluginCache.Instance.GetExtensionPaths(string.Empty).Count); + } - #region GetExtensionPaths + #endregion - [TestMethod] - public void GetExtensionPathsShouldConsolidateAllExtensions() - { - var expectedExtensions = new[] { "filter.dll", "unfilter.dll" }.Select(Path.GetFullPath).ToList(); - expectedExtensions.Add("default.dll"); - TestPluginCache.Instance.UpdateExtensions(new[] { @"filter.dll" }, false); - TestPluginCache.Instance.UpdateExtensions(new[] { @"unfilter.dll" }, true); - TestPluginCache.Instance.DefaultExtensionPaths = new[] { "default.dll" }; + #region GetExtensionPaths - var extensions = TestPluginCache.Instance.GetExtensionPaths("filter.dll"); + [TestMethod] + public void GetExtensionPathsShouldConsolidateAllExtensions() + { + var expectedExtensions = new[] { "filter.dll", "unfilter.dll" }.Select(Path.GetFullPath).ToList(); + expectedExtensions.Add("default.dll"); + TestPluginCache.Instance.UpdateExtensions(new[] { @"filter.dll" }, false); + TestPluginCache.Instance.UpdateExtensions(new[] { @"unfilter.dll" }, true); + TestPluginCache.Instance.DefaultExtensionPaths = new[] { "default.dll" }; - CollectionAssert.AreEquivalent(expectedExtensions, extensions); - } + var extensions = TestPluginCache.Instance.GetExtensionPaths("filter.dll"); - [TestMethod] - public void GetExtensionPathsShouldFilterFilterableExtensions() - { - var expectedExtensions = new[] { "filter.dll", "unfilter.dll" }.Select(Path.GetFullPath).ToList(); - expectedExtensions.Add("default.dll"); - TestPluginCache.Instance.UpdateExtensions(new[] { @"filter.dll", @"other.dll" }, false); - TestPluginCache.Instance.UpdateExtensions(new[] { @"unfilter.dll" }, true); - TestPluginCache.Instance.DefaultExtensionPaths = new[] { "default.dll" }; + CollectionAssert.AreEquivalent(expectedExtensions, extensions); + } - var extensions = TestPluginCache.Instance.GetExtensionPaths("filter.dll"); + [TestMethod] + public void GetExtensionPathsShouldFilterFilterableExtensions() + { + var expectedExtensions = new[] { "filter.dll", "unfilter.dll" }.Select(Path.GetFullPath).ToList(); + expectedExtensions.Add("default.dll"); + TestPluginCache.Instance.UpdateExtensions(new[] { @"filter.dll", @"other.dll" }, false); + TestPluginCache.Instance.UpdateExtensions(new[] { @"unfilter.dll" }, true); + TestPluginCache.Instance.DefaultExtensionPaths = new[] { "default.dll" }; - CollectionAssert.AreEquivalent(expectedExtensions, extensions); - } + var extensions = TestPluginCache.Instance.GetExtensionPaths("filter.dll"); - [TestMethod] - public void GetExtensionPathsShouldNotFilterIfEndsWithPatternIsNullOrEmpty() - { - var expectedExtensions = new[] { "filter.dll", "other.dll", "unfilter.dll" }.Select(Path.GetFullPath).ToList(); - expectedExtensions.Add("default.dll"); - TestPluginCache.Instance.UpdateExtensions(new[] { @"filter.dll", @"other.dll" }, false); - TestPluginCache.Instance.UpdateExtensions(new[] { @"unfilter.dll" }, true); - TestPluginCache.Instance.DefaultExtensionPaths = new[] { "default.dll" }; + CollectionAssert.AreEquivalent(expectedExtensions, extensions); + } - var extensions = TestPluginCache.Instance.GetExtensionPaths(string.Empty); + [TestMethod] + public void GetExtensionPathsShouldNotFilterIfEndsWithPatternIsNullOrEmpty() + { + var expectedExtensions = new[] { "filter.dll", "other.dll", "unfilter.dll" }.Select(Path.GetFullPath).ToList(); + expectedExtensions.Add("default.dll"); + TestPluginCache.Instance.UpdateExtensions(new[] { @"filter.dll", @"other.dll" }, false); + TestPluginCache.Instance.UpdateExtensions(new[] { @"unfilter.dll" }, true); + TestPluginCache.Instance.DefaultExtensionPaths = new[] { "default.dll" }; - CollectionAssert.AreEquivalent(expectedExtensions, extensions); - } + var extensions = TestPluginCache.Instance.GetExtensionPaths(string.Empty); - [TestMethod] - public void GetExtensionPathsShouldSkipDefaultExtensionsIfSetTrue() - { - var expectedExtensions = new[] { "filter.dll", "unfilter.dll" }.Select(Path.GetFullPath).ToList(); - InvokeGetExtensionPaths(expectedExtensions, true); - } + CollectionAssert.AreEquivalent(expectedExtensions, extensions); + } - [TestMethod] - public void GetExtensionPathsShouldNotSkipDefaultExtensionsIfSetFalse() - { - var expectedExtensions = new[] { "filter.dll", "unfilter.dll" }.Select(Path.GetFullPath).ToList(); - expectedExtensions.Add("default.dll"); - InvokeGetExtensionPaths(expectedExtensions, false); - } + [TestMethod] + public void GetExtensionPathsShouldSkipDefaultExtensionsIfSetTrue() + { + var expectedExtensions = new[] { "filter.dll", "unfilter.dll" }.Select(Path.GetFullPath).ToList(); + InvokeGetExtensionPaths(expectedExtensions, true); + } - #endregion + [TestMethod] + public void GetExtensionPathsShouldNotSkipDefaultExtensionsIfSetFalse() + { + var expectedExtensions = new[] { "filter.dll", "unfilter.dll" }.Select(Path.GetFullPath).ToList(); + expectedExtensions.Add("default.dll"); + InvokeGetExtensionPaths(expectedExtensions, false); + } - #region GetDefaultResolutionPaths tests + #endregion - [TestMethod] - public void GetDefaultResolutionPathsShouldReturnCurrentDirectoryByDefault() - { - var currentDirectory = Path.GetDirectoryName(typeof(TestPluginCache).GetTypeInfo().Assembly.Location); - var expectedDirectories = new List { currentDirectory }; + #region GetDefaultResolutionPaths tests - var resolutionPaths = TestPluginCache.Instance.GetDefaultResolutionPaths(); + [TestMethod] + public void GetDefaultResolutionPathsShouldReturnCurrentDirectoryByDefault() + { + var currentDirectory = Path.GetDirectoryName(typeof(TestPluginCache).GetTypeInfo().Assembly.Location); + var expectedDirectories = new List { currentDirectory }; - Assert.IsNotNull(resolutionPaths); - CollectionAssert.AreEqual(expectedDirectories, resolutionPaths.ToList()); - } + var resolutionPaths = TestPluginCache.Instance.GetDefaultResolutionPaths(); - [TestMethod] - public void GetDefaultResolutionPathsShouldReturnAdditionalExtensionPathsDirectories() - { - var currentDirectory = Path.GetDirectoryName(typeof(TestPluginCache).GetTypeInfo().Assembly.Location); - var candidateDirectory = Directory.GetParent(currentDirectory).FullName; - var extensionPaths = new List { Path.Combine(candidateDirectory, "foo.dll") }; + Assert.IsNotNull(resolutionPaths); + CollectionAssert.AreEqual(expectedDirectories, resolutionPaths.ToList()); + } - // Setup mocks. - var mockFileHelper = new Mock(); - mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(false); - var testableTestPluginCache = new TestableTestPluginCache(); + [TestMethod] + public void GetDefaultResolutionPathsShouldReturnAdditionalExtensionPathsDirectories() + { + var currentDirectory = Path.GetDirectoryName(typeof(TestPluginCache).GetTypeInfo().Assembly.Location); + var candidateDirectory = Directory.GetParent(currentDirectory).FullName; + var extensionPaths = new List { Path.Combine(candidateDirectory, "foo.dll") }; - TestPluginCache.Instance = testableTestPluginCache; + // Setup mocks. + var mockFileHelper = new Mock(); + mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(false); + var testableTestPluginCache = new TestableTestPluginCache(); - TestPluginCache.Instance.UpdateExtensions(extensionPaths, true); - var resolutionPaths = TestPluginCache.Instance.GetDefaultResolutionPaths(); + TestPluginCache.Instance = testableTestPluginCache; - var expectedExtensions = new List { candidateDirectory, currentDirectory }; + TestPluginCache.Instance.UpdateExtensions(extensionPaths, true); + var resolutionPaths = TestPluginCache.Instance.GetDefaultResolutionPaths(); - Assert.IsNotNull(resolutionPaths); - CollectionAssert.AreEqual(expectedExtensions, resolutionPaths.ToList()); - } + var expectedExtensions = new List { candidateDirectory, currentDirectory }; - [TestMethod] - public void GetDefaultResolutionPathsShouldReturnDirectoryFromDefaultExtensionsPath() - { - // Setup the testable instance. - TestPluginCache.Instance = this.testablePluginCache; + Assert.IsNotNull(resolutionPaths); + CollectionAssert.AreEqual(expectedExtensions, resolutionPaths.ToList()); + } - var defaultExtensionsFile = typeof(TestPluginCache).GetTypeInfo().Assembly.Location; - this.testablePluginCache.DefaultExtensionPaths = new List() { defaultExtensionsFile }; + [TestMethod] + public void GetDefaultResolutionPathsShouldReturnDirectoryFromDefaultExtensionsPath() + { + // Setup the testable instance. + TestPluginCache.Instance = _testablePluginCache; - var resolutionPaths = TestPluginCache.Instance.GetDefaultResolutionPaths(); + var defaultExtensionsFile = typeof(TestPluginCache).GetTypeInfo().Assembly.Location; + _testablePluginCache.DefaultExtensionPaths = new List() { defaultExtensionsFile }; - Assert.IsNotNull(resolutionPaths); - Assert.IsTrue(resolutionPaths.Contains(Path.GetDirectoryName(defaultExtensionsFile))); - } + var resolutionPaths = TestPluginCache.Instance.GetDefaultResolutionPaths(); - #endregion + Assert.IsNotNull(resolutionPaths); + Assert.IsTrue(resolutionPaths.Contains(Path.GetDirectoryName(defaultExtensionsFile))); + } - #region GetResolutionPaths tests + #endregion - [TestMethod] - public void GetResolutionPathsShouldThrowIfExtensionAssemblyIsNull() - { - Assert.ThrowsException(() => TestPluginCache.Instance.GetResolutionPaths(null)); - } + #region GetResolutionPaths tests - [TestMethod] - public void GetResolutionPathsShouldReturnExtensionAssemblyDirectoryAndTPCommonDirectory() - { - var temp = Path.GetTempPath(); - var resolutionPaths = TestPluginCache.Instance.GetResolutionPaths($@"{temp}{Path.DirectorySeparatorChar}Idonotexist.dll").Select(p => p.Replace("/", "\\")).ToList(); + [TestMethod] + public void GetResolutionPathsShouldThrowIfExtensionAssemblyIsNull() + { + Assert.ThrowsException(() => TestPluginCache.Instance.GetResolutionPaths(null)); + } - var tpCommonDirectory = Path.GetDirectoryName(typeof(TestPluginCache).GetTypeInfo().Assembly.Location); - var expectedPaths = new List { temp, tpCommonDirectory }.ConvertAll(p => p.Replace("/", "\\").TrimEnd('\\')); + [TestMethod] + public void GetResolutionPathsShouldReturnExtensionAssemblyDirectoryAndTpCommonDirectory() + { + var temp = Path.GetTempPath(); + var resolutionPaths = TestPluginCache.Instance.GetResolutionPaths($@"{temp}{Path.DirectorySeparatorChar}Idonotexist.dll").Select(p => p.Replace("/", "\\")).ToList(); - CollectionAssert.AreEqual(expectedPaths, resolutionPaths, $"Collection {string.Join(", ", resolutionPaths)}, is not equal to the expected collection {string.Join(", ", expectedPaths)}."); - } + var tpCommonDirectory = Path.GetDirectoryName(typeof(TestPluginCache).GetTypeInfo().Assembly.Location); + var expectedPaths = new List { temp, tpCommonDirectory }.ConvertAll(p => p.Replace("/", "\\").TrimEnd('\\')); - [TestMethod] - public void GetResolutionPathsShouldNotHaveDuplicatePathsIfExtensionIsInSameDirectory() - { - var tpCommonlocation = typeof(TestPluginCache).GetTypeInfo().Assembly.Location; + CollectionAssert.AreEqual(expectedPaths, resolutionPaths, $"Collection {string.Join(", ", resolutionPaths)}, is not equal to the expected collection {string.Join(", ", expectedPaths)}."); + } + + [TestMethod] + public void GetResolutionPathsShouldNotHaveDuplicatePathsIfExtensionIsInSameDirectory() + { + var tpCommonlocation = typeof(TestPluginCache).GetTypeInfo().Assembly.Location; - var resolutionPaths = TestPluginCache.Instance.GetResolutionPaths(tpCommonlocation); + var resolutionPaths = TestPluginCache.Instance.GetResolutionPaths(tpCommonlocation); - var expectedPaths = new List { Path.GetDirectoryName(tpCommonlocation) }; + var expectedPaths = new List { Path.GetDirectoryName(tpCommonlocation) }; - CollectionAssert.AreEqual(expectedPaths, resolutionPaths.ToList()); - } + CollectionAssert.AreEqual(expectedPaths, resolutionPaths.ToList()); + } - #endregion + #endregion - #region GetTestExtensions tests + #region GetTestExtensions tests - [TestMethod] - public void GetTestExtensionsShouldReturnExtensionsInAssembly() - { - TestPluginCacheHelper.SetupMockAdditionalPathExtensions(typeof(TestPluginCacheTests)); + [TestMethod] + public void GetTestExtensionsShouldReturnExtensionsInAssembly() + { + TestPluginCacheHelper.SetupMockAdditionalPathExtensions(typeof(TestPluginCacheTests)); - TestPluginCache.Instance.GetTestExtensions(typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location); + TestPluginCache.Instance.GetTestExtensions(typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location); - Assert.IsNotNull(TestPluginCache.Instance.TestExtensions); - Assert.IsTrue(TestPluginCache.Instance.TestExtensions.TestDiscoverers.Count > 0); - } + Assert.IsNotNull(TestPluginCache.Instance.TestExtensions); + Assert.IsTrue(TestPluginCache.Instance.TestExtensions.TestDiscoverers.Count > 0); + } - [TestMethod] - public void GetTestExtensionsShouldAddTestExtensionsDiscoveredToCache() - { - var extensionAssembly = typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location; + [TestMethod] + public void GetTestExtensionsShouldAddTestExtensionsDiscoveredToCache() + { + var extensionAssembly = typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location; - var testDiscovererPluginInfos = this.testablePluginCache.GetTestExtensions(extensionAssembly); + var testDiscovererPluginInfos = _testablePluginCache.GetTestExtensions(extensionAssembly); - CollectionAssert.AreEqual( - this.testablePluginCache.TestExtensions.TestDiscoverers.Keys, - testDiscovererPluginInfos.Keys); - } + CollectionAssert.AreEqual( + _testablePluginCache.TestExtensions.TestDiscoverers.Keys, + testDiscovererPluginInfos.Keys); + } - [TestMethod] - public void GetTestExtensionsShouldGetTestExtensionsFromCache() - { - var extensionAssembly = typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location; - var testDiscovererPluginInfos = this.testablePluginCache.GetTestExtensions(extensionAssembly); - Assert.IsFalse(testDiscovererPluginInfos.ContainsKey("td")); + [TestMethod] + public void GetTestExtensionsShouldGetTestExtensionsFromCache() + { + var extensionAssembly = typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location; + var testDiscovererPluginInfos = _testablePluginCache.GetTestExtensions(extensionAssembly); + Assert.IsFalse(testDiscovererPluginInfos.ContainsKey("td")); - // Set the cache. - this.testablePluginCache.TestExtensions.TestDiscoverers.Add("td", new TestDiscovererPluginInformation(typeof(TestPluginCacheTests))); + // Set the cache. + _testablePluginCache.TestExtensions.TestDiscoverers.Add("td", new TestDiscovererPluginInformation(typeof(TestPluginCacheTests))); - testDiscovererPluginInfos = this.testablePluginCache.GetTestExtensions(extensionAssembly); - Assert.IsTrue(testDiscovererPluginInfos.ContainsKey("td")); - } + testDiscovererPluginInfos = _testablePluginCache.GetTestExtensions(extensionAssembly); + Assert.IsTrue(testDiscovererPluginInfos.ContainsKey("td")); + } - [Ignore] - [TestMethod] - public void GetTestExtensionsShouldShouldThrowIfDiscovererThrows() - { - //TODO : make ITestDiscoverer interface and then mock it in order to make this test case pass. + [Ignore] + [TestMethod] + public void GetTestExtensionsShouldShouldThrowIfDiscovererThrows() + { + //TODO : make ITestDiscoverer interface and then mock it in order to make this test case pass. - var extensionAssembly = typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location; - Assert.ThrowsException(() => this.testablePluginCache.GetTestExtensions(extensionAssembly)); - } + var extensionAssembly = typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location; + Assert.ThrowsException(() => _testablePluginCache.GetTestExtensions(extensionAssembly)); + } - #endregion + #endregion - #region DiscoverTestExtensions tests + #region DiscoverTestExtensions tests - [TestMethod] - public void DiscoverTestExtensionsShouldDiscoverExtensionsFromExtensionsFolder() - { - TestPluginCacheHelper.SetupMockAdditionalPathExtensions(typeof(TestPluginCacheTests)); + [TestMethod] + public void DiscoverTestExtensionsShouldDiscoverExtensionsFromExtensionsFolder() + { + TestPluginCacheHelper.SetupMockAdditionalPathExtensions(typeof(TestPluginCacheTests)); - TestPluginCache.Instance.DiscoverTestExtensions(TestPlatformConstants.TestAdapterEndsWithPattern); + TestPluginCache.Instance.DiscoverTestExtensions(TestPlatformConstants.TestAdapterEndsWithPattern); - Assert.IsNotNull(TestPluginCache.Instance.TestExtensions); + Assert.IsNotNull(TestPluginCache.Instance.TestExtensions); - // Validate the discoverers to be absolutely certain. - Assert.IsTrue(TestPluginCache.Instance.TestExtensions.TestDiscoverers.Count > 0); - } + // Validate the discoverers to be absolutely certain. + Assert.IsTrue(TestPluginCache.Instance.TestExtensions.TestDiscoverers.Count > 0); + } - [TestMethod] - public void DiscoverTestExtensionsShouldSetCachedBoolToTrue() - { - TestPluginCacheHelper.SetupMockAdditionalPathExtensions(typeof(TestPluginCacheTests)); + [TestMethod] + public void DiscoverTestExtensionsShouldSetCachedBoolToTrue() + { + TestPluginCacheHelper.SetupMockAdditionalPathExtensions(typeof(TestPluginCacheTests)); - TestPluginCache.Instance.DiscoverTestExtensions(TestPlatformConstants.TestAdapterEndsWithPattern); + TestPluginCache.Instance.DiscoverTestExtensions(TestPlatformConstants.TestAdapterEndsWithPattern); - Assert.IsTrue(TestPluginCache.Instance.TestExtensions.AreTestDiscoverersCached); - Assert.IsTrue(TestPluginCache.Instance.TestExtensions.AreTestExtensionsCached()); - } + Assert.IsTrue(TestPluginCache.Instance.TestExtensions.AreTestDiscoverersCached); + Assert.IsTrue(TestPluginCache.Instance.TestExtensions.AreTestExtensionsCached()); + } - #endregion + #endregion - private void InvokeGetExtensionPaths(List expectedExtensions, bool skipDefaultExtensions) - { - TestPluginCache.Instance.UpdateExtensions(new[] { @"filter.dll", @"other.dll" }, false); - TestPluginCache.Instance.UpdateExtensions(new[] { @"unfilter.dll" }, true); - TestPluginCache.Instance.DefaultExtensionPaths = new[] { "default.dll" }; + private void InvokeGetExtensionPaths(List expectedExtensions, bool skipDefaultExtensions) + { + TestPluginCache.Instance.UpdateExtensions(new[] { @"filter.dll", @"other.dll" }, false); + TestPluginCache.Instance.UpdateExtensions(new[] { @"unfilter.dll" }, true); + TestPluginCache.Instance.DefaultExtensionPaths = new[] { "default.dll" }; - var extensions = TestPluginCache.Instance.GetExtensionPaths("filter.dll", skipDefaultExtensions); + var extensions = TestPluginCache.Instance.GetExtensionPaths("filter.dll", skipDefaultExtensions); - CollectionAssert.AreEquivalent(expectedExtensions, extensions); - } + CollectionAssert.AreEquivalent(expectedExtensions, extensions); } -} - +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginDiscovererTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginDiscovererTests.cs index 3f623486e7..75f9bbaa02 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginDiscovererTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginDiscovererTests.cs @@ -1,367 +1,366 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.ExtensionFramework +namespace TestPlatform.Common.UnitTests.ExtensionFramework; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Threading; +using System.Threading.Tasks; +using System.Xml; + +using Microsoft.VisualStudio.TestPlatform.Common.DataCollector; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using MSTest.TestFramework.AssertExtensions; + +[TestClass] +public class TestPluginDiscovererTests { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Reflection; - using System.Threading; - using System.Threading.Tasks; - using System.Xml; - - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using MSTest.TestFramework.AssertExtensions; - - [TestClass] - public class TestPluginDiscovererTests + private readonly TestPluginDiscoverer _testPluginDiscoverer; + + public TestPluginDiscovererTests() { - private TestPluginDiscoverer testPluginDiscoverer; + _testPluginDiscoverer = new TestPluginDiscoverer(); + } - public TestPluginDiscovererTests() - { - this.testPluginDiscoverer = new TestPluginDiscoverer(); - } + [TestMethod] + public void GetTestExtensionsInformationShouldNotThrowOnALoadException() + { + var pathToExtensions = new List { "foo.dll" }; - [TestMethod] - public void GetTestExtensionsInformationShouldNotThrowOnALoadException() - { - var pathToExtensions = new List { "foo.dll" }; + // The below should not throw an exception. + Assert.IsNotNull(_testPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions)); + } - // The below should not throw an exception. - Assert.IsNotNull(this.testPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions)); - } + [TestMethod] + public void GetTestExtensionsInformationShouldNotConsiderAbstractClasses() + { + var pathToExtensions = new List { typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location }; - [TestMethod] - public void GetTestExtensionsInformationShouldNotConsiderAbstractClasses() - { - var pathToExtensions = new List { typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location }; + // The below should not throw an exception. + var testExtensions = _testPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); + var discovererPluginInformation = new TestDiscovererPluginInformation(typeof(AbstractTestDiscoverer)); + Assert.IsFalse(testExtensions.ContainsKey(discovererPluginInformation.IdentifierData)); + } - // The below should not throw an exception. - var testExtensions = this.testPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); - var discovererPluginInformation = new TestDiscovererPluginInformation(typeof(AbstractTestDiscoverer)); - Assert.IsFalse(testExtensions.ContainsKey(discovererPluginInformation.IdentifierData)); - } + [TestMethod] + public void GetTestExtensionsInformationShouldReturnDiscovererExtensions() + { + var pathToExtensions = new List { typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location }; - [TestMethod] - public void GetTestExtensionsInformationShouldReturnDiscovererExtensions() - { - var pathToExtensions = new List { typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location }; + // The below should not throw an exception. + var testExtensions = _testPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); - // The below should not throw an exception. - var testExtensions = this.testPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); + var discovererPluginInformation = new TestDiscovererPluginInformation(typeof(ValidDiscoverer)); + var discovererPluginInformation2 = new TestDiscovererPluginInformation(typeof(ValidDiscoverer2)); - var discovererPluginInformation = new TestDiscovererPluginInformation(typeof(ValidDiscoverer)); - var discovererPluginInformation2 = new TestDiscovererPluginInformation(typeof(ValidDiscoverer2)); + Assert.IsTrue(testExtensions.ContainsKey(discovererPluginInformation.IdentifierData)); + Assert.IsTrue(testExtensions.ContainsKey(discovererPluginInformation2.IdentifierData)); + } - Assert.IsTrue(testExtensions.ContainsKey(discovererPluginInformation.IdentifierData)); - Assert.IsTrue(testExtensions.ContainsKey(discovererPluginInformation2.IdentifierData)); - } + [TestMethod] + public void GetTestExtensionsInformationShouldReturnExecutorExtensions() + { + var pathToExtensions = new List { typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location }; - [TestMethod] - public void GetTestExtensionsInformationShouldReturnExecutorExtensions() - { - var pathToExtensions = new List { typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location }; + // The below should not throw an exception. + var testExtensions = _testPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); - // The below should not throw an exception. - var testExtensions = this.testPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); + var pluginInformation = new TestExecutorPluginInformation(typeof(ValidExecutor)); + var pluginInformation2 = new TestExecutorPluginInformation(typeof(ValidExecutor2)); - var pluginInformation = new TestExecutorPluginInformation(typeof(ValidExecutor)); - var pluginInformation2 = new TestExecutorPluginInformation(typeof(ValidExecutor2)); + Assert.AreEqual(2, testExtensions.Keys.Count(k => k.Contains("ValidExecutor"))); + Assert.IsTrue(testExtensions.ContainsKey(pluginInformation.IdentifierData)); + Assert.IsTrue(testExtensions.ContainsKey(pluginInformation2.IdentifierData)); + } - Assert.AreEqual(2, testExtensions.Keys.Count(k => k.Contains("ValidExecutor"))); - Assert.IsTrue(testExtensions.ContainsKey(pluginInformation.IdentifierData)); - Assert.IsTrue(testExtensions.ContainsKey(pluginInformation2.IdentifierData)); - } + [TestMethod] + public void GetTestExtensionsInformationShouldReturnLoggerExtensions() + { + var pathToExtensions = new List { typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location }; - [TestMethod] - public void GetTestExtensionsInformationShouldReturnLoggerExtensions() - { - var pathToExtensions = new List { typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location }; + // The below should not throw an exception. + var testExtensions = _testPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); - // The below should not throw an exception. - var testExtensions = this.testPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); + var pluginInformation = new TestLoggerPluginInformation(typeof(ValidLogger)); + var pluginInformation2 = new TestLoggerPluginInformation(typeof(ValidLogger2)); - var pluginInformation = new TestLoggerPluginInformation(typeof(ValidLogger)); - var pluginInformation2 = new TestLoggerPluginInformation(typeof(ValidLogger2)); + Assert.AreEqual(1, testExtensions.Keys.Count(k => k.Contains("csv"))); + Assert.IsTrue(testExtensions.ContainsKey(pluginInformation.IdentifierData)); + Assert.IsTrue(testExtensions.ContainsKey(pluginInformation2.IdentifierData)); + } - Assert.AreEqual(1, testExtensions.Keys.Count(k => k.Contains("csv"))); - Assert.IsTrue(testExtensions.ContainsKey(pluginInformation.IdentifierData)); - Assert.IsTrue(testExtensions.ContainsKey(pluginInformation2.IdentifierData)); - } + [TestMethod] + public void GetTestExtensionsInformationShouldReturnDataCollectorExtensionsAndIgnoresInvalidDataCollectors() + { + var pathToExtensions = new List { typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location }; - [TestMethod] - public void GetTestExtensionsInformationShouldReturnDataCollectorExtensionsAndIgnoresInvalidDataCollectors() - { - var pathToExtensions = new List { typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location }; + // The below should not throw an exception. + var testExtensions = _testPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); - // The below should not throw an exception. - var testExtensions = this.testPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); + var pluginInformation = new DataCollectorConfig(typeof(ValidDataCollector)); - var pluginInformation = new DataCollectorConfig(typeof(ValidDataCollector)); + Assert.AreEqual(2, testExtensions.Keys.Count); + Assert.AreEqual(1, testExtensions.Keys.Count(k => k.Equals("datacollector://foo/bar"))); + Assert.AreEqual(1, testExtensions.Keys.Count(k => k.Equals("datacollector://foo/bar1"))); + } - Assert.AreEqual(2, testExtensions.Keys.Count); - Assert.AreEqual(1, testExtensions.Keys.Count(k => k.Equals("datacollector://foo/bar"))); - Assert.AreEqual(1, testExtensions.Keys.Count(k => k.Equals("datacollector://foo/bar1"))); - } + [TestMethod] + public void GetTestExtensionsInformationShouldReturnSettingsProviderExtensions() + { + var pathToExtensions = new List { typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location }; - [TestMethod] - public void GetTestExtensionsInformationShouldReturnSettingsProviderExtensions() + // The below should not throw an exception. + var testExtensions = _testPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); + + var pluginInformation = new TestSettingsProviderPluginInformation(typeof(ValidSettingsProvider)); + var pluginInformation2 = new TestSettingsProviderPluginInformation(typeof(ValidSettingsProvider2)); + + Assert.IsTrue(testExtensions.Keys.Select(k => k.Contains("ValidSettingsProvider")).Count() >= 3); + Assert.IsTrue(testExtensions.ContainsKey(pluginInformation.IdentifierData)); + Assert.IsTrue(testExtensions.ContainsKey(pluginInformation2.IdentifierData)); + } + + [TestMethod] + public void GetTestExtensionsInformationShouldNotAbortOnFaultyExtensions() + { + var pathToExtensions = new List { - var pathToExtensions = new List { typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location }; + typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location, + }; - // The below should not throw an exception. - var testExtensions = this.testPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); + var testExtensions = _testPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); - var pluginInformation = new TestSettingsProviderPluginInformation(typeof(ValidSettingsProvider)); - var pluginInformation2 = new TestSettingsProviderPluginInformation(typeof(ValidSettingsProvider2)); + Assert.That.DoesNotThrow(() => _testPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions)); + } - Assert.IsTrue(testExtensions.Keys.Select(k => k.Contains("ValidSettingsProvider")).Count() >= 3); - Assert.IsTrue(testExtensions.ContainsKey(pluginInformation.IdentifierData)); - Assert.IsTrue(testExtensions.ContainsKey(pluginInformation2.IdentifierData)); - } + #region Implementations + + #region Discoverers - [TestMethod] - public void GetTestExtensionsInformationShouldNotAbortOnFaultyExtensions() + private abstract class AbstractTestDiscoverer : ITestDiscoverer + { + public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) { - var pathToExtensions = new List - { - typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location, - }; + throw new NotImplementedException(); + } + } - var testExtensions = this.testPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); + private class ValidDiscoverer : ITestDiscoverer + { + public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) + { + throw new NotImplementedException(); + } + } - Assert.That.DoesNotThrow(() => this.testPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions)); + private class ValidDiscoverer2 : ITestDiscoverer + { + public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) + { + throw new NotImplementedException(); } + } - #region Implementations + #endregion - #region Discoverers + #region Executors - private abstract class AbstractTestDiscoverer : ITestDiscoverer + [ExtensionUri("ValidExecutor")] + private class ValidExecutor : ITestExecutor + { + public void Cancel() { - public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } - private class ValidDiscoverer : ITestDiscoverer + public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) { - public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } - private class ValidDiscoverer2 : ITestDiscoverer + public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) { - public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } + } - #endregion + [ExtensionUri("ValidExecutor2")] + private class ValidExecutor2 : ITestExecutor + { + public void Cancel() + { + throw new NotImplementedException(); + } - #region Executors + public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) + { + throw new NotImplementedException(); + } + + public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) + { + throw new NotImplementedException(); + } + } - [ExtensionUri("ValidExecutor")] - private class ValidExecutor : ITestExecutor + [ExtensionUri("ValidExecutor")] + private class DuplicateExecutor : ITestExecutor + { + public void Cancel() { - public void Cancel() - { - throw new NotImplementedException(); - } - - public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - throw new NotImplementedException(); - } - - public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } - [ExtensionUri("ValidExecutor2")] - private class ValidExecutor2 : ITestExecutor + public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) { - public void Cancel() - { - throw new NotImplementedException(); - } - - public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - throw new NotImplementedException(); - } - - public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } - [ExtensionUri("ValidExecutor")] - private class DuplicateExecutor : ITestExecutor + public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) { - public void Cancel() - { - throw new NotImplementedException(); - } - - public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - throw new NotImplementedException(); - } - - public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } + } - #endregion + #endregion - #region Loggers + #region Loggers - [ExtensionUri("csv")] - private class ValidLogger : ITestLogger + [ExtensionUri("csv")] + private class ValidLogger : ITestLogger + { + public void Initialize(TestLoggerEvents events, string testRunDirectory) { - public void Initialize(TestLoggerEvents events, string testRunDirectory) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } + } - [ExtensionUri("docx")] - private class ValidLogger2 : ITestLogger + [ExtensionUri("docx")] + private class ValidLogger2 : ITestLogger + { + public void Initialize(TestLoggerEvents events, string testRunDirectory) { - public void Initialize(TestLoggerEvents events, string testRunDirectory) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } + } - [ExtensionUri("csv")] - private class DuplicateLogger : ITestLogger + [ExtensionUri("csv")] + private class DuplicateLogger : ITestLogger + { + public void Initialize(TestLoggerEvents events, string testRunDirectory) { - public void Initialize(TestLoggerEvents events, string testRunDirectory) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } + } - #endregion + #endregion - #region Settings Providers + #region Settings Providers - [SettingsName("ValidSettingsProvider")] - private class ValidSettingsProvider : ISettingsProvider + [SettingsName("ValidSettingsProvider")] + private class ValidSettingsProvider : ISettingsProvider + { + public void Load(XmlReader reader) { - public void Load(XmlReader reader) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } + } - [SettingsName("ValidSettingsProvider2")] - private class ValidSettingsProvider2 : ISettingsProvider + [SettingsName("ValidSettingsProvider2")] + private class ValidSettingsProvider2 : ISettingsProvider + { + public void Load(XmlReader reader) { - public void Load(XmlReader reader) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } + } - [SettingsName("ValidSettingsProvider")] - private class DuplicateSettingsProvider : ISettingsProvider + [SettingsName("ValidSettingsProvider")] + private class DuplicateSettingsProvider : ISettingsProvider + { + public void Load(XmlReader reader) { - public void Load(XmlReader reader) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } + } - #endregion + #endregion - #region DataCollectors + #region DataCollectors - public class InvalidDataCollector : DataCollector + public class InvalidDataCollector : DataCollector + { + public override void Initialize( + XmlElement configurationElement, + DataCollectionEvents events, + DataCollectionSink dataSink, + DataCollectionLogger logger, + DataCollectionEnvironmentContext environmentContext) { - public override void Initialize( - XmlElement configurationElement, - DataCollectionEvents events, - DataCollectionSink dataSink, - DataCollectionLogger logger, - DataCollectionEnvironmentContext environmentContext) - { - } } + } - /// - /// The a data collector inheriting from another data collector. - /// - [DataCollectorFriendlyName("Foo1")] - [DataCollectorTypeUri("datacollector://foo/bar1")] - public class ADataCollectorInheritingFromAnotherDataCollector : InvalidDataCollector + /// + /// The a data collector inheriting from another data collector. + /// + [DataCollectorFriendlyName("Foo1")] + [DataCollectorTypeUri("datacollector://foo/bar1")] + public class ADataCollectorInheritingFromAnotherDataCollector : InvalidDataCollector + { + } + + [DataCollectorFriendlyName("Foo")] + [DataCollectorTypeUri("datacollector://foo/bar")] + [DataCollectorAttachmentProcessor(typeof(DataCollectorAttachmentProcessor))] + public class ValidDataCollector : DataCollector + { + public override void Initialize( + XmlElement configurationElement, + DataCollectionEvents events, + DataCollectionSink dataSink, + DataCollectionLogger logger, + DataCollectionEnvironmentContext environmentContext) { } + } - [DataCollectorFriendlyName("Foo")] - [DataCollectorTypeUri("datacollector://foo/bar")] - [DataCollectorAttachmentProcessor(typeof(DataCollectorAttachmentProcessor))] - public class ValidDataCollector : DataCollector + public class DataCollectorAttachmentProcessor : IDataCollectorAttachmentProcessor + { + public bool SupportsIncrementalProcessing => throw new NotImplementedException(); + + public IEnumerable GetExtensionUris() { - public override void Initialize( - XmlElement configurationElement, - DataCollectionEvents events, - DataCollectionSink dataSink, - DataCollectionLogger logger, - DataCollectionEnvironmentContext environmentContext) - { - } + throw new NotImplementedException(); } - public class DataCollectorAttachmentProcessor : IDataCollectorAttachmentProcessor + public Task> ProcessAttachmentSetsAsync(XmlElement configurationElement, ICollection attachments, IProgress progressReporter, IMessageLogger logger, CancellationToken cancellationToken) { - public bool SupportsIncrementalProcessing => throw new NotImplementedException(); - - public IEnumerable GetExtensionUris() - { - throw new NotImplementedException(); - } - - public Task> ProcessAttachmentSetsAsync(XmlElement configurationElement, ICollection attachments, IProgress progressReporter, IMessageLogger logger, CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } - #endregion + } + #endregion - internal class FaultyTestExecutorPluginInformation : TestExtensionPluginInformation + internal class FaultyTestExecutorPluginInformation : TestExtensionPluginInformation + { + /// + /// Default constructor + /// + /// The Type. + public FaultyTestExecutorPluginInformation(Type type) : base(type) { - /// - /// Default constructor - /// - /// The Type. - public FaultyTestExecutorPluginInformation(Type type) : base(type) - { - throw new Exception(); - } + throw new Exception(); } - #endregion } -} + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginManagerTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginManagerTests.cs index 6684ecde72..8277983bec 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginManagerTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginManagerTests.cs @@ -1,155 +1,155 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.ExtensionFramework +namespace TestPlatform.Common.UnitTests.ExtensionFramework; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class TestPluginManagerTests { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Reflection; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class TestPluginManagerTests + [TestMethod] + public void GetTestExtensionTypeShouldReturnExtensionType() { - [TestMethod] - public void GetTestExtensionTypeShouldReturnExtensionType() - { - var type = TestPluginManager.GetTestExtensionType(typeof(TestPluginManagerTests).AssemblyQualifiedName); + var type = TestPluginManager.GetTestExtensionType(typeof(TestPluginManagerTests).AssemblyQualifiedName); - Assert.AreEqual(typeof(TestPluginManagerTests), type); - } + Assert.AreEqual(typeof(TestPluginManagerTests), type); + } - [TestMethod] - public void GetTestExtensionTypeShouldThrowIfTypeNotFound() - { - Assert.ThrowsException(() => TestPluginManager.GetTestExtensionType("randomassemblyname.random")); - } + [TestMethod] + public void GetTestExtensionTypeShouldThrowIfTypeNotFound() + { + Assert.ThrowsException(() => TestPluginManager.GetTestExtensionType("randomassemblyname.random")); + } - [TestMethod] - public void CreateTestExtensionShouldCreateExtensionTypeInstance() - { - var instance = TestPluginManager.CreateTestExtension(typeof(DummyTestDiscoverer)); + [TestMethod] + public void CreateTestExtensionShouldCreateExtensionTypeInstance() + { + var instance = TestPluginManager.CreateTestExtension(typeof(DummyTestDiscoverer)); - Assert.IsNotNull(instance); - } + Assert.IsNotNull(instance); + } - [TestMethod] - public void CreateTestExtensionShouldThrowIfInstanceCannotBeCreated() - { - Assert.ThrowsException(() => TestPluginManager.CreateTestExtension(typeof(AbstractDummyLogger))); - } + [TestMethod] + public void CreateTestExtensionShouldThrowIfInstanceCannotBeCreated() + { + Assert.ThrowsException(() => TestPluginManager.CreateTestExtension(typeof(AbstractDummyLogger))); + } - [TestMethod] - public void InstanceShouldReturnTestPluginManagerInstance() - { - var instance = TestPluginManager.Instance; + [TestMethod] + public void InstanceShouldReturnTestPluginManagerInstance() + { + var instance = TestPluginManager.Instance; - Assert.IsNotNull(instance); - Assert.IsTrue(instance is TestPluginManager); - } + Assert.IsNotNull(instance); + Assert.IsTrue(instance is TestPluginManager); + } - [TestMethod] - public void InstanceShouldReturnCachedTestPluginManagerInstance() - { - var instance = TestPluginManager.Instance; + [TestMethod] + public void InstanceShouldReturnCachedTestPluginManagerInstance() + { + var instance = TestPluginManager.Instance; - Assert.AreEqual(instance, TestPluginManager.Instance); - } + Assert.AreEqual(instance, TestPluginManager.Instance); + } - [TestMethod] - public void GetTestExtensionsShouldReturnTestDiscovererExtensions() - { - TestPluginCacheHelper.SetupMockExtensions(typeof(TestPluginManagerTests)); + [TestMethod] + public void GetTestExtensionsShouldReturnTestDiscovererExtensions() + { + TestPluginCacheHelper.SetupMockExtensions(typeof(TestPluginManagerTests)); - TestPluginManager.Instance.GetSpecificTestExtensions( - TestPlatformConstants.TestAdapterEndsWithPattern, - out var unfilteredTestExtensions, - out var testExtensions); + TestPluginManager.Instance.GetSpecificTestExtensions( + TestPlatformConstants.TestAdapterEndsWithPattern, + out var unfilteredTestExtensions, + out var testExtensions); - Assert.IsNotNull(unfilteredTestExtensions); - Assert.IsNotNull(testExtensions); - Assert.IsTrue(testExtensions.Any()); - } + Assert.IsNotNull(unfilteredTestExtensions); + Assert.IsNotNull(testExtensions); + Assert.IsTrue(testExtensions.Any()); + } - [TestMethod] - public void GetTestExtensionsShouldDiscoverExtensionsOnlyOnce() - { - var discoveryCount = 0; - TestPluginCacheHelper.SetupMockExtensions(typeof(TestPluginManagerTests), () => { discoveryCount++; }); + [TestMethod] + public void GetTestExtensionsShouldDiscoverExtensionsOnlyOnce() + { + var discoveryCount = 0; + TestPluginCacheHelper.SetupMockExtensions(typeof(TestPluginManagerTests), () => discoveryCount++); + + TestPluginManager.Instance.GetSpecificTestExtensions( + TestPlatformConstants.TestAdapterEndsWithPattern, + out var unfilteredTestExtensions, + out var testExtensions); + + // Call this again to verify that discovery is not called again. + TestPluginManager.Instance.GetSpecificTestExtensions( + TestPlatformConstants.TestAdapterEndsWithPattern, + out unfilteredTestExtensions, + out testExtensions); + + Assert.IsNotNull(testExtensions); + Assert.IsTrue(testExtensions.Any()); + + Assert.AreEqual(2, discoveryCount); + } - TestPluginManager.Instance.GetSpecificTestExtensions( - TestPlatformConstants.TestAdapterEndsWithPattern, - out var unfilteredTestExtensions, + [TestMethod] + public void GetTestExtensionsForAnExtensionAssemblyShouldReturnExtensionsInThatAssembly() + { + TestPluginManager.Instance + .GetTestExtensions( + typeof(TestPluginManagerTests).GetTypeInfo().Assembly.Location, + out _, out var testExtensions); - // Call this again to verify that discovery is not called again. - TestPluginManager.Instance.GetSpecificTestExtensions( - TestPlatformConstants.TestAdapterEndsWithPattern, - out unfilteredTestExtensions, - out testExtensions); + Assert.IsNotNull(testExtensions); + Assert.IsTrue(testExtensions.Any()); + } - Assert.IsNotNull(testExtensions); - Assert.IsTrue(testExtensions.Any()); + #region Implementations - Assert.AreEqual(2, discoveryCount); + private abstract class AbstractDummyLogger : ITestLogger + { + public void Initialize(TestLoggerEvents events, string testRunDirectory) + { + throw new NotImplementedException(); } + } - [TestMethod] - public void GetTestExtensionsForAnExtensionAssemblyShouldReturnExtensionsInThatAssembly() + private class DummyTestDiscoverer : ITestDiscoverer, ITestExecutor + { + public void Cancel() { - TestPluginManager.Instance - .GetTestExtensions( - typeof(TestPluginManagerTests).GetTypeInfo().Assembly.Location, - out var unfilteredTestExtensions, - out var testExtensions); - - Assert.IsNotNull(testExtensions); - Assert.IsTrue(testExtensions.Any()); + throw new NotImplementedException(); } - #region Implementations - - private abstract class AbstractDummyLogger : ITestLogger + public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) { - public void Initialize(TestLoggerEvents events, string testRunDirectory) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } - private class DummyTestDiscoverer : ITestDiscoverer, ITestExecutor + public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) { - public void Cancel() - { - throw new NotImplementedException(); - } - - public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) - { - throw new NotImplementedException(); - } - - public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - throw new NotImplementedException(); - } - - public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } - #endregion + public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) + { + throw new NotImplementedException(); + } } -} + + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/LazyExtensionTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/LazyExtensionTests.cs index c4eba8d2fd..1f57481921 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/LazyExtensionTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/LazyExtensionTests.cs @@ -1,149 +1,149 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.ExtensionFramework.Utilities +namespace TestPlatform.Common.UnitTests.ExtensionFramework.Utilities; + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; + +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class LazyExtensionTests { - using System; - using System.Collections.Generic; - using System.ComponentModel; - using System.Linq; - - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - - [TestClass] - public class LazyExtensionTests + #region Value tests + + [TestMethod] + public void ValueShouldCreateExtensionViaTheCallback() { - #region Value tests + var mockExtension = new Mock(); + LazyExtension extension = + new( + () => mockExtension.Object, + new Mock().Object); - [TestMethod] - public void ValueShouldCreateExtensionViaTheCallback() - { - var mockExtension = new Mock(); - LazyExtension extension = - new LazyExtension( - () => { return mockExtension.Object; }, - new Mock().Object); + Assert.AreEqual(mockExtension.Object, extension.Value); + } - Assert.AreEqual(mockExtension.Object, extension.Value); - } + [TestMethod] + public void ValueShouldCreateExtensionViaTestPluginManager() + { + var testDiscovererPluginInfo = new TestDiscovererPluginInformation(typeof(DummyExtension)); + LazyExtension extension = + new( + testDiscovererPluginInfo, + new Mock().Object); + + Assert.IsNotNull(extension.Value); + Assert.AreEqual(typeof(DummyExtension), extension.Value.GetType()); + } - [TestMethod] - public void ValueShouldCreateExtensionViaTestPluginManager() - { - var testDiscovererPluginInfo = new TestDiscovererPluginInformation(typeof(DummyExtension)); - LazyExtension extension = - new LazyExtension( - testDiscovererPluginInfo, - new Mock().Object); - - Assert.IsNotNull(extension.Value); - Assert.AreEqual(typeof(DummyExtension), extension.Value.GetType()); - } + [TestMethod] + public void ValueShouldNotCreateExtensionIfAlreadyCreated() + { + var numberOfTimesExtensionCreated = 0; + var mockExtension = new Mock(); + LazyExtension extension = + new( + () => + { + numberOfTimesExtensionCreated++; + return mockExtension.Object; + }, + new Mock().Object); + + var temp = extension.Value; + temp = extension.Value; + + Assert.AreEqual(1, numberOfTimesExtensionCreated); + } - [TestMethod] - public void ValueShouldNotCreateExtensionIfAlreadyCreated() - { - var numberOfTimesExtensionCreated = 0; - var mockExtension = new Mock(); - LazyExtension extension = - new LazyExtension( - () => - { - numberOfTimesExtensionCreated++; - return mockExtension.Object; - }, - new Mock().Object); - - var temp = extension.Value; - temp = extension.Value; - - Assert.AreEqual(1, numberOfTimesExtensionCreated); - } + #endregion - #endregion + #region metadata tests - #region metadata tests + [TestMethod] + public void MetadataShouldReturnMetadataSpecified() + { + var testDiscovererPluginInfo = new TestDiscovererPluginInformation(typeof(DummyExtension)); + var mockMetadata = new Mock(); + LazyExtension extension = + new( + testDiscovererPluginInfo, + mockMetadata.Object); + + Assert.AreEqual(mockMetadata.Object, extension.Metadata); + } + + [TestMethod] + public void MetadataShouldCreateMetadataFromMetadataType() + { + var testDiscovererPluginInfo = new TestDiscovererPluginInformation(typeof(DummyExtension)); + LazyExtension extension = + new( + testDiscovererPluginInfo, + typeof(DummyDiscovererCapability)); + + var metadata = extension.Metadata; + Assert.IsNotNull(metadata); + Assert.AreEqual(typeof(DummyDiscovererCapability), metadata.GetType()); + CollectionAssert.AreEqual(new List { "csv" }, (metadata as ITestDiscovererCapabilities).FileExtension.ToArray()); + Assert.AreEqual("executor://unittestexecutor/", (metadata as ITestDiscovererCapabilities).DefaultExecutorUri.AbsoluteUri); + Assert.AreEqual(AssemblyType.Native, (metadata as ITestDiscovererCapabilities).AssemblyType); + } + + #endregion - [TestMethod] - public void MetadataShouldReturnMetadataSpecified() + #region Implementation + + private class DummyDiscovererCapability : ITestDiscovererCapabilities + { + public IEnumerable FileExtension { - var testDiscovererPluginInfo = new TestDiscovererPluginInformation(typeof(DummyExtension)); - var mockMetadata = new Mock(); - LazyExtension extension = - new LazyExtension( - testDiscovererPluginInfo, - mockMetadata.Object); - - Assert.AreEqual(mockMetadata.Object, extension.Metadata); + get; + private set; } - [TestMethod] - public void MetadataShouldCreateMetadataFromMetadataType() + public Uri DefaultExecutorUri { - var testDiscovererPluginInfo = new TestDiscovererPluginInformation(typeof(DummyExtension)); - LazyExtension extension = - new LazyExtension( - testDiscovererPluginInfo, - typeof(DummyDiscovererCapability)); - - var metadata = extension.Metadata; - Assert.IsNotNull(metadata); - Assert.AreEqual(typeof(DummyDiscovererCapability), metadata.GetType()); - CollectionAssert.AreEqual(new List { "csv" }, (metadata as ITestDiscovererCapabilities).FileExtension.ToArray()); - Assert.AreEqual("executor://unittestexecutor/", (metadata as ITestDiscovererCapabilities).DefaultExecutorUri.AbsoluteUri); - Assert.AreEqual(AssemblyType.Native, (metadata as ITestDiscovererCapabilities).AssemblyType); + get; + private set; } - #endregion - - #region Implementation + public AssemblyType AssemblyType + { + get; + private set; + } - private class DummyDiscovererCapability : ITestDiscovererCapabilities + public DummyDiscovererCapability(List fileExtensions, string executorUri, AssemblyType assemblyType) { - public IEnumerable FileExtension - { - get; - private set; - } - - public Uri DefaultExecutorUri - { - get; - private set; - } - - public AssemblyType AssemblyType - { - get; - private set; - } - - public DummyDiscovererCapability(List fileExtensions, string executorURI, AssemblyType assemblyType) - { - this.FileExtension = fileExtensions; - this.DefaultExecutorUri = new Uri(executorURI); - this.AssemblyType = assemblyType; - } + FileExtension = fileExtensions; + DefaultExecutorUri = new Uri(executorUri); + AssemblyType = assemblyType; } + } - [FileExtension("csv")] - [DefaultExecutorUri("executor://unittestexecutor")] - [Category("native")] - private class DummyExtension : ITestDiscoverer + [FileExtension("csv")] + [DefaultExecutorUri("executor://unittestexecutor")] + [Category("native")] + private class DummyExtension : ITestDiscoverer + { + public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) { - public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) - { - } } - - #endregion } -} + + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/RunSettingsProviderExtensionsTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/RunSettingsProviderExtensionsTests.cs index 114bcf4b7b..c757e012f5 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/RunSettingsProviderExtensionsTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/RunSettingsProviderExtensionsTests.cs @@ -1,315 +1,313 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors.Utilities +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors.Utilities; + +using System; +using Common; +using Common.Interfaces; +using TestTools.UnitTesting; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; + +[TestClass] +public class RunSettingsProviderExtensionsTests { - using System; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using System.Text.RegularExpressions; - - [TestClass] - public class RunSettingsProviderExtensionsTests - { - private IRunSettingsProvider runSettingsProvider; - - [TestInitialize] - public void Init() - { - runSettingsProvider = new TestableRunSettingsProvider(); - } + private IRunSettingsProvider _runSettingsProvider; - [TestMethod] - public void UpdateRunSettingsShouldUpdateGivenSettingsXml() - { - string runSettingsXml = string.Join(Environment.NewLine, - "", - " ", - " X86", - " ", - ""); + [TestInitialize] + public void Init() + { + _runSettingsProvider = new TestableRunSettingsProvider(); + } - this.runSettingsProvider.UpdateRunSettings(runSettingsXml); + [TestMethod] + public void UpdateRunSettingsShouldUpdateGivenSettingsXml() + { + string runSettingsXml = string.Join(Environment.NewLine, + "", + " ", + " X86", + " ", + ""); - StringAssert.Contains(this.runSettingsProvider.ActiveRunSettings.SettingsXml, runSettingsXml); - } + _runSettingsProvider.UpdateRunSettings(runSettingsXml); - [TestMethod] - public void UpdateRunSettingsShouldThrownExceptionIfRunSettingsProviderIsNull() - { - Assert.ThrowsException( - () => RunSettingsProviderExtensions.UpdateRunSettings(null, "")); - } + StringAssert.Contains(_runSettingsProvider.ActiveRunSettings.SettingsXml, runSettingsXml); + } - [TestMethod] - public void UpdateRunSettingsShouldThrownExceptionIfSettingsXmlIsNull() - { - Assert.ThrowsException( - () => this.runSettingsProvider.UpdateRunSettings(null)); - } + [TestMethod] + public void UpdateRunSettingsShouldThrownExceptionIfRunSettingsProviderIsNull() + { + Assert.ThrowsException( + () => RunSettingsProviderExtensions.UpdateRunSettings(null, "")); + } - [TestMethod] - public void UpdateRunSettingsShouldThrownExceptionIfSettingsXmlIsEmptyOrWhiteSpace() - { - Assert.ThrowsException( - () => this.runSettingsProvider.UpdateRunSettings(" ")); - } + [TestMethod] + public void UpdateRunSettingsShouldThrownExceptionIfSettingsXmlIsNull() + { + Assert.ThrowsException( + () => _runSettingsProvider.UpdateRunSettings(null)); + } - [TestMethod] - public void AddDefaultRunSettingsShouldSetDefaultSettingsForEmptySettings() - { - this.runSettingsProvider.AddDefaultRunSettings(); + [TestMethod] + public void UpdateRunSettingsShouldThrownExceptionIfSettingsXmlIsEmptyOrWhiteSpace() + { + Assert.ThrowsException( + () => _runSettingsProvider.UpdateRunSettings(" ")); + } - var runConfiguration = - XmlRunSettingsUtilities.GetRunConfigurationNode(this.runSettingsProvider.ActiveRunSettings.SettingsXml); - Assert.AreEqual(runConfiguration.ResultsDirectory, Constants.DefaultResultsDirectory); - Assert.AreEqual(runConfiguration.TargetFramework.ToString(), Framework.DefaultFramework.ToString()); - Assert.AreEqual(runConfiguration.TargetPlatform, Constants.DefaultPlatform); - } + [TestMethod] + public void AddDefaultRunSettingsShouldSetDefaultSettingsForEmptySettings() + { + _runSettingsProvider.AddDefaultRunSettings(); - [TestMethod] - public void AddDefaultRunSettingsShouldAddUnspecifiedSettings() - { - this.runSettingsProvider.UpdateRunSettings(string.Join(Environment.NewLine, - "", - " ", - " X86", - " ", - "")); - - this.runSettingsProvider.AddDefaultRunSettings(); - - var runConfiguration = - XmlRunSettingsUtilities.GetRunConfigurationNode(this.runSettingsProvider.ActiveRunSettings.SettingsXml); - Assert.AreEqual(runConfiguration.ResultsDirectory, Constants.DefaultResultsDirectory); - Assert.AreEqual(runConfiguration.TargetFramework.ToString(), Framework.DefaultFramework.ToString()); - } + var runConfiguration = + XmlRunSettingsUtilities.GetRunConfigurationNode(_runSettingsProvider.ActiveRunSettings.SettingsXml); + Assert.AreEqual(runConfiguration.ResultsDirectory, Constants.DefaultResultsDirectory); + Assert.AreEqual(runConfiguration.TargetFramework.ToString(), Framework.DefaultFramework.ToString()); + Assert.AreEqual(runConfiguration.TargetPlatform, Constants.DefaultPlatform); + } - [TestMethod] - public void AddDefaultRunSettingsShouldNotChangeSpecifiedSettings() - { - this.runSettingsProvider.UpdateRunSettings(string.Join(Environment.NewLine, - "", - " ", - " X64 ", - "")); + [TestMethod] + public void AddDefaultRunSettingsShouldAddUnspecifiedSettings() + { + _runSettingsProvider.UpdateRunSettings(string.Join(Environment.NewLine, + "", + " ", + " X86", + " ", + "")); + + _runSettingsProvider.AddDefaultRunSettings(); + + var runConfiguration = + XmlRunSettingsUtilities.GetRunConfigurationNode(_runSettingsProvider.ActiveRunSettings.SettingsXml); + Assert.AreEqual(runConfiguration.ResultsDirectory, Constants.DefaultResultsDirectory); + Assert.AreEqual(runConfiguration.TargetFramework.ToString(), Framework.DefaultFramework.ToString()); + } - this.runSettingsProvider.AddDefaultRunSettings(); + [TestMethod] + public void AddDefaultRunSettingsShouldNotChangeSpecifiedSettings() + { + _runSettingsProvider.UpdateRunSettings(string.Join(Environment.NewLine, + "", + " ", + " X64 ", + "")); - var runConfiguration = - XmlRunSettingsUtilities.GetRunConfigurationNode(this.runSettingsProvider.ActiveRunSettings.SettingsXml); - Assert.AreEqual(runConfiguration.TargetPlatform, Architecture.X64); - } + _runSettingsProvider.AddDefaultRunSettings(); - [TestMethod] - public void AddDefaultRunSettingsShouldThrowExceptionIfArgumentIsNull() - { - Assert.ThrowsException(() => - RunSettingsProviderExtensions.AddDefaultRunSettings(null)); - } + var runConfiguration = + XmlRunSettingsUtilities.GetRunConfigurationNode(_runSettingsProvider.ActiveRunSettings.SettingsXml); + Assert.AreEqual(runConfiguration.TargetPlatform, Architecture.X64); + } - [TestMethod] - public void UpdateRunSettingsNodeShouldThrowExceptionIfKeyIsNull() - { - Assert.ThrowsException(() => - this.runSettingsProvider.UpdateRunSettingsNode(null, "data")); - } + [TestMethod] + public void AddDefaultRunSettingsShouldThrowExceptionIfArgumentIsNull() + { + Assert.ThrowsException(() => + RunSettingsProviderExtensions.AddDefaultRunSettings(null)); + } - [TestMethod] - public void UpdateRunSettingsNodeShouldThrowExceptionIfKeyIsEmptyOrWhiteSpace() - { - Assert.ThrowsException(() => - this.runSettingsProvider.UpdateRunSettingsNode(" ", "data")); - } + [TestMethod] + public void UpdateRunSettingsNodeShouldThrowExceptionIfKeyIsNull() + { + Assert.ThrowsException(() => + _runSettingsProvider.UpdateRunSettingsNode(null, "data")); + } - [TestMethod] - public void UpdateRunSettingsNodeShouldThrowExceptionIfDataIsNull() - { - Assert.ThrowsException(() => - this.runSettingsProvider.UpdateRunSettingsNode("Key", null)); - } + [TestMethod] + public void UpdateRunSettingsNodeShouldThrowExceptionIfKeyIsEmptyOrWhiteSpace() + { + Assert.ThrowsException(() => + _runSettingsProvider.UpdateRunSettingsNode(" ", "data")); + } - [TestMethod] - public void UpdateRunSettingsNodeShouldThrowExceptionIfRunSettingsProviderIsNull() - { - Assert.ThrowsException(() => - RunSettingsProviderExtensions.UpdateRunSettingsNode(null, "Key", "data")); - } + [TestMethod] + public void UpdateRunSettingsNodeShouldThrowExceptionIfDataIsNull() + { + Assert.ThrowsException(() => + _runSettingsProvider.UpdateRunSettingsNode("Key", null)); + } - [TestMethod] - public void UpdateRunSettingsNodeShouldAddNewKeyIfNotPresent() - { - this.runSettingsProvider.UpdateRunSettings( - " "); - this.runSettingsProvider.UpdateRunSettingsNode("Key.Path", "data"); + [TestMethod] + public void UpdateRunSettingsNodeShouldThrowExceptionIfRunSettingsProviderIsNull() + { + Assert.ThrowsException(() => + RunSettingsProviderExtensions.UpdateRunSettingsNode(null, "Key", "data")); + } - Assert.AreEqual("data", this.runSettingsProvider.QueryRunSettingsNode("Key.Path")); - } + [TestMethod] + public void UpdateRunSettingsNodeShouldAddNewKeyIfNotPresent() + { + _runSettingsProvider.UpdateRunSettings( + " "); + _runSettingsProvider.UpdateRunSettingsNode("Key.Path", "data"); - [TestMethod] - public void UpdateTestRunParameterSettingsNodeShouldAddNewKeyIfNotPresent() - { - this.CheckRunSettingsAreUpdated("weburl", @"http://localhost//abc"); - } + Assert.AreEqual("data", _runSettingsProvider.QueryRunSettingsNode("Key.Path")); + } - [TestMethod] - public void UpdateTetsRunParameterSettingsNodeShouldOverrideValueIfKeyIsAlreadyPresent() - { - var runSettingsWithTestRunParameters = string.Join(Environment.NewLine, - "", - "", - " ", - " ", - " ", - ""); - var runSettingsWithTestRunParametersOverrode = string.Join(Environment.NewLine, - "", - "", - " ", - " ", - " ", - ""); - - this.runSettingsProvider.UpdateRunSettings(runSettingsWithTestRunParameters); - var match = this.runSettingsProvider.GetTestRunParameterNodeMatch( - "TestRunParameters.Parameter(name=\"weburl\",value=\"http://localhost//def\")"); - this.runSettingsProvider.UpdateTestRunParameterSettingsNode(match); - - Assert.AreEqual(runSettingsWithTestRunParametersOverrode, - this.runSettingsProvider.ActiveRunSettings.SettingsXml); - } + [TestMethod] + public void UpdateTestRunParameterSettingsNodeShouldAddNewKeyIfNotPresent() + { + CheckRunSettingsAreUpdated("weburl", @"http://localhost//abc"); + } - [TestMethod] - public void TestRunParameterSettingsNodeCanContainSpecialCharacters() - { - this.CheckRunSettingsAreUpdated("weburl:name", @"http://localhost//abc"); - } + [TestMethod] + public void UpdateTetsRunParameterSettingsNodeShouldOverrideValueIfKeyIsAlreadyPresent() + { + var runSettingsWithTestRunParameters = string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + ""); + var runSettingsWithTestRunParametersOverrode = string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + ""); + + _runSettingsProvider.UpdateRunSettings(runSettingsWithTestRunParameters); + var match = _runSettingsProvider.GetTestRunParameterNodeMatch( + "TestRunParameters.Parameter(name=\"weburl\",value=\"http://localhost//def\")"); + _runSettingsProvider.UpdateTestRunParameterSettingsNode(match); + + Assert.AreEqual(runSettingsWithTestRunParametersOverrode, + _runSettingsProvider.ActiveRunSettings.SettingsXml); + } - [TestMethod] - public void TestRunParameterSettingsNodeCanBeJustASingleCharacter() - { - this.CheckRunSettingsAreUpdated("a", @"http://localhost//abc"); - } + [TestMethod] + public void TestRunParameterSettingsNodeCanContainSpecialCharacters() + { + CheckRunSettingsAreUpdated("weburl:name", @"http://localhost//abc"); + } - [TestMethod] - public void TestRunParameterSettingsNodeCanMixSpecialCharacters() - { - this.CheckRunSettingsAreUpdated("___this_Should:be-valid.2", @"http://localhost//abc"); - } + [TestMethod] + public void TestRunParameterSettingsNodeCanBeJustASingleCharacter() + { + CheckRunSettingsAreUpdated("a", @"http://localhost//abc"); + } - [TestMethod] - public void UpdateRunSettingsNodeShouldUpdateKeyIfAlreadyPresent() - { - this.runSettingsProvider.UpdateRunSettings( - " 1 "); - this.runSettingsProvider.UpdateRunSettingsNode("RunConfiguration.MaxCpuCount", "0"); - Assert.AreEqual("0", this.runSettingsProvider.QueryRunSettingsNode("RunConfiguration.MaxCpuCount")); - } + [TestMethod] + public void TestRunParameterSettingsNodeCanMixSpecialCharacters() + { + CheckRunSettingsAreUpdated("___this_Should:be-valid.2", @"http://localhost//abc"); + } - [TestMethod] - public void UpdateRunSettingsNodeInnerXmlShouldThrowExceptionIfKeyIsNull() - { - Assert.ThrowsException(() => - this.runSettingsProvider.UpdateRunSettingsNodeInnerXml(null, "")); - } + [TestMethod] + public void UpdateRunSettingsNodeShouldUpdateKeyIfAlreadyPresent() + { + _runSettingsProvider.UpdateRunSettings( + " 1 "); + _runSettingsProvider.UpdateRunSettingsNode("RunConfiguration.MaxCpuCount", "0"); + Assert.AreEqual("0", _runSettingsProvider.QueryRunSettingsNode("RunConfiguration.MaxCpuCount")); + } - [TestMethod] - public void UpdateRunSettingsNodeInnerXmlShouldThrowExceptionIfKeyIsEmptyOrWhiteSpace() - { - Assert.ThrowsException(() => - this.runSettingsProvider.UpdateRunSettingsNodeInnerXml(" ", "")); - } + [TestMethod] + public void UpdateRunSettingsNodeInnerXmlShouldThrowExceptionIfKeyIsNull() + { + Assert.ThrowsException(() => + _runSettingsProvider.UpdateRunSettingsNodeInnerXml(null, "")); + } - [TestMethod] - public void UpdateRunSettingsNodeInnerXmlShouldThrowExceptionIfXmlIsNull() - { - Assert.ThrowsException(() => - this.runSettingsProvider.UpdateRunSettingsNodeInnerXml("Key", null)); - } + [TestMethod] + public void UpdateRunSettingsNodeInnerXmlShouldThrowExceptionIfKeyIsEmptyOrWhiteSpace() + { + Assert.ThrowsException(() => + _runSettingsProvider.UpdateRunSettingsNodeInnerXml(" ", "")); + } - [TestMethod] - public void UpdateRunSettingsNodeInnerXmlShouldThrowExceptionIfRunSettingsProviderIsNull() - { - Assert.ThrowsException(() => - RunSettingsProviderExtensions.UpdateRunSettingsNodeInnerXml(null, "Key", "")); - } + [TestMethod] + public void UpdateRunSettingsNodeInnerXmlShouldThrowExceptionIfXmlIsNull() + { + Assert.ThrowsException(() => + _runSettingsProvider.UpdateRunSettingsNodeInnerXml("Key", null)); + } - [TestMethod] - public void UpdateRunSettingsNodeInnerXmlShouldAddNewKeyIfNotPresent() - { - this.runSettingsProvider.UpdateRunSettings( - " "); - this.runSettingsProvider.UpdateRunSettingsNodeInnerXml("Key.Path", "myxml"); + [TestMethod] + public void UpdateRunSettingsNodeInnerXmlShouldThrowExceptionIfRunSettingsProviderIsNull() + { + Assert.ThrowsException(() => + RunSettingsProviderExtensions.UpdateRunSettingsNodeInnerXml(null, "Key", "")); + } - Assert.AreEqual("myxml", this.runSettingsProvider.QueryRunSettingsNode("Key.Path")); - } + [TestMethod] + public void UpdateRunSettingsNodeInnerXmlShouldAddNewKeyIfNotPresent() + { + _runSettingsProvider.UpdateRunSettings( + " "); + _runSettingsProvider.UpdateRunSettingsNodeInnerXml("Key.Path", "myxml"); - [TestMethod] - public void UpdateRunSettingsNodeInnerXmlShouldUpdateKeyIfAlreadyPresent() - { - this.runSettingsProvider.UpdateRunSettings( - " 1 "); - this.runSettingsProvider.UpdateRunSettingsNodeInnerXml("RunConfiguration", "0"); - Assert.AreEqual("0", this.runSettingsProvider.QueryRunSettingsNode("RunConfiguration.MaxCpuCount")); - } + Assert.AreEqual("myxml", _runSettingsProvider.QueryRunSettingsNode("Key.Path")); + } - [TestMethod] - public void QueryRunSettingsNodeShouldThrowIfKeyIsNull() - { - Assert.ThrowsException(() => this.runSettingsProvider.QueryRunSettingsNode(null)); - } + [TestMethod] + public void UpdateRunSettingsNodeInnerXmlShouldUpdateKeyIfAlreadyPresent() + { + _runSettingsProvider.UpdateRunSettings( + " 1 "); + _runSettingsProvider.UpdateRunSettingsNodeInnerXml("RunConfiguration", "0"); + Assert.AreEqual("0", _runSettingsProvider.QueryRunSettingsNode("RunConfiguration.MaxCpuCount")); + } - [TestMethod] - public void QueryRunSettingsNodeShouldThrowIfKeyIsEmptyOrWhiteSpace() - { - Assert.ThrowsException(() => this.runSettingsProvider.QueryRunSettingsNode(" ")); - } + [TestMethod] + public void QueryRunSettingsNodeShouldThrowIfKeyIsNull() + { + Assert.ThrowsException(() => _runSettingsProvider.QueryRunSettingsNode(null)); + } - [TestMethod] - public void QueryRunSettingsNodeShouldReturnNullForNotExistKey() - { - Assert.IsNull(this.runSettingsProvider.QueryRunSettingsNode("RunConfiguration.TargetPlatform")); - } + [TestMethod] + public void QueryRunSettingsNodeShouldThrowIfKeyIsEmptyOrWhiteSpace() + { + Assert.ThrowsException(() => _runSettingsProvider.QueryRunSettingsNode(" ")); + } - [TestMethod] - public void QueryRunSettingsNodeShouldReturnCorrectValue() - { - this.runSettingsProvider.UpdateRunSettings( - " x86 "); - Assert.AreEqual("x86", this.runSettingsProvider.QueryRunSettingsNode("RunConfiguration.TargetPlatform")); - } + [TestMethod] + public void QueryRunSettingsNodeShouldReturnNullForNotExistKey() + { + Assert.IsNull(_runSettingsProvider.QueryRunSettingsNode("RunConfiguration.TargetPlatform")); + } - private void CheckRunSettingsAreUpdated(string parameterName, string parameterValue) - { - var match = this.runSettingsProvider.GetTestRunParameterNodeMatch( - $@"TestRunParameters.Parameter(name=""{parameterName}"",value=""{parameterValue}"")"); - var runSettingsWithTestRunParameters = string.Join( - Environment.NewLine, - $@"", - $@"", - $@" ", - $@" ", - $@" ", - $@""); - - this.runSettingsProvider.UpdateRunSettings("\r\n "); - this.runSettingsProvider.UpdateTestRunParameterSettingsNode(match); - - Assert.AreEqual(runSettingsWithTestRunParameters, this.runSettingsProvider.ActiveRunSettings.SettingsXml); - } + [TestMethod] + public void QueryRunSettingsNodeShouldReturnCorrectValue() + { + _runSettingsProvider.UpdateRunSettings( + " x86 "); + Assert.AreEqual("x86", _runSettingsProvider.QueryRunSettingsNode("RunConfiguration.TargetPlatform")); + } - private class TestableRunSettingsProvider : IRunSettingsProvider - { - public RunSettings ActiveRunSettings { get; set; } + private void CheckRunSettingsAreUpdated(string parameterName, string parameterValue) + { + var match = _runSettingsProvider.GetTestRunParameterNodeMatch( + $@"TestRunParameters.Parameter(name=""{parameterName}"",value=""{parameterValue}"")"); + var runSettingsWithTestRunParameters = string.Join( + Environment.NewLine, + $@"", + $@"", + $@" ", + $@" ", + $@" ", + $@""); + + _runSettingsProvider.UpdateRunSettings("\r\n "); + _runSettingsProvider.UpdateTestRunParameterSettingsNode(match); + + Assert.AreEqual(runSettingsWithTestRunParameters, _runSettingsProvider.ActiveRunSettings.SettingsXml); + } + + private class TestableRunSettingsProvider : IRunSettingsProvider + { + public RunSettings ActiveRunSettings { get; set; } - public void SetActiveRunSettings(RunSettings runSettings) - { - this.ActiveRunSettings = runSettings; - } + public void SetActiveRunSettings(RunSettings runSettings) + { + ActiveRunSettings = runSettings; } } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestDiscovererPluginInformationTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestDiscovererPluginInformationTests.cs index 2ff6af44c3..937ed2bcb5 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestDiscovererPluginInformationTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestDiscovererPluginInformationTests.cs @@ -1,197 +1,196 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.ExtensionFramework.Utilities +namespace TestPlatform.Common.UnitTests.ExtensionFramework.Utilities; + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; + +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class TestDiscovererPluginInformationTests { - using System; - using System.Collections.Generic; - using System.ComponentModel; - using System.Linq; - - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class TestDiscovererPluginInformationTests + private TestDiscovererPluginInformation _testPluginInformation; + + [TestMethod] + public void AssemblyQualifiedNameShouldReturnTestExtensionTypesName() + { + _testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovererWithNoFileExtensions)); + Assert.AreEqual(typeof(DummyTestDiscovererWithNoFileExtensions).AssemblyQualifiedName, _testPluginInformation.AssemblyQualifiedName); + } + + [TestMethod] + public void IdentifierDataShouldReturnTestExtensionTypesName() + { + _testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovererWithNoFileExtensions)); + Assert.AreEqual(typeof(DummyTestDiscovererWithNoFileExtensions).AssemblyQualifiedName, _testPluginInformation.IdentifierData); + } + + [TestMethod] + public void FileExtensionsShouldReturnEmptyListIfADiscovererSupportsNoFileExtensions() + { + _testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovererWithNoFileExtensions)); + Assert.IsNotNull(_testPluginInformation.FileExtensions); + Assert.AreEqual(0, _testPluginInformation.FileExtensions.Count); + } + + [TestMethod] + public void FileExtensionsShouldReturnAFileExtensionForADiscoverer() { - private TestDiscovererPluginInformation testPluginInformation; - - [TestMethod] - public void AssemblyQualifiedNameShouldReturnTestExtensionTypesName() - { - this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovererWithNoFileExtensions)); - Assert.AreEqual(typeof(DummyTestDiscovererWithNoFileExtensions).AssemblyQualifiedName, this.testPluginInformation.AssemblyQualifiedName); - } - - [TestMethod] - public void IdentifierDataShouldReturnTestExtensionTypesName() - { - this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovererWithNoFileExtensions)); - Assert.AreEqual(typeof(DummyTestDiscovererWithNoFileExtensions).AssemblyQualifiedName, this.testPluginInformation.IdentifierData); - } - - [TestMethod] - public void FileExtensionsShouldReturnEmptyListIfADiscovererSupportsNoFileExtensions() - { - this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovererWithNoFileExtensions)); - Assert.IsNotNull(this.testPluginInformation.FileExtensions); - Assert.AreEqual(0, this.testPluginInformation.FileExtensions.Count); - } - - [TestMethod] - public void FileExtensionsShouldReturnAFileExtensionForADiscoverer() - { - this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovererWithOneFileExtensions)); - CollectionAssert.AreEqual(new List { "csv"}, this.testPluginInformation.FileExtensions); - } - - [TestMethod] - public void FileExtensionsShouldReturnSupportedFileExtensionsForADiscoverer() - { - this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovererWithTwoFileExtensions)); - CollectionAssert.AreEqual(new List {"csv", "docx"}, this.testPluginInformation.FileExtensions); - } - - [TestMethod] - public void AssemblyTypeShouldReturnNoneIfDiscovererHasNoCategory() - { - this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithNoCategory)); - Assert.AreEqual(AssemblyType.None, this.testPluginInformation.AssemblyType); - } - - [TestMethod] - public void AssemblyTypeShouldReturnNoneIfDiscovererHasCategoryWithNoValue() - { - this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithCategoryHavingNoValue)); - Assert.AreEqual(AssemblyType.None, this.testPluginInformation.AssemblyType); - } - - [TestMethod] - public void AssemblyTypeShouldReturnNoneIfDiscovererHasCategoryWithEmptyValue() - { - this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithCategoryHavingEmptyValue)); - Assert.AreEqual(AssemblyType.None, this.testPluginInformation.AssemblyType); - } - - [TestMethod] - public void AssemblyTypeShouldReturnNativeIfDiscovererHasNativeCategory() - { - this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithNativeCategory)); - Assert.AreEqual(AssemblyType.Native, this.testPluginInformation.AssemblyType); - } - - [TestMethod] - public void AssemblyTypeShouldReturnManagedIfDiscovererHasManagedCategory() - { - this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithManagedCategory)); - Assert.AreEqual(AssemblyType.Managed, this.testPluginInformation.AssemblyType); - } - - [TestMethod] - public void AssemblyTypeShouldReturnNoneIfDiscovererHasUnknownCategory() - { - this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithUnknownCategory)); - Assert.AreEqual(AssemblyType.None, this.testPluginInformation.AssemblyType); - } - - [TestMethod] - public void AssemblyTypeShouldReturnAssemblyTypeIfDiscovererHasCategoryInArbitCasing() - { - this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithArbitCasedCategory)); - Assert.AreEqual(AssemblyType.Native, this.testPluginInformation.AssemblyType); - } - - [TestMethod] - public void DefaultExecutorUriShouldReturnEmptyListIfADiscovererDoesNotHaveOne() - { - this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovererWithNoFileExtensions)); - Assert.IsNotNull(this.testPluginInformation.DefaultExecutorUri); - Assert.AreEqual(string.Empty, this.testPluginInformation.DefaultExecutorUri); - } - - [TestMethod] - public void DefaultExecutorUriShouldReturnDefaultExecutorUriOfADiscoverer() - { - this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovererWithOneFileExtensions)); - Assert.AreEqual("csvexecutor", this.testPluginInformation.DefaultExecutorUri); - } - - [TestMethod] - public void MetadataShouldReturnFileExtensionsAndDefaultExecutorUriAndAssemblyType() - { - this.testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovererWithTwoFileExtensions)); - - var expectedFileExtensions = new List { "csv", "docx" }; - var testPluginMetada = this.testPluginInformation.Metadata.ToArray(); - - CollectionAssert.AreEqual(expectedFileExtensions, (testPluginMetada[0] as List).ToArray()); - Assert.AreEqual("csvexecutor", testPluginMetada[1] as string); - Assert.AreEqual(AssemblyType.Managed, Enum.Parse(typeof(AssemblyType), testPluginMetada[2].ToString())); - } + _testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovererWithOneFileExtensions)); + CollectionAssert.AreEqual(new List { "csv" }, _testPluginInformation.FileExtensions); } - #region Implementation + [TestMethod] + public void FileExtensionsShouldReturnSupportedFileExtensionsForADiscoverer() + { + _testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovererWithTwoFileExtensions)); + CollectionAssert.AreEqual(new List { "csv", "docx" }, _testPluginInformation.FileExtensions); + } - public class DummyTestDiscovererWithNoFileExtensions + [TestMethod] + public void AssemblyTypeShouldReturnNoneIfDiscovererHasNoCategory() { + _testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithNoCategory)); + Assert.AreEqual(AssemblyType.None, _testPluginInformation.AssemblyType); } - [FileExtension(".dll")] - public class DummyTestDiscovereWithNoCategory + [TestMethod] + public void AssemblyTypeShouldReturnNoneIfDiscovererHasCategoryWithNoValue() { + _testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithCategoryHavingNoValue)); + Assert.AreEqual(AssemblyType.None, _testPluginInformation.AssemblyType); } - [FileExtension(".dll")] - [Category] - public class DummyTestDiscovereWithCategoryHavingNoValue + [TestMethod] + public void AssemblyTypeShouldReturnNoneIfDiscovererHasCategoryWithEmptyValue() { + _testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithCategoryHavingEmptyValue)); + Assert.AreEqual(AssemblyType.None, _testPluginInformation.AssemblyType); } - [FileExtension(".dll")] - [Category] - public class DummyTestDiscovereWithCategoryHavingEmptyValue + [TestMethod] + public void AssemblyTypeShouldReturnNativeIfDiscovererHasNativeCategory() { + _testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithNativeCategory)); + Assert.AreEqual(AssemblyType.Native, _testPluginInformation.AssemblyType); } - [FileExtension(".js")] - [Category("native")] - public class DummyTestDiscovereWithNativeCategory + [TestMethod] + public void AssemblyTypeShouldReturnManagedIfDiscovererHasManagedCategory() { + _testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithManagedCategory)); + Assert.AreEqual(AssemblyType.Managed, _testPluginInformation.AssemblyType); } - [FileExtension(".dll")] - [Category("managed")] - public class DummyTestDiscovereWithManagedCategory + [TestMethod] + public void AssemblyTypeShouldReturnNoneIfDiscovererHasUnknownCategory() { + _testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithUnknownCategory)); + Assert.AreEqual(AssemblyType.None, _testPluginInformation.AssemblyType); } - [FileExtension(".dll")] - [Category("arbitValue")] - public class DummyTestDiscovereWithUnknownCategory + [TestMethod] + public void AssemblyTypeShouldReturnAssemblyTypeIfDiscovererHasCategoryInArbitCasing() { + _testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovereWithArbitCasedCategory)); + Assert.AreEqual(AssemblyType.Native, _testPluginInformation.AssemblyType); } - [FileExtension(".dll")] - [Category("NatIVe")] - public class DummyTestDiscovereWithArbitCasedCategory + [TestMethod] + public void DefaultExecutorUriShouldReturnEmptyListIfADiscovererDoesNotHaveOne() { + _testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovererWithNoFileExtensions)); + Assert.IsNotNull(_testPluginInformation.DefaultExecutorUri); + Assert.AreEqual(string.Empty, _testPluginInformation.DefaultExecutorUri); } - [FileExtension("csv")] - [DefaultExecutorUri("csvexecutor")] - public class DummyTestDiscovererWithOneFileExtensions + [TestMethod] + public void DefaultExecutorUriShouldReturnDefaultExecutorUriOfADiscoverer() { + _testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovererWithOneFileExtensions)); + Assert.AreEqual("csvexecutor", _testPluginInformation.DefaultExecutorUri); } - [FileExtension("csv")] - [FileExtension("docx")] - [Category("managed")] - [DefaultExecutorUri("csvexecutor")] - public class DummyTestDiscovererWithTwoFileExtensions + [TestMethod] + public void MetadataShouldReturnFileExtensionsAndDefaultExecutorUriAndAssemblyType() { + _testPluginInformation = new TestDiscovererPluginInformation(typeof(DummyTestDiscovererWithTwoFileExtensions)); + + var expectedFileExtensions = new List { "csv", "docx" }; + var testPluginMetada = _testPluginInformation.Metadata.ToArray(); + + CollectionAssert.AreEqual(expectedFileExtensions, (testPluginMetada[0] as List).ToArray()); + Assert.AreEqual("csvexecutor", testPluginMetada[1] as string); + Assert.AreEqual(AssemblyType.Managed, Enum.Parse(typeof(AssemblyType), testPluginMetada[2].ToString())); } +} + +#region Implementation + +public class DummyTestDiscovererWithNoFileExtensions +{ +} + +[FileExtension(".dll")] +public class DummyTestDiscovereWithNoCategory +{ +} + +[FileExtension(".dll")] +[Category] +public class DummyTestDiscovereWithCategoryHavingNoValue +{ +} + +[FileExtension(".dll")] +[Category] +public class DummyTestDiscovereWithCategoryHavingEmptyValue +{ +} + +[FileExtension(".js")] +[Category("native")] +public class DummyTestDiscovereWithNativeCategory +{ +} + +[FileExtension(".dll")] +[Category("managed")] +public class DummyTestDiscovereWithManagedCategory +{ +} + +[FileExtension(".dll")] +[Category("arbitValue")] +public class DummyTestDiscovereWithUnknownCategory +{ +} + +[FileExtension(".dll")] +[Category("NatIVe")] +public class DummyTestDiscovereWithArbitCasedCategory +{ +} + +[FileExtension("csv")] +[DefaultExecutorUri("csvexecutor")] +public class DummyTestDiscovererWithOneFileExtensions +{ +} - #endregion +[FileExtension("csv")] +[FileExtension("docx")] +[Category("managed")] +[DefaultExecutorUri("csvexecutor")] +public class DummyTestDiscovererWithTwoFileExtensions +{ } + +#endregion \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestExtensionPluginInformationTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestExtensionPluginInformationTests.cs index 357f6c2f23..0d55f3ad89 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestExtensionPluginInformationTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestExtensionPluginInformationTests.cs @@ -1,77 +1,76 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.ExtensionFramework.Utilities -{ - using System; - using System.Linq; +namespace TestPlatform.Common.UnitTests.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Linq; - [TestClass] - public class TestExtensionPluginInformationTests - { - private TestableTestExtensionPluginInformation testPluginInformation; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestTools.UnitTesting; - internal const string DefaultExtensionURI = "executor://unittest"; +[TestClass] +public class TestExtensionPluginInformationTests +{ + private TestableTestExtensionPluginInformation _testPluginInformation; - [TestMethod] - public void AssemblyQualifiedNameShouldReturnTestExtensionTypesName() - { - this.testPluginInformation = new TestableTestExtensionPluginInformation(typeof(DummyTestExtensionWithNoExtensionUri)); - Assert.AreEqual(typeof(DummyTestExtensionWithNoExtensionUri).AssemblyQualifiedName, this.testPluginInformation.AssemblyQualifiedName); - } + internal const string DefaultExtensionUri = "executor://unittest"; - [TestMethod] - public void IdentifierDataShouldReturnExtensionUri() - { - this.testPluginInformation = new TestableTestExtensionPluginInformation(typeof(DummyTestExtensionWithExtensionUri)); - Assert.AreEqual(DefaultExtensionURI, this.testPluginInformation.IdentifierData); - } + [TestMethod] + public void AssemblyQualifiedNameShouldReturnTestExtensionTypesName() + { + _testPluginInformation = new TestableTestExtensionPluginInformation(typeof(DummyTestExtensionWithNoExtensionUri)); + Assert.AreEqual(typeof(DummyTestExtensionWithNoExtensionUri).AssemblyQualifiedName, _testPluginInformation.AssemblyQualifiedName); + } - [TestMethod] - public void ExtensionUriShouldReturnEmptyIfAnExtensionDoesNotHaveOne() - { - this.testPluginInformation = new TestableTestExtensionPluginInformation(typeof(DummyTestExtensionWithNoExtensionUri)); - Assert.IsNotNull(this.testPluginInformation.ExtensionUri); - Assert.AreEqual(string.Empty, this.testPluginInformation.ExtensionUri); - } + [TestMethod] + public void IdentifierDataShouldReturnExtensionUri() + { + _testPluginInformation = new TestableTestExtensionPluginInformation(typeof(DummyTestExtensionWithExtensionUri)); + Assert.AreEqual(DefaultExtensionUri, _testPluginInformation.IdentifierData); + } - [TestMethod] - public void ExtensionUriShouldReturnExtensionUriOfAnExtension() - { - this.testPluginInformation = new TestableTestExtensionPluginInformation(typeof(DummyTestExtensionWithExtensionUri)); - Assert.AreEqual(DefaultExtensionURI, this.testPluginInformation.ExtensionUri); - } + [TestMethod] + public void ExtensionUriShouldReturnEmptyIfAnExtensionDoesNotHaveOne() + { + _testPluginInformation = new TestableTestExtensionPluginInformation(typeof(DummyTestExtensionWithNoExtensionUri)); + Assert.IsNotNull(_testPluginInformation.ExtensionUri); + Assert.AreEqual(string.Empty, _testPluginInformation.ExtensionUri); + } - [TestMethod] - public void MetadataShouldReturnExtensionUri() - { - this.testPluginInformation = new TestableTestExtensionPluginInformation(typeof(DummyTestExtensionWithExtensionUri)); + [TestMethod] + public void ExtensionUriShouldReturnExtensionUriOfAnExtension() + { + _testPluginInformation = new TestableTestExtensionPluginInformation(typeof(DummyTestExtensionWithExtensionUri)); + Assert.AreEqual(DefaultExtensionUri, _testPluginInformation.ExtensionUri); + } - CollectionAssert.AreEqual(new object[] { DefaultExtensionURI }, this.testPluginInformation.Metadata.ToArray()); - } + [TestMethod] + public void MetadataShouldReturnExtensionUri() + { + _testPluginInformation = new TestableTestExtensionPluginInformation(typeof(DummyTestExtensionWithExtensionUri)); - #region Implementation + CollectionAssert.AreEqual(new object[] { DefaultExtensionUri }, _testPluginInformation.Metadata.ToArray()); + } - private class TestableTestExtensionPluginInformation : TestExtensionPluginInformation - { - public TestableTestExtensionPluginInformation(Type testExtensionType) : base(testExtensionType) - { - } - } + #region Implementation - private class DummyTestExtensionWithNoExtensionUri + private class TestableTestExtensionPluginInformation : TestExtensionPluginInformation + { + public TestableTestExtensionPluginInformation(Type testExtensionType) : base(testExtensionType) { } + } - [ExtensionUri(TestExtensionPluginInformationTests.DefaultExtensionURI)] - private class DummyTestExtensionWithExtensionUri - { - } + private class DummyTestExtensionWithNoExtensionUri + { + } - #endregion + [ExtensionUri(DefaultExtensionUri)] + private class DummyTestExtensionWithExtensionUri + { } -} + + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestExtensionsTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestExtensionsTests.cs index 4525781aca..7ed649189a 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestExtensionsTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestExtensionsTests.cs @@ -1,207 +1,240 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.ExtensionFramework.Utilities -{ - using System.Collections.Generic; +namespace TestPlatform.Common.UnitTests.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System.Reflection; +using System.Collections.Generic; - [TestClass] - public class TestExtensionsTests - { - private TestExtensions testExtensions; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Reflection; - [TestInitialize] - public void TestInit() - { - this.testExtensions = new TestExtensions(); - } +[TestClass] +public class TestExtensionsTests +{ + private TestExtensions _testExtensions; - [TestMethod] - public void AddExtensionsShouldNotThrowIfExtensionsIsNull() - { - this.testExtensions.AddExtension(null); + [TestInitialize] + public void TestInit() + { + _testExtensions = new TestExtensions(); + } - // Validate that the default state does not change. - Assert.IsNull(this.testExtensions.TestDiscoverers); - } + [TestMethod] + public void AddExtensionsShouldNotThrowIfExtensionsIsNull() + { + _testExtensions.AddExtension(null); - [TestMethod] - public void AddExtensionsShouldNotThrowIfExistingExtensionCollectionIsNull() - { - var testDiscoverers = new System.Collections.Generic.Dictionary(); + // Validate that the default state does not change. + Assert.IsNull(_testExtensions.TestDiscoverers); + } - testDiscoverers.Add( + [TestMethod] + public void AddExtensionsShouldNotThrowIfExistingExtensionCollectionIsNull() + { + var testDiscoverers = new Dictionary + { + { "td", - new TestDiscovererPluginInformation(typeof(TestExtensionsTests))); + new TestDiscovererPluginInformation(typeof(TestExtensionsTests)) + } + }; - this.testExtensions.AddExtension(testDiscoverers); + _testExtensions.AddExtension(testDiscoverers); - Assert.IsNotNull(this.testExtensions.TestDiscoverers); - CollectionAssert.AreEqual(this.testExtensions.TestDiscoverers, testDiscoverers); + Assert.IsNotNull(_testExtensions.TestDiscoverers); + CollectionAssert.AreEqual(_testExtensions.TestDiscoverers, testDiscoverers); - // Validate that the others remain same. - Assert.IsNull(this.testExtensions.TestExecutors); - Assert.IsNull(this.testExtensions.TestSettingsProviders); - Assert.IsNull(this.testExtensions.TestLoggers); - } + // Validate that the others remain same. + Assert.IsNull(_testExtensions.TestExecutors); + Assert.IsNull(_testExtensions.TestSettingsProviders); + Assert.IsNull(_testExtensions.TestLoggers); + } - [TestMethod] - public void AddExtensionsShouldAddToExistingExtensionCollection() + [TestMethod] + public void AddExtensionsShouldAddToExistingExtensionCollection() + { + var testDiscoverers = new Dictionary { - var testDiscoverers = new System.Collections.Generic.Dictionary(); - - testDiscoverers.Add("td1", new TestDiscovererPluginInformation(typeof(TestExtensionsTests))); - testDiscoverers.Add("td2", new TestDiscovererPluginInformation(typeof(TestExtensionsTests))); + { "td1", new TestDiscovererPluginInformation(typeof(TestExtensionsTests)) }, + { "td2", new TestDiscovererPluginInformation(typeof(TestExtensionsTests)) } + }; - this.testExtensions.TestDiscoverers = new Dictionary(); - this.testExtensions.TestDiscoverers.Add("td", new TestDiscovererPluginInformation(typeof(TestExtensionsTests))); + _testExtensions.TestDiscoverers = new Dictionary + { + { "td", new TestDiscovererPluginInformation(typeof(TestExtensionsTests)) } + }; - // Act. - this.testExtensions.AddExtension(testDiscoverers); + // Act. + _testExtensions.AddExtension(testDiscoverers); - // Validate. - var expectedTestExtensions = new Dictionary(); - expectedTestExtensions.Add("td", new TestDiscovererPluginInformation(typeof(TestExtensionsTests))); - expectedTestExtensions.Add("td1", new TestDiscovererPluginInformation(typeof(TestExtensionsTests))); - expectedTestExtensions.Add("td2", new TestDiscovererPluginInformation(typeof(TestExtensionsTests))); + // Validate. + var expectedTestExtensions = new Dictionary + { + { "td", new TestDiscovererPluginInformation(typeof(TestExtensionsTests)) }, + { "td1", new TestDiscovererPluginInformation(typeof(TestExtensionsTests)) }, + { "td2", new TestDiscovererPluginInformation(typeof(TestExtensionsTests)) } + }; - CollectionAssert.AreEqual(this.testExtensions.TestDiscoverers.Keys, expectedTestExtensions.Keys); + CollectionAssert.AreEqual(_testExtensions.TestDiscoverers.Keys, expectedTestExtensions.Keys); - // Validate that the others remain same. - Assert.IsNull(this.testExtensions.TestExecutors); - Assert.IsNull(this.testExtensions.TestSettingsProviders); - Assert.IsNull(this.testExtensions.TestLoggers); - } + // Validate that the others remain same. + Assert.IsNull(_testExtensions.TestExecutors); + Assert.IsNull(_testExtensions.TestSettingsProviders); + Assert.IsNull(_testExtensions.TestLoggers); + } - [TestMethod] - public void AddExtensionsShouldNotAddAnAlreadyExistingExtensionToTheCollection() + [TestMethod] + public void AddExtensionsShouldNotAddAnAlreadyExistingExtensionToTheCollection() + { + var testDiscoverers = new Dictionary { - var testDiscoverers = new System.Collections.Generic.Dictionary(); - - testDiscoverers.Add("td", new TestDiscovererPluginInformation(typeof(TestExtensionsTests))); - - this.testExtensions.TestDiscoverers = new System.Collections.Generic.Dictionary(); + { "td", new TestDiscovererPluginInformation(typeof(TestExtensionsTests)) } + }; - this.testExtensions.TestDiscoverers.Add("td", new TestDiscovererPluginInformation(typeof(TestExtensionsTests))); + _testExtensions.TestDiscoverers = new Dictionary + { + { "td", new TestDiscovererPluginInformation(typeof(TestExtensionsTests)) } + }; - // Act. - this.testExtensions.AddExtension(testDiscoverers); + // Act. + _testExtensions.AddExtension(testDiscoverers); - // Validate. - CollectionAssert.AreEqual(this.testExtensions.TestDiscoverers.Keys, testDiscoverers.Keys); + // Validate. + CollectionAssert.AreEqual(_testExtensions.TestDiscoverers.Keys, testDiscoverers.Keys); - // Validate that the others remain same. - Assert.IsNull(this.testExtensions.TestExecutors); - Assert.IsNull(this.testExtensions.TestSettingsProviders); - Assert.IsNull(this.testExtensions.TestLoggers); - } + // Validate that the others remain same. + Assert.IsNull(_testExtensions.TestExecutors); + Assert.IsNull(_testExtensions.TestSettingsProviders); + Assert.IsNull(_testExtensions.TestLoggers); + } - [TestMethod] - public void GetExtensionsDiscoveredFromAssemblyShouldReturnNullIfNoExtensionsPresent() - { - var assemblyLocation = typeof(TestExtensionsTests).GetTypeInfo().Assembly.Location; + [TestMethod] + public void GetExtensionsDiscoveredFromAssemblyShouldReturnNullIfNoExtensionsPresent() + { + var assemblyLocation = typeof(TestExtensionsTests).GetTypeInfo().Assembly.Location; - Assert.IsNull(this.testExtensions.GetExtensionsDiscoveredFromAssembly(assemblyLocation)); - } + Assert.IsNull(_testExtensions.GetExtensionsDiscoveredFromAssembly(assemblyLocation)); + } - [TestMethod] - public void GetExtensionsDiscoveredFromAssemblyShouldNotThrowIfExtensionAssemblyIsNull() + [TestMethod] + public void GetExtensionsDiscoveredFromAssemblyShouldNotThrowIfExtensionAssemblyIsNull() + { + _testExtensions.TestDiscoverers = new Dictionary { - this.testExtensions.TestDiscoverers = new Dictionary(); + { "td", new TestDiscovererPluginInformation(typeof(TestExtensionsTests)) } + }; - this.testExtensions.TestDiscoverers.Add("td", new TestDiscovererPluginInformation(typeof(TestExtensionsTests))); + Assert.IsNull(_testExtensions.GetExtensionsDiscoveredFromAssembly(null)); + } - Assert.IsNull(this.testExtensions.GetExtensionsDiscoveredFromAssembly(null)); - } + [TestMethod] + public void GetExtensionsDiscoveredFromAssemblyShouldReturnTestDiscoverers() + { + var assemblyLocation = typeof(TestExtensionsTests).GetTypeInfo().Assembly.Location; - [TestMethod] - public void GetExtensionsDiscoveredFromAssemblyShouldReturnTestDiscoverers() + _testExtensions.TestDiscoverers = new Dictionary { - var assemblyLocation = typeof(TestExtensionsTests).GetTypeInfo().Assembly.Location; + { "td", new TestDiscovererPluginInformation(typeof(TestExtensionsTests)) }, + { "td1", new TestDiscovererPluginInformation(typeof(TestExtensions)) } + }; - this.testExtensions.TestDiscoverers = new Dictionary(); - this.testExtensions.TestDiscoverers.Add("td", new TestDiscovererPluginInformation(typeof(TestExtensionsTests))); - this.testExtensions.TestDiscoverers.Add("td1", new TestDiscovererPluginInformation(typeof(TestExtensions))); + var extensions = _testExtensions.GetExtensionsDiscoveredFromAssembly(assemblyLocation); - var extensions = this.testExtensions.GetExtensionsDiscoveredFromAssembly(assemblyLocation); + var expectedExtensions = new Dictionary + { + { "td", new TestDiscovererPluginInformation(typeof(TestExtensionsTests)) } + }; + CollectionAssert.AreEqual(expectedExtensions.Keys, extensions.TestDiscoverers.Keys); + } - var expectedExtensions = new Dictionary(); - expectedExtensions.Add("td", new TestDiscovererPluginInformation(typeof(TestExtensionsTests))); - CollectionAssert.AreEqual(expectedExtensions.Keys, extensions.TestDiscoverers.Keys); - } + [TestMethod] + public void GetExtensionsDiscoveredFromAssemblyShouldReturnTestExecutors() + { + var assemblyLocation = typeof(TestExtensionsTests).GetTypeInfo().Assembly.Location; - [TestMethod] - public void GetExtensionsDiscoveredFromAssemblyShouldReturnTestExecutors() + _testExtensions.TestExecutors = new Dictionary { - var assemblyLocation = typeof(TestExtensionsTests).GetTypeInfo().Assembly.Location; + { "te", new TestExecutorPluginInformation(typeof(TestExtensionsTests)) }, + { "te1", new TestExecutorPluginInformation(typeof(TestExtensions)) } + }; - this.testExtensions.TestExecutors = new Dictionary(); - this.testExtensions.TestExecutors.Add("te", new TestExecutorPluginInformation(typeof(TestExtensionsTests))); - this.testExtensions.TestExecutors.Add("te1", new TestExecutorPluginInformation(typeof(TestExtensions))); + var extensions = _testExtensions.GetExtensionsDiscoveredFromAssembly(assemblyLocation); - var extensions = this.testExtensions.GetExtensionsDiscoveredFromAssembly(assemblyLocation); + var expectedExtensions = new Dictionary + { + { "te", new TestExecutorPluginInformation(typeof(TestExtensionsTests)) } + }; + CollectionAssert.AreEqual(expectedExtensions.Keys, extensions.TestExecutors.Keys); + } - var expectedExtensions = new Dictionary(); - expectedExtensions.Add("te", new TestExecutorPluginInformation(typeof(TestExtensionsTests))); - CollectionAssert.AreEqual(expectedExtensions.Keys, extensions.TestExecutors.Keys); - } + [TestMethod] + public void GetExtensionsDiscoveredFromAssemblyShouldReturnTestSettingsProviders() + { + var assemblyLocation = typeof(TestExtensionsTests).GetTypeInfo().Assembly.Location; - [TestMethod] - public void GetExtensionsDiscoveredFromAssemblyShouldReturnTestSettingsProviders() + _testExtensions.TestSettingsProviders = new Dictionary { - var assemblyLocation = typeof(TestExtensionsTests).GetTypeInfo().Assembly.Location; + { "tsp", new TestSettingsProviderPluginInformation(typeof(TestExtensionsTests)) }, + { "tsp1", new TestSettingsProviderPluginInformation(typeof(TestExtensions)) } + }; - this.testExtensions.TestSettingsProviders = new Dictionary(); - this.testExtensions.TestSettingsProviders.Add("tsp", new TestSettingsProviderPluginInformation(typeof(TestExtensionsTests))); - this.testExtensions.TestSettingsProviders.Add("tsp1", new TestSettingsProviderPluginInformation(typeof(TestExtensions))); + var extensions = _testExtensions.GetExtensionsDiscoveredFromAssembly(assemblyLocation); - var extensions = this.testExtensions.GetExtensionsDiscoveredFromAssembly(assemblyLocation); + var expectedExtensions = new Dictionary + { + { "tsp", new TestSettingsProviderPluginInformation(typeof(TestExtensionsTests)) } + }; + CollectionAssert.AreEqual(expectedExtensions.Keys, extensions.TestSettingsProviders.Keys); + } - var expectedExtensions = new Dictionary(); - expectedExtensions.Add("tsp", new TestSettingsProviderPluginInformation(typeof(TestExtensionsTests))); - CollectionAssert.AreEqual(expectedExtensions.Keys, extensions.TestSettingsProviders.Keys); - } + [TestMethod] + public void GetExtensionsDiscoveredFromAssemblyShouldReturnTestLoggers() + { + var assemblyLocation = typeof(TestExtensionsTests).GetTypeInfo().Assembly.Location; - [TestMethod] - public void GetExtensionsDiscoveredFromAssemblyShouldReturnTestLoggers() + _testExtensions.TestLoggers = new Dictionary { - var assemblyLocation = typeof(TestExtensionsTests).GetTypeInfo().Assembly.Location; + { "tl", new TestLoggerPluginInformation(typeof(TestExtensionsTests)) }, + { "tl1", new TestLoggerPluginInformation(typeof(TestExtensions)) } + }; - this.testExtensions.TestLoggers = new Dictionary(); - this.testExtensions.TestLoggers.Add("tl", new TestLoggerPluginInformation(typeof(TestExtensionsTests))); - this.testExtensions.TestLoggers.Add("tl1", new TestLoggerPluginInformation(typeof(TestExtensions))); + var extensions = _testExtensions.GetExtensionsDiscoveredFromAssembly(assemblyLocation); - var extensions = this.testExtensions.GetExtensionsDiscoveredFromAssembly(assemblyLocation); + var expectedExtensions = new Dictionary + { + { "tl", new TestLoggerPluginInformation(typeof(TestExtensionsTests)) } + }; + CollectionAssert.AreEqual(expectedExtensions.Keys, extensions.TestLoggers.Keys); + } - var expectedExtensions = new Dictionary(); - expectedExtensions.Add("tl", new TestLoggerPluginInformation(typeof(TestExtensionsTests))); - CollectionAssert.AreEqual(expectedExtensions.Keys, extensions.TestLoggers.Keys); - } + [TestMethod] + public void GetExtensionsDiscoveredFromAssemblyShouldReturnTestDiscoveresAndLoggers() + { + var assemblyLocation = typeof(TestExtensionsTests).GetTypeInfo().Assembly.Location; - [TestMethod] - public void GetExtensionsDiscoveredFromAssemblyShouldReturnTestDiscoveresAndLoggers() + _testExtensions.TestDiscoverers = new Dictionary { - var assemblyLocation = typeof(TestExtensionsTests).GetTypeInfo().Assembly.Location; - - this.testExtensions.TestDiscoverers = new Dictionary(); - this.testExtensions.TestDiscoverers.Add("td", new TestDiscovererPluginInformation(typeof(TestExtensionsTests))); + { "td", new TestDiscovererPluginInformation(typeof(TestExtensionsTests)) } + }; - this.testExtensions.TestLoggers = new Dictionary(); - this.testExtensions.TestLoggers.Add("tl", new TestLoggerPluginInformation(typeof(TestExtensionsTests))); + _testExtensions.TestLoggers = new Dictionary + { + { "tl", new TestLoggerPluginInformation(typeof(TestExtensionsTests)) } + }; - var extensions = this.testExtensions.GetExtensionsDiscoveredFromAssembly(assemblyLocation); + var extensions = _testExtensions.GetExtensionsDiscoveredFromAssembly(assemblyLocation); - var expectedDiscoverers = new Dictionary(); - expectedDiscoverers.Add("td", new TestDiscovererPluginInformation(typeof(TestExtensionsTests))); - CollectionAssert.AreEqual(expectedDiscoverers.Keys, extensions.TestDiscoverers.Keys); + var expectedDiscoverers = new Dictionary + { + { "td", new TestDiscovererPluginInformation(typeof(TestExtensionsTests)) } + }; + CollectionAssert.AreEqual(expectedDiscoverers.Keys, extensions.TestDiscoverers.Keys); - var expectedLoggers = new Dictionary(); - expectedLoggers.Add("tl", new TestLoggerPluginInformation(typeof(TestExtensionsTests))); - CollectionAssert.AreEqual(expectedLoggers.Keys, extensions.TestLoggers.Keys); - } + var expectedLoggers = new Dictionary + { + { "tl", new TestLoggerPluginInformation(typeof(TestExtensionsTests)) } + }; + CollectionAssert.AreEqual(expectedLoggers.Keys, extensions.TestLoggers.Keys); } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestLoggerPluginInformationTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestLoggerPluginInformationTests.cs index 4bd1640354..1c7e53242c 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestLoggerPluginInformationTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestLoggerPluginInformationTests.cs @@ -1,73 +1,70 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.ExtensionFramework.Utilities -{ - using System; - using System.Linq; - - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace TestPlatform.Common.UnitTests.ExtensionFramework.Utilities; +using System.Linq; - [TestClass] - public class TestLoggerPluginInformationTests - { - private TestLoggerPluginInformation testPluginInformation; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestTools.UnitTesting; - internal const string DefaultExtensionURI = "executor://unittest"; +[TestClass] +public class TestLoggerPluginInformationTests +{ + private TestLoggerPluginInformation _testPluginInformation; - internal const string DefaultFriendlyName = "excel"; + internal const string DefaultExtensionUri = "executor://unittest"; - [TestMethod] - public void AssemblyQualifiedNameShouldReturnTestExtensionTypesName() - { - this.testPluginInformation = new TestLoggerPluginInformation(typeof(DummyTestExtensionWithNoFriendlyName)); - Assert.AreEqual(typeof(DummyTestExtensionWithNoFriendlyName).AssemblyQualifiedName, this.testPluginInformation.AssemblyQualifiedName); - } + internal const string DefaultFriendlyName = "excel"; - [TestMethod] - public void IdentifierDataShouldReturnExtensionUri() - { - this.testPluginInformation = new TestLoggerPluginInformation(typeof(DummyTestExtensionWithFriendlyName)); - Assert.AreEqual(DefaultExtensionURI, this.testPluginInformation.IdentifierData); - } + [TestMethod] + public void AssemblyQualifiedNameShouldReturnTestExtensionTypesName() + { + _testPluginInformation = new TestLoggerPluginInformation(typeof(DummyTestExtensionWithNoFriendlyName)); + Assert.AreEqual(typeof(DummyTestExtensionWithNoFriendlyName).AssemblyQualifiedName, _testPluginInformation.AssemblyQualifiedName); + } - [TestMethod] - public void FriendlyNameShouldReturnEmptyIfALoggerDoesNotHaveOne() - { - this.testPluginInformation = new TestLoggerPluginInformation(typeof(DummyTestExtensionWithNoFriendlyName)); - Assert.IsNotNull(this.testPluginInformation.FriendlyName); - Assert.AreEqual(string.Empty, this.testPluginInformation.FriendlyName); - } + [TestMethod] + public void IdentifierDataShouldReturnExtensionUri() + { + _testPluginInformation = new TestLoggerPluginInformation(typeof(DummyTestExtensionWithFriendlyName)); + Assert.AreEqual(DefaultExtensionUri, _testPluginInformation.IdentifierData); + } - [TestMethod] - public void FriendlyNameShouldReturnFriendlyNameOfALogger() - { - this.testPluginInformation = new TestLoggerPluginInformation(typeof(DummyTestExtensionWithFriendlyName)); - Assert.AreEqual(DefaultFriendlyName, this.testPluginInformation.FriendlyName); - } + [TestMethod] + public void FriendlyNameShouldReturnEmptyIfALoggerDoesNotHaveOne() + { + _testPluginInformation = new TestLoggerPluginInformation(typeof(DummyTestExtensionWithNoFriendlyName)); + Assert.IsNotNull(_testPluginInformation.FriendlyName); + Assert.AreEqual(string.Empty, _testPluginInformation.FriendlyName); + } - [TestMethod] - public void MetadataShouldReturnExtensionUriAndFriendlyName() - { - this.testPluginInformation = new TestLoggerPluginInformation(typeof(DummyTestExtensionWithFriendlyName)); + [TestMethod] + public void FriendlyNameShouldReturnFriendlyNameOfALogger() + { + _testPluginInformation = new TestLoggerPluginInformation(typeof(DummyTestExtensionWithFriendlyName)); + Assert.AreEqual(DefaultFriendlyName, _testPluginInformation.FriendlyName); + } - CollectionAssert.AreEqual(new object[] { DefaultExtensionURI, DefaultFriendlyName }, this.testPluginInformation.Metadata.ToArray()); - } + [TestMethod] + public void MetadataShouldReturnExtensionUriAndFriendlyName() + { + _testPluginInformation = new TestLoggerPluginInformation(typeof(DummyTestExtensionWithFriendlyName)); - #region Implementation + CollectionAssert.AreEqual(new object[] { DefaultExtensionUri, DefaultFriendlyName }, _testPluginInformation.Metadata.ToArray()); + } - private class DummyTestExtensionWithNoFriendlyName - { - } + #region Implementation - [FriendlyName(TestLoggerPluginInformationTests.DefaultFriendlyName)] - [ExtensionUri(TestLoggerPluginInformationTests.DefaultExtensionURI)] - private class DummyTestExtensionWithFriendlyName - { - } + private class DummyTestExtensionWithNoFriendlyName + { + } - #endregion + [FriendlyName(DefaultFriendlyName)] + [ExtensionUri(DefaultExtensionUri)] + private class DummyTestExtensionWithFriendlyName + { } -} + + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestPluginInformationTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestPluginInformationTests.cs index 4b398259ef..c25e1e0492 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestPluginInformationTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestPluginInformationTests.cs @@ -1,50 +1,50 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.ExtensionFramework.Utilities +namespace TestPlatform.Common.UnitTests.ExtensionFramework.Utilities; + +using System; +using System.Linq; + +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class TestPluginInformationTests { - using System; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; + private readonly TestableTestPluginInformation _testPluginInformation; - [TestClass] - public class TestPluginInformationTests + public TestPluginInformationTests() { - private TestableTestPluginInformation testPluginInformation; - - public TestPluginInformationTests() - { - this.testPluginInformation = new TestableTestPluginInformation(typeof(TestPluginInformationTests)); - } - - [TestMethod] - public void AssemblyQualifiedNameShouldReturnTestExtensionTypesName() - { - Assert.AreEqual(typeof(TestPluginInformationTests).AssemblyQualifiedName, this.testPluginInformation.AssemblyQualifiedName); - } - - [TestMethod] - public void IdentifierDataShouldReturnTestExtensionTypesName() - { - Assert.AreEqual(typeof(TestPluginInformationTests).AssemblyQualifiedName, this.testPluginInformation.IdentifierData); - } - - [TestMethod] - public void MetadataShouldReturnTestExtensionTypesAssemblyQualifiedName() - { - CollectionAssert.AreEqual(new object[] { typeof(TestPluginInformationTests).AssemblyQualifiedName }, this.testPluginInformation.Metadata.ToArray()); - } + _testPluginInformation = new TestableTestPluginInformation(typeof(TestPluginInformationTests)); } - #region Implementation + [TestMethod] + public void AssemblyQualifiedNameShouldReturnTestExtensionTypesName() + { + Assert.AreEqual(typeof(TestPluginInformationTests).AssemblyQualifiedName, _testPluginInformation.AssemblyQualifiedName); + } + + [TestMethod] + public void IdentifierDataShouldReturnTestExtensionTypesName() + { + Assert.AreEqual(typeof(TestPluginInformationTests).AssemblyQualifiedName, _testPluginInformation.IdentifierData); + } - public class TestableTestPluginInformation : TestPluginInformation + [TestMethod] + public void MetadataShouldReturnTestExtensionTypesAssemblyQualifiedName() { - public TestableTestPluginInformation(Type testExtensionType) : base(testExtensionType) - { - } + CollectionAssert.AreEqual(new object[] { typeof(TestPluginInformationTests).AssemblyQualifiedName }, _testPluginInformation.Metadata.ToArray()); } +} - #endregion +#region Implementation + +public class TestableTestPluginInformation : TestPluginInformation +{ + public TestableTestPluginInformation(Type testExtensionType) : base(testExtensionType) + { + } } + +#endregion \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestSettingsProviderPluginInformationTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestSettingsProviderPluginInformationTests.cs index c200738a70..14dac37b32 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestSettingsProviderPluginInformationTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestSettingsProviderPluginInformationTests.cs @@ -1,69 +1,66 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.ExtensionFramework.Utilities -{ - using System; - using System.Linq; - - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace TestPlatform.Common.UnitTests.ExtensionFramework.Utilities; +using System.Linq; - [TestClass] - public class TestSettingsProviderPluginInformationTests - { - private TestSettingsProviderPluginInformation testPluginInformation; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestTools.UnitTesting; - private const string DefaultSettingsName = "mstestsettings"; +[TestClass] +public class TestSettingsProviderPluginInformationTests +{ + private TestSettingsProviderPluginInformation _testPluginInformation; - [TestMethod] - public void AssemblyQualifiedNameShouldReturnTestExtensionTypesName() - { - this.testPluginInformation = new TestSettingsProviderPluginInformation(typeof(TestPluginInformationTests)); - Assert.AreEqual(typeof(TestPluginInformationTests).AssemblyQualifiedName, this.testPluginInformation.AssemblyQualifiedName); - } + private const string DefaultSettingsName = "mstestsettings"; - [TestMethod] - public void IdentifierDataShouldReturnSettingsName() - { - this.testPluginInformation = new TestSettingsProviderPluginInformation(typeof(DummySettingProviderWithSettingsName)); - Assert.AreEqual(DefaultSettingsName, this.testPluginInformation.IdentifierData); - } + [TestMethod] + public void AssemblyQualifiedNameShouldReturnTestExtensionTypesName() + { + _testPluginInformation = new TestSettingsProviderPluginInformation(typeof(TestPluginInformationTests)); + Assert.AreEqual(typeof(TestPluginInformationTests).AssemblyQualifiedName, _testPluginInformation.AssemblyQualifiedName); + } - [TestMethod] - public void MetadataShouldReturnSettingsProviderName() - { - this.testPluginInformation = new TestSettingsProviderPluginInformation(typeof(DummySettingProviderWithSettingsName)); - CollectionAssert.AreEqual(new object[] { DefaultSettingsName }, this.testPluginInformation.Metadata.ToArray()); - } + [TestMethod] + public void IdentifierDataShouldReturnSettingsName() + { + _testPluginInformation = new TestSettingsProviderPluginInformation(typeof(DummySettingProviderWithSettingsName)); + Assert.AreEqual(DefaultSettingsName, _testPluginInformation.IdentifierData); + } - [TestMethod] - public void SettingsNameShouldReturnEmptyIfASettingsProviderDoesNotHaveOne() - { - this.testPluginInformation = new TestSettingsProviderPluginInformation(typeof(DummySettingProviderWithoutSettingsName)); - Assert.IsNotNull(this.testPluginInformation.SettingsName); - Assert.AreEqual(string.Empty, this.testPluginInformation.SettingsName); - } + [TestMethod] + public void MetadataShouldReturnSettingsProviderName() + { + _testPluginInformation = new TestSettingsProviderPluginInformation(typeof(DummySettingProviderWithSettingsName)); + CollectionAssert.AreEqual(new object[] { DefaultSettingsName }, _testPluginInformation.Metadata.ToArray()); + } - [TestMethod] - public void SettingsNameShouldReturnExtensionUriOfAnExtension() - { - this.testPluginInformation = new TestSettingsProviderPluginInformation(typeof(DummySettingProviderWithSettingsName)); - Assert.AreEqual(DefaultSettingsName, this.testPluginInformation.SettingsName); - } + [TestMethod] + public void SettingsNameShouldReturnEmptyIfASettingsProviderDoesNotHaveOne() + { + _testPluginInformation = new TestSettingsProviderPluginInformation(typeof(DummySettingProviderWithoutSettingsName)); + Assert.IsNotNull(_testPluginInformation.SettingsName); + Assert.AreEqual(string.Empty, _testPluginInformation.SettingsName); + } - #region Implementation + [TestMethod] + public void SettingsNameShouldReturnExtensionUriOfAnExtension() + { + _testPluginInformation = new TestSettingsProviderPluginInformation(typeof(DummySettingProviderWithSettingsName)); + Assert.AreEqual(DefaultSettingsName, _testPluginInformation.SettingsName); + } - private class DummySettingProviderWithoutSettingsName - { - } + #region Implementation - [SettingsName(DefaultSettingsName)] - private class DummySettingProviderWithSettingsName - { - } + private class DummySettingProviderWithoutSettingsName + { + } - #endregion + [SettingsName(DefaultSettingsName)] + private class DummySettingProviderWithSettingsName + { } -} + + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/Filtering/ConditionTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/Filtering/ConditionTests.cs index d28627c0c2..7e315ee492 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/Filtering/ConditionTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/Filtering/ConditionTests.cs @@ -1,237 +1,238 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Common.UnitTests.Filtering +namespace Microsoft.TestPlatform.Common.UnitTests.Filtering; + +using System; +using System.Linq; + +using Microsoft.VisualStudio.TestPlatform.Common.Filtering; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class ConditionTests { - using System; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.Common.Filtering; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class ConditionTests - { - [TestMethod] - public void ParseShouldThrownFormatExceptionOnNullConditionString() - { - string conditionString = null; - Assert.ThrowsException(() => Condition.Parse(conditionString)); - } - - [TestMethod] - public void ParseShouldThrownFormatExceptionOnEmptyConditionString() - { - var conditionString = ""; - Assert.ThrowsException(() => Condition.Parse(conditionString)); - } - - [TestMethod] - public void ParseShouldThrownFormatExceptionOnIncompleteConditionString() - { - var conditionString = "PropertyName="; - Assert.ThrowsException( () => Condition.Parse(conditionString)); - } - - [TestMethod] - public void ParseShouldCreateDefaultConditionWhenOnlyPropertyValuePassed() - { - var conditionString = "ABC"; - Condition condition = Condition.Parse(conditionString); - Assert.AreEqual(Condition.DefaultPropertyName, condition.Name); - Assert.AreEqual(Operation.Contains, condition.Operation); - Assert.AreEqual(conditionString, condition.Value); - } - - [TestMethod] - public void ParseShouldCreateProperConditionOnValidConditionString() - { - var conditionString = "PropertyName=PropertyValue"; - Condition condition = Condition.Parse(conditionString); - Assert.AreEqual("PropertyName", condition.Name); - Assert.AreEqual(Operation.Equal, condition.Operation); - Assert.AreEqual("PropertyValue", condition.Value); - } - - [TestMethod] - public void ParseShouldHandleEscapedString() - { - var conditionString = @"FullyQualifiedName=TestClass1\(""hello""\).TestMethod\(1.5\)"; - - Condition condition = Condition.Parse(conditionString); - Assert.AreEqual("FullyQualifiedName", condition.Name); - Assert.AreEqual(Operation.Equal, condition.Operation); - Assert.AreEqual(@"TestClass1(""hello"").TestMethod(1.5)", condition.Value); - } - - [TestMethod] - public void ParseShouldHandleEscapedBang() - { - var conditionString = @"FullyQualifiedName!=TestClass1\(""\!""\).TestMethod\(1.5\)"; - - Condition condition = Condition.Parse(conditionString); - Assert.AreEqual("FullyQualifiedName", condition.Name); - Assert.AreEqual(Operation.NotEqual, condition.Operation); - Assert.AreEqual(@"TestClass1(""!"").TestMethod(1.5)", condition.Value); - } - - [TestMethod] - public void ParseShouldHandleEscapedNotEqual() - { - var conditionString = @"FullyQualifiedName!=TestClass1\(""\!\=""\).TestMethod\(1.5\)"; - - Condition condition = Condition.Parse(conditionString); - Assert.AreEqual("FullyQualifiedName", condition.Name); - Assert.AreEqual(Operation.NotEqual, condition.Operation); - Assert.AreEqual(@"TestClass1(""!="").TestMethod(1.5)", condition.Value); - } - - [TestMethod] - public void ParseShouldHandleEscapedTilde() - { - var conditionString = @"FullyQualifiedName~TestClass1\(""\~""\).TestMethod\(1.5\)"; - - Condition condition = Condition.Parse(conditionString); - Assert.AreEqual("FullyQualifiedName", condition.Name); - Assert.AreEqual(Operation.Contains, condition.Operation); - Assert.AreEqual(@"TestClass1(""~"").TestMethod(1.5)", condition.Value); - } - - [TestMethod] - public void ParseShouldHandleEscapedNotTilde() - { - var conditionString = @"FullyQualifiedName!~TestClass1\(""\!\~""\).TestMethod\(1.5\)"; - - Condition condition = Condition.Parse(conditionString); - Assert.AreEqual("FullyQualifiedName", condition.Name); - Assert.AreEqual(Operation.NotContains, condition.Operation); - Assert.AreEqual(@"TestClass1(""!~"").TestMethod(1.5)", condition.Value); - } - - [TestMethod] - public void ParseStringWithSingleUnescapedBangThrowsFormatException1() - { - var conditionString = @"FullyQualifiedName=Test1(""!"")"; - - Assert.ThrowsException(() => Condition.Parse(conditionString)); - } - - [TestMethod] - public void ParseStringWithSingleUnescapedBangThrowsFormatException2() - { - var conditionString = @"FullyQualifiedName!Test1()"; - - Assert.ThrowsException(() => Condition.Parse(conditionString)); - } - - [TestMethod] - public void TokenizeNullThrowsArgumentNullException() - { - Assert.ThrowsException(() => Condition.TokenizeFilterConditionString(null), "str"); - } - - [TestMethod] - public void TokenizeConditionShouldHandleEscapedBang() - { - var conditionString = @"FullyQualifiedName=TestMethod\(""\!""\)"; - - var tokens = Condition.TokenizeFilterConditionString(conditionString).ToArray(); - - Assert.AreEqual(3, tokens.Length); - Assert.AreEqual("FullyQualifiedName", tokens[0]); - Assert.AreEqual("=", tokens[1]); - Assert.AreEqual(@"TestMethod\(""\!""\)", tokens[2]); - } - - [TestMethod] - public void TokenizeConditionShouldHandleEscapedNotEqual1() - { - var conditionString = @"FullyQualifiedName=TestMethod\(""\!\=""\)"; - - var tokens = Condition.TokenizeFilterConditionString(conditionString).ToArray(); - - Assert.AreEqual(3, tokens.Length); - Assert.AreEqual("FullyQualifiedName", tokens[0]); - Assert.AreEqual("=", tokens[1]); - Assert.AreEqual(@"TestMethod\(""\!\=""\)", tokens[2]); - } - - [TestMethod] - public void TokenizeConditionShouldHandleEscapedNotEqual2() - { - var conditionString = @"FullyQualifiedName!=TestMethod\(""\!\=""\)"; - - var tokens = Condition.TokenizeFilterConditionString(conditionString).ToArray(); - - Assert.AreEqual(3, tokens.Length); - Assert.AreEqual("FullyQualifiedName", tokens[0]); - Assert.AreEqual("!=", tokens[1]); - Assert.AreEqual(@"TestMethod\(""\!\=""\)", tokens[2]); - } - - [TestMethod] - public void TokenizeConditionShouldHandleEscapedBackslash() - { - var conditionString = @"FullyQualifiedName=TestMethod\(""\\""\)"; - - var tokens = Condition.TokenizeFilterConditionString(conditionString).ToArray(); - - Assert.AreEqual(3, tokens.Length); - Assert.AreEqual("FullyQualifiedName", tokens[0]); - Assert.AreEqual("=", tokens[1]); - Assert.AreEqual(@"TestMethod\(""\\""\)", tokens[2]); - } - - [TestMethod] - public void TokenizeConditionShouldHandleEscapedTilde() - { - var conditionString = @"FullyQualifiedName~TestMethod\(""\~""\)"; - - var tokens = Condition.TokenizeFilterConditionString(conditionString).ToArray(); - - Assert.AreEqual(3, tokens.Length); - Assert.AreEqual("FullyQualifiedName", tokens[0]); - Assert.AreEqual("~", tokens[1]); - Assert.AreEqual(@"TestMethod\(""\~""\)", tokens[2]); - } - - [TestMethod] - public void TokenizeConditionShouldHandleEscapedNotTilde() - { - var conditionString = @"FullyQualifiedName!~TestMethod\(""\!\~""\)"; - - var tokens = Condition.TokenizeFilterConditionString(conditionString).ToArray(); - - Assert.AreEqual(3, tokens.Length); - Assert.AreEqual("FullyQualifiedName", tokens[0]); - Assert.AreEqual("!~", tokens[1]); - Assert.AreEqual(@"TestMethod\(""\!\~""\)", tokens[2]); - } - - [TestMethod] - public void TokenizeConditionShouldHandleSingleUnescapedBang() - { - var conditionString = @"FullyQualifiedName!=TestMethod\(""!""\)"; - - var tokens = Condition.TokenizeFilterConditionString(conditionString).ToArray(); - - Assert.AreEqual(5, tokens.Length); - Assert.AreEqual("FullyQualifiedName", tokens[0]); - Assert.AreEqual("!=", tokens[1]); - Assert.AreEqual(@"TestMethod\(""", tokens[2]); - Assert.AreEqual("!", tokens[3]); - Assert.AreEqual(@"""\)", tokens[4]); - } - - [TestMethod] - public void TokenizeConditionShouldHandleSingleBangAtEnd() - { - var conditionString = "FullyQualifiedName!"; - - var tokens = Condition.TokenizeFilterConditionString(conditionString).ToArray(); - - Assert.AreEqual(2, tokens.Length); - Assert.AreEqual("FullyQualifiedName", tokens[0]); - Assert.AreEqual("!", tokens[1]); - } - } -} + [TestMethod] + public void ParseShouldThrownFormatExceptionOnNullConditionString() + { + string conditionString = null; + Assert.ThrowsException(() => Condition.Parse(conditionString)); + } + + [TestMethod] + public void ParseShouldThrownFormatExceptionOnEmptyConditionString() + { + var conditionString = ""; + Assert.ThrowsException(() => Condition.Parse(conditionString)); + } + + [TestMethod] + public void ParseShouldThrownFormatExceptionOnIncompleteConditionString() + { + var conditionString = "PropertyName="; + Assert.ThrowsException(() => Condition.Parse(conditionString)); + } + + [TestMethod] + public void ParseShouldCreateDefaultConditionWhenOnlyPropertyValuePassed() + { + var conditionString = "ABC"; + Condition condition = Condition.Parse(conditionString); + Assert.AreEqual(Condition.DefaultPropertyName, condition.Name); + Assert.AreEqual(Operation.Contains, condition.Operation); + Assert.AreEqual(conditionString, condition.Value); + } + + [TestMethod] + public void ParseShouldCreateProperConditionOnValidConditionString() + { + var conditionString = "PropertyName=PropertyValue"; + Condition condition = Condition.Parse(conditionString); + Assert.AreEqual("PropertyName", condition.Name); + Assert.AreEqual(Operation.Equal, condition.Operation); + Assert.AreEqual("PropertyValue", condition.Value); + } + + [TestMethod] + public void ParseShouldHandleEscapedString() + { + var conditionString = @"FullyQualifiedName=TestClass1\(""hello""\).TestMethod\(1.5\)"; + + Condition condition = Condition.Parse(conditionString); + Assert.AreEqual("FullyQualifiedName", condition.Name); + Assert.AreEqual(Operation.Equal, condition.Operation); + Assert.AreEqual(@"TestClass1(""hello"").TestMethod(1.5)", condition.Value); + } + + [TestMethod] + public void ParseShouldHandleEscapedBang() + { + var conditionString = @"FullyQualifiedName!=TestClass1\(""\!""\).TestMethod\(1.5\)"; + + Condition condition = Condition.Parse(conditionString); + Assert.AreEqual("FullyQualifiedName", condition.Name); + Assert.AreEqual(Operation.NotEqual, condition.Operation); + Assert.AreEqual(@"TestClass1(""!"").TestMethod(1.5)", condition.Value); + } + + [TestMethod] + public void ParseShouldHandleEscapedNotEqual() + { + var conditionString = @"FullyQualifiedName!=TestClass1\(""\!\=""\).TestMethod\(1.5\)"; + + Condition condition = Condition.Parse(conditionString); + Assert.AreEqual("FullyQualifiedName", condition.Name); + Assert.AreEqual(Operation.NotEqual, condition.Operation); + Assert.AreEqual(@"TestClass1(""!="").TestMethod(1.5)", condition.Value); + } + + [TestMethod] + public void ParseShouldHandleEscapedTilde() + { + var conditionString = @"FullyQualifiedName~TestClass1\(""\~""\).TestMethod\(1.5\)"; + + Condition condition = Condition.Parse(conditionString); + Assert.AreEqual("FullyQualifiedName", condition.Name); + Assert.AreEqual(Operation.Contains, condition.Operation); + Assert.AreEqual(@"TestClass1(""~"").TestMethod(1.5)", condition.Value); + } + + [TestMethod] + public void ParseShouldHandleEscapedNotTilde() + { + var conditionString = @"FullyQualifiedName!~TestClass1\(""\!\~""\).TestMethod\(1.5\)"; + + Condition condition = Condition.Parse(conditionString); + Assert.AreEqual("FullyQualifiedName", condition.Name); + Assert.AreEqual(Operation.NotContains, condition.Operation); + Assert.AreEqual(@"TestClass1(""!~"").TestMethod(1.5)", condition.Value); + } + + [TestMethod] + public void ParseStringWithSingleUnescapedBangThrowsFormatException1() + { + var conditionString = @"FullyQualifiedName=Test1(""!"")"; + + Assert.ThrowsException(() => Condition.Parse(conditionString)); + } + + [TestMethod] + public void ParseStringWithSingleUnescapedBangThrowsFormatException2() + { + var conditionString = @"FullyQualifiedName!Test1()"; + + Assert.ThrowsException(() => Condition.Parse(conditionString)); + } + + [TestMethod] + public void TokenizeNullThrowsArgumentNullException() + { + Assert.ThrowsException(() => Condition.TokenizeFilterConditionString(null), "str"); + } + + [TestMethod] + public void TokenizeConditionShouldHandleEscapedBang() + { + var conditionString = @"FullyQualifiedName=TestMethod\(""\!""\)"; + + var tokens = Condition.TokenizeFilterConditionString(conditionString).ToArray(); + + Assert.AreEqual(3, tokens.Length); + Assert.AreEqual("FullyQualifiedName", tokens[0]); + Assert.AreEqual("=", tokens[1]); + Assert.AreEqual(@"TestMethod\(""\!""\)", tokens[2]); + } + + [TestMethod] + public void TokenizeConditionShouldHandleEscapedNotEqual1() + { + var conditionString = @"FullyQualifiedName=TestMethod\(""\!\=""\)"; + + var tokens = Condition.TokenizeFilterConditionString(conditionString).ToArray(); + + Assert.AreEqual(3, tokens.Length); + Assert.AreEqual("FullyQualifiedName", tokens[0]); + Assert.AreEqual("=", tokens[1]); + Assert.AreEqual(@"TestMethod\(""\!\=""\)", tokens[2]); + } + + [TestMethod] + public void TokenizeConditionShouldHandleEscapedNotEqual2() + { + var conditionString = @"FullyQualifiedName!=TestMethod\(""\!\=""\)"; + + var tokens = Condition.TokenizeFilterConditionString(conditionString).ToArray(); + + Assert.AreEqual(3, tokens.Length); + Assert.AreEqual("FullyQualifiedName", tokens[0]); + Assert.AreEqual("!=", tokens[1]); + Assert.AreEqual(@"TestMethod\(""\!\=""\)", tokens[2]); + } + + [TestMethod] + public void TokenizeConditionShouldHandleEscapedBackslash() + { + var conditionString = @"FullyQualifiedName=TestMethod\(""\\""\)"; + + var tokens = Condition.TokenizeFilterConditionString(conditionString).ToArray(); + + Assert.AreEqual(3, tokens.Length); + Assert.AreEqual("FullyQualifiedName", tokens[0]); + Assert.AreEqual("=", tokens[1]); + Assert.AreEqual(@"TestMethod\(""\\""\)", tokens[2]); + } + + [TestMethod] + public void TokenizeConditionShouldHandleEscapedTilde() + { + var conditionString = @"FullyQualifiedName~TestMethod\(""\~""\)"; + + var tokens = Condition.TokenizeFilterConditionString(conditionString).ToArray(); + + Assert.AreEqual(3, tokens.Length); + Assert.AreEqual("FullyQualifiedName", tokens[0]); + Assert.AreEqual("~", tokens[1]); + Assert.AreEqual(@"TestMethod\(""\~""\)", tokens[2]); + } + + [TestMethod] + public void TokenizeConditionShouldHandleEscapedNotTilde() + { + var conditionString = @"FullyQualifiedName!~TestMethod\(""\!\~""\)"; + + var tokens = Condition.TokenizeFilterConditionString(conditionString).ToArray(); + + Assert.AreEqual(3, tokens.Length); + Assert.AreEqual("FullyQualifiedName", tokens[0]); + Assert.AreEqual("!~", tokens[1]); + Assert.AreEqual(@"TestMethod\(""\!\~""\)", tokens[2]); + } + + [TestMethod] + public void TokenizeConditionShouldHandleSingleUnescapedBang() + { + var conditionString = @"FullyQualifiedName!=TestMethod\(""!""\)"; + + var tokens = Condition.TokenizeFilterConditionString(conditionString).ToArray(); + + Assert.AreEqual(5, tokens.Length); + Assert.AreEqual("FullyQualifiedName", tokens[0]); + Assert.AreEqual("!=", tokens[1]); + Assert.AreEqual(@"TestMethod\(""", tokens[2]); + Assert.AreEqual("!", tokens[3]); + Assert.AreEqual(@"""\)", tokens[4]); + } + + [TestMethod] + public void TokenizeConditionShouldHandleSingleBangAtEnd() + { + var conditionString = "FullyQualifiedName!"; + + var tokens = Condition.TokenizeFilterConditionString(conditionString).ToArray(); + + Assert.AreEqual(2, tokens.Length); + Assert.AreEqual("FullyQualifiedName", tokens[0]); + Assert.AreEqual("!", tokens[1]); + } +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/Filtering/FastFilterTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/Filtering/FastFilterTests.cs index 3ee70eb7b5..f03459b380 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/Filtering/FastFilterTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/Filtering/FastFilterTests.cs @@ -1,453 +1,452 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Common.UnitTests.Filtering +namespace Microsoft.TestPlatform.Common.UnitTests.Filtering; + +using System; +using System.Collections.Generic; +using System.Linq; +using VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestPlatform.Common.Filtering; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using System.Collections.Immutable; + +[TestClass] +public class FastFilterTests { - using System; - using System.Collections.Generic; - using System.Linq; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Microsoft.VisualStudio.TestPlatform.Common.Filtering; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using System.Collections.Immutable; - - [TestClass] - public class FastFilterTests + [TestMethod] + public void MultipleOperatorKindsShouldNotCreateFastFilter() { - [TestMethod] - public void MultipleOperatorKindsShouldNotCreateFastFilter() - { - var filterExpressionWrapper = new FilterExpressionWrapper("Name=Test1&(Name=Test2|NameTest3)"); - var fastFilter = filterExpressionWrapper.fastFilter; + var filterExpressionWrapper = new FilterExpressionWrapper("Name=Test1&(Name=Test2|NameTest3)"); + var fastFilter = filterExpressionWrapper.FastFilter; - Assert.IsTrue(fastFilter == null); - } + Assert.IsTrue(fastFilter == null); + } - [TestMethod] - public void MultipleOperationKindsShouldNotCreateFastFilter() - { - var filterExpressionWrapper = new FilterExpressionWrapper("Name!=TestClass1&Category=Nightly"); - var fastFilter = filterExpressionWrapper.fastFilter; + [TestMethod] + public void MultipleOperationKindsShouldNotCreateFastFilter() + { + var filterExpressionWrapper = new FilterExpressionWrapper("Name!=TestClass1&Category=Nightly"); + var fastFilter = filterExpressionWrapper.FastFilter; - Assert.IsTrue(fastFilter == null); - } + Assert.IsTrue(fastFilter == null); + } - [TestMethod] - public void ContainsOperationShouldNotCreateFastFilter() - { - var filterExpressionWrapper = new FilterExpressionWrapper("Name~TestClass1"); - var fastFilter = filterExpressionWrapper.fastFilter; + [TestMethod] + public void ContainsOperationShouldNotCreateFastFilter() + { + var filterExpressionWrapper = new FilterExpressionWrapper("Name~TestClass1"); + var fastFilter = filterExpressionWrapper.FastFilter; - Assert.IsTrue(fastFilter == null); - } + Assert.IsTrue(fastFilter == null); + } - [TestMethod] - public void NotContainsOperationShouldNotCreateFastFilter() - { - var filterExpressionWrapper = new FilterExpressionWrapper("Name!~TestClass1"); - var fastFilter = filterExpressionWrapper.fastFilter; + [TestMethod] + public void NotContainsOperationShouldNotCreateFastFilter() + { + var filterExpressionWrapper = new FilterExpressionWrapper("Name!~TestClass1"); + var fastFilter = filterExpressionWrapper.FastFilter; - Assert.IsTrue(fastFilter == null); - } + Assert.IsTrue(fastFilter == null); + } - [TestMethod] - public void AndOperatorAndEqualsOperationShouldNotCreateFastFilter() - { - var filterExpressionWrapper = new FilterExpressionWrapper("Name=Test1&Name=Test2"); - var fastFilter = filterExpressionWrapper.fastFilter; + [TestMethod] + public void AndOperatorAndEqualsOperationShouldNotCreateFastFilter() + { + var filterExpressionWrapper = new FilterExpressionWrapper("Name=Test1&Name=Test2"); + var fastFilter = filterExpressionWrapper.FastFilter; - Assert.IsTrue(fastFilter == null); - Assert.IsTrue(string.IsNullOrEmpty(filterExpressionWrapper.ParseError)); - } + Assert.IsTrue(fastFilter == null); + Assert.IsTrue(string.IsNullOrEmpty(filterExpressionWrapper.ParseError)); + } - [TestMethod] - public void OrOperatorAndNotEqualsOperationShouldNotCreateFastFilter() - { - var filterExpressionWrapper = new FilterExpressionWrapper("Name!=Test1|Name!=Test2"); - var fastFilter = filterExpressionWrapper.fastFilter; + [TestMethod] + public void OrOperatorAndNotEqualsOperationShouldNotCreateFastFilter() + { + var filterExpressionWrapper = new FilterExpressionWrapper("Name!=Test1|Name!=Test2"); + var fastFilter = filterExpressionWrapper.FastFilter; - Assert.IsTrue(fastFilter == null); - Assert.IsTrue(string.IsNullOrEmpty(filterExpressionWrapper.ParseError)); - } + Assert.IsTrue(fastFilter == null); + Assert.IsTrue(string.IsNullOrEmpty(filterExpressionWrapper.ParseError)); + } - [TestMethod] - public void FastFilterWithSingleEqualsClause() - { - var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName=Test1"); - var fastFilter = filterExpressionWrapper.fastFilter; + [TestMethod] + public void FastFilterWithSingleEqualsClause() + { + var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName=Test1"); + var fastFilter = filterExpressionWrapper.FastFilter; - var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "test1" }; + var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "test1" }; - Assert.IsTrue(fastFilter != null); - Assert.AreEqual("FullyQualifiedName", fastFilter.FilterProperties.Keys.Single()); - Assert.IsFalse(fastFilter.IsFilteredOutWhenMatched); - Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); + Assert.IsTrue(fastFilter != null); + Assert.AreEqual("FullyQualifiedName", fastFilter.FilterProperties.Keys.Single()); + Assert.IsFalse(fastFilter.IsFilteredOutWhenMatched); + Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); - Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName" }, null)); + Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName" }, null)); - Assert.IsTrue(fastFilter.Evaluate((s) => "Test1")); - Assert.IsFalse(fastFilter.Evaluate((s) => "Test2")); - } + Assert.IsTrue(fastFilter.Evaluate((s) => "Test1")); + Assert.IsFalse(fastFilter.Evaluate((s) => "Test2")); + } - [TestMethod] - public void FastFilterWithMultipleEqualsClause() - { - var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName=Test1|FullyQualifiedName=Test2|FullyQualifiedName=Test3"); - var fastFilter = filterExpressionWrapper.fastFilter; + [TestMethod] + public void FastFilterWithMultipleEqualsClause() + { + var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName=Test1|FullyQualifiedName=Test2|FullyQualifiedName=Test3"); + var fastFilter = filterExpressionWrapper.FastFilter; - var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "test1", "test2", "test3" }; + var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "test1", "test2", "test3" }; - Assert.IsTrue(fastFilter != null); - Assert.AreEqual("FullyQualifiedName", fastFilter.FilterProperties.Keys.Single()); - Assert.IsFalse(fastFilter.IsFilteredOutWhenMatched); - Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); + Assert.IsTrue(fastFilter != null); + Assert.AreEqual("FullyQualifiedName", fastFilter.FilterProperties.Keys.Single()); + Assert.IsFalse(fastFilter.IsFilteredOutWhenMatched); + Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); - Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName" }, null)); + Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName" }, null)); - Assert.IsTrue(fastFilter.Evaluate((s) => "Test1")); - Assert.IsTrue(fastFilter.Evaluate((s) => "test2")); - Assert.IsTrue(fastFilter.Evaluate((s) => "test3")); - Assert.IsFalse(fastFilter.Evaluate((s) => "Test4")); - } + Assert.IsTrue(fastFilter.Evaluate((s) => "Test1")); + Assert.IsTrue(fastFilter.Evaluate((s) => "test2")); + Assert.IsTrue(fastFilter.Evaluate((s) => "test3")); + Assert.IsFalse(fastFilter.Evaluate((s) => "Test4")); + } - [TestMethod] - public void FastFilterWithMultipleEqualsClauseAndParentheses() - { - var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName=Test1|(FullyQualifiedName=Test2|FullyQualifiedName=Test3)"); - var fastFilter = filterExpressionWrapper.fastFilter; + [TestMethod] + public void FastFilterWithMultipleEqualsClauseAndParentheses() + { + var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName=Test1|(FullyQualifiedName=Test2|FullyQualifiedName=Test3)"); + var fastFilter = filterExpressionWrapper.FastFilter; - var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "test1", "test2", "test3" }; + var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "test1", "test2", "test3" }; - Assert.IsTrue(fastFilter != null); - Assert.AreEqual("FullyQualifiedName", fastFilter.FilterProperties.Keys.Single()); - Assert.IsFalse(fastFilter.IsFilteredOutWhenMatched); - Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); + Assert.IsTrue(fastFilter != null); + Assert.AreEqual("FullyQualifiedName", fastFilter.FilterProperties.Keys.Single()); + Assert.IsFalse(fastFilter.IsFilteredOutWhenMatched); + Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); - Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName" }, null)); + Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName" }, null)); - Assert.IsTrue(fastFilter.Evaluate((s) => "Test1")); - Assert.IsTrue(fastFilter.Evaluate((s) => "Test2")); - Assert.IsTrue(fastFilter.Evaluate((s) => "Test3")); - Assert.IsFalse(fastFilter.Evaluate((s) => "Test4")); - } + Assert.IsTrue(fastFilter.Evaluate((s) => "Test1")); + Assert.IsTrue(fastFilter.Evaluate((s) => "Test2")); + Assert.IsTrue(fastFilter.Evaluate((s) => "Test3")); + Assert.IsFalse(fastFilter.Evaluate((s) => "Test4")); + } - [TestMethod] - public void FastFilterWithMultipleEqualsClauseAndRegex() - { - var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName=Test1|FullyQualifiedName=Test2|FullyQualifiedName=Test3", new FilterOptions() { FilterRegEx = @"^[^\s\(]+" }); - var fastFilter = filterExpressionWrapper.fastFilter; - - var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "test1", "test2", "test3" }; - - Assert.IsTrue(fastFilter != null); - Assert.AreEqual("FullyQualifiedName", fastFilter.FilterProperties.Keys.Single()); - Assert.IsFalse(fastFilter.IsFilteredOutWhenMatched); - Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); - - Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName" }, null)); - - Assert.IsTrue(fastFilter.Evaluate((s) => "Test1")); - Assert.IsTrue(fastFilter.Evaluate((s) => "Test2")); - Assert.IsTrue(fastFilter.Evaluate((s) => "Test3")); - Assert.IsTrue(fastFilter.Evaluate((s) => "Test1 (123)")); - Assert.IsTrue(fastFilter.Evaluate((s) => "Test2(123)")); - Assert.IsTrue(fastFilter.Evaluate((s) => "Test3 (123)")); - Assert.IsFalse(fastFilter.Evaluate((s) => "Test4")); - Assert.IsFalse(fastFilter.Evaluate((s) => "Test4 ()")); - } + [TestMethod] + public void FastFilterWithMultipleEqualsClauseAndRegex() + { + var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName=Test1|FullyQualifiedName=Test2|FullyQualifiedName=Test3", new FilterOptions() { FilterRegEx = @"^[^\s\(]+" }); + var fastFilter = filterExpressionWrapper.FastFilter; + + var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "test1", "test2", "test3" }; + + Assert.IsTrue(fastFilter != null); + Assert.AreEqual("FullyQualifiedName", fastFilter.FilterProperties.Keys.Single()); + Assert.IsFalse(fastFilter.IsFilteredOutWhenMatched); + Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); + + Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName" }, null)); + + Assert.IsTrue(fastFilter.Evaluate((s) => "Test1")); + Assert.IsTrue(fastFilter.Evaluate((s) => "Test2")); + Assert.IsTrue(fastFilter.Evaluate((s) => "Test3")); + Assert.IsTrue(fastFilter.Evaluate((s) => "Test1 (123)")); + Assert.IsTrue(fastFilter.Evaluate((s) => "Test2(123)")); + Assert.IsTrue(fastFilter.Evaluate((s) => "Test3 (123)")); + Assert.IsFalse(fastFilter.Evaluate((s) => "Test4")); + Assert.IsFalse(fastFilter.Evaluate((s) => "Test4 ()")); + } - [TestMethod] - public void FastFilterWithMultipleEqualsClauseForMultiplePropertyValues() - { - var filterExpressionWrapper = new FilterExpressionWrapper("Category=UnitTest|Category=PerfTest", null); - var fastFilter = filterExpressionWrapper.fastFilter; + [TestMethod] + public void FastFilterWithMultipleEqualsClauseForMultiplePropertyValues() + { + var filterExpressionWrapper = new FilterExpressionWrapper("Category=UnitTest|Category=PerfTest", null); + var fastFilter = filterExpressionWrapper.FastFilter; - var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "unittest", "perftest" }; + var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "unittest", "perftest" }; - Assert.IsTrue(fastFilter != null); - Assert.AreEqual("Category", fastFilter.FilterProperties.Keys.Single()); - Assert.IsFalse(fastFilter.IsFilteredOutWhenMatched); - Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); + Assert.IsTrue(fastFilter != null); + Assert.AreEqual("Category", fastFilter.FilterProperties.Keys.Single()); + Assert.IsFalse(fastFilter.IsFilteredOutWhenMatched); + Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); - Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "Category" }, null)); + Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "Category" }, null)); - Assert.IsTrue(fastFilter.Evaluate((s) => new[] { "UnitTest" })); - Assert.IsTrue(fastFilter.Evaluate((s) => new[] { "PerfTest" })); - Assert.IsTrue(fastFilter.Evaluate((s) => new[] { "UnitTest", "PerfTest" })); - Assert.IsTrue(fastFilter.Evaluate((s) => new[] { "UnitTest", "IntegrationTest" })); - Assert.IsFalse(fastFilter.Evaluate((s) => new[] { "IntegrationTest" })); - Assert.IsFalse(fastFilter.Evaluate((s) => null)); - } + Assert.IsTrue(fastFilter.Evaluate((s) => new[] { "UnitTest" })); + Assert.IsTrue(fastFilter.Evaluate((s) => new[] { "PerfTest" })); + Assert.IsTrue(fastFilter.Evaluate((s) => new[] { "UnitTest", "PerfTest" })); + Assert.IsTrue(fastFilter.Evaluate((s) => new[] { "UnitTest", "IntegrationTest" })); + Assert.IsFalse(fastFilter.Evaluate((s) => new[] { "IntegrationTest" })); + Assert.IsFalse(fastFilter.Evaluate((s) => null)); + } - [TestMethod] - public void FastFilterWithMultipleEqualsClauseAndRegexReplacement() - { - var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName=TestClass.Test1|FullyQualifiedName=TestClass.Test2|FullyQualifiedName=TestClass.Test3", new FilterOptions() { FilterRegEx = @"\s*\([^\)]*\)", FilterRegExReplacement = "" }); - var fastFilter = filterExpressionWrapper.fastFilter; - - var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "testclass.test1", "testclass.test2", "testclass.test3" }; - - Assert.IsTrue(fastFilter != null); - Assert.AreEqual("FullyQualifiedName", fastFilter.FilterProperties.Keys.Single()); - Assert.IsFalse(fastFilter.IsFilteredOutWhenMatched); - Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); - - Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName" }, null)); - - Assert.IsTrue(fastFilter.Evaluate((s) => "TestClass(1).Test1")); - Assert.IsTrue(fastFilter.Evaluate((s) => "TestClass().Test1()")); - Assert.IsTrue(fastFilter.Evaluate((s) => "TestClass(1, 2).Test2")); - Assert.IsTrue(fastFilter.Evaluate((s) => "TestClass.Test3 (abcd1234)")); - Assert.IsTrue(fastFilter.Evaluate((s) => "TestClass(1).Test1(123)")); - Assert.IsTrue(fastFilter.Evaluate((s) => "TestClass(1, 2).Test2(x:1, y:2, z:3)")); - Assert.IsTrue(fastFilter.Evaluate((s) => "TestClass(1, 2,3).Test3(1) (123)")); - Assert.IsFalse(fastFilter.Evaluate((s) => "TestClass1.Test1")); - Assert.IsFalse(fastFilter.Evaluate((s) => "TestClass1(1).Test1")); - Assert.IsFalse(fastFilter.Evaluate((s) => "TestClass((1, 2, 3)).Test1")); - } + [TestMethod] + public void FastFilterWithMultipleEqualsClauseAndRegexReplacement() + { + var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName=TestClass.Test1|FullyQualifiedName=TestClass.Test2|FullyQualifiedName=TestClass.Test3", new FilterOptions() { FilterRegEx = @"\s*\([^\)]*\)", FilterRegExReplacement = "" }); + var fastFilter = filterExpressionWrapper.FastFilter; + + var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "testclass.test1", "testclass.test2", "testclass.test3" }; + + Assert.IsTrue(fastFilter != null); + Assert.AreEqual("FullyQualifiedName", fastFilter.FilterProperties.Keys.Single()); + Assert.IsFalse(fastFilter.IsFilteredOutWhenMatched); + Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); + + Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName" }, null)); + + Assert.IsTrue(fastFilter.Evaluate((s) => "TestClass(1).Test1")); + Assert.IsTrue(fastFilter.Evaluate((s) => "TestClass().Test1()")); + Assert.IsTrue(fastFilter.Evaluate((s) => "TestClass(1, 2).Test2")); + Assert.IsTrue(fastFilter.Evaluate((s) => "TestClass.Test3 (abcd1234)")); + Assert.IsTrue(fastFilter.Evaluate((s) => "TestClass(1).Test1(123)")); + Assert.IsTrue(fastFilter.Evaluate((s) => "TestClass(1, 2).Test2(x:1, y:2, z:3)")); + Assert.IsTrue(fastFilter.Evaluate((s) => "TestClass(1, 2,3).Test3(1) (123)")); + Assert.IsFalse(fastFilter.Evaluate((s) => "TestClass1.Test1")); + Assert.IsFalse(fastFilter.Evaluate((s) => "TestClass1(1).Test1")); + Assert.IsFalse(fastFilter.Evaluate((s) => "TestClass((1, 2, 3)).Test1")); + } - [TestMethod] - public void FastFilterWithSingleNotEqualsClause() - { - var filterString = "FullyQualifiedName!=Test1"; - CheckFastFailureWithNotEqualClause(filterString); - } + [TestMethod] + public void FastFilterWithSingleNotEqualsClause() + { + var filterString = "FullyQualifiedName!=Test1"; + CheckFastFailureWithNotEqualClause(filterString); + } - [TestMethod] - public void FastFilterWithNotEqualsClauseAndDifferentCase() - { - var filterString = "FullyQualifiedName!=Test1&FullyQualifiedName!=test1"; - CheckFastFailureWithNotEqualClause(filterString); - } + [TestMethod] + public void FastFilterWithNotEqualsClauseAndDifferentCase() + { + var filterString = "FullyQualifiedName!=Test1&FullyQualifiedName!=test1"; + CheckFastFailureWithNotEqualClause(filterString); + } - private void CheckFastFailureWithNotEqualClause(string filterString) - { - var filterExpressionWrapper = new FilterExpressionWrapper(filterString); - var fastFilter = filterExpressionWrapper.fastFilter; + private void CheckFastFailureWithNotEqualClause(string filterString) + { + var filterExpressionWrapper = new FilterExpressionWrapper(filterString); + var fastFilter = filterExpressionWrapper.FastFilter; - var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "test1" }; + var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "test1" }; - Assert.IsTrue(fastFilter != null); - Assert.AreEqual("FullyQualifiedName", fastFilter.FilterProperties.Keys.Single()); - Assert.IsTrue(fastFilter.IsFilteredOutWhenMatched); - Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); + Assert.IsTrue(fastFilter != null); + Assert.AreEqual("FullyQualifiedName", fastFilter.FilterProperties.Keys.Single()); + Assert.IsTrue(fastFilter.IsFilteredOutWhenMatched); + Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); - Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName" }, null)); + Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName" }, null)); - Assert.IsFalse(fastFilter.Evaluate((s) => "Test1")); - Assert.IsTrue(fastFilter.Evaluate((s) => "Test2")); - } + Assert.IsFalse(fastFilter.Evaluate((s) => "Test1")); + Assert.IsTrue(fastFilter.Evaluate((s) => "Test2")); + } - [TestMethod] - public void FastFilterWithMultipleNotEqualsClause() - { - var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName!=Test1&FullyQualifiedName!=Test2&FullyQualifiedName!=Test3"); - var fastFilter = filterExpressionWrapper.fastFilter; + [TestMethod] + public void FastFilterWithMultipleNotEqualsClause() + { + var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName!=Test1&FullyQualifiedName!=Test2&FullyQualifiedName!=Test3"); + var fastFilter = filterExpressionWrapper.FastFilter; - var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "test1", "test2", "test3" }; + var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "test1", "test2", "test3" }; - Assert.IsTrue(fastFilter != null); - Assert.AreEqual("FullyQualifiedName", fastFilter.FilterProperties.Keys.Single()); - Assert.IsTrue(fastFilter.IsFilteredOutWhenMatched); - Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); + Assert.IsTrue(fastFilter != null); + Assert.AreEqual("FullyQualifiedName", fastFilter.FilterProperties.Keys.Single()); + Assert.IsTrue(fastFilter.IsFilteredOutWhenMatched); + Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); - Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName" }, null)); + Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName" }, null)); - Assert.IsFalse(fastFilter.Evaluate((s) => "Test1")); - Assert.IsFalse(fastFilter.Evaluate((s) => "Test2")); - Assert.IsFalse(fastFilter.Evaluate((s) => "Test3")); - Assert.IsTrue(fastFilter.Evaluate((s) => "Test4")); - } + Assert.IsFalse(fastFilter.Evaluate((s) => "Test1")); + Assert.IsFalse(fastFilter.Evaluate((s) => "Test2")); + Assert.IsFalse(fastFilter.Evaluate((s) => "Test3")); + Assert.IsTrue(fastFilter.Evaluate((s) => "Test4")); + } - [TestMethod] - public void FastFilterWithMultipleNotEqualsClauseAndRegex() - { - var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName!=Test1&FullyQualifiedName!=Test2&FullyQualifiedName!=Test3", new FilterOptions() { FilterRegEx = @"^[^\s\(]+" }); - var fastFilter = filterExpressionWrapper.fastFilter; - - var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "test1", "test2", "test3" }; - - Assert.IsTrue(fastFilter != null); - Assert.AreEqual("FullyQualifiedName", fastFilter.FilterProperties.Keys.Single()); - Assert.IsTrue(fastFilter.IsFilteredOutWhenMatched); - Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); - - Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName" }, null)); - - Assert.IsFalse(fastFilter.Evaluate((s) => "Test1")); - Assert.IsFalse(fastFilter.Evaluate((s) => "Test2")); - Assert.IsFalse(fastFilter.Evaluate((s) => "Test3")); - Assert.IsFalse(fastFilter.Evaluate((s) => "Test1 (123)")); - Assert.IsFalse(fastFilter.Evaluate((s) => "Test2(123)")); - Assert.IsFalse(fastFilter.Evaluate((s) => "Test3 (123)")); - Assert.IsTrue(fastFilter.Evaluate((s) => "Test4")); - Assert.IsTrue(fastFilter.Evaluate((s) => "Test4 (123)")); - } + [TestMethod] + public void FastFilterWithMultipleNotEqualsClauseAndRegex() + { + var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName!=Test1&FullyQualifiedName!=Test2&FullyQualifiedName!=Test3", new FilterOptions() { FilterRegEx = @"^[^\s\(]+" }); + var fastFilter = filterExpressionWrapper.FastFilter; + + var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "test1", "test2", "test3" }; + + Assert.IsTrue(fastFilter != null); + Assert.AreEqual("FullyQualifiedName", fastFilter.FilterProperties.Keys.Single()); + Assert.IsTrue(fastFilter.IsFilteredOutWhenMatched); + Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); + + Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName" }, null)); + + Assert.IsFalse(fastFilter.Evaluate((s) => "Test1")); + Assert.IsFalse(fastFilter.Evaluate((s) => "Test2")); + Assert.IsFalse(fastFilter.Evaluate((s) => "Test3")); + Assert.IsFalse(fastFilter.Evaluate((s) => "Test1 (123)")); + Assert.IsFalse(fastFilter.Evaluate((s) => "Test2(123)")); + Assert.IsFalse(fastFilter.Evaluate((s) => "Test3 (123)")); + Assert.IsTrue(fastFilter.Evaluate((s) => "Test4")); + Assert.IsTrue(fastFilter.Evaluate((s) => "Test4 (123)")); + } - [TestMethod] - public void FastFilterWithMultipleNotEqualsClauseForMultiplePropertyValues() - { - var filterExpressionWrapper = new FilterExpressionWrapper("Category!=UnitTest&Category!=PerfTest", null); - var fastFilter = filterExpressionWrapper.fastFilter; + [TestMethod] + public void FastFilterWithMultipleNotEqualsClauseForMultiplePropertyValues() + { + var filterExpressionWrapper = new FilterExpressionWrapper("Category!=UnitTest&Category!=PerfTest", null); + var fastFilter = filterExpressionWrapper.FastFilter; - var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "unittest", "perftest" }; + var expectedFilterValues = new HashSet(StringComparer.OrdinalIgnoreCase) { "unittest", "perftest" }; - Assert.IsTrue(fastFilter != null); - Assert.AreEqual("Category", fastFilter.FilterProperties.Keys.Single()); - Assert.IsTrue(fastFilter.IsFilteredOutWhenMatched); - Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); + Assert.IsTrue(fastFilter != null); + Assert.AreEqual("Category", fastFilter.FilterProperties.Keys.Single()); + Assert.IsTrue(fastFilter.IsFilteredOutWhenMatched); + Assert.IsTrue(expectedFilterValues.SetEquals(fastFilter.FilterProperties.Values.Single())); - Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "Category" }, null)); + Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "Category" }, null)); - Assert.IsFalse(fastFilter.Evaluate((s) => new[] { "UnitTest" })); - Assert.IsFalse(fastFilter.Evaluate((s) => new[] { "PerfTest" })); - Assert.IsFalse(fastFilter.Evaluate((s) => new[] { "UnitTest", "PerfTest" })); - Assert.IsFalse(fastFilter.Evaluate((s) => new[] { "UnitTest", "IntegrationTest" })); - Assert.IsTrue(fastFilter.Evaluate((s) => new[] { "IntegrationTest" })); - Assert.IsTrue(fastFilter.Evaluate((s) => null)); - } + Assert.IsFalse(fastFilter.Evaluate((s) => new[] { "UnitTest" })); + Assert.IsFalse(fastFilter.Evaluate((s) => new[] { "PerfTest" })); + Assert.IsFalse(fastFilter.Evaluate((s) => new[] { "UnitTest", "PerfTest" })); + Assert.IsFalse(fastFilter.Evaluate((s) => new[] { "UnitTest", "IntegrationTest" })); + Assert.IsTrue(fastFilter.Evaluate((s) => new[] { "IntegrationTest" })); + Assert.IsTrue(fastFilter.Evaluate((s) => null)); + } - [TestMethod] - public void FastFilterWithWithRegexParseErrorShouldNotCreateFastFilter() - { - var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName=Test", new FilterOptions() { FilterRegEx = @"^[^\s\(]+\1" }); + [TestMethod] + public void FastFilterWithWithRegexParseErrorShouldNotCreateFastFilter() + { + var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName=Test", new FilterOptions() { FilterRegEx = @"^[^\s\(]+\1" }); - Assert.IsNull(filterExpressionWrapper.fastFilter); - Assert.IsFalse(string.IsNullOrEmpty(filterExpressionWrapper.ParseError)); + Assert.IsNull(filterExpressionWrapper.FastFilter); + Assert.IsFalse(string.IsNullOrEmpty(filterExpressionWrapper.ParseError)); + } + + [TestMethod] + public void FastFilterShouldThrowExceptionForUnsupportedOperatorOperationCombination() + { + ImmutableHashSet.Builder filterHashSetBuilder = ImmutableHashSet.CreateBuilder(); + try + { + var filter = new FastFilter(ImmutableDictionary.CreateRange(new[] { new KeyValuePair>("dummyName", filterHashSetBuilder.ToImmutableHashSet()) }), Operation.Equal, Operator.And); } + catch (Exception ex) + { + Assert.IsTrue(ex is ArgumentException); + Assert.AreEqual("An error occurred while creating Fast filter.", ex.Message); + } + } - [TestMethod] - public void FastFilterShouldThrowExceptionForUnsupportedOperatorOperationCombination() + [TestMethod] + public void MultiplePropertyNamesEqualOr() + { + var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName=Test1|Category=IntegrationTest"); + var fastFilter = filterExpressionWrapper.FastFilter; + + var expectedFilterKeys = new HashSet(StringComparer.OrdinalIgnoreCase) { "Category", "FullyQualifiedName" }; + + Assert.IsNotNull(fastFilter); + Assert.IsTrue(expectedFilterKeys.SetEquals(fastFilter.FilterProperties.Keys)); + Assert.IsFalse(fastFilter.IsFilteredOutWhenMatched); + Assert.IsTrue(fastFilter.FilterProperties["FullyQualifiedName"].SequenceEqual(new[] { "Test1" })); + Assert.IsTrue(fastFilter.FilterProperties["Category"].SequenceEqual(new[] { "IntegrationTest" })); + + Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName", "Category" }, null)); + Assert.AreEqual("FullyQualifiedName", filterExpressionWrapper.ValidForProperties(new List() { "Category" }, null).Single()); + + Assert.IsFalse(fastFilter.Evaluate((s) => s == "Category" ? new[] { "UnitTest" } : null)); + Assert.IsFalse(fastFilter.Evaluate((s) => s == "Category" ? new[] { "PerfTest" } : null)); + Assert.IsFalse(fastFilter.Evaluate((s) => s == "Category" ? new[] { "UnitTest", "PerfTest" } : null)); + Assert.IsTrue(fastFilter.Evaluate((s) => s == "Category" ? new[] { "UnitTest", "IntegrationTest" } : null)); + Assert.IsTrue(fastFilter.Evaluate((s) => s == "Category" ? new[] { "IntegrationTest" } : null)); + Assert.IsTrue(fastFilter.Evaluate((s) => { - ImmutableHashSet.Builder filterHashSetBuilder = ImmutableHashSet.CreateBuilder(); - try + switch (s) { - var filter = new FastFilter(ImmutableDictionary.CreateRange(new[] { new KeyValuePair>("dummyName", filterHashSetBuilder.ToImmutableHashSet()) }), Operation.Equal, Operator.And); + case "Category": + return new[] { "UnitTest" }; + case "FullyQualifiedName": + return new[] { "Test1" }; + default: + return null; } - catch (Exception ex) + })); + Assert.IsFalse(fastFilter.Evaluate((s) => + { + switch (s) { - Assert.IsTrue(ex is ArgumentException); - Assert.AreEqual("An error occurred while creating Fast filter.", ex.Message); + case "Category": + return "UnitTest"; + case "FullyQualifiedName": + return "Test2"; + default: + return null; } - } - - [TestMethod] - public void MultiplePropertyNamesEqualOr() + })); + Assert.IsTrue(fastFilter.Evaluate((s) => { - var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName=Test1|Category=IntegrationTest"); - var fastFilter = filterExpressionWrapper.fastFilter; - - var expectedFilterKeys = new HashSet(StringComparer.OrdinalIgnoreCase) { "Category", "FullyQualifiedName" }; - - Assert.IsNotNull(fastFilter); - Assert.IsTrue(expectedFilterKeys.SetEquals(fastFilter.FilterProperties.Keys)); - Assert.IsFalse(fastFilter.IsFilteredOutWhenMatched); - Assert.IsTrue(fastFilter.FilterProperties["FullyQualifiedName"].SequenceEqual(new[] { "Test1" })); - Assert.IsTrue(fastFilter.FilterProperties["Category"].SequenceEqual(new[] { "IntegrationTest" })); - - Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName", "Category" }, null)); - Assert.AreEqual("FullyQualifiedName", filterExpressionWrapper.ValidForProperties(new List() { "Category" }, null).Single()); - - Assert.IsFalse(fastFilter.Evaluate((s) => s == "Category" ? new[] { "UnitTest" } : null)); - Assert.IsFalse(fastFilter.Evaluate((s) => s == "Category" ? new[] { "PerfTest" } : null)); - Assert.IsFalse(fastFilter.Evaluate((s) => s == "Category" ? new[] { "UnitTest", "PerfTest" } : null)); - Assert.IsTrue(fastFilter.Evaluate((s) => s == "Category" ? new[] { "UnitTest", "IntegrationTest" } : null)); - Assert.IsTrue(fastFilter.Evaluate((s) => s == "Category" ? new[] { "IntegrationTest" } : null)); - Assert.IsTrue(fastFilter.Evaluate((s) => - { - switch (s) - { - case "Category": - return new[] { "UnitTest" }; - case "FullyQualifiedName": - return new[] { "Test1" }; - default: - return null; - } - })); - Assert.IsFalse(fastFilter.Evaluate((s) => - { - switch (s) - { - case "Category": - return "UnitTest"; - case "FullyQualifiedName": - return "Test2"; - default: - return null; - } - })); - Assert.IsTrue(fastFilter.Evaluate((s) => + switch (s) { - switch (s) - { - case "Category": - return new[] { "IntegrationTest" }; - case "FullyQualifiedName": - return new[] { "Test2" }; - default: - return null; - } - })); - Assert.IsFalse(fastFilter.Evaluate((s) => null)); - } + case "Category": + return new[] { "IntegrationTest" }; + case "FullyQualifiedName": + return new[] { "Test2" }; + default: + return null; + } + })); + Assert.IsFalse(fastFilter.Evaluate((s) => null)); + } - [TestMethod] - public void MultiplePropertyNamesNotEqualAnd() - { - var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName!=Test1&Category!=IntegrationTest"); - var fastFilter = filterExpressionWrapper.fastFilter; + [TestMethod] + public void MultiplePropertyNamesNotEqualAnd() + { + var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName!=Test1&Category!=IntegrationTest"); + var fastFilter = filterExpressionWrapper.FastFilter; - var expectedFilterKeys = new HashSet(StringComparer.OrdinalIgnoreCase) { "Category", "FullyQualifiedName" }; + var expectedFilterKeys = new HashSet(StringComparer.OrdinalIgnoreCase) { "Category", "FullyQualifiedName" }; - Assert.IsNotNull(fastFilter); - Assert.IsTrue(expectedFilterKeys.SetEquals(fastFilter.FilterProperties.Keys)); - Assert.IsTrue(fastFilter.IsFilteredOutWhenMatched); - Assert.IsTrue(fastFilter.FilterProperties["FullyQualifiedName"].SequenceEqual(new[] { "Test1" })); - Assert.IsTrue(fastFilter.FilterProperties["Category"].SequenceEqual(new[] { "IntegrationTest" })); + Assert.IsNotNull(fastFilter); + Assert.IsTrue(expectedFilterKeys.SetEquals(fastFilter.FilterProperties.Keys)); + Assert.IsTrue(fastFilter.IsFilteredOutWhenMatched); + Assert.IsTrue(fastFilter.FilterProperties["FullyQualifiedName"].SequenceEqual(new[] { "Test1" })); + Assert.IsTrue(fastFilter.FilterProperties["Category"].SequenceEqual(new[] { "IntegrationTest" })); - Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName", "Category" }, null)); - Assert.AreEqual("FullyQualifiedName", filterExpressionWrapper.ValidForProperties(new List() { "Category" }, null).Single()); + Assert.IsNull(filterExpressionWrapper.ValidForProperties(new List() { "FullyQualifiedName", "Category" }, null)); + Assert.AreEqual("FullyQualifiedName", filterExpressionWrapper.ValidForProperties(new List() { "Category" }, null).Single()); - Assert.IsTrue(fastFilter.Evaluate((s) => s == "Category" ? new[] { "UnitTest" } : null)); - Assert.IsFalse(fastFilter.Evaluate((s) => s == "Category" ? new[] { "UnitTest", "IntegrationTest" } : null)); - Assert.IsFalse(fastFilter.Evaluate((s) => s == "Category" ? new[] { "IntegrationTest" } : null)); - Assert.IsFalse(fastFilter.Evaluate((s) => + Assert.IsTrue(fastFilter.Evaluate((s) => s == "Category" ? new[] { "UnitTest" } : null)); + Assert.IsFalse(fastFilter.Evaluate((s) => s == "Category" ? new[] { "UnitTest", "IntegrationTest" } : null)); + Assert.IsFalse(fastFilter.Evaluate((s) => s == "Category" ? new[] { "IntegrationTest" } : null)); + Assert.IsFalse(fastFilter.Evaluate((s) => + { + switch (s) { - switch (s) - { - case "Category": - return new[] { "UnitTest" }; - case "FullyQualifiedName": - return new[] { "Test1" }; - default: - return null; - } - })); - Assert.IsFalse(fastFilter.Evaluate((s) => + case "Category": + return new[] { "UnitTest" }; + case "FullyQualifiedName": + return new[] { "Test1" }; + default: + return null; + } + })); + Assert.IsFalse(fastFilter.Evaluate((s) => + { + switch (s) { - switch (s) - { - case "Category": - return new[] { "IntegrationTest" }; - case "FullyQualifiedName": - return new[] { "Test2" }; - default: - return null; - } - })); - Assert.IsTrue(fastFilter.Evaluate((s) => + case "Category": + return new[] { "IntegrationTest" }; + case "FullyQualifiedName": + return new[] { "Test2" }; + default: + return null; + } + })); + Assert.IsTrue(fastFilter.Evaluate((s) => + { + switch (s) { - switch (s) - { - case "Category": - return new[] { "UnitTest" }; - case "FullyQualifiedName": - return new[] { "Test2" }; - default: - return null; - } - })); - } + case "Category": + return new[] { "UnitTest" }; + case "FullyQualifiedName": + return new[] { "Test2" }; + default: + return null; + } + })); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/Filtering/FilterExpressionTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/Filtering/FilterExpressionTests.cs index 5d53fcefbf..2cda5fe301 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/Filtering/FilterExpressionTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/Filtering/FilterExpressionTests.cs @@ -1,101 +1,102 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Common.UnitTests.Filtering +namespace Microsoft.TestPlatform.Common.UnitTests.Filtering; + +using System; +using System.Linq; + +using Microsoft.VisualStudio.TestPlatform.Common.Filtering; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class FilterExpressionTests { - using System; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.Common.Filtering; - using Microsoft.VisualStudio.TestTools.UnitTesting; + [TestMethod] + public void TokenizeNullThrowsArgumentNullException() + { + Assert.ThrowsException(() => FilterExpression.TokenizeFilterExpressionString(null), "str"); + } + + [TestMethod] + public void TokenizeFilterShouldHandleEscapedParenthesis() + { + var conditionString = @"(T1\(\) | T2\(\))"; + + var tokens = FilterExpression.TokenizeFilterExpressionString(conditionString).ToArray(); + + Assert.AreEqual(5, tokens.Length); + Assert.AreEqual("(", tokens[0]); + Assert.AreEqual(@"T1\(\) ", tokens[1]); + Assert.AreEqual(@"|", tokens[2]); + Assert.AreEqual(@" T2\(\)", tokens[3]); + Assert.AreEqual(")", tokens[4]); + } + + [TestMethod] + public void TokenizeFilterShouldHandleEmptyParenthesis() + { + var conditionString = @" ( ) "; - [TestClass] - public class FilterExpressionTests + var tokens = FilterExpression.TokenizeFilterExpressionString(conditionString).ToArray(); + + Assert.AreEqual(5, tokens.Length); + Assert.AreEqual(" ", tokens[0]); + Assert.AreEqual("(", tokens[1]); + Assert.AreEqual(" ", tokens[2]); + Assert.AreEqual(")", tokens[3]); + Assert.AreEqual(" ", tokens[4]); + } + + [TestMethod] + public void TokenizeFilterShouldHandleEscapedBackslash() { - [TestMethod] - public void TokenizeNullThrowsArgumentNullException() - { - Assert.ThrowsException(() => FilterExpression.TokenizeFilterExpressionString(null), "str"); - } - - [TestMethod] - public void TokenizeFilterShouldHandleEscapedParenthesis() - { - var conditionString = @"(T1\(\) | T2\(\))"; - - var tokens = FilterExpression.TokenizeFilterExpressionString(conditionString).ToArray(); - - Assert.AreEqual(5, tokens.Length); - Assert.AreEqual("(", tokens[0]); - Assert.AreEqual(@"T1\(\) ", tokens[1]); - Assert.AreEqual(@"|", tokens[2]); - Assert.AreEqual(@" T2\(\)", tokens[3]); - Assert.AreEqual(")", tokens[4]); - } - - [TestMethod] - public void TokenizeFilterShouldHandleEmptyParenthesis() - { - var conditionString = @" ( ) "; - - var tokens = FilterExpression.TokenizeFilterExpressionString(conditionString).ToArray(); - - Assert.AreEqual(5, tokens.Length); - Assert.AreEqual(" ", tokens[0]); - Assert.AreEqual("(", tokens[1]); - Assert.AreEqual(" ", tokens[2]); - Assert.AreEqual(")", tokens[3]); - Assert.AreEqual(" ", tokens[4]); - } - - [TestMethod] - public void TokenizeFilterShouldHandleEscapedBackslash() - { - var conditionString = @"(FQN!=T1\(""\\""\) | FQN!=T2\(\))"; - - var tokens = FilterExpression.TokenizeFilterExpressionString(conditionString).ToArray(); - - Assert.AreEqual(5, tokens.Length); - Assert.AreEqual("(", tokens[0]); - Assert.AreEqual(@"FQN!=T1\(""\\""\) ", tokens[1]); - Assert.AreEqual(@"|", tokens[2]); - Assert.AreEqual(@" FQN!=T2\(\)", tokens[3]); - Assert.AreEqual(")", tokens[4]); - } - - [TestMethod] - public void TokenizeFilterShouldHandleNestedParenthesis() - { - var conditionString = @"((FQN!=T1|FQN!=T2)&(Category=Foo\(\)))"; - - var tokens = FilterExpression.TokenizeFilterExpressionString(conditionString).ToArray(); - - Assert.AreEqual(11, tokens.Length); - Assert.AreEqual("(", tokens[0]); - Assert.AreEqual("(", tokens[1]); - Assert.AreEqual(@"FQN!=T1", tokens[2]); - Assert.AreEqual(@"|", tokens[3]); - Assert.AreEqual(@"FQN!=T2", tokens[4]); - Assert.AreEqual(")", tokens[5]); - Assert.AreEqual("&", tokens[6]); - Assert.AreEqual("(", tokens[7]); - Assert.AreEqual(@"Category=Foo\(\)", tokens[8]); - Assert.AreEqual(")", tokens[9]); - Assert.AreEqual(")", tokens[10]); - } - - [TestMethod] - public void TokenizeFilterShouldHandleInvalidEscapeSequence() - { - var conditionString = @"(T1\#\#)|T2\)"; - - var tokens = FilterExpression.TokenizeFilterExpressionString(conditionString).ToArray(); - - Assert.AreEqual(5, tokens.Length); - Assert.AreEqual("(", tokens[0]); - Assert.AreEqual(@"T1\#\#", tokens[1]); - Assert.AreEqual(@")", tokens[2]); - Assert.AreEqual(@"|", tokens[3]); - Assert.AreEqual(@"T2\)", tokens[4]); - } + var conditionString = @"(FQN!=T1\(""\\""\) | FQN!=T2\(\))"; + + var tokens = FilterExpression.TokenizeFilterExpressionString(conditionString).ToArray(); + + Assert.AreEqual(5, tokens.Length); + Assert.AreEqual("(", tokens[0]); + Assert.AreEqual(@"FQN!=T1\(""\\""\) ", tokens[1]); + Assert.AreEqual(@"|", tokens[2]); + Assert.AreEqual(@" FQN!=T2\(\)", tokens[3]); + Assert.AreEqual(")", tokens[4]); + } + + [TestMethod] + public void TokenizeFilterShouldHandleNestedParenthesis() + { + var conditionString = @"((FQN!=T1|FQN!=T2)&(Category=Foo\(\)))"; + + var tokens = FilterExpression.TokenizeFilterExpressionString(conditionString).ToArray(); + + Assert.AreEqual(11, tokens.Length); + Assert.AreEqual("(", tokens[0]); + Assert.AreEqual("(", tokens[1]); + Assert.AreEqual(@"FQN!=T1", tokens[2]); + Assert.AreEqual(@"|", tokens[3]); + Assert.AreEqual(@"FQN!=T2", tokens[4]); + Assert.AreEqual(")", tokens[5]); + Assert.AreEqual("&", tokens[6]); + Assert.AreEqual("(", tokens[7]); + Assert.AreEqual(@"Category=Foo\(\)", tokens[8]); + Assert.AreEqual(")", tokens[9]); + Assert.AreEqual(")", tokens[10]); + } + + [TestMethod] + public void TokenizeFilterShouldHandleInvalidEscapeSequence() + { + var conditionString = @"(T1\#\#)|T2\)"; + + var tokens = FilterExpression.TokenizeFilterExpressionString(conditionString).ToArray(); + + Assert.AreEqual(5, tokens.Length); + Assert.AreEqual("(", tokens[0]); + Assert.AreEqual(@"T1\#\#", tokens[1]); + Assert.AreEqual(@")", tokens[2]); + Assert.AreEqual(@"|", tokens[3]); + Assert.AreEqual(@"T2\)", tokens[4]); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/Filtering/TestCaseFilterExpressionTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/Filtering/TestCaseFilterExpressionTests.cs index 521ea6a9a0..f5999269ab 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/Filtering/TestCaseFilterExpressionTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/Filtering/TestCaseFilterExpressionTests.cs @@ -2,29 +2,30 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Common.UnitTests.Filtering +namespace Microsoft.TestPlatform.Common.UnitTests.Filtering; + +using System.Collections.Generic; +using System.Linq; + +using Microsoft.VisualStudio.TestPlatform.Common.Filtering; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class TestCaseFilterExpressionTests { - using System.Collections.Generic; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.Common.Filtering; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class TestCaseFilterExpressionTests + [TestMethod] + public void ValidForPropertiesShouldNotSetvalidForMatchVariableTofalseIfFilterIsInvalid() { - [TestMethod] - public void ValidForPropertiesShouldNotSetvalidForMatchVariableTofalseIfFilterIsInvalid() - { - var filterExpressionWrapper = new FilterExpressionWrapper("highlyunlikelyproperty=unused"); - var testCaseFilterExpression = new TestCaseFilterExpression(filterExpressionWrapper); + var filterExpressionWrapper = new FilterExpressionWrapper("highlyunlikelyproperty=unused"); + var testCaseFilterExpression = new TestCaseFilterExpression(filterExpressionWrapper); - Assert.AreEqual("highlyunlikelyproperty", testCaseFilterExpression.ValidForProperties(new List() { "TestCategory" }, (s) => { return null; }).Single()); + Assert.AreEqual("highlyunlikelyproperty", testCaseFilterExpression.ValidForProperties(new List() { "TestCategory" }, (s) => null).Single()); - TestCase dummyTestCase = new TestCase(); - bool result = testCaseFilterExpression.MatchTestCase(dummyTestCase, (s) => { return "unused"; }); + TestCase dummyTestCase = new(); + bool result = testCaseFilterExpression.MatchTestCase(dummyTestCase, (s) => "unused"); - Assert.IsTrue(result); - } + Assert.IsTrue(result); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/Hosting/TestHostExtensionManagerTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/Hosting/TestHostExtensionManagerTests.cs index 01c5030094..936a3086fc 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/Hosting/TestHostExtensionManagerTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/Hosting/TestHostExtensionManagerTests.cs @@ -1,44 +1,44 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.Logging -{ - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common.Hosting; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System; +namespace TestPlatform.Common.UnitTests.Logging; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common.Hosting; +using Microsoft.VisualStudio.TestPlatform.Common.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using System; - [TestClass] - public class TestHostExtensionManagerTests +[TestClass] +public class TestHostExtensionManagerTests +{ + [TestInitialize] + public void Initialize() + { + TestPluginCacheHelper.SetupMockExtensions(typeof(TestHostExtensionManagerTests)); + } + [TestMethod] + public void CreateShouldThrowExceptionIfMessageLoggerIsNull() { - [TestInitialize] - public void Initialize() + Assert.ThrowsException(() => { - TestPluginCacheHelper.SetupMockExtensions(typeof(TestHostExtensionManagerTests)); - } - [TestMethod] - public void CreateShouldThrowExceptionIfMessageLoggerIsNull() + var testLoggerExtensionManager = TestRuntimeExtensionManager.Create(null); + }); + } + + [TestMethod] + public void CreateShouldReturnInstanceOfTestLoggerExtensionManager() + { + try { - Assert.ThrowsException(() => - { - var testLoggerExtensionManager = TestRuntimeExtensionManager.Create(null); - }); + var testLoggerExtensionManager = TestRuntimeExtensionManager.Create(TestSessionMessageLogger.Instance); + Assert.IsNotNull(testLoggerExtensionManager); + Assert.IsInstanceOfType(testLoggerExtensionManager, typeof(TestRuntimeExtensionManager)); } - - [TestMethod] - public void CreateShouldReturnInstanceOfTestLoggerExtensionManager() + finally { - try - { - var testLoggerExtensionManager = TestRuntimeExtensionManager.Create(TestSessionMessageLogger.Instance); - Assert.IsNotNull(testLoggerExtensionManager); - Assert.IsInstanceOfType(testLoggerExtensionManager, typeof(TestRuntimeExtensionManager)); - } - finally - { - TestSessionMessageLogger.Instance = null; - } + TestSessionMessageLogger.Instance = null; } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/Hosting/TestHostProviderManagerTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/Hosting/TestHostProviderManagerTests.cs index d8e1ce85b6..916b4d0e6b 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/Hosting/TestHostProviderManagerTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/Hosting/TestHostProviderManagerTests.cs @@ -1,50 +1,51 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.Logging +namespace TestPlatform.Common.UnitTests.Logging; + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common.Hosting; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +/// +/// Tests the behaviors of the TestLoggerManager class. +/// +[TestClass] +public class TestHostProviderManagerTests { - using System; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common.Hosting; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - /// - /// Tests the behaviors of the TestLoggerManager class. - /// - [TestClass] - public class TestHostProviderManagerTests + public TestHostProviderManagerTests() { - public TestHostProviderManagerTests() - { - TestPluginCacheHelper.SetupMockExtensions(typeof(TestHostProviderManagerTests)); - } + TestPluginCacheHelper.SetupMockExtensions(typeof(TestHostProviderManagerTests)); + } - [TestMethod] - public void TestHostProviderManagerShouldReturnTestHostWhenAppropriateCustomUriProvided() - { - var manager = TestRuntimeProviderManager.Instance; - Assert.IsNotNull(manager.GetTestHostManagerByUri("executor://DesktopTestHost/")); - } + [TestMethod] + public void TestHostProviderManagerShouldReturnTestHostWhenAppropriateCustomUriProvided() + { + var manager = TestRuntimeProviderManager.Instance; + Assert.IsNotNull(manager.GetTestHostManagerByUri("executor://DesktopTestHost/")); + } - [TestMethod] - public void TestHostProviderManagerShouldReturnNullWhenInvalidCustomUriProvided() - { - var manager = TestRuntimeProviderManager.Instance; - Assert.IsNull(manager.GetTestHostManagerByUri("executor://InvalidHost/")); - } + [TestMethod] + public void TestHostProviderManagerShouldReturnNullWhenInvalidCustomUriProvided() + { + var manager = TestRuntimeProviderManager.Instance; + Assert.IsNull(manager.GetTestHostManagerByUri("executor://InvalidHost/")); + } - [TestMethod] - public void TestHostProviderManagerShouldReturnTestHostBasedOnRunConfiguration() - { - string runSettingsXml = @" + [TestMethod] + public void TestHostProviderManagerShouldReturnTestHostBasedOnRunConfiguration() + { + string runSettingsXml = @" 0 @@ -53,87 +54,87 @@ public void TestHostProviderManagerShouldReturnTestHostBasedOnRunConfiguration() "; - var manager = TestRuntimeProviderManager.Instance; - Assert.IsNotNull(manager.GetTestHostManagerByRunConfiguration(runSettingsXml)); - } + var manager = TestRuntimeProviderManager.Instance; + Assert.IsNotNull(manager.GetTestHostManagerByRunConfiguration(runSettingsXml)); + } - [TestMethod] - public void GetDefaultTestHostManagerReturnsANonNullInstance() - { - string runSettingsXml = string.Concat( - @" + [TestMethod] + public void GetDefaultTestHostManagerReturnsANonNullInstance() + { + string runSettingsXml = string.Concat( + @" 0 x86 ", - Framework.DefaultFramework.Name, - " "); + Framework.DefaultFramework.Name, + " "); - Assert.IsNotNull(TestRuntimeProviderManager.Instance.GetTestHostManagerByRunConfiguration(runSettingsXml)); - } + Assert.IsNotNull(TestRuntimeProviderManager.Instance.GetTestHostManagerByRunConfiguration(runSettingsXml)); + } - [TestMethod] - public void GetDefaultTestHostManagerReturnsANewInstanceEverytime() - { - string runSettingsXml = string.Concat( - @" + [TestMethod] + public void GetDefaultTestHostManagerReturnsANewInstanceEverytime() + { + string runSettingsXml = string.Concat( + @" 0 x86 ", - Framework.DefaultFramework.Name, - " "); + Framework.DefaultFramework.Name, + " "); - var instance1 = TestRuntimeProviderManager.Instance.GetTestHostManagerByRunConfiguration(runSettingsXml); - var instance2 = TestRuntimeProviderManager.Instance.GetTestHostManagerByRunConfiguration(runSettingsXml); + var instance1 = TestRuntimeProviderManager.Instance.GetTestHostManagerByRunConfiguration(runSettingsXml); + var instance2 = TestRuntimeProviderManager.Instance.GetTestHostManagerByRunConfiguration(runSettingsXml); - Assert.AreNotEqual(instance1, instance2); - } + Assert.AreNotEqual(instance1, instance2); + } - [TestMethod] - public void GetDefaultTestHostManagerReturnsDotnetCoreHostManagerIfFrameworkIsNetCore() - { - string runSettingsXml = string.Concat( - @" + [TestMethod] + public void GetDefaultTestHostManagerReturnsDotnetCoreHostManagerIfFrameworkIsNetCore() + { + string runSettingsXml = string.Concat( + @" 0 x64 ", - ".NETCoreApp,Version=v1.0", - " "); + ".NETCoreApp,Version=v1.0", + " "); - var testHostManager = TestRuntimeProviderManager.Instance.GetTestHostManagerByRunConfiguration(runSettingsXml); + var testHostManager = TestRuntimeProviderManager.Instance.GetTestHostManagerByRunConfiguration(runSettingsXml); - Assert.AreEqual(typeof(TestableTestHostManager), testHostManager.GetType()); - } + Assert.AreEqual(typeof(TestableTestHostManager), testHostManager.GetType()); + } - [TestMethod] - public void GetDefaultTestHostManagerReturnsASharedManagerIfDisableAppDomainIsFalse() - { - string runSettingsXml = string.Concat( - @" + [TestMethod] + public void GetDefaultTestHostManagerReturnsASharedManagerIfDisableAppDomainIsFalse() + { + string runSettingsXml = string.Concat( + @" 0 x86 ", - ".NETFramework,Version=v4.5.1", - " "); + ".NETFramework,Version=v4.5.1", + " "); - var testHostManager = TestRuntimeProviderManager.Instance.GetTestHostManagerByRunConfiguration(runSettingsXml); - testHostManager.Initialize(null, runSettingsXml); - Assert.IsNotNull(testHostManager); + var testHostManager = TestRuntimeProviderManager.Instance.GetTestHostManagerByRunConfiguration(runSettingsXml); + testHostManager.Initialize(null, runSettingsXml); + Assert.IsNotNull(testHostManager); - Assert.IsTrue(testHostManager.Shared, "Default TestHostManager must be shared if DisableAppDomain is false"); - } + Assert.IsTrue(testHostManager.Shared, "Default TestHostManager must be shared if DisableAppDomain is false"); + } - [TestMethod] - public void GetDefaultTestHostManagerReturnsANonSharedManagerIfDisableAppDomainIsTrue() - { - string runSettingsXml = string.Concat( - @" + [TestMethod] + public void GetDefaultTestHostManagerReturnsANonSharedManagerIfDisableAppDomainIsTrue() + { + string runSettingsXml = string.Concat( + @" 0 x86 ", - ".NETFramework,Version=v4.5.1", - "true "); + ".NETFramework,Version=v4.5.1", + "true "); - var testHostManager = TestRuntimeProviderManager.Instance.GetTestHostManagerByRunConfiguration(runSettingsXml); - testHostManager.Initialize(null, runSettingsXml); - Assert.IsNotNull(testHostManager); + var testHostManager = TestRuntimeProviderManager.Instance.GetTestHostManagerByRunConfiguration(runSettingsXml); + testHostManager.Initialize(null, runSettingsXml); + Assert.IsNotNull(testHostManager); - Assert.IsFalse(testHostManager.Shared, "Default TestHostManager must NOT be shared if DisableAppDomain is true"); - } + Assert.IsFalse(testHostManager.Shared, "Default TestHostManager must NOT be shared if DisableAppDomain is true"); + } - [TestMethod] - public void TestHostProviderManagerShouldReturnNullIfTargetFrameworkIsPortable() - { - string runSettingsXml = @" + [TestMethod] + public void TestHostProviderManagerShouldReturnNullIfTargetFrameworkIsPortable() + { + string runSettingsXml = @" 0 @@ -142,169 +143,157 @@ public void TestHostProviderManagerShouldReturnNullIfTargetFrameworkIsPortable() "; - var manager = TestRuntimeProviderManager.Instance; - Assert.IsNull(manager.GetTestHostManagerByRunConfiguration(runSettingsXml)); + var manager = TestRuntimeProviderManager.Instance; + Assert.IsNull(manager.GetTestHostManagerByRunConfiguration(runSettingsXml)); + } + + #region Implementations + + [ExtensionUri("executor://DesktopTestHost")] + [FriendlyName("DesktopTestHost")] + private class CustomTestHost : ITestRuntimeProvider + { + public event EventHandler HostLaunched; + + public event EventHandler HostExited; + + public bool Shared { get; private set; } + + + public bool CanExecuteCurrentRunConfiguration(string runsettingsXml) + { + var config = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettingsXml); + var framework = config.TargetFramework; + Shared = !config.DisableAppDomain; + + // This is expected to be called once every run so returning a new instance every time. + return framework.Name.IndexOf("netframework", StringComparison.OrdinalIgnoreCase) >= 0; + } + + public TestProcessStartInfo GetTestHostProcessStartInfo(IEnumerable sources, IDictionary environmentVariables, TestRunnerConnectionInfo connectionInfo) + { + throw new NotImplementedException(); + } + + public IEnumerable GetTestPlatformExtensions(IEnumerable sources, IEnumerable extensions) + { + throw new NotImplementedException(); + } + + public IEnumerable GetTestSources(IEnumerable sources) + { + return sources; + } + + public void Initialize(IMessageLogger logger, string runsettingsXml) + { + var config = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettingsXml); + Shared = !config.DisableAppDomain; + } + + public Task LaunchTestHostAsync(TestProcessStartInfo testHostStartInfo, CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } + + public void OnHostExited(HostProviderEventArgs e) + { + HostExited.Invoke(this, new HostProviderEventArgs("Error")); + } + + public void OnHostLaunched(HostProviderEventArgs e) + { + HostLaunched.Invoke(this, new HostProviderEventArgs("Error")); + } + + public void SetCustomLauncher(ITestHostLauncher customLauncher) + { + throw new NotImplementedException(); + } + + public Task CleanTestHostAsync(CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } + + public TestHostConnectionInfo GetTestHostConnectionInfo() + { + throw new NotImplementedException(); + } + } + + [ExtensionUri("executor://NetCoreTestHost")] + [FriendlyName("NetCoreTestHost")] + private class TestableTestHostManager : ITestRuntimeProvider + { + public event EventHandler HostLaunched; + + public event EventHandler HostExited; + + public bool Shared { get; private set; } + + public bool CanExecuteCurrentRunConfiguration(string runsettingsXml) + { + var config = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettingsXml); + var framework = config.TargetFramework; + Shared = !config.DisableAppDomain; + + // This is expected to be called once every run so returning a new instance every time. + return framework.Name.IndexOf("netstandard", StringComparison.OrdinalIgnoreCase) >= 0 + || framework.Name.IndexOf("netcoreapp", StringComparison.OrdinalIgnoreCase) >= 0; + } + + public TestProcessStartInfo GetTestHostProcessStartInfo(IEnumerable sources, IDictionary environmentVariables, TestRunnerConnectionInfo connectionInfo) + { + throw new NotImplementedException(); } - #region Implementations + public IEnumerable GetTestPlatformExtensions(IEnumerable sources, IEnumerable extensions) + { + throw new NotImplementedException(); + } - [ExtensionUri("executor://DesktopTestHost")] - [FriendlyName("DesktopTestHost")] - private class CustomTestHost : ITestRuntimeProvider + public void Initialize(IMessageLogger logger, string runsettingsXml) { - public event EventHandler HostLaunched; - - public event EventHandler HostExited; - - public bool Shared { get; private set; } - - - public bool CanExecuteCurrentRunConfiguration(string runsettingsXml) - { - var config = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettingsXml); - var framework = config.TargetFramework; - this.Shared = !config.DisableAppDomain; - - // This is expected to be called once every run so returning a new instance every time. - if (framework.Name.IndexOf("netframework", StringComparison.OrdinalIgnoreCase) >= 0) - { - return true; - } - - return false; - } - - public TestProcessStartInfo GetTestHostProcessStartInfo(IEnumerable sources, IDictionary environmentVariables, TestRunnerConnectionInfo connectionInfo) - { - throw new NotImplementedException(); - } - - public IEnumerable GetTestPlatformExtensions(IEnumerable sources, IEnumerable extensions) - { - throw new NotImplementedException(); - } - - public IEnumerable GetTestSources(IEnumerable sources) - { - return sources; - } - - public void Initialize(IMessageLogger logger, string runsettingsXml) - { - var config = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettingsXml); - this.Shared = !config.DisableAppDomain; - } - - public Task LaunchTestHostAsync(TestProcessStartInfo testHostStartInfo, CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } - - public void OnHostExited(HostProviderEventArgs e) - { - this.HostExited.Invoke(this, new HostProviderEventArgs("Error")); - } - - public void OnHostLaunched(HostProviderEventArgs e) - { - this.HostLaunched.Invoke(this, new HostProviderEventArgs("Error")); - } - - public void SetCustomLauncher(ITestHostLauncher customLauncher) - { - throw new NotImplementedException(); - } - - public Task CleanTestHostAsync(CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } - - public TestHostConnectionInfo GetTestHostConnectionInfo() - { - throw new NotImplementedException(); - } + var config = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettingsXml); + Shared = !config.DisableAppDomain; } - [ExtensionUri("executor://NetCoreTestHost")] - [FriendlyName("NetCoreTestHost")] - private class TestableTestHostManager : ITestRuntimeProvider + public Task LaunchTestHostAsync(TestProcessStartInfo testHostStartInfo, CancellationToken cancellationToken) { - public event EventHandler HostLaunched; - - public event EventHandler HostExited; - - public bool Shared { get; private set; } - - public bool CanExecuteCurrentRunConfiguration(string runsettingsXml) - { - var config = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettingsXml); - var framework = config.TargetFramework; - this.Shared = !config.DisableAppDomain; - - // This is expected to be called once every run so returning a new instance every time. - if (framework.Name.IndexOf("netstandard", StringComparison.OrdinalIgnoreCase) >= 0 - || framework.Name.IndexOf("netcoreapp", StringComparison.OrdinalIgnoreCase) >= 0) - { - return true; - } - - return false; - } - - public TestProcessStartInfo GetTestHostProcessStartInfo(IEnumerable sources, IDictionary environmentVariables, TestRunnerConnectionInfo connectionInfo) - { - throw new NotImplementedException(); - } - - public IEnumerable GetTestPlatformExtensions(IEnumerable sources, IEnumerable extensions) - { - throw new NotImplementedException(); - } - - public void Initialize(IMessageLogger logger, string runsettingsXml) - { - var config = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettingsXml); - this.Shared = !config.DisableAppDomain; - } - - public Task LaunchTestHostAsync(TestProcessStartInfo testHostStartInfo, CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } - - public void OnHostExited(HostProviderEventArgs e) - { - this.HostExited.Invoke(this, new HostProviderEventArgs("Error")); - } - - public void OnHostLaunched(HostProviderEventArgs e) - { - this.HostLaunched.Invoke(this, new HostProviderEventArgs("Error")); - } - - public void SetCustomLauncher(ITestHostLauncher customLauncher) - { - throw new NotImplementedException(); - } - - public Task CleanTestHostAsync(CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } - - public TestHostConnectionInfo GetTestHostConnectionInfo() - { - throw new NotImplementedException(); - } - - public IEnumerable GetTestSources(IEnumerable sources) - { - return sources; - } + throw new NotImplementedException(); } - #endregion + public void OnHostExited(HostProviderEventArgs e) + { + HostExited.Invoke(this, new HostProviderEventArgs("Error")); + } + + public void OnHostLaunched(HostProviderEventArgs e) + { + HostLaunched.Invoke(this, new HostProviderEventArgs("Error")); + } + + public void SetCustomLauncher(ITestHostLauncher customLauncher) + { + throw new NotImplementedException(); + } + + public Task CleanTestHostAsync(CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } + + public TestHostConnectionInfo GetTestHostConnectionInfo() + { + throw new NotImplementedException(); + } + + public IEnumerable GetTestSources(IEnumerable sources) + { + return sources; + } } -} + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/Logging/InternalTestLoggerEventsTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/Logging/InternalTestLoggerEventsTests.cs index b1e368757b..780b158ca2 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/Logging/InternalTestLoggerEventsTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/Logging/InternalTestLoggerEventsTests.cs @@ -1,571 +1,512 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Common.UnitTests.Logging +namespace Microsoft.TestPlatform.Common.UnitTests.Logging; + +using System; +using System.Collections.Generic; +using System.Threading; + +using Microsoft.VisualStudio.TestPlatform.Common.Logging; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +using VisualStudio.TestTools.UnitTesting; + +using TestResult = VisualStudio.TestPlatform.ObjectModel.TestResult; + +[TestClass] +public class InternalTestLoggerEventsBehaviors { - using System; - using System.Collections.Generic; - using System.Threading; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; + private TestSessionMessageLogger _testSessionMessageLogger; + private InternalTestLoggerEvents _loggerEvents; - using TestResult = Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult; + [TestInitialize] + public void Initialize() + { + _testSessionMessageLogger = TestSessionMessageLogger.Instance; + _loggerEvents = new InternalTestLoggerEvents(_testSessionMessageLogger); + } - [TestClass] - public class InternalTestLoggerEventsBehaviors + [TestCleanup] + public void Dispose() { - private TestSessionMessageLogger testSessionMessageLogger; - private InternalTestLoggerEvents loggerEvents; + _loggerEvents.Dispose(); + TestSessionMessageLogger.Instance = null; + } - [TestInitialize] - public void Initialize() - { - testSessionMessageLogger = TestSessionMessageLogger.Instance; - loggerEvents = new InternalTestLoggerEvents(testSessionMessageLogger); - } + [TestMethod] + public void RaiseTestRunMessageShouldNotThrowExceptionIfNoEventHandlersAreRegistered() + { + // Send the test message event. + _loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Informational, "This is a string.")); + } - [TestCleanup] - public void Dispose() - { - loggerEvents.Dispose(); - TestSessionMessageLogger.Instance = null; - } + [TestMethod] + public void RaiseTestRunMessageShouldInvokeRegisteredEventHandlerIfTestRunMessageEventArgsIsPassed() + { + EventWaitHandle waitHandle = new AutoResetEvent(false); + bool testMessageReceived = false; + TestRunMessageEventArgs eventArgs = null; + var message = "This is the test message"; + + // Register for the test message event. + _loggerEvents.TestRunMessage += (sender, e) => + { + testMessageReceived = true; + eventArgs = e; + waitHandle.Set(); + }; + + _loggerEvents.EnableEvents(); + // Send the test message event. + _loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Informational, message)); + + var waitSuccess = waitHandle.WaitOne(500); + Assert.IsTrue(waitSuccess, "Event must be raised within timeout."); + + Assert.IsTrue(testMessageReceived); + Assert.IsNotNull(eventArgs); + Assert.AreEqual(message, eventArgs.Message); + Assert.AreEqual(TestMessageLevel.Informational, eventArgs.Level); + } - [TestMethod] - public void RaiseTestRunMessageShouldNotThrowExceptionIfNoEventHandlersAreRegistered() - { - // Send the test message event. - loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Informational,"This is a string.")); - } + [TestMethod] + public void RaiseTestResultShouldInvokeRegisteredEventHandlerIfTestResultEventArgsIsPassed() + { + EventWaitHandle waitHandle = new AutoResetEvent(false); + bool testResultReceived = false; + TestResultEventArgs eventArgs = null; + var result = new TestResult(new TestCase("This is a string.", new Uri("some://uri"), "DummySourceFileName")); - [TestMethod] - public void RaiseTestRunMessageShouldInvokeRegisteredEventHandlerIfTestRunMessageEventArgsIsPassed() + // Register for the test result event. + _loggerEvents.TestResult += (sender, e) => { - EventWaitHandle waitHandle = new AutoResetEvent(false); - bool testMessageReceived = false; - TestRunMessageEventArgs eventArgs = null; - var message = "This is the test message"; - - // Register for the test message event. - loggerEvents.TestRunMessage += (sender, e) => - { - testMessageReceived = true; - eventArgs = e; - waitHandle.Set(); - }; - - loggerEvents.EnableEvents(); - // Send the test message event. - loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Informational, message)); - - var waitSuccess = waitHandle.WaitOne(500); - Assert.IsTrue(waitSuccess, "Event must be raised within timeout."); - - Assert.IsTrue(testMessageReceived); - Assert.IsNotNull(eventArgs); - Assert.AreEqual(message, eventArgs.Message); - Assert.AreEqual(TestMessageLevel.Informational, eventArgs.Level); - } + testResultReceived = true; + eventArgs = e; + waitHandle.Set(); + }; - [TestMethod] - public void RaiseTestResultShouldInvokeRegisteredEventHandlerIfTestResultEventArgsIsPassed() - { - EventWaitHandle waitHandle = new AutoResetEvent(false); - bool testResultReceived = false; - TestResultEventArgs eventArgs = null; - var result =new TestResult(new TestCase("This is a string.", new Uri("some://uri"), "DummySourceFileName")); - - // Register for the test result event. - loggerEvents.TestResult += (sender, e) => - { - testResultReceived = true; - eventArgs = e; - waitHandle.Set(); - }; - - loggerEvents.EnableEvents(); - // Send the test result event. - loggerEvents.RaiseTestResult(new TestResultEventArgs(result)); - - var waitSuccess = waitHandle.WaitOne(500); - Assert.IsTrue(waitSuccess, "Event must be raised within timeout."); - - Assert.IsTrue(testResultReceived); - Assert.IsNotNull(eventArgs); - Assert.AreEqual(result, eventArgs.Result); - } + _loggerEvents.EnableEvents(); + // Send the test result event. + _loggerEvents.RaiseTestResult(new TestResultEventArgs(result)); - [TestMethod] - public void RaiseTestResultShouldThrowExceptionIfNullTestResultEventArgsIsPassed() - { - Assert.ThrowsException(() => - { - loggerEvents.RaiseTestResult(null); - }); - } + var waitSuccess = waitHandle.WaitOne(500); + Assert.IsTrue(waitSuccess, "Event must be raised within timeout."); - [TestMethod] - public void RaiseTestRunMessageShouldThrowExceptioIfNullTestRunMessageEventArgsIsPassed() - { - Assert.ThrowsException(() => - { - loggerEvents.RaiseTestRunMessage(null); - }); - } + Assert.IsTrue(testResultReceived); + Assert.IsNotNull(eventArgs); + Assert.AreEqual(result, eventArgs.Result); + } - [TestMethod] - public void CompleteTestRunShouldInvokeRegisteredEventHandler() - { - bool testRunCompleteReceived = false; - TestRunCompleteEventArgs eventArgs = null; - - EventWaitHandle waitHandle = new AutoResetEvent(false); - - // Register for the test run complete event. - loggerEvents.TestRunComplete += (sender, e) => - { - testRunCompleteReceived = true; - eventArgs = e; - waitHandle.Set(); - }; - - loggerEvents.EnableEvents(); - // Send the test run complete event. - loggerEvents.CompleteTestRun(null, false, false, null, null, null, new TimeSpan()); - - var waitSuccess = waitHandle.WaitOne(500); - Assert.IsTrue(waitSuccess, "Event must be raised within timeout."); - Assert.IsTrue(testRunCompleteReceived); - Assert.IsNotNull(eventArgs); - } + [TestMethod] + public void RaiseTestResultShouldThrowExceptionIfNullTestResultEventArgsIsPassed() + { + Assert.ThrowsException(() => _loggerEvents.RaiseTestResult(null)); + } + + [TestMethod] + public void RaiseTestRunMessageShouldThrowExceptioIfNullTestRunMessageEventArgsIsPassed() + { + Assert.ThrowsException(() => _loggerEvents.RaiseTestRunMessage(null)); + } + + [TestMethod] + public void CompleteTestRunShouldInvokeRegisteredEventHandler() + { + bool testRunCompleteReceived = false; + TestRunCompleteEventArgs eventArgs = null; - [TestMethod] - public void EnableEventsShouldSendEventsAlreadyPresentInQueueToRegisteredEventHandlers() + EventWaitHandle waitHandle = new AutoResetEvent(false); + + // Register for the test run complete event. + _loggerEvents.TestRunComplete += (sender, e) => { - bool testResultReceived = false; - bool testMessageReceived = false; + testRunCompleteReceived = true; + eventArgs = e; + waitHandle.Set(); + }; - // Send the events. - loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Error,"This is a string.")); - loggerEvents.RaiseTestResult(new TestResultEventArgs(new TestResult(new TestCase("This is a string.", new Uri("some://uri"), "DummySourceFileName")))); + _loggerEvents.EnableEvents(); + // Send the test run complete event. + _loggerEvents.CompleteTestRun(null, false, false, null, null, null, new TimeSpan()); - // Register for the events. - loggerEvents.TestResult += (sender, e) => - { - testResultReceived = true; - }; + var waitSuccess = waitHandle.WaitOne(500); + Assert.IsTrue(waitSuccess, "Event must be raised within timeout."); + Assert.IsTrue(testRunCompleteReceived); + Assert.IsNotNull(eventArgs); + } - loggerEvents.TestRunMessage += (sender, e) => - { - testMessageReceived = true; - }; + [TestMethod] + public void EnableEventsShouldSendEventsAlreadyPresentInQueueToRegisteredEventHandlers() + { + bool testResultReceived = false; + bool testMessageReceived = false; - // Enable events and verify that the events are received. - loggerEvents.EnableEvents(); + // Send the events. + _loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Error, "This is a string.")); + _loggerEvents.RaiseTestResult(new TestResultEventArgs(new TestResult(new TestCase("This is a string.", new Uri("some://uri"), "DummySourceFileName")))); - Assert.IsTrue(testResultReceived); - Assert.IsTrue(testMessageReceived); - } + // Register for the events. + _loggerEvents.TestResult += (sender, e) => testResultReceived = true; - [TestMethod] - public void DisposeShouldNotThrowExceptionIfCalledMultipleTimes() - { - var loggerEvents = GetDisposedLoggerEvents(); - loggerEvents.Dispose(); - } + _loggerEvents.TestRunMessage += (sender, e) => testMessageReceived = true; - [TestMethod] - public void RaiseTestResultShouldThrowExceptionIfDisposedIsAlreadyCalled() - { - var loggerEvents = GetDisposedLoggerEvents(); + // Enable events and verify that the events are received. + _loggerEvents.EnableEvents(); - Assert.ThrowsException(() => - { - loggerEvents.RaiseTestResult(new TestResultEventArgs(new TestResult(new TestCase("This is a string.", new Uri("some://uri"), "DummySourceFileName")))); - }); - } + Assert.IsTrue(testResultReceived); + Assert.IsTrue(testMessageReceived); + } - [TestMethod] - public void RaiseTestRunMessageShouldThrowExceptionIfDisposeIsAlreadyCalled() - { - var loggerEvents = GetDisposedLoggerEvents(); + [TestMethod] + public void DisposeShouldNotThrowExceptionIfCalledMultipleTimes() + { + var loggerEvents = GetDisposedLoggerEvents(); + loggerEvents.Dispose(); + } - Assert.ThrowsException(() => - { - loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Error,"This is a string.")); - }); - } + [TestMethod] + public void RaiseTestResultShouldThrowExceptionIfDisposedIsAlreadyCalled() + { + var loggerEvents = GetDisposedLoggerEvents(); - [TestMethod] - public void CompleteTestRunShouldThrowExceptionIfAlreadyDisposed() - { - var loggerEvents = GetDisposedLoggerEvents(); + Assert.ThrowsException(() => loggerEvents.RaiseTestResult(new TestResultEventArgs(new TestResult(new TestCase("This is a string.", new Uri("some://uri"), "DummySourceFileName"))))); + } - Assert.ThrowsException(() => - { - loggerEvents.CompleteTestRun(null, true, false, null, null, null, new TimeSpan()); - }); - } + [TestMethod] + public void RaiseTestRunMessageShouldThrowExceptionIfDisposeIsAlreadyCalled() + { + var loggerEvents = GetDisposedLoggerEvents(); - [TestMethod] - public void EnableEventsShouldThrowExceptionIfAlreadyDisposed() - { - var loggerEvents = GetDisposedLoggerEvents(); + Assert.ThrowsException(() => loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Error, "This is a string."))); + } - Assert.ThrowsException(() => - { - loggerEvents.EnableEvents(); - }); - } + [TestMethod] + public void CompleteTestRunShouldThrowExceptionIfAlreadyDisposed() + { + var loggerEvents = GetDisposedLoggerEvents(); - [TestMethod] - public void TestRunMessageLoggerProxySendMessageShouldInvokeRegisteredEventHandler() + Assert.ThrowsException(() => loggerEvents.CompleteTestRun(null, true, false, null, null, null, new TimeSpan())); + } + + [TestMethod] + public void EnableEventsShouldThrowExceptionIfAlreadyDisposed() + { + var loggerEvents = GetDisposedLoggerEvents(); + + Assert.ThrowsException(() => loggerEvents.EnableEvents()); + } + + [TestMethod] + public void TestRunMessageLoggerProxySendMessageShouldInvokeRegisteredEventHandler() + { + var receivedRunMessage = false; + using (_loggerEvents) { - var receivedRunMessage = false; - using (loggerEvents) - { - loggerEvents.TestRunMessage += (sender, e) => - { - receivedRunMessage = true; - }; - - testSessionMessageLogger.SendMessage(TestMessageLevel.Error,"This is a string."); - } - - Assert.IsTrue(receivedRunMessage); + _loggerEvents.TestRunMessage += (sender, e) => receivedRunMessage = true; + + _testSessionMessageLogger.SendMessage(TestMessageLevel.Error, "This is a string."); } - [TestMethod] - public void TestLoggerProxySendMessageShouldNotInvokeRegisterdEventHandlerIfAlreadyDisposed() - { - var receivedRunMessage = false; - loggerEvents.TestRunMessage += (sender, e) => - { - receivedRunMessage = true; - }; + Assert.IsTrue(receivedRunMessage); + } - // Dispose the logger events, send a message, and verify it is not received. - loggerEvents.Dispose(); - testSessionMessageLogger.SendMessage(TestMessageLevel.Error,"This is a string."); + [TestMethod] + public void TestLoggerProxySendMessageShouldNotInvokeRegisterdEventHandlerIfAlreadyDisposed() + { + var receivedRunMessage = false; + _loggerEvents.TestRunMessage += (sender, e) => receivedRunMessage = true; - Assert.IsFalse(receivedRunMessage); - } + // Dispose the logger events, send a message, and verify it is not received. + _loggerEvents.Dispose(); + _testSessionMessageLogger.SendMessage(TestMessageLevel.Error, "This is a string."); - /// - /// Exception should be thrown if event args passed is null. - /// - [TestMethod] - public void RaiseDiscoveryStartShouldThrowExceptionIfNullDiscoveryStartEventArgsIsPassed() - { - Assert.ThrowsException(() => - { - loggerEvents.RaiseDiscoveryStart(null); - }); - } + Assert.IsFalse(receivedRunMessage); + } - /// - /// Exception should be thrown if discovered tests event args is null. - /// - [TestMethod] - public void RaiseDiscoveredTestsShouldThrowExceptionIfNullDiscoveredTestsEventArgsIsPassed() - { - Assert.ThrowsException(() => - { - loggerEvents.RaiseDiscoveredTests(null); - }); - } + /// + /// Exception should be thrown if event args passed is null. + /// + [TestMethod] + public void RaiseDiscoveryStartShouldThrowExceptionIfNullDiscoveryStartEventArgsIsPassed() + { + Assert.ThrowsException(() => _loggerEvents.RaiseDiscoveryStart(null)); + } - /// - /// Exception should be thrown if logger events are already disposed. - /// - [TestMethod] - public void RaiseDiscoveredTestsShouldThrowExceptionIfAlreadyDisposed() - { - var loggerEvents = GetDisposedLoggerEvents(); - List testCases = new List { new TestCase("This is a string.", new Uri("some://uri"), "DummySourceFileName") }; - DiscoveredTestsEventArgs discoveredTestsEventArgs = new DiscoveredTestsEventArgs(testCases); - - Assert.ThrowsException(() => - { - loggerEvents.RaiseDiscoveredTests(discoveredTestsEventArgs); - }); - } + /// + /// Exception should be thrown if discovered tests event args is null. + /// + [TestMethod] + public void RaiseDiscoveredTestsShouldThrowExceptionIfNullDiscoveredTestsEventArgsIsPassed() + { + Assert.ThrowsException(() => _loggerEvents.RaiseDiscoveredTests(null)); + } - /// - /// Check for invocation to registered event handlers. - /// - [TestMethod] - public void RaiseDiscoveredTestsShouldInvokeRegisteredEventHandler() - { - bool discoveredTestsReceived = false; - DiscoveredTestsEventArgs receivedEventArgs = null; - EventWaitHandle waitHandle = new AutoResetEvent(false); - - List testCases = new List { new TestCase("This is a string.", new Uri("some://uri"), "DummySourceFileName") }; - DiscoveredTestsEventArgs discoveredTestsEventArgs = new DiscoveredTestsEventArgs(testCases); - - // Register for the discovered tests event. - loggerEvents.DiscoveredTests += (sender, e) => - { - discoveredTestsReceived = true; - receivedEventArgs = e; - waitHandle.Set(); - }; - - loggerEvents.EnableEvents(); - // Send the discovered tests event. - loggerEvents.RaiseDiscoveredTests(discoveredTestsEventArgs); - - var waitSuccess = waitHandle.WaitOne(500); - Assert.IsTrue(waitSuccess, "Event must be raised within timeout."); - Assert.IsTrue(discoveredTestsReceived); - Assert.IsNotNull(receivedEventArgs); - Assert.AreEqual(receivedEventArgs, discoveredTestsEventArgs); - } + /// + /// Exception should be thrown if logger events are already disposed. + /// + [TestMethod] + public void RaiseDiscoveredTestsShouldThrowExceptionIfAlreadyDisposed() + { + var loggerEvents = GetDisposedLoggerEvents(); + List testCases = new() { new TestCase("This is a string.", new Uri("some://uri"), "DummySourceFileName") }; + DiscoveredTestsEventArgs discoveredTestsEventArgs = new(testCases); - /// - /// Exception should be thrown if event args passed is null. - /// - [TestMethod] - public void RaiseDiscoveryCompleteShouldThrowExceptionIfNullDiscoveryCompleteEventArgsIsPassed() - { - Assert.ThrowsException(() => - { - loggerEvents.RaiseDiscoveryComplete(null); - }); - } + Assert.ThrowsException(() => loggerEvents.RaiseDiscoveredTests(discoveredTestsEventArgs)); + } - /// - /// Exception should be thrown if logger events are already disposed. - /// - [TestMethod] - public void RaiseDiscoveryStartShouldThrowExceptionIfAlreadyDisposed() - { - var loggerEvents = GetDisposedLoggerEvents(); - DiscoveryCriteria discoveryCriteria = new DiscoveryCriteria() { TestCaseFilter = "Name=Test1" }; - DiscoveryStartEventArgs discoveryStartEventArgs = new DiscoveryStartEventArgs(discoveryCriteria); - - Assert.ThrowsException(() => - { - loggerEvents.RaiseDiscoveryStart(discoveryStartEventArgs); - }); - } + /// + /// Check for invocation to registered event handlers. + /// + [TestMethod] + public void RaiseDiscoveredTestsShouldInvokeRegisteredEventHandler() + { + bool discoveredTestsReceived = false; + DiscoveredTestsEventArgs receivedEventArgs = null; + EventWaitHandle waitHandle = new AutoResetEvent(false); + + List testCases = new() { new TestCase("This is a string.", new Uri("some://uri"), "DummySourceFileName") }; + DiscoveredTestsEventArgs discoveredTestsEventArgs = new(testCases); + + // Register for the discovered tests event. + _loggerEvents.DiscoveredTests += (sender, e) => + { + discoveredTestsReceived = true; + receivedEventArgs = e; + waitHandle.Set(); + }; + + _loggerEvents.EnableEvents(); + // Send the discovered tests event. + _loggerEvents.RaiseDiscoveredTests(discoveredTestsEventArgs); + + var waitSuccess = waitHandle.WaitOne(500); + Assert.IsTrue(waitSuccess, "Event must be raised within timeout."); + Assert.IsTrue(discoveredTestsReceived); + Assert.IsNotNull(receivedEventArgs); + Assert.AreEqual(receivedEventArgs, discoveredTestsEventArgs); + } - /// - /// Exception should be thrown if logger events are already disposed. - /// - [TestMethod] - public void RaiseDiscoveryCompleteShouldThrowExceptionIfAlreadyDisposed() - { - var loggerEvents = GetDisposedLoggerEvents(); - DiscoveryCompleteEventArgs discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(2, false); + /// + /// Exception should be thrown if event args passed is null. + /// + [TestMethod] + public void RaiseDiscoveryCompleteShouldThrowExceptionIfNullDiscoveryCompleteEventArgsIsPassed() + { + Assert.ThrowsException(() => _loggerEvents.RaiseDiscoveryComplete(null)); + } - Assert.ThrowsException(() => - { - loggerEvents.RaiseDiscoveryComplete(discoveryCompleteEventArgs); - }); - } + /// + /// Exception should be thrown if logger events are already disposed. + /// + [TestMethod] + public void RaiseDiscoveryStartShouldThrowExceptionIfAlreadyDisposed() + { + var loggerEvents = GetDisposedLoggerEvents(); + DiscoveryCriteria discoveryCriteria = new() { TestCaseFilter = "Name=Test1" }; + DiscoveryStartEventArgs discoveryStartEventArgs = new(discoveryCriteria); - /// - /// Check for invocation to registered event handlers. - /// - [TestMethod] - public void RaiseDiscoveryStartShouldInvokeRegisteredEventHandler() - { - bool discoveryStartReceived = false; - DiscoveryStartEventArgs receivedEventArgs = null; - EventWaitHandle waitHandle = new AutoResetEvent(false); - - DiscoveryCriteria discoveryCriteria = new DiscoveryCriteria() { TestCaseFilter = "Name=Test1" }; - DiscoveryStartEventArgs discoveryStartEventArgs = new DiscoveryStartEventArgs(discoveryCriteria); - - // Register for the discovery start event. - loggerEvents.DiscoveryStart += (sender, e) => - { - discoveryStartReceived = true; - receivedEventArgs = e; - waitHandle.Set(); - }; - - loggerEvents.EnableEvents(); - // Send the discovery start event. - loggerEvents.RaiseDiscoveryStart(discoveryStartEventArgs); - - var waitSuccess = waitHandle.WaitOne(500); - Assert.IsTrue(waitSuccess, "Event must be raised within timeout."); - Assert.IsTrue(discoveryStartReceived); - Assert.IsNotNull(receivedEventArgs); - Assert.AreEqual(receivedEventArgs, discoveryStartEventArgs); - Assert.AreEqual("Name=Test1", receivedEventArgs.DiscoveryCriteria.TestCaseFilter); - } + Assert.ThrowsException(() => loggerEvents.RaiseDiscoveryStart(discoveryStartEventArgs)); + } - /// - /// Check for invocation to registered event handlers. - /// - [TestMethod] - public void RaiseDiscoveryCompleteShouldInvokeRegisteredEventHandler() - { - bool discoveryCompleteReceived = false; - DiscoveryCompleteEventArgs receivedEventArgs = null; - EventWaitHandle waitHandle = new AutoResetEvent(false); - - DiscoveryCompleteEventArgs discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(2, false); - - // Register for the discovery complete event. - loggerEvents.DiscoveryComplete += (sender, e) => - { - discoveryCompleteReceived = true; - receivedEventArgs = e; - waitHandle.Set(); - }; - - loggerEvents.EnableEvents(); - // Send the discovery complete event. - loggerEvents.RaiseDiscoveryComplete(discoveryCompleteEventArgs); - - var waitSuccess = waitHandle.WaitOne(500); - Assert.IsTrue(waitSuccess, "Event must be raised within timeout."); - Assert.IsTrue(discoveryCompleteReceived); - Assert.IsNotNull(receivedEventArgs); - Assert.AreEqual(receivedEventArgs, discoveryCompleteEventArgs); - } + /// + /// Exception should be thrown if logger events are already disposed. + /// + [TestMethod] + public void RaiseDiscoveryCompleteShouldThrowExceptionIfAlreadyDisposed() + { + var loggerEvents = GetDisposedLoggerEvents(); + DiscoveryCompleteEventArgs discoveryCompleteEventArgs = new(2, false); - /// - /// Exception should be thrown if event args passed is null. - /// - [TestMethod] - public void RaiseTestRunStartShouldThrowExceptionIfNullTestRunStartEventArgsIsPassed() - { - Assert.ThrowsException(() => - { - loggerEvents.RaiseTestRunStart(null); - }); - } + Assert.ThrowsException(() => loggerEvents.RaiseDiscoveryComplete(discoveryCompleteEventArgs)); + } - /// - /// Exception should be thrown if event args passed is null. - /// - [TestMethod] - public void RaiseDiscoveryMessageShouldThrowExceptionIfNullTestRunMessageEventArgsIsPassed() - { - Assert.ThrowsException(() => - { - loggerEvents.RaiseDiscoveryMessage(null); - }); - } + /// + /// Check for invocation to registered event handlers. + /// + [TestMethod] + public void RaiseDiscoveryStartShouldInvokeRegisteredEventHandler() + { + bool discoveryStartReceived = false; + DiscoveryStartEventArgs receivedEventArgs = null; + EventWaitHandle waitHandle = new AutoResetEvent(false); + + DiscoveryCriteria discoveryCriteria = new() { TestCaseFilter = "Name=Test1" }; + DiscoveryStartEventArgs discoveryStartEventArgs = new(discoveryCriteria); + + // Register for the discovery start event. + _loggerEvents.DiscoveryStart += (sender, e) => + { + discoveryStartReceived = true; + receivedEventArgs = e; + waitHandle.Set(); + }; + + _loggerEvents.EnableEvents(); + // Send the discovery start event. + _loggerEvents.RaiseDiscoveryStart(discoveryStartEventArgs); + + var waitSuccess = waitHandle.WaitOne(500); + Assert.IsTrue(waitSuccess, "Event must be raised within timeout."); + Assert.IsTrue(discoveryStartReceived); + Assert.IsNotNull(receivedEventArgs); + Assert.AreEqual(receivedEventArgs, discoveryStartEventArgs); + Assert.AreEqual("Name=Test1", receivedEventArgs.DiscoveryCriteria.TestCaseFilter); + } - /// - /// Exception should be thrown if logger events are already disposed. - /// - [TestMethod] - public void RaiseTestRunStartShouldThrowExceptionIfAlreadyDisposed() - { - var loggerEvents = GetDisposedLoggerEvents(); - TestRunCriteria testRunCriteria = new TestRunCriteria(new List { @"x:dummy\foo.dll" }, 10, false, string.Empty, TimeSpan.MaxValue, null, "Name=Test1", null); - TestRunStartEventArgs testRunStartEventArgs = new TestRunStartEventArgs(testRunCriteria); - - Assert.ThrowsException(() => - { - loggerEvents.RaiseTestRunStart(testRunStartEventArgs); - }); - } + /// + /// Check for invocation to registered event handlers. + /// + [TestMethod] + public void RaiseDiscoveryCompleteShouldInvokeRegisteredEventHandler() + { + bool discoveryCompleteReceived = false; + DiscoveryCompleteEventArgs receivedEventArgs = null; + EventWaitHandle waitHandle = new AutoResetEvent(false); - /// - /// Exception should be thrown if logger events are already disposed. - /// - [TestMethod] - public void RaiseDiscoveryMessageShouldThrowExceptionIfAlreadyDisposed() - { - var loggerEvents = GetDisposedLoggerEvents(); - string message = "This is the test message"; - TestRunMessageEventArgs testRunMessageEventArgs = new TestRunMessageEventArgs(TestMessageLevel.Informational, message); - - Assert.ThrowsException(() => - { - loggerEvents.RaiseDiscoveryMessage(testRunMessageEventArgs); - }); - } + DiscoveryCompleteEventArgs discoveryCompleteEventArgs = new(2, false); - /// - /// Check for invocation to registered event handlers. - /// - [TestMethod] - public void RaiseTestRunStartShouldInvokeRegisteredEventHandler() + // Register for the discovery complete event. + _loggerEvents.DiscoveryComplete += (sender, e) => { - bool testRunStartReceived = false; - TestRunStartEventArgs receivedEventArgs = null; - EventWaitHandle waitHandle = new AutoResetEvent(false); - - TestRunCriteria testRunCriteria = new TestRunCriteria(new List { @"x:dummy\foo.dll" }, 10, false, string.Empty, TimeSpan.MaxValue, null, "Name=Test1", null); - TestRunStartEventArgs testRunStartEventArgs = new TestRunStartEventArgs(testRunCriteria); - - // Register for the test run start event. - loggerEvents.TestRunStart += (sender, e) => - { - testRunStartReceived = true; - receivedEventArgs = e; - waitHandle.Set(); - }; - - loggerEvents.EnableEvents(); - // Send the test run start event. - loggerEvents.RaiseTestRunStart(testRunStartEventArgs); - - var waitSuccess = waitHandle.WaitOne(500); - Assert.IsTrue(waitSuccess, "Event must be raised within timeout."); - Assert.IsTrue(testRunStartReceived); - Assert.IsNotNull(receivedEventArgs); - Assert.AreEqual(receivedEventArgs, testRunStartEventArgs); - Assert.AreEqual("Name=Test1", receivedEventArgs.TestRunCriteria.TestCaseFilter); - } + discoveryCompleteReceived = true; + receivedEventArgs = e; + waitHandle.Set(); + }; - /// - /// Check for invocation to registered event handlers. - /// - [TestMethod] - public void RaiseDiscoveryMessageShouldInvokeRegisteredEventHandler() - { - bool discoveryMessageReceived = false; - TestRunMessageEventArgs receivedEventArgs = null; - EventWaitHandle waitHandle = new AutoResetEvent(false); - - string message = "This is the test message"; - TestRunMessageEventArgs testRunMessageEventArgs = new TestRunMessageEventArgs(TestMessageLevel.Informational, message); - - // Register for the discovery message event. - loggerEvents.DiscoveryMessage += (sender, e) => - { - discoveryMessageReceived = true; - receivedEventArgs = e; - waitHandle.Set(); - }; - - loggerEvents.EnableEvents(); - // Send the discovery message event. - loggerEvents.RaiseDiscoveryMessage(testRunMessageEventArgs); - - var waitSuccess = waitHandle.WaitOne(500); - Assert.IsTrue(waitSuccess, "Event must be raised within timeout."); - Assert.IsTrue(discoveryMessageReceived); - Assert.IsNotNull(receivedEventArgs); - Assert.AreEqual(receivedEventArgs, testRunMessageEventArgs); - Assert.AreEqual(message, receivedEventArgs.Message); - Assert.AreEqual(TestMessageLevel.Informational, receivedEventArgs.Level); - } + _loggerEvents.EnableEvents(); + // Send the discovery complete event. + _loggerEvents.RaiseDiscoveryComplete(discoveryCompleteEventArgs); - /// - /// Gets a disposed instance of the logger events. - /// - /// Disposed instance. - private InternalTestLoggerEvents GetDisposedLoggerEvents() - { - var loggerEvents = new InternalTestLoggerEvents(testSessionMessageLogger); - loggerEvents.Dispose(); + var waitSuccess = waitHandle.WaitOne(500); + Assert.IsTrue(waitSuccess, "Event must be raised within timeout."); + Assert.IsTrue(discoveryCompleteReceived); + Assert.IsNotNull(receivedEventArgs); + Assert.AreEqual(receivedEventArgs, discoveryCompleteEventArgs); + } - return loggerEvents; - } + /// + /// Exception should be thrown if event args passed is null. + /// + [TestMethod] + public void RaiseTestRunStartShouldThrowExceptionIfNullTestRunStartEventArgsIsPassed() + { + Assert.ThrowsException(() => _loggerEvents.RaiseTestRunStart(null)); + } + + /// + /// Exception should be thrown if event args passed is null. + /// + [TestMethod] + public void RaiseDiscoveryMessageShouldThrowExceptionIfNullTestRunMessageEventArgsIsPassed() + { + Assert.ThrowsException(() => _loggerEvents.RaiseDiscoveryMessage(null)); + } + + /// + /// Exception should be thrown if logger events are already disposed. + /// + [TestMethod] + public void RaiseTestRunStartShouldThrowExceptionIfAlreadyDisposed() + { + var loggerEvents = GetDisposedLoggerEvents(); + TestRunCriteria testRunCriteria = new(new List { @"x:dummy\foo.dll" }, 10, false, string.Empty, TimeSpan.MaxValue, null, "Name=Test1", null); + TestRunStartEventArgs testRunStartEventArgs = new(testRunCriteria); + + Assert.ThrowsException(() => loggerEvents.RaiseTestRunStart(testRunStartEventArgs)); + } + + /// + /// Exception should be thrown if logger events are already disposed. + /// + [TestMethod] + public void RaiseDiscoveryMessageShouldThrowExceptionIfAlreadyDisposed() + { + var loggerEvents = GetDisposedLoggerEvents(); + string message = "This is the test message"; + TestRunMessageEventArgs testRunMessageEventArgs = new(TestMessageLevel.Informational, message); + + Assert.ThrowsException(() => loggerEvents.RaiseDiscoveryMessage(testRunMessageEventArgs)); + } + + /// + /// Check for invocation to registered event handlers. + /// + [TestMethod] + public void RaiseTestRunStartShouldInvokeRegisteredEventHandler() + { + bool testRunStartReceived = false; + TestRunStartEventArgs receivedEventArgs = null; + EventWaitHandle waitHandle = new AutoResetEvent(false); + + TestRunCriteria testRunCriteria = new(new List { @"x:dummy\foo.dll" }, 10, false, string.Empty, TimeSpan.MaxValue, null, "Name=Test1", null); + TestRunStartEventArgs testRunStartEventArgs = new(testRunCriteria); + + // Register for the test run start event. + _loggerEvents.TestRunStart += (sender, e) => + { + testRunStartReceived = true; + receivedEventArgs = e; + waitHandle.Set(); + }; + + _loggerEvents.EnableEvents(); + // Send the test run start event. + _loggerEvents.RaiseTestRunStart(testRunStartEventArgs); + + var waitSuccess = waitHandle.WaitOne(500); + Assert.IsTrue(waitSuccess, "Event must be raised within timeout."); + Assert.IsTrue(testRunStartReceived); + Assert.IsNotNull(receivedEventArgs); + Assert.AreEqual(receivedEventArgs, testRunStartEventArgs); + Assert.AreEqual("Name=Test1", receivedEventArgs.TestRunCriteria.TestCaseFilter); + } + + /// + /// Check for invocation to registered event handlers. + /// + [TestMethod] + public void RaiseDiscoveryMessageShouldInvokeRegisteredEventHandler() + { + bool discoveryMessageReceived = false; + TestRunMessageEventArgs receivedEventArgs = null; + EventWaitHandle waitHandle = new AutoResetEvent(false); + + string message = "This is the test message"; + TestRunMessageEventArgs testRunMessageEventArgs = new(TestMessageLevel.Informational, message); + + // Register for the discovery message event. + _loggerEvents.DiscoveryMessage += (sender, e) => + { + discoveryMessageReceived = true; + receivedEventArgs = e; + waitHandle.Set(); + }; + + _loggerEvents.EnableEvents(); + // Send the discovery message event. + _loggerEvents.RaiseDiscoveryMessage(testRunMessageEventArgs); + + var waitSuccess = waitHandle.WaitOne(500); + Assert.IsTrue(waitSuccess, "Event must be raised within timeout."); + Assert.IsTrue(discoveryMessageReceived); + Assert.IsNotNull(receivedEventArgs); + Assert.AreEqual(receivedEventArgs, testRunMessageEventArgs); + Assert.AreEqual(message, receivedEventArgs.Message); + Assert.AreEqual(TestMessageLevel.Informational, receivedEventArgs.Level); + } + + /// + /// Gets a disposed instance of the logger events. + /// + /// Disposed instance. + private InternalTestLoggerEvents GetDisposedLoggerEvents() + { + var loggerEvents = new InternalTestLoggerEvents(_testSessionMessageLogger); + loggerEvents.Dispose(); + + return loggerEvents; } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/Logging/TestSessionMessageLoggerTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/Logging/TestSessionMessageLoggerTests.cs index 13d32e095d..a4448eb735 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/Logging/TestSessionMessageLoggerTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/Logging/TestSessionMessageLoggerTests.cs @@ -1,66 +1,65 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Common.UnitTests.Logging -{ - using System; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.Common.UnitTests.Logging; - [TestClass] - public class TestSessionMessageLoggerTests - { - private TestSessionMessageLogger testSessionMessageLogger; +using Microsoft.VisualStudio.TestPlatform.Common.Logging; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class TestSessionMessageLoggerTests +{ + private TestSessionMessageLogger _testSessionMessageLogger; - private TestRunMessageEventArgs currentEventArgs; + private TestRunMessageEventArgs _currentEventArgs; - [TestInitialize] - public void TestInit() - { - this.testSessionMessageLogger = TestSessionMessageLogger.Instance; - } + [TestInitialize] + public void TestInit() + { + _testSessionMessageLogger = TestSessionMessageLogger.Instance; + } - [TestCleanup] - public void TestCleanup() - { - TestSessionMessageLogger.Instance = null; - } + [TestCleanup] + public void TestCleanup() + { + TestSessionMessageLogger.Instance = null; + } - [TestMethod] - public void InstanceShouldReturnALoggerInstance() - { - Assert.IsNotNull(this.testSessionMessageLogger); - } + [TestMethod] + public void InstanceShouldReturnALoggerInstance() + { + Assert.IsNotNull(_testSessionMessageLogger); + } - [TestMethod] - public void SendMessageShouldLogErrorMessages() - { - this.testSessionMessageLogger.TestRunMessage += OnMessage; + [TestMethod] + public void SendMessageShouldLogErrorMessages() + { + _testSessionMessageLogger.TestRunMessage += OnMessage; - var message = "Alert"; - this.testSessionMessageLogger.SendMessage(TestMessageLevel.Error, message); + var message = "Alert"; + _testSessionMessageLogger.SendMessage(TestMessageLevel.Error, message); - Assert.AreEqual(TestMessageLevel.Error, this.currentEventArgs.Level); - Assert.AreEqual(message, this.currentEventArgs.Message); - } + Assert.AreEqual(TestMessageLevel.Error, _currentEventArgs.Level); + Assert.AreEqual(message, _currentEventArgs.Message); + } - [TestMethod] - public void SendMessageShouldLogErrorAsWarningIfSpecifiedSo() - { - this.testSessionMessageLogger.TestRunMessage += OnMessage; - this.testSessionMessageLogger.TreatTestAdapterErrorsAsWarnings = true; + [TestMethod] + public void SendMessageShouldLogErrorAsWarningIfSpecifiedSo() + { + _testSessionMessageLogger.TestRunMessage += OnMessage; + _testSessionMessageLogger.TreatTestAdapterErrorsAsWarnings = true; - var message = "Alert"; - this.testSessionMessageLogger.SendMessage(TestMessageLevel.Error, message); + var message = "Alert"; + _testSessionMessageLogger.SendMessage(TestMessageLevel.Error, message); - Assert.AreEqual(TestMessageLevel.Warning, this.currentEventArgs.Level); - Assert.AreEqual(message, this.currentEventArgs.Message); - } + Assert.AreEqual(TestMessageLevel.Warning, _currentEventArgs.Level); + Assert.AreEqual(message, _currentEventArgs.Message); + } - private void OnMessage(object sender, TestRunMessageEventArgs e) - { - this.currentEventArgs = e; - } + private void OnMessage(object sender, TestRunMessageEventArgs e) + { + _currentEventArgs = e; } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/Program.cs b/test/Microsoft.TestPlatform.Common.UnitTests/Program.cs index c14da13e69..97bd06b99b 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/Program.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/Program.cs @@ -1,11 +1,11 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.UnitTests +namespace Microsoft.VisualStudio.TestPlatform.Common.UnitTests; + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/Properties/AssemblyInfo.cs b/test/Microsoft.TestPlatform.Common.UnitTests/Properties/AssemblyInfo.cs index 5f434531b6..c039051e1c 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/Properties/AssemblyInfo.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/Properties/AssemblyInfo.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/RequestDataTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/RequestDataTests.cs index 7ed99a3a89..964fa1423b 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/RequestDataTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/RequestDataTests.cs @@ -1,69 +1,69 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Common.UnitTests -{ - using System; +namespace Microsoft.TestPlatform.Common.UnitTests; + +using System; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestPlatform.Common; +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - [TestClass] - public class RequestDataTests +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class RequestDataTests +{ + [TestMethod] + public void RequestDataShouldReturnValidMetricsCollector() { - [TestMethod] - public void RequestDataShouldReturnValidMetricsCollector() - { - var requestData = new RequestData(); - var metricsCollection = new MetricsCollection(); - requestData.MetricsCollection = metricsCollection; + var requestData = new RequestData(); + var metricsCollection = new MetricsCollection(); + requestData.MetricsCollection = metricsCollection; - Assert.AreEqual(metricsCollection, requestData.MetricsCollection); - } + Assert.AreEqual(metricsCollection, requestData.MetricsCollection); + } - [TestMethod] - public void RequestDataShouldReturnValidProtocolConfig() - { - var requestData = new RequestData(); - requestData.ProtocolConfig = new ProtocolConfig { Version = 2 }; + [TestMethod] + public void RequestDataShouldReturnValidProtocolConfig() + { + var requestData = new RequestData(); + requestData.ProtocolConfig = new ProtocolConfig { Version = 2 }; - Assert.AreEqual(2, requestData.ProtocolConfig.Version); - } + Assert.AreEqual(2, requestData.ProtocolConfig.Version); + } - [TestMethod] - [ExpectedException(typeof(ArgumentNullException))] - public void RequestDataShouldThrowArgumentNullExpectionOnNullMetricsCollection() - { - var requestData = new RequestData(); - requestData.MetricsCollection = null; - } + [TestMethod] + [ExpectedException(typeof(ArgumentNullException))] + public void RequestDataShouldThrowArgumentNullExpectionOnNullMetricsCollection() + { + var requestData = new RequestData(); + requestData.MetricsCollection = null; + } - [TestMethod] - [ExpectedException(typeof(ArgumentNullException))] - public void RequestDataShouldThrowArgumentNullExpectionOnNullProtocolConfig() - { - var requestData = new RequestData(); - requestData.ProtocolConfig = null; - } + [TestMethod] + [ExpectedException(typeof(ArgumentNullException))] + public void RequestDataShouldThrowArgumentNullExpectionOnNullProtocolConfig() + { + var requestData = new RequestData(); + requestData.ProtocolConfig = null; + } - [TestMethod] - public void RequestDataShouldReturnIsTelemetryOptedInTrueIfTelemetryOptedIn() - { - var requestData = new RequestData(); - requestData.IsTelemetryOptedIn = true; + [TestMethod] + public void RequestDataShouldReturnIsTelemetryOptedInTrueIfTelemetryOptedIn() + { + var requestData = new RequestData(); + requestData.IsTelemetryOptedIn = true; - Assert.IsTrue(requestData.IsTelemetryOptedIn); - } + Assert.IsTrue(requestData.IsTelemetryOptedIn); + } - [TestMethod] - public void RequestDataShouldReturnIsTelemetryOptedInFalseIfTelemetryOptedOut() - { - var requestData = new RequestData(); - requestData.IsTelemetryOptedIn = false; + [TestMethod] + public void RequestDataShouldReturnIsTelemetryOptedInFalseIfTelemetryOptedOut() + { + var requestData = new RequestData(); + requestData.IsTelemetryOptedIn = false; - Assert.IsFalse(requestData.IsTelemetryOptedIn); - } + Assert.IsFalse(requestData.IsTelemetryOptedIn); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/RunSettingsManagerTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/RunSettingsManagerTests.cs index ef3b64032b..6cd77e4b1a 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/RunSettingsManagerTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/RunSettingsManagerTests.cs @@ -1,67 +1,66 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests +namespace TestPlatform.Common.UnitTests; + +using System; + +using Microsoft.VisualStudio.TestPlatform.Common; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class RunSettingsManagerTests { - using System; + [TestCleanup] + public void TestCleanup() + { + RunSettingsManager.Instance = null; + } + + [TestMethod] + public void InstanceShouldReturnARunSettingsManagerInstance() + { + var instance = RunSettingsManager.Instance; + + Assert.IsNotNull(instance); + Assert.AreEqual(typeof(RunSettingsManager), instance.GetType()); + } - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestTools.UnitTesting; + [TestMethod] + public void InstanceShouldReturnACachedValue() + { + var instance = RunSettingsManager.Instance; + var instance2 = RunSettingsManager.Instance; + + Assert.AreEqual(instance, instance2); + } - [TestClass] - public class RunSettingsManagerTests + [TestMethod] + public void ActiveRunSettingsShouldBeNonNullByDefault() { - [TestCleanup] - public void TestCleanup() - { - RunSettingsManager.Instance = null; - } - - [TestMethod] - public void InstanceShouldReturnARunSettingsManagerInstance() - { - var instance = RunSettingsManager.Instance; - - Assert.IsNotNull(instance); - Assert.AreEqual(typeof(RunSettingsManager), instance.GetType()); - } - - [TestMethod] - public void InstanceShouldReturnACachedValue() - { - var instance = RunSettingsManager.Instance; - var instance2 = RunSettingsManager.Instance; - - Assert.AreEqual(instance, instance2); - } - - [TestMethod] - public void ActiveRunSettingsShouldBeNonNullByDefault() - { - var instance = RunSettingsManager.Instance; - - Assert.IsNotNull(instance.ActiveRunSettings); - } - - [TestMethod] - public void SetActiveRunSettingsShouldThrowIfRunSettingsPassedIsNull() - { - var instance = RunSettingsManager.Instance; - - Assert.ThrowsException(() => instance.SetActiveRunSettings(null)); - } - - [TestMethod] - public void SetActiveRunSettingsShouldSetTheActiveRunSettingsProperty() - { - var instance = RunSettingsManager.Instance; - - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(""); - - instance.SetActiveRunSettings(runSettings); - - Assert.AreEqual(runSettings, instance.ActiveRunSettings); - } + var instance = RunSettingsManager.Instance; + + Assert.IsNotNull(instance.ActiveRunSettings); + } + + [TestMethod] + public void SetActiveRunSettingsShouldThrowIfRunSettingsPassedIsNull() + { + var instance = RunSettingsManager.Instance; + + Assert.ThrowsException(() => instance.SetActiveRunSettings(null)); + } + + [TestMethod] + public void SetActiveRunSettingsShouldSetTheActiveRunSettingsProperty() + { + var instance = RunSettingsManager.Instance; + + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(""); + + instance.SetActiveRunSettings(runSettings); + + Assert.AreEqual(runSettings, instance.ActiveRunSettings); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/RunSettingsTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/RunSettingsTests.cs index 8688f16b7f..9e041d4911 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/RunSettingsTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/RunSettingsTests.cs @@ -1,276 +1,272 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests +namespace TestPlatform.Common.UnitTests; + +using System; +using System.Xml; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common; +using Microsoft.VisualStudio.TestPlatform.Common.Logging; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class RunSettingsTests { - using System; - using System.Xml; - - using ExtensionFramework; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class RunSettingsTests + [TestCleanup] + public void TestCleanup() { - [TestCleanup] - public void TestCleanup() - { - TestPluginCacheHelper.ResetExtensionsCache(); - TestSessionMessageLogger.Instance = null; - } + TestPluginCacheHelper.ResetExtensionsCache(); + TestSessionMessageLogger.Instance = null; + } - #region LoadSettingsXML Tests + #region LoadSettingsXML Tests - [TestMethod] - public void LoadSettingsXmlShouldThrowOnNullSettings() - { - var runSettings = new RunSettings(); - Assert.ThrowsException(() => runSettings.LoadSettingsXml(null)); - } + [TestMethod] + public void LoadSettingsXmlShouldThrowOnNullSettings() + { + var runSettings = new RunSettings(); + Assert.ThrowsException(() => runSettings.LoadSettingsXml(null)); + } - [TestMethod] - public void LoadSettingsXmlShouldThrowOnEmptySettings() - { - var runSettings = new RunSettings(); - Assert.ThrowsException(() => runSettings.LoadSettingsXml(" ")); - } + [TestMethod] + public void LoadSettingsXmlShouldThrowOnEmptySettings() + { + var runSettings = new RunSettings(); + Assert.ThrowsException(() => runSettings.LoadSettingsXml(" ")); + } - [TestMethod] - public void LoadSettingsXmlShoulLoadAndInitializeSettingsXml() - { - var runSettings = new RunSettings(); - var emptyRunSettings = this.GetEmptyRunSettings(); + [TestMethod] + public void LoadSettingsXmlShoulLoadAndInitializeSettingsXml() + { + var runSettings = new RunSettings(); + var emptyRunSettings = GetEmptyRunSettings(); - runSettings.LoadSettingsXml(emptyRunSettings); + runSettings.LoadSettingsXml(emptyRunSettings); - // Not doing this because when we load the xml and write to string it converts it to a utf-16 format. - // So they do not exactly match. - // Assert.AreEqual(emptyRunSettings, runSettings.SettingsXml); + // Not doing this because when we load the xml and write to string it converts it to a utf-16 format. + // So they do not exactly match. + // Assert.AreEqual(emptyRunSettings, runSettings.SettingsXml); - var expectedRunSettings = "" + Environment.NewLine - + ""; - StringAssert.Contains(runSettings.SettingsXml, expectedRunSettings); - } + var expectedRunSettings = "" + Environment.NewLine + + ""; + StringAssert.Contains(runSettings.SettingsXml, expectedRunSettings); + } - [TestMethod] - public void LoadSettingsXmlShouldThrowOnInvalidSettings() - { - var runSettings = new RunSettings(); - var invalidSettings = this.GetInvalidRunSettings(); + [TestMethod] + public void LoadSettingsXmlShouldThrowOnInvalidSettings() + { + var runSettings = new RunSettings(); + var invalidSettings = GetInvalidRunSettings(); - Assert.ThrowsException( - () => runSettings.LoadSettingsXml(invalidSettings), - "An error occurred while loading the run settings."); - } + Assert.ThrowsException( + () => runSettings.LoadSettingsXml(invalidSettings), + "An error occurred while loading the run settings."); + } - #endregion + #endregion - #region InitializeSettingsProviders and GetSettings tests + #region InitializeSettingsProviders and GetSettings tests - [TestMethod] - public void InitializeSettingsProvidersShouldThrowOnNullSettings() - { - var runSettings = new RunSettings(); - Assert.ThrowsException(() => runSettings.InitializeSettingsProviders(null)); - } + [TestMethod] + public void InitializeSettingsProvidersShouldThrowOnNullSettings() + { + var runSettings = new RunSettings(); + Assert.ThrowsException(() => runSettings.InitializeSettingsProviders(null)); + } - [TestMethod] - public void InitializeSettingsProvidersShouldWorkForEmptyRunSettings() - { - var runSettings = new RunSettings(); + [TestMethod] + public void InitializeSettingsProvidersShouldWorkForEmptyRunSettings() + { + var runSettings = new RunSettings(); - runSettings.InitializeSettingsProviders(this.GetEmptyRunSettings()); + runSettings.InitializeSettingsProviders(GetEmptyRunSettings()); - Assert.IsNull(runSettings.GetSettings("RunSettings")); - } + Assert.IsNull(runSettings.GetSettings("RunSettings")); + } - [TestMethod] - public void InitializeSettingsProvidersShouldThrowIfNodeInRunSettingsDoesNotHaveAProvider() - { - TestPluginCacheHelper.SetupMockExtensions(typeof(RunSettingsTests)); + [TestMethod] + public void InitializeSettingsProvidersShouldThrowIfNodeInRunSettingsDoesNotHaveAProvider() + { + TestPluginCacheHelper.SetupMockExtensions(typeof(RunSettingsTests)); - var runSettings = new RunSettings(); - runSettings.InitializeSettingsProviders(this.GetRunSettingsWithUndefinedSettingsNodes()); + var runSettings = new RunSettings(); + runSettings.InitializeSettingsProviders(GetRunSettingsWithUndefinedSettingsNodes()); - Action action = - () => runSettings.GetSettings("OrphanNode"); + Action action = + () => runSettings.GetSettings("OrphanNode"); - Assert.ThrowsException( - action, - "Settings Provider named '{0}' was not found. The settings can not be loaded.", - "OrphanNode"); - } + Assert.ThrowsException( + action, + "Settings Provider named '{0}' was not found. The settings can not be loaded.", + "OrphanNode"); + } - [TestMethod] - public void InitializeSettingsProvidersShouldThrowIfSettingsProviderLoadThrows() - { - TestPluginCacheHelper.SetupMockExtensions(typeof(RunSettingsTests)); + [TestMethod] + public void InitializeSettingsProvidersShouldThrowIfSettingsProviderLoadThrows() + { + TestPluginCacheHelper.SetupMockExtensions(typeof(RunSettingsTests)); - var runSettings = new RunSettings(); - runSettings.InitializeSettingsProviders(this.GetRunSettingsWithBadSettingsNodes()); + var runSettings = new RunSettings(); + runSettings.InitializeSettingsProviders(GetRunSettingsWithBadSettingsNodes()); - Action action = - () => runSettings.GetSettings("BadSettings"); + Action action = + () => runSettings.GetSettings("BadSettings"); - Assert.ThrowsException( - action, - "An error occurred while initializing the settings provider named '{0}'", - "BadSettings"); - } + Assert.ThrowsException( + action, + "An error occurred while initializing the settings provider named '{0}'", + "BadSettings"); + } - [TestMethod] - public void InitializeSettingsProvidersShouldThrowIfInvalidRunSettingsIsPassed() - { - var runSettings = new RunSettings(); - Assert.ThrowsException( - () => runSettings.InitializeSettingsProviders(this.GetInvalidRunSettings()), - "An error occurred while loading the run settings."); - } + [TestMethod] + public void InitializeSettingsProvidersShouldThrowIfInvalidRunSettingsIsPassed() + { + var runSettings = new RunSettings(); + Assert.ThrowsException( + () => runSettings.InitializeSettingsProviders(GetInvalidRunSettings()), + "An error occurred while loading the run settings."); + } - [TestMethod] - public void InitializeSettingsProvidersMultipleTimesShouldThrowInvalidOperationException() - { - var runSettings = new RunSettings(); - runSettings.InitializeSettingsProviders(this.GetEmptyRunSettings()); - Assert.ThrowsException( - () => runSettings.InitializeSettingsProviders(this.GetEmptyRunSettings()), - "The Run Settings have already been loaded."); - } + [TestMethod] + public void InitializeSettingsProvidersMultipleTimesShouldThrowInvalidOperationException() + { + var runSettings = new RunSettings(); + runSettings.InitializeSettingsProviders(GetEmptyRunSettings()); + Assert.ThrowsException( + () => runSettings.InitializeSettingsProviders(GetEmptyRunSettings()), + "The Run Settings have already been loaded."); + } - [TestMethod] - public void InitializeSettingsProvidersShouldLoadSettingsIntoASettingsProvider() - { - TestPluginCacheHelper.SetupMockExtensions(typeof(RunSettingsTests)); + [TestMethod] + public void InitializeSettingsProvidersShouldLoadSettingsIntoASettingsProvider() + { + TestPluginCacheHelper.SetupMockExtensions(typeof(RunSettingsTests)); - var runSettings = new RunSettings(); - runSettings.InitializeSettingsProviders(this.GetRunSettingsWithRunConfigurationNode()); + var runSettings = new RunSettings(); + runSettings.InitializeSettingsProviders(GetRunSettingsWithRunConfigurationNode()); - var settingsProvider = runSettings.GetSettings("RunConfiguration"); + var settingsProvider = runSettings.GetSettings("RunConfiguration"); - Assert.IsNotNull(settingsProvider); - Assert.IsTrue(settingsProvider is RunConfigurationSettingsProvider); + Assert.IsNotNull(settingsProvider); + Assert.IsTrue(settingsProvider is RunConfigurationSettingsProvider); - // Also validate that the settings provider gets the right subtree. - Assert.AreEqual( - "x86", - (settingsProvider as RunConfigurationSettingsProvider).SettingsTree); - } + // Also validate that the settings provider gets the right subtree. + Assert.AreEqual( + "x86", + (settingsProvider as RunConfigurationSettingsProvider).SettingsTree); + } - [TestMethod] - public void InitializeSettingsProvidersShouldLoadSettingsIntoMultipleSettingsProviders() - { - TestPluginCacheHelper.SetupMockExtensions(typeof(RunSettingsTests)); + [TestMethod] + public void InitializeSettingsProvidersShouldLoadSettingsIntoMultipleSettingsProviders() + { + TestPluginCacheHelper.SetupMockExtensions(typeof(RunSettingsTests)); - var runSettings = new RunSettings(); - runSettings.InitializeSettingsProviders(this.GetRunSettingsWithRunConfigurationAndMSTestNode()); + var runSettings = new RunSettings(); + runSettings.InitializeSettingsProviders(GetRunSettingsWithRunConfigurationAndMsTestNode()); - var rcSettingsProvider = runSettings.GetSettings("RunConfiguration"); - var mstestSettingsProvider = runSettings.GetSettings("MSTest"); + var rcSettingsProvider = runSettings.GetSettings("RunConfiguration"); + var mstestSettingsProvider = runSettings.GetSettings("MSTest"); - Assert.IsNotNull(rcSettingsProvider); - Assert.IsTrue(rcSettingsProvider is RunConfigurationSettingsProvider); - Assert.AreEqual( - "x86", - (rcSettingsProvider as RunConfigurationSettingsProvider).SettingsTree); + Assert.IsNotNull(rcSettingsProvider); + Assert.IsTrue(rcSettingsProvider is RunConfigurationSettingsProvider); + Assert.AreEqual( + "x86", + (rcSettingsProvider as RunConfigurationSettingsProvider).SettingsTree); - Assert.IsNotNull(mstestSettingsProvider); - Assert.IsTrue(mstestSettingsProvider is MSTestSettingsProvider); - Assert.AreEqual( - "true", - (mstestSettingsProvider as MSTestSettingsProvider).SettingsTree); - } + Assert.IsNotNull(mstestSettingsProvider); + Assert.IsTrue(mstestSettingsProvider is MsTestSettingsProvider); + Assert.AreEqual( + "true", + (mstestSettingsProvider as MsTestSettingsProvider).SettingsTree); + } - [TestMethod] - public void InitializeSettingsProvidersShouldWarnOfDuplicateSettings() - { - string receivedWarningMessage = null; + [TestMethod] + public void InitializeSettingsProvidersShouldWarnOfDuplicateSettings() + { + string receivedWarningMessage = null; - TestPluginCacheHelper.SetupMockExtensions(typeof(RunSettingsTests)); - TestSessionMessageLogger.Instance.TestRunMessage += (object sender, TestRunMessageEventArgs e) => - { - receivedWarningMessage = e.Message; - }; + TestPluginCacheHelper.SetupMockExtensions(typeof(RunSettingsTests)); + TestSessionMessageLogger.Instance.TestRunMessage += (object sender, TestRunMessageEventArgs e) => receivedWarningMessage = e.Message; - var runSettings = new RunSettings(); - runSettings.InitializeSettingsProviders(this.GetRunSettingsWithDuplicateSettingsNodes()); + var runSettings = new RunSettings(); + runSettings.InitializeSettingsProviders(GetRunSettingsWithDuplicateSettingsNodes()); - Assert.IsNotNull(receivedWarningMessage); - Assert.AreEqual( - "Duplicate run settings section named 'RunConfiguration' found. Ignoring the duplicate settings.", - receivedWarningMessage); - } + Assert.IsNotNull(receivedWarningMessage); + Assert.AreEqual( + "Duplicate run settings section named 'RunConfiguration' found. Ignoring the duplicate settings.", + receivedWarningMessage); + } - #endregion + #endregion - #region GetSettings tests + #region GetSettings tests - [TestMethod] - public void GetSettingsShouldThrowIfSettingsNameIsNull() - { - var runSettings = new RunSettings(); + [TestMethod] + public void GetSettingsShouldThrowIfSettingsNameIsNull() + { + var runSettings = new RunSettings(); - Assert.ThrowsException(() => runSettings.GetSettings(null)); - } + Assert.ThrowsException(() => runSettings.GetSettings(null)); + } - [TestMethod] - public void GetSettingsShouldThrowIfSettingsNameIsEmpty() - { - var runSettings = new RunSettings(); + [TestMethod] + public void GetSettingsShouldThrowIfSettingsNameIsEmpty() + { + var runSettings = new RunSettings(); - Assert.ThrowsException(() => runSettings.GetSettings(" ")); - } + Assert.ThrowsException(() => runSettings.GetSettings(" ")); + } - // The remaining GetSettings tests are covered in the InitializeSettingsProviders tests above. - #endregion + // The remaining GetSettings tests are covered in the InitializeSettingsProviders tests above. + #endregion - #region Private methods + #region Private methods - private string GetEmptyRunSettings() - { - return @" + private string GetEmptyRunSettings() + { + return @" "; - } + } - private string GetRunSettingsWithUndefinedSettingsNodes() - { - return @" + private string GetRunSettingsWithUndefinedSettingsNodes() + { + return @" "; - } + } - private string GetRunSettingsWithBadSettingsNodes() - { - return @" + private string GetRunSettingsWithBadSettingsNodes() + { + return @" "; - } + } - private string GetRunSettingsWithRunConfigurationNode() - { - return @" + private string GetRunSettingsWithRunConfigurationNode() + { + return @" x86 "; - } + } - private string GetRunSettingsWithRunConfigurationAndMSTestNode() - { - return @" + private string GetRunSettingsWithRunConfigurationAndMsTestNode() + { + return @" x86 @@ -279,63 +275,62 @@ private string GetRunSettingsWithRunConfigurationAndMSTestNode() true "; - } + } - private string GetRunSettingsWithDuplicateSettingsNodes() - { - return @" + private string GetRunSettingsWithDuplicateSettingsNodes() + { + return @" "; - } + } - private string GetInvalidRunSettings() - { - return @" + private string GetInvalidRunSettings() + { + return @" "; - } + } - #endregion + #endregion - #region Testable Implementations + #region Testable Implementations - [SettingsName("RunConfiguration")] - private class RunConfigurationSettingsProvider : ISettingsProvider - { - public string SettingsTree { get; set; } + [SettingsName("RunConfiguration")] + private class RunConfigurationSettingsProvider : ISettingsProvider + { + public string SettingsTree { get; set; } - public void Load(XmlReader reader) - { - reader.Read(); - this.SettingsTree = reader.ReadOuterXml(); - } + public void Load(XmlReader reader) + { + reader.Read(); + SettingsTree = reader.ReadOuterXml(); } + } - [SettingsName("MSTest")] - private class MSTestSettingsProvider : ISettingsProvider - { - public string SettingsTree { get; set; } + [SettingsName("MSTest")] + private class MsTestSettingsProvider : ISettingsProvider + { + public string SettingsTree { get; set; } - public void Load(XmlReader reader) - { - reader.Read(); - this.SettingsTree = reader.ReadOuterXml(); - } + public void Load(XmlReader reader) + { + reader.Read(); + SettingsTree = reader.ReadOuterXml(); } + } - [SettingsName("BadSettings")] - private class BadSettingsProvider : ISettingsProvider + [SettingsName("BadSettings")] + private class BadSettingsProvider : ISettingsProvider + { + public void Load(XmlReader reader) { - public void Load(XmlReader reader) - { - throw new Exception(); - } + throw new Exception(); } - - #endregion } -} + + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/SettingsProvider/SettingsProviderExtensionManagerTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/SettingsProvider/SettingsProviderExtensionManagerTests.cs index 8269bd5cc1..b6c41be31f 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/SettingsProvider/SettingsProviderExtensionManagerTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/SettingsProvider/SettingsProviderExtensionManagerTests.cs @@ -1,240 +1,238 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.SettingsProvider +namespace TestPlatform.Common.UnitTests.SettingsProvider; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Xml; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.SettingsProvider; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class SettingsProviderExtensionManagerTests { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.SettingsProvider; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - using TestPlatform.Common.UnitTests.ExtensionFramework; - - [TestClass] - public class SettingsProviderExtensionManagerTests + [TestCleanup] + public void TestCleanup() { - [TestCleanup] - public void TestCleanup() - { - SettingsProviderExtensionManager.Destroy(); - } + SettingsProviderExtensionManager.Destroy(); + } - #region Constructor tests + #region Constructor tests - [TestMethod] - public void ConstructorShouldPopulateSettingsProviderMap() + [TestMethod] + public void ConstructorShouldPopulateSettingsProviderMap() + { + var extensions = GetMockExtensions("TestableSettings"); + var unfilteredExtensions = new List>> { - var extensions = this.GetMockExtensions("TestableSettings"); - var unfilteredExtensions = new List>> - { - new LazyExtension> - ( - new Mock().Object, - new Dictionary()) - }; - var spm = new TestableSettingsProviderManager(extensions, unfilteredExtensions, new Mock().Object); - - Assert.IsNotNull(spm.SettingsProvidersMap); - Assert.AreEqual("TestableSettings", spm.SettingsProvidersMap.Keys.FirstOrDefault()); - } + new LazyExtension> + ( + new Mock().Object, + new Dictionary()) + }; + var spm = new TestableSettingsProviderManager(extensions, unfilteredExtensions, new Mock().Object); + + Assert.IsNotNull(spm.SettingsProvidersMap); + Assert.AreEqual("TestableSettings", spm.SettingsProvidersMap.Keys.FirstOrDefault()); + } - [TestMethod] - public void ConstructorShouldLogWarningOnDuplicateSettingsProviderNames() + [TestMethod] + public void ConstructorShouldLogWarningOnDuplicateSettingsProviderNames() + { + var extensions = GetMockExtensions("TestableSettings", "TestableSettings"); + var unfilteredExtensions = new List>> { - var extensions = this.GetMockExtensions("TestableSettings", "TestableSettings"); - var unfilteredExtensions = new List>> - { - new LazyExtension> - ( - new Mock().Object, - new Dictionary()) - }; - var mockLogger = new Mock(); - var spm = new TestableSettingsProviderManager(extensions, unfilteredExtensions, mockLogger.Object); - - mockLogger.Verify( - l => + new LazyExtension> + ( + new Mock().Object, + new Dictionary()) + }; + var mockLogger = new Mock(); + var spm = new TestableSettingsProviderManager(extensions, unfilteredExtensions, mockLogger.Object); + + mockLogger.Verify( + l => l.SendMessage( TestMessageLevel.Error, "Duplicate settings provider named 'TestableSettings'. Ignoring the duplicate provider.")); - // Also validate the below. - Assert.IsNotNull(spm.SettingsProvidersMap); - Assert.AreEqual("TestableSettings", spm.SettingsProvidersMap.Keys.FirstOrDefault()); - } + // Also validate the below. + Assert.IsNotNull(spm.SettingsProvidersMap); + Assert.AreEqual("TestableSettings", spm.SettingsProvidersMap.Keys.FirstOrDefault()); + } - #endregion + #endregion - #region Create tests + #region Create tests - [TestMethod] - public void CreateShouldDiscoverSettingsProviderExtensions() - { - TestPluginCacheHelper.SetupMockExtensions(typeof(SettingsProviderExtensionManagerTests)); + [TestMethod] + public void CreateShouldDiscoverSettingsProviderExtensions() + { + TestPluginCacheHelper.SetupMockExtensions(typeof(SettingsProviderExtensionManagerTests)); - var extensionManager = SettingsProviderExtensionManager.Create(); + var extensionManager = SettingsProviderExtensionManager.Create(); - Assert.IsNotNull(extensionManager.SettingsProvidersMap); - Assert.IsTrue(extensionManager.SettingsProvidersMap.Count > 0); - } + Assert.IsNotNull(extensionManager.SettingsProvidersMap); + Assert.IsTrue(extensionManager.SettingsProvidersMap.Count > 0); + } - [TestMethod] - public void CreateShouldCacheDiscoveredExtensions() - { - TestPluginCacheHelper.SetupMockExtensions(typeof(SettingsProviderExtensionManagerTests), () => { }); + [TestMethod] + public void CreateShouldCacheDiscoveredExtensions() + { + TestPluginCacheHelper.SetupMockExtensions(typeof(SettingsProviderExtensionManagerTests), () => { }); - var extensionManager = SettingsProviderExtensionManager.Create(); - SettingsProviderExtensionManager.Create(); + var extensionManager = SettingsProviderExtensionManager.Create(); + SettingsProviderExtensionManager.Create(); - Assert.IsNotNull(extensionManager.SettingsProvidersMap); - Assert.IsTrue(extensionManager.SettingsProvidersMap.Count > 0); - } + Assert.IsNotNull(extensionManager.SettingsProvidersMap); + Assert.IsTrue(extensionManager.SettingsProvidersMap.Count > 0); + } - #endregion + #endregion - #region LoadAndInitialize tests + #region LoadAndInitialize tests - [TestMethod] - public void LoadAndInitializeShouldInitializeAllExtensions() - { - TestPluginCacheHelper.SetupMockExtensions(typeof(SettingsProviderExtensionManagerTests)); + [TestMethod] + public void LoadAndInitializeShouldInitializeAllExtensions() + { + TestPluginCacheHelper.SetupMockExtensions(typeof(SettingsProviderExtensionManagerTests)); - SettingsProviderExtensionManager.LoadAndInitializeAllExtensions(false); + SettingsProviderExtensionManager.LoadAndInitializeAllExtensions(false); - var settingsProviders = SettingsProviderExtensionManager.Create().SettingsProvidersMap.Values; + var settingsProviders = SettingsProviderExtensionManager.Create().SettingsProvidersMap.Values; - foreach (var provider in settingsProviders) - { - Assert.IsTrue(provider.IsExtensionCreated); - } + foreach (var provider in settingsProviders) + { + Assert.IsTrue(provider.IsExtensionCreated); } + } - #endregion + #endregion - #region GetSettingsProvider tests + #region GetSettingsProvider tests - [TestMethod] - public void GetSettingsProviderShouldThrowIfSettingsNameIsNullOrEmpty() + [TestMethod] + public void GetSettingsProviderShouldThrowIfSettingsNameIsNullOrEmpty() + { + var extensions = GetMockExtensions("TestableSettings"); + var unfilteredExtensions = new List>> { - var extensions = this.GetMockExtensions("TestableSettings"); - var unfilteredExtensions = new List>> - { - new LazyExtension> - ( - new Mock().Object, - new Dictionary()) - }; - var spm = new TestableSettingsProviderManager(extensions, unfilteredExtensions, new Mock().Object); - - Assert.ThrowsException(() => spm.GetSettingsProvider(null)); - Assert.ThrowsException(() => spm.GetSettingsProvider(string.Empty)); - } + new LazyExtension> + ( + new Mock().Object, + new Dictionary()) + }; + var spm = new TestableSettingsProviderManager(extensions, unfilteredExtensions, new Mock().Object); + + Assert.ThrowsException(() => spm.GetSettingsProvider(null)); + Assert.ThrowsException(() => spm.GetSettingsProvider(string.Empty)); + } - [TestMethod] - public void GetSettingsProviderShouldReturnNullIfSettingsProviderWithSpecifiedNameIsNotFound() + [TestMethod] + public void GetSettingsProviderShouldReturnNullIfSettingsProviderWithSpecifiedNameIsNotFound() + { + var extensions = GetMockExtensions("TestableSettings"); + var unfilteredExtensions = new List>> { - var extensions = this.GetMockExtensions("TestableSettings"); - var unfilteredExtensions = new List>> - { - new LazyExtension> - ( - new Mock().Object, - new Dictionary()) - }; - var spm = new TestableSettingsProviderManager(extensions, unfilteredExtensions, new Mock().Object); - - var sp = spm.GetSettingsProvider("RandomSettingsWhichDoesNotExist"); - - Assert.IsNull(sp); - } + new LazyExtension> + ( + new Mock().Object, + new Dictionary()) + }; + var spm = new TestableSettingsProviderManager(extensions, unfilteredExtensions, new Mock().Object); + + var sp = spm.GetSettingsProvider("RandomSettingsWhichDoesNotExist"); + + Assert.IsNull(sp); + } - [TestMethod] - public void GetSettingsProviderShouldReturnSettingsProviderInstance() + [TestMethod] + public void GetSettingsProviderShouldReturnSettingsProviderInstance() + { + var extensions = GetMockExtensions("TestableSettings"); + var unfilteredExtensions = new List>> { - var extensions = this.GetMockExtensions("TestableSettings"); - var unfilteredExtensions = new List>> - { - new LazyExtension> - ( - new Mock().Object, - new Dictionary()) - }; - var spm = new TestableSettingsProviderManager(extensions, unfilteredExtensions, new Mock().Object); - - var sp = spm.GetSettingsProvider("TestableSettings"); - - Assert.IsNotNull(sp); - Assert.IsNotNull(sp.Value); - } + new LazyExtension> + ( + new Mock().Object, + new Dictionary()) + }; + var spm = new TestableSettingsProviderManager(extensions, unfilteredExtensions, new Mock().Object); - #endregion + var sp = spm.GetSettingsProvider("TestableSettings"); - #region private methods + Assert.IsNotNull(sp); + Assert.IsNotNull(sp.Value); + } - private IEnumerable> GetMockExtensions(params string[] settingNames) - { - var settingsList = new List>(); + #endregion - foreach (var settingName in settingNames) - { - var mockSettingsProvider = new Mock(); - var metadata = new TestSettingsProviderMetadata(settingName); + #region private methods - var extension = - new LazyExtension( - mockSettingsProvider.Object, - metadata); + private IEnumerable> GetMockExtensions(params string[] settingNames) + { + var settingsList = new List>(); - settingsList.Add(extension); - } + foreach (var settingName in settingNames) + { + var mockSettingsProvider = new Mock(); + var metadata = new TestSettingsProviderMetadata(settingName); - return settingsList; + var extension = + new LazyExtension( + mockSettingsProvider.Object, + metadata); + + settingsList.Add(extension); } - #endregion + return settingsList; + } - #region Testable Implementations + #endregion - private class TestableSettingsProviderManager : SettingsProviderExtensionManager - { - public TestableSettingsProviderManager( - IEnumerable> settingsProviders, - IEnumerable>> unfilteredSettingsProviders, - IMessageLogger logger) - : base(settingsProviders, unfilteredSettingsProviders, logger) - { - } - } + #region Testable Implementations - [SettingsName("Random")] - private class RandomSettingsProvider : ISettingsProvider + private class TestableSettingsProviderManager : SettingsProviderExtensionManager + { + public TestableSettingsProviderManager( + IEnumerable> settingsProviders, + IEnumerable>> unfilteredSettingsProviders, + IMessageLogger logger) + : base(settingsProviders, unfilteredSettingsProviders, logger) { - public void Load(XmlReader reader) - { - } } - - #endregion } - [TestClass] - public class TestSettingsProviderMetadataTests + [SettingsName("Random")] + private class RandomSettingsProvider : ISettingsProvider { - [TestMethod] - public void ConstructorShouldSetSettingsName() + public void Load(XmlReader reader) { - var metadata = new TestSettingsProviderMetadata("sample"); - Assert.AreEqual("sample", metadata.SettingsName); } } + + #endregion } + +[TestClass] +public class TestSettingsProviderMetadataTests +{ + [TestMethod] + public void ConstructorShouldSetSettingsName() + { + var metadata = new TestSettingsProviderMetadata("sample"); + Assert.AreEqual("sample", metadata.SettingsName); + } +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/Telemetry/MetricsCollectionTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/Telemetry/MetricsCollectionTests.cs index b66c2b355d..c59a4d590c 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/Telemetry/MetricsCollectionTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/Telemetry/MetricsCollectionTests.cs @@ -1,60 +1,60 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Common.UnitTests.Telemetry +namespace Microsoft.TestPlatform.Common.UnitTests.Telemetry; + +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class MetricsCollectionTests { - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestTools.UnitTesting; + private readonly IMetricsCollection _metricsCollection; + + public MetricsCollectionTests() + { + _metricsCollection = new MetricsCollection(); + } + + [TestMethod] + public void AddShouldAddMetric() + { + _metricsCollection.Add("DummyMessage", "DummyValue"); + + Assert.IsTrue(_metricsCollection.Metrics.TryGetValue("DummyMessage", out var value)); + Assert.AreEqual("DummyValue", value); + } + + [TestMethod] + public void AddShouldUpdateMetricIfSameKeyIsPresentAlready() + { + _metricsCollection.Add("DummyMessage", "DummyValue"); + + Assert.IsTrue(_metricsCollection.Metrics.TryGetValue("DummyMessage", out var value)); + Assert.AreEqual("DummyValue", value); + + _metricsCollection.Add("DummyMessage", "newValue"); + + Assert.IsTrue(_metricsCollection.Metrics.TryGetValue("DummyMessage", out var newValue)); + Assert.AreEqual("newValue", newValue); + } + + [TestMethod] + public void MetricsShouldReturnValidMetricsIfValidItemsAreThere() + { + _metricsCollection.Add("DummyMessage", "DummyValue"); + _metricsCollection.Add("DummyMessage2", "DummyValue"); + + Assert.AreEqual(2, _metricsCollection.Metrics.Count); + Assert.IsTrue(_metricsCollection.Metrics.ContainsKey("DummyMessage")); + Assert.IsTrue(_metricsCollection.Metrics.ContainsKey("DummyMessage2")); + } - [TestClass] - public class MetricsCollectionTests + [TestMethod] + public void MetricsShouldReturnEmptyDictionaryIfMetricsIsEmpty() { - private IMetricsCollection metricsCollection; - - public MetricsCollectionTests() - { - this.metricsCollection = new MetricsCollection(); - } - - [TestMethod] - public void AddShouldAddMetric() - { - this.metricsCollection.Add("DummyMessage", "DummyValue"); - - Assert.IsTrue(this.metricsCollection.Metrics.TryGetValue("DummyMessage", out var value)); - Assert.AreEqual("DummyValue", value); - } - - [TestMethod] - public void AddShouldUpdateMetricIfSameKeyIsPresentAlready() - { - this.metricsCollection.Add("DummyMessage", "DummyValue"); - - Assert.IsTrue(this.metricsCollection.Metrics.TryGetValue("DummyMessage", out var value)); - Assert.AreEqual("DummyValue", value); - - this.metricsCollection.Add("DummyMessage", "newValue"); - - Assert.IsTrue(this.metricsCollection.Metrics.TryGetValue("DummyMessage", out var newValue)); - Assert.AreEqual("newValue", newValue); - } - - [TestMethod] - public void MetricsShouldReturnValidMetricsIfValidItemsAreThere() - { - this.metricsCollection.Add("DummyMessage", "DummyValue"); - this.metricsCollection.Add("DummyMessage2", "DummyValue"); - - Assert.AreEqual(2, this.metricsCollection.Metrics.Count); - Assert.IsTrue(this.metricsCollection.Metrics.ContainsKey("DummyMessage")); - Assert.IsTrue(this.metricsCollection.Metrics.ContainsKey("DummyMessage2")); - } - - [TestMethod] - public void MetricsShouldReturnEmptyDictionaryIfMetricsIsEmpty() - { - Assert.AreEqual(0, this.metricsCollection.Metrics.Count); - } + Assert.AreEqual(0, _metricsCollection.Metrics.Count); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/ExceptionUtilitiesTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/ExceptionUtilitiesTests.cs index bc4164e94b..5ea15e45a9 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/ExceptionUtilitiesTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/ExceptionUtilitiesTests.cs @@ -1,63 +1,62 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.Utilities +namespace TestPlatform.Common.UnitTests.Utilities; + +using System; + +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class ExceptionUtilitiesTests { - using System; + [TestMethod] + public void GetExceptionMessageShouldReturnEmptyIfExceptionIsNull() + { + Assert.AreEqual(string.Empty, ExceptionUtilities.GetExceptionMessage(null)); + } - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; + [TestMethod] + public void GetExceptionMessageShouldReturnExceptionMessage() + { + var exception = new ArgumentException("Some bad stuff"); + Assert.AreEqual(exception.Message, ExceptionUtilities.GetExceptionMessage(exception)); + } - [TestClass] - public class ExceptionUtilitiesTests + [TestMethod] + public void GetExceptionMessageShouldReturnExceptionMessageContainingAllExceptionMessages() { - [TestMethod] - public void GetExceptionMessageShouldReturnEmptyIfExceptionIsNull() - { - Assert.AreEqual(string.Empty, ExceptionUtilities.GetExceptionMessage(null)); - } + var innerException = new Exception("Bad stuff internally"); + var innerException2 = new Exception("Bad stuff internally 2", innerException); + var exception = new ArgumentException("Some bad stuff", innerException2); - [TestMethod] - public void GetExceptionMessageShouldReturnExceptionMessage() - { - var exception = new ArgumentException("Some bad stuff"); - Assert.AreEqual(exception.Message, ExceptionUtilities.GetExceptionMessage(exception)); - } + var message = ExceptionUtilities.GetExceptionMessage(exception); + StringAssert.Contains(message, exception.Message); + StringAssert.Contains(message, innerException.Message); + StringAssert.Contains(message, innerException.Message); + } + + [TestMethod] + public void GetExceptionMessageShouldReturnExceptionMessageContainingStackTrace() + { + var message = ExceptionUtilities.GetExceptionMessage(GetExceptionWithStackTrace()); + StringAssert.Contains(message, "Stack trace:"); + // this test is where it or + StringAssert.Contains(message, "ExceptionUtilitiesTests.GetExceptionWithStackTrace"); + } - [TestMethod] - public void GetExceptionMessageShouldReturnExceptionMessageContainingAllExceptionMessages() + private Exception GetExceptionWithStackTrace() + { + try { var innerException = new Exception("Bad stuff internally"); var innerException2 = new Exception("Bad stuff internally 2", innerException); - var exception = new ArgumentException("Some bad stuff", innerException2); - - var message = ExceptionUtilities.GetExceptionMessage(exception); - StringAssert.Contains(message, exception.Message); - StringAssert.Contains(message, innerException.Message); - StringAssert.Contains(message, innerException.Message); + throw new ArgumentException("Some bad stuff", innerException2); } - - [TestMethod] - public void GetExceptionMessageShouldReturnExceptionMessageContainingStackTrace() - { - var message = ExceptionUtilities.GetExceptionMessage(GetExceptionWithStackTrace()); - StringAssert.Contains(message, "Stack trace:"); - // this test is where it or - StringAssert.Contains(message, "ExceptionUtilitiesTests.GetExceptionWithStackTrace"); - } - - private Exception GetExceptionWithStackTrace() + catch (Exception e) { - try - { - var innerException = new Exception("Bad stuff internally"); - var innerException2 = new Exception("Bad stuff internally 2", innerException); - throw new ArgumentException("Some bad stuff", innerException2); - } - catch (Exception e) - { - return e; - } + return e; } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/FakesUtilitiesTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/FakesUtilitiesTests.cs index 4f86da5191..287302f9d0 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/FakesUtilitiesTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/FakesUtilitiesTests.cs @@ -1,124 +1,124 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.Utilities +namespace TestPlatform.Common.UnitTests.Utilities; + +using System; +using System.IO; +using System.Xml; + +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class FakesUtilitiesTests { - using System; - using System.IO; - using System.Xml; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; + [TestMethod] + public void FakesSettingsShouldThrowExceptionIfSourcesArePassedAsNull() + { + string runSettingsXml = @".netstandard,Version=5.0"; + Assert.ThrowsException(() => FakesUtilities.GenerateFakesSettingsForRunConfiguration(null, runSettingsXml)); + } - [TestClass] - public class FakesUtilitiesTests + [TestMethod] + public void FakesSettingsShouldThrowExceptionIfRunSettingsIsPassedAsNull() { - [TestMethod] - public void FakesSettingsShouldThrowExceptionIfSourcesArePassedAsNull() - { - string runSettingsXml = @".netstandard,Version=5.0"; - Assert.ThrowsException(() => FakesUtilities.GenerateFakesSettingsForRunConfiguration(null, runSettingsXml)); - } + Assert.ThrowsException(() => FakesUtilities.GenerateFakesSettingsForRunConfiguration(new string[] { }, null)); + } - [TestMethod] - public void FakesSettingsShouldThrowExceptionIfRunSettingsIsPassedAsNull() - { - Assert.ThrowsException(() => FakesUtilities.GenerateFakesSettingsForRunConfiguration(new string[] { }, null)); - } + [TestMethod] + public void FakesSettingsShouldBeNotGeneratedIfFakeConfiguratorAssemblyIsNotPresent() + { + string runSettingsXml = @""; + var generatedRunSettings = FakesUtilities.GenerateFakesSettingsForRunConfiguration(new string[] { @"C:\temp\UT.dll" }, runSettingsXml); + Assert.AreEqual(generatedRunSettings, runSettingsXml); + } - [TestMethod] - public void FakesSettingsShouldBeNotGeneratedIfFakeConfiguratorAssemblyIsNotPresent() + [TestMethod] + public void FakesDataCollectorSettingsShouldBeOverridden() + { + string runSettingsXml = @""; + var doc = new XmlDocument(); + using (var xmlReader = XmlReader.Create( + new StringReader(runSettingsXml), + new XmlReaderSettings() { CloseInput = true })) { - string runSettingsXml = @""; - var generatedRunSettings = FakesUtilities.GenerateFakesSettingsForRunConfiguration(new string[] {@"C:\temp\UT.dll" }, runSettingsXml); - Assert.AreEqual(generatedRunSettings, runSettingsXml); + doc.Load(xmlReader); } - [TestMethod] - public void FakesDataCollectorSettingsShouldBeOverridden() + var dataCollectorNode = new DataCollectorSettings() { - string runSettingsXml = @""; - var doc = new XmlDocument(); - using (var xmlReader = XmlReader.Create( - new StringReader(runSettingsXml), - new XmlReaderSettings() { CloseInput = true })) - { - doc.Load(xmlReader); - } + AssemblyQualifiedName = FakesUtilities.FakesMetadata.DataCollectorAssemblyQualifiedName, + Uri = new Uri(FakesUtilities.FakesMetadata.DataCollectorUriV1), + FriendlyName = FakesUtilities.FakesMetadata.FriendlyName, + IsEnabled = true, + Configuration = doc.FirstChild as XmlElement + }; + XmlRunSettingsUtilities.InsertDataCollectorsNode(doc.CreateNavigator(), dataCollectorNode); - var dataCollectorNode = new DataCollectorSettings() - { - AssemblyQualifiedName = FakesUtilities.FakesMetadata.DataCollectorAssemblyQualifiedName, - Uri = new Uri(FakesUtilities.FakesMetadata.DataCollectorUriV1), - FriendlyName = FakesUtilities.FakesMetadata.FriendlyName, - IsEnabled = true, - Configuration = doc.FirstChild as XmlElement - }; - XmlRunSettingsUtilities.InsertDataCollectorsNode(doc.CreateNavigator(), dataCollectorNode); + var dataCollectorNode2 = new DataCollectorSettings() + { + AssemblyQualifiedName = FakesUtilities.FakesMetadata.DataCollectorAssemblyQualifiedName, + Uri = new Uri(FakesUtilities.FakesMetadata.DataCollectorUriV2), + FriendlyName = FakesUtilities.FakesMetadata.FriendlyName, + IsEnabled = true, + Configuration = doc.FirstChild as XmlElement + }; + FakesUtilities.InsertOrReplaceFakesDataCollectorNode(doc, dataCollectorNode2); - var dataCollectorNode2 = new DataCollectorSettings() - { - AssemblyQualifiedName = FakesUtilities.FakesMetadata.DataCollectorAssemblyQualifiedName, - Uri = new Uri(FakesUtilities.FakesMetadata.DataCollectorUriV2), - FriendlyName = FakesUtilities.FakesMetadata.FriendlyName, - IsEnabled = true, - Configuration = doc.FirstChild as XmlElement - }; - FakesUtilities.InsertOrReplaceFakesDataCollectorNode(doc, dataCollectorNode2); + Assert.IsFalse(XmlRunSettingsUtilities.ContainsDataCollector(doc, FakesUtilities.FakesMetadata.DataCollectorUriV1)); + Assert.IsTrue(XmlRunSettingsUtilities.ContainsDataCollector(doc, FakesUtilities.FakesMetadata.DataCollectorUriV2)); + } - Assert.IsFalse(XmlRunSettingsUtilities.ContainsDataCollector(doc, FakesUtilities.FakesMetadata.DataCollectorUriV1)); - Assert.IsTrue(XmlRunSettingsUtilities.ContainsDataCollector(doc, FakesUtilities.FakesMetadata.DataCollectorUriV2)); + [TestMethod] + public void FakesDataCollectorSettingsShouldBeInserted() + { + string runSettingsXml = @""; + var doc = new XmlDocument(); + using (var xmlReader = XmlReader.Create( + new StringReader(runSettingsXml), + new XmlReaderSettings() { CloseInput = true })) + { + doc.Load(xmlReader); } - [TestMethod] - public void FakesDataCollectorSettingsShouldBeInserted() + var dataCollectorNode2 = new DataCollectorSettings() { - string runSettingsXml = @""; - var doc = new XmlDocument(); - using (var xmlReader = XmlReader.Create( - new StringReader(runSettingsXml), - new XmlReaderSettings() { CloseInput = true })) - { - doc.Load(xmlReader); - } + AssemblyQualifiedName = FakesUtilities.FakesMetadata.DataCollectorAssemblyQualifiedName, + Uri = new Uri(FakesUtilities.FakesMetadata.DataCollectorUriV2), + FriendlyName = FakesUtilities.FakesMetadata.FriendlyName, + IsEnabled = true, + Configuration = doc.FirstChild as XmlElement + }; + FakesUtilities.InsertOrReplaceFakesDataCollectorNode(doc, dataCollectorNode2); + Assert.IsTrue(XmlRunSettingsUtilities.ContainsDataCollector(doc, FakesUtilities.FakesMetadata.DataCollectorUriV2)); + } - var dataCollectorNode2 = new DataCollectorSettings() - { - AssemblyQualifiedName = FakesUtilities.FakesMetadata.DataCollectorAssemblyQualifiedName, - Uri = new Uri(FakesUtilities.FakesMetadata.DataCollectorUriV2), - FriendlyName = FakesUtilities.FakesMetadata.FriendlyName, - IsEnabled = true, - Configuration = doc.FirstChild as XmlElement - }; - FakesUtilities.InsertOrReplaceFakesDataCollectorNode(doc, dataCollectorNode2); - Assert.IsTrue(XmlRunSettingsUtilities.ContainsDataCollector(doc, FakesUtilities.FakesMetadata.DataCollectorUriV2)); + [TestMethod] + public void OtherRunsettingsShouldNotBeChanged() + { + string runSettingsXml = @"FrameworkCore10"; + var doc = new XmlDocument(); + using (var xmlReader = XmlReader.Create( + new StringReader(runSettingsXml), + new XmlReaderSettings() { CloseInput = true })) + { + doc.Load(xmlReader); } - [TestMethod] - public void OtherRunsettingsShouldNotBeChanged() + var dataCollectorNode2 = new DataCollectorSettings() { - string runSettingsXml = @"FrameworkCore10"; - var doc = new XmlDocument(); - using (var xmlReader = XmlReader.Create( - new StringReader(runSettingsXml), - new XmlReaderSettings() { CloseInput = true })) - { - doc.Load(xmlReader); - } - - var dataCollectorNode2 = new DataCollectorSettings() - { - AssemblyQualifiedName = FakesUtilities.FakesMetadata.DataCollectorAssemblyQualifiedName, - Uri = new Uri(FakesUtilities.FakesMetadata.DataCollectorUriV2), - FriendlyName = FakesUtilities.FakesMetadata.FriendlyName, - IsEnabled = true, - Configuration = doc.CreateElement("Configuration") - }; - FakesUtilities.InsertOrReplaceFakesDataCollectorNode(doc, dataCollectorNode2); - Assert.IsTrue(XmlRunSettingsUtilities.ContainsDataCollector(doc, FakesUtilities.FakesMetadata.DataCollectorUriV2)); - XmlNodeList nodes = doc.SelectNodes("//RunSettings/RunConfiguration/TargetFrameworkVersion"); - Assert.AreEqual("FrameworkCore10", nodes[0].InnerText); - } + AssemblyQualifiedName = FakesUtilities.FakesMetadata.DataCollectorAssemblyQualifiedName, + Uri = new Uri(FakesUtilities.FakesMetadata.DataCollectorUriV2), + FriendlyName = FakesUtilities.FakesMetadata.FriendlyName, + IsEnabled = true, + Configuration = doc.CreateElement("Configuration") + }; + FakesUtilities.InsertOrReplaceFakesDataCollectorNode(doc, dataCollectorNode2); + Assert.IsTrue(XmlRunSettingsUtilities.ContainsDataCollector(doc, FakesUtilities.FakesMetadata.DataCollectorUriV2)); + XmlNodeList nodes = doc.SelectNodes("//RunSettings/RunConfiguration/TargetFrameworkVersion"); + Assert.AreEqual("FrameworkCore10", nodes[0].InnerText); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/InstallationContextTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/InstallationContextTests.cs index b952f86484..dda4f28b52 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/InstallationContextTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/InstallationContextTests.cs @@ -1,69 +1,68 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Common.UnitTests.Utilities +namespace Microsoft.TestPlatform.Common.UnitTests.Utilities; + +using System.IO; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using VisualStudio.TestTools.UnitTesting; +using Moq; +using System.Linq; + +[TestClass] +public class InstallationContextTests { - using System.IO; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using System.Linq; + private readonly Mock _mockFileHelper; + private readonly InstallationContext _installationContext; - [TestClass] - public class InstallationContextTests + public InstallationContextTests() { - private Mock mockFileHelper; - private InstallationContext installationContext; - - public InstallationContextTests() - { - this.mockFileHelper = new Mock(); - this.installationContext = new InstallationContext(this.mockFileHelper.Object); - } + _mockFileHelper = new Mock(); + _installationContext = new InstallationContext(_mockFileHelper.Object); + } - [TestMethod] - public void TryGetVisualStudioDirectoryShouldReturnTrueIfVSIsFound() - { - this.mockFileHelper.Setup(m => m.Exists(It.IsAny())).Returns(true); + [TestMethod] + public void TryGetVisualStudioDirectoryShouldReturnTrueIfVsIsFound() + { + _mockFileHelper.Setup(m => m.Exists(It.IsAny())).Returns(true); - Assert.IsTrue(this.installationContext.TryGetVisualStudioDirectory(out string visualStudioDirectory), "VS Install Directory returned false"); + Assert.IsTrue(_installationContext.TryGetVisualStudioDirectory(out string visualStudioDirectory), "VS Install Directory returned false"); - Assert.IsTrue(Directory.Exists(visualStudioDirectory), "VS Install Directory doesn't exist"); - } + Assert.IsTrue(Directory.Exists(visualStudioDirectory), "VS Install Directory doesn't exist"); + } - [TestMethod] - public void TryGetVisualStudioDirectoryShouldReturnFalseIfVSIsNotFound() - { - this.mockFileHelper.Setup(m => m.Exists(It.IsAny())).Returns(false); + [TestMethod] + public void TryGetVisualStudioDirectoryShouldReturnFalseIfVsIsNotFound() + { + _mockFileHelper.Setup(m => m.Exists(It.IsAny())).Returns(false); - Assert.IsFalse(this.installationContext.TryGetVisualStudioDirectory(out string visualStudioDirectory), "VS Install Directory returned true"); + Assert.IsFalse(_installationContext.TryGetVisualStudioDirectory(out string visualStudioDirectory), "VS Install Directory returned true"); - Assert.IsTrue(string.IsNullOrEmpty(visualStudioDirectory), "VS Install Directory is not empty"); - } + Assert.IsTrue(string.IsNullOrEmpty(visualStudioDirectory), "VS Install Directory is not empty"); + } - [TestMethod] - public void GetVisualStudioPathShouldReturnPathToDevenvExecutable() - { - var devenvPath = this.installationContext.GetVisualStudioPath(@"C:\temp"); + [TestMethod] + public void GetVisualStudioPathShouldReturnPathToDevenvExecutable() + { + var devenvPath = _installationContext.GetVisualStudioPath(@"C:\temp"); - Assert.AreEqual(@"C:\temp\devenv.exe", devenvPath.Replace("/", "\\")); - } + Assert.AreEqual(@"C:\temp\devenv.exe", devenvPath.Replace("/", "\\")); + } - [TestMethod] - public void GetVisualStudioCommonLocationShouldReturnWellKnownLocations() + [TestMethod] + public void GetVisualStudioCommonLocationShouldReturnWellKnownLocations() + { + var expectedLocations = new[] { - var expectedLocations = new[] - { - @"C:\temp\PrivateAssemblies", - @"C:\temp\PublicAssemblies", - @"C:\temp\CommonExtensions\Microsoft\TestWindow", - @"C:\temp\CommonExtensions\Microsoft\TeamFoundation\Team Explorer", - @"C:\temp" - }; - var commonLocations = this.installationContext.GetVisualStudioCommonLocations(@"C:\temp").Select(p => p.Replace("/", "\\")).ToArray(); + @"C:\temp\PrivateAssemblies", + @"C:\temp\PublicAssemblies", + @"C:\temp\CommonExtensions\Microsoft\TestWindow", + @"C:\temp\CommonExtensions\Microsoft\TeamFoundation\Team Explorer", + @"C:\temp" + }; + var commonLocations = _installationContext.GetVisualStudioCommonLocations(@"C:\temp").Select(p => p.Replace("/", "\\")).ToArray(); - CollectionAssert.AreEquivalent(expectedLocations, commonLocations); - } + CollectionAssert.AreEquivalent(expectedLocations, commonLocations); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/MetadataReaderHelperTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/MetadataReaderHelperTests.cs index 2edefa0507..322f7bd90e 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/MetadataReaderHelperTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/MetadataReaderHelperTests.cs @@ -5,46 +5,46 @@ using System.IO; using System.Linq; using System.Reflection; + using Microsoft.VisualStudio.TestPlatform.Common.Utilities; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace TestPlatform.Common.UnitTests.Utilities +namespace TestPlatform.Common.UnitTests.Utilities; + +[TestClass] +public class MetadataReaderHelperTests { - [TestClass] - public class MetadataReaderHelperTests - { - private readonly MetadataReaderExtensionsHelper metadataReaderHelper = new MetadataReaderExtensionsHelper(); + private readonly MetadataReaderExtensionsHelper _metadataReaderHelper = new(); - [TestMethod] - public void MetadataReaderHelper_GetCollectorExtensionTypes() - { - string testAssetsPath = GetTestAssetsFolder(); - var dataCollectorFilePath = Directory.GetFiles(testAssetsPath, "AttachmentProcessorDataCollector.dll", SearchOption.AllDirectories).Where(x => x.Contains("bin")).Single(); - var types = metadataReaderHelper.DiscoverTestExtensionTypesV2Attribute(Assembly.LoadFile(dataCollectorFilePath), dataCollectorFilePath); - Assert.IsTrue(types.Any(), $"File {dataCollectorFilePath}"); - Assert.IsTrue(types[0].AssemblyQualifiedName.StartsWith("AttachmentProcessorDataCollector.SampleDataCollectorV2"), $"File {dataCollectorFilePath}"); - Assert.AreEqual(dataCollectorFilePath.Replace("/", @"\"), types[0].Assembly.Location.Replace("/", @"\"), $"File {dataCollectorFilePath}"); - Assert.IsTrue(types[1].AssemblyQualifiedName.StartsWith("AttachmentProcessorDataCollector.SampleDataCollectorV1"), $"File {dataCollectorFilePath}"); - Assert.AreEqual(dataCollectorFilePath.Replace("/", @"\"), types[1].Assembly.Location.Replace("/", @"\"), $"File {dataCollectorFilePath}"); - } + [TestMethod] + public void MetadataReaderHelper_GetCollectorExtensionTypes() + { + string testAssetsPath = GetTestAssetsFolder(); + var dataCollectorFilePath = Directory.GetFiles(testAssetsPath, "AttachmentProcessorDataCollector.dll", SearchOption.AllDirectories).Where(x => x.Contains("bin")).Single(); + var types = _metadataReaderHelper.DiscoverTestExtensionTypesV2Attribute(Assembly.LoadFile(dataCollectorFilePath), dataCollectorFilePath); + Assert.IsTrue(types.Any(), $"File {dataCollectorFilePath}"); + Assert.IsTrue(types[0].AssemblyQualifiedName.StartsWith("AttachmentProcessorDataCollector.SampleDataCollectorV2"), $"File {dataCollectorFilePath}"); + Assert.AreEqual(dataCollectorFilePath.Replace("/", @"\"), types[0].Assembly.Location.Replace("/", @"\"), $"File {dataCollectorFilePath}"); + Assert.IsTrue(types[1].AssemblyQualifiedName.StartsWith("AttachmentProcessorDataCollector.SampleDataCollectorV1"), $"File {dataCollectorFilePath}"); + Assert.AreEqual(dataCollectorFilePath.Replace("/", @"\"), types[1].Assembly.Location.Replace("/", @"\"), $"File {dataCollectorFilePath}"); + } - private string GetTestAssetsFolder() + private string GetTestAssetsFolder() + { + string current = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + while (true) { - string current = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - while (true) + if (File.Exists(Path.Combine(current, "TestPlatform.sln"))) + { + string testAssetsPath = Path.Combine(current, @"test/TestAssets"); + Assert.IsTrue(Directory.Exists(testAssetsPath), $"Directory not found '{testAssetsPath}'"); + return testAssetsPath; + } + current = Path.GetDirectoryName(current); + if (current == Path.GetPathRoot(current)) { - if (File.Exists(Path.Combine(current, "TestPlatform.sln"))) - { - string testAssetsPath = Path.Combine(current, @"test/TestAssets"); - Assert.IsTrue(Directory.Exists(testAssetsPath), $"Directory not found '{testAssetsPath}'"); - return testAssetsPath; - } - current = Path.GetDirectoryName(current); - if (current == Path.GetPathRoot(current)) - { - throw new Exception("Repo root path not tound"); - } + throw new Exception("Repo root path not tound"); } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/RunSettingsUtilitiesTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/RunSettingsUtilitiesTests.cs index 8b4a40cf10..cfcb80e7ba 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/RunSettingsUtilitiesTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/RunSettingsUtilitiesTests.cs @@ -1,124 +1,115 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.Common.UnitTests.Utilities +namespace TestPlatform.Common.UnitTests.Utilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using System.Xml; +using Microsoft.TestPlatform.TestUtilities; + +[TestClass] +public class RunSettingsUtilitiesTests { - using System; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using System.Xml; - using ExtensionFramework; - using System.Collections.Generic; - using Microsoft.TestPlatform.TestUtilities; - - [TestClass] - public class RunSettingsUtilitiesTests + [TestMethod] + public void CreateRunSettingsShouldReturnNullIfSettingsXmlIsNullorEmpty() { - [TestMethod] - public void CreateRunSettingsShouldReturnNullIfSettingsXmlIsNullorEmpty() - { - Assert.IsNull(RunSettingsUtilities.CreateAndInitializeRunSettings(null)); - } - - [TestMethod] - public void CreateRunSettingsShouldThrowExceptionWhenInvalidXmlStringIsPassed() - { - Assert.ThrowsException(() => - { - RunSettingsUtilities.CreateAndInitializeRunSettings("abc"); - } - ); - } - - [TestMethod] - public void CreateRunSettingsShouldReturnValidRunSettings() - { - TestPluginCacheHelper.SetupMockExtensions(typeof(RunSettingsUtilitiesTests)); - string runsettings = @".\TestResultstrue"; - var result= RunSettingsUtilities.CreateAndInitializeRunSettings(runsettings); - Assert.AreEqual("true", DummyMsTestSetingsProvider.StringToVerify); - TestPluginCacheHelper.ResetExtensionsCache(); - } - - [TestMethod] - public void GetMaxCpuCountWithNullSettingXmlShouldReturnDefaultCpuCount() - { - string settingXml = null; - int expectedResult = Constants.DefaultCpuCount; - - int result = RunSettingsUtilities.GetMaxCpuCount(settingXml); - - Assert.AreEqual(expectedResult, result); - } - - [TestMethod] - public void GetMaxCpuCountWithEmptySettingXmlShouldReturnDefaultCpuCount() - { - string settingXml = ""; - int expectedResult = Constants.DefaultCpuCount; - - int result = RunSettingsUtilities.GetMaxCpuCount(settingXml); - - Assert.AreEqual(expectedResult, result); - } - - [TestMethod] - public void GetMaxCpuCountWithSettingXmlNotHavingCpuCountShouldReturnDefaultCpuCount() - { - string settingXml = @""; - int expectedResult = Constants.DefaultCpuCount; - - int result = RunSettingsUtilities.GetMaxCpuCount(settingXml); - - Assert.AreEqual(expectedResult, result); - } - - [TestMethod] - public void GetMaxCpuCountWithSettingXmlCpuCountShouldReturnCorrectCpuCount() - { - string settingXml = @"5"; - int expectedResult = 5; - - int result = RunSettingsUtilities.GetMaxCpuCount(settingXml); - - Assert.AreEqual(expectedResult, result); - } - - [TestMethod] - public void GetMaxCpuCountWithInvalidCpuCountShouldReturnDefaultCpuCount() - { - string settingXml = @"-10"; - int expectedResult = Constants.DefaultCpuCount; - - int result = RunSettingsUtilities.GetMaxCpuCount(settingXml); - - Assert.AreEqual(expectedResult, result); - } - - [TestMethod] - public void GetTestAdaptersPaths() - { - string settingXml = @"C:\testadapterpath;D:\secondtestadapterpath"; - string[] expectedResult = new string[] { @"C:\testadapterpath", @"D:\secondtestadapterpath" }; - - string[] result = (string[])RunSettingsUtilities.GetTestAdaptersPaths(settingXml); - - CollectionAssert.AreEqual(expectedResult, result); - } + Assert.IsNull(RunSettingsUtilities.CreateAndInitializeRunSettings(null)); } - [SettingsName("DummyMSTest")] - public class DummyMsTestSetingsProvider : ISettingsProvider + [TestMethod] + public void CreateRunSettingsShouldThrowExceptionWhenInvalidXmlStringIsPassed() { - public void Load(XmlReader reader) - { - ValidateArg.NotNull(reader, nameof(reader)); - reader.Read(); - StringToVerify = reader.ReadOuterXml(); - } - - public static string StringToVerify = string.Empty; + Assert.ThrowsException(() => RunSettingsUtilities.CreateAndInitializeRunSettings("abc")); + } + + [TestMethod] + public void CreateRunSettingsShouldReturnValidRunSettings() + { + TestPluginCacheHelper.SetupMockExtensions(typeof(RunSettingsUtilitiesTests)); + string runsettings = @".\TestResultstrue"; + _ = RunSettingsUtilities.CreateAndInitializeRunSettings(runsettings); + Assert.AreEqual("true", DummyMsTestSetingsProvider.StringToVerify); + TestPluginCacheHelper.ResetExtensionsCache(); + } + + [TestMethod] + public void GetMaxCpuCountWithNullSettingXmlShouldReturnDefaultCpuCount() + { + string settingXml = null; + int expectedResult = Constants.DefaultCpuCount; + + int result = RunSettingsUtilities.GetMaxCpuCount(settingXml); + + Assert.AreEqual(expectedResult, result); + } + + [TestMethod] + public void GetMaxCpuCountWithEmptySettingXmlShouldReturnDefaultCpuCount() + { + string settingXml = ""; + int expectedResult = Constants.DefaultCpuCount; + + int result = RunSettingsUtilities.GetMaxCpuCount(settingXml); + + Assert.AreEqual(expectedResult, result); + } + + [TestMethod] + public void GetMaxCpuCountWithSettingXmlNotHavingCpuCountShouldReturnDefaultCpuCount() + { + string settingXml = @""; + int expectedResult = Constants.DefaultCpuCount; + + int result = RunSettingsUtilities.GetMaxCpuCount(settingXml); + + Assert.AreEqual(expectedResult, result); + } + + [TestMethod] + public void GetMaxCpuCountWithSettingXmlCpuCountShouldReturnCorrectCpuCount() + { + string settingXml = @"5"; + int expectedResult = 5; + + int result = RunSettingsUtilities.GetMaxCpuCount(settingXml); + + Assert.AreEqual(expectedResult, result); + } + + [TestMethod] + public void GetMaxCpuCountWithInvalidCpuCountShouldReturnDefaultCpuCount() + { + string settingXml = @"-10"; + int expectedResult = Constants.DefaultCpuCount; + + int result = RunSettingsUtilities.GetMaxCpuCount(settingXml); + + Assert.AreEqual(expectedResult, result); + } + + [TestMethod] + public void GetTestAdaptersPaths() + { + string settingXml = @"C:\testadapterpath;D:\secondtestadapterpath"; + string[] expectedResult = new string[] { @"C:\testadapterpath", @"D:\secondtestadapterpath" }; + + string[] result = (string[])RunSettingsUtilities.GetTestAdaptersPaths(settingXml); + + CollectionAssert.AreEqual(expectedResult, result); } } + +[SettingsName("DummyMSTest")] +public class DummyMsTestSetingsProvider : ISettingsProvider +{ + public void Load(XmlReader reader) + { + ValidateArg.NotNull(reader, nameof(reader)); + reader.Read(); + StringToVerify = reader.ReadOuterXml(); + } + + public static string StringToVerify = string.Empty; +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/Program.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/Program.cs index a0ee0a2eb5..9ac283d130 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/Program.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/Program.cs @@ -1,12 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.PlatformTests +namespace Microsoft.TestPlatform.CommunicationUtilities.PlatformTests; + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/SocketClientTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/SocketClientTests.cs index 35f3907d41..46ab0c51b7 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/SocketClientTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/SocketClientTests.cs @@ -1,182 +1,182 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.PlatformTests +namespace Microsoft.TestPlatform.CommunicationUtilities.PlatformTests; + +using System; +using System.IO; +using System.Net; +using System.Net.Sockets; +using System.Threading; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class SocketClientTests : SocketTestsBase, IDisposable { - using System; - using System.IO; - using System.Net; - using System.Net.Sockets; - using System.Threading; - - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class SocketClientTests : SocketTestsBase, IDisposable - { - private readonly TcpListener tcpListener; + private readonly TcpListener _tcpListener; - private readonly ICommunicationEndPoint socketClient; + private readonly ICommunicationEndPoint _socketClient; - private TcpClient tcpClient; + private TcpClient _tcpClient; - public SocketClientTests() - { - this.socketClient = new SocketClient(); + public SocketClientTests() + { + _socketClient = new SocketClient(); - var endpoint = new IPEndPoint(IPAddress.Loopback, 0); - this.tcpListener = new TcpListener(endpoint); - } + var endpoint = new IPEndPoint(IPAddress.Loopback, 0); + _tcpListener = new TcpListener(endpoint); + } - protected override TcpClient Client => this.tcpClient; + protected override TcpClient Client => _tcpClient; - public void Dispose() - { - this.socketClient.Stop(); + public void Dispose() + { + _socketClient.Stop(); #if NETFRAMEWORK - // tcpClient.Close() calls tcpClient.Dispose(). - this.tcpClient?.Close(); + // tcpClient.Close() calls tcpClient.Dispose(). + _tcpClient?.Close(); #else - // tcpClient.Close() not available for netcoreapp1.0 - this.tcpClient?.Dispose(); + // tcpClient.Close() not available for netcoreapp1.0 + _tcpClient?.Dispose(); #endif - GC.SuppressFinalize(this); - } + GC.SuppressFinalize(this); + } - [TestMethod] - public void SocketClientStartShouldConnectToLoopbackOnGivenPort() - { - var connectionInfo = this.StartLocalServer(); + [TestMethod] + public void SocketClientStartShouldConnectToLoopbackOnGivenPort() + { + var connectionInfo = StartLocalServer(); - this.socketClient.Start(connectionInfo); + _socketClient.Start(connectionInfo); - var acceptClientTask = this.tcpListener.AcceptTcpClientAsync(); - Assert.IsTrue(acceptClientTask.Wait(TIMEOUT)); - Assert.IsTrue(acceptClientTask.Result.Connected); - } + var acceptClientTask = _tcpListener.AcceptTcpClientAsync(); + Assert.IsTrue(acceptClientTask.Wait(Timeout)); + Assert.IsTrue(acceptClientTask.Result.Connected); + } + + [TestMethod] + [Ignore] + public void SocketClientStartShouldThrowIfServerIsNotListening() + { + var dummyConnectionInfo = "5345"; + + _socketClient.Start(dummyConnectionInfo); - [TestMethod] - [Ignore] - public void SocketClientStartShouldThrowIfServerIsNotListening() + var exceptionThrown = false; + try { - var dummyConnectionInfo = "5345"; - - this.socketClient.Start(dummyConnectionInfo); - - var exceptionThrown = false; - try - { - this.socketClient.Start(dummyConnectionInfo); - } - catch (PlatformNotSupportedException) - { - // Thrown on unix - exceptionThrown = true; - } - catch (SocketException) - { - exceptionThrown = true; - } - - Assert.IsTrue(exceptionThrown); + _socketClient.Start(dummyConnectionInfo); } - - [TestMethod] - public void SocketClientStopShouldRaiseClientDisconnectedEventOnClientDisconnection() + catch (PlatformNotSupportedException) + { + // Thrown on unix + exceptionThrown = true; + } + catch (SocketException) { - var waitEvent = this.SetupClientDisconnect(out ICommunicationChannel _); + exceptionThrown = true; + } - // Close the communication from client side - this.socketClient.Stop(); + Assert.IsTrue(exceptionThrown); + } - Assert.IsTrue(waitEvent.WaitOne(TIMEOUT)); - } + [TestMethod] + public void SocketClientStopShouldRaiseClientDisconnectedEventOnClientDisconnection() + { + var waitEvent = SetupClientDisconnect(out ICommunicationChannel _); - [TestMethod] - public void SocketClientShouldRaiseClientDisconnectedEventIfConnectionIsBroken() - { - var waitEvent = this.SetupClientDisconnect(out ICommunicationChannel _); + // Close the communication from client side + _socketClient.Stop(); + + Assert.IsTrue(waitEvent.WaitOne(Timeout)); + } - // Close the communication from server side - this.tcpClient.GetStream().Dispose(); + [TestMethod] + public void SocketClientShouldRaiseClientDisconnectedEventIfConnectionIsBroken() + { + var waitEvent = SetupClientDisconnect(out ICommunicationChannel _); + + // Close the communication from server side + _tcpClient.GetStream().Dispose(); #if NETFRAMEWORK - // tcpClient.Close() calls tcpClient.Dispose(). - this.tcpClient?.Close(); + // tcpClient.Close() calls tcpClient.Dispose(). + _tcpClient?.Close(); #else - // tcpClient.Close() not available for netcoreapp1.0 - this.tcpClient?.Dispose(); + // tcpClient.Close() not available for netcoreapp1.0 + _tcpClient?.Dispose(); #endif - Assert.IsTrue(waitEvent.WaitOne(TIMEOUT)); - } + Assert.IsTrue(waitEvent.WaitOne(Timeout)); + } - [TestMethod] - public void SocketClientStopShouldStopCommunication() - { - var waitEvent = this.SetupClientDisconnect(out ICommunicationChannel _); + [TestMethod] + public void SocketClientStopShouldStopCommunication() + { + var waitEvent = SetupClientDisconnect(out ICommunicationChannel _); - // Close the communication from socket client side - this.socketClient.Stop(); + // Close the communication from socket client side + _socketClient.Stop(); - // Validate that write on server side fails - waitEvent.WaitOne(TIMEOUT); - Assert.ThrowsException(() => WriteData(this.Client)); - } + // Validate that write on server side fails + waitEvent.WaitOne(Timeout); + Assert.ThrowsException(() => WriteData(Client)); + } - [TestMethod] - public void SocketClientStopShouldCloseChannel() - { - var waitEvent = this.SetupClientDisconnect(out ICommunicationChannel channel); + [TestMethod] + public void SocketClientStopShouldCloseChannel() + { + var waitEvent = SetupClientDisconnect(out ICommunicationChannel channel); - this.socketClient.Stop(); + _socketClient.Stop(); - waitEvent.WaitOne(TIMEOUT); - Assert.ThrowsException(() => channel.Send(DUMMYDATA)); - } + waitEvent.WaitOne(Timeout); + Assert.ThrowsException(() => channel.Send(Dummydata)); + } - protected override ICommunicationChannel SetupChannel(out ConnectedEventArgs connectedEvent) + protected override ICommunicationChannel SetupChannel(out ConnectedEventArgs connectedEvent) + { + ICommunicationChannel channel = null; + ConnectedEventArgs serverConnectedEvent = null; + ManualResetEvent waitEvent = new(false); + _socketClient.Connected += (sender, eventArgs) => { - ICommunicationChannel channel = null; - ConnectedEventArgs serverConnectedEvent = null; - ManualResetEvent waitEvent = new ManualResetEvent(false); - this.socketClient.Connected += (sender, eventArgs) => - { - serverConnectedEvent = eventArgs; - channel = eventArgs.Channel; - waitEvent.Set(); - }; - - var connectionInfo = this.StartLocalServer(); - this.socketClient.Start(connectionInfo); - - var acceptClientTask = this.tcpListener.AcceptTcpClientAsync(); - if (acceptClientTask.Wait(TimeSpan.FromMilliseconds(1000))) - { - this.tcpClient = acceptClientTask.Result; - waitEvent.WaitOne(1000); - } - - connectedEvent = serverConnectedEvent; - return channel; - } + serverConnectedEvent = eventArgs; + channel = eventArgs.Channel; + waitEvent.Set(); + }; + + var connectionInfo = StartLocalServer(); + _socketClient.Start(connectionInfo); - private ManualResetEvent SetupClientDisconnect(out ICommunicationChannel channel) + var acceptClientTask = _tcpListener.AcceptTcpClientAsync(); + if (acceptClientTask.Wait(TimeSpan.FromMilliseconds(1000))) { - var waitEvent = new ManualResetEvent(false); - this.socketClient.Disconnected += (s, e) => { waitEvent.Set(); }; - channel = this.SetupChannel(out ConnectedEventArgs _); - channel.MessageReceived += (sender, args) => - { - }; - return waitEvent; + _tcpClient = acceptClientTask.Result; + waitEvent.WaitOne(1000); } - private string StartLocalServer() + connectedEvent = serverConnectedEvent; + return channel; + } + + private ManualResetEvent SetupClientDisconnect(out ICommunicationChannel channel) + { + var waitEvent = new ManualResetEvent(false); + _socketClient.Disconnected += (s, e) => waitEvent.Set(); + channel = SetupChannel(out ConnectedEventArgs _); + channel.MessageReceived += (sender, args) => { - this.tcpListener.Start(); + }; + return waitEvent; + } - return ((IPEndPoint)this.tcpListener.LocalEndpoint).ToString(); - } + private string StartLocalServer() + { + _tcpListener.Start(); + + return ((IPEndPoint)_tcpListener.LocalEndpoint).ToString(); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/SocketCommunicationManagerTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/SocketCommunicationManagerTests.cs index 2f39dd1f73..8c1bae928b 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/SocketCommunicationManagerTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/SocketCommunicationManagerTests.cs @@ -1,375 +1,371 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.PlatformTests +namespace Microsoft.TestPlatform.CommunicationUtilities.PlatformTests; + +using System; +using System.IO; +using System.Net; +using System.Net.Sockets; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class SocketCommunicationManagerTests : IDisposable { - using System; - using System.IO; - using System.Net; - using System.Net.Sockets; - using System.Text; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class SocketCommunicationManagerTests : IDisposable - { - private const string TestDiscoveryStartMessageWithNullPayload = "{\"MessageType\":\"TestDiscovery.Start\",\"Payload\":null}"; + private const string TestDiscoveryStartMessageWithNullPayload = "{\"MessageType\":\"TestDiscovery.Start\",\"Payload\":null}"; - private const string TestDiscoveryStartMessageWithDummyPayload = "{\"MessageType\":\"TestDiscovery.Start\",\"Payload\":\"Dummy Payload\"}"; + private const string TestDiscoveryStartMessageWithDummyPayload = "{\"MessageType\":\"TestDiscovery.Start\",\"Payload\":\"Dummy Payload\"}"; - private const string TestDiscoveryStartMessageWithVersionAndPayload = "{\"Version\":2,\"MessageType\":\"TestDiscovery.Start\",\"Payload\":\"Dummy Payload\"}"; + private const string TestDiscoveryStartMessageWithVersionAndPayload = "{\"Version\":2,\"MessageType\":\"TestDiscovery.Start\",\"Payload\":\"Dummy Payload\"}"; - private const string DummyPayload = "Dummy Payload"; + private const string DummyPayload = "Dummy Payload"; - private readonly SocketCommunicationManager communicationManager; + private readonly SocketCommunicationManager _communicationManager; - private readonly TcpClient tcpClient; + private readonly TcpClient _tcpClient; - private readonly TcpListener tcpListener; + private readonly TcpListener _tcpListener; - public SocketCommunicationManagerTests() - { - this.communicationManager = new SocketCommunicationManager(); - this.tcpClient = new TcpClient(); - this.tcpListener = new TcpListener(IPAddress.Loopback, 0); - } + public SocketCommunicationManagerTests() + { + _communicationManager = new SocketCommunicationManager(); + _tcpClient = new TcpClient(); + _tcpListener = new TcpListener(IPAddress.Loopback, 0); + } - public void Dispose() - { - this.tcpListener.Stop(); + public void Dispose() + { + _tcpListener.Stop(); #if NETFRAMEWORK - // tcpClient.Close() calls tcpClient.Dispose(). - this.tcpClient?.Close(); + // tcpClient.Close() calls tcpClient.Dispose(). + _tcpClient?.Close(); #else - // tcpClient.Close() not available for netcoreapp1.0 - this.tcpClient?.Dispose(); + // tcpClient.Close() not available for netcoreapp1.0 + _tcpClient?.Dispose(); #endif - this.communicationManager.StopServer(); - this.communicationManager.StopClient(); - GC.SuppressFinalize(this); - } + _communicationManager.StopServer(); + _communicationManager.StopClient(); + GC.SuppressFinalize(this); + } - #region Server tests + #region Server tests - [TestMethod] - public async Task HostServerShouldStartServerAndReturnPortNumber() - { - var port = this.communicationManager.HostServer(new IPEndPoint(IPAddress.Loopback, 0)).Port; + [TestMethod] + public async Task HostServerShouldStartServerAndReturnPortNumber() + { + var port = _communicationManager.HostServer(new IPEndPoint(IPAddress.Loopback, 0)).Port; - Assert.IsTrue(port > 0); - await this.tcpClient.ConnectAsync(IPAddress.Loopback, port); - Assert.IsTrue(this.tcpClient.Connected); - } + Assert.IsTrue(port > 0); + await _tcpClient.ConnectAsync(IPAddress.Loopback, port); + Assert.IsTrue(_tcpClient.Connected); + } - [TestMethod] - public async Task AcceptClientAsyncShouldWaitForClientConnection() - { - var clientConnected = false; - var waitEvent = new ManualResetEvent(false); - var port = this.communicationManager.HostServer(new IPEndPoint(IPAddress.Loopback, 0)).Port; - - var acceptClientTask = this.communicationManager.AcceptClientAsync().ContinueWith( - (continuationTask, state) => - { - clientConnected = true; - waitEvent.Set(); - }, - null); - - await this.tcpClient.ConnectAsync(IPAddress.Loopback, port); - Assert.IsTrue(this.tcpClient.Connected); - Assert.IsTrue(waitEvent.WaitOne(1000) && clientConnected); - } + [TestMethod] + public async Task AcceptClientAsyncShouldWaitForClientConnection() + { + var clientConnected = false; + var waitEvent = new ManualResetEvent(false); + var port = _communicationManager.HostServer(new IPEndPoint(IPAddress.Loopback, 0)).Port; - [TestMethod] - public async Task WaitForClientConnectionShouldWaitUntilClientIsConnected() - { - var port = this.communicationManager.HostServer(new IPEndPoint(IPAddress.Loopback, 0)).Port; - var acceptClientTask = this.communicationManager.AcceptClientAsync(); - await this.tcpClient.ConnectAsync(IPAddress.Loopback, port); + var acceptClientTask = _communicationManager.AcceptClientAsync().ContinueWith( + (continuationTask, state) => + { + clientConnected = true; + waitEvent.Set(); + }, + null); + + await _tcpClient.ConnectAsync(IPAddress.Loopback, port); + Assert.IsTrue(_tcpClient.Connected); + Assert.IsTrue(waitEvent.WaitOne(1000) && clientConnected); + } - var clientConnected = this.communicationManager.WaitForClientConnection(1000); + [TestMethod] + public async Task WaitForClientConnectionShouldWaitUntilClientIsConnected() + { + var port = _communicationManager.HostServer(new IPEndPoint(IPAddress.Loopback, 0)).Port; + _ = _communicationManager.AcceptClientAsync(); + await _tcpClient.ConnectAsync(IPAddress.Loopback, port); - Assert.IsTrue(this.tcpClient.Connected); - Assert.IsTrue(clientConnected); - } + var clientConnected = _communicationManager.WaitForClientConnection(1000); - [TestMethod] - public void WaitForClientConnectionShouldReturnFalseIfClientIsNotConnected() - { - this.communicationManager.HostServer(new IPEndPoint(IPAddress.Loopback, 0)); - var acceptClientTask = this.communicationManager.AcceptClientAsync(); + Assert.IsTrue(_tcpClient.Connected); + Assert.IsTrue(clientConnected); + } - // Do not attempt the client to connect to server. Directly wait until timeout. - var clientConnected = this.communicationManager.WaitForClientConnection(100); + [TestMethod] + public void WaitForClientConnectionShouldReturnFalseIfClientIsNotConnected() + { + _communicationManager.HostServer(new IPEndPoint(IPAddress.Loopback, 0)); + _ = _communicationManager.AcceptClientAsync(); - Assert.IsFalse(clientConnected); - } + // Do not attempt the client to connect to server. Directly wait until timeout. + var clientConnected = _communicationManager.WaitForClientConnection(100); - [TestMethod] - public void StopServerShouldCloseServer() - { - var port = this.communicationManager.HostServer(new IPEndPoint(IPAddress.Loopback, 0)).Port; - var acceptClientTask = this.communicationManager.AcceptClientAsync(); + Assert.IsFalse(clientConnected); + } - this.communicationManager.StopServer(); + [TestMethod] + public void StopServerShouldCloseServer() + { + var port = _communicationManager.HostServer(new IPEndPoint(IPAddress.Loopback, 0)).Port; + var acceptClientTask = _communicationManager.AcceptClientAsync(); - Assert.ThrowsException(() => this.tcpClient.ConnectAsync(IPAddress.Loopback, port).Wait()); - } + _communicationManager.StopServer(); - #endregion + Assert.ThrowsException(() => _tcpClient.ConnectAsync(IPAddress.Loopback, port).Wait()); + } - #region Client tests + #endregion - [TestMethod] - public async Task SetupClientAsyncShouldConnectToServer() - { - var port = this.StartServer(); + #region Client tests - var setupClientTask = this.communicationManager.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)); + [TestMethod] + public async Task SetupClientAsyncShouldConnectToServer() + { + var port = StartServer(); + _ = _communicationManager.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)); - var client = await this.tcpListener.AcceptTcpClientAsync(); - Assert.IsTrue(client.Connected); - } + var client = await _tcpListener.AcceptTcpClientAsync(); + Assert.IsTrue(client.Connected); + } - [TestMethod] - public async Task WaitForServerConnectionShouldWaitUntilClientIsConnected() - { - var port = this.StartServer(); - var setupClientTask = this.communicationManager.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)); - await this.tcpListener.AcceptTcpClientAsync(); + [TestMethod] + public async Task WaitForServerConnectionShouldWaitUntilClientIsConnected() + { + var port = StartServer(); + _ = _communicationManager.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)); + await _tcpListener.AcceptTcpClientAsync(); - var serverConnected = this.communicationManager.WaitForServerConnection(1000); + var serverConnected = _communicationManager.WaitForServerConnection(1000); - Assert.IsTrue(serverConnected); - } + Assert.IsTrue(serverConnected); + } - [TestMethod] - public void WaitForServerConnectionShouldReturnFalseIfClientIsNotConnected() - { - // There is no server listening on port 20000. - var setupClientTask = this.communicationManager.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, 20000)); + [TestMethod] + public void WaitForServerConnectionShouldReturnFalseIfClientIsNotConnected() + { + // There is no server listening on port 20000. + _ = _communicationManager.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, 20000)); - var serverConnected = this.communicationManager.WaitForServerConnection(100); + var serverConnected = _communicationManager.WaitForServerConnection(100); - Assert.IsFalse(serverConnected); - } + Assert.IsFalse(serverConnected); + } - [TestMethod] - public async Task StopClientShouldDisconnectClient() - { - var client = await this.StartServerAndWaitForConnection(); + [TestMethod] + public async Task StopClientShouldDisconnectClient() + { + var client = await StartServerAndWaitForConnection(); - this.communicationManager.StopClient(); + _communicationManager.StopClient(); - // Attempt to write on client socket should throw since it should have disconnected. - Assert.ThrowsException(() => this.WriteOnSocket(client.Client)); - } + // Attempt to write on client socket should throw since it should have disconnected. + Assert.ThrowsException(() => WriteOnSocket(client.Client)); + } - #endregion + #endregion - #region Message sender tests + #region Message sender tests - [TestMethod] - public async Task SendMessageShouldSendMessageWithoutAnyPayload() - { - var client = await this.StartServerAndWaitForConnection(); + [TestMethod] + public async Task SendMessageShouldSendMessageWithoutAnyPayload() + { + var client = await StartServerAndWaitForConnection(); - this.communicationManager.SendMessage(MessageType.StartDiscovery); + _communicationManager.SendMessage(MessageType.StartDiscovery); - Assert.AreEqual(TestDiscoveryStartMessageWithNullPayload, this.ReadFromStream(client.GetStream())); - } + Assert.AreEqual(TestDiscoveryStartMessageWithNullPayload, ReadFromStream(client.GetStream())); + } - [TestMethod] - public async Task SendMessageWithPayloadShouldSerializeAndSendThePayload() - { - var client = await this.StartServerAndWaitForConnection(); + [TestMethod] + public async Task SendMessageWithPayloadShouldSerializeAndSendThePayload() + { + var client = await StartServerAndWaitForConnection(); - this.communicationManager.SendMessage(MessageType.StartDiscovery, DummyPayload); + _communicationManager.SendMessage(MessageType.StartDiscovery, DummyPayload); - Assert.AreEqual(TestDiscoveryStartMessageWithDummyPayload, this.ReadFromStream(client.GetStream())); - } + Assert.AreEqual(TestDiscoveryStartMessageWithDummyPayload, ReadFromStream(client.GetStream())); + } - [TestMethod] - public async Task SendMessageWithPayloadShouldSerializeAndSendThePayloadWithVersionStamped() - { - var client = await this.StartServerAndWaitForConnection(); + [TestMethod] + public async Task SendMessageWithPayloadShouldSerializeAndSendThePayloadWithVersionStamped() + { + var client = await StartServerAndWaitForConnection(); - this.communicationManager.SendMessage(MessageType.StartDiscovery, DummyPayload, 2); + _communicationManager.SendMessage(MessageType.StartDiscovery, DummyPayload, 2); - Assert.AreEqual(TestDiscoveryStartMessageWithVersionAndPayload, this.ReadFromStream(client.GetStream())); - } + Assert.AreEqual(TestDiscoveryStartMessageWithVersionAndPayload, ReadFromStream(client.GetStream())); + } - [TestMethod] - public async Task SendMessageWithRawMessageShouldNotSerializeThePayload() - { - var client = await this.StartServerAndWaitForConnection(); + [TestMethod] + public async Task SendMessageWithRawMessageShouldNotSerializeThePayload() + { + var client = await StartServerAndWaitForConnection(); - this.communicationManager.SendRawMessage(DummyPayload); + _communicationManager.SendRawMessage(DummyPayload); - Assert.AreEqual(DummyPayload, this.ReadFromStream(client.GetStream())); - } + Assert.AreEqual(DummyPayload, ReadFromStream(client.GetStream())); + } - #endregion + #endregion - #region Message receiver tests + #region Message receiver tests - [TestMethod] - public async Task ReceiveMessageShouldReceiveDeserializedMessage() - { - var client = await this.StartServerAndWaitForConnection(); - this.WriteToStream(client.GetStream(), TestDiscoveryStartMessageWithDummyPayload); + [TestMethod] + public async Task ReceiveMessageShouldReceiveDeserializedMessage() + { + var client = await StartServerAndWaitForConnection(); + WriteToStream(client.GetStream(), TestDiscoveryStartMessageWithDummyPayload); - var message = this.communicationManager.ReceiveMessage(); + var message = _communicationManager.ReceiveMessage(); - Assert.AreEqual(MessageType.StartDiscovery, message.MessageType); - Assert.AreEqual(DummyPayload, message.Payload); - } + Assert.AreEqual(MessageType.StartDiscovery, message.MessageType); + Assert.AreEqual(DummyPayload, message.Payload); + } - [TestMethod] - public async Task ReceiveMessageAsyncShouldReceiveDeserializedMessage() - { - var client = await this.StartServerAndWaitForConnection(); - this.WriteToStream(client.GetStream(), TestDiscoveryStartMessageWithVersionAndPayload); - - var message = await this.communicationManager.ReceiveMessageAsync(CancellationToken.None); - var versionedMessage = message as VersionedMessage; - Assert.AreEqual(MessageType.StartDiscovery, versionedMessage.MessageType); - Assert.AreEqual(DummyPayload, versionedMessage.Payload); - Assert.AreEqual(2, versionedMessage.Version); - } + [TestMethod] + public async Task ReceiveMessageAsyncShouldReceiveDeserializedMessage() + { + var client = await StartServerAndWaitForConnection(); + WriteToStream(client.GetStream(), TestDiscoveryStartMessageWithVersionAndPayload); + + var message = await _communicationManager.ReceiveMessageAsync(CancellationToken.None); + var versionedMessage = message as VersionedMessage; + Assert.AreEqual(MessageType.StartDiscovery, versionedMessage.MessageType); + Assert.AreEqual(DummyPayload, versionedMessage.Payload); + Assert.AreEqual(2, versionedMessage.Version); + } - [TestMethod] - public async Task ReceiveRawMessageShouldNotDeserializeThePayload() - { - var client = await this.StartServerAndWaitForConnection(); - this.WriteToStream(client.GetStream(), DummyPayload); + [TestMethod] + public async Task ReceiveRawMessageShouldNotDeserializeThePayload() + { + var client = await StartServerAndWaitForConnection(); + WriteToStream(client.GetStream(), DummyPayload); - var message = this.communicationManager.ReceiveRawMessage(); + var message = _communicationManager.ReceiveRawMessage(); - Assert.AreEqual(DummyPayload, message); - } + Assert.AreEqual(DummyPayload, message); + } - [TestMethod] - public async Task ReceiveRawMessageAsyncShouldNotDeserializeThePayload() - { - var client = await this.StartServerAndWaitForConnection(); - this.WriteToStream(client.GetStream(), DummyPayload); + [TestMethod] + public async Task ReceiveRawMessageAsyncShouldNotDeserializeThePayload() + { + var client = await StartServerAndWaitForConnection(); + WriteToStream(client.GetStream(), DummyPayload); - var message = await this.communicationManager.ReceiveRawMessageAsync(CancellationToken.None); + var message = await _communicationManager.ReceiveRawMessageAsync(CancellationToken.None); - Assert.AreEqual(DummyPayload, message); - } - #endregion + Assert.AreEqual(DummyPayload, message); + } + #endregion - [TestMethod] - public void SocketPollShouldNotHangServerClientCommunication() - { - // Measure the throughput with socket communication v1 (SocketCommunicationManager) - // implementation. - var server = new SocketCommunicationManager(); - var client = new SocketCommunicationManager(); + [TestMethod] + public void SocketPollShouldNotHangServerClientCommunication() + { + // Measure the throughput with socket communication v1 (SocketCommunicationManager) + // implementation. + var server = new SocketCommunicationManager(); + var client = new SocketCommunicationManager(); - int port = server.HostServer(new IPEndPoint(IPAddress.Loopback, 0)).Port; - client.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)).Wait(); - server.AcceptClientAsync().Wait(); + int port = server.HostServer(new IPEndPoint(IPAddress.Loopback, 0)).Port; + client.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)).Wait(); + server.AcceptClientAsync().Wait(); - server.WaitForClientConnection(1000); - client.WaitForServerConnection(1000); + server.WaitForClientConnection(1000); + client.WaitForServerConnection(1000); - var clientThread = new Thread(() => SendData(client)); - clientThread.Start(); + var clientThread = new Thread(() => SendData(client)); + clientThread.Start(); - var dataReceived = 0; - while (dataReceived < 2048 * 5) - { - dataReceived += server.ReceiveRawMessageAsync(CancellationToken.None).Result.Length; - Task.Delay(1000).Wait(); - } + var dataReceived = 0; + while (dataReceived < 2048 * 5) + { + dataReceived += server.ReceiveRawMessageAsync(CancellationToken.None).Result.Length; + Task.Delay(1000).Wait(); + } - clientThread.Join(); + clientThread.Join(); - Assert.IsTrue(true); - } + Assert.IsTrue(true); + } - [TestMethod] - public async Task ReceiveRawMessageNotConnectedSocketShouldReturnNull() - { - var peer = new SocketCommunicationManager(); - Assert.IsNull(peer.ReceiveRawMessage()); - Assert.IsNull(await peer.ReceiveRawMessageAsync(CancellationToken.None)); - } + [TestMethod] + public async Task ReceiveRawMessageNotConnectedSocketShouldReturnNull() + { + var peer = new SocketCommunicationManager(); + Assert.IsNull(peer.ReceiveRawMessage()); + Assert.IsNull(await peer.ReceiveRawMessageAsync(CancellationToken.None)); + } - [TestMethod] - public async Task ReceiveMessageNotConnectedSocketShouldReturnNull() - { - var peer = new SocketCommunicationManager(); - Assert.IsNull(peer.ReceiveMessage()); - Assert.IsNull(await peer.ReceiveMessageAsync(CancellationToken.None)); - } + [TestMethod] + public async Task ReceiveMessageNotConnectedSocketShouldReturnNull() + { + var peer = new SocketCommunicationManager(); + Assert.IsNull(peer.ReceiveMessage()); + Assert.IsNull(await peer.ReceiveMessageAsync(CancellationToken.None)); + } - private static void SendData(ICommunicationManager communicationManager) + private static void SendData(ICommunicationManager communicationManager) + { + // Having less than the buffer size in SocketConstants.BUFFERSIZE. + var dataBytes = new byte[2048]; + for (int i = 0; i < dataBytes.Length; i++) { - // Having less than the buffer size in SocketConstants.BUFFERSIZE. - var dataBytes = new byte[2048]; - for (int i = 0; i < dataBytes.Length; i++) - { - dataBytes[i] = 0x65; - } + dataBytes[i] = 0x65; + } - var dataBytesStr = Encoding.UTF8.GetString(dataBytes); + var dataBytesStr = Encoding.UTF8.GetString(dataBytes); - for (int i = 0; i < 5; i++) - { - communicationManager.SendRawMessage(dataBytesStr); - } + for (int i = 0; i < 5; i++) + { + communicationManager.SendRawMessage(dataBytesStr); } + } - private int StartServer() - { - this.tcpListener.Start(); + private int StartServer() + { + _tcpListener.Start(); - return ((IPEndPoint)this.tcpListener.LocalEndpoint).Port; - } + return ((IPEndPoint)_tcpListener.LocalEndpoint).Port; + } - private async Task StartServerAndWaitForConnection() - { - var port = this.StartServer(); - var setupClientTask = this.communicationManager.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)); - var client = await this.tcpListener.AcceptTcpClientAsync(); - this.communicationManager.WaitForServerConnection(1000); + private async Task StartServerAndWaitForConnection() + { + var port = StartServer(); + _ = _communicationManager.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)); + var client = await _tcpListener.AcceptTcpClientAsync(); + _communicationManager.WaitForServerConnection(1000); - return client; - } + return client; + } - private void WriteOnSocket(Socket socket) + private void WriteOnSocket(Socket socket) + { + for (int i = 0; i < 10; i++) { - for (int i = 0; i < 10; i++) - { - socket.Send(new byte[2] { 0x1, 0x0 }); - } + socket.Send(new byte[2] { 0x1, 0x0 }); } + } - private string ReadFromStream(Stream stream) - { - using (var reader = new BinaryReader(stream, Encoding.UTF8, true)) - { - return reader.ReadString(); - } - } + private string ReadFromStream(Stream stream) + { + using var reader = new BinaryReader(stream, Encoding.UTF8, true); + return reader.ReadString(); + } - private void WriteToStream(Stream stream, string data) - { - using (var writer = new BinaryWriter(stream, Encoding.UTF8, true)) - { - writer.Write(data); - writer.Flush(); - } - } + private void WriteToStream(Stream stream, string data) + { + using var writer = new BinaryWriter(stream, Encoding.UTF8, true); + writer.Write(data); + writer.Flush(); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/SocketServerTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/SocketServerTests.cs index d6ed36f694..20905b8379 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/SocketServerTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/SocketServerTests.cs @@ -1,182 +1,183 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.PlatformTests +namespace Microsoft.TestPlatform.CommunicationUtilities.PlatformTests; + +using System; +using System.IO; +using System.Net; +using System.Net.Sockets; +using System.Threading; +using System.Threading.Tasks; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class SocketServerTests : SocketTestsBase, IDisposable { - using System; - using System.IO; - using System.Net; - using System.Net.Sockets; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class SocketServerTests : SocketTestsBase, IDisposable - { - private readonly TcpClient tcpClient; - private readonly string defaultConnection = IPAddress.Loopback.ToString() + ":0"; - private readonly ICommunicationEndPoint socketServer; + private readonly TcpClient _tcpClient; + private readonly string _defaultConnection = IPAddress.Loopback.ToString() + ":0"; + private readonly ICommunicationEndPoint _socketServer; - public SocketServerTests() - { - this.socketServer = new SocketServer(); + public SocketServerTests() + { + _socketServer = new SocketServer(); - this.tcpClient = new TcpClient(); - } + _tcpClient = new TcpClient(); + } - protected override TcpClient Client => this.tcpClient; + protected override TcpClient Client => _tcpClient; - public void Dispose() - { - this.socketServer.Stop(); + public void Dispose() + { + _socketServer.Stop(); #if NETFRAMEWORK - // tcpClient.Close() calls tcpClient.Dispose(). - this.tcpClient?.Close(); + // tcpClient.Close() calls tcpClient.Dispose(). + _tcpClient?.Close(); #else - // tcpClient.Close() not available for netcoreapp1.0 - this.tcpClient?.Dispose(); + // tcpClient.Close() not available for netcoreapp1.0 + _tcpClient?.Dispose(); #endif - GC.SuppressFinalize(this); - } + GC.SuppressFinalize(this); + } - [TestMethod] - public async Task SocketServerStartShouldHostServer() - { - var connectionInfo = this.socketServer.Start(this.defaultConnection); + [TestMethod] + public async Task SocketServerStartShouldHostServer() + { + var connectionInfo = _socketServer.Start(_defaultConnection); - Assert.IsFalse(string.IsNullOrEmpty(connectionInfo)); - await this.ConnectToServer(connectionInfo.GetIPEndPoint().Port); - Assert.IsTrue(this.tcpClient.Connected); - } + Assert.IsFalse(string.IsNullOrEmpty(connectionInfo)); + await ConnectToServer(connectionInfo.GetIpEndPoint().Port); + Assert.IsTrue(_tcpClient.Connected); + } + + [TestMethod] + public void SocketServerStopShouldStopListening() + { + var connectionInfo = _socketServer.Start(_defaultConnection); + + _socketServer.Stop(); - [TestMethod] - public void SocketServerStopShouldStopListening() + try { - var connectionInfo = this.socketServer.Start(this.defaultConnection); - - this.socketServer.Stop(); - - try - { - // This method throws ExtendedSocketException (which is private). It is not possible - // to use Assert.ThrowsException in this case. - this.ConnectToServer(connectionInfo.GetIPEndPoint().Port).GetAwaiter().GetResult(); - } - catch (SocketException) - { - } + // This method throws ExtendedSocketException (which is private). It is not possible + // to use Assert.ThrowsException in this case. + ConnectToServer(connectionInfo.GetIpEndPoint().Port).GetAwaiter().GetResult(); } - - [TestMethod] - public void SocketServerStopShouldCloseClient() + catch (SocketException) { - ManualResetEvent waitEvent = new ManualResetEvent(false); - this.socketServer.Disconnected += (s, e) => { waitEvent.Set(); }; - this.SetupChannel(out ConnectedEventArgs clientConnected); + } + } - this.socketServer.Stop(); + [TestMethod] + public void SocketServerStopShouldCloseClient() + { + ManualResetEvent waitEvent = new(false); + _socketServer.Disconnected += (s, e) => waitEvent.Set(); + SetupChannel(out ConnectedEventArgs clientConnected); - waitEvent.WaitOne(); - Assert.ThrowsException(() => WriteData(this.tcpClient)); - } + _socketServer.Stop(); - [TestMethod] - public void SocketServerStopShouldRaiseClientDisconnectedEventOnClientDisconnection() - { - DisconnectedEventArgs disconnected = null; - ManualResetEvent waitEvent = new ManualResetEvent(false); - this.socketServer.Disconnected += (s, e) => - { - disconnected = e; - waitEvent.Set(); - }; - this.SetupChannel(out ConnectedEventArgs clientConnected); - - this.socketServer.Stop(); - - waitEvent.WaitOne(); - Assert.IsNotNull(disconnected); - Assert.IsNull(disconnected.Error); - } + waitEvent.WaitOne(); + Assert.ThrowsException(() => WriteData(_tcpClient)); + } - [TestMethod] - public void SocketServerStopShouldCloseChannel() + [TestMethod] + public void SocketServerStopShouldRaiseClientDisconnectedEventOnClientDisconnection() + { + DisconnectedEventArgs disconnected = null; + ManualResetEvent waitEvent = new(false); + _socketServer.Disconnected += (s, e) => { - var waitEvent = new ManualResetEventSlim(false); - var channel = this.SetupChannel(out ConnectedEventArgs clientConnected); - this.socketServer.Disconnected += (s, e) => { waitEvent.Set(); }; + disconnected = e; + waitEvent.Set(); + }; + SetupChannel(out ConnectedEventArgs clientConnected); - this.socketServer.Stop(); + _socketServer.Stop(); - waitEvent.Wait(); - Assert.ThrowsException(() => channel.Send(DUMMYDATA)); - } + waitEvent.WaitOne(); + Assert.IsNotNull(disconnected); + Assert.IsNull(disconnected.Error); + } + + [TestMethod] + public void SocketServerStopShouldCloseChannel() + { + var waitEvent = new ManualResetEventSlim(false); + var channel = SetupChannel(out ConnectedEventArgs clientConnected); + _socketServer.Disconnected += (s, e) => waitEvent.Set(); + + _socketServer.Stop(); + + waitEvent.Wait(); + Assert.ThrowsException(() => channel.Send(Dummydata)); + } + + [TestMethod] + public void SocketServerShouldRaiseClientDisconnectedEventIfConnectionIsBroken() + { + DisconnectedEventArgs clientDisconnected = null; + ManualResetEvent waitEvent = new(false); + _socketServer.Disconnected += (sender, eventArgs) => + { + clientDisconnected = eventArgs; + waitEvent.Set(); + }; + var channel = SetupChannel(out ConnectedEventArgs clientConnected); - [TestMethod] - public void SocketServerShouldRaiseClientDisconnectedEventIfConnectionIsBroken() + channel.MessageReceived += (sender, args) => { - DisconnectedEventArgs clientDisconnected = null; - ManualResetEvent waitEvent = new ManualResetEvent(false); - this.socketServer.Disconnected += (sender, eventArgs) => - { - clientDisconnected = eventArgs; - waitEvent.Set(); - }; - var channel = this.SetupChannel(out ConnectedEventArgs clientConnected); - - channel.MessageReceived += (sender, args) => - { - }; - - // Close the client channel. Message loop should stop. + }; + + // Close the client channel. Message loop should stop. #if NETFRAMEWORK - // tcpClient.Close() calls tcpClient.Dispose(). - this.tcpClient?.Close(); + // tcpClient.Close() calls tcpClient.Dispose(). + _tcpClient?.Close(); #else - // tcpClient.Close() not available for netcoreapp1.0 - this.tcpClient?.Dispose(); + // tcpClient.Close() not available for netcoreapp1.0 + _tcpClient?.Dispose(); #endif - Assert.IsTrue(waitEvent.WaitOne(1000)); - Assert.IsTrue(clientDisconnected.Error is IOException); - } + Assert.IsTrue(waitEvent.WaitOne(1000)); + Assert.IsTrue(clientDisconnected.Error is IOException); + } - [TestMethod] - public async Task SocketEndpointShouldInitializeChannelOnServerConnection() - { - var channel = this.SetupChannel(out ConnectedEventArgs _); + [TestMethod] + public async Task SocketEndpointShouldInitializeChannelOnServerConnection() + { + var channel = SetupChannel(out ConnectedEventArgs _); - await channel.Send(DUMMYDATA); + await channel.Send(Dummydata); - Assert.AreEqual(DUMMYDATA, ReadData(this.Client)); - } + Assert.AreEqual(Dummydata, ReadData(Client)); + } - protected override ICommunicationChannel SetupChannel(out ConnectedEventArgs connectedEvent) + protected override ICommunicationChannel SetupChannel(out ConnectedEventArgs connectedEvent) + { + ICommunicationChannel channel = null; + ConnectedEventArgs clientConnectedEvent = null; + ManualResetEvent waitEvent = new(false); + _socketServer.Connected += (sender, eventArgs) => { - ICommunicationChannel channel = null; - ConnectedEventArgs clientConnectedEvent = null; - ManualResetEvent waitEvent = new ManualResetEvent(false); - this.socketServer.Connected += (sender, eventArgs) => - { - clientConnectedEvent = eventArgs; - channel = eventArgs.Channel; - waitEvent.Set(); - }; - - var connectionInfo = this.socketServer.Start(this.defaultConnection); - var port = connectionInfo.GetIPEndPoint().Port; - this.ConnectToServer(port).GetAwaiter().GetResult(); - waitEvent.WaitOne(); - - connectedEvent = clientConnectedEvent; - return channel; - } + clientConnectedEvent = eventArgs; + channel = eventArgs.Channel; + waitEvent.Set(); + }; + + var connectionInfo = _socketServer.Start(_defaultConnection); + var port = connectionInfo.GetIpEndPoint().Port; + ConnectToServer(port).GetAwaiter().GetResult(); + waitEvent.WaitOne(); + + connectedEvent = clientConnectedEvent; + return channel; + } - private async Task ConnectToServer(int port) - { - await this.tcpClient.ConnectAsync(IPAddress.Loopback, port); - } + private async Task ConnectToServer(int port) + { + await _tcpClient.ConnectAsync(IPAddress.Loopback, port); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/SocketTestsBase.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/SocketTestsBase.cs index 575b1e3100..af9a247d69 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/SocketTestsBase.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.PlatformTests/SocketTestsBase.cs @@ -1,63 +1,60 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.PlatformTests -{ - using System.IO; - using System.Net.Sockets; - using System.Threading; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public abstract class SocketTestsBase - { - protected const string DUMMYDATA = "Dummy Data"; - protected const int TIMEOUT = 10 * 1000; +namespace Microsoft.TestPlatform.CommunicationUtilities.PlatformTests; - protected abstract TcpClient Client { get; } +using System.IO; +using System.Net.Sockets; +using System.Threading; - [TestMethod] - public void SocketEndpointStartShouldRaiseServerConnectedEventOnServerConnection() - { - this.SetupChannel(out ConnectedEventArgs connectedEventArgs); +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - Assert.IsNotNull(connectedEventArgs); - } +using VisualStudio.TestTools.UnitTesting; - [TestMethod] - public void SocketEndpointShouldNotifyChannelOnDataAvailable() - { - var message = string.Empty; - ManualResetEvent waitForMessage = new ManualResetEvent(false); - this.SetupChannel(out ConnectedEventArgs _).MessageReceived += (s, e) => - { - message = e.Data; - waitForMessage.Set(); - }; +[TestClass] +public abstract class SocketTestsBase +{ + protected const string Dummydata = "Dummy Data"; + protected const int Timeout = 10 * 1000; - WriteData(this.Client); + protected abstract TcpClient Client { get; } - waitForMessage.WaitOne(); - Assert.AreEqual(DUMMYDATA, message); - } + [TestMethod] + public void SocketEndpointStartShouldRaiseServerConnectedEventOnServerConnection() + { + SetupChannel(out ConnectedEventArgs connectedEventArgs); - protected static string ReadData(TcpClient client) - { - using (BinaryReader reader = new BinaryReader(client.GetStream())) - { - return reader.ReadString(); - } - } + Assert.IsNotNull(connectedEventArgs); + } - protected static void WriteData(TcpClient client) + [TestMethod] + public void SocketEndpointShouldNotifyChannelOnDataAvailable() + { + var message = string.Empty; + ManualResetEvent waitForMessage = new(false); + SetupChannel(out ConnectedEventArgs _).MessageReceived += (s, e) => { - using (BinaryWriter writer = new BinaryWriter(client.GetStream())) - { - writer.Write(DUMMYDATA); - } - } + message = e.Data; + waitForMessage.Set(); + }; - protected abstract ICommunicationChannel SetupChannel(out ConnectedEventArgs connectedEventArgs); + WriteData(Client); + + waitForMessage.WaitOne(); + Assert.AreEqual(Dummydata, message); + } + + protected static string ReadData(TcpClient client) + { + using BinaryReader reader = new(client.GetStream()); + return reader.ReadString(); } -} + + protected static void WriteData(TcpClient client) + { + using BinaryWriter writer = new(client.GetStream()); + writer.Write(Dummydata); + } + + protected abstract ICommunicationChannel SetupChannel(out ConnectedEventArgs connectedEventArgs); +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/DataCollectionRequestHandlerTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/DataCollectionRequestHandlerTests.cs index 98c6473770..b89dbe7833 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/DataCollectionRequestHandlerTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/DataCollectionRequestHandlerTests.cs @@ -1,427 +1,402 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests +namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; + +using TestDoubles; +using Microsoft.VisualStudio.TestPlatform.Common.DataCollection; +using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using VisualStudio.TestTools.UnitTesting; + +using Moq; +using Newtonsoft.Json.Linq; +using VisualStudio.TestPlatform.CoreUtilities.Helpers; + +[TestClass] +public class DataCollectionRequestHandlerTests { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.IO; - using System.Linq; - using System.Net; - - using Microsoft.TestPlatform.CommunicationUtilities.UnitTests.TestDoubles; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollection; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - using Newtonsoft.Json.Linq; - using VisualStudio.TestPlatform.CoreUtilities.Helpers; - - using CommunicationUtilitiesResources = Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources.Resources; - using CoreUtilitiesConstants = Microsoft.VisualStudio.TestPlatform.CoreUtilities.Constants; - - [TestClass] - public class DataCollectionRequestHandlerTests + private readonly Mock _mockCommunicationManager; + private readonly Mock _mockMessageSink; + private readonly Mock _mockDataCollectionManager; + private readonly Mock _mockDataCollectionTestCaseEventHandler; + private readonly TestableDataCollectionRequestHandler _requestHandler; + private readonly Mock _mockDataSerializer; + private readonly Mock _mockFileHelper; + private readonly Mock _mockRequestData; + private readonly Mock _mockMetricsCollection; + private readonly Message _afterTestRunEnd = new() { MessageType = MessageType.AfterTestRunEnd, Payload = "false" }; + private readonly Message _beforeTestRunStart = new() { - private Mock mockCommunicationManager; - private Mock mockMessageSink; - private Mock mockDataCollectionManager; - private Mock mockDataCollectionTestCaseEventHandler; - private TestableDataCollectionRequestHandler requestHandler; - private Mock mockDataSerializer; - private Mock mockFileHelper; - private Mock mockRequestData; - private Mock mockMetricsCollection; - private Message afterTestRunEnd = new Message() { MessageType = MessageType.AfterTestRunEnd, Payload = "false" }; - private Message beforeTestRunStart = new Message() - { - MessageType = MessageType.BeforeTestRunStart, - Payload = JToken.FromObject(new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll" } }) - }; + MessageType = MessageType.BeforeTestRunStart, + Payload = JToken.FromObject(new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll" } }) + }; - public DataCollectionRequestHandlerTests() - { - this.mockCommunicationManager = new Mock(); - this.mockMessageSink = new Mock(); - this.mockDataCollectionManager = new Mock(); - this.mockDataSerializer = new Mock(); - this.mockDataCollectionTestCaseEventHandler = new Mock(); - this.mockDataCollectionTestCaseEventHandler.Setup(x => x.WaitForRequestHandlerConnection(It.IsAny())).Returns(true); - this.mockFileHelper = new Mock(); - this.mockRequestData = new Mock(); - this.mockMetricsCollection = new Mock(); - this.mockRequestData.Setup(r => r.MetricsCollection).Returns(this.mockMetricsCollection.Object); - this.requestHandler = new TestableDataCollectionRequestHandler(this.mockCommunicationManager.Object, this.mockMessageSink.Object, this.mockDataCollectionManager.Object, this.mockDataCollectionTestCaseEventHandler.Object, this.mockDataSerializer.Object, this.mockFileHelper.Object, this.mockRequestData.Object); - - this.mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(this.beforeTestRunStart).Returns(this.afterTestRunEnd); - - this.mockDataCollectionManager.Setup(x => x.SessionStarted(It.IsAny())).Returns(true); - } - - [TestCleanup] - public void Cleanup() - { - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, string.Empty); - } + public DataCollectionRequestHandlerTests() + { + _mockCommunicationManager = new Mock(); + _mockMessageSink = new Mock(); + _mockDataCollectionManager = new Mock(); + _mockDataSerializer = new Mock(); + _mockDataCollectionTestCaseEventHandler = new Mock(); + _mockDataCollectionTestCaseEventHandler.Setup(x => x.WaitForRequestHandlerConnection(It.IsAny())).Returns(true); + _mockFileHelper = new Mock(); + _mockRequestData = new Mock(); + _mockMetricsCollection = new Mock(); + _mockRequestData.Setup(r => r.MetricsCollection).Returns(_mockMetricsCollection.Object); + _requestHandler = new TestableDataCollectionRequestHandler(_mockCommunicationManager.Object, _mockMessageSink.Object, _mockDataCollectionManager.Object, _mockDataCollectionTestCaseEventHandler.Object, _mockDataSerializer.Object, _mockFileHelper.Object, _mockRequestData.Object); + + _mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(_beforeTestRunStart).Returns(_afterTestRunEnd); + + _mockDataCollectionManager.Setup(x => x.SessionStarted(It.IsAny())).Returns(true); + } - [TestMethod] - public void CreateInstanceShouldThrowExceptionIfInstanceCommunicationManagerIsNull() - { - Assert.ThrowsException(() => - { - DataCollectionRequestHandler.Create(null, this.mockMessageSink.Object); - }); - } + [TestCleanup] + public void Cleanup() + { + Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, string.Empty); + } - [TestMethod] - public void CreateInstanceShouldThrowExceptinIfInstanceMessageSinkIsNull() - { - Assert.ThrowsException(() => - { - DataCollectionRequestHandler.Create(this.mockCommunicationManager.Object, null); - }); - } + [TestMethod] + public void CreateInstanceShouldThrowExceptionIfInstanceCommunicationManagerIsNull() + { + Assert.ThrowsException(() => DataCollectionRequestHandler.Create(null, _mockMessageSink.Object)); + } - [TestMethod] - public void CreateInstanceShouldCreateInstance() - { - var result = DataCollectionRequestHandler.Create(this.mockCommunicationManager.Object, this.mockMessageSink.Object); + [TestMethod] + public void CreateInstanceShouldThrowExceptinIfInstanceMessageSinkIsNull() + { + Assert.ThrowsException(() => DataCollectionRequestHandler.Create(_mockCommunicationManager.Object, null)); + } - Assert.AreEqual(result, DataCollectionRequestHandler.Instance); - } + [TestMethod] + public void CreateInstanceShouldCreateInstance() + { + var result = DataCollectionRequestHandler.Create(_mockCommunicationManager.Object, _mockMessageSink.Object); - [TestMethod] - public void InitializeCommunicationShouldInitializeCommunication() - { - this.requestHandler.InitializeCommunication(123); + Assert.AreEqual(result, DataCollectionRequestHandler.Instance); + } - this.mockCommunicationManager.Verify(x => x.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, 123)), Times.Once); - } + [TestMethod] + public void InitializeCommunicationShouldInitializeCommunication() + { + _requestHandler.InitializeCommunication(123); - [TestMethod] - public void InitializeCommunicationShouldThrowExceptionIfThrownByCommunicationManager() - { - this.mockCommunicationManager.Setup(x => x.SetupClientAsync(It.IsAny())).Throws(); + _mockCommunicationManager.Verify(x => x.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, 123)), Times.Once); + } - Assert.ThrowsException(() => - { - this.requestHandler.InitializeCommunication(123); - }); - } + [TestMethod] + public void InitializeCommunicationShouldThrowExceptionIfThrownByCommunicationManager() + { + _mockCommunicationManager.Setup(x => x.SetupClientAsync(It.IsAny())).Throws(); - [TestMethod] - public void WaitForRequestSenderConnectionShouldInvokeCommunicationManager() - { - this.requestHandler.WaitForRequestSenderConnection(0); + Assert.ThrowsException(() => _requestHandler.InitializeCommunication(123)); + } - this.mockCommunicationManager.Verify(x => x.WaitForServerConnection(It.IsAny()), Times.Once); - } + [TestMethod] + public void WaitForRequestSenderConnectionShouldInvokeCommunicationManager() + { + _requestHandler.WaitForRequestSenderConnection(0); - [TestMethod] - public void WaitForRequestSenderConnectionShouldThrowExceptionIfThrownByCommunicationManager() - { - this.mockCommunicationManager.Setup(x => x.WaitForServerConnection(It.IsAny())).Throws(); + _mockCommunicationManager.Verify(x => x.WaitForServerConnection(It.IsAny()), Times.Once); + } - Assert.ThrowsException(() => - { - this.requestHandler.WaitForRequestSenderConnection(0); - }); - } + [TestMethod] + public void WaitForRequestSenderConnectionShouldThrowExceptionIfThrownByCommunicationManager() + { + _mockCommunicationManager.Setup(x => x.WaitForServerConnection(It.IsAny())).Throws(); - [TestMethod] - public void SendDataCollectionMessageShouldSendMessageToCommunicationManager() - { - var message = new DataCollectionMessageEventArgs(TestMessageLevel.Error, "message"); + Assert.ThrowsException(() => _requestHandler.WaitForRequestSenderConnection(0)); + } - this.requestHandler.SendDataCollectionMessage(message); + [TestMethod] + public void SendDataCollectionMessageShouldSendMessageToCommunicationManager() + { + var message = new DataCollectionMessageEventArgs(TestMessageLevel.Error, "message"); - this.mockCommunicationManager.Verify(x => x.SendMessage(MessageType.DataCollectionMessage, message), Times.Once); - } + _requestHandler.SendDataCollectionMessage(message); - [TestMethod] - public void SendDataCollectionMessageShouldThrowExceptionIfThrownByCommunicationManager() - { - this.mockCommunicationManager.Setup(x => x.SendMessage(MessageType.DataCollectionMessage, It.IsAny())).Throws(); - var message = new DataCollectionMessageEventArgs(TestMessageLevel.Error, "message"); + _mockCommunicationManager.Verify(x => x.SendMessage(MessageType.DataCollectionMessage, message), Times.Once); + } - Assert.ThrowsException(() => - { - this.requestHandler.SendDataCollectionMessage(message); - }); - } + [TestMethod] + public void SendDataCollectionMessageShouldThrowExceptionIfThrownByCommunicationManager() + { + _mockCommunicationManager.Setup(x => x.SendMessage(MessageType.DataCollectionMessage, It.IsAny())).Throws(); + var message = new DataCollectionMessageEventArgs(TestMessageLevel.Error, "message"); - [TestMethod] - public void CloseShouldCloseCommunicationChannel() - { - this.requestHandler.Close(); + Assert.ThrowsException(() => _requestHandler.SendDataCollectionMessage(message)); + } - this.mockCommunicationManager.Verify(x => x.StopClient(), Times.Once); - } + [TestMethod] + public void CloseShouldCloseCommunicationChannel() + { + _requestHandler.Close(); - [TestMethod] - public void CloseShouldThrowExceptionIfThrownByCommunicationManager() - { - this.mockCommunicationManager.Setup(x => x.StopClient()).Throws(); + _mockCommunicationManager.Verify(x => x.StopClient(), Times.Once); + } - Assert.ThrowsException(() => - { - this.requestHandler.Close(); - }); - } + [TestMethod] + public void CloseShouldThrowExceptionIfThrownByCommunicationManager() + { + _mockCommunicationManager.Setup(x => x.StopClient()).Throws(); - [TestMethod] - public void DisposeShouldCloseCommunicationChannel() - { - this.requestHandler.Dispose(); + Assert.ThrowsException(() => _requestHandler.Close()); + } - this.mockCommunicationManager.Verify(x => x.StopClient(), Times.Once); - } + [TestMethod] + public void DisposeShouldCloseCommunicationChannel() + { + _requestHandler.Dispose(); - [TestMethod] - public void ProcessRequestsShouldProcessRequests() - { - var testHostLaunchedPayload = new TestHostLaunchedPayload(); - testHostLaunchedPayload.ProcessId = 1234; + _mockCommunicationManager.Verify(x => x.StopClient(), Times.Once); + } - this.mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(this.beforeTestRunStart) - .Returns(new Message() { MessageType = MessageType.TestHostLaunched, Payload = JToken.FromObject(testHostLaunchedPayload) }) - .Returns(this.afterTestRunEnd); + [TestMethod] + public void ProcessRequestsShouldProcessRequests() + { + var testHostLaunchedPayload = new TestHostLaunchedPayload(); + testHostLaunchedPayload.ProcessId = 1234; - this.mockDataCollectionManager.Setup(x => x.SessionStarted(It.IsAny())).Returns(true); - this.mockDataCollectionManager.Setup(x => x.TestHostLaunched(It.IsAny())); - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.TestHostLaunched))) - .Returns(testHostLaunchedPayload); - var beforeTestRunSTartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll" } }; - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) - .Returns(beforeTestRunSTartPayload); + _mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(_beforeTestRunStart) + .Returns(new Message() { MessageType = MessageType.TestHostLaunched, Payload = JToken.FromObject(testHostLaunchedPayload) }) + .Returns(_afterTestRunEnd); - this.requestHandler.ProcessRequests(); + _mockDataCollectionManager.Setup(x => x.SessionStarted(It.IsAny())).Returns(true); + _mockDataCollectionManager.Setup(x => x.TestHostLaunched(It.IsAny())); + _mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.TestHostLaunched))) + .Returns(testHostLaunchedPayload); + var beforeTestRunSTartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll" } }; + _mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) + .Returns(beforeTestRunSTartPayload); - this.mockDataCollectionTestCaseEventHandler.Verify(x => x.InitializeCommunication(), Times.Once); - this.mockDataCollectionTestCaseEventHandler.Verify(x => x.WaitForRequestHandlerConnection(It.IsAny()), Times.Once); - this.mockDataCollectionTestCaseEventHandler.Verify(x => x.ProcessRequests(), Times.Once); + _requestHandler.ProcessRequests(); - // Verify SessionStarted events - this.mockDataCollectionManager.Verify(x => x.SessionStarted(It.IsAny()), Times.Once); - this.mockCommunicationManager.Verify(x => x.SendMessage(MessageType.BeforeTestRunStartResult, It.IsAny()), Times.Once); + _mockDataCollectionTestCaseEventHandler.Verify(x => x.InitializeCommunication(), Times.Once); + _mockDataCollectionTestCaseEventHandler.Verify(x => x.WaitForRequestHandlerConnection(It.IsAny()), Times.Once); + _mockDataCollectionTestCaseEventHandler.Verify(x => x.ProcessRequests(), Times.Once); - // Verify TestHostLaunched events - this.mockDataCollectionManager.Verify(x => x.TestHostLaunched(1234), Times.Once); + // Verify SessionStarted events + _mockDataCollectionManager.Verify(x => x.SessionStarted(It.IsAny()), Times.Once); + _mockCommunicationManager.Verify(x => x.SendMessage(MessageType.BeforeTestRunStartResult, It.IsAny()), Times.Once); - // Verify AfterTestRun events. - this.mockDataCollectionManager.Verify(x => x.SessionEnded(It.IsAny()), Times.Once); - this.mockCommunicationManager.Verify(x => x.SendMessage(MessageType.AfterTestRunEndResult, It.IsAny()), Times.Once); - } + // Verify TestHostLaunched events + _mockDataCollectionManager.Verify(x => x.TestHostLaunched(1234), Times.Once); - [TestMethod] - public void ProcessRequestsShouldDisposeDataCollectorsOnAfterTestRunEnd() - { - this.mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(new Message() { MessageType = MessageType.AfterTestRunEnd, Payload = "false" }); + // Verify AfterTestRun events. + _mockDataCollectionManager.Verify(x => x.SessionEnded(It.IsAny()), Times.Once); + _mockCommunicationManager.Verify(x => x.SendMessage(MessageType.AfterTestRunEndResult, It.IsAny()), Times.Once); + } - this.requestHandler.ProcessRequests(); + [TestMethod] + public void ProcessRequestsShouldDisposeDataCollectorsOnAfterTestRunEnd() + { + _mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(new Message() { MessageType = MessageType.AfterTestRunEnd, Payload = "false" }); - this.mockDataCollectionManager.Verify(x => x.Dispose()); - } + _requestHandler.ProcessRequests(); - [TestMethod] - public void ProcessRequestsShouldAddSourceDirectoryToTestPluginCache() - { - var testHostLaunchedPayload = new TestHostLaunchedPayload(); - testHostLaunchedPayload.ProcessId = 1234; + _mockDataCollectionManager.Verify(x => x.Dispose()); + } - var temp = Path.GetTempPath(); - string runSettings = ""; + [TestMethod] + public void ProcessRequestsShouldAddSourceDirectoryToTestPluginCache() + { + var testHostLaunchedPayload = new TestHostLaunchedPayload(); + testHostLaunchedPayload.ProcessId = 1234; - this.mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(this.beforeTestRunStart) - .Returns(new Message() { MessageType = MessageType.TestHostLaunched, Payload = JToken.FromObject(testHostLaunchedPayload) }) - .Returns(this.afterTestRunEnd); + var temp = Path.GetTempPath(); + string runSettings = ""; - this.mockDataCollectionManager.Setup(x => x.SessionStarted(It.IsAny())).Returns(true); - this.mockDataCollectionManager.Setup(x => x.TestHostLaunched(It.IsAny())); - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.TestHostLaunched))) - .Returns(testHostLaunchedPayload); - var beforeTestRunSTartPayload = new BeforeTestRunStartPayload - { - SettingsXml = runSettings, - Sources = new List - { - Path.Combine(temp, "dir1", "test1.dll"), - Path.Combine(temp, "dir2", "test2.dll"), - Path.Combine(temp, "dir3", "test3.dll") - } - }; - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) - .Returns(beforeTestRunSTartPayload); - this.mockFileHelper.Setup(x => x.DirectoryExists($@"{temp}dir1")).Returns(true); - this.mockFileHelper.Setup(x => x.EnumerateFiles($@"{temp}dir1", SearchOption.AllDirectories, @"Collector.dll")).Returns(new List { Path.Combine(temp, "dir1", "abc.DataCollector.dll") }); - - this.requestHandler.ProcessRequests(); - - this.mockFileHelper.Verify(x => x.EnumerateFiles($@"{temp}dir1", SearchOption.AllDirectories, @"Collector.dll"), Times.Once); - Assert.IsTrue(TestPluginCache.Instance.GetExtensionPaths(@"Collector.dll").Contains(Path.Combine(temp, "dir1", "abc.DataCollector.dll"))); - } - - [TestMethod] - public void ProcessRequestsShouldThrowExceptionIfThrownByCommunicationManager() + _mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(_beforeTestRunStart) + .Returns(new Message() { MessageType = MessageType.TestHostLaunched, Payload = JToken.FromObject(testHostLaunchedPayload) }) + .Returns(_afterTestRunEnd); + + _mockDataCollectionManager.Setup(x => x.SessionStarted(It.IsAny())).Returns(true); + _mockDataCollectionManager.Setup(x => x.TestHostLaunched(It.IsAny())); + _mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.TestHostLaunched))) + .Returns(testHostLaunchedPayload); + var beforeTestRunSTartPayload = new BeforeTestRunStartPayload { - this.mockCommunicationManager.Setup(x => x.ReceiveMessage()).Throws(); + SettingsXml = runSettings, + Sources = new List + { + Path.Combine(temp, "dir1", "test1.dll"), + Path.Combine(temp, "dir2", "test2.dll"), + Path.Combine(temp, "dir3", "test3.dll") + } + }; + _mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) + .Returns(beforeTestRunSTartPayload); + _mockFileHelper.Setup(x => x.DirectoryExists($@"{temp}dir1")).Returns(true); + _mockFileHelper.Setup(x => x.EnumerateFiles($@"{temp}dir1", SearchOption.AllDirectories, @"Collector.dll")).Returns(new List { Path.Combine(temp, "dir1", "abc.DataCollector.dll") }); - Assert.ThrowsException(() => { this.requestHandler.ProcessRequests(); }); - } + _requestHandler.ProcessRequests(); - [TestMethod] - public void ProcessRequestsShouldInitializeTestCaseEventHandlerIfTestCaseLevelEventsAreEnabled() - { - var beforeTestRunSTartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll" } }; - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) - .Returns(beforeTestRunSTartPayload); + _mockFileHelper.Verify(x => x.EnumerateFiles($@"{temp}dir1", SearchOption.AllDirectories, @"Collector.dll"), Times.Once); + Assert.IsTrue(TestPluginCache.Instance.GetExtensionPaths(@"Collector.dll").Contains(Path.Combine(temp, "dir1", "abc.DataCollector.dll"))); + } - this.requestHandler.ProcessRequests(); + [TestMethod] + public void ProcessRequestsShouldThrowExceptionIfThrownByCommunicationManager() + { + _mockCommunicationManager.Setup(x => x.ReceiveMessage()).Throws(); - this.mockDataCollectionTestCaseEventHandler.Verify(x => x.InitializeCommunication(), Times.Once); - this.mockDataCollectionTestCaseEventHandler.Verify(x => x.ProcessRequests(), Times.Once); - this.mockDataCollectionTestCaseEventHandler.Verify(x => x.WaitForRequestHandlerConnection(It.IsAny()), Times.Once); - } + Assert.ThrowsException(() => _requestHandler.ProcessRequests()); + } - [TestMethod] - public void ProcessRequestsShouldSetDefaultTimeoutIfNoEnvVarialbeSet() - { - var beforeTestRunSTartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll" } }; - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) - .Returns(beforeTestRunSTartPayload); + [TestMethod] + public void ProcessRequestsShouldInitializeTestCaseEventHandlerIfTestCaseLevelEventsAreEnabled() + { + var beforeTestRunSTartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll" } }; + _mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) + .Returns(beforeTestRunSTartPayload); - this.requestHandler.ProcessRequests(); + _requestHandler.ProcessRequests(); - this.mockDataCollectionTestCaseEventHandler.Verify(h => h.WaitForRequestHandlerConnection(EnvironmentHelper.DefaultConnectionTimeout * 1000)); - } + _mockDataCollectionTestCaseEventHandler.Verify(x => x.InitializeCommunication(), Times.Once); + _mockDataCollectionTestCaseEventHandler.Verify(x => x.ProcessRequests(), Times.Once); + _mockDataCollectionTestCaseEventHandler.Verify(x => x.WaitForRequestHandlerConnection(It.IsAny()), Times.Once); + } - [TestMethod] - public void ProcessRequestsShouldSetTimeoutBasedOnEnvVariable() - { - var timeout = 10; - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, timeout.ToString()); - var beforeTestRunSTartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll" } }; - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) - .Returns(beforeTestRunSTartPayload); + [TestMethod] + public void ProcessRequestsShouldSetDefaultTimeoutIfNoEnvVarialbeSet() + { + var beforeTestRunSTartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll" } }; + _mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) + .Returns(beforeTestRunSTartPayload); - this.requestHandler.ProcessRequests(); + _requestHandler.ProcessRequests(); - this.mockDataCollectionTestCaseEventHandler.Verify(h => h.WaitForRequestHandlerConnection(timeout * 1000)); - } + _mockDataCollectionTestCaseEventHandler.Verify(h => h.WaitForRequestHandlerConnection(EnvironmentHelper.DefaultConnectionTimeout * 1000)); + } - [TestMethod] - public void ProcessRequestsShouldNotInitializeTestCaseEventHandlerIfTestCaseLevelEventsAreNotEnabled() - { - this.mockDataCollectionManager.Setup(x => x.SessionStarted(It.IsAny())).Returns(false); - var beforeTestRunSTartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll" } }; - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) - .Returns(beforeTestRunSTartPayload); + [TestMethod] + public void ProcessRequestsShouldSetTimeoutBasedOnEnvVariable() + { + var timeout = 10; + Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, timeout.ToString()); + var beforeTestRunSTartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll" } }; + _mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) + .Returns(beforeTestRunSTartPayload); - this.requestHandler.ProcessRequests(); + _requestHandler.ProcessRequests(); - this.mockDataCollectionTestCaseEventHandler.Verify(x => x.InitializeCommunication(), Times.Never); - this.mockDataCollectionTestCaseEventHandler.Verify(x => x.ProcessRequests(), Times.Never); - this.mockDataCollectionTestCaseEventHandler.Verify(x => x.WaitForRequestHandlerConnection(It.IsAny()), Times.Never); - } + _mockDataCollectionTestCaseEventHandler.Verify(h => h.WaitForRequestHandlerConnection(timeout * 1000)); + } - [TestMethod] - public void ProcessRequestsShouldReceiveCorrectPayloadInBeforeTestRunStart() - { - var beforeTestRunStartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll" } }; - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) - .Returns(beforeTestRunStartPayload); - var message = new Message() { MessageType = MessageType.BeforeTestRunStart, Payload = JToken.FromObject(beforeTestRunStartPayload) }; - this.mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(message).Returns(this.afterTestRunEnd); - this.requestHandler.ProcessRequests(); - - this.mockDataSerializer.Verify(x => x.DeserializePayload(message), Times.Once); - } - - [TestMethod] - public void ProcessRequestShouldInitializeDataCollectorsWithCorrectSettings() - { - var beforeTestRunStartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll" } }; - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) - .Returns(beforeTestRunStartPayload); - var message = new Message() { MessageType = MessageType.BeforeTestRunStart, Payload = JToken.FromObject(beforeTestRunStartPayload) }; - this.mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(message).Returns(this.afterTestRunEnd); - this.requestHandler.ProcessRequests(); - - this.mockDataCollectionManager.Verify(x => x.InitializeDataCollectors("settingsxml"), Times.Once); - } - - [TestMethod] - public void ProcessRequestShouldCallSessionStartWithCorrectTestSources() - { - var beforeTestRunStartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll", "test2.dll" } }; - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) - .Returns(beforeTestRunStartPayload); - var message = new Message() { MessageType = MessageType.BeforeTestRunStart, Payload = JToken.FromObject(beforeTestRunStartPayload) }; - this.mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(message).Returns(this.afterTestRunEnd); - this.requestHandler.ProcessRequests(); - - this.mockDataCollectionManager.Verify(x => x.SessionStarted(It.Is( - y => y.GetPropertyValue>("TestSources").Contains("test1.dll") && - y.GetPropertyValue>("TestSources").Contains("test2.dll")))); - } - - [TestMethod] - public void ProcessRequestShouldEnableTelemetry() - { - var beforeTestRunStartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll", "test2.dll" }, IsTelemetryOptedIn = true }; - this.mockRequestData.Setup(r => r.IsTelemetryOptedIn).Returns(false); - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) - .Returns(beforeTestRunStartPayload); - var message = new Message() { MessageType = MessageType.BeforeTestRunStart, Payload = JToken.FromObject(beforeTestRunStartPayload) }; - this.mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(message).Returns(this.afterTestRunEnd); - this.requestHandler.ProcessRequests(); - - this.mockRequestData.VerifySet(r => r.IsTelemetryOptedIn = true); - this.mockRequestData.VerifySet(r => r.MetricsCollection = It.IsAny()); - } - - [TestMethod] - public void ProcessRequestShouldNotEnableTelemetryIfTelemetryEnabled() - { - var beforeTestRunStartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll", "test2.dll" }, IsTelemetryOptedIn = true }; - this.mockRequestData.Setup(r => r.IsTelemetryOptedIn).Returns(true); - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) - .Returns(beforeTestRunStartPayload); - var message = new Message() { MessageType = MessageType.BeforeTestRunStart, Payload = JToken.FromObject(beforeTestRunStartPayload) }; - this.mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(message).Returns(this.afterTestRunEnd); - this.requestHandler.ProcessRequests(); - - this.mockRequestData.VerifySet(r => r.IsTelemetryOptedIn = It.IsAny(), Times.Never); - this.mockRequestData.VerifySet(r => r.MetricsCollection = It.IsAny(), Times.Never); - } - - [TestMethod] - public void ProcessRequestShouldNotEnableTelemetryIfTelemetryEnablingNotRequested() - { - var beforeTestRunStartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll", "test2.dll" }, IsTelemetryOptedIn = false }; - this.mockRequestData.Setup(r => r.IsTelemetryOptedIn).Returns(false); - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) - .Returns(beforeTestRunStartPayload); - var message = new Message() { MessageType = MessageType.BeforeTestRunStart, Payload = JToken.FromObject(beforeTestRunStartPayload) }; - this.mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(message).Returns(this.afterTestRunEnd); - this.requestHandler.ProcessRequests(); - - this.mockRequestData.VerifySet(r => r.IsTelemetryOptedIn = It.IsAny(), Times.Never); - this.mockRequestData.VerifySet(r => r.MetricsCollection = It.IsAny(), Times.Never); - } + [TestMethod] + public void ProcessRequestsShouldNotInitializeTestCaseEventHandlerIfTestCaseLevelEventsAreNotEnabled() + { + _mockDataCollectionManager.Setup(x => x.SessionStarted(It.IsAny())).Returns(false); + var beforeTestRunSTartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll" } }; + _mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) + .Returns(beforeTestRunSTartPayload); + + _requestHandler.ProcessRequests(); + + _mockDataCollectionTestCaseEventHandler.Verify(x => x.InitializeCommunication(), Times.Never); + _mockDataCollectionTestCaseEventHandler.Verify(x => x.ProcessRequests(), Times.Never); + _mockDataCollectionTestCaseEventHandler.Verify(x => x.WaitForRequestHandlerConnection(It.IsAny()), Times.Never); + } + + [TestMethod] + public void ProcessRequestsShouldReceiveCorrectPayloadInBeforeTestRunStart() + { + var beforeTestRunStartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll" } }; + _mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) + .Returns(beforeTestRunStartPayload); + var message = new Message() { MessageType = MessageType.BeforeTestRunStart, Payload = JToken.FromObject(beforeTestRunStartPayload) }; + _mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(message).Returns(_afterTestRunEnd); + _requestHandler.ProcessRequests(); + + _mockDataSerializer.Verify(x => x.DeserializePayload(message), Times.Once); + } + + [TestMethod] + public void ProcessRequestShouldInitializeDataCollectorsWithCorrectSettings() + { + var beforeTestRunStartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll" } }; + _mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) + .Returns(beforeTestRunStartPayload); + var message = new Message() { MessageType = MessageType.BeforeTestRunStart, Payload = JToken.FromObject(beforeTestRunStartPayload) }; + _mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(message).Returns(_afterTestRunEnd); + _requestHandler.ProcessRequests(); + + _mockDataCollectionManager.Verify(x => x.InitializeDataCollectors("settingsxml"), Times.Once); + } + + [TestMethod] + public void ProcessRequestShouldCallSessionStartWithCorrectTestSources() + { + var beforeTestRunStartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll", "test2.dll" } }; + _mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) + .Returns(beforeTestRunStartPayload); + var message = new Message() { MessageType = MessageType.BeforeTestRunStart, Payload = JToken.FromObject(beforeTestRunStartPayload) }; + _mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(message).Returns(_afterTestRunEnd); + _requestHandler.ProcessRequests(); + + _mockDataCollectionManager.Verify(x => x.SessionStarted(It.Is( + y => y.GetPropertyValue>("TestSources").Contains("test1.dll") && + y.GetPropertyValue>("TestSources").Contains("test2.dll")))); + } + + [TestMethod] + public void ProcessRequestShouldEnableTelemetry() + { + var beforeTestRunStartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll", "test2.dll" }, IsTelemetryOptedIn = true }; + _mockRequestData.Setup(r => r.IsTelemetryOptedIn).Returns(false); + _mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) + .Returns(beforeTestRunStartPayload); + var message = new Message() { MessageType = MessageType.BeforeTestRunStart, Payload = JToken.FromObject(beforeTestRunStartPayload) }; + _mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(message).Returns(_afterTestRunEnd); + _requestHandler.ProcessRequests(); + + _mockRequestData.VerifySet(r => r.IsTelemetryOptedIn = true); + _mockRequestData.VerifySet(r => r.MetricsCollection = It.IsAny()); + } + + [TestMethod] + public void ProcessRequestShouldNotEnableTelemetryIfTelemetryEnabled() + { + var beforeTestRunStartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll", "test2.dll" }, IsTelemetryOptedIn = true }; + _mockRequestData.Setup(r => r.IsTelemetryOptedIn).Returns(true); + _mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) + .Returns(beforeTestRunStartPayload); + var message = new Message() { MessageType = MessageType.BeforeTestRunStart, Payload = JToken.FromObject(beforeTestRunStartPayload) }; + _mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(message).Returns(_afterTestRunEnd); + _requestHandler.ProcessRequests(); + + _mockRequestData.VerifySet(r => r.IsTelemetryOptedIn = It.IsAny(), Times.Never); + _mockRequestData.VerifySet(r => r.MetricsCollection = It.IsAny(), Times.Never); + } + + [TestMethod] + public void ProcessRequestShouldNotEnableTelemetryIfTelemetryEnablingNotRequested() + { + var beforeTestRunStartPayload = new BeforeTestRunStartPayload { SettingsXml = "settingsxml", Sources = new List { "test1.dll", "test2.dll" }, IsTelemetryOptedIn = false }; + _mockRequestData.Setup(r => r.IsTelemetryOptedIn).Returns(false); + _mockDataSerializer.Setup(x => x.DeserializePayload(It.Is(y => y.MessageType == MessageType.BeforeTestRunStart))) + .Returns(beforeTestRunStartPayload); + var message = new Message() { MessageType = MessageType.BeforeTestRunStart, Payload = JToken.FromObject(beforeTestRunStartPayload) }; + _mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(message).Returns(_afterTestRunEnd); + _requestHandler.ProcessRequests(); + + _mockRequestData.VerifySet(r => r.IsTelemetryOptedIn = It.IsAny(), Times.Never); + _mockRequestData.VerifySet(r => r.MetricsCollection = It.IsAny(), Times.Never); } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/DataCollectionRequestSenderTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/DataCollectionRequestSenderTests.cs index 1da7998fb6..e20b54f671 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/DataCollectionRequestSenderTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/DataCollectionRequestSenderTests.cs @@ -1,83 +1,82 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests -{ - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests; - using Moq; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Common.DataCollection; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using VisualStudio.TestTools.UnitTesting; - [TestClass] - public class DataCollectionRequestSenderTests - { - private Mock mockCommunicationManager; - private DataCollectionRequestSender requestSender; - private Mock mockDataSerializer; +using Moq; - public DataCollectionRequestSenderTests() - { - this.mockCommunicationManager = new Mock(); - this.mockDataSerializer = new Mock(); - this.requestSender = new DataCollectionRequestSender(this.mockCommunicationManager.Object, this.mockDataSerializer.Object); - } +[TestClass] +public class DataCollectionRequestSenderTests +{ + private readonly Mock _mockCommunicationManager; + private readonly DataCollectionRequestSender _requestSender; + private readonly Mock _mockDataSerializer; - [TestMethod] - public void SendAfterTestRunEndAndGetResultShouldReturnAttachments() - { - var datacollectorUri = new Uri("my://custom/datacollector"); - var attachmentUri = new Uri("my://filename.txt"); - var displayName = "CustomDataCollector"; - var attachment = new AttachmentSet(datacollectorUri, displayName); - attachment.Attachments.Add(new UriDataAttachment(attachmentUri, "filename.txt")); - var invokedDataCollector = new InvokedDataCollector(datacollectorUri, displayName, typeof(string).AssemblyQualifiedName, typeof(string).Assembly.Location, false); - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())).Returns( - new AfterTestRunEndResult(new Collection() { attachment }, new Collection() { invokedDataCollector }, new Dictionary())); - this.mockCommunicationManager.Setup(x => x.ReceiveMessage()).Returns(new Message() { MessageType = MessageType.AfterTestRunEndResult, Payload = null }); + public DataCollectionRequestSenderTests() + { + _mockCommunicationManager = new Mock(); + _mockDataSerializer = new Mock(); + _requestSender = new DataCollectionRequestSender(_mockCommunicationManager.Object, _mockDataSerializer.Object); + } - var result = this.requestSender.SendAfterTestRunEndAndGetResult(null, false); + [TestMethod] + public void SendAfterTestRunEndAndGetResultShouldReturnAttachments() + { + var datacollectorUri = new Uri("my://custom/datacollector"); + var attachmentUri = new Uri("my://filename.txt"); + var displayName = "CustomDataCollector"; + var attachment = new AttachmentSet(datacollectorUri, displayName); + attachment.Attachments.Add(new UriDataAttachment(attachmentUri, "filename.txt")); + var invokedDataCollector = new InvokedDataCollector(datacollectorUri, displayName, typeof(string).AssemblyQualifiedName, typeof(string).Assembly.Location, false); + _mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())).Returns( + new AfterTestRunEndResult(new Collection() { attachment }, new Collection() { invokedDataCollector }, new Dictionary())); + _mockCommunicationManager.Setup(x => x.ReceiveMessage()).Returns(new Message() { MessageType = MessageType.AfterTestRunEndResult, Payload = null }); - Assert.IsNotNull(result); - Assert.IsNotNull(result.AttachmentSets); - Assert.IsNotNull(result.AttachmentSets); - Assert.IsNotNull(result.Metrics); - Assert.AreEqual(1, result.AttachmentSets.Count); - Assert.AreEqual(1, result.InvokedDataCollectors.Count); - Assert.AreEqual(0, result.Metrics.Count); - Assert.IsNotNull(result.AttachmentSets[0]); - Assert.AreEqual(displayName, result.AttachmentSets[0].DisplayName); - Assert.AreEqual(datacollectorUri, result.AttachmentSets[0].Uri); - Assert.AreEqual(attachmentUri, result.AttachmentSets[0].Attachments[0].Uri); - Assert.IsNotNull(result.InvokedDataCollectors[0]); - Assert.AreEqual(datacollectorUri, result.InvokedDataCollectors[0].Uri); - Assert.AreEqual(invokedDataCollector.FilePath, result.InvokedDataCollectors[0].FilePath); - Assert.AreEqual(invokedDataCollector.AssemblyQualifiedName, result.InvokedDataCollectors[0].AssemblyQualifiedName); - } + var result = _requestSender.SendAfterTestRunEndAndGetResult(null, false); - [TestMethod] - public void SendAfterTestRunEndAndGetResultShouldNotReturnAttachmentsWhenRequestCancelled() - { - var attachmentSets = this.requestSender.SendAfterTestRunEndAndGetResult(null, true); + Assert.IsNotNull(result); + Assert.IsNotNull(result.AttachmentSets); + Assert.IsNotNull(result.AttachmentSets); + Assert.IsNotNull(result.Metrics); + Assert.AreEqual(1, result.AttachmentSets.Count); + Assert.AreEqual(1, result.InvokedDataCollectors.Count); + Assert.AreEqual(0, result.Metrics.Count); + Assert.IsNotNull(result.AttachmentSets[0]); + Assert.AreEqual(displayName, result.AttachmentSets[0].DisplayName); + Assert.AreEqual(datacollectorUri, result.AttachmentSets[0].Uri); + Assert.AreEqual(attachmentUri, result.AttachmentSets[0].Attachments[0].Uri); + Assert.IsNotNull(result.InvokedDataCollectors[0]); + Assert.AreEqual(datacollectorUri, result.InvokedDataCollectors[0].Uri); + Assert.AreEqual(invokedDataCollector.FilePath, result.InvokedDataCollectors[0].FilePath); + Assert.AreEqual(invokedDataCollector.AssemblyQualifiedName, result.InvokedDataCollectors[0].AssemblyQualifiedName); + } - Assert.IsNull(attachmentSets); - } + [TestMethod] + public void SendAfterTestRunEndAndGetResultShouldNotReturnAttachmentsWhenRequestCancelled() + { + var attachmentSets = _requestSender.SendAfterTestRunEndAndGetResult(null, true); - [TestMethod] - public void SendBeforeTestRunStartAndGetResultShouldSendBeforeTestRunStartMessageAndPayload() - { - var testSources = new List() { "test1.dll" }; - this.mockCommunicationManager.Setup(x => x.ReceiveMessage()).Returns(new Message() { MessageType = MessageType.BeforeTestRunStartResult, Payload = null }); - this.requestSender.SendBeforeTestRunStartAndGetResult(string.Empty, testSources, true, null); + Assert.IsNull(attachmentSets); + } + + [TestMethod] + public void SendBeforeTestRunStartAndGetResultShouldSendBeforeTestRunStartMessageAndPayload() + { + var testSources = new List() { "test1.dll" }; + _mockCommunicationManager.Setup(x => x.ReceiveMessage()).Returns(new Message() { MessageType = MessageType.BeforeTestRunStartResult, Payload = null }); + _requestSender.SendBeforeTestRunStartAndGetResult(string.Empty, testSources, true, null); - this.mockCommunicationManager.Verify(x => x.SendMessage(MessageType.BeforeTestRunStart, It.Is(p => p.SettingsXml == string.Empty && p.IsTelemetryOptedIn))); - } + _mockCommunicationManager.Verify(x => x.SendMessage(MessageType.BeforeTestRunStart, It.Is(p => p.SettingsXml == string.Empty && p.IsTelemetryOptedIn))); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/DataCollectionTestCaseEventHandlerTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/DataCollectionTestCaseEventHandlerTests.cs index 9955ae315b..67b87d8afb 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/DataCollectionTestCaseEventHandlerTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/DataCollectionTestCaseEventHandlerTests.cs @@ -1,152 +1,142 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests +namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests; + +using System; +using System.Collections.ObjectModel; +using System.Net; + +using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using VisualStudio.TestTools.UnitTesting; + +using Moq; + +using Newtonsoft.Json.Linq; + +[TestClass] +public class DataCollectionTestCaseEventHandlerTests { - using System; - using System.Collections.ObjectModel; - using System.Net; + private readonly Mock _mockCommunicationManager; + private readonly Mock _mockDataCollectionManager; + private readonly DataCollectionTestCaseEventHandler _requestHandler; + private readonly Mock _dataSerializer; + + public DataCollectionTestCaseEventHandlerTests() + { + _mockCommunicationManager = new Mock(); + _mockDataCollectionManager = new Mock(); + _dataSerializer = new Mock(); + _requestHandler = new DataCollectionTestCaseEventHandler(_mockCommunicationManager.Object, new Mock().Object, _dataSerializer.Object); + } + + [TestMethod] + public void InitializeShouldInitializeConnection() + { + _mockCommunicationManager.Setup(x => x.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, 1)); + _requestHandler.InitializeCommunication(); + + _mockCommunicationManager.Verify(x => x.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); + _mockCommunicationManager.Verify(x => x.AcceptClientAsync(), Times.Once); + } + + [TestMethod] + public void InitializeShouldThrowExceptionIfExceptionIsThrownByCommunicationManager() + { + _mockCommunicationManager.Setup(x => x.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Throws(); + Assert.ThrowsException(() => _requestHandler.InitializeCommunication()); + } + + [TestMethod] + public void WaitForRequestHandlerConnectionShouldWaitForConnectionToBeCompleted() + { + _mockCommunicationManager.Setup(x => x.WaitForClientConnection(It.IsAny())).Returns(true); + + var result = _requestHandler.WaitForRequestHandlerConnection(10); + + Assert.IsTrue(result); + } + + [TestMethod] + public void WaitForRequestHandlerConnectionShouldThrowExceptionIfThrownByConnectionManager() + { + _mockCommunicationManager.Setup(x => x.WaitForClientConnection(It.IsAny())).Throws(); + + Assert.ThrowsException(() => _requestHandler.WaitForRequestHandlerConnection(10)); + } - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestTools.UnitTesting; + [TestMethod] + public void CloseShouldStopServer() + { + _requestHandler.Close(); + + _mockCommunicationManager.Verify(x => x.StopServer(), Times.Once); + } + + [TestMethod] + public void CloseShouldThrowExceptionIfThrownByCommunicationManager() + { + _mockCommunicationManager.Setup(x => x.StopServer()).Throws(); + + Assert.ThrowsException( + () => _requestHandler.Close()); + } + + [TestMethod] + public void CloseShouldNotThrowExceptionIfCommunicationManagerIsNull() + { + var requestHandler = new DataCollectionTestCaseEventHandler(null, new Mock().Object, _dataSerializer.Object); + + requestHandler.Close(); + + _mockCommunicationManager.Verify(x => x.StopServer(), Times.Never); + } - using Moq; + [TestMethod] + public void ProcessRequestsShouldProcessBeforeTestCaseStartEvent() + { + var message = new Message(); + message.MessageType = MessageType.DataCollectionTestStart; + message.Payload = JToken.FromObject(new TestCaseEndEventArgs()); + + _mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(message).Returns(new Message() { MessageType = MessageType.SessionEnd, Payload = "false" }); + + var requestHandler = new DataCollectionTestCaseEventHandler(_mockCommunicationManager.Object, _mockDataCollectionManager.Object, _dataSerializer.Object); + + requestHandler.ProcessRequests(); + + _mockDataCollectionManager.Verify(x => x.TestCaseStarted(It.IsAny()), Times.Once); + } - using Newtonsoft.Json.Linq; + [TestMethod] + public void ProcessRequestsShouldProcessAfterTestCaseCompleteEvent() + { + var message = new Message(); + message.MessageType = MessageType.DataCollectionTestEnd; + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + message.Payload = JToken.FromObject(new TestResultEventArgs(new VisualStudio.TestPlatform.ObjectModel.TestResult(testCase))); + + _mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(message).Returns(new Message() { MessageType = MessageType.SessionEnd, Payload = "false" }); + + var requestHandler = new DataCollectionTestCaseEventHandler(_mockCommunicationManager.Object, _mockDataCollectionManager.Object, _dataSerializer.Object); + + requestHandler.ProcessRequests(); + + _mockDataCollectionManager.Verify(x => x.TestCaseEnded(It.IsAny()), Times.Once); + _mockCommunicationManager.Verify(x => x.SendMessage(MessageType.DataCollectionTestEndResult, It.IsAny>())); + } - [TestClass] - public class DataCollectionTestCaseEventHandlerTests + [TestMethod] + public void ProcessRequestsShouldThrowExceptionIfThrownByCommunicationManager() { - private Mock mockCommunicationManager; - private Mock mockDataCollectionManager; - private DataCollectionTestCaseEventHandler requestHandler; - private Mock dataSerializer; - - public DataCollectionTestCaseEventHandlerTests() - { - this.mockCommunicationManager = new Mock(); - this.mockDataCollectionManager = new Mock(); - this.dataSerializer = new Mock(); - this.requestHandler = new DataCollectionTestCaseEventHandler(this.mockCommunicationManager.Object, new Mock().Object, this.dataSerializer.Object); - } - - [TestMethod] - public void InitializeShouldInitializeConnection() - { - this.mockCommunicationManager.Setup(x => x.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, 1)); - this.requestHandler.InitializeCommunication(); - - this.mockCommunicationManager.Verify(x => x.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); - this.mockCommunicationManager.Verify(x => x.AcceptClientAsync(), Times.Once); - } - - [TestMethod] - public void InitializeShouldThrowExceptionIfExceptionIsThrownByCommunicationManager() - { - this.mockCommunicationManager.Setup(x => x.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Throws(); - Assert.ThrowsException(() => - { - this.requestHandler.InitializeCommunication(); - }); - } - - [TestMethod] - public void WaitForRequestHandlerConnectionShouldWaitForConnectionToBeCompleted() - { - this.mockCommunicationManager.Setup(x => x.WaitForClientConnection(It.IsAny())).Returns(true); - - var result = this.requestHandler.WaitForRequestHandlerConnection(10); - - Assert.IsTrue(result); - } - - [TestMethod] - public void WaitForRequestHandlerConnectionShouldThrowExceptionIfThrownByConnectionManager() - { - this.mockCommunicationManager.Setup(x => x.WaitForClientConnection(It.IsAny())).Throws(); - - Assert.ThrowsException(() => - { - this.requestHandler.WaitForRequestHandlerConnection(10); - }); - } - - [TestMethod] - public void CloseShouldStopServer() - { - this.requestHandler.Close(); - - this.mockCommunicationManager.Verify(x => x.StopServer(), Times.Once); - } - - [TestMethod] - public void CloseShouldThrowExceptionIfThrownByCommunicationManager() - { - this.mockCommunicationManager.Setup(x => x.StopServer()).Throws(); - - Assert.ThrowsException( - () => - { - this.requestHandler.Close(); - }); - } - - [TestMethod] - public void CloseShouldNotThrowExceptionIfCommunicationManagerIsNull() - { - var requestHandler = new DataCollectionTestCaseEventHandler(null, new Mock().Object, this.dataSerializer.Object); - - requestHandler.Close(); - - this.mockCommunicationManager.Verify(x => x.StopServer(), Times.Never); - } - - [TestMethod] - public void ProcessRequestsShouldProcessBeforeTestCaseStartEvent() - { - var message = new Message(); - message.MessageType = MessageType.DataCollectionTestStart; - message.Payload = JToken.FromObject(new TestCaseEndEventArgs()); - - this.mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(message).Returns(new Message() { MessageType = MessageType.SessionEnd, Payload = "false" }); - - var requestHandler = new DataCollectionTestCaseEventHandler(this.mockCommunicationManager.Object, this.mockDataCollectionManager.Object, this.dataSerializer.Object); - - requestHandler.ProcessRequests(); - - this.mockDataCollectionManager.Verify(x => x.TestCaseStarted(It.IsAny()), Times.Once); - } - - [TestMethod] - public void ProcessRequestsShouldProcessAfterTestCaseCompleteEvent() - { - var message = new Message(); - message.MessageType = MessageType.DataCollectionTestEnd; - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - message.Payload = JToken.FromObject(new TestResultEventArgs(new VisualStudio.TestPlatform.ObjectModel.TestResult(testCase))); - - this.mockCommunicationManager.SetupSequence(x => x.ReceiveMessage()).Returns(message).Returns(new Message() { MessageType = MessageType.SessionEnd, Payload = "false" }); - - var requestHandler = new DataCollectionTestCaseEventHandler(this.mockCommunicationManager.Object, this.mockDataCollectionManager.Object, this.dataSerializer.Object); - - requestHandler.ProcessRequests(); - - this.mockDataCollectionManager.Verify(x => x.TestCaseEnded(It.IsAny()), Times.Once); - this.mockCommunicationManager.Verify(x => x.SendMessage(MessageType.DataCollectionTestEndResult, It.IsAny>())); - } - - [TestMethod] - public void ProcessRequestsShouldThrowExceptionIfThrownByCommunicationManager() - { - this.mockCommunicationManager.Setup(x => x.ReceiveMessage()).Throws(); + _mockCommunicationManager.Setup(x => x.ReceiveMessage()).Throws(); - Assert.ThrowsException(() => { this.requestHandler.ProcessRequests(); }); - } + Assert.ThrowsException(() => _requestHandler.ProcessRequests()); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/DataCollectionTestCaseEventSenderTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/DataCollectionTestCaseEventSenderTests.cs index 3dbba20aef..2512ecc2eb 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/DataCollectionTestCaseEventSenderTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/DataCollectionTestCaseEventSenderTests.cs @@ -1,141 +1,125 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests +namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests; + +using System; +using System.Collections.ObjectModel; +using System.Net; + +using TestDoubles; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using VisualStudio.TestTools.UnitTesting; + +using Moq; + +using Newtonsoft.Json.Linq; + +[TestClass] +public class DataCollectionTestCaseEventSenderTests { - using System; - using System.Collections.ObjectModel; - using System.Net; + private readonly DataCollectionTestCaseEventSender _dataCollectionTestCaseEventSender; + private readonly Mock _mockCommunicationManager; + private readonly TestCase _testCase = new("hello", new Uri("world://how"), "1.dll"); + + public DataCollectionTestCaseEventSenderTests() + { + _mockCommunicationManager = new Mock(); + _dataCollectionTestCaseEventSender = new TestableDataCollectionTestCaseEventSender(_mockCommunicationManager.Object, JsonDataSerializer.Instance); + } + + [TestMethod] + public void InitializeShouldInitializeCommunicationManager() + { + _dataCollectionTestCaseEventSender.InitializeCommunication(123); + + _mockCommunicationManager.Verify(x => x.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, 123)), Times.Once); + } + + [TestMethod] + public void InitializeShouldThrowExceptionIfThrownByCommunicationManager() + { + _mockCommunicationManager.Setup(x => x.SetupClientAsync(It.IsAny())).Throws(); + + Assert.ThrowsException(() => _dataCollectionTestCaseEventSender.InitializeCommunication(123)); + } + + [TestMethod] + public void WaitForRequestSenderConnectionShouldInvokeWaitForServerConnection() + { + _dataCollectionTestCaseEventSender.WaitForRequestSenderConnection(123); + + _mockCommunicationManager.Verify(x => x.WaitForServerConnection(It.IsAny()), Times.Once); + } + + [TestMethod] + public void WaitForRequestSenderConnectionShouldThrowExceptionIfThrownByCommunicationManager() + { + _mockCommunicationManager.Setup(x => x.WaitForServerConnection(It.IsAny())).Throws(); - using Microsoft.TestPlatform.CommunicationUtilities.UnitTests.TestDoubles; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestTools.UnitTesting; + Assert.ThrowsException(() => _dataCollectionTestCaseEventSender.WaitForRequestSenderConnection(123)); + } + + [TestMethod] + public void CloseShouldDisposeCommunicationManager() + { + _dataCollectionTestCaseEventSender.Close(); + + _mockCommunicationManager.Verify(x => x.StopClient(), Times.Once); + } + + [TestMethod] + public void CloseShouldThrowExceptionIfThrownByCommunicationManager() + { + _mockCommunicationManager.Setup(x => x.StopClient()).Throws(); + + Assert.ThrowsException(() => _dataCollectionTestCaseEventSender.Close()); + } + + [TestMethod] + public void SendTestCaseStartShouldSendMessageThroughCommunicationManager() + { + _mockCommunicationManager.Setup(x => x.ReceiveMessage()).Returns(new Message() { MessageType = MessageType.DataCollectionTestStartAck }); + var testcaseStartEventArgs = new TestCaseStartEventArgs(_testCase); + _dataCollectionTestCaseEventSender.SendTestCaseStart(testcaseStartEventArgs); - using Moq; + _mockCommunicationManager.Verify(x => x.SendMessage(MessageType.DataCollectionTestStart, testcaseStartEventArgs), Times.Once); + _mockCommunicationManager.Verify(x => x.ReceiveMessage(), Times.Once); + } + + [TestMethod] + public void SendTestCaseStartShouldThrowExceptionIfThrownByCommunicationManager() + { + var testcaseStartEventArgs = new TestCaseStartEventArgs(_testCase); + _mockCommunicationManager.Setup(x => x.SendMessage(MessageType.DataCollectionTestStart, testcaseStartEventArgs)).Throws(); - using Newtonsoft.Json.Linq; + Assert.ThrowsException(() => _dataCollectionTestCaseEventSender.SendTestCaseStart(testcaseStartEventArgs)); + } - [TestClass] - public class DataCollectionTestCaseEventSenderTests + [TestMethod] + public void SendTestCaseEndShouldReturnAttachments() { - private DataCollectionTestCaseEventSender dataCollectionTestCaseEventSender; - private Mock mockCommunicationManager; - private TestCase testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - - public DataCollectionTestCaseEventSenderTests() - { - this.mockCommunicationManager = new Mock(); - this.dataCollectionTestCaseEventSender = new TestableDataCollectionTestCaseEventSender(this.mockCommunicationManager.Object, JsonDataSerializer.Instance); - } - - [TestMethod] - public void InitializeShouldInitializeCommunicationManager() - { - this.dataCollectionTestCaseEventSender.InitializeCommunication(123); - - this.mockCommunicationManager.Verify(x => x.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, 123)), Times.Once); - } - - [TestMethod] - public void InitializeShouldThrowExceptionIfThrownByCommunicationManager() - { - this.mockCommunicationManager.Setup(x => x.SetupClientAsync(It.IsAny())).Throws(); - - Assert.ThrowsException(() => - { - this.dataCollectionTestCaseEventSender.InitializeCommunication(123); - }); - } - - [TestMethod] - public void WaitForRequestSenderConnectionShouldInvokeWaitForServerConnection() - { - this.dataCollectionTestCaseEventSender.WaitForRequestSenderConnection(123); - - this.mockCommunicationManager.Verify(x => x.WaitForServerConnection(It.IsAny()), Times.Once); - } - - [TestMethod] - public void WaitForRequestSenderConnectionShouldThrowExceptionIfThrownByCommunicationManager() - { - this.mockCommunicationManager.Setup(x => x.WaitForServerConnection(It.IsAny())).Throws(); - - Assert.ThrowsException(() => - { - this.dataCollectionTestCaseEventSender.WaitForRequestSenderConnection(123); - }); - } - - [TestMethod] - public void CloseShouldDisposeCommunicationManager() - { - this.dataCollectionTestCaseEventSender.Close(); - - this.mockCommunicationManager.Verify(x => x.StopClient(), Times.Once); - } - - [TestMethod] - public void CloseShouldThrowExceptionIfThrownByCommunicationManager() - { - this.mockCommunicationManager.Setup(x => x.StopClient()).Throws(); - - Assert.ThrowsException(() => - { - this.dataCollectionTestCaseEventSender.Close(); - }); - } - - [TestMethod] - public void SendTestCaseStartShouldSendMessageThroughCommunicationManager() - { - this.mockCommunicationManager.Setup(x => x.ReceiveMessage()).Returns(new Message() { MessageType = MessageType.DataCollectionTestStartAck }); - var testcaseStartEventArgs = new TestCaseStartEventArgs(this.testCase); - this.dataCollectionTestCaseEventSender.SendTestCaseStart(testcaseStartEventArgs); - - this.mockCommunicationManager.Verify(x => x.SendMessage(MessageType.DataCollectionTestStart, testcaseStartEventArgs), Times.Once); - this.mockCommunicationManager.Verify(x => x.ReceiveMessage(), Times.Once); - } - - [TestMethod] - public void SendTestCaseStartShouldThrowExceptionIfThrownByCommunicationManager() - { - var testcaseStartEventArgs = new TestCaseStartEventArgs(this.testCase); - this.mockCommunicationManager.Setup(x => x.SendMessage(MessageType.DataCollectionTestStart, testcaseStartEventArgs)).Throws(); - - Assert.ThrowsException(() => - { - this.dataCollectionTestCaseEventSender.SendTestCaseStart(testcaseStartEventArgs); - }); - } - - [TestMethod] - public void SendTestCaseEndShouldReturnAttachments() - { - var testCaseEndEventArgs = new TestCaseEndEventArgs(); - - var attachmentSet = new AttachmentSet(new Uri("my://attachment"), "displayname"); - this.mockCommunicationManager.Setup(x => x.ReceiveMessage()).Returns(new Message() { MessageType = MessageType.DataCollectionTestEndResult, Payload = JToken.FromObject(new Collection() { attachmentSet }) }); - var attachments = this.dataCollectionTestCaseEventSender.SendTestCaseEnd(testCaseEndEventArgs); - - Assert.AreEqual(attachments[0].Uri, attachmentSet.Uri); - Assert.AreEqual(attachments[0].DisplayName, attachmentSet.DisplayName); - } - - [TestMethod] - public void SendTestCaseCompletedShouldThrowExceptionIfThrownByCommunicationManager() - { - var testCaseEndEventArgs = new TestCaseEndEventArgs(); - - this.mockCommunicationManager.Setup(x => x.SendMessage(MessageType.DataCollectionTestEnd, It.IsAny())).Throws(); - - Assert.ThrowsException(() => - { - this.dataCollectionTestCaseEventSender.SendTestCaseEnd(testCaseEndEventArgs); - }); - } + var testCaseEndEventArgs = new TestCaseEndEventArgs(); + + var attachmentSet = new AttachmentSet(new Uri("my://attachment"), "displayname"); + _mockCommunicationManager.Setup(x => x.ReceiveMessage()).Returns(new Message() { MessageType = MessageType.DataCollectionTestEndResult, Payload = JToken.FromObject(new Collection() { attachmentSet }) }); + var attachments = _dataCollectionTestCaseEventSender.SendTestCaseEnd(testCaseEndEventArgs); + + Assert.AreEqual(attachments[0].Uri, attachmentSet.Uri); + Assert.AreEqual(attachments[0].DisplayName, attachmentSet.DisplayName); + } + + [TestMethod] + public void SendTestCaseCompletedShouldThrowExceptionIfThrownByCommunicationManager() + { + var testCaseEndEventArgs = new TestCaseEndEventArgs(); + + _mockCommunicationManager.Setup(x => x.SendMessage(MessageType.DataCollectionTestEnd, It.IsAny())).Throws(); + + Assert.ThrowsException(() => _dataCollectionTestCaseEventSender.SendTestCaseEnd(testCaseEndEventArgs)); } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/JsonDataSerializerTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/JsonDataSerializerTests.cs index ee44f8eefa..4de1abfb3e 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/JsonDataSerializerTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/JsonDataSerializerTests.cs @@ -1,179 +1,178 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests +namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests; + +using System; +using System.Linq; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using VisualStudio.TestTools.UnitTesting; +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; +using VisualStudio.TestPlatform.ObjectModel; +using TestResult = VisualStudio.TestPlatform.ObjectModel.TestResult; + +[TestClass] +public class JsonDataSerializerTests { - using System; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Newtonsoft.Json; - using Newtonsoft.Json.Serialization; - using VisualStudio.TestPlatform.ObjectModel; - using TestResult = VisualStudio.TestPlatform.ObjectModel.TestResult; - - [TestClass] - public class JsonDataSerializerTests - { - private JsonDataSerializer jsonDataSerializer; + private readonly JsonDataSerializer _jsonDataSerializer; - public JsonDataSerializerTests() - { - this.jsonDataSerializer = JsonDataSerializer.Instance; - } + public JsonDataSerializerTests() + { + _jsonDataSerializer = JsonDataSerializer.Instance; + } - [TestMethod] - public void SerializePayloadShouldNotPickDefaultSettings() + [TestMethod] + public void SerializePayloadShouldNotPickDefaultSettings() + { + JsonConvert.DefaultSettings = () => new JsonSerializerSettings { - JsonConvert.DefaultSettings = () => new JsonSerializerSettings + ContractResolver = new DefaultContractResolver { - ContractResolver = new DefaultContractResolver - { - NamingStrategy = new SnakeCaseNamingStrategy() - } - }; - - var classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(null); - classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(classWithSelfReferencingLoop); - classWithSelfReferencingLoop.InfiniteRefernce.InfiniteRefernce = classWithSelfReferencingLoop; - - string serializedPayload = this.jsonDataSerializer.SerializePayload("dummy", classWithSelfReferencingLoop); - Assert.AreEqual("{\"MessageType\":\"dummy\",\"Payload\":{\"InfiniteRefernce\":{}}}", serializedPayload); - } + NamingStrategy = new SnakeCaseNamingStrategy() + } + }; - [TestMethod] - public void DeserializeMessageShouldNotPickDefaultSettings() + var classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(null); + classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(classWithSelfReferencingLoop); + classWithSelfReferencingLoop.InfiniteRefernce.InfiniteRefernce = classWithSelfReferencingLoop; + + string serializedPayload = _jsonDataSerializer.SerializePayload("dummy", classWithSelfReferencingLoop); + Assert.AreEqual("{\"MessageType\":\"dummy\",\"Payload\":{\"InfiniteRefernce\":{}}}", serializedPayload); + } + + [TestMethod] + public void DeserializeMessageShouldNotPickDefaultSettings() + { + JsonConvert.DefaultSettings = () => new JsonSerializerSettings { - JsonConvert.DefaultSettings = () => new JsonSerializerSettings + ContractResolver = new DefaultContractResolver { - ContractResolver = new DefaultContractResolver - { - NamingStrategy = new SnakeCaseNamingStrategy() - } - }; - - Message message = this.jsonDataSerializer.DeserializeMessage("{\"MessageType\":\"dummy\",\"Payload\":{\"InfiniteRefernce\":{}}}"); - Assert.AreEqual("dummy", message?.MessageType); - } + NamingStrategy = new SnakeCaseNamingStrategy() + } + }; - [TestMethod] - public void SerializePayloadShouldSerializeAnObjectWithSelfReferencingLoop() - { - var classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(null); - classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(classWithSelfReferencingLoop); - classWithSelfReferencingLoop.InfiniteRefernce.InfiniteRefernce = classWithSelfReferencingLoop; + Message message = _jsonDataSerializer.DeserializeMessage("{\"MessageType\":\"dummy\",\"Payload\":{\"InfiniteRefernce\":{}}}"); + Assert.AreEqual("dummy", message?.MessageType); + } - // This line should not throw exception - this.jsonDataSerializer.SerializePayload("dummy", classWithSelfReferencingLoop); - } + [TestMethod] + public void SerializePayloadShouldSerializeAnObjectWithSelfReferencingLoop() + { + var classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(null); + classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(classWithSelfReferencingLoop); + classWithSelfReferencingLoop.InfiniteRefernce.InfiniteRefernce = classWithSelfReferencingLoop; - [TestMethod] - public void DeserializeShouldDeserializeAnObjectWhichHadSelfReferencingLoopBeforeSerialization() - { - var classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(null); - classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(classWithSelfReferencingLoop); - classWithSelfReferencingLoop.InfiniteRefernce.InfiniteRefernce = classWithSelfReferencingLoop; + // This line should not throw exception + _jsonDataSerializer.SerializePayload("dummy", classWithSelfReferencingLoop); + } - var json = this.jsonDataSerializer.SerializePayload("dummy", classWithSelfReferencingLoop); + [TestMethod] + public void DeserializeShouldDeserializeAnObjectWhichHadSelfReferencingLoopBeforeSerialization() + { + var classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(null); + classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(classWithSelfReferencingLoop); + classWithSelfReferencingLoop.InfiniteRefernce.InfiniteRefernce = classWithSelfReferencingLoop; - // This line should deserialize properly - var result = this.jsonDataSerializer.Deserialize(json, 1); + var json = _jsonDataSerializer.SerializePayload("dummy", classWithSelfReferencingLoop); - Assert.AreEqual(typeof(ClassWithSelfReferencingLoop), result.GetType()); - Assert.IsNull(result.InfiniteRefernce); - } + // This line should deserialize properly + var result = _jsonDataSerializer.Deserialize(json, 1); - [TestMethod] - public void CloneShouldReturnNullForNull() - { - var clonedTestCase = this.jsonDataSerializer.Clone(null); + Assert.AreEqual(typeof(ClassWithSelfReferencingLoop), result.GetType()); + Assert.IsNull(result.InfiniteRefernce); + } - Assert.IsNull(clonedTestCase); - } + [TestMethod] + public void CloneShouldReturnNullForNull() + { + var clonedTestCase = _jsonDataSerializer.Clone(null); - [TestMethod] - public void CloneShouldWorkForValueType() - { - var i = 2; - var clonedI = this.jsonDataSerializer.Clone(i); + Assert.IsNull(clonedTestCase); + } - Assert.AreEqual(clonedI, i); - } + [TestMethod] + public void CloneShouldWorkForValueType() + { + var i = 2; + var clonedI = _jsonDataSerializer.Clone(i); - [TestMethod] - public void CloneShouldCloneTestCaseObject() - { - var testCase = JsonDataSerializerTests.GetSampleTestCase(out var expectedTrait); + Assert.AreEqual(clonedI, i); + } - var clonedTestCase = this.jsonDataSerializer.Clone(testCase); + [TestMethod] + public void CloneShouldCloneTestCaseObject() + { + var testCase = GetSampleTestCase(out var expectedTrait); - VerifyTestCaseClone(clonedTestCase, testCase, expectedTrait); - } + var clonedTestCase = _jsonDataSerializer.Clone(testCase); - [TestMethod] - public void CloneShouldCloneTestResultsObject() - { - var testCase = JsonDataSerializerTests.GetSampleTestCase(out var expectedTrait); + VerifyTestCaseClone(clonedTestCase, testCase, expectedTrait); + } - var testResult = new TestResult(testCase); + [TestMethod] + public void CloneShouldCloneTestResultsObject() + { + var testCase = GetSampleTestCase(out var expectedTrait); - var startTime = DateTimeOffset.UtcNow; - testResult.StartTime = startTime; + var testResult = new TestResult(testCase); - var clonedTestResult = this.jsonDataSerializer.Clone(testResult); + var startTime = DateTimeOffset.UtcNow; + testResult.StartTime = startTime; - Assert.IsFalse(ReferenceEquals(testResult, clonedTestResult)); + var clonedTestResult = _jsonDataSerializer.Clone(testResult); - Assert.AreEqual(testResult.StartTime, clonedTestResult.StartTime); + Assert.IsFalse(ReferenceEquals(testResult, clonedTestResult)); - VerifyTestCaseClone(testResult.TestCase, clonedTestResult.TestCase, expectedTrait); - } + Assert.AreEqual(testResult.StartTime, clonedTestResult.StartTime); - private static TestCase GetSampleTestCase(out Trait expectedTrait) - { - var testCase = new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll"); + VerifyTestCaseClone(testResult.TestCase, clonedTestResult.TestCase, expectedTrait); + } - expectedTrait = new Trait("TraitName1", "TraitValue1"); + private static TestCase GetSampleTestCase(out Trait expectedTrait) + { + var testCase = new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll"); - testCase.Traits.Add(expectedTrait); - return testCase; - } + expectedTrait = new Trait("TraitName1", "TraitValue1"); - private static void VerifyTestCaseClone(TestCase clonedTestCase, TestCase testCase, Trait expectedTrait) - { - Assert.IsFalse(ReferenceEquals(clonedTestCase, testCase)); + testCase.Traits.Add(expectedTrait); + return testCase; + } - Assert.AreEqual(testCase.FullyQualifiedName, clonedTestCase.FullyQualifiedName); - Assert.IsFalse(ReferenceEquals(testCase.FullyQualifiedName, clonedTestCase.FullyQualifiedName)); + private static void VerifyTestCaseClone(TestCase clonedTestCase, TestCase testCase, Trait expectedTrait) + { + Assert.IsFalse(ReferenceEquals(clonedTestCase, testCase)); - Assert.AreEqual(testCase.ExecutorUri, clonedTestCase.ExecutorUri); - Assert.IsFalse(ReferenceEquals(testCase.ExecutorUri, clonedTestCase.ExecutorUri)); + Assert.AreEqual(testCase.FullyQualifiedName, clonedTestCase.FullyQualifiedName); + Assert.IsFalse(ReferenceEquals(testCase.FullyQualifiedName, clonedTestCase.FullyQualifiedName)); - Assert.AreEqual(testCase.Source, clonedTestCase.Source); - Assert.IsFalse(ReferenceEquals(testCase.Source, clonedTestCase.Source)); + Assert.AreEqual(testCase.ExecutorUri, clonedTestCase.ExecutorUri); + Assert.IsFalse(ReferenceEquals(testCase.ExecutorUri, clonedTestCase.ExecutorUri)); - Assert.AreEqual(1, clonedTestCase.Traits.Count()); + Assert.AreEqual(testCase.Source, clonedTestCase.Source); + Assert.IsFalse(ReferenceEquals(testCase.Source, clonedTestCase.Source)); - foreach (var trait in clonedTestCase.Traits) - { - Assert.IsFalse(ReferenceEquals(expectedTrait, trait)); - Assert.AreEqual(expectedTrait.Name, trait.Name); - Assert.AreEqual(expectedTrait.Value, trait.Value); - } + Assert.AreEqual(1, clonedTestCase.Traits.Count()); + + foreach (var trait in clonedTestCase.Traits) + { + Assert.IsFalse(ReferenceEquals(expectedTrait, trait)); + Assert.AreEqual(expectedTrait.Name, trait.Name); + Assert.AreEqual(expectedTrait.Value, trait.Value); } + } - public class ClassWithSelfReferencingLoop + public class ClassWithSelfReferencingLoop + { + public ClassWithSelfReferencingLoop(ClassWithSelfReferencingLoop ir) { - public ClassWithSelfReferencingLoop(ClassWithSelfReferencingLoop ir) - { - this.InfiniteRefernce = ir; - } + InfiniteRefernce = ir; + } - public ClassWithSelfReferencingLoop InfiniteRefernce - { - get; - set; - } + public ClassWithSelfReferencingLoop InfiniteRefernce + { + get; + set; } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/LengthPrefixCommunicationChannelTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/LengthPrefixCommunicationChannelTests.cs index 21c23451cc..dcf0047773 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/LengthPrefixCommunicationChannelTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/LengthPrefixCommunicationChannelTests.cs @@ -1,170 +1,165 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.UnitTests -{ - using System; - using System.IO; - using System.Threading.Tasks; +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.UnitTests; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.IO; +using System.Threading.Tasks; - [TestClass] - public class LengthPrefixCommunicationChannelTests : IDisposable - { - private const string DUMMYDATA = "Dummy Data"; +using Interfaces; - private readonly ICommunicationChannel channel; +using TestTools.UnitTesting; - private readonly MemoryStream stream; +[TestClass] +public class LengthPrefixCommunicationChannelTests : IDisposable +{ + private const string Dummydata = "Dummy Data"; - private readonly BinaryReader reader; + private readonly ICommunicationChannel _channel; - private readonly BinaryWriter writer; + private readonly MemoryStream _stream; - public LengthPrefixCommunicationChannelTests() - { - this.stream = new MemoryStream(); - this.channel = new LengthPrefixCommunicationChannel(this.stream); + private readonly BinaryReader _reader; - this.reader = new BinaryReader(this.stream); - this.writer = new BinaryWriter(this.stream); - } + private readonly BinaryWriter _writer; - public void Dispose() - { - this.stream.Dispose(); + public LengthPrefixCommunicationChannelTests() + { + _stream = new MemoryStream(); + _channel = new LengthPrefixCommunicationChannel(_stream); - this.reader.Dispose(); - this.writer.Dispose(); - GC.SuppressFinalize(this); - } + _reader = new BinaryReader(_stream); + _writer = new BinaryWriter(_stream); + } - [TestMethod] - public async Task SendShouldWriteTheDataOnStream() - { - await this.channel.Send(DUMMYDATA); + public void Dispose() + { + _stream.Dispose(); - SeekToBeginning(this.stream); - Assert.AreEqual(DUMMYDATA, this.reader.ReadString()); - } + _reader.Dispose(); + _writer.Dispose(); + GC.SuppressFinalize(this); + } - [TestMethod] - public async Task SendShouldWriteInLengthPrefixedFormat() - { - await this.channel.Send(DUMMYDATA); + [TestMethod] + public async Task SendShouldWriteTheDataOnStream() + { + await _channel.Send(Dummydata); - SeekToBeginning(this.stream); - Assert.AreEqual(DUMMYDATA.Length, Read7BitEncodedInt(this.reader)); - } + SeekToBeginning(_stream); + Assert.AreEqual(Dummydata, _reader.ReadString()); + } - [TestMethod] - public async Task SendShouldBeAbleToWriteUnicodeData() - { - // Every day is a good day - var utf8Data = "日日是好日"; - await this.channel.Send(utf8Data); + [TestMethod] + public async Task SendShouldWriteInLengthPrefixedFormat() + { + await _channel.Send(Dummydata); - SeekToBeginning(this.stream); - Assert.AreEqual(utf8Data, this.reader.ReadString()); - } + SeekToBeginning(_stream); + Assert.AreEqual(Dummydata.Length, Read7BitEncodedInt(_reader)); + } - [TestMethod] - public async Task SendShouldFlushTheStream() - { - // A buffered stream doesn't immediately flush, it waits until buffer is filled in - using (var bufferedStream = new BufferedStream(this.stream, 2048)) - { - var communicationChannel = new LengthPrefixCommunicationChannel(bufferedStream); + [TestMethod] + public async Task SendShouldBeAbleToWriteUnicodeData() + { + // Every day is a good day + var utf8Data = "日日是好日"; + await _channel.Send(utf8Data); - await communicationChannel.Send("a"); + SeekToBeginning(_stream); + Assert.AreEqual(utf8Data, _reader.ReadString()); + } - SeekToBeginning(this.stream); - Assert.AreEqual("a", this.reader.ReadString()); - } - } + [TestMethod] + public async Task SendShouldFlushTheStream() + { + // A buffered stream doesn't immediately flush, it waits until buffer is filled in + using var bufferedStream = new BufferedStream(_stream, 2048); + var communicationChannel = new LengthPrefixCommunicationChannel(bufferedStream); - [TestMethod] - public void SendShouldThrowIfChannelIsDisconnected() - { - this.stream.Dispose(); + await communicationChannel.Send("a"); - Assert.ThrowsException(() => this.channel.Send(DUMMYDATA).Wait()); - } + SeekToBeginning(_stream); + Assert.AreEqual("a", _reader.ReadString()); + } - [TestMethod] - public async Task MessageReceivedShouldProvideDataOverStream() - { - var data = string.Empty; - this.channel.MessageReceived += (sender, messageEventArgs) => - { - data = messageEventArgs.Data; - }; - this.writer.Write(DUMMYDATA); - SeekToBeginning(this.stream); + [TestMethod] + public void SendShouldThrowIfChannelIsDisconnected() + { + _stream.Dispose(); - await this.channel.NotifyDataAvailable(); + Assert.ThrowsException(() => _channel.Send(Dummydata).Wait()); + } - Assert.AreEqual(DUMMYDATA, data); - } + [TestMethod] + public async Task MessageReceivedShouldProvideDataOverStream() + { + var data = string.Empty; + _channel.MessageReceived += (sender, messageEventArgs) => data = messageEventArgs.Data; + _writer.Write(Dummydata); + SeekToBeginning(_stream); - [TestMethod] - public async Task NotifyDataAvailableShouldNotReadStreamIfNoListenersAreRegistered() - { - this.writer.Write(DUMMYDATA); - SeekToBeginning(this.stream); + await _channel.NotifyDataAvailable(); - await this.channel.NotifyDataAvailable(); + Assert.AreEqual(Dummydata, data); + } - // Data is read irrespective of listeners. See note in NotifyDataAvailable - // implementation. - Assert.AreEqual(0, this.stream.Position); - } + [TestMethod] + public async Task NotifyDataAvailableShouldNotReadStreamIfNoListenersAreRegistered() + { + _writer.Write(Dummydata); + SeekToBeginning(_stream); - [TestMethod] - public void DisposeShouldNotCloseTheStream() - { - this.channel.Dispose(); + await _channel.NotifyDataAvailable(); - // Should throw if stream is disposed. - Assert.IsTrue(this.stream.CanWrite); - } + // Data is read irrespective of listeners. See note in NotifyDataAvailable + // implementation. + Assert.AreEqual(0, _stream.Position); + } - // TODO - // WriteFromMultilpleThreadShouldBeInSequence - private static void SeekToBeginning(Stream stream) - { - stream.Seek(0, SeekOrigin.Begin); - } + [TestMethod] + public void DisposeShouldNotCloseTheStream() + { + _channel.Dispose(); - private static int Read7BitEncodedInt(BinaryReader reader) + // Should throw if stream is disposed. + Assert.IsTrue(_stream.CanWrite); + } + + // TODO + // WriteFromMultilpleThreadShouldBeInSequence + private static void SeekToBeginning(Stream stream) + { + stream.Seek(0, SeekOrigin.Begin); + } + + private static int Read7BitEncodedInt(BinaryReader reader) + { + // Copied from BinaryReader.Read7BitEncodedInt + // https://referencesource.microsoft.com/#mscorlib/system/io/binaryreader.cs,f30b8b6e8ca06e0f + // Read out an Int32 7 bits at a time. The high bit + // of the byte when on means to continue reading more bytes. + int count = 0; + int shift = 0; + byte b; + do { - // Copied from BinaryReader.Read7BitEncodedInt - // https://referencesource.microsoft.com/#mscorlib/system/io/binaryreader.cs,f30b8b6e8ca06e0f - // Read out an Int32 7 bits at a time. The high bit - // of the byte when on means to continue reading more bytes. - int count = 0; - int shift = 0; - byte b; - do + // Check for a corrupted stream. Read a max of 5 bytes. + // In a future version, add a DataFormatException. + // 5 bytes max per Int32, shift += 7 + if (shift == 5 * 7) { - // Check for a corrupted stream. Read a max of 5 bytes. - // In a future version, add a DataFormatException. - // 5 bytes max per Int32, shift += 7 - if (shift == 5 * 7) - { - throw new FormatException("Format_Bad7BitInt32"); - } - - // ReadByte handles end of stream cases for us. - b = reader.ReadByte(); - count |= (b & 0x7F) << shift; - shift += 7; + throw new FormatException("Format_Bad7BitInt32"); } - while ((b & 0x80) != 0); - return count; + // ReadByte handles end of stream cases for us. + b = reader.ReadByte(); + count |= (b & 0x7F) << shift; + shift += 7; } + while ((b & 0x80) != 0); + + return count; } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/ObjectModel/TestDiscoveryEventHandlerTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/ObjectModel/TestDiscoveryEventHandlerTests.cs index a80953beb7..6d6ffc9feb 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/ObjectModel/TestDiscoveryEventHandlerTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/ObjectModel/TestDiscoveryEventHandlerTests.cs @@ -1,58 +1,57 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests.ObjectModel +namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests.ObjectModel; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using VisualStudio.TestTools.UnitTesting; +using Moq; + +[TestClass] +public class TestDiscoveryEventHandlerTests { - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - - [TestClass] - public class TestDiscoveryEventHandlerTests + private Mock _mockClient; + private TestDiscoveryEventHandler _testDiscoveryEventHandler; + + [TestInitialize] + public void InitializeTests() + { + _mockClient = new Mock(); + _testDiscoveryEventHandler = new TestDiscoveryEventHandler(_mockClient.Object); + } + + [TestMethod] + public void HandleDiscoveredTestShouldSendTestCasesToClient() + { + _testDiscoveryEventHandler.HandleDiscoveredTests(null); + _mockClient.Verify(th => th.SendTestCases(null), Times.Once); + } + + [TestMethod] + public void HandleDiscoveryCompleteShouldInformClient() { - private Mock mockClient; - private TestDiscoveryEventHandler testDiscoveryEventHandler; - - [TestInitialize] - public void InitializeTests() - { - this.mockClient = new Mock(); - this.testDiscoveryEventHandler = new TestDiscoveryEventHandler(this.mockClient.Object); - } - - [TestMethod] - public void HandleDiscoveredTestShouldSendTestCasesToClient() - { - this.testDiscoveryEventHandler.HandleDiscoveredTests(null); - this.mockClient.Verify(th => th.SendTestCases(null), Times.Once); - } - - [TestMethod] - public void HandleDiscoveryCompleteShouldInformClient() - { - var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(0, false); - - this.testDiscoveryEventHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, null); - this.mockClient.Verify(th => th.DiscoveryComplete(discoveryCompleteEventArgs, null), Times.Once); - } - - [TestMethod] - public void HandleDiscoveryCompleteShouldNotSendASeparateTestFoundMessageToClient() - { - this.testDiscoveryEventHandler.HandleDiscoveryComplete(new DiscoveryCompleteEventArgs(0, false), null); - - this.mockClient.Verify(th => th.SendTestCases(null), Times.Never); - } - - [TestMethod] - public void HandleDiscoveryMessageShouldSendMessageToClient() - { - this.testDiscoveryEventHandler.HandleLogMessage(TestMessageLevel.Informational, string.Empty); - - this.mockClient.Verify(th => th.SendLog(TestMessageLevel.Informational, string.Empty), Times.AtLeast(1)); - } + var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(0, false); + + _testDiscoveryEventHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, null); + _mockClient.Verify(th => th.DiscoveryComplete(discoveryCompleteEventArgs, null), Times.Once); + } + + [TestMethod] + public void HandleDiscoveryCompleteShouldNotSendASeparateTestFoundMessageToClient() + { + _testDiscoveryEventHandler.HandleDiscoveryComplete(new DiscoveryCompleteEventArgs(0, false), null); + + _mockClient.Verify(th => th.SendTestCases(null), Times.Never); + } + + [TestMethod] + public void HandleDiscoveryMessageShouldSendMessageToClient() + { + _testDiscoveryEventHandler.HandleLogMessage(TestMessageLevel.Informational, string.Empty); + + _mockClient.Verify(th => th.SendLog(TestMessageLevel.Informational, string.Empty), Times.AtLeast(1)); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/ObjectModel/TestRunEventsHandlerTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/ObjectModel/TestRunEventsHandlerTests.cs index cb3bff2154..af75ae5fe4 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/ObjectModel/TestRunEventsHandlerTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/ObjectModel/TestRunEventsHandlerTests.cs @@ -1,48 +1,47 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests.ObjectModel +namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests.ObjectModel; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.EventHandlers; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class TestRunEventsHandlerTests { - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.EventHandlers; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; + private Mock _mockClient; + private TestRunEventsHandler _testRunEventHandler; + + [TestInitialize] + public void InitializeTests() + { + _mockClient = new Mock(); + _testRunEventHandler = new TestRunEventsHandler(_mockClient.Object); + } - using Moq; + [TestMethod] + public void HandleTestRunStatsChangeShouldSendTestRunStatisticsToClient() + { + _testRunEventHandler.HandleTestRunStatsChange(null); + _mockClient.Verify(th => th.SendTestRunStatistics(null), Times.Once); + } + + [TestMethod] + public void HandleTestRunCompleteShouldInformClient() + { + _testRunEventHandler.HandleTestRunComplete(null, null, null, null); + _mockClient.Verify(th => th.SendExecutionComplete(null, null, null, null), Times.Once); + } - [TestClass] - public class TestRunEventsHandlerTests + [TestMethod] + public void HandleTestRunMessageShouldSendMessageToClient() { - private Mock mockClient; - private TestRunEventsHandler testRunEventHandler; - - [TestInitialize] - public void InitializeTests() - { - this.mockClient = new Mock(); - this.testRunEventHandler = new TestRunEventsHandler(this.mockClient.Object); - } - - [TestMethod] - public void HandleTestRunStatsChangeShouldSendTestRunStatisticsToClient() - { - this.testRunEventHandler.HandleTestRunStatsChange(null); - this.mockClient.Verify(th => th.SendTestRunStatistics(null), Times.Once); - } - - [TestMethod] - public void HandleTestRunCompleteShouldInformClient() - { - this.testRunEventHandler.HandleTestRunComplete(null, null, null, null); - this.mockClient.Verify(th => th.SendExecutionComplete(null, null, null, null), Times.Once); - } - - [TestMethod] - public void HandleTestRunMessageShouldSendMessageToClient() - { - this.testRunEventHandler.HandleLogMessage(TestMessageLevel.Informational, string.Empty); - - this.mockClient.Verify(th => th.SendLog(TestMessageLevel.Informational, string.Empty), Times.AtLeast(1)); - } + _testRunEventHandler.HandleLogMessage(TestMessageLevel.Informational, string.Empty); + + _mockClient.Verify(th => th.SendLog(TestMessageLevel.Informational, string.Empty), Times.AtLeast(1)); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Program.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Program.cs index f480e8b5e2..ab3fe803ea 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Program.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Program.cs @@ -1,12 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests +namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests; + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestCaseSerializationTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestCaseSerializationTests.cs index 7a276ea487..9b767799c5 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestCaseSerializationTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestCaseSerializationTests.cs @@ -1,277 +1,274 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests.Serialization +namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests.Serialization; + +using System; +using System.Linq; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using VisualStudio.TestTools.UnitTesting; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +[TestClass] +public class TestCaseSerializationTests { - using System; - using System.Linq; + private static readonly TestCase TestCase = new( + "sampleTestClass.sampleTestCase", + new Uri("executor://sampleTestExecutor"), + "sampleTest.dll") + { + CodeFilePath = "/user/src/testFile.cs", + DisplayName = "sampleTestCase", + Id = new Guid("be78d6fc-61b0-4882-9d07-40d796fd96ce"), + LineNumber = 999, + Traits = { new Trait("Priority", "0"), new Trait("Category", "unit") } + }; + + #region v1 Tests + + [TestMethod] + public void TestCaseJsonShouldContainAllPropertiesOnSerialization() + { + var json = Serialize(TestCase); + + // Use raw deserialization to validate basic properties + dynamic data = JObject.Parse(json); + dynamic properties = data["Properties"]; + + Assert.AreEqual("TestCase.FullyQualifiedName", properties[0]["Key"]["Id"].Value); + Assert.AreEqual("sampleTestClass.sampleTestCase", properties[0]["Value"].Value); + Assert.AreEqual("TestCase.ExecutorUri", properties[1]["Key"]["Id"].Value); + Assert.AreEqual("executor://sampleTestExecutor", properties[1]["Value"].Value); + Assert.AreEqual("TestCase.Source", properties[2]["Key"]["Id"].Value); + Assert.AreEqual("sampleTest.dll", properties[2]["Value"].Value); + Assert.AreEqual("TestCase.CodeFilePath", properties[3]["Key"]["Id"].Value); + Assert.AreEqual("/user/src/testFile.cs", properties[3]["Value"].Value); + Assert.AreEqual("TestCase.DisplayName", properties[4]["Key"]["Id"].Value); + Assert.AreEqual("sampleTestCase", properties[4]["Value"].Value); + Assert.AreEqual("TestCase.Id", properties[5]["Key"]["Id"].Value); + Assert.AreEqual("be78d6fc-61b0-4882-9d07-40d796fd96ce", properties[5]["Value"].Value); + Assert.AreEqual("TestCase.LineNumber", properties[6]["Key"]["Id"].Value); + Assert.AreEqual(999, properties[6]["Value"].Value); + + // Traits require special handling with TestPlatformContract resolver. It should be null without it. + Assert.AreEqual("TestObject.Traits", properties[7]["Key"]["Id"].Value); + Assert.IsNotNull(properties[7]["Value"]); + } - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; + [TestMethod] + public void TestCaseObjectShouldContainAllPropertiesOnDeserialization() + { + var json = "{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"}," + + "{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"executor://sampleTestExecutor\"}," + + "{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTest.dll\"}," + + "{\"Key\":{\"Id\":\"TestCase.CodeFilePath\",\"Label\":\"File Path\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"/user/src/testFile.cs\"}," + + "{\"Key\":{\"Id\":\"TestCase.DisplayName\",\"Label\":\"Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestCase\"}," + + "{\"Key\":{\"Id\":\"TestCase.Id\",\"Label\":\"Id\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Guid\"},\"Value\":\"be78d6fc-61b0-4882-9d07-40d796fd96ce\"}," + + "{\"Key\":{\"Id\":\"TestCase.LineNumber\",\"Label\":\"Line Number\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Int32\"},\"Value\":999}," + + "{\"Key\":{\"Id\":\"TestObject.Traits\",\"Label\":\"Traits\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":5,\"ValueType\":\"System.Collections.Generic.KeyValuePair`2[[System.String],[System.String]][]\"},\"Value\":[{\"Key\":\"Priority\",\"Value\":\"0\"},{\"Key\":\"Category\",\"Value\":\"unit\"}]}]}"; + var test = Deserialize(json); + + Assert.AreEqual(TestCase.CodeFilePath, test.CodeFilePath); + Assert.AreEqual(TestCase.DisplayName, test.DisplayName); + Assert.AreEqual(TestCase.ExecutorUri, test.ExecutorUri); + Assert.AreEqual(TestCase.FullyQualifiedName, test.FullyQualifiedName); + Assert.AreEqual(TestCase.LineNumber, test.LineNumber); + Assert.AreEqual(TestCase.Source, test.Source); + Assert.AreEqual(TestCase.Traits.First().Name, test.Traits.First().Name); + Assert.AreEqual(TestCase.Id, test.Id); + } + + [TestMethod] + public void TestCaseObjectShouldSerializeWindowsPathWithEscaping() + { + var test = new TestCase("a.b", new Uri("uri://x"), @"C:\Test\TestAssembly.dll"); + + var json = Serialize(test); + + // Use raw deserialization to validate basic properties + dynamic data = JObject.Parse(json); + dynamic properties = data["Properties"]; + Assert.AreEqual(@"TestCase.Source", properties[2]["Key"]["Id"].Value); + Assert.AreEqual(@"C:\Test\TestAssembly.dll", properties[2]["Value"].Value); + } + + [TestMethod] + public void TestCaseObjectShouldDeserializeEscapedWindowsPath() + { + var json = "{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"a.b\"}," + + "{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"uri://x\"}," + + "{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"C:\\\\Test\\\\TestAssembly.dll\"}]}"; - using Newtonsoft.Json; - using Newtonsoft.Json.Linq; + var test = Deserialize(json); + + Assert.AreEqual(@"C:\Test\TestAssembly.dll", test.Source); + } + + [TestMethod] + public void TestCaseObjectShouldSerializeTraitsWithSpecialCharacters() + { + var test = new TestCase("a.b", new Uri("uri://x"), @"/tmp/a.b.dll"); + test.Traits.Add("t", @"SDJDDHW>,:&^%//\\\\"); + + var json = Serialize(test); + + // Use raw deserialization to validate basic properties + dynamic data = JObject.Parse(json); + dynamic properties = data["Properties"]; + Assert.AreEqual(@"TestObject.Traits", properties[7]["Key"]["Id"].Value); + Assert.AreEqual("[{\"Key\":\"t\",\"Value\":\"SDJDDHW>,:&^%//\\\\\\\\\\\\\\\\\"}]", properties[7]["Value"].ToString(Formatting.None)); + } + + [TestMethod] + public void TestCasePropertiesShouldGetRegisteredAsPartOfDeserialization() + { + TestProperty.TryUnregister("DummyProperty", out var _); + var json = "{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"a.b\"}," + + "{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"uri://x\"}," + + "{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"/tmp/a.b.dll\"}," + + "{\"Key\":{\"Id\":\"DummyProperty\",\"Label\":\"DummyPropertyLabel\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":5,\"ValueType\":\"System.String\"},\"Value\":\"dummyString\"}," + + "{\"Key\":{\"Id\":\"TestObject.Traits\",\"Label\":\"Traits\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":5,\"ValueType\":\"System.Collections.Generic.KeyValuePair`2[[System.String],[System.String]][]\"},\"Value\":[{\"Key\":\"t\",\"Value\":\"SDJDDHW>,:&^%//\\\\\\\\\\\\\\\\\"}]}]}"; + _ = Deserialize(json); + + VerifyDummyPropertyIsRegistered(); + } + + #endregion + + #region v2 Tests + + [TestMethod] + public void TestCaseJsonShouldContainAllPropertiesOnSerializationV2() + { + var json = Serialize(TestCase, 2); + + // Use raw deserialization to validate basic properties + dynamic data = JObject.Parse(json); + dynamic properties = data["Properties"]; + + // Traits require special handling with TestPlatformContract resolver. It should be null without it. + Assert.AreEqual("TestObject.Traits", properties[0]["Key"]["Id"].Value); + Assert.IsNotNull(properties[0]["Value"]); + + Assert.AreEqual("be78d6fc-61b0-4882-9d07-40d796fd96ce", data["Id"].Value); + Assert.AreEqual("sampleTestClass.sampleTestCase", data["FullyQualifiedName"].Value); + Assert.AreEqual("sampleTestCase", data["DisplayName"].Value); + Assert.AreEqual("sampleTest.dll", data["Source"].Value); + Assert.AreEqual("executor://sampleTestExecutor", data["ExecutorUri"].Value); + Assert.AreEqual("/user/src/testFile.cs", data["CodeFilePath"].Value); + Assert.AreEqual(999, data["LineNumber"].Value); + } + + [TestMethod] + public void TestCaseObjectShouldContainAllPropertiesOnDeserializationV2() + { + var json = "{\"Id\": \"be78d6fc-61b0-4882-9d07-40d796fd96ce\",\"FullyQualifiedName\": \"sampleTestClass.sampleTestCase\",\"DisplayName\": \"sampleTestCase\",\"ExecutorUri\": \"executor://sampleTestExecutor\",\"Source\": \"sampleTest.dll\",\"CodeFilePath\": \"/user/src/testFile.cs\", \"LineNumber\": 999," + + "\"Properties\": [{ \"Key\": { \"Id\": \"TestObject.Traits\", \"Label\": \"Traits\", \"Category\": \"\", \"Description\": \"\", \"Attributes\": 5, \"ValueType\": \"System.Collections.Generic.KeyValuePair`2[[System.String],[System.String]][]\"}, \"Value\": [{\"Key\": \"Priority\",\"Value\": \"0\"}, {\"Key\": \"Category\",\"Value\": \"unit\"}]}]}"; + + var test = Deserialize(json, 2); + + Assert.AreEqual(TestCase.CodeFilePath, test.CodeFilePath); + Assert.AreEqual(TestCase.DisplayName, test.DisplayName); + Assert.AreEqual(TestCase.ExecutorUri, test.ExecutorUri); + Assert.AreEqual(TestCase.FullyQualifiedName, test.FullyQualifiedName); + Assert.AreEqual(TestCase.LineNumber, test.LineNumber); + Assert.AreEqual(TestCase.Source, test.Source); + Assert.AreEqual(TestCase.Traits.First().Name, test.Traits.First().Name); + Assert.AreEqual(TestCase.Id, test.Id); + } + + [TestMethod] + public void TestCaseObjectShouldSerializeTraitsWithSpecialCharactersV2() + { + var test = new TestCase("a.b", new Uri("uri://x"), @"/tmp/a.b.dll"); + test.Traits.Add("t", @"SDJDDHW>,:&^%//\\\\"); + + var json = Serialize(test, 2); + + // Use raw deserialization to validate basic properties + dynamic data = JObject.Parse(json); + dynamic properties = data["Properties"]; + Assert.AreEqual(@"TestObject.Traits", properties[0]["Key"]["Id"].Value); + Assert.AreEqual("[{\"Key\":\"t\",\"Value\":\"SDJDDHW>,:&^%//\\\\\\\\\\\\\\\\\"}]", properties[0]["Value"].ToString(Formatting.None)); + } + + [TestMethod] + public void TestCaseObjectShouldSerializeWindowsPathWithEscapingV2() + { + var test = new TestCase("a.b", new Uri("uri://x"), @"C:\Test\TestAssembly.dll"); + + var json = Serialize(test, 2); + + // Use raw deserialization to validate basic properties + dynamic data = JObject.Parse(json); + Assert.AreEqual(@"C:\Test\TestAssembly.dll", data["Source"].Value); + } + + [TestMethod] + public void TestCaseObjectShouldDeserializeEscapedWindowsPathV2() + { + var json = "{\"Id\":\"4e35ed85-a5e8-946e-fb14-0d3de2304e74\",\"FullyQualifiedName\":\"a.b\",\"DisplayName\":\"a.b\",\"ExecutorUri\":\"uri://x\",\"Source\":\"C:\\\\Test\\\\TestAssembly.dll\",\"CodeFilePath\":null,\"LineNumber\":-1,\"Properties\":[]}"; + + var test = Deserialize(json, 2); + + Assert.AreEqual(@"C:\Test\TestAssembly.dll", test.Source); + } + + [TestMethod] + public void TestCasePropertiesShouldGetRegisteredAsPartOfDeserializationV2() + { + TestProperty.TryUnregister("DummyProperty", out var _); + var json = "{\"Id\": \"be78d6fc-61b0-4882-9d07-40d796fd96ce\",\"FullyQualifiedName\": \"sampleTestClass.sampleTestCase\",\"DisplayName\": \"sampleTestCase\",\"ExecutorUri\": \"executor://sampleTestExecutor\",\"Source\": \"sampleTest.dll\",\"CodeFilePath\": \"/user/src/testFile.cs\", \"LineNumber\": 999," + + "\"Properties\": [{\"Key\":{\"Id\":\"DummyProperty\",\"Label\":\"DummyPropertyLabel\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":5,\"ValueType\":\"System.String\"},\"Value\":\"dummyString\"}," + + "{ \"Key\": { \"Id\": \"TestObject.Traits\", \"Label\": \"Traits\", \"Category\": \"\", \"Description\": \"\", \"Attributes\": 5, \"ValueType\": \"System.Collections.Generic.KeyValuePair`2[[System.String],[System.String]][]\"}, \"Value\": [{\"Key\": \"Priority\",\"Value\": \"0\"}, {\"Key\": \"Category\",\"Value\": \"unit\"}]}]}"; + _ = Deserialize(json, 2); + + VerifyDummyPropertyIsRegistered(); + } + + #endregion + + #region Common Tests + + [TestMethod] + [DataRow(1)] + [DataRow(2)] + public void TestCaseObjectShouldDeserializeTraitsWithSpecialCharacters(int version) + { + var json = "{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"a.b\"}," + + "{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"uri://x\"}," + + "{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"/tmp/a.b.dll\"}," + + "{\"Key\":{\"Id\":\"TestObject.Traits\",\"Label\":\"Traits\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":5,\"ValueType\":\"System.Collections.Generic.KeyValuePair`2[[System.String],[System.String]][]\"},\"Value\":[{\"Key\":\"t\",\"Value\":\"SDJDDHW>,:&^%//\\\\\\\\\\\\\\\\\"}]}]}"; + + var test = Deserialize(json, version); + + var traits = test.Traits.ToArray(); + Assert.AreEqual(1, traits.Length); + Assert.AreEqual(@"SDJDDHW>,:&^%//\\\\", traits[0].Value); + } + + #endregion + + private static string Serialize(T data, int version = 1) + { + return JsonDataSerializer.Instance.Serialize(data, version); + } + + private static T Deserialize(string json, int version = 1) + { + return JsonDataSerializer.Instance.Deserialize(json, version); + } - [TestClass] - public class TestCaseSerializationTests + private void VerifyDummyPropertyIsRegistered() { - private static TestCase testCase = new TestCase( - "sampleTestClass.sampleTestCase", - new Uri("executor://sampleTestExecutor"), - "sampleTest.dll") - { - CodeFilePath = "/user/src/testFile.cs", - DisplayName = "sampleTestCase", - Id = new Guid("be78d6fc-61b0-4882-9d07-40d796fd96ce"), - LineNumber = 999, - Traits = { new Trait("Priority", "0"), new Trait("Category", "unit") } - }; - - #region v1 Tests - - [TestMethod] - public void TestCaseJsonShouldContainAllPropertiesOnSerialization() - { - var json = Serialize(testCase); - - // Use raw deserialization to validate basic properties - dynamic data = JObject.Parse(json); - dynamic properties = data["Properties"]; - - Assert.AreEqual("TestCase.FullyQualifiedName", properties[0]["Key"]["Id"].Value); - Assert.AreEqual("sampleTestClass.sampleTestCase", properties[0]["Value"].Value); - Assert.AreEqual("TestCase.ExecutorUri", properties[1]["Key"]["Id"].Value); - Assert.AreEqual("executor://sampleTestExecutor", properties[1]["Value"].Value); - Assert.AreEqual("TestCase.Source", properties[2]["Key"]["Id"].Value); - Assert.AreEqual("sampleTest.dll", properties[2]["Value"].Value); - Assert.AreEqual("TestCase.CodeFilePath", properties[3]["Key"]["Id"].Value); - Assert.AreEqual("/user/src/testFile.cs", properties[3]["Value"].Value); - Assert.AreEqual("TestCase.DisplayName", properties[4]["Key"]["Id"].Value); - Assert.AreEqual("sampleTestCase", properties[4]["Value"].Value); - Assert.AreEqual("TestCase.Id", properties[5]["Key"]["Id"].Value); - Assert.AreEqual("be78d6fc-61b0-4882-9d07-40d796fd96ce", properties[5]["Value"].Value); - Assert.AreEqual("TestCase.LineNumber", properties[6]["Key"]["Id"].Value); - Assert.AreEqual(999, properties[6]["Value"].Value); - - // Traits require special handling with TestPlatformContract resolver. It should be null without it. - Assert.AreEqual("TestObject.Traits", properties[7]["Key"]["Id"].Value); - Assert.IsNotNull(properties[7]["Value"]); - } - - [TestMethod] - public void TestCaseObjectShouldContainAllPropertiesOnDeserialization() - { - var json = "{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"}," - + "{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"executor://sampleTestExecutor\"}," - + "{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTest.dll\"}," - + "{\"Key\":{\"Id\":\"TestCase.CodeFilePath\",\"Label\":\"File Path\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"/user/src/testFile.cs\"}," - + "{\"Key\":{\"Id\":\"TestCase.DisplayName\",\"Label\":\"Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestCase\"}," - + "{\"Key\":{\"Id\":\"TestCase.Id\",\"Label\":\"Id\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Guid\"},\"Value\":\"be78d6fc-61b0-4882-9d07-40d796fd96ce\"}," - + "{\"Key\":{\"Id\":\"TestCase.LineNumber\",\"Label\":\"Line Number\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Int32\"},\"Value\":999}," - + "{\"Key\":{\"Id\":\"TestObject.Traits\",\"Label\":\"Traits\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":5,\"ValueType\":\"System.Collections.Generic.KeyValuePair`2[[System.String],[System.String]][]\"},\"Value\":[{\"Key\":\"Priority\",\"Value\":\"0\"},{\"Key\":\"Category\",\"Value\":\"unit\"}]}]}"; - var test = Deserialize(json); - - Assert.AreEqual(testCase.CodeFilePath, test.CodeFilePath); - Assert.AreEqual(testCase.DisplayName, test.DisplayName); - Assert.AreEqual(testCase.ExecutorUri, test.ExecutorUri); - Assert.AreEqual(testCase.FullyQualifiedName, test.FullyQualifiedName); - Assert.AreEqual(testCase.LineNumber, test.LineNumber); - Assert.AreEqual(testCase.Source, test.Source); - Assert.AreEqual(testCase.Traits.First().Name, test.Traits.First().Name); - Assert.AreEqual(testCase.Id, test.Id); - } - - [TestMethod] - public void TestCaseObjectShouldSerializeWindowsPathWithEscaping() - { - var test = new TestCase("a.b", new Uri("uri://x"), @"C:\Test\TestAssembly.dll"); - - var json = Serialize(test); - - // Use raw deserialization to validate basic properties - dynamic data = JObject.Parse(json); - dynamic properties = data["Properties"]; - Assert.AreEqual(@"TestCase.Source", properties[2]["Key"]["Id"].Value); - Assert.AreEqual(@"C:\Test\TestAssembly.dll", properties[2]["Value"].Value); - } - - [TestMethod] - public void TestCaseObjectShouldDeserializeEscapedWindowsPath() - { - var json = "{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"a.b\"}," - + "{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"uri://x\"}," - + "{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"C:\\\\Test\\\\TestAssembly.dll\"}]}"; - - var test = Deserialize(json); - - Assert.AreEqual(@"C:\Test\TestAssembly.dll", test.Source); - } - - [TestMethod] - public void TestCaseObjectShouldSerializeTraitsWithSpecialCharacters() - { - var test = new TestCase("a.b", new Uri("uri://x"), @"/tmp/a.b.dll"); - test.Traits.Add("t", @"SDJDDHW>,:&^%//\\\\"); - - var json = Serialize(test); - - // Use raw deserialization to validate basic properties - dynamic data = JObject.Parse(json); - dynamic properties = data["Properties"]; - Assert.AreEqual(@"TestObject.Traits", properties[7]["Key"]["Id"].Value); - Assert.AreEqual("[{\"Key\":\"t\",\"Value\":\"SDJDDHW>,:&^%//\\\\\\\\\\\\\\\\\"}]", properties[7]["Value"].ToString(Formatting.None)); - } - - [TestMethod] - public void TestCasePropertiesShouldGetRegisteredAsPartOfDeserialization() - { - TestProperty.TryUnregister("DummyProperty", out var property); - var json = "{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"a.b\"}," - + "{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"uri://x\"}," - + "{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"/tmp/a.b.dll\"}," - + "{\"Key\":{\"Id\":\"DummyProperty\",\"Label\":\"DummyPropertyLabel\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":5,\"ValueType\":\"System.String\"},\"Value\":\"dummyString\"}," - + "{\"Key\":{\"Id\":\"TestObject.Traits\",\"Label\":\"Traits\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":5,\"ValueType\":\"System.Collections.Generic.KeyValuePair`2[[System.String],[System.String]][]\"},\"Value\":[{\"Key\":\"t\",\"Value\":\"SDJDDHW>,:&^%//\\\\\\\\\\\\\\\\\"}]}]}"; - - var test = Deserialize(json); - - this.VerifyDummyPropertyIsRegistered(); - } - - #endregion - - #region v2 Tests - - [TestMethod] - public void TestCaseJsonShouldContainAllPropertiesOnSerializationV2() - { - var json = Serialize(testCase, 2); - - // Use raw deserialization to validate basic properties - dynamic data = JObject.Parse(json); - dynamic properties = data["Properties"]; - - // Traits require special handling with TestPlatformContract resolver. It should be null without it. - Assert.AreEqual("TestObject.Traits", properties[0]["Key"]["Id"].Value); - Assert.IsNotNull(properties[0]["Value"]); - - Assert.AreEqual("be78d6fc-61b0-4882-9d07-40d796fd96ce", data["Id"].Value); - Assert.AreEqual("sampleTestClass.sampleTestCase", data["FullyQualifiedName"].Value); - Assert.AreEqual("sampleTestCase", data["DisplayName"].Value); - Assert.AreEqual("sampleTest.dll", data["Source"].Value); - Assert.AreEqual("executor://sampleTestExecutor", data["ExecutorUri"].Value); - Assert.AreEqual("/user/src/testFile.cs", data["CodeFilePath"].Value); - Assert.AreEqual(999, data["LineNumber"].Value); - } - - [TestMethod] - public void TestCaseObjectShouldContainAllPropertiesOnDeserializationV2() - { - var json = "{\"Id\": \"be78d6fc-61b0-4882-9d07-40d796fd96ce\",\"FullyQualifiedName\": \"sampleTestClass.sampleTestCase\",\"DisplayName\": \"sampleTestCase\",\"ExecutorUri\": \"executor://sampleTestExecutor\",\"Source\": \"sampleTest.dll\",\"CodeFilePath\": \"/user/src/testFile.cs\", \"LineNumber\": 999," - + "\"Properties\": [{ \"Key\": { \"Id\": \"TestObject.Traits\", \"Label\": \"Traits\", \"Category\": \"\", \"Description\": \"\", \"Attributes\": 5, \"ValueType\": \"System.Collections.Generic.KeyValuePair`2[[System.String],[System.String]][]\"}, \"Value\": [{\"Key\": \"Priority\",\"Value\": \"0\"}, {\"Key\": \"Category\",\"Value\": \"unit\"}]}]}"; - - var test = Deserialize(json, 2); - - Assert.AreEqual(testCase.CodeFilePath, test.CodeFilePath); - Assert.AreEqual(testCase.DisplayName, test.DisplayName); - Assert.AreEqual(testCase.ExecutorUri, test.ExecutorUri); - Assert.AreEqual(testCase.FullyQualifiedName, test.FullyQualifiedName); - Assert.AreEqual(testCase.LineNumber, test.LineNumber); - Assert.AreEqual(testCase.Source, test.Source); - Assert.AreEqual(testCase.Traits.First().Name, test.Traits.First().Name); - Assert.AreEqual(testCase.Id, test.Id); - } - - [TestMethod] - public void TestCaseObjectShouldSerializeTraitsWithSpecialCharactersV2() - { - var test = new TestCase("a.b", new Uri("uri://x"), @"/tmp/a.b.dll"); - test.Traits.Add("t", @"SDJDDHW>,:&^%//\\\\"); - - var json = Serialize(test, 2); - - // Use raw deserialization to validate basic properties - dynamic data = JObject.Parse(json); - dynamic properties = data["Properties"]; - Assert.AreEqual(@"TestObject.Traits", properties[0]["Key"]["Id"].Value); - Assert.AreEqual("[{\"Key\":\"t\",\"Value\":\"SDJDDHW>,:&^%//\\\\\\\\\\\\\\\\\"}]", properties[0]["Value"].ToString(Formatting.None)); - } - - [TestMethod] - public void TestCaseObjectShouldSerializeWindowsPathWithEscapingV2() - { - var test = new TestCase("a.b", new Uri("uri://x"), @"C:\Test\TestAssembly.dll"); - - var json = Serialize(test, 2); - - // Use raw deserialization to validate basic properties - dynamic data = JObject.Parse(json); - Assert.AreEqual(@"C:\Test\TestAssembly.dll", data["Source"].Value); - } - - [TestMethod] - public void TestCaseObjectShouldDeserializeEscapedWindowsPathV2() - { - var json = "{\"Id\":\"4e35ed85-a5e8-946e-fb14-0d3de2304e74\",\"FullyQualifiedName\":\"a.b\",\"DisplayName\":\"a.b\",\"ExecutorUri\":\"uri://x\",\"Source\":\"C:\\\\Test\\\\TestAssembly.dll\",\"CodeFilePath\":null,\"LineNumber\":-1,\"Properties\":[]}"; - - var test = Deserialize(json, 2); - - Assert.AreEqual(@"C:\Test\TestAssembly.dll", test.Source); - } - - [TestMethod] - public void TestCasePropertiesShouldGetRegisteredAsPartOfDeserializationV2() - { - TestProperty.TryUnregister("DummyProperty", out var property); - var json = "{\"Id\": \"be78d6fc-61b0-4882-9d07-40d796fd96ce\",\"FullyQualifiedName\": \"sampleTestClass.sampleTestCase\",\"DisplayName\": \"sampleTestCase\",\"ExecutorUri\": \"executor://sampleTestExecutor\",\"Source\": \"sampleTest.dll\",\"CodeFilePath\": \"/user/src/testFile.cs\", \"LineNumber\": 999," - + "\"Properties\": [{\"Key\":{\"Id\":\"DummyProperty\",\"Label\":\"DummyPropertyLabel\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":5,\"ValueType\":\"System.String\"},\"Value\":\"dummyString\"}," - + "{ \"Key\": { \"Id\": \"TestObject.Traits\", \"Label\": \"Traits\", \"Category\": \"\", \"Description\": \"\", \"Attributes\": 5, \"ValueType\": \"System.Collections.Generic.KeyValuePair`2[[System.String],[System.String]][]\"}, \"Value\": [{\"Key\": \"Priority\",\"Value\": \"0\"}, {\"Key\": \"Category\",\"Value\": \"unit\"}]}]}"; - - var test = Deserialize(json, 2); - - this.VerifyDummyPropertyIsRegistered(); - } - - #endregion - - #region Common Tests - - [TestMethod] - [DataRow(1)] - [DataRow(2)] - public void TestCaseObjectShouldDeserializeTraitsWithSpecialCharacters(int version) - { - var json = "{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"a.b\"}," - + "{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"uri://x\"}," - + "{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"/tmp/a.b.dll\"}," - + "{\"Key\":{\"Id\":\"TestObject.Traits\",\"Label\":\"Traits\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":5,\"ValueType\":\"System.Collections.Generic.KeyValuePair`2[[System.String],[System.String]][]\"},\"Value\":[{\"Key\":\"t\",\"Value\":\"SDJDDHW>,:&^%//\\\\\\\\\\\\\\\\\"}]}]}"; - - var test = Deserialize(json, version); - - var traits = test.Traits.ToArray(); - Assert.AreEqual(1, traits.Length); - Assert.AreEqual(@"SDJDDHW>,:&^%//\\\\", traits[0].Value); - } - - #endregion - - private static string Serialize(T data, int version = 1) - { - return JsonDataSerializer.Instance.Serialize(data, version); - } - - private static T Deserialize(string json, int version = 1) - { - return JsonDataSerializer.Instance.Deserialize(json, version); - } - - private void VerifyDummyPropertyIsRegistered() - { - var dummyProperty = TestProperty.Find("DummyProperty"); - Assert.IsNotNull(dummyProperty); - Assert.AreEqual("DummyPropertyLabel", dummyProperty.Label); - Assert.AreEqual("System.String", dummyProperty.ValueType); - Assert.AreEqual(5, (int)dummyProperty.Attributes); - } + var dummyProperty = TestProperty.Find("DummyProperty"); + Assert.IsNotNull(dummyProperty); + Assert.AreEqual("DummyPropertyLabel", dummyProperty.Label); + Assert.AreEqual("System.String", dummyProperty.ValueType); + Assert.AreEqual(5, (int)dummyProperty.Attributes); } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestObjectConverterTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestObjectConverterTests.cs index 097c25d9d8..1f431db2f4 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestObjectConverterTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestObjectConverterTests.cs @@ -1,170 +1,169 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests.Serialization +namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests.Serialization; + +using System; +using System.Linq; + +using TestDoubles; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class TestObjectConverterTests { - using System; - using System.Linq; + [TestMethod] + public void TestObjectJsonShouldContainOnlyProperties() + { + var json = Serialize(new TestableTestObject()); + + Assert.AreEqual("{\"Properties\":[]}", json); + } + + [TestMethod] + public void TestObjectShouldCreateDefaultObjectOnDeserializationOfJsonWithEmptyProperties() + { + var test = Deserialize("{\"Properties\":[]}"); + + Assert.IsNotNull(test); + Assert.AreEqual(0, test.Properties.Count()); + } - using Microsoft.TestPlatform.CommunicationUtilities.UnitTests.TestDoubles; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; + [TestMethod] + public void TestCaseObjectShouldSerializeCustomProperties() + { + var test = new TestableTestObject(); + var testProperty1 = TestProperty.Register("1", "label1", typeof(Guid), typeof(TestableTestObject)); + var testPropertyData1 = Guid.Parse("02048dfd-3da7-475d-a011-8dd1121855ec"); + var testProperty2 = TestProperty.Register("2", "label2", typeof(int), typeof(TestableTestObject)); + var testPropertyData2 = 29; + test.SetPropertyValue(testProperty1, testPropertyData1); + test.SetPropertyValue(testProperty2, testPropertyData2); + + var json = Serialize(test); + + // Use raw deserialization to validate basic properties + var expectedJson = "{\"Properties\":[{\"Key\":{\"Id\":\"1\",\"Label\":\"label1\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.Guid\"},\"Value\":\"02048dfd-3da7-475d-a011-8dd1121855ec\"},{\"Key\":{\"Id\":\"2\",\"Label\":\"label2\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.Int32\"},\"Value\":29}]}"; + Assert.AreEqual(expectedJson, json); + } + + [TestMethod] + public void TestObjectShouldSerializeStringArrayValueForProperty() + { + var test = new TestableTestObject(); + var testProperty1 = TestProperty.Register("11", "label1", typeof(string[]), typeof(TestableTestObject)); + var testPropertyData1 = new[] { "val1", "val2" }; + test.SetPropertyValue(testProperty1, testPropertyData1); + + var json = Serialize(test); + + var expectedJson = "{\"Properties\":[{\"Key\":{\"Id\":\"11\",\"Label\":\"label1\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String[]\"},\"Value\":[\"val1\",\"val2\"]}]}"; + Assert.AreEqual(expectedJson, json); + } + + [TestMethod] + public void TestObjectShouldSerializeDateTimeOffsetForProperty() + { + var test = new TestableTestObject(); + var testProperty1 = TestProperty.Register("12", "label1", typeof(DateTimeOffset), typeof(TestableTestObject)); + var testPropertyData1 = DateTimeOffset.MaxValue; + test.SetPropertyValue(testProperty1, testPropertyData1); + + var json = Serialize(test); + + var expectedJson = "{\"Properties\":[{\"Key\":{\"Id\":\"12\",\"Label\":\"label1\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"9999-12-31T23:59:59.9999999+00:00\"}]}"; + Assert.AreEqual(expectedJson, json); + } + + [TestMethod] + public void TestObjectShouldDeserializeCustomProperties() + { + var json = "{\"Properties\":[{\"Key\":{\"Id\":\"13\",\"Label\":\"label1\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.Guid\"},\"Value\":\"02048dfd-3da7-475d-a011-8dd1121855ec\"},{\"Key\":{\"Id\":\"2\",\"Label\":\"label2\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.Int32\"},\"Value\":29}]}"; + + var test = Deserialize(json); + + var properties = test.Properties.ToArray(); + Assert.AreEqual(2, properties.Length); + Assert.AreEqual(Guid.Parse("02048dfd-3da7-475d-a011-8dd1121855ec"), test.GetPropertyValue(properties[0])); + Assert.AreEqual(29, test.GetPropertyValue(properties[1])); + } + + [TestMethod] + public void TestObjectShouldDeserializeNullValueForProperty() + { + var json = "{\"Properties\":[{\"Key\":{\"Id\":\"14\",\"Label\":\"label1\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null}]}"; + + var test = Deserialize(json); + + var properties = test.Properties.ToArray(); + Assert.AreEqual(1, properties.Length); + Assert.IsTrue(string.IsNullOrEmpty(test.GetPropertyValue(properties[0]).ToString())); + } + + [TestMethod] + public void TestObjectShouldDeserializeStringArrayValueForProperty() + { + var json = "{\"Properties\":[{\"Key\":{\"Id\":\"15\",\"Label\":\"label1\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String[]\"},\"Value\":[\"val1\", \"val2\"]}]}"; + + var test = Deserialize(json); + + var properties = test.Properties.ToArray(); + Assert.AreEqual(1, properties.Length); + CollectionAssert.AreEqual(new[] { "val1", "val2" }, (string[])test.GetPropertyValue(properties[0])); + } + + [TestMethod] + public void TestObjectShouldDeserializeDatetimeOffset() + { + var json = "{\"Properties\":[{\"Key\":{\"Id\":\"16\",\"Label\":\"label1\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"9999-12-31T23:59:59.9999999+00:00\"}]}"; + + var test = Deserialize(json); + + var properties = test.Properties.ToArray(); + Assert.AreEqual(1, properties.Length); + Assert.AreEqual(DateTimeOffset.MaxValue, test.GetPropertyValue(properties[0])); + } + + [TestMethod] + public void TestObjectShouldAddPropertyToTestPropertyStoreOnDeserialize() + { + var json = "{\"Properties\":[{\"Key\":{\"Id\":\"17\",\"Label\":\"label1\",\"Category\":\"c\",\"Description\":\"d\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"DummyValue\"}]}"; + + var test = Deserialize(json); + + var property = TestProperty.Find("17"); + Assert.IsNotNull(property); + Assert.AreEqual("17", property.Id); + Assert.AreEqual("label1", property.Label); + Assert.AreEqual("c", property.Category); + Assert.AreEqual("d", property.Description); + Assert.AreEqual(typeof(string), property.GetValueType()); + Assert.AreEqual(TestPropertyAttributes.None, property.Attributes); + Assert.AreEqual("DummyValue", test.GetPropertyValue(property)); + } + + [TestMethod] + public void TestObjectSetPropertyValueShouldNotConvertIfValueMatchesPropertyDataType() + { + var property = TestProperty.Register("98", "p1", typeof(bool), typeof(TestObject)); + var testobj = new TestableTestObject(); + + // This should not throw even if the runtime type of boolean where as specified + // type is object + testobj.SetPropertyValue(property, false); + + Assert.AreEqual(false, testobj.GetPropertyValue(property)); + } + + private static string Serialize(T data) + { + return JsonDataSerializer.Instance.Serialize(data); + } - [TestClass] - public class TestObjectConverterTests + private static T Deserialize(string json) { - [TestMethod] - public void TestObjectJsonShouldContainOnlyProperties() - { - var json = Serialize(new TestableTestObject()); - - Assert.AreEqual("{\"Properties\":[]}", json); - } - - [TestMethod] - public void TestObjectShouldCreateDefaultObjectOnDeserializationOfJsonWithEmptyProperties() - { - var test = Deserialize("{\"Properties\":[]}"); - - Assert.IsNotNull(test); - Assert.AreEqual(0, test.Properties.Count()); - } - - [TestMethod] - public void TestCaseObjectShouldSerializeCustomProperties() - { - var test = new TestableTestObject(); - var testProperty1 = TestProperty.Register("1", "label1", typeof(Guid), typeof(TestableTestObject)); - var testPropertyData1 = Guid.Parse("02048dfd-3da7-475d-a011-8dd1121855ec"); - var testProperty2 = TestProperty.Register("2", "label2", typeof(int), typeof(TestableTestObject)); - var testPropertyData2 = 29; - test.SetPropertyValue(testProperty1, testPropertyData1); - test.SetPropertyValue(testProperty2, testPropertyData2); - - var json = Serialize(test); - - // Use raw deserialization to validate basic properties - var expectedJson = "{\"Properties\":[{\"Key\":{\"Id\":\"1\",\"Label\":\"label1\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.Guid\"},\"Value\":\"02048dfd-3da7-475d-a011-8dd1121855ec\"},{\"Key\":{\"Id\":\"2\",\"Label\":\"label2\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.Int32\"},\"Value\":29}]}"; - Assert.AreEqual(expectedJson, json); - } - - [TestMethod] - public void TestObjectShouldSerializeStringArrayValueForProperty() - { - var test = new TestableTestObject(); - var testProperty1 = TestProperty.Register("11", "label1", typeof(string[]), typeof(TestableTestObject)); - var testPropertyData1 = new[] { "val1", "val2" }; - test.SetPropertyValue(testProperty1, testPropertyData1); - - var json = Serialize(test); - - var expectedJson = "{\"Properties\":[{\"Key\":{\"Id\":\"11\",\"Label\":\"label1\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String[]\"},\"Value\":[\"val1\",\"val2\"]}]}"; - Assert.AreEqual(expectedJson, json); - } - - [TestMethod] - public void TestObjectShouldSerializeDateTimeOffsetForProperty() - { - var test = new TestableTestObject(); - var testProperty1 = TestProperty.Register("12", "label1", typeof(DateTimeOffset), typeof(TestableTestObject)); - var testPropertyData1 = DateTimeOffset.MaxValue; - test.SetPropertyValue(testProperty1, testPropertyData1); - - var json = Serialize(test); - - var expectedJson = "{\"Properties\":[{\"Key\":{\"Id\":\"12\",\"Label\":\"label1\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"9999-12-31T23:59:59.9999999+00:00\"}]}"; - Assert.AreEqual(expectedJson, json); - } - - [TestMethod] - public void TestObjectShouldDeserializeCustomProperties() - { - var json = "{\"Properties\":[{\"Key\":{\"Id\":\"13\",\"Label\":\"label1\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.Guid\"},\"Value\":\"02048dfd-3da7-475d-a011-8dd1121855ec\"},{\"Key\":{\"Id\":\"2\",\"Label\":\"label2\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.Int32\"},\"Value\":29}]}"; - - var test = Deserialize(json); - - var properties = test.Properties.ToArray(); - Assert.AreEqual(2, properties.Length); - Assert.AreEqual(Guid.Parse("02048dfd-3da7-475d-a011-8dd1121855ec"), test.GetPropertyValue(properties[0])); - Assert.AreEqual(29, test.GetPropertyValue(properties[1])); - } - - [TestMethod] - public void TestObjectShouldDeserializeNullValueForProperty() - { - var json = "{\"Properties\":[{\"Key\":{\"Id\":\"14\",\"Label\":\"label1\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null}]}"; - - var test = Deserialize(json); - - var properties = test.Properties.ToArray(); - Assert.AreEqual(1, properties.Length); - Assert.IsTrue(string.IsNullOrEmpty(test.GetPropertyValue(properties[0]).ToString())); - } - - [TestMethod] - public void TestObjectShouldDeserializeStringArrayValueForProperty() - { - var json = "{\"Properties\":[{\"Key\":{\"Id\":\"15\",\"Label\":\"label1\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String[]\"},\"Value\":[\"val1\", \"val2\"]}]}"; - - var test = Deserialize(json); - - var properties = test.Properties.ToArray(); - Assert.AreEqual(1, properties.Length); - CollectionAssert.AreEqual(new[] { "val1", "val2" }, (string[])test.GetPropertyValue(properties[0])); - } - - [TestMethod] - public void TestObjectShouldDeserializeDatetimeOffset() - { - var json = "{\"Properties\":[{\"Key\":{\"Id\":\"16\",\"Label\":\"label1\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"9999-12-31T23:59:59.9999999+00:00\"}]}"; - - var test = Deserialize(json); - - var properties = test.Properties.ToArray(); - Assert.AreEqual(1, properties.Length); - Assert.AreEqual(DateTimeOffset.MaxValue, test.GetPropertyValue(properties[0])); - } - - [TestMethod] - public void TestObjectShouldAddPropertyToTestPropertyStoreOnDeserialize() - { - var json = "{\"Properties\":[{\"Key\":{\"Id\":\"17\",\"Label\":\"label1\",\"Category\":\"c\",\"Description\":\"d\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"DummyValue\"}]}"; - - var test = Deserialize(json); - - var property = TestProperty.Find("17"); - Assert.IsNotNull(property); - Assert.AreEqual("17", property.Id); - Assert.AreEqual("label1", property.Label); - Assert.AreEqual("c", property.Category); - Assert.AreEqual("d", property.Description); - Assert.AreEqual(typeof(string), property.GetValueType()); - Assert.AreEqual(TestPropertyAttributes.None, property.Attributes); - Assert.AreEqual("DummyValue", test.GetPropertyValue(property)); - } - - [TestMethod] - public void TestObjectSetPropertyValueShouldNotConvertIfValueMatchesPropertyDataType() - { - var property = TestProperty.Register("98", "p1", typeof(bool), typeof(TestObject)); - var testobj = new TestableTestObject(); - - // This should not throw even if the runtime type of boolean where as specified - // type is object - testobj.SetPropertyValue(property, false); - - Assert.AreEqual(false, testobj.GetPropertyValue(property)); - } - - private static string Serialize(T data) - { - return JsonDataSerializer.Instance.Serialize(data); - } - - private static T Deserialize(string json) - { - return JsonDataSerializer.Instance.Deserialize(json); - } + return JsonDataSerializer.Instance.Deserialize(json); } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestResultSerializationTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestResultSerializationTests.cs index 8f811846e5..f69ba4ee2d 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestResultSerializationTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestResultSerializationTests.cs @@ -1,312 +1,310 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests.Serialization +namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests.Serialization; + +using System; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using VisualStudio.TestTools.UnitTesting; + +using Newtonsoft.Json.Linq; + +using TestResult = VisualStudio.TestPlatform.ObjectModel.TestResult; + +[TestClass] +public class TestResultSerializationTests { - using System; + private static readonly TestCase TestCase = new( + "sampleTestClass.sampleTestCase", + new Uri("executor://sampleTestExecutor"), + "sampleTest.dll"); + + private static DateTimeOffset s_startTime = new(new DateTime(2007, 3, 10, 0, 0, 0, DateTimeKind.Utc)); + private static readonly TestResult TestResult = new(TestCase) + { + // Attachments = ? + // Messages = ? + Outcome = TestOutcome.Passed, + ErrorMessage = "sampleError", + ErrorStackTrace = "sampleStackTrace", + DisplayName = "sampleTestResult", + ComputerName = "sampleComputerName", + Duration = TimeSpan.MaxValue, + StartTime = s_startTime, + EndTime = DateTimeOffset.MaxValue + }; + + #region v1 serializer Tests (used with protocol 1 and accidentally with 3) + + [TestMethod] + [DataRow(1)] + [DataRow(3)] + public void TestResultJsonShouldContainAllPropertiesOnSerialization(int version) + { + var json = Serialize(TestResult, version); + + // Use raw deserialization to validate basic properties + dynamic data = JObject.Parse(json); + dynamic properties = data["Properties"]; + Assert.AreEqual("TestResult.Outcome", properties[0]["Key"]["Id"].Value); + Assert.AreEqual(1, properties[0]["Value"].Value); + Assert.AreEqual("TestResult.ErrorMessage", properties[1]["Key"]["Id"].Value); + Assert.AreEqual("sampleError", properties[1]["Value"].Value); + Assert.AreEqual("TestResult.ErrorStackTrace", properties[2]["Key"]["Id"].Value); + Assert.AreEqual("sampleStackTrace", properties[2]["Value"].Value); + Assert.AreEqual("TestResult.DisplayName", properties[3]["Key"]["Id"].Value); + Assert.AreEqual("sampleTestResult", properties[3]["Value"].Value); + Assert.AreEqual("TestResult.ComputerName", properties[4]["Key"]["Id"].Value); + Assert.AreEqual("sampleComputerName", properties[4]["Value"].Value); + Assert.AreEqual("TestResult.Duration", properties[5]["Key"]["Id"].Value); + Assert.AreEqual("10675199.02:48:05.4775807", properties[5]["Value"].Value); + + // By default json.net converts DateTimes to current time zone + Assert.AreEqual("TestResult.StartTime", properties[6]["Key"]["Id"].Value); + Assert.AreEqual(s_startTime.Year, ((DateTimeOffset)properties[6]["Value"].Value).Year); + Assert.AreEqual("TestResult.EndTime", properties[7]["Key"]["Id"].Value); + Assert.AreEqual(DateTimeOffset.MaxValue.Year, ((DateTimeOffset)properties[7]["Value"].Value).Year); + } + + [TestMethod] + [DataRow(1)] + [DataRow(3)] + public void TestResultObjectShouldContainAllPropertiesOnDeserialization(int version) + { + var json = "{\"TestCase\":{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"},{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"executor://sampleTestExecutor\"},{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTest.dll\"}]},\"Attachments\":[],\"Messages\":[],\"Properties\":[{\"Key\":{\"Id\":\"TestResult.Outcome\",\"Label\":\"Outcome\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome\"},\"Value\":1},{\"Key\":{\"Id\":\"TestResult.ErrorMessage\",\"Label\":\"Error Message\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleError\"},{\"Key\":{\"Id\":\"TestResult.ErrorStackTrace\",\"Label\":\"Error Stack Trace\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleStackTrace\"},{\"Key\":{\"Id\":\"TestResult.DisplayName\",\"Label\":\"TestResult Display Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestResult\"},{\"Key\":{\"Id\":\"TestResult.ComputerName\",\"Label\":\"Computer Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleComputerName\"},{\"Key\":{\"Id\":\"TestResult.Duration\",\"Label\":\"Duration\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.TimeSpan\"},\"Value\":\"10675199.02:48:05.4775807\"},{\"Key\":{\"Id\":\"TestResult.StartTime\",\"Label\":\"Start Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"2007-03-10T00:00:00+00:00\"},{\"Key\":{\"Id\":\"TestResult.EndTime\",\"Label\":\"End Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"9999-12-31T23:59:59.9999999+00:00\"}]}"; + + var test = Deserialize(json, version); + + Assert.AreEqual(TestResult.TestCase.Id, test.TestCase.Id); + Assert.AreEqual(TestResult.Attachments.Count, test.Attachments.Count); + Assert.AreEqual(TestResult.Messages.Count, test.Messages.Count); + + Assert.AreEqual(TestResult.ComputerName, test.ComputerName); + Assert.AreEqual(TestResult.DisplayName, test.DisplayName); + Assert.AreEqual(TestResult.Duration, test.Duration); + Assert.AreEqual(TestResult.EndTime, test.EndTime); + Assert.AreEqual(TestResult.ErrorMessage, test.ErrorMessage); + Assert.AreEqual(TestResult.ErrorStackTrace, test.ErrorStackTrace); + Assert.AreEqual(TestResult.Outcome, test.Outcome); + Assert.AreEqual(TestResult.StartTime, test.StartTime); + } + + [TestMethod] + [DataRow(1)] + [DataRow(3)] + public void TestResultObjectShouldSerializeAttachments(int version) + { + var result = new TestResult(TestCase); + result.StartTime = default; + result.EndTime = default; + result.Attachments.Add(new AttachmentSet(new Uri("http://dummyUri"), "sampleAttachment")); + var expectedJson = "{\"TestCase\":{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"},{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"executor://sampleTestExecutor\"},{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTest.dll\"},{\"Key\":{\"Id\":\"TestCase.CodeFilePath\",\"Label\":\"File Path\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestCase.DisplayName\",\"Label\":\"Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"},{\"Key\":{\"Id\":\"TestCase.Id\",\"Label\":\"Id\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Guid\"},\"Value\":\"28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b\"},{\"Key\":{\"Id\":\"TestCase.LineNumber\",\"Label\":\"Line Number\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Int32\"},\"Value\":-1}]},\"Attachments\":[{\"Uri\":\"http://dummyUri\",\"DisplayName\":\"sampleAttachment\",\"Attachments\":[]}],\"Messages\":[],\"Properties\":[{\"Key\":{\"Id\":\"TestResult.Outcome\",\"Label\":\"Outcome\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome, Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\"},\"Value\":0},{\"Key\":{\"Id\":\"TestResult.ErrorMessage\",\"Label\":\"Error Message\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.ErrorStackTrace\",\"Label\":\"Error Stack Trace\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.DisplayName\",\"Label\":\"TestResult Display Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.ComputerName\",\"Label\":\"Computer Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"\"},{\"Key\":{\"Id\":\"TestResult.Duration\",\"Label\":\"Duration\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.TimeSpan\"},\"Value\":\"00:00:00\"},{\"Key\":{\"Id\":\"TestResult.StartTime\",\"Label\":\"Start Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"0001-01-01T00:00:00+00:00\"},{\"Key\":{\"Id\":\"TestResult.EndTime\",\"Label\":\"End Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"0001-01-01T00:00:00+00:00\"}]}"; + + var json = Serialize(result, version); + + Assert.AreEqual(expectedJson, json); + } + + [TestMethod] + [DataRow(1)] + [DataRow(3)] + public void TestResultObjectShouldDeserializeAttachments(int version) + { + var json = "{\"TestCase\":{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"},{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"executor://sampleTestExecutor\"},{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTest.dll\"}]},\"Attachments\":[{\"Uri\":\"http://dummyUri\",\"DisplayName\":\"sampleAttachment\",\"Attachments\":[]}],\"Messages\":[],\"Properties\":[]}"; + + var result = Deserialize(json, version); + + Assert.AreEqual(1, result.Attachments.Count); + Assert.AreEqual(new Uri("http://dummyUri"), result.Attachments[0].Uri); + Assert.AreEqual("sampleAttachment", result.Attachments[0].DisplayName); + } + + [TestMethod] + [DataRow(1)] + [DataRow(3)] + public void TestResultObjectShouldSerializeDefaultValues(int version) + { + var result = new TestResult(TestCase); + result.StartTime = default; + result.EndTime = default; + var expectedJson = "{\"TestCase\":{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"},{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"executor://sampleTestExecutor\"},{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTest.dll\"},{\"Key\":{\"Id\":\"TestCase.CodeFilePath\",\"Label\":\"File Path\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestCase.DisplayName\",\"Label\":\"Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"},{\"Key\":{\"Id\":\"TestCase.Id\",\"Label\":\"Id\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Guid\"},\"Value\":\"28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b\"},{\"Key\":{\"Id\":\"TestCase.LineNumber\",\"Label\":\"Line Number\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Int32\"},\"Value\":-1}]},\"Attachments\":[],\"Messages\":[],\"Properties\":[{\"Key\":{\"Id\":\"TestResult.Outcome\",\"Label\":\"Outcome\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome, Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\"},\"Value\":0},{\"Key\":{\"Id\":\"TestResult.ErrorMessage\",\"Label\":\"Error Message\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.ErrorStackTrace\",\"Label\":\"Error Stack Trace\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.DisplayName\",\"Label\":\"TestResult Display Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.ComputerName\",\"Label\":\"Computer Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"\"},{\"Key\":{\"Id\":\"TestResult.Duration\",\"Label\":\"Duration\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.TimeSpan\"},\"Value\":\"00:00:00\"},{\"Key\":{\"Id\":\"TestResult.StartTime\",\"Label\":\"Start Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"0001-01-01T00:00:00+00:00\"},{\"Key\":{\"Id\":\"TestResult.EndTime\",\"Label\":\"End Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"0001-01-01T00:00:00+00:00\"}]}"; + + var json = Serialize(result, version); + + // Values that should be null: DisplayName, ErrorMessage, ErrorStackTrace + // Values that should be empty: ComputerName + Assert.AreEqual(expectedJson, json); + } + + [TestMethod] + [DataRow(1)] + [DataRow(3)] + public void TestResultObjectShouldDeserializeDefaultValues(int version) + { + var json = "{\"TestCase\":{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"},{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"executor://sampleTestExecutor\"},{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTest.dll\"},{\"Key\":{\"Id\":\"TestCase.CodeFilePath\",\"Label\":\"File Path\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestCase.DisplayName\",\"Label\":\"Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"},{\"Key\":{\"Id\":\"TestCase.Id\",\"Label\":\"Id\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Guid\"},\"Value\":\"28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b\"},{\"Key\":{\"Id\":\"TestCase.LineNumber\",\"Label\":\"Line Number\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Int32\"},\"Value\":-1}]},\"Attachments\":[],\"Messages\":[],\"Properties\":[{\"Key\":{\"Id\":\"TestResult.Outcome\",\"Label\":\"Outcome\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome, Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\"},\"Value\":0},{\"Key\":{\"Id\":\"TestResult.ErrorMessage\",\"Label\":\"Error Message\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.ErrorStackTrace\",\"Label\":\"Error Stack Trace\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.DisplayName\",\"Label\":\"TestResult Display Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.ComputerName\",\"Label\":\"Computer Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"\"},{\"Key\":{\"Id\":\"TestResult.Duration\",\"Label\":\"Duration\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.TimeSpan\"},\"Value\":\"00:00:00\"},{\"Key\":{\"Id\":\"TestResult.StartTime\",\"Label\":\"Start Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"0001-01-01T00:00:00+00:00\"},{\"Key\":{\"Id\":\"TestResult.EndTime\",\"Label\":\"End Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"0001-01-01T00:00:00+00:00\"}]}"; + + var result = Deserialize(json, version); + + Assert.AreEqual(0, result.Attachments.Count); + Assert.AreEqual(0, result.Messages.Count); + Assert.IsNull(result.DisplayName); + Assert.IsNull(result.ErrorMessage); + Assert.IsNull(result.ErrorStackTrace); + Assert.AreEqual(string.Empty, result.ComputerName); + } + + [TestMethod] + [DataRow(1)] + [DataRow(3)] + public void TestResultPropertiesShouldGetRegisteredAsPartOfDeserialization(int version) + { + TestProperty.TryUnregister("DummyProperty", out var _); + var json = "{\"TestCase\":{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"}," + + "{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"executor://sampleTestExecutor\"}," + + "{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTest.dll\"}," + + "{\"Key\":{\"Id\":\"TestCase.CodeFilePath\",\"Label\":\"File Path\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null}," + + "{\"Key\":{\"Id\":\"TestCase.DisplayName\",\"Label\":\"Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"}," + + "{\"Key\":{\"Id\":\"TestCase.Id\",\"Label\":\"Id\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Guid\"},\"Value\":\"28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b\"}," + + "{\"Key\":{\"Id\":\"TestCase.LineNumber\",\"Label\":\"Line Number\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Int32\"},\"Value\":-1}]}," + + "\"Attachments\":[],\"Messages\":[]," + + "\"Properties\":[{\"Key\":{\"Id\":\"TestResult.Outcome\",\"Label\":\"Outcome\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome, Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\"},\"Value\":0}," + + "{\"Key\":{\"Id\":\"TestResult.ErrorMessage\",\"Label\":\"Error Message\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.ErrorStackTrace\",\"Label\":\"Error Stack Trace\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null}," + + "{\"Key\":{\"Id\":\"TestResult.DisplayName\",\"Label\":\"TestResult Display Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.ComputerName\",\"Label\":\"Computer Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"\"}," + + "{\"Key\":{\"Id\":\"TestResult.Duration\",\"Label\":\"Duration\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.TimeSpan\"},\"Value\":\"00:00:00\"},{\"Key\":{\"Id\":\"TestResult.StartTime\",\"Label\":\"Start Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"0001-01-01T00:00:00+00:00\"}," + + "{\"Key\":{\"Id\":\"DummyProperty\",\"Label\":\"DummyPropertyLabel\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":5,\"ValueType\":\"System.String\"},\"Value\":\"dummyString\"}," + + "{\"Key\":{\"Id\":\"TestResult.EndTime\",\"Label\":\"End Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"0001-01-01T00:00:00+00:00\"}]}"; + _ = Deserialize(json, version); + + VerifyDummyPropertyIsRegistered(); + } - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; + #endregion - using Newtonsoft.Json.Linq; + #region v2 serializer Tests (used with protocol 2 and 4) - using TestResult = Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult; + [TestMethod] + [DataRow(2)] + [DataRow(4)] + public void TestResultJsonShouldContainAllPropertiesOnSerializationV2(int version) + { + var json = Serialize(TestResult, version); + + // Use raw deserialization to validate basic properties + dynamic data = JObject.Parse(json); + + Assert.AreEqual(1, data["Outcome"].Value); + Assert.AreEqual("sampleError", data["ErrorMessage"].Value); + Assert.AreEqual("sampleStackTrace", data["ErrorStackTrace"].Value); + Assert.AreEqual("sampleTestResult", data["DisplayName"].Value); + Assert.AreEqual("sampleComputerName", data["ComputerName"].Value); + Assert.AreEqual("10675199.02:48:05.4775807", data["Duration"].Value); + + // By default json.net converts DateTimes to current time zone + Assert.AreEqual(s_startTime.Year, ((DateTimeOffset)data["StartTime"].Value).Year); + Assert.AreEqual(DateTimeOffset.MaxValue.Year, ((DateTimeOffset)data["EndTime"].Value).Year); + } + + [TestMethod] + [DataRow(2)] + [DataRow(4)] + public void TestResultObjectShouldContainAllPropertiesOnDeserializationV2(int version) + { + var json = "{\"TestCase\":{\"Id\":\"28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b\",\"FullyQualifiedName\":\"sampleTestClass.sampleTestCase\",\"DisplayName\":\"sampleTestClass.sampleTestCase\",\"ExecutorUri\":\"executor://sampleTestExecutor\",\"Source\":\"sampleTest.dll\",\"CodeFilePath\":null,\"LineNumber\":-1,\"Properties\":[]},\"Attachments\":[],\"Outcome\":1,\"ErrorMessage\":\"sampleError\",\"ErrorStackTrace\":\"sampleStackTrace\",\"DisplayName\":\"sampleTestResult\",\"Messages\":[],\"ComputerName\":\"sampleComputerName\",\"Duration\":\"10675199.02:48:05.4775807\",\"StartTime\":\"2007-03-10T00:00:00+00:00\",\"EndTime\":\"9999-12-31T23:59:59.9999999+00:00\",\"Properties\":[]}"; + + var test = Deserialize(json, version); + + Assert.AreEqual(TestResult.TestCase.Id, test.TestCase.Id); + Assert.AreEqual(TestResult.Attachments.Count, test.Attachments.Count); + Assert.AreEqual(TestResult.Messages.Count, test.Messages.Count); + + Assert.AreEqual(TestResult.ComputerName, test.ComputerName); + Assert.AreEqual(TestResult.DisplayName, test.DisplayName); + Assert.AreEqual(TestResult.Duration, test.Duration); + Assert.AreEqual(TestResult.EndTime, test.EndTime); + Assert.AreEqual(TestResult.ErrorMessage, test.ErrorMessage); + Assert.AreEqual(TestResult.ErrorStackTrace, test.ErrorStackTrace); + Assert.AreEqual(TestResult.Outcome, test.Outcome); + Assert.AreEqual(TestResult.StartTime, test.StartTime); + } + + [TestMethod] + [DataRow(2)] + [DataRow(4)] + public void TestResultObjectShouldSerializeAttachmentsV2(int version) + { + var result = new TestResult(TestCase); + result.StartTime = default; + result.EndTime = default; + result.Attachments.Add(new AttachmentSet(new Uri("http://dummyUri"), "sampleAttachment")); + var expectedJson = "{\"TestCase\":{\"Id\":\"28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b\",\"FullyQualifiedName\":\"sampleTestClass.sampleTestCase\",\"DisplayName\":\"sampleTestClass.sampleTestCase\",\"ExecutorUri\":\"executor://sampleTestExecutor\",\"Source\":\"sampleTest.dll\",\"CodeFilePath\":null,\"LineNumber\":-1,\"Properties\":[]},\"Attachments\":[{\"Uri\":\"http://dummyUri\",\"DisplayName\":\"sampleAttachment\",\"Attachments\":[]}],\"Outcome\":0,\"ErrorMessage\":null,\"ErrorStackTrace\":null,\"DisplayName\":null,\"Messages\":[],\"ComputerName\":null,\"Duration\":\"00:00:00\",\"StartTime\":\"0001-01-01T00:00:00+00:00\",\"EndTime\":\"0001-01-01T00:00:00+00:00\",\"Properties\":[]}"; + + var json = Serialize(result, version); + + Assert.AreEqual(expectedJson, json); + } + + [TestMethod] + [DataRow(2)] + [DataRow(4)] + public void TestResultObjectShouldDeserializeAttachmentsV2(int version) + { + var json = "{\"TestCase\":{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"},{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"executor://sampleTestExecutor\"},{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTest.dll\"},{\"Key\":{\"Id\":\"TestCase.Id\",\"Label\":\"Id\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Guid\"},\"Value\":\"28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b\"}]},\"Attachments\":[{\"Uri\":\"http://dummyUri\",\"DisplayName\":\"sampleAttachment\",\"Attachments\":[]}],\"Messages\":[],\"Properties\":[]}"; + + var result = Deserialize(json, version); + + Assert.AreEqual(1, result.Attachments.Count); + Assert.AreEqual(new Uri("http://dummyUri"), result.Attachments[0].Uri); + Assert.AreEqual("sampleAttachment", result.Attachments[0].DisplayName); + } + + [TestMethod] + [DataRow(2)] + [DataRow(4)] + public void TestResultPropertiesShouldGetRegisteredAsPartOfDeserializationV2(int version) + { + TestProperty.TryUnregister("DummyProperty", out var _); + var json = "{\"TestCase\":{\"Id\":\"28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b\",\"FullyQualifiedName\":\"sampleTestClass.sampleTestCase\",\"DisplayName\":\"sampleTestClass.sampleTestCase\",\"ExecutorUri\":\"executor://sampleTestExecutor\",\"Source\":\"sampleTest.dll\",\"CodeFilePath\":null,\"LineNumber\":-1,\"Properties\":[]},\"Attachments\":[],\"Outcome\":1,\"ErrorMessage\":\"sampleError\",\"ErrorStackTrace\":\"sampleStackTrace\",\"DisplayName\":\"sampleTestResult\",\"Messages\":[],\"ComputerName\":\"sampleComputerName\",\"Duration\":\"10675199.02:48:05.4775807\",\"StartTime\":\"2007-03-10T00:00:00+00:00\",\"EndTime\":\"9999-12-31T23:59:59.9999999+00:00\"," + + "\"Properties\":[{\"Key\":{\"Id\":\"DummyProperty\",\"Label\":\"DummyPropertyLabel\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":5,\"ValueType\":\"System.String\"},\"Value\":\"dummyString\"},]}"; + _ = Deserialize(json, version); + + VerifyDummyPropertyIsRegistered(); + } + + #endregion + + #region future + + [TestMethod] + public void TestResultSerializationShouldThrowWhenProvidedProtocolVersionDoesNotExist() + { + // this is to ensure that introducing a new version is a conscious choice and + // and that we don't fallback to version 1 as it happened with version 3, because the serializer + // only checked for version 2 + var version = int.MaxValue; + + Assert.ThrowsException(() => Serialize(TestResult, version)); + } + + #endregion + + private static string Serialize(T data, int version) + { + return JsonDataSerializer.Instance.Serialize(data, version); + } + + private static T Deserialize(string json, int version) + { + return JsonDataSerializer.Instance.Deserialize(json, version); + } - [TestClass] - public class TestResultSerializationTests + private void VerifyDummyPropertyIsRegistered() { - private static TestCase testCase = new TestCase( - "sampleTestClass.sampleTestCase", - new Uri("executor://sampleTestExecutor"), - "sampleTest.dll"); - - private static DateTimeOffset startTime = new DateTimeOffset(new DateTime(2007, 3, 10, 0, 0, 0, DateTimeKind.Utc)); - private static TestResult testResult = new TestResult(testCase) - { - // Attachments = ? - // Messages = ? - Outcome = TestOutcome.Passed, - ErrorMessage = "sampleError", - ErrorStackTrace = "sampleStackTrace", - DisplayName = "sampleTestResult", - ComputerName = "sampleComputerName", - Duration = TimeSpan.MaxValue, - StartTime = startTime, - EndTime = DateTimeOffset.MaxValue - }; - - #region v1 serializer Tests (used with protocol 1 and accidentally with 3) - - [TestMethod] - [DataRow(1)] - [DataRow(3)] - public void TestResultJsonShouldContainAllPropertiesOnSerialization(int version) - { - var json = Serialize(testResult, version); - - // Use raw deserialization to validate basic properties - dynamic data = JObject.Parse(json); - dynamic properties = data["Properties"]; - Assert.AreEqual("TestResult.Outcome", properties[0]["Key"]["Id"].Value); - Assert.AreEqual(1, properties[0]["Value"].Value); - Assert.AreEqual("TestResult.ErrorMessage", properties[1]["Key"]["Id"].Value); - Assert.AreEqual("sampleError", properties[1]["Value"].Value); - Assert.AreEqual("TestResult.ErrorStackTrace", properties[2]["Key"]["Id"].Value); - Assert.AreEqual("sampleStackTrace", properties[2]["Value"].Value); - Assert.AreEqual("TestResult.DisplayName", properties[3]["Key"]["Id"].Value); - Assert.AreEqual("sampleTestResult", properties[3]["Value"].Value); - Assert.AreEqual("TestResult.ComputerName", properties[4]["Key"]["Id"].Value); - Assert.AreEqual("sampleComputerName", properties[4]["Value"].Value); - Assert.AreEqual("TestResult.Duration", properties[5]["Key"]["Id"].Value); - Assert.AreEqual("10675199.02:48:05.4775807", properties[5]["Value"].Value); - - // By default json.net converts DateTimes to current time zone - Assert.AreEqual("TestResult.StartTime", properties[6]["Key"]["Id"].Value); - Assert.AreEqual(startTime.Year, ((DateTimeOffset)properties[6]["Value"].Value).Year); - Assert.AreEqual("TestResult.EndTime", properties[7]["Key"]["Id"].Value); - Assert.AreEqual(DateTimeOffset.MaxValue.Year, ((DateTimeOffset)properties[7]["Value"].Value).Year); - } - - [TestMethod] - [DataRow(1)] - [DataRow(3)] - public void TestResultObjectShouldContainAllPropertiesOnDeserialization(int version) - { - var json = "{\"TestCase\":{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"},{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"executor://sampleTestExecutor\"},{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTest.dll\"}]},\"Attachments\":[],\"Messages\":[],\"Properties\":[{\"Key\":{\"Id\":\"TestResult.Outcome\",\"Label\":\"Outcome\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome\"},\"Value\":1},{\"Key\":{\"Id\":\"TestResult.ErrorMessage\",\"Label\":\"Error Message\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleError\"},{\"Key\":{\"Id\":\"TestResult.ErrorStackTrace\",\"Label\":\"Error Stack Trace\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleStackTrace\"},{\"Key\":{\"Id\":\"TestResult.DisplayName\",\"Label\":\"TestResult Display Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestResult\"},{\"Key\":{\"Id\":\"TestResult.ComputerName\",\"Label\":\"Computer Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleComputerName\"},{\"Key\":{\"Id\":\"TestResult.Duration\",\"Label\":\"Duration\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.TimeSpan\"},\"Value\":\"10675199.02:48:05.4775807\"},{\"Key\":{\"Id\":\"TestResult.StartTime\",\"Label\":\"Start Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"2007-03-10T00:00:00+00:00\"},{\"Key\":{\"Id\":\"TestResult.EndTime\",\"Label\":\"End Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"9999-12-31T23:59:59.9999999+00:00\"}]}"; - - var test = Deserialize(json, version); - - Assert.AreEqual(testResult.TestCase.Id, test.TestCase.Id); - Assert.AreEqual(testResult.Attachments.Count, test.Attachments.Count); - Assert.AreEqual(testResult.Messages.Count, test.Messages.Count); - - Assert.AreEqual(testResult.ComputerName, test.ComputerName); - Assert.AreEqual(testResult.DisplayName, test.DisplayName); - Assert.AreEqual(testResult.Duration, test.Duration); - Assert.AreEqual(testResult.EndTime, test.EndTime); - Assert.AreEqual(testResult.ErrorMessage, test.ErrorMessage); - Assert.AreEqual(testResult.ErrorStackTrace, test.ErrorStackTrace); - Assert.AreEqual(testResult.Outcome, test.Outcome); - Assert.AreEqual(testResult.StartTime, test.StartTime); - } - - [TestMethod] - [DataRow(1)] - [DataRow(3)] - public void TestResultObjectShouldSerializeAttachments(int version) - { - var result = new TestResult(testCase); - result.StartTime = default; - result.EndTime = default; - result.Attachments.Add(new AttachmentSet(new Uri("http://dummyUri"), "sampleAttachment")); - var expectedJson = "{\"TestCase\":{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"},{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"executor://sampleTestExecutor\"},{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTest.dll\"},{\"Key\":{\"Id\":\"TestCase.CodeFilePath\",\"Label\":\"File Path\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestCase.DisplayName\",\"Label\":\"Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"},{\"Key\":{\"Id\":\"TestCase.Id\",\"Label\":\"Id\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Guid\"},\"Value\":\"28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b\"},{\"Key\":{\"Id\":\"TestCase.LineNumber\",\"Label\":\"Line Number\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Int32\"},\"Value\":-1}]},\"Attachments\":[{\"Uri\":\"http://dummyUri\",\"DisplayName\":\"sampleAttachment\",\"Attachments\":[]}],\"Messages\":[],\"Properties\":[{\"Key\":{\"Id\":\"TestResult.Outcome\",\"Label\":\"Outcome\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome, Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\"},\"Value\":0},{\"Key\":{\"Id\":\"TestResult.ErrorMessage\",\"Label\":\"Error Message\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.ErrorStackTrace\",\"Label\":\"Error Stack Trace\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.DisplayName\",\"Label\":\"TestResult Display Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.ComputerName\",\"Label\":\"Computer Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"\"},{\"Key\":{\"Id\":\"TestResult.Duration\",\"Label\":\"Duration\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.TimeSpan\"},\"Value\":\"00:00:00\"},{\"Key\":{\"Id\":\"TestResult.StartTime\",\"Label\":\"Start Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"0001-01-01T00:00:00+00:00\"},{\"Key\":{\"Id\":\"TestResult.EndTime\",\"Label\":\"End Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"0001-01-01T00:00:00+00:00\"}]}"; - - var json = Serialize(result, version); - - Assert.AreEqual(expectedJson, json); - } - - [TestMethod] - [DataRow(1)] - [DataRow(3)] - public void TestResultObjectShouldDeserializeAttachments(int version) - { - var json = "{\"TestCase\":{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"},{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"executor://sampleTestExecutor\"},{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTest.dll\"}]},\"Attachments\":[{\"Uri\":\"http://dummyUri\",\"DisplayName\":\"sampleAttachment\",\"Attachments\":[]}],\"Messages\":[],\"Properties\":[]}"; - - var result = Deserialize(json, version); - - Assert.AreEqual(1, result.Attachments.Count); - Assert.AreEqual(new Uri("http://dummyUri"), result.Attachments[0].Uri); - Assert.AreEqual("sampleAttachment", result.Attachments[0].DisplayName); - } - - [TestMethod] - [DataRow(1)] - [DataRow(3)] - public void TestResultObjectShouldSerializeDefaultValues(int version) - { - var result = new TestResult(testCase); - result.StartTime = default; - result.EndTime = default; - var expectedJson = "{\"TestCase\":{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"},{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"executor://sampleTestExecutor\"},{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTest.dll\"},{\"Key\":{\"Id\":\"TestCase.CodeFilePath\",\"Label\":\"File Path\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestCase.DisplayName\",\"Label\":\"Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"},{\"Key\":{\"Id\":\"TestCase.Id\",\"Label\":\"Id\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Guid\"},\"Value\":\"28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b\"},{\"Key\":{\"Id\":\"TestCase.LineNumber\",\"Label\":\"Line Number\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Int32\"},\"Value\":-1}]},\"Attachments\":[],\"Messages\":[],\"Properties\":[{\"Key\":{\"Id\":\"TestResult.Outcome\",\"Label\":\"Outcome\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome, Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\"},\"Value\":0},{\"Key\":{\"Id\":\"TestResult.ErrorMessage\",\"Label\":\"Error Message\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.ErrorStackTrace\",\"Label\":\"Error Stack Trace\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.DisplayName\",\"Label\":\"TestResult Display Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.ComputerName\",\"Label\":\"Computer Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"\"},{\"Key\":{\"Id\":\"TestResult.Duration\",\"Label\":\"Duration\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.TimeSpan\"},\"Value\":\"00:00:00\"},{\"Key\":{\"Id\":\"TestResult.StartTime\",\"Label\":\"Start Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"0001-01-01T00:00:00+00:00\"},{\"Key\":{\"Id\":\"TestResult.EndTime\",\"Label\":\"End Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"0001-01-01T00:00:00+00:00\"}]}"; - - var json = Serialize(result, version); - - // Values that should be null: DisplayName, ErrorMessage, ErrorStackTrace - // Values that should be empty: ComputerName - Assert.AreEqual(expectedJson, json); - } - - [TestMethod] - [DataRow(1)] - [DataRow(3)] - public void TestResultObjectShouldDeserializeDefaultValues(int version) - { - var json = "{\"TestCase\":{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"},{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"executor://sampleTestExecutor\"},{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTest.dll\"},{\"Key\":{\"Id\":\"TestCase.CodeFilePath\",\"Label\":\"File Path\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestCase.DisplayName\",\"Label\":\"Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"},{\"Key\":{\"Id\":\"TestCase.Id\",\"Label\":\"Id\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Guid\"},\"Value\":\"28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b\"},{\"Key\":{\"Id\":\"TestCase.LineNumber\",\"Label\":\"Line Number\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Int32\"},\"Value\":-1}]},\"Attachments\":[],\"Messages\":[],\"Properties\":[{\"Key\":{\"Id\":\"TestResult.Outcome\",\"Label\":\"Outcome\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome, Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\"},\"Value\":0},{\"Key\":{\"Id\":\"TestResult.ErrorMessage\",\"Label\":\"Error Message\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.ErrorStackTrace\",\"Label\":\"Error Stack Trace\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.DisplayName\",\"Label\":\"TestResult Display Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.ComputerName\",\"Label\":\"Computer Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"\"},{\"Key\":{\"Id\":\"TestResult.Duration\",\"Label\":\"Duration\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.TimeSpan\"},\"Value\":\"00:00:00\"},{\"Key\":{\"Id\":\"TestResult.StartTime\",\"Label\":\"Start Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"0001-01-01T00:00:00+00:00\"},{\"Key\":{\"Id\":\"TestResult.EndTime\",\"Label\":\"End Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"0001-01-01T00:00:00+00:00\"}]}"; - - var result = Deserialize(json, version); - - Assert.AreEqual(0, result.Attachments.Count); - Assert.AreEqual(0, result.Messages.Count); - Assert.IsNull(result.DisplayName); - Assert.IsNull(result.ErrorMessage); - Assert.IsNull(result.ErrorStackTrace); - Assert.AreEqual(string.Empty, result.ComputerName); - } - - [TestMethod] - [DataRow(1)] - [DataRow(3)] - public void TestResultPropertiesShouldGetRegisteredAsPartOfDeserialization(int version) - { - TestProperty.TryUnregister("DummyProperty", out var property); - var json = "{\"TestCase\":{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"}," + - "{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"executor://sampleTestExecutor\"}," + - "{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTest.dll\"}," + - "{\"Key\":{\"Id\":\"TestCase.CodeFilePath\",\"Label\":\"File Path\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null}," + - "{\"Key\":{\"Id\":\"TestCase.DisplayName\",\"Label\":\"Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"}," + - "{\"Key\":{\"Id\":\"TestCase.Id\",\"Label\":\"Id\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Guid\"},\"Value\":\"28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b\"}," + - "{\"Key\":{\"Id\":\"TestCase.LineNumber\",\"Label\":\"Line Number\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Int32\"},\"Value\":-1}]}," + - "\"Attachments\":[],\"Messages\":[]," + - "\"Properties\":[{\"Key\":{\"Id\":\"TestResult.Outcome\",\"Label\":\"Outcome\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome, Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\"},\"Value\":0}," + - "{\"Key\":{\"Id\":\"TestResult.ErrorMessage\",\"Label\":\"Error Message\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.ErrorStackTrace\",\"Label\":\"Error Stack Trace\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":null}," + - "{\"Key\":{\"Id\":\"TestResult.DisplayName\",\"Label\":\"TestResult Display Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":null},{\"Key\":{\"Id\":\"TestResult.ComputerName\",\"Label\":\"Computer Name\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"\"}," + - "{\"Key\":{\"Id\":\"TestResult.Duration\",\"Label\":\"Duration\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.TimeSpan\"},\"Value\":\"00:00:00\"},{\"Key\":{\"Id\":\"TestResult.StartTime\",\"Label\":\"Start Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"0001-01-01T00:00:00+00:00\"}," + - "{\"Key\":{\"Id\":\"DummyProperty\",\"Label\":\"DummyPropertyLabel\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":5,\"ValueType\":\"System.String\"},\"Value\":\"dummyString\"}," + - "{\"Key\":{\"Id\":\"TestResult.EndTime\",\"Label\":\"End Time\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.DateTimeOffset\"},\"Value\":\"0001-01-01T00:00:00+00:00\"}]}"; - var test = Deserialize(json, version); - - this.VerifyDummyPropertyIsRegistered(); - } - - #endregion - - #region v2 serializer Tests (used with protocol 2 and 4) - - [TestMethod] - [DataRow(2)] - [DataRow(4)] - public void TestResultJsonShouldContainAllPropertiesOnSerializationV2(int version) - { - var json = Serialize(testResult, version); - - // Use raw deserialization to validate basic properties - dynamic data = JObject.Parse(json); - - Assert.AreEqual(1, data["Outcome"].Value); - Assert.AreEqual("sampleError", data["ErrorMessage"].Value); - Assert.AreEqual("sampleStackTrace", data["ErrorStackTrace"].Value); - Assert.AreEqual("sampleTestResult", data["DisplayName"].Value); - Assert.AreEqual("sampleComputerName", data["ComputerName"].Value); - Assert.AreEqual("10675199.02:48:05.4775807", data["Duration"].Value); - - // By default json.net converts DateTimes to current time zone - Assert.AreEqual(startTime.Year, ((DateTimeOffset)data["StartTime"].Value).Year); - Assert.AreEqual(DateTimeOffset.MaxValue.Year, ((DateTimeOffset)data["EndTime"].Value).Year); - } - - [TestMethod] - [DataRow(2)] - [DataRow(4)] - public void TestResultObjectShouldContainAllPropertiesOnDeserializationV2(int version) - { - var json = "{\"TestCase\":{\"Id\":\"28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b\",\"FullyQualifiedName\":\"sampleTestClass.sampleTestCase\",\"DisplayName\":\"sampleTestClass.sampleTestCase\",\"ExecutorUri\":\"executor://sampleTestExecutor\",\"Source\":\"sampleTest.dll\",\"CodeFilePath\":null,\"LineNumber\":-1,\"Properties\":[]},\"Attachments\":[],\"Outcome\":1,\"ErrorMessage\":\"sampleError\",\"ErrorStackTrace\":\"sampleStackTrace\",\"DisplayName\":\"sampleTestResult\",\"Messages\":[],\"ComputerName\":\"sampleComputerName\",\"Duration\":\"10675199.02:48:05.4775807\",\"StartTime\":\"2007-03-10T00:00:00+00:00\",\"EndTime\":\"9999-12-31T23:59:59.9999999+00:00\",\"Properties\":[]}"; - - var test = Deserialize(json, version); - - Assert.AreEqual(testResult.TestCase.Id, test.TestCase.Id); - Assert.AreEqual(testResult.Attachments.Count, test.Attachments.Count); - Assert.AreEqual(testResult.Messages.Count, test.Messages.Count); - - Assert.AreEqual(testResult.ComputerName, test.ComputerName); - Assert.AreEqual(testResult.DisplayName, test.DisplayName); - Assert.AreEqual(testResult.Duration, test.Duration); - Assert.AreEqual(testResult.EndTime, test.EndTime); - Assert.AreEqual(testResult.ErrorMessage, test.ErrorMessage); - Assert.AreEqual(testResult.ErrorStackTrace, test.ErrorStackTrace); - Assert.AreEqual(testResult.Outcome, test.Outcome); - Assert.AreEqual(testResult.StartTime, test.StartTime); - } - - [TestMethod] - [DataRow(2)] - [DataRow(4)] - public void TestResultObjectShouldSerializeAttachmentsV2(int version) - { - var result = new TestResult(testCase); - result.StartTime = default; - result.EndTime = default; - result.Attachments.Add(new AttachmentSet(new Uri("http://dummyUri"), "sampleAttachment")); - var expectedJson = "{\"TestCase\":{\"Id\":\"28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b\",\"FullyQualifiedName\":\"sampleTestClass.sampleTestCase\",\"DisplayName\":\"sampleTestClass.sampleTestCase\",\"ExecutorUri\":\"executor://sampleTestExecutor\",\"Source\":\"sampleTest.dll\",\"CodeFilePath\":null,\"LineNumber\":-1,\"Properties\":[]},\"Attachments\":[{\"Uri\":\"http://dummyUri\",\"DisplayName\":\"sampleAttachment\",\"Attachments\":[]}],\"Outcome\":0,\"ErrorMessage\":null,\"ErrorStackTrace\":null,\"DisplayName\":null,\"Messages\":[],\"ComputerName\":null,\"Duration\":\"00:00:00\",\"StartTime\":\"0001-01-01T00:00:00+00:00\",\"EndTime\":\"0001-01-01T00:00:00+00:00\",\"Properties\":[]}"; - - var json = Serialize(result, version); - - Assert.AreEqual(expectedJson, json); - } - - [TestMethod] - [DataRow(2)] - [DataRow(4)] - public void TestResultObjectShouldDeserializeAttachmentsV2(int version) - { - var json = "{\"TestCase\":{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"sampleTestClass.sampleTestCase\"},{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"executor://sampleTestExecutor\"},{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"sampleTest.dll\"},{\"Key\":{\"Id\":\"TestCase.Id\",\"Label\":\"Id\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Guid\"},\"Value\":\"28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b\"}]},\"Attachments\":[{\"Uri\":\"http://dummyUri\",\"DisplayName\":\"sampleAttachment\",\"Attachments\":[]}],\"Messages\":[],\"Properties\":[]}"; - - var result = Deserialize(json, version); - - Assert.AreEqual(1, result.Attachments.Count); - Assert.AreEqual(new Uri("http://dummyUri"), result.Attachments[0].Uri); - Assert.AreEqual("sampleAttachment", result.Attachments[0].DisplayName); - } - - [TestMethod] - [DataRow(2)] - [DataRow(4)] - public void TestResultPropertiesShouldGetRegisteredAsPartOfDeserializationV2(int version) - { - TestProperty.TryUnregister("DummyProperty", out var property); - var json = "{\"TestCase\":{\"Id\":\"28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b\",\"FullyQualifiedName\":\"sampleTestClass.sampleTestCase\",\"DisplayName\":\"sampleTestClass.sampleTestCase\",\"ExecutorUri\":\"executor://sampleTestExecutor\",\"Source\":\"sampleTest.dll\",\"CodeFilePath\":null,\"LineNumber\":-1,\"Properties\":[]},\"Attachments\":[],\"Outcome\":1,\"ErrorMessage\":\"sampleError\",\"ErrorStackTrace\":\"sampleStackTrace\",\"DisplayName\":\"sampleTestResult\",\"Messages\":[],\"ComputerName\":\"sampleComputerName\",\"Duration\":\"10675199.02:48:05.4775807\",\"StartTime\":\"2007-03-10T00:00:00+00:00\",\"EndTime\":\"9999-12-31T23:59:59.9999999+00:00\"," + - "\"Properties\":[{\"Key\":{\"Id\":\"DummyProperty\",\"Label\":\"DummyPropertyLabel\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":5,\"ValueType\":\"System.String\"},\"Value\":\"dummyString\"},]}"; - - var test = Deserialize(json, version); - - this.VerifyDummyPropertyIsRegistered(); - } - - #endregion - - #region future - - [TestMethod] - public void TestResultSerializationShouldThrowWhenProvidedProtocolVersionDoesNotExist() - { - // this is to ensure that introducing a new version is a conscious choice and - // and that we don't fallback to version 1 as it happened with version 3, because the serializer - // only checked for version 2 - var version = int.MaxValue; - - Assert.ThrowsException(() => Serialize(testResult, version)); - } - - #endregion - - private static string Serialize(T data, int version) - { - return JsonDataSerializer.Instance.Serialize(data, version); - } - - private static T Deserialize(string json, int version) - { - return JsonDataSerializer.Instance.Deserialize(json, version); - } - - private void VerifyDummyPropertyIsRegistered() - { - var dummyProperty = TestProperty.Find("DummyProperty"); - Assert.IsNotNull(dummyProperty); - Assert.AreEqual("DummyPropertyLabel", dummyProperty.Label); - Assert.AreEqual("System.String", dummyProperty.ValueType); - Assert.AreEqual(5, (int)dummyProperty.Attributes); - } + var dummyProperty = TestProperty.Find("DummyProperty"); + Assert.IsNotNull(dummyProperty); + Assert.AreEqual("DummyPropertyLabel", dummyProperty.Label); + Assert.AreEqual("System.String", dummyProperty.ValueType); + Assert.AreEqual(5, (int)dummyProperty.Attributes); } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/SocketCommunicationManagerTest.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/SocketCommunicationManagerTest.cs index 8fe31dca87..08cd9fd0d9 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/SocketCommunicationManagerTest.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/SocketCommunicationManagerTest.cs @@ -1,12 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests -{ - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests; + +using VisualStudio.TestTools.UnitTesting; - [TestClass] - public class SocketCommunicationManagerTest - { - } +[TestClass] +public class SocketCommunicationManagerTest +{ } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestDoubles/TestableDataCollectionRequestHandler.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestDoubles/TestableDataCollectionRequestHandler.cs index b613e78c21..8c3bbfef63 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestDoubles/TestableDataCollectionRequestHandler.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestDoubles/TestableDataCollectionRequestHandler.cs @@ -1,22 +1,21 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests.TestDoubles -{ - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests.TestDoubles; + +using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - /// - /// Testable class for DataCollectionRequestHandler since all constructors of DataCollectionRequestHandler are protected. - /// - internal class TestableDataCollectionRequestHandler : DataCollectionRequestHandler +/// +/// Testable class for DataCollectionRequestHandler since all constructors of DataCollectionRequestHandler are protected. +/// +internal class TestableDataCollectionRequestHandler : DataCollectionRequestHandler +{ + public TestableDataCollectionRequestHandler(ICommunicationManager communicationManager, IMessageSink messageSink, IDataCollectionManager dataCollectionManager, IDataCollectionTestCaseEventHandler dataCollectionTestCaseEventHandler, IDataSerializer dataSerializer, IFileHelper fIleHelper, IRequestData requestData) + : base(communicationManager, messageSink, dataCollectionManager, dataCollectionTestCaseEventHandler, dataSerializer, fIleHelper, requestData) { - public TestableDataCollectionRequestHandler(ICommunicationManager communicationManager, IMessageSink messageSink, IDataCollectionManager dataCollectionManager, IDataCollectionTestCaseEventHandler dataCollectionTestCaseEventHandler, IDataSerializer dataSerializer, IFileHelper fIleHelper, IRequestData requestData) - : base(communicationManager, messageSink, dataCollectionManager, dataCollectionTestCaseEventHandler, dataSerializer, fIleHelper, requestData) - { - } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestDoubles/TestableDataCollectionTestCaseEventSender.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestDoubles/TestableDataCollectionTestCaseEventSender.cs index ce8b0cc4c8..9ebfff8842 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestDoubles/TestableDataCollectionTestCaseEventSender.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestDoubles/TestableDataCollectionTestCaseEventSender.cs @@ -1,16 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests.TestDoubles -{ - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests.TestDoubles; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - internal class TestableDataCollectionTestCaseEventSender : DataCollectionTestCaseEventSender +internal class TestableDataCollectionTestCaseEventSender : DataCollectionTestCaseEventSender +{ + public TestableDataCollectionTestCaseEventSender(ICommunicationManager communicationManager, IDataSerializer dataSerializer) + : base(communicationManager, dataSerializer) { - public TestableDataCollectionTestCaseEventSender(ICommunicationManager communicationManager, IDataSerializer dataSerializer) - : base(communicationManager, dataSerializer) - { - } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestDoubles/TestableTestObject.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestDoubles/TestableTestObject.cs index 2127043154..653d5a3201 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestDoubles/TestableTestObject.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestDoubles/TestableTestObject.cs @@ -1,14 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests.TestDoubles -{ - using System.Runtime.Serialization; +namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests.TestDoubles; + +using System.Runtime.Serialization; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; - [DataContract] - internal class TestableTestObject : TestObject - { - } +[DataContract] +internal class TestableTestObject : TestObject +{ } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestRequestSenderTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestRequestSenderTests.cs index 5ddb461f90..6e69bde720 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestRequestSenderTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestRequestSenderTests.cs @@ -1,880 +1,878 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests +namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Threading; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using VisualStudio.TestTools.UnitTesting; +using Moq; +using VisualStudio.TestPlatform.CoreUtilities.Helpers; + +[TestClass] +public class TestRequestSenderTests { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Sockets; - using System.Threading; - - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using VisualStudio.TestPlatform.CoreUtilities.Helpers; - using CommunicationUtilitiesResources = Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources.Resources; - - [TestClass] - public class TestRequestSenderTests - { - private const int DUMMYPROTOCOLVERSION = 42; - private const int DEFAULTPROTOCOLVERSION = 1; - private const int DUMMYNEGOTIATEDPROTOCOLVERSION = 41; - private static readonly string TimoutErrorMessage = "Failed to negotiate protocol, waiting for response timed out after 0 seconds. This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout."; - - private readonly Mock mockServer; - private readonly Mock mockDataSerializer; - private readonly Mock mockChannel; - - private readonly List pathToAdditionalExtensions = new List { "Hello", "World" }; - private readonly Mock mockDiscoveryEventsHandler; - private readonly Mock mockExecutionEventsHandler; - private readonly TestRunCriteriaWithSources testRunCriteriaWithSources; - private TestHostConnectionInfo connectionInfo; - private ITestRequestSender testRequestSender; - private ConnectedEventArgs connectedEventArgs; - - public TestRequestSenderTests() - { - this.connectionInfo = new TestHostConnectionInfo - { - Endpoint = IPAddress.Loopback + ":123", - Role = ConnectionRole.Client, - Transport = Transport.Sockets - }; - this.mockChannel = new Mock(); - this.mockServer = new Mock(); - this.mockDataSerializer = new Mock(); - this.testRequestSender = new TestableTestRequestSender(this.mockServer.Object, this.connectionInfo, this.mockDataSerializer.Object, new ProtocolConfig { Version = DUMMYPROTOCOLVERSION }); - - this.connectedEventArgs = new ConnectedEventArgs(this.mockChannel.Object); - this.mockDiscoveryEventsHandler = new Mock(); - this.mockExecutionEventsHandler = new Mock(); - this.testRunCriteriaWithSources = new TestRunCriteriaWithSources(new Dictionary>(), "runsettings", null, null); - } + private const int Dummyprotocolversion = 42; + private const int Defaultprotocolversion = 1; + private const int Dummynegotiatedprotocolversion = 41; + private static readonly string TimoutErrorMessage = "Failed to negotiate protocol, waiting for response timed out after 0 seconds. This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout."; + + private readonly Mock _mockServer; + private readonly Mock _mockDataSerializer; + private readonly Mock _mockChannel; + + private readonly List _pathToAdditionalExtensions = new() { "Hello", "World" }; + private readonly Mock _mockDiscoveryEventsHandler; + private readonly Mock _mockExecutionEventsHandler; + private readonly TestRunCriteriaWithSources _testRunCriteriaWithSources; + private TestHostConnectionInfo _connectionInfo; + private readonly ITestRequestSender _testRequestSender; + private ConnectedEventArgs _connectedEventArgs; + + public TestRequestSenderTests() + { + _connectionInfo = new TestHostConnectionInfo + { + Endpoint = IPAddress.Loopback + ":123", + Role = ConnectionRole.Client, + Transport = Transport.Sockets + }; + _mockChannel = new Mock(); + _mockServer = new Mock(); + _mockDataSerializer = new Mock(); + _testRequestSender = new TestableTestRequestSender(_mockServer.Object, _connectionInfo, _mockDataSerializer.Object, new ProtocolConfig { Version = Dummyprotocolversion }); + + _connectedEventArgs = new ConnectedEventArgs(_mockChannel.Object); + _mockDiscoveryEventsHandler = new Mock(); + _mockExecutionEventsHandler = new Mock(); + _testRunCriteriaWithSources = new TestRunCriteriaWithSources(new Dictionary>(), "runsettings", null, null); + } - [TestCleanup] - public void Cleanup() - { - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, string.Empty); - } + [TestCleanup] + public void Cleanup() + { + Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, string.Empty); + } - [TestMethod] - public void InitializeCommunicationShouldHostServerAndAcceptClient() - { - var port = this.SetupFakeCommunicationChannel(); + [TestMethod] + public void InitializeCommunicationShouldHostServerAndAcceptClient() + { + var port = SetupFakeCommunicationChannel(); - Assert.AreEqual("123", port, "Correct port must be returned."); - } + Assert.AreEqual("123", port, "Correct port must be returned."); + } - [TestMethod] - public void WaitForRequestHandlerConnectionShouldWaitForClientToConnect() - { - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void WaitForRequestHandlerConnectionShouldWaitForClientToConnect() + { + SetupFakeCommunicationChannel(); - var connected = this.testRequestSender.WaitForRequestHandlerConnection(1, It.IsAny()); + var connected = _testRequestSender.WaitForRequestHandlerConnection(1, It.IsAny()); - Assert.IsTrue(connected); - } + Assert.IsTrue(connected); + } - [TestMethod] - public void WaitForRequestHandlerConnectionShouldNotConnectIfExceptionWasThrownByTcpLayer() - { - this.connectedEventArgs = new ConnectedEventArgs(new SocketException()); - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void WaitForRequestHandlerConnectionShouldNotConnectIfExceptionWasThrownByTcpLayer() + { + _connectedEventArgs = new ConnectedEventArgs(new SocketException()); + SetupFakeCommunicationChannel(); - var connected = this.testRequestSender.WaitForRequestHandlerConnection(1, It.IsAny()); + var connected = _testRequestSender.WaitForRequestHandlerConnection(1, It.IsAny()); - Assert.IsFalse(connected); - } + Assert.IsFalse(connected); + } - [TestMethod] - public void WaitForRequestHandlerConnectionWithTimeoutShouldReturnImmediatelyWhenCancellationRequested() - { - var cancellationTokenSource = new CancellationTokenSource(); - cancellationTokenSource.Cancel(); + [TestMethod] + public void WaitForRequestHandlerConnectionWithTimeoutShouldReturnImmediatelyWhenCancellationRequested() + { + var cancellationTokenSource = new CancellationTokenSource(); + cancellationTokenSource.Cancel(); - var connectionTimeout = 5000; - var watch = System.Diagnostics.Stopwatch.StartNew(); - var connected = this.testRequestSender.WaitForRequestHandlerConnection(connectionTimeout, cancellationTokenSource.Token); - watch.Stop(); + var connectionTimeout = 5000; + var watch = System.Diagnostics.Stopwatch.StartNew(); + var connected = _testRequestSender.WaitForRequestHandlerConnection(connectionTimeout, cancellationTokenSource.Token); + watch.Stop(); - Assert.IsFalse(connected); - Assert.IsTrue(watch.ElapsedMilliseconds < connectionTimeout); - } + Assert.IsFalse(connected); + Assert.IsTrue(watch.ElapsedMilliseconds < connectionTimeout); + } - [TestMethod] - public void WaitForRequestHandlerConnectionWithTimeoutShouldReturnImmediatelyIfHostExitedUnexpectedly() - { - var cancellationTokenSource = new CancellationTokenSource(); - this.testRequestSender.OnClientProcessExit("DummyError"); + [TestMethod] + public void WaitForRequestHandlerConnectionWithTimeoutShouldReturnImmediatelyIfHostExitedUnexpectedly() + { + var cancellationTokenSource = new CancellationTokenSource(); + _testRequestSender.OnClientProcessExit("DummyError"); - var connectionTimeout = 5000; - var watch = System.Diagnostics.Stopwatch.StartNew(); - var connected = this.testRequestSender.WaitForRequestHandlerConnection(connectionTimeout, cancellationTokenSource.Token); - watch.Stop(); + var connectionTimeout = 5000; + var watch = System.Diagnostics.Stopwatch.StartNew(); + var connected = _testRequestSender.WaitForRequestHandlerConnection(connectionTimeout, cancellationTokenSource.Token); + watch.Stop(); - Assert.IsFalse(connected); - Assert.IsTrue(watch.ElapsedMilliseconds < connectionTimeout); - } + Assert.IsFalse(connected); + Assert.IsTrue(watch.ElapsedMilliseconds < connectionTimeout); + } - [TestMethod] - public void CloseShouldCallStopServerOnCommunicationManager() - { - this.testRequestSender.Close(); + [TestMethod] + public void CloseShouldCallStopServerOnCommunicationManager() + { + _testRequestSender.Close(); - this.mockServer.Verify(mc => mc.Stop(), Times.Once); - } + _mockServer.Verify(mc => mc.Stop(), Times.Once); + } - [TestMethod] - public void DisposeShouldCallStopServerOnCommunicationManager() - { - this.testRequestSender.Dispose(); + [TestMethod] + public void DisposeShouldCallStopServerOnCommunicationManager() + { + _testRequestSender.Dispose(); - this.mockServer.Verify(mc => mc.Stop(), Times.Once); - } + _mockServer.Verify(mc => mc.Stop(), Times.Once); + } - [TestMethod] - public void EndSessionShouldSendSessionEndMessage() - { - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void EndSessionShouldSendSessionEndMessage() + { + SetupFakeCommunicationChannel(); - this.testRequestSender.EndSession(); + _testRequestSender.EndSession(); - this.mockDataSerializer.Verify(ds => ds.SerializeMessage(MessageType.SessionEnd), Times.Once); - this.mockChannel.Verify(c => c.Send(It.IsAny()), Times.Once); - } + _mockDataSerializer.Verify(ds => ds.SerializeMessage(MessageType.SessionEnd), Times.Once); + _mockChannel.Verify(c => c.Send(It.IsAny()), Times.Once); + } - [TestMethod] - public void EndSessionShouldNotSendSessionEndMessageIfClientDisconnected() - { - this.SetupFakeCommunicationChannel(); - this.testRequestSender.DiscoverTests(new DiscoveryCriteria(), this.mockDiscoveryEventsHandler.Object); - this.RaiseClientDisconnectedEvent(); + [TestMethod] + public void EndSessionShouldNotSendSessionEndMessageIfClientDisconnected() + { + SetupFakeCommunicationChannel(); + _testRequestSender.DiscoverTests(new DiscoveryCriteria(), _mockDiscoveryEventsHandler.Object); + RaiseClientDisconnectedEvent(); - this.testRequestSender.EndSession(); + _testRequestSender.EndSession(); - this.mockDataSerializer.Verify(ds => ds.SerializeMessage(MessageType.SessionEnd), Times.Never); - } + _mockDataSerializer.Verify(ds => ds.SerializeMessage(MessageType.SessionEnd), Times.Never); + } - [TestMethod] - public void EndSessionShouldNotSendSessionEndMessageIfTestHostProcessExited() - { - this.SetupFakeCommunicationChannel(); - this.testRequestSender.StartTestRun(this.testRunCriteriaWithSources, this.mockExecutionEventsHandler.Object); - this.testRequestSender.OnClientProcessExit("Dummy Message"); + [TestMethod] + public void EndSessionShouldNotSendSessionEndMessageIfTestHostProcessExited() + { + SetupFakeCommunicationChannel(); + _testRequestSender.StartTestRun(_testRunCriteriaWithSources, _mockExecutionEventsHandler.Object); + _testRequestSender.OnClientProcessExit("Dummy Message"); - this.testRequestSender.EndSession(); + _testRequestSender.EndSession(); - this.mockDataSerializer.Verify(ds => ds.SerializeMessage(MessageType.SessionEnd), Times.Once); - } + _mockDataSerializer.Verify(ds => ds.SerializeMessage(MessageType.SessionEnd), Times.Once); + } - [TestMethod] - public void EndSessionShouldNotSendTestRunCancelMessageIfClientDisconnected() - { - this.SetupFakeCommunicationChannel(); - this.testRequestSender.DiscoverTests(new DiscoveryCriteria(), this.mockDiscoveryEventsHandler.Object); - this.RaiseClientDisconnectedEvent(); + [TestMethod] + public void EndSessionShouldNotSendTestRunCancelMessageIfClientDisconnected() + { + SetupFakeCommunicationChannel(); + _testRequestSender.DiscoverTests(new DiscoveryCriteria(), _mockDiscoveryEventsHandler.Object); + RaiseClientDisconnectedEvent(); - this.testRequestSender.SendTestRunCancel(); + _testRequestSender.SendTestRunCancel(); - this.mockChannel.Verify(mockChannel => mockChannel.Send(MessageType.CancelTestRun), Times.Never); - } + _mockChannel.Verify(mockChannel => mockChannel.Send(MessageType.CancelTestRun), Times.Never); + } - [TestMethod] - public void EndSessionShouldNotSendTestRunAbortMessageIfClientDisconnected() - { - this.SetupFakeCommunicationChannel(); - this.testRequestSender.DiscoverTests(new DiscoveryCriteria(), this.mockDiscoveryEventsHandler.Object); - this.RaiseClientDisconnectedEvent(); + [TestMethod] + public void EndSessionShouldNotSendTestRunAbortMessageIfClientDisconnected() + { + SetupFakeCommunicationChannel(); + _testRequestSender.DiscoverTests(new DiscoveryCriteria(), _mockDiscoveryEventsHandler.Object); + RaiseClientDisconnectedEvent(); - this.testRequestSender.SendTestRunAbort(); + _testRequestSender.SendTestRunAbort(); - this.mockChannel.Verify(mockChannel => mockChannel.Send(MessageType.CancelTestRun), Times.Never); - } + _mockChannel.Verify(mockChannel => mockChannel.Send(MessageType.CancelTestRun), Times.Never); + } - [DataTestMethod] - [DataRow("")] - [DataRow(" ")] - [DataRow(null)] - public void OnClientProcessExitShouldSendErrorMessageIfStdErrIsEmpty(string stderr) - { - this.SetupFakeCommunicationChannel(); - this.testRequestSender.DiscoverTests(new DiscoveryCriteria(), this.mockDiscoveryEventsHandler.Object); + [DataTestMethod] + [DataRow("")] + [DataRow(" ")] + [DataRow(null)] + public void OnClientProcessExitShouldSendErrorMessageIfStdErrIsEmpty(string stderr) + { + SetupFakeCommunicationChannel(); + _testRequestSender.DiscoverTests(new DiscoveryCriteria(), _mockDiscoveryEventsHandler.Object); - this.testRequestSender.OnClientProcessExit(stderr); + _testRequestSender.OnClientProcessExit(stderr); - var expectedErrorMessage = "Reason: Test host process crashed"; - this.RaiseClientDisconnectedEvent(); - this.mockDiscoveryEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.Is(s => s.EndsWith(expectedErrorMessage))), Times.Once); - } + var expectedErrorMessage = "Reason: Test host process crashed"; + RaiseClientDisconnectedEvent(); + _mockDiscoveryEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.Is(s => s.EndsWith(expectedErrorMessage))), Times.Once); + } - [TestMethod] - public void OnClientProcessExitShouldNotSendErrorMessageIfOperationNotStarted() - { - this.SetupFakeCommunicationChannel(); - this.testRequestSender.OnClientProcessExit("Dummy Stderr"); + [TestMethod] + public void OnClientProcessExitShouldNotSendErrorMessageIfOperationNotStarted() + { + SetupFakeCommunicationChannel(); + _testRequestSender.OnClientProcessExit("Dummy Stderr"); - this.RaiseClientDisconnectedEvent(); - this.mockDiscoveryEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.Is(s => s.Contains("Dummy Stderr"))), Times.Never); - } + RaiseClientDisconnectedEvent(); + _mockDiscoveryEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.Is(s => s.Contains("Dummy Stderr"))), Times.Never); + } - [TestMethod] - public void OnClientProcessExitShouldNotSendRawMessageIfOperationNotStarted() - { - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void OnClientProcessExitShouldNotSendRawMessageIfOperationNotStarted() + { + SetupFakeCommunicationChannel(); - this.testRequestSender.OnClientProcessExit("Dummy Stderr"); + _testRequestSender.OnClientProcessExit("Dummy Stderr"); - this.RaiseClientDisconnectedEvent(); - this.mockDataSerializer.Verify(ds => ds.SerializePayload(MessageType.TestMessage, It.Is(p => p.Message.Contains("Dummy Stderr"))), Times.Never); - this.mockExecutionEventsHandler.Verify(eh => eh.HandleRawMessage(It.IsAny()), Times.Never); - } + RaiseClientDisconnectedEvent(); + _mockDataSerializer.Verify(ds => ds.SerializePayload(MessageType.TestMessage, It.Is(p => p.Message.Contains("Dummy Stderr"))), Times.Never); + _mockExecutionEventsHandler.Verify(eh => eh.HandleRawMessage(It.IsAny()), Times.Never); + } - #region Version Check Tests + #region Version Check Tests - [TestMethod] - public void CheckVersionWithTestHostShouldSendHighestSupportedVersion() - { - this.SetupDeserializeMessage(MessageType.VersionCheck, 99); - this.SetupRaiseMessageReceivedOnCheckVersion(); - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void CheckVersionWithTestHostShouldSendHighestSupportedVersion() + { + SetupDeserializeMessage(MessageType.VersionCheck, 99); + SetupRaiseMessageReceivedOnCheckVersion(); + SetupFakeCommunicationChannel(); - this.testRequestSender.CheckVersionWithTestHost(); + _testRequestSender.CheckVersionWithTestHost(); - this.mockDataSerializer.Verify(ds => ds.SerializePayload(MessageType.VersionCheck, DUMMYPROTOCOLVERSION), Times.Once); - this.mockChannel.Verify(mc => mc.Send(It.IsAny()), Times.Once); - } + _mockDataSerializer.Verify(ds => ds.SerializePayload(MessageType.VersionCheck, Dummyprotocolversion), Times.Once); + _mockChannel.Verify(mc => mc.Send(It.IsAny()), Times.Once); + } - [TestMethod] - public void CheckVersionWithTestHostShouldThrowIfTestHostVersionDoesNotMatch() - { - this.SetupDeserializeMessage(MessageType.ProtocolError, string.Empty); - this.SetupRaiseMessageReceivedOnCheckVersion(); - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void CheckVersionWithTestHostShouldThrowIfTestHostVersionDoesNotMatch() + { + SetupDeserializeMessage(MessageType.ProtocolError, string.Empty); + SetupRaiseMessageReceivedOnCheckVersion(); + SetupFakeCommunicationChannel(); - Assert.ThrowsException(() => this.testRequestSender.CheckVersionWithTestHost()); - } + Assert.ThrowsException(() => _testRequestSender.CheckVersionWithTestHost()); + } - [TestMethod] - public void CheckVersionWithTestHostShouldThrowIfUnexpectedResponseIsReceived() - { - this.SetupDeserializeMessage(MessageType.TestCasesFound, string.Empty); - this.SetupRaiseMessageReceivedOnCheckVersion(); - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void CheckVersionWithTestHostShouldThrowIfUnexpectedResponseIsReceived() + { + SetupDeserializeMessage(MessageType.TestCasesFound, string.Empty); + SetupRaiseMessageReceivedOnCheckVersion(); + SetupFakeCommunicationChannel(); - Assert.ThrowsException(() => this.testRequestSender.CheckVersionWithTestHost()); - } + Assert.ThrowsException(() => _testRequestSender.CheckVersionWithTestHost()); + } - [TestMethod] - public void CheckVersionWithTestHostShouldThrowIfProtocolNegotiationTimeouts() - { - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, "0"); + [TestMethod] + public void CheckVersionWithTestHostShouldThrowIfProtocolNegotiationTimeouts() + { + Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, "0"); - this.SetupFakeCommunicationChannel(); + SetupFakeCommunicationChannel(); - var message = Assert.ThrowsException(() => this.testRequestSender.CheckVersionWithTestHost()).Message; + var message = Assert.ThrowsException(() => _testRequestSender.CheckVersionWithTestHost()).Message; - Assert.AreEqual(message, TestRequestSenderTests.TimoutErrorMessage); - } + Assert.AreEqual(message, TimoutErrorMessage); + } - #endregion + #endregion - #region Discovery Protocol Tests - [TestMethod] - public void InitializeDiscoveryShouldSendCommunicationMessageWithCorrectParameters() - { - this.SetupFakeCommunicationChannel(); + #region Discovery Protocol Tests + [TestMethod] + public void InitializeDiscoveryShouldSendCommunicationMessageWithCorrectParameters() + { + SetupFakeCommunicationChannel(); - this.testRequestSender.InitializeDiscovery(this.pathToAdditionalExtensions); + _testRequestSender.InitializeDiscovery(_pathToAdditionalExtensions); - this.mockDataSerializer.Verify(d => d.SerializePayload(MessageType.DiscoveryInitialize, this.pathToAdditionalExtensions, 1), Times.Once); - this.mockChannel.Verify(mc => mc.Send(It.IsAny()), Times.Once); - } + _mockDataSerializer.Verify(d => d.SerializePayload(MessageType.DiscoveryInitialize, _pathToAdditionalExtensions, 1), Times.Once); + _mockChannel.Verify(mc => mc.Send(It.IsAny()), Times.Once); + } - [TestMethod] - public void InitializeDiscoveryShouldSendCommunicationMessageWithCorrectParametersWithVersion() - { - this.SetupFakeChannelWithVersionNegotiation(DUMMYNEGOTIATEDPROTOCOLVERSION); + [TestMethod] + public void InitializeDiscoveryShouldSendCommunicationMessageWithCorrectParametersWithVersion() + { + SetupFakeChannelWithVersionNegotiation(Dummynegotiatedprotocolversion); - this.testRequestSender.InitializeDiscovery(this.pathToAdditionalExtensions); + _testRequestSender.InitializeDiscovery(_pathToAdditionalExtensions); - this.mockDataSerializer.Verify(d => d.SerializePayload(MessageType.DiscoveryInitialize, this.pathToAdditionalExtensions, DUMMYNEGOTIATEDPROTOCOLVERSION), Times.Once); - } + _mockDataSerializer.Verify(d => d.SerializePayload(MessageType.DiscoveryInitialize, _pathToAdditionalExtensions, Dummynegotiatedprotocolversion), Times.Once); + } - [TestMethod] - public void DiscoverTestsShouldSendStartDiscoveryMessageOnChannel() - { - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void DiscoverTestsShouldSendStartDiscoveryMessageOnChannel() + { + SetupFakeCommunicationChannel(); - this.testRequestSender.DiscoverTests(new DiscoveryCriteria(), this.mockDiscoveryEventsHandler.Object); + _testRequestSender.DiscoverTests(new DiscoveryCriteria(), _mockDiscoveryEventsHandler.Object); - this.mockDataSerializer.Verify( - s => s.SerializePayload(MessageType.StartDiscovery, It.IsAny(), DEFAULTPROTOCOLVERSION), - Times.Once); - this.mockChannel.Verify(mc => mc.Send(It.IsAny()), Times.Once); - } + _mockDataSerializer.Verify( + s => s.SerializePayload(MessageType.StartDiscovery, It.IsAny(), Defaultprotocolversion), + Times.Once); + _mockChannel.Verify(mc => mc.Send(It.IsAny()), Times.Once); + } - [TestMethod] - public void DiscoverTestsShouldSendStartDiscoveryMessageOnChannelWithVersion() - { - this.SetupFakeChannelWithVersionNegotiation(DUMMYNEGOTIATEDPROTOCOLVERSION); + [TestMethod] + public void DiscoverTestsShouldSendStartDiscoveryMessageOnChannelWithVersion() + { + SetupFakeChannelWithVersionNegotiation(Dummynegotiatedprotocolversion); - this.testRequestSender.DiscoverTests(new DiscoveryCriteria(), this.mockDiscoveryEventsHandler.Object); + _testRequestSender.DiscoverTests(new DiscoveryCriteria(), _mockDiscoveryEventsHandler.Object); - this.mockDataSerializer.Verify( - s => s.SerializePayload(MessageType.StartDiscovery, It.IsAny(), DUMMYNEGOTIATEDPROTOCOLVERSION), - Times.Once); - } + _mockDataSerializer.Verify( + s => s.SerializePayload(MessageType.StartDiscovery, It.IsAny(), Dummynegotiatedprotocolversion), + Times.Once); + } - [TestMethod] - public void DiscoverTestsShouldNotifyRawMessageOnMessageReceived() - { - this.SetupDeserializeMessage(MessageType.TestMessage, new TestMessagePayload()); - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void DiscoverTestsShouldNotifyRawMessageOnMessageReceived() + { + SetupDeserializeMessage(MessageType.TestMessage, new TestMessagePayload()); + SetupFakeCommunicationChannel(); - this.testRequestSender.DiscoverTests(new DiscoveryCriteria(), this.mockDiscoveryEventsHandler.Object); + _testRequestSender.DiscoverTests(new DiscoveryCriteria(), _mockDiscoveryEventsHandler.Object); - this.RaiseMessageReceivedEvent(); - this.mockDiscoveryEventsHandler.Verify(eh => eh.HandleRawMessage("DummyData"), Times.Once); - } + RaiseMessageReceivedEvent(); + _mockDiscoveryEventsHandler.Verify(eh => eh.HandleRawMessage("DummyData"), Times.Once); + } - [TestMethod] - public void DiscoverTestsShouldNotifyDiscoveredTestsOnTestCasesFoundMessageReceived() - { - this.SetupDeserializeMessage>(MessageType.TestCasesFound, new TestCase[2]); - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void DiscoverTestsShouldNotifyDiscoveredTestsOnTestCasesFoundMessageReceived() + { + SetupDeserializeMessage>(MessageType.TestCasesFound, new TestCase[2]); + SetupFakeCommunicationChannel(); - this.testRequestSender.DiscoverTests(new DiscoveryCriteria(), this.mockDiscoveryEventsHandler.Object); + _testRequestSender.DiscoverTests(new DiscoveryCriteria(), _mockDiscoveryEventsHandler.Object); - this.RaiseMessageReceivedEvent(); - this.mockDiscoveryEventsHandler.Verify(eh => eh.HandleDiscoveredTests(It.Is>(t => t.Count() == 2))); - } + RaiseMessageReceivedEvent(); + _mockDiscoveryEventsHandler.Verify(eh => eh.HandleDiscoveredTests(It.Is>(t => t.Count() == 2))); + } - [TestMethod] - public void DiscoverTestsShouldNotifyDiscoveryCompleteOnCompleteMessageReceived() - { - var completePayload = new DiscoveryCompletePayload { TotalTests = 10, IsAborted = false }; - this.SetupDeserializeMessage(MessageType.DiscoveryComplete, completePayload); - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void DiscoverTestsShouldNotifyDiscoveryCompleteOnCompleteMessageReceived() + { + var completePayload = new DiscoveryCompletePayload { TotalTests = 10, IsAborted = false }; + SetupDeserializeMessage(MessageType.DiscoveryComplete, completePayload); + SetupFakeCommunicationChannel(); - this.testRequestSender.DiscoverTests(new DiscoveryCriteria(), this.mockDiscoveryEventsHandler.Object); + _testRequestSender.DiscoverTests(new DiscoveryCriteria(), _mockDiscoveryEventsHandler.Object); - this.RaiseMessageReceivedEvent(); - this.mockDiscoveryEventsHandler.Verify(eh => eh.HandleDiscoveryComplete(It.Is(dc => dc.IsAborted == false && dc.TotalCount == 10), null)); - } + RaiseMessageReceivedEvent(); + _mockDiscoveryEventsHandler.Verify(eh => eh.HandleDiscoveryComplete(It.Is(dc => dc.IsAborted == false && dc.TotalCount == 10), null)); + } - [TestMethod] - public void DiscoverTestsShouldStopServerOnCompleteMessageReceived() - { - var completePayload = new DiscoveryCompletePayload { TotalTests = 10, IsAborted = false }; - this.SetupDeserializeMessage(MessageType.DiscoveryComplete, completePayload); - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void DiscoverTestsShouldStopServerOnCompleteMessageReceived() + { + var completePayload = new DiscoveryCompletePayload { TotalTests = 10, IsAborted = false }; + SetupDeserializeMessage(MessageType.DiscoveryComplete, completePayload); + SetupFakeCommunicationChannel(); - this.testRequestSender.DiscoverTests(new DiscoveryCriteria(), this.mockDiscoveryEventsHandler.Object); + _testRequestSender.DiscoverTests(new DiscoveryCriteria(), _mockDiscoveryEventsHandler.Object); - this.RaiseMessageReceivedEvent(); + RaiseMessageReceivedEvent(); - this.mockServer.Verify(ms => ms.Stop()); - } + _mockServer.Verify(ms => ms.Stop()); + } - [TestMethod] - public void DiscoverTestShouldNotifyLogMessageOnTestMessageReceived() - { - var message = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = "Message1" }; - this.SetupDeserializeMessage(MessageType.TestMessage, message); - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void DiscoverTestShouldNotifyLogMessageOnTestMessageReceived() + { + var message = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = "Message1" }; + SetupDeserializeMessage(MessageType.TestMessage, message); + SetupFakeCommunicationChannel(); - this.testRequestSender.DiscoverTests(new DiscoveryCriteria(), this.mockDiscoveryEventsHandler.Object); + _testRequestSender.DiscoverTests(new DiscoveryCriteria(), _mockDiscoveryEventsHandler.Object); - this.RaiseMessageReceivedEvent(); - this.mockDiscoveryEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, "Message1")); - } + RaiseMessageReceivedEvent(); + _mockDiscoveryEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, "Message1")); + } - [TestMethod] - public void DiscoverTestShouldNotifyLogMessageIfExceptionThrownOnMessageReceived() - { - this.SetupExceptionOnMessageReceived(); - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void DiscoverTestShouldNotifyLogMessageIfExceptionThrownOnMessageReceived() + { + SetupExceptionOnMessageReceived(); + SetupFakeCommunicationChannel(); - this.testRequestSender.DiscoverTests(new DiscoveryCriteria(), this.mockDiscoveryEventsHandler.Object); + _testRequestSender.DiscoverTests(new DiscoveryCriteria(), _mockDiscoveryEventsHandler.Object); - this.RaiseMessageReceivedEvent(); - this.mockDiscoveryEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.Is(s => s.Contains("Dummy Message")))); - this.mockDiscoveryEventsHandler.Verify(eh => eh.HandleRawMessage("SerializedMessage"), Times.Once); - } + RaiseMessageReceivedEvent(); + _mockDiscoveryEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.Is(s => s.Contains("Dummy Message")))); + _mockDiscoveryEventsHandler.Verify(eh => eh.HandleRawMessage("SerializedMessage"), Times.Once); + } - [TestMethod] - public void DiscoverTestShouldNotifyDiscoveryCompleteIfExceptionThrownOnMessageReceived() - { - this.SetupExceptionOnMessageReceived(); - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void DiscoverTestShouldNotifyDiscoveryCompleteIfExceptionThrownOnMessageReceived() + { + SetupExceptionOnMessageReceived(); + SetupFakeCommunicationChannel(); - this.testRequestSender.DiscoverTests(new DiscoveryCriteria(), this.mockDiscoveryEventsHandler.Object); + _testRequestSender.DiscoverTests(new DiscoveryCriteria(), _mockDiscoveryEventsHandler.Object); - this.RaiseMessageReceivedEvent(); - this.mockDiscoveryEventsHandler.Verify(eh => eh.HandleDiscoveryComplete(It.Is(dc => dc.IsAborted == true && dc.TotalCount == -1), null)); - } + RaiseMessageReceivedEvent(); + _mockDiscoveryEventsHandler.Verify(eh => eh.HandleDiscoveryComplete(It.Is(dc => dc.IsAborted == true && dc.TotalCount == -1), null)); + } - [TestMethod] - public void DiscoverTestsShouldNotAbortDiscoveryIfClientDisconnectedAndOperationIsComplete() - { - var completePayload = new DiscoveryCompletePayload { TotalTests = 10, IsAborted = false }; - this.SetupDeserializeMessage(MessageType.DiscoveryComplete, completePayload); - this.SetupFakeCommunicationChannel(); - this.testRequestSender.DiscoverTests(new DiscoveryCriteria(), this.mockDiscoveryEventsHandler.Object); - this.RaiseMessageReceivedEvent(); // Raise discovery complete + [TestMethod] + public void DiscoverTestsShouldNotAbortDiscoveryIfClientDisconnectedAndOperationIsComplete() + { + var completePayload = new DiscoveryCompletePayload { TotalTests = 10, IsAborted = false }; + SetupDeserializeMessage(MessageType.DiscoveryComplete, completePayload); + SetupFakeCommunicationChannel(); + _testRequestSender.DiscoverTests(new DiscoveryCriteria(), _mockDiscoveryEventsHandler.Object); + RaiseMessageReceivedEvent(); // Raise discovery complete - this.RaiseClientDisconnectedEvent(); + RaiseClientDisconnectedEvent(); - this.mockDiscoveryEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Never); - this.mockDiscoveryEventsHandler.Verify(eh => eh.HandleDiscoveryComplete(new DiscoveryCompleteEventArgs(-1, true), null), Times.Never); - } + _mockDiscoveryEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Never); + _mockDiscoveryEventsHandler.Verify(eh => eh.HandleDiscoveryComplete(new DiscoveryCompleteEventArgs(-1, true), null), Times.Never); + } - [TestMethod] - public void DiscoverTestShouldNotifyLogMessageIfClientDisconnected() - { - // Expect default error message since we've not set any client exit message - var expectedErrorMessage = "Reason: Unable to communicate"; - this.SetupFakeCommunicationChannel(); - this.mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.TestMessage, It.Is(p => p.Message.Contains(expectedErrorMessage)))) - .Returns("Serialized error"); - this.testRequestSender.DiscoverTests(new DiscoveryCriteria(), this.mockDiscoveryEventsHandler.Object); + [TestMethod] + public void DiscoverTestShouldNotifyLogMessageIfClientDisconnected() + { + // Expect default error message since we've not set any client exit message + var expectedErrorMessage = "Reason: Unable to communicate"; + SetupFakeCommunicationChannel(); + _mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.TestMessage, It.Is(p => p.Message.Contains(expectedErrorMessage)))) + .Returns("Serialized error"); + _testRequestSender.DiscoverTests(new DiscoveryCriteria(), _mockDiscoveryEventsHandler.Object); - this.RaiseClientDisconnectedEvent(); + RaiseClientDisconnectedEvent(); - this.mockDiscoveryEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.Is(s => s.Contains(expectedErrorMessage)))); - this.mockDiscoveryEventsHandler.Verify(eh => eh.HandleRawMessage(It.Is(s => !string.IsNullOrEmpty(s) && s.Equals("Serialized error"))), Times.Once); - } + _mockDiscoveryEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.Is(s => s.Contains(expectedErrorMessage)))); + _mockDiscoveryEventsHandler.Verify(eh => eh.HandleRawMessage(It.Is(s => !string.IsNullOrEmpty(s) && s.Equals("Serialized error"))), Times.Once); + } - [TestMethod] - public void DiscoverTestShouldNotifyLogMessageIfClientDisconnectedWithClientExit() - { - this.SetupFakeCommunicationChannel(); - this.mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.TestMessage, It.Is(p => p.Message.Contains("Dummy Stderr")))) - .Returns("Serialized Stderr"); - this.testRequestSender.DiscoverTests(new DiscoveryCriteria(), this.mockDiscoveryEventsHandler.Object); - this.testRequestSender.OnClientProcessExit("Dummy Stderr"); + [TestMethod] + public void DiscoverTestShouldNotifyLogMessageIfClientDisconnectedWithClientExit() + { + SetupFakeCommunicationChannel(); + _mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.TestMessage, It.Is(p => p.Message.Contains("Dummy Stderr")))) + .Returns("Serialized Stderr"); + _testRequestSender.DiscoverTests(new DiscoveryCriteria(), _mockDiscoveryEventsHandler.Object); + _testRequestSender.OnClientProcessExit("Dummy Stderr"); - this.RaiseClientDisconnectedEvent(); + RaiseClientDisconnectedEvent(); - this.mockDiscoveryEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.Is(s => s.Contains("Dummy Stderr"))), Times.Once); - this.mockDiscoveryEventsHandler.Verify(eh => eh.HandleRawMessage(It.Is(s => !string.IsNullOrEmpty(s) && s.Equals("Serialized Stderr"))), Times.Once); - } + _mockDiscoveryEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.Is(s => s.Contains("Dummy Stderr"))), Times.Once); + _mockDiscoveryEventsHandler.Verify(eh => eh.HandleRawMessage(It.Is(s => !string.IsNullOrEmpty(s) && s.Equals("Serialized Stderr"))), Times.Once); + } - [TestMethod] - public void DiscoverTestShouldNotifyDiscoveryCompleteIfClientDisconnected() - { - this.SetupFakeCommunicationChannel(); - this.testRequestSender.DiscoverTests(new DiscoveryCriteria(), this.mockDiscoveryEventsHandler.Object); + [TestMethod] + public void DiscoverTestShouldNotifyDiscoveryCompleteIfClientDisconnected() + { + SetupFakeCommunicationChannel(); + _testRequestSender.DiscoverTests(new DiscoveryCriteria(), _mockDiscoveryEventsHandler.Object); - this.RaiseClientDisconnectedEvent(); + RaiseClientDisconnectedEvent(); - this.mockDiscoveryEventsHandler.Verify(eh => eh.HandleDiscoveryComplete(It.Is(dc => dc.IsAborted == true && dc.TotalCount == -1), null)); - } + _mockDiscoveryEventsHandler.Verify(eh => eh.HandleDiscoveryComplete(It.Is(dc => dc.IsAborted == true && dc.TotalCount == -1), null)); + } - #endregion + #endregion - #region Execution Protocol Tests + #region Execution Protocol Tests - [TestMethod] - public void InitializeExecutionShouldSendCommunicationMessageWithCorrectParameters() - { - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void InitializeExecutionShouldSendCommunicationMessageWithCorrectParameters() + { + SetupFakeCommunicationChannel(); - this.testRequestSender.InitializeExecution(this.pathToAdditionalExtensions); + _testRequestSender.InitializeExecution(_pathToAdditionalExtensions); - this.mockDataSerializer.Verify(d => d.SerializePayload(MessageType.ExecutionInitialize, this.pathToAdditionalExtensions, 1), Times.Once); - this.mockChannel.Verify(mc => mc.Send(It.IsAny()), Times.Once); - } + _mockDataSerializer.Verify(d => d.SerializePayload(MessageType.ExecutionInitialize, _pathToAdditionalExtensions, 1), Times.Once); + _mockChannel.Verify(mc => mc.Send(It.IsAny()), Times.Once); + } - [TestMethod] - public void InitializeExecutionShouldSendCommunicationMessageWithCorrectParametersWithVersion() - { - this.SetupFakeChannelWithVersionNegotiation(DUMMYNEGOTIATEDPROTOCOLVERSION); + [TestMethod] + public void InitializeExecutionShouldSendCommunicationMessageWithCorrectParametersWithVersion() + { + SetupFakeChannelWithVersionNegotiation(Dummynegotiatedprotocolversion); - this.testRequestSender.InitializeExecution(this.pathToAdditionalExtensions); + _testRequestSender.InitializeExecution(_pathToAdditionalExtensions); - this.mockDataSerializer.Verify(d => d.SerializePayload(MessageType.ExecutionInitialize, this.pathToAdditionalExtensions, DUMMYNEGOTIATEDPROTOCOLVERSION), Times.Once); - } + _mockDataSerializer.Verify(d => d.SerializePayload(MessageType.ExecutionInitialize, _pathToAdditionalExtensions, Dummynegotiatedprotocolversion), Times.Once); + } - [TestMethod] - public void StartTestRunShouldSendStartTestExecutionWithSourcesOnChannel() - { - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void StartTestRunShouldSendStartTestExecutionWithSourcesOnChannel() + { + SetupFakeCommunicationChannel(); - this.testRequestSender.StartTestRun(this.testRunCriteriaWithSources, this.mockExecutionEventsHandler.Object); + _testRequestSender.StartTestRun(_testRunCriteriaWithSources, _mockExecutionEventsHandler.Object); - this.mockDataSerializer.Verify(d => d.SerializePayload(MessageType.StartTestExecutionWithSources, this.testRunCriteriaWithSources, DEFAULTPROTOCOLVERSION), Times.Once); - this.mockChannel.Verify(mc => mc.Send(It.IsAny()), Times.Once); - } + _mockDataSerializer.Verify(d => d.SerializePayload(MessageType.StartTestExecutionWithSources, _testRunCriteriaWithSources, Defaultprotocolversion), Times.Once); + _mockChannel.Verify(mc => mc.Send(It.IsAny()), Times.Once); + } - [TestMethod] - public void StartTestRunShouldSendStartTestExecutionWithSourcesOnChannelWithVersion() - { - this.SetupFakeChannelWithVersionNegotiation(DUMMYNEGOTIATEDPROTOCOLVERSION); + [TestMethod] + public void StartTestRunShouldSendStartTestExecutionWithSourcesOnChannelWithVersion() + { + SetupFakeChannelWithVersionNegotiation(Dummynegotiatedprotocolversion); - this.testRequestSender.StartTestRun(this.testRunCriteriaWithSources, this.mockExecutionEventsHandler.Object); + _testRequestSender.StartTestRun(_testRunCriteriaWithSources, _mockExecutionEventsHandler.Object); - this.mockDataSerializer.Verify(d => d.SerializePayload(MessageType.StartTestExecutionWithSources, this.testRunCriteriaWithSources, DUMMYNEGOTIATEDPROTOCOLVERSION), Times.Once); - } + _mockDataSerializer.Verify(d => d.SerializePayload(MessageType.StartTestExecutionWithSources, _testRunCriteriaWithSources, Dummynegotiatedprotocolversion), Times.Once); + } - [TestMethod] - public void StartTestRunWithTestsShouldSendStartTestExecutionWithTestsOnChannel() - { - var runCriteria = new TestRunCriteriaWithTests(new TestCase[2], "runsettings", null, null); - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void StartTestRunWithTestsShouldSendStartTestExecutionWithTestsOnChannel() + { + var runCriteria = new TestRunCriteriaWithTests(new TestCase[2], "runsettings", null, null); + SetupFakeCommunicationChannel(); - this.testRequestSender.StartTestRun(runCriteria, this.mockExecutionEventsHandler.Object); + _testRequestSender.StartTestRun(runCriteria, _mockExecutionEventsHandler.Object); - this.mockDataSerializer.Verify(d => d.SerializePayload(MessageType.StartTestExecutionWithTests, runCriteria, DEFAULTPROTOCOLVERSION), Times.Once); - this.mockChannel.Verify(mc => mc.Send(It.IsAny()), Times.Once); - } + _mockDataSerializer.Verify(d => d.SerializePayload(MessageType.StartTestExecutionWithTests, runCriteria, Defaultprotocolversion), Times.Once); + _mockChannel.Verify(mc => mc.Send(It.IsAny()), Times.Once); + } - [TestMethod] - public void StartTestRunWithTestsShouldSendStartTestExecutionWithTestsOnChannelWithVersion() - { - var runCriteria = new TestRunCriteriaWithTests(new TestCase[2], "runsettings", null, null); - this.SetupFakeChannelWithVersionNegotiation(DUMMYNEGOTIATEDPROTOCOLVERSION); + [TestMethod] + public void StartTestRunWithTestsShouldSendStartTestExecutionWithTestsOnChannelWithVersion() + { + var runCriteria = new TestRunCriteriaWithTests(new TestCase[2], "runsettings", null, null); + SetupFakeChannelWithVersionNegotiation(Dummynegotiatedprotocolversion); - this.testRequestSender.StartTestRun(runCriteria, this.mockExecutionEventsHandler.Object); + _testRequestSender.StartTestRun(runCriteria, _mockExecutionEventsHandler.Object); - this.mockDataSerializer.Verify(d => d.SerializePayload(MessageType.StartTestExecutionWithTests, runCriteria, DUMMYNEGOTIATEDPROTOCOLVERSION), Times.Once); - } + _mockDataSerializer.Verify(d => d.SerializePayload(MessageType.StartTestExecutionWithTests, runCriteria, Dummynegotiatedprotocolversion), Times.Once); + } - [TestMethod] - public void StartTestRunShouldNotifyRawMessageOnMessageReceived() - { - this.SetupDeserializeMessage(MessageType.TestMessage, new TestMessagePayload()); - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void StartTestRunShouldNotifyRawMessageOnMessageReceived() + { + SetupDeserializeMessage(MessageType.TestMessage, new TestMessagePayload()); + SetupFakeCommunicationChannel(); - this.testRequestSender.StartTestRun(this.testRunCriteriaWithSources, this.mockExecutionEventsHandler.Object); + _testRequestSender.StartTestRun(_testRunCriteriaWithSources, _mockExecutionEventsHandler.Object); - this.RaiseMessageReceivedEvent(); - this.mockExecutionEventsHandler.Verify(eh => eh.HandleRawMessage("DummyData"), Times.Once); - } + RaiseMessageReceivedEvent(); + _mockExecutionEventsHandler.Verify(eh => eh.HandleRawMessage("DummyData"), Times.Once); + } - [TestMethod] - public void StartTestRunShouldNotifyTestRunStatsChangeOnRunStatsMessageReceived() - { - var testRunChangedArgs = new TestRunChangedEventArgs( - null, - new Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult[2], - new TestCase[2]); - this.SetupDeserializeMessage(MessageType.TestRunStatsChange, testRunChangedArgs); - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void StartTestRunShouldNotifyTestRunStatsChangeOnRunStatsMessageReceived() + { + var testRunChangedArgs = new TestRunChangedEventArgs( + null, + new VisualStudio.TestPlatform.ObjectModel.TestResult[2], + new TestCase[2]); + SetupDeserializeMessage(MessageType.TestRunStatsChange, testRunChangedArgs); + SetupFakeCommunicationChannel(); - this.testRequestSender.StartTestRun(this.testRunCriteriaWithSources, this.mockExecutionEventsHandler.Object); + _testRequestSender.StartTestRun(_testRunCriteriaWithSources, _mockExecutionEventsHandler.Object); - this.RaiseMessageReceivedEvent(); - this.mockExecutionEventsHandler.Verify(eh => eh.HandleTestRunStatsChange(testRunChangedArgs), Times.Once); - } + RaiseMessageReceivedEvent(); + _mockExecutionEventsHandler.Verify(eh => eh.HandleTestRunStatsChange(testRunChangedArgs), Times.Once); + } - [TestMethod] - public void StartTestRunShouldNotifyExecutionCompleteOnRunCompleteMessageReceived() - { - var testRunCompletePayload = new TestRunCompletePayload - { - TestRunCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.MaxValue), - LastRunTests = new TestRunChangedEventArgs(null, null, null), - RunAttachments = new List() - }; - this.SetupDeserializeMessage(MessageType.ExecutionComplete, testRunCompletePayload); - this.SetupFakeCommunicationChannel(); - - this.testRequestSender.StartTestRun(this.testRunCriteriaWithSources, this.mockExecutionEventsHandler.Object); - - this.RaiseMessageReceivedEvent(); - this.mockExecutionEventsHandler.Verify( - eh => eh.HandleTestRunComplete( - testRunCompletePayload.TestRunCompleteArgs, - testRunCompletePayload.LastRunTests, - testRunCompletePayload.RunAttachments, - It.IsAny>()), - Times.Once); - } + [TestMethod] + public void StartTestRunShouldNotifyExecutionCompleteOnRunCompleteMessageReceived() + { + var testRunCompletePayload = new TestRunCompletePayload + { + TestRunCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.MaxValue), + LastRunTests = new TestRunChangedEventArgs(null, null, null), + RunAttachments = new List() + }; + SetupDeserializeMessage(MessageType.ExecutionComplete, testRunCompletePayload); + SetupFakeCommunicationChannel(); + + _testRequestSender.StartTestRun(_testRunCriteriaWithSources, _mockExecutionEventsHandler.Object); + + RaiseMessageReceivedEvent(); + _mockExecutionEventsHandler.Verify( + eh => eh.HandleTestRunComplete( + testRunCompletePayload.TestRunCompleteArgs, + testRunCompletePayload.LastRunTests, + testRunCompletePayload.RunAttachments, + It.IsAny>()), + Times.Once); + } - [TestMethod] - public void StartTestRunShouldStopServerOnRunCompleteMessageReceived() + [TestMethod] + public void StartTestRunShouldStopServerOnRunCompleteMessageReceived() + { + var testRunCompletePayload = new TestRunCompletePayload { - var testRunCompletePayload = new TestRunCompletePayload - { - TestRunCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.MaxValue), - LastRunTests = new TestRunChangedEventArgs(null, null, null), - RunAttachments = new List() - }; - this.SetupDeserializeMessage(MessageType.ExecutionComplete, testRunCompletePayload); - this.SetupFakeCommunicationChannel(); + TestRunCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.MaxValue), + LastRunTests = new TestRunChangedEventArgs(null, null, null), + RunAttachments = new List() + }; + SetupDeserializeMessage(MessageType.ExecutionComplete, testRunCompletePayload); + SetupFakeCommunicationChannel(); - this.testRequestSender.StartTestRun(this.testRunCriteriaWithSources, this.mockExecutionEventsHandler.Object); + _testRequestSender.StartTestRun(_testRunCriteriaWithSources, _mockExecutionEventsHandler.Object); - this.RaiseMessageReceivedEvent(); + RaiseMessageReceivedEvent(); - this.mockServer.Verify(ms => ms.Stop()); - } + _mockServer.Verify(ms => ms.Stop()); + } - [TestMethod] - public void StartTestRunShouldNotifyLogMessageOnTestMessageReceived() - { - var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = "Dummy" }; - this.SetupDeserializeMessage(MessageType.TestMessage, testMessagePayload); - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void StartTestRunShouldNotifyLogMessageOnTestMessageReceived() + { + var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = "Dummy" }; + SetupDeserializeMessage(MessageType.TestMessage, testMessagePayload); + SetupFakeCommunicationChannel(); - this.testRequestSender.StartTestRun(this.testRunCriteriaWithSources, this.mockExecutionEventsHandler.Object); + _testRequestSender.StartTestRun(_testRunCriteriaWithSources, _mockExecutionEventsHandler.Object); - this.RaiseMessageReceivedEvent(); - this.mockExecutionEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, "Dummy"), Times.Once); - } + RaiseMessageReceivedEvent(); + _mockExecutionEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, "Dummy"), Times.Once); + } - [TestMethod] - public void StartTestRunShouldNotifyLaunchWithDebuggerOnMessageReceived() - { - var launchMessagePayload = new TestProcessStartInfo(); - this.SetupDeserializeMessage(MessageType.LaunchAdapterProcessWithDebuggerAttached, launchMessagePayload); - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void StartTestRunShouldNotifyLaunchWithDebuggerOnMessageReceived() + { + var launchMessagePayload = new TestProcessStartInfo(); + SetupDeserializeMessage(MessageType.LaunchAdapterProcessWithDebuggerAttached, launchMessagePayload); + SetupFakeCommunicationChannel(); - this.testRequestSender.StartTestRun(this.testRunCriteriaWithSources, this.mockExecutionEventsHandler.Object); + _testRequestSender.StartTestRun(_testRunCriteriaWithSources, _mockExecutionEventsHandler.Object); - this.RaiseMessageReceivedEvent(); - this.mockExecutionEventsHandler.Verify(eh => eh.LaunchProcessWithDebuggerAttached(launchMessagePayload), Times.Once); - } + RaiseMessageReceivedEvent(); + _mockExecutionEventsHandler.Verify(eh => eh.LaunchProcessWithDebuggerAttached(launchMessagePayload), Times.Once); + } - [TestMethod] - public void StartTestRunShouldSendLaunchDebuggerAttachedCallbackOnMessageReceived() - { - var launchMessagePayload = new TestProcessStartInfo(); - this.SetupDeserializeMessage(MessageType.LaunchAdapterProcessWithDebuggerAttached, launchMessagePayload); - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void StartTestRunShouldSendLaunchDebuggerAttachedCallbackOnMessageReceived() + { + var launchMessagePayload = new TestProcessStartInfo(); + SetupDeserializeMessage(MessageType.LaunchAdapterProcessWithDebuggerAttached, launchMessagePayload); + SetupFakeCommunicationChannel(); - this.testRequestSender.StartTestRun(this.testRunCriteriaWithSources, this.mockExecutionEventsHandler.Object); + _testRequestSender.StartTestRun(_testRunCriteriaWithSources, _mockExecutionEventsHandler.Object); - this.RaiseMessageReceivedEvent(); - this.mockDataSerializer.Verify(ds => ds.SerializePayload(MessageType.LaunchAdapterProcessWithDebuggerAttachedCallback, It.IsAny(), 1), Times.Once); - this.mockChannel.Verify(c => c.Send(It.IsAny()), Times.AtLeastOnce); - } + RaiseMessageReceivedEvent(); + _mockDataSerializer.Verify(ds => ds.SerializePayload(MessageType.LaunchAdapterProcessWithDebuggerAttachedCallback, It.IsAny(), 1), Times.Once); + _mockChannel.Verify(c => c.Send(It.IsAny()), Times.AtLeastOnce); + } - [TestMethod] - public void StartTestRunShouldSendLaunchDebuggerAttachedCallbackOnMessageReceivedWithVersion() - { - var launchMessagePayload = new TestProcessStartInfo(); - this.SetupFakeChannelWithVersionNegotiation(DUMMYNEGOTIATEDPROTOCOLVERSION); - this.SetupDeserializeMessage(MessageType.LaunchAdapterProcessWithDebuggerAttached, launchMessagePayload); + [TestMethod] + public void StartTestRunShouldSendLaunchDebuggerAttachedCallbackOnMessageReceivedWithVersion() + { + var launchMessagePayload = new TestProcessStartInfo(); + SetupFakeChannelWithVersionNegotiation(Dummynegotiatedprotocolversion); + SetupDeserializeMessage(MessageType.LaunchAdapterProcessWithDebuggerAttached, launchMessagePayload); - this.testRequestSender.StartTestRun(this.testRunCriteriaWithSources, this.mockExecutionEventsHandler.Object); + _testRequestSender.StartTestRun(_testRunCriteriaWithSources, _mockExecutionEventsHandler.Object); - this.RaiseMessageReceivedEvent(); - this.mockDataSerializer.Verify(ds => ds.SerializePayload(MessageType.LaunchAdapterProcessWithDebuggerAttachedCallback, It.IsAny(), DUMMYNEGOTIATEDPROTOCOLVERSION), Times.Once); - } + RaiseMessageReceivedEvent(); + _mockDataSerializer.Verify(ds => ds.SerializePayload(MessageType.LaunchAdapterProcessWithDebuggerAttachedCallback, It.IsAny(), Dummynegotiatedprotocolversion), Times.Once); + } - [TestMethod] - public void StartTestRunShouldNotifyLogMessageIfExceptionIsThrownOnMessageReceived() - { - this.SetupExceptionOnMessageReceived(); - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void StartTestRunShouldNotifyLogMessageIfExceptionIsThrownOnMessageReceived() + { + SetupExceptionOnMessageReceived(); + SetupFakeCommunicationChannel(); - this.testRequestSender.StartTestRun(this.testRunCriteriaWithSources, this.mockExecutionEventsHandler.Object); + _testRequestSender.StartTestRun(_testRunCriteriaWithSources, _mockExecutionEventsHandler.Object); - this.RaiseMessageReceivedEvent(); - this.mockExecutionEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.Is(s => s.Contains("Dummy Message"))), Times.Once); - this.mockExecutionEventsHandler.Verify(eh => eh.HandleRawMessage("SerializedMessage"), Times.Once); - } + RaiseMessageReceivedEvent(); + _mockExecutionEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.Is(s => s.Contains("Dummy Message"))), Times.Once); + _mockExecutionEventsHandler.Verify(eh => eh.HandleRawMessage("SerializedMessage"), Times.Once); + } - [TestMethod] - public void StartTestRunShouldNotifyExecutionCompleteIfExceptionIsThrownOnMessageReceived() - { - this.SetupExceptionOnMessageReceived(); - this.SetupFakeCommunicationChannel(); + [TestMethod] + public void StartTestRunShouldNotifyExecutionCompleteIfExceptionIsThrownOnMessageReceived() + { + SetupExceptionOnMessageReceived(); + SetupFakeCommunicationChannel(); - this.testRequestSender.StartTestRun(this.testRunCriteriaWithSources, this.mockExecutionEventsHandler.Object); + _testRequestSender.StartTestRun(_testRunCriteriaWithSources, _mockExecutionEventsHandler.Object); - this.RaiseMessageReceivedEvent(); - this.mockExecutionEventsHandler.Verify(eh => eh.HandleTestRunComplete(It.Is(t => t.IsAborted), null, null, null), Times.Once); - this.mockExecutionEventsHandler.Verify(eh => eh.HandleRawMessage("SerializedAbortedPayload"), Times.Once); - } + RaiseMessageReceivedEvent(); + _mockExecutionEventsHandler.Verify(eh => eh.HandleTestRunComplete(It.Is(t => t.IsAborted), null, null, null), Times.Once); + _mockExecutionEventsHandler.Verify(eh => eh.HandleRawMessage("SerializedAbortedPayload"), Times.Once); + } - [TestMethod] - public void StartTestRunShouldNotNotifyExecutionCompleteIfClientDisconnectedAndOperationComplete() + [TestMethod] + public void StartTestRunShouldNotNotifyExecutionCompleteIfClientDisconnectedAndOperationComplete() + { + var testRunCompletePayload = new TestRunCompletePayload { - var testRunCompletePayload = new TestRunCompletePayload - { - TestRunCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.MaxValue), - LastRunTests = new TestRunChangedEventArgs(null, null, null), - RunAttachments = new List() - }; - this.SetupDeserializeMessage(MessageType.ExecutionComplete, testRunCompletePayload); - this.SetupFakeCommunicationChannel(); - this.testRequestSender.StartTestRun(this.testRunCriteriaWithSources, this.mockExecutionEventsHandler.Object); - this.RaiseMessageReceivedEvent(); // Raise test run complete - - this.RaiseClientDisconnectedEvent(); - - this.mockExecutionEventsHandler.Verify(eh => eh.HandleTestRunComplete(It.Is(t => t.IsAborted), null, null, null), Times.Never); - this.mockExecutionEventsHandler.Verify(eh => eh.HandleRawMessage("SerializedAbortedPayload"), Times.Never); - } + TestRunCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.MaxValue), + LastRunTests = new TestRunChangedEventArgs(null, null, null), + RunAttachments = new List() + }; + SetupDeserializeMessage(MessageType.ExecutionComplete, testRunCompletePayload); + SetupFakeCommunicationChannel(); + _testRequestSender.StartTestRun(_testRunCriteriaWithSources, _mockExecutionEventsHandler.Object); + RaiseMessageReceivedEvent(); // Raise test run complete - [TestMethod] - public void StartTestRunShouldNotifyErrorLogMessageIfClientDisconnected() - { - this.SetupFakeCommunicationChannel(); - this.testRequestSender.StartTestRun(this.testRunCriteriaWithSources, this.mockExecutionEventsHandler.Object); + RaiseClientDisconnectedEvent(); - this.RaiseClientDisconnectedEvent(); + _mockExecutionEventsHandler.Verify(eh => eh.HandleTestRunComplete(It.Is(t => t.IsAborted), null, null, null), Times.Never); + _mockExecutionEventsHandler.Verify(eh => eh.HandleRawMessage("SerializedAbortedPayload"), Times.Never); + } - // Expect default error message since we've not set any client exit message - var expectedErrorMessage = "Reason: Unable to communicate"; - this.mockExecutionEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.Is(s => s.Contains(expectedErrorMessage))), Times.Once); - } + [TestMethod] + public void StartTestRunShouldNotifyErrorLogMessageIfClientDisconnected() + { + SetupFakeCommunicationChannel(); + _testRequestSender.StartTestRun(_testRunCriteriaWithSources, _mockExecutionEventsHandler.Object); - [TestMethod] - public void StartTestRunShouldNotifyErrorLogMessageIfClientDisconnectedWithClientExit() - { - this.SetupFakeCommunicationChannel(); - this.testRequestSender.StartTestRun(this.testRunCriteriaWithSources, this.mockExecutionEventsHandler.Object); - this.testRequestSender.OnClientProcessExit("Dummy Stderr"); + RaiseClientDisconnectedEvent(); - this.RaiseClientDisconnectedEvent(); + // Expect default error message since we've not set any client exit message + var expectedErrorMessage = "Reason: Unable to communicate"; + _mockExecutionEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.Is(s => s.Contains(expectedErrorMessage))), Times.Once); + } - var expectedErrorMessage = "Reason: Test host process crashed : Dummy Stderr"; - this.mockExecutionEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.Is(s => s.Contains(expectedErrorMessage))), Times.Once); - } + [TestMethod] + public void StartTestRunShouldNotifyErrorLogMessageIfClientDisconnectedWithClientExit() + { + SetupFakeCommunicationChannel(); + _testRequestSender.StartTestRun(_testRunCriteriaWithSources, _mockExecutionEventsHandler.Object); + _testRequestSender.OnClientProcessExit("Dummy Stderr"); - [TestMethod] - public void StartTestRunShouldNotifyExecutionCompleteIfClientDisconnected() - { - this.SetupOperationAbortedPayload(); - this.SetupFakeCommunicationChannel(); - this.testRequestSender.StartTestRun(this.testRunCriteriaWithSources, this.mockExecutionEventsHandler.Object); + RaiseClientDisconnectedEvent(); - this.RaiseClientDisconnectedEvent(); + var expectedErrorMessage = "Reason: Test host process crashed : Dummy Stderr"; + _mockExecutionEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.Is(s => s.Contains(expectedErrorMessage))), Times.Once); + } - this.mockExecutionEventsHandler.Verify(eh => eh.HandleTestRunComplete(It.Is(t => t.IsAborted), null, null, null), Times.Once); - this.mockExecutionEventsHandler.Verify(eh => eh.HandleRawMessage("SerializedAbortedPayload"), Times.Once); - } + [TestMethod] + public void StartTestRunShouldNotifyExecutionCompleteIfClientDisconnected() + { + SetupOperationAbortedPayload(); + SetupFakeCommunicationChannel(); + _testRequestSender.StartTestRun(_testRunCriteriaWithSources, _mockExecutionEventsHandler.Object); - [TestMethod] - public void SendTestRunCancelShouldSendCancelTestRunMessage() - { - this.SetupFakeCommunicationChannel(); + RaiseClientDisconnectedEvent(); - this.testRequestSender.SendTestRunCancel(); + _mockExecutionEventsHandler.Verify(eh => eh.HandleTestRunComplete(It.Is(t => t.IsAborted), null, null, null), Times.Once); + _mockExecutionEventsHandler.Verify(eh => eh.HandleRawMessage("SerializedAbortedPayload"), Times.Once); + } - this.mockDataSerializer.Verify(ds => ds.SerializeMessage(MessageType.CancelTestRun), Times.Once); - this.mockChannel.Verify(c => c.Send(It.IsAny()), Times.Once); - } + [TestMethod] + public void SendTestRunCancelShouldSendCancelTestRunMessage() + { + SetupFakeCommunicationChannel(); - [TestMethod] - public void SendTestRunAbortShouldSendAbortTestRunMessage() - { - this.SetupFakeCommunicationChannel(); + _testRequestSender.SendTestRunCancel(); - this.testRequestSender.SendTestRunAbort(); + _mockDataSerializer.Verify(ds => ds.SerializeMessage(MessageType.CancelTestRun), Times.Once); + _mockChannel.Verify(c => c.Send(It.IsAny()), Times.Once); + } - this.mockDataSerializer.Verify(ds => ds.SerializeMessage(MessageType.AbortTestRun), Times.Once); - this.mockChannel.Verify(c => c.Send(It.IsAny()), Times.Once); - } + [TestMethod] + public void SendTestRunAbortShouldSendAbortTestRunMessage() + { + SetupFakeCommunicationChannel(); - #endregion + _testRequestSender.SendTestRunAbort(); - private string SetupFakeCommunicationChannel(string connectionArgs = "123") - { - this.connectionInfo = new TestHostConnectionInfo - { - Endpoint = IPAddress.Loopback + ":" + connectionArgs, - Role = ConnectionRole.Client, - Transport = Transport.Sockets - }; - - // Setup mock connected event and initialize communication channel - this.mockServer.Setup(mc => mc.Start(this.connectionInfo.Endpoint)) - .Returns(this.connectionInfo.Endpoint) - .Callback(() => this.mockServer.Raise(s => s.Connected += null, this.mockServer.Object, this.connectedEventArgs)); - - return this.testRequestSender.InitializeCommunication().ToString(); - } + _mockDataSerializer.Verify(ds => ds.SerializeMessage(MessageType.AbortTestRun), Times.Once); + _mockChannel.Verify(c => c.Send(It.IsAny()), Times.Once); + } - private void SetupFakeChannelWithVersionNegotiation(int protocolVersion) - { - // Sends a check version message to setup the negotiated protocol version. - // This method is only required in specific tests. - this.SetupDeserializeMessage(MessageType.VersionCheck, DUMMYNEGOTIATEDPROTOCOLVERSION); - this.SetupRaiseMessageReceivedOnCheckVersion(); - this.SetupFakeCommunicationChannel(); - this.testRequestSender.CheckVersionWithTestHost(); - this.ResetRaiseMessageReceivedOnCheckVersion(); - } + #endregion - private void RaiseMessageReceivedEvent() + private string SetupFakeCommunicationChannel(string connectionArgs = "123") + { + _connectionInfo = new TestHostConnectionInfo { - this.mockChannel.Raise( - c => c.MessageReceived += null, - this.mockChannel.Object, - new MessageReceivedEventArgs { Data = "DummyData" }); - } + Endpoint = IPAddress.Loopback + ":" + connectionArgs, + Role = ConnectionRole.Client, + Transport = Transport.Sockets + }; - private void RaiseClientDisconnectedEvent() - { - this.mockServer.Raise( - s => s.Disconnected += null, - this.mockServer.Object, - new DisconnectedEventArgs { Error = new Exception("Dummy Message") }); - } + // Setup mock connected event and initialize communication channel + _mockServer.Setup(mc => mc.Start(_connectionInfo.Endpoint)) + .Returns(_connectionInfo.Endpoint) + .Callback(() => _mockServer.Raise(s => s.Connected += null, _mockServer.Object, _connectedEventArgs)); - private void SetupDeserializeMessage(string messageType, TPayload payload) - { - this.mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.IsAny())) - .Returns(new Message { MessageType = messageType }); - this.mockDataSerializer.Setup(ds => ds.DeserializePayload(It.IsAny())) - .Returns(payload); - } + return _testRequestSender.InitializeCommunication().ToString(); + } - private void SetupExceptionMessageSerialize() - { - // Serialize the exception message - this.mockDataSerializer - .Setup(ds => ds.SerializePayload(MessageType.TestMessage, It.Is(p => p.Message.Contains("Dummy Message")))) - .Returns("SerializedMessage"); - } + private void SetupFakeChannelWithVersionNegotiation(int protocolVersion) + { + // Sends a check version message to setup the negotiated protocol version. + // This method is only required in specific tests. + SetupDeserializeMessage(MessageType.VersionCheck, Dummynegotiatedprotocolversion); + SetupRaiseMessageReceivedOnCheckVersion(); + SetupFakeCommunicationChannel(); + _testRequestSender.CheckVersionWithTestHost(); + ResetRaiseMessageReceivedOnCheckVersion(); + } - private void SetupOperationAbortedPayload() - { - // Serialize the execution aborted - this.mockDataSerializer - .Setup(ds => ds.SerializePayload(MessageType.ExecutionComplete, It.Is(p => p.TestRunCompleteArgs.IsAborted))) - .Returns("SerializedAbortedPayload"); - } + private void RaiseMessageReceivedEvent() + { + _mockChannel.Raise( + c => c.MessageReceived += null, + _mockChannel.Object, + new MessageReceivedEventArgs { Data = "DummyData" }); + } - private void SetupExceptionOnMessageReceived() - { - this.SetupExceptionMessageSerialize(); - this.SetupOperationAbortedPayload(); + private void RaiseClientDisconnectedEvent() + { + _mockServer.Raise( + s => s.Disconnected += null, + _mockServer.Object, + new DisconnectedEventArgs { Error = new Exception("Dummy Message") }); + } - this.mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.IsAny())) - .Callback(() => throw new Exception("Dummy Message")); - } + private void SetupDeserializeMessage(string messageType, TPayload payload) + { + _mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.IsAny())) + .Returns(new Message { MessageType = messageType }); + _mockDataSerializer.Setup(ds => ds.DeserializePayload(It.IsAny())) + .Returns(payload); + } - private void SetupRaiseMessageReceivedOnCheckVersion() - { - this.mockChannel.Setup(mc => mc.Send(It.IsAny())).Callback(this.RaiseMessageReceivedEvent); - } + private void SetupExceptionMessageSerialize() + { + // Serialize the exception message + _mockDataSerializer + .Setup(ds => ds.SerializePayload(MessageType.TestMessage, It.Is(p => p.Message.Contains("Dummy Message")))) + .Returns("SerializedMessage"); + } - private void ResetRaiseMessageReceivedOnCheckVersion() - { - this.mockChannel.Reset(); - } + private void SetupOperationAbortedPayload() + { + // Serialize the execution aborted + _mockDataSerializer + .Setup(ds => ds.SerializePayload(MessageType.ExecutionComplete, It.Is(p => p.TestRunCompleteArgs.IsAborted))) + .Returns("SerializedAbortedPayload"); + } + + private void SetupExceptionOnMessageReceived() + { + SetupExceptionMessageSerialize(); + SetupOperationAbortedPayload(); - private class TestableTestRequestSender : TestRequestSender + _mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.IsAny())) + .Callback(() => throw new Exception("Dummy Message")); + } + + private void SetupRaiseMessageReceivedOnCheckVersion() + { + _mockChannel.Setup(mc => mc.Send(It.IsAny())).Callback(RaiseMessageReceivedEvent); + } + + private void ResetRaiseMessageReceivedOnCheckVersion() + { + _mockChannel.Reset(); + } + + private class TestableTestRequestSender : TestRequestSender + { + public TestableTestRequestSender(ICommunicationEndPoint commEndpoint, TestHostConnectionInfo connectionInfo, IDataSerializer serializer, ProtocolConfig protocolConfig) + : base(commEndpoint, connectionInfo, serializer, protocolConfig, 0) { - public TestableTestRequestSender(ICommunicationEndPoint commEndpoint, TestHostConnectionInfo connectionInfo, IDataSerializer serializer, ProtocolConfig protocolConfig) - : base(commEndpoint, connectionInfo, serializer, protocolConfig, 0) - { - } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/CommandLineArgumentsHelperTests.cs b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/CommandLineArgumentsHelperTests.cs index d8b7e460f5..e3bbfef049 100644 --- a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/CommandLineArgumentsHelperTests.cs +++ b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/CommandLineArgumentsHelperTests.cs @@ -1,143 +1,142 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CoreUtilities.UnitTests.Helpers +namespace Microsoft.TestPlatform.CoreUtilities.UnitTests.Helpers; + +using System.Collections.Generic; + +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class CommandLineArgumentsHelperTests { - using System.Collections.Generic; + [TestMethod] + public void GetArgumentsDictionaryShouldReturnDictionary() + { + var args = new List() { "--port", "12312", "--parentprocessid", "2312", "--testsourcepath", @"C:\temp\1.dll" }; + var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); + + Assert.AreEqual("12312", argsDictionary["--port"]); + Assert.AreEqual("2312", argsDictionary["--parentprocessid"]); + Assert.AreEqual(@"C:\temp\1.dll", argsDictionary["--testsourcepath"]); + } + + [TestMethod] + public void GetArgumentsDictionaryShouldIgnoreValuesWithoutPreceedingHypen() + { + var args = new List() { "port", "12312", "--parentprocessid", "2312", "--testsourcepath", @"C:\temp\1.dll" }; + var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); + + Assert.IsTrue(argsDictionary.Count == 2); + Assert.AreEqual("2312", argsDictionary["--parentprocessid"]); + Assert.AreEqual(@"C:\temp\1.dll", argsDictionary["--testsourcepath"]); + + args = new List() { "--port", "12312", "--parentprocessid", "2312", "testsourcepath", @"C:\temp\1.dll" }; + argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); + + Assert.IsTrue(argsDictionary.Count == 2); + Assert.AreEqual("12312", argsDictionary["--port"]); + Assert.AreEqual("2312", argsDictionary["--parentprocessid"]); + } + + [TestMethod] + public void GetStringArgFromDictShouldReturnStringValueOrEmpty() + { + var args = new List() { "--port", "12312", "--parentprocessid", "2312", "--testsourcepath", @"C:\temp\1.dll" }; + var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); + + string data = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, "--port"); + Assert.AreEqual("12312", data); + } + + [TestMethod] + public void GetStringArgFromDictShouldReturnNullIfValueIsNotPresent() + { + var args = new List() { "--hello", "--world" }; + var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); + + string data = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, "--hello"); + + Assert.IsTrue(argsDictionary.Count == 2); + Assert.IsNull(data); + } + + [TestMethod] + public void GetStringArgFromDictShouldReturnEmptyStringIfKeyIsNotPresent() + { + var args = new List() { "--hello", "--world" }; + var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); + + string data = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, "--port"); - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; - using Microsoft.VisualStudio.TestTools.UnitTesting; + Assert.IsTrue(argsDictionary.Count == 2); + Assert.AreEqual(string.Empty, data); + } - [TestClass] - public class CommandLineArgumentsHelperTests + [TestMethod] + public void GetArgumentsDictionaryShouldReturnEmptyDictionaryIfEmptyArgIsPassed() { - [TestMethod] - public void GetArgumentsDictionaryShouldReturnDictionary() - { - var args = new List() { "--port", "12312", "--parentprocessid", "2312", "--testsourcepath", @"C:\temp\1.dll" }; - var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); - - Assert.AreEqual("12312", argsDictionary["--port"]); - Assert.AreEqual("2312", argsDictionary["--parentprocessid"]); - Assert.AreEqual(@"C:\temp\1.dll", argsDictionary["--testsourcepath"]); - } - - [TestMethod] - public void GetArgumentsDictionaryShouldIgnoreValuesWithoutPreceedingHypen() - { - var args = new List() { "port", "12312", "--parentprocessid", "2312", "--testsourcepath", @"C:\temp\1.dll" }; - var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); - - Assert.IsTrue(argsDictionary.Count == 2); - Assert.AreEqual("2312", argsDictionary["--parentprocessid"]); - Assert.AreEqual(@"C:\temp\1.dll", argsDictionary["--testsourcepath"]); - - args = new List() { "--port", "12312", "--parentprocessid", "2312", "testsourcepath", @"C:\temp\1.dll" }; - argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); - - Assert.IsTrue(argsDictionary.Count == 2); - Assert.AreEqual("12312", argsDictionary["--port"]); - Assert.AreEqual("2312", argsDictionary["--parentprocessid"]); - } - - [TestMethod] - public void GetStringArgFromDictShouldReturnStringValueOrEmpty() - { - var args = new List() { "--port", "12312", "--parentprocessid", "2312", "--testsourcepath", @"C:\temp\1.dll" }; - var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); - - string data = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, "--port"); - Assert.AreEqual("12312", data); - } - - [TestMethod] - public void GetStringArgFromDictShouldReturnNullIfValueIsNotPresent() - { - var args = new List() { "--hello", "--world" }; - var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); - - string data = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, "--hello"); - - Assert.IsTrue(argsDictionary.Count == 2); - Assert.IsNull(data); - } - - [TestMethod] - public void GetStringArgFromDictShouldReturnEmptyStringIfKeyIsNotPresent() - { - var args = new List() { "--hello", "--world" }; - var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); - - string data = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, "--port"); - - Assert.IsTrue(argsDictionary.Count == 2); - Assert.AreEqual(string.Empty, data); - } - - [TestMethod] - public void GetArgumentsDictionaryShouldReturnEmptyDictionaryIfEmptyArgIsPassed() - { - var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(null); - Assert.IsTrue(argsDictionary.Count == 0); - - argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(new string[] { }); - Assert.IsTrue(argsDictionary.Count == 0); - } - - [TestMethod] - public void GetArgumentsDictionaryShouldTreatValueAsNullIfTwoConsecutiveKeysArePassed() - { - var args = new List() { "--hello", "--world" }; - var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); - - Assert.IsTrue(argsDictionary.Count == 2); - Assert.IsNull(argsDictionary["--hello"]); - Assert.IsNull(argsDictionary["--world"]); - } - - [TestMethod] - public void GetIntArgFromDictShouldReturnZeroIfKeyIsNotPresent() - { - var args = new List() { "--hello", "--world" }; - var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); - - int data = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, "--port"); - - Assert.AreEqual(0, data); - } - - [TestMethod] - public void GetIntArgFromDictShouldReturnTheValueIfKeyIsPresent() - { - var args = new List() { "--port", "1000" }; - var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); - - int data = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, "--port"); - - Assert.AreEqual(1000, data); - } - - [TestMethod] - public void TryGetIntArgFromDictShouldReturnTrueIfKeyIsPresentAndTheValue() - { - var args = new List() { "--port", "59870" }; - var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); - - bool found = CommandLineArgumentsHelper.TryGetIntArgFromDict(argsDictionary, "--port", out var data); - - Assert.IsTrue(found); - Assert.AreEqual(59870, data); - } - - [TestMethod] - public void TryGetIntArgFromDictShouldReturnFalseIfKeyIsNotPresent() - { - var args = new List() { "--hello", "--world" }; - var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); - - bool found = CommandLineArgumentsHelper.TryGetIntArgFromDict(argsDictionary, "--port", out var data); - - Assert.IsFalse(found); - } + var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(null); + Assert.IsTrue(argsDictionary.Count == 0); + + argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(new string[] { }); + Assert.IsTrue(argsDictionary.Count == 0); + } + + [TestMethod] + public void GetArgumentsDictionaryShouldTreatValueAsNullIfTwoConsecutiveKeysArePassed() + { + var args = new List() { "--hello", "--world" }; + var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); + + Assert.IsTrue(argsDictionary.Count == 2); + Assert.IsNull(argsDictionary["--hello"]); + Assert.IsNull(argsDictionary["--world"]); + } + + [TestMethod] + public void GetIntArgFromDictShouldReturnZeroIfKeyIsNotPresent() + { + var args = new List() { "--hello", "--world" }; + var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); + + int data = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, "--port"); + + Assert.AreEqual(0, data); + } + + [TestMethod] + public void GetIntArgFromDictShouldReturnTheValueIfKeyIsPresent() + { + var args = new List() { "--port", "1000" }; + var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); + + int data = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, "--port"); + + Assert.AreEqual(1000, data); + } + + [TestMethod] + public void TryGetIntArgFromDictShouldReturnTrueIfKeyIsPresentAndTheValue() + { + var args = new List() { "--port", "59870" }; + var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); + + bool found = CommandLineArgumentsHelper.TryGetIntArgFromDict(argsDictionary, "--port", out var data); + + Assert.IsTrue(found); + Assert.AreEqual(59870, data); + } + + [TestMethod] + public void TryGetIntArgFromDictShouldReturnFalseIfKeyIsNotPresent() + { + var args = new List() { "--hello", "--world" }; + var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); + bool found = CommandLineArgumentsHelper.TryGetIntArgFromDict(argsDictionary, "--port", out _); + + Assert.IsFalse(found); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/DotnetHostHelperTest.cs b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/DotnetHostHelperTest.cs index 41ee4db786..2ab9917164 100644 --- a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/DotnetHostHelperTest.cs +++ b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/DotnetHostHelperTest.cs @@ -1,355 +1,354 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CoreUtilities.UnitTests.Helpers +namespace Microsoft.TestPlatform.CoreUtilities.UnitTests.Helpers; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using VisualStudio.TestTools.UnitTesting; +using Win32; +using Moq; + +[TestClass] +public class DotnetHostHelperTest : IDisposable { - using System; - using System.Collections.Generic; - using System.IO; - using System.Text; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Microsoft.Win32; - using Moq; - - [TestClass] - public class DotnetHostHelperTest : IDisposable + private readonly Mock _fileHelper = new(); + private readonly Mock _processHelper = new(); + private readonly Mock _environmentHelper = new(); + private readonly Mock _windowsRegistrytHelper = new(); + private readonly Mock _environmentVariableHelper = new(); + private readonly MockMuxerHelper _muxerHelper = new(); + + [TestMethod] + public void GetDotnetPathByArchitecture_SameArchitecture() { - private readonly Mock fileHelper = new Mock(); - private readonly Mock processHelper = new Mock(); - private readonly Mock environmentHelper = new Mock(); - private readonly Mock windowsRegistrytHelper = new Mock(); - private readonly Mock environmentVariableHelper = new Mock(); - private readonly MockMuxerHelper muxerHelper = new MockMuxerHelper(); - - [TestMethod] - public void GetDotnetPathByArchitecture_SameArchitecture() - { - // Arrange - string finalMuxerPath = muxerHelper.RenameMuxerAndReturnPath(PlatformOperatingSystem.Windows, PlatformArchitecture.X64); - var dotnetHostHelper = new DotnetHostHelper(fileHelper.Object, environmentHelper.Object, windowsRegistrytHelper.Object, environmentVariableHelper.Object, processHelper.Object); - environmentHelper.SetupGet(x => x.OperatingSystem).Returns(PlatformOperatingSystem.Windows); - environmentHelper.SetupGet(x => x.Architecture).Returns(PlatformArchitecture.X64); - processHelper.Setup(x => x.GetCurrentProcessFileName()).Returns(finalMuxerPath); - processHelper.Setup(x => x.GetCurrentProcessArchitecture()).Returns(PlatformArchitecture.X64); - - // Act & Assert - Assert.IsTrue(dotnetHostHelper.TryGetDotnetPathByArchitecture(PlatformArchitecture.X64, out string muxerPath)); - Assert.AreEqual(finalMuxerPath, muxerPath); - } + // Arrange + string finalMuxerPath = _muxerHelper.RenameMuxerAndReturnPath(PlatformOperatingSystem.Windows, PlatformArchitecture.X64); + var dotnetHostHelper = new DotnetHostHelper(_fileHelper.Object, _environmentHelper.Object, _windowsRegistrytHelper.Object, _environmentVariableHelper.Object, _processHelper.Object); + _environmentHelper.SetupGet(x => x.OperatingSystem).Returns(PlatformOperatingSystem.Windows); + _environmentHelper.SetupGet(x => x.Architecture).Returns(PlatformArchitecture.X64); + _processHelper.Setup(x => x.GetCurrentProcessFileName()).Returns(finalMuxerPath); + _processHelper.Setup(x => x.GetCurrentProcessArchitecture()).Returns(PlatformArchitecture.X64); + + // Act & Assert + Assert.IsTrue(dotnetHostHelper.TryGetDotnetPathByArchitecture(PlatformArchitecture.X64, out string muxerPath)); + Assert.AreEqual(finalMuxerPath, muxerPath); + } - [DataTestMethod] - [DataRow(PlatformArchitecture.X86, PlatformArchitecture.X64, PlatformOperatingSystem.Windows, "DOTNET_ROOT(x86)")] - [DataRow(PlatformArchitecture.X86, PlatformArchitecture.X64, PlatformOperatingSystem.Windows, "DOTNET_ROOT")] + [DataTestMethod] + [DataRow(PlatformArchitecture.X86, PlatformArchitecture.X64, PlatformOperatingSystem.Windows, "DOTNET_ROOT(x86)")] + [DataRow(PlatformArchitecture.X86, PlatformArchitecture.X64, PlatformOperatingSystem.Windows, "DOTNET_ROOT")] - [DataRow(PlatformArchitecture.ARM64, PlatformArchitecture.X64, PlatformOperatingSystem.Windows, "DOTNET_ROOT(x86)", false)] - [DataRow(PlatformArchitecture.ARM64, PlatformArchitecture.X64, PlatformOperatingSystem.Windows, "DOTNET_ROOT_ARM64")] - [DataRow(PlatformArchitecture.ARM64, PlatformArchitecture.X64, PlatformOperatingSystem.Windows, "DOTNET_ROOT")] + [DataRow(PlatformArchitecture.ARM64, PlatformArchitecture.X64, PlatformOperatingSystem.Windows, "DOTNET_ROOT(x86)", false)] + [DataRow(PlatformArchitecture.ARM64, PlatformArchitecture.X64, PlatformOperatingSystem.Windows, "DOTNET_ROOT_ARM64")] + [DataRow(PlatformArchitecture.ARM64, PlatformArchitecture.X64, PlatformOperatingSystem.Windows, "DOTNET_ROOT")] - [DataRow(PlatformArchitecture.X64, PlatformArchitecture.X64, PlatformOperatingSystem.Windows, "DOTNET_ROOT(x86)", false)] - [DataRow(PlatformArchitecture.X64, PlatformArchitecture.ARM64, PlatformOperatingSystem.Windows, "DOTNET_ROOT_X64")] - [DataRow(PlatformArchitecture.X64, PlatformArchitecture.ARM64, PlatformOperatingSystem.Windows, "DOTNET_ROOT")] + [DataRow(PlatformArchitecture.X64, PlatformArchitecture.X64, PlatformOperatingSystem.Windows, "DOTNET_ROOT(x86)", false)] + [DataRow(PlatformArchitecture.X64, PlatformArchitecture.ARM64, PlatformOperatingSystem.Windows, "DOTNET_ROOT_X64")] + [DataRow(PlatformArchitecture.X64, PlatformArchitecture.ARM64, PlatformOperatingSystem.Windows, "DOTNET_ROOT")] - [DataRow(PlatformArchitecture.ARM64, PlatformArchitecture.X64, PlatformOperatingSystem.OSX, "DOTNET_ROOT_ARM64")] - [DataRow(PlatformArchitecture.ARM64, PlatformArchitecture.X64, PlatformOperatingSystem.OSX, "DOTNET_ROOT")] + [DataRow(PlatformArchitecture.ARM64, PlatformArchitecture.X64, PlatformOperatingSystem.OSX, "DOTNET_ROOT_ARM64")] + [DataRow(PlatformArchitecture.ARM64, PlatformArchitecture.X64, PlatformOperatingSystem.OSX, "DOTNET_ROOT")] - [DataRow(PlatformArchitecture.X64, PlatformArchitecture.ARM64, PlatformOperatingSystem.OSX, "DOTNET_ROOT_X64")] - [DataRow(PlatformArchitecture.X64, PlatformArchitecture.ARM64, PlatformOperatingSystem.OSX, "DOTNET_ROOT")] - public void GetDotnetPathByArchitecture_EnvVars(PlatformArchitecture targetArchitecture, - PlatformArchitecture platformArchitecture, - PlatformOperatingSystem platformSystem, - string envVar, - bool found = true) + [DataRow(PlatformArchitecture.X64, PlatformArchitecture.ARM64, PlatformOperatingSystem.OSX, "DOTNET_ROOT_X64")] + [DataRow(PlatformArchitecture.X64, PlatformArchitecture.ARM64, PlatformOperatingSystem.OSX, "DOTNET_ROOT")] + public void GetDotnetPathByArchitecture_EnvVars(PlatformArchitecture targetArchitecture, + PlatformArchitecture platformArchitecture, + PlatformOperatingSystem platformSystem, + string envVar, + bool found = true) + { + // Arrange + string dotnetRootX64 = _muxerHelper.RenameMuxerAndReturnPath(platformSystem, PlatformArchitecture.X64); + string dotnetRootArm64 = _muxerHelper.RenameMuxerAndReturnPath(platformSystem, PlatformArchitecture.ARM64); + string dotnetRootX86 = null; + if (platformSystem == PlatformOperatingSystem.Windows) { - // Arrange - string DOTNET_ROOT_X64 = muxerHelper.RenameMuxerAndReturnPath(platformSystem, PlatformArchitecture.X64); - string DOTNET_ROOT_ARM64 = muxerHelper.RenameMuxerAndReturnPath(platformSystem, PlatformArchitecture.ARM64); - string DOTNET_ROOT_X86 = null; - if (platformSystem == PlatformOperatingSystem.Windows) - { - DOTNET_ROOT_X86 = muxerHelper.RenameMuxerAndReturnPath(platformSystem, PlatformArchitecture.X86); - } - string DOTNET_ROOT = muxerHelper.RenameMuxerAndReturnPath(platformSystem, targetArchitecture); - Dictionary envVars = new Dictionary() - { - { "DOTNET_ROOT_X64" , DOTNET_ROOT_X64}, - { "DOTNET_ROOT_ARM64" , DOTNET_ROOT_ARM64}, - { "DOTNET_ROOT(x86)" , DOTNET_ROOT_X86}, - { "DOTNET_ROOT" , DOTNET_ROOT}, - }; - - environmentHelper.SetupGet(x => x.Architecture).Returns(platformArchitecture); - environmentHelper.SetupGet(x => x.OperatingSystem).Returns(platformSystem); - environmentVariableHelper.Setup(x => x.GetEnvironmentVariable(envVar)).Returns(Path.GetDirectoryName(envVars[envVar])); - environmentVariableHelper.Setup(x => x.GetEnvironmentVariable("ProgramFiles")).Returns("notfound"); - fileHelper.Setup(x => x.DirectoryExists(Path.GetDirectoryName(envVars[envVar]))).Returns(true); - fileHelper.Setup(x => x.Exists(envVars[envVar])).Returns(true); - if (found) - { - fileHelper.Setup(x => x.GetStream(envVars[envVar], FileMode.Open, FileAccess.Read)).Returns(File.OpenRead(envVars[envVar])); - } - - // Act & Assert - var dotnetHostHelper = new DotnetHostHelper(fileHelper.Object, environmentHelper.Object, windowsRegistrytHelper.Object, environmentVariableHelper.Object, processHelper.Object); - Assert.AreEqual(found, dotnetHostHelper.TryGetDotnetPathByArchitecture(targetArchitecture, out string muxerPath)); - Assert.AreEqual(found ? envVars[envVar] : null, muxerPath); + dotnetRootX86 = _muxerHelper.RenameMuxerAndReturnPath(platformSystem, PlatformArchitecture.X86); } - - [DataTestMethod] - [DataRow("DOTNET_ROOT_ARM64", "DOTNET_ROOT", PlatformArchitecture.ARM64, PlatformArchitecture.X64)] - [DataRow("DOTNET_ROOT(x86)", "DOTNET_ROOT", PlatformArchitecture.X86, PlatformArchitecture.X64)] - public void GetDotnetPathByArchitecture_EnvVars_DirectoryNotExists_TryNext(string notExists, string nextEnv, PlatformArchitecture targetAchitecture, PlatformArchitecture platformArchitecture) + string dotnetRoot = _muxerHelper.RenameMuxerAndReturnPath(platformSystem, targetArchitecture); + Dictionary envVars = new() { - // Arrange - string DOTNET_ROOT_X64 = muxerHelper.RenameMuxerAndReturnPath(PlatformOperatingSystem.Windows, PlatformArchitecture.X64); - string DOTNET_ROOT_ARM64 = muxerHelper.RenameMuxerAndReturnPath(PlatformOperatingSystem.Windows, PlatformArchitecture.ARM64); - string DOTNET_ROOT_X86 = muxerHelper.RenameMuxerAndReturnPath(PlatformOperatingSystem.Windows, PlatformArchitecture.X86); - string DOTNET_ROOT = muxerHelper.RenameMuxerAndReturnPath(PlatformOperatingSystem.Windows, targetAchitecture); - Dictionary envVars = new Dictionary() - { - { "DOTNET_ROOT_X64" , DOTNET_ROOT_X64}, - { "DOTNET_ROOT_ARM64" , DOTNET_ROOT_ARM64}, - { "DOTNET_ROOT(x86)" , DOTNET_ROOT_X86}, - { "DOTNET_ROOT" , DOTNET_ROOT}, - }; - - environmentHelper.SetupGet(x => x.Architecture).Returns(platformArchitecture); - environmentHelper.SetupGet(x => x.OperatingSystem).Returns(PlatformOperatingSystem.Windows); - environmentVariableHelper.Setup(x => x.GetEnvironmentVariable(notExists)).Returns(Path.GetDirectoryName(envVars[notExists])); - environmentVariableHelper.Setup(x => x.GetEnvironmentVariable(nextEnv)).Returns(Path.GetDirectoryName(envVars[nextEnv])); - fileHelper.Setup(x => x.DirectoryExists(Path.GetDirectoryName(envVars[nextEnv]))).Returns(true); - fileHelper.Setup(x => x.Exists(envVars[nextEnv])).Returns(true); - fileHelper.Setup(x => x.GetStream(envVars[nextEnv], FileMode.Open, FileAccess.Read)).Returns(File.OpenRead(envVars[nextEnv])); - - //Act & Assert - var dotnetHostHelper = new DotnetHostHelper(fileHelper.Object, environmentHelper.Object, windowsRegistrytHelper.Object, environmentVariableHelper.Object, processHelper.Object); - Assert.IsTrue(dotnetHostHelper.TryGetDotnetPathByArchitecture(targetAchitecture, out string muxerPath)); - Assert.AreEqual(envVars[nextEnv], muxerPath); - } - - [DataTestMethod] - [DataRow(PlatformArchitecture.X64, PlatformArchitecture.X64, true)] - [DataRow(PlatformArchitecture.X64, PlatformArchitecture.X86, false)] - public void GetDotnetPathByArchitecture_GlobalInstallation_Windows(PlatformArchitecture muxerArchitecture, PlatformArchitecture targetArchitecture, bool found) + { "DOTNET_ROOT_X64", dotnetRootX64 }, + { "DOTNET_ROOT_ARM64", dotnetRootArm64 }, + { "DOTNET_ROOT(x86)", dotnetRootX86 }, + { "DOTNET_ROOT", dotnetRoot }, + }; + + _environmentHelper.SetupGet(x => x.Architecture).Returns(platformArchitecture); + _environmentHelper.SetupGet(x => x.OperatingSystem).Returns(platformSystem); + _environmentVariableHelper.Setup(x => x.GetEnvironmentVariable(envVar)).Returns(Path.GetDirectoryName(envVars[envVar])); + _environmentVariableHelper.Setup(x => x.GetEnvironmentVariable("ProgramFiles")).Returns("notfound"); + _fileHelper.Setup(x => x.DirectoryExists(Path.GetDirectoryName(envVars[envVar]))).Returns(true); + _fileHelper.Setup(x => x.Exists(envVars[envVar])).Returns(true); + if (found) { - // Arrange - string dotnetMuxer = muxerHelper.RenameMuxerAndReturnPath(PlatformOperatingSystem.Windows, muxerArchitecture); - Mock installedVersionKey = new Mock(); - Mock architectureSubKey = new Mock(); - Mock nativeArchSubKey = new Mock(); - installedVersionKey.Setup(x => x.OpenSubKey(It.IsAny())).Returns(architectureSubKey.Object); - architectureSubKey.Setup(x => x.OpenSubKey(It.IsAny())).Returns(nativeArchSubKey.Object); - nativeArchSubKey.Setup(x => x.GetValue(It.IsAny())).Returns(Path.GetDirectoryName(dotnetMuxer)); - this.windowsRegistrytHelper.Setup(x => x.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)).Returns(installedVersionKey.Object); - this.fileHelper.Setup(x => x.Exists(dotnetMuxer)).Returns(true); - this.fileHelper.Setup(x => x.GetStream(dotnetMuxer, FileMode.Open, FileAccess.Read)).Returns(File.OpenRead(dotnetMuxer)); - - //Act & Assert - var dotnetHostHelper = new DotnetHostHelper(fileHelper.Object, environmentHelper.Object, windowsRegistrytHelper.Object, environmentVariableHelper.Object, processHelper.Object); - Assert.AreEqual(found, dotnetHostHelper.TryGetDotnetPathByArchitecture(targetArchitecture, out string muxerPath)); - Assert.AreEqual(found ? dotnetMuxer : null, muxerPath); + _fileHelper.Setup(x => x.GetStream(envVars[envVar], FileMode.Open, FileAccess.Read)).Returns(File.OpenRead(envVars[envVar])); } - [DataTestMethod] - [DataRow(true, false, false, false)] - [DataRow(false, true, false, false)] - [DataRow(false, false, true, false)] - [DataRow(false, false, false, true)] - public void GetDotnetPathByArchitecture_GlobalInstallation_NullSubkeys(bool nullInstalledVersion, bool nullArchitecture, bool nullNative, bool nullInstallLocation) - { - // Arrange - Mock installedVersionKey = new Mock(); - Mock architectureSubKey = new Mock(); - Mock nativeArchSubKey = new Mock(); - installedVersionKey.Setup(x => x.OpenSubKey(It.IsAny())).Returns(nullArchitecture ? null : architectureSubKey.Object); - architectureSubKey.Setup(x => x.OpenSubKey(It.IsAny())).Returns(nullNative ? null : nativeArchSubKey.Object); - nativeArchSubKey.Setup(x => x.GetValue(It.IsAny())).Returns(nullInstallLocation ? null : ""); - this.windowsRegistrytHelper.Setup(x => x.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)).Returns(nullInstalledVersion ? null : installedVersionKey.Object); - this.environmentVariableHelper.Setup(x => x.GetEnvironmentVariable("ProgramFiles")).Returns("notfound"); - - //Act & Assert - var dotnetHostHelper = new DotnetHostHelper(fileHelper.Object, environmentHelper.Object, windowsRegistrytHelper.Object, environmentVariableHelper.Object, processHelper.Object); - Assert.IsFalse(dotnetHostHelper.TryGetDotnetPathByArchitecture(PlatformArchitecture.X64, out string muxerPath)); - } + // Act & Assert + var dotnetHostHelper = new DotnetHostHelper(_fileHelper.Object, _environmentHelper.Object, _windowsRegistrytHelper.Object, _environmentVariableHelper.Object, _processHelper.Object); + Assert.AreEqual(found, dotnetHostHelper.TryGetDotnetPathByArchitecture(targetArchitecture, out string muxerPath)); + Assert.AreEqual(found ? envVars[envVar] : null, muxerPath); + } - [DataTestMethod] - [DataRow(PlatformArchitecture.ARM64, "/etc/dotnet/install_location_arm64", true, PlatformOperatingSystem.OSX)] - [DataRow(PlatformArchitecture.X64, "/etc/dotnet/install_location_x64", true, PlatformOperatingSystem.OSX)] - [DataRow(PlatformArchitecture.ARM64, "/etc/dotnet/install_location", true, PlatformOperatingSystem.OSX)] - [DataRow(PlatformArchitecture.X64, "/etc/dotnet/install_location", true, PlatformOperatingSystem.OSX)] - [DataRow(PlatformArchitecture.ARM64, "/etc/dotnet/install_location_x64", false, PlatformOperatingSystem.OSX)] - - [DataRow(PlatformArchitecture.ARM64, "/etc/dotnet/install_location_arm64", false, PlatformOperatingSystem.Unix)] - [DataRow(PlatformArchitecture.X64, "/etc/dotnet/install_location_x64", false, PlatformOperatingSystem.Unix)] - [DataRow(PlatformArchitecture.ARM64, "/etc/dotnet/install_location", false, PlatformOperatingSystem.Unix)] - [DataRow(PlatformArchitecture.X64, "/etc/dotnet/install_location", false, PlatformOperatingSystem.Unix)] - [DataRow(PlatformArchitecture.ARM64, "/etc/dotnet/install_location_x64", false, PlatformOperatingSystem.Unix)] - public void GetDotnetPathByArchitecture_GlobalInstallation_Unix(PlatformArchitecture targetArchitecture, string install_location, bool found, PlatformOperatingSystem os) + [DataTestMethod] + [DataRow("DOTNET_ROOT_ARM64", "DOTNET_ROOT", PlatformArchitecture.ARM64, PlatformArchitecture.X64)] + [DataRow("DOTNET_ROOT(x86)", "DOTNET_ROOT", PlatformArchitecture.X86, PlatformArchitecture.X64)] + public void GetDotnetPathByArchitecture_EnvVars_DirectoryNotExists_TryNext(string notExists, string nextEnv, PlatformArchitecture targetAchitecture, PlatformArchitecture platformArchitecture) + { + // Arrange + string dotnetRootX64 = _muxerHelper.RenameMuxerAndReturnPath(PlatformOperatingSystem.Windows, PlatformArchitecture.X64); + string dotnetRootArm64 = _muxerHelper.RenameMuxerAndReturnPath(PlatformOperatingSystem.Windows, PlatformArchitecture.ARM64); + string dotnetRootX86 = _muxerHelper.RenameMuxerAndReturnPath(PlatformOperatingSystem.Windows, PlatformArchitecture.X86); + string dotnetRoot = _muxerHelper.RenameMuxerAndReturnPath(PlatformOperatingSystem.Windows, targetAchitecture); + Dictionary envVars = new() { - // Arrange - string dotnetMuxer = muxerHelper.RenameMuxerAndReturnPath(os, targetArchitecture); - this.environmentHelper.SetupGet(x => x.OperatingSystem).Returns(os); - this.fileHelper.Setup(x => x.Exists(install_location)).Returns(true); - this.fileHelper.Setup(x => x.Exists(dotnetMuxer)).Returns(true); - this.fileHelper.Setup(x => x.GetStream(install_location, FileMode.Open, FileAccess.Read)).Returns(new MemoryStream(Encoding.UTF8.GetBytes(Path.GetDirectoryName(dotnetMuxer)))); - if (found) - { - this.fileHelper.Setup(x => x.GetStream(dotnetMuxer, FileMode.Open, FileAccess.Read)).Returns(File.OpenRead(dotnetMuxer)); - } + { "DOTNET_ROOT_X64", dotnetRootX64 }, + { "DOTNET_ROOT_ARM64", dotnetRootArm64 }, + { "DOTNET_ROOT(x86)", dotnetRootX86 }, + { "DOTNET_ROOT", dotnetRoot }, + }; + + _environmentHelper.SetupGet(x => x.Architecture).Returns(platformArchitecture); + _environmentHelper.SetupGet(x => x.OperatingSystem).Returns(PlatformOperatingSystem.Windows); + _environmentVariableHelper.Setup(x => x.GetEnvironmentVariable(notExists)).Returns(Path.GetDirectoryName(envVars[notExists])); + _environmentVariableHelper.Setup(x => x.GetEnvironmentVariable(nextEnv)).Returns(Path.GetDirectoryName(envVars[nextEnv])); + _fileHelper.Setup(x => x.DirectoryExists(Path.GetDirectoryName(envVars[nextEnv]))).Returns(true); + _fileHelper.Setup(x => x.Exists(envVars[nextEnv])).Returns(true); + _fileHelper.Setup(x => x.GetStream(envVars[nextEnv], FileMode.Open, FileAccess.Read)).Returns(File.OpenRead(envVars[nextEnv])); + + //Act & Assert + var dotnetHostHelper = new DotnetHostHelper(_fileHelper.Object, _environmentHelper.Object, _windowsRegistrytHelper.Object, _environmentVariableHelper.Object, _processHelper.Object); + Assert.IsTrue(dotnetHostHelper.TryGetDotnetPathByArchitecture(targetAchitecture, out string muxerPath)); + Assert.AreEqual(envVars[nextEnv], muxerPath); + } - //Act & Assert - var dotnetHostHelper = new DotnetHostHelper(fileHelper.Object, environmentHelper.Object, windowsRegistrytHelper.Object, environmentVariableHelper.Object, processHelper.Object); - Assert.AreEqual(found, dotnetHostHelper.TryGetDotnetPathByArchitecture(targetArchitecture, out string muxerPath)); - Assert.AreEqual(found ? dotnetMuxer : null, muxerPath); - } + [DataTestMethod] + [DataRow(PlatformArchitecture.X64, PlatformArchitecture.X64, true)] + [DataRow(PlatformArchitecture.X64, PlatformArchitecture.X86, false)] + public void GetDotnetPathByArchitecture_GlobalInstallation_Windows(PlatformArchitecture muxerArchitecture, PlatformArchitecture targetArchitecture, bool found) + { + // Arrange + string dotnetMuxer = _muxerHelper.RenameMuxerAndReturnPath(PlatformOperatingSystem.Windows, muxerArchitecture); + Mock installedVersionKey = new(); + Mock architectureSubKey = new(); + Mock nativeArchSubKey = new(); + installedVersionKey.Setup(x => x.OpenSubKey(It.IsAny())).Returns(architectureSubKey.Object); + architectureSubKey.Setup(x => x.OpenSubKey(It.IsAny())).Returns(nativeArchSubKey.Object); + nativeArchSubKey.Setup(x => x.GetValue(It.IsAny())).Returns(Path.GetDirectoryName(dotnetMuxer)); + _windowsRegistrytHelper.Setup(x => x.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)).Returns(installedVersionKey.Object); + _fileHelper.Setup(x => x.Exists(dotnetMuxer)).Returns(true); + _fileHelper.Setup(x => x.GetStream(dotnetMuxer, FileMode.Open, FileAccess.Read)).Returns(File.OpenRead(dotnetMuxer)); + + //Act & Assert + var dotnetHostHelper = new DotnetHostHelper(_fileHelper.Object, _environmentHelper.Object, _windowsRegistrytHelper.Object, _environmentVariableHelper.Object, _processHelper.Object); + Assert.AreEqual(found, dotnetHostHelper.TryGetDotnetPathByArchitecture(targetArchitecture, out string muxerPath)); + Assert.AreEqual(found ? dotnetMuxer : null, muxerPath); + } - [DataTestMethod] - [DataRow(PlatformArchitecture.X86, PlatformArchitecture.X64, "ProgramFiles(x86)", "dotnet", true)] - [DataRow(PlatformArchitecture.X64, PlatformArchitecture.ARM64, "ProgramFiles", @"dotnet\x64", true)] - [DataRow(PlatformArchitecture.X64, PlatformArchitecture.X64, "ProgramFiles", "dotnet", true)] - [DataRow(PlatformArchitecture.X86, PlatformArchitecture.X86, "ProgramFiles", "dotnet", true)] - [DataRow(PlatformArchitecture.X64, PlatformArchitecture.X64, "ProgramFiles", "dotnet", false)] - [TestCategory("Windows")] - public void GetDotnetPathByArchitecture_DefaultInstallation_Win(PlatformArchitecture targetArchitecture, PlatformArchitecture platformArchitecture, string envVar, string subfolder, bool found) - { - // Arrange - string dotnetMuxer = muxerHelper.RenameMuxerAndReturnPath(PlatformOperatingSystem.Windows, targetArchitecture, subfolder); - this.environmentVariableHelper.Setup(x => x.GetEnvironmentVariable(envVar)).Returns(dotnetMuxer.Replace(Path.Combine(subfolder, "dotnet.exe"), string.Empty)); - this.environmentHelper.Setup(x => x.Architecture).Returns(platformArchitecture); - if (found) - { - this.fileHelper.Setup(x => x.Exists(dotnetMuxer)).Returns(true); - this.fileHelper.Setup(x => x.GetStream(dotnetMuxer, FileMode.Open, FileAccess.Read)).Returns(new MemoryStream(Encoding.UTF8.GetBytes(Path.GetDirectoryName(dotnetMuxer)))); - this.fileHelper.Setup(x => x.GetStream(dotnetMuxer, FileMode.Open, FileAccess.Read)).Returns(File.OpenRead(dotnetMuxer)); - } + [DataTestMethod] + [DataRow(true, false, false, false)] + [DataRow(false, true, false, false)] + [DataRow(false, false, true, false)] + [DataRow(false, false, false, true)] + public void GetDotnetPathByArchitecture_GlobalInstallation_NullSubkeys(bool nullInstalledVersion, bool nullArchitecture, bool nullNative, bool nullInstallLocation) + { + // Arrange + Mock installedVersionKey = new(); + Mock architectureSubKey = new(); + Mock nativeArchSubKey = new(); + installedVersionKey.Setup(x => x.OpenSubKey(It.IsAny())).Returns(nullArchitecture ? null : architectureSubKey.Object); + architectureSubKey.Setup(x => x.OpenSubKey(It.IsAny())).Returns(nullNative ? null : nativeArchSubKey.Object); + nativeArchSubKey.Setup(x => x.GetValue(It.IsAny())).Returns(nullInstallLocation ? null : ""); + _windowsRegistrytHelper.Setup(x => x.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)).Returns(nullInstalledVersion ? null : installedVersionKey.Object); + _environmentVariableHelper.Setup(x => x.GetEnvironmentVariable("ProgramFiles")).Returns("notfound"); + + //Act & Assert + var dotnetHostHelper = new DotnetHostHelper(_fileHelper.Object, _environmentHelper.Object, _windowsRegistrytHelper.Object, _environmentVariableHelper.Object, _processHelper.Object); + Assert.IsFalse(dotnetHostHelper.TryGetDotnetPathByArchitecture(PlatformArchitecture.X64, out string muxerPath)); + } - //Act & Assert - var dotnetHostHelper = new DotnetHostHelper(fileHelper.Object, environmentHelper.Object, windowsRegistrytHelper.Object, environmentVariableHelper.Object, processHelper.Object); - Assert.AreEqual(found, dotnetHostHelper.TryGetDotnetPathByArchitecture(targetArchitecture, out string muxerPath)); - Assert.AreEqual(found ? dotnetMuxer : null, muxerPath); + [DataTestMethod] + [DataRow(PlatformArchitecture.ARM64, "/etc/dotnet/install_location_arm64", true, PlatformOperatingSystem.OSX)] + [DataRow(PlatformArchitecture.X64, "/etc/dotnet/install_location_x64", true, PlatformOperatingSystem.OSX)] + [DataRow(PlatformArchitecture.ARM64, "/etc/dotnet/install_location", true, PlatformOperatingSystem.OSX)] + [DataRow(PlatformArchitecture.X64, "/etc/dotnet/install_location", true, PlatformOperatingSystem.OSX)] + [DataRow(PlatformArchitecture.ARM64, "/etc/dotnet/install_location_x64", false, PlatformOperatingSystem.OSX)] + + [DataRow(PlatformArchitecture.ARM64, "/etc/dotnet/install_location_arm64", false, PlatformOperatingSystem.Unix)] + [DataRow(PlatformArchitecture.X64, "/etc/dotnet/install_location_x64", false, PlatformOperatingSystem.Unix)] + [DataRow(PlatformArchitecture.ARM64, "/etc/dotnet/install_location", false, PlatformOperatingSystem.Unix)] + [DataRow(PlatformArchitecture.X64, "/etc/dotnet/install_location", false, PlatformOperatingSystem.Unix)] + [DataRow(PlatformArchitecture.ARM64, "/etc/dotnet/install_location_x64", false, PlatformOperatingSystem.Unix)] + public void GetDotnetPathByArchitecture_GlobalInstallation_Unix(PlatformArchitecture targetArchitecture, string installLocation, bool found, PlatformOperatingSystem os) + { + // Arrange + string dotnetMuxer = _muxerHelper.RenameMuxerAndReturnPath(os, targetArchitecture); + _environmentHelper.SetupGet(x => x.OperatingSystem).Returns(os); + _fileHelper.Setup(x => x.Exists(installLocation)).Returns(true); + _fileHelper.Setup(x => x.Exists(dotnetMuxer)).Returns(true); + _fileHelper.Setup(x => x.GetStream(installLocation, FileMode.Open, FileAccess.Read)).Returns(new MemoryStream(Encoding.UTF8.GetBytes(Path.GetDirectoryName(dotnetMuxer)))); + if (found) + { + _fileHelper.Setup(x => x.GetStream(dotnetMuxer, FileMode.Open, FileAccess.Read)).Returns(File.OpenRead(dotnetMuxer)); } - [DataTestMethod] - [DataRow(PlatformArchitecture.X64, PlatformArchitecture.X64, "/usr/local/share/dotnet", "", true, PlatformOperatingSystem.OSX)] - [DataRow(PlatformArchitecture.X64, PlatformArchitecture.ARM64, "/usr/local/share/dotnet/x64", "", true, PlatformOperatingSystem.OSX)] - [DataRow(PlatformArchitecture.ARM64, PlatformArchitecture.X64, "/usr/local/share/dotnet", "", true, PlatformOperatingSystem.OSX)] - [DataRow(PlatformArchitecture.X64, PlatformArchitecture.X64, "/usr/local/share/dotnet", "", false, PlatformOperatingSystem.OSX)] - - [DataRow(PlatformArchitecture.X64, PlatformArchitecture.X64, "/usr/share/dotnet", "", false, PlatformOperatingSystem.Unix)] - [DataRow(PlatformArchitecture.X64, PlatformArchitecture.ARM64, "/usr/share/dotnet/x64", "", false, PlatformOperatingSystem.Unix)] - [DataRow(PlatformArchitecture.ARM64, PlatformArchitecture.X64, "/usr/share/dotnet", "", false, PlatformOperatingSystem.Unix)] - [DataRow(PlatformArchitecture.X64, PlatformArchitecture.X64, "/usr/share/dotnet", "", false, PlatformOperatingSystem.Unix)] - public void GetDotnetPathByArchitecture_DefaultInstallation_Unix(PlatformArchitecture targetArchitecture, PlatformArchitecture platformArchitecture, string expectedFolder, string subfolder, bool found, PlatformOperatingSystem os) + //Act & Assert + var dotnetHostHelper = new DotnetHostHelper(_fileHelper.Object, _environmentHelper.Object, _windowsRegistrytHelper.Object, _environmentVariableHelper.Object, _processHelper.Object); + Assert.AreEqual(found, dotnetHostHelper.TryGetDotnetPathByArchitecture(targetArchitecture, out string muxerPath)); + Assert.AreEqual(found ? dotnetMuxer : null, muxerPath); + } + + [DataTestMethod] + [DataRow(PlatformArchitecture.X86, PlatformArchitecture.X64, "ProgramFiles(x86)", "dotnet", true)] + [DataRow(PlatformArchitecture.X64, PlatformArchitecture.ARM64, "ProgramFiles", @"dotnet\x64", true)] + [DataRow(PlatformArchitecture.X64, PlatformArchitecture.X64, "ProgramFiles", "dotnet", true)] + [DataRow(PlatformArchitecture.X86, PlatformArchitecture.X86, "ProgramFiles", "dotnet", true)] + [DataRow(PlatformArchitecture.X64, PlatformArchitecture.X64, "ProgramFiles", "dotnet", false)] + [TestCategory("Windows")] + public void GetDotnetPathByArchitecture_DefaultInstallation_Win(PlatformArchitecture targetArchitecture, PlatformArchitecture platformArchitecture, string envVar, string subfolder, bool found) + { + // Arrange + string dotnetMuxer = _muxerHelper.RenameMuxerAndReturnPath(PlatformOperatingSystem.Windows, targetArchitecture, subfolder); + _environmentVariableHelper.Setup(x => x.GetEnvironmentVariable(envVar)).Returns(dotnetMuxer.Replace(Path.Combine(subfolder, "dotnet.exe"), string.Empty)); + _environmentHelper.Setup(x => x.Architecture).Returns(platformArchitecture); + if (found) { - // Arrange - string dotnetMuxer = muxerHelper.RenameMuxerAndReturnPath(os, targetArchitecture, subfolder); - this.environmentHelper.SetupGet(x => x.OperatingSystem).Returns(os); - this.environmentHelper.Setup(x => x.Architecture).Returns(platformArchitecture); - string expectedMuxerPath = Path.Combine(expectedFolder, "dotnet"); - this.fileHelper.Setup(x => x.Exists(expectedMuxerPath)).Returns(true); - this.fileHelper.Setup(x => x.GetStream(expectedMuxerPath, FileMode.Open, FileAccess.Read)).Returns(new MemoryStream(Encoding.UTF8.GetBytes(Path.GetDirectoryName(dotnetMuxer)))); - if (found) - { - this.fileHelper.Setup(x => x.GetStream(expectedMuxerPath, FileMode.Open, FileAccess.Read)).Returns(File.OpenRead(dotnetMuxer)); - } + _fileHelper.Setup(x => x.Exists(dotnetMuxer)).Returns(true); + _fileHelper.Setup(x => x.GetStream(dotnetMuxer, FileMode.Open, FileAccess.Read)).Returns(new MemoryStream(Encoding.UTF8.GetBytes(Path.GetDirectoryName(dotnetMuxer)))); + _fileHelper.Setup(x => x.GetStream(dotnetMuxer, FileMode.Open, FileAccess.Read)).Returns(File.OpenRead(dotnetMuxer)); + } - //Act & Assert - var dotnetHostHelper = new DotnetHostHelper(fileHelper.Object, environmentHelper.Object, windowsRegistrytHelper.Object, environmentVariableHelper.Object, processHelper.Object); - Assert.AreEqual(found, dotnetHostHelper.TryGetDotnetPathByArchitecture(targetArchitecture, out string muxerPath)); - Assert.AreEqual(found ? expectedMuxerPath : null, muxerPath); + //Act & Assert + var dotnetHostHelper = new DotnetHostHelper(_fileHelper.Object, _environmentHelper.Object, _windowsRegistrytHelper.Object, _environmentVariableHelper.Object, _processHelper.Object); + Assert.AreEqual(found, dotnetHostHelper.TryGetDotnetPathByArchitecture(targetArchitecture, out string muxerPath)); + Assert.AreEqual(found ? dotnetMuxer : null, muxerPath); + } + + [DataTestMethod] + [DataRow(PlatformArchitecture.X64, PlatformArchitecture.X64, "/usr/local/share/dotnet", "", true, PlatformOperatingSystem.OSX)] + [DataRow(PlatformArchitecture.X64, PlatformArchitecture.ARM64, "/usr/local/share/dotnet/x64", "", true, PlatformOperatingSystem.OSX)] + [DataRow(PlatformArchitecture.ARM64, PlatformArchitecture.X64, "/usr/local/share/dotnet", "", true, PlatformOperatingSystem.OSX)] + [DataRow(PlatformArchitecture.X64, PlatformArchitecture.X64, "/usr/local/share/dotnet", "", false, PlatformOperatingSystem.OSX)] + + [DataRow(PlatformArchitecture.X64, PlatformArchitecture.X64, "/usr/share/dotnet", "", false, PlatformOperatingSystem.Unix)] + [DataRow(PlatformArchitecture.X64, PlatformArchitecture.ARM64, "/usr/share/dotnet/x64", "", false, PlatformOperatingSystem.Unix)] + [DataRow(PlatformArchitecture.ARM64, PlatformArchitecture.X64, "/usr/share/dotnet", "", false, PlatformOperatingSystem.Unix)] + [DataRow(PlatformArchitecture.X64, PlatformArchitecture.X64, "/usr/share/dotnet", "", false, PlatformOperatingSystem.Unix)] + public void GetDotnetPathByArchitecture_DefaultInstallation_Unix(PlatformArchitecture targetArchitecture, PlatformArchitecture platformArchitecture, string expectedFolder, string subfolder, bool found, PlatformOperatingSystem os) + { + // Arrange + string dotnetMuxer = _muxerHelper.RenameMuxerAndReturnPath(os, targetArchitecture, subfolder); + _environmentHelper.SetupGet(x => x.OperatingSystem).Returns(os); + _environmentHelper.Setup(x => x.Architecture).Returns(platformArchitecture); + string expectedMuxerPath = Path.Combine(expectedFolder, "dotnet"); + _fileHelper.Setup(x => x.Exists(expectedMuxerPath)).Returns(true); + _fileHelper.Setup(x => x.GetStream(expectedMuxerPath, FileMode.Open, FileAccess.Read)).Returns(new MemoryStream(Encoding.UTF8.GetBytes(Path.GetDirectoryName(dotnetMuxer)))); + if (found) + { + _fileHelper.Setup(x => x.GetStream(expectedMuxerPath, FileMode.Open, FileAccess.Read)).Returns(File.OpenRead(dotnetMuxer)); } - public void Dispose() => this.muxerHelper.Dispose(); + //Act & Assert + var dotnetHostHelper = new DotnetHostHelper(_fileHelper.Object, _environmentHelper.Object, _windowsRegistrytHelper.Object, _environmentVariableHelper.Object, _processHelper.Object); + Assert.AreEqual(found, dotnetHostHelper.TryGetDotnetPathByArchitecture(targetArchitecture, out string muxerPath)); + Assert.AreEqual(found ? expectedMuxerPath : null, muxerPath); + } + public void Dispose() => _muxerHelper.Dispose(); - class MockMuxerHelper : IDisposable + + class MockMuxerHelper : IDisposable + { + private static readonly string DotnetMuxerWinX86 = "TestAssets/dotnetWinX86.exe"; + private static readonly string DotnetMuxerWinX64 = "TestAssets/dotnetWinX64.exe"; + private static readonly string DotnetMuxerWinArm64 = "TestAssets/dotnetWinArm64.exe"; + private static readonly string DotnetMuxerMacArm64 = "TestAssets/dotnetMacArm64"; + private static readonly string DotnetMuxerMacX64 = "TestAssets/dotnetMacX64"; + private readonly List _muxers = new(); + + public MockMuxerHelper() { - private static string DotnetMuxerWinX86 = "TestAssets/dotnetWinX86.exe"; - private static string DotnetMuxerWinX64 = "TestAssets/dotnetWinX64.exe"; - private static string DotnetMuxerWinArm64 = "TestAssets/dotnetWinArm64.exe"; - private static string DotnetMuxerMacArm64 = "TestAssets/dotnetMacArm64"; - private static string DotnetMuxerMacX64 = "TestAssets/dotnetMacX64"; - private readonly List muxers = new List(); - - public MockMuxerHelper() - { - Assert.IsTrue(File.Exists(DotnetMuxerWinX86)); - Assert.IsTrue(File.Exists(DotnetMuxerWinX64)); - Assert.IsTrue(File.Exists(DotnetMuxerWinArm64)); - Assert.IsTrue(File.Exists(DotnetMuxerMacArm64)); - Assert.IsTrue(File.Exists(DotnetMuxerMacX64)); - } + Assert.IsTrue(File.Exists(DotnetMuxerWinX86)); + Assert.IsTrue(File.Exists(DotnetMuxerWinX64)); + Assert.IsTrue(File.Exists(DotnetMuxerWinArm64)); + Assert.IsTrue(File.Exists(DotnetMuxerMacArm64)); + Assert.IsTrue(File.Exists(DotnetMuxerMacX64)); + } - public string RenameMuxerAndReturnPath(PlatformOperatingSystem platform, PlatformArchitecture architecture, string subfolder = "") + public string RenameMuxerAndReturnPath(PlatformOperatingSystem platform, PlatformArchitecture architecture, string subfolder = "") + { + string tmpDirectory = Path.GetTempPath(); + string muxerPath; + switch (platform) { - string tmpDirectory = Path.GetTempPath(); - string muxerPath; - switch (platform) - { - case PlatformOperatingSystem.Windows: + case PlatformOperatingSystem.Windows: + { + muxerPath = Path.Combine(tmpDirectory, Guid.NewGuid().ToString("N"), subfolder, "dotnet.exe"); + Directory.CreateDirectory(Path.GetDirectoryName(muxerPath)); + if (architecture == PlatformArchitecture.ARM64) { - muxerPath = Path.Combine(tmpDirectory, Guid.NewGuid().ToString("N"), subfolder, "dotnet.exe"); - Directory.CreateDirectory(Path.GetDirectoryName(muxerPath)); - if (architecture == PlatformArchitecture.ARM64) - { - File.Copy(DotnetMuxerWinArm64, muxerPath); - break; - } - else if (architecture == PlatformArchitecture.X64) - { - File.Copy(DotnetMuxerWinX64, muxerPath); - break; - } - else if (architecture == PlatformArchitecture.X86) - { - File.Copy(DotnetMuxerWinX86, muxerPath); - break; - } - - throw new NotSupportedException($"Unsupported architecture '{architecture}'"); + File.Copy(DotnetMuxerWinArm64, muxerPath); + break; } - case PlatformOperatingSystem.OSX: + else if (architecture == PlatformArchitecture.X64) { - muxerPath = Path.Combine(tmpDirectory, Guid.NewGuid().ToString("N"), subfolder, "dotnet"); - Directory.CreateDirectory(Path.GetDirectoryName(muxerPath)); - if (architecture == PlatformArchitecture.ARM64) - { - File.Copy(DotnetMuxerMacArm64, muxerPath); - break; - } - else if (architecture == PlatformArchitecture.X64) - { - File.Copy(DotnetMuxerMacX64, muxerPath); - break; - } - - throw new NotSupportedException($"Unsupported architecture '{architecture}'"); + File.Copy(DotnetMuxerWinX64, muxerPath); + break; } - case PlatformOperatingSystem.Unix: + else if (architecture == PlatformArchitecture.X86) { - muxerPath = Path.Combine(tmpDirectory, Guid.NewGuid().ToString("N"), subfolder, "dotnet"); - Directory.CreateDirectory(Path.GetDirectoryName(muxerPath)); - File.WriteAllText(muxerPath, "not supported"); + File.Copy(DotnetMuxerWinX86, muxerPath); break; } - default: - throw new NotSupportedException($"Unsupported OS '{platform}'"); - } - muxers.Add(muxerPath); - return muxerPath; + throw new NotSupportedException($"Unsupported architecture '{architecture}'"); + } + case PlatformOperatingSystem.OSX: + { + muxerPath = Path.Combine(tmpDirectory, Guid.NewGuid().ToString("N"), subfolder, "dotnet"); + Directory.CreateDirectory(Path.GetDirectoryName(muxerPath)); + if (architecture == PlatformArchitecture.ARM64) + { + File.Copy(DotnetMuxerMacArm64, muxerPath); + break; + } + else if (architecture == PlatformArchitecture.X64) + { + File.Copy(DotnetMuxerMacX64, muxerPath); + break; + } + + throw new NotSupportedException($"Unsupported architecture '{architecture}'"); + } + case PlatformOperatingSystem.Unix: + { + muxerPath = Path.Combine(tmpDirectory, Guid.NewGuid().ToString("N"), subfolder, "dotnet"); + Directory.CreateDirectory(Path.GetDirectoryName(muxerPath)); + File.WriteAllText(muxerPath, "not supported"); + break; + } + default: + throw new NotSupportedException($"Unsupported OS '{platform}'"); } - public void Dispose() + _muxers.Add(muxerPath); + return muxerPath; + } + + public void Dispose() + { + foreach (var muxer in _muxers) { - foreach (var muxer in muxers) - { - Directory.Delete(Path.GetDirectoryName(muxer), true); - } + Directory.Delete(Path.GetDirectoryName(muxer), true); } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/EnvironmentHelperTests.cs b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/EnvironmentHelperTests.cs index 35124678e4..dbd13240de 100644 --- a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/EnvironmentHelperTests.cs +++ b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/EnvironmentHelperTests.cs @@ -1,63 +1,63 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CoreUtilities.UnitTests.Helpers +namespace Microsoft.TestPlatform.CoreUtilities.UnitTests.Helpers; + +using System; + +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class EnvironmentHelperTests { - using System; + private static readonly int DefaultTimeout = 90; + [TestCleanup] + public void Cleanup() + { + Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, string.Empty); + } + + [TestMethod] + public void GetConnectionTimeoutShouldReturnDefaultValue() + { + Assert.AreEqual(DefaultTimeout, EnvironmentHelper.GetConnectionTimeout()); + } + + [TestMethod] + public void GetConnectionTimeoutShouldReturnEnvVariableValueIfSet() + { + var val = 100; + Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, val.ToString()); + Assert.AreEqual(val, EnvironmentHelper.GetConnectionTimeout()); + } + + [TestMethod] + public void GetConnectionTimeoutShouldReturnDefaultOnNegativeValue() + { + Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, "-1"); + Assert.AreEqual(DefaultTimeout, EnvironmentHelper.GetConnectionTimeout()); + } - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; - using Microsoft.VisualStudio.TestTools.UnitTesting; + [TestMethod] + public void GetConnectionTimeoutShouldReturnZeroOnEnvVariableValueZero() + { + Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, "0"); + Assert.AreEqual(0, EnvironmentHelper.GetConnectionTimeout()); + } + + [TestMethod] + public void GetConnectionTimeoutShouldReturnDefaultOnEnvVariableValueDecimal() + { + Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, "10.4"); + Assert.AreEqual(DefaultTimeout, EnvironmentHelper.GetConnectionTimeout()); + } - [TestClass] - public class EnvironmentHelperTests + [TestMethod] + public void GetConnectionTimeoutShouldReturnDefaultOnInvalidValue() { - private static readonly int DefaultTimeout = 90; - [TestCleanup] - public void Cleanup() - { - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, string.Empty); - } - - [TestMethod] - public void GetConnectionTimeoutShouldReturnDefaultValue() - { - Assert.AreEqual(EnvironmentHelperTests.DefaultTimeout, EnvironmentHelper.GetConnectionTimeout()); - } - - [TestMethod] - public void GetConnectionTimeoutShouldReturnEnvVariableValueIfSet() - { - var val = 100; - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, val.ToString()); - Assert.AreEqual(val, EnvironmentHelper.GetConnectionTimeout()); - } - - [TestMethod] - public void GetConnectionTimeoutShouldReturnDefaultOnNegativeValue() - { - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, "-1"); - Assert.AreEqual(EnvironmentHelperTests.DefaultTimeout, EnvironmentHelper.GetConnectionTimeout()); - } - - [TestMethod] - public void GetConnectionTimeoutShouldReturnZeroOnEnvVariableValueZero() - { - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, "0"); - Assert.AreEqual(0, EnvironmentHelper.GetConnectionTimeout()); - } - - [TestMethod] - public void GetConnectionTimeoutShouldReturnDefaultOnEnvVariableValueDecimal() - { - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, "10.4"); - Assert.AreEqual(EnvironmentHelperTests.DefaultTimeout, EnvironmentHelper.GetConnectionTimeout()); - } - - [TestMethod] - public void GetConnectionTimeoutShouldReturnDefaultOnInvalidValue() - { - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, "InvalidValue"); - Assert.AreEqual(EnvironmentHelperTests.DefaultTimeout, EnvironmentHelper.GetConnectionTimeout()); - } + Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, "InvalidValue"); + Assert.AreEqual(DefaultTimeout, EnvironmentHelper.GetConnectionTimeout()); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/FileHelperTests.cs b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/FileHelperTests.cs index a7660bb127..9271339088 100644 --- a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/FileHelperTests.cs +++ b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/FileHelperTests.cs @@ -1,41 +1,36 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CoreUtilities.UnitTests.Helpers +namespace Microsoft.TestPlatform.CoreUtilities.UnitTests.Helpers; + +using System.IO; +using VisualStudio.TestTools.UnitTesting; +using VisualStudio.TestPlatform.Utilities.Helpers; + +[TestClass] +public class FileHelperTests { - using System.IO; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using VisualStudio.TestPlatform.Utilities.Helpers; + private readonly FileHelper _fileHelper; + private readonly string _tempFile; - [TestClass] - public class FileHelperTests + public FileHelperTests() { - private readonly FileHelper fileHelper; - private readonly string tempFile; - - public FileHelperTests() - { - this.tempFile = Path.GetTempFileName(); - File.AppendAllText(this.tempFile, "Some content.."); - this.fileHelper = new FileHelper(); - } + _tempFile = Path.GetTempFileName(); + File.AppendAllText(_tempFile, "Some content.."); + _fileHelper = new FileHelper(); + } - [TestCleanup] - public void Cleanup() - { - File.Delete(this.tempFile); - } + [TestCleanup] + public void Cleanup() + { + File.Delete(_tempFile); + } - [TestMethod] - public void GetStreamShouldAbleToGetTwoStreamSimultanouslyIfFileAccessIsRead() - { - using (var stream1 = this.fileHelper.GetStream(this.tempFile, FileMode.Open, FileAccess.Read)) - { - using (var stream2 = - this.fileHelper.GetStream(this.tempFile, FileMode.Open, FileAccess.Read)) - { - } - } - } + [TestMethod] + public void GetStreamShouldAbleToGetTwoStreamSimultanouslyIfFileAccessIsRead() + { + using var stream1 = _fileHelper.GetStream(_tempFile, FileMode.Open, FileAccess.Read); + using var stream2 = + _fileHelper.GetStream(_tempFile, FileMode.Open, FileAccess.Read); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Output/OutputExtensionsTests.cs b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Output/OutputExtensionsTests.cs index 3e73efdfcb..a9b3350a25 100644 --- a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Output/OutputExtensionsTests.cs +++ b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Output/OutputExtensionsTests.cs @@ -1,159 +1,152 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CoreUtilities.UnitTests.Output +namespace Microsoft.TestPlatform.CoreUtilities.UnitTests.Output; + +using VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using Moq; +using System; + +[TestClass] +public class OutputExtensionsTests { - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Moq; - using System; + private readonly Mock _mockOutput; + private ConsoleColor _color; + private readonly ConsoleColor _previousColor; + private readonly ConsoleColor _newColor; - [TestClass] - public class OutputExtensionsTests + public OutputExtensionsTests() { - private Mock mockOutput; - private ConsoleColor color; - private ConsoleColor previousColor; - private ConsoleColor newColor; + // Setting Console.ForegroundColor to newColor which will be used to determine whether + // test command output is redirecting to file or writing to console. + // If command output is redirecting to file, then Console.ForegroundColor can't be modified. + // So that tests which assert Console.ForegroundColor should not run. + _previousColor = Console.ForegroundColor; + _newColor = _previousColor == ConsoleColor.Gray + ? ConsoleColor.Black + : ConsoleColor.Blue; + Console.ForegroundColor = _newColor; + + _mockOutput = new Mock(); + _color = Console.ForegroundColor; + _mockOutput.Setup(o => o.WriteLine(It.IsAny(), It.IsAny())).Callback(() => _color = Console.ForegroundColor); + } - public OutputExtensionsTests() - { - // Setting Console.ForegroundColor to newColor which will be used to determine whether - // test command output is redirecting to file or writing to console. - // If command output is redirecting to file, then Console.ForegroundColor can't be modified. - // So that tests which assert Console.ForegroundColor should not run. - this.previousColor = Console.ForegroundColor; - this.newColor = previousColor == ConsoleColor.Gray - ? ConsoleColor.Black - : ConsoleColor.Blue; - Console.ForegroundColor = this.newColor; - - this.mockOutput = new Mock(); - this.color = Console.ForegroundColor; - this.mockOutput.Setup(o => o.WriteLine(It.IsAny(), It.IsAny())).Callback(() => - { - this.color = Console.ForegroundColor; - }); - } + [TestCleanup] + public void CleanUp() + { + Console.ForegroundColor = _previousColor; + } - [TestCleanup] - public void CleanUp() - { - Console.ForegroundColor = previousColor; - } + [TestMethod] + public void OutputErrorForSimpleMessageShouldOutputTheMessageString() + { + _mockOutput.Object.Error(false, "HelloError", null); + _mockOutput.Verify(o => o.WriteLine("HelloError", OutputLevel.Error), Times.Once()); + } - [TestMethod] - public void OutputErrorForSimpleMessageShouldOutputTheMessageString() - { - this.mockOutput.Object.Error(false, "HelloError", null); - this.mockOutput.Verify(o => o.WriteLine("HelloError", OutputLevel.Error), Times.Once()); - } + [TestMethod] + public void OutputErrorForSimpleMessageShouldOutputTheMessageStringWithPrefixIfSet() + { + _mockOutput.Object.Error(true, "HelloError", null); + _mockOutput.Verify(o => o.WriteLine("Error: HelloError", OutputLevel.Error), Times.Once()); + } - [TestMethod] - public void OutputErrorForSimpleMessageShouldOutputTheMessageStringWithPrefixIfSet() + [TestMethod] + public void OutputErrorForSimpleMessageShouldSetConsoleColorToRed() + { + if (CanNotSetConsoleForegroundColor()) { - this.mockOutput.Object.Error(true, "HelloError", null); - this.mockOutput.Verify(o => o.WriteLine("Error: HelloError", OutputLevel.Error), Times.Once()); + return; } - [TestMethod] - public void OutputErrorForSimpleMessageShouldSetConsoleColorToRed() - { - if (CanNotSetConsoleForegroundColor()) - { - return; - } + _mockOutput.Object.Error(false, "HelloError", null); + Assert.IsTrue(_color == ConsoleColor.Red, "Console color not set."); + } - this.mockOutput.Object.Error(false, "HelloError", null); - Assert.IsTrue(this.color == ConsoleColor.Red, "Console color not set."); - } + [TestMethod] + public void OutputErrorForMessageWithParamsShouldOutputFormattedMessage() + { + _mockOutput.Object.Error(false, "HelloError {0} {1}", "Foo", "Bar"); + _mockOutput.Verify(o => o.WriteLine("HelloError Foo Bar", OutputLevel.Error), Times.Once()); + } - [TestMethod] - public void OutputErrorForMessageWithParamsShouldOutputFormattedMessage() - { - this.mockOutput.Object.Error(false, "HelloError {0} {1}", "Foo", "Bar"); - this.mockOutput.Verify(o => o.WriteLine("HelloError Foo Bar", OutputLevel.Error), Times.Once()); - } + [TestMethod] + public void OutputWarningForSimpleMessageShouldOutputTheMessageString() + { + _mockOutput.Object.Warning(false, "HelloWarning", null); + _mockOutput.Verify(o => o.WriteLine("HelloWarning", OutputLevel.Warning), Times.Once()); + } - [TestMethod] - public void OutputWarningForSimpleMessageShouldOutputTheMessageString() + [TestMethod] + public void OutputWarningForSimpleMessageShouldSetConsoleColorToYellow() + { + if (CanNotSetConsoleForegroundColor()) { - this.mockOutput.Object.Warning(false, "HelloWarning", null); - this.mockOutput.Verify(o => o.WriteLine("HelloWarning", OutputLevel.Warning), Times.Once()); + return; } - [TestMethod] - public void OutputWarningForSimpleMessageShouldSetConsoleColorToYellow() - { - if (CanNotSetConsoleForegroundColor()) - { - return; - } + _mockOutput.Object.Warning(false, "HelloWarning", null); + Assert.IsTrue(_color == ConsoleColor.Yellow); + } - this.mockOutput.Object.Warning(false, "HelloWarning", null); - Assert.IsTrue(this.color == ConsoleColor.Yellow); - } + [TestMethod] + public void OutputWarningForMessageWithParamsShouldOutputFormattedMessage() + { + _mockOutput.Object.Warning(false, "HelloWarning {0} {1}", "Foo", "Bar"); + _mockOutput.Verify(o => o.WriteLine("HelloWarning Foo Bar", OutputLevel.Warning), Times.Once()); + } - [TestMethod] - public void OutputWarningForMessageWithParamsShouldOutputFormattedMessage() - { - this.mockOutput.Object.Warning(false, "HelloWarning {0} {1}", "Foo", "Bar"); - this.mockOutput.Verify(o => o.WriteLine("HelloWarning Foo Bar", OutputLevel.Warning), Times.Once()); - } + [TestMethod] + public void OutputInformationForSimpleMessageShouldOutputTheMessageString() + { + _mockOutput.Object.Information(false, ConsoleColor.Green, "HelloInformation", null); + _mockOutput.Verify(o => o.WriteLine("HelloInformation", OutputLevel.Information), Times.Once()); + } - [TestMethod] - public void OutputInformationForSimpleMessageShouldOutputTheMessageString() + [TestMethod] + public void OutputInformationForSimpleMessageShouldSetConsoleColorToGivenColor() + { + if (CanNotSetConsoleForegroundColor()) { - this.mockOutput.Object.Information(false, ConsoleColor.Green, "HelloInformation", null); - this.mockOutput.Verify(o => o.WriteLine("HelloInformation", OutputLevel.Information), Times.Once()); + return; } - [TestMethod] - public void OutputInformationForSimpleMessageShouldSetConsoleColorToGivenColor() - { - if (CanNotSetConsoleForegroundColor()) - { - return; - } + _mockOutput.Object.Information(false, ConsoleColor.Green, "HelloInformation", null); + Assert.IsTrue(_color == ConsoleColor.Green); + } - this.mockOutput.Object.Information(false, ConsoleColor.Green, "HelloInformation", null); - Assert.IsTrue(this.color == ConsoleColor.Green); - } + [TestMethod] + public void OutputInformationForMessageWithParamsShouldOutputFormattedMessage() + { + _mockOutput.Object.Information(false, "HelloInformation {0} {1}", "Foo", "Bar"); + _mockOutput.Verify(o => o.WriteLine("HelloInformation Foo Bar", OutputLevel.Information), Times.Once()); + } - [TestMethod] - public void OutputInformationForMessageWithParamsShouldOutputFormattedMessage() + [TestMethod] + public void OutputInformationShouldNotChangeConsoleOutputColor() + { + if (CanNotSetConsoleForegroundColor()) { - this.mockOutput.Object.Information(false, "HelloInformation {0} {1}", "Foo", "Bar"); - this.mockOutput.Verify(o => o.WriteLine("HelloInformation Foo Bar", OutputLevel.Information), Times.Once()); + return; } - [TestMethod] - public void OutputInformationShouldNotChangeConsoleOutputColor() - { - if (CanNotSetConsoleForegroundColor()) - { - return; - } - - ConsoleColor color1 = Console.ForegroundColor, color2 = Console.ForegroundColor == ConsoleColor.Red ? ConsoleColor.Black : ConsoleColor.Red; - this.mockOutput.Setup(o => o.WriteLine(It.IsAny(), It.IsAny())).Callback(() => - { - color2 = Console.ForegroundColor; - }); - - this.mockOutput.Object.Information(false, "HelloInformation {0} {1}", "Foo", "Bar"); - this.mockOutput.Verify(o => o.WriteLine("HelloInformation Foo Bar", OutputLevel.Information), Times.Once()); - Assert.IsTrue(color1 == color2); - } + ConsoleColor color1 = Console.ForegroundColor, color2 = Console.ForegroundColor == ConsoleColor.Red ? ConsoleColor.Black : ConsoleColor.Red; + _mockOutput.Setup(o => o.WriteLine(It.IsAny(), It.IsAny())).Callback(() => color2 = Console.ForegroundColor); - private bool CanNotSetConsoleForegroundColor() + _mockOutput.Object.Information(false, "HelloInformation {0} {1}", "Foo", "Bar"); + _mockOutput.Verify(o => o.WriteLine("HelloInformation Foo Bar", OutputLevel.Information), Times.Once()); + Assert.IsTrue(color1 == color2); + } + + private bool CanNotSetConsoleForegroundColor() + { + if (Console.ForegroundColor != _newColor) { - if (Console.ForegroundColor != this.newColor) - { - Assert.Inconclusive("Can't set Console foreground color. Might be because process output redirect to file."); - return true; - } - return false; + Assert.Inconclusive("Can't set Console foreground color. Might be because process output redirect to file."); + return true; } + return false; } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Program.cs b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Program.cs index 8383a433b0..ebd4142ed4 100644 --- a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Program.cs +++ b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Program.cs @@ -1,14 +1,14 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CoreUtilities.UnitTests +namespace TestPlatform.CoreUtilities.UnitTests; + +/// +/// Main entry point for the command line runner. +/// +public static class Program { - /// - /// Main entry point for the command line runner. - /// - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Tracing/EqtTraceTests.cs b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Tracing/EqtTraceTests.cs index 825c8ad96f..ba936f35da 100644 --- a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Tracing/EqtTraceTests.cs +++ b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Tracing/EqtTraceTests.cs @@ -1,187 +1,182 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CoreUtilities.UnitTests -{ +namespace TestPlatform.CoreUtilities.UnitTests; + #if NETFRAMEWORK - using System.Diagnostics; +using System.Diagnostics; #endif - using System.IO; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using System; +using System.IO; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using System; - [TestClass] - public class EqtTraceTests - { - private static string dirPath = null; - private static string logFile = null; +[TestClass] +public class EqtTraceTests +{ + private static string s_dirPath = null; + private static string s_logFile = null; - [ClassInitialize] - public static void Init(TestContext testContext) + [ClassInitialize] + public static void Init(TestContext testContext) + { + // Set DoNotInitailize to false. + EqtTrace.DoNotInitailize = false; + s_dirPath = Path.Combine(Path.GetTempPath(), "TraceUT"); + try { - // Set DoNotInitailize to false. - EqtTrace.DoNotInitailize = false; - dirPath = Path.Combine(Path.GetTempPath(), "TraceUT"); - try - { - Directory.CreateDirectory(dirPath); - logFile = Path.Combine(dirPath, "trace.log"); - } - catch(Exception ex) - { - Console.WriteLine(ex.Message); - } - - EqtTrace.InitializeTrace(logFile, PlatformTraceLevel.Off); + Directory.CreateDirectory(s_dirPath); + s_logFile = Path.Combine(s_dirPath, "trace.log"); } - - [TestMethod] - public void CheckInitializeLogFileTest() + catch (Exception ex) { - Assert.AreEqual(logFile, EqtTrace.LogFile, "Expected log file to be {0}", logFile); + Console.WriteLine(ex.Message); } - [TestMethod] - public void CheckIfTraceStateIsVerboseEnabled() - { + EqtTrace.InitializeTrace(s_logFile, PlatformTraceLevel.Off); + } + + [TestMethod] + public void CheckInitializeLogFileTest() + { + Assert.AreEqual(s_logFile, EqtTrace.LogFile, "Expected log file to be {0}", s_logFile); + } + + [TestMethod] + public void CheckIfTraceStateIsVerboseEnabled() + { #if NETFRAMEWORK - EqtTrace.TraceLevel = TraceLevel.Verbose; + EqtTrace.TraceLevel = TraceLevel.Verbose; #else - EqtTrace.TraceLevel = PlatformTraceLevel.Verbose; + EqtTrace.TraceLevel = PlatformTraceLevel.Verbose; #endif - Assert.IsTrue(EqtTrace.IsVerboseEnabled, "Expected trace state to be verbose actual state {0}", EqtTrace.IsVerboseEnabled); - } + Assert.IsTrue(EqtTrace.IsVerboseEnabled, "Expected trace state to be verbose actual state {0}", EqtTrace.IsVerboseEnabled); + } - [TestMethod] - public void CheckIfTraceStateIsErrorEnabled() - { + [TestMethod] + public void CheckIfTraceStateIsErrorEnabled() + { #if NETFRAMEWORK - EqtTrace.TraceLevel = TraceLevel.Error; + EqtTrace.TraceLevel = TraceLevel.Error; #else - EqtTrace.TraceLevel = PlatformTraceLevel.Error; + EqtTrace.TraceLevel = PlatformTraceLevel.Error; #endif - Assert.IsTrue(EqtTrace.IsErrorEnabled, "Expected trace state to be error actual state {0}", EqtTrace.IsErrorEnabled); - } + Assert.IsTrue(EqtTrace.IsErrorEnabled, "Expected trace state to be error actual state {0}", EqtTrace.IsErrorEnabled); + } - [TestMethod] - public void CheckIfTraceStateIsInfoEnabled() - { + [TestMethod] + public void CheckIfTraceStateIsInfoEnabled() + { #if NETFRAMEWORK - EqtTrace.TraceLevel = TraceLevel.Info; + EqtTrace.TraceLevel = TraceLevel.Info; #else - EqtTrace.TraceLevel = PlatformTraceLevel.Info; + EqtTrace.TraceLevel = PlatformTraceLevel.Info; #endif - Assert.IsTrue(EqtTrace.IsInfoEnabled, "Expected trace state to be info actual state {0}", EqtTrace.IsInfoEnabled); - } + Assert.IsTrue(EqtTrace.IsInfoEnabled, "Expected trace state to be info actual state {0}", EqtTrace.IsInfoEnabled); + } - [TestMethod] - public void CheckIfTraceStateIsWarningEnabled() - { + [TestMethod] + public void CheckIfTraceStateIsWarningEnabled() + { #if NETFRAMEWORK - EqtTrace.TraceLevel = TraceLevel.Warning; + EqtTrace.TraceLevel = TraceLevel.Warning; #else - EqtTrace.TraceLevel = PlatformTraceLevel.Warning; + EqtTrace.TraceLevel = PlatformTraceLevel.Warning; #endif - Assert.IsTrue(EqtTrace.IsWarningEnabled, "Expected trace state to be warning actual state {0}", EqtTrace.IsWarningEnabled); - } + Assert.IsTrue(EqtTrace.IsWarningEnabled, "Expected trace state to be warning actual state {0}", EqtTrace.IsWarningEnabled); + } - [TestMethod] - public void TraceShouldWriteError() - { + [TestMethod] + public void TraceShouldWriteError() + { #if NETFRAMEWORK - EqtTrace.TraceLevel = TraceLevel.Error; + EqtTrace.TraceLevel = TraceLevel.Error; #else - EqtTrace.TraceLevel = PlatformTraceLevel.Error; + EqtTrace.TraceLevel = PlatformTraceLevel.Error; #endif - EqtTrace.Error(new NotImplementedException()); - Assert.IsNotNull(ReadLogFile(), "Expected error message"); - } + EqtTrace.Error(new NotImplementedException()); + Assert.IsNotNull(ReadLogFile(), "Expected error message"); + } - [TestMethod] - public void TraceShouldWriteWarning() - { + [TestMethod] + public void TraceShouldWriteWarning() + { #if NETFRAMEWORK - EqtTrace.TraceLevel = TraceLevel.Warning; + EqtTrace.TraceLevel = TraceLevel.Warning; #else - EqtTrace.TraceLevel = PlatformTraceLevel.Warning; + EqtTrace.TraceLevel = PlatformTraceLevel.Warning; #endif - EqtTrace.Warning("Dummy Warning Message"); - Assert.IsTrue(ReadLogFile().Contains("Dummy Warning Message"), "Expected Warning message"); - } + EqtTrace.Warning("Dummy Warning Message"); + Assert.IsTrue(ReadLogFile().Contains("Dummy Warning Message"), "Expected Warning message"); + } - [TestMethod] - public void TraceShouldWriteVerbose() - { + [TestMethod] + public void TraceShouldWriteVerbose() + { #if NETFRAMEWORK - EqtTrace.TraceLevel = TraceLevel.Verbose; + EqtTrace.TraceLevel = TraceLevel.Verbose; #else - EqtTrace.TraceLevel = PlatformTraceLevel.Verbose; + EqtTrace.TraceLevel = PlatformTraceLevel.Verbose; #endif - EqtTrace.Verbose("Dummy Verbose Message"); - Assert.IsTrue(ReadLogFile().Contains("Dummy Verbose Message"), "Expected Verbose message"); - } + EqtTrace.Verbose("Dummy Verbose Message"); + Assert.IsTrue(ReadLogFile().Contains("Dummy Verbose Message"), "Expected Verbose message"); + } - [TestMethod] - public void TraceShouldWriteInfo() - { + [TestMethod] + public void TraceShouldWriteInfo() + { #if NETFRAMEWORK - EqtTrace.TraceLevel = TraceLevel.Info; + EqtTrace.TraceLevel = TraceLevel.Info; #else - EqtTrace.TraceLevel = PlatformTraceLevel.Info; + EqtTrace.TraceLevel = PlatformTraceLevel.Info; #endif - EqtTrace.Info("Dummy Info Message"); - Assert.IsTrue(ReadLogFile().Contains("Dummy Info Message"), "Expected Info message"); - } + EqtTrace.Info("Dummy Info Message"); + Assert.IsTrue(ReadLogFile().Contains("Dummy Info Message"), "Expected Info message"); + } - [TestMethod] - public void TraceShouldNotWriteVerboseIfTraceLevelIsInfo() - { + [TestMethod] + public void TraceShouldNotWriteVerboseIfTraceLevelIsInfo() + { #if NETFRAMEWORK - EqtTrace.TraceLevel = TraceLevel.Info; + EqtTrace.TraceLevel = TraceLevel.Info; #else - EqtTrace.TraceLevel = PlatformTraceLevel.Info; + EqtTrace.TraceLevel = PlatformTraceLevel.Info; #endif - EqtTrace.Info("Dummy Info Message"); - EqtTrace.Verbose("Unexpected Dummy Verbose Message"); + EqtTrace.Info("Dummy Info Message"); + EqtTrace.Verbose("Unexpected Dummy Verbose Message"); - var logFileContent = ReadLogFile(); - Assert.IsFalse(logFileContent.Contains("Unexpected Dummy Verbose Message"), "Verbose message not expected"); - Assert.IsTrue(logFileContent.Contains("Dummy Info Message"), "Expected Info message"); - } + var logFileContent = ReadLogFile(); + Assert.IsFalse(logFileContent.Contains("Unexpected Dummy Verbose Message"), "Verbose message not expected"); + Assert.IsTrue(logFileContent.Contains("Dummy Info Message"), "Expected Info message"); + } - [TestMethod] - public void TraceShouldNotWriteIfDoNotInitializationIsSetToTrue() - { - EqtTrace.DoNotInitailize = true; + [TestMethod] + public void TraceShouldNotWriteIfDoNotInitializationIsSetToTrue() + { + EqtTrace.DoNotInitailize = true; #if NETFRAMEWORK - EqtTrace.TraceLevel = TraceLevel.Info; + EqtTrace.TraceLevel = TraceLevel.Info; #else - EqtTrace.TraceLevel = PlatformTraceLevel.Info; + EqtTrace.TraceLevel = PlatformTraceLevel.Info; #endif - EqtTrace.Info("Dummy Info Message: TraceShouldNotWriteIfDoNotInitializationIsSetToTrue"); - Assert.IsFalse(ReadLogFile().Contains("Dummy Info Message: TraceShouldNotWriteIfDoNotInitializationIsSetToTrue"), "Did not expect Dummy Info message"); - } + EqtTrace.Info("Dummy Info Message: TraceShouldNotWriteIfDoNotInitializationIsSetToTrue"); + Assert.IsFalse(ReadLogFile().Contains("Dummy Info Message: TraceShouldNotWriteIfDoNotInitializationIsSetToTrue"), "Did not expect Dummy Info message"); + } - private string ReadLogFile() + private string ReadLogFile() + { + string log = null; + try { - string log = null; - try - { - using (var fs = new FileStream(logFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - { - using (var sr = new StreamReader(fs)) - { - log = sr.ReadToEnd(); - } - } - } - catch(Exception ex) - { - Console.WriteLine(ex.Message); - } - - return log; + using var fs = new FileStream(s_logFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + using var sr = new StreamReader(fs); + log = sr.ReadToEnd(); } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + + return log; } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Utilities/JobQueueTests.cs b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Utilities/JobQueueTests.cs index 5cb90ddbcb..d46ed0291a 100644 --- a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Utilities/JobQueueTests.cs +++ b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Utilities/JobQueueTests.cs @@ -1,536 +1,477 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CoreUtilities.UnitTests -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Threading; +namespace TestPlatform.CoreUtilities.UnitTests; + +using System; +using System.Collections.Generic; +using System.Threading; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestClass] - public class JobQueueTests +[TestClass] +public class JobQueueTests +{ + [TestMethod] + public void ConstructorThrowsWhenNullProcessHandlerIsProvided() { - [TestMethod] - public void ConstructorThrowsWhenNullProcessHandlerIsProvided() - { - JobQueue jobQueue = null; - Assert.ThrowsException(() => - { - jobQueue = new JobQueue(null, "dp", int.MaxValue, int.MaxValue, false, (message) => { }); - }); + JobQueue jobQueue = null; + Assert.ThrowsException(() => jobQueue = new JobQueue(null, "dp", int.MaxValue, int.MaxValue, false, (message) => { })); - if (jobQueue != null) - { - jobQueue.Dispose(); - } + if (jobQueue != null) + { + jobQueue.Dispose(); } + } - [TestMethod] - public void ThrowsWhenNullEmptyOrWhiteSpaceDisplayNameIsProvided() - { - JobQueue jobQueue = null; - Assert.ThrowsException(() => - { - jobQueue = new JobQueue(GetEmptyProcessHandler(), null, int.MaxValue, int.MaxValue, false, (message) => { }); - }); - Assert.ThrowsException(() => - { - jobQueue = new JobQueue(GetEmptyProcessHandler(), "", int.MaxValue, int.MaxValue, false, (message) => { }); - }); - Assert.ThrowsException(() => - { - jobQueue = new JobQueue(GetEmptyProcessHandler(), " ", int.MaxValue, int.MaxValue, false, (message) => { }); - }); + [TestMethod] + public void ThrowsWhenNullEmptyOrWhiteSpaceDisplayNameIsProvided() + { + JobQueue jobQueue = null; + Assert.ThrowsException(() => jobQueue = new JobQueue(GetEmptyProcessHandler(), null, int.MaxValue, int.MaxValue, false, (message) => { })); + Assert.ThrowsException(() => jobQueue = new JobQueue(GetEmptyProcessHandler(), "", int.MaxValue, int.MaxValue, false, (message) => { })); + Assert.ThrowsException(() => jobQueue = new JobQueue(GetEmptyProcessHandler(), " ", int.MaxValue, int.MaxValue, false, (message) => { })); - if (jobQueue != null) - { - jobQueue.Dispose(); - } + if (jobQueue != null) + { + jobQueue.Dispose(); } + } + + [TestMethod] + public void JobsCanBeAddedToTheQueueAndAreProcessedInTheOrderReceived() + { + // Setup the job process handler to keep track of the jobs. + var jobsProcessed = new List(); + Action processHandler = (job) => jobsProcessed.Add(job); + + // Setup Test Data. + var job1 = 1; + var job2 = 2; + var job3 = 3; - [TestMethod] - public void JobsCanBeAddedToTheQueueAndAreProcessedInTheOrderReceived() + // Queue the jobs and verify they are processed in the order added. + using (var queue = new JobQueue(processHandler, "dp", int.MaxValue, int.MaxValue, false, (message) => { })) { - // Setup the job process handler to keep track of the jobs. - var jobsProcessed = new List(); - Action processHandler = (job) => - { - jobsProcessed.Add(job); - }; + queue.QueueJob(job1, 0); + queue.QueueJob(job2, 0); + queue.QueueJob(job3, 0); + } - // Setup Test Data. - var job1 = 1; - var job2 = 2; - var job3 = 3; + Assert.AreEqual(job1, jobsProcessed[0]); + Assert.AreEqual(job2, jobsProcessed[1]); + Assert.AreEqual(job3, jobsProcessed[2]); + } - // Queue the jobs and verify they are processed in the order added. - using (var queue = new JobQueue(processHandler, "dp", int.MaxValue, int.MaxValue, false, (message) => { })) - { - queue.QueueJob(job1, 0); - queue.QueueJob(job2, 0); - queue.QueueJob(job3, 0); - } + [TestMethod] + public void JobsAreProcessedOnABackgroundThread() + { + // Setup the job process handler to keep track of the jobs. + var jobsProcessed = new List(); + Action processHandler = (job) => jobsProcessed.Add(Thread.CurrentThread.ManagedThreadId); - Assert.AreEqual(job1, jobsProcessed[0]); - Assert.AreEqual(job2, jobsProcessed[1]); - Assert.AreEqual(job3, jobsProcessed[2]); + // Queue the jobs and verify they are processed on a background thread. + using (var queue = new JobQueue(processHandler, "dp", int.MaxValue, int.MaxValue, false, (message) => { })) + { + queue.QueueJob("dp", 0); } - [TestMethod] - public void JobsAreProcessedOnABackgroundThread() - { - // Setup the job process handler to keep track of the jobs. - var jobsProcessed = new List(); - Action processHandler = (job) => - { - jobsProcessed.Add(Thread.CurrentThread.ManagedThreadId); - }; + Assert.AreNotEqual(Thread.CurrentThread.ManagedThreadId, jobsProcessed[0]); + } - // Queue the jobs and verify they are processed on a background thread. - using (var queue = new JobQueue(processHandler, "dp", int.MaxValue, int.MaxValue, false, (message) => { })) - { - queue.QueueJob("dp", 0); - } + [TestMethod] + public void ThrowsWhenQueuingAfterDisposed() + { + var queue = new JobQueue(GetEmptyProcessHandler(), "dp", int.MaxValue, int.MaxValue, false, (message) => { }); + queue.Dispose(); - Assert.AreNotEqual(Thread.CurrentThread.ManagedThreadId, jobsProcessed[0]); - } + Assert.ThrowsException(() => queue.QueueJob("dp", 0)); + } - [TestMethod] - public void ThrowsWhenQueuingAfterDisposed() - { - var queue = new JobQueue(GetEmptyProcessHandler(), "dp", int.MaxValue, int.MaxValue, false, (message) => { }); - queue.Dispose(); + [TestMethod] + public void ThrowsWhenResumingAfterDisposed() + { + var queue = new JobQueue(GetEmptyProcessHandler(), "dp", int.MaxValue, int.MaxValue, false, (message) => { }); + queue.Dispose(); - Assert.ThrowsException(() => - { - queue.QueueJob("dp", 0); - }); - } + Assert.ThrowsException(() => queue.Resume()); + } - [TestMethod] - public void ThrowsWhenResumingAfterDisposed() - { - var queue = new JobQueue(GetEmptyProcessHandler(), "dp", int.MaxValue, int.MaxValue, false, (message) => { }); - queue.Dispose(); + [TestMethod] + public void ThrowsWhenPausingAfterDisposed() + { + var queue = new JobQueue(GetEmptyProcessHandler(), "dp", int.MaxValue, int.MaxValue, false, (message) => { }); + queue.Dispose(); - Assert.ThrowsException(() => - { - queue.Resume(); - }); - } + Assert.ThrowsException(() => queue.Pause()); + } - [TestMethod] - public void ThrowsWhenPausingAfterDisposed() - { - var queue = new JobQueue(GetEmptyProcessHandler(), "dp", int.MaxValue, int.MaxValue, false, (message) => { }); - queue.Dispose(); + [TestMethod] + public void ThrowsWhenFlushingAfterDisposed() + { + var queue = new JobQueue(GetEmptyProcessHandler(), "dp", int.MaxValue, int.MaxValue, false, (message) => { }); + queue.Dispose(); - Assert.ThrowsException(() => - { - queue.Pause(); - }); - } + Assert.ThrowsException(() => queue.Flush()); + } - [TestMethod] - public void ThrowsWhenFlushingAfterDisposed() - { - var queue = new JobQueue(GetEmptyProcessHandler(), "dp", int.MaxValue, int.MaxValue, false, (message) => { }); - queue.Dispose(); + [TestMethod] + public void DisposeDoesNotThrowWhenCalledTwice() + { + var queue = new JobQueue(GetEmptyProcessHandler(), "dp", int.MaxValue, int.MaxValue, false, (message) => { }); + queue.Dispose(); + queue.Dispose(); + } - Assert.ThrowsException(() => - { - queue.Flush(); - }); - } + [TestMethod] + public void OncePausedNoFurtherJobsAreProcessedUntilResumeIsCalled() + { + // Setup the job process handler to keep track of the jobs it is called with. + List processedJobs = new(); + Action processHandler = (job) => processedJobs.Add(job); - [TestMethod] - [SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "queue is required to be disposed twice.")] - public void DisposeDoesNotThrowWhenCalledTwice() + // Queue the jobs after paused and verify they are not processed until resumed. + using (var queue = new JobQueue(processHandler, "dp", int.MaxValue, int.MaxValue, false, (message) => { })) { - var queue = new JobQueue(GetEmptyProcessHandler(), "dp", int.MaxValue, int.MaxValue, false, (message) => { }); - queue.Dispose(); - queue.Dispose(); - } + queue.Pause(); + queue.QueueJob("dp", 0); + queue.QueueJob("dp", 0); + queue.QueueJob("dp", 0); - [TestMethod] - public void OncePausedNoFurtherJobsAreProcessedUntilResumeIsCalled() - { - // Setup the job process handler to keep track of the jobs it is called with. - List processedJobs = new List(); - Action processHandler = (job) => - { - processedJobs.Add(job); - }; + // Allow other threads to execute and verify no jobs processed because the queue is paused. + Thread.Sleep(0); + Assert.AreEqual(0, processedJobs.Count); - // Queue the jobs after paused and verify they are not processed until resumed. - using (var queue = new JobQueue(processHandler, "dp", int.MaxValue, int.MaxValue, false, (message) => { })) - { - queue.Pause(); - queue.QueueJob("dp", 0); - queue.QueueJob("dp", 0); - queue.QueueJob("dp", 0); + queue.Resume(); + } - // Allow other threads to execute and verify no jobs processed because the queue is paused. - Thread.Sleep(0); - Assert.AreEqual(0, processedJobs.Count); + Assert.AreEqual(3, processedJobs.Count); + } - queue.Resume(); - } + [TestMethod] + public void ThrowsWhenBeingDisposedWhileQueueIsPaused() + { + using var queue = new JobQueue(GetEmptyProcessHandler(), "dp", int.MaxValue, int.MaxValue, false, (message) => { }); + queue.Pause(); - Assert.AreEqual(3, processedJobs.Count); - } + Assert.ThrowsException(() => queue.Dispose()); - [TestMethod] - public void ThrowsWhenBeingDisposedWhileQueueIsPaused() - { - using (var queue = new JobQueue(GetEmptyProcessHandler(), "dp", int.MaxValue, int.MaxValue, false, (message) => { })) - { - queue.Pause(); + queue.Resume(); + } - Assert.ThrowsException(() => - { - queue.Dispose(); - }); + [TestMethod] + public void FlushMethodWaitsForAllJobsToBeProcessedBeforeReturning() + { + // Setup the job process handler to keep track of the jobs it has processed. + var jobsProcessed = 0; + Action processHandler = (job) => jobsProcessed++; - queue.Resume(); - } - } + // Queue several jobs and verify they have been processed when wait returns. + using var queue = new JobQueue(processHandler, "dp", int.MaxValue, int.MaxValue, false, (message) => { }); + queue.QueueJob("dp", 0); + queue.QueueJob("dp", 0); + queue.QueueJob("dp", 0); - [TestMethod] - public void FlushMethodWaitsForAllJobsToBeProcessedBeforeReturning() - { - // Setup the job process handler to keep track of the jobs it has processed. - var jobsProcessed = 0; - Action processHandler = (job) => - { - jobsProcessed++; - }; + queue.Flush(); - // Queue several jobs and verify they have been processed when wait returns. - using (var queue = new JobQueue(processHandler, "dp", int.MaxValue, int.MaxValue, false, (message) => { })) - { - queue.QueueJob("dp", 0); - queue.QueueJob("dp", 0); - queue.QueueJob("dp", 0); + Assert.AreEqual(3, jobsProcessed); + } - queue.Flush(); + [TestMethod] + public void TestBlockAtEnqueueDueToLength() + { + ManualResetEvent allowJobProcessingHandlerToProceed = new(false); + AutoResetEvent jobProcessed = new(false); - Assert.AreEqual(3, jobsProcessed); + // process handler for the jobs in queue. It blocks on a job till the queue gets full and the handler sets the + // event allowHandlerToProceed. + Action processHandler = (job) => + { + allowJobProcessingHandlerToProceed.WaitOne(); + if (job.Equals("job11", StringComparison.OrdinalIgnoreCase)) + { + jobProcessed.Set(); } - } + }; - [TestMethod] - public void TestBlockAtEnqueueDueToLength() + using JobQueueWrapper queue = new(processHandler, 5, int.MaxValue, true, allowJobProcessingHandlerToProceed); + // run the same thing multiple times to ensure that the queue isn't in a erroneous state after being blocked. + for (int i = 0; i < 10; i++) { - ManualResetEvent allowJobProcessingHandlerToProceed = new ManualResetEvent(false); - AutoResetEvent jobProcessed = new AutoResetEvent(false); + queue.QueueJob("job1", 0); + queue.QueueJob("job2", 0); + queue.QueueJob("job3", 0); + queue.QueueJob("job4", 0); + queue.QueueJob("job5", 0); + + // At this point only 5 jobs have been queued. Even if all are still in queue, still the need to block shouldn't have + // risen. So queue.enteredBlockingMethod would be false. + Assert.IsFalse(queue.IsEnqueueBlocked, "Entered the over-ridden blocking method at a wrong time."); + + queue.QueueJob("job6", 0); + queue.QueueJob("job7", 0); + queue.QueueJob("job8", 0); + queue.QueueJob("job9", 0); + queue.QueueJob("job10", 0); + queue.QueueJob("job11", 0); + + // By this point surely the queue would have blocked at least once, hence setting queue.enteredBlockingMethod true. + Assert.IsTrue(queue.IsEnqueueBlocked, "Did not enter the over-ridden blocking method"); + + // We wait till all jobs are finished, so that for the next iteration the queue is in a deterministic state. + jobProcessed.WaitOne(); + + // queue.enteredBlockingMethod is set to false to check it again in next iteration. Also + // allowJobProcessingHandlerToProceed is reset to block the handler again in next iteration. + queue.IsEnqueueBlocked = false; + allowJobProcessingHandlerToProceed.Reset(); + + // if we reach here it means that the queue was successfully blocked at some point in between job6 and job11 + // and subsequently unblocked. + } + } - // process handler for the jobs in queue. It blocks on a job till the queue gets full and the handler sets the - // event allowHandlerToProceed. - Action processHandler = (job) => - { - allowJobProcessingHandlerToProceed.WaitOne(); - if (job.Equals("job11", StringComparison.OrdinalIgnoreCase)) - { - jobProcessed.Set(); - } - }; - - using (JobQueueWrapper queue = new JobQueueWrapper(processHandler, 5, int.MaxValue, true, allowJobProcessingHandlerToProceed)) + [TestMethod] + public void TestBlockAtEnqueueDueToSize() + { + ManualResetEvent allowJobProcessingHandlerToProceed = new(false); + AutoResetEvent jobProcessed = new(false); + + // process handler for the jobs in queue. It blocks on a job till the queue gets full and the handler sets the + // event allowHandlerToProceed. + Action processHandler = (job) => + { + allowJobProcessingHandlerToProceed.WaitOne(); + if (job.Equals("job11", StringComparison.OrdinalIgnoreCase)) { - // run the same thing multiple times to ensure that the queue isn't in a erroneous state after being blocked. - for (int i = 0; i < 10; i++) - { - queue.QueueJob("job1", 0); - queue.QueueJob("job2", 0); - queue.QueueJob("job3", 0); - queue.QueueJob("job4", 0); - queue.QueueJob("job5", 0); - - // At this point only 5 jobs have been queued. Even if all are still in queue, still the need to block shouldn't have - // risen. So queue.enteredBlockingMethod would be false. - Assert.IsFalse(queue.IsEnqueueBlocked, "Entered the over-ridden blocking method at a wrong time."); - - queue.QueueJob("job6", 0); - queue.QueueJob("job7", 0); - queue.QueueJob("job8", 0); - queue.QueueJob("job9", 0); - queue.QueueJob("job10", 0); - queue.QueueJob("job11", 0); - - // By this point surely the queue would have blocked at least once, hence setting queue.enteredBlockingMethod true. - Assert.IsTrue(queue.IsEnqueueBlocked, "Did not enter the over-ridden blocking method"); - - // We wait till all jobs are finished, so that for the next iteration the queue is in a deterministic state. - jobProcessed.WaitOne(); - - // queue.enteredBlockingMethod is set to false to check it again in next iteration. Also - // allowJobProcessingHandlerToProceed is reset to block the handler again in next iteration. - queue.IsEnqueueBlocked = false; - allowJobProcessingHandlerToProceed.Reset(); - - // if we reach here it means that the queue was successfully blocked at some point in between job6 and job11 - // and subsequently unblocked. - } + jobProcessed.Set(); } - } + }; - [TestMethod] - public void TestBlockAtEnqueueDueToSize() + using JobQueueWrapper queue = new(processHandler, int.MaxValue, 40, true, allowJobProcessingHandlerToProceed); + // run the same thing multiple times to ensure that the queue isn't in a erroneous state after being blocked. + for (int i = 0; i < 10; i++) { - ManualResetEvent allowJobProcessingHandlerToProceed = new ManualResetEvent(false); - AutoResetEvent jobProcessed = new AutoResetEvent(false); + queue.QueueJob("job1", 8); + queue.QueueJob("job2", 8); + queue.QueueJob("job3", 8); + queue.QueueJob("job4", 8); + queue.QueueJob("job5", 8); + + // At this point exactly 80 bytes have been queued. Even if all are still in queue, still the need to block shouldn't + // have risen. So queue.enteredBlockingMethod would be false. + Assert.IsFalse(queue.IsEnqueueBlocked, "Entered the over-ridden blocking method at a wrong time."); + + queue.QueueJob("job6", 8); + queue.QueueJob("job7", 8); + queue.QueueJob("job8", 8); + queue.QueueJob("job9", 8); + queue.QueueJob("job10", 10); + queue.QueueJob("job11", 10); + + // By this point surely the queue would have blocked at least once, hence setting queue.enteredBlockingMethod true. + Assert.IsTrue(queue.IsEnqueueBlocked, "Did not enter the over-ridden blocking method"); + + // We wait till all jobs are finished, so that for the next iteration the queue is in a deterministic state. + jobProcessed.WaitOne(); + + // queue.enteredBlockingMethod is set to false to check it again in next iteration. Also + // allowJobProcessingHandlerToProceed is reset to block the handler again in next iteration. + queue.IsEnqueueBlocked = false; + allowJobProcessingHandlerToProceed.Reset(); + + // if we reach here it means that the queue was successfully blocked at some point in between job6 and job11 + // and subsequently unblocked. + } + } - // process handler for the jobs in queue. It blocks on a job till the queue gets full and the handler sets the - // event allowHandlerToProceed. - Action processHandler = (job) => - { - allowJobProcessingHandlerToProceed.WaitOne(); - if (job.Equals("job11", StringComparison.OrdinalIgnoreCase)) - { - jobProcessed.Set(); - } - }; - - using (JobQueueWrapper queue = new JobQueueWrapper(processHandler, int.MaxValue, 40, true, allowJobProcessingHandlerToProceed)) + [TestMethod] + public void TestBlockingDisabled() + { + ManualResetEvent allowJobProcessingHandlerToProceed = new(false); + AutoResetEvent jobProcessed = new(false); + + // process handler for the jobs in queue. It blocks on a job till the test method sets the + // event allowHandlerToProceed. + Action processHandler = (job) => + { + allowJobProcessingHandlerToProceed.WaitOne(); + if (job.Equals("job5", StringComparison.OrdinalIgnoreCase)) { - // run the same thing multiple times to ensure that the queue isn't in a erroneous state after being blocked. - for (int i = 0; i < 10; i++) - { - queue.QueueJob("job1", 8); - queue.QueueJob("job2", 8); - queue.QueueJob("job3", 8); - queue.QueueJob("job4", 8); - queue.QueueJob("job5", 8); - - // At this point exactly 80 bytes have been queued. Even if all are still in queue, still the need to block shouldn't - // have risen. So queue.enteredBlockingMethod would be false. - Assert.IsFalse(queue.IsEnqueueBlocked, "Entered the over-ridden blocking method at a wrong time."); - - queue.QueueJob("job6", 8); - queue.QueueJob("job7", 8); - queue.QueueJob("job8", 8); - queue.QueueJob("job9", 8); - queue.QueueJob("job10", 10); - queue.QueueJob("job11", 10); - - // By this point surely the queue would have blocked at least once, hence setting queue.enteredBlockingMethod true. - Assert.IsTrue(queue.IsEnqueueBlocked, "Did not enter the over-ridden blocking method"); - - // We wait till all jobs are finished, so that for the next iteration the queue is in a deterministic state. - jobProcessed.WaitOne(); - - // queue.enteredBlockingMethod is set to false to check it again in next iteration. Also - // allowJobProcessingHandlerToProceed is reset to block the handler again in next iteration. - queue.IsEnqueueBlocked = false; - allowJobProcessingHandlerToProceed.Reset(); - - // if we reach here it means that the queue was successfully blocked at some point in between job6 and job11 - // and subsequently unblocked. - } + jobProcessed.Set(); } - } + }; - [TestMethod] - public void TestBlockingDisabled() + using JobQueueWrapper queue = new(processHandler, 2, int.MaxValue, false, allowJobProcessingHandlerToProceed); + // run the same thing multiple times to ensure that the queue isn't in a erroneous state after first run. + for (int i = 0; i < 10; i++) { - ManualResetEvent allowJobProcessingHandlerToProceed = new ManualResetEvent(false); - AutoResetEvent jobProcessed = new AutoResetEvent(false); + queue.QueueJob("job1", 0); + queue.QueueJob("job2", 0); - // process handler for the jobs in queue. It blocks on a job till the test method sets the - // event allowHandlerToProceed. - Action processHandler = (job) => - { - allowJobProcessingHandlerToProceed.WaitOne(); - if (job.Equals("job5", StringComparison.OrdinalIgnoreCase)) - { - jobProcessed.Set(); - } - }; - - using (JobQueueWrapper queue = new JobQueueWrapper(processHandler, 2, int.MaxValue, false, allowJobProcessingHandlerToProceed)) - { - // run the same thing multiple times to ensure that the queue isn't in a erroneous state after first run. - for (int i = 0; i < 10; i++) - { - queue.QueueJob("job1", 0); - queue.QueueJob("job2", 0); - - // At this point only 2 jobs have been queued. Even if all are still in queue, still the need to block shouldn't have - // risen. So queue.enteredBlockingMethod would be false regardless of the blocking disabled or not. - Assert.IsFalse(queue.IsEnqueueBlocked, "Entered the over-ridden blocking method at a wrong time."); + // At this point only 2 jobs have been queued. Even if all are still in queue, still the need to block shouldn't have + // risen. So queue.enteredBlockingMethod would be false regardless of the blocking disabled or not. + Assert.IsFalse(queue.IsEnqueueBlocked, "Entered the over-ridden blocking method at a wrong time."); - queue.QueueJob("job3", 0); - queue.QueueJob("job4", 0); - queue.QueueJob("job5", 0); + queue.QueueJob("job3", 0); + queue.QueueJob("job4", 0); + queue.QueueJob("job5", 0); - // queue.enteredBlockingMethod should still be false as the queue should not have blocked. - Assert.IsFalse(queue.IsEnqueueBlocked, "Entered the over-ridden blocking method though blocking is disabled."); + // queue.enteredBlockingMethod should still be false as the queue should not have blocked. + Assert.IsFalse(queue.IsEnqueueBlocked, "Entered the over-ridden blocking method though blocking is disabled."); - // allow handlers to proceed. - allowJobProcessingHandlerToProceed.Set(); + // allow handlers to proceed. + allowJobProcessingHandlerToProceed.Set(); - // We wait till all jobs are finished, so that for the next iteration the queue is in a deterministic state. - jobProcessed.WaitOne(); + // We wait till all jobs are finished, so that for the next iteration the queue is in a deterministic state. + jobProcessed.WaitOne(); - // queue.enteredBlockingMethod is set to false to check it again in next iteration. Also - // allowJobProcessingHandlerToProceed is reset to allow blocking the handler again in next iteration. - queue.IsEnqueueBlocked = false; - allowJobProcessingHandlerToProceed.Reset(); + // queue.enteredBlockingMethod is set to false to check it again in next iteration. Also + // allowJobProcessingHandlerToProceed is reset to allow blocking the handler again in next iteration. + queue.IsEnqueueBlocked = false; + allowJobProcessingHandlerToProceed.Reset(); - // if we reach here it means that the queue was never blocked. - } - } + // if we reach here it means that the queue was never blocked. } + } - [TestMethod] - public void TestLargeTestResultCanBeLoadedWithBlockingEnabled() - { - var jobProcessed = new AutoResetEvent(false); + [TestMethod] + public void TestLargeTestResultCanBeLoadedWithBlockingEnabled() + { + var jobProcessed = new AutoResetEvent(false); - // process handler for the jobs in queue. - Action processHandler = (job) => - { - jobProcessed.Set(); - }; + // process handler for the jobs in queue. + Action processHandler = (job) => jobProcessed.Set(); - using (JobQueueNonBlocking queue = new JobQueueNonBlocking(processHandler)) - { - // run the same thing multiple times to ensure that the queue isn't in a erroneous state after first run. - for (var i = 0; i < 10; i++) - { - // we try to enqueue a job of size greater than bound on the queue. It should be queued without blocking as - // we check whether or not the queue size has exceeded the limit before actually queuing. - queue.QueueJob("job1", 8); - - // if queue.EnteredBlockingMethod is true, the enqueuing entered the overridden blocking method. This was not - // intended. - Assert.IsFalse(queue.EnteredBlockingMethod, "Entered the over-ridden blocking method."); - jobProcessed.WaitOne(); - } - } + using JobQueueNonBlocking queue = new(processHandler); + // run the same thing multiple times to ensure that the queue isn't in a erroneous state after first run. + for (var i = 0; i < 10; i++) + { + // we try to enqueue a job of size greater than bound on the queue. It should be queued without blocking as + // we check whether or not the queue size has exceeded the limit before actually queuing. + queue.QueueJob("job1", 8); + + // if queue.EnteredBlockingMethod is true, the enqueuing entered the overridden blocking method. This was not + // intended. + Assert.IsFalse(queue.EnteredBlockingMethod, "Entered the over-ridden blocking method."); + jobProcessed.WaitOne(); } + } + + [TestMethod] + [Timeout(60000)] + public void TestDisposeUnblocksBlockedThreads() + { + var allowJobProcessingHandlerToProceed = new ManualResetEvent(false); - [TestMethod] - [Timeout(60000)] - public void TestDisposeUnblocksBlockedThreads() + using var gotBlocked = new ManualResetEvent(false); + var job1Running = new ManualResetEvent(false); + + // process handler for the jobs in queue. It blocks on a job till the test method sets the + // event allowHandlerToProceed. + Action processHandler = (job) => { - var allowJobProcessingHandlerToProceed = new ManualResetEvent(false); + if (job.Equals("job1", StringComparison.OrdinalIgnoreCase)) + job1Running.Set(); - using (var gotBlocked = new ManualResetEvent(false)) - { - var job1Running = new ManualResetEvent(false); - - // process handler for the jobs in queue. It blocks on a job till the test method sets the - // event allowHandlerToProceed. - Action processHandler = (job) => - { - if (job.Equals("job1", StringComparison.OrdinalIgnoreCase)) - job1Running.Set(); - - allowJobProcessingHandlerToProceed.WaitOne(); - }; - - var jobQueue = new JobQueueWrapper(processHandler, 1, int.MaxValue, true, gotBlocked); - - var queueThread = new Thread( - source => - { - jobQueue.QueueJob("job1", 0); - job1Running.WaitOne(); - jobQueue.QueueJob("job2", 0); - jobQueue.QueueJob("job3", 0); - allowJobProcessingHandlerToProceed.Set(); - }); - queueThread.Start(); - - gotBlocked.WaitOne(); - jobQueue.Dispose(); - queueThread.Join(); - } - } + allowJobProcessingHandlerToProceed.WaitOne(); + }; - #region Implementation + var jobQueue = new JobQueueWrapper(processHandler, 1, int.MaxValue, true, gotBlocked); - /// - /// a class that inherits from job queue and over rides the WaitForQueueToEmpty to allow for checking that blocking and - /// unblocking work as expected. - /// - internal class JobQueueWrapper : JobQueue - { - public JobQueueWrapper(Action processJob, - int maxNoOfStringsQueueCanHold, - int maxNoOfBytesQueueCanHold, - bool isBoundsEnabled, - ManualResetEvent queueGotBlocked) - : base(processJob, "foo", maxNoOfStringsQueueCanHold, maxNoOfBytesQueueCanHold, isBoundsEnabled, (message) => { }) + var queueThread = new Thread( + source => { - this.IsEnqueueBlocked = false; - this.queueGotBlocked = queueGotBlocked; - } + jobQueue.QueueJob("job1", 0); + job1Running.WaitOne(); + jobQueue.QueueJob("job2", 0); + jobQueue.QueueJob("job3", 0); + allowJobProcessingHandlerToProceed.Set(); + }); + queueThread.Start(); - protected override bool WaitForQueueToGetEmpty() - { - this.IsEnqueueBlocked = true; - this.queueGotBlocked.Set(); - return base.WaitForQueueToGetEmpty(); - } + gotBlocked.WaitOne(); + jobQueue.Dispose(); + queueThread.Join(); + } - /// - /// Specifies whether enQueue was blocked or not. - /// - public bool IsEnqueueBlocked - { - get; - set; - } + #region Implementation + + /// + /// a class that inherits from job queue and over rides the WaitForQueueToEmpty to allow for checking that blocking and + /// unblocking work as expected. + /// + internal class JobQueueWrapper : JobQueue + { + public JobQueueWrapper(Action processJob, + int maxNoOfStringsQueueCanHold, + int maxNoOfBytesQueueCanHold, + bool isBoundsEnabled, + ManualResetEvent queueGotBlocked) + : base(processJob, "foo", maxNoOfStringsQueueCanHold, maxNoOfBytesQueueCanHold, isBoundsEnabled, (message) => { }) + { + IsEnqueueBlocked = false; + _queueGotBlocked = queueGotBlocked; + } - private ManualResetEvent queueGotBlocked; + protected override bool WaitForQueueToGetEmpty() + { + IsEnqueueBlocked = true; + _queueGotBlocked.Set(); + return base.WaitForQueueToGetEmpty(); } /// - /// a class that inherits from job queue and over rides the WaitForQueueToEmpty to simply setting a boolean to tell - /// whether or not the queue entered the blocking method during the enqueue process. + /// Specifies whether enQueue was blocked or not. /// - internal class JobQueueNonBlocking : JobQueue + public bool IsEnqueueBlocked { - public JobQueueNonBlocking(Action processHandler) - : base(processHandler, "foo", 1, 5, true, (message) => { }) - { - EnteredBlockingMethod = false; - } + get; + set; + } - public bool EnteredBlockingMethod { get; private set; } + private readonly ManualResetEvent _queueGotBlocked; + } - protected override bool WaitForQueueToGetEmpty() - { - EnteredBlockingMethod = true; - return true; - } + /// + /// a class that inherits from job queue and over rides the WaitForQueueToEmpty to simply setting a boolean to tell + /// whether or not the queue entered the blocking method during the enqueue process. + /// + internal class JobQueueNonBlocking : JobQueue + { + public JobQueueNonBlocking(Action processHandler) + : base(processHandler, "foo", 1, 5, true, (message) => { }) + { + EnteredBlockingMethod = false; } - #endregion - - #region Utility Methods + public bool EnteredBlockingMethod { get; private set; } - /// - /// Returns a job processing handler which does nothing. - /// - /// Type of job the handler processes. - /// Job processing handler which does nothing. - private static Action GetEmptyProcessHandler() + protected override bool WaitForQueueToGetEmpty() { - Action handler = (job) => - { - }; - - return handler; + EnteredBlockingMethod = true; + return true; } + } + + #endregion + + #region Utility Methods - #endregion + /// + /// Returns a job processing handler which does nothing. + /// + /// Type of job the handler processes. + /// Job processing handler which does nothing. + private static Action GetEmptyProcessHandler() + { + Action handler = (job) => + { + }; + + return handler; } -} + + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Utilities/TimeSpanParserTests.cs b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Utilities/TimeSpanParserTests.cs index 471a0bbe69..0959b3cff9 100644 --- a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Utilities/TimeSpanParserTests.cs +++ b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Utilities/TimeSpanParserTests.cs @@ -1,87 +1,87 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CoreUtilities.UnitTests -{ - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System; +namespace TestPlatform.CoreUtilities.UnitTests; - [TestClass] - public class TimeSpanParserTests - { - [TestMethod] - // core use cases - [DataRow("5400000")] - [DataRow("5400000ms")] - [DataRow("5400s")] - [DataRow("90m")] - [DataRow("1.5h")] - [DataRow("0.0625d")] +using Microsoft.VisualStudio.TestPlatform.Utilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using System; + +[TestClass] +public class TimeSpanParserTests +{ + [TestMethod] + // core use cases + [DataRow("5400000")] + [DataRow("5400000ms")] + [DataRow("5400s")] + [DataRow("90m")] + [DataRow("1.5h")] + [DataRow("0.0625d")] - // with space for parsing from xml - [DataRow("5400000 ms")] - [DataRow("5400 s")] - [DataRow("90 m")] - [DataRow("1.5 h")] - [DataRow("0.0625 d")] + // with space for parsing from xml + [DataRow("5400000 ms")] + [DataRow("5400 s")] + [DataRow("90 m")] + [DataRow("1.5 h")] + [DataRow("0.0625 d")] - // nice to haves - [DataRow("5400000MS")] - [DataRow("5400000millisecond")] - [DataRow("5400000milliseconds")] - [DataRow("5400000mil")] - [DataRow("5400000milisecond")] - [DataRow("5400000miliseconds")] - [DataRow("5400000mils")] - [DataRow("5400000millis")] - [DataRow("5400000millisecs")] - [DataRow("5400000milisecs")] - [DataRow("5400S")] - [DataRow("5400second")] - [DataRow("5400seconds")] - [DataRow("5400sec")] - [DataRow("5400secs")] - [DataRow("90M")] - [DataRow("90minute")] - [DataRow("90minutes")] - [DataRow("90min")] - [DataRow("90mins")] - [DataRow("1.5H")] - [DataRow("1.5hour")] - [DataRow("1.5hours")] - [DataRow("1.5hrs")] - [DataRow("1.5hr")] - [DataRow("0.0625D")] - [DataRow("0.0625day")] - [DataRow("0.0625days")] - public void Parses90Minutes(string time) - { - Assert.IsTrue(TimeSpanParser.TryParse(time, out var t)); - Assert.AreEqual(TimeSpan.FromMinutes(90), t); - } + // nice to haves + [DataRow("5400000MS")] + [DataRow("5400000millisecond")] + [DataRow("5400000milliseconds")] + [DataRow("5400000mil")] + [DataRow("5400000milisecond")] + [DataRow("5400000miliseconds")] + [DataRow("5400000mils")] + [DataRow("5400000millis")] + [DataRow("5400000millisecs")] + [DataRow("5400000milisecs")] + [DataRow("5400S")] + [DataRow("5400second")] + [DataRow("5400seconds")] + [DataRow("5400sec")] + [DataRow("5400secs")] + [DataRow("90M")] + [DataRow("90minute")] + [DataRow("90minutes")] + [DataRow("90min")] + [DataRow("90mins")] + [DataRow("1.5H")] + [DataRow("1.5hour")] + [DataRow("1.5hours")] + [DataRow("1.5hrs")] + [DataRow("1.5hr")] + [DataRow("0.0625D")] + [DataRow("0.0625day")] + [DataRow("0.0625days")] + public void Parses90Minutes(string time) + { + Assert.IsTrue(TimeSpanParser.TryParse(time, out var t)); + Assert.AreEqual(TimeSpan.FromMinutes(90), t); + } - [TestMethod] - [DataRow(null)] - [DataRow("")] - [DataRow(" ")] - [DataRow("\n")] - [DataRow("\t")] - public void ReturnsEmptyTimeSpanOnNullOrWhiteSpace(string time) - { - Assert.IsTrue(TimeSpanParser.TryParse(time, out var t)); - Assert.AreEqual(TimeSpan.Zero, t); - } + [TestMethod] + [DataRow(null)] + [DataRow("")] + [DataRow(" ")] + [DataRow("\n")] + [DataRow("\t")] + public void ReturnsEmptyTimeSpanOnNullOrWhiteSpace(string time) + { + Assert.IsTrue(TimeSpanParser.TryParse(time, out var t)); + Assert.AreEqual(TimeSpan.Zero, t); + } - [TestMethod] - [DataRow("09808asf")] - [DataRow("asfsadf")] - [DataRow("min")] - [DataRow("ms")] - [DataRow("1.1.1")] - public void ReturnsFalseForInvalidInput(string time) - { - Assert.IsFalse(TimeSpanParser.TryParse(time, out var _)); - } + [TestMethod] + [DataRow("09808asf")] + [DataRow("asfsadf")] + [DataRow("min")] + [DataRow("ms")] + [DataRow("1.1.1")] + public void ReturnsFalseForInvalidInput(string time) + { + Assert.IsFalse(TimeSpanParser.TryParse(time, out var _)); } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Adapter/FrameworkHandleTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Adapter/FrameworkHandleTests.cs index 033c571c21..8a205083fc 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Adapter/FrameworkHandleTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Adapter/FrameworkHandleTests.cs @@ -1,106 +1,105 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Adapter -{ - using System; +namespace TestPlatform.CrossPlatEngine.UnitTests.Adapter; + +using System; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; +using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; +using Moq; - [TestClass] - public class FrameworkHandleTests +[TestClass] +public class FrameworkHandleTests +{ + [TestMethod] + public void EnableShutdownAfterTestRunShoudBeFalseByDefault() { - [TestMethod] - public void EnableShutdownAfterTestRunShoudBeFalseByDefault() - { - var tec = GetTestExecutionContext(); - var frameworkHandle = new FrameworkHandle(null, new TestRunCache(100, TimeSpan.MaxValue, (s, r, ip) => { }), tec, null); + var tec = GetTestExecutionContext(); + var frameworkHandle = new FrameworkHandle(null, new TestRunCache(100, TimeSpan.MaxValue, (s, r, ip) => { }), tec, null); - Assert.IsFalse(frameworkHandle.EnableShutdownAfterTestRun); - } + Assert.IsFalse(frameworkHandle.EnableShutdownAfterTestRun); + } - [TestMethod] - public void EnableShutdownAfterTestRunShoudBeSetAppropriately() - { - var tec = GetTestExecutionContext(); - var frameworkHandle = new FrameworkHandle(null, new TestRunCache(100, TimeSpan.MaxValue, (s, r, ip) => { }), tec, null); + [TestMethod] + public void EnableShutdownAfterTestRunShoudBeSetAppropriately() + { + var tec = GetTestExecutionContext(); + var frameworkHandle = new FrameworkHandle(null, new TestRunCache(100, TimeSpan.MaxValue, (s, r, ip) => { }), tec, null); - frameworkHandle.EnableShutdownAfterTestRun = true; + frameworkHandle.EnableShutdownAfterTestRun = true; - Assert.IsTrue(frameworkHandle.EnableShutdownAfterTestRun); - } + Assert.IsTrue(frameworkHandle.EnableShutdownAfterTestRun); + } - [TestMethod] - public void LaunchProcessWithDebuggerAttachedShouldThrowIfObjectIsDisposed() - { - var tec = GetTestExecutionContext(); - var frameworkHandle = new FrameworkHandle(null, new TestRunCache(100, TimeSpan.MaxValue, (s, r, ip) => { }), tec, null); - frameworkHandle.Dispose(); + [TestMethod] + public void LaunchProcessWithDebuggerAttachedShouldThrowIfObjectIsDisposed() + { + var tec = GetTestExecutionContext(); + var frameworkHandle = new FrameworkHandle(null, new TestRunCache(100, TimeSpan.MaxValue, (s, r, ip) => { }), tec, null); + frameworkHandle.Dispose(); - Assert.ThrowsException(() => frameworkHandle.LaunchProcessWithDebuggerAttached(null, null, null, null)); - } + Assert.ThrowsException(() => frameworkHandle.LaunchProcessWithDebuggerAttached(null, null, null, null)); + } - // TODO: Enable method once we fix the "IsDebug" in TestExecutionContext - // [TestMethod] - public void LaunchProcessWithDebuggerAttachedShouldThrowIfNotInDebugContext() + // TODO: Enable method once we fix the "IsDebug" in TestExecutionContext + // [TestMethod] + public void LaunchProcessWithDebuggerAttachedShouldThrowIfNotInDebugContext() + { + var tec = GetTestExecutionContext(); + var frameworkHandle = new FrameworkHandle(null, new TestRunCache(100, TimeSpan.MaxValue, (s, r, ip) => { }), tec, null); + + var isExceptionThrown = false; + try { - var tec = GetTestExecutionContext(); - var frameworkHandle = new FrameworkHandle(null, new TestRunCache(100, TimeSpan.MaxValue, (s, r, ip) => { }), tec, null); - - var isExceptionThrown = false; - try - { - frameworkHandle.LaunchProcessWithDebuggerAttached(null, null, null, null); - } - catch (InvalidOperationException exception) - { - isExceptionThrown = true; - Assert.AreEqual("This operation is not allowed in the context of a non-debug run.", exception.Message); - } - - Assert.IsTrue(isExceptionThrown); + frameworkHandle.LaunchProcessWithDebuggerAttached(null, null, null, null); } - - [TestMethod] - public void LaunchProcessWithDebuggerAttachedShouldCallRunEventsHandler() + catch (InvalidOperationException exception) { - var tec = GetTestExecutionContext(); - tec.IsDebug = true; - var mockTestRunEventsHandler = new Mock(); + isExceptionThrown = true; + Assert.AreEqual("This operation is not allowed in the context of a non-debug run.", exception.Message); + } - var frameworkHandle = new FrameworkHandle( - null, - new TestRunCache(100, TimeSpan.MaxValue, (s, r, ip) => { }), - tec, - mockTestRunEventsHandler.Object); + Assert.IsTrue(isExceptionThrown); + } - frameworkHandle.LaunchProcessWithDebuggerAttached(null, null, null, null); + [TestMethod] + public void LaunchProcessWithDebuggerAttachedShouldCallRunEventsHandler() + { + var tec = GetTestExecutionContext(); + tec.IsDebug = true; + var mockTestRunEventsHandler = new Mock(); - mockTestRunEventsHandler.Verify(mt => - mt.LaunchProcessWithDebuggerAttached(It.IsAny()), Times.Once); - } + var frameworkHandle = new FrameworkHandle( + null, + new TestRunCache(100, TimeSpan.MaxValue, (s, r, ip) => { }), + tec, + mockTestRunEventsHandler.Object); - private static TestExecutionContext GetTestExecutionContext() - { - var tec = new TestExecutionContext( - frequencyOfRunStatsChangeEvent: 100, - runStatsChangeEventTimeout: TimeSpan.MaxValue, - inIsolation: false, - keepAlive: false, - isDataCollectionEnabled: false, - areTestCaseLevelEventsRequired: false, - hasTestRun: false, - isDebug: false, - testCaseFilter: string.Empty, - filterOptions: null); - return tec; - } + frameworkHandle.LaunchProcessWithDebuggerAttached(null, null, null, null); + + mockTestRunEventsHandler.Verify(mt => + mt.LaunchProcessWithDebuggerAttached(It.IsAny()), Times.Once); + } + + private static TestExecutionContext GetTestExecutionContext() + { + var tec = new TestExecutionContext( + frequencyOfRunStatsChangeEvent: 100, + runStatsChangeEventTimeout: TimeSpan.MaxValue, + inIsolation: false, + keepAlive: false, + isDataCollectionEnabled: false, + areTestCaseLevelEventsRequired: false, + hasTestRun: false, + isDebug: false, + testCaseFilter: string.Empty, + filterOptions: null); + return tec; } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Adapter/RunContextTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Adapter/RunContextTests.cs index 88a2b62a5c..13bf71a865 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Adapter/RunContextTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Adapter/RunContextTests.cs @@ -1,66 +1,63 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Adapter -{ - using System.Collections.Generic; +namespace TestPlatform.CrossPlatEngine.UnitTests.Adapter; - using Microsoft.VisualStudio.TestPlatform.Common.Filtering; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using MSTest.TestFramework.AssertExtensions; +using System.Collections.Generic; - [TestClass] - public class RunContextTests - { - private RunContext runContext; +using Microsoft.VisualStudio.TestPlatform.Common.Filtering; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter; +using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestInitialize] - public void TestInit() - { - this.runContext = new RunContext(); - } +[TestClass] +public class RunContextTests +{ + private RunContext _runContext; - [TestMethod] - public void GetTestCaseFilterShouldReturnNullIfFilterExpressionIsNull() - { - this.runContext.FilterExpressionWrapper = null; + [TestInitialize] + public void TestInit() + { + _runContext = new RunContext(); + } - Assert.IsNull(this.runContext.GetTestCaseFilter(null, (s) => { return null; })); - } + [TestMethod] + public void GetTestCaseFilterShouldReturnNullIfFilterExpressionIsNull() + { + _runContext.FilterExpressionWrapper = null; - /// - /// If only property value passed, consider property key and operation defaults. - /// - [TestMethod] - public void GetTestCaseFilterShouldNotThrowIfPropertyValueOnlyPassed() - { - this.runContext.FilterExpressionWrapper = new FilterExpressionWrapper("Infinity"); + Assert.IsNull(_runContext.GetTestCaseFilter(null, (s) => null)); + } - var filter = this.runContext.GetTestCaseFilter(new List{ "FullyQualifiedName" }, (s) => { return null; }); + /// + /// If only property value passed, consider property key and operation defaults. + /// + [TestMethod] + public void GetTestCaseFilterShouldNotThrowIfPropertyValueOnlyPassed() + { + _runContext.FilterExpressionWrapper = new FilterExpressionWrapper("Infinity"); + + var filter = _runContext.GetTestCaseFilter(new List { "FullyQualifiedName" }, (s) => null); - Assert.IsNotNull(filter); - } + Assert.IsNotNull(filter); + } - [TestMethod] - public void GetTestCaseFilterShouldNotThrowOnInvalidProperties() - { - this.runContext.FilterExpressionWrapper = new FilterExpressionWrapper("highlyunlikelyproperty=unused"); + [TestMethod] + public void GetTestCaseFilterShouldNotThrowOnInvalidProperties() + { + _runContext.FilterExpressionWrapper = new FilterExpressionWrapper("highlyunlikelyproperty=unused"); - var filter = this.runContext.GetTestCaseFilter(new List { "TestCategory" }, (s) => { return null; }); + var filter = _runContext.GetTestCaseFilter(new List { "TestCategory" }, (s) => null); - Assert.IsNotNull(filter); - } + Assert.IsNotNull(filter); + } - [TestMethod] - public void GetTestCaseFilterShouldReturnTestCaseFilter() - { - this.runContext.FilterExpressionWrapper = new FilterExpressionWrapper("TestCategory=Important"); - var filter = this.runContext.GetTestCaseFilter(new List { "TestCategory" }, (s) => { return null; }); + [TestMethod] + public void GetTestCaseFilterShouldReturnTestCaseFilter() + { + _runContext.FilterExpressionWrapper = new FilterExpressionWrapper("TestCategory=Important"); + var filter = _runContext.GetTestCaseFilter(new List { "TestCategory" }, (s) => null); - Assert.IsNotNull(filter); - Assert.AreEqual("TestCategory=Important", filter.TestCaseFilterValue); - } + Assert.IsNotNull(filter); + Assert.AreEqual("TestCategory=Important", filter.TestCaseFilterValue); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Adapter/TestExecutionRecorderTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Adapter/TestExecutionRecorderTests.cs index 1754bf621d..691d98d341 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Adapter/TestExecutionRecorderTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Adapter/TestExecutionRecorderTests.cs @@ -1,227 +1,224 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Adapter -{ - using System; - using System.Collections.Generic; +namespace TestPlatform.CrossPlatEngine.UnitTests.Adapter; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; - using Moq; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; +using Microsoft.VisualStudio.TestTools.UnitTesting; - using TestPlatform.CrossPlatEngine.UnitTests.TestableImplementations; +using Moq; - [TestClass] - public class TestExecutionRecorderTests - { - private TestableTestRunCache testableTestRunCache; - private Mock mockTestCaseEventsHandler; - private TestExecutionRecorder testRecorder, testRecorderWithTestEventsHandler; - private TestCase testCase; - private Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult testResult; +using TestableImplementations; - [TestInitialize] - public void TestInit() - { - this.testableTestRunCache = new TestableTestRunCache(); - this.testRecorder = new TestExecutionRecorder(null, this.testableTestRunCache); +[TestClass] +public class TestExecutionRecorderTests +{ + private TestableTestRunCache _testableTestRunCache; + private Mock _mockTestCaseEventsHandler; + private TestExecutionRecorder _testRecorder, _testRecorderWithTestEventsHandler; + private TestCase _testCase; + private Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult _testResult; + + [TestInitialize] + public void TestInit() + { + _testableTestRunCache = new TestableTestRunCache(); + _testRecorder = new TestExecutionRecorder(null, _testableTestRunCache); - this.testCase = new TestCase("A.C.M", new Uri("executor://dummy"), "A"); - this.testResult = new Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult(this.testCase); + _testCase = new TestCase("A.C.M", new Uri("executor://dummy"), "A"); + _testResult = new Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult(_testCase); - this.mockTestCaseEventsHandler = new Mock(); - testRecorderWithTestEventsHandler = new TestExecutionRecorder(this.mockTestCaseEventsHandler.Object, this.testableTestRunCache); + _mockTestCaseEventsHandler = new Mock(); + _testRecorderWithTestEventsHandler = new TestExecutionRecorder(_mockTestCaseEventsHandler.Object, _testableTestRunCache); - } + } - [TestMethod] - public void AttachmentsShouldReturnEmptyListByDefault() - { - var attachments = this.testRecorder.Attachments; + [TestMethod] + public void AttachmentsShouldReturnEmptyListByDefault() + { + var attachments = _testRecorder.Attachments; - Assert.IsNotNull(attachments); - Assert.AreEqual(0, attachments.Count); - } + Assert.IsNotNull(attachments); + Assert.AreEqual(0, attachments.Count); + } - [TestMethod] - public void RecordStartShouldUpdateTestRunCache() - { - this.testRecorder.RecordStart(this.testCase); - Assert.IsTrue(this.testableTestRunCache.TestStartedList.Contains(this.testCase)); - } + [TestMethod] + public void RecordStartShouldUpdateTestRunCache() + { + _testRecorder.RecordStart(_testCase); + Assert.IsTrue(_testableTestRunCache.TestStartedList.Contains(_testCase)); + } - [TestMethod] - public void RecordResultShouldUpdateTestRunCache() - { - this.testRecorder.RecordResult(this.testResult); - Assert.IsTrue(this.testableTestRunCache.TestResultList.Contains(this.testResult)); - } + [TestMethod] + public void RecordResultShouldUpdateTestRunCache() + { + _testRecorder.RecordResult(_testResult); + Assert.IsTrue(_testableTestRunCache.TestResultList.Contains(_testResult)); + } - [TestMethod] - public void RecordEndShouldUpdateTestRunCache() - { - this.testRecorder.RecordEnd(this.testCase, TestOutcome.Passed); - Assert.IsTrue(this.testableTestRunCache.TestCompletedList.Contains(this.testCase)); - } + [TestMethod] + public void RecordEndShouldUpdateTestRunCache() + { + _testRecorder.RecordEnd(_testCase, TestOutcome.Passed); + Assert.IsTrue(_testableTestRunCache.TestCompletedList.Contains(_testCase)); + } - [TestMethod] - public void RecordAttachmentsShouldAddToAttachmentSet() - { - var attachmentSet = new List { new AttachmentSet(new Uri("attachment://dummy"), "attachment") }; + [TestMethod] + public void RecordAttachmentsShouldAddToAttachmentSet() + { + var attachmentSet = new List { new AttachmentSet(new Uri("attachment://dummy"), "attachment") }; - this.testRecorder.RecordAttachments(attachmentSet); + _testRecorder.RecordAttachments(attachmentSet); - var attachments = testRecorder.Attachments; + var attachments = _testRecorder.Attachments; - Assert.IsNotNull(attachments); - CollectionAssert.AreEqual(attachmentSet, attachments); - } + Assert.IsNotNull(attachments); + CollectionAssert.AreEqual(attachmentSet, attachments); + } - [TestMethod] - public void RecordAttachmentsShouldAddToAttachmentSetForMultipleAttachments() + [TestMethod] + public void RecordAttachmentsShouldAddToAttachmentSetForMultipleAttachments() + { + var attachmentSet = new List { - var attachmentSet = new List - { - new AttachmentSet(new Uri("attachment://dummy"), "attachment"), - new AttachmentSet(new Uri("attachment://infinite"), "infinity") - }; + new AttachmentSet(new Uri("attachment://dummy"), "attachment"), + new AttachmentSet(new Uri("attachment://infinite"), "infinity") + }; - this.testRecorder.RecordAttachments(attachmentSet); + _testRecorder.RecordAttachments(attachmentSet); - var attachments = this.testRecorder.Attachments; + var attachments = _testRecorder.Attachments; - Assert.IsNotNull(attachments); - CollectionAssert.AreEqual(attachmentSet, attachments); + Assert.IsNotNull(attachments); + CollectionAssert.AreEqual(attachmentSet, attachments); - var newAttachmentSet = new AttachmentSet(new Uri("attachment://median"), "mid"); - attachmentSet.Add(newAttachmentSet); + var newAttachmentSet = new AttachmentSet(new Uri("attachment://median"), "mid"); + attachmentSet.Add(newAttachmentSet); - this.testRecorder.RecordAttachments(new List { newAttachmentSet }); + _testRecorder.RecordAttachments(new List { newAttachmentSet }); - attachments = this.testRecorder.Attachments; + attachments = _testRecorder.Attachments; - Assert.IsNotNull(attachments); - CollectionAssert.AreEqual(attachmentSet, attachments); - } - - #region TestCaseResult caching tests. - [TestMethod] - public void RecordStartShouldInvokeSendTestCaseStart() - { - this.testRecorderWithTestEventsHandler.RecordStart(this.testCase); + Assert.IsNotNull(attachments); + CollectionAssert.AreEqual(attachmentSet, attachments); + } - this.mockTestCaseEventsHandler.Verify(x => x.SendTestCaseStart(this.testCase), Times.Once); - } + #region TestCaseResult caching tests. + [TestMethod] + public void RecordStartShouldInvokeSendTestCaseStart() + { + _testRecorderWithTestEventsHandler.RecordStart(_testCase); - [TestMethod] - public void RecordEndShouldInovkeTestCaseEndEventOnlyIfTestCaseStartWasCalledBefore() - { - this.testRecorderWithTestEventsHandler.RecordStart(this.testCase); - this.testRecorderWithTestEventsHandler.RecordEnd(this.testCase, TestOutcome.Passed); + _mockTestCaseEventsHandler.Verify(x => x.SendTestCaseStart(_testCase), Times.Once); + } - this.mockTestCaseEventsHandler.Verify(x => x.SendTestCaseEnd(this.testCase, TestOutcome.Passed), Times.Once); - } + [TestMethod] + public void RecordEndShouldInovkeTestCaseEndEventOnlyIfTestCaseStartWasCalledBefore() + { + _testRecorderWithTestEventsHandler.RecordStart(_testCase); + _testRecorderWithTestEventsHandler.RecordEnd(_testCase, TestOutcome.Passed); - [TestMethod] - public void RecordEndShouldNotInovkeTestCaseEndEventIfTestCaseStartWasNotCalledBefore() - { - this.testRecorderWithTestEventsHandler.RecordEnd(this.testCase, TestOutcome.Passed); + _mockTestCaseEventsHandler.Verify(x => x.SendTestCaseEnd(_testCase, TestOutcome.Passed), Times.Once); + } - this.mockTestCaseEventsHandler.Verify(x => x.SendTestCaseEnd(this.testCase, TestOutcome.Passed), Times.Never); - } + [TestMethod] + public void RecordEndShouldNotInovkeTestCaseEndEventIfTestCaseStartWasNotCalledBefore() + { + _testRecorderWithTestEventsHandler.RecordEnd(_testCase, TestOutcome.Passed); - [TestMethod] - public void RecordEndShouldNotInvokeTestCaseEndEventInCaseOfAMissingTestCaseStartInDataDrivenScenario() - { - this.testRecorderWithTestEventsHandler.RecordStart(this.testCase); - this.testRecorderWithTestEventsHandler.RecordEnd(this.testCase, TestOutcome.Passed); - this.testRecorderWithTestEventsHandler.RecordEnd(this.testCase, TestOutcome.Failed); + _mockTestCaseEventsHandler.Verify(x => x.SendTestCaseEnd(_testCase, TestOutcome.Passed), Times.Never); + } - this.mockTestCaseEventsHandler.Verify(x => x.SendTestCaseEnd(this.testCase, TestOutcome.Passed), Times.Once); - this.mockTestCaseEventsHandler.Verify(x => x.SendTestCaseEnd(this.testCase, TestOutcome.Failed), Times.Never); - } + [TestMethod] + public void RecordEndShouldNotInvokeTestCaseEndEventInCaseOfAMissingTestCaseStartInDataDrivenScenario() + { + _testRecorderWithTestEventsHandler.RecordStart(_testCase); + _testRecorderWithTestEventsHandler.RecordEnd(_testCase, TestOutcome.Passed); + _testRecorderWithTestEventsHandler.RecordEnd(_testCase, TestOutcome.Failed); - [TestMethod] - public void RecordEndShouldInvokeSendTestCaseEndMultipleTimesInDataDrivenScenario() - { - this.testRecorderWithTestEventsHandler.RecordStart(this.testCase); - this.testRecorderWithTestEventsHandler.RecordEnd(this.testCase, TestOutcome.Passed); - this.testRecorderWithTestEventsHandler.RecordStart(this.testCase); - this.testRecorderWithTestEventsHandler.RecordEnd(this.testCase, TestOutcome.Passed); + _mockTestCaseEventsHandler.Verify(x => x.SendTestCaseEnd(_testCase, TestOutcome.Passed), Times.Once); + _mockTestCaseEventsHandler.Verify(x => x.SendTestCaseEnd(_testCase, TestOutcome.Failed), Times.Never); + } - this.mockTestCaseEventsHandler.Verify(x => x.SendTestCaseEnd(this.testCase, TestOutcome.Passed), Times.Exactly(2)); - } + [TestMethod] + public void RecordEndShouldInvokeSendTestCaseEndMultipleTimesInDataDrivenScenario() + { + _testRecorderWithTestEventsHandler.RecordStart(_testCase); + _testRecorderWithTestEventsHandler.RecordEnd(_testCase, TestOutcome.Passed); + _testRecorderWithTestEventsHandler.RecordStart(_testCase); + _testRecorderWithTestEventsHandler.RecordEnd(_testCase, TestOutcome.Passed); - [TestMethod] - public void RecordStartAndRecordEndShouldIgnoreRedundantTestCaseStartAndTestCaseEnd() - { - this.testRecorderWithTestEventsHandler.RecordStart(this.testCase); - this.testRecorderWithTestEventsHandler.RecordStart(this.testCase); - this.testRecorderWithTestEventsHandler.RecordEnd(this.testCase, TestOutcome.Passed); - this.testRecorderWithTestEventsHandler.RecordEnd(this.testCase, TestOutcome.Passed); + _mockTestCaseEventsHandler.Verify(x => x.SendTestCaseEnd(_testCase, TestOutcome.Passed), Times.Exactly(2)); + } - this.mockTestCaseEventsHandler.Verify(x => x.SendTestCaseStart(this.testCase), Times.Exactly(1)); - this.mockTestCaseEventsHandler.Verify(x => x.SendTestCaseEnd(this.testCase, TestOutcome.Passed), Times.Exactly(1)); - } + [TestMethod] + public void RecordStartAndRecordEndShouldIgnoreRedundantTestCaseStartAndTestCaseEnd() + { + _testRecorderWithTestEventsHandler.RecordStart(_testCase); + _testRecorderWithTestEventsHandler.RecordStart(_testCase); + _testRecorderWithTestEventsHandler.RecordEnd(_testCase, TestOutcome.Passed); + _testRecorderWithTestEventsHandler.RecordEnd(_testCase, TestOutcome.Passed); - [TestMethod] - public void RecordResultShouldPublishTestResultIfRecordStartAndRecordEndEventsAreNotPublished() - { - this.testRecorderWithTestEventsHandler.RecordResult(this.testResult); + _mockTestCaseEventsHandler.Verify(x => x.SendTestCaseStart(_testCase), Times.Exactly(1)); + _mockTestCaseEventsHandler.Verify(x => x.SendTestCaseEnd(_testCase, TestOutcome.Passed), Times.Exactly(1)); + } - this.mockTestCaseEventsHandler.Verify(x => x.SendTestResult(this.testResult), Times.Once); - } + [TestMethod] + public void RecordResultShouldPublishTestResultIfRecordStartAndRecordEndEventsAreNotPublished() + { + _testRecorderWithTestEventsHandler.RecordResult(_testResult); - [TestMethod] - public void RecordResultShouldPublishTestCaseResultEventIfTestCaseStartAndTestCaseEndEventsArePublished() - { - this.testRecorderWithTestEventsHandler.RecordStart(this.testCase); - this.testRecorderWithTestEventsHandler.RecordEnd(this.testCase, TestOutcome.Passed); - this.testRecorderWithTestEventsHandler.RecordResult(this.testResult); + _mockTestCaseEventsHandler.Verify(x => x.SendTestResult(_testResult), Times.Once); + } - this.mockTestCaseEventsHandler.Verify(x => x.SendTestResult(testResult), Times.Once); - } + [TestMethod] + public void RecordResultShouldPublishTestCaseResultEventIfTestCaseStartAndTestCaseEndEventsArePublished() + { + _testRecorderWithTestEventsHandler.RecordStart(_testCase); + _testRecorderWithTestEventsHandler.RecordEnd(_testCase, TestOutcome.Passed); + _testRecorderWithTestEventsHandler.RecordResult(_testResult); - [TestMethod] - public void RecordResultShouldFlushIfRecordEndWasCalledBefore() - { - this.testRecorderWithTestEventsHandler.RecordStart(this.testCase); - this.testRecorderWithTestEventsHandler.RecordEnd(this.testCase, TestOutcome.Passed); - this.testRecorderWithTestEventsHandler.RecordResult(this.testResult); + _mockTestCaseEventsHandler.Verify(x => x.SendTestResult(_testResult), Times.Once); + } - this.mockTestCaseEventsHandler.Verify(x => x.SendTestCaseEnd(this.testCase, TestOutcome.Passed), Times.Once); - Assert.IsTrue(this.testableTestRunCache.TestResultList.Contains(this.testResult)); - } + [TestMethod] + public void RecordResultShouldFlushIfRecordEndWasCalledBefore() + { + _testRecorderWithTestEventsHandler.RecordStart(_testCase); + _testRecorderWithTestEventsHandler.RecordEnd(_testCase, TestOutcome.Passed); + _testRecorderWithTestEventsHandler.RecordResult(_testResult); - [TestMethod] - public void RecordResultShouldSendTestCaseEndEventAndFlushIfRecordEndWasCalledAfterRecordResult() - { - this.testResult.Outcome = TestOutcome.Passed; - this.testRecorderWithTestEventsHandler.RecordStart(this.testCase); - this.testRecorderWithTestEventsHandler.RecordResult(this.testResult); - this.testRecorderWithTestEventsHandler.RecordEnd(this.testCase, this.testResult.Outcome); + _mockTestCaseEventsHandler.Verify(x => x.SendTestCaseEnd(_testCase, TestOutcome.Passed), Times.Once); + Assert.IsTrue(_testableTestRunCache.TestResultList.Contains(_testResult)); + } - this.mockTestCaseEventsHandler.Verify(x => x.SendTestCaseEnd(this.testCase, TestOutcome.Passed), Times.Once); - Assert.IsTrue(this.testableTestRunCache.TestResultList.Contains(this.testResult)); - } + [TestMethod] + public void RecordResultShouldSendTestCaseEndEventAndFlushIfRecordEndWasCalledAfterRecordResult() + { + _testResult.Outcome = TestOutcome.Passed; + _testRecorderWithTestEventsHandler.RecordStart(_testCase); + _testRecorderWithTestEventsHandler.RecordResult(_testResult); + _testRecorderWithTestEventsHandler.RecordEnd(_testCase, _testResult.Outcome); - [TestMethod] - public void RecordResultShouldSendTestCaseEndEventIfRecordEndWasNotCalled() - { - this.testResult.Outcome = TestOutcome.Passed; - this.testRecorderWithTestEventsHandler.RecordStart(this.testCase); - this.testRecorderWithTestEventsHandler.RecordResult(this.testResult); + _mockTestCaseEventsHandler.Verify(x => x.SendTestCaseEnd(_testCase, TestOutcome.Passed), Times.Once); + Assert.IsTrue(_testableTestRunCache.TestResultList.Contains(_testResult)); + } - this.mockTestCaseEventsHandler.Verify(x => x.SendTestCaseEnd(this.testCase, TestOutcome.Passed), Times.Once); - Assert.IsTrue(this.testableTestRunCache.TestResultList.Contains(this.testResult)); - } + [TestMethod] + public void RecordResultShouldSendTestCaseEndEventIfRecordEndWasNotCalled() + { + _testResult.Outcome = TestOutcome.Passed; + _testRecorderWithTestEventsHandler.RecordStart(_testCase); + _testRecorderWithTestEventsHandler.RecordResult(_testResult); - #endregion + _mockTestCaseEventsHandler.Verify(x => x.SendTestCaseEnd(_testCase, TestOutcome.Passed), Times.Once); + Assert.IsTrue(_testableTestRunCache.TestResultList.Contains(_testResult)); } + + #endregion } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/AttachmentsProcessing/DataCollectorAttachmentsProcessorsFactoryTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/AttachmentsProcessing/DataCollectorAttachmentsProcessorsFactoryTests.cs index 6212061853..87f6600d53 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/AttachmentsProcessing/DataCollectorAttachmentsProcessorsFactoryTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/AttachmentsProcessing/DataCollectorAttachmentsProcessorsFactoryTests.cs @@ -1,266 +1,273 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.DataCollectorAttachmentsProcessorsFactoryTests +namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.DataCollectorAttachmentsProcessorsFactoryTests; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; +using System.Xml; +using TestUtilities; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.TestRunAttachmentsProcessing; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class DataCollectorAttachmentsProcessorsFactoryTests { - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Reflection; - using System.Text.RegularExpressions; - using System.Threading; - using System.Threading.Tasks; - using System.Xml; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.TestRunAttachmentsProcessing; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class DataCollectorAttachmentsProcessorsFactoryTests - { - private readonly DataCollectorAttachmentsProcessorsFactory dataCollectorAttachmentsProcessorsFactory = new DataCollectorAttachmentsProcessorsFactory(); + private readonly DataCollectorAttachmentsProcessorsFactory _dataCollectorAttachmentsProcessorsFactory = new(); - [TestInitialize] - public void Init() - { - TestPluginCacheHelper.SetupMockExtensions(typeof(DataCollectorAttachmentsProcessorsFactoryTests)); - } + [TestInitialize] + public void Init() + { + TestPluginCacheHelper.SetupMockExtensions(typeof(DataCollectorAttachmentsProcessorsFactoryTests)); + } - [TestCleanup] - public void Cleanup() - { - TestPluginCacheHelper.ResetExtensionsCache(); - } + [TestCleanup] + public void Cleanup() + { + TestPluginCacheHelper.ResetExtensionsCache(); + } - [TestMethod] - public void Create_ShouldReturnListOfAttachmentProcessors() + [TestMethod] + public void Create_ShouldReturnListOfAttachmentProcessors() + { + // arrange + List invokedDataCollectors = new() { - // arrange - List invokedDataCollectors = new List(); - invokedDataCollectors.Add(new InvokedDataCollector(new Uri("datacollector://Sample"), "Sample", typeof(SampleDataCollector).AssemblyQualifiedName, typeof(SampleDataCollector).Assembly.Location, true)); - invokedDataCollectors.Add(new InvokedDataCollector(new Uri("datacollector://SampleData2"), "SampleData2", typeof(SampleData2Collector).AssemblyQualifiedName, typeof(SampleData2Collector).Assembly.Location, true)); - invokedDataCollectors.Add(new InvokedDataCollector(new Uri("datacollector://SampleData3"), "SampleData3", typeof(SampleData3Collector).AssemblyQualifiedName, typeof(SampleData3Collector).Assembly.Location, true)); - // act - var dataCollectorAttachmentsProcessors = dataCollectorAttachmentsProcessorsFactory.Create(invokedDataCollectors.ToArray(), null); - - // assert - Assert.AreEqual(3, dataCollectorAttachmentsProcessors.Length); - - Assert.AreEqual(1, dataCollectorAttachmentsProcessors.Count(x => x.FriendlyName == "Sample")); - Assert.AreEqual(1, dataCollectorAttachmentsProcessors.Count(x => x.FriendlyName == "SampleData3")); - Assert.AreEqual(1, dataCollectorAttachmentsProcessors.Count(x => x.FriendlyName == "Code Coverage")); - - Assert.AreEqual(typeof(DataCollectorAttachmentProcessor).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[0].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName); - Assert.AreEqual(typeof(DataCollectorAttachmentProcessor2).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[1].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName); - Assert.AreEqual(typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[2].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName); - } + new InvokedDataCollector(new Uri("datacollector://Sample"), "Sample", typeof(SampleDataCollector).AssemblyQualifiedName, typeof(SampleDataCollector).Assembly.Location, true), + new InvokedDataCollector(new Uri("datacollector://SampleData2"), "SampleData2", typeof(SampleData2Collector).AssemblyQualifiedName, typeof(SampleData2Collector).Assembly.Location, true), + new InvokedDataCollector(new Uri("datacollector://SampleData3"), "SampleData3", typeof(SampleData3Collector).AssemblyQualifiedName, typeof(SampleData3Collector).Assembly.Location, true) + }; + // act + var dataCollectorAttachmentsProcessors = _dataCollectorAttachmentsProcessorsFactory.Create(invokedDataCollectors.ToArray(), null); + + // assert + Assert.AreEqual(3, dataCollectorAttachmentsProcessors.Length); + + Assert.AreEqual(1, dataCollectorAttachmentsProcessors.Count(x => x.FriendlyName == "Sample")); + Assert.AreEqual(1, dataCollectorAttachmentsProcessors.Count(x => x.FriendlyName == "SampleData3")); + Assert.AreEqual(1, dataCollectorAttachmentsProcessors.Count(x => x.FriendlyName == "Code Coverage")); + + Assert.AreEqual(typeof(DataCollectorAttachmentProcessor).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[0].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName); + Assert.AreEqual(typeof(DataCollectorAttachmentProcessor2).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[1].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName); + Assert.AreEqual(typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[2].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName); + } - [DataTestMethod] - [DataRow(true)] - [DataRow(false)] - public void Create_EmptyOrNullInvokedDataCollector_ShouldReturnCodeCoverageDataAttachmentsHandler(bool empty) - { - // act - var dataCollectorAttachmentsProcessors = dataCollectorAttachmentsProcessorsFactory.Create(empty ? new InvokedDataCollector[0] : null, null); + [DataTestMethod] + [DataRow(true)] + [DataRow(false)] + public void Create_EmptyOrNullInvokedDataCollector_ShouldReturnCodeCoverageDataAttachmentsHandler(bool empty) + { + // act + var dataCollectorAttachmentsProcessors = _dataCollectorAttachmentsProcessorsFactory.Create(empty ? new InvokedDataCollector[0] : null, null); - //assert - Assert.AreEqual(1, dataCollectorAttachmentsProcessors.Length); - Assert.AreEqual(typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[0].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName); - } + //assert + Assert.AreEqual(1, dataCollectorAttachmentsProcessors.Length); + Assert.AreEqual(typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[0].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName); + } - [TestMethod] - public void Create_ShouldNotFailIfWrongDataCollectorAttachmentProcessor() + [TestMethod] + public void Create_ShouldNotFailIfWrongDataCollectorAttachmentProcessor() + { + // arrange + List invokedDataCollectors = new() { - // arrange - List invokedDataCollectors = new List(); - invokedDataCollectors.Add(new InvokedDataCollector(new Uri("datacollector://SampleData4"), "SampleData4", typeof(SampleData4Collector).AssemblyQualifiedName, typeof(SampleData4Collector).Assembly.Location, true)); + new InvokedDataCollector(new Uri("datacollector://SampleData4"), "SampleData4", typeof(SampleData4Collector).AssemblyQualifiedName, typeof(SampleData4Collector).Assembly.Location, true) + }; - // act - var dataCollectorAttachmentsProcessors = dataCollectorAttachmentsProcessorsFactory.Create(invokedDataCollectors.ToArray(), null); + // act + var dataCollectorAttachmentsProcessors = _dataCollectorAttachmentsProcessorsFactory.Create(invokedDataCollectors.ToArray(), null); - // assert - Assert.AreEqual(1, dataCollectorAttachmentsProcessors.Length); - Assert.AreEqual(typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[0].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName); - } + // assert + Assert.AreEqual(1, dataCollectorAttachmentsProcessors.Length); + Assert.AreEqual(typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[0].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName); + } - [TestMethod] - public void Create_ShouldAddTwoTimeCodeCoverageDataAttachmentsHandler() + [TestMethod] + public void Create_ShouldAddTwoTimeCodeCoverageDataAttachmentsHandler() + { + // arrange + List invokedDataCollectors = new() { - // arrange - List invokedDataCollectors = new List(); - invokedDataCollectors.Add(new InvokedDataCollector(new Uri("datacollector://microsoft/CodeCoverage/2.0"), "SampleData5", typeof(SampleData5Collector).AssemblyQualifiedName, typeof(SampleData5Collector).Assembly.Location, true)); + new InvokedDataCollector(new Uri("datacollector://microsoft/CodeCoverage/2.0"), "SampleData5", typeof(SampleData5Collector).AssemblyQualifiedName, typeof(SampleData5Collector).Assembly.Location, true) + }; - // act - var dataCollectorAttachmentsProcessors = dataCollectorAttachmentsProcessorsFactory.Create(invokedDataCollectors.ToArray(), null); + // act + var dataCollectorAttachmentsProcessors = _dataCollectorAttachmentsProcessorsFactory.Create(invokedDataCollectors.ToArray(), null); - // assert - Assert.AreEqual(2, dataCollectorAttachmentsProcessors.Length); - Assert.AreEqual(typeof(DataCollectorAttachmentProcessor).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[0].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName); - Assert.AreEqual(typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[1].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName); - } + // assert + Assert.AreEqual(2, dataCollectorAttachmentsProcessors.Length); + Assert.AreEqual(typeof(DataCollectorAttachmentProcessor).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[0].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName); + Assert.AreEqual(typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[1].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName); + } - [TestMethod] - public void Create_ShouldLoadOrderingByFilePath() + [TestMethod] + public void Create_ShouldLoadOrderingByFilePath() + { + // arrange + // We cannot cleanup at the end because assembly will be copied into tmp directory and loaded + string testAssetsPath = GetTestAssetsFolder(); + var dataCollectorFilePath = Directory.GetFiles(testAssetsPath, "AttachmentProcessorDataCollector.dll", SearchOption.AllDirectories).Where(x => x.Contains("bin")).Single(); + string tmpDir = Path.Combine(Path.GetTempPath(), nameof(Create_ShouldLoadOrderingByFilePath)); + Directory.CreateDirectory(tmpDir); + string version1 = Path.Combine(tmpDir, "1.0.0"); + Directory.CreateDirectory(version1); + File.Copy(dataCollectorFilePath, Path.Combine(version1, Path.GetFileName(dataCollectorFilePath)), true); + string version2 = Path.Combine(tmpDir, "1.0.1"); + Directory.CreateDirectory(version2); + File.Copy(dataCollectorFilePath, Path.Combine(version2, Path.GetFileName(dataCollectorFilePath)), true); + + List invokedDataCollectors = new() { - // arrange - // We cannot cleanup at the end because assembly will be copied into tmp directory and loaded - string testAssetsPath = GetTestAssetsFolder(); - var dataCollectorFilePath = Directory.GetFiles(testAssetsPath, "AttachmentProcessorDataCollector.dll", SearchOption.AllDirectories).Where(x => x.Contains("bin")).Single(); - string tmpDir = Path.Combine(Path.GetTempPath(), nameof(Create_ShouldLoadOrderingByFilePath)); - Directory.CreateDirectory(tmpDir); - string version1 = Path.Combine(tmpDir, "1.0.0"); - Directory.CreateDirectory(version1); - File.Copy(dataCollectorFilePath, Path.Combine(version1, Path.GetFileName(dataCollectorFilePath)), true); - string version2 = Path.Combine(tmpDir, "1.0.1"); - Directory.CreateDirectory(version2); - File.Copy(dataCollectorFilePath, Path.Combine(version2, Path.GetFileName(dataCollectorFilePath)), true); - - List invokedDataCollectors = new List(); - invokedDataCollectors.Add(new InvokedDataCollector(new Uri("my://sample/datacollector"), "sample", "AttachmentProcessorDataCollector.SampleDataCollectorV2", Path.Combine(version1, Path.GetFileName(dataCollectorFilePath)), true)); - invokedDataCollectors.Add(new InvokedDataCollector(new Uri("my://sample/datacollector"), "sample", "AttachmentProcessorDataCollector.SampleDataCollectorV2", Path.Combine(version2, Path.GetFileName(dataCollectorFilePath)), true)); - - // act - var dataCollectorAttachmentsProcessors = dataCollectorAttachmentsProcessorsFactory.Create(invokedDataCollectors.ToArray(), null); - - // assert - Assert.AreEqual(2, dataCollectorAttachmentsProcessors.Length); - Assert.IsTrue(Regex.IsMatch(dataCollectorAttachmentsProcessors[0].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName, @"AttachmentProcessorDataCollector\.SampleDataCollectorAttachmentProcessor, AttachmentProcessorDataCollector, Version=.*, Culture=neutral, PublicKeyToken=null")); - Assert.AreEqual(Path.Combine(version2, Path.GetFileName(dataCollectorFilePath)), dataCollectorAttachmentsProcessors[0].DataCollectorAttachmentProcessorInstance.GetType().Assembly.Location); - Assert.AreEqual(typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[1].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName); - } + new InvokedDataCollector(new Uri("my://sample/datacollector"), "sample", "AttachmentProcessorDataCollector.SampleDataCollectorV2", Path.Combine(version1, Path.GetFileName(dataCollectorFilePath)), true), + new InvokedDataCollector(new Uri("my://sample/datacollector"), "sample", "AttachmentProcessorDataCollector.SampleDataCollectorV2", Path.Combine(version2, Path.GetFileName(dataCollectorFilePath)), true) + }; + + // act + var dataCollectorAttachmentsProcessors = _dataCollectorAttachmentsProcessorsFactory.Create(invokedDataCollectors.ToArray(), null); + + // assert + Assert.AreEqual(2, dataCollectorAttachmentsProcessors.Length); + Assert.IsTrue(Regex.IsMatch(dataCollectorAttachmentsProcessors[0].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName, @"AttachmentProcessorDataCollector\.SampleDataCollectorAttachmentProcessor, AttachmentProcessorDataCollector, Version=.*, Culture=neutral, PublicKeyToken=null")); + Assert.AreEqual(Path.Combine(version2, Path.GetFileName(dataCollectorFilePath)), dataCollectorAttachmentsProcessors[0].DataCollectorAttachmentProcessorInstance.GetType().Assembly.Location); + Assert.AreEqual(typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[1].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName); + } - private string GetTestAssetsFolder() + private string GetTestAssetsFolder() + { + string current = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + while (true) { - string current = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - while (true) + if (File.Exists(Path.Combine(current, "TestPlatform.sln"))) { - if (File.Exists(Path.Combine(current, "TestPlatform.sln"))) - { - string testAssetsPath = Path.Combine(current, @"test/TestAssets"); - Assert.IsTrue(Directory.Exists(testAssetsPath), $"Directory not found '{testAssetsPath}'"); - return testAssetsPath; - } - current = Path.GetDirectoryName(current); - if (current == Path.GetPathRoot(current)) - { - throw new Exception("Repo root path not tound"); - } + string testAssetsPath = Path.Combine(current, @"test/TestAssets"); + Assert.IsTrue(Directory.Exists(testAssetsPath), $"Directory not found '{testAssetsPath}'"); + return testAssetsPath; } - } - - [DataCollectorFriendlyName("Sample")] - [DataCollectorTypeUri("datacollector://Sample")] - [DataCollectorAttachmentProcessor(typeof(DataCollectorAttachmentProcessor))] - public class SampleDataCollector : DataCollector - { - public override void Initialize( - XmlElement configurationElement, - DataCollectionEvents events, - DataCollectionSink dataSink, - DataCollectionLogger logger, - DataCollectionEnvironmentContext environmentContext) + current = Path.GetDirectoryName(current); + if (current == Path.GetPathRoot(current)) { - + throw new Exception("Repo root path not tound"); } } + } - [DataCollectorFriendlyName("SampleData2")] - [DataCollectorTypeUri("datacollector://SampleData2")] - [DataCollectorAttachmentProcessor(typeof(DataCollectorAttachmentProcessor))] - public class SampleData2Collector : DataCollector + [DataCollectorFriendlyName("Sample")] + [DataCollectorTypeUri("datacollector://Sample")] + [DataCollectorAttachmentProcessor(typeof(DataCollectorAttachmentProcessor))] + public class SampleDataCollector : DataCollector + { + public override void Initialize( + XmlElement configurationElement, + DataCollectionEvents events, + DataCollectionSink dataSink, + DataCollectionLogger logger, + DataCollectionEnvironmentContext environmentContext) { - public override void Initialize( - XmlElement configurationElement, - DataCollectionEvents events, - DataCollectionSink dataSink, - DataCollectionLogger logger, - DataCollectionEnvironmentContext environmentContext) - { - } } + } - [DataCollectorFriendlyName("SampleData3")] - [DataCollectorTypeUri("datacollector://SampleData3")] - [DataCollectorAttachmentProcessor(typeof(DataCollectorAttachmentProcessor2))] - public class SampleData3Collector : DataCollector + [DataCollectorFriendlyName("SampleData2")] + [DataCollectorTypeUri("datacollector://SampleData2")] + [DataCollectorAttachmentProcessor(typeof(DataCollectorAttachmentProcessor))] + public class SampleData2Collector : DataCollector + { + public override void Initialize( + XmlElement configurationElement, + DataCollectionEvents events, + DataCollectionSink dataSink, + DataCollectionLogger logger, + DataCollectionEnvironmentContext environmentContext) { - public override void Initialize( - XmlElement configurationElement, - DataCollectionEvents events, - DataCollectionSink dataSink, - DataCollectionLogger logger, - DataCollectionEnvironmentContext environmentContext) - { - } } + } - [DataCollectorFriendlyName("SampleData4")] - [DataCollectorTypeUri("datacollector://SampleData4")] - [DataCollectorAttachmentProcessor(typeof(string))] - public class SampleData4Collector : DataCollector + [DataCollectorFriendlyName("SampleData3")] + [DataCollectorTypeUri("datacollector://SampleData3")] + [DataCollectorAttachmentProcessor(typeof(DataCollectorAttachmentProcessor2))] + public class SampleData3Collector : DataCollector + { + public override void Initialize( + XmlElement configurationElement, + DataCollectionEvents events, + DataCollectionSink dataSink, + DataCollectionLogger logger, + DataCollectionEnvironmentContext environmentContext) { - public override void Initialize( - XmlElement configurationElement, - DataCollectionEvents events, - DataCollectionSink dataSink, - DataCollectionLogger logger, - DataCollectionEnvironmentContext environmentContext) - { - } } + } - [DataCollectorFriendlyName("SampleData5")] - [DataCollectorTypeUri("datacollector://microsoft/CodeCoverage/2.0")] - [DataCollectorAttachmentProcessor(typeof(DataCollectorAttachmentProcessor))] - public class SampleData5Collector : DataCollector + [DataCollectorFriendlyName("SampleData4")] + [DataCollectorTypeUri("datacollector://SampleData4")] + [DataCollectorAttachmentProcessor(typeof(string))] + public class SampleData4Collector : DataCollector + { + public override void Initialize( + XmlElement configurationElement, + DataCollectionEvents events, + DataCollectionSink dataSink, + DataCollectionLogger logger, + DataCollectionEnvironmentContext environmentContext) { - public override void Initialize( - XmlElement configurationElement, - DataCollectionEvents events, - DataCollectionSink dataSink, - DataCollectionLogger logger, - DataCollectionEnvironmentContext environmentContext) - { - } } + } - public class DataCollectorAttachmentProcessor : IDataCollectorAttachmentProcessor + [DataCollectorFriendlyName("SampleData5")] + [DataCollectorTypeUri("datacollector://microsoft/CodeCoverage/2.0")] + [DataCollectorAttachmentProcessor(typeof(DataCollectorAttachmentProcessor))] + public class SampleData5Collector : DataCollector + { + public override void Initialize( + XmlElement configurationElement, + DataCollectionEvents events, + DataCollectionSink dataSink, + DataCollectionLogger logger, + DataCollectionEnvironmentContext environmentContext) { - public bool SupportsIncrementalProcessing => throw new NotImplementedException(); - public IEnumerable GetExtensionUris() - { - throw new NotImplementedException(); - } + } + } - public Task> ProcessAttachmentSetsAsync(XmlElement configurationElement, ICollection attachments, IProgress progressReporter, IMessageLogger logger, CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } + public class DataCollectorAttachmentProcessor : IDataCollectorAttachmentProcessor + { + public bool SupportsIncrementalProcessing => throw new NotImplementedException(); + + public IEnumerable GetExtensionUris() + { + throw new NotImplementedException(); } - public class DataCollectorAttachmentProcessor2 : IDataCollectorAttachmentProcessor + public Task> ProcessAttachmentSetsAsync(XmlElement configurationElement, ICollection attachments, IProgress progressReporter, IMessageLogger logger, CancellationToken cancellationToken) { - public bool SupportsIncrementalProcessing => throw new NotImplementedException(); + throw new NotImplementedException(); + } + } - public IEnumerable GetExtensionUris() - { - throw new NotImplementedException(); - } + public class DataCollectorAttachmentProcessor2 : IDataCollectorAttachmentProcessor + { + public bool SupportsIncrementalProcessing => throw new NotImplementedException(); - public Task> ProcessAttachmentSetsAsync(XmlElement configurationElement, ICollection attachments, IProgress progressReporter, IMessageLogger logger, CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } + public IEnumerable GetExtensionUris() + { + throw new NotImplementedException(); + } + + public Task> ProcessAttachmentSetsAsync(XmlElement configurationElement, ICollection attachments, IProgress progressReporter, IMessageLogger logger, CancellationToken cancellationToken) + { + throw new NotImplementedException(); } } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/AttachmentsProcessing/TestRunAttachmentsProcessingManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/AttachmentsProcessing/TestRunAttachmentsProcessingManagerTests.cs index 4e0666cd3a..aad3bdc442 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/AttachmentsProcessing/TestRunAttachmentsProcessingManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/AttachmentsProcessing/TestRunAttachmentsProcessingManagerTests.cs @@ -1,425 +1,424 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.TestRunAttachmentsProcessing +namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.TestRunAttachmentsProcessing; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using System.Xml; +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.TestRunAttachmentsProcessing; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using VisualStudio.TestTools.UnitTesting; +using Moq; + +[TestClass] +public class TestRunAttachmentsProcessingManagerTests { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Linq; - using System.Threading; - using System.Threading.Tasks; - using System.Xml; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.TestRunAttachmentsProcessing; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - - [TestClass] - public class TestRunAttachmentsProcessingManagerTests + private const string Uri1 = "datacollector://microsoft/some1/1.0"; + private const string Uri2 = "datacollector://microsoft/some2/2.0"; + private const string Uri3 = "datacollector://microsoft/some3/2.0"; + + private readonly Mock _mockRequestData; + private readonly Mock _mockMetricsCollection; + private readonly Mock _mockEventSource; + private readonly Mock _mockAttachmentHandler1; + private readonly Mock _mockAttachmentHandler2; + private readonly Mock _mockDataCollectorAttachmentsProcessorsFactory; + private readonly Mock _mockEventsHandler; + private readonly TestRunAttachmentsProcessingManager _manager; + private readonly CancellationTokenSource _cancellationTokenSource; + + public TestRunAttachmentsProcessingManagerTests() { - private const string uri1 = "datacollector://microsoft/some1/1.0"; - private const string uri2 = "datacollector://microsoft/some2/2.0"; - private const string uri3 = "datacollector://microsoft/some3/2.0"; - - private readonly Mock mockRequestData; - private readonly Mock mockMetricsCollection; - private readonly Mock mockEventSource; - private readonly Mock mockAttachmentHandler1; - private readonly Mock mockAttachmentHandler2; - private readonly Mock mockDataCollectorAttachmentsProcessorsFactory; - private readonly Mock mockEventsHandler; - private readonly TestRunAttachmentsProcessingManager manager; - private readonly CancellationTokenSource cancellationTokenSource; - - public TestRunAttachmentsProcessingManagerTests() - { - mockRequestData = new Mock(); - mockMetricsCollection = new Mock(); - mockRequestData.Setup(r => r.MetricsCollection).Returns(mockMetricsCollection.Object); - - mockEventSource = new Mock(); - mockAttachmentHandler1 = new Mock(); - mockAttachmentHandler1.Setup(x => x.SupportsIncrementalProcessing).Returns(true); - mockAttachmentHandler2 = new Mock(); - mockAttachmentHandler2.Setup(x => x.SupportsIncrementalProcessing).Returns(true); - mockEventsHandler = new Mock(); - mockDataCollectorAttachmentsProcessorsFactory = new Mock(); - - mockAttachmentHandler1.Setup(h => h.GetExtensionUris()).Returns(new[] { new Uri(uri1) }); - mockAttachmentHandler2.Setup(h => h.GetExtensionUris()).Returns(new[] { new Uri(uri2) }); - mockDataCollectorAttachmentsProcessorsFactory.Setup(p => p.Create(It.IsAny(), It.IsAny())) + _mockRequestData = new Mock(); + _mockMetricsCollection = new Mock(); + _mockRequestData.Setup(r => r.MetricsCollection).Returns(_mockMetricsCollection.Object); + + _mockEventSource = new Mock(); + _mockAttachmentHandler1 = new Mock(); + _mockAttachmentHandler1.Setup(x => x.SupportsIncrementalProcessing).Returns(true); + _mockAttachmentHandler2 = new Mock(); + _mockAttachmentHandler2.Setup(x => x.SupportsIncrementalProcessing).Returns(true); + _mockEventsHandler = new Mock(); + _mockDataCollectorAttachmentsProcessorsFactory = new Mock(); + + _mockAttachmentHandler1.Setup(h => h.GetExtensionUris()).Returns(new[] { new Uri(Uri1) }); + _mockAttachmentHandler2.Setup(h => h.GetExtensionUris()).Returns(new[] { new Uri(Uri2) }); + _mockDataCollectorAttachmentsProcessorsFactory.Setup(p => p.Create(It.IsAny(), It.IsAny())) .Returns(new DataCollectorAttachmentProcessor[] { - new DataCollectorAttachmentProcessor( "friendlyNameA", mockAttachmentHandler1.Object ), - new DataCollectorAttachmentProcessor( "friendlyNameB" ,mockAttachmentHandler2.Object ) + new DataCollectorAttachmentProcessor( "friendlyNameA", _mockAttachmentHandler1.Object ), + new DataCollectorAttachmentProcessor( "friendlyNameB" ,_mockAttachmentHandler2.Object ) }); - manager = new TestRunAttachmentsProcessingManager(mockEventSource.Object, mockDataCollectorAttachmentsProcessorsFactory.Object); + _manager = new TestRunAttachmentsProcessingManager(_mockEventSource.Object, _mockDataCollectorAttachmentsProcessorsFactory.Object); - cancellationTokenSource = new CancellationTokenSource(); - } - - [TestMethod] - public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachmentsThroughEventsHandler_IfNoAttachmentsOnInput() - { - // arrange - List inputAttachments = new List(); - - // act - await manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], mockEventsHandler.Object, cancellationTokenSource.Token); - - // assert - VerifyCompleteEvent(false, false); - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingComplete(It.Is(a => !a.IsCanceled), It.Is>(c => c.Count == 0))); - mockEventsHandler.Verify(h => h.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never); - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.IsAny()), Times.Never); - mockEventSource.Verify(s => s.TestRunAttachmentsProcessingStart(0)); - mockEventSource.Verify(s => s.TestRunAttachmentsProcessingStop(0)); - mockAttachmentHandler1.Verify(h => h.GetExtensionUris(), Times.Never); - mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Never); - mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); - mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + _cancellationTokenSource = new CancellationTokenSource(); + } - VerifyMetrics(inputCount: 0, outputCount: 0); - } + [TestMethod] + public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachmentsThroughEventsHandler_IfNoAttachmentsOnInput() + { + // arrange + List inputAttachments = new(); + + // act + await _manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], _mockEventsHandler.Object, _cancellationTokenSource.Token); + + // assert + VerifyCompleteEvent(false, false); + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingComplete(It.Is(a => !a.IsCanceled), It.Is>(c => c.Count == 0))); + _mockEventsHandler.Verify(h => h.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never); + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.IsAny()), Times.Never); + _mockEventSource.Verify(s => s.TestRunAttachmentsProcessingStart(0)); + _mockEventSource.Verify(s => s.TestRunAttachmentsProcessingStop(0)); + _mockAttachmentHandler1.Verify(h => h.GetExtensionUris(), Times.Never); + _mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Never); + _mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + _mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + + VerifyMetrics(inputCount: 0, outputCount: 0); + } - [TestMethod] - public async Task ProcessTestRunAttachmentsAsync_ShouldReturnNoAttachments_IfNoAttachmentsOnInput() - { - // arrange - List inputAttachments = new List(); + [TestMethod] + public async Task ProcessTestRunAttachmentsAsync_ShouldReturnNoAttachments_IfNoAttachmentsOnInput() + { + // arrange + List inputAttachments = new(); - // act - var result = await manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], cancellationTokenSource.Token); + // act + var result = await _manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], _cancellationTokenSource.Token); - // assert - Assert.AreEqual(0, result.Count); - mockAttachmentHandler1.Verify(h => h.GetExtensionUris(), Times.Never); - mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Never); - mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); - mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + // assert + Assert.AreEqual(0, result.Count); + _mockAttachmentHandler1.Verify(h => h.GetExtensionUris(), Times.Never); + _mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Never); + _mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + _mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); - VerifyMetrics(inputCount: 0, outputCount: 0); - } + VerifyMetrics(inputCount: 0, outputCount: 0); + } - [TestMethod] - public async Task ProcessTestRunAttachmentsAsync_ShouldReturn1NotProcessedAttachmentThroughEventsHandler_If1NotRelatedAttachmentOnInput() + [TestMethod] + public async Task ProcessTestRunAttachmentsAsync_ShouldReturn1NotProcessedAttachmentThroughEventsHandler_If1NotRelatedAttachmentOnInput() + { + // arrange + List inputAttachments = new() { - // arrange - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri3), "uri3_input") - }; - - // act - await manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], mockEventsHandler.Object, cancellationTokenSource.Token); - - // assert - VerifyCompleteEvent(false, false, inputAttachments[0]); - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.IsAny()), Times.Never); - mockEventsHandler.Verify(h => h.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never); - mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); - mockAttachmentHandler2.Verify(h => h.GetExtensionUris()); - mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); - mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); - - VerifyMetrics(inputCount: 1, outputCount: 1); - } + new AttachmentSet(new Uri(Uri3), "uri3_input") + }; + + // act + await _manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], _mockEventsHandler.Object, _cancellationTokenSource.Token); + + // assert + VerifyCompleteEvent(false, false, inputAttachments[0]); + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.IsAny()), Times.Never); + _mockEventsHandler.Verify(h => h.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never); + _mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); + _mockAttachmentHandler2.Verify(h => h.GetExtensionUris()); + _mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + _mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + + VerifyMetrics(inputCount: 1, outputCount: 1); + } - [TestMethod] - public async Task ProcessTestRunAttachmentsAsync_ShouldReturn1NotProcessedAttachment_If1NotRelatedAttachmentOnInput() + [TestMethod] + public async Task ProcessTestRunAttachmentsAsync_ShouldReturn1NotProcessedAttachment_If1NotRelatedAttachmentOnInput() + { + // arrange + List inputAttachments = new() { - // arrange - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri3), "uri3_input") - }; + new AttachmentSet(new Uri(Uri3), "uri3_input") + }; - // act - var result = await manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], cancellationTokenSource.Token); + // act + var result = await _manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], _cancellationTokenSource.Token); - // assert - Assert.AreEqual(1, result.Count); - Assert.IsTrue(result.Contains(inputAttachments[0])); - mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); - mockAttachmentHandler2.Verify(h => h.GetExtensionUris()); - mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); - mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + // assert + Assert.AreEqual(1, result.Count); + Assert.IsTrue(result.Contains(inputAttachments[0])); + _mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); + _mockAttachmentHandler2.Verify(h => h.GetExtensionUris()); + _mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + _mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); - VerifyMetrics(inputCount: 1, outputCount: 1); - } + VerifyMetrics(inputCount: 1, outputCount: 1); + } - [TestMethod] - public async Task ProcessTestRunAttachmentsAsync_ShouldReturn1ProcessedAttachmentThroughEventsHandler_IfRelatedAttachmentOnInput() + [TestMethod] + public async Task ProcessTestRunAttachmentsAsync_ShouldReturn1ProcessedAttachmentThroughEventsHandler_IfRelatedAttachmentOnInput() + { + // arrange + List inputAttachments = new() { - // arrange - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_input") - }; + new AttachmentSet(new Uri(Uri1), "uri1_input") + }; - List outputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_output") - }; + List outputAttachments = new() + { + new AttachmentSet(new Uri(Uri1), "uri1_output") + }; - mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).ReturnsAsync(outputAttachments); + _mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).ReturnsAsync(outputAttachments); - // act - await manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], mockEventsHandler.Object, cancellationTokenSource.Token); + // act + await _manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], _mockEventsHandler.Object, _cancellationTokenSource.Token); - // assert - VerifyCompleteEvent(false, false, outputAttachments[0]); - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.IsAny()), Times.Never); - mockEventsHandler.Verify(h => h.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never); - mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); - mockAttachmentHandler2.Verify(h => h.GetExtensionUris()); - mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); - mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + // assert + VerifyCompleteEvent(false, false, outputAttachments[0]); + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.IsAny()), Times.Never); + _mockEventsHandler.Verify(h => h.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never); + _mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); + _mockAttachmentHandler2.Verify(h => h.GetExtensionUris()); + _mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), _cancellationTokenSource.Token)); + _mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); - VerifyMetrics(inputCount: 1, outputCount: 1); - } + VerifyMetrics(inputCount: 1, outputCount: 1); + } - [TestMethod] - public async Task ProcessTestRunAttachmentsAsync_ShouldReturn1ProcessedAttachment_IfRelatedAttachmentOnInput() + [TestMethod] + public async Task ProcessTestRunAttachmentsAsync_ShouldReturn1ProcessedAttachment_IfRelatedAttachmentOnInput() + { + // arrange + List inputAttachments = new() { - // arrange - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_input") - }; + new AttachmentSet(new Uri(Uri1), "uri1_input") + }; - List outputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_output") - }; + List outputAttachments = new() + { + new AttachmentSet(new Uri(Uri1), "uri1_output") + }; - mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).ReturnsAsync(outputAttachments); + _mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).ReturnsAsync(outputAttachments); - // act - var result = await manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], cancellationTokenSource.Token); + // act + var result = await _manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], _cancellationTokenSource.Token); - // assert - Assert.AreEqual(1, result.Count); - Assert.IsTrue(result.Contains(outputAttachments[0])); - mockEventSource.Verify(s => s.TestRunAttachmentsProcessingStart(1)); - mockEventSource.Verify(s => s.TestRunAttachmentsProcessingStop(1)); - mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); - mockAttachmentHandler2.Verify(h => h.GetExtensionUris()); - mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); - mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + // assert + Assert.AreEqual(1, result.Count); + Assert.IsTrue(result.Contains(outputAttachments[0])); + _mockEventSource.Verify(s => s.TestRunAttachmentsProcessingStart(1)); + _mockEventSource.Verify(s => s.TestRunAttachmentsProcessingStop(1)); + _mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); + _mockAttachmentHandler2.Verify(h => h.GetExtensionUris()); + _mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), _cancellationTokenSource.Token)); + _mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); - VerifyMetrics(inputCount: 1, outputCount: 1); - } + VerifyMetrics(inputCount: 1, outputCount: 1); + } - [TestMethod] - public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachmentsThroughEventsHandler_IfRelatedAttachmentOnInputButHandlerThrowsException() + [TestMethod] + public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachmentsThroughEventsHandler_IfRelatedAttachmentOnInputButHandlerThrowsException() + { + // arrange + List inputAttachments = new() { - // arrange - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_input") - }; + new AttachmentSet(new Uri(Uri1), "uri1_input") + }; - var exceptionToThrow = new Exception("exception message"); - mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).Throws(exceptionToThrow); + var exceptionToThrow = new Exception("exception message"); + _mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).Throws(exceptionToThrow); - // act - await manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], mockEventsHandler.Object, cancellationTokenSource.Token); + // act + await _manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], _mockEventsHandler.Object, _cancellationTokenSource.Token); - // assert - VerifyCompleteEvent(false, false, inputAttachments[0]); - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.IsAny()), Times.Never); - mockEventsHandler.Verify(h => h.HandleLogMessage(TestMessageLevel.Error, exceptionToThrow.ToString()), Times.Once); - mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); - mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Once); - mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); - mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + // assert + VerifyCompleteEvent(false, false, inputAttachments[0]); + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.IsAny()), Times.Never); + _mockEventsHandler.Verify(h => h.HandleLogMessage(TestMessageLevel.Error, exceptionToThrow.ToString()), Times.Once); + _mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); + _mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Once); + _mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), _cancellationTokenSource.Token)); + _mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); - VerifyMetrics(inputCount: 1, outputCount: 1); - } + VerifyMetrics(inputCount: 1, outputCount: 1); + } - [TestMethod] - public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachments_IfRelatedAttachmentOnInputButHandlerThrowsException() + [TestMethod] + public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachments_IfRelatedAttachmentOnInputButHandlerThrowsException() + { + // arrange + List inputAttachments = new() { - // arrange - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_input") - }; + new AttachmentSet(new Uri(Uri1), "uri1_input") + }; - mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).Throws(new Exception("exception message")); + _mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).Throws(new Exception("exception message")); - // act - var result = await manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], cancellationTokenSource.Token); + // act + var result = await _manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], _cancellationTokenSource.Token); - // assert - Assert.AreEqual(1, result.Count); - Assert.IsTrue(result.Contains(inputAttachments[0])); - mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); - mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Once); - mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); - mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + // assert + Assert.AreEqual(1, result.Count); + Assert.IsTrue(result.Contains(inputAttachments[0])); + _mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); + _mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Once); + _mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), _cancellationTokenSource.Token)); + _mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); - VerifyMetrics(inputCount: 1, outputCount: 1); - } + VerifyMetrics(inputCount: 1, outputCount: 1); + } - [TestMethod] - public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachmentsThroughEventsHandler_IfOperationIsCancelled() + [TestMethod] + public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachmentsThroughEventsHandler_IfOperationIsCancelled() + { + // arrange + _cancellationTokenSource.Cancel(); + List inputAttachments = new() { - // arrange - cancellationTokenSource.Cancel(); - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_input") - }; + new AttachmentSet(new Uri(Uri1), "uri1_input") + }; - // act - await manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], mockEventsHandler.Object, cancellationTokenSource.Token); + // act + await _manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], _mockEventsHandler.Object, _cancellationTokenSource.Token); - // assert - VerifyCompleteEvent(true, false, inputAttachments[0]); - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.IsAny()), Times.Never); - mockAttachmentHandler1.Verify(h => h.GetExtensionUris(), Times.Never); - mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Never); - mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); - mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + // assert + VerifyCompleteEvent(true, false, inputAttachments[0]); + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.IsAny()), Times.Never); + _mockAttachmentHandler1.Verify(h => h.GetExtensionUris(), Times.Never); + _mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Never); + _mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + _mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); - VerifyMetrics(inputCount: 1, outputCount: 1, status: "Canceled"); - } + VerifyMetrics(inputCount: 1, outputCount: 1, status: "Canceled"); + } - [TestMethod] - public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachments_IfOperationIsCancelled() + [TestMethod] + public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachments_IfOperationIsCancelled() + { + // arrange + _cancellationTokenSource.Cancel(); + List inputAttachments = new() { - // arrange - cancellationTokenSource.Cancel(); - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_input") - }; + new AttachmentSet(new Uri(Uri1), "uri1_input") + }; - // act - var result = await manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], cancellationTokenSource.Token); + // act + var result = await _manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], _cancellationTokenSource.Token); - // assert - Assert.AreEqual(1, result.Count); - Assert.IsTrue(result.Contains(inputAttachments[0])); - mockAttachmentHandler1.Verify(h => h.GetExtensionUris(), Times.Never); - mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Never); - mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); - mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + // assert + Assert.AreEqual(1, result.Count); + Assert.IsTrue(result.Contains(inputAttachments[0])); + _mockAttachmentHandler1.Verify(h => h.GetExtensionUris(), Times.Never); + _mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Never); + _mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + _mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); - VerifyMetrics(inputCount: 1, outputCount: 1, status: "Canceled"); - } + VerifyMetrics(inputCount: 1, outputCount: 1, status: "Canceled"); + } - [TestMethod] - public async Task ProcessTestRunAttachmentsAsync_ShouldReturnProcessedAttachmentsThroughEventsHandler_IfRelatedAttachmentsOnInput() + [TestMethod] + public async Task ProcessTestRunAttachmentsAsync_ShouldReturnProcessedAttachmentsThroughEventsHandler_IfRelatedAttachmentsOnInput() + { + // arrange + List inputAttachments = new() { - // arrange - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_input1"), - new AttachmentSet(new Uri(uri1), "uri1_input2"), - new AttachmentSet(new Uri(uri2), "uri2_input1"), - new AttachmentSet(new Uri(uri2), "uri2_input2"), - new AttachmentSet(new Uri(uri3), "uri3_input1"), - }; - - List outputAttachmentsForHandler1 = new List - { - new AttachmentSet(new Uri(uri1), "uri1_output") - }; + new AttachmentSet(new Uri(Uri1), "uri1_input1"), + new AttachmentSet(new Uri(Uri1), "uri1_input2"), + new AttachmentSet(new Uri(Uri2), "uri2_input1"), + new AttachmentSet(new Uri(Uri2), "uri2_input2"), + new AttachmentSet(new Uri(Uri3), "uri3_input1"), + }; + + List outputAttachmentsForHandler1 = new() + { + new AttachmentSet(new Uri(Uri1), "uri1_output") + }; - List outputAttachmentsForHandler2 = new List - { - new AttachmentSet(new Uri(uri2), "uri2_output") - }; + List outputAttachmentsForHandler2 = new() + { + new AttachmentSet(new Uri(Uri2), "uri2_output") + }; - mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(null, It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).ReturnsAsync(outputAttachmentsForHandler1); - mockAttachmentHandler2.Setup(h => h.ProcessAttachmentSetsAsync(null, It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).ReturnsAsync(outputAttachmentsForHandler2); + _mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(null, It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).ReturnsAsync(outputAttachmentsForHandler1); + _mockAttachmentHandler2.Setup(h => h.ProcessAttachmentSetsAsync(null, It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).ReturnsAsync(outputAttachmentsForHandler2); - // act - await manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], mockEventsHandler.Object, cancellationTokenSource.Token); + // act + await _manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], _mockEventsHandler.Object, _cancellationTokenSource.Token); - // assert - VerifyCompleteEvent(false, false, inputAttachments[4], outputAttachmentsForHandler1.First(), outputAttachmentsForHandler2.First()); - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.IsAny()), Times.Never); - mockEventsHandler.Verify(h => h.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never); - mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); - mockAttachmentHandler2.Verify(h => h.GetExtensionUris()); - mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 2 && c.Contains(inputAttachments[0]) && c.Contains(inputAttachments[1])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); - mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 2 && c.Contains(inputAttachments[2]) && c.Contains(inputAttachments[3])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); + // assert + VerifyCompleteEvent(false, false, inputAttachments[4], outputAttachmentsForHandler1.First(), outputAttachmentsForHandler2.First()); + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.IsAny()), Times.Never); + _mockEventsHandler.Verify(h => h.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never); + _mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); + _mockAttachmentHandler2.Verify(h => h.GetExtensionUris()); + _mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 2 && c.Contains(inputAttachments[0]) && c.Contains(inputAttachments[1])), It.IsAny>(), It.IsAny(), _cancellationTokenSource.Token)); + _mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 2 && c.Contains(inputAttachments[2]) && c.Contains(inputAttachments[3])), It.IsAny>(), It.IsAny(), _cancellationTokenSource.Token)); - VerifyMetrics(inputCount: 5, outputCount: 3); - } + VerifyMetrics(inputCount: 5, outputCount: 3); + } - [TestMethod] - public async Task ProcessTestRunAttachmentsAsync_ShouldReturnProcessedAttachments_IfRelatedAttachmentsOnInput() + [TestMethod] + public async Task ProcessTestRunAttachmentsAsync_ShouldReturnProcessedAttachments_IfRelatedAttachmentsOnInput() + { + // arrange + List inputAttachments = new() { - // arrange - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_input1"), - new AttachmentSet(new Uri(uri1), "uri1_input2"), - new AttachmentSet(new Uri(uri2), "uri2_input1"), - new AttachmentSet(new Uri(uri2), "uri2_input2"), - new AttachmentSet(new Uri(uri3), "uri3_input1"), - }; - - List outputAttachmentsForHandler1 = new List - { - new AttachmentSet(new Uri(uri1), "uri1_output") - }; - - List outputAttachmentsForHandler2 = new List - { - new AttachmentSet(new Uri(uri2), "uri2_output") - }; - - mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).ReturnsAsync(outputAttachmentsForHandler1); - mockAttachmentHandler2.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).ReturnsAsync(outputAttachmentsForHandler2); - - // act - var result = await manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], cancellationTokenSource.Token); - - // assert - Assert.AreEqual(3, result.Count); - Assert.IsTrue(result.Contains(inputAttachments[4])); - Assert.IsTrue(result.Contains(outputAttachmentsForHandler1[0])); - Assert.IsTrue(result.Contains(outputAttachmentsForHandler2[0])); - mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); - mockAttachmentHandler2.Verify(h => h.GetExtensionUris()); - mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 2 && c.Contains(inputAttachments[0]) && c.Contains(inputAttachments[1])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); - mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 2 && c.Contains(inputAttachments[2]) && c.Contains(inputAttachments[3])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); + new AttachmentSet(new Uri(Uri1), "uri1_input1"), + new AttachmentSet(new Uri(Uri1), "uri1_input2"), + new AttachmentSet(new Uri(Uri2), "uri2_input1"), + new AttachmentSet(new Uri(Uri2), "uri2_input2"), + new AttachmentSet(new Uri(Uri3), "uri3_input1"), + }; + + List outputAttachmentsForHandler1 = new() + { + new AttachmentSet(new Uri(Uri1), "uri1_output") + }; - VerifyMetrics(inputCount: 5, outputCount: 3); - } + List outputAttachmentsForHandler2 = new() + { + new AttachmentSet(new Uri(Uri2), "uri2_output") + }; + + _mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).ReturnsAsync(outputAttachmentsForHandler1); + _mockAttachmentHandler2.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).ReturnsAsync(outputAttachmentsForHandler2); + + // act + var result = await _manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], _cancellationTokenSource.Token); + + // assert + Assert.AreEqual(3, result.Count); + Assert.IsTrue(result.Contains(inputAttachments[4])); + Assert.IsTrue(result.Contains(outputAttachmentsForHandler1[0])); + Assert.IsTrue(result.Contains(outputAttachmentsForHandler2[0])); + _mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); + _mockAttachmentHandler2.Verify(h => h.GetExtensionUris()); + _mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 2 && c.Contains(inputAttachments[0]) && c.Contains(inputAttachments[1])), It.IsAny>(), It.IsAny(), _cancellationTokenSource.Token)); + _mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 2 && c.Contains(inputAttachments[2]) && c.Contains(inputAttachments[3])), It.IsAny>(), It.IsAny(), _cancellationTokenSource.Token)); + + VerifyMetrics(inputCount: 5, outputCount: 3); + } - [TestMethod] - public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachmentsThroughEventsHandler_IfOperationCancelled() + [TestMethod] + public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachmentsThroughEventsHandler_IfOperationCancelled() + { + // arrange + List inputAttachments = new() { - // arrange - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_input") - }; + new AttachmentSet(new Uri(Uri1), "uri1_input") + }; - ICollection outputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_output") - }; + ICollection outputAttachments = new List + { + new AttachmentSet(new Uri(Uri1), "uri1_output") + }; - var innerTaskCompletionSource = new TaskCompletionSource(); + var innerTaskCompletionSource = new TaskCompletionSource(); - mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) - .Returns((string configElement, ICollection i1, IProgress progress, IMessageLogger logger, CancellationToken cancellation) => + _mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) + .Returns((string configElement, ICollection i1, IProgress progress, IMessageLogger logger, CancellationToken cancellation) => { try { @@ -434,7 +433,7 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachmentsT if (i == 3) { - cancellationTokenSource.Cancel(); + _cancellationTokenSource.Cancel(); Task.Delay(500).Wait(); } } @@ -447,45 +446,45 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachmentsT return Task.FromResult(outputAttachments); }); - // act - await manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], mockEventsHandler.Object, cancellationTokenSource.Token); - Console.WriteLine("Attachments processing done"); - await innerTaskCompletionSource.Task; - - // assert - VerifyCompleteEvent(true, false, inputAttachments[0]); - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.IsAny()), Times.Exactly(4)); - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgs(a, 1)))); - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgs(a, 2)))); - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgs(a, 3)))); - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgs(a, 4)))); - mockEventsHandler.Verify(h => h.HandleLogMessage(TestMessageLevel.Informational, "Attachments processing was cancelled.")); - mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); - mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Never); - mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); - mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); - - VerifyMetrics(inputCount: 1, outputCount: 1, status: "Canceled"); - } - - [TestMethod] - public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachments_IfOperationCancelled() - { - // arrange - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_input") - }; + // act + await _manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], _mockEventsHandler.Object, _cancellationTokenSource.Token); + Console.WriteLine("Attachments processing done"); + await innerTaskCompletionSource.Task; + + // assert + VerifyCompleteEvent(true, false, inputAttachments[0]); + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.IsAny()), Times.Exactly(4)); + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgs(a, 1)))); + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgs(a, 2)))); + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgs(a, 3)))); + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgs(a, 4)))); + _mockEventsHandler.Verify(h => h.HandleLogMessage(TestMessageLevel.Informational, "Attachments processing was cancelled.")); + _mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); + _mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Never); + _mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), _cancellationTokenSource.Token)); + _mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + + VerifyMetrics(inputCount: 1, outputCount: 1, status: "Canceled"); + } - ICollection outputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_output") - }; + [TestMethod] + public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachments_IfOperationCancelled() + { + // arrange + List inputAttachments = new() + { + new AttachmentSet(new Uri(Uri1), "uri1_input") + }; - var innerTaskCompletionSource = new TaskCompletionSource(); + ICollection outputAttachments = new List + { + new AttachmentSet(new Uri(Uri1), "uri1_output") + }; + + var innerTaskCompletionSource = new TaskCompletionSource(); - mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) - .Returns((XmlElement configurationElement, ICollection i1, IProgress p, IMessageLogger logger, CancellationToken cancellation) => + _mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) + .Returns((XmlElement configurationElement, ICollection i1, IProgress p, IMessageLogger logger, CancellationToken cancellation) => { try { @@ -499,7 +498,7 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachments_ if (i == 3) { - cancellationTokenSource.Cancel(); + _cancellationTokenSource.Cancel(); Task.Delay(500).Wait(); } } @@ -512,57 +511,57 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachments_ return Task.FromResult(outputAttachments); }); - // act - var result = await manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], cancellationTokenSource.Token); - Console.WriteLine("Attachments processing done"); - await innerTaskCompletionSource.Task; - - // assert - Assert.IsNotNull(result); - Assert.AreEqual(1, result.Count); - Assert.IsTrue(result.Contains(inputAttachments[0])); - mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); - mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Never); - mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); - mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); - - VerifyMetrics(inputCount: 1, outputCount: 1, status: "Canceled"); - } + // act + var result = await _manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], _cancellationTokenSource.Token); + Console.WriteLine("Attachments processing done"); + await innerTaskCompletionSource.Task; + + // assert + Assert.IsNotNull(result); + Assert.AreEqual(1, result.Count); + Assert.IsTrue(result.Contains(inputAttachments[0])); + _mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); + _mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Never); + _mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), _cancellationTokenSource.Token)); + _mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + + VerifyMetrics(inputCount: 1, outputCount: 1, status: "Canceled"); + } - [TestMethod] - public async Task ProcessTestRunAttachmentsAsync_ShouldReturnProperlySendProgressEvents_IfHandlersPropagesEvents() + [TestMethod] + public async Task ProcessTestRunAttachmentsAsync_ShouldReturnProperlySendProgressEvents_IfHandlersPropagesEvents() + { + // arrange + List inputAttachments = new() { - // arrange - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_input"), - new AttachmentSet(new Uri(uri2), "uri2_input") - }; + new AttachmentSet(new Uri(Uri1), "uri1_input"), + new AttachmentSet(new Uri(Uri2), "uri2_input") + }; - ICollection outputAttachments1 = new List - { - new AttachmentSet(new Uri(uri1), "uri1_output") - }; + ICollection outputAttachments1 = new List + { + new AttachmentSet(new Uri(Uri1), "uri1_output") + }; - ICollection outputAttachments2 = new List - { - new AttachmentSet(new Uri(uri2), "uri2_output") - }; + ICollection outputAttachments2 = new List + { + new AttachmentSet(new Uri(Uri2), "uri2_output") + }; - var innerTaskCompletionSource = new TaskCompletionSource(); + var innerTaskCompletionSource = new TaskCompletionSource(); - int counter = 0; - mockEventsHandler.Setup(h => h.HandleTestRunAttachmentsProcessingProgress(It.IsAny())).Callback(() => + int counter = 0; + _mockEventsHandler.Setup(h => h.HandleTestRunAttachmentsProcessingProgress(It.IsAny())).Callback(() => + { + counter++; + if (counter == 6) { - counter++; - if (counter == 6) - { - innerTaskCompletionSource.TrySetResult(null); - } - }); + innerTaskCompletionSource.TrySetResult(null); + } + }); - mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(null, It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) - .Returns((XmlElement configurationElement, ICollection i1, IProgress progress, IMessageLogger logger, CancellationToken cancellation) => + _mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(null, It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) + .Returns((XmlElement configurationElement, ICollection i1, IProgress progress, IMessageLogger logger, CancellationToken cancellation) => { progress.Report(25); progress.Report(50); @@ -572,8 +571,8 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturnProperlySendProgres return Task.FromResult(outputAttachments1); }); - mockAttachmentHandler2.Setup(h => h.ProcessAttachmentSetsAsync(null, It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) - .Returns((XmlElement configurationElement, ICollection i1, IProgress progress, IMessageLogger logger, CancellationToken cancellation) => + _mockAttachmentHandler2.Setup(h => h.ProcessAttachmentSetsAsync(null, It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) + .Returns((XmlElement configurationElement, ICollection i1, IProgress progress, IMessageLogger logger, CancellationToken cancellation) => { progress.Report(50); logger.SendMessage(TestMessageLevel.Informational, "info"); @@ -581,44 +580,44 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturnProperlySendProgres return Task.FromResult(outputAttachments2); }); - // act - await manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], mockEventsHandler.Object, CancellationToken.None); - - // assert - await innerTaskCompletionSource.Task; - VerifyCompleteEvent(false, false, outputAttachments1.First(), outputAttachments2.First()); - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.IsAny()), Times.Exactly(6)); - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 1, 25, uri1)))); - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 1, 50, uri1)))); - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 1, 75, uri1)))); - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 1, 100, uri1)))); - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 2, 50, uri2)))); - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 2, 100, uri2)))); - mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); - mockAttachmentHandler2.Verify(h => h.GetExtensionUris()); - mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), CancellationToken.None)); - mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[1])), It.IsAny>(), It.IsAny(), CancellationToken.None)); - - mockEventsHandler.Verify(h => h.HandleLogMessage(TestMessageLevel.Informational, "info")); - mockEventsHandler.Verify(h => h.HandleLogMessage(TestMessageLevel.Error, "error")); - - VerifyMetrics(inputCount: 2, outputCount: 2); - } - - [TestMethod] - public async Task ProcessTestRunAttachmentsAsync_ShouldNotFailIfRunsettingsIsNull() - { - // arrange - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_input"), - new AttachmentSet(new Uri(uri2), "uri2_input") - }; - ICollection outputAttachments = new List - { - new AttachmentSet(new Uri(uri2), "uri2_output") - }; - mockAttachmentHandler2.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) + // act + await _manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], _mockEventsHandler.Object, CancellationToken.None); + + // assert + await innerTaskCompletionSource.Task; + VerifyCompleteEvent(false, false, outputAttachments1.First(), outputAttachments2.First()); + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.IsAny()), Times.Exactly(6)); + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 1, 25, Uri1)))); + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 1, 50, Uri1)))); + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 1, 75, Uri1)))); + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 1, 100, Uri1)))); + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 2, 50, Uri2)))); + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 2, 100, Uri2)))); + _mockAttachmentHandler1.Verify(h => h.GetExtensionUris()); + _mockAttachmentHandler2.Verify(h => h.GetExtensionUris()); + _mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), CancellationToken.None)); + _mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[1])), It.IsAny>(), It.IsAny(), CancellationToken.None)); + + _mockEventsHandler.Verify(h => h.HandleLogMessage(TestMessageLevel.Informational, "info")); + _mockEventsHandler.Verify(h => h.HandleLogMessage(TestMessageLevel.Error, "error")); + + VerifyMetrics(inputCount: 2, outputCount: 2); + } + + [TestMethod] + public async Task ProcessTestRunAttachmentsAsync_ShouldNotFailIfRunsettingsIsNull() + { + // arrange + List inputAttachments = new() + { + new AttachmentSet(new Uri(Uri1), "uri1_input"), + new AttachmentSet(new Uri(Uri2), "uri2_input") + }; + ICollection outputAttachments = new List + { + new AttachmentSet(new Uri(Uri2), "uri2_output") + }; + _mockAttachmentHandler2.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) .Returns((XmlElement configurationElement, ICollection i1, IProgress progress, IMessageLogger logger, CancellationToken cancellation) => { // assert @@ -626,32 +625,32 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldNotFailIfRunsettingsIsNul return Task.FromResult(outputAttachments); }); - // act - await manager.ProcessTestRunAttachmentsAsync(null, mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], mockEventsHandler.Object, cancellationTokenSource.Token); + // act + await _manager.ProcessTestRunAttachmentsAsync(null, _mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], _mockEventsHandler.Object, _cancellationTokenSource.Token); - // assert - mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())); - } + // assert + _mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())); + } - [DataTestMethod] - [DataRow(true)] - [DataRow(false)] - public async Task ProcessTestRunAttachmentsAsync_ShouldFlowCorrectDataCollectorConfiguration(bool withConfig) + [DataTestMethod] + [DataRow(true)] + [DataRow(false)] + public async Task ProcessTestRunAttachmentsAsync_ShouldFlowCorrectDataCollectorConfiguration(bool withConfig) + { + // arrange + List inputAttachments = new() { - // arrange - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_input"), - new AttachmentSet(new Uri(uri2), "uri2_input") - }; + new AttachmentSet(new Uri(Uri1), "uri1_input"), + new AttachmentSet(new Uri(Uri2), "uri2_input") + }; - List invokedDataCollectors = new List - { - new InvokedDataCollector(new Uri(uri1),withConfig ? "friendlyNameA" : "friendlyNameB", typeof(string).AssemblyQualifiedName, typeof(string).Assembly.Location, false) - }; + List invokedDataCollectors = new() + { + new InvokedDataCollector(new Uri(Uri1), withConfig ? "friendlyNameA" : "friendlyNameB", typeof(string).AssemblyQualifiedName, typeof(string).Assembly.Location, false) + }; - string runSettingsXml = - $@" + string runSettingsXml = + $@" @@ -665,53 +664,53 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldFlowCorrectDataCollectorC "; - mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) - .Returns((XmlElement configurationElement, ICollection i1, IProgress progress, IMessageLogger logger, CancellationToken cancellation) => + _mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) + .Returns((XmlElement configurationElement, ICollection i1, IProgress progress, IMessageLogger logger, CancellationToken cancellation) => + { + // assert + if (withConfig) { - // assert - if (withConfig) - { - Assert.IsNotNull(configurationElement); - Assert.AreEqual("Value", configurationElement.InnerXml); - } - else - { - Assert.IsNull(configurationElement); - } + Assert.IsNotNull(configurationElement); + Assert.AreEqual("Value", configurationElement.InnerXml); + } + else + { + Assert.IsNull(configurationElement); + } - ICollection outputAttachments = new List - { - new AttachmentSet(new Uri(uri2), "uri2_output") - }; - return Task.FromResult(outputAttachments); - }); + ICollection outputAttachments = new List + { + new AttachmentSet(new Uri(Uri2), "uri2_output") + }; + return Task.FromResult(outputAttachments); + }); - // act - await manager.ProcessTestRunAttachmentsAsync(runSettingsXml, mockRequestData.Object, inputAttachments, invokedDataCollectors, mockEventsHandler.Object, cancellationTokenSource.Token); + // act + await _manager.ProcessTestRunAttachmentsAsync(runSettingsXml, _mockRequestData.Object, inputAttachments, invokedDataCollectors, _mockEventsHandler.Object, _cancellationTokenSource.Token); - // assert - mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())); - } + // assert + _mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())); + } - [TestMethod] - public async Task ProcessTestRunAttachmentsAsync_ShouldNotConsumeAttachmentsIfProcessorFails() + [TestMethod] + public async Task ProcessTestRunAttachmentsAsync_ShouldNotConsumeAttachmentsIfProcessorFails() + { + // arrange + List inputAttachments = new() { - // arrange - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_input_1") - }; - inputAttachments[0].Attachments.Add(UriDataAttachment.CreateFrom("file1", "Sample1")); - inputAttachments[0].Attachments.Add(UriDataAttachment.CreateFrom("file2", "Sample2")); - inputAttachments[0].Attachments.Add(UriDataAttachment.CreateFrom("file3", "Sample3")); + new AttachmentSet(new Uri(Uri1), "uri1_input_1") + }; + inputAttachments[0].Attachments.Add(UriDataAttachment.CreateFrom("file1", "Sample1")); + inputAttachments[0].Attachments.Add(UriDataAttachment.CreateFrom("file2", "Sample2")); + inputAttachments[0].Attachments.Add(UriDataAttachment.CreateFrom("file3", "Sample3")); - mockAttachmentHandler1.Setup(h => h.GetExtensionUris()).Returns(new[] { new Uri(uri1) }); - mockAttachmentHandler2.Setup(h => h.GetExtensionUris()).Returns(new[] { new Uri(uri1) }); + _mockAttachmentHandler1.Setup(h => h.GetExtensionUris()).Returns(new[] { new Uri(Uri1) }); + _mockAttachmentHandler2.Setup(h => h.GetExtensionUris()).Returns(new[] { new Uri(Uri1) }); - bool firstProcessorFailed = false; + bool firstProcessorFailed = false; - mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) + _mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) .Returns((XmlElement configurationElement, ICollection i1, IProgress progress, IMessageLogger logger, CancellationToken cancellation) => { try @@ -725,13 +724,13 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldNotConsumeAttachmentsIfPr } }); - ICollection output = new List - { - new AttachmentSet(new Uri(uri1), "uri1_input_1") - }; - output.Single().Attachments.Add(UriDataAttachment.CreateFrom("file4", "Merged")); + ICollection output = new List + { + new AttachmentSet(new Uri(Uri1), "uri1_input_1") + }; + output.Single().Attachments.Add(UriDataAttachment.CreateFrom("file4", "Merged")); - mockAttachmentHandler2.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) + _mockAttachmentHandler2.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) .Returns((XmlElement configurationElement, ICollection i1, IProgress progress, IMessageLogger logger, CancellationToken cancellation) => { // assert @@ -746,33 +745,33 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldNotConsumeAttachmentsIfPr return Task.FromResult(output); }); - // act - await manager.ProcessTestRunAttachmentsAsync(null, mockRequestData.Object, inputAttachments, new List(), mockEventsHandler.Object, cancellationTokenSource.Token); + // act + await _manager.ProcessTestRunAttachmentsAsync(null, _mockRequestData.Object, inputAttachments, new List(), _mockEventsHandler.Object, _cancellationTokenSource.Token); - // assert - mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Once()); - mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Once()); - VerifyCompleteEvent(false, false, output.ToArray()); - } + // assert + _mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Once()); + _mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Once()); + VerifyCompleteEvent(false, false, output.ToArray()); + } - [TestMethod] - public async Task ProcessTestRunAttachmentsAsync_ShouldNotConsumeAttachmentsIfAllProcessorsFail() + [TestMethod] + public async Task ProcessTestRunAttachmentsAsync_ShouldNotConsumeAttachmentsIfAllProcessorsFail() + { + // arrange + List inputAttachments = new() { - // arrange - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_input_1"), - }; - inputAttachments[0].Attachments.Add(UriDataAttachment.CreateFrom("file1", "Sample1")); - inputAttachments[0].Attachments.Add(UriDataAttachment.CreateFrom("file2", "Sample2")); - inputAttachments[0].Attachments.Add(UriDataAttachment.CreateFrom("file3", "Sample3")); + new AttachmentSet(new Uri(Uri1), "uri1_input_1"), + }; + inputAttachments[0].Attachments.Add(UriDataAttachment.CreateFrom("file1", "Sample1")); + inputAttachments[0].Attachments.Add(UriDataAttachment.CreateFrom("file2", "Sample2")); + inputAttachments[0].Attachments.Add(UriDataAttachment.CreateFrom("file3", "Sample3")); - mockAttachmentHandler1.Setup(h => h.GetExtensionUris()).Returns(new[] { new Uri(uri1) }); - mockAttachmentHandler2.Setup(h => h.GetExtensionUris()).Returns(new[] { new Uri(uri1) }); + _mockAttachmentHandler1.Setup(h => h.GetExtensionUris()).Returns(new[] { new Uri(Uri1) }); + _mockAttachmentHandler2.Setup(h => h.GetExtensionUris()).Returns(new[] { new Uri(Uri1) }); - bool firstProcessorFailed = false; - mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) + bool firstProcessorFailed = false; + _mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) .Returns((XmlElement configurationElement, ICollection i1, IProgress progress, IMessageLogger logger, CancellationToken cancellation) => { try @@ -786,8 +785,8 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldNotConsumeAttachmentsIfAl } }); - bool secondProcessorFailed = false; - mockAttachmentHandler2.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) + bool secondProcessorFailed = false; + _mockAttachmentHandler2.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) .Returns((XmlElement configurationElement, ICollection i1, IProgress progress, IMessageLogger logger, CancellationToken cancellation) => { try @@ -809,75 +808,74 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldNotConsumeAttachmentsIfAl } }); - // act - await manager.ProcessTestRunAttachmentsAsync(null, mockRequestData.Object, inputAttachments, new List(), mockEventsHandler.Object, cancellationTokenSource.Token); + // act + await _manager.ProcessTestRunAttachmentsAsync(null, _mockRequestData.Object, inputAttachments, new List(), _mockEventsHandler.Object, _cancellationTokenSource.Token); - // assert - Assert.IsTrue(firstProcessorFailed && secondProcessorFailed); - mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Once()); - mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Once()); - VerifyCompleteEvent(false, false, inputAttachments.ToArray()); - } + // assert + Assert.IsTrue(firstProcessorFailed && secondProcessorFailed); + _mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Once()); + _mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Once()); + VerifyCompleteEvent(false, false, inputAttachments.ToArray()); + } - [TestMethod] - public async Task ProcessTestRunAttachmentsAsync_ShouldSkipAttachmentProcessorIfDoesNotSupportIncrementalProcessing() + [TestMethod] + public async Task ProcessTestRunAttachmentsAsync_ShouldSkipAttachmentProcessorIfDoesNotSupportIncrementalProcessing() + { + // arrange + var inputAttachments = new List { - // arrange - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_input"), - new AttachmentSet(new Uri(uri2), "uri2_input") - }; - mockAttachmentHandler1.Setup(x => x.SupportsIncrementalProcessing).Returns(false); + new AttachmentSet(new Uri(Uri1), "uri1_input"), + new AttachmentSet(new Uri(Uri2), "uri2_input") + }; + _mockAttachmentHandler1.Setup(x => x.SupportsIncrementalProcessing).Returns(false); - // act - await manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], mockEventsHandler.Object, cancellationTokenSource.Token); + // act + await _manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], _mockEventsHandler.Object, _cancellationTokenSource.Token); - // assert - // We expect that first attachment is still returned as-is because not processed. - VerifyCompleteEvent(false, false, inputAttachments.First()); - mockAttachmentHandler1.Verify(h => h.GetExtensionUris(), Times.Never); - mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + // assert + // We expect that first attachment is still returned as-is because not processed. + VerifyCompleteEvent(false, false, inputAttachments.First()); + _mockAttachmentHandler1.Verify(h => h.GetExtensionUris(), Times.Never); + _mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); - mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Once); - mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Once); + _mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Once); + _mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Once); - mockEventsHandler.Verify(h => h.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); - } + _mockEventsHandler.Verify(h => h.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); + } - private void VerifyMetrics(int inputCount, int outputCount, string status = "Completed") - { - mockEventSource.Verify(s => s.TestRunAttachmentsProcessingStart(inputCount)); - mockEventSource.Verify(s => s.TestRunAttachmentsProcessingStop(outputCount)); + private void VerifyMetrics(int inputCount, int outputCount, string status = "Completed") + { + _mockEventSource.Verify(s => s.TestRunAttachmentsProcessingStart(inputCount)); + _mockEventSource.Verify(s => s.TestRunAttachmentsProcessingStop(outputCount)); - mockMetricsCollection.Verify(m => m.Add(TelemetryDataConstants.NumberOfAttachmentsSentForProcessing, inputCount)); - mockMetricsCollection.Verify(m => m.Add(TelemetryDataConstants.NumberOfAttachmentsAfterProcessing, outputCount)); - mockMetricsCollection.Verify(m => m.Add(TelemetryDataConstants.AttachmentsProcessingState, status)); - mockMetricsCollection.Verify(m => m.Add(TelemetryDataConstants.TimeTakenInSecForAttachmentsProcessing, It.IsAny())); - } + _mockMetricsCollection.Verify(m => m.Add(TelemetryDataConstants.NumberOfAttachmentsSentForProcessing, inputCount)); + _mockMetricsCollection.Verify(m => m.Add(TelemetryDataConstants.NumberOfAttachmentsAfterProcessing, outputCount)); + _mockMetricsCollection.Verify(m => m.Add(TelemetryDataConstants.AttachmentsProcessingState, status)); + _mockMetricsCollection.Verify(m => m.Add(TelemetryDataConstants.TimeTakenInSecForAttachmentsProcessing, It.IsAny())); + } - private void VerifyCompleteEvent(bool isCanceled, bool containsError, params AttachmentSet[] expectedSets) - { - mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingComplete( - It.Is(a => a.IsCanceled == isCanceled && (a.Error != null) == containsError), - It.Is>(c => c.Count == expectedSets.Length && expectedSets.All(e => c.Contains(e))))); - } + private void VerifyCompleteEvent(bool isCanceled, bool containsError, params AttachmentSet[] expectedSets) + { + _mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingComplete( + It.Is(a => a.IsCanceled == isCanceled && (a.Error != null) == containsError), + It.Is>(c => c.Count == expectedSets.Length && expectedSets.All(e => c.Contains(e))))); + } - private bool VerifyProgressArgs(TestRunAttachmentsProcessingProgressEventArgs args, int progress) - { - Assert.AreEqual(1, args.CurrentAttachmentProcessorIndex); - Assert.AreEqual(2, args.AttachmentProcessorsCount); - Assert.AreEqual(1, args.CurrentAttachmentProcessorUris.Count); - Assert.AreEqual(uri1, args.CurrentAttachmentProcessorUris.First().AbsoluteUri); - return progress == args.CurrentAttachmentProcessorProgress; - } + private bool VerifyProgressArgs(TestRunAttachmentsProcessingProgressEventArgs args, int progress) + { + Assert.AreEqual(1, args.CurrentAttachmentProcessorIndex); + Assert.AreEqual(2, args.AttachmentProcessorsCount); + Assert.AreEqual(1, args.CurrentAttachmentProcessorUris.Count); + Assert.AreEqual(Uri1, args.CurrentAttachmentProcessorUris.First().AbsoluteUri); + return progress == args.CurrentAttachmentProcessorProgress; + } - private bool VerifyProgressArgsForTwoHandlers(TestRunAttachmentsProcessingProgressEventArgs args, long handlerIndex, long progress, string uri) - { - return progress == args.CurrentAttachmentProcessorProgress && - args.CurrentAttachmentProcessorIndex == handlerIndex && - args.CurrentAttachmentProcessorUris.First().AbsoluteUri == uri && - args.AttachmentProcessorsCount == 2; - } + private bool VerifyProgressArgsForTwoHandlers(TestRunAttachmentsProcessingProgressEventArgs args, long handlerIndex, long progress, string uri) + { + return progress == args.CurrentAttachmentProcessorProgress && + args.CurrentAttachmentProcessorIndex == handlerIndex && + args.CurrentAttachmentProcessorUris.First().AbsoluteUri == uri && + args.AttachmentProcessorsCount == 2; } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs index 667147dd02..e0db686d3c 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs @@ -1,169 +1,168 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Client +namespace TestPlatform.CrossPlatEngine.UnitTests.Client; + +using System; +using System.IO; +using System.Collections.Generic; +using System.Linq; +using System.Threading; + +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class InProcessProxyDiscoveryManagerTests { - using System; - using System.IO; - using System.Collections.Generic; - using System.Linq; - using System.Threading; - - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - [TestClass] - public class InProcessProxyDiscoveryManagerTests + private Mock _mockTestHostManagerFactory; + private InProcessProxyDiscoveryManager _inProcessProxyDiscoveryManager; + private Mock _mockDiscoveryManager; + private Mock _mockTestHostManager; + + public InProcessProxyDiscoveryManagerTests() + { + _mockTestHostManagerFactory = new Mock(); + _mockDiscoveryManager = new Mock(); + _mockTestHostManager = new Mock(); + _mockTestHostManagerFactory.Setup(o => o.GetDiscoveryManager()).Returns(_mockDiscoveryManager.Object); + _inProcessProxyDiscoveryManager = new InProcessProxyDiscoveryManager(_mockTestHostManager.Object, _mockTestHostManagerFactory.Object); + } + + [TestCleanup] + public void TestCleanup() { - private Mock mockTestHostManagerFactory; - private InProcessProxyDiscoveryManager inProcessProxyDiscoveryManager; - private Mock mockDiscoveryManager; - private Mock mockTestHostManager; - - public InProcessProxyDiscoveryManagerTests() - { - this.mockTestHostManagerFactory = new Mock(); - this.mockDiscoveryManager = new Mock(); - this.mockTestHostManager = new Mock(); - this.mockTestHostManagerFactory.Setup(o => o.GetDiscoveryManager()).Returns(this.mockDiscoveryManager.Object); - this.inProcessProxyDiscoveryManager = new InProcessProxyDiscoveryManager(this.mockTestHostManager.Object, this.mockTestHostManagerFactory.Object); - } - - [TestCleanup] - public void TestCleanup() - { - this.mockDiscoveryManager = null; - this.mockTestHostManagerFactory = null; - this.inProcessProxyDiscoveryManager = null; - this.mockTestHostManager = null; - } - - [TestMethod] - public void DiscoverTestsShouldCallInitialize() - { - var manualResetEvent = new ManualResetEvent(false); - this.mockDiscoveryManager.Setup(o => o.Initialize(Enumerable.Empty(), null)).Callback( - () => manualResetEvent.Set()); - - var discoveryCriteria = new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty); - this.inProcessProxyDiscoveryManager.DiscoverTests(discoveryCriteria, null); - - Assert.IsTrue(manualResetEvent.WaitOne(5000), "DiscoverTests should call Initialize"); - } - - [TestMethod] - public void DiscoverTestsShouldUpdateTestPluginCacheWithExtensionsReturnByTestHost() - { - var manualResetEvent = new ManualResetEvent(false); - this.mockDiscoveryManager.Setup(o => o.Initialize(Enumerable.Empty(), null)).Callback( - () => manualResetEvent.Set()); - - var path = Path.Combine(Path.GetTempPath(), "DiscoveryDummy.dll"); - this.mockTestHostManager.Setup(o => o.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new List { path }); - var expectedResult = TestPluginCache.Instance.GetExtensionPaths(string.Empty); - expectedResult.Add(path); - var discoveryCriteria = new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty); - - this.inProcessProxyDiscoveryManager.DiscoverTests(discoveryCriteria, null); - - Assert.IsTrue(manualResetEvent.WaitOne(5000), "DiscoverTests should call Initialize"); - CollectionAssert.AreEquivalent(expectedResult, TestPluginCache.Instance.GetExtensionPaths(string.Empty)); - } - - [TestMethod] - public void DiscoverTestsShouldCallDiscoveryManagerDiscoverTests() - { - var discoveryCriteria = new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty); - var mockTestDiscoveryEventsHandler = new Mock(); - var manualResetEvent = new ManualResetEvent(false); - - this.mockDiscoveryManager.Setup(o => o.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object)).Callback( - () => manualResetEvent.Set()); - - this.inProcessProxyDiscoveryManager.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object); - - Assert.IsTrue(manualResetEvent.WaitOne(5000), "IDiscoveryManager.DiscoverTests should get called"); - } - - [TestMethod] - public void DiscoverTestsShouldCatchExceptionAndCallHandleDiscoveryComplete() - { - var discoveryCriteria = new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty); - var mockTestDiscoveryEventsHandler = new Mock(); - var manualResetEvent = new ManualResetEvent(false); - - this.mockDiscoveryManager.Setup(o => o.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object)).Callback( - () => throw new Exception()); - - mockTestDiscoveryEventsHandler.Setup(o => o.HandleDiscoveryComplete(It.IsAny(), It.IsAny>())).Callback( - () => manualResetEvent.Set()); - - this.inProcessProxyDiscoveryManager.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object); - - Assert.IsTrue(manualResetEvent.WaitOne(5000), "ITestDiscoveryEventsHandler.HandleDiscoveryComplete should get called"); - } - - [TestMethod] - public void AbortShouldCallDiscoveryManagerAbort() - { - var manualResetEvent = new ManualResetEvent(false); - - this.mockDiscoveryManager.Setup(o => o.Abort()).Callback( - () => manualResetEvent.Set()); - - this.inProcessProxyDiscoveryManager.Abort(); - - Assert.IsTrue(manualResetEvent.WaitOne(5000), "IDiscoveryManager.Abort should get called"); - } - - [TestMethod] - public void DiscoverTestRunShouldAllowRuntimeProviderToUpdateAdapterSource() - { - var inputSources = new List { "test.dll" }; - var discoveryCriteria = new DiscoveryCriteria(inputSources, 1, string.Empty); - var mockTestDiscoveryEventsHandler = new Mock(); - var manualResetEvent = new ManualResetEvent(false); - - this.mockTestHostManager.Setup(hm => hm.GetTestSources(discoveryCriteria.Sources)).Returns(discoveryCriteria.Sources); - this.mockDiscoveryManager.Setup(o => o.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object)).Callback( - () => manualResetEvent.Set()); + _mockDiscoveryManager = null; + _mockTestHostManagerFactory = null; + _inProcessProxyDiscoveryManager = null; + _mockTestHostManager = null; + } - this.inProcessProxyDiscoveryManager = new InProcessProxyDiscoveryManager(this.mockTestHostManager.Object, this.mockTestHostManagerFactory.Object); - this.inProcessProxyDiscoveryManager.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object); - - Assert.IsTrue(manualResetEvent.WaitOne(5000), "IDiscoveryManager.DiscoverTests should get called"); - this.mockTestHostManager.Verify(hm => hm.GetTestSources(inputSources), Times.Once); - } + [TestMethod] + public void DiscoverTestsShouldCallInitialize() + { + var manualResetEvent = new ManualResetEvent(false); + _mockDiscoveryManager.Setup(o => o.Initialize(Enumerable.Empty(), null)).Callback( + () => manualResetEvent.Set()); + + var discoveryCriteria = new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty); + _inProcessProxyDiscoveryManager.DiscoverTests(discoveryCriteria, null); + + Assert.IsTrue(manualResetEvent.WaitOne(5000), "DiscoverTests should call Initialize"); + } + + [TestMethod] + public void DiscoverTestsShouldUpdateTestPluginCacheWithExtensionsReturnByTestHost() + { + var manualResetEvent = new ManualResetEvent(false); + _mockDiscoveryManager.Setup(o => o.Initialize(Enumerable.Empty(), null)).Callback( + () => manualResetEvent.Set()); + + var path = Path.Combine(Path.GetTempPath(), "DiscoveryDummy.dll"); + _mockTestHostManager.Setup(o => o.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new List { path }); + var expectedResult = TestPluginCache.Instance.GetExtensionPaths(string.Empty); + expectedResult.Add(path); + var discoveryCriteria = new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty); + + _inProcessProxyDiscoveryManager.DiscoverTests(discoveryCriteria, null); + + Assert.IsTrue(manualResetEvent.WaitOne(5000), "DiscoverTests should call Initialize"); + CollectionAssert.AreEquivalent(expectedResult, TestPluginCache.Instance.GetExtensionPaths(string.Empty)); + } + + [TestMethod] + public void DiscoverTestsShouldCallDiscoveryManagerDiscoverTests() + { + var discoveryCriteria = new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty); + var mockTestDiscoveryEventsHandler = new Mock(); + var manualResetEvent = new ManualResetEvent(false); + + _mockDiscoveryManager.Setup(o => o.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object)).Callback( + () => manualResetEvent.Set()); + + _inProcessProxyDiscoveryManager.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object); + + Assert.IsTrue(manualResetEvent.WaitOne(5000), "IDiscoveryManager.DiscoverTests should get called"); + } - [TestMethod] - public void DiscoverTestRunShouldUpdateTestSourcesIfSourceDiffersFromTestHostManagerSource() - { - var actualSources = new List { "actualSource.dll" }; - var inputSource = new List { "inputPackage.appxrecipe" }; + [TestMethod] + public void DiscoverTestsShouldCatchExceptionAndCallHandleDiscoveryComplete() + { + var discoveryCriteria = new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty); + var mockTestDiscoveryEventsHandler = new Mock(); + var manualResetEvent = new ManualResetEvent(false); + + _mockDiscoveryManager.Setup(o => o.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object)).Callback( + () => throw new Exception()); + + mockTestDiscoveryEventsHandler.Setup(o => o.HandleDiscoveryComplete(It.IsAny(), It.IsAny>())).Callback( + () => manualResetEvent.Set()); + + _inProcessProxyDiscoveryManager.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object); + + Assert.IsTrue(manualResetEvent.WaitOne(5000), "ITestDiscoveryEventsHandler.HandleDiscoveryComplete should get called"); + } + + [TestMethod] + public void AbortShouldCallDiscoveryManagerAbort() + { + var manualResetEvent = new ManualResetEvent(false); + + _mockDiscoveryManager.Setup(o => o.Abort()).Callback( + () => manualResetEvent.Set()); + + _inProcessProxyDiscoveryManager.Abort(); + + Assert.IsTrue(manualResetEvent.WaitOne(5000), "IDiscoveryManager.Abort should get called"); + } + + [TestMethod] + public void DiscoverTestRunShouldAllowRuntimeProviderToUpdateAdapterSource() + { + var inputSources = new List { "test.dll" }; + var discoveryCriteria = new DiscoveryCriteria(inputSources, 1, string.Empty); + var mockTestDiscoveryEventsHandler = new Mock(); + var manualResetEvent = new ManualResetEvent(false); + + _mockTestHostManager.Setup(hm => hm.GetTestSources(discoveryCriteria.Sources)).Returns(discoveryCriteria.Sources); + _mockDiscoveryManager.Setup(o => o.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object)).Callback( + () => manualResetEvent.Set()); + + _inProcessProxyDiscoveryManager = new InProcessProxyDiscoveryManager(_mockTestHostManager.Object, _mockTestHostManagerFactory.Object); + _inProcessProxyDiscoveryManager.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object); + + Assert.IsTrue(manualResetEvent.WaitOne(5000), "IDiscoveryManager.DiscoverTests should get called"); + _mockTestHostManager.Verify(hm => hm.GetTestSources(inputSources), Times.Once); + } + + [TestMethod] + public void DiscoverTestRunShouldUpdateTestSourcesIfSourceDiffersFromTestHostManagerSource() + { + var actualSources = new List { "actualSource.dll" }; + var inputSource = new List { "inputPackage.appxrecipe" }; - var discoveryCriteria = new DiscoveryCriteria(inputSource, 1, string.Empty); - var mockTestDiscoveryEventsHandler = new Mock(); - var manualResetEvent = new ManualResetEvent(false); + var discoveryCriteria = new DiscoveryCriteria(inputSource, 1, string.Empty); + var mockTestDiscoveryEventsHandler = new Mock(); + var manualResetEvent = new ManualResetEvent(false); - this.mockTestHostManager.Setup(hm => hm.GetTestSources(discoveryCriteria.Sources)).Returns(actualSources); + _mockTestHostManager.Setup(hm => hm.GetTestSources(discoveryCriteria.Sources)).Returns(actualSources); - this.mockDiscoveryManager.Setup(o => o.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object)).Callback( - () => manualResetEvent.Set()); + _mockDiscoveryManager.Setup(o => o.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object)).Callback( + () => manualResetEvent.Set()); - this.inProcessProxyDiscoveryManager.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object); + _inProcessProxyDiscoveryManager.DiscoverTests(discoveryCriteria, mockTestDiscoveryEventsHandler.Object); - Assert.IsTrue(manualResetEvent.WaitOne(5000), "IDiscoveryManager.DiscoverTests should get called"); + Assert.IsTrue(manualResetEvent.WaitOne(5000), "IDiscoveryManager.DiscoverTests should get called"); - // AdapterSourceMap should contain updated testSources. - Assert.AreEqual(actualSources.FirstOrDefault(), discoveryCriteria.AdapterSourceMap.FirstOrDefault().Value.FirstOrDefault()); - Assert.AreEqual(inputSource.FirstOrDefault(), discoveryCriteria.Package); - } + // AdapterSourceMap should contain updated testSources. + Assert.AreEqual(actualSources.FirstOrDefault(), discoveryCriteria.AdapterSourceMap.FirstOrDefault().Value.FirstOrDefault()); + Assert.AreEqual(inputSource.FirstOrDefault(), discoveryCriteria.Package); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs index f4f2ad00ff..d1040a6db8 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs @@ -1,206 +1,205 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Client +namespace TestPlatform.CrossPlatEngine.UnitTests.Client; + +using System; +using System.IO; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Moq; + +[TestClass] +public class InProcessProxyExecutionManagerTests { - using System; - using System.IO; - using System.Collections.Generic; - using System.Linq; - using System.Threading; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - - [TestClass] - public class InProcessProxyExecutionManagerTests + private Mock _mockTestHostManagerFactory; + private InProcessProxyExecutionManager _inProcessProxyExecutionManager; + private Mock _mockExecutionManager; + private Mock _mockTestHostManager; + + public InProcessProxyExecutionManagerTests() { - private Mock mockTestHostManagerFactory; - private InProcessProxyExecutionManager inProcessProxyExecutionManager; - private Mock mockExecutionManager; - private Mock mockTestHostManager; - - public InProcessProxyExecutionManagerTests() - { - this.mockTestHostManagerFactory = new Mock(); - this.mockExecutionManager = new Mock(); - this.mockTestHostManager = new Mock(); - this.mockTestHostManagerFactory.Setup(o => o.GetExecutionManager()).Returns(this.mockExecutionManager.Object); - this.inProcessProxyExecutionManager = new InProcessProxyExecutionManager(this.mockTestHostManager.Object, this.mockTestHostManagerFactory.Object); - } - - [TestCleanup] - public void TestCleanup() - { - this.mockExecutionManager = null; - this.mockTestHostManagerFactory = null; - this.inProcessProxyExecutionManager = null; - this.mockTestHostManager = null; - } - - - [TestMethod] - public void StartTestRunShouldCallInitialize() - { - var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); - var mockTestMessageEventHandler = new Mock(); - this.inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); - - this.mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty(), It.IsAny()), Times.Once, "StartTestRun should call Initialize if not already initialized"); - } - - [TestMethod] - public void StartTestRunShouldUpdateTestPlauginCacheWithExtensionsReturnByTestHost() - { - var path = Path.Combine(Path.GetTempPath(), "dummy.dll"); - this.mockTestHostManager.Setup(o => o.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new List { path }); - var expectedResult = TestPluginCache.Instance.GetExtensionPaths(string.Empty); - expectedResult.Add(path); - - var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); - this.inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); - - CollectionAssert.AreEquivalent(expectedResult, TestPluginCache.Instance.GetExtensionPaths(string.Empty)); - } - - [TestMethod] - public void StartTestRunShouldCallExecutionManagerStartTestRunWithAdapterSourceMap() - { - var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); - var manualResetEvent = new ManualResetEvent(true); - - this.mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.AdapterSourceMap, null, testRunCriteria.TestRunSettings, It.IsAny(), null, null)).Callback( - () => manualResetEvent.Set()); - - this.inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); - - Assert.IsTrue(manualResetEvent.WaitOne(5000), "IExecutionManager.StartTestRun should get called"); - } - - [TestMethod] - public void StartTestRunShouldAllowRuntimeProviderToUpdateAdapterSource() - { - var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); + _mockTestHostManagerFactory = new Mock(); + _mockExecutionManager = new Mock(); + _mockTestHostManager = new Mock(); + _mockTestHostManagerFactory.Setup(o => o.GetExecutionManager()).Returns(_mockExecutionManager.Object); + _inProcessProxyExecutionManager = new InProcessProxyExecutionManager(_mockTestHostManager.Object, _mockTestHostManagerFactory.Object); + } - this.mockTestHostManager.Setup(hm => hm.GetTestSources(testRunCriteria.Sources)).Returns(testRunCriteria.Sources); + [TestCleanup] + public void TestCleanup() + { + _mockExecutionManager = null; + _mockTestHostManagerFactory = null; + _inProcessProxyExecutionManager = null; + _mockTestHostManager = null; + } - this.inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); - this.mockTestHostManager.Verify(hm => hm.GetTestSources(testRunCriteria.Sources), Times.Once); - } + [TestMethod] + public void StartTestRunShouldCallInitialize() + { + var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); + var mockTestMessageEventHandler = new Mock(); + _inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); - [TestMethod] - public void StartTestRunShouldCallExecutionManagerStartTestRunWithTestCase() - { - var testRunCriteria = new TestRunCriteria( - new List { new TestCase("A.C.M", new Uri("excutor://dummy"), "s.dll") }, - frequencyOfRunStatsChangeEvent: 10); - var manualResetEvent = new ManualResetEvent(true); + _mockExecutionManager.Verify(o => o.Initialize(Enumerable.Empty(), It.IsAny()), Times.Once, "StartTestRun should call Initialize if not already initialized"); + } + + [TestMethod] + public void StartTestRunShouldUpdateTestPlauginCacheWithExtensionsReturnByTestHost() + { + var path = Path.Combine(Path.GetTempPath(), "dummy.dll"); + _mockTestHostManager.Setup(o => o.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new List { path }); + var expectedResult = TestPluginCache.Instance.GetExtensionPaths(string.Empty); + expectedResult.Add(path); - this.mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.Tests, null, testRunCriteria.TestRunSettings, It.IsAny(), null, null)).Callback( - () => manualResetEvent.Set()); + var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); + _inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); - this.inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); + CollectionAssert.AreEquivalent(expectedResult, TestPluginCache.Instance.GetExtensionPaths(string.Empty)); + } - Assert.IsTrue(manualResetEvent.WaitOne(5000), "IExecutionManager.StartTestRun should get called"); - } + [TestMethod] + public void StartTestRunShouldCallExecutionManagerStartTestRunWithAdapterSourceMap() + { + var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); + var manualResetEvent = new ManualResetEvent(true); - [TestMethod] - public void StartTestRunShouldUpdateTestCaseSourceIfTestCaseSourceDiffersFromTestHostManagerSource() - { - var actualSources = new List { "actualSource.dll" }; - var inputSource = new List { "inputPackage.appxrecipe" }; + _mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.AdapterSourceMap, null, testRunCriteria.TestRunSettings, It.IsAny(), null, null)).Callback( + () => manualResetEvent.Set()); - var testRunCriteria = new TestRunCriteria( - new List { new TestCase("A.C.M", new Uri("excutor://dummy"), inputSource.FirstOrDefault()) }, - frequencyOfRunStatsChangeEvent: 10); - var manualResetEvent = new ManualResetEvent(false); + _inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); - this.mockTestHostManager.Setup(hm => hm.GetTestSources(inputSource)).Returns(actualSources); + Assert.IsTrue(manualResetEvent.WaitOne(5000), "IExecutionManager.StartTestRun should get called"); + } - this.mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.Tests, inputSource.FirstOrDefault(), testRunCriteria.TestRunSettings, It.IsAny(), null, null)) - .Callback(() => manualResetEvent.Set()); + [TestMethod] + public void StartTestRunShouldAllowRuntimeProviderToUpdateAdapterSource() + { + var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); - this.inProcessProxyExecutionManager = new InProcessProxyExecutionManager(this.mockTestHostManager.Object, this.mockTestHostManagerFactory.Object); + _mockTestHostManager.Setup(hm => hm.GetTestSources(testRunCriteria.Sources)).Returns(testRunCriteria.Sources); - this.inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); + _inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); - Assert.IsTrue(manualResetEvent.WaitOne(5000), "IExecutionManager.StartTestRun should get called"); - this.mockExecutionManager.Verify(o => o.StartTestRun(testRunCriteria.Tests, inputSource.FirstOrDefault(), testRunCriteria.TestRunSettings, It.IsAny(), null, null)); - this.mockTestHostManager.Verify(hm => hm.GetTestSources(inputSource), Times.Once); - Assert.AreEqual(actualSources.FirstOrDefault(), testRunCriteria.Tests.FirstOrDefault().Source); - } + _mockTestHostManager.Verify(hm => hm.GetTestSources(testRunCriteria.Sources), Times.Once); + } - [TestMethod] - public void StartTestRunShouldNotUpdateTestCaseSourceIfTestCaseSourceDiffersFromTestHostManagerSource() - { - var actualSources = new List { "actualSource.dll" }; - var testRunCriteria = new TestRunCriteria( - new List { new TestCase("A.C.M", new Uri("excutor://dummy"), actualSources.FirstOrDefault()) }, - frequencyOfRunStatsChangeEvent: 10); - var manualResetEvent = new ManualResetEvent(false); + [TestMethod] + public void StartTestRunShouldCallExecutionManagerStartTestRunWithTestCase() + { + var testRunCriteria = new TestRunCriteria( + new List { new TestCase("A.C.M", new Uri("excutor://dummy"), "s.dll") }, + frequencyOfRunStatsChangeEvent: 10); + var manualResetEvent = new ManualResetEvent(true); - this.mockTestHostManager.Setup(hm => hm.GetTestSources(actualSources)).Returns(actualSources); + _mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.Tests, null, testRunCriteria.TestRunSettings, It.IsAny(), null, null)).Callback( + () => manualResetEvent.Set()); - this.mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.Tests, null, testRunCriteria.TestRunSettings, It.IsAny(), null, null)) - .Callback(() => manualResetEvent.Set()); + _inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); - this.inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); + Assert.IsTrue(manualResetEvent.WaitOne(5000), "IExecutionManager.StartTestRun should get called"); + } - Assert.IsTrue(manualResetEvent.WaitOne(5000), "IExecutionManager.StartTestRun should get called"); - this.mockExecutionManager.Verify(o => o.StartTestRun(testRunCriteria.Tests, null, testRunCriteria.TestRunSettings, It.IsAny(), null, null)); - this.mockTestHostManager.Verify(hm => hm.GetTestSources(actualSources)); - Assert.AreEqual(actualSources.FirstOrDefault(), testRunCriteria.Tests.FirstOrDefault().Source); - } + [TestMethod] + public void StartTestRunShouldUpdateTestCaseSourceIfTestCaseSourceDiffersFromTestHostManagerSource() + { + var actualSources = new List { "actualSource.dll" }; + var inputSource = new List { "inputPackage.appxrecipe" }; - [TestMethod] - public void StartTestRunShouldCatchExceptionAndCallHandleRunComplete() - { - var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); - var mockTestRunEventsHandler = new Mock(); - var manualResetEvent = new ManualResetEvent(true); + var testRunCriteria = new TestRunCriteria( + new List { new TestCase("A.C.M", new Uri("excutor://dummy"), inputSource.FirstOrDefault()) }, + frequencyOfRunStatsChangeEvent: 10); + var manualResetEvent = new ManualResetEvent(false); - this.mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.AdapterSourceMap, null, testRunCriteria.TestRunSettings, It.IsAny(), null, mockTestRunEventsHandler.Object)).Callback( - () => throw new Exception()); + _mockTestHostManager.Setup(hm => hm.GetTestSources(inputSource)).Returns(actualSources); - mockTestRunEventsHandler.Setup(o => o.HandleTestRunComplete(It.IsAny(), null, null, null)).Callback( - () => manualResetEvent.Set()); + _mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.Tests, inputSource.FirstOrDefault(), testRunCriteria.TestRunSettings, It.IsAny(), null, null)) + .Callback(() => manualResetEvent.Set()); - this.inProcessProxyExecutionManager.StartTestRun(testRunCriteria, mockTestRunEventsHandler.Object); + _inProcessProxyExecutionManager = new InProcessProxyExecutionManager(_mockTestHostManager.Object, _mockTestHostManagerFactory.Object); - Assert.IsTrue(manualResetEvent.WaitOne(5000), "ITestRunEventsHandler.HandleTestRunComplete should get called"); - } + _inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); - [TestMethod] - public void AbortShouldCallExecutionManagerAbort() - { - var manualResetEvent = new ManualResetEvent(true); + Assert.IsTrue(manualResetEvent.WaitOne(5000), "IExecutionManager.StartTestRun should get called"); + _mockExecutionManager.Verify(o => o.StartTestRun(testRunCriteria.Tests, inputSource.FirstOrDefault(), testRunCriteria.TestRunSettings, It.IsAny(), null, null)); + _mockTestHostManager.Verify(hm => hm.GetTestSources(inputSource), Times.Once); + Assert.AreEqual(actualSources.FirstOrDefault(), testRunCriteria.Tests.FirstOrDefault().Source); + } - this.mockExecutionManager.Setup(o => o.Abort(It.IsAny())).Callback( - () => manualResetEvent.Set()); + [TestMethod] + public void StartTestRunShouldNotUpdateTestCaseSourceIfTestCaseSourceDiffersFromTestHostManagerSource() + { + var actualSources = new List { "actualSource.dll" }; + var testRunCriteria = new TestRunCriteria( + new List { new TestCase("A.C.M", new Uri("excutor://dummy"), actualSources.FirstOrDefault()) }, + frequencyOfRunStatsChangeEvent: 10); + var manualResetEvent = new ManualResetEvent(false); - this.inProcessProxyExecutionManager.Abort(It.IsAny()); + _mockTestHostManager.Setup(hm => hm.GetTestSources(actualSources)).Returns(actualSources); - Assert.IsTrue(manualResetEvent.WaitOne(5000), "IExecutionManager.Abort should get called"); - } + _mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.Tests, null, testRunCriteria.TestRunSettings, It.IsAny(), null, null)) + .Callback(() => manualResetEvent.Set()); - [TestMethod] - public void CancelShouldCallExecutionManagerCancel() - { - var manualResetEvent = new ManualResetEvent(true); + _inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null); + + Assert.IsTrue(manualResetEvent.WaitOne(5000), "IExecutionManager.StartTestRun should get called"); + _mockExecutionManager.Verify(o => o.StartTestRun(testRunCriteria.Tests, null, testRunCriteria.TestRunSettings, It.IsAny(), null, null)); + _mockTestHostManager.Verify(hm => hm.GetTestSources(actualSources)); + Assert.AreEqual(actualSources.FirstOrDefault(), testRunCriteria.Tests.FirstOrDefault().Source); + } + + [TestMethod] + public void StartTestRunShouldCatchExceptionAndCallHandleRunComplete() + { + var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); + var mockTestRunEventsHandler = new Mock(); + var manualResetEvent = new ManualResetEvent(true); + + _mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.AdapterSourceMap, null, testRunCriteria.TestRunSettings, It.IsAny(), null, mockTestRunEventsHandler.Object)).Callback( + () => throw new Exception()); + + mockTestRunEventsHandler.Setup(o => o.HandleTestRunComplete(It.IsAny(), null, null, null)).Callback( + () => manualResetEvent.Set()); + + _inProcessProxyExecutionManager.StartTestRun(testRunCriteria, mockTestRunEventsHandler.Object); + + Assert.IsTrue(manualResetEvent.WaitOne(5000), "ITestRunEventsHandler.HandleTestRunComplete should get called"); + } + + [TestMethod] + public void AbortShouldCallExecutionManagerAbort() + { + var manualResetEvent = new ManualResetEvent(true); + + _mockExecutionManager.Setup(o => o.Abort(It.IsAny())).Callback( + () => manualResetEvent.Set()); + + _inProcessProxyExecutionManager.Abort(It.IsAny()); + + Assert.IsTrue(manualResetEvent.WaitOne(5000), "IExecutionManager.Abort should get called"); + } + + [TestMethod] + public void CancelShouldCallExecutionManagerCancel() + { + var manualResetEvent = new ManualResetEvent(true); - this.mockExecutionManager.Setup(o => o.Cancel(It.IsAny())).Callback( - () => manualResetEvent.Set()); + _mockExecutionManager.Setup(o => o.Cancel(It.IsAny())).Callback( + () => manualResetEvent.Set()); - this.inProcessProxyExecutionManager.Cancel(It.IsAny()); + _inProcessProxyExecutionManager.Cancel(It.IsAny()); - Assert.IsTrue(manualResetEvent.WaitOne(5000), "IExecutionManager.Abort should get called"); - } + Assert.IsTrue(manualResetEvent.WaitOne(5000), "IExecutionManager.Abort should get called"); } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelDiscoveryDataAggregatorTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelDiscoveryDataAggregatorTests.cs index c8d1e1ec8a..da4d1999f0 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelDiscoveryDataAggregatorTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelDiscoveryDataAggregatorTests.cs @@ -1,228 +1,237 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Client.Parallel -{ - using System; - using System.Collections.Generic; +namespace TestPlatform.CrossPlatEngine.UnitTests.Client.Parallel; + +using System; +using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; +using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestClass] - public class ParallelDiscoveryDataAggregatorTests +[TestClass] +public class ParallelDiscoveryDataAggregatorTests +{ + [TestMethod] + public void AggregateShouldAggregateAbortedCorrectly() { - [TestMethod] - public void AggregateShouldAggregateAbortedCorrectly() - { - var aggregator = new ParallelDiscoveryDataAggregator(); + var aggregator = new ParallelDiscoveryDataAggregator(); - aggregator.Aggregate(totalTests: 5, isAborted: false); - Assert.IsFalse(aggregator.IsAborted, "Aborted must be false"); + aggregator.Aggregate(totalTests: 5, isAborted: false); + Assert.IsFalse(aggregator.IsAborted, "Aborted must be false"); - aggregator.Aggregate(totalTests: 5, isAborted: true); - Assert.IsTrue(aggregator.IsAborted, "Aborted must be true"); + aggregator.Aggregate(totalTests: 5, isAborted: true); + Assert.IsTrue(aggregator.IsAborted, "Aborted must be true"); - aggregator.Aggregate(totalTests: 5, isAborted: false); - Assert.IsTrue(aggregator.IsAborted, "Aborted must be true"); + aggregator.Aggregate(totalTests: 5, isAborted: false); + Assert.IsTrue(aggregator.IsAborted, "Aborted must be true"); - Assert.AreEqual(-1, aggregator.TotalTests, "Aggregator shouldn't count tests if one host aborts"); - } + Assert.AreEqual(-1, aggregator.TotalTests, "Aggregator shouldn't count tests if one host aborts"); + } - [TestMethod] - public void AggregateShouldAggregateTotalTestsCorrectly() - { - var aggregator = new ParallelDiscoveryDataAggregator(); - aggregator.Aggregate(totalTests: 2, isAborted: false); - Assert.AreEqual(2, aggregator.TotalTests, "Aggregated totalTests count does not match"); + [TestMethod] + public void AggregateShouldAggregateTotalTestsCorrectly() + { + var aggregator = new ParallelDiscoveryDataAggregator(); + aggregator.Aggregate(totalTests: 2, isAborted: false); + Assert.AreEqual(2, aggregator.TotalTests, "Aggregated totalTests count does not match"); - aggregator.Aggregate(totalTests: 5, isAborted: false); - Assert.AreEqual(7, aggregator.TotalTests, "Aggregated totalTests count does not match"); + aggregator.Aggregate(totalTests: 5, isAborted: false); + Assert.AreEqual(7, aggregator.TotalTests, "Aggregated totalTests count does not match"); - aggregator.Aggregate(totalTests: 3, isAborted: false); - Assert.AreEqual(10, aggregator.TotalTests, "Aggregated totalTests count does not match"); - } + aggregator.Aggregate(totalTests: 3, isAborted: false); + Assert.AreEqual(10, aggregator.TotalTests, "Aggregated totalTests count does not match"); + } - [TestMethod] - public void AggregateDiscoveryDataMetricsShouldAggregateMetricsCorrectly() - { - var aggregator = new ParallelDiscoveryDataAggregator(); + [TestMethod] + public void AggregateDiscoveryDataMetricsShouldAggregateMetricsCorrectly() + { + var aggregator = new ParallelDiscoveryDataAggregator(); - aggregator.AggregateDiscoveryDataMetrics(null); + aggregator.AggregateDiscoveryDataMetrics(null); - var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); - Assert.AreEqual(0, runMetrics.Count); - } + var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); + Assert.AreEqual(0, runMetrics.Count); + } - [TestMethod] - public void AggregateDiscoveryDataMetricsShouldAddTotalTestsDiscovered() + [TestMethod] + public void AggregateDiscoveryDataMetricsShouldAddTotalTestsDiscovered() + { + var aggregator = new ParallelDiscoveryDataAggregator(); + + var dict = new Dictionary { - var aggregator = new ParallelDiscoveryDataAggregator(); + { TelemetryDataConstants.TotalTestsDiscovered, 2 } + }; - var dict = new Dictionary(); - dict.Add(TelemetryDataConstants.TotalTestsDiscovered, 2); + aggregator.AggregateDiscoveryDataMetrics(dict); + aggregator.AggregateDiscoveryDataMetrics(dict); - aggregator.AggregateDiscoveryDataMetrics(dict); - aggregator.AggregateDiscoveryDataMetrics(dict); + var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); - var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); + Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.TotalTestsDiscovered, out var value)); + Assert.AreEqual(4, Convert.ToInt32(value)); + } - Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.TotalTestsDiscovered, out var value)); - Assert.AreEqual(4, Convert.ToInt32(value)); - } + [TestMethod] + public void AggregateDiscoveryDataMetricsShouldAddTimeTakenToDiscoverTests() + { + var aggregator = new ParallelDiscoveryDataAggregator(); - [TestMethod] - public void AggregateDiscoveryDataMetricsShouldAddTimeTakenToDiscoverTests() + var dict = new Dictionary { - var aggregator = new ParallelDiscoveryDataAggregator(); + { TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter, .02091 } + }; - var dict = new Dictionary(); - dict.Add(TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter, .02091); + aggregator.AggregateDiscoveryDataMetrics(dict); + aggregator.AggregateDiscoveryDataMetrics(dict); - aggregator.AggregateDiscoveryDataMetrics(dict); - aggregator.AggregateDiscoveryDataMetrics(dict); + var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); - var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); + Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter, out var value)); + Assert.AreEqual(.04182, value); + } - Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter, out var value)); - Assert.AreEqual(.04182, value); - } + [TestMethod] + public void AggregateDiscoveryDataMetricsShouldAddTimeTakenByAllAdapters() + { + var aggregator = new ParallelDiscoveryDataAggregator(); - [TestMethod] - public void AggregateDiscoveryDataMetricsShouldAddTimeTakenByAllAdapters() + var dict = new Dictionary { - var aggregator = new ParallelDiscoveryDataAggregator(); + { TelemetryDataConstants.TimeTakenInSecByAllAdapters, .02091 } + }; - var dict = new Dictionary(); - dict.Add(TelemetryDataConstants.TimeTakenInSecByAllAdapters, .02091); + aggregator.AggregateDiscoveryDataMetrics(dict); + aggregator.AggregateDiscoveryDataMetrics(dict); - aggregator.AggregateDiscoveryDataMetrics(dict); - aggregator.AggregateDiscoveryDataMetrics(dict); + var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); - var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); + Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.TimeTakenInSecByAllAdapters, out var value)); + Assert.AreEqual(.04182, value); + } - Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.TimeTakenInSecByAllAdapters, out var value)); - Assert.AreEqual(.04182, value); - } + [TestMethod] + public void AggregateDiscoveryDataMetricsShouldAddTimeTakenToLoadAdapters() + { + var aggregator = new ParallelDiscoveryDataAggregator(); - [TestMethod] - public void AggregateDiscoveryDataMetricsShouldAddTimeTakenToLoadAdapters() + var dict = new Dictionary { - var aggregator = new ParallelDiscoveryDataAggregator(); + { TelemetryDataConstants.TimeTakenToLoadAdaptersInSec, .02091 } + }; - var dict = new Dictionary(); - dict.Add(TelemetryDataConstants.TimeTakenToLoadAdaptersInSec, .02091); + aggregator.AggregateDiscoveryDataMetrics(dict); + aggregator.AggregateDiscoveryDataMetrics(dict); - aggregator.AggregateDiscoveryDataMetrics(dict); - aggregator.AggregateDiscoveryDataMetrics(dict); + var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); - var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); + Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.TimeTakenToLoadAdaptersInSec, out var value)); + Assert.AreEqual(.04182, value); + } - Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.TimeTakenToLoadAdaptersInSec, out var value)); - Assert.AreEqual(.04182, value); - } + [TestMethod] + public void AggregateDiscoveryDataMetricsShouldNotAggregateDiscoveryState() + { + var aggregator = new ParallelDiscoveryDataAggregator(); - [TestMethod] - public void AggregateDiscoveryDataMetricsShouldNotAggregateDiscoveryState() + var dict = new Dictionary { - var aggregator = new ParallelDiscoveryDataAggregator(); + { TelemetryDataConstants.DiscoveryState, "Completed" } + }; - var dict = new Dictionary(); - dict.Add(TelemetryDataConstants.DiscoveryState, "Completed"); + aggregator.AggregateDiscoveryDataMetrics(dict); + aggregator.AggregateDiscoveryDataMetrics(dict); - aggregator.AggregateDiscoveryDataMetrics(dict); - aggregator.AggregateDiscoveryDataMetrics(dict); - - var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); - - Assert.IsFalse(runMetrics.TryGetValue(TelemetryDataConstants.DiscoveryState, out var value)); - } + var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); + Assert.IsFalse(runMetrics.TryGetValue(TelemetryDataConstants.DiscoveryState, out _)); + } - [TestMethod] - public void GetAggregatedDiscoveryDataMetricsShouldReturnEmptyIfMetricAggregatorIsEmpty() - { - var aggregator = new ParallelDiscoveryDataAggregator(); + [TestMethod] + public void GetAggregatedDiscoveryDataMetricsShouldReturnEmptyIfMetricAggregatorIsEmpty() + { + var aggregator = new ParallelDiscoveryDataAggregator(); - var dict = new Dictionary(); + var dict = new Dictionary(); - aggregator.AggregateDiscoveryDataMetrics(dict); - var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); + aggregator.AggregateDiscoveryDataMetrics(dict); + var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); - Assert.AreEqual(0, runMetrics.Count); - } + Assert.AreEqual(0, runMetrics.Count); + } - [TestMethod] - public void GetAggregatedDiscoveryDataMetricsShouldReturnEmptyIfMetricsIsNull() - { - var aggregator = new ParallelDiscoveryDataAggregator(); + [TestMethod] + public void GetAggregatedDiscoveryDataMetricsShouldReturnEmptyIfMetricsIsNull() + { + var aggregator = new ParallelDiscoveryDataAggregator(); + _ = new Dictionary(); - var dict = new Dictionary(); + aggregator.AggregateDiscoveryDataMetrics(null); + var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); - aggregator.AggregateDiscoveryDataMetrics(null); - var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); + Assert.AreEqual(0, runMetrics.Count); + } - Assert.AreEqual(0, runMetrics.Count); - } + [TestMethod] + public void GetDiscoveryDataMetricsShouldAddTotalAdaptersUsedIfMetricsIsNotEmpty() + { + var aggregator = new ParallelDiscoveryDataAggregator(); - [TestMethod] - public void GetDiscoveryDataMetricsShouldAddTotalAdaptersUsedIfMetricsIsNotEmpty() + var dict = new Dictionary { - var aggregator = new ParallelDiscoveryDataAggregator(); + { TelemetryDataConstants.TotalTestsByAdapter, 2 } + }; - var dict = new Dictionary(); - dict.Add(TelemetryDataConstants.TotalTestsByAdapter, 2); + aggregator.AggregateDiscoveryDataMetrics(dict); + aggregator.AggregateDiscoveryDataMetrics(dict); - aggregator.AggregateDiscoveryDataMetrics(dict); - aggregator.AggregateDiscoveryDataMetrics(dict); + var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); - var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); + Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.NumberOfAdapterUsedToDiscoverTests, out var value)); + Assert.AreEqual(1, value); + } - Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.NumberOfAdapterUsedToDiscoverTests, out var value)); - Assert.AreEqual(1, value); - } + [TestMethod] + public void GetDiscoveryDataMetricsShouldAddNumberOfAdapterDiscoveredIfMetricsIsEmpty() + { + var aggregator = new ParallelDiscoveryDataAggregator(); - [TestMethod] - public void GetDiscoveryDataMetricsShouldAddNumberOfAdapterDiscoveredIfMetricsIsEmpty() + var dict = new Dictionary { - var aggregator = new ParallelDiscoveryDataAggregator(); - - var dict = new Dictionary(); - dict.Add(TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter + "executor:MSTestV1", .02091); - dict.Add(TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter + "executor:MSTestV2", .02091); - - aggregator.AggregateDiscoveryDataMetrics(dict); + { TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter + "executor:MSTestV1", .02091 }, + { TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter + "executor:MSTestV2", .02091 } + }; - var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); + aggregator.AggregateDiscoveryDataMetrics(dict); - Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringDiscovery, out var value)); - Assert.AreEqual(2, value); - } - - [TestMethod] - public void GetDiscoveryDataMetricsShouldNotAddTotalAdaptersUsedIfMetricsIsEmpty() - { - var aggregator = new ParallelDiscoveryDataAggregator(); - var dict = new Dictionary(); + var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); - aggregator.AggregateDiscoveryDataMetrics(dict); + Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringDiscovery, out var value)); + Assert.AreEqual(2, value); + } - var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); + [TestMethod] + public void GetDiscoveryDataMetricsShouldNotAddTotalAdaptersUsedIfMetricsIsEmpty() + { + var aggregator = new ParallelDiscoveryDataAggregator(); + var dict = new Dictionary(); - Assert.IsFalse(runMetrics.TryGetValue(TelemetryDataConstants.NumberOfAdapterUsedToDiscoverTests, out var value)); - } + aggregator.AggregateDiscoveryDataMetrics(dict); - [TestMethod] - public void GetDiscoveryDataMetricsShouldNotAddNumberOfAdapterDiscoveredIfMetricsIsEmpty() - { - var aggregator = new ParallelDiscoveryDataAggregator(); - var dict = new Dictionary(); + var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); + Assert.IsFalse(runMetrics.TryGetValue(TelemetryDataConstants.NumberOfAdapterUsedToDiscoverTests, out _)); + } - aggregator.AggregateDiscoveryDataMetrics(dict); + [TestMethod] + public void GetDiscoveryDataMetricsShouldNotAddNumberOfAdapterDiscoveredIfMetricsIsEmpty() + { + var aggregator = new ParallelDiscoveryDataAggregator(); + var dict = new Dictionary(); - var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); + aggregator.AggregateDiscoveryDataMetrics(dict); - Assert.IsFalse(runMetrics.TryGetValue(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringDiscovery, out var value)); - } + var runMetrics = aggregator.GetAggregatedDiscoveryDataMetrics(); + Assert.IsFalse(runMetrics.TryGetValue(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringDiscovery, out _)); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelDiscoveryEventsHandlerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelDiscoveryEventsHandlerTests.cs index 4ba1536d27..d674d30d63 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelDiscoveryEventsHandlerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelDiscoveryEventsHandlerTests.cs @@ -1,206 +1,205 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Client -{ - using System.Collections.Generic; - - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - [TestClass] - public class ParallelDiscoveryEventsHandlerTests - { - private ParallelDiscoveryEventsHandler parallelDiscoveryEventsHandler; +namespace TestPlatform.CrossPlatEngine.UnitTests.Client; - private Mock mockProxyDiscoveryManager; +using System.Collections.Generic; - private Mock mockTestDiscoveryEventsHandler; +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; - private Mock mockParallelProxyDiscoveryManager; +using Moq; - private Mock mockDataSerializer; +[TestClass] +public class ParallelDiscoveryEventsHandlerTests +{ + private ParallelDiscoveryEventsHandler _parallelDiscoveryEventsHandler; - private Mock mockRequestData; + private Mock _mockProxyDiscoveryManager; - [TestInitialize] - public void TestInit() - { - this.mockProxyDiscoveryManager = new Mock(); - this.mockTestDiscoveryEventsHandler = new Mock(); - this.mockParallelProxyDiscoveryManager = new Mock(); - this.mockDataSerializer = new Mock(); - this.mockRequestData = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new NoOpMetricsCollection()); + private Mock _mockTestDiscoveryEventsHandler; - this.parallelDiscoveryEventsHandler = new ParallelDiscoveryEventsHandler(this.mockRequestData.Object, mockProxyDiscoveryManager.Object, - this.mockTestDiscoveryEventsHandler.Object, this.mockParallelProxyDiscoveryManager.Object, - new ParallelDiscoveryDataAggregator(), this.mockDataSerializer.Object); - } + private Mock _mockParallelProxyDiscoveryManager; - [TestMethod] - public void HandleDiscoveryCompleteShouldNotCallLastChunkResultsIfNotPresent() - { - int totalTests = 10; - bool aborted = false; - this.mockParallelProxyDiscoveryManager.Setup(mp => mp.HandlePartialDiscoveryComplete( - this.mockProxyDiscoveryManager.Object, totalTests, null, aborted)).Returns(false); + private Mock _mockDataSerializer; - var discoveryCompleteEventsArgs = new DiscoveryCompleteEventArgs(totalTests, aborted); + private Mock _mockRequestData; - this.parallelDiscoveryEventsHandler.HandleDiscoveryComplete(discoveryCompleteEventsArgs, null); + [TestInitialize] + public void TestInit() + { + _mockProxyDiscoveryManager = new Mock(); + _mockTestDiscoveryEventsHandler = new Mock(); + _mockParallelProxyDiscoveryManager = new Mock(); + _mockDataSerializer = new Mock(); + _mockRequestData = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new NoOpMetricsCollection()); + + _parallelDiscoveryEventsHandler = new ParallelDiscoveryEventsHandler(_mockRequestData.Object, _mockProxyDiscoveryManager.Object, + _mockTestDiscoveryEventsHandler.Object, _mockParallelProxyDiscoveryManager.Object, + new ParallelDiscoveryDataAggregator(), _mockDataSerializer.Object); + } - // Raw message must be sent - this.mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleRawMessage(It.IsAny()), Times.Never); + [TestMethod] + public void HandleDiscoveryCompleteShouldNotCallLastChunkResultsIfNotPresent() + { + int totalTests = 10; + bool aborted = false; + _mockParallelProxyDiscoveryManager.Setup(mp => mp.HandlePartialDiscoveryComplete( + _mockProxyDiscoveryManager.Object, totalTests, null, aborted)).Returns(false); - this.mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleDiscoveredTests(null), Times.Never); + var discoveryCompleteEventsArgs = new DiscoveryCompleteEventArgs(totalTests, aborted); - this.mockParallelProxyDiscoveryManager.Verify(mp => mp.HandlePartialDiscoveryComplete( - this.mockProxyDiscoveryManager.Object, totalTests, null, aborted), Times.Once); - } + _parallelDiscoveryEventsHandler.HandleDiscoveryComplete(discoveryCompleteEventsArgs, null); - [TestMethod] - public void HandleDiscoveryCompleteShouldCallLastChunkResultsIfPresent() - { - string payload = "Tests"; - int totalTests = 10; - bool aborted = false; - var lastChunk = new List(); + // Raw message must be sent + _mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleRawMessage(It.IsAny()), Times.Never); - this.mockDataSerializer.Setup(mds => mds.SerializePayload(MessageType.TestCasesFound, lastChunk)) - .Returns(payload); + _mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleDiscoveredTests(null), Times.Never); - this.mockParallelProxyDiscoveryManager.Setup(mp => mp.HandlePartialDiscoveryComplete( - this.mockProxyDiscoveryManager.Object, totalTests, lastChunk, aborted)).Returns(false); + _mockParallelProxyDiscoveryManager.Verify(mp => mp.HandlePartialDiscoveryComplete( + _mockProxyDiscoveryManager.Object, totalTests, null, aborted), Times.Once); + } - var discoveryCompleteEventsArgs = new DiscoveryCompleteEventArgs(totalTests, aborted); + [TestMethod] + public void HandleDiscoveryCompleteShouldCallLastChunkResultsIfPresent() + { + string payload = "Tests"; + int totalTests = 10; + bool aborted = false; + var lastChunk = new List(); - this.parallelDiscoveryEventsHandler.HandleDiscoveryComplete(discoveryCompleteEventsArgs, lastChunk); + _mockDataSerializer.Setup(mds => mds.SerializePayload(MessageType.TestCasesFound, lastChunk)) + .Returns(payload); - // Raw message must be sent - this.mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleRawMessage(payload), Times.Once); + _mockParallelProxyDiscoveryManager.Setup(mp => mp.HandlePartialDiscoveryComplete( + _mockProxyDiscoveryManager.Object, totalTests, lastChunk, aborted)).Returns(false); - this.mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleDiscoveredTests(lastChunk), Times.Once); + var discoveryCompleteEventsArgs = new DiscoveryCompleteEventArgs(totalTests, aborted); - this.mockParallelProxyDiscoveryManager.Verify(mp => mp.HandlePartialDiscoveryComplete( - this.mockProxyDiscoveryManager.Object, totalTests, null, aborted), Times.Once); - } + _parallelDiscoveryEventsHandler.HandleDiscoveryComplete(discoveryCompleteEventsArgs, lastChunk); - [TestMethod] - public void HandleDiscoveryCompleteShouldCollectMetrics() - { - string payload = "DiscoveryComplete"; - int totalTests = 10; - bool aborted = false; + // Raw message must be sent + _mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleRawMessage(payload), Times.Once); - this.mockParallelProxyDiscoveryManager.Setup(mp => mp.HandlePartialDiscoveryComplete( - this.mockProxyDiscoveryManager.Object, totalTests, null, aborted)).Returns(true); + _mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleDiscoveredTests(lastChunk), Times.Once); - this.mockDataSerializer.Setup(mds => mds.SerializeMessage(MessageType.DiscoveryComplete)).Returns(payload); + _mockParallelProxyDiscoveryManager.Verify(mp => mp.HandlePartialDiscoveryComplete( + _mockProxyDiscoveryManager.Object, totalTests, null, aborted), Times.Once); + } - var mockMetricsCollector = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollector.Object); + [TestMethod] + public void HandleDiscoveryCompleteShouldCollectMetrics() + { + string payload = "DiscoveryComplete"; + int totalTests = 10; + bool aborted = false; - var discoveryCompleteEventsArgs = new DiscoveryCompleteEventArgs(totalTests, aborted); + _mockParallelProxyDiscoveryManager.Setup(mp => mp.HandlePartialDiscoveryComplete( + _mockProxyDiscoveryManager.Object, totalTests, null, aborted)).Returns(true); - // Act. - this.parallelDiscoveryEventsHandler.HandleDiscoveryComplete(discoveryCompleteEventsArgs, null); + _mockDataSerializer.Setup(mds => mds.SerializeMessage(MessageType.DiscoveryComplete)).Returns(payload); - // Verify. - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.DiscoveryState, It.IsAny()), Times.Once); - } + var mockMetricsCollector = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollector.Object); - [TestMethod] - public void HandleDiscoveryCompleteShouldCallTestDiscoveryCompleteOnActualHandlerIfParallelManagerReturnsCompleteAsTrue() - { - string payload = "DiscoveryComplete"; - int totalTests = 10; - bool aborted = false; + var discoveryCompleteEventsArgs = new DiscoveryCompleteEventArgs(totalTests, aborted); - this.mockParallelProxyDiscoveryManager.Setup(mp => mp.HandlePartialDiscoveryComplete( - this.mockProxyDiscoveryManager.Object, totalTests, null, aborted)).Returns(true); + // Act. + _parallelDiscoveryEventsHandler.HandleDiscoveryComplete(discoveryCompleteEventsArgs, null); - this.mockDataSerializer.Setup(mds => mds.SerializeMessage(MessageType.DiscoveryComplete)).Returns(payload); + // Verify. + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.DiscoveryState, It.IsAny()), Times.Once); + } - // Act - var discoveryCompleteEventsArgs = new DiscoveryCompleteEventArgs(totalTests, aborted); + [TestMethod] + public void HandleDiscoveryCompleteShouldCallTestDiscoveryCompleteOnActualHandlerIfParallelManagerReturnsCompleteAsTrue() + { + string payload = "DiscoveryComplete"; + int totalTests = 10; + bool aborted = false; - this.parallelDiscoveryEventsHandler.HandleDiscoveryComplete(discoveryCompleteEventsArgs, null); + _mockParallelProxyDiscoveryManager.Setup(mp => mp.HandlePartialDiscoveryComplete( + _mockProxyDiscoveryManager.Object, totalTests, null, aborted)).Returns(true); - // Verify - this.mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleDiscoveredTests(null), Times.Never); + _mockDataSerializer.Setup(mds => mds.SerializeMessage(MessageType.DiscoveryComplete)).Returns(payload); - this.mockParallelProxyDiscoveryManager.Verify(mp => mp.HandlePartialDiscoveryComplete( - this.mockProxyDiscoveryManager.Object, totalTests, null, aborted), Times.Once); + // Act + var discoveryCompleteEventsArgs = new DiscoveryCompleteEventArgs(totalTests, aborted); - this.mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleRawMessage(It.IsAny()), Times.Once); + _parallelDiscoveryEventsHandler.HandleDiscoveryComplete(discoveryCompleteEventsArgs, null); - this.mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleDiscoveryComplete(It.IsAny(), null), Times.Once); - } + // Verify + _mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleDiscoveredTests(null), Times.Never); - [TestMethod] - public void HandleDiscoveryTestsShouldJustPassOnTheEventToDiscoveryEventsHandler() - { - var tests = new List(); - this.parallelDiscoveryEventsHandler.HandleDiscoveredTests(tests); + _mockParallelProxyDiscoveryManager.Verify(mp => mp.HandlePartialDiscoveryComplete( + _mockProxyDiscoveryManager.Object, totalTests, null, aborted), Times.Once); - this.mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleDiscoveredTests(tests), Times.Once); - } + _mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleRawMessage(It.IsAny()), Times.Once); - [TestMethod] - public void HandleRawMessageShouldSendTestCasesFoundRawMessageToDiscoveryEventsHandler() - { - string payload = "Tests"; - this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())) - .Returns(new Message() { MessageType = MessageType.TestCasesFound, Payload = payload }); + _mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleDiscoveryComplete(It.IsAny(), null), Times.Once); + } - this.parallelDiscoveryEventsHandler.HandleRawMessage(payload); + [TestMethod] + public void HandleDiscoveryTestsShouldJustPassOnTheEventToDiscoveryEventsHandler() + { + var tests = new List(); + _parallelDiscoveryEventsHandler.HandleDiscoveredTests(tests); + + _mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleDiscoveredTests(tests), Times.Once); + } + + [TestMethod] + public void HandleRawMessageShouldSendTestCasesFoundRawMessageToDiscoveryEventsHandler() + { + string payload = "Tests"; + _mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())) + .Returns(new Message() { MessageType = MessageType.TestCasesFound, Payload = payload }); + + _parallelDiscoveryEventsHandler.HandleRawMessage(payload); - this.mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleRawMessage(payload), Times.Once); - } + _mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleRawMessage(payload), Times.Once); + } - [TestMethod] - public void HandleRawMessageShouldNotSendDiscoveryCompleteEventRawMessageToDiscoveryEventsHandler() - { - string payload = "DiscoveryComplete"; - this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())) - .Returns(new Message() { MessageType = MessageType.DiscoveryComplete, Payload = payload }); + [TestMethod] + public void HandleRawMessageShouldNotSendDiscoveryCompleteEventRawMessageToDiscoveryEventsHandler() + { + string payload = "DiscoveryComplete"; + _mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())) + .Returns(new Message() { MessageType = MessageType.DiscoveryComplete, Payload = payload }); - this.parallelDiscoveryEventsHandler.HandleRawMessage(payload); + _parallelDiscoveryEventsHandler.HandleRawMessage(payload); - this.mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleRawMessage(It.IsAny()), Times.Never); - } + _mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleRawMessage(It.IsAny()), Times.Never); + } - [TestMethod] - public void HandleRawMessageShouldSendLoggerRawMessageToDiscoveryEventsHandler() - { - string payload = "LogMessage"; - this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())) - .Returns(new Message() { MessageType = MessageType.TestMessage, Payload = payload }); + [TestMethod] + public void HandleRawMessageShouldSendLoggerRawMessageToDiscoveryEventsHandler() + { + string payload = "LogMessage"; + _mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())) + .Returns(new Message() { MessageType = MessageType.TestMessage, Payload = payload }); - this.parallelDiscoveryEventsHandler.HandleRawMessage(payload); + _parallelDiscoveryEventsHandler.HandleRawMessage(payload); - this.mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleRawMessage(payload), Times.Once); - } + _mockTestDiscoveryEventsHandler.Verify(mt => mt.HandleRawMessage(payload), Times.Once); + } - [TestMethod] - public void HandleLogMessageShouldJustPassOnTheEventToDiscoveryEventsHandler() - { - string log = "Hello"; - this.parallelDiscoveryEventsHandler.HandleLogMessage(TestMessageLevel.Error, log); + [TestMethod] + public void HandleLogMessageShouldJustPassOnTheEventToDiscoveryEventsHandler() + { + string log = "Hello"; + _parallelDiscoveryEventsHandler.HandleLogMessage(TestMessageLevel.Error, log); - this.mockTestDiscoveryEventsHandler.Verify(mt => - mt.HandleLogMessage(TestMessageLevel.Error, log), Times.Once); - } + _mockTestDiscoveryEventsHandler.Verify(mt => + mt.HandleLogMessage(TestMessageLevel.Error, log), Times.Once); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelOperationManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelOperationManagerTests.cs index 2f0ce2fc4e..dc15be323a 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelOperationManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelOperationManagerTests.cs @@ -1,188 +1,182 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Client +namespace TestPlatform.CrossPlatEngine.UnitTests.Client; + +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using System; +using System.Collections.Generic; +using System.Linq; + +[TestClass] +public class ParallelOperationManagerTests { - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; - - [TestClass] - public class ParallelOperationManagerTests + private MockParallelOperationManager _proxyParallelManager; + + [TestInitialize] + public void InitializeTests() { - private MockParallelOperationManager proxyParallelManager; + Func sampleCreator = + () => new SampleConcurrentClass(); - [TestInitialize] - public void InitializeTests() - { - Func sampleCreator = - () => - { - return new SampleConcurrentClass(); - }; + _proxyParallelManager = new MockParallelOperationManager(sampleCreator, 2, true); + } - this.proxyParallelManager = new MockParallelOperationManager(sampleCreator, 2, true); - } + [TestMethod] + public void AbstractProxyParallelManagerShouldCreateCorrectNumberOfConcurrentObjects() + { + var createdSampleClasses = new List(); + Func sampleCreator = + () => + { + var sample = new SampleConcurrentClass(); + createdSampleClasses.Add(sample); + return sample; + }; - [TestMethod] - public void AbstractProxyParallelManagerShouldCreateCorrectNumberOfConcurrentObjects() - { - var createdSampleClasses = new List(); - Func sampleCreator = - () => - { - var sample = new SampleConcurrentClass(); - createdSampleClasses.Add(sample); - return sample; - }; - - this.proxyParallelManager = new MockParallelOperationManager(sampleCreator, 3, true); - - Assert.AreEqual(3, createdSampleClasses.Count, "Number of Concurrent Objects created should be 3"); - } + _proxyParallelManager = new MockParallelOperationManager(sampleCreator, 3, true); - [TestMethod] - public void AbstractProxyParallelManagerShouldUpdateToCorrectNumberOfConcurrentObjects() - { - var createdSampleClasses = new List(); - Func sampleCreator = - () => - { - var sample = new SampleConcurrentClass(); - createdSampleClasses.Add(sample); - return sample; - }; + Assert.AreEqual(3, createdSampleClasses.Count, "Number of Concurrent Objects created should be 3"); + } - this.proxyParallelManager = new MockParallelOperationManager(sampleCreator, 1, true); + [TestMethod] + public void AbstractProxyParallelManagerShouldUpdateToCorrectNumberOfConcurrentObjects() + { + var createdSampleClasses = new List(); + Func sampleCreator = + () => + { + var sample = new SampleConcurrentClass(); + createdSampleClasses.Add(sample); + return sample; + }; - Assert.AreEqual(1, createdSampleClasses.Count, "Number of Concurrent Objects created should be 1"); + _proxyParallelManager = new MockParallelOperationManager(sampleCreator, 1, true); - this.proxyParallelManager.UpdateParallelLevel(4); + Assert.AreEqual(1, createdSampleClasses.Count, "Number of Concurrent Objects created should be 1"); - Assert.AreEqual(4, createdSampleClasses.Count, "Number of Concurrent Objects created should be 4"); - } + _proxyParallelManager.UpdateParallelLevel(4); - [TestMethod] - public void DoActionOnConcurrentObjectsShouldCallAllObjects() - { - var createdSampleClasses = new List(); - Func sampleCreator = - () => - { - var sample = new SampleConcurrentClass(); - createdSampleClasses.Add(sample); - return sample; - }; - - this.proxyParallelManager = new MockParallelOperationManager(sampleCreator, 4, true); - - Assert.AreEqual(4, createdSampleClasses.Count, "Number of Concurrent Objects created should be 4"); - - int count = 0; - this.proxyParallelManager.DoActionOnAllConcurrentObjects( - (sample) => - { - count++; - Assert.IsTrue(createdSampleClasses.Contains(sample), "Called object must be in the created list."); - // Make sure action is not called on same object multiple times - createdSampleClasses.Remove(sample); - }); - - Assert.AreEqual(4, count, "Number of Concurrent Objects called should be 4"); - - Assert.AreEqual(0, createdSampleClasses.Count, "All concurrent objects must be called."); - } + Assert.AreEqual(4, createdSampleClasses.Count, "Number of Concurrent Objects created should be 4"); + } - [TestMethod] - public void AddManagerShouldAddAManagerWithHandlerInConcurrentManagerList() - { - // At the beginning it should be equal to parallel level - Assert.AreEqual(2, this.proxyParallelManager.GetConcurrentManagersCount()); + [TestMethod] + public void DoActionOnConcurrentObjectsShouldCallAllObjects() + { + var createdSampleClasses = new List(); + Func sampleCreator = + () => + { + var sample = new SampleConcurrentClass(); + createdSampleClasses.Add(sample); + return sample; + }; - this.proxyParallelManager.AddManager(new SampleConcurrentClass(true), new SampleHandlerClass()); + _proxyParallelManager = new MockParallelOperationManager(sampleCreator, 4, true); - Assert.AreEqual(3, this.proxyParallelManager.GetConcurrentManagersCount()); - Assert.AreEqual(1, this.proxyParallelManager.GetConcurrentManagerInstances().Count(m => m.CheckValue)); - } + Assert.AreEqual(4, createdSampleClasses.Count, "Number of Concurrent Objects created should be 4"); - [TestMethod] - public void RemoveManagerShouldRemoveAManagerFromConcurrentManagerList() - { - var manager = new SampleConcurrentClass(true); - this.proxyParallelManager.AddManager(manager, new SampleHandlerClass()); + int count = 0; + _proxyParallelManager.DoActionOnAllConcurrentObjects( + (sample) => + { + count++; + Assert.IsTrue(createdSampleClasses.Contains(sample), "Called object must be in the created list."); + // Make sure action is not called on same object multiple times + createdSampleClasses.Remove(sample); + }); - Assert.AreEqual(3, this.proxyParallelManager.GetConcurrentManagersCount()); + Assert.AreEqual(4, count, "Number of Concurrent Objects called should be 4"); - this.proxyParallelManager.RemoveManager(manager); + Assert.AreEqual(0, createdSampleClasses.Count, "All concurrent objects must be called."); + } - Assert.AreEqual(2, this.proxyParallelManager.GetConcurrentManagersCount()); - Assert.AreEqual(0, this.proxyParallelManager.GetConcurrentManagerInstances().Count(m => m.CheckValue)); - } + [TestMethod] + public void AddManagerShouldAddAManagerWithHandlerInConcurrentManagerList() + { + // At the beginning it should be equal to parallel level + Assert.AreEqual(2, _proxyParallelManager.GetConcurrentManagersCount()); - [TestMethod] - public void UpdateHandlerForManagerShouldAddNewHandlerIfNotexist() - { - var manager = new SampleConcurrentClass(true); - this.proxyParallelManager.UpdateHandlerForManager(manager, new SampleHandlerClass()); + _proxyParallelManager.AddManager(new SampleConcurrentClass(true), new SampleHandlerClass()); - Assert.AreEqual(3, this.proxyParallelManager.GetConcurrentManagersCount()); - Assert.AreEqual(1, this.proxyParallelManager.GetConcurrentManagerInstances().Count(m => m.CheckValue)); - } + Assert.AreEqual(3, _proxyParallelManager.GetConcurrentManagersCount()); + Assert.AreEqual(1, _proxyParallelManager.GetConcurrentManagerInstances().Count(m => m.CheckValue)); + } - [TestMethod] - public void UpdateHandlerForManagerShouldUpdateHandlerForGivenManager() - { - var manager = new SampleConcurrentClass(true); - this.proxyParallelManager.AddManager(manager, new SampleHandlerClass()); + [TestMethod] + public void RemoveManagerShouldRemoveAManagerFromConcurrentManagerList() + { + var manager = new SampleConcurrentClass(true); + _proxyParallelManager.AddManager(manager, new SampleHandlerClass()); - // For current handler the value of variable CheckValue should be false; - Assert.IsFalse(this.proxyParallelManager.GetHandlerForGivenManager(manager).CheckValue); + Assert.AreEqual(3, _proxyParallelManager.GetConcurrentManagersCount()); - var newHandler = new SampleHandlerClass(true); + _proxyParallelManager.RemoveManager(manager); - // Update manager with new handler - this.proxyParallelManager.UpdateHandlerForManager(manager, newHandler); + Assert.AreEqual(2, _proxyParallelManager.GetConcurrentManagersCount()); + Assert.AreEqual(0, _proxyParallelManager.GetConcurrentManagerInstances().Count(m => m.CheckValue)); + } - // It should not add new manager but update the current one - Assert.AreEqual(3, this.proxyParallelManager.GetConcurrentManagersCount()); - Assert.IsTrue(this.proxyParallelManager.GetHandlerForGivenManager(manager).CheckValue); - } + [TestMethod] + public void UpdateHandlerForManagerShouldAddNewHandlerIfNotexist() + { + var manager = new SampleConcurrentClass(true); + _proxyParallelManager.UpdateHandlerForManager(manager, new SampleHandlerClass()); - private class MockParallelOperationManager : ParallelOperationManager - { - public MockParallelOperationManager(Func createNewClient, int parallelLevel, bool sharedHosts) : - base(createNewClient, parallelLevel, sharedHosts) - { - } + Assert.AreEqual(3, _proxyParallelManager.GetConcurrentManagersCount()); + Assert.AreEqual(1, _proxyParallelManager.GetConcurrentManagerInstances().Count(m => m.CheckValue)); + } - public void DoActionOnAllConcurrentObjects(Action action) - { - this.DoActionOnAllManagers(action, false); - } + [TestMethod] + public void UpdateHandlerForManagerShouldUpdateHandlerForGivenManager() + { + var manager = new SampleConcurrentClass(true); + _proxyParallelManager.AddManager(manager, new SampleHandlerClass()); + + // For current handler the value of variable CheckValue should be false; + Assert.IsFalse(_proxyParallelManager.GetHandlerForGivenManager(manager).CheckValue); + + var newHandler = new SampleHandlerClass(true); + + // Update manager with new handler + _proxyParallelManager.UpdateHandlerForManager(manager, newHandler); + + // It should not add new manager but update the current one + Assert.AreEqual(3, _proxyParallelManager.GetConcurrentManagersCount()); + Assert.IsTrue(_proxyParallelManager.GetHandlerForGivenManager(manager).CheckValue); + } + + private class MockParallelOperationManager : ParallelOperationManager + { + public MockParallelOperationManager(Func createNewClient, int parallelLevel, bool sharedHosts) : + base(createNewClient, parallelLevel, sharedHosts) + { } - private class SampleConcurrentClass + public void DoActionOnAllConcurrentObjects(Action action) { - public bool IsDisposeCalled = false; - public bool CheckValue; - public SampleConcurrentClass(bool value=false) - { - this.CheckValue = value; - } + DoActionOnAllManagers(action, false); } + } - private class SampleHandlerClass + private class SampleConcurrentClass + { + public readonly bool CheckValue; + public SampleConcurrentClass(bool value = false) { - public bool CheckValue; - public SampleHandlerClass(bool value=false) - { - this.CheckValue = value; - } + CheckValue = value; + } + } + private class SampleHandlerClass + { + public readonly bool CheckValue; + public SampleHandlerClass(bool value = false) + { + CheckValue = value; } + } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelProxyDiscoveryManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelProxyDiscoveryManagerTests.cs index d9f85b420b..5624c59a78 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelProxyDiscoveryManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelProxyDiscoveryManagerTests.cs @@ -1,295 +1,279 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Client +namespace TestPlatform.CrossPlatEngine.UnitTests.Client; + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class ParallelProxyDiscoveryManagerTests { - using System; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - [TestClass] - public class ParallelProxyDiscoveryManagerTests + private const int TaskTimeout = 15 * 1000; // In milliseconds. + private readonly List> _createdMockManagers; + private readonly Func _proxyManagerFunc; + private readonly Mock _mockHandler; + private readonly List _sources = new() { "1.dll", "2.dll" }; + private readonly DiscoveryCriteria _testDiscoveryCriteria; + private bool _proxyManagerFuncCalled; + private readonly List _processedSources; + private readonly ManualResetEventSlim _discoveryCompleted; + private readonly Mock _mockRequestData; + + public ParallelProxyDiscoveryManagerTests() { - private const int taskTimeout = 15 * 1000; // In milliseconds. - private List> createdMockManagers; - private Func proxyManagerFunc; - private Mock mockHandler; - private List sources = new List() { "1.dll", "2.dll" }; - private DiscoveryCriteria testDiscoveryCriteria; - private bool proxyManagerFuncCalled; - private List processedSources; - private ManualResetEventSlim discoveryCompleted; - private Mock mockRequestData; - - public ParallelProxyDiscoveryManagerTests() + _processedSources = new List(); + _createdMockManagers = new List>(); + _proxyManagerFunc = () => { - this.processedSources = new List(); - this.createdMockManagers = new List>(); - this.proxyManagerFunc = () => - { - this.proxyManagerFuncCalled = true; - var manager = new Mock(); - this.createdMockManagers.Add(manager); - return manager.Object; - }; - this.mockHandler = new Mock(); - this.testDiscoveryCriteria = new DiscoveryCriteria(sources, 100, null); - this.discoveryCompleted = new ManualResetEventSlim(false); - this.mockRequestData = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new NoOpMetricsCollection()); - } - - [TestMethod] - public void InitializeShouldCallAllConcurrentManagersOnce() - { - InvokeAndVerifyInitialize(3); - } - - [TestMethod] - public void InitializeShouldCallAllConcurrentManagersWithFalseFlagIfSkipDefaultAdaptersIsFalse() - { - InvokeAndVerifyInitialize(3, false); - } + _proxyManagerFuncCalled = true; + var manager = new Mock(); + _createdMockManagers.Add(manager); + return manager.Object; + }; + _mockHandler = new Mock(); + _testDiscoveryCriteria = new DiscoveryCriteria(_sources, 100, null); + _discoveryCompleted = new ManualResetEventSlim(false); + _mockRequestData = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new NoOpMetricsCollection()); + } + [TestMethod] + public void InitializeShouldCallAllConcurrentManagersOnce() + { + InvokeAndVerifyInitialize(3); + } - [TestMethod] - public void InitializeShouldCallAllConcurrentManagersWithTrueFlagIfSkipDefaultAdaptersIsTrue() - { - InvokeAndVerifyInitialize(3, true); - } + [TestMethod] + public void InitializeShouldCallAllConcurrentManagersWithFalseFlagIfSkipDefaultAdaptersIsFalse() + { + InvokeAndVerifyInitialize(3, false); + } - [TestMethod] - public void AbortShouldCallAllConcurrentManagersOnce() - { - var parallelDiscoveryManager = new ParallelProxyDiscoveryManager(this.mockRequestData.Object, this.proxyManagerFunc, 4, false); - parallelDiscoveryManager.Abort(); + [TestMethod] + public void InitializeShouldCallAllConcurrentManagersWithTrueFlagIfSkipDefaultAdaptersIsTrue() + { + InvokeAndVerifyInitialize(3, true); + } - Assert.AreEqual(4, createdMockManagers.Count, "Number of Concurrent Managers created should be 4"); - createdMockManagers.ForEach(dm => dm.Verify(m => m.Abort(), Times.Once)); - } + [TestMethod] + public void AbortShouldCallAllConcurrentManagersOnce() + { + var parallelDiscoveryManager = new ParallelProxyDiscoveryManager(_mockRequestData.Object, _proxyManagerFunc, 4, false); - [TestMethod] - public void DiscoverTestsShouldProcessAllSources() - { - // Testcase filter should be passed to all parallel discovery criteria. - this.testDiscoveryCriteria.TestCaseFilter = "Name~Test"; - var parallelDiscoveryManager = this.SetupDiscoveryManager(this.proxyManagerFunc, 2, false); + parallelDiscoveryManager.Abort(); - Task.Run(() => - { - parallelDiscoveryManager.DiscoverTests(this.testDiscoveryCriteria, this.mockHandler.Object); - }); + Assert.AreEqual(4, _createdMockManagers.Count, "Number of Concurrent Managers created should be 4"); + _createdMockManagers.ForEach(dm => dm.Verify(m => m.Abort(), Times.Once)); + } - Assert.IsTrue(this.discoveryCompleted.Wait(ParallelProxyDiscoveryManagerTests.taskTimeout), "Test discovery not completed."); - Assert.AreEqual(sources.Count, processedSources.Count, "All Sources must be processed."); - AssertMissingAndDuplicateSources(processedSources); - } + [TestMethod] + public void DiscoverTestsShouldProcessAllSources() + { + // Testcase filter should be passed to all parallel discovery criteria. + _testDiscoveryCriteria.TestCaseFilter = "Name~Test"; + var parallelDiscoveryManager = SetupDiscoveryManager(_proxyManagerFunc, 2, false); - /// - /// Create ParallelProxyDiscoveryManager with parallel level 1 and two source, - /// Abort in any source should not stop discovery for other sources. - /// - [TestMethod] - public void DiscoveryTestsShouldProcessAllSourcesOnDiscoveryAbortsForAnySource() - { - // Since the hosts are aborted, total aggregated tests sent across will be -1 - var discoveryManagerMock = new Mock(); - this.createdMockManagers.Add(discoveryManagerMock); - var parallelDiscoveryManager = this.SetupDiscoveryManager(() => discoveryManagerMock.Object, 1, true, totalTests: -1); + Task.Run(() => parallelDiscoveryManager.DiscoverTests(_testDiscoveryCriteria, _mockHandler.Object)); - Task.Run(() => - { - parallelDiscoveryManager.DiscoverTests(this.testDiscoveryCriteria, this.mockHandler.Object); - }); + Assert.IsTrue(_discoveryCompleted.Wait(TaskTimeout), "Test discovery not completed."); + Assert.AreEqual(_sources.Count, _processedSources.Count, "All Sources must be processed."); + AssertMissingAndDuplicateSources(_processedSources); + } - Assert.IsTrue(this.discoveryCompleted.Wait(ParallelProxyDiscoveryManagerTests.taskTimeout), "Test discovery not completed."); - Assert.AreEqual(2, processedSources.Count, "All Sources must be processed."); - } + /// + /// Create ParallelProxyDiscoveryManager with parallel level 1 and two source, + /// Abort in any source should not stop discovery for other sources. + /// + [TestMethod] + public void DiscoveryTestsShouldProcessAllSourcesOnDiscoveryAbortsForAnySource() + { + // Since the hosts are aborted, total aggregated tests sent across will be -1 + var discoveryManagerMock = new Mock(); + _createdMockManagers.Add(discoveryManagerMock); + var parallelDiscoveryManager = SetupDiscoveryManager(() => discoveryManagerMock.Object, 1, true, totalTests: -1); - /// - /// Create ParallelProxyDiscoveryManager with parallel level 1 and two sources, - /// Overall discovery should stop, if aborting was requested - /// - [TestMethod] - public void DiscoveryTestsShouldStopDiscoveryIfAbortionWasRequested() - { - // Since the hosts are aborted, total aggregated tests sent across will be -1 - var discoveryManagerMock = new Mock(); - this.createdMockManagers.Add(discoveryManagerMock); - var parallelDiscoveryManager = this.SetupDiscoveryManager(() => discoveryManagerMock.Object, 1, true, totalTests: -1); + Task.Run(() => parallelDiscoveryManager.DiscoverTests(_testDiscoveryCriteria, _mockHandler.Object)); - Task.Run(() => - { - parallelDiscoveryManager.DiscoverTests(this.testDiscoveryCriteria, this.mockHandler.Object); - parallelDiscoveryManager.Abort(); - }); + Assert.IsTrue(_discoveryCompleted.Wait(TaskTimeout), "Test discovery not completed."); + Assert.AreEqual(2, _processedSources.Count, "All Sources must be processed."); + } - Assert.IsTrue(this.discoveryCompleted.Wait(taskTimeout), "Test discovery not completed."); - Assert.AreEqual(1, processedSources.Count, "One source should be processed."); - } + /// + /// Create ParallelProxyDiscoveryManager with parallel level 1 and two sources, + /// Overall discovery should stop, if aborting was requested + /// + [TestMethod] + public void DiscoveryTestsShouldStopDiscoveryIfAbortionWasRequested() + { + // Since the hosts are aborted, total aggregated tests sent across will be -1 + var discoveryManagerMock = new Mock(); + _createdMockManagers.Add(discoveryManagerMock); + var parallelDiscoveryManager = SetupDiscoveryManager(() => discoveryManagerMock.Object, 1, true, totalTests: -1); - [TestMethod] - public void DiscoveryTestsShouldProcessAllSourceIfOneDiscoveryManagerIsStarved() + Task.Run(() => { - // Ensure that second discovery manager never starts. Expect 10 total tests. - // Override DiscoveryComplete since overall aborted should be true - var parallelDiscoveryManager = this.SetupDiscoveryManager(this.proxyManagerFunc, 2, false, totalTests: 10); - this.createdMockManagers[1].Reset(); - this.createdMockManagers[1].Setup(dm => dm.DiscoverTests(It.IsAny(), It.IsAny())) - .Throws(); - this.mockHandler.Setup(mh => mh.HandleDiscoveryComplete(It.IsAny(), null)) - .Callback>((t, l) => { this.discoveryCompleted.Set(); }); - - Task.Run(() => - { - parallelDiscoveryManager.DiscoverTests(this.testDiscoveryCriteria, this.mockHandler.Object); - }); - - // Processed sources should be 1 since the 2nd source is never discovered - Assert.IsTrue(this.discoveryCompleted.Wait(ParallelProxyDiscoveryManagerTests.taskTimeout), "Test discovery not completed."); - Assert.AreEqual(1, processedSources.Count, "All Sources must be processed."); - } + parallelDiscoveryManager.DiscoverTests(_testDiscoveryCriteria, _mockHandler.Object); + parallelDiscoveryManager.Abort(); + }); - [TestMethod] - public void DiscoveryTestsShouldCatchExceptionAndHandleLogMessageOfError() - { - // Ensure that second discovery manager never starts. Expect 10 total tests. - // Override DiscoveryComplete since overall aborted should be true - var parallelDiscoveryManager = this.SetupDiscoveryManager(this.proxyManagerFunc, 2, false, totalTests: 10); - this.createdMockManagers[1].Reset(); - this.createdMockManagers[1].Setup(dm => dm.DiscoverTests(It.IsAny(), It.IsAny())) - .Throws(); - this.mockHandler.Setup(mh => mh.HandleDiscoveryComplete(It.IsAny(), null)) - .Callback>((t, l) => { this.discoveryCompleted.Set(); }); - - Task.Run(() => - { - parallelDiscoveryManager.DiscoverTests(this.testDiscoveryCriteria, this.mockHandler.Object); - }); + Assert.IsTrue(_discoveryCompleted.Wait(TaskTimeout), "Test discovery not completed."); + Assert.AreEqual(1, _processedSources.Count, "One source should be processed."); + } - // Processed sources should be 1 since the 2nd source is never discovered - Assert.IsTrue(this.discoveryCompleted.Wait(ParallelProxyDiscoveryManagerTests.taskTimeout), "Test discovery not completed."); - mockHandler.Verify(s => s.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); - } + [TestMethod] + public void DiscoveryTestsShouldProcessAllSourceIfOneDiscoveryManagerIsStarved() + { + // Ensure that second discovery manager never starts. Expect 10 total tests. + // Override DiscoveryComplete since overall aborted should be true + var parallelDiscoveryManager = SetupDiscoveryManager(_proxyManagerFunc, 2, false, totalTests: 10); + _createdMockManagers[1].Reset(); + _createdMockManagers[1].Setup(dm => dm.DiscoverTests(It.IsAny(), It.IsAny())) + .Throws(); + _mockHandler.Setup(mh => mh.HandleDiscoveryComplete(It.IsAny(), null)) + .Callback>((t, l) => _discoveryCompleted.Set()); + + Task.Run(() => parallelDiscoveryManager.DiscoverTests(_testDiscoveryCriteria, _mockHandler.Object)); + + // Processed sources should be 1 since the 2nd source is never discovered + Assert.IsTrue(_discoveryCompleted.Wait(TaskTimeout), "Test discovery not completed."); + Assert.AreEqual(1, _processedSources.Count, "All Sources must be processed."); + } - [TestMethod] - public void DiscoveryTestsShouldCatchExceptionAndHandleRawMessageOfTestMessage() - { - // Ensure that second discovery manager never starts. Expect 10 total tests. - // Override DiscoveryComplete since overall aborted should be true - var parallelDiscoveryManager = this.SetupDiscoveryManager(this.proxyManagerFunc, 2, false, totalTests: 10); - this.createdMockManagers[1].Reset(); - this.createdMockManagers[1].Setup(dm => dm.DiscoverTests(It.IsAny(), It.IsAny())) - .Throws(); - this.mockHandler.Setup(mh => mh.HandleDiscoveryComplete(It.IsAny(), null)) - .Callback>((t, l) => { this.discoveryCompleted.Set(); }); - - Task.Run(() => - { - parallelDiscoveryManager.DiscoverTests(this.testDiscoveryCriteria, this.mockHandler.Object); - }); + [TestMethod] + public void DiscoveryTestsShouldCatchExceptionAndHandleLogMessageOfError() + { + // Ensure that second discovery manager never starts. Expect 10 total tests. + // Override DiscoveryComplete since overall aborted should be true + var parallelDiscoveryManager = SetupDiscoveryManager(_proxyManagerFunc, 2, false, totalTests: 10); + _createdMockManagers[1].Reset(); + _createdMockManagers[1].Setup(dm => dm.DiscoverTests(It.IsAny(), It.IsAny())) + .Throws(); + _mockHandler.Setup(mh => mh.HandleDiscoveryComplete(It.IsAny(), null)) + .Callback>((t, l) => _discoveryCompleted.Set()); + + Task.Run(() => parallelDiscoveryManager.DiscoverTests(_testDiscoveryCriteria, _mockHandler.Object)); + + // Processed sources should be 1 since the 2nd source is never discovered + Assert.IsTrue(_discoveryCompleted.Wait(TaskTimeout), "Test discovery not completed."); + _mockHandler.Verify(s => s.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); + } - // Processed sources should be 1 since the 2nd source is never discovered - Assert.IsTrue(this.discoveryCompleted.Wait(ParallelProxyDiscoveryManagerTests.taskTimeout), "Test discovery not completed."); - mockHandler.Verify(s => s.HandleRawMessage(It.Is(str => str.Contains(MessageType.TestMessage)))); - } + [TestMethod] + public void DiscoveryTestsShouldCatchExceptionAndHandleRawMessageOfTestMessage() + { + // Ensure that second discovery manager never starts. Expect 10 total tests. + // Override DiscoveryComplete since overall aborted should be true + var parallelDiscoveryManager = SetupDiscoveryManager(_proxyManagerFunc, 2, false, totalTests: 10); + _createdMockManagers[1].Reset(); + _createdMockManagers[1].Setup(dm => dm.DiscoverTests(It.IsAny(), It.IsAny())) + .Throws(); + _mockHandler.Setup(mh => mh.HandleDiscoveryComplete(It.IsAny(), null)) + .Callback>((t, l) => _discoveryCompleted.Set()); + + Task.Run(() => parallelDiscoveryManager.DiscoverTests(_testDiscoveryCriteria, _mockHandler.Object)); + + // Processed sources should be 1 since the 2nd source is never discovered + Assert.IsTrue(_discoveryCompleted.Wait(TaskTimeout), "Test discovery not completed."); + _mockHandler.Verify(s => s.HandleRawMessage(It.Is(str => str.Contains(MessageType.TestMessage)))); + } - [TestMethod] - public void HandlePartialDiscoveryCompleteShouldCreateANewProxyDiscoveryManagerIfIsAbortedIsTrue() - { - this.proxyManagerFuncCalled = false; - var parallelDiscoveryManager = new ParallelProxyDiscoveryManager(this.mockRequestData.Object, this.proxyManagerFunc, 1, false); - var proxyDiscovermanager = new ProxyDiscoveryManager(this.mockRequestData.Object, new Mock().Object, new Mock().Object); + [TestMethod] + public void HandlePartialDiscoveryCompleteShouldCreateANewProxyDiscoveryManagerIfIsAbortedIsTrue() + { + _proxyManagerFuncCalled = false; + var parallelDiscoveryManager = new ParallelProxyDiscoveryManager(_mockRequestData.Object, _proxyManagerFunc, 1, false); + var proxyDiscovermanager = new ProxyDiscoveryManager(_mockRequestData.Object, new Mock().Object, new Mock().Object); - parallelDiscoveryManager.HandlePartialDiscoveryComplete(proxyDiscovermanager, 20, new List(), isAborted: true); + parallelDiscoveryManager.HandlePartialDiscoveryComplete(proxyDiscovermanager, 20, new List(), isAborted: true); - Assert.IsTrue(this.proxyManagerFuncCalled); - } + Assert.IsTrue(_proxyManagerFuncCalled); + } - private IParallelProxyDiscoveryManager SetupDiscoveryManager(Func getProxyManager, int parallelLevel, bool abortDiscovery, int totalTests = 20) - { - var parallelDiscoveryManager = new ParallelProxyDiscoveryManager(this.mockRequestData.Object, getProxyManager, parallelLevel, false); - this.SetupDiscoveryTests(this.processedSources, abortDiscovery); + private IParallelProxyDiscoveryManager SetupDiscoveryManager(Func getProxyManager, int parallelLevel, bool abortDiscovery, int totalTests = 20) + { + var parallelDiscoveryManager = new ParallelProxyDiscoveryManager(_mockRequestData.Object, getProxyManager, parallelLevel, false); + SetupDiscoveryTests(_processedSources, abortDiscovery); - // Setup a complete handler for parallel discovery manager - this.mockHandler.Setup(mh => mh.HandleDiscoveryComplete(It.IsAny(), null)) - .Callback>( - (discoveryCompleteEventArgs, lastChunk) => { this.discoveryCompleted.Set(); }); + // Setup a complete handler for parallel discovery manager + _mockHandler.Setup(mh => mh.HandleDiscoveryComplete(It.IsAny(), null)) + .Callback>( + (discoveryCompleteEventArgs, lastChunk) => _discoveryCompleted.Set()); - return parallelDiscoveryManager; - } + return parallelDiscoveryManager; + } - private void SetupDiscoveryTests(List processedSources, bool isAbort) + private void SetupDiscoveryTests(List processedSources, bool isAbort) + { + var syncObject = new object(); + foreach (var manager in _createdMockManagers) { - var syncObject = new object(); - foreach (var manager in this.createdMockManagers) - { - manager.Setup(m => m.DiscoverTests(It.IsAny(), It.IsAny())). - Callback( - (criteria, handler) => + manager.Setup(m => m.DiscoverTests(It.IsAny(), It.IsAny())). + Callback( + (criteria, handler) => + { + lock (syncObject) { - lock (syncObject) - { - processedSources.AddRange(criteria.Sources); - } + processedSources.AddRange(criteria.Sources); + } - Task.Delay(100).Wait(); + Task.Delay(100).Wait(); - Assert.AreEqual(this.testDiscoveryCriteria.TestCaseFilter, criteria.TestCaseFilter); - handler.HandleDiscoveryComplete(isAbort ? new DiscoveryCompleteEventArgs(-1, isAbort) : new DiscoveryCompleteEventArgs(10, isAbort), null); - }); - } + Assert.AreEqual(_testDiscoveryCriteria.TestCaseFilter, criteria.TestCaseFilter); + handler.HandleDiscoveryComplete(isAbort ? new DiscoveryCompleteEventArgs(-1, isAbort) : new DiscoveryCompleteEventArgs(10, isAbort), null); + }); } + } - private void AssertMissingAndDuplicateSources(List processedSources) + private void AssertMissingAndDuplicateSources(List processedSources) + { + foreach (var source in _sources) { - foreach (var source in this.sources) - { - bool matchFound = false; + bool matchFound = false; - foreach (var processedSrc in processedSources) + foreach (var processedSrc in processedSources) + { + if (processedSrc.Equals(source)) { - if (processedSrc.Equals(source)) + if (matchFound) { - if (matchFound) - { - Assert.Fail("Concurrency issue detected: Source['{0}'] got processed twice", processedSrc); - } - - matchFound = true; + Assert.Fail("Concurrency issue detected: Source['{0}'] got processed twice", processedSrc); } - } - Assert.IsTrue(matchFound, "Concurrency issue detected: Source['{0}'] did NOT get processed at all", source); + matchFound = true; + } } + + Assert.IsTrue(matchFound, "Concurrency issue detected: Source['{0}'] did NOT get processed at all", source); } + } - private void InvokeAndVerifyInitialize(int concurrentManagersCount, bool skipDefaultAdapters = false) - { - var parallelDiscoveryManager = new ParallelProxyDiscoveryManager(this.mockRequestData.Object, this.proxyManagerFunc, concurrentManagersCount, false); + private void InvokeAndVerifyInitialize(int concurrentManagersCount, bool skipDefaultAdapters = false) + { + var parallelDiscoveryManager = new ParallelProxyDiscoveryManager(_mockRequestData.Object, _proxyManagerFunc, concurrentManagersCount, false); - // Action - parallelDiscoveryManager.Initialize(skipDefaultAdapters); + // Action + parallelDiscoveryManager.Initialize(skipDefaultAdapters); - // Verify - Assert.AreEqual(concurrentManagersCount, createdMockManagers.Count, $"Number of Concurrent Managers created should be {concurrentManagersCount}"); - createdMockManagers.ForEach(dm => dm.Verify(m => m.Initialize(skipDefaultAdapters), Times.Once)); - } + // Verify + Assert.AreEqual(concurrentManagersCount, _createdMockManagers.Count, $"Number of Concurrent Managers created should be {concurrentManagersCount}"); + _createdMockManagers.ForEach(dm => dm.Verify(m => m.Initialize(skipDefaultAdapters), Times.Once)); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelProxyExecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelProxyExecutionManagerTests.cs index ca4700c66e..16f73a318d 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelProxyExecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelProxyExecutionManagerTests.cs @@ -1,379 +1,368 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Client +namespace TestPlatform.CrossPlatEngine.UnitTests.Client; + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class ParallelProxyExecutionManagerTests { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Linq; - using System.Threading; - using System.Threading.Tasks; - - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - [TestClass] - public class ParallelProxyExecutionManagerTests - { - private static readonly int taskTimeout = 15 * 1000; // In milliseconds + private static readonly int TaskTimeout = 15 * 1000; // In milliseconds - private List> createdMockManagers; - private Func proxyManagerFunc; - private Mock mockHandler; - private Mock mockTestHostManager; + private readonly List> _createdMockManagers; + private Func _proxyManagerFunc; + private readonly Mock _mockHandler; + private Mock _mockTestHostManager; - private Mock mockRequestSender; + private Mock _mockRequestSender; - private Mock mockDataCollectionManager; - private List sources; - private List processedSources; - private TestRunCriteria testRunCriteriaWithSources; - private List testCases; - private List processedTestCases; - private TestRunCriteria testRunCriteriaWithTests; + private Mock _mockDataCollectionManager; + private readonly List _sources; + private readonly List _processedSources; + private readonly TestRunCriteria _testRunCriteriaWithSources; + private readonly List _testCases; + private readonly List _processedTestCases; + private readonly TestRunCriteria _testRunCriteriaWithTests; - private bool proxyManagerFuncCalled; - private ManualResetEventSlim executionCompleted; - private Mock mockRequestData; + private bool _proxyManagerFuncCalled; + private readonly ManualResetEventSlim _executionCompleted; + private readonly Mock _mockRequestData; - public ParallelProxyExecutionManagerTests() + public ParallelProxyExecutionManagerTests() + { + _executionCompleted = new ManualResetEventSlim(false); + _createdMockManagers = new List>(); + _proxyManagerFunc = () => { - this.executionCompleted = new ManualResetEventSlim(false); - this.createdMockManagers = new List>(); - this.proxyManagerFunc = () => - { - this.proxyManagerFuncCalled = true; - var manager = new Mock(); - createdMockManagers.Add(manager); - return manager.Object; - }; - this.mockHandler = new Mock(); - - // Configure sources - this.sources = new List() { "1.dll", "2.dll" }; - this.processedSources = new List(); - this.testRunCriteriaWithSources = new TestRunCriteria(sources, 100, false, string.Empty, TimeSpan.MaxValue, null, "Name~Test", new FilterOptions() { FilterRegEx = @"^[^\s\(]+" }); - - // Configure testcases - this.testCases = CreateTestCases(); - this.processedTestCases = new List(); - this.testRunCriteriaWithTests = new TestRunCriteria(this.testCases, 100); - this.mockRequestData = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new NoOpMetricsCollection()); - } + _proxyManagerFuncCalled = true; + var manager = new Mock(); + _createdMockManagers.Add(manager); + return manager.Object; + }; + _mockHandler = new Mock(); + + // Configure sources + _sources = new List() { "1.dll", "2.dll" }; + _processedSources = new List(); + _testRunCriteriaWithSources = new TestRunCriteria(_sources, 100, false, string.Empty, TimeSpan.MaxValue, null, "Name~Test", new FilterOptions() { FilterRegEx = @"^[^\s\(]+" }); + + // Configure testcases + _testCases = CreateTestCases(); + _processedTestCases = new List(); + _testRunCriteriaWithTests = new TestRunCriteria(_testCases, 100); + _mockRequestData = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new NoOpMetricsCollection()); + } - [TestMethod] - public void InitializeShouldCallAllConcurrentManagersOnce() - { - InvokeAndVerifyInitialize(3); - } + [TestMethod] + public void InitializeShouldCallAllConcurrentManagersOnce() + { + InvokeAndVerifyInitialize(3); + } - [TestMethod] - public void InitializeShouldCallAllConcurrentManagersWithFalseFlagIfSkipDefaultAdaptersIsFalse() - { - InvokeAndVerifyInitialize(3, false); - } + [TestMethod] + public void InitializeShouldCallAllConcurrentManagersWithFalseFlagIfSkipDefaultAdaptersIsFalse() + { + InvokeAndVerifyInitialize(3, false); + } - [TestMethod] - public void InitializeShouldCallAllConcurrentManagersWithTrueFlagIfSkipDefaultAdaptersIsTrue() - { - InvokeAndVerifyInitialize(3, true); - } + [TestMethod] + public void InitializeShouldCallAllConcurrentManagersWithTrueFlagIfSkipDefaultAdaptersIsTrue() + { + InvokeAndVerifyInitialize(3, true); + } - [TestMethod] - public void AbortShouldCallAllConcurrentManagersOnce() - { - var parallelExecutionManager = new ParallelProxyExecutionManager(this.mockRequestData.Object, this.proxyManagerFunc, 4); + [TestMethod] + public void AbortShouldCallAllConcurrentManagersOnce() + { + var parallelExecutionManager = new ParallelProxyExecutionManager(_mockRequestData.Object, _proxyManagerFunc, 4); - parallelExecutionManager.Abort(It.IsAny()); + parallelExecutionManager.Abort(It.IsAny()); - Assert.AreEqual(4, createdMockManagers.Count, "Number of Concurrent Managers created should be 4"); - createdMockManagers.ForEach(em => em.Verify(m => m.Abort(It.IsAny()), Times.Once)); - } + Assert.AreEqual(4, _createdMockManagers.Count, "Number of Concurrent Managers created should be 4"); + _createdMockManagers.ForEach(em => em.Verify(m => m.Abort(It.IsAny()), Times.Once)); + } - [TestMethod] - public void CancelShouldCallAllConcurrentManagersOnce() - { - var parallelExecutionManager = new ParallelProxyExecutionManager(this.mockRequestData.Object, this.proxyManagerFunc, 4); + [TestMethod] + public void CancelShouldCallAllConcurrentManagersOnce() + { + var parallelExecutionManager = new ParallelProxyExecutionManager(_mockRequestData.Object, _proxyManagerFunc, 4); - parallelExecutionManager.Cancel(It.IsAny()); + parallelExecutionManager.Cancel(It.IsAny()); - Assert.AreEqual(4, createdMockManagers.Count, "Number of Concurrent Managers created should be 4"); - createdMockManagers.ForEach(em => em.Verify(m => m.Cancel(It.IsAny()), Times.Once)); - } + Assert.AreEqual(4, _createdMockManagers.Count, "Number of Concurrent Managers created should be 4"); + _createdMockManagers.ForEach(em => em.Verify(m => m.Cancel(It.IsAny()), Times.Once)); + } - [TestMethod] - public void StartTestRunShouldProcessAllSources() - { - var parallelExecutionManager = this.SetupExecutionManager(this.proxyManagerFunc, 2); + [TestMethod] + public void StartTestRunShouldProcessAllSources() + { + var parallelExecutionManager = SetupExecutionManager(_proxyManagerFunc, 2); - parallelExecutionManager.StartTestRun(testRunCriteriaWithSources, this.mockHandler.Object); + parallelExecutionManager.StartTestRun(_testRunCriteriaWithSources, _mockHandler.Object); - Assert.IsTrue(this.executionCompleted.Wait(taskTimeout), "Test run not completed."); - Assert.AreEqual(this.sources.Count, processedSources.Count, "All Sources must be processed."); - AssertMissingAndDuplicateSources(processedSources); - } + Assert.IsTrue(_executionCompleted.Wait(TaskTimeout), "Test run not completed."); + Assert.AreEqual(_sources.Count, _processedSources.Count, "All Sources must be processed."); + AssertMissingAndDuplicateSources(_processedSources); + } - [TestMethod] - public void StartTestRunShouldProcessAllTestCases() - { - var parallelExecutionManager = this.SetupExecutionManager(this.proxyManagerFunc, 3, setupTestCases: true); + [TestMethod] + public void StartTestRunShouldProcessAllTestCases() + { + var parallelExecutionManager = SetupExecutionManager(_proxyManagerFunc, 3, setupTestCases: true); - parallelExecutionManager.StartTestRun(this.testRunCriteriaWithTests, this.mockHandler.Object); + parallelExecutionManager.StartTestRun(_testRunCriteriaWithTests, _mockHandler.Object); - Assert.IsTrue(this.executionCompleted.Wait(taskTimeout), "Test run not completed."); - Assert.AreEqual(this.testCases.Count, processedTestCases.Count, "All Tests must be processed."); - AssertMissingAndDuplicateTestCases(this.testCases, processedTestCases); - } + Assert.IsTrue(_executionCompleted.Wait(TaskTimeout), "Test run not completed."); + Assert.AreEqual(_testCases.Count, _processedTestCases.Count, "All Tests must be processed."); + AssertMissingAndDuplicateTestCases(_testCases, _processedTestCases); + } - [TestMethod] - public void StartTestRunWithSourcesShouldNotSendCompleteUntilAllSourcesAreProcessed() - { - var parallelExecutionManager = this.SetupExecutionManager(this.proxyManagerFunc, 2); + [TestMethod] + public void StartTestRunWithSourcesShouldNotSendCompleteUntilAllSourcesAreProcessed() + { + var parallelExecutionManager = SetupExecutionManager(_proxyManagerFunc, 2); - Task.Run(() => - { - parallelExecutionManager.StartTestRun(testRunCriteriaWithSources, this.mockHandler.Object); - }); + Task.Run(() => parallelExecutionManager.StartTestRun(_testRunCriteriaWithSources, _mockHandler.Object)); - Assert.IsTrue(this.executionCompleted.Wait(taskTimeout), "Test run not completed."); - Assert.AreEqual(this.sources.Count, this.processedSources.Count, "All Sources must be processed."); - AssertMissingAndDuplicateSources(this.processedSources); - } + Assert.IsTrue(_executionCompleted.Wait(TaskTimeout), "Test run not completed."); + Assert.AreEqual(_sources.Count, _processedSources.Count, "All Sources must be processed."); + AssertMissingAndDuplicateSources(_processedSources); + } - [TestMethod] - public void HandlePartialRunCompleteShouldCreateNewProxyExecutionManagerIfDataCollectionEnabled() - { - var completeArgs = new TestRunCompleteEventArgs(null, true, true, null, null, null, TimeSpan.Zero); - this.mockTestHostManager = new Mock(); - this.mockRequestSender = new Mock(); - this.mockDataCollectionManager = new Mock(); - var proxyDataCollectionManager = new ProxyExecutionManagerWithDataCollection(this.mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object, this.mockDataCollectionManager.Object); - var parallelExecutionManager = this.SetupExecutionManager(this.proxyManagerFunc, 2, setupTestCases: true); - - this.proxyManagerFuncCalled = false; - parallelExecutionManager.HandlePartialRunComplete(proxyDataCollectionManager, completeArgs, null, null, null); - Assert.IsTrue(this.proxyManagerFuncCalled); - } + [TestMethod] + public void HandlePartialRunCompleteShouldCreateNewProxyExecutionManagerIfDataCollectionEnabled() + { + var completeArgs = new TestRunCompleteEventArgs(null, true, true, null, null, null, TimeSpan.Zero); + _mockTestHostManager = new Mock(); + _mockRequestSender = new Mock(); + _mockDataCollectionManager = new Mock(); + var proxyDataCollectionManager = new ProxyExecutionManagerWithDataCollection(_mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object, _mockDataCollectionManager.Object); + var parallelExecutionManager = SetupExecutionManager(_proxyManagerFunc, 2, setupTestCases: true); + + _proxyManagerFuncCalled = false; + parallelExecutionManager.HandlePartialRunComplete(proxyDataCollectionManager, completeArgs, null, null, null); + Assert.IsTrue(_proxyManagerFuncCalled); + } - [TestMethod] - public void HandlePartialRunCompleteShouldCreateNewProxyExecutionManagerIfDataCollectionEnabledAndCreatorWithDataCollection() + [TestMethod] + public void HandlePartialRunCompleteShouldCreateNewProxyExecutionManagerIfDataCollectionEnabledAndCreatorWithDataCollection() + { + var completeArgs = new TestRunCompleteEventArgs(null, true, true, null, null, null, TimeSpan.Zero); + _mockTestHostManager = new Mock(); + _mockRequestSender = new Mock(); + _mockDataCollectionManager = new Mock(); + var proxyDataCollectionManager = new ProxyExecutionManagerWithDataCollection(_mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object, _mockDataCollectionManager.Object); + var managers = new List>(); + _proxyManagerFunc = () => { - var completeArgs = new TestRunCompleteEventArgs(null, true, true, null, null, null, TimeSpan.Zero); - this.mockTestHostManager = new Mock(); - this.mockRequestSender = new Mock(); - this.mockDataCollectionManager = new Mock(); - var proxyDataCollectionManager = new ProxyExecutionManagerWithDataCollection(this.mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object, this.mockDataCollectionManager.Object); - var managers = new List>(); - this.proxyManagerFunc = () => - { - this.proxyManagerFuncCalled = true; - var manager = new Mock(this.mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object, this.mockDataCollectionManager.Object); - managers.Add(manager); - return manager.Object; - }; - var parallelExecutionManager = this.SetupExecutionManager(this.proxyManagerFunc, 2, setupTestCases: true); - - this.proxyManagerFuncCalled = false; - parallelExecutionManager.HandlePartialRunComplete(proxyDataCollectionManager, completeArgs, null, null, null); - Assert.IsTrue(this.proxyManagerFuncCalled); - - var handler = parallelExecutionManager.GetHandlerForGivenManager(managers.Last().Object); - Assert.IsTrue(handler is ParallelDataCollectionEventsHandler); - } + _proxyManagerFuncCalled = true; + var manager = new Mock(_mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object, _mockDataCollectionManager.Object); + managers.Add(manager); + return manager.Object; + }; + var parallelExecutionManager = SetupExecutionManager(_proxyManagerFunc, 2, setupTestCases: true); + + _proxyManagerFuncCalled = false; + parallelExecutionManager.HandlePartialRunComplete(proxyDataCollectionManager, completeArgs, null, null, null); + Assert.IsTrue(_proxyManagerFuncCalled); + + var handler = parallelExecutionManager.GetHandlerForGivenManager(managers.Last().Object); + Assert.IsTrue(handler is ParallelDataCollectionEventsHandler); + } - [TestMethod] - public void HandlePartialRunCompleteShouldCreateNewProxyExecutionManagerIfIsAbortedIsTrue() - { - var completeArgs = new TestRunCompleteEventArgs(null, true, true, null, null, null, TimeSpan.Zero); - this.mockTestHostManager = new Mock(); - this.mockRequestSender = new Mock(); - var parallelExecutionManager = this.SetupExecutionManager(this.proxyManagerFunc, 2, setupTestCases: true); - - this.proxyManagerFuncCalled = false; - var proxyExecutionManagerManager = new ProxyExecutionManager(this.mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object); - parallelExecutionManager.HandlePartialRunComplete(proxyExecutionManagerManager, completeArgs, null, null, null); - Assert.IsTrue(this.proxyManagerFuncCalled); - } + [TestMethod] + public void HandlePartialRunCompleteShouldCreateNewProxyExecutionManagerIfIsAbortedIsTrue() + { + var completeArgs = new TestRunCompleteEventArgs(null, true, true, null, null, null, TimeSpan.Zero); + _mockTestHostManager = new Mock(); + _mockRequestSender = new Mock(); + var parallelExecutionManager = SetupExecutionManager(_proxyManagerFunc, 2, setupTestCases: true); + + _proxyManagerFuncCalled = false; + var proxyExecutionManagerManager = new ProxyExecutionManager(_mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object); + parallelExecutionManager.HandlePartialRunComplete(proxyExecutionManagerManager, completeArgs, null, null, null); + Assert.IsTrue(_proxyManagerFuncCalled); + } - [TestMethod] - public void StartTestRunWithTestsShouldNotSendCompleteUntilAllTestsAreProcessed() - { - var parallelExecutionManager = this.SetupExecutionManager(this.proxyManagerFunc, 3, setupTestCases: true); + [TestMethod] + public void StartTestRunWithTestsShouldNotSendCompleteUntilAllTestsAreProcessed() + { + var parallelExecutionManager = SetupExecutionManager(_proxyManagerFunc, 3, setupTestCases: true); - Task.Run(() => - { - parallelExecutionManager.StartTestRun(this.testRunCriteriaWithTests, this.mockHandler.Object); - }); + Task.Run(() => parallelExecutionManager.StartTestRun(_testRunCriteriaWithTests, _mockHandler.Object)); - Assert.IsTrue(this.executionCompleted.Wait(taskTimeout), "Test run not completed."); - Assert.AreEqual(this.testCases.Count, processedTestCases.Count, "All Tests must be processed."); - AssertMissingAndDuplicateTestCases(this.testCases, processedTestCases); - } + Assert.IsTrue(_executionCompleted.Wait(TaskTimeout), "Test run not completed."); + Assert.AreEqual(_testCases.Count, _processedTestCases.Count, "All Tests must be processed."); + AssertMissingAndDuplicateTestCases(_testCases, _processedTestCases); + } - [TestMethod] - public void StartTestRunShouldNotProcessAllSourcesOnExecutionCancelsForAnySource() - { - var executionManagerMock = new Mock(); - var parallelExecutionManager = new ParallelProxyExecutionManager(this.mockRequestData.Object, () => executionManagerMock.Object, 1); - this.createdMockManagers.Add(executionManagerMock); - this.SetupMockManagers(this.processedSources, isCanceled: true, isAborted: false); - SetupHandleTestRunComplete(this.executionCompleted); + [TestMethod] + public void StartTestRunShouldNotProcessAllSourcesOnExecutionCancelsForAnySource() + { + var executionManagerMock = new Mock(); + var parallelExecutionManager = new ParallelProxyExecutionManager(_mockRequestData.Object, () => executionManagerMock.Object, 1); + _createdMockManagers.Add(executionManagerMock); + SetupMockManagers(_processedSources, isCanceled: true, isAborted: false); + SetupHandleTestRunComplete(_executionCompleted); - Task.Run(() => { parallelExecutionManager.StartTestRun(this.testRunCriteriaWithSources, this.mockHandler.Object); }); + Task.Run(() => parallelExecutionManager.StartTestRun(_testRunCriteriaWithSources, _mockHandler.Object)); - Assert.IsTrue(this.executionCompleted.Wait(taskTimeout), "Test run not completed."); - Assert.AreEqual(1, this.processedSources.Count, "Abort should stop all sources execution."); - } + Assert.IsTrue(_executionCompleted.Wait(TaskTimeout), "Test run not completed."); + Assert.AreEqual(1, _processedSources.Count, "Abort should stop all sources execution."); + } - [TestMethod] - public void StartTestRunShouldNotProcessAllSourcesOnExecutionAborted() - { - var executionManagerMock = new Mock(); - var parallelExecutionManager = new ParallelProxyExecutionManager(this.mockRequestData.Object, () => executionManagerMock.Object, 1); - this.createdMockManagers.Add(executionManagerMock); - this.SetupMockManagers(this.processedSources, isCanceled: false, isAborted: false); - SetupHandleTestRunComplete(this.executionCompleted); + [TestMethod] + public void StartTestRunShouldNotProcessAllSourcesOnExecutionAborted() + { + var executionManagerMock = new Mock(); + var parallelExecutionManager = new ParallelProxyExecutionManager(_mockRequestData.Object, () => executionManagerMock.Object, 1); + _createdMockManagers.Add(executionManagerMock); + SetupMockManagers(_processedSources, isCanceled: false, isAborted: false); + SetupHandleTestRunComplete(_executionCompleted); - parallelExecutionManager.Abort(It.IsAny()); - Task.Run(() => { parallelExecutionManager.StartTestRun(this.testRunCriteriaWithSources, this.mockHandler.Object); }); + parallelExecutionManager.Abort(It.IsAny()); + Task.Run(() => parallelExecutionManager.StartTestRun(_testRunCriteriaWithSources, _mockHandler.Object)); - Assert.IsTrue(this.executionCompleted.Wait(taskTimeout), "Test run not completed."); - Assert.AreEqual(1, this.processedSources.Count, "Abort should stop all sources execution."); - } + Assert.IsTrue(_executionCompleted.Wait(TaskTimeout), "Test run not completed."); + Assert.AreEqual(1, _processedSources.Count, "Abort should stop all sources execution."); + } - [TestMethod] - public void StartTestRunShouldProcessAllSourcesOnExecutionAbortsForAnySource() - { - var executionManagerMock = new Mock(); - var parallelExecutionManager = new ParallelProxyExecutionManager(this.mockRequestData.Object, () => executionManagerMock.Object, 1); - this.createdMockManagers.Add(executionManagerMock); - this.SetupMockManagers(processedSources, isCanceled: false, isAborted: true); - SetupHandleTestRunComplete(this.executionCompleted); + [TestMethod] + public void StartTestRunShouldProcessAllSourcesOnExecutionAbortsForAnySource() + { + var executionManagerMock = new Mock(); + var parallelExecutionManager = new ParallelProxyExecutionManager(_mockRequestData.Object, () => executionManagerMock.Object, 1); + _createdMockManagers.Add(executionManagerMock); + SetupMockManagers(_processedSources, isCanceled: false, isAborted: true); + SetupHandleTestRunComplete(_executionCompleted); - Task.Run(() => { parallelExecutionManager.StartTestRun(this.testRunCriteriaWithSources, this.mockHandler.Object); }); + Task.Run(() => parallelExecutionManager.StartTestRun(_testRunCriteriaWithSources, _mockHandler.Object)); - Assert.IsTrue(this.executionCompleted.Wait(taskTimeout), "Test run not completed."); - Assert.AreEqual(2, this.processedSources.Count, "Abort should stop all sources execution."); - } + Assert.IsTrue(_executionCompleted.Wait(TaskTimeout), "Test run not completed."); + Assert.AreEqual(2, _processedSources.Count, "Abort should stop all sources execution."); + } - [TestMethod] - public void StartTestRunShouldProcessAllSourceIfOneDiscoveryManagerIsStarved() - { - // Ensure that second discovery manager never starts. Expect 10 total tests. - var parallelExecutionManager = this.SetupExecutionManager(this.proxyManagerFunc, 2); - this.createdMockManagers[1].Reset(); - this.createdMockManagers[1].Setup(em => em.StartTestRun(It.IsAny(), It.IsAny())) - .Throws(); + [TestMethod] + public void StartTestRunShouldProcessAllSourceIfOneDiscoveryManagerIsStarved() + { + // Ensure that second discovery manager never starts. Expect 10 total tests. + var parallelExecutionManager = SetupExecutionManager(_proxyManagerFunc, 2); + _createdMockManagers[1].Reset(); + _createdMockManagers[1].Setup(em => em.StartTestRun(It.IsAny(), It.IsAny())) + .Throws(); - Task.Run(() => - { - parallelExecutionManager.StartTestRun(this.testRunCriteriaWithSources, this.mockHandler.Object); - }); + Task.Run(() => parallelExecutionManager.StartTestRun(_testRunCriteriaWithSources, _mockHandler.Object)); - // Processed sources should be 1 since the 2nd source is never discovered - Assert.IsTrue(this.executionCompleted.Wait(taskTimeout), "Test run not completed."); - Assert.AreEqual(1, this.processedSources.Count, "All Sources must be processed."); - } + // Processed sources should be 1 since the 2nd source is never discovered + Assert.IsTrue(_executionCompleted.Wait(TaskTimeout), "Test run not completed."); + Assert.AreEqual(1, _processedSources.Count, "All Sources must be processed."); + } - [TestMethod] - public void StartTestRunShouldCatchExceptionAndHandleLogMessageOfError() - { - var parallelExecutionManager = this.SetupExecutionManager(this.proxyManagerFunc, 2); - this.createdMockManagers[1].Reset(); - this.createdMockManagers[1].Setup(em => em.StartTestRun(It.IsAny(), It.IsAny())) - .Throws(); + [TestMethod] + public void StartTestRunShouldCatchExceptionAndHandleLogMessageOfError() + { + var parallelExecutionManager = SetupExecutionManager(_proxyManagerFunc, 2); + _createdMockManagers[1].Reset(); + _createdMockManagers[1].Setup(em => em.StartTestRun(It.IsAny(), It.IsAny())) + .Throws(); - Task.Run(() => - { - parallelExecutionManager.StartTestRun(this.testRunCriteriaWithSources, this.mockHandler.Object); - }); + Task.Run(() => parallelExecutionManager.StartTestRun(_testRunCriteriaWithSources, _mockHandler.Object)); - Assert.IsTrue(this.executionCompleted.Wait(taskTimeout), "Test run not completed."); - mockHandler.Verify(s => s.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); - } + Assert.IsTrue(_executionCompleted.Wait(TaskTimeout), "Test run not completed."); + _mockHandler.Verify(s => s.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); + } - [TestMethod] - public void StartTestRunShouldCatchExceptionAndHandleRawMessageOfTestMessage() - { - var parallelExecutionManager = this.SetupExecutionManager(this.proxyManagerFunc, 2); - this.createdMockManagers[1].Reset(); - this.createdMockManagers[1].Setup(em => em.StartTestRun(It.IsAny(), It.IsAny())) - .Throws(); + [TestMethod] + public void StartTestRunShouldCatchExceptionAndHandleRawMessageOfTestMessage() + { + var parallelExecutionManager = SetupExecutionManager(_proxyManagerFunc, 2); + _createdMockManagers[1].Reset(); + _createdMockManagers[1].Setup(em => em.StartTestRun(It.IsAny(), It.IsAny())) + .Throws(); - Task.Run(() => - { - parallelExecutionManager.StartTestRun(this.testRunCriteriaWithSources, this.mockHandler.Object); - }); + Task.Run(() => parallelExecutionManager.StartTestRun(_testRunCriteriaWithSources, _mockHandler.Object)); - Assert.IsTrue(this.executionCompleted.Wait(taskTimeout), "Test run not completed."); - mockHandler.Verify(s => s.HandleRawMessage(It.Is(str => str.Contains(MessageType.TestMessage)))); - } + Assert.IsTrue(_executionCompleted.Wait(TaskTimeout), "Test run not completed."); + _mockHandler.Verify(s => s.HandleRawMessage(It.Is(str => str.Contains(MessageType.TestMessage)))); + } - [TestMethod] - public void StartTestRunShouldAggregateRunData() + [TestMethod] + public void StartTestRunShouldAggregateRunData() + { + var parallelExecutionManager = new ParallelProxyExecutionManager(_mockRequestData.Object, _proxyManagerFunc, 2); + var syncObject = new object(); + + foreach (var manager in _createdMockManagers) { - var parallelExecutionManager = new ParallelProxyExecutionManager(this.mockRequestData.Object, this.proxyManagerFunc, 2); - var syncObject = new object(); + manager.Setup(m => m.StartTestRun(It.IsAny(), It.IsAny())). + Callback( + (criteria, handler) => + { + lock (syncObject) + { + _processedSources.AddRange(criteria.Sources); + } - foreach (var manager in createdMockManagers) - { - manager.Setup(m => m.StartTestRun(It.IsAny(), It.IsAny())). - Callback( - (criteria, handler) => + Task.Delay(100).Wait(); + var stats = new Dictionary { - lock (syncObject) - { - this.processedSources.AddRange(criteria.Sources); - } - - Task.Delay(100).Wait(); - var stats = new Dictionary(); - stats.Add(TestOutcome.Passed, 3); - stats.Add(TestOutcome.Failed, 2); - var runAttachments = new Collection(); - runAttachments.Add(new AttachmentSet(new Uri("hello://x/"), "Hello")); - var executorUris = new List() { "hello1" }; - bool isCanceled = false; - bool isAborted = false; - TimeSpan timespan = TimeSpan.FromMilliseconds(100); - - if (string.Equals(criteria.Sources?.FirstOrDefault(), "2.dll")) - { - isCanceled = true; - isAborted = true; - timespan = TimeSpan.FromMilliseconds(200); - } - - var completeArgs = new TestRunCompleteEventArgs(new - TestRunStatistics(5, stats), isCanceled, isAborted, null, runAttachments, new Collection(), timespan); - handler.HandleTestRunComplete(completeArgs, null, runAttachments, executorUris); - }); - } + { TestOutcome.Passed, 3 }, + { TestOutcome.Failed, 2 } + }; + var runAttachments = new Collection + { + new AttachmentSet(new Uri("hello://x/"), "Hello") + }; + var executorUris = new List() { "hello1" }; + bool isCanceled = false; + bool isAborted = false; + TimeSpan timespan = TimeSpan.FromMilliseconds(100); + + if (string.Equals(criteria.Sources?.FirstOrDefault(), "2.dll")) + { + isCanceled = true; + isAborted = true; + timespan = TimeSpan.FromMilliseconds(200); + } - Exception assertException = null; - this.mockHandler.Setup(m => m.HandleTestRunComplete( - It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>())).Callback - , ICollection>( + var completeArgs = new TestRunCompleteEventArgs(new + TestRunStatistics(5, stats), isCanceled, isAborted, null, runAttachments, new Collection(), timespan); + handler.HandleTestRunComplete(completeArgs, null, runAttachments, executorUris); + }); + } + + Exception assertException = null; + _mockHandler.Setup(m => m.HandleTestRunComplete( + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>())).Callback + , ICollection>( (completeArgs, runChangedArgs, runAttachments, executorUris) => { try @@ -401,175 +390,171 @@ public void StartTestRunShouldAggregateRunData() } finally { - this.executionCompleted.Set(); + _executionCompleted.Set(); } }); - Task.Run(() => - { - parallelExecutionManager.StartTestRun(testRunCriteriaWithSources, this.mockHandler.Object); - }); + Task.Run(() => parallelExecutionManager.StartTestRun(_testRunCriteriaWithSources, _mockHandler.Object)); - Assert.IsTrue(this.executionCompleted.Wait(taskTimeout), "Test run not completed."); + Assert.IsTrue(_executionCompleted.Wait(TaskTimeout), "Test run not completed."); - Assert.IsNull(assertException, assertException?.ToString()); - Assert.AreEqual(sources.Count, this.processedSources.Count, "All Sources must be processed."); - AssertMissingAndDuplicateSources(this.processedSources); - } + Assert.IsNull(assertException, assertException?.ToString()); + Assert.AreEqual(_sources.Count, _processedSources.Count, "All Sources must be processed."); + AssertMissingAndDuplicateSources(_processedSources); + } + + private ParallelProxyExecutionManager SetupExecutionManager(Func proxyManagerFunc, int parallelLevel) + { + return SetupExecutionManager(proxyManagerFunc, parallelLevel, false); + } - private ParallelProxyExecutionManager SetupExecutionManager(Func proxyManagerFunc, int parallelLevel) + private ParallelProxyExecutionManager SetupExecutionManager(Func proxyManagerFunc, int parallelLevel, bool setupTestCases) + { + var parallelExecutionManager = new ParallelProxyExecutionManager(_mockRequestData.Object, proxyManagerFunc, parallelLevel); + + if (setupTestCases) { - return this.SetupExecutionManager(proxyManagerFunc, parallelLevel, false); + SetupMockManagersForTestCase(_processedTestCases, _testRunCriteriaWithTests); } - - private ParallelProxyExecutionManager SetupExecutionManager(Func proxyManagerFunc, int parallelLevel, bool setupTestCases) + else { - var parallelExecutionManager = new ParallelProxyExecutionManager(this.mockRequestData.Object, proxyManagerFunc, parallelLevel); + SetupMockManagers(_processedSources); + } - if (setupTestCases) - { - SetupMockManagersForTestCase(this.processedTestCases, this.testRunCriteriaWithTests); - } - else - { - this.SetupMockManagers(this.processedSources); - } + SetupHandleTestRunComplete(_executionCompleted); + return parallelExecutionManager; + } - this.SetupHandleTestRunComplete(this.executionCompleted); - return parallelExecutionManager; - } + private void SetupHandleTestRunComplete(ManualResetEventSlim completeEvent) + { + _mockHandler.Setup(mh => mh.HandleTestRunComplete(It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>())) + .Callback, ICollection>( + (testRunCompleteArgs, testRunChangedEventArgs, attachmentSets, executorUris) => completeEvent.Set()); + } - private void SetupHandleTestRunComplete(ManualResetEventSlim completeEvent) + private void AssertMissingAndDuplicateSources(List processedSources) + { + foreach (var source in _sources) { - this.mockHandler.Setup(mh => mh.HandleTestRunComplete(It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>())) - .Callback, ICollection>( - (testRunCompleteArgs, testRunChangedEventArgs, attachmentSets, executorUris) => { completeEvent.Set(); }); - } + var matchFound = false; - private void AssertMissingAndDuplicateSources(List processedSources) - { - foreach (var source in this.sources) + foreach (var processedSrc in processedSources) { - var matchFound = false; - - foreach (var processedSrc in processedSources) + if (processedSrc.Equals(source)) { - if (processedSrc.Equals(source)) + if (matchFound) { - if (matchFound) - { - Assert.Fail("Concurrreny issue detected: Source['{0}'] got processed twice", processedSrc); - } - - matchFound = true; + Assert.Fail("Concurrreny issue detected: Source['{0}'] got processed twice", processedSrc); } - } - Assert.IsTrue(matchFound, "Concurrency issue detected: Source['{0}'] did NOT get processed at all", source); + matchFound = true; + } } - } - private static TestRunCompleteEventArgs CreateTestRunCompleteArgs(bool isCanceled = false, bool isAborted = false) - { - return new TestRunCompleteEventArgs( - new TestRunStatistics(new Dictionary()), - isCanceled, - isAborted, - null, - null, - null, - TimeSpan.FromMilliseconds(1)); + Assert.IsTrue(matchFound, "Concurrency issue detected: Source['{0}'] did NOT get processed at all", source); } + } + + private static TestRunCompleteEventArgs CreateTestRunCompleteArgs(bool isCanceled = false, bool isAborted = false) + { + return new TestRunCompleteEventArgs( + new TestRunStatistics(new Dictionary()), + isCanceled, + isAborted, + null, + null, + null, + TimeSpan.FromMilliseconds(1)); + } - private static void AssertMissingAndDuplicateTestCases(List tests, List processedTestCases) + private static void AssertMissingAndDuplicateTestCases(List tests, List processedTestCases) + { + foreach (var test in tests) { - foreach (var test in tests) - { - bool matchFound = false; + bool matchFound = false; - foreach (var processedTest in processedTestCases) + foreach (var processedTest in processedTestCases) + { + if (processedTest.FullyQualifiedName.Equals(test.FullyQualifiedName)) { - if (processedTest.FullyQualifiedName.Equals(test.FullyQualifiedName)) - { - if (matchFound) - Assert.Fail("Concurrency issue detected: Test['{0}'] got processed twice", test.FullyQualifiedName); - matchFound = true; - } + if (matchFound) + Assert.Fail("Concurrency issue detected: Test['{0}'] got processed twice", test.FullyQualifiedName); + matchFound = true; } - - Assert.IsTrue(matchFound, "Concurrency issue detected: Test['{0}'] did NOT get processed at all", - test.FullyQualifiedName); } + + Assert.IsTrue(matchFound, "Concurrency issue detected: Test['{0}'] did NOT get processed at all", + test.FullyQualifiedName); } + } - private void SetupMockManagersForTestCase(List processedTestCases, TestRunCriteria testRunCriteria) + private void SetupMockManagersForTestCase(List processedTestCases, TestRunCriteria testRunCriteria) + { + var syncObject = new object(); + foreach (var manager in _createdMockManagers) { - var syncObject = new object(); - foreach (var manager in createdMockManagers) - { - manager.Setup(m => m.StartTestRun(It.IsAny(), It.IsAny())). - Callback( - (criteria, handler) => + manager.Setup(m => m.StartTestRun(It.IsAny(), It.IsAny())). + Callback( + (criteria, handler) => + { + lock (syncObject) { - lock (syncObject) - { - processedTestCases.AddRange(criteria.Tests); - } + processedTestCases.AddRange(criteria.Tests); + } - Task.Delay(100).Wait(); + Task.Delay(100).Wait(); - // Duplicated testRunCriteria should match the actual one. - Assert.AreEqual(testRunCriteria, criteria, "Mismatch in testRunCriteria"); - handler.HandleTestRunComplete(CreateTestRunCompleteArgs(), null, null, null); - }); - } + // Duplicated testRunCriteria should match the actual one. + Assert.AreEqual(testRunCriteria, criteria, "Mismatch in testRunCriteria"); + handler.HandleTestRunComplete(CreateTestRunCompleteArgs(), null, null, null); + }); } + } - private static List CreateTestCases() - { - TestCase tc1 = new TestCase("dll1.class1.test1", new Uri("hello://x/"), "1.dll"); - TestCase tc21 = new TestCase("dll2.class21.test21", new Uri("hello://x/"), "2.dll"); - TestCase tc22 = new TestCase("dll2.class21.test22", new Uri("hello://x/"), "2.dll"); - TestCase tc31 = new TestCase("dll3.class31.test31", new Uri("hello://x/"), "3.dll"); - TestCase tc32 = new TestCase("dll3.class31.test32", new Uri("hello://x/"), "3.dll"); - - var tests = new List() { tc1, tc21, tc22, tc31, tc32 }; - return tests; - } + private static List CreateTestCases() + { + TestCase tc1 = new("dll1.class1.test1", new Uri("hello://x/"), "1.dll"); + TestCase tc21 = new("dll2.class21.test21", new Uri("hello://x/"), "2.dll"); + TestCase tc22 = new("dll2.class21.test22", new Uri("hello://x/"), "2.dll"); + TestCase tc31 = new("dll3.class31.test31", new Uri("hello://x/"), "3.dll"); + TestCase tc32 = new("dll3.class31.test32", new Uri("hello://x/"), "3.dll"); + + var tests = new List() { tc1, tc21, tc22, tc31, tc32 }; + return tests; + } - private void SetupMockManagers(List processedSources, bool isCanceled = false, bool isAborted = false) + private void SetupMockManagers(List processedSources, bool isCanceled = false, bool isAborted = false) + { + var syncObject = new object(); + foreach (var manager in _createdMockManagers) { - var syncObject = new object(); - foreach (var manager in createdMockManagers) - { - manager.Setup(m => m.StartTestRun(It.IsAny(), It.IsAny())). - Callback( - (criteria, handler) => + manager.Setup(m => m.StartTestRun(It.IsAny(), It.IsAny())). + Callback( + (criteria, handler) => + { + lock (syncObject) { - lock (syncObject) - { - processedSources.AddRange(criteria.Sources); - } - Task.Delay(100).Wait(); - - // Duplicated testRunCriteria should match the actual one. - Assert.AreEqual(testRunCriteriaWithSources, criteria, "Mismatch in testRunCriteria"); - handler.HandleTestRunComplete(CreateTestRunCompleteArgs(isCanceled, isAborted), null, null, null); - }); - } + processedSources.AddRange(criteria.Sources); + } + Task.Delay(100).Wait(); + + // Duplicated testRunCriteria should match the actual one. + Assert.AreEqual(_testRunCriteriaWithSources, criteria, "Mismatch in testRunCriteria"); + handler.HandleTestRunComplete(CreateTestRunCompleteArgs(isCanceled, isAborted), null, null, null); + }); } + } - private void InvokeAndVerifyInitialize(int concurrentManagersCount, bool skipDefaultAdapters = false) - { - var parallelExecutionManager = new ParallelProxyExecutionManager(this.mockRequestData.Object, proxyManagerFunc, concurrentManagersCount); + private void InvokeAndVerifyInitialize(int concurrentManagersCount, bool skipDefaultAdapters = false) + { + var parallelExecutionManager = new ParallelProxyExecutionManager(_mockRequestData.Object, _proxyManagerFunc, concurrentManagersCount); - parallelExecutionManager.Initialize(skipDefaultAdapters); + parallelExecutionManager.Initialize(skipDefaultAdapters); - Assert.AreEqual(concurrentManagersCount, createdMockManagers.Count, $"Number of Concurrent Managers created should be {concurrentManagersCount}"); - createdMockManagers.ForEach(em => em.Verify(m => m.Initialize(skipDefaultAdapters), Times.Once)); - } + Assert.AreEqual(concurrentManagersCount, _createdMockManagers.Count, $"Number of Concurrent Managers created should be {concurrentManagersCount}"); + _createdMockManagers.ForEach(em => em.Verify(m => m.Initialize(skipDefaultAdapters), Times.Once)); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelRunDataAggregatorTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelRunDataAggregatorTests.cs index 348005c78b..820b619418 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelRunDataAggregatorTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelRunDataAggregatorTests.cs @@ -1,438 +1,457 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Client.Parallel +namespace TestPlatform.CrossPlatEngine.UnitTests.Client.Parallel; + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class ParallelRunDataAggregatorTests { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class ParallelRunDataAggregatorTests + [TestMethod] + public void ParallelRunDataAggregatorConstructorShouldInitializeAggregatorVars() { - [TestMethod] - public void ParallelRunDataAggregatorConstructorShouldInitializeAggregatorVars() - { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - Assert.AreEqual(aggregator.ElapsedTime, TimeSpan.Zero, "Timespan must be initialized to zero."); + Assert.AreEqual(aggregator.ElapsedTime, TimeSpan.Zero, "Timespan must be initialized to zero."); - Assert.IsNotNull(aggregator.Exceptions, "Exceptions list must not be null"); - Assert.IsNotNull(aggregator.ExecutorUris, "ExecutorUris list must not be null"); - Assert.IsNotNull(aggregator.RunCompleteArgsAttachments, "RunCompleteArgsAttachments list must not be null"); - Assert.IsNotNull(aggregator.RunContextAttachments, "RunContextAttachments list must not be null"); + Assert.IsNotNull(aggregator.Exceptions, "Exceptions list must not be null"); + Assert.IsNotNull(aggregator.ExecutorUris, "ExecutorUris list must not be null"); + Assert.IsNotNull(aggregator.RunCompleteArgsAttachments, "RunCompleteArgsAttachments list must not be null"); + Assert.IsNotNull(aggregator.RunContextAttachments, "RunContextAttachments list must not be null"); - Assert.AreEqual(0, aggregator.Exceptions.Count, "Exceptions List must be initialized as empty list."); - Assert.AreEqual(0, aggregator.ExecutorUris.Count, "Exceptions List must be initialized as empty list."); - Assert.AreEqual(0, aggregator.RunCompleteArgsAttachments.Count, "RunCompleteArgsAttachments List must be initialized as empty list."); - Assert.AreEqual(0, aggregator.RunContextAttachments.Count, "RunContextAttachments List must be initialized as empty list"); + Assert.AreEqual(0, aggregator.Exceptions.Count, "Exceptions List must be initialized as empty list."); + Assert.AreEqual(0, aggregator.ExecutorUris.Count, "Exceptions List must be initialized as empty list."); + Assert.AreEqual(0, aggregator.RunCompleteArgsAttachments.Count, "RunCompleteArgsAttachments List must be initialized as empty list."); + Assert.AreEqual(0, aggregator.RunContextAttachments.Count, "RunContextAttachments List must be initialized as empty list"); - Assert.IsFalse(aggregator.IsAborted, "Aborted must be false by default"); + Assert.IsFalse(aggregator.IsAborted, "Aborted must be false by default"); - Assert.IsFalse(aggregator.IsCanceled, "Canceled must be false by default"); - } + Assert.IsFalse(aggregator.IsCanceled, "Canceled must be false by default"); + } + + [TestMethod] + public void AggregateShouldAggregateRunCompleteAttachmentsCorrectly() + { + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - [TestMethod] - public void AggregateShouldAggregateRunCompleteAttachmentsCorrectly() + var attachmentSet1 = new Collection { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); + new AttachmentSet(new Uri("x://hello1"), "hello1") + }; - var attachmentSet1 = new Collection(); - attachmentSet1.Add(new AttachmentSet(new Uri("x://hello1"), "hello1")); + aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, null, attachmentSet1, null); - aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, null, attachmentSet1, null); + Assert.AreEqual(1, aggregator.RunCompleteArgsAttachments.Count, "RunCompleteArgsAttachments List must have data."); - Assert.AreEqual(1, aggregator.RunCompleteArgsAttachments.Count, "RunCompleteArgsAttachments List must have data."); + var attachmentSet2 = new Collection + { + new AttachmentSet(new Uri("x://hello2"), "hello2") + }; - var attachmentSet2 = new Collection(); - attachmentSet2.Add(new AttachmentSet(new Uri("x://hello2"), "hello2")); + aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, null, attachmentSet2, null); - aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, null, attachmentSet2, null); + Assert.AreEqual(2, aggregator.RunCompleteArgsAttachments.Count, "RunCompleteArgsAttachments List must have aggregated data."); + } - Assert.AreEqual(2, aggregator.RunCompleteArgsAttachments.Count, "RunCompleteArgsAttachments List must have aggregated data."); - } + [TestMethod] + public void AggregateShouldAggregateRunContextAttachmentsCorrectly() + { + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - [TestMethod] - public void AggregateShouldAggregateRunContextAttachmentsCorrectly() + var attachmentSet1 = new Collection { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); + new AttachmentSet(new Uri("x://hello1"), "hello1") + }; - var attachmentSet1 = new Collection(); - attachmentSet1.Add(new AttachmentSet(new Uri("x://hello1"), "hello1")); + aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, attachmentSet1, null, null); - aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, attachmentSet1, null, null); + Assert.AreEqual(1, aggregator.RunContextAttachments.Count, "RunContextAttachments List must have data."); - Assert.AreEqual(1, aggregator.RunContextAttachments.Count, "RunContextAttachments List must have data."); + var attachmentSet2 = new Collection + { + new AttachmentSet(new Uri("x://hello2"), "hello2") + }; - var attachmentSet2 = new Collection(); - attachmentSet2.Add(new AttachmentSet(new Uri("x://hello2"), "hello2")); + aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, attachmentSet2, null, null); - aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, attachmentSet2, null, null); + Assert.AreEqual(2, aggregator.RunContextAttachments.Count, "RunContextAttachments List must have aggregated data."); + } - Assert.AreEqual(2, aggregator.RunContextAttachments.Count, "RunContextAttachments List must have aggregated data."); - } + [TestMethod] + public void AggregateShouldAggregateInvokedCollectorsCorrectly() + { + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - [TestMethod] - public void AggregateShouldAggregateInvokedCollectorsCorrectly() + var invokedDataCollectors = new Collection() { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - - var invokedDataCollectors = new Collection() - { - new InvokedDataCollector(new Uri("datacollector://sample"),"sample", typeof(string).AssemblyQualifiedName,typeof(string).Assembly.Location,false) - }; - aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, null, null, invokedDataCollectors); - Assert.AreEqual(1, aggregator.InvokedDataCollectors.Count, "InvokedDataCollectors List must have data."); - - var invokedDataCollectors2 = new Collection() - { - new InvokedDataCollector(new Uri("datacollector://sample2"),"sample2", typeof(int).AssemblyQualifiedName,typeof(int).Assembly.Location,false) - }; - aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, null, null, invokedDataCollectors2); - Assert.AreEqual(2, aggregator.InvokedDataCollectors.Count, "InvokedDataCollectors List must have aggregated data."); - - aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, null, null, invokedDataCollectors); - aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, null, null, invokedDataCollectors2); - - Assert.AreEqual(2, aggregator.InvokedDataCollectors.Count, "InvokedDataCollectors List must have aggregated data."); - Assert.AreEqual(invokedDataCollectors[0].AssemblyQualifiedName, aggregator.InvokedDataCollectors[0].AssemblyQualifiedName); - Assert.AreEqual(invokedDataCollectors[0].FilePath, aggregator.InvokedDataCollectors[0].FilePath); - Assert.AreEqual(invokedDataCollectors[0].Uri, aggregator.InvokedDataCollectors[0].Uri); - Assert.AreEqual(invokedDataCollectors2[0].AssemblyQualifiedName, aggregator.InvokedDataCollectors[1].AssemblyQualifiedName); - Assert.AreEqual(invokedDataCollectors2[0].FilePath, aggregator.InvokedDataCollectors[1].FilePath); - Assert.AreEqual(invokedDataCollectors2[0].Uri, aggregator.InvokedDataCollectors[1].Uri); - } - - [TestMethod] - public void AggregateShouldAggregateAbortedAndCanceledCorrectly() + new InvokedDataCollector(new Uri("datacollector://sample"),"sample", typeof(string).AssemblyQualifiedName,typeof(string).Assembly.Location,false) + }; + aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, null, null, invokedDataCollectors); + Assert.AreEqual(1, aggregator.InvokedDataCollectors.Count, "InvokedDataCollectors List must have data."); + + var invokedDataCollectors2 = new Collection() { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); + new InvokedDataCollector(new Uri("datacollector://sample2"),"sample2", typeof(int).AssemblyQualifiedName,typeof(int).Assembly.Location,false) + }; + aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, null, null, invokedDataCollectors2); + Assert.AreEqual(2, aggregator.InvokedDataCollectors.Count, "InvokedDataCollectors List must have aggregated data."); + + aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, null, null, invokedDataCollectors); + aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, null, null, invokedDataCollectors2); + + Assert.AreEqual(2, aggregator.InvokedDataCollectors.Count, "InvokedDataCollectors List must have aggregated data."); + Assert.AreEqual(invokedDataCollectors[0].AssemblyQualifiedName, aggregator.InvokedDataCollectors[0].AssemblyQualifiedName); + Assert.AreEqual(invokedDataCollectors[0].FilePath, aggregator.InvokedDataCollectors[0].FilePath); + Assert.AreEqual(invokedDataCollectors[0].Uri, aggregator.InvokedDataCollectors[0].Uri); + Assert.AreEqual(invokedDataCollectors2[0].AssemblyQualifiedName, aggregator.InvokedDataCollectors[1].AssemblyQualifiedName); + Assert.AreEqual(invokedDataCollectors2[0].FilePath, aggregator.InvokedDataCollectors[1].FilePath); + Assert.AreEqual(invokedDataCollectors2[0].Uri, aggregator.InvokedDataCollectors[1].Uri); + } - aggregator.Aggregate(null, null, null, TimeSpan.Zero, isAborted: false, isCanceled: false, runContextAttachments: null, - runCompleteArgsAttachments: null, invokedDataCollectors: null); + [TestMethod] + public void AggregateShouldAggregateAbortedAndCanceledCorrectly() + { + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - Assert.IsFalse(aggregator.IsAborted, "Aborted must be false"); + aggregator.Aggregate(null, null, null, TimeSpan.Zero, isAborted: false, isCanceled: false, runContextAttachments: null, + runCompleteArgsAttachments: null, invokedDataCollectors: null); - Assert.IsFalse(aggregator.IsCanceled, "Canceled must be false"); + Assert.IsFalse(aggregator.IsAborted, "Aborted must be false"); - aggregator.Aggregate(null, null, null, TimeSpan.Zero, isAborted: true, isCanceled: false, runContextAttachments: null, - runCompleteArgsAttachments: null, invokedDataCollectors: null); + Assert.IsFalse(aggregator.IsCanceled, "Canceled must be false"); - Assert.IsTrue(aggregator.IsAborted, "Aborted must be true"); + aggregator.Aggregate(null, null, null, TimeSpan.Zero, isAborted: true, isCanceled: false, runContextAttachments: null, + runCompleteArgsAttachments: null, invokedDataCollectors: null); - Assert.IsFalse(aggregator.IsCanceled, "Canceled must still be false"); + Assert.IsTrue(aggregator.IsAborted, "Aborted must be true"); - aggregator.Aggregate(null, null, null, TimeSpan.Zero, isAborted: false, isCanceled: true, runContextAttachments: null, - runCompleteArgsAttachments: null, invokedDataCollectors: null); + Assert.IsFalse(aggregator.IsCanceled, "Canceled must still be false"); - Assert.IsTrue(aggregator.IsAborted, "Aborted must continue be true"); + aggregator.Aggregate(null, null, null, TimeSpan.Zero, isAborted: false, isCanceled: true, runContextAttachments: null, + runCompleteArgsAttachments: null, invokedDataCollectors: null); - Assert.IsTrue(aggregator.IsCanceled, "Canceled must be true"); + Assert.IsTrue(aggregator.IsAborted, "Aborted must continue be true"); - aggregator.Aggregate(null, null, null, TimeSpan.Zero, isAborted: false, isCanceled: false, runContextAttachments: null, - runCompleteArgsAttachments: null, invokedDataCollectors: null); + Assert.IsTrue(aggregator.IsCanceled, "Canceled must be true"); - Assert.IsTrue(aggregator.IsAborted, "Aborted must continue be true"); + aggregator.Aggregate(null, null, null, TimeSpan.Zero, isAborted: false, isCanceled: false, runContextAttachments: null, + runCompleteArgsAttachments: null, invokedDataCollectors: null); - Assert.IsTrue(aggregator.IsCanceled, "Canceled must continue be true"); + Assert.IsTrue(aggregator.IsAborted, "Aborted must continue be true"); - } + Assert.IsTrue(aggregator.IsCanceled, "Canceled must continue be true"); - [TestMethod] - public void AggregateShouldAggregateTimeSpanCorrectly() - { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); + } - aggregator.Aggregate(null, null, null, TimeSpan.Zero, isAborted: false, isCanceled: false, runContextAttachments: null, - runCompleteArgsAttachments: null, invokedDataCollectors: null); + [TestMethod] + public void AggregateShouldAggregateTimeSpanCorrectly() + { + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - Assert.AreEqual(TimeSpan.Zero, aggregator.ElapsedTime, "Timespan must be zero"); + aggregator.Aggregate(null, null, null, TimeSpan.Zero, isAborted: false, isCanceled: false, runContextAttachments: null, + runCompleteArgsAttachments: null, invokedDataCollectors: null); - aggregator.Aggregate(null, null, null, TimeSpan.FromMilliseconds(100), isAborted: false, isCanceled: false, runContextAttachments: null, - runCompleteArgsAttachments: null, invokedDataCollectors: null); + Assert.AreEqual(TimeSpan.Zero, aggregator.ElapsedTime, "Timespan must be zero"); - Assert.AreEqual(TimeSpan.FromMilliseconds(100), aggregator.ElapsedTime, "Timespan must be 100ms"); + aggregator.Aggregate(null, null, null, TimeSpan.FromMilliseconds(100), isAborted: false, isCanceled: false, runContextAttachments: null, + runCompleteArgsAttachments: null, invokedDataCollectors: null); + Assert.AreEqual(TimeSpan.FromMilliseconds(100), aggregator.ElapsedTime, "Timespan must be 100ms"); - aggregator.Aggregate(null, null, null, TimeSpan.FromMilliseconds(200), isAborted: false, isCanceled: false, runContextAttachments: null, - runCompleteArgsAttachments: null, invokedDataCollectors: null); - Assert.AreEqual(TimeSpan.FromMilliseconds(200), aggregator.ElapsedTime, "Timespan should be Max of all 200ms"); + aggregator.Aggregate(null, null, null, TimeSpan.FromMilliseconds(200), isAborted: false, isCanceled: false, runContextAttachments: null, + runCompleteArgsAttachments: null, invokedDataCollectors: null); - aggregator.Aggregate(null, null, null, TimeSpan.FromMilliseconds(150), isAborted: false, isCanceled: false, runContextAttachments: null, - runCompleteArgsAttachments: null, invokedDataCollectors: null); + Assert.AreEqual(TimeSpan.FromMilliseconds(200), aggregator.ElapsedTime, "Timespan should be Max of all 200ms"); - Assert.AreEqual(TimeSpan.FromMilliseconds(200), aggregator.ElapsedTime, "Timespan should be Max of all i.e. 200ms"); - } + aggregator.Aggregate(null, null, null, TimeSpan.FromMilliseconds(150), isAborted: false, isCanceled: false, runContextAttachments: null, + runCompleteArgsAttachments: null, invokedDataCollectors: null); - [TestMethod] - public void AggregateShouldAggregateExceptionsCorrectly() - { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); + Assert.AreEqual(TimeSpan.FromMilliseconds(200), aggregator.ElapsedTime, "Timespan should be Max of all i.e. 200ms"); + } - aggregator.Aggregate(null, null, exception: null, elapsedTime: TimeSpan.Zero, isAborted: false, isCanceled: false, runContextAttachments: null, - runCompleteArgsAttachments: null, invokedDataCollectors: null); + [TestMethod] + public void AggregateShouldAggregateExceptionsCorrectly() + { + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - Assert.IsNull(aggregator.GetAggregatedException(), "Aggregated exception must be null"); + aggregator.Aggregate(null, null, exception: null, elapsedTime: TimeSpan.Zero, isAborted: false, isCanceled: false, runContextAttachments: null, + runCompleteArgsAttachments: null, invokedDataCollectors: null); - var exception1 = new NotImplementedException(); - aggregator.Aggregate(null, null, exception: exception1, elapsedTime: TimeSpan.Zero, isAborted: false, isCanceled: false, runContextAttachments: null, - runCompleteArgsAttachments: null, invokedDataCollectors: null); + Assert.IsNull(aggregator.GetAggregatedException(), "Aggregated exception must be null"); - var aggregatedException = aggregator.GetAggregatedException() as AggregateException; - Assert.IsNotNull(aggregatedException, "Aggregated exception must NOT be null"); - Assert.IsNotNull(aggregatedException.InnerExceptions, "Inner exception list must NOT be null"); - Assert.AreEqual(1, aggregatedException.InnerExceptions.Count, "Inner exception list must have one element"); - Assert.AreEqual(exception1, aggregatedException.InnerExceptions[0], "Inner exception must be the one set."); + var exception1 = new NotImplementedException(); + aggregator.Aggregate(null, null, exception: exception1, elapsedTime: TimeSpan.Zero, isAborted: false, isCanceled: false, runContextAttachments: null, + runCompleteArgsAttachments: null, invokedDataCollectors: null); - var exception2 = new NotSupportedException(); - aggregator.Aggregate(null, null, exception: exception2, elapsedTime: TimeSpan.Zero, isAborted: false, isCanceled: false, runContextAttachments: null, - runCompleteArgsAttachments: null, invokedDataCollectors: null); + var aggregatedException = aggregator.GetAggregatedException() as AggregateException; + Assert.IsNotNull(aggregatedException, "Aggregated exception must NOT be null"); + Assert.IsNotNull(aggregatedException.InnerExceptions, "Inner exception list must NOT be null"); + Assert.AreEqual(1, aggregatedException.InnerExceptions.Count, "Inner exception list must have one element"); + Assert.AreEqual(exception1, aggregatedException.InnerExceptions[0], "Inner exception must be the one set."); - aggregatedException = aggregator.GetAggregatedException() as AggregateException; - Assert.IsNotNull(aggregatedException, "Aggregated exception must NOT be null"); - Assert.IsNotNull(aggregatedException.InnerExceptions, "Inner exception list must NOT be null"); - Assert.AreEqual(2, aggregatedException.InnerExceptions.Count, "Inner exception list must have one element"); - Assert.AreEqual(exception2, aggregatedException.InnerExceptions[1], "Inner exception must be the one set."); - } + var exception2 = new NotSupportedException(); + aggregator.Aggregate(null, null, exception: exception2, elapsedTime: TimeSpan.Zero, isAborted: false, isCanceled: false, runContextAttachments: null, + runCompleteArgsAttachments: null, invokedDataCollectors: null); - [TestMethod] - public void AggregateShouldAggregateExecutorUrisCorrectly() - { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); + aggregatedException = aggregator.GetAggregatedException() as AggregateException; + Assert.IsNotNull(aggregatedException, "Aggregated exception must NOT be null"); + Assert.IsNotNull(aggregatedException.InnerExceptions, "Inner exception list must NOT be null"); + Assert.AreEqual(2, aggregatedException.InnerExceptions.Count, "Inner exception list must have one element"); + Assert.AreEqual(exception2, aggregatedException.InnerExceptions[1], "Inner exception must be the one set."); + } - aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, null, null, null); + [TestMethod] + public void AggregateShouldAggregateExecutorUrisCorrectly() + { + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - Assert.AreEqual(0, aggregator.ExecutorUris.Count, "ExecutorUris List must not have data."); + aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, null, null, null); - var uri1 = "x://hello1"; - aggregator.Aggregate(null, new List() { uri1 }, null, TimeSpan.Zero, false, false, null, null, null); + Assert.AreEqual(0, aggregator.ExecutorUris.Count, "ExecutorUris List must not have data."); - Assert.AreEqual(1, aggregator.ExecutorUris.Count, "ExecutorUris List must have data."); - Assert.IsTrue(aggregator.ExecutorUris.Contains(uri1), "ExecutorUris List must have correct data."); + var uri1 = "x://hello1"; + aggregator.Aggregate(null, new List() { uri1 }, null, TimeSpan.Zero, false, false, null, null, null); - var uri2 = "x://hello2"; - aggregator.Aggregate(null, new List() { uri2 }, null, TimeSpan.Zero, false, false, null, null, null); + Assert.AreEqual(1, aggregator.ExecutorUris.Count, "ExecutorUris List must have data."); + Assert.IsTrue(aggregator.ExecutorUris.Contains(uri1), "ExecutorUris List must have correct data."); - Assert.AreEqual(2, aggregator.ExecutorUris.Count, "ExecutorUris List must have aggregated data."); - Assert.IsTrue(aggregator.ExecutorUris.Contains(uri2), "ExecutorUris List must have correct data."); - } + var uri2 = "x://hello2"; + aggregator.Aggregate(null, new List() { uri2 }, null, TimeSpan.Zero, false, false, null, null, null); - [TestMethod] - public void AggregateShouldAggregateRunStatsCorrectly() - { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - - aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, null, null, null); - - var runStats = aggregator.GetAggregatedRunStats(); - Assert.AreEqual(0, runStats.ExecutedTests, "RunStats must not have data."); - - var stats1 = new Dictionary(); - stats1.Add(TestOutcome.Passed, 2); - stats1.Add(TestOutcome.Failed, 3); - stats1.Add(TestOutcome.Skipped, 1); - stats1.Add(TestOutcome.NotFound, 4); - stats1.Add(TestOutcome.None, 2); - - aggregator.Aggregate(new TestRunStatistics(12, stats1), null, null, TimeSpan.Zero, false, false, null, null, null); - - runStats = aggregator.GetAggregatedRunStats(); - Assert.AreEqual(12, runStats.ExecutedTests, "RunStats must have aggregated data."); - Assert.AreEqual(2, runStats.Stats[TestOutcome.Passed], "RunStats must have aggregated data."); - Assert.AreEqual(3, runStats.Stats[TestOutcome.Failed], "RunStats must have aggregated data."); - Assert.AreEqual(1, runStats.Stats[TestOutcome.Skipped], "RunStats must have aggregated data."); - Assert.AreEqual(4, runStats.Stats[TestOutcome.NotFound], "RunStats must have aggregated data."); - Assert.AreEqual(2, runStats.Stats[TestOutcome.None], "RunStats must have aggregated data."); - - - var stats2 = new Dictionary(); - stats2.Add(TestOutcome.Passed, 3); - stats2.Add(TestOutcome.Failed, 2); - stats2.Add(TestOutcome.Skipped, 2); - stats2.Add(TestOutcome.NotFound, 1); - stats2.Add(TestOutcome.None, 3); - - aggregator.Aggregate(new TestRunStatistics(11, stats2), null, null, TimeSpan.Zero, false, false, null, null, null); - - runStats = aggregator.GetAggregatedRunStats(); - Assert.AreEqual(23, runStats.ExecutedTests, "RunStats must have aggregated data."); - Assert.AreEqual(5, runStats.Stats[TestOutcome.Passed], "RunStats must have aggregated data."); - Assert.AreEqual(5, runStats.Stats[TestOutcome.Failed], "RunStats must have aggregated data."); - Assert.AreEqual(3, runStats.Stats[TestOutcome.Skipped], "RunStats must have aggregated data."); - Assert.AreEqual(5, runStats.Stats[TestOutcome.NotFound], "RunStats must have aggregated data."); - Assert.AreEqual(5, runStats.Stats[TestOutcome.None], "RunStats must have aggregated data."); - } - - [TestMethod] - public void AggregateRunDataMetricsShouldAggregateMetricsCorrectly() - { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); + Assert.AreEqual(2, aggregator.ExecutorUris.Count, "ExecutorUris List must have aggregated data."); + Assert.IsTrue(aggregator.ExecutorUris.Contains(uri2), "ExecutorUris List must have correct data."); + } - aggregator.AggregateRunDataMetrics(null); + [TestMethod] + public void AggregateShouldAggregateRunStatsCorrectly() + { + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - var runMetrics = aggregator.GetAggregatedRunDataMetrics(); - Assert.AreEqual(0, runMetrics.Count); - } + aggregator.Aggregate(null, null, null, TimeSpan.Zero, false, false, null, null, null); - [TestMethod] - public void AggregateRunDataMetricsShouldAddTotalTestsRun() - { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); + var runStats = aggregator.GetAggregatedRunStats(); + Assert.AreEqual(0, runStats.ExecutedTests, "RunStats must not have data."); - var dict = new Dictionary(); - dict.Add(TelemetryDataConstants.TotalTestsRanByAdapter, 2); + var stats1 = new Dictionary + { + { TestOutcome.Passed, 2 }, + { TestOutcome.Failed, 3 }, + { TestOutcome.Skipped, 1 }, + { TestOutcome.NotFound, 4 }, + { TestOutcome.None, 2 } + }; - aggregator.AggregateRunDataMetrics(dict); - aggregator.AggregateRunDataMetrics(dict); + aggregator.Aggregate(new TestRunStatistics(12, stats1), null, null, TimeSpan.Zero, false, false, null, null, null); - var runMetrics = aggregator.GetAggregatedRunDataMetrics(); + runStats = aggregator.GetAggregatedRunStats(); + Assert.AreEqual(12, runStats.ExecutedTests, "RunStats must have aggregated data."); + Assert.AreEqual(2, runStats.Stats[TestOutcome.Passed], "RunStats must have aggregated data."); + Assert.AreEqual(3, runStats.Stats[TestOutcome.Failed], "RunStats must have aggregated data."); + Assert.AreEqual(1, runStats.Stats[TestOutcome.Skipped], "RunStats must have aggregated data."); + Assert.AreEqual(4, runStats.Stats[TestOutcome.NotFound], "RunStats must have aggregated data."); + Assert.AreEqual(2, runStats.Stats[TestOutcome.None], "RunStats must have aggregated data."); - Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.TotalTestsRanByAdapter, out var value)); - Assert.AreEqual(4, Convert.ToInt32(value)); - } - [TestMethod] - public void AggregateRunDataMetricsShouldAddTimeTakenToRunTests() + var stats2 = new Dictionary { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); + { TestOutcome.Passed, 3 }, + { TestOutcome.Failed, 2 }, + { TestOutcome.Skipped, 2 }, + { TestOutcome.NotFound, 1 }, + { TestOutcome.None, 3 } + }; + + aggregator.Aggregate(new TestRunStatistics(11, stats2), null, null, TimeSpan.Zero, false, false, null, null, null); + + runStats = aggregator.GetAggregatedRunStats(); + Assert.AreEqual(23, runStats.ExecutedTests, "RunStats must have aggregated data."); + Assert.AreEqual(5, runStats.Stats[TestOutcome.Passed], "RunStats must have aggregated data."); + Assert.AreEqual(5, runStats.Stats[TestOutcome.Failed], "RunStats must have aggregated data."); + Assert.AreEqual(3, runStats.Stats[TestOutcome.Skipped], "RunStats must have aggregated data."); + Assert.AreEqual(5, runStats.Stats[TestOutcome.NotFound], "RunStats must have aggregated data."); + Assert.AreEqual(5, runStats.Stats[TestOutcome.None], "RunStats must have aggregated data."); + } - var dict = new Dictionary(); - dict.Add(TelemetryDataConstants.TimeTakenToRunTestsByAnAdapter, .02091); + [TestMethod] + public void AggregateRunDataMetricsShouldAggregateMetricsCorrectly() + { + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - aggregator.AggregateRunDataMetrics(dict); - aggregator.AggregateRunDataMetrics(dict); + aggregator.AggregateRunDataMetrics(null); - var runMetrics = aggregator.GetAggregatedRunDataMetrics(); + var runMetrics = aggregator.GetAggregatedRunDataMetrics(); + Assert.AreEqual(0, runMetrics.Count); + } - Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.TimeTakenToRunTestsByAnAdapter, out var value)); - Assert.AreEqual(.04182, value); - } + [TestMethod] + public void AggregateRunDataMetricsShouldAddTotalTestsRun() + { + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - [TestMethod] - public void AggregateRunDataMetricsShouldAddTimeTakenByAllAdapters() + var dict = new Dictionary { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); + { TelemetryDataConstants.TotalTestsRanByAdapter, 2 } + }; - var dict = new Dictionary(); - dict.Add(TelemetryDataConstants.TimeTakenByAllAdaptersInSec, .02091); + aggregator.AggregateRunDataMetrics(dict); + aggregator.AggregateRunDataMetrics(dict); - aggregator.AggregateRunDataMetrics(dict); - aggregator.AggregateRunDataMetrics(dict); + var runMetrics = aggregator.GetAggregatedRunDataMetrics(); - var runMetrics = aggregator.GetAggregatedRunDataMetrics(); + Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.TotalTestsRanByAdapter, out var value)); + Assert.AreEqual(4, Convert.ToInt32(value)); + } - Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.TimeTakenByAllAdaptersInSec, out var value)); - Assert.AreEqual(.04182, value); - } + [TestMethod] + public void AggregateRunDataMetricsShouldAddTimeTakenToRunTests() + { + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - [TestMethod] - public void AggregateRunDataMetricsShouldNotAggregateRunState() + var dict = new Dictionary { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); + { TelemetryDataConstants.TimeTakenToRunTestsByAnAdapter, .02091 } + }; - var dict = new Dictionary(); - dict.Add(TelemetryDataConstants.RunState, "Completed"); + aggregator.AggregateRunDataMetrics(dict); + aggregator.AggregateRunDataMetrics(dict); - aggregator.AggregateRunDataMetrics(dict); - aggregator.AggregateRunDataMetrics(dict); + var runMetrics = aggregator.GetAggregatedRunDataMetrics(); - var runMetrics = aggregator.GetAggregatedRunDataMetrics(); + Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.TimeTakenToRunTestsByAnAdapter, out var value)); + Assert.AreEqual(.04182, value); + } - Assert.IsFalse(runMetrics.TryGetValue(TelemetryDataConstants.RunState, out var value)); - } + [TestMethod] + public void AggregateRunDataMetricsShouldAddTimeTakenByAllAdapters() + { + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - [TestMethod] - public void GetAggregatedRunDataMetricsShouldReturnEmptyIfMetricAggregatorIsEmpty() + var dict = new Dictionary { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); + { TelemetryDataConstants.TimeTakenByAllAdaptersInSec, .02091 } + }; + + aggregator.AggregateRunDataMetrics(dict); + aggregator.AggregateRunDataMetrics(dict); - var dict = new Dictionary(); + var runMetrics = aggregator.GetAggregatedRunDataMetrics(); - aggregator.AggregateRunDataMetrics(dict); - var runMetrics = aggregator.GetAggregatedRunDataMetrics(); + Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.TimeTakenByAllAdaptersInSec, out var value)); + Assert.AreEqual(.04182, value); + } - Assert.AreEqual(0, runMetrics.Count); - } + [TestMethod] + public void AggregateRunDataMetricsShouldNotAggregateRunState() + { + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - [TestMethod] - public void GetAggregatedRunDataMetricsShouldReturnEmptyIfMetricsIsNull() + var dict = new Dictionary { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); + { TelemetryDataConstants.RunState, "Completed" } + }; - var dict = new Dictionary(); + aggregator.AggregateRunDataMetrics(dict); + aggregator.AggregateRunDataMetrics(dict); - aggregator.AggregateRunDataMetrics(null); - var runMetrics = aggregator.GetAggregatedRunDataMetrics(); + var runMetrics = aggregator.GetAggregatedRunDataMetrics(); + Assert.IsFalse(runMetrics.TryGetValue(TelemetryDataConstants.RunState, out _)); + } - Assert.AreEqual(0, runMetrics.Count); - } + [TestMethod] + public void GetAggregatedRunDataMetricsShouldReturnEmptyIfMetricAggregatorIsEmpty() + { + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - [TestMethod] - public void GetRunDataMetricsShouldAddTotalAdaptersUsedIfMetricsIsNotEmpty() - { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); + var dict = new Dictionary(); - var dict = new Dictionary(); - dict.Add(TelemetryDataConstants.TotalTestsRanByAdapter, 2); + aggregator.AggregateRunDataMetrics(dict); + var runMetrics = aggregator.GetAggregatedRunDataMetrics(); - aggregator.AggregateRunDataMetrics(dict); - aggregator.AggregateRunDataMetrics(dict); + Assert.AreEqual(0, runMetrics.Count); + } + + [TestMethod] + public void GetAggregatedRunDataMetricsShouldReturnEmptyIfMetricsIsNull() + { + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); + _ = new Dictionary(); + + aggregator.AggregateRunDataMetrics(null); + var runMetrics = aggregator.GetAggregatedRunDataMetrics(); - var runMetrics = aggregator.GetAggregatedRunDataMetrics(); + Assert.AreEqual(0, runMetrics.Count); + } - Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.NumberOfAdapterUsedToRunTests, out var value)); - Assert.AreEqual(1, value); - } + [TestMethod] + public void GetRunDataMetricsShouldAddTotalAdaptersUsedIfMetricsIsNotEmpty() + { + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - [TestMethod] - public void GetRunDataMetricsShouldAddNumberOfAdapterDiscoveredIfMetricsIsEmpty() + var dict = new Dictionary { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); + { TelemetryDataConstants.TotalTestsRanByAdapter, 2 } + }; - var dict = new Dictionary(); - dict.Add(TelemetryDataConstants.TimeTakenToRunTestsByAnAdapter + "executor:MSTestV1", .02091); - dict.Add(TelemetryDataConstants.TimeTakenToRunTestsByAnAdapter + "executor:MSTestV2", .02091); + aggregator.AggregateRunDataMetrics(dict); + aggregator.AggregateRunDataMetrics(dict); - aggregator.AggregateRunDataMetrics(dict); + var runMetrics = aggregator.GetAggregatedRunDataMetrics(); - var runMetrics = aggregator.GetAggregatedRunDataMetrics(); + Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.NumberOfAdapterUsedToRunTests, out var value)); + Assert.AreEqual(1, value); + } - Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringExecution, out var value)); - Assert.AreEqual(2, value); - } + [TestMethod] + public void GetRunDataMetricsShouldAddNumberOfAdapterDiscoveredIfMetricsIsEmpty() + { + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - [TestMethod] - public void GetRunDataMetricsShouldNotAddTotalAdaptersUsedIfMetricsIsEmpty() + var dict = new Dictionary { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - var dict = new Dictionary(); + { TelemetryDataConstants.TimeTakenToRunTestsByAnAdapter + "executor:MSTestV1", .02091 }, + { TelemetryDataConstants.TimeTakenToRunTestsByAnAdapter + "executor:MSTestV2", .02091 } + }; - aggregator.AggregateRunDataMetrics(dict); + aggregator.AggregateRunDataMetrics(dict); - var runMetrics = aggregator.GetAggregatedRunDataMetrics(); + var runMetrics = aggregator.GetAggregatedRunDataMetrics(); - Assert.IsFalse(runMetrics.TryGetValue(TelemetryDataConstants.NumberOfAdapterUsedToRunTests, out var value)); - } + Assert.IsTrue(runMetrics.TryGetValue(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringExecution, out var value)); + Assert.AreEqual(2, value); + } - [TestMethod] - public void GetRunDataMetricsShouldNotAddNumberOfAdapterDiscoveredIfMetricsIsEmpty() - { - var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); - var dict = new Dictionary(); + [TestMethod] + public void GetRunDataMetricsShouldNotAddTotalAdaptersUsedIfMetricsIsEmpty() + { + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); + var dict = new Dictionary(); + + aggregator.AggregateRunDataMetrics(dict); - aggregator.AggregateRunDataMetrics(dict); + var runMetrics = aggregator.GetAggregatedRunDataMetrics(); + Assert.IsFalse(runMetrics.TryGetValue(TelemetryDataConstants.NumberOfAdapterUsedToRunTests, out _)); + } + + [TestMethod] + public void GetRunDataMetricsShouldNotAddNumberOfAdapterDiscoveredIfMetricsIsEmpty() + { + var aggregator = new ParallelRunDataAggregator(Constants.EmptyRunSettings); + var dict = new Dictionary(); - var runMetrics = aggregator.GetAggregatedRunDataMetrics(); + aggregator.AggregateRunDataMetrics(dict); - Assert.IsFalse(runMetrics.TryGetValue(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringExecution, out var value)); - } + var runMetrics = aggregator.GetAggregatedRunDataMetrics(); + Assert.IsFalse(runMetrics.TryGetValue(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringExecution, out _)); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelRunEventsHandlerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelRunEventsHandlerTests.cs index 3e28c73fe0..f1e346e4d6 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelRunEventsHandlerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelRunEventsHandlerTests.cs @@ -1,204 +1,203 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Client +namespace TestPlatform.CrossPlatEngine.UnitTests.Client; + +using System; +using System.Collections.Generic; + +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class ParallelRunEventsHandlerTests { - using System; - using System.Collections.Generic; - - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - [TestClass] - public class ParallelRunEventsHandlerTests - { - private ParallelRunEventsHandler parallelRunEventsHandler; - - private Mock mockProxyExecutionManager; + private ParallelRunEventsHandler _parallelRunEventsHandler; - private Mock mockTestRunEventsHandler; + private Mock _mockProxyExecutionManager; - private Mock mockParallelProxyExecutionManager; + private Mock _mockTestRunEventsHandler; - private Mock mockDataSerializer; + private Mock _mockParallelProxyExecutionManager; - private Mock mockRequestData; + private Mock _mockDataSerializer; - [TestInitialize] - public void TestInit() - { - this.mockProxyExecutionManager = new Mock(); - this.mockTestRunEventsHandler = new Mock(); - this.mockParallelProxyExecutionManager = new Mock(); - this.mockDataSerializer = new Mock(); - this.mockRequestData = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new NoOpMetricsCollection()); + private Mock _mockRequestData; - this.parallelRunEventsHandler = new ParallelRunEventsHandler(this.mockRequestData.Object, this.mockProxyExecutionManager.Object, - this.mockTestRunEventsHandler.Object, this.mockParallelProxyExecutionManager.Object, - new ParallelRunDataAggregator(Constants.EmptyRunSettings), this.mockDataSerializer.Object); - } + [TestInitialize] + public void TestInit() + { + _mockProxyExecutionManager = new Mock(); + _mockTestRunEventsHandler = new Mock(); + _mockParallelProxyExecutionManager = new Mock(); + _mockDataSerializer = new Mock(); + _mockRequestData = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new NoOpMetricsCollection()); + + _parallelRunEventsHandler = new ParallelRunEventsHandler(_mockRequestData.Object, _mockProxyExecutionManager.Object, + _mockTestRunEventsHandler.Object, _mockParallelProxyExecutionManager.Object, + new ParallelRunDataAggregator(Constants.EmptyRunSettings), _mockDataSerializer.Object); + } - [TestMethod] - public void HandleRawMessageShouldSendStatsChangeRawMessageToRunEventsHandler() - { - string payload = "RunStats"; - this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())) - .Returns(new Message() { MessageType = MessageType.TestRunStatsChange, Payload = payload }); + [TestMethod] + public void HandleRawMessageShouldSendStatsChangeRawMessageToRunEventsHandler() + { + string payload = "RunStats"; + _mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())) + .Returns(new Message() { MessageType = MessageType.TestRunStatsChange, Payload = payload }); - this.parallelRunEventsHandler.HandleRawMessage(payload); + _parallelRunEventsHandler.HandleRawMessage(payload); - this.mockTestRunEventsHandler.Verify(mt => mt.HandleRawMessage(payload), Times.Once); - } + _mockTestRunEventsHandler.Verify(mt => mt.HandleRawMessage(payload), Times.Once); + } - [TestMethod] - public void HandleRawMessageShouldSendLoggerRawMessageToRunEventsHandler() - { - string payload = "LogMessage"; - this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())) - .Returns(new Message() { MessageType = MessageType.TestMessage, Payload = payload }); + [TestMethod] + public void HandleRawMessageShouldSendLoggerRawMessageToRunEventsHandler() + { + string payload = "LogMessage"; + _mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())) + .Returns(new Message() { MessageType = MessageType.TestMessage, Payload = payload }); - this.parallelRunEventsHandler.HandleRawMessage(payload); + _parallelRunEventsHandler.HandleRawMessage(payload); - this.mockTestRunEventsHandler.Verify(mt => mt.HandleRawMessage(payload), Times.Once); - } + _mockTestRunEventsHandler.Verify(mt => mt.HandleRawMessage(payload), Times.Once); + } - [TestMethod] - public void HandleRawMessageShouldNotSendRunCompleteEventRawMessageToRunEventsHandler() - { - string payload = "ExecComplete"; - this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())) - .Returns(new Message() { MessageType = MessageType.ExecutionComplete, Payload = payload }); + [TestMethod] + public void HandleRawMessageShouldNotSendRunCompleteEventRawMessageToRunEventsHandler() + { + string payload = "ExecComplete"; + _mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())) + .Returns(new Message() { MessageType = MessageType.ExecutionComplete, Payload = payload }); - this.parallelRunEventsHandler.HandleRawMessage(payload); + _parallelRunEventsHandler.HandleRawMessage(payload); - this.mockTestRunEventsHandler.Verify(mt => mt.HandleRawMessage(It.IsAny()), Times.Never); - } + _mockTestRunEventsHandler.Verify(mt => mt.HandleRawMessage(It.IsAny()), Times.Never); + } - [TestMethod] - public void HandleLogMessageShouldJustPassOnTheEventToRunEventsHandler() - { - string log = "Hello"; - this.parallelRunEventsHandler.HandleLogMessage(TestMessageLevel.Error, log); + [TestMethod] + public void HandleLogMessageShouldJustPassOnTheEventToRunEventsHandler() + { + string log = "Hello"; + _parallelRunEventsHandler.HandleLogMessage(TestMessageLevel.Error, log); - this.mockTestRunEventsHandler.Verify(mt => - mt.HandleLogMessage(TestMessageLevel.Error, log), Times.Once); - } + _mockTestRunEventsHandler.Verify(mt => + mt.HandleLogMessage(TestMessageLevel.Error, log), Times.Once); + } - [TestMethod] - public void HandleRunStatsChangeShouldJustPassOnTheEventToRunEventsHandler() - { - var eventArgs = new TestRunChangedEventArgs(null, null, null); - this.parallelRunEventsHandler.HandleTestRunStatsChange(eventArgs); + [TestMethod] + public void HandleRunStatsChangeShouldJustPassOnTheEventToRunEventsHandler() + { + var eventArgs = new TestRunChangedEventArgs(null, null, null); + _parallelRunEventsHandler.HandleTestRunStatsChange(eventArgs); - this.mockTestRunEventsHandler.Verify(mt => mt.HandleTestRunStatsChange(eventArgs), Times.Once); - } + _mockTestRunEventsHandler.Verify(mt => mt.HandleTestRunStatsChange(eventArgs), Times.Once); + } - [TestMethod] - public void LaunchProcessWithDebuggerAttachedShouldJustPassOnTheEventToRunEventsHandler() - { - var testProcessStartInfo = new TestProcessStartInfo(); - this.parallelRunEventsHandler.LaunchProcessWithDebuggerAttached(testProcessStartInfo); + [TestMethod] + public void LaunchProcessWithDebuggerAttachedShouldJustPassOnTheEventToRunEventsHandler() + { + var testProcessStartInfo = new TestProcessStartInfo(); + _parallelRunEventsHandler.LaunchProcessWithDebuggerAttached(testProcessStartInfo); - this.mockTestRunEventsHandler.Verify(mt => mt.LaunchProcessWithDebuggerAttached(testProcessStartInfo), Times.Once); - } + _mockTestRunEventsHandler.Verify(mt => mt.LaunchProcessWithDebuggerAttached(testProcessStartInfo), Times.Once); + } - [TestMethod] - public void HandleRunCompleteShouldNotCallLastChunkResultsIfNotPresent() - { - var completeArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.Zero); + [TestMethod] + public void HandleRunCompleteShouldNotCallLastChunkResultsIfNotPresent() + { + var completeArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.Zero); - this.mockParallelProxyExecutionManager.Setup(mp => mp.HandlePartialRunComplete( - this.mockProxyExecutionManager.Object, completeArgs, null, null, null)).Returns(false); + _mockParallelProxyExecutionManager.Setup(mp => mp.HandlePartialRunComplete( + _mockProxyExecutionManager.Object, completeArgs, null, null, null)).Returns(false); - this.parallelRunEventsHandler.HandleTestRunComplete(completeArgs, null, null, null); + _parallelRunEventsHandler.HandleTestRunComplete(completeArgs, null, null, null); - // Raw message must be sent - this.mockTestRunEventsHandler.Verify(mt => mt.HandleRawMessage(It.IsAny()), Times.Never); + // Raw message must be sent + _mockTestRunEventsHandler.Verify(mt => mt.HandleRawMessage(It.IsAny()), Times.Never); - this.mockTestRunEventsHandler.Verify(mt => mt.HandleTestRunStatsChange(null), Times.Never); + _mockTestRunEventsHandler.Verify(mt => mt.HandleTestRunStatsChange(null), Times.Never); - this.mockParallelProxyExecutionManager.Verify(mp => mp.HandlePartialRunComplete( - this.mockProxyExecutionManager.Object, completeArgs, null, null, null), Times.Once); - } + _mockParallelProxyExecutionManager.Verify(mp => mp.HandlePartialRunComplete( + _mockProxyExecutionManager.Object, completeArgs, null, null, null), Times.Once); + } - [TestMethod] - public void HandleRunCompleteShouldCallLastChunkResultsIfPresent() - { - string payload = "RunStats"; - var lastChunk = new TestRunChangedEventArgs(null, null, null); - var completeArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.Zero); + [TestMethod] + public void HandleRunCompleteShouldCallLastChunkResultsIfPresent() + { + string payload = "RunStats"; + var lastChunk = new TestRunChangedEventArgs(null, null, null); + var completeArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.Zero); - this.mockDataSerializer.Setup(mds => mds.SerializePayload(MessageType.TestRunStatsChange, lastChunk)) - .Returns(payload); + _mockDataSerializer.Setup(mds => mds.SerializePayload(MessageType.TestRunStatsChange, lastChunk)) + .Returns(payload); - this.mockParallelProxyExecutionManager.Setup(mp => mp.HandlePartialRunComplete( - this.mockProxyExecutionManager.Object, completeArgs, null, null, null)).Returns(false); + _mockParallelProxyExecutionManager.Setup(mp => mp.HandlePartialRunComplete( + _mockProxyExecutionManager.Object, completeArgs, null, null, null)).Returns(false); - this.parallelRunEventsHandler.HandleTestRunComplete(completeArgs, lastChunk, null, null); + _parallelRunEventsHandler.HandleTestRunComplete(completeArgs, lastChunk, null, null); - // Raw message must be sent - this.mockTestRunEventsHandler.Verify(mt => mt.HandleRawMessage(payload), Times.Once); + // Raw message must be sent + _mockTestRunEventsHandler.Verify(mt => mt.HandleRawMessage(payload), Times.Once); - this.mockTestRunEventsHandler.Verify(mt => mt.HandleTestRunStatsChange(lastChunk), Times.Once); + _mockTestRunEventsHandler.Verify(mt => mt.HandleTestRunStatsChange(lastChunk), Times.Once); - this.mockParallelProxyExecutionManager.Verify(mp => mp.HandlePartialRunComplete( - this.mockProxyExecutionManager.Object, completeArgs, null, null, null), Times.Once); - } + _mockParallelProxyExecutionManager.Verify(mp => mp.HandlePartialRunComplete( + _mockProxyExecutionManager.Object, completeArgs, null, null, null), Times.Once); + } - [TestMethod] - public void HandleRunCompleteShouldCallTestRunCompleteOnActualHandlerIfParallelMaangerReturnsCompleteAsTrue() - { - string payload = "ExecComplete"; - var completeArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.Zero); + [TestMethod] + public void HandleRunCompleteShouldCallTestRunCompleteOnActualHandlerIfParallelMaangerReturnsCompleteAsTrue() + { + string payload = "ExecComplete"; + var completeArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.Zero); - this.mockParallelProxyExecutionManager.Setup(mp => mp.HandlePartialRunComplete( - this.mockProxyExecutionManager.Object, completeArgs, null, null, null)).Returns(true); + _mockParallelProxyExecutionManager.Setup(mp => mp.HandlePartialRunComplete( + _mockProxyExecutionManager.Object, completeArgs, null, null, null)).Returns(true); - this.mockDataSerializer.Setup(mds => mds.SerializeMessage(MessageType.ExecutionComplete)).Returns(payload); + _mockDataSerializer.Setup(mds => mds.SerializeMessage(MessageType.ExecutionComplete)).Returns(payload); - this.parallelRunEventsHandler.HandleTestRunComplete(completeArgs, null, null, null); + _parallelRunEventsHandler.HandleTestRunComplete(completeArgs, null, null, null); - this.mockTestRunEventsHandler.Verify(mt => mt.HandleTestRunStatsChange(null), Times.Never); + _mockTestRunEventsHandler.Verify(mt => mt.HandleTestRunStatsChange(null), Times.Never); - this.mockParallelProxyExecutionManager.Verify(mp => mp.HandlePartialRunComplete( - this.mockProxyExecutionManager.Object, completeArgs, null, null, null), Times.Once); + _mockParallelProxyExecutionManager.Verify(mp => mp.HandlePartialRunComplete( + _mockProxyExecutionManager.Object, completeArgs, null, null, null), Times.Once); - this.mockTestRunEventsHandler.Verify(mt => mt.HandleRawMessage(It.IsAny()), Times.Once); + _mockTestRunEventsHandler.Verify(mt => mt.HandleRawMessage(It.IsAny()), Times.Once); - this.mockTestRunEventsHandler.Verify(mt => mt.HandleTestRunComplete( - It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>()), Times.Once); - } + _mockTestRunEventsHandler.Verify(mt => mt.HandleTestRunComplete( + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>()), Times.Once); + } - [TestMethod] - public void HandleRunCompleteShouldCollectMetrics() - { - var mockMetricsCollector = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollector.Object); + [TestMethod] + public void HandleRunCompleteShouldCollectMetrics() + { + var mockMetricsCollector = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollector.Object); - var completeArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.Zero); + var completeArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.Zero); - this.mockParallelProxyExecutionManager.Setup(mp => mp.HandlePartialRunComplete( - this.mockProxyExecutionManager.Object, completeArgs, null, null, null)).Returns(true); + _mockParallelProxyExecutionManager.Setup(mp => mp.HandlePartialRunComplete( + _mockProxyExecutionManager.Object, completeArgs, null, null, null)).Returns(true); - // Act - this.parallelRunEventsHandler.HandleTestRunComplete(completeArgs, null, null, null); + // Act + _parallelRunEventsHandler.HandleTestRunComplete(completeArgs, null, null, null); - // Verify. - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.RunState, It.IsAny()), Times.Once); - } + // Verify. + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.RunState, It.IsAny()), Times.Once); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyBaseManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyBaseManagerTests.cs index 64f5ace172..8183b45cc0 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyBaseManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyBaseManagerTests.cs @@ -1,125 +1,119 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Client +namespace TestPlatform.CrossPlatEngine.UnitTests.Client; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +using System.Collections.Generic; +using System.Net; +using System.Threading; +using System.Threading.Tasks; + +[TestClass] +public class ProxyBaseManagerTests { - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using System.Collections.Generic; - using System.Net; - using System.Threading; - using System.Threading.Tasks; - - [TestClass] - public class ProxyBaseManagerTests + private const int Clientprocessexitwait = 10 * 1000; + private Mock _mockCommunicationEndpoint; + private ITestRequestSender _testRequestSender; + readonly ProtocolConfig _protocolConfig = new() { Version = 2 }; + private readonly Mock _mockRequestData; + protected readonly Mock _mockTestHostManager; + protected Mock _mockDataSerializer; + protected Mock _mockChannel; + private readonly Mock _mockFileHelper; + + public ProxyBaseManagerTests() { - private const int CLIENTPROCESSEXITWAIT = 10 * 1000; - private Mock mockCommunicationEndpoint; - private ITestRequestSender testRequestSender; - - ProtocolConfig protocolConfig = new ProtocolConfig { Version = 2 }; - private readonly Mock mockRequestData; - protected readonly Mock mockTestHostManager; - protected Mock mockDataSerializer; - protected Mock mockChannel; - private Mock mockFileHelper; - - public ProxyBaseManagerTests() - { - this.mockTestHostManager = new Mock(); - this.mockDataSerializer = new Mock(); - this.mockRequestData = new Mock(); - this.mockChannel = new Mock(); - this.mockFileHelper = new Mock(); - - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new Mock().Object); - this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(null)).Returns(new Message()); - this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(string.Empty)).Returns(new Message()); - this.mockTestHostManager.SetupGet(th => th.Shared).Returns(true); - this.mockTestHostManager.Setup( - m => m.GetTestHostProcessStartInfo( - It.IsAny>(), - It.IsAny>(), - It.IsAny())) - .Returns(new TestProcessStartInfo()); - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())) - .Callback( - () => - { - this.mockTestHostManager.Raise(thm => thm.HostLaunched += null, new HostProviderEventArgs(string.Empty)); - }) - .Returns(Task.FromResult(true)); - } - - private void SetupAndInitializeTestRequestSender() - { - var connectionInfo = new TestHostConnectionInfo - { - Endpoint = IPAddress.Loopback + ":0", - Role = ConnectionRole.Client, - Transport = Transport.Sockets - }; - this.mockCommunicationEndpoint = new Mock(); - this.mockDataSerializer = new Mock(); - this.testRequestSender = new TestRequestSender(this.mockCommunicationEndpoint.Object, connectionInfo, this.mockDataSerializer.Object, this.protocolConfig, CLIENTPROCESSEXITWAIT); - this.mockCommunicationEndpoint.Setup(mc => mc.Start(connectionInfo.Endpoint)).Returns(connectionInfo.Endpoint).Callback(() => - { - this.mockCommunicationEndpoint.Raise( - s => s.Connected += null, - this.mockCommunicationEndpoint.Object, - new ConnectedEventArgs(this.mockChannel.Object)); - }); - this.SetupChannelMessage(MessageType.VersionCheck, MessageType.VersionCheck, this.protocolConfig.Version); - - this.testRequestSender.InitializeCommunication(); - } - - public void SetupChannelMessage(string messageType, string returnMessageType, TPayload returnPayload) - { - this.mockChannel.Setup(mc => mc.Send(It.Is(s => s.Contains(messageType)))) - .Callback(() => this.mockChannel.Raise(c => c.MessageReceived += null, this.mockChannel.Object, new MessageReceivedEventArgs { Data = messageType })); + _mockTestHostManager = new Mock(); + _mockDataSerializer = new Mock(); + _mockRequestData = new Mock(); + _mockChannel = new Mock(); + _mockFileHelper = new Mock(); - this.mockDataSerializer.Setup(ds => ds.SerializePayload(It.Is(s => s.Equals(messageType)), It.IsAny())).Returns(messageType); - this.mockDataSerializer.Setup(ds => ds.SerializePayload(It.Is(s => s.Equals(messageType)), It.IsAny(), It.IsAny())).Returns(messageType); - this.mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.Is(s => s.Equals(messageType)))).Returns(new Message { MessageType = returnMessageType }); - this.mockDataSerializer.Setup(ds => ds.DeserializePayload(It.Is(m => m.MessageType.Equals(messageType)))).Returns(returnPayload); - } + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new Mock().Object); + _mockDataSerializer.Setup(mds => mds.DeserializeMessage(null)).Returns(new Message()); + _mockDataSerializer.Setup(mds => mds.DeserializeMessage(string.Empty)).Returns(new Message()); + _mockTestHostManager.SetupGet(th => th.Shared).Returns(true); + _mockTestHostManager.Setup( + m => m.GetTestHostProcessStartInfo( + It.IsAny>(), + It.IsAny>(), + It.IsAny())) + .Returns(new TestProcessStartInfo()); + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())) + .Callback( + () => _mockTestHostManager.Raise(thm => thm.HostLaunched += null, new HostProviderEventArgs(string.Empty))) + .Returns(Task.FromResult(true)); + } - public void RaiseMessageReceived(string data) + private void SetupAndInitializeTestRequestSender() + { + var connectionInfo = new TestHostConnectionInfo { - this.mockChannel.Raise(c => c.MessageReceived += null, this.mockChannel.Object, - new MessageReceivedEventArgs { Data = data }); - } + Endpoint = IPAddress.Loopback + ":0", + Role = ConnectionRole.Client, + Transport = Transport.Sockets + }; + _mockCommunicationEndpoint = new Mock(); + _mockDataSerializer = new Mock(); + _testRequestSender = new TestRequestSender(_mockCommunicationEndpoint.Object, connectionInfo, _mockDataSerializer.Object, _protocolConfig, Clientprocessexitwait); + _mockCommunicationEndpoint.Setup(mc => mc.Start(connectionInfo.Endpoint)).Returns(connectionInfo.Endpoint).Callback(() => _mockCommunicationEndpoint.Raise( + s => s.Connected += null, + _mockCommunicationEndpoint.Object, + new ConnectedEventArgs(_mockChannel.Object))); + SetupChannelMessage(MessageType.VersionCheck, MessageType.VersionCheck, _protocolConfig.Version); - protected ProxyDiscoveryManager GetProxyDiscoveryManager() - { - this.SetupAndInitializeTestRequestSender(); - var testDiscoveryManager = new ProxyDiscoveryManager( - mockRequestData.Object, - testRequestSender, - mockTestHostManager.Object, - mockDataSerializer.Object, - this.mockFileHelper.Object); - - return testDiscoveryManager; - } - - internal ProxyExecutionManager GetProxyExecutionManager() - { - this.SetupAndInitializeTestRequestSender(); - this.mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - var testExecutionManager = new ProxyExecutionManager(mockRequestData.Object, testRequestSender, - mockTestHostManager.Object, mockDataSerializer.Object, this.mockFileHelper.Object); + _testRequestSender.InitializeCommunication(); + } + + public void SetupChannelMessage(string messageType, string returnMessageType, TPayload returnPayload) + { + _mockChannel.Setup(mc => mc.Send(It.Is(s => s.Contains(messageType)))) + .Callback(() => _mockChannel.Raise(c => c.MessageReceived += null, _mockChannel.Object, new MessageReceivedEventArgs { Data = messageType })); + + _mockDataSerializer.Setup(ds => ds.SerializePayload(It.Is(s => s.Equals(messageType)), It.IsAny())).Returns(messageType); + _mockDataSerializer.Setup(ds => ds.SerializePayload(It.Is(s => s.Equals(messageType)), It.IsAny(), It.IsAny())).Returns(messageType); + _mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.Is(s => s.Equals(messageType)))).Returns(new Message { MessageType = returnMessageType }); + _mockDataSerializer.Setup(ds => ds.DeserializePayload(It.Is(m => m.MessageType.Equals(messageType)))).Returns(returnPayload); + } + + public void RaiseMessageReceived(string data) + { + _mockChannel.Raise(c => c.MessageReceived += null, _mockChannel.Object, + new MessageReceivedEventArgs { Data = data }); + } + + protected ProxyDiscoveryManager GetProxyDiscoveryManager() + { + SetupAndInitializeTestRequestSender(); + var testDiscoveryManager = new ProxyDiscoveryManager( + _mockRequestData.Object, + _testRequestSender, + _mockTestHostManager.Object, + _mockDataSerializer.Object, + _mockFileHelper.Object); + + return testDiscoveryManager; + } + + internal ProxyExecutionManager GetProxyExecutionManager() + { + SetupAndInitializeTestRequestSender(); + _mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + var testExecutionManager = new ProxyExecutionManager(_mockRequestData.Object, _testRequestSender, + _mockTestHostManager.Object, _mockDataSerializer.Object, _mockFileHelper.Object); - return testExecutionManager; - } + return testExecutionManager; } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyDiscoveryManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyDiscoveryManagerTests.cs index 5133483580..44c37e3d16 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyDiscoveryManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyDiscoveryManagerTests.cs @@ -1,519 +1,513 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Client +namespace TestPlatform.CrossPlatEngine.UnitTests.Client; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class ProxyDiscoveryManagerTests : ProxyBaseManagerTests { - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - - [TestClass] - public class ProxyDiscoveryManagerTests : ProxyBaseManagerTests - { - //private const int CLIENTPROCESSEXITWAIT = 10 * 1000; + //private const int CLIENTPROCESSEXITWAIT = 10 * 1000; - private readonly DiscoveryCriteria discoveryCriteria; + private readonly DiscoveryCriteria _discoveryCriteria; - private ProxyDiscoveryManager testDiscoveryManager; + private ProxyDiscoveryManager _testDiscoveryManager; - private Mock mockRequestSender; + private readonly Mock _mockRequestSender; - //private Mock mockDataSerializer; + //private Mock mockDataSerializer; - private Mock mockRequestData; + private readonly Mock _mockRequestData; - private Mock mockMetricsCollection; - private Mock mockFileHelper; + private readonly Mock _mockMetricsCollection; + private readonly Mock _mockFileHelper; - public ProxyDiscoveryManagerTests() - { - this.mockRequestSender = new Mock(); - this.mockRequestData = new Mock(); - this.mockMetricsCollection = new Mock(); - this.mockFileHelper = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(this.mockMetricsCollection.Object); - this.testDiscoveryManager = new ProxyDiscoveryManager( - this.mockRequestData.Object, - this.mockRequestSender.Object, - this.mockTestHostManager.Object, - this.mockDataSerializer.Object, - this.mockFileHelper.Object); - this.discoveryCriteria = new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty); - } + public ProxyDiscoveryManagerTests() + { + _mockRequestSender = new Mock(); + _mockRequestData = new Mock(); + _mockMetricsCollection = new Mock(); + _mockFileHelper = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(_mockMetricsCollection.Object); + _testDiscoveryManager = new ProxyDiscoveryManager( + _mockRequestData.Object, + _mockRequestSender.Object, + _mockTestHostManager.Object, + _mockDataSerializer.Object, + _mockFileHelper.Object); + _discoveryCriteria = new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty); + } - [TestMethod] - public void DiscoverTestsShouldNotInitializeExtensionsOnNoExtensions() - { - // Make sure TestPlugincache is refreshed. - TestPluginCache.Instance = null; + [TestMethod] + public void DiscoverTestsShouldNotInitializeExtensionsOnNoExtensions() + { + // Make sure TestPlugincache is refreshed. + TestPluginCache.Instance = null; - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, null); + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, null); - this.mockRequestSender.Verify(s => s.InitializeDiscovery(It.IsAny>()), Times.Never); - } + _mockRequestSender.Verify(s => s.InitializeDiscovery(It.IsAny>()), Times.Never); + } - [TestMethod] - public void DiscoverTestsShouldNotInitializeExtensionsOnCommunicationFailure() - { - // Make sure TestPlugincache is refreshed. - TestPluginCache.Instance = null; + [TestMethod] + public void DiscoverTestsShouldNotInitializeExtensionsOnCommunicationFailure() + { + // Make sure TestPlugincache is refreshed. + TestPluginCache.Instance = null; - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); - Mock mockTestDiscoveryEventHandler = new Mock(); + Mock mockTestDiscoveryEventHandler = new(); - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, mockTestDiscoveryEventHandler.Object); + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, mockTestDiscoveryEventHandler.Object); - this.mockRequestSender.Verify(s => s.InitializeExecution(It.IsAny>()), Times.Never); - } + _mockRequestSender.Verify(s => s.InitializeExecution(It.IsAny>()), Times.Never); + } - [TestMethod] - public void DiscoverTestsShouldAllowRuntimeProviderToUpdateAdapterSource() - { - // Make sure TestPlugincache is refreshed. - TestPluginCache.Instance = null; + [TestMethod] + public void DiscoverTestsShouldAllowRuntimeProviderToUpdateAdapterSource() + { + // Make sure TestPlugincache is refreshed. + TestPluginCache.Instance = null; - this.mockTestHostManager.Setup(hm => hm.GetTestSources(this.discoveryCriteria.Sources)).Returns(this.discoveryCriteria.Sources); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + _mockTestHostManager.Setup(hm => hm.GetTestSources(_discoveryCriteria.Sources)).Returns(_discoveryCriteria.Sources); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - Mock mockTestDiscoveryEventHandler = new Mock(); + Mock mockTestDiscoveryEventHandler = new(); - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, mockTestDiscoveryEventHandler.Object); + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, mockTestDiscoveryEventHandler.Object); - this.mockTestHostManager.Verify(hm => hm.GetTestSources(this.discoveryCriteria.Sources), Times.Once); - } + _mockTestHostManager.Verify(hm => hm.GetTestSources(_discoveryCriteria.Sources), Times.Once); + } - [TestMethod] - public void DiscoverTestsShouldUpdateTestSourcesIfSourceDiffersFromTestHostManagerSource() - { - var actualSources = new List { "actualSource.dll" }; - var inputSource = new List { "inputPackage.appxrecipe" }; + [TestMethod] + public void DiscoverTestsShouldUpdateTestSourcesIfSourceDiffersFromTestHostManagerSource() + { + var actualSources = new List { "actualSource.dll" }; + var inputSource = new List { "inputPackage.appxrecipe" }; - var localDiscoveryCriteria = new DiscoveryCriteria(inputSource, 1, string.Empty); + var localDiscoveryCriteria = new DiscoveryCriteria(inputSource, 1, string.Empty); - this.mockTestHostManager.Setup(hm => hm.GetTestSources(localDiscoveryCriteria.Sources)).Returns(actualSources); - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(true)); - this.mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new List()); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + _mockTestHostManager.Setup(hm => hm.GetTestSources(localDiscoveryCriteria.Sources)).Returns(actualSources); + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(true)); + _mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new List()); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - Mock mockTestDiscoveryEventHandler = new Mock(); + Mock mockTestDiscoveryEventHandler = new(); - this.testDiscoveryManager.DiscoverTests(localDiscoveryCriteria, mockTestDiscoveryEventHandler.Object); + _testDiscoveryManager.DiscoverTests(localDiscoveryCriteria, mockTestDiscoveryEventHandler.Object); - Assert.IsNotNull(localDiscoveryCriteria.Package); - // AdapterSourceMap should contain updated testSources. - Assert.AreEqual(actualSources.FirstOrDefault(), localDiscoveryCriteria.AdapterSourceMap.FirstOrDefault().Value.FirstOrDefault()); - Assert.AreEqual(inputSource.FirstOrDefault(), localDiscoveryCriteria.Package); - } + Assert.IsNotNull(localDiscoveryCriteria.Package); + // AdapterSourceMap should contain updated testSources. + Assert.AreEqual(actualSources.FirstOrDefault(), localDiscoveryCriteria.AdapterSourceMap.FirstOrDefault().Value.FirstOrDefault()); + Assert.AreEqual(inputSource.FirstOrDefault(), localDiscoveryCriteria.Package); + } - [TestMethod] - public void DiscoverTestsShouldNotUpdateTestSourcesIfSourceDoNotDifferFromTestHostManagerSource() - { - var actualSources = new List { "actualSource.dll" }; - var inputSource = new List { "actualSource.dll" }; + [TestMethod] + public void DiscoverTestsShouldNotUpdateTestSourcesIfSourceDoNotDifferFromTestHostManagerSource() + { + var actualSources = new List { "actualSource.dll" }; + var inputSource = new List { "actualSource.dll" }; - var localDiscoveryCriteria = new DiscoveryCriteria(inputSource, 1, string.Empty); + var localDiscoveryCriteria = new DiscoveryCriteria(inputSource, 1, string.Empty); - this.mockTestHostManager.Setup(hm => hm.GetTestSources(localDiscoveryCriteria.Sources)).Returns(actualSources); - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(true)); - this.mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new List()); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + _mockTestHostManager.Setup(hm => hm.GetTestSources(localDiscoveryCriteria.Sources)).Returns(actualSources); + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(true)); + _mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new List()); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - Mock mockTestDiscoveryEventHandler = new Mock(); + Mock mockTestDiscoveryEventHandler = new(); - this.testDiscoveryManager.DiscoverTests(localDiscoveryCriteria, mockTestDiscoveryEventHandler.Object); + _testDiscoveryManager.DiscoverTests(localDiscoveryCriteria, mockTestDiscoveryEventHandler.Object); - Assert.IsNull(localDiscoveryCriteria.Package); - // AdapterSourceMap should contain updated testSources. - Assert.AreEqual(actualSources.FirstOrDefault(), localDiscoveryCriteria.AdapterSourceMap.FirstOrDefault().Value.FirstOrDefault()); - } + Assert.IsNull(localDiscoveryCriteria.Package); + // AdapterSourceMap should contain updated testSources. + Assert.AreEqual(actualSources.FirstOrDefault(), localDiscoveryCriteria.AdapterSourceMap.FirstOrDefault().Value.FirstOrDefault()); + } - [TestMethod] - public void DiscoverTestsShouldNotSendDiscoveryRequestIfCommunicationFails() - { - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())) - .Callback( - () => - { - this.mockTestHostManager.Raise(thm => thm.HostLaunched += null, new HostProviderEventArgs(string.Empty)); - }) - .Returns(Task.FromResult(false)); + [TestMethod] + public void DiscoverTestsShouldNotSendDiscoveryRequestIfCommunicationFails() + { + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())) + .Callback( + () => _mockTestHostManager.Raise(thm => thm.HostLaunched += null, new HostProviderEventArgs(string.Empty))) + .Returns(Task.FromResult(false)); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - // Make sure TestPlugincache is refreshed. - TestPluginCache.Instance = null; + // Make sure TestPlugincache is refreshed. + TestPluginCache.Instance = null; - Mock mockTestDiscoveryEventHandler = new Mock(); + Mock mockTestDiscoveryEventHandler = new(); - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, mockTestDiscoveryEventHandler.Object); + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, mockTestDiscoveryEventHandler.Object); - this.mockRequestSender.Verify(s => s.DiscoverTests(It.IsAny(), It.IsAny()), Times.Never); - } + _mockRequestSender.Verify(s => s.DiscoverTests(It.IsAny(), It.IsAny()), Times.Never); + } - [TestMethod] - public void DiscoverTestsShouldInitializeExtensionsIfPresent() - { - // Make sure TestPlugincache is refreshed. - TestPluginCache.Instance = null; + [TestMethod] + public void DiscoverTestsShouldInitializeExtensionsIfPresent() + { + // Make sure TestPlugincache is refreshed. + TestPluginCache.Instance = null; - try - { - var extensions = new[] { "c:\\e1.dll", "c:\\e2.dll" }; + try + { + var extensions = new[] { "c:\\e1.dll", "c:\\e2.dll" }; - // Setup Mocks. - TestPluginCacheHelper.SetupMockAdditionalPathExtensions(extensions); - this.mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - this.mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new[] { "c:\\e1.dll", "c:\\e2.dll" }); + // Setup Mocks. + TestPluginCacheHelper.SetupMockAdditionalPathExtensions(extensions); + _mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + _mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new[] { "c:\\e1.dll", "c:\\e2.dll" }); - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, null); + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, null); - // Also verify that we have waited for client connection. - this.mockRequestSender.Verify(s => s.InitializeDiscovery(extensions), Times.Once); - } - finally - { - TestPluginCache.Instance = null; - } + // Also verify that we have waited for client connection. + _mockRequestSender.Verify(s => s.InitializeDiscovery(extensions), Times.Once); } - - [TestMethod] - public void DiscoverTestsShouldInitializeExtensionsWithExistingExtensionsOnly() + finally { - var inputExtensions = new[] { "abc.TestAdapter.dll", "def.TestAdapter.dll", "xyz.TestAdapter.dll" }; - var expectedOutputPaths = new[] { "abc.TestAdapter.dll", "xyz.TestAdapter.dll" }; + TestPluginCache.Instance = null; + } + } - TestPluginCacheHelper.SetupMockAdditionalPathExtensions(inputExtensions); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - this.mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns((IEnumerable sources, IEnumerable extensions) => - { - return extensions.Select(extension => { return Path.GetFileName(extension); }); - }); + [TestMethod] + public void DiscoverTestsShouldInitializeExtensionsWithExistingExtensionsOnly() + { + var inputExtensions = new[] { "abc.TestAdapter.dll", "def.TestAdapter.dll", "xyz.TestAdapter.dll" }; + var expectedOutputPaths = new[] { "abc.TestAdapter.dll", "xyz.TestAdapter.dll" }; - this.mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns((string extensionPath) => - { - return !extensionPath.Contains("def.TestAdapter.dll"); - }); + TestPluginCacheHelper.SetupMockAdditionalPathExtensions(inputExtensions); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + _mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns((IEnumerable sources, IEnumerable extensions) => extensions.Select(extension => Path.GetFileName(extension))); - this.mockFileHelper.Setup(fh => fh.Exists("def.TestAdapter.dll")).Returns(false); - this.mockFileHelper.Setup(fh => fh.Exists("xyz.TestAdapter.dll")).Returns(true); + _mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns((string extensionPath) => !extensionPath.Contains("def.TestAdapter.dll")); - var mockTestDiscoveryEventHandler = new Mock(); - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, mockTestDiscoveryEventHandler.Object); + _mockFileHelper.Setup(fh => fh.Exists("def.TestAdapter.dll")).Returns(false); + _mockFileHelper.Setup(fh => fh.Exists("xyz.TestAdapter.dll")).Returns(true); - this.mockRequestSender.Verify(s => s.InitializeDiscovery(expectedOutputPaths), Times.Once); - } + var mockTestDiscoveryEventHandler = new Mock(); + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, mockTestDiscoveryEventHandler.Object); + + _mockRequestSender.Verify(s => s.InitializeDiscovery(expectedOutputPaths), Times.Once); + } - [TestMethod] - public void DiscoverTestsShouldQueryTestHostManagerForExtensions() + [TestMethod] + public void DiscoverTestsShouldQueryTestHostManagerForExtensions() + { + TestPluginCache.Instance = null; + try { - TestPluginCache.Instance = null; - try - { - TestPluginCacheHelper.SetupMockAdditionalPathExtensions(new[] { "c:\\e1.dll" }); - this.mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - this.mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new[] { "he1.dll", "c:\\e1.dll" }); + TestPluginCacheHelper.SetupMockAdditionalPathExtensions(new[] { "c:\\e1.dll" }); + _mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + _mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new[] { "he1.dll", "c:\\e1.dll" }); - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, null); + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, null); - this.mockRequestSender.Verify(s => s.InitializeDiscovery(new[] { "he1.dll", "c:\\e1.dll" }), Times.Once); - } - finally - { - TestPluginCache.Instance = null; - } + _mockRequestSender.Verify(s => s.InitializeDiscovery(new[] { "he1.dll", "c:\\e1.dll" }), Times.Once); } + finally + { + TestPluginCache.Instance = null; + } + } - [TestMethod] - public void DiscoverTestsShouldPassAdapterToTestHostManagerFromTestPluginCacheExtensions() + [TestMethod] + public void DiscoverTestsShouldPassAdapterToTestHostManagerFromTestPluginCacheExtensions() + { + // We are updating extension with test adapter only to make it easy to test. + // In product code it filter out test adapter from extension + TestPluginCache.Instance.UpdateExtensions(new List { "abc.TestAdapter.dll", "xyz.TestAdapter.dll" }, false); + try { - // We are updating extension with test adapter only to make it easy to test. - // In product code it filter out test adapter from extension - TestPluginCache.Instance.UpdateExtensions(new List { "abc.TestAdapter.dll", "xyz.TestAdapter.dll" }, false); - try - { - this.mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - var expectedResult = TestPluginCache.Instance.GetExtensionPaths(string.Empty); + _mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + var expectedResult = TestPluginCache.Instance.GetExtensionPaths(string.Empty); - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, null); + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, null); - this.mockTestHostManager.Verify(th => th.GetTestPlatformExtensions(It.IsAny>(), expectedResult), Times.Once); - } - finally - { - TestPluginCache.Instance = null; - } + _mockTestHostManager.Verify(th => th.GetTestPlatformExtensions(It.IsAny>(), expectedResult), Times.Once); } - - [TestMethod] - public void DiscoverTestsShouldNotInitializeDefaultAdaptersIfSkipDefaultAdaptersIsTrue() + finally { - InvokeAndVerifyDiscoverTests(true); + TestPluginCache.Instance = null; } + } - [TestMethod] - public void DiscoverTestsShouldInitializeDefaultAdaptersIfSkipDefaultAdaptersIsFalse() - { - InvokeAndVerifyDiscoverTests(false); - } + [TestMethod] + public void DiscoverTestsShouldNotInitializeDefaultAdaptersIfSkipDefaultAdaptersIsTrue() + { + InvokeAndVerifyDiscoverTests(true); + } - [TestMethod] - public void DiscoverTestsShouldNotIntializeTestHost() - { - // Setup mocks. - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + [TestMethod] + public void DiscoverTestsShouldInitializeDefaultAdaptersIfSkipDefaultAdaptersIsFalse() + { + InvokeAndVerifyDiscoverTests(false); + } - // Act. - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, null); + [TestMethod] + public void DiscoverTestsShouldNotIntializeTestHost() + { + // Setup mocks. + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - this.mockRequestSender.Verify(s => s.InitializeCommunication(), Times.Once); - this.mockTestHostManager.Verify(thl => thl.LaunchTestHostAsync(It.IsAny(), It.IsAny()), Times.Once); - } + // Act. + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, null); - [TestMethod] - public void DiscoverTestsShouldCatchExceptionAndCallHandleDiscoveryComplete() - { - // Setup mocks. - Mock mockTestDiscoveryEventsHandler = new Mock(); - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); + _mockRequestSender.Verify(s => s.InitializeCommunication(), Times.Once); + _mockTestHostManager.Verify(thl => thl.LaunchTestHostAsync(It.IsAny(), It.IsAny()), Times.Once); + } - // Act. - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, mockTestDiscoveryEventsHandler.Object); + [TestMethod] + public void DiscoverTestsShouldCatchExceptionAndCallHandleDiscoveryComplete() + { + // Setup mocks. + Mock mockTestDiscoveryEventsHandler = new(); + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); - // Verify - mockTestDiscoveryEventsHandler.Verify(s => s.HandleDiscoveryComplete(It.IsAny(), It.IsAny>())); - mockTestDiscoveryEventsHandler.Verify(s => s.HandleRawMessage(It.IsAny())); - mockTestDiscoveryEventsHandler.Verify(s => s.HandleLogMessage(TestMessageLevel.Error, It.IsAny())); - } + // Act. + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, mockTestDiscoveryEventsHandler.Object); - [TestMethod] - public void DiscoverTestsShouldCatchExceptionAndCallHandleRawMessageOfDiscoveryComplete() - { - // Setup mocks. - Mock mockTestDiscoveryEventsHandler = new Mock(); - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); + // Verify + mockTestDiscoveryEventsHandler.Verify(s => s.HandleDiscoveryComplete(It.IsAny(), It.IsAny>())); + mockTestDiscoveryEventsHandler.Verify(s => s.HandleRawMessage(It.IsAny())); + mockTestDiscoveryEventsHandler.Verify(s => s.HandleLogMessage(TestMessageLevel.Error, It.IsAny())); + } - this.mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.TestMessage, It.IsAny())).Returns(MessageType.TestMessage); - this.mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.DiscoveryComplete, It.IsAny())).Returns(MessageType.DiscoveryComplete); + [TestMethod] + public void DiscoverTestsShouldCatchExceptionAndCallHandleRawMessageOfDiscoveryComplete() + { + // Setup mocks. + Mock mockTestDiscoveryEventsHandler = new(); + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); + + _mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.TestMessage, It.IsAny())).Returns(MessageType.TestMessage); + _mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.DiscoveryComplete, It.IsAny())).Returns(MessageType.DiscoveryComplete); - this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns((string rawMessage) => + _mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns((string rawMessage) => + { + var messageType = rawMessage.Contains(MessageType.DiscoveryComplete) ? MessageType.DiscoveryComplete : MessageType.TestMessage; + var message = new Message { - var messageType = rawMessage.Contains(MessageType.DiscoveryComplete) ? MessageType.DiscoveryComplete : MessageType.TestMessage; - var message = new Message - { - MessageType = messageType - }; + MessageType = messageType + }; - return message; - }); + return message; + }); - // Act. - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, mockTestDiscoveryEventsHandler.Object); + // Act. + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, mockTestDiscoveryEventsHandler.Object); - // Verify - mockTestDiscoveryEventsHandler.Verify(s => s.HandleRawMessage(It.Is(str => str.Contains(MessageType.DiscoveryComplete))), Times.Once); - } + // Verify + mockTestDiscoveryEventsHandler.Verify(s => s.HandleRawMessage(It.Is(str => str.Contains(MessageType.DiscoveryComplete))), Times.Once); + } - [TestMethod] - public void DiscoverTestsShouldCatchExceptionAndCallHandleRawMessageOfTestMessage() - { - // Setup mocks. - Mock mockTestDiscoveryEventsHandler = new Mock(); - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); + [TestMethod] + public void DiscoverTestsShouldCatchExceptionAndCallHandleRawMessageOfTestMessage() + { + // Setup mocks. + Mock mockTestDiscoveryEventsHandler = new(); + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); - this.mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.TestMessage, It.IsAny())).Returns(MessageType.TestMessage); - this.mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.DiscoveryComplete, It.IsAny())).Returns(MessageType.DiscoveryComplete); + _mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.TestMessage, It.IsAny())).Returns(MessageType.TestMessage); + _mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.DiscoveryComplete, It.IsAny())).Returns(MessageType.DiscoveryComplete); - this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns((string rawMessage) => + _mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns((string rawMessage) => + { + var messageType = rawMessage.Contains(MessageType.DiscoveryComplete) ? MessageType.DiscoveryComplete : MessageType.TestMessage; + var message = new Message { - var messageType = rawMessage.Contains(MessageType.DiscoveryComplete) ? MessageType.DiscoveryComplete : MessageType.TestMessage; - var message = new Message - { - MessageType = messageType - }; + MessageType = messageType + }; - return message; - }); + return message; + }); - // Act. - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, mockTestDiscoveryEventsHandler.Object); + // Act. + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, mockTestDiscoveryEventsHandler.Object); - // Verify - mockTestDiscoveryEventsHandler.Verify(s => s.HandleRawMessage(It.Is(str => str.Contains(MessageType.TestMessage))), Times.Once); - } + // Verify + mockTestDiscoveryEventsHandler.Verify(s => s.HandleRawMessage(It.Is(str => str.Contains(MessageType.TestMessage))), Times.Once); + } - [TestMethod] - public void DiscoverTestsShouldCatchExceptionAndCallHandleLogMessageOfError() - { - // Setup mocks. - Mock mockTestDiscoveryEventsHandler = new Mock(); - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); + [TestMethod] + public void DiscoverTestsShouldCatchExceptionAndCallHandleLogMessageOfError() + { + // Setup mocks. + Mock mockTestDiscoveryEventsHandler = new(); + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); - // Act. - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, mockTestDiscoveryEventsHandler.Object); + // Act. + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, mockTestDiscoveryEventsHandler.Object); - // Verify - mockTestDiscoveryEventsHandler.Verify(s => s.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); - } + // Verify + mockTestDiscoveryEventsHandler.Verify(s => s.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); + } - [TestMethod] - public void DiscoverTestsShouldInitiateServerDiscoveryLoop() - { - // Setup mocks. - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + [TestMethod] + public void DiscoverTestsShouldInitiateServerDiscoveryLoop() + { + // Setup mocks. + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + _mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - // Act. - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, null); + // Act. + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, null); - // Assert. - this.mockRequestSender.Verify(s => s.DiscoverTests(It.IsAny(), this.testDiscoveryManager), Times.Once); - } + // Assert. + _mockRequestSender.Verify(s => s.DiscoverTests(It.IsAny(), _testDiscoveryManager), Times.Once); + } - [TestMethod] - public void DiscoverTestsCloseTestHostIfRawMessageIsOfTypeDiscoveryComplete() - { - Mock mockTestDiscoveryEventsHandler = new Mock(); + [TestMethod] + public void DiscoverTestsCloseTestHostIfRawMessageIsOfTypeDiscoveryComplete() + { + Mock mockTestDiscoveryEventsHandler = new(); - this.mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.TestMessage, It.IsAny())).Returns(MessageType.TestMessage); - this.mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.DiscoveryComplete, It.IsAny())).Returns(MessageType.DiscoveryComplete); + _mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.TestMessage, It.IsAny())).Returns(MessageType.TestMessage); + _mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.DiscoveryComplete, It.IsAny())).Returns(MessageType.DiscoveryComplete); - this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns((string rawMessage) => + _mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns((string rawMessage) => + { + var messageType = rawMessage.Contains(MessageType.DiscoveryComplete) ? MessageType.DiscoveryComplete : MessageType.TestMessage; + var message = new Message { - var messageType = rawMessage.Contains(MessageType.DiscoveryComplete) ? MessageType.DiscoveryComplete : MessageType.TestMessage; - var message = new Message - { - MessageType = messageType - }; + MessageType = messageType + }; - return message; - }); + return message; + }); - // Act. - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, mockTestDiscoveryEventsHandler.Object); + // Act. + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, mockTestDiscoveryEventsHandler.Object); - // Verify - this.mockTestHostManager.Verify(mthm => mthm.CleanTestHostAsync(It.IsAny()), Times.Once); - } + // Verify + _mockTestHostManager.Verify(mthm => mthm.CleanTestHostAsync(It.IsAny()), Times.Once); + } - [TestMethod] - public void DiscoverTestsShouldNotCloseTestHostIfRawMessageIsNotOfTypeDiscoveryComplete() - { - Mock mockTestDiscoveryEventsHandler = new Mock(); + [TestMethod] + public void DiscoverTestsShouldNotCloseTestHostIfRawMessageIsNotOfTypeDiscoveryComplete() + { + Mock mockTestDiscoveryEventsHandler = new(); - this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns(() => + _mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns(() => + { + var message = new Message { - var message = new Message - { - MessageType = MessageType.DiscoveryInitialize - }; + MessageType = MessageType.DiscoveryInitialize + }; - return message; - }); + return message; + }); - // Act. - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, mockTestDiscoveryEventsHandler.Object); + // Act. + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, mockTestDiscoveryEventsHandler.Object); - // Verify - this.mockTestHostManager.Verify(mthm => mthm.CleanTestHostAsync(It.IsAny()), Times.Never); - } + // Verify + _mockTestHostManager.Verify(mthm => mthm.CleanTestHostAsync(It.IsAny()), Times.Never); + } - [TestMethod] - public void DiscoveryManagerShouldPassOnHandleDiscoveredTests() - { - Mock mockTestDiscoveryEventsHandler = new Mock(); - var testCases = new List() { new TestCase("x.y.z", new Uri("x://y"), "x.dll") }; + [TestMethod] + public void DiscoveryManagerShouldPassOnHandleDiscoveredTests() + { + Mock mockTestDiscoveryEventsHandler = new(); + var testCases = new List() { new TestCase("x.y.z", new Uri("x://y"), "x.dll") }; - this.testDiscoveryManager = this.GetProxyDiscoveryManager(); - this.SetupChannelMessage(MessageType.StartDiscovery, MessageType.TestCasesFound, testCases); + _testDiscoveryManager = GetProxyDiscoveryManager(); + SetupChannelMessage(MessageType.StartDiscovery, MessageType.TestCasesFound, testCases); - var completePayload = new DiscoveryCompletePayload() + var completePayload = new DiscoveryCompletePayload() + { + IsAborted = false, + LastDiscoveredTests = null, + TotalTests = 1 + }; + var completeMessage = new Message() { MessageType = MessageType.DiscoveryComplete, Payload = null }; + mockTestDiscoveryEventsHandler.Setup(mh => mh.HandleDiscoveredTests(It.IsAny>())).Callback( + () => { - IsAborted = false, - LastDiscoveredTests = null, - TotalTests = 1 - }; - var completeMessage = new Message() { MessageType = MessageType.DiscoveryComplete, Payload = null }; - mockTestDiscoveryEventsHandler.Setup(mh => mh.HandleDiscoveredTests(It.IsAny>())).Callback( - () => - { - this.mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.IsAny())).Returns(completeMessage); - this.mockDataSerializer.Setup(ds => ds.DeserializePayload(completeMessage)).Returns(completePayload); - }); - - // Act. - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, mockTestDiscoveryEventsHandler.Object); - - // Verify - mockTestDiscoveryEventsHandler.Verify(mtdeh => mtdeh.HandleDiscoveredTests(It.IsAny>()), Times.AtLeastOnce); - } + _mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.IsAny())).Returns(completeMessage); + _mockDataSerializer.Setup(ds => ds.DeserializePayload(completeMessage)).Returns(completePayload); + }); - [TestMethod] - public void DiscoveryManagerShouldPassOnHandleLogMessage() - { - Mock mockTestDiscoveryEventsHandler = new Mock(); + // Act. + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, mockTestDiscoveryEventsHandler.Object); + + // Verify + mockTestDiscoveryEventsHandler.Verify(mtdeh => mtdeh.HandleDiscoveredTests(It.IsAny>()), Times.AtLeastOnce); + } - this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns(() => + [TestMethod] + public void DiscoveryManagerShouldPassOnHandleLogMessage() + { + Mock mockTestDiscoveryEventsHandler = new(); + + _mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns(() => + { + var message = new Message { - var message = new Message - { - MessageType = MessageType.TestMessage - }; + MessageType = MessageType.TestMessage + }; - return message; - }); + return message; + }); - // Act. - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, mockTestDiscoveryEventsHandler.Object); + // Act. + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, mockTestDiscoveryEventsHandler.Object); - // Verify - mockTestDiscoveryEventsHandler.Verify(mtdeh => mtdeh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once); - } + // Verify + mockTestDiscoveryEventsHandler.Verify(mtdeh => mtdeh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once); + } - [TestMethod] - public void AbortShouldSendTestDiscoveryCancelIfCommunicationSuccessful() - { - var mockTestDiscoveryEventsHandler = new Mock(); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + [TestMethod] + public void AbortShouldSendTestDiscoveryCancelIfCommunicationSuccessful() + { + var mockTestDiscoveryEventsHandler = new Mock(); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - Mock mockTestRunEventsHandler = new Mock(); + Mock mockTestRunEventsHandler = new(); - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, mockTestDiscoveryEventsHandler.Object); + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, mockTestDiscoveryEventsHandler.Object); - this.testDiscoveryManager.Abort(); + _testDiscoveryManager.Abort(); - this.mockRequestSender.Verify(s => s.EndSession(), Times.Once); - } + _mockRequestSender.Verify(s => s.EndSession(), Times.Once); + } - [TestMethod] - public void StartTestRunShouldAttemptToTakeProxyFromPoolIfProxyIsNull() - { - var testSessionInfo = new TestSessionInfo(); + [TestMethod] + public void StartTestRunShouldAttemptToTakeProxyFromPoolIfProxyIsNull() + { + var testSessionInfo = new TestSessionInfo(); - Func + Func proxyOperationManagerCreator = ( string source, ProxyDiscoveryManager proxyDiscoveryManager) => @@ -521,115 +515,114 @@ public void StartTestRunShouldAttemptToTakeProxyFromPoolIfProxyIsNull() var proxyOperationManager = TestSessionPool.Instance.TryTakeProxy( testSessionInfo, source, - discoveryCriteria.RunSettings); + _discoveryCriteria.RunSettings); return proxyOperationManager; }; - var testDiscoveryManager = new ProxyDiscoveryManager( - testSessionInfo, - proxyOperationManagerCreator); + var testDiscoveryManager = new ProxyDiscoveryManager( + testSessionInfo, + proxyOperationManagerCreator); - var mockTestSessionPool = new Mock(); - TestSessionPool.Instance = mockTestSessionPool.Object; + var mockTestSessionPool = new Mock(); + TestSessionPool.Instance = mockTestSessionPool.Object; - try - { - var mockProxyOperationManager = new Mock( - this.mockRequestData.Object, - this.mockRequestSender.Object, - this.mockTestHostManager.Object); - mockTestSessionPool.Setup( + try + { + var mockProxyOperationManager = new Mock( + _mockRequestData.Object, + _mockRequestSender.Object, + _mockTestHostManager.Object); + mockTestSessionPool.Setup( tsp => tsp.TryTakeProxy( testSessionInfo, It.IsAny(), It.IsAny())) - .Returns(mockProxyOperationManager.Object); + .Returns(mockProxyOperationManager.Object); - testDiscoveryManager.Initialize(true); - testDiscoveryManager.DiscoverTests( - discoveryCriteria, - new Mock().Object); + testDiscoveryManager.Initialize(true); + testDiscoveryManager.DiscoverTests( + _discoveryCriteria, + new Mock().Object); - mockTestSessionPool.Verify( - tsp => tsp.TryTakeProxy( - testSessionInfo, - It.IsAny(), - It.IsAny()), - Times.Once); - } - finally - { - TestSessionPool.Instance = null; - } + mockTestSessionPool.Verify( + tsp => tsp.TryTakeProxy( + testSessionInfo, + It.IsAny(), + It.IsAny()), + Times.Once); } - - private void InvokeAndVerifyDiscoverTests(bool skipDefaultAdapters) + finally { - TestPluginCache.Instance = null; - TestPluginCache.Instance.DefaultExtensionPaths = new List { "default1.dll", "default2.dll" }; - TestPluginCache.Instance.UpdateExtensions(new List { "filterTestAdapter.dll" }, false); - TestPluginCache.Instance.UpdateExtensions(new List { "unfilter.dll" }, true); + TestSessionPool.Instance = null; + } + } - try - { - this.mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - this.mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns((IEnumerable sources, IEnumerable extensions) => extensions); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - var expectedResult = TestPluginCache.Instance.GetExtensionPaths(TestPlatformConstants.TestAdapterEndsWithPattern, skipDefaultAdapters); + private void InvokeAndVerifyDiscoverTests(bool skipDefaultAdapters) + { + TestPluginCache.Instance = null; + TestPluginCache.Instance.DefaultExtensionPaths = new List { "default1.dll", "default2.dll" }; + TestPluginCache.Instance.UpdateExtensions(new List { "filterTestAdapter.dll" }, false); + TestPluginCache.Instance.UpdateExtensions(new List { "unfilter.dll" }, true); - this.testDiscoveryManager.Initialize(skipDefaultAdapters); - this.testDiscoveryManager.DiscoverTests(this.discoveryCriteria, null); + try + { + _mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + _mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns((IEnumerable sources, IEnumerable extensions) => extensions); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + var expectedResult = TestPluginCache.Instance.GetExtensionPaths(TestPlatformConstants.TestAdapterEndsWithPattern, skipDefaultAdapters); - this.mockRequestSender.Verify(s => s.InitializeDiscovery(expectedResult), Times.Once); - } - finally - { - TestPluginCache.Instance = null; - } - } + _testDiscoveryManager.Initialize(skipDefaultAdapters); + _testDiscoveryManager.DiscoverTests(_discoveryCriteria, null); - //private void SetupAndInitializeTestRequestSender() - //{ - // var connectionInfo = new TestHostConnectionInfo - // { - // Endpoint = IPAddress.Loopback + ":0", - // Role = ConnectionRole.Client, - // Transport = Transport.Sockets - // }; - - // this.mockCommunicationEndpoint = new Mock(); - // this.mockDataSerializer = new Mock(); - // this.testRequestSender = new TestRequestSender(this.mockCommunicationEndpoint.Object, connectionInfo, this.mockDataSerializer.Object, this.protocolConfig, CLIENTPROCESSEXITWAIT); - // this.mockCommunicationEndpoint.Setup(mc => mc.Start(connectionInfo.Endpoint)).Returns(connectionInfo.Endpoint).Callback(() => - // { - // this.mockCommunicationEndpoint.Raise( - // s => s.Connected += null, - // this.mockCommunicationEndpoint.Object, - // new ConnectedEventArgs(this.mockChannel.Object)); - // }); - // this.SetupChannelMessage(MessageType.VersionCheck, MessageType.VersionCheck, this.protocolConfig.Version); - // this.testRequestSender.InitializeCommunication(); - - // this.testDiscoveryManager = new ProxyDiscoveryManager( - // this.mockRequestData.Object, - // this.testRequestSender, - // this.mockTestHostManager.Object, - // this.mockDataSerializer.Object, - // this.testableClientConnectionTimeout); - //} - - //private void SetupChannelMessage(string messageType, string returnMessageType, TPayload returnPayload) - //{ - // this.mockChannel.Setup(mc => mc.Send(It.Is(s => s.Contains(messageType)))) - // .Callback(() => this.mockChannel.Raise(c => c.MessageReceived += null, this.mockChannel.Object, new MessageReceivedEventArgs { Data = messageType })); - - // this.mockDataSerializer.Setup(ds => ds.SerializePayload(It.Is(s => s.Equals(messageType)), It.IsAny())).Returns(messageType); - // this.mockDataSerializer.Setup(ds => ds.SerializePayload(It.Is(s => s.Equals(messageType)), It.IsAny(), It.IsAny())).Returns(messageType); - // this.mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.Is(s => s.Equals(messageType)))) - // .Returns(new Message { MessageType = returnMessageType }); - // this.mockDataSerializer.Setup(ds => ds.DeserializePayload(It.Is(m => m.MessageType.Equals(messageType)))) - // .Returns(returnPayload); - //} + _mockRequestSender.Verify(s => s.InitializeDiscovery(expectedResult), Times.Once); + } + finally + { + TestPluginCache.Instance = null; + } } -} + + //private void SetupAndInitializeTestRequestSender() + //{ + // var connectionInfo = new TestHostConnectionInfo + // { + // Endpoint = IPAddress.Loopback + ":0", + // Role = ConnectionRole.Client, + // Transport = Transport.Sockets + // }; + + // this.mockCommunicationEndpoint = new Mock(); + // this.mockDataSerializer = new Mock(); + // this.testRequestSender = new TestRequestSender(this.mockCommunicationEndpoint.Object, connectionInfo, this.mockDataSerializer.Object, this.protocolConfig, CLIENTPROCESSEXITWAIT); + // this.mockCommunicationEndpoint.Setup(mc => mc.Start(connectionInfo.Endpoint)).Returns(connectionInfo.Endpoint).Callback(() => + // { + // this.mockCommunicationEndpoint.Raise( + // s => s.Connected += null, + // this.mockCommunicationEndpoint.Object, + // new ConnectedEventArgs(this.mockChannel.Object)); + // }); + // this.SetupChannelMessage(MessageType.VersionCheck, MessageType.VersionCheck, this.protocolConfig.Version); + // this.testRequestSender.InitializeCommunication(); + + // this.testDiscoveryManager = new ProxyDiscoveryManager( + // this.mockRequestData.Object, + // this.testRequestSender, + // this.mockTestHostManager.Object, + // this.mockDataSerializer.Object, + // this.testableClientConnectionTimeout); + //} + + //private void SetupChannelMessage(string messageType, string returnMessageType, TPayload returnPayload) + //{ + // this.mockChannel.Setup(mc => mc.Send(It.Is(s => s.Contains(messageType)))) + // .Callback(() => this.mockChannel.Raise(c => c.MessageReceived += null, this.mockChannel.Object, new MessageReceivedEventArgs { Data = messageType })); + + // this.mockDataSerializer.Setup(ds => ds.SerializePayload(It.Is(s => s.Equals(messageType)), It.IsAny())).Returns(messageType); + // this.mockDataSerializer.Setup(ds => ds.SerializePayload(It.Is(s => s.Equals(messageType)), It.IsAny(), It.IsAny())).Returns(messageType); + // this.mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.Is(s => s.Equals(messageType)))) + // .Returns(new Message { MessageType = returnMessageType }); + // this.mockDataSerializer.Setup(ds => ds.DeserializePayload(It.Is(m => m.MessageType.Equals(messageType)))) + // .Returns(returnPayload); + //} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs index dfe854a27e..6b83d9d7ac 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs @@ -1,754 +1,738 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Client +namespace TestPlatform.CrossPlatEngine.UnitTests.Client; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.Common; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +using CrossPlatEngineResources = Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; + +[TestClass] +public class ProxyExecutionManagerTests : ProxyBaseManagerTests { - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Threading; - using System.Threading.Tasks; + private readonly Mock _mockRequestSender; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; + private readonly Mock _mockTestRunCriteria; - using Moq; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + private readonly Mock _mockRequestData; - using CrossPlatEngineResources = Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; + private readonly Mock _mockMetricsCollection; - [TestClass] - public class ProxyExecutionManagerTests : ProxyBaseManagerTests - { - private readonly Mock mockRequestSender; + private readonly Mock _mockFileHelper; - private readonly Mock mockTestRunCriteria; + private ProxyExecutionManager _testExecutionManager; - private readonly Mock mockRequestData; + //private Mock mockDataSerializer; - private Mock mockMetricsCollection; + public ProxyExecutionManagerTests() + { + _mockRequestSender = new Mock(); + _mockTestRunCriteria = new Mock(new List { "source.dll" }, 10); + //this.mockDataSerializer = new Mock(); + _mockRequestData = new Mock(); + _mockMetricsCollection = new Mock(); + _mockFileHelper = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(_mockMetricsCollection.Object); + + _testExecutionManager = new ProxyExecutionManager(_mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object, _mockDataSerializer.Object, _mockFileHelper.Object); + + //this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(null)).Returns(new Message()); + //this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(string.Empty)).Returns(new Message()); + } - private Mock mockFileHelper; + [TestMethod] + public void StartTestRunShouldNotInitializeExtensionsOnNoExtensions() + { + // Make sure TestPlugincache is refreshed. + TestPluginCache.Instance = null; - private ProxyExecutionManager testExecutionManager; + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - //private Mock mockDataSerializer; + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, null); - public ProxyExecutionManagerTests() - { - this.mockRequestSender = new Mock(); - this.mockTestRunCriteria = new Mock(new List { "source.dll" }, 10); - //this.mockDataSerializer = new Mock(); - this.mockRequestData = new Mock(); - this.mockMetricsCollection = new Mock(); - this.mockFileHelper = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(this.mockMetricsCollection.Object); - - this.testExecutionManager = new ProxyExecutionManager(this.mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object, this.mockDataSerializer.Object, this.mockFileHelper.Object); - - //this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(null)).Returns(new Message()); - //this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(string.Empty)).Returns(new Message()); - } + _mockRequestSender.Verify(s => s.InitializeExecution(It.IsAny>()), Times.Never); + } - [TestMethod] - public void StartTestRunShouldNotInitializeExtensionsOnNoExtensions() - { - // Make sure TestPlugincache is refreshed. - TestPluginCache.Instance = null; + [TestMethod] + public void StartTestRunShouldAllowRuntimeProviderToUpdateAdapterSource() + { + // Make sure TestPlugincache is refreshed. + TestPluginCache.Instance = null; - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + _mockTestHostManager.Setup(hm => hm.GetTestSources(_mockTestRunCriteria.Object.Sources)).Returns(_mockTestRunCriteria.Object.Sources); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, null); + Mock mockTestRunEventsHandler = new(); - this.mockRequestSender.Verify(s => s.InitializeExecution(It.IsAny>()), Times.Never); - } + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); - [TestMethod] - public void StartTestRunShouldAllowRuntimeProviderToUpdateAdapterSource() - { - // Make sure TestPlugincache is refreshed. - TestPluginCache.Instance = null; + _mockTestHostManager.Verify(hm => hm.GetTestSources(_mockTestRunCriteria.Object.Sources), Times.Once); + } - this.mockTestHostManager.Setup(hm => hm.GetTestSources(this.mockTestRunCriteria.Object.Sources)).Returns(this.mockTestRunCriteria.Object.Sources); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + [TestMethod] + public void StartTestRunShouldUpdateTestCaseSourceIfTestCaseSourceDiffersFromTestHostManagerSource() + { + var actualSources = new List { "actualSource.dll" }; + var inputSource = new List { "inputPackage.appxrecipe" }; - Mock mockTestRunEventsHandler = new Mock(); + var testRunCriteria = new TestRunCriteria( + new List { new TestCase("A.C.M", new Uri("excutor://dummy"), inputSource.FirstOrDefault()) }, + frequencyOfRunStatsChangeEvent: 10); - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); + _mockTestHostManager.Setup(hm => hm.GetTestSources(inputSource)).Returns(actualSources); + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(true)); + _mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new List()); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + Mock mockTestRunEventsHandler = new(); - this.mockTestHostManager.Verify(hm => hm.GetTestSources(this.mockTestRunCriteria.Object.Sources), Times.Once); - } + _testExecutionManager.StartTestRun(testRunCriteria, mockTestRunEventsHandler.Object); - [TestMethod] - public void StartTestRunShouldUpdateTestCaseSourceIfTestCaseSourceDiffersFromTestHostManagerSource() - { - var actualSources = new List { "actualSource.dll" }; - var inputSource = new List { "inputPackage.appxrecipe" }; + _mockTestHostManager.Verify(hm => hm.GetTestSources(inputSource), Times.Once); + Assert.AreEqual(actualSources.FirstOrDefault(), testRunCriteria.Tests.FirstOrDefault().Source); + } - var testRunCriteria = new TestRunCriteria( - new List { new TestCase("A.C.M", new Uri("excutor://dummy"), inputSource.FirstOrDefault()) }, - frequencyOfRunStatsChangeEvent: 10); + [TestMethod] + public void StartTestRunShouldNotUpdateTestCaseSourceIfTestCaseSourceDoNotDifferFromTestHostManagerSource() + { + var actualSources = new List { "actualSource.dll" }; + var inputSource = new List { "actualSource.dll" }; - this.mockTestHostManager.Setup(hm => hm.GetTestSources(inputSource)).Returns(actualSources); - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(true)); - this.mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new List()); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - Mock mockTestRunEventsHandler = new Mock(); + var testRunCriteria = new TestRunCriteria( + new List { new TestCase("A.C.M", new Uri("excutor://dummy"), inputSource.FirstOrDefault()) }, + frequencyOfRunStatsChangeEvent: 10); - this.testExecutionManager.StartTestRun(testRunCriteria, mockTestRunEventsHandler.Object); + _mockTestHostManager.Setup(hm => hm.GetTestSources(inputSource)).Returns(actualSources); + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(true)); + _mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new List()); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + Mock mockTestRunEventsHandler = new(); - this.mockTestHostManager.Verify(hm => hm.GetTestSources(inputSource), Times.Once); - Assert.AreEqual(actualSources.FirstOrDefault(), testRunCriteria.Tests.FirstOrDefault().Source); - } + _testExecutionManager.StartTestRun(testRunCriteria, mockTestRunEventsHandler.Object); - [TestMethod] - public void StartTestRunShouldNotUpdateTestCaseSourceIfTestCaseSourceDoNotDifferFromTestHostManagerSource() - { - var actualSources = new List { "actualSource.dll" }; - var inputSource = new List { "actualSource.dll" }; + _mockTestHostManager.Verify(hm => hm.GetTestSources(inputSource), Times.Once); + Assert.AreEqual(actualSources.FirstOrDefault(), testRunCriteria.Tests.FirstOrDefault().Source); + } - var testRunCriteria = new TestRunCriteria( - new List { new TestCase("A.C.M", new Uri("excutor://dummy"), inputSource.FirstOrDefault()) }, - frequencyOfRunStatsChangeEvent: 10); + [TestMethod] + public void StartTestRunShouldNotInitializeExtensionsOnCommunicationFailure() + { + // Make sure TestPlugincache is refreshed. + TestPluginCache.Instance = null; - this.mockTestHostManager.Setup(hm => hm.GetTestSources(inputSource)).Returns(actualSources); - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(true)); - this.mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new List()); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - Mock mockTestRunEventsHandler = new Mock(); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); - this.testExecutionManager.StartTestRun(testRunCriteria, mockTestRunEventsHandler.Object); + Mock mockTestRunEventsHandler = new(); - this.mockTestHostManager.Verify(hm => hm.GetTestSources(inputSource), Times.Once); - Assert.AreEqual(actualSources.FirstOrDefault(), testRunCriteria.Tests.FirstOrDefault().Source); - } + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); - [TestMethod] - public void StartTestRunShouldNotInitializeExtensionsOnCommunicationFailure() - { - // Make sure TestPlugincache is refreshed. - TestPluginCache.Instance = null; + _mockRequestSender.Verify(s => s.InitializeExecution(It.IsAny>()), Times.Never); + } - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); + [TestMethod] + public void StartTestRunShouldInitializeExtensionsIfPresent() + { + // Make sure TestPlugincache is refreshed. + TestPluginCache.Instance = null; - Mock mockTestRunEventsHandler = new Mock(); + try + { + var extensions = new List() { "C:\\foo.dll" }; + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + _mockTestHostManager.Setup(x => x.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())) + .Returns(extensions); - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, null); - this.mockRequestSender.Verify(s => s.InitializeExecution(It.IsAny>()), Times.Never); + // Also verify that we have waited for client connection. + _mockRequestSender.Verify(s => s.InitializeExecution(extensions), Times.Once); } - - [TestMethod] - public void StartTestRunShouldInitializeExtensionsIfPresent() + finally { - // Make sure TestPlugincache is refreshed. TestPluginCache.Instance = null; + } + } - try - { - var extensions = new List() { "C:\\foo.dll" }; - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - this.mockTestHostManager.Setup(x => x.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())) - .Returns(extensions); + [TestMethod] + public void StartTestRunShouldQueryTestHostManagerForExtensions() + { + TestPluginCache.Instance = null; + try + { + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + _mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new[] { "he1.dll", "c:\\e1.dll" }); - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, null); + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, null); - // Also verify that we have waited for client connection. - this.mockRequestSender.Verify(s => s.InitializeExecution(extensions), Times.Once); - } - finally - { - TestPluginCache.Instance = null; - } + _mockRequestSender.Verify(s => s.InitializeExecution(new[] { "he1.dll", "c:\\e1.dll" }), Times.Once); } - - [TestMethod] - public void StartTestRunShouldQueryTestHostManagerForExtensions() + finally { TestPluginCache.Instance = null; - try - { - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - this.mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new[] { "he1.dll", "c:\\e1.dll" }); - - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, null); - - this.mockRequestSender.Verify(s => s.InitializeExecution(new[] { "he1.dll", "c:\\e1.dll" }), Times.Once); - } - finally - { - TestPluginCache.Instance = null; - } } + } - [TestMethod] - public void StartTestRunShouldPassAdapterToTestHostManagerFromTestPluginCacheExtensions() + [TestMethod] + public void StartTestRunShouldPassAdapterToTestHostManagerFromTestPluginCacheExtensions() + { + // We are updating extension with testadapter only to make it easy to test. + // In product code it filter out testadapter from extension + TestPluginCache.Instance.UpdateExtensions(new List { "abc.TestAdapter.dll", "xyz.TestAdapter.dll" }, false); + try { - // We are updating extension with testadapter only to make it easy to test. - // In product code it filter out testadapter from extension - TestPluginCache.Instance.UpdateExtensions(new List { "abc.TestAdapter.dll", "xyz.TestAdapter.dll" }, false); - try - { - this.mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - var expectedResult = TestPluginCache.Instance.GetExtensionPaths(string.Empty); + _mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + var expectedResult = TestPluginCache.Instance.GetExtensionPaths(string.Empty); - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, null); + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, null); - this.mockTestHostManager.Verify(th => th.GetTestPlatformExtensions(It.IsAny>(), expectedResult), Times.Once); - } - finally - { - TestPluginCache.Instance = null; - } + _mockTestHostManager.Verify(th => th.GetTestPlatformExtensions(It.IsAny>(), expectedResult), Times.Once); } - - [TestMethod] - public void StartTestRunShouldNotInitializeDefaultAdaptersIfSkipDefaultAdaptersIsTrue() + finally { - InvokeAndVerifyStartTestRun(true); + TestPluginCache.Instance = null; } + } - [TestMethod] - public void StartTestRunShouldInitializeDefaultAdaptersIfSkipDefaultAdaptersIsFalse() - { - InvokeAndVerifyStartTestRun(false); - } + [TestMethod] + public void StartTestRunShouldNotInitializeDefaultAdaptersIfSkipDefaultAdaptersIsTrue() + { + InvokeAndVerifyStartTestRun(true); + } - [TestMethod] - public void StartTestRunShouldIntializeTestHost() - { - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + [TestMethod] + public void StartTestRunShouldInitializeDefaultAdaptersIfSkipDefaultAdaptersIsFalse() + { + InvokeAndVerifyStartTestRun(false); + } - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, null); + [TestMethod] + public void StartTestRunShouldIntializeTestHost() + { + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + _mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - this.mockRequestSender.Verify(s => s.InitializeCommunication(), Times.Once); - this.mockTestHostManager.Verify(thl => thl.LaunchTestHostAsync(It.IsAny(), It.IsAny()), Times.Once); - } + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, null); - [TestMethod] - public void StartTestRunShouldNotSendStartTestRunRequestIfCommunicationFails() - { - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())) - .Callback( - () => - { - this.mockTestHostManager.Raise(thm => thm.HostLaunched += null, new HostProviderEventArgs(string.Empty)); - }) - .Returns(Task.FromResult(false)); + _mockRequestSender.Verify(s => s.InitializeCommunication(), Times.Once); + _mockTestHostManager.Verify(thl => thl.LaunchTestHostAsync(It.IsAny(), It.IsAny()), Times.Once); + } - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + [TestMethod] + public void StartTestRunShouldNotSendStartTestRunRequestIfCommunicationFails() + { + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())) + .Callback( + () => _mockTestHostManager.Raise(thm => thm.HostLaunched += null, new HostProviderEventArgs(string.Empty))) + .Returns(Task.FromResult(false)); - // Make sure TestPlugincache is refreshed. - TestPluginCache.Instance = null; + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - Mock mockTestRunEventsHandler = new Mock(); + // Make sure TestPlugincache is refreshed. + TestPluginCache.Instance = null; - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); + Mock mockTestRunEventsHandler = new(); - this.mockRequestSender.Verify(s => s.StartTestRun(It.IsAny(), It.IsAny()), Times.Never); - } + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); - [TestMethod] - public void StartTestRunShouldInitializeExtensionsIfTestHostIsNotShared() - { - TestPluginCache.Instance = null; - this.mockTestHostManager.SetupGet(th => th.Shared).Returns(false); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - this.mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new[] { "x.dll" }); + _mockRequestSender.Verify(s => s.StartTestRun(It.IsAny(), It.IsAny()), Times.Never); + } - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, null); + [TestMethod] + public void StartTestRunShouldInitializeExtensionsIfTestHostIsNotShared() + { + TestPluginCache.Instance = null; + _mockTestHostManager.SetupGet(th => th.Shared).Returns(false); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + _mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns(new[] { "x.dll" }); - this.mockRequestSender.Verify(s => s.InitializeExecution(It.IsAny>()), Times.Once); - } + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, null); - [TestMethod] - public void StartTestRunShouldInitializeExtensionsWithExistingExtensionsOnly() - { - TestPluginCache.Instance = null; - TestPluginCache.Instance.UpdateExtensions(new List { "abc.TestAdapter.dll", "def.TestAdapter.dll", "xyz.TestAdapter.dll" }, false); - var expectedOutputPaths = new[] { "abc.TestAdapter.dll", "xyz.TestAdapter.dll" }; + _mockRequestSender.Verify(s => s.InitializeExecution(It.IsAny>()), Times.Once); + } - this.mockTestHostManager.SetupGet(th => th.Shared).Returns(false); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - this.mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns((IEnumerable sources, IEnumerable extensions) => - { - return extensions.Select(extension => { return Path.GetFileName(extension); }); - }); + [TestMethod] + public void StartTestRunShouldInitializeExtensionsWithExistingExtensionsOnly() + { + TestPluginCache.Instance = null; + TestPluginCache.Instance.UpdateExtensions(new List { "abc.TestAdapter.dll", "def.TestAdapter.dll", "xyz.TestAdapter.dll" }, false); + var expectedOutputPaths = new[] { "abc.TestAdapter.dll", "xyz.TestAdapter.dll" }; - this.mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns((string extensionPath) => - { - return !extensionPath.Contains("def.TestAdapter.dll"); - }); + _mockTestHostManager.SetupGet(th => th.Shared).Returns(false); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + _mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns((IEnumerable sources, IEnumerable extensions) => extensions.Select(extension => Path.GetFileName(extension))); - this.mockFileHelper.Setup(fh => fh.Exists("def.TestAdapter.dll")).Returns(false); - this.mockFileHelper.Setup(fh => fh.Exists("xyz.TestAdapter.dll")).Returns(true); + _mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns((string extensionPath) => !extensionPath.Contains("def.TestAdapter.dll")); - var mockTestRunEventsHandler = new Mock(); - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); + _mockFileHelper.Setup(fh => fh.Exists("def.TestAdapter.dll")).Returns(false); + _mockFileHelper.Setup(fh => fh.Exists("xyz.TestAdapter.dll")).Returns(true); - this.mockRequestSender.Verify(s => s.InitializeExecution(expectedOutputPaths), Times.Once); - } + var mockTestRunEventsHandler = new Mock(); + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); - [TestMethod] - public void SetupChannelShouldThrowExceptionIfClientConnectionTimeout() - { - string runsettings = "\r\n\r\n \r\n {0}\r\n \r\n"; + _mockRequestSender.Verify(s => s.InitializeExecution(expectedOutputPaths), Times.Once); + } - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); + [TestMethod] + public void SetupChannelShouldThrowExceptionIfClientConnectionTimeout() + { + string runsettings = "\r\n\r\n \r\n {0}\r\n \r\n"; - Assert.ThrowsException(() => this.testExecutionManager.SetupChannel(new List { "source.dll" }, runsettings)); - } + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); - [TestMethod] - public void SetupChannelShouldThrowExceptionIfTestHostExitedBeforeConnectionIsEstablished() - { - string runsettings = "\r\n\r\n \r\n {0}\r\n \r\n"; + Assert.ThrowsException(() => _testExecutionManager.SetupChannel(new List { "source.dll" }, runsettings)); + } - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(true)).Callback(() => { this.mockTestHostManager.Raise(t => t.HostExited += null, new HostProviderEventArgs("I crashed!")); }); + [TestMethod] + public void SetupChannelShouldThrowExceptionIfTestHostExitedBeforeConnectionIsEstablished() + { + string runsettings = "\r\n\r\n \r\n {0}\r\n \r\n"; - Assert.AreEqual(string.Format(CrossPlatEngineResources.Resources.TestHostExitedWithError, "I crashed!"), Assert.ThrowsException(() => this.testExecutionManager.SetupChannel(new List { "source.dll" }, runsettings)).Message); - } + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(true)).Callback(() => _mockTestHostManager.Raise(t => t.HostExited += null, new HostProviderEventArgs("I crashed!"))); - [TestMethod] - public void StartTestRunShouldCatchExceptionAndCallHandleTestRunComplete() - { - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); + Assert.AreEqual(string.Format(CrossPlatEngineResources.Resources.TestHostExitedWithError, "I crashed!"), Assert.ThrowsException(() => _testExecutionManager.SetupChannel(new List { "source.dll" }, runsettings)).Message); + } - Mock mockTestRunEventsHandler = new Mock(); + [TestMethod] + public void StartTestRunShouldCatchExceptionAndCallHandleTestRunComplete() + { + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); + Mock mockTestRunEventsHandler = new(); - mockTestRunEventsHandler.Verify(s => s.HandleTestRunComplete(It.Is(t => t.IsAborted == true), null, null, null)); - } + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); - [TestMethod] - public void StartTestRunShouldCatchExceptionAndCallHandleRawMessageOfTestRunComplete() - { - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); + mockTestRunEventsHandler.Verify(s => s.HandleTestRunComplete(It.Is(t => t.IsAborted == true), null, null, null)); + } + + [TestMethod] + public void StartTestRunShouldCatchExceptionAndCallHandleRawMessageOfTestRunComplete() + { + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); - this.mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.TestMessage, It.IsAny())).Returns(MessageType.TestMessage); - this.mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.ExecutionComplete, It.IsAny())).Returns(MessageType.ExecutionComplete); + _mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.TestMessage, It.IsAny())).Returns(MessageType.TestMessage); + _mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.ExecutionComplete, It.IsAny())).Returns(MessageType.ExecutionComplete); - this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns((string rawMessage) => + _mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns((string rawMessage) => + { + var messageType = rawMessage.Contains(MessageType.ExecutionComplete) ? MessageType.ExecutionComplete : MessageType.TestMessage; + var message = new Message { - var messageType = rawMessage.Contains(MessageType.ExecutionComplete) ? MessageType.ExecutionComplete : MessageType.TestMessage; - var message = new Message - { - MessageType = messageType - }; + MessageType = messageType + }; - return message; - }); + return message; + }); - Mock mockTestRunEventsHandler = new Mock(); + Mock mockTestRunEventsHandler = new(); - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); - mockTestRunEventsHandler.Verify(s => s.HandleRawMessage(It.Is(str => str.Contains(MessageType.ExecutionComplete))), Times.Once); - } + mockTestRunEventsHandler.Verify(s => s.HandleRawMessage(It.Is(str => str.Contains(MessageType.ExecutionComplete))), Times.Once); + } - [TestMethod] - public void StartTestRunShouldCatchExceptionAndCallHandleRawMessageOfTestMessage() - { - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); + [TestMethod] + public void StartTestRunShouldCatchExceptionAndCallHandleRawMessageOfTestMessage() + { + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); - this.mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.TestMessage, It.IsAny())).Returns(MessageType.TestMessage); - this.mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.ExecutionComplete, It.IsAny())).Returns(MessageType.ExecutionComplete); + _mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.TestMessage, It.IsAny())).Returns(MessageType.TestMessage); + _mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.ExecutionComplete, It.IsAny())).Returns(MessageType.ExecutionComplete); - this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns((string rawMessage) => + _mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns((string rawMessage) => + { + var messageType = rawMessage.Contains(MessageType.ExecutionComplete) ? MessageType.ExecutionComplete : MessageType.TestMessage; + var message = new Message { - var messageType = rawMessage.Contains(MessageType.ExecutionComplete) ? MessageType.ExecutionComplete : MessageType.TestMessage; - var message = new Message - { - MessageType = messageType - }; + MessageType = messageType + }; - return message; - }); + return message; + }); - Mock mockTestRunEventsHandler = new Mock(); + Mock mockTestRunEventsHandler = new(); - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); - mockTestRunEventsHandler.Verify(s => s.HandleRawMessage(It.Is(str => str.Contains(MessageType.TestMessage)))); - } + mockTestRunEventsHandler.Verify(s => s.HandleRawMessage(It.Is(str => str.Contains(MessageType.TestMessage)))); + } - [TestMethod] - public void StartTestRunShouldCatchExceptionAndCallHandleLogMessageOfError() - { - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); + [TestMethod] + public void StartTestRunShouldCatchExceptionAndCallHandleLogMessageOfError() + { + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); - Mock mockTestRunEventsHandler = new Mock(); + Mock mockTestRunEventsHandler = new(); - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); - mockTestRunEventsHandler.Verify(s => s.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); - } + mockTestRunEventsHandler.Verify(s => s.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); + } - [TestMethod] - public void StartTestRunShouldCatchExceptionAndCallHandleRawMessageAndHandleLogMessage() - { - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); + [TestMethod] + public void StartTestRunShouldCatchExceptionAndCallHandleRawMessageAndHandleLogMessage() + { + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Returns(Task.FromResult(false)); - Mock mockTestRunEventsHandler = new Mock(); + Mock mockTestRunEventsHandler = new(); - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); - mockTestRunEventsHandler.Verify(s => s.HandleRawMessage(It.IsAny())); - mockTestRunEventsHandler.Verify(s => s.HandleLogMessage(TestMessageLevel.Error, It.IsAny())); - } + mockTestRunEventsHandler.Verify(s => s.HandleRawMessage(It.IsAny())); + mockTestRunEventsHandler.Verify(s => s.HandleLogMessage(TestMessageLevel.Error, It.IsAny())); + } - [TestMethod] - public void StartTestRunForCancelRequestShouldHandleLogMessageWithProperErrorMessage() - { - Mock mockTestRunEventsHandler = new Mock(); - this.testExecutionManager.Cancel(mockTestRunEventsHandler.Object); + [TestMethod] + public void StartTestRunForCancelRequestShouldHandleLogMessageWithProperErrorMessage() + { + Mock mockTestRunEventsHandler = new(); + _testExecutionManager.Cancel(mockTestRunEventsHandler.Object); - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); - mockTestRunEventsHandler.Verify(s => s.HandleLogMessage(TestMessageLevel.Error, "Cancelling the operation as requested.")); - } + mockTestRunEventsHandler.Verify(s => s.HandleLogMessage(TestMessageLevel.Error, "Cancelling the operation as requested.")); + } - [TestMethod] - public void StartTestRunForAnExceptionDuringLaunchOfTestShouldHandleLogMessageWithProperErrorMessage() - { - Mock mockTestRunEventsHandler = new Mock(); - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Throws(new Exception("DummyException")); + [TestMethod] + public void StartTestRunForAnExceptionDuringLaunchOfTestShouldHandleLogMessageWithProperErrorMessage() + { + Mock mockTestRunEventsHandler = new(); + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Throws(new Exception("DummyException")); - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); - mockTestRunEventsHandler.Verify(s => s.HandleLogMessage(TestMessageLevel.Error, It.Is(str => str.StartsWith("Failed to launch testhost with error: System.Exception: DummyException")))); - } + mockTestRunEventsHandler.Verify(s => s.HandleLogMessage(TestMessageLevel.Error, It.Is(str => str.StartsWith("Failed to launch testhost with error: System.Exception: DummyException")))); + } - [TestMethod] - public void StartTestRunShouldInitiateTestRunForSourcesThroughTheServer() - { - TestRunCriteriaWithSources testRunCriteriaPassed = null; - this.mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - this.mockRequestSender.Setup(s => s.StartTestRun(It.IsAny(), this.testExecutionManager)) - .Callback( - (TestRunCriteriaWithSources criteria, ITestRunEventsHandler sink) => - { - testRunCriteriaPassed = criteria; - }); - - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, null); - - Assert.IsNotNull(testRunCriteriaPassed); - CollectionAssert.AreEqual(this.mockTestRunCriteria.Object.AdapterSourceMap.Keys, testRunCriteriaPassed.AdapterSourceMap.Keys); - CollectionAssert.AreEqual(this.mockTestRunCriteria.Object.AdapterSourceMap.Values, testRunCriteriaPassed.AdapterSourceMap.Values); - Assert.AreEqual(this.mockTestRunCriteria.Object.FrequencyOfRunStatsChangeEvent, testRunCriteriaPassed.TestExecutionContext.FrequencyOfRunStatsChangeEvent); - Assert.AreEqual(this.mockTestRunCriteria.Object.RunStatsChangeEventTimeout, testRunCriteriaPassed.TestExecutionContext.RunStatsChangeEventTimeout); - Assert.AreEqual(this.mockTestRunCriteria.Object.TestRunSettings, testRunCriteriaPassed.RunSettings); - } + [TestMethod] + public void StartTestRunShouldInitiateTestRunForSourcesThroughTheServer() + { + TestRunCriteriaWithSources testRunCriteriaPassed = null; + _mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + _mockRequestSender.Setup(s => s.StartTestRun(It.IsAny(), _testExecutionManager)) + .Callback( + (TestRunCriteriaWithSources criteria, ITestRunEventsHandler sink) => testRunCriteriaPassed = criteria); + + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, null); + + Assert.IsNotNull(testRunCriteriaPassed); + CollectionAssert.AreEqual(_mockTestRunCriteria.Object.AdapterSourceMap.Keys, testRunCriteriaPassed.AdapterSourceMap.Keys); + CollectionAssert.AreEqual(_mockTestRunCriteria.Object.AdapterSourceMap.Values, testRunCriteriaPassed.AdapterSourceMap.Values); + Assert.AreEqual(_mockTestRunCriteria.Object.FrequencyOfRunStatsChangeEvent, testRunCriteriaPassed.TestExecutionContext.FrequencyOfRunStatsChangeEvent); + Assert.AreEqual(_mockTestRunCriteria.Object.RunStatsChangeEventTimeout, testRunCriteriaPassed.TestExecutionContext.RunStatsChangeEventTimeout); + Assert.AreEqual(_mockTestRunCriteria.Object.TestRunSettings, testRunCriteriaPassed.RunSettings); + } - [TestMethod] - public void StartTestRunShouldInitiateTestRunForTestsThroughTheServer() - { - TestRunCriteriaWithTests testRunCriteriaPassed = null; - this.mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - this.mockRequestSender.Setup(s => s.StartTestRun(It.IsAny(), this.testExecutionManager)) - .Callback( - (TestRunCriteriaWithTests criteria, ITestRunEventsHandler sink) => - { - testRunCriteriaPassed = criteria; - }); - var runCriteria = new Mock( - new List { new TestCase("A.C.M", new System.Uri("executor://dummy"), "source.dll") }, - 10); - - this.testExecutionManager.StartTestRun(runCriteria.Object, null); - - Assert.IsNotNull(testRunCriteriaPassed); - CollectionAssert.AreEqual(runCriteria.Object.Tests.ToList(), testRunCriteriaPassed.Tests.ToList()); - Assert.AreEqual( - runCriteria.Object.FrequencyOfRunStatsChangeEvent, - testRunCriteriaPassed.TestExecutionContext.FrequencyOfRunStatsChangeEvent); - Assert.AreEqual( - runCriteria.Object.RunStatsChangeEventTimeout, - testRunCriteriaPassed.TestExecutionContext.RunStatsChangeEventTimeout); - Assert.AreEqual( - runCriteria.Object.TestRunSettings, - testRunCriteriaPassed.RunSettings); - } + [TestMethod] + public void StartTestRunShouldInitiateTestRunForTestsThroughTheServer() + { + TestRunCriteriaWithTests testRunCriteriaPassed = null; + _mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + _mockRequestSender.Setup(s => s.StartTestRun(It.IsAny(), _testExecutionManager)) + .Callback( + (TestRunCriteriaWithTests criteria, ITestRunEventsHandler sink) => testRunCriteriaPassed = criteria); + var runCriteria = new Mock( + new List { new TestCase("A.C.M", new Uri("executor://dummy"), "source.dll") }, + 10); + + _testExecutionManager.StartTestRun(runCriteria.Object, null); + + Assert.IsNotNull(testRunCriteriaPassed); + CollectionAssert.AreEqual(runCriteria.Object.Tests.ToList(), testRunCriteriaPassed.Tests.ToList()); + Assert.AreEqual( + runCriteria.Object.FrequencyOfRunStatsChangeEvent, + testRunCriteriaPassed.TestExecutionContext.FrequencyOfRunStatsChangeEvent); + Assert.AreEqual( + runCriteria.Object.RunStatsChangeEventTimeout, + testRunCriteriaPassed.TestExecutionContext.RunStatsChangeEventTimeout); + Assert.AreEqual( + runCriteria.Object.TestRunSettings, + testRunCriteriaPassed.RunSettings); + } - [TestMethod] - public void CloseShouldSignalToServerSessionEndIfTestHostWasLaunched() - { - string runsettings = "\r\n\r\n \r\n {0}\r\n \r\n"; + [TestMethod] + public void CloseShouldSignalToServerSessionEndIfTestHostWasLaunched() + { + string runsettings = "\r\n\r\n \r\n {0}\r\n \r\n"; - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - this.testExecutionManager.SetupChannel(new List { "source.dll" }, runsettings); + _testExecutionManager.SetupChannel(new List { "source.dll" }, runsettings); - this.testExecutionManager.Close(); + _testExecutionManager.Close(); - this.mockRequestSender.Verify(s => s.EndSession(), Times.Once); - } + _mockRequestSender.Verify(s => s.EndSession(), Times.Once); + } - [TestMethod] - public void CloseShouldNotSendSignalToServerSessionEndIfTestHostWasNotLaunched() - { - this.testExecutionManager.Close(); + [TestMethod] + public void CloseShouldNotSendSignalToServerSessionEndIfTestHostWasNotLaunched() + { + _testExecutionManager.Close(); - this.mockRequestSender.Verify(s => s.EndSession(), Times.Never); - } + _mockRequestSender.Verify(s => s.EndSession(), Times.Never); + } - [TestMethod] - public void CloseShouldSignalServerSessionEndEachTime() - { - string runsettings = "\r\n\r\n \r\n {0}\r\n \r\n"; + [TestMethod] + public void CloseShouldSignalServerSessionEndEachTime() + { + string runsettings = "\r\n\r\n \r\n {0}\r\n \r\n"; - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - this.testExecutionManager.SetupChannel(new List { "source.dll" }, runsettings); + _testExecutionManager.SetupChannel(new List { "source.dll" }, runsettings); - this.testExecutionManager.Close(); - this.testExecutionManager.Close(); + _testExecutionManager.Close(); + _testExecutionManager.Close(); - this.mockRequestSender.Verify(s => s.EndSession(), Times.Exactly(2)); - } + _mockRequestSender.Verify(s => s.EndSession(), Times.Exactly(2)); + } - [TestMethod] - public void CancelShouldNotSendSendTestRunCancelIfCommunicationFails() - { - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); + [TestMethod] + public void CancelShouldNotSendSendTestRunCancelIfCommunicationFails() + { + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); - Mock mockTestRunEventsHandler = new Mock(); + Mock mockTestRunEventsHandler = new(); - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); - this.testExecutionManager.Cancel(It.IsAny()); + _testExecutionManager.Cancel(It.IsAny()); - this.mockRequestSender.Verify(s => s.SendTestRunCancel(), Times.Never); - } + _mockRequestSender.Verify(s => s.SendTestRunCancel(), Times.Never); + } - [TestMethod] - public void AbortShouldSendTestRunAbortIfCommunicationSuccessful() - { - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + [TestMethod] + public void AbortShouldSendTestRunAbortIfCommunicationSuccessful() + { + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - Mock mockTestRunEventsHandler = new Mock(); + Mock mockTestRunEventsHandler = new(); - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); - this.testExecutionManager.Abort(It.IsAny()); + _testExecutionManager.Abort(It.IsAny()); - this.mockRequestSender.Verify(s => s.SendTestRunAbort(), Times.Once); - } + _mockRequestSender.Verify(s => s.SendTestRunAbort(), Times.Once); + } - [TestMethod] - public void AbortShouldNotSendTestRunAbortIfCommunicationFails() - { - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); + [TestMethod] + public void AbortShouldNotSendTestRunAbortIfCommunicationFails() + { + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); - Mock mockTestRunEventsHandler = new Mock(); + Mock mockTestRunEventsHandler = new(); - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); - this.testExecutionManager.Abort(It.IsAny()); + _testExecutionManager.Abort(It.IsAny()); - this.mockRequestSender.Verify(s => s.SendTestRunAbort(), Times.Never); - } + _mockRequestSender.Verify(s => s.SendTestRunAbort(), Times.Never); + } - [TestMethod] - public void ExecuteTestsCloseTestHostIfRawMessageIfOfTypeExecutionComplete() - { - Mock mockTestRunEventsHandler = new Mock(); + [TestMethod] + public void ExecuteTestsCloseTestHostIfRawMessageIfOfTypeExecutionComplete() + { + Mock mockTestRunEventsHandler = new(); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); - this.mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.TestMessage, It.IsAny())).Returns(MessageType.TestMessage); - this.mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.ExecutionComplete, It.IsAny())).Returns(MessageType.ExecutionComplete); + _mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.TestMessage, It.IsAny())).Returns(MessageType.TestMessage); + _mockDataSerializer.Setup(ds => ds.SerializePayload(MessageType.ExecutionComplete, It.IsAny())).Returns(MessageType.ExecutionComplete); - this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns((string rawMessage) => + _mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns((string rawMessage) => + { + var messageType = rawMessage.Contains(MessageType.ExecutionComplete) ? MessageType.ExecutionComplete : MessageType.TestMessage; + var message = new Message { - var messageType = rawMessage.Contains(MessageType.ExecutionComplete) ? MessageType.ExecutionComplete : MessageType.TestMessage; - var message = new Message - { - MessageType = messageType - }; + MessageType = messageType + }; - return message; - }); + return message; + }); - // Act. - this.testExecutionManager.StartTestRun(mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); + // Act. + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); - // Verify - this.mockTestHostManager.Verify(mthm => mthm.CleanTestHostAsync(It.IsAny()), Times.Once); - } + // Verify + _mockTestHostManager.Verify(mthm => mthm.CleanTestHostAsync(It.IsAny()), Times.Once); + } - [TestMethod] - public void ExecuteTestsShouldNotCloseTestHostIfRawMessageIsNotOfTypeExecutionComplete() - { - Mock mockTestRunEventsHandler = new Mock(); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); + [TestMethod] + public void ExecuteTestsShouldNotCloseTestHostIfRawMessageIsNotOfTypeExecutionComplete() + { + Mock mockTestRunEventsHandler = new(); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); - this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns(() => + _mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns(() => + { + var message = new Message { - var message = new Message - { - MessageType = MessageType.ExecutionInitialize - }; + MessageType = MessageType.ExecutionInitialize + }; + + return message; + }); + + // Act. + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); - return message; + // Verify + _mockTestHostManager.Verify(mthm => mthm.CleanTestHostAsync(It.IsAny()), Times.Never); + } + + [TestMethod] + public void ExecutionManagerShouldPassOnTestRunStatsChange() + { + _mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + Mock mockTestRunEventsHandler = new(); + var runCriteria = new Mock( + new List { new TestCase("A.C.M", new Uri("executor://dummy"), "source.dll") }, + 10); + var testRunChangedArgs = new TestRunChangedEventArgs(null, null, null); + + _testExecutionManager = GetProxyExecutionManager(); + + var completePayload = new TestRunCompletePayload() + { + ExecutorUris = null, + LastRunTests = null, + RunAttachments = null, + TestRunCompleteArgs = null + }; + var completeMessage = new Message() { MessageType = MessageType.ExecutionComplete, Payload = null }; + SetupChannelMessage(MessageType.StartTestExecutionWithTests, MessageType.TestRunStatsChange, testRunChangedArgs); + + mockTestRunEventsHandler.Setup(mh => mh.HandleTestRunStatsChange(It.IsAny())).Callback( + () => + { + _mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.IsAny())).Returns(completeMessage); + _mockDataSerializer.Setup(ds => ds.DeserializePayload(completeMessage)).Returns(completePayload); + _mockDataSerializer.Setup(ds => ds.SerializeMessage(It.IsAny())) + .Returns(MessageType.SessionEnd); + RaiseMessageReceived(MessageType.ExecutionComplete); }); - // Act. - this.testExecutionManager.StartTestRun(mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); + var waitHandle = new AutoResetEvent(false); + mockTestRunEventsHandler.Setup(mh => mh.HandleTestRunComplete( + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>())).Callback(() => waitHandle.Set()); - // Verify - this.mockTestHostManager.Verify(mthm => mthm.CleanTestHostAsync(It.IsAny()), Times.Never); - } + // Act. + _testExecutionManager.StartTestRun(runCriteria.Object, mockTestRunEventsHandler.Object); + waitHandle.WaitOne(); - [TestMethod] - public void ExecutionManagerShouldPassOnTestRunStatsChange() - { - this.mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - Mock mockTestRunEventsHandler = new Mock(); - var runCriteria = new Mock( - new List { new TestCase("A.C.M", new System.Uri("executor://dummy"), "source.dll") }, - 10); - var testRunChangedArgs = new TestRunChangedEventArgs(null, null, null); + // Verify + mockTestRunEventsHandler.Verify(mtdeh => mtdeh.HandleTestRunStatsChange(It.IsAny()), Times.Once); + } - this.testExecutionManager = this.GetProxyExecutionManager(); + [TestMethod] + public void ExecutionManagerShouldPassOnHandleLogMessage() + { + Mock mockTestRunEventsHandler = new(); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); - var completePayload = new TestRunCompletePayload() + _mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns(() => + { + var message = new Message { - ExecutorUris = null, - LastRunTests = null, - RunAttachments = null, - TestRunCompleteArgs = null + MessageType = MessageType.TestMessage }; - var completeMessage = new Message() { MessageType = MessageType.ExecutionComplete, Payload = null }; - this.SetupChannelMessage(MessageType.StartTestExecutionWithTests, MessageType.TestRunStatsChange, testRunChangedArgs); - - mockTestRunEventsHandler.Setup(mh => mh.HandleTestRunStatsChange(It.IsAny())).Callback( - () => - { - this.mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.IsAny())).Returns(completeMessage); - this.mockDataSerializer.Setup(ds => ds.DeserializePayload(completeMessage)).Returns(completePayload); - this.mockDataSerializer.Setup(ds => ds.SerializeMessage(It.IsAny())) - .Returns(MessageType.SessionEnd); - this.RaiseMessageReceived(MessageType.ExecutionComplete); - }); - - var waitHandle = new AutoResetEvent(false); - mockTestRunEventsHandler.Setup(mh => mh.HandleTestRunComplete( - It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>())).Callback(() => waitHandle.Set()); - - // Act. - this.testExecutionManager.StartTestRun(runCriteria.Object, mockTestRunEventsHandler.Object); - waitHandle.WaitOne(); - - // Verify - mockTestRunEventsHandler.Verify(mtdeh => mtdeh.HandleTestRunStatsChange(It.IsAny()), Times.Once); - } - [TestMethod] - public void ExecutionManagerShouldPassOnHandleLogMessage() - { - Mock mockTestRunEventsHandler = new Mock(); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(false); + return message; + }); - this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(It.IsAny())).Returns(() => - { - var message = new Message - { - MessageType = MessageType.TestMessage - }; + // Act. + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); + + // Verify + mockTestRunEventsHandler.Verify(mtdeh => mtdeh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once); + } - return message; + [TestMethod] + public void ExecutionManagerShouldPassOnLaunchProcessWithDebuggerAttached() + { + _mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + Mock mockTestRunEventsHandler = new(); + var runCriteria = new Mock( + new List { new TestCase("A.C.M", new Uri("executor://dummy"), "source.dll") }, + 10); + var payload = new TestProcessStartInfo(); + + _testExecutionManager = GetProxyExecutionManager(); + + var completePayload = new TestRunCompletePayload() + { + ExecutorUris = null, + LastRunTests = null, + RunAttachments = null, + TestRunCompleteArgs = null + }; + var completeMessage = new Message() { MessageType = MessageType.ExecutionComplete, Payload = null }; + SetupChannelMessage(MessageType.StartTestExecutionWithTests, + MessageType.LaunchAdapterProcessWithDebuggerAttached, payload); + + mockTestRunEventsHandler.Setup(mh => mh.LaunchProcessWithDebuggerAttached(It.IsAny())).Callback( + () => + { + _mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.IsAny())).Returns(completeMessage); + _mockDataSerializer.Setup(ds => ds.DeserializePayload(completeMessage)).Returns(completePayload); + _mockDataSerializer.Setup(ds => ds.SerializeMessage(It.IsAny())) + .Returns(MessageType.SessionEnd); + RaiseMessageReceived(MessageType.ExecutionComplete); }); - // Act. - this.testExecutionManager.StartTestRun(mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); + var waitHandle = new AutoResetEvent(false); + mockTestRunEventsHandler.Setup(mh => mh.HandleTestRunComplete( + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>())).Callback(() => waitHandle.Set()); - // Verify - mockTestRunEventsHandler.Verify(mtdeh => mtdeh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once); - } + _testExecutionManager.StartTestRun(runCriteria.Object, mockTestRunEventsHandler.Object); - [TestMethod] - public void ExecutionManagerShouldPassOnLaunchProcessWithDebuggerAttached() - { - this.mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - Mock mockTestRunEventsHandler = new Mock(); - var runCriteria = new Mock( - new List { new TestCase("A.C.M", new System.Uri("executor://dummy"), "source.dll") }, - 10); - var payload = new TestProcessStartInfo(); - - this.testExecutionManager = this.GetProxyExecutionManager(); + waitHandle.WaitOne(); - var completePayload = new TestRunCompletePayload() - { - ExecutorUris = null, - LastRunTests = null, - RunAttachments = null, - TestRunCompleteArgs = null - }; - var completeMessage = new Message() { MessageType = MessageType.ExecutionComplete, Payload = null }; - this.SetupChannelMessage(MessageType.StartTestExecutionWithTests, - MessageType.LaunchAdapterProcessWithDebuggerAttached, payload); - - mockTestRunEventsHandler.Setup(mh => mh.LaunchProcessWithDebuggerAttached(It.IsAny())).Callback( - () => - { - this.mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.IsAny())).Returns(completeMessage); - this.mockDataSerializer.Setup(ds => ds.DeserializePayload(completeMessage)).Returns(completePayload); - this.mockDataSerializer.Setup(ds => ds.SerializeMessage(It.IsAny())) - .Returns(MessageType.SessionEnd); - this.RaiseMessageReceived(MessageType.ExecutionComplete); - }); - - var waitHandle = new AutoResetEvent(false); - mockTestRunEventsHandler.Setup(mh => mh.HandleTestRunComplete( - It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>())).Callback(() => waitHandle.Set()); - - this.testExecutionManager.StartTestRun(runCriteria.Object, mockTestRunEventsHandler.Object); - - waitHandle.WaitOne(); - - // Verify - mockTestRunEventsHandler.Verify(mtdeh => mtdeh.LaunchProcessWithDebuggerAttached(It.IsAny()), Times.Once); - } + // Verify + mockTestRunEventsHandler.Verify(mtdeh => mtdeh.LaunchProcessWithDebuggerAttached(It.IsAny()), Times.Once); + } - [TestMethod] - public void StartTestRunShouldAttemptToTakeProxyFromPoolIfProxyIsNull() - { - var testSessionInfo = new TestSessionInfo(); + [TestMethod] + public void StartTestRunShouldAttemptToTakeProxyFromPoolIfProxyIsNull() + { + var testSessionInfo = new TestSessionInfo(); - Func + Func proxyOperationManagerCreator = ( string source, ProxyExecutionManager proxyExecutionManager) => @@ -761,112 +745,111 @@ public void StartTestRunShouldAttemptToTakeProxyFromPoolIfProxyIsNull() return proxyOperationManager; }; - var testExecutionManager = new ProxyExecutionManager( - testSessionInfo, - proxyOperationManagerCreator, - false); + var testExecutionManager = new ProxyExecutionManager( + testSessionInfo, + proxyOperationManagerCreator, + false); - var mockTestSessionPool = new Mock(); - TestSessionPool.Instance = mockTestSessionPool.Object; + var mockTestSessionPool = new Mock(); + TestSessionPool.Instance = mockTestSessionPool.Object; - try - { - var mockProxyOperationManager = new Mock( - this.mockRequestData.Object, - this.mockRequestSender.Object, - this.mockTestHostManager.Object); - mockTestSessionPool.Setup( + try + { + var mockProxyOperationManager = new Mock( + _mockRequestData.Object, + _mockRequestSender.Object, + _mockTestHostManager.Object); + mockTestSessionPool.Setup( tsp => tsp.TryTakeProxy( testSessionInfo, It.IsAny(), It.IsAny())) - .Returns(mockProxyOperationManager.Object); + .Returns(mockProxyOperationManager.Object); - testExecutionManager.Initialize(true); - testExecutionManager.StartTestRun( - this.mockTestRunCriteria.Object, - new Mock().Object); + testExecutionManager.Initialize(true); + testExecutionManager.StartTestRun( + _mockTestRunCriteria.Object, + new Mock().Object); - mockTestSessionPool.Verify( - tsp => tsp.TryTakeProxy( - testSessionInfo, - It.IsAny(), - It.IsAny()), - Times.Once); - } - finally - { - TestSessionPool.Instance = null; - } + mockTestSessionPool.Verify( + tsp => tsp.TryTakeProxy( + testSessionInfo, + It.IsAny(), + It.IsAny()), + Times.Once); } - - private void SignalEvent(ManualResetEvent manualResetEvent) + finally { - // Wait for the 100 ms. - Task.Delay(200).Wait(); - - manualResetEvent.Set(); + TestSessionPool.Instance = null; } + } - private void InvokeAndVerifyStartTestRun(bool skipDefaultAdapters) - { - TestPluginCache.Instance = null; - TestPluginCache.Instance.DefaultExtensionPaths = new List { "default1.dll", "default2.dll" }; - TestPluginCache.Instance.UpdateExtensions(new List { "filterTestAdapter.dll" }, false); - TestPluginCache.Instance.UpdateExtensions(new List { "unfilter.dll" }, true); + private void SignalEvent(ManualResetEvent manualResetEvent) + { + // Wait for the 100 ms. + Task.Delay(200).Wait(); - try - { - this.mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - this.mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns((IEnumerable sources, IEnumerable extensions) => extensions); - this.mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); - var expectedResult = TestPluginCache.Instance.GetExtensionPaths(TestPlatformConstants.TestAdapterEndsWithPattern, skipDefaultAdapters); + manualResetEvent.Set(); + } - this.testExecutionManager.Initialize(skipDefaultAdapters); - this.testExecutionManager.StartTestRun(this.mockTestRunCriteria.Object, null); + private void InvokeAndVerifyStartTestRun(bool skipDefaultAdapters) + { + TestPluginCache.Instance = null; + TestPluginCache.Instance.DefaultExtensionPaths = new List { "default1.dll", "default2.dll" }; + TestPluginCache.Instance.UpdateExtensions(new List { "filterTestAdapter.dll" }, false); + TestPluginCache.Instance.UpdateExtensions(new List { "unfilter.dll" }, true); - this.mockRequestSender.Verify(s => s.InitializeExecution(expectedResult), Times.Once); - } - finally - { - TestPluginCache.Instance = null; - } + try + { + _mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + _mockTestHostManager.Setup(th => th.GetTestPlatformExtensions(It.IsAny>(), It.IsAny>())).Returns((IEnumerable sources, IEnumerable extensions) => extensions); + _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); + var expectedResult = TestPluginCache.Instance.GetExtensionPaths(TestPlatformConstants.TestAdapterEndsWithPattern, skipDefaultAdapters); + + _testExecutionManager.Initialize(skipDefaultAdapters); + _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, null); + + _mockRequestSender.Verify(s => s.InitializeExecution(expectedResult), Times.Once); + } + finally + { + TestPluginCache.Instance = null; } + } - //private void SetupReceiveRawMessageAsyncAndDeserializeMessageAndInitialize() - //{ - // var connectionInfo = new TestHostConnectionInfo - // { - // Endpoint = IPAddress.Loopback + ":0", - // Role = ConnectionRole.Client, - // Transport = Transport.Sockets - // }; - // this.mockCommunicationEndpoint = new Mock(); - // this.mockDataSerializer = new Mock(); - // this.testRequestSender = new TestRequestSender(this.mockCommunicationEndpoint.Object, connectionInfo, this.mockDataSerializer.Object, this.protocolConfig, CLIENTPROCESSEXITWAIT); - // this.mockCommunicationEndpoint.Setup(mc => mc.Start(connectionInfo.Endpoint)).Returns(connectionInfo.Endpoint).Callback(() => - // { - // this.mockCommunicationEndpoint.Raise( - // s => s.Connected += null, - // this.mockCommunicationEndpoint.Object, - // new ConnectedEventArgs(this.mockChannel.Object)); - // }); - // this.SetupChannelMessage(MessageType.VersionCheck, MessageType.VersionCheck, this.protocolConfig.Version); - - // this.testRequestSender.InitializeCommunication(); - - // this.testExecutionManager = new ProxyExecutionManager(this.mockRequestData.Object, this.testRequestSender, this.mockTestHostManager.Object, this.mockDataSerializer.Object, this.clientConnectionTimeout); - //} - - //private void SetupChannelMessage(string messageType, string returnMessageType, TPayload returnPayload) - //{ - // this.mockChannel.Setup(mc => mc.Send(It.Is(s => s.Contains(messageType)))) - // .Callback(() => this.mockChannel.Raise(c => c.MessageReceived += null, this.mockChannel.Object, new MessageReceivedEventArgs { Data = messageType })); - - // this.mockDataSerializer.Setup(ds => ds.SerializePayload(It.Is(s => s.Equals(messageType)), It.IsAny())).Returns(messageType); - // this.mockDataSerializer.Setup(ds => ds.SerializePayload(It.Is(s => s.Equals(messageType)), It.IsAny(), It.IsAny())).Returns(messageType); - // this.mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.Is(s => s.Equals(messageType)))).Returns(new Message { MessageType = returnMessageType }); - // this.mockDataSerializer.Setup(ds => ds.DeserializePayload(It.Is(m => m.MessageType.Equals(messageType)))).Returns(returnPayload); - //} - } -} + //private void SetupReceiveRawMessageAsyncAndDeserializeMessageAndInitialize() + //{ + // var connectionInfo = new TestHostConnectionInfo + // { + // Endpoint = IPAddress.Loopback + ":0", + // Role = ConnectionRole.Client, + // Transport = Transport.Sockets + // }; + // this.mockCommunicationEndpoint = new Mock(); + // this.mockDataSerializer = new Mock(); + // this.testRequestSender = new TestRequestSender(this.mockCommunicationEndpoint.Object, connectionInfo, this.mockDataSerializer.Object, this.protocolConfig, CLIENTPROCESSEXITWAIT); + // this.mockCommunicationEndpoint.Setup(mc => mc.Start(connectionInfo.Endpoint)).Returns(connectionInfo.Endpoint).Callback(() => + // { + // this.mockCommunicationEndpoint.Raise( + // s => s.Connected += null, + // this.mockCommunicationEndpoint.Object, + // new ConnectedEventArgs(this.mockChannel.Object)); + // }); + // this.SetupChannelMessage(MessageType.VersionCheck, MessageType.VersionCheck, this.protocolConfig.Version); + + // this.testRequestSender.InitializeCommunication(); + + // this.testExecutionManager = new ProxyExecutionManager(this.mockRequestData.Object, this.testRequestSender, this.mockTestHostManager.Object, this.mockDataSerializer.Object, this.clientConnectionTimeout); + //} + + //private void SetupChannelMessage(string messageType, string returnMessageType, TPayload returnPayload) + //{ + // this.mockChannel.Setup(mc => mc.Send(It.Is(s => s.Contains(messageType)))) + // .Callback(() => this.mockChannel.Raise(c => c.MessageReceived += null, this.mockChannel.Object, new MessageReceivedEventArgs { Data = messageType })); + + // this.mockDataSerializer.Setup(ds => ds.SerializePayload(It.Is(s => s.Equals(messageType)), It.IsAny())).Returns(messageType); + // this.mockDataSerializer.Setup(ds => ds.SerializePayload(It.Is(s => s.Equals(messageType)), It.IsAny(), It.IsAny())).Returns(messageType); + // this.mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.Is(s => s.Equals(messageType)))).Returns(new Message { MessageType = returnMessageType }); + // this.mockDataSerializer.Setup(ds => ds.DeserializePayload(It.Is(m => m.MessageType.Equals(messageType)))).Returns(returnPayload); + //} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerWithDataCollectionTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerWithDataCollectionTests.cs index b8e2819084..67b823928a 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerWithDataCollectionTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerWithDataCollectionTests.cs @@ -1,232 +1,226 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Client +namespace TestPlatform.CrossPlatEngine.UnitTests.Client; + +using System; +using System.Collections.Generic; + +using Microsoft.VisualStudio.TestPlatform.Common; +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class ProxyExecutionManagerWithDataCollectionTests { - using System; - using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - [TestClass] - public class ProxyExecutionManagerWithDataCollectionTests - { - private ProxyExecutionManager testExecutionManager; + private ProxyExecutionManager _testExecutionManager; - private Mock mockTestHostManager; + private Mock _mockTestHostManager; - private Mock mockRequestSender; + private Mock _mockRequestSender; - private Mock mockDataCollectionManager; + private Mock _mockDataCollectionManager; - private Mock mockProcessHelper; + private Mock _mockProcessHelper; - private ProxyExecutionManagerWithDataCollection proxyExecutionManager; + private ProxyExecutionManagerWithDataCollection _proxyExecutionManager; - private Mock mockDataSerializer; + private Mock _mockDataSerializer; - private Mock mockRequestData; + private Mock _mockRequestData; - private Mock mockMetricsCollection; + private Mock _mockMetricsCollection; - private Mock mockFileHelper; + private Mock _mockFileHelper; - [TestInitialize] - public void TestInit() - { - this.mockTestHostManager = new Mock(); - this.mockRequestSender = new Mock(); - this.mockDataSerializer = new Mock(); - this.mockRequestData = new Mock(); - this.mockMetricsCollection = new Mock(); - this.mockFileHelper = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(this.mockMetricsCollection.Object); - this.testExecutionManager = new ProxyExecutionManager(this.mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object, this.mockDataSerializer.Object, this.mockFileHelper.Object); - this.mockDataCollectionManager = new Mock(); - this.mockProcessHelper = new Mock(); - this.proxyExecutionManager = new ProxyExecutionManagerWithDataCollection(this.mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object, this.mockDataCollectionManager.Object); - } + [TestInitialize] + public void TestInit() + { + _mockTestHostManager = new Mock(); + _mockRequestSender = new Mock(); + _mockDataSerializer = new Mock(); + _mockRequestData = new Mock(); + _mockMetricsCollection = new Mock(); + _mockFileHelper = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(_mockMetricsCollection.Object); + _testExecutionManager = new ProxyExecutionManager(_mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object, _mockDataSerializer.Object, _mockFileHelper.Object); + _mockDataCollectionManager = new Mock(); + _mockProcessHelper = new Mock(); + _proxyExecutionManager = new ProxyExecutionManagerWithDataCollection(_mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object, _mockDataCollectionManager.Object); + } - [TestMethod] - public void InitializeShouldInitializeDataCollectionProcessIfDataCollectionIsEnabled() - { - this.proxyExecutionManager.Initialize(false); + [TestMethod] + public void InitializeShouldInitializeDataCollectionProcessIfDataCollectionIsEnabled() + { + _proxyExecutionManager.Initialize(false); - mockDataCollectionManager.Verify(dc => dc.BeforeTestRunStart(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); - } + _mockDataCollectionManager.Verify(dc => dc.BeforeTestRunStart(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); + } - [TestMethod] - public void InitializeShouldThrowExceptionIfThrownByDataCollectionManager() - { - this.mockDataCollectionManager.Setup(x => x.Initialize()).Throws(); + [TestMethod] + public void InitializeShouldThrowExceptionIfThrownByDataCollectionManager() + { + _mockDataCollectionManager.Setup(x => x.Initialize()).Throws(); - Assert.ThrowsException(() => - { - this.proxyExecutionManager.Initialize(false); - }); - } + Assert.ThrowsException(() => _proxyExecutionManager.Initialize(false)); + } - [TestMethod] - public void InitializeShouldCallAfterTestRunIfExceptionIsThrownWhileCreatingDataCollectionProcess() - { - mockDataCollectionManager.Setup(dc => dc.BeforeTestRunStart(It.IsAny(), It.IsAny(), It.IsAny())).Throws(new Exception("MyException")); + [TestMethod] + public void InitializeShouldCallAfterTestRunIfExceptionIsThrownWhileCreatingDataCollectionProcess() + { + _mockDataCollectionManager.Setup(dc => dc.BeforeTestRunStart(It.IsAny(), It.IsAny(), It.IsAny())).Throws(new Exception("MyException")); - Assert.ThrowsException(() => - { - this.proxyExecutionManager.Initialize(false); - }); + Assert.ThrowsException(() => _proxyExecutionManager.Initialize(false)); - mockDataCollectionManager.Verify(dc => dc.BeforeTestRunStart(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); - mockDataCollectionManager.Verify(dc => dc.AfterTestRunEnd(It.IsAny(), It.IsAny()), Times.Once); - } + _mockDataCollectionManager.Verify(dc => dc.BeforeTestRunStart(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); + _mockDataCollectionManager.Verify(dc => dc.AfterTestRunEnd(It.IsAny(), It.IsAny()), Times.Once); + } - [TestMethod] - public void InitializeShouldSaveExceptionMessagesIfThrownByDataCollectionProcess() - { - var mockRequestSender = new Mock(); - var testSources = new List() { "abc.dll", "efg.dll" }; - mockRequestSender.Setup(x => x.SendBeforeTestRunStartAndGetResult(string.Empty, testSources, It.IsAny(), It.IsAny())).Throws(new Exception("MyException")); - mockRequestSender.Setup(x => x.WaitForRequestHandlerConnection(It.IsAny())).Returns(true); - - var mockDataCollectionLauncher = new Mock(); - var proxyDataCollectonManager = new ProxyDataCollectionManager(this.mockRequestData.Object, string.Empty, testSources, mockRequestSender.Object, this.mockProcessHelper.Object, mockDataCollectionLauncher.Object); - - var proxyExecutionManager = new ProxyExecutionManagerWithDataCollection(this.mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object, proxyDataCollectonManager); - proxyExecutionManager.Initialize(false); - Assert.IsNotNull(proxyExecutionManager.DataCollectionRunEventsHandler.Messages); - Assert.AreEqual(TestMessageLevel.Error, proxyExecutionManager.DataCollectionRunEventsHandler.Messages[0].Item1); - StringAssert.Contains(proxyExecutionManager.DataCollectionRunEventsHandler.Messages[0].Item2, "MyException"); - } + [TestMethod] + public void InitializeShouldSaveExceptionMessagesIfThrownByDataCollectionProcess() + { + var mockRequestSender = new Mock(); + var testSources = new List() { "abc.dll", "efg.dll" }; + mockRequestSender.Setup(x => x.SendBeforeTestRunStartAndGetResult(string.Empty, testSources, It.IsAny(), It.IsAny())).Throws(new Exception("MyException")); + mockRequestSender.Setup(x => x.WaitForRequestHandlerConnection(It.IsAny())).Returns(true); + + var mockDataCollectionLauncher = new Mock(); + var proxyDataCollectonManager = new ProxyDataCollectionManager(_mockRequestData.Object, string.Empty, testSources, mockRequestSender.Object, _mockProcessHelper.Object, mockDataCollectionLauncher.Object); + + var proxyExecutionManager = new ProxyExecutionManagerWithDataCollection(_mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object, proxyDataCollectonManager); + proxyExecutionManager.Initialize(false); + Assert.IsNotNull(proxyExecutionManager.DataCollectionRunEventsHandler.Messages); + Assert.AreEqual(TestMessageLevel.Error, proxyExecutionManager.DataCollectionRunEventsHandler.Messages[0].Item1); + StringAssert.Contains(proxyExecutionManager.DataCollectionRunEventsHandler.Messages[0].Item2, "MyException"); + } - [TestMethod] - public void UpdateTestProcessStartInfoShouldUpdateDataCollectionPortArg() - { - this.mockDataCollectionManager.Setup(x => x.BeforeTestRunStart(It.IsAny(), It.IsAny(), It.IsAny())).Returns(DataCollectionParameters.CreateDefaultParameterInstance()); + [TestMethod] + public void UpdateTestProcessStartInfoShouldUpdateDataCollectionPortArg() + { + _mockDataCollectionManager.Setup(x => x.BeforeTestRunStart(It.IsAny(), It.IsAny(), It.IsAny())).Returns(DataCollectionParameters.CreateDefaultParameterInstance()); - var testProcessStartInfo = new TestProcessStartInfo(); - testProcessStartInfo.Arguments = string.Empty; + var testProcessStartInfo = new TestProcessStartInfo(); + testProcessStartInfo.Arguments = string.Empty; - var proxyExecutionManager = new TestableProxyExecutionManagerWithDataCollection(this.mockRequestSender.Object, this.mockTestHostManager.Object, this.mockDataCollectionManager.Object); - proxyExecutionManager.UpdateTestProcessStartInfoWrapper(testProcessStartInfo); + var proxyExecutionManager = new TestableProxyExecutionManagerWithDataCollection(_mockRequestSender.Object, _mockTestHostManager.Object, _mockDataCollectionManager.Object); + proxyExecutionManager.UpdateTestProcessStartInfoWrapper(testProcessStartInfo); - Assert.IsTrue(testProcessStartInfo.Arguments.Contains("--datacollectionport 0")); - } + Assert.IsTrue(testProcessStartInfo.Arguments.Contains("--datacollectionport 0")); + } - [TestMethod] - public void UpdateTestProcessStartInfoShouldUpdateTelemetryOptedInArgTrueIfTelemetryOptedIn() - { - var mockRequestData = new Mock(); - this.mockRequestData.Setup(rd => rd.IsTelemetryOptedIn).Returns(true); + [TestMethod] + public void UpdateTestProcessStartInfoShouldUpdateTelemetryOptedInArgTrueIfTelemetryOptedIn() + { + var mockRequestData = new Mock(); + _mockRequestData.Setup(rd => rd.IsTelemetryOptedIn).Returns(true); - this.mockDataCollectionManager.Setup(x => x.BeforeTestRunStart(It.IsAny(), It.IsAny(), It.IsAny())).Returns(DataCollectionParameters.CreateDefaultParameterInstance()); + _mockDataCollectionManager.Setup(x => x.BeforeTestRunStart(It.IsAny(), It.IsAny(), It.IsAny())).Returns(DataCollectionParameters.CreateDefaultParameterInstance()); - var testProcessStartInfo = new TestProcessStartInfo(); - testProcessStartInfo.Arguments = string.Empty; + var testProcessStartInfo = new TestProcessStartInfo(); + testProcessStartInfo.Arguments = string.Empty; - var proxyExecutionManager = new TestableProxyExecutionManagerWithDataCollection(this.mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object, this.mockDataCollectionManager.Object); + var proxyExecutionManager = new TestableProxyExecutionManagerWithDataCollection(_mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object, _mockDataCollectionManager.Object); - // Act. - proxyExecutionManager.UpdateTestProcessStartInfoWrapper(testProcessStartInfo); + // Act. + proxyExecutionManager.UpdateTestProcessStartInfoWrapper(testProcessStartInfo); - // Verify. - Assert.IsTrue(testProcessStartInfo.Arguments.Contains("--telemetryoptedin true")); - } + // Verify. + Assert.IsTrue(testProcessStartInfo.Arguments.Contains("--telemetryoptedin true")); + } - [TestMethod] - public void UpdateTestProcessStartInfoShouldUpdateTelemetryOptedInArgFalseIfTelemetryOptedOut() - { - var mockRequestData = new Mock(); - this.mockRequestData.Setup(rd => rd.IsTelemetryOptedIn).Returns(false); + [TestMethod] + public void UpdateTestProcessStartInfoShouldUpdateTelemetryOptedInArgFalseIfTelemetryOptedOut() + { + var mockRequestData = new Mock(); + _mockRequestData.Setup(rd => rd.IsTelemetryOptedIn).Returns(false); - this.mockDataCollectionManager.Setup(x => x.BeforeTestRunStart(It.IsAny(), It.IsAny(), It.IsAny())).Returns(DataCollectionParameters.CreateDefaultParameterInstance()); + _mockDataCollectionManager.Setup(x => x.BeforeTestRunStart(It.IsAny(), It.IsAny(), It.IsAny())).Returns(DataCollectionParameters.CreateDefaultParameterInstance()); - var testProcessStartInfo = new TestProcessStartInfo(); - testProcessStartInfo.Arguments = string.Empty; + var testProcessStartInfo = new TestProcessStartInfo(); + testProcessStartInfo.Arguments = string.Empty; - var proxyExecutionManager = new TestableProxyExecutionManagerWithDataCollection(this.mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object, this.mockDataCollectionManager.Object); + var proxyExecutionManager = new TestableProxyExecutionManagerWithDataCollection(_mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object, _mockDataCollectionManager.Object); - // Act. - proxyExecutionManager.UpdateTestProcessStartInfoWrapper(testProcessStartInfo); + // Act. + proxyExecutionManager.UpdateTestProcessStartInfoWrapper(testProcessStartInfo); - // Verify. - Assert.IsTrue(testProcessStartInfo.Arguments.Contains("--telemetryoptedin false")); - } + // Verify. + Assert.IsTrue(testProcessStartInfo.Arguments.Contains("--telemetryoptedin false")); + } - [TestMethod] - public void LaunchProcessWithDebuggerAttachedShouldUpdateEnvironmentVariables() + [TestMethod] + public void LaunchProcessWithDebuggerAttachedShouldUpdateEnvironmentVariables() + { + // Setup + var mockRunEventsHandler = new Mock(); + TestProcessStartInfo launchedStartInfo = null; + mockRunEventsHandler.Setup(runHandler => runHandler.LaunchProcessWithDebuggerAttached(It.IsAny())).Callback + ((TestProcessStartInfo startInfo) => launchedStartInfo = startInfo); + var proxyExecutionManager = new ProxyExecutionManagerWithDataCollection(_mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object, _mockDataCollectionManager.Object); + var mockTestRunCriteria = new Mock(new List { "source.dll" }, 10); + var testProcessStartInfo = new TestProcessStartInfo { - // Setup - var mockRunEventsHandler = new Mock(); - TestProcessStartInfo launchedStartInfo = null; - mockRunEventsHandler.Setup(runHandler => runHandler.LaunchProcessWithDebuggerAttached(It.IsAny())).Callback - ((TestProcessStartInfo startInfo) => { launchedStartInfo = startInfo; }); - var proxyExecutionManager = new ProxyExecutionManagerWithDataCollection(this.mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object, this.mockDataCollectionManager.Object); - var mockTestRunCriteria = new Mock(new List { "source.dll" }, 10); - var testProcessStartInfo = new TestProcessStartInfo + Arguments = string.Empty, + EnvironmentVariables = new Dictionary { - Arguments = string.Empty, - EnvironmentVariables = new Dictionary - { - {"variable1", "value1" }, - {"variable2", "value2" } - } - }; - - // Act. - proxyExecutionManager.StartTestRun(mockTestRunCriteria.Object, mockRunEventsHandler.Object); - proxyExecutionManager.LaunchProcessWithDebuggerAttached(testProcessStartInfo); - - // Verify. - Assert.IsTrue(launchedStartInfo != null, "Failed to get the start info"); - foreach (var envVaribale in testProcessStartInfo.EnvironmentVariables) - { - Assert.AreEqual(envVaribale.Value, launchedStartInfo.EnvironmentVariables[envVaribale.Key], $"Expected environment variable {envVaribale.Key} : {envVaribale.Value} not found"); + {"variable1", "value1" }, + {"variable2", "value2" } } - } + }; - [TestMethod] - public void TestHostManagerHostLaunchedTriggerShouldSendTestHostLaunchedEvent() + // Act. + proxyExecutionManager.StartTestRun(mockTestRunCriteria.Object, mockRunEventsHandler.Object); + proxyExecutionManager.LaunchProcessWithDebuggerAttached(testProcessStartInfo); + + // Verify. + Assert.IsTrue(launchedStartInfo != null, "Failed to get the start info"); + foreach (var envVaribale in testProcessStartInfo.EnvironmentVariables) { - var proxyExecutionManager = new ProxyExecutionManagerWithDataCollection(this.mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object, this.mockDataCollectionManager.Object); + Assert.AreEqual(envVaribale.Value, launchedStartInfo.EnvironmentVariables[envVaribale.Key], $"Expected environment variable {envVaribale.Key} : {envVaribale.Value} not found"); + } + } - this.mockTestHostManager.Raise(x => x.HostLaunched += null, new HostProviderEventArgs("launched", 0, 1234)); + [TestMethod] + public void TestHostManagerHostLaunchedTriggerShouldSendTestHostLaunchedEvent() + { + var proxyExecutionManager = new ProxyExecutionManagerWithDataCollection(_mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object, _mockDataCollectionManager.Object); - this.mockDataCollectionManager.Verify(x => x.TestHostLaunched(It.IsAny())); - } + _mockTestHostManager.Raise(x => x.HostLaunched += null, new HostProviderEventArgs("launched", 0, 1234)); + + _mockDataCollectionManager.Verify(x => x.TestHostLaunched(It.IsAny())); } +} - internal class TestableProxyExecutionManagerWithDataCollection : ProxyExecutionManagerWithDataCollection +internal class TestableProxyExecutionManagerWithDataCollection : ProxyExecutionManagerWithDataCollection +{ + public TestableProxyExecutionManagerWithDataCollection(ITestRequestSender testRequestSender, ITestRuntimeProvider testHostManager, IProxyDataCollectionManager proxyDataCollectionManager) : base(new RequestData { MetricsCollection = new NoOpMetricsCollection() }, testRequestSender, testHostManager, proxyDataCollectionManager) { - public TestableProxyExecutionManagerWithDataCollection(ITestRequestSender testRequestSender, ITestRuntimeProvider testHostManager, IProxyDataCollectionManager proxyDataCollectionManager) : base(new RequestData { MetricsCollection = new NoOpMetricsCollection() }, testRequestSender, testHostManager, proxyDataCollectionManager) - { - } + } - public TestableProxyExecutionManagerWithDataCollection(IRequestData requestData, ITestRequestSender testRequestSender, ITestRuntimeProvider testHostManager, IProxyDataCollectionManager proxyDataCollectionManager) : base(requestData, testRequestSender, testHostManager, proxyDataCollectionManager) - { - } + public TestableProxyExecutionManagerWithDataCollection(IRequestData requestData, ITestRequestSender testRequestSender, ITestRuntimeProvider testHostManager, IProxyDataCollectionManager proxyDataCollectionManager) : base(requestData, testRequestSender, testHostManager, proxyDataCollectionManager) + { + } - public TestProcessStartInfo UpdateTestProcessStartInfoWrapper(TestProcessStartInfo testProcessStartInfo) - { - return this.UpdateTestProcessStartInfo(testProcessStartInfo); - } + public TestProcessStartInfo UpdateTestProcessStartInfoWrapper(TestProcessStartInfo testProcessStartInfo) + { + return UpdateTestProcessStartInfo(testProcessStartInfo); + } - public override TestProcessStartInfo UpdateTestProcessStartInfo(TestProcessStartInfo testProcessStartInfo) - { - return base.UpdateTestProcessStartInfo(testProcessStartInfo); - } + public override TestProcessStartInfo UpdateTestProcessStartInfo(TestProcessStartInfo testProcessStartInfo) + { + return base.UpdateTestProcessStartInfo(testProcessStartInfo); } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyOperationManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyOperationManagerTests.cs index c1d95923f2..77173e3106 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyOperationManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyOperationManagerTests.cs @@ -1,566 +1,556 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Client +namespace TestPlatform.CrossPlatEngine.UnitTests.Client; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using System.Net; +using System.Threading; +using System.Threading.Tasks; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class ProxyOperationManagerTests : ProxyBaseManagerTests { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Globalization; - using System.Linq; - using System.Net; - using System.Threading; - using System.Threading.Tasks; + private const int Clientprocessexitwait = 10 * 1000; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; + private readonly ProxyOperationManager _testOperationManager; - using Moq; + private readonly Mock _mockRequestSender; - [TestClass] - public class ProxyOperationManagerTests : ProxyBaseManagerTests - { - private const int CLIENTPROCESSEXITWAIT = 10 * 1000; - - private readonly ProxyOperationManager testOperationManager; - - private readonly Mock mockRequestSender; + private Mock _mockProcessHelper; - private Mock mockProcessHelper; + private Mock _mockRunsettingHelper; - private Mock mockRunsettingHelper; + private Mock _mockWindowsRegistry; - private Mock mockWindowsRegistry; + private Mock _mockEnvironmentVariableHelper; - private Mock mockEnvironmentVariableHelper; + private Mock _mockFileHelper; - private Mock mockFileHelper; + private Mock _mockEnvironment; - private Mock mockEnvironment; + private readonly Mock _mockRequestData; - private Mock mockRequestData; + private readonly int _connectionTimeout = EnvironmentHelper.DefaultConnectionTimeout * 1000; - private int connectionTimeout = EnvironmentHelper.DefaultConnectionTimeout * 1000; + private readonly string _defaultRunSettings = "\r\n\r\n \r\n {0}\r\n \r\n"; - private string defaultRunSettings = "\r\n\r\n \r\n {0}\r\n \r\n"; + private static readonly string TimoutErrorMessage = + "vstest.console process failed to connect to testhost process after 90 seconds. This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout."; - private static readonly string TimoutErrorMessage = - "vstest.console process failed to connect to testhost process after 90 seconds. This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout."; - - public ProxyOperationManagerTests() - { - this.mockRequestSender = new Mock(); - this.mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(connectionTimeout, It.IsAny())).Returns(true); - this.mockRequestData = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new Mock().Object); - this.testOperationManager = new TestableProxyOperationManager(this.mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object); - } + public ProxyOperationManagerTests() + { + _mockRequestSender = new Mock(); + _mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(_connectionTimeout, It.IsAny())).Returns(true); + _mockRequestData = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new Mock().Object); + _testOperationManager = new TestableProxyOperationManager(_mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object); + } - [TestCleanup] - public void Cleanup() - { - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, string.Empty); - } + [TestCleanup] + public void Cleanup() + { + Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, string.Empty); + } - [TestMethod] - public void SetupChannelShouldLaunchTestHost() - { - var expectedStartInfo = new TestProcessStartInfo(); - this.mockRequestSender.Setup(rs => rs.InitializeCommunication()).Returns(123); - this.mockTestHostManager.Setup( - th => th.GetTestHostProcessStartInfo(Enumerable.Empty(), It.IsAny>(), It.IsAny())) - .Returns(expectedStartInfo); + [TestMethod] + public void SetupChannelShouldLaunchTestHost() + { + var expectedStartInfo = new TestProcessStartInfo(); + _mockRequestSender.Setup(rs => rs.InitializeCommunication()).Returns(123); + _mockTestHostManager.Setup( + th => th.GetTestHostProcessStartInfo(Enumerable.Empty(), It.IsAny>(), It.IsAny())) + .Returns(expectedStartInfo); - this.testOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); + _testOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); - this.mockTestHostManager.Verify(thl => thl.LaunchTestHostAsync(It.Is(si => si == expectedStartInfo), It.IsAny()), Times.Once); - } + _mockTestHostManager.Verify(thl => thl.LaunchTestHostAsync(It.Is(si => si == expectedStartInfo), It.IsAny()), Times.Once); + } - [TestMethod] - public void SetupChannelShouldCreateTimestampedLogFileForHost() - { - this.mockRequestSender.Setup(rs => rs.InitializeCommunication()).Returns(123); - EqtTrace.InitializeTrace("log.txt", PlatformTraceLevel.Verbose); - - this.testOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); - - this.mockTestHostManager.Verify( - th => - th.GetTestHostProcessStartInfo( - It.IsAny>(), - It.IsAny>(), - It.Is( - t => t.LogFile.Contains("log.host." + DateTime.Now.ToString("yy-MM-dd")) - && t.LogFile.Contains("_" + Thread.CurrentThread.ManagedThreadId + ".txt")))); + [TestMethod] + public void SetupChannelShouldCreateTimestampedLogFileForHost() + { + _mockRequestSender.Setup(rs => rs.InitializeCommunication()).Returns(123); + EqtTrace.InitializeTrace("log.txt", PlatformTraceLevel.Verbose); + + _testOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); + + _mockTestHostManager.Verify( + th => + th.GetTestHostProcessStartInfo( + It.IsAny>(), + It.IsAny>(), + It.Is( + t => t.LogFile.Contains("log.host." + DateTime.Now.ToString("yy-MM-dd")) + && t.LogFile.Contains("_" + Thread.CurrentThread.ManagedThreadId + ".txt")))); #if NETFRAMEWORK - EqtTrace.TraceLevel = TraceLevel.Off; + EqtTrace.TraceLevel = TraceLevel.Off; #else - EqtTrace.TraceLevel = PlatformTraceLevel.Off; + EqtTrace.TraceLevel = PlatformTraceLevel.Off; #endif - } + } - [TestMethod] - public void SetupChannelShouldAddRunnerProcessIdForTestHost() - { - this.mockRequestSender.Setup(rs => rs.InitializeCommunication()).Returns(123); + [TestMethod] + public void SetupChannelShouldAddRunnerProcessIdForTestHost() + { + _mockRequestSender.Setup(rs => rs.InitializeCommunication()).Returns(123); - this.testOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); + _testOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); - this.mockTestHostManager.Verify( - th => - th.GetTestHostProcessStartInfo( - It.IsAny>(), - It.IsAny>(), - It.Is(t => t.RunnerProcessId.Equals(Process.GetCurrentProcess().Id)))); - } + _mockTestHostManager.Verify( + th => + th.GetTestHostProcessStartInfo( + It.IsAny>(), + It.IsAny>(), + It.Is(t => t.RunnerProcessId.Equals(Process.GetCurrentProcess().Id)))); + } - [TestMethod] - public void SetupChannelShouldAddCorrectTraceLevelForTestHost() - { + [TestMethod] + public void SetupChannelShouldAddCorrectTraceLevelForTestHost() + { #if NETFRAMEWORK - EqtTrace.TraceLevel = TraceLevel.Info; + EqtTrace.TraceLevel = TraceLevel.Info; #else - EqtTrace.TraceLevel = PlatformTraceLevel.Info; + EqtTrace.TraceLevel = PlatformTraceLevel.Info; #endif - this.mockRequestSender.Setup(rs => rs.InitializeCommunication()).Returns(123); - this.testOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); + _mockRequestSender.Setup(rs => rs.InitializeCommunication()).Returns(123); + _testOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); - this.mockTestHostManager.Verify( - th => - th.GetTestHostProcessStartInfo( - It.IsAny>(), - It.IsAny>(), - It.Is(t => t.TraceLevel == (int)PlatformTraceLevel.Info))); - } + _mockTestHostManager.Verify( + th => + th.GetTestHostProcessStartInfo( + It.IsAny>(), + It.IsAny>(), + It.Is(t => t.TraceLevel == (int)PlatformTraceLevel.Info))); + } - [TestMethod] - public void SetupChannelShouldSetupServerForCommunication() - { - this.testOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); + [TestMethod] + public void SetupChannelShouldSetupServerForCommunication() + { + _testOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); - this.mockRequestSender.Verify(s => s.InitializeCommunication(), Times.Once); - } + _mockRequestSender.Verify(s => s.InitializeCommunication(), Times.Once); + } - [TestMethod] - public void SetupChannelShouldCallHostServerIfRunnerIsServer() + [TestMethod] + public void SetupChannelShouldCallHostServerIfRunnerIsServer() + { + var connectionInfo = new TestHostConnectionInfo { - var connectionInfo = new TestHostConnectionInfo - { - Endpoint = IPAddress.Loopback + ":0", - Role = ConnectionRole.Host, - Transport = Transport.Sockets - }; - ProtocolConfig protocolConfig = new ProtocolConfig { Version = 2 }; - var mockCommunicationServer = new Mock(); + Endpoint = IPAddress.Loopback + ":0", + Role = ConnectionRole.Host, + Transport = Transport.Sockets + }; + ProtocolConfig protocolConfig = new() { Version = 2 }; + var mockCommunicationServer = new Mock(); - mockCommunicationServer.Setup(mc => mc.Start(connectionInfo.Endpoint)).Returns(IPAddress.Loopback + ":123").Callback( - () => { mockCommunicationServer.Raise(s => s.Connected += null, mockCommunicationServer.Object, new ConnectedEventArgs(this.mockChannel.Object)); }); + mockCommunicationServer.Setup(mc => mc.Start(connectionInfo.Endpoint)).Returns(IPAddress.Loopback + ":123").Callback( + () => mockCommunicationServer.Raise(s => s.Connected += null, mockCommunicationServer.Object, new ConnectedEventArgs(_mockChannel.Object))); - var testRequestSender = new TestRequestSender(mockCommunicationServer.Object, connectionInfo, mockDataSerializer.Object, protocolConfig, CLIENTPROCESSEXITWAIT); - this.SetupChannelMessage(MessageType.VersionCheck, MessageType.VersionCheck, protocolConfig.Version); + var testRequestSender = new TestRequestSender(mockCommunicationServer.Object, connectionInfo, _mockDataSerializer.Object, protocolConfig, Clientprocessexitwait); + SetupChannelMessage(MessageType.VersionCheck, MessageType.VersionCheck, protocolConfig.Version); - this.mockTestHostManager.Setup(thm => thm.GetTestHostConnectionInfo()).Returns(connectionInfo); + _mockTestHostManager.Setup(thm => thm.GetTestHostConnectionInfo()).Returns(connectionInfo); - var localTestOperationManager = new TestableProxyOperationManager(this.mockRequestData.Object, testRequestSender, this.mockTestHostManager.Object); + var localTestOperationManager = new TestableProxyOperationManager(_mockRequestData.Object, testRequestSender, _mockTestHostManager.Object); - localTestOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); + localTestOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); - mockCommunicationServer.Verify(s => s.Start(IPAddress.Loopback.ToString() + ":0"), Times.Once); - } + mockCommunicationServer.Verify(s => s.Start(IPAddress.Loopback.ToString() + ":0"), Times.Once); + } - [TestMethod] - public void SetupChannelShouldCallSetupClientIfRunnerIsClient() + [TestMethod] + public void SetupChannelShouldCallSetupClientIfRunnerIsClient() + { + var connectionInfo = new TestHostConnectionInfo { - var connectionInfo = new TestHostConnectionInfo - { - Endpoint = IPAddress.Loopback + ":124", - Role = ConnectionRole.Host, - Transport = Transport.Sockets - }; - ProtocolConfig protocolConfig = new ProtocolConfig { Version = 2 }; - var mockCommunicationEndpoint = new Mock(); - mockCommunicationEndpoint.Setup(mc => mc.Start(connectionInfo.Endpoint)).Returns(connectionInfo.Endpoint).Callback(() => - { - mockCommunicationEndpoint.Raise( - s => s.Connected += null, - mockCommunicationEndpoint.Object, - new ConnectedEventArgs(this.mockChannel.Object)); - }); - - this.SetupChannelMessage(MessageType.VersionCheck, MessageType.VersionCheck, protocolConfig.Version); - var testRequestSender = new TestRequestSender(mockCommunicationEndpoint.Object, connectionInfo, mockDataSerializer.Object, new ProtocolConfig { Version = 2 }, CLIENTPROCESSEXITWAIT); - - this.mockTestHostManager.Setup(thm => thm.GetTestHostConnectionInfo()).Returns(connectionInfo); - - var localTestOperationManager = new TestableProxyOperationManager(this.mockRequestData.Object, testRequestSender, this.mockTestHostManager.Object); - - localTestOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); - - mockCommunicationEndpoint.Verify(s => s.Start(It.IsAny()), Times.Once); - } + Endpoint = IPAddress.Loopback + ":124", + Role = ConnectionRole.Host, + Transport = Transport.Sockets + }; + ProtocolConfig protocolConfig = new() { Version = 2 }; + var mockCommunicationEndpoint = new Mock(); + mockCommunicationEndpoint.Setup(mc => mc.Start(connectionInfo.Endpoint)).Returns(connectionInfo.Endpoint).Callback(() => mockCommunicationEndpoint.Raise( + s => s.Connected += null, + mockCommunicationEndpoint.Object, + new ConnectedEventArgs(_mockChannel.Object))); - [TestMethod] - public void SetupChannelShouldNotInitializeIfConnectionIsAlreadyInitialized() - { - this.testOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); - this.testOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); + SetupChannelMessage(MessageType.VersionCheck, MessageType.VersionCheck, protocolConfig.Version); + var testRequestSender = new TestRequestSender(mockCommunicationEndpoint.Object, connectionInfo, _mockDataSerializer.Object, new ProtocolConfig { Version = 2 }, Clientprocessexitwait); - this.mockRequestSender.Verify(s => s.InitializeCommunication(), Times.Once); - } + _mockTestHostManager.Setup(thm => thm.GetTestHostConnectionInfo()).Returns(connectionInfo); - [TestMethod] - public void SetupChannelShouldWaitForTestHostConnection() - { - this.testOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); + var localTestOperationManager = new TestableProxyOperationManager(_mockRequestData.Object, testRequestSender, _mockTestHostManager.Object); - this.mockRequestSender.Verify(rs => rs.WaitForRequestHandlerConnection(this.connectionTimeout, It.IsAny()), Times.Once); - } + localTestOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); - [TestMethod] - public void SetupChannelShouldNotWaitForTestHostConnectionIfConnectionIsInitialized() - { - this.testOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); - this.testOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); + mockCommunicationEndpoint.Verify(s => s.Start(It.IsAny()), Times.Once); + } - this.mockRequestSender.Verify(rs => rs.WaitForRequestHandlerConnection(this.connectionTimeout, It.IsAny()), Times.Exactly(1)); - } + [TestMethod] + public void SetupChannelShouldNotInitializeIfConnectionIsAlreadyInitialized() + { + _testOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); + _testOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); - [TestMethod] - public void SetupChannelShouldHonorTimeOutSetByUser() - { - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, "100"); + _mockRequestSender.Verify(s => s.InitializeCommunication(), Times.Once); + } - this.mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(100000, It.IsAny())).Returns(true); - this.testOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); + [TestMethod] + public void SetupChannelShouldWaitForTestHostConnection() + { + _testOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); - this.mockRequestSender.Verify(rs => rs.WaitForRequestHandlerConnection(100000, It.IsAny()), Times.Exactly(1)); - } + _mockRequestSender.Verify(rs => rs.WaitForRequestHandlerConnection(_connectionTimeout, It.IsAny()), Times.Once); + } - [TestMethod] - public void SetupChannelShouldThrowIfWaitForTestHostConnectionTimesOut() - { - SetupTestHostLaunched(true); - this.mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(this.connectionTimeout, It.IsAny())).Returns(false); + [TestMethod] + public void SetupChannelShouldNotWaitForTestHostConnectionIfConnectionIsInitialized() + { + _testOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); + _testOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); - var operationManager = new TestableProxyOperationManager(this.mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object); + _mockRequestSender.Verify(rs => rs.WaitForRequestHandlerConnection(_connectionTimeout, It.IsAny()), Times.Exactly(1)); + } - var message = Assert.ThrowsException(() => operationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings)).Message; - Assert.AreEqual(message, ProxyOperationManagerTests.TimoutErrorMessage); - } + [TestMethod] + public void SetupChannelShouldHonorTimeOutSetByUser() + { + Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, "100"); - [TestMethod] - public void SetupChannelShouldThrowTestPlatformExceptionIfRequestCancelled() - { - SetupTestHostLaunched(true); - this.mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(this.connectionTimeout, It.IsAny())).Returns(false); + _mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(100000, It.IsAny())).Returns(true); + _testOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); - var cancellationTokenSource = new CancellationTokenSource(); - var operationManager = new TestableProxyOperationManager(this.mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object, cancellationTokenSource); + _mockRequestSender.Verify(rs => rs.WaitForRequestHandlerConnection(100000, It.IsAny()), Times.Exactly(1)); + } - cancellationTokenSource.Cancel(); - var message = Assert.ThrowsException(() => operationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings)).Message; - StringAssert.Equals("Canceling the operation as requested.", message); - } + [TestMethod] + public void SetupChannelShouldThrowIfWaitForTestHostConnectionTimesOut() + { + SetupTestHostLaunched(true); + _mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(_connectionTimeout, It.IsAny())).Returns(false); - [TestMethod] - public void SetupChannelShouldThrowTestPlatformExceptionIfRequestCancelledDuringLaunchOfTestHost() - { - SetupTestHostLaunched(true); - this.mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(this.connectionTimeout, It.IsAny())).Returns(false); + var operationManager = new TestableProxyOperationManager(_mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object); - this.mockTestHostManager.Setup(rs => rs.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Callback(() => Task.Run(() => { throw new OperationCanceledException(); })); + var message = Assert.ThrowsException(() => operationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings)).Message; + Assert.AreEqual(message, TimoutErrorMessage); + } - var cancellationTokenSource = new CancellationTokenSource(); - var operationManager = new TestableProxyOperationManager(this.mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object, cancellationTokenSource); + [TestMethod] + public void SetupChannelShouldThrowTestPlatformExceptionIfRequestCancelled() + { + SetupTestHostLaunched(true); + _mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(_connectionTimeout, It.IsAny())).Returns(false); - var message = Assert.ThrowsException(() => operationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings)).Message; - StringAssert.Equals("Canceling the operation as requested.", message); - } + var cancellationTokenSource = new CancellationTokenSource(); + var operationManager = new TestableProxyOperationManager(_mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object, cancellationTokenSource); - [TestMethod] - public void SetupChannelShouldThrowTestPlatformExceptionIfRequestCancelledPostHostLaunchDuringWaitForHandlerConnection() - { - SetupTestHostLaunched(true); - this.mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(this.connectionTimeout, It.IsAny())).Returns(false); + cancellationTokenSource.Cancel(); + var message = Assert.ThrowsException(() => operationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings)).Message; + Equals("Canceling the operation as requested.", message); + } - var cancellationTokenSource = new CancellationTokenSource(); - this.mockTestHostManager.Setup(rs => rs.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Callback(() => cancellationTokenSource.Cancel()); - var operationManager = new TestableProxyOperationManager(this.mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object, cancellationTokenSource); + [TestMethod] + public void SetupChannelShouldThrowTestPlatformExceptionIfRequestCancelledDuringLaunchOfTestHost() + { + SetupTestHostLaunched(true); + _mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(_connectionTimeout, It.IsAny())).Returns(false); - var message = Assert.ThrowsException(() => operationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings)).Message; - StringAssert.Equals("Canceling the operation as requested.", message); - } + _mockTestHostManager.Setup(rs => rs.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Callback(() => Task.Run(() => throw new OperationCanceledException())); - [TestMethod] - public void SetupChannelShouldThrowIfLaunchTestHostFails() - { - SetupTestHostLaunched(false); - this.mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(this.connectionTimeout, It.IsAny())).Returns(true); + var cancellationTokenSource = new CancellationTokenSource(); + var operationManager = new TestableProxyOperationManager(_mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object, cancellationTokenSource); - var operationManager = new TestableProxyOperationManager(this.mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object); + var message = Assert.ThrowsException(() => operationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings)).Message; + Equals("Canceling the operation as requested.", message); + } - var message = Assert.ThrowsException(() => operationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings)).Message; - Assert.AreEqual(message, string.Format(CultureInfo.CurrentUICulture, Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources.Resources.InitializationFailed)); - } + [TestMethod] + public void SetupChannelShouldThrowTestPlatformExceptionIfRequestCancelledPostHostLaunchDuringWaitForHandlerConnection() + { + SetupTestHostLaunched(true); + _mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(_connectionTimeout, It.IsAny())).Returns(false); - [TestMethod] - public void SetupChannelShouldCheckVersionWithTestHost() - { - this.testOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); - this.mockRequestSender.Verify(rs => rs.CheckVersionWithTestHost(), Times.Once); - } + var cancellationTokenSource = new CancellationTokenSource(); + _mockTestHostManager.Setup(rs => rs.LaunchTestHostAsync(It.IsAny(), It.IsAny())).Callback(() => cancellationTokenSource.Cancel()); + var operationManager = new TestableProxyOperationManager(_mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object, cancellationTokenSource); - [TestMethod] - public void SetupChannelShouldThrowExceptionIfVersionCheckFails() - { - // Make the version check fail - this.mockRequestSender.Setup(rs => rs.CheckVersionWithTestHost()).Throws(new TestPlatformException("Version check failed")); - Assert.ThrowsException(() => this.testOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings)); - } + var message = Assert.ThrowsException(() => operationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings)).Message; + Equals("Canceling the operation as requested.", message); + } - [TestMethod] - public void SetupChannelForDotnetHostManagerWithIsVersionCheckRequiredFalseShouldNotCheckVersionWithTestHost() - { - this.SetUpMocksForDotNetTestHost(); - var testHostManager = new TestableDotnetTestHostManager(false, this.mockProcessHelper.Object, this.mockFileHelper.Object, this.mockEnvironment.Object, this.mockRunsettingHelper.Object, this.mockWindowsRegistry.Object, this.mockEnvironmentVariableHelper.Object); - var operationManager = new TestableProxyOperationManager(this.mockRequestData.Object, this.mockRequestSender.Object, testHostManager); + [TestMethod] + public void SetupChannelShouldThrowIfLaunchTestHostFails() + { + SetupTestHostLaunched(false); + _mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(_connectionTimeout, It.IsAny())).Returns(true); - operationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); + var operationManager = new TestableProxyOperationManager(_mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object); - this.mockRequestSender.Verify(rs => rs.CheckVersionWithTestHost(), Times.Never); - } + var message = Assert.ThrowsException(() => operationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings)).Message; + Assert.AreEqual(message, string.Format(CultureInfo.CurrentUICulture, Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources.Resources.InitializationFailed)); + } - [TestMethod] - public void SetupChannelForDotnetHostManagerWithIsVersionCheckRequiredTrueShouldCheckVersionWithTestHost() - { - this.SetUpMocksForDotNetTestHost(); - var testHostManager = new TestableDotnetTestHostManager(true, this.mockProcessHelper.Object, this.mockFileHelper.Object, this.mockEnvironment.Object, this.mockRunsettingHelper.Object, this.mockWindowsRegistry.Object, this.mockEnvironmentVariableHelper.Object); - var operationManager = new TestableProxyOperationManager(this.mockRequestData.Object, this.mockRequestSender.Object, testHostManager); + [TestMethod] + public void SetupChannelShouldCheckVersionWithTestHost() + { + _testOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); + _mockRequestSender.Verify(rs => rs.CheckVersionWithTestHost(), Times.Once); + } - operationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); + [TestMethod] + public void SetupChannelShouldThrowExceptionIfVersionCheckFails() + { + // Make the version check fail + _mockRequestSender.Setup(rs => rs.CheckVersionWithTestHost()).Throws(new TestPlatformException("Version check failed")); + Assert.ThrowsException(() => _testOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings)); + } - this.mockRequestSender.Verify(rs => rs.CheckVersionWithTestHost(), Times.Once); - } + [TestMethod] + public void SetupChannelForDotnetHostManagerWithIsVersionCheckRequiredFalseShouldNotCheckVersionWithTestHost() + { + SetUpMocksForDotNetTestHost(); + var testHostManager = new TestableDotnetTestHostManager(false, _mockProcessHelper.Object, _mockFileHelper.Object, _mockEnvironment.Object, _mockRunsettingHelper.Object, _mockWindowsRegistry.Object, _mockEnvironmentVariableHelper.Object); + var operationManager = new TestableProxyOperationManager(_mockRequestData.Object, _mockRequestSender.Object, testHostManager); - [TestMethod] - public void CloseShouldEndSessionIfHostWasLaunched() - { - this.mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(this.connectionTimeout, It.IsAny())).Returns(true); - this.testOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); + operationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); - this.testOperationManager.Close(); + _mockRequestSender.Verify(rs => rs.CheckVersionWithTestHost(), Times.Never); + } - this.mockRequestSender.Verify(rs => rs.EndSession(), Times.Once); - } + [TestMethod] + public void SetupChannelForDotnetHostManagerWithIsVersionCheckRequiredTrueShouldCheckVersionWithTestHost() + { + SetUpMocksForDotNetTestHost(); + var testHostManager = new TestableDotnetTestHostManager(true, _mockProcessHelper.Object, _mockFileHelper.Object, _mockEnvironment.Object, _mockRunsettingHelper.Object, _mockWindowsRegistry.Object, _mockEnvironmentVariableHelper.Object); + var operationManager = new TestableProxyOperationManager(_mockRequestData.Object, _mockRequestSender.Object, testHostManager); - [TestMethod] - public void CloseShouldNotEndSessionIfHostLaucnhedFailed() - { - this.testOperationManager.Close(); + operationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); - this.mockRequestSender.Verify(rs => rs.EndSession(), Times.Never); - } + _mockRequestSender.Verify(rs => rs.CheckVersionWithTestHost(), Times.Once); + } - [TestMethod] - public void CloseShouldAlwaysCleanTestHost() - { - this.testOperationManager.Close(); + [TestMethod] + public void CloseShouldEndSessionIfHostWasLaunched() + { + _mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(_connectionTimeout, It.IsAny())).Returns(true); + _testOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); - this.mockTestHostManager.Verify(th => th.CleanTestHostAsync(It.IsAny()), Times.Once); - } + _testOperationManager.Close(); - [TestMethod] - public void CloseShouldResetChannelInitialization() - { - this.SetupWaitForTestHostExit(); - this.mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(this.connectionTimeout, It.IsAny())).Returns(true); - this.testOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); + _mockRequestSender.Verify(rs => rs.EndSession(), Times.Once); + } - this.testOperationManager.Close(); + [TestMethod] + public void CloseShouldNotEndSessionIfHostLaucnhedFailed() + { + _testOperationManager.Close(); - this.testOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); - this.mockTestHostManager.Verify(th => th.LaunchTestHostAsync(It.IsAny(), It.IsAny()), Times.Exactly(2)); - } + _mockRequestSender.Verify(rs => rs.EndSession(), Times.Never); + } - [TestMethod] - public void CloseShouldTerminateTesthostProcessIfWaitTimesout() - { - // Ensure testhost start returns a dummy process id - this.mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(this.connectionTimeout, It.IsAny())).Returns(true); - this.testOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); + [TestMethod] + public void CloseShouldAlwaysCleanTestHost() + { + _testOperationManager.Close(); - this.testOperationManager.Close(); + _mockTestHostManager.Verify(th => th.CleanTestHostAsync(It.IsAny()), Times.Once); + } - this.mockTestHostManager.Verify(th => th.CleanTestHostAsync(It.IsAny()), Times.Once); - } + [TestMethod] + public void CloseShouldResetChannelInitialization() + { + SetupWaitForTestHostExit(); + _mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(_connectionTimeout, It.IsAny())).Returns(true); + _testOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); - [TestMethod] - public void CloseShouldNotThrowIfEndSessionFails() - { - this.mockRequestSender.Setup(rs => rs.EndSession()).Throws(); + _testOperationManager.Close(); - this.testOperationManager.Close(); - } + _testOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); + _mockTestHostManager.Verify(th => th.LaunchTestHostAsync(It.IsAny(), It.IsAny()), Times.Exactly(2)); + } - private void SetupWaitForTestHostExit() - { - // Raise host exited when end session is called - this.mockRequestSender.Setup(rs => rs.EndSession()) - .Callback(() => this.mockTestHostManager.Raise(t => t.HostExited += null, new HostProviderEventArgs(string.Empty))); - } + [TestMethod] + public void CloseShouldTerminateTesthostProcessIfWaitTimesout() + { + // Ensure testhost start returns a dummy process id + _mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(_connectionTimeout, It.IsAny())).Returns(true); + _testOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); - private void SetupTestHostLaunched(bool launchStatus) - { - // Raise host exited when end session is called - this.mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())) - .Callback(() => this.mockTestHostManager.Raise(t => t.HostLaunched += null, new HostProviderEventArgs(string.Empty))) - .Returns(Task.FromResult(launchStatus)); - } + _testOperationManager.Close(); - [TestMethod] - public void UpdateTestProcessStartInfoShouldUpdateTelemetryOptedInArgTrueIfTelemetryOptedIn() - { - TestProcessStartInfo receivedTestProcessInfo = new TestProcessStartInfo(); - var mockRequestData = new Mock(); + _mockTestHostManager.Verify(th => th.CleanTestHostAsync(It.IsAny()), Times.Once); + } - mockRequestData.Setup(rd => rd.IsTelemetryOptedIn).Returns(true); + [TestMethod] + public void CloseShouldNotThrowIfEndSessionFails() + { + _mockRequestSender.Setup(rs => rs.EndSession()).Throws(); - var testOperationManager = new TestableProxyOperationManager(mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object); + _testOperationManager.Close(); + } - this.mockTestHostManager - .Setup(tm => tm.LaunchTestHostAsync(It.IsAny(), It.IsAny())) - .Callback( - (testProcessStartInfo, cancellationToken) => - { - receivedTestProcessInfo = testProcessStartInfo; - }) - .Returns(Task.FromResult(true)); + private void SetupWaitForTestHostExit() + { + // Raise host exited when end session is called + _mockRequestSender.Setup(rs => rs.EndSession()) + .Callback(() => _mockTestHostManager.Raise(t => t.HostExited += null, new HostProviderEventArgs(string.Empty))); + } - // Act. - testOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); + private void SetupTestHostLaunched(bool launchStatus) + { + // Raise host exited when end session is called + _mockTestHostManager.Setup(tmh => tmh.LaunchTestHostAsync(It.IsAny(), It.IsAny())) + .Callback(() => _mockTestHostManager.Raise(t => t.HostLaunched += null, new HostProviderEventArgs(string.Empty))) + .Returns(Task.FromResult(launchStatus)); + } - // Verify. - Assert.IsTrue(receivedTestProcessInfo.Arguments.Contains("--telemetryoptedin true")); - } + [TestMethod] + public void UpdateTestProcessStartInfoShouldUpdateTelemetryOptedInArgTrueIfTelemetryOptedIn() + { + TestProcessStartInfo receivedTestProcessInfo = new(); + var mockRequestData = new Mock(); - [TestMethod] - public void UpdateTestProcessStartInfoShouldUpdateTelemetryOptedInArgFalseIfTelemetryOptedOut() - { - TestProcessStartInfo receivedTestProcessInfo = new TestProcessStartInfo(); - var mockRequestData = new Mock(); + mockRequestData.Setup(rd => rd.IsTelemetryOptedIn).Returns(true); - mockRequestData.Setup(rd => rd.IsTelemetryOptedIn).Returns(false); + var testOperationManager = new TestableProxyOperationManager(mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object); - var testOperationManager = new TestableProxyOperationManager(mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object); + _mockTestHostManager + .Setup(tm => tm.LaunchTestHostAsync(It.IsAny(), It.IsAny())) + .Callback( + (testProcessStartInfo, cancellationToken) => receivedTestProcessInfo = testProcessStartInfo) + .Returns(Task.FromResult(true)); - this.mockTestHostManager - .Setup(tm => tm.LaunchTestHostAsync(It.IsAny(), It.IsAny())) - .Callback( - (testProcessStartInfo, cancellationToken) => - { - receivedTestProcessInfo = testProcessStartInfo; - }) - .Returns(Task.FromResult(true)); + // Act. + testOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); - // Act. - testOperationManager.SetupChannel(Enumerable.Empty(), this.defaultRunSettings); + // Verify. + Assert.IsTrue(receivedTestProcessInfo.Arguments.Contains("--telemetryoptedin true")); + } + + [TestMethod] + public void UpdateTestProcessStartInfoShouldUpdateTelemetryOptedInArgFalseIfTelemetryOptedOut() + { + TestProcessStartInfo receivedTestProcessInfo = new(); + var mockRequestData = new Mock(); + + mockRequestData.Setup(rd => rd.IsTelemetryOptedIn).Returns(false); + + var testOperationManager = new TestableProxyOperationManager(mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object); + + _mockTestHostManager + .Setup(tm => tm.LaunchTestHostAsync(It.IsAny(), It.IsAny())) + .Callback( + (testProcessStartInfo, cancellationToken) => receivedTestProcessInfo = testProcessStartInfo) + .Returns(Task.FromResult(true)); + + // Act. + testOperationManager.SetupChannel(Enumerable.Empty(), _defaultRunSettings); + + // Verify. + Assert.IsTrue(receivedTestProcessInfo.Arguments.Contains("--telemetryoptedin false")); + } - // Verify. - Assert.IsTrue(receivedTestProcessInfo.Arguments.Contains("--telemetryoptedin false")); + private void SetUpMocksForDotNetTestHost() + { + _mockProcessHelper = new Mock(); + _mockFileHelper = new Mock(); + _mockEnvironment = new Mock(); + _mockRunsettingHelper = new Mock(); + _mockWindowsRegistry = new Mock(); + _mockEnvironmentVariableHelper = new Mock(); + + _mockRunsettingHelper.SetupGet(r => r.IsDefaultTargetArchitecture).Returns(true); + _mockProcessHelper.Setup( + ph => + ph.LaunchProcess( + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>(), + It.IsAny>(), + It.IsAny>())) + .Callback, Action, Action, Action>( + (var1, var2, var3, dictionary, errorCallback, exitCallback, outputCallback) => + { + var process = Process.GetCurrentProcess(); + + errorCallback(process, string.Empty); + exitCallback(process); + }).Returns(Process.GetCurrentProcess()); + } + + private class TestableProxyOperationManager : ProxyOperationManager + { + public TestableProxyOperationManager(IRequestData requestData, + ITestRequestSender requestSender, + ITestRuntimeProvider testHostManager) : base(requestData, requestSender, testHostManager) + { } - private void SetUpMocksForDotNetTestHost() + public TestableProxyOperationManager( + IRequestData requestData, + ITestRequestSender requestSender, + ITestRuntimeProvider testHostManager, + CancellationTokenSource cancellationTokenSource) : base(requestData, requestSender, testHostManager) { - this.mockProcessHelper = new Mock(); - this.mockFileHelper = new Mock(); - this.mockEnvironment = new Mock(); - this.mockRunsettingHelper = new Mock(); - this.mockWindowsRegistry = new Mock(); - this.mockEnvironmentVariableHelper = new Mock(); - - this.mockRunsettingHelper.SetupGet(r => r.IsDefaultTargetArchitecture).Returns(true); - this.mockProcessHelper.Setup( - ph => - ph.LaunchProcess( - It.IsAny(), - It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>(), - It.IsAny>(), - It.IsAny>())) - .Callback, Action, Action, Action>( - (var1, var2, var3, dictionary, errorCallback, exitCallback, outputCallback) => - { - var process = Process.GetCurrentProcess(); - - errorCallback(process, string.Empty); - exitCallback(process); - }).Returns(Process.GetCurrentProcess()); + CancellationTokenSource = cancellationTokenSource; } + } + + private class TestableDotnetTestHostManager : DotnetTestHostManager + { + private readonly bool _isVersionCheckRequired; - private class TestableProxyOperationManager : ProxyOperationManager + public TestableDotnetTestHostManager( + bool checkRequired, + IProcessHelper processHelper, + IFileHelper fileHelper, + IEnvironment environment, + IRunSettingsHelper runsettingHelper, + IWindowsRegistryHelper windowsRegistryHelper, + IEnvironmentVariableHelper environmentVariableHelper) : base( + processHelper, + fileHelper, + new DotnetHostHelper(fileHelper, environment, windowsRegistryHelper, environmentVariableHelper, processHelper), + environment, + runsettingHelper, + windowsRegistryHelper, + environmentVariableHelper) { - public TestableProxyOperationManager(IRequestData requestData, - ITestRequestSender requestSender, - ITestRuntimeProvider testHostManager) : base(requestData, requestSender, testHostManager) - { - } - - public TestableProxyOperationManager( - IRequestData requestData, - ITestRequestSender requestSender, - ITestRuntimeProvider testHostManager, - CancellationTokenSource cancellationTokenSource) : base(requestData, requestSender, testHostManager) - { - this.CancellationTokenSource = cancellationTokenSource; - } + _isVersionCheckRequired = checkRequired; } - private class TestableDotnetTestHostManager : DotnetTestHostManager + internal override bool IsVersionCheckRequired => _isVersionCheckRequired; + + public override TestProcessStartInfo GetTestHostProcessStartInfo( + IEnumerable sources, + IDictionary environmentVariables, + TestRunnerConnectionInfo connectionInfo) { - private bool isVersionCheckRequired; - - public TestableDotnetTestHostManager( - bool checkRequired, - IProcessHelper processHelper, - IFileHelper fileHelper, - IEnvironment environment, - IRunSettingsHelper runsettingHelper, - IWindowsRegistryHelper windowsRegistryHelper, - IEnvironmentVariableHelper environmentVariableHelper) : base( - processHelper, - fileHelper, - new DotnetHostHelper(fileHelper, environment, windowsRegistryHelper, environmentVariableHelper, processHelper), - environment, - runsettingHelper, - windowsRegistryHelper, - environmentVariableHelper) - { - this.isVersionCheckRequired = checkRequired; - } - - internal override bool IsVersionCheckRequired => this.isVersionCheckRequired; - - public override TestProcessStartInfo GetTestHostProcessStartInfo( - IEnumerable sources, - IDictionary environmentVariables, - TestRunnerConnectionInfo connectionInfo) - { - return new TestProcessStartInfo(); - } + return new TestProcessStartInfo(); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyTestSessionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyTestSessionManagerTests.cs index d8764eb2c3..c7cf525111 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyTestSessionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyTestSessionManagerTests.cs @@ -1,335 +1,334 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.Client -{ - using System; - using System.Collections.Generic; +namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.Client; + +using System; +using System.Collections.Generic; + +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class ProxyTestSessionManagerTests +{ + private readonly IList _fakeTestSources = new List() { @"C:\temp\FakeTestAsset.dll" }; + private readonly IList _fakeTestMultipleSources = new List() { + @"C:\temp\FakeTestAsset1.dll", + @"C:\temp\FakeTestAsset2.dll", + @"C:\temp\FakeTestAsset3.dll", + @"C:\temp\FakeTestAsset4.dll", + @"C:\temp\FakeTestAsset5.dll", + @"C:\temp\FakeTestAsset6.dll", + @"C:\temp\FakeTestAsset7.dll", + @"C:\temp\FakeTestAsset8.dll", + }; + private readonly string _fakeRunSettings = "FakeRunSettings"; + private Mock _mockEventsHandler; + + [TestInitialize] + public void TestInitialize() + { + TestSessionPool.Instance = null; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestTools.UnitTesting; + _mockEventsHandler = new Mock(); - using Moq; + _mockEventsHandler.Setup(e => e.HandleStartTestSessionComplete(It.IsAny())) + .Callback((TestSessionInfo tsi) => { }); + } - [TestClass] - public class ProxyTestSessionManagerTests + [TestMethod] + public void StartSessionShouldSucceedIfCalledOnlyOnce() { - private readonly IList fakeTestSources = new List() { @"C:\temp\FakeTestAsset.dll" }; - private readonly IList fakeTestMultipleSources = new List() { - @"C:\temp\FakeTestAsset1.dll", - @"C:\temp\FakeTestAsset2.dll", - @"C:\temp\FakeTestAsset3.dll", - @"C:\temp\FakeTestAsset4.dll", - @"C:\temp\FakeTestAsset5.dll", - @"C:\temp\FakeTestAsset6.dll", - @"C:\temp\FakeTestAsset7.dll", - @"C:\temp\FakeTestAsset8.dll", - }; - private readonly string fakeRunSettings = "FakeRunSettings"; - private Mock mockEventsHandler; + var mockProxyOperationManager = new Mock(null, null, null); + mockProxyOperationManager.Setup(pom => pom.SetupChannel(It.IsAny>(), It.IsAny())) + .Returns(true); + + var testSessionCriteria = CreateTestSession(_fakeTestSources, _fakeRunSettings); + var proxyManager = CreateProxy(testSessionCriteria, mockProxyOperationManager.Object); + + // First call to StartSession should succeed. + Assert.IsTrue(proxyManager.StartSession(_mockEventsHandler.Object)); + mockProxyOperationManager.Verify(pom => pom.SetupChannel( + testSessionCriteria.Sources, + testSessionCriteria.RunSettings), + Times.Once); + _mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( + It.IsAny()), + Times.Once); + + // Second call to StartSession should fail. + Assert.IsFalse(proxyManager.StartSession(_mockEventsHandler.Object)); + mockProxyOperationManager.Verify(pom => pom.SetupChannel( + testSessionCriteria.Sources, + testSessionCriteria.RunSettings), + Times.Once); + _mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( + It.IsAny()), + Times.Once); + } - [TestInitialize] - public void TestInitialize() - { - TestSessionPool.Instance = null; + [TestMethod] + public void StartSessionShouldSucceedWhenCalledWithMultipleSources() + { + var mockProxyOperationManager = new Mock(null, null, null); + mockProxyOperationManager.Setup(pom => pom.SetupChannel(It.IsAny>(), It.IsAny())) + .Returns(true); + + var testSessionCriteria = CreateTestSession(_fakeTestMultipleSources, _fakeRunSettings); + var proxyManager = CreateProxy(testSessionCriteria, mockProxyOperationManager.Object); + + // First call to StartSession should succeed. + Assert.IsTrue(proxyManager.StartSession(_mockEventsHandler.Object)); + mockProxyOperationManager.Verify(pom => pom.SetupChannel( + It.IsAny>(), + testSessionCriteria.RunSettings), + Times.Exactly(_fakeTestMultipleSources.Count)); + _mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( + It.IsAny()), + Times.Once); + } - this.mockEventsHandler = new Mock(); + [TestMethod] + public void StartSessionShouldFailIfProxyCreatorIsNull() + { + var testSessionCriteria = CreateTestSession(_fakeTestSources, _fakeRunSettings); + var proxyManager = CreateProxy(testSessionCriteria, null); - this.mockEventsHandler.Setup(e => e.HandleStartTestSessionComplete(It.IsAny())) - .Callback((TestSessionInfo tsi) => { }); - } + Assert.IsFalse(proxyManager.StartSession(_mockEventsHandler.Object)); + _mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( + It.IsAny()), + Times.Never); + } - [TestMethod] - public void StartSessionShouldSucceedIfCalledOnlyOnce() - { - var mockProxyOperationManager = new Mock(null, null, null); - mockProxyOperationManager.Setup(pom => pom.SetupChannel(It.IsAny>(), It.IsAny())) - .Returns(true); - - var testSessionCriteria = this.CreateTestSession(this.fakeTestSources, this.fakeRunSettings); - var proxyManager = this.CreateProxy(testSessionCriteria, mockProxyOperationManager.Object); - - // First call to StartSession should succeed. - Assert.IsTrue(proxyManager.StartSession(this.mockEventsHandler.Object)); - mockProxyOperationManager.Verify(pom => pom.SetupChannel( - testSessionCriteria.Sources, - testSessionCriteria.RunSettings), - Times.Once); - this.mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( - It.IsAny()), - Times.Once); - - // Second call to StartSession should fail. - Assert.IsFalse(proxyManager.StartSession(this.mockEventsHandler.Object)); - mockProxyOperationManager.Verify(pom => pom.SetupChannel( - testSessionCriteria.Sources, - testSessionCriteria.RunSettings), - Times.Once); - this.mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( - It.IsAny()), - Times.Once); - } - - [TestMethod] - public void StartSessionShouldSucceedWhenCalledWithMultipleSources() - { - var mockProxyOperationManager = new Mock(null, null, null); - mockProxyOperationManager.Setup(pom => pom.SetupChannel(It.IsAny>(), It.IsAny())) - .Returns(true); - - var testSessionCriteria = this.CreateTestSession(this.fakeTestMultipleSources, this.fakeRunSettings); - var proxyManager = this.CreateProxy(testSessionCriteria, mockProxyOperationManager.Object); - - // First call to StartSession should succeed. - Assert.IsTrue(proxyManager.StartSession(this.mockEventsHandler.Object)); - mockProxyOperationManager.Verify(pom => pom.SetupChannel( - It.IsAny>(), - testSessionCriteria.RunSettings), - Times.Exactly(this.fakeTestMultipleSources.Count)); - this.mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( - It.IsAny()), - Times.Once); - } - - [TestMethod] - public void StartSessionShouldFailIfProxyCreatorIsNull() - { - var testSessionCriteria = this.CreateTestSession(this.fakeTestSources, this.fakeRunSettings); - var proxyManager = this.CreateProxy(testSessionCriteria, null); + [TestMethod] + public void StartSessionShouldFailIfSetupChannelReturnsFalse() + { + var mockProxyOperationManager = new Mock(null, null, null); + mockProxyOperationManager.Setup(pom => pom.SetupChannel(It.IsAny>(), It.IsAny())) + .Returns(false); + mockProxyOperationManager.Setup(pom => pom.Close()).Callback(() => { }); + + var testSessionCriteria = CreateTestSession(_fakeTestSources, _fakeRunSettings); + var proxyManager = CreateProxy(testSessionCriteria, mockProxyOperationManager.Object); + + // Call fails because SetupChannel returns false. + Assert.IsFalse(proxyManager.StartSession(_mockEventsHandler.Object)); + mockProxyOperationManager.Verify(pom => pom.SetupChannel( + It.IsAny>(), + It.IsAny()), + Times.Once); + mockProxyOperationManager.Verify(pom => pom.Close(), Times.Never); + _mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( + It.IsAny()), + Times.Never); + } - Assert.IsFalse(proxyManager.StartSession(this.mockEventsHandler.Object)); - this.mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( - It.IsAny()), - Times.Never); - } + [TestMethod] + public void StartSessionShouldFailIfSetupChannelThrowsException() + { + var mockProxyOperationManager = new Mock(null, null, null); + mockProxyOperationManager.Setup(pom => pom.SetupChannel(It.IsAny>(), It.IsAny())) + .Throws(new TestPlatformException("Dummy exception.")); + mockProxyOperationManager.Setup(pom => pom.Close()).Callback(() => { }); + + var testSessionCriteria = CreateTestSession(_fakeTestSources, _fakeRunSettings); + var proxyManager = CreateProxy(testSessionCriteria, mockProxyOperationManager.Object); + + // Call fails because SetupChannel returns false. + Assert.IsFalse(proxyManager.StartSession(_mockEventsHandler.Object)); + mockProxyOperationManager.Verify(pom => pom.SetupChannel( + It.IsAny>(), + It.IsAny()), + Times.Once); + mockProxyOperationManager.Verify(pom => pom.Close(), Times.Never); + _mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( + It.IsAny()), + Times.Never); + } - [TestMethod] - public void StartSessionShouldFailIfSetupChannelReturnsFalse() - { - var mockProxyOperationManager = new Mock(null, null, null); - mockProxyOperationManager.Setup(pom => pom.SetupChannel(It.IsAny>(), It.IsAny())) - .Returns(false); - mockProxyOperationManager.Setup(pom => pom.Close()).Callback(() => { }); - - var testSessionCriteria = this.CreateTestSession(this.fakeTestSources, this.fakeRunSettings); - var proxyManager = this.CreateProxy(testSessionCriteria, mockProxyOperationManager.Object); - - // Call fails because SetupChannel returns false. - Assert.IsFalse(proxyManager.StartSession(this.mockEventsHandler.Object)); - mockProxyOperationManager.Verify(pom => pom.SetupChannel( - It.IsAny>(), - It.IsAny()), - Times.Once); - mockProxyOperationManager.Verify(pom => pom.Close(), Times.Never); - this.mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( - It.IsAny()), - Times.Never); - } - - [TestMethod] - public void StartSessionShouldFailIfSetupChannelThrowsException() - { - var mockProxyOperationManager = new Mock(null, null, null); - mockProxyOperationManager.Setup(pom => pom.SetupChannel(It.IsAny>(), It.IsAny())) - .Throws(new TestPlatformException("Dummy exception.")); - mockProxyOperationManager.Setup(pom => pom.Close()).Callback(() => { }); - - var testSessionCriteria = this.CreateTestSession(this.fakeTestSources, this.fakeRunSettings); - var proxyManager = this.CreateProxy(testSessionCriteria, mockProxyOperationManager.Object); - - // Call fails because SetupChannel returns false. - Assert.IsFalse(proxyManager.StartSession(this.mockEventsHandler.Object)); - mockProxyOperationManager.Verify(pom => pom.SetupChannel( - It.IsAny>(), - It.IsAny()), - Times.Once); - mockProxyOperationManager.Verify(pom => pom.Close(), Times.Never); - this.mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( - It.IsAny()), - Times.Never); - } - - [TestMethod] - public void StartSessionShouldFailIfAddSessionFails() - { - var mockTestSessionPool = new Mock(); - mockTestSessionPool.Setup(tsp => tsp.AddSession(It.IsAny(), It.IsAny())) - .Returns(false); - TestSessionPool.Instance = mockTestSessionPool.Object; - - var mockProxyOperationManager = new Mock(null, null, null); - mockProxyOperationManager.Setup(pom => pom.SetupChannel(It.IsAny>(), It.IsAny())) - .Returns(true); - mockProxyOperationManager.Setup(pom => pom.Close()).Callback(() => { }); - - var testSessionCriteria = this.CreateTestSession(this.fakeTestSources, this.fakeRunSettings); - var proxyManager = this.CreateProxy(testSessionCriteria, mockProxyOperationManager.Object); - - // Call to StartSession should fail because AddSession fails. - Assert.IsFalse(proxyManager.StartSession(this.mockEventsHandler.Object)); - mockProxyOperationManager.Verify(pom => pom.SetupChannel( - testSessionCriteria.Sources, - testSessionCriteria.RunSettings), - Times.Once); - mockProxyOperationManager.Verify(pom => pom.Close(), Times.Once); - this.mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( - It.IsAny()), - Times.Never); - } - - [TestMethod] - public void StopSessionShouldSucceedIfCalledOnlyOnce() - { - var mockProxyOperationManager = new Mock(null, null, null); - mockProxyOperationManager.Setup(pom => pom.SetupChannel(It.IsAny>(), It.IsAny())) - .Returns(true); - mockProxyOperationManager.Setup(pom => pom.Close()).Callback(() => { }); - - var testSessionCriteria = this.CreateTestSession(this.fakeTestSources, this.fakeRunSettings); - var proxyManager = this.CreateProxy(testSessionCriteria, mockProxyOperationManager.Object); - - // StartSession should succeed. - Assert.IsTrue(proxyManager.StartSession(this.mockEventsHandler.Object)); - mockProxyOperationManager.Verify(pom => pom.SetupChannel( - testSessionCriteria.Sources, - testSessionCriteria.RunSettings), - Times.Once); - this.mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( - It.IsAny()), - Times.Once); - - // First call to StopSession should succeed. - Assert.IsTrue(proxyManager.StopSession()); - mockProxyOperationManager.Verify(pom => pom.Close(), Times.Once); - - // Second call to StopSession should fail. - Assert.IsFalse(proxyManager.StopSession()); - mockProxyOperationManager.Verify(pom => pom.Close(), Times.Once); - } - - [TestMethod] - public void StopSessionShouldSucceedWhenCalledWithMultipleSources() - { - var mockProxyOperationManager = new Mock(null, null, null); - mockProxyOperationManager.Setup(pom => pom.SetupChannel(It.IsAny>(), It.IsAny())) - .Returns(true); - mockProxyOperationManager.Setup(pom => pom.Close()).Callback(() => { }); - - var testSessionCriteria = this.CreateTestSession(this.fakeTestMultipleSources, this.fakeRunSettings); - var proxyManager = this.CreateProxy(testSessionCriteria, mockProxyOperationManager.Object); - - // StartSession should succeed. - Assert.IsTrue(proxyManager.StartSession(this.mockEventsHandler.Object)); - mockProxyOperationManager.Verify(pom => pom.SetupChannel( - It.IsAny>(), - testSessionCriteria.RunSettings), - Times.Exactly(testSessionCriteria.Sources.Count)); - this.mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( - It.IsAny()), - Times.Once); - - // First call to StopSession should succeed. - Assert.IsTrue(proxyManager.StopSession()); - mockProxyOperationManager.Verify(pom => pom.Close(), Times.Exactly(testSessionCriteria.Sources.Count)); - } - - [TestMethod] - public void DequeueProxyShouldSucceedIfIdentificationCriteriaAreMet() - { - var mockProxyOperationManager = new Mock(null, null, null); - mockProxyOperationManager.Setup(pom => pom.SetupChannel(It.IsAny>(), It.IsAny())) - .Returns(true); - - var testSessionCriteria = this.CreateTestSession(this.fakeTestSources, this.fakeRunSettings); - var proxyManager = this.CreateProxy(testSessionCriteria, mockProxyOperationManager.Object); - - // StartSession should succeed. - Assert.IsTrue(proxyManager.StartSession(this.mockEventsHandler.Object)); - mockProxyOperationManager.Verify(pom => pom.SetupChannel( - It.IsAny>(), - testSessionCriteria.RunSettings), - Times.Exactly(testSessionCriteria.Sources.Count)); - this.mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( - It.IsAny()), - Times.Once); - - // First call to DequeueProxy fails because of source mismatch. - Assert.ThrowsException(() => proxyManager.DequeueProxy( - @"C:\temp\FakeTestAsset2.dll", - testSessionCriteria.RunSettings)); - - // Second call to DequeueProxy fails because of runsettings mismatch. - Assert.ThrowsException(() => proxyManager.DequeueProxy( + [TestMethod] + public void StartSessionShouldFailIfAddSessionFails() + { + var mockTestSessionPool = new Mock(); + mockTestSessionPool.Setup(tsp => tsp.AddSession(It.IsAny(), It.IsAny())) + .Returns(false); + TestSessionPool.Instance = mockTestSessionPool.Object; + + var mockProxyOperationManager = new Mock(null, null, null); + mockProxyOperationManager.Setup(pom => pom.SetupChannel(It.IsAny>(), It.IsAny())) + .Returns(true); + mockProxyOperationManager.Setup(pom => pom.Close()).Callback(() => { }); + + var testSessionCriteria = CreateTestSession(_fakeTestSources, _fakeRunSettings); + var proxyManager = CreateProxy(testSessionCriteria, mockProxyOperationManager.Object); + + // Call to StartSession should fail because AddSession fails. + Assert.IsFalse(proxyManager.StartSession(_mockEventsHandler.Object)); + mockProxyOperationManager.Verify(pom => pom.SetupChannel( + testSessionCriteria.Sources, + testSessionCriteria.RunSettings), + Times.Once); + mockProxyOperationManager.Verify(pom => pom.Close(), Times.Once); + _mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( + It.IsAny()), + Times.Never); + } + + [TestMethod] + public void StopSessionShouldSucceedIfCalledOnlyOnce() + { + var mockProxyOperationManager = new Mock(null, null, null); + mockProxyOperationManager.Setup(pom => pom.SetupChannel(It.IsAny>(), It.IsAny())) + .Returns(true); + mockProxyOperationManager.Setup(pom => pom.Close()).Callback(() => { }); + + var testSessionCriteria = CreateTestSession(_fakeTestSources, _fakeRunSettings); + var proxyManager = CreateProxy(testSessionCriteria, mockProxyOperationManager.Object); + + // StartSession should succeed. + Assert.IsTrue(proxyManager.StartSession(_mockEventsHandler.Object)); + mockProxyOperationManager.Verify(pom => pom.SetupChannel( + testSessionCriteria.Sources, + testSessionCriteria.RunSettings), + Times.Once); + _mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( + It.IsAny()), + Times.Once); + + // First call to StopSession should succeed. + Assert.IsTrue(proxyManager.StopSession()); + mockProxyOperationManager.Verify(pom => pom.Close(), Times.Once); + + // Second call to StopSession should fail. + Assert.IsFalse(proxyManager.StopSession()); + mockProxyOperationManager.Verify(pom => pom.Close(), Times.Once); + } + + [TestMethod] + public void StopSessionShouldSucceedWhenCalledWithMultipleSources() + { + var mockProxyOperationManager = new Mock(null, null, null); + mockProxyOperationManager.Setup(pom => pom.SetupChannel(It.IsAny>(), It.IsAny())) + .Returns(true); + mockProxyOperationManager.Setup(pom => pom.Close()).Callback(() => { }); + + var testSessionCriteria = CreateTestSession(_fakeTestMultipleSources, _fakeRunSettings); + var proxyManager = CreateProxy(testSessionCriteria, mockProxyOperationManager.Object); + + // StartSession should succeed. + Assert.IsTrue(proxyManager.StartSession(_mockEventsHandler.Object)); + mockProxyOperationManager.Verify(pom => pom.SetupChannel( + It.IsAny>(), + testSessionCriteria.RunSettings), + Times.Exactly(testSessionCriteria.Sources.Count)); + _mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( + It.IsAny()), + Times.Once); + + // First call to StopSession should succeed. + Assert.IsTrue(proxyManager.StopSession()); + mockProxyOperationManager.Verify(pom => pom.Close(), Times.Exactly(testSessionCriteria.Sources.Count)); + } + + [TestMethod] + public void DequeueProxyShouldSucceedIfIdentificationCriteriaAreMet() + { + var mockProxyOperationManager = new Mock(null, null, null); + mockProxyOperationManager.Setup(pom => pom.SetupChannel(It.IsAny>(), It.IsAny())) + .Returns(true); + + var testSessionCriteria = CreateTestSession(_fakeTestSources, _fakeRunSettings); + var proxyManager = CreateProxy(testSessionCriteria, mockProxyOperationManager.Object); + + // StartSession should succeed. + Assert.IsTrue(proxyManager.StartSession(_mockEventsHandler.Object)); + mockProxyOperationManager.Verify(pom => pom.SetupChannel( + It.IsAny>(), + testSessionCriteria.RunSettings), + Times.Exactly(testSessionCriteria.Sources.Count)); + _mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( + It.IsAny()), + Times.Once); + + // First call to DequeueProxy fails because of source mismatch. + Assert.ThrowsException(() => proxyManager.DequeueProxy( + @"C:\temp\FakeTestAsset2.dll", + testSessionCriteria.RunSettings)); + + // Second call to DequeueProxy fails because of runsettings mismatch. + Assert.ThrowsException(() => proxyManager.DequeueProxy( + testSessionCriteria.Sources[0], + "DummyRunSettings")); + + // Third call to DequeueProxy succeeds. + Assert.AreEqual(proxyManager.DequeueProxy( testSessionCriteria.Sources[0], - "DummyRunSettings")); - - // Third call to DequeueProxy succeeds. - Assert.AreEqual(proxyManager.DequeueProxy( - testSessionCriteria.Sources[0], - testSessionCriteria.RunSettings), - mockProxyOperationManager.Object); - - // Fourth call to DequeueProxy fails because proxy became unavailable following successful deque. - Assert.ThrowsException(() => proxyManager.DequeueProxy( + testSessionCriteria.RunSettings), + mockProxyOperationManager.Object); + + // Fourth call to DequeueProxy fails because proxy became unavailable following successful deque. + Assert.ThrowsException(() => proxyManager.DequeueProxy( + testSessionCriteria.Sources[0], + testSessionCriteria.RunSettings)); + } + + [TestMethod] + public void EnqueueProxyShouldSucceedIfIdentificationCriteriaAreMet() + { + var mockProxyOperationManager = new Mock(null, null, null); + mockProxyOperationManager.Setup(pom => pom.SetupChannel(It.IsAny>(), It.IsAny())) + .Returns(true); + + var testSessionCriteria = CreateTestSession(_fakeTestSources, _fakeRunSettings); + var proxyManager = CreateProxy(testSessionCriteria, mockProxyOperationManager.Object); + + // Validate sanity checks. + Assert.ThrowsException(() => proxyManager.EnqueueProxy(-1)); + Assert.ThrowsException(() => proxyManager.EnqueueProxy(1)); + + // StartSession should succeed. + Assert.IsTrue(proxyManager.StartSession(_mockEventsHandler.Object)); + mockProxyOperationManager.Verify(pom => pom.SetupChannel( + It.IsAny>(), + testSessionCriteria.RunSettings), + Times.Exactly(testSessionCriteria.Sources.Count)); + _mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( + It.IsAny()), + Times.Once); + + // Call throws exception because proxy is already available. + Assert.ThrowsException(() => proxyManager.EnqueueProxy(0)); + + // Call succeeds. + Assert.AreEqual(proxyManager.DequeueProxy( testSessionCriteria.Sources[0], - testSessionCriteria.RunSettings)); - } + testSessionCriteria.RunSettings), + mockProxyOperationManager.Object); + Assert.IsTrue(proxyManager.EnqueueProxy(0)); + } - [TestMethod] - public void EnqueueProxyShouldSucceedIfIdentificationCriteriaAreMet() - { - var mockProxyOperationManager = new Mock(null, null, null); - mockProxyOperationManager.Setup(pom => pom.SetupChannel(It.IsAny>(), It.IsAny())) - .Returns(true); - - var testSessionCriteria = this.CreateTestSession(this.fakeTestSources, this.fakeRunSettings); - var proxyManager = this.CreateProxy(testSessionCriteria, mockProxyOperationManager.Object); - - // Validate sanity checks. - Assert.ThrowsException(() => proxyManager.EnqueueProxy(-1)); - Assert.ThrowsException(() => proxyManager.EnqueueProxy(1)); - - // StartSession should succeed. - Assert.IsTrue(proxyManager.StartSession(this.mockEventsHandler.Object)); - mockProxyOperationManager.Verify(pom => pom.SetupChannel( - It.IsAny>(), - testSessionCriteria.RunSettings), - Times.Exactly(testSessionCriteria.Sources.Count)); - this.mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete( - It.IsAny()), - Times.Once); - - // Call throws exception because proxy is already available. - Assert.ThrowsException(() => proxyManager.EnqueueProxy(0)); - - // Call succeeds. - Assert.AreEqual(proxyManager.DequeueProxy( - testSessionCriteria.Sources[0], - testSessionCriteria.RunSettings), - mockProxyOperationManager.Object); - Assert.IsTrue(proxyManager.EnqueueProxy(0)); - } - - private StartTestSessionCriteria CreateTestSession(IList sources, string runSettings) - { - return new StartTestSessionCriteria() - { - Sources = sources, - RunSettings = runSettings - }; - } - - private ProxyTestSessionManager CreateProxy( - StartTestSessionCriteria testSessionCriteria, - ProxyOperationManager proxyOperationManager) + private StartTestSessionCriteria CreateTestSession(IList sources, string runSettings) + { + return new StartTestSessionCriteria() { - return new ProxyTestSessionManager( - testSessionCriteria, - testSessionCriteria.Sources.Count, - () => { return proxyOperationManager; }); - } + Sources = sources, + RunSettings = runSettings + }; + } + + private ProxyTestSessionManager CreateProxy( + StartTestSessionCriteria testSessionCriteria, + ProxyOperationManager proxyOperationManager) + { + return new ProxyTestSessionManager( + testSessionCriteria, + testSessionCriteria.Sources.Count, + () => proxyOperationManager); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/DataCollectionLauncherFactoryTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/DataCollectionLauncherFactoryTests.cs index 50ce45cbf1..32cf828e54 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/DataCollectionLauncherFactoryTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/DataCollectionLauncherFactoryTests.cs @@ -1,49 +1,48 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.DataCollection +namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.DataCollection; + +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class DataCollectionLauncherFactoryTests { - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; + private readonly Mock _mockProcessHelper; + + private readonly string _dummyRunSettings = + ""; + + public DataCollectionLauncherFactoryTests() + { + _mockProcessHelper = new Mock(); + } + + [TestMethod] + public void GetDataCollectorLauncherShouldReturnDefaultDataCollectionLauncherWithFullClrRunner() + { + _mockProcessHelper.Setup(x => x.GetCurrentProcessFileName()).Returns("vstest.console.exe"); + var dataCollectorLauncher = DataCollectionLauncherFactory.GetDataCollectorLauncher(_mockProcessHelper.Object, _dummyRunSettings); + Assert.IsInstanceOfType(dataCollectorLauncher, typeof(DefaultDataCollectionLauncher)); + } - using Moq; + [TestMethod] + public void GetDataCollectorLauncherShouldReturnDotnetDataCollectionLauncherWithDotnetCore() + { + _mockProcessHelper.Setup(x => x.GetCurrentProcessFileName()).Returns("dotnet"); + var dataCollectorLauncher = DataCollectionLauncherFactory.GetDataCollectorLauncher(_mockProcessHelper.Object, _dummyRunSettings); + Assert.IsInstanceOfType(dataCollectorLauncher, typeof(DotnetDataCollectionLauncher)); + } - [TestClass] - public class DataCollectionLauncherFactoryTests + [TestMethod] + public void GetDataCollectorLauncherShouldBeInsensitiveToCaseOfCurrentProcess() { - private Mock mockProcessHelper; - - private string dummyRunSettings = - ""; - - public DataCollectionLauncherFactoryTests() - { - this.mockProcessHelper = new Mock(); - } - - [TestMethod] - public void GetDataCollectorLauncherShouldReturnDefaultDataCollectionLauncherWithFullCLRRunner() - { - mockProcessHelper.Setup(x => x.GetCurrentProcessFileName()).Returns("vstest.console.exe"); - var dataCollectorLauncher = DataCollectionLauncherFactory.GetDataCollectorLauncher(mockProcessHelper.Object, this.dummyRunSettings); - Assert.IsInstanceOfType(dataCollectorLauncher, typeof(DefaultDataCollectionLauncher)); - } - - [TestMethod] - public void GetDataCollectorLauncherShouldReturnDotnetDataCollectionLauncherWithDotnetCore() - { - mockProcessHelper.Setup(x => x.GetCurrentProcessFileName()).Returns("dotnet"); - var dataCollectorLauncher = DataCollectionLauncherFactory.GetDataCollectorLauncher(mockProcessHelper.Object, this.dummyRunSettings); - Assert.IsInstanceOfType(dataCollectorLauncher, typeof(DotnetDataCollectionLauncher)); - } - - [TestMethod] - public void GetDataCollectorLauncherShouldBeInsensitiveToCaseOfCurrentProcess() - { - mockProcessHelper.Setup(x => x.GetCurrentProcessFileName()).Returns("DOTNET"); - var dataCollectorLauncher = DataCollectionLauncherFactory.GetDataCollectorLauncher(mockProcessHelper.Object, this.dummyRunSettings); - Assert.IsInstanceOfType(dataCollectorLauncher, typeof(DotnetDataCollectionLauncher)); - } + _mockProcessHelper.Setup(x => x.GetCurrentProcessFileName()).Returns("DOTNET"); + var dataCollectorLauncher = DataCollectionLauncherFactory.GetDataCollectorLauncher(_mockProcessHelper.Object, _dummyRunSettings); + Assert.IsInstanceOfType(dataCollectorLauncher, typeof(DotnetDataCollectionLauncher)); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/DataCollectionTestRunEventsHandlerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/DataCollectionTestRunEventsHandlerTests.cs index d801a23c3d..9474a25459 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/DataCollectionTestRunEventsHandlerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/DataCollectionTestRunEventsHandlerTests.cs @@ -1,183 +1,184 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.DataCollection +namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.DataCollection; + +using System; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class DataCollectionTestRunEventsHandlerTests { - using System; - using System.Collections.ObjectModel; - using System.Linq; - using System.Threading; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - [TestClass] - public class DataCollectionTestRunEventsHandlerTests + private Mock _baseTestRunEventsHandler; + private DataCollectionTestRunEventsHandler _testRunEventHandler; + private Mock _proxyDataCollectionManager; + private Mock _mockDataSerializer; + + [TestInitialize] + public void InitializeTests() { - private Mock baseTestRunEventsHandler; - private DataCollectionTestRunEventsHandler testRunEventHandler; - private Mock proxyDataCollectionManager; - private Mock mockDataSerializer; + _baseTestRunEventsHandler = new Mock(); + _proxyDataCollectionManager = new Mock(); + _mockDataSerializer = new Mock(); + _testRunEventHandler = new DataCollectionTestRunEventsHandler(_baseTestRunEventsHandler.Object, _proxyDataCollectionManager.Object, _mockDataSerializer.Object, CancellationToken.None); + } - [TestInitialize] - public void InitializeTests() - { - this.baseTestRunEventsHandler = new Mock(); - this.proxyDataCollectionManager = new Mock(); - this.mockDataSerializer = new Mock(); - this.testRunEventHandler = new DataCollectionTestRunEventsHandler(this.baseTestRunEventsHandler.Object, this.proxyDataCollectionManager.Object, this.mockDataSerializer.Object, CancellationToken.None); - } - - [TestMethod] - public void HandleLogMessageShouldSendMessageToBaseTestRunEventsHandler() - { - this.testRunEventHandler.HandleLogMessage(TestMessageLevel.Informational, null); - this.baseTestRunEventsHandler.Verify(th => th.HandleLogMessage(0, null), Times.AtLeast(1)); - } + [TestMethod] + public void HandleLogMessageShouldSendMessageToBaseTestRunEventsHandler() + { + _testRunEventHandler.HandleLogMessage(TestMessageLevel.Informational, null); + _baseTestRunEventsHandler.Verify(th => th.HandleLogMessage(0, null), Times.AtLeast(1)); + } - [TestMethod] - public void HandleRawMessageShouldSendMessageToBaseTestRunEventsHandler() - { - this.mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())).Returns(new Message() { MessageType = MessageType.BeforeTestRunStart }); - this.testRunEventHandler.HandleRawMessage(null); - this.baseTestRunEventsHandler.Verify(th => th.HandleRawMessage(null), Times.AtLeast(1)); - } + [TestMethod] + public void HandleRawMessageShouldSendMessageToBaseTestRunEventsHandler() + { + _mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())).Returns(new Message() { MessageType = MessageType.BeforeTestRunStart }); + _testRunEventHandler.HandleRawMessage(null); + _baseTestRunEventsHandler.Verify(th => th.HandleRawMessage(null), Times.AtLeast(1)); + } - [TestMethod] - public void HandleRawMessageShouldGetDataCollectorAttachments() - { - var testRunCompleteEventArgs = new TestRunCompleteEventArgs(null, false, false, null, new Collection(), new Collection(), new TimeSpan()); + [TestMethod] + public void HandleRawMessageShouldGetDataCollectorAttachments() + { + var testRunCompleteEventArgs = new TestRunCompleteEventArgs(null, false, false, null, new Collection(), new Collection(), new TimeSpan()); - this.mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())).Returns(new Message() { MessageType = MessageType.ExecutionComplete }); - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) - .Returns(new TestRunCompletePayload() { TestRunCompleteArgs = testRunCompleteEventArgs }); + _mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())).Returns(new Message() { MessageType = MessageType.ExecutionComplete }); + _mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) + .Returns(new TestRunCompletePayload() { TestRunCompleteArgs = testRunCompleteEventArgs }); - this.testRunEventHandler.HandleRawMessage(string.Empty); - this.proxyDataCollectionManager.Verify( - dcm => dcm.AfterTestRunEnd(false, It.IsAny()), - Times.Once); - } + _testRunEventHandler.HandleRawMessage(string.Empty); + _proxyDataCollectionManager.Verify( + dcm => dcm.AfterTestRunEnd(false, It.IsAny()), + Times.Once); + } - [TestMethod] - public void HandleRawMessageShouldInvokeAfterTestRunEndPassingFalseIfRequestNotCancelled() - { - var testRunCompleteEventArgs = new TestRunCompleteEventArgs(null, false, false, null, new Collection(), new Collection(), new TimeSpan()); + [TestMethod] + public void HandleRawMessageShouldInvokeAfterTestRunEndPassingFalseIfRequestNotCancelled() + { + var testRunCompleteEventArgs = new TestRunCompleteEventArgs(null, false, false, null, new Collection(), new Collection(), new TimeSpan()); - this.mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())).Returns(new Message() { MessageType = MessageType.ExecutionComplete }); - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) - .Returns(new TestRunCompletePayload() { TestRunCompleteArgs = testRunCompleteEventArgs }); + _mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())).Returns(new Message() { MessageType = MessageType.ExecutionComplete }); + _mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) + .Returns(new TestRunCompletePayload() { TestRunCompleteArgs = testRunCompleteEventArgs }); - var cancellationTokenSource = new CancellationTokenSource(); - testRunEventHandler = new DataCollectionTestRunEventsHandler(this.baseTestRunEventsHandler.Object, this.proxyDataCollectionManager.Object, this.mockDataSerializer.Object, cancellationTokenSource.Token); + var cancellationTokenSource = new CancellationTokenSource(); + _testRunEventHandler = new DataCollectionTestRunEventsHandler(_baseTestRunEventsHandler.Object, _proxyDataCollectionManager.Object, _mockDataSerializer.Object, cancellationTokenSource.Token); - testRunEventHandler.HandleRawMessage(string.Empty); + _testRunEventHandler.HandleRawMessage(string.Empty); - this.proxyDataCollectionManager.Verify( - dcm => dcm.AfterTestRunEnd(false, It.IsAny()), - Times.Once); - } + _proxyDataCollectionManager.Verify( + dcm => dcm.AfterTestRunEnd(false, It.IsAny()), + Times.Once); + } - [TestMethod] - public void HandleRawMessageShouldInvokeAfterTestRunEndPassingTrueIfRequestCancelled() - { - var testRunCompleteEventArgs = new TestRunCompleteEventArgs(null, false, false, null, new Collection(), new Collection(), new TimeSpan()); + [TestMethod] + public void HandleRawMessageShouldInvokeAfterTestRunEndPassingTrueIfRequestCancelled() + { + var testRunCompleteEventArgs = new TestRunCompleteEventArgs(null, false, false, null, new Collection(), new Collection(), new TimeSpan()); - this.mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())).Returns(new Message() { MessageType = MessageType.ExecutionComplete }); - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) - .Returns(new TestRunCompletePayload() { TestRunCompleteArgs = testRunCompleteEventArgs }); + _mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())).Returns(new Message() { MessageType = MessageType.ExecutionComplete }); + _mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) + .Returns(new TestRunCompletePayload() { TestRunCompleteArgs = testRunCompleteEventArgs }); - var cancellationTokenSource = new CancellationTokenSource(); - testRunEventHandler = new DataCollectionTestRunEventsHandler(this.baseTestRunEventsHandler.Object, this.proxyDataCollectionManager.Object, this.mockDataSerializer.Object, cancellationTokenSource.Token); - cancellationTokenSource.Cancel(); + var cancellationTokenSource = new CancellationTokenSource(); + _testRunEventHandler = new DataCollectionTestRunEventsHandler(_baseTestRunEventsHandler.Object, _proxyDataCollectionManager.Object, _mockDataSerializer.Object, cancellationTokenSource.Token); + cancellationTokenSource.Cancel(); - testRunEventHandler.HandleRawMessage(string.Empty); + _testRunEventHandler.HandleRawMessage(string.Empty); - this.proxyDataCollectionManager.Verify( - dcm => dcm.AfterTestRunEnd(true, It.IsAny()), - Times.Once); - } + _proxyDataCollectionManager.Verify( + dcm => dcm.AfterTestRunEnd(true, It.IsAny()), + Times.Once); + } - [TestMethod] - public void HandleRawMessageShouldInvokeAfterTestRunEndAndReturnInvokedDataCollectors() + [TestMethod] + public void HandleRawMessageShouldInvokeAfterTestRunEndAndReturnInvokedDataCollectors() + { + var invokedDataCollectors = new Collection { - var invokedDataCollectors = new Collection(); - invokedDataCollectors.Add(new InvokedDataCollector(new Uri("datacollector://sample"), "sample", typeof(string).AssemblyQualifiedName, typeof(string).Assembly.Location, true)); - - var testRunCompleteEventArgs = new TestRunCompleteEventArgs(null, false, false, null, new Collection(), new Collection(), new TimeSpan()); - this.mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())).Returns(new Message() { MessageType = MessageType.ExecutionComplete }); - this.mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) - .Returns(new TestRunCompletePayload() { TestRunCompleteArgs = testRunCompleteEventArgs }); - this.proxyDataCollectionManager.Setup(p => p.AfterTestRunEnd(It.IsAny(), It.IsAny())) - .Returns(new DataCollectionResult(null, invokedDataCollectors)); - this.mockDataSerializer.Setup(r => r.SerializePayload(It.IsAny(), It.IsAny())).Callback((string message, object o) => - { - Assert.AreEqual(1, ((TestRunCompletePayload)o).TestRunCompleteArgs.InvokedDataCollectors.Count); - Assert.AreEqual(invokedDataCollectors[0], ((TestRunCompletePayload)o).TestRunCompleteArgs.InvokedDataCollectors[0]); - }); - - testRunEventHandler = new DataCollectionTestRunEventsHandler(this.baseTestRunEventsHandler.Object, this.proxyDataCollectionManager.Object, this.mockDataSerializer.Object, CancellationToken.None); - testRunEventHandler.HandleRawMessage(string.Empty); - - var testRunCompleteEventArgs2 = new TestRunCompleteEventArgs(null, false, false, null, new Collection(), new Collection(), new TimeSpan()); - testRunEventHandler.HandleTestRunComplete(testRunCompleteEventArgs2, null, null, null); - Assert.AreEqual(1, testRunCompleteEventArgs2.InvokedDataCollectors.Count); - Assert.AreEqual(invokedDataCollectors[0], testRunCompleteEventArgs2.InvokedDataCollectors[0]); - - this.proxyDataCollectionManager.Verify( - dcm => dcm.AfterTestRunEnd(false, It.IsAny()), - Times.Once); - } - - #region Get Combined Attachments - [TestMethod] - public void GetCombinedAttachmentSetsShouldReturnCombinedAttachments() + new InvokedDataCollector(new Uri("datacollector://sample"), "sample", typeof(string).AssemblyQualifiedName, typeof(string).Assembly.Location, true) + }; + + var testRunCompleteEventArgs = new TestRunCompleteEventArgs(null, false, false, null, new Collection(), new Collection(), new TimeSpan()); + _mockDataSerializer.Setup(x => x.DeserializeMessage(It.IsAny())).Returns(new Message() { MessageType = MessageType.ExecutionComplete }); + _mockDataSerializer.Setup(x => x.DeserializePayload(It.IsAny())) + .Returns(new TestRunCompletePayload() { TestRunCompleteArgs = testRunCompleteEventArgs }); + _proxyDataCollectionManager.Setup(p => p.AfterTestRunEnd(It.IsAny(), It.IsAny())) + .Returns(new DataCollectionResult(null, invokedDataCollectors)); + _mockDataSerializer.Setup(r => r.SerializePayload(It.IsAny(), It.IsAny())).Callback((string message, object o) => { - Collection Attachments1 = new Collection(); - AttachmentSet attachmentset1 = new AttachmentSet(new Uri("DataCollection://Attachment/v1"), "AttachmentV1"); - attachmentset1.Attachments.Add(new UriDataAttachment(new Uri("DataCollection://Attachment/v11"), "AttachmentV1-Attachment1")); - Attachments1.Add(attachmentset1); + Assert.AreEqual(1, ((TestRunCompletePayload)o).TestRunCompleteArgs.InvokedDataCollectors.Count); + Assert.AreEqual(invokedDataCollectors[0], ((TestRunCompletePayload)o).TestRunCompleteArgs.InvokedDataCollectors[0]); + }); - Collection Attachments2 = new Collection(); - AttachmentSet attachmentset2 = new AttachmentSet(new Uri("DataCollection://Attachment/v1"), "AttachmentV1"); - attachmentset2.Attachments.Add(new UriDataAttachment(new Uri("DataCollection://Attachment/v12"), "AttachmentV1-Attachment2")); + _testRunEventHandler = new DataCollectionTestRunEventsHandler(_baseTestRunEventsHandler.Object, _proxyDataCollectionManager.Object, _mockDataSerializer.Object, CancellationToken.None); + _testRunEventHandler.HandleRawMessage(string.Empty); - Attachments2.Add(attachmentset2); + var testRunCompleteEventArgs2 = new TestRunCompleteEventArgs(null, false, false, null, new Collection(), new Collection(), new TimeSpan()); + _testRunEventHandler.HandleTestRunComplete(testRunCompleteEventArgs2, null, null, null); + Assert.AreEqual(1, testRunCompleteEventArgs2.InvokedDataCollectors.Count); + Assert.AreEqual(invokedDataCollectors[0], testRunCompleteEventArgs2.InvokedDataCollectors[0]); - var result = DataCollectionTestRunEventsHandler.GetCombinedAttachmentSets(Attachments1, Attachments2); + _proxyDataCollectionManager.Verify( + dcm => dcm.AfterTestRunEnd(false, It.IsAny()), + Times.Once); + } - Assert.AreEqual(1, result.Count); - Assert.AreEqual(2, result.First().Attachments.Count); - } + #region Get Combined Attachments + [TestMethod] + public void GetCombinedAttachmentSetsShouldReturnCombinedAttachments() + { + Collection attachments1 = new(); + AttachmentSet attachmentset1 = new(new Uri("DataCollection://Attachment/v1"), "AttachmentV1"); + attachmentset1.Attachments.Add(new UriDataAttachment(new Uri("DataCollection://Attachment/v11"), "AttachmentV1-Attachment1")); + attachments1.Add(attachmentset1); - [TestMethod] - public void GetCombinedAttachmentSetsShouldReturnFirstArgumentIfSecondArgumentIsNull() - { - Collection Attachments1 = new Collection(); - AttachmentSet attachmentset1 = new AttachmentSet(new Uri("DataCollection://Attachment/v1"), "AttachmentV1"); - attachmentset1.Attachments.Add(new UriDataAttachment(new Uri("DataCollection://Attachment/v11"), "AttachmentV1-Attachment1")); - Attachments1.Add(attachmentset1); + Collection attachments2 = new(); + AttachmentSet attachmentset2 = new(new Uri("DataCollection://Attachment/v1"), "AttachmentV1"); + attachmentset2.Attachments.Add(new UriDataAttachment(new Uri("DataCollection://Attachment/v12"), "AttachmentV1-Attachment2")); - var result = DataCollectionTestRunEventsHandler.GetCombinedAttachmentSets(Attachments1, null); + attachments2.Add(attachmentset2); - Assert.AreEqual(1, result.Count); - Assert.AreEqual(1, result.First().Attachments.Count); - } + var result = DataCollectionTestRunEventsHandler.GetCombinedAttachmentSets(attachments1, attachments2); - [TestMethod] - public void GetCombinedAttachmentSetsShouldReturnNullIfFirstArgumentIsNull() - { - var result = DataCollectionTestRunEventsHandler.GetCombinedAttachmentSets(null, null); - Assert.IsNull(result); - } + Assert.AreEqual(1, result.Count); + Assert.AreEqual(2, result.First().Attachments.Count); + } - #endregion + [TestMethod] + public void GetCombinedAttachmentSetsShouldReturnFirstArgumentIfSecondArgumentIsNull() + { + Collection attachments1 = new(); + AttachmentSet attachmentset1 = new(new Uri("DataCollection://Attachment/v1"), "AttachmentV1"); + attachmentset1.Attachments.Add(new UriDataAttachment(new Uri("DataCollection://Attachment/v11"), "AttachmentV1-Attachment1")); + attachments1.Add(attachmentset1); + + var result = DataCollectionTestRunEventsHandler.GetCombinedAttachmentSets(attachments1, null); + + Assert.AreEqual(1, result.Count); + Assert.AreEqual(1, result.First().Attachments.Count); } + + [TestMethod] + public void GetCombinedAttachmentSetsShouldReturnNullIfFirstArgumentIsNull() + { + var result = DataCollectionTestRunEventsHandler.GetCombinedAttachmentSets(null, null); + Assert.IsNull(result); + } + + #endregion } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/DotnetDataCollectionLauncherTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/DotnetDataCollectionLauncherTests.cs index 337e267ff4..ab63191aab 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/DotnetDataCollectionLauncherTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/DotnetDataCollectionLauncherTests.cs @@ -1,72 +1,71 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.DataCollection +namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.DataCollection; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; + +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class DotnetDataCollectionLauncherTests { - using System; - using System.Collections.Generic; - using System.IO; - using System.Reflection; - - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - [TestClass] - public class DotnetDataCollectionLauncherTests - { - private Mock mockFileHelper; + private readonly Mock _mockFileHelper; - private Mock mockProcessHelper; + private readonly Mock _mockProcessHelper; - private Mock mockMessageLogger; + private readonly Mock _mockMessageLogger; - private DotnetDataCollectionLauncher dataCollectionLauncher; + private readonly DotnetDataCollectionLauncher _dataCollectionLauncher; - public DotnetDataCollectionLauncherTests() - { - this.mockFileHelper = new Mock(); - this.mockProcessHelper = new Mock(); - this.mockMessageLogger = new Mock(); + public DotnetDataCollectionLauncherTests() + { + _mockFileHelper = new Mock(); + _mockProcessHelper = new Mock(); + _mockMessageLogger = new Mock(); - this.dataCollectionLauncher = new DotnetDataCollectionLauncher(this.mockProcessHelper.Object, this.mockFileHelper.Object, this.mockMessageLogger.Object); - } + _dataCollectionLauncher = new DotnetDataCollectionLauncher(_mockProcessHelper.Object, _mockFileHelper.Object, _mockMessageLogger.Object); + } - [TestMethod] - public void LaunchDataCollectorShouldLaunchDataCollectorProcess() - { - List arguments = new List(); - this.dataCollectionLauncher.LaunchDataCollector(null, arguments); + [TestMethod] + public void LaunchDataCollectorShouldLaunchDataCollectorProcess() + { + List arguments = new(); + _dataCollectionLauncher.LaunchDataCollector(null, arguments); - this.mockProcessHelper.Verify(x => x.LaunchProcess(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny>(), It.IsAny>()), Times.Once()); - } + _mockProcessHelper.Verify(x => x.LaunchProcess(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny>(), It.IsAny>()), Times.Once()); + } - [TestMethod] - public void LaunchDataCollectorShouldAppendDoubleQuoteForDataCollectorDllPath() - { - var currentWorkingDirectory = Path.GetDirectoryName(typeof(DefaultDataCollectionLauncher).GetTypeInfo().Assembly.GetAssemblyLocation()); - var dataCollectorAssemblyPath = Path.Combine(currentWorkingDirectory, "datacollector.dll"); + [TestMethod] + public void LaunchDataCollectorShouldAppendDoubleQuoteForDataCollectorDllPath() + { + var currentWorkingDirectory = Path.GetDirectoryName(typeof(DefaultDataCollectionLauncher).GetTypeInfo().Assembly.GetAssemblyLocation()); + var dataCollectorAssemblyPath = Path.Combine(currentWorkingDirectory, "datacollector.dll"); - List arguments = new List(); - this.dataCollectionLauncher.LaunchDataCollector(null, arguments); + List arguments = new(); + _dataCollectionLauncher.LaunchDataCollector(null, arguments); - this.mockProcessHelper.Verify(x => x.LaunchProcess(It.IsAny(), string.Format("{0} \"{1}\" {2} ", "exec", dataCollectorAssemblyPath, string.Join(" ", arguments)), It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny>(), It.IsAny>()), Times.Once()); - } + _mockProcessHelper.Verify(x => x.LaunchProcess(It.IsAny(), string.Format("{0} \"{1}\" {2} ", "exec", dataCollectorAssemblyPath, string.Join(" ", arguments)), It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny>(), It.IsAny>()), Times.Once()); + } - [TestMethod] - public void LaunchDataCollectorShouldLaunchDataCollectorProcessWithCurrecntWorkingDirectory() - { - List arguments = new List(); - this.dataCollectionLauncher.LaunchDataCollector(null, arguments); + [TestMethod] + public void LaunchDataCollectorShouldLaunchDataCollectorProcessWithCurrecntWorkingDirectory() + { + List arguments = new(); + _dataCollectionLauncher.LaunchDataCollector(null, arguments); - string currentWorkingDirectory = Directory.GetCurrentDirectory(); + string currentWorkingDirectory = Directory.GetCurrentDirectory(); - this.mockProcessHelper.Verify(x => x.LaunchProcess(It.IsAny(), It.IsAny(), currentWorkingDirectory, It.IsAny>(), It.IsAny>(), It.IsAny>(), It.IsAny>()), Times.Once()); - } + _mockProcessHelper.Verify(x => x.LaunchProcess(It.IsAny(), It.IsAny(), currentWorkingDirectory, It.IsAny>(), It.IsAny>(), It.IsAny>(), It.IsAny>()), Times.Once()); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectionExtensionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectionExtensionManagerTests.cs index 0b439bff1a..bec606ec81 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectionExtensionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectionExtensionManagerTests.cs @@ -1,32 +1,31 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.DataCollection +namespace TestPlatform.CrossPlatEngine.UnitTests.DataCollection; + +using System; +using System.IO; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Xml; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +using Constants = Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Constants; + +[TestClass] +public class InProcDataCollectionExtensionManagerTests { - using System; - using System.IO; - using System.Collections.Generic; - using System.Linq; - using System.Reflection; - using System.Xml; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - using Constants = Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Constants; - using TestResult = Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult; - - [TestClass] - public class InProcDataCollectionExtensionManagerTests - { - private string settingsXml = @" + private readonly string _settingsXml = @" @@ -37,39 +36,39 @@ public class InProcDataCollectionExtensionManagerTests "; - private Mock mockTestEventsPublisher; - private TestableInProcDataCollectionExtensionManager inProcDataCollectionManager; - private static string temp = Path.GetTempPath(); - private string defaultCodebase = Path.Combine(temp, "repos", "MSTest", "src", "managed", "TestPlatform", "TestImpactListener.Tests", "bin", "Debug"); - private Mock mockFileHelper; - private TestPluginCache testPluginCache; - - [TestInitialize] - public void TestInit() - { - this.mockTestEventsPublisher = new Mock(); - this.mockFileHelper = new Mock(); - this.testPluginCache = TestPluginCache.Instance; - this.inProcDataCollectionManager = new TestableInProcDataCollectionExtensionManager(this.settingsXml, this.mockTestEventsPublisher.Object, this.defaultCodebase, this.testPluginCache, this.mockFileHelper.Object); - } + private Mock _mockTestEventsPublisher; + private TestableInProcDataCollectionExtensionManager _inProcDataCollectionManager; + private static readonly string Temp = Path.GetTempPath(); + private readonly string _defaultCodebase = Path.Combine(Temp, "repos", "MSTest", "src", "managed", "TestPlatform", "TestImpactListener.Tests", "bin", "Debug"); + private Mock _mockFileHelper; + private TestPluginCache _testPluginCache; + + [TestInitialize] + public void TestInit() + { + _mockTestEventsPublisher = new Mock(); + _mockFileHelper = new Mock(); + _testPluginCache = TestPluginCache.Instance; + _inProcDataCollectionManager = new TestableInProcDataCollectionExtensionManager(_settingsXml, _mockTestEventsPublisher.Object, _defaultCodebase, _testPluginCache, _mockFileHelper.Object); + } - [TestMethod] - public void InProcDataCollectionExtensionManagerShouldLoadsDataCollectorsFromRunSettings() - { - var dataCollector = inProcDataCollectionManager.InProcDataCollectors.First().Value as MockDataCollector; + [TestMethod] + public void InProcDataCollectionExtensionManagerShouldLoadsDataCollectorsFromRunSettings() + { + var dataCollector = _inProcDataCollectionManager.InProcDataCollectors.First().Value as MockDataCollector; - Assert.IsTrue(inProcDataCollectionManager.IsInProcDataCollectionEnabled, "InProcDataCollection must be enabled if runsettings contains inproc datacollectors."); - Assert.AreEqual(1, inProcDataCollectionManager.InProcDataCollectors.Count, "One Datacollector must be registered"); + Assert.IsTrue(_inProcDataCollectionManager.IsInProcDataCollectionEnabled, "InProcDataCollection must be enabled if runsettings contains inproc datacollectors."); + Assert.AreEqual(1, _inProcDataCollectionManager.InProcDataCollectors.Count, "One Datacollector must be registered"); - StringAssert.Equals(dataCollector.AssemblyQualifiedName, "TestImpactListener.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7ccb7239ffde675a"); - StringAssert.Equals(dataCollector.CodeBase, Path.Combine(temp, "repos", "MSTest", "src", "managed", "TestPlatform", "TestImpactListener.Tests", "bin", "Debug", "TestImpactListener.Tests.dll")); - StringAssert.Equals(dataCollector.Configuration.OuterXml, @"4312"); - } + Equals(dataCollector.AssemblyQualifiedName, "TestImpactListener.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7ccb7239ffde675a"); + Equals(dataCollector.CodeBase, Path.Combine(Temp, "repos", "MSTest", "src", "managed", "TestPlatform", "TestImpactListener.Tests", "bin", "Debug", "TestImpactListener.Tests.dll")); + Equals(dataCollector.Configuration.OuterXml, @"4312"); + } - [TestMethod] - public void InProcDataCollectionExtensionManagerLoadsDataCollectorFromDefaultCodebaseIfExistsAndCodebaseIsRelative() - { - string settingsXml = @" + [TestMethod] + public void InProcDataCollectionExtensionManagerLoadsDataCollectorFromDefaultCodebaseIfExistsAndCodebaseIsRelative() + { + string settingsXml = @" @@ -81,17 +80,17 @@ public void InProcDataCollectionExtensionManagerLoadsDataCollectorFromDefaultCod "; - this.mockFileHelper.Setup(fh => fh.Exists(Path.Combine(temp, "repos", "MSTest", "src", "managed", "TestPlatform", "TestImpactListener.Tests", "bin", "Debug", "TestImpactListener.Tests.dll"))).Returns(true); - this.inProcDataCollectionManager = new TestableInProcDataCollectionExtensionManager(settingsXml, this.mockTestEventsPublisher.Object, this.defaultCodebase, this.testPluginCache, this.mockFileHelper.Object); + _mockFileHelper.Setup(fh => fh.Exists(Path.Combine(Temp, "repos", "MSTest", "src", "managed", "TestPlatform", "TestImpactListener.Tests", "bin", "Debug", "TestImpactListener.Tests.dll"))).Returns(true); + _inProcDataCollectionManager = new TestableInProcDataCollectionExtensionManager(settingsXml, _mockTestEventsPublisher.Object, _defaultCodebase, _testPluginCache, _mockFileHelper.Object); - var codebase = (inProcDataCollectionManager.InProcDataCollectors.Values.First() as MockDataCollector).CodeBase; - Assert.AreEqual(Path.Combine(temp, "repos", "MSTest", "src", "managed", "TestPlatform", "TestImpactListener.Tests", "bin", "Debug", "TestImpactListener.Tests.dll"), codebase); - } + var codebase = (_inProcDataCollectionManager.InProcDataCollectors.Values.First() as MockDataCollector).CodeBase; + Assert.AreEqual(Path.Combine(Temp, "repos", "MSTest", "src", "managed", "TestPlatform", "TestImpactListener.Tests", "bin", "Debug", "TestImpactListener.Tests.dll"), codebase); + } - [TestMethod] - public void InProcDataCollectionExtensionManagerLoadsDataCollectorFromTestPluginCacheIfExistsAndCodebaseIsRelative() - { - string settingsXml = @" + [TestMethod] + public void InProcDataCollectionExtensionManagerLoadsDataCollectorFromTestPluginCacheIfExistsAndCodebaseIsRelative() + { + string settingsXml = @" @@ -103,19 +102,19 @@ public void InProcDataCollectionExtensionManagerLoadsDataCollectorFromTestPlugin "; - this.testPluginCache.UpdateExtensions(new List { Path.Combine(temp, "source", ".nuget", "TestImpactListenerDataCollector.dll") }, true); - this.mockFileHelper.Setup(fh => fh.Exists(Path.Combine(temp, "source", ".nuget", "TestImpactListenerDataCollector.dll"))).Returns(true); + _testPluginCache.UpdateExtensions(new List { Path.Combine(Temp, "source", ".nuget", "TestImpactListenerDataCollector.dll") }, true); + _mockFileHelper.Setup(fh => fh.Exists(Path.Combine(Temp, "source", ".nuget", "TestImpactListenerDataCollector.dll"))).Returns(true); - this.inProcDataCollectionManager = new TestableInProcDataCollectionExtensionManager(settingsXml, this.mockTestEventsPublisher.Object, this.defaultCodebase, this.testPluginCache, this.mockFileHelper.Object); + _inProcDataCollectionManager = new TestableInProcDataCollectionExtensionManager(settingsXml, _mockTestEventsPublisher.Object, _defaultCodebase, _testPluginCache, _mockFileHelper.Object); - var codebase = (inProcDataCollectionManager.InProcDataCollectors.Values.First() as MockDataCollector).CodeBase; - Assert.AreEqual(Path.Combine(temp,"source", ".nuget", "TestImpactListenerDataCollector.dll"), codebase); - } + var codebase = (_inProcDataCollectionManager.InProcDataCollectors.Values.First() as MockDataCollector).CodeBase; + Assert.AreEqual(Path.Combine(Temp, "source", ".nuget", "TestImpactListenerDataCollector.dll"), codebase); + } - [TestMethod] - public void InProcDataCollectionExtensionManagerLoadsDataCollectorFromGivenCodebaseIfCodebaseIsAbsolute() - { - string settingsXml = @" + [TestMethod] + public void InProcDataCollectionExtensionManagerLoadsDataCollectorFromGivenCodebaseIfCodebaseIsAbsolute() + { + string settingsXml = @" @@ -126,19 +125,19 @@ public void InProcDataCollectionExtensionManagerLoadsDataCollectorFromGivenCodeb "; - this.inProcDataCollectionManager = new TestableInProcDataCollectionExtensionManager(settingsXml, this.mockTestEventsPublisher.Object, this.defaultCodebase, this.testPluginCache, this.mockFileHelper.Object); + _inProcDataCollectionManager = new TestableInProcDataCollectionExtensionManager(settingsXml, _mockTestEventsPublisher.Object, _defaultCodebase, _testPluginCache, _mockFileHelper.Object); - var codebase = (inProcDataCollectionManager.InProcDataCollectors.Values.First() as MockDataCollector).CodeBase; - Assert.AreEqual("\\\\DummyPath\\TestImpactListener.Tests.dll", codebase); - } + var codebase = (_inProcDataCollectionManager.InProcDataCollectors.Values.First() as MockDataCollector).CodeBase; + Assert.AreEqual("\\\\DummyPath\\TestImpactListener.Tests.dll", codebase); + } - [TestMethod] - public void InProcDataCollectorIsReadingMultipleDataCollector() - { - var temp = Path.GetTempPath(); - var path1 = Path.Combine(temp, "repos", "MSTest", "src", "managed", "TestPlatform", "TestImpactListener.Tests", "bin", "Debug", "TestImpactListener.Tests1.dll"); - var path2 = Path.Combine(temp, "repos", "MSTest", "src", "managed", "TestPlatform", "TestImpactListener.Tests", "bin", "Debug", "TestImpactListener.Tests2.dll"); - var multiSettingsXml = $@" + [TestMethod] + public void InProcDataCollectorIsReadingMultipleDataCollector() + { + var temp = Path.GetTempPath(); + var path1 = Path.Combine(temp, "repos", "MSTest", "src", "managed", "TestPlatform", "TestImpactListener.Tests", "bin", "Debug", "TestImpactListener.Tests1.dll"); + var path2 = Path.Combine(temp, "repos", "MSTest", "src", "managed", "TestPlatform", "TestImpactListener.Tests", "bin", "Debug", "TestImpactListener.Tests2.dll"); + var multiSettingsXml = $@" @@ -155,37 +154,37 @@ public void InProcDataCollectorIsReadingMultipleDataCollector() "; - this.inProcDataCollectionManager = new TestableInProcDataCollectionExtensionManager(multiSettingsXml, this.mockTestEventsPublisher.Object, this.defaultCodebase, this.testPluginCache, this.mockFileHelper.Object); - bool secondOne = false; - MockDataCollector dataCollector1 = null; - MockDataCollector dataCollector2 = null; + _inProcDataCollectionManager = new TestableInProcDataCollectionExtensionManager(multiSettingsXml, _mockTestEventsPublisher.Object, _defaultCodebase, _testPluginCache, _mockFileHelper.Object); + bool secondOne = false; + MockDataCollector dataCollector1 = null; + MockDataCollector dataCollector2 = null; - foreach (var inProcDC in inProcDataCollectionManager.InProcDataCollectors.Values) + foreach (var inProcDc in _inProcDataCollectionManager.InProcDataCollectors.Values) + { + if (secondOne) + { + dataCollector2 = inProcDc as MockDataCollector; + } + else { - if (secondOne) - { - dataCollector2 = inProcDC as MockDataCollector; - } - else - { - dataCollector1 = inProcDC as MockDataCollector; - secondOne = true; - } + dataCollector1 = inProcDc as MockDataCollector; + secondOne = true; } + } - Assert.IsTrue(string.Equals(dataCollector1.AssemblyQualifiedName, "TestImpactListener.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7ccb7239ffde675a", StringComparison.OrdinalIgnoreCase)); - Assert.IsTrue(string.Equals(dataCollector1.CodeBase, Path.Combine(temp, "repos", "MSTest", "src", "managed", "TestPlatform", "TestImpactListener.Tests", "bin", "Debug", "TestImpactListener.Tests1.dll"), StringComparison.OrdinalIgnoreCase)); - Assert.IsTrue(string.Equals(dataCollector1.Configuration.OuterXml, @"4312", StringComparison.OrdinalIgnoreCase)); + Assert.IsTrue(string.Equals(dataCollector1.AssemblyQualifiedName, "TestImpactListener.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7ccb7239ffde675a", StringComparison.OrdinalIgnoreCase)); + Assert.IsTrue(string.Equals(dataCollector1.CodeBase, Path.Combine(temp, "repos", "MSTest", "src", "managed", "TestPlatform", "TestImpactListener.Tests", "bin", "Debug", "TestImpactListener.Tests1.dll"), StringComparison.OrdinalIgnoreCase)); + Assert.IsTrue(string.Equals(dataCollector1.Configuration.OuterXml, @"4312", StringComparison.OrdinalIgnoreCase)); - Assert.IsTrue(string.Equals(dataCollector2.AssemblyQualifiedName, "TestImpactListener.Tests, Version=2.0.0.0, Culture=neutral, PublicKeyToken=7ccb7239ffde675a", StringComparison.OrdinalIgnoreCase)); - Assert.IsTrue(string.Equals(dataCollector2.CodeBase, Path.Combine(temp, "repos", "MSTest", "src", "managed", "TestPlatform", "TestImpactListener.Tests", "bin", "Debug", "TestImpactListener.Tests2.dll"), StringComparison.OrdinalIgnoreCase)); - Assert.IsTrue(string.Equals(dataCollector2.Configuration.OuterXml, @"4313", StringComparison.OrdinalIgnoreCase)); - } + Assert.IsTrue(string.Equals(dataCollector2.AssemblyQualifiedName, "TestImpactListener.Tests, Version=2.0.0.0, Culture=neutral, PublicKeyToken=7ccb7239ffde675a", StringComparison.OrdinalIgnoreCase)); + Assert.IsTrue(string.Equals(dataCollector2.CodeBase, Path.Combine(temp, "repos", "MSTest", "src", "managed", "TestPlatform", "TestImpactListener.Tests", "bin", "Debug", "TestImpactListener.Tests2.dll"), StringComparison.OrdinalIgnoreCase)); + Assert.IsTrue(string.Equals(dataCollector2.Configuration.OuterXml, @"4313", StringComparison.OrdinalIgnoreCase)); + } - [TestMethod] - public void InProcDataCollectionExtensionManagerWillNotEnableDataCollectionForInavlidSettingsXml() - { - var invalidSettingsXml = @" + [TestMethod] + public void InProcDataCollectionExtensionManagerWillNotEnableDataCollectionForInavlidSettingsXml() + { + var invalidSettingsXml = @" @@ -197,151 +196,152 @@ public void InProcDataCollectionExtensionManagerWillNotEnableDataCollectionForIn "; - var manager = new InProcDataCollectionExtensionManager(invalidSettingsXml, this.mockTestEventsPublisher.Object, this.defaultCodebase, this.testPluginCache); - Assert.IsFalse(manager.IsInProcDataCollectionEnabled, "InProcDataCollection must be disabled on invalid settings."); - } - [TestMethod] - public void TriggerSessionStartShouldBeCalledWithCorrectTestSources() + var manager = new InProcDataCollectionExtensionManager(invalidSettingsXml, _mockTestEventsPublisher.Object, _defaultCodebase, _testPluginCache); + Assert.IsFalse(manager.IsInProcDataCollectionEnabled, "InProcDataCollection must be disabled on invalid settings."); + } + [TestMethod] + public void TriggerSessionStartShouldBeCalledWithCorrectTestSources() + { + var properties = new Dictionary { - var properties = new Dictionary(); - properties.Add("TestSources", new List() { "testsource1.dll", "testsource2.dll" }); + { "TestSources", new List() { "testsource1.dll", "testsource2.dll" } } + }; - var mockDataCollector = inProcDataCollectionManager.InProcDataCollectors.Values.FirstOrDefault() as MockDataCollector; + var mockDataCollector = _inProcDataCollectionManager.InProcDataCollectors.Values.FirstOrDefault() as MockDataCollector; - this.mockTestEventsPublisher.Raise(x => x.SessionStart += null, new SessionStartEventArgs(properties)); - Assert.IsTrue((mockDataCollector.TestSessionStartCalled == 1), "TestSessionStart must be called on datacollector"); + _mockTestEventsPublisher.Raise(x => x.SessionStart += null, new SessionStartEventArgs(properties)); + Assert.IsTrue((mockDataCollector.TestSessionStartCalled == 1), "TestSessionStart must be called on datacollector"); - Assert.IsTrue(mockDataCollector.TestSources.Contains("testsource1.dll")); - Assert.IsTrue(mockDataCollector.TestSources.Contains("testsource2.dll")); - } + Assert.IsTrue(mockDataCollector.TestSources.Contains("testsource1.dll")); + Assert.IsTrue(mockDataCollector.TestSources.Contains("testsource2.dll")); + } - [TestMethod] - public void TriggerSessionStartShouldCallInProcDataCollector() - { - this.mockTestEventsPublisher.Raise(x => x.SessionStart += null, new SessionStartEventArgs()); + [TestMethod] + public void TriggerSessionStartShouldCallInProcDataCollector() + { + _mockTestEventsPublisher.Raise(x => x.SessionStart += null, new SessionStartEventArgs()); - var mockDataCollector = inProcDataCollectionManager.InProcDataCollectors.Values.FirstOrDefault() as MockDataCollector; - Assert.IsTrue((mockDataCollector.TestSessionStartCalled == 1), "TestSessionStart must be called on datacollector"); - Assert.IsTrue((mockDataCollector.TestSessionEndCalled == 0), "TestSessionEnd must NOT be called on datacollector"); - Assert.IsTrue((mockDataCollector.TestCaseStartCalled == 0), "TestCaseStart must NOT be called on datacollector"); - Assert.IsTrue((mockDataCollector.TestCaseEndCalled == 0), "TestCaseEnd must NOT be called on datacollector"); - } + var mockDataCollector = _inProcDataCollectionManager.InProcDataCollectors.Values.FirstOrDefault() as MockDataCollector; + Assert.IsTrue((mockDataCollector.TestSessionStartCalled == 1), "TestSessionStart must be called on datacollector"); + Assert.IsTrue((mockDataCollector.TestSessionEndCalled == 0), "TestSessionEnd must NOT be called on datacollector"); + Assert.IsTrue((mockDataCollector.TestCaseStartCalled == 0), "TestCaseStart must NOT be called on datacollector"); + Assert.IsTrue((mockDataCollector.TestCaseEndCalled == 0), "TestCaseEnd must NOT be called on datacollector"); + } - [TestMethod] - public void TriggerSessionEndShouldCallInProcDataCollector() - { - this.mockTestEventsPublisher.Raise(x => x.SessionEnd += null, new SessionEndEventArgs()); + [TestMethod] + public void TriggerSessionEndShouldCallInProcDataCollector() + { + _mockTestEventsPublisher.Raise(x => x.SessionEnd += null, new SessionEndEventArgs()); - var mockDataCollector = inProcDataCollectionManager.InProcDataCollectors.Values.FirstOrDefault() as MockDataCollector; - Assert.IsTrue((mockDataCollector.TestSessionStartCalled == 0), "TestSessionEnd must NOT be called on datacollector"); - Assert.IsTrue((mockDataCollector.TestSessionEndCalled == 1), "TestSessionStart must be called on datacollector"); - Assert.IsTrue((mockDataCollector.TestCaseStartCalled == 0), "TestCaseStart must NOT be called on datacollector"); - Assert.IsTrue((mockDataCollector.TestCaseEndCalled == 0), "TestCaseEnd must NOT be called on datacollector"); - } + var mockDataCollector = _inProcDataCollectionManager.InProcDataCollectors.Values.FirstOrDefault() as MockDataCollector; + Assert.IsTrue((mockDataCollector.TestSessionStartCalled == 0), "TestSessionEnd must NOT be called on datacollector"); + Assert.IsTrue((mockDataCollector.TestSessionEndCalled == 1), "TestSessionStart must be called on datacollector"); + Assert.IsTrue((mockDataCollector.TestCaseStartCalled == 0), "TestCaseStart must NOT be called on datacollector"); + Assert.IsTrue((mockDataCollector.TestCaseEndCalled == 0), "TestCaseEnd must NOT be called on datacollector"); + } - [TestMethod] - public void TriggerTestCaseStartShouldCallInProcDataCollector() - { - var testCase = new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll"); - // random guid - testCase.Id = new Guid("3871B3B0-2853-406B-BB61-1FE1764116FD"); - this.mockTestEventsPublisher.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(testCase)); + [TestMethod] + public void TriggerTestCaseStartShouldCallInProcDataCollector() + { + var testCase = new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll"); + // random guid + testCase.Id = new Guid("3871B3B0-2853-406B-BB61-1FE1764116FD"); + _mockTestEventsPublisher.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(testCase)); - var mockDataCollector = inProcDataCollectionManager.InProcDataCollectors.Values.FirstOrDefault() as MockDataCollector; + var mockDataCollector = _inProcDataCollectionManager.InProcDataCollectors.Values.FirstOrDefault() as MockDataCollector; - Assert.IsTrue((mockDataCollector.TestCaseStartCalled == 1), "TestCaseStart must be called on datacollector"); - Assert.IsTrue((mockDataCollector.TestCaseEndCalled == 0), "TestCaseEnd must NOT be called on datacollector"); - } + Assert.IsTrue((mockDataCollector.TestCaseStartCalled == 1), "TestCaseStart must be called on datacollector"); + Assert.IsTrue((mockDataCollector.TestCaseEndCalled == 0), "TestCaseEnd must NOT be called on datacollector"); + } - [TestMethod] - public void TriggerTestCaseEndShouldtBeCalledMultipleTimesInDataDrivenScenario() + [TestMethod] + public void TriggerTestCaseEndShouldtBeCalledMultipleTimesInDataDrivenScenario() + { + var testCase = new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll"); + // random guid + testCase.Id = new Guid("3871B3B0-2853-406B-BB61-1FE1764116FD"); + _mockTestEventsPublisher.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(testCase)); + _mockTestEventsPublisher.Raise(x => x.TestCaseEnd += null, new TestCaseEndEventArgs(testCase, TestOutcome.Passed)); + _mockTestEventsPublisher.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(testCase)); + _mockTestEventsPublisher.Raise(x => x.TestCaseEnd += null, new TestCaseEndEventArgs(testCase, TestOutcome.Failed)); + + var mockDataCollector = _inProcDataCollectionManager.InProcDataCollectors.Values.FirstOrDefault() as MockDataCollector; + Assert.IsTrue((mockDataCollector.TestCaseStartCalled == 2), "TestCaseStart must only be called once"); + Assert.IsTrue((mockDataCollector.TestCaseEndCalled == 2), "TestCaseEnd must only be called once"); + } + + internal class TestableInProcDataCollectionExtensionManager : InProcDataCollectionExtensionManager + { + public TestableInProcDataCollectionExtensionManager(string runSettings, ITestEventsPublisher mockTestEventsPublisher, string defaultCodebase, TestPluginCache testPluginCache, IFileHelper fileHelper) + : base(runSettings, mockTestEventsPublisher, defaultCodebase, testPluginCache, fileHelper) { - var testCase = new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll"); - // random guid - testCase.Id = new Guid("3871B3B0-2853-406B-BB61-1FE1764116FD"); - this.mockTestEventsPublisher.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(testCase)); - this.mockTestEventsPublisher.Raise(x => x.TestCaseEnd += null, new TestCaseEndEventArgs(testCase, TestOutcome.Passed)); - this.mockTestEventsPublisher.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(testCase)); - this.mockTestEventsPublisher.Raise(x => x.TestCaseEnd += null, new TestCaseEndEventArgs(testCase, TestOutcome.Failed)); - - var mockDataCollector = inProcDataCollectionManager.InProcDataCollectors.Values.FirstOrDefault() as MockDataCollector; - Assert.IsTrue((mockDataCollector.TestCaseStartCalled == 2), "TestCaseStart must only be called once"); - Assert.IsTrue((mockDataCollector.TestCaseEndCalled == 2), "TestCaseEnd must only be called once"); } - internal class TestableInProcDataCollectionExtensionManager : InProcDataCollectionExtensionManager + protected override IInProcDataCollector CreateDataCollector(string assemblyQualifiedName, string codebase, XmlElement configuration, TypeInfo interfaceTypeInfo) { - public TestableInProcDataCollectionExtensionManager(string runSettings, ITestEventsPublisher mockTestEventsPublisher, string defaultCodebase, TestPluginCache testPluginCache, IFileHelper fileHelper) - : base(runSettings, mockTestEventsPublisher, defaultCodebase, testPluginCache, fileHelper) - { - } - - protected override IInProcDataCollector CreateDataCollector(string assemblyQualifiedName, string codebase, XmlElement configuration, TypeInfo interfaceTypeInfo) - { - return new MockDataCollector(assemblyQualifiedName, codebase,configuration); - } + return new MockDataCollector(assemblyQualifiedName, codebase, configuration); } + } - public class MockDataCollector : IInProcDataCollector + public class MockDataCollector : IInProcDataCollector + { + public MockDataCollector(string assemblyQualifiedName, string codebase, XmlElement configuration) { - public MockDataCollector(string assemblyQualifiedName, string codebase, XmlElement configuration) - { - this.AssemblyQualifiedName = assemblyQualifiedName; - this.CodeBase = codebase; - this.Configuration = configuration; - } + AssemblyQualifiedName = assemblyQualifiedName; + CodeBase = codebase; + Configuration = configuration; + } - public string AssemblyQualifiedName - { - get; - private set; - } + public string AssemblyQualifiedName + { + get; + private set; + } - public string CodeBase - { - get; - private set; - } + public string CodeBase + { + get; + private set; + } - public XmlElement Configuration - { - get; - private set; - } + public XmlElement Configuration + { + get; + private set; + } - public int TestSessionStartCalled { get; private set; } - public int TestSessionEndCalled { get; private set; } - public int TestCaseStartCalled { get; private set; } - public int TestCaseEndCalled { get; private set; } - public IEnumerable TestSources - { - get; - private set; - } + public int TestSessionStartCalled { get; private set; } + public int TestSessionEndCalled { get; private set; } + public int TestCaseStartCalled { get; private set; } + public int TestCaseEndCalled { get; private set; } + public IEnumerable TestSources + { + get; + private set; + } - public void LoadDataCollector(IDataCollectionSink inProcDataCollectionSink) - { - // Do Nothing - } + public void LoadDataCollector(IDataCollectionSink inProcDataCollectionSink) + { + // Do Nothing + } - public void TriggerInProcDataCollectionMethod(string methodName, InProcDataCollectionArgs methodArg) + public void TriggerInProcDataCollectionMethod(string methodName, InProcDataCollectionArgs methodArg) + { + switch (methodName) { - switch (methodName) - { - case Constants.TestSessionStartMethodName: this.TestSessionStartMethodCalled(methodArg as TestSessionStartArgs); break; - case Constants.TestSessionEndMethodName: TestSessionEndCalled++; break; - case Constants.TestCaseStartMethodName: TestCaseStartCalled++; break; - case Constants.TestCaseEndMethodName: TestCaseEndCalled++; break; - default: break; - } + case Constants.TestSessionStartMethodName: TestSessionStartMethodCalled(methodArg as TestSessionStartArgs); break; + case Constants.TestSessionEndMethodName: TestSessionEndCalled++; break; + case Constants.TestCaseStartMethodName: TestCaseStartCalled++; break; + case Constants.TestCaseEndMethodName: TestCaseEndCalled++; break; + default: break; } + } - private void TestSessionStartMethodCalled(TestSessionStartArgs testSessionStartArgs) - { - TestSessionStartCalled++; - this.TestSources = testSessionStartArgs.GetPropertyValue>("TestSources"); - } + private void TestSessionStartMethodCalled(TestSessionStartArgs testSessionStartArgs) + { + TestSessionStartCalled++; + TestSources = testSessionStartArgs.GetPropertyValue>("TestSources"); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectionSinkTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectionSinkTests.cs index 83fba0bd1e..07b959d6de 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectionSinkTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectionSinkTests.cs @@ -1,68 +1,67 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.DataCollection -{ - using System; +namespace TestPlatform.CrossPlatEngine.UnitTests.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; - [TestClass] - public class InProcDataCollectionSinkTests - { - private IDataCollectionSink dataCollectionSink; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestTools.UnitTesting; - private DataCollectionContext dataCollectionContext; +[TestClass] +public class InProcDataCollectionSinkTests +{ + private IDataCollectionSink _dataCollectionSink; - private TestCase testCase; + private DataCollectionContext _dataCollectionContext; - [TestInitialize] - public void InitializeTest() - { - this.dataCollectionSink = new InProcDataCollectionSink(); - this.testCase = new TestCase("DummyNS.DummyC.DummyM", new Uri("executor://mstest/v1"), "Dummy.dll"); - this.dataCollectionContext = new DataCollectionContext(this.testCase); - } + private TestCase _testCase; - [TestMethod] - public void SendDataShouldAddKeyValueToDictionaryInSink() - { - this.testCase.SetPropertyValue(TestCaseProperties.Id, Guid.NewGuid()); - this.dataCollectionSink.SendData(this.dataCollectionContext, "DummyKey", "DummyValue"); + [TestInitialize] + public void InitializeTest() + { + _dataCollectionSink = new InProcDataCollectionSink(); + _testCase = new TestCase("DummyNS.DummyC.DummyM", new Uri("executor://mstest/v1"), "Dummy.dll"); + _dataCollectionContext = new DataCollectionContext(_testCase); + } - var dict = ((InProcDataCollectionSink)this.dataCollectionSink).GetDataCollectionDataSetForTestCase(this.testCase.Id); + [TestMethod] + public void SendDataShouldAddKeyValueToDictionaryInSink() + { + _testCase.SetPropertyValue(TestCaseProperties.Id, Guid.NewGuid()); + _dataCollectionSink.SendData(_dataCollectionContext, "DummyKey", "DummyValue"); - Assert.AreEqual("DummyValue", dict["DummyKey"]); - } + var dict = ((InProcDataCollectionSink)_dataCollectionSink).GetDataCollectionDataSetForTestCase(_testCase.Id); - [TestMethod] + Assert.AreEqual("DummyValue", dict["DummyKey"]); + } - public void SendDataShouldThrowArgumentExceptionIfKeyIsNull() - { - this.testCase.SetPropertyValue(TestCaseProperties.Id, Guid.NewGuid()); + [TestMethod] - Assert.ThrowsException( - () => this.dataCollectionSink.SendData(this.dataCollectionContext, null, "DummyValue")); - } + public void SendDataShouldThrowArgumentExceptionIfKeyIsNull() + { + _testCase.SetPropertyValue(TestCaseProperties.Id, Guid.NewGuid()); + + Assert.ThrowsException( + () => _dataCollectionSink.SendData(_dataCollectionContext, null, "DummyValue")); + } - [TestMethod] - public void SendDataShouldThrowArgumentExceptionIfValueIsNull() - { - this.testCase.SetPropertyValue(TestCaseProperties.Id, Guid.NewGuid()); + [TestMethod] + public void SendDataShouldThrowArgumentExceptionIfValueIsNull() + { + _testCase.SetPropertyValue(TestCaseProperties.Id, Guid.NewGuid()); - Assert.ThrowsException( - () => this.dataCollectionSink.SendData(this.dataCollectionContext, "DummyKey", null)); - } + Assert.ThrowsException( + () => _dataCollectionSink.SendData(_dataCollectionContext, "DummyKey", null)); + } - //[TestMethod] - // TODO : Currently this code hits when test case id is null for core projects. For that we don't have algorithm to generate the guid. It's not implemented exception now (Source Code : EqtHash.cs). - public void SendDataShouldThrowArgumentExceptionIfTestCaseIdIsNull() - { - Assert.ThrowsException( - () => this.dataCollectionSink.SendData(this.dataCollectionContext, "DummyKey", "DummyValue")); - } + //[TestMethod] + // TODO : Currently this code hits when test case id is null for core projects. For that we don't have algorithm to generate the guid. It's not implemented exception now (Source Code : EqtHash.cs). + public void SendDataShouldThrowArgumentExceptionIfTestCaseIdIsNull() + { + Assert.ThrowsException( + () => _dataCollectionSink.SendData(_dataCollectionContext, "DummyKey", "DummyValue")); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectorTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectorTests.cs index 2f34e29ae0..5856b9ca6a 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectorTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectorTests.cs @@ -1,143 +1,144 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.DataCollection +namespace TestPlatform.CrossPlatEngine.UnitTests.DataCollection; + +using System.IO; +using System.Reflection; + +using Coverlet.Collector.DataCollection; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.InProcDataCollector; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class InProcDataCollectorTests { - using System.IO; - using System.Reflection; - using Coverlet.Collector.DataCollection; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.InProcDataCollector; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - [TestClass] - public class InProcDataCollectorTests + private readonly Mock _assemblyLoadContext; + + private IInProcDataCollector _inProcDataCollector; + + public InProcDataCollectorTests() { - private Mock assemblyLoadContext; + _assemblyLoadContext = new Mock(); + } - private IInProcDataCollector inProcDataCollector; + [TestMethod] + public void InProcDataCollectorShouldNotThrowExceptionIfInvalidAssemblyIsProvided() + { + _assemblyLoadContext.Setup(alc => alc.LoadAssemblyFromPath(It.IsAny())) + .Throws(); + + _inProcDataCollector = new InProcDataCollector( + string.Empty, + string.Empty, + null, + string.Empty, + _assemblyLoadContext.Object, + TestPluginCache.Instance); + + Assert.IsNull(_inProcDataCollector.AssemblyQualifiedName); + } - public InProcDataCollectorTests() - { - this.assemblyLoadContext = new Mock(); - } + [TestMethod] + public void InProcDataCollectorShouldNotThrowExceptionIfAssemblyDoesNotContainAnyInProcDataCollector() + { + _assemblyLoadContext.Setup(alc => alc.LoadAssemblyFromPath(It.IsAny())) + .Returns(Assembly.GetEntryAssembly()); + + _inProcDataCollector = new InProcDataCollector( + string.Empty, + string.Empty, + null, + string.Empty, + _assemblyLoadContext.Object, + TestPluginCache.Instance); + + Assert.IsNull(_inProcDataCollector.AssemblyQualifiedName); + } - [TestMethod] - public void InProcDataCollectorShouldNotThrowExceptionIfInvalidAssemblyIsProvided() - { - this.assemblyLoadContext.Setup(alc => alc.LoadAssemblyFromPath(It.IsAny())) - .Throws(); - - this.inProcDataCollector = new InProcDataCollector( - string.Empty, - string.Empty, - null, - string.Empty, - this.assemblyLoadContext.Object, - TestPluginCache.Instance); - - Assert.IsNull(this.inProcDataCollector.AssemblyQualifiedName); - } + [TestMethod] + public void InProcDataCollectorShouldInitializeIfAssemblyContainsAnyInProcDataCollector() + { + var typeInfo = typeof(TestableInProcDataCollector).GetTypeInfo(); - [TestMethod] - public void InProcDataCollectorShouldNotThrowExceptionIfAssemblyDoesNotContainAnyInProcDataCollector() - { - this.assemblyLoadContext.Setup(alc => alc.LoadAssemblyFromPath(It.IsAny())) - .Returns(Assembly.GetEntryAssembly()); - - this.inProcDataCollector = new InProcDataCollector( - string.Empty, - string.Empty, - null, - string.Empty, - this.assemblyLoadContext.Object, - TestPluginCache.Instance); - - Assert.IsNull(this.inProcDataCollector.AssemblyQualifiedName); - } + _assemblyLoadContext.Setup(alc => alc.LoadAssemblyFromPath(It.IsAny())) + .Returns(typeInfo.Assembly); - [TestMethod] - public void InProcDataCollectorShouldInitializeIfAssemblyContainsAnyInProcDataCollector() - { - var typeInfo = typeof(TestableInProcDataCollector).GetTypeInfo(); + _inProcDataCollector = new InProcDataCollector( + string.Empty, + typeInfo.AssemblyQualifiedName, + typeInfo, + string.Empty, + _assemblyLoadContext.Object, + TestPluginCache.Instance); - this.assemblyLoadContext.Setup(alc => alc.LoadAssemblyFromPath(It.IsAny())) - .Returns(typeInfo.Assembly); + Assert.IsNotNull(_inProcDataCollector.AssemblyQualifiedName); + Assert.AreEqual(_inProcDataCollector.AssemblyQualifiedName, typeInfo.AssemblyQualifiedName); + } - this.inProcDataCollector = new InProcDataCollector( - string.Empty, - typeInfo.AssemblyQualifiedName, - typeInfo, - string.Empty, - this.assemblyLoadContext.Object, - TestPluginCache.Instance); + [TestMethod] + public void InProcDataCollectorLoadCoverlet() + { + var typeInfo = typeof(CoverletInProcDataCollector).GetTypeInfo(); - Assert.IsNotNull(this.inProcDataCollector.AssemblyQualifiedName); - Assert.AreEqual(this.inProcDataCollector.AssemblyQualifiedName, typeInfo.AssemblyQualifiedName); - } + Assert.AreEqual("9.9.9.9", typeInfo.Assembly.GetName().Version.ToString()); - [TestMethod] - public void InProcDataCollectorLoadCoverlet() - { - var typeInfo = typeof(CoverletInProcDataCollector).GetTypeInfo(); + _assemblyLoadContext.Setup(alc => alc.LoadAssemblyFromPath(It.IsAny())) + .Returns(typeInfo.Assembly); - Assert.AreEqual("9.9.9.9", typeInfo.Assembly.GetName().Version.ToString()); + // We need to mock TestPluginCache because we have to create assembly resolver instance + // using SetupAssemblyResolver method, we don't use any other method of class(like DiscoverTestExtensions etc...) + // that fire creation + TestableTestPluginCache testablePlugin = new(); + testablePlugin.SetupAssemblyResolver(typeInfo.Assembly.Location); - this.assemblyLoadContext.Setup(alc => alc.LoadAssemblyFromPath(It.IsAny())) - .Returns(typeInfo.Assembly); + _inProcDataCollector = new InProcDataCollector( + typeInfo.Assembly.Location, + "Coverlet.Collector.DataCollection.CoverletInProcDataCollector, coverlet.collector, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + typeof(InProcDataCollection).GetTypeInfo(), + string.Empty, + _assemblyLoadContext.Object, + testablePlugin); - // We need to mock TestPluginCache because we have to create assembly resolver instance - // using SetupAssemblyResolver method, we don't use any other method of class(like DiscoverTestExtensions etc...) - // that fire creation - TestableTestPluginCache testablePlugin = new TestableTestPluginCache(); - testablePlugin.SetupAssemblyResolver(typeInfo.Assembly.Location); + Assert.IsNotNull(_inProcDataCollector.AssemblyQualifiedName); + Assert.AreEqual(_inProcDataCollector.AssemblyQualifiedName, typeInfo.AssemblyQualifiedName); + } - this.inProcDataCollector = new InProcDataCollector( - typeInfo.Assembly.Location, - "Coverlet.Collector.DataCollection.CoverletInProcDataCollector, coverlet.collector, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", - typeof(InProcDataCollection).GetTypeInfo(), - string.Empty, - this.assemblyLoadContext.Object, - testablePlugin); + private class TestableInProcDataCollector : InProcDataCollection + { + public void Initialize(IDataCollectionSink dataCollectionSink) + { + throw new System.NotImplementedException(); + } + + public void TestSessionStart(TestSessionStartArgs testSessionStartArgs) + { + throw new System.NotImplementedException(); + } - Assert.IsNotNull(this.inProcDataCollector.AssemblyQualifiedName); - Assert.AreEqual(this.inProcDataCollector.AssemblyQualifiedName, typeInfo.AssemblyQualifiedName); + public void TestCaseStart(TestCaseStartArgs testCaseStartArgs) + { + throw new System.NotImplementedException(); + } + + public void TestCaseEnd(TestCaseEndArgs testCaseEndArgs) + { + throw new System.NotImplementedException(); } - private class TestableInProcDataCollector : InProcDataCollection + public void TestSessionEnd(TestSessionEndArgs testSessionEndArgs) { - public void Initialize(IDataCollectionSink dataCollectionSink) - { - throw new System.NotImplementedException(); - } - - public void TestSessionStart(TestSessionStartArgs testSessionStartArgs) - { - throw new System.NotImplementedException(); - } - - public void TestCaseStart(TestCaseStartArgs testCaseStartArgs) - { - throw new System.NotImplementedException(); - } - - public void TestCaseEnd(TestCaseEndArgs testCaseEndArgs) - { - throw new System.NotImplementedException(); - } - - public void TestSessionEnd(TestSessionEndArgs testSessionEndArgs) - { - throw new System.NotImplementedException(); - } + throw new System.NotImplementedException(); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ParallelDataCollectionEventsHandlerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ParallelDataCollectionEventsHandlerTests.cs index 50e4e1b802..5791d7084d 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ParallelDataCollectionEventsHandlerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ParallelDataCollectionEventsHandlerTests.cs @@ -1,96 +1,95 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.DataCollection +namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.DataCollection; + +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; +using VisualStudio.TestTools.UnitTesting; +using Moq; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Threading; +using System.Threading.Tasks; +using Constants = VisualStudio.TestPlatform.ObjectModel.Constants; + +[TestClass] +public class ParallelDataCollectionEventsHandlerTests { - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Threading; - using System.Threading.Tasks; - using Constants = VisualStudio.TestPlatform.ObjectModel.Constants; + private const string Uri1 = "datacollector://microsoft/some1/1.0"; + private const string Uri2 = "datacollector://microsoft/some2/2.0"; + private const string Uri3 = "datacollector://microsoft/some3/2.0"; + + private readonly Mock _mockRequestData; + private readonly Mock _mockProxyExecutionManager; + private readonly Mock _mockTestRunEventsHandler; + private readonly Mock _mockParallelProxyExecutionManager; + private readonly Mock _mockTestRunAttachmentsProcessingManager; + private readonly CancellationTokenSource _cancellationTokenSource; + private readonly ParallelDataCollectionEventsHandler _parallelDataCollectionEventsHandler; - [TestClass] - public class ParallelDataCollectionEventsHandlerTests + public ParallelDataCollectionEventsHandlerTests() { - private const string uri1 = "datacollector://microsoft/some1/1.0"; - private const string uri2 = "datacollector://microsoft/some2/2.0"; - private const string uri3 = "datacollector://microsoft/some3/2.0"; + _mockRequestData = new Mock(); + _mockProxyExecutionManager = new Mock(); + _mockTestRunEventsHandler = new Mock(); + _mockParallelProxyExecutionManager = new Mock(); + _mockTestRunAttachmentsProcessingManager = new Mock(); + _cancellationTokenSource = new CancellationTokenSource(); + _parallelDataCollectionEventsHandler = new ParallelDataCollectionEventsHandler(_mockRequestData.Object, _mockProxyExecutionManager.Object, _mockTestRunEventsHandler.Object, + _mockParallelProxyExecutionManager.Object, new ParallelRunDataAggregator(Constants.EmptyRunSettings), _mockTestRunAttachmentsProcessingManager.Object, _cancellationTokenSource.Token); - private readonly Mock mockRequestData; - private readonly Mock mockProxyExecutionManager; - private readonly Mock mockTestRunEventsHandler; - private readonly Mock mockParallelProxyExecutionManager; - private readonly Mock mockTestRunAttachmentsProcessingManager; - private readonly CancellationTokenSource cancellationTokenSource; - private readonly ParallelDataCollectionEventsHandler parallelDataCollectionEventsHandler; + _mockParallelProxyExecutionManager.Setup(m => m.HandlePartialRunComplete(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>(), It.IsAny>())).Returns(true); + } - public ParallelDataCollectionEventsHandlerTests() + [TestMethod] + public void HandleTestRunComplete_ShouldCallProcessTestRunAttachmentsAsyncWithAttachmentsAndUseResults() + { + // arrange + List inputAttachments = new() { - mockRequestData = new Mock(); - mockProxyExecutionManager = new Mock(); - mockTestRunEventsHandler = new Mock(); - mockParallelProxyExecutionManager = new Mock(); - mockTestRunAttachmentsProcessingManager = new Mock(); - cancellationTokenSource = new CancellationTokenSource(); - parallelDataCollectionEventsHandler = new ParallelDataCollectionEventsHandler(mockRequestData.Object, mockProxyExecutionManager.Object, mockTestRunEventsHandler.Object, - mockParallelProxyExecutionManager.Object, new ParallelRunDataAggregator(Constants.EmptyRunSettings), mockTestRunAttachmentsProcessingManager.Object, cancellationTokenSource.Token); + new AttachmentSet(new Uri(Uri1), "uri1_input1"), + new AttachmentSet(new Uri(Uri2), "uri2_input1"), + new AttachmentSet(new Uri(Uri3), "uri3_input1") + }; - mockParallelProxyExecutionManager.Setup(m => m.HandlePartialRunComplete(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>(), It.IsAny>())).Returns(true); - } - - [TestMethod] - public void HandleTestRunComplete_ShouldCallProcessTestRunAttachmentsAsyncWithAttachmentsAndUseResults() + Collection outputAttachments = new() { - // arrange - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_input1"), - new AttachmentSet(new Uri(uri2), "uri2_input1"), - new AttachmentSet(new Uri(uri3), "uri3_input1") - }; - - Collection outputAttachments = new Collection - { - new AttachmentSet(new Uri(uri1), "uri1_input1") - }; + new AttachmentSet(new Uri(Uri1), "uri1_input1") + }; - mockTestRunAttachmentsProcessingManager.Setup(f => f.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, It.IsAny>(), It.IsAny>(), It.IsAny())).Returns(Task.FromResult(outputAttachments)); + _mockTestRunAttachmentsProcessingManager.Setup(f => f.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, It.IsAny>(), It.IsAny>(), It.IsAny())).Returns(Task.FromResult(outputAttachments)); - // act - parallelDataCollectionEventsHandler.HandleTestRunComplete(new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromSeconds(1)), null, inputAttachments, null); + // act + _parallelDataCollectionEventsHandler.HandleTestRunComplete(new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromSeconds(1)), null, inputAttachments, null); - // assert - mockTestRunEventsHandler.Verify(h => h.HandleTestRunComplete(It.IsAny(), It.IsAny(), It.Is>(c => c.Count == 1 && c.Contains(outputAttachments[0])), It.IsAny>())); - mockTestRunAttachmentsProcessingManager.Verify(f => f.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, It.Is>(a => a.Count == 3), It.IsAny>(), cancellationTokenSource.Token)); - } + // assert + _mockTestRunEventsHandler.Verify(h => h.HandleTestRunComplete(It.IsAny(), It.IsAny(), It.Is>(c => c.Count == 1 && c.Contains(outputAttachments[0])), It.IsAny>())); + _mockTestRunAttachmentsProcessingManager.Verify(f => f.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, It.Is>(a => a.Count == 3), It.IsAny>(), _cancellationTokenSource.Token)); + } - [TestMethod] - public void HandleTestRunComplete_ShouldCallProcessTestRunAttachmentsAsyncWithAttachmentsAndNotUserResults_IfManagerReturnsNull() + [TestMethod] + public void HandleTestRunComplete_ShouldCallProcessTestRunAttachmentsAsyncWithAttachmentsAndNotUserResults_IfManagerReturnsNull() + { + // arrange + List inputAttachments = new() { - // arrange - List inputAttachments = new List - { - new AttachmentSet(new Uri(uri1), "uri1_input1"), - new AttachmentSet(new Uri(uri2), "uri2_input1"), - new AttachmentSet(new Uri(uri3), "uri3_input1") - }; + new AttachmentSet(new Uri(Uri1), "uri1_input1"), + new AttachmentSet(new Uri(Uri2), "uri2_input1"), + new AttachmentSet(new Uri(Uri3), "uri3_input1") + }; - mockTestRunAttachmentsProcessingManager.Setup(f => f.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, It.IsAny>(), It.IsAny>(), It.IsAny())).Returns(Task.FromResult((Collection)null)); + _mockTestRunAttachmentsProcessingManager.Setup(f => f.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, It.IsAny>(), It.IsAny>(), It.IsAny())).Returns(Task.FromResult((Collection)null)); - // act - parallelDataCollectionEventsHandler.HandleTestRunComplete(new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromSeconds(1)), null, inputAttachments, null); + // act + _parallelDataCollectionEventsHandler.HandleTestRunComplete(new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromSeconds(1)), null, inputAttachments, null); - // assert - mockTestRunEventsHandler.Verify(h => h.HandleTestRunComplete(It.IsAny(), It.IsAny(), It.Is>(c => c.Count == 3), It.IsAny>())); - mockTestRunAttachmentsProcessingManager.Verify(f => f.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, It.Is>(a => a.Count == 3), It.IsAny>(), cancellationTokenSource.Token)); - } + // assert + _mockTestRunEventsHandler.Verify(h => h.HandleTestRunComplete(It.IsAny(), It.IsAny(), It.Is>(c => c.Count == 3), It.IsAny>())); + _mockTestRunAttachmentsProcessingManager.Verify(f => f.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, _mockRequestData.Object, It.Is>(a => a.Count == 3), It.IsAny>(), _cancellationTokenSource.Token)); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ProxyDataCollectionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ProxyDataCollectionManagerTests.cs index 37c60a1612..a6ceb3f7b4 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ProxyDataCollectionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ProxyDataCollectionManagerTests.cs @@ -1,280 +1,277 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.DataCollection +namespace TestPlatform.CrossPlatEngine.UnitTests.DataCollection; + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.IO; +using System.Reflection; + +using Microsoft.VisualStudio.TestPlatform.Common.DataCollection; +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class ProxyDataCollectionManagerTests { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Diagnostics; - using System.IO; - using System.Reflection; - - using Microsoft.VisualStudio.TestPlatform.Common.DataCollection; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using CommunicationUtilitiesResources = Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources.Resources; - using CoreUtilitiesConstants = Microsoft.VisualStudio.TestPlatform.CoreUtilities.Constants; - - using Moq; - - [TestClass] - public class ProxyDataCollectionManagerTests + private Mock _mockDataCollectionRequestSender; + private ProxyDataCollectionManager _proxyDataCollectionManager; + private Mock _mockDataCollectionLauncher; + private Mock _mockProcessHelper; + private Mock _mockRequestData; + private Mock _mockMetricsCollection; + private static readonly string TimoutErrorMessage = + "vstest.console process failed to connect to datacollector process after 90 seconds. This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout."; + + [TestInitialize] + public void Initialize() { - private Mock mockDataCollectionRequestSender; - private ProxyDataCollectionManager proxyDataCollectionManager; - private Mock mockDataCollectionLauncher; - private Mock mockProcessHelper; - private Mock mockRequestData; - private Mock mockMetricsCollection; - private static readonly string TimoutErrorMessage = - "vstest.console process failed to connect to datacollector process after 90 seconds. This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout."; - - [TestInitialize] - public void Initialize() - { - this.mockDataCollectionRequestSender = new Mock(); - this.mockDataCollectionLauncher = new Mock(); - this.mockProcessHelper = new Mock(); - this.mockRequestData = new Mock(); - this.mockMetricsCollection = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(this.mockMetricsCollection.Object); - this.proxyDataCollectionManager = new ProxyDataCollectionManager(this.mockRequestData.Object, string.Empty, new List() { "testsource1.dll" }, this.mockDataCollectionRequestSender.Object, this.mockProcessHelper.Object, this.mockDataCollectionLauncher.Object); - } + _mockDataCollectionRequestSender = new Mock(); + _mockDataCollectionLauncher = new Mock(); + _mockProcessHelper = new Mock(); + _mockRequestData = new Mock(); + _mockMetricsCollection = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(_mockMetricsCollection.Object); + _proxyDataCollectionManager = new ProxyDataCollectionManager(_mockRequestData.Object, string.Empty, new List() { "testsource1.dll" }, _mockDataCollectionRequestSender.Object, _mockProcessHelper.Object, _mockDataCollectionLauncher.Object); + } - [TestCleanup] - public void Cleanup() - { - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, string.Empty); - Environment.SetEnvironmentVariable(ProxyDataCollectionManager.DebugEnvironmentVaribleName, string.Empty); - } + [TestCleanup] + public void Cleanup() + { + Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, string.Empty); + Environment.SetEnvironmentVariable(ProxyDataCollectionManager.DebugEnvironmentVaribleName, string.Empty); + } - [TestMethod] - public void InitializeShouldInitializeCommunication() - { - this.mockDataCollectionRequestSender.Setup(x => x.WaitForRequestHandlerConnection(EnvironmentHelper.DefaultConnectionTimeout * 1000)).Returns(true); - this.proxyDataCollectionManager.Initialize(); + [TestMethod] + public void InitializeShouldInitializeCommunication() + { + _mockDataCollectionRequestSender.Setup(x => x.WaitForRequestHandlerConnection(EnvironmentHelper.DefaultConnectionTimeout * 1000)).Returns(true); + _proxyDataCollectionManager.Initialize(); - this.mockDataCollectionLauncher.Verify(x => x.LaunchDataCollector(It.IsAny>(), It.IsAny>()), Times.Once); - this.mockDataCollectionRequestSender.Verify(x => x.WaitForRequestHandlerConnection(EnvironmentHelper.DefaultConnectionTimeout * 1000), Times.Once); - } + _mockDataCollectionLauncher.Verify(x => x.LaunchDataCollector(It.IsAny>(), It.IsAny>()), Times.Once); + _mockDataCollectionRequestSender.Verify(x => x.WaitForRequestHandlerConnection(EnvironmentHelper.DefaultConnectionTimeout * 1000), Times.Once); + } - [TestMethod] - public void InitializeShouldThrowExceptionIfConnectionTimeouts() - { - this.mockDataCollectionRequestSender.Setup(x => x.WaitForRequestHandlerConnection(It.IsAny())).Returns(false); + [TestMethod] + public void InitializeShouldThrowExceptionIfConnectionTimeouts() + { + _mockDataCollectionRequestSender.Setup(x => x.WaitForRequestHandlerConnection(It.IsAny())).Returns(false); - var message = Assert.ThrowsException(() => this.proxyDataCollectionManager.Initialize()).Message; - Assert.AreEqual(message, ProxyDataCollectionManagerTests.TimoutErrorMessage); - } + var message = Assert.ThrowsException(() => _proxyDataCollectionManager.Initialize()).Message; + Assert.AreEqual(message, TimoutErrorMessage); + } - [TestMethod] - public void InitializeShouldSetTimeoutBasedOnTimeoutEnvironmentVarible() - { - var timeout = 10; - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, timeout.ToString()); - this.mockDataCollectionRequestSender.Setup(x => x.WaitForRequestHandlerConnection(timeout * 1000)).Returns(true); + [TestMethod] + public void InitializeShouldSetTimeoutBasedOnTimeoutEnvironmentVarible() + { + var timeout = 10; + Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, timeout.ToString()); + _mockDataCollectionRequestSender.Setup(x => x.WaitForRequestHandlerConnection(timeout * 1000)).Returns(true); - this.proxyDataCollectionManager.Initialize(); + _proxyDataCollectionManager.Initialize(); - this.mockDataCollectionRequestSender.Verify(x => x.WaitForRequestHandlerConnection(timeout * 1000), Times.Once); - } + _mockDataCollectionRequestSender.Verify(x => x.WaitForRequestHandlerConnection(timeout * 1000), Times.Once); + } - [TestMethod] - public void InitializeShouldSetTimeoutBasedOnDebugEnvironmentVaribleName() - { - Environment.SetEnvironmentVariable(ProxyDataCollectionManager.DebugEnvironmentVaribleName, "1"); - var expectedTimeout = EnvironmentHelper.DefaultConnectionTimeout * 1000 * 5; - this.mockDataCollectionRequestSender.Setup(x => x.WaitForRequestHandlerConnection(expectedTimeout)).Returns(true); + [TestMethod] + public void InitializeShouldSetTimeoutBasedOnDebugEnvironmentVaribleName() + { + Environment.SetEnvironmentVariable(ProxyDataCollectionManager.DebugEnvironmentVaribleName, "1"); + var expectedTimeout = EnvironmentHelper.DefaultConnectionTimeout * 1000 * 5; + _mockDataCollectionRequestSender.Setup(x => x.WaitForRequestHandlerConnection(expectedTimeout)).Returns(true); - this.proxyDataCollectionManager.Initialize(); + _proxyDataCollectionManager.Initialize(); - this.mockDataCollectionRequestSender.Verify(x => x.WaitForRequestHandlerConnection(expectedTimeout), Times.Once); - } + _mockDataCollectionRequestSender.Verify(x => x.WaitForRequestHandlerConnection(expectedTimeout), Times.Once); + } - [TestMethod] - public void InitializeShouldPassDiagArgumentsIfDiagIsEnabled() - { - // Saving the EqtTrace state + [TestMethod] + public void InitializeShouldPassDiagArgumentsIfDiagIsEnabled() + { + // Saving the EqtTrace state #if NETFRAMEWORK - var traceLevel = EqtTrace.TraceLevel; - EqtTrace.TraceLevel = TraceLevel.Off; + var traceLevel = EqtTrace.TraceLevel; + EqtTrace.TraceLevel = TraceLevel.Off; #else - var traceLevel = (TraceLevel)EqtTrace.TraceLevel; - EqtTrace.TraceLevel = (PlatformTraceLevel)TraceLevel.Off; + var traceLevel = (TraceLevel)EqtTrace.TraceLevel; + EqtTrace.TraceLevel = (PlatformTraceLevel)TraceLevel.Off; #endif - var traceFileName = EqtTrace.LogFile; - - try - { - EqtTrace.InitializeTrace("mylog.txt", PlatformTraceLevel.Info); - this.mockDataCollectionRequestSender.Setup(x => x.WaitForRequestHandlerConnection(It.IsAny())).Returns(true); - - this.proxyDataCollectionManager.Initialize(); - - var expectedTraceLevel = (int)PlatformTraceLevel.Info; - this.mockDataCollectionLauncher.Verify( - x => - x.LaunchDataCollector( - It.IsAny>(), - It.Is>(list => list.Contains("--diag") && list.Contains("--tracelevel") && list.Contains(expectedTraceLevel.ToString()))), - Times.Once); - } - finally - { - // Restoring to initial state for EqtTrace - EqtTrace.InitializeTrace(traceFileName, PlatformTraceLevel.Verbose); + var traceFileName = EqtTrace.LogFile; + + try + { + EqtTrace.InitializeTrace("mylog.txt", PlatformTraceLevel.Info); + _mockDataCollectionRequestSender.Setup(x => x.WaitForRequestHandlerConnection(It.IsAny())).Returns(true); + + _proxyDataCollectionManager.Initialize(); + + var expectedTraceLevel = (int)PlatformTraceLevel.Info; + _mockDataCollectionLauncher.Verify( + x => + x.LaunchDataCollector( + It.IsAny>(), + It.Is>(list => list.Contains("--diag") && list.Contains("--tracelevel") && list.Contains(expectedTraceLevel.ToString()))), + Times.Once); + } + finally + { + // Restoring to initial state for EqtTrace + EqtTrace.InitializeTrace(traceFileName, PlatformTraceLevel.Verbose); #if NETFRAMEWORK - EqtTrace.TraceLevel = traceLevel; + EqtTrace.TraceLevel = traceLevel; #else - EqtTrace.TraceLevel = (PlatformTraceLevel)traceLevel; + EqtTrace.TraceLevel = (PlatformTraceLevel)traceLevel; #endif - } } + } - [TestMethod] - public void SendTestHostInitiazliedShouldPassProcessIdToRequestSender() - { - this.proxyDataCollectionManager.TestHostLaunched(1234); + [TestMethod] + public void SendTestHostInitiazliedShouldPassProcessIdToRequestSender() + { + _proxyDataCollectionManager.TestHostLaunched(1234); - this.mockDataCollectionRequestSender.Verify(x => x.SendTestHostLaunched(It.Is(y => y.ProcessId == 1234))); - } + _mockDataCollectionRequestSender.Verify(x => x.SendTestHostLaunched(It.Is(y => y.ProcessId == 1234))); + } - [TestMethod] - public void BeforeTestRunStartShouldPassRunSettingsWithExtensionsFolderUpdatedAsTestAdapterPath() - { - string runsettings = $""; - var sourceList = new List() { "testsource1.dll" }; - this.proxyDataCollectionManager = new ProxyDataCollectionManager(this.mockRequestData.Object, runsettings, sourceList, this.mockDataCollectionRequestSender.Object, this.mockProcessHelper.Object, this.mockDataCollectionLauncher.Object); - this.mockRequestData.Setup(r => r.IsTelemetryOptedIn).Returns(true); + [TestMethod] + public void BeforeTestRunStartShouldPassRunSettingsWithExtensionsFolderUpdatedAsTestAdapterPath() + { + string runsettings = $""; + var sourceList = new List() { "testsource1.dll" }; + _proxyDataCollectionManager = new ProxyDataCollectionManager(_mockRequestData.Object, runsettings, sourceList, _mockDataCollectionRequestSender.Object, _mockProcessHelper.Object, _mockDataCollectionLauncher.Object); + _mockRequestData.Setup(r => r.IsTelemetryOptedIn).Returns(true); - BeforeTestRunStartResult res = new BeforeTestRunStartResult(new Dictionary(), 123); - this.mockDataCollectionRequestSender.Setup(x => x.SendBeforeTestRunStartAndGetResult(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny())).Returns(res); + BeforeTestRunStartResult res = new(new Dictionary(), 123); + _mockDataCollectionRequestSender.Setup(x => x.SendBeforeTestRunStartAndGetResult(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny())).Returns(res); - var result = this.proxyDataCollectionManager.BeforeTestRunStart(true, true, null); + var result = _proxyDataCollectionManager.BeforeTestRunStart(true, true, null); - var extensionsFolderPath = Path.Combine(Path.GetDirectoryName(typeof(ITestPlatform).GetTypeInfo().Assembly.Location), "Extensions"); - var expectedSettingsXML = $"{extensionsFolderPath}"; - this.mockDataCollectionRequestSender.Verify( - x => x.SendBeforeTestRunStartAndGetResult(expectedSettingsXML, sourceList, true, It.IsAny()), Times.Once); - } + var extensionsFolderPath = Path.Combine(Path.GetDirectoryName(typeof(ITestPlatform).GetTypeInfo().Assembly.Location), "Extensions"); + var expectedSettingsXml = $"{extensionsFolderPath}"; + _mockDataCollectionRequestSender.Verify( + x => x.SendBeforeTestRunStartAndGetResult(expectedSettingsXml, sourceList, true, It.IsAny()), Times.Once); + } - [TestMethod] - public void BeforeTestRunStartShouldReturnDataCollectorParameters() - { - BeforeTestRunStartResult res = new BeforeTestRunStartResult(new Dictionary(), 123); - var sourceList = new List() { "testsource1.dll" }; - this.mockDataCollectionRequestSender.Setup(x => x.SendBeforeTestRunStartAndGetResult(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny())).Returns(res); + [TestMethod] + public void BeforeTestRunStartShouldReturnDataCollectorParameters() + { + BeforeTestRunStartResult res = new(new Dictionary(), 123); + var sourceList = new List() { "testsource1.dll" }; + _mockDataCollectionRequestSender.Setup(x => x.SendBeforeTestRunStartAndGetResult(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny())).Returns(res); - var result = this.proxyDataCollectionManager.BeforeTestRunStart(true, true, null); + var result = _proxyDataCollectionManager.BeforeTestRunStart(true, true, null); - this.mockDataCollectionRequestSender.Verify( - x => x.SendBeforeTestRunStartAndGetResult(It.IsAny(), sourceList, false, It.IsAny()), Times.Once); - Assert.IsNotNull(result); - Assert.AreEqual(res.DataCollectionEventsPort, result.DataCollectionEventsPort); - Assert.AreEqual(res.EnvironmentVariables.Count, result.EnvironmentVariables.Count); - } + _mockDataCollectionRequestSender.Verify( + x => x.SendBeforeTestRunStartAndGetResult(It.IsAny(), sourceList, false, It.IsAny()), Times.Once); + Assert.IsNotNull(result); + Assert.AreEqual(res.DataCollectionEventsPort, result.DataCollectionEventsPort); + Assert.AreEqual(res.EnvironmentVariables.Count, result.EnvironmentVariables.Count); + } - [TestMethod] - public void BeforeTestRunStartsShouldInvokeRunEventsHandlerIfExceptionIsThrown() - { - var mockRunEventsHandler = new Mock(); - this.mockDataCollectionRequestSender.Setup( - x => x.SendBeforeTestRunStartAndGetResult(It.IsAny(), new List() { "testsource1.dll" }, false, It.IsAny())) - .Throws(); + [TestMethod] + public void BeforeTestRunStartsShouldInvokeRunEventsHandlerIfExceptionIsThrown() + { + var mockRunEventsHandler = new Mock(); + _mockDataCollectionRequestSender.Setup( + x => x.SendBeforeTestRunStartAndGetResult(It.IsAny(), new List() { "testsource1.dll" }, false, It.IsAny())) + .Throws(); - var result = this.proxyDataCollectionManager.BeforeTestRunStart(true, true, mockRunEventsHandler.Object); + var result = _proxyDataCollectionManager.BeforeTestRunStart(true, true, mockRunEventsHandler.Object); - mockRunEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.IsRegex("Exception of type 'System.Exception' was thrown..*")), Times.Once); - Assert.AreEqual(0, result.EnvironmentVariables.Count); - Assert.IsFalse(result.AreTestCaseLevelEventsRequired); - Assert.AreEqual(0, result.DataCollectionEventsPort); - } + mockRunEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.IsRegex("Exception of type 'System.Exception' was thrown..*")), Times.Once); + Assert.AreEqual(0, result.EnvironmentVariables.Count); + Assert.IsFalse(result.AreTestCaseLevelEventsRequired); + Assert.AreEqual(0, result.DataCollectionEventsPort); + } + + [TestMethod] + public void SendBeforeTestRunStartAndGetResultShouldBeInvokedWithCorrectTestSources() + { + var testSources = new List() { "abc.dll", "efg.dll" }; + _proxyDataCollectionManager = new ProxyDataCollectionManager(_mockRequestData.Object, string.Empty, testSources, _mockDataCollectionRequestSender.Object, _mockProcessHelper.Object, _mockDataCollectionLauncher.Object); - [TestMethod] - public void SendBeforeTestRunStartAndGetResultShouldBeInvokedWithCorrectTestSources() + BeforeTestRunStartResult res = new(new Dictionary(), 123); + _mockDataCollectionRequestSender.Setup(x => x.SendBeforeTestRunStartAndGetResult(string.Empty, testSources, It.IsAny(), It.IsAny())).Returns(res); + + var result = _proxyDataCollectionManager.BeforeTestRunStart(true, true, null); + + _mockDataCollectionRequestSender.Verify( + x => x.SendBeforeTestRunStartAndGetResult(string.Empty, testSources, false, It.IsAny()), Times.Once); + Assert.IsNotNull(result); + Assert.AreEqual(res.DataCollectionEventsPort, result.DataCollectionEventsPort); + Assert.AreEqual(res.EnvironmentVariables.Count, result.EnvironmentVariables.Count); + } + + [TestMethod] + [DataRow(false)] + [DataRow(true)] + public void AfterTestRunEndShouldReturnAttachments(bool telemetryOptedIn) + { + var attachments = new Collection(); + var invokedDataCollectors = new Collection(); + var dispName = "MockAttachments"; + var uri = new Uri("Mock://Attachments"); + var attachmentSet = new AttachmentSet(uri, dispName); + attachments.Add(attachmentSet); + _mockRequestData.Setup(m => m.IsTelemetryOptedIn).Returns(telemetryOptedIn); + + var metrics = new Dictionary() { - var testSources = new List() { "abc.dll", "efg.dll" }; - this.proxyDataCollectionManager = new ProxyDataCollectionManager(this.mockRequestData.Object, string.Empty, testSources, this.mockDataCollectionRequestSender.Object, this.mockProcessHelper.Object, this.mockDataCollectionLauncher.Object); + {"key", "value"} + }; - BeforeTestRunStartResult res = new BeforeTestRunStartResult(new Dictionary(), 123); - this.mockDataCollectionRequestSender.Setup(x => x.SendBeforeTestRunStartAndGetResult(string.Empty, testSources, It.IsAny(), It.IsAny())).Returns(res); + _mockDataCollectionRequestSender.Setup(x => x.SendAfterTestRunEndAndGetResult(It.IsAny(), It.IsAny())).Returns(new AfterTestRunEndResult(attachments, invokedDataCollectors, metrics)); - var result = this.proxyDataCollectionManager.BeforeTestRunStart(true, true, null); + var result = _proxyDataCollectionManager.AfterTestRunEnd(false, null); - this.mockDataCollectionRequestSender.Verify( - x => x.SendBeforeTestRunStartAndGetResult(string.Empty, testSources, false, It.IsAny()), Times.Once); - Assert.IsNotNull(result); - Assert.AreEqual(res.DataCollectionEventsPort, result.DataCollectionEventsPort); - Assert.AreEqual(res.EnvironmentVariables.Count, result.EnvironmentVariables.Count); - } + Assert.IsNotNull(result); + Assert.AreEqual(1, result.Attachments.Count); + Assert.IsNotNull(result.Attachments[0]); + Assert.AreEqual(dispName, result.Attachments[0].DisplayName); + Assert.AreEqual(uri, result.Attachments[0].Uri); - [TestMethod] - [DataRow(false)] - [DataRow(true)] - public void AfterTestRunEndShouldReturnAttachments(bool telemetryOptedIn) + if (telemetryOptedIn) { - var attachments = new Collection(); - var invokedDataCollectors = new Collection(); - var dispName = "MockAttachments"; - var uri = new Uri("Mock://Attachments"); - var attachmentSet = new AttachmentSet(uri, dispName); - attachments.Add(attachmentSet); - this.mockRequestData.Setup(m => m.IsTelemetryOptedIn).Returns(telemetryOptedIn); - - var metrics = new Dictionary() - { - {"key", "value"} - }; - - this.mockDataCollectionRequestSender.Setup(x => x.SendAfterTestRunEndAndGetResult(It.IsAny(), It.IsAny())).Returns(new AfterTestRunEndResult(attachments, invokedDataCollectors, metrics)); - - var result = this.proxyDataCollectionManager.AfterTestRunEnd(false, null); - - Assert.IsNotNull(result); - Assert.AreEqual(1, result.Attachments.Count); - Assert.IsNotNull(result.Attachments[0]); - Assert.AreEqual(dispName, result.Attachments[0].DisplayName); - Assert.AreEqual(uri, result.Attachments[0].Uri); - - if (telemetryOptedIn) - { - mockMetricsCollection.Verify(m => m.Add("key", "value"), Times.Once); - } - else - { - mockMetricsCollection.Verify(m => m.Add(It.IsAny(), It.IsAny()), Times.Never); - } + _mockMetricsCollection.Verify(m => m.Add("key", "value"), Times.Once); } - - [TestMethod] - public void AfterTestRunEndShouldInvokeRunEventsHandlerIfExceptionIsThrown() + else { - var mockRunEventsHandler = new Mock(); - this.mockDataCollectionRequestSender.Setup( - x => x.SendAfterTestRunEndAndGetResult(It.IsAny(), It.IsAny())) - .Throws(); + _mockMetricsCollection.Verify(m => m.Add(It.IsAny(), It.IsAny()), Times.Never); + } + } + + [TestMethod] + public void AfterTestRunEndShouldInvokeRunEventsHandlerIfExceptionIsThrown() + { + var mockRunEventsHandler = new Mock(); + _mockDataCollectionRequestSender.Setup( + x => x.SendAfterTestRunEndAndGetResult(It.IsAny(), It.IsAny())) + .Throws(); - var result = this.proxyDataCollectionManager.AfterTestRunEnd(false, mockRunEventsHandler.Object); + var result = _proxyDataCollectionManager.AfterTestRunEnd(false, mockRunEventsHandler.Object); - mockRunEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.IsRegex("Exception of type 'System.Exception' was thrown..*")), Times.Once); - } + mockRunEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, It.IsRegex("Exception of type 'System.Exception' was thrown..*")), Times.Once); + } - [TestMethod] - public void ProxyDataCollectionShouldLogEnabledDataCollectors() - { - string settings = @" + [TestMethod] + public void ProxyDataCollectionShouldLogEnabledDataCollectors() + { + string settings = @" @@ -283,13 +280,12 @@ public void ProxyDataCollectionShouldLogEnabledDataCollectors() "; - var testSources = new List() { "abc.dll", "efg.dll" }; - this.mockRequestData.Setup(rd => rd.IsTelemetryOptedIn).Returns(true); + var testSources = new List() { "abc.dll", "efg.dll" }; + _mockRequestData.Setup(rd => rd.IsTelemetryOptedIn).Returns(true); - var proxyExecutionManager = new ProxyDataCollectionManager(this.mockRequestData.Object, settings, testSources, this.mockDataCollectionRequestSender.Object, this.mockProcessHelper.Object, this.mockDataCollectionLauncher.Object); + var proxyExecutionManager = new ProxyDataCollectionManager(_mockRequestData.Object, settings, testSources, _mockDataCollectionRequestSender.Object, _mockProcessHelper.Object, _mockDataCollectionLauncher.Object); - var resultString = "{ FriendlyName = Code Coverage, Uri = datacollector://microsoft/CodeCoverage/2.0 }"; - this.mockMetricsCollection.Verify(rd => rd.Add(TelemetryDataConstants.DataCollectorsEnabled, resultString), Times.Once); - } + var resultString = "{ FriendlyName = Code Coverage, Uri = datacollector://microsoft/CodeCoverage/2.0 }"; + _mockMetricsCollection.Verify(rd => rd.Add(TelemetryDataConstants.DataCollectorsEnabled, resultString), Times.Once); } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ProxyOutOfProcDataCollectionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ProxyOutOfProcDataCollectionManagerTests.cs index b4bc2403fe..f8ad4e8500 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ProxyOutOfProcDataCollectionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ProxyOutOfProcDataCollectionManagerTests.cs @@ -1,65 +1,66 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.DataCollection -{ - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.DataCollection; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using VisualStudio.TestTools.UnitTesting; + +using Moq; +using System; +using System.Collections.ObjectModel; - using Moq; - using System; - using System.Collections.ObjectModel; +[TestClass] +public class ProxyOutOfProcDataCollectionManagerTests +{ + private readonly Mock _mockTestEventsPublisher; + private readonly Mock _mockDataCollectionTestCaseEventSender; + private readonly Collection _attachmentSets; + private readonly TestCase _testcase; + private VisualStudio.TestPlatform.ObjectModel.TestResult _testResult; - [TestClass] - public class ProxyOutOfProcDataCollectionManagerTests + private readonly ProxyOutOfProcDataCollectionManager _proxyOutOfProcDataCollectionManager; + public ProxyOutOfProcDataCollectionManagerTests() { - private Mock mockTestEventsPublisher; - private Mock mockDataCollectionTestCaseEventSender; - private Collection attachmentSets; - private TestCase testcase; - private VisualStudio.TestPlatform.ObjectModel.TestResult testResult; + _mockTestEventsPublisher = new Mock(); + _mockDataCollectionTestCaseEventSender = new Mock(); + _proxyOutOfProcDataCollectionManager = new ProxyOutOfProcDataCollectionManager(_mockDataCollectionTestCaseEventSender.Object, _mockTestEventsPublisher.Object); - private ProxyOutOfProcDataCollectionManager proxyOutOfProcDataCollectionManager; - public ProxyOutOfProcDataCollectionManagerTests() + var attachmentSet = new AttachmentSet(new Uri("my://datacollector"), "mydatacollector"); + attachmentSet.Attachments.Add(new UriDataAttachment(new Uri("my://attachment.txt"), string.Empty)); + _attachmentSets = new Collection { - this.mockTestEventsPublisher = new Mock(); - this.mockDataCollectionTestCaseEventSender = new Mock(); - this.proxyOutOfProcDataCollectionManager = new ProxyOutOfProcDataCollectionManager(this.mockDataCollectionTestCaseEventSender.Object, this.mockTestEventsPublisher.Object); - - var attachmentSet = new AttachmentSet(new Uri("my://datacollector"), "mydatacollector"); - attachmentSet.Attachments.Add(new UriDataAttachment(new Uri("my://attachment.txt"), string.Empty)); - this.attachmentSets = new Collection(); - this.attachmentSets.Add(attachmentSet); + attachmentSet + }; - this.testcase = new TestCase(); - this.testcase.Id = Guid.NewGuid(); - this.mockDataCollectionTestCaseEventSender.Setup(x => x.SendTestCaseEnd(It.IsAny())).Returns(this.attachmentSets); - this.mockTestEventsPublisher.Raise(x => x.TestCaseEnd += null, new TestCaseEndEventArgs(this.testcase, TestOutcome.Passed)); - this.testResult = new VisualStudio.TestPlatform.ObjectModel.TestResult(this.testcase); - } + _testcase = new TestCase(); + _testcase.Id = Guid.NewGuid(); + _mockDataCollectionTestCaseEventSender.Setup(x => x.SendTestCaseEnd(It.IsAny())).Returns(_attachmentSets); + _mockTestEventsPublisher.Raise(x => x.TestCaseEnd += null, new TestCaseEndEventArgs(_testcase, TestOutcome.Passed)); + _testResult = new VisualStudio.TestPlatform.ObjectModel.TestResult(_testcase); + } - [TestMethod] - public void TriggerTestCaseEndShouldReturnCacheAttachmentsAndAssociateWithTestResultWhenTriggerSendTestResultIsInvoked() - { - this.mockTestEventsPublisher.Raise(x => x.TestResult += null, new TestResultEventArgs(this.testResult)); + [TestMethod] + public void TriggerTestCaseEndShouldReturnCacheAttachmentsAndAssociateWithTestResultWhenTriggerSendTestResultIsInvoked() + { + _mockTestEventsPublisher.Raise(x => x.TestResult += null, new TestResultEventArgs(_testResult)); - Assert.AreEqual(1, this.testResult.Attachments.Count); - Assert.IsTrue(this.testResult.Attachments[0].Attachments[0].Uri.OriginalString.Contains("attachment.txt")); - } + Assert.AreEqual(1, _testResult.Attachments.Count); + Assert.IsTrue(_testResult.Attachments[0].Attachments[0].Uri.OriginalString.Contains("attachment.txt")); + } - [TestMethod] - public void TriggerSendTestResultShouldDeleteTheAttachmentsFromCache() - { - this.mockTestEventsPublisher.Raise(x => x.TestResult += null, new TestResultEventArgs(this.testResult)); + [TestMethod] + public void TriggerSendTestResultShouldDeleteTheAttachmentsFromCache() + { + _mockTestEventsPublisher.Raise(x => x.TestResult += null, new TestResultEventArgs(_testResult)); - this.testResult = new VisualStudio.TestPlatform.ObjectModel.TestResult(this.testcase); - this.mockTestEventsPublisher.Raise(x => x.TestResult += null, new TestResultEventArgs(this.testResult)); + _testResult = new VisualStudio.TestPlatform.ObjectModel.TestResult(_testcase); + _mockTestEventsPublisher.Raise(x => x.TestResult += null, new TestResultEventArgs(_testResult)); - Assert.AreEqual(0, this.testResult.Attachments.Count); - } + Assert.AreEqual(0, _testResult.Attachments.Count); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscovererEnumeratorTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscovererEnumeratorTests.cs index 16f4749e9b..b1fe282edd 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscovererEnumeratorTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscovererEnumeratorTests.cs @@ -1,750 +1,778 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Discovery +namespace TestPlatform.CrossPlatEngine.UnitTests.Discovery; + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Globalization; +using System.Linq; +using System.Reflection; +using System.Threading; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class DiscovererEnumeratorTests { - using System; - using System.Collections.Generic; - using System.ComponentModel; - using System.Globalization; - using System.Linq; - using System.Reflection; - using System.Threading; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - [TestClass] - public class DiscovererEnumeratorTests + private readonly CancellationTokenSource _cancellationTokenSource = new(); + private readonly DiscovererEnumerator _discovererEnumerator; + private readonly Mock _mockTestPlatformEventSource; + private readonly DiscoveryResultCache _discoveryResultCache; + private readonly Mock _mockRequestData; + private readonly Mock _mockMetricsCollection; + private readonly Mock _mockAssemblyProperties; + private readonly Mock _runSettingsMock; + private readonly Mock _messageLoggerMock; + + public DiscovererEnumeratorTests() { - private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); - private readonly DiscovererEnumerator discovererEnumerator; - private readonly Mock mockTestPlatformEventSource; - private readonly DiscoveryResultCache discoveryResultCache; - private readonly Mock mockRequestData; - private readonly Mock mockMetricsCollection; - private readonly Mock mockAssemblyProperties; - private readonly Mock runSettingsMock; - private readonly Mock messageLoggerMock; - - public DiscovererEnumeratorTests() - { - this.mockTestPlatformEventSource = new Mock(); - this.discoveryResultCache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { }); - this.mockRequestData = new Mock(); - this.mockMetricsCollection = new Mock(); - this.mockAssemblyProperties = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(this.mockMetricsCollection.Object); - this.discovererEnumerator = new DiscovererEnumerator(this.mockRequestData.Object, this.discoveryResultCache, this.mockTestPlatformEventSource.Object, this.mockAssemblyProperties.Object, this.cancellationTokenSource.Token); - this.runSettingsMock = new Mock(); - this.messageLoggerMock = new Mock(); - TestPluginCacheHelper.SetupMockExtensions( new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); - TestDiscoveryExtensionManager.Destroy(); - } + _mockTestPlatformEventSource = new Mock(); + _discoveryResultCache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { }); + _mockRequestData = new Mock(); + _mockMetricsCollection = new Mock(); + _mockAssemblyProperties = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(_mockMetricsCollection.Object); + _discovererEnumerator = new DiscovererEnumerator(_mockRequestData.Object, _discoveryResultCache, _mockTestPlatformEventSource.Object, _mockAssemblyProperties.Object, _cancellationTokenSource.Token); + _runSettingsMock = new Mock(); + _messageLoggerMock = new Mock(); + TestPluginCacheHelper.SetupMockExtensions(new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); + TestDiscoveryExtensionManager.Destroy(); + } - [TestCleanup] - public void Cleanup() - { - ManagedDllTestDiscoverer.Reset(); - NativeDllTestDiscoverer.Reset(); - JsonTestDiscoverer.Reset(); - NotImplementedTestDiscoverer.Reset(); - } + [TestCleanup] + public void Cleanup() + { + ManagedDllTestDiscoverer.Reset(); + NativeDllTestDiscoverer.Reset(); + JsonTestDiscoverer.Reset(); + NotImplementedTestDiscoverer.Reset(); + } - [TestMethod] - public void LoadTestsShouldReportWarningOnNoDiscoverers() - { - TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(TestPluginCache).GetTypeInfo().Assembly.Location }, - () => { }); - var sources = new List { typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location }; + [TestMethod] + public void LoadTestsShouldReportWarningOnNoDiscoverers() + { + TestPluginCacheHelper.SetupMockExtensions( + new string[] { typeof(TestPluginCache).GetTypeInfo().Assembly.Location }, + () => { }); + var sources = new List { typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location }; - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", sources); + var extensionSourceMap = new Dictionary> + { + { "_none_", sources } + }; - this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, null, this.messageLoggerMock.Object); + _discovererEnumerator.LoadTests(extensionSourceMap, _runSettingsMock.Object, null, _messageLoggerMock.Object); - var messageFormat = - "No test is available in {0}. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again."; - var message = string.Format(messageFormat, string.Join(" ", sources)); + var messageFormat = + "No test is available in {0}. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again."; + var message = string.Format(messageFormat, string.Join(" ", sources)); - this.messageLoggerMock.Verify( - l => + _messageLoggerMock.Verify( + l => l.SendMessage(TestMessageLevel.Warning, message), Times.Once); - } + } - [TestMethod] - public void LoadTestsShouldNotCallIntoDiscoverersIfNoneMatchesSources() + [TestMethod] + public void LoadTestsShouldNotCallIntoDiscoverersIfNoneMatchesSources() + { + TestPluginCacheHelper.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); + var sources = new List { "temp.jpeg" }; + + var extensionSourceMap = new Dictionary> { - TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); - var sources = new List { "temp.jpeg" }; + { "_none_", sources } + }; - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", sources); + _discovererEnumerator.LoadTests(extensionSourceMap, _runSettingsMock.Object, null, _messageLoggerMock.Object); - this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, null, this.messageLoggerMock.Object); + Assert.IsFalse(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + Assert.IsFalse(NativeDllTestDiscoverer.IsNativeDiscoverTestCalled); + } - Assert.IsFalse(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - Assert.IsFalse(NativeDllTestDiscoverer.IsNativeDiscoverTestCalled); - } + [TestMethod] + public void LoadTestsShouldCallOnlyNativeDiscovererIfNativeAssembliesPassed() + { + TestPluginCacheHelper.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); + + _mockAssemblyProperties.Setup(pe => pe.GetAssemblyType("native.dll")).Returns(AssemblyType.Native); - [TestMethod] - public void LoadTestsShouldCallOnlyNativeDiscovererIfNativeAssembliesPassed() + var sources = new List { - TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); + "native.dll" + }; - this.mockAssemblyProperties.Setup(pe => pe.GetAssemblyType("native.dll")).Returns(AssemblyType.Native); + var extensionSourceMap = new Dictionary> + { + { "_none_", sources } + }; - var sources = new List - { - "native.dll" - }; + string testCaseFilter = "TestFilter"; - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", sources); + _discovererEnumerator.LoadTests(extensionSourceMap, _runSettingsMock.Object, testCaseFilter, _messageLoggerMock.Object); - string testCaseFilter = "TestFilter"; + Assert.IsTrue(NativeDllTestDiscoverer.IsNativeDiscoverTestCalled); + CollectionAssert.AreEqual(sources, NativeDllTestDiscoverer.Sources.ToList()); - this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, testCaseFilter, this.messageLoggerMock.Object); + Assert.IsFalse(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + Assert.IsFalse(JsonTestDiscoverer.IsDiscoverTestCalled); + } - Assert.IsTrue(NativeDllTestDiscoverer.IsNativeDiscoverTestCalled); - CollectionAssert.AreEqual(sources, NativeDllTestDiscoverer.Sources.ToList()); + [TestMethod] + public void LoadTestsShouldCallOnlyManagedDiscovererIfManagedAssembliesPassed() + { + TestPluginCacheHelper.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); - Assert.IsFalse(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - Assert.IsFalse(JsonTestDiscoverer.IsDiscoverTestCalled); - } + _mockAssemblyProperties.Setup(pe => pe.GetAssemblyType("managed.dll")).Returns(AssemblyType.Managed); - [TestMethod] - public void LoadTestsShouldCallOnlyManagedDiscovererIfManagedAssembliesPassed() + var sources = new List { - TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); + "managed.dll" + }; - this.mockAssemblyProperties.Setup(pe => pe.GetAssemblyType("managed.dll")).Returns(AssemblyType.Managed); + var extensionSourceMap = new Dictionary> + { + { "_none_", sources } + }; - var sources = new List - { - "managed.dll" - }; + string testCaseFilter = "TestFilter"; - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", sources); + _discovererEnumerator.LoadTests(extensionSourceMap, _runSettingsMock.Object, testCaseFilter, _messageLoggerMock.Object); - string testCaseFilter = "TestFilter"; + Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + CollectionAssert.AreEqual(sources, ManagedDllTestDiscoverer.Sources.ToList()); - this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, testCaseFilter, this.messageLoggerMock.Object); + Assert.IsFalse(NativeDllTestDiscoverer.IsNativeDiscoverTestCalled); + Assert.IsFalse(JsonTestDiscoverer.IsDiscoverTestCalled); + } - Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - CollectionAssert.AreEqual(sources, ManagedDllTestDiscoverer.Sources.ToList()); + [TestMethod] + public void LoadTestsShouldCallBothNativeAndManagedDiscoverersWithCorrectSources() + { + TestPluginCacheHelper.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); - Assert.IsFalse(NativeDllTestDiscoverer.IsNativeDiscoverTestCalled); - Assert.IsFalse(JsonTestDiscoverer.IsDiscoverTestCalled); - } + _mockAssemblyProperties.Setup(pe => pe.GetAssemblyType("native.dll")).Returns(AssemblyType.Native); + _mockAssemblyProperties.Setup(pe => pe.GetAssemblyType("managed.dll")).Returns(AssemblyType.Managed); - [TestMethod] - public void LoadTestsShouldCallBothNativeAndManagedDiscoverersWithCorrectSources() + var nativeSources = new List { - TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); - - this.mockAssemblyProperties.Setup(pe => pe.GetAssemblyType("native.dll")).Returns(AssemblyType.Native); - this.mockAssemblyProperties.Setup(pe => pe.GetAssemblyType("managed.dll")).Returns(AssemblyType.Managed); + "native.dll" + }; + var managedSources = new List + { + "managed.dll" + }; - var nativeSources = new List - { - "native.dll" - }; - var managedSources = new List - { - "managed.dll" - }; + var extensionSourceMap = new Dictionary> + { + { "_none_", nativeSources.Concat(managedSources) } + }; - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", nativeSources.Concat(managedSources)); + string testCaseFilter = "TestFilter"; - string testCaseFilter = "TestFilter"; + _discovererEnumerator.LoadTests(extensionSourceMap, _runSettingsMock.Object, testCaseFilter, _messageLoggerMock.Object); - this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, testCaseFilter, this.messageLoggerMock.Object); + Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + CollectionAssert.AreEqual(managedSources, ManagedDllTestDiscoverer.Sources.ToList()); - Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - CollectionAssert.AreEqual(managedSources, ManagedDllTestDiscoverer.Sources.ToList()); + Assert.IsTrue(NativeDllTestDiscoverer.IsNativeDiscoverTestCalled); + CollectionAssert.AreEqual(nativeSources, NativeDllTestDiscoverer.Sources.ToList()); - Assert.IsTrue(NativeDllTestDiscoverer.IsNativeDiscoverTestCalled); - CollectionAssert.AreEqual(nativeSources, NativeDllTestDiscoverer.Sources.ToList()); + Assert.IsFalse(JsonTestDiscoverer.IsDiscoverTestCalled); + } - Assert.IsFalse(JsonTestDiscoverer.IsDiscoverTestCalled); - } + [TestMethod] + public void LoadTestsShouldCallIntoADiscovererThatMatchesTheSources() + { + TestPluginCacheHelper.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); - [TestMethod] - public void LoadTestsShouldCallIntoADiscovererThatMatchesTheSources() + var sources = new List { - TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + }; - var sources = new List - { - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location - }; + var extensionSourceMap = new Dictionary> + { + { "_none_", sources } + }; + string testCaseFilter = "TestFilter"; - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", sources); - string testCaseFilter = "TestFilter"; + _discovererEnumerator.LoadTests(extensionSourceMap, _runSettingsMock.Object, testCaseFilter, _messageLoggerMock.Object); - this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, testCaseFilter, this.messageLoggerMock.Object); + Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + Assert.IsFalse(JsonTestDiscoverer.IsDiscoverTestCalled); - Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - Assert.IsFalse(JsonTestDiscoverer.IsDiscoverTestCalled); + // Also validate that the right set of arguments were passed on to the discoverer. + CollectionAssert.AreEqual(sources, ManagedDllTestDiscoverer.Sources.ToList()); + Assert.AreEqual(_runSettingsMock.Object, DllTestDiscoverer.DiscoveryContext.RunSettings); + Assert.AreEqual(testCaseFilter, (DllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); + Assert.AreEqual(_messageLoggerMock.Object, DllTestDiscoverer.MessageLogger); + Assert.IsNotNull(DllTestDiscoverer.DiscoverySink); + } - // Also validate that the right set of arguments were passed on to the discoverer. - CollectionAssert.AreEqual(sources, ManagedDllTestDiscoverer.Sources.ToList()); - Assert.AreEqual(this.runSettingsMock.Object, ManagedDllTestDiscoverer.DiscoveryContext.RunSettings); - Assert.AreEqual(testCaseFilter, (ManagedDllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); - Assert.AreEqual(this.messageLoggerMock.Object, ManagedDllTestDiscoverer.MessageLogger); - Assert.IsNotNull(ManagedDllTestDiscoverer.DiscoverySink); - } + [TestMethod] + public void LoadTestsShouldCallIntoMultipleDiscoverersThatMatchesTheSources() + { + TestPluginCacheHelper.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); - [TestMethod] - public void LoadTestsShouldCallIntoMultipleDiscoverersThatMatchesTheSources() - { - TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); - - var dllsources = new List - { - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location - }; - var jsonsources = new List - { - "test1.json", - "test2.json" - }; - var sources = new List(dllsources); - sources.AddRange(jsonsources); - - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", sources); - - var runSettings = this.runSettingsMock.Object; - - string testCaseFilter = "TestFilter"; - - this.discovererEnumerator.LoadTests(extensionSourceMap, runSettings, testCaseFilter, this.messageLoggerMock.Object); - - Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - Assert.IsTrue(JsonTestDiscoverer.IsDiscoverTestCalled); - - // Also validate that the right set of arguments were passed on to the discoverer. - CollectionAssert.AreEqual(dllsources, ManagedDllTestDiscoverer.Sources.ToList()); - Assert.AreEqual(runSettings, ManagedDllTestDiscoverer.DiscoveryContext.RunSettings); - Assert.AreEqual(testCaseFilter, (ManagedDllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); - Assert.AreEqual(this.messageLoggerMock.Object, ManagedDllTestDiscoverer.MessageLogger); - Assert.IsNotNull(ManagedDllTestDiscoverer.DiscoverySink); - - CollectionAssert.AreEqual(jsonsources, JsonTestDiscoverer.Sources.ToList()); - Assert.AreEqual(runSettings, JsonTestDiscoverer.DiscoveryContext.RunSettings); - Assert.AreEqual(testCaseFilter, (JsonTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); - Assert.AreEqual(this.messageLoggerMock.Object, JsonTestDiscoverer.MessageLogger); - Assert.IsNotNull(JsonTestDiscoverer.DiscoverySink); - } + var dllsources = new List + { + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + }; + var jsonsources = new List + { + "test1.json", + "test2.json" + }; + var sources = new List(dllsources); + sources.AddRange(jsonsources); - [TestMethod] - public void LoadTestsShouldCallIntoOtherDiscoverersWhenCreatingOneFails() + var extensionSourceMap = new Dictionary> { - TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); + { "_none_", sources } + }; - var sources = new List - { - "test1.csv", - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location - }; + var runSettings = _runSettingsMock.Object; - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", sources); + string testCaseFilter = "TestFilter"; - var runSettings = this.runSettingsMock.Object; + _discovererEnumerator.LoadTests(extensionSourceMap, runSettings, testCaseFilter, _messageLoggerMock.Object); - string testCaseFilter = "TestFilter"; + Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + Assert.IsTrue(JsonTestDiscoverer.IsDiscoverTestCalled); - this.discovererEnumerator.LoadTests(extensionSourceMap, runSettings, testCaseFilter, this.messageLoggerMock.Object); + // Also validate that the right set of arguments were passed on to the discoverer. + CollectionAssert.AreEqual(dllsources, ManagedDllTestDiscoverer.Sources.ToList()); + Assert.AreEqual(runSettings, DllTestDiscoverer.DiscoveryContext.RunSettings); + Assert.AreEqual(testCaseFilter, (DllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); + Assert.AreEqual(_messageLoggerMock.Object, DllTestDiscoverer.MessageLogger); + Assert.IsNotNull(DllTestDiscoverer.DiscoverySink); - Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - Assert.IsFalse(SingletonTestDiscoverer.IsDiscoverTestCalled); + CollectionAssert.AreEqual(jsonsources, JsonTestDiscoverer.Sources.ToList()); + Assert.AreEqual(runSettings, JsonTestDiscoverer.DiscoveryContext.RunSettings); + Assert.AreEqual(testCaseFilter, (JsonTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); + Assert.AreEqual(_messageLoggerMock.Object, JsonTestDiscoverer.MessageLogger); + Assert.IsNotNull(JsonTestDiscoverer.DiscoverySink); + } - // Also validate that the right set of arguments were passed on to the discoverer. - CollectionAssert.AreEqual(new List { sources[1] }, ManagedDllTestDiscoverer.Sources.ToList()); - Assert.AreEqual(runSettings, ManagedDllTestDiscoverer.DiscoveryContext.RunSettings); - Assert.AreEqual(testCaseFilter, (ManagedDllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); - Assert.AreEqual(this.messageLoggerMock.Object, ManagedDllTestDiscoverer.MessageLogger); - Assert.IsNotNull(ManagedDllTestDiscoverer.DiscoverySink); - } + [TestMethod] + public void LoadTestsShouldCallIntoOtherDiscoverersWhenCreatingOneFails() + { + TestPluginCacheHelper.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); + + var sources = new List + { + "test1.csv", + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + }; - [TestMethod] - public void LoadTestsShouldCallIntoOtherDiscoverersEvenIfDiscoveryInOneFails() + var extensionSourceMap = new Dictionary> { - TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); + { "_none_", sources } + }; + + var runSettings = _runSettingsMock.Object; + + string testCaseFilter = "TestFilter"; - var sources = new List - { - "test1.cs", - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location - }; + _discovererEnumerator.LoadTests(extensionSourceMap, runSettings, testCaseFilter, _messageLoggerMock.Object); - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", sources); + Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + Assert.IsFalse(SingletonTestDiscoverer.IsDiscoverTestCalled); - var runSettings = this.runSettingsMock.Object; + // Also validate that the right set of arguments were passed on to the discoverer. + CollectionAssert.AreEqual(new List { sources[1] }, ManagedDllTestDiscoverer.Sources.ToList()); + Assert.AreEqual(runSettings, DllTestDiscoverer.DiscoveryContext.RunSettings); + Assert.AreEqual(testCaseFilter, (DllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); + Assert.AreEqual(_messageLoggerMock.Object, DllTestDiscoverer.MessageLogger); + Assert.IsNotNull(DllTestDiscoverer.DiscoverySink); + } - string testCaseFilter = "TestFilter"; + [TestMethod] + public void LoadTestsShouldCallIntoOtherDiscoverersEvenIfDiscoveryInOneFails() + { + TestPluginCacheHelper.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); - this.discovererEnumerator.LoadTests(extensionSourceMap, runSettings, testCaseFilter, this.messageLoggerMock.Object); + var sources = new List + { + "test1.cs", + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + }; - Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - Assert.IsTrue(NotImplementedTestDiscoverer.IsDiscoverTestCalled); + var extensionSourceMap = new Dictionary> + { + { "_none_", sources } + }; - // Also validate that the right set of arguments were passed on to the discoverer. - CollectionAssert.AreEqual(new List { sources[1] }, ManagedDllTestDiscoverer.Sources.ToList()); - Assert.AreEqual(runSettings, ManagedDllTestDiscoverer.DiscoveryContext.RunSettings); - Assert.AreEqual(testCaseFilter, (ManagedDllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); - Assert.AreEqual(this.messageLoggerMock.Object, ManagedDllTestDiscoverer.MessageLogger); - Assert.IsNotNull(ManagedDllTestDiscoverer.DiscoverySink); + var runSettings = _runSettingsMock.Object; - // Check if we log the failure. - var message = string.Format( - CultureInfo.CurrentUICulture, - "An exception occurred while test discoverer '{0}' was loading tests. Exception: {1}", - typeof(NotImplementedTestDiscoverer).Name, - "The method or operation is not implemented."); + string testCaseFilter = "TestFilter"; - this.messageLoggerMock.Verify(l => l.SendMessage(TestMessageLevel.Error, message), Times.Once); - } + _discovererEnumerator.LoadTests(extensionSourceMap, runSettings, testCaseFilter, _messageLoggerMock.Object); - [TestMethod] - public void LoadTestsShouldCollectMetrics() - { - var mockMetricsCollector = new Mock(); - var dict = new Dictionary(); - dict.Add("DummyMessage", "DummyValue"); - - TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); - - var sources = new List - { - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location - }; - - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", sources); - - mockMetricsCollector.Setup(mc => mc.Metrics).Returns(dict); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollector.Object); - - string testCaseFilter = "TestFilter"; - this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, testCaseFilter, this.messageLoggerMock.Object); - - // Verify. - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenInSecByAllAdapters, It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.NumberOfAdapterUsedToDiscoverTests, It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringDiscovery, It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TotalTestsByAdapter + ".discoverer://manageddlldiscoverer/", It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter + ".discoverer://manageddlldiscoverer/", It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TotalTestsByAdapter + ".discoverer://nativedlldiscoverer/", It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter + ".discoverer://nativedlldiscoverer/", It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenToLoadAdaptersInSec, It.IsAny()), Times.Once); - } + Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + Assert.IsTrue(NotImplementedTestDiscoverer.IsDiscoverTestCalled); - [TestMethod] - public void LoadTestsShouldNotCallIntoDiscoverersWhenCancelled() - { - // Setup - string[] extensions = new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }; - TestPluginCacheHelper.SetupMockExtensions(extensions, () => { }); - - var dllsources = new List - { - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location - }; - var jsonsources = new List - { - "test1.json", - "test2.json" - }; - var sources = new List(dllsources); - sources.AddRange(jsonsources); - - var extensionSourceMap = new Dictionary> - { - { "_none_", sources } - }; - - // Act - this.cancellationTokenSource.Cancel(); - var runSettings = this.runSettingsMock.Object; - string testCaseFilter = "TestFilter"; - this.discovererEnumerator.LoadTests(extensionSourceMap, runSettings, testCaseFilter, this.messageLoggerMock.Object); - - // Validate - Assert.IsFalse(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - Assert.IsFalse(JsonTestDiscoverer.IsDiscoverTestCalled); - this.messageLoggerMock.Verify(logger => logger.SendMessage(TestMessageLevel.Warning, "Discovery of tests cancelled."), Times.Once); - } + // Also validate that the right set of arguments were passed on to the discoverer. + CollectionAssert.AreEqual(new List { sources[1] }, ManagedDllTestDiscoverer.Sources.ToList()); + Assert.AreEqual(runSettings, DllTestDiscoverer.DiscoveryContext.RunSettings); + Assert.AreEqual(testCaseFilter, (DllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); + Assert.AreEqual(_messageLoggerMock.Object, DllTestDiscoverer.MessageLogger); + Assert.IsNotNull(DllTestDiscoverer.DiscoverySink); + + // Check if we log the failure. + var message = string.Format( + CultureInfo.CurrentUICulture, + "An exception occurred while test discoverer '{0}' was loading tests. Exception: {1}", + typeof(NotImplementedTestDiscoverer).Name, + "The method or operation is not implemented."); - [TestMethod] - public void LoadTestsShouldCallIntoTheAdapterWithTheRightTestCaseSink() + _messageLoggerMock.Verify(l => l.SendMessage(TestMessageLevel.Error, message), Times.Once); + } + + [TestMethod] + public void LoadTestsShouldCollectMetrics() + { + var mockMetricsCollector = new Mock(); + var dict = new Dictionary { - this.InvokeLoadTestWithMockSetup(); + { "DummyMessage", "DummyValue" } + }; - Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - Assert.AreEqual(2, this.discoveryResultCache.Tests.Count); - } + TestPluginCacheHelper.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); - [TestMethod] - public void LoadTestsShouldNotShowAnyWarningOnTestsDiscovered() + var sources = new List { - this.InvokeLoadTestWithMockSetup(); + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + }; - Assert.AreEqual(2, this.discoveryResultCache.Tests.Count); + var extensionSourceMap = new Dictionary> + { + { "_none_", sources } + }; + + mockMetricsCollector.Setup(mc => mc.Metrics).Returns(dict); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollector.Object); + + string testCaseFilter = "TestFilter"; + _discovererEnumerator.LoadTests(extensionSourceMap, _runSettingsMock.Object, testCaseFilter, _messageLoggerMock.Object); + + // Verify. + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenInSecByAllAdapters, It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.NumberOfAdapterUsedToDiscoverTests, It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringDiscovery, It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TotalTestsByAdapter + ".discoverer://manageddlldiscoverer/", It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter + ".discoverer://manageddlldiscoverer/", It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TotalTestsByAdapter + ".discoverer://nativedlldiscoverer/", It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter + ".discoverer://nativedlldiscoverer/", It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenToLoadAdaptersInSec, It.IsAny()), Times.Once); + } - this.messageLoggerMock.Verify(m => m.SendMessage(TestMessageLevel.Warning, It.IsAny()), Times.Never); - } + [TestMethod] + public void LoadTestsShouldNotCallIntoDiscoverersWhenCancelled() + { + // Setup + string[] extensions = new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }; + TestPluginCacheHelper.SetupMockExtensions(extensions, () => { }); - [TestMethod] - public void LoadTestShouldInstrumentDiscoveryStart() + var dllsources = new List { - this.InvokeLoadTestWithMockSetup(); - this.mockTestPlatformEventSource.Verify(x => x.DiscoveryStart(), Times.Once); - } + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + }; + var jsonsources = new List + { + "test1.json", + "test2.json" + }; + var sources = new List(dllsources); + sources.AddRange(jsonsources); - [TestMethod] - public void LoadTestShouldInstrumentDiscoveryStop() + var extensionSourceMap = new Dictionary> { - this.InvokeLoadTestWithMockSetup(); - this.mockTestPlatformEventSource.Verify(x => x.DiscoveryStop(It.IsAny()), Times.Once); - } + { "_none_", sources } + }; + + // Act + _cancellationTokenSource.Cancel(); + var runSettings = _runSettingsMock.Object; + string testCaseFilter = "TestFilter"; + _discovererEnumerator.LoadTests(extensionSourceMap, runSettings, testCaseFilter, _messageLoggerMock.Object); + + // Validate + Assert.IsFalse(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + Assert.IsFalse(JsonTestDiscoverer.IsDiscoverTestCalled); + _messageLoggerMock.Verify(logger => logger.SendMessage(TestMessageLevel.Warning, "Discovery of tests cancelled."), Times.Once); + } + + [TestMethod] + public void LoadTestsShouldCallIntoTheAdapterWithTheRightTestCaseSink() + { + InvokeLoadTestWithMockSetup(); - [TestMethod] - public void LoadTestShouldInstrumentAdapterDiscoveryStart() + Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + Assert.AreEqual(2, _discoveryResultCache.Tests.Count); + } + + [TestMethod] + public void LoadTestsShouldNotShowAnyWarningOnTestsDiscovered() + { + InvokeLoadTestWithMockSetup(); + + Assert.AreEqual(2, _discoveryResultCache.Tests.Count); + + _messageLoggerMock.Verify(m => m.SendMessage(TestMessageLevel.Warning, It.IsAny()), Times.Never); + } + + [TestMethod] + public void LoadTestShouldInstrumentDiscoveryStart() + { + InvokeLoadTestWithMockSetup(); + _mockTestPlatformEventSource.Verify(x => x.DiscoveryStart(), Times.Once); + } + + [TestMethod] + public void LoadTestShouldInstrumentDiscoveryStop() + { + InvokeLoadTestWithMockSetup(); + _mockTestPlatformEventSource.Verify(x => x.DiscoveryStop(It.IsAny()), Times.Once); + } + + [TestMethod] + public void LoadTestShouldInstrumentAdapterDiscoveryStart() + { + InvokeLoadTestWithMockSetup(); + _mockTestPlatformEventSource.Verify(x => x.AdapterDiscoveryStart(It.IsAny()), Times.AtLeastOnce); + } + + [TestMethod] + public void LoadTestShouldInstrumentAdapterDiscoveryStop() + { + InvokeLoadTestWithMockSetup(); + _mockTestPlatformEventSource.Verify(x => x.AdapterDiscoveryStop(It.IsAny()), Times.AtLeastOnce); + } + + [TestMethod] + public void LoadTestsShouldIterateOverAllExtensionsInTheMapAndDiscoverTests() + { + TestPluginCacheHelper.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); + + var dllsources = new List { - this.InvokeLoadTestWithMockSetup(); - this.mockTestPlatformEventSource.Verify(x => x.AdapterDiscoveryStart(It.IsAny()), Times.AtLeastOnce); - } + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + }; + var jsonsources = new List + { + "test1.json", + "test2.json" + }; - [TestMethod] - public void LoadTestShouldInstrumentAdapterDiscoveryStop() + var extensionSourceMap = new Dictionary> { - this.InvokeLoadTestWithMockSetup(); - this.mockTestPlatformEventSource.Verify(x => x.AdapterDiscoveryStop(It.IsAny()), Times.AtLeastOnce); - } + { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location, jsonsources }, + { "_none_", dllsources } + }; - [TestMethod] - public void LoadTestsShouldIterateOverAllExtensionsInTheMapAndDiscoverTests() - { - TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); - - var dllsources = new List - { - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location - }; - var jsonsources = new List - { - "test1.json", - "test2.json" - }; - - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add(typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location, jsonsources); - extensionSourceMap.Add("_none_", dllsources); - - var runSettings = this.runSettingsMock.Object; - - string testCaseFilter = "TestFilter"; - - this.discovererEnumerator.LoadTests(extensionSourceMap, runSettings, testCaseFilter, this.messageLoggerMock.Object); - - Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - Assert.IsTrue(JsonTestDiscoverer.IsDiscoverTestCalled); - - // Also validate that the right set of arguments were passed on to the discoverer. - CollectionAssert.AreEqual(dllsources, ManagedDllTestDiscoverer.Sources.ToList()); - Assert.AreEqual(runSettings, ManagedDllTestDiscoverer.DiscoveryContext.RunSettings); - Assert.AreEqual(testCaseFilter, (ManagedDllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); - Assert.AreEqual(this.messageLoggerMock.Object, ManagedDllTestDiscoverer.MessageLogger); - Assert.IsNotNull(ManagedDllTestDiscoverer.DiscoverySink); - - CollectionAssert.AreEqual(jsonsources, JsonTestDiscoverer.Sources.ToList()); - Assert.AreEqual(runSettings, JsonTestDiscoverer.DiscoveryContext.RunSettings); - Assert.AreEqual(testCaseFilter, (JsonTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); - Assert.AreEqual(this.messageLoggerMock.Object, JsonTestDiscoverer.MessageLogger); - Assert.IsNotNull(JsonTestDiscoverer.DiscoverySink); - } + var runSettings = _runSettingsMock.Object; - [TestMethod] - public void LoadTestsShouldLogWarningMessageOnNoTestsInAssemblies() - { - DiscovererEnumeratorTests.SetupForNoTestsAvailableInGivenAssemblies(out var extensionSourceMap, out var sourcesString); + string testCaseFilter = "TestFilter"; - this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, null, this.messageLoggerMock.Object); + _discovererEnumerator.LoadTests(extensionSourceMap, runSettings, testCaseFilter, _messageLoggerMock.Object); - var expectedMessage = - $"No test is available in {sourcesString}. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again."; + Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + Assert.IsTrue(JsonTestDiscoverer.IsDiscoverTestCalled); - this.messageLoggerMock.Verify(l => l.SendMessage(TestMessageLevel.Warning, expectedMessage)); - } + // Also validate that the right set of arguments were passed on to the discoverer. + CollectionAssert.AreEqual(dllsources, ManagedDllTestDiscoverer.Sources.ToList()); + Assert.AreEqual(runSettings, DllTestDiscoverer.DiscoveryContext.RunSettings); + Assert.AreEqual(testCaseFilter, (DllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); + Assert.AreEqual(_messageLoggerMock.Object, DllTestDiscoverer.MessageLogger); + Assert.IsNotNull(DllTestDiscoverer.DiscoverySink); - [TestMethod] - public void LoadTestsShouldLogWarningMessageOnNoTestsInAssembliesWithTestCaseFilter() - { - DiscovererEnumeratorTests.SetupForNoTestsAvailableInGivenAssemblies(out var extensionSourceMap, out var sourcesString); + CollectionAssert.AreEqual(jsonsources, JsonTestDiscoverer.Sources.ToList()); + Assert.AreEqual(runSettings, JsonTestDiscoverer.DiscoveryContext.RunSettings); + Assert.AreEqual(testCaseFilter, (JsonTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); + Assert.AreEqual(_messageLoggerMock.Object, JsonTestDiscoverer.MessageLogger); + Assert.IsNotNull(JsonTestDiscoverer.DiscoverySink); + } - var testCaseFilter = "Name~TestMethod1"; + [TestMethod] + public void LoadTestsShouldLogWarningMessageOnNoTestsInAssemblies() + { + SetupForNoTestsAvailableInGivenAssemblies(out var extensionSourceMap, out var sourcesString); - this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, testCaseFilter, this.messageLoggerMock.Object); + _discovererEnumerator.LoadTests(extensionSourceMap, _runSettingsMock.Object, null, _messageLoggerMock.Object); - var expectedMessage = - $"No test matches the given testcase filter `{testCaseFilter}` in {sourcesString}"; + var expectedMessage = + $"No test is available in {sourcesString}. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again."; - this.messageLoggerMock.Verify(l => l.SendMessage(TestMessageLevel.Warning, expectedMessage)); - } + _messageLoggerMock.Verify(l => l.SendMessage(TestMessageLevel.Warning, expectedMessage)); + } - [TestMethod] - public void LoadTestsShouldShortenTheLongTestCaseFilterWhenNoTestsDiscovered() - { - DiscovererEnumeratorTests.SetupForNoTestsAvailableInGivenAssemblies(out var extensionSourceMap, out var sourcesString); + [TestMethod] + public void LoadTestsShouldLogWarningMessageOnNoTestsInAssembliesWithTestCaseFilter() + { + SetupForNoTestsAvailableInGivenAssemblies(out var extensionSourceMap, out var sourcesString); - var veryLengthyTestCaseFilter = "FullyQualifiedName=TestPlatform.CrossPlatEngine" + - ".UnitTests.Discovery.DiscovererEnumeratorTests." + - "LoadTestsShouldShortenTheLongTestCaseFilterWhenNoTestsDiscovered" + - "TestCaseFilterWithVeryLengthTestCaseNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; + var testCaseFilter = "Name~TestMethod1"; - this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, veryLengthyTestCaseFilter, this.messageLoggerMock.Object); + _discovererEnumerator.LoadTests(extensionSourceMap, _runSettingsMock.Object, testCaseFilter, _messageLoggerMock.Object); - var expectedTestCaseFilter = veryLengthyTestCaseFilter.Substring(0, 256) + "..."; - var expectedMessage = - $"No test matches the given testcase filter `{expectedTestCaseFilter}` in {sourcesString}"; + var expectedMessage = + $"No test matches the given testcase filter `{testCaseFilter}` in {sourcesString}"; - this.messageLoggerMock.Verify(l => l.SendMessage(TestMessageLevel.Warning, expectedMessage)); - } + _messageLoggerMock.Verify(l => l.SendMessage(TestMessageLevel.Warning, expectedMessage)); + } - private static void SetupForNoTestsAvailableInGivenAssemblies( - out Dictionary> extensionSourceMap, - out string sourcesString) - { - var crossPlatEngineAssemblyLocation = typeof(DiscovererEnumerator).GetTypeInfo().Assembly.Location; - var objectModelAseeAssemblyLocation = typeof(TestCase).GetTypeInfo().Assembly.Location; - var sources = new string[] { crossPlatEngineAssemblyLocation, objectModelAseeAssemblyLocation }; + [TestMethod] + public void LoadTestsShouldShortenTheLongTestCaseFilterWhenNoTestsDiscovered() + { + SetupForNoTestsAvailableInGivenAssemblies(out var extensionSourceMap, out var sourcesString); - extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", sources); - sourcesString = string.Join(" ", crossPlatEngineAssemblyLocation, objectModelAseeAssemblyLocation); - } + var veryLengthyTestCaseFilter = "FullyQualifiedName=TestPlatform.CrossPlatEngine" + + ".UnitTests.Discovery.DiscovererEnumeratorTests." + + "LoadTestsShouldShortenTheLongTestCaseFilterWhenNoTestsDiscovered" + + "TestCaseFilterWithVeryLengthTestCaseNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; - private void InvokeLoadTestWithMockSetup() - { - TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); + _discovererEnumerator.LoadTests(extensionSourceMap, _runSettingsMock.Object, veryLengthyTestCaseFilter, _messageLoggerMock.Object); - var sources = new List - { - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location - }; + var expectedTestCaseFilter = veryLengthyTestCaseFilter.Substring(0, 256) + "..."; + var expectedMessage = + $"No test matches the given testcase filter `{expectedTestCaseFilter}` in {sourcesString}"; - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", sources); + _messageLoggerMock.Verify(l => l.SendMessage(TestMessageLevel.Warning, expectedMessage)); + } - this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, null, this.messageLoggerMock.Object); - } + private static void SetupForNoTestsAvailableInGivenAssemblies( + out Dictionary> extensionSourceMap, + out string sourcesString) + { + var crossPlatEngineAssemblyLocation = typeof(DiscovererEnumerator).GetTypeInfo().Assembly.Location; + var objectModelAseeAssemblyLocation = typeof(TestCase).GetTypeInfo().Assembly.Location; + var sources = new string[] { crossPlatEngineAssemblyLocation, objectModelAseeAssemblyLocation }; - #region Implementation + extensionSourceMap = new Dictionary> + { + { "_none_", sources } + }; + sourcesString = string.Join(" ", crossPlatEngineAssemblyLocation, objectModelAseeAssemblyLocation); + } - /// - /// Placing this before others so that at runtime this would be the first to be discovered as a discoverer. - /// - [FileExtension(".csv")] - [DefaultExecutorUri("discoverer://csvdiscoverer")] - private class SingletonTestDiscoverer : ITestDiscoverer + private void InvokeLoadTestWithMockSetup() + { + TestPluginCacheHelper.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); + + var sources = new List { - private SingletonTestDiscoverer() - { - } + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + }; - public static bool IsDiscoverTestCalled { get; private set; } + var extensionSourceMap = new Dictionary> + { + { "_none_", sources } + }; - public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) - { - IsDiscoverTestCalled = true; - } + _discovererEnumerator.LoadTests(extensionSourceMap, _runSettingsMock.Object, null, _messageLoggerMock.Object); + } - public static void Reset() - { - IsDiscoverTestCalled = false; - } + #region Implementation + + /// + /// Placing this before others so that at runtime this would be the first to be discovered as a discoverer. + /// + [FileExtension(".csv")] + [DefaultExecutorUri("discoverer://csvdiscoverer")] + private class SingletonTestDiscoverer : ITestDiscoverer + { + private SingletonTestDiscoverer() + { } - [FileExtension(".cs")] - [DefaultExecutorUri("discoverer://csvdiscoverer")] - private class NotImplementedTestDiscoverer : ITestDiscoverer + public static bool IsDiscoverTestCalled { get; private set; } + + public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) { - public static bool IsDiscoverTestCalled { get; private set; } + IsDiscoverTestCalled = true; + } - public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) - { - IsDiscoverTestCalled = true; - throw new NotImplementedException(); - } + public static void Reset() + { + IsDiscoverTestCalled = false; + } + } - public static void Reset() - { - IsDiscoverTestCalled = false; - } + [FileExtension(".cs")] + [DefaultExecutorUri("discoverer://csvdiscoverer")] + private class NotImplementedTestDiscoverer : ITestDiscoverer + { + public static bool IsDiscoverTestCalled { get; private set; } + + public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) + { + IsDiscoverTestCalled = true; + throw new NotImplementedException(); } - [FileExtension(".dll")] - [DefaultExecutorUri("discoverer://manageddlldiscoverer")] - [Category("managed")] - private class ManagedDllTestDiscoverer : DllTestDiscoverer + public static void Reset() { - public static bool IsManagedDiscoverTestCalled { get; private set; } + IsDiscoverTestCalled = false; + } + } - public static IEnumerable Sources { get; set; } + [FileExtension(".dll")] + [DefaultExecutorUri("discoverer://manageddlldiscoverer")] + [Category("managed")] + private class ManagedDllTestDiscoverer : DllTestDiscoverer + { + public static bool IsManagedDiscoverTestCalled { get; private set; } - public override void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) - { - Sources = sources; - IsManagedDiscoverTestCalled = true; - base.DiscoverTests(sources, discoveryContext, logger, discoverySink); - } + public static IEnumerable Sources { get; set; } - public static void Reset() - { - IsManagedDiscoverTestCalled = false; - Sources = null; - } + public override void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) + { + Sources = sources; + IsManagedDiscoverTestCalled = true; + base.DiscoverTests(sources, discoveryContext, logger, discoverySink); } - [FileExtension(".dll")] - [DefaultExecutorUri("discoverer://nativedlldiscoverer")] - [Category("native")] - private class NativeDllTestDiscoverer : DllTestDiscoverer + public static void Reset() { - public static bool IsNativeDiscoverTestCalled { get; private set; } + IsManagedDiscoverTestCalled = false; + Sources = null; + } + } - public static IEnumerable Sources { get; set; } + [FileExtension(".dll")] + [DefaultExecutorUri("discoverer://nativedlldiscoverer")] + [Category("native")] + private class NativeDllTestDiscoverer : DllTestDiscoverer + { + public static bool IsNativeDiscoverTestCalled { get; private set; } - public override void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) - { - Sources = sources; - IsNativeDiscoverTestCalled = true; - base.DiscoverTests(sources, discoveryContext, logger, discoverySink); - } + public static IEnumerable Sources { get; set; } - public static void Reset() - { - IsNativeDiscoverTestCalled = false; - Sources = null; - } + public override void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) + { + Sources = sources; + IsNativeDiscoverTestCalled = true; + base.DiscoverTests(sources, discoveryContext, logger, discoverySink); } - private class DllTestDiscoverer : ITestDiscoverer + public static void Reset() { - public static IDiscoveryContext DiscoveryContext { get; private set; } + IsNativeDiscoverTestCalled = false; + Sources = null; + } + } + + private class DllTestDiscoverer : ITestDiscoverer + { + public static IDiscoveryContext DiscoveryContext { get; private set; } - public static IMessageLogger MessageLogger { get; private set; } + public static IMessageLogger MessageLogger { get; private set; } - public static ITestCaseDiscoverySink DiscoverySink { get; private set; } + public static ITestCaseDiscoverySink DiscoverySink { get; private set; } - public virtual void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) + public virtual void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) + { + if (ShouldTestDiscovered(sources) == false) { - if (DllTestDiscoverer.ShouldTestDiscovered(sources) == false) - { - return; - } + return; + } - DiscoveryContext = discoveryContext; - MessageLogger = logger; - DiscoverySink = discoverySink; + DiscoveryContext = discoveryContext; + MessageLogger = logger; + DiscoverySink = discoverySink; - var testCase = new TestCase("A.C.M", new Uri("executor://dllexecutor"), "A"); - discoverySink.SendTestCase(testCase); - } + var testCase = new TestCase("A.C.M", new Uri("executor://dllexecutor"), "A"); + discoverySink.SendTestCase(testCase); + } - private static bool ShouldTestDiscovered(IEnumerable sources) + private static bool ShouldTestDiscovered(IEnumerable sources) + { + var shouldTestDiscovered = false; + foreach (var source in sources) { - var shouldTestDiscovered = false; - foreach (var source in sources) + if (source.Equals("native.dll") || source.Equals("managed.dll") || source.EndsWith("CrossPlatEngine.UnitTests.dll")) { - if (source.Equals("native.dll") || source.Equals("managed.dll") || source.EndsWith("CrossPlatEngine.UnitTests.dll")) - { - shouldTestDiscovered = true; - break; - } + shouldTestDiscovered = true; + break; } - - return shouldTestDiscovered; } - } - [FileExtension(".json")] - [DefaultExecutorUri("discoverer://jsondiscoverer")] - private class JsonTestDiscoverer : ITestDiscoverer - { - public static bool IsDiscoverTestCalled { get; private set; } + return shouldTestDiscovered; + } + } - public static IEnumerable Sources { get; private set; } + [FileExtension(".json")] + [DefaultExecutorUri("discoverer://jsondiscoverer")] + private class JsonTestDiscoverer : ITestDiscoverer + { + public static bool IsDiscoverTestCalled { get; private set; } - public static IDiscoveryContext DiscoveryContext { get; private set; } + public static IEnumerable Sources { get; private set; } - public static IMessageLogger MessageLogger { get; private set; } + public static IDiscoveryContext DiscoveryContext { get; private set; } - public static ITestCaseDiscoverySink DiscoverySink { get; private set; } + public static IMessageLogger MessageLogger { get; private set; } - public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) - { - IsDiscoverTestCalled = true; - Sources = sources; - DiscoveryContext = discoveryContext; - MessageLogger = logger; - DiscoverySink = discoverySink; - } + public static ITestCaseDiscoverySink DiscoverySink { get; private set; } - public static void Reset() - { - IsDiscoverTestCalled = false; - } + public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) + { + IsDiscoverTestCalled = true; + Sources = sources; + DiscoveryContext = discoveryContext; + MessageLogger = logger; + DiscoverySink = discoverySink; } - #endregion + public static void Reset() + { + IsDiscoverTestCalled = false; + } } -} + + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryContextTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryContextTests.cs index 88a170084d..74d615e3c8 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryContextTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryContextTests.cs @@ -1,76 +1,73 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Discovery +namespace TestPlatform.CrossPlatEngine.UnitTests.Discovery; + +using System.Collections.Generic; + +using Microsoft.VisualStudio.TestPlatform.Common.Filtering; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class DiscoveryContextTests { - using System.Collections.Generic; + private DiscoveryContext _discoveryContext; - using Microsoft.VisualStudio.TestPlatform.Common.Filtering; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using MSTest.TestFramework.AssertExtensions; + [TestInitialize] + public void TestInit() + { + _discoveryContext = new DiscoveryContext(); + } - [TestClass] - public class DiscoveryContextTests + /// + /// GetTestCaseFilter should return null in case filter expression is null + /// + [TestMethod] + public void GetTestCaseFilterShouldReturnNullIfFilterExpressionIsNull() { - private DiscoveryContext discoveryContext; - - [TestInitialize] - public void TestInit() - { - this.discoveryContext = new DiscoveryContext(); - } - - /// - /// GetTestCaseFilter should return null in case filter expression is null - /// - [TestMethod] - public void GetTestCaseFilterShouldReturnNullIfFilterExpressionIsNull() - { - this.discoveryContext.FilterExpressionWrapper = null; - - Assert.IsNull(this.discoveryContext.GetTestCaseFilter(null, (s) => { return null; })); - } - - /// - /// If only property value passed, consider property key and operation defaults. - /// - [TestMethod] - public void GetTestCaseFilterShouldNotThrowIfPropertyValueOnlyPassed() - { - this.discoveryContext.FilterExpressionWrapper = new FilterExpressionWrapper("Infinity"); - - var filter = this.discoveryContext.GetTestCaseFilter(new List{ "FullyQualifiedName" }, (s) => { return null; }); - - Assert.IsNotNull(filter); - } - - /// - /// Exception should not be thrown in case invalid properties passed in filter expression. - /// - [TestMethod] - public void GetTestCaseFilterShouldNotThrowOnInvalidProperties() - { - this.discoveryContext.FilterExpressionWrapper = new FilterExpressionWrapper("highlyunlikelyproperty=unused"); - - var filter = this.discoveryContext.GetTestCaseFilter(new List { "TestCategory" }, (s) => { return null; }); - - Assert.IsNotNull(filter); - } - - /// - /// GetTestCaseFilter should return correct filter as present in filter expression. - /// - [TestMethod] - public void GetTestCaseFilterShouldReturnTestCaseFilter() - { - this.discoveryContext.FilterExpressionWrapper = new FilterExpressionWrapper("TestCategory=Important"); - - var filter = this.discoveryContext.GetTestCaseFilter(new List { "TestCategory" }, (s) => { return null; }); - - Assert.IsNotNull(filter); - Assert.AreEqual("TestCategory=Important", filter.TestCaseFilterValue); - } + _discoveryContext.FilterExpressionWrapper = null; + + Assert.IsNull(_discoveryContext.GetTestCaseFilter(null, (s) => null)); + } + + /// + /// If only property value passed, consider property key and operation defaults. + /// + [TestMethod] + public void GetTestCaseFilterShouldNotThrowIfPropertyValueOnlyPassed() + { + _discoveryContext.FilterExpressionWrapper = new FilterExpressionWrapper("Infinity"); + + var filter = _discoveryContext.GetTestCaseFilter(new List { "FullyQualifiedName" }, (s) => null); + + Assert.IsNotNull(filter); + } + + /// + /// Exception should not be thrown in case invalid properties passed in filter expression. + /// + [TestMethod] + public void GetTestCaseFilterShouldNotThrowOnInvalidProperties() + { + _discoveryContext.FilterExpressionWrapper = new FilterExpressionWrapper("highlyunlikelyproperty=unused"); + + var filter = _discoveryContext.GetTestCaseFilter(new List { "TestCategory" }, (s) => null); + + Assert.IsNotNull(filter); + } + + /// + /// GetTestCaseFilter should return correct filter as present in filter expression. + /// + [TestMethod] + public void GetTestCaseFilterShouldReturnTestCaseFilter() + { + _discoveryContext.FilterExpressionWrapper = new FilterExpressionWrapper("TestCategory=Important"); + + var filter = _discoveryContext.GetTestCaseFilter(new List { "TestCategory" }, (s) => null); + + Assert.IsNotNull(filter); + Assert.AreEqual("TestCategory=Important", filter.TestCaseFilterValue); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs index d7d956b4be..9f544c1138 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs @@ -1,271 +1,270 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Discovery +namespace TestPlatform.CrossPlatEngine.UnitTests.Discovery; + +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.Logging; +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +using CrossPlatEngineResources = Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources.Resources; + +[TestClass] +public class DiscoveryManagerTests { - using System.Collections.Generic; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Reflection; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - using CrossPlatEngineResources = Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources.Resources; - - [TestClass] - public class DiscoveryManagerTests + private DiscoveryManager _discoveryManager; + private Mock _mockRequestData; + private Mock _mockMetricsCollection; + private TestSessionMessageLogger _sessionLogger; + + [TestInitialize] + public void TestInit() { - private DiscoveryManager discoveryManager; - private Mock mockRequestData; - private Mock mockMetricsCollection; - private TestSessionMessageLogger sessionLogger; + _mockRequestData = new Mock(); + _mockMetricsCollection = new Mock(); + _sessionLogger = TestSessionMessageLogger.Instance; + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(_mockMetricsCollection.Object); + _discoveryManager = new DiscoveryManager(_mockRequestData.Object); + } - [TestInitialize] - public void TestInit() - { - this.mockRequestData = new Mock(); - this.mockMetricsCollection = new Mock(); - this.sessionLogger = TestSessionMessageLogger.Instance; - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(this.mockMetricsCollection.Object); - this.discoveryManager = new DiscoveryManager(this.mockRequestData.Object); - } - - [TestCleanup] - public void TestCleanup() - { - TestDiscoveryExtensionManager.Destroy(); - TestPluginCache.Instance = null; - } + [TestCleanup] + public void TestCleanup() + { + TestDiscoveryExtensionManager.Destroy(); + TestPluginCache.Instance = null; + } - #region Initialize tests + #region Initialize tests - [TestMethod] - public void InitializeShouldUpdateAdditionalExtenions() - { - var mockFileHelper = new Mock(); - var mockLogger = new Mock(); - mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(false); - TestPluginCache.Instance = new TestableTestPluginCache(); + [TestMethod] + public void InitializeShouldUpdateAdditionalExtenions() + { + var mockFileHelper = new Mock(); + var mockLogger = new Mock(); + mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(false); + TestPluginCache.Instance = new TestableTestPluginCache(); - this.discoveryManager.Initialize( - new string[] { typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location }, mockLogger.Object); + _discoveryManager.Initialize( + new string[] { typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location }, mockLogger.Object); - var allDiscoverers = TestDiscoveryExtensionManager.Create().Discoverers; + var allDiscoverers = TestDiscoveryExtensionManager.Create().Discoverers; - Assert.IsNotNull(allDiscoverers); - Assert.IsTrue(allDiscoverers.Any()); - } + Assert.IsNotNull(allDiscoverers); + Assert.IsTrue(allDiscoverers.Any()); + } - #endregion + #endregion - #region DiscoverTests tests + #region DiscoverTests tests - [TestMethod] - public void DiscoverTestsShouldLogIfTheSourceDoesNotExist() - { - var criteria = new DiscoveryCriteria(new List { "imaginary.dll" }, 100, null); - var mockLogger = new Mock(); + [TestMethod] + public void DiscoverTestsShouldLogIfTheSourceDoesNotExist() + { + var criteria = new DiscoveryCriteria(new List { "imaginary.dll" }, 100, null); + var mockLogger = new Mock(); - this.discoveryManager.DiscoverTests(criteria, mockLogger.Object); + _discoveryManager.DiscoverTests(criteria, mockLogger.Object); - var errorMessage = string.Format(CultureInfo.CurrentCulture, "Could not find file {0}.", Path.Combine(Directory.GetCurrentDirectory(), "imaginary.dll")); - mockLogger.Verify( - l => + var errorMessage = string.Format(CultureInfo.CurrentCulture, "Could not find file {0}.", Path.Combine(Directory.GetCurrentDirectory(), "imaginary.dll")); + mockLogger.Verify( + l => l.HandleLogMessage( - Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging.TestMessageLevel.Warning, + TestMessageLevel.Warning, errorMessage), - Times.Once); - } + Times.Once); + } - [TestMethod] - public void DiscoverTestsShouldLogIfTheSourceDoesNotExistIfItHasAPackage() - { - var criteria = new DiscoveryCriteria(new List { "imaginary.exe" }, 100, null); + [TestMethod] + public void DiscoverTestsShouldLogIfTheSourceDoesNotExistIfItHasAPackage() + { + var criteria = new DiscoveryCriteria(new List { "imaginary.exe" }, 100, null); - var packageName = "recipe.AppxRecipe"; + var packageName = "recipe.AppxRecipe"; - var fakeDirectory = Directory.GetDirectoryRoot(typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location); + var fakeDirectory = Directory.GetDirectoryRoot(typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location); - criteria.Package = Path.Combine(fakeDirectory, Path.Combine(packageName)); - var mockLogger = new Mock(); + criteria.Package = Path.Combine(fakeDirectory, Path.Combine(packageName)); + var mockLogger = new Mock(); - this.discoveryManager.DiscoverTests(criteria, mockLogger.Object); + _discoveryManager.DiscoverTests(criteria, mockLogger.Object); - var errorMessage = string.Format(CultureInfo.CurrentCulture, "Could not find file {0}.", Path.Combine(fakeDirectory, "imaginary.exe")); - mockLogger.Verify( - l => + var errorMessage = string.Format(CultureInfo.CurrentCulture, "Could not find file {0}.", Path.Combine(fakeDirectory, "imaginary.exe")); + mockLogger.Verify( + l => l.HandleLogMessage( - Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging.TestMessageLevel.Warning, + TestMessageLevel.Warning, errorMessage), - Times.Once); - } + Times.Once); + } - [TestMethod] - public void DiscoverTestsShouldLogIfThereAreNoValidSources() - { - var sources = new List { "imaginary.dll" }; - var criteria = new DiscoveryCriteria(sources, 100, null); - var mockLogger = new Mock(); + [TestMethod] + public void DiscoverTestsShouldLogIfThereAreNoValidSources() + { + var sources = new List { "imaginary.dll" }; + var criteria = new DiscoveryCriteria(sources, 100, null); + var mockLogger = new Mock(); - this.discoveryManager.DiscoverTests(criteria, mockLogger.Object); + _discoveryManager.DiscoverTests(criteria, mockLogger.Object); - var sourcesString = string.Join(",", sources.ToArray()); - var errorMessage = string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.NoValidSourceFoundForDiscovery, sourcesString); - mockLogger.Verify( - l => + var sourcesString = string.Join(",", sources.ToArray()); + var errorMessage = string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.NoValidSourceFoundForDiscovery, sourcesString); + mockLogger.Verify( + l => l.HandleLogMessage( - Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging.TestMessageLevel.Warning, + TestMessageLevel.Warning, errorMessage), - Times.Once); - } + Times.Once); + } - [TestMethod] - public void DiscoverTestsShouldLogIfTheSameSourceIsSpecifiedTwice() - { - TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); + [TestMethod] + public void DiscoverTestsShouldLogIfTheSameSourceIsSpecifiedTwice() + { + TestPluginCacheHelper.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); - var sources = new List - { - typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location, - typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location - }; + var sources = new List + { + typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location, + typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location + }; - var criteria = new DiscoveryCriteria(sources, 100, null); - var mockLogger = new Mock(); + var criteria = new DiscoveryCriteria(sources, 100, null); + var mockLogger = new Mock(); - this.discoveryManager.DiscoverTests(criteria, mockLogger.Object); + _discoveryManager.DiscoverTests(criteria, mockLogger.Object); - var errorMessage = string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.DuplicateSource, sources[0]); - mockLogger.Verify( - l => + var errorMessage = string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.DuplicateSource, sources[0]); + mockLogger.Verify( + l => l.HandleLogMessage( - Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging.TestMessageLevel.Warning, + TestMessageLevel.Warning, errorMessage), - Times.Once); - } + Times.Once); + } - [TestMethod] - public void DiscoverTestsShouldDiscoverTestsInTheSpecifiedSource() - { - TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); + [TestMethod] + public void DiscoverTestsShouldDiscoverTestsInTheSpecifiedSource() + { + TestPluginCacheHelper.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); - var sources = new List - { - typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location - }; + var sources = new List + { + typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location + }; - var criteria = new DiscoveryCriteria(sources, 1, null); - var mockLogger = new Mock(); + var criteria = new DiscoveryCriteria(sources, 1, null); + var mockLogger = new Mock(); - this.discoveryManager.DiscoverTests(criteria, mockLogger.Object); + _discoveryManager.DiscoverTests(criteria, mockLogger.Object); - // Assert that the tests are passed on via the handletestruncomplete event. - mockLogger.Verify(l => l.HandleDiscoveryComplete(It.IsAny(), It.IsAny>()), Times.Once); - } + // Assert that the tests are passed on via the handletestruncomplete event. + mockLogger.Verify(l => l.HandleDiscoveryComplete(It.IsAny(), It.IsAny>()), Times.Once); + } - [TestMethod] - public void DiscoverTestsShouldSendMetricsOnDiscoveryComplete() - { - var metricsCollector = new MetricsCollection(); - metricsCollector.Add("DummyMessage", "DummyValue"); + [TestMethod] + public void DiscoverTestsShouldSendMetricsOnDiscoveryComplete() + { + var metricsCollector = new MetricsCollection(); + metricsCollector.Add("DummyMessage", "DummyValue"); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(metricsCollector); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(metricsCollector); - DiscoveryCompleteEventArgs receivedDiscoveryCompleteEventArgs = null; + DiscoveryCompleteEventArgs receivedDiscoveryCompleteEventArgs = null; - TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); + TestPluginCacheHelper.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); - var sources = new List - { - typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location - }; + var sources = new List + { + typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location + }; - var mockLogger = new Mock(); - var criteria = new DiscoveryCriteria(sources, 1, null); + var mockLogger = new Mock(); + var criteria = new DiscoveryCriteria(sources, 1, null); - mockLogger.Setup(ml => ml.HandleDiscoveryComplete(It.IsAny(), It.IsAny>())) - .Callback( - (DiscoveryCompleteEventArgs complete, - IEnumerable tests) => - { - receivedDiscoveryCompleteEventArgs = complete; - }); + mockLogger.Setup(ml => ml.HandleDiscoveryComplete(It.IsAny(), It.IsAny>())) + .Callback( + (DiscoveryCompleteEventArgs complete, + IEnumerable tests) => receivedDiscoveryCompleteEventArgs = complete); - // Act. - this.discoveryManager.DiscoverTests(criteria, mockLogger.Object); + // Act. + _discoveryManager.DiscoverTests(criteria, mockLogger.Object); - // Assert - Assert.IsNotNull(receivedDiscoveryCompleteEventArgs.Metrics); - Assert.IsTrue(receivedDiscoveryCompleteEventArgs.Metrics.Any()); - Assert.IsTrue(receivedDiscoveryCompleteEventArgs.Metrics.ContainsKey("DummyMessage")); - } + // Assert + Assert.IsNotNull(receivedDiscoveryCompleteEventArgs.Metrics); + Assert.IsTrue(receivedDiscoveryCompleteEventArgs.Metrics.Any()); + Assert.IsTrue(receivedDiscoveryCompleteEventArgs.Metrics.ContainsKey("DummyMessage")); + } - [TestMethod] - public void DiscoverTestsShouldCollectMetrics() + [TestMethod] + public void DiscoverTestsShouldCollectMetrics() + { + var mockMetricsCollector = new Mock(); + var dict = new Dictionary { - var mockMetricsCollector = new Mock(); - var dict = new Dictionary(); - dict.Add("DummyMessage", "DummyValue"); + { "DummyMessage", "DummyValue" } + }; - mockMetricsCollector.Setup(mc => mc.Metrics).Returns(dict); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollector.Object); + mockMetricsCollector.Setup(mc => mc.Metrics).Returns(dict); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollector.Object); - TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); + TestPluginCacheHelper.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); - var sources = new List - { - typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location - }; - - var mockLogger = new Mock(); - var criteria = new DiscoveryCriteria(sources, 1, null); + var sources = new List + { + typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location + }; - // Act. - this.discoveryManager.DiscoverTests(criteria, mockLogger.Object); + var mockLogger = new Mock(); + var criteria = new DiscoveryCriteria(sources, 1, null); - // Verify. - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.DiscoveryState, It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TotalTestsDiscovered, It.IsAny()), Times.Once); - } + // Act. + _discoveryManager.DiscoverTests(criteria, mockLogger.Object); - [TestMethod] - public void DiscoveryInitializeShouldVerifyWarningMessageIfAdapterFailedToLoad() - { - var assemblyLocation = typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location; - var mockLogger = new Mock(); - TestPluginCacheHelper.SetupMockExtensions( - new string[] { assemblyLocation }, - () => { }); + // Verify. + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.DiscoveryState, It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TotalTestsDiscovered, It.IsAny()), Times.Once); + } - //Act - this.discoveryManager.Initialize(new List { assemblyLocation }, mockLogger.Object); + [TestMethod] + public void DiscoveryInitializeShouldVerifyWarningMessageIfAdapterFailedToLoad() + { + var assemblyLocation = typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location; + var mockLogger = new Mock(); + TestPluginCacheHelper.SetupMockExtensions( + new string[] { assemblyLocation }, + () => { }); - //when handler instance returns warning - sessionLogger.SendMessage(TestMessageLevel.Warning, "verify that the HandleLogMessage method getting invoked at least once"); + //Act + _discoveryManager.Initialize(new List { assemblyLocation }, mockLogger.Object); - // Verify. - mockLogger.Verify(rd => rd.HandleLogMessage(TestMessageLevel.Warning, "verify that the HandleLogMessage method getting invoked at least once"), Times.Once); - } + //when handler instance returns warning + _sessionLogger.SendMessage(TestMessageLevel.Warning, "verify that the HandleLogMessage method getting invoked at least once"); - #endregion + // Verify. + mockLogger.Verify(rd => rd.HandleLogMessage(TestMessageLevel.Warning, "verify that the HandleLogMessage method getting invoked at least once"), Times.Once); } -} + + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryResultCacheTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryResultCacheTests.cs index 06b907f708..3979cbd537 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryResultCacheTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryResultCacheTests.cs @@ -1,124 +1,122 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Discovery +namespace TestPlatform.CrossPlatEngine.UnitTests.Discovery; + +using System; + +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +[TestClass] +public class DiscoveryResultCacheTests { - using System; - - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery; - using System.Collections; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; - - [TestClass] - public class DiscoveryResultCacheTests + [TestMethod] + public void DiscoveryResultCacheConstructorShouldInitializeDiscoveredTestsList() + { + var cache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { }); + + Assert.IsNotNull(cache.Tests); + Assert.AreEqual(0, cache.Tests.Count); + } + + [TestMethod] + public void DiscoveryResultCacheConstructorShouldInitializeTotalDiscoveredTests() + { + var cache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { }); + + Assert.AreEqual(0, cache.TotalDiscoveredTests); + } + + [TestMethod] + public void AddTestShouldAddATestCaseToTheList() + { + var cache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { }); + + var testCase = new TestCase("A.C.M", new Uri("executor://unittest"), "A"); + cache.AddTest(testCase); + + Assert.AreEqual(1, cache.Tests.Count); + Assert.AreEqual(testCase, cache.Tests[0]); + } + + [TestMethod] + public void AddTestShouldIncreaseDiscoveredTestsCount() + { + var cache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { }); + + var testCase = new TestCase("A.C.M", new Uri("executor://unittest"), "A"); + cache.AddTest(testCase); + + Assert.AreEqual(1, cache.TotalDiscoveredTests); + } + + [TestMethod] + public void AddTestShouldReportTestCasesIfMaxCacheSizeIsMet() + { + ICollection reportedTestCases = null; + var cache = new DiscoveryResultCache(2, TimeSpan.FromHours(1), (tests) => reportedTestCases = tests); + + var testCase1 = new TestCase("A.C.M", new Uri("executor://unittest"), "A"); + var testCase2 = new TestCase("A.C.M2", new Uri("executor://unittest"), "A"); + cache.AddTest(testCase1); + cache.AddTest(testCase2); + + Assert.IsNotNull(reportedTestCases); + Assert.AreEqual(2, reportedTestCases.Count); + CollectionAssert.AreEqual(new List { testCase1, testCase2 }, reportedTestCases.ToList()); + } + + [TestMethod] + public void AddTestShouldResetTestListOnceCacheSizeIsMet() + { + var cache = new DiscoveryResultCache(2, TimeSpan.FromHours(1), (tests) => { }); + + var testCase1 = new TestCase("A.C.M", new Uri("executor://unittest"), "A"); + var testCase2 = new TestCase("A.C.M2", new Uri("executor://unittest"), "A"); + cache.AddTest(testCase1); + cache.AddTest(testCase2); + + Assert.IsNotNull(cache.Tests); + Assert.AreEqual(0, cache.Tests.Count); + + // Validate that total tests is no reset though. + Assert.AreEqual(2, cache.TotalDiscoveredTests); + } + + [TestMethod] + public void AddTestShouldReportTestCasesIfCacheTimeoutIsMet() + { + ICollection reportedTestCases = null; + var cache = new DiscoveryResultCache(100, TimeSpan.FromMilliseconds(10), (tests) => reportedTestCases = tests); + + var testCase = new TestCase("A.C.M", new Uri("executor://unittest"), "A"); + Task.Delay(20).Wait(); + cache.AddTest(testCase); + + Assert.IsNotNull(reportedTestCases); + Assert.AreEqual(1, reportedTestCases.Count); + Assert.AreEqual(testCase, reportedTestCases.ToArray()[0]); + } + + [TestMethod] + public void AddTestShouldResetTestListIfCacheTimeoutIsMet() { - [TestMethod] - public void DiscoveryResultCacheConstructorShouldInitializeDiscoveredTestsList() - { - var cache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { }); - - Assert.IsNotNull(cache.Tests); - Assert.AreEqual(0, cache.Tests.Count); - } - - [TestMethod] - public void DiscoveryResultCacheConstructorShouldInitializeTotalDiscoveredTests() - { - var cache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { }); - - Assert.AreEqual(0, cache.TotalDiscoveredTests); - } - - [TestMethod] - public void AddTestShouldAddATestCaseToTheList() - { - var cache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { }); - - var testCase = new TestCase("A.C.M", new Uri("executor://unittest"), "A"); - cache.AddTest(testCase); - - Assert.AreEqual(1, cache.Tests.Count); - Assert.AreEqual(testCase, cache.Tests[0]); - } - - [TestMethod] - public void AddTestShouldIncreaseDiscoveredTestsCount() - { - var cache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { }); - - var testCase = new TestCase("A.C.M", new Uri("executor://unittest"), "A"); - cache.AddTest(testCase); - - Assert.AreEqual(1, cache.TotalDiscoveredTests); - } - - [TestMethod] - public void AddTestShouldReportTestCasesIfMaxCacheSizeIsMet() - { - ICollection reportedTestCases = null; - var cache = new DiscoveryResultCache(2, TimeSpan.FromHours(1), (tests) => { reportedTestCases = tests; }); - - var testCase1 = new TestCase("A.C.M", new Uri("executor://unittest"), "A"); - var testCase2 = new TestCase("A.C.M2", new Uri("executor://unittest"), "A"); - cache.AddTest(testCase1); - cache.AddTest(testCase2); - - Assert.IsNotNull(reportedTestCases); - Assert.AreEqual(2, reportedTestCases.Count); - CollectionAssert.AreEqual(new List { testCase1, testCase2 }, reportedTestCases.ToList()); - } - - [TestMethod] - public void AddTestShouldResetTestListOnceCacheSizeIsMet() - { - var cache = new DiscoveryResultCache(2, TimeSpan.FromHours(1), (tests) => { }); - - var testCase1 = new TestCase("A.C.M", new Uri("executor://unittest"), "A"); - var testCase2 = new TestCase("A.C.M2", new Uri("executor://unittest"), "A"); - cache.AddTest(testCase1); - cache.AddTest(testCase2); - - Assert.IsNotNull(cache.Tests); - Assert.AreEqual(0, cache.Tests.Count); - - // Validate that total tests is no reset though. - Assert.AreEqual(2, cache.TotalDiscoveredTests); - } - - [TestMethod] - public void AddTestShouldReportTestCasesIfCacheTimeoutIsMet() - { - ICollection reportedTestCases = null; - var cache = new DiscoveryResultCache(100, TimeSpan.FromMilliseconds(10), (tests) => { reportedTestCases = tests; }); - - var testCase = new TestCase("A.C.M", new Uri("executor://unittest"), "A"); - Task.Delay(20).Wait(); - cache.AddTest(testCase); - - Assert.IsNotNull(reportedTestCases); - Assert.AreEqual(1, reportedTestCases.Count); - Assert.AreEqual(testCase, reportedTestCases.ToArray()[0]); - } - - [TestMethod] - public void AddTestShouldResetTestListIfCacheTimeoutIsMet() - { - ICollection reportedTestCases = null; - var cache = new DiscoveryResultCache(100, TimeSpan.FromMilliseconds(10), (tests) => { reportedTestCases = tests; }); - - var testCase = new TestCase("A.C.M", new Uri("executor://unittest"), "A"); - Task.Delay(20).Wait(); - cache.AddTest(testCase); - - Assert.IsNotNull(cache.Tests); - Assert.AreEqual(0, cache.Tests.Count); - - // Validate that total tests is no reset though. - Assert.AreEqual(1, cache.TotalDiscoveredTests); - } + ICollection reportedTestCases = null; + var cache = new DiscoveryResultCache(100, TimeSpan.FromMilliseconds(10), (tests) => reportedTestCases = tests); + + var testCase = new TestCase("A.C.M", new Uri("executor://unittest"), "A"); + Task.Delay(20).Wait(); + cache.AddTest(testCase); + + Assert.IsNotNull(cache.Tests); + Assert.AreEqual(0, cache.Tests.Count); + + // Validate that total tests is no reset though. + Assert.AreEqual(1, cache.TotalDiscoveredTests); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/TestCaseDiscoverySinkTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/TestCaseDiscoverySinkTests.cs index 417977fc22..61062e0aa4 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/TestCaseDiscoverySinkTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/TestCaseDiscoverySinkTests.cs @@ -1,44 +1,41 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Discovery -{ - using System; +namespace TestPlatform.CrossPlatEngine.UnitTests.Discovery; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; - using Moq; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestClass] - public class TestCaseDiscoverySinkTests +[TestClass] +public class TestCaseDiscoverySinkTests +{ + [TestMethod] + public void SendTestCaseShouldNotThrowIfCacheIsNull() { - [TestMethod] - public void SendTestCaseShouldNotThrowIfCacheIsNull() - { - var sink = new TestCaseDiscoverySink(null); + var sink = new TestCaseDiscoverySink(null); - var testCase = new TestCase("A.C.M", new Uri("executor://unittest"), "A"); + var testCase = new TestCase("A.C.M", new Uri("executor://unittest"), "A"); - // This should not throw. - sink.SendTestCase(testCase); - } + // This should not throw. + sink.SendTestCase(testCase); + } - [TestMethod] - public void SendTestCaseShouldSendTestCasesToCache() - { - var cache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { }); - var sink = new TestCaseDiscoverySink(cache); + [TestMethod] + public void SendTestCaseShouldSendTestCasesToCache() + { + var cache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { }); + var sink = new TestCaseDiscoverySink(cache); - var testCase = new TestCase("A.C.M", new Uri("executor://unittest"), "A"); + var testCase = new TestCase("A.C.M", new Uri("executor://unittest"), "A"); - sink.SendTestCase(testCase); + sink.SendTestCase(testCase); - // Assert that the cache has the test case. - Assert.IsNotNull(cache.Tests); - Assert.AreEqual(1, cache.Tests.Count); - Assert.AreEqual(testCase, cache.Tests[0]); - } + // Assert that the cache has the test case. + Assert.IsNotNull(cache.Tests); + Assert.AreEqual(1, cache.Tests.Count); + Assert.AreEqual(testCase, cache.Tests[0]); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/EventHandlers/TestRequestHandlerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/EventHandlers/TestRequestHandlerTests.cs index a85aec8b51..c86dbebe59 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/EventHandlers/TestRequestHandlerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/EventHandlers/TestRequestHandlerTests.cs @@ -3,541 +3,538 @@ using System; using System.Net.Sockets; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; using Microsoft.VisualStudio.TestPlatform.Utilities; -namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities +namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; + +using Interfaces; + +using TestTools.UnitTesting; +using Moq; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; +using ObjectModel; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; + +[TestClass] +public class TestRequestHandlerTests { - using System.IO; - - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using System.Threading.Tasks; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - - [TestClass] - public class TestRequestHandlerTests - { - private readonly Mock mockCommunicationClient; - private readonly Mock mockCommunicationEndpointFactory; - private readonly Mock mockChannel; - private readonly Mock mockTestHostManagerFactory; - private readonly Mock mockDiscoveryManager; - private readonly Mock mockExecutionManager; - - private readonly JsonDataSerializer dataSerializer; - private ITestRequestHandler requestHandler; - private readonly TestHostConnectionInfo testHostConnectionInfo; - private readonly JobQueue jobQueue; - - public TestRequestHandlerTests() - { - this.mockCommunicationClient = new Mock(); - this.mockCommunicationEndpointFactory = new Mock(); - this.mockChannel = new Mock(); - this.dataSerializer = JsonDataSerializer.Instance; - this.testHostConnectionInfo = new TestHostConnectionInfo - { - Endpoint = IPAddress.Loopback + ":123", - Role = ConnectionRole.Client - }; - - this.jobQueue = new JobQueue( - action => { action(); }, - "TestHostOperationQueue", - 500, - 25000000, - true, - message => EqtTrace.Error(message)); - - // Setup mock discovery and execution managers - this.mockTestHostManagerFactory = new Mock(); - this.mockDiscoveryManager = new Mock(); - this.mockExecutionManager = new Mock(); - this.mockTestHostManagerFactory.Setup(mf => mf.GetDiscoveryManager()).Returns(this.mockDiscoveryManager.Object); - this.mockTestHostManagerFactory.Setup(mf => mf.GetExecutionManager()).Returns(this.mockExecutionManager.Object); - this.mockCommunicationEndpointFactory.Setup(f => f.Create(ConnectionRole.Client)) - .Returns(this.mockCommunicationClient.Object); - - this.requestHandler = new TestableTestRequestHandler( - this.testHostConnectionInfo, - this.mockCommunicationEndpointFactory.Object, - JsonDataSerializer.Instance, - jobQueue); - this.requestHandler.InitializeCommunication(); - this.mockCommunicationClient.Raise(e => e.Connected += null, new ConnectedEventArgs(this.mockChannel.Object)); - } + private readonly Mock _mockCommunicationClient; + private readonly Mock _mockCommunicationEndpointFactory; + private readonly Mock _mockChannel; + private readonly Mock _mockTestHostManagerFactory; + private readonly Mock _mockDiscoveryManager; + private readonly Mock _mockExecutionManager; + + private readonly JsonDataSerializer _dataSerializer; + private ITestRequestHandler _requestHandler; + private readonly TestHostConnectionInfo _testHostConnectionInfo; + private readonly JobQueue _jobQueue; + + public TestRequestHandlerTests() + { + _mockCommunicationClient = new Mock(); + _mockCommunicationEndpointFactory = new Mock(); + _mockChannel = new Mock(); + _dataSerializer = JsonDataSerializer.Instance; + _testHostConnectionInfo = new TestHostConnectionInfo + { + Endpoint = IPAddress.Loopback + ":123", + Role = ConnectionRole.Client + }; + + _jobQueue = new JobQueue( + action => action(), + "TestHostOperationQueue", + 500, + 25000000, + true, + message => EqtTrace.Error(message)); + + // Setup mock discovery and execution managers + _mockTestHostManagerFactory = new Mock(); + _mockDiscoveryManager = new Mock(); + _mockExecutionManager = new Mock(); + _mockTestHostManagerFactory.Setup(mf => mf.GetDiscoveryManager()).Returns(_mockDiscoveryManager.Object); + _mockTestHostManagerFactory.Setup(mf => mf.GetExecutionManager()).Returns(_mockExecutionManager.Object); + _mockCommunicationEndpointFactory.Setup(f => f.Create(ConnectionRole.Client)) + .Returns(_mockCommunicationClient.Object); + + _requestHandler = new TestableTestRequestHandler( + _testHostConnectionInfo, + _mockCommunicationEndpointFactory.Object, + JsonDataSerializer.Instance, + _jobQueue); + _requestHandler.InitializeCommunication(); + _mockCommunicationClient.Raise(e => e.Connected += null, new ConnectedEventArgs(_mockChannel.Object)); + } - [TestMethod] - public void InitializeCommunicationShouldConnectToServerAsynchronously() - { - this.mockCommunicationClient.Verify(c => c.Start(this.testHostConnectionInfo.Endpoint), Times.Once); - } + [TestMethod] + public void InitializeCommunicationShouldConnectToServerAsynchronously() + { + _mockCommunicationClient.Verify(c => c.Start(_testHostConnectionInfo.Endpoint), Times.Once); + } - [TestMethod] - [TestCategory("Windows")] - public void InitializeCommunicationShouldThrowIfServerIsNotAccessible() - { - var connectionInfo = new TestHostConnectionInfo - { - Endpoint = IPAddress.Loopback + ":123", - Role = ConnectionRole.Client - }; - var socketClient = new SocketClient(); - socketClient.Connected += (sender, connectedEventArgs) => - { - Assert.IsFalse(connectedEventArgs.Connected); - Assert.AreEqual(typeof(SocketException), connectedEventArgs.Fault.InnerException.GetType()); - }; - this.mockCommunicationEndpointFactory.Setup(f => f.Create(ConnectionRole.Client)) - .Returns(socketClient); - var rh = new TestableTestRequestHandler(connectionInfo, this.mockCommunicationEndpointFactory.Object, this.dataSerializer, this.jobQueue); - - rh.InitializeCommunication(); - this.requestHandler.WaitForRequestSenderConnection(1000); - } + [TestMethod] + [TestCategory("Windows")] + public void InitializeCommunicationShouldThrowIfServerIsNotAccessible() + { + var connectionInfo = new TestHostConnectionInfo + { + Endpoint = IPAddress.Loopback + ":123", + Role = ConnectionRole.Client + }; + var socketClient = new SocketClient(); + socketClient.Connected += (sender, connectedEventArgs) => + { + Assert.IsFalse(connectedEventArgs.Connected); + Assert.AreEqual(typeof(SocketException), connectedEventArgs.Fault.InnerException.GetType()); + }; + _mockCommunicationEndpointFactory.Setup(f => f.Create(ConnectionRole.Client)) + .Returns(socketClient); + var rh = new TestableTestRequestHandler(connectionInfo, _mockCommunicationEndpointFactory.Object, _dataSerializer, _jobQueue); + + rh.InitializeCommunication(); + _requestHandler.WaitForRequestSenderConnection(1000); + } - [TestMethod] - public void WaitForRequestSenderConnectionShouldWaitUntilConnectionIsSetup() - { - Assert.IsTrue(this.requestHandler.WaitForRequestSenderConnection(1000)); - } + [TestMethod] + public void WaitForRequestSenderConnectionShouldWaitUntilConnectionIsSetup() + { + Assert.IsTrue(_requestHandler.WaitForRequestSenderConnection(1000)); + } - [TestMethod] - public void WaitForRequestSenderConnectionShouldReturnFalseIfConnectionSetupTimesout() - { - this.requestHandler = new TestableTestRequestHandler( - this.testHostConnectionInfo, - this.mockCommunicationEndpointFactory.Object, - JsonDataSerializer.Instance, - jobQueue); - this.requestHandler.InitializeCommunication(); - - Assert.IsFalse(this.requestHandler.WaitForRequestSenderConnection(1)); - } + [TestMethod] + public void WaitForRequestSenderConnectionShouldReturnFalseIfConnectionSetupTimesout() + { + _requestHandler = new TestableTestRequestHandler( + _testHostConnectionInfo, + _mockCommunicationEndpointFactory.Object, + JsonDataSerializer.Instance, + _jobQueue); + _requestHandler.InitializeCommunication(); + + Assert.IsFalse(_requestHandler.WaitForRequestSenderConnection(1)); + } - [TestMethod] - public void ProcessRequestsShouldProcessMessagesUntilSessionCompleted() - { - var task = this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); + [TestMethod] + public void ProcessRequestsShouldProcessMessagesUntilSessionCompleted() + { + var task = ProcessRequestsAsync(_mockTestHostManagerFactory.Object); - this.SendSessionEnd(); - Assert.IsTrue(task.Wait(2000)); - } + SendSessionEnd(); + Assert.IsTrue(task.Wait(2000)); + } - #region Version Check Protocol + #region Version Check Protocol - [TestMethod] - public void ProcessRequestsVersionCheckShouldAckMinimumOfGivenAndHighestSupportedVersion() - { - var message = new Message { MessageType = MessageType.VersionCheck, Payload = 1 }; - this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); + [TestMethod] + public void ProcessRequestsVersionCheckShouldAckMinimumOfGivenAndHighestSupportedVersion() + { + var message = new Message { MessageType = MessageType.VersionCheck, Payload = 1 }; + ProcessRequestsAsync(_mockTestHostManagerFactory.Object); - this.SendMessageOnChannel(message); + SendMessageOnChannel(message); - this.VerifyResponseMessageEquals(this.Serialize(message)); - this.SendSessionEnd(); - } + VerifyResponseMessageEquals(Serialize(message)); + SendSessionEnd(); + } - [TestMethod] - public void ProcessRequestsVersionCheckShouldLogErrorIfDiagnosticsEnableFails() + [TestMethod] + public void ProcessRequestsVersionCheckShouldLogErrorIfDiagnosticsEnableFails() + { + if (!string.IsNullOrEmpty(EqtTrace.LogFile)) { - if (!string.IsNullOrEmpty(EqtTrace.LogFile)) - { - // This test is no-op if diagnostics session is enabled - return; - } - EqtTrace.ErrorOnInitialization = "non-existent-error"; - var message = new Message { MessageType = MessageType.VersionCheck, Payload = 1 }; - this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); - - this.SendMessageOnChannel(message); - - this.VerifyResponseMessageContains(EqtTrace.ErrorOnInitialization); - this.SendSessionEnd(); + // This test is no-op if diagnostics session is enabled + return; } + EqtTrace.ErrorOnInitialization = "non-existent-error"; + var message = new Message { MessageType = MessageType.VersionCheck, Payload = 1 }; + ProcessRequestsAsync(_mockTestHostManagerFactory.Object); - #endregion + SendMessageOnChannel(message); - #region Discovery Protocol + VerifyResponseMessageContains(EqtTrace.ErrorOnInitialization); + SendSessionEnd(); + } - [TestMethod] - public void ProcessRequestsDiscoveryInitializeShouldSetExtensionPaths() - { - var message = this.dataSerializer.SerializePayload(MessageType.DiscoveryInitialize, new[] { "testadapter.dll" }); - this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); + #endregion - this.SendMessageOnChannel(message); - this.jobQueue.Flush(); + #region Discovery Protocol - this.mockDiscoveryManager.Verify(d => d.Initialize(It.Is>(paths => paths.Any(p => p.Equals("testadapter.dll"))), It.IsAny())); - this.SendSessionEnd(); - } + [TestMethod] + public void ProcessRequestsDiscoveryInitializeShouldSetExtensionPaths() + { + var message = _dataSerializer.SerializePayload(MessageType.DiscoveryInitialize, new[] { "testadapter.dll" }); + ProcessRequestsAsync(_mockTestHostManagerFactory.Object); - [TestMethod] - public void ProcessRequestsDiscoveryStartShouldStartDiscoveryWithGivenCriteria() - { - var message = this.dataSerializer.SerializePayload(MessageType.StartDiscovery, new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty)); - this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); + SendMessageOnChannel(message); + _jobQueue.Flush(); - this.SendMessageOnChannel(message); - this.jobQueue.Flush(); + _mockDiscoveryManager.Verify(d => d.Initialize(It.Is>(paths => paths.Any(p => p.Equals("testadapter.dll"))), It.IsAny())); + SendSessionEnd(); + } - this.mockDiscoveryManager.Verify(d => d.DiscoverTests(It.Is(dc => dc.Sources.Contains("test.dll")), It.IsAny())); - this.SendSessionEnd(); - } + [TestMethod] + public void ProcessRequestsDiscoveryStartShouldStartDiscoveryWithGivenCriteria() + { + var message = _dataSerializer.SerializePayload(MessageType.StartDiscovery, new DiscoveryCriteria(new[] { "test.dll" }, 1, string.Empty)); + ProcessRequestsAsync(_mockTestHostManagerFactory.Object); - [TestMethod] - public void DiscoveryCompleteShouldSendDiscoveryCompletePayloadOnChannel() - { - var discoveryComplete = new DiscoveryCompletePayload { TotalTests = 1, LastDiscoveredTests = Enumerable.Empty(), IsAborted = false }; - var message = this.dataSerializer.SerializePayload(MessageType.DiscoveryComplete, discoveryComplete); + SendMessageOnChannel(message); + _jobQueue.Flush(); - this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); + _mockDiscoveryManager.Verify(d => d.DiscoverTests(It.Is(dc => dc.Sources.Contains("test.dll")), It.IsAny())); + SendSessionEnd(); + } - this.requestHandler.DiscoveryComplete(new DiscoveryCompleteEventArgs(discoveryComplete.TotalTests, discoveryComplete.IsAborted), discoveryComplete.LastDiscoveredTests); + [TestMethod] + public void DiscoveryCompleteShouldSendDiscoveryCompletePayloadOnChannel() + { + var discoveryComplete = new DiscoveryCompletePayload { TotalTests = 1, LastDiscoveredTests = Enumerable.Empty(), IsAborted = false }; + var message = _dataSerializer.SerializePayload(MessageType.DiscoveryComplete, discoveryComplete); - this.VerifyResponseMessageEquals(message); - this.SendSessionEnd(); - } + ProcessRequestsAsync(_mockTestHostManagerFactory.Object); - #endregion + _requestHandler.DiscoveryComplete(new DiscoveryCompleteEventArgs(discoveryComplete.TotalTests, discoveryComplete.IsAborted), discoveryComplete.LastDiscoveredTests); - #region Execution Protocol + VerifyResponseMessageEquals(message); + SendSessionEnd(); + } - [TestMethod] - public void ProcessRequestsExecutionInitializeShouldSetExtensionPaths() - { - var message = this.dataSerializer.SerializePayload(MessageType.ExecutionInitialize, new[] { "testadapter.dll" }); - this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); + #endregion - this.SendMessageOnChannel(message); - this.jobQueue.Flush(); + #region Execution Protocol - this.mockExecutionManager.Verify(e => e.Initialize(It.Is>(paths => paths.Any(p => p.Equals("testadapter.dll"))), It.IsAny())); - this.SendSessionEnd(); - } + [TestMethod] + public void ProcessRequestsExecutionInitializeShouldSetExtensionPaths() + { + var message = _dataSerializer.SerializePayload(MessageType.ExecutionInitialize, new[] { "testadapter.dll" }); + ProcessRequestsAsync(_mockTestHostManagerFactory.Object); - [TestMethod] - public void ProcessRequestsExecutionStartShouldStartExecutionWithGivenSources() - { - var asm = new Dictionary>(); - asm["mstestv2"] = new[] {"test1.dll", "test2.dll"}; - var testRunCriteriaWithSources = new TestRunCriteriaWithSources(asm, "runsettings", null, null); - var message = this.dataSerializer.SerializePayload(MessageType.StartTestExecutionWithSources, testRunCriteriaWithSources); - - this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); - - this.SendMessageOnChannel(message); - this.jobQueue.Flush(); - - mockExecutionManager.Verify(e => - e.StartTestRun( - It.Is>>(d => d.ContainsKey("mstestv2")), It.IsAny(), - It.IsAny(), - It.IsAny(), It.IsAny(), - It.IsAny())); - this.SendSessionEnd(); - } + SendMessageOnChannel(message); + _jobQueue.Flush(); - [TestMethod] - public void ProcessRequestsExecutionStartShouldStartExecutionWithGivenTests() - { - var t1 = new TestCase("N.C.M1", new Uri("executor://mstest/v2"), "test1.dll"); - var t2 = new TestCase("N.C.M2", new Uri("executor://mstest/v2"), "test1.dll"); - var testCases = new [] { t1, t2 }; - var testRunCriteriaWithTests = new TestRunCriteriaWithTests(testCases, "runsettings", null, null); - var message = this.dataSerializer.SerializePayload(MessageType.StartTestExecutionWithTests, testRunCriteriaWithTests); - - this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); - - this.SendMessageOnChannel(message); - this.jobQueue.Flush(); - - mockExecutionManager.Verify(e => - e.StartTestRun( - It.Is>(tcs => - tcs.Any(t => t.FullyQualifiedName.Equals("N.C.M1")) && - tcs.Any(t => t.FullyQualifiedName.Equals("N.C.M2"))), It.IsAny(), - It.IsAny(), - It.IsAny(), It.IsAny(), - It.IsAny())); - this.SendSessionEnd(); - } + _mockExecutionManager.Verify(e => e.Initialize(It.Is>(paths => paths.Any(p => p.Equals("testadapter.dll"))), It.IsAny())); + SendSessionEnd(); + } - [TestMethod] - public void ProcessRequestsExecutionCancelShouldCancelTestRun() + [TestMethod] + public void ProcessRequestsExecutionStartShouldStartExecutionWithGivenSources() + { + var asm = new Dictionary> { - var message = this.dataSerializer.SerializePayload(MessageType.CancelTestRun, string.Empty); + ["mstestv2"] = new[] { "test1.dll", "test2.dll" } + }; + var testRunCriteriaWithSources = new TestRunCriteriaWithSources(asm, "runsettings", null, null); + var message = _dataSerializer.SerializePayload(MessageType.StartTestExecutionWithSources, testRunCriteriaWithSources); - this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); - this.SendMessageOnChannel(message); + ProcessRequestsAsync(_mockTestHostManagerFactory.Object); - mockExecutionManager.Verify(e => e.Cancel(It.IsAny())); - this.SendSessionEnd(); - } + SendMessageOnChannel(message); + _jobQueue.Flush(); - [TestMethod] - public void ProcessRequestsExecutionLaunchAdapterProcessWithDebuggerShouldSendAckMessage() - { - var message = this.dataSerializer.SerializePayload(MessageType.LaunchAdapterProcessWithDebuggerAttachedCallback, string.Empty); + _mockExecutionManager.Verify(e => + e.StartTestRun( + It.Is>>(d => d.ContainsKey("mstestv2")), It.IsAny(), + It.IsAny(), + It.IsAny(), It.IsAny(), + It.IsAny())); + SendSessionEnd(); + } - this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); - this.SendMessageOnChannel(message); - this.jobQueue.Flush(); + [TestMethod] + public void ProcessRequestsExecutionStartShouldStartExecutionWithGivenTests() + { + var t1 = new TestCase("N.C.M1", new Uri("executor://mstest/v2"), "test1.dll"); + var t2 = new TestCase("N.C.M2", new Uri("executor://mstest/v2"), "test1.dll"); + var testCases = new[] { t1, t2 }; + var testRunCriteriaWithTests = new TestRunCriteriaWithTests(testCases, "runsettings", null, null); + var message = _dataSerializer.SerializePayload(MessageType.StartTestExecutionWithTests, testRunCriteriaWithTests); + + ProcessRequestsAsync(_mockTestHostManagerFactory.Object); + + SendMessageOnChannel(message); + _jobQueue.Flush(); + + _mockExecutionManager.Verify(e => + e.StartTestRun( + It.Is>(tcs => + tcs.Any(t => t.FullyQualifiedName.Equals("N.C.M1")) && + tcs.Any(t => t.FullyQualifiedName.Equals("N.C.M2"))), It.IsAny(), + It.IsAny(), + It.IsAny(), It.IsAny(), + It.IsAny())); + SendSessionEnd(); + } - this.SendSessionEnd(); - } + [TestMethod] + public void ProcessRequestsExecutionCancelShouldCancelTestRun() + { + var message = _dataSerializer.SerializePayload(MessageType.CancelTestRun, string.Empty); - [TestMethod] - public void ProcessRequestsExecutionAbortShouldStopTestRun() - { - var message = this.dataSerializer.SerializePayload(MessageType.AbortTestRun, string.Empty); + ProcessRequestsAsync(_mockTestHostManagerFactory.Object); + SendMessageOnChannel(message); - this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); - this.SendMessageOnChannel(message); + _mockExecutionManager.Verify(e => e.Cancel(It.IsAny())); + SendSessionEnd(); + } - mockExecutionManager.Verify(e => e.Abort(It.IsAny())); - this.SendSessionEnd(); - } + [TestMethod] + public void ProcessRequestsExecutionLaunchAdapterProcessWithDebuggerShouldSendAckMessage() + { + var message = _dataSerializer.SerializePayload(MessageType.LaunchAdapterProcessWithDebuggerAttachedCallback, string.Empty); - [TestMethod] - public void SendExecutionCompleteShouldSendTestRunCompletePayloadOnChannel() - { - var t1 = new TestCase("N.C.M1", new Uri("executor://mstest/v2"), "test1.dll"); - var t2 = new TestCase("N.C.M2", new Uri("executor://mstest/v2"), "test1.dll"); - var testCases = new[] { t1, t2 }; - var testRunCriteriaWithTests = new TestRunCriteriaWithTests(testCases, "runsettings", null, null); - var message = this.dataSerializer.SerializePayload(MessageType.StartTestExecutionWithTests, testRunCriteriaWithTests); - this.mockExecutionManager.Setup(em => em.StartTestRun(It.IsAny>(), It.IsAny(), + ProcessRequestsAsync(_mockTestHostManagerFactory.Object); + SendMessageOnChannel(message); + _jobQueue.Flush(); + + SendSessionEnd(); + } + + [TestMethod] + public void ProcessRequestsExecutionAbortShouldStopTestRun() + { + var message = _dataSerializer.SerializePayload(MessageType.AbortTestRun, string.Empty); + + ProcessRequestsAsync(_mockTestHostManagerFactory.Object); + SendMessageOnChannel(message); + + _mockExecutionManager.Verify(e => e.Abort(It.IsAny())); + SendSessionEnd(); + } + + [TestMethod] + public void SendExecutionCompleteShouldSendTestRunCompletePayloadOnChannel() + { + var t1 = new TestCase("N.C.M1", new Uri("executor://mstest/v2"), "test1.dll"); + var t2 = new TestCase("N.C.M2", new Uri("executor://mstest/v2"), "test1.dll"); + var testCases = new[] { t1, t2 }; + var testRunCriteriaWithTests = new TestRunCriteriaWithTests(testCases, "runsettings", null, null); + var message = _dataSerializer.SerializePayload(MessageType.StartTestExecutionWithTests, testRunCriteriaWithTests); + _mockExecutionManager.Setup(em => em.StartTestRun(It.IsAny>(), It.IsAny(), + It.IsAny(), + It.IsAny(), It.IsAny(), + It.IsAny())).Callback(() => _requestHandler.SendExecutionComplete(It.IsAny(), It.IsAny(), It.IsAny>(), It.IsAny>())); + + ProcessRequestsAsync(_mockTestHostManagerFactory.Object); + _mockChannel.Setup(mc => mc.Send(It.Is(d => d.Contains(MessageType.ExecutionComplete)))) + .Callback( + (d) => + { + var msg = _dataSerializer.DeserializeMessage(d); + var payload = _dataSerializer.DeserializePayload(msg); + Assert.IsNotNull(payload); + }); + SendMessageOnChannel(message); + _jobQueue.Flush(); + + _mockExecutionManager.Verify(e => + e.StartTestRun( + It.Is>(tcs => + tcs.Any(t => t.FullyQualifiedName.Equals("N.C.M1")) && + tcs.Any(t => t.FullyQualifiedName.Equals("N.C.M2"))), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), - It.IsAny())).Callback(() => - { - this.requestHandler.SendExecutionComplete(It.IsAny(), It.IsAny(), It.IsAny>(), It.IsAny>()); - }); - - this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); - this.mockChannel.Setup(mc => mc.Send(It.Is(d => d.Contains(MessageType.ExecutionComplete)))) - .Callback( - (d) => - { - var msg = this.dataSerializer.DeserializeMessage(d); - var payload = this.dataSerializer.DeserializePayload(msg); - Assert.IsNotNull(payload); - }); - this.SendMessageOnChannel(message); - this.jobQueue.Flush(); - - mockExecutionManager.Verify(e => - e.StartTestRun( - It.Is>(tcs => - tcs.Any(t => t.FullyQualifiedName.Equals("N.C.M1")) && - tcs.Any(t => t.FullyQualifiedName.Equals("N.C.M2"))), It.IsAny(), - It.IsAny(), - It.IsAny(), It.IsAny(), - It.IsAny())); - this.SendSessionEnd(); - } + It.IsAny())); + SendSessionEnd(); + } - [TestMethod] - public void LaunchProcessWithDebuggerAttachedShouldSendProcessInformationOnChannel() - { - var message = this.dataSerializer.SerializePayload(MessageType.LaunchAdapterProcessWithDebuggerAttachedCallback, "123"); - - this.mockChannel.Setup(mc => mc.Send(It.Is(d => d.Contains(MessageType.LaunchAdapterProcessWithDebuggerAttached)))) - .Callback( - (d) => - { - var msg = this.dataSerializer.DeserializeMessage(d); - var payload = this.dataSerializer.DeserializePayload(msg); - Assert.IsNotNull(payload); - this.SendMessageOnChannel(message); - this.SendSessionEnd(); - }); - - var task = Task.Run(() => this.requestHandler.LaunchProcessWithDebuggerAttached(new TestProcessStartInfo())); - } + [TestMethod] + public void LaunchProcessWithDebuggerAttachedShouldSendProcessInformationOnChannel() + { + var message = _dataSerializer.SerializePayload(MessageType.LaunchAdapterProcessWithDebuggerAttachedCallback, "123"); + + _mockChannel.Setup(mc => mc.Send(It.Is(d => d.Contains(MessageType.LaunchAdapterProcessWithDebuggerAttached)))) + .Callback( + (d) => + { + var msg = _dataSerializer.DeserializeMessage(d); + var payload = _dataSerializer.DeserializePayload(msg); + Assert.IsNotNull(payload); + SendMessageOnChannel(message); + SendSessionEnd(); + }); + + var task = Task.Run(() => _requestHandler.LaunchProcessWithDebuggerAttached(new TestProcessStartInfo())); + } - [TestMethod] - public void LaunchProcessWithDebuggerAttachedShouldWaitForProcessIdFromRunner() - { - var message = dataSerializer.SerializePayload(MessageType.LaunchAdapterProcessWithDebuggerAttachedCallback, "123"); - - this.mockChannel.Setup(mc => mc.Send(It.Is(d => d.Contains(MessageType.LaunchAdapterProcessWithDebuggerAttached)))) - .Callback( - (d) => - { - var msg = this.dataSerializer.DeserializeMessage(d); - var payload = this.dataSerializer.DeserializePayload(msg); - Assert.IsNotNull(payload); - this.SendMessageOnChannel(message); - this.SendSessionEnd(); - }); - - var task = Task.Run(() => this.requestHandler.LaunchProcessWithDebuggerAttached(new TestProcessStartInfo())); - - Assert.AreEqual(123, task.Result); - } - #endregion + [TestMethod] + public void LaunchProcessWithDebuggerAttachedShouldWaitForProcessIdFromRunner() + { + var message = _dataSerializer.SerializePayload(MessageType.LaunchAdapterProcessWithDebuggerAttachedCallback, "123"); + + _mockChannel.Setup(mc => mc.Send(It.Is(d => d.Contains(MessageType.LaunchAdapterProcessWithDebuggerAttached)))) + .Callback( + (d) => + { + var msg = _dataSerializer.DeserializeMessage(d); + var payload = _dataSerializer.DeserializePayload(msg); + Assert.IsNotNull(payload); + SendMessageOnChannel(message); + SendSessionEnd(); + }); + + var task = Task.Run(() => _requestHandler.LaunchProcessWithDebuggerAttached(new TestProcessStartInfo())); + + Assert.AreEqual(123, task.Result); + } + #endregion - #region Logging Protocol - [TestMethod] - public void SendLogShouldSendTestMessageWithLevelOnChannel() - { - var logMsg = "Testing log message on channel"; + #region Logging Protocol + [TestMethod] + public void SendLogShouldSendTestMessageWithLevelOnChannel() + { + var logMsg = "Testing log message on channel"; - this.mockChannel.Setup(mc => mc.Send(It.Is(d => d.Contains(MessageType.TestMessage)))) - .Callback( - (d) => - { - var msg = this.dataSerializer.DeserializeMessage(d); - var payload = this.dataSerializer.DeserializePayload(msg); - Assert.IsNotNull(payload); - Assert.AreEqual(payload.Message, logMsg); - }); + _mockChannel.Setup(mc => mc.Send(It.Is(d => d.Contains(MessageType.TestMessage)))) + .Callback( + (d) => + { + var msg = _dataSerializer.DeserializeMessage(d); + var payload = _dataSerializer.DeserializePayload(msg); + Assert.IsNotNull(payload); + Assert.AreEqual(payload.Message, logMsg); + }); - this.requestHandler.SendLog(TestMessageLevel.Informational, "Testing log message on channel"); + _requestHandler.SendLog(TestMessageLevel.Informational, "Testing log message on channel"); - this.SendSessionEnd(); - } - #endregion + SendSessionEnd(); + } + #endregion - [TestMethod] - public void ProcessRequestsEndSessionShouldCloseRequestHandler() - { + [TestMethod] + public void ProcessRequestsEndSessionShouldCloseRequestHandler() + { - this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); - this.SendSessionEnd(); + ProcessRequestsAsync(_mockTestHostManagerFactory.Object); + SendSessionEnd(); - this.mockCommunicationClient.Verify(mc=>mc.Stop(), Times.Once); - } + _mockCommunicationClient.Verify(mc => mc.Stop(), Times.Once); + } - [TestMethod] - public void ProcessRequestsAbortSessionShouldBeNoOp() - { - var message = dataSerializer.SerializePayload(MessageType.SessionAbort, string.Empty); + [TestMethod] + public void ProcessRequestsAbortSessionShouldBeNoOp() + { + var message = _dataSerializer.SerializePayload(MessageType.SessionAbort, string.Empty); - this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); - this.SendMessageOnChannel(message); + ProcessRequestsAsync(_mockTestHostManagerFactory.Object); + SendMessageOnChannel(message); - // Session abort should not close the client - this.mockCommunicationClient.Verify(mc => mc.Stop(), Times.Never); - } + // Session abort should not close the client + _mockCommunicationClient.Verify(mc => mc.Stop(), Times.Never); + } - [TestMethod] - public void ProcessRequestsInvalidMessageTypeShouldNotThrow() - { - var message = dataSerializer.SerializePayload("DummyMessage", string.Empty); + [TestMethod] + public void ProcessRequestsInvalidMessageTypeShouldNotThrow() + { + var message = _dataSerializer.SerializePayload("DummyMessage", string.Empty); - this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); - this.SendMessageOnChannel(message); + ProcessRequestsAsync(_mockTestHostManagerFactory.Object); + SendMessageOnChannel(message); - this.SendSessionEnd(); - } + SendSessionEnd(); + } - [TestMethod] - public void ProcessRequestsInvalidMessageTypeShouldProcessFutureMessages() - { - var message = dataSerializer.SerializePayload("DummyMessage", string.Empty); + [TestMethod] + public void ProcessRequestsInvalidMessageTypeShouldProcessFutureMessages() + { + var message = _dataSerializer.SerializePayload("DummyMessage", string.Empty); - this.ProcessRequestsAsync(this.mockTestHostManagerFactory.Object); - this.SendMessageOnChannel(message); + ProcessRequestsAsync(_mockTestHostManagerFactory.Object); + SendMessageOnChannel(message); - // Should process this message, after the invalid message - this.SendSessionEnd(); - this.mockCommunicationClient.Verify(mc => mc.Stop(), Times.Once); - } + // Should process this message, after the invalid message + SendSessionEnd(); + _mockCommunicationClient.Verify(mc => mc.Stop(), Times.Once); + } - [TestMethod] - public void DisposeShouldStopCommunicationChannel() - { - var testRequestHandler = this.requestHandler as TestRequestHandler; - Assert.IsNotNull(testRequestHandler); + [TestMethod] + public void DisposeShouldStopCommunicationChannel() + { + var testRequestHandler = _requestHandler as TestRequestHandler; + Assert.IsNotNull(testRequestHandler); - testRequestHandler.Dispose(); + testRequestHandler.Dispose(); - this.mockCommunicationClient.Verify(mc => mc.Stop(), Times.Once); - } + _mockCommunicationClient.Verify(mc => mc.Stop(), Times.Once); + } - private void SendMessageOnChannel(Message message) - { - // Setup message to be returned on deserialization of data - var data = this.Serialize(message); - this.SendMessageOnChannel(data); - } + private void SendMessageOnChannel(Message message) + { + // Setup message to be returned on deserialization of data + var data = Serialize(message); + SendMessageOnChannel(data); + } - private void SendMessageOnChannel(string data) - { - this.mockChannel.Raise(c => c.MessageReceived += null, new MessageReceivedEventArgs { Data = data }); - } + private void SendMessageOnChannel(string data) + { + _mockChannel.Raise(c => c.MessageReceived += null, new MessageReceivedEventArgs { Data = data }); + } - private void SendSessionEnd() - { - this.SendMessageOnChannel(new Message { MessageType = MessageType.SessionEnd, Payload = string.Empty }); - } + private void SendSessionEnd() + { + SendMessageOnChannel(new Message { MessageType = MessageType.SessionEnd, Payload = string.Empty }); + } - private Task ProcessRequestsAsync() - { - return Task.Run(() => this.requestHandler.ProcessRequests(new Mock().Object)); - } + private Task ProcessRequestsAsync() + { + return Task.Run(() => _requestHandler.ProcessRequests(new Mock().Object)); + } - private Task ProcessRequestsAsync(ITestHostManagerFactory testHostManagerFactory) - { - return Task.Run(() => this.requestHandler.ProcessRequests(testHostManagerFactory)); - } + private Task ProcessRequestsAsync(ITestHostManagerFactory testHostManagerFactory) + { + return Task.Run(() => _requestHandler.ProcessRequests(testHostManagerFactory)); + } - private string Serialize(Message message) - { - return this.dataSerializer.SerializePayload(message.MessageType, message.Payload); - } + private string Serialize(Message message) + { + return _dataSerializer.SerializePayload(message.MessageType, message.Payload); + } - private void VerifyResponseMessageEquals(string message) - { - this.mockChannel.Verify(mc => mc.Send(It.Is(s => s.Equals(message)))); - } + private void VerifyResponseMessageEquals(string message) + { + _mockChannel.Verify(mc => mc.Send(It.Is(s => s.Equals(message)))); + } - private void VerifyResponseMessageContains(string message) - { - this.mockChannel.Verify(mc => mc.Send(It.Is(s => s.Contains(message)))); - } + private void VerifyResponseMessageContains(string message) + { + _mockChannel.Verify(mc => mc.Send(It.Is(s => s.Contains(message)))); } +} - public class TestableTestRequestHandler : TestRequestHandler - { - public TestableTestRequestHandler( - TestHostConnectionInfo testHostConnectionInfo, - ICommunicationEndpointFactory communicationEndpointFactory, - IDataSerializer dataSerializer, - JobQueue jobQueue) - : base( - testHostConnectionInfo, - communicationEndpointFactory, - dataSerializer, - jobQueue, - OnLaunchAdapterProcessWithDebuggerAttachedAckReceived, - OnAttachDebuggerAckRecieved) - { - } +public class TestableTestRequestHandler : TestRequestHandler +{ + public TestableTestRequestHandler( + TestHostConnectionInfo testHostConnectionInfo, + ICommunicationEndpointFactory communicationEndpointFactory, + IDataSerializer dataSerializer, + JobQueue jobQueue) + : base( + testHostConnectionInfo, + communicationEndpointFactory, + dataSerializer, + jobQueue, + OnLaunchAdapterProcessWithDebuggerAttachedAckReceived, + OnAttachDebuggerAckRecieved) + { + } - private static void OnLaunchAdapterProcessWithDebuggerAttachedAckReceived(Message message) - { - Assert.AreEqual(message.MessageType, MessageType.LaunchAdapterProcessWithDebuggerAttachedCallback); - } + private static void OnLaunchAdapterProcessWithDebuggerAttachedAckReceived(Message message) + { + Assert.AreEqual(message.MessageType, MessageType.LaunchAdapterProcessWithDebuggerAttachedCallback); + } - private static void OnAttachDebuggerAckRecieved(Message message) - { - Assert.AreEqual(message.MessageType, MessageType.AttachDebuggerCallback); - } + private static void OnAttachDebuggerAckRecieved(Message message) + { + Assert.AreEqual(message.MessageType, MessageType.AttachDebuggerCallback); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/BaseRunTestsTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/BaseRunTestsTests.cs index c93cdf16e3..8f24c9cddc 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/BaseRunTestsTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/BaseRunTestsTests.cs @@ -1,1093 +1,1057 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Execution +namespace TestPlatform.CrossPlatEngine.UnitTests.Execution; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; + +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OMTestResult = Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult; + +using Moq; +using Microsoft.TestPlatform.TestUtilities; + +[TestClass] +public class BaseRunTestsTests { - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Reflection; - - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using OMTestResult = Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult; - - using Moq; - using Microsoft.TestPlatform.TestUtilities; - - [TestClass] - public class BaseRunTestsTests - { - private const string BaseRunTestsExecutorUri = "executor://BaseRunTestsExecutor/"; - private const string BadBaseRunTestsExecutorUri = "executor://BadBaseRunTestsExecutor/"; + private const string BaseRunTestsExecutorUri = "executor://BaseRunTestsExecutor/"; + private const string BadBaseRunTestsExecutorUri = "executor://BadBaseRunTestsExecutor/"; - private TestExecutionContext testExecutionContext; - private Mock mockTestRunEventsHandler; + private readonly TestExecutionContext _testExecutionContext; + private readonly Mock _mockTestRunEventsHandler; - private TestableBaseRunTests runTestsInstance; + private TestableBaseRunTests _runTestsInstance; - private Mock mockTestPlatformEventSource; - private Mock mockThread; + private readonly Mock _mockTestPlatformEventSource; + private Mock _mockThread; - private Mock mockRequestData; + private readonly Mock _mockRequestData; - private Mock mockMetricsCollection; + private readonly Mock _mockMetricsCollection; - private Mock mockDataSerializer; + private readonly Mock _mockDataSerializer; - private TestRunChangedEventArgs receivedRunStatusArgs; - private TestRunCompleteEventArgs receivedRunCompleteArgs; - private ICollection receivedattachments; - private ICollection receivedExecutorUris; - private TestCase inProgressTestCase; + private TestRunChangedEventArgs _receivedRunStatusArgs; + private TestRunCompleteEventArgs _receivedRunCompleteArgs; + private ICollection _receivedattachments; + private ICollection _receivedExecutorUris; + private TestCase _inProgressTestCase; - public BaseRunTestsTests() - { - this.testExecutionContext = new TestExecutionContext( - frequencyOfRunStatsChangeEvent: 100, - runStatsChangeEventTimeout: TimeSpan.MaxValue, - inIsolation: false, - keepAlive: false, - isDataCollectionEnabled: false, - areTestCaseLevelEventsRequired: false, - hasTestRun: false, - isDebug: false, - testCaseFilter: string.Empty, - filterOptions: null); - this.mockTestRunEventsHandler = new Mock(); - - this.mockTestPlatformEventSource = new Mock(); - - this.mockRequestData = new Mock(); - this.mockMetricsCollection = new Mock(); - this.mockThread = new Mock(); - this.mockDataSerializer = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(this.mockMetricsCollection.Object); - - this.runTestsInstance = new TestableBaseRunTests( - this.mockRequestData.Object, - null, - null, - this.testExecutionContext, - null, - this.mockTestRunEventsHandler.Object, - this.mockTestPlatformEventSource.Object, - null, - new PlatformThread(), - this.mockDataSerializer.Object); - - TestPluginCacheHelper.SetupMockExtensions(new string[] { typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location }, () => { }); - } + public BaseRunTestsTests() + { + _testExecutionContext = new TestExecutionContext( + frequencyOfRunStatsChangeEvent: 100, + runStatsChangeEventTimeout: TimeSpan.MaxValue, + inIsolation: false, + keepAlive: false, + isDataCollectionEnabled: false, + areTestCaseLevelEventsRequired: false, + hasTestRun: false, + isDebug: false, + testCaseFilter: string.Empty, + filterOptions: null); + _mockTestRunEventsHandler = new Mock(); + + _mockTestPlatformEventSource = new Mock(); + + _mockRequestData = new Mock(); + _mockMetricsCollection = new Mock(); + _mockThread = new Mock(); + _mockDataSerializer = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(_mockMetricsCollection.Object); + + _runTestsInstance = new TestableBaseRunTests( + _mockRequestData.Object, + null, + null, + _testExecutionContext, + null, + _mockTestRunEventsHandler.Object, + _mockTestPlatformEventSource.Object, + null, + new PlatformThread(), + _mockDataSerializer.Object); + + TestPluginCacheHelper.SetupMockExtensions(new string[] { typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location }, () => { }); + } - [TestCleanup] - public void Cleanup() - { - TestExecutorExtensionManager.Destroy(); - TestPluginCacheHelper.ResetExtensionsCache(); - } + [TestCleanup] + public void Cleanup() + { + TestExecutorExtensionManager.Destroy(); + TestPluginCacheHelper.ResetExtensionsCache(); + } - #region Constructor tests + #region Constructor tests - [TestMethod] - public void ConstructorShouldInitializeRunContext() - { - var runContext = this.runTestsInstance.GetRunContext; - Assert.IsNotNull(runContext); - Assert.IsFalse(runContext.KeepAlive); - Assert.IsFalse(runContext.InIsolation); - Assert.IsFalse(runContext.IsDataCollectionEnabled); - Assert.IsFalse(runContext.IsBeingDebugged); - } + [TestMethod] + public void ConstructorShouldInitializeRunContext() + { + var runContext = _runTestsInstance.GetRunContext; + Assert.IsNotNull(runContext); + Assert.IsFalse(runContext.KeepAlive); + Assert.IsFalse(runContext.InIsolation); + Assert.IsFalse(runContext.IsDataCollectionEnabled); + Assert.IsFalse(runContext.IsBeingDebugged); + } - [TestMethod] - public void ConstructorShouldInitializeFrameworkHandle() - { - var frameworkHandle = this.runTestsInstance.GetFrameworkHandle; - Assert.IsNotNull(frameworkHandle); - } + [TestMethod] + public void ConstructorShouldInitializeFrameworkHandle() + { + var frameworkHandle = _runTestsInstance.GetFrameworkHandle; + Assert.IsNotNull(frameworkHandle); + } - [TestMethod] - public void ConstructorShouldInitializeExecutorUrisThatRanTests() - { - var executorUris = this.runTestsInstance.GetExecutorUrisThatRanTests; - Assert.IsNotNull(executorUris); - } + [TestMethod] + public void ConstructorShouldInitializeExecutorUrisThatRanTests() + { + var executorUris = _runTestsInstance.GetExecutorUrisThatRanTests; + Assert.IsNotNull(executorUris); + } - #endregion + #endregion - #region RunTests tests + #region RunTests tests - [TestMethod] - public void RunTestsShouldRaiseTestRunCompleteWithAbortedAsTrueOnException() - { - TestRunCompleteEventArgs receivedCompleteArgs = null; + [TestMethod] + public void RunTestsShouldRaiseTestRunCompleteWithAbortedAsTrueOnException() + { + TestRunCompleteEventArgs receivedCompleteArgs = null; - // Setup mocks. - this.runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => { throw new NotImplementedException(); }; - this.mockTestRunEventsHandler.Setup( + // Setup mocks. + _runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => throw new NotImplementedException(); + _mockTestRunEventsHandler.Setup( treh => - treh.HandleTestRunComplete( - It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>())) - .Callback( - ( - TestRunCompleteEventArgs complete, - TestRunChangedEventArgs stats, - ICollection attachments, - ICollection executorUris) => - { - receivedCompleteArgs = complete; - }); - - this.runTestsInstance.RunTests(); - - Assert.IsNotNull(receivedCompleteArgs); - Assert.IsTrue(receivedCompleteArgs.IsAborted); - } + treh.HandleTestRunComplete( + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>())) + .Callback( + ( + TestRunCompleteEventArgs complete, + TestRunChangedEventArgs stats, + ICollection attachments, + ICollection executorUris) => receivedCompleteArgs = complete); + + _runTestsInstance.RunTests(); + + Assert.IsNotNull(receivedCompleteArgs); + Assert.IsTrue(receivedCompleteArgs.IsAborted); + } - [TestMethod] - public void RunTestsShouldNotThrowIfExceptionIsAFileNotFoundException() - { - TestRunCompleteEventArgs receivedCompleteArgs = null; + [TestMethod] + public void RunTestsShouldNotThrowIfExceptionIsAFileNotFoundException() + { + TestRunCompleteEventArgs receivedCompleteArgs = null; - // Setup mocks. - this.runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => { throw new FileNotFoundException(); }; - this.mockTestRunEventsHandler.Setup( + // Setup mocks. + _runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => throw new FileNotFoundException(); + _mockTestRunEventsHandler.Setup( treh => - treh.HandleTestRunComplete( - It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>())) - .Callback( - ( - TestRunCompleteEventArgs complete, - TestRunChangedEventArgs stats, - ICollection attachments, - ICollection executorUris) => - { - receivedCompleteArgs = complete; - }); - - // This should not throw. - this.runTestsInstance.RunTests(); - - Assert.IsNotNull(receivedCompleteArgs); - Assert.IsTrue(receivedCompleteArgs.IsAborted); - } + treh.HandleTestRunComplete( + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>())) + .Callback( + ( + TestRunCompleteEventArgs complete, + TestRunChangedEventArgs stats, + ICollection attachments, + ICollection executorUris) => receivedCompleteArgs = complete); + + // This should not throw. + _runTestsInstance.RunTests(); + + Assert.IsNotNull(receivedCompleteArgs); + Assert.IsTrue(receivedCompleteArgs.IsAborted); + } - [TestMethod] - public void RunTestsShouldNotThrowIfExceptionIsAnArgumentException() - { - TestRunCompleteEventArgs receivedCompleteArgs = null; + [TestMethod] + public void RunTestsShouldNotThrowIfExceptionIsAnArgumentException() + { + TestRunCompleteEventArgs receivedCompleteArgs = null; - // Setup mocks. - this.runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => { throw new ArgumentException(); }; - this.mockTestRunEventsHandler.Setup( + // Setup mocks. + _runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => throw new ArgumentException(); + _mockTestRunEventsHandler.Setup( treh => - treh.HandleTestRunComplete( - It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>())) - .Callback( - ( - TestRunCompleteEventArgs complete, - TestRunChangedEventArgs stats, - ICollection attachments, - ICollection executorUris) => - { - receivedCompleteArgs = complete; - }); - - // This should not throw. - this.runTestsInstance.RunTests(); - - Assert.IsNotNull(receivedCompleteArgs); - Assert.IsTrue(receivedCompleteArgs.IsAborted); - } + treh.HandleTestRunComplete( + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>())) + .Callback( + ( + TestRunCompleteEventArgs complete, + TestRunChangedEventArgs stats, + ICollection attachments, + ICollection executorUris) => receivedCompleteArgs = complete); + + // This should not throw. + _runTestsInstance.RunTests(); + + Assert.IsNotNull(receivedCompleteArgs); + Assert.IsTrue(receivedCompleteArgs.IsAborted); + } - [TestMethod] - public void RunTestsShouldAbortIfExecutorUriExtensionMapIsNull() - { - TestRunCompleteEventArgs receivedCompleteArgs = null; + [TestMethod] + public void RunTestsShouldAbortIfExecutorUriExtensionMapIsNull() + { + TestRunCompleteEventArgs receivedCompleteArgs = null; - // Setup mocks. - this.runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => { return null; }; - this.mockTestRunEventsHandler.Setup( + // Setup mocks. + _runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => null; + _mockTestRunEventsHandler.Setup( treh => - treh.HandleTestRunComplete( - It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>())) - .Callback( - ( - TestRunCompleteEventArgs complete, - TestRunChangedEventArgs stats, - ICollection attachments, - ICollection executorUris) => - { - receivedCompleteArgs = complete; - }); - - // This should not throw. - this.runTestsInstance.RunTests(); - - Assert.IsNotNull(receivedCompleteArgs); - Assert.IsTrue(receivedCompleteArgs.IsAborted); - } + treh.HandleTestRunComplete( + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>())) + .Callback( + ( + TestRunCompleteEventArgs complete, + TestRunChangedEventArgs stats, + ICollection attachments, + ICollection executorUris) => receivedCompleteArgs = complete); + + // This should not throw. + _runTestsInstance.RunTests(); + + Assert.IsNotNull(receivedCompleteArgs); + Assert.IsTrue(receivedCompleteArgs.IsAborted); + } - [TestMethod] - public void RunTestsShouldInvokeTheTestExecutorIfAdapterAssemblyIsKnown() + [TestMethod] + public void RunTestsShouldInvokeTheTestExecutorIfAdapterAssemblyIsKnown() + { + var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var executorUriExtensionMap = new List> { - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; - var executorUriExtensionMap = new List> - { - new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) - }; - LazyExtension receivedExecutor = null; + new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) + }; + LazyExtension receivedExecutor = null; - // Setup mocks. - this.runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => { return executorUriExtensionMap; }; - this.runTestsInstance.InvokeExecutorCallback = - (executor, executorUriExtensionTuple, runContext, frameworkHandle) => - { - receivedExecutor = executor; - }; + // Setup mocks. + _runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => executorUriExtensionMap; + _runTestsInstance.InvokeExecutorCallback = + (executor, executorUriExtensionTuple, runContext, frameworkHandle) => receivedExecutor = executor; - this.runTestsInstance.RunTests(); + _runTestsInstance.RunTests(); - Assert.IsNotNull(receivedExecutor); - Assert.AreEqual(BaseRunTestsExecutorUri, receivedExecutor.Metadata.ExtensionUri); - } + Assert.IsNotNull(receivedExecutor); + Assert.AreEqual(BaseRunTestsExecutorUri, receivedExecutor.Metadata.ExtensionUri); + } - [TestMethod] - public void RunTestsShouldInvokeTheTestExecutorIfAdapterAssemblyIsUnknown() + [TestMethod] + public void RunTestsShouldInvokeTheTestExecutorIfAdapterAssemblyIsUnknown() + { + var executorUriExtensionMap = new List> { - var executorUriExtensionMap = new List> - { - new Tuple(new Uri(BaseRunTestsExecutorUri), Microsoft.VisualStudio.TestPlatform.ObjectModel.Constants.UnspecifiedAdapterPath) - }; - LazyExtension receivedExecutor = null; + new Tuple(new Uri(BaseRunTestsExecutorUri), Constants.UnspecifiedAdapterPath) + }; + LazyExtension receivedExecutor = null; - // Setup mocks. - this.runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => { return executorUriExtensionMap; }; - this.runTestsInstance.InvokeExecutorCallback = - (executor, executorUriExtensionTuple, runContext, frameworkHandle) => - { - receivedExecutor = executor; - }; + // Setup mocks. + _runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => executorUriExtensionMap; + _runTestsInstance.InvokeExecutorCallback = + (executor, executorUriExtensionTuple, runContext, frameworkHandle) => receivedExecutor = executor; - this.runTestsInstance.RunTests(); + _runTestsInstance.RunTests(); - Assert.IsNotNull(receivedExecutor); - Assert.AreEqual(BaseRunTestsExecutorUri, receivedExecutor.Metadata.ExtensionUri); - } + Assert.IsNotNull(receivedExecutor); + Assert.AreEqual(BaseRunTestsExecutorUri, receivedExecutor.Metadata.ExtensionUri); + } - [TestMethod] - public void RunTestsShouldInstrumentExecutionStart() - { - this.runTestsInstance.RunTests(); + [TestMethod] + public void RunTestsShouldInstrumentExecutionStart() + { + _runTestsInstance.RunTests(); - this.mockTestPlatformEventSource.Verify(x => x.ExecutionStart(), Times.Once); - } + _mockTestPlatformEventSource.Verify(x => x.ExecutionStart(), Times.Once); + } - [TestMethod] - public void RunTestsShouldInstrumentExecutionStop() - { - this.SetupExecutorUriMock(); + [TestMethod] + public void RunTestsShouldInstrumentExecutionStop() + { + SetupExecutorUriMock(); - this.runTestsInstance.RunTests(); + _runTestsInstance.RunTests(); - this.mockTestPlatformEventSource.Verify(x => x.ExecutionStop(It.IsAny()), Times.Once); - } + _mockTestPlatformEventSource.Verify(x => x.ExecutionStop(It.IsAny()), Times.Once); + } - [TestMethod] - public void RunTestsShouldInstrumentAdapterExecutionStart() - { - this.SetupExecutorUriMock(); + [TestMethod] + public void RunTestsShouldInstrumentAdapterExecutionStart() + { + SetupExecutorUriMock(); - this.runTestsInstance.RunTests(); + _runTestsInstance.RunTests(); - this.mockTestPlatformEventSource.Verify(x => x.AdapterExecutionStart(It.IsAny()), Times.AtLeastOnce); - } + _mockTestPlatformEventSource.Verify(x => x.AdapterExecutionStart(It.IsAny()), Times.AtLeastOnce); + } - [TestMethod] - public void RunTestsShouldInstrumentAdapterExecutionStop() - { - this.SetupExecutorUriMock(); + [TestMethod] + public void RunTestsShouldInstrumentAdapterExecutionStop() + { + SetupExecutorUriMock(); - this.runTestsInstance.RunTests(); + _runTestsInstance.RunTests(); - this.mockTestPlatformEventSource.Verify(x => x.AdapterExecutionStop(It.IsAny()), Times.AtLeastOnce); - } + _mockTestPlatformEventSource.Verify(x => x.AdapterExecutionStop(It.IsAny()), Times.AtLeastOnce); + } - [TestMethod] - public void RunTestsShouldReportAWarningIfExecutorUriIsNotDefinedInExtensionAssembly() + [TestMethod] + public void RunTestsShouldReportAWarningIfExecutorUriIsNotDefinedInExtensionAssembly() + { + var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var executorUriExtensionMap = new List> { - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; - var executorUriExtensionMap = new List> - { - new Tuple(new Uri("executor://nonexistent/"), assemblyLocation) - }; - LazyExtension receivedExecutor = null; + new Tuple(new Uri("executor://nonexistent/"), assemblyLocation) + }; + LazyExtension receivedExecutor = null; - // Setup mocks. - this.runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => { return executorUriExtensionMap; }; - this.runTestsInstance.InvokeExecutorCallback = - (executor, executorUriExtensionTuple, runContext, frameworkHandle) => - { - receivedExecutor = executor; - }; + // Setup mocks. + _runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => executorUriExtensionMap; + _runTestsInstance.InvokeExecutorCallback = + (executor, executorUriExtensionTuple, runContext, frameworkHandle) => receivedExecutor = executor; - this.runTestsInstance.RunTests(); + _runTestsInstance.RunTests(); - var expectedWarningMessageFormat = - "Could not find test executor with URI '{0}'. Make sure that the test executor is installed and supports .net runtime version {1}."; + var expectedWarningMessageFormat = + "Could not find test executor with URI '{0}'. Make sure that the test executor is installed and supports .net runtime version {1}."; - // var runtimeVersion = string.Concat(PlatformServices.Default.Runtime.RuntimeType, " ", - // PlatformServices.Default.Runtime.RuntimeVersion); - var runtimeVersion = " "; + // var runtimeVersion = string.Concat(PlatformServices.Default.Runtime.RuntimeType, " ", + // PlatformServices.Default.Runtime.RuntimeVersion); + var runtimeVersion = " "; - var expectedWarningMessage = string.Format( - expectedWarningMessageFormat, - "executor://nonexistent/", - runtimeVersion); - this.mockTestRunEventsHandler.Verify( - treh => treh.HandleLogMessage(TestMessageLevel.Warning, expectedWarningMessage), Times.Once); + var expectedWarningMessage = string.Format( + expectedWarningMessageFormat, + "executor://nonexistent/", + runtimeVersion); + _mockTestRunEventsHandler.Verify( + treh => treh.HandleLogMessage(TestMessageLevel.Warning, expectedWarningMessage), Times.Once); - // Should not have been called. - Assert.IsNull(receivedExecutor); - } + // Should not have been called. + Assert.IsNull(receivedExecutor); + } - [TestMethod] - public void RunTestsShouldNotAddExecutorUriToExecutorUriListIfNoTestsAreRun() + [TestMethod] + public void RunTestsShouldNotAddExecutorUriToExecutorUriListIfNoTestsAreRun() + { + var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var executorUriExtensionMap = new List> { - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; - var executorUriExtensionMap = new List> - { - new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) - }; + new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) + }; - // Setup mocks. - this.runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => { return executorUriExtensionMap; }; + // Setup mocks. + _runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => executorUriExtensionMap; - this.runTestsInstance.RunTests(); + _runTestsInstance.RunTests(); - Assert.AreEqual(0, this.runTestsInstance.GetExecutorUrisThatRanTests.Count); - } + Assert.AreEqual(0, _runTestsInstance.GetExecutorUrisThatRanTests.Count); + } - [TestMethod] - public void RunTestsShouldAddExecutorUriToExecutorUriListIfExecutorHasRunTests() + [TestMethod] + public void RunTestsShouldAddExecutorUriToExecutorUriListIfExecutorHasRunTests() + { + var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var executorUriExtensionMap = new List> { - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; - var executorUriExtensionMap = new List> + new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) + }; + + // Setup mocks. + _runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => executorUriExtensionMap; + _runTestsInstance.InvokeExecutorCallback = + (executor, executorUriExtensionTuple, runContext, frameworkHandle) => { - new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) + var testCase = new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll"); + var testResult = new OMTestResult(testCase); + _runTestsInstance.GetTestRunCache.OnNewTestResult(testResult); }; - // Setup mocks. - this.runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => { return executorUriExtensionMap; }; - this.runTestsInstance.InvokeExecutorCallback = - (executor, executorUriExtensionTuple, runContext, frameworkHandle) => - { - var testCase = new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll"); - var testResult = new Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult(testCase); - this.runTestsInstance.GetTestRunCache.OnNewTestResult(testResult); - }; - - this.runTestsInstance.RunTests(); + _runTestsInstance.RunTests(); - var expectedUris = new string[] { BaseRunTestsExecutorUri.ToLower() }; - CollectionAssert.AreEqual(expectedUris, this.runTestsInstance.GetExecutorUrisThatRanTests.ToArray()); - } + var expectedUris = new string[] { BaseRunTestsExecutorUri.ToLower() }; + CollectionAssert.AreEqual(expectedUris, _runTestsInstance.GetExecutorUrisThatRanTests.ToArray()); + } - [TestMethod] - public void RunTestsShouldReportWarningIfExecutorThrowsAnException() + [TestMethod] + public void RunTestsShouldReportWarningIfExecutorThrowsAnException() + { + var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var executorUriExtensionMap = new List> { - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; - var executorUriExtensionMap = new List> - { - new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) - }; - - // Setup mocks. - this.runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => { return executorUriExtensionMap; }; - this.runTestsInstance.InvokeExecutorCallback = - (executor, executorUriExtensionTuple, runContext, frameworkHandle) => - { - throw new ArgumentException("Test influenced."); - }; - - this.runTestsInstance.RunTests(); - - var messageFormat = "An exception occurred while invoking executor '{0}': {1}"; - var message = string.Format(messageFormat, BaseRunTestsExecutorUri.ToLower(), "Test influenced."); - this.mockTestRunEventsHandler.Verify( - treh => treh.HandleLogMessage(TestMessageLevel.Error, It.Is(s => s.StartsWith(message))), - Times.Once); - - // Also validate that a test run complete is called. - this.mockTestRunEventsHandler.Verify( - treh => treh.HandleTestRunComplete( - It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>()), Times.Once); - } + new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) + }; + + // Setup mocks. + _runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => executorUriExtensionMap; + _runTestsInstance.InvokeExecutorCallback = + (executor, executorUriExtensionTuple, runContext, frameworkHandle) => throw new ArgumentException("Test influenced."); + + _runTestsInstance.RunTests(); + + var messageFormat = "An exception occurred while invoking executor '{0}': {1}"; + var message = string.Format(messageFormat, BaseRunTestsExecutorUri.ToLower(), "Test influenced."); + _mockTestRunEventsHandler.Verify( + treh => treh.HandleLogMessage(TestMessageLevel.Error, It.Is(s => s.StartsWith(message))), + Times.Once); + + // Also validate that a test run complete is called. + _mockTestRunEventsHandler.Verify( + treh => treh.HandleTestRunComplete( + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>()), Times.Once); + } - [TestMethod] - public void RunTestsShouldNotFailOtherExecutorsRunIfOneExecutorThrowsAnException() + [TestMethod] + public void RunTestsShouldNotFailOtherExecutorsRunIfOneExecutorThrowsAnException() + { + var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var executorUriExtensionMap = new List> { - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; - var executorUriExtensionMap = new List> + new Tuple(new Uri(BadBaseRunTestsExecutorUri), assemblyLocation), + new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) + }; + + // Setup mocks. + _runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => executorUriExtensionMap; + _runTestsInstance.InvokeExecutorCallback = + (executor, executorUriExtensionTuple, runContext, frameworkHandle) => { - new Tuple(new Uri(BadBaseRunTestsExecutorUri), assemblyLocation), - new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) + if (string.Equals(BadBaseRunTestsExecutorUri, executor.Metadata.ExtensionUri)) + { + throw new Exception(); + } + else + { + var testCase = new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll"); + var testResult = new OMTestResult(testCase); + _runTestsInstance.GetTestRunCache.OnNewTestResult(testResult); + } }; - // Setup mocks. - this.runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => { return executorUriExtensionMap; }; - this.runTestsInstance.InvokeExecutorCallback = - (executor, executorUriExtensionTuple, runContext, frameworkHandle) => - { - if (string.Equals(BadBaseRunTestsExecutorUri, executor.Metadata.ExtensionUri)) - { - throw new Exception(); - } - else - { - var testCase = new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll"); - var testResult = new Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult(testCase); - this.runTestsInstance.GetTestRunCache.OnNewTestResult(testResult); - } - }; - - this.runTestsInstance.RunTests(); - - var expectedUris = new string[] { BaseRunTestsExecutorUri.ToLower() }; - CollectionAssert.AreEqual(expectedUris, this.runTestsInstance.GetExecutorUrisThatRanTests.ToArray()); - } + _runTestsInstance.RunTests(); + + var expectedUris = new string[] { BaseRunTestsExecutorUri.ToLower() }; + CollectionAssert.AreEqual(expectedUris, _runTestsInstance.GetExecutorUrisThatRanTests.ToArray()); + } - [TestMethod] - public void RunTestsShouldIterateThroughAllExecutors() + [TestMethod] + public void RunTestsShouldIterateThroughAllExecutors() + { + var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var executorUriExtensionMap = new List> { - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; - var executorUriExtensionMap = new List> + new Tuple(new Uri(BadBaseRunTestsExecutorUri), assemblyLocation), + new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) + }; + + // Setup mocks. + _runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => executorUriExtensionMap; + _runTestsInstance.InvokeExecutorCallback = + (executor, executorUriExtensionTuple, runContext, frameworkHandle) => { - new Tuple(new Uri(BadBaseRunTestsExecutorUri), assemblyLocation), - new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) + var testCase = new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll"); + var testResult = new OMTestResult(testCase); + _runTestsInstance.GetTestRunCache.OnNewTestResult(testResult); }; - // Setup mocks. - this.runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => { return executorUriExtensionMap; }; - this.runTestsInstance.InvokeExecutorCallback = - (executor, executorUriExtensionTuple, runContext, frameworkHandle) => - { - var testCase = new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll"); - var testResult = new Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult(testCase); - this.runTestsInstance.GetTestRunCache.OnNewTestResult(testResult); - }; - - this.runTestsInstance.RunTests(); + _runTestsInstance.RunTests(); - var expectedUris = new string[] { BadBaseRunTestsExecutorUri.ToLower(), BaseRunTestsExecutorUri.ToLower() }; - CollectionAssert.AreEqual(expectedUris, this.runTestsInstance.GetExecutorUrisThatRanTests.ToArray()); - } + var expectedUris = new string[] { BadBaseRunTestsExecutorUri.ToLower(), BaseRunTestsExecutorUri.ToLower() }; + CollectionAssert.AreEqual(expectedUris, _runTestsInstance.GetExecutorUrisThatRanTests.ToArray()); + } - [TestMethod] - public void RunTestsShouldRaiseTestRunComplete() - { - this.SetUpTestRunEvents(); - - // Act. - this.runTestsInstance.RunTests(); - - // Test run complete assertions. - Assert.IsNotNull(receivedRunCompleteArgs); - Assert.IsNull(receivedRunCompleteArgs.Error); - Assert.IsFalse(receivedRunCompleteArgs.IsAborted); - Assert.AreEqual(this.runTestsInstance.GetTestRunCache.TestRunStatistics.ExecutedTests, receivedRunCompleteArgs.TestRunStatistics.ExecutedTests); - - // Test run changed event assertions - Assert.IsNotNull(receivedRunStatusArgs); - Assert.AreEqual(this.runTestsInstance.GetTestRunCache.TestRunStatistics.ExecutedTests, receivedRunStatusArgs.TestRunStatistics.ExecutedTests); - Assert.IsNotNull(receivedRunStatusArgs.NewTestResults); - Assert.IsTrue(receivedRunStatusArgs.NewTestResults.Any()); - Assert.IsTrue(receivedRunStatusArgs.ActiveTests == null || !receivedRunStatusArgs.ActiveTests.Any()); - - // Attachments - Assert.IsNotNull(receivedattachments); - - // Executor Uris - var expectedUris = new string[] { BadBaseRunTestsExecutorUri.ToLower(), BaseRunTestsExecutorUri.ToLower() }; - CollectionAssert.AreEqual(expectedUris, receivedExecutorUris.ToArray()); - } + [TestMethod] + public void RunTestsShouldRaiseTestRunComplete() + { + SetUpTestRunEvents(); + + // Act. + _runTestsInstance.RunTests(); + + // Test run complete assertions. + Assert.IsNotNull(_receivedRunCompleteArgs); + Assert.IsNull(_receivedRunCompleteArgs.Error); + Assert.IsFalse(_receivedRunCompleteArgs.IsAborted); + Assert.AreEqual(_runTestsInstance.GetTestRunCache.TestRunStatistics.ExecutedTests, _receivedRunCompleteArgs.TestRunStatistics.ExecutedTests); + + // Test run changed event assertions + Assert.IsNotNull(_receivedRunStatusArgs); + Assert.AreEqual(_runTestsInstance.GetTestRunCache.TestRunStatistics.ExecutedTests, _receivedRunStatusArgs.TestRunStatistics.ExecutedTests); + Assert.IsNotNull(_receivedRunStatusArgs.NewTestResults); + Assert.IsTrue(_receivedRunStatusArgs.NewTestResults.Any()); + Assert.IsTrue(_receivedRunStatusArgs.ActiveTests == null || !_receivedRunStatusArgs.ActiveTests.Any()); + + // Attachments + Assert.IsNotNull(_receivedattachments); + + // Executor Uris + var expectedUris = new string[] { BadBaseRunTestsExecutorUri.ToLower(), BaseRunTestsExecutorUri.ToLower() }; + CollectionAssert.AreEqual(expectedUris, _receivedExecutorUris.ToArray()); + } - [TestMethod] - public void RunTestsShouldNotCloneTestCaseAndTestResultsObjectForNonPackageSource() - { - this.SetUpTestRunEvents(); + [TestMethod] + public void RunTestsShouldNotCloneTestCaseAndTestResultsObjectForNonPackageSource() + { + SetUpTestRunEvents(); - this.runTestsInstance.RunTests(); + _runTestsInstance.RunTests(); - this.mockDataSerializer.Verify(d => d.Clone(It.IsAny()), Times.Never); - this.mockDataSerializer.Verify(d => d.Clone(It.IsAny()), Times.Never); - } + _mockDataSerializer.Verify(d => d.Clone(It.IsAny()), Times.Never); + _mockDataSerializer.Verify(d => d.Clone(It.IsAny()), Times.Never); + } - [TestMethod] - public void RunTestsShouldUpdateTestResultsTestCaseSourceWithPackageIfTestSourceIsPackage() - { - const string package = @"C:\Projects\UnitTestApp1\AppPackages\UnitTestApp1\UnitTestApp1_1.0.0.0_Win32_Debug_Test\UnitTestApp1_1.0.0.0_Win32_Debug.appx"; - this.SetUpTestRunEvents(package); + [TestMethod] + public void RunTestsShouldUpdateTestResultsTestCaseSourceWithPackageIfTestSourceIsPackage() + { + const string package = @"C:\Projects\UnitTestApp1\AppPackages\UnitTestApp1\UnitTestApp1_1.0.0.0_Win32_Debug_Test\UnitTestApp1_1.0.0.0_Win32_Debug.appx"; + SetUpTestRunEvents(package); - // Act. - this.runTestsInstance.RunTests(); + // Act. + _runTestsInstance.RunTests(); - // Test run changed event assertions - Assert.IsNotNull(receivedRunStatusArgs.NewTestResults); - Assert.IsTrue(receivedRunStatusArgs.NewTestResults.Any()); + // Test run changed event assertions + Assert.IsNotNull(_receivedRunStatusArgs.NewTestResults); + Assert.IsTrue(_receivedRunStatusArgs.NewTestResults.Any()); - // verify TC.Source is updated with package - foreach (var tr in receivedRunStatusArgs.NewTestResults) - { - Assert.AreEqual(tr.TestCase.Source, package); - } + // verify TC.Source is updated with package + foreach (var tr in _receivedRunStatusArgs.NewTestResults) + { + Assert.AreEqual(tr.TestCase.Source, package); } + } - [TestMethod] - public void RunTestsShouldUpdateActiveTestCasesSourceWithPackageIfTestSourceIsPackage() - { - const string package = @"C:\Porjects\UnitTestApp3\Debug\UnitTestApp3\UnitTestApp3.build.appxrecipe"; - this.mockDataSerializer.Setup(d => d.Clone(It.IsAny())) - .Returns(t => JsonDataSerializer.Instance.Clone(t)); - this.SetUpTestRunEvents(package, setupHandleTestRunComplete: false); + [TestMethod] + public void RunTestsShouldUpdateActiveTestCasesSourceWithPackageIfTestSourceIsPackage() + { + const string package = @"C:\Porjects\UnitTestApp3\Debug\UnitTestApp3\UnitTestApp3.build.appxrecipe"; + _mockDataSerializer.Setup(d => d.Clone(It.IsAny())) + .Returns(t => JsonDataSerializer.Instance.Clone(t)); + SetUpTestRunEvents(package, setupHandleTestRunComplete: false); - // Act. - this.runTestsInstance.RunTests(); + // Act. + _runTestsInstance.RunTests(); - Assert.IsNotNull(receivedRunStatusArgs.ActiveTests); - Assert.AreEqual(1, receivedRunStatusArgs.ActiveTests.Count()); + Assert.IsNotNull(_receivedRunStatusArgs.ActiveTests); + Assert.AreEqual(1, _receivedRunStatusArgs.ActiveTests.Count()); - foreach (var tc in receivedRunStatusArgs.ActiveTests) - { - Assert.AreEqual(tc.Source, package); - } + foreach (var tc in _receivedRunStatusArgs.ActiveTests) + { + Assert.AreEqual(tc.Source, package); } + } - [TestMethod] - public void RunTestsShouldCloneTheActiveTestCaseObjectsIfTestSourceIsPackage() - { - const string package = @"C:\Porjects\UnitTestApp3\Debug\UnitTestApp3\UnitTestApp3.build.appxrecipe"; + [TestMethod] + public void RunTestsShouldCloneTheActiveTestCaseObjectsIfTestSourceIsPackage() + { + const string package = @"C:\Porjects\UnitTestApp3\Debug\UnitTestApp3\UnitTestApp3.build.appxrecipe"; - this.SetUpTestRunEvents(package, setupHandleTestRunComplete: false); + SetUpTestRunEvents(package, setupHandleTestRunComplete: false); - // Act. - this.runTestsInstance.RunTests(); + // Act. + _runTestsInstance.RunTests(); - Assert.IsNotNull(receivedRunStatusArgs.ActiveTests); - Assert.AreEqual(1, receivedRunStatusArgs.ActiveTests.Count()); + Assert.IsNotNull(_receivedRunStatusArgs.ActiveTests); + Assert.AreEqual(1, _receivedRunStatusArgs.ActiveTests.Count()); - this.mockDataSerializer.Verify(d => d.Clone(It.IsAny()), Times.Exactly(2)); - } + _mockDataSerializer.Verify(d => d.Clone(It.IsAny()), Times.Exactly(2)); + } - [TestMethod] - public void RunTestsShouldCloneTheTestResultsObjectsIfTestSourceIsPackage() - { - const string package = @"C:\Porjects\UnitTestApp3\Debug\UnitTestApp3\UnitTestApp3.build.appxrecipe"; + [TestMethod] + public void RunTestsShouldCloneTheTestResultsObjectsIfTestSourceIsPackage() + { + const string package = @"C:\Porjects\UnitTestApp3\Debug\UnitTestApp3\UnitTestApp3.build.appxrecipe"; - this.SetUpTestRunEvents(package, setupHandleTestRunComplete: false); + SetUpTestRunEvents(package, setupHandleTestRunComplete: false); - // Act. - this.runTestsInstance.RunTests(); + // Act. + _runTestsInstance.RunTests(); - Assert.IsNotNull(receivedRunStatusArgs.NewTestResults); - Assert.AreEqual(1, receivedRunStatusArgs.ActiveTests.Count()); + Assert.IsNotNull(_receivedRunStatusArgs.NewTestResults); + Assert.AreEqual(1, _receivedRunStatusArgs.ActiveTests.Count()); - this.mockDataSerializer.Verify(d => d.Clone(It.IsAny()), Times.Exactly(2)); - } + _mockDataSerializer.Verify(d => d.Clone(It.IsAny()), Times.Exactly(2)); + } - [TestMethod] - public void RunTestsShouldNotifyItsImplementersOfAnyExceptionThrownByTheExecutors() + [TestMethod] + public void RunTestsShouldNotifyItsImplementersOfAnyExceptionThrownByTheExecutors() + { + bool? isExceptionThrown = null; + var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var executorUriExtensionMap = new List> { - bool? isExceptionThrown = null; - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; - var executorUriExtensionMap = new List> - { - new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) - }; + new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) + }; - // Setup mocks. - this.runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => { return executorUriExtensionMap; }; - this.runTestsInstance.InvokeExecutorCallback = - (executor, executorUriExtensionTuple, runContext, frameworkHandle) => - { - throw new Exception(); - }; - this.runTestsInstance.BeforeRaisingTestRunCompleteCallback = (isEx) => { isExceptionThrown = isEx; }; + // Setup mocks. + _runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => executorUriExtensionMap; + _runTestsInstance.InvokeExecutorCallback = + (executor, executorUriExtensionTuple, runContext, frameworkHandle) => throw new Exception(); + _runTestsInstance.BeforeRaisingTestRunCompleteCallback = (isEx) => isExceptionThrown = isEx; - this.runTestsInstance.RunTests(); + _runTestsInstance.RunTests(); - Assert.IsTrue(isExceptionThrown.HasValue && isExceptionThrown.Value); - } + Assert.IsTrue(isExceptionThrown.HasValue && isExceptionThrown.Value); + } - [TestMethod] - public void RunTestsShouldReportLogMessagesFromExecutors() + [TestMethod] + public void RunTestsShouldReportLogMessagesFromExecutors() + { + var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var executorUriExtensionMap = new List> { - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; - var executorUriExtensionMap = new List> - { - new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) - }; - this.runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => executorUriExtensionMap; - this.runTestsInstance.InvokeExecutorCallback = - (executor, executorUriTuple, runcontext, frameworkHandle) => - { - frameworkHandle.SendMessage(TestMessageLevel.Error, "DummyMessage"); - }; + new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) + }; + _runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => executorUriExtensionMap; + _runTestsInstance.InvokeExecutorCallback = + (executor, executorUriTuple, runcontext, frameworkHandle) => frameworkHandle.SendMessage(TestMessageLevel.Error, "DummyMessage"); - this.runTestsInstance.RunTests(); + _runTestsInstance.RunTests(); - this.mockTestRunEventsHandler.Verify(re => re.HandleLogMessage(TestMessageLevel.Error, "DummyMessage")); - } + _mockTestRunEventsHandler.Verify(re => re.HandleLogMessage(TestMessageLevel.Error, "DummyMessage")); + } - [TestMethod] - public void RunTestsShouldCreateSTAThreadIfExecutionThreadApartmentStateIsSTA() - { - this.SetupForExecutionThreadApartmentStateTests(PlatformApartmentState.STA); - this.runTestsInstance.RunTests(); - this.mockThread.Verify(t => t.Run(It.IsAny(), PlatformApartmentState.STA, true)); - } + [TestMethod] + public void RunTestsShouldCreateStaThreadIfExecutionThreadApartmentStateIsSta() + { + SetupForExecutionThreadApartmentStateTests(PlatformApartmentState.STA); + _runTestsInstance.RunTests(); + _mockThread.Verify(t => t.Run(It.IsAny(), PlatformApartmentState.STA, true)); + } - [TestMethod] - public void RunTestsShouldSendMetricsOnTestRunComplete() - { - TestRunCompleteEventArgs receivedRunCompleteArgs = null; - var mockMetricsCollector = new Mock(); - - var dict = new Dictionary(); - dict.Add("DummyMessage", "DummyValue"); - - // Setup mocks. - mockMetricsCollector.Setup(mc => mc.Metrics).Returns(dict); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollector.Object); - - this.mockTestRunEventsHandler.Setup( - treh => - treh.HandleTestRunComplete( - It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>())) - .Callback( - ( - TestRunCompleteEventArgs complete, - TestRunChangedEventArgs stats, - ICollection attachments, - ICollection executorUris) => - { - receivedRunCompleteArgs = complete; - }); - - // Act. - this.runTestsInstance.RunTests(); - - // Assert. - Assert.IsNotNull(receivedRunCompleteArgs.Metrics); - Assert.IsTrue(receivedRunCompleteArgs.Metrics.Any()); - Assert.IsTrue(receivedRunCompleteArgs.Metrics.ContainsKey("DummyMessage")); - } + [TestMethod] + public void RunTestsShouldSendMetricsOnTestRunComplete() + { + TestRunCompleteEventArgs receivedRunCompleteArgs = null; + var mockMetricsCollector = new Mock(); - [TestMethod] - public void RunTestsShouldCollectMetrics() + var dict = new Dictionary { - var mockMetricsCollector = new Mock(); - var dict = new Dictionary(); - dict.Add("DummyMessage", "DummyValue"); - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; - var executorUriExtensionMap = new List> - { - new Tuple(new Uri(BadBaseRunTestsExecutorUri), assemblyLocation), - new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) - }; - - // Setup mocks. - this.runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => { return executorUriExtensionMap; }; - this.runTestsInstance.InvokeExecutorCallback = - (executor, executorUriExtensionTuple, runContext, frameworkHandle) => - { - var testCase = new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll"); - var testResult = new Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult(testCase); - this.runTestsInstance.GetTestRunCache.OnNewTestResult(testResult); - }; - mockMetricsCollector.Setup(mc => mc.Metrics).Returns(dict); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollector.Object); - - // Act. - this.runTestsInstance.RunTests(); - - // Verify. - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TotalTestsRun, It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.RunState, It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.NumberOfAdapterUsedToRunTests, It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringExecution, It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenByAllAdaptersInSec, It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(string.Concat(TelemetryDataConstants.TimeTakenToRunTestsByAnAdapter, ".", new Uri(BadBaseRunTestsExecutorUri)), It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(string.Concat(TelemetryDataConstants.TotalTestsRanByAdapter, ".", new Uri(BadBaseRunTestsExecutorUri)), It.IsAny()), Times.Once); - } + { "DummyMessage", "DummyValue" } + }; - [TestMethod] - public void RunTestsShouldNotCreateThreadIfExecutionThreadApartmentStateIsMTA() - { - this.SetupForExecutionThreadApartmentStateTests(PlatformApartmentState.MTA); - this.runTestsInstance.RunTests(); + // Setup mocks. + mockMetricsCollector.Setup(mc => mc.Metrics).Returns(dict); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollector.Object); - this.mockThread.Verify(t => t.Run(It.IsAny(), PlatformApartmentState.STA, true), Times.Never); - } + _mockTestRunEventsHandler.Setup( + treh => + treh.HandleTestRunComplete( + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>())) + .Callback( + ( + TestRunCompleteEventArgs complete, + TestRunChangedEventArgs stats, + ICollection attachments, + ICollection executorUris) => receivedRunCompleteArgs = complete); + + // Act. + _runTestsInstance.RunTests(); + + // Assert. + Assert.IsNotNull(receivedRunCompleteArgs.Metrics); + Assert.IsTrue(receivedRunCompleteArgs.Metrics.Any()); + Assert.IsTrue(receivedRunCompleteArgs.Metrics.ContainsKey("DummyMessage")); + } - [TestMethod] - public void RunTestsShouldRunTestsInMTAThreadWhenRunningInSTAThreadFails() + [TestMethod] + public void RunTestsShouldCollectMetrics() + { + var mockMetricsCollector = new Mock(); + var dict = new Dictionary { - this.SetupForExecutionThreadApartmentStateTests(PlatformApartmentState.STA); - this.mockThread.Setup( - mt => mt.Run(It.IsAny(), PlatformApartmentState.STA, It.IsAny())).Throws(); - bool isInvokeExecutorCalled = false; - this.runTestsInstance.InvokeExecutorCallback = - (executor, executorUriTuple, runcontext, frameworkHandle) => - { - isInvokeExecutorCalled = true; - }; - this.runTestsInstance.RunTests(); - - Assert.IsTrue(isInvokeExecutorCalled, "InvokeExecutor() should be called when STA thread creation fails."); - this.mockThread.Verify(t => t.Run(It.IsAny(), PlatformApartmentState.STA, true), Times.Once); - } - - [TestMethod] - public void CancelShouldCreateSTAThreadIfExecutionThreadApartmentStateIsSTA() + { "DummyMessage", "DummyValue" } + }; + var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var executorUriExtensionMap = new List> { - this.SetupForExecutionThreadApartmentStateTests(PlatformApartmentState.STA); - this.mockThread.Setup(mt => mt.Run(It.IsAny(), PlatformApartmentState.STA, It.IsAny())) - .Callback((action, start, waitForCompletion) => - { - if (waitForCompletion) - { - // Callback for RunTests(). - this.runTestsInstance.Cancel(); - } - }); + new Tuple(new Uri(BadBaseRunTestsExecutorUri), assemblyLocation), + new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) + }; + + // Setup mocks. + _runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => executorUriExtensionMap; + _runTestsInstance.InvokeExecutorCallback = + (executor, executorUriExtensionTuple, runContext, frameworkHandle) => + { + var testCase = new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll"); + var testResult = new OMTestResult(testCase); + _runTestsInstance.GetTestRunCache.OnNewTestResult(testResult); + }; + mockMetricsCollector.Setup(mc => mc.Metrics).Returns(dict); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollector.Object); + + // Act. + _runTestsInstance.RunTests(); + + // Verify. + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TotalTestsRun, It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.RunState, It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.NumberOfAdapterUsedToRunTests, It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringExecution, It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenByAllAdaptersInSec, It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(string.Concat(TelemetryDataConstants.TimeTakenToRunTestsByAnAdapter, ".", new Uri(BadBaseRunTestsExecutorUri)), It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(string.Concat(TelemetryDataConstants.TotalTestsRanByAdapter, ".", new Uri(BadBaseRunTestsExecutorUri)), It.IsAny()), Times.Once); + } - this.runTestsInstance.RunTests(); - this.mockThread.Verify( - t => t.Run(It.IsAny(), PlatformApartmentState.STA, It.IsAny()), - Times.Exactly(2), - "Both RunTests() and Cancel() should create STA thread."); - } + [TestMethod] + public void RunTestsShouldNotCreateThreadIfExecutionThreadApartmentStateIsMta() + { + SetupForExecutionThreadApartmentStateTests(PlatformApartmentState.MTA); + _runTestsInstance.RunTests(); - #endregion + _mockThread.Verify(t => t.Run(It.IsAny(), PlatformApartmentState.STA, true), Times.Never); + } - #region Private Methods + [TestMethod] + public void RunTestsShouldRunTestsInMtaThreadWhenRunningInStaThreadFails() + { + SetupForExecutionThreadApartmentStateTests(PlatformApartmentState.STA); + _mockThread.Setup( + mt => mt.Run(It.IsAny(), PlatformApartmentState.STA, It.IsAny())).Throws(); + bool isInvokeExecutorCalled = false; + _runTestsInstance.InvokeExecutorCallback = + (executor, executorUriTuple, runcontext, frameworkHandle) => isInvokeExecutorCalled = true; + _runTestsInstance.RunTests(); + + Assert.IsTrue(isInvokeExecutorCalled, "InvokeExecutor() should be called when STA thread creation fails."); + _mockThread.Verify(t => t.Run(It.IsAny(), PlatformApartmentState.STA, true), Times.Once); + } - private void SetupExecutorUriMock() - { - var executorUriExtensionMap = new List> + [TestMethod] + public void CancelShouldCreateStaThreadIfExecutionThreadApartmentStateIsSta() + { + SetupForExecutionThreadApartmentStateTests(PlatformApartmentState.STA); + _mockThread.Setup(mt => mt.Run(It.IsAny(), PlatformApartmentState.STA, It.IsAny())) + .Callback((action, start, waitForCompletion) => { - new Tuple(new Uri(BaseRunTestsExecutorUri), Microsoft.VisualStudio.TestPlatform.ObjectModel.Constants.UnspecifiedAdapterPath) - }; - LazyExtension receivedExecutor = null; - - // Setup mocks. - this.runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => { return executorUriExtensionMap; }; - this.runTestsInstance.InvokeExecutorCallback = - (executor, executorUriExtensionTuple, runContext, frameworkHandle) => + if (waitForCompletion) { - receivedExecutor = executor; - }; - } + // Callback for RunTests(). + _runTestsInstance.Cancel(); + } + }); + + _runTestsInstance.RunTests(); + _mockThread.Verify( + t => t.Run(It.IsAny(), PlatformApartmentState.STA, It.IsAny()), + Times.Exactly(2), + "Both RunTests() and Cancel() should create STA thread."); + } + + #endregion - private void SetupForExecutionThreadApartmentStateTests(PlatformApartmentState apartmentState) + #region Private Methods + + private void SetupExecutorUriMock() + { + var executorUriExtensionMap = new List> { - this.mockThread = new Mock(); + new Tuple(new Uri(BaseRunTestsExecutorUri), Constants.UnspecifiedAdapterPath) + }; + LazyExtension receivedExecutor = null; + + // Setup mocks. + _runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => executorUriExtensionMap; + _runTestsInstance.InvokeExecutorCallback = + (executor, executorUriExtensionTuple, runContext, frameworkHandle) => receivedExecutor = executor; + } + + private void SetupForExecutionThreadApartmentStateTests(PlatformApartmentState apartmentState) + { + _mockThread = new Mock(); - this.runTestsInstance = new TestableBaseRunTests( - this.mockRequestData.Object, - null, - $@" + _runTestsInstance = new TestableBaseRunTests( + _mockRequestData.Object, + null, + $@" {apartmentState} ", - this.testExecutionContext, - null, - this.mockTestRunEventsHandler.Object, - this.mockTestPlatformEventSource.Object, - null, - this.mockThread.Object, - this.mockDataSerializer.Object); - - TestPluginCacheHelper.SetupMockExtensions(new string[] { typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location }, () => { }); - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; - var executorUriExtensionMap = new List> - { - new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) - }; - this.runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => { return executorUriExtensionMap; }; + _testExecutionContext, + null, + _mockTestRunEventsHandler.Object, + _mockTestPlatformEventSource.Object, + null, + _mockThread.Object, + _mockDataSerializer.Object); + + TestPluginCacheHelper.SetupMockExtensions(new string[] { typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location }, () => { }); + var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var executorUriExtensionMap = new List> + { + new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) + }; + _runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => executorUriExtensionMap; + } + + private void SetUpTestRunEvents(string package = null, bool setupHandleTestRunComplete = true) + { + if (setupHandleTestRunComplete) + { + SetupHandleTestRunComplete(); + } + else + { + SetupHandleTestRunStatsChange(); } - private void SetUpTestRunEvents(string package = null, bool setupHandleTestRunComplete = true) + SetupDataSerializer(); + + _runTestsInstance = _runTestsInstance = new TestableBaseRunTests( + _mockRequestData.Object, + package, + null, + _testExecutionContext, + null, + _mockTestRunEventsHandler.Object, + _mockTestPlatformEventSource.Object, + null, + new PlatformThread(), + _mockDataSerializer.Object); + + var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var executorUriExtensionMap = new List> { - if (setupHandleTestRunComplete) - { - this.SetupHandleTestRunComplete(); - } - else - { - this.SetupHandleTestRunStatsChange(); - } + new Tuple(new Uri(BadBaseRunTestsExecutorUri), assemblyLocation), + new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) + }; - this.SetupDataSerializer(); + // Setup mocks. + SetupExecutorCallback(executorUriExtensionMap); + } - this.runTestsInstance = this.runTestsInstance = new TestableBaseRunTests( - this.mockRequestData.Object, - package, - null, - this.testExecutionContext, - null, - this.mockTestRunEventsHandler.Object, - this.mockTestPlatformEventSource.Object, - null, - new PlatformThread(), - this.mockDataSerializer.Object); - - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; - var executorUriExtensionMap = new List> + private void SetupExecutorCallback(List> executorUriExtensionMap) + { + _runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => executorUriExtensionMap; + _runTestsInstance.InvokeExecutorCallback = + (executor, executorUriExtensionTuple, runContext, frameworkHandle) => { - new Tuple(new Uri(BadBaseRunTestsExecutorUri), assemblyLocation), - new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) + var testCase = new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll"); + var testResult = new OMTestResult(testCase); + _inProgressTestCase = new TestCase("x.y.z2", new Uri("uri://dummy"), "x.dll"); + + _runTestsInstance.GetTestRunCache.OnTestStarted(_inProgressTestCase); + _runTestsInstance.GetTestRunCache.OnNewTestResult(testResult); }; + } - // Setup mocks. - this.SetupExecutorCallback(executorUriExtensionMap); - } + private void SetupDataSerializer() + { + _mockDataSerializer.Setup(d => d.Clone(It.IsAny())) + .Returns(t => JsonDataSerializer.Instance.Clone(t)); - private void SetupExecutorCallback(List> executorUriExtensionMap) - { - this.runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => { return executorUriExtensionMap; }; - this.runTestsInstance.InvokeExecutorCallback = - (executor, executorUriExtensionTuple, runContext, frameworkHandle) => - { - var testCase = new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll"); - var testResult = new Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult(testCase); - this.inProgressTestCase = new TestCase("x.y.z2", new Uri("uri://dummy"), "x.dll"); + _mockDataSerializer.Setup(d => d.Clone(It.IsAny())) + .Returns(t => JsonDataSerializer.Instance.Clone(t)); + } - this.runTestsInstance.GetTestRunCache.OnTestStarted(inProgressTestCase); - this.runTestsInstance.GetTestRunCache.OnNewTestResult(testResult); - }; - } + private void SetupHandleTestRunStatsChange() + { + _testExecutionContext.FrequencyOfRunStatsChangeEvent = 2; + _mockTestRunEventsHandler + .Setup(treh => treh.HandleTestRunStatsChange(It.IsAny())) + .Callback((TestRunChangedEventArgs stats) => _receivedRunStatusArgs = stats); + } - private void SetupDataSerializer() - { - this.mockDataSerializer.Setup(d => d.Clone(It.IsAny())) - .Returns(t => JsonDataSerializer.Instance.Clone(t)); + private void SetupHandleTestRunComplete() + { + _mockTestRunEventsHandler.Setup( + treh => + treh.HandleTestRunComplete( + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>())) + .Callback( + ( + TestRunCompleteEventArgs complete, + TestRunChangedEventArgs stats, + ICollection attachments, + ICollection executorUris) => + { + _receivedRunCompleteArgs = complete; + _receivedRunStatusArgs = stats; + _receivedattachments = attachments; + _receivedExecutorUris = executorUris; + }); + } - this.mockDataSerializer.Setup(d => d.Clone(It.IsAny())) - .Returns(t => JsonDataSerializer.Instance.Clone(t)); - } + #endregion - private void SetupHandleTestRunStatsChange() - { - this.testExecutionContext.FrequencyOfRunStatsChangeEvent = 2; - this.mockTestRunEventsHandler - .Setup(treh => treh.HandleTestRunStatsChange(It.IsAny())) - .Callback((TestRunChangedEventArgs stats) => { receivedRunStatusArgs = stats; }); - } + #region Testable Implementation - private void SetupHandleTestRunComplete() + private class TestableBaseRunTests : BaseRunTests + { + public TestableBaseRunTests( + IRequestData requestData, + string package, + string runSettings, + TestExecutionContext testExecutionContext, + ITestCaseEventsHandler testCaseEventsHandler, + ITestRunEventsHandler testRunEventsHandler, + ITestPlatformEventSource testPlatformEventSource, + ITestEventsPublisher testEventsPublisher, + IThread platformThread, + IDataSerializer dataSerializer) + : base( + requestData, + package, + runSettings, + testExecutionContext, + testCaseEventsHandler, + testRunEventsHandler, + testPlatformEventSource, + testEventsPublisher, + platformThread, + dataSerializer) { - this.mockTestRunEventsHandler.Setup( - treh => - treh.HandleTestRunComplete( - It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>())) - .Callback( - ( - TestRunCompleteEventArgs complete, - TestRunChangedEventArgs stats, - ICollection attachments, - ICollection executorUris) => - { - receivedRunCompleteArgs = complete; - this.receivedRunStatusArgs = stats; - receivedattachments = attachments; - receivedExecutorUris = executorUris; - }); + _testCaseEventsHandler = testCaseEventsHandler; } - #endregion - - #region Testable Implementation - - private class TestableBaseRunTests : BaseRunTests - { - public TestableBaseRunTests( - IRequestData requestData, - string package, - string runSettings, - TestExecutionContext testExecutionContext, - ITestCaseEventsHandler testCaseEventsHandler, - ITestRunEventsHandler testRunEventsHandler, - ITestPlatformEventSource testPlatformEventSource, - ITestEventsPublisher testEventsPublisher, - IThread platformThread, - IDataSerializer dataSerializer) - : base( - requestData, - package, - runSettings, - testExecutionContext, - testCaseEventsHandler, - testRunEventsHandler, - testPlatformEventSource, - testEventsPublisher, - platformThread, - dataSerializer) - { - this.testCaseEventsHandler = testCaseEventsHandler; - } + private readonly ITestCaseEventsHandler _testCaseEventsHandler; - private ITestCaseEventsHandler testCaseEventsHandler; + public Action BeforeRaisingTestRunCompleteCallback { get; set; } - public Action BeforeRaisingTestRunCompleteCallback { get; set; } + public Func>> GetExecutorUriExtensionMapCallback { get; set; } - public Func>> GetExecutorUriExtensionMapCallback { get; set; } + public + Action + , Tuple, RunContext, + IFrameworkHandle> InvokeExecutorCallback + { get; set; } - public - Action - , Tuple, RunContext, - IFrameworkHandle> InvokeExecutorCallback - { get; set; } + /// + /// Gets the run settings. + /// + public string GetRunSettings => RunSettings; - /// - /// Gets the run settings. - /// - public string GetRunSettings => this.RunSettings; + /// + /// Gets the test execution context. + /// + public TestExecutionContext GetTestExecutionContext => TestExecutionContext; - /// - /// Gets the test execution context. - /// - public TestExecutionContext GetTestExecutionContext => this.TestExecutionContext; + /// + /// Gets the test run events handler. + /// + public ITestRunEventsHandler GetTestRunEventsHandler => TestRunEventsHandler; - /// - /// Gets the test run events handler. - /// - public ITestRunEventsHandler GetTestRunEventsHandler => this.TestRunEventsHandler; + /// + /// Gets the test run cache. + /// + public ITestRunCache GetTestRunCache => TestRunCache; - /// - /// Gets the test run cache. - /// - public ITestRunCache GetTestRunCache => this.TestRunCache; + public bool GetIsCancellationRequested => IsCancellationRequested; - public bool GetIsCancellationRequested => this.IsCancellationRequested; + public RunContext GetRunContext => RunContext; - public RunContext GetRunContext => this.RunContext; + public FrameworkHandle GetFrameworkHandle => FrameworkHandle; - public FrameworkHandle GetFrameworkHandle => this.FrameworkHandle; + public ICollection GetExecutorUrisThatRanTests => ExecutorUrisThatRanTests; - public ICollection GetExecutorUrisThatRanTests => this.ExecutorUrisThatRanTests; - - protected override void BeforeRaisingTestRunComplete(bool exceptionsHitDuringRunTests) - { - this.BeforeRaisingTestRunCompleteCallback?.Invoke(exceptionsHitDuringRunTests); - } + protected override void BeforeRaisingTestRunComplete(bool exceptionsHitDuringRunTests) + { + BeforeRaisingTestRunCompleteCallback?.Invoke(exceptionsHitDuringRunTests); + } - protected override IEnumerable> GetExecutorUriExtensionMap(IFrameworkHandle testExecutorFrameworkHandle, RunContext runContext) - { - return this.GetExecutorUriExtensionMapCallback?.Invoke(testExecutorFrameworkHandle, runContext); - } + protected override IEnumerable> GetExecutorUriExtensionMap(IFrameworkHandle testExecutorFrameworkHandle, RunContext runContext) + { + return GetExecutorUriExtensionMapCallback?.Invoke(testExecutorFrameworkHandle, runContext); + } - protected override void InvokeExecutor(LazyExtension executor, Tuple executorUriExtensionTuple, RunContext runContext, IFrameworkHandle frameworkHandle) - { - this.InvokeExecutorCallback?.Invoke(executor, executorUriExtensionTuple, runContext, frameworkHandle); - } + protected override void InvokeExecutor(LazyExtension executor, Tuple executorUriExtensionTuple, RunContext runContext, IFrameworkHandle frameworkHandle) + { + InvokeExecutorCallback?.Invoke(executor, executorUriExtensionTuple, runContext, frameworkHandle); + } - protected override void SendSessionEnd() - { - this.testCaseEventsHandler?.SendSessionEnd(); - } + protected override void SendSessionEnd() + { + _testCaseEventsHandler?.SendSessionEnd(); + } - protected override void SendSessionStart() - { - this.testCaseEventsHandler?.SendSessionStart(new Dictionary { { "TestSources", new List() { "1.dll" } } }); - } + protected override void SendSessionStart() + { + _testCaseEventsHandler?.SendSessionStart(new Dictionary { { "TestSources", new List() { "1.dll" } } }); + } - protected override bool ShouldAttachDebuggerToTestHost( - LazyExtension executor, - Tuple executorUri, - RunContext runContext) - { - return false; - } + protected override bool ShouldAttachDebuggerToTestHost( + LazyExtension executor, + Tuple executorUri, + RunContext runContext) + { + return false; } + } - [ExtensionUri(BaseRunTestsExecutorUri)] - private class TestExecutor : ITestExecutor + [ExtensionUri(BaseRunTestsExecutorUri)] + private class TestExecutor : ITestExecutor + { + public void Cancel() { - public void Cancel() - { - } + } - public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - } + public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) + { + } - public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - } + public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) + { } + } - [ExtensionUri(BadBaseRunTestsExecutorUri)] - private class BadTestExecutor : ITestExecutor + [ExtensionUri(BadBaseRunTestsExecutorUri)] + private class BadTestExecutor : ITestExecutor + { + public void Cancel() { - public void Cancel() - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); + } - public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - throw new NotImplementedException(); - } + public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) + { + throw new NotImplementedException(); + } - public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - throw new NotImplementedException(); - } + public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) + { + throw new NotImplementedException(); } + } - #endregion + #endregion - } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs index ce5d24ea30..f7bd098d83 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs @@ -1,455 +1,456 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Execution -{ - using System; - using System.Collections.Generic; - using System.Reflection; - using System.Xml; - - using Microsoft.TestPlatform.TestUtilities; - - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.Common.SettingsProvider; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - using static RunTestsWithSourcesTests; - - [TestClass] - public class ExecutionManagerTests - { - private ExecutionManager executionManager; - private TestExecutionContext testExecutionContext; - private Mock mockRequestData; - private TestSessionMessageLogger sessionLogger; +namespace TestPlatform.CrossPlatEngine.UnitTests.Execution; - [TestInitialize] - public void TestInit() - { - this.mockRequestData = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new NoOpMetricsCollection()); - this.sessionLogger = TestSessionMessageLogger.Instance; - this.executionManager = new ExecutionManager(new RequestData - { - MetricsCollection = new NoOpMetricsCollection() - }); - - TestPluginCache.Instance = null; - - testExecutionContext = new TestExecutionContext( - frequencyOfRunStatsChangeEvent: 1, - runStatsChangeEventTimeout: TimeSpan.MaxValue, - inIsolation: false, - keepAlive: false, - isDataCollectionEnabled: false, - areTestCaseLevelEventsRequired: false, - hasTestRun: false, - isDebug: false, - testCaseFilter: null, - filterOptions: null); - } +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Xml; - [TestCleanup] - public void TestCleanup() - { - RunTestWithSourcesExecutor.RunTestsWithSourcesCallback = null; - RunTestWithSourcesExecutor.RunTestsWithTestsCallback = null; +using Microsoft.TestPlatform.TestUtilities; - TestDiscoveryExtensionManager.Destroy(); - TestExecutorExtensionManager.Destroy(); - SettingsProviderExtensionManager.Destroy(); - } +using Microsoft.VisualStudio.TestPlatform.Common; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Microsoft.VisualStudio.TestPlatform.Common.Logging; +using Microsoft.VisualStudio.TestPlatform.Common.SettingsProvider; +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestMethod] - public void InitializeShouldLoadAndInitializeAllExtensions() +using Moq; + +using static RunTestsWithSourcesTests; + +[TestClass] +public class ExecutionManagerTests +{ + private ExecutionManager _executionManager; + private TestExecutionContext _testExecutionContext; + private Mock _mockRequestData; + private TestSessionMessageLogger _sessionLogger; + + [TestInitialize] + public void TestInit() + { + _mockRequestData = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new NoOpMetricsCollection()); + _sessionLogger = TestSessionMessageLogger.Instance; + _executionManager = new ExecutionManager(new RequestData { - var commonAssemblyLocation = typeof(ExecutionManagerTests).GetTypeInfo().Assembly.Location; - var mockTestMessageEventHandler = new Mock(); - TestPluginCacheHelper.SetupMockExtensions( - new string[] { commonAssemblyLocation }, - () => { }); + MetricsCollection = new NoOpMetricsCollection() + }); + + TestPluginCache.Instance = null; + + _testExecutionContext = new TestExecutionContext( + frequencyOfRunStatsChangeEvent: 1, + runStatsChangeEventTimeout: TimeSpan.MaxValue, + inIsolation: false, + keepAlive: false, + isDataCollectionEnabled: false, + areTestCaseLevelEventsRequired: false, + hasTestRun: false, + isDebug: false, + testCaseFilter: null, + filterOptions: null); + } + [TestCleanup] + public void TestCleanup() + { + RunTestWithSourcesExecutor.RunTestsWithSourcesCallback = null; + RunTestWithSourcesExecutor.RunTestsWithTestsCallback = null; - this.executionManager.Initialize(new List { commonAssemblyLocation }, mockTestMessageEventHandler.Object); + TestDiscoveryExtensionManager.Destroy(); + TestExecutorExtensionManager.Destroy(); + SettingsProviderExtensionManager.Destroy(); + } - Assert.IsNotNull(TestPluginCache.Instance.TestExtensions); + [TestMethod] + public void InitializeShouldLoadAndInitializeAllExtensions() + { + var commonAssemblyLocation = typeof(ExecutionManagerTests).GetTypeInfo().Assembly.Location; + var mockTestMessageEventHandler = new Mock(); + TestPluginCacheHelper.SetupMockExtensions( + new string[] { commonAssemblyLocation }, + () => { }); - // Executors - Assert.IsTrue(TestPluginCache.Instance.TestExtensions.TestExecutors.Count > 0); - var allExecutors = TestExecutorExtensionManager.Create().TestExtensions; - foreach (var executor in allExecutors) - { - Assert.IsTrue(executor.IsExtensionCreated); - } + _executionManager.Initialize(new List { commonAssemblyLocation }, mockTestMessageEventHandler.Object); - // Settings Providers - Assert.IsTrue(TestPluginCache.Instance.TestExtensions.TestSettingsProviders.Count > 0); - var settingsProviders = SettingsProviderExtensionManager.Create().SettingsProvidersMap.Values; + Assert.IsNotNull(TestPluginCache.Instance.TestExtensions); - foreach (var provider in settingsProviders) - { - Assert.IsTrue(provider.IsExtensionCreated); - } - } + // Executors + Assert.IsTrue(TestPluginCache.Instance.TestExtensions.TestExecutors.Count > 0); + var allExecutors = TestExecutorExtensionManager.Create().TestExtensions; - [TestMethod] - public void StartTestRunShouldRunTestsInTheProvidedSources() + foreach (var executor in allExecutors) { - var assemblyLocation = typeof(ExecutionManagerTests).GetTypeInfo().Assembly.Location; - TestPluginCacheHelper.SetupMockExtensions( - new string[] { assemblyLocation }, - () => { }); - TestPluginCache.Instance.DiscoverTestExtensions(TestPlatformConstants.TestAdapterEndsWithPattern); - TestPluginCache.Instance.DiscoverTestExtensions(TestPlatformConstants.TestAdapterEndsWithPattern); - - - var adapterSourceMap = new Dictionary>(); - adapterSourceMap.Add(assemblyLocation, new List { assemblyLocation }); - - var mockTestRunEventsHandler = new Mock(); - - var isExecutorCalled = false; - RunTestWithSourcesExecutor.RunTestsWithSourcesCallback = (s, rc, fh) => - { - isExecutorCalled = true; - var tr = - new Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult( - new Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase( - "A.C.M", - new Uri("e://d/"), - "A.dll")); - fh.RecordResult(tr); - }; - - this.executionManager.StartTestRun(adapterSourceMap, null, null, testExecutionContext, null, mockTestRunEventsHandler.Object); - - Assert.IsTrue(isExecutorCalled); - mockTestRunEventsHandler.Verify( - treh => treh.HandleTestRunComplete(It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>()), Times.Once); - - // Also verify that run stats are passed through. - mockTestRunEventsHandler.Verify(treh => treh.HandleTestRunStatsChange(It.IsAny()), Times.Once); + Assert.IsTrue(executor.IsExtensionCreated); } - [TestMethod] - public void StartTestRunShouldRunTestsForTheProvidedTests() + // Settings Providers + Assert.IsTrue(TestPluginCache.Instance.TestExtensions.TestSettingsProviders.Count > 0); + var settingsProviders = SettingsProviderExtensionManager.Create().SettingsProvidersMap.Values; + + foreach (var provider in settingsProviders) { - var assemblyLocation = typeof(ExecutionManagerTests).GetTypeInfo().Assembly.Location; - - var tests = new List - { - new TestCase("A.C.M1", new Uri(RunTestsWithSourcesTestsExecutorUri), assemblyLocation) - }; - - var mockTestRunEventsHandler = new Mock(); - - var isExecutorCalled = false; - RunTestWithSourcesExecutor.RunTestsWithTestsCallback = (s, rc, fh) => - { - isExecutorCalled = true; - var tr = - new Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult( - new Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase( - "A.C.M", - new Uri(RunTestsWithSourcesTestsExecutorUri), - "A.dll")); - fh.RecordResult(tr); - }; - TestPluginCacheHelper.SetupMockExtensions(new string[] { assemblyLocation }, () => { }); - - - this.executionManager.StartTestRun(tests, null, null, testExecutionContext, null, mockTestRunEventsHandler.Object); - - Assert.IsTrue(isExecutorCalled); - mockTestRunEventsHandler.Verify( - treh => treh.HandleTestRunComplete(It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>()), Times.Once); - - // Also verify that run stats are passed through. - mockTestRunEventsHandler.Verify(treh => treh.HandleTestRunStatsChange(It.IsAny()), Times.Once); + Assert.IsTrue(provider.IsExtensionCreated); } + } - [TestMethod] - public void StartTestRunShouldAbortTheRunIfAnyExceptionComesForTheProvidedTests() - { - var mockTestRunEventsHandler = new Mock(); + [TestMethod] + public void StartTestRunShouldRunTestsInTheProvidedSources() + { + var assemblyLocation = typeof(ExecutionManagerTests).GetTypeInfo().Assembly.Location; + TestPluginCacheHelper.SetupMockExtensions( + new string[] { assemblyLocation }, + () => { }); + TestPluginCache.Instance.DiscoverTestExtensions(TestPlatformConstants.TestAdapterEndsWithPattern); + TestPluginCache.Instance.DiscoverTestExtensions(TestPlatformConstants.TestAdapterEndsWithPattern); - // Call StartTestRun with faulty runsettings so that it will throw exception - this.executionManager.StartTestRun(new List(), null, @"-1", testExecutionContext, null, mockTestRunEventsHandler.Object); - // Verify that TestRunComplete get called and error message are getting logged - mockTestRunEventsHandler.Verify(treh => treh.HandleTestRunComplete(It.IsAny(), null, null, null), Times.Once); - mockTestRunEventsHandler.Verify(treh => treh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); - } + var adapterSourceMap = new Dictionary> + { + { assemblyLocation, new List { assemblyLocation } } + }; + + var mockTestRunEventsHandler = new Mock(); - [TestMethod] - public void StartTestRunShouldAbortTheRunIfAnyExceptionComesForTheProvidedSources() + var isExecutorCalled = false; + RunTestWithSourcesExecutor.RunTestsWithSourcesCallback = (s, rc, fh) => { - var mockTestRunEventsHandler = new Mock(); + isExecutorCalled = true; + var tr = + new Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult( + new TestCase( + "A.C.M", + new Uri("e://d/"), + "A.dll")); + fh.RecordResult(tr); + }; + + _executionManager.StartTestRun(adapterSourceMap, null, null, _testExecutionContext, null, mockTestRunEventsHandler.Object); + + Assert.IsTrue(isExecutorCalled); + mockTestRunEventsHandler.Verify( + treh => treh.HandleTestRunComplete(It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>()), Times.Once); + + // Also verify that run stats are passed through. + mockTestRunEventsHandler.Verify(treh => treh.HandleTestRunStatsChange(It.IsAny()), Times.Once); + } - // Call StartTestRun with faulty runsettings so that it will throw exception - this.executionManager.StartTestRun(new Dictionary>(), null, @"-1", testExecutionContext, null, mockTestRunEventsHandler.Object); + [TestMethod] + public void StartTestRunShouldRunTestsForTheProvidedTests() + { + var assemblyLocation = typeof(ExecutionManagerTests).GetTypeInfo().Assembly.Location; - // Verify that TestRunComplete get called and error message are getting logged - mockTestRunEventsHandler.Verify(treh => treh.HandleTestRunComplete(It.IsAny(), null, null, null), Times.Once); - mockTestRunEventsHandler.Verify(treh => treh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); - } + var tests = new List + { + new TestCase("A.C.M1", new Uri(RunTestsWithSourcesTestsExecutorUri), assemblyLocation) + }; - //[TestMethod] - //public void InitializeShouldVerifyWarningMessageIfAdapterFailedToLoad() - //{ - // var assemblyLocation = typeof(ExecutionManagerTests).GetTypeInfo().Assembly.Location; - // var mockLogger = new Mock(); - // TestPluginCacheHelper.SetupMockExtensions( - // new string[] { assemblyLocation }, - // () => { }); - // //Act - // this.executionManager.Initialize(new List { assemblyLocation }, mockLogger.Object); - - // //when handler instance returns warning - // sessionLogger.SendMessage(TestMessageLevel.Warning, "verify that it is downgraded to warning"); - - // // Verify. - // mockLogger.Verify(rd => rd.HandleLogMessage(TestMessageLevel.Warning, "verify that it is downgraded to warning"), Times.Once); - //} - - [TestMethod] - public void InitializeShouldVerifyTheHandlerInitializationWhenAdapterIsFailedToLoad() + var mockTestRunEventsHandler = new Mock(); + + var isExecutorCalled = false; + RunTestWithSourcesExecutor.RunTestsWithTestsCallback = (s, rc, fh) => { - var mockLogger = new Mock(); + isExecutorCalled = true; + var tr = + new Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult( + new TestCase( + "A.C.M", + new Uri(RunTestsWithSourcesTestsExecutorUri), + "A.dll")); + fh.RecordResult(tr); + }; + TestPluginCacheHelper.SetupMockExtensions(new string[] { assemblyLocation }, () => { }); + + + _executionManager.StartTestRun(tests, null, null, _testExecutionContext, null, mockTestRunEventsHandler.Object); + + Assert.IsTrue(isExecutorCalled); + mockTestRunEventsHandler.Verify( + treh => treh.HandleTestRunComplete(It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>()), Times.Once); + + // Also verify that run stats are passed through. + mockTestRunEventsHandler.Verify(treh => treh.HandleTestRunStatsChange(It.IsAny()), Times.Once); + } + + [TestMethod] + public void StartTestRunShouldAbortTheRunIfAnyExceptionComesForTheProvidedTests() + { + var mockTestRunEventsHandler = new Mock(); - //when handler instance is null - sessionLogger.SendMessage(It.IsAny(), "verify that the HandleLogMessage method will not be invoked when handler is not initialized"); + // Call StartTestRun with faulty runsettings so that it will throw exception + _executionManager.StartTestRun(new List(), null, @"-1", _testExecutionContext, null, mockTestRunEventsHandler.Object); - // Verify. - mockLogger.Verify(rd => rd.HandleLogMessage(It.IsAny(), "verify that the HandleLogMessage method will not be invoked when handler is not initialized"), Times.Never); - } + // Verify that TestRunComplete get called and error message are getting logged + mockTestRunEventsHandler.Verify(treh => treh.HandleTestRunComplete(It.IsAny(), null, null, null), Times.Once); + mockTestRunEventsHandler.Verify(treh => treh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); + } + + [TestMethod] + public void StartTestRunShouldAbortTheRunIfAnyExceptionComesForTheProvidedSources() + { + var mockTestRunEventsHandler = new Mock(); + + // Call StartTestRun with faulty runsettings so that it will throw exception + _executionManager.StartTestRun(new Dictionary>(), null, @"-1", _testExecutionContext, null, mockTestRunEventsHandler.Object); - #region Implementations + // Verify that TestRunComplete get called and error message are getting logged + mockTestRunEventsHandler.Verify(treh => treh.HandleTestRunComplete(It.IsAny(), null, null, null), Times.Once); + mockTestRunEventsHandler.Verify(treh => treh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); + } + + //[TestMethod] + //public void InitializeShouldVerifyWarningMessageIfAdapterFailedToLoad() + //{ + // var assemblyLocation = typeof(ExecutionManagerTests).GetTypeInfo().Assembly.Location; + // var mockLogger = new Mock(); + // TestPluginCacheHelper.SetupMockExtensions( + // new string[] { assemblyLocation }, + // () => { }); + // //Act + // this.executionManager.Initialize(new List { assemblyLocation }, mockLogger.Object); + + // //when handler instance returns warning + // sessionLogger.SendMessage(TestMessageLevel.Warning, "verify that it is downgraded to warning"); + + // // Verify. + // mockLogger.Verify(rd => rd.HandleLogMessage(TestMessageLevel.Warning, "verify that it is downgraded to warning"), Times.Once); + //} + + [TestMethod] + public void InitializeShouldVerifyTheHandlerInitializationWhenAdapterIsFailedToLoad() + { + var mockLogger = new Mock(); + + //when handler instance is null + _sessionLogger.SendMessage(It.IsAny(), "verify that the HandleLogMessage method will not be invoked when handler is not initialized"); + + // Verify. + mockLogger.Verify(rd => rd.HandleLogMessage(It.IsAny(), "verify that the HandleLogMessage method will not be invoked when handler is not initialized"), Times.Never); + } - #region Discoverers + #region Implementations - private abstract class AbstractTestDiscoverer : ITestDiscoverer + #region Discoverers + + private abstract class AbstractTestDiscoverer : ITestDiscoverer + { + public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) { - public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } + } - private class ValidDiscoverer : ITestDiscoverer + private class ValidDiscoverer : ITestDiscoverer + { + public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) { - public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } + } - private class ValidDiscoverer2 : ITestDiscoverer + private class ValidDiscoverer2 : ITestDiscoverer + { + public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) { - public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } + } + + #endregion - #endregion + #region Executors - #region Executors + [ExtensionUri("ValidExecutor")] + private class ValidExecutor : ITestExecutor + { + public void Cancel() + { + throw new NotImplementedException(); + } - [ExtensionUri("ValidExecutor")] - private class ValidExecutor : ITestExecutor + public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) { - public void Cancel() - { - throw new NotImplementedException(); - } - - public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - throw new NotImplementedException(); - } - - public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } - [ExtensionUri("ValidExecutor2")] - private class ValidExecutor2 : ITestExecutor + public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) { - public void Cancel() - { - throw new NotImplementedException(); - } - - public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - throw new NotImplementedException(); - } - - public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } + } - [ExtensionUri("ValidExecutor")] - private class DuplicateExecutor : ITestExecutor + [ExtensionUri("ValidExecutor2")] + private class ValidExecutor2 : ITestExecutor + { + public void Cancel() { - public void Cancel() - { - throw new NotImplementedException(); - } - - public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - throw new NotImplementedException(); - } - - public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } - #endregion + public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) + { + throw new NotImplementedException(); + } - #region Loggers + public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) + { + throw new NotImplementedException(); + } + } - [ExtensionUri("csv")] - private class ValidLogger : ITestLogger + [ExtensionUri("ValidExecutor")] + private class DuplicateExecutor : ITestExecutor + { + public void Cancel() { - public void Initialize(TestLoggerEvents events, string testRunDirectory) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } - [ExtensionUri("docx")] - private class ValidLogger2 : ITestLogger + public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) { - public void Initialize(TestLoggerEvents events, string testRunDirectory) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } - [ExtensionUri("csv")] - private class DuplicateLogger : ITestLogger + public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) { - public void Initialize(TestLoggerEvents events, string testRunDirectory) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } + } - #endregion + #endregion - #region Settings Providers + #region Loggers - [SettingsName("ValidSettingsProvider")] - private class ValidSettingsProvider : ISettingsProvider + [ExtensionUri("csv")] + private class ValidLogger : ITestLogger + { + public void Initialize(TestLoggerEvents events, string testRunDirectory) { - public void Load(XmlReader reader) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } + } - [SettingsName("ValidSettingsProvider2")] - private class ValidSettingsProvider2 : ISettingsProvider + [ExtensionUri("docx")] + private class ValidLogger2 : ITestLogger + { + public void Initialize(TestLoggerEvents events, string testRunDirectory) { - public void Load(XmlReader reader) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } + } - [SettingsName("ValidSettingsProvider")] - private class DuplicateSettingsProvider : ISettingsProvider + [ExtensionUri("csv")] + private class DuplicateLogger : ITestLogger + { + public void Initialize(TestLoggerEvents events, string testRunDirectory) { - public void Load(XmlReader reader) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } + } - #endregion + #endregion - #region DataCollectors + #region Settings Providers - public class InvalidDataCollector : DataCollector + [SettingsName("ValidSettingsProvider")] + private class ValidSettingsProvider : ISettingsProvider + { + public void Load(XmlReader reader) { - public override void Initialize( - XmlElement configurationElement, - DataCollectionEvents events, - DataCollectionSink dataSink, - DataCollectionLogger logger, - DataCollectionEnvironmentContext environmentContext) - { - - } + throw new NotImplementedException(); } + } - /// - /// The a data collector inheriting from another data collector. - /// - [DataCollectorFriendlyName("Foo1")] - [DataCollectorTypeUri("datacollector://foo/bar1")] - public class ADataCollectorInheritingFromAnotherDataCollector : InvalidDataCollector + [SettingsName("ValidSettingsProvider2")] + private class ValidSettingsProvider2 : ISettingsProvider + { + public void Load(XmlReader reader) + { + throw new NotImplementedException(); + } + } + + [SettingsName("ValidSettingsProvider")] + private class DuplicateSettingsProvider : ISettingsProvider + { + public void Load(XmlReader reader) + { + throw new NotImplementedException(); + } + } + + #endregion + + #region DataCollectors + + public class InvalidDataCollector : DataCollector + { + public override void Initialize( + XmlElement configurationElement, + DataCollectionEvents events, + DataCollectionSink dataSink, + DataCollectionLogger logger, + DataCollectionEnvironmentContext environmentContext) { + } + } + + /// + /// The a data collector inheriting from another data collector. + /// + [DataCollectorFriendlyName("Foo1")] + [DataCollectorTypeUri("datacollector://foo/bar1")] + public class ADataCollectorInheritingFromAnotherDataCollector : InvalidDataCollector + { + } - [DataCollectorFriendlyName("Foo")] - [DataCollectorTypeUri("datacollector://foo/bar")] - public class ValidDataCollector : DataCollector + [DataCollectorFriendlyName("Foo")] + [DataCollectorTypeUri("datacollector://foo/bar")] + public class ValidDataCollector : DataCollector + { + public override void Initialize( + XmlElement configurationElement, + DataCollectionEvents events, + DataCollectionSink dataSink, + DataCollectionLogger logger, + DataCollectionEnvironmentContext environmentContext) { - public override void Initialize( - XmlElement configurationElement, - DataCollectionEvents events, - DataCollectionSink dataSink, - DataCollectionLogger logger, - DataCollectionEnvironmentContext environmentContext) - { - - } + } - #endregion + } + #endregion - internal class FaultyTestExecutorPluginInformation : TestExtensionPluginInformation + internal class FaultyTestExecutorPluginInformation : TestExtensionPluginInformation + { + /// + /// Default constructor + /// + /// The Type. + public FaultyTestExecutorPluginInformation(Type type) : base(type) { - /// - /// Default constructor - /// - /// The Type. - public FaultyTestExecutorPluginInformation(Type type) : base(type) - { - throw new Exception(); - } + throw new Exception(); } - #endregion } -} + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/RunTestsWithSourcesTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/RunTestsWithSourcesTests.cs index b8754f6582..768c02c42d 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/RunTestsWithSourcesTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/RunTestsWithSourcesTests.cs @@ -1,401 +1,417 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Execution +namespace TestPlatform.CrossPlatEngine.UnitTests.Execution; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +using TestableImplementations; + +[TestClass] +public class RunTestsWithSourcesTests { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Reflection; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - using TestableImplementations; - - [TestClass] - public class RunTestsWithSourcesTests + private TestableTestRunCache _testableTestRunCache; + private TestExecutionContext _testExecutionContext; + private Mock _mockTestRunEventsHandler; + private TestableRunTestsWithSources _runTestsInstance; + private Mock _mockRequestData; + private Mock _mockMetricsCollection; + + internal const string RunTestsWithSourcesTestsExecutorUri = "executor://RunTestWithSourcesDiscoverer/"; + + [TestInitialize] + public void TestInit() { - private TestableTestRunCache testableTestRunCache; - private TestExecutionContext testExecutionContext; - private Mock mockTestRunEventsHandler; - private TestableRunTestsWithSources runTestsInstance; - private Mock mockRequestData; - private Mock mockMetricsCollection; + _testableTestRunCache = new TestableTestRunCache(); + _testExecutionContext = new TestExecutionContext( + frequencyOfRunStatsChangeEvent: 100, + runStatsChangeEventTimeout: TimeSpan.MaxValue, + inIsolation: false, + keepAlive: false, + isDataCollectionEnabled: false, + areTestCaseLevelEventsRequired: false, + hasTestRun: false, + isDebug: false, + testCaseFilter: null, + filterOptions: null); + _mockTestRunEventsHandler = new Mock(); + _mockMetricsCollection = new Mock(); + _mockRequestData = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(_mockMetricsCollection.Object); + + TestPluginCacheHelper.SetupMockExtensions( + new string[] { typeof(RunTestsWithSourcesTests).GetTypeInfo().Assembly.Location }, + () => { }); + + TestPluginCache.Instance.DiscoverTestExtensions(TestPlatformConstants.TestAdapterEndsWithPattern); + TestPluginCache.Instance.DiscoverTestExtensions(TestPlatformConstants.TestAdapterEndsWithPattern); + } - internal const string RunTestsWithSourcesTestsExecutorUri = "executor://RunTestWithSourcesDiscoverer/"; + [TestCleanup] + public void TestCleanup() + { + RunTestWithSourcesExecutor.RunTestsWithSourcesCallback = null; + TestPluginCacheHelper.ResetExtensionsCache(); + } - [TestInitialize] - public void TestInit() + [TestMethod] + public void BeforeRaisingTestRunCompleteShouldWarnIfNoTestsAreRun() + { + var adapterSourceMap = new Dictionary> { - this.testableTestRunCache = new TestableTestRunCache(); - this.testExecutionContext = new TestExecutionContext( - frequencyOfRunStatsChangeEvent: 100, - runStatsChangeEventTimeout: TimeSpan.MaxValue, - inIsolation: false, - keepAlive: false, - isDataCollectionEnabled: false, - areTestCaseLevelEventsRequired: false, - hasTestRun: false, - isDebug: false, - testCaseFilter: null, - filterOptions: null); - this.mockTestRunEventsHandler = new Mock(); - this.mockMetricsCollection = new Mock(); - this.mockRequestData = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(this.mockMetricsCollection.Object); - - TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(RunTestsWithSourcesTests).GetTypeInfo().Assembly.Location }, - () => { }); - - TestPluginCache.Instance.DiscoverTestExtensions(TestPlatformConstants.TestAdapterEndsWithPattern); - TestPluginCache.Instance.DiscoverTestExtensions(TestPlatformConstants.TestAdapterEndsWithPattern); - } + { "a", new List { "a", "aa" } }, + { "b", new List { "b", "ab" } } + }; - [TestCleanup] - public void TestCleanup() + var executorUriVsSourceList = new Dictionary, IEnumerable> { - RunTestWithSourcesExecutor.RunTestsWithSourcesCallback = null; - TestPluginCacheHelper.ResetExtensionsCache(); - } + { new Tuple(new Uri("e://d/"), "A.dll"), new List { "s1.dll " } } + }; + + _runTestsInstance = new TestableRunTestsWithSources( + adapterSourceMap, + null, + _testExecutionContext, + null, + _mockTestRunEventsHandler.Object, + executorUriVsSourceList, + _mockRequestData.Object); + + _runTestsInstance.CallBeforeRaisingTestRunComplete(false); + + var messageFormat = + "No test is available in {0}. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again."; + var message = string.Format(messageFormat, "a aa b ab"); + _mockTestRunEventsHandler.Verify(treh => treh.HandleLogMessage(TestMessageLevel.Warning, message), + Times.Once); + } - [TestMethod] - public void BeforeRaisingTestRunCompleteShouldWarnIfNoTestsAreRun() + [TestMethod] + public void GetExecutorUriExtensionMapShouldReturnEmptyOnInvalidSources() + { + var adapterSourceMap = new Dictionary> { - var adapterSourceMap = new Dictionary>(); - adapterSourceMap.Add("a", new List {"a", "aa"}); - adapterSourceMap.Add("b", new List { "b", "ab" }); - - var executorUriVsSourceList = new Dictionary, IEnumerable>(); - executorUriVsSourceList.Add(new Tuple(new Uri("e://d/"), "A.dll"), new List {"s1.dll "}); - - this.runTestsInstance = new TestableRunTestsWithSources( - adapterSourceMap, - null, - testExecutionContext, - null, - this.mockTestRunEventsHandler.Object, - executorUriVsSourceList, - this.mockRequestData.Object); - - this.runTestsInstance.CallBeforeRaisingTestRunComplete(false); - - var messageFormat = - "No test is available in {0}. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again."; - var message = string.Format(messageFormat, "a aa b ab"); - this.mockTestRunEventsHandler.Verify(treh => treh.HandleLogMessage(TestMessageLevel.Warning, message), - Times.Once); - } + { "a", new List { "a", "aa" } } + }; - [TestMethod] - public void GetExecutorUriExtensionMapShouldReturnEmptyOnInvalidSources() - { - var adapterSourceMap = new Dictionary>(); - adapterSourceMap.Add("a", new List { "a", "aa" }); + _runTestsInstance = new TestableRunTestsWithSources( + adapterSourceMap, + null, + _testExecutionContext, + null, + _mockTestRunEventsHandler.Object, + _mockRequestData.Object); - this.runTestsInstance = new TestableRunTestsWithSources( - adapterSourceMap, - null, - testExecutionContext, - null, - this.mockTestRunEventsHandler.Object, - this.mockRequestData.Object); + var executorUris = _runTestsInstance.CallGetExecutorUriExtensionMap(new Mock().Object, new RunContext()); - var executorUris = this.runTestsInstance.CallGetExecutorUriExtensionMap(new Mock().Object, new RunContext()); + Assert.IsNotNull(executorUris); + Assert.AreEqual(0, executorUris.Count()); + } - Assert.IsNotNull(executorUris); - Assert.AreEqual(0, executorUris.Count()); - } + [TestMethod] + public void GetExecutorUriExtensionMapShouldReturnDefaultExecutorUrisForTheDiscoverersDefined() + { + var assemblyLocation = typeof(RunTestsWithSourcesTests).GetTypeInfo().Assembly.Location; - [TestMethod] - public void GetExecutorUriExtensionMapShouldReturnDefaultExecutorUrisForTheDiscoverersDefined() + var adapterSourceMap = new Dictionary> { - var assemblyLocation = typeof (RunTestsWithSourcesTests).GetTypeInfo().Assembly.Location; - - var adapterSourceMap = new Dictionary>(); - adapterSourceMap.Add("a", new List {"a", "aa"}); - adapterSourceMap.Add(assemblyLocation, new List {assemblyLocation}); - - this.runTestsInstance = new TestableRunTestsWithSources( - adapterSourceMap, - null, - testExecutionContext, - null, - this.mockTestRunEventsHandler.Object, - this.mockRequestData.Object); - - var executorUris = this.runTestsInstance.CallGetExecutorUriExtensionMap( - new Mock().Object, new RunContext()); - - Assert.IsNotNull(executorUris); - CollectionAssert.Contains(executorUris.ToArray(), - new Tuple(new Uri("executor://RunTestWithSourcesDiscoverer"), assemblyLocation)); - } + { "a", new List { "a", "aa" } }, + { assemblyLocation, new List { assemblyLocation } } + }; + + _runTestsInstance = new TestableRunTestsWithSources( + adapterSourceMap, + null, + _testExecutionContext, + null, + _mockTestRunEventsHandler.Object, + _mockRequestData.Object); + + var executorUris = _runTestsInstance.CallGetExecutorUriExtensionMap( + new Mock().Object, new RunContext()); + + Assert.IsNotNull(executorUris); + CollectionAssert.Contains(executorUris.ToArray(), + new Tuple(new Uri("executor://RunTestWithSourcesDiscoverer"), assemblyLocation)); + } - [TestMethod] - public void InvokeExecutorShouldInvokeTestExecutorWithTheSources() + [TestMethod] + public void InvokeExecutorShouldInvokeTestExecutorWithTheSources() + { + var adapterSourceMap = new Dictionary> { - var adapterSourceMap = new Dictionary>(); - adapterSourceMap.Add("a", new List { "a", "aa" }); - adapterSourceMap.Add("b", new List { "b", "ab" }); - - var executorUriVsSourceList = new Dictionary, IEnumerable>(); - var executorUriExtensionTuple = new Tuple(new Uri("e://d/"), "A.dll"); - executorUriVsSourceList.Add(executorUriExtensionTuple, new List { "s1.dll " }); - - this.runTestsInstance = new TestableRunTestsWithSources( - adapterSourceMap, - null, - testExecutionContext, - null, - this.mockTestRunEventsHandler.Object, - executorUriVsSourceList, - this.mockRequestData.Object); - - var testExecutor = new RunTestWithSourcesExecutor(); - var extension = new LazyExtension(testExecutor, new TestExecutorMetadata("e://d/")); - IEnumerable receivedSources = null; - RunTestWithSourcesExecutor.RunTestsWithSourcesCallback = (sources, rc, fh) => { receivedSources = sources; }; - - this.runTestsInstance.CallInvokeExecutor(extension, executorUriExtensionTuple, null, null); - - Assert.IsNotNull(receivedSources); - CollectionAssert.AreEqual(new List {"s1.dll "}, receivedSources.ToList()); - } + { "a", new List { "a", "aa" } }, + { "b", new List { "b", "ab" } } + }; + + var executorUriVsSourceList = new Dictionary, IEnumerable>(); + var executorUriExtensionTuple = new Tuple(new Uri("e://d/"), "A.dll"); + executorUriVsSourceList.Add(executorUriExtensionTuple, new List { "s1.dll " }); + + _runTestsInstance = new TestableRunTestsWithSources( + adapterSourceMap, + null, + _testExecutionContext, + null, + _mockTestRunEventsHandler.Object, + executorUriVsSourceList, + _mockRequestData.Object); + + var testExecutor = new RunTestWithSourcesExecutor(); + var extension = new LazyExtension(testExecutor, new TestExecutorMetadata("e://d/")); + IEnumerable receivedSources = null; + RunTestWithSourcesExecutor.RunTestsWithSourcesCallback = (sources, rc, fh) => receivedSources = sources; + + _runTestsInstance.CallInvokeExecutor(extension, executorUriExtensionTuple, null, null); + + Assert.IsNotNull(receivedSources); + CollectionAssert.AreEqual(new List { "s1.dll " }, receivedSources.ToList()); + } - [TestMethod] - public void RunTestsShouldRunTestsForTheSourcesSpecified() - { - var assemblyLocation = typeof(RunTestsWithSourcesTests).GetTypeInfo().Assembly.Location; - - var adapterSourceMap = new Dictionary>(); - adapterSourceMap.Add("a", new List { "a", "aa" }); - adapterSourceMap.Add(assemblyLocation, new List { assemblyLocation }); - - this.runTestsInstance = new TestableRunTestsWithSources( - adapterSourceMap, - null, - testExecutionContext, - null, - this.mockTestRunEventsHandler.Object, - this.mockRequestData.Object); - - bool isExecutorCalled = false; - RunTestWithSourcesExecutor.RunTestsWithSourcesCallback = (s, rc, fh) => { isExecutorCalled = true; }; - - this.runTestsInstance.RunTests(); - - Assert.IsTrue(isExecutorCalled); - this.mockTestRunEventsHandler.Verify( - treh => treh.HandleTestRunComplete(It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>()), Times.Once); - } + [TestMethod] + public void RunTestsShouldRunTestsForTheSourcesSpecified() + { + var assemblyLocation = typeof(RunTestsWithSourcesTests).GetTypeInfo().Assembly.Location; - [TestMethod] - public void RunTestsShouldLogWarningOnNoTestsAvailableInAssembly() + var adapterSourceMap = new Dictionary> { - string testCaseFilter = null; - this.SetupForNoTestsAvailable(testCaseFilter, out var sourcesString); + { "a", new List { "a", "aa" } }, + { assemblyLocation, new List { assemblyLocation } } + }; + + _runTestsInstance = new TestableRunTestsWithSources( + adapterSourceMap, + null, + _testExecutionContext, + null, + _mockTestRunEventsHandler.Object, + _mockRequestData.Object); + + bool isExecutorCalled = false; + RunTestWithSourcesExecutor.RunTestsWithSourcesCallback = (s, rc, fh) => isExecutorCalled = true; + + _runTestsInstance.RunTests(); + + Assert.IsTrue(isExecutorCalled); + _mockTestRunEventsHandler.Verify( + treh => treh.HandleTestRunComplete(It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>()), Times.Once); + } - this.runTestsInstance.RunTests(); + [TestMethod] + public void RunTestsShouldLogWarningOnNoTestsAvailableInAssembly() + { + string testCaseFilter = null; + SetupForNoTestsAvailable(testCaseFilter, out var sourcesString); - var expectedMessage = - $"No test is available in {sourcesString}. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again."; - this.mockTestRunEventsHandler.Verify(treh => treh.HandleLogMessage(TestMessageLevel.Warning, expectedMessage), Times.Once); - } + _runTestsInstance.RunTests(); - [TestMethod] - public void RunTestsShouldLogWarningOnNoTestsAvailableInAssemblyWithTestCaseFilter() - { - var testCaseFilter = "Name~TestMethod1"; - this.SetupForNoTestsAvailable(testCaseFilter, out var sourcesString); + var expectedMessage = + $"No test is available in {sourcesString}. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again."; + _mockTestRunEventsHandler.Verify(treh => treh.HandleLogMessage(TestMessageLevel.Warning, expectedMessage), Times.Once); + } - this.runTestsInstance.RunTests(); + [TestMethod] + public void RunTestsShouldLogWarningOnNoTestsAvailableInAssemblyWithTestCaseFilter() + { + var testCaseFilter = "Name~TestMethod1"; + SetupForNoTestsAvailable(testCaseFilter, out var sourcesString); - var expectedMessage = - $"No test matches the given testcase filter `{testCaseFilter}` in {sourcesString}"; - this.mockTestRunEventsHandler.Verify(treh => treh.HandleLogMessage(TestMessageLevel.Warning, expectedMessage), Times.Once); - } + _runTestsInstance.RunTests(); - [TestMethod] - public void RunTestsShouldLogWarningOnNoTestsAvailableInAssemblyWithLongTestCaseFilter() - { - var veryLengthyTestCaseFilter = "FullyQualifiedName=TestPlatform.CrossPlatEngine" + - ".UnitTests.Execution.RunTestsWithSourcesTests." + - "RunTestsShouldLogWarningOnNoTestsAvailableInAssemblyWithLongTestCaseFilter" + - "WithVeryLengthTestCaseNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; - this.SetupForNoTestsAvailable(veryLengthyTestCaseFilter, out var sourcesString); + var expectedMessage = + $"No test matches the given testcase filter `{testCaseFilter}` in {sourcesString}"; + _mockTestRunEventsHandler.Verify(treh => treh.HandleLogMessage(TestMessageLevel.Warning, expectedMessage), Times.Once); + } - this.runTestsInstance.RunTests(); + [TestMethod] + public void RunTestsShouldLogWarningOnNoTestsAvailableInAssemblyWithLongTestCaseFilter() + { + var veryLengthyTestCaseFilter = "FullyQualifiedName=TestPlatform.CrossPlatEngine" + + ".UnitTests.Execution.RunTestsWithSourcesTests." + + "RunTestsShouldLogWarningOnNoTestsAvailableInAssemblyWithLongTestCaseFilter" + + "WithVeryLengthTestCaseNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; + SetupForNoTestsAvailable(veryLengthyTestCaseFilter, out var sourcesString); - var expectedTestCaseFilter = veryLengthyTestCaseFilter.Substring(0, 256)+ "..."; + _runTestsInstance.RunTests(); - var expectedMessage = - $"No test matches the given testcase filter `{expectedTestCaseFilter}` in {sourcesString}"; - this.mockTestRunEventsHandler.Verify(treh => treh.HandleLogMessage(TestMessageLevel.Warning, expectedMessage), Times.Once); - } + var expectedTestCaseFilter = veryLengthyTestCaseFilter.Substring(0, 256) + "..."; + + var expectedMessage = + $"No test matches the given testcase filter `{expectedTestCaseFilter}` in {sourcesString}"; + _mockTestRunEventsHandler.Verify(treh => treh.HandleLogMessage(TestMessageLevel.Warning, expectedMessage), Times.Once); + } - [TestMethod] - public void SendSessionStartShouldCallSessionStartWithCorrectTestSources() + [TestMethod] + public void SendSessionStartShouldCallSessionStartWithCorrectTestSources() + { + var adapterSourceMap = new Dictionary> { - var adapterSourceMap = new Dictionary>(); - adapterSourceMap.Add("a", new List { "1.dll", "2.dll" }); - var mockTestCaseEventsHandler = new Mock(); - - this.runTestsInstance = new TestableRunTestsWithSources( - adapterSourceMap, - null, - testExecutionContext, - mockTestCaseEventsHandler.Object, - this.mockTestRunEventsHandler.Object, - this.mockRequestData.Object); - - this.runTestsInstance.CallSendSessionStart(); - - mockTestCaseEventsHandler.Verify(x => x.SendSessionStart(It.Is>( - y => y.ContainsKey("TestSources") - && ((IEnumerable)y["TestSources"]).Contains("1.dll") - && ((IEnumerable)y["TestSources"]).Contains("2.dll") - ))); - } + { "a", new List { "1.dll", "2.dll" } } + }; + var mockTestCaseEventsHandler = new Mock(); + + _runTestsInstance = new TestableRunTestsWithSources( + adapterSourceMap, + null, + _testExecutionContext, + mockTestCaseEventsHandler.Object, + _mockTestRunEventsHandler.Object, + _mockRequestData.Object); + + _runTestsInstance.CallSendSessionStart(); + + mockTestCaseEventsHandler.Verify(x => x.SendSessionStart(It.Is>( + y => y.ContainsKey("TestSources") + && ((IEnumerable)y["TestSources"]).Contains("1.dll") + && ((IEnumerable)y["TestSources"]).Contains("2.dll") + ))); + } - [TestMethod] - public void SendSessionEndShouldCallSessionEnd() + [TestMethod] + public void SendSessionEndShouldCallSessionEnd() + { + var adapterSourceMap = new Dictionary> { - var adapterSourceMap = new Dictionary>(); - adapterSourceMap.Add("a", new List { "1.dll", "2.dll" }); - var mockTestCaseEventsHandler = new Mock(); + { "a", new List { "1.dll", "2.dll" } } + }; + var mockTestCaseEventsHandler = new Mock(); + + _runTestsInstance = new TestableRunTestsWithSources( + adapterSourceMap, + null, + _testExecutionContext, + mockTestCaseEventsHandler.Object, + _mockTestRunEventsHandler.Object, + _mockRequestData.Object); + + _runTestsInstance.CallSendSessionEnd(); + + mockTestCaseEventsHandler.Verify(x => x.SendSessionEnd()); + } + + private void SetupForNoTestsAvailable(string testCaseFilter, out string sourcesString) + { + var testAssemblyLocation = typeof(TestCase).GetTypeInfo().Assembly.Location; + + var adapterAssemblyLocation = typeof(RunTestsWithSourcesTests).GetTypeInfo().Assembly.Location; + + var adapterSourceMap = new Dictionary>(); - this.runTestsInstance = new TestableRunTestsWithSources( - adapterSourceMap, - null, - testExecutionContext, - mockTestCaseEventsHandler.Object, - this.mockTestRunEventsHandler.Object, - this.mockRequestData.Object); + var sources = new[] { testAssemblyLocation, "a" }; + sourcesString = string.Join(" ", sources); - this.runTestsInstance.CallSendSessionEnd(); + adapterSourceMap.Add(adapterAssemblyLocation, sources); - mockTestCaseEventsHandler.Verify(x => x.SendSessionEnd()); + _testExecutionContext.TestCaseFilter = testCaseFilter; + + _runTestsInstance = new TestableRunTestsWithSources( + adapterSourceMap, + null, + _testExecutionContext, + null, + _mockTestRunEventsHandler.Object, + _mockRequestData.Object); + } + + #region Testable Implementations + + private class TestableRunTestsWithSources : RunTestsWithSources + { + public TestableRunTestsWithSources(Dictionary> adapterSourceMap, string runSettings, + TestExecutionContext testExecutionContext, ITestCaseEventsHandler testCaseEventsHandler, ITestRunEventsHandler testRunEventsHandler, IRequestData requestData) + : base(requestData, adapterSourceMap, null, runSettings, testExecutionContext, testCaseEventsHandler, testRunEventsHandler) + { } - private void SetupForNoTestsAvailable(string testCaseFilter, out string sourcesString) + internal TestableRunTestsWithSources(Dictionary> adapterSourceMap, string runSettings, + TestExecutionContext testExecutionContext, + ITestCaseEventsHandler testCaseEventsHandler, ITestRunEventsHandler testRunEventsHandler, Dictionary, IEnumerable> executorUriVsSourceList, IRequestData requestData) + : base(requestData, adapterSourceMap, null, runSettings, testExecutionContext, testCaseEventsHandler, testRunEventsHandler, executorUriVsSourceList) { - var testAssemblyLocation = typeof(TestCase).GetTypeInfo().Assembly.Location; + } - var adapterAssemblyLocation = typeof(RunTestsWithSourcesTests).GetTypeInfo().Assembly.Location; + public void CallBeforeRaisingTestRunComplete(bool exceptionsHitDuringRunTests) + { + BeforeRaisingTestRunComplete(exceptionsHitDuringRunTests); + } - var adapterSourceMap = new Dictionary>(); + public IEnumerable> CallGetExecutorUriExtensionMap( + IFrameworkHandle testExecutorFrameworkHandle, RunContext runContext) + { + return GetExecutorUriExtensionMap(testExecutorFrameworkHandle, runContext); + } - var sources = new[] {testAssemblyLocation, "a"}; - sourcesString = string.Join(" ", sources); + public void CallSendSessionStart() + { + SendSessionStart(); + } - adapterSourceMap.Add(adapterAssemblyLocation, sources); + public void CallSendSessionEnd() + { + SendSessionEnd(); + } - this.testExecutionContext.TestCaseFilter = testCaseFilter; + public void CallInvokeExecutor(LazyExtension executor, + Tuple executorUriExtensionTuple, RunContext runContext, IFrameworkHandle frameworkHandle) + { + InvokeExecutor(executor, executorUriExtensionTuple, runContext, frameworkHandle); + } + } - this.runTestsInstance = new TestableRunTestsWithSources( - adapterSourceMap, - null, - testExecutionContext, - null, - this.mockTestRunEventsHandler.Object, - this.mockRequestData.Object); + [FileExtension(".dll")] + [DefaultExecutorUri(RunTestsWithSourcesTestsExecutorUri)] + private class RunTestWithSourcesDiscoverer : ITestDiscoverer + { + public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) + { + throw new NotImplementedException(); } + } - #region Testable Implementations + [ExtensionUri(RunTestsWithSourcesTestsExecutorUri)] + internal class RunTestWithSourcesExecutor : ITestExecutor + { + public static Action, IRunContext, IFrameworkHandle> RunTestsWithSourcesCallback { get; set; } + public static Action, IRunContext, IFrameworkHandle> RunTestsWithTestsCallback { get; set; } - private class TestableRunTestsWithSources : RunTestsWithSources + public void Cancel() { - public TestableRunTestsWithSources(Dictionary> adapterSourceMap, string runSettings, - TestExecutionContext testExecutionContext, ITestCaseEventsHandler testCaseEventsHandler, ITestRunEventsHandler testRunEventsHandler, IRequestData requestData) - : base(requestData, adapterSourceMap, null, runSettings, testExecutionContext, testCaseEventsHandler, testRunEventsHandler) - { - } - - internal TestableRunTestsWithSources(Dictionary> adapterSourceMap, string runSettings, - TestExecutionContext testExecutionContext, - ITestCaseEventsHandler testCaseEventsHandler, ITestRunEventsHandler testRunEventsHandler, Dictionary, IEnumerable> executorUriVsSourceList, IRequestData requestData) - : base(requestData, adapterSourceMap, null, runSettings, testExecutionContext, testCaseEventsHandler, testRunEventsHandler, executorUriVsSourceList) - { - } - - public void CallBeforeRaisingTestRunComplete(bool exceptionsHitDuringRunTests) - { - this.BeforeRaisingTestRunComplete(exceptionsHitDuringRunTests); - } - - public IEnumerable> CallGetExecutorUriExtensionMap( - IFrameworkHandle testExecutorFrameworkHandle, RunContext runContext) - { - return this.GetExecutorUriExtensionMap(testExecutorFrameworkHandle, runContext); - } - - public void CallSendSessionStart() - { - this.SendSessionStart(); - } - - public void CallSendSessionEnd() - { - this.SendSessionEnd(); - } - - public void CallInvokeExecutor(LazyExtension executor, - Tuple executorUriExtensionTuple, RunContext runContext, IFrameworkHandle frameworkHandle) - { - this.InvokeExecutor(executor, executorUriExtensionTuple, runContext, frameworkHandle); - } + throw new NotImplementedException(); } - [FileExtension(".dll")] - [DefaultExecutorUri(RunTestsWithSourcesTestsExecutorUri)] - private class RunTestWithSourcesDiscoverer : ITestDiscoverer + public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) { - public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) - { - throw new NotImplementedException(); - } + RunTestsWithSourcesCallback?.Invoke(sources, runContext, frameworkHandle); } - [ExtensionUri(RunTestsWithSourcesTestsExecutorUri)] - internal class RunTestWithSourcesExecutor : ITestExecutor + public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) { - public static Action, IRunContext, IFrameworkHandle> RunTestsWithSourcesCallback { get; set; } - public static Action, IRunContext, IFrameworkHandle> RunTestsWithTestsCallback { get; set; } - - public void Cancel() - { - throw new NotImplementedException(); - } - - public void RunTests(IEnumerable sources, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - RunTestsWithSourcesCallback?.Invoke(sources, runContext, frameworkHandle); - } - - public void RunTests(IEnumerable tests, IRunContext runContext, IFrameworkHandle frameworkHandle) - { - RunTestsWithTestsCallback?.Invoke(tests, runContext, frameworkHandle); - } + RunTestsWithTestsCallback?.Invoke(tests, runContext, frameworkHandle); } - - #endregion } -} + + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/RunTestsWithTestsTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/RunTestsWithTestsTests.cs index c8cf6f182b..8ff2659427 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/RunTestsWithTestsTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/RunTestsWithTestsTests.cs @@ -1,242 +1,241 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Execution +namespace TestPlatform.CrossPlatEngine.UnitTests.Execution; + +using System; +using System.Collections.Generic; +using System.Linq; + +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; +using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +using TestableImplementations; + +[TestClass] +public class RunTestsWithTestsTests { - using System; - using System.Collections.Generic; - using System.Linq; - - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Adapter; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - using TestPlatform.CrossPlatEngine.UnitTests.TestableImplementations; - - [TestClass] - public class RunTestsWithTestsTests + private TestableTestRunCache _testableTestRunCache; + private TestExecutionContext _testExecutionContext; + private Mock _mockTestRunEventsHandler; + private TestableRunTestsWithTests _runTestsInstance; + private Mock _mockRequestData; + private Mock _mockMetricsCollection; + + private const string RunTestsWithSourcesTestsExecutorUri = "executor://RunTestWithSourcesDiscoverer/"; + + [TestInitialize] + public void TestInit() + { + _testableTestRunCache = new TestableTestRunCache(); + _mockMetricsCollection = new Mock(); + _mockRequestData = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(_mockMetricsCollection.Object); + _testExecutionContext = new TestExecutionContext( + frequencyOfRunStatsChangeEvent: 100, + runStatsChangeEventTimeout: TimeSpan.MaxValue, + inIsolation: false, + keepAlive: false, + isDataCollectionEnabled: false, + areTestCaseLevelEventsRequired: false, + hasTestRun: false, + isDebug: false, + testCaseFilter: null, + filterOptions: null); + _mockTestRunEventsHandler = new Mock(); + } + + [TestMethod] + public void GetExecutorUriExtensionMapShouldReturnExecutorUrisMapForTestCasesWithSameExecutorUri() { - private TestableTestRunCache testableTestRunCache; - private TestExecutionContext testExecutionContext; - private Mock mockTestRunEventsHandler; - private TestableRunTestsWithTests runTestsInstance; - private Mock mockRequestData; - private Mock mockMetricsCollection; + var tests = new List + { + new TestCase("A.C.M1", new Uri("e://d"), "s.dll"), + new TestCase("A.C.M2", new Uri("e://d"), "s.dll") + }; + + _runTestsInstance = new TestableRunTestsWithTests( + tests, + null, + _testExecutionContext, + null, + _mockTestRunEventsHandler.Object, + _mockRequestData.Object); - private const string RunTestsWithSourcesTestsExecutorUri = "executor://RunTestWithSourcesDiscoverer/"; + var map = _runTestsInstance.CallGetExecutorUriExtensionMap(new Mock().Object, new RunContext()); - [TestInitialize] - public void TestInit() + var expectedMap = new List> { - this.testableTestRunCache = new TestableTestRunCache(); - this.mockMetricsCollection = new Mock(); - this.mockRequestData = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(this.mockMetricsCollection.Object); - this.testExecutionContext = new TestExecutionContext( - frequencyOfRunStatsChangeEvent: 100, - runStatsChangeEventTimeout: TimeSpan.MaxValue, - inIsolation: false, - keepAlive: false, - isDataCollectionEnabled: false, - areTestCaseLevelEventsRequired: false, - hasTestRun: false, - isDebug: false, - testCaseFilter: null, - filterOptions: null); - this.mockTestRunEventsHandler = new Mock(); - } + new Tuple(new Uri("e://d"), + Constants.UnspecifiedAdapterPath) + }; + + CollectionAssert.AreEqual(expectedMap, map.ToList()); + } - [TestMethod] - public void GetExecutorUriExtensionMapShouldReturnExecutorUrisMapForTestCasesWithSameExecutorUri() + [TestMethod] + public void GetExecutorUriExtensionMapShouldReturnExecutorUrisMapForTestCasesWithDifferentExecutorUri() + { + var tests = new List { - var tests = new List - { - new TestCase("A.C.M1", new Uri("e://d"), "s.dll"), - new TestCase("A.C.M2", new Uri("e://d"), "s.dll") - }; - - this.runTestsInstance = new TestableRunTestsWithTests( - tests, - null, - testExecutionContext, - null, - this.mockTestRunEventsHandler.Object, - this.mockRequestData.Object); - - var map = this.runTestsInstance.CallGetExecutorUriExtensionMap(new Mock().Object, new RunContext()); - - var expectedMap = new List> - { - new Tuple(new Uri("e://d"), - Microsoft.VisualStudio.TestPlatform.ObjectModel.Constants.UnspecifiedAdapterPath) - }; - - CollectionAssert.AreEqual(expectedMap, map.ToList()); - } + new TestCase("A.C.M1", new Uri("e://d"), "s.dll"), + new TestCase("A.C.M2", new Uri("e://d2"), "s.dll") + }; + + _runTestsInstance = new TestableRunTestsWithTests( + tests, + null, + _testExecutionContext, + null, + _mockTestRunEventsHandler.Object, + _mockRequestData.Object); + + var map = _runTestsInstance.CallGetExecutorUriExtensionMap(new Mock().Object, new RunContext()); + + var expectedMap = new List> + { + new Tuple(new Uri("e://d"), + Constants.UnspecifiedAdapterPath), + new Tuple(new Uri("e://d2"), + Constants.UnspecifiedAdapterPath) + }; + + CollectionAssert.AreEqual(expectedMap, map.ToList()); + } + + [TestMethod] + public void InvokeExecutorShouldInvokeTestExecutorWithTheTests() + { + var tests = new List + { + new TestCase("A.C.M1", new Uri("e://d"), "s.dll") + }; + + var executorUriVsTestList = new Dictionary, List>(); + var executorUriExtensionTuple = new Tuple(new Uri("e://d/"), "A.dll"); + executorUriVsTestList.Add(executorUriExtensionTuple, tests); + + _runTestsInstance = new TestableRunTestsWithTests( + tests, + null, + _testExecutionContext, + null, + _mockTestRunEventsHandler.Object, + executorUriVsTestList, + _mockRequestData.Object); + + var testExecutor = new RunTestsWithSourcesTests.RunTestWithSourcesExecutor(); + var extension = new LazyExtension(testExecutor, new TestExecutorMetadata("e://d/")); + IEnumerable receivedTests = null; + RunTestsWithSourcesTests.RunTestWithSourcesExecutor.RunTestsWithTestsCallback = (t, rc, fh) => receivedTests = t; + + _runTestsInstance.CallInvokeExecutor(extension, executorUriExtensionTuple, null, null); + + Assert.IsNotNull(receivedTests); + CollectionAssert.AreEqual(tests, receivedTests.ToList()); + } + + [TestMethod] + public void SendSessionStartShouldCallSessionStartWithCorrectTestSources() + { + var tests = new List + { + new TestCase("A.C.M1", new Uri("e://d"), "s.dll") + }; + var mockTestCaseEventsHandler = new Mock(); + + _runTestsInstance = new TestableRunTestsWithTests( + tests, + null, + _testExecutionContext, + mockTestCaseEventsHandler.Object, + _mockTestRunEventsHandler.Object, + _mockRequestData.Object); + + _runTestsInstance.CallSendSessionStart(); + + mockTestCaseEventsHandler.Verify(x => x.SendSessionStart(It.Is>( + y => y.ContainsKey("TestSources") + && ((IEnumerable)y["TestSources"]).Contains("s.dll") + ))); + } + + [TestMethod] + public void SendSessionEndShouldCallSessionEnd() + { + var tests = new List + { + new TestCase("A.C.M1", new Uri("e://d"), "s.dll") + }; + var mockTestCaseEventsHandler = new Mock(); + + _runTestsInstance = new TestableRunTestsWithTests( + tests, + null, + _testExecutionContext, + mockTestCaseEventsHandler.Object, + _mockTestRunEventsHandler.Object, + _mockRequestData.Object); - [TestMethod] - public void GetExecutorUriExtensionMapShouldReturnExecutorUrisMapForTestCasesWithDifferentExecutorUri() + _runTestsInstance.CallSendSessionEnd(); + + mockTestCaseEventsHandler.Verify(x => x.SendSessionEnd()); + } + + #region Testable Implementations + + private class TestableRunTestsWithTests : RunTestsWithTests + { + public TestableRunTestsWithTests(IEnumerable testCases, + string runSettings, TestExecutionContext testExecutionContext, + ITestCaseEventsHandler testCaseEventsHandler, ITestRunEventsHandler testRunEventsHandler, + IRequestData requestData) + : base(requestData, testCases, null, runSettings, testExecutionContext, testCaseEventsHandler, testRunEventsHandler) { - var tests = new List - { - new TestCase("A.C.M1", new Uri("e://d"), "s.dll"), - new TestCase("A.C.M2", new Uri("e://d2"), "s.dll") - }; - - this.runTestsInstance = new TestableRunTestsWithTests( - tests, - null, - testExecutionContext, - null, - this.mockTestRunEventsHandler.Object, - this.mockRequestData.Object); - - var map = this.runTestsInstance.CallGetExecutorUriExtensionMap(new Mock().Object, new RunContext()); - - var expectedMap = new List> - { - new Tuple(new Uri("e://d"), - Microsoft.VisualStudio.TestPlatform.ObjectModel.Constants.UnspecifiedAdapterPath), - new Tuple(new Uri("e://d2"), - Microsoft.VisualStudio.TestPlatform.ObjectModel.Constants.UnspecifiedAdapterPath) - }; - - CollectionAssert.AreEqual(expectedMap, map.ToList()); } - [TestMethod] - public void InvokeExecutorShouldInvokeTestExecutorWithTheTests() + + internal TestableRunTestsWithTests(IEnumerable testCases, string runSettings, TestExecutionContext testExecutionContext, ITestCaseEventsHandler testCaseEventsHandler, ITestRunEventsHandler testRunEventsHandler, Dictionary, List> executorUriVsTestList, IRequestData requestData) + : base( + requestData, testCases, null, runSettings, testExecutionContext, + testCaseEventsHandler, testRunEventsHandler, executorUriVsTestList) { - var tests = new List - { - new TestCase("A.C.M1", new Uri("e://d"), "s.dll") - }; - - var executorUriVsTestList = new Dictionary, List>(); - var executorUriExtensionTuple = new Tuple(new Uri("e://d/"), "A.dll"); - executorUriVsTestList.Add(executorUriExtensionTuple, tests); - - this.runTestsInstance = new TestableRunTestsWithTests( - tests, - null, - testExecutionContext, - null, - this.mockTestRunEventsHandler.Object, - executorUriVsTestList, - this.mockRequestData.Object); - - var testExecutor = new RunTestsWithSourcesTests.RunTestWithSourcesExecutor(); - var extension = new LazyExtension(testExecutor, new TestExecutorMetadata("e://d/")); - IEnumerable receivedTests = null; - RunTestsWithSourcesTests.RunTestWithSourcesExecutor.RunTestsWithTestsCallback = (t, rc, fh) => { receivedTests = t; }; - - this.runTestsInstance.CallInvokeExecutor(extension, executorUriExtensionTuple, null, null); - - Assert.IsNotNull(receivedTests); - CollectionAssert.AreEqual(tests, receivedTests.ToList()); } - [TestMethod] - public void SendSessionStartShouldCallSessionStartWithCorrectTestSources() + public IEnumerable> CallGetExecutorUriExtensionMap( + IFrameworkHandle testExecutorFrameworkHandle, RunContext runContext) { - var tests = new List - { - new TestCase("A.C.M1", new Uri("e://d"), "s.dll") - }; - var mockTestCaseEventsHandler = new Mock(); - - this.runTestsInstance = new TestableRunTestsWithTests( - tests, - null, - testExecutionContext, - mockTestCaseEventsHandler.Object, - this.mockTestRunEventsHandler.Object, - this.mockRequestData.Object); - - this.runTestsInstance.CallSendSessionStart(); - - mockTestCaseEventsHandler.Verify(x => x.SendSessionStart(It.Is>( - y => y.ContainsKey("TestSources") - && ((IEnumerable)y["TestSources"]).Contains("s.dll") - ))); + return GetExecutorUriExtensionMap(testExecutorFrameworkHandle, runContext); } - [TestMethod] - public void SendSessionEndShouldCallSessionEnd() + public void CallInvokeExecutor(LazyExtension executor, + Tuple executorUriExtensionTuple, RunContext runContext, IFrameworkHandle frameworkHandle) { - var tests = new List - { - new TestCase("A.C.M1", new Uri("e://d"), "s.dll") - }; - var mockTestCaseEventsHandler = new Mock(); - - this.runTestsInstance = new TestableRunTestsWithTests( - tests, - null, - testExecutionContext, - mockTestCaseEventsHandler.Object, - this.mockTestRunEventsHandler.Object, - this.mockRequestData.Object); - - this.runTestsInstance.CallSendSessionEnd(); - - mockTestCaseEventsHandler.Verify(x => x.SendSessionEnd()); + InvokeExecutor(executor, executorUriExtensionTuple, runContext, frameworkHandle); } - #region Testable Implementations + public void CallSendSessionStart() + { + SendSessionStart(); + } - private class TestableRunTestsWithTests : RunTestsWithTests + public void CallSendSessionEnd() { - public TestableRunTestsWithTests(IEnumerable testCases, - string runSettings, TestExecutionContext testExecutionContext, - ITestCaseEventsHandler testCaseEventsHandler, ITestRunEventsHandler testRunEventsHandler, - IRequestData requestData) - : base(requestData, testCases, null, runSettings, testExecutionContext, testCaseEventsHandler, testRunEventsHandler) - { - } - - - internal TestableRunTestsWithTests(IEnumerable testCases, string runSettings, TestExecutionContext testExecutionContext, ITestCaseEventsHandler testCaseEventsHandler, ITestRunEventsHandler testRunEventsHandler, Dictionary, List> executorUriVsTestList, IRequestData requestData) - : base( -requestData, testCases, null, runSettings, testExecutionContext, - testCaseEventsHandler, testRunEventsHandler, executorUriVsTestList) - { - } - - public IEnumerable> CallGetExecutorUriExtensionMap( - IFrameworkHandle testExecutorFrameworkHandle, RunContext runContext) - { - return this.GetExecutorUriExtensionMap(testExecutorFrameworkHandle, runContext); - } - - public void CallInvokeExecutor(LazyExtension executor, - Tuple executorUriExtensionTuple, RunContext runContext, IFrameworkHandle frameworkHandle) - { - this.InvokeExecutor(executor, executorUriExtensionTuple, runContext, frameworkHandle); - } - - public void CallSendSessionStart() - { - this.SendSessionStart(); - } - - public void CallSendSessionEnd() - { - this.SendSessionEnd(); - } + SendSessionEnd(); } + } - #endregion + #endregion - } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/TestRunCacheTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/TestRunCacheTests.cs index 19938f825b..17f54709ae 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/TestRunCacheTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/TestRunCacheTests.cs @@ -1,408 +1,400 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Execution +namespace TestPlatform.CrossPlatEngine.UnitTests.Execution; + +using System; +using System.Collections.Generic; +using System.Linq; + +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +[TestClass] +public class TestRunCacheBehaviors { - using System; - using System.Collections.Generic; - using System.Linq; - - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - [TestClass] - public class TestRunCacheBehaviors + #region OnTestStarted tests + + [TestMethod] + public void OnTestStartedShouldAddToInProgressTests() { - #region OnTestStarted tests + var tester = new TestCacheTester { ExpectedCacheSize = int.MaxValue }; - [TestMethod] - public void OnTestStartedShouldAddToInProgressTests() - { - var tester = new TestCacheTester { ExpectedCacheSize = int.MaxValue }; + var cache = new TestRunCache(int.MaxValue, TimeSpan.MaxValue, tester.CacheHitOnSize); - var cache = new TestRunCache(int.MaxValue, TimeSpan.MaxValue, tester.CacheHitOnSize); + var tr = GetTestResult(0); + cache.OnTestStarted(tr.TestCase); - var tr = this.GetTestResult(0); - cache.OnTestStarted(tr.TestCase); + CollectionAssert.Contains(cache.InProgressTests.ToList(), tr.TestCase); + } - CollectionAssert.Contains(cache.InProgressTests.ToList(), tr.TestCase); - } + [TestMethod] + public void OnTestStartedShouldAddMultipleInProgressTestsTillCacheHit() + { + long cacheSize = 10; + var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; - [TestMethod] - public void OnTestStartedShouldAddMultipleInProgressTestsTillCacheHit() + var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); + for (var i = 0; i < (cacheSize - 1); i++) { - long cacheSize = 10; - var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; - - var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); - for (var i = 0; i < (cacheSize - 1); i++) - { - var tr = this.GetTestResult(i); - cache.OnTestStarted(tr.TestCase); + var tr = GetTestResult(i); + cache.OnTestStarted(tr.TestCase); - Assert.AreEqual(i, cache.InProgressTests.Count - 1); - } + Assert.AreEqual(i, cache.InProgressTests.Count - 1); } + } - //[TestMethod] - //public void OnTestStartedShouldReportInProgressTestsForLongRunningUnitTest() - //{ - // var cacheTimeout = new TimeSpan(0, 0, 0, 3, 0); - // var tester = new TestCacheTester { ExpectedCacheSize = int.MaxValue }; + //[TestMethod] + //public void OnTestStartedShouldReportInProgressTestsForLongRunningUnitTest() + //{ + // var cacheTimeout = new TimeSpan(0, 0, 0, 3, 0); + // var tester = new TestCacheTester { ExpectedCacheSize = int.MaxValue }; - // var cache = new TestRunCache(int.MaxValue, cacheTimeout, tester.CacheHitOnTimerLimit); + // var cache = new TestRunCache(int.MaxValue, cacheTimeout, tester.CacheHitOnTimerLimit); - // var tr = this.GetTestResult(0); - // cache.OnTestStarted(tr.TestCase); + // var tr = this.GetTestResult(0); + // cache.OnTestStarted(tr.TestCase); - // Assert.AreEqual(0, tester.TotalInProgressTestsReceived); + // Assert.AreEqual(0, tester.TotalInProgressTestsReceived); - // Assert.AreEqual(1, tester.TotalInProgressTestsReceived); - //} + // Assert.AreEqual(1, tester.TotalInProgressTestsReceived); + //} - [TestMethod] - public void OnTestStartedShouldReportResultsOnCacheHit() + [TestMethod] + public void OnTestStartedShouldReportResultsOnCacheHit() + { + long cacheSize = 2; + var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; + + var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); + for (var i = 0; i < cacheSize; i++) { - long cacheSize = 2; - var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; - - var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); - for (var i = 0; i < cacheSize; i++) - { - var tr = this.GetTestResult(i); - cache.OnTestStarted(tr.TestCase); - } - - Assert.AreEqual(1, tester.CacheHitCount); - Assert.AreEqual(0, cache.TotalExecutedTests); - Assert.AreEqual(0, cache.TestResults.Count); - Assert.AreEqual(0, cache.InProgressTests.Count); - Assert.AreEqual(2, tester.TotalInProgressTestsReceived); + var tr = GetTestResult(i); + cache.OnTestStarted(tr.TestCase); } - #endregion + Assert.AreEqual(1, tester.CacheHitCount); + Assert.AreEqual(0, cache.TotalExecutedTests); + Assert.AreEqual(0, cache.TestResults.Count); + Assert.AreEqual(0, cache.InProgressTests.Count); + Assert.AreEqual(2, tester.TotalInProgressTestsReceived); + } - #region OnNewTestResult tests + #endregion - [TestMethod] - public void OnNewTestResultShouldAddToTotalExecutedTests() - { - long cacheSize = 10; - var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; + #region OnNewTestResult tests - var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); - for (var i = 0; i < 2; i++) - { - var tr = this.GetTestResult(i); - cache.OnNewTestResult(tr); - } + [TestMethod] + public void OnNewTestResultShouldAddToTotalExecutedTests() + { + long cacheSize = 10; + var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; - Assert.AreEqual(2, cache.TotalExecutedTests); + var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); + for (var i = 0; i < 2; i++) + { + var tr = GetTestResult(i); + cache.OnNewTestResult(tr); } - [TestMethod] - public void OnNewTestResultShouldAddToTestResultCache() + Assert.AreEqual(2, cache.TotalExecutedTests); + } + + [TestMethod] + public void OnNewTestResultShouldAddToTestResultCache() + { + long cacheSize = 10; + var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; + + var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); + for (var i = 0; i < 2; i++) { - long cacheSize = 10; - var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; - - var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); - for (var i = 0; i < 2; i++) - { - var tr = this.GetTestResult(i); - cache.OnNewTestResult(tr); - CollectionAssert.Contains(cache.TestResults.ToList(), tr); - } + var tr = GetTestResult(i); + cache.OnNewTestResult(tr); + CollectionAssert.Contains(cache.TestResults.ToList(), tr); } + } + + [TestMethod] + public void OnNewTestResultShouldUpdateRunStats() + { + long cacheSize = 10; + var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; - [TestMethod] - public void OnNewTestResultShouldUpdateRunStats() + var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); + for (var i = 0; i < 2; i++) { - long cacheSize = 10; - var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; - - var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); - for (var i = 0; i < 2; i++) - { - var tr = this.GetTestResult(i); - tr.Outcome = TestOutcome.Passed; - cache.OnNewTestResult(tr); - } - - Assert.AreEqual(2, cache.TestRunStatistics.ExecutedTests); - Assert.AreEqual(2, cache.TestRunStatistics.Stats[TestOutcome.Passed]); + var tr = GetTestResult(i); + tr.Outcome = TestOutcome.Passed; + cache.OnNewTestResult(tr); } - [TestMethod] - public void OnNewTestResultShouldRemoveTestCaseFromInProgressList() - { - long cacheSize = 10; - var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; + Assert.AreEqual(2, cache.TestRunStatistics.ExecutedTests); + Assert.AreEqual(2, cache.TestRunStatistics.Stats[TestOutcome.Passed]); + } - var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); - for (var i = 0; i < 2; i++) - { - var tr = this.GetTestResult(i); - cache.OnTestStarted(tr.TestCase); - cache.OnNewTestResult(tr); - } + [TestMethod] + public void OnNewTestResultShouldRemoveTestCaseFromInProgressList() + { + long cacheSize = 10; + var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; - Assert.AreEqual(0, cache.InProgressTests.Count); + var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); + for (var i = 0; i < 2; i++) + { + var tr = GetTestResult(i); + cache.OnTestStarted(tr.TestCase); + cache.OnNewTestResult(tr); } - [TestMethod] - public void OnNewTestResultShouldReportTestResultsWhenMaxCacheSizeIsHit() + Assert.AreEqual(0, cache.InProgressTests.Count); + } + + [TestMethod] + public void OnNewTestResultShouldReportTestResultsWhenMaxCacheSizeIsHit() + { + long cacheSize = 10; + var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; + + var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); + for (var i = 0; i < cacheSize; i++) { - long cacheSize = 10; - var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; - - var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); - for (var i = 0; i < cacheSize; i++) - { - var tr = this.GetTestResult(i); - cache.OnNewTestResult(tr); - } - - Assert.AreEqual(1, tester.CacheHitCount); - Assert.AreEqual(cacheSize, cache.TotalExecutedTests); - Assert.AreEqual(0, cache.TestResults.Count); + var tr = GetTestResult(i); + cache.OnNewTestResult(tr); } - [TestMethod] - public void OnNewTestResultShouldNotFireIfMaxCacheSizeIsNotHit() + Assert.AreEqual(1, tester.CacheHitCount); + Assert.AreEqual(cacheSize, cache.TotalExecutedTests); + Assert.AreEqual(0, cache.TestResults.Count); + } + + [TestMethod] + public void OnNewTestResultShouldNotFireIfMaxCacheSizeIsNotHit() + { + long cacheSize = 10; + var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; + + var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); + var executedTests = cacheSize - 1; + for (var i = 0; i < executedTests; i++) { - long cacheSize = 10; - var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; - - var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); - var executedTests = cacheSize - 1; - for (var i = 0; i < executedTests; i++) - { - var tr = this.GetTestResult(i); - cache.OnNewTestResult(tr); - } - - Assert.AreEqual(0, tester.CacheHitCount); - Assert.AreEqual(executedTests, cache.TotalExecutedTests); - Assert.AreEqual(executedTests, cache.TestResults.Count); + var tr = GetTestResult(i); + cache.OnNewTestResult(tr); } - [TestMethod] - public void OnNewTestResultShouldReportResultsMultipleTimes() - { - long cacheSize = 10; - var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; + Assert.AreEqual(0, tester.CacheHitCount); + Assert.AreEqual(executedTests, cache.TotalExecutedTests); + Assert.AreEqual(executedTests, cache.TestResults.Count); + } - var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); - long executedTests = 45; + [TestMethod] + public void OnNewTestResultShouldReportResultsMultipleTimes() + { + long cacheSize = 10; + var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; - for (var i = 0; i < executedTests; i++) - { - var tr = this.GetTestResult(i); - cache.OnNewTestResult(tr); - } + var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); + long executedTests = 45; - Assert.AreEqual(4, tester.CacheHitCount); - Assert.AreEqual(executedTests, cache.TotalExecutedTests); - Assert.AreEqual(5, cache.TestResults.Count); + for (var i = 0; i < executedTests; i++) + { + var tr = GetTestResult(i); + cache.OnNewTestResult(tr); } - #endregion + Assert.AreEqual(4, tester.CacheHitCount); + Assert.AreEqual(executedTests, cache.TotalExecutedTests); + Assert.AreEqual(5, cache.TestResults.Count); + } - #region OnTestCompletion tests + #endregion - [TestMethod] - public void OnTestCompletionShouldNotThrowIfCompletedTestIsNull() - { - long cacheSize = 10; - var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; + #region OnTestCompletion tests - var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); + [TestMethod] + public void OnTestCompletionShouldNotThrowIfCompletedTestIsNull() + { + long cacheSize = 10; + var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; - Assert.IsFalse(cache.OnTestCompletion(null)); - } + var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); - [TestMethod] - public void OnTestCompletionShouldReturnFalseIfInProgressTestsIsEmpty() - { - long cacheSize = 10; - var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; + Assert.IsFalse(cache.OnTestCompletion(null)); + } + + [TestMethod] + public void OnTestCompletionShouldReturnFalseIfInProgressTestsIsEmpty() + { + long cacheSize = 10; + var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; - var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); + var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); - Assert.IsFalse(cache.OnTestCompletion(this.GetTestResult(0).TestCase)); - } + Assert.IsFalse(cache.OnTestCompletion(GetTestResult(0).TestCase)); + } - [TestMethod] - public void OnTestCompletionShouldUpdateInProgressList() + [TestMethod] + public void OnTestCompletionShouldUpdateInProgressList() + { + long cacheSize = 2; + var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; + + var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); + for (int i = 0; i < cacheSize; i++) { - long cacheSize = 2; - var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; - - var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); - for (int i = 0; i < cacheSize; i++) - { - var tr = this.GetTestResult(i); - cache.OnTestStarted(tr.TestCase); - Assert.IsTrue(cache.OnTestCompletion(tr.TestCase)); - - Assert.AreEqual(0, cache.InProgressTests.Count); - } + var tr = GetTestResult(i); + cache.OnTestStarted(tr.TestCase); + Assert.IsTrue(cache.OnTestCompletion(tr.TestCase)); + + Assert.AreEqual(0, cache.InProgressTests.Count); } + } - [TestMethod] - public void OnTestCompletionShouldUpdateInProgressListWhenTestHasSameId() - { - long cacheSize = 2; - var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; + [TestMethod] + public void OnTestCompletionShouldUpdateInProgressListWhenTestHasSameId() + { + long cacheSize = 2; + var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; - var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); - for (var i = 0; i < cacheSize; i++) - { - var tr = this.GetTestResult(i); - cache.OnTestStarted(tr.TestCase); + var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); + for (var i = 0; i < cacheSize; i++) + { + var tr = GetTestResult(i); + cache.OnTestStarted(tr.TestCase); - var clone = new TestCase( - tr.TestCase.FullyQualifiedName, - tr.TestCase.ExecutorUri, - tr.TestCase.Source); - clone.Id = tr.TestCase.Id; + var clone = new TestCase( + tr.TestCase.FullyQualifiedName, + tr.TestCase.ExecutorUri, + tr.TestCase.Source); + clone.Id = tr.TestCase.Id; - Assert.IsTrue(cache.OnTestCompletion(clone)); + Assert.IsTrue(cache.OnTestCompletion(clone)); - Assert.AreEqual(0, cache.InProgressTests.Count); - } + Assert.AreEqual(0, cache.InProgressTests.Count); } + } - [TestMethod] - public void OnTestCompleteShouldNotRemoveTestCaseFromInProgressListForUnrelatedTestResult() - { - long cacheSize = 10; - var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; + [TestMethod] + public void OnTestCompleteShouldNotRemoveTestCaseFromInProgressListForUnrelatedTestResult() + { + long cacheSize = 10; + var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; - var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); + var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); - var tr1 = this.GetTestResult(0); - cache.OnTestStarted(tr1.TestCase); + var tr1 = GetTestResult(0); + cache.OnTestStarted(tr1.TestCase); - var tr2 = this.GetTestResult(1); - Assert.IsFalse(cache.OnTestCompletion(tr2.TestCase)); + var tr2 = GetTestResult(1); + Assert.IsFalse(cache.OnTestCompletion(tr2.TestCase)); - Assert.AreEqual(1, cache.InProgressTests.Count); - } + Assert.AreEqual(1, cache.InProgressTests.Count); + } + + #endregion - #endregion + #region GetLastChunk tests - #region GetLastChunk tests + [TestMethod] + public void GetLastChunkShouldReturnTestResultsInCache() + { + long cacheSize = 10; + var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; + + var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); + List pushedTestResults = new(); - [TestMethod] - public void GetLastChunkShouldReturnTestResultsInCache() + for (var i = 0; i < 2; i++) { - long cacheSize = 10; - var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; + var tr = GetTestResult(i); + cache.OnNewTestResult(tr); + pushedTestResults.Add(tr); + } - var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); - List pushedTestResults = new List(); + var testResultsInCache = cache.GetLastChunk(); + CollectionAssert.AreEqual(pushedTestResults, testResultsInCache.ToList()); + } - for (var i = 0; i < 2; i++) - { - var tr = this.GetTestResult(i); - cache.OnNewTestResult(tr); - pushedTestResults.Add(tr); - } + [TestMethod] + public void GetLastChunkShouldResetTestResultsInCache() + { + long cacheSize = 10; + var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; - var testResultsInCache = cache.GetLastChunk(); - CollectionAssert.AreEqual(pushedTestResults, testResultsInCache.ToList()); - } + var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); - [TestMethod] - public void GetLastChunkShouldResetTestResultsInCache() + for (var i = 0; i < 2; i++) { - long cacheSize = 10; - var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; + var tr = GetTestResult(i); + cache.OnNewTestResult(tr); + } - var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); + cache.GetLastChunk(); + Assert.AreEqual(0, cache.TestResults.Count); + } - for (var i = 0; i < 2; i++) - { - var tr = this.GetTestResult(i); - cache.OnNewTestResult(tr); - } + #endregion - cache.GetLastChunk(); - Assert.AreEqual(0, cache.TestResults.Count); - } + #region TestRunStasts tests - #endregion + [TestMethod] + public void TestRunStatsShouldReturnCurrentStats() + { + long cacheSize = 10; + var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; - #region TestRunStasts tests + var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); - [TestMethod] - public void TestRunStatsShouldReturnCurrentStats() + for (var i = 0; i < cacheSize; i++) { - long cacheSize = 10; - var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; - - var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); - - for (var i = 0; i < cacheSize; i++) - { - var tr = this.GetTestResult(i); - if (i < 5) - { - tr.Outcome = TestOutcome.Passed; - } - else - { - tr.Outcome = TestOutcome.Failed; - } - - cache.OnNewTestResult(tr); - } - - var stats = cache.TestRunStatistics; - - Assert.AreEqual(cacheSize, stats.ExecutedTests); - Assert.AreEqual(5, stats.Stats[TestOutcome.Passed]); - Assert.AreEqual(5, stats.Stats[TestOutcome.Failed]); + var tr = GetTestResult(i); + tr.Outcome = i < 5 ? TestOutcome.Passed : TestOutcome.Failed; + + cache.OnNewTestResult(tr); } - #endregion + var stats = cache.TestRunStatistics; - #region Helpers + Assert.AreEqual(cacheSize, stats.ExecutedTests); + Assert.AreEqual(5, stats.Stats[TestOutcome.Passed]); + Assert.AreEqual(5, stats.Stats[TestOutcome.Failed]); + } - private Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult GetTestResult(int index) - { - var tc = new TestCase("Test" + index, new Uri("executor://dummy"), "DummySourceFileName"); - var testResult = new Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult(tc); - testResult.TestCase.Id = Guid.NewGuid(); + #endregion - return testResult; - } + #region Helpers - private class TestCacheTester - { - public long ExpectedCacheSize { get; set; } + private Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult GetTestResult(int index) + { + var tc = new TestCase("Test" + index, new Uri("executor://dummy"), "DummySourceFileName"); + var testResult = new Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult(tc); + testResult.TestCase.Id = Guid.NewGuid(); - public int CacheHitCount { get; set; } + return testResult; + } - public int TotalInProgressTestsReceived { get; set; } + private class TestCacheTester + { + public long ExpectedCacheSize { get; set; } - public void CacheHitOnSize(TestRunStatistics stats, ICollection results, ICollection tests) - { - Assert.AreEqual(this.ExpectedCacheSize, results.Count + tests.Count); - this.CacheHitCount++; - this.TotalInProgressTestsReceived += tests.Count; - } + public int CacheHitCount { get; set; } - public void CacheHitOnTimerLimit(ICollection results, ICollection tests) - { - this.CacheHitCount++; - this.TotalInProgressTestsReceived += tests.Count; - } + public int TotalInProgressTestsReceived { get; set; } + + public void CacheHitOnSize(TestRunStatistics stats, ICollection results, ICollection tests) + { + Assert.AreEqual(ExpectedCacheSize, results.Count + tests.Count); + CacheHitCount++; + TotalInProgressTestsReceived += tests.Count; } - #endregion + public void CacheHitOnTimerLimit(ICollection results, ICollection tests) + { + CacheHitCount++; + TotalInProgressTestsReceived += tests.Count; + } } -} + + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Program.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Program.cs index 939e1bde54..d7f4aa4dff 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Program.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Program.cs @@ -1,11 +1,11 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.UnitTests +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.UnitTests; + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Properties/AssemblyInfo.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Properties/AssemblyInfo.cs index 69cb64748c..a0cc463275 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Properties/AssemblyInfo.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Properties/AssemblyInfo.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs index 87ee90db47..2da1c7b3df 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs @@ -1,111 +1,111 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests +namespace TestPlatform.CrossPlatEngine.UnitTests; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +using Microsoft.TestPlatform.CrossPlatEngine.UnitTests.TestableImplementations; +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class TestEngineTests { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Reflection; - - using Microsoft.TestPlatform.CrossPlatEngine.UnitTests.TestableImplementations; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - [TestClass] - public class TestEngineTests - { - private ITestEngine testEngine; - private Mock mockProcessHelper; - private ProtocolConfig protocolConfig = new ProtocolConfig { Version = 1 }; - private ITestRuntimeProvider testableTestRuntimeProvider; - private Mock mockRequestData; - private Mock mockMetricsCollection; - - public TestEngineTests() - { - TestPluginCacheHelper.SetupMockExtensions(new[] { typeof(TestEngineTests).GetTypeInfo().Assembly.Location }, () => { }); - this.mockProcessHelper = new Mock(); - this.testableTestRuntimeProvider = new TestableRuntimeProvider(true); - this.mockRequestData = new Mock(); - this.mockMetricsCollection = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(this.mockMetricsCollection.Object); - this.mockRequestData.Setup(rd => rd.ProtocolConfig).Returns(this.protocolConfig); - } - - [TestInitialize] - public void Init() - { - this.mockProcessHelper.Setup(o => o.GetCurrentProcessFileName()).Returns("vstest.console"); - this.testEngine = new TestableTestEngine(this.mockProcessHelper.Object); - } + private ITestEngine _testEngine; + private readonly Mock _mockProcessHelper; + private readonly ProtocolConfig _protocolConfig = new() { Version = 1 }; + private ITestRuntimeProvider _testableTestRuntimeProvider; + private readonly Mock _mockRequestData; + private readonly Mock _mockMetricsCollection; + + public TestEngineTests() + { + TestPluginCacheHelper.SetupMockExtensions(new[] { typeof(TestEngineTests).GetTypeInfo().Assembly.Location }, () => { }); + _mockProcessHelper = new Mock(); + _testableTestRuntimeProvider = new TestableRuntimeProvider(true); + _mockRequestData = new Mock(); + _mockMetricsCollection = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(_mockMetricsCollection.Object); + _mockRequestData.Setup(rd => rd.ProtocolConfig).Returns(_protocolConfig); + } - [TestMethod] - public void GetDiscoveryManagerShouldReturnANonNullInstance() - { - var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, null); - Assert.IsNotNull(this.testEngine.GetDiscoveryManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, discoveryCriteria)); - } + [TestInitialize] + public void Init() + { + _mockProcessHelper.Setup(o => o.GetCurrentProcessFileName()).Returns("vstest.console"); + _testEngine = new TestableTestEngine(_mockProcessHelper.Object); + } - [TestMethod] - public void GetDiscoveryManagerShouldReturnsNewInstanceOfProxyDiscoveryManagerIfTestHostIsShared() - { - string settingXml = - @" + [TestMethod] + public void GetDiscoveryManagerShouldReturnANonNullInstance() + { + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, null); + Assert.IsNotNull(_testEngine.GetDiscoveryManager(_mockRequestData.Object, _testableTestRuntimeProvider, discoveryCriteria)); + } + + [TestMethod] + public void GetDiscoveryManagerShouldReturnsNewInstanceOfProxyDiscoveryManagerIfTestHostIsShared() + { + string settingXml = + @" true "; - var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); - var discoveryManager = this.testEngine.GetDiscoveryManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, discoveryCriteria); + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); + var discoveryManager = _testEngine.GetDiscoveryManager(_mockRequestData.Object, _testableTestRuntimeProvider, discoveryCriteria); - Assert.AreNotSame(discoveryManager, this.testEngine.GetDiscoveryManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, discoveryCriteria)); - Assert.IsInstanceOfType(this.testEngine.GetDiscoveryManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, discoveryCriteria), typeof(ProxyDiscoveryManager)); - } + Assert.AreNotSame(discoveryManager, _testEngine.GetDiscoveryManager(_mockRequestData.Object, _testableTestRuntimeProvider, discoveryCriteria)); + Assert.IsInstanceOfType(_testEngine.GetDiscoveryManager(_mockRequestData.Object, _testableTestRuntimeProvider, discoveryCriteria), typeof(ProxyDiscoveryManager)); + } - [TestMethod] - public void GetDiscoveryManagerShouldReturnsParallelDiscoveryManagerIfTestHostIsNotShared() - { - string settingXml = - @" + [TestMethod] + public void GetDiscoveryManagerShouldReturnsParallelDiscoveryManagerIfTestHostIsNotShared() + { + string settingXml = + @" true "; - var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); - this.testableTestRuntimeProvider = new TestableRuntimeProvider(false); + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); + _testableTestRuntimeProvider = new TestableRuntimeProvider(false); - Assert.IsNotNull(this.testEngine.GetDiscoveryManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, discoveryCriteria)); - Assert.IsInstanceOfType(this.testEngine.GetDiscoveryManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, discoveryCriteria), typeof(ParallelProxyDiscoveryManager)); - } + Assert.IsNotNull(_testEngine.GetDiscoveryManager(_mockRequestData.Object, _testableTestRuntimeProvider, discoveryCriteria)); + Assert.IsInstanceOfType(_testEngine.GetDiscoveryManager(_mockRequestData.Object, _testableTestRuntimeProvider, discoveryCriteria), typeof(ParallelProxyDiscoveryManager)); + } - [TestMethod] - public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagerIfCurrentProcessIsDotnet() - { - var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, null); - this.mockProcessHelper.Setup(o => o.GetCurrentProcessFileName()).Returns("dotnet.exe"); + [TestMethod] + public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagerIfCurrentProcessIsDotnet() + { + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, null); + _mockProcessHelper.Setup(o => o.GetCurrentProcessFileName()).Returns("dotnet.exe"); - var discoveryManager = this.testEngine.GetDiscoveryManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, discoveryCriteria); - Assert.IsNotNull(discoveryManager); - Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); - } + var discoveryManager = _testEngine.GetDiscoveryManager(_mockRequestData.Object, _testableTestRuntimeProvider, discoveryCriteria); + Assert.IsNotNull(discoveryManager); + Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); + } - [TestMethod] - public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagerIfDisableAppDomainIsSet() - { - string settingXml = - @" + [TestMethod] + public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagerIfDisableAppDomainIsSet() + { + string settingXml = + @" x86 true @@ -114,18 +114,18 @@ public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagerIfD "; - var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); - var discoveryManager = this.testEngine.GetDiscoveryManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, discoveryCriteria); - Assert.IsNotNull(discoveryManager); - Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); - } + var discoveryManager = _testEngine.GetDiscoveryManager(_mockRequestData.Object, _testableTestRuntimeProvider, discoveryCriteria); + Assert.IsNotNull(discoveryManager); + Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); + } - [TestMethod] - public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagerIfDesignModeIsTrue() - { - string settingXml = - @" + [TestMethod] + public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagerIfDesignModeIsTrue() + { + string settingXml = + @" x86 false @@ -134,18 +134,18 @@ public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagerIfD "; - var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); - var discoveryManager = this.testEngine.GetDiscoveryManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, discoveryCriteria); - Assert.IsNotNull(discoveryManager); - Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); - } + var discoveryManager = _testEngine.GetDiscoveryManager(_mockRequestData.Object, _testableTestRuntimeProvider, discoveryCriteria); + Assert.IsNotNull(discoveryManager); + Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); + } - [TestMethod] - public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagereIfTargetFrameworkIsNetcoreApp() - { - string settingXml = - @" + [TestMethod] + public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagereIfTargetFrameworkIsNetcoreApp() + { + string settingXml = + @" x86 false @@ -154,18 +154,18 @@ public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagereIf "; - var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); - var discoveryManager = this.testEngine.GetDiscoveryManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, discoveryCriteria); - Assert.IsNotNull(discoveryManager); - Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); - } + var discoveryManager = _testEngine.GetDiscoveryManager(_mockRequestData.Object, _testableTestRuntimeProvider, discoveryCriteria); + Assert.IsNotNull(discoveryManager); + Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); + } - [TestMethod] - public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagereIfTargetFrameworkIsNetStandard() - { - string settingXml = - @" + [TestMethod] + public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagereIfTargetFrameworkIsNetStandard() + { + string settingXml = + @" x86 false @@ -174,18 +174,18 @@ public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagereIf "; - var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); - var discoveryManager = this.testEngine.GetDiscoveryManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, discoveryCriteria); - Assert.IsNotNull(discoveryManager); - Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); - } + var discoveryManager = _testEngine.GetDiscoveryManager(_mockRequestData.Object, _testableTestRuntimeProvider, discoveryCriteria); + Assert.IsNotNull(discoveryManager); + Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); + } - [TestMethod] - public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagereIfTargetPlatformIsX64() - { - string settingXml = - @" + [TestMethod] + public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagereIfTargetPlatformIsX64() + { + string settingXml = + @" x64 false @@ -194,18 +194,18 @@ public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagereIf "; - var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); - var discoveryManager = this.testEngine.GetDiscoveryManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, discoveryCriteria); - Assert.IsNotNull(discoveryManager); - Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); - } + var discoveryManager = _testEngine.GetDiscoveryManager(_mockRequestData.Object, _testableTestRuntimeProvider, discoveryCriteria); + Assert.IsNotNull(discoveryManager); + Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); + } - [TestMethod] - public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagereIfrunsettingsHasTestSettingsInIt() - { - string settingXml = - @" + [TestMethod] + public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagereIfrunsettingsHasTestSettingsInIt() + { + string settingXml = + @" x86 false @@ -217,18 +217,18 @@ public void GetDiscoveryManagerShouldNotReturnsInProcessProxyDiscoveryManagereIf "; - var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); - var discoveryManager = this.testEngine.GetDiscoveryManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, discoveryCriteria); - Assert.IsNotNull(discoveryManager); - Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); - } + var discoveryManager = _testEngine.GetDiscoveryManager(_mockRequestData.Object, _testableTestRuntimeProvider, discoveryCriteria); + Assert.IsNotNull(discoveryManager); + Assert.IsNotInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); + } - [TestMethod] - public void GetDiscoveryManagerShouldReturnsInProcessProxyDiscoveryManager() - { - string settingXml = - @" + [TestMethod] + public void GetDiscoveryManagerShouldReturnsInProcessProxyDiscoveryManager() + { + string settingXml = + @" x64 false @@ -237,98 +237,98 @@ public void GetDiscoveryManagerShouldReturnsInProcessProxyDiscoveryManager() "; - var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); + var discoveryCriteria = new DiscoveryCriteria(new List { "1.dll" }, 100, settingXml); - var discoveryManager = this.testEngine.GetDiscoveryManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, discoveryCriteria); - Assert.IsNotNull(discoveryManager); - Assert.IsInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); - } + var discoveryManager = _testEngine.GetDiscoveryManager(_mockRequestData.Object, _testableTestRuntimeProvider, discoveryCriteria); + Assert.IsNotNull(discoveryManager); + Assert.IsInstanceOfType(discoveryManager, typeof(InProcessProxyDiscoveryManager)); + } - [TestMethod] - public void GetExecutionManagerShouldReturnANonNullInstance() - { - var testRunCriteria = new TestRunCriteria(new List { "1.dll" }, 100); + [TestMethod] + public void GetExecutionManagerShouldReturnANonNullInstance() + { + var testRunCriteria = new TestRunCriteria(new List { "1.dll" }, 100); - Assert.IsNotNull(this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria)); - } + Assert.IsNotNull(_testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria)); + } - [TestMethod] - public void GetExecutionManagerShouldReturnNewInstance() - { - var testRunCriteria = new TestRunCriteria(new List { "1.dll" }, 100); - var executionManager = this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria); + [TestMethod] + public void GetExecutionManagerShouldReturnNewInstance() + { + var testRunCriteria = new TestRunCriteria(new List { "1.dll" }, 100); + var executionManager = _testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria); - Assert.AreNotSame(executionManager, this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria)); - } + Assert.AreNotSame(executionManager, _testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria)); + } - [TestMethod] - public void GetExecutionManagerShouldReturnDefaultExecutionManagerIfParallelDisabled() - { - string settingXml = @"true"; - var testRunCriteria = new TestRunCriteria(new List { "1.dll" }, 100, false, settingXml); + [TestMethod] + public void GetExecutionManagerShouldReturnDefaultExecutionManagerIfParallelDisabled() + { + string settingXml = @"true"; + var testRunCriteria = new TestRunCriteria(new List { "1.dll" }, 100, false, settingXml); - Assert.IsNotNull(this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria)); - Assert.IsInstanceOfType(this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria), typeof(ProxyExecutionManager)); - } + Assert.IsNotNull(_testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria)); + Assert.IsInstanceOfType(_testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria), typeof(ProxyExecutionManager)); + } - [TestMethod] - public void GetExecutionManagerWithSingleSourceShouldReturnDefaultExecutionManagerEvenIfParallelEnabled() - { - string settingXml = - @" + [TestMethod] + public void GetExecutionManagerWithSingleSourceShouldReturnDefaultExecutionManagerEvenIfParallelEnabled() + { + string settingXml = + @" 2 true "; - var testRunCriteria = new TestRunCriteria(new List { "1.dll" }, 100, false, settingXml); + var testRunCriteria = new TestRunCriteria(new List { "1.dll" }, 100, false, settingXml); - Assert.IsNotNull(this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria)); - Assert.IsInstanceOfType(this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria), typeof(ProxyExecutionManager)); - } + Assert.IsNotNull(_testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria)); + Assert.IsInstanceOfType(_testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria), typeof(ProxyExecutionManager)); + } - [TestMethod] - public void GetExecutionManagerShouldReturnParallelExecutionManagerIfParallelEnabled() - { - string settingXml = @"2"; - var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); + [TestMethod] + public void GetExecutionManagerShouldReturnParallelExecutionManagerIfParallelEnabled() + { + string settingXml = @"2"; + var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); - Assert.IsNotNull(this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria)); - Assert.IsInstanceOfType(this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria), typeof(ParallelProxyExecutionManager)); - } + Assert.IsNotNull(_testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria)); + Assert.IsInstanceOfType(_testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria), typeof(ParallelProxyExecutionManager)); + } - [TestMethod] - public void GetExecutionManagerShouldReturnParallelExecutionManagerIfHostIsNotShared() - { - string settingXml = - @" + [TestMethod] + public void GetExecutionManagerShouldReturnParallelExecutionManagerIfHostIsNotShared() + { + string settingXml = + @" true "; - this.testableTestRuntimeProvider = new TestableRuntimeProvider(false); - var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); + _testableTestRuntimeProvider = new TestableRuntimeProvider(false); + var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); - Assert.IsNotNull(this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria)); - Assert.IsInstanceOfType(this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria), typeof(ParallelProxyExecutionManager)); - } + Assert.IsNotNull(_testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria)); + Assert.IsInstanceOfType(_testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria), typeof(ParallelProxyExecutionManager)); + } - [TestMethod] - public void GetExcecutionManagerShouldReturnExectuionManagerWithDataCollectionIfDataCollectionIsEnabled() - { - var settingXml = @""; - var testRunCriteria = new TestRunCriteria(new List { "1.dll" }, 100, false, settingXml); - var result = this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria); + [TestMethod] + public void GetExcecutionManagerShouldReturnExectuionManagerWithDataCollectionIfDataCollectionIsEnabled() + { + var settingXml = @""; + var testRunCriteria = new TestRunCriteria(new List { "1.dll" }, 100, false, settingXml); + var result = _testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria); - Assert.IsNotNull(result); - Assert.IsInstanceOfType(result, typeof(ProxyExecutionManagerWithDataCollection)); - } + Assert.IsNotNull(result); + Assert.IsInstanceOfType(result, typeof(ProxyExecutionManagerWithDataCollection)); + } - [TestMethod] - public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfInIsolationIsTrue() - { - string settingXml = - @" + [TestMethod] + public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfInIsolationIsTrue() + { + string settingXml = + @" true false @@ -337,19 +337,19 @@ public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfIn "; - var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); + var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); - var executionManager = this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria); + var executionManager = _testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria); - Assert.IsNotNull(executionManager); - Assert.IsNotInstanceOfType(executionManager, typeof(InProcessProxyExecutionManager)); - } + Assert.IsNotNull(executionManager); + Assert.IsNotInstanceOfType(executionManager, typeof(InProcessProxyExecutionManager)); + } - [TestMethod] - public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfParallelEnabled() - { - string settingXml = - @" + [TestMethod] + public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfParallelEnabled() + { + string settingXml = + @" false false @@ -358,19 +358,19 @@ public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfPa "; - var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); + var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); - var executionManager = this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria); + var executionManager = _testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria); - Assert.IsNotNull(executionManager); - Assert.IsNotInstanceOfType(executionManager, typeof(InProcessProxyExecutionManager)); - } + Assert.IsNotNull(executionManager); + Assert.IsNotInstanceOfType(executionManager, typeof(InProcessProxyExecutionManager)); + } - [TestMethod] - public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfDataCollectorIsEnabled() - { - string settingXml = - @" + [TestMethod] + public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfDataCollectorIsEnabled() + { + string settingXml = + @" false false @@ -385,19 +385,19 @@ public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfDa "; - var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); + var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); - var executionManager = this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria); + var executionManager = _testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria); - Assert.IsNotNull(executionManager); - Assert.IsNotInstanceOfType(executionManager, typeof(InProcessProxyExecutionManager)); - } + Assert.IsNotNull(executionManager); + Assert.IsNotInstanceOfType(executionManager, typeof(InProcessProxyExecutionManager)); + } - [TestMethod] - public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfInProcDataCollectorIsEnabled() - { - string settingXml = - @" + [TestMethod] + public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfInProcDataCollectorIsEnabled() + { + string settingXml = + @" false false @@ -415,19 +415,19 @@ public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfIn "; - var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); + var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); - var executionManager = this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria); + var executionManager = _testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria); - Assert.IsNotNull(executionManager); - Assert.IsNotInstanceOfType(executionManager, typeof(InProcessProxyExecutionManager)); - } + Assert.IsNotNull(executionManager); + Assert.IsNotInstanceOfType(executionManager, typeof(InProcessProxyExecutionManager)); + } - [TestMethod] - public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfrunsettingsHasTestSettingsInIt() - { - string settingXml = - @" + [TestMethod] + public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfrunsettingsHasTestSettingsInIt() + { + string settingXml = + @" false false @@ -439,20 +439,20 @@ public void GetExecutionManagerShouldNotReturnInProcessProxyexecutionManagerIfru "; - var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); + var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); - var executionManager = this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria); + var executionManager = _testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria); - Assert.IsNotNull(executionManager); - Assert.IsNotInstanceOfType(executionManager, typeof(InProcessProxyExecutionManager)); - } + Assert.IsNotNull(executionManager); + Assert.IsNotInstanceOfType(executionManager, typeof(InProcessProxyExecutionManager)); + } - [TestMethod] - public void GetExecutionManagerShouldReturnInProcessProxyexecutionManager() - { - string settingXml = - @" + [TestMethod] + public void GetExecutionManagerShouldReturnInProcessProxyexecutionManager() + { + string settingXml = + @" false false @@ -461,25 +461,25 @@ public void GetExecutionManagerShouldReturnInProcessProxyexecutionManager() "; - var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); + var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); - var executionManager = this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria); + var executionManager = _testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria); - Assert.IsNotNull(executionManager); - Assert.IsInstanceOfType(executionManager, typeof(InProcessProxyExecutionManager)); - } + Assert.IsNotNull(executionManager); + Assert.IsInstanceOfType(executionManager, typeof(InProcessProxyExecutionManager)); + } - [TestMethod] - public void GetExtensionManagerShouldReturnANonNullInstance() - { - Assert.IsNotNull(this.testEngine.GetExtensionManager()); - } + [TestMethod] + public void GetExtensionManagerShouldReturnANonNullInstance() + { + Assert.IsNotNull(_testEngine.GetExtensionManager()); + } - [TestMethod] - public void GetExtensionManagerShouldCollectMetrics() - { - string settingXml = - @" + [TestMethod] + public void GetExtensionManagerShouldCollectMetrics() + { + string settingXml = + @" false false @@ -488,180 +488,180 @@ public void GetExtensionManagerShouldCollectMetrics() "; - var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); + var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); - var executionManager = this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria); + var executionManager = _testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria); - this.mockMetricsCollection.Verify(mc => mc.Add(TelemetryDataConstants.ParallelEnabledDuringExecution, It.IsAny()), Times.Once); - } + _mockMetricsCollection.Verify(mc => mc.Add(TelemetryDataConstants.ParallelEnabledDuringExecution, It.IsAny()), Times.Once); + } - [TestMethod] - public void ProxyDataCollectionManagerShouldBeInitialzedWithCorrectTestSourcesWhenTestRunCriteriaContainsSourceList() - { - var settingXml = @""; + [TestMethod] + public void ProxyDataCollectionManagerShouldBeInitialzedWithCorrectTestSourcesWhenTestRunCriteriaContainsSourceList() + { + var settingXml = @""; - var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); + var testRunCriteria = new TestRunCriteria(new List { "1.dll", "2.dll" }, 100, false, settingXml); - var executionManager = this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria); + var executionManager = _testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria); - Assert.IsTrue((executionManager as ProxyExecutionManagerWithDataCollection).ProxyDataCollectionManager.Sources.Contains("1.dll")); - } + Assert.IsTrue((executionManager as ProxyExecutionManagerWithDataCollection).ProxyDataCollectionManager.Sources.Contains("1.dll")); + } - [TestMethod] - public void ProxyDataCollectionManagerShouldBeInitialzedWithCorrectTestSourcesWhenTestRunCriteriaContainsTestCaseList() - { - var settingXml = @""; + [TestMethod] + public void ProxyDataCollectionManagerShouldBeInitialzedWithCorrectTestSourcesWhenTestRunCriteriaContainsTestCaseList() + { + var settingXml = @""; - var testCaseList = new List { new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll") }; - var testRunCriteria = new TestRunCriteria(testCaseList, 100, false, settingXml); + var testCaseList = new List { new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll") }; + var testRunCriteria = new TestRunCriteria(testCaseList, 100, false, settingXml); - var executionManager = this.testEngine.GetExecutionManager(this.mockRequestData.Object, this.testableTestRuntimeProvider, testRunCriteria); + var executionManager = _testEngine.GetExecutionManager(_mockRequestData.Object, _testableTestRuntimeProvider, testRunCriteria); - Assert.IsTrue((executionManager as ProxyExecutionManagerWithDataCollection).ProxyDataCollectionManager.Sources.Contains("x.dll")); - } + Assert.IsTrue((executionManager as ProxyExecutionManagerWithDataCollection).ProxyDataCollectionManager.Sources.Contains("x.dll")); + } - /// - /// GetLoggerManager should return a non null instance. - /// - [TestMethod] - public void GetLoggerManagerShouldReturnNonNullInstance() - { - Assert.IsNotNull(this.testEngine.GetLoggerManager(mockRequestData.Object)); - } - - /// - /// GetLoggerManager should always return new instance of logger manager. - /// - [TestMethod] - public void GetLoggerManagerShouldAlwaysReturnNewInstance() - { - Assert.AreNotSame(this.testEngine.GetLoggerManager(mockRequestData.Object), this.testEngine.GetLoggerManager(mockRequestData.Object)); - } + /// + /// GetLoggerManager should return a non null instance. + /// + [TestMethod] + public void GetLoggerManagerShouldReturnNonNullInstance() + { + Assert.IsNotNull(_testEngine.GetLoggerManager(_mockRequestData.Object)); + } - [TestMethod] - public void GetTestSessionManagerShouldReturnAValidInstance() - { - var settingXml = @"true"; - var testSessionCriteria = new StartTestSessionCriteria() - { - Sources = new List { "1.dll" }, - RunSettings = settingXml - }; - - Assert.IsNotNull(this.testEngine.GetTestSessionManager( - this.mockRequestData.Object, - testSessionCriteria)); - } - - [TestMethod] - public void GetTestSessionManagerShouldReturnNewInstance() - { - var settingXml = @"true"; - var testSessionCriteria = new StartTestSessionCriteria() - { - Sources = new List { "1.dll" }, - RunSettings = settingXml - }; - - var testSessionManager1 = this.testEngine.GetTestSessionManager( - this.mockRequestData.Object, - testSessionCriteria); - - Assert.AreNotSame( - this.testEngine.GetTestSessionManager( - this.mockRequestData.Object, - testSessionCriteria), - testSessionManager1); - } - - [TestMethod] - public void GetTestSessionManagerShouldReturnDefaultTestSessionManagerIfParallelDisabled() + /// + /// GetLoggerManager should always return new instance of logger manager. + /// + [TestMethod] + public void GetLoggerManagerShouldAlwaysReturnNewInstance() + { + Assert.AreNotSame(_testEngine.GetLoggerManager(_mockRequestData.Object), _testEngine.GetLoggerManager(_mockRequestData.Object)); + } + + [TestMethod] + public void GetTestSessionManagerShouldReturnAValidInstance() + { + var settingXml = @"true"; + var testSessionCriteria = new StartTestSessionCriteria() { - var settingXml = @"true"; - var testSessionCriteria = new StartTestSessionCriteria() - { - Sources = new List { "1.dll" }, - RunSettings = settingXml - }; - - var testSessionManager = this.testEngine.GetTestSessionManager( - this.mockRequestData.Object, - testSessionCriteria); - - Assert.IsNotNull(testSessionManager); - Assert.IsInstanceOfType(testSessionManager, typeof(ProxyTestSessionManager)); - } - - [TestMethod] - public void GetTestSessionManagerShouldReturnDefaultTestSessionManagerEvenIfParallelEnabled() + Sources = new List { "1.dll" }, + RunSettings = settingXml + }; + + Assert.IsNotNull(_testEngine.GetTestSessionManager( + _mockRequestData.Object, + testSessionCriteria)); + } + + [TestMethod] + public void GetTestSessionManagerShouldReturnNewInstance() + { + var settingXml = @"true"; + var testSessionCriteria = new StartTestSessionCriteria() + { + Sources = new List { "1.dll" }, + RunSettings = settingXml + }; + + var testSessionManager1 = _testEngine.GetTestSessionManager( + _mockRequestData.Object, + testSessionCriteria); + + Assert.AreNotSame( + _testEngine.GetTestSessionManager( + _mockRequestData.Object, + testSessionCriteria), + testSessionManager1); + } + + [TestMethod] + public void GetTestSessionManagerShouldReturnDefaultTestSessionManagerIfParallelDisabled() + { + var settingXml = @"true"; + var testSessionCriteria = new StartTestSessionCriteria() { - string settingXml = - @" + Sources = new List { "1.dll" }, + RunSettings = settingXml + }; + + var testSessionManager = _testEngine.GetTestSessionManager( + _mockRequestData.Object, + testSessionCriteria); + + Assert.IsNotNull(testSessionManager); + Assert.IsInstanceOfType(testSessionManager, typeof(ProxyTestSessionManager)); + } + + [TestMethod] + public void GetTestSessionManagerShouldReturnDefaultTestSessionManagerEvenIfParallelEnabled() + { + string settingXml = + @" 2 true "; - var testSessionCriteria = new StartTestSessionCriteria() - { - Sources = new List { "1.dll" }, - RunSettings = settingXml - }; - - var testSessionManager = this.testEngine.GetTestSessionManager( - this.mockRequestData.Object, - testSessionCriteria); - - Assert.IsNotNull(testSessionManager); - Assert.IsInstanceOfType(testSessionManager, typeof(ProxyTestSessionManager)); - } - - [TestMethod] - public void GetTestSessionManagerShouldReturnDefaultTestSessionManagerIfParallelEnabled() + var testSessionCriteria = new StartTestSessionCriteria() { - string settingXml = @"2"; - var testSessionCriteria = new StartTestSessionCriteria() - { - Sources = new List { "1.dll", "2.dll" }, - RunSettings = settingXml - }; - - var testSessionManager = this.testEngine.GetTestSessionManager( - this.mockRequestData.Object, - testSessionCriteria); - - Assert.IsNotNull(testSessionManager); - Assert.IsInstanceOfType(testSessionManager, typeof(ProxyTestSessionManager)); - } - - [TestMethod] - public void GetTestSessionManagerShouldReturnDefaultTestSessionManagerIfHostIsNotShared() + Sources = new List { "1.dll" }, + RunSettings = settingXml + }; + + var testSessionManager = _testEngine.GetTestSessionManager( + _mockRequestData.Object, + testSessionCriteria); + + Assert.IsNotNull(testSessionManager); + Assert.IsInstanceOfType(testSessionManager, typeof(ProxyTestSessionManager)); + } + + [TestMethod] + public void GetTestSessionManagerShouldReturnDefaultTestSessionManagerIfParallelEnabled() + { + string settingXml = @"2"; + var testSessionCriteria = new StartTestSessionCriteria() { - string settingXml = - @" + Sources = new List { "1.dll", "2.dll" }, + RunSettings = settingXml + }; + + var testSessionManager = _testEngine.GetTestSessionManager( + _mockRequestData.Object, + testSessionCriteria); + + Assert.IsNotNull(testSessionManager); + Assert.IsInstanceOfType(testSessionManager, typeof(ProxyTestSessionManager)); + } + + [TestMethod] + public void GetTestSessionManagerShouldReturnDefaultTestSessionManagerIfHostIsNotShared() + { + string settingXml = + @" true "; - var testSessionCriteria = new StartTestSessionCriteria() - { - Sources = new List { "1.dll", "2.dll" }, - RunSettings = settingXml - }; - - var testSessionManager = this.testEngine.GetTestSessionManager( - this.mockRequestData.Object, - testSessionCriteria); - - Assert.IsNotNull(testSessionManager); - Assert.IsInstanceOfType(testSessionManager, typeof(ProxyTestSessionManager)); - } - - [TestMethod] - public void GetTestSessionManagerShouldReturnDefaultTestSessionManagerIfDataCollectionIsEnabled() + var testSessionCriteria = new StartTestSessionCriteria() { - var settingXml = - @" + Sources = new List { "1.dll", "2.dll" }, + RunSettings = settingXml + }; + + var testSessionManager = _testEngine.GetTestSessionManager( + _mockRequestData.Object, + testSessionCriteria); + + Assert.IsNotNull(testSessionManager); + Assert.IsInstanceOfType(testSessionManager, typeof(ProxyTestSessionManager)); + } + + [TestMethod] + public void GetTestSessionManagerShouldReturnDefaultTestSessionManagerIfDataCollectionIsEnabled() + { + var settingXml = + @" @@ -669,62 +669,62 @@ public void GetTestSessionManagerShouldReturnDefaultTestSessionManagerIfDataColl "; - var testSessionCriteria = new StartTestSessionCriteria() - { - Sources = new List { "1.dll" }, - RunSettings = settingXml - }; - - var testSessionManager = this.testEngine.GetTestSessionManager( - this.mockRequestData.Object, - testSessionCriteria); - - Assert.IsNotNull(testSessionManager); - Assert.IsInstanceOfType(testSessionManager, typeof(ProxyTestSessionManager)); - } - - [TestMethod] - public void GetTestSessionManagerShouldReturnNullWhenTargetFrameworkIsNetFramework() + var testSessionCriteria = new StartTestSessionCriteria() { - var settingXml = - @" + Sources = new List { "1.dll" }, + RunSettings = settingXml + }; + + var testSessionManager = _testEngine.GetTestSessionManager( + _mockRequestData.Object, + testSessionCriteria); + + Assert.IsNotNull(testSessionManager); + Assert.IsInstanceOfType(testSessionManager, typeof(ProxyTestSessionManager)); + } + + [TestMethod] + public void GetTestSessionManagerShouldReturnNullWhenTargetFrameworkIsNetFramework() + { + var settingXml = + @" .NETFramework, Version=v4.5 "; - var testSessionCriteria = new StartTestSessionCriteria() - { - Sources = new List { "1.dll" }, - RunSettings = settingXml - }; - - Assert.IsNull(this.testEngine.GetTestSessionManager( - this.mockRequestData.Object, - testSessionCriteria)); - } - - [TestMethod] - public void GetTestSessionManagerShouldReturnNotNullIfCurrentProcessIsDotnet() + var testSessionCriteria = new StartTestSessionCriteria() { - var testSessionCriteria = new StartTestSessionCriteria() - { - Sources = new List { "1.dll" }, - RunSettings = null - }; - this.mockProcessHelper.Setup(ph => ph.GetCurrentProcessFileName()).Returns("dotnet.exe"); - - var testSessionManager = this.testEngine.GetTestSessionManager( - this.mockRequestData.Object, - testSessionCriteria); - - Assert.IsNotNull(testSessionManager); - } - - [TestMethod] - public void GetTestSessionManagerShouldReturnNotNullIfDisableAppDomainIsSet() + Sources = new List { "1.dll" }, + RunSettings = settingXml + }; + + Assert.IsNull(_testEngine.GetTestSessionManager( + _mockRequestData.Object, + testSessionCriteria)); + } + + [TestMethod] + public void GetTestSessionManagerShouldReturnNotNullIfCurrentProcessIsDotnet() + { + var testSessionCriteria = new StartTestSessionCriteria() { - string settingXml = - @" + Sources = new List { "1.dll" }, + RunSettings = null + }; + _mockProcessHelper.Setup(ph => ph.GetCurrentProcessFileName()).Returns("dotnet.exe"); + + var testSessionManager = _testEngine.GetTestSessionManager( + _mockRequestData.Object, + testSessionCriteria); + + Assert.IsNotNull(testSessionManager); + } + + [TestMethod] + public void GetTestSessionManagerShouldReturnNotNullIfDisableAppDomainIsSet() + { + string settingXml = + @" x86 true @@ -733,24 +733,24 @@ public void GetTestSessionManagerShouldReturnNotNullIfDisableAppDomainIsSet() "; - var testSessionCriteria = new StartTestSessionCriteria() - { - Sources = new List { "1.dll" }, - RunSettings = settingXml - }; + var testSessionCriteria = new StartTestSessionCriteria() + { + Sources = new List { "1.dll" }, + RunSettings = settingXml + }; - var testSessionManager = this.testEngine.GetTestSessionManager( - this.mockRequestData.Object, - testSessionCriteria); + var testSessionManager = _testEngine.GetTestSessionManager( + _mockRequestData.Object, + testSessionCriteria); - Assert.IsNotNull(testSessionManager); - } + Assert.IsNotNull(testSessionManager); + } - [TestMethod] - public void GetTestSessionManagerShouldReturnNotNullIfDesignModeIsTrue() - { - string settingXml = - @" + [TestMethod] + public void GetTestSessionManagerShouldReturnNotNullIfDesignModeIsTrue() + { + string settingXml = + @" x86 false @@ -759,24 +759,24 @@ public void GetTestSessionManagerShouldReturnNotNullIfDesignModeIsTrue() "; - var testSessionCriteria = new StartTestSessionCriteria() - { - Sources = new List { "1.dll" }, - RunSettings = settingXml - }; + var testSessionCriteria = new StartTestSessionCriteria() + { + Sources = new List { "1.dll" }, + RunSettings = settingXml + }; - var testSessionManager = this.testEngine.GetTestSessionManager( - this.mockRequestData.Object, - testSessionCriteria); + var testSessionManager = _testEngine.GetTestSessionManager( + _mockRequestData.Object, + testSessionCriteria); - Assert.IsNotNull(testSessionManager); - } + Assert.IsNotNull(testSessionManager); + } - [TestMethod] - public void GetTestSessionManagerShouldReturnNotNullIfTargetFrameworkIsNetcoreApp() - { - string settingXml = - @" + [TestMethod] + public void GetTestSessionManagerShouldReturnNotNullIfTargetFrameworkIsNetcoreApp() + { + string settingXml = + @" x86 false @@ -785,24 +785,24 @@ public void GetTestSessionManagerShouldReturnNotNullIfTargetFrameworkIsNetcoreAp "; - var testSessionCriteria = new StartTestSessionCriteria() - { - Sources = new List { "1.dll" }, - RunSettings = settingXml - }; + var testSessionCriteria = new StartTestSessionCriteria() + { + Sources = new List { "1.dll" }, + RunSettings = settingXml + }; - var testSessionManager = this.testEngine.GetTestSessionManager( - this.mockRequestData.Object, - testSessionCriteria); + var testSessionManager = _testEngine.GetTestSessionManager( + _mockRequestData.Object, + testSessionCriteria); - Assert.IsNotNull(testSessionManager); - } + Assert.IsNotNull(testSessionManager); + } - [TestMethod] - public void GetTestSessionManagerShouldReturnNotNullIfTargetFrameworkIsNetStandard() - { - string settingXml = - @" + [TestMethod] + public void GetTestSessionManagerShouldReturnNotNullIfTargetFrameworkIsNetStandard() + { + string settingXml = + @" x86 false @@ -811,24 +811,24 @@ public void GetTestSessionManagerShouldReturnNotNullIfTargetFrameworkIsNetStanda "; - var testSessionCriteria = new StartTestSessionCriteria() - { - Sources = new List { "1.dll" }, - RunSettings = settingXml - }; + var testSessionCriteria = new StartTestSessionCriteria() + { + Sources = new List { "1.dll" }, + RunSettings = settingXml + }; - var testSessionManager = this.testEngine.GetTestSessionManager( - this.mockRequestData.Object, - testSessionCriteria); + var testSessionManager = _testEngine.GetTestSessionManager( + _mockRequestData.Object, + testSessionCriteria); - Assert.IsNotNull(testSessionManager); - } + Assert.IsNotNull(testSessionManager); + } - [TestMethod] - public void GetTestSessionManagerShouldReturnNotNullIfTargetPlatformIsX64() - { - string settingXml = - @" + [TestMethod] + public void GetTestSessionManagerShouldReturnNotNullIfTargetPlatformIsX64() + { + string settingXml = + @" x64 false @@ -837,24 +837,24 @@ public void GetTestSessionManagerShouldReturnNotNullIfTargetPlatformIsX64() "; - var testSessionCriteria = new StartTestSessionCriteria() - { - Sources = new List { "1.dll" }, - RunSettings = settingXml - }; + var testSessionCriteria = new StartTestSessionCriteria() + { + Sources = new List { "1.dll" }, + RunSettings = settingXml + }; - var testSessionManager = this.testEngine.GetTestSessionManager( - this.mockRequestData.Object, - testSessionCriteria); + var testSessionManager = _testEngine.GetTestSessionManager( + _mockRequestData.Object, + testSessionCriteria); - Assert.IsNotNull(testSessionManager); - } + Assert.IsNotNull(testSessionManager); + } - [TestMethod] - public void GetTestSessionManagerShouldReturnNotNullIfRunSettingsHasTestSettingsInIt() - { - string settingXml = - @" + [TestMethod] + public void GetTestSessionManagerShouldReturnNotNullIfRunSettingsHasTestSettingsInIt() + { + string settingXml = + @" x86 false @@ -866,17 +866,16 @@ public void GetTestSessionManagerShouldReturnNotNullIfRunSettingsHasTestSettings "; - var testSessionCriteria = new StartTestSessionCriteria() - { - Sources = new List { "1.dll" }, - RunSettings = settingXml - }; + var testSessionCriteria = new StartTestSessionCriteria() + { + Sources = new List { "1.dll" }, + RunSettings = settingXml + }; - var testSessionManager = this.testEngine.GetTestSessionManager( - this.mockRequestData.Object, - testSessionCriteria); + var testSessionManager = _testEngine.GetTestSessionManager( + _mockRequestData.Object, + testSessionCriteria); - Assert.IsNotNull(testSessionManager); - } + Assert.IsNotNull(testSessionManager); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestExtensionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestExtensionManagerTests.cs index f964f88853..1d01824900 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestExtensionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestExtensionManagerTests.cs @@ -1,54 +1,53 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests -{ - using System.Collections.Generic; - using System.Reflection; +namespace TestPlatform.CrossPlatEngine.UnitTests; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +using System.Reflection; - [TestClass] - public class TestExtensionManagerTests - { - private ITestExtensionManager testExtensionManager; +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; +using Microsoft.VisualStudio.TestTools.UnitTesting; - public TestExtensionManagerTests() - { - this.testExtensionManager = new TestExtensionManager(); +[TestClass] +public class TestExtensionManagerTests +{ + private readonly ITestExtensionManager _testExtensionManager; - // Reset the singleton - TestPluginCache.Instance = null; - } + public TestExtensionManagerTests() + { + _testExtensionManager = new TestExtensionManager(); - [TestCleanup] - public void TestCleanup() - { - TestPluginCache.Instance = null; - } + // Reset the singleton + TestPluginCache.Instance = null; + } - [TestMethod] - public void UseAdditionalExtensionsShouldUpdateAdditionalExtensionsInCache() - { - var extensions = new List { typeof(TestExtensionManagerTests).GetTypeInfo().Assembly.Location }; + [TestCleanup] + public void TestCleanup() + { + TestPluginCache.Instance = null; + } - this.testExtensionManager.UseAdditionalExtensions(extensions, true); + [TestMethod] + public void UseAdditionalExtensionsShouldUpdateAdditionalExtensionsInCache() + { + var extensions = new List { typeof(TestExtensionManagerTests).GetTypeInfo().Assembly.Location }; - CollectionAssert.AreEquivalent(extensions, TestPluginCache.Instance.GetExtensionPaths(string.Empty)); - } + _testExtensionManager.UseAdditionalExtensions(extensions, true); - [TestMethod] - public void ClearExtensionsShouldClearExtensionsInCache() - { - var extensions = new List { @"Foo.dll" }; - this.testExtensionManager.UseAdditionalExtensions(extensions, false); + CollectionAssert.AreEquivalent(extensions, TestPluginCache.Instance.GetExtensionPaths(string.Empty)); + } + + [TestMethod] + public void ClearExtensionsShouldClearExtensionsInCache() + { + var extensions = new List { @"Foo.dll" }; + _testExtensionManager.UseAdditionalExtensions(extensions, false); - this.testExtensionManager.ClearExtensions(); + _testExtensionManager.ClearExtensions(); - Assert.AreEqual(0, TestPluginCache.Instance.GetExtensionPaths(string.Empty).Count); - } + Assert.AreEqual(0, TestPluginCache.Instance.GetExtensionPaths(string.Empty).Count); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestHostManagerFactoryTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestHostManagerFactoryTests.cs index d277598365..c5286fed60 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestHostManagerFactoryTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestHostManagerFactoryTests.cs @@ -1,59 +1,58 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests +namespace TestPlatform.CrossPlatEngine.UnitTests; + +using System; + +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class TestHostManagerFactoryTests { - using System; + private readonly TestHostManagerFactory _testHostManagerFactory; + private readonly Mock _mockRequestData; + private readonly Mock _mockMetricsCollection; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestTools.UnitTesting; + public TestHostManagerFactoryTests() + { + _mockMetricsCollection = new Mock(); + _mockRequestData = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(_mockMetricsCollection.Object); + _testHostManagerFactory = new TestHostManagerFactory(_mockRequestData.Object); + } + + [TestMethod] + public void ConstructorShouldThrowIfRequestDataIsNull() + { + Assert.ThrowsException(() => new TestHostManagerFactory(null)); + } - using Moq; + [TestMethod] + public void GetDiscoveryManagerShouldReturnADiscoveryManagerInstance() + { + Assert.IsNotNull(_testHostManagerFactory.GetDiscoveryManager()); + } + + [TestMethod] + public void GetDiscoveryManagerShouldCacheTheDiscoveryManagerInstance() + { + Assert.AreEqual(_testHostManagerFactory.GetDiscoveryManager(), _testHostManagerFactory.GetDiscoveryManager()); + } + + [TestMethod] + public void GetDiscoveryManagerShouldReturnAnExecutionManagerInstance() + { + Assert.IsNotNull(_testHostManagerFactory.GetExecutionManager()); + } - [TestClass] - public class TestHostManagerFactoryTests + [TestMethod] + public void GetDiscoveryManagerShouldCacheTheExecutionManagerInstance() { - private TestHostManagerFactory testHostManagerFactory; - private Mock mockRequestData; - private Mock mockMetricsCollection; - - public TestHostManagerFactoryTests() - { - this.mockMetricsCollection = new Mock(); - this.mockRequestData = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(this.mockMetricsCollection.Object); - this.testHostManagerFactory = new TestHostManagerFactory(this.mockRequestData.Object); - } - - [TestMethod] - public void ConstructorShouldThrowIfRequestDataIsNull() - { - Assert.ThrowsException(() => new TestHostManagerFactory(null)); - } - - [TestMethod] - public void GetDiscoveryManagerShouldReturnADiscoveryManagerInstance() - { - Assert.IsNotNull(this.testHostManagerFactory.GetDiscoveryManager()); - } - - [TestMethod] - public void GetDiscoveryManagerShouldCacheTheDiscoveryManagerInstance() - { - Assert.AreEqual(this.testHostManagerFactory.GetDiscoveryManager(), this.testHostManagerFactory.GetDiscoveryManager()); - } - - [TestMethod] - public void GetDiscoveryManagerShouldReturnAnExecutionManagerInstance() - { - Assert.IsNotNull(this.testHostManagerFactory.GetExecutionManager()); - } - - [TestMethod] - public void GetDiscoveryManagerShouldCacheTheExecutionManagerInstance() - { - Assert.AreEqual(this.testHostManagerFactory.GetExecutionManager(), this.testHostManagerFactory.GetExecutionManager()); - } + Assert.AreEqual(_testHostManagerFactory.GetExecutionManager(), _testHostManagerFactory.GetExecutionManager()); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestLoggerManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestLoggerManagerTests.cs index 9acef39540..4adf37e899 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestLoggerManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestLoggerManagerTests.cs @@ -3,78 +3,79 @@ using Microsoft.VisualStudio.TestPlatform.Common.Exceptions; -namespace TestPlatform.CrossPlatEngine.UnitTests +namespace TestPlatform.CrossPlatEngine.UnitTests; + +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Threading; + +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.Common.Logging; +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +using ObjectModel = Microsoft.VisualStudio.TestPlatform.ObjectModel; + +/// +/// Tests the behaviors of the TestLoggerManager class. +/// +[TestClass] +public class TestLoggerManagerTests { - using System; - using System.Collections.Generic; - using System.Reflection; - using System.Threading; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - using ObjectModel = Microsoft.VisualStudio.TestPlatform.ObjectModel; + private static int s_counter = 0; + private static readonly EventWaitHandle WaitHandle = new AutoResetEvent(false); + private readonly string _loggerUri = "testlogger://logger"; - /// - /// Tests the behaviors of the TestLoggerManager class. - /// - [TestClass] - public class TestLoggerManagerTests + [TestInitialize] + public void Initialize() { - private static int counter = 0; - private static EventWaitHandle waitHandle = new AutoResetEvent(false); - private string loggerUri = "testlogger://logger"; - - [TestInitialize] - public void Initialize() - { - TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location }, - () => { }); - } + TestPluginCacheHelper.SetupMockExtensions( + new string[] { typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location }, + () => { }); + } - [TestCleanup] - public void TestCleanup() - { - TestPluginCacheHelper.ResetExtensionsCache(); - } + [TestCleanup] + public void TestCleanup() + { + TestPluginCacheHelper.ResetExtensionsCache(); + } - [TestMethod] - public void TryGetUriFromFriendlyNameShouldReturnUriIfLoggerIsAdded() - { - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.InitializeLoggerByUri(new Uri(loggerUri), new Dictionary()); - testLoggerManager.TryGetUriFromFriendlyName("TestLoggerExtension", out var uri); - Assert.AreEqual(uri.ToString(), new Uri(loggerUri).ToString()); - } + [TestMethod] + public void TryGetUriFromFriendlyNameShouldReturnUriIfLoggerIsAdded() + { + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); + testLoggerManager.TryGetUriFromFriendlyName("TestLoggerExtension", out var uri); + Assert.AreEqual(uri.ToString(), new Uri(_loggerUri).ToString()); + } - [TestMethod] - public void TryGetUriFromFriendlyNameShouldNotReturnUriIfLoggerIsNotAdded() - { - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.TryGetUriFromFriendlyName("TestLoggerExtension1", out var uri); - Assert.IsNull(uri); - } + [TestMethod] + public void TryGetUriFromFriendlyNameShouldNotReturnUriIfLoggerIsNotAdded() + { + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.TryGetUriFromFriendlyName("TestLoggerExtension1", out var uri); + Assert.IsNull(uri); + } - [TestMethod] - public void GetResultsDirectoryShouldReturnNullIfRunSettingsIsNull() - { - var testLoggerManager = new DummyTestLoggerManager(); - string result = testLoggerManager.GetResultsDirectory(null); - Assert.IsNull(result); - } + [TestMethod] + public void GetResultsDirectoryShouldReturnNullIfRunSettingsIsNull() + { + var testLoggerManager = new DummyTestLoggerManager(); + string result = testLoggerManager.GetResultsDirectory(null); + Assert.IsNull(result); + } - [TestMethod] - public void GetResultsDirectoryShouldReadResultsDirectoryFromSettingsIfSpecified() - { - string runSettingsXml = @" + [TestMethod] + public void GetResultsDirectoryShouldReadResultsDirectoryFromSettingsIfSpecified() + { + string runSettingsXml = @" 0 @@ -84,15 +85,15 @@ public void GetResultsDirectoryShouldReadResultsDirectoryFromSettingsIfSpecified "; - var testLoggerManager = new DummyTestLoggerManager(); - string result = testLoggerManager.GetResultsDirectory(runSettingsXml); - Assert.AreEqual(0, string.Compare("DummyTestResultsFolder", result)); - } + var testLoggerManager = new DummyTestLoggerManager(); + string result = testLoggerManager.GetResultsDirectory(runSettingsXml); + Assert.AreEqual(0, string.Compare("DummyTestResultsFolder", result)); + } - [TestMethod] - public void GetResultsDirectoryShouldReturnDefaultPathIfResultsDirectoryIsNotProvidedInRunSettings() - { - string runSettingsXml = @" + [TestMethod] + public void GetResultsDirectoryShouldReturnDefaultPathIfResultsDirectoryIsNotProvidedInRunSettings() + { + string runSettingsXml = @" 0 @@ -101,16 +102,16 @@ public void GetResultsDirectoryShouldReturnDefaultPathIfResultsDirectoryIsNotPro "; - var testLoggerManager = new DummyTestLoggerManager(); - string result = testLoggerManager.GetResultsDirectory(runSettingsXml); + var testLoggerManager = new DummyTestLoggerManager(); + string result = testLoggerManager.GetResultsDirectory(runSettingsXml); - Assert.AreEqual(0, string.Compare(Constants.DefaultResultsDirectory, result)); - } + Assert.AreEqual(0, string.Compare(Constants.DefaultResultsDirectory, result)); + } - [TestMethod] - public void GetTargetFrameworkShouldReturnFrameworkProvidedInRunSettings() - { - string runSettingsXml = @" + [TestMethod] + public void GetTargetFrameworkShouldReturnFrameworkProvidedInRunSettings() + { + string runSettingsXml = @" 0 @@ -119,174 +120,171 @@ public void GetTargetFrameworkShouldReturnFrameworkProvidedInRunSettings() "; - var testLoggerManager = new DummyTestLoggerManager(); - var framework = testLoggerManager.GetTargetFramework(runSettingsXml); - - Assert.AreEqual(".NETFramework,Version=v4.5", framework.Name); - } + var testLoggerManager = new DummyTestLoggerManager(); + var framework = testLoggerManager.GetTargetFramework(runSettingsXml); - [TestMethod] - public void HandleTestRunMessageShouldInvokeTestRunMessageHandlerOfLoggers() - { - counter = 0; - waitHandle.Reset(); - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.InitializeLoggerByUri(new Uri(loggerUri), new Dictionary()); - testLoggerManager.EnableLogging(); + Assert.AreEqual(".NETFramework,Version=v4.5", framework.Name); + } - testLoggerManager.HandleTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Informational, "TestRunMessage")); + [TestMethod] + public void HandleTestRunMessageShouldInvokeTestRunMessageHandlerOfLoggers() + { + s_counter = 0; + WaitHandle.Reset(); + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); + testLoggerManager.EnableLogging(); - waitHandle.WaitOne(); - Assert.AreEqual(1, counter); - } + testLoggerManager.HandleTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Informational, "TestRunMessage")); - [TestMethod] - public void HandleTestRunMessageShouldNotInvokeTestRunMessageHandlerOfLoggersIfDisposed() - { - counter = 0; - waitHandle.Reset(); - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.InitializeLoggerByUri(new Uri(loggerUri), new Dictionary()); - testLoggerManager.EnableLogging(); + WaitHandle.WaitOne(); + Assert.AreEqual(1, s_counter); + } - testLoggerManager.Dispose(); - testLoggerManager.HandleTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Informational, "TestRunMessage")); + [TestMethod] + public void HandleTestRunMessageShouldNotInvokeTestRunMessageHandlerOfLoggersIfDisposed() + { + s_counter = 0; + WaitHandle.Reset(); + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); + testLoggerManager.EnableLogging(); - Assert.AreEqual(0, counter); - } + testLoggerManager.Dispose(); + testLoggerManager.HandleTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Informational, "TestRunMessage")); - [TestMethod] - public void HandleTestRunCompleteShouldInvokeTestRunCompleteHandlerOfLoggers() - { - counter = 0; - waitHandle.Reset(); - // setup TestLogger - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.InitializeLoggerByUri(new Uri(loggerUri), new Dictionary()); - testLoggerManager.EnableLogging(); + Assert.AreEqual(0, s_counter); + } - testLoggerManager.HandleTestRunComplete(new TestRunCompleteEventArgs(null, false, false, null, null, null, new TimeSpan())); + [TestMethod] + public void HandleTestRunCompleteShouldInvokeTestRunCompleteHandlerOfLoggers() + { + s_counter = 0; + WaitHandle.Reset(); + // setup TestLogger + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); + testLoggerManager.EnableLogging(); - waitHandle.WaitOne(); - Assert.AreEqual(1, counter); - } + testLoggerManager.HandleTestRunComplete(new TestRunCompleteEventArgs(null, false, false, null, null, null, new TimeSpan())); - [TestMethod] - public void HandleTestRunCompleteShouldNotInvokeTestRunCompleteHandlerOfLoggersIfDisposed() - { - counter = 0; - waitHandle.Reset(); - // setup TestLogger - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.InitializeLoggerByUri(new Uri(loggerUri), new Dictionary()); - testLoggerManager.EnableLogging(); + WaitHandle.WaitOne(); + Assert.AreEqual(1, s_counter); + } - testLoggerManager.Dispose(); - testLoggerManager.HandleTestRunComplete(new TestRunCompleteEventArgs(null, false, false, null, null, null, new TimeSpan())); + [TestMethod] + public void HandleTestRunCompleteShouldNotInvokeTestRunCompleteHandlerOfLoggersIfDisposed() + { + s_counter = 0; + WaitHandle.Reset(); + // setup TestLogger + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); + testLoggerManager.EnableLogging(); - Assert.AreEqual(0, counter); - } + testLoggerManager.Dispose(); + testLoggerManager.HandleTestRunComplete(new TestRunCompleteEventArgs(null, false, false, null, null, null, new TimeSpan())); - [TestMethod] - public void HandleTestRunCompleteShouldDisposeLoggerManager() - { - counter = 0; - waitHandle.Reset(); - // setup TestLogger - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.InitializeLoggerByUri(new Uri(loggerUri), new Dictionary()); - testLoggerManager.EnableLogging(); + Assert.AreEqual(0, s_counter); + } - testLoggerManager.HandleTestRunComplete(new TestRunCompleteEventArgs(null, false, false, null, null, null, new TimeSpan())); - testLoggerManager.HandleTestRunComplete(new TestRunCompleteEventArgs(null, false, false, null, null, null, new TimeSpan())); // count should not increase because of second call. + [TestMethod] + public void HandleTestRunCompleteShouldDisposeLoggerManager() + { + s_counter = 0; + WaitHandle.Reset(); + // setup TestLogger + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); + testLoggerManager.EnableLogging(); - Assert.AreEqual(1, counter); - } + testLoggerManager.HandleTestRunComplete(new TestRunCompleteEventArgs(null, false, false, null, null, null, new TimeSpan())); + testLoggerManager.HandleTestRunComplete(new TestRunCompleteEventArgs(null, false, false, null, null, null, new TimeSpan())); // count should not increase because of second call. - [TestMethod] - public void HandleTestRunStatsChangeShouldInvokeTestRunChangedHandlerOfLoggers() - { - counter = 0; - waitHandle.Reset(); - // setup TestLogger - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.InitializeLoggerByUri(new Uri(loggerUri), new Dictionary()); - testLoggerManager.EnableLogging(); - - testLoggerManager.HandleTestRunStatsChange( - new TestRunChangedEventArgs( - null, - new List() - { - new ObjectModel.TestResult( - new TestCase( - "This is a string.", - new Uri("some://uri"), - "This is a string.")) - }, - null)); - - waitHandle.WaitOne(); - Assert.AreEqual(1, counter); - } + Assert.AreEqual(1, s_counter); + } - [TestMethod] - public void HandleTestRunStatsChangeShouldNotInvokeTestRunChangedHandlerOfLoggersIfDisposed() - { - counter = 0; - waitHandle.Reset(); - // setup TestLogger - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.InitializeLoggerByUri(new Uri(loggerUri), new Dictionary()); - testLoggerManager.EnableLogging(); - - testLoggerManager.Dispose(); - testLoggerManager.HandleTestRunStatsChange( - new TestRunChangedEventArgs( - null, - new List() - { - new ObjectModel.TestResult( - new TestCase( - "This is a string.", - new Uri("some://uri"), - "This is a string.")) - }, - null)); - - Assert.AreEqual(0, counter); - } + [TestMethod] + public void HandleTestRunStatsChangeShouldInvokeTestRunChangedHandlerOfLoggers() + { + s_counter = 0; + WaitHandle.Reset(); + // setup TestLogger + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); + testLoggerManager.EnableLogging(); + + testLoggerManager.HandleTestRunStatsChange( + new TestRunChangedEventArgs( + null, + new List() + { + new ObjectModel.TestResult( + new TestCase( + "This is a string.", + new Uri("some://uri"), + "This is a string.")) + }, + null)); + + WaitHandle.WaitOne(); + Assert.AreEqual(1, s_counter); + } - [TestMethod] - public void AddLoggerShouldNotThrowExceptionIfUriIsNull() - { - var testLoggerManager = new DummyTestLoggerManager(); - Assert.ThrowsException( - () => + [TestMethod] + public void HandleTestRunStatsChangeShouldNotInvokeTestRunChangedHandlerOfLoggersIfDisposed() + { + s_counter = 0; + WaitHandle.Reset(); + // setup TestLogger + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); + testLoggerManager.EnableLogging(); + + testLoggerManager.Dispose(); + testLoggerManager.HandleTestRunStatsChange( + new TestRunChangedEventArgs( + null, + new List() { - testLoggerManager.InitializeLoggerByUri(null, null); - }); - } + new ObjectModel.TestResult( + new TestCase( + "This is a string.", + new Uri("some://uri"), + "This is a string.")) + }, + null)); + + Assert.AreEqual(0, s_counter); + } - [TestMethod] - public void AddLoggerShouldNotThrowExceptionIfUriIsNonExistent() - { - var testLoggerManager = new DummyTestLoggerManager(); - Assert.IsFalse(testLoggerManager.InitializeLoggerByUri(new Uri("logger://NotALogger"), null)); - } + [TestMethod] + public void AddLoggerShouldNotThrowExceptionIfUriIsNull() + { + var testLoggerManager = new DummyTestLoggerManager(); + Assert.ThrowsException( + () => testLoggerManager.InitializeLoggerByUri(null, null)); + } - [TestMethod] - public void AddLoggerShouldAddDefaultLoggerParameterForTestLoggerWithParameters() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void AddLoggerShouldNotThrowExceptionIfUriIsNonExistent() + { + var testLoggerManager = new DummyTestLoggerManager(); + Assert.IsFalse(testLoggerManager.InitializeLoggerByUri(new Uri("logger://NotALogger"), null)); + } - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + [TestMethod] + public void AddLoggerShouldAddDefaultLoggerParameterForTestLoggerWithParameters() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - string settingsXml = - @" + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + + string settingsXml = + @" 0 @@ -301,333 +299,327 @@ public void AddLoggerShouldAddDefaultLoggerParameterForTestLoggerWithParameters( "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); - - Assert.IsNotNull(ValidLoggerWithParameters.parameters, "parameters not getting passed"); - Assert.IsTrue( - ValidLoggerWithParameters.parameters.ContainsKey(DefaultLoggerParameterNames.TestRunDirectory), - $"{DefaultLoggerParameterNames.TestRunDirectory} not added to parameters"); - Assert.IsFalse( - string.IsNullOrWhiteSpace( - ValidLoggerWithParameters.parameters[DefaultLoggerParameterNames.TestRunDirectory]), - $"parameter {DefaultLoggerParameterNames.TestRunDirectory} should not be null, empty or whitespace"); - } + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); + + Assert.IsNotNull(ValidLoggerWithParameters.Parameters, "parameters not getting passed"); + Assert.IsTrue( + ValidLoggerWithParameters.Parameters.ContainsKey(DefaultLoggerParameterNames.TestRunDirectory), + $"{DefaultLoggerParameterNames.TestRunDirectory} not added to parameters"); + Assert.IsFalse( + string.IsNullOrWhiteSpace( + ValidLoggerWithParameters.Parameters[DefaultLoggerParameterNames.TestRunDirectory]), + $"parameter {DefaultLoggerParameterNames.TestRunDirectory} should not be null, empty or whitespace"); + } - [TestMethod] - public void DisposeShouldNotThrowExceptionIfCalledMultipleTimes() - { - // Dispose the logger manager multiple times and verify that no exception is thrown. - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.Dispose(); - testLoggerManager.Dispose(); - } + [TestMethod] + public void DisposeShouldNotThrowExceptionIfCalledMultipleTimes() + { + // Dispose the logger manager multiple times and verify that no exception is thrown. + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.Dispose(); + testLoggerManager.Dispose(); + } - [TestMethod] - public void AddLoggerShouldThrowObjectDisposedExceptionAfterDisposedIsCalled() - { - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.Dispose(); + [TestMethod] + public void AddLoggerShouldThrowObjectDisposedExceptionAfterDisposedIsCalled() + { + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.Dispose(); - Assert.ThrowsException( - () => - { - testLoggerManager.InitializeLoggerByUri(new Uri("some://uri"), null); - }); - } + Assert.ThrowsException( + () => testLoggerManager.InitializeLoggerByUri(new Uri("some://uri"), null)); + } - [TestMethod] - public void EnableLoggingShouldThrowObjectDisposedExceptionAfterDisposedIsCalled() - { - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.Dispose(); - Assert.ThrowsException( - () => - { - testLoggerManager.EnableLogging(); - }); - } + [TestMethod] + public void EnableLoggingShouldThrowObjectDisposedExceptionAfterDisposedIsCalled() + { + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.Dispose(); + Assert.ThrowsException( + () => testLoggerManager.EnableLogging()); + } - [TestMethod] - public void LoggerInitialzeShouldCollectLoggersForTelemetry() - { - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void LoggerInitialzeShouldCollectLoggersForTelemetry() + { + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.InitializeLoggerByUri(new Uri(this.loggerUri), new Dictionary()); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); - // Act. - testLoggerManager.Initialize(null); + // Act. + testLoggerManager.Initialize(null); - // Verify - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger")); - } + // Verify + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger")); + } - /// - /// DiscoveryStart event handler of loggers should be called only if discovery events are registered. - /// - [TestMethod] - public void HandleDiscoveryStartShouldInvokeDiscoveryStartHandlerOfLoggers() - { - counter = 0; - waitHandle.Reset(); + /// + /// DiscoveryStart event handler of loggers should be called only if discovery events are registered. + /// + [TestMethod] + public void HandleDiscoveryStartShouldInvokeDiscoveryStartHandlerOfLoggers() + { + s_counter = 0; + WaitHandle.Reset(); - DiscoveryCriteria discoveryCriteria = new DiscoveryCriteria() { TestCaseFilter = "Name=Test1" }; - DiscoveryStartEventArgs discoveryStartEventArgs = new DiscoveryStartEventArgs(discoveryCriteria); + DiscoveryCriteria discoveryCriteria = new() { TestCaseFilter = "Name=Test1" }; + DiscoveryStartEventArgs discoveryStartEventArgs = new(discoveryCriteria); - // setup TestLogger - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.InitializeLoggerByUri(new Uri(loggerUri), new Dictionary()); - testLoggerManager.EnableLogging(); + // setup TestLogger + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); + testLoggerManager.EnableLogging(); - testLoggerManager.HandleDiscoveryStart(discoveryStartEventArgs); + testLoggerManager.HandleDiscoveryStart(discoveryStartEventArgs); - // Assertions when discovery events registered - waitHandle.WaitOne(); - Assert.AreEqual(1, counter); - } + // Assertions when discovery events registered + WaitHandle.WaitOne(); + Assert.AreEqual(1, s_counter); + } - /// - /// DiscoveryStart event handler of loggers should be called only if discovery events are registered. - /// - [TestMethod] - public void HandleDiscoveryStartShouldNotInvokeDiscoveryStartHandlerOfLoggersIfDisposed() - { - counter = 0; - waitHandle.Reset(); + /// + /// DiscoveryStart event handler of loggers should be called only if discovery events are registered. + /// + [TestMethod] + public void HandleDiscoveryStartShouldNotInvokeDiscoveryStartHandlerOfLoggersIfDisposed() + { + s_counter = 0; + WaitHandle.Reset(); - DiscoveryCriteria discoveryCriteria = new DiscoveryCriteria() { TestCaseFilter = "Name=Test1" }; - DiscoveryStartEventArgs discoveryStartEventArgs = new DiscoveryStartEventArgs(discoveryCriteria); + DiscoveryCriteria discoveryCriteria = new() { TestCaseFilter = "Name=Test1" }; + DiscoveryStartEventArgs discoveryStartEventArgs = new(discoveryCriteria); - // setup TestLogger - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.InitializeLoggerByUri(new Uri(loggerUri), new Dictionary()); - testLoggerManager.EnableLogging(); + // setup TestLogger + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); + testLoggerManager.EnableLogging(); - testLoggerManager.Dispose(); - testLoggerManager.HandleDiscoveryStart(discoveryStartEventArgs); + testLoggerManager.Dispose(); + testLoggerManager.HandleDiscoveryStart(discoveryStartEventArgs); - // Assertions when discovery events registered - Assert.AreEqual(0, counter); - } + // Assertions when discovery events registered + Assert.AreEqual(0, s_counter); + } - /// - /// DiscoveredTests event handler of loggers should be called only if discovery events are registered. - /// - [TestMethod] - public void HandleDiscoveredTestsShouldInvokeDiscoveredTestsHandlerOfLoggers() - { - counter = 0; - waitHandle.Reset(); + /// + /// DiscoveredTests event handler of loggers should be called only if discovery events are registered. + /// + [TestMethod] + public void HandleDiscoveredTestsShouldInvokeDiscoveredTestsHandlerOfLoggers() + { + s_counter = 0; + WaitHandle.Reset(); - List testCases = new List { new TestCase("This is a string.", new Uri("some://uri"), "DummySourceFileName") }; - DiscoveredTestsEventArgs discoveredTestsEventArgs = new DiscoveredTestsEventArgs(testCases); + List testCases = new() { new TestCase("This is a string.", new Uri("some://uri"), "DummySourceFileName") }; + DiscoveredTestsEventArgs discoveredTestsEventArgs = new(testCases); - // setup TestLogger - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.InitializeLoggerByUri(new Uri(loggerUri), new Dictionary()); - testLoggerManager.EnableLogging(); + // setup TestLogger + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); + testLoggerManager.EnableLogging(); - testLoggerManager.HandleDiscoveredTests(discoveredTestsEventArgs); + testLoggerManager.HandleDiscoveredTests(discoveredTestsEventArgs); - // Assertions when discovery events registered - waitHandle.WaitOne(); - Assert.AreEqual(1, counter); - } + // Assertions when discovery events registered + WaitHandle.WaitOne(); + Assert.AreEqual(1, s_counter); + } - [TestMethod] - public void HandleDiscoveredTestsShouldNotInvokeDiscoveredTestsHandlerOfLoggersIfDisposed() - { - counter = 0; - waitHandle.Reset(); + [TestMethod] + public void HandleDiscoveredTestsShouldNotInvokeDiscoveredTestsHandlerOfLoggersIfDisposed() + { + s_counter = 0; + WaitHandle.Reset(); - List testCases = new List { new TestCase("This is a string.", new Uri("some://uri"), "DummySourceFileName") }; - DiscoveredTestsEventArgs discoveredTestsEventArgs = new DiscoveredTestsEventArgs(testCases); + List testCases = new() { new TestCase("This is a string.", new Uri("some://uri"), "DummySourceFileName") }; + DiscoveredTestsEventArgs discoveredTestsEventArgs = new(testCases); - // setup TestLogger - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.InitializeLoggerByUri(new Uri(loggerUri), new Dictionary()); - testLoggerManager.EnableLogging(); + // setup TestLogger + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); + testLoggerManager.EnableLogging(); - testLoggerManager.Dispose(); - testLoggerManager.HandleDiscoveredTests(discoveredTestsEventArgs); + testLoggerManager.Dispose(); + testLoggerManager.HandleDiscoveredTests(discoveredTestsEventArgs); - // Assertions when discovery events registered - Assert.AreEqual(0, counter); - } + // Assertions when discovery events registered + Assert.AreEqual(0, s_counter); + } - /// - /// TestRunStart event handler of loggers should be called only if test run events are registered. - /// - [TestMethod] - public void HandleTestRunStartShouldInvokeTestRunStartHandlerOfLoggers() - { - counter = 0; - waitHandle.Reset(); + /// + /// TestRunStart event handler of loggers should be called only if test run events are registered. + /// + [TestMethod] + public void HandleTestRunStartShouldInvokeTestRunStartHandlerOfLoggers() + { + s_counter = 0; + WaitHandle.Reset(); - TestRunCriteria testRunCriteria = new TestRunCriteria(new List { @"x:dummy\foo.dll" }, 10, false, string.Empty, TimeSpan.MaxValue, null, "Name=Test1", null); - TestRunStartEventArgs testRunStartEventArgs = new TestRunStartEventArgs(testRunCriteria); + TestRunCriteria testRunCriteria = new(new List { @"x:dummy\foo.dll" }, 10, false, string.Empty, TimeSpan.MaxValue, null, "Name=Test1", null); + TestRunStartEventArgs testRunStartEventArgs = new(testRunCriteria); - // setup TestLogger - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.InitializeLoggerByUri(new Uri(loggerUri), new Dictionary()); - testLoggerManager.EnableLogging(); + // setup TestLogger + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); + testLoggerManager.EnableLogging(); - testLoggerManager.HandleTestRunStart(testRunStartEventArgs); + testLoggerManager.HandleTestRunStart(testRunStartEventArgs); - // Assertions when test run events registered - waitHandle.WaitOne(); - Assert.AreEqual(1, counter); - } + // Assertions when test run events registered + WaitHandle.WaitOne(); + Assert.AreEqual(1, s_counter); + } - /// - /// TestRunStart event handler of loggers should be called only if test run events are registered. - /// - [TestMethod] - public void HandleTestRunStartShouldNotInvokeTestRunStartHandlerOfLoggersIfDisposed() - { - counter = 0; - waitHandle.Reset(); + /// + /// TestRunStart event handler of loggers should be called only if test run events are registered. + /// + [TestMethod] + public void HandleTestRunStartShouldNotInvokeTestRunStartHandlerOfLoggersIfDisposed() + { + s_counter = 0; + WaitHandle.Reset(); - TestRunCriteria testRunCriteria = new TestRunCriteria(new List { @"x:dummy\foo.dll" }, 10, false, string.Empty, TimeSpan.MaxValue, null, "Name=Test1", null); - TestRunStartEventArgs testRunStartEventArgs = new TestRunStartEventArgs(testRunCriteria); + TestRunCriteria testRunCriteria = new(new List { @"x:dummy\foo.dll" }, 10, false, string.Empty, TimeSpan.MaxValue, null, "Name=Test1", null); + TestRunStartEventArgs testRunStartEventArgs = new(testRunCriteria); - // setup TestLogger - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.InitializeLoggerByUri(new Uri(loggerUri), new Dictionary()); - testLoggerManager.EnableLogging(); + // setup TestLogger + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); + testLoggerManager.EnableLogging(); - testLoggerManager.Dispose(); - testLoggerManager.HandleTestRunStart(testRunStartEventArgs); + testLoggerManager.Dispose(); + testLoggerManager.HandleTestRunStart(testRunStartEventArgs); - // Assertions when test run events registered - Assert.AreEqual(0, counter); - } + // Assertions when test run events registered + Assert.AreEqual(0, s_counter); + } - /// - /// DiscoveryComplete event handler of loggers should be called only if discovery events are registered. - /// - [TestMethod] - public void HandleDiscoveryCompleteShouldInvokeDiscoveryCompleteHandlerOfLoggers() - { - counter = 0; - waitHandle.Reset(); + /// + /// DiscoveryComplete event handler of loggers should be called only if discovery events are registered. + /// + [TestMethod] + public void HandleDiscoveryCompleteShouldInvokeDiscoveryCompleteHandlerOfLoggers() + { + s_counter = 0; + WaitHandle.Reset(); - DiscoveryCompleteEventArgs discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(2, false); + DiscoveryCompleteEventArgs discoveryCompleteEventArgs = new(2, false); - // setup TestLogger - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.InitializeLoggerByUri(new Uri(loggerUri), new Dictionary()); - testLoggerManager.EnableLogging(); + // setup TestLogger + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); + testLoggerManager.EnableLogging(); - testLoggerManager.HandleDiscoveryComplete(discoveryCompleteEventArgs); + testLoggerManager.HandleDiscoveryComplete(discoveryCompleteEventArgs); - // Assertions when discovery events registered - waitHandle.WaitOne(); - Assert.AreEqual(1, counter); - } + // Assertions when discovery events registered + WaitHandle.WaitOne(); + Assert.AreEqual(1, s_counter); + } - /// - /// DiscoveryComplete event handler of loggers should be called only if discovery events are registered. - /// - [TestMethod] - public void HandleDiscoveryCompleteShouldNotInvokeDiscoveryCompleteHandlerOfLoggersIfDisposed() - { - counter = 0; - waitHandle.Reset(); + /// + /// DiscoveryComplete event handler of loggers should be called only if discovery events are registered. + /// + [TestMethod] + public void HandleDiscoveryCompleteShouldNotInvokeDiscoveryCompleteHandlerOfLoggersIfDisposed() + { + s_counter = 0; + WaitHandle.Reset(); - var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(2, false); + var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(2, false); - // setup TestLogger - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.InitializeLoggerByUri(new Uri(loggerUri), new Dictionary()); - testLoggerManager.EnableLogging(); + // setup TestLogger + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); + testLoggerManager.EnableLogging(); - testLoggerManager.Dispose(); - testLoggerManager.HandleDiscoveryComplete(discoveryCompleteEventArgs); + testLoggerManager.Dispose(); + testLoggerManager.HandleDiscoveryComplete(discoveryCompleteEventArgs); - // Assertions when discovery events registered - Assert.AreEqual(0, counter); - } + // Assertions when discovery events registered + Assert.AreEqual(0, s_counter); + } - [TestMethod] - public void HandleDiscoveryCompleteShouldDisposeLoggerManager() - { - counter = 0; - waitHandle.Reset(); - // setup TestLogger - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.InitializeLoggerByUri(new Uri(loggerUri), new Dictionary()); - testLoggerManager.EnableLogging(); - - var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(2, false); - testLoggerManager.HandleDiscoveryComplete(discoveryCompleteEventArgs); - testLoggerManager.HandleDiscoveryComplete(discoveryCompleteEventArgs); // count should not increase because of second call. - - Assert.AreEqual(1, counter); - } + [TestMethod] + public void HandleDiscoveryCompleteShouldDisposeLoggerManager() + { + s_counter = 0; + WaitHandle.Reset(); + // setup TestLogger + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); + testLoggerManager.EnableLogging(); + + var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(2, false); + testLoggerManager.HandleDiscoveryComplete(discoveryCompleteEventArgs); + testLoggerManager.HandleDiscoveryComplete(discoveryCompleteEventArgs); // count should not increase because of second call. + + Assert.AreEqual(1, s_counter); + } - /// - /// DiscoveryMessage event handler of loggers should be called only if discovery events are registered. - /// - [TestMethod] - public void HandleDiscoveryMessageShouldInvokeDiscoveryMessageHandlerOfLoggers() - { - counter = 0; - waitHandle.Reset(); + /// + /// DiscoveryMessage event handler of loggers should be called only if discovery events are registered. + /// + [TestMethod] + public void HandleDiscoveryMessageShouldInvokeDiscoveryMessageHandlerOfLoggers() + { + s_counter = 0; + WaitHandle.Reset(); - string message = "This is the test message"; - TestRunMessageEventArgs testRunMessageEventArgs = new TestRunMessageEventArgs(TestMessageLevel.Informational, message); + string message = "This is the test message"; + TestRunMessageEventArgs testRunMessageEventArgs = new(TestMessageLevel.Informational, message); - // setup TestLogger - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.InitializeLoggerByUri(new Uri(loggerUri), new Dictionary()); - testLoggerManager.EnableLogging(); + // setup TestLogger + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); + testLoggerManager.EnableLogging(); - testLoggerManager.HandleDiscoveryMessage(testRunMessageEventArgs); + testLoggerManager.HandleDiscoveryMessage(testRunMessageEventArgs); - // Assertions when discovery events registered - waitHandle.WaitOne(); - Assert.AreEqual(1, counter); - } + // Assertions when discovery events registered + WaitHandle.WaitOne(); + Assert.AreEqual(1, s_counter); + } - /// - /// DiscoveryMessage event handler of loggers should be called only if discovery events are registered. - /// - [TestMethod] - public void HandleDiscoveryMessageShouldNotInvokeDiscoveryMessageHandlerOfLoggersIfDisposed() - { - counter = 0; - waitHandle.Reset(); + /// + /// DiscoveryMessage event handler of loggers should be called only if discovery events are registered. + /// + [TestMethod] + public void HandleDiscoveryMessageShouldNotInvokeDiscoveryMessageHandlerOfLoggersIfDisposed() + { + s_counter = 0; + WaitHandle.Reset(); - string message = "This is the test message"; - TestRunMessageEventArgs testRunMessageEventArgs = new TestRunMessageEventArgs(TestMessageLevel.Informational, message); + string message = "This is the test message"; + TestRunMessageEventArgs testRunMessageEventArgs = new(TestMessageLevel.Informational, message); - // setup TestLogger - var testLoggerManager = new DummyTestLoggerManager(); - testLoggerManager.InitializeLoggerByUri(new Uri(loggerUri), new Dictionary()); - testLoggerManager.EnableLogging(); + // setup TestLogger + var testLoggerManager = new DummyTestLoggerManager(); + testLoggerManager.InitializeLoggerByUri(new Uri(_loggerUri), new Dictionary()); + testLoggerManager.EnableLogging(); - testLoggerManager.Dispose(); - testLoggerManager.HandleDiscoveryMessage(testRunMessageEventArgs); + testLoggerManager.Dispose(); + testLoggerManager.HandleDiscoveryMessage(testRunMessageEventArgs); - Assert.AreEqual(0, counter); - } + Assert.AreEqual(0, s_counter); + } - [TestMethod] - public void InitializeShouldInitializeLoggerFromFriendlyNameWhenOnlyFriendlyNamePresent() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldInitializeLoggerFromFriendlyNameWhenOnlyFriendlyNamePresent() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - string settingsXml = - @" + string settingsXml = + @" @@ -636,24 +628,24 @@ public void InitializeShouldInitializeLoggerFromFriendlyNameWhenOnlyFriendlyName "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(1, ValidLoggerWithParameters.counter); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); - } + Assert.AreEqual(1, ValidLoggerWithParameters.Counter); + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); + } - [TestMethod] - public void InitializeShouldInitializeLoggerFromUriWhenOnlyUriPresent() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldInitializeLoggerFromUriWhenOnlyUriPresent() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - string settingsXml = - @" + string settingsXml = + @" @@ -662,27 +654,27 @@ public void InitializeShouldInitializeLoggerFromUriWhenOnlyUriPresent() "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(1, ValidLoggerWithParameters.counter); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); - } + Assert.AreEqual(1, ValidLoggerWithParameters.Counter); + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); + } - [TestMethod] - public void InitializeShouldInitializeLoggerFromAssemblyNameWhenAssemblyNameAndCodeBasePresent() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldInitializeLoggerFromAssemblyNameWhenAssemblyNameAndCodeBasePresent() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -691,26 +683,26 @@ public void InitializeShouldInitializeLoggerFromAssemblyNameWhenAssemblyNameAndC "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(1, ValidLoggerWithParameters.counter); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); - } + Assert.AreEqual(1, ValidLoggerWithParameters.Counter); + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); + } - [TestMethod] - public void InitializeShouldNotInitializeLoggersWhenOnlyAssemblyNameIsPresent() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldNotInitializeLoggersWhenOnlyAssemblyNameIsPresent() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; + var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - string settingsXml = - @" + string settingsXml = + @" @@ -719,28 +711,25 @@ public void InitializeShouldNotInitializeLoggersWhenOnlyAssemblyNameIsPresent() "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - Assert.ThrowsException(() => - { - testLoggerManager.Initialize(settingsXml); - }); - Assert.AreEqual(0, ValidLoggerWithParameters.counter); - } + Assert.ThrowsException(() => testLoggerManager.Initialize(settingsXml)); + Assert.AreEqual(0, ValidLoggerWithParameters.Counter); + } - [TestMethod] - public void InitializeShouldNotInitializeLoggersFromAssemblyNameWhenInterfaceDoesNotMatch() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldNotInitializeLoggersFromAssemblyNameWhenInterfaceDoesNotMatch() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = typeof(InvalidLogger).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var assemblyQualifiedName = typeof(InvalidLogger).AssemblyQualifiedName; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -749,27 +738,24 @@ public void InitializeShouldNotInitializeLoggersFromAssemblyNameWhenInterfaceDoe "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - Assert.ThrowsException(() => - { - testLoggerManager.Initialize(settingsXml); - }); - Assert.AreEqual(0, InvalidLogger.counter); - } + Assert.ThrowsException(() => testLoggerManager.Initialize(settingsXml)); + Assert.AreEqual(0, InvalidLogger.Counter); + } - [TestMethod] - public void InitializeShouldNotInitializeLoggersWhenAssemblyNameInvalid() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldNotInitializeLoggersWhenAssemblyNameInvalid() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = "invalid"; + var assemblyQualifiedName = "invalid"; - string settingsXml = - @" + string settingsXml = + @" @@ -778,27 +764,24 @@ public void InitializeShouldNotInitializeLoggersWhenAssemblyNameInvalid() "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - Assert.ThrowsException(() => - { - testLoggerManager.Initialize(settingsXml); - }); - Assert.AreEqual(0, ValidLoggerWithParameters.counter); - } + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + Assert.ThrowsException(() => testLoggerManager.Initialize(settingsXml)); + Assert.AreEqual(0, ValidLoggerWithParameters.Counter); + } - [TestMethod] - public void InitializeShouldNotInitializeLoggersWhenCodeBaseInvalid() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldNotInitializeLoggersWhenCodeBaseInvalid() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = typeof(InvalidLogger).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var assemblyQualifiedName = typeof(InvalidLogger).AssemblyQualifiedName; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -807,29 +790,26 @@ public void InitializeShouldNotInitializeLoggersWhenCodeBaseInvalid() "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - Assert.ThrowsException(() => - { - testLoggerManager.Initialize(settingsXml); - }); - Assert.AreEqual(0, ValidLoggerWithParameters.counter); - } + Assert.ThrowsException(() => testLoggerManager.Initialize(settingsXml)); + Assert.AreEqual(0, ValidLoggerWithParameters.Counter); + } - [TestMethod] - public void InitializeShouldInitializeLoggerOnceWhenMultipleLoggersWithSameAssemblyNamePresent() - { - // Duplicate loggers should be ignored - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldInitializeLoggerOnceWhenMultipleLoggersWithSameAssemblyNamePresent() + { + // Duplicate loggers should be ignored + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -839,28 +819,28 @@ public void InitializeShouldInitializeLoggerOnceWhenMultipleLoggersWithSameAssem "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(1, ValidLoggerWithParameters.counter); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); - } + Assert.AreEqual(1, ValidLoggerWithParameters.Counter); + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); + } - [TestMethod] - public void InitializeShouldInitializeLoggerOnce() - { - // Duplicate loggers should be ignored - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldInitializeLoggerOnce() + { + // Duplicate loggers should be ignored + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -872,27 +852,27 @@ public void InitializeShouldInitializeLoggerOnce() "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(1, ValidLoggerWithParameters.counter); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); - } + Assert.AreEqual(1, ValidLoggerWithParameters.Counter); + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); + } - [TestMethod] - public void InitializeShouldNotConsiderLoggerAsInitializedWhenInitializationErrorOccurs() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldNotConsiderLoggerAsInitializedWhenInitializationErrorOccurs() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = typeof(LoggerWithInitializationError).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var assemblyQualifiedName = typeof(LoggerWithInitializationError).AssemblyQualifiedName; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -901,27 +881,24 @@ public void InitializeShouldNotConsiderLoggerAsInitializedWhenInitializationErro "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - Assert.ThrowsException(() => - { - testLoggerManager.Initialize(settingsXml); - }); - } + Assert.ThrowsException(() => testLoggerManager.Initialize(settingsXml)); + } - [TestMethod] - public void InitializeShouldThrowWhenLoggerManagerAlreadyDisposed() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldThrowWhenLoggerManagerAlreadyDisposed() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -930,24 +907,24 @@ public void InitializeShouldThrowWhenLoggerManagerAlreadyDisposed() "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Dispose(); - Assert.ThrowsException(() => testLoggerManager.Initialize(settingsXml)); - } + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Dispose(); + Assert.ThrowsException(() => testLoggerManager.Initialize(settingsXml)); + } - [TestMethod] - public void InitializeShouldInitilaizeMultipleLoggersIfPresent() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldInitilaizeMultipleLoggersIfPresent() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -958,27 +935,27 @@ public void InitializeShouldInitilaizeMultipleLoggersIfPresent() "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(1, ValidLoggerWithParameters.counter); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); - } + Assert.AreEqual(1, ValidLoggerWithParameters.Counter); + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); + } - [TestMethod] - public void AreLoggersInitializedShouldReturnTrueWhenLoggersInitialized() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void AreLoggersInitializedShouldReturnTrueWhenLoggersInitialized() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -989,25 +966,25 @@ public void AreLoggersInitializedShouldReturnTrueWhenLoggersInitialized() "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.IsTrue(testLoggerManager.LoggersInitialized); - } + Assert.IsTrue(testLoggerManager.LoggersInitialized); + } - [TestMethod] - public void AreLoggersInitializedShouldReturnFalseWhenLoggersNotInitialized() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void AreLoggersInitializedShouldReturnFalseWhenLoggersNotInitialized() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -1018,24 +995,24 @@ public void AreLoggersInitializedShouldReturnFalseWhenLoggersNotInitialized() "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - Assert.IsFalse(testLoggerManager.LoggersInitialized); - } + Assert.IsFalse(testLoggerManager.LoggersInitialized); + } - [TestMethod] - public void AreLoggersInitializedShouldReturnFalseWhenNoLoggersPresent() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void AreLoggersInitializedShouldReturnFalseWhenNoLoggersPresent() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -1043,25 +1020,25 @@ public void AreLoggersInitializedShouldReturnFalseWhenNoLoggersPresent() "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.IsFalse(testLoggerManager.LoggersInitialized); - } + Assert.IsFalse(testLoggerManager.LoggersInitialized); + } - [TestMethod] - public void InitializeShouldPassConfigurationElementAsParameters() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldPassConfigurationElementAsParameters() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -1077,31 +1054,31 @@ public void InitializeShouldPassConfigurationElementAsParameters() "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(1, ValidLoggerWithParameters.counter); - Assert.AreEqual(4, ValidLoggerWithParameters.parameters.Count); // Two additional because of testRunDirectory and targetFramework - Assert.AreEqual("Value1", ValidLoggerWithParameters.parameters["Key1"]); - Assert.AreEqual("Value2", ValidLoggerWithParameters.parameters["Key2"]); + Assert.AreEqual(1, ValidLoggerWithParameters.Counter); + Assert.AreEqual(4, ValidLoggerWithParameters.Parameters.Count); // Two additional because of testRunDirectory and targetFramework + Assert.AreEqual("Value1", ValidLoggerWithParameters.Parameters["Key1"]); + Assert.AreEqual("Value2", ValidLoggerWithParameters.Parameters["Key2"]); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); - } + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); + } - [TestMethod] - public void InitializeShouldSkipEmptyConfigurationValueInParameters() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldSkipEmptyConfigurationValueInParameters() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -1117,31 +1094,31 @@ public void InitializeShouldSkipEmptyConfigurationValueInParameters() "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(1, ValidLoggerWithParameters.counter); - Assert.AreEqual(3, ValidLoggerWithParameters.parameters.Count); // Two additional because of testRunDirectory and targetFramework - Assert.IsFalse(ValidLoggerWithParameters.parameters.TryGetValue("Key1", out var key1Value)); - Assert.AreEqual("Value2", ValidLoggerWithParameters.parameters["Key2"]); + Assert.AreEqual(1, ValidLoggerWithParameters.Counter); + Assert.AreEqual(3, ValidLoggerWithParameters.Parameters.Count); // Two additional because of testRunDirectory and targetFramework + Assert.IsFalse(ValidLoggerWithParameters.Parameters.TryGetValue("Key1", out var key1Value)); + Assert.AreEqual("Value2", ValidLoggerWithParameters.Parameters["Key2"]); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); - } + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); + } - [TestMethod] - public void InitializeShouldUseLastValueInParametersForDuplicateConfigurationValue() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldUseLastValueInParametersForDuplicateConfigurationValue() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -1158,31 +1135,31 @@ public void InitializeShouldUseLastValueInParametersForDuplicateConfigurationVal "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(1, ValidLoggerWithParameters.counter); - Assert.AreEqual(4, ValidLoggerWithParameters.parameters.Count); // Two additional because of testRunDirectory and targetFramework - Assert.AreEqual("Value3", ValidLoggerWithParameters.parameters["Key1"]); - Assert.AreEqual("Value2", ValidLoggerWithParameters.parameters["Key2"]); + Assert.AreEqual(1, ValidLoggerWithParameters.Counter); + Assert.AreEqual(4, ValidLoggerWithParameters.Parameters.Count); // Two additional because of testRunDirectory and targetFramework + Assert.AreEqual("Value3", ValidLoggerWithParameters.Parameters["Key1"]); + Assert.AreEqual("Value2", ValidLoggerWithParameters.Parameters["Key2"]); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); - } + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); + } - [TestMethod] - public void InitializeShouldNotInitializeDisabledLoggers() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldNotInitializeDisabledLoggers() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -1193,27 +1170,27 @@ public void InitializeShouldNotInitializeDisabledLoggers() "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(0, ValidLoggerWithParameters.counter); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2")); - } + Assert.AreEqual(0, ValidLoggerWithParameters.Counter); + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2")); + } - [TestMethod] - public void InitializeShouldInitializeFromAssemblyNameIfAllAttributesPresent() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldInitializeFromAssemblyNameIfAllAttributesPresent() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -1229,29 +1206,29 @@ public void InitializeShouldInitializeFromAssemblyNameIfAllAttributesPresent() "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(1, ValidLoggerWithParameters.counter); - Assert.AreEqual(4, ValidLoggerWithParameters.parameters.Count); // Two additional because of testRunDirectory and targetFramework - Assert.AreEqual("Value1", ValidLoggerWithParameters.parameters["Key1"]); - Assert.AreEqual("Value2", ValidLoggerWithParameters.parameters["Key2"]); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); - } + Assert.AreEqual(1, ValidLoggerWithParameters.Counter); + Assert.AreEqual(4, ValidLoggerWithParameters.Parameters.Count); // Two additional because of testRunDirectory and targetFramework + Assert.AreEqual("Value1", ValidLoggerWithParameters.Parameters["Key1"]); + Assert.AreEqual("Value2", ValidLoggerWithParameters.Parameters["Key2"]); + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); + } - [TestMethod] - public void InitializeShouldInitializeFromUriIfUriAndNamePresent() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldInitializeFromUriIfUriAndNamePresent() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -1267,29 +1244,29 @@ public void InitializeShouldInitializeFromUriIfUriAndNamePresent() "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(1, ValidLoggerWithParameters.counter); - Assert.AreEqual(4, ValidLoggerWithParameters.parameters.Count); // Two additional because of testRunDirectory and targetFramework - Assert.AreEqual("Value1", ValidLoggerWithParameters.parameters["Key1"]); - Assert.AreEqual("Value2", ValidLoggerWithParameters.parameters["Key2"]); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); - } + Assert.AreEqual(1, ValidLoggerWithParameters.Counter); + Assert.AreEqual(4, ValidLoggerWithParameters.Parameters.Count); // Two additional because of testRunDirectory and targetFramework + Assert.AreEqual("Value1", ValidLoggerWithParameters.Parameters["Key1"]); + Assert.AreEqual("Value2", ValidLoggerWithParameters.Parameters["Key2"]); + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); + } - [TestMethod] - public void InitializeShouldInitializeFromUriIfUnableToFromAssemblyName() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldInitializeFromUriIfUnableToFromAssemblyName() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -1305,29 +1282,29 @@ public void InitializeShouldInitializeFromUriIfUnableToFromAssemblyName() "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(1, ValidLoggerWithParameters.counter); - Assert.AreEqual(4, ValidLoggerWithParameters.parameters.Count); // Two additional because of testRunDirectory and targetFramework - Assert.AreEqual("Value1", ValidLoggerWithParameters.parameters["Key1"]); - Assert.AreEqual("Value2", ValidLoggerWithParameters.parameters["Key2"]); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); - } + Assert.AreEqual(1, ValidLoggerWithParameters.Counter); + Assert.AreEqual(4, ValidLoggerWithParameters.Parameters.Count); // Two additional because of testRunDirectory and targetFramework + Assert.AreEqual("Value1", ValidLoggerWithParameters.Parameters["Key1"]); + Assert.AreEqual("Value2", ValidLoggerWithParameters.Parameters["Key2"]); + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); + } - [TestMethod] - public void InitializeShouldInitializeFromNameIfUnableToFromUri() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldInitializeFromNameIfUnableToFromUri() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -1343,29 +1320,29 @@ public void InitializeShouldInitializeFromNameIfUnableToFromUri() "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(1, ValidLoggerWithParameters.counter); - Assert.AreEqual(4, ValidLoggerWithParameters.parameters.Count); // Two additional because of testRunDirectory and targetFramework - Assert.AreEqual("Value1", ValidLoggerWithParameters.parameters["Key1"]); - Assert.AreEqual("Value2", ValidLoggerWithParameters.parameters["Key2"]); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); - } + Assert.AreEqual(1, ValidLoggerWithParameters.Counter); + Assert.AreEqual(4, ValidLoggerWithParameters.Parameters.Count); // Two additional because of testRunDirectory and targetFramework + Assert.AreEqual("Value1", ValidLoggerWithParameters.Parameters["Key1"]); + Assert.AreEqual("Value2", ValidLoggerWithParameters.Parameters["Key2"]); + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); + } - [TestMethod] - public void InitializeShouldInitializeLoggersWithTestRunDirectoryIfPresentInRunSettings() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldInitializeLoggersWithTestRunDirectoryIfPresentInRunSettings() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" 0 @@ -1387,30 +1364,30 @@ public void InitializeShouldInitializeLoggersWithTestRunDirectoryIfPresentInRunS "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(1, ValidLoggerWithParameters.counter); - Assert.AreEqual(4, ValidLoggerWithParameters.parameters.Count); // Two additional because of testRunDirectory and targetFramework - Assert.AreEqual("Value1", ValidLoggerWithParameters.parameters["Key1"]); - Assert.AreEqual("DummyTestResultsFolder", ValidLoggerWithParameters.parameters["testRunDirectory"]); - Assert.AreEqual("Value2", ValidLoggerWithParameters.parameters["Key2"]); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); - } + Assert.AreEqual(1, ValidLoggerWithParameters.Counter); + Assert.AreEqual(4, ValidLoggerWithParameters.Parameters.Count); // Two additional because of testRunDirectory and targetFramework + Assert.AreEqual("Value1", ValidLoggerWithParameters.Parameters["Key1"]); + Assert.AreEqual("DummyTestResultsFolder", ValidLoggerWithParameters.Parameters["testRunDirectory"]); + Assert.AreEqual("Value2", ValidLoggerWithParameters.Parameters["Key2"]); + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); + } - [TestMethod] - public void InitializeShouldInitializeLoggersWithDefaultTestRunDirectoryIfNotPresentInRunSettings() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldInitializeLoggersWithDefaultTestRunDirectoryIfNotPresentInRunSettings() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" 0 @@ -1431,30 +1408,30 @@ public void InitializeShouldInitializeLoggersWithDefaultTestRunDirectoryIfNotPre "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(1, ValidLoggerWithParameters.counter); - Assert.AreEqual(4, ValidLoggerWithParameters.parameters.Count); // Two additional because of testRunDirectory and targetFramework - Assert.AreEqual("Value1", ValidLoggerWithParameters.parameters["Key1"]); - Assert.AreEqual(Constants.DefaultResultsDirectory, ValidLoggerWithParameters.parameters["testRunDirectory"]); - Assert.AreEqual("Value2", ValidLoggerWithParameters.parameters["Key2"]); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); - } + Assert.AreEqual(1, ValidLoggerWithParameters.Counter); + Assert.AreEqual(4, ValidLoggerWithParameters.Parameters.Count); // Two additional because of testRunDirectory and targetFramework + Assert.AreEqual("Value1", ValidLoggerWithParameters.Parameters["Key1"]); + Assert.AreEqual(Constants.DefaultResultsDirectory, ValidLoggerWithParameters.Parameters["testRunDirectory"]); + Assert.AreEqual("Value2", ValidLoggerWithParameters.Parameters["Key2"]); + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLogger2,TestPlatform.CrossPlatEngine.UnitTests.TestLoggerManagerTests+ValidLoggerWithParameters")); + } - [TestMethod] - public void InitializeShouldNotInitializeIfUnableToFromName() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldNotInitializeIfUnableToFromName() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = - @" + string settingsXml = + @" @@ -1470,90 +1447,87 @@ public void InitializeShouldNotInitializeIfUnableToFromName() "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - Assert.ThrowsException(() => - { - testLoggerManager.Initialize(settingsXml); - }); - Assert.AreEqual(0, ValidLoggerWithParameters.counter); - } + Assert.ThrowsException(() => testLoggerManager.Initialize(settingsXml)); + Assert.AreEqual(0, ValidLoggerWithParameters.Counter); + } - [TestMethod] - public void InitializeShouldNotInitializeAnyLoggerIfNoLoggerPresent() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldNotInitializeAnyLoggerIfNoLoggerPresent() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - string settingsXml = - @" + string settingsXml = + @" "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(0, ValidLoggerWithParameters.counter); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "")); - } + Assert.AreEqual(0, ValidLoggerWithParameters.Counter); + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "")); + } - [TestMethod] - public void InitializeShouldNotInitializeAnyLoggerIfEmptyLoggerRunSettings() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldNotInitializeAnyLoggerIfEmptyLoggerRunSettings() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - string settingsXml = - @" + string settingsXml = + @" "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(0, ValidLoggerWithParameters.counter); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "")); - } + Assert.AreEqual(0, ValidLoggerWithParameters.Counter); + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "")); + } - [TestMethod] - public void InitializeShouldNotThrowWhenLoggersNotPresentInRunSettings() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldNotThrowWhenLoggersNotPresentInRunSettings() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - string settingsXml = - @" + string settingsXml = + @" "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(0, ValidLoggerWithParameters.counter); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "")); - } + Assert.AreEqual(0, ValidLoggerWithParameters.Counter); + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "")); + } - [TestMethod] - public void InitializeShouldNotInitializeAnyLoggerIfEmptyLoggersNode() - { - ValidLoggerWithParameters.Reset(); - var mockRequestData = new Mock(); - var mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + [TestMethod] + public void InitializeShouldNotInitializeAnyLoggerIfEmptyLoggersNode() + { + ValidLoggerWithParameters.Reset(); + var mockRequestData = new Mock(); + var mockMetricsCollection = new Mock(); + mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - string settingsXml = - @" + string settingsXml = + @" @@ -1561,157 +1535,153 @@ public void InitializeShouldNotInitializeAnyLoggerIfEmptyLoggersNode() "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); - testLoggerManager.Initialize(settingsXml); + var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); + testLoggerManager.Initialize(settingsXml); - Assert.AreEqual(0, ValidLoggerWithParameters.counter); - mockMetricsCollection.Verify( - rd => rd.Add(TelemetryDataConstants.LoggerUsed, "")); - } + Assert.AreEqual(0, ValidLoggerWithParameters.Counter); + mockMetricsCollection.Verify( + rd => rd.Add(TelemetryDataConstants.LoggerUsed, "")); + } - [ExtensionUri("testlogger://logger")] - [FriendlyName("TestLoggerExtension")] - private class ValidLogger : ITestLogger + [ExtensionUri("testlogger://logger")] + [FriendlyName("TestLoggerExtension")] + private class ValidLogger : ITestLogger + { + public void Initialize(TestLoggerEvents events, string testRunDirectory) { - public void Initialize(TestLoggerEvents events, string testRunDirectory) - { - events.TestRunMessage += TestMessageHandler; - events.TestRunComplete += Events_TestRunComplete; - events.TestResult += Events_TestResult; - events.TestRunStart += TestRunStartHandler; - - events.DiscoveryStart += DiscoveryStartHandler; - events.DiscoveryMessage += DiscoveryMessageHandler; - events.DiscoveredTests += DiscoveredTestsHandler; - events.DiscoveryComplete += DiscoveryCompleteHandler; - } - - private void Events_TestResult(object sender, TestResultEventArgs e) - { - TestLoggerManagerTests.counter++; - TestLoggerManagerTests.waitHandle.Set(); - } - - private void Events_TestRunComplete(object sender, TestRunCompleteEventArgs e) - { - TestLoggerManagerTests.counter++; - TestLoggerManagerTests.waitHandle.Set(); + events.TestRunMessage += TestMessageHandler; + events.TestRunComplete += Events_TestRunComplete; + events.TestResult += Events_TestResult; + events.TestRunStart += TestRunStartHandler; - } - - private void TestMessageHandler(object sender, TestRunMessageEventArgs e) - { - if (e.Message.Equals("TestRunMessage")) - { - TestLoggerManagerTests.counter++; - TestLoggerManagerTests.waitHandle.Set(); - - } - } + events.DiscoveryStart += DiscoveryStartHandler; + events.DiscoveryMessage += DiscoveryMessageHandler; + events.DiscoveredTests += DiscoveredTestsHandler; + events.DiscoveryComplete += DiscoveryCompleteHandler; + } - private void TestRunStartHandler(object sender, TestRunStartEventArgs e) - { - TestLoggerManagerTests.counter++; - TestLoggerManagerTests.waitHandle.Set(); - } + private void Events_TestResult(object sender, TestResultEventArgs e) + { + s_counter++; + WaitHandle.Set(); + } - private void DiscoveryMessageHandler(object sender, TestRunMessageEventArgs e) - { - TestLoggerManagerTests.counter++; - TestLoggerManagerTests.waitHandle.Set(); - } + private void Events_TestRunComplete(object sender, TestRunCompleteEventArgs e) + { + s_counter++; + WaitHandle.Set(); - private void DiscoveryStartHandler(object sender, DiscoveryStartEventArgs e) - { - TestLoggerManagerTests.counter++; - TestLoggerManagerTests.waitHandle.Set(); - } + } - private void DiscoveredTestsHandler(object sender, DiscoveredTestsEventArgs e) + private void TestMessageHandler(object sender, TestRunMessageEventArgs e) + { + if (e.Message.Equals("TestRunMessage")) { - TestLoggerManagerTests.counter++; - TestLoggerManagerTests.waitHandle.Set(); - } + s_counter++; + WaitHandle.Set(); - private void DiscoveryCompleteHandler(object sender, DiscoveryCompleteEventArgs e) - { - TestLoggerManagerTests.counter++; - TestLoggerManagerTests.waitHandle.Set(); } } - [ExtensionUri("testlogger://logger2")] - [FriendlyName("TestLoggerExtension2")] - private class ValidLogger2 : ITestLogger + private void TestRunStartHandler(object sender, TestRunStartEventArgs e) { - public void Initialize(TestLoggerEvents events, string testRunDirectory) - { - } - + s_counter++; + WaitHandle.Set(); } - [ExtensionUri("testlogger://invalidLogger")] - [FriendlyName("InvalidTestLoggerExtension")] - private class InvalidLogger + private void DiscoveryMessageHandler(object sender, TestRunMessageEventArgs e) { - public static int counter = 0; + s_counter++; + WaitHandle.Set(); + } - public void Initialize(TestLoggerEvents events, string testRunDirectory) - { - counter++; - } + private void DiscoveryStartHandler(object sender, DiscoveryStartEventArgs e) + { + s_counter++; + WaitHandle.Set(); + } + private void DiscoveredTestsHandler(object sender, DiscoveredTestsEventArgs e) + { + s_counter++; + WaitHandle.Set(); } - [ExtensionUri("testlogger://loggerWithError")] - [FriendlyName("ErroredTestLoggerExtension")] - private class LoggerWithInitializationError : ITestLogger + private void DiscoveryCompleteHandler(object sender, DiscoveryCompleteEventArgs e) { - public void Initialize(TestLoggerEvents events, string testRunDirectory) - { - throw new Exception(); - } + s_counter++; + WaitHandle.Set(); } + } - [ExtensionUri("test-logger-with-parameter://logger")] - [FriendlyName("TestLoggerWithParameterExtension")] - private class ValidLoggerWithParameters : ITestLoggerWithParameters + [ExtensionUri("testlogger://logger2")] + [FriendlyName("TestLoggerExtension2")] + private class ValidLogger2 : ITestLogger + { + public void Initialize(TestLoggerEvents events, string testRunDirectory) { - public static Dictionary parameters; - public static int counter = 0; + } - public void Initialize(TestLoggerEvents events, string testRunDirectory) - { - counter += 2; - } + } - public void Initialize(TestLoggerEvents events, Dictionary parameters) - { - counter++; - ValidLoggerWithParameters.parameters = parameters; - } + [ExtensionUri("testlogger://invalidLogger")] + [FriendlyName("InvalidTestLoggerExtension")] + private class InvalidLogger + { + public static int Counter = 0; - public static void Reset() - { - counter = 0; - ValidLoggerWithParameters.parameters = null; - } + public void Initialize(TestLoggerEvents events, string testRunDirectory) + { + Counter++; } - internal class DummyTestLoggerManager : TestLoggerManager + } + + [ExtensionUri("testlogger://loggerWithError")] + [FriendlyName("ErroredTestLoggerExtension")] + private class LoggerWithInitializationError : ITestLogger + { + public void Initialize(TestLoggerEvents events, string testRunDirectory) { - public DummyTestLoggerManager() : base(null, TestSessionMessageLogger.Instance, new InternalTestLoggerEvents(TestSessionMessageLogger.Instance)) - { + throw new Exception(); + } + } - } + [ExtensionUri("test-logger-with-parameter://logger")] + [FriendlyName("TestLoggerWithParameterExtension")] + private class ValidLoggerWithParameters : ITestLoggerWithParameters + { + public static Dictionary Parameters; + public static int Counter = 0; - public DummyTestLoggerManager(IRequestData requestData) : base(requestData, TestSessionMessageLogger.Instance, new InternalTestLoggerEvents(TestSessionMessageLogger.Instance)) - { + public void Initialize(TestLoggerEvents events, string testRunDirectory) + { + Counter += 2; + } - } + public void Initialize(TestLoggerEvents events, Dictionary parameters) + { + Counter++; + Parameters = parameters; + } + + public static void Reset() + { + Counter = 0; + Parameters = null; } } -} + internal class DummyTestLoggerManager : TestLoggerManager + { + public DummyTestLoggerManager() : base(null, TestSessionMessageLogger.Instance, new InternalTestLoggerEvents(TestSessionMessageLogger.Instance)) + { + } + + public DummyTestLoggerManager(IRequestData requestData) : base(requestData, TestSessionMessageLogger.Instance, new InternalTestLoggerEvents(TestSessionMessageLogger.Instance)) + { + } + } +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestSession/TestSessionPoolTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestSession/TestSessionPoolTests.cs index ab3c47ebe0..1683fafb7e 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestSession/TestSessionPoolTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestSession/TestSessionPoolTests.cs @@ -1,124 +1,123 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.TestSession +namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.TestSession; + +using System; + +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class TestSessionPoolTests { - using System; - - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestTools.UnitTesting; + [TestMethod] + public void AddSessionShouldSucceedIfTestSessionInfoIsUnique() + { + TestSessionPool.Instance = null; + + var testSessionInfo = new TestSessionInfo(); + var proxyTestSessionManager = new ProxyTestSessionManager( + new StartTestSessionCriteria(), + 1, + () => null); + + Assert.IsTrue(TestSessionPool.Instance.AddSession(testSessionInfo, proxyTestSessionManager)); + Assert.IsFalse(TestSessionPool.Instance.AddSession(testSessionInfo, proxyTestSessionManager)); + } - using Moq; + [TestMethod] + public void KillSessionShouldSucceedIfTestSessionExists() + { + TestSessionPool.Instance = null; + + var testSessionInfo = new TestSessionInfo(); + var mockProxyTestSessionManager = new Mock( + new StartTestSessionCriteria(), + 1, + (Func)(() => null)); + + mockProxyTestSessionManager.SetupSequence(tsm => tsm.StopSession()) + .Returns(true) + .Returns(false); + + Assert.IsFalse(TestSessionPool.Instance.KillSession(testSessionInfo)); + mockProxyTestSessionManager.Verify(tsm => tsm.StopSession(), Times.Never); - [TestClass] - public class TestSessionPoolTests + Assert.IsTrue(TestSessionPool.Instance.AddSession(testSessionInfo, mockProxyTestSessionManager.Object)); + Assert.IsTrue(TestSessionPool.Instance.KillSession(testSessionInfo)); + mockProxyTestSessionManager.Verify(tsm => tsm.StopSession(), Times.Once); + + Assert.IsTrue(TestSessionPool.Instance.AddSession(testSessionInfo, mockProxyTestSessionManager.Object)); + Assert.IsFalse(TestSessionPool.Instance.KillSession(testSessionInfo)); + mockProxyTestSessionManager.Verify(tsm => tsm.StopSession(), Times.Exactly(2)); + } + + [TestMethod] + public void TakeProxyShouldSucceedIfMatchingCriteriaAreCorrect() { - [TestMethod] - public void AddSessionShouldSucceedIfTestSessionInfoIsUnique() - { - TestSessionPool.Instance = null; - - var testSessionInfo = new TestSessionInfo(); - var proxyTestSessionManager = new ProxyTestSessionManager( - new StartTestSessionCriteria(), - 1, - () => { return null; }); - - Assert.IsTrue(TestSessionPool.Instance.AddSession(testSessionInfo, proxyTestSessionManager)); - Assert.IsFalse(TestSessionPool.Instance.AddSession(testSessionInfo, proxyTestSessionManager)); - } - - [TestMethod] - public void KillSessionShouldSucceedIfTestSessionExists() - { - TestSessionPool.Instance = null; - - var testSessionInfo = new TestSessionInfo(); - var mockProxyTestSessionManager = new Mock( - new StartTestSessionCriteria(), - 1, - (Func)(() => { return null; })); - - mockProxyTestSessionManager.SetupSequence(tsm => tsm.StopSession()) - .Returns(true) - .Returns(false); - - Assert.IsFalse(TestSessionPool.Instance.KillSession(testSessionInfo)); - mockProxyTestSessionManager.Verify(tsm => tsm.StopSession(), Times.Never); - - Assert.IsTrue(TestSessionPool.Instance.AddSession(testSessionInfo, mockProxyTestSessionManager.Object)); - Assert.IsTrue(TestSessionPool.Instance.KillSession(testSessionInfo)); - mockProxyTestSessionManager.Verify(tsm => tsm.StopSession(), Times.Once); - - Assert.IsTrue(TestSessionPool.Instance.AddSession(testSessionInfo, mockProxyTestSessionManager.Object)); - Assert.IsFalse(TestSessionPool.Instance.KillSession(testSessionInfo)); - mockProxyTestSessionManager.Verify(tsm => tsm.StopSession(), Times.Exactly(2)); - } - - [TestMethod] - public void TakeProxyShouldSucceedIfMatchingCriteriaAreCorrect() - { - TestSessionPool.Instance = null; - - var testSessionInfo = new TestSessionInfo(); - var mockProxyTestSessionManager = new Mock( - new StartTestSessionCriteria(), - 1, - (Func)(() => { return null; })); - - mockProxyTestSessionManager.SetupSequence(tsm => tsm.DequeueProxy(It.IsAny(), It.IsAny())) - .Throws(new InvalidOperationException("Test Exception")) - .Returns(new ProxyOperationManager(null, null, null)); - - // Take proxy fails because test session is invalid. - Assert.IsNull(TestSessionPool.Instance.TryTakeProxy(new TestSessionInfo(), string.Empty, string.Empty)); - mockProxyTestSessionManager.Verify(tsm => tsm.DequeueProxy(It.IsAny(), It.IsAny()), Times.Never); - - Assert.IsTrue(TestSessionPool.Instance.AddSession(testSessionInfo, mockProxyTestSessionManager.Object)); - - // First TakeProxy fails because of throwing, see setup sequence. - Assert.IsNull(TestSessionPool.Instance.TryTakeProxy(testSessionInfo, string.Empty, string.Empty)); - mockProxyTestSessionManager.Verify(tsm => tsm.DequeueProxy(It.IsAny(), It.IsAny()), Times.Once); - - // Second TakeProxy succeeds, see setup sequence. - Assert.IsNotNull(TestSessionPool.Instance.TryTakeProxy(testSessionInfo, string.Empty, string.Empty)); - mockProxyTestSessionManager.Verify(tsm => tsm.DequeueProxy(It.IsAny(), It.IsAny()), Times.Exactly(2)); - } - - [TestMethod] - public void ReturnProxyShouldSucceedIfProxyIdIsValid() - { - TestSessionPool.Instance = null; - - var testSessionInfo = new TestSessionInfo(); - var mockProxyTestSessionManager = new Mock( - new StartTestSessionCriteria(), - 1, - (Func)(() => { return null; })); - - mockProxyTestSessionManager.SetupSequence(tsm => tsm.EnqueueProxy(It.IsAny())) - .Throws(new ArgumentException("Test Exception")) - .Throws(new InvalidOperationException("Test Exception")) - .Returns(true); - - Assert.IsFalse(TestSessionPool.Instance.ReturnProxy(new TestSessionInfo(), 0)); - mockProxyTestSessionManager.Verify(tsm => tsm.EnqueueProxy(It.IsAny()), Times.Never); - - Assert.IsTrue(TestSessionPool.Instance.AddSession(testSessionInfo, mockProxyTestSessionManager.Object)); - - // Simulates proxy id not found (see setup sequence). - Assert.ThrowsException(() => TestSessionPool.Instance.ReturnProxy(testSessionInfo, 0)); - mockProxyTestSessionManager.Verify(tsm => tsm.EnqueueProxy(It.IsAny()), Times.Once); - - // Simulates proxy already available (see setup sequence). - Assert.IsFalse(TestSessionPool.Instance.ReturnProxy(testSessionInfo, 0)); - mockProxyTestSessionManager.Verify(tsm => tsm.EnqueueProxy(It.IsAny()), Times.Exactly(2)); - - // EnqueueProxy call succeeds. - Assert.IsTrue(TestSessionPool.Instance.ReturnProxy(testSessionInfo, 0)); - mockProxyTestSessionManager.Verify(tsm => tsm.EnqueueProxy(It.IsAny()), Times.Exactly(3)); - } + TestSessionPool.Instance = null; + + var testSessionInfo = new TestSessionInfo(); + var mockProxyTestSessionManager = new Mock( + new StartTestSessionCriteria(), + 1, + (Func)(() => null)); + + mockProxyTestSessionManager.SetupSequence(tsm => tsm.DequeueProxy(It.IsAny(), It.IsAny())) + .Throws(new InvalidOperationException("Test Exception")) + .Returns(new ProxyOperationManager(null, null, null)); + + // Take proxy fails because test session is invalid. + Assert.IsNull(TestSessionPool.Instance.TryTakeProxy(new TestSessionInfo(), string.Empty, string.Empty)); + mockProxyTestSessionManager.Verify(tsm => tsm.DequeueProxy(It.IsAny(), It.IsAny()), Times.Never); + + Assert.IsTrue(TestSessionPool.Instance.AddSession(testSessionInfo, mockProxyTestSessionManager.Object)); + + // First TakeProxy fails because of throwing, see setup sequence. + Assert.IsNull(TestSessionPool.Instance.TryTakeProxy(testSessionInfo, string.Empty, string.Empty)); + mockProxyTestSessionManager.Verify(tsm => tsm.DequeueProxy(It.IsAny(), It.IsAny()), Times.Once); + + // Second TakeProxy succeeds, see setup sequence. + Assert.IsNotNull(TestSessionPool.Instance.TryTakeProxy(testSessionInfo, string.Empty, string.Empty)); + mockProxyTestSessionManager.Verify(tsm => tsm.DequeueProxy(It.IsAny(), It.IsAny()), Times.Exactly(2)); + } + + [TestMethod] + public void ReturnProxyShouldSucceedIfProxyIdIsValid() + { + TestSessionPool.Instance = null; + + var testSessionInfo = new TestSessionInfo(); + var mockProxyTestSessionManager = new Mock( + new StartTestSessionCriteria(), + 1, + (Func)(() => null)); + + mockProxyTestSessionManager.SetupSequence(tsm => tsm.EnqueueProxy(It.IsAny())) + .Throws(new ArgumentException("Test Exception")) + .Throws(new InvalidOperationException("Test Exception")) + .Returns(true); + + Assert.IsFalse(TestSessionPool.Instance.ReturnProxy(new TestSessionInfo(), 0)); + mockProxyTestSessionManager.Verify(tsm => tsm.EnqueueProxy(It.IsAny()), Times.Never); + + Assert.IsTrue(TestSessionPool.Instance.AddSession(testSessionInfo, mockProxyTestSessionManager.Object)); + + // Simulates proxy id not found (see setup sequence). + Assert.ThrowsException(() => TestSessionPool.Instance.ReturnProxy(testSessionInfo, 0)); + mockProxyTestSessionManager.Verify(tsm => tsm.EnqueueProxy(It.IsAny()), Times.Once); + + // Simulates proxy already available (see setup sequence). + Assert.IsFalse(TestSessionPool.Instance.ReturnProxy(testSessionInfo, 0)); + mockProxyTestSessionManager.Verify(tsm => tsm.EnqueueProxy(It.IsAny()), Times.Exactly(2)); + + // EnqueueProxy call succeeds. + Assert.IsTrue(TestSessionPool.Instance.ReturnProxy(testSessionInfo, 0)); + mockProxyTestSessionManager.Verify(tsm => tsm.EnqueueProxy(It.IsAny()), Times.Exactly(3)); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableRuntimeProvider.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableRuntimeProvider.cs index de7089630c..5c622bf372 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableRuntimeProvider.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableRuntimeProvider.cs @@ -1,83 +1,82 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.TestableImplementations +namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.TestableImplementations; + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +[ExtensionUri("executor://TestableTestHost")] +[FriendlyName("TestableTestHost")] +public class TestableRuntimeProvider : ITestRuntimeProvider { - using System; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - - [ExtensionUri("executor://TestableTestHost")] - [FriendlyName("TestableTestHost")] - public class TestableRuntimeProvider : ITestRuntimeProvider + public TestableRuntimeProvider() + { + } + + public TestableRuntimeProvider(bool shared) + { + Shared = shared; + } + + public event EventHandler HostLaunched; + + public event EventHandler HostExited; + + public bool Shared { get; } + + public void Initialize(IMessageLogger logger, string runsettingsXml) + { + } + + public bool CanExecuteCurrentRunConfiguration(string runsettingsXml) + { + return true; + } + + public void SetCustomLauncher(ITestHostLauncher customLauncher) + { + } + + public TestHostConnectionInfo GetTestHostConnectionInfo() + { + return new TestHostConnectionInfo { Endpoint = "127.0.0.1:0", Role = ConnectionRole.Client, Transport = Transport.Sockets }; + } + + public Task LaunchTestHostAsync(TestProcessStartInfo testHostStartInfo, CancellationToken cancellationToken) + { + HostLaunched(this, null); + return Task.FromResult(true); + } + + public TestProcessStartInfo GetTestHostProcessStartInfo( + IEnumerable sources, + IDictionary environmentVariables, + TestRunnerConnectionInfo connectionInfo) + { + return default; + } + + public IEnumerable GetTestPlatformExtensions(IEnumerable sources, IEnumerable extensions) + { + return extensions; + } + + public IEnumerable GetTestSources(IEnumerable sources) + { + return sources; + } + + public Task CleanTestHostAsync(CancellationToken cancellationToken) { - public TestableRuntimeProvider() - { - } - - public TestableRuntimeProvider(bool shared) - { - Shared = shared; - } - - public event EventHandler HostLaunched; - - public event EventHandler HostExited; - - public bool Shared { get; } - - public void Initialize(IMessageLogger logger, string runsettingsXml) - { - } - - public bool CanExecuteCurrentRunConfiguration(string runsettingsXml) - { - return true; - } - - public void SetCustomLauncher(ITestHostLauncher customLauncher) - { - } - - public TestHostConnectionInfo GetTestHostConnectionInfo() - { - return new TestHostConnectionInfo { Endpoint = "127.0.0.1:0", Role = ConnectionRole.Client, Transport = Transport.Sockets }; - } - - public Task LaunchTestHostAsync(TestProcessStartInfo testHostStartInfo, CancellationToken cancellationToken) - { - HostLaunched(this, null); - return Task.FromResult(true); - } - - public TestProcessStartInfo GetTestHostProcessStartInfo( - IEnumerable sources, - IDictionary environmentVariables, - TestRunnerConnectionInfo connectionInfo) - { - return default; - } - - public IEnumerable GetTestPlatformExtensions(IEnumerable sources, IEnumerable extensions) - { - return extensions; - } - - public IEnumerable GetTestSources(IEnumerable sources) - { - return sources; - } - - public Task CleanTestHostAsync(CancellationToken cancellationToken) - { - HostExited(this, null); - return Task.FromResult(true); - } + HostExited(this, null); + return Task.FromResult(true); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestEngine.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestEngine.cs index f850fb8f6f..bcf6326606 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestEngine.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestEngine.cs @@ -1,17 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests -{ - using Microsoft.VisualStudio.TestPlatform.Common.Hosting; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +namespace TestPlatform.CrossPlatEngine.UnitTests; + +using Microsoft.VisualStudio.TestPlatform.Common.Hosting; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - public class TestableTestEngine : TestEngine +public class TestableTestEngine : TestEngine +{ + public TestableTestEngine(IProcessHelper processHelper) + : base(TestRuntimeProviderManager.Instance, processHelper) { - public TestableTestEngine(IProcessHelper processHelper) - : base(TestRuntimeProviderManager.Instance, processHelper) - { - } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestRunCache.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestRunCache.cs index f7521b97b2..3d5f7cca8c 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestRunCache.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestableImplementations/TestableTestRunCache.cs @@ -1,66 +1,64 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.TestableImplementations -{ - using System; - using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +namespace TestPlatform.CrossPlatEngine.UnitTests.TestableImplementations; +using System.Collections.Generic; + +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - public class TestableTestRunCache : ITestRunCache +public class TestableTestRunCache : ITestRunCache +{ + public TestableTestRunCache() { - public TestableTestRunCache() - { - this.TestStartedList = new List(); - this.TestCompletedList = new List(); - this.TestResultList = new List(); - } + TestStartedList = new List(); + TestCompletedList = new List(); + TestResultList = new List(); + } - // use the below three to fill in data to the testable cache. - public List TestStartedList { get; private set; } + // use the below three to fill in data to the testable cache. + public List TestStartedList { get; private set; } - public List TestCompletedList { get; private set; } + public List TestCompletedList { get; private set; } - public List TestResultList { get; private set; } + public List TestResultList { get; private set; } - public ICollection InProgressTests { get; set; } + public ICollection InProgressTests { get; set; } - // Use the TestResultList instead to fill in data. This is just to avoid confusion. - public ICollection TestResults { get; set; } + // Use the TestResultList instead to fill in data. This is just to avoid confusion. + public ICollection TestResults { get; set; } - public TestRunStatistics TestRunStatistics { get; set; } + public TestRunStatistics TestRunStatistics { get; set; } - public long TotalExecutedTests { get; set; } + public long TotalExecutedTests { get; set; } - public IDictionary AdapterTelemetry => new Dictionary(); + public IDictionary AdapterTelemetry => new Dictionary(); - public ICollection GetLastChunk() - { - return this.TestResultList; - } + public ICollection GetLastChunk() + { + return TestResultList; + } - public void OnNewTestResult(TestResult testResult) - { - this.TestResultList.Add(testResult); - } + public void OnNewTestResult(TestResult testResult) + { + TestResultList.Add(testResult); + } - public bool OnTestCompletion(TestCase testCase) - { - this.TestCompletedList.Add(testCase); + public bool OnTestCompletion(TestCase testCase) + { + TestCompletedList.Add(testCase); - return false; - } + return false; + } - public void OnTestStarted(TestCase testCase) - { - this.TestStartedList.Add(testCase); - } + public void OnTestStarted(TestCase testCase) + { + TestStartedList.Add(testCase); + } - public void Dispose() - { - } + public void Dispose() + { } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Utilities/TestSourcesUtilityTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Utilities/TestSourcesUtilityTests.cs index 5eaf9d64de..953bf9c741 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Utilities/TestSourcesUtilityTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Utilities/TestSourcesUtilityTests.cs @@ -1,85 +1,88 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.CrossPlatEngine.UnitTests.Adapter +namespace TestPlatform.CrossPlatEngine.UnitTests.Adapter; + +using System; +using System.IO; +using System.Collections.Generic; +using System.Linq; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Utilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class TestSourcesUtilityTests { - using System; - using System.IO; - using System.Collections.Generic; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; + private static readonly string Temp = Path.GetTempPath(); - [TestClass] - public class TestSourcesUtilityTests + [TestMethod] + public void GetSourcesShouldAggregateSourcesIfMultiplePresentInAdapterSourceMap() { - private static string temp = Path.GetTempPath(); - - [TestMethod] - public void GetSourcesShouldAggregateSourcesIfMultiplePresentInAdapterSourceMap() + var adapterSourceMap = new Dictionary> { - var adapterSourceMap = new Dictionary>(); - adapterSourceMap.Add("adapter1", new List() { "source1.dll", "source2.dll" }); - adapterSourceMap.Add("adapter2", new List() { "source1.dll", "source3.dll" }); - adapterSourceMap.Add("adapter3", new List() { "source1.dll"}); + { "adapter1", new List() { "source1.dll", "source2.dll" } }, + { "adapter2", new List() { "source1.dll", "source3.dll" } }, + { "adapter3", new List() { "source1.dll" } } + }; - var sources = TestSourcesUtility.GetSources(adapterSourceMap); - Assert.AreEqual(5, sources.Count()); - Assert.IsTrue(sources.Contains("source1.dll")); - Assert.IsTrue(sources.Contains("source2.dll")); - Assert.IsTrue(sources.Contains("source3.dll")); - } + var sources = TestSourcesUtility.GetSources(adapterSourceMap); + Assert.AreEqual(5, sources.Count()); + Assert.IsTrue(sources.Contains("source1.dll")); + Assert.IsTrue(sources.Contains("source2.dll")); + Assert.IsTrue(sources.Contains("source3.dll")); + } - [TestMethod] - public void GetSourcesShouldGetDistinctSourcesFromTestCases() - { - var path = Path.Combine(temp, "d"); - var tests = new List() { new TestCase("test1", new Uri(path), "source1.dll"), - new TestCase("test2", new Uri(path), "source2.dll"), - new TestCase("test3", new Uri(path), "source1.dll")}; + [TestMethod] + public void GetSourcesShouldGetDistinctSourcesFromTestCases() + { + var path = Path.Combine(Temp, "d"); + var tests = new List() { new TestCase("test1", new Uri(path), "source1.dll"), + new TestCase("test2", new Uri(path), "source2.dll"), + new TestCase("test3", new Uri(path), "source1.dll")}; - var sources = TestSourcesUtility.GetSources(tests); - Assert.AreEqual(2, sources.Count()); - Assert.IsTrue(sources.Contains("source1.dll")); - Assert.IsTrue(sources.Contains("source2.dll")); - } + var sources = TestSourcesUtility.GetSources(tests); + Assert.AreEqual(2, sources.Count()); + Assert.IsTrue(sources.Contains("source1.dll")); + Assert.IsTrue(sources.Contains("source2.dll")); + } - [TestMethod] - public void GetDefaultCodeBasePathShouldReturnNullIfAdapterSourceMapIsEmpty() - { - var adapterSourceMap = new Dictionary>(); + [TestMethod] + public void GetDefaultCodeBasePathShouldReturnNullIfAdapterSourceMapIsEmpty() + { + var adapterSourceMap = new Dictionary>(); - var defaultCodeBase = TestSourcesUtility.GetDefaultCodebasePath(adapterSourceMap); - Assert.IsNull(defaultCodeBase); - } + var defaultCodeBase = TestSourcesUtility.GetDefaultCodebasePath(adapterSourceMap); + Assert.IsNull(defaultCodeBase); + } - [TestMethod] - public void GetDefaultCodeBasePathShouldReturnNullIfTestCaseListIsEmpty() - { - var tests = new List(); + [TestMethod] + public void GetDefaultCodeBasePathShouldReturnNullIfTestCaseListIsEmpty() + { + var tests = new List(); - var defaultCodeBase = TestSourcesUtility.GetDefaultCodebasePath(tests); - Assert.IsNull(defaultCodeBase); - } + var defaultCodeBase = TestSourcesUtility.GetDefaultCodebasePath(tests); + Assert.IsNull(defaultCodeBase); + } - [TestMethod] - public void GetDefaultCodeBasePathShouldReturnDefaultDirectoryPathForAdapterSourceMap() + [TestMethod] + public void GetDefaultCodeBasePathShouldReturnDefaultDirectoryPathForAdapterSourceMap() + { + var adapterSourceMap = new Dictionary> { - var adapterSourceMap = new Dictionary>(); - adapterSourceMap.Add("adapter1", new List() { Path.Combine(temp, "folder1", "source1.dll"), Path.Combine(temp, "folder2", "source2.dll") }); + { "adapter1", new List() { Path.Combine(Temp, "folder1", "source1.dll"), Path.Combine(Temp, "folder2", "source2.dll") } } + }; - var defaultCodeBase = TestSourcesUtility.GetDefaultCodebasePath(adapterSourceMap); - Assert.AreEqual(Path.Combine(temp, "folder1"), defaultCodeBase); - } + var defaultCodeBase = TestSourcesUtility.GetDefaultCodebasePath(adapterSourceMap); + Assert.AreEqual(Path.Combine(Temp, "folder1"), defaultCodeBase); + } - [TestMethod] - public void GetDefaultCodeBasePathShouldReturnDefaultDirectoryPathForTestCaseList() - { - var tests = new List() { new TestCase("test1", new Uri(Path.Combine(temp, "d")), Path.Combine(temp, "folder1", "source1.dll")) }; + [TestMethod] + public void GetDefaultCodeBasePathShouldReturnDefaultDirectoryPathForTestCaseList() + { + var tests = new List() { new TestCase("test1", new Uri(Path.Combine(Temp, "d")), Path.Combine(Temp, "folder1", "source1.dll")) }; - var defaultCodeBase = TestSourcesUtility.GetDefaultCodebasePath(tests); - Assert.AreEqual(Path.Combine(temp, "folder1"), defaultCodeBase); - } + var defaultCodeBase = TestSourcesUtility.GetDefaultCodebasePath(tests); + Assert.AreEqual(Path.Combine(Temp, "folder1"), defaultCodeBase); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/BlameCollectorTests.cs b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/BlameCollectorTests.cs index ea8e9a983c..bb9b01376f 100644 --- a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/BlameCollectorTests.cs +++ b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/BlameCollectorTests.cs @@ -1,764 +1,760 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests; + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Threading; +using System.Xml; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using VisualStudio.TestTools.UnitTesting; + +using Moq; + +/// +/// The blame collector tests. +/// +[TestClass] +[TestCategory("Windows")] +public class BlameCollectorTests { - using System; - using System.Collections.Generic; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Threading; - using System.Xml; - - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; + private readonly DataCollectionEnvironmentContext _context; + private readonly DataCollectionContext _dataCollectionContext; + private BlameCollector _blameDataCollector; + private readonly Mock _mockLogger; + private readonly Mock _mockDataColectionEvents; + private readonly Mock _mockDataCollectionSink; + private readonly Mock _mockBlameReaderWriter; + private readonly Mock _mockProcessDumpUtility; + private readonly Mock _mockInactivityTimer; + private readonly Mock _mockFileHelper; + private readonly XmlElement _configurationElement; + private readonly string _filepath; /// - /// The blame collector tests. + /// Initializes a new instance of the class. /// - [TestClass] - [TestCategory("Windows")] - public class BlameCollectorTests + public BlameCollectorTests() { - private DataCollectionEnvironmentContext context; - private DataCollectionContext dataCollectionContext; - private BlameCollector blameDataCollector; - private Mock mockLogger; - private Mock mockDataColectionEvents; - private Mock mockDataCollectionSink; - private Mock mockBlameReaderWriter; - private Mock mockProcessDumpUtility; - private Mock mockInactivityTimer; - private Mock mockFileHelper; - private XmlElement configurationElement; - private string filepath; - - /// - /// Initializes a new instance of the class. - /// - public BlameCollectorTests() - { - // Initializing mocks - this.mockLogger = new Mock(); - this.mockDataColectionEvents = new Mock(); - this.mockDataCollectionSink = new Mock(); - this.mockBlameReaderWriter = new Mock(); - this.mockProcessDumpUtility = new Mock(); - this.mockInactivityTimer = new Mock(); - this.mockFileHelper = new Mock(); - this.blameDataCollector = new TestableBlameCollector( - this.mockBlameReaderWriter.Object, - this.mockProcessDumpUtility.Object, - this.mockInactivityTimer.Object, - this.mockFileHelper.Object); - - // Initializing members - TestCase testcase = new TestCase { Id = Guid.NewGuid() }; - this.dataCollectionContext = new DataCollectionContext(testcase); - this.configurationElement = null; - this.context = new DataCollectionEnvironmentContext(this.dataCollectionContext); - - this.filepath = Path.Combine(Path.GetTempPath(), "Test"); - FileStream stream = File.Create(this.filepath); - stream.Dispose(); - } + // Initializing mocks + _mockLogger = new Mock(); + _mockDataColectionEvents = new Mock(); + _mockDataCollectionSink = new Mock(); + _mockBlameReaderWriter = new Mock(); + _mockProcessDumpUtility = new Mock(); + _mockInactivityTimer = new Mock(); + _mockFileHelper = new Mock(); + _blameDataCollector = new TestableBlameCollector( + _mockBlameReaderWriter.Object, + _mockProcessDumpUtility.Object, + _mockInactivityTimer.Object, + _mockFileHelper.Object); + + // Initializing members + TestCase testcase = new() { Id = Guid.NewGuid() }; + _dataCollectionContext = new DataCollectionContext(testcase); + _configurationElement = null; + _context = new DataCollectionEnvironmentContext(_dataCollectionContext); + + _filepath = Path.Combine(Path.GetTempPath(), "Test"); + FileStream stream = File.Create(_filepath); + stream.Dispose(); + } - /// - /// The initialize should throw exception if data collection logger is null. - /// - [TestMethod] - public void InitializeShouldThrowExceptionIfDataCollectionLoggerIsNull() - { - Assert.ThrowsException(() => - { - this.blameDataCollector.Initialize( - this.configurationElement, - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - null, - null); - }); - } + /// + /// The initialize should throw exception if data collection logger is null. + /// + [TestMethod] + public void InitializeShouldThrowExceptionIfDataCollectionLoggerIsNull() + { + Assert.ThrowsException(() => _blameDataCollector.Initialize( + _configurationElement, + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + null, + null)); + } - /// - /// Initializing with collect dump for hang disabled should ensure InativityTimer is never initialized or reset - /// - [TestMethod] - public void InitializeWithDumpForHangDisabledShouldNotInitializeInactivityTimerOrCallReset() - { - int resetCalledCount = 0; + /// + /// Initializing with collect dump for hang disabled should ensure InativityTimer is never initialized or reset + /// + [TestMethod] + public void InitializeWithDumpForHangDisabledShouldNotInitializeInactivityTimerOrCallReset() + { + int resetCalledCount = 0; - this.mockInactivityTimer.Setup(x => x.ResetTimer(It.Is(y => y.TotalMinutes == 1.0))).Callback(() => { resetCalledCount++; }); + _mockInactivityTimer.Setup(x => x.ResetTimer(It.Is(y => y.TotalMinutes == 1.0))).Callback(() => resetCalledCount++); - this.blameDataCollector.Initialize( - this.GetDumpConfigurationElement(false, false, false), - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); + _blameDataCollector.Initialize( + GetDumpConfigurationElement(false, false, false), + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); - Assert.AreEqual(0, resetCalledCount, "Should not have called InactivityTimer.Reset since no collect dump on hang is disabled."); - } + Assert.AreEqual(0, resetCalledCount, "Should not have called InactivityTimer.Reset since no collect dump on hang is disabled."); + } - /// - /// Initializing with collect dump for hang should configure the timer with the right values and should - /// not call the reset method if no events are received. - /// - [TestMethod] - public void InitializeWithDumpForHangShouldInitializeInactivityTimerAndCallResetOnce() - { - int resetCalledCount = 0; + /// + /// Initializing with collect dump for hang should configure the timer with the right values and should + /// not call the reset method if no events are received. + /// + [TestMethod] + public void InitializeWithDumpForHangShouldInitializeInactivityTimerAndCallResetOnce() + { + int resetCalledCount = 0; - this.mockInactivityTimer.Setup(x => x.ResetTimer(It.Is(y => y.TotalMilliseconds == 1.0))).Callback(() => { resetCalledCount++; }); + _mockInactivityTimer.Setup(x => x.ResetTimer(It.Is(y => y.TotalMilliseconds == 1.0))).Callback(() => resetCalledCount++); - this.blameDataCollector.Initialize( - this.GetDumpConfigurationElement(false, false, true, 1), - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); + _blameDataCollector.Initialize( + GetDumpConfigurationElement(false, false, true, 1), + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); - Assert.AreEqual(1, resetCalledCount, "Should have called InactivityTimer.Reset exactly once since no events were received"); - } + Assert.AreEqual(1, resetCalledCount, "Should have called InactivityTimer.Reset exactly once since no events were received"); + } - /// - /// Initializing with collect dump for hang should configure the timer with the right values and should - /// reset for each event received - /// - [TestMethod] - public void InitializeWithDumpForHangShouldInitializeInactivityTimerAndResetForEachEventReceived() - { - int resetCalledCount = 0; + /// + /// Initializing with collect dump for hang should configure the timer with the right values and should + /// reset for each event received + /// + [TestMethod] + public void InitializeWithDumpForHangShouldInitializeInactivityTimerAndResetForEachEventReceived() + { + int resetCalledCount = 0; - this.mockInactivityTimer.Setup(x => x.ResetTimer(It.Is(y => y.TotalMilliseconds == 1.0))).Callback(() => { resetCalledCount++; }); + _mockInactivityTimer.Setup(x => x.ResetTimer(It.Is(y => y.TotalMilliseconds == 1.0))).Callback(() => resetCalledCount++); - this.mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), It.IsAny())) - .Returns(this.filepath); + _mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), It.IsAny())) + .Returns(_filepath); - this.blameDataCollector.Initialize( - this.GetDumpConfigurationElement(false, false, true, 1), - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); + _blameDataCollector.Initialize( + GetDumpConfigurationElement(false, false, true, 1), + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); - TestCase testcase = new TestCase("TestProject.UnitTest.TestMethod", new Uri("test:/abc"), "abc.dll"); + TestCase testcase = new("TestProject.UnitTest.TestMethod", new Uri("test:/abc"), "abc.dll"); - this.mockDataColectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(testcase)); - this.mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(this.dataCollectionContext)); + _mockDataColectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(testcase)); + _mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(_dataCollectionContext)); - Assert.AreEqual(3, resetCalledCount, "Should have called InactivityTimer.Reset exactly 3 times"); - } + Assert.AreEqual(3, resetCalledCount, "Should have called InactivityTimer.Reset exactly 3 times"); + } - /// - /// Initializing with collect dump for hang should capture a dump on timeout - /// - [TestMethod] - public void InitializeWithDumpForHangShouldCaptureADumpOnTimeout() - { - this.blameDataCollector = new TestableBlameCollector( - this.mockBlameReaderWriter.Object, - this.mockProcessDumpUtility.Object, - null, - this.mockFileHelper.Object); - - var dumpFile = "abc_hang.dmp"; - var hangBasedDumpcollected = new ManualResetEventSlim(); - - this.mockFileHelper.Setup(x => x.Exists(It.Is(y => y == "abc_hang.dmp"))).Returns(true); - this.mockFileHelper.Setup(x => x.GetFullPath(It.Is(y => y == "abc_hang.dmp"))).Returns("abc_hang.dmp"); - this.mockProcessDumpUtility.Setup(x => x.StartHangBasedProcessDump(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>())); - this.mockProcessDumpUtility.Setup(x => x.GetDumpFiles(true, false)).Returns(new[] { dumpFile }); - this.mockDataCollectionSink.Setup(x => x.SendFileAsync(It.IsAny())).Callback(() => hangBasedDumpcollected.Set()); - - this.blameDataCollector.Initialize( - this.GetDumpConfigurationElement(false, false, true, 0), - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); - - hangBasedDumpcollected.Wait(1000); - this.mockProcessDumpUtility.Verify(x => x.StartHangBasedProcessDump(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>()), Times.Once); - this.mockProcessDumpUtility.Verify(x => x.GetDumpFiles(true, false), Times.Once); - this.mockDataCollectionSink.Verify(x => x.SendFileAsync(It.Is(y => y.Path == dumpFile)), Times.Once); - } + /// + /// Initializing with collect dump for hang should capture a dump on timeout + /// + [TestMethod] + public void InitializeWithDumpForHangShouldCaptureADumpOnTimeout() + { + _blameDataCollector = new TestableBlameCollector( + _mockBlameReaderWriter.Object, + _mockProcessDumpUtility.Object, + null, + _mockFileHelper.Object); + + var dumpFile = "abc_hang.dmp"; + var hangBasedDumpcollected = new ManualResetEventSlim(); + + _mockFileHelper.Setup(x => x.Exists(It.Is(y => y == "abc_hang.dmp"))).Returns(true); + _mockFileHelper.Setup(x => x.GetFullPath(It.Is(y => y == "abc_hang.dmp"))).Returns("abc_hang.dmp"); + _mockProcessDumpUtility.Setup(x => x.StartHangBasedProcessDump(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>())); + _mockProcessDumpUtility.Setup(x => x.GetDumpFiles(true, false)).Returns(new[] { dumpFile }); + _mockDataCollectionSink.Setup(x => x.SendFileAsync(It.IsAny())).Callback(() => hangBasedDumpcollected.Set()); + + _blameDataCollector.Initialize( + GetDumpConfigurationElement(false, false, true, 0), + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); + + hangBasedDumpcollected.Wait(1000); + _mockProcessDumpUtility.Verify(x => x.StartHangBasedProcessDump(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>()), Times.Once); + _mockProcessDumpUtility.Verify(x => x.GetDumpFiles(true, false), Times.Once); + _mockDataCollectionSink.Verify(x => x.SendFileAsync(It.Is(y => y.Path == dumpFile)), Times.Once); + } - /// - /// Initializing with collect dump for hang should kill test host process even if an error - /// occurs during capturing the dump. Basically it should not throw. - /// - [TestMethod] - public void InitializeWithDumpForHangShouldCaptureKillTestHostOnTimeoutEvenIfGetDumpFileFails() - { - this.blameDataCollector = new TestableBlameCollector( - this.mockBlameReaderWriter.Object, - this.mockProcessDumpUtility.Object, - null, - this.mockFileHelper.Object); - - var hangBasedDumpcollected = new ManualResetEventSlim(); - - this.mockFileHelper.Setup(x => x.Exists(It.Is(y => y == "abc_hang.dmp"))).Returns(true); - this.mockFileHelper.Setup(x => x.GetFullPath(It.Is(y => y == "abc_hang.dmp"))).Returns("abc_hang.dmp"); - this.mockProcessDumpUtility.Setup(x => x.StartHangBasedProcessDump(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>())); - this.mockProcessDumpUtility.Setup(x => x.GetDumpFiles(true, false)).Callback(() => hangBasedDumpcollected.Set()).Throws(new Exception("Some exception")); - - this.blameDataCollector.Initialize( - this.GetDumpConfigurationElement(false, false, true, 0), - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); - - hangBasedDumpcollected.Wait(1000); - this.mockProcessDumpUtility.Verify(x => x.StartHangBasedProcessDump(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>()), Times.Once); - this.mockProcessDumpUtility.Verify(x => x.GetDumpFiles(true, false), Times.Once); - } + /// + /// Initializing with collect dump for hang should kill test host process even if an error + /// occurs during capturing the dump. Basically it should not throw. + /// + [TestMethod] + public void InitializeWithDumpForHangShouldCaptureKillTestHostOnTimeoutEvenIfGetDumpFileFails() + { + _blameDataCollector = new TestableBlameCollector( + _mockBlameReaderWriter.Object, + _mockProcessDumpUtility.Object, + null, + _mockFileHelper.Object); + + var hangBasedDumpcollected = new ManualResetEventSlim(); + + _mockFileHelper.Setup(x => x.Exists(It.Is(y => y == "abc_hang.dmp"))).Returns(true); + _mockFileHelper.Setup(x => x.GetFullPath(It.Is(y => y == "abc_hang.dmp"))).Returns("abc_hang.dmp"); + _mockProcessDumpUtility.Setup(x => x.StartHangBasedProcessDump(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>())); + _mockProcessDumpUtility.Setup(x => x.GetDumpFiles(true, false)).Callback(() => hangBasedDumpcollected.Set()).Throws(new Exception("Some exception")); + + _blameDataCollector.Initialize( + GetDumpConfigurationElement(false, false, true, 0), + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); + + hangBasedDumpcollected.Wait(1000); + _mockProcessDumpUtility.Verify(x => x.StartHangBasedProcessDump(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>()), Times.Once); + _mockProcessDumpUtility.Verify(x => x.GetDumpFiles(true, false), Times.Once); + } - /// - /// Initializing with collect dump for hang should kill test host process even if an error - /// occurs during attaching it as a datacollector attachment. Basically it should not throw. - /// - [TestMethod] - public void InitializeWithDumpForHangShouldCaptureKillTestHostOnTimeoutEvenIfAttachingDumpFails() - { - this.blameDataCollector = new TestableBlameCollector( - this.mockBlameReaderWriter.Object, - this.mockProcessDumpUtility.Object, - null, - this.mockFileHelper.Object); - - var dumpFile = "abc_hang.dmp"; - var hangBasedDumpcollected = new ManualResetEventSlim(); - - this.mockFileHelper.Setup(x => x.Exists(It.Is(y => y == "abc_hang.dmp"))).Returns(true); - this.mockFileHelper.Setup(x => x.GetFullPath(It.Is(y => y == "abc_hang.dmp"))).Returns("abc_hang.dmp"); - this.mockProcessDumpUtility.Setup(x => x.StartHangBasedProcessDump(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>())); - this.mockProcessDumpUtility.Setup(x => x.GetDumpFiles(true, false)).Returns(new[] { dumpFile }); - this.mockDataCollectionSink.Setup(x => x.SendFileAsync(It.IsAny())).Callback(() => hangBasedDumpcollected.Set()).Throws(new Exception("Some other exception")); - - this.blameDataCollector.Initialize( - this.GetDumpConfigurationElement(false, false, true, 0), - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); - - hangBasedDumpcollected.Wait(1000); - this.mockProcessDumpUtility.Verify(x => x.StartHangBasedProcessDump(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>()), Times.Once); - this.mockProcessDumpUtility.Verify(x => x.GetDumpFiles(true, false), Times.Once); - this.mockDataCollectionSink.Verify(x => x.SendFileAsync(It.Is(y => y.Path == dumpFile)), Times.Once); - } + /// + /// Initializing with collect dump for hang should kill test host process even if an error + /// occurs during attaching it as a datacollector attachment. Basically it should not throw. + /// + [TestMethod] + public void InitializeWithDumpForHangShouldCaptureKillTestHostOnTimeoutEvenIfAttachingDumpFails() + { + _blameDataCollector = new TestableBlameCollector( + _mockBlameReaderWriter.Object, + _mockProcessDumpUtility.Object, + null, + _mockFileHelper.Object); + + var dumpFile = "abc_hang.dmp"; + var hangBasedDumpcollected = new ManualResetEventSlim(); + + _mockFileHelper.Setup(x => x.Exists(It.Is(y => y == "abc_hang.dmp"))).Returns(true); + _mockFileHelper.Setup(x => x.GetFullPath(It.Is(y => y == "abc_hang.dmp"))).Returns("abc_hang.dmp"); + _mockProcessDumpUtility.Setup(x => x.StartHangBasedProcessDump(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>())); + _mockProcessDumpUtility.Setup(x => x.GetDumpFiles(true, false)).Returns(new[] { dumpFile }); + _mockDataCollectionSink.Setup(x => x.SendFileAsync(It.IsAny())).Callback(() => hangBasedDumpcollected.Set()).Throws(new Exception("Some other exception")); + + _blameDataCollector.Initialize( + GetDumpConfigurationElement(false, false, true, 0), + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); + + hangBasedDumpcollected.Wait(1000); + _mockProcessDumpUtility.Verify(x => x.StartHangBasedProcessDump(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>()), Times.Once); + _mockProcessDumpUtility.Verify(x => x.GetDumpFiles(true, false), Times.Once); + _mockDataCollectionSink.Verify(x => x.SendFileAsync(It.Is(y => y.Path == dumpFile)), Times.Once); + } - /// - /// The trigger session ended handler should write to file if test start count is greater. - /// - [TestMethod] - public void TriggerSessionEndedHandlerShouldWriteToFileIfTestHostCrash() - { - // Initializing Blame Data Collector - this.blameDataCollector.Initialize( - this.configurationElement, - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); + /// + /// The trigger session ended handler should write to file if test start count is greater. + /// + [TestMethod] + public void TriggerSessionEndedHandlerShouldWriteToFileIfTestHostCrash() + { + // Initializing Blame Data Collector + _blameDataCollector.Initialize( + _configurationElement, + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); - TestCase testcase = new TestCase("TestProject.UnitTest.TestMethod", new Uri("test:/abc"), "abc.dll"); + TestCase testcase = new("TestProject.UnitTest.TestMethod", new Uri("test:/abc"), "abc.dll"); - // Setup and Raise TestCaseStart and Session End Event - this.mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), It.IsAny())) - .Returns(this.filepath); + // Setup and Raise TestCaseStart and Session End Event + _mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), It.IsAny())) + .Returns(_filepath); - this.mockDataColectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(testcase)); - this.mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(this.dataCollectionContext)); + _mockDataColectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(testcase)); + _mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(_dataCollectionContext)); - // Verify WriteTestSequence Call - this.mockBlameReaderWriter.Verify(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Once); - } + // Verify WriteTestSequence Call + _mockBlameReaderWriter.Verify(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Once); + } - /// - /// The trigger session ended handler should not write to file if test start count is same as test end count. - /// - [TestMethod] - public void TriggerSessionEndedHandlerShouldNotWriteToFileIfNoTestHostCrash() - { - // Initializing Blame Data Collector - this.blameDataCollector.Initialize( - this.configurationElement, - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); - - TestCase testcase = new TestCase("TestProject.UnitTest.TestMethod", new Uri("test:/abc"), "abc.dll"); - - // Setup and Raise TestCaseStart and Session End Event - this.mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), It.IsAny())).Returns(this.filepath); - this.mockDataColectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(testcase)); - this.mockDataColectionEvents.Raise(x => x.TestCaseEnd += null, new TestCaseEndEventArgs(testcase, TestOutcome.Passed)); - this.mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(this.dataCollectionContext)); - - // Verify WriteTestSequence Call - this.mockBlameReaderWriter.Verify(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), this.filepath), Times.Never); - } + /// + /// The trigger session ended handler should not write to file if test start count is same as test end count. + /// + [TestMethod] + public void TriggerSessionEndedHandlerShouldNotWriteToFileIfNoTestHostCrash() + { + // Initializing Blame Data Collector + _blameDataCollector.Initialize( + _configurationElement, + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); + + TestCase testcase = new("TestProject.UnitTest.TestMethod", new Uri("test:/abc"), "abc.dll"); + + // Setup and Raise TestCaseStart and Session End Event + _mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), It.IsAny())).Returns(_filepath); + _mockDataColectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(testcase)); + _mockDataColectionEvents.Raise(x => x.TestCaseEnd += null, new TestCaseEndEventArgs(testcase, TestOutcome.Passed)); + _mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(_dataCollectionContext)); + + // Verify WriteTestSequence Call + _mockBlameReaderWriter.Verify(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), _filepath), Times.Never); + } - /// - /// The event handlers should generate correct test sequence and testObjectDictionary for both completed and not completed tests - /// - [TestMethod] - public void EventHandlersShouldGenerateCorrectTestSequenceAndTestObjectDictionaryForBothCompletedAndNotCompletedTests() - { - // Initializing Blame Data Collector - this.blameDataCollector.Initialize( - this.configurationElement, - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); - - TestCase testcase1 = new TestCase("TestProject.UnitTest.TestMethod1", new Uri("test:/abc"), "abc.dll"); - TestCase testcase2 = new TestCase("TestProject.UnitTest.TestMethod2", new Uri("test:/abc"), "abc.dll"); - testcase1.DisplayName = "TestMethod1"; - testcase2.DisplayName = "TestMethod2"; - var blameTestObject1 = new BlameTestObject(testcase1); - var blameTestObject2 = new BlameTestObject(testcase2); - - // Setup and Raise TestCaseStart and Session End Event - this.mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), It.IsAny())).Returns(this.filepath); - this.mockDataColectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(testcase1)); - this.mockDataColectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(testcase2)); - this.mockDataColectionEvents.Raise(x => x.TestCaseEnd += null, new TestCaseEndEventArgs(testcase1, TestOutcome.Passed)); - blameTestObject1.IsCompleted = true; - this.mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(this.dataCollectionContext)); - - // Verify call to mockBlameReaderWriter - this.mockBlameReaderWriter.Verify( - x => x.WriteTestSequence( + /// + /// The event handlers should generate correct test sequence and testObjectDictionary for both completed and not completed tests + /// + [TestMethod] + public void EventHandlersShouldGenerateCorrectTestSequenceAndTestObjectDictionaryForBothCompletedAndNotCompletedTests() + { + // Initializing Blame Data Collector + _blameDataCollector.Initialize( + _configurationElement, + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); + + TestCase testcase1 = new("TestProject.UnitTest.TestMethod1", new Uri("test:/abc"), "abc.dll"); + TestCase testcase2 = new("TestProject.UnitTest.TestMethod2", new Uri("test:/abc"), "abc.dll"); + testcase1.DisplayName = "TestMethod1"; + testcase2.DisplayName = "TestMethod2"; + var blameTestObject1 = new BlameTestObject(testcase1); + var blameTestObject2 = new BlameTestObject(testcase2); + + // Setup and Raise TestCaseStart and Session End Event + _mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), It.IsAny())).Returns(_filepath); + _mockDataColectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(testcase1)); + _mockDataColectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(testcase2)); + _mockDataColectionEvents.Raise(x => x.TestCaseEnd += null, new TestCaseEndEventArgs(testcase1, TestOutcome.Passed)); + blameTestObject1.IsCompleted = true; + _mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(_dataCollectionContext)); + + // Verify call to mockBlameReaderWriter + _mockBlameReaderWriter.Verify( + x => x.WriteTestSequence( It.Is>(y => y.Count == 2 && y.First() == blameTestObject1.Id && y.Last() == blameTestObject2.Id), It.Is>( y => y.Count == 2 && - y[blameTestObject1.Id].IsCompleted == true && y[blameTestObject2.Id].IsCompleted == false && - y[blameTestObject1.Id].FullyQualifiedName == "TestProject.UnitTest.TestMethod1" && y[blameTestObject2.Id].FullyQualifiedName == "TestProject.UnitTest.TestMethod2" && - y[blameTestObject1.Id].Source == "abc.dll" && y[blameTestObject2.Id].Source == "abc.dll" && - y[blameTestObject1.Id].DisplayName == "TestMethod1" && y[blameTestObject2.Id].DisplayName == "TestMethod2"), + y[blameTestObject1.Id].IsCompleted == true && y[blameTestObject2.Id].IsCompleted == false && + y[blameTestObject1.Id].FullyQualifiedName == "TestProject.UnitTest.TestMethod1" && y[blameTestObject2.Id].FullyQualifiedName == "TestProject.UnitTest.TestMethod2" && + y[blameTestObject1.Id].Source == "abc.dll" && y[blameTestObject2.Id].Source == "abc.dll" && + y[blameTestObject1.Id].DisplayName == "TestMethod1" && y[blameTestObject2.Id].DisplayName == "TestMethod2"), It.IsAny()), - Times.Once); - } + Times.Once); + } - /// - /// The trigger session ended handler should get dump files if proc dump was enabled - /// - [TestMethod] - public void TriggerSessionEndedHandlerShouldGetDumpFileIfProcDumpEnabled() - { - // Initializing Blame Data Collector - this.blameDataCollector.Initialize( - this.GetDumpConfigurationElement(), - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); - - // Setup - this.mockProcessDumpUtility.Setup(x => x.GetDumpFiles(It.IsAny(), It.IsAny())).Returns(new[] { this.filepath }); - this.mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), It.IsAny())) - .Returns(this.filepath); - - // Raise - this.mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(this.dataCollectionContext, 1234)); - this.mockDataColectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(new TestCase())); - this.mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(this.dataCollectionContext)); - - // Verify GetDumpFiles Call - this.mockProcessDumpUtility.Verify(x => x.GetDumpFiles(It.IsAny(), It.IsAny()), Times.Once); - } + /// + /// The trigger session ended handler should get dump files if proc dump was enabled + /// + [TestMethod] + public void TriggerSessionEndedHandlerShouldGetDumpFileIfProcDumpEnabled() + { + // Initializing Blame Data Collector + _blameDataCollector.Initialize( + GetDumpConfigurationElement(), + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); + + // Setup + _mockProcessDumpUtility.Setup(x => x.GetDumpFiles(It.IsAny(), It.IsAny())).Returns(new[] { _filepath }); + _mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), It.IsAny())) + .Returns(_filepath); + + // Raise + _mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(_dataCollectionContext, 1234)); + _mockDataColectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(new TestCase())); + _mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(_dataCollectionContext)); + + // Verify GetDumpFiles Call + _mockProcessDumpUtility.Verify(x => x.GetDumpFiles(It.IsAny(), It.IsAny()), Times.Once); + } - /// - /// The trigger session ended handler should ensure proc dump process is terminated when no crash is detected - /// - [TestMethod] - public void TriggerSessionEndedHandlerShouldEnsureProcDumpProcessIsTerminated() - { - // Initializing Blame Data Collector - this.blameDataCollector.Initialize( - this.GetDumpConfigurationElement(), - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); - - // Mock proc dump utility terminate process call - this.mockProcessDumpUtility.Setup(x => x.DetachFromTargetProcess(It.IsAny())); - - // Raise - this.mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(this.dataCollectionContext)); - - // Verify GetDumpFiles Call - this.mockProcessDumpUtility.Verify(x => x.DetachFromTargetProcess(It.IsAny()), Times.Once); - } + /// + /// The trigger session ended handler should ensure proc dump process is terminated when no crash is detected + /// + [TestMethod] + public void TriggerSessionEndedHandlerShouldEnsureProcDumpProcessIsTerminated() + { + // Initializing Blame Data Collector + _blameDataCollector.Initialize( + GetDumpConfigurationElement(), + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); + + // Mock proc dump utility terminate process call + _mockProcessDumpUtility.Setup(x => x.DetachFromTargetProcess(It.IsAny())); + + // Raise + _mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(_dataCollectionContext)); + + // Verify GetDumpFiles Call + _mockProcessDumpUtility.Verify(x => x.DetachFromTargetProcess(It.IsAny()), Times.Once); + } - /// - /// The trigger session ended handler should get dump files if collect dump on exit was enabled irrespective of completed test case count - /// - [TestMethod] - public void TriggerSessionEndedHandlerShouldGetDumpFileIfCollectDumpOnExitIsEnabled() - { - // Initializing Blame Data Collector - this.blameDataCollector.Initialize( - this.GetDumpConfigurationElement(collectDumpOnExit: true), - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); - - // Setup - this.mockProcessDumpUtility.Setup(x => x.GetDumpFiles(true, false)).Returns(new[] { this.filepath }); - this.mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), It.IsAny())) - .Returns(this.filepath); - - // Raise - this.mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(this.dataCollectionContext, 1234)); - this.mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(this.dataCollectionContext)); - - // Verify GetDumpFiles Call - this.mockProcessDumpUtility.Verify(x => x.GetDumpFiles(true, false), Times.Once); - } + /// + /// The trigger session ended handler should get dump files if collect dump on exit was enabled irrespective of completed test case count + /// + [TestMethod] + public void TriggerSessionEndedHandlerShouldGetDumpFileIfCollectDumpOnExitIsEnabled() + { + // Initializing Blame Data Collector + _blameDataCollector.Initialize( + GetDumpConfigurationElement(collectDumpOnExit: true), + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); + + // Setup + _mockProcessDumpUtility.Setup(x => x.GetDumpFiles(true, false)).Returns(new[] { _filepath }); + _mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), It.IsAny())) + .Returns(_filepath); + + // Raise + _mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(_dataCollectionContext, 1234)); + _mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(_dataCollectionContext)); + + // Verify GetDumpFiles Call + _mockProcessDumpUtility.Verify(x => x.GetDumpFiles(true, false), Times.Once); + } - /// - /// The trigger session ended handler should log exception if GetDumpfile throws FileNotFound Exception - /// - [TestMethod] - public void TriggerSessionEndedHandlerShouldLogWarningIfGetDumpFileThrowsFileNotFound() - { - // Initializing Blame Data Collector - // force it to collect dump on exit, which won't happen and we should see a warning - // but we should not see warning if we tell it to create dump and there is no crash - this.blameDataCollector.Initialize( - this.GetDumpConfigurationElement(false, collectDumpOnExit: true), - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); - - // Setup and raise events - this.mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), It.IsAny())) - .Returns(this.filepath); - this.mockProcessDumpUtility.Setup(x => x.GetDumpFiles(true, It.IsAny())).Throws(new FileNotFoundException()); - this.mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(this.dataCollectionContext, 1234)); - this.mockDataColectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(new TestCase())); - this.mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(this.dataCollectionContext)); - - // Verify GetDumpFiles Call - this.mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.IsAny()), Times.Once); - } + /// + /// The trigger session ended handler should log exception if GetDumpfile throws FileNotFound Exception + /// + [TestMethod] + public void TriggerSessionEndedHandlerShouldLogWarningIfGetDumpFileThrowsFileNotFound() + { + // Initializing Blame Data Collector + // force it to collect dump on exit, which won't happen and we should see a warning + // but we should not see warning if we tell it to create dump and there is no crash + _blameDataCollector.Initialize( + GetDumpConfigurationElement(false, collectDumpOnExit: true), + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); + + // Setup and raise events + _mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), It.IsAny())) + .Returns(_filepath); + _mockProcessDumpUtility.Setup(x => x.GetDumpFiles(true, It.IsAny())).Throws(new FileNotFoundException()); + _mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(_dataCollectionContext, 1234)); + _mockDataColectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(new TestCase())); + _mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(_dataCollectionContext)); + + // Verify GetDumpFiles Call + _mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.IsAny()), Times.Once); + } - /// - /// The trigger test host launched handler should start process dump utility if proc dump was enabled - /// - [TestMethod] - public void TriggerTestHostLaunchedHandlerShouldStartProcDumpUtilityIfProcDumpEnabled() - { - // Initializing Blame Data Collector - this.blameDataCollector.Initialize( - this.GetDumpConfigurationElement(), - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); - - // Raise TestHostLaunched - this.mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(this.dataCollectionContext, 1234)); - - // Verify StartProcessDumpCall - this.mockProcessDumpUtility.Verify(x => x.StartTriggerBasedProcessDump(1234, It.IsAny(), false, It.IsAny(), false)); - } + /// + /// The trigger test host launched handler should start process dump utility if proc dump was enabled + /// + [TestMethod] + public void TriggerTestHostLaunchedHandlerShouldStartProcDumpUtilityIfProcDumpEnabled() + { + // Initializing Blame Data Collector + _blameDataCollector.Initialize( + GetDumpConfigurationElement(), + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); + + // Raise TestHostLaunched + _mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(_dataCollectionContext, 1234)); + + // Verify StartProcessDumpCall + _mockProcessDumpUtility.Verify(x => x.StartTriggerBasedProcessDump(1234, It.IsAny(), false, It.IsAny(), false)); + } - /// - /// The trigger test host launched handler should start process dump utility for full dump if full dump was enabled - /// - [TestMethod] - public void TriggerTestHostLaunchedHandlerShouldStartProcDumpUtilityForFullDumpIfFullDumpEnabled() - { - // Initializing Blame Data Collector - this.blameDataCollector.Initialize( - this.GetDumpConfigurationElement(isFullDump: true), - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); - - // Raise TestHostLaunched - this.mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(this.dataCollectionContext, 1234)); - - // Verify StartProcessDumpCall - this.mockProcessDumpUtility.Verify(x => x.StartTriggerBasedProcessDump(1234, It.IsAny(), true, It.IsAny(), false)); - } + /// + /// The trigger test host launched handler should start process dump utility for full dump if full dump was enabled + /// + [TestMethod] + public void TriggerTestHostLaunchedHandlerShouldStartProcDumpUtilityForFullDumpIfFullDumpEnabled() + { + // Initializing Blame Data Collector + _blameDataCollector.Initialize( + GetDumpConfigurationElement(isFullDump: true), + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); + + // Raise TestHostLaunched + _mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(_dataCollectionContext, 1234)); + + // Verify StartProcessDumpCall + _mockProcessDumpUtility.Verify(x => x.StartTriggerBasedProcessDump(1234, It.IsAny(), true, It.IsAny(), false)); + } - /// - /// The trigger test host launched handler should start process dump utility for full dump if full dump was enabled - /// - [TestMethod] - public void TriggerTestHostLaunchedHandlerShouldStartProcDumpUtilityForFullDumpIfFullDumpEnabledCaseSensitivity() - { - var dumpConfig = this.GetDumpConfigurationElement(); - var dumpTypeAttribute = dumpConfig.OwnerDocument.CreateAttribute("DuMpType"); - dumpTypeAttribute.Value = "FuLl"; - dumpConfig[BlameDataCollector.Constants.DumpModeKey].Attributes.Append(dumpTypeAttribute); - var dumpOnExitAttribute = dumpConfig.OwnerDocument.CreateAttribute("CollEctAlways"); - dumpOnExitAttribute.Value = "FaLSe"; - dumpConfig[BlameDataCollector.Constants.DumpModeKey].Attributes.Append(dumpOnExitAttribute); - - // Initializing Blame Data Collector - this.blameDataCollector.Initialize( - dumpConfig, - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); - - // Raise TestHostLaunched - this.mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(this.dataCollectionContext, 1234)); - - // Verify StartProcessDumpCall - this.mockProcessDumpUtility.Verify(x => x.StartTriggerBasedProcessDump(1234, It.IsAny(), true, It.IsAny(), false)); - } + /// + /// The trigger test host launched handler should start process dump utility for full dump if full dump was enabled + /// + [TestMethod] + public void TriggerTestHostLaunchedHandlerShouldStartProcDumpUtilityForFullDumpIfFullDumpEnabledCaseSensitivity() + { + var dumpConfig = GetDumpConfigurationElement(); + var dumpTypeAttribute = dumpConfig.OwnerDocument.CreateAttribute("DuMpType"); + dumpTypeAttribute.Value = "FuLl"; + dumpConfig[BlameDataCollector.Constants.DumpModeKey].Attributes.Append(dumpTypeAttribute); + var dumpOnExitAttribute = dumpConfig.OwnerDocument.CreateAttribute("CollEctAlways"); + dumpOnExitAttribute.Value = "FaLSe"; + dumpConfig[BlameDataCollector.Constants.DumpModeKey].Attributes.Append(dumpOnExitAttribute); + + // Initializing Blame Data Collector + _blameDataCollector.Initialize( + dumpConfig, + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); + + // Raise TestHostLaunched + _mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(_dataCollectionContext, 1234)); + + // Verify StartProcessDumpCall + _mockProcessDumpUtility.Verify(x => x.StartTriggerBasedProcessDump(1234, It.IsAny(), true, It.IsAny(), false)); + } - /// - /// The trigger test host launched handler should start process dump utility for full dump if full dump was enabled - /// - [TestMethod] - public void TriggerTestHostLaunchedHandlerShouldLogWarningForWrongCollectDumpKey() - { - var dumpConfig = this.GetDumpConfigurationElement(); - var dumpTypeAttribute = dumpConfig.OwnerDocument.CreateAttribute("Xyz"); - dumpTypeAttribute.Value = "FuLl"; - dumpConfig[BlameDataCollector.Constants.DumpModeKey].Attributes.Append(dumpTypeAttribute); - - // Initializing Blame Data Collector - this.blameDataCollector.Initialize( - dumpConfig, - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); - - // Raise TestHostLaunched - this.mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(this.dataCollectionContext, 1234)); - - // Verify - this.mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.Is(str => str == string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterKeyIncorrect, "Xyz"))), Times.Once); - } + /// + /// The trigger test host launched handler should start process dump utility for full dump if full dump was enabled + /// + [TestMethod] + public void TriggerTestHostLaunchedHandlerShouldLogWarningForWrongCollectDumpKey() + { + var dumpConfig = GetDumpConfigurationElement(); + var dumpTypeAttribute = dumpConfig.OwnerDocument.CreateAttribute("Xyz"); + dumpTypeAttribute.Value = "FuLl"; + dumpConfig[BlameDataCollector.Constants.DumpModeKey].Attributes.Append(dumpTypeAttribute); + + // Initializing Blame Data Collector + _blameDataCollector.Initialize( + dumpConfig, + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); + + // Raise TestHostLaunched + _mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(_dataCollectionContext, 1234)); + + // Verify + _mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.Is(str => str == string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterKeyIncorrect, "Xyz"))), Times.Once); + } - /// - /// The trigger test host launched handler should start process dump utility for full dump if full dump was enabled - /// - [TestMethod] - public void TriggerTestHostLaunchedHandlerShouldLogWarningForWrongDumpType() - { - var dumpConfig = this.GetDumpConfigurationElement(); - var dumpTypeAttribute = dumpConfig.OwnerDocument.CreateAttribute("DumpType"); - dumpTypeAttribute.Value = "random"; - dumpConfig[BlameDataCollector.Constants.DumpModeKey].Attributes.Append(dumpTypeAttribute); - - // Initializing Blame Data Collector - this.blameDataCollector.Initialize( - dumpConfig, - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); - - // Raise TestHostLaunched - this.mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(this.dataCollectionContext, 1234)); - - // Verify - this.mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.Is(str => str == string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterValueIncorrect, "DumpType", BlameDataCollector.Constants.FullConfigurationValue, BlameDataCollector.Constants.MiniConfigurationValue))), Times.Once); - } + /// + /// The trigger test host launched handler should start process dump utility for full dump if full dump was enabled + /// + [TestMethod] + public void TriggerTestHostLaunchedHandlerShouldLogWarningForWrongDumpType() + { + var dumpConfig = GetDumpConfigurationElement(); + var dumpTypeAttribute = dumpConfig.OwnerDocument.CreateAttribute("DumpType"); + dumpTypeAttribute.Value = "random"; + dumpConfig[BlameDataCollector.Constants.DumpModeKey].Attributes.Append(dumpTypeAttribute); + + // Initializing Blame Data Collector + _blameDataCollector.Initialize( + dumpConfig, + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); + + // Raise TestHostLaunched + _mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(_dataCollectionContext, 1234)); + + // Verify + _mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.Is(str => str == string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterValueIncorrect, "DumpType", BlameDataCollector.Constants.FullConfigurationValue, BlameDataCollector.Constants.MiniConfigurationValue))), Times.Once); + } - /// - /// The trigger test host launched handler should start process dump utility for full dump if full dump was enabled - /// - [TestMethod] - public void TriggerTestHostLaunchedHandlerShouldLogWarningForNonBooleanCollectAlwaysValue() - { - var dumpConfig = this.GetDumpConfigurationElement(); - var dumpTypeAttribute = dumpConfig.OwnerDocument.CreateAttribute("DumpType"); - dumpTypeAttribute.Value = "random"; - dumpConfig[BlameDataCollector.Constants.DumpModeKey].Attributes.Append(dumpTypeAttribute); - - // Initializing Blame Data Collector - this.blameDataCollector.Initialize( - dumpConfig, - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); - - // Raise TestHostLaunched - this.mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(this.dataCollectionContext, 1234)); - - // Verify - this.mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.Is(str => str == string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterValueIncorrect, "DumpType", BlameDataCollector.Constants.FullConfigurationValue, BlameDataCollector.Constants.MiniConfigurationValue))), Times.Once); - } + /// + /// The trigger test host launched handler should start process dump utility for full dump if full dump was enabled + /// + [TestMethod] + public void TriggerTestHostLaunchedHandlerShouldLogWarningForNonBooleanCollectAlwaysValue() + { + var dumpConfig = GetDumpConfigurationElement(); + var dumpTypeAttribute = dumpConfig.OwnerDocument.CreateAttribute("DumpType"); + dumpTypeAttribute.Value = "random"; + dumpConfig[BlameDataCollector.Constants.DumpModeKey].Attributes.Append(dumpTypeAttribute); + + // Initializing Blame Data Collector + _blameDataCollector.Initialize( + dumpConfig, + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); + + // Raise TestHostLaunched + _mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(_dataCollectionContext, 1234)); + + // Verify + _mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.Is(str => str == string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterValueIncorrect, "DumpType", BlameDataCollector.Constants.FullConfigurationValue, BlameDataCollector.Constants.MiniConfigurationValue))), Times.Once); + } - /// - /// The trigger test host launched handler should start process dump utility for full dump if full dump was enabled - /// - [TestMethod] - public void TriggerTestHostLaunchedHandlerShouldLogNoWarningWhenDumpTypeIsUsedWithHangDumpBecauseEitherHangDumpTypeOrDumpTypeCanBeSpecified() - { - var dumpConfig = this.GetDumpConfigurationElement(isFullDump: true, false, colectDumpOnHang: true, 1800000); + /// + /// The trigger test host launched handler should start process dump utility for full dump if full dump was enabled + /// + [TestMethod] + public void TriggerTestHostLaunchedHandlerShouldLogNoWarningWhenDumpTypeIsUsedWithHangDumpBecauseEitherHangDumpTypeOrDumpTypeCanBeSpecified() + { + var dumpConfig = GetDumpConfigurationElement(isFullDump: true, false, colectDumpOnHang: true, 1800000); - // Initializing Blame Data Collector - this.blameDataCollector.Initialize( - dumpConfig, - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); + // Initializing Blame Data Collector + _blameDataCollector.Initialize( + dumpConfig, + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); - // Raise TestHostLaunched - this.mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(this.dataCollectionContext, 1234)); + // Raise TestHostLaunched + _mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(_dataCollectionContext, 1234)); - // Verify - this.mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.IsAny()), Times.Never); - } + // Verify + _mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.IsAny()), Times.Never); + } - /// - /// The trigger test host launched handler should not break if start process dump throws TestPlatFormExceptions and log error message - /// - [TestMethod] - public void TriggerTestHostLaunchedHandlerShouldCatchTestPlatFormExceptionsAndReportMessage() - { - // Initializing Blame Data Collector - this.blameDataCollector.Initialize( - this.GetDumpConfigurationElement(), - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); - - // Make StartProcessDump throw exception - var tpex = new TestPlatformException("env var exception"); - this.mockProcessDumpUtility.Setup(x => x.StartTriggerBasedProcessDump(1234, It.IsAny(), false, It.IsAny(), false)) - .Throws(tpex); - - // Raise TestHostLaunched - this.mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(this.dataCollectionContext, 1234)); - - // Verify - this.mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.Is(str => str == string.Format(CultureInfo.CurrentUICulture, Resources.Resources.ProcDumpCouldNotStart, tpex.Message))), Times.Once); - } + /// + /// The trigger test host launched handler should not break if start process dump throws TestPlatFormExceptions and log error message + /// + [TestMethod] + public void TriggerTestHostLaunchedHandlerShouldCatchTestPlatFormExceptionsAndReportMessage() + { + // Initializing Blame Data Collector + _blameDataCollector.Initialize( + GetDumpConfigurationElement(), + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); + + // Make StartProcessDump throw exception + var tpex = new TestPlatformException("env var exception"); + _mockProcessDumpUtility.Setup(x => x.StartTriggerBasedProcessDump(1234, It.IsAny(), false, It.IsAny(), false)) + .Throws(tpex); + + // Raise TestHostLaunched + _mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(_dataCollectionContext, 1234)); + + // Verify + _mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.Is(str => str == string.Format(CultureInfo.CurrentUICulture, Resources.Resources.ProcDumpCouldNotStart, tpex.Message))), Times.Once); + } - /// - /// The trigger test host launched handler should not break if start process dump throws unknown exceptions and report message with stack trace - /// - [TestMethod] - public void TriggerTestHostLaunchedHandlerShouldCatchAllUnexpectedExceptionsAndReportMessageWithStackTrace() + /// + /// The trigger test host launched handler should not break if start process dump throws unknown exceptions and report message with stack trace + /// + [TestMethod] + public void TriggerTestHostLaunchedHandlerShouldCatchAllUnexpectedExceptionsAndReportMessageWithStackTrace() + { + // Initializing Blame Data Collector + _blameDataCollector.Initialize( + GetDumpConfigurationElement(), + _mockDataColectionEvents.Object, + _mockDataCollectionSink.Object, + _mockLogger.Object, + _context); + + // Make StartProcessDump throw exception + var ex = new Exception("start process failed"); + _mockProcessDumpUtility.Setup(x => x.StartTriggerBasedProcessDump(1234, It.IsAny(), false, It.IsAny(), false)) + .Throws(ex); + + // Raise TestHostLaunched + _mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(_dataCollectionContext, 1234)); + + // Verify + _mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.Is(str => str == string.Format(CultureInfo.CurrentUICulture, Resources.Resources.ProcDumpCouldNotStart, ex.ToString()))), Times.Once); + } + + [TestCleanup] + public void CleanUp() + { + File.Delete(_filepath); + } + + private XmlElement GetDumpConfigurationElement( + bool isFullDump = false, + bool collectDumpOnExit = false, + bool colectDumpOnHang = false, + int inactivityTimeInMilliseconds = 0) + { + var xmldoc = new XmlDocument(); + var outernode = xmldoc.CreateElement("Configuration"); + var node = xmldoc.CreateElement(BlameDataCollector.Constants.DumpModeKey); + outernode.AppendChild(node); + node.InnerText = "Text"; + + if (isFullDump) { - // Initializing Blame Data Collector - this.blameDataCollector.Initialize( - this.GetDumpConfigurationElement(), - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - this.mockLogger.Object, - this.context); - - // Make StartProcessDump throw exception - var ex = new Exception("start process failed"); - this.mockProcessDumpUtility.Setup(x => x.StartTriggerBasedProcessDump(1234, It.IsAny(), false, It.IsAny(), false)) - .Throws(ex); - - // Raise TestHostLaunched - this.mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(this.dataCollectionContext, 1234)); - - // Verify - this.mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.Is(str => str == string.Format(CultureInfo.CurrentUICulture, Resources.Resources.ProcDumpCouldNotStart, ex.ToString()))), Times.Once); + var fulldumpAttribute = xmldoc.CreateAttribute(BlameDataCollector.Constants.DumpTypeKey); + fulldumpAttribute.Value = "full"; + node.Attributes.Append(fulldumpAttribute); } - [TestCleanup] - public void CleanUp() + if (collectDumpOnExit) { - File.Delete(this.filepath); + var collectDumpOnExitAttribute = xmldoc.CreateAttribute(BlameDataCollector.Constants.CollectDumpAlwaysKey); + collectDumpOnExitAttribute.Value = "true"; + node.Attributes.Append(collectDumpOnExitAttribute); } - private XmlElement GetDumpConfigurationElement( - bool isFullDump = false, - bool collectDumpOnExit = false, - bool colectDumpOnHang = false, - int inactivityTimeInMilliseconds = 0) + if (colectDumpOnHang) { - var xmldoc = new XmlDocument(); - var outernode = xmldoc.CreateElement("Configuration"); - var node = xmldoc.CreateElement(BlameDataCollector.Constants.DumpModeKey); - outernode.AppendChild(node); - node.InnerText = "Text"; + var hangDumpNode = xmldoc.CreateElement(BlameDataCollector.Constants.CollectDumpOnTestSessionHang); + outernode.AppendChild(hangDumpNode); + + var inactivityTimeAttribute = xmldoc.CreateAttribute(BlameDataCollector.Constants.TestTimeout); + inactivityTimeAttribute.Value = $"{inactivityTimeInMilliseconds}"; + hangDumpNode.Attributes.Append(inactivityTimeAttribute); if (isFullDump) { var fulldumpAttribute = xmldoc.CreateAttribute(BlameDataCollector.Constants.DumpTypeKey); fulldumpAttribute.Value = "full"; - node.Attributes.Append(fulldumpAttribute); - } - - if (collectDumpOnExit) - { - var collectDumpOnExitAttribute = xmldoc.CreateAttribute(BlameDataCollector.Constants.CollectDumpAlwaysKey); - collectDumpOnExitAttribute.Value = "true"; - node.Attributes.Append(collectDumpOnExitAttribute); + hangDumpNode.Attributes.Append(fulldumpAttribute); } - - if (colectDumpOnHang) - { - var hangDumpNode = xmldoc.CreateElement(BlameDataCollector.Constants.CollectDumpOnTestSessionHang); - outernode.AppendChild(hangDumpNode); - - var inactivityTimeAttribute = xmldoc.CreateAttribute(BlameDataCollector.Constants.TestTimeout); - inactivityTimeAttribute.Value = $"{inactivityTimeInMilliseconds}"; - hangDumpNode.Attributes.Append(inactivityTimeAttribute); - - if (isFullDump) - { - var fulldumpAttribute = xmldoc.CreateAttribute(BlameDataCollector.Constants.DumpTypeKey); - fulldumpAttribute.Value = "full"; - hangDumpNode.Attributes.Append(fulldumpAttribute); - } - } - - return outernode; } + return outernode; + } + + /// + /// The testable blame collector. + /// + internal class TestableBlameCollector : BlameCollector + { /// - /// The testable blame collector. + /// Initializes a new instance of the class. /// - internal class TestableBlameCollector : BlameCollector + /// + /// The blame reader writer. + /// + /// + /// ProcessDumpUtility instance. + /// + /// + /// InactivityTimer instance. + /// + /// + /// MockFileHelper instance. + /// + internal TestableBlameCollector(IBlameReaderWriter blameReaderWriter, IProcessDumpUtility processDumpUtility, IInactivityTimer inactivityTimer, IFileHelper mockFileHelper) + : base(blameReaderWriter, processDumpUtility, inactivityTimer, mockFileHelper) { - /// - /// Initializes a new instance of the class. - /// - /// - /// The blame reader writer. - /// - /// - /// ProcessDumpUtility instance. - /// - /// - /// InactivityTimer instance. - /// - /// - /// MockFileHelper instance. - /// - internal TestableBlameCollector(IBlameReaderWriter blameReaderWriter, IProcessDumpUtility processDumpUtility, IInactivityTimer inactivityTimer, IFileHelper mockFileHelper) - : base(blameReaderWriter, processDumpUtility, inactivityTimer, mockFileHelper) - { - } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/BlameLoggerTests.cs b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/BlameLoggerTests.cs index 2f53aee914..fe66fe5c5e 100644 --- a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/BlameLoggerTests.cs +++ b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/BlameLoggerTests.cs @@ -1,173 +1,163 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests; + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +using Microsoft.VisualStudio.TestPlatform.Common.Logging; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +/// +/// The blame logger tests. +/// +[TestClass] +public class BlameLoggerTests { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; + private readonly Mock _mockOutput; + private readonly Mock _mockBlameReaderWriter; + private readonly BlameLogger _blameLogger; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; + /// + /// Initializes a new instance of the class. + /// + public BlameLoggerTests() + { + // Mock for ITestRunRequest + _mockOutput = new Mock(); + _mockBlameReaderWriter = new Mock(); + _blameLogger = new TestableBlameLogger(_mockOutput.Object, _mockBlameReaderWriter.Object); + } - using Moq; + /// + /// The initialize should throw exception if events is null. + /// + [TestMethod] + public void InitializeShouldThrowExceptionIfEventsIsNull() + { + Assert.ThrowsException(() => _blameLogger.Initialize(null, string.Empty)); + } /// - /// The blame logger tests. + /// The test run complete handler should get faulty test run if test run aborted. /// - [TestClass] - public class BlameLoggerTests + [TestMethod] + public void TestRunCompleteHandlerShouldGetFaultyTestRunIfTestRunAborted() { - private Mock testRunRequest; - private Mock events; - private Mock mockOutput; - private Mock mockBlameReaderWriter; - private BlameLogger blameLogger; + InitializeAndVerify(1); + } - /// - /// Initializes a new instance of the class. - /// - public BlameLoggerTests() - { - // Mock for ITestRunRequest - this.testRunRequest = new Mock(); - this.events = new Mock(); - this.mockOutput = new Mock(); - this.mockBlameReaderWriter = new Mock(); - this.blameLogger = new TestableBlameLogger(this.mockOutput.Object, this.mockBlameReaderWriter.Object); - } + /// + /// The test run complete handler should get faulty test run if test run aborted for multiple test project. + /// + [TestMethod] + public void TestRunCompleteHandlerShouldGetFaultyTestRunIfTestRunAbortedForMultipleProjects() + { + InitializeAndVerify(2); + } - /// - /// The initialize should throw exception if events is null. - /// - [TestMethod] - public void InitializeShouldThrowExceptionIfEventsIsNull() - { - Assert.ThrowsException(() => - { - this.blameLogger.Initialize(null, string.Empty); - }); - } + /// + /// The test run complete handler should not read file if test run not aborted. + /// + [TestMethod] + public void TestRunCompleteHandlerShouldNotReadFileIfTestRunNotAborted() + { + // Initialize Blame Logger + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + _blameLogger.Initialize(loggerEvents, (string)null); - /// - /// The test run complete handler should get faulty test run if test run aborted. - /// - [TestMethod] - public void TestRunCompleteHandlerShouldGetFaultyTestRunIfTestRunAborted() - { - this.InitializeAndVerify(1); - } + // Setup and Raise event + _mockBlameReaderWriter.Setup(x => x.ReadTestSequence(It.IsAny())); + loggerEvents.CompleteTestRun(null, false, false, null, null, null, new TimeSpan(1, 0, 0, 0)); - /// - /// The test run complete handler should get faulty test run if test run aborted for multiple test project. - /// - [TestMethod] - public void TestRunCompleteHandlerShouldGetFaultyTestRunIfTestRunAbortedForMultipleProjects() - { - this.InitializeAndVerify(2); - } + // Verify Call + _mockBlameReaderWriter.Verify(x => x.ReadTestSequence(It.IsAny()), Times.Never); + } - /// - /// The test run complete handler should not read file if test run not aborted. - /// - [TestMethod] - public void TestRunCompleteHandlerShouldNotReadFileIfTestRunNotAborted() - { - // Initialize Blame Logger - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - this.blameLogger.Initialize(loggerEvents, (string)null); + /// + /// The test run complete handler should return if uri attachment is null. + /// + [TestMethod] + public void TestRunCompleteHandlerShouldReturnIfUriAttachmentIsNull() + { + // Initialize + var attachmentSet = new AttachmentSet(new Uri("test://uri"), "Blame"); + var attachmentSetList = new List { attachmentSet }; - // Setup and Raise event - this.mockBlameReaderWriter.Setup(x => x.ReadTestSequence(It.IsAny())); - loggerEvents.CompleteTestRun(null, false, false, null, null, null, new TimeSpan(1, 0, 0, 0)); + // Initialize Blame Logger + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + _blameLogger.Initialize(loggerEvents, (string)null); - // Verify Call - this.mockBlameReaderWriter.Verify(x => x.ReadTestSequence(It.IsAny()), Times.Never); - } + // Setup and Raise event + loggerEvents.CompleteTestRun(null, false, true, null, new Collection(attachmentSetList), new Collection(), new TimeSpan(1, 0, 0, 0)); - /// - /// The test run complete handler should return if uri attachment is null. - /// - [TestMethod] - public void TestRunCompleteHandlerShouldReturnIfUriAttachmentIsNull() - { - // Initialize - var attachmentSet = new AttachmentSet(new Uri("test://uri"), "Blame"); - var attachmentSetList = new List { attachmentSet }; + // Verify Call + _mockBlameReaderWriter.Verify(x => x.ReadTestSequence(It.IsAny()), Times.Never); + } - // Initialize Blame Logger - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - this.blameLogger.Initialize(loggerEvents, (string)null); + private AttachmentSet GetAttachmentSet() + { + var attachmentSet = new AttachmentSet(new Uri("test://uri"), "Blame"); + attachmentSet.Attachments.Add(new UriDataAttachment(new Uri("C:/folder1/sequence.xml"), "description")); + attachmentSet.Attachments.Add(new UriDataAttachment(new Uri("C:/folder1/dump.dmp"), "description")); - // Setup and Raise event - loggerEvents.CompleteTestRun(null, false, true, null, new Collection(attachmentSetList), new Collection(), new TimeSpan(1, 0, 0, 0)); + return attachmentSet; + } - // Verify Call - this.mockBlameReaderWriter.Verify(x => x.ReadTestSequence(It.IsAny()), Times.Never); - } + private void InitializeAndVerify(int count) + { + // Initialize + var attachmentSetList = new List(); - private AttachmentSet GetAttachmentSet() + for (int i = 0; i < count; i++) { - var attachmentSet = new AttachmentSet(new Uri("test://uri"), "Blame"); - attachmentSet.Attachments.Add(new UriDataAttachment(new Uri("C:/folder1/sequence.xml"), "description")); - attachmentSet.Attachments.Add(new UriDataAttachment(new Uri("C:/folder1/dump.dmp"), "description")); - - return attachmentSet; + attachmentSetList.Add(GetAttachmentSet()); } - private void InitializeAndVerify(int count) + // Initialize Blame Logger + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + _blameLogger.Initialize(loggerEvents, (string)null); + + var testCaseList = new List { - // Initialize - var attachmentSetList = new List(); - - for (int i = 0; i < count; i++) - { - attachmentSetList.Add(this.GetAttachmentSet()); - } - - // Initialize Blame Logger - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - this.blameLogger.Initialize(loggerEvents, (string)null); - - var testCaseList = - new List - { - new BlameTestObject(new TestCase("ABC.UnitTestMethod1", new Uri("test://uri"), "C://test/filepath")), - new BlameTestObject(new TestCase("ABC.UnitTestMethod2", new Uri("test://uri"), "C://test/filepath")) - }; - - // Setup and Raise event - this.mockBlameReaderWriter.Setup(x => x.ReadTestSequence(It.IsAny())).Returns(testCaseList); - loggerEvents.CompleteTestRun(null, false, true, null, new Collection(attachmentSetList), new Collection(), new TimeSpan(1, 0, 0, 0)); - - // Verify Call - this.mockBlameReaderWriter.Verify(x => x.ReadTestSequence(It.Is(str => str.EndsWith(".xml"))), Times.Exactly(count)); - } + new BlameTestObject(new TestCase("ABC.UnitTestMethod1", new Uri("test://uri"), "C://test/filepath")), + new BlameTestObject(new TestCase("ABC.UnitTestMethod2", new Uri("test://uri"), "C://test/filepath")) + }; + + // Setup and Raise event + _mockBlameReaderWriter.Setup(x => x.ReadTestSequence(It.IsAny())).Returns(testCaseList); + loggerEvents.CompleteTestRun(null, false, true, null, new Collection(attachmentSetList), new Collection(), new TimeSpan(1, 0, 0, 0)); + + // Verify Call + _mockBlameReaderWriter.Verify(x => x.ReadTestSequence(It.Is(str => str.EndsWith(".xml"))), Times.Exactly(count)); + } + /// + /// The testable blame logger. + /// + internal class TestableBlameLogger : BlameLogger + { /// - /// The testable blame logger. + /// Initializes a new instance of the class. /// - internal class TestableBlameLogger : BlameLogger + /// + /// The output. + /// + /// + /// The blame Reader Writer. + /// + internal TestableBlameLogger(IOutput output, IBlameReaderWriter blameReaderWriter) + : base(output, blameReaderWriter) { - /// - /// Initializes a new instance of the class. - /// - /// - /// The output. - /// - /// - /// The blame Reader Writer. - /// - internal TestableBlameLogger(IOutput output, IBlameReaderWriter blameReaderWriter) - : base(output, blameReaderWriter) - { - } } } } diff --git a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/InactivityTimerTests.cs b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/InactivityTimerTests.cs index 7897eb1f2e..79b4ffd98e 100644 --- a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/InactivityTimerTests.cs +++ b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/InactivityTimerTests.cs @@ -1,31 +1,31 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests; + +using System; +using System.Threading; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class InactivityTimerTests { - using System; - using System.Threading; - using Microsoft.VisualStudio.TestTools.UnitTesting; + private int _callBackCount = 0; + private readonly ManualResetEventSlim _timerEvent = new(); - [TestClass] - public class InactivityTimerTests + [TestMethod] + public void InactivityTimerShouldResetAndCallbackWhenResetIsCalled() { - private int callBackCount = 0; - private ManualResetEventSlim timerEvent = new ManualResetEventSlim(); - - [TestMethod] - public void InactivityTimerShouldResetAndCallbackWhenResetIsCalled() - { - var timer = new InactivityTimer(this.TimerCallback); - timer.ResetTimer(TimeSpan.FromMilliseconds(1)); - this.timerEvent.Wait(1000); - Assert.AreEqual(1, this.callBackCount, "Should have fired once."); - } + var timer = new InactivityTimer(TimerCallback); + timer.ResetTimer(TimeSpan.FromMilliseconds(1)); + _timerEvent.Wait(1000); + Assert.AreEqual(1, _callBackCount, "Should have fired once."); + } - private void TimerCallback() - { - this.callBackCount++; - this.timerEvent.Set(); - } + private void TimerCallback() + { + _callBackCount++; + _timerEvent.Set(); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests.csproj b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests.csproj index 09bce9beb6..2c7b43a296 100644 --- a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests.csproj +++ b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests.csproj @@ -17,6 +17,10 @@ true true + + + + @@ -28,8 +32,5 @@ - - - diff --git a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/ProcDumpArgsBuilderTests.cs b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/ProcDumpArgsBuilderTests.cs index eb1d7114ee..d00d54c9c5 100644 --- a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/ProcDumpArgsBuilderTests.cs +++ b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/ProcDumpArgsBuilderTests.cs @@ -1,57 +1,57 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests; + +using System.Collections.Generic; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class ProcDumpArgsBuilderTests { - using System.Collections.Generic; - using Microsoft.VisualStudio.TestTools.UnitTesting; + private readonly int _defaultProcId = 1234; + private readonly string _defaultDumpFileName = "dump"; + + [TestMethod] + public void BuildHangBasedProcDumpArgsShouldCreateCorrectArgString() + { + var procDumpArgsBuilder = new ProcDumpArgsBuilder(); + var argString = procDumpArgsBuilder.BuildHangBasedProcDumpArgs(_defaultProcId, _defaultDumpFileName, false); + Assert.AreEqual("-accepteula -n 1 1234 dump.dmp", argString); + } + + [TestMethod] + public void BuildHangBasedProcDumpArgsWithFullDumpEnabledShouldCreateCorrectArgString() + { + var procDumpArgsBuilder = new ProcDumpArgsBuilder(); + var argString = procDumpArgsBuilder.BuildHangBasedProcDumpArgs(_defaultProcId, _defaultDumpFileName, true); + Assert.AreEqual("-accepteula -n 1 -ma 1234 dump.dmp", argString); + } + + [TestMethod] + public void BuildTriggerBasedProcDumpArgsShouldCreateCorrectArgString() + { + var procDumpArgsBuilder = new ProcDumpArgsBuilder(); + var argString = procDumpArgsBuilder.BuildTriggerBasedProcDumpArgs(_defaultProcId, _defaultDumpFileName, new List { "a", "b" }, false); + Assert.AreEqual("-accepteula -e 1 -g -t -f a -f b 1234 dump.dmp", argString); + } - [TestClass] - public class ProcDumpArgsBuilderTests + [TestMethod] + public void BuildTriggerProcDumpArgsWithFullDumpEnabledShouldCreateCorrectArgString() { - private int defaultProcId = 1234; - private string defaultDumpFileName = "dump"; - - [TestMethod] - public void BuildHangBasedProcDumpArgsShouldCreateCorrectArgString() - { - var procDumpArgsBuilder = new ProcDumpArgsBuilder(); - var argString = procDumpArgsBuilder.BuildHangBasedProcDumpArgs(this.defaultProcId, this.defaultDumpFileName, false); - Assert.AreEqual("-accepteula -n 1 1234 dump.dmp", argString); - } - - [TestMethod] - public void BuildHangBasedProcDumpArgsWithFullDumpEnabledShouldCreateCorrectArgString() - { - var procDumpArgsBuilder = new ProcDumpArgsBuilder(); - var argString = procDumpArgsBuilder.BuildHangBasedProcDumpArgs(this.defaultProcId, this.defaultDumpFileName, true); - Assert.AreEqual("-accepteula -n 1 -ma 1234 dump.dmp", argString); - } - - [TestMethod] - public void BuildTriggerBasedProcDumpArgsShouldCreateCorrectArgString() - { - var procDumpArgsBuilder = new ProcDumpArgsBuilder(); - var argString = procDumpArgsBuilder.BuildTriggerBasedProcDumpArgs(this.defaultProcId, this.defaultDumpFileName, new List { "a", "b" }, false); - Assert.AreEqual("-accepteula -e 1 -g -t -f a -f b 1234 dump.dmp", argString); - } - - [TestMethod] - public void BuildTriggerProcDumpArgsWithFullDumpEnabledShouldCreateCorrectArgString() - { - var procDumpArgsBuilder = new ProcDumpArgsBuilder(); - var argString = procDumpArgsBuilder.BuildTriggerBasedProcDumpArgs(this.defaultProcId, this.defaultDumpFileName, new List { "a", "b" }, true); - Assert.AreEqual("-accepteula -e 1 -g -t -ma -f a -f b 1234 dump.dmp", argString); - } - - [TestMethod] - public void BuildTriggerProcDumpArgsWithAlwaysCollectShouldCreateCorrectArgString() - { - var procDumpArgsBuilder = new ProcDumpArgsBuilder(); - var argString = procDumpArgsBuilder.BuildTriggerBasedProcDumpArgs(this.defaultProcId, this.defaultDumpFileName, new List { "a", "b" }, true); - - // adds -t for collect on every process exit - Assert.AreEqual("-accepteula -e 1 -g -t -ma -f a -f b 1234 dump.dmp", argString); - } + var procDumpArgsBuilder = new ProcDumpArgsBuilder(); + var argString = procDumpArgsBuilder.BuildTriggerBasedProcDumpArgs(_defaultProcId, _defaultDumpFileName, new List { "a", "b" }, true); + Assert.AreEqual("-accepteula -e 1 -g -t -ma -f a -f b 1234 dump.dmp", argString); + } + + [TestMethod] + public void BuildTriggerProcDumpArgsWithAlwaysCollectShouldCreateCorrectArgString() + { + var procDumpArgsBuilder = new ProcDumpArgsBuilder(); + var argString = procDumpArgsBuilder.BuildTriggerBasedProcDumpArgs(_defaultProcId, _defaultDumpFileName, new List { "a", "b" }, true); + + // adds -t for collect on every process exit + Assert.AreEqual("-accepteula -e 1 -g -t -ma -f a -f b 1234 dump.dmp", argString); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/ProcessDumpUtilityTests.cs b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/ProcessDumpUtilityTests.cs index 82dbe72e70..c5b8040040 100644 --- a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/ProcessDumpUtilityTests.cs +++ b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/ProcessDumpUtilityTests.cs @@ -1,70 +1,66 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests -{ - using System; - using System.Diagnostics; - using System.IO; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests; +using System.IO; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using VisualStudio.TestTools.UnitTesting; + +using Moq; - using Moq; +/// +/// The blame collector tests. +/// +[TestClass] +public class ProcessDumpUtilityTests +{ + private readonly Mock _mockFileHelper; + private readonly Mock _mockProcessHelper; + private readonly Mock _mockHangDumperFactory; + private readonly Mock _mockCrashDumperFactory; /// - /// The blame collector tests. + /// Initializes a new instance of the class. /// - [TestClass] - public class ProcessDumpUtilityTests + public ProcessDumpUtilityTests() { - private Mock mockFileHelper; - private Mock mockProcessHelper; - private Mock mockHangDumperFactory; - private Mock mockCrashDumperFactory; - - /// - /// Initializes a new instance of the class. - /// - public ProcessDumpUtilityTests() - { - this.mockFileHelper = new Mock(); - this.mockProcessHelper = new Mock(); - this.mockHangDumperFactory = new Mock(); - this.mockCrashDumperFactory = new Mock(); - } + _mockFileHelper = new Mock(); + _mockProcessHelper = new Mock(); + _mockHangDumperFactory = new Mock(); + _mockCrashDumperFactory = new Mock(); + } - /// - /// GetDumpFile will return empty list of strings if no dump files found - /// - [TestMethod] - public void GetDumpFileWillThrowExceptionIfNoDumpfile() - { - var process = "process"; - var processId = 12345; - var testResultsDirectory = "D:\\TestResults"; + /// + /// GetDumpFile will return empty list of strings if no dump files found + /// + [TestMethod] + public void GetDumpFileWillThrowExceptionIfNoDumpfile() + { + var process = "process"; + var processId = 12345; + var testResultsDirectory = "D:\\TestResults"; - this.mockFileHelper.Setup(x => x.GetFiles(It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(new string[] { }); - this.mockProcessHelper.Setup(x => x.GetProcessName(processId)) - .Returns(process); + _mockFileHelper.Setup(x => x.GetFiles(It.IsAny(), It.IsAny(), It.IsAny())) + .Returns(new string[] { }); + _mockProcessHelper.Setup(x => x.GetProcessName(processId)) + .Returns(process); - this.mockHangDumperFactory.Setup(x => x.Create(It.IsAny())) - .Returns(new Mock().Object); + _mockHangDumperFactory.Setup(x => x.Create(It.IsAny())) + .Returns(new Mock().Object); - this.mockCrashDumperFactory.Setup(x => x.Create(It.IsAny())) - .Returns(new Mock().Object); + _mockCrashDumperFactory.Setup(x => x.Create(It.IsAny())) + .Returns(new Mock().Object); - var processDumpUtility = new ProcessDumpUtility( - this.mockProcessHelper.Object, - this.mockFileHelper.Object, - this.mockHangDumperFactory.Object, - this.mockCrashDumperFactory.Object); + var processDumpUtility = new ProcessDumpUtility( + _mockProcessHelper.Object, + _mockFileHelper.Object, + _mockHangDumperFactory.Object, + _mockCrashDumperFactory.Object); - processDumpUtility.StartTriggerBasedProcessDump(processId, testResultsDirectory, false, ".NETCoreApp,Version=v5.0", false); + processDumpUtility.StartTriggerBasedProcessDump(processId, testResultsDirectory, false, ".NETCoreApp,Version=v5.0", false); - var ex = Assert.ThrowsException(() => processDumpUtility.GetDumpFiles(true, false)); - Assert.AreEqual(ex.Message, Resources.Resources.DumpFileNotGeneratedErrorMessage); - } + var ex = Assert.ThrowsException(() => processDumpUtility.GetDumpFiles(true, false)); + Assert.AreEqual(ex.Message, Resources.Resources.DumpFileNotGeneratedErrorMessage); } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/Program.cs b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/Program.cs index 43205ef72e..766417aa90 100644 --- a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/Program.cs +++ b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/Program.cs @@ -1,11 +1,11 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests; + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/XmlReaderWriterTests.cs b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/XmlReaderWriterTests.cs index c8b7b5f689..70eed65eba 100644 --- a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/XmlReaderWriterTests.cs +++ b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/XmlReaderWriterTests.cs @@ -1,219 +1,206 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests +namespace Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using VisualStudio.TestTools.UnitTesting; + +using Moq; + +/// +/// The xml reader writer tests. +/// +[TestClass] +public class XmlReaderWriterTests { - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; + private readonly TestableXmlReaderWriter _xmlReaderWriter; + private readonly Mock _mockFileHelper; + private readonly Mock _mockStream; + private readonly List _testCaseList; + private readonly Dictionary _testObjectDictionary; + private readonly BlameTestObject _blameTestObject; /// - /// The xml reader writer tests. + /// Initializes a new instance of the class. /// - [TestClass] - public class XmlReaderWriterTests + public XmlReaderWriterTests() { - private TestableXmlReaderWriter xmlReaderWriter; - private Mock mockFileHelper; - private Mock mockStream; - private List testCaseList; - private Dictionary testObjectDictionary; - private BlameTestObject blameTestObject; - - /// - /// Initializes a new instance of the class. - /// - public XmlReaderWriterTests() + _mockFileHelper = new Mock(); + _xmlReaderWriter = new TestableXmlReaderWriter(_mockFileHelper.Object); + _mockStream = new Mock(); + _testCaseList = new List(); + _testObjectDictionary = new Dictionary(); + var testcase = new TestCase { - this.mockFileHelper = new Mock(); - this.xmlReaderWriter = new TestableXmlReaderWriter(this.mockFileHelper.Object); - this.mockStream = new Mock(); - this.testCaseList = new List(); - this.testObjectDictionary = new Dictionary(); - var testcase = new TestCase - { - ExecutorUri = new Uri("test:/abc"), - FullyQualifiedName = "TestProject.UnitTest.TestMethod", - Source = "abc.dll" - }; - this.blameTestObject = new BlameTestObject(testcase); - } + ExecutorUri = new Uri("test:/abc"), + FullyQualifiedName = "TestProject.UnitTest.TestMethod", + Source = "abc.dll" + }; + _blameTestObject = new BlameTestObject(testcase); + } - /// - /// The write test sequence should throw exception if file path is null. - /// - [TestMethod] - public void WriteTestSequenceShouldThrowExceptionIfFilePathIsNull() - { - this.testCaseList.Add(this.blameTestObject.Id); - this.testObjectDictionary.Add(this.blameTestObject.Id, this.blameTestObject); + /// + /// The write test sequence should throw exception if file path is null. + /// + [TestMethod] + public void WriteTestSequenceShouldThrowExceptionIfFilePathIsNull() + { + _testCaseList.Add(_blameTestObject.Id); + _testObjectDictionary.Add(_blameTestObject.Id, _blameTestObject); - Assert.ThrowsException(() => - { - this.xmlReaderWriter.WriteTestSequence(this.testCaseList, this.testObjectDictionary, null); - }); - } + Assert.ThrowsException(() => _xmlReaderWriter.WriteTestSequence(_testCaseList, _testObjectDictionary, null)); + } - /// - /// The write test sequence should throw exception if file path is empty. - /// - [TestMethod] - public void WriteTestSequenceShouldThrowExceptionIfFilePathIsEmpty() - { - this.testCaseList.Add(this.blameTestObject.Id); - this.testObjectDictionary.Add(this.blameTestObject.Id, this.blameTestObject); + /// + /// The write test sequence should throw exception if file path is empty. + /// + [TestMethod] + public void WriteTestSequenceShouldThrowExceptionIfFilePathIsEmpty() + { + _testCaseList.Add(_blameTestObject.Id); + _testObjectDictionary.Add(_blameTestObject.Id, _blameTestObject); - Assert.ThrowsException(() => - { - this.xmlReaderWriter.WriteTestSequence(this.testCaseList, this.testObjectDictionary, string.Empty); - }); - } + Assert.ThrowsException(() => _xmlReaderWriter.WriteTestSequence(_testCaseList, _testObjectDictionary, string.Empty)); + } - /// - /// The read test sequence should throw exception if file path is null. - /// - [TestMethod] - public void ReadTestSequenceShouldThrowExceptionIfFilePathIsNull() - { - Assert.ThrowsException(() => - { - this.xmlReaderWriter.ReadTestSequence(null); - }); - } + /// + /// The read test sequence should throw exception if file path is null. + /// + [TestMethod] + public void ReadTestSequenceShouldThrowExceptionIfFilePathIsNull() + { + Assert.ThrowsException(() => _xmlReaderWriter.ReadTestSequence(null)); + } - /// - /// The read test sequence should throw exception if file not found. - /// - [TestMethod] - public void ReadTestSequenceShouldThrowExceptionIfFileNotFound() - { - this.mockFileHelper.Setup(m => m.Exists(It.IsAny())).Returns(false); + /// + /// The read test sequence should throw exception if file not found. + /// + [TestMethod] + public void ReadTestSequenceShouldThrowExceptionIfFileNotFound() + { + _mockFileHelper.Setup(m => m.Exists(It.IsAny())).Returns(false); - Assert.ThrowsException(() => - { - this.xmlReaderWriter.ReadTestSequence(string.Empty); - }); - } + Assert.ThrowsException(() => _xmlReaderWriter.ReadTestSequence(string.Empty)); + } - /// - /// The read test sequence should read file stream. - /// - [TestMethod] - public void ReadTestSequenceShouldReadFileStream() - { - // Setup - this.mockFileHelper.Setup(m => m.Exists(It.IsAny())).Returns(true); - this.mockFileHelper.Setup(m => m.GetStream("path.xml", FileMode.Open, FileAccess.ReadWrite)).Returns(this.mockStream.Object); + /// + /// The read test sequence should read file stream. + /// + [TestMethod] + public void ReadTestSequenceShouldReadFileStream() + { + // Setup + _mockFileHelper.Setup(m => m.Exists(It.IsAny())).Returns(true); + _mockFileHelper.Setup(m => m.GetStream("path.xml", FileMode.Open, FileAccess.ReadWrite)).Returns(_mockStream.Object); - // Call to Read Test Sequence - this.xmlReaderWriter.ReadTestSequence("path.xml"); + // Call to Read Test Sequence + _xmlReaderWriter.ReadTestSequence("path.xml"); - // Verify Call to fileHelper - this.mockFileHelper.Verify(x => x.GetStream("path.xml", FileMode.Open, FileAccess.ReadWrite)); + // Verify Call to fileHelper + _mockFileHelper.Verify(x => x.GetStream("path.xml", FileMode.Open, FileAccess.ReadWrite)); - // Verify Call to stream read - this.mockStream.Verify(x => x.Read(It.IsAny(), It.IsAny(), It.IsAny())); - } + // Verify Call to stream read + _mockStream.Verify(x => x.Read(It.IsAny(), It.IsAny(), It.IsAny())); + } - /// - /// The write test sequence should write file stream. - /// - [TestMethod] - public void WriteTestSequenceShouldWriteFileStream() - { - // Setup - this.mockFileHelper.Setup(m => m.Exists(It.IsAny())).Returns(true); - this.mockFileHelper.Setup(m => m.GetStream("path.xml", FileMode.Create, FileAccess.ReadWrite)).Returns(this.mockStream.Object); - this.mockStream.Setup(x => x.CanWrite).Returns(true); - this.mockStream.Setup(x => x.Write(It.IsAny(), It.IsAny(), It.IsAny())); + /// + /// The write test sequence should write file stream. + /// + [TestMethod] + public void WriteTestSequenceShouldWriteFileStream() + { + // Setup + _mockFileHelper.Setup(m => m.Exists(It.IsAny())).Returns(true); + _mockFileHelper.Setup(m => m.GetStream("path.xml", FileMode.Create, FileAccess.ReadWrite)).Returns(_mockStream.Object); + _mockStream.Setup(x => x.CanWrite).Returns(true); + _mockStream.Setup(x => x.Write(It.IsAny(), It.IsAny(), It.IsAny())); - this.xmlReaderWriter.WriteTestSequence(this.testCaseList, this.testObjectDictionary, "path"); + _xmlReaderWriter.WriteTestSequence(_testCaseList, _testObjectDictionary, "path"); - // Verify Call to fileHelper - this.mockFileHelper.Verify(x => x.GetStream("path.xml", FileMode.Create, FileAccess.ReadWrite)); + // Verify Call to fileHelper + _mockFileHelper.Verify(x => x.GetStream("path.xml", FileMode.Create, FileAccess.ReadWrite)); - // Verify Call to stream write - this.mockStream.Verify(x => x.Write(It.IsAny(), It.IsAny(), It.IsAny())); - } + // Verify Call to stream write + _mockStream.Verify(x => x.Write(It.IsAny(), It.IsAny(), It.IsAny())); + } - /// - /// Verify Write and Read test sequence to check file contents if test completed is false. - /// - [TestMethod] - public void WriteTestSequenceShouldWriteCorrectFileContentsIfTestCompletedIsFalse() + /// + /// Verify Write and Read test sequence to check file contents if test completed is false. + /// + [TestMethod] + public void WriteTestSequenceShouldWriteCorrectFileContentsIfTestCompletedIsFalse() + { + var xmlReaderWriter = new XmlReaderWriter(); + var testObject = new BlameTestObject(new TestCase("Abc.UnitTest1", new Uri("test:/abc"), "Abc.dll")); + testObject.DisplayName = "UnitTest1"; + var testSequence = new List { - var xmlReaderWriter = new XmlReaderWriter(); - var testObject = new BlameTestObject(new TestCase("Abc.UnitTest1", new Uri("test:/abc"), "Abc.dll")); - testObject.DisplayName = "UnitTest1"; - var testSequence = new List - { - testObject.Id - }; - var testObjectDictionary = new Dictionary - { - { testObject.Id, testObject } - }; - - var filePath = xmlReaderWriter.WriteTestSequence(testSequence, testObjectDictionary, Path.GetTempPath()); - var testCaseList = xmlReaderWriter.ReadTestSequence(filePath); - File.Delete(filePath); - - Assert.AreEqual("Abc.UnitTest1", testCaseList.First().FullyQualifiedName); - Assert.AreEqual("UnitTest1", testCaseList.First().DisplayName); - Assert.AreEqual("Abc.dll", testCaseList.First().Source); - Assert.IsFalse(testCaseList.First().IsCompleted); - } + testObject.Id + }; + var testObjectDictionary = new Dictionary + { + { testObject.Id, testObject } + }; - /// - /// Verify Write and Read test sequence to check file contents if test completed is true. - /// - [TestMethod] - public void WriteTestSequenceShouldWriteCorrectFileContentsIfTestCompletedIsTrue() + var filePath = xmlReaderWriter.WriteTestSequence(testSequence, testObjectDictionary, Path.GetTempPath()); + var testCaseList = xmlReaderWriter.ReadTestSequence(filePath); + File.Delete(filePath); + + Assert.AreEqual("Abc.UnitTest1", testCaseList.First().FullyQualifiedName); + Assert.AreEqual("UnitTest1", testCaseList.First().DisplayName); + Assert.AreEqual("Abc.dll", testCaseList.First().Source); + Assert.IsFalse(testCaseList.First().IsCompleted); + } + + /// + /// Verify Write and Read test sequence to check file contents if test completed is true. + /// + [TestMethod] + public void WriteTestSequenceShouldWriteCorrectFileContentsIfTestCompletedIsTrue() + { + var xmlReaderWriter = new XmlReaderWriter(); + var testObject = new BlameTestObject(new TestCase("Abc.UnitTest1", new Uri("test:/abc"), "Abc.dll")); + testObject.DisplayName = "UnitTest1"; + var testSequence = new List { - var xmlReaderWriter = new XmlReaderWriter(); - var testObject = new BlameTestObject(new TestCase("Abc.UnitTest1", new Uri("test:/abc"), "Abc.dll")); - testObject.DisplayName = "UnitTest1"; - var testSequence = new List - { - testObject.Id - }; - var testObjectDictionary = new Dictionary - { - { testObject.Id, testObject } - }; - - testObjectDictionary[testObject.Id].IsCompleted = true; - var filePath = xmlReaderWriter.WriteTestSequence(testSequence, testObjectDictionary, Path.GetTempPath()); - var testCaseList = xmlReaderWriter.ReadTestSequence(filePath); - File.Delete(filePath); - - Assert.AreEqual("Abc.UnitTest1", testCaseList.First().FullyQualifiedName); - Assert.AreEqual("UnitTest1", testCaseList.First().DisplayName); - Assert.AreEqual("Abc.dll", testCaseList.First().Source); - Assert.IsTrue(testCaseList.First().IsCompleted); - } + testObject.Id + }; + var testObjectDictionary = new Dictionary + { + { testObject.Id, testObject } + }; + + testObjectDictionary[testObject.Id].IsCompleted = true; + var filePath = xmlReaderWriter.WriteTestSequence(testSequence, testObjectDictionary, Path.GetTempPath()); + var testCaseList = xmlReaderWriter.ReadTestSequence(filePath); + File.Delete(filePath); + + Assert.AreEqual("Abc.UnitTest1", testCaseList.First().FullyQualifiedName); + Assert.AreEqual("UnitTest1", testCaseList.First().DisplayName); + Assert.AreEqual("Abc.dll", testCaseList.First().Source); + Assert.IsTrue(testCaseList.First().IsCompleted); + } + /// + /// The testable xml reader writer. + /// + internal class TestableXmlReaderWriter : XmlReaderWriter + { /// - /// The testable xml reader writer. + /// Initializes a new instance of the class. /// - internal class TestableXmlReaderWriter : XmlReaderWriter + /// + /// The file helper. + /// + internal TestableXmlReaderWriter(IFileHelper fileHelper) + : base(fileHelper) { - /// - /// Initializes a new instance of the class. - /// - /// - /// The file helper. - /// - internal TestableXmlReaderWriter(IFileHelper fileHelper) - : base(fileHelper) - { - } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests/HtmlLoggerTests.cs b/test/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests/HtmlLoggerTests.cs index 63976c48f2..cfd3fca152 100644 --- a/test/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests/HtmlLoggerTests.cs +++ b/test/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests/HtmlLoggerTests.cs @@ -1,597 +1,594 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests +namespace Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests; + +using System; +using System.Collections.Generic; +using System.IO; +using VisualStudio.TestTools.UnitTesting; +using Moq; +using ObjectModel = VisualStudio.TestPlatform.ObjectModel; +using VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger; +using HtmlLoggerConstants = VisualStudio.TestPlatform.Extensions.HtmlLogger.Constants; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using HtmlLogger = VisualStudio.TestPlatform.Extensions.HtmlLogger; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using System.Linq; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using System.Runtime.Serialization; +using Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger.ObjectModel; + +[TestClass] +public class HtmlLoggerTests { - using System; - using System.Collections.Generic; - using System.IO; - using VisualStudio.TestTools.UnitTesting; - using Moq; - using ObjectModel = VisualStudio.TestPlatform.ObjectModel; - using VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger; - using HtmlLoggerConstants = VisualStudio.TestPlatform.Extensions.HtmlLogger.Constants; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using HtmlLogger = VisualStudio.TestPlatform.Extensions.HtmlLogger; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using System.Runtime.Serialization; - using Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger.ObjectModel; - - [TestClass] - public class HtmlLoggerTests - { - private Mock events; - private HtmlLogger.HtmlLogger htmlLogger; - private Dictionary parameters; - private static readonly string DefaultTestRunDirectory = Path.GetTempPath(); - private static readonly string DefaultLogFileNameParameterValue = "logfilevalue.html"; - private Mock mockFileHelper; - private Mock mockXmlSerializer; - private Mock mockHtmlTransformer; - - [TestInitialize] - public void TestInitialize() - { - this.events = new Mock(); - this.mockFileHelper = new Mock(); - this.mockHtmlTransformer = new Mock(); - this.mockXmlSerializer = new Mock(); - this.htmlLogger = new HtmlLogger.HtmlLogger(this.mockFileHelper.Object, this.mockHtmlTransformer.Object, this.mockXmlSerializer.Object); - this.parameters = new Dictionary(2) - { - [DefaultLoggerParameterNames.TestRunDirectory] = HtmlLoggerTests.DefaultTestRunDirectory, - [HtmlLoggerConstants.LogFileNameKey] = HtmlLoggerTests.DefaultLogFileNameParameterValue - }; - this.htmlLogger.Initialize(this.events.Object, this.parameters); - } + private Mock _events; + private HtmlLogger.HtmlLogger _htmlLogger; + private Dictionary _parameters; + private static readonly string DefaultTestRunDirectory = Path.GetTempPath(); + private static readonly string DefaultLogFileNameParameterValue = "logfilevalue.html"; + private Mock _mockFileHelper; + private Mock _mockXmlSerializer; + private Mock _mockHtmlTransformer; + + [TestInitialize] + public void TestInitialize() + { + _events = new Mock(); + _mockFileHelper = new Mock(); + _mockHtmlTransformer = new Mock(); + _mockXmlSerializer = new Mock(); + _htmlLogger = new HtmlLogger.HtmlLogger(_mockFileHelper.Object, _mockHtmlTransformer.Object, _mockXmlSerializer.Object); + _parameters = new Dictionary(2) + { + [DefaultLoggerParameterNames.TestRunDirectory] = DefaultTestRunDirectory, + [HtmlLoggerConstants.LogFileNameKey] = DefaultLogFileNameParameterValue + }; + _htmlLogger.Initialize(_events.Object, _parameters); + } - #region Initialize Method + #region Initialize Method - [TestMethod] - public void InitializeShouldThrowExceptionIfEventsIsNull() - { - Assert.ThrowsException( - () => - { - this.htmlLogger.Initialize(null, this.parameters); - }); - } - - [TestMethod] - public void InitializeShouldInitializeAllProperties() - { - const string testResultDir = @"C:\Code\abc"; - var events = new Mock(); + [TestMethod] + public void InitializeShouldThrowExceptionIfEventsIsNull() + { + Assert.ThrowsException( + () => _htmlLogger.Initialize(null, _parameters)); + } - this.htmlLogger.Initialize(events.Object, testResultDir); + [TestMethod] + public void InitializeShouldInitializeAllProperties() + { + const string testResultDir = @"C:\Code\abc"; + var events = new Mock(); - Assert.AreEqual(this.htmlLogger.TestResultsDirPath, testResultDir); - Assert.IsNotNull(this.htmlLogger.TestRunDetails); - Assert.IsNotNull(this.htmlLogger.Results); - } + _htmlLogger.Initialize(events.Object, testResultDir); - [TestMethod] - public void InitializeShouldThrowExceptionIfTestRunDirectoryIsEmptyOrNull() - { - Assert.ThrowsException( - () => - { - this.events = new Mock(); - this.parameters[DefaultLoggerParameterNames.TestRunDirectory] = null; - this.htmlLogger.Initialize(events.Object, parameters); - }); - } - - [TestMethod] - public void InitializeShouldThrowExceptionIfParametersAreEmpty() - { - var events = new Mock(); - Assert.ThrowsException(() => this.htmlLogger.Initialize(events.Object, new Dictionary())); - } + Assert.AreEqual(_htmlLogger.TestResultsDirPath, testResultDir); + Assert.IsNotNull(_htmlLogger.TestRunDetails); + Assert.IsNotNull(_htmlLogger.Results); + } - [TestMethod] - public void TestMessageHandlerShouldThrowExceptionIfEventArgsIsNull() - { - Assert.ThrowsException(() => + [TestMethod] + public void InitializeShouldThrowExceptionIfTestRunDirectoryIsEmptyOrNull() + { + Assert.ThrowsException( + () => { - this.htmlLogger.TestMessageHandler(new object(), default); + _events = new Mock(); + _parameters[DefaultLoggerParameterNames.TestRunDirectory] = null; + _htmlLogger.Initialize(_events.Object, _parameters); }); - } + } - #endregion + [TestMethod] + public void InitializeShouldThrowExceptionIfParametersAreEmpty() + { + var events = new Mock(); + Assert.ThrowsException(() => _htmlLogger.Initialize(events.Object, new Dictionary())); + } - [TestMethod] - public void TestMessageHandlerShouldAddMessageWhenItIsInformation() - { - const string message = "First message"; - var testRunMessageEventArgs = new TestRunMessageEventArgs(TestMessageLevel.Informational, message); + [TestMethod] + public void TestMessageHandlerShouldThrowExceptionIfEventArgsIsNull() + { + Assert.ThrowsException(() => _htmlLogger.TestMessageHandler(new object(), default)); + } - this.htmlLogger.TestMessageHandler(new object(), testRunMessageEventArgs); + #endregion - var actualMessage = this.htmlLogger.TestRunDetails.RunLevelMessageInformational.First(); - Assert.AreEqual(message, actualMessage); - } + [TestMethod] + public void TestMessageHandlerShouldAddMessageWhenItIsInformation() + { + const string message = "First message"; + var testRunMessageEventArgs = new TestRunMessageEventArgs(TestMessageLevel.Informational, message); - [TestMethod] - public void TestMessageHandlerShouldNotInitializelistForInformationErrorAndWarningMessages() - { - Assert.IsNull(this.htmlLogger.TestRunDetails.RunLevelMessageInformational); - Assert.IsNull(this.htmlLogger.TestRunDetails.RunLevelMessageErrorAndWarning); - } + _htmlLogger.TestMessageHandler(new object(), testRunMessageEventArgs); - [TestMethod] - public void TestCompleteHandlerShouldThrowExceptionIfParametersAreNull() - { - Dictionary parameters = null; - var events = new Mock(); - Assert.ThrowsException(() => this.htmlLogger.Initialize(events.Object, parameters)); - } + var actualMessage = _htmlLogger.TestRunDetails.RunLevelMessageInformational.First(); + Assert.AreEqual(message, actualMessage); + } - [TestMethod] - public void TestMessageHandlerShouldAddMessageInListIfItIsWarningAndError() - { - const string message = "error message"; - const string message2 = "warning message"; + [TestMethod] + public void TestMessageHandlerShouldNotInitializelistForInformationErrorAndWarningMessages() + { + Assert.IsNull(_htmlLogger.TestRunDetails.RunLevelMessageInformational); + Assert.IsNull(_htmlLogger.TestRunDetails.RunLevelMessageErrorAndWarning); + } + + [TestMethod] + public void TestCompleteHandlerShouldThrowExceptionIfParametersAreNull() + { + Dictionary parameters = null; + var events = new Mock(); + Assert.ThrowsException(() => _htmlLogger.Initialize(events.Object, parameters)); + } - var testRunMessageEventArgs = new TestRunMessageEventArgs(TestMessageLevel.Error, message); - this.htmlLogger.TestMessageHandler(new object(), testRunMessageEventArgs); - var testRunMessageEventArgs2 = new TestRunMessageEventArgs(TestMessageLevel.Warning, message2); - this.htmlLogger.TestMessageHandler(new object(), testRunMessageEventArgs2); + [TestMethod] + public void TestMessageHandlerShouldAddMessageInListIfItIsWarningAndError() + { + const string message = "error message"; + const string message2 = "warning message"; - Assert.AreEqual(message, this.htmlLogger.TestRunDetails.RunLevelMessageErrorAndWarning.First()); - Assert.AreEqual(2, this.htmlLogger.TestRunDetails.RunLevelMessageErrorAndWarning.Count); - } + var testRunMessageEventArgs = new TestRunMessageEventArgs(TestMessageLevel.Error, message); + _htmlLogger.TestMessageHandler(new object(), testRunMessageEventArgs); + var testRunMessageEventArgs2 = new TestRunMessageEventArgs(TestMessageLevel.Warning, message2); + _htmlLogger.TestMessageHandler(new object(), testRunMessageEventArgs2); - [TestMethod] - public void TestResultHandlerShouldKeepTrackOfFailedResult() - { - var failTestCase1 = CreateTestCase("Fail1"); + Assert.AreEqual(message, _htmlLogger.TestRunDetails.RunLevelMessageErrorAndWarning.First()); + Assert.AreEqual(2, _htmlLogger.TestRunDetails.RunLevelMessageErrorAndWarning.Count); + } - var failResult1 = new ObjectModel.TestResult(failTestCase1) { Outcome = TestOutcome.Failed }; + [TestMethod] + public void TestResultHandlerShouldKeepTrackOfFailedResult() + { + var failTestCase1 = CreateTestCase("Fail1"); - this.htmlLogger.TestResultHandler(new object(), new Mock(failResult1).Object); + var failResult1 = new ObjectModel.TestResult(failTestCase1) { Outcome = TestOutcome.Failed }; - Assert.AreEqual(1, this.htmlLogger.FailedTests, "Failed Tests"); - } + _htmlLogger.TestResultHandler(new object(), new Mock(failResult1).Object); - [TestMethod] - public void TestResultHandlerShouldKeepTrackOfTotalResult() - { - var passTestCase1 = CreateTestCase("Pass1"); - var passResult1 = new ObjectModel.TestResult(passTestCase1) { Outcome = TestOutcome.Passed }; + Assert.AreEqual(1, _htmlLogger.FailedTests, "Failed Tests"); + } - this.htmlLogger.TestResultHandler(new object(), new Mock(passResult1).Object); + [TestMethod] + public void TestResultHandlerShouldKeepTrackOfTotalResult() + { + var passTestCase1 = CreateTestCase("Pass1"); + var passResult1 = new ObjectModel.TestResult(passTestCase1) { Outcome = TestOutcome.Passed }; - Assert.AreEqual(1, this.htmlLogger.TotalTests, "Total Tests"); - } + _htmlLogger.TestResultHandler(new object(), new Mock(passResult1).Object); - [TestMethod] - public void TestResultHandlerShouldKeepTrackOfPassedResult() - { - var passTestCase2 = CreateTestCase("Pass2"); - var passResult2 = new ObjectModel.TestResult(passTestCase2) { Outcome = TestOutcome.Passed }; + Assert.AreEqual(1, _htmlLogger.TotalTests, "Total Tests"); + } - this.htmlLogger.TestResultHandler(new object(), new Mock(passResult2).Object); + [TestMethod] + public void TestResultHandlerShouldKeepTrackOfPassedResult() + { + var passTestCase2 = CreateTestCase("Pass2"); + var passResult2 = new ObjectModel.TestResult(passTestCase2) { Outcome = TestOutcome.Passed }; - Assert.AreEqual(1, this.htmlLogger.PassedTests, "Passed Tests"); - } + _htmlLogger.TestResultHandler(new object(), new Mock(passResult2).Object); - [TestMethod] - public void TestResultHandlerShouldKeepTrackOfSkippedResult() - { - var skipTestCase1 = CreateTestCase("Skip1"); - var skipResult1 = new ObjectModel.TestResult(skipTestCase1) { Outcome = TestOutcome.Skipped }; + Assert.AreEqual(1, _htmlLogger.PassedTests, "Passed Tests"); + } - this.htmlLogger.TestResultHandler(new object(), new Mock(skipResult1).Object); + [TestMethod] + public void TestResultHandlerShouldKeepTrackOfSkippedResult() + { + var skipTestCase1 = CreateTestCase("Skip1"); + var skipResult1 = new ObjectModel.TestResult(skipTestCase1) { Outcome = TestOutcome.Skipped }; - Assert.AreEqual(1, this.htmlLogger.SkippedTests, "Skipped Tests"); - } + _htmlLogger.TestResultHandler(new object(), new Mock(skipResult1).Object); - [TestMethod] - public void TestResultHandlerShouldSetDisplayNameIfDisplayNameIsNull() + Assert.AreEqual(1, _htmlLogger.SkippedTests, "Skipped Tests"); + } + + [TestMethod] + public void TestResultHandlerShouldSetDisplayNameIfDisplayNameIsNull() + { + //this assert is for checking result display name equals to null + var passTestCase1 = CreateTestCase("Pass1"); + var passTestResultExpected = new ObjectModel.TestResult(passTestCase1) { - //this assert is for checking result display name equals to null - var passTestCase1 = CreateTestCase("Pass1"); - var passTestResultExpected = new ObjectModel.TestResult(passTestCase1) - { - DisplayName = null, - TestCase = { FullyQualifiedName = "abc" } - }; + DisplayName = null, + TestCase = { FullyQualifiedName = "abc" } + }; - this.htmlLogger.TestResultHandler(new object(), new Mock(passTestResultExpected).Object); + _htmlLogger.TestResultHandler(new object(), new Mock(passTestResultExpected).Object); - Assert.AreEqual("abc", this.htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.First().DisplayName); - } + Assert.AreEqual("abc", _htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.First().DisplayName); + } - [TestMethod] - public void TestResultHandlerShouldSetDisplayNameIfDisplayNameIsNotNull() + [TestMethod] + public void TestResultHandlerShouldSetDisplayNameIfDisplayNameIsNotNull() + { + //this assert is for checking result display name not equals to null + var passTestCase1 = CreateTestCase("Pass1"); + var passTestResultExpected = new ObjectModel.TestResult(passTestCase1) { - //this assert is for checking result display name not equals to null - var passTestCase1 = CreateTestCase("Pass1"); - var passTestResultExpected = new ObjectModel.TestResult(passTestCase1) - { - DisplayName = "def", - TestCase = { FullyQualifiedName = "abc" } - }; + DisplayName = "def", + TestCase = { FullyQualifiedName = "abc" } + }; - this.htmlLogger.TestResultHandler(new object(), new Mock(passTestResultExpected).Object); + _htmlLogger.TestResultHandler(new object(), new Mock(passTestResultExpected).Object); - Assert.AreEqual("def", this.htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.Last().DisplayName); - } + Assert.AreEqual("def", _htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.Last().DisplayName); + } - [TestMethod] - public void TestResultHandlerShouldCreateTestResultProperly() - { - var passTestCase = CreateTestCase("Pass1"); - passTestCase.DisplayName = "abc"; - passTestCase.FullyQualifiedName = "fully"; - passTestCase.Source = "abc/def.dll"; - TimeSpan ts1 = new TimeSpan(0, 0, 0, 1, 0); + [TestMethod] + public void TestResultHandlerShouldCreateTestResultProperly() + { + var passTestCase = CreateTestCase("Pass1"); + passTestCase.DisplayName = "abc"; + passTestCase.FullyQualifiedName = "fully"; + passTestCase.Source = "abc/def.dll"; + TimeSpan ts1 = new(0, 0, 0, 1, 0); + + var passTestResultExpected = new ObjectModel.TestResult(passTestCase) + { + DisplayName = "def", + ErrorMessage = "error message", + ErrorStackTrace = "Error stack trace", + Duration = ts1 + }; + + var eventArg = new Mock(passTestResultExpected); + // Act + _htmlLogger.TestResultHandler(new object(), eventArg.Object); + + var result = _htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.First(); + + Assert.AreEqual("def", result.DisplayName); + Assert.AreEqual("error message", result.ErrorMessage); + Assert.AreEqual("Error stack trace", result.ErrorStackTrace); + Assert.AreEqual("fully", result.FullyQualifiedName); + Assert.AreEqual("abc/def.dll", _htmlLogger.TestRunDetails.ResultCollectionList.First().Source); + Assert.AreEqual("1s", result.Duration); + } - var passTestResultExpected = new ObjectModel.TestResult(passTestCase) - { - DisplayName = "def", - ErrorMessage = "error message", - ErrorStackTrace = "Error stack trace", - Duration = ts1 - }; - - var eventArg = new Mock(passTestResultExpected); - // Act - this.htmlLogger.TestResultHandler(new object(), eventArg.Object); - - var result = this.htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.First(); - - Assert.AreEqual("def", result.DisplayName); - Assert.AreEqual("error message", result.ErrorMessage); - Assert.AreEqual("Error stack trace", result.ErrorStackTrace); - Assert.AreEqual("fully", result.FullyQualifiedName); - Assert.AreEqual("abc/def.dll", this.htmlLogger.TestRunDetails.ResultCollectionList.First().Source); - Assert.AreEqual("1s", result.Duration); - } - - [TestMethod] - public void GetFormattedDurationStringShouldGiveCorrectFormat() - { - TimeSpan ts1 = new TimeSpan(0, 0, 0, 0, 1); - Assert.AreEqual("1ms", htmlLogger.GetFormattedDurationString(ts1)); + [TestMethod] + public void GetFormattedDurationStringShouldGiveCorrectFormat() + { + TimeSpan ts1 = new(0, 0, 0, 0, 1); + Assert.AreEqual("1ms", _htmlLogger.GetFormattedDurationString(ts1)); - TimeSpan ts2 = new TimeSpan(0, 0, 0, 1, 0); - Assert.AreEqual("1s", htmlLogger.GetFormattedDurationString(ts2)); + TimeSpan ts2 = new(0, 0, 0, 1, 0); + Assert.AreEqual("1s", _htmlLogger.GetFormattedDurationString(ts2)); - TimeSpan ts3 = new TimeSpan(0, 0, 1, 0, 1); - Assert.AreEqual("1m", htmlLogger.GetFormattedDurationString(ts3)); + TimeSpan ts3 = new(0, 0, 1, 0, 1); + Assert.AreEqual("1m", _htmlLogger.GetFormattedDurationString(ts3)); - TimeSpan ts4 = new TimeSpan(0, 1, 0, 2, 3); - Assert.AreEqual("1h", htmlLogger.GetFormattedDurationString(ts4)); + TimeSpan ts4 = new(0, 1, 0, 2, 3); + Assert.AreEqual("1h", _htmlLogger.GetFormattedDurationString(ts4)); - TimeSpan ts5 = new TimeSpan(0, 1, 2, 3, 4); - Assert.AreEqual("1h 2m", htmlLogger.GetFormattedDurationString(ts5)); + TimeSpan ts5 = new(0, 1, 2, 3, 4); + Assert.AreEqual("1h 2m", _htmlLogger.GetFormattedDurationString(ts5)); - TimeSpan ts6 = new TimeSpan(0, 0, 1, 2, 3); - Assert.AreEqual("1m 2s", htmlLogger.GetFormattedDurationString(ts6)); + TimeSpan ts6 = new(0, 0, 1, 2, 3); + Assert.AreEqual("1m 2s", _htmlLogger.GetFormattedDurationString(ts6)); - TimeSpan ts7 = new TimeSpan(0, 0, 0, 1, 3); - Assert.AreEqual("1s 3ms", htmlLogger.GetFormattedDurationString(ts7)); + TimeSpan ts7 = new(0, 0, 0, 1, 3); + Assert.AreEqual("1s 3ms", _htmlLogger.GetFormattedDurationString(ts7)); - TimeSpan ts8 = new TimeSpan(2); - Assert.AreEqual("< 1ms", htmlLogger.GetFormattedDurationString(ts8)); + TimeSpan ts8 = new(2); + Assert.AreEqual("< 1ms", _htmlLogger.GetFormattedDurationString(ts8)); - TimeSpan ts10 = new TimeSpan(1, 0, 0, 1, 3); - Assert.AreEqual("> 1d", htmlLogger.GetFormattedDurationString(ts10)); + TimeSpan ts10 = new(1, 0, 0, 1, 3); + Assert.AreEqual("> 1d", _htmlLogger.GetFormattedDurationString(ts10)); - TimeSpan ts9 = new TimeSpan(0, 0, 0, 0, 0); - Assert.IsNull(htmlLogger.GetFormattedDurationString(ts9)); - } + TimeSpan ts9 = new(0, 0, 0, 0, 0); + Assert.IsNull(_htmlLogger.GetFormattedDurationString(ts9)); + } - [TestMethod] - public void TestResultHandlerShouldCreateOneTestEntryForEachTestCase() - { - TestCase testCase1 = CreateTestCase("TestCase1"); - TestCase testCase2 = CreateTestCase("TestCase2"); - ObjectModel.TestResult result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; - ObjectModel.TestResult result2 = new ObjectModel.TestResult(testCase2) { Outcome = TestOutcome.Passed }; - Mock resultEventArg1 = new Mock(result1); - Mock resultEventArg2 = new Mock(result2); - - // Act - this.htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); - this.htmlLogger.TestResultHandler(new object(), resultEventArg2.Object); - - Assert.AreEqual(2, this.htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.Count, "TestResultHandler is not creating test result entry for each test case"); - } - - [TestMethod] - public void TestResultHandlerShouldCreateOneTestResultCollectionForOneSource() - { - TestCase testCase1 = CreateTestCase("TestCase1"); - testCase1.Source = "abc.dll"; + [TestMethod] + public void TestResultHandlerShouldCreateOneTestEntryForEachTestCase() + { + TestCase testCase1 = CreateTestCase("TestCase1"); + TestCase testCase2 = CreateTestCase("TestCase2"); + ObjectModel.TestResult result1 = new(testCase1) { Outcome = TestOutcome.Failed }; + ObjectModel.TestResult result2 = new(testCase2) { Outcome = TestOutcome.Passed }; + Mock resultEventArg1 = new(result1); + Mock resultEventArg2 = new(result2); + + // Act + _htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); + _htmlLogger.TestResultHandler(new object(), resultEventArg2.Object); + + Assert.AreEqual(2, _htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.Count, "TestResultHandler is not creating test result entry for each test case"); + } - TestCase testCase2 = CreateTestCase("TestCase2"); - testCase2.Source = "def.dll"; + [TestMethod] + public void TestResultHandlerShouldCreateOneTestResultCollectionForOneSource() + { + TestCase testCase1 = CreateTestCase("TestCase1"); + testCase1.Source = "abc.dll"; - ObjectModel.TestResult result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; - ObjectModel.TestResult result2 = new ObjectModel.TestResult(testCase2) { Outcome = TestOutcome.Passed }; + TestCase testCase2 = CreateTestCase("TestCase2"); + testCase2.Source = "def.dll"; - this.htmlLogger.TestResultHandler(new object(), new Mock(result1).Object); - this.htmlLogger.TestResultHandler(new object(), new Mock(result2).Object); + ObjectModel.TestResult result1 = new(testCase1) { Outcome = TestOutcome.Failed }; + ObjectModel.TestResult result2 = new(testCase2) { Outcome = TestOutcome.Passed }; - Assert.AreEqual(2, this.htmlLogger.TestRunDetails.ResultCollectionList.Count); - Assert.AreEqual("abc.dll", this.htmlLogger.TestRunDetails.ResultCollectionList.First().Source); - Assert.AreEqual("def.dll", this.htmlLogger.TestRunDetails.ResultCollectionList.Last().Source); - } + _htmlLogger.TestResultHandler(new object(), new Mock(result1).Object); + _htmlLogger.TestResultHandler(new object(), new Mock(result2).Object); - [TestMethod] - public void TestResultHandlerShouldAddFailedResultToFailedResultListInTestResultCollection() - { - TestCase testCase1 = CreateTestCase("TestCase1"); - ObjectModel.TestResult result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; + Assert.AreEqual(2, _htmlLogger.TestRunDetails.ResultCollectionList.Count); + Assert.AreEqual("abc.dll", _htmlLogger.TestRunDetails.ResultCollectionList.First().Source); + Assert.AreEqual("def.dll", _htmlLogger.TestRunDetails.ResultCollectionList.Last().Source); + } - this.htmlLogger.TestResultHandler(new object(), new Mock(result1).Object); + [TestMethod] + public void TestResultHandlerShouldAddFailedResultToFailedResultListInTestResultCollection() + { + TestCase testCase1 = CreateTestCase("TestCase1"); + ObjectModel.TestResult result1 = new(testCase1) { Outcome = TestOutcome.Failed }; - Assert.AreEqual(1, this.htmlLogger.TestRunDetails.ResultCollectionList.First().FailedResultList.Count); - } + _htmlLogger.TestResultHandler(new object(), new Mock(result1).Object); - [TestMethod] - public void TestResultHandlerShouldAddHierarchicalResultsForOrderedTest() - { - TestCase testCase1 = CreateTestCase("TestCase1"); - TestCase testCase2 = CreateTestCase("TestCase2"); - TestCase testCase3 = CreateTestCase("TestCase3"); + Assert.AreEqual(1, _htmlLogger.TestRunDetails.ResultCollectionList.First().FailedResultList.Count); + } - Guid parentExecutionId = Guid.NewGuid(); + [TestMethod] + public void TestResultHandlerShouldAddHierarchicalResultsForOrderedTest() + { + TestCase testCase1 = CreateTestCase("TestCase1"); + TestCase testCase2 = CreateTestCase("TestCase2"); + TestCase testCase3 = CreateTestCase("TestCase3"); - ObjectModel.TestResult result1 = new ObjectModel.TestResult(testCase1); - result1.SetPropertyValue(HtmlLoggerConstants.ExecutionIdProperty, parentExecutionId); - result1.SetPropertyValue(HtmlLoggerConstants.TestTypeProperty, HtmlLoggerConstants.OrderedTestTypeGuid); + Guid parentExecutionId = Guid.NewGuid(); - this.htmlLogger.TestResultHandler(new object(), new Mock(result1).Object); + ObjectModel.TestResult result1 = new(testCase1); + result1.SetPropertyValue(HtmlLoggerConstants.ExecutionIdProperty, parentExecutionId); + result1.SetPropertyValue(HtmlLoggerConstants.TestTypeProperty, HtmlLoggerConstants.OrderedTestTypeGuid); - Assert.AreEqual(1, this.htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.Count, "test handler is adding parent result correctly"); - Assert.IsNull(this.htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.First().InnerTestResults, "test handler is adding child result correctly"); + _htmlLogger.TestResultHandler(new object(), new Mock(result1).Object); - var result2 = new ObjectModel.TestResult(testCase2); - result2.SetPropertyValue(HtmlLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); - result2.SetPropertyValue(HtmlLoggerConstants.ParentExecIdProperty, parentExecutionId); + Assert.AreEqual(1, _htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.Count, "test handler is adding parent result correctly"); + Assert.IsNull(_htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.First().InnerTestResults, "test handler is adding child result correctly"); - var result3 = new ObjectModel.TestResult(testCase3) { Outcome = TestOutcome.Failed }; - result3.SetPropertyValue(HtmlLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); - result3.SetPropertyValue(HtmlLoggerConstants.ParentExecIdProperty, parentExecutionId); + var result2 = new ObjectModel.TestResult(testCase2); + result2.SetPropertyValue(HtmlLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); + result2.SetPropertyValue(HtmlLoggerConstants.ParentExecIdProperty, parentExecutionId); - this.htmlLogger.TestResultHandler(new object(), new Mock(result2).Object); - this.htmlLogger.TestResultHandler(new object(), new Mock(result3).Object); + var result3 = new ObjectModel.TestResult(testCase3) { Outcome = TestOutcome.Failed }; + result3.SetPropertyValue(HtmlLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); + result3.SetPropertyValue(HtmlLoggerConstants.ParentExecIdProperty, parentExecutionId); - Assert.AreEqual(1, this.htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.Count, "test handler is adding parent result correctly"); - Assert.AreEqual(2, this.htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.First().InnerTestResults.Count, "test handler is adding child result correctly"); - } + _htmlLogger.TestResultHandler(new object(), new Mock(result2).Object); + _htmlLogger.TestResultHandler(new object(), new Mock(result3).Object); - [TestMethod] - public void TestCompleteHandlerShouldKeepTackOfSummary() - { - TestCase passTestCase1 = CreateTestCase("Pass1"); - TestCase passTestCase2 = CreateTestCase("Pass2"); - TestCase failTestCase1 = CreateTestCase("Fail1"); - TestCase skipTestCase1 = CreateTestCase("Skip1"); - var passResult1 = new ObjectModel.TestResult(passTestCase1) { Outcome = TestOutcome.Passed }; - var passResult2 = new ObjectModel.TestResult(passTestCase2) { Outcome = TestOutcome.Passed }; - var failResult1 = new ObjectModel.TestResult(failTestCase1) { Outcome = TestOutcome.Failed }; - var skipResult1 = new ObjectModel.TestResult(skipTestCase1) { Outcome = TestOutcome.Skipped }; - - this.htmlLogger.TestResultHandler(new object(), new Mock(passResult1).Object); - this.htmlLogger.TestResultHandler(new object(), new Mock(passResult2).Object); - this.htmlLogger.TestResultHandler(new object(), new Mock(failResult1).Object); - this.htmlLogger.TestResultHandler(new object(), new Mock(skipResult1).Object); - - this.mockFileHelper.Setup(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite)).Callback((x, y, z) => - { - }).Returns(new Mock().Object); - - this.htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); - - Assert.AreEqual(4, this.htmlLogger.TestRunDetails.Summary.TotalTests, "summary should keep track of total tests"); - Assert.AreEqual(1, this.htmlLogger.TestRunDetails.Summary.FailedTests, "summary should keep track of failed tests"); - Assert.AreEqual(2, this.htmlLogger.TestRunDetails.Summary.PassedTests, "summary should keep track of passed tests"); - Assert.AreEqual(1, this.htmlLogger.TestRunDetails.Summary.SkippedTests, "summary should keep track of passed tests"); - Assert.AreEqual(50, this.htmlLogger.TestRunDetails.Summary.PassPercentage, "summary should keep track of passed tests"); - Assert.IsNull(this.htmlLogger.TestRunDetails.Summary.TotalRunTime, "summary should keep track of passed tests"); - } - - [TestMethod] - public void TestCompleteHandlerShouldCreateCustumHtmlFileNamewithLogFileNameKey() - { - var parameters = new Dictionary(); - parameters[HtmlLoggerConstants.LogFileNameKey] = null; - parameters[DefaultLoggerParameterNames.TestRunDirectory] = "dsa"; - - var testCase1 = CreateTestCase("TestCase1"); - var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; - var resultEventArg1 = new Mock(result1); - this.htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); - - this.htmlLogger.Initialize(new Mock().Object, parameters); - this.htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); - Assert.IsTrue(this.htmlLogger.HtmlFilePath.Contains("TestResult")); - } - - [TestMethod] - public void TestCompleteHandlerShouldCreateCustumHtmlFileNameWithLogPrefix() + Assert.AreEqual(1, _htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.Count, "test handler is adding parent result correctly"); + Assert.AreEqual(2, _htmlLogger.TestRunDetails.ResultCollectionList.First().ResultList.First().InnerTestResults.Count, "test handler is adding child result correctly"); + } + + [TestMethod] + public void TestCompleteHandlerShouldKeepTackOfSummary() + { + TestCase passTestCase1 = CreateTestCase("Pass1"); + TestCase passTestCase2 = CreateTestCase("Pass2"); + TestCase failTestCase1 = CreateTestCase("Fail1"); + TestCase skipTestCase1 = CreateTestCase("Skip1"); + var passResult1 = new ObjectModel.TestResult(passTestCase1) { Outcome = TestOutcome.Passed }; + var passResult2 = new ObjectModel.TestResult(passTestCase2) { Outcome = TestOutcome.Passed }; + var failResult1 = new ObjectModel.TestResult(failTestCase1) { Outcome = TestOutcome.Failed }; + var skipResult1 = new ObjectModel.TestResult(skipTestCase1) { Outcome = TestOutcome.Skipped }; + + _htmlLogger.TestResultHandler(new object(), new Mock(passResult1).Object); + _htmlLogger.TestResultHandler(new object(), new Mock(passResult2).Object); + _htmlLogger.TestResultHandler(new object(), new Mock(failResult1).Object); + _htmlLogger.TestResultHandler(new object(), new Mock(skipResult1).Object); + + _mockFileHelper.Setup(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite)).Callback((x, y, z) => + { + }).Returns(new Mock().Object); + + _htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); + + Assert.AreEqual(4, _htmlLogger.TestRunDetails.Summary.TotalTests, "summary should keep track of total tests"); + Assert.AreEqual(1, _htmlLogger.TestRunDetails.Summary.FailedTests, "summary should keep track of failed tests"); + Assert.AreEqual(2, _htmlLogger.TestRunDetails.Summary.PassedTests, "summary should keep track of passed tests"); + Assert.AreEqual(1, _htmlLogger.TestRunDetails.Summary.SkippedTests, "summary should keep track of passed tests"); + Assert.AreEqual(50, _htmlLogger.TestRunDetails.Summary.PassPercentage, "summary should keep track of passed tests"); + Assert.IsNull(_htmlLogger.TestRunDetails.Summary.TotalRunTime, "summary should keep track of passed tests"); + } + + [TestMethod] + public void TestCompleteHandlerShouldCreateCustumHtmlFileNamewithLogFileNameKey() + { + var parameters = new Dictionary { - var parameters = new Dictionary(); - parameters[HtmlLoggerConstants.LogFilePrefixKey] = "sample"; - parameters[DefaultLoggerParameterNames.TestRunDirectory] = "dsa"; - parameters[DefaultLoggerParameterNames.TargetFramework] = ".NETFramework,Version=4.5.1"; - - var testCase1 = CreateTestCase("TestCase1"); - var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; - var resultEventArg1 = new Mock(result1); - this.htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); - - this.htmlLogger.Initialize(new Mock().Object, parameters); - this.htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); - Assert.IsFalse(this.htmlLogger.HtmlFilePath.Contains("__")); - } - - [TestMethod] - public void TestCompleteHandlerShouldCreateCustumHtmlFileNameWithLogPrefixIfTargetFrameworkIsNull() + [HtmlLoggerConstants.LogFileNameKey] = null, + [DefaultLoggerParameterNames.TestRunDirectory] = "dsa" + }; + + var testCase1 = CreateTestCase("TestCase1"); + var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; + var resultEventArg1 = new Mock(result1); + _htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); + + _htmlLogger.Initialize(new Mock().Object, parameters); + _htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); + Assert.IsTrue(_htmlLogger.HtmlFilePath.Contains("TestResult")); + } + + [TestMethod] + public void TestCompleteHandlerShouldCreateCustumHtmlFileNameWithLogPrefix() + { + var parameters = new Dictionary { - var parameters = new Dictionary(); - parameters[HtmlLoggerConstants.LogFilePrefixKey] = "sample"; - parameters[DefaultLoggerParameterNames.TestRunDirectory] = "dsa"; - parameters[DefaultLoggerParameterNames.TargetFramework] = ".NETFramework,Version=4.5.1"; - - var testCase1 = CreateTestCase("TestCase1"); - var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; - var resultEventArg1 = new Mock(result1); - this.htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); - - this.htmlLogger.Initialize(new Mock().Object, parameters); - this.htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); - Assert.IsTrue(this.htmlLogger.HtmlFilePath.Contains("sample_net451")); - } - - [TestMethod] - public void TestCompleteHandlerShouldCreateCustumHtmlFileNameWithLogPrefixNull() + [HtmlLoggerConstants.LogFilePrefixKey] = "sample", + [DefaultLoggerParameterNames.TestRunDirectory] = "dsa", + [DefaultLoggerParameterNames.TargetFramework] = ".NETFramework,Version=4.5.1" + }; + + var testCase1 = CreateTestCase("TestCase1"); + var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; + var resultEventArg1 = new Mock(result1); + _htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); + + _htmlLogger.Initialize(new Mock().Object, parameters); + _htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); + Assert.IsFalse(_htmlLogger.HtmlFilePath.Contains("__")); + } + + [TestMethod] + public void TestCompleteHandlerShouldCreateCustumHtmlFileNameWithLogPrefixIfTargetFrameworkIsNull() + { + var parameters = new Dictionary { - var parameters = new Dictionary(); - parameters[HtmlLoggerConstants.LogFilePrefixKey] = null; - parameters[DefaultLoggerParameterNames.TestRunDirectory] = "dsa"; - parameters[DefaultLoggerParameterNames.TargetFramework] = ".NETFramework,Version=4.5.1"; + [HtmlLoggerConstants.LogFilePrefixKey] = "sample", + [DefaultLoggerParameterNames.TestRunDirectory] = "dsa", + [DefaultLoggerParameterNames.TargetFramework] = ".NETFramework,Version=4.5.1" + }; - var testCase1 = CreateTestCase("TestCase1"); - var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; - var resultEventArg1 = new Mock(result1); + var testCase1 = CreateTestCase("TestCase1"); + var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; + var resultEventArg1 = new Mock(result1); + _htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); - this.mockFileHelper.Setup(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite)).Callback((x, y, z) => - { - }).Returns(new Mock().Object); + _htmlLogger.Initialize(new Mock().Object, parameters); + _htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); + Assert.IsTrue(_htmlLogger.HtmlFilePath.Contains("sample_net451")); + } - this.htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); - this.htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); + [TestMethod] + public void TestCompleteHandlerShouldCreateCustumHtmlFileNameWithLogPrefixNull() + { + var parameters = new Dictionary + { + [HtmlLoggerConstants.LogFilePrefixKey] = null, + [DefaultLoggerParameterNames.TestRunDirectory] = "dsa", + [DefaultLoggerParameterNames.TargetFramework] = ".NETFramework,Version=4.5.1" + }; - this.mockFileHelper.Verify(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite), Times.Once); - } + var testCase1 = CreateTestCase("TestCase1"); + var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; + var resultEventArg1 = new Mock(result1); - [TestMethod] - public void TestCompleteHandlerShouldThrowExceptionWithLogPrefixIfTargetFrameworkKeyIsNotPresent() + _mockFileHelper.Setup(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite)).Callback((x, y, z) => { - var parameters = new Dictionary(); - parameters[HtmlLoggerConstants.LogFilePrefixKey] = "sample.html"; - parameters[DefaultLoggerParameterNames.TestRunDirectory] = "dsa"; - var testCase1 = CreateTestCase("TestCase1"); - var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; - var resultEventArg1 = new Mock(result1); - this.htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); + }).Returns(new Mock().Object); - this.htmlLogger.Initialize(new Mock().Object, parameters); + _htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); + _htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); - Assert.ThrowsException(() => this.htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero))); - } + _mockFileHelper.Verify(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite), Times.Once); + } - [TestMethod] - public void IntializeShouldThrowExceptionIfBothPrefixAndNameProvided() + [TestMethod] + public void TestCompleteHandlerShouldThrowExceptionWithLogPrefixIfTargetFrameworkKeyIsNotPresent() + { + var parameters = new Dictionary { - this.parameters[HtmlLoggerConstants.LogFileNameKey] = "results.html"; - var trxPrefix = Path.Combine(Path.GetTempPath(), "results"); - this.parameters[HtmlLoggerConstants.LogFilePrefixKey] = "HtmlPrefix"; - this.parameters[DefaultLoggerParameterNames.TargetFramework] = ".NETFramework,Version=4.5.1"; + [HtmlLoggerConstants.LogFilePrefixKey] = "sample.html", + [DefaultLoggerParameterNames.TestRunDirectory] = "dsa" + }; + var testCase1 = CreateTestCase("TestCase1"); + var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; + var resultEventArg1 = new Mock(result1); + _htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); - Assert.ThrowsException(() => this.htmlLogger.Initialize(events.Object, this.parameters)); - } + _htmlLogger.Initialize(new Mock().Object, parameters); - [TestMethod] - public void TestCompleteHandlerShouldCreateFileCorrectly() - { - var testCase1 = CreateTestCase("TestCase1"); - var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; - var resultEventArg1 = new Mock(result1); + Assert.ThrowsException(() => _htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero))); + } - this.mockFileHelper.Setup(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite)).Callback((x, y, z) => - { - }).Returns(new Mock().Object); + [TestMethod] + public void IntializeShouldThrowExceptionIfBothPrefixAndNameProvided() + { + _parameters[HtmlLoggerConstants.LogFileNameKey] = "results.html"; + var trxPrefix = Path.Combine(Path.GetTempPath(), "results"); + _parameters[HtmlLoggerConstants.LogFilePrefixKey] = "HtmlPrefix"; + _parameters[DefaultLoggerParameterNames.TargetFramework] = ".NETFramework,Version=4.5.1"; - this.htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); - this.htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); + Assert.ThrowsException(() => _htmlLogger.Initialize(_events.Object, _parameters)); + } - this.mockFileHelper.Verify(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite), Times.Once); - } + [TestMethod] + public void TestCompleteHandlerShouldCreateFileCorrectly() + { + var testCase1 = CreateTestCase("TestCase1"); + var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; + var resultEventArg1 = new Mock(result1); - [TestMethod] - public void TestCompleteHandlerShouldDeleteFileCorrectly() + _mockFileHelper.Setup(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite)).Callback((x, y, z) => { - var testCase1 = CreateTestCase("TestCase1"); - var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; - var resultEventArg1 = new Mock(result1); + }).Returns(new Mock().Object); - this.mockFileHelper.Setup(x => x.Delete(It.IsAny())).Callback((x) => - { - }); + _htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); + _htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); - this.htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); - this.htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); + _mockFileHelper.Verify(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite), Times.Once); + } - this.mockFileHelper.Verify(x => x.Delete(It.IsAny()), Times.Once); - } + [TestMethod] + public void TestCompleteHandlerShouldDeleteFileCorrectly() + { + var testCase1 = CreateTestCase("TestCase1"); + var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; + var resultEventArg1 = new Mock(result1); - [TestMethod] - public void TestCompleteHandlerShouldCallHtmlTransformerCorrectly() + _mockFileHelper.Setup(x => x.Delete(It.IsAny())).Callback((x) => { - var testCase1 = CreateTestCase("TestCase1"); - var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; - var resultEventArg1 = new Mock(result1); + }); - this.mockFileHelper.Setup(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite)).Callback((x, y, z) => - { - }).Returns(new Mock().Object); + _htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); + _htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); - this.htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); - this.htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); + _mockFileHelper.Verify(x => x.Delete(It.IsAny()), Times.Once); + } - this.mockHtmlTransformer.Verify(x => x.Transform(It.IsAny(), It.IsAny()), Times.Once); - } + [TestMethod] + public void TestCompleteHandlerShouldCallHtmlTransformerCorrectly() + { + var testCase1 = CreateTestCase("TestCase1"); + var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; + var resultEventArg1 = new Mock(result1); - [TestMethod] - public void TestCompleteHandlerShouldWriteToXmlSerializerCorrectly() - { - var testCase1 = CreateTestCase("TestCase1") ?? throw new ArgumentNullException($"CreateTestCase(\"TestCase1\")"); - var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; - var resultEventArg1 = new Mock(result1); - this.mockFileHelper.Setup(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite)).Callback((x, y, z) => - { - }).Returns(new Mock().Object); - - this.htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); - this.htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); - - this.mockXmlSerializer.Verify(x => x.WriteObject(It.IsAny(), It.IsAny()), Times.Once); - Assert.IsTrue(htmlLogger.XmlFilePath.Contains(".xml")); - Assert.IsTrue(htmlLogger.HtmlFilePath.Contains(".html")); - } - - [TestMethod] - public void TestCompleteHandlerShouldNotDivideByZeroWhenThereAre0TestResults() + _mockFileHelper.Setup(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite)).Callback((x, y, z) => { - this.mockFileHelper.Setup(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite)).Callback((x, y, z) => - { - }).Returns(new Mock().Object); + }).Returns(new Mock().Object); - this.htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); + _htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); + _htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); - Assert.AreEqual(0, this.htmlLogger.TestRunDetails.Summary.TotalTests); - Assert.AreEqual(0, this.htmlLogger.TestRunDetails.Summary.PassPercentage); - } + _mockHtmlTransformer.Verify(x => x.Transform(It.IsAny(), It.IsAny()), Times.Once); + } - private static TestCase CreateTestCase(string testCaseName) + [TestMethod] + public void TestCompleteHandlerShouldWriteToXmlSerializerCorrectly() + { + var testCase1 = CreateTestCase("TestCase1") ?? throw new ArgumentNullException($"CreateTestCase(\"TestCase1\")"); + var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; + var resultEventArg1 = new Mock(result1); + _mockFileHelper.Setup(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite)).Callback((x, y, z) => { - return new TestCase(testCaseName, new Uri("some://uri"), "DummySourceFileName"); - } - } -} + }).Returns(new Mock().Object); + _htmlLogger.TestResultHandler(new object(), resultEventArg1.Object); + _htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); + _mockXmlSerializer.Verify(x => x.WriteObject(It.IsAny(), It.IsAny()), Times.Once); + Assert.IsTrue(_htmlLogger.XmlFilePath.Contains(".xml")); + Assert.IsTrue(_htmlLogger.HtmlFilePath.Contains(".html")); + } + [TestMethod] + public void TestCompleteHandlerShouldNotDivideByZeroWhenThereAre0TestResults() + { + _mockFileHelper.Setup(x => x.GetStream(It.IsAny(), FileMode.Create, FileAccess.ReadWrite)).Callback((x, y, z) => + { + }).Returns(new Mock().Object); + _htmlLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); + Assert.AreEqual(0, _htmlLogger.TestRunDetails.Summary.TotalTests); + Assert.AreEqual(0, _htmlLogger.TestRunDetails.Summary.PassPercentage); + } + private static TestCase CreateTestCase(string testCaseName) + { + return new TestCase(testCaseName, new Uri("some://uri"), "DummySourceFileName"); + } +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests/Program.cs b/test/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests/Program.cs index a67797b97c..9210c4d973 100644 --- a/test/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests/Program.cs +++ b/test/Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests/Program.cs @@ -1,9 +1,11 @@ -namespace Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests; + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/Program.cs b/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/Program.cs index 7642a15003..313fa60ef0 100644 --- a/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/Program.cs +++ b/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/Program.cs @@ -1,11 +1,11 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests +namespace Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests; + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/TrxLoggerTests.cs b/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/TrxLoggerTests.cs index 360eaaf83d..85b027ab70 100644 --- a/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/TrxLoggerTests.cs +++ b/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/TrxLoggerTests.cs @@ -2,987 +2,977 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests +namespace Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests; + +using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; +using Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using VisualStudio.TestTools.UnitTesting; +using Moq; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Xml; +using System.Xml.Linq; +using VisualStudio.TestPlatform.ObjectModel; +using VisualStudio.TestPlatform.ObjectModel.Client; +using VisualStudio.TestPlatform.ObjectModel.Logging; +using ObjectModel = VisualStudio.TestPlatform.ObjectModel; +using TrxLoggerConstants = TrxLogger.Utility.Constants; +using TrxLoggerObjectModel = ObjectModel; +using TrxLoggerResources = VisualStudio.TestPlatform.Extensions.TrxLogger.Resources.TrxResource; + +[TestClass] +public class TrxLoggerTests { - using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; - using Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Runtime.CompilerServices; - using System.Xml; - using System.Xml.Linq; - using VisualStudio.TestPlatform.ObjectModel; - using VisualStudio.TestPlatform.ObjectModel.Client; - using VisualStudio.TestPlatform.ObjectModel.Logging; - using ObjectModel = Microsoft.VisualStudio.TestPlatform.ObjectModel; - using TrxLoggerConstants = Microsoft.TestPlatform.Extensions.TrxLogger.Utility.Constants; - using TrxLoggerObjectModel = Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel; - using TrxLoggerResources = Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.Resources.TrxResource; - - [TestClass] - public class TrxLoggerTests - { - private Mock events; - private TestableTrxLogger testableTrxLogger; - private Dictionary parameters; - private static string DefaultTestRunDirectory = Path.GetTempPath(); - private static string DefaultLogFileNameParameterValue = "logfilevalue.trx"; - private const string DefaultLogFilePrefixParameterValue = "log_prefix"; - - private const int MultipleLoggerInstanceCount = 2; - - [TestInitialize] - public void Initialize() - { - this.events = new Mock(); - - this.testableTrxLogger = new TestableTrxLogger(); - this.parameters = new Dictionary(2); - this.parameters[DefaultLoggerParameterNames.TestRunDirectory] = TrxLoggerTests.DefaultTestRunDirectory; - this.parameters[TrxLoggerConstants.LogFileNameKey] = TrxLoggerTests.DefaultLogFileNameParameterValue; - this.testableTrxLogger.Initialize(this.events.Object, this.parameters); - } + private Mock _events; + private TestableTrxLogger _testableTrxLogger; + private Dictionary _parameters; + private static readonly string DefaultTestRunDirectory = Path.GetTempPath(); + private static readonly string DefaultLogFileNameParameterValue = "logfilevalue.trx"; + private const string DefaultLogFilePrefixParameterValue = "log_prefix"; - [TestCleanup] - public void Cleanup() - { - if (!string.IsNullOrEmpty(this.testableTrxLogger?.trxFile) && File.Exists(this.testableTrxLogger.trxFile)) - { - File.Delete(this.testableTrxLogger.trxFile); - } - } + private const int MultipleLoggerInstanceCount = 2; - [TestMethod] - public void InitializeShouldThrowExceptionIfEventsIsNull() - { - Assert.ThrowsException( - () => - { - this.testableTrxLogger.Initialize(null, this.parameters); - }); - } + [TestInitialize] + public void Initialize() + { + _events = new Mock(); - [TestMethod] - public void InitializeShouldNotThrowExceptionIfEventsIsNotNull() + _testableTrxLogger = new TestableTrxLogger(); + _parameters = new Dictionary(2) { - var events = new Mock(); - this.testableTrxLogger.Initialize(events.Object, this.parameters); - } + [DefaultLoggerParameterNames.TestRunDirectory] = DefaultTestRunDirectory, + [TrxLoggerConstants.LogFileNameKey] = DefaultLogFileNameParameterValue + }; + _testableTrxLogger.Initialize(_events.Object, _parameters); + } - [TestMethod] - public void InitializeShouldThrowExceptionIfTestRunDirectoryIsEmptyOrNull() + [TestCleanup] + public void Cleanup() + { + if (!string.IsNullOrEmpty(_testableTrxLogger?.TrxFile) && File.Exists(_testableTrxLogger.TrxFile)) { - Assert.ThrowsException( - () => - { - var events = new Mock(); - this.parameters[DefaultLoggerParameterNames.TestRunDirectory] = null; - this.testableTrxLogger.Initialize(events.Object, parameters); - }); + File.Delete(_testableTrxLogger.TrxFile); } + } - [TestMethod] - public void InitializeShouldNotThrowExceptionIfTestRunDirectoryIsNeitherEmptyNorNull() - { - var events = new Mock(); - this.testableTrxLogger.Initialize(events.Object, this.parameters); - } + [TestMethod] + public void InitializeShouldThrowExceptionIfEventsIsNull() + { + Assert.ThrowsException( + () => _testableTrxLogger.Initialize(null, _parameters)); + } - [TestMethod] - public void InitializeShouldThrowExceptionIfParametersAreEmpty() - { - var events = new Mock(); - Assert.ThrowsException(() => this.testableTrxLogger.Initialize(events.Object, new Dictionary())); - } + [TestMethod] + public void InitializeShouldNotThrowExceptionIfEventsIsNotNull() + { + var events = new Mock(); + _testableTrxLogger.Initialize(events.Object, _parameters); + } - [TestMethod] - public void TestMessageHandlerShouldThrowExceptionIfEventArgsIsNull() - { - Assert.ThrowsException(() => + [TestMethod] + public void InitializeShouldThrowExceptionIfTestRunDirectoryIsEmptyOrNull() + { + Assert.ThrowsException( + () => { - this.testableTrxLogger.TestMessageHandler(new object(), default); + var events = new Mock(); + _parameters[DefaultLoggerParameterNames.TestRunDirectory] = null; + _testableTrxLogger.Initialize(events.Object, _parameters); }); - } + } - [TestMethod] - public void TestMessageHandlerShouldAddMessageWhenItIsInformation() - { - string message = "First message"; - string message2 = "Second message"; - TestRunMessageEventArgs trme = new TestRunMessageEventArgs(TestMessageLevel.Informational, message); - this.testableTrxLogger.TestMessageHandler(new object(), trme); + [TestMethod] + public void InitializeShouldNotThrowExceptionIfTestRunDirectoryIsNeitherEmptyNorNull() + { + var events = new Mock(); + _testableTrxLogger.Initialize(events.Object, _parameters); + } - TestRunMessageEventArgs trme2 = new TestRunMessageEventArgs(TestMessageLevel.Informational, message2); - this.testableTrxLogger.TestMessageHandler(new object(), trme2); + [TestMethod] + public void InitializeShouldThrowExceptionIfParametersAreEmpty() + { + var events = new Mock(); + Assert.ThrowsException(() => _testableTrxLogger.Initialize(events.Object, new Dictionary())); + } - string expectedMessage = message + Environment.NewLine + message2 + Environment.NewLine; - Assert.AreEqual(expectedMessage, this.testableTrxLogger.GetRunLevelInformationalMessage()); - } + [TestMethod] + public void TestMessageHandlerShouldThrowExceptionIfEventArgsIsNull() + { + Assert.ThrowsException(() => _testableTrxLogger.TestMessageHandler(new object(), default)); + } - [TestMethod] - public void TestMessageHandlerShouldAddMessageInListIfItIsWarning() - { - string message = "The information to test"; - TestRunMessageEventArgs trme = new TestRunMessageEventArgs(TestMessageLevel.Warning, message); - this.testableTrxLogger.TestMessageHandler(new object(), trme); - this.testableTrxLogger.TestMessageHandler(new object(), trme); + [TestMethod] + public void TestMessageHandlerShouldAddMessageWhenItIsInformation() + { + string message = "First message"; + string message2 = "Second message"; + TestRunMessageEventArgs trme = new(TestMessageLevel.Informational, message); + _testableTrxLogger.TestMessageHandler(new object(), trme); - Assert.AreEqual(2, this.testableTrxLogger.GetRunLevelErrorsAndWarnings().Count); - } + TestRunMessageEventArgs trme2 = new(TestMessageLevel.Informational, message2); + _testableTrxLogger.TestMessageHandler(new object(), trme2); - [TestMethod] - public void TestMessageHandlerShouldAddMessageInListIfItIsError() - { - string message = "The information to test"; - TestRunMessageEventArgs trme = new TestRunMessageEventArgs(TestMessageLevel.Error, message); - this.testableTrxLogger.TestMessageHandler(new object(), trme); + string expectedMessage = message + Environment.NewLine + message2 + Environment.NewLine; + Assert.AreEqual(expectedMessage, _testableTrxLogger.GetRunLevelInformationalMessage()); + } - Assert.AreEqual(1, this.testableTrxLogger.GetRunLevelErrorsAndWarnings().Count); - } + [TestMethod] + public void TestMessageHandlerShouldAddMessageInListIfItIsWarning() + { + string message = "The information to test"; + TestRunMessageEventArgs trme = new(TestMessageLevel.Warning, message); + _testableTrxLogger.TestMessageHandler(new object(), trme); + _testableTrxLogger.TestMessageHandler(new object(), trme); - [TestMethod] - public void TestResultHandlerShouldCaptureStartTimeInSummaryWithTimeStampDuringIntialize() - { - ObjectModel.TestCase testCase = CreateTestCase("dummy string"); - ObjectModel.TestResult testResult = new ObjectModel.TestResult(testCase); - Mock e = new Mock(testResult); + Assert.AreEqual(2, _testableTrxLogger.GetRunLevelErrorsAndWarnings().Count); + } - this.testableTrxLogger.TestResultHandler(new object(), e.Object); + [TestMethod] + public void TestMessageHandlerShouldAddMessageInListIfItIsError() + { + string message = "The information to test"; + TestRunMessageEventArgs trme = new(TestMessageLevel.Error, message); + _testableTrxLogger.TestMessageHandler(new object(), trme); - Assert.AreEqual(this.testableTrxLogger.TestRunStartTime, this.testableTrxLogger.LoggerTestRun.Started); - } + Assert.AreEqual(1, _testableTrxLogger.GetRunLevelErrorsAndWarnings().Count); + } - [TestMethod] - public void TestResultHandlerKeepingTheTrackOfPassedAndFailedTests() - { - ObjectModel.TestCase passTestCase1 = CreateTestCase("Pass1"); - ObjectModel.TestCase passTestCase2 = CreateTestCase("Pass2"); - ObjectModel.TestCase failTestCase1 = CreateTestCase("Fail1"); - ObjectModel.TestCase skipTestCase1 = CreateTestCase("Skip1"); + [TestMethod] + public void TestResultHandlerShouldCaptureStartTimeInSummaryWithTimeStampDuringIntialize() + { + TestCase testCase = CreateTestCase("dummy string"); + ObjectModel.TestResult testResult = new(testCase); + Mock e = new(testResult); - ObjectModel.TestResult passResult1 = new ObjectModel.TestResult(passTestCase1); - passResult1.Outcome = ObjectModel.TestOutcome.Passed; + _testableTrxLogger.TestResultHandler(new object(), e.Object); - ObjectModel.TestResult passResult2 = new ObjectModel.TestResult(passTestCase2); - passResult2.Outcome = ObjectModel.TestOutcome.Passed; + Assert.AreEqual(_testableTrxLogger.TestRunStartTime, _testableTrxLogger.LoggerTestRun.Started); + } - ObjectModel.TestResult failResult1 = new ObjectModel.TestResult(failTestCase1); - failResult1.Outcome = ObjectModel.TestOutcome.Failed; + [TestMethod] + public void TestResultHandlerKeepingTheTrackOfPassedAndFailedTests() + { + TestCase passTestCase1 = CreateTestCase("Pass1"); + TestCase passTestCase2 = CreateTestCase("Pass2"); + TestCase failTestCase1 = CreateTestCase("Fail1"); + TestCase skipTestCase1 = CreateTestCase("Skip1"); - ObjectModel.TestResult skipResult1 = new ObjectModel.TestResult(skipTestCase1); - skipResult1.Outcome = ObjectModel.TestOutcome.Skipped; + ObjectModel.TestResult passResult1 = new(passTestCase1); + passResult1.Outcome = TestOutcome.Passed; - Mock pass1 = new Mock(passResult1); - Mock pass2 = new Mock(passResult2); - Mock fail1 = new Mock(failResult1); - Mock skip1 = new Mock(skipResult1); + ObjectModel.TestResult passResult2 = new(passTestCase2); + passResult2.Outcome = TestOutcome.Passed; - this.testableTrxLogger.TestResultHandler(new object(), pass1.Object); - this.testableTrxLogger.TestResultHandler(new object(), pass2.Object); - this.testableTrxLogger.TestResultHandler(new object(), fail1.Object); - this.testableTrxLogger.TestResultHandler(new object(), skip1.Object); + ObjectModel.TestResult failResult1 = new(failTestCase1); + failResult1.Outcome = TestOutcome.Failed; - Assert.AreEqual(2, this.testableTrxLogger.PassedTestCount, "Passed Tests"); - Assert.AreEqual(1, this.testableTrxLogger.FailedTestCount, "Failed Tests"); - } + ObjectModel.TestResult skipResult1 = new(skipTestCase1); + skipResult1.Outcome = TestOutcome.Skipped; - [TestMethod] - public void TestResultHandlerKeepingTheTrackOfTotalTests() - { - ObjectModel.TestCase passTestCase1 = CreateTestCase("Pass1"); - ObjectModel.TestCase passTestCase2 = CreateTestCase("Pass2"); - ObjectModel.TestCase failTestCase1 = CreateTestCase("Fail1"); - ObjectModel.TestCase skipTestCase1 = CreateTestCase("Skip1"); + Mock pass1 = new(passResult1); + Mock pass2 = new(passResult2); + Mock fail1 = new(failResult1); + Mock skip1 = new(skipResult1); - ObjectModel.TestResult passResult1 = new ObjectModel.TestResult(passTestCase1); - passResult1.Outcome = ObjectModel.TestOutcome.Passed; + _testableTrxLogger.TestResultHandler(new object(), pass1.Object); + _testableTrxLogger.TestResultHandler(new object(), pass2.Object); + _testableTrxLogger.TestResultHandler(new object(), fail1.Object); + _testableTrxLogger.TestResultHandler(new object(), skip1.Object); - ObjectModel.TestResult passResult2 = new ObjectModel.TestResult(passTestCase2); - passResult2.Outcome = ObjectModel.TestOutcome.Passed; + Assert.AreEqual(2, _testableTrxLogger.PassedTestCount, "Passed Tests"); + Assert.AreEqual(1, _testableTrxLogger.FailedTestCount, "Failed Tests"); + } - ObjectModel.TestResult failResult1 = new ObjectModel.TestResult(failTestCase1); - failResult1.Outcome = ObjectModel.TestOutcome.Failed; + [TestMethod] + public void TestResultHandlerKeepingTheTrackOfTotalTests() + { + TestCase passTestCase1 = CreateTestCase("Pass1"); + TestCase passTestCase2 = CreateTestCase("Pass2"); + TestCase failTestCase1 = CreateTestCase("Fail1"); + TestCase skipTestCase1 = CreateTestCase("Skip1"); - ObjectModel.TestResult skipResult1 = new ObjectModel.TestResult(skipTestCase1); - skipResult1.Outcome = ObjectModel.TestOutcome.Skipped; + ObjectModel.TestResult passResult1 = new(passTestCase1); + passResult1.Outcome = TestOutcome.Passed; - Mock pass1 = new Mock(passResult1); - Mock pass2 = new Mock(passResult2); - Mock fail1 = new Mock(failResult1); - Mock skip1 = new Mock(skipResult1); + ObjectModel.TestResult passResult2 = new(passTestCase2); + passResult2.Outcome = TestOutcome.Passed; - this.testableTrxLogger.TestResultHandler(new object(), pass1.Object); - this.testableTrxLogger.TestResultHandler(new object(), pass2.Object); - this.testableTrxLogger.TestResultHandler(new object(), fail1.Object); - this.testableTrxLogger.TestResultHandler(new object(), skip1.Object); + ObjectModel.TestResult failResult1 = new(failTestCase1); + failResult1.Outcome = TestOutcome.Failed; - Assert.AreEqual(4, this.testableTrxLogger.TotalTestCount, "Passed Tests"); - } + ObjectModel.TestResult skipResult1 = new(skipTestCase1); + skipResult1.Outcome = TestOutcome.Skipped; - [TestMethod] - public void TestResultHandlerLockingAMessageForSkipTest() - { - ObjectModel.TestCase skipTestCase1 = CreateTestCase("Skip1"); + Mock pass1 = new(passResult1); + Mock pass2 = new(passResult2); + Mock fail1 = new(failResult1); + Mock skip1 = new(skipResult1); - ObjectModel.TestResult skipResult1 = new ObjectModel.TestResult(skipTestCase1); - skipResult1.Outcome = ObjectModel.TestOutcome.Skipped; + _testableTrxLogger.TestResultHandler(new object(), pass1.Object); + _testableTrxLogger.TestResultHandler(new object(), pass2.Object); + _testableTrxLogger.TestResultHandler(new object(), fail1.Object); + _testableTrxLogger.TestResultHandler(new object(), skip1.Object); - Mock skip1 = new Mock(skipResult1); + Assert.AreEqual(4, _testableTrxLogger.TotalTestCount, "Passed Tests"); + } - this.testableTrxLogger.TestResultHandler(new object(), skip1.Object); + [TestMethod] + public void TestResultHandlerLockingAMessageForSkipTest() + { + TestCase skipTestCase1 = CreateTestCase("Skip1"); - string expectedMessage = String.Format(CultureInfo.CurrentCulture, TrxLoggerResources.MessageForSkippedTests, "Skip1"); + ObjectModel.TestResult skipResult1 = new(skipTestCase1); + skipResult1.Outcome = TestOutcome.Skipped; - Assert.AreEqual(expectedMessage + Environment.NewLine, this.testableTrxLogger.GetRunLevelInformationalMessage()); - } + Mock skip1 = new(skipResult1); - [TestMethod] - public void TestResultHandlerShouldCreateOneTestResultForEachTestCase() - { - var testCase1 = CreateTestCase("testCase1"); - ObjectModel.TestCase testCase2 = CreateTestCase("testCase2"); + _testableTrxLogger.TestResultHandler(new object(), skip1.Object); - ObjectModel.TestResult result1 = new ObjectModel.TestResult(testCase1); - result1.Outcome = ObjectModel.TestOutcome.Skipped; + string expectedMessage = String.Format(CultureInfo.CurrentCulture, TrxLoggerResources.MessageForSkippedTests, "Skip1"); - ObjectModel.TestResult result2 = new ObjectModel.TestResult(testCase2); - result2.Outcome = ObjectModel.TestOutcome.Failed; + Assert.AreEqual(expectedMessage + Environment.NewLine, _testableTrxLogger.GetRunLevelInformationalMessage()); + } - Mock resultEventArg1 = new Mock(result1); - Mock resultEventArg2 = new Mock(result2); + [TestMethod] + public void TestResultHandlerShouldCreateOneTestResultForEachTestCase() + { + var testCase1 = CreateTestCase("testCase1"); + TestCase testCase2 = CreateTestCase("testCase2"); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); + ObjectModel.TestResult result1 = new(testCase1); + result1.Outcome = TestOutcome.Skipped; - Assert.AreEqual(2, this.testableTrxLogger.TestResultCount, "TestResultHandler is not creating test result entry for each test case"); - } + ObjectModel.TestResult result2 = new(testCase2); + result2.Outcome = TestOutcome.Failed; - [TestMethod] - public void TestResultHandlerShouldCreateOneTestEntryForEachTestCase() - { - ObjectModel.TestCase testCase1 = CreateTestCase("TestCase1"); - ObjectModel.TestCase testCase2 = CreateTestCase("TestCase2"); + Mock resultEventArg1 = new(result1); + Mock resultEventArg2 = new(result2); - ObjectModel.TestResult result1 = new ObjectModel.TestResult(testCase1); - result1.Outcome = ObjectModel.TestOutcome.Skipped; + _testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); - ObjectModel.TestResult result2 = new ObjectModel.TestResult(testCase2); - result2.Outcome = ObjectModel.TestOutcome.Passed; + Assert.AreEqual(2, _testableTrxLogger.TestResultCount, "TestResultHandler is not creating test result entry for each test case"); + } - Mock resultEventArg1 = new Mock(result1); - Mock resultEventArg2 = new Mock(result2); + [TestMethod] + public void TestResultHandlerShouldCreateOneTestEntryForEachTestCase() + { + TestCase testCase1 = CreateTestCase("TestCase1"); + TestCase testCase2 = CreateTestCase("TestCase2"); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); + ObjectModel.TestResult result1 = new(testCase1); + result1.Outcome = TestOutcome.Skipped; - Assert.AreEqual(2, this.testableTrxLogger.TestEntryCount, "TestResultHandler is not creating test result entry for each test case"); - } + ObjectModel.TestResult result2 = new(testCase2); + result2.Outcome = TestOutcome.Passed; - [TestMethod] - public void TestResultHandlerShouldCreateOneUnitTestElementForEachTestCase() - { - ObjectModel.TestCase testCase1 = CreateTestCase("TestCase1"); - ObjectModel.TestCase testCase2 = CreateTestCase("TestCase2"); + Mock resultEventArg1 = new(result1); + Mock resultEventArg2 = new(result2); - ObjectModel.TestResult result1 = new ObjectModel.TestResult(testCase1); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); - ObjectModel.TestResult result2 = new ObjectModel.TestResult(testCase2); - result2.Outcome = ObjectModel.TestOutcome.Failed; + Assert.AreEqual(2, _testableTrxLogger.TestEntryCount, "TestResultHandler is not creating test result entry for each test case"); + } - Mock resultEventArg1 = new Mock(result1); - Mock resultEventArg2 = new Mock(result2); + [TestMethod] + public void TestResultHandlerShouldCreateOneUnitTestElementForEachTestCase() + { + TestCase testCase1 = CreateTestCase("TestCase1"); + TestCase testCase2 = CreateTestCase("TestCase2"); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); + ObjectModel.TestResult result1 = new(testCase1); - Assert.AreEqual(2, this.testableTrxLogger.UnitTestElementCount, "TestResultHandler is not creating test result entry for each test case"); - } + ObjectModel.TestResult result2 = new(testCase2); + result2.Outcome = TestOutcome.Failed; - [TestMethod] - public void TestResultHandlerShouldAddFlatResultsIfParentTestResultIsNotPresent() - { - ObjectModel.TestCase testCase1 = CreateTestCase("TestCase1"); + Mock resultEventArg1 = new(result1); + Mock resultEventArg2 = new(result2); - Guid parentExecutionId = Guid.NewGuid(); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); - ObjectModel.TestResult result1 = new ObjectModel.TestResult(testCase1); - result1.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); - result1.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); + Assert.AreEqual(2, _testableTrxLogger.UnitTestElementCount, "TestResultHandler is not creating test result entry for each test case"); + } - ObjectModel.TestResult result2 = new ObjectModel.TestResult(testCase1); - result2.Outcome = ObjectModel.TestOutcome.Failed; - result2.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); - result2.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); + [TestMethod] + public void TestResultHandlerShouldAddFlatResultsIfParentTestResultIsNotPresent() + { + TestCase testCase1 = CreateTestCase("TestCase1"); - Mock resultEventArg1 = new Mock(result1); - Mock resultEventArg2 = new Mock(result2); + Guid parentExecutionId = Guid.NewGuid(); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); + ObjectModel.TestResult result1 = new(testCase1); + result1.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); + result1.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); - Assert.AreEqual(2, this.testableTrxLogger.TestResultCount, "TestResultHandler is not creating flat results when parent result is not present."); - } + ObjectModel.TestResult result2 = new(testCase1); + result2.Outcome = TestOutcome.Failed; + result2.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); + result2.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); - [TestMethod] - public void TestResultHandlerShouldChangeGuidAndDisplayNameForMsTestResultIfParentNotPresentButTestResultNamePresent() - { - this.ValidateTestIdAndNameInTrx(true); - } + Mock resultEventArg1 = new(result1); + Mock resultEventArg2 = new(result2); - [TestMethod] - public void TestResultHandlerShouldNotChangeGuidAndDisplayNameForNonMsTestResultIfParentNotPresentButTestResultNamePresent() - { - this.ValidateTestIdAndNameInTrx(false); - } + _testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); - [TestMethod] - public void TestResultHandlerShouldAddHierarchicalResultsIfParentTestResultIsPresent() - { - ObjectModel.TestCase testCase1 = CreateTestCase("TestCase1"); + Assert.AreEqual(2, _testableTrxLogger.TestResultCount, "TestResultHandler is not creating flat results when parent result is not present."); + } - Guid parentExecutionId = Guid.NewGuid(); + [TestMethod] + public void TestResultHandlerShouldChangeGuidAndDisplayNameForMsTestResultIfParentNotPresentButTestResultNamePresent() + { + ValidateTestIdAndNameInTrx(true); + } - ObjectModel.TestResult result1 = new ObjectModel.TestResult(testCase1); - result1.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, parentExecutionId); + [TestMethod] + public void TestResultHandlerShouldNotChangeGuidAndDisplayNameForNonMsTestResultIfParentNotPresentButTestResultNamePresent() + { + ValidateTestIdAndNameInTrx(false); + } - ObjectModel.TestResult result2 = new ObjectModel.TestResult(testCase1); - result2.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); - result2.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); + [TestMethod] + public void TestResultHandlerShouldAddHierarchicalResultsIfParentTestResultIsPresent() + { + TestCase testCase1 = CreateTestCase("TestCase1"); - ObjectModel.TestResult result3 = new ObjectModel.TestResult(testCase1); - result3.Outcome = ObjectModel.TestOutcome.Failed; - result3.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); - result3.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); + Guid parentExecutionId = Guid.NewGuid(); - Mock resultEventArg1 = new Mock(result1); - Mock resultEventArg2 = new Mock(result2); - Mock resultEventArg3 = new Mock(result3); + ObjectModel.TestResult result1 = new(testCase1); + result1.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, parentExecutionId); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg3.Object); + ObjectModel.TestResult result2 = new(testCase1); + result2.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); + result2.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); - Assert.AreEqual(1, this.testableTrxLogger.TestResultCount, "TestResultHandler is not creating hierarchical results when parent result is present."); - Assert.AreEqual(3, this.testableTrxLogger.TotalTestCount, "TestResultHandler is not adding all inner results in parent test result."); - } + ObjectModel.TestResult result3 = new(testCase1); + result3.Outcome = TestOutcome.Failed; + result3.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); + result3.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); - [TestMethod] - public void TestResultHandlerShouldAddSingleTestElementForDataDrivenTests() - { - ObjectModel.TestCase testCase1 = CreateTestCase("TestCase1"); + Mock resultEventArg1 = new(result1); + Mock resultEventArg2 = new(result2); + Mock resultEventArg3 = new(result3); - Guid parentExecutionId = Guid.NewGuid(); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg3.Object); - ObjectModel.TestResult result1 = new ObjectModel.TestResult(testCase1); - result1.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, parentExecutionId); + Assert.AreEqual(1, _testableTrxLogger.TestResultCount, "TestResultHandler is not creating hierarchical results when parent result is present."); + Assert.AreEqual(3, _testableTrxLogger.TotalTestCount, "TestResultHandler is not adding all inner results in parent test result."); + } - ObjectModel.TestResult result2 = new ObjectModel.TestResult(testCase1); - result2.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); - result2.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); + [TestMethod] + public void TestResultHandlerShouldAddSingleTestElementForDataDrivenTests() + { + TestCase testCase1 = CreateTestCase("TestCase1"); - ObjectModel.TestResult result3 = new ObjectModel.TestResult(testCase1); - result3.Outcome = ObjectModel.TestOutcome.Failed; - result3.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); - result3.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); + Guid parentExecutionId = Guid.NewGuid(); - Mock resultEventArg1 = new Mock(result1); - Mock resultEventArg2 = new Mock(result2); - Mock resultEventArg3 = new Mock(result3); + ObjectModel.TestResult result1 = new(testCase1); + result1.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, parentExecutionId); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg3.Object); + ObjectModel.TestResult result2 = new(testCase1); + result2.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); + result2.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); - Assert.AreEqual(1, this.testableTrxLogger.UnitTestElementCount, "TestResultHandler is adding multiple test elements for data driven tests."); - } + ObjectModel.TestResult result3 = new(testCase1); + result3.Outcome = TestOutcome.Failed; + result3.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); + result3.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); - [TestMethod] - public void TestResultHandlerShouldAddSingleTestEntryForDataDrivenTests() - { - ObjectModel.TestCase testCase1 = CreateTestCase("TestCase1"); + Mock resultEventArg1 = new(result1); + Mock resultEventArg2 = new(result2); + Mock resultEventArg3 = new(result3); - Guid parentExecutionId = Guid.NewGuid(); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg3.Object); - ObjectModel.TestResult result1 = new ObjectModel.TestResult(testCase1); - result1.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, parentExecutionId); + Assert.AreEqual(1, _testableTrxLogger.UnitTestElementCount, "TestResultHandler is adding multiple test elements for data driven tests."); + } - ObjectModel.TestResult result2 = new ObjectModel.TestResult(testCase1); - result2.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); - result2.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); + [TestMethod] + public void TestResultHandlerShouldAddSingleTestEntryForDataDrivenTests() + { + TestCase testCase1 = CreateTestCase("TestCase1"); - ObjectModel.TestResult result3 = new ObjectModel.TestResult(testCase1); - result3.Outcome = ObjectModel.TestOutcome.Failed; - result3.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); - result3.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); + Guid parentExecutionId = Guid.NewGuid(); - Mock resultEventArg1 = new Mock(result1); - Mock resultEventArg2 = new Mock(result2); - Mock resultEventArg3 = new Mock(result3); + ObjectModel.TestResult result1 = new(testCase1); + result1.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, parentExecutionId); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg3.Object); + ObjectModel.TestResult result2 = new(testCase1); + result2.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); + result2.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); - Assert.AreEqual(1, this.testableTrxLogger.TestEntryCount, "TestResultHandler is adding multiple test entries for data driven tests."); - } + ObjectModel.TestResult result3 = new(testCase1); + result3.Outcome = TestOutcome.Failed; + result3.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); + result3.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); - [TestMethod] - public void TestResultHandlerShouldAddHierarchicalResultsForOrderedTest() - { - ObjectModel.TestCase testCase1 = CreateTestCase("TestCase1"); - ObjectModel.TestCase testCase2 = CreateTestCase("TestCase2"); - ObjectModel.TestCase testCase3 = CreateTestCase("TestCase3"); + Mock resultEventArg1 = new(result1); + Mock resultEventArg2 = new(result2); + Mock resultEventArg3 = new(result3); - Guid parentExecutionId = Guid.NewGuid(); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg3.Object); - ObjectModel.TestResult result1 = new ObjectModel.TestResult(testCase1); - result1.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, parentExecutionId); - result1.SetPropertyValue(TrxLoggerConstants.TestTypeProperty, TrxLoggerConstants.OrderedTestTypeGuid); + Assert.AreEqual(1, _testableTrxLogger.TestEntryCount, "TestResultHandler is adding multiple test entries for data driven tests."); + } - ObjectModel.TestResult result2 = new ObjectModel.TestResult(testCase2); - result2.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); - result2.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); + [TestMethod] + public void TestResultHandlerShouldAddHierarchicalResultsForOrderedTest() + { + TestCase testCase1 = CreateTestCase("TestCase1"); + TestCase testCase2 = CreateTestCase("TestCase2"); + TestCase testCase3 = CreateTestCase("TestCase3"); - ObjectModel.TestResult result3 = new ObjectModel.TestResult(testCase3); - result3.Outcome = ObjectModel.TestOutcome.Failed; - result3.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); - result3.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); + Guid parentExecutionId = Guid.NewGuid(); - Mock resultEventArg1 = new Mock(result1); - Mock resultEventArg2 = new Mock(result2); - Mock resultEventArg3 = new Mock(result3); + ObjectModel.TestResult result1 = new(testCase1); + result1.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, parentExecutionId); + result1.SetPropertyValue(TrxLoggerConstants.TestTypeProperty, TrxLoggerConstants.OrderedTestTypeGuid); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg3.Object); + ObjectModel.TestResult result2 = new(testCase2); + result2.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); + result2.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); - Assert.AreEqual(1, this.testableTrxLogger.TestResultCount, "TestResultHandler is not creating hierarchical results for ordered test."); - Assert.AreEqual(3, this.testableTrxLogger.TotalTestCount, "TestResultHandler is not adding all inner results in ordered test."); - } + ObjectModel.TestResult result3 = new(testCase3); + result3.Outcome = TestOutcome.Failed; + result3.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); + result3.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); - [TestMethod] - public void TestResultHandlerShouldAddMultipleTestElementsForOrderedTest() - { - ObjectModel.TestCase testCase1 = CreateTestCase("TestCase1"); - ObjectModel.TestCase testCase2 = CreateTestCase("TestCase2"); - ObjectModel.TestCase testCase3 = CreateTestCase("TestCase3"); + Mock resultEventArg1 = new(result1); + Mock resultEventArg2 = new(result2); + Mock resultEventArg3 = new(result3); - Guid parentExecutionId = Guid.NewGuid(); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg3.Object); - ObjectModel.TestResult result1 = new ObjectModel.TestResult(testCase1); - result1.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, parentExecutionId); - result1.SetPropertyValue(TrxLoggerConstants.TestTypeProperty, TrxLoggerConstants.OrderedTestTypeGuid); + Assert.AreEqual(1, _testableTrxLogger.TestResultCount, "TestResultHandler is not creating hierarchical results for ordered test."); + Assert.AreEqual(3, _testableTrxLogger.TotalTestCount, "TestResultHandler is not adding all inner results in ordered test."); + } - ObjectModel.TestResult result2 = new ObjectModel.TestResult(testCase2); - result2.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); - result2.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); + [TestMethod] + public void TestResultHandlerShouldAddMultipleTestElementsForOrderedTest() + { + TestCase testCase1 = CreateTestCase("TestCase1"); + TestCase testCase2 = CreateTestCase("TestCase2"); + TestCase testCase3 = CreateTestCase("TestCase3"); - ObjectModel.TestResult result3 = new ObjectModel.TestResult(testCase3); - result3.Outcome = ObjectModel.TestOutcome.Failed; - result3.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); - result3.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); + Guid parentExecutionId = Guid.NewGuid(); - Mock resultEventArg1 = new Mock(result1); - Mock resultEventArg2 = new Mock(result2); - Mock resultEventArg3 = new Mock(result3); + ObjectModel.TestResult result1 = new(testCase1); + result1.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, parentExecutionId); + result1.SetPropertyValue(TrxLoggerConstants.TestTypeProperty, TrxLoggerConstants.OrderedTestTypeGuid); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg3.Object); + ObjectModel.TestResult result2 = new(testCase2); + result2.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); + result2.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); - Assert.AreEqual(3, this.testableTrxLogger.UnitTestElementCount, "TestResultHandler is not adding multiple test elements for ordered test."); - } + ObjectModel.TestResult result3 = new(testCase3); + result3.Outcome = TestOutcome.Failed; + result3.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); + result3.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); - [TestMethod] - public void TestResultHandlerShouldAddSingleTestEntryForOrderedTest() - { - ObjectModel.TestCase testCase1 = CreateTestCase("TestCase1"); - ObjectModel.TestCase testCase2 = CreateTestCase("TestCase2"); - ObjectModel.TestCase testCase3 = CreateTestCase("TestCase3"); + Mock resultEventArg1 = new(result1); + Mock resultEventArg2 = new(result2); + Mock resultEventArg3 = new(result3); - Guid parentExecutionId = Guid.NewGuid(); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg3.Object); - ObjectModel.TestResult result1 = new ObjectModel.TestResult(testCase1); - result1.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, parentExecutionId); - result1.SetPropertyValue(TrxLoggerConstants.TestTypeProperty, TrxLoggerConstants.OrderedTestTypeGuid); + Assert.AreEqual(3, _testableTrxLogger.UnitTestElementCount, "TestResultHandler is not adding multiple test elements for ordered test."); + } - ObjectModel.TestResult result2 = new ObjectModel.TestResult(testCase2); - result2.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); - result2.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); + [TestMethod] + public void TestResultHandlerShouldAddSingleTestEntryForOrderedTest() + { + TestCase testCase1 = CreateTestCase("TestCase1"); + TestCase testCase2 = CreateTestCase("TestCase2"); + TestCase testCase3 = CreateTestCase("TestCase3"); - ObjectModel.TestResult result3 = new ObjectModel.TestResult(testCase3); - result3.Outcome = ObjectModel.TestOutcome.Failed; - result3.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); - result3.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); + Guid parentExecutionId = Guid.NewGuid(); - Mock resultEventArg1 = new Mock(result1); - Mock resultEventArg2 = new Mock(result2); - Mock resultEventArg3 = new Mock(result3); + ObjectModel.TestResult result1 = new(testCase1); + result1.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, parentExecutionId); + result1.SetPropertyValue(TrxLoggerConstants.TestTypeProperty, TrxLoggerConstants.OrderedTestTypeGuid); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg3.Object); + ObjectModel.TestResult result2 = new(testCase2); + result2.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); + result2.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); - Assert.AreEqual(1, this.testableTrxLogger.TestEntryCount, "TestResultHandler is adding multiple test entries for ordered test."); - } + ObjectModel.TestResult result3 = new(testCase3); + result3.Outcome = TestOutcome.Failed; + result3.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); + result3.SetPropertyValue(TrxLoggerConstants.ParentExecIdProperty, parentExecutionId); - [TestMethod] - public void TestRunCompleteHandlerShouldReportFailedOutcomeIfTestRunIsAborted() - { - string message = "The information to test"; - TestRunMessageEventArgs trme = new TestRunMessageEventArgs(TestMessageLevel.Error, message); - this.testableTrxLogger.TestMessageHandler(new object(), trme); + Mock resultEventArg1 = new(result1); + Mock resultEventArg2 = new(result2); + Mock resultEventArg3 = new(result3); - this.testableTrxLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg1.Object); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg2.Object); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg3.Object); - Assert.AreEqual(this.testableTrxLogger.TestResultOutcome, TrxLoggerObjectModel.TestOutcome.Failed); - } + Assert.AreEqual(1, _testableTrxLogger.TestEntryCount, "TestResultHandler is adding multiple test entries for ordered test."); + } - [TestMethod] - public void OutcomeOfRunWillBeFailIfAnyTestsFails() - { - ObjectModel.TestCase passTestCase1 = CreateTestCase("Pass1"); - ObjectModel.TestCase passTestCase2 = CreateTestCase("Pass2"); - ObjectModel.TestCase failTestCase1 = CreateTestCase("Fail1"); - ObjectModel.TestCase skipTestCase1 = CreateTestCase("Skip1"); + [TestMethod] + public void TestRunCompleteHandlerShouldReportFailedOutcomeIfTestRunIsAborted() + { + string message = "The information to test"; + TestRunMessageEventArgs trme = new(TestMessageLevel.Error, message); + _testableTrxLogger.TestMessageHandler(new object(), trme); - ObjectModel.TestResult passResult1 = new ObjectModel.TestResult(passTestCase1); - passResult1.Outcome = ObjectModel.TestOutcome.Passed; + _testableTrxLogger.TestRunCompleteHandler(new object(), new TestRunCompleteEventArgs(null, false, true, null, null, null, TimeSpan.Zero)); - ObjectModel.TestResult passResult2 = new ObjectModel.TestResult(passTestCase2); - passResult2.Outcome = ObjectModel.TestOutcome.Passed; + Assert.AreEqual(_testableTrxLogger.TestResultOutcome, TrxLoggerObjectModel.TestOutcome.Failed); + } - ObjectModel.TestResult failResult1 = new ObjectModel.TestResult(failTestCase1); - failResult1.Outcome = ObjectModel.TestOutcome.Failed; + [TestMethod] + public void OutcomeOfRunWillBeFailIfAnyTestsFails() + { + TestCase passTestCase1 = CreateTestCase("Pass1"); + TestCase passTestCase2 = CreateTestCase("Pass2"); + TestCase failTestCase1 = CreateTestCase("Fail1"); + TestCase skipTestCase1 = CreateTestCase("Skip1"); - ObjectModel.TestResult skipResult1 = new ObjectModel.TestResult(skipTestCase1); - skipResult1.Outcome = ObjectModel.TestOutcome.Skipped; + ObjectModel.TestResult passResult1 = new(passTestCase1); + passResult1.Outcome = TestOutcome.Passed; - Mock pass1 = new Mock(passResult1); - Mock pass2 = new Mock(passResult2); - Mock fail1 = new Mock(failResult1); - Mock skip1 = new Mock(skipResult1); + ObjectModel.TestResult passResult2 = new(passTestCase2); + passResult2.Outcome = TestOutcome.Passed; - this.testableTrxLogger.TestResultHandler(new object(), pass1.Object); - this.testableTrxLogger.TestResultHandler(new object(), pass2.Object); - this.testableTrxLogger.TestResultHandler(new object(), fail1.Object); - this.testableTrxLogger.TestResultHandler(new object(), skip1.Object); + ObjectModel.TestResult failResult1 = new(failTestCase1); + failResult1.Outcome = TestOutcome.Failed; - var testRunCompleteEventArgs = CreateTestRunCompleteEventArgs(); + ObjectModel.TestResult skipResult1 = new(skipTestCase1); + skipResult1.Outcome = TestOutcome.Skipped; - this.testableTrxLogger.TestRunCompleteHandler(new object(), testRunCompleteEventArgs); + Mock pass1 = new(passResult1); + Mock pass2 = new(passResult2); + Mock fail1 = new(failResult1); + Mock skip1 = new(skipResult1); - Assert.AreEqual(TrxLoggerObjectModel.TestOutcome.Failed, this.testableTrxLogger.TestResultOutcome); - } + _testableTrxLogger.TestResultHandler(new object(), pass1.Object); + _testableTrxLogger.TestResultHandler(new object(), pass2.Object); + _testableTrxLogger.TestResultHandler(new object(), fail1.Object); + _testableTrxLogger.TestResultHandler(new object(), skip1.Object); - [TestMethod] - public void OutcomeOfRunWillBeCompletedIfNoTestsFails() - { - ObjectModel.TestCase passTestCase1 = CreateTestCase("Pass1"); - ObjectModel.TestCase passTestCase2 = CreateTestCase("Pass2"); - ObjectModel.TestCase skipTestCase1 = CreateTestCase("Skip1"); + var testRunCompleteEventArgs = CreateTestRunCompleteEventArgs(); - ObjectModel.TestResult passResult1 = new ObjectModel.TestResult(passTestCase1); - passResult1.Outcome = ObjectModel.TestOutcome.Passed; + _testableTrxLogger.TestRunCompleteHandler(new object(), testRunCompleteEventArgs); - ObjectModel.TestResult passResult2 = new ObjectModel.TestResult(passTestCase2); - passResult2.Outcome = ObjectModel.TestOutcome.Passed; + Assert.AreEqual(TrxLoggerObjectModel.TestOutcome.Failed, _testableTrxLogger.TestResultOutcome); + } - ObjectModel.TestResult skipResult1 = new ObjectModel.TestResult(skipTestCase1); - skipResult1.Outcome = ObjectModel.TestOutcome.Skipped; + [TestMethod] + public void OutcomeOfRunWillBeCompletedIfNoTestsFails() + { + TestCase passTestCase1 = CreateTestCase("Pass1"); + TestCase passTestCase2 = CreateTestCase("Pass2"); + TestCase skipTestCase1 = CreateTestCase("Skip1"); - Mock pass1 = new Mock(passResult1); - Mock pass2 = new Mock(passResult2); - Mock skip1 = new Mock(skipResult1); + ObjectModel.TestResult passResult1 = new(passTestCase1); + passResult1.Outcome = TestOutcome.Passed; - this.testableTrxLogger.TestResultHandler(new object(), pass1.Object); - this.testableTrxLogger.TestResultHandler(new object(), pass2.Object); - this.testableTrxLogger.TestResultHandler(new object(), skip1.Object); + ObjectModel.TestResult passResult2 = new(passTestCase2); + passResult2.Outcome = TestOutcome.Passed; - var testRunCompleteEventArgs = CreateTestRunCompleteEventArgs(); + ObjectModel.TestResult skipResult1 = new(skipTestCase1); + skipResult1.Outcome = TestOutcome.Skipped; - this.testableTrxLogger.TestRunCompleteHandler(new object(), testRunCompleteEventArgs); + Mock pass1 = new(passResult1); + Mock pass2 = new(passResult2); + Mock skip1 = new(skipResult1); - Assert.AreEqual(TrxLoggerObjectModel.TestOutcome.Completed, this.testableTrxLogger.TestResultOutcome); - } + _testableTrxLogger.TestResultHandler(new object(), pass1.Object); + _testableTrxLogger.TestResultHandler(new object(), pass2.Object); + _testableTrxLogger.TestResultHandler(new object(), skip1.Object); - [TestMethod] - public void TheDefaultTrxFileNameShouldNotHaveWhiteSpace() - { - // To create default trx file, log file parameter should be null. - this.parameters[TrxLoggerConstants.LogFileNameKey] = null; - this.testableTrxLogger.Initialize(this.events.Object, this.parameters); + var testRunCompleteEventArgs = CreateTestRunCompleteEventArgs(); - this.MakeTestRunComplete(); + _testableTrxLogger.TestRunCompleteHandler(new object(), testRunCompleteEventArgs); - bool trxFileNameContainsWhiteSpace = Path.GetFileName(this.testableTrxLogger.trxFile).Contains(' '); - Assert.IsFalse(trxFileNameContainsWhiteSpace, $"\"{this.testableTrxLogger.trxFile}\": Trx file name should not have white spaces"); - } + Assert.AreEqual(TrxLoggerObjectModel.TestOutcome.Completed, _testableTrxLogger.TestResultOutcome); + } - [TestMethod] - public void DefaultTrxFileShouldCreateIfLogFileNameParameterNotPassed() - { - // To create default trx file, If LogFileName parameter not passed - this.parameters.Remove(TrxLoggerConstants.LogFileNameKey); - this.testableTrxLogger.Initialize(this.events.Object, this.parameters); + [TestMethod] + public void TheDefaultTrxFileNameShouldNotHaveWhiteSpace() + { + // To create default trx file, log file parameter should be null. + _parameters[TrxLoggerConstants.LogFileNameKey] = null; + _testableTrxLogger.Initialize(_events.Object, _parameters); - this.MakeTestRunComplete(); + MakeTestRunComplete(); - Assert.IsFalse(string.IsNullOrWhiteSpace(this.testableTrxLogger.trxFile)); - } + bool trxFileNameContainsWhiteSpace = Path.GetFileName(_testableTrxLogger.TrxFile).Contains(' '); + Assert.IsFalse(trxFileNameContainsWhiteSpace, $"\"{_testableTrxLogger.TrxFile}\": Trx file name should not have white spaces"); + } - [TestMethod] - public void DefaultTrxFileNameVerification() - { - this.parameters.Remove(TrxLoggerConstants.LogFileNameKey); - this.parameters[TrxLoggerConstants.LogFilePrefixKey] = DefaultLogFilePrefixParameterValue; + [TestMethod] + public void DefaultTrxFileShouldCreateIfLogFileNameParameterNotPassed() + { + // To create default trx file, If LogFileName parameter not passed + _parameters.Remove(TrxLoggerConstants.LogFileNameKey); + _testableTrxLogger.Initialize(_events.Object, _parameters); - var time = DateTime.Now; - var trxFileHelper = new TrxFileHelper(() => time); + MakeTestRunComplete(); - testableTrxLogger = new TestableTrxLogger(new FileHelper(), trxFileHelper); - testableTrxLogger.Initialize(this.events.Object, this.parameters); + Assert.IsFalse(string.IsNullOrWhiteSpace(_testableTrxLogger.TrxFile)); + } - MakeTestRunComplete(); + [TestMethod] + public void DefaultTrxFileNameVerification() + { + _parameters.Remove(TrxLoggerConstants.LogFileNameKey); + _parameters[TrxLoggerConstants.LogFilePrefixKey] = DefaultLogFilePrefixParameterValue; - var fileName = Path.GetFileName(testableTrxLogger.trxFile); - var expectedName = $"{DefaultLogFilePrefixParameterValue}{time:_yyyyMMddHHmmss}.trx"; + var time = DateTime.Now; + var trxFileHelper = new TrxFileHelper(() => time); - Assert.AreEqual(expectedName, fileName, "Trx file name pattern has changed. It should be in the form of prefix_yyyyMMddHHmmss.trx, Azure Devops VSTest task depends on this naming."); - } + _testableTrxLogger = new TestableTrxLogger(new FileHelper(), trxFileHelper); + _testableTrxLogger.Initialize(_events.Object, _parameters); - [TestMethod] - public void DefaultTrxFileShouldIterateIfLogFileNameParameterNotPassed() - { - this.parameters.Remove(TrxLoggerConstants.LogFileNameKey); + MakeTestRunComplete(); - var files = TestMultipleTrxLoggers(); + var fileName = Path.GetFileName(_testableTrxLogger.TrxFile); + var expectedName = $"{DefaultLogFilePrefixParameterValue}{time:_yyyyMMddHHmmss}.trx"; - Assert.AreEqual(MultipleLoggerInstanceCount, files.Length, "All logger instances should get different file names!"); - } + Assert.AreEqual(expectedName, fileName, "Trx file name pattern has changed. It should be in the form of prefix_yyyyMMddHHmmss.trx, Azure Devops VSTest task depends on this naming."); + } - [TestMethod] - public void TrxFileNameShouldNotIterate() - { - var files = TestMultipleTrxLoggers(); + [TestMethod] + public void DefaultTrxFileShouldIterateIfLogFileNameParameterNotPassed() + { + _parameters.Remove(TrxLoggerConstants.LogFileNameKey); - Assert.AreEqual(1, files.Length, "All logger instances should get the same file name!"); - } + var files = TestMultipleTrxLoggers(); - [TestMethod] - public void TrxPrefixFileNameShouldIterate() - { - this.parameters.Remove(TrxLoggerConstants.LogFileNameKey); - this.parameters[TrxLoggerConstants.LogFilePrefixKey] = DefaultLogFilePrefixParameterValue; + Assert.AreEqual(MultipleLoggerInstanceCount, files.Length, "All logger instances should get different file names!"); + } - var files = TestMultipleTrxLoggers(); + [TestMethod] + public void TrxFileNameShouldNotIterate() + { + var files = TestMultipleTrxLoggers(); - Assert.AreEqual(MultipleLoggerInstanceCount, files.Length, "All logger instances should get different file names!"); - } + Assert.AreEqual(1, files.Length, "All logger instances should get the same file name!"); + } + + [TestMethod] + public void TrxPrefixFileNameShouldIterate() + { + _parameters.Remove(TrxLoggerConstants.LogFileNameKey); + _parameters[TrxLoggerConstants.LogFilePrefixKey] = DefaultLogFilePrefixParameterValue; + + var files = TestMultipleTrxLoggers(); - private string[] TestMultipleTrxLoggers() + Assert.AreEqual(MultipleLoggerInstanceCount, files.Length, "All logger instances should get different file names!"); + } + + private string[] TestMultipleTrxLoggers() + { + var files = new string[2]; + + try { - var files = new string[2]; + var time = new DateTime(2020, 1, 1, 0, 0, 0); - try - { - var time = new DateTime(2020, 1, 1, 0, 0, 0); + var trxFileHelper = new TrxFileHelper(() => time); + var trxLogger1 = new TestableTrxLogger(new FileHelper(), trxFileHelper); + var trxLogger2 = new TestableTrxLogger(new FileHelper(), trxFileHelper); - var trxFileHelper = new TrxFileHelper(() => time); - var trxLogger1 = new TestableTrxLogger(new FileHelper(), trxFileHelper); - var trxLogger2 = new TestableTrxLogger(new FileHelper(), trxFileHelper); + trxLogger1.Initialize(_events.Object, _parameters); + trxLogger2.Initialize(_events.Object, _parameters); - trxLogger1.Initialize(this.events.Object, this.parameters); - trxLogger2.Initialize(this.events.Object, this.parameters); + MakeTestRunComplete(trxLogger1); + files[0] = trxLogger1.TrxFile; - MakeTestRunComplete(trxLogger1); - files[0] = trxLogger1.trxFile; + MakeTestRunComplete(trxLogger2); + files[1] = trxLogger2.TrxFile; + } + finally + { + files = files + .Where(i => !string.IsNullOrWhiteSpace(i)) + .Distinct() + .ToArray(); - MakeTestRunComplete(trxLogger2); - files[1] = trxLogger2.trxFile; - } - finally + foreach (var file in files) { - files = files - .Where(i => !string.IsNullOrWhiteSpace(i)) - .Distinct() - .ToArray(); - - foreach (var file in files) + if (!string.IsNullOrEmpty(file) && File.Exists(file)) { - if (!string.IsNullOrEmpty(file) && File.Exists(file)) - { - File.Delete(file); - } + File.Delete(file); } } - - return files; } - [TestMethod] - public void CustomTrxFileNameShouldConstructFromLogFileParameter() - { - this.MakeTestRunComplete(); - - Assert.AreEqual(Path.Combine(TrxLoggerTests.DefaultTestRunDirectory, TrxLoggerTests.DefaultLogFileNameParameterValue), this.testableTrxLogger.trxFile, "Wrong Trx file name"); - } + return files; + } - /// - /// Unit test for reading TestCategories from the TestCase which is part of test result. - /// - [TestMethod] - public void GetCustomPropertyValueFromTestCaseShouldReadCategoryAttributesFromTestCase() - { - ObjectModel.TestCase testCase1 = CreateTestCase("TestCase1"); - TestProperty testProperty = TestProperty.Register("MSTestDiscoverer.TestCategory", "String array property", string.Empty, string.Empty, typeof(string[]), null, TestPropertyAttributes.Hidden, typeof(TestObject)); + [TestMethod] + public void CustomTrxFileNameShouldConstructFromLogFileParameter() + { + MakeTestRunComplete(); - testCase1.SetPropertyValue(testProperty, new[] { "ClassLevel", "AsmLevel" }); + Assert.AreEqual(Path.Combine(DefaultTestRunDirectory, DefaultLogFileNameParameterValue), _testableTrxLogger.TrxFile, "Wrong Trx file name"); + } - var converter = new Converter(new Mock().Object, new TrxFileHelper()); - List listCategoriesActual = converter.GetCustomPropertyValueFromTestCase(testCase1, "MSTestDiscoverer.TestCategory"); + /// + /// Unit test for reading TestCategories from the TestCase which is part of test result. + /// + [TestMethod] + public void GetCustomPropertyValueFromTestCaseShouldReadCategoryAttributesFromTestCase() + { + TestCase testCase1 = CreateTestCase("TestCase1"); + TestProperty testProperty = TestProperty.Register("MSTestDiscoverer.TestCategory", "String array property", string.Empty, string.Empty, typeof(string[]), null, TestPropertyAttributes.Hidden, typeof(TestObject)); - List listCategoriesExpected = new List(); - listCategoriesExpected.Add("ClassLevel"); - listCategoriesExpected.Add("AsmLevel"); + testCase1.SetPropertyValue(testProperty, new[] { "ClassLevel", "AsmLevel" }); - CollectionAssert.AreEqual(listCategoriesExpected, listCategoriesActual); - } + var converter = new Converter(new Mock().Object, new TrxFileHelper()); + List listCategoriesActual = converter.GetCustomPropertyValueFromTestCase(testCase1, "MSTestDiscoverer.TestCategory"); - [TestMethod] - public void GetCustomPropertyValueFromTestCaseShouldReadWorkItemAttributesFromTestCase() + List listCategoriesExpected = new() { - ObjectModel.TestCase testCase1 = CreateTestCase("TestCase1"); - TestProperty testProperty = TestProperty.Register("WorkItemIds", "String array property", string.Empty, string.Empty, typeof(string[]), null, TestPropertyAttributes.Hidden, typeof(TestObject)); + "ClassLevel", + "AsmLevel" + }; - testCase1.SetPropertyValue(testProperty, new[] { "99999", "0" }); + CollectionAssert.AreEqual(listCategoriesExpected, listCategoriesActual); + } - var converter = new Converter(new Mock().Object, new TrxFileHelper()); - List listWorkItemsActual = converter.GetCustomPropertyValueFromTestCase(testCase1, "WorkItemIds"); + [TestMethod] + public void GetCustomPropertyValueFromTestCaseShouldReadWorkItemAttributesFromTestCase() + { + TestCase testCase1 = CreateTestCase("TestCase1"); + TestProperty testProperty = TestProperty.Register("WorkItemIds", "String array property", string.Empty, string.Empty, typeof(string[]), null, TestPropertyAttributes.Hidden, typeof(TestObject)); - List listWorkItemsExpected = new List(); - listWorkItemsExpected.Add("99999"); - listWorkItemsExpected.Add("0"); + testCase1.SetPropertyValue(testProperty, new[] { "99999", "0" }); - CollectionAssert.AreEqual(listWorkItemsExpected, listWorkItemsActual); - } + var converter = new Converter(new Mock().Object, new TrxFileHelper()); + List listWorkItemsActual = converter.GetCustomPropertyValueFromTestCase(testCase1, "WorkItemIds"); - [TestMethod] - public void CRLFCharactersShouldGetRetainedInTrx() + List listWorkItemsExpected = new() { - // To create default trx file, If LogFileName parameter not passed - this.parameters.Remove(TrxLoggerConstants.LogFileNameKey); - this.testableTrxLogger.Initialize(this.events.Object, this.parameters); + "99999", + "0" + }; - string message = $"one line{ Environment.NewLine }second line\r\nthird line"; - var pass = TrxLoggerTests.CreatePassTestResultEventArgsMock("Pass1", new List { new TestResultMessage(TestResultMessage.StandardOutCategory, message) }); + CollectionAssert.AreEqual(listWorkItemsExpected, listWorkItemsActual); + } - this.testableTrxLogger.TestResultHandler(new object(), pass.Object); + [TestMethod] + public void CrlfCharactersShouldGetRetainedInTrx() + { + // To create default trx file, If LogFileName parameter not passed + _parameters.Remove(TrxLoggerConstants.LogFileNameKey); + _testableTrxLogger.Initialize(_events.Object, _parameters); - var testRunCompleteEventArgs = TrxLoggerTests.CreateTestRunCompleteEventArgs(); - this.testableTrxLogger.TestRunCompleteHandler(new object(), testRunCompleteEventArgs); + string message = $"one line{ Environment.NewLine }second line\r\nthird line"; + var pass = CreatePassTestResultEventArgsMock("Pass1", new List { new TestResultMessage(TestResultMessage.StandardOutCategory, message) }); - Assert.IsTrue(File.Exists(this.testableTrxLogger.trxFile), string.Format("TRX file: {0}, should have got created.", this.testableTrxLogger.trxFile)); + _testableTrxLogger.TestResultHandler(new object(), pass.Object); - string actualMessage = GetElementValueFromTrx(this.testableTrxLogger.trxFile, "StdOut"); + var testRunCompleteEventArgs = CreateTestRunCompleteEventArgs(); + _testableTrxLogger.TestRunCompleteHandler(new object(), testRunCompleteEventArgs); - Assert.IsNotNull(actualMessage); - Assert.IsTrue(string.Equals(message, actualMessage), string.Format("StdOut messages do not match. Expected:{0}, Actual:{1}", message, actualMessage)); - } + Assert.IsTrue(File.Exists(_testableTrxLogger.TrxFile), string.Format("TRX file: {0}, should have got created.", _testableTrxLogger.TrxFile)); - [TestMethod] - public void TestRunInformationShouldContainUtcDateTime() - { - this.MakeTestRunComplete(); - this.ValidateDateTimeInTrx(this.testableTrxLogger.trxFile); - } + string actualMessage = GetElementValueFromTrx(_testableTrxLogger.TrxFile, "StdOut"); - private void ValidateDateTimeInTrx(string trxFileName) - { - using (FileStream file = File.OpenRead(trxFileName)) - { - using (XmlReader reader = XmlReader.Create(file)) - { - XDocument document = XDocument.Load(reader); - var timesNode = document.Descendants(document.Root.GetDefaultNamespace() + "Times").FirstOrDefault(); - ValidateTimeWithinUtcLimits(DateTimeOffset.Parse(timesNode.Attributes("creation").FirstOrDefault().Value)); - ValidateTimeWithinUtcLimits(DateTimeOffset.Parse(timesNode.Attributes("start").FirstOrDefault().Value)); - var resultNode = document.Descendants(document.Root.GetDefaultNamespace() + "UnitTestResult").FirstOrDefault(); - ValidateTimeWithinUtcLimits(DateTimeOffset.Parse(resultNode.Attributes("endTime").FirstOrDefault().Value)); - ValidateTimeWithinUtcLimits(DateTimeOffset.Parse(resultNode.Attributes("startTime").FirstOrDefault().Value)); - } - } - } - - [TestMethod] - [DataRow("results")] - public void CustomTrxFileNameShouldBeConstructedFromRelativeLogFilePrefixParameter(string prefixName) - { - this.parameters.Remove(TrxLoggerConstants.LogFileNameKey); - this.parameters[TrxLoggerConstants.LogFilePrefixKey] = prefixName; - this.parameters[DefaultLoggerParameterNames.TargetFramework] = ".NETFramework,Version=4.5.1"; - this.testableTrxLogger.Initialize(events.Object, this.parameters); - - this.MakeTestRunComplete(); + Assert.IsNotNull(actualMessage); + Assert.IsTrue(string.Equals(message, actualMessage), string.Format("StdOut messages do not match. Expected:{0}, Actual:{1}", message, actualMessage)); + } - string actualFileNameWithoutTimestamp = this.testableTrxLogger.trxFile.Substring(0, this.testableTrxLogger.trxFile.LastIndexOf('_')); + [TestMethod] + public void TestRunInformationShouldContainUtcDateTime() + { + MakeTestRunComplete(); + ValidateDateTimeInTrx(_testableTrxLogger.TrxFile); + } - Assert.AreNotEqual(Path.Combine(TrxLoggerTests.DefaultTestRunDirectory, "results.trx"), this.testableTrxLogger.trxFile, "Expected framework name to appear in file name"); - Assert.AreNotEqual(Path.Combine(TrxLoggerTests.DefaultTestRunDirectory, "results_net451.trx"), this.testableTrxLogger.trxFile, "Expected time stamp to appear in file name"); - Assert.AreEqual(Path.Combine(TrxLoggerTests.DefaultTestRunDirectory, "results_net451"), actualFileNameWithoutTimestamp); - } + private void ValidateDateTimeInTrx(string trxFileName) + { + using FileStream file = File.OpenRead(trxFileName); + using XmlReader reader = XmlReader.Create(file); + XDocument document = XDocument.Load(reader); + var timesNode = document.Descendants(document.Root.GetDefaultNamespace() + "Times").FirstOrDefault(); + ValidateTimeWithinUtcLimits(DateTimeOffset.Parse(timesNode.Attributes("creation").FirstOrDefault().Value)); + ValidateTimeWithinUtcLimits(DateTimeOffset.Parse(timesNode.Attributes("start").FirstOrDefault().Value)); + var resultNode = document.Descendants(document.Root.GetDefaultNamespace() + "UnitTestResult").FirstOrDefault(); + ValidateTimeWithinUtcLimits(DateTimeOffset.Parse(resultNode.Attributes("endTime").FirstOrDefault().Value)); + ValidateTimeWithinUtcLimits(DateTimeOffset.Parse(resultNode.Attributes("startTime").FirstOrDefault().Value)); + } - [TestMethod] - public void CustomTrxFileNameShouldBeConstructedFromAbsoluteLogFilePrefixParameter() - { - this.parameters.Remove(TrxLoggerConstants.LogFileNameKey); - var trxPrefix = Path.Combine(Path.GetTempPath(), "results"); - this.parameters[TrxLoggerConstants.LogFilePrefixKey] = trxPrefix; - this.parameters[DefaultLoggerParameterNames.TargetFramework] = ".NETFramework,Version=4.5.1"; - this.testableTrxLogger.Initialize(events.Object, this.parameters); + [TestMethod] + [DataRow("results")] + public void CustomTrxFileNameShouldBeConstructedFromRelativeLogFilePrefixParameter(string prefixName) + { + _parameters.Remove(TrxLoggerConstants.LogFileNameKey); + _parameters[TrxLoggerConstants.LogFilePrefixKey] = prefixName; + _parameters[DefaultLoggerParameterNames.TargetFramework] = ".NETFramework,Version=4.5.1"; + _testableTrxLogger.Initialize(_events.Object, _parameters); - this.MakeTestRunComplete(); + MakeTestRunComplete(); - string actualFileNameWithoutTimestamp = this.testableTrxLogger.trxFile.Substring(0, this.testableTrxLogger.trxFile.LastIndexOf('_')); + string actualFileNameWithoutTimestamp = _testableTrxLogger.TrxFile.Substring(0, _testableTrxLogger.TrxFile.LastIndexOf('_')); - Assert.AreEqual(trxPrefix + "_net451", actualFileNameWithoutTimestamp); + Assert.AreNotEqual(Path.Combine(DefaultTestRunDirectory, "results.trx"), _testableTrxLogger.TrxFile, "Expected framework name to appear in file name"); + Assert.AreNotEqual(Path.Combine(DefaultTestRunDirectory, "results_net451.trx"), _testableTrxLogger.TrxFile, "Expected time stamp to appear in file name"); + Assert.AreEqual(Path.Combine(DefaultTestRunDirectory, "results_net451"), actualFileNameWithoutTimestamp); + } - File.Delete(this.testableTrxLogger.trxFile); - } + [TestMethod] + public void CustomTrxFileNameShouldBeConstructedFromAbsoluteLogFilePrefixParameter() + { + _parameters.Remove(TrxLoggerConstants.LogFileNameKey); + var trxPrefix = Path.Combine(Path.GetTempPath(), "results"); + _parameters[TrxLoggerConstants.LogFilePrefixKey] = trxPrefix; + _parameters[DefaultLoggerParameterNames.TargetFramework] = ".NETFramework,Version=4.5.1"; + _testableTrxLogger.Initialize(_events.Object, _parameters); - [TestMethod] - public void IntializeShouldThrowExceptionIfBothPrefixAndNameProvided() - { - this.parameters[TrxLoggerConstants.LogFileNameKey] = "results.trx"; - var trxPrefix = Path.Combine(Path.GetTempPath(), "results"); - this.parameters[TrxLoggerConstants.LogFilePrefixKey] = trxPrefix; - this.parameters[DefaultLoggerParameterNames.TargetFramework] = ".NETFramework,Version=4.5.1"; + MakeTestRunComplete(); - Assert.ThrowsException(() => this.testableTrxLogger.Initialize(events.Object, this.parameters)); - } + string actualFileNameWithoutTimestamp = _testableTrxLogger.TrxFile.Substring(0, _testableTrxLogger.TrxFile.LastIndexOf('_')); - private void ValidateTestIdAndNameInTrx(bool isMstestAdapter) - { - ObjectModel.TestCase testCase = CreateTestCase("TestCase"); - testCase.ExecutorUri = isMstestAdapter ? new Uri("some://mstestadapteruri") : new Uri("some://uri"); + Assert.AreEqual(trxPrefix + "_net451", actualFileNameWithoutTimestamp); - ObjectModel.TestResult result = new ObjectModel.TestResult(testCase); - result.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); - if (isMstestAdapter) - { - result.DisplayName = "testDisplayName"; - } + File.Delete(_testableTrxLogger.TrxFile); + } - Mock resultEventArg = new Mock(result); - this.testableTrxLogger.TestResultHandler(new object(), resultEventArg.Object); - var testRunCompleteEventArgs = TrxLoggerTests.CreateTestRunCompleteEventArgs(); - this.testableTrxLogger.TestRunCompleteHandler(new object(), testRunCompleteEventArgs); + [TestMethod] + public void IntializeShouldThrowExceptionIfBothPrefixAndNameProvided() + { + _parameters[TrxLoggerConstants.LogFileNameKey] = "results.trx"; + var trxPrefix = Path.Combine(Path.GetTempPath(), "results"); + _parameters[TrxLoggerConstants.LogFilePrefixKey] = trxPrefix; + _parameters[DefaultLoggerParameterNames.TargetFramework] = ".NETFramework,Version=4.5.1"; - this.ValidateResultAttributesInTrx(this.testableTrxLogger.trxFile, testCase.Id, testCase.DisplayName, isMstestAdapter); - } + Assert.ThrowsException(() => _testableTrxLogger.Initialize(_events.Object, _parameters)); + } - private void ValidateResultAttributesInTrx(string trxFileName, Guid testId, string testName, bool isMstestAdapter) - { - using (FileStream file = File.OpenRead(trxFileName)) - { - using (XmlReader reader = XmlReader.Create(file)) - { - XDocument document = XDocument.Load(reader); - var resultNode = document.Descendants(document.Root.GetDefaultNamespace() + "UnitTestResult").FirstOrDefault(); - if (isMstestAdapter) - { - Assert.AreNotEqual(resultNode.Attributes("testId").FirstOrDefault().Value, testId.ToString()); - Assert.AreNotEqual(resultNode.Attributes("testName").FirstOrDefault().Value, testName); - } - else - { - Assert.AreEqual(resultNode.Attributes("testId").FirstOrDefault().Value, testId.ToString()); - Assert.AreEqual(resultNode.Attributes("testName").FirstOrDefault().Value, testName); - } - } - } - } + private void ValidateTestIdAndNameInTrx(bool isMstestAdapter) + { + TestCase testCase = CreateTestCase("TestCase"); + testCase.ExecutorUri = isMstestAdapter ? new Uri("some://mstestadapteruri") : new Uri("some://uri"); - private void ValidateTimeWithinUtcLimits(DateTimeOffset dateTime) + ObjectModel.TestResult result = new(testCase); + result.SetPropertyValue(TrxLoggerConstants.ExecutionIdProperty, Guid.NewGuid()); + if (isMstestAdapter) { - Assert.IsTrue(dateTime.UtcDateTime.Subtract(DateTime.UtcNow) < new TimeSpan(0, 0, 0, 60)); + result.DisplayName = "testDisplayName"; } - private string GetElementValueFromTrx(string trxFileName, string fieldName) - { - using (FileStream file = File.OpenRead(trxFileName)) - using (XmlReader reader = XmlReader.Create(file)) - { - while (reader.Read()) - { - if (reader.Name.Equals(fieldName) && reader.NodeType == XmlNodeType.Element) - { - return reader.ReadElementContentAsString(); - } - } - } + Mock resultEventArg = new(result); + _testableTrxLogger.TestResultHandler(new object(), resultEventArg.Object); + var testRunCompleteEventArgs = CreateTestRunCompleteEventArgs(); + _testableTrxLogger.TestRunCompleteHandler(new object(), testRunCompleteEventArgs); - return null; - } + ValidateResultAttributesInTrx(_testableTrxLogger.TrxFile, testCase.Id, testCase.DisplayName, isMstestAdapter); + } - private static TestCase CreateTestCase(string testCaseName) + private void ValidateResultAttributesInTrx(string trxFileName, Guid testId, string testName, bool isMstestAdapter) + { + using FileStream file = File.OpenRead(trxFileName); + using XmlReader reader = XmlReader.Create(file); + XDocument document = XDocument.Load(reader); + var resultNode = document.Descendants(document.Root.GetDefaultNamespace() + "UnitTestResult").FirstOrDefault(); + if (isMstestAdapter) { - return new ObjectModel.TestCase(testCaseName, new Uri("some://uri"), "DummySourceFileName"); + Assert.AreNotEqual(resultNode.Attributes("testId").FirstOrDefault().Value, testId.ToString()); + Assert.AreNotEqual(resultNode.Attributes("testName").FirstOrDefault().Value, testName); } - - private static TestRunCompleteEventArgs CreateTestRunCompleteEventArgs() + else { - var testRunCompleteEventArgs = new TestRunCompleteEventArgs(null, false, false, null, - new Collection(), new Collection(), new TimeSpan(1, 0, 0, 0)); - return testRunCompleteEventArgs; + Assert.AreEqual(resultNode.Attributes("testId").FirstOrDefault().Value, testId.ToString()); + Assert.AreEqual(resultNode.Attributes("testName").FirstOrDefault().Value, testName); } + } - private static Mock CreatePassTestResultEventArgsMock(string testCaseName = "Pass1", List testResultMessages = null) - { - TestCase passTestCase = CreateTestCase(testCaseName); - var passResult = new ObjectModel.TestResult(passTestCase); - passResult.Outcome = TestOutcome.Passed; + private void ValidateTimeWithinUtcLimits(DateTimeOffset dateTime) + { + Assert.IsTrue(dateTime.UtcDateTime.Subtract(DateTime.UtcNow) < new TimeSpan(0, 0, 0, 60)); + } - if (testResultMessages != null && testResultMessages.Any()) + private string GetElementValueFromTrx(string trxFileName, string fieldName) + { + using (FileStream file = File.OpenRead(trxFileName)) + using (XmlReader reader = XmlReader.Create(file)) + { + while (reader.Read()) { - foreach (var message in testResultMessages) + if (reader.Name.Equals(fieldName) && reader.NodeType == XmlNodeType.Element) { - passResult.Messages.Add(message); + return reader.ReadElementContentAsString(); } } - - return new Mock(passResult); } - private void MakeTestRunComplete() => this.MakeTestRunComplete(this.testableTrxLogger); + return null; + } - private void MakeTestRunComplete(TestableTrxLogger testableTrxLogger) - { - var pass = TrxLoggerTests.CreatePassTestResultEventArgsMock(); - testableTrxLogger.TestResultHandler(new object(), pass.Object); - var testRunCompleteEventArgs = TrxLoggerTests.CreateTestRunCompleteEventArgs(); - testableTrxLogger.TestRunCompleteHandler(new object(), testRunCompleteEventArgs); - } + private static TestCase CreateTestCase(string testCaseName) + { + return new TestCase(testCaseName, new Uri("some://uri"), "DummySourceFileName"); } - internal class TestableTrxLogger : TrxLogger + private static TestRunCompleteEventArgs CreateTestRunCompleteEventArgs() { - public TestableTrxLogger() : base() { } - public TestableTrxLogger(IFileHelper fileHelper, TrxFileHelper trxFileHelper) : base(fileHelper, trxFileHelper) { } + var testRunCompleteEventArgs = new TestRunCompleteEventArgs(null, false, false, null, + new Collection(), new Collection(), new TimeSpan(1, 0, 0, 0)); + return testRunCompleteEventArgs; + } + + private static Mock CreatePassTestResultEventArgsMock(string testCaseName = "Pass1", List testResultMessages = null) + { + TestCase passTestCase = CreateTestCase(testCaseName); + var passResult = new ObjectModel.TestResult(passTestCase); + passResult.Outcome = TestOutcome.Passed; - public string trxFile; - internal override void PopulateTrxFile(string trxFileName, XmlElement rootElement) + if (testResultMessages != null && testResultMessages.Any()) { - this.trxFile = trxFileName; - base.PopulateTrxFile(trxFile, rootElement); + foreach (var message in testResultMessages) + { + passResult.Messages.Add(message); + } } + + return new Mock(passResult); + } + + private void MakeTestRunComplete() => MakeTestRunComplete(_testableTrxLogger); + + private void MakeTestRunComplete(TestableTrxLogger testableTrxLogger) + { + var pass = CreatePassTestResultEventArgsMock(); + testableTrxLogger.TestResultHandler(new object(), pass.Object); + var testRunCompleteEventArgs = CreateTestRunCompleteEventArgs(); + testableTrxLogger.TestRunCompleteHandler(new object(), testRunCompleteEventArgs); } } + +internal class TestableTrxLogger : TrxLogger +{ + public TestableTrxLogger() : base() { } + public TestableTrxLogger(IFileHelper fileHelper, TrxFileHelper trxFileHelper) : base(fileHelper, trxFileHelper) { } + + public string TrxFile; + internal override void PopulateTrxFile(string trxFileName, XmlElement rootElement) + { + TrxFile = trxFileName; + base.PopulateTrxFile(TrxFile, rootElement); + } +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/Utility/ConverterTests.cs b/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/Utility/ConverterTests.cs index 3630e668bb..1e8864df3a 100644 --- a/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/Utility/ConverterTests.cs +++ b/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/Utility/ConverterTests.cs @@ -1,260 +1,256 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests.Utility +namespace Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests.Utility; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using VisualStudio.TestTools.UnitTesting; +using ObjectModel; +using TestPlatformObjectModel = VisualStudio.TestPlatform.ObjectModel; +using TestOutcome = VisualStudio.TestPlatform.ObjectModel.TestOutcome; +using TrxLoggerConstants = TrxLogger.Utility.Constants; +using TrxLoggerOutcome = ObjectModel.TestOutcome; +using UriDataAttachment = VisualStudio.TestPlatform.ObjectModel.UriDataAttachment; +using Moq; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; + +[TestClass] +public class ConverterTests { - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using ObjectModel; - using TestPlatformObjectModel = Microsoft.VisualStudio.TestPlatform.ObjectModel; - using TestOutcome = VisualStudio.TestPlatform.ObjectModel.TestOutcome; - using TrxLoggerConstants = Microsoft.TestPlatform.Extensions.TrxLogger.Utility.Constants; - using TrxLoggerOutcome = Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel.TestOutcome; - using UriDataAttachment = VisualStudio.TestPlatform.ObjectModel.UriDataAttachment; - using Moq; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - - [TestClass] - public class ConverterTests + private Converter _converter; + private readonly Mock _fileHelper; + private readonly TrxFileHelper _trxFileHelper; + + public ConverterTests() { - private Converter converter; - private Mock fileHelper; - private readonly TrxFileHelper trxFileHelper; + _fileHelper = new Mock(); + _trxFileHelper = new TrxFileHelper(); + _converter = new Converter(_fileHelper.Object, _trxFileHelper); + } - public ConverterTests() - { - this.fileHelper = new Mock(); - this.trxFileHelper = new TrxFileHelper(); - this.converter = new Converter(this.fileHelper.Object, trxFileHelper); - } + [TestMethod] + public void ToOutcomeShouldMapFailedToFailed() + { + Assert.AreEqual(TrxLoggerOutcome.Failed, _converter.ToOutcome(TestOutcome.Failed)); + } - [TestMethod] - public void ToOutcomeShouldMapFailedToFailed() - { - Assert.AreEqual(TrxLoggerOutcome.Failed, this.converter.ToOutcome(TestOutcome.Failed)); - } + [TestMethod] + public void ToOutcomeShouldMapPassedToPassed() + { + Assert.AreEqual(TrxLoggerOutcome.Passed, _converter.ToOutcome(TestOutcome.Passed)); + } - [TestMethod] - public void ToOutcomeShouldMapPassedToPassed() - { - Assert.AreEqual(TrxLoggerOutcome.Passed, this.converter.ToOutcome(TestOutcome.Passed)); - } + [TestMethod] + public void ToOutcomeShouldMapSkippedToNotExecuted() + { + Assert.AreEqual(TrxLoggerOutcome.NotExecuted, _converter.ToOutcome(TestOutcome.Skipped)); + } - [TestMethod] - public void ToOutcomeShouldMapSkippedToNotExecuted() - { - Assert.AreEqual(TrxLoggerOutcome.NotExecuted, this.converter.ToOutcome(TestOutcome.Skipped)); - } + [TestMethod] + public void ToOutcomeShouldMapNoneToNotExecuted() + { + Assert.AreEqual(TrxLoggerOutcome.NotExecuted, _converter.ToOutcome(TestOutcome.None)); + } - [TestMethod] - public void ToOutcomeShouldMapNoneToNotExecuted() - { - Assert.AreEqual(TrxLoggerOutcome.NotExecuted, this.converter.ToOutcome(TestOutcome.None)); - } + [TestMethod] + public void ToOutcomeShouldMapNotFoundToNotExecuted() + { + Assert.AreEqual(TrxLoggerOutcome.NotExecuted, _converter.ToOutcome(TestOutcome.NotFound)); + } - [TestMethod] - public void ToOutcomeShouldMapNotFoundToNotExecuted() - { - Assert.AreEqual(TrxLoggerOutcome.NotExecuted, this.converter.ToOutcome(TestOutcome.NotFound)); - } + [TestMethod] + public void ToCollectionEntriesShouldRenameAttachmentUriIfTheAttachmentNameIsSame() + { + SetupForToCollectionEntries(out var tempDir, out var attachmentSets, out var testRun, out var testResultsDirectory); - [TestMethod] - public void ToCollectionEntriesShouldRenameAttachmentUriIfTheAttachmentNameIsSame() - { - ConverterTests.SetupForToCollectionEntries(out var tempDir, out var attachmentSets, out var testRun, out var testResultsDirectory); + _converter = new Converter(new FileHelper(), _trxFileHelper); + List collectorDataEntries = _converter.ToCollectionEntries(attachmentSets, testRun, testResultsDirectory); - this.converter = new Converter(new FileHelper(), trxFileHelper); - List collectorDataEntries = this.converter.ToCollectionEntries(attachmentSets, testRun, testResultsDirectory); + Assert.AreEqual(2, collectorDataEntries[0].Attachments.Count); + Assert.AreEqual($@"{Environment.MachineName}{Path.DirectorySeparatorChar}123.coverage", ((ObjectModel.UriDataAttachment)collectorDataEntries[0].Attachments[0]).Uri.OriginalString); + Assert.AreEqual($@"{Environment.MachineName}{Path.DirectorySeparatorChar}123[1].coverage", ((ObjectModel.UriDataAttachment)collectorDataEntries[0].Attachments[1]).Uri.OriginalString); - Assert.AreEqual(2, collectorDataEntries[0].Attachments.Count); - Assert.AreEqual($@"{Environment.MachineName}{Path.DirectorySeparatorChar}123.coverage", ((ObjectModel.UriDataAttachment) collectorDataEntries[0].Attachments[0]).Uri.OriginalString); - Assert.AreEqual($@"{Environment.MachineName}{Path.DirectorySeparatorChar}123[1].coverage", ((ObjectModel.UriDataAttachment)collectorDataEntries[0].Attachments[1]).Uri.OriginalString); + Directory.Delete(tempDir, true); + } - Directory.Delete(tempDir, true); - } + /// + /// Unit test for assigning or populating test categories read to the unit test element. + /// + [TestMethod] + public void ToTestElementShouldAssignTestCategoryOfUnitTestElement() + { + TestCase testCase = CreateTestCase("TestCase1"); + TestPlatformObjectModel.TestResult result = new(testCase); + TestProperty testProperty = TestProperty.Register("MSTestDiscoverer.TestCategory", "String array property", string.Empty, string.Empty, typeof(string[]), null, TestPropertyAttributes.Hidden, typeof(TestObject)); - /// - /// Unit test for assigning or populating test categories read to the unit test element. - /// - [TestMethod] - public void ToTestElementShouldAssignTestCategoryOfUnitTestElement() - { - TestPlatformObjectModel.TestCase testCase = CreateTestCase("TestCase1"); - TestPlatformObjectModel.TestResult result = new TestPlatformObjectModel.TestResult(testCase); - TestProperty testProperty = TestProperty.Register("MSTestDiscoverer.TestCategory", "String array property", string.Empty, string.Empty, typeof(string[]), null, TestPropertyAttributes.Hidden, typeof(TestObject)); + testCase.SetPropertyValue(testProperty, new[] { "AsmLevel", "ClassLevel", "MethodLevel" }); - testCase.SetPropertyValue(testProperty, new[] { "AsmLevel", "ClassLevel", "MethodLevel" }); + var unitTestElement = _converter.ToTestElement(testCase.Id, Guid.Empty, Guid.Empty, testCase.DisplayName, TrxLoggerConstants.UnitTestType, testCase); - var unitTestElement = this.converter.ToTestElement(testCase.Id, Guid.Empty, Guid.Empty, testCase.DisplayName, TrxLoggerConstants.UnitTestType, testCase); + object[] expected = new[] { "MethodLevel", "ClassLevel", "AsmLevel" }; - object[] expected = new[] { "MethodLevel", "ClassLevel", "AsmLevel" }; + CollectionAssert.AreEqual(expected, unitTestElement.TestCategories.ToArray().OrderByDescending(x => x).ToArray()); + } - CollectionAssert.AreEqual(expected, unitTestElement.TestCategories.ToArray().OrderByDescending(x => x).ToArray()); - } + [TestMethod] + public void ToTestElementShouldAssignWorkItemOfUnitTestElement() + { + TestCase testCase = CreateTestCase("TestCase1"); + TestPlatformObjectModel.TestResult result = new(testCase); + TestProperty testProperty = TestProperty.Register("WorkItemIds", "String array property", string.Empty, string.Empty, typeof(string[]), null, TestPropertyAttributes.Hidden, typeof(TestObject)); - [TestMethod] - public void ToTestElementShouldAssignWorkitemOfUnitTestElement() - { - TestPlatformObjectModel.TestCase testCase = CreateTestCase("TestCase1"); - TestPlatformObjectModel.TestResult result = new TestPlatformObjectModel.TestResult(testCase); - TestProperty testProperty = TestProperty.Register("WorkItemIds", "String array property", string.Empty, string.Empty, typeof(string[]), null, TestPropertyAttributes.Hidden, typeof(TestObject)); + testCase.SetPropertyValue(testProperty, new[] { "3", "99999", "0" }); - testCase.SetPropertyValue(testProperty, new[] { "3", "99999", "0" }); + var unitTestElement = _converter.ToTestElement(testCase.Id, Guid.Empty, Guid.Empty, testCase.DisplayName, TrxLoggerConstants.UnitTestType, testCase); - var unitTestElement = this.converter.ToTestElement(testCase.Id, Guid.Empty, Guid.Empty, testCase.DisplayName, TrxLoggerConstants.UnitTestType, testCase); + int[] expected = new[] { 0, 3, 99999 }; - int[] expected = new[] { 0, 3, 99999 }; + CollectionAssert.AreEquivalent(expected, unitTestElement.WorkItems.ToArray()); + } - CollectionAssert.AreEquivalent(expected, unitTestElement.WorkItems.ToArray()); - } + /// + /// Unit test for regression when there's no test categories. + /// + [TestMethod] + public void ToTestElementShouldNotFailWhenThereIsNoTestCategories() + { + TestCase testCase = CreateTestCase("TestCase1"); - /// - /// Unit test for regression when there's no test categories. - /// - [TestMethod] - public void ToTestElementShouldNotFailWhenThereIsNoTestCategoreis() - { - TestPlatformObjectModel.TestCase testCase = CreateTestCase("TestCase1"); - TestPlatformObjectModel.TestResult result = new TestPlatformObjectModel.TestResult(testCase); + var unitTestElement = _converter.ToTestElement(testCase.Id, Guid.Empty, Guid.Empty, testCase.DisplayName, TrxLoggerConstants.UnitTestType, testCase); - var unitTestElement = this.converter.ToTestElement(testCase.Id, Guid.Empty, Guid.Empty, testCase.DisplayName, TrxLoggerConstants.UnitTestType, testCase); + object[] expected = Enumerable.Empty().ToArray(); - object[] expected = Enumerable.Empty().ToArray(); + CollectionAssert.AreEqual(expected, unitTestElement.TestCategories.ToArray()); + } - CollectionAssert.AreEqual(expected, unitTestElement.TestCategories.ToArray()); - } + [TestMethod] + public void ToTestElementShouldContainExpectedTestMethodPropertiesIfFqnIsSameAsTestName() + { + var expectedClassName = "TestProject1.Class1"; + var expectedTestName = "TestMethod1"; + var fullyQualifiedName = expectedClassName + "." + expectedTestName; + var testName = "TestProject1.Class1.TestMethod1"; - [TestMethod] - public void ToTestElementShouldContainExpectedTestMethodPropertiesIfFqnIsSameAsTestName() - { - var expectedClassName = "TestProject1.Class1"; - var expectedTestName = "TestMethod1"; - var fullyQualifiedName = expectedClassName + "." + expectedTestName; - var testName = "TestProject1.Class1.TestMethod1"; + ValidateTestMethodProperties(testName, fullyQualifiedName, expectedClassName, expectedTestName); + } - ValidateTestMethodProperties(testName, fullyQualifiedName, expectedClassName, expectedTestName); - } + [TestMethod] + public void ToTestElementShouldContainExpectedTestMethodPropertiesIfFqnEndsWithTestName() + { + var expectedClassName = "TestProject1.Class1"; + var expectedTestName = "TestMethod1(2, 3, 4.0d)"; + var fullyQualifiedName = expectedClassName + "." + expectedTestName; + var testName = "TestMethod1(2, 3, 4.0d)"; - [TestMethod] - public void ToTestElementShouldContainExpectedTestMethodPropertiesIfFqnEndsWithTestName() - { - var expectedClassName = "TestProject1.Class1"; - var expectedTestName = "TestMethod1(2, 3, 4.0d)"; - var fullyQualifiedName = expectedClassName + "." + expectedTestName; - var testName = "TestMethod1(2, 3, 4.0d)"; + ValidateTestMethodProperties(testName, fullyQualifiedName, expectedClassName, expectedTestName); + } - ValidateTestMethodProperties(testName, fullyQualifiedName, expectedClassName, expectedTestName); - } + [TestMethod] + public void ToTestElementShouldContainExpectedTestMethodPropertiesIfFqnDoesNotEndsWithTestName() + { + var expectedClassName = "TestProject1.Class1.TestMethod1(2, 3, 4"; + var expectedTestName = "0d)"; + var fullyQualifiedName = "TestProject1.Class1.TestMethod1(2, 3, 4." + expectedTestName; + var testName = "TestMethod1"; - [TestMethod] - public void ToTestElementShouldContainExpectedTestMethodPropertiesIfFqnDoesNotEndsWithTestName() - { - var expectedClassName = "TestProject1.Class1.TestMethod1(2, 3, 4"; - var expectedTestName = "0d)"; - var fullyQualifiedName = "TestProject1.Class1.TestMethod1(2, 3, 4." + expectedTestName; - var testName = "TestMethod1"; + ValidateTestMethodProperties(testName, fullyQualifiedName, expectedClassName, expectedTestName); + } - ValidateTestMethodProperties(testName, fullyQualifiedName, expectedClassName, expectedTestName); - } + [TestMethod] + public void ToResultFilesShouldAddAttachmentsWithRelativeUri() + { + UriDataAttachment uriDataAttachment1 = + new(new Uri($"/mnt/c/abc.txt", UriKind.Relative), "Description 1"); - [TestMethod] - public void ToResultFilesShouldAddAttachmentsWithRelativeURI() + var attachmentSets = new List { - UriDataAttachment uriDataAttachment1 = - new UriDataAttachment(new Uri($"/mnt/c/abc.txt", UriKind.Relative), "Description 1"); + new AttachmentSet(new Uri("xyz://microsoft/random/2.0"), "XPlat test run") + }; - var attachmentSets = new List - { - new AttachmentSet(new Uri("xyz://microsoft/random/2.0"), "XPlat test run") - }; + var testRun = new TestRun(Guid.NewGuid()); + testRun.RunConfiguration = new TestRunConfiguration("Testrun 1", _trxFileHelper); + attachmentSets[0].Attachments.Add(uriDataAttachment1); - var testRun = new TestRun(Guid.NewGuid()); - testRun.RunConfiguration = new TestRunConfiguration("Testrun 1", trxFileHelper); - attachmentSets[0].Attachments.Add(uriDataAttachment1); + var resultFiles = _converter.ToResultFiles(attachmentSets, testRun, @"c:\temp", null); + Assert.IsTrue(resultFiles[0].Contains("abc.txt")); + } - var resultFiles = this.converter.ToResultFiles(attachmentSets, testRun, @"c:\temp", null); - Assert.IsTrue(resultFiles[0].Contains("abc.txt")); - } + [TestMethod] + public void ToTestElementShouldNotFailWhenClassNameIsTheSameAsFullyQualifiedName() + { + // the converter assumed to find 'classname' in the fqn and split it on 'classname.' + // but that threw an exception because 'classname.' is not contained in 'classname' + // (notice the . at the end) + // we should not be assuming that the fqn will have '.' in them + // seen it for example with qtest - [TestMethod] - public void ToTestElementShouldNotFailWhenClassNameIsTheSameAsFullyQualifiedName() - { - // the converter assumed to find 'classname' in the fqn and split it on 'classname.' - // but that threw an exception because 'classname.' is not contained in 'classname' - // (notice the . at the end) - // we should not be assuming that the fqn will have '.' in them - // seen it for example with qtest - - string expectedClassName, expectedTestName, fullyQualifiedName, source, testName; - expectedClassName = expectedTestName = fullyQualifiedName = source = testName = "test1"; - - TestPlatformObjectModel.TestCase testCase = new TestPlatformObjectModel.TestCase(fullyQualifiedName, new Uri("some://uri"), source); - TestPlatformObjectModel.TestResult result = new TestPlatformObjectModel.TestResult(testCase); - var unitTestElement = this.converter.ToTestElement(testCase.Id, Guid.Empty, Guid.Empty, testName, TrxLoggerConstants.UnitTestType, testCase) as UnitTestElement; - - Assert.AreEqual(expectedClassName, unitTestElement.TestMethod.ClassName); - Assert.AreEqual(expectedTestName, unitTestElement.TestMethod.Name); - } - - private void ValidateTestMethodProperties(string testName, string fullyQualifiedName, string expectedClassName, string expectedTestName) - { - TestPlatformObjectModel.TestCase testCase = CreateTestCase(fullyQualifiedName); - TestPlatformObjectModel.TestResult result = new TestPlatformObjectModel.TestResult(testCase); + string expectedClassName, expectedTestName, fullyQualifiedName, source, testName; + expectedClassName = expectedTestName = fullyQualifiedName = source = testName = "test1"; - var unitTestElement = this.converter.ToTestElement(testCase.Id, Guid.Empty, Guid.Empty, testName, TrxLoggerConstants.UnitTestType, testCase) as UnitTestElement; + TestCase testCase = new(fullyQualifiedName, new Uri("some://uri"), source); + var unitTestElement = _converter.ToTestElement(testCase.Id, Guid.Empty, Guid.Empty, testName, TrxLoggerConstants.UnitTestType, testCase) as UnitTestElement; - Assert.AreEqual(expectedClassName, unitTestElement.TestMethod.ClassName); - Assert.AreEqual(expectedTestName, unitTestElement.TestMethod.Name); - } + Assert.AreEqual(expectedClassName, unitTestElement.TestMethod.ClassName); + Assert.AreEqual(expectedTestName, unitTestElement.TestMethod.Name); + } - private static TestCase CreateTestCase(string fullyQualifiedName) - { - return new TestPlatformObjectModel.TestCase(fullyQualifiedName, new Uri("some://uri"), "DummySourceFileName"); - } + private void ValidateTestMethodProperties(string testName, string fullyQualifiedName, string expectedClassName, string expectedTestName) + { + TestCase testCase = CreateTestCase(fullyQualifiedName); - private static void SetupForToCollectionEntries(out string tempDir, out List attachmentSets, out TestRun testRun, - out string testResultsDirectory) - { - ConverterTests.CreateTempCoverageFiles(out tempDir, out var coverageFilePath1, out var coverageFilePath2); - - UriDataAttachment uriDataAttachment1 = - new UriDataAttachment(new Uri(new Uri("file://"), coverageFilePath1), "Description 1"); - UriDataAttachment uriDataAttachment2 = - new UriDataAttachment(new Uri(new Uri("file://"), coverageFilePath2), "Description 2"); - attachmentSets = new List - { - new AttachmentSet(new Uri("datacollector://microsoft/CodeCoverage/2.0"), "Code Coverage") - }; - - testRun = new TestRun(Guid.NewGuid()); - testRun.RunConfiguration = new TestRunConfiguration("Testrun 1", new TrxFileHelper()); - attachmentSets[0].Attachments.Add(uriDataAttachment1); - attachmentSets[0].Attachments.Add(uriDataAttachment2); - testResultsDirectory = Path.Combine(tempDir, "TestResults"); - } - - private static void CreateTempCoverageFiles(out string tempDir, out string coverageFilePath1, - out string coverageFilePath2) + var unitTestElement = _converter.ToTestElement(testCase.Id, Guid.Empty, Guid.Empty, testName, TrxLoggerConstants.UnitTestType, testCase) as UnitTestElement; + + Assert.AreEqual(expectedClassName, unitTestElement.TestMethod.ClassName); + Assert.AreEqual(expectedTestName, unitTestElement.TestMethod.Name); + } + + private static TestCase CreateTestCase(string fullyQualifiedName) + { + return new TestCase(fullyQualifiedName, new Uri("some://uri"), "DummySourceFileName"); + } + + private static void SetupForToCollectionEntries(out string tempDir, out List attachmentSets, out TestRun testRun, + out string testResultsDirectory) + { + CreateTempCoverageFiles(out tempDir, out var coverageFilePath1, out var coverageFilePath2); + + UriDataAttachment uriDataAttachment1 = + new(new Uri(new Uri("file://"), coverageFilePath1), "Description 1"); + UriDataAttachment uriDataAttachment2 = + new(new Uri(new Uri("file://"), coverageFilePath2), "Description 2"); + attachmentSets = new List { - tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); + new AttachmentSet(new Uri("datacollector://microsoft/CodeCoverage/2.0"), "Code Coverage") + }; + + testRun = new TestRun(Guid.NewGuid()); + testRun.RunConfiguration = new TestRunConfiguration("Testrun 1", new TrxFileHelper()); + attachmentSets[0].Attachments.Add(uriDataAttachment1); + attachmentSets[0].Attachments.Add(uriDataAttachment2); + testResultsDirectory = Path.Combine(tempDir, "TestResults"); + } + + private static void CreateTempCoverageFiles(out string tempDir, out string coverageFilePath1, + out string coverageFilePath2) + { + tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); - var covDir1 = Path.Combine(tempDir, Guid.NewGuid().ToString()); - var covDir2 = Path.Combine(tempDir, Guid.NewGuid().ToString()); + var covDir1 = Path.Combine(tempDir, Guid.NewGuid().ToString()); + var covDir2 = Path.Combine(tempDir, Guid.NewGuid().ToString()); - Directory.CreateDirectory(covDir1); - Directory.CreateDirectory(covDir2); + Directory.CreateDirectory(covDir1); + Directory.CreateDirectory(covDir2); - coverageFilePath1 = Path.Combine(covDir1, "123.coverage"); - coverageFilePath2 = Path.Combine(covDir2, "123.coverage"); + coverageFilePath1 = Path.Combine(covDir1, "123.coverage"); + coverageFilePath2 = Path.Combine(covDir2, "123.coverage"); - File.WriteAllText(coverageFilePath1, string.Empty); - File.WriteAllText(coverageFilePath2, string.Empty); - } + File.WriteAllText(coverageFilePath1, string.Empty); + File.WriteAllText(coverageFilePath2, string.Empty); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/Utility/TrxFileHelperTests.cs b/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/Utility/TrxFileHelperTests.cs index 50797dd0b7..3dad959aca 100644 --- a/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/Utility/TrxFileHelperTests.cs +++ b/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/Utility/TrxFileHelperTests.cs @@ -1,20 +1,20 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests.Utility -{ - using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests.Utility; + +using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; - [TestClass] - public class TrxFileHelperTests +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class TrxFileHelperTests +{ + [TestMethod] + public void ReplaceInvalidFileNameCharsShouldReplaceSpace() { - [TestMethod] - public void ReplaceInvalidFileNameCharsShouldReplaceSpace() - { - var fileHelper = new TrxFileHelper(); + var fileHelper = new TrxFileHelper(); - Assert.AreEqual("samadala_SAMADALA_2017-10-13_18_33_17", fileHelper.ReplaceInvalidFileNameChars("samadala_SAMADALA 2017-10-13 18_33_17")); - } + Assert.AreEqual("samadala_SAMADALA_2017-10-13_18_33_17", fileHelper.ReplaceInvalidFileNameChars("samadala_SAMADALA 2017-10-13 18_33_17")); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/XmlPersistenceTests.cs b/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/XmlPersistenceTests.cs index 49a0ce11b9..d2b558ae4b 100644 --- a/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/XmlPersistenceTests.cs +++ b/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/XmlPersistenceTests.cs @@ -1,71 +1,70 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests -{ - using Microsoft.TestPlatform.Extensions.TrxLogger.XML; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests; + +using XML; +using VisualStudio.TestTools.UnitTesting; - [TestClass] - public class XmlPersistenceTests +[TestClass] +public class XmlPersistenceTests +{ + [TestMethod] + public void SaveObjectShouldReplaceInvalidCharacter() { - [TestMethod] - public void SaveObjectShouldReplaceInvalidCharacter() - { - XmlPersistence xmlPersistence = new XmlPersistence(); - var node = xmlPersistence.CreateRootElement("TestRun"); + XmlPersistence xmlPersistence = new(); + var node = xmlPersistence.CreateRootElement("TestRun"); - // we are handling only #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] - char[] invalidXmlCharacterArray = new char[7]; - invalidXmlCharacterArray[0] = (char)0x5; - invalidXmlCharacterArray[1] = (char)0xb; - invalidXmlCharacterArray[2] = (char)0xf; - invalidXmlCharacterArray[3] = (char)0xd800; - invalidXmlCharacterArray[4] = (char)0xdc00; - invalidXmlCharacterArray[5] = (char)0xfffe; - invalidXmlCharacterArray[6] = (char)0x0; + // we are handling only #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] + char[] invalidXmlCharacterArray = new char[7]; + invalidXmlCharacterArray[0] = (char)0x5; + invalidXmlCharacterArray[1] = (char)0xb; + invalidXmlCharacterArray[2] = (char)0xf; + invalidXmlCharacterArray[3] = (char)0xd800; + invalidXmlCharacterArray[4] = (char)0xdc00; + invalidXmlCharacterArray[5] = (char)0xfffe; + invalidXmlCharacterArray[6] = (char)0x0; - string strWithInvalidCharForXml = new string(invalidXmlCharacterArray); - xmlPersistence.SaveObject(strWithInvalidCharForXml, node, null, "dummy"); + string strWithInvalidCharForXml = new(invalidXmlCharacterArray); + xmlPersistence.SaveObject(strWithInvalidCharForXml, node, null, "dummy"); - string expectedResult = "\\u0005\\u000b\\u000f\\ud800\\udc00\\ufffe\\u0000"; - Assert.AreEqual(0, string.Compare(expectedResult, node.InnerXml)); - } + string expectedResult = "\\u0005\\u000b\\u000f\\ud800\\udc00\\ufffe\\u0000"; + Assert.AreEqual(0, string.Compare(expectedResult, node.InnerXml)); + } - [TestMethod] - public void SaveObjectShouldNotReplaceValidCharacter() - { - XmlPersistence xmlPersistence = new XmlPersistence(); - var node = xmlPersistence.CreateRootElement("TestRun"); + [TestMethod] + public void SaveObjectShouldNotReplaceValidCharacter() + { + XmlPersistence xmlPersistence = new(); + var node = xmlPersistence.CreateRootElement("TestRun"); - // we are handling only #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] - char[] validXmlCharacterArray = new char[8]; - validXmlCharacterArray[0] = (char)0x9; - validXmlCharacterArray[1] = (char)0xa; - validXmlCharacterArray[2] = (char)0xd; - validXmlCharacterArray[3] = (char)0x20; - validXmlCharacterArray[4] = (char)0xc123; - validXmlCharacterArray[5] = (char)0xe000; - validXmlCharacterArray[6] = (char)0xea12; - validXmlCharacterArray[7] = (char)0xfffd; + // we are handling only #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] + char[] validXmlCharacterArray = new char[8]; + validXmlCharacterArray[0] = (char)0x9; + validXmlCharacterArray[1] = (char)0xa; + validXmlCharacterArray[2] = (char)0xd; + validXmlCharacterArray[3] = (char)0x20; + validXmlCharacterArray[4] = (char)0xc123; + validXmlCharacterArray[5] = (char)0xe000; + validXmlCharacterArray[6] = (char)0xea12; + validXmlCharacterArray[7] = (char)0xfffd; - string strWithValidCharForXml = new string(validXmlCharacterArray); + string strWithValidCharForXml = new(validXmlCharacterArray); - xmlPersistence.SaveObject(strWithValidCharForXml, node, null, "dummy"); + xmlPersistence.SaveObject(strWithValidCharForXml, node, null, "dummy"); - string expectedResult = "\t\n\r 섣�"; - Assert.AreEqual(0, string.Compare(expectedResult, node.InnerXml)); - } + string expectedResult = "\t\n\r 섣�"; + Assert.AreEqual(0, string.Compare(expectedResult, node.InnerXml)); + } - [TestMethod] - public void SaveObjectShouldReplaceOnlyInvalidCharacter() - { - XmlPersistence xmlPersistence = new XmlPersistence(); - var node = xmlPersistence.CreateRootElement("TestRun"); - string strWithInvalidCharForXml = "This string has these \0 \v invalid characters"; - xmlPersistence.SaveObject(strWithInvalidCharForXml, node, null, "dummy"); - string expectedResult = "This string has these \\u0000 \\u000b invalid characters"; - Assert.AreEqual(0, string.Compare(expectedResult, node.InnerXml)); - } + [TestMethod] + public void SaveObjectShouldReplaceOnlyInvalidCharacter() + { + XmlPersistence xmlPersistence = new(); + var node = xmlPersistence.CreateRootElement("TestRun"); + string strWithInvalidCharForXml = "This string has these \0 \v invalid characters"; + xmlPersistence.SaveObject(strWithInvalidCharForXml, node, null, "dummy"); + string expectedResult = "This string has these \\u0000 \\u000b invalid characters"; + Assert.AreEqual(0, string.Compare(expectedResult, node.InnerXml)); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.ObjectModel.PlatformTests/DiaSessionTests.cs b/test/Microsoft.TestPlatform.ObjectModel.PlatformTests/DiaSessionTests.cs index fcda7cb429..df3699427b 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.PlatformTests/DiaSessionTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.PlatformTests/DiaSessionTests.cs @@ -1,162 +1,162 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.ObjectModel.PlatformTests -{ - using System; - using System.Diagnostics; +namespace Microsoft.TestPlatform.ObjectModel.PlatformTests; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Diagnostics; - [TestClass] - public class DiaSessionTests : IntegrationTestBase - { - private const string NET451 = "net451"; - private const string NETCOREAPP21 = "netcoreapp2.1"; +using Microsoft.TestPlatform.TestUtilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestTools.UnitTesting; - public static string GetAndSetTargetFrameWork(IntegrationTestEnvironment testEnvironment) - { - var currentTargetFrameWork = testEnvironment.TargetFramework; +[TestClass] +public class DiaSessionTests : IntegrationTestBase +{ + private const string NET451 = "net451"; + private const string NETCOREAPP21 = "netcoreapp2.1"; + + public static string GetAndSetTargetFrameWork(IntegrationTestEnvironment testEnvironment) + { + var currentTargetFrameWork = testEnvironment.TargetFramework; + testEnvironment.TargetFramework = #if NETFRAMEWORK - testEnvironment.TargetFramework = NET451; + NET451; #else - testEnvironment.TargetFramework = NETCOREAPP21; + NETCOREAPP21; #endif - return currentTargetFrameWork; - } + return currentTargetFrameWork; + } - [TestMethod] - public void GetNavigationDataShouldReturnCorrectFileNameAndLineNumber() - { - var currentTargetFrameWork = GetAndSetTargetFrameWork(this.testEnvironment); - var assemblyPath = GetAssetFullPath("SimpleClassLibrary.dll"); + [TestMethod] + public void GetNavigationDataShouldReturnCorrectFileNameAndLineNumber() + { + var currentTargetFrameWork = GetAndSetTargetFrameWork(_testEnvironment); + var assemblyPath = GetAssetFullPath("SimpleClassLibrary.dll"); - DiaSession diaSession = new DiaSession(assemblyPath); - DiaNavigationData diaNavigationData = diaSession.GetNavigationData("SimpleClassLibrary.Class1", "PassingTest"); + var diaSession = new DiaSession(assemblyPath); + DiaNavigationData diaNavigationData = diaSession.GetNavigationData("SimpleClassLibrary.Class1", "PassingTest"); - Assert.IsNotNull(diaNavigationData, "Failed to get navigation data"); - StringAssert.EndsWith(diaNavigationData.FileName, @"\SimpleClassLibrary\Class1.cs"); + Assert.IsNotNull(diaNavigationData, "Failed to get navigation data"); + StringAssert.EndsWith(diaNavigationData.FileName, @"\SimpleClassLibrary\Class1.cs"); - this.ValidateMinLineNumber(12, diaNavigationData.MinLineNumber); - Assert.AreEqual(14, diaNavigationData.MaxLineNumber, "Incorrect max line number"); + ValidateMinLineNumber(11, diaNavigationData.MinLineNumber); + Assert.AreEqual(13, diaNavigationData.MaxLineNumber, "Incorrect max line number"); - this.testEnvironment.TargetFramework = currentTargetFrameWork; - } + _testEnvironment.TargetFramework = currentTargetFrameWork; + } - [TestMethod] - public void GetNavigationDataShouldReturnCorrectDataForAsyncMethod() - { - var currentTargetFrameWork = GetAndSetTargetFrameWork(this.testEnvironment); - var assemblyPath = this.GetAssetFullPath("SimpleClassLibrary.dll"); + [TestMethod] + public void GetNavigationDataShouldReturnCorrectDataForAsyncMethod() + { + var currentTargetFrameWork = GetAndSetTargetFrameWork(_testEnvironment); + var assemblyPath = GetAssetFullPath("SimpleClassLibrary.dll"); - DiaSession diaSession = new DiaSession(assemblyPath); - DiaNavigationData diaNavigationData = diaSession.GetNavigationData("SimpleClassLibrary.Class1+d__1", "MoveNext"); + var diaSession = new DiaSession(assemblyPath); + DiaNavigationData diaNavigationData = diaSession.GetNavigationData("SimpleClassLibrary.Class1+d__1", "MoveNext"); - Assert.IsNotNull(diaNavigationData, "Failed to get navigation data"); - StringAssert.EndsWith(diaNavigationData.FileName, @"\SimpleClassLibrary\Class1.cs"); + Assert.IsNotNull(diaNavigationData, "Failed to get navigation data"); + StringAssert.EndsWith(diaNavigationData.FileName, @"\SimpleClassLibrary\Class1.cs"); - this.ValidateMinLineNumber(17, diaNavigationData.MinLineNumber); - Assert.AreEqual(19, diaNavigationData.MaxLineNumber, "Incorrect max line number"); + ValidateMinLineNumber(16, diaNavigationData.MinLineNumber); + Assert.AreEqual(18, diaNavigationData.MaxLineNumber, "Incorrect max line number"); - this.testEnvironment.TargetFramework = currentTargetFrameWork; - } + _testEnvironment.TargetFramework = currentTargetFrameWork; + } - [TestMethod] - public void GetNavigationDataShouldReturnCorrectDataForOverLoadedMethod() - { - var currentTargetFrameWork = GetAndSetTargetFrameWork(this.testEnvironment); - var assemblyPath = this.GetAssetFullPath("SimpleClassLibrary.dll"); + [TestMethod] + public void GetNavigationDataShouldReturnCorrectDataForOverLoadedMethod() + { + var currentTargetFrameWork = GetAndSetTargetFrameWork(_testEnvironment); + var assemblyPath = GetAssetFullPath("SimpleClassLibrary.dll"); - DiaSession diaSession = new DiaSession(assemblyPath); - DiaNavigationData diaNavigationData = diaSession.GetNavigationData("SimpleClassLibrary.Class1", "OverLoadedMethod"); + var diaSession = new DiaSession(assemblyPath); + DiaNavigationData diaNavigationData = diaSession.GetNavigationData("SimpleClassLibrary.Class1", "OverLoadedMethod"); - Assert.IsNotNull(diaNavigationData, "Failed to get navigation data"); - StringAssert.EndsWith(diaNavigationData.FileName, @"\SimpleClassLibrary\Class1.cs"); + Assert.IsNotNull(diaNavigationData, "Failed to get navigation data"); + StringAssert.EndsWith(diaNavigationData.FileName, @"\SimpleClassLibrary\Class1.cs"); - // Weird why DiaSession is now returning the first overloaded method - // as compared to before when it used to return second method - this.ValidateLineNumbers(diaNavigationData.MinLineNumber, diaNavigationData.MaxLineNumber); + // Weird why DiaSession is now returning the first overloaded method + // as compared to before when it used to return second method + ValidateLineNumbers(diaNavigationData.MinLineNumber, diaNavigationData.MaxLineNumber); - this.testEnvironment.TargetFramework = currentTargetFrameWork; - } + _testEnvironment.TargetFramework = currentTargetFrameWork; + } - [TestMethod] - public void GetNavigationDataShouldReturnNullForNotExistMethodNameOrNotExistTypeName() - { - var currentTargetFrameWork = GetAndSetTargetFrameWork(this.testEnvironment); - var assemblyPath = GetAssetFullPath("SimpleClassLibrary.dll"); + [TestMethod] + public void GetNavigationDataShouldReturnNullForNotExistMethodNameOrNotExistTypeName() + { + var currentTargetFrameWork = GetAndSetTargetFrameWork(_testEnvironment); + var assemblyPath = GetAssetFullPath("SimpleClassLibrary.dll"); - DiaSession diaSession = new DiaSession(assemblyPath); + var diaSession = new DiaSession(assemblyPath); - // Not exist method name - DiaNavigationData diaNavigationData = diaSession.GetNavigationData("SimpleClassLibrary.Class1", "NotExistMethod"); - Assert.IsNull(diaNavigationData); + // Not exist method name + DiaNavigationData diaNavigationData = diaSession.GetNavigationData("SimpleClassLibrary.Class1", "NotExistMethod"); + Assert.IsNull(diaNavigationData); - // Not Exist Type name - diaNavigationData = diaSession.GetNavigationData("SimpleClassLibrary.NotExistType", "PassingTest"); - Assert.IsNull(diaNavigationData); + // Not Exist Type name + diaNavigationData = diaSession.GetNavigationData("SimpleClassLibrary.NotExistType", "PassingTest"); + Assert.IsNull(diaNavigationData); - this.testEnvironment.TargetFramework = currentTargetFrameWork; - } + _testEnvironment.TargetFramework = currentTargetFrameWork; + } + + [TestMethod] + public void DiaSessionPerfTest() + { + var currentTargetFrameWork = GetAndSetTargetFrameWork(_testEnvironment); + var assemblyPath = GetAssetFullPath("SimpleClassLibrary.dll"); + + var watch = Stopwatch.StartNew(); + var diaSession = new DiaSession(assemblyPath); + DiaNavigationData diaNavigationData = diaSession.GetNavigationData("SimpleClassLibrary.HugeMethodSet", "MSTest_D1_01"); + watch.Stop(); + + Assert.IsNotNull(diaNavigationData, "Failed to get navigation data"); + StringAssert.EndsWith(diaNavigationData.FileName, @"\SimpleClassLibrary\HugeMethodSet.cs"); + ValidateMinLineNumber(9, diaNavigationData.MinLineNumber); + Assert.AreEqual(10, diaNavigationData.MaxLineNumber); + var expectedTime = 150; + Assert.IsTrue(watch.Elapsed.Milliseconds < expectedTime, string.Format("DiaSession Perf test Actual time:{0} ms Expected time:{1} ms", watch.Elapsed.Milliseconds, expectedTime)); + + _testEnvironment.TargetFramework = currentTargetFrameWork; + } - [TestMethod] - public void DiaSessionPerfTest() + private void ValidateLineNumbers(int min, int max) + { + // Release builds optimize code, hence min line numbers are different. + if (IntegrationTestEnvironment.BuildConfiguration.StartsWith("release", StringComparison.OrdinalIgnoreCase)) { - var currentTargetFrameWork = GetAndSetTargetFrameWork(this.testEnvironment); - var assemblyPath = this.GetAssetFullPath("SimpleClassLibrary.dll"); - - var watch = Stopwatch.StartNew(); - DiaSession diaSession = new DiaSession(assemblyPath); - DiaNavigationData diaNavigationData = diaSession.GetNavigationData("SimpleClassLibrary.HugeMethodSet", "MSTest_D1_01"); - watch.Stop(); - - Assert.IsNotNull(diaNavigationData, "Failed to get navigation data"); - StringAssert.EndsWith(diaNavigationData.FileName, @"\SimpleClassLibrary\HugeMethodSet.cs"); - this.ValidateMinLineNumber(9, diaNavigationData.MinLineNumber); - Assert.AreEqual(10, diaNavigationData.MaxLineNumber); - var expectedTime = 150; - Assert.IsTrue(watch.Elapsed.Milliseconds < expectedTime, string.Format("DiaSession Perf test Actual time:{0} ms Expected time:{1} ms", watch.Elapsed.Milliseconds, expectedTime)); - - this.testEnvironment.TargetFramework = currentTargetFrameWork; + Assert.AreEqual(min, max, "Incorrect min line number"); } - - private void ValidateLineNumbers(int min, int max) + else { - // Release builds optimize code, hence min line numbers are different. - if (IntegrationTestEnvironment.BuildConfiguration.StartsWith("release", StringComparison.OrdinalIgnoreCase)) + if (max == 23) + { + Assert.AreEqual(min + 1, max, "Incorrect min line number"); + } + else if (max == 27) { - Assert.AreEqual(min, max, "Incorrect min line number"); + Assert.AreEqual(min + 1, max, "Incorrect min line number"); } else { - if (max == 23) - { - Assert.AreEqual(min + 1, max, "Incorrect min line number"); - } - else if (max == 27) - { - Assert.AreEqual(min + 1, max, "Incorrect min line number"); - } - else - { - Assert.Fail("Incorrect min/max line number"); - } + Assert.Fail("Incorrect min/max line number"); } } + } - private void ValidateMinLineNumber(int expected, int actual) + private void ValidateMinLineNumber(int expected, int actual) + { + // Release builds optimize code, hence min line numbers are different. + if (IntegrationTestEnvironment.BuildConfiguration.StartsWith("release", StringComparison.OrdinalIgnoreCase)) { - // Release builds optimize code, hence min line numbers are different. - if (IntegrationTestEnvironment.BuildConfiguration.StartsWith("release", StringComparison.OrdinalIgnoreCase)) - { - Assert.AreEqual(expected + 1, actual, "Incorrect min line number"); - } - else - { - Assert.AreEqual(expected, actual, "Incorrect min line number"); - } + Assert.AreEqual(expected + 1, actual, "Incorrect min line number"); + } + else + { + Assert.AreEqual(expected, actual, "Incorrect min line number"); } } } diff --git a/test/Microsoft.TestPlatform.ObjectModel.PlatformTests/Program.cs b/test/Microsoft.TestPlatform.ObjectModel.PlatformTests/Program.cs index b60b16a4a8..05d6103873 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.PlatformTests/Program.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.PlatformTests/Program.cs @@ -1,14 +1,14 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests; + +/// +/// Main entry point for the command line runner. +/// +public static class Program { - /// - /// Main entry point for the command line runner. - /// - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/BaseTestRunCriteriaTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/BaseTestRunCriteriaTests.cs index 36560f786b..4df8e24a97 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/BaseTestRunCriteriaTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/BaseTestRunCriteriaTests.cs @@ -1,67 +1,66 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.ObjectModel.UnitTests.Client -{ - using System; +namespace Microsoft.TestPlatform.ObjectModel.UnitTests.Client; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using VisualStudio.TestPlatform.ObjectModel.Client; - [TestClass] - public class BaseTestRunCriteriaTests - { - [TestMethod] - public void ConstructorShouldThrowIfFrequencyOfRunStatsChangeIsZero() - { - var isExceptionThrown = false; +using System; - try - { - var criteria = new BaseTestRunCriteria(frequencyOfRunStatsChangeEvent: 0); - } - catch (ArgumentOutOfRangeException ex) - { - isExceptionThrown = true; - StringAssert.Contains(ex.Message, "Notification frequency need to be a positive value."); - } +using VisualStudio.TestTools.UnitTesting; +using VisualStudio.TestPlatform.ObjectModel.Client; +[TestClass] +public class BaseTestRunCriteriaTests +{ + [TestMethod] + public void ConstructorShouldThrowIfFrequencyOfRunStatsChangeIsZero() + { + var isExceptionThrown = false; - Assert.IsTrue(isExceptionThrown); + try + { + var criteria = new BaseTestRunCriteria(frequencyOfRunStatsChangeEvent: 0); } - - [TestMethod] - public void ConstructorShouldThrowIfFrequencyOfRunStatsChangeIsLesssThanZero() + catch (ArgumentOutOfRangeException ex) { - var isExceptionThrown = false; + isExceptionThrown = true; + StringAssert.Contains(ex.Message, "Notification frequency need to be a positive value."); + } - try - { - var criteria = new BaseTestRunCriteria(frequencyOfRunStatsChangeEvent: -10); - } - catch (ArgumentOutOfRangeException ex) - { - isExceptionThrown = true; - StringAssert.Contains(ex.Message, "Notification frequency need to be a positive value."); - } + Assert.IsTrue(isExceptionThrown); + } - Assert.IsTrue(isExceptionThrown); - } + [TestMethod] + public void ConstructorShouldThrowIfFrequencyOfRunStatsChangeIsLesssThanZero() + { + var isExceptionThrown = false; - [TestMethod] - public void ConstructorShouldThrowIfRunStatsChangeEventTimeoutIsMinimumTimeSpanValue() + try { - var isExceptionThrown = false; + var criteria = new BaseTestRunCriteria(frequencyOfRunStatsChangeEvent: -10); + } + catch (ArgumentOutOfRangeException ex) + { + isExceptionThrown = true; + StringAssert.Contains(ex.Message, "Notification frequency need to be a positive value."); + } + + Assert.IsTrue(isExceptionThrown); + } - try - { - var criteria = new BaseTestRunCriteria(frequencyOfRunStatsChangeEvent: 1, keepAlive: false, testSettings: null, runStatsChangeEventTimeout: TimeSpan.MinValue); - } - catch (ArgumentOutOfRangeException ex) - { - isExceptionThrown = true; - StringAssert.Contains(ex.Message, "Notification timeout must be greater than zero."); - } + [TestMethod] + public void ConstructorShouldThrowIfRunStatsChangeEventTimeoutIsMinimumTimeSpanValue() + { + var isExceptionThrown = false; - Assert.IsTrue(isExceptionThrown); + try + { + var criteria = new BaseTestRunCriteria(frequencyOfRunStatsChangeEvent: 1, keepAlive: false, testSettings: null, runStatsChangeEventTimeout: TimeSpan.MinValue); } + catch (ArgumentOutOfRangeException ex) + { + isExceptionThrown = true; + StringAssert.Contains(ex.Message, "Notification timeout must be greater than zero."); + } + + Assert.IsTrue(isExceptionThrown); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/DiscoveryCriteriaTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/DiscoveryCriteriaTests.cs index 5b309a92d1..dbe65a799c 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/DiscoveryCriteriaTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/DiscoveryCriteriaTests.cs @@ -1,57 +1,56 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.ObjectModel.UnitTests.Client +namespace Microsoft.TestPlatform.ObjectModel.UnitTests.Client; + +using System; +using System.Linq; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using VisualStudio.TestTools.UnitTesting; + +using Newtonsoft.Json; + +[TestClass] +public class DiscoveryCriteriaTests { - using System; - using System.Linq; + private readonly DiscoveryCriteria _discoveryCriteria; + private static readonly JsonSerializerSettings Settings = new() + { + TypeNameHandling = TypeNameHandling.None + }; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestTools.UnitTesting; + public DiscoveryCriteriaTests() + { + _discoveryCriteria = new DiscoveryCriteria( + new[] { "sampleTest.dll" }, + 100, + ""); + _discoveryCriteria.TestCaseFilter = "TestFilter"; + } - using Newtonsoft.Json; + [TestMethod] + public void DiscoveryCriteriaSerializesToExpectedJson() + { + var expectedJson = "{\"Package\":null,\"AdapterSourceMap\":{\"_none_\":[\"sampleTest.dll\"]},\"FrequencyOfDiscoveredTestsEvent\":100,\"DiscoveredTestEventTimeout\":\"10675199.02:48:05.4775807\",\"RunSettings\":\"\",\"TestCaseFilter\":\"TestFilter\",\"TestSessionInfo\":null}"; + + var json = JsonConvert.SerializeObject(_discoveryCriteria, Settings); + + Assert.AreEqual(expectedJson, json); + } - [TestClass] - public class DiscoveryCriteriaTests + [TestMethod] + public void DiscoveryCriteriaShouldBeDeserializable() { - private readonly DiscoveryCriteria discoveryCriteria; - private static readonly JsonSerializerSettings Settings = new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.None - }; - - public DiscoveryCriteriaTests() - { - this.discoveryCriteria = new DiscoveryCriteria( - new[] { "sampleTest.dll" }, - 100, - ""); - this.discoveryCriteria.TestCaseFilter = "TestFilter"; - } - - [TestMethod] - public void DiscoveryCriteriaSerializesToExpectedJson() - { - var expectedJson = "{\"Package\":null,\"AdapterSourceMap\":{\"_none_\":[\"sampleTest.dll\"]},\"FrequencyOfDiscoveredTestsEvent\":100,\"DiscoveredTestEventTimeout\":\"10675199.02:48:05.4775807\",\"RunSettings\":\"\",\"TestCaseFilter\":\"TestFilter\",\"TestSessionInfo\":null}"; - - var json = JsonConvert.SerializeObject(this.discoveryCriteria, Settings); - - Assert.AreEqual(expectedJson, json); - } - - [TestMethod] - public void DiscoveryCriteriaShouldBeDeserializable() - { - var json = "{\"Sources\":[\"sampleTest.dll\"],\"AdapterSourceMap\":{\"_none_\":[\"sampleTest.dll\"]},\"FrequencyOfDiscoveredTestsEvent\":100,\"DiscoveredTestEventTimeout\":\"10675199.02:48:05.4775807\",\"RunSettings\":\"\",\"TestCaseFilter\":\"TestFilter\"}"; - - var criteria = JsonConvert.DeserializeObject(json, Settings); - - Assert.AreEqual(TimeSpan.MaxValue, criteria.DiscoveredTestEventTimeout); - Assert.AreEqual(100, criteria.FrequencyOfDiscoveredTestsEvent); - Assert.AreEqual("", criteria.RunSettings); - Assert.AreEqual("TestFilter", criteria.TestCaseFilter); - Assert.AreEqual("sampleTest.dll", criteria.AdapterSourceMap["_none_"].Single()); - CollectionAssert.AreEqual(new[] { "sampleTest.dll" }, criteria.Sources.ToArray()); - } + var json = "{\"Sources\":[\"sampleTest.dll\"],\"AdapterSourceMap\":{\"_none_\":[\"sampleTest.dll\"]},\"FrequencyOfDiscoveredTestsEvent\":100,\"DiscoveredTestEventTimeout\":\"10675199.02:48:05.4775807\",\"RunSettings\":\"\",\"TestCaseFilter\":\"TestFilter\"}"; + + var criteria = JsonConvert.DeserializeObject(json, Settings); + + Assert.AreEqual(TimeSpan.MaxValue, criteria.DiscoveredTestEventTimeout); + Assert.AreEqual(100, criteria.FrequencyOfDiscoveredTestsEvent); + Assert.AreEqual("", criteria.RunSettings); + Assert.AreEqual("TestFilter", criteria.TestCaseFilter); + Assert.AreEqual("sampleTest.dll", criteria.AdapterSourceMap["_none_"].Single()); + CollectionAssert.AreEqual(new[] { "sampleTest.dll" }, criteria.Sources.ToArray()); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/TestRunCriteriaTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/TestRunCriteriaTests.cs index b6d50cc2b0..e30c568261 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/TestRunCriteriaTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/TestRunCriteriaTests.cs @@ -1,153 +1,152 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.ObjectModel.UnitTests +namespace Microsoft.TestPlatform.ObjectModel.UnitTests; + +using System; +using System.Collections.Generic; +using System.Linq; + +using VisualStudio.TestTools.UnitTesting; + +using VisualStudio.TestPlatform.ObjectModel; +using VisualStudio.TestPlatform.ObjectModel.Client; + +[TestClass] +public class TestRunCriteriaTests { - using System; - using System.Collections.Generic; - using System.Linq; + #region Constructor tests. + + [TestMethod] + public void ConstructorForSourcesShouldInitializeAdapterSourceMap() + { + var sources = new List { "s1.dll", "s2.dll" }; + var testRunCriteria = new TestRunCriteria(sources, frequencyOfRunStatsChangeEvent: 10); - using Microsoft.VisualStudio.TestTools.UnitTesting; + Assert.IsNotNull(testRunCriteria.AdapterSourceMap); + CollectionAssert.AreEqual(new List { "_none_" }, testRunCriteria.AdapterSourceMap.Keys); + CollectionAssert.AreEqual(sources, testRunCriteria.AdapterSourceMap.Values.First().ToList()); + } + + [TestMethod] + public void ConstructorForSourcesWithBaseTestRunCriteriaShouldInitializeAdapterSourceMap() + { + var sources = new List { "s1.dll", "s2.dll" }; + var testRunCriteria = new TestRunCriteria(sources, new TestRunCriteria(new List { "temp.dll" }, 10)); - using VisualStudio.TestPlatform.ObjectModel; - using VisualStudio.TestPlatform.ObjectModel.Client; + Assert.IsNotNull(testRunCriteria.AdapterSourceMap); + CollectionAssert.AreEqual(new List { "_none_" }, testRunCriteria.AdapterSourceMap.Keys); + CollectionAssert.AreEqual(sources, testRunCriteria.AdapterSourceMap.Values.First().ToList()); + } - [TestClass] - public class TestRunCriteriaTests + [TestMethod] + public void ConstructorForSourcesWithAdapterSourceMapShouldInitializeSourceMap() { - #region Constructor tests. - - [TestMethod] - public void ConstructorForSourcesShouldInitializeAdapterSourceMap() - { - var sources = new List { "s1.dll", "s2.dll" }; - var testRunCriteria = new TestRunCriteria(sources, frequencyOfRunStatsChangeEvent: 10); - - Assert.IsNotNull(testRunCriteria.AdapterSourceMap); - CollectionAssert.AreEqual(new List { "_none_" }, testRunCriteria.AdapterSourceMap.Keys); - CollectionAssert.AreEqual(sources, testRunCriteria.AdapterSourceMap.Values.First().ToList()); - } - - [TestMethod] - public void ConstructorForSourcesWithBaseTestRunCriteriaShouldInitializeAdapterSourceMap() - { - var sources = new List { "s1.dll", "s2.dll" }; - var testRunCriteria = new TestRunCriteria(sources, new TestRunCriteria(new List { "temp.dll" }, 10)); - - Assert.IsNotNull(testRunCriteria.AdapterSourceMap); - CollectionAssert.AreEqual(new List { "_none_" }, testRunCriteria.AdapterSourceMap.Keys); - CollectionAssert.AreEqual(sources, testRunCriteria.AdapterSourceMap.Values.First().ToList()); - } - - [TestMethod] - public void ConstructorForSourcesWithAdapterSourceMapShouldInitializeSourceMap() - { - var adapterSourceMap = new Dictionary>(); - var sourceSet1 = new List { "s1.dll", "s2.dll" }; - var sourceSet2 = new List { "s1.json", "s2.json" }; - adapterSourceMap.Add("dummyadapter1", sourceSet1); - adapterSourceMap.Add("dummyadapter2", sourceSet2); - - var testRunCriteria = new TestRunCriteria(adapterSourceMap, 10, false, null, TimeSpan.MaxValue, null); - - Assert.IsNotNull(testRunCriteria.AdapterSourceMap); - CollectionAssert.AreEqual(new List { "dummyadapter1", "dummyadapter2" }, testRunCriteria.AdapterSourceMap.Keys); - CollectionAssert.AreEqual(sourceSet1, testRunCriteria.AdapterSourceMap.Values.First().ToList()); - CollectionAssert.AreEqual(sourceSet2, testRunCriteria.AdapterSourceMap.Values.ToArray()[1].ToList()); - } - - #endregion - - #region Sources tests. - - [TestMethod] - public void SourcesShouldEnumerateThroughAllSourcesInTheAdapterSourceMap() - { - var adapterSourceMap = new Dictionary>(); - var sourceSet1 = new List { "s1.dll", "s2.dll" }; - var sourceSet2 = new List { "s1.json", "s2.json" }; - adapterSourceMap.Add("dummyadapter1", sourceSet1); - adapterSourceMap.Add("dummyadapter2", sourceSet2); - - var testRunCriteria = new TestRunCriteria(adapterSourceMap, 10, false, null, TimeSpan.MaxValue, null); - - var expectedSourceSet = new List(sourceSet1); - expectedSourceSet.AddRange(sourceSet2); - CollectionAssert.AreEqual(expectedSourceSet, testRunCriteria.Sources.ToList()); - } - - [TestMethod] - public void SourcesShouldReturnNullIfAdapterSourceMapIsNull() - { - var testRunCriteria = - new TestRunCriteria( - new List { new TestCase("A.C.M", new Uri("excutor://dummy"), "s.dll") }, - frequencyOfRunStatsChangeEvent: 10); - - Assert.IsNull(testRunCriteria.Sources); - } - - #endregion - - #region HasSpecificSources tests - - [TestMethod] - public void HasSpecificSourcesReturnsFalseIfSourcesAreNotSpecified() - { - var testRunCriteria = - new TestRunCriteria( - new List { new TestCase("A.C.M", new Uri("excutor://dummy"), "s.dll") }, - frequencyOfRunStatsChangeEvent: 10); - - Assert.IsFalse(testRunCriteria.HasSpecificSources); - } - - [TestMethod] - public void HasSpecificSourcesReturnsTrueIfSourcesAreSpecified() - { - var sources = new List { "s1.dll", "s2.dll" }; - var testRunCriteria = new TestRunCriteria(sources, frequencyOfRunStatsChangeEvent: 10); - - Assert.IsTrue(testRunCriteria.HasSpecificSources); - } - - #endregion - - #region HasSpecificTests tests - - [TestMethod] - public void HasSpecificTestsReturnsTrueIfTestsAreSpecified() - { - var testRunCriteria = - new TestRunCriteria( - new List { new TestCase("A.C.M", new Uri("excutor://dummy"), "s.dll") }, - frequencyOfRunStatsChangeEvent: 10); - - Assert.IsTrue(testRunCriteria.HasSpecificTests); - } - - [TestMethod] - public void HasSpecificTestsReturnsFalseIfSourcesAreSpecified() - { - var sources = new List { "s1.dll", "s2.dll" }; - var testRunCriteria = new TestRunCriteria(sources, frequencyOfRunStatsChangeEvent: 10); - - Assert.IsFalse(testRunCriteria.HasSpecificTests); - } - - #endregion - - #region TestCaseFilter tests + var adapterSourceMap = new Dictionary>(); + var sourceSet1 = new List { "s1.dll", "s2.dll" }; + var sourceSet2 = new List { "s1.json", "s2.json" }; + adapterSourceMap.Add("dummyadapter1", sourceSet1); + adapterSourceMap.Add("dummyadapter2", sourceSet2); + + var testRunCriteria = new TestRunCriteria(adapterSourceMap, 10, false, null, TimeSpan.MaxValue, null); + + Assert.IsNotNull(testRunCriteria.AdapterSourceMap); + CollectionAssert.AreEqual(new List { "dummyadapter1", "dummyadapter2" }, testRunCriteria.AdapterSourceMap.Keys); + CollectionAssert.AreEqual(sourceSet1, testRunCriteria.AdapterSourceMap.Values.First().ToList()); + CollectionAssert.AreEqual(sourceSet2, testRunCriteria.AdapterSourceMap.Values.ToArray()[1].ToList()); + } - [TestMethod] - public void TestCaseFilterSetterShouldSetFilterCriteriaForSources() - { - var sources = new List { "s1.dll", "s2.dll" }; - var testRunCriteria = new TestRunCriteria(sources, 10, false, string.Empty, TimeSpan.MaxValue, null, "foo", null); + #endregion - Assert.AreEqual("foo", testRunCriteria.TestCaseFilter); - } + #region Sources tests. - #endregion + [TestMethod] + public void SourcesShouldEnumerateThroughAllSourcesInTheAdapterSourceMap() + { + var adapterSourceMap = new Dictionary>(); + var sourceSet1 = new List { "s1.dll", "s2.dll" }; + var sourceSet2 = new List { "s1.json", "s2.json" }; + adapterSourceMap.Add("dummyadapter1", sourceSet1); + adapterSourceMap.Add("dummyadapter2", sourceSet2); + + var testRunCriteria = new TestRunCriteria(adapterSourceMap, 10, false, null, TimeSpan.MaxValue, null); + + var expectedSourceSet = new List(sourceSet1); + expectedSourceSet.AddRange(sourceSet2); + CollectionAssert.AreEqual(expectedSourceSet, testRunCriteria.Sources.ToList()); + } + + [TestMethod] + public void SourcesShouldReturnNullIfAdapterSourceMapIsNull() + { + var testRunCriteria = + new TestRunCriteria( + new List { new TestCase("A.C.M", new Uri("excutor://dummy"), "s.dll") }, + frequencyOfRunStatsChangeEvent: 10); + + Assert.IsNull(testRunCriteria.Sources); } -} + + #endregion + + #region HasSpecificSources tests + + [TestMethod] + public void HasSpecificSourcesReturnsFalseIfSourcesAreNotSpecified() + { + var testRunCriteria = + new TestRunCriteria( + new List { new TestCase("A.C.M", new Uri("excutor://dummy"), "s.dll") }, + frequencyOfRunStatsChangeEvent: 10); + + Assert.IsFalse(testRunCriteria.HasSpecificSources); + } + + [TestMethod] + public void HasSpecificSourcesReturnsTrueIfSourcesAreSpecified() + { + var sources = new List { "s1.dll", "s2.dll" }; + var testRunCriteria = new TestRunCriteria(sources, frequencyOfRunStatsChangeEvent: 10); + + Assert.IsTrue(testRunCriteria.HasSpecificSources); + } + + #endregion + + #region HasSpecificTests tests + + [TestMethod] + public void HasSpecificTestsReturnsTrueIfTestsAreSpecified() + { + var testRunCriteria = + new TestRunCriteria( + new List { new TestCase("A.C.M", new Uri("excutor://dummy"), "s.dll") }, + frequencyOfRunStatsChangeEvent: 10); + + Assert.IsTrue(testRunCriteria.HasSpecificTests); + } + + [TestMethod] + public void HasSpecificTestsReturnsFalseIfSourcesAreSpecified() + { + var sources = new List { "s1.dll", "s2.dll" }; + var testRunCriteria = new TestRunCriteria(sources, frequencyOfRunStatsChangeEvent: 10); + + Assert.IsFalse(testRunCriteria.HasSpecificTests); + } + + #endregion + + #region TestCaseFilter tests + + [TestMethod] + public void TestCaseFilterSetterShouldSetFilterCriteriaForSources() + { + var sources = new List { "s1.dll", "s2.dll" }; + var testRunCriteria = new TestRunCriteria(sources, 10, false, string.Empty, TimeSpan.MaxValue, null, "foo", null); + + Assert.AreEqual("foo", testRunCriteria.TestCaseFilter); + } + + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/CustomKeyValueConverterTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/CustomKeyValueConverterTests.cs index 36d82f47d9..35dc114e4a 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/CustomKeyValueConverterTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/CustomKeyValueConverterTests.cs @@ -1,97 +1,95 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.ObjectModel.UnitTests +namespace Microsoft.TestPlatform.ObjectModel.UnitTests; +using System.Collections.Generic; +using System.Globalization; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class CustomKeyValueConverterTests { - using System; - using System.Collections.Generic; - using System.Globalization; + private readonly CustomKeyValueConverter _customKeyValueConverter; + + public CustomKeyValueConverterTests() + { + _customKeyValueConverter = new CustomKeyValueConverter(); + } + + [TestMethod] + public void CustomKeyValueConverterShouldDeserializeWellformedJson() + { + var json = "[{ \"Key\": \"key1\", \"Value\": \"val1\" }]"; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; + var data = _customKeyValueConverter.ConvertFrom(null, CultureInfo.InvariantCulture, json) as KeyValuePair[]; - [TestClass] - public class CustomKeyValueConverterTests + Assert.IsNotNull(data); + Assert.AreEqual(1, data.Length); + Assert.AreEqual("key1", data[0].Key); + Assert.AreEqual("val1", data[0].Value); + } + + [TestMethod] + public void CustomKeyValueConverterShouldDeserializeKeyValuePairArray() + { + var json = "[{ \"Key\": \"key1\", \"Value\": \"val1\" }, { \"Key\": \"key2\", \"Value\": \"val2\" }]"; + + var data = _customKeyValueConverter.ConvertFrom(null, CultureInfo.InvariantCulture, json) as KeyValuePair[]; + + Assert.IsNotNull(data); + Assert.AreEqual(2, data.Length); + Assert.AreEqual("key1", data[0].Key); + Assert.AreEqual("val1", data[0].Value); + Assert.AreEqual("key2", data[1].Key); + Assert.AreEqual("val2", data[1].Value); + } + + [TestMethod] + public void CustomKeyValueConverterShouldDeserializeEmptyArray() { - private readonly CustomKeyValueConverter customKeyValueConverter; - - public CustomKeyValueConverterTests() - { - this.customKeyValueConverter = new CustomKeyValueConverter(); - } - - [TestMethod] - public void CustomKeyValueConverterShouldDeserializeWellformedJson() - { - var json = "[{ \"Key\": \"key1\", \"Value\": \"val1\" }]"; - - var data = this.customKeyValueConverter.ConvertFrom(null, CultureInfo.InvariantCulture, json) as KeyValuePair[]; - - Assert.IsNotNull(data); - Assert.AreEqual(1, data.Length); - Assert.AreEqual("key1", data[0].Key); - Assert.AreEqual("val1", data[0].Value); - } - - [TestMethod] - public void CustomKeyValueConverterShouldDeserializeKeyValuePairArray() - { - var json = "[{ \"Key\": \"key1\", \"Value\": \"val1\" }, { \"Key\": \"key2\", \"Value\": \"val2\" }]"; - - var data = this.customKeyValueConverter.ConvertFrom(null, CultureInfo.InvariantCulture, json) as KeyValuePair[]; - - Assert.IsNotNull(data); - Assert.AreEqual(2, data.Length); - Assert.AreEqual("key1", data[0].Key); - Assert.AreEqual("val1", data[0].Value); - Assert.AreEqual("key2", data[1].Key); - Assert.AreEqual("val2", data[1].Value); - } - - [TestMethod] - public void CustomKeyValueConverterShouldDeserializeEmptyArray() - { - var json = "[]"; - - var data = this.customKeyValueConverter.ConvertFrom(null, CultureInfo.InvariantCulture, json) as KeyValuePair[]; - - Assert.IsNotNull(data); - Assert.AreEqual(0, data.Length); - } - - [TestMethod] - public void CustomKeyValueConverterShouldDeserializeEmptyKeyOrValue() - { - var json = "[{ \"Key\": \"\", \"Value\": \"\" }]"; - - var data = this.customKeyValueConverter.ConvertFrom(null, CultureInfo.InvariantCulture, json) as KeyValuePair[]; - - Assert.AreEqual(1, data.Length); - Assert.AreEqual(string.Empty, data[0].Key); - Assert.AreEqual(string.Empty, data[0].Value); - } - - [TestMethod] - public void CustomKeyValueConverterShouldDeserializeDuplicateKeysKvps() - { - var json = "[{ \"Key\": \"key1\", \"Value\": \"val1\" }, { \"Key\": \"key1\", \"Value\": \"val2\" }]"; - - var data = this.customKeyValueConverter.ConvertFrom(null, CultureInfo.InvariantCulture, json) as KeyValuePair[]; - - Assert.IsNotNull(data); - Assert.AreEqual(2, data.Length); - Assert.AreEqual("key1", data[0].Key); - Assert.AreEqual("val1", data[0].Value); - Assert.AreEqual("key1", data[1].Key); - Assert.AreEqual("val2", data[1].Value); - } - - [TestMethod] - public void CustomKeyValueConverterShouldDeserializeNullValue() - { - var data = this.customKeyValueConverter.ConvertFrom(null, CultureInfo.InvariantCulture, null) as KeyValuePair[]; - - Assert.IsNull(data); - } + var json = "[]"; + + var data = _customKeyValueConverter.ConvertFrom(null, CultureInfo.InvariantCulture, json) as KeyValuePair[]; + + Assert.IsNotNull(data); + Assert.AreEqual(0, data.Length); + } + + [TestMethod] + public void CustomKeyValueConverterShouldDeserializeEmptyKeyOrValue() + { + var json = "[{ \"Key\": \"\", \"Value\": \"\" }]"; + + var data = _customKeyValueConverter.ConvertFrom(null, CultureInfo.InvariantCulture, json) as KeyValuePair[]; + + Assert.AreEqual(1, data.Length); + Assert.AreEqual(string.Empty, data[0].Key); + Assert.AreEqual(string.Empty, data[0].Value); + } + + [TestMethod] + public void CustomKeyValueConverterShouldDeserializeDuplicateKeysKvps() + { + var json = "[{ \"Key\": \"key1\", \"Value\": \"val1\" }, { \"Key\": \"key1\", \"Value\": \"val2\" }]"; + + var data = _customKeyValueConverter.ConvertFrom(null, CultureInfo.InvariantCulture, json) as KeyValuePair[]; + + Assert.IsNotNull(data); + Assert.AreEqual(2, data.Length); + Assert.AreEqual("key1", data[0].Key); + Assert.AreEqual("val1", data[0].Value); + Assert.AreEqual("key1", data[1].Key); + Assert.AreEqual("val2", data[1].Value); + } + + [TestMethod] + public void CustomKeyValueConverterShouldDeserializeNullValue() + { + var data = _customKeyValueConverter.ConvertFrom(null, CultureInfo.InvariantCulture, null) as KeyValuePair[]; + + Assert.IsNull(data); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/CustomStringArrayConverterTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/CustomStringArrayConverterTests.cs index 7b7b4802c5..5a68e5da08 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/CustomStringArrayConverterTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/CustomStringArrayConverterTests.cs @@ -1,76 +1,76 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.ObjectModel.UnitTests -{ - using System.Globalization; +namespace Microsoft.TestPlatform.ObjectModel.UnitTests; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Globalization; - [TestClass] - public class CustomStringArrayConverterTests - { - private readonly CustomStringArrayConverter customStringArrayConverter; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class CustomStringArrayConverterTests +{ + private readonly CustomStringArrayConverter _customStringArrayConverter; - public CustomStringArrayConverterTests() - { - this.customStringArrayConverter = new CustomStringArrayConverter(); - } + public CustomStringArrayConverterTests() + { + _customStringArrayConverter = new CustomStringArrayConverter(); + } - [TestMethod] - public void CustomStringArrayConverterShouldDeserializeWellformedJson() - { - var json = "[ \"val2\", \"val1\" ]"; + [TestMethod] + public void CustomStringArrayConverterShouldDeserializeWellformedJson() + { + var json = "[ \"val2\", \"val1\" ]"; - var data = this.customStringArrayConverter.ConvertFrom(null, CultureInfo.InvariantCulture, json) as string[]; + var data = _customStringArrayConverter.ConvertFrom(null, CultureInfo.InvariantCulture, json) as string[]; - Assert.IsNotNull(data); - Assert.AreEqual(2, data.Length); - CollectionAssert.AreEqual(new[] { "val2", "val1" }, data); - } + Assert.IsNotNull(data); + Assert.AreEqual(2, data.Length); + CollectionAssert.AreEqual(new[] { "val2", "val1" }, data); + } - [TestMethod] - public void CustomStringArrayConverterShouldDeserializeEmptyArray() - { - var json = "[]"; + [TestMethod] + public void CustomStringArrayConverterShouldDeserializeEmptyArray() + { + var json = "[]"; - var data = this.customStringArrayConverter.ConvertFrom(null, CultureInfo.InvariantCulture, json) as string[]; + var data = _customStringArrayConverter.ConvertFrom(null, CultureInfo.InvariantCulture, json) as string[]; - Assert.IsNotNull(data); - Assert.AreEqual(0, data.Length); - } + Assert.IsNotNull(data); + Assert.AreEqual(0, data.Length); + } - [TestMethod] - public void CustomStringArrayConverterShouldDeserializeNullKeyOrValue() - { - var json = "[null, \"val\"]"; + [TestMethod] + public void CustomStringArrayConverterShouldDeserializeNullKeyOrValue() + { + var json = "[null, \"val\"]"; - var data = this.customStringArrayConverter.ConvertFrom(null, CultureInfo.InvariantCulture, json) as string[]; + var data = _customStringArrayConverter.ConvertFrom(null, CultureInfo.InvariantCulture, json) as string[]; - Assert.AreEqual(2, data.Length); - Assert.IsNull(data[0]); - Assert.AreEqual("val", data[1]); - } + Assert.AreEqual(2, data.Length); + Assert.IsNull(data[0]); + Assert.AreEqual("val", data[1]); + } - [TestMethod] - public void CustomStringArrayConverterShouldDeserializeEmptyKeyOrValue() - { - var json = "[\"\", \"\"]"; + [TestMethod] + public void CustomStringArrayConverterShouldDeserializeEmptyKeyOrValue() + { + var json = "[\"\", \"\"]"; - var data = this.customStringArrayConverter.ConvertFrom(null, CultureInfo.InvariantCulture, json) as string[]; + var data = _customStringArrayConverter.ConvertFrom(null, CultureInfo.InvariantCulture, json) as string[]; - Assert.AreEqual(2, data.Length); - Assert.AreEqual(string.Empty, data[0]); - Assert.AreEqual(string.Empty, data[1]); - } + Assert.AreEqual(2, data.Length); + Assert.AreEqual(string.Empty, data[0]); + Assert.AreEqual(string.Empty, data[1]); + } - [TestMethod] - public void CustomStringArrayConverterShouldDeserializeNullValue() - { - var data = this.customStringArrayConverter.ConvertFrom(null, CultureInfo.InvariantCulture, null) as string[]; + [TestMethod] + public void CustomStringArrayConverterShouldDeserializeNullValue() + { + var data = _customStringArrayConverter.ConvertFrom(null, CultureInfo.InvariantCulture, null) as string[]; - Assert.IsNull(data); - } + Assert.IsNull(data); } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/DataCollector/Events/SessionEventsTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/DataCollector/Events/SessionEventsTests.cs index c02f0db37a..47cd5c84db 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/DataCollector/Events/SessionEventsTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/DataCollector/Events/SessionEventsTests.cs @@ -1,53 +1,54 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.ObjectModel.UnitTests +namespace Microsoft.TestPlatform.ObjectModel.UnitTests; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; + +[TestClass] +public class SessionEventsTests { - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System.Collections.Generic; + private readonly SessionStartEventArgs _sessionStartEventArgs; - [TestClass] - public class SessionEventsTests + public SessionEventsTests() { - private SessionStartEventArgs sessionStartEventArgs; - - public SessionEventsTests() + var properties = new Dictionary { - var properties = new Dictionary(); - properties.Add("property1", 1); - properties.Add("property2", 2); + { "property1", 1 }, + { "property2", 2 } + }; - this.sessionStartEventArgs = new SessionStartEventArgs(properties); - } + _sessionStartEventArgs = new SessionStartEventArgs(properties); + } - [TestMethod] - public void SessionStartEventArgsGetPropertiesShouldGetPropertiesEnumerator() + [TestMethod] + public void SessionStartEventArgsGetPropertiesShouldGetPropertiesEnumerator() + { + var properties = _sessionStartEventArgs.GetProperties(); + int propertiesCount = 0; + while (properties.MoveNext()) { - var properties = this.sessionStartEventArgs.GetProperties(); - int propertiesCount = 0; - while (properties.MoveNext()) - { - propertiesCount++; - } - - Assert.AreEqual(2, propertiesCount); + propertiesCount++; } - [TestMethod] - public void SessionStartEventArgsGetPropertyValueShouldGetPropertyValue() - { - var value = this.sessionStartEventArgs.GetPropertyValue("property1"); + Assert.AreEqual(2, propertiesCount); + } - Assert.AreEqual(1, value); - } + [TestMethod] + public void SessionStartEventArgsGetPropertyValueShouldGetPropertyValue() + { + var value = _sessionStartEventArgs.GetPropertyValue("property1"); - [TestMethod] - public void SessionStartEventArgsGetPropertyValueShouldGetPropertyValueInObject() - { - var value = this.sessionStartEventArgs.GetPropertyValue("property1"); + Assert.AreEqual(1, value); + } - Assert.AreEqual(1, value); - } + [TestMethod] + public void SessionStartEventArgsGetPropertyValueShouldGetPropertyValueInObject() + { + var value = _sessionStartEventArgs.GetPropertyValue("property1"); + + Assert.AreEqual(1, value); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/FrameworkTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/FrameworkTests.cs index 78c0b2857a..2bf44813f7 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/FrameworkTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/FrameworkTests.cs @@ -1,86 +1,86 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.ObjectModel.UnitTests +namespace Microsoft.TestPlatform.ObjectModel.UnitTests; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class FrameworkTests { - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; + [TestMethod] + public void FrameworkFromStringShouldReturnNullForNull() + { + Assert.IsNull(Framework.FromString(null)); + } + + [TestMethod] + public void FrameworkFromStringShouldReturnNullForEmptyString() + { + Assert.IsNull(Framework.FromString(string.Empty)); + } + + [TestMethod] + public void FrameworkFromStringShouldReturnNullForInvalidString() + { + Assert.IsNull(Framework.FromString("InvalidFramework")); + } + + [TestMethod] + public void FrameworkFromStringShouldIgnoreCase() + { + var fx = Framework.FromString("framework35"); + Assert.AreEqual(".NETFramework,Version=v3.5", fx.Name); + + fx = Framework.FromString("FRAMEWORK40"); + Assert.AreEqual(".NETFramework,Version=v4.0", fx.Name); - [TestClass] - public class FrameworkTests + fx = Framework.FromString("Framework45"); + Assert.AreEqual(".NETFramework,Version=v4.5", fx.Name); + + fx = Framework.FromString("frameworKcore10"); + Assert.AreEqual(".NETCoreApp,Version=v1.0", fx.Name); + + fx = Framework.FromString("frameworkUAP10"); + Assert.AreEqual("UAP,Version=v10.0", fx.Name); + } + + [TestMethod] + public void FrameworkFromStringShouldTrimSpacesAroundFrameworkString() + { + var fx = Framework.FromString(" Framework35"); + + Assert.AreEqual(".NETFramework,Version=v3.5", fx.Name); + Assert.AreEqual("3.5.0.0", fx.Version); + } + + [TestMethod] + public void FrameworkFromStringShouldWorkForShortNames() + { + var fx = Framework.FromString("net451"); + Assert.AreEqual(".NETFramework,Version=v4.5.1", fx.Name); + Assert.AreEqual("4.5.1.0", fx.Version); + + var corefx = Framework.FromString("netcoreapp2.0"); + Assert.AreEqual(".NETCoreApp,Version=v2.0", corefx.Name); + Assert.AreEqual("2.0.0.0", corefx.Version); + } + + [TestMethod] + public void DefaultFrameworkShouldBeNet40OnDesktop() { - [TestMethod] - public void FrameworkFromStringShouldReturnNullForNull() - { - Assert.IsNull(Framework.FromString(null)); - } - - [TestMethod] - public void FrameworkFromStringShouldReturnNullForEmptyString() - { - Assert.IsNull(Framework.FromString(string.Empty)); - } - - [TestMethod] - public void FrameworkFromStringShouldReturnNullForInvalidString() - { - Assert.IsNull(Framework.FromString("InvalidFramework")); - } - - [TestMethod] - public void FrameworkFromStringShouldIgnoreCase() - { - var fx = Framework.FromString("framework35"); - Assert.AreEqual(".NETFramework,Version=v3.5", fx.Name); - - fx = Framework.FromString("FRAMEWORK40"); - Assert.AreEqual(".NETFramework,Version=v4.0", fx.Name); - - fx = Framework.FromString("Framework45"); - Assert.AreEqual(".NETFramework,Version=v4.5", fx.Name); - - fx = Framework.FromString("frameworKcore10"); - Assert.AreEqual(".NETCoreApp,Version=v1.0", fx.Name); - - fx = Framework.FromString("frameworkUAP10"); - Assert.AreEqual("UAP,Version=v10.0", fx.Name); - } - - [TestMethod] - public void FrameworkFromStringShouldTrimSpacesAroundFrameworkString() - { - var fx = Framework.FromString(" Framework35"); - - Assert.AreEqual(".NETFramework,Version=v3.5", fx.Name); - Assert.AreEqual("3.5.0.0", fx.Version); - } - - [TestMethod] - public void FrameworkFromStringShouldWorkForShortNames() - { - var fx = Framework.FromString("net451"); - Assert.AreEqual(".NETFramework,Version=v4.5.1", fx.Name); - Assert.AreEqual("4.5.1.0", fx.Version); - - var corefx = Framework.FromString("netcoreapp2.0"); - Assert.AreEqual(".NETCoreApp,Version=v2.0", corefx.Name); - Assert.AreEqual("2.0.0.0", corefx.Version); - } - - [TestMethod] - public void DefaultFrameworkShouldBeNet40OnDesktop() - { #if NETFRAMEWORK - Assert.AreEqual(".NETFramework,Version=v4.0", Framework.DefaultFramework.Name); + Assert.AreEqual(".NETFramework,Version=v4.0", Framework.DefaultFramework.Name); #endif - } + } - [TestMethod] - public void DefaultFrameworkShouldBeNetCoreApp10OnNonDesktop() - { + [TestMethod] + public void DefaultFrameworkShouldBeNetCoreApp10OnNonDesktop() + { #if !NET451 - Assert.AreEqual(".NETCoreApp,Version=v1.0", Framework.DefaultFramework.Name); + Assert.AreEqual(".NETCoreApp,Version=v1.0", Framework.DefaultFramework.Name); #endif - } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Hosting/TestRunnerConnectionInfoExtensionsTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Hosting/TestRunnerConnectionInfoExtensionsTests.cs index a2fa14f682..cdf5a0e54f 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Hosting/TestRunnerConnectionInfoExtensionsTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Hosting/TestRunnerConnectionInfoExtensionsTests.cs @@ -1,75 +1,73 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.TestHostProvider.UnitTests.Hosting -{ - using System; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace TestPlatform.TestHostProvider.UnitTests.Hosting; + +using System; -#pragma warning disable SA1600 - [TestClass] - public class TestRunnerConnectionInfoExtensionsTests +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class TestRunnerConnectionInfoExtensionsTests +{ + [TestMethod] + public void ToCommandLineOptionsShouldIncludePort() { - [TestMethod] - public void ToCommandLineOptionsShouldIncludePort() - { - var connectionInfo = new TestRunnerConnectionInfo { Port = 123, ConnectionInfo = new TestHostConnectionInfo { Endpoint = "127.0.0.0:123", Role = ConnectionRole.Client, Transport = Transport.Sockets } }; + var connectionInfo = new TestRunnerConnectionInfo { Port = 123, ConnectionInfo = new TestHostConnectionInfo { Endpoint = "127.0.0.0:123", Role = ConnectionRole.Client, Transport = Transport.Sockets } }; - var options = connectionInfo.ToCommandLineOptions(); + var options = connectionInfo.ToCommandLineOptions(); - StringAssert.StartsWith(options, "--port 123 --endpoint 127.0.0.0:123 --role client"); - } + StringAssert.StartsWith(options, "--port 123 --endpoint 127.0.0.0:123 --role client"); + } - [TestMethod] - public void ToCommandLineOptionsShouldIncludeEndpoint() - { - var connectionInfo = new TestRunnerConnectionInfo { Port = 123, ConnectionInfo = new TestHostConnectionInfo { Endpoint = "127.0.0.0:123", Role = ConnectionRole.Client, Transport = Transport.Sockets } }; + [TestMethod] + public void ToCommandLineOptionsShouldIncludeEndpoint() + { + var connectionInfo = new TestRunnerConnectionInfo { Port = 123, ConnectionInfo = new TestHostConnectionInfo { Endpoint = "127.0.0.0:123", Role = ConnectionRole.Client, Transport = Transport.Sockets } }; - var options = connectionInfo.ToCommandLineOptions(); + var options = connectionInfo.ToCommandLineOptions(); - StringAssert.Contains(options, "--endpoint 127.0.0.0:123"); - } + StringAssert.Contains(options, "--endpoint 127.0.0.0:123"); + } - [TestMethod] - public void ToCommandLineOptionsShouldIncludeRole() - { - var connectionInfo = new TestRunnerConnectionInfo { Port = 123, ConnectionInfo = new TestHostConnectionInfo { Endpoint = "127.0.0.0:123", Role = ConnectionRole.Client, Transport = Transport.Sockets } }; + [TestMethod] + public void ToCommandLineOptionsShouldIncludeRole() + { + var connectionInfo = new TestRunnerConnectionInfo { Port = 123, ConnectionInfo = new TestHostConnectionInfo { Endpoint = "127.0.0.0:123", Role = ConnectionRole.Client, Transport = Transport.Sockets } }; - var options = connectionInfo.ToCommandLineOptions(); + var options = connectionInfo.ToCommandLineOptions(); - StringAssert.Contains(options, "--role client"); - } + StringAssert.Contains(options, "--role client"); + } - [TestMethod] - public void ToCommandLineOptionsShouldIncludeParentProcessId() - { - var connectionInfo = new TestRunnerConnectionInfo { RunnerProcessId = 123 }; + [TestMethod] + public void ToCommandLineOptionsShouldIncludeParentProcessId() + { + var connectionInfo = new TestRunnerConnectionInfo { RunnerProcessId = 123 }; - var options = connectionInfo.ToCommandLineOptions(); + var options = connectionInfo.ToCommandLineOptions(); - Assert.IsTrue(options.IndexOf("--parentprocessid 123", StringComparison.OrdinalIgnoreCase) >= 0); - } + Assert.IsTrue(options.IndexOf("--parentprocessid 123", StringComparison.OrdinalIgnoreCase) >= 0); + } - [TestMethod] - public void ToCommandLineOptionsShouldNotIncludeDiagnosticsOptionIfNotEnabled() - { - var connectionInfo = default(TestRunnerConnectionInfo); + [TestMethod] + public void ToCommandLineOptionsShouldNotIncludeDiagnosticsOptionIfNotEnabled() + { + var connectionInfo = default(TestRunnerConnectionInfo); - var options = connectionInfo.ToCommandLineOptions(); + var options = connectionInfo.ToCommandLineOptions(); - Assert.IsFalse(options.IndexOf("--diag", StringComparison.OrdinalIgnoreCase) >= 0); - } + Assert.IsFalse(options.IndexOf("--diag", StringComparison.OrdinalIgnoreCase) >= 0); + } - [TestMethod] - public void ToCommandLineOptionsShouldIncludeDiagnosticsOptionIfEnabled() - { - var connectionInfo = new TestRunnerConnectionInfo { LogFile = "log.txt", TraceLevel = 3 }; + [TestMethod] + public void ToCommandLineOptionsShouldIncludeDiagnosticsOptionIfEnabled() + { + var connectionInfo = new TestRunnerConnectionInfo { LogFile = "log.txt", TraceLevel = 3 }; - var options = connectionInfo.ToCommandLineOptions(); + var options = connectionInfo.ToCommandLineOptions(); - StringAssert.EndsWith(options, "--diag log.txt --tracelevel 3"); - } + StringAssert.EndsWith(options, "--diag log.txt --tracelevel 3"); } -#pragma warning restore SA1600 } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Program.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Program.cs index ac2135a417..d77f39796f 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Program.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Program.cs @@ -1,11 +1,11 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.ObjectModel.UnitTests +namespace Microsoft.TestPlatform.ObjectModel.UnitTests; + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/RunSettings/RunConfigurationTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/RunSettings/RunConfigurationTests.cs index cb14ddbb71..1d4cb69637 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/RunSettings/RunConfigurationTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/RunSettings/RunConfigurationTests.cs @@ -1,48 +1,48 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.ObjectModel.UnitTests -{ - using System; +namespace Microsoft.TestPlatform.ObjectModel.UnitTests; + +using System; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using MSTest.TestFramework.AssertExtensions; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; +using VisualStudio.TestTools.UnitTesting; +using MSTest.TestFramework.AssertExtensions; + +[TestClass] +public class RunConfigurationTests +{ + [TestMethod] + public void RunConfigurationDefaultValuesMustBeUsedOnCreation() + { + var runConfiguration = new RunConfiguration(); + + // Verify Default + Assert.AreEqual(Constants.DefaultPlatform, runConfiguration.TargetPlatform); + Assert.AreEqual(Framework.DefaultFramework, runConfiguration.TargetFramework); + Assert.AreEqual(Constants.DefaultBatchSize, runConfiguration.BatchSize); + Assert.AreEqual(0, runConfiguration.TestSessionTimeout); + Assert.AreEqual(Constants.DefaultResultsDirectory, runConfiguration.ResultsDirectory); + Assert.IsNull(runConfiguration.SolutionDirectory); + Assert.AreEqual(Constants.DefaultTreatTestAdapterErrorsAsWarnings, runConfiguration.TreatTestAdapterErrorsAsWarnings); + Assert.IsNull(runConfiguration.BinariesRoot); + Assert.IsNull(runConfiguration.TestAdaptersPaths); + Assert.AreEqual(Constants.DefaultCpuCount, runConfiguration.MaxCpuCount); + Assert.IsFalse(runConfiguration.DisableAppDomain); + Assert.IsFalse(runConfiguration.DisableParallelization); + Assert.IsFalse(runConfiguration.DesignMode); + Assert.IsFalse(runConfiguration.InIsolation); + Assert.AreEqual(runConfiguration.DesignMode, runConfiguration.ShouldCollectSourceInformation); + Assert.AreEqual(Constants.DefaultExecutionThreadApartmentState, runConfiguration.ExecutionThreadApartmentState); + } - [TestClass] - public class RunConfigurationTests + [TestMethod] + public void RunConfigurationShouldNotThrowExceptionOnUnknownElements() { - [TestMethod] - public void RunConfigurationDefaultValuesMustBeUsedOnCreation() - { - var runConfiguration = new RunConfiguration(); - - // Verify Default - Assert.AreEqual(Constants.DefaultPlatform, runConfiguration.TargetPlatform); - Assert.AreEqual(Framework.DefaultFramework, runConfiguration.TargetFramework); - Assert.AreEqual(Constants.DefaultBatchSize, runConfiguration.BatchSize); - Assert.AreEqual(0, runConfiguration.TestSessionTimeout); - Assert.AreEqual(Constants.DefaultResultsDirectory, runConfiguration.ResultsDirectory); - Assert.IsNull(runConfiguration.SolutionDirectory); - Assert.AreEqual(Constants.DefaultTreatTestAdapterErrorsAsWarnings, runConfiguration.TreatTestAdapterErrorsAsWarnings); - Assert.IsNull(runConfiguration.BinariesRoot); - Assert.IsNull(runConfiguration.TestAdaptersPaths); - Assert.AreEqual(Constants.DefaultCpuCount, runConfiguration.MaxCpuCount); - Assert.IsFalse(runConfiguration.DisableAppDomain); - Assert.IsFalse(runConfiguration.DisableParallelization); - Assert.IsFalse(runConfiguration.DesignMode); - Assert.IsFalse(runConfiguration.InIsolation); - Assert.AreEqual(runConfiguration.DesignMode, runConfiguration.ShouldCollectSourceInformation); - Assert.AreEqual(Constants.DefaultExecutionThreadApartmentState, runConfiguration.ExecutionThreadApartmentState); - } - - [TestMethod] - public void RunConfigurationShouldNotThrowExceptionOnUnknownElements() - { - string settingsXml = - @" + string settingsXml = + @" TestResults @@ -50,17 +50,17 @@ public void RunConfigurationShouldNotThrowExceptionOnUnknownElements() "; - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml); + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml); - Assert.IsNotNull(runConfiguration); - Assert.IsTrue(runConfiguration.DesignMode); - } + Assert.IsNotNull(runConfiguration); + Assert.IsTrue(runConfiguration.DesignMode); + } - [TestMethod] - public void RunConfigurationReadsValuesCorrectlyFromXml() - { - string settingsXml = - @" + [TestMethod] + public void RunConfigurationReadsValuesCorrectlyFromXml() + { + string settingsXml = + @" TestResults @@ -82,94 +82,87 @@ public void RunConfigurationReadsValuesCorrectlyFromXml() "; - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml); - - // Verify Default - Assert.AreEqual(Architecture.X64, runConfiguration.TargetPlatform); - - var expectedFramework = Framework.FromString("FrameworkCore10"); - var actualFramework = runConfiguration.TargetFramework; - Assert.AreEqual(expectedFramework.Name, runConfiguration.TargetFramework.Name); - Assert.AreEqual(expectedFramework.Version, runConfiguration.TargetFramework.Version); - - Assert.AreEqual("TestResults", runConfiguration.ResultsDirectory); - - var expectedSolutionPath = Environment.GetEnvironmentVariable("temp"); - Assert.AreEqual(expectedSolutionPath, runConfiguration.SolutionDirectory); - - Assert.IsTrue(runConfiguration.TreatTestAdapterErrorsAsWarnings); - Assert.AreEqual(@"E:\x\z", runConfiguration.BinariesRoot); - Assert.AreEqual(@"C:\a\b;D:\x\y", runConfiguration.TestAdaptersPaths); - Assert.AreEqual(2, runConfiguration.MaxCpuCount); - Assert.AreEqual(5, runConfiguration.BatchSize); - Assert.AreEqual(10000, runConfiguration.TestSessionTimeout); - Assert.IsTrue(runConfiguration.DisableAppDomain); - Assert.IsTrue(runConfiguration.DisableParallelization); - Assert.IsTrue(runConfiguration.DesignMode); - Assert.IsTrue(runConfiguration.InIsolation); - Assert.IsFalse(runConfiguration.ShouldCollectSourceInformation); - Assert.AreEqual(PlatformApartmentState.STA, runConfiguration.ExecutionThreadApartmentState); - } - - [TestMethod] - public void SetTargetFrameworkVersionShouldSetTargetFramework() - { -#pragma warning disable 612, 618 - - var runConfiguration = new RunConfiguration(); - runConfiguration.TargetFrameworkVersion = FrameworkVersion.Framework35; - StringAssert.Equals(Framework.FromString("Framework35").Name, runConfiguration.TargetFramework.Name); - Assert.AreEqual(FrameworkVersion.Framework35, runConfiguration.TargetFrameworkVersion); - - runConfiguration.TargetFrameworkVersion = FrameworkVersion.Framework40; - StringAssert.Equals(Framework.FromString("Framework40").Name, runConfiguration.TargetFramework.Name); - Assert.AreEqual(FrameworkVersion.Framework40, runConfiguration.TargetFrameworkVersion); - - runConfiguration.TargetFrameworkVersion = FrameworkVersion.Framework45; - StringAssert.Equals(Framework.FromString("Framework45").Name, runConfiguration.TargetFramework.Name); - Assert.AreEqual(FrameworkVersion.Framework45, runConfiguration.TargetFrameworkVersion); - - runConfiguration.TargetFrameworkVersion = FrameworkVersion.FrameworkCore10; - StringAssert.Equals(Framework.FromString("FrameworkCore10").Name, runConfiguration.TargetFramework.Name); - Assert.AreEqual(FrameworkVersion.FrameworkCore10, runConfiguration.TargetFrameworkVersion); - - runConfiguration.TargetFrameworkVersion = FrameworkVersion.FrameworkUap10; - StringAssert.Equals(Framework.FromString("FrameworkUap10").Name, runConfiguration.TargetFramework.Name); - Assert.AreEqual(FrameworkVersion.FrameworkUap10, runConfiguration.TargetFrameworkVersion); - -#pragma warning restore 612, 618 - } - - [TestMethod] - public void SetTargetFrameworkShouldSetTargetFrameworkVersion() - { - var runConfiguration = new RunConfiguration(); - -#pragma warning disable 612, 618 + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml); + + // Verify Default + Assert.AreEqual(Architecture.X64, runConfiguration.TargetPlatform); + + var expectedFramework = Framework.FromString("FrameworkCore10"); + _ = runConfiguration.TargetFramework; + Assert.AreEqual(expectedFramework.Name, runConfiguration.TargetFramework.Name); + Assert.AreEqual(expectedFramework.Version, runConfiguration.TargetFramework.Version); + + Assert.AreEqual("TestResults", runConfiguration.ResultsDirectory); + + var expectedSolutionPath = Environment.GetEnvironmentVariable("temp"); + Assert.AreEqual(expectedSolutionPath, runConfiguration.SolutionDirectory); + + Assert.IsTrue(runConfiguration.TreatTestAdapterErrorsAsWarnings); + Assert.AreEqual(@"E:\x\z", runConfiguration.BinariesRoot); + Assert.AreEqual(@"C:\a\b;D:\x\y", runConfiguration.TestAdaptersPaths); + Assert.AreEqual(2, runConfiguration.MaxCpuCount); + Assert.AreEqual(5, runConfiguration.BatchSize); + Assert.AreEqual(10000, runConfiguration.TestSessionTimeout); + Assert.IsTrue(runConfiguration.DisableAppDomain); + Assert.IsTrue(runConfiguration.DisableParallelization); + Assert.IsTrue(runConfiguration.DesignMode); + Assert.IsTrue(runConfiguration.InIsolation); + Assert.IsFalse(runConfiguration.ShouldCollectSourceInformation); + Assert.AreEqual(PlatformApartmentState.STA, runConfiguration.ExecutionThreadApartmentState); + } - runConfiguration.TargetFramework = Framework.FromString("Framework35"); - Assert.AreEqual(FrameworkVersion.Framework35, runConfiguration.TargetFrameworkVersion); + [TestMethod] + [Obsolete] + public void SetTargetFrameworkVersionShouldSetTargetFramework() + { + var runConfiguration = new RunConfiguration(); + runConfiguration.TargetFrameworkVersion = FrameworkVersion.Framework35; + Equals(Framework.FromString("Framework35").Name, runConfiguration.TargetFramework.Name); + Assert.AreEqual(FrameworkVersion.Framework35, runConfiguration.TargetFrameworkVersion); + + runConfiguration.TargetFrameworkVersion = FrameworkVersion.Framework40; + Equals(Framework.FromString("Framework40").Name, runConfiguration.TargetFramework.Name); + Assert.AreEqual(FrameworkVersion.Framework40, runConfiguration.TargetFrameworkVersion); + + runConfiguration.TargetFrameworkVersion = FrameworkVersion.Framework45; + Equals(Framework.FromString("Framework45").Name, runConfiguration.TargetFramework.Name); + Assert.AreEqual(FrameworkVersion.Framework45, runConfiguration.TargetFrameworkVersion); + + runConfiguration.TargetFrameworkVersion = FrameworkVersion.FrameworkCore10; + Equals(Framework.FromString("FrameworkCore10").Name, runConfiguration.TargetFramework.Name); + Assert.AreEqual(FrameworkVersion.FrameworkCore10, runConfiguration.TargetFrameworkVersion); + + runConfiguration.TargetFrameworkVersion = FrameworkVersion.FrameworkUap10; + Equals(Framework.FromString("FrameworkUap10").Name, runConfiguration.TargetFramework.Name); + Assert.AreEqual(FrameworkVersion.FrameworkUap10, runConfiguration.TargetFrameworkVersion); + } - runConfiguration.TargetFramework = Framework.FromString("Framework40"); - Assert.AreEqual(FrameworkVersion.Framework40, runConfiguration.TargetFrameworkVersion); + [TestMethod] + [Obsolete] + public void SetTargetFrameworkShouldSetTargetFrameworkVersion() + { + var runConfiguration = new RunConfiguration(); + runConfiguration.TargetFramework = Framework.FromString("Framework35"); + Assert.AreEqual(FrameworkVersion.Framework35, runConfiguration.TargetFrameworkVersion); - runConfiguration.TargetFramework = Framework.FromString("Framework45"); - Assert.AreEqual(FrameworkVersion.Framework45, runConfiguration.TargetFrameworkVersion); + runConfiguration.TargetFramework = Framework.FromString("Framework40"); + Assert.AreEqual(FrameworkVersion.Framework40, runConfiguration.TargetFrameworkVersion); - runConfiguration.TargetFramework = Framework.FromString("FrameworkCore10"); - Assert.AreEqual(FrameworkVersion.FrameworkCore10, runConfiguration.TargetFrameworkVersion); + runConfiguration.TargetFramework = Framework.FromString("Framework45"); + Assert.AreEqual(FrameworkVersion.Framework45, runConfiguration.TargetFrameworkVersion); - runConfiguration.TargetFramework = Framework.FromString("FrameworkUap10"); - Assert.AreEqual(FrameworkVersion.FrameworkUap10, runConfiguration.TargetFrameworkVersion); + runConfiguration.TargetFramework = Framework.FromString("FrameworkCore10"); + Assert.AreEqual(FrameworkVersion.FrameworkCore10, runConfiguration.TargetFrameworkVersion); -#pragma warning restore 612, 618 - } + runConfiguration.TargetFramework = Framework.FromString("FrameworkUap10"); + Assert.AreEqual(FrameworkVersion.FrameworkUap10, runConfiguration.TargetFrameworkVersion); + } - [TestMethod] - public void RunConfigurationFromXmlThrowsSettingsExceptionIfBatchSizeIsInvalid() - { - string settingsXml = - @" + [TestMethod] + public void RunConfigurationFromXmlThrowsSettingsExceptionIfBatchSizeIsInvalid() + { + string settingsXml = + @" Foo @@ -177,16 +170,16 @@ public void RunConfigurationFromXmlThrowsSettingsExceptionIfBatchSizeIsInvalid() "; - Assert.That.Throws( - () => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml)) - .WithExactMessage("Invalid settings 'RunConfiguration'. Invalid value 'Foo' specified for 'BatchSize'."); - } + Assert.That.Throws( + () => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml)) + .WithExactMessage("Invalid settings 'RunConfiguration'. Invalid value 'Foo' specified for 'BatchSize'."); + } - [TestMethod] - public void RunConfigurationFromXmlThrowsSettingsExceptionIfTestSessionTimeoutIsInvalid() - { - string settingsXml = - @" + [TestMethod] + public void RunConfigurationFromXmlThrowsSettingsExceptionIfTestSessionTimeoutIsInvalid() + { + string settingsXml = + @" -1 @@ -194,16 +187,16 @@ public void RunConfigurationFromXmlThrowsSettingsExceptionIfTestSessionTimeoutIs "; - Assert.That.Throws( - () => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml)) - .WithExactMessage("Invalid settings 'RunConfiguration'. Invalid value '-1' specified for 'TestSessionTimeout'."); - } + Assert.That.Throws( + () => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml)) + .WithExactMessage("Invalid settings 'RunConfiguration'. Invalid value '-1' specified for 'TestSessionTimeout'."); + } - [TestMethod] - public void RunConfigurationFromXmlShouldNotThrowsSettingsExceptionIfTestSessionTimeoutIsZero() - { - string settingsXml = - @" + [TestMethod] + public void RunConfigurationFromXmlShouldNotThrowsSettingsExceptionIfTestSessionTimeoutIsZero() + { + string settingsXml = + @" 0 @@ -211,14 +204,14 @@ public void RunConfigurationFromXmlShouldNotThrowsSettingsExceptionIfTestSession "; - XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml); - } + XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml); + } - [TestMethod] - public void RunConfigurationFromXmlThrowsSettingsExceptionIfExecutionThreadApartmentStateIsInvalid() - { - string settingsXml = - @" + [TestMethod] + public void RunConfigurationFromXmlThrowsSettingsExceptionIfExecutionThreadApartmentStateIsInvalid() + { + string settingsXml = + @" RandomValue @@ -226,134 +219,133 @@ public void RunConfigurationFromXmlThrowsSettingsExceptionIfExecutionThreadApart "; - Assert.That.Throws( - () => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml)) - .WithExactMessage("Invalid settings 'RunConfiguration'. Invalid value 'RandomValue' specified for 'ExecutionThreadApartmentState'."); - } + Assert.That.Throws( + () => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml)) + .WithExactMessage("Invalid settings 'RunConfiguration'. Invalid value 'RandomValue' specified for 'ExecutionThreadApartmentState'."); + } - [TestMethod] - public void RunConfigurationFromXmlThrowsSettingsExceptionIfBatchSizeIsNegativeInteger() - { - string settingsXml = - @" + [TestMethod] + public void RunConfigurationFromXmlThrowsSettingsExceptionIfBatchSizeIsNegativeInteger() + { + string settingsXml = + @" -10 "; - Assert.That.Throws( - () => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml)) - .WithExactMessage("Invalid settings 'RunConfiguration'. Invalid value '-10' specified for 'BatchSize'."); - } - - [DataRow(true)] - [DataRow(false)] - [DataTestMethod] - public void RunConfigurationShouldReadValueForDesignMode(bool designModeValue) - { - string settingsXml = string.Format( - @" + Assert.That.Throws( + () => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml)) + .WithExactMessage("Invalid settings 'RunConfiguration'. Invalid value '-10' specified for 'BatchSize'."); + } + + [DataRow(true)] + [DataRow(false)] + [DataTestMethod] + public void RunConfigurationShouldReadValueForDesignMode(bool designModeValue) + { + string settingsXml = string.Format( + @" {0} ", designModeValue); - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml); + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml); - Assert.AreEqual(designModeValue, runConfiguration.DesignMode); - } + Assert.AreEqual(designModeValue, runConfiguration.DesignMode); + } - [TestMethod] - public void RunConfigurationShouldSetDesignModeAsFalseByDefault() - { - string settingsXml = - @" + [TestMethod] + public void RunConfigurationShouldSetDesignModeAsFalseByDefault() + { + string settingsXml = + @" x64 "; - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml); + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml); - Assert.IsFalse(runConfiguration.DesignMode); - } + Assert.IsFalse(runConfiguration.DesignMode); + } - [TestMethod] - public void RunConfigurationToXmlShouldProvideDesignMode() - { - var runConfiguration = new RunConfiguration { DesignMode = true }; + [TestMethod] + public void RunConfigurationToXmlShouldProvideDesignMode() + { + var runConfiguration = new RunConfiguration { DesignMode = true }; - StringAssert.Contains(runConfiguration.ToXml().InnerXml, "True"); - } + StringAssert.Contains(runConfiguration.ToXml().InnerXml, "True"); + } - [DataRow(true)] - [DataRow(false)] - [DataTestMethod] - public void RunConfigurationShouldReadValueForCollectSourceInformation(bool val) - { - string settingsXml = string.Format( - @" + [DataRow(true)] + [DataRow(false)] + [DataTestMethod] + public void RunConfigurationShouldReadValueForCollectSourceInformation(bool val) + { + string settingsXml = string.Format( + @" {0} ", val); - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml); + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml); - Assert.AreEqual(val, runConfiguration.ShouldCollectSourceInformation); - } + Assert.AreEqual(val, runConfiguration.ShouldCollectSourceInformation); + } - [TestMethod] - public void RunConfigurationShouldSetCollectSourceInformationSameAsDesignModeByDefault() - { - string settingsXml = - @" + [TestMethod] + public void RunConfigurationShouldSetCollectSourceInformationSameAsDesignModeByDefault() + { + string settingsXml = + @" x64 "; - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml); - - Assert.AreEqual(runConfiguration.DesignMode, runConfiguration.ShouldCollectSourceInformation); - } - - [DataTestMethod] - [DataRow(true)] - [DataRow(false)] - public void RunConfigurationToXmlShouldProvideCollectSourceInformationSameAsDesignMode(bool val) - { - var runConfiguration = new RunConfiguration { DesignMode = val }; - StringAssert.Contains(runConfiguration.ToXml().InnerXml.ToUpperInvariant(), $"{val}".ToUpperInvariant()); - } - - [TestMethod] - public void RunConfigurationToXmlShouldProvideExecutionThreadApartmentState() - { - var runConfiguration = new RunConfiguration { ExecutionThreadApartmentState = PlatformApartmentState.STA }; - - StringAssert.Contains(runConfiguration.ToXml().InnerXml, "STA"); - } - - [TestMethod] - public void RunConfigurationShouldThrowSettingsExceptionIfResultsirectoryIsEmpty() - { - string settingsXml = - @" + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml); + + Assert.AreEqual(runConfiguration.DesignMode, runConfiguration.ShouldCollectSourceInformation); + } + + [DataTestMethod] + [DataRow(true)] + [DataRow(false)] + public void RunConfigurationToXmlShouldProvideCollectSourceInformationSameAsDesignMode(bool val) + { + var runConfiguration = new RunConfiguration { DesignMode = val }; + StringAssert.Contains(runConfiguration.ToXml().InnerXml.ToUpperInvariant(), $"{val}".ToUpperInvariant()); + } + + [TestMethod] + public void RunConfigurationToXmlShouldProvideExecutionThreadApartmentState() + { + var runConfiguration = new RunConfiguration { ExecutionThreadApartmentState = PlatformApartmentState.STA }; + + StringAssert.Contains(runConfiguration.ToXml().InnerXml, "STA"); + } + + [TestMethod] + public void RunConfigurationShouldThrowSettingsExceptionIfResultsirectoryIsEmpty() + { + string settingsXml = + @" "; - Assert.That.Throws( - () => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml)) - .WithExactMessage("Invalid settings 'RunConfiguration'. Invalid value '' specified for 'ResultsDirectory'."); - } + Assert.That.Throws( + () => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml)) + .WithExactMessage("Invalid settings 'RunConfiguration'. Invalid value '' specified for 'ResultsDirectory'."); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/TestCaseTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/TestCaseTests.cs index f61dfcd2d7..2c902a358d 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/TestCaseTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/TestCaseTests.cs @@ -1,194 +1,194 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.ObjectModel.UnitTests +namespace Microsoft.TestPlatform.ObjectModel.UnitTests; + +using System; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class TestCaseTests { - using System; - - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class TestCaseTests - { - private TestCase testCase; - - [TestInitialize] - public void TestInit() - { - testCase = new TestCase("sampleTestClass.sampleTestCase", new Uri("executor://sampleTestExecutor"), "sampleTest.dll"); - } - - [TestMethod] - public void TestCaseIdIfNotSetExplicitlyShouldReturnGuidBasedOnSourceAndName() - { - Assert.AreEqual("28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b", testCase.Id.ToString()); - } - - [TestMethod] - public void TestCaseIdIfNotSetExplicitlyShouldReturnGuidBasedOnSourceAndNameIfNameIsChanged() - { - testCase.FullyQualifiedName = "sampleTestClass1.sampleTestCase1"; - - Assert.AreEqual("6f86dd1c-7130-a1ae-8e7f-02e7de898a43", testCase.Id.ToString()); - } - - [TestMethod] - public void TestCaseIdIfNotSetExplicitlyShouldReturnGuidBasedOnSourceAndNameIfSourceIsChanged() - { - testCase.Source = "sampleTest1.dll"; - - Assert.AreEqual("22843fee-70ea-4cf4-37cd-5061b4c47a8a", testCase.Id.ToString()); - } - - [TestMethod] - public void TestCaseIdShouldReturnIdSetExplicitlyEvenIfNameOrSourceInfoChanges() - { - var testGuid = new Guid("{8167845C-9CDB-476F-9F2B-1B1C1FE01B7D}"); - testCase.Id = testGuid; - - testCase.FullyQualifiedName = "sampleTestClass1.sampleTestCase1"; - testCase.Source = "sampleTest1.dll"; - - Assert.AreEqual(testGuid, testCase.Id); - } - - [TestMethod] - public void TestCaseLocalExtensionDataIsPubliclySettableGettableProperty() - { - var dummyData = "foo"; - this.testCase.LocalExtensionData = dummyData; - Assert.AreEqual("foo", this.testCase.LocalExtensionData); - } - - #region GetSetPropertyValue Tests - - [TestMethod] - public void TestCaseGetPropertyValueForCodeFilePathShouldReturnCorrectValue() - { - var testCodeFilePath = "C:\\temp\foo.cs"; - this.testCase.CodeFilePath = testCodeFilePath; - - Assert.AreEqual(testCodeFilePath, this.testCase.GetPropertyValue(TestCaseProperties.CodeFilePath)); - } - - [TestMethod] - public void TestCaseGetPropertyValueForDisplayNameShouldReturnCorrectValue() - { - var testDisplayName = "testCaseDisplayName"; - this.testCase.DisplayName = testDisplayName; - - Assert.AreEqual(testDisplayName, this.testCase.GetPropertyValue(TestCaseProperties.DisplayName)); - } - - [TestMethod] - public void TestCaseGetPropertyValueForExecutorUriShouldReturnCorrectValue() - { - var testExecutorUri = new Uri("http://foo"); - this.testCase.ExecutorUri = testExecutorUri; - - Assert.AreEqual(testExecutorUri, this.testCase.GetPropertyValue(TestCaseProperties.ExecutorUri)); - } - - [TestMethod] - public void TestCaseGetPropertyValueForFullyQualifiedNameShouldReturnCorrectValue() - { - var testFullyQualifiedName = "fullyQualifiedName.Test1"; - this.testCase.FullyQualifiedName = testFullyQualifiedName; - - Assert.AreEqual(testFullyQualifiedName, this.testCase.GetPropertyValue(TestCaseProperties.FullyQualifiedName)); - } - - [TestMethod] - public void TestCaseGetPropertyValueForIdShouldReturnCorrectValue() - { - var testId = new Guid("{7845816C-9CDB-37DA-9ADF-1B1C1FE01B7D}"); - this.testCase.Id = testId; - - Assert.AreEqual(testId, this.testCase.GetPropertyValue(TestCaseProperties.Id)); - } - - [TestMethod] - public void TestCaseGetPropertyValueForLineNumberShouldReturnCorrectValue() - { - var testLineNumber = 34; - this.testCase.LineNumber = testLineNumber; - - Assert.AreEqual(testLineNumber, this.testCase.GetPropertyValue(TestCaseProperties.LineNumber)); - } - - [TestMethod] - public void TestCaseGetPropertyValueForSourceShouldReturnCorrectValue() - { - var testSource = "C://temp/foobar.dll"; - this.testCase.Source = testSource; - - Assert.AreEqual(testSource, this.testCase.GetPropertyValue(TestCaseProperties.Source)); - } - - [TestMethod] - public void TestCaseSetPropertyValueForCodeFilePathShouldSetValue() - { - var testCodeFilePath = "C:\\temp\foo.cs"; - this.testCase.SetPropertyValue(TestCaseProperties.CodeFilePath, testCodeFilePath); - - Assert.AreEqual(testCodeFilePath, this.testCase.CodeFilePath); - } - - [TestMethod] - public void TestCaseSetPropertyValueForDisplayNameShouldSetValue() - { - var testDisplayName = "testCaseDisplayName"; - this.testCase.SetPropertyValue(TestCaseProperties.DisplayName, testDisplayName); - - Assert.AreEqual(testDisplayName, this.testCase.DisplayName); - } - - [TestMethod] - public void TestCaseSetPropertyValueForExecutorUriShouldSetValue() - { - var testExecutorUri = new Uri("http://foo"); - this.testCase.SetPropertyValue(TestCaseProperties.ExecutorUri, testExecutorUri); - - Assert.AreEqual(testExecutorUri, this.testCase.ExecutorUri); - } - - [TestMethod] - public void TestCaseSetPropertyValueForFullyQualifiedNameShouldSetValue() - { - var testFullyQualifiedName = "fullyQualifiedName.Test1"; - this.testCase.SetPropertyValue(TestCaseProperties.FullyQualifiedName, testFullyQualifiedName); - - Assert.AreEqual(testFullyQualifiedName, this.testCase.FullyQualifiedName); - } - - [TestMethod] - public void TestCaseSetPropertyValueForIdShouldSetValue() - { - var testId = new Guid("{7845816C-9CDB-37DA-9ADF-1B1C1FE01B7D}"); - this.testCase.SetPropertyValue(TestCaseProperties.Id, testId); - - Assert.AreEqual(testId, this.testCase.Id); - } - - [TestMethod] - public void TestCaseSetPropertyValueForLineNumberShouldSetValue() - { - var testLineNumber = 34; - this.testCase.SetPropertyValue(TestCaseProperties.LineNumber, testLineNumber); - - Assert.AreEqual(testLineNumber, this.testCase.LineNumber); - } - - [TestMethod] - public void TestCaseSetPropertyValueForSourceShouldSetValue() - { - var testSource = "C://temp/foobar.dll"; - this.testCase.SetPropertyValue(TestCaseProperties.Source, testSource); - - Assert.AreEqual(testSource, this.testCase.Source); - } - - #endregion - } -} + private TestCase _testCase; + + [TestInitialize] + public void TestInit() + { + _testCase = new TestCase("sampleTestClass.sampleTestCase", new Uri("executor://sampleTestExecutor"), "sampleTest.dll"); + } + + [TestMethod] + public void TestCaseIdIfNotSetExplicitlyShouldReturnGuidBasedOnSourceAndName() + { + Assert.AreEqual("28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b", _testCase.Id.ToString()); + } + + [TestMethod] + public void TestCaseIdIfNotSetExplicitlyShouldReturnGuidBasedOnSourceAndNameIfNameIsChanged() + { + _testCase.FullyQualifiedName = "sampleTestClass1.sampleTestCase1"; + + Assert.AreEqual("6f86dd1c-7130-a1ae-8e7f-02e7de898a43", _testCase.Id.ToString()); + } + + [TestMethod] + public void TestCaseIdIfNotSetExplicitlyShouldReturnGuidBasedOnSourceAndNameIfSourceIsChanged() + { + _testCase.Source = "sampleTest1.dll"; + + Assert.AreEqual("22843fee-70ea-4cf4-37cd-5061b4c47a8a", _testCase.Id.ToString()); + } + + [TestMethod] + public void TestCaseIdShouldReturnIdSetExplicitlyEvenIfNameOrSourceInfoChanges() + { + var testGuid = new Guid("{8167845C-9CDB-476F-9F2B-1B1C1FE01B7D}"); + _testCase.Id = testGuid; + + _testCase.FullyQualifiedName = "sampleTestClass1.sampleTestCase1"; + _testCase.Source = "sampleTest1.dll"; + + Assert.AreEqual(testGuid, _testCase.Id); + } + + [TestMethod] + public void TestCaseLocalExtensionDataIsPubliclySettableGettableProperty() + { + var dummyData = "foo"; + _testCase.LocalExtensionData = dummyData; + Assert.AreEqual("foo", _testCase.LocalExtensionData); + } + + #region GetSetPropertyValue Tests + + [TestMethod] + public void TestCaseGetPropertyValueForCodeFilePathShouldReturnCorrectValue() + { + var testCodeFilePath = "C:\\temp\foo.cs"; + _testCase.CodeFilePath = testCodeFilePath; + + Assert.AreEqual(testCodeFilePath, _testCase.GetPropertyValue(TestCaseProperties.CodeFilePath)); + } + + [TestMethod] + public void TestCaseGetPropertyValueForDisplayNameShouldReturnCorrectValue() + { + var testDisplayName = "testCaseDisplayName"; + _testCase.DisplayName = testDisplayName; + + Assert.AreEqual(testDisplayName, _testCase.GetPropertyValue(TestCaseProperties.DisplayName)); + } + + [TestMethod] + public void TestCaseGetPropertyValueForExecutorUriShouldReturnCorrectValue() + { + var testExecutorUri = new Uri("http://foo"); + _testCase.ExecutorUri = testExecutorUri; + + Assert.AreEqual(testExecutorUri, _testCase.GetPropertyValue(TestCaseProperties.ExecutorUri)); + } + + [TestMethod] + public void TestCaseGetPropertyValueForFullyQualifiedNameShouldReturnCorrectValue() + { + var testFullyQualifiedName = "fullyQualifiedName.Test1"; + _testCase.FullyQualifiedName = testFullyQualifiedName; + + Assert.AreEqual(testFullyQualifiedName, _testCase.GetPropertyValue(TestCaseProperties.FullyQualifiedName)); + } + + [TestMethod] + public void TestCaseGetPropertyValueForIdShouldReturnCorrectValue() + { + var testId = new Guid("{7845816C-9CDB-37DA-9ADF-1B1C1FE01B7D}"); + _testCase.Id = testId; + + Assert.AreEqual(testId, _testCase.GetPropertyValue(TestCaseProperties.Id)); + } + + [TestMethod] + public void TestCaseGetPropertyValueForLineNumberShouldReturnCorrectValue() + { + var testLineNumber = 34; + _testCase.LineNumber = testLineNumber; + + Assert.AreEqual(testLineNumber, _testCase.GetPropertyValue(TestCaseProperties.LineNumber)); + } + + [TestMethod] + public void TestCaseGetPropertyValueForSourceShouldReturnCorrectValue() + { + var testSource = "C://temp/foobar.dll"; + _testCase.Source = testSource; + + Assert.AreEqual(testSource, _testCase.GetPropertyValue(TestCaseProperties.Source)); + } + + [TestMethod] + public void TestCaseSetPropertyValueForCodeFilePathShouldSetValue() + { + var testCodeFilePath = "C:\\temp\foo.cs"; + _testCase.SetPropertyValue(TestCaseProperties.CodeFilePath, testCodeFilePath); + + Assert.AreEqual(testCodeFilePath, _testCase.CodeFilePath); + } + + [TestMethod] + public void TestCaseSetPropertyValueForDisplayNameShouldSetValue() + { + var testDisplayName = "testCaseDisplayName"; + _testCase.SetPropertyValue(TestCaseProperties.DisplayName, testDisplayName); + + Assert.AreEqual(testDisplayName, _testCase.DisplayName); + } + + [TestMethod] + public void TestCaseSetPropertyValueForExecutorUriShouldSetValue() + { + var testExecutorUri = new Uri("http://foo"); + _testCase.SetPropertyValue(TestCaseProperties.ExecutorUri, testExecutorUri); + + Assert.AreEqual(testExecutorUri, _testCase.ExecutorUri); + } + + [TestMethod] + public void TestCaseSetPropertyValueForFullyQualifiedNameShouldSetValue() + { + var testFullyQualifiedName = "fullyQualifiedName.Test1"; + _testCase.SetPropertyValue(TestCaseProperties.FullyQualifiedName, testFullyQualifiedName); + + Assert.AreEqual(testFullyQualifiedName, _testCase.FullyQualifiedName); + } + + [TestMethod] + public void TestCaseSetPropertyValueForIdShouldSetValue() + { + var testId = new Guid("{7845816C-9CDB-37DA-9ADF-1B1C1FE01B7D}"); + _testCase.SetPropertyValue(TestCaseProperties.Id, testId); + + Assert.AreEqual(testId, _testCase.Id); + } + + [TestMethod] + public void TestCaseSetPropertyValueForLineNumberShouldSetValue() + { + var testLineNumber = 34; + _testCase.SetPropertyValue(TestCaseProperties.LineNumber, testLineNumber); + + Assert.AreEqual(testLineNumber, _testCase.LineNumber); + } + + [TestMethod] + public void TestCaseSetPropertyValueForSourceShouldSetValue() + { + var testSource = "C://temp/foobar.dll"; + _testCase.SetPropertyValue(TestCaseProperties.Source, testSource); + + Assert.AreEqual(testSource, _testCase.Source); + } + + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/TestObjectTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/TestObjectTests.cs index e910b4ad26..63716a8265 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/TestObjectTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/TestObjectTests.cs @@ -1,47 +1,46 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.ObjectModel.UnitTests -{ - using System; +namespace Microsoft.TestPlatform.ObjectModel.UnitTests; + +using System; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System.Collections.Generic; - using System.Linq; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +using System.Linq; - [TestClass] - public class TestObjectTests +[TestClass] +public class TestObjectTests +{ + private static readonly TestCase TestCase = new( + "sampleTestClass.sampleTestCase", + new Uri("executor://sampleTestExecutor"), + "sampleTest.dll") { - private static TestCase testCase = new TestCase( - "sampleTestClass.sampleTestCase", - new Uri("executor://sampleTestExecutor"), - "sampleTest.dll") - { - CodeFilePath = "/user/src/testFile.cs", - DisplayName = "sampleTestCase", - Id = new Guid("be78d6fc-61b0-4882-9d07-40d796fd96ce"), - Traits = { new Trait("Priority", "0"), new Trait("Category", "unit") } - }; + CodeFilePath = "/user/src/testFile.cs", + DisplayName = "sampleTestCase", + Id = new Guid("be78d6fc-61b0-4882-9d07-40d796fd96ce"), + Traits = { new Trait("Priority", "0"), new Trait("Category", "unit") } + }; - [TestMethod] - public void TestCaseIdShouldReturnGuidWhenTestPropertiesIdIsSet() - { - Guid expected = new Guid("{8167845C-9CDB-476F-9F2B-1B1C1FE01B7D}"); - testCase.Id = expected; - var actual = testCase.Id; - Assert.AreEqual(expected, actual); - } + [TestMethod] + public void TestCaseIdShouldReturnGuidWhenTestPropertiesIdIsSet() + { + Guid expected = new("{8167845C-9CDB-476F-9F2B-1B1C1FE01B7D}"); + TestCase.Id = expected; + var actual = TestCase.Id; + Assert.AreEqual(expected, actual); + } - [TestMethod] - public void GetPropertiesShouldReturnListOfPropertiesInStore() - { - TestProperty tp = TestProperty.Register("dummyId", "dummyLabel", typeof(int), typeof(TestObjectTests)); - var kvp = new KeyValuePair(tp, 123); - testCase.SetPropertyValue(kvp.Key, kvp.Value); + [TestMethod] + public void GetPropertiesShouldReturnListOfPropertiesInStore() + { + TestProperty tp = TestProperty.Register("dummyId", "dummyLabel", typeof(int), typeof(TestObjectTests)); + var kvp = new KeyValuePair(tp, 123); + TestCase.SetPropertyValue(kvp.Key, kvp.Value); - var properties = testCase.GetProperties().ToList(); - Assert.IsTrue(properties.Contains(kvp)); - } + var properties = TestCase.GetProperties().ToList(); + Assert.IsTrue(properties.Contains(kvp)); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/TestResultTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/TestResultTests.cs index b60b15ca8e..089b49f3c3 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/TestResultTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/TestResultTests.cs @@ -1,192 +1,191 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.ObjectModel.UnitTests +namespace Microsoft.TestPlatform.ObjectModel.UnitTests; + +using System; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using TestResult = VisualStudio.TestPlatform.ObjectModel.TestResult; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class TestResultTests { - using System; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using TestResult = Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult; - - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class TestResultTests - { - private readonly TestCase testcase; - private readonly TestResult result; - - public TestResultTests() - { - this.testcase = new TestCase("FQN", new Uri("http://dummyUri"), "dummySource"); - this.result = new TestResult(testcase); - } - - [TestMethod] - public void TestResultShouldInitializeEmptyAttachments() - { - Assert.AreEqual(0, this.result.Attachments.Count); - } - - [TestMethod] - public void TestResultShouldInitializeEmptyMessages() - { - Assert.AreEqual(0, this.result.Messages.Count); - } - - [TestMethod] - public void TestResultShouldInitializeStartAndEndTimeToCurrent() - { - Assert.IsTrue(this.result.StartTime.Subtract(DateTimeOffset.UtcNow) < new TimeSpan(0, 0, 0, 10)); - Assert.IsTrue(this.result.EndTime.Subtract(DateTimeOffset.UtcNow) < new TimeSpan(0, 0, 0, 10)); - } - - #region GetSetPropertyValue Tests - - [TestMethod] - public void TestResultGetPropertyValueForComputerNameShouldReturnCorrectValue() - { - var testComputerName = "computerName"; - this.result.ComputerName = testComputerName; - - Assert.AreEqual(testComputerName, this.result.GetPropertyValue(TestResultProperties.ComputerName)); - } - - [TestMethod] - public void TestResultGetPropertyValueForDisplayNameShouldReturnCorrectValue() - { - var testDisplayName = "displayName"; - this.result.DisplayName = testDisplayName; - - Assert.AreEqual(testDisplayName, this.result.GetPropertyValue(TestResultProperties.DisplayName)); - } - - [TestMethod] - public void TestResultGetPropertyValueForDurationShouldReturnCorrectValue() - { - var testDuration = new TimeSpan(0, 0, 0, 10); - this.result.Duration = testDuration; - - Assert.AreEqual(testDuration, this.result.GetPropertyValue(TestResultProperties.Duration)); - } - - [TestMethod] - public void TestResultGetPropertyValueForEndTimeShouldReturnCorrectValue() - { - var testEndTime = new DateTimeOffset(new DateTime(2007, 3, 10, 0, 0, 10, DateTimeKind.Utc)); - this.result.EndTime = testEndTime; - - Assert.AreEqual(testEndTime, this.result.GetPropertyValue(TestResultProperties.EndTime)); - } - - [TestMethod] - public void TestResultGetPropertyValueForErrorMessageShouldReturnCorrectValue() - { - var testErrorMessage = "error123"; - this.result.ErrorMessage = testErrorMessage; - - Assert.AreEqual(testErrorMessage, this.result.GetPropertyValue(TestResultProperties.ErrorMessage)); - } - - [TestMethod] - public void TestResultGetPropertyValueForErrorStackTraceShouldReturnCorrectValue() - { - var testErrorStackTrace = "errorStack"; - this.result.ErrorStackTrace = testErrorStackTrace; - - Assert.AreEqual(testErrorStackTrace, this.result.GetPropertyValue(TestResultProperties.ErrorStackTrace)); - } - - [TestMethod] - public void TestResultGetPropertyValueForTestOutcomeShouldReturnCorrectValue() - { - var testOutcome = TestOutcome.Passed; - this.result.Outcome = testOutcome; - - Assert.AreEqual(testOutcome, this.result.GetPropertyValue(TestResultProperties.Outcome)); - } - - [TestMethod] - public void TestResultGetPropertyValueForStartTimeShouldReturnCorrectValue() - { - var testStartTime = new DateTimeOffset(new DateTime(2007, 3, 10, 0, 0, 0, DateTimeKind.Utc)); - this.result.StartTime = testStartTime; - - Assert.AreEqual(testStartTime, this.result.GetPropertyValue(TestResultProperties.StartTime)); - } - - [TestMethod] - public void TestResultSetPropertyValueForComputerNameShouldSetValue() - { - var testComputerName = "computerNameSet"; - this.result.SetPropertyValue(TestResultProperties.ComputerName, testComputerName); - - Assert.AreEqual(testComputerName, this.result.ComputerName); - } - - [TestMethod] - public void TestResultSetPropertyValueForDisplayNameShouldSetValue() - { - var testDisplayName = "displayNameSet"; - this.result.SetPropertyValue(TestResultProperties.DisplayName, testDisplayName); - - Assert.AreEqual(testDisplayName, this.result.DisplayName); - } - - [TestMethod] - public void TestResultSetPropertyValueForDurationShouldSetValue() - { - var testDuration = new TimeSpan(0, 0, 0, 20); - this.result.SetPropertyValue(TestResultProperties.Duration, testDuration); - - Assert.AreEqual(testDuration, this.result.Duration); - } - - [TestMethod] - public void TestResultSetPropertyValueForEndTimeShouldSetValue() - { - var testEndTime = new DateTimeOffset(new DateTime(2007, 5, 10, 0, 0, 10, DateTimeKind.Utc)); - this.result.SetPropertyValue(TestResultProperties.EndTime, testEndTime); - - Assert.AreEqual(testEndTime, this.result.EndTime); - } - - [TestMethod] - public void TestResultSetPropertyValueForErrorMessageShouldSetValue() - { - var testErrorMessage = "error123Set"; - this.result.SetPropertyValue(TestResultProperties.ErrorMessage, testErrorMessage); - - Assert.AreEqual(testErrorMessage, this.result.ErrorMessage); - } - - [TestMethod] - public void TestResultSetPropertyValueForErrorStackTraceShouldSetValue() - { - var testErrorStackTrace = "errorStackSet"; - this.result.SetPropertyValue(TestResultProperties.ErrorStackTrace, testErrorStackTrace); - - Assert.AreEqual(testErrorStackTrace, this.result.ErrorStackTrace); - } - - [TestMethod] - public void TestResultSetPropertyValueForTestOutcomeShouldSetValue() - { - var testOutcome = TestOutcome.Failed; - this.result.SetPropertyValue(TestResultProperties.Outcome, testOutcome); - - Assert.AreEqual(testOutcome, this.result.Outcome); - } - - [TestMethod] - public void TestResultSetPropertyValueForStartTimeShouldSetValue() - { - var testStartTime = new DateTimeOffset(new DateTime(2007, 5, 10, 0, 0, 0, DateTimeKind.Utc)); - this.result.SetPropertyValue(TestResultProperties.StartTime, testStartTime); - - Assert.AreEqual(testStartTime, this.result.StartTime); - } - - #endregion - - } -} + private readonly TestCase _testcase; + private readonly TestResult _result; + + public TestResultTests() + { + _testcase = new TestCase("FQN", new Uri("http://dummyUri"), "dummySource"); + _result = new TestResult(_testcase); + } + + [TestMethod] + public void TestResultShouldInitializeEmptyAttachments() + { + Assert.AreEqual(0, _result.Attachments.Count); + } + + [TestMethod] + public void TestResultShouldInitializeEmptyMessages() + { + Assert.AreEqual(0, _result.Messages.Count); + } + + [TestMethod] + public void TestResultShouldInitializeStartAndEndTimeToCurrent() + { + Assert.IsTrue(_result.StartTime.Subtract(DateTimeOffset.UtcNow) < new TimeSpan(0, 0, 0, 10)); + Assert.IsTrue(_result.EndTime.Subtract(DateTimeOffset.UtcNow) < new TimeSpan(0, 0, 0, 10)); + } + + #region GetSetPropertyValue Tests + + [TestMethod] + public void TestResultGetPropertyValueForComputerNameShouldReturnCorrectValue() + { + var testComputerName = "computerName"; + _result.ComputerName = testComputerName; + + Assert.AreEqual(testComputerName, _result.GetPropertyValue(TestResultProperties.ComputerName)); + } + + [TestMethod] + public void TestResultGetPropertyValueForDisplayNameShouldReturnCorrectValue() + { + var testDisplayName = "displayName"; + _result.DisplayName = testDisplayName; + + Assert.AreEqual(testDisplayName, _result.GetPropertyValue(TestResultProperties.DisplayName)); + } + + [TestMethod] + public void TestResultGetPropertyValueForDurationShouldReturnCorrectValue() + { + var testDuration = new TimeSpan(0, 0, 0, 10); + _result.Duration = testDuration; + + Assert.AreEqual(testDuration, _result.GetPropertyValue(TestResultProperties.Duration)); + } + + [TestMethod] + public void TestResultGetPropertyValueForEndTimeShouldReturnCorrectValue() + { + var testEndTime = new DateTimeOffset(new DateTime(2007, 3, 10, 0, 0, 10, DateTimeKind.Utc)); + _result.EndTime = testEndTime; + + Assert.AreEqual(testEndTime, _result.GetPropertyValue(TestResultProperties.EndTime)); + } + + [TestMethod] + public void TestResultGetPropertyValueForErrorMessageShouldReturnCorrectValue() + { + var testErrorMessage = "error123"; + _result.ErrorMessage = testErrorMessage; + + Assert.AreEqual(testErrorMessage, _result.GetPropertyValue(TestResultProperties.ErrorMessage)); + } + + [TestMethod] + public void TestResultGetPropertyValueForErrorStackTraceShouldReturnCorrectValue() + { + var testErrorStackTrace = "errorStack"; + _result.ErrorStackTrace = testErrorStackTrace; + + Assert.AreEqual(testErrorStackTrace, _result.GetPropertyValue(TestResultProperties.ErrorStackTrace)); + } + + [TestMethod] + public void TestResultGetPropertyValueForTestOutcomeShouldReturnCorrectValue() + { + var testOutcome = TestOutcome.Passed; + _result.Outcome = testOutcome; + + Assert.AreEqual(testOutcome, _result.GetPropertyValue(TestResultProperties.Outcome)); + } + + [TestMethod] + public void TestResultGetPropertyValueForStartTimeShouldReturnCorrectValue() + { + var testStartTime = new DateTimeOffset(new DateTime(2007, 3, 10, 0, 0, 0, DateTimeKind.Utc)); + _result.StartTime = testStartTime; + + Assert.AreEqual(testStartTime, _result.GetPropertyValue(TestResultProperties.StartTime)); + } + + [TestMethod] + public void TestResultSetPropertyValueForComputerNameShouldSetValue() + { + var testComputerName = "computerNameSet"; + _result.SetPropertyValue(TestResultProperties.ComputerName, testComputerName); + + Assert.AreEqual(testComputerName, _result.ComputerName); + } + + [TestMethod] + public void TestResultSetPropertyValueForDisplayNameShouldSetValue() + { + var testDisplayName = "displayNameSet"; + _result.SetPropertyValue(TestResultProperties.DisplayName, testDisplayName); + + Assert.AreEqual(testDisplayName, _result.DisplayName); + } + + [TestMethod] + public void TestResultSetPropertyValueForDurationShouldSetValue() + { + var testDuration = new TimeSpan(0, 0, 0, 20); + _result.SetPropertyValue(TestResultProperties.Duration, testDuration); + + Assert.AreEqual(testDuration, _result.Duration); + } + + [TestMethod] + public void TestResultSetPropertyValueForEndTimeShouldSetValue() + { + var testEndTime = new DateTimeOffset(new DateTime(2007, 5, 10, 0, 0, 10, DateTimeKind.Utc)); + _result.SetPropertyValue(TestResultProperties.EndTime, testEndTime); + + Assert.AreEqual(testEndTime, _result.EndTime); + } + + [TestMethod] + public void TestResultSetPropertyValueForErrorMessageShouldSetValue() + { + var testErrorMessage = "error123Set"; + _result.SetPropertyValue(TestResultProperties.ErrorMessage, testErrorMessage); + + Assert.AreEqual(testErrorMessage, _result.ErrorMessage); + } + + [TestMethod] + public void TestResultSetPropertyValueForErrorStackTraceShouldSetValue() + { + var testErrorStackTrace = "errorStackSet"; + _result.SetPropertyValue(TestResultProperties.ErrorStackTrace, testErrorStackTrace); + + Assert.AreEqual(testErrorStackTrace, _result.ErrorStackTrace); + } + + [TestMethod] + public void TestResultSetPropertyValueForTestOutcomeShouldSetValue() + { + var testOutcome = TestOutcome.Failed; + _result.SetPropertyValue(TestResultProperties.Outcome, testOutcome); + + Assert.AreEqual(testOutcome, _result.Outcome); + } + + [TestMethod] + public void TestResultSetPropertyValueForStartTimeShouldSetValue() + { + var testStartTime = new DateTimeOffset(new DateTime(2007, 5, 10, 0, 0, 0, DateTimeKind.Utc)); + _result.SetPropertyValue(TestResultProperties.StartTime, testStartTime); + + Assert.AreEqual(testStartTime, _result.StartTime); + } + + #endregion + +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Utilities/AssemblyHelperTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Utilities/AssemblyHelperTests.cs index bee3795169..441fbf09e2 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Utilities/AssemblyHelperTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Utilities/AssemblyHelperTests.cs @@ -3,75 +3,74 @@ #if NETFRAMEWORK -namespace Microsoft.TestPlatform.ObjectModel.UnitTests.Utilities +namespace Microsoft.TestPlatform.ObjectModel.UnitTests.Utilities; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using VisualStudio.TestTools.UnitTesting; +using Moq; +using System; + +[TestClass] +public class AssemblyHelperTests { - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using System; - - [TestClass] - public class AssemblyHelperTests + private readonly Mock _runContext; + private readonly Mock _runSettings; + + public AssemblyHelperTests() + { + _runContext = new Mock(); + _runSettings = new Mock(); + } + + [TestMethod] + public void SetNetFrameworkCompatiblityModeShouldSetAppDomainTargetFrameWorkWhenFramework40() { - private Mock runContext; - private Mock runSettings; - - public AssemblyHelperTests() - { - this.runContext = new Mock(); - this.runSettings = new Mock(); - } - - [TestMethod] - public void SetNETFrameworkCompatiblityModeShouldSetAppDomainTargetFrameWorkWhenFramework40() - { - this.runSettings.Setup(rs => rs.SettingsXml).Returns(@" Framework40 "); - this.runContext.Setup(rc => rc.RunSettings).Returns(runSettings.Object); - AppDomainSetup appDomainSetup = new AppDomainSetup(); - - AssemblyHelper.SetNETFrameworkCompatiblityMode(appDomainSetup, runContext.Object); - - Assert.AreEqual(".NETFramework,Version=v4.0", appDomainSetup.TargetFrameworkName); - } - - [TestMethod] - public void SetNETFrameworkCompatiblityModeShouldSetAppDomainTargetFrameWorkWhenNETFrameworkVersionv40() - { - this.runSettings.Setup(rs => rs.SettingsXml).Returns(@" .NETFramework,Version=v4.0 "); - this.runContext.Setup(rc => rc.RunSettings).Returns(runSettings.Object); - AppDomainSetup appDomainSetup = new AppDomainSetup(); - - AssemblyHelper.SetNETFrameworkCompatiblityMode(appDomainSetup, runContext.Object); - - Assert.AreEqual(".NETFramework,Version=v4.0", appDomainSetup.TargetFrameworkName); - } - - [TestMethod] - public void SetNETFrameworkCompatiblityModeShouldNotSetAppDomainTargetFrameWorkWhenFramework45() - { - this.runSettings.Setup(rs => rs.SettingsXml).Returns(@" Framework45 "); - this.runContext.Setup(rc => rc.RunSettings).Returns(runSettings.Object); - AppDomainSetup appDomainSetup = new AppDomainSetup(); - - AssemblyHelper.SetNETFrameworkCompatiblityMode(appDomainSetup, runContext.Object); - - Assert.IsNull(appDomainSetup.TargetFrameworkName); - } - - [TestMethod] - public void SetNETFrameworkCompatiblityModeShouldNotSetAppDomainTargetFrameWorkWhenNETFrameworkVersionv45() - { - Mock runContext = new Mock(); - Mock runSettings = new Mock(); - runSettings.Setup(rs => rs.SettingsXml).Returns(@" .NETFramework,Version=v4.5 "); - runContext.Setup(rc => rc.RunSettings).Returns(runSettings.Object); - AppDomainSetup appDomainSetup = new AppDomainSetup(); - - AssemblyHelper.SetNETFrameworkCompatiblityMode(appDomainSetup, runContext.Object); - - Assert.IsNull(appDomainSetup.TargetFrameworkName); - } + _runSettings.Setup(rs => rs.SettingsXml).Returns(@" Framework40 "); + _runContext.Setup(rc => rc.RunSettings).Returns(_runSettings.Object); + AppDomainSetup appDomainSetup = new(); + + AssemblyHelper.SetNETFrameworkCompatiblityMode(appDomainSetup, _runContext.Object); + + Assert.AreEqual(".NETFramework,Version=v4.0", appDomainSetup.TargetFrameworkName); + } + + [TestMethod] + public void SetNetFrameworkCompatiblityModeShouldSetAppDomainTargetFrameWorkWhenNetFrameworkVersionv40() + { + _runSettings.Setup(rs => rs.SettingsXml).Returns(@" .NETFramework,Version=v4.0 "); + _runContext.Setup(rc => rc.RunSettings).Returns(_runSettings.Object); + AppDomainSetup appDomainSetup = new(); + + AssemblyHelper.SetNETFrameworkCompatiblityMode(appDomainSetup, _runContext.Object); + + Assert.AreEqual(".NETFramework,Version=v4.0", appDomainSetup.TargetFrameworkName); + } + + [TestMethod] + public void SetNetFrameworkCompatiblityModeShouldNotSetAppDomainTargetFrameWorkWhenFramework45() + { + _runSettings.Setup(rs => rs.SettingsXml).Returns(@" Framework45 "); + _runContext.Setup(rc => rc.RunSettings).Returns(_runSettings.Object); + AppDomainSetup appDomainSetup = new(); + + AssemblyHelper.SetNETFrameworkCompatiblityMode(appDomainSetup, _runContext.Object); + + Assert.IsNull(appDomainSetup.TargetFrameworkName); + } + + [TestMethod] + public void SetNetFrameworkCompatiblityModeShouldNotSetAppDomainTargetFrameWorkWhenNetFrameworkVersionv45() + { + Mock runContext = new(); + Mock runSettings = new(); + runSettings.Setup(rs => rs.SettingsXml).Returns(@" .NETFramework,Version=v4.5 "); + runContext.Setup(rc => rc.RunSettings).Returns(runSettings.Object); + AppDomainSetup appDomainSetup = new(); + + AssemblyHelper.SetNETFrameworkCompatiblityMode(appDomainSetup, runContext.Object); + + Assert.IsNull(appDomainSetup.TargetFrameworkName); } } #endif diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Utilities/FilterHelperTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Utilities/FilterHelperTests.cs index a6a9e2b452..e7a1bba1d4 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Utilities/FilterHelperTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Utilities/FilterHelperTests.cs @@ -1,81 +1,82 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.ObjectModel.UnitTests.Utilities -{ - using System; - using System.Globalization; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.ObjectModel.UnitTests.Utilities; + +using System; +using System.Globalization; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - [TestClass] - public class FilterHelpersTests +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class FilterHelpersTests +{ + [TestMethod] + public void EscapeUnescapeNullThrowsArgumentNullException() { - [TestMethod] - public void EscapeUnescapeNullThrowsArgumentNullException() - { - Assert.ThrowsException(() => FilterHelper.Escape(null)); - Assert.ThrowsException(() => FilterHelper.Unescape(null)); - } + Assert.ThrowsException(() => FilterHelper.Escape(null)); + Assert.ThrowsException(() => FilterHelper.Unescape(null)); + } - [TestMethod] - public void EscapeUnescapeEmptyString() - { - Assert.AreEqual(string.Empty, FilterHelper.Escape(string.Empty)); - Assert.AreEqual(string.Empty, FilterHelper.Unescape(string.Empty)); - } + [TestMethod] + public void EscapeUnescapeEmptyString() + { + Assert.AreEqual(string.Empty, FilterHelper.Escape(string.Empty)); + Assert.AreEqual(string.Empty, FilterHelper.Unescape(string.Empty)); + } - [TestMethod] - public void EscapeUnescapeStringWithoutSpecialCharacters() - { - var str = "TestNamespace.TestClass.TestMethod"; - Assert.AreEqual(str, FilterHelper.Escape(str)); - Assert.AreEqual(str, FilterHelper.Unescape(str)); - } + [TestMethod] + public void EscapeUnescapeStringWithoutSpecialCharacters() + { + var str = "TestNamespace.TestClass.TestMethod"; + Assert.AreEqual(str, FilterHelper.Escape(str)); + Assert.AreEqual(str, FilterHelper.Unescape(str)); + } - [TestMethod] - public void EscapeUnescapeStringWithParenthesis() - { - var value = "TestClass(1).TestMethod(2)"; - var escapedValue = FilterHelper.Escape(value); + [TestMethod] + public void EscapeUnescapeStringWithParenthesis() + { + var value = "TestClass(1).TestMethod(2)"; + var escapedValue = FilterHelper.Escape(value); - Assert.AreEqual(@"TestClass\(1\).TestMethod\(2\)", escapedValue); - Assert.AreEqual(value, FilterHelper.Unescape(escapedValue)); - } + Assert.AreEqual(@"TestClass\(1\).TestMethod\(2\)", escapedValue); + Assert.AreEqual(value, FilterHelper.Unescape(escapedValue)); + } - [TestMethod] - public void EscapeUnescapeStringWithSpecialCharacters() - { - var value = @"TestClass(""a | b"").TestMethod(""x != y"")"; - var escapedValue = @"TestClass\(""a \| b""\).TestMethod\(""x \!\= y""\)"; + [TestMethod] + public void EscapeUnescapeStringWithSpecialCharacters() + { + var value = @"TestClass(""a | b"").TestMethod(""x != y"")"; + var escapedValue = @"TestClass\(""a \| b""\).TestMethod\(""x \!\= y""\)"; - Assert.AreEqual(escapedValue, FilterHelper.Escape(value)); - Assert.AreEqual(value, FilterHelper.Unescape(escapedValue)); - } + Assert.AreEqual(escapedValue, FilterHelper.Escape(value)); + Assert.AreEqual(value, FilterHelper.Unescape(escapedValue)); + } - [TestMethod] - public void EscapeUnescapeStringWithPrefix() - { - var value = @"printf(""\r\n"")"; - var escapedValue = @"printf\(""\\r\\n""\)"; + [TestMethod] + public void EscapeUnescapeStringWithPrefix() + { + var value = @"printf(""\r\n"")"; + var escapedValue = @"printf\(""\\r\\n""\)"; - Assert.AreEqual(escapedValue, FilterHelper.Escape(value)); - Assert.AreEqual(value, FilterHelper.Unescape(escapedValue)); - } + Assert.AreEqual(escapedValue, FilterHelper.Escape(value)); + Assert.AreEqual(value, FilterHelper.Unescape(escapedValue)); + } - [TestMethod] - public void UnescapeForInvalidStringThrowsArgumentException1() - { - var invalidString = @"TestClass\$""a %4 b""%2.TestMethod"; - Assert.ThrowsException(() => FilterHelper.Unescape(invalidString), string.Format(CultureInfo.CurrentCulture, Resources.TestCaseFilterEscapeException, invalidString)); - } + [TestMethod] + public void UnescapeForInvalidStringThrowsArgumentException1() + { + var invalidString = @"TestClass\$""a %4 b""%2.TestMethod"; + Assert.ThrowsException(() => FilterHelper.Unescape(invalidString), string.Format(CultureInfo.CurrentCulture, Resources.TestCaseFilterEscapeException, invalidString)); + } - [TestMethod] - public void UnescapeForInvalidStringThrowsArgumentException2() - { - var invalidString = @"TestClass\"; - Assert.ThrowsException(() => FilterHelper.Unescape(invalidString), string.Format(CultureInfo.CurrentCulture, Resources.TestCaseFilterEscapeException, invalidString)); - } + [TestMethod] + public void UnescapeForInvalidStringThrowsArgumentException2() + { + var invalidString = @"TestClass\"; + Assert.ThrowsException(() => FilterHelper.Unescape(invalidString), string.Format(CultureInfo.CurrentCulture, Resources.TestCaseFilterEscapeException, invalidString)); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Utilities/XmlRunSettingsUtilitiesTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Utilities/XmlRunSettingsUtilitiesTests.cs index 835354ade6..2b387f823e 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Utilities/XmlRunSettingsUtilitiesTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Utilities/XmlRunSettingsUtilitiesTests.cs @@ -4,21 +4,23 @@ using System; using System.Xml; -namespace Microsoft.TestPlatform.ObjectModel.UnitTests.Utilities +namespace Microsoft.TestPlatform.ObjectModel.UnitTests.Utilities; + +using System.Collections.Generic; +using System.Linq; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class XmlRunSettingsUtilitiesTests { - using System.Collections.Generic; - using System.Linq; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class XmlRunSettingsUtilitiesTests - { - #region Private Variables + #region Private Variables - private readonly string runSettingsXmlWithDataCollectors = @" + private readonly string _runSettingsXmlWithDataCollectors = @" @@ -38,7 +40,7 @@ public class XmlRunSettingsUtilitiesTests "; - private readonly string runSettingsXmlWithDataCollectorsDisabled = @" + private readonly string _runSettingsXmlWithDataCollectorsDisabled = @" @@ -58,7 +60,7 @@ public class XmlRunSettingsUtilitiesTests "; - private readonly string runSettingsXmlWithIncorrectDataCollectorSettings = @" + private readonly string _runSettingsXmlWithIncorrectDataCollectorSettings = @" @@ -78,25 +80,25 @@ public class XmlRunSettingsUtilitiesTests "; - private readonly string EmptyRunSettings = ""; + private readonly string _emptyRunSettings = ""; - #endregion + #endregion - #region GetTestRunParameters tests + #region GetTestRunParameters tests - [TestMethod] - public void GetTestRunParametersReturnsEmptyDictionaryOnNullRunSettings() - { - Dictionary trp = XmlRunSettingsUtilities.GetTestRunParameters(null); - Assert.IsNotNull(trp); - Assert.AreEqual(0, trp.Count); - } + [TestMethod] + public void GetTestRunParametersReturnsEmptyDictionaryOnNullRunSettings() + { + Dictionary trp = XmlRunSettingsUtilities.GetTestRunParameters(null); + Assert.IsNotNull(trp); + Assert.AreEqual(0, trp.Count); + } - [TestMethod] - public void GetTestRunParametersReturnsEmptyDictionaryWhenNoTestRunParameters() - { - string settingsXml = - @" + [TestMethod] + public void GetTestRunParametersReturnsEmptyDictionaryWhenNoTestRunParameters() + { + string settingsXml = + @" .\TestResults @@ -105,16 +107,16 @@ public void GetTestRunParametersReturnsEmptyDictionaryWhenNoTestRunParameters() "; - Dictionary trp = XmlRunSettingsUtilities.GetTestRunParameters(settingsXml); - Assert.IsNotNull(trp); - Assert.AreEqual(0, trp.Count); - } + Dictionary trp = XmlRunSettingsUtilities.GetTestRunParameters(settingsXml); + Assert.IsNotNull(trp); + Assert.AreEqual(0, trp.Count); + } - [TestMethod] - public void GetTestRunParametersReturnsEmptyDictionaryForEmptyTestRunParametersNode() - { - string settingsXml = - @" + [TestMethod] + public void GetTestRunParametersReturnsEmptyDictionaryForEmptyTestRunParametersNode() + { + string settingsXml = + @" .\TestResults @@ -125,16 +127,16 @@ public void GetTestRunParametersReturnsEmptyDictionaryForEmptyTestRunParametersN "; - Dictionary trp = XmlRunSettingsUtilities.GetTestRunParameters(settingsXml); - Assert.IsNotNull(trp); - Assert.AreEqual(0, trp.Count); - } + Dictionary trp = XmlRunSettingsUtilities.GetTestRunParameters(settingsXml); + Assert.IsNotNull(trp); + Assert.AreEqual(0, trp.Count); + } - [TestMethod] - public void GetTestRunParametersReturns1EntryOn1TestRunParameter() - { - string settingsXml = - @" + [TestMethod] + public void GetTestRunParametersReturns1EntryOn1TestRunParameter() + { + string settingsXml = + @" .\TestResults @@ -146,20 +148,20 @@ public void GetTestRunParametersReturns1EntryOn1TestRunParameter() "; - Dictionary trp = XmlRunSettingsUtilities.GetTestRunParameters(settingsXml); - Assert.IsNotNull(trp); - Assert.AreEqual(1, trp.Count); + Dictionary trp = XmlRunSettingsUtilities.GetTestRunParameters(settingsXml); + Assert.IsNotNull(trp); + Assert.AreEqual(1, trp.Count); - // Verify Parameter Values. - Assert.IsTrue(trp.ContainsKey("webAppUrl")); - Assert.AreEqual("http://localhost", trp["webAppUrl"]); - } + // Verify Parameter Values. + Assert.IsTrue(trp.ContainsKey("webAppUrl")); + Assert.AreEqual("http://localhost", trp["webAppUrl"]); + } - [TestMethod] - public void GetTestRunParametersReturns3EntryOn3TestRunParameter() - { - string settingsXml = - @" + [TestMethod] + public void GetTestRunParametersReturns3EntryOn3TestRunParameter() + { + string settingsXml = + @" .\TestResults @@ -173,24 +175,24 @@ public void GetTestRunParametersReturns3EntryOn3TestRunParameter() "; - Dictionary trp = XmlRunSettingsUtilities.GetTestRunParameters(settingsXml); - Assert.IsNotNull(trp); - Assert.AreEqual(3, trp.Count); - - // Verify Parameter Values. - Assert.IsTrue(trp.ContainsKey("webAppUrl")); - Assert.AreEqual("http://localhost", trp["webAppUrl"]); - Assert.IsTrue(trp.ContainsKey("webAppUserName")); - Assert.AreEqual("Admin", trp["webAppUserName"]); - Assert.IsTrue(trp.ContainsKey("webAppPassword")); - Assert.AreEqual("Password",trp["webAppPassword"]); - } + Dictionary trp = XmlRunSettingsUtilities.GetTestRunParameters(settingsXml); + Assert.IsNotNull(trp); + Assert.AreEqual(3, trp.Count); + + // Verify Parameter Values. + Assert.IsTrue(trp.ContainsKey("webAppUrl")); + Assert.AreEqual("http://localhost", trp["webAppUrl"]); + Assert.IsTrue(trp.ContainsKey("webAppUserName")); + Assert.AreEqual("Admin", trp["webAppUserName"]); + Assert.IsTrue(trp.ContainsKey("webAppPassword")); + Assert.AreEqual("Password", trp["webAppPassword"]); + } - [TestMethod] - public void GetTestRunParametersThrowsWhenTRPNodeHasAttributes() - { - string settingsXml = - @" + [TestMethod] + public void GetTestRunParametersThrowsWhenTrpNodeHasAttributes() + { + string settingsXml = + @" .\TestResults @@ -202,14 +204,14 @@ public void GetTestRunParametersThrowsWhenTRPNodeHasAttributes() "; - Assert.ThrowsException(() => XmlRunSettingsUtilities.GetTestRunParameters(settingsXml)); - } + Assert.ThrowsException(() => XmlRunSettingsUtilities.GetTestRunParameters(settingsXml)); + } - [TestMethod] - public void GetTestRunParametersThrowsWhenTRPNodeHasNonParameterTypeChildNodes() - { - string settingsXml = - @" + [TestMethod] + public void GetTestRunParametersThrowsWhenTrpNodeHasNonParameterTypeChildNodes() + { + string settingsXml = + @" .\TestResults @@ -222,14 +224,14 @@ public void GetTestRunParametersThrowsWhenTRPNodeHasNonParameterTypeChildNodes() "; - Assert.ThrowsException(() => XmlRunSettingsUtilities.GetTestRunParameters(settingsXml)); - } + Assert.ThrowsException(() => XmlRunSettingsUtilities.GetTestRunParameters(settingsXml)); + } - [TestMethod] - public void GetTestRunParametersIgnoresMalformedKeyValues() - { - string settingsXml = - @" + [TestMethod] + public void GetTestRunParametersIgnoresMalformedKeyValues() + { + string settingsXml = + @" .\TestResults @@ -241,15 +243,15 @@ public void GetTestRunParametersIgnoresMalformedKeyValues() "; - Dictionary trp = XmlRunSettingsUtilities.GetTestRunParameters(settingsXml); - Assert.IsNotNull(trp); - Assert.AreEqual(0, trp.Count); - } + Dictionary trp = XmlRunSettingsUtilities.GetTestRunParameters(settingsXml); + Assert.IsNotNull(trp); + Assert.AreEqual(0, trp.Count); + } - [TestMethod] - public void GetInProcDataCollectionRunSettingsFromSettings() - { - string settingsXml= @" + [TestMethod] + public void GetInProcDataCollectionRunSettingsFromSettings() + { + string settingsXml = @" @@ -260,15 +262,15 @@ public void GetInProcDataCollectionRunSettingsFromSettings() "; - var inProcDCRunSettings = XmlRunSettingsUtilities.GetInProcDataCollectionRunSettings(settingsXml); - Assert.IsNotNull(inProcDCRunSettings); - Assert.AreEqual(1, inProcDCRunSettings.DataCollectorSettingsList.Count); - } + var inProcDcRunSettings = XmlRunSettingsUtilities.GetInProcDataCollectionRunSettings(settingsXml); + Assert.IsNotNull(inProcDcRunSettings); + Assert.AreEqual(1, inProcDcRunSettings.DataCollectorSettingsList.Count); + } - [TestMethod] - public void GetInProcDataCollectionRunSettingsThrowsExceptionWhenXMLNotValid() - { - string settingsXml = @" + [TestMethod] + public void GetInProcDataCollectionRunSettingsThrowsExceptionWhenXmlNotValid() + { + string settingsXml = @" @@ -280,100 +282,100 @@ public void GetInProcDataCollectionRunSettingsThrowsExceptionWhenXMLNotValid() "; - Assert.ThrowsException( - () => XmlRunSettingsUtilities.GetInProcDataCollectionRunSettings(settingsXml)); - } - #endregion + Assert.ThrowsException( + () => XmlRunSettingsUtilities.GetInProcDataCollectionRunSettings(settingsXml)); + } + #endregion - #region CreateDefaultRunSettings tests + #region CreateDefaultRunSettings tests - [TestMethod] - public void CreateDefaultRunSettingsShouldReturnABasicRunSettings() - { - var defaultRunSettings = XmlRunSettingsUtilities.CreateDefaultRunSettings().CreateNavigator().OuterXml; - var expectedRunSettings = string.Join(Environment.NewLine, - "", - " ", - " ", - " ", - "" - ); - - Assert.AreEqual(expectedRunSettings, defaultRunSettings); - } + [TestMethod] + public void CreateDefaultRunSettingsShouldReturnABasicRunSettings() + { + var defaultRunSettings = XmlRunSettingsUtilities.CreateDefaultRunSettings().CreateNavigator().OuterXml; + var expectedRunSettings = string.Join(Environment.NewLine, + "", + " ", + " ", + " ", + "" + ); + + Assert.AreEqual(expectedRunSettings, defaultRunSettings); + } - #endregion + #endregion - #region IsDataCollectionEnabled tests + #region IsDataCollectionEnabled tests - [TestMethod] - public void IsDataCollectionEnabledShouldReturnFalseIfRunSettingsIsNull() - { - Assert.IsFalse(XmlRunSettingsUtilities.IsDataCollectionEnabled(null)); - } + [TestMethod] + public void IsDataCollectionEnabledShouldReturnFalseIfRunSettingsIsNull() + { + Assert.IsFalse(XmlRunSettingsUtilities.IsDataCollectionEnabled(null)); + } - [TestMethod] - public void IsDataCollectionEnabledShouldReturnFalseIfDataCollectionNodeIsNotPresent() - { - Assert.IsFalse(XmlRunSettingsUtilities.IsDataCollectionEnabled(EmptyRunSettings)); - } + [TestMethod] + public void IsDataCollectionEnabledShouldReturnFalseIfDataCollectionNodeIsNotPresent() + { + Assert.IsFalse(XmlRunSettingsUtilities.IsDataCollectionEnabled(_emptyRunSettings)); + } - [TestMethod] - public void IsDataCollectionEnabledShouldReturnFalseIfDataCollectionIsDisabled() - { - Assert.IsFalse(XmlRunSettingsUtilities.IsDataCollectionEnabled(this.runSettingsXmlWithDataCollectorsDisabled)); - } + [TestMethod] + public void IsDataCollectionEnabledShouldReturnFalseIfDataCollectionIsDisabled() + { + Assert.IsFalse(XmlRunSettingsUtilities.IsDataCollectionEnabled(_runSettingsXmlWithDataCollectorsDisabled)); + } - [TestMethod] - public void IsDataCollectionEnabledShouldReturnTrueIfDataCollectionIsEnabled() - { - Assert.IsTrue(XmlRunSettingsUtilities.IsDataCollectionEnabled(this.runSettingsXmlWithDataCollectors)); - } + [TestMethod] + public void IsDataCollectionEnabledShouldReturnTrueIfDataCollectionIsEnabled() + { + Assert.IsTrue(XmlRunSettingsUtilities.IsDataCollectionEnabled(_runSettingsXmlWithDataCollectors)); + } - #endregion + #endregion - #region IsInProcDataCollectionEnabled tests. + #region IsInProcDataCollectionEnabled tests. - [TestMethod] - public void IsInProcDataCollectionEnabledShouldReturnFalseIfRunSettingsIsNull() - { - Assert.IsFalse(XmlRunSettingsUtilities.IsInProcDataCollectionEnabled(null)); - } + [TestMethod] + public void IsInProcDataCollectionEnabledShouldReturnFalseIfRunSettingsIsNull() + { + Assert.IsFalse(XmlRunSettingsUtilities.IsInProcDataCollectionEnabled(null)); + } - [TestMethod] - public void IsInProcDataCollectionEnabledShouldReturnFalseIfDataCollectionNodeIsNotPresent() - { - Assert.IsFalse(XmlRunSettingsUtilities.IsInProcDataCollectionEnabled(EmptyRunSettings)); - } + [TestMethod] + public void IsInProcDataCollectionEnabledShouldReturnFalseIfDataCollectionNodeIsNotPresent() + { + Assert.IsFalse(XmlRunSettingsUtilities.IsInProcDataCollectionEnabled(_emptyRunSettings)); + } - [TestMethod] - public void IsInProcDataCollectionEnabledShouldReturnFalseIfDataCollectionIsDisabled() - { - Assert.IsFalse(XmlRunSettingsUtilities.IsInProcDataCollectionEnabled(this.ConvertOutOfProcDataCollectionSettingsToInProcDataCollectionSettings(this.runSettingsXmlWithDataCollectorsDisabled))); - } + [TestMethod] + public void IsInProcDataCollectionEnabledShouldReturnFalseIfDataCollectionIsDisabled() + { + Assert.IsFalse(XmlRunSettingsUtilities.IsInProcDataCollectionEnabled(ConvertOutOfProcDataCollectionSettingsToInProcDataCollectionSettings(_runSettingsXmlWithDataCollectorsDisabled))); + } - [TestMethod] - public void IsInProcDataCollectionEnabledShouldReturnTrueIfDataCollectionIsEnabled() - { - Assert.IsTrue(XmlRunSettingsUtilities.IsInProcDataCollectionEnabled(this.ConvertOutOfProcDataCollectionSettingsToInProcDataCollectionSettings(this.runSettingsXmlWithDataCollectors))); - } + [TestMethod] + public void IsInProcDataCollectionEnabledShouldReturnTrueIfDataCollectionIsEnabled() + { + Assert.IsTrue(XmlRunSettingsUtilities.IsInProcDataCollectionEnabled(ConvertOutOfProcDataCollectionSettingsToInProcDataCollectionSettings(_runSettingsXmlWithDataCollectors))); + } - #endregion + #endregion - #region GetLoggerRunsettings tests + #region GetLoggerRunsettings tests - [TestMethod] - public void GetLoggerRunSettingsShouldReturnNullWhenSettingsIsnull() - { - Assert.IsNull(XmlRunSettingsUtilities.GetLoggerRunSettings(null)); - } + [TestMethod] + public void GetLoggerRunSettingsShouldReturnNullWhenSettingsIsnull() + { + Assert.IsNull(XmlRunSettingsUtilities.GetLoggerRunSettings(null)); + } - [TestMethod] - public void GetLoggerRunSettingShouldReturnNullWhenNoLoggersPresent() - { - string runSettingsXmlWithNoLoggers = - @" + [TestMethod] + public void GetLoggerRunSettingShouldReturnNullWhenNoLoggersPresent() + { + string runSettingsXmlWithNoLoggers = + @" @@ -394,14 +396,14 @@ public void GetLoggerRunSettingShouldReturnNullWhenNoLoggersPresent() "; - Assert.IsNull(XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsXmlWithNoLoggers)); - } + Assert.IsNull(XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsXmlWithNoLoggers)); + } - [TestMethod] - public void GetLoggerRunSettingsShouldNotReturnNullWhenLoggersPresent() - { - string runSettingsWithLoggerHavingFriendlyName = - @" + [TestMethod] + public void GetLoggerRunSettingsShouldNotReturnNullWhenLoggersPresent() + { + string runSettingsWithLoggerHavingFriendlyName = + @" @@ -412,14 +414,14 @@ public void GetLoggerRunSettingsShouldNotReturnNullWhenLoggersPresent() "; - Assert.IsNotNull(XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingFriendlyName)); - } + Assert.IsNotNull(XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingFriendlyName)); + } - [TestMethod] - public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectFriendlyName() - { - string runSettingsWithLoggerHavingFriendlyName = - @" + [TestMethod] + public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectFriendlyName() + { + string runSettingsWithLoggerHavingFriendlyName = + @" @@ -430,15 +432,15 @@ public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectFriendlyName() "; - var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingFriendlyName); - Assert.AreEqual("TestLoggerWithParameterExtension", loggerRunSettings.LoggerSettingsList.First().FriendlyName); - } + var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingFriendlyName); + Assert.AreEqual("TestLoggerWithParameterExtension", loggerRunSettings.LoggerSettingsList.First().FriendlyName); + } - [TestMethod] - public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectUri() - { - string runSettingsWithLoggerHavingUri = - @" + [TestMethod] + public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectUri() + { + string runSettingsWithLoggerHavingUri = + @" @@ -449,15 +451,15 @@ public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectUri() "; - var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingUri); - Assert.IsTrue(new Uri("testlogger://logger").Equals(loggerRunSettings.LoggerSettingsList.First().Uri)); - } + var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingUri); + Assert.IsTrue(new Uri("testlogger://logger").Equals(loggerRunSettings.LoggerSettingsList.First().Uri)); + } - [TestMethod] - public void GetLoggerRunSettingsShouldThrowWhenInvalidUri() - { - string runSettingsWithInvalidUri = - @" + [TestMethod] + public void GetLoggerRunSettingsShouldThrowWhenInvalidUri() + { + string runSettingsWithInvalidUri = + @" @@ -468,29 +470,29 @@ public void GetLoggerRunSettingsShouldThrowWhenInvalidUri() "; - var exceptionMessage = string.Empty; - - try - { - XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithInvalidUri); - } - catch (SettingsException ex) - { - exceptionMessage = ex.Message; - } - - Assert.IsTrue(exceptionMessage.Contains( - string.Format( - Resources.InvalidUriInSettings, - "invalidUri", - "Logger"))); - } + var exceptionMessage = string.Empty; - [TestMethod] - public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectAssemblyQualifiedName() + try + { + XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithInvalidUri); + } + catch (SettingsException ex) { - string runSettingsWithLoggerHavingAssemblyQualifiedName = - @" + exceptionMessage = ex.Message; + } + + Assert.IsTrue(exceptionMessage.Contains( + string.Format( + Resources.InvalidUriInSettings, + "invalidUri", + "Logger"))); + } + + [TestMethod] + public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectAssemblyQualifiedName() + { + string runSettingsWithLoggerHavingAssemblyQualifiedName = + @" @@ -501,15 +503,15 @@ public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectAssemblyQualifiedNa "; - var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingAssemblyQualifiedName); - Assert.AreEqual("Sample.Sample.Sample.SampleLogger, Sample.Sample.Logger, Version=0.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx", loggerRunSettings.LoggerSettingsList.First().AssemblyQualifiedName); - } + var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingAssemblyQualifiedName); + Assert.AreEqual("Sample.Sample.Sample.SampleLogger, Sample.Sample.Logger, Version=0.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx", loggerRunSettings.LoggerSettingsList.First().AssemblyQualifiedName); + } - [TestMethod] - public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectCodeBase() - { - string runSettingsWithLoggerHavingAssemblyQualifiedName = - @" + [TestMethod] + public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectCodeBase() + { + string runSettingsWithLoggerHavingAssemblyQualifiedName = + @" @@ -520,15 +522,15 @@ public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectCodeBase() "; - var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingAssemblyQualifiedName); - Assert.AreEqual(@"C:\Sample\Sample.TestLogger.dll", loggerRunSettings.LoggerSettingsList.First().CodeBase); - } + var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingAssemblyQualifiedName); + Assert.AreEqual(@"C:\Sample\Sample.TestLogger.dll", loggerRunSettings.LoggerSettingsList.First().CodeBase); + } - [TestMethod] - public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectEnabledAttributeValue() - { - string runSettingsWithLoggerHavingEnabledAttribute = - @" + [TestMethod] + public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectEnabledAttributeValue() + { + string runSettingsWithLoggerHavingEnabledAttribute = + @" @@ -539,15 +541,15 @@ public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectEnabledAttributeVal "; - var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingEnabledAttribute); - Assert.IsFalse(loggerRunSettings.LoggerSettingsList.First().IsEnabled); - } + var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingEnabledAttribute); + Assert.IsFalse(loggerRunSettings.LoggerSettingsList.First().IsEnabled); + } - [TestMethod] - public void GetLoggerRunSettingsShouldReturnLoggerWithEnabledFalseIfInvalidEnabledValue() - { - string runSettingsWithLoggerHavingInvalidEnabledValue = - @" + [TestMethod] + public void GetLoggerRunSettingsShouldReturnLoggerWithEnabledFalseIfInvalidEnabledValue() + { + string runSettingsWithLoggerHavingInvalidEnabledValue = + @" @@ -558,15 +560,15 @@ public void GetLoggerRunSettingsShouldReturnLoggerWithEnabledFalseIfInvalidEnabl "; - var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingInvalidEnabledValue); - Assert.IsFalse(loggerRunSettings.LoggerSettingsList.First().IsEnabled); - } + var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingInvalidEnabledValue); + Assert.IsFalse(loggerRunSettings.LoggerSettingsList.First().IsEnabled); + } - [TestMethod] - public void GetLoggerRunSettingsShouldReturnLoggerAsEnabledWhenEnabledAttributeNotPresent() - { - string runSettingsWithLoggerHavingEnabledAttribute = - @" + [TestMethod] + public void GetLoggerRunSettingsShouldReturnLoggerAsEnabledWhenEnabledAttributeNotPresent() + { + string runSettingsWithLoggerHavingEnabledAttribute = + @" @@ -577,15 +579,15 @@ public void GetLoggerRunSettingsShouldReturnLoggerAsEnabledWhenEnabledAttributeN "; - var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingEnabledAttribute); - Assert.IsTrue(loggerRunSettings.LoggerSettingsList.First().IsEnabled); - } + var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingEnabledAttribute); + Assert.IsTrue(loggerRunSettings.LoggerSettingsList.First().IsEnabled); + } - [TestMethod] - public void GetLoggerRunSettingsShouldThrowIfDuplicateAttributesPresent() - { - string runSettingsWithLoggerHavingDuplicateAttributes = - @" + [TestMethod] + public void GetLoggerRunSettingsShouldThrowIfDuplicateAttributesPresent() + { + string runSettingsWithLoggerHavingDuplicateAttributes = + @" @@ -596,25 +598,25 @@ public void GetLoggerRunSettingsShouldThrowIfDuplicateAttributesPresent() "; - var exceptionMessage = string.Empty; - - try - { - XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingDuplicateAttributes); - } - catch (SettingsException ex) - { - exceptionMessage = ex.Message; - } + var exceptionMessage = string.Empty; - Assert.IsTrue(exceptionMessage.Contains(CommonResources.MalformedRunSettingsFile)); + try + { + XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingDuplicateAttributes); } - - [TestMethod] - public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectValuesWhenMultipleAttributesPresent() + catch (SettingsException ex) { - string runSettingsWithLoggerHavingMultipleAttributes = - @" + exceptionMessage = ex.Message; + } + + Assert.IsTrue(exceptionMessage.Contains(CommonResources.MalformedRunSettingsFile)); + } + + [TestMethod] + public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectValuesWhenMultipleAttributesPresent() + { + string runSettingsWithLoggerHavingMultipleAttributes = + @" @@ -625,19 +627,19 @@ public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectValuesWhenMultipleA "; - var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingMultipleAttributes); - Assert.AreEqual("TestLoggerWithParameterExtension", loggerRunSettings.LoggerSettingsList.First().FriendlyName); - Assert.IsTrue(new Uri("testlogger://logger").Equals(loggerRunSettings.LoggerSettingsList.First().Uri)); - Assert.AreEqual("Sample.Sample.Sample.SampleLogger, Sample.Sample.Logger, Version=0.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx", loggerRunSettings.LoggerSettingsList.First().AssemblyQualifiedName); - Assert.AreEqual(@"C:\Sample\Sample.TestLogger.dll", loggerRunSettings.LoggerSettingsList.First().CodeBase); - Assert.IsFalse(loggerRunSettings.LoggerSettingsList.First().IsEnabled); - } + var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingMultipleAttributes); + Assert.AreEqual("TestLoggerWithParameterExtension", loggerRunSettings.LoggerSettingsList.First().FriendlyName); + Assert.IsTrue(new Uri("testlogger://logger").Equals(loggerRunSettings.LoggerSettingsList.First().Uri)); + Assert.AreEqual("Sample.Sample.Sample.SampleLogger, Sample.Sample.Logger, Version=0.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx", loggerRunSettings.LoggerSettingsList.First().AssemblyQualifiedName); + Assert.AreEqual(@"C:\Sample\Sample.TestLogger.dll", loggerRunSettings.LoggerSettingsList.First().CodeBase); + Assert.IsFalse(loggerRunSettings.LoggerSettingsList.First().IsEnabled); + } - [TestMethod] - public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectValuesWhenCaseSensitivityNotMaintained() - { - string runSettingsWithLoggerHavingAttributesWithRandomCasing = - @" + [TestMethod] + public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectValuesWhenCaseSensitivityNotMaintained() + { + string runSettingsWithLoggerHavingAttributesWithRandomCasing = + @" @@ -648,19 +650,19 @@ public void GetLoggerRunSettingsShouldReturnLoggerWithCorrectValuesWhenCaseSensi "; - var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingAttributesWithRandomCasing); - Assert.AreEqual("TestLoggerWithParameterExtension", loggerRunSettings.LoggerSettingsList.First().FriendlyName); - Assert.IsTrue(new Uri("testlogger://logger").Equals(loggerRunSettings.LoggerSettingsList.First().Uri)); - Assert.AreEqual("Sample.Sample.Sample.SampleLogger, Sample.Sample.Logger, Version=0.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx", loggerRunSettings.LoggerSettingsList.First().AssemblyQualifiedName); - Assert.AreEqual(@"C:\Sample\Sample.TestLogger.dll", loggerRunSettings.LoggerSettingsList.First().CodeBase); - Assert.IsFalse(loggerRunSettings.LoggerSettingsList.First().IsEnabled); - } + var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithLoggerHavingAttributesWithRandomCasing); + Assert.AreEqual("TestLoggerWithParameterExtension", loggerRunSettings.LoggerSettingsList.First().FriendlyName); + Assert.IsTrue(new Uri("testlogger://logger").Equals(loggerRunSettings.LoggerSettingsList.First().Uri)); + Assert.AreEqual("Sample.Sample.Sample.SampleLogger, Sample.Sample.Logger, Version=0.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx", loggerRunSettings.LoggerSettingsList.First().AssemblyQualifiedName); + Assert.AreEqual(@"C:\Sample\Sample.TestLogger.dll", loggerRunSettings.LoggerSettingsList.First().CodeBase); + Assert.IsFalse(loggerRunSettings.LoggerSettingsList.First().IsEnabled); + } - [TestMethod] - public void GetLoggerRunSettingsShouldThrowShouldThrowOnMalformedLoggerSettings() - { - string runSettingsXmlWithMalformedLoggerSettings = - @" + [TestMethod] + public void GetLoggerRunSettingsShouldThrowShouldThrowOnMalformedLoggerSettings() + { + string runSettingsXmlWithMalformedLoggerSettings = + @" @@ -671,25 +673,25 @@ public void GetLoggerRunSettingsShouldThrowShouldThrowOnMalformedLoggerSettings( "; - var exceptionMessage = string.Empty; + var exceptionMessage = string.Empty; - try - { - XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsXmlWithMalformedLoggerSettings); - } - catch (SettingsException ex) - { - exceptionMessage = ex.Message; - } - - Assert.IsTrue(exceptionMessage.Contains(CommonResources.MalformedRunSettingsFile)); + try + { + XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsXmlWithMalformedLoggerSettings); } - - [TestMethod] - public void GetLoggerRunSettingsShouldThrowWhenAttribtuesPresentInLoggerRunSettingsNode() + catch (SettingsException ex) { - string runSettingsWithAttributesPresentInLoggerRunSettingsNode = - @" + exceptionMessage = ex.Message; + } + + Assert.IsTrue(exceptionMessage.Contains(CommonResources.MalformedRunSettingsFile)); + } + + [TestMethod] + public void GetLoggerRunSettingsShouldThrowWhenAttribtuesPresentInLoggerRunSettingsNode() + { + string runSettingsWithAttributesPresentInLoggerRunSettingsNode = + @" @@ -700,28 +702,28 @@ public void GetLoggerRunSettingsShouldThrowWhenAttribtuesPresentInLoggerRunSetti "; - var exceptionMessage = string.Empty; - - try - { - XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithAttributesPresentInLoggerRunSettingsNode); - } - catch (SettingsException ex) - { - exceptionMessage = ex.Message; - } - - Assert.IsTrue(exceptionMessage.Contains(string.Format( - Resources.InvalidSettingsXmlAttribute, - "LoggerRunSettings", - "name"))); - } + var exceptionMessage = string.Empty; - [TestMethod] - public void GetLoggerRunSettingsShouldReturnEmptyLoggerRunSettingsWhenLoggerRunSettingsNodeIsEmpty() + try { - string runSettingsWithEmptyLoggerRunSettingsNode = - @" + XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithAttributesPresentInLoggerRunSettingsNode); + } + catch (SettingsException ex) + { + exceptionMessage = ex.Message; + } + + Assert.IsTrue(exceptionMessage.Contains(string.Format( + Resources.InvalidSettingsXmlAttribute, + "LoggerRunSettings", + "name"))); + } + + [TestMethod] + public void GetLoggerRunSettingsShouldReturnEmptyLoggerRunSettingsWhenLoggerRunSettingsNodeIsEmpty() + { + string runSettingsWithEmptyLoggerRunSettingsNode = + @" @@ -729,30 +731,30 @@ public void GetLoggerRunSettingsShouldReturnEmptyLoggerRunSettingsWhenLoggerRunS "; - var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithEmptyLoggerRunSettingsNode); - Assert.AreEqual(0, loggerRunSettings.LoggerSettingsList.Count); - } + var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithEmptyLoggerRunSettingsNode); + Assert.AreEqual(0, loggerRunSettings.LoggerSettingsList.Count); + } - [TestMethod] - public void GetLoggerRunSettingsShouldReturnEmptyLoggerRunSettingsWhenLoggerRunSettingsNodeIsSelfEnding() - { - string runSettingsWithEmptyLoggerRunSettingsNode = - @" + [TestMethod] + public void GetLoggerRunSettingsShouldReturnEmptyLoggerRunSettingsWhenLoggerRunSettingsNodeIsSelfEnding() + { + string runSettingsWithEmptyLoggerRunSettingsNode = + @" "; - var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithEmptyLoggerRunSettingsNode); - Assert.AreEqual(0, loggerRunSettings.LoggerSettingsList.Count); - } + var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithEmptyLoggerRunSettingsNode); + Assert.AreEqual(0, loggerRunSettings.LoggerSettingsList.Count); + } - [TestMethod] - public void GetLoggerRunSettingsShouldThrowWhenNodeOtherThanLoggersPresentInLoggerRunSettings() - { - string runSettingsWithNodeOtherLoggers = - @" + [TestMethod] + public void GetLoggerRunSettingsShouldThrowWhenNodeOtherThanLoggersPresentInLoggerRunSettings() + { + string runSettingsWithNodeOtherLoggers = + @" @@ -763,28 +765,28 @@ public void GetLoggerRunSettingsShouldThrowWhenNodeOtherThanLoggersPresentInLogg "; - var exceptionMessage = string.Empty; - - try - { - XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithNodeOtherLoggers); - } - catch (SettingsException ex) - { - exceptionMessage = ex.Message; - } - - Assert.IsTrue(exceptionMessage.Contains(string.Format( - Resources.InvalidSettingsXmlElement, - "LoggerRUNSettings", - "LoggersInvalid"))); - } + var exceptionMessage = string.Empty; - [TestMethod] - public void GetLoggerRunSettingsShouldThrowWhenAttribtuesPresentInLoggersNode() + try { - string runSettingsWithAttributesPresentInLoggersNode = - @" + XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithNodeOtherLoggers); + } + catch (SettingsException ex) + { + exceptionMessage = ex.Message; + } + + Assert.IsTrue(exceptionMessage.Contains(string.Format( + Resources.InvalidSettingsXmlElement, + "LoggerRUNSettings", + "LoggersInvalid"))); + } + + [TestMethod] + public void GetLoggerRunSettingsShouldThrowWhenAttribtuesPresentInLoggersNode() + { + string runSettingsWithAttributesPresentInLoggersNode = + @" @@ -795,28 +797,28 @@ public void GetLoggerRunSettingsShouldThrowWhenAttribtuesPresentInLoggersNode() "; - var exceptionMessage = string.Empty; - - try - { - XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithAttributesPresentInLoggersNode); - } - catch (SettingsException ex) - { - exceptionMessage = ex.Message; - } - - Assert.IsTrue(exceptionMessage.Contains(string.Format( - Resources.InvalidSettingsXmlAttribute, - "Loggers", - "nameAttr"))); - } + var exceptionMessage = string.Empty; - [TestMethod] - public void GetLoggerRunSettingsShouldReturnEmptyLoggersWhenLoggersIsEmpty() + try + { + XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithAttributesPresentInLoggersNode); + } + catch (SettingsException ex) { - string runSettingsWithEmptyLoggersNode = - @" + exceptionMessage = ex.Message; + } + + Assert.IsTrue(exceptionMessage.Contains(string.Format( + Resources.InvalidSettingsXmlAttribute, + "Loggers", + "nameAttr"))); + } + + [TestMethod] + public void GetLoggerRunSettingsShouldReturnEmptyLoggersWhenLoggersIsEmpty() + { + string runSettingsWithEmptyLoggersNode = + @" @@ -826,15 +828,15 @@ public void GetLoggerRunSettingsShouldReturnEmptyLoggersWhenLoggersIsEmpty() "; - var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithEmptyLoggersNode); - Assert.AreEqual(0, loggerRunSettings.LoggerSettingsList.Count); - } + var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithEmptyLoggersNode); + Assert.AreEqual(0, loggerRunSettings.LoggerSettingsList.Count); + } - [TestMethod] - public void GetLoggerRunSettingsShouldReturnEmptyLoggersWhenLoggersIsSelfEnding() - { - string runSettingsWithEmptyLoggersNode = - @" + [TestMethod] + public void GetLoggerRunSettingsShouldReturnEmptyLoggersWhenLoggersIsSelfEnding() + { + string runSettingsWithEmptyLoggersNode = + @" @@ -843,15 +845,15 @@ public void GetLoggerRunSettingsShouldReturnEmptyLoggersWhenLoggersIsSelfEnding( "; - var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithEmptyLoggersNode); - Assert.AreEqual(0, loggerRunSettings.LoggerSettingsList.Count); - } + var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithEmptyLoggersNode); + Assert.AreEqual(0, loggerRunSettings.LoggerSettingsList.Count); + } - [TestMethod] - public void GetLoggerRunSettingsShouldThrowWhenNodeOtherThanLoggerPresentInLoggers() - { - string runSettingsWithNodeOtherLoggers = - @" + [TestMethod] + public void GetLoggerRunSettingsShouldThrowWhenNodeOtherThanLoggerPresentInLoggers() + { + string runSettingsWithNodeOtherLoggers = + @" @@ -862,29 +864,29 @@ public void GetLoggerRunSettingsShouldThrowWhenNodeOtherThanLoggerPresentInLogge "; - var exceptionMessage = string.Empty; - - try - { - XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithNodeOtherLoggers); - } - catch (SettingsException ex) - { - exceptionMessage = ex.Message; - } - - Assert.IsTrue(exceptionMessage.Contains(string.Format( - Resources.InvalidSettingsXmlElement, - "Loggers", - "LoggerInvalid"))); - } + var exceptionMessage = string.Empty; - [TestMethod] - public void GetLoggerRunSettingsShouldThrowWhenRequiredAttributesNotPresentInLoggerNode() + try + { + XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithNodeOtherLoggers); + } + catch (SettingsException ex) { - // One among friendlyName, uri and assemblyQualifiedName should be present. - string runSettingsWithNoneOfRequiredAttributes = - @" + exceptionMessage = ex.Message; + } + + Assert.IsTrue(exceptionMessage.Contains(string.Format( + Resources.InvalidSettingsXmlElement, + "Loggers", + "LoggerInvalid"))); + } + + [TestMethod] + public void GetLoggerRunSettingsShouldThrowWhenRequiredAttributesNotPresentInLoggerNode() + { + // One among friendlyName, uri and assemblyQualifiedName should be present. + string runSettingsWithNoneOfRequiredAttributes = + @" @@ -895,27 +897,27 @@ public void GetLoggerRunSettingsShouldThrowWhenRequiredAttributesNotPresentInLog "; - var exceptionMessage = string.Empty; - - try - { - XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithNoneOfRequiredAttributes); - } - catch (SettingsException ex) - { - exceptionMessage = ex.Message; - } + var exceptionMessage = string.Empty; - Assert.IsTrue(exceptionMessage.Contains(string.Format( - Resources.MissingLoggerAttributes, - "LogGer"))); + try + { + XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithNoneOfRequiredAttributes); } - - [TestMethod] - public void GetLoggerRunSettingsShouldReturnConfigurationElementIfPresentInLoggerNode() + catch (SettingsException ex) { - string runSettingsWithConfigurationElementInLoggerNode = - @" + exceptionMessage = ex.Message; + } + + Assert.IsTrue(exceptionMessage.Contains(string.Format( + Resources.MissingLoggerAttributes, + "LogGer"))); + } + + [TestMethod] + public void GetLoggerRunSettingsShouldReturnConfigurationElementIfPresentInLoggerNode() + { + string runSettingsWithConfigurationElementInLoggerNode = + @" @@ -931,21 +933,21 @@ public void GetLoggerRunSettingsShouldReturnConfigurationElementIfPresentInLogge "; - var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithConfigurationElementInLoggerNode); + var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithConfigurationElementInLoggerNode); - var expectedConfigurationElement = new XmlDocument().CreateElement("ConfiGUration"); - expectedConfigurationElement.InnerXml = "Value1Value2"; - Assert.AreEqual(expectedConfigurationElement.Name, - loggerRunSettings.LoggerSettingsList.First().Configuration.Name); - Assert.AreEqual(expectedConfigurationElement.InnerXml, - loggerRunSettings.LoggerSettingsList.First().Configuration.InnerXml); - } + var expectedConfigurationElement = new XmlDocument().CreateElement("ConfiGUration"); + expectedConfigurationElement.InnerXml = "Value1Value2"; + Assert.AreEqual(expectedConfigurationElement.Name, + loggerRunSettings.LoggerSettingsList.First().Configuration.Name); + Assert.AreEqual(expectedConfigurationElement.InnerXml, + loggerRunSettings.LoggerSettingsList.First().Configuration.InnerXml); + } - [TestMethod] - public void GetLoggerRunSettingsShouldThrowWhenNodeOtherThanConfigurationPresentInLogger() - { - string runSettingsWithInvalidConfigurationElement = - @" + [TestMethod] + public void GetLoggerRunSettingsShouldThrowWhenNodeOtherThanConfigurationPresentInLogger() + { + string runSettingsWithInvalidConfigurationElement = + @" @@ -961,28 +963,28 @@ public void GetLoggerRunSettingsShouldThrowWhenNodeOtherThanConfigurationPresent "; - var exceptionMessage = string.Empty; - - try - { - XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithInvalidConfigurationElement); - } - catch (SettingsException ex) - { - exceptionMessage = ex.Message; - } - - Assert.AreEqual(string.Format( - Resources.InvalidSettingsXmlElement, - "Logger", - "ConfiGUrationInvalid"), exceptionMessage); - } + var exceptionMessage = string.Empty; - [TestMethod] - public void GetLoggerRunSettingsShouldThrowOnInvalidAttributeInLoggerNode() + try + { + XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithInvalidConfigurationElement); + } + catch (SettingsException ex) { - string runSettingsWithInvalidAttributeInLoggerNode = - @" + exceptionMessage = ex.Message; + } + + Assert.AreEqual(string.Format( + Resources.InvalidSettingsXmlElement, + "Logger", + "ConfiGUrationInvalid"), exceptionMessage); + } + + [TestMethod] + public void GetLoggerRunSettingsShouldThrowOnInvalidAttributeInLoggerNode() + { + string runSettingsWithInvalidAttributeInLoggerNode = + @" @@ -998,28 +1000,28 @@ public void GetLoggerRunSettingsShouldThrowOnInvalidAttributeInLoggerNode() "; - var exceptionMessage = string.Empty; - - try - { - XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithInvalidAttributeInLoggerNode); - } - catch (SettingsException ex) - { - exceptionMessage = ex.Message; - } - - Assert.AreEqual(string.Format( - Resources.InvalidSettingsXmlAttribute, - "Logger", - "invalidAttr"), exceptionMessage); - } + var exceptionMessage = string.Empty; - [TestMethod] - public void GetLoggerRunSettingsShouldReturnMultipleLoggersIfPresent() + try + { + XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithInvalidAttributeInLoggerNode); + } + catch (SettingsException ex) { - string runSettingsWithMultipleLoggers = - @" + exceptionMessage = ex.Message; + } + + Assert.AreEqual(string.Format( + Resources.InvalidSettingsXmlAttribute, + "Logger", + "invalidAttr"), exceptionMessage); + } + + [TestMethod] + public void GetLoggerRunSettingsShouldReturnMultipleLoggersIfPresent() + { + string runSettingsWithMultipleLoggers = + @" @@ -1042,44 +1044,44 @@ public void GetLoggerRunSettingsShouldReturnMultipleLoggersIfPresent() "; - var loggerRunSettings = - XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithMultipleLoggers); - - Assert.AreEqual(3, loggerRunSettings.LoggerSettingsList.Count); - - // 1st logger - var loggerFirst = loggerRunSettings.LoggerSettingsList[0]; - Assert.AreEqual("TestLoggerWithParameterExtension", loggerFirst.FriendlyName); - Assert.IsTrue(string.IsNullOrWhiteSpace(loggerFirst.Uri?.ToString())); - Assert.IsTrue(string.IsNullOrWhiteSpace(loggerFirst.AssemblyQualifiedName)); - Assert.IsTrue(string.IsNullOrWhiteSpace(loggerFirst.CodeBase)); - Assert.IsTrue(loggerFirst.IsEnabled); - Assert.AreEqual("Value1Value2", loggerFirst.Configuration.InnerXml); - - // 2nd logger - var loggerSecond = loggerRunSettings.LoggerSettingsList[1]; - Assert.AreEqual("TestLogger", loggerSecond.FriendlyName); - Assert.AreEqual(new Uri("testlogger://logger").ToString(), loggerSecond.Uri.ToString()); - Assert.AreEqual("Sample.Sample.Sample.SampleLogger, Sample.Sample.Logger, Version=0.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx", loggerSecond.AssemblyQualifiedName); - Assert.AreEqual(@"C:\Sample\Sample.TestLogger.dll", loggerSecond.CodeBase); - Assert.IsFalse(loggerSecond.IsEnabled); - Assert.IsNull(loggerSecond.Configuration); - - // 3rd logger - var loggerThird = loggerRunSettings.LoggerSettingsList[2]; - Assert.IsTrue(string.IsNullOrWhiteSpace(loggerThird.FriendlyName)); - Assert.AreEqual(new Uri("testlogger://loggerTemp").ToString(), loggerThird.Uri.ToString()); - Assert.IsTrue(string.IsNullOrWhiteSpace(loggerThird.AssemblyQualifiedName)); - Assert.IsTrue(string.IsNullOrWhiteSpace(loggerThird.CodeBase)); - Assert.IsTrue(loggerThird.IsEnabled); - Assert.AreEqual("Value3Value4", loggerThird.Configuration.InnerXml); - } + var loggerRunSettings = + XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithMultipleLoggers); + + Assert.AreEqual(3, loggerRunSettings.LoggerSettingsList.Count); + + // 1st logger + var loggerFirst = loggerRunSettings.LoggerSettingsList[0]; + Assert.AreEqual("TestLoggerWithParameterExtension", loggerFirst.FriendlyName); + Assert.IsTrue(string.IsNullOrWhiteSpace(loggerFirst.Uri?.ToString())); + Assert.IsTrue(string.IsNullOrWhiteSpace(loggerFirst.AssemblyQualifiedName)); + Assert.IsTrue(string.IsNullOrWhiteSpace(loggerFirst.CodeBase)); + Assert.IsTrue(loggerFirst.IsEnabled); + Assert.AreEqual("Value1Value2", loggerFirst.Configuration.InnerXml); + + // 2nd logger + var loggerSecond = loggerRunSettings.LoggerSettingsList[1]; + Assert.AreEqual("TestLogger", loggerSecond.FriendlyName); + Assert.AreEqual(new Uri("testlogger://logger").ToString(), loggerSecond.Uri.ToString()); + Assert.AreEqual("Sample.Sample.Sample.SampleLogger, Sample.Sample.Logger, Version=0.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx", loggerSecond.AssemblyQualifiedName); + Assert.AreEqual(@"C:\Sample\Sample.TestLogger.dll", loggerSecond.CodeBase); + Assert.IsFalse(loggerSecond.IsEnabled); + Assert.IsNull(loggerSecond.Configuration); + + // 3rd logger + var loggerThird = loggerRunSettings.LoggerSettingsList[2]; + Assert.IsTrue(string.IsNullOrWhiteSpace(loggerThird.FriendlyName)); + Assert.AreEqual(new Uri("testlogger://loggerTemp").ToString(), loggerThird.Uri.ToString()); + Assert.IsTrue(string.IsNullOrWhiteSpace(loggerThird.AssemblyQualifiedName)); + Assert.IsTrue(string.IsNullOrWhiteSpace(loggerThird.CodeBase)); + Assert.IsTrue(loggerThird.IsEnabled); + Assert.AreEqual("Value3Value4", loggerThird.Configuration.InnerXml); + } - [TestMethod] - public void GetLoggerRunSettingsShouldReturnLoggersWhenLoggerHasSelfEndingTag() - { - string runSettingsWithSelfEndingLoggers = - @" + [TestMethod] + public void GetLoggerRunSettingsShouldReturnLoggersWhenLoggerHasSelfEndingTag() + { + string runSettingsWithSelfEndingLoggers = + @" @@ -1093,21 +1095,21 @@ public void GetLoggerRunSettingsShouldReturnLoggersWhenLoggerHasSelfEndingTag() "; - var loggerRunSettings = - XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithSelfEndingLoggers); + var loggerRunSettings = + XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithSelfEndingLoggers); - Assert.AreEqual(3, loggerRunSettings.LoggerSettingsList.Count); - Assert.AreEqual("TestLoggerWithParameterExtension", loggerRunSettings.LoggerSettingsList[0].FriendlyName); - Assert.AreEqual("TestLogger", loggerRunSettings.LoggerSettingsList[1].FriendlyName); - Assert.AreEqual("TestLogger", loggerRunSettings.LoggerSettingsList[1].FriendlyName); - Assert.IsTrue(string.IsNullOrWhiteSpace(loggerRunSettings.LoggerSettingsList[2].FriendlyName)); - } + Assert.AreEqual(3, loggerRunSettings.LoggerSettingsList.Count); + Assert.AreEqual("TestLoggerWithParameterExtension", loggerRunSettings.LoggerSettingsList[0].FriendlyName); + Assert.AreEqual("TestLogger", loggerRunSettings.LoggerSettingsList[1].FriendlyName); + Assert.AreEqual("TestLogger", loggerRunSettings.LoggerSettingsList[1].FriendlyName); + Assert.IsTrue(string.IsNullOrWhiteSpace(loggerRunSettings.LoggerSettingsList[2].FriendlyName)); + } - [TestMethod] - public void GetLoggerRunSettingsShouldReturnLastConfigurationElementIfMultiplePresent() - { - string runSettingsWithMultipleConfigurationElements = - @" + [TestMethod] + public void GetLoggerRunSettingsShouldReturnLastConfigurationElementIfMultiplePresent() + { + string runSettingsWithMultipleConfigurationElements = + @" @@ -1127,56 +1129,56 @@ public void GetLoggerRunSettingsShouldReturnLastConfigurationElementIfMultiplePr "; - var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithMultipleConfigurationElements); + var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runSettingsWithMultipleConfigurationElements); - var expectedConfigurationElement = new XmlDocument().CreateElement("ConfiGUration"); - expectedConfigurationElement.InnerXml = "Value3Value4"; - Assert.AreEqual(expectedConfigurationElement.Name, - loggerRunSettings.LoggerSettingsList.First().Configuration.Name); - Assert.AreEqual(expectedConfigurationElement.InnerXml, - loggerRunSettings.LoggerSettingsList.First().Configuration.InnerXml); - } + var expectedConfigurationElement = new XmlDocument().CreateElement("ConfiGUration"); + expectedConfigurationElement.InnerXml = "Value3Value4"; + Assert.AreEqual(expectedConfigurationElement.Name, + loggerRunSettings.LoggerSettingsList.First().Configuration.Name); + Assert.AreEqual(expectedConfigurationElement.InnerXml, + loggerRunSettings.LoggerSettingsList.First().Configuration.InnerXml); + } - #endregion + #endregion - #region GetDataCollectionRunSettings tests + #region GetDataCollectionRunSettings tests - [TestMethod] - public void GetDataCollectionRunSettingsShouldReturnNullIfSettingsIsNull() - { - Assert.IsNull(XmlRunSettingsUtilities.GetDataCollectionRunSettings(null)); - } + [TestMethod] + public void GetDataCollectionRunSettingsShouldReturnNullIfSettingsIsNull() + { + Assert.IsNull(XmlRunSettingsUtilities.GetDataCollectionRunSettings(null)); + } - [TestMethod] - public void GetDataCollectionRunSettingsShouldReturnNullOnNoDataCollectorSettings() - { - Assert.IsNull(XmlRunSettingsUtilities.GetDataCollectionRunSettings(EmptyRunSettings)); - } + [TestMethod] + public void GetDataCollectionRunSettingsShouldReturnNullOnNoDataCollectorSettings() + { + Assert.IsNull(XmlRunSettingsUtilities.GetDataCollectionRunSettings(_emptyRunSettings)); + } - [TestMethod] - public void GetDataCollectionRunSettingsShouldReturnDataCollectorRunSettings() - { - Assert.IsNotNull(XmlRunSettingsUtilities.GetDataCollectionRunSettings(this.runSettingsXmlWithDataCollectors)); - } + [TestMethod] + public void GetDataCollectionRunSettingsShouldReturnDataCollectorRunSettings() + { + Assert.IsNotNull(XmlRunSettingsUtilities.GetDataCollectionRunSettings(_runSettingsXmlWithDataCollectors)); + } - [TestMethod] - public void GetDataCollectionRunSettingsShouldReturnDataCollectorRunSettingsEvenIfDisabled() - { - Assert.IsNotNull(XmlRunSettingsUtilities.GetDataCollectionRunSettings(this.runSettingsXmlWithDataCollectorsDisabled)); - } + [TestMethod] + public void GetDataCollectionRunSettingsShouldReturnDataCollectorRunSettingsEvenIfDisabled() + { + Assert.IsNotNull(XmlRunSettingsUtilities.GetDataCollectionRunSettings(_runSettingsXmlWithDataCollectorsDisabled)); + } - [TestMethod] - public void GetDataCollectionRunSettingsShouldThrowOnMalformedDataCollectorSettings() - { - Assert.ThrowsException(() => XmlRunSettingsUtilities.GetDataCollectionRunSettings(this.runSettingsXmlWithIncorrectDataCollectorSettings)); - } + [TestMethod] + public void GetDataCollectionRunSettingsShouldThrowOnMalformedDataCollectorSettings() + { + Assert.ThrowsException(() => XmlRunSettingsUtilities.GetDataCollectionRunSettings(_runSettingsXmlWithIncorrectDataCollectorSettings)); + } - #endregion + #endregion - [TestMethod] - public void GetDataCollectorsFriendlyNameShouldReturnListOfFriendlyName() - { - var settingsXml = @" + [TestMethod] + public void GetDataCollectorsFriendlyNameShouldReturnListOfFriendlyName() + { + var settingsXml = @" @@ -1187,20 +1189,19 @@ public void GetDataCollectorsFriendlyNameShouldReturnListOfFriendlyName() "; - var friendlyNameList = XmlRunSettingsUtilities.GetDataCollectorsFriendlyName(settingsXml).ToList(); + var friendlyNameList = XmlRunSettingsUtilities.GetDataCollectorsFriendlyName(settingsXml).ToList(); - Assert.AreEqual(2, friendlyNameList.Count, "There should be two friendly name"); - CollectionAssert.AreEqual(friendlyNameList, new List { "DummyDataCollector1", "DummyDataCollector2" }); - } + Assert.AreEqual(2, friendlyNameList.Count, "There should be two friendly name"); + CollectionAssert.AreEqual(friendlyNameList, new List { "DummyDataCollector1", "DummyDataCollector2" }); + } - private string ConvertOutOfProcDataCollectionSettingsToInProcDataCollectionSettings(string settings) - { - return - settings.Replace("DataCollectionRunSettings", "InProcDataCollectionRunSettings") - .Replace("", "") - .Replace("", "") - .Replace("", ""); - } + private string ConvertOutOfProcDataCollectionSettingsToInProcDataCollectionSettings(string settings) + { + return + settings.Replace("DataCollectionRunSettings", "InProcDataCollectionRunSettings") + .Replace("", "") + .Replace("", "") + .Replace("", ""); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.PerformanceTests/PerformanceTests.cs b/test/Microsoft.TestPlatform.PerformanceTests/PerformanceTests.cs index f82848e218..97f3ee9b31 100644 --- a/test/Microsoft.TestPlatform.PerformanceTests/PerformanceTests.cs +++ b/test/Microsoft.TestPlatform.PerformanceTests/PerformanceTests.cs @@ -1,101 +1,101 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.PerformanceTests +namespace Microsoft.TestPlatform.PerformanceTests; + +using TestUtilities.PerfInstrumentation; + +using VisualStudio.TestTools.UnitTesting; + +/// +/// The performance tests. +/// +[TestClass] +public class PerformanceTests : PerformanceTestBase { - using Microsoft.TestPlatform.TestUtilities.PerfInstrumentation; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - /// - /// The performance tests. - /// - [TestClass] - public class PerformanceTests : PerformanceTestBase + [TestMethod] + public void ExecutionPerformanceTest() + { + RunExecutionPerformanceTests(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty); + + ValidateSummaryStatus(1, 1, 1); + ValidatePassedTests("SampleUnitTestProject.UnitTest1.PassingTest"); + ValidateFailedTests("SampleUnitTestProject.UnitTest1.FailingTest"); + ValidateSkippedTests("SampleUnitTestProject.UnitTest1.SkippingTest"); + + AnalyzePerfData(); + var actualExecutionTime = GetExecutionTime(); + + // Sample Assert statement to verify the performance. 500 will be replaced by the actual threshold value. + Assert.IsTrue(actualExecutionTime < 500); + } + + [TestMethod] + public void DiscoveryPerformanceTest() + { + RunDiscoveryPerformanceTests(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty); + + ValidateDiscoveredTests( + "SampleUnitTestProject.UnitTest1.PassingTest", + "SampleUnitTestProject.UnitTest1.FailingTest", + "SampleUnitTestProject.UnitTest1.SkippingTest"); + + AnalyzePerfData(); + var actualDiscoveryTime = GetDiscoveryTime(); + + // Sample Assert statement to verify the performance. 500 will be replaced by the actual threshold value. + Assert.IsTrue(actualDiscoveryTime < 500); + } + + [TestMethod] + public void VsTestConsolePerformanceTest() { - [TestMethod] - public void ExecutionPerformanceTest() - { - this.RunExecutionPerformanceTests(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty); - - this.ValidateSummaryStatus(1, 1, 1); - this.ValidatePassedTests("SampleUnitTestProject.UnitTest1.PassingTest"); - this.ValidateFailedTests("SampleUnitTestProject.UnitTest1.FailingTest"); - this.ValidateSkippedTests("SampleUnitTestProject.UnitTest1.SkippingTest"); - - this.AnalyzePerfData(); - var actualExecutionTime = this.GetExecutionTime(); - - // Sample Assert statement to verify the performance. 500 will be replaced by the actual threshold value. - Assert.IsTrue(actualExecutionTime < 500); - } - - [TestMethod] - public void DiscoveryPerformanceTest() - { - this.RunDiscoveryPerformanceTests(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty); - - this.ValidateDiscoveredTests( - "SampleUnitTestProject.UnitTest1.PassingTest", - "SampleUnitTestProject.UnitTest1.FailingTest", - "SampleUnitTestProject.UnitTest1.SkippingTest"); - - this.AnalyzePerfData(); - var actualDiscoveryTime = this.GetDiscoveryTime(); - - // Sample Assert statement to verify the performance. 500 will be replaced by the actual threshold value. - Assert.IsTrue(actualDiscoveryTime < 500); - } - - [TestMethod] - public void VsTestConsolePerformanceTest() - { - this.RunExecutionPerformanceTests(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty); - - this.ValidateSummaryStatus(1, 1, 1); - this.ValidatePassedTests("SampleUnitTestProject.UnitTest1.PassingTest"); - this.ValidateFailedTests("SampleUnitTestProject.UnitTest1.FailingTest"); - this.ValidateSkippedTests("SampleUnitTestProject.UnitTest1.SkippingTest"); - - this.AnalyzePerfData(); - var actualVsTestTime = this.GetVsTestTime(); - - // Sample Assert statement to verify the performance. 1500 will be replaced by the actual threshold value. - Assert.IsTrue(actualVsTestTime < 1500); - } - - [TestMethod] - public void TestHostPerformanceTest() - { - this.RunExecutionPerformanceTests(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty); - - this.ValidateSummaryStatus(1, 1, 1); - this.ValidatePassedTests("SampleUnitTestProject.UnitTest1.PassingTest"); - this.ValidateFailedTests("SampleUnitTestProject.UnitTest1.FailingTest"); - this.ValidateSkippedTests("SampleUnitTestProject.UnitTest1.SkippingTest"); - - this.AnalyzePerfData(); - var actualTestHostTime = this.GetTestHostTime(); - - // Sample Assert statement to verify the performance. 1000 will be replaced by the actual threshold value. - Assert.IsTrue(actualTestHostTime < 1000); - } - - [TestMethod] - public void MsTestV2AdapterPerformanceTest() - { - this.RunExecutionPerformanceTests(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty); - - this.ValidateSummaryStatus(1, 1, 1); - this.ValidatePassedTests("SampleUnitTestProject.UnitTest1.PassingTest"); - this.ValidateFailedTests("SampleUnitTestProject.UnitTest1.FailingTest"); - this.ValidateSkippedTests("SampleUnitTestProject.UnitTest1.SkippingTest"); - - this.AnalyzePerfData(); - - var actualAdapterTimeTaken = this.GetAdapterExecutionTime("executor://mstestadapter/v2"); - - // Sample Assert statement to verify the performance. 300 will be replaced by the actual threshold value. - Assert.IsTrue(actualAdapterTimeTaken < 300); - } + RunExecutionPerformanceTests(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty); + + ValidateSummaryStatus(1, 1, 1); + ValidatePassedTests("SampleUnitTestProject.UnitTest1.PassingTest"); + ValidateFailedTests("SampleUnitTestProject.UnitTest1.FailingTest"); + ValidateSkippedTests("SampleUnitTestProject.UnitTest1.SkippingTest"); + + AnalyzePerfData(); + var actualVsTestTime = GetVsTestTime(); + + // Sample Assert statement to verify the performance. 1500 will be replaced by the actual threshold value. + Assert.IsTrue(actualVsTestTime < 1500); + } + + [TestMethod] + public void TestHostPerformanceTest() + { + RunExecutionPerformanceTests(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty); + + ValidateSummaryStatus(1, 1, 1); + ValidatePassedTests("SampleUnitTestProject.UnitTest1.PassingTest"); + ValidateFailedTests("SampleUnitTestProject.UnitTest1.FailingTest"); + ValidateSkippedTests("SampleUnitTestProject.UnitTest1.SkippingTest"); + + AnalyzePerfData(); + var actualTestHostTime = GetTestHostTime(); + + // Sample Assert statement to verify the performance. 1000 will be replaced by the actual threshold value. + Assert.IsTrue(actualTestHostTime < 1000); + } + + [TestMethod] + public void MsTestV2AdapterPerformanceTest() + { + RunExecutionPerformanceTests(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty); + + ValidateSummaryStatus(1, 1, 1); + ValidatePassedTests("SampleUnitTestProject.UnitTest1.PassingTest"); + ValidateFailedTests("SampleUnitTestProject.UnitTest1.FailingTest"); + ValidateSkippedTests("SampleUnitTestProject.UnitTest1.SkippingTest"); + + AnalyzePerfData(); + + var actualAdapterTimeTaken = GetAdapterExecutionTime("executor://mstestadapter/v2"); + + // Sample Assert statement to verify the performance. 300 will be replaced by the actual threshold value. + Assert.IsTrue(actualAdapterTimeTaken < 300); } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.PerformanceTests/Program.cs b/test/Microsoft.TestPlatform.PerformanceTests/Program.cs index f51a7b7fe2..2b49b9440a 100644 --- a/test/Microsoft.TestPlatform.PerformanceTests/Program.cs +++ b/test/Microsoft.TestPlatform.PerformanceTests/Program.cs @@ -1,11 +1,13 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace testhost.UnitTests +#pragma warning disable IDE1006 // Naming Styles +namespace testhost.UnitTests; +#pragma warning restore IDE1006 // Naming Styles + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.PerformanceTests/ProtocolV1Tests.cs b/test/Microsoft.TestPlatform.PerformanceTests/ProtocolV1Tests.cs index 7f78e23b16..86d34b86cf 100644 --- a/test/Microsoft.TestPlatform.PerformanceTests/ProtocolV1Tests.cs +++ b/test/Microsoft.TestPlatform.PerformanceTests/ProtocolV1Tests.cs @@ -1,124 +1,124 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.PerformanceTests -{ - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System; - using System.Diagnostics; - using System.IO; +namespace Microsoft.TestPlatform.PerformanceTests; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using System; +using System.Diagnostics; +using System.IO; - using TestResult = Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult; +using TestResult = Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult; - [TestClass] - public class ProtocolV1Tests +[TestClass] +public class ProtocolV1Tests +{ + private static readonly TestCase TestCase = new( + "sampleTestClass.sampleTestCase", + new Uri("executor://sampleTestExecutor"), + "sampleTest.dll") { - private static TestCase testCase = new TestCase( - "sampleTestClass.sampleTestCase", - new Uri("executor://sampleTestExecutor"), - "sampleTest.dll") - { - CodeFilePath = "/user/src/testFile.cs", - DisplayName = "sampleTestCase", - Id = new Guid("be78d6fc-61b0-4882-9d07-40d796fd96ce"), - LineNumber = 999, - Traits = { new Trait("Priority", "0"), new Trait("Category", "unit") } - }; + CodeFilePath = "/user/src/testFile.cs", + DisplayName = "sampleTestCase", + Id = new Guid("be78d6fc-61b0-4882-9d07-40d796fd96ce"), + LineNumber = 999, + Traits = { new Trait("Priority", "0"), new Trait("Category", "unit") } + }; - private static DateTimeOffset startTime = new DateTimeOffset(new DateTime(2007, 3, 10, 0, 0, 0, DateTimeKind.Utc)); + private static DateTimeOffset s_startTime = new(new DateTime(2007, 3, 10, 0, 0, 0, DateTimeKind.Utc)); - private static TestResult testResult = new TestResult(testCase) - { - // Attachments = ? - // Messages = ? - Outcome = TestOutcome.Passed, - ErrorMessage = "sampleError", - ErrorStackTrace = "sampleStackTrace", - DisplayName = "sampleTestResult", - ComputerName = "sampleComputerName", - Duration = TimeSpan.MaxValue, - StartTime = startTime, - EndTime = DateTimeOffset.MaxValue - }; - - [TestMethod] - public void TestCaseSerialize() + private static readonly TestResult TestResult = new(TestCase) + { + // Attachments = ? + // Messages = ? + Outcome = TestOutcome.Passed, + ErrorMessage = "sampleError", + ErrorStackTrace = "sampleStackTrace", + DisplayName = "sampleTestResult", + ComputerName = "sampleComputerName", + Duration = TimeSpan.MaxValue, + StartTime = s_startTime, + EndTime = DateTimeOffset.MaxValue + }; + + [TestMethod] + public void TestCaseSerialize() + { + Serialize(TestCase); + Stopwatch sw = Stopwatch.StartNew(); + + for (int i = 0; i < 10000; i++) { - Serialize(testCase); - Stopwatch sw = Stopwatch.StartNew(); + Serialize(TestCase); + } + sw.Stop(); - for (int i = 0; i < 10000; i++) - { - Serialize(testCase); - } - sw.Stop(); + VerifyPerformanceResult("TestCaseSerialize1", 2000, sw.ElapsedMilliseconds); + } - VerifyPerformanceResult("TestCaseSerialize1", 2000, sw.ElapsedMilliseconds); - } - - [TestMethod] - public void TestCaseDeserialize() + [TestMethod] + public void TestCaseDeserialize() + { + var json = Serialize(TestCase); + Deserialize(json); + + Stopwatch sw = Stopwatch.StartNew(); + for (int i = 0; i < 10000; i++) { - var json = Serialize(testCase); Deserialize(json); + } + sw.Stop(); - Stopwatch sw = Stopwatch.StartNew(); - for (int i = 0; i < 10000; i++) - { - Deserialize(json); - } - sw.Stop(); + VerifyPerformanceResult("TestCaseDeserialize1", 2000, sw.ElapsedMilliseconds); + } - VerifyPerformanceResult("TestCaseDeserialize1", 2000, sw.ElapsedMilliseconds); - } + [TestMethod] + public void TestResultSerialize() + { + Serialize(TestResult); + Stopwatch sw = Stopwatch.StartNew(); - [TestMethod] - public void TestResultSerialize() + for (int i = 0; i < 10000; i++) { - Serialize(testResult); - Stopwatch sw = Stopwatch.StartNew(); + Serialize(TestResult); + } + sw.Stop(); - for (int i = 0; i < 10000; i++) - { - Serialize(testResult); - } - sw.Stop(); + VerifyPerformanceResult("TestResultSerialize1", 2000, sw.ElapsedMilliseconds); + } - VerifyPerformanceResult("TestResultSerialize1", 2000, sw.ElapsedMilliseconds); - } + [TestMethod] + public void TestResultDeserialize() + { + var json = Serialize(TestResult); + Deserialize(json); - [TestMethod] - public void TestResultDeserialize() + Stopwatch sw = Stopwatch.StartNew(); + for (int i = 0; i < 10000; i++) { - var json = Serialize(testResult); Deserialize(json); - - Stopwatch sw = Stopwatch.StartNew(); - for (int i = 0; i < 10000; i++) - { - Deserialize(json); - } - sw.Stop(); - - VerifyPerformanceResult("TestResultDeserialize1", 3500, sw.ElapsedMilliseconds); } + sw.Stop(); - private static string Serialize(T data, int version = 1) - { - return JsonDataSerializer.Instance.Serialize(data, version); - } + VerifyPerformanceResult("TestResultDeserialize1", 3500, sw.ElapsedMilliseconds); + } - private static T Deserialize(string json, int version = 1) - { - return JsonDataSerializer.Instance.Deserialize(json, version); - } + private static string Serialize(T data, int version = 1) + { + return JsonDataSerializer.Instance.Serialize(data, version); + } - private static void VerifyPerformanceResult(string scenario, long expectedElapsedTime, long elapsedTime) - { - Assert.IsTrue(elapsedTime < expectedElapsedTime, $"Scenario '{scenario}' doesn't match with expected elapsed time."); - File.AppendAllText(@"E:\ProtocolPerf.txt", $" {scenario} : " + elapsedTime); - } + private static T Deserialize(string json, int version = 1) + { + return JsonDataSerializer.Instance.Deserialize(json, version); + } + + private static void VerifyPerformanceResult(string scenario, long expectedElapsedTime, long elapsedTime) + { + Assert.IsTrue(elapsedTime < expectedElapsedTime, $"Scenario '{scenario}' doesn't match with expected elapsed time."); + File.AppendAllText(@"E:\ProtocolPerf.txt", $" {scenario} : " + elapsedTime); } } diff --git a/test/Microsoft.TestPlatform.PerformanceTests/ProtocolV2Tests.cs b/test/Microsoft.TestPlatform.PerformanceTests/ProtocolV2Tests.cs index 4e2ca53d51..7957d4d6ac 100644 --- a/test/Microsoft.TestPlatform.PerformanceTests/ProtocolV2Tests.cs +++ b/test/Microsoft.TestPlatform.PerformanceTests/ProtocolV2Tests.cs @@ -1,122 +1,121 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.PerformanceTests -{ - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System; - using System.Diagnostics; - using System.IO; +namespace Microsoft.TestPlatform.PerformanceTests; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using VisualStudio.TestTools.UnitTesting; +using System; +using System.Diagnostics; +using System.IO; - using TestResult = Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult; +using TestResult = VisualStudio.TestPlatform.ObjectModel.TestResult; - [TestClass] - public class ProtocolV2Tests +[TestClass] +public class ProtocolV2Tests +{ + private static readonly TestCase TestCase = new( + "sampleTestClass.sampleTestCase", + new Uri("executor://sampleTestExecutor"), + "sampleTest.dll") { - private static TestCase testCase = new TestCase( - "sampleTestClass.sampleTestCase", - new Uri("executor://sampleTestExecutor"), - "sampleTest.dll") - { - CodeFilePath = "/user/src/testFile.cs", - DisplayName = "sampleTestCase", - Id = new Guid("be78d6fc-61b0-4882-9d07-40d796fd96ce"), - LineNumber = 999, - Traits = { new Trait("Priority", "0"), new Trait("Category", "unit") } - }; + CodeFilePath = "/user/src/testFile.cs", + DisplayName = "sampleTestCase", + Id = new Guid("be78d6fc-61b0-4882-9d07-40d796fd96ce"), + LineNumber = 999, + Traits = { new Trait("Priority", "0"), new Trait("Category", "unit") } + }; - private static DateTimeOffset startTime = new DateTimeOffset(new DateTime(2007, 3, 10, 0, 0, 0, DateTimeKind.Utc)); + private static readonly DateTimeOffset StartTime = new(new DateTime(2007, 3, 10, 0, 0, 0, DateTimeKind.Utc)); - private static TestResult testResult = new TestResult(testCase) - { - // Attachments = ? - // Messages = ? - Outcome = TestOutcome.Passed, - ErrorMessage = "sampleError", - ErrorStackTrace = "sampleStackTrace", - DisplayName = "sampleTestResult", - ComputerName = "sampleComputerName", - Duration = TimeSpan.MaxValue, - StartTime = startTime, - EndTime = DateTimeOffset.MaxValue - }; - - [TestMethod] - public void TestCaseSerialize2() + private static readonly TestResult TestResult = new(TestCase) + { + // Attachments = ? + // Messages = ? + Outcome = TestOutcome.Passed, + ErrorMessage = "sampleError", + ErrorStackTrace = "sampleStackTrace", + DisplayName = "sampleTestResult", + ComputerName = "sampleComputerName", + Duration = TimeSpan.MaxValue, + StartTime = StartTime, + EndTime = DateTimeOffset.MaxValue + }; + + [TestMethod] + public void TestCaseSerialize2() + { + Serialize(TestCase, 2); + Stopwatch sw = Stopwatch.StartNew(); + for (int i = 0; i < 10000; i++) { - Serialize(testCase, 2); - Stopwatch sw = Stopwatch.StartNew(); - for (int i = 0; i < 10000; i++) - { - Serialize(testCase, 2); - } - sw.Stop(); - - VerifyPerformanceResult("TestCaseSerialize2", 2000, sw.ElapsedMilliseconds); + Serialize(TestCase, 2); } + sw.Stop(); - [TestMethod] - public void TestCaseDeserialize2() - { - var json = Serialize(testCase, 2); - Deserialize(json, 2); - - Stopwatch sw = Stopwatch.StartNew(); - for (int i = 0; i < 10000; i++) - { - Deserialize(json, 2); - } - sw.Stop(); + VerifyPerformanceResult("TestCaseSerialize2", 2000, sw.ElapsedMilliseconds); + } - VerifyPerformanceResult("TestCaseDeserialize2", 2000, sw.ElapsedMilliseconds); - } + [TestMethod] + public void TestCaseDeserialize2() + { + var json = Serialize(TestCase, 2); + Deserialize(json, 2); - [TestMethod] - public void TestResultSerialize2() + Stopwatch sw = Stopwatch.StartNew(); + for (int i = 0; i < 10000; i++) { - Serialize(testResult, 2); - Stopwatch sw = Stopwatch.StartNew(); - for (int i = 0; i < 10000; i++) - { - Serialize(testResult, 2); - } - sw.Stop(); - - VerifyPerformanceResult("TestResultSerialize2", 2000, sw.ElapsedMilliseconds); + Deserialize(json, 2); } + sw.Stop(); - [TestMethod] - public void TestResultDeserialize2() + VerifyPerformanceResult("TestCaseDeserialize2", 2000, sw.ElapsedMilliseconds); + } + + [TestMethod] + public void TestResultSerialize2() + { + Serialize(TestResult, 2); + Stopwatch sw = Stopwatch.StartNew(); + for (int i = 0; i < 10000; i++) { - var json = Serialize(testResult, 2); - Deserialize(json, 2); + Serialize(TestResult, 2); + } + sw.Stop(); - Stopwatch sw = Stopwatch.StartNew(); - for (int i = 0; i < 10000; i++) - { - Deserialize(json, 2); - } - sw.Stop(); + VerifyPerformanceResult("TestResultSerialize2", 2000, sw.ElapsedMilliseconds); + } - VerifyPerformanceResult("TestResultDeserialize2", 2000, sw.ElapsedMilliseconds); - } + [TestMethod] + public void TestResultDeserialize2() + { + var json = Serialize(TestResult, 2); + Deserialize(json, 2); - private static string Serialize(T data, int version = 1) + Stopwatch sw = Stopwatch.StartNew(); + for (int i = 0; i < 10000; i++) { - return JsonDataSerializer.Instance.Serialize(data, version); + Deserialize(json, 2); } + sw.Stop(); - private static T Deserialize(string json, int version = 1) - { - return JsonDataSerializer.Instance.Deserialize(json, version); - } + VerifyPerformanceResult("TestResultDeserialize2", 2000, sw.ElapsedMilliseconds); + } - private static void VerifyPerformanceResult(string scenario, long expectedElapsedTime, long elapsedTime) - { - Assert.IsTrue(elapsedTime < expectedElapsedTime, $"Scenario '{scenario}' doesn't match with expected elapsed time."); - File.AppendAllText(@"E:\ProtocolPerf.txt", $" {scenario} : " + elapsedTime); - } + private static string Serialize(T data, int version = 1) + { + return JsonDataSerializer.Instance.Serialize(data, version); + } + + private static T Deserialize(string json, int version = 1) + { + return JsonDataSerializer.Instance.Deserialize(json, version); + } + + private static void VerifyPerformanceResult(string scenario, long expectedElapsedTime, long elapsedTime) + { + Assert.IsTrue(elapsedTime < expectedElapsedTime, $"Scenario '{scenario}' doesn't match with expected elapsed time."); + File.AppendAllText(@"E:\ProtocolPerf.txt", $" {scenario} : " + elapsedTime); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.PerformanceTests/SocketTests.cs b/test/Microsoft.TestPlatform.PerformanceTests/SocketTests.cs index 5281da2692..7f9d95ff9a 100644 --- a/test/Microsoft.TestPlatform.PerformanceTests/SocketTests.cs +++ b/test/Microsoft.TestPlatform.PerformanceTests/SocketTests.cs @@ -1,137 +1,138 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.PerformanceTests +namespace Microsoft.TestPlatform.PerformanceTests; + +using System; +using System.Diagnostics; +using System.Net; +using System.Threading; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class SocketTests { - using System; - using System.Diagnostics; - using System.Net; - using System.Threading; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class SocketTests + [TestMethod] + public void SocketThroughput2() { - [TestMethod] - public void SocketThroughput2() + // Measure the throughput with socket communication v2 (SocketServer, SocketClient) + // implementation. + var server = new SocketServer(); + var client = new SocketClient(); + ICommunicationChannel serverChannel = null; + ICommunicationChannel clientChannel = null; + ManualResetEventSlim dataTransferred = new(false); + ManualResetEventSlim clientConnected = new(false); + ManualResetEventSlim serverConnected = new(false); + int dataReceived = 0; + var watch = new Stopwatch(); + var thread = new Thread(() => SendData(clientChannel, watch)); + + // Setup server + server.Connected += (sender, args) => { - // Measure the throughput with socket communication v2 (SocketServer, SocketClient) - // implementation. - var server = new SocketServer(); - var client = new SocketClient(); - ICommunicationChannel serverChannel = null; - ICommunicationChannel clientChannel = null; - ManualResetEventSlim dataTransferred = new ManualResetEventSlim(false); - ManualResetEventSlim clientConnected = new ManualResetEventSlim(false); - ManualResetEventSlim serverConnected = new ManualResetEventSlim(false); - int dataReceived = 0; - var watch = new Stopwatch(); - var thread = new Thread(() => SendData(clientChannel, watch)); - - // Setup server - server.Connected += (sender, args) => + serverChannel = args.Channel; + serverChannel.MessageReceived += (channel, messageReceived) => { - serverChannel = args.Channel; - serverChannel.MessageReceived += (channel, messageReceived) => - { - // Keep count of bytes - dataReceived += messageReceived.Data.Length; - - if (dataReceived >= 65536 * 20000) - { - dataTransferred.Set(); - watch.Stop(); - } - }; + // Keep count of bytes + dataReceived += messageReceived.Data.Length; - clientConnected.Set(); + if (dataReceived >= 65536 * 20000) + { + dataTransferred.Set(); + watch.Stop(); + } }; - client.Connected += (sender, args) => - { - clientChannel = args.Channel; - - thread.Start(); + clientConnected.Set(); + }; - serverConnected.Set(); - }; + client.Connected += (sender, args) => + { + clientChannel = args.Channel; - var port = server.Start(IPAddress.Loopback.ToString()+":0"); - client.Start(port); + thread.Start(); - clientConnected.Wait(); - serverConnected.Wait(); - thread.Join(); - dataTransferred.Wait(); + serverConnected.Set(); + }; - Assert.IsTrue(watch.Elapsed < TimeSpan.FromSeconds(4), "Elapsed: " + watch.Elapsed); - } + var port = server.Start(IPAddress.Loopback.ToString() + ":0"); + client.Start(port); - [TestMethod] - public void SocketThroughput1() - { - // Measure the throughput with socket communication v1 (SocketCommunicationManager) - // implementation. - var server = new SocketCommunicationManager(); - var client = new SocketCommunicationManager(); - var watch = new Stopwatch(); + clientConnected.Wait(); + serverConnected.Wait(); + thread.Join(); + dataTransferred.Wait(); - int port = server.HostServer(new IPEndPoint(IPAddress.Loopback, 0)).Port; - client.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)).Wait(); - server.AcceptClientAsync().Wait(); + Assert.IsTrue(watch.Elapsed < TimeSpan.FromSeconds(4), "Elapsed: " + watch.Elapsed); + } - server.WaitForClientConnection(1000); - client.WaitForServerConnection(1000); + [TestMethod] + public void SocketThroughput1() + { + // Measure the throughput with socket communication v1 (SocketCommunicationManager) + // implementation. + var server = new SocketCommunicationManager(); + var client = new SocketCommunicationManager(); + var watch = new Stopwatch(); - var clientThread = new Thread(() => SendData2(client, watch)); - clientThread.Start(); + int port = server.HostServer(new IPEndPoint(IPAddress.Loopback, 0)).Port; + client.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)).Wait(); + server.AcceptClientAsync().Wait(); - var dataReceived = 0; - while (dataReceived < 65536 * 20000) - { - dataReceived += server.ReceiveRawMessage().Length; - } + server.WaitForClientConnection(1000); + client.WaitForServerConnection(1000); - watch.Stop(); - clientThread.Join(); + var clientThread = new Thread(() => SendData2(client, watch)); + clientThread.Start(); - Assert.IsTrue(watch.Elapsed < TimeSpan.FromSeconds(4), "Elapsed: " + watch.Elapsed); + var dataReceived = 0; + while (dataReceived < 65536 * 20000) + { + dataReceived += server.ReceiveRawMessage().Length; } - private static void SendData(ICommunicationChannel channel, Stopwatch watch) + watch.Stop(); + clientThread.Join(); + + Assert.IsTrue(watch.Elapsed < TimeSpan.FromSeconds(4), "Elapsed: " + watch.Elapsed); + } + + private static void SendData(ICommunicationChannel channel, Stopwatch watch) + { + var dataBytes = new byte[65536]; + for (int i = 0; i < dataBytes.Length; i++) { - var dataBytes = new byte[65536]; - for (int i = 0; i < dataBytes.Length; i++) - { - dataBytes[i] = 0x65; - } + dataBytes[i] = 0x65; + } - var dataBytesStr = System.Text.Encoding.UTF8.GetString(dataBytes); + var dataBytesStr = System.Text.Encoding.UTF8.GetString(dataBytes); - watch.Start(); - for (int i = 0; i < 20000; i++) - { - channel.Send(dataBytesStr); - } + watch.Start(); + for (int i = 0; i < 20000; i++) + { + channel.Send(dataBytesStr); } + } - private static void SendData2(ICommunicationManager communicationManager, Stopwatch watch) + private static void SendData2(ICommunicationManager communicationManager, Stopwatch watch) + { + var dataBytes = new byte[65536]; + for (int i = 0; i < dataBytes.Length; i++) { - var dataBytes = new byte[65536]; - for (int i = 0; i < dataBytes.Length; i++) - { - dataBytes[i] = 0x65; - } + dataBytes[i] = 0x65; + } - var dataBytesStr = System.Text.Encoding.UTF8.GetString(dataBytes); + var dataBytesStr = System.Text.Encoding.UTF8.GetString(dataBytes); - watch.Start(); - for (int i = 0; i < 20000; i++) - { - communicationManager.SendRawMessage(dataBytesStr); - } + watch.Start(); + for (int i = 0; i < 20000; i++) + { + communicationManager.SendRawMessage(dataBytesStr); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/DiscoveryPerfTests.cs b/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/DiscoveryPerfTests.cs index ca2c0cdf9a..3052033b8e 100644 --- a/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/DiscoveryPerfTests.cs +++ b/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/DiscoveryPerfTests.cs @@ -1,107 +1,106 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.PerformanceTests.TranslationLayer +namespace Microsoft.TestPlatform.PerformanceTests.TranslationLayer; + +using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; + +[TestClass] +public class DiscoveryPerfTests : TelemetryPerfTestbase { - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System.Collections.Generic; + private readonly IVsTestConsoleWrapper _vstestConsoleWrapper; + private readonly DiscoveryEventHandler2 _discoveryEventHandler2; - [TestClass] - public class DiscoveryPerfTests : TelemetryPerfTestbase + public DiscoveryPerfTests() { - private IVsTestConsoleWrapper vstestConsoleWrapper; - private DiscoveryEventHandler2 discoveryEventHandler2; - - public DiscoveryPerfTests() - { - this.vstestConsoleWrapper = this.GetVsTestConsoleWrapper(); - this.discoveryEventHandler2 = new DiscoveryEventHandler2(); - } + _vstestConsoleWrapper = GetVsTestConsoleWrapper(); + _discoveryEventHandler2 = new DiscoveryEventHandler2(); + } - [TestMethod] - [TestCategory("TelemetryPerf")] - public void DiscoverMsTest10K() + [TestMethod] + [TestCategory("TelemetryPerf")] + public void DiscoverMsTest10K() + { + var testAssemblies = new List { - var testAssemblies = new List - { - GetPerfAssetFullPath("MSTestAdapterPerfTestProject", "MSTestAdapterPerfTestProject.dll"), - }; + GetPerfAssetFullPath("MSTestAdapterPerfTestProject", "MSTestAdapterPerfTestProject.dll"), + }; - this.vstestConsoleWrapper.DiscoverTests(testAssemblies, this.GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true }, this.discoveryEventHandler2); + _vstestConsoleWrapper.DiscoverTests(testAssemblies, GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true }, _discoveryEventHandler2); - this.PostTelemetry("DiscoverMsTest10K", this.discoveryEventHandler2.Metrics); - } + PostTelemetry("DiscoverMsTest10K", _discoveryEventHandler2.Metrics); + } - [TestMethod] - [TestCategory("TelemetryPerf")] - public void DiscoverXunit10K() + [TestMethod] + [TestCategory("TelemetryPerf")] + public void DiscoverXunit10K() + { + var testAssemblies = new List { - var testAssemblies = new List - { - GetPerfAssetFullPath("XunitAdapterPerfTestProject", "XunitAdapterPerfTestProject.dll"), - }; + GetPerfAssetFullPath("XunitAdapterPerfTestProject", "XunitAdapterPerfTestProject.dll"), + }; - this.vstestConsoleWrapper.DiscoverTests(testAssemblies, this.GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true }, this.discoveryEventHandler2); + _vstestConsoleWrapper.DiscoverTests(testAssemblies, GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true }, _discoveryEventHandler2); - this.PostTelemetry("DiscoverXunit10K", this.discoveryEventHandler2.Metrics); - } + PostTelemetry("DiscoverXunit10K", _discoveryEventHandler2.Metrics); + } - [TestMethod] - [TestCategory("TelemetryPerf")] - public void DiscoverNunit10K() + [TestMethod] + [TestCategory("TelemetryPerf")] + public void DiscoverNunit10K() + { + var testAssemblies = new List { - var testAssemblies = new List - { - GetPerfAssetFullPath("NunitAdapterPerfTestProject", "NunitAdapterPerfTestProject.dll"), - }; + GetPerfAssetFullPath("NunitAdapterPerfTestProject", "NunitAdapterPerfTestProject.dll"), + }; - this.vstestConsoleWrapper.DiscoverTests(testAssemblies, this.GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true }, this.discoveryEventHandler2); + _vstestConsoleWrapper.DiscoverTests(testAssemblies, GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true }, _discoveryEventHandler2); - this.PostTelemetry("DiscoverNunit10K", this.discoveryEventHandler2.Metrics); - } + PostTelemetry("DiscoverNunit10K", _discoveryEventHandler2.Metrics); + } - [TestMethod] - [TestCategory("TelemetryPerf")] - public void DiscoverMsTest10KWithDefaultAdaptersSkipped() + [TestMethod] + [TestCategory("TelemetryPerf")] + public void DiscoverMsTest10KWithDefaultAdaptersSkipped() + { + var testAssemblies = new List { - var testAssemblies = new List - { - GetPerfAssetFullPath("MSTestAdapterPerfTestProject", "MSTestAdapterPerfTestProject.dll"), - }; + GetPerfAssetFullPath("MSTestAdapterPerfTestProject", "MSTestAdapterPerfTestProject.dll"), + }; - this.vstestConsoleWrapper.DiscoverTests(testAssemblies, this.GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true, SkipDefaultAdapters = true }, this.discoveryEventHandler2); + _vstestConsoleWrapper.DiscoverTests(testAssemblies, GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true, SkipDefaultAdapters = true }, _discoveryEventHandler2); - this.PostTelemetry("DiscoverMsTest10KWithDefaultAdaptersSkipped", this.discoveryEventHandler2.Metrics); - } + PostTelemetry("DiscoverMsTest10KWithDefaultAdaptersSkipped", _discoveryEventHandler2.Metrics); + } - [TestMethod] - [TestCategory("TelemetryPerf")] - public void DiscoverXunit10KWithDefaultAdaptersSkipped() + [TestMethod] + [TestCategory("TelemetryPerf")] + public void DiscoverXunit10KWithDefaultAdaptersSkipped() + { + var testAssemblies = new List { - var testAssemblies = new List - { - GetPerfAssetFullPath("XunitAdapterPerfTestProject", "XunitAdapterPerfTestProject.dll"), - }; + GetPerfAssetFullPath("XunitAdapterPerfTestProject", "XunitAdapterPerfTestProject.dll"), + }; - this.vstestConsoleWrapper.DiscoverTests(testAssemblies, this.GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true, SkipDefaultAdapters = true }, this.discoveryEventHandler2); + _vstestConsoleWrapper.DiscoverTests(testAssemblies, GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true, SkipDefaultAdapters = true }, _discoveryEventHandler2); - this.PostTelemetry("DiscoverXunit10KWithDefaultAdaptersSkipped", this.discoveryEventHandler2.Metrics); - } + PostTelemetry("DiscoverXunit10KWithDefaultAdaptersSkipped", _discoveryEventHandler2.Metrics); + } - [TestMethod] - [TestCategory("TelemetryPerf")] - public void DiscoverNunit10KWithDefaultAdaptersSkipped() + [TestMethod] + [TestCategory("TelemetryPerf")] + public void DiscoverNunit10KWithDefaultAdaptersSkipped() + { + var testAssemblies = new List { - var testAssemblies = new List - { - GetPerfAssetFullPath("NunitAdapterPerfTestProject", "NunitAdapterPerfTestProject.dll"), - }; + GetPerfAssetFullPath("NunitAdapterPerfTestProject", "NunitAdapterPerfTestProject.dll"), + }; - this.vstestConsoleWrapper.DiscoverTests(testAssemblies, this.GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true, SkipDefaultAdapters = true }, this.discoveryEventHandler2); + _vstestConsoleWrapper.DiscoverTests(testAssemblies, GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true, SkipDefaultAdapters = true }, _discoveryEventHandler2); - this.PostTelemetry("DiscoverNunit10KWithDefaultAdaptersSkipped", this.discoveryEventHandler2.Metrics); - } + PostTelemetry("DiscoverNunit10KWithDefaultAdaptersSkipped", _discoveryEventHandler2.Metrics); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/EventHandler/DiscoveryEventHandler.cs b/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/EventHandler/DiscoveryEventHandler.cs index ffccb55529..053aed924d 100644 --- a/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/EventHandler/DiscoveryEventHandler.cs +++ b/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/EventHandler/DiscoveryEventHandler.cs @@ -1,57 +1,57 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.PerformanceTests.TranslationLayer +namespace Microsoft.TestPlatform.PerformanceTests.TranslationLayer; + +using System.Collections.Generic; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + +/// +public class DiscoveryEventHandler2 : ITestDiscoveryEventsHandler2 { - using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + /// + /// Gets the discovered test cases. + /// + public List DiscoveredTestCases { get; } - /// - public class DiscoveryEventHandler2 : ITestDiscoveryEventsHandler2 - { - /// - /// Gets the discovered test cases. - /// - public List DiscoveredTestCases { get; } + /// + /// Gets the metrics. + /// + public IDictionary Metrics { get; private set; } - /// - /// Gets the metrics. - /// - public IDictionary Metrics { get; private set; } + public DiscoveryEventHandler2() + { + DiscoveredTestCases = new List(); + } - public DiscoveryEventHandler2() - { - this.DiscoveredTestCases = new List(); - } + public void HandleRawMessage(string rawMessage) + { + // No Op + } - public void HandleRawMessage(string rawMessage) - { - // No Op - } + public void HandleLogMessage(TestMessageLevel level, string message) + { + // No Op + } - public void HandleLogMessage(TestMessageLevel level, string message) + public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk) + { + if (lastChunk != null) { - // No Op + DiscoveredTestCases.AddRange(lastChunk); } - public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk) - { - if (lastChunk != null) - { - this.DiscoveredTestCases.AddRange(lastChunk); - } - - this.Metrics = discoveryCompleteEventArgs.Metrics; - } + Metrics = discoveryCompleteEventArgs.Metrics; + } - public void HandleDiscoveredTests(IEnumerable discoveredTestCases) + public void HandleDiscoveredTests(IEnumerable discoveredTestCases) + { + if (discoveredTestCases != null) { - if (discoveredTestCases != null) - { - this.DiscoveredTestCases.AddRange(discoveredTestCases); - } + DiscoveredTestCases.AddRange(discoveredTestCases); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/EventHandler/RunEventHandler.cs b/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/EventHandler/RunEventHandler.cs index da3ec378d9..d880556625 100644 --- a/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/EventHandler/RunEventHandler.cs +++ b/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/EventHandler/RunEventHandler.cs @@ -1,85 +1,84 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.PerformanceTests.TranslationLayer -{ - using System.Collections.Generic; - - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +namespace Microsoft.TestPlatform.PerformanceTests.TranslationLayer; - /// - public class RunEventHandler : ITestRunEventsHandler2 - { - /// - /// Gets the test results. - /// - public List TestResults { get; private set; } +using System.Collections.Generic; - /// - /// Gets the metrics. - /// - public IDictionary Metrics { get; private set; } +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - /// - /// Gets the log message. - /// - public string LogMessage { get; private set; } +/// +public class RunEventHandler : ITestRunEventsHandler2 +{ + /// + /// Gets the test results. + /// + public List TestResults { get; private set; } - /// - /// Gets the test message level. - /// - public TestMessageLevel TestMessageLevel { get; private set; } + /// + /// Gets the metrics. + /// + public IDictionary Metrics { get; private set; } - public RunEventHandler() - { - this.TestResults = new List(); - } + /// + /// Gets the log message. + /// + public string LogMessage { get; private set; } - public void HandleLogMessage(TestMessageLevel level, string message) - { - this.LogMessage = message; - this.TestMessageLevel = level; - } + /// + /// Gets the test message level. + /// + public TestMessageLevel TestMessageLevel { get; private set; } - public void HandleTestRunComplete( - TestRunCompleteEventArgs testRunCompleteArgs, - TestRunChangedEventArgs lastChunkArgs, - ICollection runContextAttachments, - ICollection executorUris) - { - if (lastChunkArgs != null && lastChunkArgs.NewTestResults != null) - { - this.TestResults.AddRange(lastChunkArgs.NewTestResults); - } + public RunEventHandler() + { + TestResults = new List(); + } - this.Metrics = testRunCompleteArgs.Metrics; - } + public void HandleLogMessage(TestMessageLevel level, string message) + { + LogMessage = message; + TestMessageLevel = level; + } - public void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChangedArgs) + public void HandleTestRunComplete( + TestRunCompleteEventArgs testRunCompleteArgs, + TestRunChangedEventArgs lastChunkArgs, + ICollection runContextAttachments, + ICollection executorUris) + { + if (lastChunkArgs != null && lastChunkArgs.NewTestResults != null) { - if (testRunChangedArgs != null && testRunChangedArgs.NewTestResults != null) - { - this.TestResults.AddRange(testRunChangedArgs.NewTestResults); - } + TestResults.AddRange(lastChunkArgs.NewTestResults); } - public void HandleRawMessage(string rawMessage) - { - // No op - } + Metrics = testRunCompleteArgs.Metrics; + } - public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) + public void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChangedArgs) + { + if (testRunChangedArgs != null && testRunChangedArgs.NewTestResults != null) { - // No op - return -1; + TestResults.AddRange(testRunChangedArgs.NewTestResults); } + } - public bool AttachDebuggerToProcess(int pid) - { - // No op - return true; - } + public void HandleRawMessage(string rawMessage) + { + // No op + } + + public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) + { + // No op + return -1; + } + + public bool AttachDebuggerToProcess(int pid) + { + // No op + return true; } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/ExecutionPerfTests.cs b/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/ExecutionPerfTests.cs index 81a45044cd..8b74ed11b6 100644 --- a/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/ExecutionPerfTests.cs +++ b/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/ExecutionPerfTests.cs @@ -1,104 +1,107 @@ -using System.Collections.Generic; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.TestPlatform.PerformanceTests.TranslationLayer; + +using System.Collections.Generic; + using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace Microsoft.TestPlatform.PerformanceTests.TranslationLayer +[TestClass] +public class ExecutionPerfTests : TelemetryPerfTestbase { - [TestClass] - public class ExecutionPerfTests : TelemetryPerfTestbase - { - private IVsTestConsoleWrapper vstestConsoleWrapper; - private RunEventHandler runEventHandler; + private IVsTestConsoleWrapper _vstestConsoleWrapper; + private RunEventHandler _runEventHandler; - public ExecutionPerfTests() - { - this.vstestConsoleWrapper = this.GetVsTestConsoleWrapper(); - this.runEventHandler = new RunEventHandler(); - } + public ExecutionPerfTests() + { + _vstestConsoleWrapper = GetVsTestConsoleWrapper(); + _runEventHandler = new RunEventHandler(); + } - [TestMethod] - [TestCategory("TelemetryPerf")] - public void RunMsTest10K() + [TestMethod] + [TestCategory("TelemetryPerf")] + public void RunMsTest10K() + { + var testAssemblies = new List { - var testAssemblies = new List - { - GetPerfAssetFullPath("MSTestAdapterPerfTestProject", "MSTestAdapterPerfTestProject.dll"), - }; + GetPerfAssetFullPath("MSTestAdapterPerfTestProject", "MSTestAdapterPerfTestProject.dll"), + }; - this.vstestConsoleWrapper.RunTests(testAssemblies, this.GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true }, this.runEventHandler); + _vstestConsoleWrapper.RunTests(testAssemblies, GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true }, _runEventHandler); - this.PostTelemetry("RunMsTest10K", this.runEventHandler.Metrics); - } + PostTelemetry("RunMsTest10K", _runEventHandler.Metrics); + } - [TestMethod] - [TestCategory("TelemetryPerf")] - public void RunXunit10K() + [TestMethod] + [TestCategory("TelemetryPerf")] + public void RunXunit10K() + { + var testAssemblies = new List { - var testAssemblies = new List - { - GetPerfAssetFullPath("XunitAdapterPerfTestProject", "XunitAdapterPerfTestProject.dll"), - }; + GetPerfAssetFullPath("XunitAdapterPerfTestProject", "XunitAdapterPerfTestProject.dll"), + }; - this.vstestConsoleWrapper.RunTests(testAssemblies, this.GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true }, this.runEventHandler); + _vstestConsoleWrapper.RunTests(testAssemblies, GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true }, _runEventHandler); - this.PostTelemetry("RunXunit10K", this.runEventHandler.Metrics); - } + PostTelemetry("RunXunit10K", _runEventHandler.Metrics); + } - [TestMethod] - [TestCategory("TelemetryPerf")] - public void RunNunit10K() + [TestMethod] + [TestCategory("TelemetryPerf")] + public void RunNunit10K() + { + var testAssemblies = new List { - var testAssemblies = new List - { - GetPerfAssetFullPath("NunitAdapterPerfTestProject", "NunitAdapterPerfTestProject.dll"), - }; + GetPerfAssetFullPath("NunitAdapterPerfTestProject", "NunitAdapterPerfTestProject.dll"), + }; - this.vstestConsoleWrapper.RunTests(testAssemblies, this.GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true }, this.runEventHandler); + _vstestConsoleWrapper.RunTests(testAssemblies, GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true }, _runEventHandler); - this.PostTelemetry("RunNunit10K", this.runEventHandler.Metrics); - } + PostTelemetry("RunNunit10K", _runEventHandler.Metrics); + } - [TestMethod] - [TestCategory("TelemetryPerf")] - public void RunMsTest10KWithDefaultAdaptersSkipped() + [TestMethod] + [TestCategory("TelemetryPerf")] + public void RunMsTest10KWithDefaultAdaptersSkipped() + { + var testAssemblies = new List { - var testAssemblies = new List - { - GetPerfAssetFullPath("MSTestAdapterPerfTestProject", "MSTestAdapterPerfTestProject.dll"), - }; + GetPerfAssetFullPath("MSTestAdapterPerfTestProject", "MSTestAdapterPerfTestProject.dll"), + }; - this.vstestConsoleWrapper.RunTests(testAssemblies, this.GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true, SkipDefaultAdapters = true }, this.runEventHandler); + _vstestConsoleWrapper.RunTests(testAssemblies, GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true, SkipDefaultAdapters = true }, _runEventHandler); - this.PostTelemetry("RunMsTest10KWithDefaultAdaptersSkipped", this.runEventHandler.Metrics); - } + PostTelemetry("RunMsTest10KWithDefaultAdaptersSkipped", _runEventHandler.Metrics); + } - [TestMethod] - [TestCategory("TelemetryPerf")] - public void RunXunit10KWithDefaultAdaptersSkipped() + [TestMethod] + [TestCategory("TelemetryPerf")] + public void RunXunit10KWithDefaultAdaptersSkipped() + { + var testAssemblies = new List { - var testAssemblies = new List - { - GetPerfAssetFullPath("XunitAdapterPerfTestProject", "XunitAdapterPerfTestProject.dll"), - }; + GetPerfAssetFullPath("XunitAdapterPerfTestProject", "XunitAdapterPerfTestProject.dll"), + }; - this.vstestConsoleWrapper.RunTests(testAssemblies, this.GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true, SkipDefaultAdapters = true }, this.runEventHandler); + _vstestConsoleWrapper.RunTests(testAssemblies, GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true, SkipDefaultAdapters = true }, _runEventHandler); - this.PostTelemetry("RunXunit10KWithDefaultAdaptersSkipped", this.runEventHandler.Metrics); - } + PostTelemetry("RunXunit10KWithDefaultAdaptersSkipped", _runEventHandler.Metrics); + } - [TestMethod] - [TestCategory("TelemetryPerf")] - public void RunNunit10KWithDefaultAdaptersSkipped() + [TestMethod] + [TestCategory("TelemetryPerf")] + public void RunNunit10KWithDefaultAdaptersSkipped() + { + var testAssemblies = new List { - var testAssemblies = new List - { - GetPerfAssetFullPath("NunitAdapterPerfTestProject", "NunitAdapterPerfTestProject.dll"), - }; + GetPerfAssetFullPath("NunitAdapterPerfTestProject", "NunitAdapterPerfTestProject.dll"), + }; - this.vstestConsoleWrapper.RunTests(testAssemblies, this.GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true, SkipDefaultAdapters = true }, this.runEventHandler); + _vstestConsoleWrapper.RunTests(testAssemblies, GetDefaultRunSettings(), new TestPlatformOptions() { CollectMetrics = true, SkipDefaultAdapters = true }, _runEventHandler); - this.PostTelemetry("RunNunit10KWithDefaultAdaptersSkipped", this.runEventHandler.Metrics); - } + PostTelemetry("RunNunit10KWithDefaultAdaptersSkipped", _runEventHandler.Metrics); } } diff --git a/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/TelemetryPerfTestBase.cs b/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/TelemetryPerfTestBase.cs index 3f2dd5b6a2..ddaa0e2c5b 100644 --- a/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/TelemetryPerfTestBase.cs +++ b/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/TelemetryPerfTestBase.cs @@ -1,113 +1,112 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.PerformanceTests.TranslationLayer +namespace Microsoft.TestPlatform.PerformanceTests.TranslationLayer; + +using ApplicationInsights; +using ApplicationInsights.Extensibility; +using Microsoft.TestPlatform.VsTestConsole.TranslationLayer; +using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; +using VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +using System.IO; +using System.Reflection; + +[TestClass] +public class TelemetryPerfTestbase { - using Microsoft.ApplicationInsights; - using Microsoft.ApplicationInsights.Extensibility; - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer; - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System.Collections.Generic; - using System.IO; - using System.Reflection; + private const string TelemetryInstrumentationKey = "76b373ba-8a55-45dd-b6db-7f1a83288691"; + private readonly TelemetryClient _client; + private readonly DirectoryInfo _currentDirectory = new DirectoryInfo(typeof(DiscoveryPerfTests).GetTypeInfo().Assembly.GetAssemblyLocation()).Parent; - [TestClass] - public class TelemetryPerfTestbase + public TelemetryPerfTestbase() { - private const string TelemetryInstrumentationKey = "76b373ba-8a55-45dd-b6db-7f1a83288691"; - private TelemetryClient client; - private DirectoryInfo currentDirectory = new DirectoryInfo(typeof(DiscoveryPerfTests).GetTypeInfo().Assembly.GetAssemblyLocation()).Parent; + _client = new TelemetryClient(); + TelemetryConfiguration.Active.InstrumentationKey = TelemetryInstrumentationKey; + } - public TelemetryPerfTestbase() - { - client = new TelemetryClient(); - TelemetryConfiguration.Active.InstrumentationKey = TelemetryInstrumentationKey; - } + /// + /// Used for posting the telemetry to AppInsights + /// + /// + /// + public void PostTelemetry(string perfScenario, IDictionary handlerMetrics) + { + var properties = new Dictionary(); + var metrics = new Dictionary(); - /// - /// Used for posting the telemetry to AppInsights - /// - /// - /// - public void PostTelemetry(string perfScenario, IDictionary handlerMetrics) + foreach (var entry in handlerMetrics) { - var properties = new Dictionary(); - var metrics = new Dictionary(); - - foreach (var entry in handlerMetrics) + var stringValue = entry.Value.ToString(); + if (double.TryParse(stringValue, out var doubleValue)) { - var stringValue = entry.Value.ToString(); - if (double.TryParse(stringValue, out var doubleValue)) - { - metrics.Add(entry.Key, doubleValue); - } - else - { - properties.Add(entry.Key, stringValue); - } + metrics.Add(entry.Key, doubleValue); + } + else + { + properties.Add(entry.Key, stringValue); } - this.client.TrackEvent(perfScenario, properties, metrics); - this.client.Flush(); } + _client.TrackEvent(perfScenario, properties, metrics); + _client.Flush(); + } - /// - /// Returns the full path to the test asset dll - /// - /// Name of the directory of the test dll - /// Name of the test dll - /// - public string GetPerfAssetFullPath(string dllDirectory, string dllName) - { - return Path.Combine(this.currentDirectory.FullName, "TestAssets\\PerfAssets", dllDirectory , dllName ); - } + /// + /// Returns the full path to the test asset dll + /// + /// Name of the directory of the test dll + /// Name of the test dll + /// + public string GetPerfAssetFullPath(string dllDirectory, string dllName) + { + return Path.Combine(_currentDirectory.FullName, "TestAssets\\PerfAssets", dllDirectory, dllName); + } - /// - /// Returns the VsTestConsole Wrapper. - /// - /// - public IVsTestConsoleWrapper GetVsTestConsoleWrapper() - { - var vstestConsoleWrapper = new VsTestConsoleWrapper(this.GetConsoleRunnerPath()); - vstestConsoleWrapper.StartSession(); + /// + /// Returns the VsTestConsole Wrapper. + /// + /// + public IVsTestConsoleWrapper GetVsTestConsoleWrapper() + { + var vstestConsoleWrapper = new VsTestConsoleWrapper(GetConsoleRunnerPath()); + vstestConsoleWrapper.StartSession(); - return vstestConsoleWrapper; - } + return vstestConsoleWrapper; + } - private string BuildConfiguration + private string BuildConfiguration + { + get { - get - { #if DEBUG - return "Debug"; + return "Debug"; #else - return "Release"; + return "Release"; #endif - } } + } - private string GetConsoleRunnerPath() - { - // Find the root - var root = this.currentDirectory.Parent.Parent.Parent; - // Path to artifacts vstest.console - return Path.Combine(root.FullName, BuildConfiguration, "net451", "win7-x64", "vstest.console.exe"); - } + private string GetConsoleRunnerPath() + { + // Find the root + var root = _currentDirectory.Parent.Parent.Parent; + // Path to artifacts vstest.console + return Path.Combine(root.FullName, BuildConfiguration, "net451", "win7-x64", "vstest.console.exe"); + } - /// - /// Returns the default runsettings xml - /// - /// - public string GetDefaultRunSettings() - { - string runSettingsXml = $@" + /// + /// Returns the default runsettings xml + /// + /// + public string GetDefaultRunSettings() + { + string runSettingsXml = $@" Framework45 "; - return runSettingsXml; - } + return runSettingsXml; } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.SmokeTests/DataCollectorTests.Coverlet.cs b/test/Microsoft.TestPlatform.SmokeTests/DataCollectorTests.Coverlet.cs index d99fc1de05..4c6d44f1e6 100644 --- a/test/Microsoft.TestPlatform.SmokeTests/DataCollectorTests.Coverlet.cs +++ b/test/Microsoft.TestPlatform.SmokeTests/DataCollectorTests.Coverlet.cs @@ -1,56 +1,55 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.SmokeTests +namespace Microsoft.TestPlatform.SmokeTests; + +using TestUtilities; +using VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; +using System; +using System.IO; +using System.Linq; + +[TestClass] +public class DataCollectorTestsCoverlets : IntegrationTestBase { - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; - using System; - using System.IO; - using System.Linq; - - [TestClass] - public class DataCollectorTestsCoverlets : IntegrationTestBase + [TestMethod] + public void RunCoverletCoverage() { - [TestMethod] - public void RunCoverletCoverage() + // Collector is supported only for netcoreapp2.1, is compiled for netcoreapp2.1 and packaged as netstandard + if (_testEnvironment.TargetFramework != CoreRunnerFramework) { - // Collector is supported only for netcoreapp2.1, is compiled for netcoreapp2.1 and packaged as netstandard - if (this.testEnvironment.TargetFramework != CoreRunnerFramework) - { - return; - } - - // We use netcoreapp runner - // "...\vstest\tools\dotnet\dotnet.exe "...\vstest\artifacts\Debug\netcoreapp2.1\vstest.console.dll" --collect:"XPlat Code Coverage" ... - this.testEnvironment.RunnerFramework = CoreRunnerFramework; - var resultsDir = new TempDirectory(); - - string coverletAdapterPath = Path.GetDirectoryName(Directory.GetFiles(this.testEnvironment.GetNugetPackage("coverlet.collector"), "coverlet.collector.dll", SearchOption.AllDirectories).Single()); - string logId = Guid.NewGuid().ToString("N"); - string assemblyPath = this.BuildMultipleAssemblyPath("CoverletCoverageTestProject.dll").Trim('\"'); - string logPath = Path.Combine(Path.GetDirectoryName(assemblyPath), $"coverletcoverage.{logId}.log"); - string logPathDirectory = Path.GetDirectoryName(logPath); - string argument = $"--collect:{"XPlat Code Coverage".AddDoubleQuote()} {PrepareArguments(assemblyPath, coverletAdapterPath, "", ".NETCoreApp,Version=v2.1", resultsDirectory: resultsDir.Path)} --diag:{logPath.AddDoubleQuote()}"; - this.InvokeVsTest(argument); - - // Verify vstest.console.dll CollectArgumentProcessor fix codeBase for coverlet package - // This assert check that we're sure that we've updated collector setting code base with full path, - // otherwise without "custom coverlet code" inside ProxyExecutionManager coverlet dll won't be resolved inside testhost. - var log = Directory.GetFiles(logPathDirectory, $"coverletcoverage.{logId}.log").Single(); - Assert.IsTrue(File.ReadAllText(log).Contains("CoverletDataCollector in-process codeBase path")); - - // Verify out-of-proc coverlet collector load - var dataCollectorLog = Directory.GetFiles(logPathDirectory, $"coverletcoverage.{logId}.datacollector*log").Single(); - Assert.IsTrue(File.ReadAllText(dataCollectorLog).Contains("[coverlet]Initializing CoverletCoverageDataCollector")); - - // Verify in-proc coverlet collector load - var hostLog = Directory.GetFiles(logPathDirectory, $"coverletcoverage.{logId}.host*log").Single(); - Assert.IsTrue(File.ReadAllText(hostLog).Contains("[coverlet]Initialize CoverletInProcDataCollector")); - - // Verify default coverage file is generated - this.StdOutputContains("coverage.cobertura.xml"); + return; } + + // We use netcoreapp runner + // "...\vstest\tools\dotnet\dotnet.exe "...\vstest\artifacts\Debug\netcoreapp2.1\vstest.console.dll" --collect:"XPlat Code Coverage" ... + _testEnvironment.RunnerFramework = CoreRunnerFramework; + var resultsDir = new TempDirectory(); + + string coverletAdapterPath = Path.GetDirectoryName(Directory.GetFiles(_testEnvironment.GetNugetPackage("coverlet.collector"), "coverlet.collector.dll", SearchOption.AllDirectories).Single()); + string logId = Guid.NewGuid().ToString("N"); + string assemblyPath = BuildMultipleAssemblyPath("CoverletCoverageTestProject.dll").Trim('\"'); + string logPath = Path.Combine(Path.GetDirectoryName(assemblyPath), $"coverletcoverage.{logId}.log"); + string logPathDirectory = Path.GetDirectoryName(logPath); + string argument = $"--collect:{"XPlat Code Coverage".AddDoubleQuote()} {PrepareArguments(assemblyPath, coverletAdapterPath, "", ".NETCoreApp,Version=v2.1", resultsDirectory: resultsDir.Path)} --diag:{logPath.AddDoubleQuote()}"; + InvokeVsTest(argument); + + // Verify vstest.console.dll CollectArgumentProcessor fix codeBase for coverlet package + // This assert check that we're sure that we've updated collector setting code base with full path, + // otherwise without "custom coverlet code" inside ProxyExecutionManager coverlet dll won't be resolved inside testhost. + var log = Directory.GetFiles(logPathDirectory, $"coverletcoverage.{logId}.log").Single(); + Assert.IsTrue(File.ReadAllText(log).Contains("CoverletDataCollector in-process codeBase path")); + + // Verify out-of-proc coverlet collector load + var dataCollectorLog = Directory.GetFiles(logPathDirectory, $"coverletcoverage.{logId}.datacollector*log").Single(); + Assert.IsTrue(File.ReadAllText(dataCollectorLog).Contains("[coverlet]Initializing CoverletCoverageDataCollector")); + + // Verify in-proc coverlet collector load + var hostLog = Directory.GetFiles(logPathDirectory, $"coverletcoverage.{logId}.host*log").Single(); + Assert.IsTrue(File.ReadAllText(hostLog).Contains("[coverlet]Initialize CoverletInProcDataCollector")); + + // Verify default coverage file is generated + StdOutputContains("coverage.cobertura.xml"); } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.SmokeTests/DataCollectorTests.cs b/test/Microsoft.TestPlatform.SmokeTests/DataCollectorTests.cs index d4fd64d77e..dc6adf9918 100644 --- a/test/Microsoft.TestPlatform.SmokeTests/DataCollectorTests.cs +++ b/test/Microsoft.TestPlatform.SmokeTests/DataCollectorTests.cs @@ -1,46 +1,48 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.SmokeTests +namespace Microsoft.TestPlatform.SmokeTests; + +using System.IO; + +using TestUtilities; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class DataCollectorTests : IntegrationTestBase { - using System.IO; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; + private static readonly string InProcTestResultFile = Path.Combine(Path.GetTempPath(), "inproctest.txt"); + private const string InProDataCollectorTestProject = "SimpleTestProject.dll"; + [TestMethod] + public void RunAllWithInProcDataCollectorSettings() + { + // Delete File if already exists + File.Delete(InProcTestResultFile); + + var runSettings = GetInProcDataCollectionRunsettingsFile(); + + InvokeVsTestForExecution(_testEnvironment.GetTestAsset(InProDataCollectorTestProject), GetTestAdapterPath(), ".NETFramework,Version=v4.5.1", runSettings); + ValidateSummaryStatus(1, 1, 1); + + ValidateInProcDataCollectionOutput(); + } + + private static void ValidateInProcDataCollectionOutput() + { + Assert.IsTrue(File.Exists(InProcTestResultFile), "Datacollector test file doesn't exist: {0}.", InProcTestResultFile); + var actual = File.ReadAllText(InProcTestResultFile); + var expected = @"TestSessionStart : 4312 TestCaseStart : PassingTest TestCaseEnd : PassingTest TestCaseStart : FailingTest TestCaseEnd : FailingTest TestCaseStart : SkippingTest TestCaseEnd : SkippingTest TestSessionEnd"; + actual = actual.Replace(" ", string.Empty).Replace("\r\n", string.Empty); + expected = expected.Replace(" ", string.Empty).Replace("\r\n", string.Empty); + Assert.AreEqual(expected, actual); + } - [TestClass] - public class DataCollectorTests : IntegrationTestBase + private string GetInProcDataCollectionRunsettingsFile() { - private static string InProcTestResultFile = Path.Combine(Path.GetTempPath(), "inproctest.txt"); - private const string InProDataCollectorTestProject = "SimpleTestProject.dll"; - [TestMethod] - public void RunAllWithInProcDataCollectorSettings() - { - // Delete File if already exists - File.Delete(InProcTestResultFile); - - var runSettings = this.GetInProcDataCollectionRunsettingsFile(); - - this.InvokeVsTestForExecution(testEnvironment.GetTestAsset(DataCollectorTests.InProDataCollectorTestProject), this.GetTestAdapterPath(), ".NETFramework,Version=v4.5.1", runSettings); - this.ValidateSummaryStatus(1, 1, 1); - - ValidateInProcDataCollectionOutput(); - } - - private static void ValidateInProcDataCollectionOutput() - { - Assert.IsTrue(File.Exists(InProcTestResultFile), "Datacollector test file doesn't exist: {0}.", InProcTestResultFile); - var actual = File.ReadAllText(InProcTestResultFile); - var expected = @"TestSessionStart : 4312 TestCaseStart : PassingTest TestCaseEnd : PassingTest TestCaseStart : FailingTest TestCaseEnd : FailingTest TestCaseStart : SkippingTest TestCaseEnd : SkippingTest TestSessionEnd"; - actual = actual.Replace(" ", string.Empty).Replace("\r\n", string.Empty); - expected = expected.Replace(" ", string.Empty).Replace("\r\n", string.Empty); - Assert.AreEqual(expected, actual); - } - - private string GetInProcDataCollectionRunsettingsFile() - { - var runSettings = Path.Combine(Path.GetDirectoryName(testEnvironment.GetTestAsset(DataCollectorTests.InProDataCollectorTestProject)), "runsettingstest.runsettings"); - var inprocasm = testEnvironment.GetTestAsset("SimpleDataCollector.dll"); - var fileContents = @" + var runSettings = Path.Combine(Path.GetDirectoryName(_testEnvironment.GetTestAsset(InProDataCollectorTestProject)), "runsettingstest.runsettings"); + var inprocasm = _testEnvironment.GetTestAsset("SimpleDataCollector.dll"); + var fileContents = @" @@ -52,10 +54,9 @@ private string GetInProcDataCollectionRunsettingsFile() "; - fileContents = string.Format(fileContents, AssemblyUtility.GetAssemblyName(inprocasm), inprocasm); - File.WriteAllText(runSettings, fileContents); + fileContents = string.Format(fileContents, AssemblyUtility.GetAssemblyName(inprocasm), inprocasm); + File.WriteAllText(runSettings, fileContents); - return runSettings; - } + return runSettings; } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.SmokeTests/DiscoveryTests.cs b/test/Microsoft.TestPlatform.SmokeTests/DiscoveryTests.cs index 3329868548..75cdd41bd7 100644 --- a/test/Microsoft.TestPlatform.SmokeTests/DiscoveryTests.cs +++ b/test/Microsoft.TestPlatform.SmokeTests/DiscoveryTests.cs @@ -1,20 +1,20 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.SmokeTests -{ - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.SmokeTests; + +using TestUtilities; - [TestClass] - public class DiscoveryTests : IntegrationTestBase +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class DiscoveryTests : IntegrationTestBase +{ + [TestMethod] + public void DiscoverAllTests() { - [TestMethod] - public void DiscoverAllTests() - { - this.InvokeVsTestForDiscovery(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, ".NETFramework,Version=v4.5.1"); - var listOfTests = new string[] { "SampleUnitTestProject.UnitTest1.PassingTest", "SampleUnitTestProject.UnitTest1.FailingTest", "SampleUnitTestProject.UnitTest1.SkippingTest" }; - this.ValidateDiscoveredTests(listOfTests); - } + InvokeVsTestForDiscovery(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, ".NETFramework,Version=v4.5.1"); + var listOfTests = new string[] { "SampleUnitTestProject.UnitTest1.PassingTest", "SampleUnitTestProject.UnitTest1.FailingTest", "SampleUnitTestProject.UnitTest1.SkippingTest" }; + ValidateDiscoveredTests(listOfTests); } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.SmokeTests/DotnetHostArchitectureVerifierTests.cs b/test/Microsoft.TestPlatform.SmokeTests/DotnetHostArchitectureVerifierTests.cs index 4c2eac9e32..d424fd2468 100644 --- a/test/Microsoft.TestPlatform.SmokeTests/DotnetHostArchitectureVerifierTests.cs +++ b/test/Microsoft.TestPlatform.SmokeTests/DotnetHostArchitectureVerifierTests.cs @@ -1,48 +1,48 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.SmokeTests -{ - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Newtonsoft.Json.Linq; - using System.Collections.Generic; - using System.IO; - using System.Linq; +namespace Microsoft.TestPlatform.SmokeTests; + +using TestUtilities; +using VisualStudio.TestTools.UnitTesting; +using Newtonsoft.Json.Linq; +using System.Collections.Generic; +using System.IO; +using System.Linq; - [TestClass] - // On Linux/Mac we don't download the same .NET SDK bundles - [TestCategory("Windows-Review")] - public class DotnetHostArchitectureVerifierTests : IntegrationTestBase +[TestClass] +// On Linux/Mac we don't download the same .NET SDK bundles +[TestCategory("Windows-Review")] +public class DotnetHostArchitectureVerifierTests : IntegrationTestBase +{ + [TestMethod] + [DataRow("X64")] + [DataRow("X86")] + public void VerifyHostArchitecture(string architecture) { - [TestMethod] - [DataRow("X64")] - [DataRow("X86")] - public void VerifyHostArchitecture(string architecture) - { - using var workSpace = new TempDirectory(); - string dotnetPath = GetDownloadedDotnetMuxerFromTools(architecture); - var vstestConsolePath = GetDotnetRunnerPath(); - var dotnetRunnerPath = workSpace.CreateDirectory("dotnetrunner"); - workSpace.CopyAll(new DirectoryInfo(Path.GetDirectoryName(vstestConsolePath)), dotnetRunnerPath); + using var workSpace = new TempDirectory(); + string dotnetPath = GetDownloadedDotnetMuxerFromTools(architecture); + var vstestConsolePath = GetDotnetRunnerPath(); + var dotnetRunnerPath = workSpace.CreateDirectory("dotnetrunner"); + workSpace.CopyAll(new DirectoryInfo(Path.GetDirectoryName(vstestConsolePath)), dotnetRunnerPath); - // Patch the runner - string sdkVersion = GetLatestSdkVersion(dotnetPath); - string runtimeConfigFile = Path.Combine(dotnetRunnerPath.FullName, "vstest.console.runtimeconfig.json"); - JObject patchRuntimeConfig = JObject.Parse(File.ReadAllText(runtimeConfigFile)); - patchRuntimeConfig["runtimeOptions"]["framework"]["version"] = sdkVersion; - File.WriteAllText(runtimeConfigFile, patchRuntimeConfig.ToString()); + // Patch the runner + string sdkVersion = GetLatestSdkVersion(dotnetPath); + string runtimeConfigFile = Path.Combine(dotnetRunnerPath.FullName, "vstest.console.runtimeconfig.json"); + JObject patchRuntimeConfig = JObject.Parse(File.ReadAllText(runtimeConfigFile)); + patchRuntimeConfig["runtimeOptions"]["framework"]["version"] = sdkVersion; + File.WriteAllText(runtimeConfigFile, patchRuntimeConfig.ToString()); - var environmentVariables = new Dictionary - { - ["DOTNET_MULTILEVEL_LOOKUP"] = "0", - ["ExpectedArchitecture"] = architecture - }; + var environmentVariables = new Dictionary + { + ["DOTNET_MULTILEVEL_LOOKUP"] = "0", + ["ExpectedArchitecture"] = architecture + }; - this.ExecuteApplication(dotnetPath, "new mstest", out string stdOut, out string stdError, out int exitCode, environmentVariables, workSpace.Path); + ExecuteApplication(dotnetPath, "new mstest", out string stdOut, out string stdError, out int exitCode, environmentVariables, workSpace.Path); - // Patch test file - File.WriteAllText(Path.Combine(workSpace.Path, "UnitTest1.cs"), + // Patch test file + File.WriteAllText(Path.Combine(workSpace.Path, "UnitTest1.cs"), @" using Microsoft.VisualStudio.TestTools.UnitTesting; using System; @@ -59,11 +59,10 @@ public void TestMethod1() } }"); - this.ExecuteApplication(dotnetPath, $"test -p:VsTestConsolePath=\"{Path.Combine(dotnetRunnerPath.FullName, Path.GetFileName(vstestConsolePath))}\"", out stdOut, out stdError, out exitCode, environmentVariables, workSpace.Path); - Assert.AreEqual(0, exitCode, stdOut); - } - - private string GetLatestSdkVersion(string dotnetPath) - => Path.GetFileName(Directory.GetDirectories(Path.Combine(Path.GetDirectoryName(dotnetPath), @"shared/Microsoft.NETCore.App")).OrderByDescending(x => x).First()); + ExecuteApplication(dotnetPath, $"test -p:VsTestConsolePath=\"{Path.Combine(dotnetRunnerPath.FullName, Path.GetFileName(vstestConsolePath))}\"", out stdOut, out stdError, out exitCode, environmentVariables, workSpace.Path); + Assert.AreEqual(0, exitCode, stdOut); } -} + + private string GetLatestSdkVersion(string dotnetPath) + => Path.GetFileName(Directory.GetDirectories(Path.Combine(Path.GetDirectoryName(dotnetPath), @"shared/Microsoft.NETCore.App")).OrderByDescending(x => x).First()); +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.SmokeTests/ExecutionTests.cs b/test/Microsoft.TestPlatform.SmokeTests/ExecutionTests.cs index 5584ef4f5a..9316e57e9f 100644 --- a/test/Microsoft.TestPlatform.SmokeTests/ExecutionTests.cs +++ b/test/Microsoft.TestPlatform.SmokeTests/ExecutionTests.cs @@ -1,34 +1,33 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.SmokeTests -{ - using Microsoft.TestPlatform.TestUtilities; +namespace Microsoft.TestPlatform.SmokeTests; + +using TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using VisualStudio.TestTools.UnitTesting; - [TestClass] - public class ExecutionTests : IntegrationTestBase +[TestClass] +public class ExecutionTests : IntegrationTestBase +{ + [TestMethod] + public void RunAllTestExecution() { - [TestMethod] - public void RunAllTestExecution() - { - this.InvokeVsTestForExecution(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), ".NETFramework,Version=v4.5.1"); - this.ValidateSummaryStatus(1, 1, 1); - this.ValidatePassedTests("SampleUnitTestProject.UnitTest1.PassingTest"); - this.ValidateFailedTests("SampleUnitTestProject.UnitTest1.FailingTest"); - this.ValidateSkippedTests("SampleUnitTestProject.UnitTest1.SkippingTest"); - } + InvokeVsTestForExecution(GetSampleTestAssembly(), GetTestAdapterPath(), ".NETFramework,Version=v4.5.1"); + ValidateSummaryStatus(1, 1, 1); + ValidatePassedTests("SampleUnitTestProject.UnitTest1.PassingTest"); + ValidateFailedTests("SampleUnitTestProject.UnitTest1.FailingTest"); + ValidateSkippedTests("SampleUnitTestProject.UnitTest1.SkippingTest"); + } - [TestMethod] - public void RunSelectedTests() - { - using var resultsDir = new TempDirectory(); - var arguments = PrepareArguments(this.GetSampleTestAssembly(), this.GetTestAdapterPath(), string.Empty, ".NETFramework,Version=v4.5.1", resultsDirectory: resultsDir.Path); - arguments = string.Concat(arguments, " /Tests:PassingTest"); - this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 0, 0); - this.ValidatePassedTests("SampleUnitTestProject.UnitTest1.PassingTest"); - } + [TestMethod] + public void RunSelectedTests() + { + using var resultsDir = new TempDirectory(); + var arguments = PrepareArguments(GetSampleTestAssembly(), GetTestAdapterPath(), string.Empty, ".NETFramework,Version=v4.5.1", resultsDirectory: resultsDir.Path); + arguments = string.Concat(arguments, " /Tests:PassingTest"); + InvokeVsTest(arguments); + ValidateSummaryStatus(1, 0, 0); + ValidatePassedTests("SampleUnitTestProject.UnitTest1.PassingTest"); } } diff --git a/test/Microsoft.TestPlatform.SmokeTests/Program.cs b/test/Microsoft.TestPlatform.SmokeTests/Program.cs index f51a7b7fe2..2b49b9440a 100644 --- a/test/Microsoft.TestPlatform.SmokeTests/Program.cs +++ b/test/Microsoft.TestPlatform.SmokeTests/Program.cs @@ -1,11 +1,13 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace testhost.UnitTests +#pragma warning disable IDE1006 // Naming Styles +namespace testhost.UnitTests; +#pragma warning restore IDE1006 // Naming Styles + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DefaultTestHostManagerTests.cs b/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DefaultTestHostManagerTests.cs index 99cb96cf7a..d88b369a0f 100644 --- a/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DefaultTestHostManagerTests.cs +++ b/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DefaultTestHostManagerTests.cs @@ -1,598 +1,597 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.TestHostProvider.Hosting.UnitTests +namespace TestPlatform.TestHostProvider.Hosting.UnitTests; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Threading; +using System.Threading.Tasks; + +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting; +using Microsoft.VisualStudio.TestPlatform.DesktopTestHostRuntimeProvider; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class DefaultTestHostManagerTests { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.IO; - using System.Linq; - using System.Reflection; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting; - using Microsoft.VisualStudio.TestPlatform.DesktopTestHostRuntimeProvider; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - -#pragma warning disable SA1600 - [TestClass] - public class DefaultTestHostManagerTests - { - private readonly TestProcessStartInfo startInfo; - private readonly Mock mockMessageLogger; - private readonly Mock mockProcessHelper; - private readonly Mock mockFileHelper; - private readonly Mock mockDotnetHostHelper; - private readonly Mock mockEnvironment; - - private DefaultTestHostManager testHostManager; - private TestableTestHostManager testableTestHostManager; - private string errorMessage; - private int exitCode; - private int testHostId; - - public DefaultTestHostManagerTests() - { - this.mockProcessHelper = new Mock(); - this.mockFileHelper = new Mock(); - this.mockProcessHelper.Setup(ph => ph.GetCurrentProcessFileName()).Returns("vstest.console.exe"); - this.mockDotnetHostHelper = new Mock(); - this.mockEnvironment = new Mock(); + private readonly TestProcessStartInfo _startInfo; + private readonly Mock _mockMessageLogger; + private readonly Mock _mockProcessHelper; + private readonly Mock _mockFileHelper; + private readonly Mock _mockDotnetHostHelper; + private readonly Mock _mockEnvironment; + + private readonly DefaultTestHostManager _testHostManager; + private TestableTestHostManager _testableTestHostManager; + private string _errorMessage; + private int _exitCode; + private int _testHostId; + + public DefaultTestHostManagerTests() + { + _mockProcessHelper = new Mock(); + _mockFileHelper = new Mock(); + _mockProcessHelper.Setup(ph => ph.GetCurrentProcessFileName()).Returns("vstest.console.exe"); + _mockDotnetHostHelper = new Mock(); + _mockEnvironment = new Mock(); - this.mockMessageLogger = new Mock(); + _mockMessageLogger = new Mock(); - this.testHostManager = new DefaultTestHostManager(this.mockProcessHelper.Object, this.mockFileHelper.Object, this.mockEnvironment.Object, this.mockDotnetHostHelper.Object); - this.testHostManager.Initialize(this.mockMessageLogger.Object, $" {Architecture.X64} {Framework.DefaultFramework} {false} "); - this.startInfo = this.testHostManager.GetTestHostProcessStartInfo(Enumerable.Empty(), null, default); - } + _testHostManager = new DefaultTestHostManager(_mockProcessHelper.Object, _mockFileHelper.Object, _mockEnvironment.Object, _mockDotnetHostHelper.Object); + _testHostManager.Initialize(_mockMessageLogger.Object, $" {Architecture.X64} {Framework.DefaultFramework} {false} "); + _startInfo = _testHostManager.GetTestHostProcessStartInfo(Enumerable.Empty(), null, default); + } - [TestMethod] - public void ConstructorShouldSetX86ProcessForX86Architecture() - { - this.testHostManager.Initialize(this.mockMessageLogger.Object, $" {Architecture.X86} {Framework.DefaultFramework} {false} "); + [TestMethod] + public void ConstructorShouldSetX86ProcessForX86Architecture() + { + _testHostManager.Initialize(_mockMessageLogger.Object, $" {Architecture.X86} {Framework.DefaultFramework} {false} "); - var info = this.testHostManager.GetTestHostProcessStartInfo(Enumerable.Empty(), null, default); + var info = _testHostManager.GetTestHostProcessStartInfo(Enumerable.Empty(), null, default); - StringAssert.EndsWith(info.FileName, "testhost.x86.exe"); - } + StringAssert.EndsWith(info.FileName, "testhost.x86.exe"); + } - [TestMethod] - public void ConstructorShouldSetX64ProcessForX64Architecture() - { - StringAssert.EndsWith(this.startInfo.FileName, "testhost.exe"); - } + [TestMethod] + public void ConstructorShouldSetX64ProcessForX64Architecture() + { + StringAssert.EndsWith(_startInfo.FileName, "testhost.exe"); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldIncludeFileNameFromSubFolderTestHostWhenCurrentProcessIsDotnet() - { - string subFoler = "TestHost"; + [TestMethod] + public void GetTestHostProcessStartInfoShouldIncludeFileNameFromSubFolderTestHostWhenCurrentProcessIsDotnet() + { + string subFoler = "TestHost"; - var startInfo = this.testHostManager.GetTestHostProcessStartInfo(Enumerable.Empty(), null, default); + var startInfo = _testHostManager.GetTestHostProcessStartInfo(Enumerable.Empty(), null, default); - Assert.IsTrue(startInfo.FileName.EndsWith(Path.Combine(subFoler, "testhost.exe"))); - } + Assert.IsTrue(startInfo.FileName.EndsWith(Path.Combine(subFoler, "testhost.exe"))); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldIncludeConnectionInfo() - { - var connectionInfo = new TestRunnerConnectionInfo { Port = 123, ConnectionInfo = new TestHostConnectionInfo { Endpoint = "127.0.0.0:123", Role = ConnectionRole.Client, Transport = Transport.Sockets }, RunnerProcessId = 101 }; - var info = this.testHostManager.GetTestHostProcessStartInfo( - Enumerable.Empty(), - null, - connectionInfo); + [TestMethod] + public void GetTestHostProcessStartInfoShouldIncludeConnectionInfo() + { + var connectionInfo = new TestRunnerConnectionInfo { Port = 123, ConnectionInfo = new TestHostConnectionInfo { Endpoint = "127.0.0.0:123", Role = ConnectionRole.Client, Transport = Transport.Sockets }, RunnerProcessId = 101 }; + var info = _testHostManager.GetTestHostProcessStartInfo( + Enumerable.Empty(), + null, + connectionInfo); - Assert.AreEqual(" --port 123 --endpoint 127.0.0.0:123 --role client --parentprocessid 101", info.Arguments); - } + Assert.AreEqual(" --port 123 --endpoint 127.0.0.0:123 --role client --parentprocessid 101", info.Arguments); + } - [TestMethod] - public void GetTestHostConnectionInfoShouldIncludeEndpointRoleAndChannelType() + [TestMethod] + public void GetTestHostConnectionInfoShouldIncludeEndpointRoleAndChannelType() + { + var connectionInfo = new TestHostConnectionInfo { - var connectionInfo = new TestHostConnectionInfo - { - Endpoint = "127.0.0.1:0", - Role = ConnectionRole.Client, - Transport = Transport.Sockets - }; + Endpoint = "127.0.0.1:0", + Role = ConnectionRole.Client, + Transport = Transport.Sockets + }; - var info = this.testHostManager.GetTestHostConnectionInfo(); + var info = _testHostManager.GetTestHostConnectionInfo(); - Assert.AreEqual(connectionInfo, info); - } + Assert.AreEqual(connectionInfo, info); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldIncludeEmptyEnvironmentVariables() - { - Assert.AreEqual(0, this.startInfo.EnvironmentVariables.Count); - } + [TestMethod] + public void GetTestHostProcessStartInfoShouldIncludeEmptyEnvironmentVariables() + { + Assert.AreEqual(0, _startInfo.EnvironmentVariables.Count); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldIncludeEnvironmentVariables() - { - var environmentVariables = new Dictionary { { "k1", "v1" } }; + [TestMethod] + public void GetTestHostProcessStartInfoShouldIncludeEnvironmentVariables() + { + var environmentVariables = new Dictionary { { "k1", "v1" } }; - var info = this.testHostManager.GetTestHostProcessStartInfo(Enumerable.Empty(), environmentVariables, default); + var info = _testHostManager.GetTestHostProcessStartInfo(Enumerable.Empty(), environmentVariables, default); - Assert.AreEqual(environmentVariables, info.EnvironmentVariables); - } + Assert.AreEqual(environmentVariables, info.EnvironmentVariables); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldIncludeCurrentWorkingDirectory() - { - Assert.AreEqual(Directory.GetCurrentDirectory(), this.startInfo.WorkingDirectory); - } + [TestMethod] + public void GetTestHostProcessStartInfoShouldIncludeCurrentWorkingDirectory() + { + Assert.AreEqual(Directory.GetCurrentDirectory(), _startInfo.WorkingDirectory); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldIncludeTestSourcePathInArgumentsIfNonShared() - { - this.testHostManager.Initialize(this.mockMessageLogger.Object, $" {Architecture.X86} {Framework.DefaultFramework} {true} "); - var connectionInfo = new TestRunnerConnectionInfo { Port = 123, ConnectionInfo = new TestHostConnectionInfo { Endpoint = "127.0.0.0:123", Role = ConnectionRole.Client, Transport = Transport.Sockets }, RunnerProcessId = 101 }; - var source = "C:\temp\a.dll"; + [TestMethod] + public void GetTestHostProcessStartInfoShouldIncludeTestSourcePathInArgumentsIfNonShared() + { + _testHostManager.Initialize(_mockMessageLogger.Object, $" {Architecture.X86} {Framework.DefaultFramework} {true} "); + var connectionInfo = new TestRunnerConnectionInfo { Port = 123, ConnectionInfo = new TestHostConnectionInfo { Endpoint = "127.0.0.0:123", Role = ConnectionRole.Client, Transport = Transport.Sockets }, RunnerProcessId = 101 }; + var source = "C:\temp\a.dll"; - var info = this.testHostManager.GetTestHostProcessStartInfo( - new List() { source }, - null, - connectionInfo); + var info = _testHostManager.GetTestHostProcessStartInfo( + new List() { source }, + null, + connectionInfo); - Assert.AreEqual(" --port 123 --endpoint 127.0.0.0:123 --role client --parentprocessid 101 --testsourcepath " + source.AddDoubleQuote(), info.Arguments); - } + Assert.AreEqual(" --port 123 --endpoint 127.0.0.0:123 --role client --parentprocessid 101 --testsourcepath " + source.AddDoubleQuote(), info.Arguments); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldUseMonoAsHostOnNonWindowsIfNotStartedWithMono() - { - this.mockProcessHelper.Setup(p => p.GetCurrentProcessFileName()).Returns("/usr/bin/dotnet"); - this.mockEnvironment.Setup(e => e.OperatingSystem).Returns(PlatformOperatingSystem.Unix); - this.mockDotnetHostHelper.Setup(d => d.GetMonoPath()).Returns("/usr/bin/mono"); - var source = "C:\temp\a.dll"; - - var info = this.testHostManager.GetTestHostProcessStartInfo( - new List() { source }, - null, - default); - - Assert.AreEqual("/usr/bin/mono", info.FileName); - StringAssert.Contains(info.Arguments, "TestHost" + Path.DirectorySeparatorChar + "testhost.exe\""); - } + [TestMethod] + public void GetTestHostProcessStartInfoShouldUseMonoAsHostOnNonWindowsIfNotStartedWithMono() + { + _mockProcessHelper.Setup(p => p.GetCurrentProcessFileName()).Returns("/usr/bin/dotnet"); + _mockEnvironment.Setup(e => e.OperatingSystem).Returns(PlatformOperatingSystem.Unix); + _mockDotnetHostHelper.Setup(d => d.GetMonoPath()).Returns("/usr/bin/mono"); + var source = "C:\temp\a.dll"; + + var info = _testHostManager.GetTestHostProcessStartInfo( + new List() { source }, + null, + default); + + Assert.AreEqual("/usr/bin/mono", info.FileName); + StringAssert.Contains(info.Arguments, "TestHost" + Path.DirectorySeparatorChar + "testhost.exe\""); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldNotUseMonoAsHostOnNonWindowsIfStartedWithMono() - { - this.mockProcessHelper.Setup(p => p.GetCurrentProcessFileName()).Returns("/usr/bin/mono"); - this.mockEnvironment.Setup(e => e.OperatingSystem).Returns(PlatformOperatingSystem.Unix); - this.mockDotnetHostHelper.Setup(d => d.GetMonoPath()).Returns("/usr/bin/mono"); - var source = @"C:\temp\a.dll"; - - var info = this.testHostManager.GetTestHostProcessStartInfo( - new List() { source }, - null, - default); - - StringAssert.Contains(info.FileName, "TestHost" + Path.DirectorySeparatorChar + "testhost.exe"); - Assert.IsFalse(info.Arguments.Contains("TestHost" + Path.DirectorySeparatorChar + "testhost.exe")); - } + [TestMethod] + public void GetTestHostProcessStartInfoShouldNotUseMonoAsHostOnNonWindowsIfStartedWithMono() + { + _mockProcessHelper.Setup(p => p.GetCurrentProcessFileName()).Returns("/usr/bin/mono"); + _mockEnvironment.Setup(e => e.OperatingSystem).Returns(PlatformOperatingSystem.Unix); + _mockDotnetHostHelper.Setup(d => d.GetMonoPath()).Returns("/usr/bin/mono"); + var source = @"C:\temp\a.dll"; + + var info = _testHostManager.GetTestHostProcessStartInfo( + new List() { source }, + null, + default); + + StringAssert.Contains(info.FileName, "TestHost" + Path.DirectorySeparatorChar + "testhost.exe"); + Assert.IsFalse(info.Arguments.Contains("TestHost" + Path.DirectorySeparatorChar + "testhost.exe")); + } - [TestMethod] - public void GetTestPlatformExtensionsShouldReturnExtensionsListAsIsIfSourcesListIsEmpty() - { - this.testHostManager.Initialize(this.mockMessageLogger.Object, $" "); - List currentList = new List { @"FooExtension.dll" }; + [TestMethod] + public void GetTestPlatformExtensionsShouldReturnExtensionsListAsIsIfSourcesListIsEmpty() + { + _testHostManager.Initialize(_mockMessageLogger.Object, $" "); + List currentList = new() { @"FooExtension.dll" }; - // Act - var resultExtensions = this.testHostManager.GetTestPlatformExtensions(new List(), currentList).ToList(); + // Act + var resultExtensions = _testHostManager.GetTestPlatformExtensions(new List(), currentList).ToList(); - // Verify - CollectionAssert.AreEqual(currentList, resultExtensions); - } + // Verify + CollectionAssert.AreEqual(currentList, resultExtensions); + } - [TestMethod] - public void GetTestPlatformExtensionsShouldReturnExtensionsListAsIsIfSourcesListIsNull() - { - this.testHostManager.Initialize(this.mockMessageLogger.Object, $" "); - List currentList = new List { @"FooExtension.dll" }; + [TestMethod] + public void GetTestPlatformExtensionsShouldReturnExtensionsListAsIsIfSourcesListIsNull() + { + _testHostManager.Initialize(_mockMessageLogger.Object, $" "); + List currentList = new() { @"FooExtension.dll" }; - // Act - var resultExtensions = this.testHostManager.GetTestPlatformExtensions(null, currentList).ToList(); + // Act + var resultExtensions = _testHostManager.GetTestPlatformExtensions(null, currentList).ToList(); - // Verify - CollectionAssert.AreEqual(currentList, resultExtensions); - } + // Verify + CollectionAssert.AreEqual(currentList, resultExtensions); + } - [TestMethod] - public void GetTestPlatformExtensionsShouldNotExcludeOutputDirectoryExtensionsIfTestAdapterPathIsSet() - { - List sourcesDir = new List { @"C:\Source1" }; - List sources = new List { @"C:\Source1\source1.dll" }; + [TestMethod] + public void GetTestPlatformExtensionsShouldNotExcludeOutputDirectoryExtensionsIfTestAdapterPathIsSet() + { + List sourcesDir = new() { @"C:\Source1" }; + List sources = new() { @"C:\Source1\source1.dll" }; - List extensionsList1 = new List { @"C:\Source1\ext1.TestAdapter.dll", @"C:\Source1\ext2.TestAdapter.dll" }; - this.mockFileHelper.Setup(fh => fh.EnumerateFiles(sourcesDir[0], SearchOption.TopDirectoryOnly, "TestAdapter.dll")).Returns(extensionsList1); + List extensionsList1 = new() { @"C:\Source1\ext1.TestAdapter.dll", @"C:\Source1\ext2.TestAdapter.dll" }; + _mockFileHelper.Setup(fh => fh.EnumerateFiles(sourcesDir[0], SearchOption.TopDirectoryOnly, "TestAdapter.dll")).Returns(extensionsList1); - this.mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList1[0])).Returns(new Version(2, 0)); - this.mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList1[1])).Returns(new Version(5, 5)); + _mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList1[0])).Returns(new Version(2, 0)); + _mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList1[1])).Returns(new Version(5, 5)); - this.testHostManager.Initialize(this.mockMessageLogger.Object, $" C:\\Foo "); - List currentList = new List { @"FooExtension.dll", @"C:\Source1\ext1.TestAdapter.dll", @"C:\Source1\ext2.TestAdapter.dll" }; + _testHostManager.Initialize(_mockMessageLogger.Object, $" C:\\Foo "); + List currentList = new() { @"FooExtension.dll", @"C:\Source1\ext1.TestAdapter.dll", @"C:\Source1\ext2.TestAdapter.dll" }; - // Act - var resultExtensions = this.testHostManager.GetTestPlatformExtensions(sources, currentList).ToList(); + // Act + var resultExtensions = _testHostManager.GetTestPlatformExtensions(sources, currentList).ToList(); - // Verify - CollectionAssert.AreEqual(currentList, resultExtensions); - } + // Verify + CollectionAssert.AreEqual(currentList, resultExtensions); + } - [TestMethod] - [TestCategory("Windows")] - public void GetTestPlatformExtensionsShouldIncludeOutputDirectoryExtensionsIfTestAdapterPathIsNotSet() - { - List sourcesDir = new List { "C:\\Source1", "C:\\Source2" }; - List sources = new List { @"C:\Source1\source1.dll", @"C:\Source2\source2.dll" }; + [TestMethod] + [TestCategory("Windows")] + public void GetTestPlatformExtensionsShouldIncludeOutputDirectoryExtensionsIfTestAdapterPathIsNotSet() + { + List sourcesDir = new() { "C:\\Source1", "C:\\Source2" }; + List sources = new() { @"C:\Source1\source1.dll", @"C:\Source2\source2.dll" }; - List extensionsList1 = new List { @"C:\Source1\ext1.TestAdapter.dll", @"C:\Source1\ext2.TestAdapter.dll" }; - List extensionsList2 = new List { @"C:\Source2\ext1.TestAdapter.dll", @"C:\Source2\ext2.TestAdapter.dll" }; + List extensionsList1 = new() { @"C:\Source1\ext1.TestAdapter.dll", @"C:\Source1\ext2.TestAdapter.dll" }; + List extensionsList2 = new() { @"C:\Source2\ext1.TestAdapter.dll", @"C:\Source2\ext2.TestAdapter.dll" }; - this.mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList1[0])).Returns(new Version(2, 0)); - this.mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList1[1])).Returns(new Version(5, 5)); - this.mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList2[0])).Returns(new Version(2, 2)); - this.mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList2[1])).Returns(new Version(5, 0)); + _mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList1[0])).Returns(new Version(2, 0)); + _mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList1[1])).Returns(new Version(5, 5)); + _mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList2[0])).Returns(new Version(2, 2)); + _mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList2[1])).Returns(new Version(5, 0)); - this.mockFileHelper.Setup(fh => fh.EnumerateFiles(sourcesDir[0], SearchOption.TopDirectoryOnly, "TestAdapter.dll")).Returns(extensionsList1); - this.mockFileHelper.Setup(fh => fh.EnumerateFiles(sourcesDir[1], SearchOption.TopDirectoryOnly, "TestAdapter.dll")).Returns(extensionsList2); + _mockFileHelper.Setup(fh => fh.EnumerateFiles(sourcesDir[0], SearchOption.TopDirectoryOnly, "TestAdapter.dll")).Returns(extensionsList1); + _mockFileHelper.Setup(fh => fh.EnumerateFiles(sourcesDir[1], SearchOption.TopDirectoryOnly, "TestAdapter.dll")).Returns(extensionsList2); - this.testHostManager.Initialize(this.mockMessageLogger.Object, $" {Framework.DefaultFramework} "); + _testHostManager.Initialize(_mockMessageLogger.Object, $" {Framework.DefaultFramework} "); - // Act - var resultExtensions = this.testHostManager.GetTestPlatformExtensions(sources, new List()).ToList(); + // Act + var resultExtensions = _testHostManager.GetTestPlatformExtensions(sources, new List()).ToList(); - // Verify - List expectedList = new List { @"C:\Source2\ext1.TestAdapter.dll", @"C:\Source1\ext2.TestAdapter.dll" }; - CollectionAssert.AreEqual(expectedList, resultExtensions); - this.mockMessageLogger.Verify(ml => ml.SendMessage(TestMessageLevel.Warning, "Multiple versions of same extension found. Selecting the highest version." + Environment.NewLine + " ext1.TestAdapter : 2.2\n ext2.TestAdapter : 5.5"), Times.Once); - } + // Verify + List expectedList = new() { @"C:\Source2\ext1.TestAdapter.dll", @"C:\Source1\ext2.TestAdapter.dll" }; + CollectionAssert.AreEqual(expectedList, resultExtensions); + _mockMessageLogger.Verify(ml => ml.SendMessage(TestMessageLevel.Warning, "Multiple versions of same extension found. Selecting the highest version." + Environment.NewLine + " ext1.TestAdapter : 2.2\n ext2.TestAdapter : 5.5"), Times.Once); + } - [TestMethod] - [TestCategory("Windows")] - public void GetTestPlatformExtensionsShouldReturnPathTheHigherVersionedFileExtensions() - { - List sourcesDir = new List { "C:\\Source1", "C:\\Source2" }; - List sources = new List { @"C:\Source1\source1.dll", @"C:\Source2\source2.dll" }; + [TestMethod] + [TestCategory("Windows")] + public void GetTestPlatformExtensionsShouldReturnPathTheHigherVersionedFileExtensions() + { + List sourcesDir = new() { "C:\\Source1", "C:\\Source2" }; + List sources = new() { @"C:\Source1\source1.dll", @"C:\Source2\source2.dll" }; - List extensionsList1 = new List { @"C:\Source1\ext1.TestAdapter.dll" }; - List extensionsList2 = new List { @"C:\Source2\ext1.TestAdapter.dll" }; + List extensionsList1 = new() { @"C:\Source1\ext1.TestAdapter.dll" }; + List extensionsList2 = new() { @"C:\Source2\ext1.TestAdapter.dll" }; - this.mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList1[0])).Returns(new Version(2, 0)); - this.mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList2[0])).Returns(new Version(2, 2)); + _mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList1[0])).Returns(new Version(2, 0)); + _mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList2[0])).Returns(new Version(2, 2)); - this.mockFileHelper.Setup(fh => fh.EnumerateFiles(sourcesDir[0], SearchOption.TopDirectoryOnly, "TestAdapter.dll")).Returns(extensionsList1); - this.mockFileHelper.Setup(fh => fh.EnumerateFiles(sourcesDir[1], SearchOption.TopDirectoryOnly, "TestAdapter.dll")).Returns(extensionsList2); + _mockFileHelper.Setup(fh => fh.EnumerateFiles(sourcesDir[0], SearchOption.TopDirectoryOnly, "TestAdapter.dll")).Returns(extensionsList1); + _mockFileHelper.Setup(fh => fh.EnumerateFiles(sourcesDir[1], SearchOption.TopDirectoryOnly, "TestAdapter.dll")).Returns(extensionsList2); - this.testHostManager.Initialize(this.mockMessageLogger.Object, $" {Framework.DefaultFramework} "); + _testHostManager.Initialize(_mockMessageLogger.Object, $" {Framework.DefaultFramework} "); - // Act - var resultExtensions = this.testHostManager.GetTestPlatformExtensions(sources, new List()).ToList(); + // Act + var resultExtensions = _testHostManager.GetTestPlatformExtensions(sources, new List()).ToList(); - // Verify - CollectionAssert.AreEqual(extensionsList2, resultExtensions); - this.mockMessageLogger.Verify(ml => ml.SendMessage(TestMessageLevel.Warning, "Multiple versions of same extension found. Selecting the highest version." + Environment.NewLine + " ext1.TestAdapter : 2.2"), Times.Once); - } + // Verify + CollectionAssert.AreEqual(extensionsList2, resultExtensions); + _mockMessageLogger.Verify(ml => ml.SendMessage(TestMessageLevel.Warning, "Multiple versions of same extension found. Selecting the highest version." + Environment.NewLine + " ext1.TestAdapter : 2.2"), Times.Once); + } - [TestMethod] - [TestCategory("Windows")] - public void GetTestPlatformExtensionsShouldReturnPathToSingleFileExtensionOfATypeIfVersionsAreSame() - { - List sourcesDir = new List { "C:\\Source1", "C:\\Source2" }; - List sources = new List { @"C:\Source1\source1.dll", @"C:\Source2\source2.dll" }; + [TestMethod] + [TestCategory("Windows")] + public void GetTestPlatformExtensionsShouldReturnPathToSingleFileExtensionOfATypeIfVersionsAreSame() + { + List sourcesDir = new() { "C:\\Source1", "C:\\Source2" }; + List sources = new() { @"C:\Source1\source1.dll", @"C:\Source2\source2.dll" }; - List extensionsList1 = new List { @"C:\Source1\ext1.TestAdapter.dll" }; - List extensionsList2 = new List { @"C:\Source2\ext1.TestAdapter.dll" }; + List extensionsList1 = new() { @"C:\Source1\ext1.TestAdapter.dll" }; + List extensionsList2 = new() { @"C:\Source2\ext1.TestAdapter.dll" }; - this.mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList1[0])).Returns(new Version(2, 0)); - this.mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList2[0])).Returns(new Version(2, 0)); + _mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList1[0])).Returns(new Version(2, 0)); + _mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList2[0])).Returns(new Version(2, 0)); - this.mockFileHelper.Setup(fh => fh.EnumerateFiles(sourcesDir[0], SearchOption.TopDirectoryOnly, "TestAdapter.dll")).Returns(extensionsList1); - this.mockFileHelper.Setup(fh => fh.EnumerateFiles(sourcesDir[1], SearchOption.TopDirectoryOnly, "TestAdapter.dll")).Returns(extensionsList2); + _mockFileHelper.Setup(fh => fh.EnumerateFiles(sourcesDir[0], SearchOption.TopDirectoryOnly, "TestAdapter.dll")).Returns(extensionsList1); + _mockFileHelper.Setup(fh => fh.EnumerateFiles(sourcesDir[1], SearchOption.TopDirectoryOnly, "TestAdapter.dll")).Returns(extensionsList2); - this.testHostManager.Initialize(this.mockMessageLogger.Object, $" {Framework.DefaultFramework} "); + _testHostManager.Initialize(_mockMessageLogger.Object, $" {Framework.DefaultFramework} "); - // Act - var resultExtensions = this.testHostManager.GetTestPlatformExtensions(sources, new List()).ToList(); + // Act + var resultExtensions = _testHostManager.GetTestPlatformExtensions(sources, new List()).ToList(); - // Verify - CollectionAssert.AreEqual(extensionsList1, resultExtensions); - this.mockMessageLogger.Verify(ml => ml.SendMessage(TestMessageLevel.Warning, It.IsAny()), Times.Never); - } + // Verify + CollectionAssert.AreEqual(extensionsList1, resultExtensions); + _mockMessageLogger.Verify(ml => ml.SendMessage(TestMessageLevel.Warning, It.IsAny()), Times.Never); + } - [TestMethod] - public void LaunchTestHostShouldReturnTestHostProcessId() - { - this.mockProcessHelper.Setup( - ph => - ph.LaunchProcess( - It.IsAny(), - It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>(), - It.IsAny>(), - It.IsAny>())).Returns(Process.GetCurrentProcess()); + [TestMethod] + public void LaunchTestHostShouldReturnTestHostProcessId() + { + _mockProcessHelper.Setup( + ph => + ph.LaunchProcess( + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>(), + It.IsAny>(), + It.IsAny>())).Returns(Process.GetCurrentProcess()); - this.testHostManager.Initialize(this.mockMessageLogger.Object, $" {Architecture.X64} {Framework.DefaultFramework} {false} "); - var startInfo = this.testHostManager.GetTestHostProcessStartInfo(Enumerable.Empty(), null, default); + _testHostManager.Initialize(_mockMessageLogger.Object, $" {Architecture.X64} {Framework.DefaultFramework} {false} "); + var startInfo = _testHostManager.GetTestHostProcessStartInfo(Enumerable.Empty(), null, default); - this.testHostManager.HostLaunched += this.TestHostManagerHostLaunched; + _testHostManager.HostLaunched += TestHostManagerHostLaunched; - Task processId = this.testHostManager.LaunchTestHostAsync(startInfo, CancellationToken.None); - processId.Wait(); + Task processId = _testHostManager.LaunchTestHostAsync(startInfo, CancellationToken.None); + processId.Wait(); - Assert.IsTrue(processId.Result); + Assert.IsTrue(processId.Result); - Assert.AreEqual(Process.GetCurrentProcess().Id, this.testHostId); - } + Assert.AreEqual(Process.GetCurrentProcess().Id, _testHostId); + } - [TestMethod] - public void LaunchTestHostAsyncShouldNotStartHostProcessIfCancellationTokenIsSet() - { - this.testableTestHostManager = new TestableTestHostManager( - Architecture.X64, - Framework.DefaultFramework, - this.mockProcessHelper.Object, - true, - this.mockMessageLogger.Object); + [TestMethod] + public void LaunchTestHostAsyncShouldNotStartHostProcessIfCancellationTokenIsSet() + { + _testableTestHostManager = new TestableTestHostManager( + Architecture.X64, + Framework.DefaultFramework, + _mockProcessHelper.Object, + true, + _mockMessageLogger.Object); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); - cancellationTokenSource.Cancel(); + CancellationTokenSource cancellationTokenSource = new(); + cancellationTokenSource.Cancel(); - Assert.ThrowsException(() => this.testableTestHostManager.LaunchTestHostAsync(this.GetDefaultStartInfo(), cancellationTokenSource.Token).Wait()); - } + Assert.ThrowsException(() => _testableTestHostManager.LaunchTestHostAsync(GetDefaultStartInfo(), cancellationTokenSource.Token).Wait()); + } - [TestMethod] - public void PropertiesShouldReturnEmptyDictionary() - { - Assert.AreEqual(0, this.testHostManager.Properties.Count); - } + [TestMethod] + public void PropertiesShouldReturnEmptyDictionary() + { + Assert.AreEqual(0, _testHostManager.Properties.Count); + } - [TestMethod] - public void DefaultTestHostManagerShouldBeShared() - { - Assert.IsTrue(this.testHostManager.Shared); - } + [TestMethod] + public void DefaultTestHostManagerShouldBeShared() + { + Assert.IsTrue(_testHostManager.Shared); + } - [TestMethod] - public void LaunchTestHostShouldUseCustomHostIfSet() - { - var mockCustomLauncher = new Mock(); - this.testHostManager.SetCustomLauncher(mockCustomLauncher.Object); - var currentProcess = Process.GetCurrentProcess(); - mockCustomLauncher.Setup(mc => mc.LaunchTestHost(It.IsAny(), It.IsAny())).Returns(currentProcess.Id); + [TestMethod] + public void LaunchTestHostShouldUseCustomHostIfSet() + { + var mockCustomLauncher = new Mock(); + _testHostManager.SetCustomLauncher(mockCustomLauncher.Object); + var currentProcess = Process.GetCurrentProcess(); + mockCustomLauncher.Setup(mc => mc.LaunchTestHost(It.IsAny(), It.IsAny())).Returns(currentProcess.Id); - this.testHostManager.HostLaunched += this.TestHostManagerHostLaunched; + _testHostManager.HostLaunched += TestHostManagerHostLaunched; - Task pid = this.testHostManager.LaunchTestHostAsync(this.startInfo, CancellationToken.None); - pid.Wait(); - mockCustomLauncher.Verify(mc => mc.LaunchTestHost(It.IsAny(), It.IsAny()), Times.Once); + Task pid = _testHostManager.LaunchTestHostAsync(_startInfo, CancellationToken.None); + pid.Wait(); + mockCustomLauncher.Verify(mc => mc.LaunchTestHost(It.IsAny(), It.IsAny()), Times.Once); - Assert.IsTrue(pid.Result); - Assert.AreEqual(currentProcess.Id, this.testHostId); - } + Assert.IsTrue(pid.Result); + Assert.AreEqual(currentProcess.Id, _testHostId); + } - [TestMethod] - public void LaunchTestHostShouldSetExitCallbackInCaseCustomHost() - { - var mockCustomLauncher = new Mock(); - this.testHostManager.SetCustomLauncher(mockCustomLauncher.Object); - var currentProcess = Process.GetCurrentProcess(); - mockCustomLauncher.Setup(mc => mc.LaunchTestHost(It.IsAny(), It.IsAny())).Returns(currentProcess.Id); - this.testHostManager.LaunchTestHostAsync(this.startInfo, CancellationToken.None).Wait(); + [TestMethod] + public void LaunchTestHostShouldSetExitCallbackInCaseCustomHost() + { + var mockCustomLauncher = new Mock(); + _testHostManager.SetCustomLauncher(mockCustomLauncher.Object); + var currentProcess = Process.GetCurrentProcess(); + mockCustomLauncher.Setup(mc => mc.LaunchTestHost(It.IsAny(), It.IsAny())).Returns(currentProcess.Id); + _testHostManager.LaunchTestHostAsync(_startInfo, CancellationToken.None).Wait(); - this.mockProcessHelper.Verify(ph => ph.SetExitCallback(currentProcess.Id, It.IsAny>())); - } + _mockProcessHelper.Verify(ph => ph.SetExitCallback(currentProcess.Id, It.IsAny>())); + } - [TestMethod] - [TestCategory("Windows")] - public void GetTestSourcesShouldReturnAppropriateSourceIfAppxRecipeIsProvided() - { - var sourcePath = Path.Combine(Path.GetDirectoryName(typeof(TestableTestHostManager).GetTypeInfo().Assembly.GetAssemblyLocation()), @"..\..\..\..\TestAssets\UWPTestAssets\UnitTestApp8.build.appxrecipe"); - IEnumerable sources = this.testHostManager.GetTestSources(new List { sourcePath }); - Assert.IsTrue(sources.Any()); - Assert.IsTrue(sources.FirstOrDefault().EndsWith(".exe", StringComparison.OrdinalIgnoreCase)); - } + [TestMethod] + [TestCategory("Windows")] + public void GetTestSourcesShouldReturnAppropriateSourceIfAppxRecipeIsProvided() + { + var sourcePath = Path.Combine(Path.GetDirectoryName(typeof(TestableTestHostManager).GetTypeInfo().Assembly.GetAssemblyLocation()), @"..\..\..\..\TestAssets\UWPTestAssets\UnitTestApp8.build.appxrecipe"); + IEnumerable sources = _testHostManager.GetTestSources(new List { sourcePath }); + Assert.IsTrue(sources.Any()); + Assert.IsTrue(sources.FirstOrDefault().EndsWith(".exe", StringComparison.OrdinalIgnoreCase)); + } - [TestMethod] - [TestCategory("Windows")] - public void AppxManifestFileShouldReturnAppropriateSourceIfAppxManifestIsProvided() - { - var appxManifestPath = Path.Combine(Path.GetDirectoryName(typeof(TestableTestHostManager).GetTypeInfo().Assembly.GetAssemblyLocation()), @"..\..\..\..\TestAssets\UWPTestAssets\AppxManifest.xml"); - string source = AppxManifestFile.GetApplicationExecutableName(appxManifestPath); - Assert.AreEqual("UnitTestApp8.exe", source); - } + [TestMethod] + [TestCategory("Windows")] + public void AppxManifestFileShouldReturnAppropriateSourceIfAppxManifestIsProvided() + { + var appxManifestPath = Path.Combine(Path.GetDirectoryName(typeof(TestableTestHostManager).GetTypeInfo().Assembly.GetAssemblyLocation()), @"..\..\..\..\TestAssets\UWPTestAssets\AppxManifest.xml"); + string source = AppxManifestFile.GetApplicationExecutableName(appxManifestPath); + Assert.AreEqual("UnitTestApp8.exe", source); + } - [TestMethod] - public async Task ErrorMessageShouldBeReadAsynchronously() - { - string errorData = "Custom Error Strings"; - this.ErrorCallBackTestHelper(errorData, -1); + [TestMethod] + public async Task ErrorMessageShouldBeReadAsynchronously() + { + string errorData = "Custom Error Strings"; + ErrorCallBackTestHelper(errorData, -1); - await this.testableTestHostManager.LaunchTestHostAsync(this.GetDefaultStartInfo(), CancellationToken.None); + await _testableTestHostManager.LaunchTestHostAsync(GetDefaultStartInfo(), CancellationToken.None); - Assert.AreEqual(errorData, this.errorMessage); - } + Assert.AreEqual(errorData, _errorMessage); + } - [TestMethod] - public async Task NoErrorMessageIfExitCodeZero() - { - string errorData = string.Empty; - this.ErrorCallBackTestHelper(errorData, 0); + [TestMethod] + public async Task NoErrorMessageIfExitCodeZero() + { + string errorData = string.Empty; + ErrorCallBackTestHelper(errorData, 0); - await this.testableTestHostManager.LaunchTestHostAsync(this.GetDefaultStartInfo(), CancellationToken.None); + await _testableTestHostManager.LaunchTestHostAsync(GetDefaultStartInfo(), CancellationToken.None); - Assert.IsNull(this.errorMessage); - } + Assert.IsNull(_errorMessage); + } - [TestMethod] - [DataRow(null)] - [DataRow("")] - public async Task ErrorReceivedCallbackShouldNotLogNullOrEmptyData(string errorData) - { - this.ErrorCallBackTestHelper(errorData, -1); + [TestMethod] + [DataRow(null)] + [DataRow("")] + public async Task ErrorReceivedCallbackShouldNotLogNullOrEmptyData(string errorData) + { + ErrorCallBackTestHelper(errorData, -1); - await this.testableTestHostManager.LaunchTestHostAsync(this.GetDefaultStartInfo(), CancellationToken.None); + await _testableTestHostManager.LaunchTestHostAsync(GetDefaultStartInfo(), CancellationToken.None); - Assert.AreEqual(this.errorMessage, string.Empty); - } + Assert.AreEqual(_errorMessage, string.Empty); + } - [TestMethod] - [DataRow(0)] - [DataRow(-1)] - public async Task ProcessExitedButNoErrorMessageIfNoDataWritten(int exitCode) - { - this.ExitCallBackTestHelper(exitCode); + [TestMethod] + [DataRow(0)] + [DataRow(-1)] + public async Task ProcessExitedButNoErrorMessageIfNoDataWritten(int exitCode) + { + ExitCallBackTestHelper(exitCode); - await this.testableTestHostManager.LaunchTestHostAsync(this.GetDefaultStartInfo(), CancellationToken.None); + await _testableTestHostManager.LaunchTestHostAsync(GetDefaultStartInfo(), CancellationToken.None); - Assert.AreEqual(this.errorMessage, string.Empty); - Assert.AreEqual(this.exitCode, exitCode); - } + Assert.AreEqual(_errorMessage, string.Empty); + Assert.AreEqual(_exitCode, exitCode); + } - [TestMethod] - public async Task CleanTestHostAsyncShouldKillTestHostProcess() - { - var pid = Process.GetCurrentProcess().Id; - bool isVerified = false; - this.mockProcessHelper.Setup(ph => ph.TerminateProcess(It.IsAny())) - .Callback(p => isVerified = ((Process)p).Id == pid); + [TestMethod] + public async Task CleanTestHostAsyncShouldKillTestHostProcess() + { + var pid = Process.GetCurrentProcess().Id; + bool isVerified = false; + _mockProcessHelper.Setup(ph => ph.TerminateProcess(It.IsAny())) + .Callback(p => isVerified = ((Process)p).Id == pid); - this.ExitCallBackTestHelper(0); - await this.testableTestHostManager.LaunchTestHostAsync(this.GetDefaultStartInfo(), CancellationToken.None); - await this.testableTestHostManager.CleanTestHostAsync(CancellationToken.None); + ExitCallBackTestHelper(0); + await _testableTestHostManager.LaunchTestHostAsync(GetDefaultStartInfo(), CancellationToken.None); + await _testableTestHostManager.CleanTestHostAsync(CancellationToken.None); - Assert.IsTrue(isVerified); - } + Assert.IsTrue(isVerified); + } - [TestMethod] - public async Task CleanTestHostAsyncShouldNotThrowIfTestHostIsNotStarted() - { - var pid = Process.GetCurrentProcess().Id; - bool isVerified = false; - this.mockProcessHelper.Setup(ph => ph.TerminateProcess(It.IsAny())).Callback(p => isVerified = ((Process)p).Id == pid).Throws(); + [TestMethod] + public async Task CleanTestHostAsyncShouldNotThrowIfTestHostIsNotStarted() + { + var pid = Process.GetCurrentProcess().Id; + bool isVerified = false; + _mockProcessHelper.Setup(ph => ph.TerminateProcess(It.IsAny())).Callback(p => isVerified = ((Process)p).Id == pid).Throws(); - this.ExitCallBackTestHelper(0); - await this.testableTestHostManager.LaunchTestHostAsync(this.GetDefaultStartInfo(), CancellationToken.None); - await this.testableTestHostManager.CleanTestHostAsync(CancellationToken.None); + ExitCallBackTestHelper(0); + await _testableTestHostManager.LaunchTestHostAsync(GetDefaultStartInfo(), CancellationToken.None); + await _testableTestHostManager.CleanTestHostAsync(CancellationToken.None); - Assert.IsTrue(isVerified); - } + Assert.IsTrue(isVerified); + } - private void TestableTestHostManagerHostExited(object sender, HostProviderEventArgs e) - { - this.errorMessage = e.Data.TrimEnd(Environment.NewLine.ToCharArray()); - this.exitCode = e.ErrroCode; - } + private void TestableTestHostManagerHostExited(object sender, HostProviderEventArgs e) + { + _errorMessage = e.Data.TrimEnd(Environment.NewLine.ToCharArray()); + _exitCode = e.ErrroCode; + } - private void TestHostManagerHostExited(object sender, HostProviderEventArgs e) + private void TestHostManagerHostExited(object sender, HostProviderEventArgs e) + { + if (e.ErrroCode != 0) { - if (e.ErrroCode != 0) - { - this.errorMessage = e.Data.TrimEnd(Environment.NewLine.ToCharArray()); - } + _errorMessage = e.Data.TrimEnd(Environment.NewLine.ToCharArray()); } + } - private void TestHostManagerHostLaunched(object sender, HostProviderEventArgs e) - { - this.testHostId = e.ProcessId; - } + private void TestHostManagerHostLaunched(object sender, HostProviderEventArgs e) + { + _testHostId = e.ProcessId; + } - private void ErrorCallBackTestHelper(string errorMessage, int exitCode) - { - this.testableTestHostManager = new TestableTestHostManager( - Architecture.X64, - Framework.DefaultFramework, - this.mockProcessHelper.Object, - true, - this.mockMessageLogger.Object); - - this.testableTestHostManager.HostExited += this.TestHostManagerHostExited; - - this.mockProcessHelper.Setup( - ph => - ph.LaunchProcess( - It.IsAny(), - It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>(), - It.IsAny>(), - It.IsAny>())) - .Callback, Action, Action, Action>( - (var1, var2, var3, dictionary, errorCallback, exitCallback, outputCallback) => - { - var process = Process.GetCurrentProcess(); - - errorCallback(process, errorMessage); - exitCallback(process); - }).Returns(Process.GetCurrentProcess()); - - this.mockProcessHelper.Setup(ph => ph.TryGetExitCode(It.IsAny(), out exitCode)).Returns(true); - } + private void ErrorCallBackTestHelper(string errorMessage, int exitCode) + { + _testableTestHostManager = new TestableTestHostManager( + Architecture.X64, + Framework.DefaultFramework, + _mockProcessHelper.Object, + true, + _mockMessageLogger.Object); - private void ExitCallBackTestHelper(int exitCode) - { - this.testableTestHostManager = new TestableTestHostManager( - Architecture.X64, - Framework.DefaultFramework, - this.mockProcessHelper.Object, - true, - this.mockMessageLogger.Object); - - this.testableTestHostManager.HostExited += this.TestableTestHostManagerHostExited; - - this.mockProcessHelper.Setup( - ph => - ph.LaunchProcess( - It.IsAny(), - It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>(), - It.IsAny>(), - It.IsAny>())) - .Callback, Action, Action, Action>( - (var1, var2, var3, dictionary, errorCallback, exitCallback, outputCallback) => - { - var process = Process.GetCurrentProcess(); - exitCallback(process); - }).Returns(Process.GetCurrentProcess()); - - this.mockProcessHelper.Setup(ph => ph.TryGetExitCode(It.IsAny(), out exitCode)).Returns(true); - } + _testableTestHostManager.HostExited += TestHostManagerHostExited; - private TestProcessStartInfo GetDefaultStartInfo() - { - return new TestProcessStartInfo(); - } + _mockProcessHelper.Setup( + ph => + ph.LaunchProcess( + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>(), + It.IsAny>(), + It.IsAny>())) + .Callback, Action, Action, Action>( + (var1, var2, var3, dictionary, errorCallback, exitCallback, outputCallback) => + { + var process = Process.GetCurrentProcess(); + + errorCallback(process, errorMessage); + exitCallback(process); + }).Returns(Process.GetCurrentProcess()); + + _mockProcessHelper.Setup(ph => ph.TryGetExitCode(It.IsAny(), out exitCode)).Returns(true); + } + + private void ExitCallBackTestHelper(int exitCode) + { + _testableTestHostManager = new TestableTestHostManager( + Architecture.X64, + Framework.DefaultFramework, + _mockProcessHelper.Object, + true, + _mockMessageLogger.Object); + + _testableTestHostManager.HostExited += TestableTestHostManagerHostExited; + + _mockProcessHelper.Setup( + ph => + ph.LaunchProcess( + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>(), + It.IsAny>(), + It.IsAny>())) + .Callback, Action, Action, Action>( + (var1, var2, var3, dictionary, errorCallback, exitCallback, outputCallback) => + { + var process = Process.GetCurrentProcess(); + exitCallback(process); + }).Returns(Process.GetCurrentProcess()); + + _mockProcessHelper.Setup(ph => ph.TryGetExitCode(It.IsAny(), out exitCode)).Returns(true); + } - private class TestableTestHostManager : DefaultTestHostManager + private TestProcessStartInfo GetDefaultStartInfo() + { + return new TestProcessStartInfo(); + } + + private class TestableTestHostManager : DefaultTestHostManager + { + public TestableTestHostManager( + Architecture architecture, + Framework framework, + IProcessHelper processHelper, + bool shared, + IMessageLogger logger) + : base(processHelper, new FileHelper(), new PlatformEnvironment(), new DotnetHostHelper()) { - public TestableTestHostManager( - Architecture architecture, - Framework framework, - IProcessHelper processHelper, - bool shared, - IMessageLogger logger) - : base(processHelper, new FileHelper(), new PlatformEnvironment(), new DotnetHostHelper()) - { - this.Initialize(logger, $" {architecture} {framework} {!shared} "); - } + Initialize(logger, $" {architecture} {framework} {!shared} "); } } -#pragma warning restore SA1600 -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs b/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs index 1db6e0f02f..e743f5db44 100644 --- a/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs +++ b/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerTests.cs @@ -1,317 +1,317 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.TestHostProvider.UnitTests.Hosting +namespace TestPlatform.TestHostProvider.UnitTests.Hosting; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class DotnetTestHostManagerTests { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.IO; - using System.Linq; - using System.Reflection; - using System.Text; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - -#pragma warning disable SA1600 - - [TestClass] - public class DotnetTestHostManagerTests - { - private const string DefaultDotnetPath = "c:\\tmp\\dotnet.exe"; + private const string DefaultDotnetPath = "c:\\tmp\\dotnet.exe"; - private readonly Mock mockTestHostLauncher; + private readonly Mock _mockTestHostLauncher; - private readonly Mock mockProcessHelper; + private readonly Mock _mockProcessHelper; - private readonly Mock mockFileHelper; + private readonly Mock _mockFileHelper; - private readonly Mock mockWindowsRegistry; + private readonly Mock _mockWindowsRegistry; - private readonly Mock mockMessageLogger; + private readonly Mock _mockMessageLogger; - private readonly Mock mockEnvironment; + private readonly Mock _mockEnvironment; - private readonly Mock mockRunsettingHelper; + private readonly Mock _mockRunsettingHelper; - private readonly TestRunnerConnectionInfo defaultConnectionInfo; + private readonly TestRunnerConnectionInfo _defaultConnectionInfo; - private readonly string[] testSource = { "test.dll" }; + private readonly string[] _testSource = { "test.dll" }; - private readonly string defaultTestHostPath; + private readonly string _defaultTestHostPath; - private readonly TestProcessStartInfo defaultTestProcessStartInfo; + private readonly TestProcessStartInfo _defaultTestProcessStartInfo; - private readonly TestableDotnetTestHostManager dotnetHostManager; + private readonly TestableDotnetTestHostManager _dotnetHostManager; - private Mock mockEnvironmentVariable; + private readonly Mock _mockEnvironmentVariable; - private string errorMessage; + private string _errorMessage; - private int exitCode; + private int _exitCode; - private int testHostId; + private int _testHostId; - private string temp = Path.GetTempPath(); + private readonly string _temp = Path.GetTempPath(); - public DotnetTestHostManagerTests() - { - this.mockTestHostLauncher = new Mock(); - this.mockProcessHelper = new Mock(); - this.mockFileHelper = new Mock(); - this.mockMessageLogger = new Mock(); - this.mockEnvironment = new Mock(); - this.mockWindowsRegistry = new Mock(); - this.mockEnvironmentVariable = new Mock(); - this.mockRunsettingHelper = new Mock(); - this.defaultConnectionInfo = new TestRunnerConnectionInfo { Port = 123, ConnectionInfo = new TestHostConnectionInfo { Endpoint = "127.0.0.1:123", Role = ConnectionRole.Client }, RunnerProcessId = 0 }; - - this.mockEnvironment.SetupGet(e => e.Architecture).Returns((PlatformArchitecture)Enum.Parse(typeof(PlatformArchitecture), Constants.DefaultPlatform.ToString())); - this.mockRunsettingHelper.SetupGet(r => r.IsDefaultTargetArchitecture).Returns(true); - string defaultSourcePath = Path.Combine(this.temp, "test.dll"); - this.defaultTestHostPath = Path.Combine(this.temp, "testhost.dll"); - this.dotnetHostManager = new TestableDotnetTestHostManager( - this.mockProcessHelper.Object, - this.mockFileHelper.Object, - new DotnetHostHelper(this.mockFileHelper.Object, this.mockEnvironment.Object, this.mockWindowsRegistry.Object, this.mockEnvironmentVariable.Object, this.mockProcessHelper.Object), - this.mockEnvironment.Object, - this.mockRunsettingHelper.Object, - this.mockWindowsRegistry.Object, - this.mockEnvironmentVariable.Object); - this.dotnetHostManager.Initialize(this.mockMessageLogger.Object, string.Empty); - - this.dotnetHostManager.HostExited += this.DotnetHostManagerHostExited; - - // Setup a dummy current process for tests - this.mockProcessHelper.Setup(ph => ph.GetCurrentProcessFileName()).Returns(DefaultDotnetPath); - this.mockProcessHelper.Setup(ph => ph.GetTestEngineDirectory()).Returns(DefaultDotnetPath); - this.mockProcessHelper.Setup(ph => ph.GetCurrentProcessArchitecture()).Returns(PlatformArchitecture.X64); - this.mockEnvironmentVariable.Setup(ev => ev.GetEnvironmentVariable(It.IsAny())).Returns(Path.GetDirectoryName(DefaultDotnetPath)); - this.mockFileHelper.Setup(ph => ph.Exists(this.defaultTestHostPath)).Returns(true); - this.mockFileHelper.Setup(ph => ph.Exists(DefaultDotnetPath)).Returns(true); - - this.mockTestHostLauncher - .Setup(th => th.LaunchTestHost(It.IsAny(), It.IsAny())) - .Returns(Process.GetCurrentProcess().Id); - - this.mockTestHostLauncher - .Setup(th => th.LaunchTestHost(It.IsAny())) - .Returns(Process.GetCurrentProcess().Id); - - this.defaultTestProcessStartInfo = this.dotnetHostManager.GetTestHostProcessStartInfo(new[] { defaultSourcePath }, null, this.defaultConnectionInfo); - } + public DotnetTestHostManagerTests() + { + _mockTestHostLauncher = new Mock(); + _mockProcessHelper = new Mock(); + _mockFileHelper = new Mock(); + _mockMessageLogger = new Mock(); + _mockEnvironment = new Mock(); + _mockWindowsRegistry = new Mock(); + _mockEnvironmentVariable = new Mock(); + _mockRunsettingHelper = new Mock(); + _defaultConnectionInfo = new TestRunnerConnectionInfo { Port = 123, ConnectionInfo = new TestHostConnectionInfo { Endpoint = "127.0.0.1:123", Role = ConnectionRole.Client }, RunnerProcessId = 0 }; + + _mockEnvironment.SetupGet(e => e.Architecture).Returns((PlatformArchitecture)Enum.Parse(typeof(PlatformArchitecture), Constants.DefaultPlatform.ToString())); + _mockRunsettingHelper.SetupGet(r => r.IsDefaultTargetArchitecture).Returns(true); + string defaultSourcePath = Path.Combine(_temp, "test.dll"); + _defaultTestHostPath = Path.Combine(_temp, "testhost.dll"); + _dotnetHostManager = new TestableDotnetTestHostManager( + _mockProcessHelper.Object, + _mockFileHelper.Object, + new DotnetHostHelper(_mockFileHelper.Object, _mockEnvironment.Object, _mockWindowsRegistry.Object, _mockEnvironmentVariable.Object, _mockProcessHelper.Object), + _mockEnvironment.Object, + _mockRunsettingHelper.Object, + _mockWindowsRegistry.Object, + _mockEnvironmentVariable.Object); + _dotnetHostManager.Initialize(_mockMessageLogger.Object, string.Empty); + + _dotnetHostManager.HostExited += DotnetHostManagerHostExited; + + // Setup a dummy current process for tests + _mockProcessHelper.Setup(ph => ph.GetCurrentProcessFileName()).Returns(DefaultDotnetPath); + _mockProcessHelper.Setup(ph => ph.GetTestEngineDirectory()).Returns(DefaultDotnetPath); + _mockProcessHelper.Setup(ph => ph.GetCurrentProcessArchitecture()).Returns(PlatformArchitecture.X64); + _mockEnvironmentVariable.Setup(ev => ev.GetEnvironmentVariable(It.IsAny())).Returns(Path.GetDirectoryName(DefaultDotnetPath)); + _mockFileHelper.Setup(ph => ph.Exists(_defaultTestHostPath)).Returns(true); + _mockFileHelper.Setup(ph => ph.Exists(DefaultDotnetPath)).Returns(true); + + _mockTestHostLauncher + .Setup(th => th.LaunchTestHost(It.IsAny(), It.IsAny())) + .Returns(Process.GetCurrentProcess().Id); + + _mockTestHostLauncher + .Setup(th => th.LaunchTestHost(It.IsAny())) + .Returns(Process.GetCurrentProcess().Id); + + _defaultTestProcessStartInfo = _dotnetHostManager.GetTestHostProcessStartInfo(new[] { defaultSourcePath }, null, _defaultConnectionInfo); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldThrowIfSourceIsNull() - { - Action action = () => this.dotnetHostManager.GetTestHostProcessStartInfo(null, null, this.defaultConnectionInfo); + [TestMethod] + public void GetTestHostProcessStartInfoShouldThrowIfSourceIsNull() + { + Action action = () => _dotnetHostManager.GetTestHostProcessStartInfo(null, null, _defaultConnectionInfo); - Assert.ThrowsException(action); - } + Assert.ThrowsException(action); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldThrowIfMultipleSourcesAreProvided() - { - var sources = new[] { "test1.dll", "test2.dll" }; - Action action = () => this.dotnetHostManager.GetTestHostProcessStartInfo(sources, null, this.defaultConnectionInfo); + [TestMethod] + public void GetTestHostProcessStartInfoShouldThrowIfMultipleSourcesAreProvided() + { + var sources = new[] { "test1.dll", "test2.dll" }; + Action action = () => _dotnetHostManager.GetTestHostProcessStartInfo(sources, null, _defaultConnectionInfo); - Assert.ThrowsException(action); - } + Assert.ThrowsException(action); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldInvokeDotnetCommandline() - { - this.mockProcessHelper.Setup(ph => ph.GetCurrentProcessFileName()).Returns(DefaultDotnetPath); - this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); + [TestMethod] + public void GetTestHostProcessStartInfoShouldInvokeDotnetCommandline() + { + _mockProcessHelper.Setup(ph => ph.GetCurrentProcessFileName()).Returns(DefaultDotnetPath); + _mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); - var startInfo = this.GetDefaultStartInfo(); + var startInfo = GetDefaultStartInfo(); - Assert.AreEqual(DefaultDotnetPath, startInfo.FileName); - } + Assert.AreEqual(DefaultDotnetPath, startInfo.FileName); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldInvokeDotnetXPlatOnLinux() - { - this.mockProcessHelper.Setup(ph => ph.GetCurrentProcessFileName()).Returns("/tmp/dotnet"); - this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); + [TestMethod] + public void GetTestHostProcessStartInfoShouldInvokeDotnetXPlatOnLinux() + { + _mockProcessHelper.Setup(ph => ph.GetCurrentProcessFileName()).Returns("/tmp/dotnet"); + _mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); - var startInfo = this.GetDefaultStartInfo(); + var startInfo = GetDefaultStartInfo(); - Assert.AreEqual("/tmp/dotnet", startInfo.FileName); - } + Assert.AreEqual("/tmp/dotnet", startInfo.FileName); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldInvokeDotnetExec() - { - this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); - var startInfo = this.GetDefaultStartInfo(); + [TestMethod] + public void GetTestHostProcessStartInfoShouldInvokeDotnetExec() + { + _mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); + var startInfo = GetDefaultStartInfo(); - StringAssert.StartsWith(startInfo.Arguments, "exec"); - } + StringAssert.StartsWith(startInfo.Arguments, "exec"); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldAddRuntimeConfigJsonIfExists() - { - this.mockFileHelper.Setup(fh => fh.Exists("test.runtimeconfig.json")).Returns(true); - this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); + [TestMethod] + public void GetTestHostProcessStartInfoShouldAddRuntimeConfigJsonIfExists() + { + _mockFileHelper.Setup(fh => fh.Exists("test.runtimeconfig.json")).Returns(true); + _mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); - var startInfo = this.GetDefaultStartInfo(); + var startInfo = GetDefaultStartInfo(); - StringAssert.Contains(startInfo.Arguments, "--runtimeconfig \"test.runtimeconfig.json\""); - } + StringAssert.Contains(startInfo.Arguments, "--runtimeconfig \"test.runtimeconfig.json\""); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldNotAddRuntimeConfigJsonIfNotExists() - { - this.mockFileHelper.Setup(fh => fh.Exists("test.runtimeconfig.json")).Returns(false); - this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); + [TestMethod] + public void GetTestHostProcessStartInfoShouldNotAddRuntimeConfigJsonIfNotExists() + { + _mockFileHelper.Setup(fh => fh.Exists("test.runtimeconfig.json")).Returns(false); + _mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); - var startInfo = this.GetDefaultStartInfo(); + var startInfo = GetDefaultStartInfo(); - Assert.IsFalse(startInfo.Arguments.Contains("--runtimeconfig \"test.runtimeconfig.json\"")); - } + Assert.IsFalse(startInfo.Arguments.Contains("--runtimeconfig \"test.runtimeconfig.json\"")); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldAddDepsFileJsonIfExists() - { - this.mockFileHelper.Setup(fh => fh.Exists("test.deps.json")).Returns(true); - this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); + [TestMethod] + public void GetTestHostProcessStartInfoShouldAddDepsFileJsonIfExists() + { + _mockFileHelper.Setup(fh => fh.Exists("test.deps.json")).Returns(true); + _mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); - var startInfo = this.GetDefaultStartInfo(); + var startInfo = GetDefaultStartInfo(); - StringAssert.Contains(startInfo.Arguments, "--depsfile \"test.deps.json\""); - } + StringAssert.Contains(startInfo.Arguments, "--depsfile \"test.deps.json\""); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldNotAddDepsFileJsonIfNotExists() - { - this.mockFileHelper.Setup(fh => fh.Exists("test.deps.json")).Returns(false); - this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); + [TestMethod] + public void GetTestHostProcessStartInfoShouldNotAddDepsFileJsonIfNotExists() + { + _mockFileHelper.Setup(fh => fh.Exists("test.deps.json")).Returns(false); + _mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); - var startInfo = this.GetDefaultStartInfo(); + var startInfo = GetDefaultStartInfo(); - Assert.IsFalse(startInfo.Arguments.Contains("--depsfile \"test.deps.json\"")); - } + Assert.IsFalse(startInfo.Arguments.Contains("--depsfile \"test.deps.json\"")); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldIncludeConnectionInfo() - { - var connectionInfo = new TestRunnerConnectionInfo { Port = 123, ConnectionInfo = new TestHostConnectionInfo { Endpoint = "127.0.0.0:123", Role = ConnectionRole.Client, Transport = Transport.Sockets }, RunnerProcessId = 101 }; - this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); + [TestMethod] + public void GetTestHostProcessStartInfoShouldIncludeConnectionInfo() + { + var connectionInfo = new TestRunnerConnectionInfo { Port = 123, ConnectionInfo = new TestHostConnectionInfo { Endpoint = "127.0.0.0:123", Role = ConnectionRole.Client, Transport = Transport.Sockets }, RunnerProcessId = 101 }; + _mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); - var startInfo = this.dotnetHostManager.GetTestHostProcessStartInfo(this.testSource, null, connectionInfo); + var startInfo = _dotnetHostManager.GetTestHostProcessStartInfo(_testSource, null, connectionInfo); - StringAssert.Contains(startInfo.Arguments, "--port " + connectionInfo.Port + " --endpoint " + connectionInfo.ConnectionInfo.Endpoint + " --role client --parentprocessid 101"); - } + StringAssert.Contains(startInfo.Arguments, "--port " + connectionInfo.Port + " --endpoint " + connectionInfo.ConnectionInfo.Endpoint + " --role client --parentprocessid 101"); + } - [TestMethod] - public void GetTestHostConnectionInfoShouldIncludeEndpointRoleAndChannelType() - { - var connectionInfo = new TestHostConnectionInfo { Endpoint = "127.0.0.1:0", Role = ConnectionRole.Client, Transport = Transport.Sockets }; + [TestMethod] + public void GetTestHostConnectionInfoShouldIncludeEndpointRoleAndChannelType() + { + var connectionInfo = new TestHostConnectionInfo { Endpoint = "127.0.0.1:0", Role = ConnectionRole.Client, Transport = Transport.Sockets }; - var info = this.dotnetHostManager.GetTestHostConnectionInfo(); + var info = _dotnetHostManager.GetTestHostConnectionInfo(); - Assert.AreEqual(connectionInfo, info); - } + Assert.AreEqual(connectionInfo, info); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldIncludeEnvironmentVariables() - { - var environmentVariables = new Dictionary { { "k1", "v1" }, { "k2", "v2" } }; - this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); + [TestMethod] + public void GetTestHostProcessStartInfoShouldIncludeEnvironmentVariables() + { + var environmentVariables = new Dictionary { { "k1", "v1" }, { "k2", "v2" } }; + _mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); - var startInfo = this.dotnetHostManager.GetTestHostProcessStartInfo(this.testSource, environmentVariables, this.defaultConnectionInfo); + var startInfo = _dotnetHostManager.GetTestHostProcessStartInfo(_testSource, environmentVariables, _defaultConnectionInfo); - Assert.AreEqual(environmentVariables, startInfo.EnvironmentVariables); - } + Assert.AreEqual(environmentVariables, startInfo.EnvironmentVariables); + } - [TestMethod] - public void GetTestHostProcessStartIfDepsFileNotFoundAndTestHostFoundShouldNotThrowException() - { - this.mockFileHelper.Setup(fh => fh.Exists("test.deps.json")).Returns(false); - this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); + [TestMethod] + public void GetTestHostProcessStartIfDepsFileNotFoundAndTestHostFoundShouldNotThrowException() + { + _mockFileHelper.Setup(fh => fh.Exists("test.deps.json")).Returns(false); + _mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); - var startInfo = this.GetDefaultStartInfo(); - StringAssert.Contains(startInfo.Arguments, "testhost.dll"); - } + var startInfo = GetDefaultStartInfo(); + StringAssert.Contains(startInfo.Arguments, "testhost.dll"); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldUseTestHostX64ExePresentOnWindows() - { - var testhostExePath = "testhost.exe"; - this.mockFileHelper.Setup(ph => ph.Exists(testhostExePath)).Returns(true); - this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); - this.mockEnvironment.Setup(ev => ev.OperatingSystem).Returns(PlatformOperatingSystem.Windows); + [TestMethod] + public void GetTestHostProcessStartInfoShouldUseTestHostX64ExePresentOnWindows() + { + var testhostExePath = "testhost.exe"; + _mockFileHelper.Setup(ph => ph.Exists(testhostExePath)).Returns(true); + _mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); + _mockEnvironment.Setup(ev => ev.OperatingSystem).Returns(PlatformOperatingSystem.Windows); - var startInfo = this.GetDefaultStartInfo(); + var startInfo = GetDefaultStartInfo(); - StringAssert.Contains(startInfo.FileName, testhostExePath); - } + StringAssert.Contains(startInfo.FileName, testhostExePath); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldUseDotnetExeOnUnixWithTestHostDllPath() - { - this.mockFileHelper.Setup(ph => ph.Exists("testhost.x86.exe")).Returns(true); - this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); - this.mockEnvironment.Setup(ev => ev.OperatingSystem).Returns(PlatformOperatingSystem.Unix); + [TestMethod] + public void GetTestHostProcessStartInfoShouldUseDotnetExeOnUnixWithTestHostDllPath() + { + _mockFileHelper.Setup(ph => ph.Exists("testhost.x86.exe")).Returns(true); + _mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); + _mockEnvironment.Setup(ev => ev.OperatingSystem).Returns(PlatformOperatingSystem.Unix); - var startInfo = this.GetDefaultStartInfo(); + var startInfo = GetDefaultStartInfo(); - StringAssert.Contains(startInfo.FileName, "dotnet"); - StringAssert.Contains(startInfo.Arguments, "testhost.dll"); - } + StringAssert.Contains(startInfo.FileName, "dotnet"); + StringAssert.Contains(startInfo.Arguments, "testhost.dll"); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldUseTestHostExeIfPresentOnWindows() - { - var testhostExePath = "testhost.exe"; - this.mockFileHelper.Setup(ph => ph.Exists(testhostExePath)).Returns(true); - this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); - this.mockEnvironment.Setup(ev => ev.OperatingSystem).Returns(PlatformOperatingSystem.Windows); + [TestMethod] + public void GetTestHostProcessStartInfoShouldUseTestHostExeIfPresentOnWindows() + { + var testhostExePath = "testhost.exe"; + _mockFileHelper.Setup(ph => ph.Exists(testhostExePath)).Returns(true); + _mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); + _mockEnvironment.Setup(ev => ev.OperatingSystem).Returns(PlatformOperatingSystem.Windows); - this.dotnetHostManager.Initialize(this.mockMessageLogger.Object, "x64"); - var startInfo = this.GetDefaultStartInfo(); + _dotnetHostManager.Initialize(_mockMessageLogger.Object, "x64"); + var startInfo = GetDefaultStartInfo(); - StringAssert.Contains(startInfo.FileName, testhostExePath); - } + StringAssert.Contains(startInfo.FileName, testhostExePath); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldUseDotnetHostPathFromRunsettings() - { - var dotnetHostPath = @"C:\dotnet.exe"; - this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); - this.mockEnvironment.Setup(ev => ev.OperatingSystem).Returns(PlatformOperatingSystem.Windows); - this.dotnetHostManager.Initialize(this.mockMessageLogger.Object, $"{dotnetHostPath}"); - var startInfo = this.GetDefaultStartInfo(); + [TestMethod] + public void GetTestHostProcessStartInfoShouldUseDotnetHostPathFromRunsettings() + { + var dotnetHostPath = @"C:\dotnet.exe"; + _mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); + _mockEnvironment.Setup(ev => ev.OperatingSystem).Returns(PlatformOperatingSystem.Windows); + _dotnetHostManager.Initialize(_mockMessageLogger.Object, $"{dotnetHostPath}"); + var startInfo = GetDefaultStartInfo(); - StringAssert.Contains(startInfo.FileName, dotnetHostPath); - } + StringAssert.Contains(startInfo.FileName, dotnetHostPath); + } - [TestMethod] - [TestCategory("Windows")] - public void GetTestHostProcessStartInfoShouldUseTestHostExeFromNugetIfNotFoundInSourceLocation() - { - var testhostExePath = "testhost.exe"; - this.dotnetHostManager.Initialize(this.mockMessageLogger.Object, "x64"); - this.mockFileHelper.Setup(ph => ph.Exists(testhostExePath)).Returns(false); - this.mockFileHelper.Setup(ph => ph.Exists("C:\\packages\\microsoft.testplatform.testhost\\15.0.0-Dev\\build\\netcoreapp2.1\\x64\\testhost.exe")).Returns(true); - this.mockEnvironment.Setup(ev => ev.OperatingSystem).Returns(PlatformOperatingSystem.Windows); - var sourcePath = Path.Combine(this.temp, "test.dll"); - - string runtimeConfigFileContent = -@"{ + [TestMethod] + [TestCategory("Windows")] + public void GetTestHostProcessStartInfoShouldUseTestHostExeFromNugetIfNotFoundInSourceLocation() + { + var testhostExePath = "testhost.exe"; + _dotnetHostManager.Initialize(_mockMessageLogger.Object, "x64"); + _mockFileHelper.Setup(ph => ph.Exists(testhostExePath)).Returns(false); + _mockFileHelper.Setup(ph => ph.Exists("C:\\packages\\microsoft.testplatform.testhost\\15.0.0-Dev\\build\\netcoreapp2.1\\x64\\testhost.exe")).Returns(true); + _mockEnvironment.Setup(ev => ev.OperatingSystem).Returns(PlatformOperatingSystem.Windows); + var sourcePath = Path.Combine(_temp, "test.dll"); + + string runtimeConfigFileContent = + @"{ ""runtimeOptions"": { ""additionalProbingPaths"": [ ""C:\\packages"" @@ -319,8 +319,8 @@ public void GetTestHostProcessStartInfoShouldUseTestHostExeFromNugetIfNotFoundIn } }"; - string depsFileContent = -@"{ + string depsFileContent = + @"{ ""runtimeTarget"": { ""name"": "".NETCoreApp,Version=v1.0"", ""signature"": ""8f25843f8e35a3e80ef4ae98b95117ea5c468b3f"" @@ -353,35 +353,35 @@ public void GetTestHostProcessStartInfoShouldUseTestHostExeFromNugetIfNotFoundIn } }"; - MemoryStream runtimeConfigStream = new MemoryStream(Encoding.UTF8.GetBytes(runtimeConfigFileContent)); - this.mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(this.temp, "test.runtimeconfig.dev.json"), FileMode.Open, FileAccess.Read)).Returns(runtimeConfigStream); - this.mockFileHelper.Setup(ph => ph.Exists(Path.Combine(this.temp, "test.runtimeconfig.dev.json"))).Returns(true); + MemoryStream runtimeConfigStream = new(Encoding.UTF8.GetBytes(runtimeConfigFileContent)); + _mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(_temp, "test.runtimeconfig.dev.json"), FileMode.Open, FileAccess.Read)).Returns(runtimeConfigStream); + _mockFileHelper.Setup(ph => ph.Exists(Path.Combine(_temp, "test.runtimeconfig.dev.json"))).Returns(true); - MemoryStream depsFileStream = new MemoryStream(Encoding.UTF8.GetBytes(depsFileContent)); - this.mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(this.temp, "test.deps.json"), FileMode.Open, FileAccess.Read)).Returns(depsFileStream); - this.mockFileHelper.Setup(ph => ph.Exists(Path.Combine(this.temp, "test.deps.json"))).Returns(true); + MemoryStream depsFileStream = new(Encoding.UTF8.GetBytes(depsFileContent)); + _mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(_temp, "test.deps.json"), FileMode.Open, FileAccess.Read)).Returns(depsFileStream); + _mockFileHelper.Setup(ph => ph.Exists(Path.Combine(_temp, "test.deps.json"))).Returns(true); - string testHostFullPath = @"C:\packages\microsoft.testplatform.testhost/15.0.0-Dev\lib/netstandard1.5/testhost.dll"; - this.mockFileHelper.Setup(ph => ph.Exists(testHostFullPath)).Returns(true); + string testHostFullPath = @"C:\packages\microsoft.testplatform.testhost/15.0.0-Dev\lib/netstandard1.5/testhost.dll"; + _mockFileHelper.Setup(ph => ph.Exists(testHostFullPath)).Returns(true); - var startInfo = this.dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, this.defaultConnectionInfo); + var startInfo = _dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, _defaultConnectionInfo); - StringAssert.Contains(startInfo.FileName, "C:\\packages\\microsoft.testplatform.testhost\\15.0.0-Dev\\build\\netcoreapp2.1\\x64\\testhost.exe"); - } + StringAssert.Contains(startInfo.FileName, "C:\\packages\\microsoft.testplatform.testhost\\15.0.0-Dev\\build\\netcoreapp2.1\\x64\\testhost.exe"); + } - [TestMethod] - [TestCategory("Windows")] - public void GetTestHostProcessStartInfoShouldUseTestHostX86ExeFromNugetIfNotFoundInSourceLocation() - { - var testhostExePath = "testhost.x86.exe"; - this.dotnetHostManager.Initialize(this.mockMessageLogger.Object, "x86"); - this.mockFileHelper.Setup(ph => ph.Exists(testhostExePath)).Returns(false); - this.mockFileHelper.Setup(ph => ph.Exists($"C:\\packages{Path.DirectorySeparatorChar}microsoft.testplatform.testhost\\15.0.0-Dev{Path.DirectorySeparatorChar}build\\netcoreapp2.1\\x86\\testhost.x86.exe")).Returns(true); - this.mockEnvironment.Setup(ev => ev.OperatingSystem).Returns(PlatformOperatingSystem.Windows); - var sourcePath = Path.Combine(this.temp, "test.dll"); - - string runtimeConfigFileContent = -@"{ + [TestMethod] + [TestCategory("Windows")] + public void GetTestHostProcessStartInfoShouldUseTestHostX86ExeFromNugetIfNotFoundInSourceLocation() + { + var testhostExePath = "testhost.x86.exe"; + _dotnetHostManager.Initialize(_mockMessageLogger.Object, "x86"); + _mockFileHelper.Setup(ph => ph.Exists(testhostExePath)).Returns(false); + _mockFileHelper.Setup(ph => ph.Exists($"C:\\packages{Path.DirectorySeparatorChar}microsoft.testplatform.testhost\\15.0.0-Dev{Path.DirectorySeparatorChar}build\\netcoreapp2.1\\x86\\testhost.x86.exe")).Returns(true); + _mockEnvironment.Setup(ev => ev.OperatingSystem).Returns(PlatformOperatingSystem.Windows); + var sourcePath = Path.Combine(_temp, "test.dll"); + + string runtimeConfigFileContent = + @"{ ""runtimeOptions"": { ""additionalProbingPaths"": [ ""C:\\packages"" @@ -389,8 +389,8 @@ public void GetTestHostProcessStartInfoShouldUseTestHostX86ExeFromNugetIfNotFoun } }"; - string depsFileContent = -@"{ + string depsFileContent = + @"{ ""runtimeTarget"": { ""name"": "".NETCoreApp,Version=v1.0"", ""signature"": ""8f25843f8e35a3e80ef4ae98b95117ea5c468b3f"" @@ -423,274 +423,274 @@ public void GetTestHostProcessStartInfoShouldUseTestHostX86ExeFromNugetIfNotFoun } }"; - MemoryStream runtimeConfigStream = new MemoryStream(Encoding.UTF8.GetBytes(runtimeConfigFileContent)); - this.mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(this.temp, "test.runtimeconfig.dev.json"), FileMode.Open, FileAccess.Read)).Returns(runtimeConfigStream); - this.mockFileHelper.Setup(ph => ph.Exists(Path.Combine(this.temp, "test.runtimeconfig.dev.json"))).Returns(true); + MemoryStream runtimeConfigStream = new(Encoding.UTF8.GetBytes(runtimeConfigFileContent)); + _mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(_temp, "test.runtimeconfig.dev.json"), FileMode.Open, FileAccess.Read)).Returns(runtimeConfigStream); + _mockFileHelper.Setup(ph => ph.Exists(Path.Combine(_temp, "test.runtimeconfig.dev.json"))).Returns(true); - MemoryStream depsFileStream = new MemoryStream(Encoding.UTF8.GetBytes(depsFileContent)); - this.mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(this.temp, "test.deps.json"), FileMode.Open, FileAccess.Read)).Returns(depsFileStream); - this.mockFileHelper.Setup(ph => ph.Exists(Path.Combine(this.temp, "test.deps.json"))).Returns(true); + MemoryStream depsFileStream = new(Encoding.UTF8.GetBytes(depsFileContent)); + _mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(_temp, "test.deps.json"), FileMode.Open, FileAccess.Read)).Returns(depsFileStream); + _mockFileHelper.Setup(ph => ph.Exists(Path.Combine(_temp, "test.deps.json"))).Returns(true); - string testHostFullPath = $@"C:\packages{Path.DirectorySeparatorChar}microsoft.testplatform.testhost/15.0.0-Dev{Path.DirectorySeparatorChar}lib/netstandard1.5/testhost.dll"; - this.mockFileHelper.Setup(ph => ph.Exists(testHostFullPath)).Returns(true); + string testHostFullPath = $@"C:\packages{Path.DirectorySeparatorChar}microsoft.testplatform.testhost/15.0.0-Dev{Path.DirectorySeparatorChar}lib/netstandard1.5/testhost.dll"; + _mockFileHelper.Setup(ph => ph.Exists(testHostFullPath)).Returns(true); - var startInfo = this.dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, this.defaultConnectionInfo); + var startInfo = _dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, _defaultConnectionInfo); - StringAssert.Contains(startInfo.FileName, "C:\\packages\\microsoft.testplatform.testhost\\15.0.0-Dev\\build\\netcoreapp2.1\\x86\\testhost.x86.exe"); - } + StringAssert.Contains(startInfo.FileName, "C:\\packages\\microsoft.testplatform.testhost\\15.0.0-Dev\\build\\netcoreapp2.1\\x86\\testhost.x86.exe"); + } - [TestMethod] - public void LaunchTestHostShouldLaunchProcessWithNullEnvironmentVariablesOrArgs() - { - var expectedProcessId = Process.GetCurrentProcess().Id; - this.mockTestHostLauncher.Setup(thl => thl.LaunchTestHost(It.IsAny(), It.IsAny())).Returns(expectedProcessId); - this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); - var startInfo = this.GetDefaultStartInfo(); - this.dotnetHostManager.SetCustomLauncher(this.mockTestHostLauncher.Object); + [TestMethod] + public void LaunchTestHostShouldLaunchProcessWithNullEnvironmentVariablesOrArgs() + { + var expectedProcessId = Process.GetCurrentProcess().Id; + _mockTestHostLauncher.Setup(thl => thl.LaunchTestHost(It.IsAny(), It.IsAny())).Returns(expectedProcessId); + _mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); + var startInfo = GetDefaultStartInfo(); + _dotnetHostManager.SetCustomLauncher(_mockTestHostLauncher.Object); - this.dotnetHostManager.HostLaunched += this.DotnetHostManagerHostLaunched; + _dotnetHostManager.HostLaunched += DotnetHostManagerHostLaunched; - Task processId = this.dotnetHostManager.LaunchTestHostAsync(startInfo, CancellationToken.None); - processId.Wait(); + Task processId = _dotnetHostManager.LaunchTestHostAsync(startInfo, CancellationToken.None); + processId.Wait(); - Assert.IsTrue(processId.Result); - Assert.AreEqual(expectedProcessId, this.testHostId); - } + Assert.IsTrue(processId.Result); + Assert.AreEqual(expectedProcessId, _testHostId); + } - [TestMethod] - public void LaunchTestHostAsyncShouldNotStartHostProcessIfCancellationTokenIsSet() - { - var expectedProcessId = Process.GetCurrentProcess().Id; - this.mockTestHostLauncher.Setup(thl => thl.LaunchTestHost(It.IsAny())).Returns(expectedProcessId); - this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); - var startInfo = this.GetDefaultStartInfo(); + [TestMethod] + public void LaunchTestHostAsyncShouldNotStartHostProcessIfCancellationTokenIsSet() + { + var expectedProcessId = Process.GetCurrentProcess().Id; + _mockTestHostLauncher.Setup(thl => thl.LaunchTestHost(It.IsAny())).Returns(expectedProcessId); + _mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); + var startInfo = GetDefaultStartInfo(); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); - cancellationTokenSource.Cancel(); + CancellationTokenSource cancellationTokenSource = new(); + cancellationTokenSource.Cancel(); - Assert.ThrowsException(() => this.dotnetHostManager.LaunchTestHostAsync(startInfo, cancellationTokenSource.Token).Wait()); - } + Assert.ThrowsException(() => _dotnetHostManager.LaunchTestHostAsync(startInfo, cancellationTokenSource.Token).Wait()); + } - [TestMethod] - public void LaunchTestHostShouldLaunchProcessWithEnvironmentVariables() - { - var variables = new Dictionary { { "k1", "v1" }, { "k2", "v2" } }; - var startInfo = new TestProcessStartInfo { EnvironmentVariables = variables }; - this.dotnetHostManager.SetCustomLauncher(this.mockTestHostLauncher.Object); + [TestMethod] + public void LaunchTestHostShouldLaunchProcessWithEnvironmentVariables() + { + var variables = new Dictionary { { "k1", "v1" }, { "k2", "v2" } }; + var startInfo = new TestProcessStartInfo { EnvironmentVariables = variables }; + _dotnetHostManager.SetCustomLauncher(_mockTestHostLauncher.Object); - this.dotnetHostManager.HostLaunched += this.DotnetHostManagerHostLaunched; + _dotnetHostManager.HostLaunched += DotnetHostManagerHostLaunched; - Task processId = this.dotnetHostManager.LaunchTestHostAsync(startInfo, CancellationToken.None); - processId.Wait(); + Task processId = _dotnetHostManager.LaunchTestHostAsync(startInfo, CancellationToken.None); + processId.Wait(); - Assert.IsTrue(processId.Result); - this.mockTestHostLauncher.Verify(thl => thl.LaunchTestHost(It.Is(x => x.EnvironmentVariables.Equals(variables)), It.IsAny()), Times.Once); - } + Assert.IsTrue(processId.Result); + _mockTestHostLauncher.Verify(thl => thl.LaunchTestHost(It.Is(x => x.EnvironmentVariables.Equals(variables)), It.IsAny()), Times.Once); + } - [TestMethod] - public void DotnetTestHostManagerShouldNotBeShared() - { - Assert.IsFalse(this.dotnetHostManager.Shared); - } + [TestMethod] + public void DotnetTestHostManagerShouldNotBeShared() + { + Assert.IsFalse(_dotnetHostManager.Shared); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldThrowExceptionWhenDotnetIsNotInstalled() + [TestMethod] + public void GetTestHostProcessStartInfoShouldThrowExceptionWhenDotnetIsNotInstalled() + { + // To validate the else part, set current process to exe other than dotnet + _mockProcessHelper.Setup(ph => ph.GetCurrentProcessFileName()).Returns("vstest.console.exe"); + + // Reset the muxer + _mockEnvironmentVariable.Setup(ev => ev.GetEnvironmentVariable(It.IsAny())).Returns(string.Empty); + + char separator = ';'; + var dotnetExeName = "dotnet.exe"; + if (!Environment.OSVersion.Platform.ToString().StartsWith("Win")) { - // To validate the else part, set current process to exe other than dotnet - this.mockProcessHelper.Setup(ph => ph.GetCurrentProcessFileName()).Returns("vstest.console.exe"); - - // Reset the muxer - this.mockEnvironmentVariable.Setup(ev => ev.GetEnvironmentVariable(It.IsAny())).Returns(string.Empty); - - char separator = ';'; - var dotnetExeName = "dotnet.exe"; - if (!System.Environment.OSVersion.Platform.ToString().StartsWith("Win")) - { - separator = ':'; - dotnetExeName = "dotnet"; - } + separator = ':'; + dotnetExeName = "dotnet"; + } - var paths = Environment.GetEnvironmentVariable("PATH").Split(separator); + var paths = Environment.GetEnvironmentVariable("PATH").Split(separator); - foreach (string path in paths) - { - string dotnetExeFullPath = Path.Combine(path.Trim(), dotnetExeName); - this.mockFileHelper.Setup(fh => fh.Exists(dotnetExeFullPath)).Returns(false); - } + foreach (string path in paths) + { + string dotnetExeFullPath = Path.Combine(path.Trim(), dotnetExeName); + _mockFileHelper.Setup(fh => fh.Exists(dotnetExeFullPath)).Returns(false); + } - this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); + _mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); - Action action = () => this.GetDefaultStartInfo(); + Action action = () => GetDefaultStartInfo(); - Assert.ThrowsException(action); - } + Assert.ThrowsException(action); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldIncludeSourceDirectoryAsWorkingDirectory() - { - // Absolute path to the source directory - var sourcePath = Path.Combine(this.temp, "test.dll"); - this.mockFileHelper.Setup(ph => ph.Exists(Path.Combine(this.temp, "testhost.dll"))).Returns(true); - var startInfo = this.dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, this.defaultConnectionInfo); + [TestMethod] + public void GetTestHostProcessStartInfoShouldIncludeSourceDirectoryAsWorkingDirectory() + { + // Absolute path to the source directory + var sourcePath = Path.Combine(_temp, "test.dll"); + _mockFileHelper.Setup(ph => ph.Exists(Path.Combine(_temp, "testhost.dll"))).Returns(true); + var startInfo = _dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, _defaultConnectionInfo); - Assert.AreEqual(Path.GetDirectoryName(this.temp), startInfo.WorkingDirectory); - } + Assert.AreEqual(Path.GetDirectoryName(_temp), startInfo.WorkingDirectory); + } - [TestMethod] - public void GetTestPlatformExtensionsShouldReturnEmptySetIfSourceDirectoryDoesNotExist() - { - this.mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(false); - var extensions = this.dotnetHostManager.GetTestPlatformExtensions(new[] { $".{Path.DirectorySeparatorChar}foo.dll" }, Enumerable.Empty()); + [TestMethod] + public void GetTestPlatformExtensionsShouldReturnEmptySetIfSourceDirectoryDoesNotExist() + { + _mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(false); + var extensions = _dotnetHostManager.GetTestPlatformExtensions(new[] { $".{Path.DirectorySeparatorChar}foo.dll" }, Enumerable.Empty()); - Assert.AreEqual(0, extensions.Count()); - } + Assert.AreEqual(0, extensions.Count()); + } - [TestMethod] - public void GetTestPlatformExtensionsShouldReturnLibariesFromSourceDirectory() - { - this.mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); - this.mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny(), SearchOption.TopDirectoryOnly, It.IsAny())).Returns(new[] { "foo.TestAdapter.dll" }); - var extensions = this.dotnetHostManager.GetTestPlatformExtensions(new[] { $".{Path.DirectorySeparatorChar}foo.dll" }, Enumerable.Empty()); + [TestMethod] + public void GetTestPlatformExtensionsShouldReturnLibariesFromSourceDirectory() + { + _mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); + _mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny(), SearchOption.TopDirectoryOnly, It.IsAny())).Returns(new[] { "foo.TestAdapter.dll" }); + var extensions = _dotnetHostManager.GetTestPlatformExtensions(new[] { $".{Path.DirectorySeparatorChar}foo.dll" }, Enumerable.Empty()); - CollectionAssert.AreEqual(new[] { "foo.TestAdapter.dll" }, extensions.ToArray()); - } + CollectionAssert.AreEqual(new[] { "foo.TestAdapter.dll" }, extensions.ToArray()); + } - [TestMethod] - public void GetTestPlatformExtensionsShouldReturnEmptySetIfSourceDirectoryIsEmpty() - { - // Parent directory is empty since the input source is file "test.dll" - this.mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); - this.mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny(), SearchOption.TopDirectoryOnly, It.IsAny())).Returns(new[] { "foo.dll" }); - var extensions = this.dotnetHostManager.GetTestPlatformExtensions(this.testSource, Enumerable.Empty()); + [TestMethod] + public void GetTestPlatformExtensionsShouldReturnEmptySetIfSourceDirectoryIsEmpty() + { + // Parent directory is empty since the input source is file "test.dll" + _mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); + _mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny(), SearchOption.TopDirectoryOnly, It.IsAny())).Returns(new[] { "foo.dll" }); + var extensions = _dotnetHostManager.GetTestPlatformExtensions(_testSource, Enumerable.Empty()); - Assert.AreEqual(0, extensions.Count()); - } + Assert.AreEqual(0, extensions.Count()); + } - [TestMethod] - public void GetTestPlatformExtensionsShouldNotAddNonCoverletDataCollectorsExtensionsIfPresent() - { - this.mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); - this.mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny(), SearchOption.TopDirectoryOnly, It.IsAny())).Returns(new[] { "foo.dll" }); - var extensions = this.dotnetHostManager.GetTestPlatformExtensions(this.testSource, new List { "abc.dataollector.dll" }); + [TestMethod] + public void GetTestPlatformExtensionsShouldNotAddNonCoverletDataCollectorsExtensionsIfPresent() + { + _mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); + _mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny(), SearchOption.TopDirectoryOnly, It.IsAny())).Returns(new[] { "foo.dll" }); + var extensions = _dotnetHostManager.GetTestPlatformExtensions(_testSource, new List { "abc.dataollector.dll" }); - Assert.AreEqual(0, extensions.Count()); - } + Assert.AreEqual(0, extensions.Count()); + } - [TestMethod] - public async Task LaunchTestHostShouldLaunchProcessWithConnectionInfo() - { - var expectedArgs = "exec \"" + this.defaultTestHostPath + "\" --port 123 --endpoint 127.0.0.1:123 --role client --parentprocessid 0"; - this.dotnetHostManager.SetCustomLauncher(this.mockTestHostLauncher.Object); - await this.dotnetHostManager.LaunchTestHostAsync(this.defaultTestProcessStartInfo, CancellationToken.None); + [TestMethod] + public async Task LaunchTestHostShouldLaunchProcessWithConnectionInfo() + { + var expectedArgs = "exec \"" + _defaultTestHostPath + "\" --port 123 --endpoint 127.0.0.1:123 --role client --parentprocessid 0"; + _dotnetHostManager.SetCustomLauncher(_mockTestHostLauncher.Object); + await _dotnetHostManager.LaunchTestHostAsync(_defaultTestProcessStartInfo, CancellationToken.None); - this.mockTestHostLauncher.Verify(thl => thl.LaunchTestHost(It.Is(x => x.Arguments.Equals(expectedArgs)), It.IsAny()), Times.Once); - } + _mockTestHostLauncher.Verify(thl => thl.LaunchTestHost(It.Is(x => x.Arguments.Equals(expectedArgs)), It.IsAny()), Times.Once); + } - [TestMethod] - public void LaunchTestHostShouldSetExitCallBackInCaseCustomHost() - { - var expectedProcessId = Process.GetCurrentProcess().Id; - this.mockTestHostLauncher.Setup(thl => thl.LaunchTestHost(It.IsAny(), It.IsAny())).Returns(expectedProcessId); - this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); + [TestMethod] + public void LaunchTestHostShouldSetExitCallBackInCaseCustomHost() + { + var expectedProcessId = Process.GetCurrentProcess().Id; + _mockTestHostLauncher.Setup(thl => thl.LaunchTestHost(It.IsAny(), It.IsAny())).Returns(expectedProcessId); + _mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); - var startInfo = this.GetDefaultStartInfo(); - this.dotnetHostManager.SetCustomLauncher(this.mockTestHostLauncher.Object); - this.dotnetHostManager.LaunchTestHostAsync(startInfo, CancellationToken.None).Wait(); + var startInfo = GetDefaultStartInfo(); + _dotnetHostManager.SetCustomLauncher(_mockTestHostLauncher.Object); + _dotnetHostManager.LaunchTestHostAsync(startInfo, CancellationToken.None).Wait(); - this.mockProcessHelper.Verify(ph => ph.SetExitCallback(expectedProcessId, It.IsAny>())); - } + _mockProcessHelper.Verify(ph => ph.SetExitCallback(expectedProcessId, It.IsAny>())); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldIncludeTestHostPathFromSourceDirectoryIfDepsFileNotFound() - { - // Absolute path to the source directory - var sourcePath = Path.Combine(this.temp, "test.dll"); - string expectedTestHostPath = Path.Combine(this.temp, "testhost.dll"); - this.mockFileHelper.Setup(ph => ph.Exists(expectedTestHostPath)).Returns(true); - this.mockFileHelper.Setup(ph => ph.Exists(Path.Combine(this.temp, "test.runtimeconfig.dev.json"))).Returns(true); + [TestMethod] + public void GetTestHostProcessStartInfoShouldIncludeTestHostPathFromSourceDirectoryIfDepsFileNotFound() + { + // Absolute path to the source directory + var sourcePath = Path.Combine(_temp, "test.dll"); + string expectedTestHostPath = Path.Combine(_temp, "testhost.dll"); + _mockFileHelper.Setup(ph => ph.Exists(expectedTestHostPath)).Returns(true); + _mockFileHelper.Setup(ph => ph.Exists(Path.Combine(_temp, "test.runtimeconfig.dev.json"))).Returns(true); - var startInfo = this.dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, this.defaultConnectionInfo); + var startInfo = _dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, _defaultConnectionInfo); - StringAssert.Contains(startInfo.Arguments, expectedTestHostPath); - } + StringAssert.Contains(startInfo.Arguments, expectedTestHostPath); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldIncludeTestHostPathNextToTestRunnerIfTesthostDllIsNoFoundAndDepsFileNotFound() - { - // Absolute path to the source directory - var sourcePath = Path.Combine(this.temp, "test.dll"); - string testhostNextToTestDll = Path.Combine(this.temp, "testhost.dll"); - this.mockFileHelper.Setup(ph => ph.Exists(testhostNextToTestDll)).Returns(false); - - var here = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); - var expectedTestHostPath = Path.Combine(here, "testhost.dll"); - this.mockFileHelper.Setup(ph => ph.Exists(expectedTestHostPath)).Returns(true); - - var startInfo = this.dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, this.defaultConnectionInfo); - - StringAssert.Contains(startInfo.Arguments, expectedTestHostPath); - var expectedAdditionalDepsPath = Path.Combine(here, "testhost.deps.json"); - StringAssert.Contains(startInfo.Arguments, $"--additional-deps \"{expectedAdditionalDepsPath}\""); - var expectedAdditionalProbingPath = here; - StringAssert.Contains(startInfo.Arguments, $"--additionalprobingpath \"{expectedAdditionalProbingPath}\""); - var expectedRuntimeConfigPath = Path.Combine(here, "testhost-latest.runtimeconfig.json"); - StringAssert.Contains(startInfo.Arguments, $"--runtimeconfig \"{expectedRuntimeConfigPath}\""); - } + [TestMethod] + public void GetTestHostProcessStartInfoShouldIncludeTestHostPathNextToTestRunnerIfTesthostDllIsNoFoundAndDepsFileNotFound() + { + // Absolute path to the source directory + var sourcePath = Path.Combine(_temp, "test.dll"); + string testhostNextToTestDll = Path.Combine(_temp, "testhost.dll"); + _mockFileHelper.Setup(ph => ph.Exists(testhostNextToTestDll)).Returns(false); + + var here = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + var expectedTestHostPath = Path.Combine(here, "testhost.dll"); + _mockFileHelper.Setup(ph => ph.Exists(expectedTestHostPath)).Returns(true); + + var startInfo = _dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, _defaultConnectionInfo); + + StringAssert.Contains(startInfo.Arguments, expectedTestHostPath); + var expectedAdditionalDepsPath = Path.Combine(here, "testhost.deps.json"); + StringAssert.Contains(startInfo.Arguments, $"--additional-deps \"{expectedAdditionalDepsPath}\""); + var expectedAdditionalProbingPath = here; + StringAssert.Contains(startInfo.Arguments, $"--additionalprobingpath \"{expectedAdditionalProbingPath}\""); + var expectedRuntimeConfigPath = Path.Combine(here, "testhost-latest.runtimeconfig.json"); + StringAssert.Contains(startInfo.Arguments, $"--runtimeconfig \"{expectedRuntimeConfigPath}\""); + } - [TestMethod] - - // we can't put in a "default" value, and we don't have other way to determine if this provided value is the - // runtime default or the actual value that user provided, so right now the default will use the latest, instead - // or the more correct 1.0, it should be okay, as that version is not supported anymore anyway - [DataRow("netcoreapp1.0", "latest")] - [DataRow("netcoreapp2.1", "2.1")] - [DataRow("netcoreapp3.1", "3.1")] - [DataRow("net5.0", "5.0")] - - // net6.0 is currently the latest released version, but it still has it's own runtime config, it is not the same as - // "latest" which means the latest you have on system. So if you have only 5.0 SDK then net6.0 will fail because it can't find net6.0, - // but latest would use net5.0 because that is the latest one on your system. - [DataRow("net6.0", "6.0")] - public void GetTestHostProcessStartInfoShouldIncludeTestHostPathNextToTestRunnerIfTesthostDllIsNoFoundAndDepsFileNotFoundWithTheCorrectTfm(string tfm, string suffix) - { - // Absolute path to the source directory - var sourcePath = Path.Combine(this.temp, "test.dll"); - string testhostNextToTestDll = Path.Combine(this.temp, "testhost.dll"); - this.mockFileHelper.Setup(ph => ph.Exists(testhostNextToTestDll)).Returns(false); + [TestMethod] + + // we can't put in a "default" value, and we don't have other way to determine if this provided value is the + // runtime default or the actual value that user provided, so right now the default will use the latest, instead + // or the more correct 1.0, it should be okay, as that version is not supported anymore anyway + [DataRow("netcoreapp1.0", "latest")] + [DataRow("netcoreapp2.1", "2.1")] + [DataRow("netcoreapp3.1", "3.1")] + [DataRow("net5.0", "5.0")] + + // net6.0 is currently the latest released version, but it still has it's own runtime config, it is not the same as + // "latest" which means the latest you have on system. So if you have only 5.0 SDK then net6.0 will fail because it can't find net6.0, + // but latest would use net5.0 because that is the latest one on your system. + [DataRow("net6.0", "6.0")] + public void GetTestHostProcessStartInfoShouldIncludeTestHostPathNextToTestRunnerIfTesthostDllIsNoFoundAndDepsFileNotFoundWithTheCorrectTfm(string tfm, string suffix) + { + // Absolute path to the source directory + var sourcePath = Path.Combine(_temp, "test.dll"); + string testhostNextToTestDll = Path.Combine(_temp, "testhost.dll"); + _mockFileHelper.Setup(ph => ph.Exists(testhostNextToTestDll)).Returns(false); - var here = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); - var testhostNextToRunner = Path.Combine(here, "testhost.dll"); - this.mockFileHelper.Setup(ph => ph.Exists(testhostNextToRunner)).Returns(true); + var here = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + var testhostNextToRunner = Path.Combine(here, "testhost.dll"); + _mockFileHelper.Setup(ph => ph.Exists(testhostNextToRunner)).Returns(true); - this.dotnetHostManager.Initialize(this.mockMessageLogger.Object, $"{tfm}"); - var startInfo = this.dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, this.defaultConnectionInfo); + _dotnetHostManager.Initialize(_mockMessageLogger.Object, $"{tfm}"); + var startInfo = _dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, _defaultConnectionInfo); - var expectedRuntimeConfigPath = Path.Combine(here, $"testhost-{suffix}.runtimeconfig.json"); - StringAssert.Contains(startInfo.Arguments, $"--runtimeconfig \"{expectedRuntimeConfigPath}\""); - } + var expectedRuntimeConfigPath = Path.Combine(here, $"testhost-{suffix}.runtimeconfig.json"); + StringAssert.Contains(startInfo.Arguments, $"--runtimeconfig \"{expectedRuntimeConfigPath}\""); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldIncludeTestHostPathFromSourceDirectoryIfRunConfigDevFileNotFound() - { - // Absolute path to the source directory - var sourcePath = Path.Combine(this.temp, "test.dll"); - string expectedTestHostPath = Path.Combine(this.temp, "testhost.dll"); - this.mockFileHelper.Setup(ph => ph.Exists(expectedTestHostPath)).Returns(true); - this.mockFileHelper.Setup(ph => ph.Exists(Path.Combine(this.temp, "test.deps.json"))).Returns(true); + [TestMethod] + public void GetTestHostProcessStartInfoShouldIncludeTestHostPathFromSourceDirectoryIfRunConfigDevFileNotFound() + { + // Absolute path to the source directory + var sourcePath = Path.Combine(_temp, "test.dll"); + string expectedTestHostPath = Path.Combine(_temp, "testhost.dll"); + _mockFileHelper.Setup(ph => ph.Exists(expectedTestHostPath)).Returns(true); + _mockFileHelper.Setup(ph => ph.Exists(Path.Combine(_temp, "test.deps.json"))).Returns(true); - var startInfo = this.dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, this.defaultConnectionInfo); + var startInfo = _dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, _defaultConnectionInfo); - Assert.IsTrue(startInfo.Arguments.Contains(expectedTestHostPath)); - } + Assert.IsTrue(startInfo.Arguments.Contains(expectedTestHostPath)); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldIncludeTestHostPathFromDepsFile() - { - // Absolute path to the source directory - var sourcePath = Path.Combine(this.temp, "test.dll"); + [TestMethod] + public void GetTestHostProcessStartInfoShouldIncludeTestHostPathFromDepsFile() + { + // Absolute path to the source directory + var sourcePath = Path.Combine(_temp, "test.dll"); - string runtimeConfigFileContent = -@"{ + string runtimeConfigFileContent = + @"{ ""runtimeOptions"": { ""additionalProbingPaths"": [ ""C:\\packages"" @@ -698,8 +698,8 @@ public void GetTestHostProcessStartInfoShouldIncludeTestHostPathFromDepsFile() } }"; - string depsFileContent = -@"{ + string depsFileContent = + @"{ ""runtimeTarget"": { ""name"": "".NETCoreApp,Version=v1.0"", ""signature"": ""8f25843f8e35a3e80ef4ae98b95117ea5c468b3f"" @@ -732,30 +732,30 @@ public void GetTestHostProcessStartInfoShouldIncludeTestHostPathFromDepsFile() } }"; - MemoryStream runtimeConfigStream = new MemoryStream(Encoding.UTF8.GetBytes(runtimeConfigFileContent)); - this.mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(this.temp, "test.runtimeconfig.dev.json"), FileMode.Open, FileAccess.Read)).Returns(runtimeConfigStream); - this.mockFileHelper.Setup(ph => ph.Exists(Path.Combine(this.temp, "test.runtimeconfig.dev.json"))).Returns(true); + MemoryStream runtimeConfigStream = new(Encoding.UTF8.GetBytes(runtimeConfigFileContent)); + _mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(_temp, "test.runtimeconfig.dev.json"), FileMode.Open, FileAccess.Read)).Returns(runtimeConfigStream); + _mockFileHelper.Setup(ph => ph.Exists(Path.Combine(_temp, "test.runtimeconfig.dev.json"))).Returns(true); - MemoryStream depsFileStream = new MemoryStream(Encoding.UTF8.GetBytes(depsFileContent)); - this.mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(this.temp, "test.deps.json"), FileMode.Open, FileAccess.Read)).Returns(depsFileStream); - this.mockFileHelper.Setup(ph => ph.Exists(Path.Combine(this.temp, "test.deps.json"))).Returns(true); + MemoryStream depsFileStream = new(Encoding.UTF8.GetBytes(depsFileContent)); + _mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(_temp, "test.deps.json"), FileMode.Open, FileAccess.Read)).Returns(depsFileStream); + _mockFileHelper.Setup(ph => ph.Exists(Path.Combine(_temp, "test.deps.json"))).Returns(true); - string testHostFullPath = $@"C:\packages{Path.DirectorySeparatorChar}microsoft.testplatform.testhost/15.0.0-Dev{Path.DirectorySeparatorChar}lib/netstandard1.5/testhost.dll"; - this.mockFileHelper.Setup(ph => ph.Exists(testHostFullPath)).Returns(true); + string testHostFullPath = $@"C:\packages{Path.DirectorySeparatorChar}microsoft.testplatform.testhost/15.0.0-Dev{Path.DirectorySeparatorChar}lib/netstandard1.5/testhost.dll"; + _mockFileHelper.Setup(ph => ph.Exists(testHostFullPath)).Returns(true); - var startInfo = this.dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, this.defaultConnectionInfo); + var startInfo = _dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, _defaultConnectionInfo); - Assert.IsTrue(startInfo.Arguments.Contains(testHostFullPath)); - } + Assert.IsTrue(startInfo.Arguments.Contains(testHostFullPath)); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldIncludeTestHostPathFromSourceDirectoryIfNugetpathDoesntExist() - { - // Absolute path to the source directory - var sourcePath = Path.Combine(this.temp, "test.dll"); + [TestMethod] + public void GetTestHostProcessStartInfoShouldIncludeTestHostPathFromSourceDirectoryIfNugetpathDoesntExist() + { + // Absolute path to the source directory + var sourcePath = Path.Combine(_temp, "test.dll"); - string runtimeConfigFileContent = -@"{ + string runtimeConfigFileContent = + @"{ ""runtimeOptions"": { ""additionalProbingPaths"": [ ""C:\\packages"" @@ -763,8 +763,8 @@ public void GetTestHostProcessStartInfoShouldIncludeTestHostPathFromSourceDirect } }"; - string depsFileContent = -@"{ + string depsFileContent = + @"{ ""runtimeTarget"": { ""name"": "".NETCoreApp,Version=v1.0"", ""signature"": ""8f25843f8e35a3e80ef4ae98b95117ea5c468b3f"" @@ -797,32 +797,32 @@ public void GetTestHostProcessStartInfoShouldIncludeTestHostPathFromSourceDirect } }"; - MemoryStream runtimeConfigStream = new MemoryStream(Encoding.UTF8.GetBytes(runtimeConfigFileContent)); - this.mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(this.temp, "test.runtimeconfig.dev.json"), FileMode.Open, FileAccess.Read)).Returns(runtimeConfigStream); - this.mockFileHelper.Setup(ph => ph.Exists(Path.Combine(this.temp, "test.runtimeconfig.dev.json"))).Returns(true); + MemoryStream runtimeConfigStream = new(Encoding.UTF8.GetBytes(runtimeConfigFileContent)); + _mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(_temp, "test.runtimeconfig.dev.json"), FileMode.Open, FileAccess.Read)).Returns(runtimeConfigStream); + _mockFileHelper.Setup(ph => ph.Exists(Path.Combine(_temp, "test.runtimeconfig.dev.json"))).Returns(true); - MemoryStream depsFileStream = new MemoryStream(Encoding.UTF8.GetBytes(depsFileContent)); - this.mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(this.temp, "test.deps.json"), FileMode.Open, FileAccess.Read)).Returns(depsFileStream); - this.mockFileHelper.Setup(ph => ph.Exists(Path.Combine(this.temp, "test.deps.json"))).Returns(true); + MemoryStream depsFileStream = new(Encoding.UTF8.GetBytes(depsFileContent)); + _mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(_temp, "test.deps.json"), FileMode.Open, FileAccess.Read)).Returns(depsFileStream); + _mockFileHelper.Setup(ph => ph.Exists(Path.Combine(_temp, "test.deps.json"))).Returns(true); - string testHostFullPath = $@"C:\packages{Path.DirectorySeparatorChar}microsoft.testplatform.testhost/15.0.0-Dev{Path.DirectorySeparatorChar}lib/netstandard1.5/testhost.dll"; - this.mockFileHelper.Setup(ph => ph.Exists(testHostFullPath)).Returns(false); + string testHostFullPath = $@"C:\packages{Path.DirectorySeparatorChar}microsoft.testplatform.testhost/15.0.0-Dev{Path.DirectorySeparatorChar}lib/netstandard1.5/testhost.dll"; + _mockFileHelper.Setup(ph => ph.Exists(testHostFullPath)).Returns(false); - string testHostPath = Path.Combine(this.temp, "testhost.dll"); + string testHostPath = Path.Combine(_temp, "testhost.dll"); - var startInfo = this.dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, this.defaultConnectionInfo); + var startInfo = _dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, _defaultConnectionInfo); - Assert.IsTrue(startInfo.Arguments.Contains(testHostPath)); - } + Assert.IsTrue(startInfo.Arguments.Contains(testHostPath)); + } - [TestMethod] - public void GetTestHostProcessStartInfoShouldSkipInvalidAdditionalProbingPaths() - { - // Absolute path to the source directory - var sourcePath = Path.Combine(this.temp, "test.dll"); + [TestMethod] + public void GetTestHostProcessStartInfoShouldSkipInvalidAdditionalProbingPaths() + { + // Absolute path to the source directory + var sourcePath = Path.Combine(_temp, "test.dll"); - string runtimeConfigFileContent = -@"{ + string runtimeConfigFileContent = + @"{ ""runtimeOptions"": { ""additionalProbingPaths"": [ ""C:\\Users\\bob\\.dotnet\\store\\|arch|\\|tfm|"", @@ -831,8 +831,8 @@ public void GetTestHostProcessStartInfoShouldSkipInvalidAdditionalProbingPaths() } }"; - string depsFileContent = -@"{ + string depsFileContent = + @"{ ""runtimeTarget"": { ""name"": "".NETCoreApp,Version=v1.0"", ""signature"": ""8f25843f8e35a3e80ef4ae98b95117ea5c468b3f"" @@ -865,217 +865,215 @@ public void GetTestHostProcessStartInfoShouldSkipInvalidAdditionalProbingPaths() } }"; - MemoryStream runtimeConfigStream = new MemoryStream(Encoding.UTF8.GetBytes(runtimeConfigFileContent)); - this.mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(this.temp, "test.runtimeconfig.dev.json"), FileMode.Open, FileAccess.Read)).Returns(runtimeConfigStream); - this.mockFileHelper.Setup(ph => ph.Exists(Path.Combine(this.temp, "test.runtimeconfig.dev.json"))).Returns(true); + MemoryStream runtimeConfigStream = new(Encoding.UTF8.GetBytes(runtimeConfigFileContent)); + _mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(_temp, "test.runtimeconfig.dev.json"), FileMode.Open, FileAccess.Read)).Returns(runtimeConfigStream); + _mockFileHelper.Setup(ph => ph.Exists(Path.Combine(_temp, "test.runtimeconfig.dev.json"))).Returns(true); - MemoryStream depsFileStream = new MemoryStream(Encoding.UTF8.GetBytes(depsFileContent)); - this.mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(this.temp, "test.deps.json"), FileMode.Open, FileAccess.Read)).Returns(depsFileStream); - this.mockFileHelper.Setup(ph => ph.Exists(Path.Combine(this.temp, "test.deps.json"))).Returns(true); + MemoryStream depsFileStream = new(Encoding.UTF8.GetBytes(depsFileContent)); + _mockFileHelper.Setup(ph => ph.GetStream(Path.Combine(_temp, "test.deps.json"), FileMode.Open, FileAccess.Read)).Returns(depsFileStream); + _mockFileHelper.Setup(ph => ph.Exists(Path.Combine(_temp, "test.deps.json"))).Returns(true); - string testHostFullPath = $@"C:\packages{Path.DirectorySeparatorChar}microsoft.testplatform.testhost/15.0.0-Dev{Path.DirectorySeparatorChar}lib/netstandard1.5/testhost.dll"; - this.mockFileHelper.Setup(ph => ph.Exists(testHostFullPath)).Returns(true); + string testHostFullPath = $@"C:\packages{Path.DirectorySeparatorChar}microsoft.testplatform.testhost/15.0.0-Dev{Path.DirectorySeparatorChar}lib/netstandard1.5/testhost.dll"; + _mockFileHelper.Setup(ph => ph.Exists(testHostFullPath)).Returns(true); - var startInfo = this.dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, this.defaultConnectionInfo); + var startInfo = _dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, _defaultConnectionInfo); - Assert.IsTrue(startInfo.Arguments.Contains(testHostFullPath)); - } + Assert.IsTrue(startInfo.Arguments.Contains(testHostFullPath)); + } + + [TestMethod] + [DataRow("DOTNET_ROOT(x86)", "x86")] + [DataRow("DOTNET_ROOT", "x64")] + [DataRow("DOTNET_ROOT_WRONG", "")] + [TestCategory("Windows")] + public void GetTestHostProcessStartInfoShouldForwardDOTNET_ROOTEnvVarsForAppHost(string envVar, string expectedValue) + { + _mockFileHelper.Setup(ph => ph.Exists("testhost.exe")).Returns(true); + _mockEnvironment.Setup(ev => ev.OperatingSystem).Returns(PlatformOperatingSystem.Windows); + _mockEnvironmentVariable.Reset(); + _mockEnvironmentVariable.Setup(x => x.GetEnvironmentVariable($"VSTEST_WINAPPHOST_{envVar}")).Returns(expectedValue); - [TestMethod] - [DataRow("DOTNET_ROOT(x86)", "x86")] - [DataRow("DOTNET_ROOT", "x64")] - [DataRow("DOTNET_ROOT_WRONG", "")] - [TestCategory("Windows")] - public void GetTestHostProcessStartInfoShouldForwardDOTNET_ROOTEnvVarsForAppHost(string envVar, string expectedValue) + var startInfo = _dotnetHostManager.GetTestHostProcessStartInfo(_testSource, null, _defaultConnectionInfo); + if (!string.IsNullOrEmpty(expectedValue)) { - this.mockFileHelper.Setup(ph => ph.Exists("testhost.exe")).Returns(true); - this.mockEnvironment.Setup(ev => ev.OperatingSystem).Returns(PlatformOperatingSystem.Windows); - this.mockEnvironmentVariable.Reset(); - this.mockEnvironmentVariable.Setup(x => x.GetEnvironmentVariable($"VSTEST_WINAPPHOST_{envVar}")).Returns(expectedValue); - - var startInfo = this.dotnetHostManager.GetTestHostProcessStartInfo(this.testSource, null, this.defaultConnectionInfo); - if (!string.IsNullOrEmpty(expectedValue)) - { - Assert.AreEqual(1, startInfo.EnvironmentVariables.Count); - Assert.IsNotNull(startInfo.EnvironmentVariables[envVar]); - Assert.AreEqual(startInfo.EnvironmentVariables[envVar], expectedValue); - } - else - { - Assert.AreEqual(0, startInfo.EnvironmentVariables.Count); - } + Assert.AreEqual(1, startInfo.EnvironmentVariables.Count); + Assert.IsNotNull(startInfo.EnvironmentVariables[envVar]); + Assert.AreEqual(startInfo.EnvironmentVariables[envVar], expectedValue); } - - [TestMethod] - public async Task DotNetCoreErrorMessageShouldBeReadAsynchronouslyAsync() + else { - var errorData = "Custom Error Strings"; - this.ErrorCallBackTestHelper(errorData, -1); + Assert.AreEqual(0, startInfo.EnvironmentVariables.Count); + } + } - await this.dotnetHostManager.LaunchTestHostAsync(this.defaultTestProcessStartInfo, CancellationToken.None); + [TestMethod] + public async Task DotNetCoreErrorMessageShouldBeReadAsynchronouslyAsync() + { + var errorData = "Custom Error Strings"; + ErrorCallBackTestHelper(errorData, -1); - Assert.AreEqual(errorData, this.errorMessage); - } + await _dotnetHostManager.LaunchTestHostAsync(_defaultTestProcessStartInfo, CancellationToken.None); - [TestMethod] - public async Task DotNetCoreNoErrorMessageIfExitCodeZero() - { - string errorData = string.Empty; - this.ErrorCallBackTestHelper(errorData, 0); + Assert.AreEqual(errorData, _errorMessage); + } - await this.dotnetHostManager.LaunchTestHostAsync(this.defaultTestProcessStartInfo, CancellationToken.None); + [TestMethod] + public async Task DotNetCoreNoErrorMessageIfExitCodeZero() + { + string errorData = string.Empty; + ErrorCallBackTestHelper(errorData, 0); - Assert.IsNull(this.errorMessage); - } + await _dotnetHostManager.LaunchTestHostAsync(_defaultTestProcessStartInfo, CancellationToken.None); - [TestMethod] - [DataRow(null)] - [DataRow("")] - public async Task DotNetCoreErrorReceivedCallbackShouldNotLogNullOrEmptyData(string errorData) - { - this.ErrorCallBackTestHelper(errorData, -1); + Assert.IsNull(_errorMessage); + } - await this.dotnetHostManager.LaunchTestHostAsync(this.defaultTestProcessStartInfo, CancellationToken.None); + [TestMethod] + [DataRow(null)] + [DataRow("")] + public async Task DotNetCoreErrorReceivedCallbackShouldNotLogNullOrEmptyData(string errorData) + { + ErrorCallBackTestHelper(errorData, -1); - Assert.AreEqual(this.errorMessage, string.Empty); - } + await _dotnetHostManager.LaunchTestHostAsync(_defaultTestProcessStartInfo, CancellationToken.None); - [TestMethod] - [DataRow(0)] - [DataRow(-1)] - public async Task DotNetCoreProcessExitedButNoErrorMessageIfNoDataWritten(int exitCode) - { - var errorData = string.Empty; - this.ExitCallBackTestHelper(exitCode); + Assert.AreEqual(_errorMessage, string.Empty); + } - // override event listener - this.dotnetHostManager.HostExited += this.DotnetHostManagerExitCodeTesterHostExited; + [TestMethod] + [DataRow(0)] + [DataRow(-1)] + public async Task DotNetCoreProcessExitedButNoErrorMessageIfNoDataWritten(int exitCode) + { + var errorData = string.Empty; + ExitCallBackTestHelper(exitCode); - await this.dotnetHostManager.LaunchTestHostAsync(this.defaultTestProcessStartInfo, CancellationToken.None); + // override event listener + _dotnetHostManager.HostExited += DotnetHostManagerExitCodeTesterHostExited; - Assert.AreEqual(this.errorMessage, string.Empty); - Assert.AreEqual(this.exitCode, exitCode); - } + await _dotnetHostManager.LaunchTestHostAsync(_defaultTestProcessStartInfo, CancellationToken.None); - [TestMethod] - public async Task CleanTestHostAsyncShouldKillTestHostProcess() - { - var pid = Process.GetCurrentProcess().Id; - bool isVerified = false; - this.mockProcessHelper.Setup(ph => ph.TerminateProcess(It.IsAny())) - .Callback(p => isVerified = ((Process)p).Id == pid); + Assert.AreEqual(_errorMessage, string.Empty); + Assert.AreEqual(_exitCode, exitCode); + } - this.ExitCallBackTestHelper(0); - await this.dotnetHostManager.LaunchTestHostAsync(this.defaultTestProcessStartInfo, CancellationToken.None); + [TestMethod] + public async Task CleanTestHostAsyncShouldKillTestHostProcess() + { + var pid = Process.GetCurrentProcess().Id; + bool isVerified = false; + _mockProcessHelper.Setup(ph => ph.TerminateProcess(It.IsAny())) + .Callback(p => isVerified = ((Process)p).Id == pid); - await this.dotnetHostManager.CleanTestHostAsync(CancellationToken.None); + ExitCallBackTestHelper(0); + await _dotnetHostManager.LaunchTestHostAsync(_defaultTestProcessStartInfo, CancellationToken.None); - Assert.IsTrue(isVerified); - } + await _dotnetHostManager.CleanTestHostAsync(CancellationToken.None); - [TestMethod] - public async Task CleanTestHostAsyncShouldNotThrowIfTestHostIsNotStarted() - { - var pid = Process.GetCurrentProcess().Id; - bool isVerified = false; - this.mockProcessHelper.Setup(ph => ph.TerminateProcess(It.IsAny())).Callback(p => isVerified = ((Process)p).Id == pid).Throws(); + Assert.IsTrue(isVerified); + } - this.ExitCallBackTestHelper(0); - await this.dotnetHostManager.LaunchTestHostAsync(this.defaultTestProcessStartInfo, CancellationToken.None); + [TestMethod] + public async Task CleanTestHostAsyncShouldNotThrowIfTestHostIsNotStarted() + { + var pid = Process.GetCurrentProcess().Id; + bool isVerified = false; + _mockProcessHelper.Setup(ph => ph.TerminateProcess(It.IsAny())).Callback(p => isVerified = ((Process)p).Id == pid).Throws(); - await this.dotnetHostManager.CleanTestHostAsync(CancellationToken.None); + ExitCallBackTestHelper(0); + await _dotnetHostManager.LaunchTestHostAsync(_defaultTestProcessStartInfo, CancellationToken.None); - Assert.IsTrue(isVerified); - } + await _dotnetHostManager.CleanTestHostAsync(CancellationToken.None); - private void DotnetHostManagerExitCodeTesterHostExited(object sender, HostProviderEventArgs e) - { - this.errorMessage = e.Data.TrimEnd(Environment.NewLine.ToCharArray()); - this.exitCode = e.ErrroCode; - } + Assert.IsTrue(isVerified); + } - private void DotnetHostManagerHostExited(object sender, HostProviderEventArgs e) - { - if (e.ErrroCode != 0) - { - this.errorMessage = e.Data.TrimEnd(Environment.NewLine.ToCharArray()); - } - } + private void DotnetHostManagerExitCodeTesterHostExited(object sender, HostProviderEventArgs e) + { + _errorMessage = e.Data.TrimEnd(Environment.NewLine.ToCharArray()); + _exitCode = e.ErrroCode; + } - private void DotnetHostManagerHostLaunched(object sender, HostProviderEventArgs e) + private void DotnetHostManagerHostExited(object sender, HostProviderEventArgs e) + { + if (e.ErrroCode != 0) { - this.testHostId = e.ProcessId; + _errorMessage = e.Data.TrimEnd(Environment.NewLine.ToCharArray()); } + } - private void ErrorCallBackTestHelper(string errorMessage, int exitCode) - { - this.mockProcessHelper.Setup( - ph => - ph.LaunchProcess( - It.IsAny(), - It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>(), - It.IsAny>(), - It.IsAny>())) - .Callback, Action, Action, Action>( - (var1, var2, var3, dictionary, errorCallback, exitCallback, outputCallback) => - { - var process = Process.GetCurrentProcess(); - - errorCallback(process, errorMessage); - exitCallback(process); - }).Returns(Process.GetCurrentProcess()); - - this.mockProcessHelper.Setup(ph => ph.TryGetExitCode(It.IsAny(), out exitCode)).Returns(true); - } + private void DotnetHostManagerHostLaunched(object sender, HostProviderEventArgs e) + { + _testHostId = e.ProcessId; + } - private void ExitCallBackTestHelper(int exitCode) - { - this.mockProcessHelper.Setup( - ph => - ph.LaunchProcess( - It.IsAny(), - It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>(), - It.IsAny>(), - It.IsAny>())) - .Callback, Action, Action, Action>( - (var1, var2, var3, dictionary, errorCallback, exitCallback, outputCallback) => - { - var process = Process.GetCurrentProcess(); - exitCallback(process); - }).Returns(Process.GetCurrentProcess()); - - this.mockProcessHelper.Setup(ph => ph.TryGetExitCode(It.IsAny(), out exitCode)).Returns(true); - } + private void ErrorCallBackTestHelper(string errorMessage, int exitCode) + { + _mockProcessHelper.Setup( + ph => + ph.LaunchProcess( + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>(), + It.IsAny>(), + It.IsAny>())) + .Callback, Action, Action, Action>( + (var1, var2, var3, dictionary, errorCallback, exitCallback, outputCallback) => + { + var process = Process.GetCurrentProcess(); + + errorCallback(process, errorMessage); + exitCallback(process); + }).Returns(Process.GetCurrentProcess()); + + _mockProcessHelper.Setup(ph => ph.TryGetExitCode(It.IsAny(), out exitCode)).Returns(true); + } - private TestProcessStartInfo GetDefaultStartInfo() - { - var startInfo = this.dotnetHostManager.GetTestHostProcessStartInfo( - this.testSource, - null, - this.defaultConnectionInfo); - return startInfo; - } + private void ExitCallBackTestHelper(int exitCode) + { + _mockProcessHelper.Setup( + ph => + ph.LaunchProcess( + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>(), + It.IsAny>(), + It.IsAny>())) + .Callback, Action, Action, Action>( + (var1, var2, var3, dictionary, errorCallback, exitCallback, outputCallback) => + { + var process = Process.GetCurrentProcess(); + exitCallback(process); + }).Returns(Process.GetCurrentProcess()); + + _mockProcessHelper.Setup(ph => ph.TryGetExitCode(It.IsAny(), out exitCode)).Returns(true); + } + + private TestProcessStartInfo GetDefaultStartInfo() + { + var startInfo = _dotnetHostManager.GetTestHostProcessStartInfo( + _testSource, + null, + _defaultConnectionInfo); + return startInfo; + } - internal class TestableDotnetTestHostManager : DotnetTestHostManager + internal class TestableDotnetTestHostManager : DotnetTestHostManager + { + public TestableDotnetTestHostManager( + IProcessHelper processHelper, + IFileHelper fileHelper, + IDotnetHostHelper dotnetTestHostHelper, + IEnvironment environment, + IRunSettingsHelper runsettingsHelper, + IWindowsRegistryHelper windowsRegistryHelper, + IEnvironmentVariableHelper environmentVariableHelper) + : base(processHelper, fileHelper, dotnetTestHostHelper, environment, runsettingsHelper, windowsRegistryHelper, environmentVariableHelper) { - public TestableDotnetTestHostManager( - IProcessHelper processHelper, - IFileHelper fileHelper, - IDotnetHostHelper dotnetTestHostHelper, - IEnvironment environment, - IRunSettingsHelper runsettingsHelper, - IWindowsRegistryHelper windowsRegistryHelper, - IEnvironmentVariableHelper environmentVariableHelper) - : base(processHelper, fileHelper, dotnetTestHostHelper, environment, runsettingsHelper, windowsRegistryHelper, environmentVariableHelper) - { - } } } -#pragma warning restore SA1600 -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/TestHostManagerCallbacksTests.cs b/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/TestHostManagerCallbacksTests.cs index 98e8f2d9cf..c6694d482e 100644 --- a/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/TestHostManagerCallbacksTests.cs +++ b/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/TestHostManagerCallbacksTests.cs @@ -1,97 +1,97 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.TestHostProvider.Hosting.UnitTests +namespace TestPlatform.TestHostProvider.Hosting.UnitTests; + +using System; +using System.Text; + +using Microsoft.TestPlatform.TestHostProvider.Hosting; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class TestHostManagerCallbacksTests { - using System; - using System.Text; - using Microsoft.TestPlatform.TestHostProvider.Hosting; - using Microsoft.VisualStudio.TestTools.UnitTesting; + private StringBuilder _testHostProcessStdError; + + public TestHostManagerCallbacksTests() + { + _testHostProcessStdError = new StringBuilder(0, Microsoft.VisualStudio.TestPlatform.CoreUtilities.Constants.StandardErrorMaxLength); + } + + [TestMethod] + public void ErrorReceivedCallbackShouldAppendNoDataOnNullDataReceived() + { + _testHostProcessStdError.Append("NoDataShouldAppend"); + TestHostManagerCallbacks.ErrorReceivedCallback(_testHostProcessStdError, null); + + Assert.AreEqual("NoDataShouldAppend", _testHostProcessStdError.ToString()); + } + + [TestMethod] + public void ErrorReceivedCallbackShouldAppendNoDataOnEmptyDataReceived() + { + _testHostProcessStdError.Append("NoDataShouldAppend"); + TestHostManagerCallbacks.ErrorReceivedCallback(_testHostProcessStdError, string.Empty); + + Assert.AreEqual("NoDataShouldAppend", _testHostProcessStdError.ToString()); + } + + [TestMethod] + public void ErrorReceivedCallbackShouldAppendWhiteSpaceString() + { + _testHostProcessStdError.Append("OldData"); + TestHostManagerCallbacks.ErrorReceivedCallback(_testHostProcessStdError, " "); + + Assert.AreEqual("OldData " + Environment.NewLine, _testHostProcessStdError.ToString()); + } - [TestClass] - public class TestHostManagerCallbacksTests + [TestMethod] + public void ErrorReceivedCallbackShouldAppendGivenData() { - private StringBuilder testHostProcessStdError; - - public TestHostManagerCallbacksTests() - { - this.testHostProcessStdError = new StringBuilder(0, Microsoft.VisualStudio.TestPlatform.CoreUtilities.Constants.StandardErrorMaxLength); - } - - [TestMethod] - public void ErrorReceivedCallbackShouldAppendNoDataOnNullDataReceived() - { - this.testHostProcessStdError.Append("NoDataShouldAppend"); - TestHostManagerCallbacks.ErrorReceivedCallback(this.testHostProcessStdError, null); - - Assert.AreEqual("NoDataShouldAppend", this.testHostProcessStdError.ToString()); - } - - [TestMethod] - public void ErrorReceivedCallbackShouldAppendNoDataOnEmptyDataReceived() - { - this.testHostProcessStdError.Append("NoDataShouldAppend"); - TestHostManagerCallbacks.ErrorReceivedCallback(this.testHostProcessStdError, string.Empty); - - Assert.AreEqual("NoDataShouldAppend", this.testHostProcessStdError.ToString()); - } - - [TestMethod] - public void ErrorReceivedCallbackShouldAppendWhiteSpaceString() - { - this.testHostProcessStdError.Append("OldData"); - TestHostManagerCallbacks.ErrorReceivedCallback(this.testHostProcessStdError, " "); - - Assert.AreEqual("OldData " + Environment.NewLine, this.testHostProcessStdError.ToString()); - } - - [TestMethod] - public void ErrorReceivedCallbackShouldAppendGivenData() - { - this.testHostProcessStdError.Append("NoDataShouldAppend"); - TestHostManagerCallbacks.ErrorReceivedCallback(this.testHostProcessStdError, "new data"); - - Assert.AreEqual("NoDataShouldAppendnew data" + Environment.NewLine, this.testHostProcessStdError.ToString()); - } - - [TestMethod] - public void ErrorReceivedCallbackShouldNotAppendNewDataIfErrorMessageAlreadyReachedMaxLength() - { - this.testHostProcessStdError = new StringBuilder(0, 5); - this.testHostProcessStdError.Append("12345"); - TestHostManagerCallbacks.ErrorReceivedCallback(this.testHostProcessStdError, "678"); - - Assert.AreEqual("12345", this.testHostProcessStdError.ToString()); - } - - [TestMethod] - public void ErrorReceivedCallbackShouldAppendSubStringOfDataIfErrorMessageReachedMaxLength() - { - this.testHostProcessStdError = new StringBuilder(0, 5); - this.testHostProcessStdError.Append("1234"); - TestHostManagerCallbacks.ErrorReceivedCallback(this.testHostProcessStdError, "5678"); - - Assert.AreEqual("12345", this.testHostProcessStdError.ToString()); - } - - [TestMethod] - public void ErrorReceivedCallbackShouldAppendEntireStringEvenItReachesToMaxLength() - { - this.testHostProcessStdError = new StringBuilder(0, 5); - this.testHostProcessStdError.Append("12"); - TestHostManagerCallbacks.ErrorReceivedCallback(this.testHostProcessStdError, "3"); - - Assert.AreEqual("123" + Environment.NewLine, this.testHostProcessStdError.ToString()); - } - - [TestMethod] - public void ErrorReceivedCallbackShouldAppendNewLineApproprioritlyWhenReachingMaxLength() - { - this.testHostProcessStdError = new StringBuilder(0, 5); - this.testHostProcessStdError.Append("123"); - TestHostManagerCallbacks.ErrorReceivedCallback(this.testHostProcessStdError, "4"); - - Assert.AreEqual("1234" + Environment.NewLine.Substring(0, 1), this.testHostProcessStdError.ToString()); - } + _testHostProcessStdError.Append("NoDataShouldAppend"); + TestHostManagerCallbacks.ErrorReceivedCallback(_testHostProcessStdError, "new data"); + + Assert.AreEqual("NoDataShouldAppendnew data" + Environment.NewLine, _testHostProcessStdError.ToString()); + } + + [TestMethod] + public void ErrorReceivedCallbackShouldNotAppendNewDataIfErrorMessageAlreadyReachedMaxLength() + { + _testHostProcessStdError = new StringBuilder(0, 5); + _testHostProcessStdError.Append("12345"); + TestHostManagerCallbacks.ErrorReceivedCallback(_testHostProcessStdError, "678"); + + Assert.AreEqual("12345", _testHostProcessStdError.ToString()); + } + + [TestMethod] + public void ErrorReceivedCallbackShouldAppendSubStringOfDataIfErrorMessageReachedMaxLength() + { + _testHostProcessStdError = new StringBuilder(0, 5); + _testHostProcessStdError.Append("1234"); + TestHostManagerCallbacks.ErrorReceivedCallback(_testHostProcessStdError, "5678"); + + Assert.AreEqual("12345", _testHostProcessStdError.ToString()); + } + + [TestMethod] + public void ErrorReceivedCallbackShouldAppendEntireStringEvenItReachesToMaxLength() + { + _testHostProcessStdError = new StringBuilder(0, 5); + _testHostProcessStdError.Append("12"); + TestHostManagerCallbacks.ErrorReceivedCallback(_testHostProcessStdError, "3"); + + Assert.AreEqual("123" + Environment.NewLine, _testHostProcessStdError.ToString()); + } + + [TestMethod] + public void ErrorReceivedCallbackShouldAppendNewLineApproprioritlyWhenReachingMaxLength() + { + _testHostProcessStdError = new StringBuilder(0, 5); + _testHostProcessStdError.Append("123"); + TestHostManagerCallbacks.ErrorReceivedCallback(_testHostProcessStdError, "4"); + + Assert.AreEqual("1234" + Environment.NewLine.Substring(0, 1), _testHostProcessStdError.ToString()); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Program.cs b/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Program.cs index 02b716c787..d7f4aa4dff 100644 --- a/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Program.cs +++ b/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Program.cs @@ -1,13 +1,11 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.UnitTests +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.UnitTests; + +public static class Program { -#pragma warning disable SA1600 - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } -#pragma warning restore SA1600 } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.TestUtilities/AssemblyUtility.cs b/test/Microsoft.TestPlatform.TestUtilities/AssemblyUtility.cs index 1e1d29c5d6..31cf3c4bd2 100644 --- a/test/Microsoft.TestPlatform.TestUtilities/AssemblyUtility.cs +++ b/test/Microsoft.TestPlatform.TestUtilities/AssemblyUtility.cs @@ -1,30 +1,29 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.TestUtilities -{ - using System.Reflection; +namespace Microsoft.TestPlatform.TestUtilities; + +using System.Reflection; #if !NET451 - using System.Runtime.Loader; +using System.Runtime.Loader; #endif +/// +/// Assembly utility to perform assembly related functions. +/// +public class AssemblyUtility +{ /// - /// Assembly utility to perform assembly related functions. + /// Gets the assembly name at a given location. /// - public class AssemblyUtility + /// + /// + public static AssemblyName GetAssemblyName(string assemblyPath) { - /// - /// Gets the assembly name at a given location. - /// - /// - /// - public static AssemblyName GetAssemblyName(string assemblyPath) - { #if !NET451 - return AssemblyLoadContext.GetAssemblyName(assemblyPath); + return AssemblyLoadContext.GetAssemblyName(assemblyPath); #else - return AssemblyName.GetAssemblyName(assemblyPath); + return AssemblyName.GetAssemblyName(assemblyPath); #endif - } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.TestUtilities/FileAssert.cs b/test/Microsoft.TestPlatform.TestUtilities/FileAssert.cs index 75147b98fc..c65d4aa0bd 100644 --- a/test/Microsoft.TestPlatform.TestUtilities/FileAssert.cs +++ b/test/Microsoft.TestPlatform.TestUtilities/FileAssert.cs @@ -1,24 +1,24 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace TestPlatform.TestUtilities +namespace TestPlatform.TestUtilities; + +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using System.IO; + +public static class FileAssert { - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System.IO; + private const string StringHighlighter = "\"\"\""; - public static class FileAssert + public static void Contains(string filePath, params string[] substrs) { - private const string StringHighlighter = "\"\"\""; - - public static void Contains(string filePath, params string[] substrs) + Assert.IsTrue(File.Exists(filePath), $"{filePath}: file doesn't exist."); + var fileContent = File.ReadAllText(filePath); + foreach (var substr in substrs) { - Assert.IsTrue(File.Exists(filePath), $"{filePath}: file doesn't exist."); - var fileContent= File.ReadAllText(filePath); - foreach(var substr in substrs) - { - Assert.IsTrue(fileContent.Contains(substr), + Assert.IsTrue(fileContent.Contains(substr), $"{filePath}: file doesn't contains {StringHighlighter} {substr} {StringHighlighter}"); - } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs b/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs index ec6e6dfdf4..0cc20ac898 100644 --- a/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs +++ b/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs @@ -1,812 +1,796 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.TestUtilities +namespace Microsoft.TestPlatform.TestUtilities; + +using Microsoft.TestPlatform.VsTestConsole.TranslationLayer; +using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; + +/// +/// Base class for integration tests. +/// +public class IntegrationTestBase { - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer; - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.IO; - using System.Linq; - using System.Text; - using System.Text.RegularExpressions; - using System.Xml; + public const string DesktopRunnerFramework = "net451"; + public const string CoreRunnerFramework = "netcoreapp2.1"; - /// - /// Base class for integration tests. - /// - public class IntegrationTestBase + private const string TotalTestsMessage = "Total tests: {0}"; + private const string PassedTestsMessage = " Passed: {0}"; + private const string FailedTestsMessage = " Failed: {0}"; + private const string SkippedTestsMessage = " Skipped: {0}"; + private const string TestSummaryStatusMessageFormat = "Total tests: {0} Passed: {1} Failed: {2} Skipped: {3}"; + private string _standardTestOutput = string.Empty; + private string _standardTestError = string.Empty; + private int _runnerExitCode = -1; + + private string _arguments = string.Empty; + + protected readonly IntegrationTestEnvironment _testEnvironment; + + private readonly string _testAdapterRelativePath = @"mstest.testadapter\{0}\build\_common".Replace('\\', Path.DirectorySeparatorChar); + private readonly string _nUnitTestAdapterRelativePath = @"nunit3testadapter\{0}\build".Replace('\\', Path.DirectorySeparatorChar); + private readonly string _xUnitTestAdapterRelativePath = @"xunit.runner.visualstudio\{0}\build\_common".Replace('\\', Path.DirectorySeparatorChar); + private readonly string _chutzpahTestAdapterRelativePath = @"chutzpah\{0}\tools".Replace('\\', Path.DirectorySeparatorChar); + + protected static readonly bool IsWindows = System.Environment.OSVersion.Platform.ToString().StartsWith("Win"); + + public enum UnitTestFramework { - public const string DesktopRunnerFramework = "net451"; - public const string CoreRunnerFramework = "netcoreapp2.1"; + NUnit, XUnit, MSTest, CPP, Chutzpah + } - private const string TotalTestsMessage = "Total tests: {0}"; - private const string PassedTestsMessage = " Passed: {0}"; - private const string FailedTestsMessage = " Failed: {0}"; - private const string SkippedTestsMessage = " Skipped: {0}"; - private const string TestSummaryStatusMessageFormat = "Total tests: {0} Passed: {1} Failed: {2} Skipped: {3}"; - private string standardTestOutput = string.Empty; - private string standardTestError = string.Empty; - private string standardTestOutputWithWhiteSpace = string.Empty; - private string standardTestErrorWithWhiteSpace = string.Empty; - private int runnerExitCode = -1; + public IntegrationTestBase() + { + _testEnvironment = new IntegrationTestEnvironment(); + } - private string arguments = string.Empty; + public string StdOut => _standardTestOutput; + public string StdOutWithWhiteSpace { get; private set; } = string.Empty; - protected readonly IntegrationTestEnvironment testEnvironment; + public string StdErr => _standardTestError; + public string StdErrWithWhiteSpace { get; private set; } = string.Empty; - private readonly string TestAdapterRelativePath = @"mstest.testadapter\{0}\build\_common".Replace('\\', Path.DirectorySeparatorChar); - private readonly string NUnitTestAdapterRelativePath = @"nunit3testadapter\{0}\build".Replace('\\', Path.DirectorySeparatorChar); - private readonly string XUnitTestAdapterRelativePath = @"xunit.runner.visualstudio\{0}\build\_common".Replace('\\', Path.DirectorySeparatorChar); - private readonly string ChutzpahTestAdapterRelativePath = @"chutzpah\{0}\tools".Replace('\\', Path.DirectorySeparatorChar); + /// + /// Prepare arguments for vstest.console.exe. + /// + /// List of test assemblies. + /// Path to test adapter. + /// Text of run settings. + /// + /// + /// Command line arguments string. + public static string PrepareArguments(string[] testAssemblies, string testAdapterPath, string runSettings, + string framework, string inIsolation = "", string resultsDirectory = null) + { + var arguments = ""; + foreach (var path in testAssemblies) + { + arguments += path.AddDoubleQuote() + " "; + } - protected static readonly bool IsWindows = System.Environment.OSVersion.Platform.ToString().StartsWith("Win"); + arguments = arguments.Trim(); - public enum UnitTestFramework + if (!string.IsNullOrWhiteSpace(testAdapterPath)) { - NUnit, XUnit, MSTest, CPP, Chutzpah + // Append adapter path + arguments = string.Concat(arguments, " /testadapterpath:", testAdapterPath.AddDoubleQuote()); } - public IntegrationTestBase() + if (!string.IsNullOrWhiteSpace(runSettings)) { - this.testEnvironment = new IntegrationTestEnvironment(); + // Append run settings + arguments = string.Concat(arguments, " /settings:", runSettings.AddDoubleQuote()); } - public string StdOut => this.standardTestOutput; - public string StdOutWithWhiteSpace => this.standardTestOutputWithWhiteSpace; + if (!string.IsNullOrWhiteSpace(framework)) + { + // Append run settings + arguments = string.Concat(arguments, " /framework:", framework.AddDoubleQuote()); + } - public string StdErr => this.standardTestError; - public string StdErrWithWhiteSpace => this.standardTestErrorWithWhiteSpace; + arguments = string.Concat(arguments, " /logger:", "console;verbosity=normal".AddDoubleQuote()); - /// - /// Prepare arguments for vstest.console.exe. - /// - /// List of test assemblies. - /// Path to test adapter. - /// Text of run settings. - /// - /// - /// Command line arguments string. - public static string PrepareArguments(string[] testAssemblies, string testAdapterPath, string runSettings, - string framework, string inIsolation = "", string resultsDirectory = null) + if (!string.IsNullOrWhiteSpace(inIsolation)) { - var arguments = ""; - foreach (var path in testAssemblies) - { - arguments += path.AddDoubleQuote() + " "; - } + arguments = string.Concat(arguments, " ", inIsolation); + } - arguments = arguments.Trim(); + if (!string.IsNullOrWhiteSpace(resultsDirectory)) + { + // Append results directory + arguments = string.Concat(arguments, " /ResultsDirectory:", resultsDirectory.AddDoubleQuote()); + } - if (!string.IsNullOrWhiteSpace(testAdapterPath)) - { - // Append adapter path - arguments = string.Concat(arguments, " /testadapterpath:", testAdapterPath.AddDoubleQuote()); - } + return arguments; + } - if (!string.IsNullOrWhiteSpace(runSettings)) - { - // Append run settings - arguments = string.Concat(arguments, " /settings:", runSettings.AddDoubleQuote()); - } + /// + /// Prepare arguments for vstest.console.exe. + /// + /// Name of the test assembly. + /// Path to test adapter. + /// Text of run settings. + /// + /// + /// Command line arguments string. + public static string PrepareArguments(string testAssembly, string testAdapterPath, string runSettings, + string framework, string inIsolation = "", string resultsDirectory = null) + => PrepareArguments(new string[] { testAssembly }, testAdapterPath, runSettings, framework, inIsolation, resultsDirectory); - if (!string.IsNullOrWhiteSpace(framework)) - { - // Append run settings - arguments = string.Concat(arguments, " /framework:", framework.AddDoubleQuote()); - } - arguments = string.Concat(arguments, " /logger:", "console;verbosity=normal".AddDoubleQuote()); + /// + /// Invokes vstest.console with specified arguments. + /// + /// Arguments provided to vstest.console.exe + public void InvokeVsTest(string arguments, Dictionary environmentVariables = null) + { + ExecuteVsTestConsole(arguments, out _standardTestOutput, out _standardTestError, out _runnerExitCode, environmentVariables); + FormatStandardOutCome(); + } - if (!string.IsNullOrWhiteSpace(inIsolation)) - { - arguments = string.Concat(arguments, " ", inIsolation); - } + /// + /// Invokes our local copy of dotnet that is patched with artifacts from the build with specified arguments. + /// + /// Arguments provided to vstest.console.exe + public void InvokeDotnetTest(string arguments) + { + var vstestConsolePath = Path.Combine(IntegrationTestEnvironment.TestPlatformRootDirectory, "artifacts", IntegrationTestEnvironment.BuildConfiguration, "netcoreapp2.1", "vstest.console.dll"); + var env = "VSTEST_CONSOLE_PATH"; + var originalVstestConsolePath = Environment.GetEnvironmentVariable(env); - if (!string.IsNullOrWhiteSpace(resultsDirectory)) + try + { + Environment.SetEnvironmentVariable(env, vstestConsolePath); + if (arguments.Contains(".csproj")) { - // Append results directory - arguments = string.Concat(arguments, " /ResultsDirectory:", resultsDirectory.AddDoubleQuote()); + arguments = $@"-p:VsTestConsolePath=""{vstestConsolePath}"" " + arguments; } - return arguments; + ExecutePatchedDotnet("test", arguments, out _standardTestOutput, out _standardTestError, out _runnerExitCode); + FormatStandardOutCome(); } - - /// - /// Prepare arguments for vstest.console.exe. - /// - /// Name of the test assembly. - /// Path to test adapter. - /// Text of run settings. - /// - /// - /// Command line arguments string. - public static string PrepareArguments(string testAssembly, string testAdapterPath, string runSettings, - string framework, string inIsolation = "", string resultsDirectory = null) - => PrepareArguments(new string[] { testAssembly }, testAdapterPath, runSettings, framework, inIsolation, resultsDirectory); - - - /// - /// Invokes vstest.console with specified arguments. - /// - /// Arguments provided to vstest.console.exe - public void InvokeVsTest(string arguments, Dictionary environmentVariables = null) + finally { - this.ExecuteVsTestConsole(arguments, out this.standardTestOutput, out this.standardTestError, out this.runnerExitCode, environmentVariables); - this.FormatStandardOutCome(); + Environment.SetEnvironmentVariable(env, originalVstestConsolePath); } + } - /// - /// Invokes our local copy of dotnet that is patched with artifacts from the build with specified arguments. - /// - /// Arguments provided to vstest.console.exe - public void InvokeDotnetTest(string arguments) - { - var vstestConsolePath = Path.Combine(IntegrationTestEnvironment.TestPlatformRootDirectory, "artifacts", IntegrationTestEnvironment.BuildConfiguration, "netcoreapp2.1", "vstest.console.dll"); - var env = "VSTEST_CONSOLE_PATH"; - var originalVstestConsolePath = Environment.GetEnvironmentVariable(env); + /// + /// Invokes vstest.console to execute tests in a test assembly. + /// + /// A test assembly. + /// Path to test adapters. + /// Dotnet Framework of test assembly. + /// Run settings for execution. + public void InvokeVsTestForExecution(string testAssembly, + string testAdapterPath, + string framework, + string runSettings = "", + Dictionary environmentVariables = null) + { + using var workspace = new TempDirectory(); - try - { - Environment.SetEnvironmentVariable(env, vstestConsolePath); - if (arguments.Contains(".csproj")) - { - arguments = $@"-p:VsTestConsolePath=""{vstestConsolePath}"" " + arguments; - } + var arguments = PrepareArguments(testAssembly, testAdapterPath, runSettings, framework, _testEnvironment.InIsolationValue, resultsDirectory: workspace.Path); + InvokeVsTest(arguments, environmentVariables); + } - this.ExecutePatchedDotnet("test", arguments, out this.standardTestOutput, out this.standardTestError, out this.runnerExitCode); - this.FormatStandardOutCome(); - } - finally - { - Environment.SetEnvironmentVariable(env, originalVstestConsolePath); - } - } + /// + /// Invokes vstest.console to discover tests in a test assembly. "/listTests" is appended to the arguments. + /// + /// A test assembly. + /// Path to test adapters. + /// Run settings for execution. + public void InvokeVsTestForDiscovery(string testAssembly, string testAdapterPath, string runSettings = "", string targetFramework = "", Dictionary environmentVariables = null) + { + using var workspace = new TempDirectory(); - /// - /// Invokes vstest.console to execute tests in a test assembly. - /// - /// A test assembly. - /// Path to test adapters. - /// Dotnet Framework of test assembly. - /// Run settings for execution. - public void InvokeVsTestForExecution(string testAssembly, - string testAdapterPath, - string framework, - string runSettings = "", - Dictionary environmentVariables = null) - { - using var workspace = new TempDirectory(); + var arguments = PrepareArguments(testAssembly, testAdapterPath, runSettings, targetFramework, _testEnvironment.InIsolationValue, resultsDirectory: workspace.Path); + arguments = string.Concat(arguments, " /listtests"); + InvokeVsTest(arguments, environmentVariables); + } - var arguments = PrepareArguments(testAssembly, testAdapterPath, runSettings, framework, this.testEnvironment.InIsolationValue, resultsDirectory: workspace.Path); - this.InvokeVsTest(arguments, environmentVariables); + /// + /// Execute Tests that are not supported with given Runner framework. + /// + /// Runner Framework + /// Framework for which Tests are not supported + /// Message to be shown + public void ExecuteNotSupportedRunnerFrameworkTests(string runnerFramework, string framework, string message) + { + if (runnerFramework.StartsWith(framework)) + { + Assert.Inconclusive(message); } + } - /// - /// Invokes vstest.console to discover tests in a test assembly. "/listTests" is appended to the arguments. - /// - /// A test assembly. - /// Path to test adapters. - /// Run settings for execution. - public void InvokeVsTestForDiscovery(string testAssembly, string testAdapterPath, string runSettings = "", string targetFramework = "", Dictionary environmentVariables = null) + /// + /// Validate if the overall test count and results are matching. + /// + /// Passed test count + /// Failed test count + /// Skipped test count + public void ValidateSummaryStatus(int passedTestsCount, int failedTestsCount, int skippedTestsCount) + { + var totalTestCount = passedTestsCount + failedTestsCount + skippedTestsCount; + if (totalTestCount == 0) { - using var workspace = new TempDirectory(); - - var arguments = PrepareArguments(testAssembly, testAdapterPath, runSettings, targetFramework, this.testEnvironment.InIsolationValue, resultsDirectory: workspace.Path); - arguments = string.Concat(arguments, " /listtests"); - this.InvokeVsTest(arguments, environmentVariables); + // No test should be found/run + var summaryStatus = string.Format( + TestSummaryStatusMessageFormat, + @"\d+", + @"\d+", + @"\d+", + @"\d+"); + StringAssert.DoesNotMatch( + _standardTestOutput, + new Regex(summaryStatus), + "Excepted: There should not be test summary{2}Actual: {0}{2}Standard Error: {1}{2}Arguments: {3}{2}", + _standardTestOutput, + _standardTestError, + Environment.NewLine, + _arguments); } - - /// - /// Execute Tests that are not supported with given Runner framework. - /// - /// Runner Framework - /// Framework for which Tests are not supported - /// Message to be shown - public void ExecuteNotSupportedRunnerFrameworkTests(string runnerFramework, string framework, string message) + else { - if (runnerFramework.StartsWith(framework)) + var summaryStatus = string.Format(TotalTestsMessage, totalTestCount); + if (passedTestsCount != 0) { - Assert.Inconclusive(message); + summaryStatus += string.Format(PassedTestsMessage, passedTestsCount); } - } - /// - /// Validate if the overall test count and results are matching. - /// - /// Passed test count - /// Failed test count - /// Skipped test count - public void ValidateSummaryStatus(int passedTestsCount, int failedTestsCount, int skippedTestsCount) - { - var totalTestCount = passedTestsCount + failedTestsCount + skippedTestsCount; - if (totalTestCount == 0) + if (failedTestsCount != 0) { - // No test should be found/run - var summaryStatus = string.Format( - TestSummaryStatusMessageFormat, - @"\d+", - @"\d+", - @"\d+", - @"\d+"); - StringAssert.DoesNotMatch( - this.standardTestOutput, - new Regex(summaryStatus), - "Excepted: There should not be test summary{2}Actual: {0}{2}Standard Error: {1}{2}Arguments: {3}{2}", - this.standardTestOutput, - this.standardTestError, - Environment.NewLine, - this.arguments); + summaryStatus += string.Format(FailedTestsMessage, failedTestsCount); } - else + + if (skippedTestsCount != 0) { - var summaryStatus = string.Format(TotalTestsMessage, totalTestCount); - if (passedTestsCount != 0) - { - summaryStatus += string.Format(PassedTestsMessage, passedTestsCount); - } + summaryStatus += string.Format(SkippedTestsMessage, skippedTestsCount); + } - if (failedTestsCount != 0) - { - summaryStatus += string.Format(FailedTestsMessage, failedTestsCount); - } + Assert.IsTrue( + _standardTestOutput.Contains(summaryStatus), + "The Test summary does not match.{3}Expected summary: {1}{3}Test Output: {0}{3}Standard Error: {2}{3}Arguments: {4}{3}", + _standardTestOutput, + summaryStatus, + _standardTestError, + Environment.NewLine, + _arguments); + } + } - if (skippedTestsCount != 0) - { - summaryStatus += string.Format(SkippedTestsMessage, skippedTestsCount); - } + public void StdErrorContains(string substring) + { + Assert.IsTrue(_standardTestError.Contains(substring), "StdErrorOutput - [{0}] did not contain expected string '{1}'", _standardTestError, substring); + } - Assert.IsTrue( - this.standardTestOutput.Contains(summaryStatus), - "The Test summary does not match.{3}Expected summary: {1}{3}Test Output: {0}{3}Standard Error: {2}{3}Arguments: {4}{3}", - this.standardTestOutput, - summaryStatus, - this.standardTestError, - Environment.NewLine, - this.arguments); - } - } + public void StdErrorDoesNotContains(string substring) + { + Assert.IsFalse(_standardTestError.Contains(substring), "StdErrorOutput - [{0}] did not contain expected string '{1}'", _standardTestError, substring); + } - public void StdErrorContains(string substring) - { - Assert.IsTrue(this.standardTestError.Contains(substring), "StdErrorOutput - [{0}] did not contain expected string '{1}'", this.standardTestError, substring); - } + public void StdOutputContains(string substring) + { + Assert.IsTrue(_standardTestOutput.Contains(substring), $"StdOutout:{Environment.NewLine} Expected substring: {substring}{Environment.NewLine}Actual string: {_standardTestOutput}"); + } - public void StdErrorDoesNotContains(string substring) - { - Assert.IsFalse(this.standardTestError.Contains(substring), "StdErrorOutput - [{0}] did not contain expected string '{1}'", this.standardTestError, substring); - } + public void StdOutputDoesNotContains(string substring) + { + Assert.IsFalse(_standardTestOutput.Contains(substring), $"StdOutout:{Environment.NewLine} Not expected substring: {substring}{Environment.NewLine}Actual string: {_standardTestOutput}"); + } - public void StdOutputContains(string substring) - { - Assert.IsTrue(this.standardTestOutput.Contains(substring), $"StdOutout:{Environment.NewLine} Expected substring: {substring}{Environment.NewLine}Actual string: {this.standardTestOutput}"); - } + public void ExitCodeEquals(int exitCode) + { + Assert.AreEqual(exitCode, _runnerExitCode, $"ExitCode - [{_runnerExitCode}] doesn't match expected '{exitCode}'."); + } - public void StdOutputDoesNotContains(string substring) - { - Assert.IsFalse(this.standardTestOutput.Contains(substring), $"StdOutout:{Environment.NewLine} Not expected substring: {substring}{Environment.NewLine}Actual string: {this.standardTestOutput}"); + /// + /// Validates if the test results have the specified set of passed tests. + /// + /// Set of passed tests. + /// Provide the full test name similar to this format SampleTest.TestCode.TestMethodPass. + public void ValidatePassedTests(params string[] passedTests) + { + // Convert the unicode character to its unicode value for assertion + _standardTestOutput = Regex.Replace(_standardTestOutput, @"[^\x00-\x7F]", c => string.Format(@"\u{0:x4}", (int)c.Value[0])); + foreach (var test in passedTests) + { + // Check for tick or ? both, in some cases as unicode character for tick is not available + // in std out and gets replaced by ? + var flag = _standardTestOutput.Contains("Passed " + test) + || _standardTestOutput.Contains("Passed " + GetTestMethodName(test)) + || _standardTestOutput.Contains("\\ufffd " + test) + || _standardTestOutput.Contains("\\ufffd " + GetTestMethodName(test)); + Assert.IsTrue(flag, "Test {0} does not appear in passed tests list.", test); } + } - public void ExitCodeEquals(int exitCode) + /// + /// Validates if the test results have the specified set of failed tests. + /// + /// Set of failed tests. + /// + /// Provide the full test name similar to this format SampleTest.TestCode.TestMethodFailed. + /// Also validates whether these tests have stack trace info. + /// + public void ValidateFailedTests(params string[] failedTests) + { + foreach (var test in failedTests) { - Assert.AreEqual(exitCode, this.runnerExitCode, $"ExitCode - [{this.runnerExitCode}] doesn't match expected '{exitCode}'."); - } + var flag = _standardTestOutput.Contains("Failed " + test) + || _standardTestOutput.Contains("Failed " + GetTestMethodName(test)); + Assert.IsTrue(flag, "Test {0} does not appear in failed tests list.", test); - /// - /// Validates if the test results have the specified set of passed tests. - /// - /// Set of passed tests. - /// Provide the full test name similar to this format SampleTest.TestCode.TestMethodPass. - public void ValidatePassedTests(params string[] passedTests) - { - // Convert the unicode character to its unicode value for assertion - this.standardTestOutput = Regex.Replace(this.standardTestOutput, @"[^\x00-\x7F]", c => string.Format(@"\u{0:x4}", (int)c.Value[0])); - foreach (var test in passedTests) - { - // Check for tick or ? both, in some cases as unicode character for tick is not available - // in std out and gets replaced by ? - var flag = this.standardTestOutput.Contains("Passed " + test) - || this.standardTestOutput.Contains("Passed " + GetTestMethodName(test)) - || this.standardTestOutput.Contains("\\ufffd " + test) - || this.standardTestOutput.Contains("\\ufffd " + GetTestMethodName(test)); - Assert.IsTrue(flag, "Test {0} does not appear in passed tests list.", test); - } + // Verify stack information as well. + Assert.IsTrue(_standardTestOutput.Contains(GetTestMethodName(test)), "No stack trace for failed test: {0}", test); } + } - /// - /// Validates if the test results have the specified set of failed tests. - /// - /// Set of failed tests. - /// - /// Provide the full test name similar to this format SampleTest.TestCode.TestMethodFailed. - /// Also validates whether these tests have stack trace info. - /// - public void ValidateFailedTests(params string[] failedTests) + /// + /// Validates if the test results have the specified set of skipped tests. + /// + /// The set of skipped tests. + /// Provide the full test name similar to this format SampleTest.TestCode.TestMethodSkipped. + public void ValidateSkippedTests(params string[] skippedTests) + { + foreach (var test in skippedTests) { - foreach (var test in failedTests) - { - var flag = this.standardTestOutput.Contains("Failed " + test) - || this.standardTestOutput.Contains("Failed " + GetTestMethodName(test)); - Assert.IsTrue(flag, "Test {0} does not appear in failed tests list.", test); - - // Verify stack information as well. - Assert.IsTrue(this.standardTestOutput.Contains(GetTestMethodName(test)), "No stack trace for failed test: {0}", test); - } + var flag = _standardTestOutput.Contains("Skipped " + test) + || _standardTestOutput.Contains("Skipped " + GetTestMethodName(test)); + Assert.IsTrue(flag, "Test {0} does not appear in skipped tests list.", test); } + } - /// - /// Validates if the test results have the specified set of skipped tests. - /// - /// The set of skipped tests. - /// Provide the full test name similar to this format SampleTest.TestCode.TestMethodSkipped. - public void ValidateSkippedTests(params string[] skippedTests) + /// + /// Validate if the discovered tests list contains provided tests. + /// + /// List of tests expected to be discovered. + public void ValidateDiscoveredTests(params string[] discoveredTestsList) + { + foreach (var test in discoveredTestsList) { - foreach (var test in skippedTests) - { - var flag = this.standardTestOutput.Contains("Skipped " + test) - || this.standardTestOutput.Contains("Skipped " + GetTestMethodName(test)); - Assert.IsTrue(flag, "Test {0} does not appear in skipped tests list.", test); - } + var flag = _standardTestOutput.Contains(test) + || _standardTestOutput.Contains(GetTestMethodName(test)); + Assert.IsTrue(flag, $"Test {test} does not appear in discovered tests list." + + $"{System.Environment.NewLine}Std Output: {_standardTestOutput}" + + $"{System.Environment.NewLine}Std Error: { _standardTestError}"); } + } - /// - /// Validate if the discovered tests list contains provided tests. - /// - /// List of tests expected to be discovered. - public void ValidateDiscoveredTests(params string[] discoveredTestsList) + /// + /// Validate that the discovered tests list doesn't contain specified tests. + /// + /// List of tests expected not to be discovered. + public void ValidateTestsNotDiscovered(params string[] testsList) + { + foreach (var test in testsList) { - foreach (var test in discoveredTestsList) - { - var flag = this.standardTestOutput.Contains(test) - || this.standardTestOutput.Contains(GetTestMethodName(test)); - Assert.IsTrue(flag, $"Test {test} does not appear in discovered tests list." + - $"{System.Environment.NewLine}Std Output: {this.standardTestOutput}" + - $"{System.Environment.NewLine}Std Error: { this.standardTestError}"); - } + var flag = _standardTestOutput.Contains(test) + || _standardTestOutput.Contains(GetTestMethodName(test)); + Assert.IsFalse(flag, $"Test {test} should not appear in discovered tests list." + + $"{System.Environment.NewLine}Std Output: {_standardTestOutput}" + + $"{System.Environment.NewLine}Std Error: { _standardTestError}"); } + } - /// - /// Validate that the discovered tests list doesn't contain specified tests. - /// - /// List of tests expected not to be discovered. - public void ValidateTestsNotDiscovered(params string[] testsList) + public void ValidateFullyQualifiedDiscoveredTests(string filePath, params string[] discoveredTestsList) + { + var fileOutput = File.ReadAllLines(filePath); + Assert.IsTrue(fileOutput.Length == 3); + + foreach (var test in discoveredTestsList) { - foreach (var test in testsList) - { - var flag = this.standardTestOutput.Contains(test) - || this.standardTestOutput.Contains(GetTestMethodName(test)); - Assert.IsFalse(flag, $"Test {test} should not appear in discovered tests list." + - $"{System.Environment.NewLine}Std Output: {this.standardTestOutput}" + - $"{System.Environment.NewLine}Std Error: { this.standardTestError}"); - } + var flag = fileOutput.Contains(test) + || fileOutput.Contains(GetTestMethodName(test)); + Assert.IsTrue(flag, $"Test {test} does not appear in discovered tests list." + + $"{System.Environment.NewLine}Std Output: {_standardTestOutput}" + + $"{System.Environment.NewLine}Std Error: { _standardTestError}"); } + } - public void ValidateFullyQualifiedDiscoveredTests(string filePath, params string[] discoveredTestsList) - { - var fileOutput = File.ReadAllLines(filePath); - Assert.IsTrue(fileOutput.Length == 3); + protected string GetSampleTestAssembly() + { + return GetAssetFullPath("SimpleTestProject.dll"); + } - foreach (var test in discoveredTestsList) - { - var flag = fileOutput.Contains(test) - || fileOutput.Contains(GetTestMethodName(test)); - Assert.IsTrue(flag, $"Test {test} does not appear in discovered tests list." + - $"{System.Environment.NewLine}Std Output: {this.standardTestOutput}" + - $"{System.Environment.NewLine}Std Error: { this.standardTestError}"); - } - } + protected string GetAssetFullPath(string assetName) + { + return _testEnvironment.GetTestAsset(assetName); + } - protected string GetSampleTestAssembly() - { - return this.GetAssetFullPath("SimpleTestProject.dll"); - } + protected string GetAssetFullPath(string assetName, string targetFramework) + { + return _testEnvironment.GetTestAsset(assetName, targetFramework); + } - protected string GetAssetFullPath(string assetName) + protected string GetProjectFullPath(string projectName) + { + return _testEnvironment.GetTestProject(projectName); + } + + protected string GetProjectAssetFullPath(string projectName, string assetName) + { + var projectPath = _testEnvironment.GetTestProject(projectName); + return Path.Combine(Path.GetDirectoryName(projectPath), assetName); + } + + protected string GetTestAdapterPath(UnitTestFramework testFramework = UnitTestFramework.MSTest) + { + string adapterRelativePath = string.Empty; + + if (testFramework == UnitTestFramework.MSTest) { - return this.testEnvironment.GetTestAsset(assetName); + adapterRelativePath = string.Format(_testAdapterRelativePath, _testEnvironment.DependencyVersions["MSTestAdapterVersion"]); } - - protected string GetAssetFullPath(string assetName, string targetFramework) + else if (testFramework == UnitTestFramework.NUnit) { - return this.testEnvironment.GetTestAsset(assetName, targetFramework); + adapterRelativePath = string.Format(_nUnitTestAdapterRelativePath, _testEnvironment.DependencyVersions["NUnit3AdapterVersion"]); } - - protected string GetProjectFullPath(string projectName) + else if (testFramework == UnitTestFramework.XUnit) { - return this.testEnvironment.GetTestProject(projectName); + adapterRelativePath = string.Format(_xUnitTestAdapterRelativePath, _testEnvironment.DependencyVersions["XUnitAdapterVersion"]); } - - protected string GetProjectAssetFullPath(string projectName, string assetName) + else if (testFramework == UnitTestFramework.Chutzpah) { - var projectPath = this.testEnvironment.GetTestProject(projectName); - return Path.Combine(Path.GetDirectoryName(projectPath), assetName); + adapterRelativePath = string.Format(_chutzpahTestAdapterRelativePath, _testEnvironment.DependencyVersions["ChutzpahAdapterVersion"]); } - protected string GetTestAdapterPath(UnitTestFramework testFramework = UnitTestFramework.MSTest) - { - string adapterRelativePath = string.Empty; + return _testEnvironment.GetNugetPackage(adapterRelativePath); + } - if (testFramework == UnitTestFramework.MSTest) - { - adapterRelativePath = string.Format(TestAdapterRelativePath, this.testEnvironment.DependencyVersions["MSTestAdapterVersion"]); - } - else if (testFramework == UnitTestFramework.NUnit) - { - adapterRelativePath = string.Format(NUnitTestAdapterRelativePath, this.testEnvironment.DependencyVersions["NUnit3AdapterVersion"]); - } - else if (testFramework == UnitTestFramework.XUnit) - { - adapterRelativePath = string.Format(XUnitTestAdapterRelativePath, this.testEnvironment.DependencyVersions["XUnitAdapterVersion"]); - } - else if (testFramework == UnitTestFramework.Chutzpah) - { - adapterRelativePath = string.Format(ChutzpahTestAdapterRelativePath, this.testEnvironment.DependencyVersions["ChutzpahAdapterVersion"]); - } + protected bool IsDesktopRunner() + { + return _testEnvironment.RunnerFramework == IntegrationTestBase.DesktopRunnerFramework; + } - return this.testEnvironment.GetNugetPackage(adapterRelativePath); - } + protected bool IsNetCoreRunner() + { + return _testEnvironment.RunnerFramework == IntegrationTestBase.CoreRunnerFramework; + } - protected bool IsDesktopRunner() + /// + /// Gets the path to vstest.console.exe. + /// + /// + /// Full path to test runner + /// + public virtual string GetConsoleRunnerPath() + { + string consoleRunnerPath = string.Empty; + + if (IsDesktopRunner()) { - return this.testEnvironment.RunnerFramework == IntegrationTestBase.DesktopRunnerFramework; + consoleRunnerPath = Path.Combine(_testEnvironment.PublishDirectory, "vstest.console.exe"); } - - protected bool IsNetCoreRunner() + else if (IsNetCoreRunner()) { - return this.testEnvironment.RunnerFramework == IntegrationTestBase.CoreRunnerFramework; + var executablePath = IsWindows ? @"dotnet\dotnet.exe" : @"dotnet-linux/dotnet"; + consoleRunnerPath = Path.Combine(_testEnvironment.ToolsDirectory, executablePath); } - - /// - /// Gets the path to vstest.console.exe. - /// - /// - /// Full path to test runner - /// - public virtual string GetConsoleRunnerPath() + else { - string consoleRunnerPath = string.Empty; + Assert.Fail("Unknown Runner framework - [{0}]", _testEnvironment.RunnerFramework); + } - if (this.IsDesktopRunner()) - { - consoleRunnerPath = Path.Combine(this.testEnvironment.PublishDirectory, "vstest.console.exe"); - } - else if (this.IsNetCoreRunner()) - { - var executablePath = IsWindows ? @"dotnet\dotnet.exe" : @"dotnet-linux/dotnet"; - consoleRunnerPath = Path.Combine(this.testEnvironment.ToolsDirectory, executablePath); - } - else - { - Assert.Fail("Unknown Runner framework - [{0}]", this.testEnvironment.RunnerFramework); - } + Assert.IsTrue(File.Exists(consoleRunnerPath), "GetConsoleRunnerPath: Path not found: {0}", consoleRunnerPath); + return consoleRunnerPath; + } - Assert.IsTrue(File.Exists(consoleRunnerPath), "GetConsoleRunnerPath: Path not found: {0}", consoleRunnerPath); - return consoleRunnerPath; - } + protected virtual string SetVSTestConsoleDLLPathInArgs(string args) + { + var vstestConsoleDll = Path.Combine(_testEnvironment.PublishDirectory, "vstest.console.dll"); + vstestConsoleDll = vstestConsoleDll.AddDoubleQuote(); + args = string.Concat( + vstestConsoleDll, + " ", + args); + return args; + } + + /// + /// Returns the VsTestConsole Wrapper. + /// + /// + public IVsTestConsoleWrapper GetVsTestConsoleWrapper(out TempDirectory logFileDir) + { + logFileDir = new TempDirectory(); - protected virtual string SetVSTestConsoleDLLPathInArgs(string args) + if (!Directory.Exists(logFileDir.Path)) { - var vstestConsoleDll = Path.Combine(this.testEnvironment.PublishDirectory, "vstest.console.dll"); - vstestConsoleDll = vstestConsoleDll.AddDoubleQuote(); - args = string.Concat( - vstestConsoleDll, - " ", - args); - return args; + Directory.CreateDirectory(logFileDir.Path); } - /// - /// Returns the VsTestConsole Wrapper. - /// - /// - public IVsTestConsoleWrapper GetVsTestConsoleWrapper(out TempDirectory logFileDir) + // Directory is already unique so there is no need to have a unique file name. + var logFilePath = Path.Combine(logFileDir.Path, "log.txt"); + if (!File.Exists(logFilePath)) { - logFileDir = new TempDirectory(); - - if (!Directory.Exists(logFileDir.Path)) - { - Directory.CreateDirectory(logFileDir.Path); - } + File.Create(logFilePath).Close(); + } - // Directory is already unique so there is no need to have a unique file name. - var logFilePath = Path.Combine(logFileDir.Path, "log.txt"); - if (!File.Exists(logFilePath)) - { - File.Create(logFilePath).Close(); - } + Console.WriteLine($"Logging diagnostics in {logFilePath}"); - Console.WriteLine($"Logging diagnostics in {logFilePath}"); + var consoleRunnerPath = IsNetCoreRunner() + ? Path.Combine(_testEnvironment.PublishDirectory, "vstest.console.dll") + : GetConsoleRunnerPath(); + var executablePath = IsWindows ? @"dotnet\dotnet.exe" : @"dotnet-linux/dotnet"; + var dotnetPath = Path.Combine(_testEnvironment.ToolsDirectory, executablePath); - string consoleRunnerPath; + if (!File.Exists(dotnetPath)) + { + throw new FileNotFoundException($"File '{dotnetPath}' was not found."); + } - if (this.IsNetCoreRunner()) - { - consoleRunnerPath = Path.Combine(this.testEnvironment.PublishDirectory, "vstest.console.dll"); - } - else - { - consoleRunnerPath = this.GetConsoleRunnerPath(); - } - var executablePath = IsWindows ? @"dotnet\dotnet.exe" : @"dotnet-linux/dotnet"; - var dotnetPath = Path.Combine(this.testEnvironment.ToolsDirectory, executablePath); + var vstestConsoleWrapper = new VsTestConsoleWrapper(consoleRunnerPath, dotnetPath, new ConsoleParameters() { LogFilePath = logFilePath }); + vstestConsoleWrapper.StartSession(); - if (!File.Exists(dotnetPath)) - { - throw new FileNotFoundException($"File '{dotnetPath}' was not found."); - } + return vstestConsoleWrapper; + } - var vstestConsoleWrapper = new VsTestConsoleWrapper(consoleRunnerPath, dotnetPath, new ConsoleParameters() { LogFilePath = logFilePath }); - vstestConsoleWrapper.StartSession(); + /// + /// Gets the test method name from full name. + /// + /// Fully qualified name of the test. + /// Simple name of the test. + private static string GetTestMethodName(string testFullName) + { + string testMethodName = string.Empty; - return vstestConsoleWrapper; + var splits = testFullName.Split('.'); + if (splits.Length >= 3) + { + testMethodName = testFullName.Split('.')[2]; } - /// - /// Gets the test method name from full name. - /// - /// Fully qualified name of the test. - /// Simple name of the test. - private static string GetTestMethodName(string testFullName) + return testMethodName; + } + + private void ExecuteVsTestConsole(string args, out string stdOut, out string stdError, out int exitCode, Dictionary environmentVariables = null) + { + if (IsNetCoreRunner()) { - string testMethodName = string.Empty; + args = SetVSTestConsoleDLLPathInArgs(args); + } - var splits = testFullName.Split('.'); - if (splits.Length >= 3) - { - testMethodName = testFullName.Split('.')[2]; - } + _arguments = args; - return testMethodName; - } + ExecuteApplication(GetConsoleRunnerPath(), args, out stdOut, out stdError, out exitCode, environmentVariables); + } - private void ExecuteVsTestConsole(string args, out string stdOut, out string stdError, out int exitCode, Dictionary environmentVariables = null) + /// + /// Executes a local copy of dotnet that has VSTest task installed and possibly other modifications. Do not use this to + /// do your builds or to run general tests, unless you want your changes to be reflected. + /// + /// + /// + /// + /// + /// + private void ExecutePatchedDotnet(string command, string args, out string stdOut, out string stdError, out int exitCode) + { + var environmentVariables = new Dictionary { - if (this.IsNetCoreRunner()) - { - args = this.SetVSTestConsoleDLLPathInArgs(args); - } + ["DOTNET_MULTILEVEL_LOOKUP"] = "0" + }; - this.arguments = args; + var executablePath = IsWindows ? @"dotnet\dotnet.exe" : @"dotnet-linux/dotnet"; + var patchedDotnetPath = Path.Combine(_testEnvironment.TestArtifactsDirectory, executablePath); + ExecuteApplication(patchedDotnetPath, string.Join(" ", command, args), out stdOut, out stdError, out exitCode, environmentVariables); + } - this.ExecuteApplication(this.GetConsoleRunnerPath(), args, out stdOut, out stdError, out exitCode, environmentVariables); + protected void ExecuteApplication(string path, string args, out string stdOut, out string stdError, out int exitCode, Dictionary environmentVariables = null, string workingDirectory = null) + { + if (string.IsNullOrWhiteSpace(path)) + { + throw new ArgumentException("Executable path must not be null or whitespace.", nameof(path)); } - /// - /// Executes a local copy of dotnet that has VSTest task installed and possibly other modifications. Do not use this to - /// do your builds or to run general tests, unless you want your changes to be reflected. - /// - /// - /// - /// - /// - /// - private void ExecutePatchedDotnet(string command, string args, out string stdOut, out string stdError, out int exitCode) - { - var environmentVariables = new Dictionary - { - ["DOTNET_MULTILEVEL_LOOKUP"] = "0" - }; + var executableName = Path.GetFileName(path); - var executablePath = IsWindows ? @"dotnet\dotnet.exe" : @"dotnet-linux/dotnet"; - var patchedDotnetPath = Path.Combine(this.testEnvironment.TestArtifactsDirectory, executablePath); - this.ExecuteApplication(patchedDotnetPath, string.Join(" ", command, args), out stdOut, out stdError, out exitCode, environmentVariables); - } + using var process = new Process(); + Console.WriteLine($"IntegrationTestBase.Execute: Starting {executableName}"); + process.StartInfo.FileName = path; + process.StartInfo.Arguments = args; + process.StartInfo.UseShellExecute = false; + process.StartInfo.RedirectStandardError = true; + process.StartInfo.RedirectStandardOutput = true; + process.StartInfo.CreateNoWindow = true; + process.StartInfo.StandardOutputEncoding = Encoding.UTF8; + process.StartInfo.StandardErrorEncoding = Encoding.UTF8; - protected void ExecuteApplication(string path, string args, out string stdOut, out string stdError, out int exitCode, Dictionary environmentVariables = null, string workingDirectory = null) + if (workingDirectory != null) { - if (string.IsNullOrWhiteSpace(path)) - { - throw new ArgumentException("Executable path must not be null or whitespace.", nameof(path)); - } - - var executableName = Path.GetFileName(path); + process.StartInfo.WorkingDirectory = workingDirectory; + } - using (Process process = new Process()) + if (environmentVariables != null) + { + foreach (var variable in environmentVariables) { - Console.WriteLine($"IntegrationTestBase.Execute: Starting {executableName}"); - process.StartInfo.FileName = path; - process.StartInfo.Arguments = args; - process.StartInfo.UseShellExecute = false; - process.StartInfo.RedirectStandardError = true; - process.StartInfo.RedirectStandardOutput = true; - process.StartInfo.CreateNoWindow = true; - process.StartInfo.StandardOutputEncoding = Encoding.UTF8; - process.StartInfo.StandardErrorEncoding = Encoding.UTF8; - - if (workingDirectory != null) + if (process.StartInfo.EnvironmentVariables.ContainsKey(variable.Key)) { - process.StartInfo.WorkingDirectory = workingDirectory; + process.StartInfo.EnvironmentVariables[variable.Key] = variable.Value; } - - if (environmentVariables != null) + else { - foreach (var variable in environmentVariables) - { - if (process.StartInfo.EnvironmentVariables.ContainsKey(variable.Key)) - { - process.StartInfo.EnvironmentVariables[variable.Key] = variable.Value; - } - else - { - process.StartInfo.EnvironmentVariables.Add(variable.Key, variable.Value); - } - } + process.StartInfo.EnvironmentVariables.Add(variable.Key, variable.Value); } + } + } - var stdoutBuffer = new StringBuilder(); - var stderrBuffer = new StringBuilder(); - process.OutputDataReceived += (sender, eventArgs) => - { - stdoutBuffer.AppendLine(eventArgs.Data); - }; + var stdoutBuffer = new StringBuilder(); + var stderrBuffer = new StringBuilder(); + process.OutputDataReceived += (sender, eventArgs) => stdoutBuffer.AppendLine(eventArgs.Data); + process.ErrorDataReceived += (sender, eventArgs) => stderrBuffer.AppendLine(eventArgs.Data); - process.ErrorDataReceived += (sender, eventArgs) => stderrBuffer.AppendLine(eventArgs.Data); + Console.WriteLine("IntegrationTestBase.Execute: Path = {0}", process.StartInfo.FileName); + Console.WriteLine("IntegrationTestBase.Execute: Arguments = {0}", process.StartInfo.Arguments); - Console.WriteLine("IntegrationTestBase.Execute: Path = {0}", process.StartInfo.FileName); - Console.WriteLine("IntegrationTestBase.Execute: Arguments = {0}", process.StartInfo.Arguments); + var stopwatch = new Stopwatch(); + stopwatch.Start(); - Stopwatch stopwatch = new Stopwatch(); - stopwatch.Start(); + process.Start(); + process.BeginOutputReadLine(); + process.BeginErrorReadLine(); + if (!process.WaitForExit(5 * 60 * 1000)) // 5 minutes + { + Console.WriteLine($"IntegrationTestBase.Execute: Timed out waiting for {executableName}. Terminating the process."); + process.Kill(); + } + else + { + // Ensure async buffers are flushed + process.WaitForExit(); + } - process.Start(); - process.BeginOutputReadLine(); - process.BeginErrorReadLine(); - if (!process.WaitForExit(5 * 60 * 1000)) // 5 minutes - { - Console.WriteLine($"IntegrationTestBase.Execute: Timed out waiting for {executableName}. Terminating the process."); - process.Kill(); - } - else - { - // Ensure async buffers are flushed - process.WaitForExit(); - } + stopwatch.Stop(); - stopwatch.Stop(); + Console.WriteLine($"IntegrationTestBase.Execute: Total execution time: {stopwatch.Elapsed.Duration()}"); - Console.WriteLine($"IntegrationTestBase.Execute: Total execution time: {stopwatch.Elapsed.Duration()}"); + stdError = stderrBuffer.ToString(); + stdOut = stdoutBuffer.ToString(); + exitCode = process.ExitCode; - stdError = stderrBuffer.ToString(); - stdOut = stdoutBuffer.ToString(); - exitCode = process.ExitCode; + Console.WriteLine("IntegrationTestBase.Execute: stdError = {0}", stdError); + Console.WriteLine("IntegrationTestBase.Execute: stdOut = {0}", stdOut); + Console.WriteLine($"IntegrationTestBase.Execute: Stopped {executableName}. Exit code = {0}", exitCode); + } - Console.WriteLine("IntegrationTestBase.Execute: stdError = {0}", stdError); - Console.WriteLine("IntegrationTestBase.Execute: stdOut = {0}", stdOut); - Console.WriteLine($"IntegrationTestBase.Execute: Stopped {executableName}. Exit code = {0}", exitCode); - } - } + private void FormatStandardOutCome() + { + StdErrWithWhiteSpace = _standardTestError; + _standardTestError = Regex.Replace(_standardTestError, @"\s+", " "); - private void FormatStandardOutCome() - { - this.standardTestErrorWithWhiteSpace = this.standardTestError; - this.standardTestError = Regex.Replace(this.standardTestError, @"\s+", " "); + StdOutWithWhiteSpace = _standardTestOutput; + _standardTestOutput = Regex.Replace(_standardTestOutput, @"\s+", " "); + } - this.standardTestOutputWithWhiteSpace = this.standardTestOutput; - this.standardTestOutput = Regex.Replace(this.standardTestOutput, @"\s+", " "); - } + /// + /// Create runsettings file from runConfigurationDictionary at destinationRunsettingsPath + /// + /// + /// Destination runsettings path where resulted file saves + /// + /// + /// Contains run configuration settings + /// + public static void CreateRunSettingsFile(string destinationRunsettingsPath, IDictionary runConfigurationDictionary) + { + var doc = new XmlDocument(); + var xmlDeclaration = doc.CreateNode(XmlNodeType.XmlDeclaration, string.Empty, string.Empty); - /// - /// Create runsettings file from runConfigurationDictionary at destinationRunsettingsPath - /// - /// - /// Destination runsettings path where resulted file saves - /// - /// - /// Contains run configuration settings - /// - public static void CreateRunSettingsFile(string destinationRunsettingsPath, IDictionary runConfigurationDictionary) - { - var doc = new XmlDocument(); - var xmlDeclaration = doc.CreateNode(XmlNodeType.XmlDeclaration, string.Empty, string.Empty); + doc.AppendChild(xmlDeclaration); + var runSettingsNode = doc.CreateElement(Constants.RunSettingsName); + doc.AppendChild(runSettingsNode); + var runConfigNode = doc.CreateElement(Constants.RunConfigurationSettingsName); + runSettingsNode.AppendChild(runConfigNode); - doc.AppendChild(xmlDeclaration); - var runSettingsNode = doc.CreateElement(Constants.RunSettingsName); - doc.AppendChild(runSettingsNode); - var runConfigNode = doc.CreateElement(Constants.RunConfigurationSettingsName); - runSettingsNode.AppendChild(runConfigNode); + foreach (var settingsEntry in runConfigurationDictionary) + { + var childNode = doc.CreateElement(settingsEntry.Key); + childNode.InnerText = settingsEntry.Value; + runConfigNode.AppendChild(childNode); + } - foreach (var settingsEntry in runConfigurationDictionary) - { - var childNode = doc.CreateElement(settingsEntry.Key); - childNode.InnerText = settingsEntry.Value; - runConfigNode.AppendChild(childNode); - } + Stream stream = new FileHelper().GetStream(destinationRunsettingsPath, FileMode.Create); + doc.Save(stream); + stream.Dispose(); + } - Stream stream = new FileHelper().GetStream(destinationRunsettingsPath, FileMode.Create); - doc.Save(stream); - stream.Dispose(); - } + /// + /// Create runsettings file at destinationRunsettingsPath with the content from xmlString + /// + /// + /// Destination runsettings path where resulted file is saved + /// + /// + /// Run settings xml string + /// + public static void CreateRunSettingsFile(string destinationRunsettingsPath, string runSettingsXml) + { + var doc = new XmlDocument(); + doc.LoadXml(runSettingsXml); + var stream = new FileHelper().GetStream(destinationRunsettingsPath, FileMode.Create); + doc.Save(stream); + stream.Dispose(); + } - /// - /// Create runsettings file at destinationRunsettingsPath with the content from xmlString - /// - /// - /// Destination runsettings path where resulted file is saved - /// - /// - /// Run settings xml string - /// - public static void CreateRunSettingsFile(string destinationRunsettingsPath, string runSettingsXml) + protected string BuildMultipleAssemblyPath(params string[] assetNames) + { + var assertFullPaths = new string[assetNames.Length]; + for (var i = 0; i < assetNames.Length; i++) { - var doc = new XmlDocument(); - doc.LoadXml(runSettingsXml); - var stream = new FileHelper().GetStream(destinationRunsettingsPath, FileMode.Create); - doc.Save(stream); - stream.Dispose(); + assertFullPaths[i] = GetAssetFullPath(assetNames[i]).AddDoubleQuote(); } - protected string BuildMultipleAssemblyPath(params string[] assetNames) - { - var assertFullPaths = new string[assetNames.Length]; - for (var i = 0; i < assetNames.Length; i++) - { - assertFullPaths[i] = this.GetAssetFullPath(assetNames[i]).AddDoubleQuote(); - } - - return string.Join(" ", assertFullPaths); - } + return string.Join(" ", assertFullPaths); + } - protected static string GetDiagArg(string rootDir) - => " --diag:" + Path.Combine(rootDir, "log.txt"); + protected static string GetDiagArg(string rootDir) + => " --diag:" + Path.Combine(rootDir, "log.txt"); - /// - /// Counts the number of logs following the '*.host.*' pattern in the given folder. - /// - protected static int CountTestHostLogs(string diagLogsDir, IEnumerable testHostProcessNames) - => Directory.GetFiles(diagLogsDir, "*.host.*") - .Count(filePath => + /// + /// Counts the number of logs following the '*.host.*' pattern in the given folder. + /// + protected static int CountTestHostLogs(string diagLogsDir, IEnumerable testHostProcessNames) + => Directory.GetFiles(diagLogsDir, "*.host.*") + .Count(filePath => + { + var firstLine = File.ReadLines(filePath).FirstOrDefault(); + return testHostProcessNames.Any(processName => { - var firstLine = File.ReadLines(filePath).FirstOrDefault(); - return testHostProcessNames.Any(processName => + var parts = processName.Split('.'); + if (parts.Length > 2) { - var parts = processName.Split('.'); - if (parts.Length > 2) - { - throw new InvalidOperationException(""); - } - - var hostName = parts[0]; - var platformName = parts.Length > 1 ? @$"\.{parts[1]}" : string.Empty; - - var isMatch = Regex.IsMatch(firstLine, @$",\s{hostName}(?:\.net\d+)?{platformName}\.(?:exe|dll),"); - return isMatch; - }); + throw new InvalidOperationException(""); + } + + var hostName = parts[0]; + var platformName = parts.Length > 1 ? @$"\.{parts[1]}" : string.Empty; + + var isMatch = Regex.IsMatch(firstLine, @$",\s{hostName}(?:\.net\d+)?{platformName}\.(?:exe|dll),"); + return isMatch; }); + }); - protected static void AssertExpectedNumberOfHostProcesses(int expectedNumOfProcessCreated, string diagLogsDir, IEnumerable testHostProcessNames, string arguments = null, string runnerPath = null) - { - var processCreatedCount = CountTestHostLogs(diagLogsDir, testHostProcessNames); - Assert.AreEqual( - expectedNumOfProcessCreated, - processCreatedCount, - $"Number of {string.Join(", ", testHostProcessNames)} process created, expected: {expectedNumOfProcessCreated} actual: {processCreatedCount} {(arguments == null ? "" : "args: " + arguments)} {(runnerPath == null ? "" : "runner path: " + runnerPath)}"); - } + protected static void AssertExpectedNumberOfHostProcesses(int expectedNumOfProcessCreated, string diagLogsDir, IEnumerable testHostProcessNames, string arguments = null, string runnerPath = null) + { + var processCreatedCount = CountTestHostLogs(diagLogsDir, testHostProcessNames); + Assert.AreEqual( + expectedNumOfProcessCreated, + processCreatedCount, + $"Number of {string.Join(", ", testHostProcessNames)} process created, expected: {expectedNumOfProcessCreated} actual: {processCreatedCount} {(arguments == null ? "" : "args: " + arguments)} {(runnerPath == null ? "" : "runner path: " + runnerPath)}"); + } - protected static string GetDownloadedDotnetMuxerFromTools(string architecture) + protected static string GetDownloadedDotnetMuxerFromTools(string architecture) + { + if (architecture != "X86" && architecture != "X64") { - if (architecture != "X86" && architecture != "X64") - { - throw new NotSupportedException(nameof(architecture)); - } - - string path = Path.Combine(IntegrationTestEnvironment.TestPlatformRootDirectory, "tools", - architecture == "X86" ? - "dotnet_x86" : - $"dotnet", - $"dotnet{(IsWindows ? ".exe" : "")}"); + throw new NotSupportedException(nameof(architecture)); + } - Assert.IsTrue(File.Exists(path)); + string path = Path.Combine(IntegrationTestEnvironment.TestPlatformRootDirectory, "tools", + architecture == "X86" ? + "dotnet_x86" : + $"dotnet", + $"dotnet{(IsWindows ? ".exe" : "")}"); - return path; - } + Assert.IsTrue(File.Exists(path)); - protected static string GetDotnetRunnerPath() => Path.Combine(IntegrationTestEnvironment.TestPlatformRootDirectory, "artifacts", IntegrationTestEnvironment.BuildConfiguration, "netcoreapp2.1", "vstest.console.dll"); + return path; } + + protected static string GetDotnetRunnerPath() => Path.Combine(IntegrationTestEnvironment.TestPlatformRootDirectory, "artifacts", IntegrationTestEnvironment.BuildConfiguration, "netcoreapp2.1", "vstest.console.dll"); } diff --git a/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestEnvironment.cs b/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestEnvironment.cs index a56217f37d..e2cacdf640 100644 --- a/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestEnvironment.cs +++ b/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestEnvironment.cs @@ -1,331 +1,326 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.TestUtilities -{ - using System; - using System.Collections.Generic; - using System.IO; - using System.Xml; - - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.TestUtilities; - /// - /// Provider for test environment configuration. - /// Currently reads configuration from environment variables. We may support a - /// different provider later. E.g. run settings. - /// - public class IntegrationTestEnvironment - { - public static string TestPlatformRootDirectory = Environment.GetEnvironmentVariable("TP_ROOT_DIR") - ?? Path.GetFullPath(@"..\..\..\..\..".Replace('\\', Path.DirectorySeparatorChar)); +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml; - private static Dictionary dependencyVersions; +using VisualStudio.TestTools.UnitTesting; - private string targetRuntime; +/// +/// Provider for test environment configuration. +/// Currently reads configuration from environment variables. We may support a +/// different provider later. E.g. run settings. +/// +public class IntegrationTestEnvironment +{ + public static string TestPlatformRootDirectory = + Environment.GetEnvironmentVariable("TP_ROOT_DIR") + ?? Path.GetFullPath(@"..\..\..\..\..".Replace('\\', Path.DirectorySeparatorChar)); - public IntegrationTestEnvironment() - { - // These environment variables are set in scripts/test.ps1 or scripts/test.sh. - this.TargetFramework = Environment.GetEnvironmentVariable("TPT_TargetFramework"); - this.TargetRuntime = Environment.GetEnvironmentVariable("TPT_TargetRuntime"); + private static Dictionary s_dependencyVersions; - // If the variables are not set, valid defaults are assumed. - if (string.IsNullOrEmpty(this.TargetFramework)) - { - // Run integration tests for net451 by default. - this.TargetFramework = "net451"; - } + private string _targetRuntime; - if (string.IsNullOrEmpty(TestPlatformRootDirectory)) - { - // Running in VS/IDE. Use artifacts directory as root. - // Get root directory from test assembly output directory - TestPlatformRootDirectory = Path.GetFullPath(@"..\..\..\..\..".Replace('\\', Path.DirectorySeparatorChar)); - } + public IntegrationTestEnvironment() + { + // These environment variables are set in scripts/test.ps1 or scripts/test.sh. + TargetFramework = Environment.GetEnvironmentVariable("TPT_TargetFramework"); + TargetRuntime = Environment.GetEnvironmentVariable("TPT_TargetRuntime"); - this.TestAssetsPath = Path.Combine(TestPlatformRootDirectory, $@"test{Path.DirectorySeparatorChar}TestAssets"); + // If the variables are not set, valid defaults are assumed. + if (string.IsNullOrEmpty(TargetFramework)) + { + // Run integration tests for net451 by default. + TargetFramework = "net451"; + } - // There is an assumption that integration tests will always run from a source enlistment. - // Need to remove this assumption when we move to a CDP. - this.PackageDirectory = Path.Combine(TestPlatformRootDirectory, @"packages"); - this.ToolsDirectory = Path.Combine(TestPlatformRootDirectory, @"tools"); - this.TestArtifactsDirectory = Path.Combine(TestPlatformRootDirectory, "artifacts", "testArtifacts"); - this.RunnerFramework = "net451"; + if (string.IsNullOrEmpty(TestPlatformRootDirectory)) + { + // Running in VS/IDE. Use artifacts directory as root. + // Get root directory from test assembly output directory + TestPlatformRootDirectory = Path.GetFullPath(@"..\..\..\..\..".Replace('\\', Path.DirectorySeparatorChar)); } - /// - /// Gets the build configuration for the test run. - /// - public static string BuildConfiguration + TestAssetsPath = Path.Combine(TestPlatformRootDirectory, $@"test{Path.DirectorySeparatorChar}TestAssets"); + + // There is an assumption that integration tests will always run from a source enlistment. + // Need to remove this assumption when we move to a CDP. + PackageDirectory = Path.Combine(TestPlatformRootDirectory, @"packages"); + ToolsDirectory = Path.Combine(TestPlatformRootDirectory, @"tools"); + TestArtifactsDirectory = Path.Combine(TestPlatformRootDirectory, "artifacts", "testArtifacts"); + RunnerFramework = "net451"; + } + + /// + /// Gets the build configuration for the test run. + /// + public static string BuildConfiguration + { + get { - get - { #if DEBUG - return "Debug"; + return "Debug"; #else - return "Release"; + return "Release"; #endif - } } + } - public Dictionary DependencyVersions + public Dictionary DependencyVersions + { + get { - get + if (s_dependencyVersions == null) { - if (dependencyVersions == null) - { - dependencyVersions = GetDependencies(TestPlatformRootDirectory); - } - - return dependencyVersions; + s_dependencyVersions = GetDependencies(TestPlatformRootDirectory); } - } - /// - /// Gets the nuget packages directory for enlistment. - /// - public string PackageDirectory - { - get; - private set; + return s_dependencyVersions; } + } - /// - /// Gets the publish directory for vstest.console package. - /// - public string PublishDirectory + /// + /// Gets the nuget packages directory for enlistment. + /// + public string PackageDirectory + { + get; + private set; + } + + /// + /// Gets the publish directory for vstest.console package. + /// + public string PublishDirectory + { + get { - get - { - // this used to switch to src\package\package\bin\based on whether - // this is running in cli, but that's a bad idea, the console there does not have - // a runtime config and will fail to start with error testhostpolicy.dll not found - var publishDirectory = Path.Combine( - TestPlatformRootDirectory, - "artifacts", - BuildConfiguration, - this.RunnerFramework, - this.TargetRuntime); - - if (!Directory.Exists(publishDirectory)) - { - throw new InvalidOperationException($"Path '{publishDirectory}' does not exist, did you build the solution via build.cmd?"); - } + // this used to switch to src\package\package\bin\based on whether + // this is running in cli, but that's a bad idea, the console there does not have + // a runtime config and will fail to start with error testhostpolicy.dll not found + var publishDirectory = Path.Combine( + TestPlatformRootDirectory, + "artifacts", + BuildConfiguration, + RunnerFramework, + TargetRuntime); - return publishDirectory; - } + return !Directory.Exists(publishDirectory) + ? throw new InvalidOperationException($"Path '{publishDirectory}' does not exist, did you build the solution via build.cmd?") + : publishDirectory; } + } - /// - /// Gets the extensions directory for vstest.console package. - /// - public string ExtensionsDirectory => Path.Combine(PublishDirectory, "Extensions"); + /// + /// Gets the extensions directory for vstest.console package. + /// + public string ExtensionsDirectory => Path.Combine(PublishDirectory, "Extensions"); - /// - /// Gets the target framework. - /// Supported values = net451, netcoreapp1.0. - /// - public string TargetFramework - { - get; - set; - } + /// + /// Gets the target framework. + /// Supported values = net451, netcoreapp1.0. + /// + public string TargetFramework + { + get; + set; + } - /// - /// Gets the target runtime. - /// Supported values = win7-x64. - /// - public string TargetRuntime + /// + /// Gets the target runtime. + /// Supported values = win7-x64. + /// + public string TargetRuntime + { + get { - get + if (RunnerFramework == IntegrationTestBase.DesktopRunnerFramework) { - if (this.RunnerFramework == IntegrationTestBase.DesktopRunnerFramework) + if (string.IsNullOrEmpty(_targetRuntime)) { - if (string.IsNullOrEmpty(this.targetRuntime)) - { - this.targetRuntime = "win7-x64"; - } - } - else - { - this.targetRuntime = ""; + _targetRuntime = "win7-x64"; } - - return this.targetRuntime; } - set + else { - this.targetRuntime = value; + _targetRuntime = ""; } - } - /// - /// Gets the inIsolation. - /// Supported values = /InIsolation. - /// - public string InIsolationValue - { - get; set; + return _targetRuntime; } - - /// - /// Gets the root directory for test assets. - /// - public string TestAssetsPath + set { - get; + _targetRuntime = value; } + } - /// - /// Gets the tools directory for dependent tools - /// - public string ToolsDirectory - { - get; - private set; - } + /// + /// Gets the inIsolation. + /// Supported values = /InIsolation. + /// + public string InIsolationValue + { + get; set; + } - /// - /// Gets the test artifacts directory. - /// - public string TestArtifactsDirectory - { - get; - private set; - } + /// + /// Gets the root directory for test assets. + /// + public string TestAssetsPath + { + get; + } - /// - /// Gets the application type. - /// Supported values = net451, netcoreapp1.0. - /// - public string RunnerFramework - { - get; - set; - } + /// + /// Gets the tools directory for dependent tools + /// + public string ToolsDirectory + { + get; + private set; + } - /// - /// Gets the full path to a test asset. - /// - /// Name of the asset with extension. E.g. SimpleUnitTest.dll - /// Full path to the test asset. - /// - /// Test assets follow several conventions: - /// (a) They are built for supported frameworks. See . - /// (b) They are built for provided build configuration. - /// (c) Name of the test asset matches the parent directory name. E.g. TestAssets\SimpleUnitTest\SimpleUnitTest.csproj must - /// produce TestAssets\SimpleUnitTest\bin\Debug\net451\SimpleUnitTest.dll - /// - public string GetTestAsset(string assetName) - { - return GetTestAsset(assetName, this.TargetFramework); - } + /// + /// Gets the test artifacts directory. + /// + public string TestArtifactsDirectory + { + get; + private set; + } - /// - /// Gets the full path to a test asset. - /// - /// Name of the asset with extension. E.g. SimpleUnitTest.dll - /// asset project target framework. E.g net451 - /// Full path to the test asset. - /// - /// Test assets follow several conventions: - /// (a) They are built for supported frameworks. See . - /// (b) They are built for provided build configuration. - /// (c) Name of the test asset matches the parent directory name. E.g. TestAssets\SimpleUnitTest\SimpleUnitTest.csproj must - /// produce TestAssets\SimpleUnitTest\bin\Debug\net451\SimpleUnitTest.dll - /// - public string GetTestAsset(string assetName, string targetFramework) - { - var simpleAssetName = Path.GetFileNameWithoutExtension(assetName); - var assetPath = Path.Combine( - this.TestAssetsPath, - simpleAssetName, - "bin", - BuildConfiguration, - targetFramework, - assetName); + /// + /// Gets the application type. + /// Supported values = net451, netcoreapp1.0. + /// + public string RunnerFramework + { + get; + set; + } - Assert.IsTrue(File.Exists(assetPath), "GetTestAsset: Path not found: {0}.", assetPath); + /// + /// Gets the full path to a test asset. + /// + /// Name of the asset with extension. E.g. SimpleUnitTest.dll + /// Full path to the test asset. + /// + /// Test assets follow several conventions: + /// (a) They are built for supported frameworks. See . + /// (b) They are built for provided build configuration. + /// (c) Name of the test asset matches the parent directory name. E.g. TestAssets\SimpleUnitTest\SimpleUnitTest.csproj must + /// produce TestAssets\SimpleUnitTest\bin\Debug\net451\SimpleUnitTest.dll + /// + public string GetTestAsset(string assetName) + { + return GetTestAsset(assetName, TargetFramework); + } - return assetPath; - } + /// + /// Gets the full path to a test asset. + /// + /// Name of the asset with extension. E.g. SimpleUnitTest.dll + /// asset project target framework. E.g net451 + /// Full path to the test asset. + /// + /// Test assets follow several conventions: + /// (a) They are built for supported frameworks. See . + /// (b) They are built for provided build configuration. + /// (c) Name of the test asset matches the parent directory name. E.g. TestAssets\SimpleUnitTest\SimpleUnitTest.csproj must + /// produce TestAssets\SimpleUnitTest\bin\Debug\net451\SimpleUnitTest.dll + /// + public string GetTestAsset(string assetName, string targetFramework) + { + var simpleAssetName = Path.GetFileNameWithoutExtension(assetName); + var assetPath = Path.Combine( + TestAssetsPath, + simpleAssetName, + "bin", + BuildConfiguration, + targetFramework, + assetName); + + Assert.IsTrue(File.Exists(assetPath), "GetTestAsset: Path not found: {0}.", assetPath); + + return assetPath; + } - /// - /// Gets the full path to a nuget package. - /// - /// Suffix for the nuget package. - /// Complete path to a nuget package. - /// GetNugetPackage("foobar") will return a path to packages\foobar. - public string GetNugetPackage(string packageSuffix) - { - var packagePath = Path.Combine(this.PackageDirectory, packageSuffix); + /// + /// Gets the full path to a nuget package. + /// + /// Suffix for the nuget package. + /// Complete path to a nuget package. + /// GetNugetPackage("foobar") will return a path to packages\foobar. + public string GetNugetPackage(string packageSuffix) + { + var packagePath = Path.Combine(PackageDirectory, packageSuffix); - Assert.IsTrue(Directory.Exists(packagePath), "GetNugetPackage: Directory not found: {0}.", packagePath); + Assert.IsTrue(Directory.Exists(packagePath), "GetNugetPackage: Directory not found: {0}.", packagePath); - return packagePath; - } + return packagePath; + } - private static Dictionary GetDependencies(string testPlatformRoot) + private static Dictionary GetDependencies(string testPlatformRoot) + { + var dependencyPropsFile = Path.Combine(testPlatformRoot, @"scripts\build\TestPlatform.Dependencies.props".Replace('\\', Path.DirectorySeparatorChar)); + var dependencyProps = new Dictionary(); + if (!File.Exists(dependencyPropsFile)) { - var dependencyPropsFile = Path.Combine(testPlatformRoot, @"scripts\build\TestPlatform.Dependencies.props".Replace('\\', Path.DirectorySeparatorChar)); - var dependencyProps = new Dictionary(); - if (!File.Exists(dependencyPropsFile)) - { - throw new FileNotFoundException("Dependency props file not found: " + dependencyPropsFile); - } + throw new FileNotFoundException("Dependency props file not found: " + dependencyPropsFile); + } - using (var reader = XmlReader.Create(dependencyPropsFile)) + using (var reader = XmlReader.Create(dependencyPropsFile)) + { + reader.ReadToFollowing("PropertyGroup"); + using var props = reader.ReadSubtree(); + props.MoveToContent(); + props.Read(); // Read thru the PropertyGroup node + while (!props.EOF) { - reader.ReadToFollowing("PropertyGroup"); - using (var props = reader.ReadSubtree()) + if (props.IsStartElement() && !string.IsNullOrEmpty(props.Name)) { - props.MoveToContent(); - props.Read(); // Read thru the PropertyGroup node - while (!props.EOF) + if (!dependencyProps.ContainsKey(props.Name)) + { + dependencyProps.Add(props.Name, props.ReadElementContentAsString()); + } + else { - if (props.IsStartElement() && !string.IsNullOrEmpty(props.Name)) - { - if (!dependencyProps.ContainsKey(props.Name)) - { - dependencyProps.Add(props.Name, props.ReadElementContentAsString()); - } - else - { - dependencyProps[props.Name] = string.Join(", ", dependencyProps[props.Name], props.ReadElementContentAsString()); - } - } - props.Read(); + dependencyProps[props.Name] = string.Join(", ", dependencyProps[props.Name], props.ReadElementContentAsString()); } } + props.Read(); } - - return dependencyProps; } - /// - /// Gets the full path to a test asset. - /// - /// Name of the asset with extension. E.g. SimpleUnitTest.csproj - /// Full path to the test asset. - /// - /// Test assets follow several conventions: - /// (a) They are built for supported frameworks. See . - /// (b) They are built for provided build configuration. - /// (c) Name of the test asset matches the parent directory name. E.g. TestAssets\SimpleUnitTest\SimpleUnitTest.csproj must - /// produce TestAssets\SimpleUnitTest\SimpleUnitTest.csproj - /// - public string GetTestProject(string assetName) - { - var simpleAssetName = Path.GetFileNameWithoutExtension(assetName); - var assetPath = Path.Combine( - this.TestAssetsPath, - simpleAssetName, - assetName); + return dependencyProps; + } - Assert.IsTrue(File.Exists(assetPath), "GetTestAsset: Path not found: {0}.", assetPath); + /// + /// Gets the full path to a test asset. + /// + /// Name of the asset with extension. E.g. SimpleUnitTest.csproj + /// Full path to the test asset. + /// + /// Test assets follow several conventions: + /// (a) They are built for supported frameworks. See . + /// (b) They are built for provided build configuration. + /// (c) Name of the test asset matches the parent directory name. E.g. TestAssets\SimpleUnitTest\SimpleUnitTest.csproj must + /// produce TestAssets\SimpleUnitTest\SimpleUnitTest.csproj + /// + public string GetTestProject(string assetName) + { + var simpleAssetName = Path.GetFileNameWithoutExtension(assetName); + var assetPath = Path.Combine( + TestAssetsPath, + simpleAssetName, + assetName); - return assetPath; - } + Assert.IsTrue(File.Exists(assetPath), "GetTestAsset: Path not found: {0}.", assetPath); + + return assetPath; } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.TestUtilities/PerfInstrumentation/Constants.cs b/test/Microsoft.TestPlatform.TestUtilities/PerfInstrumentation/Constants.cs index fd5e633154..1d1c8adc38 100644 --- a/test/Microsoft.TestPlatform.TestUtilities/PerfInstrumentation/Constants.cs +++ b/test/Microsoft.TestPlatform.TestUtilities/PerfInstrumentation/Constants.cs @@ -1,70 +1,69 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.TestUtilities.PerfInstrumentation +namespace Microsoft.TestPlatform.TestUtilities.PerfInstrumentation; + +/// +/// The constants. +/// +public class Constants { /// - /// The constants. + /// The discovery task. /// - public class Constants - { - /// - /// The discovery task. - /// - public const string DiscoveryTask = "Discovery"; + public const string DiscoveryTask = "Discovery"; - /// - /// The execution task. - /// - public const string ExecutionTask = "Execution"; + /// + /// The execution task. + /// + public const string ExecutionTask = "Execution"; - /// - /// The execution request task. - /// - public const string ExecutionRequestTask = "ExecutionRequest"; + /// + /// The execution request task. + /// + public const string ExecutionRequestTask = "ExecutionRequest"; - /// - /// The discovery request task. - /// - public const string DiscoveryRequestTask = "DiscoveryRequest"; + /// + /// The discovery request task. + /// + public const string DiscoveryRequestTask = "DiscoveryRequest"; - /// - /// The test host task. - /// - public const string TestHostTask = "TestHost"; + /// + /// The test host task. + /// + public const string TestHostTask = "TestHost"; - /// - /// The vs test console task. - /// - public const string VsTestConsoleTask = "VsTestConsole"; + /// + /// The vs test console task. + /// + public const string VsTestConsoleTask = "VsTestConsole"; - /// - /// The adapter search task. - /// - public const string AdapterSearchTask = "AdapterSearch"; + /// + /// The adapter search task. + /// + public const string AdapterSearchTask = "AdapterSearch"; - /// - /// The adapter execution task. - /// - public const string AdapterExecutionTask = "AdapterExecution"; + /// + /// The adapter execution task. + /// + public const string AdapterExecutionTask = "AdapterExecution"; - /// - /// The adapter discovery task. - /// - public const string AdapterDiscoveryTask = "AdapterDiscovery"; + /// + /// The adapter discovery task. + /// + public const string AdapterDiscoveryTask = "AdapterDiscovery"; - #region PayLoad Property Names + #region PayLoad Property Names - /// - /// The execution uri property. - /// - public const string ExecutionUriProperty = "executorUri"; + /// + /// The execution uri property. + /// + public const string ExecutionUriProperty = "executorUri"; - /// - /// The number of tests property. - /// - public const string NumberOfTestsProperty = "numberOfTests"; - #endregion + /// + /// The number of tests property. + /// + public const string NumberOfTestsProperty = "numberOfTests"; + #endregion - } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.TestUtilities/PerfInstrumentation/PerfAnalyzer.cs b/test/Microsoft.TestPlatform.TestUtilities/PerfInstrumentation/PerfAnalyzer.cs index 2cc24960b6..2c1eac24f2 100644 --- a/test/Microsoft.TestPlatform.TestUtilities/PerfInstrumentation/PerfAnalyzer.cs +++ b/test/Microsoft.TestPlatform.TestUtilities/PerfInstrumentation/PerfAnalyzer.cs @@ -1,243 +1,240 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.TestUtilities.PerfInstrumentation -{ - using System.Collections.Generic; +namespace Microsoft.TestPlatform.TestUtilities.PerfInstrumentation; + +using System.Collections.Generic; #if NETFRAMEWORK - using Microsoft.Diagnostics.Tracing; - using Microsoft.Diagnostics.Tracing.Parsers; - using Microsoft.Diagnostics.Tracing.Session; - using System; - using System.Linq; +using Diagnostics.Tracing; +using Diagnostics.Tracing.Parsers; +using Diagnostics.Tracing.Session; +using System; +using System.Linq; #endif +/// +/// The performance analyzer. +/// +public class PerfAnalyzer +{ /// - /// The performance analyzer. + /// The etw session provider name. /// - public class PerfAnalyzer - { - /// - /// The etw session provider name. - /// - private const string ETWSessionProviderName = "TestPlatform"; + private const string EtwSessionProviderName = "TestPlatform"; #if NETFRAMEWORK - private string perfDataFileName; - private TraceEventSession traceEventSession; - private Dictionary> testPlatformTaskMap; + private readonly string _perfDataFileName; + private readonly TraceEventSession _traceEventSession; + private readonly Dictionary> _testPlatformTaskMap; #endif - /// - /// Initializes a new instance of the class. - /// - public PerfAnalyzer() - { + /// + /// Initializes a new instance of the class. + /// + public PerfAnalyzer() + { #if NETFRAMEWORK - this.perfDataFileName = "TestPlatformEventsData.etl"; - this.testPlatformTaskMap = new Dictionary>(); - this.traceEventSession = new TraceEventSession("TestPlatformSession", this.perfDataFileName); + _perfDataFileName = "TestPlatformEventsData.etl"; + _testPlatformTaskMap = new Dictionary>(); + _traceEventSession = new TraceEventSession("TestPlatformSession", _perfDataFileName); #endif - } + } - /// - /// The enable provider. - /// - public void EnableProvider() - { + /// + /// The enable provider. + /// + public void EnableProvider() + { #if NETFRAMEWORK - this.traceEventSession.StopOnDispose = true; - this.traceEventSession.EnableProvider(ETWSessionProviderName); + _traceEventSession.StopOnDispose = true; + _traceEventSession.EnableProvider(EtwSessionProviderName); #endif - } + } - /// - /// The disable provider. - /// - public void DisableProvider() - { + /// + /// The disable provider. + /// + public void DisableProvider() + { #if NETFRAMEWORK - this.traceEventSession.Dispose(); + _traceEventSession.Dispose(); #endif - } + } - /// - /// The analyze events data. - /// - public void AnalyzeEventsData() - { + /// + /// The analyze events data. + /// + public void AnalyzeEventsData() + { #if NETFRAMEWORK - using (var source = new ETWTraceEventSource(this.perfDataFileName)) + using var source = new ETWTraceEventSource(_perfDataFileName); + // Open the file + var parser = new DynamicTraceEventParser(source); + parser.All += delegate (TraceEvent data) + { + try { - // Open the file - var parser = new DynamicTraceEventParser(source); - parser.All += delegate(TraceEvent data) + if (data.ProviderName.Equals("TestPlatform") && !data.EventName.Equals("ManifestData")) + { + Console.WriteLine("Received Event : {0}", data.ToString()); + var key = data.ProcessID + "_" + data.ThreadID.ToString() + "_" + data.TaskName; + + if (!_testPlatformTaskMap.ContainsKey(key)) + { + var list = new List { CreateTestPlatformTask(data) }; + _testPlatformTaskMap.Add(key, list); + } + else { - try + if (data.Opcode == TraceEventOpcode.Start) { - if (data.ProviderName.Equals("TestPlatform") && !data.EventName.Equals("ManifestData")) - { - Console.WriteLine("Received Event : {0}", data.ToString()); - var key = data.ProcessID + "_" + data.ThreadID.ToString() + "_" + data.TaskName; - - if (!testPlatformTaskMap.ContainsKey(key)) - { - var list = new List { CreateTestPlatformTask(data) }; - testPlatformTaskMap.Add(key, list); - } - else - { - if (data.Opcode == TraceEventOpcode.Start) - { - testPlatformTaskMap[key].Add(CreateTestPlatformTask(data)); - } - else - { - UpdateTask(testPlatformTaskMap[key].Last(), data); - } - } - } + _testPlatformTaskMap[key].Add(CreateTestPlatformTask(data)); } - catch (Exception ex) + else { - Console.WriteLine(ex.ToString()); + UpdateTask(_testPlatformTaskMap[key].Last(), data); } - }; - source.Process(); // Read the file, processing the callbacks. + } + } } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + }; + source.Process(); // Read the file, processing the callbacks. #endif - } + } - /// - /// The get elapsed time by task name. - /// - /// - /// The task name. - /// - /// - /// The . - /// - public double GetElapsedTimeByTaskName(string taskName) - { - var timeTaken = 0.0; + /// + /// The get elapsed time by task name. + /// + /// + /// The task name. + /// + /// + /// The . + /// + public double GetElapsedTimeByTaskName(string taskName) + { + var timeTaken = 0.0; #if NETFRAMEWORK - var key = GetEventKey(taskName); + var key = GetEventKey(taskName); - if (key != null) - { - var task = testPlatformTaskMap[key].First(); - timeTaken = task.EventStopped - task.EventStarted; - } -#endif - return timeTaken; + if (key != null) + { + var task = _testPlatformTaskMap[key].First(); + timeTaken = task.EventStopped - task.EventStarted; } +#endif + return timeTaken; + } - /// - /// The get event data by task name. - /// - /// - /// The task name. - /// - /// - /// The . - /// - public IDictionary GetEventDataByTaskName(string taskName) - { - IDictionary properties = new Dictionary(); + /// + /// The get event data by task name. + /// + /// + /// The task name. + /// + /// + /// The . + /// + public IDictionary GetEventDataByTaskName(string taskName) + { + IDictionary properties = new Dictionary(); #if NETFRAMEWORK - var key = GetEventKey(taskName); + var key = GetEventKey(taskName); - if(key != null) - { - properties = testPlatformTaskMap[key].First().PayLoadProperties; - } -#endif - return properties; + if (key != null) + { + properties = _testPlatformTaskMap[key].First().PayLoadProperties; } +#endif + return properties; + } - public double GetAdapterExecutionTime(string executorUri) - { - var timeTaken = 0.0; + public double GetAdapterExecutionTime(string executorUri) + { + var timeTaken = 0.0; #if NETFRAMEWORK - var key = GetEventKey(Constants.AdapterExecutionTask); + var key = GetEventKey(Constants.AdapterExecutionTask); - if(key != null) - { - var task = testPlatformTaskMap[key].Find(t => t.PayLoadProperties["executorUri"].Equals(executorUri)); - timeTaken = task.EventStopped - task.EventStarted; - } -#endif - return timeTaken; + if (key != null) + { + var task = _testPlatformTaskMap[key].Find(t => t.PayLoadProperties["executorUri"].Equals(executorUri)); + timeTaken = task.EventStopped - task.EventStarted; } +#endif + return timeTaken; + } - public long GetAdapterExecutedTests(string executorUri) - { - long totalTestsExecuted = 0; + public long GetAdapterExecutedTests(string executorUri) + { + long totalTestsExecuted = 0; #if NETFRAMEWORK - var key = GetEventKey(Constants.AdapterExecutionTask); + var key = GetEventKey(Constants.AdapterExecutionTask); - if (key != null) - { - var task = testPlatformTaskMap[key].Find(t => t.PayLoadProperties["executorUri"].Equals(executorUri)); - long.TryParse(task.PayLoadProperties["numberOfTests"], out totalTestsExecuted); - } -#endif - return totalTestsExecuted; + if (key != null) + { + var task = _testPlatformTaskMap[key].Find(t => t.PayLoadProperties["executorUri"].Equals(executorUri)); + long.TryParse(task.PayLoadProperties["numberOfTests"], out totalTestsExecuted); } +#endif + return totalTestsExecuted; + } #if NETFRAMEWORK - private string GetEventKey(string taskName) - { - string key = null; + private string GetEventKey(string taskName) + { + string key = null; - key = testPlatformTaskMap.Keys.FirstOrDefault(k => k.Split('_')[2].Equals(taskName)); + key = _testPlatformTaskMap.Keys.FirstOrDefault(k => k.Split('_')[2].Equals(taskName)); - return key; - } + return key; + } - private static TestPlatformTask CreateTestPlatformTask(TraceEvent data) - { - var task = new TestPlatformTask(data.TaskName, data.TimeStampRelativeMSec); - task.PayLoadProperties = GetPayloadProperties(data); - return task; - } + private static TestPlatformTask CreateTestPlatformTask(TraceEvent data) + { + var task = new TestPlatformTask(data.TaskName, data.TimeStampRelativeMSec); + task.PayLoadProperties = GetPayloadProperties(data); + return task; + } - private static void UpdateTask(TestPlatformTask task, TraceEvent data) - { - task.EventStopped = data.TimeStampRelativeMSec; - var payLoadProperties = GetPayloadProperties(data); + private static void UpdateTask(TestPlatformTask task, TraceEvent data) + { + task.EventStopped = data.TimeStampRelativeMSec; + var payLoadProperties = GetPayloadProperties(data); - //Merging dictionaries look for better way - foreach (var k in payLoadProperties.Keys) + //Merging dictionaries look for better way + foreach (var k in payLoadProperties.Keys) + { + if (!task.PayLoadProperties.ContainsKey(k)) { - if (!task.PayLoadProperties.ContainsKey(k)) - { - task.PayLoadProperties.Add(k, payLoadProperties[k]); - } + task.PayLoadProperties.Add(k, payLoadProperties[k]); } } + } - private static IDictionary GetPayloadProperties(TraceEvent data) - { - var payLoadProperties = new Dictionary(); + private static IDictionary GetPayloadProperties(TraceEvent data) + { + var payLoadProperties = new Dictionary(); - foreach (var payLoad in data.PayloadNames) + foreach (var payLoad in data.PayloadNames) + { + var payLoadData = data.PayloadByName(payLoad).ToString(); + if (!payLoadProperties.ContainsKey(payLoad)) { - var payLoadData = data.PayloadByName(payLoad).ToString(); - if (!payLoadProperties.ContainsKey(payLoad)) - { - payLoadProperties.Add(payLoad, payLoadData); - } - else - { - payLoadProperties[payLoad] = payLoadData; - } + payLoadProperties.Add(payLoad, payLoadData); + } + else + { + payLoadProperties[payLoad] = payLoadData; } - - return payLoadProperties; } -#endif + + return payLoadProperties; } -} +#endif +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.TestUtilities/PerfInstrumentation/PerformanceTestBase.cs b/test/Microsoft.TestPlatform.TestUtilities/PerfInstrumentation/PerformanceTestBase.cs index 476d7c7684..747308cd5b 100644 --- a/test/Microsoft.TestPlatform.TestUtilities/PerfInstrumentation/PerformanceTestBase.cs +++ b/test/Microsoft.TestPlatform.TestUtilities/PerfInstrumentation/PerformanceTestBase.cs @@ -1,132 +1,131 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.TestUtilities.PerfInstrumentation +namespace Microsoft.TestPlatform.TestUtilities.PerfInstrumentation; + +using System.Collections.Generic; + +/// +/// The performance test base. +/// +public class PerformanceTestBase : IntegrationTestBase { - using System.Collections.Generic; + private readonly PerfAnalyzer _perfAnalyzer; /// - /// The performance test base. + /// Initializes a new instance of the class. /// - public class PerformanceTestBase : IntegrationTestBase + public PerformanceTestBase() + : base() { - private PerfAnalyzer perfAnalyzer; - - /// - /// Initializes a new instance of the class. - /// - public PerformanceTestBase() - : base() - { - this.perfAnalyzer = new PerfAnalyzer(); - } - - /// - /// The run execution performance tests. - /// - /// - /// The test asset. - /// - /// - /// The test adapter path. - /// - /// - /// The run settings. - /// - public void RunExecutionPerformanceTests(string testAsset, string testAdapterPath, string runSettings) - { - // Start session and listen + _perfAnalyzer = new PerfAnalyzer(); + } + + /// + /// The run execution performance tests. + /// + /// + /// The test asset. + /// + /// + /// The test adapter path. + /// + /// + /// The run settings. + /// + public void RunExecutionPerformanceTests(string testAsset, string testAdapterPath, string runSettings) + { + // Start session and listen #if NETFRAMEWORK - this.perfAnalyzer.EnableProvider(); + _perfAnalyzer.EnableProvider(); #endif - // Run Test - this.InvokeVsTestForExecution(testAsset, testAdapterPath, ".NETFramework,Version=v4.5.1", runSettings); + // Run Test + InvokeVsTestForExecution(testAsset, testAdapterPath, ".NETFramework,Version=v4.5.1", runSettings); - // Stop Listening + // Stop Listening #if NETFRAMEWORK - this.perfAnalyzer.DisableProvider(); + _perfAnalyzer.DisableProvider(); #endif - } - - /// - /// The run discovery performance tests. - /// - /// - /// The test asset. - /// - /// - /// The test adapter path. - /// - /// - /// The run settings. - /// - public void RunDiscoveryPerformanceTests(string testAsset, string testAdapterPath, string runSettings) - { - // Start session and listen + } + + /// + /// The run discovery performance tests. + /// + /// + /// The test asset. + /// + /// + /// The test adapter path. + /// + /// + /// The run settings. + /// + public void RunDiscoveryPerformanceTests(string testAsset, string testAdapterPath, string runSettings) + { + // Start session and listen #if NETFRAMEWORK - this.perfAnalyzer.EnableProvider(); + _perfAnalyzer.EnableProvider(); #endif - // Run Test - this.InvokeVsTestForDiscovery(testAsset, testAdapterPath, runSettings, ".NETFramework,Version=v4.5.1"); + // Run Test + InvokeVsTestForDiscovery(testAsset, testAdapterPath, runSettings, ".NETFramework,Version=v4.5.1"); - // Stop Listening + // Stop Listening #if NETFRAMEWORK - this.perfAnalyzer.DisableProvider(); + _perfAnalyzer.DisableProvider(); #endif - } - - /// - /// The analyze performance data. - /// - public void AnalyzePerfData() - { - this.perfAnalyzer.AnalyzeEventsData(); - } - - /// - /// The get execution time. - /// - /// - /// The . - /// - public double GetExecutionTime() - { - return this.perfAnalyzer.GetElapsedTimeByTaskName(Constants.ExecutionTask); - } - - public double GetDiscoveryTime() - { - return this.perfAnalyzer.GetElapsedTimeByTaskName(Constants.DiscoveryTask); - } - - public double GetVsTestTime() - { - return this.perfAnalyzer.GetElapsedTimeByTaskName(Constants.VsTestConsoleTask); - } - - public double GetTestHostTime() - { - return this.perfAnalyzer.GetElapsedTimeByTaskName(Constants.TestHostTask); - } - - public double GetAdapterSearchTime() - { - return this.perfAnalyzer.GetElapsedTimeByTaskName(Constants.AdapterSearchTask); - } - - public IDictionary GetDiscoveryData() - { - return this.perfAnalyzer.GetEventDataByTaskName(Constants.AdapterDiscoveryTask); - } - - public IDictionary GetExecutionData() - { - return this.perfAnalyzer.GetEventDataByTaskName(Constants.AdapterExecutionTask); - } - - public double GetAdapterExecutionTime(string executorUri) - { - return this.perfAnalyzer.GetAdapterExecutionTime(executorUri); - } } -} + + /// + /// The analyze performance data. + /// + public void AnalyzePerfData() + { + _perfAnalyzer.AnalyzeEventsData(); + } + + /// + /// The get execution time. + /// + /// + /// The . + /// + public double GetExecutionTime() + { + return _perfAnalyzer.GetElapsedTimeByTaskName(Constants.ExecutionTask); + } + + public double GetDiscoveryTime() + { + return _perfAnalyzer.GetElapsedTimeByTaskName(Constants.DiscoveryTask); + } + + public double GetVsTestTime() + { + return _perfAnalyzer.GetElapsedTimeByTaskName(Constants.VsTestConsoleTask); + } + + public double GetTestHostTime() + { + return _perfAnalyzer.GetElapsedTimeByTaskName(Constants.TestHostTask); + } + + public double GetAdapterSearchTime() + { + return _perfAnalyzer.GetElapsedTimeByTaskName(Constants.AdapterSearchTask); + } + + public IDictionary GetDiscoveryData() + { + return _perfAnalyzer.GetEventDataByTaskName(Constants.AdapterDiscoveryTask); + } + + public IDictionary GetExecutionData() + { + return _perfAnalyzer.GetEventDataByTaskName(Constants.AdapterExecutionTask); + } + + public double GetAdapterExecutionTime(string executorUri) + { + return _perfAnalyzer.GetAdapterExecutionTime(executorUri); + } +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.TestUtilities/PerfInstrumentation/TestPlatformTask.cs b/test/Microsoft.TestPlatform.TestUtilities/PerfInstrumentation/TestPlatformTask.cs index b6b63343e8..4eab3795c3 100644 --- a/test/Microsoft.TestPlatform.TestUtilities/PerfInstrumentation/TestPlatformTask.cs +++ b/test/Microsoft.TestPlatform.TestUtilities/PerfInstrumentation/TestPlatformTask.cs @@ -1,28 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.TestUtilities.PerfInstrumentation -{ - using System.Collections.Generic; +namespace Microsoft.TestPlatform.TestUtilities.PerfInstrumentation; - /// - /// The test platform task. - /// - public class TestPlatformTask - { - public string TaskName { get; set; } +using System.Collections.Generic; - public double EventStarted { get; set; } +/// +/// The test platform task. +/// +public class TestPlatformTask +{ + public string TaskName { get; set; } - public double EventStopped { get; set; } + public double EventStarted { get; set; } - public IDictionary PayLoadProperties { get; set; } + public double EventStopped { get; set; } - public TestPlatformTask(string taskName, double eventStarted) - { - this.EventStarted = eventStarted; - this.TaskName = taskName; - this.PayLoadProperties = new Dictionary(); - } + public IDictionary PayLoadProperties { get; set; } + + public TestPlatformTask(string taskName, double eventStarted) + { + EventStarted = eventStarted; + TaskName = taskName; + PayLoadProperties = new Dictionary(); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.TestUtilities/TempDirectory.cs b/test/Microsoft.TestPlatform.TestUtilities/TempDirectory.cs index e8c29e8308..352954c9c2 100644 --- a/test/Microsoft.TestPlatform.TestUtilities/TempDirectory.cs +++ b/test/Microsoft.TestPlatform.TestUtilities/TempDirectory.cs @@ -4,78 +4,77 @@ using System; using System.IO; -namespace Microsoft.TestPlatform.TestUtilities +namespace Microsoft.TestPlatform.TestUtilities; + +public class TempDirectory : IDisposable { - public class TempDirectory : IDisposable + /// + /// Creates a unique temporary directory. + /// + public TempDirectory() { - /// - /// Creates a unique temporary directory. - /// - public TempDirectory() - { - Path = CreateUniqueDirectory(); - } - - public string Path { get; } + Path = CreateUniqueDirectory(); + } - public void Dispose() - { - TryRemoveDirectory(Path); - } + public string Path { get; } - public DirectoryInfo CreateDirectory(string dir) - => Directory.CreateDirectory(System.IO.Path.Combine(Path, dir)); + public void Dispose() + { + TryRemoveDirectory(Path); + } - public void CopyAll(DirectoryInfo source, DirectoryInfo target) - { - Directory.CreateDirectory(target.FullName); + public DirectoryInfo CreateDirectory(string dir) + => Directory.CreateDirectory(System.IO.Path.Combine(Path, dir)); - // Copy each file into the new directory. - foreach (FileInfo fi in source.GetFiles()) - { - fi.CopyTo(System.IO.Path.Combine(target.FullName, fi.Name), true); - } + public void CopyAll(DirectoryInfo source, DirectoryInfo target) + { + Directory.CreateDirectory(target.FullName); - // Copy each subdirectory using recursion. - foreach (DirectoryInfo diSourceSubDir in source.GetDirectories()) - { - DirectoryInfo nextTargetSubDir = - target.CreateSubdirectory(diSourceSubDir.Name); - CopyAll(diSourceSubDir, nextTargetSubDir); - } - } - /// - /// Creates an unique temporary directory. - /// - /// - /// Path of the created directory. - /// - internal static string CreateUniqueDirectory() + // Copy each file into the new directory. + foreach (FileInfo fi in source.GetFiles()) { - // AGENT_TEMPDIRECTORY is AzureDevops variable, which is set to path - // that is cleaned up after every job. This is preferable to use over - // just the normal temp. - var temp = GetTempPath(); - var directoryPath = System.IO.Path.Combine(temp, Guid.NewGuid().ToString("n")); - Directory.CreateDirectory(directoryPath); + fi.CopyTo(System.IO.Path.Combine(target.FullName, fi.Name), true); + } - return directoryPath; + // Copy each subdirectory using recursion. + foreach (DirectoryInfo diSourceSubDir in source.GetDirectories()) + { + DirectoryInfo nextTargetSubDir = + target.CreateSubdirectory(diSourceSubDir.Name); + CopyAll(diSourceSubDir, nextTargetSubDir); } + } + /// + /// Creates an unique temporary directory. + /// + /// + /// Path of the created directory. + /// + internal static string CreateUniqueDirectory() + { + // AGENT_TEMPDIRECTORY is AzureDevops variable, which is set to path + // that is cleaned up after every job. This is preferable to use over + // just the normal temp. + var temp = GetTempPath(); + var directoryPath = System.IO.Path.Combine(temp, Guid.NewGuid().ToString("n")); + Directory.CreateDirectory(directoryPath); - private static string GetTempPath() - => Environment.GetEnvironmentVariable("AGENT_TEMPDIRECTORY") - ?? System.IO.Path.GetTempPath(); + return directoryPath; + } - public static void TryRemoveDirectory(string directory) + private static string GetTempPath() + => Environment.GetEnvironmentVariable("AGENT_TEMPDIRECTORY") + ?? System.IO.Path.GetTempPath(); + + public static void TryRemoveDirectory(string directory) + { + if (Directory.Exists(directory)) { - if (Directory.Exists(directory)) + try { - try - { - Directory.Delete(directory, true); - } - catch { } + Directory.Delete(directory, true); } + catch { } } } } diff --git a/test/Microsoft.TestPlatform.TestUtilities/TestPluginCacheHelper.cs b/test/Microsoft.TestPlatform.TestUtilities/TestPluginCacheHelper.cs index 869d8897d7..263faa138b 100644 --- a/test/Microsoft.TestPlatform.TestUtilities/TestPluginCacheHelper.cs +++ b/test/Microsoft.TestPlatform.TestUtilities/TestPluginCacheHelper.cs @@ -4,67 +4,68 @@ using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; using Microsoft.VisualStudio.TestPlatform.Common.SettingsProvider; using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + using Moq; + using System; using System.Linq; using System.Reflection; -namespace Microsoft.TestPlatform.TestUtilities +namespace Microsoft.TestPlatform.TestUtilities; + +public static class TestPluginCacheHelper { - public static class TestPluginCacheHelper + public static TestableTestPluginCache SetupMockAdditionalPathExtensions(Type callingTest) { - public static TestableTestPluginCache SetupMockAdditionalPathExtensions(Type callingTest) - { - return SetupMockAdditionalPathExtensions( - new string[] { callingTest.GetTypeInfo().Assembly.Location }); - } + return SetupMockAdditionalPathExtensions( + new string[] { callingTest.GetTypeInfo().Assembly.Location }); + } - public static TestableTestPluginCache SetupMockAdditionalPathExtensions(string[] extensions) - { - var mockFileHelper = new Mock(); - var testPluginCache = new TestableTestPluginCache(); + public static TestableTestPluginCache SetupMockAdditionalPathExtensions(string[] extensions) + { + var mockFileHelper = new Mock(); + var testPluginCache = new TestableTestPluginCache(); - TestPluginCache.Instance = testPluginCache; + TestPluginCache.Instance = testPluginCache; - // Stub the default extensions folder. - mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(false); + // Stub the default extensions folder. + mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(false); - TestPluginCache.Instance.UpdateExtensions(extensions, true); + TestPluginCache.Instance.UpdateExtensions(extensions, true); - return testPluginCache; - } + return testPluginCache; + } - public static void SetupMockExtensions(Type callingTest, Mock mockFileHelper = null) - { - SetupMockExtensions(callingTest, () => { }, mockFileHelper); - } + public static void SetupMockExtensions(Type callingTest, Mock mockFileHelper = null) + { + SetupMockExtensions(callingTest, () => { }, mockFileHelper); + } - public static void SetupMockExtensions(Type callingTest, Action callback, Mock mockFileHelper = null) - { - SetupMockExtensions(new[] { callingTest.GetTypeInfo().Assembly.Location }, callback, mockFileHelper); - } + public static void SetupMockExtensions(Type callingTest, Action callback, Mock mockFileHelper = null) + { + SetupMockExtensions(new[] { callingTest.GetTypeInfo().Assembly.Location }, callback, mockFileHelper); + } - public static void SetupMockExtensions(string[] extensions, Action callback, Mock mockFileHelper = null) + public static void SetupMockExtensions(string[] extensions, Action callback, Mock mockFileHelper = null) + { + // Setup mocks. + if (mockFileHelper == null) { - // Setup mocks. - if (mockFileHelper == null) - { - mockFileHelper = new Mock(); - } + mockFileHelper = new Mock(); + } - mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); + mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); - var testableTestPluginCache = new TestableTestPluginCache(extensions.ToList()); - testableTestPluginCache.Action = callback; + var testableTestPluginCache = new TestableTestPluginCache(extensions.ToList()); + testableTestPluginCache.Action = callback; - // Setup the testable instance. - TestPluginCache.Instance = testableTestPluginCache; - } + // Setup the testable instance. + TestPluginCache.Instance = testableTestPluginCache; + } - public static void ResetExtensionsCache() - { - TestPluginCache.Instance = null; - SettingsProviderExtensionManager.Destroy(); - } + public static void ResetExtensionsCache() + { + TestPluginCache.Instance = null; + SettingsProviderExtensionManager.Destroy(); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.TestUtilities/TestableTestPluginCache.cs b/test/Microsoft.TestPlatform.TestUtilities/TestableTestPluginCache.cs index 58c234b378..af2f6a5bfa 100644 --- a/test/Microsoft.TestPlatform.TestUtilities/TestableTestPluginCache.cs +++ b/test/Microsoft.TestPlatform.TestUtilities/TestableTestPluginCache.cs @@ -1,37 +1,37 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.TestUtilities -{ - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.SettingsProvider; - using System; - using System.Collections.Generic; +namespace Microsoft.TestPlatform.TestUtilities; + +using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.SettingsProvider; + +using System; +using System.Collections.Generic; - public class TestableTestPluginCache : TestPluginCache +public class TestableTestPluginCache : TestPluginCache +{ + public Action Action; + public TestableTestPluginCache(List extensionsPath) { - public Action Action; - public TestableTestPluginCache(List extensionsPath) - { - TestDiscoveryExtensionManager.Destroy(); - TestExecutorExtensionManager.Destroy(); - SettingsProviderExtensionManager.Destroy(); - this.UpdateExtensions(extensionsPath, skipExtensionFilters: false); - } + TestDiscoveryExtensionManager.Destroy(); + TestExecutorExtensionManager.Destroy(); + SettingsProviderExtensionManager.Destroy(); + UpdateExtensions(extensionsPath, skipExtensionFilters: false); + } - public TestableTestPluginCache() : this(new List()) - { - } + public TestableTestPluginCache() : this(new List()) + { + } - protected override IEnumerable GetFilteredExtensions(List extensions, string searchPattern) - { - this.Action?.Invoke(); - return extensions; - } + protected override IEnumerable GetFilteredExtensions(List extensions, string searchPattern) + { + Action?.Invoke(); + return extensions; + } - new public void SetupAssemblyResolver(string extensionAssembly) - { - base.SetupAssemblyResolver(extensionAssembly); - } + new public void SetupAssemblyResolver(string extensionAssembly) + { + base.SetupAssemblyResolver(extensionAssembly); } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/ClientUtilitiesTests.cs b/test/Microsoft.TestPlatform.Utilities.UnitTests/ClientUtilitiesTests.cs index 1616cbd9f4..d7dc907cbf 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/ClientUtilitiesTests.cs +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/ClientUtilitiesTests.cs @@ -1,177 +1,204 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Utilities.Tests +namespace Microsoft.TestPlatform.Utilities.Tests; + +using System; +using System.IO; +using System.Reflection; +using System.Xml; + +using Microsoft.VisualStudio.TestPlatform.Utilities; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class ClientUtilitiesTests { - using System; - using System.IO; - using System.Reflection; - using System.Xml; + [TestMethod] + public void FixRelativePathsInRunSettingsShouldThrowIfDocumentIsNull() + { + Assert.ThrowsException(() => ClientUtilities.FixRelativePathsInRunSettings(null, "c:\\temp")); + } - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; + [TestMethod] + public void FixRelativePathsInRunSettingsShouldThrowIfPathIsNullOrEmpty() + { + Assert.ThrowsException(() => ClientUtilities.FixRelativePathsInRunSettings(new XmlDocument(), null)); + Assert.ThrowsException(() => ClientUtilities.FixRelativePathsInRunSettings(new XmlDocument(), "")); + } - [TestClass] - public class ClientUtilitiesTests + [TestMethod] + public void FixRelativePathsInRunSettingsShouldNotModifyAnEmptyRunSettings() { - [TestMethod] - public void FixRelativePathsInRunSettingsShouldThrowIfDocumentIsNull() - { - Assert.ThrowsException(() => ClientUtilities.FixRelativePathsInRunSettings(null, "c:\\temp")); - } + var runSettingsXml = ""; - [TestMethod] - public void FixRelativePathsInRunSettingsShouldThrowIfPathIsNullOrEmpty() - { - Assert.ThrowsException(() => ClientUtilities.FixRelativePathsInRunSettings(new XmlDocument(), null)); - Assert.ThrowsException(() => ClientUtilities.FixRelativePathsInRunSettings(new XmlDocument(), "")); - } + var doc = new XmlDocument(); + doc.LoadXml(runSettingsXml); - [TestMethod] - public void FixRelativePathsInRunSettingsShouldNotModifyAnEmptyRunSettings() - { - var runSettingsXML = ""; + var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; - var doc = new XmlDocument(); - doc.LoadXml(runSettingsXML); + ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); - var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; + var finalSettingsXml = doc.OuterXml; - ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); + var expectedRunSettingsXml = string.Concat("", + Path.GetDirectoryName(currentAssemblyLocation), + ""); - var finalSettingsXml = doc.OuterXml; + Assert.AreEqual(expectedRunSettingsXml, finalSettingsXml); + } - var expectedRunSettingsXML = string.Concat("", - Path.GetDirectoryName(currentAssemblyLocation), - ""); + [TestMethod] + public void FixRelativePathsInRunSettingsShouldModifyRelativeTestSettingsFilePath() + { + var runSettingsXml = "..\\remote.testsettings"; - Assert.AreEqual(expectedRunSettingsXML, finalSettingsXml); - } + var doc = new XmlDocument(); + doc.LoadXml(runSettingsXml); - [TestMethod] - public void FixRelativePathsInRunSettingsShouldModifyRelativeTestSettingsFilePath() - { - var runSettingsXML = "..\\remote.testsettings"; + var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; - var doc = new XmlDocument(); - doc.LoadXml(runSettingsXML); + ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); - var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; + var finalSettingsXml = doc.OuterXml; - ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); + var expectedPath = Path.GetFullPath(Path.Combine( + Path.GetDirectoryName(currentAssemblyLocation), "..\\remote.testsettings")); + var expectedSettingsXml = string.Concat( + "", + expectedPath, + "", + Path.GetDirectoryName(currentAssemblyLocation), + ""); - var finalSettingsXml = doc.OuterXml; + Assert.AreEqual(expectedSettingsXml, finalSettingsXml); + } - var expectedPath = Path.GetFullPath(Path.Combine( - Path.GetDirectoryName(currentAssemblyLocation), "..\\remote.testsettings")); - var expectedSettingsXml = string.Concat( - "", - expectedPath, - "", - Path.GetDirectoryName(currentAssemblyLocation), - ""); + [TestMethod] + public void FixRelativePathsInRunSettingsShouldNotModifyAbsoluteTestSettingsFilePath() + { + var absolutePath = Path.Combine(Path.GetTempPath(), "remote.testsettings"); + var runSettingsXml = $"{absolutePath}"; - Assert.AreEqual(expectedSettingsXml, finalSettingsXml); - } + var doc = new XmlDocument(); + doc.LoadXml(runSettingsXml); - [TestMethod] - public void FixRelativePathsInRunSettingsShouldNotModifyAbsoluteTestSettingsFilePath() - { - var absolutePath = Path.Combine(Path.GetTempPath(), "remote.testsettings"); - var runSettingsXML = $"{absolutePath}"; + var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; - var doc = new XmlDocument(); - doc.LoadXml(runSettingsXML); + ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); - var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; + var finalSettingsXml = doc.OuterXml; - ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); + var expectedRunSettingsXml = string.Concat($"{absolutePath}", + Path.GetDirectoryName(currentAssemblyLocation), + ""); - var finalSettingsXml = doc.OuterXml; + Assert.AreEqual(expectedRunSettingsXml, finalSettingsXml); + } - var expectedRunSettingsXML = string.Concat($"{absolutePath}", - Path.GetDirectoryName(currentAssemblyLocation), - ""); + [TestMethod] + public void FixRelativePathsInRunSettingsShouldNotModifyEmptyTestSettingsFilePath() + { + var runSettingsXml = ""; - Assert.AreEqual(expectedRunSettingsXML, finalSettingsXml); - } + var doc = new XmlDocument(); + doc.LoadXml(runSettingsXml); - [TestMethod] - public void FixRelativePathsInRunSettingsShouldNotModifyEmptyTestSettingsFilePath() - { - var runSettingsXML = ""; + var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; - var doc = new XmlDocument(); - doc.LoadXml(runSettingsXML); + ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); - var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; + var finalSettingsXml = doc.OuterXml; - ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); + var expectedRunSettingsXml = string.Concat("", + Path.GetDirectoryName(currentAssemblyLocation), + ""); - var finalSettingsXml = doc.OuterXml; + Assert.AreEqual(expectedRunSettingsXml, finalSettingsXml); + } - var expectedRunSettingsXML = string.Concat("", - Path.GetDirectoryName(currentAssemblyLocation), - ""); + [TestMethod] + public void FixRelativePathsInRunSettingsShouldModifyRelativeResultsDirectory() + { + var runSettingsXml = "..\\results"; - Assert.AreEqual(expectedRunSettingsXML, finalSettingsXml); - } + var doc = new XmlDocument(); + doc.LoadXml(runSettingsXml); - [TestMethod] - public void FixRelativePathsInRunSettingsShouldModifyRelativeResultsDirectory() - { - var runSettingsXML = "..\\results"; + var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; - var doc = new XmlDocument(); - doc.LoadXml(runSettingsXML); + ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); - var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; + var finalSettingsXml = doc.OuterXml; - ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); + var expectedPath = Path.GetFullPath(Path.Combine( + Path.GetDirectoryName(currentAssemblyLocation), "..\\results")); + var expectedSettingsXml = string.Concat( + "", + expectedPath, + "", + Path.GetDirectoryName(currentAssemblyLocation), + ""); - var finalSettingsXml = doc.OuterXml; + Assert.AreEqual(expectedSettingsXml, finalSettingsXml); + } - var expectedPath = Path.GetFullPath(Path.Combine( - Path.GetDirectoryName(currentAssemblyLocation), "..\\results")); - var expectedSettingsXml = string.Concat( - "", - expectedPath, - "", - Path.GetDirectoryName(currentAssemblyLocation), - ""); + [TestMethod] + public void FixRelativePathsInRunSettingsShouldNotModifyAbsoluteResultsDirectory() + { + var absolutePath = Path.Combine(Path.GetTempPath(), "results"); + var runSettingsXml = $"{absolutePath}"; - Assert.AreEqual(expectedSettingsXml, finalSettingsXml); - } + var doc = new XmlDocument(); + doc.LoadXml(runSettingsXml); - [TestMethod] - public void FixRelativePathsInRunSettingsShouldNotModifyAbsoluteResultsDirectory() - { - var absolutePath = Path.Combine(Path.GetTempPath(), "results"); - var runSettingsXML = $"{absolutePath}"; + var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; - var doc = new XmlDocument(); - doc.LoadXml(runSettingsXML); + ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); - var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; + var finalSettingsXml = doc.OuterXml; - ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); + var expectedRunSettingsXml = string.Concat($"{absolutePath}", + Path.GetDirectoryName(currentAssemblyLocation), + ""); - var finalSettingsXml = doc.OuterXml; + Assert.AreEqual(expectedRunSettingsXml, finalSettingsXml); + } - var expectedRunSettingsXML = string.Concat($"{absolutePath}", - Path.GetDirectoryName(currentAssemblyLocation), - ""); + [TestMethod] + public void FixRelativePathsInRunSettingsShouldNotModifyEmptyResultsDirectory() + { + var runSettingsXml = ""; - Assert.AreEqual(expectedRunSettingsXML, finalSettingsXml); - } + var doc = new XmlDocument(); + doc.LoadXml(runSettingsXml); + + var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; + + ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); + + var finalSettingsXml = doc.OuterXml; - [TestMethod] - public void FixRelativePathsInRunSettingsShouldNotModifyEmptyResultsDirectory() + var expectedRunSettingsXml = string.Concat("", + Path.GetDirectoryName(currentAssemblyLocation), + ""); + + Assert.AreEqual(expectedRunSettingsXml, finalSettingsXml); + } + + [TestMethod] + public void FixRelativePathsInRunSettingsShouldExpandEnvironmentVariable() + { + try { - var runSettingsXML = ""; + Environment.SetEnvironmentVariable("TEST_TEMP", Path.GetTempPath()); + // using TEST_TEMP because TMP or TEMP, or HOME are not defined across all tested OSes + // Using \\ instead of platform specifc path separator does not matter, because the paths are not interpreted by the OS. + var runSettingsXml = "%TEST_TEMP%\\results"; var doc = new XmlDocument(); - doc.LoadXml(runSettingsXML); + doc.LoadXml(runSettingsXml); var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; @@ -179,45 +206,20 @@ public void FixRelativePathsInRunSettingsShouldNotModifyEmptyResultsDirectory() var finalSettingsXml = doc.OuterXml; - var expectedRunSettingsXML = string.Concat("", + var expectedPath = $"{Environment.GetEnvironmentVariable("TEST_TEMP")}\\results"; + + var expectedSettingsXml = string.Concat( + "", + expectedPath, + "", Path.GetDirectoryName(currentAssemblyLocation), ""); - Assert.AreEqual(expectedRunSettingsXML, finalSettingsXml); + Assert.AreEqual(expectedSettingsXml, finalSettingsXml); } - - [TestMethod] - public void FixRelativePathsInRunSettingsShouldExpandEnvironmentVariable() + finally { - try { - Environment.SetEnvironmentVariable("TEST_TEMP", Path.GetTempPath()); - // using TEST_TEMP because TMP or TEMP, or HOME are not defined across all tested OSes - // Using \\ instead of platform specifc path separator does not matter, because the paths are not interpreted by the OS. - var runSettingsXML = "%TEST_TEMP%\\results"; - - var doc = new XmlDocument(); - doc.LoadXml(runSettingsXML); - - var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; - - ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); - - var finalSettingsXml = doc.OuterXml; - - var expectedPath = $"{Environment.GetEnvironmentVariable("TEST_TEMP")}\\results"; - - var expectedSettingsXml = string.Concat( - "", - expectedPath, - "", - Path.GetDirectoryName(currentAssemblyLocation), - ""); - - Assert.AreEqual(expectedSettingsXml, finalSettingsXml); - } - finally { - Environment.SetEnvironmentVariable("TEST_TEMP", null); - } + Environment.SetEnvironmentVariable("TEST_TEMP", null); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/CodeCoverageDataAttachmentsHandlerTests.cs b/test/Microsoft.TestPlatform.Utilities.UnitTests/CodeCoverageDataAttachmentsHandlerTests.cs index 9e49656cc9..a34124bc7b 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/CodeCoverageDataAttachmentsHandlerTests.cs +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/CodeCoverageDataAttachmentsHandlerTests.cs @@ -1,191 +1,195 @@ -namespace Microsoft.TestPlatform.Utilities.UnitTests +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.TestPlatform.Utilities.UnitTests; + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +#if !NETFRAMEWORK +using System.Runtime.InteropServices; +#endif +using System.Threading; +using System.Threading.Tasks; +using System.Xml; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using VisualStudio.TestTools.UnitTesting; +using Moq; + +[TestClass] +public class CodeCoverageDataAttachmentsHandlerTests { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.IO; - using System.Linq; - using System.Runtime.InteropServices; - using System.Threading; - using System.Threading.Tasks; - using System.Xml; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - - [TestClass] - public class CodeCoverageDataAttachmentsHandlerTests - { - private readonly Mock> mockProgressReporter; - private readonly XmlElement configurationElement; - private readonly CodeCoverageDataAttachmentsHandler coverageDataAttachmentsHandler; - private readonly string _filePrefix; + private readonly Mock> _mockProgressReporter; + private readonly XmlElement _configurationElement; + private readonly CodeCoverageDataAttachmentsHandler _coverageDataAttachmentsHandler; + private readonly string _filePrefix; - public TestContext TestContext { get; set; } + public TestContext TestContext { get; set; } - internal string TestFilesDirectory => Path.Combine(TestContext.DeploymentDirectory, "TestFiles"); + internal string TestFilesDirectory => Path.Combine(TestContext.DeploymentDirectory, "TestFiles"); - public CodeCoverageDataAttachmentsHandlerTests() - { - var doc = new XmlDocument(); - doc.LoadXml(""); - configurationElement = doc.DocumentElement; - mockProgressReporter = new Mock>(); - coverageDataAttachmentsHandler = new CodeCoverageDataAttachmentsHandler(); + public CodeCoverageDataAttachmentsHandlerTests() + { + var doc = new XmlDocument(); + doc.LoadXml(""); + _configurationElement = doc.DocumentElement; + _mockProgressReporter = new Mock>(); + _coverageDataAttachmentsHandler = new CodeCoverageDataAttachmentsHandler(); #if NETFRAMEWORK - _filePrefix = "file:///"; + _filePrefix = "file:///"; #else - _filePrefix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "file:///" : "file://"; + _filePrefix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "file:///" : "file://"; #endif - } + } #if NETFRAMEWORK - [ClassInitialize] - public static void ClassInitialize(TestContext context) - { - // Copying test files to correct place, - var assemblyPath = AppDomain.CurrentDomain.BaseDirectory; - var testFilesDirectory = Path.Combine(context.DeploymentDirectory, "TestFiles"); - Directory.CreateDirectory(testFilesDirectory); - var files = Directory.GetFiles(Path.Combine(assemblyPath, "TestFiles")); - foreach (var file in files) - File.Copy(file, Path.Combine(testFilesDirectory, Path.GetFileName(file))); - } + [ClassInitialize] + public static void ClassInitialize(TestContext context) + { + // Copying test files to correct place, + var assemblyPath = AppDomain.CurrentDomain.BaseDirectory; + var testFilesDirectory = Path.Combine(context.DeploymentDirectory, "TestFiles"); + Directory.CreateDirectory(testFilesDirectory); + var files = Directory.GetFiles(Path.Combine(assemblyPath, "TestFiles")); + foreach (var file in files) + File.Copy(file, Path.Combine(testFilesDirectory, Path.GetFileName(file))); + } #endif - [TestMethod] - public async Task HandleDataCollectionAttachmentSetsShouldReturnEmptySetWhenNoAttachmentsOrAttachmentsAreNull() - { - Collection attachment = new Collection(); - ICollection resultAttachmentSets = await - coverageDataAttachmentsHandler.ProcessAttachmentSetsAsync(configurationElement, attachment, mockProgressReporter.Object, null, CancellationToken.None); + [TestMethod] + public async Task HandleDataCollectionAttachmentSetsShouldReturnEmptySetWhenNoAttachmentsOrAttachmentsAreNull() + { + Collection attachment = new(); + ICollection resultAttachmentSets = await + _coverageDataAttachmentsHandler.ProcessAttachmentSetsAsync(_configurationElement, attachment, _mockProgressReporter.Object, null, CancellationToken.None); - Assert.IsNotNull(resultAttachmentSets); - Assert.IsTrue(resultAttachmentSets.Count == 0); + Assert.IsNotNull(resultAttachmentSets); + Assert.IsTrue(resultAttachmentSets.Count == 0); - resultAttachmentSets = await coverageDataAttachmentsHandler.ProcessAttachmentSetsAsync(configurationElement, null, mockProgressReporter.Object, null, CancellationToken.None); + resultAttachmentSets = await _coverageDataAttachmentsHandler.ProcessAttachmentSetsAsync(_configurationElement, null, _mockProgressReporter.Object, null, CancellationToken.None); - Assert.IsNotNull(resultAttachmentSets); - Assert.IsTrue(resultAttachmentSets.Count == 0); + Assert.IsNotNull(resultAttachmentSets); + Assert.IsTrue(resultAttachmentSets.Count == 0); - mockProgressReporter.Verify(p => p.Report(It.IsAny()), Times.Never); - } + _mockProgressReporter.Verify(p => p.Report(It.IsAny()), Times.Never); + } - [TestMethod] - public async Task HandleDataCollectionAttachmentSetsShouldReturnInputIfOnly1Attachment() - { - var attachmentSet = new AttachmentSet(new Uri("datacollector://microsoft/CodeCoverage/2.0"), string.Empty); - attachmentSet.Attachments.Add(new UriDataAttachment(new Uri("C:\\temp\\aa.coverage"), "coverage")); - - Collection attachment = new Collection { attachmentSet }; - ICollection resultAttachmentSets = await - coverageDataAttachmentsHandler.ProcessAttachmentSetsAsync(configurationElement, attachment, mockProgressReporter.Object, null, CancellationToken.None); - - Assert.IsNotNull(resultAttachmentSets); - Assert.IsTrue(resultAttachmentSets.Count == 1); - Assert.IsTrue(resultAttachmentSets.First().Attachments.Count == 1); - Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", resultAttachmentSets.First().Uri.AbsoluteUri); - Assert.AreEqual("file:///C:/temp/aa.coverage", resultAttachmentSets.First().Attachments.First().Uri.AbsoluteUri); - } - - [TestMethod] - public async Task HandleDataCollectionAttachmentSetsShouldReturnInputIf2DifferentFormatAttachments() - { - var file1Path = Path.Combine(TestFilesDirectory, "fullcovered.cobertura.xml"); - var file2Path = Path.Combine(Path.Combine(TestFilesDirectory, "fullcovered.coverage")); - var attachmentSet = new AttachmentSet(new Uri("datacollector://microsoft/CodeCoverage/2.0"), string.Empty); - attachmentSet.Attachments.Add(new UriDataAttachment(new Uri(file1Path), "coverage")); - attachmentSet.Attachments.Add(new UriDataAttachment(new Uri(file2Path), "coverage")); - - Collection attachment = new Collection { attachmentSet }; - ICollection resultAttachmentSets = await - coverageDataAttachmentsHandler.ProcessAttachmentSetsAsync(configurationElement, attachment, mockProgressReporter.Object, null, CancellationToken.None); - - Assert.IsNotNull(resultAttachmentSets); - Assert.IsTrue(resultAttachmentSets.Count == 1); - Assert.IsTrue(resultAttachmentSets.First().Attachments.Count == 2); - Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", resultAttachmentSets.First().Uri.AbsoluteUri); - Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", resultAttachmentSets.Last().Uri.AbsoluteUri); - Assert.AreEqual(_filePrefix + file1Path.Replace("\\", "/").Replace(" ", "%20"), resultAttachmentSets.First().Attachments.First().Uri.AbsoluteUri); - Assert.AreEqual(_filePrefix + file2Path.Replace("\\", "/").Replace(" ", "%20"), resultAttachmentSets.First().Attachments.Last().Uri.AbsoluteUri); - } - - [TestMethod] - public async Task HandleDataCollectionAttachmentSetsShouldReturnInputIf2SameFormatAttachments() - { - var file1Path = Path.Combine(TestFilesDirectory, "fullcovered.cobertura.xml"); - var attachmentSet = new AttachmentSet(new Uri("datacollector://microsoft/CodeCoverage/2.0"), string.Empty); - attachmentSet.Attachments.Add(new UriDataAttachment(new Uri(file1Path), "coverage")); - attachmentSet.Attachments.Add(new UriDataAttachment(new Uri(file1Path), "coverage")); - - Collection attachment = new Collection { attachmentSet }; - ICollection resultAttachmentSets = await - coverageDataAttachmentsHandler.ProcessAttachmentSetsAsync(configurationElement, attachment, mockProgressReporter.Object, null, CancellationToken.None); - - Assert.IsNotNull(resultAttachmentSets); - Assert.IsTrue(resultAttachmentSets.Count == 1); - Assert.IsTrue(resultAttachmentSets.First().Attachments.Count == 1); - Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", resultAttachmentSets.First().Uri.AbsoluteUri); - Assert.AreEqual(_filePrefix + file1Path.Replace("\\", "/").Replace(" ", "%20"), resultAttachmentSets.First().Attachments.First().Uri.AbsoluteUri); - } - - [TestMethod] - public async Task HandleDataCollectionAttachmentSetsShouldReturnInputIfOnly1LogsAttachment() - { - var attachmentSet = new AttachmentSet(new Uri("datacollector://microsoft/CodeCoverage/2.0"), string.Empty); - attachmentSet.Attachments.Add(new UriDataAttachment(new Uri("C:\\temp\\aa.logs"), "coverage")); - - Collection attachment = new Collection { attachmentSet }; - ICollection resultAttachmentSets = await - coverageDataAttachmentsHandler.ProcessAttachmentSetsAsync(configurationElement, attachment, mockProgressReporter.Object, null, CancellationToken.None); - - Assert.IsNotNull(resultAttachmentSets); - Assert.IsTrue(resultAttachmentSets.Count == 1); - Assert.IsTrue(resultAttachmentSets.First().Attachments.Count == 1); - Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", resultAttachmentSets.First().Uri.AbsoluteUri); - Assert.AreEqual("file:///C:/temp/aa.logs", resultAttachmentSets.First().Attachments.First().Uri.AbsoluteUri); - } - - [TestMethod] - public async Task HandleDataCollectionAttachmentSetsShouldReturnInputIfOnlySeveralLogsAttachmentAnd1Report() - { - var attachmentSet = new AttachmentSet(new Uri("datacollector://microsoft/CodeCoverage/2.0"), string.Empty); - attachmentSet.Attachments.Add(new UriDataAttachment(new Uri("C:\\temp\\aa.coverage"), "coverage")); + [TestMethod] + public async Task HandleDataCollectionAttachmentSetsShouldReturnInputIfOnly1Attachment() + { + var attachmentSet = new AttachmentSet(new Uri("datacollector://microsoft/CodeCoverage/2.0"), string.Empty); + attachmentSet.Attachments.Add(new UriDataAttachment(new Uri("C:\\temp\\aa.coverage"), "coverage")); + + Collection attachment = new() { attachmentSet }; + ICollection resultAttachmentSets = await + _coverageDataAttachmentsHandler.ProcessAttachmentSetsAsync(_configurationElement, attachment, _mockProgressReporter.Object, null, CancellationToken.None); + + Assert.IsNotNull(resultAttachmentSets); + Assert.IsTrue(resultAttachmentSets.Count == 1); + Assert.IsTrue(resultAttachmentSets.First().Attachments.Count == 1); + Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", resultAttachmentSets.First().Uri.AbsoluteUri); + Assert.AreEqual("file:///C:/temp/aa.coverage", resultAttachmentSets.First().Attachments.First().Uri.AbsoluteUri); + } - var attachmentSet1 = new AttachmentSet(new Uri("datacollector://microsoft/CodeCoverage/2.0"), string.Empty); - attachmentSet1.Attachments.Add(new UriDataAttachment(new Uri("C:\\temp\\aa.logs"), "coverage")); - attachmentSet1.Attachments.Add(new UriDataAttachment(new Uri("C:\\temp\\bb.logs"), "coverage")); + [TestMethod] + public async Task HandleDataCollectionAttachmentSetsShouldReturnInputIf2DifferentFormatAttachments() + { + var file1Path = Path.Combine(TestFilesDirectory, "fullcovered.cobertura.xml"); + var file2Path = Path.Combine(Path.Combine(TestFilesDirectory, "fullcovered.coverage")); + var attachmentSet = new AttachmentSet(new Uri("datacollector://microsoft/CodeCoverage/2.0"), string.Empty); + attachmentSet.Attachments.Add(new UriDataAttachment(new Uri(file1Path), "coverage")); + attachmentSet.Attachments.Add(new UriDataAttachment(new Uri(file2Path), "coverage")); + + Collection attachment = new() { attachmentSet }; + ICollection resultAttachmentSets = await + _coverageDataAttachmentsHandler.ProcessAttachmentSetsAsync(_configurationElement, attachment, _mockProgressReporter.Object, null, CancellationToken.None); + + Assert.IsNotNull(resultAttachmentSets); + Assert.IsTrue(resultAttachmentSets.Count == 1); + Assert.IsTrue(resultAttachmentSets.First().Attachments.Count == 2); + Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", resultAttachmentSets.First().Uri.AbsoluteUri); + Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", resultAttachmentSets.Last().Uri.AbsoluteUri); + Assert.AreEqual(_filePrefix + file1Path.Replace("\\", "/").Replace(" ", "%20"), resultAttachmentSets.First().Attachments.First().Uri.AbsoluteUri); + Assert.AreEqual(_filePrefix + file2Path.Replace("\\", "/").Replace(" ", "%20"), resultAttachmentSets.First().Attachments.Last().Uri.AbsoluteUri); + } - Collection attachment = new Collection { attachmentSet, attachmentSet1 }; - ICollection resultAttachmentSets = await - coverageDataAttachmentsHandler.ProcessAttachmentSetsAsync(configurationElement, attachment, mockProgressReporter.Object, null, CancellationToken.None); + [TestMethod] + public async Task HandleDataCollectionAttachmentSetsShouldReturnInputIf2SameFormatAttachments() + { + var file1Path = Path.Combine(TestFilesDirectory, "fullcovered.cobertura.xml"); + var attachmentSet = new AttachmentSet(new Uri("datacollector://microsoft/CodeCoverage/2.0"), string.Empty); + attachmentSet.Attachments.Add(new UriDataAttachment(new Uri(file1Path), "coverage")); + attachmentSet.Attachments.Add(new UriDataAttachment(new Uri(file1Path), "coverage")); + + Collection attachment = new() { attachmentSet }; + ICollection resultAttachmentSets = await + _coverageDataAttachmentsHandler.ProcessAttachmentSetsAsync(_configurationElement, attachment, _mockProgressReporter.Object, null, CancellationToken.None); + + Assert.IsNotNull(resultAttachmentSets); + Assert.IsTrue(resultAttachmentSets.Count == 1); + Assert.IsTrue(resultAttachmentSets.First().Attachments.Count == 1); + Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", resultAttachmentSets.First().Uri.AbsoluteUri); + Assert.AreEqual(_filePrefix + file1Path.Replace("\\", "/").Replace(" ", "%20"), resultAttachmentSets.First().Attachments.First().Uri.AbsoluteUri); + } - Assert.IsNotNull(resultAttachmentSets); - Assert.IsTrue(resultAttachmentSets.Count == 2); - Assert.IsTrue(resultAttachmentSets.First().Attachments.Count == 1); - Assert.IsTrue(resultAttachmentSets.Last().Attachments.Count == 2); - } + [TestMethod] + public async Task HandleDataCollectionAttachmentSetsShouldReturnInputIfOnly1LogsAttachment() + { + var attachmentSet = new AttachmentSet(new Uri("datacollector://microsoft/CodeCoverage/2.0"), string.Empty); + attachmentSet.Attachments.Add(new UriDataAttachment(new Uri("C:\\temp\\aa.logs"), "coverage")); + + Collection attachment = new() { attachmentSet }; + ICollection resultAttachmentSets = await + _coverageDataAttachmentsHandler.ProcessAttachmentSetsAsync(_configurationElement, attachment, _mockProgressReporter.Object, null, CancellationToken.None); + + Assert.IsNotNull(resultAttachmentSets); + Assert.IsTrue(resultAttachmentSets.Count == 1); + Assert.IsTrue(resultAttachmentSets.First().Attachments.Count == 1); + Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", resultAttachmentSets.First().Uri.AbsoluteUri); + Assert.AreEqual("file:///C:/temp/aa.logs", resultAttachmentSets.First().Attachments.First().Uri.AbsoluteUri); + } - [TestMethod] - public async Task HandleDataCollectionAttachmentSetsShouldThrowIfCancellationRequested() - { - var attachmentSet = new AttachmentSet(new Uri("//badrui//"), string.Empty); - attachmentSet.Attachments.Add(new UriDataAttachment(new Uri("C:\\temp\\aa.coverage"), "coverage")); - CancellationTokenSource cts = new CancellationTokenSource(); - cts.Cancel(); + [TestMethod] + public async Task HandleDataCollectionAttachmentSetsShouldReturnInputIfOnlySeveralLogsAttachmentAnd1Report() + { + var attachmentSet = new AttachmentSet(new Uri("datacollector://microsoft/CodeCoverage/2.0"), string.Empty); + attachmentSet.Attachments.Add(new UriDataAttachment(new Uri("C:\\temp\\aa.coverage"), "coverage")); + + var attachmentSet1 = new AttachmentSet(new Uri("datacollector://microsoft/CodeCoverage/2.0"), string.Empty); + attachmentSet1.Attachments.Add(new UriDataAttachment(new Uri("C:\\temp\\aa.logs"), "coverage")); + attachmentSet1.Attachments.Add(new UriDataAttachment(new Uri("C:\\temp\\bb.logs"), "coverage")); + + Collection attachment = new() { attachmentSet, attachmentSet1 }; + ICollection resultAttachmentSets = await + _coverageDataAttachmentsHandler.ProcessAttachmentSetsAsync(_configurationElement, attachment, _mockProgressReporter.Object, null, CancellationToken.None); + + Assert.IsNotNull(resultAttachmentSets); + Assert.IsTrue(resultAttachmentSets.Count == 2); + Assert.IsTrue(resultAttachmentSets.First().Attachments.Count == 1); + Assert.IsTrue(resultAttachmentSets.Last().Attachments.Count == 2); + } + + [TestMethod] + public async Task HandleDataCollectionAttachmentSetsShouldThrowIfCancellationRequested() + { + var attachmentSet = new AttachmentSet(new Uri("//badrui//"), string.Empty); + attachmentSet.Attachments.Add(new UriDataAttachment(new Uri("C:\\temp\\aa.coverage"), "coverage")); + CancellationTokenSource cts = new(); + cts.Cancel(); - Collection attachment = new Collection - { - attachmentSet, - attachmentSet - }; + Collection attachment = new() + { + attachmentSet, + attachmentSet + }; - await Assert.ThrowsExceptionAsync(async () => await coverageDataAttachmentsHandler.ProcessAttachmentSetsAsync(configurationElement, attachment, mockProgressReporter.Object, null, cts.Token)); + await Assert.ThrowsExceptionAsync(async () => await _coverageDataAttachmentsHandler.ProcessAttachmentSetsAsync(_configurationElement, attachment, _mockProgressReporter.Object, null, cts.Token)); - Assert.AreEqual(2, attachment.Count); + Assert.AreEqual(2, attachment.Count); - mockProgressReporter.Verify(p => p.Report(It.IsAny()), Times.Never); - } + _mockProgressReporter.Verify(p => p.Report(It.IsAny()), Times.Never); } -} +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/CodeCoverageRunSettingsProcessorTests.cs b/test/Microsoft.TestPlatform.Utilities.UnitTests/CodeCoverageRunSettingsProcessorTests.cs index 03b51f7d41..7ae9a67b58 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/CodeCoverageRunSettingsProcessorTests.cs +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/CodeCoverageRunSettingsProcessorTests.cs @@ -1,284 +1,285 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Utilities.UnitTests +namespace Microsoft.TestPlatform.Utilities.UnitTests; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Xml; + +using Microsoft.VisualStudio.TestPlatform.Utilities; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class CodeCoverageRunSettingsProcessorTests { - using System; - using System.Collections.Generic; - using System.IO; - using System.Reflection; - using System.Xml; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class CodeCoverageRunSettingsProcessorTests + #region Members + private readonly XmlElement _defaultSettings; + + private readonly CodeCoverageRunSettingsProcessor _processor; + #endregion + + #region Constructors + public CodeCoverageRunSettingsProcessorTests() { - #region Members - private XmlElement defaultSettings; + _defaultSettings = GetDefaultConfiguration(); + _processor = new CodeCoverageRunSettingsProcessor(_defaultSettings); + } + #endregion - private CodeCoverageRunSettingsProcessor processor; - #endregion + #region Test Methods + [TestMethod] + public void ProcessingShouldReturnNullForNullOrEmptySettings() + { + Assert.IsNull(_processor.Process((string)null)); + Assert.IsNull(_processor.Process("")); - #region Constructors - public CodeCoverageRunSettingsProcessorTests() - { - this.defaultSettings = this.GetDefaultConfiguration(); - this.processor = new CodeCoverageRunSettingsProcessor(this.defaultSettings); - } - #endregion + Assert.IsNull(_processor.Process((XmlNode)null)); - #region Test Methods - [TestMethod] - public void ProcessingShouldReturnNullForNullOrEmptySettings() - { - Assert.IsNull(processor.Process((string)null)); - Assert.IsNull(processor.Process("")); + Assert.IsNull(_processor.Process((XmlDocument)null)); + } - Assert.IsNull(processor.Process((XmlNode)null)); + [TestMethod] + public void MissingCodeCoverageTagShouldAddDefaultTag() + { + const string settings = ""; + string expected = $"{_defaultSettings.OuterXml}"; - Assert.IsNull(processor.Process((XmlDocument)null)); - } + Assert.AreEqual(expected, _processor.Process(settings).OuterXml); + } - [TestMethod] - public void MissingCodeCoverageTagShouldAddDefaultTag() - { - const string settings = ""; - string expected = $"{this.defaultSettings.OuterXml}"; + [TestMethod] + public void EmptyCodeCoverageTagShouldAddDefaultTag() + { + const string settings = ""; + var processedNode = _processor.Process(settings); + Assert.IsNotNull(processedNode); - Assert.AreEqual(expected, processor.Process(settings).OuterXml); - } + var codeCoverageNodes = ExtractNodes(processedNode, _defaultSettings, "./CodeCoverage"); - [TestMethod] - public void EmptyCodeCoverageTagShouldAddDefaultTag() - { - const string settings = ""; - var processedNode = processor.Process(settings); - Assert.IsNotNull(processedNode); + CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./ModulePaths/Exclude"); + CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./Functions/Exclude"); + CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./Attributes/Exclude"); + CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./Sources/Exclude"); + } - var codeCoverageNodes = this.ExtractNodes(processedNode, this.defaultSettings, "./CodeCoverage"); + [TestMethod] + public void MergeDefaultsDisabledShouldReturnInputUnaltered() + { + var settings = string.Join( + Environment.NewLine, + @"", + @" ", + @" ", + @" ", + @" ", + @" ", + @" ", + @" ", + @" .*\\atlmfc\\.*", + @" .*\\atlmbfc\\.*", + @" .*\\vctools\\.*", + @" .*\\public\\sdk2\\.*", + @" .*\\externalapis\\.*", + @" .*\\microsoft sdks\\.*", + @" .*\\vc\\include\\.*", + @" .*\\msclr\\.*", + @" .*\\ucrt\\.*", + @" ", + @" ", + @" ", + @" ", + @""); + + var document = new XmlDocument(); + document.LoadXml(settings); + + Assert.AreEqual(document.OuterXml, _processor.Process(settings).OuterXml); + } - this.CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./ModulePaths/Exclude"); - this.CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./Functions/Exclude"); - this.CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./Attributes/Exclude"); - this.CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./Sources/Exclude"); - } + [TestMethod] + public void MixedTestShouldCorrectlyAddMissingTags() + { + var settings = string.Join( + Environment.NewLine, + @"", + @" ", + @" ", + @" ", + @" ", + @" ", + @" ", + @" ", + @" .*\\atlmfc\\.*", + @" .*\\atlmbfc\\.*", + @" .*\\vctools\\.*", + @" .*\\public\\sdk2\\.*", + @" .*\\externalapis\\.*", + @" .*\\microsoft sdks\\.*", + @" .*\\vc\\include\\.*", + @" .*\\msclr\\.*", + @" .*\\ucrt\\.*", + @" ", + @" ", + @" ", + @""); + + var expectedResult = string.Join( + Environment.NewLine, + @"", + @" ", + @" ", + @" ", + @" .*CPPUnitTestFramework.*", + @" .*vstest.console.*", + @" .*microsoft.intellitrace.*", + @" .*testhost.*", + @" .*datacollector.*", + @" .*microsoft.teamfoundation.testplatform.*", + @" .*microsoft.visualstudio.testplatform.*", + @" .*microsoft.visualstudio.testwindow.*", + @" .*microsoft.visualstudio.mstest.*", + @" .*microsoft.visualstudio.qualitytools.*", + @" .*microsoft.vssdk.testhostadapter.*", + @" .*microsoft.vssdk.testhostframework.*", + @" .*qtagent32.*", + @" .*msvcr.*dll$", + @" .*msvcp.*dll$", + @" .*clr.dll$", + @" .*clr.ni.dll$", + @" .*clrjit.dll$", + @" .*clrjit.ni.dll$", + @" .*mscoree.dll$", + @" .*mscoreei.dll$", + @" .*mscoreei.ni.dll$", + @" .*mscorlib.dll$", + @" .*mscorlib.ni.dll$", + @" .*cryptbase.dll$", + @" .*bcryptPrimitives.dll$", + @" ", + @" ", + @" ", + @" ", + @" ^std::.*", + @" ^ATL::.*", + @" .*::__GetTestMethodInfo.*", + @" .*__CxxPureMSILEntry.*", + @" ^Microsoft::VisualStudio::CppCodeCoverageFramework::.*", + @" ^Microsoft::VisualStudio::CppUnitTestFramework::.*", + @" .*::YOU_CAN_ONLY_DESIGNATE_ONE_.*", + @" ^__.*", + @" .*::__.*", + @" ", + @" ", + @" ", + @" ", + @" ^System.Diagnostics.DebuggerHiddenAttribute$", + @" ^System.Diagnostics.DebuggerNonUserCodeAttribute$", + @" System.Runtime.CompilerServices.CompilerGeneratedAttribute$", + @" ^System.CodeDom.Compiler.GeneratedCodeAttribute$", + @" ^System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute$", + @" ^Microsoft.VisualStudio.TestPlatform.TestSDKAutoGeneratedCode.*", + @" ", + @" ", + @" ", + @" ", + @" .*\\atlmfc\\.*", + @" .*\\atlmbfc\\.*", + @" .*\\vctools\\.*", + @" .*\\public\\sdk2\\.*", + @" .*\\externalapis\\.*", + @" .*\\microsoft sdks\\.*", + @" .*\\vc\\include\\.*", + @" .*\\msclr\\.*", + @" .*\\ucrt\\.*", + @" .*\\public\\sdk\\.*", + @" ", + @" ", + @" ", + @""); + + var expectedResultDocument = new XmlDocument(); + expectedResultDocument.LoadXml(expectedResult); + + var processedNode = _processor.Process(settings); + Assert.IsNotNull(processedNode); + + var codeCoverageNodes = ExtractNodes(processedNode, expectedResultDocument.DocumentElement, "./CodeCoverage"); + + CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./ModulePaths/Exclude"); + CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./Functions/Exclude"); + CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./Attributes/Exclude"); + CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./Sources/Exclude"); + } + #endregion - [TestMethod] - public void MergeDefaultsDisabledShouldReturnInputUnaltered() + #region Helpers + private XmlNode ExtractNode(XmlNode node, string path) + { + try { - var settings = string.Join( - Environment.NewLine, - @"", - @" ", - @" ", - @" ", - @" ", - @" ", - @" ", - @" ", - @" .*\\atlmfc\\.*", - @" .*\\atlmbfc\\.*", - @" .*\\vctools\\.*", - @" .*\\public\\sdk2\\.*", - @" .*\\externalapis\\.*", - @" .*\\microsoft sdks\\.*", - @" .*\\vc\\include\\.*", - @" .*\\msclr\\.*", - @" .*\\ucrt\\.*", - @" ", - @" ", - @" ", - @" ", - @""); - - var document = new XmlDocument(); - document.LoadXml(settings); - - Assert.AreEqual(document.OuterXml, processor.Process(settings).OuterXml); + return node.SelectSingleNode(path); } - - [TestMethod] - public void MixedTestShouldCorrectlyAddMissingTags() + catch { - var settings = string.Join( - Environment.NewLine, - @"", - @" ", - @" ", - @" ", - @" ", - @" ", - @" ", - @" ", - @" .*\\atlmfc\\.*", - @" .*\\atlmbfc\\.*", - @" .*\\vctools\\.*", - @" .*\\public\\sdk2\\.*", - @" .*\\externalapis\\.*", - @" .*\\microsoft sdks\\.*", - @" .*\\vc\\include\\.*", - @" .*\\msclr\\.*", - @" .*\\ucrt\\.*", - @" ", - @" ", - @" ", - @""); - - var expectedResult = string.Join( - Environment.NewLine, - @"", - @" ", - @" ", - @" ", - @" .*CPPUnitTestFramework.*", - @" .*vstest.console.*", - @" .*microsoft.intellitrace.*", - @" .*testhost.*", - @" .*datacollector.*", - @" .*microsoft.teamfoundation.testplatform.*", - @" .*microsoft.visualstudio.testplatform.*", - @" .*microsoft.visualstudio.testwindow.*", - @" .*microsoft.visualstudio.mstest.*", - @" .*microsoft.visualstudio.qualitytools.*", - @" .*microsoft.vssdk.testhostadapter.*", - @" .*microsoft.vssdk.testhostframework.*", - @" .*qtagent32.*", - @" .*msvcr.*dll$", - @" .*msvcp.*dll$", - @" .*clr.dll$", - @" .*clr.ni.dll$", - @" .*clrjit.dll$", - @" .*clrjit.ni.dll$", - @" .*mscoree.dll$", - @" .*mscoreei.dll$", - @" .*mscoreei.ni.dll$", - @" .*mscorlib.dll$", - @" .*mscorlib.ni.dll$", - @" .*cryptbase.dll$", - @" .*bcryptPrimitives.dll$", - @" ", - @" ", - @" ", - @" ", - @" ^std::.*", - @" ^ATL::.*", - @" .*::__GetTestMethodInfo.*", - @" .*__CxxPureMSILEntry.*", - @" ^Microsoft::VisualStudio::CppCodeCoverageFramework::.*", - @" ^Microsoft::VisualStudio::CppUnitTestFramework::.*", - @" .*::YOU_CAN_ONLY_DESIGNATE_ONE_.*", - @" ^__.*", - @" .*::__.*", - @" ", - @" ", - @" ", - @" ", - @" ^System.Diagnostics.DebuggerHiddenAttribute$", - @" ^System.Diagnostics.DebuggerNonUserCodeAttribute$", - @" System.Runtime.CompilerServices.CompilerGeneratedAttribute$", - @" ^System.CodeDom.Compiler.GeneratedCodeAttribute$", - @" ^System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute$", - @" ^Microsoft.VisualStudio.TestPlatform.TestSDKAutoGeneratedCode.*", - @" ", - @" ", - @" ", - @" ", - @" .*\\atlmfc\\.*", - @" .*\\atlmbfc\\.*", - @" .*\\vctools\\.*", - @" .*\\public\\sdk2\\.*", - @" .*\\externalapis\\.*", - @" .*\\microsoft sdks\\.*", - @" .*\\vc\\include\\.*", - @" .*\\msclr\\.*", - @" .*\\ucrt\\.*", - @" .*\\public\\sdk\\.*", - @" ", - @" ", - @" ", - @""); - - var expectedResultDocument = new XmlDocument(); - expectedResultDocument.LoadXml(expectedResult); - - var processedNode = processor.Process(settings); - Assert.IsNotNull(processedNode); - - var codeCoverageNodes = this.ExtractNodes(processedNode, expectedResultDocument.DocumentElement, "./CodeCoverage"); - - this.CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./ModulePaths/Exclude"); - this.CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./Functions/Exclude"); - this.CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./Attributes/Exclude"); - this.CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./Sources/Exclude"); } - #endregion - - #region Helpers - private XmlNode ExtractNode(XmlNode node, string path) - { - try - { - return node.SelectSingleNode(path); - } - catch - { - } - return null; - } + return null; + } - private XmlElement GetDefaultConfiguration() + private XmlElement GetDefaultConfiguration() + { + var document = new XmlDocument(); + Assembly assembly = typeof(CodeCoverageRunSettingsProcessorTests).GetTypeInfo().Assembly; + using (Stream stream = assembly.GetManifestResourceStream( + "Microsoft.TestPlatform.Utilities.UnitTests.DefaultCodeCoverageConfig.xml")) { - var document = new XmlDocument(); - Assembly assembly = typeof(CodeCoverageRunSettingsProcessorTests).GetTypeInfo().Assembly; - using (Stream stream = assembly.GetManifestResourceStream( - "Microsoft.TestPlatform.Utilities.UnitTests.DefaultCodeCoverageConfig.xml")) - { - document.Load(stream); - } - - return document.DocumentElement; + document.Load(stream); } - private Tuple ExtractNodes(XmlNode currentSettingsRoot, XmlNode defaultSettingsRoot, string path) - { - var currentNode = this.ExtractNode(currentSettingsRoot, path); - var defaultNode = this.ExtractNode(defaultSettingsRoot, path); - Assert.IsNotNull(currentNode); - Assert.IsNotNull(defaultNode); + return document.DocumentElement; + } - return new Tuple(currentNode, defaultNode); - } + private Tuple ExtractNodes(XmlNode currentSettingsRoot, XmlNode defaultSettingsRoot, string path) + { + var currentNode = ExtractNode(currentSettingsRoot, path); + var defaultNode = ExtractNode(defaultSettingsRoot, path); + Assert.IsNotNull(currentNode); + Assert.IsNotNull(defaultNode); - private void CompareResults(XmlNode currentSettingsRoot, XmlNode defaultSettingsRoot, string path) - { - var nodes = this.ExtractNodes(currentSettingsRoot, defaultSettingsRoot, path); + return new Tuple(currentNode, defaultNode); + } - Assert.AreEqual(nodes.Item1.ChildNodes.Count, nodes.Item2.ChildNodes.Count); + private void CompareResults(XmlNode currentSettingsRoot, XmlNode defaultSettingsRoot, string path) + { + var nodes = ExtractNodes(currentSettingsRoot, defaultSettingsRoot, path); - var set = new HashSet(); - foreach (XmlNode child in nodes.Item1.ChildNodes) + Assert.AreEqual(nodes.Item1.ChildNodes.Count, nodes.Item2.ChildNodes.Count); + + var set = new HashSet(); + foreach (XmlNode child in nodes.Item1.ChildNodes) + { + if (!set.Contains(child.OuterXml)) { - if (!set.Contains(child.OuterXml)) - { - set.Add(child.OuterXml); - } + set.Add(child.OuterXml); } + } - foreach (XmlNode child in nodes.Item2.ChildNodes) + foreach (XmlNode child in nodes.Item2.ChildNodes) + { + if (!set.Contains(child.OuterXml)) { - if (!set.Contains(child.OuterXml)) - { - set.Add(child.OuterXml); - continue; - } - - set.Remove(child.OuterXml); + set.Add(child.OuterXml); + continue; } - Assert.AreEqual(0, set.Count); + set.Remove(child.OuterXml); } - #endregion + + Assert.AreEqual(0, set.Count); } -} + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/CommandLineUtilitiesTest.cs b/test/Microsoft.TestPlatform.Utilities.UnitTests/CommandLineUtilitiesTest.cs index f63ec574b6..daf293db8a 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/CommandLineUtilitiesTest.cs +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/CommandLineUtilitiesTest.cs @@ -1,32 +1,32 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Utilities.Tests -{ - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.TestPlatform.Utilities.Tests; - [TestClass] - public class CommandLineUtilitiesTest - { - private void VerifyCommandLineSplitter(string commandLine, string[] expected) - { - CommandLineUtilities.SplitCommandLineIntoArguments(commandLine, out var actual); +using Microsoft.VisualStudio.TestPlatform.Utilities; - Assert.AreEqual(expected.Length, actual.Length); - for (int i = 0; i < actual.Length; ++i) - { - Assert.AreEqual(expected[i], actual[i]); - } - } +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class CommandLineUtilitiesTest +{ + private void VerifyCommandLineSplitter(string commandLine, string[] expected) + { + CommandLineUtilities.SplitCommandLineIntoArguments(commandLine, out var actual); - [TestMethod] - public void TestCommandLineSplitter() + Assert.AreEqual(expected.Length, actual.Length); + for (int i = 0; i < actual.Length; ++i) { - VerifyCommandLineSplitter("", new string[0]); - VerifyCommandLineSplitter("/testadapterpath:\"c:\\Path\"", new[] { @"/testadapterpath:c:\Path" }); - VerifyCommandLineSplitter("/testadapterpath:\"c:\\Path\" /logger:\"trx\"", new[] { @"/testadapterpath:c:\Path", "/logger:trx" }); - VerifyCommandLineSplitter("/testadapterpath:\"c:\\Path\" /logger:\"trx\" /diag:\"log.txt\"", new[] { @"/testadapterpath:c:\Path", "/logger:trx", "/diag:log.txt" }); + Assert.AreEqual(expected[i], actual[i]); } } -} + + [TestMethod] + public void TestCommandLineSplitter() + { + VerifyCommandLineSplitter("", new string[0]); + VerifyCommandLineSplitter("/testadapterpath:\"c:\\Path\"", new[] { @"/testadapterpath:c:\Path" }); + VerifyCommandLineSplitter("/testadapterpath:\"c:\\Path\" /logger:\"trx\"", new[] { @"/testadapterpath:c:\Path", "/logger:trx" }); + VerifyCommandLineSplitter("/testadapterpath:\"c:\\Path\" /logger:\"trx\" /diag:\"log.txt\"", new[] { @"/testadapterpath:c:\Path", "/logger:trx", "/diag:log.txt" }); + } +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs b/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs index bd928e4965..2f4adf51ee 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs @@ -1,277 +1,277 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Utilities.UnitTests +namespace Microsoft.TestPlatform.Utilities.UnitTests; + +using System; +using System.Xml; + +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using OMResources = VisualStudio.TestPlatform.ObjectModel.Resources.CommonResources; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using VisualStudio.TestTools.UnitTesting; +using MSTest.TestFramework.AssertExtensions; +using System.Collections.Generic; +using System.Linq; +using System.Globalization; +using System.Text; + +[TestClass] +public class InferRunSettingsHelperTests { - using System; - using System.Xml; - - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using OMResources = Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources.CommonResources; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using MSTest.TestFramework.AssertExtensions; - using System.Collections.Generic; - using System.Linq; - using System.Globalization; - using System.Text; - - [TestClass] - public class InferRunSettingsHelperTests - { - private IDictionary sourceArchitectures; - private IDictionary sourceFrameworks; - private readonly Framework frameworkNet45 = Framework.FromString(".NETFramework,Version=4.5"); - private readonly Framework frameworkNet46 = Framework.FromString(".NETFramework,Version=4.6"); - private readonly Framework frameworkNet47 = Framework.FromString(".NETFramework,Version=4.7"); - private const string multiTargettingForwardLink = @"https://aka.ms/tp/vstest/multitargetingdoc?view=vs-2019"; - - public InferRunSettingsHelperTests() - { - sourceArchitectures = new Dictionary(); - sourceFrameworks = new Dictionary(); - } - - [TestMethod] - public void UpdateRunSettingsShouldThrowIfRunSettingsNodeDoesNotExist() - { - var settings = @""; - var xmlDocument = this.GetXmlDocument(settings); - - Action action = () => InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp"); - - Assert.That.Throws(action) - .WithMessage(string.Format("An error occurred while loading the settings. Error: {0}.", - "Could not find 'RunSettings' node.")); - } - - [TestMethod] - public void UpdateRunSettingsShouldThrowIfPlatformNodeIsInvalid() - { - var settings = @"foo"; - var xmlDocument = this.GetXmlDocument(settings); - - Action action = () => InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp"); - - Assert.That.Throws(action) - .WithMessage(string.Format("An error occurred while loading the settings. Error: {0}.", - string.Format("Invalid setting '{0}'. Invalid value '{1}' specified for '{2}'", - "RunConfiguration", - "foo", - "TargetPlatform"))); - } - - [TestMethod] - public void UpdateRunSettingsShouldThrowIfFrameworkNodeIsInvalid() - { - var settings = @"foo"; - var xmlDocument = this.GetXmlDocument(settings); + private readonly IDictionary _sourceArchitectures; + private readonly IDictionary _sourceFrameworks; + private readonly Framework _frameworkNet45 = Framework.FromString(".NETFramework,Version=4.5"); + private readonly Framework _frameworkNet46 = Framework.FromString(".NETFramework,Version=4.6"); + private readonly Framework _frameworkNet47 = Framework.FromString(".NETFramework,Version=4.7"); + private const string MultiTargettingForwardLink = @"https://aka.ms/tp/vstest/multitargetingdoc?view=vs-2019"; - Action action = () => InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp"); + public InferRunSettingsHelperTests() + { + _sourceArchitectures = new Dictionary(); + _sourceFrameworks = new Dictionary(); + } + + [TestMethod] + public void UpdateRunSettingsShouldThrowIfRunSettingsNodeDoesNotExist() + { + var settings = @""; + var xmlDocument = GetXmlDocument(settings); - Assert.That.Throws(action) - .WithMessage(string.Format("An error occurred while loading the settings. Error: {0}.", - string.Format("Invalid setting '{0}'. Invalid value '{1}' specified for '{2}'", - "RunConfiguration", - "foo", - "TargetFrameworkVersion"))); - } + Action action = () => InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp"); - [TestMethod] - public void UpdateRunSettingsShouldUpdateWithPlatformSettings() - { - var settings = @""; - var xmlDocument = this.GetXmlDocument(settings); + Assert.That.Throws(action) + .WithMessage(string.Format("An error occurred while loading the settings. Error: {0}.", + "Could not find 'RunSettings' node.")); + } - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp"); + [TestMethod] + public void UpdateRunSettingsShouldThrowIfPlatformNodeIsInvalid() + { + var settings = @"foo"; + var xmlDocument = GetXmlDocument(settings); - var xml = xmlDocument.OuterXml; + Action action = () => InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp"); - StringAssert.Contains(xml, "X86"); - } - - [TestMethod] - public void UpdateRunSettingsShouldUpdateWithFrameworkSettings() - { - var settings = @""; - var xmlDocument = this.GetXmlDocument(settings); + Assert.That.Throws(action) + .WithMessage(string.Format("An error occurred while loading the settings. Error: {0}.", + string.Format("Invalid setting '{0}'. Invalid value '{1}' specified for '{2}'", + "RunConfiguration", + "foo", + "TargetPlatform"))); + } - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp"); + [TestMethod] + public void UpdateRunSettingsShouldThrowIfFrameworkNodeIsInvalid() + { + var settings = @"foo"; + var xmlDocument = GetXmlDocument(settings); - var xml = xmlDocument.OuterXml; + Action action = () => InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp"); - StringAssert.Contains(xml, $"{Framework.DefaultFramework.Name}"); - } + Assert.That.Throws(action) + .WithMessage(string.Format("An error occurred while loading the settings. Error: {0}.", + string.Format("Invalid setting '{0}'. Invalid value '{1}' specified for '{2}'", + "RunConfiguration", + "foo", + "TargetFrameworkVersion"))); + } - [TestMethod] - public void UpdateRunSettingsShouldUpdateWithResultsDirectorySettings() - { - var settings = @""; - var xmlDocument = this.GetXmlDocument(settings); + [TestMethod] + public void UpdateRunSettingsShouldUpdateWithPlatformSettings() + { + var settings = @""; + var xmlDocument = GetXmlDocument(settings); - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp"); + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp"); - var xml = xmlDocument.OuterXml; + var xml = xmlDocument.OuterXml; - StringAssert.Contains(xml, "temp"); - } + StringAssert.Contains(xml, "X86"); + } - [TestMethod] - public void UpdateRunSettingsShouldNotUpdatePlatformIfRunSettingsAlreadyHasIt() - { - var settings = @"X86"; - var xmlDocument = this.GetXmlDocument(settings); + [TestMethod] + public void UpdateRunSettingsShouldUpdateWithFrameworkSettings() + { + var settings = @""; + var xmlDocument = GetXmlDocument(settings); - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp"); - var xml = xmlDocument.OuterXml; + var xml = xmlDocument.OuterXml; - StringAssert.Contains(xml, "X86"); - } + StringAssert.Contains(xml, $"{Framework.DefaultFramework.Name}"); + } - [TestMethod] - public void UpdateRunSettingsShouldNotUpdateFrameworkIfRunSettingsAlreadyHasIt() - { - var settings = @"Framework40"; - var xmlDocument = this.GetXmlDocument(settings); + [TestMethod] + public void UpdateRunSettingsShouldUpdateWithResultsDirectorySettings() + { + var settings = @""; + var xmlDocument = GetXmlDocument(settings); - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp"); - var xml = xmlDocument.OuterXml; + var xml = xmlDocument.OuterXml; - StringAssert.Contains(xml, ".NETFramework,Version=v4.0"); - } - //TargetFrameworkMoniker + StringAssert.Contains(xml, "temp"); + } - [TestMethod] - public void UpdateRunSettingsShouldAllowTargetFrameworkMonikerValue() - { + [TestMethod] + public void UpdateRunSettingsShouldNotUpdatePlatformIfRunSettingsAlreadyHasIt() + { + var settings = @"X86"; + var xmlDocument = GetXmlDocument(settings); - var settings = @".NETFramework,Version=v4.0"; - var xmlDocument = this.GetXmlDocument(settings); + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); + var xml = xmlDocument.OuterXml; - var xml = xmlDocument.OuterXml; + StringAssert.Contains(xml, "X86"); + } - StringAssert.Contains(xml, ".NETFramework,Version=v4.0"); - } + [TestMethod] + public void UpdateRunSettingsShouldNotUpdateFrameworkIfRunSettingsAlreadyHasIt() + { + var settings = @"Framework40"; + var xmlDocument = GetXmlDocument(settings); - [TestMethod] - public void UpdateRunSettingsShouldNotUpdateResultsDirectoryIfRunSettingsAlreadyHasIt() - { - var settings = @"someplace"; - var xmlDocument = this.GetXmlDocument(settings); + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); + var xml = xmlDocument.OuterXml; - var xml = xmlDocument.OuterXml; + StringAssert.Contains(xml, ".NETFramework,Version=v4.0"); + } + //TargetFrameworkMoniker - StringAssert.Contains(xml, "someplace"); - } + [TestMethod] + public void UpdateRunSettingsShouldAllowTargetFrameworkMonikerValue() + { - [TestMethod] - public void UpdateRunSettingsShouldNotUpdatePlatformOrFrameworkOrResultsDirectoryIfRunSettingsAlreadyHasIt() - { - var settings = @"X86Framework40someplace"; - var xmlDocument = this.GetXmlDocument(settings); + var settings = @".NETFramework,Version=v4.0"; + var xmlDocument = GetXmlDocument(settings); - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); - var xml = xmlDocument.OuterXml; + var xml = xmlDocument.OuterXml; - StringAssert.Contains(xml, "X86"); - StringAssert.Contains(xml, "Framework40"); - StringAssert.Contains(xml, "someplace"); - } + StringAssert.Contains(xml, ".NETFramework,Version=v4.0"); + } - [TestMethod] - public void UpdateRunSettingsWithAnEmptyRunSettingsShouldAddValuesSpecifiedInRunConfiguration() - { - var settings = @""; - var xmlDocument = this.GetXmlDocument(settings); + [TestMethod] + public void UpdateRunSettingsShouldNotUpdateResultsDirectoryIfRunSettingsAlreadyHasIt() + { + var settings = @"someplace"; + var xmlDocument = GetXmlDocument(settings); - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); - var xml = xmlDocument.OuterXml; + var xml = xmlDocument.OuterXml; - StringAssert.Contains(xml, "X64"); - StringAssert.Contains(xml, $"{Framework.DefaultFramework.Name}"); - StringAssert.Contains(xml, "temp"); - } + StringAssert.Contains(xml, "someplace"); + } - [TestMethod] - public void UpdateRunSettingsShouldReturnBackACompleteRunSettings() - { - var settings = @""; - var xmlDocument = this.GetXmlDocument(settings); + [TestMethod] + public void UpdateRunSettingsShouldNotUpdatePlatformOrFrameworkOrResultsDirectoryIfRunSettingsAlreadyHasIt() + { + var settings = @"X86Framework40someplace"; + var xmlDocument = GetXmlDocument(settings); - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); - var xml = xmlDocument.OuterXml; - var expectedRunSettings = string.Format("tempX64{0}", Framework.DefaultFramework.Name); + var xml = xmlDocument.OuterXml; - Assert.AreEqual(expectedRunSettings, xml); - } + StringAssert.Contains(xml, "X86"); + StringAssert.Contains(xml, "Framework40"); + StringAssert.Contains(xml, "someplace"); + } - [TestMethod] - public void UpdateRunSettingsShouldThrowIfArchitectureSetIsIncompatibleWithCurrentSystemArchitecture() - { - var settings = @""; - var xmlDocument = this.GetXmlDocument(settings); + [TestMethod] + public void UpdateRunSettingsWithAnEmptyRunSettingsShouldAddValuesSpecifiedInRunConfiguration() + { + var settings = @""; + var xmlDocument = GetXmlDocument(settings); - Action action = () => InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.ARM, Framework.DefaultFramework, "temp"); + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); - Assert.That.Throws(action) - .WithMessage(string.Format( - "Incompatible Target platform settings '{0}' with system architecture '{1}'.", - "ARM", - XmlRunSettingsUtilities.OSArchitecture.ToString())); - } + var xml = xmlDocument.OuterXml; - [TestMethod] - public void UpdateDesignModeOrCsiShouldNotModifyXmlIfNodeIsAlreadyPresent() - { - var settings = @"FalseFalse"; - var xmlDocument = this.GetXmlDocument(settings); + StringAssert.Contains(xml, "X64"); + StringAssert.Contains(xml, $"{Framework.DefaultFramework.Name}"); + StringAssert.Contains(xml, "temp"); + } - InferRunSettingsHelper.UpdateDesignMode(xmlDocument, true); - InferRunSettingsHelper.UpdateCollectSourceInformation(xmlDocument, true); + [TestMethod] + public void UpdateRunSettingsShouldReturnBackACompleteRunSettings() + { + var settings = @""; + var xmlDocument = GetXmlDocument(settings); - Assert.AreEqual("False", this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/DesignMode")); - Assert.AreEqual("False", this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/CollectSourceInformation")); - } + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); - [DataTestMethod] - [DataRow(true)] - [DataRow(false)] - public void UpdateDesignModeOrCsiShouldModifyXmlToValueProvided(bool val) - { - var settings = @""; - var xmlDocument = this.GetXmlDocument(settings); + var xml = xmlDocument.OuterXml; + var expectedRunSettings = string.Format("tempX64{0}", Framework.DefaultFramework.Name); - InferRunSettingsHelper.UpdateDesignMode(xmlDocument, val); - InferRunSettingsHelper.UpdateCollectSourceInformation(xmlDocument, val); + Assert.AreEqual(expectedRunSettings, xml); + } - Assert.AreEqual(val.ToString(), this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/DesignMode")); - Assert.AreEqual(val.ToString(), this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/CollectSourceInformation")); - } + [TestMethod] + public void UpdateRunSettingsShouldThrowIfArchitectureSetIsIncompatibleWithCurrentSystemArchitecture() + { + var settings = @""; + var xmlDocument = GetXmlDocument(settings); - [TestMethod] - public void MakeRunsettingsCompatibleShouldDeleteNewlyAddedRunConfigurationNode() - { - var settings = @"FalseFalse"; + Action action = () => InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.ARM, Framework.DefaultFramework, "temp"); - var result = InferRunSettingsHelper.MakeRunsettingsCompatible(settings); + Assert.That.Throws(action) + .WithMessage(string.Format( + "Incompatible Target platform settings '{0}' with system architecture '{1}'.", + "ARM", + XmlRunSettingsUtilities.OSArchitecture.ToString())); + } - Assert.IsTrue(result.IndexOf("DesignMode", StringComparison.OrdinalIgnoreCase) < 0); - } + [TestMethod] + public void UpdateDesignModeOrCsiShouldNotModifyXmlIfNodeIsAlreadyPresent() + { + var settings = @"FalseFalse"; + var xmlDocument = GetXmlDocument(settings); - [TestMethod] - public void MakeRunsettingsCompatibleShouldNotDeleteOldRunConfigurationNode() - { - var settings = @" + InferRunSettingsHelper.UpdateDesignMode(xmlDocument, true); + InferRunSettingsHelper.UpdateCollectSourceInformation(xmlDocument, true); + + Assert.AreEqual("False", GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/DesignMode")); + Assert.AreEqual("False", GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/CollectSourceInformation")); + } + + [DataTestMethod] + [DataRow(true)] + [DataRow(false)] + public void UpdateDesignModeOrCsiShouldModifyXmlToValueProvided(bool val) + { + var settings = @""; + var xmlDocument = GetXmlDocument(settings); + + InferRunSettingsHelper.UpdateDesignMode(xmlDocument, val); + InferRunSettingsHelper.UpdateCollectSourceInformation(xmlDocument, val); + + Assert.AreEqual(val.ToString(), GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/DesignMode")); + Assert.AreEqual(val.ToString(), GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/CollectSourceInformation")); + } + + [TestMethod] + public void MakeRunsettingsCompatibleShouldDeleteNewlyAddedRunConfigurationNode() + { + var settings = @"FalseFalse"; + + var result = InferRunSettingsHelper.MakeRunsettingsCompatible(settings); + + Assert.IsTrue(result.IndexOf("DesignMode", StringComparison.OrdinalIgnoreCase) < 0); + } + + [TestMethod] + public void MakeRunsettingsCompatibleShouldNotDeleteOldRunConfigurationNode() + { + var settings = @" False False @@ -286,22 +286,22 @@ public void MakeRunsettingsCompatibleShouldNotDeleteOldRunConfigurationNode() "; - var result = InferRunSettingsHelper.MakeRunsettingsCompatible(settings); - - Assert.IsTrue(result.IndexOf("TargetPlatform", StringComparison.OrdinalIgnoreCase) > 0); - Assert.IsTrue(result.IndexOf("TargetFrameworkVersion", StringComparison.OrdinalIgnoreCase) > 0); - Assert.IsTrue(result.IndexOf("TestAdaptersPaths", StringComparison.OrdinalIgnoreCase) > 0); - Assert.IsTrue(result.IndexOf("ResultsDirectory", StringComparison.OrdinalIgnoreCase) > 0); - Assert.IsTrue(result.IndexOf("SolutionDirectory", StringComparison.OrdinalIgnoreCase) > 0); - Assert.IsTrue(result.IndexOf("MaxCpuCount", StringComparison.OrdinalIgnoreCase) > 0); - Assert.IsTrue(result.IndexOf("DisableParallelization", StringComparison.OrdinalIgnoreCase) > 0); - Assert.IsTrue(result.IndexOf("DisableAppDomain", StringComparison.OrdinalIgnoreCase) > 0); - } - - [TestMethod] - public void UpdateTargetDeviceValueFromOldMsTestSettings() - { - var settings = @" + var result = InferRunSettingsHelper.MakeRunsettingsCompatible(settings); + + Assert.IsTrue(result.IndexOf("TargetPlatform", StringComparison.OrdinalIgnoreCase) > 0); + Assert.IsTrue(result.IndexOf("TargetFrameworkVersion", StringComparison.OrdinalIgnoreCase) > 0); + Assert.IsTrue(result.IndexOf("TestAdaptersPaths", StringComparison.OrdinalIgnoreCase) > 0); + Assert.IsTrue(result.IndexOf("ResultsDirectory", StringComparison.OrdinalIgnoreCase) > 0); + Assert.IsTrue(result.IndexOf("SolutionDirectory", StringComparison.OrdinalIgnoreCase) > 0); + Assert.IsTrue(result.IndexOf("MaxCpuCount", StringComparison.OrdinalIgnoreCase) > 0); + Assert.IsTrue(result.IndexOf("DisableParallelization", StringComparison.OrdinalIgnoreCase) > 0); + Assert.IsTrue(result.IndexOf("DisableAppDomain", StringComparison.OrdinalIgnoreCase) > 0); + } + + [TestMethod] + public void UpdateTargetDeviceValueFromOldMsTestSettings() + { + var settings = @" 2 False @@ -312,221 +312,215 @@ public void UpdateTargetDeviceValueFromOldMsTestSettings() "; - var xmlDocument = this.GetXmlDocument(settings); + var xmlDocument = GetXmlDocument(settings); - var result = InferRunSettingsHelper.TryGetDeviceXml(xmlDocument.CreateNavigator(), out string deviceXml); - Assert.IsTrue(result); + var result = InferRunSettingsHelper.TryGetDeviceXml(xmlDocument.CreateNavigator(), out string deviceXml); + Assert.IsTrue(result); - InferRunSettingsHelper.UpdateTargetDevice(xmlDocument, deviceXml); - Assert.AreEqual(deviceXml.ToString(), this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetDevice")); - } + InferRunSettingsHelper.UpdateTargetDevice(xmlDocument, deviceXml); + Assert.AreEqual(deviceXml.ToString(), GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetDevice")); + } - [TestMethod] - public void UpdateTargetPlatformShouldNotModifyXmlIfNodeIsAlreadyPresentForOverwriteFalse() - { - var settings = @"x86"; - var xmlDocument = this.GetXmlDocument(settings); + [TestMethod] + public void UpdateTargetPlatformShouldNotModifyXmlIfNodeIsAlreadyPresentForOverwriteFalse() + { + var settings = @"x86"; + var xmlDocument = GetXmlDocument(settings); - InferRunSettingsHelper.UpdateTargetPlatform(xmlDocument, "X64", overwrite: false); + InferRunSettingsHelper.UpdateTargetPlatform(xmlDocument, "X64", overwrite: false); - Assert.AreEqual("x86", this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetPlatform")); - } + Assert.AreEqual("x86", GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetPlatform")); + } - [TestMethod] - public void UpdateTargetPlatformShouldModifyXmlIfNodeIsAlreadyPresentForOverwriteTrue() - { - var settings = @"x86"; - var xmlDocument = this.GetXmlDocument(settings); + [TestMethod] + public void UpdateTargetPlatformShouldModifyXmlIfNodeIsAlreadyPresentForOverwriteTrue() + { + var settings = @"x86"; + var xmlDocument = GetXmlDocument(settings); - InferRunSettingsHelper.UpdateTargetPlatform(xmlDocument, "X64", overwrite: true); + InferRunSettingsHelper.UpdateTargetPlatform(xmlDocument, "X64", overwrite: true); - Assert.AreEqual("X64", this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetPlatform")); - } + Assert.AreEqual("X64", GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetPlatform")); + } - [TestMethod] - public void UpdateTargetPlatformShouldAddPlatformXmlNodeIfNotPresent() - { - var settings = @""; - var xmlDocument = this.GetXmlDocument(settings); + [TestMethod] + public void UpdateTargetPlatformShouldAddPlatformXmlNodeIfNotPresent() + { + var settings = @""; + var xmlDocument = GetXmlDocument(settings); - InferRunSettingsHelper.UpdateTargetPlatform(xmlDocument, "X64"); + InferRunSettingsHelper.UpdateTargetPlatform(xmlDocument, "X64"); - Assert.AreEqual("X64", this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetPlatform")); - } + Assert.AreEqual("X64", GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetPlatform")); + } - [TestMethod] - public void UpdateTargetFrameworkShouldNotModifyXmlIfNodeIsAlreadyPresentForOverwriteFalse() - { - var settings = @".NETFramework,Version=v4.5"; - var xmlDocument = this.GetXmlDocument(settings); + [TestMethod] + public void UpdateTargetFrameworkShouldNotModifyXmlIfNodeIsAlreadyPresentForOverwriteFalse() + { + var settings = @".NETFramework,Version=v4.5"; + var xmlDocument = GetXmlDocument(settings); - InferRunSettingsHelper.UpdateTargetFramework(xmlDocument, ".NETCoreApp,Version=v1.0", overwrite: false); + InferRunSettingsHelper.UpdateTargetFramework(xmlDocument, ".NETCoreApp,Version=v1.0", overwrite: false); - Assert.AreEqual(".NETFramework,Version=v4.5", this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetFrameworkVersion")); - } + Assert.AreEqual(".NETFramework,Version=v4.5", GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetFrameworkVersion")); + } - [TestMethod] - public void UpdateTargetFrameworkShouldModifyXmlIfNodeIsAlreadyPresentForOverwriteTrue() - { - var settings = @".NETFramework,Version=v4.5"; - var xmlDocument = this.GetXmlDocument(settings); + [TestMethod] + public void UpdateTargetFrameworkShouldModifyXmlIfNodeIsAlreadyPresentForOverwriteTrue() + { + var settings = @".NETFramework,Version=v4.5"; + var xmlDocument = GetXmlDocument(settings); - InferRunSettingsHelper.UpdateTargetFramework(xmlDocument, ".NETCoreApp,Version=v1.0", overwrite: true); + InferRunSettingsHelper.UpdateTargetFramework(xmlDocument, ".NETCoreApp,Version=v1.0", overwrite: true); - Assert.AreEqual(".NETCoreApp,Version=v1.0", this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetFrameworkVersion")); - } + Assert.AreEqual(".NETCoreApp,Version=v1.0", GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetFrameworkVersion")); + } - [TestMethod] - public void UpdateTargetFrameworkShouldAddFrameworkXmlNodeIfNotPresent() - { - var settings = @""; - var xmlDocument = this.GetXmlDocument(settings); + [TestMethod] + public void UpdateTargetFrameworkShouldAddFrameworkXmlNodeIfNotPresent() + { + var settings = @""; + var xmlDocument = GetXmlDocument(settings); - InferRunSettingsHelper.UpdateTargetFramework(xmlDocument, ".NETCoreApp,Version=v1.0"); + InferRunSettingsHelper.UpdateTargetFramework(xmlDocument, ".NETCoreApp,Version=v1.0"); - Assert.AreEqual(".NETCoreApp,Version=v1.0", this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetFrameworkVersion")); - } + Assert.AreEqual(".NETCoreApp,Version=v1.0", GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetFrameworkVersion")); + } - [TestMethod] - public void FilterCompatibleSourcesShouldIdentifyIncomaptiableSourcesAndConstructWarningMessage() - { - #region Arrange - sourceArchitectures["AnyCPU1net46.dll"] = Architecture.AnyCPU; - sourceArchitectures["x64net47.exe"] = Architecture.X64; - sourceArchitectures["x86net45.dll"] = Architecture.X86; + [TestMethod] + public void FilterCompatibleSourcesShouldIdentifyIncomaptiableSourcesAndConstructWarningMessage() + { + #region Arrange + _sourceArchitectures["AnyCPU1net46.dll"] = Architecture.AnyCPU; + _sourceArchitectures["x64net47.exe"] = Architecture.X64; + _sourceArchitectures["x86net45.dll"] = Architecture.X86; - sourceFrameworks["AnyCPU1net46.dll"] = frameworkNet46; - sourceFrameworks["x64net47.exe"] = frameworkNet47; - sourceFrameworks["x86net45.dll"] = frameworkNet45; + _sourceFrameworks["AnyCPU1net46.dll"] = _frameworkNet46; + _sourceFrameworks["x64net47.exe"] = _frameworkNet47; + _sourceFrameworks["x86net45.dll"] = _frameworkNet45; - StringBuilder sb = new StringBuilder(); - sb.AppendLine(); - sb.AppendLine(GetSourceIncompatibleMessage("AnyCPU1net46.dll")); - sb.AppendLine(GetSourceIncompatibleMessage("x64net47.exe")); - sb.AppendLine(GetSourceIncompatibleMessage("x86net45.dll")); + StringBuilder sb = new(); + sb.AppendLine(); + sb.AppendLine(GetSourceIncompatibleMessage("AnyCPU1net46.dll")); + sb.AppendLine(GetSourceIncompatibleMessage("x64net47.exe")); + sb.AppendLine(GetSourceIncompatibleMessage("x86net45.dll")); - var expected = string.Format(CultureInfo.CurrentCulture, OMResources.DisplayChosenSettings, frameworkNet45, Constants.DefaultPlatform, sb.ToString(), multiTargettingForwardLink); - #endregion + var expected = string.Format(CultureInfo.CurrentCulture, OMResources.DisplayChosenSettings, _frameworkNet45, Constants.DefaultPlatform, sb.ToString(), MultiTargettingForwardLink); - string warningMessage = string.Empty; - var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Constants.DefaultPlatform, Constants.DefaultPlatform, frameworkNet45, sourceArchitectures, sourceFrameworks, out warningMessage); - // None of the DLLs passed are compatible to the chosen settings - Assert.AreEqual(0, compatibleSources.Count()); - Assert.AreEqual(expected, warningMessage); - } + #endregion + var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Constants.DefaultPlatform, Constants.DefaultPlatform, _frameworkNet45, _sourceArchitectures, _sourceFrameworks, out string warningMessage); - [TestMethod] - public void FilterCompatibleSourcesShouldIdentifyCompatibleSources() - { - sourceArchitectures["x64net45.exe"] = Architecture.X64; - sourceArchitectures["x86net45.dll"] = Architecture.X86; - - sourceFrameworks["x64net45.exe"] = frameworkNet45; - sourceFrameworks["x86net45.dll"] = frameworkNet45; + // None of the DLLs passed are compatible to the chosen settings + Assert.AreEqual(0, compatibleSources.Count()); + Assert.AreEqual(expected, warningMessage); + } - StringBuilder sb = new StringBuilder(); - sb.AppendLine(); - sb.AppendLine(GetSourceIncompatibleMessage("x86net45.dll")); + [TestMethod] + public void FilterCompatibleSourcesShouldIdentifyCompatibleSources() + { + _sourceArchitectures["x64net45.exe"] = Architecture.X64; + _sourceArchitectures["x86net45.dll"] = Architecture.X86; - var expected = string.Format(CultureInfo.CurrentCulture, OMResources.DisplayChosenSettings, frameworkNet45, Constants.DefaultPlatform, sb.ToString(), multiTargettingForwardLink); + _sourceFrameworks["x64net45.exe"] = _frameworkNet45; + _sourceFrameworks["x86net45.dll"] = _frameworkNet45; - string warningMessage = string.Empty; - var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Constants.DefaultPlatform, Constants.DefaultPlatform, frameworkNet45, sourceArchitectures, sourceFrameworks, out warningMessage); - - // only "x64net45.exe" is the compatible source - Assert.AreEqual(1, compatibleSources.Count()); - Assert.AreEqual(expected, warningMessage); - } + StringBuilder sb = new(); + sb.AppendLine(); + sb.AppendLine(GetSourceIncompatibleMessage("x86net45.dll")); - [TestMethod] - public void FilterCompatibleSourcesShouldNotComposeWarningIfSettingsAreCorrect() - { - sourceArchitectures["x86net45.dll"] = Architecture.X86; - sourceFrameworks["x86net45.dll"] = frameworkNet45; - - string warningMessage = string.Empty; - var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Architecture.X86, Constants.DefaultPlatform, frameworkNet45, sourceArchitectures, sourceFrameworks, out warningMessage); + var expected = string.Format(CultureInfo.CurrentCulture, OMResources.DisplayChosenSettings, _frameworkNet45, Constants.DefaultPlatform, sb.ToString(), MultiTargettingForwardLink); - // only "x86net45.dll" is the compatible source - Assert.AreEqual(1, compatibleSources.Count()); - Assert.IsTrue(string.IsNullOrEmpty(warningMessage)); - } - - [TestMethod] - public void FilterCompatibleSourcesShouldRetrunWarningMessageIfNoConflict() - { - sourceArchitectures["x64net45.exe"] = Architecture.X64; - sourceFrameworks["x64net45.exe"] = frameworkNet45; + var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Constants.DefaultPlatform, Constants.DefaultPlatform, _frameworkNet45, _sourceArchitectures, _sourceFrameworks, out string warningMessage); - string warningMessage = string.Empty; - var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Constants.DefaultPlatform, Constants.DefaultPlatform, frameworkNet45, sourceArchitectures, sourceFrameworks, out warningMessage); - - Assert.IsTrue(string.IsNullOrEmpty(warningMessage)); - } - - [TestMethod] - public void IsTestSettingsEnabledShouldReturnTrueIfRunsettingsHasTestSettings() - { - string runsettingsString = @" + // only "x64net45.exe" is the compatible source + Assert.AreEqual(1, compatibleSources.Count()); + Assert.AreEqual(expected, warningMessage); + } + + [TestMethod] + public void FilterCompatibleSourcesShouldNotComposeWarningIfSettingsAreCorrect() + { + _sourceArchitectures["x86net45.dll"] = Architecture.X86; + _sourceFrameworks["x86net45.dll"] = _frameworkNet45; + + var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Architecture.X86, Constants.DefaultPlatform, _frameworkNet45, _sourceArchitectures, _sourceFrameworks, out string warningMessage); + + // only "x86net45.dll" is the compatible source + Assert.AreEqual(1, compatibleSources.Count()); + Assert.IsTrue(string.IsNullOrEmpty(warningMessage)); + } + + [TestMethod] + public void FilterCompatibleSourcesShouldRetrunWarningMessageIfNoConflict() + { + _sourceArchitectures["x64net45.exe"] = Architecture.X64; + _sourceFrameworks["x64net45.exe"] = _frameworkNet45; + _ = InferRunSettingsHelper.FilterCompatibleSources(Constants.DefaultPlatform, Constants.DefaultPlatform, _frameworkNet45, _sourceArchitectures, _sourceFrameworks, out string warningMessage); + + Assert.IsTrue(string.IsNullOrEmpty(warningMessage)); + } + + [TestMethod] + public void IsTestSettingsEnabledShouldReturnTrueIfRunsettingsHasTestSettings() + { + string runsettingsString = @" C:\temp.testsettings true "; - Assert.IsTrue(InferRunSettingsHelper.IsTestSettingsEnabled(runsettingsString)); - } + Assert.IsTrue(InferRunSettingsHelper.IsTestSettingsEnabled(runsettingsString)); + } - [TestMethod] - public void IsTestSettingsEnabledShouldReturnFalseIfRunsettingsDoesnotHaveTestSettings() - { - string runsettingsString = @" + [TestMethod] + public void IsTestSettingsEnabledShouldReturnFalseIfRunsettingsDoesnotHaveTestSettings() + { + string runsettingsString = @" true "; - Assert.IsFalse(InferRunSettingsHelper.IsTestSettingsEnabled(runsettingsString)); - } + Assert.IsFalse(InferRunSettingsHelper.IsTestSettingsEnabled(runsettingsString)); + } - [TestMethod] - public void TryGetLegacySettingsForRunSettingsWithoutLegacySettingsShouldReturnFalse() - { - string runSettingsXml = @" + [TestMethod] + public void TryGetLegacySettingsForRunSettingsWithoutLegacySettingsShouldReturnFalse() + { + string runSettingsXml = @" "; + Assert.IsFalse(InferRunSettingsHelper.TryGetLegacySettingElements(runSettingsXml, out _)); + } - Assert.IsFalse(InferRunSettingsHelper.TryGetLegacySettingElements(runSettingsXml, out Dictionary legacySettings)); - } - - [TestMethod] - public void TryGetLegacySettingsForRunSettingsWithInvalidLegacySettingsShouldReturnFalse() - { - string runSettingsXml = @" + [TestMethod] + public void TryGetLegacySettingsForRunSettingsWithInvalidLegacySettingsShouldReturnFalse() + { + string runSettingsXml = @" "; + Assert.IsFalse(InferRunSettingsHelper.TryGetLegacySettingElements(runSettingsXml, out _)); + } - Assert.IsFalse(InferRunSettingsHelper.TryGetLegacySettingElements(runSettingsXml, out Dictionary legacySettings)); - } - - [TestMethod] - public void TryGetLegacySettingsForRunSettingsWithEmptyLegacySettingsShouldReturnTrueAndEmptyListForLegacySettingElements() - { - string runSettingsXml = @" + [TestMethod] + public void TryGetLegacySettingsForRunSettingsWithEmptyLegacySettingsShouldReturnTrueAndEmptyListForLegacySettingElements() + { + string runSettingsXml = @" "; - Assert.IsTrue(InferRunSettingsHelper.TryGetLegacySettingElements(runSettingsXml, out Dictionary legacySettings)); - Assert.AreEqual(0, legacySettings.Count); - } + Assert.IsTrue(InferRunSettingsHelper.TryGetLegacySettingElements(runSettingsXml, out Dictionary legacySettings)); + Assert.AreEqual(0, legacySettings.Count); + } - [TestMethod] - public void TryGetLegacySettingsForRunSettingsWithValidLegacySettingsShouldReturnTrueAndListForLegacySettingElements() - { - string runSettingsXml = @" + [TestMethod] + public void TryGetLegacySettingsForRunSettingsWithValidLegacySettingsShouldReturnTrueAndListForLegacySettingElements() + { + string runSettingsXml = @" @@ -544,21 +538,21 @@ public void TryGetLegacySettingsForRunSettingsWithValidLegacySettingsShouldRetur "; - var expectedElements = "Deployment, Scripts, Execution, AssemblyResolution, Timeouts, Hosts"; - var expectedDeploymentAttributes = "enabled, deploySatelliteAssemblies"; - var expectedExecutionAttributes = "hostProcessPlatform, parallelTestCount"; - - Assert.IsTrue(InferRunSettingsHelper.TryGetLegacySettingElements(runSettingsXml, out Dictionary legacySettings)); - Assert.AreEqual(3, legacySettings.Count, "count does not match"); - Assert.AreEqual(expectedElements, legacySettings["Elements"]); - Assert.AreEqual(expectedDeploymentAttributes, legacySettings["DeploymentAttributes"]); - Assert.AreEqual(expectedExecutionAttributes, legacySettings["ExecutionAttributes"]); - } - - [TestMethod] - public void GetEnvironmentVariablesWithValidValuesInRunSettingsShouldReturnValidDictionary() - { - string runSettingsXml = @" + var expectedElements = "Deployment, Scripts, Execution, AssemblyResolution, Timeouts, Hosts"; + var expectedDeploymentAttributes = "enabled, deploySatelliteAssemblies"; + var expectedExecutionAttributes = "hostProcessPlatform, parallelTestCount"; + + Assert.IsTrue(InferRunSettingsHelper.TryGetLegacySettingElements(runSettingsXml, out Dictionary legacySettings)); + Assert.AreEqual(3, legacySettings.Count, "count does not match"); + Assert.AreEqual(expectedElements, legacySettings["Elements"]); + Assert.AreEqual(expectedDeploymentAttributes, legacySettings["DeploymentAttributes"]); + Assert.AreEqual(expectedExecutionAttributes, legacySettings["ExecutionAttributes"]); + } + + [TestMethod] + public void GetEnvironmentVariablesWithValidValuesInRunSettingsShouldReturnValidDictionary() + { + string runSettingsXml = @" C:\temp @@ -567,17 +561,17 @@ public void GetEnvironmentVariablesWithValidValuesInRunSettingsShouldReturnValid "; - var envVars = InferRunSettingsHelper.GetEnvironmentVariables(runSettingsXml); + var envVars = InferRunSettingsHelper.GetEnvironmentVariables(runSettingsXml); - Assert.AreEqual(2, envVars.Count); - Assert.AreEqual(@"C:\temp", envVars["RANDOM_PATH"]); - Assert.AreEqual(@"C:\temp2", envVars["RANDOM_PATH2"]); - } + Assert.AreEqual(2, envVars.Count); + Assert.AreEqual(@"C:\temp", envVars["RANDOM_PATH"]); + Assert.AreEqual(@"C:\temp2", envVars["RANDOM_PATH2"]); + } - [TestMethod] - public void GetEnvironmentVariablesWithDuplicateEnvValuesInRunSettingsShouldReturnValidDictionary() - { - string runSettingsXml = @" + [TestMethod] + public void GetEnvironmentVariablesWithDuplicateEnvValuesInRunSettingsShouldReturnValidDictionary() + { + string runSettingsXml = @" C:\temp @@ -586,30 +580,30 @@ public void GetEnvironmentVariablesWithDuplicateEnvValuesInRunSettingsShouldRetu "; - var envVars = InferRunSettingsHelper.GetEnvironmentVariables(runSettingsXml); + var envVars = InferRunSettingsHelper.GetEnvironmentVariables(runSettingsXml); - Assert.AreEqual(1, envVars.Count); - Assert.AreEqual(@"C:\temp", envVars["RANDOM_PATH"]); - } + Assert.AreEqual(1, envVars.Count); + Assert.AreEqual(@"C:\temp", envVars["RANDOM_PATH"]); + } - [TestMethod] - public void GetEnvironmentVariablesWithEmptyVariablesInRunSettingsShouldReturnEmptyDictionary() - { - string runSettingsXml = @" + [TestMethod] + public void GetEnvironmentVariablesWithEmptyVariablesInRunSettingsShouldReturnEmptyDictionary() + { + string runSettingsXml = @" "; - var envVars = InferRunSettingsHelper.GetEnvironmentVariables(runSettingsXml); - Assert.AreEqual(0, envVars.Count); - } + var envVars = InferRunSettingsHelper.GetEnvironmentVariables(runSettingsXml); + Assert.AreEqual(0, envVars.Count); + } - [TestMethod] - public void GetEnvironmentVariablesWithInvalidValuesInRunSettingsShouldReturnNull() - { - string runSettingsXml = @" + [TestMethod] + public void GetEnvironmentVariablesWithInvalidValuesInRunSettingsShouldReturnNull() + { + string runSettingsXml = @" @@ -617,29 +611,29 @@ public void GetEnvironmentVariablesWithInvalidValuesInRunSettingsShouldReturnNul "; - var envVars = InferRunSettingsHelper.GetEnvironmentVariables(runSettingsXml); - Assert.IsNull(envVars); - } + var envVars = InferRunSettingsHelper.GetEnvironmentVariables(runSettingsXml); + Assert.IsNull(envVars); + } - [TestMethod] - public void GetEnvironmentVariablesWithoutEnvVarNodeInRunSettingsShouldReturnNull() - { - string runSettingsXml = @" + [TestMethod] + public void GetEnvironmentVariablesWithoutEnvVarNodeInRunSettingsShouldReturnNull() + { + string runSettingsXml = @" "; - var envVars = InferRunSettingsHelper.GetEnvironmentVariables(runSettingsXml); - Assert.IsNull(envVars); - } + var envVars = InferRunSettingsHelper.GetEnvironmentVariables(runSettingsXml); + Assert.IsNull(envVars); + } - #region RunSettingsIncompatibeWithTestSettings Tests + #region RunSettingsIncompatibeWithTestSettings Tests - [TestMethod] - public void RunSettingsWithCodeCoverageAndInlineTestSettingsXml() - { - // Setup - var runSettingsWithCodeCoverageAndInlineTestSettingsXml = @" + [TestMethod] + public void RunSettingsWithCodeCoverageAndInlineTestSettingsXml() + { + // Setup + var runSettingsWithCodeCoverageAndInlineTestSettingsXml = @" Framework45 @@ -665,17 +659,17 @@ public void RunSettingsWithCodeCoverageAndInlineTestSettingsXml() "; - // Act and validate - Assert.IsFalse(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( - runSettingsWithCodeCoverageAndInlineTestSettingsXml), "Invalid response"); - Assert.IsTrue(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( - ConvertOutOfProcToInProcDataCollectionSettings(runSettingsWithCodeCoverageAndInlineTestSettingsXml)), "Invalid response"); - } - - [TestMethod] - public void RunSettingsWithFakesAndCodeCoverageAndInlineTestSettingsXml() - { - var runSettingsWithFakesAndCodeCoverageAndInlineTestSettingsXml = @" + // Act and validate + Assert.IsFalse(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( + runSettingsWithCodeCoverageAndInlineTestSettingsXml), "Invalid response"); + Assert.IsTrue(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( + ConvertOutOfProcToInProcDataCollectionSettings(runSettingsWithCodeCoverageAndInlineTestSettingsXml)), "Invalid response"); + } + + [TestMethod] + public void RunSettingsWithFakesAndCodeCoverageAndInlineTestSettingsXml() + { + var runSettingsWithFakesAndCodeCoverageAndInlineTestSettingsXml = @" Framework45 @@ -698,17 +692,17 @@ public void RunSettingsWithFakesAndCodeCoverageAndInlineTestSettingsXml() "; - // Act and validate - Assert.IsFalse(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( - runSettingsWithFakesAndCodeCoverageAndInlineTestSettingsXml), "Invalid response"); - Assert.IsTrue(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( - ConvertOutOfProcToInProcDataCollectionSettings(runSettingsWithFakesAndCodeCoverageAndInlineTestSettingsXml)), "Invalid response"); - } - - [TestMethod] - public void RunSettingsWithEnabledAndDisabledCollectorAndNoEmbeddedTestSettingsXml() - { - var runSettingsWithEnabledAndDisabledCollectorAndInlineTestSettingsXml = @" + // Act and validate + Assert.IsFalse(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( + runSettingsWithFakesAndCodeCoverageAndInlineTestSettingsXml), "Invalid response"); + Assert.IsTrue(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( + ConvertOutOfProcToInProcDataCollectionSettings(runSettingsWithFakesAndCodeCoverageAndInlineTestSettingsXml)), "Invalid response"); + } + + [TestMethod] + public void RunSettingsWithEnabledAndDisabledCollectorAndNoEmbeddedTestSettingsXml() + { + var runSettingsWithEnabledAndDisabledCollectorAndInlineTestSettingsXml = @" Framework45 @@ -728,17 +722,17 @@ public void RunSettingsWithEnabledAndDisabledCollectorAndNoEmbeddedTestSettingsX "; - // Act and validate - Assert.IsFalse(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( - runSettingsWithEnabledAndDisabledCollectorAndInlineTestSettingsXml), "Invalid response"); - Assert.IsFalse(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( - ConvertOutOfProcToInProcDataCollectionSettings(runSettingsWithEnabledAndDisabledCollectorAndInlineTestSettingsXml)), "Invalid response"); - } - - [TestMethod] - public void RunSettingsWithEnabledAndDisabledCollectorAndInlineTestSettingsXml() - { - var runSettingsWithEnabledAndDisabledCollectorAndInlineTestSettingsXml = @" + // Act and validate + Assert.IsFalse(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( + runSettingsWithEnabledAndDisabledCollectorAndInlineTestSettingsXml), "Invalid response"); + Assert.IsFalse(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( + ConvertOutOfProcToInProcDataCollectionSettings(runSettingsWithEnabledAndDisabledCollectorAndInlineTestSettingsXml)), "Invalid response"); + } + + [TestMethod] + public void RunSettingsWithEnabledAndDisabledCollectorAndInlineTestSettingsXml() + { + var runSettingsWithEnabledAndDisabledCollectorAndInlineTestSettingsXml = @" Framework45 @@ -763,17 +757,17 @@ public void RunSettingsWithEnabledAndDisabledCollectorAndInlineTestSettingsXml() "; - // Act and validate - Assert.IsTrue(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( - runSettingsWithEnabledAndDisabledCollectorAndInlineTestSettingsXml), "Invalid response"); - Assert.IsTrue(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( - ConvertOutOfProcToInProcDataCollectionSettings(runSettingsWithEnabledAndDisabledCollectorAndInlineTestSettingsXml)), "Invalid response"); - } - - [TestMethod] - public void RunSettingsWithDisabledCollectionSettingsAndInlineTestSettingsXml() - { - var runSettingsWithDisabledCollectionSettingsAndInlineTestSettingsXml = @" + // Act and validate + Assert.IsTrue(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( + runSettingsWithEnabledAndDisabledCollectorAndInlineTestSettingsXml), "Invalid response"); + Assert.IsTrue(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( + ConvertOutOfProcToInProcDataCollectionSettings(runSettingsWithEnabledAndDisabledCollectorAndInlineTestSettingsXml)), "Invalid response"); + } + + [TestMethod] + public void RunSettingsWithDisabledCollectionSettingsAndInlineTestSettingsXml() + { + var runSettingsWithDisabledCollectionSettingsAndInlineTestSettingsXml = @" Framework45 @@ -798,44 +792,43 @@ public void RunSettingsWithDisabledCollectionSettingsAndInlineTestSettingsXml() "; - // Act and validate - Assert.IsFalse(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( - runSettingsWithDisabledCollectionSettingsAndInlineTestSettingsXml), "Invalid response"); - Assert.IsFalse(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( - ConvertOutOfProcToInProcDataCollectionSettings(runSettingsWithDisabledCollectionSettingsAndInlineTestSettingsXml)), "Invalid response"); - } - - #endregion - - #region Private Methods - - private string GetSourceIncompatibleMessage(string source) - { - return string.Format(CultureInfo.CurrentCulture, OMResources.SourceIncompatible, source, sourceFrameworks[source].Name, sourceArchitectures[source]); - } - - private XmlDocument GetXmlDocument(string settingsXml) - { - var doc = new XmlDocument(); - doc.LoadXml(settingsXml); - - return doc; - } - - private string GetValueOf(XmlDocument xmlDocument, string xpath) - { - return xmlDocument.SelectSingleNode(xpath).InnerText; - } - - private string ConvertOutOfProcToInProcDataCollectionSettings(string settings) - { - return settings.Replace("DataCollectionRunSettings", "InProcDataCollectionRunSettings") - .Replace("", "") - .Replace("", "") - .Replace("", ""); - } - - #endregion - } -} + // Act and validate + Assert.IsFalse(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( + runSettingsWithDisabledCollectionSettingsAndInlineTestSettingsXml), "Invalid response"); + Assert.IsFalse(InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings( + ConvertOutOfProcToInProcDataCollectionSettings(runSettingsWithDisabledCollectionSettingsAndInlineTestSettingsXml)), "Invalid response"); + } + + #endregion + + #region Private Methods + + private string GetSourceIncompatibleMessage(string source) + { + return string.Format(CultureInfo.CurrentCulture, OMResources.SourceIncompatible, source, _sourceFrameworks[source].Name, _sourceArchitectures[source]); + } + + private XmlDocument GetXmlDocument(string settingsXml) + { + var doc = new XmlDocument(); + doc.LoadXml(settingsXml); + + return doc; + } + + private string GetValueOf(XmlDocument xmlDocument, string xpath) + { + return xmlDocument.SelectSingleNode(xpath).InnerText; + } + + private string ConvertOutOfProcToInProcDataCollectionSettings(string settings) + { + return settings.Replace("DataCollectionRunSettings", "InProcDataCollectionRunSettings") + .Replace("", "") + .Replace("", "") + .Replace("", ""); + } + + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/MSTestSettingsUtilitiesTests.cs b/test/Microsoft.TestPlatform.Utilities.UnitTests/MSTestSettingsUtilitiesTests.cs index 366e32871a..6a107c74a2 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/MSTestSettingsUtilitiesTests.cs +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/MSTestSettingsUtilitiesTests.cs @@ -1,122 +1,121 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Utilities.Tests +namespace Microsoft.TestPlatform.Utilities.Tests; + +using System; +using System.Xml; + +using Microsoft.VisualStudio.TestPlatform.Utilities; +using VisualStudio.TestTools.UnitTesting; +using MSTest.TestFramework.AssertExtensions; + +[TestClass] +public class MsTestSettingsUtilitiesTests { - using System; - using System.Xml; + #region IsLegacyTestSettingsFile tests + + [TestMethod] + public void IsLegacyTestSettingsFileShouldReturnTrueIfTestSettingsExtension() + { + Assert.IsTrue(MSTestSettingsUtilities.IsLegacyTestSettingsFile("C:\\temp\\t.testsettings")); + } + + [TestMethod] + public void IsLegacyTestSettingsFileShouldReturnTrueIfTestRunConfigExtension() + { + Assert.IsTrue(MSTestSettingsUtilities.IsLegacyTestSettingsFile("C:\\temp\\t.testrunConfig")); + } + + [TestMethod] + public void IsLegacyTestSettingsFileShouldReturnTrueIfVsmdiExtension() + { + Assert.IsTrue(MSTestSettingsUtilities.IsLegacyTestSettingsFile("C:\\temp\\t.vsmdi")); + } + + #endregion - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using MSTest.TestFramework.AssertExtensions; + #region Import tests - [TestClass] - public class MSTestSettingsUtilitiesTests + [TestMethod] + public void ImportShouldThrowIfNotLegacySettingsFile() { - #region IsLegacyTestSettingsFile tests - - [TestMethod] - public void IsLegacyTestSettingsFileShouldReturnTrueIfTestSettingsExtension() - { - Assert.IsTrue(MSTestSettingsUtilities.IsLegacyTestSettingsFile("C:\\temp\\t.testsettings")); - } - - [TestMethod] - public void IsLegacyTestSettingsFileShouldReturnTrueIfTestRunConfigExtension() - { - Assert.IsTrue(MSTestSettingsUtilities.IsLegacyTestSettingsFile("C:\\temp\\t.testrunConfig")); - } - - [TestMethod] - public void IsLegacyTestSettingsFileShouldReturnTrueIfVSMDIExtension() - { - Assert.IsTrue(MSTestSettingsUtilities.IsLegacyTestSettingsFile("C:\\temp\\t.vsmdi")); - } - - #endregion - - #region Import tests - - [TestMethod] - public void ImportShouldThrowIfNotLegacySettingsFile() - { - var defaultRunSettingsXml = ""; - var xmlDocument = new XmlDocument(); - xmlDocument.LoadXml(defaultRunSettingsXml); - - Action action = - () => + var defaultRunSettingsXml = ""; + var xmlDocument = new XmlDocument(); + xmlDocument.LoadXml(defaultRunSettingsXml); + + Action action = + () => MSTestSettingsUtilities.Import( "C:\\temp\\r.runsettings", xmlDocument); - Assert.That.Throws(action).WithMessage("Unexpected settings file specified."); - } - - [TestMethod] - public void ImportShouldThrowIfDefaultRunSettingsIsIncorrect() - { - var defaultRunSettingsXml = ""; - var xmlDocument = new XmlDocument(); - xmlDocument.LoadXml(defaultRunSettingsXml); - - Action action = - () => + Assert.That.Throws(action).WithMessage("Unexpected settings file specified."); + } + + [TestMethod] + public void ImportShouldThrowIfDefaultRunSettingsIsIncorrect() + { + var defaultRunSettingsXml = ""; + var xmlDocument = new XmlDocument(); + xmlDocument.LoadXml(defaultRunSettingsXml); + + Action action = + () => MSTestSettingsUtilities.Import( "C:\\temp\\r.testsettings", xmlDocument); - Assert.That.Throws(action).WithMessage("Could not find 'RunSettings' node."); - } - - [TestMethod] - public void ImportShouldEmbedTestSettingsInformation() - { - var defaultRunSettingsXml = ""; - var xmlDocument = new XmlDocument(); - xmlDocument.LoadXml(defaultRunSettingsXml); - var finalxPath = MSTestSettingsUtilities.Import( - "C:\\temp\\r.testsettings", - xmlDocument); - - var finalSettingsXml = finalxPath.CreateNavigator().OuterXml; - - var expectedSettingsXml = string.Join(Environment.NewLine, - "", - " ", - " C:\\temp\\r.testsettings", - " true", - " ", - " ", - "" - ); - - Assert.AreEqual(expectedSettingsXml, finalSettingsXml); - } - - [TestMethod] - public void ImportShouldEmbedTestSettingsAndDefaultRunConfigurationInformation() - { - var defaultRunSettingsXml = ""; - var xmlDocument = new XmlDocument(); - xmlDocument.LoadXml(defaultRunSettingsXml); - var finalxPath = MSTestSettingsUtilities.Import( - "C:\\temp\\r.testsettings", - xmlDocument); - - var finalSettingsXml = finalxPath.CreateNavigator().OuterXml; - - var expectedSettingsXml = string.Join(Environment.NewLine, - "", - " ", - " ", - " C:\\temp\\r.testsettings", - " true", - " ", - "" - ); - - Assert.AreEqual(expectedSettingsXml, finalSettingsXml); - } - - #endregion + Assert.That.Throws(action).WithMessage("Could not find 'RunSettings' node."); + } + + [TestMethod] + public void ImportShouldEmbedTestSettingsInformation() + { + var defaultRunSettingsXml = ""; + var xmlDocument = new XmlDocument(); + xmlDocument.LoadXml(defaultRunSettingsXml); + var finalxPath = MSTestSettingsUtilities.Import( + "C:\\temp\\r.testsettings", + xmlDocument); + + var finalSettingsXml = finalxPath.CreateNavigator().OuterXml; + + var expectedSettingsXml = string.Join(Environment.NewLine, + "", + " ", + " C:\\temp\\r.testsettings", + " true", + " ", + " ", + "" + ); + + Assert.AreEqual(expectedSettingsXml, finalSettingsXml); + } + + [TestMethod] + public void ImportShouldEmbedTestSettingsAndDefaultRunConfigurationInformation() + { + var defaultRunSettingsXml = ""; + var xmlDocument = new XmlDocument(); + xmlDocument.LoadXml(defaultRunSettingsXml); + var finalxPath = MSTestSettingsUtilities.Import( + "C:\\temp\\r.testsettings", + xmlDocument); + + var finalSettingsXml = finalxPath.CreateNavigator().OuterXml; + + var expectedSettingsXml = string.Join(Environment.NewLine, + "", + " ", + " ", + " C:\\temp\\r.testsettings", + " true", + " ", + "" + ); + + Assert.AreEqual(expectedSettingsXml, finalSettingsXml); } -} + + #endregion +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/Program.cs b/test/Microsoft.TestPlatform.Utilities.UnitTests/Program.cs index 7feda95b4b..ad08a1dbfa 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/Program.cs +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/Program.cs @@ -1,11 +1,11 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Utilities.UnitTests +namespace Microsoft.TestPlatform.Utilities.UnitTests; + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/StringUtilitiesTests.cs b/test/Microsoft.TestPlatform.Utilities.UnitTests/StringUtilitiesTests.cs index c285f3a155..f3d9daa580 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/StringUtilitiesTests.cs +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/StringUtilitiesTests.cs @@ -3,96 +3,97 @@ using System.Linq; -namespace Microsoft.TestPlatform.Utilities.UnitTests +namespace Microsoft.TestPlatform.Utilities.UnitTests; + +using Castle.Core.Internal; + +using Microsoft.VisualStudio.TestPlatform.Utilities; + +using VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class StringUtilitiesTests { - using Castle.Core.Internal; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; + [TestMethod] + public void SplitShouldReturnWhenStringisNullOrEmpty() + { + var argsList = string.Empty.Tokenize(SplitChar, EscapeChar); + + Assert.IsTrue(argsList.IsNullOrEmpty()); + } + + [TestMethod] + public void SplitShouldReturnWhenStringDoesntContainSplitChar() + { + var data = "foobar"; + var argsList = data.Tokenize(SplitChar, EscapeChar); + var enumerable = argsList as string[] ?? argsList.ToArray(); + + Assert.IsTrue(enumerable.Length == 1); + Assert.IsTrue(enumerable.First().Equals(data)); + } + + [TestMethod] + public void SplitShouldSplitWhenStringContainsSplitChar() + { + var data = "foo,bar"; + var argsList = data.Tokenize(SplitChar, EscapeChar); + var enumerable = argsList as string[] ?? argsList.ToArray(); + + Assert.IsTrue(enumerable.Length == 2); + } + + [TestMethod] + public void SplitShouldSplitWhenStringWithSplitCharStartEnd() + { + var data = ",foo,bar,"; + var argsList = data.Tokenize(SplitChar, EscapeChar); + var enumerable = argsList as string[] ?? argsList.ToArray(); + + Assert.IsTrue(enumerable.Length == 4); + } + + [TestMethod] + public void SplitShouldEscapeSplitCharWhenEscapedCharPresent() + { + var data = "foo\\,bar"; + var argsList = data.Tokenize(SplitChar, EscapeChar); + var enumerable = argsList as string[] ?? argsList.ToArray(); + + Assert.IsTrue(enumerable.Length == 1); + Assert.IsTrue(enumerable.First().Equals("foo,bar")); + } + + [TestMethod] + public void SplitShouldEscapeSplitCharWhenEscapedNonEscapedCharPresent() + { + var data = "foo\\,,bar"; + var argsList = data.Tokenize(SplitChar, EscapeChar); + var enumerable = argsList as string[] ?? argsList.ToArray(); + Assert.IsTrue(enumerable.Length == 2); + Assert.IsTrue(enumerable.First().Equals("foo,")); + } + + [TestMethod] + public void SplitShouldSplitWhenOnlySplitCharPresent() + { + var data = ","; + var argsList = data.Tokenize(SplitChar, EscapeChar); + var enumerable = argsList as string[] ?? argsList.ToArray(); - [TestClass] - public class StringUtilitiesTests + Assert.IsTrue(enumerable.Length == 2); + } + + [TestMethod] + public void SplitShouldNotSplitWhenNoSplitCharPresent() { - [TestMethod] - public void SplitShouldReturnWhenStringisNullOrEmpty() - { - var argsList = string.Empty.Tokenize(SplitChar, EscapeChar); - - Assert.IsTrue(argsList.IsNullOrEmpty()); - } - - [TestMethod] - public void SplitShouldReturnWhenStringDoesntContainSplitChar() - { - var data = "foobar"; - var argsList = data.Tokenize(SplitChar, EscapeChar); - var enumerable = argsList as string[] ?? argsList.ToArray(); - - Assert.IsTrue(enumerable.Length == 1); - Assert.IsTrue(enumerable.First().Equals(data)); - } - - [TestMethod] - public void SplitShouldSplitWhenStringContainsSplitChar() - { - var data = "foo,bar"; - var argsList = data.Tokenize(SplitChar, EscapeChar); - var enumerable = argsList as string[] ?? argsList.ToArray(); - - Assert.IsTrue(enumerable.Length == 2); - } - - [TestMethod] - public void SplitShouldSplitWhenStringWithSplitCharStartEnd() - { - var data = ",foo,bar,"; - var argsList = data.Tokenize(SplitChar, EscapeChar); - var enumerable = argsList as string[] ?? argsList.ToArray(); - - Assert.IsTrue(enumerable.Length == 4); - } - - [TestMethod] - public void SplitShouldEscapeSplitCharWhenEscapedCharPresent() - { - var data = "foo\\,bar"; - var argsList = data.Tokenize(SplitChar, EscapeChar); - var enumerable = argsList as string[] ?? argsList.ToArray(); - - Assert.IsTrue(enumerable.Length == 1); - Assert.IsTrue(enumerable.First().Equals("foo,bar")); - } - - [TestMethod] - public void SplitShouldEscapeSplitCharWhenEscapedNonEscapedCharPresent() - { - var data = "foo\\,,bar"; - var argsList = data.Tokenize(SplitChar, EscapeChar); - var enumerable = argsList as string[] ?? argsList.ToArray(); - Assert.IsTrue(enumerable.Length == 2); - Assert.IsTrue(enumerable.First().Equals("foo,")); - } - - [TestMethod] - public void SplitShouldSplitWhenOnlySplitCharPresent() - { - var data = ","; - var argsList = data.Tokenize(SplitChar, EscapeChar); - var enumerable = argsList as string[] ?? argsList.ToArray(); - - Assert.IsTrue(enumerable.Length == 2); - } - - [TestMethod] - public void SplitShouldNotSplitWhenNoSplitCharPresent() - { - var data = "foo\\bar"; - var argsList = data.Tokenize(SplitChar, EscapeChar); - var enumerable = argsList as string[] ?? argsList.ToArray(); - - Assert.IsTrue(enumerable.Length == 1); - } - - private const char SplitChar = ','; - private const char EscapeChar = '\\'; + var data = "foo\\bar"; + var argsList = data.Tokenize(SplitChar, EscapeChar); + var enumerable = argsList as string[] ?? argsList.ToArray(); + + Assert.IsTrue(enumerable.Length == 1); } -} + + private const char SplitChar = ','; + private const char EscapeChar = '\\'; +} \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/XmlUtilitiesTests.cs b/test/Microsoft.TestPlatform.Utilities.UnitTests/XmlUtilitiesTests.cs index 76cc3772dc..79fd7529a5 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/XmlUtilitiesTests.cs +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/XmlUtilitiesTests.cs @@ -1,221 +1,215 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.Utilities.UnitTests -{ - using System; - using System.Xml; - using System.Xml.XPath; +namespace Microsoft.TestPlatform.Utilities.UnitTests; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Xml; +using System.Xml.XPath; - [TestClass] - public class XmlUtilitiesTests - { - #region GetNodeXml tests +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities; - [TestMethod] - public void GetNodeXmlShouldThrowIfxmlDocumentIsNull() - { - Assert.ThrowsException(() => XmlUtilities.GetNodeXml(null, @"/RunSettings/RunConfiguration")); - } +using VisualStudio.TestTools.UnitTesting; - [TestMethod] - public void GetNodeXmlShouldThrowIfXPathIsNull() - { - var settingsXml = @""; - var xmlDocument = this.GetXmlDocument(settingsXml); +[TestClass] +public class XmlUtilitiesTests +{ + #region GetNodeXml tests - Assert.ThrowsException(() => XmlUtilities.GetNodeXml(xmlDocument.CreateNavigator(), null)); - } + [TestMethod] + public void GetNodeXmlShouldThrowIfxmlDocumentIsNull() + { + Assert.ThrowsException(() => XmlUtilities.GetNodeXml(null, @"/RunSettings/RunConfiguration")); + } - [TestMethod] - public void GetNodeXmlShouldThrowIfXPathIsInvalid() - { - var settingsXml = @""; - var xmlDocument = this.GetXmlDocument(settingsXml); + [TestMethod] + public void GetNodeXmlShouldThrowIfXPathIsNull() + { + var settingsXml = @""; + var xmlDocument = GetXmlDocument(settingsXml); - Assert.ThrowsException(() => XmlUtilities.GetNodeXml(xmlDocument.CreateNavigator(), @"Rs\r")); - } + Assert.ThrowsException(() => XmlUtilities.GetNodeXml(xmlDocument.CreateNavigator(), null)); + } - [TestMethod] - public void GetNodeXmlShouldReturnNullIfNodeDoesNotExist() - { - var settingsXml = @""; - var xmlDocument = this.GetXmlDocument(settingsXml); + [TestMethod] + public void GetNodeXmlShouldThrowIfXPathIsInvalid() + { + var settingsXml = @""; + var xmlDocument = GetXmlDocument(settingsXml); - Assert.IsNull(XmlUtilities.GetNodeXml(xmlDocument.CreateNavigator(), @"/RunSettings/RunConfiguration")); - } + Assert.ThrowsException(() => XmlUtilities.GetNodeXml(xmlDocument.CreateNavigator(), @"Rs\r")); + } - [TestMethod] - public void GetNodeXmlShouldReturnNodeValue() - { - var settingsXml = @"abc"; - var xmlDocument = this.GetXmlDocument(settingsXml); + [TestMethod] + public void GetNodeXmlShouldReturnNullIfNodeDoesNotExist() + { + var settingsXml = @""; + var xmlDocument = GetXmlDocument(settingsXml); - Assert.AreEqual("abc", XmlUtilities.GetNodeXml(xmlDocument.CreateNavigator(), @"/RunSettings/RC")); - } + Assert.IsNull(XmlUtilities.GetNodeXml(xmlDocument.CreateNavigator(), @"/RunSettings/RunConfiguration")); + } - #endregion + [TestMethod] + public void GetNodeXmlShouldReturnNodeValue() + { + var settingsXml = @"abc"; + var xmlDocument = GetXmlDocument(settingsXml); - #region IsValidNodeXmlValue tests + Assert.AreEqual("abc", XmlUtilities.GetNodeXml(xmlDocument.CreateNavigator(), @"/RunSettings/RC")); + } - [TestMethod] - public void IsValidNodeXmlValueShouldReturnFalseOnArgumentException() - { - Func validator = (string xml) => - { - Enum.Parse(typeof(Architecture), xml); - return true; - }; + #endregion - Assert.IsFalse(XmlUtilities.IsValidNodeXmlValue("foo", validator)); - } + #region IsValidNodeXmlValue tests - [TestMethod] - public void IsValidNodeXmlValueShouldReturnFalseIfValidatorReturnsFalse() + [TestMethod] + public void IsValidNodeXmlValueShouldReturnFalseOnArgumentException() + { + Func validator = (string xml) => { - Func validator = (string xml) => - { - return false; - }; + Enum.Parse(typeof(Architecture), xml); + return true; + }; - Assert.IsFalse(XmlUtilities.IsValidNodeXmlValue("foo", validator)); - } + Assert.IsFalse(XmlUtilities.IsValidNodeXmlValue("foo", validator)); + } - [TestMethod] - public void IsValidNodeXmlValueShouldReturnTrueIfValidatorReturnsTrue() - { - Func validator = (string xml) => - { - return true; - }; + [TestMethod] + public void IsValidNodeXmlValueShouldReturnFalseIfValidatorReturnsFalse() + { + Func validator = (string xml) => false; - Assert.IsTrue(XmlUtilities.IsValidNodeXmlValue("foo", validator)); - } + Assert.IsFalse(XmlUtilities.IsValidNodeXmlValue("foo", validator)); + } - #endregion + [TestMethod] + public void IsValidNodeXmlValueShouldReturnTrueIfValidatorReturnsTrue() + { + Func validator = (string xml) => true; - #region AppendOrModifyChild tests + Assert.IsTrue(XmlUtilities.IsValidNodeXmlValue("foo", validator)); + } - [TestMethod] - public void AppendOrModifyChildShouldModifyExistingNode() - { - var settingsXml = @"abc"; - var xmlDocument = this.GetXmlDocument(settingsXml); + #endregion - XmlUtilities.AppendOrModifyChild(xmlDocument, @"/RunSettings/RC", "RC", "ab"); + #region AppendOrModifyChild tests - var rcxmlDocument = xmlDocument.SelectSingleNode(@"/RunSettings/RC"); - Assert.IsNotNull(rcxmlDocument); - Assert.AreEqual("ab", rcxmlDocument.InnerXml); - } + [TestMethod] + public void AppendOrModifyChildShouldModifyExistingNode() + { + var settingsXml = @"abc"; + var xmlDocument = GetXmlDocument(settingsXml); - [TestMethod] - public void AppendOrModifyChildShouldAppendANewNode() - { - var settingsXml = @""; - var xmlDocument = this.GetXmlDocument(settingsXml); + XmlUtilities.AppendOrModifyChild(xmlDocument, @"/RunSettings/RC", "RC", "ab"); - XmlUtilities.AppendOrModifyChild(xmlDocument, @"/RunSettings/RC", "RC", "abc"); + var rcxmlDocument = xmlDocument.SelectSingleNode(@"/RunSettings/RC"); + Assert.IsNotNull(rcxmlDocument); + Assert.AreEqual("ab", rcxmlDocument.InnerXml); + } - var rcxmlDocument = xmlDocument.SelectSingleNode(@"/RunSettings/RC"); - Assert.IsNotNull(rcxmlDocument); - Assert.AreEqual("abc", rcxmlDocument.InnerXml); - } + [TestMethod] + public void AppendOrModifyChildShouldAppendANewNode() + { + var settingsXml = @""; + var xmlDocument = GetXmlDocument(settingsXml); - [TestMethod] - public void AppendOrModifyChildShouldNotModifyExistingXmlIfInnerXmlPassedInIsNull() - { - var settingsXml = @"abc"; - var xmlDocument = this.GetXmlDocument(settingsXml); + XmlUtilities.AppendOrModifyChild(xmlDocument, @"/RunSettings/RC", "RC", "abc"); - XmlUtilities.AppendOrModifyChild(xmlDocument, @"/RunSettings/RC", "RC", null); + var rcxmlDocument = xmlDocument.SelectSingleNode(@"/RunSettings/RC"); + Assert.IsNotNull(rcxmlDocument); + Assert.AreEqual("abc", rcxmlDocument.InnerXml); + } - var rcxmlDocument = xmlDocument.SelectSingleNode(@"/RunSettings/RC"); - Assert.IsNotNull(rcxmlDocument); - Assert.AreEqual("abc", rcxmlDocument.InnerXml); - } + [TestMethod] + public void AppendOrModifyChildShouldNotModifyExistingXmlIfInnerXmlPassedInIsNull() + { + var settingsXml = @"abc"; + var xmlDocument = GetXmlDocument(settingsXml); - [TestMethod] - public void AppendOrModifyChildShouldCreateAnEmptyNewNodeIfInnerXmlPassedInIsNull() - { - var settingsXml = @""; - var xmlDocument = this.GetXmlDocument(settingsXml); + XmlUtilities.AppendOrModifyChild(xmlDocument, @"/RunSettings/RC", "RC", null); - XmlUtilities.AppendOrModifyChild(xmlDocument, @"/RunSettings/RC", "RC", null); + var rcxmlDocument = xmlDocument.SelectSingleNode(@"/RunSettings/RC"); + Assert.IsNotNull(rcxmlDocument); + Assert.AreEqual("abc", rcxmlDocument.InnerXml); + } - var rcxmlDocument = xmlDocument.SelectSingleNode(@"/RunSettings/RC"); - Assert.IsNotNull(rcxmlDocument); - Assert.AreEqual(string.Empty, rcxmlDocument.InnerXml); - } + [TestMethod] + public void AppendOrModifyChildShouldCreateAnEmptyNewNodeIfInnerXmlPassedInIsNull() + { + var settingsXml = @""; + var xmlDocument = GetXmlDocument(settingsXml); - [TestMethod] - public void AppendOrModifyChildShouldNotModifyIfParentNodeDoesNotExist() - { - var settingsXml = @""; - var xmlDocument = this.GetXmlDocument(settingsXml); + XmlUtilities.AppendOrModifyChild(xmlDocument, @"/RunSettings/RC", "RC", null); - XmlUtilities.AppendOrModifyChild(xmlDocument, @"/RunSettings/RC/RD", "RD", null); + var rcxmlDocument = xmlDocument.SelectSingleNode(@"/RunSettings/RC"); + Assert.IsNotNull(rcxmlDocument); + Assert.AreEqual(string.Empty, rcxmlDocument.InnerXml); + } - Assert.AreEqual(settingsXml, xmlDocument.OuterXml); - } + [TestMethod] + public void AppendOrModifyChildShouldNotModifyIfParentNodeDoesNotExist() + { + var settingsXml = @""; + var xmlDocument = GetXmlDocument(settingsXml); - [TestMethod] - public void AppendOrModifyChildShouldAppendANewNodeWithEscapingSpecialChars() - { - var settingsXml = @""; - var xmlDocument = this.GetXmlDocument(settingsXml); + XmlUtilities.AppendOrModifyChild(xmlDocument, @"/RunSettings/RC/RD", "RD", null); - XmlUtilities.AppendOrModifyChild(xmlDocument, @"/RunSettings/RC", "RC", "a&bd\"e'f"); + Assert.AreEqual(settingsXml, xmlDocument.OuterXml); + } - var rcxmlDocument = xmlDocument.SelectSingleNode(@"/RunSettings/RC"); - Assert.IsNotNull(rcxmlDocument); - Assert.AreEqual("a&b<c>d\"e'f", rcxmlDocument.InnerXml); - Assert.AreEqual("a&bd\"e'f", rcxmlDocument.InnerText); - } + [TestMethod] + public void AppendOrModifyChildShouldAppendANewNodeWithEscapingSpecialChars() + { + var settingsXml = @""; + var xmlDocument = GetXmlDocument(settingsXml); - #endregion + XmlUtilities.AppendOrModifyChild(xmlDocument, @"/RunSettings/RC", "RC", "a&bd\"e'f"); - #region RemoveChildNode tests + var rcxmlDocument = xmlDocument.SelectSingleNode(@"/RunSettings/RC"); + Assert.IsNotNull(rcxmlDocument); + Assert.AreEqual("a&b<c>d\"e'f", rcxmlDocument.InnerXml); + Assert.AreEqual("a&bd\"e'f", rcxmlDocument.InnerText); + } - [TestMethod] - public void RemoveChildNodeShouldNotModifyExistingXmlIfNodeDoesnotExist() - { - var settingsXml = @""; - var xmlDocument = this.GetXmlDocument(settingsXml); + #endregion - XmlUtilities.RemoveChildNode(xmlDocument.CreateNavigator(), @"/RunSettings/RC", "RC"); + #region RemoveChildNode tests - Assert.AreEqual(settingsXml, xmlDocument.OuterXml); - } + [TestMethod] + public void RemoveChildNodeShouldNotModifyExistingXmlIfNodeDoesnotExist() + { + var settingsXml = @""; + var xmlDocument = GetXmlDocument(settingsXml); - [TestMethod] - public void RemoveChildNodeShouldRemoveXmlIfExist() - { - var settingsXml = @"abc"; - var xmlDocument = this.GetXmlDocument(settingsXml); - var navigator = xmlDocument.CreateNavigator(); - navigator.MoveToChild("RunSettings", string.Empty); - XmlUtilities.RemoveChildNode(navigator, @"/RunSettings/RC", "RC"); + XmlUtilities.RemoveChildNode(xmlDocument.CreateNavigator(), @"/RunSettings/RC", "RC"); - Assert.AreEqual(@"", xmlDocument.OuterXml); - } + Assert.AreEqual(settingsXml, xmlDocument.OuterXml); + } - #endregion + [TestMethod] + public void RemoveChildNodeShouldRemoveXmlIfExist() + { + var settingsXml = @"abc"; + var xmlDocument = GetXmlDocument(settingsXml); + var navigator = xmlDocument.CreateNavigator(); + navigator.MoveToChild("RunSettings", string.Empty); + XmlUtilities.RemoveChildNode(navigator, @"/RunSettings/RC", "RC"); - #region Private Methods + Assert.AreEqual(@"", xmlDocument.OuterXml); + } - private XmlDocument GetXmlDocument(string settingsXml) - { - var doc = new XmlDocument(); - doc.LoadXml(settingsXml); + #endregion - return doc; - } + #region Private Methods - #endregion + private XmlDocument GetXmlDocument(string settingsXml) + { + var doc = new XmlDocument(); + doc.LoadXml(settingsXml); + + return doc; } -} + + #endregion +} \ No newline at end of file diff --git a/test/SettingsMigrator.UnitTests/MigratorTests.cs b/test/SettingsMigrator.UnitTests/MigratorTests.cs index 4fe25372a7..fcd6672593 100644 --- a/test/SettingsMigrator.UnitTests/MigratorTests.cs +++ b/test/SettingsMigrator.UnitTests/MigratorTests.cs @@ -1,175 +1,171 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.SettingsMigrator.UnitTests +namespace Microsoft.VisualStudio.TestPlatform.SettingsMigrator.UnitTests; + +using System.IO; +using System.Xml; + +using TestTools.UnitTesting; + +[TestClass] +public class MigratorTests { - using System.IO; - using System.Xml; - using Microsoft.VisualStudio.TestTools.UnitTesting; + private const string InvalidSettings = ""; + + private const string OldRunSettings = "" + + "" + + "true" + + "" + + "" + + ""; + + private Migrator _migrator; + private string _newRunsettingsPath; + private string _oldTestsettingsPath; + private string _oldRunsettingsPath; + + [TestInitialize] + public void TestInit() + { + _migrator = new Migrator(); + _newRunsettingsPath = Path.Combine(Path.GetTempPath(), "generatedRunsettings.runsettings"); + _oldTestsettingsPath = Path.GetFullPath(Path.Combine(".", "oldTestsettings.testsettings")); + _oldRunsettingsPath = Path.Combine(Path.GetTempPath(), "oldRunsettings.runsettings"); + } - [TestClass] - public class MigratorTests + [TestCleanup] + public void TestCleanup() { - private const string InvalidSettings = ""; - - private const string OldRunSettings = "" + - "" + - "true" + - "" + - "" + - ""; - - private Migrator migrator; - private string newRunsettingsPath; - private string oldTestsettingsPath; - private string oldRunsettingsPath; - - [TestInitialize] - public void TestInit() + if (File.Exists(_newRunsettingsPath)) { - this.migrator = new Migrator(); - this.newRunsettingsPath = Path.Combine(Path.GetTempPath(), "generatedRunsettings.runsettings"); - this.oldTestsettingsPath = Path.GetFullPath(Path.Combine(".", "oldTestsettings.testsettings")); - this.oldRunsettingsPath = Path.Combine(Path.GetTempPath(), "oldRunsettings.runsettings"); + File.Delete(_newRunsettingsPath); } + } - [TestCleanup] - public void TestCleanup() - { - if (File.Exists(this.newRunsettingsPath)) - { - File.Delete(this.newRunsettingsPath); - } - } + [TestMethod] + public void NonRootedPathIsNotMigrated() + { + _migrator.Migrate("asda", _newRunsettingsPath); - [TestMethod] - public void NonRootedPathIsNotMigrated() - { - this.migrator.Migrate("asda", this.newRunsettingsPath); + Assert.IsFalse(File.Exists(_newRunsettingsPath), "Run settings should not be generated."); + } - Assert.IsFalse(File.Exists(this.newRunsettingsPath), "Run settings should not be generated."); - } + [TestMethod] + public void MigratorGeneratesCorrectRunsettingsForEmbeddedTestSettings() + { + var doc = new XmlDocument(); + doc.LoadXml(OldRunSettings); + var settingsnode = doc.DocumentElement.SelectSingleNode(@"/RunSettings/MSTest/SettingsFile"); + settingsnode.InnerText = _oldTestsettingsPath; + File.WriteAllText(_oldRunsettingsPath, doc.InnerXml); - [TestMethod] - public void MigratorGeneratesCorrectRunsettingsForEmbeddedTestSettings() - { - var doc = new XmlDocument(); - doc.LoadXml(OldRunSettings); - var settingsnode = doc.DocumentElement.SelectSingleNode(@"/RunSettings/MSTest/SettingsFile"); - settingsnode.InnerText = this.oldTestsettingsPath; - File.WriteAllText(this.oldRunsettingsPath, doc.InnerXml); + _migrator.Migrate(_oldRunsettingsPath, _newRunsettingsPath); - this.migrator.Migrate(this.oldRunsettingsPath, this.newRunsettingsPath); + Validate(_newRunsettingsPath); - Validate(this.newRunsettingsPath); + File.Delete(_oldRunsettingsPath); + } - File.Delete(this.oldRunsettingsPath); - } + [TestMethod] + public void MigratorGeneratesCorrectRunsettingsForEmbeddedTestSettingsOfRelativePath() + { + _oldRunsettingsPath = Path.GetFullPath(Path.Combine(".", "oldRunSettingsWithEmbeddedSettings.runSEttings")); - [TestMethod] - public void MigratorGeneratesCorrectRunsettingsForEmbeddedTestSettingsOfRelativePath() - { - this.oldRunsettingsPath = Path.GetFullPath(Path.Combine(".", "oldRunSettingsWithEmbeddedSettings.runSEttings")); + _migrator.Migrate(_oldRunsettingsPath, _newRunsettingsPath); + Validate(_newRunsettingsPath); + } - this.migrator.Migrate(this.oldRunsettingsPath, this.newRunsettingsPath); - Validate(this.newRunsettingsPath); - } + [TestMethod] + public void MigratorGeneratesCorrectRunsettingsWithDc() + { + _oldRunsettingsPath = Path.GetFullPath(Path.Combine(".", "oldRunSettingsWithDataCollector.runsettings")); - [TestMethod] - public void MigratorGeneratesCorrectRunsettingsWithDC() - { - this.oldRunsettingsPath = Path.GetFullPath(Path.Combine(".", "oldRunSettingsWithDataCollector.runsettings")); - - this.migrator.Migrate(this.oldRunsettingsPath, this.newRunsettingsPath); - - using (XmlTextReader reader = new XmlTextReader(this.newRunsettingsPath)) - { - reader.Namespaces = false; - var document = new XmlDocument(); - document.Load(reader); - var root = document.DocumentElement; - var dataCollectorNode = root.SelectNodes(@"/RunSettings/DataCollectionRunSettings/DataCollectors/DataCollector"); - Assert.AreEqual(2, dataCollectorNode.Count, "Data collector is missing"); - } - } + _migrator.Migrate(_oldRunsettingsPath, _newRunsettingsPath); - [TestMethod] - public void MigratorGeneratesCorrectRunsettingsForTestSettings() - { - this.migrator.Migrate(this.oldTestsettingsPath, this.newRunsettingsPath); + using XmlTextReader reader = new(_newRunsettingsPath); + reader.Namespaces = false; + var document = new XmlDocument(); + document.Load(reader); + var root = document.DocumentElement; + var dataCollectorNode = root.SelectNodes(@"/RunSettings/DataCollectionRunSettings/DataCollectors/DataCollector"); + Assert.AreEqual(2, dataCollectorNode.Count, "Data collector is missing"); + } - Validate(this.newRunsettingsPath); - } + [TestMethod] + public void MigratorGeneratesCorrectRunsettingsForTestSettings() + { + _migrator.Migrate(_oldTestsettingsPath, _newRunsettingsPath); - [TestMethod] - [ExpectedException(typeof(XmlException))] - public void InvalidSettingsThrowsException() - { - this.oldTestsettingsPath = Path.Combine(Path.GetTempPath(), "oldTestsettings.testsettings"); + Validate(_newRunsettingsPath); + } + + [TestMethod] + [ExpectedException(typeof(XmlException))] + public void InvalidSettingsThrowsException() + { + _oldTestsettingsPath = Path.Combine(Path.GetTempPath(), "oldTestsettings.testsettings"); - File.WriteAllText(this.oldTestsettingsPath, InvalidSettings); - File.WriteAllText(this.newRunsettingsPath, string.Empty); + File.WriteAllText(_oldTestsettingsPath, InvalidSettings); + File.WriteAllText(_newRunsettingsPath, string.Empty); - this.migrator.Migrate(this.oldTestsettingsPath, this.newRunsettingsPath); + _migrator.Migrate(_oldTestsettingsPath, _newRunsettingsPath); - File.Delete(this.oldTestsettingsPath); - } + File.Delete(_oldTestsettingsPath); + } - [TestMethod] - [ExpectedException(typeof(DirectoryNotFoundException))] - public void InvalidPathThrowsException() - { - string oldTestsettingsPath = @"X:\generatedRun,settings.runsettings"; + [TestMethod] + [ExpectedException(typeof(DirectoryNotFoundException))] + public void InvalidPathThrowsException() + { + string oldTestsettingsPath = @"X:\generatedRun,settings.runsettings"; - this.migrator.Migrate(oldTestsettingsPath, this.newRunsettingsPath); - } + _migrator.Migrate(oldTestsettingsPath, _newRunsettingsPath); + } - private static void Validate(string newRunsettingsPath) - { - Assert.IsTrue(File.Exists(newRunsettingsPath), "Run settings should be generated."); + private static void Validate(string newRunsettingsPath) + { + Assert.IsTrue(File.Exists(newRunsettingsPath), "Run settings should be generated."); - using (XmlTextReader reader = new XmlTextReader(newRunsettingsPath)) - { - reader.Namespaces = false; + using XmlTextReader reader = new(newRunsettingsPath); + reader.Namespaces = false; - var document = new XmlDocument(); - document.Load(reader); - var root = document.DocumentElement; + var document = new XmlDocument(); + document.Load(reader); + var root = document.DocumentElement; - Assert.IsNotNull(root.SelectSingleNode(@"/RunSettings/WebTestRunConfiguration/Browser/Headers/Header"), "There should be a WebTestRunConfiguration node"); - Assert.IsNotNull(root.SelectSingleNode(@"/RunSettings/LegacySettings"), "There should be a LegacySettings node"); - Assert.IsNotNull(root.SelectSingleNode(@"/RunSettings/LegacySettings/Deployment/DeploymentItem"), "There should be a DeploymentItem node"); + Assert.IsNotNull(root.SelectSingleNode(@"/RunSettings/WebTestRunConfiguration/Browser/Headers/Header"), "There should be a WebTestRunConfiguration node"); + Assert.IsNotNull(root.SelectSingleNode(@"/RunSettings/LegacySettings"), "There should be a LegacySettings node"); + Assert.IsNotNull(root.SelectSingleNode(@"/RunSettings/LegacySettings/Deployment/DeploymentItem"), "There should be a DeploymentItem node"); - var scriptNode = root.SelectSingleNode(@"/RunSettings/LegacySettings/Scripts"); - Assert.IsNotNull(scriptNode, "There should be a WebTestRunConfiguration node"); - Assert.AreEqual(".\\setup.bat", scriptNode.Attributes["setupScript"].Value, "setupScript does not match."); - Assert.AreEqual(".\\cleanup.bat", scriptNode.Attributes["cleanupScript"].Value, "cleanupScript does not match."); + var scriptNode = root.SelectSingleNode(@"/RunSettings/LegacySettings/Scripts"); + Assert.IsNotNull(scriptNode, "There should be a WebTestRunConfiguration node"); + Assert.AreEqual(".\\setup.bat", scriptNode.Attributes["setupScript"].Value, "setupScript does not match."); + Assert.AreEqual(".\\cleanup.bat", scriptNode.Attributes["cleanupScript"].Value, "cleanupScript does not match."); - var forcedLegacyNode = root.SelectSingleNode(@"/RunSettings/MSTest/ForcedLegacyMode"); - Assert.IsNotNull(forcedLegacyNode, "ForcedLegacy node should be present"); - Assert.AreEqual("true", forcedLegacyNode.InnerText, "Forced legacy should be true"); + var forcedLegacyNode = root.SelectSingleNode(@"/RunSettings/MSTest/ForcedLegacyMode"); + Assert.IsNotNull(forcedLegacyNode, "ForcedLegacy node should be present"); + Assert.AreEqual("true", forcedLegacyNode.InnerText, "Forced legacy should be true"); - var executionNode = root.SelectSingleNode(@" / RunSettings/LegacySettings/Execution"); - Assert.IsNotNull(executionNode, "There should be a Execution node"); - Assert.AreEqual("2", executionNode.Attributes["parallelTestCount"].Value, "parallelTestCount value does not match."); - Assert.AreEqual("MSIL", executionNode.Attributes["hostProcessPlatform"].Value, "hostProcessPlatform value does not match."); + var executionNode = root.SelectSingleNode(@" / RunSettings/LegacySettings/Execution"); + Assert.IsNotNull(executionNode, "There should be a Execution node"); + Assert.AreEqual("2", executionNode.Attributes["parallelTestCount"].Value, "parallelTestCount value does not match."); + Assert.AreEqual("MSIL", executionNode.Attributes["hostProcessPlatform"].Value, "hostProcessPlatform value does not match."); - Assert.IsNotNull(root.SelectSingleNode(@"/RunSettings/LegacySettings/Execution/Hosts"), "There should be a Hosts node"); + Assert.IsNotNull(root.SelectSingleNode(@"/RunSettings/LegacySettings/Execution/Hosts"), "There should be a Hosts node"); - var timeoutNode = root.SelectSingleNode(@"/RunSettings/LegacySettings/Execution/Timeouts"); - Assert.IsNotNull(timeoutNode, "There should be a Timeouts node"); - Assert.AreEqual("120000", timeoutNode.Attributes["testTimeout"].Value, "testTimeout value does not match."); + var timeoutNode = root.SelectSingleNode(@"/RunSettings/LegacySettings/Execution/Timeouts"); + Assert.IsNotNull(timeoutNode, "There should be a Timeouts node"); + Assert.AreEqual("120000", timeoutNode.Attributes["testTimeout"].Value, "testTimeout value does not match."); - Assert.IsNotNull(root.SelectSingleNode(@"/RunSettings/LegacySettings/Execution/TestTypeSpecific/UnitTestRunConfig/AssemblyResolution/TestDirectory"), "There should be a Assembly resolution node"); + Assert.IsNotNull(root.SelectSingleNode(@"/RunSettings/LegacySettings/Execution/TestTypeSpecific/UnitTestRunConfig/AssemblyResolution/TestDirectory"), "There should be a Assembly resolution node"); - var testSessionTimeoutNode = root.SelectSingleNode(@"/RunSettings/RunConfiguration/TestSessionTimeout"); - Assert.IsNotNull(testSessionTimeoutNode, "There should be a TestSessionTimeout node"); - Assert.AreEqual("60000", testSessionTimeoutNode.InnerText, "Timeout value does not match."); + var testSessionTimeoutNode = root.SelectSingleNode(@"/RunSettings/RunConfiguration/TestSessionTimeout"); + Assert.IsNotNull(testSessionTimeoutNode, "There should be a TestSessionTimeout node"); + Assert.AreEqual("60000", testSessionTimeoutNode.InnerText, "Timeout value does not match."); - var dataCollectorNode = root.SelectSingleNode(@"/RunSettings/DataCollectionRunSettings/DataCollectors/DataCollector"); - Assert.IsNotNull(dataCollectorNode, "There should be a DataCollector node"); - Assert.AreEqual("Event Log", dataCollectorNode.Attributes["friendlyName"].Value, "Data collector does not match."); - } - } + var dataCollectorNode = root.SelectSingleNode(@"/RunSettings/DataCollectionRunSettings/DataCollectors/DataCollector"); + Assert.IsNotNull(dataCollectorNode, "There should be a DataCollector node"); + Assert.AreEqual("Event Log", dataCollectorNode.Attributes["friendlyName"].Value, "Data collector does not match."); } -} +} \ No newline at end of file diff --git a/test/SettingsMigrator.UnitTests/PathResolverTests.cs b/test/SettingsMigrator.UnitTests/PathResolverTests.cs index 9acd635236..b8b857d00d 100644 --- a/test/SettingsMigrator.UnitTests/PathResolverTests.cs +++ b/test/SettingsMigrator.UnitTests/PathResolverTests.cs @@ -1,75 +1,75 @@ -// Copyright(c) Microsoft Corporation.All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.SettingsMigrator.UnitTests +namespace Microsoft.VisualStudio.TestPlatform.SettingsMigrator.UnitTests; + +using System; +using System.Globalization; +using System.IO; + +using TestTools.UnitTesting; + +[TestClass] +public class PathResolverTests { - using System; - using System.Globalization; - using System.IO; - using Microsoft.VisualStudio.TestTools.UnitTesting; + private PathResolver _pathResolver; - [TestClass] - public class PathResolverTests + [TestInitialize] + public void TestInit() { - private PathResolver pathResolver; - - [TestInitialize] - public void TestInit() - { - this.pathResolver = new PathResolver(); - } + _pathResolver = new PathResolver(); + } - [TestMethod] - public void PathResolverShouldReturnNullForEmptyArguments() - { - var newFilePath = this.pathResolver.GetTargetPath(new string[] { }); - Assert.IsNull(newFilePath, "Empty arguments should return null"); - } + [TestMethod] + public void PathResolverShouldReturnNullForEmptyArguments() + { + var newFilePath = _pathResolver.GetTargetPath(new string[] { }); + Assert.IsNull(newFilePath, "Empty arguments should return null"); + } - [TestMethod] - public void PathResolverShouldReturnNullForInvalidArguments() - { - var newFilePath = this.pathResolver.GetTargetPath(new string[] { "asd", "asd", "asd" }); - Assert.IsNull(newFilePath, "Invalid arguments should return null"); - } + [TestMethod] + public void PathResolverShouldReturnNullForInvalidArguments() + { + var newFilePath = _pathResolver.GetTargetPath(new string[] { "asd", "asd", "asd" }); + Assert.IsNull(newFilePath, "Invalid arguments should return null"); + } - [TestMethod] - public void PathResolverShouldReturnNullForRelativePaths() - { - var newFilePath = this.pathResolver.GetTargetPath(new string[] { "asd.testsettings" }); - Assert.IsNull(newFilePath, "Relative paths should return null"); - } + [TestMethod] + public void PathResolverShouldReturnNullForRelativePaths() + { + var newFilePath = _pathResolver.GetTargetPath(new string[] { "asd.testsettings" }); + Assert.IsNull(newFilePath, "Relative paths should return null"); + } - [TestMethod] - public void PathResolverShouldReturnNullForRelativePathsWithTwoArguments() - { - var newFilePath = this.pathResolver.GetTargetPath(new string[] { "asd.Testsettings", "C:\\asd.runsettings" }); - Assert.IsNull(newFilePath, "Relative paths should return null"); - } + [TestMethod] + public void PathResolverShouldReturnNullForRelativePathsWithTwoArguments() + { + var newFilePath = _pathResolver.GetTargetPath(new string[] { "asd.Testsettings", "C:\\asd.runsettings" }); + Assert.IsNull(newFilePath, "Relative paths should return null"); + } - [TestMethod] - public void PathResolverShouldNotReturnNullForPathsWithExtensionInCapitals() - { - var newFilePath = this.pathResolver.GetTargetPath(new string[] { "C:\\asd.TestSEettings", "C:\\asd.RuNSettings" }); - Assert.IsNotNull(newFilePath, "Relative paths should not return null"); - } + [TestMethod] + public void PathResolverShouldNotReturnNullForPathsWithExtensionInCapitals() + { + var newFilePath = _pathResolver.GetTargetPath(new string[] { "C:\\asd.TestSEettings", "C:\\asd.RuNSettings" }); + Assert.IsNotNull(newFilePath, "Relative paths should not return null"); + } - [TestMethod] - public void PathResolverShouldReturnNullForRelativePathsForRunsettings() - { - var newFilePath = this.pathResolver.GetTargetPath(new string[] { "C:\\asd.testsettings", "asd.runsettings" }); - Assert.IsNull(newFilePath, "Relative paths should return null"); - } + [TestMethod] + public void PathResolverShouldReturnNullForRelativePathsForRunsettings() + { + var newFilePath = _pathResolver.GetTargetPath(new string[] { "C:\\asd.testsettings", "asd.runsettings" }); + Assert.IsNull(newFilePath, "Relative paths should return null"); + } - [TestMethod] - public void PathResolverShouldReturnRunsettingsPathOfSameLocationAsTestSettings() - { - var newFilePath = this.pathResolver.GetTargetPath(new string[] { "C:\\asd.testsettings" }); - Assert.IsNotNull(newFilePath, "File path should not be null."); - Assert.IsTrue(string.Equals(Path.GetExtension(newFilePath), ".runsettings"), "File path should be .runsettings"); - Assert.IsTrue(newFilePath.Contains("C:\\asd_"), "File should be of same name as testsettings"); - var time = newFilePath.Substring(7, 19); - Assert.IsTrue(DateTime.TryParseExact(time, "MM-dd-yyyy_hh-mm-ss", CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTime date), "File name should have datetime"); - } + [TestMethod] + public void PathResolverShouldReturnRunsettingsPathOfSameLocationAsTestSettings() + { + var newFilePath = _pathResolver.GetTargetPath(new string[] { "C:\\asd.testsettings" }); + Assert.IsNotNull(newFilePath, "File path should not be null."); + Assert.IsTrue(string.Equals(Path.GetExtension(newFilePath), ".runsettings"), "File path should be .runsettings"); + Assert.IsTrue(newFilePath.Contains("C:\\asd_"), "File should be of same name as testsettings"); + var time = newFilePath.Substring(7, 19); + Assert.IsTrue(DateTime.TryParseExact(time, "MM-dd-yyyy_hh-mm-ss", CultureInfo.CurrentCulture, DateTimeStyles.None, out _), "File name should have datetime"); } } \ No newline at end of file diff --git a/test/SettingsMigrator.UnitTests/ProgramTests.cs b/test/SettingsMigrator.UnitTests/ProgramTests.cs index 6ce0729e71..0fca0c966c 100644 --- a/test/SettingsMigrator.UnitTests/ProgramTests.cs +++ b/test/SettingsMigrator.UnitTests/ProgramTests.cs @@ -1,25 +1,24 @@ -// Copyright(c) Microsoft Corporation.All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.SettingsMigrator.UnitTests -{ - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace Microsoft.VisualStudio.TestPlatform.SettingsMigrator.UnitTests; + +using TestTools.UnitTesting; - [TestClass] - public class ProgramTests +[TestClass] +public class ProgramTests +{ + [TestMethod] + public void MoreThanTwoArgumentsShouldNotBeAccepted() { - [TestMethod] - public void MoreThanTwoArgumentsShouldNotBeAccepted() - { - int returnCode = Program.Main(new string[] { "asd", "asd", "asd" }); - Assert.AreEqual(1, returnCode, "More than 2 arguments should not be accepted."); - } + int returnCode = Program.Main(new string[] { "asd", "asd", "asd" }); + Assert.AreEqual(1, returnCode, "More than 2 arguments should not be accepted."); + } - [TestMethod] - public void NoArgumentsShouldNotBeAccepted() - { - int returnCode = Program.Main(new string[] { }); - Assert.AreEqual(1, returnCode, "No arguments should not be accepted."); - } + [TestMethod] + public void NoArgumentsShouldNotBeAccepted() + { + int returnCode = Program.Main(new string[] { }); + Assert.AreEqual(1, returnCode, "No arguments should not be accepted."); } } \ No newline at end of file diff --git a/test/TestAssets/AppDomainGetAssembliesTestProject/UnitTest1.cs b/test/TestAssets/AppDomainGetAssembliesTestProject/UnitTest1.cs index 0cfa179995..adb207276d 100644 --- a/test/TestAssets/AppDomainGetAssembliesTestProject/UnitTest1.cs +++ b/test/TestAssets/AppDomainGetAssembliesTestProject/UnitTest1.cs @@ -1,6 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + using Microsoft.VisualStudio.TestTools.UnitTesting; + using System; -using System.Linq; namespace AppDomainGetAssembliesTestProject { @@ -15,7 +18,7 @@ public void TestMethod1() var allAssemblies = AppDomain.CurrentDomain.GetAssemblies(); - foreach(var assembly in allAssemblies) + foreach (var assembly in allAssemblies) { var typeInfo = assembly.GetTypes(); } diff --git a/test/TestAssets/ArchitectureSwitch/UnitTest1.cs b/test/TestAssets/ArchitectureSwitch/UnitTest1.cs index 80aaa5fa73..e298ffc99d 100644 --- a/test/TestAssets/ArchitectureSwitch/UnitTest1.cs +++ b/test/TestAssets/ArchitectureSwitch/UnitTest1.cs @@ -4,9 +4,12 @@ using System; using System.Collections; using System.Runtime.InteropServices; + using Microsoft.VisualStudio.TestTools.UnitTesting; +#pragma warning disable IDE0161 // Convert to file-scoped namespace namespace TestProjectNetcore +#pragma warning restore IDE0161 // Convert to file-scoped namespace { [TestClass] public class UnitTest1 @@ -14,18 +17,18 @@ public class UnitTest1 [TestMethod] public void TestMethod1() { - foreach(DictionaryEntry envVar in Environment.GetEnvironmentVariables()) - { - if(envVar.Key.ToString().StartsWith("DOTNET_ROOT")) - { - Console.WriteLine($"{envVar.Key}: {envVar.Value.ToString()}"); - } - } + foreach (DictionaryEntry envVar in Environment.GetEnvironmentVariables()) + { + if (envVar.Key.ToString().StartsWith("DOTNET_ROOT")) + { + Console.WriteLine($"{envVar.Key}: {envVar.Value}"); + } + } - Console.WriteLine("OSArchitecture: " + RuntimeInformation.OSArchitecture.ToString()); - Console.WriteLine("ProcessArchitecture: " + RuntimeInformation.ProcessArchitecture.ToString()); - Console.WriteLine("Runtime location: " + typeof(object).Assembly.Location); - Assert.IsTrue(false); + Console.WriteLine("OSArchitecture: " + RuntimeInformation.OSArchitecture.ToString()); + Console.WriteLine("ProcessArchitecture: " + RuntimeInformation.ProcessArchitecture.ToString()); + Console.WriteLine("Runtime location: " + typeof(object).Assembly.Location); + Assert.IsTrue(false); } } -} +} \ No newline at end of file diff --git a/test/TestAssets/AttachmentProcessorDataCollector/SampleDataCollector.cs b/test/TestAssets/AttachmentProcessorDataCollector/SampleDataCollector.cs index e3d61d6eec..e0b0fbfe93 100644 --- a/test/TestAssets/AttachmentProcessorDataCollector/SampleDataCollector.cs +++ b/test/TestAssets/AttachmentProcessorDataCollector/SampleDataCollector.cs @@ -12,6 +12,7 @@ namespace AttachmentProcessorDataCollector using System.Threading; using System.Threading.Tasks; using System.Xml; + using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; @@ -31,9 +32,9 @@ public class SampleDataCollectorV2 : SampleDataCollectorV1 { } [DataCollectorTypeUri(ExtensionInfo.ExtensionIdentifier)] public class SampleDataCollectorV1 : DataCollector { - private DataCollectionSink dataCollectionSink; - private DataCollectionEnvironmentContext context; - private string tempDirectoryPath = Path.GetTempPath(); + private DataCollectionSink _dataCollectionSink; + private DataCollectionEnvironmentContext _context; + private readonly string _tempDirectoryPath = Path.GetTempPath(); public override void Initialize( XmlElement configurationElement, @@ -42,17 +43,17 @@ public override void Initialize( DataCollectionLogger logger, DataCollectionEnvironmentContext environmentContext) { - events.SessionEnd += this.SessionEnded_Handler; - this.dataCollectionSink = dataSink; - this.context = environmentContext; + events.SessionEnd += SessionEnded_Handler; + _dataCollectionSink = dataSink; + _context = environmentContext; } private void SessionEnded_Handler(object sender, SessionEndEventArgs e) { - string tmpAttachment = Path.Combine(tempDirectoryPath, Guid.NewGuid().ToString("N"), "DataCollectorAttachmentProcessor_1.txt"); + string tmpAttachment = Path.Combine(_tempDirectoryPath, Guid.NewGuid().ToString("N"), "DataCollectorAttachmentProcessor_1.txt"); Directory.CreateDirectory(Path.GetDirectoryName(tmpAttachment)); - File.WriteAllText(tmpAttachment, $"SessionEnded_Handler_{Guid.NewGuid().ToString("N")}"); - this.dataCollectionSink.SendFileAsync(this.context.SessionDataCollectionContext, tmpAttachment, true); + File.WriteAllText(tmpAttachment, $"SessionEnded_Handler_{Guid.NewGuid():N}"); + _dataCollectionSink.SendFileAsync(_context.SessionDataCollectionContext, tmpAttachment, true); } } diff --git a/test/TestAssets/AttachmentProcessorDataCollector/TestExtensionTypesAttribute.cs b/test/TestAssets/AttachmentProcessorDataCollector/TestExtensionTypesAttribute.cs index b38196a844..7741062800 100644 --- a/test/TestAssets/AttachmentProcessorDataCollector/TestExtensionTypesAttribute.cs +++ b/test/TestAssets/AttachmentProcessorDataCollector/TestExtensionTypesAttribute.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using AttachmentProcessorDataCollector; + using Microsoft.VisualStudio.TestPlatform; [assembly: TestExtensionTypes(typeof(SampleDataCollectorV1))] @@ -17,7 +18,7 @@ internal sealed class TestExtensionTypesAttribute : Attribute { public TestExtensionTypesAttribute(params Type[] types) { - this.Types = types; + Types = types; } public Type[] Types { get; } diff --git a/test/TestAssets/BlameUnitTestProject/UnitTest1.cs b/test/TestAssets/BlameUnitTestProject/UnitTest1.cs index 9e8f7c5f33..54f64f668f 100644 --- a/test/TestAssets/BlameUnitTestProject/UnitTest1.cs +++ b/test/TestAssets/BlameUnitTestProject/UnitTest1.cs @@ -1,23 +1,23 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace BlameUnitTestProject -{ - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System; +namespace BlameUnitTestProject; + +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using System; - [TestClass] - public class UnitTest1 +[TestClass] +public class UnitTest1 +{ + [TestMethod] + public void TestMethod1() { - [TestMethod] - public void TestMethod1() - { - } + } - [TestMethod] - public void TestMethod2() - { - Environment.FailFast("Crash the process on purpose."); - } + [TestMethod] + public void TestMethod2() + { + Environment.FailFast("Crash the process on purpose."); } } diff --git a/test/TestAssets/CUITTestProject/CodedUITest1.cs b/test/TestAssets/CUITTestProject/CodedUITest1.cs index ffefca4985..931e16b9a4 100644 --- a/test/TestAssets/CUITTestProject/CodedUITest1.cs +++ b/test/TestAssets/CUITTestProject/CodedUITest1.cs @@ -3,14 +3,8 @@ namespace CodedUITestProject { - using System; - using System.Collections.Generic; - using System.Text.RegularExpressions; - using System.Windows.Input; - using System.Drawing; - using Microsoft.VisualStudio.TestTools.UITesting; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Microsoft.VisualStudio.TestTools.UITest.Extension; + using Microsoft.VisualStudio.TestTools.UITesting; + using Microsoft.VisualStudio.TestTools.UnitTesting; [CodedUITest] public class CodedUITestProject diff --git a/test/TestAssets/CodeCoverageTest/Logic.cs b/test/TestAssets/CodeCoverageTest/Logic.cs index a6481b04af..cb2f7532a2 100644 --- a/test/TestAssets/CodeCoverageTest/Logic.cs +++ b/test/TestAssets/CodeCoverageTest/Logic.cs @@ -1,8 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. namespace CodeCoverageTest { diff --git a/test/TestAssets/CodeCoverageTest/UnitTest1.cs b/test/TestAssets/CodeCoverageTest/UnitTest1.cs index 071d4dfe93..6213c4c3ec 100644 --- a/test/TestAssets/CodeCoverageTest/UnitTest1.cs +++ b/test/TestAssets/CodeCoverageTest/UnitTest1.cs @@ -1,4 +1,6 @@ -using System; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + using Microsoft.VisualStudio.TestTools.UnitTesting; namespace CodeCoverageTest @@ -6,33 +8,35 @@ namespace CodeCoverageTest [TestClass] public class UnitTest1 { - private Logic logic; + private readonly Logic _logic; public UnitTest1() { - this.logic = new Logic(); + _logic = new Logic(); } [TestMethod] public void TestAbs() { - Assert.AreEqual(logic.Abs(0), 0); - Assert.AreEqual(logic.Abs(-5), 5); - Assert.AreEqual(logic.Abs(7), 7); + Assert.AreEqual(_logic.Abs(0), 0); + Assert.AreEqual(_logic.Abs(-5), 5); + Assert.AreEqual(_logic.Abs(7), 7); } [TestMethod] public void TestSign() { - Assert.AreEqual(logic.Sign(0), 0); - Assert.AreEqual(logic.Sign(-5), -1); - Assert.AreEqual(logic.Sign(7), 1); + Assert.AreEqual(_logic.Sign(0), 0); + Assert.AreEqual(_logic.Sign(-5), -1); + Assert.AreEqual(_logic.Sign(7), 1); } [TestMethod] +#pragma warning disable IDE1006 // Naming Styles public void __CxxPureMSILEntry_Test() +#pragma warning restore IDE1006 // Naming Styles { - Assert.AreEqual(logic.Abs(0), 0); + Assert.AreEqual(_logic.Abs(0), 0); } } } diff --git a/test/TestAssets/ConsoleManagedApp/Program.cs b/test/TestAssets/ConsoleManagedApp/Program.cs index 247024f0a0..1c0542b084 100644 --- a/test/TestAssets/ConsoleManagedApp/Program.cs +++ b/test/TestAssets/ConsoleManagedApp/Program.cs @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + using System; namespace ConsoleManagedApp diff --git a/test/TestAssets/CoverletCoverageTestProject/UnitTest1.cs b/test/TestAssets/CoverletCoverageTestProject/UnitTest1.cs index 7183e4941d..4f0f2868f9 100644 --- a/test/TestAssets/CoverletCoverageTestProject/UnitTest1.cs +++ b/test/TestAssets/CoverletCoverageTestProject/UnitTest1.cs @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + using Xunit; namespace CoverletCoverageTestProject diff --git a/test/TestAssets/CrashingOnDebugAssertTestProject/DebugTests.cs b/test/TestAssets/CrashingOnDebugAssertTestProject/DebugTests.cs index 52d252f1aa..f512bf7a13 100644 --- a/test/TestAssets/CrashingOnDebugAssertTestProject/DebugTests.cs +++ b/test/TestAssets/CrashingOnDebugAssertTestProject/DebugTests.cs @@ -1,5 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + using System.Diagnostics; -using Microsoft.VisualStudio.TestPlatform.ObjectModel; + using Microsoft.VisualStudio.TestTools.UnitTesting; namespace CrashingOnDebugAssertTestProject diff --git a/test/TestAssets/DisableAppdomainTest1/UnitTest1.cs b/test/TestAssets/DisableAppdomainTest1/UnitTest1.cs index 09a13aa6cb..75515dd09f 100644 --- a/test/TestAssets/DisableAppdomainTest1/UnitTest1.cs +++ b/test/TestAssets/DisableAppdomainTest1/UnitTest1.cs @@ -1,30 +1,31 @@ -using System; -using System.Diagnostics; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace UnitTestProject1; + +using System; using System.IO; -using System.Threading; + using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTestProject1 +[TestClass] +public class UnitTest1 { - [TestClass] - public class UnitTest1 + [TestMethod] + public void TestMethod1() { - [TestMethod] - public void TestMethod1() - { - // make sure the last test was run in different process. - var envvariable = Environment.GetEnvironmentVariable("{60BBC8A3-3AEB-40C4-AAD5-F6DA6305C6C7}"); - Assert.IsTrue(string.IsNullOrEmpty(envvariable)); + // make sure the last test was run in different process. + var envvariable = Environment.GetEnvironmentVariable("{60BBC8A3-3AEB-40C4-AAD5-F6DA6305C6C7}"); + Assert.IsTrue(string.IsNullOrEmpty(envvariable)); - // make sure the appdomain is the one created by testhost - var config = File.ReadAllText(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); - Assert.AreEqual("TestHostAppDomain", AppDomain.CurrentDomain.FriendlyName); + // make sure the appdomain is the one created by testhost + var config = File.ReadAllText(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); + Assert.AreEqual("TestHostAppDomain", AppDomain.CurrentDomain.FriendlyName); - // make sure config file is honoured - Assert.IsTrue(config.Contains("Assembly1")); + // make sure config file is honoured + Assert.IsTrue(config.Contains("Assembly1")); - // set env variable so that next test can assert if this is not carried forward - Environment.SetEnvironmentVariable("{60BBC8A3-3AEB-40C4-AAD5-F6DA6305C6C7}", "{60BBC8A3-3AEB-40C4-AAD5-F6DA6305C6C7}"); - } + // set env variable so that next test can assert if this is not carried forward + Environment.SetEnvironmentVariable("{60BBC8A3-3AEB-40C4-AAD5-F6DA6305C6C7}", "{60BBC8A3-3AEB-40C4-AAD5-F6DA6305C6C7}"); } } diff --git a/test/TestAssets/DisableAppdomainTest2/UnitTest1.cs b/test/TestAssets/DisableAppdomainTest2/UnitTest1.cs index 90cbc8550c..29ada4dd68 100644 --- a/test/TestAssets/DisableAppdomainTest2/UnitTest1.cs +++ b/test/TestAssets/DisableAppdomainTest2/UnitTest1.cs @@ -1,30 +1,31 @@ -using System; -using System.Diagnostics; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace UnitTestProject17; + +using System; using System.IO; -using System.Threading; + using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTestProject17 +[TestClass] +public class UnitTest1 { - [TestClass] - public class UnitTest1 + [TestMethod] + public void TestMethod1() { - [TestMethod] - public void TestMethod1() - { - // make sure the last test was run in different process. - var envvariable = Environment.GetEnvironmentVariable("{60BBC8A3-3AEB-40C4-AAD5-F6DA6305C6C7}"); - Assert.IsTrue(string.IsNullOrEmpty(envvariable)); + // make sure the last test was run in different process. + var envvariable = Environment.GetEnvironmentVariable("{60BBC8A3-3AEB-40C4-AAD5-F6DA6305C6C7}"); + Assert.IsTrue(string.IsNullOrEmpty(envvariable)); - // make sure the appdomain is the one created by testhost - var config = File.ReadAllText(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); - Assert.AreEqual("TestHostAppDomain", AppDomain.CurrentDomain.FriendlyName); + // make sure the appdomain is the one created by testhost + var config = File.ReadAllText(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); + Assert.AreEqual("TestHostAppDomain", AppDomain.CurrentDomain.FriendlyName); - // make sure config file is honoured - Assert.IsTrue(config.Contains("Assembly2")); + // make sure config file is honoured + Assert.IsTrue(config.Contains("Assembly2")); - // set env variable so that next test can assert if this is not carried forward - Environment.SetEnvironmentVariable("{60BBC8A3-3AEB-40C4-AAD5-F6DA6305C6C7}", "{60BBC8A3-3AEB-40C4-AAD5-F6DA6305C6C7}"); - } + // set env variable so that next test can assert if this is not carried forward + Environment.SetEnvironmentVariable("{60BBC8A3-3AEB-40C4-AAD5-F6DA6305C6C7}", "{60BBC8A3-3AEB-40C4-AAD5-F6DA6305C6C7}"); } } diff --git a/test/TestAssets/DiscoveryTestProject/LongDiscoveryTestClass.cs b/test/TestAssets/DiscoveryTestProject/LongDiscoveryTestClass.cs index 2d5c65feeb..26549f1961 100644 --- a/test/TestAssets/DiscoveryTestProject/LongDiscoveryTestClass.cs +++ b/test/TestAssets/DiscoveryTestProject/LongDiscoveryTestClass.cs @@ -1,7 +1,8 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Collections.Generic; -using System.Text; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.VisualStudio.TestTools.UnitTesting; + using System.Threading; namespace DiscoveryTestProject3 diff --git a/test/TestAssets/EnvironmentVariablesTestProject/UnitTest1.cs b/test/TestAssets/EnvironmentVariablesTestProject/UnitTest1.cs index bb6b2fcadc..783a51e865 100644 --- a/test/TestAssets/EnvironmentVariablesTestProject/UnitTest1.cs +++ b/test/TestAssets/EnvironmentVariablesTestProject/UnitTest1.cs @@ -1,4 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + using Microsoft.VisualStudio.TestTools.UnitTesting; + using System; namespace EnvironmentVariablesTestProject diff --git a/test/TestAssets/EventLogUnitTestProject/UnitTest1.cs b/test/TestAssets/EventLogUnitTestProject/UnitTest1.cs index cd54859fc5..c3c438e38e 100644 --- a/test/TestAssets/EventLogUnitTestProject/UnitTest1.cs +++ b/test/TestAssets/EventLogUnitTestProject/UnitTest1.cs @@ -1,40 +1,38 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace EventLogUnitTestProject -{ - using System.Diagnostics; - using System.Threading; +namespace EventLogUnitTestProject; + +using System.Diagnostics; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestClass] - public class UnitTest1 +[TestClass] +public class UnitTest1 +{ + [TestMethod] + public void TestMethod1() { - [TestMethod] - public void TestMethod1() - { - EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 110); - EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 111); - EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 112); - } + EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 110); + EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 111); + EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 112); + } - [TestMethod] - public void TestMethod2() - { - EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 220); - EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 221); - EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 222); - EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 223); - } + [TestMethod] + public void TestMethod2() + { + EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 220); + EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 221); + EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 222); + EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 223); + } - [TestMethod] - public void TestMethod3() - { - EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 330); - EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 331); - EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 332); - } + [TestMethod] + public void TestMethod3() + { + EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 330); + EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 331); + EventLog.WriteEntry("Application", "Application", EventLogEntryType.Error, 332); } } diff --git a/test/TestAssets/LegacySettingsUnitTestProject/UnitTest1.cs b/test/TestAssets/LegacySettingsUnitTestProject/UnitTest1.cs index ad08ec679c..f6ab967704 100644 --- a/test/TestAssets/LegacySettingsUnitTestProject/UnitTest1.cs +++ b/test/TestAssets/LegacySettingsUnitTestProject/UnitTest1.cs @@ -10,7 +10,7 @@ namespace LegacySettingsUnitTestProject [TestClass] public class UnitTest1 - { + { /// /// Test for scripts /// diff --git a/test/TestAssets/MstestV1UnitTestProject/UnitTest1.cs b/test/TestAssets/MstestV1UnitTestProject/UnitTest1.cs index 877ea916b3..fc9fcf3511 100644 --- a/test/TestAssets/MstestV1UnitTestProject/UnitTest1.cs +++ b/test/TestAssets/MstestV1UnitTestProject/UnitTest1.cs @@ -3,11 +3,6 @@ namespace MstestV1UnitTestProject { - using System; - using System.Diagnostics; - using System.Threading; - using System.IO; - using System.Reflection; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/test/TestAssets/MultitargetedNetFrameworkProject/UnitTest1.cs b/test/TestAssets/MultitargetedNetFrameworkProject/UnitTest1.cs index a7b364d9a0..37516d123a 100644 --- a/test/TestAssets/MultitargetedNetFrameworkProject/UnitTest1.cs +++ b/test/TestAssets/MultitargetedNetFrameworkProject/UnitTest1.cs @@ -1,7 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + using System; using System.IO; using System.Net.Security; using System.Security.Authentication; + using Xunit; namespace MultitargetedNetFrameworkProject @@ -14,36 +18,37 @@ public class UnitTest1 #endif #if NET452 - public string TargetFramework { get; } = "NET452"; + public string TargetFramework { get; } = "NET452"; #endif #if NET46 - public string TargetFramework { get; } = "NET46"; + public string TargetFramework { get; } = "NET46"; #endif #if NET461 - public string TargetFramework { get; } = "NET461"; + public string TargetFramework { get; } = "NET461"; #endif #if NET462 - public string TargetFramework { get; } = "NET462"; + public string TargetFramework { get; } = "NET462"; #endif #if NET47 - public string TargetFramework { get; } = "NET47"; + public string TargetFramework { get; } = "NET47"; #endif #if NET471 - public string TargetFramework { get; } = "NET471"; + public string TargetFramework { get; } = "NET471"; #endif #if NET472 - public string TargetFramework { get; } = "NET472"; + public string TargetFramework { get; } = "NET472"; #endif #if NET48 - public string TargetFramework { get; } = "NET48"; + public string TargetFramework { get; } = "NET48"; #endif + // Using xUnit here because MSTest uses AppDomains by default and fixes this problem for us // as long as the appdomains are enabled and modern .NET Framework is installed. [Fact] @@ -63,7 +68,7 @@ public void FailsUntilNet462ButPassesOnNewerNetFramework() exception = ex; } - switch (this.TargetFramework) + switch (TargetFramework) { case "NET451": case "NET452": diff --git a/test/TestAssets/NUTestProject/Class1.cs b/test/TestAssets/NUTestProject/Class1.cs index ec97dd18bf..7dd8ee0a94 100644 --- a/test/TestAssets/NUTestProject/Class1.cs +++ b/test/TestAssets/NUTestProject/Class1.cs @@ -1,20 +1,22 @@ -using NUnit.Framework; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace NUnitTestProject +namespace NUnitTestProject; + +using NUnit.Framework; + +[TestFixture] +public class NUnitTest1 { - [TestFixture] - public class NUnitTest1 + [Test] + public void PassTestMethod1() { - [Test] - public void PassTestMethod1() - { - Assert.AreEqual(5, 5); - } + Assert.AreEqual(5, 5); + } - [Test] - public void FailTestMethod1() - { - Assert.AreEqual(5, 6); - } + [Test] + public void FailTestMethod1() + { + Assert.AreEqual(5, 6); } } diff --git a/test/TestAssets/NUTestProject/NUTestProject.csproj b/test/TestAssets/NUTestProject/NUTestProject.csproj index 17f1b47419..d62f6e4c34 100644 --- a/test/TestAssets/NUTestProject/NUTestProject.csproj +++ b/test/TestAssets/NUTestProject/NUTestProject.csproj @@ -8,6 +8,7 @@ netcoreapp3.1 false NUTestProject + preview diff --git a/test/TestAssets/NewtonSoftDependency/UnitTest1.cs b/test/TestAssets/NewtonSoftDependency/UnitTest1.cs index 522f819653..84a5d9ca8c 100644 --- a/test/TestAssets/NewtonSoftDependency/UnitTest1.cs +++ b/test/TestAssets/NewtonSoftDependency/UnitTest1.cs @@ -1,3 +1,5 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. namespace NewtonSoftDependency { diff --git a/test/TestAssets/OutOfProcDataCollector/SampleDataCollector.cs b/test/TestAssets/OutOfProcDataCollector/SampleDataCollector.cs index f2268ae2fa..fa525b119b 100644 --- a/test/TestAssets/OutOfProcDataCollector/SampleDataCollector.cs +++ b/test/TestAssets/OutOfProcDataCollector/SampleDataCollector.cs @@ -13,11 +13,11 @@ namespace OutOfProcDataCollector [DataCollectorTypeUri("my://sample/datacollector")] public class SampleDataCollector : DataCollector, ITestExecutionEnvironmentSpecifier { - int i = 0; - private DataCollectionSink dataCollectionSink; - private DataCollectionEnvironmentContext context; - private DataCollectionLogger logger; - private readonly string tempDirectoryPath = Environment.GetEnvironmentVariable("TEST_ASSET_SAMPLE_COLLECTOR_PATH") ?? Path.GetTempPath(); + int _i = 0; + private DataCollectionSink _dataCollectionSink; + private DataCollectionEnvironmentContext _context; + private DataCollectionLogger _logger; + private readonly string _tempDirectoryPath = Environment.GetEnvironmentVariable("TEST_ASSET_SAMPLE_COLLECTOR_PATH") ?? Path.GetTempPath(); public override void Initialize( System.Xml.XmlElement configurationElement, @@ -27,50 +27,50 @@ public override void Initialize( DataCollectionEnvironmentContext environmentContext) { - events.TestHostLaunched += this.TestHostLaunched_Handler; - events.SessionStart += this.SessionStarted_Handler; - events.SessionEnd += this.SessionEnded_Handler; - events.TestCaseStart += this.Events_TestCaseStart; - events.TestCaseEnd += this.Events_TestCaseEnd; - this.dataCollectionSink = dataSink; - this.context = environmentContext; - this.logger = logger; + events.TestHostLaunched += TestHostLaunched_Handler; + events.SessionStart += SessionStarted_Handler; + events.SessionEnd += SessionEnded_Handler; + events.TestCaseStart += Events_TestCaseStart; + events.TestCaseEnd += Events_TestCaseEnd; + _dataCollectionSink = dataSink; + _context = environmentContext; + _logger = logger; } private void Events_TestCaseEnd(object sender, TestCaseEndEventArgs e) { - this.logger.LogWarning(this.context.SessionDataCollectionContext, "TestCaseEnded " + e.TestCaseName); + _logger.LogWarning(_context.SessionDataCollectionContext, "TestCaseEnded " + e.TestCaseName); } private void Events_TestCaseStart(object sender, TestCaseStartEventArgs e) { - this.logger.LogWarning(this.context.SessionDataCollectionContext, "TestCaseStarted " + e.TestCaseName); - this.logger.LogWarning(this.context.SessionDataCollectionContext, "TestCaseStarted " + e.TestElement.FullyQualifiedName); - var filename = Path.Combine(this.tempDirectoryPath, "testcasefilename" + i++ + ".txt"); + _logger.LogWarning(_context.SessionDataCollectionContext, "TestCaseStarted " + e.TestCaseName); + _logger.LogWarning(_context.SessionDataCollectionContext, "TestCaseStarted " + e.TestElement.FullyQualifiedName); + var filename = Path.Combine(_tempDirectoryPath, "testcasefilename" + _i++ + ".txt"); File.WriteAllText(filename, string.Empty); - this.dataCollectionSink.SendFileAsync(e.Context, filename, true); + _dataCollectionSink.SendFileAsync(e.Context, filename, true); } private void SessionStarted_Handler(object sender, SessionStartEventArgs args) { - var filename = Path.Combine(this.tempDirectoryPath, "filename.txt"); + var filename = Path.Combine(_tempDirectoryPath, "filename.txt"); File.WriteAllText(filename, string.Empty); - this.dataCollectionSink.SendFileAsync(this.context.SessionDataCollectionContext, filename, true); - this.logger.LogWarning(this.context.SessionDataCollectionContext, "SessionStarted"); + _dataCollectionSink.SendFileAsync(_context.SessionDataCollectionContext, filename, true); + _logger.LogWarning(_context.SessionDataCollectionContext, "SessionStarted"); } private void SessionEnded_Handler(object sender, SessionEndEventArgs args) { - this.logger.LogError(this.context.SessionDataCollectionContext, new Exception("my exception")); - this.logger.LogWarning(this.context.SessionDataCollectionContext, "my warning"); - this.logger.LogException(this.context.SessionDataCollectionContext, new Exception("abc"), DataCollectorMessageLevel.Error); + _logger.LogError(_context.SessionDataCollectionContext, new Exception("my exception")); + _logger.LogWarning(_context.SessionDataCollectionContext, "my warning"); + _logger.LogException(_context.SessionDataCollectionContext, new Exception("abc"), DataCollectorMessageLevel.Error); - this.logger.LogWarning(this.context.SessionDataCollectionContext, "SessionEnded"); + _logger.LogWarning(_context.SessionDataCollectionContext, "SessionEnded"); } private void TestHostLaunched_Handler(object sender, TestHostLaunchedEventArgs e) { - this.logger.LogWarning(this.context.SessionDataCollectionContext, "TestHostLaunched " + e.TestHostProcessId); + _logger.LogWarning(_context.SessionDataCollectionContext, "TestHostLaunched " + e.TestHostProcessId); } public IEnumerable> GetTestExecutionEnvironmentVariables() @@ -80,7 +80,7 @@ public IEnumerable> GetTestExecutionEnvironmentVari protected override void Dispose(bool disposing) { - this.logger.LogWarning(this.context.SessionDataCollectionContext, "Dispose called."); + _logger.LogWarning(_context.SessionDataCollectionContext, "Dispose called."); } } } \ No newline at end of file diff --git a/test/TestAssets/PerfAssets/MSTestAdapterPerfTestProject/MSTests.cs b/test/TestAssets/PerfAssets/MSTestAdapterPerfTestProject/MSTests.cs index b544f41cd7..465574a82a 100644 --- a/test/TestAssets/PerfAssets/MSTestAdapterPerfTestProject/MSTests.cs +++ b/test/TestAssets/PerfAssets/MSTestAdapterPerfTestProject/MSTests.cs @@ -1,40017 +1,40019 @@ -using System; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + using Microsoft.VisualStudio.TestTools.UnitTesting; namespace UnitTestinProgress { [TestClass] - public class MSTests + public class MSTests { - #region PassingTests - [TestMethod] - public void Test_01() - { - } - [TestMethod] - public void Test_02() - { - } - [TestMethod] - public void Test_03() - { - } - [TestMethod] - public void Test_04() - { - } - [TestMethod] - public void Test_05() - { - } - [TestMethod] - public void Test_06() - { - } - [TestMethod] - public void Test_07() - { - } - [TestMethod] - public void Test_08() - { - } - [TestMethod] - public void Test_09() - { - } - [TestMethod] - public void Test_10() - { - } - [TestMethod] - public void Test_11() - { - } - [TestMethod] - public void Test_12() - { - } - [TestMethod] - public void Test_13() - { - } - [TestMethod] - public void Test_14() - { - } - [TestMethod] - public void Test_15() - { - } - [TestMethod] - public void Test_16() - { - } - [TestMethod] - public void Test_17() - { - } - [TestMethod] - public void Test_18() - { - } - [TestMethod] - public void Test_19() - { - } - [TestMethod] - public void Test_20() - { - } - [TestMethod] - public void Test_21() - { - } - [TestMethod] - public void Test_22() - { - } - [TestMethod] - public void Test_23() - { - } - [TestMethod] - public void Test_24() - { - } - [TestMethod] - public void Test_25() - { - } - [TestMethod] - public void Test_26() - { - } - [TestMethod] - public void Test_27() - { - } - [TestMethod] - public void Test_28() - { - } - [TestMethod] - public void Test_29() - { - } - [TestMethod] - public void Test_30() - { - } - [TestMethod] - public void Test_31() - { - } - [TestMethod] - public void Test_32() - { - } - [TestMethod] - public void Test_33() - { - } - [TestMethod] - public void Test_34() - { - } - [TestMethod] - public void Test_35() - { - } - [TestMethod] - public void Test_36() - { - } - [TestMethod] - public void Test_37() - { - } - [TestMethod] - public void Test_38() - { - } - [TestMethod] - public void Test_39() - { - } - [TestMethod] - public void Test_40() - { - } - [TestMethod] - public void Test_41() - { - } - [TestMethod] - public void Test_42() - { - } - [TestMethod] - public void Test_43() - { - } - [TestMethod] - public void Test_44() - { - } - [TestMethod] - public void Test_45() - { - } - [TestMethod] - public void Test_46() - { - } - [TestMethod] - public void Test_47() - { - } - [TestMethod] - public void Test_48() - { - } - [TestMethod] - public void Test_49() - { - } - [TestMethod] - public void Test_50() - { - } - [TestMethod] - public void Test_51() - { - } - [TestMethod] - public void Test_52() - { - } - [TestMethod] - public void Test_53() - { - } - [TestMethod] - public void Test_54() - { - } - [TestMethod] - public void Test_55() - { - } - [TestMethod] - public void Test_56() - { - } - [TestMethod] - public void Test_57() - { - } - [TestMethod] - public void Test_58() - { - } - [TestMethod] - public void Test_59() - { - } - [TestMethod] - public void Test_60() - { - } - [TestMethod] - public void Test_61() - { - } - [TestMethod] - public void Test_62() - { - } - [TestMethod] - public void Test_63() - { - } - [TestMethod] - public void Test_64() - { - } - [TestMethod] - public void Test_65() - { - } - [TestMethod] - public void Test_66() - { - } - [TestMethod] - public void Test_67() - { - } - [TestMethod] - public void Test_68() - { - } - [TestMethod] - public void Test_69() - { - } - [TestMethod] - public void Test_70() - { - } - [TestMethod] - public void Test_71() - { - } - [TestMethod] - public void Test_72() - { - } - [TestMethod] - public void Test_73() - { - } - [TestMethod] - public void Test_74() - { - } - [TestMethod] - public void Test_75() - { - } - [TestMethod] - public void Test_76() - { - } - [TestMethod] - public void Test_77() - { - } - [TestMethod] - public void Test_78() - { - } - [TestMethod] - public void Test_79() - { - } - [TestMethod] - public void Test_80() - { - } - [TestMethod] - public void Test_81() - { - } - [TestMethod] - public void Test_82() - { - } - [TestMethod] - public void Test_83() - { - } - [TestMethod] - public void Test_84() - { - } - [TestMethod] - public void Test_85() - { - } - [TestMethod] - public void Test_86() - { - } - [TestMethod] - public void Test_87() - { - } - [TestMethod] - public void Test_88() - { - } - [TestMethod] - public void Test_89() - { - } - [TestMethod] - public void Test_90() - { - } - [TestMethod] - public void Test_91() - { - } - [TestMethod] - public void Test_92() - { - } - [TestMethod] - public void Test_93() - { - } - [TestMethod] - public void Test_94() - { - } - [TestMethod] - public void Test_95() - { - } - [TestMethod] - public void Test_96() - { - } - [TestMethod] - public void Test_97() - { - } - [TestMethod] - public void Test_98() - { - } - [TestMethod] - public void Test_99() - { - } - [TestMethod] - public void Test_100() - { - } - [TestMethod] - public void Test_101() - { - } - [TestMethod] - public void Test_102() - { - } - [TestMethod] - public void Test_103() - { - } - [TestMethod] - public void Test_104() - { - } - [TestMethod] - public void Test_105() - { - } - [TestMethod] - public void Test_106() - { - } - [TestMethod] - public void Test_107() - { - } - [TestMethod] - public void Test_108() - { - } - [TestMethod] - public void Test_109() - { - } - [TestMethod] - public void Test_110() - { - } - [TestMethod] - public void Test_111() - { - } - [TestMethod] - public void Test_112() - { - } - [TestMethod] - public void Test_113() - { - } - [TestMethod] - public void Test_114() - { - } - [TestMethod] - public void Test_115() - { - } - [TestMethod] - public void Test_116() - { - } - [TestMethod] - public void Test_117() - { - } - [TestMethod] - public void Test_118() - { - } - [TestMethod] - public void Test_119() - { - } - [TestMethod] - public void Test_120() - { - } - [TestMethod] - public void Test_121() - { - } - [TestMethod] - public void Test_122() - { - } - [TestMethod] - public void Test_123() - { - } - [TestMethod] - public void Test_124() - { - } - [TestMethod] - public void Test_125() - { - } - [TestMethod] - public void Test_126() - { - } - [TestMethod] - public void Test_127() - { - } - [TestMethod] - public void Test_128() - { - } - [TestMethod] - public void Test_129() - { - } - [TestMethod] - public void Test_130() - { - } - [TestMethod] - public void Test_131() - { - } - [TestMethod] - public void Test_132() - { - } - [TestMethod] - public void Test_133() - { - } - [TestMethod] - public void Test_134() - { - } - [TestMethod] - public void Test_135() - { - } - [TestMethod] - public void Test_136() - { - } - [TestMethod] - public void Test_137() - { - } - [TestMethod] - public void Test_138() - { - } - [TestMethod] - public void Test_139() - { - } - [TestMethod] - public void Test_140() - { - } - [TestMethod] - public void Test_141() - { - } - [TestMethod] - public void Test_142() - { - } - [TestMethod] - public void Test_143() - { - } - [TestMethod] - public void Test_144() - { - } - [TestMethod] - public void Test_145() - { - } - [TestMethod] - public void Test_146() - { - } - [TestMethod] - public void Test_147() - { - } - [TestMethod] - public void Test_148() - { - } - [TestMethod] - public void Test_149() - { - } - [TestMethod] - public void Test_150() - { - } - [TestMethod] - public void Test_151() - { - } - [TestMethod] - public void Test_152() - { - } - [TestMethod] - public void Test_153() - { - } - [TestMethod] - public void Test_154() - { - } - [TestMethod] - public void Test_155() - { - } - [TestMethod] - public void Test_156() - { - } - [TestMethod] - public void Test_157() - { - } - [TestMethod] - public void Test_158() - { - } - [TestMethod] - public void Test_159() - { - } - [TestMethod] - public void Test_160() - { - } - [TestMethod] - public void Test_161() - { - } - [TestMethod] - public void Test_162() - { - } - [TestMethod] - public void Test_163() - { - } - [TestMethod] - public void Test_164() - { - } - [TestMethod] - public void Test_165() - { - } - [TestMethod] - public void Test_166() - { - } - [TestMethod] - public void Test_167() - { - } - [TestMethod] - public void Test_168() - { - } - [TestMethod] - public void Test_169() - { - } - [TestMethod] - public void Test_170() - { - } - [TestMethod] - public void Test_171() - { - } - [TestMethod] - public void Test_172() - { - } - [TestMethod] - public void Test_173() - { - } - [TestMethod] - public void Test_174() - { - } - [TestMethod] - public void Test_175() - { - } - [TestMethod] - public void Test_176() - { - } - [TestMethod] - public void Test_177() - { - } - [TestMethod] - public void Test_178() - { - } - [TestMethod] - public void Test_179() - { - } - [TestMethod] - public void Test_180() - { - } - [TestMethod] - public void Test_181() - { - } - [TestMethod] - public void Test_182() - { - } - [TestMethod] - public void Test_183() - { - } - [TestMethod] - public void Test_184() - { - } - [TestMethod] - public void Test_185() - { - } - [TestMethod] - public void Test_186() - { - } - [TestMethod] - public void Test_187() - { - } - [TestMethod] - public void Test_188() - { - } - [TestMethod] - public void Test_189() - { - } - [TestMethod] - public void Test_190() - { - } - [TestMethod] - public void Test_191() - { - } - [TestMethod] - public void Test_192() - { - } - [TestMethod] - public void Test_193() - { - } - [TestMethod] - public void Test_194() - { - } - [TestMethod] - public void Test_195() - { - } - [TestMethod] - public void Test_196() - { - } - [TestMethod] - public void Test_197() - { - } - [TestMethod] - public void Test_198() - { - } - [TestMethod] - public void Test_199() - { - } - [TestMethod] - public void Test_200() - { - } - [TestMethod] - public void Test_201() - { - } - [TestMethod] - public void Test_202() - { - } - [TestMethod] - public void Test_203() - { - } - [TestMethod] - public void Test_204() - { - } - [TestMethod] - public void Test_205() - { - } - [TestMethod] - public void Test_206() - { - } - [TestMethod] - public void Test_207() - { - } - [TestMethod] - public void Test_208() - { - } - [TestMethod] - public void Test_209() - { - } - [TestMethod] - public void Test_210() - { - } - [TestMethod] - public void Test_211() - { - } - [TestMethod] - public void Test_212() - { - } - [TestMethod] - public void Test_213() - { - } - [TestMethod] - public void Test_214() - { - } - [TestMethod] - public void Test_215() - { - } - [TestMethod] - public void Test_216() - { - } - [TestMethod] - public void Test_217() - { - } - [TestMethod] - public void Test_218() - { - } - [TestMethod] - public void Test_219() - { - } - [TestMethod] - public void Test_220() - { - } - [TestMethod] - public void Test_221() - { - } - [TestMethod] - public void Test_222() - { - } - [TestMethod] - public void Test_223() - { - } - [TestMethod] - public void Test_224() - { - } - [TestMethod] - public void Test_225() - { - } - [TestMethod] - public void Test_226() - { - } - [TestMethod] - public void Test_227() - { - } - [TestMethod] - public void Test_228() - { - } - [TestMethod] - public void Test_229() - { - } - [TestMethod] - public void Test_230() - { - } - [TestMethod] - public void Test_231() - { - } - [TestMethod] - public void Test_232() - { - } - [TestMethod] - public void Test_233() - { - } - [TestMethod] - public void Test_234() - { - } - [TestMethod] - public void Test_235() - { - } - [TestMethod] - public void Test_236() - { - } - [TestMethod] - public void Test_237() - { - } - [TestMethod] - public void Test_238() - { - } - [TestMethod] - public void Test_239() - { - } - [TestMethod] - public void Test_240() - { - } - [TestMethod] - public void Test_241() - { - } - [TestMethod] - public void Test_242() - { - } - [TestMethod] - public void Test_243() - { - } - [TestMethod] - public void Test_244() - { - } - [TestMethod] - public void Test_245() - { - } - [TestMethod] - public void Test_246() - { - } - [TestMethod] - public void Test_247() - { - } - [TestMethod] - public void Test_248() - { - } - [TestMethod] - public void Test_249() - { - } - [TestMethod] - public void Test_250() - { - } - [TestMethod] - public void Test_251() - { - } - [TestMethod] - public void Test_252() - { - } - [TestMethod] - public void Test_253() - { - } - [TestMethod] - public void Test_254() - { - } - [TestMethod] - public void Test_255() - { - } - [TestMethod] - public void Test_256() - { - } - [TestMethod] - public void Test_257() - { - } - [TestMethod] - public void Test_258() - { - } - [TestMethod] - public void Test_259() - { - } - [TestMethod] - public void Test_260() - { - } - [TestMethod] - public void Test_261() - { - } - [TestMethod] - public void Test_262() - { - } - [TestMethod] - public void Test_263() - { - } - [TestMethod] - public void Test_264() - { - } - [TestMethod] - public void Test_265() - { - } - [TestMethod] - public void Test_266() - { - } - [TestMethod] - public void Test_267() - { - } - [TestMethod] - public void Test_268() - { - } - [TestMethod] - public void Test_269() - { - } - [TestMethod] - public void Test_270() - { - } - [TestMethod] - public void Test_271() - { - } - [TestMethod] - public void Test_272() - { - } - [TestMethod] - public void Test_273() - { - } - [TestMethod] - public void Test_274() - { - } - [TestMethod] - public void Test_275() - { - } - [TestMethod] - public void Test_276() - { - } - [TestMethod] - public void Test_277() - { - } - [TestMethod] - public void Test_278() - { - } - [TestMethod] - public void Test_279() - { - } - [TestMethod] - public void Test_280() - { - } - [TestMethod] - public void Test_281() - { - } - [TestMethod] - public void Test_282() - { - } - [TestMethod] - public void Test_283() - { - } - [TestMethod] - public void Test_284() - { - } - [TestMethod] - public void Test_285() - { - } - [TestMethod] - public void Test_286() - { - } - [TestMethod] - public void Test_287() - { - } - [TestMethod] - public void Test_288() - { - } - [TestMethod] - public void Test_289() - { - } - [TestMethod] - public void Test_290() - { - } - [TestMethod] - public void Test_291() - { - } - [TestMethod] - public void Test_292() - { - } - [TestMethod] - public void Test_293() - { - } - [TestMethod] - public void Test_294() - { - } - [TestMethod] - public void Test_295() - { - } - [TestMethod] - public void Test_296() - { - } - [TestMethod] - public void Test_297() - { - } - [TestMethod] - public void Test_298() - { - } - [TestMethod] - public void Test_299() - { - } - [TestMethod] - public void Test_300() - { - } - [TestMethod] - public void Test_301() - { - } - [TestMethod] - public void Test_302() - { - } - [TestMethod] - public void Test_303() - { - } - [TestMethod] - public void Test_304() - { - } - [TestMethod] - public void Test_305() - { - } - [TestMethod] - public void Test_306() - { - } - [TestMethod] - public void Test_307() - { - } - [TestMethod] - public void Test_308() - { - } - [TestMethod] - public void Test_309() - { - } - [TestMethod] - public void Test_310() - { - } - [TestMethod] - public void Test_311() - { - } - [TestMethod] - public void Test_312() - { - } - [TestMethod] - public void Test_313() - { - } - [TestMethod] - public void Test_314() - { - } - [TestMethod] - public void Test_315() - { - } - [TestMethod] - public void Test_316() - { - } - [TestMethod] - public void Test_317() - { - } - [TestMethod] - public void Test_318() - { - } - [TestMethod] - public void Test_319() - { - } - [TestMethod] - public void Test_320() - { - } - [TestMethod] - public void Test_321() - { - } - [TestMethod] - public void Test_322() - { - } - [TestMethod] - public void Test_323() - { - } - [TestMethod] - public void Test_324() - { - } - [TestMethod] - public void Test_325() - { - } - [TestMethod] - public void Test_326() - { - } - [TestMethod] - public void Test_327() - { - } - [TestMethod] - public void Test_328() - { - } - [TestMethod] - public void Test_329() - { - } - [TestMethod] - public void Test_330() - { - } - [TestMethod] - public void Test_331() - { - } - [TestMethod] - public void Test_332() - { - } - [TestMethod] - public void Test_333() - { - } - [TestMethod] - public void Test_334() - { - } - [TestMethod] - public void Test_335() - { - } - [TestMethod] - public void Test_336() - { - } - [TestMethod] - public void Test_337() - { - } - [TestMethod] - public void Test_338() - { - } - [TestMethod] - public void Test_339() - { - } - [TestMethod] - public void Test_340() - { - } - [TestMethod] - public void Test_341() - { - } - [TestMethod] - public void Test_342() - { - } - [TestMethod] - public void Test_343() - { - } - [TestMethod] - public void Test_344() - { - } - [TestMethod] - public void Test_345() - { - } - [TestMethod] - public void Test_346() - { - } - [TestMethod] - public void Test_347() - { - } - [TestMethod] - public void Test_348() - { - } - [TestMethod] - public void Test_349() - { - } - [TestMethod] - public void Test_350() - { - } - [TestMethod] - public void Test_351() - { - } - [TestMethod] - public void Test_352() - { - } - [TestMethod] - public void Test_353() - { - } - [TestMethod] - public void Test_354() - { - } - [TestMethod] - public void Test_355() - { - } - [TestMethod] - public void Test_356() - { - } - [TestMethod] - public void Test_357() - { - } - [TestMethod] - public void Test_358() - { - } - [TestMethod] - public void Test_359() - { - } - [TestMethod] - public void Test_360() - { - } - [TestMethod] - public void Test_361() - { - } - [TestMethod] - public void Test_362() - { - } - [TestMethod] - public void Test_363() - { - } - [TestMethod] - public void Test_364() - { - } - [TestMethod] - public void Test_365() - { - } - [TestMethod] - public void Test_366() - { - } - [TestMethod] - public void Test_367() - { - } - [TestMethod] - public void Test_368() - { - } - [TestMethod] - public void Test_369() - { - } - [TestMethod] - public void Test_370() - { - } - [TestMethod] - public void Test_371() - { - } - [TestMethod] - public void Test_372() - { - } - [TestMethod] - public void Test_373() - { - } - [TestMethod] - public void Test_374() - { - } - [TestMethod] - public void Test_375() - { - } - [TestMethod] - public void Test_376() - { - } - [TestMethod] - public void Test_377() - { - } - [TestMethod] - public void Test_378() - { - } - [TestMethod] - public void Test_379() - { - } - [TestMethod] - public void Test_380() - { - } - [TestMethod] - public void Test_381() - { - } - [TestMethod] - public void Test_382() - { - } - [TestMethod] - public void Test_383() - { - } - [TestMethod] - public void Test_384() - { - } - [TestMethod] - public void Test_385() - { - } - [TestMethod] - public void Test_386() - { - } - [TestMethod] - public void Test_387() - { - } - [TestMethod] - public void Test_388() - { - } - [TestMethod] - public void Test_389() - { - } - [TestMethod] - public void Test_390() - { - } - [TestMethod] - public void Test_391() - { - } - [TestMethod] - public void Test_392() - { - } - [TestMethod] - public void Test_393() - { - } - [TestMethod] - public void Test_394() - { - } - [TestMethod] - public void Test_395() - { - } - [TestMethod] - public void Test_396() - { - } - [TestMethod] - public void Test_397() - { - } - [TestMethod] - public void Test_398() - { - } - [TestMethod] - public void Test_399() - { - } - [TestMethod] - public void Test_400() - { - } - [TestMethod] - public void Test_401() - { - } - [TestMethod] - public void Test_402() - { - } - [TestMethod] - public void Test_403() - { - } - [TestMethod] - public void Test_404() - { - } - [TestMethod] - public void Test_405() - { - } - [TestMethod] - public void Test_406() - { - } - [TestMethod] - public void Test_407() - { - } - [TestMethod] - public void Test_408() - { - } - [TestMethod] - public void Test_409() - { - } - [TestMethod] - public void Test_410() - { - } - [TestMethod] - public void Test_411() - { - } - [TestMethod] - public void Test_412() - { - } - [TestMethod] - public void Test_413() - { - } - [TestMethod] - public void Test_414() - { - } - [TestMethod] - public void Test_415() - { - } - [TestMethod] - public void Test_416() - { - } - [TestMethod] - public void Test_417() - { - } - [TestMethod] - public void Test_418() - { - } - [TestMethod] - public void Test_419() - { - } - [TestMethod] - public void Test_420() - { - } - [TestMethod] - public void Test_421() - { - } - [TestMethod] - public void Test_422() - { - } - [TestMethod] - public void Test_423() - { - } - [TestMethod] - public void Test_424() - { - } - [TestMethod] - public void Test_425() - { - } - [TestMethod] - public void Test_426() - { - } - [TestMethod] - public void Test_427() - { - } - [TestMethod] - public void Test_428() - { - } - [TestMethod] - public void Test_429() - { - } - [TestMethod] - public void Test_430() - { - } - [TestMethod] - public void Test_431() - { - } - [TestMethod] - public void Test_432() - { - } - [TestMethod] - public void Test_433() - { - } - [TestMethod] - public void Test_434() - { - } - [TestMethod] - public void Test_435() - { - } - [TestMethod] - public void Test_436() - { - } - [TestMethod] - public void Test_437() - { - } - [TestMethod] - public void Test_438() - { - } - [TestMethod] - public void Test_439() - { - } - [TestMethod] - public void Test_440() - { - } - [TestMethod] - public void Test_441() - { - } - [TestMethod] - public void Test_442() - { - } - [TestMethod] - public void Test_443() - { - } - [TestMethod] - public void Test_444() - { - } - [TestMethod] - public void Test_445() - { - } - [TestMethod] - public void Test_446() - { - } - [TestMethod] - public void Test_447() - { - } - [TestMethod] - public void Test_448() - { - } - [TestMethod] - public void Test_449() - { - } - [TestMethod] - public void Test_450() - { - } - [TestMethod] - public void Test_451() - { - } - [TestMethod] - public void Test_452() - { - } - [TestMethod] - public void Test_453() - { - } - [TestMethod] - public void Test_454() - { - } - [TestMethod] - public void Test_455() - { - } - [TestMethod] - public void Test_456() - { - } - [TestMethod] - public void Test_457() - { - } - [TestMethod] - public void Test_458() - { - } - [TestMethod] - public void Test_459() - { - } - [TestMethod] - public void Test_460() - { - } - [TestMethod] - public void Test_461() - { - } - [TestMethod] - public void Test_462() - { - } - [TestMethod] - public void Test_463() - { - } - [TestMethod] - public void Test_464() - { - } - [TestMethod] - public void Test_465() - { - } - [TestMethod] - public void Test_466() - { - } - [TestMethod] - public void Test_467() - { - } - [TestMethod] - public void Test_468() - { - } - [TestMethod] - public void Test_469() - { - } - [TestMethod] - public void Test_470() - { - } - [TestMethod] - public void Test_471() - { - } - [TestMethod] - public void Test_472() - { - } - [TestMethod] - public void Test_473() - { - } - [TestMethod] - public void Test_474() - { - } - [TestMethod] - public void Test_475() - { - } - [TestMethod] - public void Test_476() - { - } - [TestMethod] - public void Test_477() - { - } - [TestMethod] - public void Test_478() - { - } - [TestMethod] - public void Test_479() - { - } - [TestMethod] - public void Test_480() - { - } - [TestMethod] - public void Test_481() - { - } - [TestMethod] - public void Test_482() - { - } - [TestMethod] - public void Test_483() - { - } - [TestMethod] - public void Test_484() - { - } - [TestMethod] - public void Test_485() - { - } - [TestMethod] - public void Test_486() - { - } - [TestMethod] - public void Test_487() - { - } - [TestMethod] - public void Test_488() - { - } - [TestMethod] - public void Test_489() - { - } - [TestMethod] - public void Test_490() - { - } - [TestMethod] - public void Test_491() - { - } - [TestMethod] - public void Test_492() - { - } - [TestMethod] - public void Test_493() - { - } - [TestMethod] - public void Test_494() - { - } - [TestMethod] - public void Test_495() - { - } - [TestMethod] - public void Test_496() - { - } - [TestMethod] - public void Test_497() - { - } - [TestMethod] - public void Test_498() - { - } - [TestMethod] - public void Test_499() - { - } - [TestMethod] - public void Test_500() - { - } - [TestMethod] - public void Test_501() - { - } - [TestMethod] - public void Test_502() - { - } - [TestMethod] - public void Test_503() - { - } - [TestMethod] - public void Test_504() - { - } - [TestMethod] - public void Test_505() - { - } - [TestMethod] - public void Test_506() - { - } - [TestMethod] - public void Test_507() - { - } - [TestMethod] - public void Test_508() - { - } - [TestMethod] - public void Test_509() - { - } - [TestMethod] - public void Test_510() - { - } - [TestMethod] - public void Test_511() - { - } - [TestMethod] - public void Test_512() - { - } - [TestMethod] - public void Test_513() - { - } - [TestMethod] - public void Test_514() - { - } - [TestMethod] - public void Test_515() - { - } - [TestMethod] - public void Test_516() - { - } - [TestMethod] - public void Test_517() - { - } - [TestMethod] - public void Test_518() - { - } - [TestMethod] - public void Test_519() - { - } - [TestMethod] - public void Test_520() - { - } - [TestMethod] - public void Test_521() - { - } - [TestMethod] - public void Test_522() - { - } - [TestMethod] - public void Test_523() - { - } - [TestMethod] - public void Test_524() - { - } - [TestMethod] - public void Test_525() - { - } - [TestMethod] - public void Test_526() - { - } - [TestMethod] - public void Test_527() - { - } - [TestMethod] - public void Test_528() - { - } - [TestMethod] - public void Test_529() - { - } - [TestMethod] - public void Test_530() - { - } - [TestMethod] - public void Test_531() - { - } - [TestMethod] - public void Test_532() - { - } - [TestMethod] - public void Test_533() - { - } - [TestMethod] - public void Test_534() - { - } - [TestMethod] - public void Test_535() - { - } - [TestMethod] - public void Test_536() - { - } - [TestMethod] - public void Test_537() - { - } - [TestMethod] - public void Test_538() - { - } - [TestMethod] - public void Test_539() - { - } - [TestMethod] - public void Test_540() - { - } - [TestMethod] - public void Test_541() - { - } - [TestMethod] - public void Test_542() - { - } - [TestMethod] - public void Test_543() - { - } - [TestMethod] - public void Test_544() - { - } - [TestMethod] - public void Test_545() - { - } - [TestMethod] - public void Test_546() - { - } - [TestMethod] - public void Test_547() - { - } - [TestMethod] - public void Test_548() - { - } - [TestMethod] - public void Test_549() - { - } - [TestMethod] - public void Test_550() - { - } - [TestMethod] - public void Test_551() - { - } - [TestMethod] - public void Test_552() - { - } - [TestMethod] - public void Test_553() - { - } - [TestMethod] - public void Test_554() - { - } - [TestMethod] - public void Test_555() - { - } - [TestMethod] - public void Test_556() - { - } - [TestMethod] - public void Test_557() - { - } - [TestMethod] - public void Test_558() - { - } - [TestMethod] - public void Test_559() - { - } - [TestMethod] - public void Test_560() - { - } - [TestMethod] - public void Test_561() - { - } - [TestMethod] - public void Test_562() - { - } - [TestMethod] - public void Test_563() - { - } - [TestMethod] - public void Test_564() - { - } - [TestMethod] - public void Test_565() - { - } - [TestMethod] - public void Test_566() - { - } - [TestMethod] - public void Test_567() - { - } - [TestMethod] - public void Test_568() - { - } - [TestMethod] - public void Test_569() - { - } - [TestMethod] - public void Test_570() - { - } - [TestMethod] - public void Test_571() - { - } - [TestMethod] - public void Test_572() - { - } - [TestMethod] - public void Test_573() - { - } - [TestMethod] - public void Test_574() - { - } - [TestMethod] - public void Test_575() - { - } - [TestMethod] - public void Test_576() - { - } - [TestMethod] - public void Test_577() - { - } - [TestMethod] - public void Test_578() - { - } - [TestMethod] - public void Test_579() - { - } - [TestMethod] - public void Test_580() - { - } - [TestMethod] - public void Test_581() - { - } - [TestMethod] - public void Test_582() - { - } - [TestMethod] - public void Test_583() - { - } - [TestMethod] - public void Test_584() - { - } - [TestMethod] - public void Test_585() - { - } - [TestMethod] - public void Test_586() - { - } - [TestMethod] - public void Test_587() - { - } - [TestMethod] - public void Test_588() - { - } - [TestMethod] - public void Test_589() - { - } - [TestMethod] - public void Test_590() - { - } - [TestMethod] - public void Test_591() - { - } - [TestMethod] - public void Test_592() - { - } - [TestMethod] - public void Test_593() - { - } - [TestMethod] - public void Test_594() - { - } - [TestMethod] - public void Test_595() - { - } - [TestMethod] - public void Test_596() - { - } - [TestMethod] - public void Test_597() - { - } - [TestMethod] - public void Test_598() - { - } - [TestMethod] - public void Test_599() - { - } - [TestMethod] - public void Test_600() - { - } - [TestMethod] - public void Test_601() - { - } - [TestMethod] - public void Test_602() - { - } - [TestMethod] - public void Test_603() - { - } - [TestMethod] - public void Test_604() - { - } - [TestMethod] - public void Test_605() - { - } - [TestMethod] - public void Test_606() - { - } - [TestMethod] - public void Test_607() - { - } - [TestMethod] - public void Test_608() - { - } - [TestMethod] - public void Test_609() - { - } - [TestMethod] - public void Test_610() - { - } - [TestMethod] - public void Test_611() - { - } - [TestMethod] - public void Test_612() - { - } - [TestMethod] - public void Test_613() - { - } - [TestMethod] - public void Test_614() - { - } - [TestMethod] - public void Test_615() - { - } - [TestMethod] - public void Test_616() - { - } - [TestMethod] - public void Test_617() - { - } - [TestMethod] - public void Test_618() - { - } - [TestMethod] - public void Test_619() - { - } - [TestMethod] - public void Test_620() - { - } - [TestMethod] - public void Test_621() - { - } - [TestMethod] - public void Test_622() - { - } - [TestMethod] - public void Test_623() - { - } - [TestMethod] - public void Test_624() - { - } - [TestMethod] - public void Test_625() - { - } - [TestMethod] - public void Test_626() - { - } - [TestMethod] - public void Test_627() - { - } - [TestMethod] - public void Test_628() - { - } - [TestMethod] - public void Test_629() - { - } - [TestMethod] - public void Test_630() - { - } - [TestMethod] - public void Test_631() - { - } - [TestMethod] - public void Test_632() - { - } - [TestMethod] - public void Test_633() - { - } - [TestMethod] - public void Test_634() - { - } - [TestMethod] - public void Test_635() - { - } - [TestMethod] - public void Test_636() - { - } - [TestMethod] - public void Test_637() - { - } - [TestMethod] - public void Test_638() - { - } - [TestMethod] - public void Test_639() - { - } - [TestMethod] - public void Test_640() - { - } - [TestMethod] - public void Test_641() - { - } - [TestMethod] - public void Test_642() - { - } - [TestMethod] - public void Test_643() - { - } - [TestMethod] - public void Test_644() - { - } - [TestMethod] - public void Test_645() - { - } - [TestMethod] - public void Test_646() - { - } - [TestMethod] - public void Test_647() - { - } - [TestMethod] - public void Test_648() - { - } - [TestMethod] - public void Test_649() - { - } - [TestMethod] - public void Test_650() - { - } - [TestMethod] - public void Test_651() - { - } - [TestMethod] - public void Test_652() - { - } - [TestMethod] - public void Test_653() - { - } - [TestMethod] - public void Test_654() - { - } - [TestMethod] - public void Test_655() - { - } - [TestMethod] - public void Test_656() - { - } - [TestMethod] - public void Test_657() - { - } - [TestMethod] - public void Test_658() - { - } - [TestMethod] - public void Test_659() - { - } - [TestMethod] - public void Test_660() - { - } - [TestMethod] - public void Test_661() - { - } - [TestMethod] - public void Test_662() - { - } - [TestMethod] - public void Test_663() - { - } - [TestMethod] - public void Test_664() - { - } - [TestMethod] - public void Test_665() - { - } - [TestMethod] - public void Test_666() - { - } - [TestMethod] - public void Test_667() - { - } - [TestMethod] - public void Test_668() - { - } - [TestMethod] - public void Test_669() - { - } - [TestMethod] - public void Test_670() - { - } - [TestMethod] - public void Test_671() - { - } - [TestMethod] - public void Test_672() - { - } - [TestMethod] - public void Test_673() - { - } - [TestMethod] - public void Test_674() - { - } - [TestMethod] - public void Test_675() - { - } - [TestMethod] - public void Test_676() - { - } - [TestMethod] - public void Test_677() - { - } - [TestMethod] - public void Test_678() - { - } - [TestMethod] - public void Test_679() - { - } - [TestMethod] - public void Test_680() - { - } - [TestMethod] - public void Test_681() - { - } - [TestMethod] - public void Test_682() - { - } - [TestMethod] - public void Test_683() - { - } - [TestMethod] - public void Test_684() - { - } - [TestMethod] - public void Test_685() - { - } - [TestMethod] - public void Test_686() - { - } - [TestMethod] - public void Test_687() - { - } - [TestMethod] - public void Test_688() - { - } - [TestMethod] - public void Test_689() - { - } - [TestMethod] - public void Test_690() - { - } - [TestMethod] - public void Test_691() - { - } - [TestMethod] - public void Test_692() - { - } - [TestMethod] - public void Test_693() - { - } - [TestMethod] - public void Test_694() - { - } - [TestMethod] - public void Test_695() - { - } - [TestMethod] - public void Test_696() - { - } - [TestMethod] - public void Test_697() - { - } - [TestMethod] - public void Test_698() - { - } - [TestMethod] - public void Test_699() - { - } - [TestMethod] - public void Test_700() - { - } - [TestMethod] - public void Test_701() - { - } - [TestMethod] - public void Test_702() - { - } - [TestMethod] - public void Test_703() - { - } - [TestMethod] - public void Test_704() - { - } - [TestMethod] - public void Test_705() - { - } - [TestMethod] - public void Test_706() - { - } - [TestMethod] - public void Test_707() - { - } - [TestMethod] - public void Test_708() - { - } - [TestMethod] - public void Test_709() - { - } - [TestMethod] - public void Test_710() - { - } - [TestMethod] - public void Test_711() - { - } - [TestMethod] - public void Test_712() - { - } - [TestMethod] - public void Test_713() - { - } - [TestMethod] - public void Test_714() - { - } - [TestMethod] - public void Test_715() - { - } - [TestMethod] - public void Test_716() - { - } - [TestMethod] - public void Test_717() - { - } - [TestMethod] - public void Test_718() - { - } - [TestMethod] - public void Test_719() - { - } - [TestMethod] - public void Test_720() - { - } - [TestMethod] - public void Test_721() - { - } - [TestMethod] - public void Test_722() - { - } - [TestMethod] - public void Test_723() - { - } - [TestMethod] - public void Test_724() - { - } - [TestMethod] - public void Test_725() - { - } - [TestMethod] - public void Test_726() - { - } - [TestMethod] - public void Test_727() - { - } - [TestMethod] - public void Test_728() - { - } - [TestMethod] - public void Test_729() - { - } - [TestMethod] - public void Test_730() - { - } - [TestMethod] - public void Test_731() - { - } - [TestMethod] - public void Test_732() - { - } - [TestMethod] - public void Test_733() - { - } - [TestMethod] - public void Test_734() - { - } - [TestMethod] - public void Test_735() - { - } - [TestMethod] - public void Test_736() - { - } - [TestMethod] - public void Test_737() - { - } - [TestMethod] - public void Test_738() - { - } - [TestMethod] - public void Test_739() - { - } - [TestMethod] - public void Test_740() - { - } - [TestMethod] - public void Test_741() - { - } - [TestMethod] - public void Test_742() - { - } - [TestMethod] - public void Test_743() - { - } - [TestMethod] - public void Test_744() - { - } - [TestMethod] - public void Test_745() - { - } - [TestMethod] - public void Test_746() - { - } - [TestMethod] - public void Test_747() - { - } - [TestMethod] - public void Test_748() - { - } - [TestMethod] - public void Test_749() - { - } - [TestMethod] - public void Test_750() - { - } - [TestMethod] - public void Test_751() - { - } - [TestMethod] - public void Test_752() - { - } - [TestMethod] - public void Test_753() - { - } - [TestMethod] - public void Test_754() - { - } - [TestMethod] - public void Test_755() - { - } - [TestMethod] - public void Test_756() - { - } - [TestMethod] - public void Test_757() - { - } - [TestMethod] - public void Test_758() - { - } - [TestMethod] - public void Test_759() - { - } - [TestMethod] - public void Test_760() - { - } - [TestMethod] - public void Test_761() - { - } - [TestMethod] - public void Test_762() - { - } - [TestMethod] - public void Test_763() - { - } - [TestMethod] - public void Test_764() - { - } - [TestMethod] - public void Test_765() - { - } - [TestMethod] - public void Test_766() - { - } - [TestMethod] - public void Test_767() - { - } - [TestMethod] - public void Test_768() - { - } - [TestMethod] - public void Test_769() - { - } - [TestMethod] - public void Test_770() - { - } - [TestMethod] - public void Test_771() - { - } - [TestMethod] - public void Test_772() - { - } - [TestMethod] - public void Test_773() - { - } - [TestMethod] - public void Test_774() - { - } - [TestMethod] - public void Test_775() - { - } - [TestMethod] - public void Test_776() - { - } - [TestMethod] - public void Test_777() - { - } - [TestMethod] - public void Test_778() - { - } - [TestMethod] - public void Test_779() - { - } - [TestMethod] - public void Test_780() - { - } - [TestMethod] - public void Test_781() - { - } - [TestMethod] - public void Test_782() - { - } - [TestMethod] - public void Test_783() - { - } - [TestMethod] - public void Test_784() - { - } - [TestMethod] - public void Test_785() - { - } - [TestMethod] - public void Test_786() - { - } - [TestMethod] - public void Test_787() - { - } - [TestMethod] - public void Test_788() - { - } - [TestMethod] - public void Test_789() - { - } - [TestMethod] - public void Test_790() - { - } - [TestMethod] - public void Test_791() - { - } - [TestMethod] - public void Test_792() - { - } - [TestMethod] - public void Test_793() - { - } - [TestMethod] - public void Test_794() - { - } - [TestMethod] - public void Test_795() - { - } - [TestMethod] - public void Test_796() - { - } - [TestMethod] - public void Test_797() - { - } - [TestMethod] - public void Test_798() - { - } - [TestMethod] - public void Test_799() - { - } - [TestMethod] - public void Test_800() - { - } - [TestMethod] - public void Test_801() - { - } - [TestMethod] - public void Test_802() - { - } - [TestMethod] - public void Test_803() - { - } - [TestMethod] - public void Test_804() - { - } - [TestMethod] - public void Test_805() - { - } - [TestMethod] - public void Test_806() - { - } - [TestMethod] - public void Test_807() - { - } - [TestMethod] - public void Test_808() - { - } - [TestMethod] - public void Test_809() - { - } - [TestMethod] - public void Test_810() - { - } - [TestMethod] - public void Test_811() - { - } - [TestMethod] - public void Test_812() - { - } - [TestMethod] - public void Test_813() - { - } - [TestMethod] - public void Test_814() - { - } - [TestMethod] - public void Test_815() - { - } - [TestMethod] - public void Test_816() - { - } - [TestMethod] - public void Test_817() - { - } - [TestMethod] - public void Test_818() - { - } - [TestMethod] - public void Test_819() - { - } - [TestMethod] - public void Test_820() - { - } - [TestMethod] - public void Test_821() - { - } - [TestMethod] - public void Test_822() - { - } - [TestMethod] - public void Test_823() - { - } - [TestMethod] - public void Test_824() - { - } - [TestMethod] - public void Test_825() - { - } - [TestMethod] - public void Test_826() - { - } - [TestMethod] - public void Test_827() - { - } - [TestMethod] - public void Test_828() - { - } - [TestMethod] - public void Test_829() - { - } - [TestMethod] - public void Test_830() - { - } - [TestMethod] - public void Test_831() - { - } - [TestMethod] - public void Test_832() - { - } - [TestMethod] - public void Test_833() - { - } - [TestMethod] - public void Test_834() - { - } - [TestMethod] - public void Test_835() - { - } - [TestMethod] - public void Test_836() - { - } - [TestMethod] - public void Test_837() - { - } - [TestMethod] - public void Test_838() - { - } - [TestMethod] - public void Test_839() - { - } - [TestMethod] - public void Test_840() - { - } - [TestMethod] - public void Test_841() - { - } - [TestMethod] - public void Test_842() - { - } - [TestMethod] - public void Test_843() - { - } - [TestMethod] - public void Test_844() - { - } - [TestMethod] - public void Test_845() - { - } - [TestMethod] - public void Test_846() - { - } - [TestMethod] - public void Test_847() - { - } - [TestMethod] - public void Test_848() - { - } - [TestMethod] - public void Test_849() - { - } - [TestMethod] - public void Test_850() - { - } - [TestMethod] - public void Test_851() - { - } - [TestMethod] - public void Test_852() - { - } - [TestMethod] - public void Test_853() - { - } - [TestMethod] - public void Test_854() - { - } - [TestMethod] - public void Test_855() - { - } - [TestMethod] - public void Test_856() - { - } - [TestMethod] - public void Test_857() - { - } - [TestMethod] - public void Test_858() - { - } - [TestMethod] - public void Test_859() - { - } - [TestMethod] - public void Test_860() - { - } - [TestMethod] - public void Test_861() - { - } - [TestMethod] - public void Test_862() - { - } - [TestMethod] - public void Test_863() - { - } - [TestMethod] - public void Test_864() - { - } - [TestMethod] - public void Test_865() - { - } - [TestMethod] - public void Test_866() - { - } - [TestMethod] - public void Test_867() - { - } - [TestMethod] - public void Test_868() - { - } - [TestMethod] - public void Test_869() - { - } - [TestMethod] - public void Test_870() - { - } - [TestMethod] - public void Test_871() - { - } - [TestMethod] - public void Test_872() - { - } - [TestMethod] - public void Test_873() - { - } - [TestMethod] - public void Test_874() - { - } - [TestMethod] - public void Test_875() - { - } - [TestMethod] - public void Test_876() - { - } - [TestMethod] - public void Test_877() - { - } - [TestMethod] - public void Test_878() - { - } - [TestMethod] - public void Test_879() - { - } - [TestMethod] - public void Test_880() - { - } - [TestMethod] - public void Test_881() - { - } - [TestMethod] - public void Test_882() - { - } - [TestMethod] - public void Test_883() - { - } - [TestMethod] - public void Test_884() - { - } - [TestMethod] - public void Test_885() - { - } - [TestMethod] - public void Test_886() - { - } - [TestMethod] - public void Test_887() - { - } - [TestMethod] - public void Test_888() - { - } - [TestMethod] - public void Test_889() - { - } - [TestMethod] - public void Test_890() - { - } - [TestMethod] - public void Test_891() - { - } - [TestMethod] - public void Test_892() - { - } - [TestMethod] - public void Test_893() - { - } - [TestMethod] - public void Test_894() - { - } - [TestMethod] - public void Test_895() - { - } - [TestMethod] - public void Test_896() - { - } - [TestMethod] - public void Test_897() - { - } - [TestMethod] - public void Test_898() - { - } - [TestMethod] - public void Test_899() - { - } - [TestMethod] - public void Test_900() - { - } - [TestMethod] - public void Test_901() - { - } - [TestMethod] - public void Test_902() - { - } - [TestMethod] - public void Test_903() - { - } - [TestMethod] - public void Test_904() - { - } - [TestMethod] - public void Test_905() - { - } - [TestMethod] - public void Test_906() - { - } - [TestMethod] - public void Test_907() - { - } - [TestMethod] - public void Test_908() - { - } - [TestMethod] - public void Test_909() - { - } - [TestMethod] - public void Test_910() - { - } - [TestMethod] - public void Test_911() - { - } - [TestMethod] - public void Test_912() - { - } - [TestMethod] - public void Test_913() - { - } - [TestMethod] - public void Test_914() - { - } - [TestMethod] - public void Test_915() - { - } - [TestMethod] - public void Test_916() - { - } - [TestMethod] - public void Test_917() - { - } - [TestMethod] - public void Test_918() - { - } - [TestMethod] - public void Test_919() - { - } - [TestMethod] - public void Test_920() - { - } - [TestMethod] - public void Test_921() - { - } - [TestMethod] - public void Test_922() - { - } - [TestMethod] - public void Test_923() - { - } - [TestMethod] - public void Test_924() - { - } - [TestMethod] - public void Test_925() - { - } - [TestMethod] - public void Test_926() - { - } - [TestMethod] - public void Test_927() - { - } - [TestMethod] - public void Test_928() - { - } - [TestMethod] - public void Test_929() - { - } - [TestMethod] - public void Test_930() - { - } - [TestMethod] - public void Test_931() - { - } - [TestMethod] - public void Test_932() - { - } - [TestMethod] - public void Test_933() - { - } - [TestMethod] - public void Test_934() - { - } - [TestMethod] - public void Test_935() - { - } - [TestMethod] - public void Test_936() - { - } - [TestMethod] - public void Test_937() - { - } - [TestMethod] - public void Test_938() - { - } - [TestMethod] - public void Test_939() - { - } - [TestMethod] - public void Test_940() - { - } - [TestMethod] - public void Test_941() - { - } - [TestMethod] - public void Test_942() - { - } - [TestMethod] - public void Test_943() - { - } - [TestMethod] - public void Test_944() - { - } - [TestMethod] - public void Test_945() - { - } - [TestMethod] - public void Test_946() - { - } - [TestMethod] - public void Test_947() - { - } - [TestMethod] - public void Test_948() - { - } - [TestMethod] - public void Test_949() - { - } - [TestMethod] - public void Test_950() - { - } - [TestMethod] - public void Test_951() - { - } - [TestMethod] - public void Test_952() - { - } - [TestMethod] - public void Test_953() - { - } - [TestMethod] - public void Test_954() - { - } - [TestMethod] - public void Test_955() - { - } - [TestMethod] - public void Test_956() - { - } - [TestMethod] - public void Test_957() - { - } - [TestMethod] - public void Test_958() - { - } - [TestMethod] - public void Test_959() - { - } - [TestMethod] - public void Test_960() - { - } - [TestMethod] - public void Test_961() - { - } - [TestMethod] - public void Test_962() - { - } - [TestMethod] - public void Test_963() - { - } - [TestMethod] - public void Test_964() - { - } - [TestMethod] - public void Test_965() - { - } - [TestMethod] - public void Test_966() - { - } - [TestMethod] - public void Test_967() - { - } - [TestMethod] - public void Test_968() - { - } - [TestMethod] - public void Test_969() - { - } - [TestMethod] - public void Test_970() - { - } - [TestMethod] - public void Test_971() - { - } - [TestMethod] - public void Test_972() - { - } - [TestMethod] - public void Test_973() - { - } - [TestMethod] - public void Test_974() - { - } - [TestMethod] - public void Test_975() - { - } - [TestMethod] - public void Test_976() - { - } - [TestMethod] - public void Test_977() - { - } - [TestMethod] - public void Test_978() - { - } - [TestMethod] - public void Test_979() - { - } - [TestMethod] - public void Test_980() - { - } - [TestMethod] - public void Test_981() - { - } - [TestMethod] - public void Test_982() - { - } - [TestMethod] - public void Test_983() - { - } - [TestMethod] - public void Test_984() - { - } - [TestMethod] - public void Test_985() - { - } - [TestMethod] - public void Test_986() - { - } - [TestMethod] - public void Test_987() - { - } - [TestMethod] - public void Test_988() - { - } - [TestMethod] - public void Test_989() - { - } - [TestMethod] - public void Test_990() - { - } - [TestMethod] - public void Test_991() - { - } - [TestMethod] - public void Test_992() - { - } - [TestMethod] - public void Test_993() - { - } - [TestMethod] - public void Test_994() - { - } - [TestMethod] - public void Test_995() - { - } - [TestMethod] - public void Test_996() - { - } - [TestMethod] - public void Test_997() - { - } - [TestMethod] - public void Test_998() - { - } - [TestMethod] - public void Test_999() - { - } - [TestMethod] - public void Test_1000() - { - } - [TestMethod] - public void Test_1001() - { - } - [TestMethod] - public void Test_1002() - { - } - [TestMethod] - public void Test_1003() - { - } - [TestMethod] - public void Test_1004() - { - } - [TestMethod] - public void Test_1005() - { - } - [TestMethod] - public void Test_1006() - { - } - [TestMethod] - public void Test_1007() - { - } - [TestMethod] - public void Test_1008() - { - } - [TestMethod] - public void Test_1009() - { - } - [TestMethod] - public void Test_1010() - { - } - [TestMethod] - public void Test_1011() - { - } - [TestMethod] - public void Test_1012() - { - } - [TestMethod] - public void Test_1013() - { - } - [TestMethod] - public void Test_1014() - { - } - [TestMethod] - public void Test_1015() - { - } - [TestMethod] - public void Test_1016() - { - } - [TestMethod] - public void Test_1017() - { - } - [TestMethod] - public void Test_1018() - { - } - [TestMethod] - public void Test_1019() - { - } - [TestMethod] - public void Test_1020() - { - } - [TestMethod] - public void Test_1021() - { - } - [TestMethod] - public void Test_1022() - { - } - [TestMethod] - public void Test_1023() - { - } - [TestMethod] - public void Test_1024() - { - } - [TestMethod] - public void Test_1025() - { - } - [TestMethod] - public void Test_1026() - { - } - [TestMethod] - public void Test_1027() - { - } - [TestMethod] - public void Test_1028() - { - } - [TestMethod] - public void Test_1029() - { - } - [TestMethod] - public void Test_1030() - { - } - [TestMethod] - public void Test_1031() - { - } - [TestMethod] - public void Test_1032() - { - } - [TestMethod] - public void Test_1033() - { - } - [TestMethod] - public void Test_1034() - { - } - [TestMethod] - public void Test_1035() - { - } - [TestMethod] - public void Test_1036() - { - } - [TestMethod] - public void Test_1037() - { - } - [TestMethod] - public void Test_1038() - { - } - [TestMethod] - public void Test_1039() - { - } - [TestMethod] - public void Test_1040() - { - } - [TestMethod] - public void Test_1041() - { - } - [TestMethod] - public void Test_1042() - { - } - [TestMethod] - public void Test_1043() - { - } - [TestMethod] - public void Test_1044() - { - } - [TestMethod] - public void Test_1045() - { - } - [TestMethod] - public void Test_1046() - { - } - [TestMethod] - public void Test_1047() - { - } - [TestMethod] - public void Test_1048() - { - } - [TestMethod] - public void Test_1049() - { - } - [TestMethod] - public void Test_1050() - { - } - [TestMethod] - public void Test_1051() - { - } - [TestMethod] - public void Test_1052() - { - } - [TestMethod] - public void Test_1053() - { - } - [TestMethod] - public void Test_1054() - { - } - [TestMethod] - public void Test_1055() - { - } - [TestMethod] - public void Test_1056() - { - } - [TestMethod] - public void Test_1057() - { - } - [TestMethod] - public void Test_1058() - { - } - [TestMethod] - public void Test_1059() - { - } - [TestMethod] - public void Test_1060() - { - } - [TestMethod] - public void Test_1061() - { - } - [TestMethod] - public void Test_1062() - { - } - [TestMethod] - public void Test_1063() - { - } - [TestMethod] - public void Test_1064() - { - } - [TestMethod] - public void Test_1065() - { - } - [TestMethod] - public void Test_1066() - { - } - [TestMethod] - public void Test_1067() - { - } - [TestMethod] - public void Test_1068() - { - } - [TestMethod] - public void Test_1069() - { - } - [TestMethod] - public void Test_1070() - { - } - [TestMethod] - public void Test_1071() - { - } - [TestMethod] - public void Test_1072() - { - } - [TestMethod] - public void Test_1073() - { - } - [TestMethod] - public void Test_1074() - { - } - [TestMethod] - public void Test_1075() - { - } - [TestMethod] - public void Test_1076() - { - } - [TestMethod] - public void Test_1077() - { - } - [TestMethod] - public void Test_1078() - { - } - [TestMethod] - public void Test_1079() - { - } - [TestMethod] - public void Test_1080() - { - } - [TestMethod] - public void Test_1081() - { - } - [TestMethod] - public void Test_1082() - { - } - [TestMethod] - public void Test_1083() - { - } - [TestMethod] - public void Test_1084() - { - } - [TestMethod] - public void Test_1085() - { - } - [TestMethod] - public void Test_1086() - { - } - [TestMethod] - public void Test_1087() - { - } - [TestMethod] - public void Test_1088() - { - } - [TestMethod] - public void Test_1089() - { - } - [TestMethod] - public void Test_1090() - { - } - [TestMethod] - public void Test_1091() - { - } - [TestMethod] - public void Test_1092() - { - } - [TestMethod] - public void Test_1093() - { - } - [TestMethod] - public void Test_1094() - { - } - [TestMethod] - public void Test_1095() - { - } - [TestMethod] - public void Test_1096() - { - } - [TestMethod] - public void Test_1097() - { - } - [TestMethod] - public void Test_1098() - { - } - [TestMethod] - public void Test_1099() - { - } - [TestMethod] - public void Test_1100() - { - } - [TestMethod] - public void Test_1101() - { - } - [TestMethod] - public void Test_1102() - { - } - [TestMethod] - public void Test_1103() - { - } - [TestMethod] - public void Test_1104() - { - } - [TestMethod] - public void Test_1105() - { - } - [TestMethod] - public void Test_1106() - { - } - [TestMethod] - public void Test_1107() - { - } - [TestMethod] - public void Test_1108() - { - } - [TestMethod] - public void Test_1109() - { - } - [TestMethod] - public void Test_1110() - { - } - [TestMethod] - public void Test_1111() - { - } - [TestMethod] - public void Test_1112() - { - } - [TestMethod] - public void Test_1113() - { - } - [TestMethod] - public void Test_1114() - { - } - [TestMethod] - public void Test_1115() - { - } - [TestMethod] - public void Test_1116() - { - } - [TestMethod] - public void Test_1117() - { - } - [TestMethod] - public void Test_1118() - { - } - [TestMethod] - public void Test_1119() - { - } - [TestMethod] - public void Test_1120() - { - } - [TestMethod] - public void Test_1121() - { - } - [TestMethod] - public void Test_1122() - { - } - [TestMethod] - public void Test_1123() - { - } - [TestMethod] - public void Test_1124() - { - } - [TestMethod] - public void Test_1125() - { - } - [TestMethod] - public void Test_1126() - { - } - [TestMethod] - public void Test_1127() - { - } - [TestMethod] - public void Test_1128() - { - } - [TestMethod] - public void Test_1129() - { - } - [TestMethod] - public void Test_1130() - { - } - [TestMethod] - public void Test_1131() - { - } - [TestMethod] - public void Test_1132() - { - } - [TestMethod] - public void Test_1133() - { - } - [TestMethod] - public void Test_1134() - { - } - [TestMethod] - public void Test_1135() - { - } - [TestMethod] - public void Test_1136() - { - } - [TestMethod] - public void Test_1137() - { - } - [TestMethod] - public void Test_1138() - { - } - [TestMethod] - public void Test_1139() - { - } - [TestMethod] - public void Test_1140() - { - } - [TestMethod] - public void Test_1141() - { - } - [TestMethod] - public void Test_1142() - { - } - [TestMethod] - public void Test_1143() - { - } - [TestMethod] - public void Test_1144() - { - } - [TestMethod] - public void Test_1145() - { - } - [TestMethod] - public void Test_1146() - { - } - [TestMethod] - public void Test_1147() - { - } - [TestMethod] - public void Test_1148() - { - } - [TestMethod] - public void Test_1149() - { - } - [TestMethod] - public void Test_1150() - { - } - [TestMethod] - public void Test_1151() - { - } - [TestMethod] - public void Test_1152() - { - } - [TestMethod] - public void Test_1153() - { - } - [TestMethod] - public void Test_1154() - { - } - [TestMethod] - public void Test_1155() - { - } - [TestMethod] - public void Test_1156() - { - } - [TestMethod] - public void Test_1157() - { - } - [TestMethod] - public void Test_1158() - { - } - [TestMethod] - public void Test_1159() - { - } - [TestMethod] - public void Test_1160() - { - } - [TestMethod] - public void Test_1161() - { - } - [TestMethod] - public void Test_1162() - { - } - [TestMethod] - public void Test_1163() - { - } - [TestMethod] - public void Test_1164() - { - } - [TestMethod] - public void Test_1165() - { - } - [TestMethod] - public void Test_1166() - { - } - [TestMethod] - public void Test_1167() - { - } - [TestMethod] - public void Test_1168() - { - } - [TestMethod] - public void Test_1169() - { - } - [TestMethod] - public void Test_1170() - { - } - [TestMethod] - public void Test_1171() - { - } - [TestMethod] - public void Test_1172() - { - } - [TestMethod] - public void Test_1173() - { - } - [TestMethod] - public void Test_1174() - { - } - [TestMethod] - public void Test_1175() - { - } - [TestMethod] - public void Test_1176() - { - } - [TestMethod] - public void Test_1177() - { - } - [TestMethod] - public void Test_1178() - { - } - [TestMethod] - public void Test_1179() - { - } - [TestMethod] - public void Test_1180() - { - } - [TestMethod] - public void Test_1181() - { - } - [TestMethod] - public void Test_1182() - { - } - [TestMethod] - public void Test_1183() - { - } - [TestMethod] - public void Test_1184() - { - } - [TestMethod] - public void Test_1185() - { - } - [TestMethod] - public void Test_1186() - { - } - [TestMethod] - public void Test_1187() - { - } - [TestMethod] - public void Test_1188() - { - } - [TestMethod] - public void Test_1189() - { - } - [TestMethod] - public void Test_1190() - { - } - [TestMethod] - public void Test_1191() - { - } - [TestMethod] - public void Test_1192() - { - } - [TestMethod] - public void Test_1193() - { - } - [TestMethod] - public void Test_1194() - { - } - [TestMethod] - public void Test_1195() - { - } - [TestMethod] - public void Test_1196() - { - } - [TestMethod] - public void Test_1197() - { - } - [TestMethod] - public void Test_1198() - { - } - [TestMethod] - public void Test_1199() - { - } - [TestMethod] - public void Test_1200() - { - } - [TestMethod] - public void Test_1201() - { - } - [TestMethod] - public void Test_1202() - { - } - [TestMethod] - public void Test_1203() - { - } - [TestMethod] - public void Test_1204() - { - } - [TestMethod] - public void Test_1205() - { - } - [TestMethod] - public void Test_1206() - { - } - [TestMethod] - public void Test_1207() - { - } - [TestMethod] - public void Test_1208() - { - } - [TestMethod] - public void Test_1209() - { - } - [TestMethod] - public void Test_1210() - { - } - [TestMethod] - public void Test_1211() - { - } - [TestMethod] - public void Test_1212() - { - } - [TestMethod] - public void Test_1213() - { - } - [TestMethod] - public void Test_1214() - { - } - [TestMethod] - public void Test_1215() - { - } - [TestMethod] - public void Test_1216() - { - } - [TestMethod] - public void Test_1217() - { - } - [TestMethod] - public void Test_1218() - { - } - [TestMethod] - public void Test_1219() - { - } - [TestMethod] - public void Test_1220() - { - } - [TestMethod] - public void Test_1221() - { - } - [TestMethod] - public void Test_1222() - { - } - [TestMethod] - public void Test_1223() - { - } - [TestMethod] - public void Test_1224() - { - } - [TestMethod] - public void Test_1225() - { - } - [TestMethod] - public void Test_1226() - { - } - [TestMethod] - public void Test_1227() - { - } - [TestMethod] - public void Test_1228() - { - } - [TestMethod] - public void Test_1229() - { - } - [TestMethod] - public void Test_1230() - { - } - [TestMethod] - public void Test_1231() - { - } - [TestMethod] - public void Test_1232() - { - } - [TestMethod] - public void Test_1233() - { - } - [TestMethod] - public void Test_1234() - { - } - [TestMethod] - public void Test_1235() - { - } - [TestMethod] - public void Test_1236() - { - } - [TestMethod] - public void Test_1237() - { - } - [TestMethod] - public void Test_1238() - { - } - [TestMethod] - public void Test_1239() - { - } - [TestMethod] - public void Test_1240() - { - } - [TestMethod] - public void Test_1241() - { - } - [TestMethod] - public void Test_1242() - { - } - [TestMethod] - public void Test_1243() - { - } - [TestMethod] - public void Test_1244() - { - } - [TestMethod] - public void Test_1245() - { - } - [TestMethod] - public void Test_1246() - { - } - [TestMethod] - public void Test_1247() - { - } - [TestMethod] - public void Test_1248() - { - } - [TestMethod] - public void Test_1249() - { - } - [TestMethod] - public void Test_1250() - { - } - [TestMethod] - public void Test_1251() - { - } - [TestMethod] - public void Test_1252() - { - } - [TestMethod] - public void Test_1253() - { - } - [TestMethod] - public void Test_1254() - { - } - [TestMethod] - public void Test_1255() - { - } - [TestMethod] - public void Test_1256() - { - } - [TestMethod] - public void Test_1257() - { - } - [TestMethod] - public void Test_1258() - { - } - [TestMethod] - public void Test_1259() - { - } - [TestMethod] - public void Test_1260() - { - } - [TestMethod] - public void Test_1261() - { - } - [TestMethod] - public void Test_1262() - { - } - [TestMethod] - public void Test_1263() - { - } - [TestMethod] - public void Test_1264() - { - } - [TestMethod] - public void Test_1265() - { - } - [TestMethod] - public void Test_1266() - { - } - [TestMethod] - public void Test_1267() - { - } - [TestMethod] - public void Test_1268() - { - } - [TestMethod] - public void Test_1269() - { - } - [TestMethod] - public void Test_1270() - { - } - [TestMethod] - public void Test_1271() - { - } - [TestMethod] - public void Test_1272() - { - } - [TestMethod] - public void Test_1273() - { - } - [TestMethod] - public void Test_1274() - { - } - [TestMethod] - public void Test_1275() - { - } - [TestMethod] - public void Test_1276() - { - } - [TestMethod] - public void Test_1277() - { - } - [TestMethod] - public void Test_1278() - { - } - [TestMethod] - public void Test_1279() - { - } - [TestMethod] - public void Test_1280() - { - } - [TestMethod] - public void Test_1281() - { - } - [TestMethod] - public void Test_1282() - { - } - [TestMethod] - public void Test_1283() - { - } - [TestMethod] - public void Test_1284() - { - } - [TestMethod] - public void Test_1285() - { - } - [TestMethod] - public void Test_1286() - { - } - [TestMethod] - public void Test_1287() - { - } - [TestMethod] - public void Test_1288() - { - } - [TestMethod] - public void Test_1289() - { - } - [TestMethod] - public void Test_1290() - { - } - [TestMethod] - public void Test_1291() - { - } - [TestMethod] - public void Test_1292() - { - } - [TestMethod] - public void Test_1293() - { - } - [TestMethod] - public void Test_1294() - { - } - [TestMethod] - public void Test_1295() - { - } - [TestMethod] - public void Test_1296() - { - } - [TestMethod] - public void Test_1297() - { - } - [TestMethod] - public void Test_1298() - { - } - [TestMethod] - public void Test_1299() - { - } - [TestMethod] - public void Test_1300() - { - } - [TestMethod] - public void Test_1301() - { - } - [TestMethod] - public void Test_1302() - { - } - [TestMethod] - public void Test_1303() - { - } - [TestMethod] - public void Test_1304() - { - } - [TestMethod] - public void Test_1305() - { - } - [TestMethod] - public void Test_1306() - { - } - [TestMethod] - public void Test_1307() - { - } - [TestMethod] - public void Test_1308() - { - } - [TestMethod] - public void Test_1309() - { - } - [TestMethod] - public void Test_1310() - { - } - [TestMethod] - public void Test_1311() - { - } - [TestMethod] - public void Test_1312() - { - } - [TestMethod] - public void Test_1313() - { - } - [TestMethod] - public void Test_1314() - { - } - [TestMethod] - public void Test_1315() - { - } - [TestMethod] - public void Test_1316() - { - } - [TestMethod] - public void Test_1317() - { - } - [TestMethod] - public void Test_1318() - { - } - [TestMethod] - public void Test_1319() - { - } - [TestMethod] - public void Test_1320() - { - } - [TestMethod] - public void Test_1321() - { - } - [TestMethod] - public void Test_1322() - { - } - [TestMethod] - public void Test_1323() - { - } - [TestMethod] - public void Test_1324() - { - } - [TestMethod] - public void Test_1325() - { - } - [TestMethod] - public void Test_1326() - { - } - [TestMethod] - public void Test_1327() - { - } - [TestMethod] - public void Test_1328() - { - } - [TestMethod] - public void Test_1329() - { - } - [TestMethod] - public void Test_1330() - { - } - [TestMethod] - public void Test_1331() - { - } - [TestMethod] - public void Test_1332() - { - } - [TestMethod] - public void Test_1333() - { - } - [TestMethod] - public void Test_1334() - { - } - [TestMethod] - public void Test_1335() - { - } - [TestMethod] - public void Test_1336() - { - } - [TestMethod] - public void Test_1337() - { - } - [TestMethod] - public void Test_1338() - { - } - [TestMethod] - public void Test_1339() - { - } - [TestMethod] - public void Test_1340() - { - } - [TestMethod] - public void Test_1341() - { - } - [TestMethod] - public void Test_1342() - { - } - [TestMethod] - public void Test_1343() - { - } - [TestMethod] - public void Test_1344() - { - } - [TestMethod] - public void Test_1345() - { - } - [TestMethod] - public void Test_1346() - { - } - [TestMethod] - public void Test_1347() - { - } - [TestMethod] - public void Test_1348() - { - } - [TestMethod] - public void Test_1349() - { - } - [TestMethod] - public void Test_1350() - { - } - [TestMethod] - public void Test_1351() - { - } - [TestMethod] - public void Test_1352() - { - } - [TestMethod] - public void Test_1353() - { - } - [TestMethod] - public void Test_1354() - { - } - [TestMethod] - public void Test_1355() - { - } - [TestMethod] - public void Test_1356() - { - } - [TestMethod] - public void Test_1357() - { - } - [TestMethod] - public void Test_1358() - { - } - [TestMethod] - public void Test_1359() - { - } - [TestMethod] - public void Test_1360() - { - } - [TestMethod] - public void Test_1361() - { - } - [TestMethod] - public void Test_1362() - { - } - [TestMethod] - public void Test_1363() - { - } - [TestMethod] - public void Test_1364() - { - } - [TestMethod] - public void Test_1365() - { - } - [TestMethod] - public void Test_1366() - { - } - [TestMethod] - public void Test_1367() - { - } - [TestMethod] - public void Test_1368() - { - } - [TestMethod] - public void Test_1369() - { - } - [TestMethod] - public void Test_1370() - { - } - [TestMethod] - public void Test_1371() - { - } - [TestMethod] - public void Test_1372() - { - } - [TestMethod] - public void Test_1373() - { - } - [TestMethod] - public void Test_1374() - { - } - [TestMethod] - public void Test_1375() - { - } - [TestMethod] - public void Test_1376() - { - } - [TestMethod] - public void Test_1377() - { - } - [TestMethod] - public void Test_1378() - { - } - [TestMethod] - public void Test_1379() - { - } - [TestMethod] - public void Test_1380() - { - } - [TestMethod] - public void Test_1381() - { - } - [TestMethod] - public void Test_1382() - { - } - [TestMethod] - public void Test_1383() - { - } - [TestMethod] - public void Test_1384() - { - } - [TestMethod] - public void Test_1385() - { - } - [TestMethod] - public void Test_1386() - { - } - [TestMethod] - public void Test_1387() - { - } - [TestMethod] - public void Test_1388() - { - } - [TestMethod] - public void Test_1389() - { - } - [TestMethod] - public void Test_1390() - { - } - [TestMethod] - public void Test_1391() - { - } - [TestMethod] - public void Test_1392() - { - } - [TestMethod] - public void Test_1393() - { - } - [TestMethod] - public void Test_1394() - { - } - [TestMethod] - public void Test_1395() - { - } - [TestMethod] - public void Test_1396() - { - } - [TestMethod] - public void Test_1397() - { - } - [TestMethod] - public void Test_1398() - { - } - [TestMethod] - public void Test_1399() - { - } - [TestMethod] - public void Test_1400() - { - } - [TestMethod] - public void Test_1401() - { - } - [TestMethod] - public void Test_1402() - { - } - [TestMethod] - public void Test_1403() - { - } - [TestMethod] - public void Test_1404() - { - } - [TestMethod] - public void Test_1405() - { - } - [TestMethod] - public void Test_1406() - { - } - [TestMethod] - public void Test_1407() - { - } - [TestMethod] - public void Test_1408() - { - } - [TestMethod] - public void Test_1409() - { - } - [TestMethod] - public void Test_1410() - { - } - [TestMethod] - public void Test_1411() - { - } - [TestMethod] - public void Test_1412() - { - } - [TestMethod] - public void Test_1413() - { - } - [TestMethod] - public void Test_1414() - { - } - [TestMethod] - public void Test_1415() - { - } - [TestMethod] - public void Test_1416() - { - } - [TestMethod] - public void Test_1417() - { - } - [TestMethod] - public void Test_1418() - { - } - [TestMethod] - public void Test_1419() - { - } - [TestMethod] - public void Test_1420() - { - } - [TestMethod] - public void Test_1421() - { - } - [TestMethod] - public void Test_1422() - { - } - [TestMethod] - public void Test_1423() - { - } - [TestMethod] - public void Test_1424() - { - } - [TestMethod] - public void Test_1425() - { - } - [TestMethod] - public void Test_1426() - { - } - [TestMethod] - public void Test_1427() - { - } - [TestMethod] - public void Test_1428() - { - } - [TestMethod] - public void Test_1429() - { - } - [TestMethod] - public void Test_1430() - { - } - [TestMethod] - public void Test_1431() - { - } - [TestMethod] - public void Test_1432() - { - } - [TestMethod] - public void Test_1433() - { - } - [TestMethod] - public void Test_1434() - { - } - [TestMethod] - public void Test_1435() - { - } - [TestMethod] - public void Test_1436() - { - } - [TestMethod] - public void Test_1437() - { - } - [TestMethod] - public void Test_1438() - { - } - [TestMethod] - public void Test_1439() - { - } - [TestMethod] - public void Test_1440() - { - } - [TestMethod] - public void Test_1441() - { - } - [TestMethod] - public void Test_1442() - { - } - [TestMethod] - public void Test_1443() - { - } - [TestMethod] - public void Test_1444() - { - } - [TestMethod] - public void Test_1445() - { - } - [TestMethod] - public void Test_1446() - { - } - [TestMethod] - public void Test_1447() - { - } - [TestMethod] - public void Test_1448() - { - } - [TestMethod] - public void Test_1449() - { - } - [TestMethod] - public void Test_1450() - { - } - [TestMethod] - public void Test_1451() - { - } - [TestMethod] - public void Test_1452() - { - } - [TestMethod] - public void Test_1453() - { - } - [TestMethod] - public void Test_1454() - { - } - [TestMethod] - public void Test_1455() - { - } - [TestMethod] - public void Test_1456() - { - } - [TestMethod] - public void Test_1457() - { - } - [TestMethod] - public void Test_1458() - { - } - [TestMethod] - public void Test_1459() - { - } - [TestMethod] - public void Test_1460() - { - } - [TestMethod] - public void Test_1461() - { - } - [TestMethod] - public void Test_1462() - { - } - [TestMethod] - public void Test_1463() - { - } - [TestMethod] - public void Test_1464() - { - } - [TestMethod] - public void Test_1465() - { - } - [TestMethod] - public void Test_1466() - { - } - [TestMethod] - public void Test_1467() - { - } - [TestMethod] - public void Test_1468() - { - } - [TestMethod] - public void Test_1469() - { - } - [TestMethod] - public void Test_1470() - { - } - [TestMethod] - public void Test_1471() - { - } - [TestMethod] - public void Test_1472() - { - } - [TestMethod] - public void Test_1473() - { - } - [TestMethod] - public void Test_1474() - { - } - [TestMethod] - public void Test_1475() - { - } - [TestMethod] - public void Test_1476() - { - } - [TestMethod] - public void Test_1477() - { - } - [TestMethod] - public void Test_1478() - { - } - [TestMethod] - public void Test_1479() - { - } - [TestMethod] - public void Test_1480() - { - } - [TestMethod] - public void Test_1481() - { - } - [TestMethod] - public void Test_1482() - { - } - [TestMethod] - public void Test_1483() - { - } - [TestMethod] - public void Test_1484() - { - } - [TestMethod] - public void Test_1485() - { - } - [TestMethod] - public void Test_1486() - { - } - [TestMethod] - public void Test_1487() - { - } - [TestMethod] - public void Test_1488() - { - } - [TestMethod] - public void Test_1489() - { - } - [TestMethod] - public void Test_1490() - { - } - [TestMethod] - public void Test_1491() - { - } - [TestMethod] - public void Test_1492() - { - } - [TestMethod] - public void Test_1493() - { - } - [TestMethod] - public void Test_1494() - { - } - [TestMethod] - public void Test_1495() - { - } - [TestMethod] - public void Test_1496() - { - } - [TestMethod] - public void Test_1497() - { - } - [TestMethod] - public void Test_1498() - { - } - [TestMethod] - public void Test_1499() - { - } - [TestMethod] - public void Test_1500() - { - } - [TestMethod] - public void Test_1501() - { - } - [TestMethod] - public void Test_1502() - { - } - [TestMethod] - public void Test_1503() - { - } - [TestMethod] - public void Test_1504() - { - } - [TestMethod] - public void Test_1505() - { - } - [TestMethod] - public void Test_1506() - { - } - [TestMethod] - public void Test_1507() - { - } - [TestMethod] - public void Test_1508() - { - } - [TestMethod] - public void Test_1509() - { - } - [TestMethod] - public void Test_1510() - { - } - [TestMethod] - public void Test_1511() - { - } - [TestMethod] - public void Test_1512() - { - } - [TestMethod] - public void Test_1513() - { - } - [TestMethod] - public void Test_1514() - { - } - [TestMethod] - public void Test_1515() - { - } - [TestMethod] - public void Test_1516() - { - } - [TestMethod] - public void Test_1517() - { - } - [TestMethod] - public void Test_1518() - { - } - [TestMethod] - public void Test_1519() - { - } - [TestMethod] - public void Test_1520() - { - } - [TestMethod] - public void Test_1521() - { - } - [TestMethod] - public void Test_1522() - { - } - [TestMethod] - public void Test_1523() - { - } - [TestMethod] - public void Test_1524() - { - } - [TestMethod] - public void Test_1525() - { - } - [TestMethod] - public void Test_1526() - { - } - [TestMethod] - public void Test_1527() - { - } - [TestMethod] - public void Test_1528() - { - } - [TestMethod] - public void Test_1529() - { - } - [TestMethod] - public void Test_1530() - { - } - [TestMethod] - public void Test_1531() - { - } - [TestMethod] - public void Test_1532() - { - } - [TestMethod] - public void Test_1533() - { - } - [TestMethod] - public void Test_1534() - { - } - [TestMethod] - public void Test_1535() - { - } - [TestMethod] - public void Test_1536() - { - } - [TestMethod] - public void Test_1537() - { - } - [TestMethod] - public void Test_1538() - { - } - [TestMethod] - public void Test_1539() - { - } - [TestMethod] - public void Test_1540() - { - } - [TestMethod] - public void Test_1541() - { - } - [TestMethod] - public void Test_1542() - { - } - [TestMethod] - public void Test_1543() - { - } - [TestMethod] - public void Test_1544() - { - } - [TestMethod] - public void Test_1545() - { - } - [TestMethod] - public void Test_1546() - { - } - [TestMethod] - public void Test_1547() - { - } - [TestMethod] - public void Test_1548() - { - } - [TestMethod] - public void Test_1549() - { - } - [TestMethod] - public void Test_1550() - { - } - [TestMethod] - public void Test_1551() - { - } - [TestMethod] - public void Test_1552() - { - } - [TestMethod] - public void Test_1553() - { - } - [TestMethod] - public void Test_1554() - { - } - [TestMethod] - public void Test_1555() - { - } - [TestMethod] - public void Test_1556() - { - } - [TestMethod] - public void Test_1557() - { - } - [TestMethod] - public void Test_1558() - { - } - [TestMethod] - public void Test_1559() - { - } - [TestMethod] - public void Test_1560() - { - } - [TestMethod] - public void Test_1561() - { - } - [TestMethod] - public void Test_1562() - { - } - [TestMethod] - public void Test_1563() - { - } - [TestMethod] - public void Test_1564() - { - } - [TestMethod] - public void Test_1565() - { - } - [TestMethod] - public void Test_1566() - { - } - [TestMethod] - public void Test_1567() - { - } - [TestMethod] - public void Test_1568() - { - } - [TestMethod] - public void Test_1569() - { - } - [TestMethod] - public void Test_1570() - { - } - [TestMethod] - public void Test_1571() - { - } - [TestMethod] - public void Test_1572() - { - } - [TestMethod] - public void Test_1573() - { - } - [TestMethod] - public void Test_1574() - { - } - [TestMethod] - public void Test_1575() - { - } - [TestMethod] - public void Test_1576() - { - } - [TestMethod] - public void Test_1577() - { - } - [TestMethod] - public void Test_1578() - { - } - [TestMethod] - public void Test_1579() - { - } - [TestMethod] - public void Test_1580() - { - } - [TestMethod] - public void Test_1581() - { - } - [TestMethod] - public void Test_1582() - { - } - [TestMethod] - public void Test_1583() - { - } - [TestMethod] - public void Test_1584() - { - } - [TestMethod] - public void Test_1585() - { - } - [TestMethod] - public void Test_1586() - { - } - [TestMethod] - public void Test_1587() - { - } - [TestMethod] - public void Test_1588() - { - } - [TestMethod] - public void Test_1589() - { - } - [TestMethod] - public void Test_1590() - { - } - [TestMethod] - public void Test_1591() - { - } - [TestMethod] - public void Test_1592() - { - } - [TestMethod] - public void Test_1593() - { - } - [TestMethod] - public void Test_1594() - { - } - [TestMethod] - public void Test_1595() - { - } - [TestMethod] - public void Test_1596() - { - } - [TestMethod] - public void Test_1597() - { - } - [TestMethod] - public void Test_1598() - { - } - [TestMethod] - public void Test_1599() - { - } - [TestMethod] - public void Test_1600() - { - } - [TestMethod] - public void Test_1601() - { - } - [TestMethod] - public void Test_1602() - { - } - [TestMethod] - public void Test_1603() - { - } - [TestMethod] - public void Test_1604() - { - } - [TestMethod] - public void Test_1605() - { - } - [TestMethod] - public void Test_1606() - { - } - [TestMethod] - public void Test_1607() - { - } - [TestMethod] - public void Test_1608() - { - } - [TestMethod] - public void Test_1609() - { - } - [TestMethod] - public void Test_1610() - { - } - [TestMethod] - public void Test_1611() - { - } - [TestMethod] - public void Test_1612() - { - } - [TestMethod] - public void Test_1613() - { - } - [TestMethod] - public void Test_1614() - { - } - [TestMethod] - public void Test_1615() - { - } - [TestMethod] - public void Test_1616() - { - } - [TestMethod] - public void Test_1617() - { - } - [TestMethod] - public void Test_1618() - { - } - [TestMethod] - public void Test_1619() - { - } - [TestMethod] - public void Test_1620() - { - } - [TestMethod] - public void Test_1621() - { - } - [TestMethod] - public void Test_1622() - { - } - [TestMethod] - public void Test_1623() - { - } - [TestMethod] - public void Test_1624() - { - } - [TestMethod] - public void Test_1625() - { - } - [TestMethod] - public void Test_1626() - { - } - [TestMethod] - public void Test_1627() - { - } - [TestMethod] - public void Test_1628() - { - } - [TestMethod] - public void Test_1629() - { - } - [TestMethod] - public void Test_1630() - { - } - [TestMethod] - public void Test_1631() - { - } - [TestMethod] - public void Test_1632() - { - } - [TestMethod] - public void Test_1633() - { - } - [TestMethod] - public void Test_1634() - { - } - [TestMethod] - public void Test_1635() - { - } - [TestMethod] - public void Test_1636() - { - } - [TestMethod] - public void Test_1637() - { - } - [TestMethod] - public void Test_1638() - { - } - [TestMethod] - public void Test_1639() - { - } - [TestMethod] - public void Test_1640() - { - } - [TestMethod] - public void Test_1641() - { - } - [TestMethod] - public void Test_1642() - { - } - [TestMethod] - public void Test_1643() - { - } - [TestMethod] - public void Test_1644() - { - } - [TestMethod] - public void Test_1645() - { - } - [TestMethod] - public void Test_1646() - { - } - [TestMethod] - public void Test_1647() - { - } - [TestMethod] - public void Test_1648() - { - } - [TestMethod] - public void Test_1649() - { - } - [TestMethod] - public void Test_1650() - { - } - [TestMethod] - public void Test_1651() - { - } - [TestMethod] - public void Test_1652() - { - } - [TestMethod] - public void Test_1653() - { - } - [TestMethod] - public void Test_1654() - { - } - [TestMethod] - public void Test_1655() - { - } - [TestMethod] - public void Test_1656() - { - } - [TestMethod] - public void Test_1657() - { - } - [TestMethod] - public void Test_1658() - { - } - [TestMethod] - public void Test_1659() - { - } - [TestMethod] - public void Test_1660() - { - } - [TestMethod] - public void Test_1661() - { - } - [TestMethod] - public void Test_1662() - { - } - [TestMethod] - public void Test_1663() - { - } - [TestMethod] - public void Test_1664() - { - } - [TestMethod] - public void Test_1665() - { - } - [TestMethod] - public void Test_1666() - { - } - [TestMethod] - public void Test_1667() - { - } - [TestMethod] - public void Test_1668() - { - } - [TestMethod] - public void Test_1669() - { - } - [TestMethod] - public void Test_1670() - { - } - [TestMethod] - public void Test_1671() - { - } - [TestMethod] - public void Test_1672() - { - } - [TestMethod] - public void Test_1673() - { - } - [TestMethod] - public void Test_1674() - { - } - [TestMethod] - public void Test_1675() - { - } - [TestMethod] - public void Test_1676() - { - } - [TestMethod] - public void Test_1677() - { - } - [TestMethod] - public void Test_1678() - { - } - [TestMethod] - public void Test_1679() - { - } - [TestMethod] - public void Test_1680() - { - } - [TestMethod] - public void Test_1681() - { - } - [TestMethod] - public void Test_1682() - { - } - [TestMethod] - public void Test_1683() - { - } - [TestMethod] - public void Test_1684() - { - } - [TestMethod] - public void Test_1685() - { - } - [TestMethod] - public void Test_1686() - { - } - [TestMethod] - public void Test_1687() - { - } - [TestMethod] - public void Test_1688() - { - } - [TestMethod] - public void Test_1689() - { - } - [TestMethod] - public void Test_1690() - { - } - [TestMethod] - public void Test_1691() - { - } - [TestMethod] - public void Test_1692() - { - } - [TestMethod] - public void Test_1693() - { - } - [TestMethod] - public void Test_1694() - { - } - [TestMethod] - public void Test_1695() - { - } - [TestMethod] - public void Test_1696() - { - } - [TestMethod] - public void Test_1697() - { - } - [TestMethod] - public void Test_1698() - { - } - [TestMethod] - public void Test_1699() - { - } - [TestMethod] - public void Test_1700() - { - } - [TestMethod] - public void Test_1701() - { - } - [TestMethod] - public void Test_1702() - { - } - [TestMethod] - public void Test_1703() - { - } - [TestMethod] - public void Test_1704() - { - } - [TestMethod] - public void Test_1705() - { - } - [TestMethod] - public void Test_1706() - { - } - [TestMethod] - public void Test_1707() - { - } - [TestMethod] - public void Test_1708() - { - } - [TestMethod] - public void Test_1709() - { - } - [TestMethod] - public void Test_1710() - { - } - [TestMethod] - public void Test_1711() - { - } - [TestMethod] - public void Test_1712() - { - } - [TestMethod] - public void Test_1713() - { - } - [TestMethod] - public void Test_1714() - { - } - [TestMethod] - public void Test_1715() - { - } - [TestMethod] - public void Test_1716() - { - } - [TestMethod] - public void Test_1717() - { - } - [TestMethod] - public void Test_1718() - { - } - [TestMethod] - public void Test_1719() - { - } - [TestMethod] - public void Test_1720() - { - } - [TestMethod] - public void Test_1721() - { - } - [TestMethod] - public void Test_1722() - { - } - [TestMethod] - public void Test_1723() - { - } - [TestMethod] - public void Test_1724() - { - } - [TestMethod] - public void Test_1725() - { - } - [TestMethod] - public void Test_1726() - { - } - [TestMethod] - public void Test_1727() - { - } - [TestMethod] - public void Test_1728() - { - } - [TestMethod] - public void Test_1729() - { - } - [TestMethod] - public void Test_1730() - { - } - [TestMethod] - public void Test_1731() - { - } - [TestMethod] - public void Test_1732() - { - } - [TestMethod] - public void Test_1733() - { - } - [TestMethod] - public void Test_1734() - { - } - [TestMethod] - public void Test_1735() - { - } - [TestMethod] - public void Test_1736() - { - } - [TestMethod] - public void Test_1737() - { - } - [TestMethod] - public void Test_1738() - { - } - [TestMethod] - public void Test_1739() - { - } - [TestMethod] - public void Test_1740() - { - } - [TestMethod] - public void Test_1741() - { - } - [TestMethod] - public void Test_1742() - { - } - [TestMethod] - public void Test_1743() - { - } - [TestMethod] - public void Test_1744() - { - } - [TestMethod] - public void Test_1745() - { - } - [TestMethod] - public void Test_1746() - { - } - [TestMethod] - public void Test_1747() - { - } - [TestMethod] - public void Test_1748() - { - } - [TestMethod] - public void Test_1749() - { - } - [TestMethod] - public void Test_1750() - { - } - [TestMethod] - public void Test_1751() - { - } - [TestMethod] - public void Test_1752() - { - } - [TestMethod] - public void Test_1753() - { - } - [TestMethod] - public void Test_1754() - { - } - [TestMethod] - public void Test_1755() - { - } - [TestMethod] - public void Test_1756() - { - } - [TestMethod] - public void Test_1757() - { - } - [TestMethod] - public void Test_1758() - { - } - [TestMethod] - public void Test_1759() - { - } - [TestMethod] - public void Test_1760() - { - } - [TestMethod] - public void Test_1761() - { - } - [TestMethod] - public void Test_1762() - { - } - [TestMethod] - public void Test_1763() - { - } - [TestMethod] - public void Test_1764() - { - } - [TestMethod] - public void Test_1765() - { - } - [TestMethod] - public void Test_1766() - { - } - [TestMethod] - public void Test_1767() - { - } - [TestMethod] - public void Test_1768() - { - } - [TestMethod] - public void Test_1769() - { - } - [TestMethod] - public void Test_1770() - { - } - [TestMethod] - public void Test_1771() - { - } - [TestMethod] - public void Test_1772() - { - } - [TestMethod] - public void Test_1773() - { - } - [TestMethod] - public void Test_1774() - { - } - [TestMethod] - public void Test_1775() - { - } - [TestMethod] - public void Test_1776() - { - } - [TestMethod] - public void Test_1777() - { - } - [TestMethod] - public void Test_1778() - { - } - [TestMethod] - public void Test_1779() - { - } - [TestMethod] - public void Test_1780() - { - } - [TestMethod] - public void Test_1781() - { - } - [TestMethod] - public void Test_1782() - { - } - [TestMethod] - public void Test_1783() - { - } - [TestMethod] - public void Test_1784() - { - } - [TestMethod] - public void Test_1785() - { - } - [TestMethod] - public void Test_1786() - { - } - [TestMethod] - public void Test_1787() - { - } - [TestMethod] - public void Test_1788() - { - } - [TestMethod] - public void Test_1789() - { - } - [TestMethod] - public void Test_1790() - { - } - [TestMethod] - public void Test_1791() - { - } - [TestMethod] - public void Test_1792() - { - } - [TestMethod] - public void Test_1793() - { - } - [TestMethod] - public void Test_1794() - { - } - [TestMethod] - public void Test_1795() - { - } - [TestMethod] - public void Test_1796() - { - } - [TestMethod] - public void Test_1797() - { - } - [TestMethod] - public void Test_1798() - { - } - [TestMethod] - public void Test_1799() - { - } - [TestMethod] - public void Test_1800() - { - } - [TestMethod] - public void Test_1801() - { - } - [TestMethod] - public void Test_1802() - { - } - [TestMethod] - public void Test_1803() - { - } - [TestMethod] - public void Test_1804() - { - } - [TestMethod] - public void Test_1805() - { - } - [TestMethod] - public void Test_1806() - { - } - [TestMethod] - public void Test_1807() - { - } - [TestMethod] - public void Test_1808() - { - } - [TestMethod] - public void Test_1809() - { - } - [TestMethod] - public void Test_1810() - { - } - [TestMethod] - public void Test_1811() - { - } - [TestMethod] - public void Test_1812() - { - } - [TestMethod] - public void Test_1813() - { - } - [TestMethod] - public void Test_1814() - { - } - [TestMethod] - public void Test_1815() - { - } - [TestMethod] - public void Test_1816() - { - } - [TestMethod] - public void Test_1817() - { - } - [TestMethod] - public void Test_1818() - { - } - [TestMethod] - public void Test_1819() - { - } - [TestMethod] - public void Test_1820() - { - } - [TestMethod] - public void Test_1821() - { - } - [TestMethod] - public void Test_1822() - { - } - [TestMethod] - public void Test_1823() - { - } - [TestMethod] - public void Test_1824() - { - } - [TestMethod] - public void Test_1825() - { - } - [TestMethod] - public void Test_1826() - { - } - [TestMethod] - public void Test_1827() - { - } - [TestMethod] - public void Test_1828() - { - } - [TestMethod] - public void Test_1829() - { - } - [TestMethod] - public void Test_1830() - { - } - [TestMethod] - public void Test_1831() - { - } - [TestMethod] - public void Test_1832() - { - } - [TestMethod] - public void Test_1833() - { - } - [TestMethod] - public void Test_1834() - { - } - [TestMethod] - public void Test_1835() - { - } - [TestMethod] - public void Test_1836() - { - } - [TestMethod] - public void Test_1837() - { - } - [TestMethod] - public void Test_1838() - { - } - [TestMethod] - public void Test_1839() - { - } - [TestMethod] - public void Test_1840() - { - } - [TestMethod] - public void Test_1841() - { - } - [TestMethod] - public void Test_1842() - { - } - [TestMethod] - public void Test_1843() - { - } - [TestMethod] - public void Test_1844() - { - } - [TestMethod] - public void Test_1845() - { - } - [TestMethod] - public void Test_1846() - { - } - [TestMethod] - public void Test_1847() - { - } - [TestMethod] - public void Test_1848() - { - } - [TestMethod] - public void Test_1849() - { - } - [TestMethod] - public void Test_1850() - { - } - [TestMethod] - public void Test_1851() - { - } - [TestMethod] - public void Test_1852() - { - } - [TestMethod] - public void Test_1853() - { - } - [TestMethod] - public void Test_1854() - { - } - [TestMethod] - public void Test_1855() - { - } - [TestMethod] - public void Test_1856() - { - } - [TestMethod] - public void Test_1857() - { - } - [TestMethod] - public void Test_1858() - { - } - [TestMethod] - public void Test_1859() - { - } - [TestMethod] - public void Test_1860() - { - } - [TestMethod] - public void Test_1861() - { - } - [TestMethod] - public void Test_1862() - { - } - [TestMethod] - public void Test_1863() - { - } - [TestMethod] - public void Test_1864() - { - } - [TestMethod] - public void Test_1865() - { - } - [TestMethod] - public void Test_1866() - { - } - [TestMethod] - public void Test_1867() - { - } - [TestMethod] - public void Test_1868() - { - } - [TestMethod] - public void Test_1869() - { - } - [TestMethod] - public void Test_1870() - { - } - [TestMethod] - public void Test_1871() - { - } - [TestMethod] - public void Test_1872() - { - } - [TestMethod] - public void Test_1873() - { - } - [TestMethod] - public void Test_1874() - { - } - [TestMethod] - public void Test_1875() - { - } - [TestMethod] - public void Test_1876() - { - } - [TestMethod] - public void Test_1877() - { - } - [TestMethod] - public void Test_1878() - { - } - [TestMethod] - public void Test_1879() - { - } - [TestMethod] - public void Test_1880() - { - } - [TestMethod] - public void Test_1881() - { - } - [TestMethod] - public void Test_1882() - { - } - [TestMethod] - public void Test_1883() - { - } - [TestMethod] - public void Test_1884() - { - } - [TestMethod] - public void Test_1885() - { - } - [TestMethod] - public void Test_1886() - { - } - [TestMethod] - public void Test_1887() - { - } - [TestMethod] - public void Test_1888() - { - } - [TestMethod] - public void Test_1889() - { - } - [TestMethod] - public void Test_1890() - { - } - [TestMethod] - public void Test_1891() - { - } - [TestMethod] - public void Test_1892() - { - } - [TestMethod] - public void Test_1893() - { - } - [TestMethod] - public void Test_1894() - { - } - [TestMethod] - public void Test_1895() - { - } - [TestMethod] - public void Test_1896() - { - } - [TestMethod] - public void Test_1897() - { - } - [TestMethod] - public void Test_1898() - { - } - [TestMethod] - public void Test_1899() - { - } - [TestMethod] - public void Test_1900() - { - } - [TestMethod] - public void Test_1901() - { - } - [TestMethod] - public void Test_1902() - { - } - [TestMethod] - public void Test_1903() - { - } - [TestMethod] - public void Test_1904() - { - } - [TestMethod] - public void Test_1905() - { - } - [TestMethod] - public void Test_1906() - { - } - [TestMethod] - public void Test_1907() - { - } - [TestMethod] - public void Test_1908() - { - } - [TestMethod] - public void Test_1909() - { - } - [TestMethod] - public void Test_1910() - { - } - [TestMethod] - public void Test_1911() - { - } - [TestMethod] - public void Test_1912() - { - } - [TestMethod] - public void Test_1913() - { - } - [TestMethod] - public void Test_1914() - { - } - [TestMethod] - public void Test_1915() - { - } - [TestMethod] - public void Test_1916() - { - } - [TestMethod] - public void Test_1917() - { - } - [TestMethod] - public void Test_1918() - { - } - [TestMethod] - public void Test_1919() - { - } - [TestMethod] - public void Test_1920() - { - } - [TestMethod] - public void Test_1921() - { - } - [TestMethod] - public void Test_1922() - { - } - [TestMethod] - public void Test_1923() - { - } - [TestMethod] - public void Test_1924() - { - } - [TestMethod] - public void Test_1925() - { - } - [TestMethod] - public void Test_1926() - { - } - [TestMethod] - public void Test_1927() - { - } - [TestMethod] - public void Test_1928() - { - } - [TestMethod] - public void Test_1929() - { - } - [TestMethod] - public void Test_1930() - { - } - [TestMethod] - public void Test_1931() - { - } - [TestMethod] - public void Test_1932() - { - } - [TestMethod] - public void Test_1933() - { - } - [TestMethod] - public void Test_1934() - { - } - [TestMethod] - public void Test_1935() - { - } - [TestMethod] - public void Test_1936() - { - } - [TestMethod] - public void Test_1937() - { - } - [TestMethod] - public void Test_1938() - { - } - [TestMethod] - public void Test_1939() - { - } - [TestMethod] - public void Test_1940() - { - } - [TestMethod] - public void Test_1941() - { - } - [TestMethod] - public void Test_1942() - { - } - [TestMethod] - public void Test_1943() - { - } - [TestMethod] - public void Test_1944() - { - } - [TestMethod] - public void Test_1945() - { - } - [TestMethod] - public void Test_1946() - { - } - [TestMethod] - public void Test_1947() - { - } - [TestMethod] - public void Test_1948() - { - } - [TestMethod] - public void Test_1949() - { - } - [TestMethod] - public void Test_1950() - { - } - [TestMethod] - public void Test_1951() - { - } - [TestMethod] - public void Test_1952() - { - } - [TestMethod] - public void Test_1953() - { - } - [TestMethod] - public void Test_1954() - { - } - [TestMethod] - public void Test_1955() - { - } - [TestMethod] - public void Test_1956() - { - } - [TestMethod] - public void Test_1957() - { - } - [TestMethod] - public void Test_1958() - { - } - [TestMethod] - public void Test_1959() - { - } - [TestMethod] - public void Test_1960() - { - } - [TestMethod] - public void Test_1961() - { - } - [TestMethod] - public void Test_1962() - { - } - [TestMethod] - public void Test_1963() - { - } - [TestMethod] - public void Test_1964() - { - } - [TestMethod] - public void Test_1965() - { - } - [TestMethod] - public void Test_1966() - { - } - [TestMethod] - public void Test_1967() - { - } - [TestMethod] - public void Test_1968() - { - } - [TestMethod] - public void Test_1969() - { - } - [TestMethod] - public void Test_1970() - { - } - [TestMethod] - public void Test_1971() - { - } - [TestMethod] - public void Test_1972() - { - } - [TestMethod] - public void Test_1973() - { - } - [TestMethod] - public void Test_1974() - { - } - [TestMethod] - public void Test_1975() - { - } - [TestMethod] - public void Test_1976() - { - } - [TestMethod] - public void Test_1977() - { - } - [TestMethod] - public void Test_1978() - { - } - [TestMethod] - public void Test_1979() - { - } - [TestMethod] - public void Test_1980() - { - } - [TestMethod] - public void Test_1981() - { - } - [TestMethod] - public void Test_1982() - { - } - [TestMethod] - public void Test_1983() - { - } - [TestMethod] - public void Test_1984() - { - } - [TestMethod] - public void Test_1985() - { - } - [TestMethod] - public void Test_1986() - { - } - [TestMethod] - public void Test_1987() - { - } - [TestMethod] - public void Test_1988() - { - } - [TestMethod] - public void Test_1989() - { - } - [TestMethod] - public void Test_1990() - { - } - [TestMethod] - public void Test_1991() - { - } - [TestMethod] - public void Test_1992() - { - } - [TestMethod] - public void Test_1993() - { - } - [TestMethod] - public void Test_1994() - { - } - [TestMethod] - public void Test_1995() - { - } - [TestMethod] - public void Test_1996() - { - } - [TestMethod] - public void Test_1997() - { - } - [TestMethod] - public void Test_1998() - { - } - [TestMethod] - public void Test_1999() - { - } - [TestMethod] - public void Test_2000() - { - } - [TestMethod] - public void Test_2001() - { - } - [TestMethod] - public void Test_2002() - { - } - [TestMethod] - public void Test_2003() - { - } - [TestMethod] - public void Test_2004() - { - } - [TestMethod] - public void Test_2005() - { - } - [TestMethod] - public void Test_2006() - { - } - [TestMethod] - public void Test_2007() - { - } - [TestMethod] - public void Test_2008() - { - } - [TestMethod] - public void Test_2009() - { - } - [TestMethod] - public void Test_2010() - { - } - [TestMethod] - public void Test_2011() - { - } - [TestMethod] - public void Test_2012() - { - } - [TestMethod] - public void Test_2013() - { - } - [TestMethod] - public void Test_2014() - { - } - [TestMethod] - public void Test_2015() - { - } - [TestMethod] - public void Test_2016() - { - } - [TestMethod] - public void Test_2017() - { - } - [TestMethod] - public void Test_2018() - { - } - [TestMethod] - public void Test_2019() - { - } - [TestMethod] - public void Test_2020() - { - } - [TestMethod] - public void Test_2021() - { - } - [TestMethod] - public void Test_2022() - { - } - [TestMethod] - public void Test_2023() - { - } - [TestMethod] - public void Test_2024() - { - } - [TestMethod] - public void Test_2025() - { - } - [TestMethod] - public void Test_2026() - { - } - [TestMethod] - public void Test_2027() - { - } - [TestMethod] - public void Test_2028() - { - } - [TestMethod] - public void Test_2029() - { - } - [TestMethod] - public void Test_2030() - { - } - [TestMethod] - public void Test_2031() - { - } - [TestMethod] - public void Test_2032() - { - } - [TestMethod] - public void Test_2033() - { - } - [TestMethod] - public void Test_2034() - { - } - [TestMethod] - public void Test_2035() - { - } - [TestMethod] - public void Test_2036() - { - } - [TestMethod] - public void Test_2037() - { - } - [TestMethod] - public void Test_2038() - { - } - [TestMethod] - public void Test_2039() - { - } - [TestMethod] - public void Test_2040() - { - } - [TestMethod] - public void Test_2041() - { - } - [TestMethod] - public void Test_2042() - { - } - [TestMethod] - public void Test_2043() - { - } - [TestMethod] - public void Test_2044() - { - } - [TestMethod] - public void Test_2045() - { - } - [TestMethod] - public void Test_2046() - { - } - [TestMethod] - public void Test_2047() - { - } - [TestMethod] - public void Test_2048() - { - } - [TestMethod] - public void Test_2049() - { - } - [TestMethod] - public void Test_2050() - { - } - [TestMethod] - public void Test_2051() - { - } - [TestMethod] - public void Test_2052() - { - } - [TestMethod] - public void Test_2053() - { - } - [TestMethod] - public void Test_2054() - { - } - [TestMethod] - public void Test_2055() - { - } - [TestMethod] - public void Test_2056() - { - } - [TestMethod] - public void Test_2057() - { - } - [TestMethod] - public void Test_2058() - { - } - [TestMethod] - public void Test_2059() - { - } - [TestMethod] - public void Test_2060() - { - } - [TestMethod] - public void Test_2061() - { - } - [TestMethod] - public void Test_2062() - { - } - [TestMethod] - public void Test_2063() - { - } - [TestMethod] - public void Test_2064() - { - } - [TestMethod] - public void Test_2065() - { - } - [TestMethod] - public void Test_2066() - { - } - [TestMethod] - public void Test_2067() - { - } - [TestMethod] - public void Test_2068() - { - } - [TestMethod] - public void Test_2069() - { - } - [TestMethod] - public void Test_2070() - { - } - [TestMethod] - public void Test_2071() - { - } - [TestMethod] - public void Test_2072() - { - } - [TestMethod] - public void Test_2073() - { - } - [TestMethod] - public void Test_2074() - { - } - [TestMethod] - public void Test_2075() - { - } - [TestMethod] - public void Test_2076() - { - } - [TestMethod] - public void Test_2077() - { - } - [TestMethod] - public void Test_2078() - { - } - [TestMethod] - public void Test_2079() - { - } - [TestMethod] - public void Test_2080() - { - } - [TestMethod] - public void Test_2081() - { - } - [TestMethod] - public void Test_2082() - { - } - [TestMethod] - public void Test_2083() - { - } - [TestMethod] - public void Test_2084() - { - } - [TestMethod] - public void Test_2085() - { - } - [TestMethod] - public void Test_2086() - { - } - [TestMethod] - public void Test_2087() - { - } - [TestMethod] - public void Test_2088() - { - } - [TestMethod] - public void Test_2089() - { - } - [TestMethod] - public void Test_2090() - { - } - [TestMethod] - public void Test_2091() - { - } - [TestMethod] - public void Test_2092() - { - } - [TestMethod] - public void Test_2093() - { - } - [TestMethod] - public void Test_2094() - { - } - [TestMethod] - public void Test_2095() - { - } - [TestMethod] - public void Test_2096() - { - } - [TestMethod] - public void Test_2097() - { - } - [TestMethod] - public void Test_2098() - { - } - [TestMethod] - public void Test_2099() - { - } - [TestMethod] - public void Test_2100() - { - } - [TestMethod] - public void Test_2101() - { - } - [TestMethod] - public void Test_2102() - { - } - [TestMethod] - public void Test_2103() - { - } - [TestMethod] - public void Test_2104() - { - } - [TestMethod] - public void Test_2105() - { - } - [TestMethod] - public void Test_2106() - { - } - [TestMethod] - public void Test_2107() - { - } - [TestMethod] - public void Test_2108() - { - } - [TestMethod] - public void Test_2109() - { - } - [TestMethod] - public void Test_2110() - { - } - [TestMethod] - public void Test_2111() - { - } - [TestMethod] - public void Test_2112() - { - } - [TestMethod] - public void Test_2113() - { - } - [TestMethod] - public void Test_2114() - { - } - [TestMethod] - public void Test_2115() - { - } - [TestMethod] - public void Test_2116() - { - } - [TestMethod] - public void Test_2117() - { - } - [TestMethod] - public void Test_2118() - { - } - [TestMethod] - public void Test_2119() - { - } - [TestMethod] - public void Test_2120() - { - } - [TestMethod] - public void Test_2121() - { - } - [TestMethod] - public void Test_2122() - { - } - [TestMethod] - public void Test_2123() - { - } - [TestMethod] - public void Test_2124() - { - } - [TestMethod] - public void Test_2125() - { - } - [TestMethod] - public void Test_2126() - { - } - [TestMethod] - public void Test_2127() - { - } - [TestMethod] - public void Test_2128() - { - } - [TestMethod] - public void Test_2129() - { - } - [TestMethod] - public void Test_2130() - { - } - [TestMethod] - public void Test_2131() - { - } - [TestMethod] - public void Test_2132() - { - } - [TestMethod] - public void Test_2133() - { - } - [TestMethod] - public void Test_2134() - { - } - [TestMethod] - public void Test_2135() - { - } - [TestMethod] - public void Test_2136() - { - } - [TestMethod] - public void Test_2137() - { - } - [TestMethod] - public void Test_2138() - { - } - [TestMethod] - public void Test_2139() - { - } - [TestMethod] - public void Test_2140() - { - } - [TestMethod] - public void Test_2141() - { - } - [TestMethod] - public void Test_2142() - { - } - [TestMethod] - public void Test_2143() - { - } - [TestMethod] - public void Test_2144() - { - } - [TestMethod] - public void Test_2145() - { - } - [TestMethod] - public void Test_2146() - { - } - [TestMethod] - public void Test_2147() - { - } - [TestMethod] - public void Test_2148() - { - } - [TestMethod] - public void Test_2149() - { - } - [TestMethod] - public void Test_2150() - { - } - [TestMethod] - public void Test_2151() - { - } - [TestMethod] - public void Test_2152() - { - } - [TestMethod] - public void Test_2153() - { - } - [TestMethod] - public void Test_2154() - { - } - [TestMethod] - public void Test_2155() - { - } - [TestMethod] - public void Test_2156() - { - } - [TestMethod] - public void Test_2157() - { - } - [TestMethod] - public void Test_2158() - { - } - [TestMethod] - public void Test_2159() - { - } - [TestMethod] - public void Test_2160() - { - } - [TestMethod] - public void Test_2161() - { - } - [TestMethod] - public void Test_2162() - { - } - [TestMethod] - public void Test_2163() - { - } - [TestMethod] - public void Test_2164() - { - } - [TestMethod] - public void Test_2165() - { - } - [TestMethod] - public void Test_2166() - { - } - [TestMethod] - public void Test_2167() - { - } - [TestMethod] - public void Test_2168() - { - } - [TestMethod] - public void Test_2169() - { - } - [TestMethod] - public void Test_2170() - { - } - [TestMethod] - public void Test_2171() - { - } - [TestMethod] - public void Test_2172() - { - } - [TestMethod] - public void Test_2173() - { - } - [TestMethod] - public void Test_2174() - { - } - [TestMethod] - public void Test_2175() - { - } - [TestMethod] - public void Test_2176() - { - } - [TestMethod] - public void Test_2177() - { - } - [TestMethod] - public void Test_2178() - { - } - [TestMethod] - public void Test_2179() - { - } - [TestMethod] - public void Test_2180() - { - } - [TestMethod] - public void Test_2181() - { - } - [TestMethod] - public void Test_2182() - { - } - [TestMethod] - public void Test_2183() - { - } - [TestMethod] - public void Test_2184() - { - } - [TestMethod] - public void Test_2185() - { - } - [TestMethod] - public void Test_2186() - { - } - [TestMethod] - public void Test_2187() - { - } - [TestMethod] - public void Test_2188() - { - } - [TestMethod] - public void Test_2189() - { - } - [TestMethod] - public void Test_2190() - { - } - [TestMethod] - public void Test_2191() - { - } - [TestMethod] - public void Test_2192() - { - } - [TestMethod] - public void Test_2193() - { - } - [TestMethod] - public void Test_2194() - { - } - [TestMethod] - public void Test_2195() - { - } - [TestMethod] - public void Test_2196() - { - } - [TestMethod] - public void Test_2197() - { - } - [TestMethod] - public void Test_2198() - { - } - [TestMethod] - public void Test_2199() - { - } - [TestMethod] - public void Test_2200() - { - } - [TestMethod] - public void Test_2201() - { - } - [TestMethod] - public void Test_2202() - { - } - [TestMethod] - public void Test_2203() - { - } - [TestMethod] - public void Test_2204() - { - } - [TestMethod] - public void Test_2205() - { - } - [TestMethod] - public void Test_2206() - { - } - [TestMethod] - public void Test_2207() - { - } - [TestMethod] - public void Test_2208() - { - } - [TestMethod] - public void Test_2209() - { - } - [TestMethod] - public void Test_2210() - { - } - [TestMethod] - public void Test_2211() - { - } - [TestMethod] - public void Test_2212() - { - } - [TestMethod] - public void Test_2213() - { - } - [TestMethod] - public void Test_2214() - { - } - [TestMethod] - public void Test_2215() - { - } - [TestMethod] - public void Test_2216() - { - } - [TestMethod] - public void Test_2217() - { - } - [TestMethod] - public void Test_2218() - { - } - [TestMethod] - public void Test_2219() - { - } - [TestMethod] - public void Test_2220() - { - } - [TestMethod] - public void Test_2221() - { - } - [TestMethod] - public void Test_2222() - { - } - [TestMethod] - public void Test_2223() - { - } - [TestMethod] - public void Test_2224() - { - } - [TestMethod] - public void Test_2225() - { - } - [TestMethod] - public void Test_2226() - { - } - [TestMethod] - public void Test_2227() - { - } - [TestMethod] - public void Test_2228() - { - } - [TestMethod] - public void Test_2229() - { - } - [TestMethod] - public void Test_2230() - { - } - [TestMethod] - public void Test_2231() - { - } - [TestMethod] - public void Test_2232() - { - } - [TestMethod] - public void Test_2233() - { - } - [TestMethod] - public void Test_2234() - { - } - [TestMethod] - public void Test_2235() - { - } - [TestMethod] - public void Test_2236() - { - } - [TestMethod] - public void Test_2237() - { - } - [TestMethod] - public void Test_2238() - { - } - [TestMethod] - public void Test_2239() - { - } - [TestMethod] - public void Test_2240() - { - } - [TestMethod] - public void Test_2241() - { - } - [TestMethod] - public void Test_2242() - { - } - [TestMethod] - public void Test_2243() - { - } - [TestMethod] - public void Test_2244() - { - } - [TestMethod] - public void Test_2245() - { - } - [TestMethod] - public void Test_2246() - { - } - [TestMethod] - public void Test_2247() - { - } - [TestMethod] - public void Test_2248() - { - } - [TestMethod] - public void Test_2249() - { - } - [TestMethod] - public void Test_2250() - { - } - [TestMethod] - public void Test_2251() - { - } - [TestMethod] - public void Test_2252() - { - } - [TestMethod] - public void Test_2253() - { - } - [TestMethod] - public void Test_2254() - { - } - [TestMethod] - public void Test_2255() - { - } - [TestMethod] - public void Test_2256() - { - } - [TestMethod] - public void Test_2257() - { - } - [TestMethod] - public void Test_2258() - { - } - [TestMethod] - public void Test_2259() - { - } - [TestMethod] - public void Test_2260() - { - } - [TestMethod] - public void Test_2261() - { - } - [TestMethod] - public void Test_2262() - { - } - [TestMethod] - public void Test_2263() - { - } - [TestMethod] - public void Test_2264() - { - } - [TestMethod] - public void Test_2265() - { - } - [TestMethod] - public void Test_2266() - { - } - [TestMethod] - public void Test_2267() - { - } - [TestMethod] - public void Test_2268() - { - } - [TestMethod] - public void Test_2269() - { - } - [TestMethod] - public void Test_2270() - { - } - [TestMethod] - public void Test_2271() - { - } - [TestMethod] - public void Test_2272() - { - } - [TestMethod] - public void Test_2273() - { - } - [TestMethod] - public void Test_2274() - { - } - [TestMethod] - public void Test_2275() - { - } - [TestMethod] - public void Test_2276() - { - } - [TestMethod] - public void Test_2277() - { - } - [TestMethod] - public void Test_2278() - { - } - [TestMethod] - public void Test_2279() - { - } - [TestMethod] - public void Test_2280() - { - } - [TestMethod] - public void Test_2281() - { - } - [TestMethod] - public void Test_2282() - { - } - [TestMethod] - public void Test_2283() - { - } - [TestMethod] - public void Test_2284() - { - } - [TestMethod] - public void Test_2285() - { - } - [TestMethod] - public void Test_2286() - { - } - [TestMethod] - public void Test_2287() - { - } - [TestMethod] - public void Test_2288() - { - } - [TestMethod] - public void Test_2289() - { - } - [TestMethod] - public void Test_2290() - { - } - [TestMethod] - public void Test_2291() - { - } - [TestMethod] - public void Test_2292() - { - } - [TestMethod] - public void Test_2293() - { - } - [TestMethod] - public void Test_2294() - { - } - [TestMethod] - public void Test_2295() - { - } - [TestMethod] - public void Test_2296() - { - } - [TestMethod] - public void Test_2297() - { - } - [TestMethod] - public void Test_2298() - { - } - [TestMethod] - public void Test_2299() - { - } - [TestMethod] - public void Test_2300() - { - } - [TestMethod] - public void Test_2301() - { - } - [TestMethod] - public void Test_2302() - { - } - [TestMethod] - public void Test_2303() - { - } - [TestMethod] - public void Test_2304() - { - } - [TestMethod] - public void Test_2305() - { - } - [TestMethod] - public void Test_2306() - { - } - [TestMethod] - public void Test_2307() - { - } - [TestMethod] - public void Test_2308() - { - } - [TestMethod] - public void Test_2309() - { - } - [TestMethod] - public void Test_2310() - { - } - [TestMethod] - public void Test_2311() - { - } - [TestMethod] - public void Test_2312() - { - } - [TestMethod] - public void Test_2313() - { - } - [TestMethod] - public void Test_2314() - { - } - [TestMethod] - public void Test_2315() - { - } - [TestMethod] - public void Test_2316() - { - } - [TestMethod] - public void Test_2317() - { - } - [TestMethod] - public void Test_2318() - { - } - [TestMethod] - public void Test_2319() - { - } - [TestMethod] - public void Test_2320() - { - } - [TestMethod] - public void Test_2321() - { - } - [TestMethod] - public void Test_2322() - { - } - [TestMethod] - public void Test_2323() - { - } - [TestMethod] - public void Test_2324() - { - } - [TestMethod] - public void Test_2325() - { - } - [TestMethod] - public void Test_2326() - { - } - [TestMethod] - public void Test_2327() - { - } - [TestMethod] - public void Test_2328() - { - } - [TestMethod] - public void Test_2329() - { - } - [TestMethod] - public void Test_2330() - { - } - [TestMethod] - public void Test_2331() - { - } - [TestMethod] - public void Test_2332() - { - } - [TestMethod] - public void Test_2333() - { - } - [TestMethod] - public void Test_2334() - { - } - [TestMethod] - public void Test_2335() - { - } - [TestMethod] - public void Test_2336() - { - } - [TestMethod] - public void Test_2337() - { - } - [TestMethod] - public void Test_2338() - { - } - [TestMethod] - public void Test_2339() - { - } - [TestMethod] - public void Test_2340() - { - } - [TestMethod] - public void Test_2341() - { - } - [TestMethod] - public void Test_2342() - { - } - [TestMethod] - public void Test_2343() - { - } - [TestMethod] - public void Test_2344() - { - } - [TestMethod] - public void Test_2345() - { - } - [TestMethod] - public void Test_2346() - { - } - [TestMethod] - public void Test_2347() - { - } - [TestMethod] - public void Test_2348() - { - } - [TestMethod] - public void Test_2349() - { - } - [TestMethod] - public void Test_2350() - { - } - [TestMethod] - public void Test_2351() - { - } - [TestMethod] - public void Test_2352() - { - } - [TestMethod] - public void Test_2353() - { - } - [TestMethod] - public void Test_2354() - { - } - [TestMethod] - public void Test_2355() - { - } - [TestMethod] - public void Test_2356() - { - } - [TestMethod] - public void Test_2357() - { - } - [TestMethod] - public void Test_2358() - { - } - [TestMethod] - public void Test_2359() - { - } - [TestMethod] - public void Test_2360() - { - } - [TestMethod] - public void Test_2361() - { - } - [TestMethod] - public void Test_2362() - { - } - [TestMethod] - public void Test_2363() - { - } - [TestMethod] - public void Test_2364() - { - } - [TestMethod] - public void Test_2365() - { - } - [TestMethod] - public void Test_2366() - { - } - [TestMethod] - public void Test_2367() - { - } - [TestMethod] - public void Test_2368() - { - } - [TestMethod] - public void Test_2369() - { - } - [TestMethod] - public void Test_2370() - { - } - [TestMethod] - public void Test_2371() - { - } - [TestMethod] - public void Test_2372() - { - } - [TestMethod] - public void Test_2373() - { - } - [TestMethod] - public void Test_2374() - { - } - [TestMethod] - public void Test_2375() - { - } - [TestMethod] - public void Test_2376() - { - } - [TestMethod] - public void Test_2377() - { - } - [TestMethod] - public void Test_2378() - { - } - [TestMethod] - public void Test_2379() - { - } - [TestMethod] - public void Test_2380() - { - } - [TestMethod] - public void Test_2381() - { - } - [TestMethod] - public void Test_2382() - { - } - [TestMethod] - public void Test_2383() - { - } - [TestMethod] - public void Test_2384() - { - } - [TestMethod] - public void Test_2385() - { - } - [TestMethod] - public void Test_2386() - { - } - [TestMethod] - public void Test_2387() - { - } - [TestMethod] - public void Test_2388() - { - } - [TestMethod] - public void Test_2389() - { - } - [TestMethod] - public void Test_2390() - { - } - [TestMethod] - public void Test_2391() - { - } - [TestMethod] - public void Test_2392() - { - } - [TestMethod] - public void Test_2393() - { - } - [TestMethod] - public void Test_2394() - { - } - [TestMethod] - public void Test_2395() - { - } - [TestMethod] - public void Test_2396() - { - } - [TestMethod] - public void Test_2397() - { - } - [TestMethod] - public void Test_2398() - { - } - [TestMethod] - public void Test_2399() - { - } - [TestMethod] - public void Test_2400() - { - } - [TestMethod] - public void Test_2401() - { - } - [TestMethod] - public void Test_2402() - { - } - [TestMethod] - public void Test_2403() - { - } - [TestMethod] - public void Test_2404() - { - } - [TestMethod] - public void Test_2405() - { - } - [TestMethod] - public void Test_2406() - { - } - [TestMethod] - public void Test_2407() - { - } - [TestMethod] - public void Test_2408() - { - } - [TestMethod] - public void Test_2409() - { - } - [TestMethod] - public void Test_2410() - { - } - [TestMethod] - public void Test_2411() - { - } - [TestMethod] - public void Test_2412() - { - } - [TestMethod] - public void Test_2413() - { - } - [TestMethod] - public void Test_2414() - { - } - [TestMethod] - public void Test_2415() - { - } - [TestMethod] - public void Test_2416() - { - } - [TestMethod] - public void Test_2417() - { - } - [TestMethod] - public void Test_2418() - { - } - [TestMethod] - public void Test_2419() - { - } - [TestMethod] - public void Test_2420() - { - } - [TestMethod] - public void Test_2421() - { - } - [TestMethod] - public void Test_2422() - { - } - [TestMethod] - public void Test_2423() - { - } - [TestMethod] - public void Test_2424() - { - } - [TestMethod] - public void Test_2425() - { - } - [TestMethod] - public void Test_2426() - { - } - [TestMethod] - public void Test_2427() - { - } - [TestMethod] - public void Test_2428() - { - } - [TestMethod] - public void Test_2429() - { - } - [TestMethod] - public void Test_2430() - { - } - [TestMethod] - public void Test_2431() - { - } - [TestMethod] - public void Test_2432() - { - } - [TestMethod] - public void Test_2433() - { - } - [TestMethod] - public void Test_2434() - { - } - [TestMethod] - public void Test_2435() - { - } - [TestMethod] - public void Test_2436() - { - } - [TestMethod] - public void Test_2437() - { - } - [TestMethod] - public void Test_2438() - { - } - [TestMethod] - public void Test_2439() - { - } - [TestMethod] - public void Test_2440() - { - } - [TestMethod] - public void Test_2441() - { - } - [TestMethod] - public void Test_2442() - { - } - [TestMethod] - public void Test_2443() - { - } - [TestMethod] - public void Test_2444() - { - } - [TestMethod] - public void Test_2445() - { - } - [TestMethod] - public void Test_2446() - { - } - [TestMethod] - public void Test_2447() - { - } - [TestMethod] - public void Test_2448() - { - } - [TestMethod] - public void Test_2449() - { - } - [TestMethod] - public void Test_2450() - { - } - [TestMethod] - public void Test_2451() - { - } - [TestMethod] - public void Test_2452() - { - } - [TestMethod] - public void Test_2453() - { - } - [TestMethod] - public void Test_2454() - { - } - [TestMethod] - public void Test_2455() - { - } - [TestMethod] - public void Test_2456() - { - } - [TestMethod] - public void Test_2457() - { - } - [TestMethod] - public void Test_2458() - { - } - [TestMethod] - public void Test_2459() - { - } - [TestMethod] - public void Test_2460() - { - } - [TestMethod] - public void Test_2461() - { - } - [TestMethod] - public void Test_2462() - { - } - [TestMethod] - public void Test_2463() - { - } - [TestMethod] - public void Test_2464() - { - } - [TestMethod] - public void Test_2465() - { - } - [TestMethod] - public void Test_2466() - { - } - [TestMethod] - public void Test_2467() - { - } - [TestMethod] - public void Test_2468() - { - } - [TestMethod] - public void Test_2469() - { - } - [TestMethod] - public void Test_2470() - { - } - [TestMethod] - public void Test_2471() - { - } - [TestMethod] - public void Test_2472() - { - } - [TestMethod] - public void Test_2473() - { - } - [TestMethod] - public void Test_2474() - { - } - [TestMethod] - public void Test_2475() - { - } - [TestMethod] - public void Test_2476() - { - } - [TestMethod] - public void Test_2477() - { - } - [TestMethod] - public void Test_2478() - { - } - [TestMethod] - public void Test_2479() - { - } - [TestMethod] - public void Test_2480() - { - } - [TestMethod] - public void Test_2481() - { - } - [TestMethod] - public void Test_2482() - { - } - [TestMethod] - public void Test_2483() - { - } - [TestMethod] - public void Test_2484() - { - } - [TestMethod] - public void Test_2485() - { - } - [TestMethod] - public void Test_2486() - { - } - [TestMethod] - public void Test_2487() - { - } - [TestMethod] - public void Test_2488() - { - } - [TestMethod] - public void Test_2489() - { - } - [TestMethod] - public void Test_2490() - { - } - [TestMethod] - public void Test_2491() - { - } - [TestMethod] - public void Test_2492() - { - } - [TestMethod] - public void Test_2493() - { - } - [TestMethod] - public void Test_2494() - { - } - [TestMethod] - public void Test_2495() - { - } - [TestMethod] - public void Test_2496() - { - } - [TestMethod] - public void Test_2497() - { - } - [TestMethod] - public void Test_2498() - { - } - [TestMethod] - public void Test_2499() - { - } - [TestMethod] - public void Test_2500() - { - } - [TestMethod] - public void Test_2501() - { - } - [TestMethod] - public void Test_2502() - { - } - [TestMethod] - public void Test_2503() - { - } - [TestMethod] - public void Test_2504() - { - } - [TestMethod] - public void Test_2505() - { - } - [TestMethod] - public void Test_2506() - { - } - [TestMethod] - public void Test_2507() - { - } - [TestMethod] - public void Test_2508() - { - } - [TestMethod] - public void Test_2509() - { - } - [TestMethod] - public void Test_2510() - { - } - [TestMethod] - public void Test_2511() - { - } - [TestMethod] - public void Test_2512() - { - } - [TestMethod] - public void Test_2513() - { - } - [TestMethod] - public void Test_2514() - { - } - [TestMethod] - public void Test_2515() - { - } - [TestMethod] - public void Test_2516() - { - } - [TestMethod] - public void Test_2517() - { - } - [TestMethod] - public void Test_2518() - { - } - [TestMethod] - public void Test_2519() - { - } - [TestMethod] - public void Test_2520() - { - } - [TestMethod] - public void Test_2521() - { - } - [TestMethod] - public void Test_2522() - { - } - [TestMethod] - public void Test_2523() - { - } - [TestMethod] - public void Test_2524() - { - } - [TestMethod] - public void Test_2525() - { - } - [TestMethod] - public void Test_2526() - { - } - [TestMethod] - public void Test_2527() - { - } - [TestMethod] - public void Test_2528() - { - } - [TestMethod] - public void Test_2529() - { - } - [TestMethod] - public void Test_2530() - { - } - [TestMethod] - public void Test_2531() - { - } - [TestMethod] - public void Test_2532() - { - } - [TestMethod] - public void Test_2533() - { - } - [TestMethod] - public void Test_2534() - { - } - [TestMethod] - public void Test_2535() - { - } - [TestMethod] - public void Test_2536() - { - } - [TestMethod] - public void Test_2537() - { - } - [TestMethod] - public void Test_2538() - { - } - [TestMethod] - public void Test_2539() - { - } - [TestMethod] - public void Test_2540() - { - } - [TestMethod] - public void Test_2541() - { - } - [TestMethod] - public void Test_2542() - { - } - [TestMethod] - public void Test_2543() - { - } - [TestMethod] - public void Test_2544() - { - } - [TestMethod] - public void Test_2545() - { - } - [TestMethod] - public void Test_2546() - { - } - [TestMethod] - public void Test_2547() - { - } - [TestMethod] - public void Test_2548() - { - } - [TestMethod] - public void Test_2549() - { - } - [TestMethod] - public void Test_2550() - { - } - [TestMethod] - public void Test_2551() - { - } - [TestMethod] - public void Test_2552() - { - } - [TestMethod] - public void Test_2553() - { - } - [TestMethod] - public void Test_2554() - { - } - [TestMethod] - public void Test_2555() - { - } - [TestMethod] - public void Test_2556() - { - } - [TestMethod] - public void Test_2557() - { - } - [TestMethod] - public void Test_2558() - { - } - [TestMethod] - public void Test_2559() - { - } - [TestMethod] - public void Test_2560() - { - } - [TestMethod] - public void Test_2561() - { - } - [TestMethod] - public void Test_2562() - { - } - [TestMethod] - public void Test_2563() - { - } - [TestMethod] - public void Test_2564() - { - } - [TestMethod] - public void Test_2565() - { - } - [TestMethod] - public void Test_2566() - { - } - [TestMethod] - public void Test_2567() - { - } - [TestMethod] - public void Test_2568() - { - } - [TestMethod] - public void Test_2569() - { - } - [TestMethod] - public void Test_2570() - { - } - [TestMethod] - public void Test_2571() - { - } - [TestMethod] - public void Test_2572() - { - } - [TestMethod] - public void Test_2573() - { - } - [TestMethod] - public void Test_2574() - { - } - [TestMethod] - public void Test_2575() - { - } - [TestMethod] - public void Test_2576() - { - } - [TestMethod] - public void Test_2577() - { - } - [TestMethod] - public void Test_2578() - { - } - [TestMethod] - public void Test_2579() - { - } - [TestMethod] - public void Test_2580() - { - } - [TestMethod] - public void Test_2581() - { - } - [TestMethod] - public void Test_2582() - { - } - [TestMethod] - public void Test_2583() - { - } - [TestMethod] - public void Test_2584() - { - } - [TestMethod] - public void Test_2585() - { - } - [TestMethod] - public void Test_2586() - { - } - [TestMethod] - public void Test_2587() - { - } - [TestMethod] - public void Test_2588() - { - } - [TestMethod] - public void Test_2589() - { - } - [TestMethod] - public void Test_2590() - { - } - [TestMethod] - public void Test_2591() - { - } - [TestMethod] - public void Test_2592() - { - } - [TestMethod] - public void Test_2593() - { - } - [TestMethod] - public void Test_2594() - { - } - [TestMethod] - public void Test_2595() - { - } - [TestMethod] - public void Test_2596() - { - } - [TestMethod] - public void Test_2597() - { - } - [TestMethod] - public void Test_2598() - { - } - [TestMethod] - public void Test_2599() - { - } - [TestMethod] - public void Test_2600() - { - } - [TestMethod] - public void Test_2601() - { - } - [TestMethod] - public void Test_2602() - { - } - [TestMethod] - public void Test_2603() - { - } - [TestMethod] - public void Test_2604() - { - } - [TestMethod] - public void Test_2605() - { - } - [TestMethod] - public void Test_2606() - { - } - [TestMethod] - public void Test_2607() - { - } - [TestMethod] - public void Test_2608() - { - } - [TestMethod] - public void Test_2609() - { - } - [TestMethod] - public void Test_2610() - { - } - [TestMethod] - public void Test_2611() - { - } - [TestMethod] - public void Test_2612() - { - } - [TestMethod] - public void Test_2613() - { - } - [TestMethod] - public void Test_2614() - { - } - [TestMethod] - public void Test_2615() - { - } - [TestMethod] - public void Test_2616() - { - } - [TestMethod] - public void Test_2617() - { - } - [TestMethod] - public void Test_2618() - { - } - [TestMethod] - public void Test_2619() - { - } - [TestMethod] - public void Test_2620() - { - } - [TestMethod] - public void Test_2621() - { - } - [TestMethod] - public void Test_2622() - { - } - [TestMethod] - public void Test_2623() - { - } - [TestMethod] - public void Test_2624() - { - } - [TestMethod] - public void Test_2625() - { - } - [TestMethod] - public void Test_2626() - { - } - [TestMethod] - public void Test_2627() - { - } - [TestMethod] - public void Test_2628() - { - } - [TestMethod] - public void Test_2629() - { - } - [TestMethod] - public void Test_2630() - { - } - [TestMethod] - public void Test_2631() - { - } - [TestMethod] - public void Test_2632() - { - } - [TestMethod] - public void Test_2633() - { - } - [TestMethod] - public void Test_2634() - { - } - [TestMethod] - public void Test_2635() - { - } - [TestMethod] - public void Test_2636() - { - } - [TestMethod] - public void Test_2637() - { - } - [TestMethod] - public void Test_2638() - { - } - [TestMethod] - public void Test_2639() - { - } - [TestMethod] - public void Test_2640() - { - } - [TestMethod] - public void Test_2641() - { - } - [TestMethod] - public void Test_2642() - { - } - [TestMethod] - public void Test_2643() - { - } - [TestMethod] - public void Test_2644() - { - } - [TestMethod] - public void Test_2645() - { - } - [TestMethod] - public void Test_2646() - { - } - [TestMethod] - public void Test_2647() - { - } - [TestMethod] - public void Test_2648() - { - } - [TestMethod] - public void Test_2649() - { - } - [TestMethod] - public void Test_2650() - { - } - [TestMethod] - public void Test_2651() - { - } - [TestMethod] - public void Test_2652() - { - } - [TestMethod] - public void Test_2653() - { - } - [TestMethod] - public void Test_2654() - { - } - [TestMethod] - public void Test_2655() - { - } - [TestMethod] - public void Test_2656() - { - } - [TestMethod] - public void Test_2657() - { - } - [TestMethod] - public void Test_2658() - { - } - [TestMethod] - public void Test_2659() - { - } - [TestMethod] - public void Test_2660() - { - } - [TestMethod] - public void Test_2661() - { - } - [TestMethod] - public void Test_2662() - { - } - [TestMethod] - public void Test_2663() - { - } - [TestMethod] - public void Test_2664() - { - } - [TestMethod] - public void Test_2665() - { - } - [TestMethod] - public void Test_2666() - { - } - [TestMethod] - public void Test_2667() - { - } - [TestMethod] - public void Test_2668() - { - } - [TestMethod] - public void Test_2669() - { - } - [TestMethod] - public void Test_2670() - { - } - [TestMethod] - public void Test_2671() - { - } - [TestMethod] - public void Test_2672() - { - } - [TestMethod] - public void Test_2673() - { - } - [TestMethod] - public void Test_2674() - { - } - [TestMethod] - public void Test_2675() - { - } - [TestMethod] - public void Test_2676() - { - } - [TestMethod] - public void Test_2677() - { - } - [TestMethod] - public void Test_2678() - { - } - [TestMethod] - public void Test_2679() - { - } - [TestMethod] - public void Test_2680() - { - } - [TestMethod] - public void Test_2681() - { - } - [TestMethod] - public void Test_2682() - { - } - [TestMethod] - public void Test_2683() - { - } - [TestMethod] - public void Test_2684() - { - } - [TestMethod] - public void Test_2685() - { - } - [TestMethod] - public void Test_2686() - { - } - [TestMethod] - public void Test_2687() - { - } - [TestMethod] - public void Test_2688() - { - } - [TestMethod] - public void Test_2689() - { - } - [TestMethod] - public void Test_2690() - { - } - [TestMethod] - public void Test_2691() - { - } - [TestMethod] - public void Test_2692() - { - } - [TestMethod] - public void Test_2693() - { - } - [TestMethod] - public void Test_2694() - { - } - [TestMethod] - public void Test_2695() - { - } - [TestMethod] - public void Test_2696() - { - } - [TestMethod] - public void Test_2697() - { - } - [TestMethod] - public void Test_2698() - { - } - [TestMethod] - public void Test_2699() - { - } - [TestMethod] - public void Test_2700() - { - } - [TestMethod] - public void Test_2701() - { - } - [TestMethod] - public void Test_2702() - { - } - [TestMethod] - public void Test_2703() - { - } - [TestMethod] - public void Test_2704() - { - } - [TestMethod] - public void Test_2705() - { - } - [TestMethod] - public void Test_2706() - { - } - [TestMethod] - public void Test_2707() - { - } - [TestMethod] - public void Test_2708() - { - } - [TestMethod] - public void Test_2709() - { - } - [TestMethod] - public void Test_2710() - { - } - [TestMethod] - public void Test_2711() - { - } - [TestMethod] - public void Test_2712() - { - } - [TestMethod] - public void Test_2713() - { - } - [TestMethod] - public void Test_2714() - { - } - [TestMethod] - public void Test_2715() - { - } - [TestMethod] - public void Test_2716() - { - } - [TestMethod] - public void Test_2717() - { - } - [TestMethod] - public void Test_2718() - { - } - [TestMethod] - public void Test_2719() - { - } - [TestMethod] - public void Test_2720() - { - } - [TestMethod] - public void Test_2721() - { - } - [TestMethod] - public void Test_2722() - { - } - [TestMethod] - public void Test_2723() - { - } - [TestMethod] - public void Test_2724() - { - } - [TestMethod] - public void Test_2725() - { - } - [TestMethod] - public void Test_2726() - { - } - [TestMethod] - public void Test_2727() - { - } - [TestMethod] - public void Test_2728() - { - } - [TestMethod] - public void Test_2729() - { - } - [TestMethod] - public void Test_2730() - { - } - [TestMethod] - public void Test_2731() - { - } - [TestMethod] - public void Test_2732() - { - } - [TestMethod] - public void Test_2733() - { - } - [TestMethod] - public void Test_2734() - { - } - [TestMethod] - public void Test_2735() - { - } - [TestMethod] - public void Test_2736() - { - } - [TestMethod] - public void Test_2737() - { - } - [TestMethod] - public void Test_2738() - { - } - [TestMethod] - public void Test_2739() - { - } - [TestMethod] - public void Test_2740() - { - } - [TestMethod] - public void Test_2741() - { - } - [TestMethod] - public void Test_2742() - { - } - [TestMethod] - public void Test_2743() - { - } - [TestMethod] - public void Test_2744() - { - } - [TestMethod] - public void Test_2745() - { - } - [TestMethod] - public void Test_2746() - { - } - [TestMethod] - public void Test_2747() - { - } - [TestMethod] - public void Test_2748() - { - } - [TestMethod] - public void Test_2749() - { - } - [TestMethod] - public void Test_2750() - { - } - [TestMethod] - public void Test_2751() - { - } - [TestMethod] - public void Test_2752() - { - } - [TestMethod] - public void Test_2753() - { - } - [TestMethod] - public void Test_2754() - { - } - [TestMethod] - public void Test_2755() - { - } - [TestMethod] - public void Test_2756() - { - } - [TestMethod] - public void Test_2757() - { - } - [TestMethod] - public void Test_2758() - { - } - [TestMethod] - public void Test_2759() - { - } - [TestMethod] - public void Test_2760() - { - } - [TestMethod] - public void Test_2761() - { - } - [TestMethod] - public void Test_2762() - { - } - [TestMethod] - public void Test_2763() - { - } - [TestMethod] - public void Test_2764() - { - } - [TestMethod] - public void Test_2765() - { - } - [TestMethod] - public void Test_2766() - { - } - [TestMethod] - public void Test_2767() - { - } - [TestMethod] - public void Test_2768() - { - } - [TestMethod] - public void Test_2769() - { - } - [TestMethod] - public void Test_2770() - { - } - [TestMethod] - public void Test_2771() - { - } - [TestMethod] - public void Test_2772() - { - } - [TestMethod] - public void Test_2773() - { - } - [TestMethod] - public void Test_2774() - { - } - [TestMethod] - public void Test_2775() - { - } - [TestMethod] - public void Test_2776() - { - } - [TestMethod] - public void Test_2777() - { - } - [TestMethod] - public void Test_2778() - { - } - [TestMethod] - public void Test_2779() - { - } - [TestMethod] - public void Test_2780() - { - } - [TestMethod] - public void Test_2781() - { - } - [TestMethod] - public void Test_2782() - { - } - [TestMethod] - public void Test_2783() - { - } - [TestMethod] - public void Test_2784() - { - } - [TestMethod] - public void Test_2785() - { - } - [TestMethod] - public void Test_2786() - { - } - [TestMethod] - public void Test_2787() - { - } - [TestMethod] - public void Test_2788() - { - } - [TestMethod] - public void Test_2789() - { - } - [TestMethod] - public void Test_2790() - { - } - [TestMethod] - public void Test_2791() - { - } - [TestMethod] - public void Test_2792() - { - } - [TestMethod] - public void Test_2793() - { - } - [TestMethod] - public void Test_2794() - { - } - [TestMethod] - public void Test_2795() - { - } - [TestMethod] - public void Test_2796() - { - } - [TestMethod] - public void Test_2797() - { - } - [TestMethod] - public void Test_2798() - { - } - [TestMethod] - public void Test_2799() - { - } - [TestMethod] - public void Test_2800() - { - } - [TestMethod] - public void Test_2801() - { - } - [TestMethod] - public void Test_2802() - { - } - [TestMethod] - public void Test_2803() - { - } - [TestMethod] - public void Test_2804() - { - } - [TestMethod] - public void Test_2805() - { - } - [TestMethod] - public void Test_2806() - { - } - [TestMethod] - public void Test_2807() - { - } - [TestMethod] - public void Test_2808() - { - } - [TestMethod] - public void Test_2809() - { - } - [TestMethod] - public void Test_2810() - { - } - [TestMethod] - public void Test_2811() - { - } - [TestMethod] - public void Test_2812() - { - } - [TestMethod] - public void Test_2813() - { - } - [TestMethod] - public void Test_2814() - { - } - [TestMethod] - public void Test_2815() - { - } - [TestMethod] - public void Test_2816() - { - } - [TestMethod] - public void Test_2817() - { - } - [TestMethod] - public void Test_2818() - { - } - [TestMethod] - public void Test_2819() - { - } - [TestMethod] - public void Test_2820() - { - } - [TestMethod] - public void Test_2821() - { - } - [TestMethod] - public void Test_2822() - { - } - [TestMethod] - public void Test_2823() - { - } - [TestMethod] - public void Test_2824() - { - } - [TestMethod] - public void Test_2825() - { - } - [TestMethod] - public void Test_2826() - { - } - [TestMethod] - public void Test_2827() - { - } - [TestMethod] - public void Test_2828() - { - } - [TestMethod] - public void Test_2829() - { - } - [TestMethod] - public void Test_2830() - { - } - [TestMethod] - public void Test_2831() - { - } - [TestMethod] - public void Test_2832() - { - } - [TestMethod] - public void Test_2833() - { - } - [TestMethod] - public void Test_2834() - { - } - [TestMethod] - public void Test_2835() - { - } - [TestMethod] - public void Test_2836() - { - } - [TestMethod] - public void Test_2837() - { - } - [TestMethod] - public void Test_2838() - { - } - [TestMethod] - public void Test_2839() - { - } - [TestMethod] - public void Test_2840() - { - } - [TestMethod] - public void Test_2841() - { - } - [TestMethod] - public void Test_2842() - { - } - [TestMethod] - public void Test_2843() - { - } - [TestMethod] - public void Test_2844() - { - } - [TestMethod] - public void Test_2845() - { - } - [TestMethod] - public void Test_2846() - { - } - [TestMethod] - public void Test_2847() - { - } - [TestMethod] - public void Test_2848() - { - } - [TestMethod] - public void Test_2849() - { - } - [TestMethod] - public void Test_2850() - { - } - [TestMethod] - public void Test_2851() - { - } - [TestMethod] - public void Test_2852() - { - } - [TestMethod] - public void Test_2853() - { - } - [TestMethod] - public void Test_2854() - { - } - [TestMethod] - public void Test_2855() - { - } - [TestMethod] - public void Test_2856() - { - } - [TestMethod] - public void Test_2857() - { - } - [TestMethod] - public void Test_2858() - { - } - [TestMethod] - public void Test_2859() - { - } - [TestMethod] - public void Test_2860() - { - } - [TestMethod] - public void Test_2861() - { - } - [TestMethod] - public void Test_2862() - { - } - [TestMethod] - public void Test_2863() - { - } - [TestMethod] - public void Test_2864() - { - } - [TestMethod] - public void Test_2865() - { - } - [TestMethod] - public void Test_2866() - { - } - [TestMethod] - public void Test_2867() - { - } - [TestMethod] - public void Test_2868() - { - } - [TestMethod] - public void Test_2869() - { - } - [TestMethod] - public void Test_2870() - { - } - [TestMethod] - public void Test_2871() - { - } - [TestMethod] - public void Test_2872() - { - } - [TestMethod] - public void Test_2873() - { - } - [TestMethod] - public void Test_2874() - { - } - [TestMethod] - public void Test_2875() - { - } - [TestMethod] - public void Test_2876() - { - } - [TestMethod] - public void Test_2877() - { - } - [TestMethod] - public void Test_2878() - { - } - [TestMethod] - public void Test_2879() - { - } - [TestMethod] - public void Test_2880() - { - } - [TestMethod] - public void Test_2881() - { - } - [TestMethod] - public void Test_2882() - { - } - [TestMethod] - public void Test_2883() - { - } - [TestMethod] - public void Test_2884() - { - } - [TestMethod] - public void Test_2885() - { - } - [TestMethod] - public void Test_2886() - { - } - [TestMethod] - public void Test_2887() - { - } - [TestMethod] - public void Test_2888() - { - } - [TestMethod] - public void Test_2889() - { - } - [TestMethod] - public void Test_2890() - { - } - [TestMethod] - public void Test_2891() - { - } - [TestMethod] - public void Test_2892() - { - } - [TestMethod] - public void Test_2893() - { - } - [TestMethod] - public void Test_2894() - { - } - [TestMethod] - public void Test_2895() - { - } - [TestMethod] - public void Test_2896() - { - } - [TestMethod] - public void Test_2897() - { - } - [TestMethod] - public void Test_2898() - { - } - [TestMethod] - public void Test_2899() - { - } - [TestMethod] - public void Test_2900() - { - } - [TestMethod] - public void Test_2901() - { - } - [TestMethod] - public void Test_2902() - { - } - [TestMethod] - public void Test_2903() - { - } - [TestMethod] - public void Test_2904() - { - } - [TestMethod] - public void Test_2905() - { - } - [TestMethod] - public void Test_2906() - { - } - [TestMethod] - public void Test_2907() - { - } - [TestMethod] - public void Test_2908() - { - } - [TestMethod] - public void Test_2909() - { - } - [TestMethod] - public void Test_2910() - { - } - [TestMethod] - public void Test_2911() - { - } - [TestMethod] - public void Test_2912() - { - } - [TestMethod] - public void Test_2913() - { - } - [TestMethod] - public void Test_2914() - { - } - [TestMethod] - public void Test_2915() - { - } - [TestMethod] - public void Test_2916() - { - } - [TestMethod] - public void Test_2917() - { - } - [TestMethod] - public void Test_2918() - { - } - [TestMethod] - public void Test_2919() - { - } - [TestMethod] - public void Test_2920() - { - } - [TestMethod] - public void Test_2921() - { - } - [TestMethod] - public void Test_2922() - { - } - [TestMethod] - public void Test_2923() - { - } - [TestMethod] - public void Test_2924() - { - } - [TestMethod] - public void Test_2925() - { - } - [TestMethod] - public void Test_2926() - { - } - [TestMethod] - public void Test_2927() - { - } - [TestMethod] - public void Test_2928() - { - } - [TestMethod] - public void Test_2929() - { - } - [TestMethod] - public void Test_2930() - { - } - [TestMethod] - public void Test_2931() - { - } - [TestMethod] - public void Test_2932() - { - } - [TestMethod] - public void Test_2933() - { - } - [TestMethod] - public void Test_2934() - { - } - [TestMethod] - public void Test_2935() - { - } - [TestMethod] - public void Test_2936() - { - } - [TestMethod] - public void Test_2937() - { - } - [TestMethod] - public void Test_2938() - { - } - [TestMethod] - public void Test_2939() - { - } - [TestMethod] - public void Test_2940() - { - } - [TestMethod] - public void Test_2941() - { - } - [TestMethod] - public void Test_2942() - { - } - [TestMethod] - public void Test_2943() - { - } - [TestMethod] - public void Test_2944() - { - } - [TestMethod] - public void Test_2945() - { - } - [TestMethod] - public void Test_2946() - { - } - [TestMethod] - public void Test_2947() - { - } - [TestMethod] - public void Test_2948() - { - } - [TestMethod] - public void Test_2949() - { - } - [TestMethod] - public void Test_2950() - { - } - [TestMethod] - public void Test_2951() - { - } - [TestMethod] - public void Test_2952() - { - } - [TestMethod] - public void Test_2953() - { - } - [TestMethod] - public void Test_2954() - { - } - [TestMethod] - public void Test_2955() - { - } - [TestMethod] - public void Test_2956() - { - } - [TestMethod] - public void Test_2957() - { - } - [TestMethod] - public void Test_2958() - { - } - [TestMethod] - public void Test_2959() - { - } - [TestMethod] - public void Test_2960() - { - } - [TestMethod] - public void Test_2961() - { - } - [TestMethod] - public void Test_2962() - { - } - [TestMethod] - public void Test_2963() - { - } - [TestMethod] - public void Test_2964() - { - } - [TestMethod] - public void Test_2965() - { - } - [TestMethod] - public void Test_2966() - { - } - [TestMethod] - public void Test_2967() - { - } - [TestMethod] - public void Test_2968() - { - } - [TestMethod] - public void Test_2969() - { - } - [TestMethod] - public void Test_2970() - { - } - [TestMethod] - public void Test_2971() - { - } - [TestMethod] - public void Test_2972() - { - } - [TestMethod] - public void Test_2973() - { - } - [TestMethod] - public void Test_2974() - { - } - [TestMethod] - public void Test_2975() - { - } - [TestMethod] - public void Test_2976() - { - } - [TestMethod] - public void Test_2977() - { - } - [TestMethod] - public void Test_2978() - { - } - [TestMethod] - public void Test_2979() - { - } - [TestMethod] - public void Test_2980() - { - } - [TestMethod] - public void Test_2981() - { - } - [TestMethod] - public void Test_2982() - { - } - [TestMethod] - public void Test_2983() - { - } - [TestMethod] - public void Test_2984() - { - } - [TestMethod] - public void Test_2985() - { - } - [TestMethod] - public void Test_2986() - { - } - [TestMethod] - public void Test_2987() - { - } - [TestMethod] - public void Test_2988() - { - } - [TestMethod] - public void Test_2989() - { - } - [TestMethod] - public void Test_2990() - { - } - [TestMethod] - public void Test_2991() - { - } - [TestMethod] - public void Test_2992() - { - } - [TestMethod] - public void Test_2993() - { - } - [TestMethod] - public void Test_2994() - { - } - [TestMethod] - public void Test_2995() - { - } - [TestMethod] - public void Test_2996() - { - } - [TestMethod] - public void Test_2997() - { - } - [TestMethod] - public void Test_2998() - { - } - [TestMethod] - public void Test_2999() - { - } - [TestMethod] - public void Test_3000() - { - } - [TestMethod] - public void Test_3001() - { - } - [TestMethod] - public void Test_3002() - { - } - [TestMethod] - public void Test_3003() - { - } - [TestMethod] - public void Test_3004() - { - } - [TestMethod] - public void Test_3005() - { - } - [TestMethod] - public void Test_3006() - { - } - [TestMethod] - public void Test_3007() - { - } - [TestMethod] - public void Test_3008() - { - } - [TestMethod] - public void Test_3009() - { - } - [TestMethod] - public void Test_3010() - { - } - [TestMethod] - public void Test_3011() - { - } - [TestMethod] - public void Test_3012() - { - } - [TestMethod] - public void Test_3013() - { - } - [TestMethod] - public void Test_3014() - { - } - [TestMethod] - public void Test_3015() - { - } - [TestMethod] - public void Test_3016() - { - } - [TestMethod] - public void Test_3017() - { - } - [TestMethod] - public void Test_3018() - { - } - [TestMethod] - public void Test_3019() - { - } - [TestMethod] - public void Test_3020() - { - } - [TestMethod] - public void Test_3021() - { - } - [TestMethod] - public void Test_3022() - { - } - [TestMethod] - public void Test_3023() - { - } - [TestMethod] - public void Test_3024() - { - } - [TestMethod] - public void Test_3025() - { - } - [TestMethod] - public void Test_3026() - { - } - [TestMethod] - public void Test_3027() - { - } - [TestMethod] - public void Test_3028() - { - } - [TestMethod] - public void Test_3029() - { - } - [TestMethod] - public void Test_3030() - { - } - [TestMethod] - public void Test_3031() - { - } - [TestMethod] - public void Test_3032() - { - } - [TestMethod] - public void Test_3033() - { - } - [TestMethod] - public void Test_3034() - { - } - [TestMethod] - public void Test_3035() - { - } - [TestMethod] - public void Test_3036() - { - } - [TestMethod] - public void Test_3037() - { - } - [TestMethod] - public void Test_3038() - { - } - [TestMethod] - public void Test_3039() - { - } - [TestMethod] - public void Test_3040() - { - } - [TestMethod] - public void Test_3041() - { - } - [TestMethod] - public void Test_3042() - { - } - [TestMethod] - public void Test_3043() - { - } - [TestMethod] - public void Test_3044() - { - } - [TestMethod] - public void Test_3045() - { - } - [TestMethod] - public void Test_3046() - { - } - [TestMethod] - public void Test_3047() - { - } - [TestMethod] - public void Test_3048() - { - } - [TestMethod] - public void Test_3049() - { - } - [TestMethod] - public void Test_3050() - { - } - [TestMethod] - public void Test_3051() - { - } - [TestMethod] - public void Test_3052() - { - } - [TestMethod] - public void Test_3053() - { - } - [TestMethod] - public void Test_3054() - { - } - [TestMethod] - public void Test_3055() - { - } - [TestMethod] - public void Test_3056() - { - } - [TestMethod] - public void Test_3057() - { - } - [TestMethod] - public void Test_3058() - { - } - [TestMethod] - public void Test_3059() - { - } - [TestMethod] - public void Test_3060() - { - } - [TestMethod] - public void Test_3061() - { - } - [TestMethod] - public void Test_3062() - { - } - [TestMethod] - public void Test_3063() - { - } - [TestMethod] - public void Test_3064() - { - } - [TestMethod] - public void Test_3065() - { - } - [TestMethod] - public void Test_3066() - { - } - [TestMethod] - public void Test_3067() - { - } - [TestMethod] - public void Test_3068() - { - } - [TestMethod] - public void Test_3069() - { - } - [TestMethod] - public void Test_3070() - { - } - [TestMethod] - public void Test_3071() - { - } - [TestMethod] - public void Test_3072() - { - } - [TestMethod] - public void Test_3073() - { - } - [TestMethod] - public void Test_3074() - { - } - [TestMethod] - public void Test_3075() - { - } - [TestMethod] - public void Test_3076() - { - } - [TestMethod] - public void Test_3077() - { - } - [TestMethod] - public void Test_3078() - { - } - [TestMethod] - public void Test_3079() - { - } - [TestMethod] - public void Test_3080() - { - } - [TestMethod] - public void Test_3081() - { - } - [TestMethod] - public void Test_3082() - { - } - [TestMethod] - public void Test_3083() - { - } - [TestMethod] - public void Test_3084() - { - } - [TestMethod] - public void Test_3085() - { - } - [TestMethod] - public void Test_3086() - { - } - [TestMethod] - public void Test_3087() - { - } - [TestMethod] - public void Test_3088() - { - } - [TestMethod] - public void Test_3089() - { - } - [TestMethod] - public void Test_3090() - { - } - [TestMethod] - public void Test_3091() - { - } - [TestMethod] - public void Test_3092() - { - } - [TestMethod] - public void Test_3093() - { - } - [TestMethod] - public void Test_3094() - { - } - [TestMethod] - public void Test_3095() - { - } - [TestMethod] - public void Test_3096() - { - } - [TestMethod] - public void Test_3097() - { - } - [TestMethod] - public void Test_3098() - { - } - [TestMethod] - public void Test_3099() - { - } - [TestMethod] - public void Test_3100() - { - } - [TestMethod] - public void Test_3101() - { - } - [TestMethod] - public void Test_3102() - { - } - [TestMethod] - public void Test_3103() - { - } - [TestMethod] - public void Test_3104() - { - } - [TestMethod] - public void Test_3105() - { - } - [TestMethod] - public void Test_3106() - { - } - [TestMethod] - public void Test_3107() - { - } - [TestMethod] - public void Test_3108() - { - } - [TestMethod] - public void Test_3109() - { - } - [TestMethod] - public void Test_3110() - { - } - [TestMethod] - public void Test_3111() - { - } - [TestMethod] - public void Test_3112() - { - } - [TestMethod] - public void Test_3113() - { - } - [TestMethod] - public void Test_3114() - { - } - [TestMethod] - public void Test_3115() - { - } - [TestMethod] - public void Test_3116() - { - } - [TestMethod] - public void Test_3117() - { - } - [TestMethod] - public void Test_3118() - { - } - [TestMethod] - public void Test_3119() - { - } - [TestMethod] - public void Test_3120() - { - } - [TestMethod] - public void Test_3121() - { - } - [TestMethod] - public void Test_3122() - { - } - [TestMethod] - public void Test_3123() - { - } - [TestMethod] - public void Test_3124() - { - } - [TestMethod] - public void Test_3125() - { - } - [TestMethod] - public void Test_3126() - { - } - [TestMethod] - public void Test_3127() - { - } - [TestMethod] - public void Test_3128() - { - } - [TestMethod] - public void Test_3129() - { - } - [TestMethod] - public void Test_3130() - { - } - [TestMethod] - public void Test_3131() - { - } - [TestMethod] - public void Test_3132() - { - } - [TestMethod] - public void Test_3133() - { - } - [TestMethod] - public void Test_3134() - { - } - [TestMethod] - public void Test_3135() - { - } - [TestMethod] - public void Test_3136() - { - } - [TestMethod] - public void Test_3137() - { - } - [TestMethod] - public void Test_3138() - { - } - [TestMethod] - public void Test_3139() - { - } - [TestMethod] - public void Test_3140() - { - } - [TestMethod] - public void Test_3141() - { - } - [TestMethod] - public void Test_3142() - { - } - [TestMethod] - public void Test_3143() - { - } - [TestMethod] - public void Test_3144() - { - } - [TestMethod] - public void Test_3145() - { - } - [TestMethod] - public void Test_3146() - { - } - [TestMethod] - public void Test_3147() - { - } - [TestMethod] - public void Test_3148() - { - } - [TestMethod] - public void Test_3149() - { - } - [TestMethod] - public void Test_3150() - { - } - [TestMethod] - public void Test_3151() - { - } - [TestMethod] - public void Test_3152() - { - } - [TestMethod] - public void Test_3153() - { - } - [TestMethod] - public void Test_3154() - { - } - [TestMethod] - public void Test_3155() - { - } - [TestMethod] - public void Test_3156() - { - } - [TestMethod] - public void Test_3157() - { - } - [TestMethod] - public void Test_3158() - { - } - [TestMethod] - public void Test_3159() - { - } - [TestMethod] - public void Test_3160() - { - } - [TestMethod] - public void Test_3161() - { - } - [TestMethod] - public void Test_3162() - { - } - [TestMethod] - public void Test_3163() - { - } - [TestMethod] - public void Test_3164() - { - } - [TestMethod] - public void Test_3165() - { - } - [TestMethod] - public void Test_3166() - { - } - [TestMethod] - public void Test_3167() - { - } - [TestMethod] - public void Test_3168() - { - } - [TestMethod] - public void Test_3169() - { - } - [TestMethod] - public void Test_3170() - { - } - [TestMethod] - public void Test_3171() - { - } - [TestMethod] - public void Test_3172() - { - } - [TestMethod] - public void Test_3173() - { - } - [TestMethod] - public void Test_3174() - { - } - [TestMethod] - public void Test_3175() - { - } - [TestMethod] - public void Test_3176() - { - } - [TestMethod] - public void Test_3177() - { - } - [TestMethod] - public void Test_3178() - { - } - [TestMethod] - public void Test_3179() - { - } - [TestMethod] - public void Test_3180() - { - } - [TestMethod] - public void Test_3181() - { - } - [TestMethod] - public void Test_3182() - { - } - [TestMethod] - public void Test_3183() - { - } - [TestMethod] - public void Test_3184() - { - } - [TestMethod] - public void Test_3185() - { - } - [TestMethod] - public void Test_3186() - { - } - [TestMethod] - public void Test_3187() - { - } - [TestMethod] - public void Test_3188() - { - } - [TestMethod] - public void Test_3189() - { - } - [TestMethod] - public void Test_3190() - { - } - [TestMethod] - public void Test_3191() - { - } - [TestMethod] - public void Test_3192() - { - } - [TestMethod] - public void Test_3193() - { - } - [TestMethod] - public void Test_3194() - { - } - [TestMethod] - public void Test_3195() - { - } - [TestMethod] - public void Test_3196() - { - } - [TestMethod] - public void Test_3197() - { - } - [TestMethod] - public void Test_3198() - { - } - [TestMethod] - public void Test_3199() - { - } - [TestMethod] - public void Test_3200() - { - } - [TestMethod] - public void Test_3201() - { - } - [TestMethod] - public void Test_3202() - { - } - [TestMethod] - public void Test_3203() - { - } - [TestMethod] - public void Test_3204() - { - } - [TestMethod] - public void Test_3205() - { - } - [TestMethod] - public void Test_3206() - { - } - [TestMethod] - public void Test_3207() - { - } - [TestMethod] - public void Test_3208() - { - } - [TestMethod] - public void Test_3209() - { - } - [TestMethod] - public void Test_3210() - { - } - [TestMethod] - public void Test_3211() - { - } - [TestMethod] - public void Test_3212() - { - } - [TestMethod] - public void Test_3213() - { - } - [TestMethod] - public void Test_3214() - { - } - [TestMethod] - public void Test_3215() - { - } - [TestMethod] - public void Test_3216() - { - } - [TestMethod] - public void Test_3217() - { - } - [TestMethod] - public void Test_3218() - { - } - [TestMethod] - public void Test_3219() - { - } - [TestMethod] - public void Test_3220() - { - } - [TestMethod] - public void Test_3221() - { - } - [TestMethod] - public void Test_3222() - { - } - [TestMethod] - public void Test_3223() - { - } - [TestMethod] - public void Test_3224() - { - } - [TestMethod] - public void Test_3225() - { - } - [TestMethod] - public void Test_3226() - { - } - [TestMethod] - public void Test_3227() - { - } - [TestMethod] - public void Test_3228() - { - } - [TestMethod] - public void Test_3229() - { - } - [TestMethod] - public void Test_3230() - { - } - [TestMethod] - public void Test_3231() - { - } - [TestMethod] - public void Test_3232() - { - } - [TestMethod] - public void Test_3233() - { - } - [TestMethod] - public void Test_3234() - { - } - [TestMethod] - public void Test_3235() - { - } - [TestMethod] - public void Test_3236() - { - } - [TestMethod] - public void Test_3237() - { - } - [TestMethod] - public void Test_3238() - { - } - [TestMethod] - public void Test_3239() - { - } - [TestMethod] - public void Test_3240() - { - } - [TestMethod] - public void Test_3241() - { - } - [TestMethod] - public void Test_3242() - { - } - [TestMethod] - public void Test_3243() - { - } - [TestMethod] - public void Test_3244() - { - } - [TestMethod] - public void Test_3245() - { - } - [TestMethod] - public void Test_3246() - { - } - [TestMethod] - public void Test_3247() - { - } - [TestMethod] - public void Test_3248() - { - } - [TestMethod] - public void Test_3249() - { - } - [TestMethod] - public void Test_3250() - { - } - [TestMethod] - public void Test_3251() - { - } - [TestMethod] - public void Test_3252() - { - } - [TestMethod] - public void Test_3253() - { - } - [TestMethod] - public void Test_3254() - { - } - [TestMethod] - public void Test_3255() - { - } - [TestMethod] - public void Test_3256() - { - } - [TestMethod] - public void Test_3257() - { - } - [TestMethod] - public void Test_3258() - { - } - [TestMethod] - public void Test_3259() - { - } - [TestMethod] - public void Test_3260() - { - } - [TestMethod] - public void Test_3261() - { - } - [TestMethod] - public void Test_3262() - { - } - [TestMethod] - public void Test_3263() - { - } - [TestMethod] - public void Test_3264() - { - } - [TestMethod] - public void Test_3265() - { - } - [TestMethod] - public void Test_3266() - { - } - [TestMethod] - public void Test_3267() - { - } - [TestMethod] - public void Test_3268() - { - } - [TestMethod] - public void Test_3269() - { - } - [TestMethod] - public void Test_3270() - { - } - [TestMethod] - public void Test_3271() - { - } - [TestMethod] - public void Test_3272() - { - } - [TestMethod] - public void Test_3273() - { - } - [TestMethod] - public void Test_3274() - { - } - [TestMethod] - public void Test_3275() - { - } - [TestMethod] - public void Test_3276() - { - } - [TestMethod] - public void Test_3277() - { - } - [TestMethod] - public void Test_3278() - { - } - [TestMethod] - public void Test_3279() - { - } - [TestMethod] - public void Test_3280() - { - } - [TestMethod] - public void Test_3281() - { - } - [TestMethod] - public void Test_3282() - { - } - [TestMethod] - public void Test_3283() - { - } - [TestMethod] - public void Test_3284() - { - } - [TestMethod] - public void Test_3285() - { - } - [TestMethod] - public void Test_3286() - { - } - [TestMethod] - public void Test_3287() - { - } - [TestMethod] - public void Test_3288() - { - } - [TestMethod] - public void Test_3289() - { - } - [TestMethod] - public void Test_3290() - { - } - [TestMethod] - public void Test_3291() - { - } - [TestMethod] - public void Test_3292() - { - } - [TestMethod] - public void Test_3293() - { - } - [TestMethod] - public void Test_3294() - { - } - [TestMethod] - public void Test_3295() - { - } - [TestMethod] - public void Test_3296() - { - } - [TestMethod] - public void Test_3297() - { - } - [TestMethod] - public void Test_3298() - { - } - [TestMethod] - public void Test_3299() - { - } - [TestMethod] - public void Test_3300() - { - } - [TestMethod] - public void Test_3301() - { - } - [TestMethod] - public void Test_3302() - { - } - [TestMethod] - public void Test_3303() - { - } - [TestMethod] - public void Test_3304() - { - } - [TestMethod] - public void Test_3305() - { - } - [TestMethod] - public void Test_3306() - { - } - [TestMethod] - public void Test_3307() - { - } - [TestMethod] - public void Test_3308() - { - } - [TestMethod] - public void Test_3309() - { - } - [TestMethod] - public void Test_3310() - { - } - [TestMethod] - public void Test_3311() - { - } - [TestMethod] - public void Test_3312() - { - } - [TestMethod] - public void Test_3313() - { - } - [TestMethod] - public void Test_3314() - { - } - [TestMethod] - public void Test_3315() - { - } - [TestMethod] - public void Test_3316() - { - } - [TestMethod] - public void Test_3317() - { - } - [TestMethod] - public void Test_3318() - { - } - [TestMethod] - public void Test_3319() - { - } - [TestMethod] - public void Test_3320() - { - } - [TestMethod] - public void Test_3321() - { - } - [TestMethod] - public void Test_3322() - { - } - [TestMethod] - public void Test_3323() - { - } - [TestMethod] - public void Test_3324() - { - } - [TestMethod] - public void Test_3325() - { - } - [TestMethod] - public void Test_3326() - { - } - [TestMethod] - public void Test_3327() - { - } - [TestMethod] - public void Test_3328() - { - } - [TestMethod] - public void Test_3329() - { - } - [TestMethod] - public void Test_3330() - { - } - [TestMethod] - public void Test_3331() - { - } - [TestMethod] - public void Test_3332() - { - } - [TestMethod] - public void Test_3333() - { - } - [TestMethod] - public void Test_3334() - { - } - [TestMethod] - public void Test_3335() - { - } - [TestMethod] - public void Test_3336() - { - } - [TestMethod] - public void Test_3337() - { - } - [TestMethod] - public void Test_3338() - { - } - [TestMethod] - public void Test_3339() - { - } - [TestMethod] - public void Test_3340() - { - } - [TestMethod] - public void Test_3341() - { - } - [TestMethod] - public void Test_3342() - { - } - [TestMethod] - public void Test_3343() - { - } - [TestMethod] - public void Test_3344() - { - } - [TestMethod] - public void Test_3345() - { - } - [TestMethod] - public void Test_3346() - { - } - [TestMethod] - public void Test_3347() - { - } - [TestMethod] - public void Test_3348() - { - } - [TestMethod] - public void Test_3349() - { - } - [TestMethod] - public void Test_3350() - { - } - [TestMethod] - public void Test_3351() - { - } - [TestMethod] - public void Test_3352() - { - } - [TestMethod] - public void Test_3353() - { - } - [TestMethod] - public void Test_3354() - { - } - [TestMethod] - public void Test_3355() - { - } - [TestMethod] - public void Test_3356() - { - } - [TestMethod] - public void Test_3357() - { - } - [TestMethod] - public void Test_3358() - { - } - [TestMethod] - public void Test_3359() - { - } - [TestMethod] - public void Test_3360() - { - } - [TestMethod] - public void Test_3361() - { - } - [TestMethod] - public void Test_3362() - { - } - [TestMethod] - public void Test_3363() - { - } - [TestMethod] - public void Test_3364() - { - } - [TestMethod] - public void Test_3365() - { - } - [TestMethod] - public void Test_3366() - { - } - [TestMethod] - public void Test_3367() - { - } - [TestMethod] - public void Test_3368() - { - } - [TestMethod] - public void Test_3369() - { - } - [TestMethod] - public void Test_3370() - { - } - [TestMethod] - public void Test_3371() - { - } - [TestMethod] - public void Test_3372() - { - } - [TestMethod] - public void Test_3373() - { - } - [TestMethod] - public void Test_3374() - { - } - [TestMethod] - public void Test_3375() - { - } - [TestMethod] - public void Test_3376() - { - } - [TestMethod] - public void Test_3377() - { - } - [TestMethod] - public void Test_3378() - { - } - [TestMethod] - public void Test_3379() - { - } - [TestMethod] - public void Test_3380() - { - } - [TestMethod] - public void Test_3381() - { - } - [TestMethod] - public void Test_3382() - { - } - [TestMethod] - public void Test_3383() - { - } - [TestMethod] - public void Test_3384() - { - } - [TestMethod] - public void Test_3385() - { - } - [TestMethod] - public void Test_3386() - { - } - [TestMethod] - public void Test_3387() - { - } - [TestMethod] - public void Test_3388() - { - } - [TestMethod] - public void Test_3389() - { - } - [TestMethod] - public void Test_3390() - { - } - [TestMethod] - public void Test_3391() - { - } - [TestMethod] - public void Test_3392() - { - } - [TestMethod] - public void Test_3393() - { - } - [TestMethod] - public void Test_3394() - { - } - [TestMethod] - public void Test_3395() - { - } - [TestMethod] - public void Test_3396() - { - } - [TestMethod] - public void Test_3397() - { - } - [TestMethod] - public void Test_3398() - { - } - [TestMethod] - public void Test_3399() - { - } - [TestMethod] - public void Test_3400() - { - } - [TestMethod] - public void Test_3401() - { - } - [TestMethod] - public void Test_3402() - { - } - [TestMethod] - public void Test_3403() - { - } - [TestMethod] - public void Test_3404() - { - } - [TestMethod] - public void Test_3405() - { - } - [TestMethod] - public void Test_3406() - { - } - [TestMethod] - public void Test_3407() - { - } - [TestMethod] - public void Test_3408() - { - } - [TestMethod] - public void Test_3409() - { - } - [TestMethod] - public void Test_3410() - { - } - [TestMethod] - public void Test_3411() - { - } - [TestMethod] - public void Test_3412() - { - } - [TestMethod] - public void Test_3413() - { - } - [TestMethod] - public void Test_3414() - { - } - [TestMethod] - public void Test_3415() - { - } - [TestMethod] - public void Test_3416() - { - } - [TestMethod] - public void Test_3417() - { - } - [TestMethod] - public void Test_3418() - { - } - [TestMethod] - public void Test_3419() - { - } - [TestMethod] - public void Test_3420() - { - } - [TestMethod] - public void Test_3421() - { - } - [TestMethod] - public void Test_3422() - { - } - [TestMethod] - public void Test_3423() - { - } - [TestMethod] - public void Test_3424() - { - } - [TestMethod] - public void Test_3425() - { - } - [TestMethod] - public void Test_3426() - { - } - [TestMethod] - public void Test_3427() - { - } - [TestMethod] - public void Test_3428() - { - } - [TestMethod] - public void Test_3429() - { - } - [TestMethod] - public void Test_3430() - { - } - [TestMethod] - public void Test_3431() - { - } - [TestMethod] - public void Test_3432() - { - } - [TestMethod] - public void Test_3433() - { - } - [TestMethod] - public void Test_3434() - { - } - [TestMethod] - public void Test_3435() - { - } - [TestMethod] - public void Test_3436() - { - } - [TestMethod] - public void Test_3437() - { - } - [TestMethod] - public void Test_3438() - { - } - [TestMethod] - public void Test_3439() - { - } - [TestMethod] - public void Test_3440() - { - } - [TestMethod] - public void Test_3441() - { - } - [TestMethod] - public void Test_3442() - { - } - [TestMethod] - public void Test_3443() - { - } - [TestMethod] - public void Test_3444() - { - } - [TestMethod] - public void Test_3445() - { - } - [TestMethod] - public void Test_3446() - { - } - [TestMethod] - public void Test_3447() - { - } - [TestMethod] - public void Test_3448() - { - } - [TestMethod] - public void Test_3449() - { - } - [TestMethod] - public void Test_3450() - { - } - [TestMethod] - public void Test_3451() - { - } - [TestMethod] - public void Test_3452() - { - } - [TestMethod] - public void Test_3453() - { - } - [TestMethod] - public void Test_3454() - { - } - [TestMethod] - public void Test_3455() - { - } - [TestMethod] - public void Test_3456() - { - } - [TestMethod] - public void Test_3457() - { - } - [TestMethod] - public void Test_3458() - { - } - [TestMethod] - public void Test_3459() - { - } - [TestMethod] - public void Test_3460() - { - } - [TestMethod] - public void Test_3461() - { - } - [TestMethod] - public void Test_3462() - { - } - [TestMethod] - public void Test_3463() - { - } - [TestMethod] - public void Test_3464() - { - } - [TestMethod] - public void Test_3465() - { - } - [TestMethod] - public void Test_3466() - { - } - [TestMethod] - public void Test_3467() - { - } - [TestMethod] - public void Test_3468() - { - } - [TestMethod] - public void Test_3469() - { - } - [TestMethod] - public void Test_3470() - { - } - [TestMethod] - public void Test_3471() - { - } - [TestMethod] - public void Test_3472() - { - } - [TestMethod] - public void Test_3473() - { - } - [TestMethod] - public void Test_3474() - { - } - [TestMethod] - public void Test_3475() - { - } - [TestMethod] - public void Test_3476() - { - } - [TestMethod] - public void Test_3477() - { - } - [TestMethod] - public void Test_3478() - { - } - [TestMethod] - public void Test_3479() - { - } - [TestMethod] - public void Test_3480() - { - } - [TestMethod] - public void Test_3481() - { - } - [TestMethod] - public void Test_3482() - { - } - [TestMethod] - public void Test_3483() - { - } - [TestMethod] - public void Test_3484() - { - } - [TestMethod] - public void Test_3485() - { - } - [TestMethod] - public void Test_3486() - { - } - [TestMethod] - public void Test_3487() - { - } - [TestMethod] - public void Test_3488() - { - } - [TestMethod] - public void Test_3489() - { - } - [TestMethod] - public void Test_3490() - { - } - [TestMethod] - public void Test_3491() - { - } - [TestMethod] - public void Test_3492() - { - } - [TestMethod] - public void Test_3493() - { - } - [TestMethod] - public void Test_3494() - { - } - [TestMethod] - public void Test_3495() - { - } - [TestMethod] - public void Test_3496() - { - } - [TestMethod] - public void Test_3497() - { - } - [TestMethod] - public void Test_3498() - { - } - [TestMethod] - public void Test_3499() - { - } - [TestMethod] - public void Test_3500() - { - } - [TestMethod] - public void Test_3501() - { - } - [TestMethod] - public void Test_3502() - { - } - [TestMethod] - public void Test_3503() - { - } - [TestMethod] - public void Test_3504() - { - } - [TestMethod] - public void Test_3505() - { - } - [TestMethod] - public void Test_3506() - { - } - [TestMethod] - public void Test_3507() - { - } - [TestMethod] - public void Test_3508() - { - } - [TestMethod] - public void Test_3509() - { - } - [TestMethod] - public void Test_3510() - { - } - [TestMethod] - public void Test_3511() - { - } - [TestMethod] - public void Test_3512() - { - } - [TestMethod] - public void Test_3513() - { - } - [TestMethod] - public void Test_3514() - { - } - [TestMethod] - public void Test_3515() - { - } - [TestMethod] - public void Test_3516() - { - } - [TestMethod] - public void Test_3517() - { - } - [TestMethod] - public void Test_3518() - { - } - [TestMethod] - public void Test_3519() - { - } - [TestMethod] - public void Test_3520() - { - } - [TestMethod] - public void Test_3521() - { - } - [TestMethod] - public void Test_3522() - { - } - [TestMethod] - public void Test_3523() - { - } - [TestMethod] - public void Test_3524() - { - } - [TestMethod] - public void Test_3525() - { - } - [TestMethod] - public void Test_3526() - { - } - [TestMethod] - public void Test_3527() - { - } - [TestMethod] - public void Test_3528() - { - } - [TestMethod] - public void Test_3529() - { - } - [TestMethod] - public void Test_3530() - { - } - [TestMethod] - public void Test_3531() - { - } - [TestMethod] - public void Test_3532() - { - } - [TestMethod] - public void Test_3533() - { - } - [TestMethod] - public void Test_3534() - { - } - [TestMethod] - public void Test_3535() - { - } - [TestMethod] - public void Test_3536() - { - } - [TestMethod] - public void Test_3537() - { - } - [TestMethod] - public void Test_3538() - { - } - [TestMethod] - public void Test_3539() - { - } - [TestMethod] - public void Test_3540() - { - } - [TestMethod] - public void Test_3541() - { - } - [TestMethod] - public void Test_3542() - { - } - [TestMethod] - public void Test_3543() - { - } - [TestMethod] - public void Test_3544() - { - } - [TestMethod] - public void Test_3545() - { - } - [TestMethod] - public void Test_3546() - { - } - [TestMethod] - public void Test_3547() - { - } - [TestMethod] - public void Test_3548() - { - } - [TestMethod] - public void Test_3549() - { - } - [TestMethod] - public void Test_3550() - { - } - [TestMethod] - public void Test_3551() - { - } - [TestMethod] - public void Test_3552() - { - } - [TestMethod] - public void Test_3553() - { - } - [TestMethod] - public void Test_3554() - { - } - [TestMethod] - public void Test_3555() - { - } - [TestMethod] - public void Test_3556() - { - } - [TestMethod] - public void Test_3557() - { - } - [TestMethod] - public void Test_3558() - { - } - [TestMethod] - public void Test_3559() - { - } - [TestMethod] - public void Test_3560() - { - } - [TestMethod] - public void Test_3561() - { - } - [TestMethod] - public void Test_3562() - { - } - [TestMethod] - public void Test_3563() - { - } - [TestMethod] - public void Test_3564() - { - } - [TestMethod] - public void Test_3565() - { - } - [TestMethod] - public void Test_3566() - { - } - [TestMethod] - public void Test_3567() - { - } - [TestMethod] - public void Test_3568() - { - } - [TestMethod] - public void Test_3569() - { - } - [TestMethod] - public void Test_3570() - { - } - [TestMethod] - public void Test_3571() - { - } - [TestMethod] - public void Test_3572() - { - } - [TestMethod] - public void Test_3573() - { - } - [TestMethod] - public void Test_3574() - { - } - [TestMethod] - public void Test_3575() - { - } - [TestMethod] - public void Test_3576() - { - } - [TestMethod] - public void Test_3577() - { - } - [TestMethod] - public void Test_3578() - { - } - [TestMethod] - public void Test_3579() - { - } - [TestMethod] - public void Test_3580() - { - } - [TestMethod] - public void Test_3581() - { - } - [TestMethod] - public void Test_3582() - { - } - [TestMethod] - public void Test_3583() - { - } - [TestMethod] - public void Test_3584() - { - } - [TestMethod] - public void Test_3585() - { - } - [TestMethod] - public void Test_3586() - { - } - [TestMethod] - public void Test_3587() - { - } - [TestMethod] - public void Test_3588() - { - } - [TestMethod] - public void Test_3589() - { - } - [TestMethod] - public void Test_3590() - { - } - [TestMethod] - public void Test_3591() - { - } - [TestMethod] - public void Test_3592() - { - } - [TestMethod] - public void Test_3593() - { - } - [TestMethod] - public void Test_3594() - { - } - [TestMethod] - public void Test_3595() - { - } - [TestMethod] - public void Test_3596() - { - } - [TestMethod] - public void Test_3597() - { - } - [TestMethod] - public void Test_3598() - { - } - [TestMethod] - public void Test_3599() - { - } - [TestMethod] - public void Test_3600() - { - } - [TestMethod] - public void Test_3601() - { - } - [TestMethod] - public void Test_3602() - { - } - [TestMethod] - public void Test_3603() - { - } - [TestMethod] - public void Test_3604() - { - } - [TestMethod] - public void Test_3605() - { - } - [TestMethod] - public void Test_3606() - { - } - [TestMethod] - public void Test_3607() - { - } - [TestMethod] - public void Test_3608() - { - } - [TestMethod] - public void Test_3609() - { - } - [TestMethod] - public void Test_3610() - { - } - [TestMethod] - public void Test_3611() - { - } - [TestMethod] - public void Test_3612() - { - } - [TestMethod] - public void Test_3613() - { - } - [TestMethod] - public void Test_3614() - { - } - [TestMethod] - public void Test_3615() - { - } - [TestMethod] - public void Test_3616() - { - } - [TestMethod] - public void Test_3617() - { - } - [TestMethod] - public void Test_3618() - { - } - [TestMethod] - public void Test_3619() - { - } - [TestMethod] - public void Test_3620() - { - } - [TestMethod] - public void Test_3621() - { - } - [TestMethod] - public void Test_3622() - { - } - [TestMethod] - public void Test_3623() - { - } - [TestMethod] - public void Test_3624() - { - } - [TestMethod] - public void Test_3625() - { - } - [TestMethod] - public void Test_3626() - { - } - [TestMethod] - public void Test_3627() - { - } - [TestMethod] - public void Test_3628() - { - } - [TestMethod] - public void Test_3629() - { - } - [TestMethod] - public void Test_3630() - { - } - [TestMethod] - public void Test_3631() - { - } - [TestMethod] - public void Test_3632() - { - } - [TestMethod] - public void Test_3633() - { - } - [TestMethod] - public void Test_3634() - { - } - [TestMethod] - public void Test_3635() - { - } - [TestMethod] - public void Test_3636() - { - } - [TestMethod] - public void Test_3637() - { - } - [TestMethod] - public void Test_3638() - { - } - [TestMethod] - public void Test_3639() - { - } - [TestMethod] - public void Test_3640() - { - } - [TestMethod] - public void Test_3641() - { - } - [TestMethod] - public void Test_3642() - { - } - [TestMethod] - public void Test_3643() - { - } - [TestMethod] - public void Test_3644() - { - } - [TestMethod] - public void Test_3645() - { - } - [TestMethod] - public void Test_3646() - { - } - [TestMethod] - public void Test_3647() - { - } - [TestMethod] - public void Test_3648() - { - } - [TestMethod] - public void Test_3649() - { - } - [TestMethod] - public void Test_3650() - { - } - [TestMethod] - public void Test_3651() - { - } - [TestMethod] - public void Test_3652() - { - } - [TestMethod] - public void Test_3653() - { - } - [TestMethod] - public void Test_3654() - { - } - [TestMethod] - public void Test_3655() - { - } - [TestMethod] - public void Test_3656() - { - } - [TestMethod] - public void Test_3657() - { - } - [TestMethod] - public void Test_3658() - { - } - [TestMethod] - public void Test_3659() - { - } - [TestMethod] - public void Test_3660() - { - } - [TestMethod] - public void Test_3661() - { - } - [TestMethod] - public void Test_3662() - { - } - [TestMethod] - public void Test_3663() - { - } - [TestMethod] - public void Test_3664() - { - } - [TestMethod] - public void Test_3665() - { - } - [TestMethod] - public void Test_3666() - { - } - [TestMethod] - public void Test_3667() - { - } - [TestMethod] - public void Test_3668() - { - } - [TestMethod] - public void Test_3669() - { - } - [TestMethod] - public void Test_3670() - { - } - [TestMethod] - public void Test_3671() - { - } - [TestMethod] - public void Test_3672() - { - } - [TestMethod] - public void Test_3673() - { - } - [TestMethod] - public void Test_3674() - { - } - [TestMethod] - public void Test_3675() - { - } - [TestMethod] - public void Test_3676() - { - } - [TestMethod] - public void Test_3677() - { - } - [TestMethod] - public void Test_3678() - { - } - [TestMethod] - public void Test_3679() - { - } - [TestMethod] - public void Test_3680() - { - } - [TestMethod] - public void Test_3681() - { - } - [TestMethod] - public void Test_3682() - { - } - [TestMethod] - public void Test_3683() - { - } - [TestMethod] - public void Test_3684() - { - } - [TestMethod] - public void Test_3685() - { - } - [TestMethod] - public void Test_3686() - { - } - [TestMethod] - public void Test_3687() - { - } - [TestMethod] - public void Test_3688() - { - } - [TestMethod] - public void Test_3689() - { - } - [TestMethod] - public void Test_3690() - { - } - [TestMethod] - public void Test_3691() - { - } - [TestMethod] - public void Test_3692() - { - } - [TestMethod] - public void Test_3693() - { - } - [TestMethod] - public void Test_3694() - { - } - [TestMethod] - public void Test_3695() - { - } - [TestMethod] - public void Test_3696() - { - } - [TestMethod] - public void Test_3697() - { - } - [TestMethod] - public void Test_3698() - { - } - [TestMethod] - public void Test_3699() - { - } - [TestMethod] - public void Test_3700() - { - } - [TestMethod] - public void Test_3701() - { - } - [TestMethod] - public void Test_3702() - { - } - [TestMethod] - public void Test_3703() - { - } - [TestMethod] - public void Test_3704() - { - } - [TestMethod] - public void Test_3705() - { - } - [TestMethod] - public void Test_3706() - { - } - [TestMethod] - public void Test_3707() - { - } - [TestMethod] - public void Test_3708() - { - } - [TestMethod] - public void Test_3709() - { - } - [TestMethod] - public void Test_3710() - { - } - [TestMethod] - public void Test_3711() - { - } - [TestMethod] - public void Test_3712() - { - } - [TestMethod] - public void Test_3713() - { - } - [TestMethod] - public void Test_3714() - { - } - [TestMethod] - public void Test_3715() - { - } - [TestMethod] - public void Test_3716() - { - } - [TestMethod] - public void Test_3717() - { - } - [TestMethod] - public void Test_3718() - { - } - [TestMethod] - public void Test_3719() - { - } - [TestMethod] - public void Test_3720() - { - } - [TestMethod] - public void Test_3721() - { - } - [TestMethod] - public void Test_3722() - { - } - [TestMethod] - public void Test_3723() - { - } - [TestMethod] - public void Test_3724() - { - } - [TestMethod] - public void Test_3725() - { - } - [TestMethod] - public void Test_3726() - { - } - [TestMethod] - public void Test_3727() - { - } - [TestMethod] - public void Test_3728() - { - } - [TestMethod] - public void Test_3729() - { - } - [TestMethod] - public void Test_3730() - { - } - [TestMethod] - public void Test_3731() - { - } - [TestMethod] - public void Test_3732() - { - } - [TestMethod] - public void Test_3733() - { - } - [TestMethod] - public void Test_3734() - { - } - [TestMethod] - public void Test_3735() - { - } - [TestMethod] - public void Test_3736() - { - } - [TestMethod] - public void Test_3737() - { - } - [TestMethod] - public void Test_3738() - { - } - [TestMethod] - public void Test_3739() - { - } - [TestMethod] - public void Test_3740() - { - } - [TestMethod] - public void Test_3741() - { - } - [TestMethod] - public void Test_3742() - { - } - [TestMethod] - public void Test_3743() - { - } - [TestMethod] - public void Test_3744() - { - } - [TestMethod] - public void Test_3745() - { - } - [TestMethod] - public void Test_3746() - { - } - [TestMethod] - public void Test_3747() - { - } - [TestMethod] - public void Test_3748() - { - } - [TestMethod] - public void Test_3749() - { - } - [TestMethod] - public void Test_3750() - { - } - [TestMethod] - public void Test_3751() - { - } - [TestMethod] - public void Test_3752() - { - } - [TestMethod] - public void Test_3753() - { - } - [TestMethod] - public void Test_3754() - { - } - [TestMethod] - public void Test_3755() - { - } - [TestMethod] - public void Test_3756() - { - } - [TestMethod] - public void Test_3757() - { - } - [TestMethod] - public void Test_3758() - { - } - [TestMethod] - public void Test_3759() - { - } - [TestMethod] - public void Test_3760() - { - } - [TestMethod] - public void Test_3761() - { - } - [TestMethod] - public void Test_3762() - { - } - [TestMethod] - public void Test_3763() - { - } - [TestMethod] - public void Test_3764() - { - } - [TestMethod] - public void Test_3765() - { - } - [TestMethod] - public void Test_3766() - { - } - [TestMethod] - public void Test_3767() - { - } - [TestMethod] - public void Test_3768() - { - } - [TestMethod] - public void Test_3769() - { - } - [TestMethod] - public void Test_3770() - { - } - [TestMethod] - public void Test_3771() - { - } - [TestMethod] - public void Test_3772() - { - } - [TestMethod] - public void Test_3773() - { - } - [TestMethod] - public void Test_3774() - { - } - [TestMethod] - public void Test_3775() - { - } - [TestMethod] - public void Test_3776() - { - } - [TestMethod] - public void Test_3777() - { - } - [TestMethod] - public void Test_3778() - { - } - [TestMethod] - public void Test_3779() - { - } - [TestMethod] - public void Test_3780() - { - } - [TestMethod] - public void Test_3781() - { - } - [TestMethod] - public void Test_3782() - { - } - [TestMethod] - public void Test_3783() - { - } - [TestMethod] - public void Test_3784() - { - } - [TestMethod] - public void Test_3785() - { - } - [TestMethod] - public void Test_3786() - { - } - [TestMethod] - public void Test_3787() - { - } - [TestMethod] - public void Test_3788() - { - } - [TestMethod] - public void Test_3789() - { - } - [TestMethod] - public void Test_3790() - { - } - [TestMethod] - public void Test_3791() - { - } - [TestMethod] - public void Test_3792() - { - } - [TestMethod] - public void Test_3793() - { - } - [TestMethod] - public void Test_3794() - { - } - [TestMethod] - public void Test_3795() - { - } - [TestMethod] - public void Test_3796() - { - } - [TestMethod] - public void Test_3797() - { - } - [TestMethod] - public void Test_3798() - { - } - [TestMethod] - public void Test_3799() - { - } - [TestMethod] - public void Test_3800() - { - } - [TestMethod] - public void Test_3801() - { - } - [TestMethod] - public void Test_3802() - { - } - [TestMethod] - public void Test_3803() - { - } - [TestMethod] - public void Test_3804() - { - } - [TestMethod] - public void Test_3805() - { - } - [TestMethod] - public void Test_3806() - { - } - [TestMethod] - public void Test_3807() - { - } - [TestMethod] - public void Test_3808() - { - } - [TestMethod] - public void Test_3809() - { - } - [TestMethod] - public void Test_3810() - { - } - [TestMethod] - public void Test_3811() - { - } - [TestMethod] - public void Test_3812() - { - } - [TestMethod] - public void Test_3813() - { - } - [TestMethod] - public void Test_3814() - { - } - [TestMethod] - public void Test_3815() - { - } - [TestMethod] - public void Test_3816() - { - } - [TestMethod] - public void Test_3817() - { - } - [TestMethod] - public void Test_3818() - { - } - [TestMethod] - public void Test_3819() - { - } - [TestMethod] - public void Test_3820() - { - } - [TestMethod] - public void Test_3821() - { - } - [TestMethod] - public void Test_3822() - { - } - [TestMethod] - public void Test_3823() - { - } - [TestMethod] - public void Test_3824() - { - } - [TestMethod] - public void Test_3825() - { - } - [TestMethod] - public void Test_3826() - { - } - [TestMethod] - public void Test_3827() - { - } - [TestMethod] - public void Test_3828() - { - } - [TestMethod] - public void Test_3829() - { - } - [TestMethod] - public void Test_3830() - { - } - [TestMethod] - public void Test_3831() - { - } - [TestMethod] - public void Test_3832() - { - } - [TestMethod] - public void Test_3833() - { - } - [TestMethod] - public void Test_3834() - { - } - [TestMethod] - public void Test_3835() - { - } - [TestMethod] - public void Test_3836() - { - } - [TestMethod] - public void Test_3837() - { - } - [TestMethod] - public void Test_3838() - { - } - [TestMethod] - public void Test_3839() - { - } - [TestMethod] - public void Test_3840() - { - } - [TestMethod] - public void Test_3841() - { - } - [TestMethod] - public void Test_3842() - { - } - [TestMethod] - public void Test_3843() - { - } - [TestMethod] - public void Test_3844() - { - } - [TestMethod] - public void Test_3845() - { - } - [TestMethod] - public void Test_3846() - { - } - [TestMethod] - public void Test_3847() - { - } - [TestMethod] - public void Test_3848() - { - } - [TestMethod] - public void Test_3849() - { - } - [TestMethod] - public void Test_3850() - { - } - [TestMethod] - public void Test_3851() - { - } - [TestMethod] - public void Test_3852() - { - } - [TestMethod] - public void Test_3853() - { - } - [TestMethod] - public void Test_3854() - { - } - [TestMethod] - public void Test_3855() - { - } - [TestMethod] - public void Test_3856() - { - } - [TestMethod] - public void Test_3857() - { - } - [TestMethod] - public void Test_3858() - { - } - [TestMethod] - public void Test_3859() - { - } - [TestMethod] - public void Test_3860() - { - } - [TestMethod] - public void Test_3861() - { - } - [TestMethod] - public void Test_3862() - { - } - [TestMethod] - public void Test_3863() - { - } - [TestMethod] - public void Test_3864() - { - } - [TestMethod] - public void Test_3865() - { - } - [TestMethod] - public void Test_3866() - { - } - [TestMethod] - public void Test_3867() - { - } - [TestMethod] - public void Test_3868() - { - } - [TestMethod] - public void Test_3869() - { - } - [TestMethod] - public void Test_3870() - { - } - [TestMethod] - public void Test_3871() - { - } - [TestMethod] - public void Test_3872() - { - } - [TestMethod] - public void Test_3873() - { - } - [TestMethod] - public void Test_3874() - { - } - [TestMethod] - public void Test_3875() - { - } - [TestMethod] - public void Test_3876() - { - } - [TestMethod] - public void Test_3877() - { - } - [TestMethod] - public void Test_3878() - { - } - [TestMethod] - public void Test_3879() - { - } - [TestMethod] - public void Test_3880() - { - } - [TestMethod] - public void Test_3881() - { - } - [TestMethod] - public void Test_3882() - { - } - [TestMethod] - public void Test_3883() - { - } - [TestMethod] - public void Test_3884() - { - } - [TestMethod] - public void Test_3885() - { - } - [TestMethod] - public void Test_3886() - { - } - [TestMethod] - public void Test_3887() - { - } - [TestMethod] - public void Test_3888() - { - } - [TestMethod] - public void Test_3889() - { - } - [TestMethod] - public void Test_3890() - { - } - [TestMethod] - public void Test_3891() - { - } - [TestMethod] - public void Test_3892() - { - } - [TestMethod] - public void Test_3893() - { - } - [TestMethod] - public void Test_3894() - { - } - [TestMethod] - public void Test_3895() - { - } - [TestMethod] - public void Test_3896() - { - } - [TestMethod] - public void Test_3897() - { - } - [TestMethod] - public void Test_3898() - { - } - [TestMethod] - public void Test_3899() - { - } - [TestMethod] - public void Test_3900() - { - } - [TestMethod] - public void Test_3901() - { - } - [TestMethod] - public void Test_3902() - { - } - [TestMethod] - public void Test_3903() - { - } - [TestMethod] - public void Test_3904() - { - } - [TestMethod] - public void Test_3905() - { - } - [TestMethod] - public void Test_3906() - { - } - [TestMethod] - public void Test_3907() - { - } - [TestMethod] - public void Test_3908() - { - } - [TestMethod] - public void Test_3909() - { - } - [TestMethod] - public void Test_3910() - { - } - [TestMethod] - public void Test_3911() - { - } - [TestMethod] - public void Test_3912() - { - } - [TestMethod] - public void Test_3913() - { - } - [TestMethod] - public void Test_3914() - { - } - [TestMethod] - public void Test_3915() - { - } - [TestMethod] - public void Test_3916() - { - } - [TestMethod] - public void Test_3917() - { - } - [TestMethod] - public void Test_3918() - { - } - [TestMethod] - public void Test_3919() - { - } - [TestMethod] - public void Test_3920() - { - } - [TestMethod] - public void Test_3921() - { - } - [TestMethod] - public void Test_3922() - { - } - [TestMethod] - public void Test_3923() - { - } - [TestMethod] - public void Test_3924() - { - } - [TestMethod] - public void Test_3925() - { - } - [TestMethod] - public void Test_3926() - { - } - [TestMethod] - public void Test_3927() - { - } - [TestMethod] - public void Test_3928() - { - } - [TestMethod] - public void Test_3929() - { - } - [TestMethod] - public void Test_3930() - { - } - [TestMethod] - public void Test_3931() - { - } - [TestMethod] - public void Test_3932() - { - } - [TestMethod] - public void Test_3933() - { - } - [TestMethod] - public void Test_3934() - { - } - [TestMethod] - public void Test_3935() - { - } - [TestMethod] - public void Test_3936() - { - } - [TestMethod] - public void Test_3937() - { - } - [TestMethod] - public void Test_3938() - { - } - [TestMethod] - public void Test_3939() - { - } - [TestMethod] - public void Test_3940() - { - } - [TestMethod] - public void Test_3941() - { - } - [TestMethod] - public void Test_3942() - { - } - [TestMethod] - public void Test_3943() - { - } - [TestMethod] - public void Test_3944() - { - } - [TestMethod] - public void Test_3945() - { - } - [TestMethod] - public void Test_3946() - { - } - [TestMethod] - public void Test_3947() - { - } - [TestMethod] - public void Test_3948() - { - } - [TestMethod] - public void Test_3949() - { - } - [TestMethod] - public void Test_3950() - { - } - [TestMethod] - public void Test_3951() - { - } - [TestMethod] - public void Test_3952() - { - } - [TestMethod] - public void Test_3953() - { - } - [TestMethod] - public void Test_3954() - { - } - [TestMethod] - public void Test_3955() - { - } - [TestMethod] - public void Test_3956() - { - } - [TestMethod] - public void Test_3957() - { - } - [TestMethod] - public void Test_3958() - { - } - [TestMethod] - public void Test_3959() - { - } - [TestMethod] - public void Test_3960() - { - } - [TestMethod] - public void Test_3961() - { - } - [TestMethod] - public void Test_3962() - { - } - [TestMethod] - public void Test_3963() - { - } - [TestMethod] - public void Test_3964() - { - } - [TestMethod] - public void Test_3965() - { - } - [TestMethod] - public void Test_3966() - { - } - [TestMethod] - public void Test_3967() - { - } - [TestMethod] - public void Test_3968() - { - } - [TestMethod] - public void Test_3969() - { - } - [TestMethod] - public void Test_3970() - { - } - [TestMethod] - public void Test_3971() - { - } - [TestMethod] - public void Test_3972() - { - } - [TestMethod] - public void Test_3973() - { - } - [TestMethod] - public void Test_3974() - { - } - [TestMethod] - public void Test_3975() - { - } - [TestMethod] - public void Test_3976() - { - } - [TestMethod] - public void Test_3977() - { - } - [TestMethod] - public void Test_3978() - { - } - [TestMethod] - public void Test_3979() - { - } - [TestMethod] - public void Test_3980() - { - } - [TestMethod] - public void Test_3981() - { - } - [TestMethod] - public void Test_3982() - { - } - [TestMethod] - public void Test_3983() - { - } - [TestMethod] - public void Test_3984() - { - } - [TestMethod] - public void Test_3985() - { - } - [TestMethod] - public void Test_3986() - { - } - [TestMethod] - public void Test_3987() - { - } - [TestMethod] - public void Test_3988() - { - } - [TestMethod] - public void Test_3989() - { - } - [TestMethod] - public void Test_3990() - { - } - [TestMethod] - public void Test_3991() - { - } - [TestMethod] - public void Test_3992() - { - } - [TestMethod] - public void Test_3993() - { - } - [TestMethod] - public void Test_3994() - { - } - [TestMethod] - public void Test_3995() - { - } - [TestMethod] - public void Test_3996() - { - } - [TestMethod] - public void Test_3997() - { - } - [TestMethod] - public void Test_3998() - { - } - [TestMethod] - public void Test_3999() - { - } - [TestMethod] - public void Test_4000() - { - } - [TestMethod] - public void Test_4001() - { - } - [TestMethod] - public void Test_4002() - { - } - [TestMethod] - public void Test_4003() - { - } - [TestMethod] - public void Test_4004() - { - } - [TestMethod] - public void Test_4005() - { - } - [TestMethod] - public void Test_4006() - { - } - [TestMethod] - public void Test_4007() - { - } - [TestMethod] - public void Test_4008() - { - } - [TestMethod] - public void Test_4009() - { - } - [TestMethod] - public void Test_4010() - { - } - [TestMethod] - public void Test_4011() - { - } - [TestMethod] - public void Test_4012() - { - } - [TestMethod] - public void Test_4013() - { - } - [TestMethod] - public void Test_4014() - { - } - [TestMethod] - public void Test_4015() - { - } - [TestMethod] - public void Test_4016() - { - } - [TestMethod] - public void Test_4017() - { - } - [TestMethod] - public void Test_4018() - { - } - [TestMethod] - public void Test_4019() - { - } - [TestMethod] - public void Test_4020() - { - } - [TestMethod] - public void Test_4021() - { - } - [TestMethod] - public void Test_4022() - { - } - [TestMethod] - public void Test_4023() - { - } - [TestMethod] - public void Test_4024() - { - } - [TestMethod] - public void Test_4025() - { - } - [TestMethod] - public void Test_4026() - { - } - [TestMethod] - public void Test_4027() - { - } - [TestMethod] - public void Test_4028() - { - } - [TestMethod] - public void Test_4029() - { - } - [TestMethod] - public void Test_4030() - { - } - [TestMethod] - public void Test_4031() - { - } - [TestMethod] - public void Test_4032() - { - } - [TestMethod] - public void Test_4033() - { - } - [TestMethod] - public void Test_4034() - { - } - [TestMethod] - public void Test_4035() - { - } - [TestMethod] - public void Test_4036() - { - } - [TestMethod] - public void Test_4037() - { - } - [TestMethod] - public void Test_4038() - { - } - [TestMethod] - public void Test_4039() - { - } - [TestMethod] - public void Test_4040() - { - } - [TestMethod] - public void Test_4041() - { - } - [TestMethod] - public void Test_4042() - { - } - [TestMethod] - public void Test_4043() - { - } - [TestMethod] - public void Test_4044() - { - } - [TestMethod] - public void Test_4045() - { - } - [TestMethod] - public void Test_4046() - { - } - [TestMethod] - public void Test_4047() - { - } - [TestMethod] - public void Test_4048() - { - } - [TestMethod] - public void Test_4049() - { - } - [TestMethod] - public void Test_4050() - { - } - [TestMethod] - public void Test_4051() - { - } - [TestMethod] - public void Test_4052() - { - } - [TestMethod] - public void Test_4053() - { - } - [TestMethod] - public void Test_4054() - { - } - [TestMethod] - public void Test_4055() - { - } - [TestMethod] - public void Test_4056() - { - } - [TestMethod] - public void Test_4057() - { - } - [TestMethod] - public void Test_4058() - { - } - [TestMethod] - public void Test_4059() - { - } - [TestMethod] - public void Test_4060() - { - } - [TestMethod] - public void Test_4061() - { - } - [TestMethod] - public void Test_4062() - { - } - [TestMethod] - public void Test_4063() - { - } - [TestMethod] - public void Test_4064() - { - } - [TestMethod] - public void Test_4065() - { - } - [TestMethod] - public void Test_4066() - { - } - [TestMethod] - public void Test_4067() - { - } - [TestMethod] - public void Test_4068() - { - } - [TestMethod] - public void Test_4069() - { - } - [TestMethod] - public void Test_4070() - { - } - [TestMethod] - public void Test_4071() - { - } - [TestMethod] - public void Test_4072() - { - } - [TestMethod] - public void Test_4073() - { - } - [TestMethod] - public void Test_4074() - { - } - [TestMethod] - public void Test_4075() - { - } - [TestMethod] - public void Test_4076() - { - } - [TestMethod] - public void Test_4077() - { - } - [TestMethod] - public void Test_4078() - { - } - [TestMethod] - public void Test_4079() - { - } - [TestMethod] - public void Test_4080() - { - } - [TestMethod] - public void Test_4081() - { - } - [TestMethod] - public void Test_4082() - { - } - [TestMethod] - public void Test_4083() - { - } - [TestMethod] - public void Test_4084() - { - } - [TestMethod] - public void Test_4085() - { - } - [TestMethod] - public void Test_4086() - { - } - [TestMethod] - public void Test_4087() - { - } - [TestMethod] - public void Test_4088() - { - } - [TestMethod] - public void Test_4089() - { - } - [TestMethod] - public void Test_4090() - { - } - [TestMethod] - public void Test_4091() - { - } - [TestMethod] - public void Test_4092() - { - } - [TestMethod] - public void Test_4093() - { - } - [TestMethod] - public void Test_4094() - { - } - [TestMethod] - public void Test_4095() - { - } - [TestMethod] - public void Test_4096() - { - } - [TestMethod] - public void Test_4097() - { - } - [TestMethod] - public void Test_4098() - { - } - [TestMethod] - public void Test_4099() - { - } - [TestMethod] - public void Test_4100() - { - } - [TestMethod] - public void Test_4101() - { - } - [TestMethod] - public void Test_4102() - { - } - [TestMethod] - public void Test_4103() - { - } - [TestMethod] - public void Test_4104() - { - } - [TestMethod] - public void Test_4105() - { - } - [TestMethod] - public void Test_4106() - { - } - [TestMethod] - public void Test_4107() - { - } - [TestMethod] - public void Test_4108() - { - } - [TestMethod] - public void Test_4109() - { - } - [TestMethod] - public void Test_4110() - { - } - [TestMethod] - public void Test_4111() - { - } - [TestMethod] - public void Test_4112() - { - } - [TestMethod] - public void Test_4113() - { - } - [TestMethod] - public void Test_4114() - { - } - [TestMethod] - public void Test_4115() - { - } - [TestMethod] - public void Test_4116() - { - } - [TestMethod] - public void Test_4117() - { - } - [TestMethod] - public void Test_4118() - { - } - [TestMethod] - public void Test_4119() - { - } - [TestMethod] - public void Test_4120() - { - } - [TestMethod] - public void Test_4121() - { - } - [TestMethod] - public void Test_4122() - { - } - [TestMethod] - public void Test_4123() - { - } - [TestMethod] - public void Test_4124() - { - } - [TestMethod] - public void Test_4125() - { - } - [TestMethod] - public void Test_4126() - { - } - [TestMethod] - public void Test_4127() - { - } - [TestMethod] - public void Test_4128() - { - } - [TestMethod] - public void Test_4129() - { - } - [TestMethod] - public void Test_4130() - { - } - [TestMethod] - public void Test_4131() - { - } - [TestMethod] - public void Test_4132() - { - } - [TestMethod] - public void Test_4133() - { - } - [TestMethod] - public void Test_4134() - { - } - [TestMethod] - public void Test_4135() - { - } - [TestMethod] - public void Test_4136() - { - } - [TestMethod] - public void Test_4137() - { - } - [TestMethod] - public void Test_4138() - { - } - [TestMethod] - public void Test_4139() - { - } - [TestMethod] - public void Test_4140() - { - } - [TestMethod] - public void Test_4141() - { - } - [TestMethod] - public void Test_4142() - { - } - [TestMethod] - public void Test_4143() - { - } - [TestMethod] - public void Test_4144() - { - } - [TestMethod] - public void Test_4145() - { - } - [TestMethod] - public void Test_4146() - { - } - [TestMethod] - public void Test_4147() - { - } - [TestMethod] - public void Test_4148() - { - } - [TestMethod] - public void Test_4149() - { - } - [TestMethod] - public void Test_4150() - { - } - [TestMethod] - public void Test_4151() - { - } - [TestMethod] - public void Test_4152() - { - } - [TestMethod] - public void Test_4153() - { - } - [TestMethod] - public void Test_4154() - { - } - [TestMethod] - public void Test_4155() - { - } - [TestMethod] - public void Test_4156() - { - } - [TestMethod] - public void Test_4157() - { - } - [TestMethod] - public void Test_4158() - { - } - [TestMethod] - public void Test_4159() - { - } - [TestMethod] - public void Test_4160() - { - } - [TestMethod] - public void Test_4161() - { - } - [TestMethod] - public void Test_4162() - { - } - [TestMethod] - public void Test_4163() - { - } - [TestMethod] - public void Test_4164() - { - } - [TestMethod] - public void Test_4165() - { - } - [TestMethod] - public void Test_4166() - { - } - [TestMethod] - public void Test_4167() - { - } - [TestMethod] - public void Test_4168() - { - } - [TestMethod] - public void Test_4169() - { - } - [TestMethod] - public void Test_4170() - { - } - [TestMethod] - public void Test_4171() - { - } - [TestMethod] - public void Test_4172() - { - } - [TestMethod] - public void Test_4173() - { - } - [TestMethod] - public void Test_4174() - { - } - [TestMethod] - public void Test_4175() - { - } - [TestMethod] - public void Test_4176() - { - } - [TestMethod] - public void Test_4177() - { - } - [TestMethod] - public void Test_4178() - { - } - [TestMethod] - public void Test_4179() - { - } - [TestMethod] - public void Test_4180() - { - } - [TestMethod] - public void Test_4181() - { - } - [TestMethod] - public void Test_4182() - { - } - [TestMethod] - public void Test_4183() - { - } - [TestMethod] - public void Test_4184() - { - } - [TestMethod] - public void Test_4185() - { - } - [TestMethod] - public void Test_4186() - { - } - [TestMethod] - public void Test_4187() - { - } - [TestMethod] - public void Test_4188() - { - } - [TestMethod] - public void Test_4189() - { - } - [TestMethod] - public void Test_4190() - { - } - [TestMethod] - public void Test_4191() - { - } - [TestMethod] - public void Test_4192() - { - } - [TestMethod] - public void Test_4193() - { - } - [TestMethod] - public void Test_4194() - { - } - [TestMethod] - public void Test_4195() - { - } - [TestMethod] - public void Test_4196() - { - } - [TestMethod] - public void Test_4197() - { - } - [TestMethod] - public void Test_4198() - { - } - [TestMethod] - public void Test_4199() - { - } - [TestMethod] - public void Test_4200() - { - } - [TestMethod] - public void Test_4201() - { - } - [TestMethod] - public void Test_4202() - { - } - [TestMethod] - public void Test_4203() - { - } - [TestMethod] - public void Test_4204() - { - } - [TestMethod] - public void Test_4205() - { - } - [TestMethod] - public void Test_4206() - { - } - [TestMethod] - public void Test_4207() - { - } - [TestMethod] - public void Test_4208() - { - } - [TestMethod] - public void Test_4209() - { - } - [TestMethod] - public void Test_4210() - { - } - [TestMethod] - public void Test_4211() - { - } - [TestMethod] - public void Test_4212() - { - } - [TestMethod] - public void Test_4213() - { - } - [TestMethod] - public void Test_4214() - { - } - [TestMethod] - public void Test_4215() - { - } - [TestMethod] - public void Test_4216() - { - } - [TestMethod] - public void Test_4217() - { - } - [TestMethod] - public void Test_4218() - { - } - [TestMethod] - public void Test_4219() - { - } - [TestMethod] - public void Test_4220() - { - } - [TestMethod] - public void Test_4221() - { - } - [TestMethod] - public void Test_4222() - { - } - [TestMethod] - public void Test_4223() - { - } - [TestMethod] - public void Test_4224() - { - } - [TestMethod] - public void Test_4225() - { - } - [TestMethod] - public void Test_4226() - { - } - [TestMethod] - public void Test_4227() - { - } - [TestMethod] - public void Test_4228() - { - } - [TestMethod] - public void Test_4229() - { - } - [TestMethod] - public void Test_4230() - { - } - [TestMethod] - public void Test_4231() - { - } - [TestMethod] - public void Test_4232() - { - } - [TestMethod] - public void Test_4233() - { - } - [TestMethod] - public void Test_4234() - { - } - [TestMethod] - public void Test_4235() - { - } - [TestMethod] - public void Test_4236() - { - } - [TestMethod] - public void Test_4237() - { - } - [TestMethod] - public void Test_4238() - { - } - [TestMethod] - public void Test_4239() - { - } - [TestMethod] - public void Test_4240() - { - } - [TestMethod] - public void Test_4241() - { - } - [TestMethod] - public void Test_4242() - { - } - [TestMethod] - public void Test_4243() - { - } - [TestMethod] - public void Test_4244() - { - } - [TestMethod] - public void Test_4245() - { - } - [TestMethod] - public void Test_4246() - { - } - [TestMethod] - public void Test_4247() - { - } - [TestMethod] - public void Test_4248() - { - } - [TestMethod] - public void Test_4249() - { - } - [TestMethod] - public void Test_4250() - { - } - [TestMethod] - public void Test_4251() - { - } - [TestMethod] - public void Test_4252() - { - } - [TestMethod] - public void Test_4253() - { - } - [TestMethod] - public void Test_4254() - { - } - [TestMethod] - public void Test_4255() - { - } - [TestMethod] - public void Test_4256() - { - } - [TestMethod] - public void Test_4257() - { - } - [TestMethod] - public void Test_4258() - { - } - [TestMethod] - public void Test_4259() - { - } - [TestMethod] - public void Test_4260() - { - } - [TestMethod] - public void Test_4261() - { - } - [TestMethod] - public void Test_4262() - { - } - [TestMethod] - public void Test_4263() - { - } - [TestMethod] - public void Test_4264() - { - } - [TestMethod] - public void Test_4265() - { - } - [TestMethod] - public void Test_4266() - { - } - [TestMethod] - public void Test_4267() - { - } - [TestMethod] - public void Test_4268() - { - } - [TestMethod] - public void Test_4269() - { - } - [TestMethod] - public void Test_4270() - { - } - [TestMethod] - public void Test_4271() - { - } - [TestMethod] - public void Test_4272() - { - } - [TestMethod] - public void Test_4273() - { - } - [TestMethod] - public void Test_4274() - { - } - [TestMethod] - public void Test_4275() - { - } - [TestMethod] - public void Test_4276() - { - } - [TestMethod] - public void Test_4277() - { - } - [TestMethod] - public void Test_4278() - { - } - [TestMethod] - public void Test_4279() - { - } - [TestMethod] - public void Test_4280() - { - } - [TestMethod] - public void Test_4281() - { - } - [TestMethod] - public void Test_4282() - { - } - [TestMethod] - public void Test_4283() - { - } - [TestMethod] - public void Test_4284() - { - } - [TestMethod] - public void Test_4285() - { - } - [TestMethod] - public void Test_4286() - { - } - [TestMethod] - public void Test_4287() - { - } - [TestMethod] - public void Test_4288() - { - } - [TestMethod] - public void Test_4289() - { - } - [TestMethod] - public void Test_4290() - { - } - [TestMethod] - public void Test_4291() - { - } - [TestMethod] - public void Test_4292() - { - } - [TestMethod] - public void Test_4293() - { - } - [TestMethod] - public void Test_4294() - { - } - [TestMethod] - public void Test_4295() - { - } - [TestMethod] - public void Test_4296() - { - } - [TestMethod] - public void Test_4297() - { - } - [TestMethod] - public void Test_4298() - { - } - [TestMethod] - public void Test_4299() - { - } - [TestMethod] - public void Test_4300() - { - } - [TestMethod] - public void Test_4301() - { - } - [TestMethod] - public void Test_4302() - { - } - [TestMethod] - public void Test_4303() - { - } - [TestMethod] - public void Test_4304() - { - } - [TestMethod] - public void Test_4305() - { - } - [TestMethod] - public void Test_4306() - { - } - [TestMethod] - public void Test_4307() - { - } - [TestMethod] - public void Test_4308() - { - } - [TestMethod] - public void Test_4309() - { - } - [TestMethod] - public void Test_4310() - { - } - [TestMethod] - public void Test_4311() - { - } - [TestMethod] - public void Test_4312() - { - } - [TestMethod] - public void Test_4313() - { - } - [TestMethod] - public void Test_4314() - { - } - [TestMethod] - public void Test_4315() - { - } - [TestMethod] - public void Test_4316() - { - } - [TestMethod] - public void Test_4317() - { - } - [TestMethod] - public void Test_4318() - { - } - [TestMethod] - public void Test_4319() - { - } - [TestMethod] - public void Test_4320() - { - } - [TestMethod] - public void Test_4321() - { - } - [TestMethod] - public void Test_4322() - { - } - [TestMethod] - public void Test_4323() - { - } - [TestMethod] - public void Test_4324() - { - } - [TestMethod] - public void Test_4325() - { - } - [TestMethod] - public void Test_4326() - { - } - [TestMethod] - public void Test_4327() - { - } - [TestMethod] - public void Test_4328() - { - } - [TestMethod] - public void Test_4329() - { - } - [TestMethod] - public void Test_4330() - { - } - [TestMethod] - public void Test_4331() - { - } - [TestMethod] - public void Test_4332() - { - } - [TestMethod] - public void Test_4333() - { - } - [TestMethod] - public void Test_4334() - { - } - [TestMethod] - public void Test_4335() - { - } - [TestMethod] - public void Test_4336() - { - } - [TestMethod] - public void Test_4337() - { - } - [TestMethod] - public void Test_4338() - { - } - [TestMethod] - public void Test_4339() - { - } - [TestMethod] - public void Test_4340() - { - } - [TestMethod] - public void Test_4341() - { - } - [TestMethod] - public void Test_4342() - { - } - [TestMethod] - public void Test_4343() - { - } - [TestMethod] - public void Test_4344() - { - } - [TestMethod] - public void Test_4345() - { - } - [TestMethod] - public void Test_4346() - { - } - [TestMethod] - public void Test_4347() - { - } - [TestMethod] - public void Test_4348() - { - } - [TestMethod] - public void Test_4349() - { - } - [TestMethod] - public void Test_4350() - { - } - [TestMethod] - public void Test_4351() - { - } - [TestMethod] - public void Test_4352() - { - } - [TestMethod] - public void Test_4353() - { - } - [TestMethod] - public void Test_4354() - { - } - [TestMethod] - public void Test_4355() - { - } - [TestMethod] - public void Test_4356() - { - } - [TestMethod] - public void Test_4357() - { - } - [TestMethod] - public void Test_4358() - { - } - [TestMethod] - public void Test_4359() - { - } - [TestMethod] - public void Test_4360() - { - } - [TestMethod] - public void Test_4361() - { - } - [TestMethod] - public void Test_4362() - { - } - [TestMethod] - public void Test_4363() - { - } - [TestMethod] - public void Test_4364() - { - } - [TestMethod] - public void Test_4365() - { - } - [TestMethod] - public void Test_4366() - { - } - [TestMethod] - public void Test_4367() - { - } - [TestMethod] - public void Test_4368() - { - } - [TestMethod] - public void Test_4369() - { - } - [TestMethod] - public void Test_4370() - { - } - [TestMethod] - public void Test_4371() - { - } - [TestMethod] - public void Test_4372() - { - } - [TestMethod] - public void Test_4373() - { - } - [TestMethod] - public void Test_4374() - { - } - [TestMethod] - public void Test_4375() - { - } - [TestMethod] - public void Test_4376() - { - } - [TestMethod] - public void Test_4377() - { - } - [TestMethod] - public void Test_4378() - { - } - [TestMethod] - public void Test_4379() - { - } - [TestMethod] - public void Test_4380() - { - } - [TestMethod] - public void Test_4381() - { - } - [TestMethod] - public void Test_4382() - { - } - [TestMethod] - public void Test_4383() - { - } - [TestMethod] - public void Test_4384() - { - } - [TestMethod] - public void Test_4385() - { - } - [TestMethod] - public void Test_4386() - { - } - [TestMethod] - public void Test_4387() - { - } - [TestMethod] - public void Test_4388() - { - } - [TestMethod] - public void Test_4389() - { - } - [TestMethod] - public void Test_4390() - { - } - [TestMethod] - public void Test_4391() - { - } - [TestMethod] - public void Test_4392() - { - } - [TestMethod] - public void Test_4393() - { - } - [TestMethod] - public void Test_4394() - { - } - [TestMethod] - public void Test_4395() - { - } - [TestMethod] - public void Test_4396() - { - } - [TestMethod] - public void Test_4397() - { - } - [TestMethod] - public void Test_4398() - { - } - [TestMethod] - public void Test_4399() - { - } - [TestMethod] - public void Test_4400() - { - } - [TestMethod] - public void Test_4401() - { - } - [TestMethod] - public void Test_4402() - { - } - [TestMethod] - public void Test_4403() - { - } - [TestMethod] - public void Test_4404() - { - } - [TestMethod] - public void Test_4405() - { - } - [TestMethod] - public void Test_4406() - { - } - [TestMethod] - public void Test_4407() - { - } - [TestMethod] - public void Test_4408() - { - } - [TestMethod] - public void Test_4409() - { - } - [TestMethod] - public void Test_4410() - { - } - [TestMethod] - public void Test_4411() - { - } - [TestMethod] - public void Test_4412() - { - } - [TestMethod] - public void Test_4413() - { - } - [TestMethod] - public void Test_4414() - { - } - [TestMethod] - public void Test_4415() - { - } - [TestMethod] - public void Test_4416() - { - } - [TestMethod] - public void Test_4417() - { - } - [TestMethod] - public void Test_4418() - { - } - [TestMethod] - public void Test_4419() - { - } - [TestMethod] - public void Test_4420() - { - } - [TestMethod] - public void Test_4421() - { - } - [TestMethod] - public void Test_4422() - { - } - [TestMethod] - public void Test_4423() - { - } - [TestMethod] - public void Test_4424() - { - } - [TestMethod] - public void Test_4425() - { - } - [TestMethod] - public void Test_4426() - { - } - [TestMethod] - public void Test_4427() - { - } - [TestMethod] - public void Test_4428() - { - } - [TestMethod] - public void Test_4429() - { - } - [TestMethod] - public void Test_4430() - { - } - [TestMethod] - public void Test_4431() - { - } - [TestMethod] - public void Test_4432() - { - } - [TestMethod] - public void Test_4433() - { - } - [TestMethod] - public void Test_4434() - { - } - [TestMethod] - public void Test_4435() - { - } - [TestMethod] - public void Test_4436() - { - } - [TestMethod] - public void Test_4437() - { - } - [TestMethod] - public void Test_4438() - { - } - [TestMethod] - public void Test_4439() - { - } - [TestMethod] - public void Test_4440() - { - } - [TestMethod] - public void Test_4441() - { - } - [TestMethod] - public void Test_4442() - { - } - [TestMethod] - public void Test_4443() - { - } - [TestMethod] - public void Test_4444() - { - } - [TestMethod] - public void Test_4445() - { - } - [TestMethod] - public void Test_4446() - { - } - [TestMethod] - public void Test_4447() - { - } - [TestMethod] - public void Test_4448() - { - } - [TestMethod] - public void Test_4449() - { - } - [TestMethod] - public void Test_4450() - { - } - [TestMethod] - public void Test_4451() - { - } - [TestMethod] - public void Test_4452() - { - } - [TestMethod] - public void Test_4453() - { - } - [TestMethod] - public void Test_4454() - { - } - [TestMethod] - public void Test_4455() - { - } - [TestMethod] - public void Test_4456() - { - } - [TestMethod] - public void Test_4457() - { - } - [TestMethod] - public void Test_4458() - { - } - [TestMethod] - public void Test_4459() - { - } - [TestMethod] - public void Test_4460() - { - } - [TestMethod] - public void Test_4461() - { - } - [TestMethod] - public void Test_4462() - { - } - [TestMethod] - public void Test_4463() - { - } - [TestMethod] - public void Test_4464() - { - } - [TestMethod] - public void Test_4465() - { - } - [TestMethod] - public void Test_4466() - { - } - [TestMethod] - public void Test_4467() - { - } - [TestMethod] - public void Test_4468() - { - } - [TestMethod] - public void Test_4469() - { - } - [TestMethod] - public void Test_4470() - { - } - [TestMethod] - public void Test_4471() - { - } - [TestMethod] - public void Test_4472() - { - } - [TestMethod] - public void Test_4473() - { - } - [TestMethod] - public void Test_4474() - { - } - [TestMethod] - public void Test_4475() - { - } - [TestMethod] - public void Test_4476() - { - } - [TestMethod] - public void Test_4477() - { - } - [TestMethod] - public void Test_4478() - { - } - [TestMethod] - public void Test_4479() - { - } - [TestMethod] - public void Test_4480() - { - } - [TestMethod] - public void Test_4481() - { - } - [TestMethod] - public void Test_4482() - { - } - [TestMethod] - public void Test_4483() - { - } - [TestMethod] - public void Test_4484() - { - } - [TestMethod] - public void Test_4485() - { - } - [TestMethod] - public void Test_4486() - { - } - [TestMethod] - public void Test_4487() - { - } - [TestMethod] - public void Test_4488() - { - } - [TestMethod] - public void Test_4489() - { - } - [TestMethod] - public void Test_4490() - { - } - [TestMethod] - public void Test_4491() - { - } - [TestMethod] - public void Test_4492() - { - } - [TestMethod] - public void Test_4493() - { - } - [TestMethod] - public void Test_4494() - { - } - [TestMethod] - public void Test_4495() - { - } - [TestMethod] - public void Test_4496() - { - } - [TestMethod] - public void Test_4497() - { - } - [TestMethod] - public void Test_4498() - { - } - [TestMethod] - public void Test_4499() - { - } - [TestMethod] - public void Test_4500() - { - } - [TestMethod] - public void Test_4501() - { - } - [TestMethod] - public void Test_4502() - { - } - [TestMethod] - public void Test_4503() - { - } - [TestMethod] - public void Test_4504() - { - } - [TestMethod] - public void Test_4505() - { - } - [TestMethod] - public void Test_4506() - { - } - [TestMethod] - public void Test_4507() - { - } - [TestMethod] - public void Test_4508() - { - } - [TestMethod] - public void Test_4509() - { - } - [TestMethod] - public void Test_4510() - { - } - [TestMethod] - public void Test_4511() - { - } - [TestMethod] - public void Test_4512() - { - } - [TestMethod] - public void Test_4513() - { - } - [TestMethod] - public void Test_4514() - { - } - [TestMethod] - public void Test_4515() - { - } - [TestMethod] - public void Test_4516() - { - } - [TestMethod] - public void Test_4517() - { - } - [TestMethod] - public void Test_4518() - { - } - [TestMethod] - public void Test_4519() - { - } - [TestMethod] - public void Test_4520() - { - } - [TestMethod] - public void Test_4521() - { - } - [TestMethod] - public void Test_4522() - { - } - [TestMethod] - public void Test_4523() - { - } - [TestMethod] - public void Test_4524() - { - } - [TestMethod] - public void Test_4525() - { - } - [TestMethod] - public void Test_4526() - { - } - [TestMethod] - public void Test_4527() - { - } - [TestMethod] - public void Test_4528() - { - } - [TestMethod] - public void Test_4529() - { - } - [TestMethod] - public void Test_4530() - { - } - [TestMethod] - public void Test_4531() - { - } - [TestMethod] - public void Test_4532() - { - } - [TestMethod] - public void Test_4533() - { - } - [TestMethod] - public void Test_4534() - { - } - [TestMethod] - public void Test_4535() - { - } - [TestMethod] - public void Test_4536() - { - } - [TestMethod] - public void Test_4537() - { - } - [TestMethod] - public void Test_4538() - { - } - [TestMethod] - public void Test_4539() - { - } - [TestMethod] - public void Test_4540() - { - } - [TestMethod] - public void Test_4541() - { - } - [TestMethod] - public void Test_4542() - { - } - [TestMethod] - public void Test_4543() - { - } - [TestMethod] - public void Test_4544() - { - } - [TestMethod] - public void Test_4545() - { - } - [TestMethod] - public void Test_4546() - { - } - [TestMethod] - public void Test_4547() - { - } - [TestMethod] - public void Test_4548() - { - } - [TestMethod] - public void Test_4549() - { - } - [TestMethod] - public void Test_4550() - { - } - [TestMethod] - public void Test_4551() - { - } - [TestMethod] - public void Test_4552() - { - } - [TestMethod] - public void Test_4553() - { - } - [TestMethod] - public void Test_4554() - { - } - [TestMethod] - public void Test_4555() - { - } - [TestMethod] - public void Test_4556() - { - } - [TestMethod] - public void Test_4557() - { - } - [TestMethod] - public void Test_4558() - { - } - [TestMethod] - public void Test_4559() - { - } - [TestMethod] - public void Test_4560() - { - } - [TestMethod] - public void Test_4561() - { - } - [TestMethod] - public void Test_4562() - { - } - [TestMethod] - public void Test_4563() - { - } - [TestMethod] - public void Test_4564() - { - } - [TestMethod] - public void Test_4565() - { - } - [TestMethod] - public void Test_4566() - { - } - [TestMethod] - public void Test_4567() - { - } - [TestMethod] - public void Test_4568() - { - } - [TestMethod] - public void Test_4569() - { - } - [TestMethod] - public void Test_4570() - { - } - [TestMethod] - public void Test_4571() - { - } - [TestMethod] - public void Test_4572() - { - } - [TestMethod] - public void Test_4573() - { - } - [TestMethod] - public void Test_4574() - { - } - [TestMethod] - public void Test_4575() - { - } - [TestMethod] - public void Test_4576() - { - } - [TestMethod] - public void Test_4577() - { - } - [TestMethod] - public void Test_4578() - { - } - [TestMethod] - public void Test_4579() - { - } - [TestMethod] - public void Test_4580() - { - } - [TestMethod] - public void Test_4581() - { - } - [TestMethod] - public void Test_4582() - { - } - [TestMethod] - public void Test_4583() - { - } - [TestMethod] - public void Test_4584() - { - } - [TestMethod] - public void Test_4585() - { - } - [TestMethod] - public void Test_4586() - { - } - [TestMethod] - public void Test_4587() - { - } - [TestMethod] - public void Test_4588() - { - } - [TestMethod] - public void Test_4589() - { - } - [TestMethod] - public void Test_4590() - { - } - [TestMethod] - public void Test_4591() - { - } - [TestMethod] - public void Test_4592() - { - } - [TestMethod] - public void Test_4593() - { - } - [TestMethod] - public void Test_4594() - { - } - [TestMethod] - public void Test_4595() - { - } - [TestMethod] - public void Test_4596() - { - } - [TestMethod] - public void Test_4597() - { - } - [TestMethod] - public void Test_4598() - { - } - [TestMethod] - public void Test_4599() - { - } - [TestMethod] - public void Test_4600() - { - } - [TestMethod] - public void Test_4601() - { - } - [TestMethod] - public void Test_4602() - { - } - [TestMethod] - public void Test_4603() - { - } - [TestMethod] - public void Test_4604() - { - } - [TestMethod] - public void Test_4605() - { - } - [TestMethod] - public void Test_4606() - { - } - [TestMethod] - public void Test_4607() - { - } - [TestMethod] - public void Test_4608() - { - } - [TestMethod] - public void Test_4609() - { - } - [TestMethod] - public void Test_4610() - { - } - [TestMethod] - public void Test_4611() - { - } - [TestMethod] - public void Test_4612() - { - } - [TestMethod] - public void Test_4613() - { - } - [TestMethod] - public void Test_4614() - { - } - [TestMethod] - public void Test_4615() - { - } - [TestMethod] - public void Test_4616() - { - } - [TestMethod] - public void Test_4617() - { - } - [TestMethod] - public void Test_4618() - { - } - [TestMethod] - public void Test_4619() - { - } - [TestMethod] - public void Test_4620() - { - } - [TestMethod] - public void Test_4621() - { - } - [TestMethod] - public void Test_4622() - { - } - [TestMethod] - public void Test_4623() - { - } - [TestMethod] - public void Test_4624() - { - } - [TestMethod] - public void Test_4625() - { - } - [TestMethod] - public void Test_4626() - { - } - [TestMethod] - public void Test_4627() - { - } - [TestMethod] - public void Test_4628() - { - } - [TestMethod] - public void Test_4629() - { - } - [TestMethod] - public void Test_4630() - { - } - [TestMethod] - public void Test_4631() - { - } - [TestMethod] - public void Test_4632() - { - } - [TestMethod] - public void Test_4633() - { - } - [TestMethod] - public void Test_4634() - { - } - [TestMethod] - public void Test_4635() - { - } - [TestMethod] - public void Test_4636() - { - } - [TestMethod] - public void Test_4637() - { - } - [TestMethod] - public void Test_4638() - { - } - [TestMethod] - public void Test_4639() - { - } - [TestMethod] - public void Test_4640() - { - } - [TestMethod] - public void Test_4641() - { - } - [TestMethod] - public void Test_4642() - { - } - [TestMethod] - public void Test_4643() - { - } - [TestMethod] - public void Test_4644() - { - } - [TestMethod] - public void Test_4645() - { - } - [TestMethod] - public void Test_4646() - { - } - [TestMethod] - public void Test_4647() - { - } - [TestMethod] - public void Test_4648() - { - } - [TestMethod] - public void Test_4649() - { - } - [TestMethod] - public void Test_4650() - { - } - [TestMethod] - public void Test_4651() - { - } - [TestMethod] - public void Test_4652() - { - } - [TestMethod] - public void Test_4653() - { - } - [TestMethod] - public void Test_4654() - { - } - [TestMethod] - public void Test_4655() - { - } - [TestMethod] - public void Test_4656() - { - } - [TestMethod] - public void Test_4657() - { - } - [TestMethod] - public void Test_4658() - { - } - [TestMethod] - public void Test_4659() - { - } - [TestMethod] - public void Test_4660() - { - } - [TestMethod] - public void Test_4661() - { - } - [TestMethod] - public void Test_4662() - { - } - [TestMethod] - public void Test_4663() - { - } - [TestMethod] - public void Test_4664() - { - } - [TestMethod] - public void Test_4665() - { - } - [TestMethod] - public void Test_4666() - { - } - [TestMethod] - public void Test_4667() - { - } - [TestMethod] - public void Test_4668() - { - } - [TestMethod] - public void Test_4669() - { - } - [TestMethod] - public void Test_4670() - { - } - [TestMethod] - public void Test_4671() - { - } - [TestMethod] - public void Test_4672() - { - } - [TestMethod] - public void Test_4673() - { - } - [TestMethod] - public void Test_4674() - { - } - [TestMethod] - public void Test_4675() - { - } - [TestMethod] - public void Test_4676() - { - } - [TestMethod] - public void Test_4677() - { - } - [TestMethod] - public void Test_4678() - { - } - [TestMethod] - public void Test_4679() - { - } - [TestMethod] - public void Test_4680() - { - } - [TestMethod] - public void Test_4681() - { - } - [TestMethod] - public void Test_4682() - { - } - [TestMethod] - public void Test_4683() - { - } - [TestMethod] - public void Test_4684() - { - } - [TestMethod] - public void Test_4685() - { - } - [TestMethod] - public void Test_4686() - { - } - [TestMethod] - public void Test_4687() - { - } - [TestMethod] - public void Test_4688() - { - } - [TestMethod] - public void Test_4689() - { - } - [TestMethod] - public void Test_4690() - { - } - [TestMethod] - public void Test_4691() - { - } - [TestMethod] - public void Test_4692() - { - } - [TestMethod] - public void Test_4693() - { - } - [TestMethod] - public void Test_4694() - { - } - [TestMethod] - public void Test_4695() - { - } - [TestMethod] - public void Test_4696() - { - } - [TestMethod] - public void Test_4697() - { - } - [TestMethod] - public void Test_4698() - { - } - [TestMethod] - public void Test_4699() - { - } - [TestMethod] - public void Test_4700() - { - } - [TestMethod] - public void Test_4701() - { - } - [TestMethod] - public void Test_4702() - { - } - [TestMethod] - public void Test_4703() - { - } - [TestMethod] - public void Test_4704() - { - } - [TestMethod] - public void Test_4705() - { - } - [TestMethod] - public void Test_4706() - { - } - [TestMethod] - public void Test_4707() - { - } - [TestMethod] - public void Test_4708() - { - } - [TestMethod] - public void Test_4709() - { - } - [TestMethod] - public void Test_4710() - { - } - [TestMethod] - public void Test_4711() - { - } - [TestMethod] - public void Test_4712() - { - } - [TestMethod] - public void Test_4713() - { - } - [TestMethod] - public void Test_4714() - { - } - [TestMethod] - public void Test_4715() - { - } - [TestMethod] - public void Test_4716() - { - } - [TestMethod] - public void Test_4717() - { - } - [TestMethod] - public void Test_4718() - { - } - [TestMethod] - public void Test_4719() - { - } - [TestMethod] - public void Test_4720() - { - } - [TestMethod] - public void Test_4721() - { - } - [TestMethod] - public void Test_4722() - { - } - [TestMethod] - public void Test_4723() - { - } - [TestMethod] - public void Test_4724() - { - } - [TestMethod] - public void Test_4725() - { - } - [TestMethod] - public void Test_4726() - { - } - [TestMethod] - public void Test_4727() - { - } - [TestMethod] - public void Test_4728() - { - } - [TestMethod] - public void Test_4729() - { - } - [TestMethod] - public void Test_4730() - { - } - [TestMethod] - public void Test_4731() - { - } - [TestMethod] - public void Test_4732() - { - } - [TestMethod] - public void Test_4733() - { - } - [TestMethod] - public void Test_4734() - { - } - [TestMethod] - public void Test_4735() - { - } - [TestMethod] - public void Test_4736() - { - } - [TestMethod] - public void Test_4737() - { - } - [TestMethod] - public void Test_4738() - { - } - [TestMethod] - public void Test_4739() - { - } - [TestMethod] - public void Test_4740() - { - } - [TestMethod] - public void Test_4741() - { - } - [TestMethod] - public void Test_4742() - { - } - [TestMethod] - public void Test_4743() - { - } - [TestMethod] - public void Test_4744() - { - } - [TestMethod] - public void Test_4745() - { - } - [TestMethod] - public void Test_4746() - { - } - [TestMethod] - public void Test_4747() - { - } - [TestMethod] - public void Test_4748() - { - } - [TestMethod] - public void Test_4749() - { - } - [TestMethod] - public void Test_4750() - { - } - [TestMethod] - public void Test_4751() - { - } - [TestMethod] - public void Test_4752() - { - } - [TestMethod] - public void Test_4753() - { - } - [TestMethod] - public void Test_4754() - { - } - [TestMethod] - public void Test_4755() - { - } - [TestMethod] - public void Test_4756() - { - } - [TestMethod] - public void Test_4757() - { - } - [TestMethod] - public void Test_4758() - { - } - [TestMethod] - public void Test_4759() - { - } - [TestMethod] - public void Test_4760() - { - } - [TestMethod] - public void Test_4761() - { - } - [TestMethod] - public void Test_4762() - { - } - [TestMethod] - public void Test_4763() - { - } - [TestMethod] - public void Test_4764() - { - } - [TestMethod] - public void Test_4765() - { - } - [TestMethod] - public void Test_4766() - { - } - [TestMethod] - public void Test_4767() - { - } - [TestMethod] - public void Test_4768() - { - } - [TestMethod] - public void Test_4769() - { - } - [TestMethod] - public void Test_4770() - { - } - [TestMethod] - public void Test_4771() - { - } - [TestMethod] - public void Test_4772() - { - } - [TestMethod] - public void Test_4773() - { - } - [TestMethod] - public void Test_4774() - { - } - [TestMethod] - public void Test_4775() - { - } - [TestMethod] - public void Test_4776() - { - } - [TestMethod] - public void Test_4777() - { - } - [TestMethod] - public void Test_4778() - { - } - [TestMethod] - public void Test_4779() - { - } - [TestMethod] - public void Test_4780() - { - } - [TestMethod] - public void Test_4781() - { - } - [TestMethod] - public void Test_4782() - { - } - [TestMethod] - public void Test_4783() - { - } - [TestMethod] - public void Test_4784() - { - } - [TestMethod] - public void Test_4785() - { - } - [TestMethod] - public void Test_4786() - { - } - [TestMethod] - public void Test_4787() - { - } - [TestMethod] - public void Test_4788() - { - } - [TestMethod] - public void Test_4789() - { - } - [TestMethod] - public void Test_4790() - { - } - [TestMethod] - public void Test_4791() - { - } - [TestMethod] - public void Test_4792() - { - } - [TestMethod] - public void Test_4793() - { - } - [TestMethod] - public void Test_4794() - { - } - [TestMethod] - public void Test_4795() - { - } - [TestMethod] - public void Test_4796() - { - } - [TestMethod] - public void Test_4797() - { - } - [TestMethod] - public void Test_4798() - { - } - [TestMethod] - public void Test_4799() - { - } - [TestMethod] - public void Test_4800() - { - } - [TestMethod] - public void Test_4801() - { - } - [TestMethod] - public void Test_4802() - { - } - [TestMethod] - public void Test_4803() - { - } - [TestMethod] - public void Test_4804() - { - } - [TestMethod] - public void Test_4805() - { - } - [TestMethod] - public void Test_4806() - { - } - [TestMethod] - public void Test_4807() - { - } - [TestMethod] - public void Test_4808() - { - } - [TestMethod] - public void Test_4809() - { - } - [TestMethod] - public void Test_4810() - { - } - [TestMethod] - public void Test_4811() - { - } - [TestMethod] - public void Test_4812() - { - } - [TestMethod] - public void Test_4813() - { - } - [TestMethod] - public void Test_4814() - { - } - [TestMethod] - public void Test_4815() - { - } - [TestMethod] - public void Test_4816() - { - } - [TestMethod] - public void Test_4817() - { - } - [TestMethod] - public void Test_4818() - { - } - [TestMethod] - public void Test_4819() - { - } - [TestMethod] - public void Test_4820() - { - } - [TestMethod] - public void Test_4821() - { - } - [TestMethod] - public void Test_4822() - { - } - [TestMethod] - public void Test_4823() - { - } - [TestMethod] - public void Test_4824() - { - } - [TestMethod] - public void Test_4825() - { - } - [TestMethod] - public void Test_4826() - { - } - [TestMethod] - public void Test_4827() - { - } - [TestMethod] - public void Test_4828() - { - } - [TestMethod] - public void Test_4829() - { - } - [TestMethod] - public void Test_4830() - { - } - [TestMethod] - public void Test_4831() - { - } - [TestMethod] - public void Test_4832() - { - } - [TestMethod] - public void Test_4833() - { - } - [TestMethod] - public void Test_4834() - { - } - [TestMethod] - public void Test_4835() - { - } - [TestMethod] - public void Test_4836() - { - } - [TestMethod] - public void Test_4837() - { - } - [TestMethod] - public void Test_4838() - { - } - [TestMethod] - public void Test_4839() - { - } - [TestMethod] - public void Test_4840() - { - } - [TestMethod] - public void Test_4841() - { - } - [TestMethod] - public void Test_4842() - { - } - [TestMethod] - public void Test_4843() - { - } - [TestMethod] - public void Test_4844() - { - } - [TestMethod] - public void Test_4845() - { - } - [TestMethod] - public void Test_4846() - { - } - [TestMethod] - public void Test_4847() - { - } - [TestMethod] - public void Test_4848() - { - } - [TestMethod] - public void Test_4849() - { - } - [TestMethod] - public void Test_4850() - { - } - [TestMethod] - public void Test_4851() - { - } - [TestMethod] - public void Test_4852() - { - } - [TestMethod] - public void Test_4853() - { - } - [TestMethod] - public void Test_4854() - { - } - [TestMethod] - public void Test_4855() - { - } - [TestMethod] - public void Test_4856() - { - } - [TestMethod] - public void Test_4857() - { - } - [TestMethod] - public void Test_4858() - { - } - [TestMethod] - public void Test_4859() - { - } - [TestMethod] - public void Test_4860() - { - } - [TestMethod] - public void Test_4861() - { - } - [TestMethod] - public void Test_4862() - { - } - [TestMethod] - public void Test_4863() - { - } - [TestMethod] - public void Test_4864() - { - } - [TestMethod] - public void Test_4865() - { - } - [TestMethod] - public void Test_4866() - { - } - [TestMethod] - public void Test_4867() - { - } - [TestMethod] - public void Test_4868() - { - } - [TestMethod] - public void Test_4869() - { - } - [TestMethod] - public void Test_4870() - { - } - [TestMethod] - public void Test_4871() - { - } - [TestMethod] - public void Test_4872() - { - } - [TestMethod] - public void Test_4873() - { - } - [TestMethod] - public void Test_4874() - { - } - [TestMethod] - public void Test_4875() - { - } - [TestMethod] - public void Test_4876() - { - } - [TestMethod] - public void Test_4877() - { - } - [TestMethod] - public void Test_4878() - { - } - [TestMethod] - public void Test_4879() - { - } - [TestMethod] - public void Test_4880() - { - } - [TestMethod] - public void Test_4881() - { - } - [TestMethod] - public void Test_4882() - { - } - [TestMethod] - public void Test_4883() - { - } - [TestMethod] - public void Test_4884() - { - } - [TestMethod] - public void Test_4885() - { - } - [TestMethod] - public void Test_4886() - { - } - [TestMethod] - public void Test_4887() - { - } - [TestMethod] - public void Test_4888() - { - } - [TestMethod] - public void Test_4889() - { - } - [TestMethod] - public void Test_4890() - { - } - [TestMethod] - public void Test_4891() - { - } - [TestMethod] - public void Test_4892() - { - } - [TestMethod] - public void Test_4893() - { - } - [TestMethod] - public void Test_4894() - { - } - [TestMethod] - public void Test_4895() - { - } - [TestMethod] - public void Test_4896() - { - } - [TestMethod] - public void Test_4897() - { - } - [TestMethod] - public void Test_4898() - { - } - [TestMethod] - public void Test_4899() - { - } - [TestMethod] - public void Test_4900() - { - } - [TestMethod] - public void Test_4901() - { - } - [TestMethod] - public void Test_4902() - { - } - [TestMethod] - public void Test_4903() - { - } - [TestMethod] - public void Test_4904() - { - } - [TestMethod] - public void Test_4905() - { - } - [TestMethod] - public void Test_4906() - { - } - [TestMethod] - public void Test_4907() - { - } - [TestMethod] - public void Test_4908() - { - } - [TestMethod] - public void Test_4909() - { - } - [TestMethod] - public void Test_4910() - { - } - [TestMethod] - public void Test_4911() - { - } - [TestMethod] - public void Test_4912() - { - } - [TestMethod] - public void Test_4913() - { - } - [TestMethod] - public void Test_4914() - { - } - [TestMethod] - public void Test_4915() - { - } - [TestMethod] - public void Test_4916() - { - } - [TestMethod] - public void Test_4917() - { - } - [TestMethod] - public void Test_4918() - { - } - [TestMethod] - public void Test_4919() - { - } - [TestMethod] - public void Test_4920() - { - } - [TestMethod] - public void Test_4921() - { - } - [TestMethod] - public void Test_4922() - { - } - [TestMethod] - public void Test_4923() - { - } - [TestMethod] - public void Test_4924() - { - } - [TestMethod] - public void Test_4925() - { - } - [TestMethod] - public void Test_4926() - { - } - [TestMethod] - public void Test_4927() - { - } - [TestMethod] - public void Test_4928() - { - } - [TestMethod] - public void Test_4929() - { - } - [TestMethod] - public void Test_4930() - { - } - [TestMethod] - public void Test_4931() - { - } - [TestMethod] - public void Test_4932() - { - } - [TestMethod] - public void Test_4933() - { - } - [TestMethod] - public void Test_4934() - { - } - [TestMethod] - public void Test_4935() - { - } - [TestMethod] - public void Test_4936() - { - } - [TestMethod] - public void Test_4937() - { - } - [TestMethod] - public void Test_4938() - { - } - [TestMethod] - public void Test_4939() - { - } - [TestMethod] - public void Test_4940() - { - } - [TestMethod] - public void Test_4941() - { - } - [TestMethod] - public void Test_4942() - { - } - [TestMethod] - public void Test_4943() - { - } - [TestMethod] - public void Test_4944() - { - } - [TestMethod] - public void Test_4945() - { - } - [TestMethod] - public void Test_4946() - { - } - [TestMethod] - public void Test_4947() - { - } - [TestMethod] - public void Test_4948() - { - } - [TestMethod] - public void Test_4949() - { - } - [TestMethod] - public void Test_4950() - { - } - [TestMethod] - public void Test_4951() - { - } - [TestMethod] - public void Test_4952() - { - } - [TestMethod] - public void Test_4953() - { - } - [TestMethod] - public void Test_4954() - { - } - [TestMethod] - public void Test_4955() - { - } - [TestMethod] - public void Test_4956() - { - } - [TestMethod] - public void Test_4957() - { - } - [TestMethod] - public void Test_4958() - { - } - [TestMethod] - public void Test_4959() - { - } - [TestMethod] - public void Test_4960() - { - } - [TestMethod] - public void Test_4961() - { - } - [TestMethod] - public void Test_4962() - { - } - [TestMethod] - public void Test_4963() - { - } - [TestMethod] - public void Test_4964() - { - } - [TestMethod] - public void Test_4965() - { - } - [TestMethod] - public void Test_4966() - { - } - [TestMethod] - public void Test_4967() - { - } - [TestMethod] - public void Test_4968() - { - } - [TestMethod] - public void Test_4969() - { - } - [TestMethod] - public void Test_4970() - { - } - [TestMethod] - public void Test_4971() - { - } - [TestMethod] - public void Test_4972() - { - } - [TestMethod] - public void Test_4973() - { - } - [TestMethod] - public void Test_4974() - { - } - [TestMethod] - public void Test_4975() - { - } - [TestMethod] - public void Test_4976() - { - } - [TestMethod] - public void Test_4977() - { - } - [TestMethod] - public void Test_4978() - { - } - [TestMethod] - public void Test_4979() - { - } - [TestMethod] - public void Test_4980() - { - } - [TestMethod] - public void Test_4981() - { - } - [TestMethod] - public void Test_4982() - { - } - [TestMethod] - public void Test_4983() - { - } - [TestMethod] - public void Test_4984() - { - } - [TestMethod] - public void Test_4985() - { - } - [TestMethod] - public void Test_4986() - { - } - [TestMethod] - public void Test_4987() - { - } - [TestMethod] - public void Test_4988() - { - } - [TestMethod] - public void Test_4989() - { - } - [TestMethod] - public void Test_4990() - { - } - [TestMethod] - public void Test_4991() - { - } - [TestMethod] - public void Test_4992() - { - } - [TestMethod] - public void Test_4993() - { - } - [TestMethod] - public void Test_4994() - { - } - [TestMethod] - public void Test_4995() - { - } - [TestMethod] - public void Test_4996() - { - } - [TestMethod] - public void Test_4997() - { - } - [TestMethod] - public void Test_4998() - { - } - [TestMethod] - public void Test_4999() - { - } - [TestMethod] - public void Test_5000() - { - } - [TestMethod] - public void Test_5001() - { - } - [TestMethod] - public void Test_5002() - { - } - [TestMethod] - public void Test_5003() - { - } - [TestMethod] - public void Test_5004() - { - } - [TestMethod] - public void Test_5005() - { - } - [TestMethod] - public void Test_5006() - { - } - [TestMethod] - public void Test_5007() - { - } - [TestMethod] - public void Test_5008() - { - } - [TestMethod] - public void Test_5009() - { - } - [TestMethod] - public void Test_5010() - { - } - [TestMethod] - public void Test_5011() - { - } - [TestMethod] - public void Test_5012() - { - } - [TestMethod] - public void Test_5013() - { - } - [TestMethod] - public void Test_5014() - { - } - [TestMethod] - public void Test_5015() - { - } - [TestMethod] - public void Test_5016() - { - } - [TestMethod] - public void Test_5017() - { - } - [TestMethod] - public void Test_5018() - { - } - [TestMethod] - public void Test_5019() - { - } - [TestMethod] - public void Test_5020() - { - } - [TestMethod] - public void Test_5021() - { - } - [TestMethod] - public void Test_5022() - { - } - [TestMethod] - public void Test_5023() - { - } - [TestMethod] - public void Test_5024() - { - } - [TestMethod] - public void Test_5025() - { - } - [TestMethod] - public void Test_5026() - { - } - [TestMethod] - public void Test_5027() - { - } - [TestMethod] - public void Test_5028() - { - } - [TestMethod] - public void Test_5029() - { - } - [TestMethod] - public void Test_5030() - { - } - [TestMethod] - public void Test_5031() - { - } - [TestMethod] - public void Test_5032() - { - } - [TestMethod] - public void Test_5033() - { - } - [TestMethod] - public void Test_5034() - { - } - [TestMethod] - public void Test_5035() - { - } - [TestMethod] - public void Test_5036() - { - } - [TestMethod] - public void Test_5037() - { - } - [TestMethod] - public void Test_5038() - { - } - [TestMethod] - public void Test_5039() - { - } - [TestMethod] - public void Test_5040() - { - } - [TestMethod] - public void Test_5041() - { - } - [TestMethod] - public void Test_5042() - { - } - [TestMethod] - public void Test_5043() - { - } - [TestMethod] - public void Test_5044() - { - } - [TestMethod] - public void Test_5045() - { - } - [TestMethod] - public void Test_5046() - { - } - [TestMethod] - public void Test_5047() - { - } - [TestMethod] - public void Test_5048() - { - } - [TestMethod] - public void Test_5049() - { - } - [TestMethod] - public void Test_5050() - { - } - [TestMethod] - public void Test_5051() - { - } - [TestMethod] - public void Test_5052() - { - } - [TestMethod] - public void Test_5053() - { - } - [TestMethod] - public void Test_5054() - { - } - [TestMethod] - public void Test_5055() - { - } - [TestMethod] - public void Test_5056() - { - } - [TestMethod] - public void Test_5057() - { - } - [TestMethod] - public void Test_5058() - { - } - [TestMethod] - public void Test_5059() - { - } - [TestMethod] - public void Test_5060() - { - } - [TestMethod] - public void Test_5061() - { - } - [TestMethod] - public void Test_5062() - { - } - [TestMethod] - public void Test_5063() - { - } - [TestMethod] - public void Test_5064() - { - } - [TestMethod] - public void Test_5065() - { - } - [TestMethod] - public void Test_5066() - { - } - [TestMethod] - public void Test_5067() - { - } - [TestMethod] - public void Test_5068() - { - } - [TestMethod] - public void Test_5069() - { - } - [TestMethod] - public void Test_5070() - { - } - [TestMethod] - public void Test_5071() - { - } - [TestMethod] - public void Test_5072() - { - } - [TestMethod] - public void Test_5073() - { - } - [TestMethod] - public void Test_5074() - { - } - [TestMethod] - public void Test_5075() - { - } - [TestMethod] - public void Test_5076() - { - } - [TestMethod] - public void Test_5077() - { - } - [TestMethod] - public void Test_5078() - { - } - [TestMethod] - public void Test_5079() - { - } - [TestMethod] - public void Test_5080() - { - } - [TestMethod] - public void Test_5081() - { - } - [TestMethod] - public void Test_5082() - { - } - [TestMethod] - public void Test_5083() - { - } - [TestMethod] - public void Test_5084() - { - } - [TestMethod] - public void Test_5085() - { - } - [TestMethod] - public void Test_5086() - { - } - [TestMethod] - public void Test_5087() - { - } - [TestMethod] - public void Test_5088() - { - } - [TestMethod] - public void Test_5089() - { - } - [TestMethod] - public void Test_5090() - { - } - [TestMethod] - public void Test_5091() - { - } - [TestMethod] - public void Test_5092() - { - } - [TestMethod] - public void Test_5093() - { - } - [TestMethod] - public void Test_5094() - { - } - [TestMethod] - public void Test_5095() - { - } - [TestMethod] - public void Test_5096() - { - } - [TestMethod] - public void Test_5097() - { - } - [TestMethod] - public void Test_5098() - { - } - [TestMethod] - public void Test_5099() - { - } - [TestMethod] - public void Test_5100() - { - } - [TestMethod] - public void Test_5101() - { - } - [TestMethod] - public void Test_5102() - { - } - [TestMethod] - public void Test_5103() - { - } - [TestMethod] - public void Test_5104() - { - } - [TestMethod] - public void Test_5105() - { - } - [TestMethod] - public void Test_5106() - { - } - [TestMethod] - public void Test_5107() - { - } - [TestMethod] - public void Test_5108() - { - } - [TestMethod] - public void Test_5109() - { - } - [TestMethod] - public void Test_5110() - { - } - [TestMethod] - public void Test_5111() - { - } - [TestMethod] - public void Test_5112() - { - } - [TestMethod] - public void Test_5113() - { - } - [TestMethod] - public void Test_5114() - { - } - [TestMethod] - public void Test_5115() - { - } - [TestMethod] - public void Test_5116() - { - } - [TestMethod] - public void Test_5117() - { - } - [TestMethod] - public void Test_5118() - { - } - [TestMethod] - public void Test_5119() - { - } - [TestMethod] - public void Test_5120() - { - } - [TestMethod] - public void Test_5121() - { - } - [TestMethod] - public void Test_5122() - { - } - [TestMethod] - public void Test_5123() - { - } - [TestMethod] - public void Test_5124() - { - } - [TestMethod] - public void Test_5125() - { - } - [TestMethod] - public void Test_5126() - { - } - [TestMethod] - public void Test_5127() - { - } - [TestMethod] - public void Test_5128() - { - } - [TestMethod] - public void Test_5129() - { - } - [TestMethod] - public void Test_5130() - { - } - [TestMethod] - public void Test_5131() - { - } - [TestMethod] - public void Test_5132() - { - } - [TestMethod] - public void Test_5133() - { - } - [TestMethod] - public void Test_5134() - { - } - [TestMethod] - public void Test_5135() - { - } - [TestMethod] - public void Test_5136() - { - } - [TestMethod] - public void Test_5137() - { - } - [TestMethod] - public void Test_5138() - { - } - [TestMethod] - public void Test_5139() - { - } - [TestMethod] - public void Test_5140() - { - } - [TestMethod] - public void Test_5141() - { - } - [TestMethod] - public void Test_5142() - { - } - [TestMethod] - public void Test_5143() - { - } - [TestMethod] - public void Test_5144() - { - } - [TestMethod] - public void Test_5145() - { - } - [TestMethod] - public void Test_5146() - { - } - [TestMethod] - public void Test_5147() - { - } - [TestMethod] - public void Test_5148() - { - } - [TestMethod] - public void Test_5149() - { - } - [TestMethod] - public void Test_5150() - { - } - [TestMethod] - public void Test_5151() - { - } - [TestMethod] - public void Test_5152() - { - } - [TestMethod] - public void Test_5153() - { - } - [TestMethod] - public void Test_5154() - { - } - [TestMethod] - public void Test_5155() - { - } - [TestMethod] - public void Test_5156() - { - } - [TestMethod] - public void Test_5157() - { - } - [TestMethod] - public void Test_5158() - { - } - [TestMethod] - public void Test_5159() - { - } - [TestMethod] - public void Test_5160() - { - } - [TestMethod] - public void Test_5161() - { - } - [TestMethod] - public void Test_5162() - { - } - [TestMethod] - public void Test_5163() - { - } - [TestMethod] - public void Test_5164() - { - } - [TestMethod] - public void Test_5165() - { - } - [TestMethod] - public void Test_5166() - { - } - [TestMethod] - public void Test_5167() - { - } - [TestMethod] - public void Test_5168() - { - } - [TestMethod] - public void Test_5169() - { - } - [TestMethod] - public void Test_5170() - { - } - [TestMethod] - public void Test_5171() - { - } - [TestMethod] - public void Test_5172() - { - } - [TestMethod] - public void Test_5173() - { - } - [TestMethod] - public void Test_5174() - { - } - [TestMethod] - public void Test_5175() - { - } - [TestMethod] - public void Test_5176() - { - } - [TestMethod] - public void Test_5177() - { - } - [TestMethod] - public void Test_5178() - { - } - [TestMethod] - public void Test_5179() - { - } - [TestMethod] - public void Test_5180() - { - } - [TestMethod] - public void Test_5181() - { - } - [TestMethod] - public void Test_5182() - { - } - [TestMethod] - public void Test_5183() - { - } - [TestMethod] - public void Test_5184() - { - } - [TestMethod] - public void Test_5185() - { - } - [TestMethod] - public void Test_5186() - { - } - [TestMethod] - public void Test_5187() - { - } - [TestMethod] - public void Test_5188() - { - } - [TestMethod] - public void Test_5189() - { - } - [TestMethod] - public void Test_5190() - { - } - [TestMethod] - public void Test_5191() - { - } - [TestMethod] - public void Test_5192() - { - } - [TestMethod] - public void Test_5193() - { - } - [TestMethod] - public void Test_5194() - { - } - [TestMethod] - public void Test_5195() - { - } - [TestMethod] - public void Test_5196() - { - } - [TestMethod] - public void Test_5197() - { - } - [TestMethod] - public void Test_5198() - { - } - [TestMethod] - public void Test_5199() - { - } - [TestMethod] - public void Test_5200() - { - } - [TestMethod] - public void Test_5201() - { - } - [TestMethod] - public void Test_5202() - { - } - [TestMethod] - public void Test_5203() - { - } - [TestMethod] - public void Test_5204() - { - } - [TestMethod] - public void Test_5205() - { - } - [TestMethod] - public void Test_5206() - { - } - [TestMethod] - public void Test_5207() - { - } - [TestMethod] - public void Test_5208() - { - } - [TestMethod] - public void Test_5209() - { - } - [TestMethod] - public void Test_5210() - { - } - [TestMethod] - public void Test_5211() - { - } - [TestMethod] - public void Test_5212() - { - } - [TestMethod] - public void Test_5213() - { - } - [TestMethod] - public void Test_5214() - { - } - [TestMethod] - public void Test_5215() - { - } - [TestMethod] - public void Test_5216() - { - } - [TestMethod] - public void Test_5217() - { - } - [TestMethod] - public void Test_5218() - { - } - [TestMethod] - public void Test_5219() - { - } - [TestMethod] - public void Test_5220() - { - } - [TestMethod] - public void Test_5221() - { - } - [TestMethod] - public void Test_5222() - { - } - [TestMethod] - public void Test_5223() - { - } - [TestMethod] - public void Test_5224() - { - } - [TestMethod] - public void Test_5225() - { - } - [TestMethod] - public void Test_5226() - { - } - [TestMethod] - public void Test_5227() - { - } - [TestMethod] - public void Test_5228() - { - } - [TestMethod] - public void Test_5229() - { - } - [TestMethod] - public void Test_5230() - { - } - [TestMethod] - public void Test_5231() - { - } - [TestMethod] - public void Test_5232() - { - } - [TestMethod] - public void Test_5233() - { - } - [TestMethod] - public void Test_5234() - { - } - [TestMethod] - public void Test_5235() - { - } - [TestMethod] - public void Test_5236() - { - } - [TestMethod] - public void Test_5237() - { - } - [TestMethod] - public void Test_5238() - { - } - [TestMethod] - public void Test_5239() - { - } - [TestMethod] - public void Test_5240() - { - } - [TestMethod] - public void Test_5241() - { - } - [TestMethod] - public void Test_5242() - { - } - [TestMethod] - public void Test_5243() - { - } - [TestMethod] - public void Test_5244() - { - } - [TestMethod] - public void Test_5245() - { - } - [TestMethod] - public void Test_5246() - { - } - [TestMethod] - public void Test_5247() - { - } - [TestMethod] - public void Test_5248() - { - } - [TestMethod] - public void Test_5249() - { - } - [TestMethod] - public void Test_5250() - { - } - [TestMethod] - public void Test_5251() - { - } - [TestMethod] - public void Test_5252() - { - } - [TestMethod] - public void Test_5253() - { - } - [TestMethod] - public void Test_5254() - { - } - [TestMethod] - public void Test_5255() - { - } - [TestMethod] - public void Test_5256() - { - } - [TestMethod] - public void Test_5257() - { - } - [TestMethod] - public void Test_5258() - { - } - [TestMethod] - public void Test_5259() - { - } - [TestMethod] - public void Test_5260() - { - } - [TestMethod] - public void Test_5261() - { - } - [TestMethod] - public void Test_5262() - { - } - [TestMethod] - public void Test_5263() - { - } - [TestMethod] - public void Test_5264() - { - } - [TestMethod] - public void Test_5265() - { - } - [TestMethod] - public void Test_5266() - { - } - [TestMethod] - public void Test_5267() - { - } - [TestMethod] - public void Test_5268() - { - } - [TestMethod] - public void Test_5269() - { - } - [TestMethod] - public void Test_5270() - { - } - [TestMethod] - public void Test_5271() - { - } - [TestMethod] - public void Test_5272() - { - } - [TestMethod] - public void Test_5273() - { - } - [TestMethod] - public void Test_5274() - { - } - [TestMethod] - public void Test_5275() - { - } - [TestMethod] - public void Test_5276() - { - } - [TestMethod] - public void Test_5277() - { - } - [TestMethod] - public void Test_5278() - { - } - [TestMethod] - public void Test_5279() - { - } - [TestMethod] - public void Test_5280() - { - } - [TestMethod] - public void Test_5281() - { - } - [TestMethod] - public void Test_5282() - { - } - [TestMethod] - public void Test_5283() - { - } - [TestMethod] - public void Test_5284() - { - } - [TestMethod] - public void Test_5285() - { - } - [TestMethod] - public void Test_5286() - { - } - [TestMethod] - public void Test_5287() - { - } - [TestMethod] - public void Test_5288() - { - } - [TestMethod] - public void Test_5289() - { - } - [TestMethod] - public void Test_5290() - { - } - [TestMethod] - public void Test_5291() - { - } - [TestMethod] - public void Test_5292() - { - } - [TestMethod] - public void Test_5293() - { - } - [TestMethod] - public void Test_5294() - { - } - [TestMethod] - public void Test_5295() - { - } - [TestMethod] - public void Test_5296() - { - } - [TestMethod] - public void Test_5297() - { - } - [TestMethod] - public void Test_5298() - { - } - [TestMethod] - public void Test_5299() - { - } - [TestMethod] - public void Test_5300() - { - } - [TestMethod] - public void Test_5301() - { - } - [TestMethod] - public void Test_5302() - { - } - [TestMethod] - public void Test_5303() - { - } - [TestMethod] - public void Test_5304() - { - } - [TestMethod] - public void Test_5305() - { - } - [TestMethod] - public void Test_5306() - { - } - [TestMethod] - public void Test_5307() - { - } - [TestMethod] - public void Test_5308() - { - } - [TestMethod] - public void Test_5309() - { - } - [TestMethod] - public void Test_5310() - { - } - [TestMethod] - public void Test_5311() - { - } - [TestMethod] - public void Test_5312() - { - } - [TestMethod] - public void Test_5313() - { - } - [TestMethod] - public void Test_5314() - { - } - [TestMethod] - public void Test_5315() - { - } - [TestMethod] - public void Test_5316() - { - } - [TestMethod] - public void Test_5317() - { - } - [TestMethod] - public void Test_5318() - { - } - [TestMethod] - public void Test_5319() - { - } - [TestMethod] - public void Test_5320() - { - } - [TestMethod] - public void Test_5321() - { - } - [TestMethod] - public void Test_5322() - { - } - [TestMethod] - public void Test_5323() - { - } - [TestMethod] - public void Test_5324() - { - } - [TestMethod] - public void Test_5325() - { - } - [TestMethod] - public void Test_5326() - { - } - [TestMethod] - public void Test_5327() - { - } - [TestMethod] - public void Test_5328() - { - } - [TestMethod] - public void Test_5329() - { - } - [TestMethod] - public void Test_5330() - { - } - [TestMethod] - public void Test_5331() - { - } - [TestMethod] - public void Test_5332() - { - } - [TestMethod] - public void Test_5333() - { - } - [TestMethod] - public void Test_5334() - { - } - [TestMethod] - public void Test_5335() - { - } - [TestMethod] - public void Test_5336() - { - } - [TestMethod] - public void Test_5337() - { - } - [TestMethod] - public void Test_5338() - { - } - [TestMethod] - public void Test_5339() - { - } - [TestMethod] - public void Test_5340() - { - } - [TestMethod] - public void Test_5341() - { - } - [TestMethod] - public void Test_5342() - { - } - [TestMethod] - public void Test_5343() - { - } - [TestMethod] - public void Test_5344() - { - } - [TestMethod] - public void Test_5345() - { - } - [TestMethod] - public void Test_5346() - { - } - [TestMethod] - public void Test_5347() - { - } - [TestMethod] - public void Test_5348() - { - } - [TestMethod] - public void Test_5349() - { - } - [TestMethod] - public void Test_5350() - { - } - [TestMethod] - public void Test_5351() - { - } - [TestMethod] - public void Test_5352() - { - } - [TestMethod] - public void Test_5353() - { - } - [TestMethod] - public void Test_5354() - { - } - [TestMethod] - public void Test_5355() - { - } - [TestMethod] - public void Test_5356() - { - } - [TestMethod] - public void Test_5357() - { - } - [TestMethod] - public void Test_5358() - { - } - [TestMethod] - public void Test_5359() - { - } - [TestMethod] - public void Test_5360() - { - } - [TestMethod] - public void Test_5361() - { - } - [TestMethod] - public void Test_5362() - { - } - [TestMethod] - public void Test_5363() - { - } - [TestMethod] - public void Test_5364() - { - } - [TestMethod] - public void Test_5365() - { - } - [TestMethod] - public void Test_5366() - { - } - [TestMethod] - public void Test_5367() - { - } - [TestMethod] - public void Test_5368() - { - } - [TestMethod] - public void Test_5369() - { - } - [TestMethod] - public void Test_5370() - { - } - [TestMethod] - public void Test_5371() - { - } - [TestMethod] - public void Test_5372() - { - } - [TestMethod] - public void Test_5373() - { - } - [TestMethod] - public void Test_5374() - { - } - [TestMethod] - public void Test_5375() - { - } - [TestMethod] - public void Test_5376() - { - } - [TestMethod] - public void Test_5377() - { - } - [TestMethod] - public void Test_5378() - { - } - [TestMethod] - public void Test_5379() - { - } - [TestMethod] - public void Test_5380() - { - } - [TestMethod] - public void Test_5381() - { - } - [TestMethod] - public void Test_5382() - { - } - [TestMethod] - public void Test_5383() - { - } - [TestMethod] - public void Test_5384() - { - } - [TestMethod] - public void Test_5385() - { - } - [TestMethod] - public void Test_5386() - { - } - [TestMethod] - public void Test_5387() - { - } - [TestMethod] - public void Test_5388() - { - } - [TestMethod] - public void Test_5389() - { - } - [TestMethod] - public void Test_5390() - { - } - [TestMethod] - public void Test_5391() - { - } - [TestMethod] - public void Test_5392() - { - } - [TestMethod] - public void Test_5393() - { - } - [TestMethod] - public void Test_5394() - { - } - [TestMethod] - public void Test_5395() - { - } - [TestMethod] - public void Test_5396() - { - } - [TestMethod] - public void Test_5397() - { - } - [TestMethod] - public void Test_5398() - { - } - [TestMethod] - public void Test_5399() - { - } - [TestMethod] - public void Test_5400() - { - } - [TestMethod] - public void Test_5401() - { - } - [TestMethod] - public void Test_5402() - { - } - [TestMethod] - public void Test_5403() - { - } - [TestMethod] - public void Test_5404() - { - } - [TestMethod] - public void Test_5405() - { - } - [TestMethod] - public void Test_5406() - { - } - [TestMethod] - public void Test_5407() - { - } - [TestMethod] - public void Test_5408() - { - } - [TestMethod] - public void Test_5409() - { - } - [TestMethod] - public void Test_5410() - { - } - [TestMethod] - public void Test_5411() - { - } - [TestMethod] - public void Test_5412() - { - } - [TestMethod] - public void Test_5413() - { - } - [TestMethod] - public void Test_5414() - { - } - [TestMethod] - public void Test_5415() - { - } - [TestMethod] - public void Test_5416() - { - } - [TestMethod] - public void Test_5417() - { - } - [TestMethod] - public void Test_5418() - { - } - [TestMethod] - public void Test_5419() - { - } - [TestMethod] - public void Test_5420() - { - } - [TestMethod] - public void Test_5421() - { - } - [TestMethod] - public void Test_5422() - { - } - [TestMethod] - public void Test_5423() - { - } - [TestMethod] - public void Test_5424() - { - } - [TestMethod] - public void Test_5425() - { - } - [TestMethod] - public void Test_5426() - { - } - [TestMethod] - public void Test_5427() - { - } - [TestMethod] - public void Test_5428() - { - } - [TestMethod] - public void Test_5429() - { - } - [TestMethod] - public void Test_5430() - { - } - [TestMethod] - public void Test_5431() - { - } - [TestMethod] - public void Test_5432() - { - } - [TestMethod] - public void Test_5433() - { - } - [TestMethod] - public void Test_5434() - { - } - [TestMethod] - public void Test_5435() - { - } - [TestMethod] - public void Test_5436() - { - } - [TestMethod] - public void Test_5437() - { - } - [TestMethod] - public void Test_5438() - { - } - [TestMethod] - public void Test_5439() - { - } - [TestMethod] - public void Test_5440() - { - } - [TestMethod] - public void Test_5441() - { - } - [TestMethod] - public void Test_5442() - { - } - [TestMethod] - public void Test_5443() - { - } - [TestMethod] - public void Test_5444() - { - } - [TestMethod] - public void Test_5445() - { - } - [TestMethod] - public void Test_5446() - { - } - [TestMethod] - public void Test_5447() - { - } - [TestMethod] - public void Test_5448() - { - } - [TestMethod] - public void Test_5449() - { - } - [TestMethod] - public void Test_5450() - { - } - [TestMethod] - public void Test_5451() - { - } - [TestMethod] - public void Test_5452() - { - } - [TestMethod] - public void Test_5453() - { - } - [TestMethod] - public void Test_5454() - { - } - [TestMethod] - public void Test_5455() - { - } - [TestMethod] - public void Test_5456() - { - } - [TestMethod] - public void Test_5457() - { - } - [TestMethod] - public void Test_5458() - { - } - [TestMethod] - public void Test_5459() - { - } - [TestMethod] - public void Test_5460() - { - } - [TestMethod] - public void Test_5461() - { - } - [TestMethod] - public void Test_5462() - { - } - [TestMethod] - public void Test_5463() - { - } - [TestMethod] - public void Test_5464() - { - } - [TestMethod] - public void Test_5465() - { - } - [TestMethod] - public void Test_5466() - { - } - [TestMethod] - public void Test_5467() - { - } - [TestMethod] - public void Test_5468() - { - } - [TestMethod] - public void Test_5469() - { - } - [TestMethod] - public void Test_5470() - { - } - [TestMethod] - public void Test_5471() - { - } - [TestMethod] - public void Test_5472() - { - } - [TestMethod] - public void Test_5473() - { - } - [TestMethod] - public void Test_5474() - { - } - [TestMethod] - public void Test_5475() - { - } - [TestMethod] - public void Test_5476() - { - } - [TestMethod] - public void Test_5477() - { - } - [TestMethod] - public void Test_5478() - { - } - [TestMethod] - public void Test_5479() - { - } - [TestMethod] - public void Test_5480() - { - } - [TestMethod] - public void Test_5481() - { - } - [TestMethod] - public void Test_5482() - { - } - [TestMethod] - public void Test_5483() - { - } - [TestMethod] - public void Test_5484() - { - } - [TestMethod] - public void Test_5485() - { - } - [TestMethod] - public void Test_5486() - { - } - [TestMethod] - public void Test_5487() - { - } - [TestMethod] - public void Test_5488() - { - } - [TestMethod] - public void Test_5489() - { - } - [TestMethod] - public void Test_5490() - { - } - [TestMethod] - public void Test_5491() - { - } - [TestMethod] - public void Test_5492() - { - } - [TestMethod] - public void Test_5493() - { - } - [TestMethod] - public void Test_5494() - { - } - [TestMethod] - public void Test_5495() - { - } - [TestMethod] - public void Test_5496() - { - } - [TestMethod] - public void Test_5497() - { - } - [TestMethod] - public void Test_5498() - { - } - [TestMethod] - public void Test_5499() - { - } - [TestMethod] - public void Test_5500() - { - } - [TestMethod] - public void Test_5501() - { - } - [TestMethod] - public void Test_5502() - { - } - [TestMethod] - public void Test_5503() - { - } - [TestMethod] - public void Test_5504() - { - } - [TestMethod] - public void Test_5505() - { - } - [TestMethod] - public void Test_5506() - { - } - [TestMethod] - public void Test_5507() - { - } - [TestMethod] - public void Test_5508() - { - } - [TestMethod] - public void Test_5509() - { - } - [TestMethod] - public void Test_5510() - { - } - [TestMethod] - public void Test_5511() - { - } - [TestMethod] - public void Test_5512() - { - } - [TestMethod] - public void Test_5513() - { - } - [TestMethod] - public void Test_5514() - { - } - [TestMethod] - public void Test_5515() - { - } - [TestMethod] - public void Test_5516() - { - } - [TestMethod] - public void Test_5517() - { - } - [TestMethod] - public void Test_5518() - { - } - [TestMethod] - public void Test_5519() - { - } - [TestMethod] - public void Test_5520() - { - } - [TestMethod] - public void Test_5521() - { - } - [TestMethod] - public void Test_5522() - { - } - [TestMethod] - public void Test_5523() - { - } - [TestMethod] - public void Test_5524() - { - } - [TestMethod] - public void Test_5525() - { - } - [TestMethod] - public void Test_5526() - { - } - [TestMethod] - public void Test_5527() - { - } - [TestMethod] - public void Test_5528() - { - } - [TestMethod] - public void Test_5529() - { - } - [TestMethod] - public void Test_5530() - { - } - [TestMethod] - public void Test_5531() - { - } - [TestMethod] - public void Test_5532() - { - } - [TestMethod] - public void Test_5533() - { - } - [TestMethod] - public void Test_5534() - { - } - [TestMethod] - public void Test_5535() - { - } - [TestMethod] - public void Test_5536() - { - } - [TestMethod] - public void Test_5537() - { - } - [TestMethod] - public void Test_5538() - { - } - [TestMethod] - public void Test_5539() - { - } - [TestMethod] - public void Test_5540() - { - } - [TestMethod] - public void Test_5541() - { - } - [TestMethod] - public void Test_5542() - { - } - [TestMethod] - public void Test_5543() - { - } - [TestMethod] - public void Test_5544() - { - } - [TestMethod] - public void Test_5545() - { - } - [TestMethod] - public void Test_5546() - { - } - [TestMethod] - public void Test_5547() - { - } - [TestMethod] - public void Test_5548() - { - } - [TestMethod] - public void Test_5549() - { - } - [TestMethod] - public void Test_5550() - { - } - [TestMethod] - public void Test_5551() - { - } - [TestMethod] - public void Test_5552() - { - } - [TestMethod] - public void Test_5553() - { - } - [TestMethod] - public void Test_5554() - { - } - [TestMethod] - public void Test_5555() - { - } - [TestMethod] - public void Test_5556() - { - } - [TestMethod] - public void Test_5557() - { - } - [TestMethod] - public void Test_5558() - { - } - [TestMethod] - public void Test_5559() - { - } - [TestMethod] - public void Test_5560() - { - } - [TestMethod] - public void Test_5561() - { - } - [TestMethod] - public void Test_5562() - { - } - [TestMethod] - public void Test_5563() - { - } - [TestMethod] - public void Test_5564() - { - } - [TestMethod] - public void Test_5565() - { - } - [TestMethod] - public void Test_5566() - { - } - [TestMethod] - public void Test_5567() - { - } - [TestMethod] - public void Test_5568() - { - } - [TestMethod] - public void Test_5569() - { - } - [TestMethod] - public void Test_5570() - { - } - [TestMethod] - public void Test_5571() - { - } - [TestMethod] - public void Test_5572() - { - } - [TestMethod] - public void Test_5573() - { - } - [TestMethod] - public void Test_5574() - { - } - [TestMethod] - public void Test_5575() - { - } - [TestMethod] - public void Test_5576() - { - } - [TestMethod] - public void Test_5577() - { - } - [TestMethod] - public void Test_5578() - { - } - [TestMethod] - public void Test_5579() - { - } - [TestMethod] - public void Test_5580() - { - } - [TestMethod] - public void Test_5581() - { - } - [TestMethod] - public void Test_5582() - { - } - [TestMethod] - public void Test_5583() - { - } - [TestMethod] - public void Test_5584() - { - } - [TestMethod] - public void Test_5585() - { - } - [TestMethod] - public void Test_5586() - { - } - [TestMethod] - public void Test_5587() - { - } - [TestMethod] - public void Test_5588() - { - } - [TestMethod] - public void Test_5589() - { - } - [TestMethod] - public void Test_5590() - { - } - [TestMethod] - public void Test_5591() - { - } - [TestMethod] - public void Test_5592() - { - } - [TestMethod] - public void Test_5593() - { - } - [TestMethod] - public void Test_5594() - { - } - [TestMethod] - public void Test_5595() - { - } - [TestMethod] - public void Test_5596() - { - } - [TestMethod] - public void Test_5597() - { - } - [TestMethod] - public void Test_5598() - { - } - [TestMethod] - public void Test_5599() - { - } - [TestMethod] - public void Test_5600() - { - } - [TestMethod] - public void Test_5601() - { - } - [TestMethod] - public void Test_5602() - { - } - [TestMethod] - public void Test_5603() - { - } - [TestMethod] - public void Test_5604() - { - } - [TestMethod] - public void Test_5605() - { - } - [TestMethod] - public void Test_5606() - { - } - [TestMethod] - public void Test_5607() - { - } - [TestMethod] - public void Test_5608() - { - } - [TestMethod] - public void Test_5609() - { - } - [TestMethod] - public void Test_5610() - { - } - [TestMethod] - public void Test_5611() - { - } - [TestMethod] - public void Test_5612() - { - } - [TestMethod] - public void Test_5613() - { - } - [TestMethod] - public void Test_5614() - { - } - [TestMethod] - public void Test_5615() - { - } - [TestMethod] - public void Test_5616() - { - } - [TestMethod] - public void Test_5617() - { - } - [TestMethod] - public void Test_5618() - { - } - [TestMethod] - public void Test_5619() - { - } - [TestMethod] - public void Test_5620() - { - } - [TestMethod] - public void Test_5621() - { - } - [TestMethod] - public void Test_5622() - { - } - [TestMethod] - public void Test_5623() - { - } - [TestMethod] - public void Test_5624() - { - } - [TestMethod] - public void Test_5625() - { - } - [TestMethod] - public void Test_5626() - { - } - [TestMethod] - public void Test_5627() - { - } - [TestMethod] - public void Test_5628() - { - } - [TestMethod] - public void Test_5629() - { - } - [TestMethod] - public void Test_5630() - { - } - [TestMethod] - public void Test_5631() - { - } - [TestMethod] - public void Test_5632() - { - } - [TestMethod] - public void Test_5633() - { - } - [TestMethod] - public void Test_5634() - { - } - [TestMethod] - public void Test_5635() - { - } - [TestMethod] - public void Test_5636() - { - } - [TestMethod] - public void Test_5637() - { - } - [TestMethod] - public void Test_5638() - { - } - [TestMethod] - public void Test_5639() - { - } - [TestMethod] - public void Test_5640() - { - } - [TestMethod] - public void Test_5641() - { - } - [TestMethod] - public void Test_5642() - { - } - [TestMethod] - public void Test_5643() - { - } - [TestMethod] - public void Test_5644() - { - } - [TestMethod] - public void Test_5645() - { - } - [TestMethod] - public void Test_5646() - { - } - [TestMethod] - public void Test_5647() - { - } - [TestMethod] - public void Test_5648() - { - } - [TestMethod] - public void Test_5649() - { - } - [TestMethod] - public void Test_5650() - { - } - [TestMethod] - public void Test_5651() - { - } - [TestMethod] - public void Test_5652() - { - } - [TestMethod] - public void Test_5653() - { - } - [TestMethod] - public void Test_5654() - { - } - [TestMethod] - public void Test_5655() - { - } - [TestMethod] - public void Test_5656() - { - } - [TestMethod] - public void Test_5657() - { - } - [TestMethod] - public void Test_5658() - { - } - [TestMethod] - public void Test_5659() - { - } - [TestMethod] - public void Test_5660() - { - } - [TestMethod] - public void Test_5661() - { - } - [TestMethod] - public void Test_5662() - { - } - [TestMethod] - public void Test_5663() - { - } - [TestMethod] - public void Test_5664() - { - } - [TestMethod] - public void Test_5665() - { - } - [TestMethod] - public void Test_5666() - { - } - [TestMethod] - public void Test_5667() - { - } - [TestMethod] - public void Test_5668() - { - } - [TestMethod] - public void Test_5669() - { - } - [TestMethod] - public void Test_5670() - { - } - [TestMethod] - public void Test_5671() - { - } - [TestMethod] - public void Test_5672() - { - } - [TestMethod] - public void Test_5673() - { - } - [TestMethod] - public void Test_5674() - { - } - [TestMethod] - public void Test_5675() - { - } - [TestMethod] - public void Test_5676() - { - } - [TestMethod] - public void Test_5677() - { - } - [TestMethod] - public void Test_5678() - { - } - [TestMethod] - public void Test_5679() - { - } - [TestMethod] - public void Test_5680() - { - } - [TestMethod] - public void Test_5681() - { - } - [TestMethod] - public void Test_5682() - { - } - [TestMethod] - public void Test_5683() - { - } - [TestMethod] - public void Test_5684() - { - } - [TestMethod] - public void Test_5685() - { - } - [TestMethod] - public void Test_5686() - { - } - [TestMethod] - public void Test_5687() - { - } - [TestMethod] - public void Test_5688() - { - } - [TestMethod] - public void Test_5689() - { - } - [TestMethod] - public void Test_5690() - { - } - [TestMethod] - public void Test_5691() - { - } - [TestMethod] - public void Test_5692() - { - } - [TestMethod] - public void Test_5693() - { - } - [TestMethod] - public void Test_5694() - { - } - [TestMethod] - public void Test_5695() - { - } - [TestMethod] - public void Test_5696() - { - } - [TestMethod] - public void Test_5697() - { - } - [TestMethod] - public void Test_5698() - { - } - [TestMethod] - public void Test_5699() - { - } - [TestMethod] - public void Test_5700() - { - } - [TestMethod] - public void Test_5701() - { - } - [TestMethod] - public void Test_5702() - { - } - [TestMethod] - public void Test_5703() - { - } - [TestMethod] - public void Test_5704() - { - } - [TestMethod] - public void Test_5705() - { - } - [TestMethod] - public void Test_5706() - { - } - [TestMethod] - public void Test_5707() - { - } - [TestMethod] - public void Test_5708() - { - } - [TestMethod] - public void Test_5709() - { - } - [TestMethod] - public void Test_5710() - { - } - [TestMethod] - public void Test_5711() - { - } - [TestMethod] - public void Test_5712() - { - } - [TestMethod] - public void Test_5713() - { - } - [TestMethod] - public void Test_5714() - { - } - [TestMethod] - public void Test_5715() - { - } - [TestMethod] - public void Test_5716() - { - } - [TestMethod] - public void Test_5717() - { - } - [TestMethod] - public void Test_5718() - { - } - [TestMethod] - public void Test_5719() - { - } - [TestMethod] - public void Test_5720() - { - } - [TestMethod] - public void Test_5721() - { - } - [TestMethod] - public void Test_5722() - { - } - [TestMethod] - public void Test_5723() - { - } - [TestMethod] - public void Test_5724() - { - } - [TestMethod] - public void Test_5725() - { - } - [TestMethod] - public void Test_5726() - { - } - [TestMethod] - public void Test_5727() - { - } - [TestMethod] - public void Test_5728() - { - } - [TestMethod] - public void Test_5729() - { - } - [TestMethod] - public void Test_5730() - { - } - [TestMethod] - public void Test_5731() - { - } - [TestMethod] - public void Test_5732() - { - } - [TestMethod] - public void Test_5733() - { - } - [TestMethod] - public void Test_5734() - { - } - [TestMethod] - public void Test_5735() - { - } - [TestMethod] - public void Test_5736() - { - } - [TestMethod] - public void Test_5737() - { - } - [TestMethod] - public void Test_5738() - { - } - [TestMethod] - public void Test_5739() - { - } - [TestMethod] - public void Test_5740() - { - } - [TestMethod] - public void Test_5741() - { - } - [TestMethod] - public void Test_5742() - { - } - [TestMethod] - public void Test_5743() - { - } - [TestMethod] - public void Test_5744() - { - } - [TestMethod] - public void Test_5745() - { - } - [TestMethod] - public void Test_5746() - { - } - [TestMethod] - public void Test_5747() - { - } - [TestMethod] - public void Test_5748() - { - } - [TestMethod] - public void Test_5749() - { - } - [TestMethod] - public void Test_5750() - { - } - [TestMethod] - public void Test_5751() - { - } - [TestMethod] - public void Test_5752() - { - } - [TestMethod] - public void Test_5753() - { - } - [TestMethod] - public void Test_5754() - { - } - [TestMethod] - public void Test_5755() - { - } - [TestMethod] - public void Test_5756() - { - } - [TestMethod] - public void Test_5757() - { - } - [TestMethod] - public void Test_5758() - { - } - [TestMethod] - public void Test_5759() - { - } - [TestMethod] - public void Test_5760() - { - } - [TestMethod] - public void Test_5761() - { - } - [TestMethod] - public void Test_5762() - { - } - [TestMethod] - public void Test_5763() - { - } - [TestMethod] - public void Test_5764() - { - } - [TestMethod] - public void Test_5765() - { - } - [TestMethod] - public void Test_5766() - { - } - [TestMethod] - public void Test_5767() - { - } - [TestMethod] - public void Test_5768() - { - } - [TestMethod] - public void Test_5769() - { - } - [TestMethod] - public void Test_5770() - { - } - [TestMethod] - public void Test_5771() - { - } - [TestMethod] - public void Test_5772() - { - } - [TestMethod] - public void Test_5773() - { - } - [TestMethod] - public void Test_5774() - { - } - [TestMethod] - public void Test_5775() - { - } - [TestMethod] - public void Test_5776() - { - } - [TestMethod] - public void Test_5777() - { - } - [TestMethod] - public void Test_5778() - { - } - [TestMethod] - public void Test_5779() - { - } - [TestMethod] - public void Test_5780() - { - } - [TestMethod] - public void Test_5781() - { - } - [TestMethod] - public void Test_5782() - { - } - [TestMethod] - public void Test_5783() - { - } - [TestMethod] - public void Test_5784() - { - } - [TestMethod] - public void Test_5785() - { - } - [TestMethod] - public void Test_5786() - { - } - [TestMethod] - public void Test_5787() - { - } - [TestMethod] - public void Test_5788() - { - } - [TestMethod] - public void Test_5789() - { - } - [TestMethod] - public void Test_5790() - { - } - [TestMethod] - public void Test_5791() - { - } - [TestMethod] - public void Test_5792() - { - } - [TestMethod] - public void Test_5793() - { - } - [TestMethod] - public void Test_5794() - { - } - [TestMethod] - public void Test_5795() - { - } - [TestMethod] - public void Test_5796() - { - } - [TestMethod] - public void Test_5797() - { - } - [TestMethod] - public void Test_5798() - { - } - [TestMethod] - public void Test_5799() - { - } - [TestMethod] - public void Test_5800() - { - } - [TestMethod] - public void Test_5801() - { - } - [TestMethod] - public void Test_5802() - { - } - [TestMethod] - public void Test_5803() - { - } - [TestMethod] - public void Test_5804() - { - } - [TestMethod] - public void Test_5805() - { - } - [TestMethod] - public void Test_5806() - { - } - [TestMethod] - public void Test_5807() - { - } - [TestMethod] - public void Test_5808() - { - } - [TestMethod] - public void Test_5809() - { - } - [TestMethod] - public void Test_5810() - { - } - [TestMethod] - public void Test_5811() - { - } - [TestMethod] - public void Test_5812() - { - } - [TestMethod] - public void Test_5813() - { - } - [TestMethod] - public void Test_5814() - { - } - [TestMethod] - public void Test_5815() - { - } - [TestMethod] - public void Test_5816() - { - } - [TestMethod] - public void Test_5817() - { - } - [TestMethod] - public void Test_5818() - { - } - [TestMethod] - public void Test_5819() - { - } - [TestMethod] - public void Test_5820() - { - } - [TestMethod] - public void Test_5821() - { - } - [TestMethod] - public void Test_5822() - { - } - [TestMethod] - public void Test_5823() - { - } - [TestMethod] - public void Test_5824() - { - } - [TestMethod] - public void Test_5825() - { - } - [TestMethod] - public void Test_5826() - { - } - [TestMethod] - public void Test_5827() - { - } - [TestMethod] - public void Test_5828() - { - } - [TestMethod] - public void Test_5829() - { - } - [TestMethod] - public void Test_5830() - { - } - [TestMethod] - public void Test_5831() - { - } - [TestMethod] - public void Test_5832() - { - } - [TestMethod] - public void Test_5833() - { - } - [TestMethod] - public void Test_5834() - { - } - [TestMethod] - public void Test_5835() - { - } - [TestMethod] - public void Test_5836() - { - } - [TestMethod] - public void Test_5837() - { - } - [TestMethod] - public void Test_5838() - { - } - [TestMethod] - public void Test_5839() - { - } - [TestMethod] - public void Test_5840() - { - } - [TestMethod] - public void Test_5841() - { - } - [TestMethod] - public void Test_5842() - { - } - [TestMethod] - public void Test_5843() - { - } - [TestMethod] - public void Test_5844() - { - } - [TestMethod] - public void Test_5845() - { - } - [TestMethod] - public void Test_5846() - { - } - [TestMethod] - public void Test_5847() - { - } - [TestMethod] - public void Test_5848() - { - } - [TestMethod] - public void Test_5849() - { - } - [TestMethod] - public void Test_5850() - { - } - [TestMethod] - public void Test_5851() - { - } - [TestMethod] - public void Test_5852() - { - } - [TestMethod] - public void Test_5853() - { - } - [TestMethod] - public void Test_5854() - { - } - [TestMethod] - public void Test_5855() - { - } - [TestMethod] - public void Test_5856() - { - } - [TestMethod] - public void Test_5857() - { - } - [TestMethod] - public void Test_5858() - { - } - [TestMethod] - public void Test_5859() - { - } - [TestMethod] - public void Test_5860() - { - } - [TestMethod] - public void Test_5861() - { - } - [TestMethod] - public void Test_5862() - { - } - [TestMethod] - public void Test_5863() - { - } - [TestMethod] - public void Test_5864() - { - } - [TestMethod] - public void Test_5865() - { - } - [TestMethod] - public void Test_5866() - { - } - [TestMethod] - public void Test_5867() - { - } - [TestMethod] - public void Test_5868() - { - } - [TestMethod] - public void Test_5869() - { - } - [TestMethod] - public void Test_5870() - { - } - [TestMethod] - public void Test_5871() - { - } - [TestMethod] - public void Test_5872() - { - } - [TestMethod] - public void Test_5873() - { - } - [TestMethod] - public void Test_5874() - { - } - [TestMethod] - public void Test_5875() - { - } - [TestMethod] - public void Test_5876() - { - } - [TestMethod] - public void Test_5877() - { - } - [TestMethod] - public void Test_5878() - { - } - [TestMethod] - public void Test_5879() - { - } - [TestMethod] - public void Test_5880() - { - } - [TestMethod] - public void Test_5881() - { - } - [TestMethod] - public void Test_5882() - { - } - [TestMethod] - public void Test_5883() - { - } - [TestMethod] - public void Test_5884() - { - } - [TestMethod] - public void Test_5885() - { - } - [TestMethod] - public void Test_5886() - { - } - [TestMethod] - public void Test_5887() - { - } - [TestMethod] - public void Test_5888() - { - } - [TestMethod] - public void Test_5889() - { - } - [TestMethod] - public void Test_5890() - { - } - [TestMethod] - public void Test_5891() - { - } - [TestMethod] - public void Test_5892() - { - } - [TestMethod] - public void Test_5893() - { - } - [TestMethod] - public void Test_5894() - { - } - [TestMethod] - public void Test_5895() - { - } - [TestMethod] - public void Test_5896() - { - } - [TestMethod] - public void Test_5897() - { - } - [TestMethod] - public void Test_5898() - { - } - [TestMethod] - public void Test_5899() - { - } - [TestMethod] - public void Test_5900() - { - } - [TestMethod] - public void Test_5901() - { - } - [TestMethod] - public void Test_5902() - { - } - [TestMethod] - public void Test_5903() - { - } - [TestMethod] - public void Test_5904() - { - } - [TestMethod] - public void Test_5905() - { - } - [TestMethod] - public void Test_5906() - { - } - [TestMethod] - public void Test_5907() - { - } - [TestMethod] - public void Test_5908() - { - } - [TestMethod] - public void Test_5909() - { - } - [TestMethod] - public void Test_5910() - { - } - [TestMethod] - public void Test_5911() - { - } - [TestMethod] - public void Test_5912() - { - } - [TestMethod] - public void Test_5913() - { - } - [TestMethod] - public void Test_5914() - { - } - [TestMethod] - public void Test_5915() - { - } - [TestMethod] - public void Test_5916() - { - } - [TestMethod] - public void Test_5917() - { - } - [TestMethod] - public void Test_5918() - { - } - [TestMethod] - public void Test_5919() - { - } - [TestMethod] - public void Test_5920() - { - } - [TestMethod] - public void Test_5921() - { - } - [TestMethod] - public void Test_5922() - { - } - [TestMethod] - public void Test_5923() - { - } - [TestMethod] - public void Test_5924() - { - } - [TestMethod] - public void Test_5925() - { - } - [TestMethod] - public void Test_5926() - { - } - [TestMethod] - public void Test_5927() - { - } - [TestMethod] - public void Test_5928() - { - } - [TestMethod] - public void Test_5929() - { - } - [TestMethod] - public void Test_5930() - { - } - [TestMethod] - public void Test_5931() - { - } - [TestMethod] - public void Test_5932() - { - } - [TestMethod] - public void Test_5933() - { - } - [TestMethod] - public void Test_5934() - { - } - [TestMethod] - public void Test_5935() - { - } - [TestMethod] - public void Test_5936() - { - } - [TestMethod] - public void Test_5937() - { - } - [TestMethod] - public void Test_5938() - { - } - [TestMethod] - public void Test_5939() - { - } - [TestMethod] - public void Test_5940() - { - } - [TestMethod] - public void Test_5941() - { - } - [TestMethod] - public void Test_5942() - { - } - [TestMethod] - public void Test_5943() - { - } - [TestMethod] - public void Test_5944() - { - } - [TestMethod] - public void Test_5945() - { - } - [TestMethod] - public void Test_5946() - { - } - [TestMethod] - public void Test_5947() - { - } - [TestMethod] - public void Test_5948() - { - } - [TestMethod] - public void Test_5949() - { - } - [TestMethod] - public void Test_5950() - { - } - [TestMethod] - public void Test_5951() - { - } - [TestMethod] - public void Test_5952() - { - } - [TestMethod] - public void Test_5953() - { - } - [TestMethod] - public void Test_5954() - { - } - [TestMethod] - public void Test_5955() - { - } - [TestMethod] - public void Test_5956() - { - } - [TestMethod] - public void Test_5957() - { - } - [TestMethod] - public void Test_5958() - { - } - [TestMethod] - public void Test_5959() - { - } - [TestMethod] - public void Test_5960() - { - } - [TestMethod] - public void Test_5961() - { - } - [TestMethod] - public void Test_5962() - { - } - [TestMethod] - public void Test_5963() - { - } - [TestMethod] - public void Test_5964() - { - } - [TestMethod] - public void Test_5965() - { - } - [TestMethod] - public void Test_5966() - { - } - [TestMethod] - public void Test_5967() - { - } - [TestMethod] - public void Test_5968() - { - } - [TestMethod] - public void Test_5969() - { - } - [TestMethod] - public void Test_5970() - { - } - [TestMethod] - public void Test_5971() - { - } - [TestMethod] - public void Test_5972() - { - } - [TestMethod] - public void Test_5973() - { - } - [TestMethod] - public void Test_5974() - { - } - [TestMethod] - public void Test_5975() - { - } - [TestMethod] - public void Test_5976() - { - } - [TestMethod] - public void Test_5977() - { - } - [TestMethod] - public void Test_5978() - { - } - [TestMethod] - public void Test_5979() - { - } - [TestMethod] - public void Test_5980() - { - } - [TestMethod] - public void Test_5981() - { - } - [TestMethod] - public void Test_5982() - { - } - [TestMethod] - public void Test_5983() - { - } - [TestMethod] - public void Test_5984() - { - } - [TestMethod] - public void Test_5985() - { - } - [TestMethod] - public void Test_5986() - { - } - [TestMethod] - public void Test_5987() - { - } - [TestMethod] - public void Test_5988() - { - } - [TestMethod] - public void Test_5989() - { - } - [TestMethod] - public void Test_5990() - { - } - [TestMethod] - public void Test_5991() - { - } - [TestMethod] - public void Test_5992() - { - } - [TestMethod] - public void Test_5993() - { - } - [TestMethod] - public void Test_5994() - { - } - [TestMethod] - public void Test_5995() - { - } - [TestMethod] - public void Test_5996() - { - } - [TestMethod] - public void Test_5997() - { - } - [TestMethod] - public void Test_5998() - { - } - [TestMethod] - public void Test_5999() - { - } - [TestMethod] - public void Test_6000() - { - } - [TestMethod] - public void Test_6001() - { - } - [TestMethod] - public void Test_6002() - { - } - [TestMethod] - public void Test_6003() - { - } - [TestMethod] - public void Test_6004() - { - } - [TestMethod] - public void Test_6005() - { - } - [TestMethod] - public void Test_6006() - { - } - [TestMethod] - public void Test_6007() - { - } - [TestMethod] - public void Test_6008() - { - } - [TestMethod] - public void Test_6009() - { - } - [TestMethod] - public void Test_6010() - { - } - [TestMethod] - public void Test_6011() - { - } - [TestMethod] - public void Test_6012() - { - } - [TestMethod] - public void Test_6013() - { - } - [TestMethod] - public void Test_6014() - { - } - [TestMethod] - public void Test_6015() - { - } - [TestMethod] - public void Test_6016() - { - } - [TestMethod] - public void Test_6017() - { - } - [TestMethod] - public void Test_6018() - { - } - [TestMethod] - public void Test_6019() - { - } - [TestMethod] - public void Test_6020() - { - } - [TestMethod] - public void Test_6021() - { - } - [TestMethod] - public void Test_6022() - { - } - [TestMethod] - public void Test_6023() - { - } - [TestMethod] - public void Test_6024() - { - } - [TestMethod] - public void Test_6025() - { - } - [TestMethod] - public void Test_6026() - { - } - [TestMethod] - public void Test_6027() - { - } - [TestMethod] - public void Test_6028() - { - } - [TestMethod] - public void Test_6029() - { - } - [TestMethod] - public void Test_6030() - { - } - [TestMethod] - public void Test_6031() - { - } - [TestMethod] - public void Test_6032() - { - } - [TestMethod] - public void Test_6033() - { - } - [TestMethod] - public void Test_6034() - { - } - [TestMethod] - public void Test_6035() - { - } - [TestMethod] - public void Test_6036() - { - } - [TestMethod] - public void Test_6037() - { - } - [TestMethod] - public void Test_6038() - { - } - [TestMethod] - public void Test_6039() - { - } - [TestMethod] - public void Test_6040() - { - } - [TestMethod] - public void Test_6041() - { - } - [TestMethod] - public void Test_6042() - { - } - [TestMethod] - public void Test_6043() - { - } - [TestMethod] - public void Test_6044() - { - } - [TestMethod] - public void Test_6045() - { - } - [TestMethod] - public void Test_6046() - { - } - [TestMethod] - public void Test_6047() - { - } - [TestMethod] - public void Test_6048() - { - } - [TestMethod] - public void Test_6049() - { - } - [TestMethod] - public void Test_6050() - { - } - [TestMethod] - public void Test_6051() - { - } - [TestMethod] - public void Test_6052() - { - } - [TestMethod] - public void Test_6053() - { - } - [TestMethod] - public void Test_6054() - { - } - [TestMethod] - public void Test_6055() - { - } - [TestMethod] - public void Test_6056() - { - } - [TestMethod] - public void Test_6057() - { - } - [TestMethod] - public void Test_6058() - { - } - [TestMethod] - public void Test_6059() - { - } - [TestMethod] - public void Test_6060() - { - } - [TestMethod] - public void Test_6061() - { - } - [TestMethod] - public void Test_6062() - { - } - [TestMethod] - public void Test_6063() - { - } - [TestMethod] - public void Test_6064() - { - } - [TestMethod] - public void Test_6065() - { - } - [TestMethod] - public void Test_6066() - { - } - [TestMethod] - public void Test_6067() - { - } - [TestMethod] - public void Test_6068() - { - } - [TestMethod] - public void Test_6069() - { - } - [TestMethod] - public void Test_6070() - { - } - [TestMethod] - public void Test_6071() - { - } - [TestMethod] - public void Test_6072() - { - } - [TestMethod] - public void Test_6073() - { - } - [TestMethod] - public void Test_6074() - { - } - [TestMethod] - public void Test_6075() - { - } - [TestMethod] - public void Test_6076() - { - } - [TestMethod] - public void Test_6077() - { - } - [TestMethod] - public void Test_6078() - { - } - [TestMethod] - public void Test_6079() - { - } - [TestMethod] - public void Test_6080() - { - } - [TestMethod] - public void Test_6081() - { - } - [TestMethod] - public void Test_6082() - { - } - [TestMethod] - public void Test_6083() - { - } - [TestMethod] - public void Test_6084() - { - } - [TestMethod] - public void Test_6085() - { - } - [TestMethod] - public void Test_6086() - { - } - [TestMethod] - public void Test_6087() - { - } - [TestMethod] - public void Test_6088() - { - } - [TestMethod] - public void Test_6089() - { - } - [TestMethod] - public void Test_6090() - { - } - [TestMethod] - public void Test_6091() - { - } - [TestMethod] - public void Test_6092() - { - } - [TestMethod] - public void Test_6093() - { - } - [TestMethod] - public void Test_6094() - { - } - [TestMethod] - public void Test_6095() - { - } - [TestMethod] - public void Test_6096() - { - } - [TestMethod] - public void Test_6097() - { - } - [TestMethod] - public void Test_6098() - { - } - [TestMethod] - public void Test_6099() - { - } - [TestMethod] - public void Test_6100() - { - } - [TestMethod] - public void Test_6101() - { - } - [TestMethod] - public void Test_6102() - { - } - [TestMethod] - public void Test_6103() - { - } - [TestMethod] - public void Test_6104() - { - } - [TestMethod] - public void Test_6105() - { - } - [TestMethod] - public void Test_6106() - { - } - [TestMethod] - public void Test_6107() - { - } - [TestMethod] - public void Test_6108() - { - } - [TestMethod] - public void Test_6109() - { - } - [TestMethod] - public void Test_6110() - { - } - [TestMethod] - public void Test_6111() - { - } - [TestMethod] - public void Test_6112() - { - } - [TestMethod] - public void Test_6113() - { - } - [TestMethod] - public void Test_6114() - { - } - [TestMethod] - public void Test_6115() - { - } - [TestMethod] - public void Test_6116() - { - } - [TestMethod] - public void Test_6117() - { - } - [TestMethod] - public void Test_6118() - { - } - [TestMethod] - public void Test_6119() - { - } - [TestMethod] - public void Test_6120() - { - } - [TestMethod] - public void Test_6121() - { - } - [TestMethod] - public void Test_6122() - { - } - [TestMethod] - public void Test_6123() - { - } - [TestMethod] - public void Test_6124() - { - } - [TestMethod] - public void Test_6125() - { - } - [TestMethod] - public void Test_6126() - { - } - [TestMethod] - public void Test_6127() - { - } - [TestMethod] - public void Test_6128() - { - } - [TestMethod] - public void Test_6129() - { - } - [TestMethod] - public void Test_6130() - { - } - [TestMethod] - public void Test_6131() - { - } - [TestMethod] - public void Test_6132() - { - } - [TestMethod] - public void Test_6133() - { - } - [TestMethod] - public void Test_6134() - { - } - [TestMethod] - public void Test_6135() - { - } - [TestMethod] - public void Test_6136() - { - } - [TestMethod] - public void Test_6137() - { - } - [TestMethod] - public void Test_6138() - { - } - [TestMethod] - public void Test_6139() - { - } - [TestMethod] - public void Test_6140() - { - } - [TestMethod] - public void Test_6141() - { - } - [TestMethod] - public void Test_6142() - { - } - [TestMethod] - public void Test_6143() - { - } - [TestMethod] - public void Test_6144() - { - } - [TestMethod] - public void Test_6145() - { - } - [TestMethod] - public void Test_6146() - { - } - [TestMethod] - public void Test_6147() - { - } - [TestMethod] - public void Test_6148() - { - } - [TestMethod] - public void Test_6149() - { - } - [TestMethod] - public void Test_6150() - { - } - [TestMethod] - public void Test_6151() - { - } - [TestMethod] - public void Test_6152() - { - } - [TestMethod] - public void Test_6153() - { - } - [TestMethod] - public void Test_6154() - { - } - [TestMethod] - public void Test_6155() - { - } - [TestMethod] - public void Test_6156() - { - } - [TestMethod] - public void Test_6157() - { - } - [TestMethod] - public void Test_6158() - { - } - [TestMethod] - public void Test_6159() - { - } - [TestMethod] - public void Test_6160() - { - } - [TestMethod] - public void Test_6161() - { - } - [TestMethod] - public void Test_6162() - { - } - [TestMethod] - public void Test_6163() - { - } - [TestMethod] - public void Test_6164() - { - } - [TestMethod] - public void Test_6165() - { - } - [TestMethod] - public void Test_6166() - { - } - [TestMethod] - public void Test_6167() - { - } - [TestMethod] - public void Test_6168() - { - } - [TestMethod] - public void Test_6169() - { - } - [TestMethod] - public void Test_6170() - { - } - [TestMethod] - public void Test_6171() - { - } - [TestMethod] - public void Test_6172() - { - } - [TestMethod] - public void Test_6173() - { - } - [TestMethod] - public void Test_6174() - { - } - [TestMethod] - public void Test_6175() - { - } - [TestMethod] - public void Test_6176() - { - } - [TestMethod] - public void Test_6177() - { - } - [TestMethod] - public void Test_6178() - { - } - [TestMethod] - public void Test_6179() - { - } - [TestMethod] - public void Test_6180() - { - } - [TestMethod] - public void Test_6181() - { - } - [TestMethod] - public void Test_6182() - { - } - [TestMethod] - public void Test_6183() - { - } - [TestMethod] - public void Test_6184() - { - } - [TestMethod] - public void Test_6185() - { - } - [TestMethod] - public void Test_6186() - { - } - [TestMethod] - public void Test_6187() - { - } - [TestMethod] - public void Test_6188() - { - } - [TestMethod] - public void Test_6189() - { - } - [TestMethod] - public void Test_6190() - { - } - [TestMethod] - public void Test_6191() - { - } - [TestMethod] - public void Test_6192() - { - } - [TestMethod] - public void Test_6193() - { - } - [TestMethod] - public void Test_6194() - { - } - [TestMethod] - public void Test_6195() - { - } - [TestMethod] - public void Test_6196() - { - } - [TestMethod] - public void Test_6197() - { - } - [TestMethod] - public void Test_6198() - { - } - [TestMethod] - public void Test_6199() - { - } - [TestMethod] - public void Test_6200() - { - } - [TestMethod] - public void Test_6201() - { - } - [TestMethod] - public void Test_6202() - { - } - [TestMethod] - public void Test_6203() - { - } - [TestMethod] - public void Test_6204() - { - } - [TestMethod] - public void Test_6205() - { - } - [TestMethod] - public void Test_6206() - { - } - [TestMethod] - public void Test_6207() - { - } - [TestMethod] - public void Test_6208() - { - } - [TestMethod] - public void Test_6209() - { - } - [TestMethod] - public void Test_6210() - { - } - [TestMethod] - public void Test_6211() - { - } - [TestMethod] - public void Test_6212() - { - } - [TestMethod] - public void Test_6213() - { - } - [TestMethod] - public void Test_6214() - { - } - [TestMethod] - public void Test_6215() - { - } - [TestMethod] - public void Test_6216() - { - } - [TestMethod] - public void Test_6217() - { - } - [TestMethod] - public void Test_6218() - { - } - [TestMethod] - public void Test_6219() - { - } - [TestMethod] - public void Test_6220() - { - } - [TestMethod] - public void Test_6221() - { - } - [TestMethod] - public void Test_6222() - { - } - [TestMethod] - public void Test_6223() - { - } - [TestMethod] - public void Test_6224() - { - } - [TestMethod] - public void Test_6225() - { - } - [TestMethod] - public void Test_6226() - { - } - [TestMethod] - public void Test_6227() - { - } - [TestMethod] - public void Test_6228() - { - } - [TestMethod] - public void Test_6229() - { - } - [TestMethod] - public void Test_6230() - { - } - [TestMethod] - public void Test_6231() - { - } - [TestMethod] - public void Test_6232() - { - } - [TestMethod] - public void Test_6233() - { - } - [TestMethod] - public void Test_6234() - { - } - [TestMethod] - public void Test_6235() - { - } - [TestMethod] - public void Test_6236() - { - } - [TestMethod] - public void Test_6237() - { - } - [TestMethod] - public void Test_6238() - { - } - [TestMethod] - public void Test_6239() - { - } - [TestMethod] - public void Test_6240() - { - } - [TestMethod] - public void Test_6241() - { - } - [TestMethod] - public void Test_6242() - { - } - [TestMethod] - public void Test_6243() - { - } - [TestMethod] - public void Test_6244() - { - } - [TestMethod] - public void Test_6245() - { - } - [TestMethod] - public void Test_6246() - { - } - [TestMethod] - public void Test_6247() - { - } - [TestMethod] - public void Test_6248() - { - } - [TestMethod] - public void Test_6249() - { - } - [TestMethod] - public void Test_6250() - { - } - [TestMethod] - public void Test_6251() - { - } - [TestMethod] - public void Test_6252() - { - } - [TestMethod] - public void Test_6253() - { - } - [TestMethod] - public void Test_6254() - { - } - [TestMethod] - public void Test_6255() - { - } - [TestMethod] - public void Test_6256() - { - } - [TestMethod] - public void Test_6257() - { - } - [TestMethod] - public void Test_6258() - { - } - [TestMethod] - public void Test_6259() - { - } - [TestMethod] - public void Test_6260() - { - } - [TestMethod] - public void Test_6261() - { - } - [TestMethod] - public void Test_6262() - { - } - [TestMethod] - public void Test_6263() - { - } - [TestMethod] - public void Test_6264() - { - } - [TestMethod] - public void Test_6265() - { - } - [TestMethod] - public void Test_6266() - { - } - [TestMethod] - public void Test_6267() - { - } - [TestMethod] - public void Test_6268() - { - } - [TestMethod] - public void Test_6269() - { - } - [TestMethod] - public void Test_6270() - { - } - [TestMethod] - public void Test_6271() - { - } - [TestMethod] - public void Test_6272() - { - } - [TestMethod] - public void Test_6273() - { - } - [TestMethod] - public void Test_6274() - { - } - [TestMethod] - public void Test_6275() - { - } - [TestMethod] - public void Test_6276() - { - } - [TestMethod] - public void Test_6277() - { - } - [TestMethod] - public void Test_6278() - { - } - [TestMethod] - public void Test_6279() - { - } - [TestMethod] - public void Test_6280() - { - } - [TestMethod] - public void Test_6281() - { - } - [TestMethod] - public void Test_6282() - { - } - [TestMethod] - public void Test_6283() - { - } - [TestMethod] - public void Test_6284() - { - } - [TestMethod] - public void Test_6285() - { - } - [TestMethod] - public void Test_6286() - { - } - [TestMethod] - public void Test_6287() - { - } - [TestMethod] - public void Test_6288() - { - } - [TestMethod] - public void Test_6289() - { - } - [TestMethod] - public void Test_6290() - { - } - [TestMethod] - public void Test_6291() - { - } - [TestMethod] - public void Test_6292() - { - } - [TestMethod] - public void Test_6293() - { - } - [TestMethod] - public void Test_6294() - { - } - [TestMethod] - public void Test_6295() - { - } - [TestMethod] - public void Test_6296() - { - } - [TestMethod] - public void Test_6297() - { - } - [TestMethod] - public void Test_6298() - { - } - [TestMethod] - public void Test_6299() - { - } - [TestMethod] - public void Test_6300() - { - } - [TestMethod] - public void Test_6301() - { - } - [TestMethod] - public void Test_6302() - { - } - [TestMethod] - public void Test_6303() - { - } - [TestMethod] - public void Test_6304() - { - } - [TestMethod] - public void Test_6305() - { - } - [TestMethod] - public void Test_6306() - { - } - [TestMethod] - public void Test_6307() - { - } - [TestMethod] - public void Test_6308() - { - } - [TestMethod] - public void Test_6309() - { - } - [TestMethod] - public void Test_6310() - { - } - [TestMethod] - public void Test_6311() - { - } - [TestMethod] - public void Test_6312() - { - } - [TestMethod] - public void Test_6313() - { - } - [TestMethod] - public void Test_6314() - { - } - [TestMethod] - public void Test_6315() - { - } - [TestMethod] - public void Test_6316() - { - } - [TestMethod] - public void Test_6317() - { - } - [TestMethod] - public void Test_6318() - { - } - [TestMethod] - public void Test_6319() - { - } - [TestMethod] - public void Test_6320() - { - } - [TestMethod] - public void Test_6321() - { - } - [TestMethod] - public void Test_6322() - { - } - [TestMethod] - public void Test_6323() - { - } - [TestMethod] - public void Test_6324() - { - } - [TestMethod] - public void Test_6325() - { - } - [TestMethod] - public void Test_6326() - { - } - [TestMethod] - public void Test_6327() - { - } - [TestMethod] - public void Test_6328() - { - } - [TestMethod] - public void Test_6329() - { - } - [TestMethod] - public void Test_6330() - { - } - [TestMethod] - public void Test_6331() - { - } - [TestMethod] - public void Test_6332() - { - } - [TestMethod] - public void Test_6333() - { - } - [TestMethod] - public void Test_6334() - { - } - [TestMethod] - public void Test_6335() - { - } - [TestMethod] - public void Test_6336() - { - } - [TestMethod] - public void Test_6337() - { - } - [TestMethod] - public void Test_6338() - { - } - [TestMethod] - public void Test_6339() - { - } - [TestMethod] - public void Test_6340() - { - } - [TestMethod] - public void Test_6341() - { - } - [TestMethod] - public void Test_6342() - { - } - [TestMethod] - public void Test_6343() - { - } - [TestMethod] - public void Test_6344() - { - } - [TestMethod] - public void Test_6345() - { - } - [TestMethod] - public void Test_6346() - { - } - [TestMethod] - public void Test_6347() - { - } - [TestMethod] - public void Test_6348() - { - } - [TestMethod] - public void Test_6349() - { - } - [TestMethod] - public void Test_6350() - { - } - [TestMethod] - public void Test_6351() - { - } - [TestMethod] - public void Test_6352() - { - } - [TestMethod] - public void Test_6353() - { - } - [TestMethod] - public void Test_6354() - { - } - [TestMethod] - public void Test_6355() - { - } - [TestMethod] - public void Test_6356() - { - } - [TestMethod] - public void Test_6357() - { - } - [TestMethod] - public void Test_6358() - { - } - [TestMethod] - public void Test_6359() - { - } - [TestMethod] - public void Test_6360() - { - } - [TestMethod] - public void Test_6361() - { - } - [TestMethod] - public void Test_6362() - { - } - [TestMethod] - public void Test_6363() - { - } - [TestMethod] - public void Test_6364() - { - } - [TestMethod] - public void Test_6365() - { - } - [TestMethod] - public void Test_6366() - { - } - [TestMethod] - public void Test_6367() - { - } - [TestMethod] - public void Test_6368() - { - } - [TestMethod] - public void Test_6369() - { - } - [TestMethod] - public void Test_6370() - { - } - [TestMethod] - public void Test_6371() - { - } - [TestMethod] - public void Test_6372() - { - } - [TestMethod] - public void Test_6373() - { - } - [TestMethod] - public void Test_6374() - { - } - [TestMethod] - public void Test_6375() - { - } - [TestMethod] - public void Test_6376() - { - } - [TestMethod] - public void Test_6377() - { - } - [TestMethod] - public void Test_6378() - { - } - [TestMethod] - public void Test_6379() - { - } - [TestMethod] - public void Test_6380() - { - } - [TestMethod] - public void Test_6381() - { - } - [TestMethod] - public void Test_6382() - { - } - [TestMethod] - public void Test_6383() - { - } - [TestMethod] - public void Test_6384() - { - } - [TestMethod] - public void Test_6385() - { - } - [TestMethod] - public void Test_6386() - { - } - [TestMethod] - public void Test_6387() - { - } - [TestMethod] - public void Test_6388() - { - } - [TestMethod] - public void Test_6389() - { - } - [TestMethod] - public void Test_6390() - { - } - [TestMethod] - public void Test_6391() - { - } - [TestMethod] - public void Test_6392() - { - } - [TestMethod] - public void Test_6393() - { - } - [TestMethod] - public void Test_6394() - { - } - [TestMethod] - public void Test_6395() - { - } - [TestMethod] - public void Test_6396() - { - } - [TestMethod] - public void Test_6397() - { - } - [TestMethod] - public void Test_6398() - { - } - [TestMethod] - public void Test_6399() - { - } - [TestMethod] - public void Test_6400() - { - } - [TestMethod] - public void Test_6401() - { - } - [TestMethod] - public void Test_6402() - { - } - [TestMethod] - public void Test_6403() - { - } - [TestMethod] - public void Test_6404() - { - } - [TestMethod] - public void Test_6405() - { - } - [TestMethod] - public void Test_6406() - { - } - [TestMethod] - public void Test_6407() - { - } - [TestMethod] - public void Test_6408() - { - } - [TestMethod] - public void Test_6409() - { - } - [TestMethod] - public void Test_6410() - { - } - [TestMethod] - public void Test_6411() - { - } - [TestMethod] - public void Test_6412() - { - } - [TestMethod] - public void Test_6413() - { - } - [TestMethod] - public void Test_6414() - { - } - [TestMethod] - public void Test_6415() - { - } - [TestMethod] - public void Test_6416() - { - } - [TestMethod] - public void Test_6417() - { - } - [TestMethod] - public void Test_6418() - { - } - [TestMethod] - public void Test_6419() - { - } - [TestMethod] - public void Test_6420() - { - } - [TestMethod] - public void Test_6421() - { - } - [TestMethod] - public void Test_6422() - { - } - [TestMethod] - public void Test_6423() - { - } - [TestMethod] - public void Test_6424() - { - } - [TestMethod] - public void Test_6425() - { - } - [TestMethod] - public void Test_6426() - { - } - [TestMethod] - public void Test_6427() - { - } - [TestMethod] - public void Test_6428() - { - } - [TestMethod] - public void Test_6429() - { - } - [TestMethod] - public void Test_6430() - { - } - [TestMethod] - public void Test_6431() - { - } - [TestMethod] - public void Test_6432() - { - } - [TestMethod] - public void Test_6433() - { - } - [TestMethod] - public void Test_6434() - { - } - [TestMethod] - public void Test_6435() - { - } - [TestMethod] - public void Test_6436() - { - } - [TestMethod] - public void Test_6437() - { - } - [TestMethod] - public void Test_6438() - { - } - [TestMethod] - public void Test_6439() - { - } - [TestMethod] - public void Test_6440() - { - } - [TestMethod] - public void Test_6441() - { - } - [TestMethod] - public void Test_6442() - { - } - [TestMethod] - public void Test_6443() - { - } - [TestMethod] - public void Test_6444() - { - } - [TestMethod] - public void Test_6445() - { - } - [TestMethod] - public void Test_6446() - { - } - [TestMethod] - public void Test_6447() - { - } - [TestMethod] - public void Test_6448() - { - } - [TestMethod] - public void Test_6449() - { - } - [TestMethod] - public void Test_6450() - { - } - [TestMethod] - public void Test_6451() - { - } - [TestMethod] - public void Test_6452() - { - } - [TestMethod] - public void Test_6453() - { - } - [TestMethod] - public void Test_6454() - { - } - [TestMethod] - public void Test_6455() - { - } - [TestMethod] - public void Test_6456() - { - } - [TestMethod] - public void Test_6457() - { - } - [TestMethod] - public void Test_6458() - { - } - [TestMethod] - public void Test_6459() - { - } - [TestMethod] - public void Test_6460() - { - } - [TestMethod] - public void Test_6461() - { - } - [TestMethod] - public void Test_6462() - { - } - [TestMethod] - public void Test_6463() - { - } - [TestMethod] - public void Test_6464() - { - } - [TestMethod] - public void Test_6465() - { - } - [TestMethod] - public void Test_6466() - { - } - [TestMethod] - public void Test_6467() - { - } - [TestMethod] - public void Test_6468() - { - } - [TestMethod] - public void Test_6469() - { - } - [TestMethod] - public void Test_6470() - { - } - [TestMethod] - public void Test_6471() - { - } - [TestMethod] - public void Test_6472() - { - } - [TestMethod] - public void Test_6473() - { - } - [TestMethod] - public void Test_6474() - { - } - [TestMethod] - public void Test_6475() - { - } - [TestMethod] - public void Test_6476() - { - } - [TestMethod] - public void Test_6477() - { - } - [TestMethod] - public void Test_6478() - { - } - [TestMethod] - public void Test_6479() - { - } - [TestMethod] - public void Test_6480() - { - } - [TestMethod] - public void Test_6481() - { - } - [TestMethod] - public void Test_6482() - { - } - [TestMethod] - public void Test_6483() - { - } - [TestMethod] - public void Test_6484() - { - } - [TestMethod] - public void Test_6485() - { - } - [TestMethod] - public void Test_6486() - { - } - [TestMethod] - public void Test_6487() - { - } - [TestMethod] - public void Test_6488() - { - } - [TestMethod] - public void Test_6489() - { - } - [TestMethod] - public void Test_6490() - { - } - [TestMethod] - public void Test_6491() - { - } - [TestMethod] - public void Test_6492() - { - } - [TestMethod] - public void Test_6493() - { - } - [TestMethod] - public void Test_6494() - { - } - [TestMethod] - public void Test_6495() - { - } - [TestMethod] - public void Test_6496() - { - } - [TestMethod] - public void Test_6497() - { - } - [TestMethod] - public void Test_6498() - { - } - [TestMethod] - public void Test_6499() - { - } - [TestMethod] - public void Test_6500() - { - } - [TestMethod] - public void Test_6501() - { - } - [TestMethod] - public void Test_6502() - { - } - [TestMethod] - public void Test_6503() - { - } - [TestMethod] - public void Test_6504() - { - } - [TestMethod] - public void Test_6505() - { - } - [TestMethod] - public void Test_6506() - { - } - [TestMethod] - public void Test_6507() - { - } - [TestMethod] - public void Test_6508() - { - } - [TestMethod] - public void Test_6509() - { - } - [TestMethod] - public void Test_6510() - { - } - [TestMethod] - public void Test_6511() - { - } - [TestMethod] - public void Test_6512() - { - } - [TestMethod] - public void Test_6513() - { - } - [TestMethod] - public void Test_6514() - { - } - [TestMethod] - public void Test_6515() - { - } - [TestMethod] - public void Test_6516() - { - } - [TestMethod] - public void Test_6517() - { - } - [TestMethod] - public void Test_6518() - { - } - [TestMethod] - public void Test_6519() - { - } - [TestMethod] - public void Test_6520() - { - } - [TestMethod] - public void Test_6521() - { - } - [TestMethod] - public void Test_6522() - { - } - [TestMethod] - public void Test_6523() - { - } - [TestMethod] - public void Test_6524() - { - } - [TestMethod] - public void Test_6525() - { - } - [TestMethod] - public void Test_6526() - { - } - [TestMethod] - public void Test_6527() - { - } - [TestMethod] - public void Test_6528() - { - } - [TestMethod] - public void Test_6529() - { - } - [TestMethod] - public void Test_6530() - { - } - [TestMethod] - public void Test_6531() - { - } - [TestMethod] - public void Test_6532() - { - } - [TestMethod] - public void Test_6533() - { - } - [TestMethod] - public void Test_6534() - { - } - [TestMethod] - public void Test_6535() - { - } - [TestMethod] - public void Test_6536() - { - } - [TestMethod] - public void Test_6537() - { - } - [TestMethod] - public void Test_6538() - { - } - [TestMethod] - public void Test_6539() - { - } - [TestMethod] - public void Test_6540() - { - } - [TestMethod] - public void Test_6541() - { - } - [TestMethod] - public void Test_6542() - { - } - [TestMethod] - public void Test_6543() - { - } - [TestMethod] - public void Test_6544() - { - } - [TestMethod] - public void Test_6545() - { - } - [TestMethod] - public void Test_6546() - { - } - [TestMethod] - public void Test_6547() - { - } - [TestMethod] - public void Test_6548() - { - } - [TestMethod] - public void Test_6549() - { - } - [TestMethod] - public void Test_6550() - { - } - [TestMethod] - public void Test_6551() - { - } - [TestMethod] - public void Test_6552() - { - } - [TestMethod] - public void Test_6553() - { - } - [TestMethod] - public void Test_6554() - { - } - [TestMethod] - public void Test_6555() - { - } - [TestMethod] - public void Test_6556() - { - } - [TestMethod] - public void Test_6557() - { - } - [TestMethod] - public void Test_6558() - { - } - [TestMethod] - public void Test_6559() - { - } - [TestMethod] - public void Test_6560() - { - } - [TestMethod] - public void Test_6561() - { - } - [TestMethod] - public void Test_6562() - { - } - [TestMethod] - public void Test_6563() - { - } - [TestMethod] - public void Test_6564() - { - } - [TestMethod] - public void Test_6565() - { - } - [TestMethod] - public void Test_6566() - { - } - [TestMethod] - public void Test_6567() - { - } - [TestMethod] - public void Test_6568() - { - } - [TestMethod] - public void Test_6569() - { - } - [TestMethod] - public void Test_6570() - { - } - [TestMethod] - public void Test_6571() - { - } - [TestMethod] - public void Test_6572() - { - } - [TestMethod] - public void Test_6573() - { - } - [TestMethod] - public void Test_6574() - { - } - [TestMethod] - public void Test_6575() - { - } - [TestMethod] - public void Test_6576() - { - } - [TestMethod] - public void Test_6577() - { - } - [TestMethod] - public void Test_6578() - { - } - [TestMethod] - public void Test_6579() - { - } - [TestMethod] - public void Test_6580() - { - } - [TestMethod] - public void Test_6581() - { - } - [TestMethod] - public void Test_6582() - { - } - [TestMethod] - public void Test_6583() - { - } - [TestMethod] - public void Test_6584() - { - } - [TestMethod] - public void Test_6585() - { - } - [TestMethod] - public void Test_6586() - { - } - [TestMethod] - public void Test_6587() - { - } - [TestMethod] - public void Test_6588() - { - } - [TestMethod] - public void Test_6589() - { - } - [TestMethod] - public void Test_6590() - { - } - [TestMethod] - public void Test_6591() - { - } - [TestMethod] - public void Test_6592() - { - } - [TestMethod] - public void Test_6593() - { - } - [TestMethod] - public void Test_6594() - { - } - [TestMethod] - public void Test_6595() - { - } - [TestMethod] - public void Test_6596() - { - } - [TestMethod] - public void Test_6597() - { - } - [TestMethod] - public void Test_6598() - { - } - [TestMethod] - public void Test_6599() - { - } - [TestMethod] - public void Test_6600() - { - } - [TestMethod] - public void Test_6601() - { - } - [TestMethod] - public void Test_6602() - { - } - [TestMethod] - public void Test_6603() - { - } - [TestMethod] - public void Test_6604() - { - } - [TestMethod] - public void Test_6605() - { - } - [TestMethod] - public void Test_6606() - { - } - [TestMethod] - public void Test_6607() - { - } - [TestMethod] - public void Test_6608() - { - } - [TestMethod] - public void Test_6609() - { - } - [TestMethod] - public void Test_6610() - { - } - [TestMethod] - public void Test_6611() - { - } - [TestMethod] - public void Test_6612() - { - } - [TestMethod] - public void Test_6613() - { - } - [TestMethod] - public void Test_6614() - { - } - [TestMethod] - public void Test_6615() - { - } - [TestMethod] - public void Test_6616() - { - } - [TestMethod] - public void Test_6617() - { - } - [TestMethod] - public void Test_6618() - { - } - [TestMethod] - public void Test_6619() - { - } - [TestMethod] - public void Test_6620() - { - } - [TestMethod] - public void Test_6621() - { - } - [TestMethod] - public void Test_6622() - { - } - [TestMethod] - public void Test_6623() - { - } - [TestMethod] - public void Test_6624() - { - } - [TestMethod] - public void Test_6625() - { - } - [TestMethod] - public void Test_6626() - { - } - [TestMethod] - public void Test_6627() - { - } - [TestMethod] - public void Test_6628() - { - } - [TestMethod] - public void Test_6629() - { - } - [TestMethod] - public void Test_6630() - { - } - [TestMethod] - public void Test_6631() - { - } - [TestMethod] - public void Test_6632() - { - } - [TestMethod] - public void Test_6633() - { - } - [TestMethod] - public void Test_6634() - { - } - [TestMethod] - public void Test_6635() - { - } - [TestMethod] - public void Test_6636() - { - } - [TestMethod] - public void Test_6637() - { - } - [TestMethod] - public void Test_6638() - { - } - [TestMethod] - public void Test_6639() - { - } - [TestMethod] - public void Test_6640() - { - } - [TestMethod] - public void Test_6641() - { - } - [TestMethod] - public void Test_6642() - { - } - [TestMethod] - public void Test_6643() - { - } - [TestMethod] - public void Test_6644() - { - } - [TestMethod] - public void Test_6645() - { - } - [TestMethod] - public void Test_6646() - { - } - [TestMethod] - public void Test_6647() - { - } - [TestMethod] - public void Test_6648() - { - } - [TestMethod] - public void Test_6649() - { - } - [TestMethod] - public void Test_6650() - { - } - [TestMethod] - public void Test_6651() - { - } - [TestMethod] - public void Test_6652() - { - } - [TestMethod] - public void Test_6653() - { - } - [TestMethod] - public void Test_6654() - { - } - [TestMethod] - public void Test_6655() - { - } - [TestMethod] - public void Test_6656() - { - } - [TestMethod] - public void Test_6657() - { - } - [TestMethod] - public void Test_6658() - { - } - [TestMethod] - public void Test_6659() - { - } - [TestMethod] - public void Test_6660() - { - } - [TestMethod] - public void Test_6661() - { - } - [TestMethod] - public void Test_6662() - { - } - [TestMethod] - public void Test_6663() - { - } - [TestMethod] - public void Test_6664() - { - } - [TestMethod] - public void Test_6665() - { - } - [TestMethod] - public void Test_6666() - { - } - [TestMethod] - public void Test_6667() - { - } - [TestMethod] - public void Test_6668() - { - } - [TestMethod] - public void Test_6669() - { - } - [TestMethod] - public void Test_6670() - { - } - [TestMethod] - public void Test_6671() - { - } - [TestMethod] - public void Test_6672() - { - } - [TestMethod] - public void Test_6673() - { - } - [TestMethod] - public void Test_6674() - { - } - [TestMethod] - public void Test_6675() - { - } - [TestMethod] - public void Test_6676() - { - } - [TestMethod] - public void Test_6677() - { - } - [TestMethod] - public void Test_6678() - { - } - [TestMethod] - public void Test_6679() - { - } - [TestMethod] - public void Test_6680() - { - } - [TestMethod] - public void Test_6681() - { - } - [TestMethod] - public void Test_6682() - { - } - [TestMethod] - public void Test_6683() - { - } - [TestMethod] - public void Test_6684() - { - } - [TestMethod] - public void Test_6685() - { - } - [TestMethod] - public void Test_6686() - { - } - [TestMethod] - public void Test_6687() - { - } - [TestMethod] - public void Test_6688() - { - } - [TestMethod] - public void Test_6689() - { - } - [TestMethod] - public void Test_6690() - { - } - [TestMethod] - public void Test_6691() - { - } - [TestMethod] - public void Test_6692() - { - } - [TestMethod] - public void Test_6693() - { - } - [TestMethod] - public void Test_6694() - { - } - [TestMethod] - public void Test_6695() - { - } - [TestMethod] - public void Test_6696() - { - } - [TestMethod] - public void Test_6697() - { - } - [TestMethod] - public void Test_6698() - { - } - [TestMethod] - public void Test_6699() - { - } - [TestMethod] - public void Test_6700() - { - } - [TestMethod] - public void Test_6701() - { - } - [TestMethod] - public void Test_6702() - { - } - [TestMethod] - public void Test_6703() - { - } - [TestMethod] - public void Test_6704() - { - } - [TestMethod] - public void Test_6705() - { - } - [TestMethod] - public void Test_6706() - { - } - [TestMethod] - public void Test_6707() - { - } - [TestMethod] - public void Test_6708() - { - } - [TestMethod] - public void Test_6709() - { - } - [TestMethod] - public void Test_6710() - { - } - [TestMethod] - public void Test_6711() - { - } - [TestMethod] - public void Test_6712() - { - } - [TestMethod] - public void Test_6713() - { - } - [TestMethod] - public void Test_6714() - { - } - [TestMethod] - public void Test_6715() - { - } - [TestMethod] - public void Test_6716() - { - } - [TestMethod] - public void Test_6717() - { - } - [TestMethod] - public void Test_6718() - { - } - [TestMethod] - public void Test_6719() - { - } - [TestMethod] - public void Test_6720() - { - } - [TestMethod] - public void Test_6721() - { - } - [TestMethod] - public void Test_6722() - { - } - [TestMethod] - public void Test_6723() - { - } - [TestMethod] - public void Test_6724() - { - } - [TestMethod] - public void Test_6725() - { - } - [TestMethod] - public void Test_6726() - { - } - [TestMethod] - public void Test_6727() - { - } - [TestMethod] - public void Test_6728() - { - } - [TestMethod] - public void Test_6729() - { - } - [TestMethod] - public void Test_6730() - { - } - [TestMethod] - public void Test_6731() - { - } - [TestMethod] - public void Test_6732() - { - } - [TestMethod] - public void Test_6733() - { - } - [TestMethod] - public void Test_6734() - { - } - [TestMethod] - public void Test_6735() - { - } - [TestMethod] - public void Test_6736() - { - } - [TestMethod] - public void Test_6737() - { - } - [TestMethod] - public void Test_6738() - { - } - [TestMethod] - public void Test_6739() - { - } - [TestMethod] - public void Test_6740() - { - } - [TestMethod] - public void Test_6741() - { - } - [TestMethod] - public void Test_6742() - { - } - [TestMethod] - public void Test_6743() - { - } - [TestMethod] - public void Test_6744() - { - } - [TestMethod] - public void Test_6745() - { - } - [TestMethod] - public void Test_6746() - { - } - [TestMethod] - public void Test_6747() - { - } - [TestMethod] - public void Test_6748() - { - } - [TestMethod] - public void Test_6749() - { - } - [TestMethod] - public void Test_6750() - { - } - [TestMethod] - public void Test_6751() - { - } - [TestMethod] - public void Test_6752() - { - } - [TestMethod] - public void Test_6753() - { - } - [TestMethod] - public void Test_6754() - { - } - [TestMethod] - public void Test_6755() - { - } - [TestMethod] - public void Test_6756() - { - } - [TestMethod] - public void Test_6757() - { - } - [TestMethod] - public void Test_6758() - { - } - [TestMethod] - public void Test_6759() - { - } - [TestMethod] - public void Test_6760() - { - } - [TestMethod] - public void Test_6761() - { - } - [TestMethod] - public void Test_6762() - { - } - [TestMethod] - public void Test_6763() - { - } - [TestMethod] - public void Test_6764() - { - } - [TestMethod] - public void Test_6765() - { - } - [TestMethod] - public void Test_6766() - { - } - [TestMethod] - public void Test_6767() - { - } - [TestMethod] - public void Test_6768() - { - } - [TestMethod] - public void Test_6769() - { - } - [TestMethod] - public void Test_6770() - { - } - [TestMethod] - public void Test_6771() - { - } - [TestMethod] - public void Test_6772() - { - } - [TestMethod] - public void Test_6773() - { - } - [TestMethod] - public void Test_6774() - { - } - [TestMethod] - public void Test_6775() - { - } - [TestMethod] - public void Test_6776() - { - } - [TestMethod] - public void Test_6777() - { - } - [TestMethod] - public void Test_6778() - { - } - [TestMethod] - public void Test_6779() - { - } - [TestMethod] - public void Test_6780() - { - } - [TestMethod] - public void Test_6781() - { - } - [TestMethod] - public void Test_6782() - { - } - [TestMethod] - public void Test_6783() - { - } - [TestMethod] - public void Test_6784() - { - } - [TestMethod] - public void Test_6785() - { - } - [TestMethod] - public void Test_6786() - { - } - [TestMethod] - public void Test_6787() - { - } - [TestMethod] - public void Test_6788() - { - } - [TestMethod] - public void Test_6789() - { - } - [TestMethod] - public void Test_6790() - { - } - [TestMethod] - public void Test_6791() - { - } - [TestMethod] - public void Test_6792() - { - } - [TestMethod] - public void Test_6793() - { - } - [TestMethod] - public void Test_6794() - { - } - [TestMethod] - public void Test_6795() - { - } - [TestMethod] - public void Test_6796() - { - } - [TestMethod] - public void Test_6797() - { - } - [TestMethod] - public void Test_6798() - { - } - [TestMethod] - public void Test_6799() - { - } - [TestMethod] - public void Test_6800() - { - } - [TestMethod] - public void Test_6801() - { - } - [TestMethod] - public void Test_6802() - { - } - [TestMethod] - public void Test_6803() - { - } - [TestMethod] - public void Test_6804() - { - } - [TestMethod] - public void Test_6805() - { - } - [TestMethod] - public void Test_6806() - { - } - [TestMethod] - public void Test_6807() - { - } - [TestMethod] - public void Test_6808() - { - } - [TestMethod] - public void Test_6809() - { - } - [TestMethod] - public void Test_6810() - { - } - [TestMethod] - public void Test_6811() - { - } - [TestMethod] - public void Test_6812() - { - } - [TestMethod] - public void Test_6813() - { - } - [TestMethod] - public void Test_6814() - { - } - [TestMethod] - public void Test_6815() - { - } - [TestMethod] - public void Test_6816() - { - } - [TestMethod] - public void Test_6817() - { - } - [TestMethod] - public void Test_6818() - { - } - [TestMethod] - public void Test_6819() - { - } - [TestMethod] - public void Test_6820() - { - } - [TestMethod] - public void Test_6821() - { - } - [TestMethod] - public void Test_6822() - { - } - [TestMethod] - public void Test_6823() - { - } - [TestMethod] - public void Test_6824() - { - } - [TestMethod] - public void Test_6825() - { - } - [TestMethod] - public void Test_6826() - { - } - [TestMethod] - public void Test_6827() - { - } - [TestMethod] - public void Test_6828() - { - } - [TestMethod] - public void Test_6829() - { - } - [TestMethod] - public void Test_6830() - { - } - [TestMethod] - public void Test_6831() - { - } - [TestMethod] - public void Test_6832() - { - } - [TestMethod] - public void Test_6833() - { - } - [TestMethod] - public void Test_6834() - { - } - [TestMethod] - public void Test_6835() - { - } - [TestMethod] - public void Test_6836() - { - } - [TestMethod] - public void Test_6837() - { - } - [TestMethod] - public void Test_6838() - { - } - [TestMethod] - public void Test_6839() - { - } - [TestMethod] - public void Test_6840() - { - } - [TestMethod] - public void Test_6841() - { - } - [TestMethod] - public void Test_6842() - { - } - [TestMethod] - public void Test_6843() - { - } - [TestMethod] - public void Test_6844() - { - } - [TestMethod] - public void Test_6845() - { - } - [TestMethod] - public void Test_6846() - { - } - [TestMethod] - public void Test_6847() - { - } - [TestMethod] - public void Test_6848() - { - } - [TestMethod] - public void Test_6849() - { - } - [TestMethod] - public void Test_6850() - { - } - [TestMethod] - public void Test_6851() - { - } - [TestMethod] - public void Test_6852() - { - } - [TestMethod] - public void Test_6853() - { - } - [TestMethod] - public void Test_6854() - { - } - [TestMethod] - public void Test_6855() - { - } - [TestMethod] - public void Test_6856() - { - } - [TestMethod] - public void Test_6857() - { - } - [TestMethod] - public void Test_6858() - { - } - [TestMethod] - public void Test_6859() - { - } - [TestMethod] - public void Test_6860() - { - } - [TestMethod] - public void Test_6861() - { - } - [TestMethod] - public void Test_6862() - { - } - [TestMethod] - public void Test_6863() - { - } - [TestMethod] - public void Test_6864() - { - } - [TestMethod] - public void Test_6865() - { - } - [TestMethod] - public void Test_6866() - { - } - [TestMethod] - public void Test_6867() - { - } - [TestMethod] - public void Test_6868() - { - } - [TestMethod] - public void Test_6869() - { - } - [TestMethod] - public void Test_6870() - { - } - [TestMethod] - public void Test_6871() - { - } - [TestMethod] - public void Test_6872() - { - } - [TestMethod] - public void Test_6873() - { - } - [TestMethod] - public void Test_6874() - { - } - [TestMethod] - public void Test_6875() - { - } - [TestMethod] - public void Test_6876() - { - } - [TestMethod] - public void Test_6877() - { - } - [TestMethod] - public void Test_6878() - { - } - [TestMethod] - public void Test_6879() - { - } - [TestMethod] - public void Test_6880() - { - } - [TestMethod] - public void Test_6881() - { - } - [TestMethod] - public void Test_6882() - { - } - [TestMethod] - public void Test_6883() - { - } - [TestMethod] - public void Test_6884() - { - } - [TestMethod] - public void Test_6885() - { - } - [TestMethod] - public void Test_6886() - { - } - [TestMethod] - public void Test_6887() - { - } - [TestMethod] - public void Test_6888() - { - } - [TestMethod] - public void Test_6889() - { - } - [TestMethod] - public void Test_6890() - { - } - [TestMethod] - public void Test_6891() - { - } - [TestMethod] - public void Test_6892() - { - } - [TestMethod] - public void Test_6893() - { - } - [TestMethod] - public void Test_6894() - { - } - [TestMethod] - public void Test_6895() - { - } - [TestMethod] - public void Test_6896() - { - } - [TestMethod] - public void Test_6897() - { - } - [TestMethod] - public void Test_6898() - { - } - [TestMethod] - public void Test_6899() - { - } - [TestMethod] - public void Test_6900() - { - } - [TestMethod] - public void Test_6901() - { - } - [TestMethod] - public void Test_6902() - { - } - [TestMethod] - public void Test_6903() - { - } - [TestMethod] - public void Test_6904() - { - } - [TestMethod] - public void Test_6905() - { - } - [TestMethod] - public void Test_6906() - { - } - [TestMethod] - public void Test_6907() - { - } - [TestMethod] - public void Test_6908() - { - } - [TestMethod] - public void Test_6909() - { - } - [TestMethod] - public void Test_6910() - { - } - [TestMethod] - public void Test_6911() - { - } - [TestMethod] - public void Test_6912() - { - } - [TestMethod] - public void Test_6913() - { - } - [TestMethod] - public void Test_6914() - { - } - [TestMethod] - public void Test_6915() - { - } - [TestMethod] - public void Test_6916() - { - } - [TestMethod] - public void Test_6917() - { - } - [TestMethod] - public void Test_6918() - { - } - [TestMethod] - public void Test_6919() - { - } - [TestMethod] - public void Test_6920() - { - } - [TestMethod] - public void Test_6921() - { - } - [TestMethod] - public void Test_6922() - { - } - [TestMethod] - public void Test_6923() - { - } - [TestMethod] - public void Test_6924() - { - } - [TestMethod] - public void Test_6925() - { - } - [TestMethod] - public void Test_6926() - { - } - [TestMethod] - public void Test_6927() - { - } - [TestMethod] - public void Test_6928() - { - } - [TestMethod] - public void Test_6929() - { - } - [TestMethod] - public void Test_6930() - { - } - [TestMethod] - public void Test_6931() - { - } - [TestMethod] - public void Test_6932() - { - } - [TestMethod] - public void Test_6933() - { - } - [TestMethod] - public void Test_6934() - { - } - [TestMethod] - public void Test_6935() - { - } - [TestMethod] - public void Test_6936() - { - } - [TestMethod] - public void Test_6937() - { - } - [TestMethod] - public void Test_6938() - { - } - [TestMethod] - public void Test_6939() - { - } - [TestMethod] - public void Test_6940() - { - } - [TestMethod] - public void Test_6941() - { - } - [TestMethod] - public void Test_6942() - { - } - [TestMethod] - public void Test_6943() - { - } - [TestMethod] - public void Test_6944() - { - } - [TestMethod] - public void Test_6945() - { - } - [TestMethod] - public void Test_6946() - { - } - [TestMethod] - public void Test_6947() - { - } - [TestMethod] - public void Test_6948() - { - } - [TestMethod] - public void Test_6949() - { - } - [TestMethod] - public void Test_6950() - { - } - [TestMethod] - public void Test_6951() - { - } - [TestMethod] - public void Test_6952() - { - } - [TestMethod] - public void Test_6953() - { - } - [TestMethod] - public void Test_6954() - { - } - [TestMethod] - public void Test_6955() - { - } - [TestMethod] - public void Test_6956() - { - } - [TestMethod] - public void Test_6957() - { - } - [TestMethod] - public void Test_6958() - { - } - [TestMethod] - public void Test_6959() - { - } - [TestMethod] - public void Test_6960() - { - } - [TestMethod] - public void Test_6961() - { - } - [TestMethod] - public void Test_6962() - { - } - [TestMethod] - public void Test_6963() - { - } - [TestMethod] - public void Test_6964() - { - } - [TestMethod] - public void Test_6965() - { - } - [TestMethod] - public void Test_6966() - { - } - [TestMethod] - public void Test_6967() - { - } - [TestMethod] - public void Test_6968() - { - } - [TestMethod] - public void Test_6969() - { - } - [TestMethod] - public void Test_6970() - { - } - [TestMethod] - public void Test_6971() - { - } - [TestMethod] - public void Test_6972() - { - } - [TestMethod] - public void Test_6973() - { - } - [TestMethod] - public void Test_6974() - { - } - [TestMethod] - public void Test_6975() - { - } - [TestMethod] - public void Test_6976() - { - } - [TestMethod] - public void Test_6977() - { - } - [TestMethod] - public void Test_6978() - { - } - [TestMethod] - public void Test_6979() - { - } - [TestMethod] - public void Test_6980() - { - } - [TestMethod] - public void Test_6981() - { - } - [TestMethod] - public void Test_6982() - { - } - [TestMethod] - public void Test_6983() - { - } - [TestMethod] - public void Test_6984() - { - } - [TestMethod] - public void Test_6985() - { - } - [TestMethod] - public void Test_6986() - { - } - [TestMethod] - public void Test_6987() - { - } - [TestMethod] - public void Test_6988() - { - } - [TestMethod] - public void Test_6989() - { - } - [TestMethod] - public void Test_6990() - { - } - [TestMethod] - public void Test_6991() - { - } - [TestMethod] - public void Test_6992() - { - } - [TestMethod] - public void Test_6993() - { - } - [TestMethod] - public void Test_6994() - { - } - [TestMethod] - public void Test_6995() - { - } - [TestMethod] - public void Test_6996() - { - } - [TestMethod] - public void Test_6997() - { - } - [TestMethod] - public void Test_6998() - { - } - [TestMethod] - public void Test_6999() - { - } - [TestMethod] - public void Test_7000() - { - } - [TestMethod] - public void Test_7001() - { - } - [TestMethod] - public void Test_7002() - { - } - [TestMethod] - public void Test_7003() - { - } - [TestMethod] - public void Test_7004() - { - } - [TestMethod] - public void Test_7005() - { - } - [TestMethod] - public void Test_7006() - { - } - [TestMethod] - public void Test_7007() - { - } - [TestMethod] - public void Test_7008() - { - } - [TestMethod] - public void Test_7009() - { - } - [TestMethod] - public void Test_7010() - { - } - [TestMethod] - public void Test_7011() - { - } - [TestMethod] - public void Test_7012() - { - } - [TestMethod] - public void Test_7013() - { - } - [TestMethod] - public void Test_7014() - { - } - [TestMethod] - public void Test_7015() - { - } - [TestMethod] - public void Test_7016() - { - } - [TestMethod] - public void Test_7017() - { - } - [TestMethod] - public void Test_7018() - { - } - [TestMethod] - public void Test_7019() - { - } - [TestMethod] - public void Test_7020() - { - } - [TestMethod] - public void Test_7021() - { - } - [TestMethod] - public void Test_7022() - { - } - [TestMethod] - public void Test_7023() - { - } - [TestMethod] - public void Test_7024() - { - } - [TestMethod] - public void Test_7025() - { - } - [TestMethod] - public void Test_7026() - { - } - [TestMethod] - public void Test_7027() - { - } - [TestMethod] - public void Test_7028() - { - } - [TestMethod] - public void Test_7029() - { - } - [TestMethod] - public void Test_7030() - { - } - [TestMethod] - public void Test_7031() - { - } - [TestMethod] - public void Test_7032() - { - } - [TestMethod] - public void Test_7033() - { - } - [TestMethod] - public void Test_7034() - { - } - [TestMethod] - public void Test_7035() - { - } - [TestMethod] - public void Test_7036() - { - } - [TestMethod] - public void Test_7037() - { - } - [TestMethod] - public void Test_7038() - { - } - [TestMethod] - public void Test_7039() - { - } - [TestMethod] - public void Test_7040() - { - } - [TestMethod] - public void Test_7041() - { - } - [TestMethod] - public void Test_7042() - { - } - [TestMethod] - public void Test_7043() - { - } - [TestMethod] - public void Test_7044() - { - } - [TestMethod] - public void Test_7045() - { - } - [TestMethod] - public void Test_7046() - { - } - [TestMethod] - public void Test_7047() - { - } - [TestMethod] - public void Test_7048() - { - } - [TestMethod] - public void Test_7049() - { - } - [TestMethod] - public void Test_7050() - { - } - [TestMethod] - public void Test_7051() - { - } - [TestMethod] - public void Test_7052() - { - } - [TestMethod] - public void Test_7053() - { - } - [TestMethod] - public void Test_7054() - { - } - [TestMethod] - public void Test_7055() - { - } - [TestMethod] - public void Test_7056() - { - } - [TestMethod] - public void Test_7057() - { - } - [TestMethod] - public void Test_7058() - { - } - [TestMethod] - public void Test_7059() - { - } - [TestMethod] - public void Test_7060() - { - } - [TestMethod] - public void Test_7061() - { - } - [TestMethod] - public void Test_7062() - { - } - [TestMethod] - public void Test_7063() - { - } - [TestMethod] - public void Test_7064() - { - } - [TestMethod] - public void Test_7065() - { - } - [TestMethod] - public void Test_7066() - { - } - [TestMethod] - public void Test_7067() - { - } - [TestMethod] - public void Test_7068() - { - } - [TestMethod] - public void Test_7069() - { - } - [TestMethod] - public void Test_7070() - { - } - [TestMethod] - public void Test_7071() - { - } - [TestMethod] - public void Test_7072() - { - } - [TestMethod] - public void Test_7073() - { - } - [TestMethod] - public void Test_7074() - { - } - [TestMethod] - public void Test_7075() - { - } - [TestMethod] - public void Test_7076() - { - } - [TestMethod] - public void Test_7077() - { - } - [TestMethod] - public void Test_7078() - { - } - [TestMethod] - public void Test_7079() - { - } - [TestMethod] - public void Test_7080() - { - } - [TestMethod] - public void Test_7081() - { - } - [TestMethod] - public void Test_7082() - { - } - [TestMethod] - public void Test_7083() - { - } - [TestMethod] - public void Test_7084() - { - } - [TestMethod] - public void Test_7085() - { - } - [TestMethod] - public void Test_7086() - { - } - [TestMethod] - public void Test_7087() - { - } - [TestMethod] - public void Test_7088() - { - } - [TestMethod] - public void Test_7089() - { - } - [TestMethod] - public void Test_7090() - { - } - [TestMethod] - public void Test_7091() - { - } - [TestMethod] - public void Test_7092() - { - } - [TestMethod] - public void Test_7093() - { - } - [TestMethod] - public void Test_7094() - { - } - [TestMethod] - public void Test_7095() - { - } - [TestMethod] - public void Test_7096() - { - } - [TestMethod] - public void Test_7097() - { - } - [TestMethod] - public void Test_7098() - { - } - [TestMethod] - public void Test_7099() - { - } - [TestMethod] - public void Test_7100() - { - } - [TestMethod] - public void Test_7101() - { - } - [TestMethod] - public void Test_7102() - { - } - [TestMethod] - public void Test_7103() - { - } - [TestMethod] - public void Test_7104() - { - } - [TestMethod] - public void Test_7105() - { - } - [TestMethod] - public void Test_7106() - { - } - [TestMethod] - public void Test_7107() - { - } - [TestMethod] - public void Test_7108() - { - } - [TestMethod] - public void Test_7109() - { - } - [TestMethod] - public void Test_7110() - { - } - [TestMethod] - public void Test_7111() - { - } - [TestMethod] - public void Test_7112() - { - } - [TestMethod] - public void Test_7113() - { - } - [TestMethod] - public void Test_7114() - { - } - [TestMethod] - public void Test_7115() - { - } - [TestMethod] - public void Test_7116() - { - } - [TestMethod] - public void Test_7117() - { - } - [TestMethod] - public void Test_7118() - { - } - [TestMethod] - public void Test_7119() - { - } - [TestMethod] - public void Test_7120() - { - } - [TestMethod] - public void Test_7121() - { - } - [TestMethod] - public void Test_7122() - { - } - [TestMethod] - public void Test_7123() - { - } - [TestMethod] - public void Test_7124() - { - } - [TestMethod] - public void Test_7125() - { - } - [TestMethod] - public void Test_7126() - { - } - [TestMethod] - public void Test_7127() - { - } - [TestMethod] - public void Test_7128() - { - } - [TestMethod] - public void Test_7129() - { - } - [TestMethod] - public void Test_7130() - { - } - [TestMethod] - public void Test_7131() - { - } - [TestMethod] - public void Test_7132() - { - } - [TestMethod] - public void Test_7133() - { - } - [TestMethod] - public void Test_7134() - { - } - [TestMethod] - public void Test_7135() - { - } - [TestMethod] - public void Test_7136() - { - } - [TestMethod] - public void Test_7137() - { - } - [TestMethod] - public void Test_7138() - { - } - [TestMethod] - public void Test_7139() - { - } - [TestMethod] - public void Test_7140() - { - } - [TestMethod] - public void Test_7141() - { - } - [TestMethod] - public void Test_7142() - { - } - [TestMethod] - public void Test_7143() - { - } - [TestMethod] - public void Test_7144() - { - } - [TestMethod] - public void Test_7145() - { - } - [TestMethod] - public void Test_7146() - { - } - [TestMethod] - public void Test_7147() - { - } - [TestMethod] - public void Test_7148() - { - } - [TestMethod] - public void Test_7149() - { - } - [TestMethod] - public void Test_7150() - { - } - [TestMethod] - public void Test_7151() - { - } - [TestMethod] - public void Test_7152() - { - } - [TestMethod] - public void Test_7153() - { - } - [TestMethod] - public void Test_7154() - { - } - [TestMethod] - public void Test_7155() - { - } - [TestMethod] - public void Test_7156() - { - } - [TestMethod] - public void Test_7157() - { - } - [TestMethod] - public void Test_7158() - { - } - [TestMethod] - public void Test_7159() - { - } - [TestMethod] - public void Test_7160() - { - } - [TestMethod] - public void Test_7161() - { - } - [TestMethod] - public void Test_7162() - { - } - [TestMethod] - public void Test_7163() - { - } - [TestMethod] - public void Test_7164() - { - } - [TestMethod] - public void Test_7165() - { - } - [TestMethod] - public void Test_7166() - { - } - [TestMethod] - public void Test_7167() - { - } - [TestMethod] - public void Test_7168() - { - } - [TestMethod] - public void Test_7169() - { - } - [TestMethod] - public void Test_7170() - { - } - [TestMethod] - public void Test_7171() - { - } - [TestMethod] - public void Test_7172() - { - } - [TestMethod] - public void Test_7173() - { - } - [TestMethod] - public void Test_7174() - { - } - [TestMethod] - public void Test_7175() - { - } - [TestMethod] - public void Test_7176() - { - } - [TestMethod] - public void Test_7177() - { - } - [TestMethod] - public void Test_7178() - { - } - [TestMethod] - public void Test_7179() - { - } - [TestMethod] - public void Test_7180() - { - } - [TestMethod] - public void Test_7181() - { - } - [TestMethod] - public void Test_7182() - { - } - [TestMethod] - public void Test_7183() - { - } - [TestMethod] - public void Test_7184() - { - } - [TestMethod] - public void Test_7185() - { - } - [TestMethod] - public void Test_7186() - { - } - [TestMethod] - public void Test_7187() - { - } - [TestMethod] - public void Test_7188() - { - } - [TestMethod] - public void Test_7189() - { - } - [TestMethod] - public void Test_7190() - { - } - [TestMethod] - public void Test_7191() - { - } - [TestMethod] - public void Test_7192() - { - } - [TestMethod] - public void Test_7193() - { - } - [TestMethod] - public void Test_7194() - { - } - [TestMethod] - public void Test_7195() - { - } - [TestMethod] - public void Test_7196() - { - } - [TestMethod] - public void Test_7197() - { - } - [TestMethod] - public void Test_7198() - { - } - [TestMethod] - public void Test_7199() - { - } - [TestMethod] - public void Test_7200() - { - } - [TestMethod] - public void Test_7201() - { - } - [TestMethod] - public void Test_7202() - { - } - [TestMethod] - public void Test_7203() - { - } - [TestMethod] - public void Test_7204() - { - } - [TestMethod] - public void Test_7205() - { - } - [TestMethod] - public void Test_7206() - { - } - [TestMethod] - public void Test_7207() - { - } - [TestMethod] - public void Test_7208() - { - } - [TestMethod] - public void Test_7209() - { - } - [TestMethod] - public void Test_7210() - { - } - [TestMethod] - public void Test_7211() - { - } - [TestMethod] - public void Test_7212() - { - } - [TestMethod] - public void Test_7213() - { - } - [TestMethod] - public void Test_7214() - { - } - [TestMethod] - public void Test_7215() - { - } - [TestMethod] - public void Test_7216() - { - } - [TestMethod] - public void Test_7217() - { - } - [TestMethod] - public void Test_7218() - { - } - [TestMethod] - public void Test_7219() - { - } - [TestMethod] - public void Test_7220() - { - } - [TestMethod] - public void Test_7221() - { - } - [TestMethod] - public void Test_7222() - { - } - [TestMethod] - public void Test_7223() - { - } - [TestMethod] - public void Test_7224() - { - } - [TestMethod] - public void Test_7225() - { - } - [TestMethod] - public void Test_7226() - { - } - [TestMethod] - public void Test_7227() - { - } - [TestMethod] - public void Test_7228() - { - } - [TestMethod] - public void Test_7229() - { - } - [TestMethod] - public void Test_7230() - { - } - [TestMethod] - public void Test_7231() - { - } - [TestMethod] - public void Test_7232() - { - } - [TestMethod] - public void Test_7233() - { - } - [TestMethod] - public void Test_7234() - { - } - [TestMethod] - public void Test_7235() - { - } - [TestMethod] - public void Test_7236() - { - } - [TestMethod] - public void Test_7237() - { - } - [TestMethod] - public void Test_7238() - { - } - [TestMethod] - public void Test_7239() - { - } - [TestMethod] - public void Test_7240() - { - } - [TestMethod] - public void Test_7241() - { - } - [TestMethod] - public void Test_7242() - { - } - [TestMethod] - public void Test_7243() - { - } - [TestMethod] - public void Test_7244() - { - } - [TestMethod] - public void Test_7245() - { - } - [TestMethod] - public void Test_7246() - { - } - [TestMethod] - public void Test_7247() - { - } - [TestMethod] - public void Test_7248() - { - } - [TestMethod] - public void Test_7249() - { - } - [TestMethod] - public void Test_7250() - { - } - [TestMethod] - public void Test_7251() - { - } - [TestMethod] - public void Test_7252() - { - } - [TestMethod] - public void Test_7253() - { - } - [TestMethod] - public void Test_7254() - { - } - [TestMethod] - public void Test_7255() - { - } - [TestMethod] - public void Test_7256() - { - } - [TestMethod] - public void Test_7257() - { - } - [TestMethod] - public void Test_7258() - { - } - [TestMethod] - public void Test_7259() - { - } - [TestMethod] - public void Test_7260() - { - } - [TestMethod] - public void Test_7261() - { - } - [TestMethod] - public void Test_7262() - { - } - [TestMethod] - public void Test_7263() - { - } - [TestMethod] - public void Test_7264() - { - } - [TestMethod] - public void Test_7265() - { - } - [TestMethod] - public void Test_7266() - { - } - [TestMethod] - public void Test_7267() - { - } - [TestMethod] - public void Test_7268() - { - } - [TestMethod] - public void Test_7269() - { - } - [TestMethod] - public void Test_7270() - { - } - [TestMethod] - public void Test_7271() - { - } - [TestMethod] - public void Test_7272() - { - } - [TestMethod] - public void Test_7273() - { - } - [TestMethod] - public void Test_7274() - { - } - [TestMethod] - public void Test_7275() - { - } - [TestMethod] - public void Test_7276() - { - } - [TestMethod] - public void Test_7277() - { - } - [TestMethod] - public void Test_7278() - { - } - [TestMethod] - public void Test_7279() - { - } - [TestMethod] - public void Test_7280() - { - } - [TestMethod] - public void Test_7281() - { - } - [TestMethod] - public void Test_7282() - { - } - [TestMethod] - public void Test_7283() - { - } - [TestMethod] - public void Test_7284() - { - } - [TestMethod] - public void Test_7285() - { - } - [TestMethod] - public void Test_7286() - { - } - [TestMethod] - public void Test_7287() - { - } - [TestMethod] - public void Test_7288() - { - } - [TestMethod] - public void Test_7289() - { - } - [TestMethod] - public void Test_7290() - { - } - [TestMethod] - public void Test_7291() - { - } - [TestMethod] - public void Test_7292() - { - } - [TestMethod] - public void Test_7293() - { - } - [TestMethod] - public void Test_7294() - { - } - [TestMethod] - public void Test_7295() - { - } - [TestMethod] - public void Test_7296() - { - } - [TestMethod] - public void Test_7297() - { - } - [TestMethod] - public void Test_7298() - { - } - [TestMethod] - public void Test_7299() - { - } - [TestMethod] - public void Test_7300() - { - } - [TestMethod] - public void Test_7301() - { - } - [TestMethod] - public void Test_7302() - { - } - [TestMethod] - public void Test_7303() - { - } - [TestMethod] - public void Test_7304() - { - } - [TestMethod] - public void Test_7305() - { - } - [TestMethod] - public void Test_7306() - { - } - [TestMethod] - public void Test_7307() - { - } - [TestMethod] - public void Test_7308() - { - } - [TestMethod] - public void Test_7309() - { - } - [TestMethod] - public void Test_7310() - { - } - [TestMethod] - public void Test_7311() - { - } - [TestMethod] - public void Test_7312() - { - } - [TestMethod] - public void Test_7313() - { - } - [TestMethod] - public void Test_7314() - { - } - [TestMethod] - public void Test_7315() - { - } - [TestMethod] - public void Test_7316() - { - } - [TestMethod] - public void Test_7317() - { - } - [TestMethod] - public void Test_7318() - { - } - [TestMethod] - public void Test_7319() - { - } - [TestMethod] - public void Test_7320() - { - } - [TestMethod] - public void Test_7321() - { - } - [TestMethod] - public void Test_7322() - { - } - [TestMethod] - public void Test_7323() - { - } - [TestMethod] - public void Test_7324() - { - } - [TestMethod] - public void Test_7325() - { - } - [TestMethod] - public void Test_7326() - { - } - [TestMethod] - public void Test_7327() - { - } - [TestMethod] - public void Test_7328() - { - } - [TestMethod] - public void Test_7329() - { - } - [TestMethod] - public void Test_7330() - { - } - [TestMethod] - public void Test_7331() - { - } - [TestMethod] - public void Test_7332() - { - } - [TestMethod] - public void Test_7333() - { - } - [TestMethod] - public void Test_7334() - { - } - [TestMethod] - public void Test_7335() - { - } - [TestMethod] - public void Test_7336() - { - } - [TestMethod] - public void Test_7337() - { - } - [TestMethod] - public void Test_7338() - { - } - [TestMethod] - public void Test_7339() - { - } - [TestMethod] - public void Test_7340() - { - } - [TestMethod] - public void Test_7341() - { - } - [TestMethod] - public void Test_7342() - { - } - [TestMethod] - public void Test_7343() - { - } - [TestMethod] - public void Test_7344() - { - } - [TestMethod] - public void Test_7345() - { - } - [TestMethod] - public void Test_7346() - { - } - [TestMethod] - public void Test_7347() - { - } - [TestMethod] - public void Test_7348() - { - } - [TestMethod] - public void Test_7349() - { - } - [TestMethod] - public void Test_7350() - { - } - [TestMethod] - public void Test_7351() - { - } - [TestMethod] - public void Test_7352() - { - } - [TestMethod] - public void Test_7353() - { - } - [TestMethod] - public void Test_7354() - { - } - [TestMethod] - public void Test_7355() - { - } - [TestMethod] - public void Test_7356() - { - } - [TestMethod] - public void Test_7357() - { - } - [TestMethod] - public void Test_7358() - { - } - [TestMethod] - public void Test_7359() - { - } - [TestMethod] - public void Test_7360() - { - } - [TestMethod] - public void Test_7361() - { - } - [TestMethod] - public void Test_7362() - { - } - [TestMethod] - public void Test_7363() - { - } - [TestMethod] - public void Test_7364() - { - } - [TestMethod] - public void Test_7365() - { - } - [TestMethod] - public void Test_7366() - { - } - [TestMethod] - public void Test_7367() - { - } - [TestMethod] - public void Test_7368() - { - } - [TestMethod] - public void Test_7369() - { - } - [TestMethod] - public void Test_7370() - { - } - [TestMethod] - public void Test_7371() - { - } - [TestMethod] - public void Test_7372() - { - } - [TestMethod] - public void Test_7373() - { - } - [TestMethod] - public void Test_7374() - { - } - [TestMethod] - public void Test_7375() - { - } - [TestMethod] - public void Test_7376() - { - } - [TestMethod] - public void Test_7377() - { - } - [TestMethod] - public void Test_7378() - { - } - [TestMethod] - public void Test_7379() - { - } - [TestMethod] - public void Test_7380() - { - } - [TestMethod] - public void Test_7381() - { - } - [TestMethod] - public void Test_7382() - { - } - [TestMethod] - public void Test_7383() - { - } - [TestMethod] - public void Test_7384() - { - } - [TestMethod] - public void Test_7385() - { - } - [TestMethod] - public void Test_7386() - { - } - [TestMethod] - public void Test_7387() - { - } - [TestMethod] - public void Test_7388() - { - } - [TestMethod] - public void Test_7389() - { - } - [TestMethod] - public void Test_7390() - { - } - [TestMethod] - public void Test_7391() - { - } - [TestMethod] - public void Test_7392() - { - } - [TestMethod] - public void Test_7393() - { - } - [TestMethod] - public void Test_7394() - { - } - [TestMethod] - public void Test_7395() - { - } - [TestMethod] - public void Test_7396() - { - } - [TestMethod] - public void Test_7397() - { - } - [TestMethod] - public void Test_7398() - { - } - [TestMethod] - public void Test_7399() - { - } - [TestMethod] - public void Test_7400() - { - } - [TestMethod] - public void Test_7401() - { - } - [TestMethod] - public void Test_7402() - { - } - [TestMethod] - public void Test_7403() - { - } - [TestMethod] - public void Test_7404() - { - } - [TestMethod] - public void Test_7405() - { - } - [TestMethod] - public void Test_7406() - { - } - [TestMethod] - public void Test_7407() - { - } - [TestMethod] - public void Test_7408() - { - } - [TestMethod] - public void Test_7409() - { - } - [TestMethod] - public void Test_7410() - { - } - [TestMethod] - public void Test_7411() - { - } - [TestMethod] - public void Test_7412() - { - } - [TestMethod] - public void Test_7413() - { - } - [TestMethod] - public void Test_7414() - { - } - [TestMethod] - public void Test_7415() - { - } - [TestMethod] - public void Test_7416() - { - } - [TestMethod] - public void Test_7417() - { - } - [TestMethod] - public void Test_7418() - { - } - [TestMethod] - public void Test_7419() - { - } - [TestMethod] - public void Test_7420() - { - } - [TestMethod] - public void Test_7421() - { - } - [TestMethod] - public void Test_7422() - { - } - [TestMethod] - public void Test_7423() - { - } - [TestMethod] - public void Test_7424() - { - } - [TestMethod] - public void Test_7425() - { - } - [TestMethod] - public void Test_7426() - { - } - [TestMethod] - public void Test_7427() - { - } - [TestMethod] - public void Test_7428() - { - } - [TestMethod] - public void Test_7429() - { - } - [TestMethod] - public void Test_7430() - { - } - [TestMethod] - public void Test_7431() - { - } - [TestMethod] - public void Test_7432() - { - } - [TestMethod] - public void Test_7433() - { - } - [TestMethod] - public void Test_7434() - { - } - [TestMethod] - public void Test_7435() - { - } - [TestMethod] - public void Test_7436() - { - } - [TestMethod] - public void Test_7437() - { - } - [TestMethod] - public void Test_7438() - { - } - [TestMethod] - public void Test_7439() - { - } - [TestMethod] - public void Test_7440() - { - } - [TestMethod] - public void Test_7441() - { - } - [TestMethod] - public void Test_7442() - { - } - [TestMethod] - public void Test_7443() - { - } - [TestMethod] - public void Test_7444() - { - } - [TestMethod] - public void Test_7445() - { - } - [TestMethod] - public void Test_7446() - { - } - [TestMethod] - public void Test_7447() - { - } - [TestMethod] - public void Test_7448() - { - } - [TestMethod] - public void Test_7449() - { - } - [TestMethod] - public void Test_7450() - { - } - [TestMethod] - public void Test_7451() - { - } - [TestMethod] - public void Test_7452() - { - } - [TestMethod] - public void Test_7453() - { - } - [TestMethod] - public void Test_7454() - { - } - [TestMethod] - public void Test_7455() - { - } - [TestMethod] - public void Test_7456() - { - } - [TestMethod] - public void Test_7457() - { - } - [TestMethod] - public void Test_7458() - { - } - [TestMethod] - public void Test_7459() - { - } - [TestMethod] - public void Test_7460() - { - } - [TestMethod] - public void Test_7461() - { - } - [TestMethod] - public void Test_7462() - { - } - [TestMethod] - public void Test_7463() - { - } - [TestMethod] - public void Test_7464() - { - } - [TestMethod] - public void Test_7465() - { - } - [TestMethod] - public void Test_7466() - { - } - [TestMethod] - public void Test_7467() - { - } - [TestMethod] - public void Test_7468() - { - } - [TestMethod] - public void Test_7469() - { - } - [TestMethod] - public void Test_7470() - { - } - [TestMethod] - public void Test_7471() - { - } - [TestMethod] - public void Test_7472() - { - } - [TestMethod] - public void Test_7473() - { - } - [TestMethod] - public void Test_7474() - { - } - [TestMethod] - public void Test_7475() - { - } - [TestMethod] - public void Test_7476() - { - } - [TestMethod] - public void Test_7477() - { - } - [TestMethod] - public void Test_7478() - { - } - [TestMethod] - public void Test_7479() - { - } - [TestMethod] - public void Test_7480() - { - } - [TestMethod] - public void Test_7481() - { - } - [TestMethod] - public void Test_7482() - { - } - [TestMethod] - public void Test_7483() - { - } - [TestMethod] - public void Test_7484() - { - } - [TestMethod] - public void Test_7485() - { - } - [TestMethod] - public void Test_7486() - { - } - [TestMethod] - public void Test_7487() - { - } - [TestMethod] - public void Test_7488() - { - } - [TestMethod] - public void Test_7489() - { - } - [TestMethod] - public void Test_7490() - { - } - [TestMethod] - public void Test_7491() - { - } - [TestMethod] - public void Test_7492() - { - } - [TestMethod] - public void Test_7493() - { - } - [TestMethod] - public void Test_7494() - { - } - [TestMethod] - public void Test_7495() - { - } - [TestMethod] - public void Test_7496() - { - } - [TestMethod] - public void Test_7497() - { - } - [TestMethod] - public void Test_7498() - { - } - [TestMethod] - public void Test_7499() - { - } - [TestMethod] - public void Test_7500() - { - } - [TestMethod] - public void Test_7501() - { - } - [TestMethod] - public void Test_7502() - { - } - [TestMethod] - public void Test_7503() - { - } - [TestMethod] - public void Test_7504() - { - } - [TestMethod] - public void Test_7505() - { - } - [TestMethod] - public void Test_7506() - { - } - [TestMethod] - public void Test_7507() - { - } - [TestMethod] - public void Test_7508() - { - } - [TestMethod] - public void Test_7509() - { - } - [TestMethod] - public void Test_7510() - { - } - [TestMethod] - public void Test_7511() - { - } - [TestMethod] - public void Test_7512() - { - } - [TestMethod] - public void Test_7513() - { - } - [TestMethod] - public void Test_7514() - { - } - [TestMethod] - public void Test_7515() - { - } - [TestMethod] - public void Test_7516() - { - } - [TestMethod] - public void Test_7517() - { - } - [TestMethod] - public void Test_7518() - { - } - [TestMethod] - public void Test_7519() - { - } - [TestMethod] - public void Test_7520() - { - } - [TestMethod] - public void Test_7521() - { - } - [TestMethod] - public void Test_7522() - { - } - [TestMethod] - public void Test_7523() - { - } - [TestMethod] - public void Test_7524() - { - } - [TestMethod] - public void Test_7525() - { - } - [TestMethod] - public void Test_7526() - { - } - [TestMethod] - public void Test_7527() - { - } - [TestMethod] - public void Test_7528() - { - } - [TestMethod] - public void Test_7529() - { - } - [TestMethod] - public void Test_7530() - { - } - [TestMethod] - public void Test_7531() - { - } - [TestMethod] - public void Test_7532() - { - } - [TestMethod] - public void Test_7533() - { - } - [TestMethod] - public void Test_7534() - { - } - [TestMethod] - public void Test_7535() - { - } - [TestMethod] - public void Test_7536() - { - } - [TestMethod] - public void Test_7537() - { - } - [TestMethod] - public void Test_7538() - { - } - [TestMethod] - public void Test_7539() - { - } - [TestMethod] - public void Test_7540() - { - } - [TestMethod] - public void Test_7541() - { - } - [TestMethod] - public void Test_7542() - { - } - [TestMethod] - public void Test_7543() - { - } - [TestMethod] - public void Test_7544() - { - } - [TestMethod] - public void Test_7545() - { - } - [TestMethod] - public void Test_7546() - { - } - [TestMethod] - public void Test_7547() - { - } - [TestMethod] - public void Test_7548() - { - } - [TestMethod] - public void Test_7549() - { - } - [TestMethod] - public void Test_7550() - { - } - [TestMethod] - public void Test_7551() - { - } - [TestMethod] - public void Test_7552() - { - } - [TestMethod] - public void Test_7553() - { - } - [TestMethod] - public void Test_7554() - { - } - [TestMethod] - public void Test_7555() - { - } - [TestMethod] - public void Test_7556() - { - } - [TestMethod] - public void Test_7557() - { - } - [TestMethod] - public void Test_7558() - { - } - [TestMethod] - public void Test_7559() - { - } - [TestMethod] - public void Test_7560() - { - } - [TestMethod] - public void Test_7561() - { - } - [TestMethod] - public void Test_7562() - { - } - [TestMethod] - public void Test_7563() - { - } - [TestMethod] - public void Test_7564() - { - } - [TestMethod] - public void Test_7565() - { - } - [TestMethod] - public void Test_7566() - { - } - [TestMethod] - public void Test_7567() - { - } - [TestMethod] - public void Test_7568() - { - } - [TestMethod] - public void Test_7569() - { - } - [TestMethod] - public void Test_7570() - { - } - [TestMethod] - public void Test_7571() - { - } - [TestMethod] - public void Test_7572() - { - } - [TestMethod] - public void Test_7573() - { - } - [TestMethod] - public void Test_7574() - { - } - [TestMethod] - public void Test_7575() - { - } - [TestMethod] - public void Test_7576() - { - } - [TestMethod] - public void Test_7577() - { - } - [TestMethod] - public void Test_7578() - { - } - [TestMethod] - public void Test_7579() - { - } - [TestMethod] - public void Test_7580() - { - } - [TestMethod] - public void Test_7581() - { - } - [TestMethod] - public void Test_7582() - { - } - [TestMethod] - public void Test_7583() - { - } - [TestMethod] - public void Test_7584() - { - } - [TestMethod] - public void Test_7585() - { - } - [TestMethod] - public void Test_7586() - { - } - [TestMethod] - public void Test_7587() - { - } - [TestMethod] - public void Test_7588() - { - } - [TestMethod] - public void Test_7589() - { - } - [TestMethod] - public void Test_7590() - { - } - [TestMethod] - public void Test_7591() - { - } - [TestMethod] - public void Test_7592() - { - } - [TestMethod] - public void Test_7593() - { - } - [TestMethod] - public void Test_7594() - { - } - [TestMethod] - public void Test_7595() - { - } - [TestMethod] - public void Test_7596() - { - } - [TestMethod] - public void Test_7597() - { - } - [TestMethod] - public void Test_7598() - { - } - [TestMethod] - public void Test_7599() - { - } - [TestMethod] - public void Test_7600() - { - } - [TestMethod] - public void Test_7601() - { - } - [TestMethod] - public void Test_7602() - { - } - [TestMethod] - public void Test_7603() - { - } - [TestMethod] - public void Test_7604() - { - } - [TestMethod] - public void Test_7605() - { - } - [TestMethod] - public void Test_7606() - { - } - [TestMethod] - public void Test_7607() - { - } - [TestMethod] - public void Test_7608() - { - } - [TestMethod] - public void Test_7609() - { - } - [TestMethod] - public void Test_7610() - { - } - [TestMethod] - public void Test_7611() - { - } - [TestMethod] - public void Test_7612() - { - } - [TestMethod] - public void Test_7613() - { - } - [TestMethod] - public void Test_7614() - { - } - [TestMethod] - public void Test_7615() - { - } - [TestMethod] - public void Test_7616() - { - } - [TestMethod] - public void Test_7617() - { - } - [TestMethod] - public void Test_7618() - { - } - [TestMethod] - public void Test_7619() - { - } - [TestMethod] - public void Test_7620() - { - } - [TestMethod] - public void Test_7621() - { - } - [TestMethod] - public void Test_7622() - { - } - [TestMethod] - public void Test_7623() - { - } - [TestMethod] - public void Test_7624() - { - } - [TestMethod] - public void Test_7625() - { - } - [TestMethod] - public void Test_7626() - { - } - [TestMethod] - public void Test_7627() - { - } - [TestMethod] - public void Test_7628() - { - } - [TestMethod] - public void Test_7629() - { - } - [TestMethod] - public void Test_7630() - { - } - [TestMethod] - public void Test_7631() - { - } - [TestMethod] - public void Test_7632() - { - } - [TestMethod] - public void Test_7633() - { - } - [TestMethod] - public void Test_7634() - { - } - [TestMethod] - public void Test_7635() - { - } - [TestMethod] - public void Test_7636() - { - } - [TestMethod] - public void Test_7637() - { - } - [TestMethod] - public void Test_7638() - { - } - [TestMethod] - public void Test_7639() - { - } - [TestMethod] - public void Test_7640() - { - } - [TestMethod] - public void Test_7641() - { - } - [TestMethod] - public void Test_7642() - { - } - [TestMethod] - public void Test_7643() - { - } - [TestMethod] - public void Test_7644() - { - } - [TestMethod] - public void Test_7645() - { - } - [TestMethod] - public void Test_7646() - { - } - [TestMethod] - public void Test_7647() - { - } - [TestMethod] - public void Test_7648() - { - } - [TestMethod] - public void Test_7649() - { - } - [TestMethod] - public void Test_7650() - { - } - [TestMethod] - public void Test_7651() - { - } - [TestMethod] - public void Test_7652() - { - } - [TestMethod] - public void Test_7653() - { - } - [TestMethod] - public void Test_7654() - { - } - [TestMethod] - public void Test_7655() - { - } - [TestMethod] - public void Test_7656() - { - } - [TestMethod] - public void Test_7657() - { - } - [TestMethod] - public void Test_7658() - { - } - [TestMethod] - public void Test_7659() - { - } - [TestMethod] - public void Test_7660() - { - } - [TestMethod] - public void Test_7661() - { - } - [TestMethod] - public void Test_7662() - { - } - [TestMethod] - public void Test_7663() - { - } - [TestMethod] - public void Test_7664() - { - } - [TestMethod] - public void Test_7665() - { - } - [TestMethod] - public void Test_7666() - { - } - [TestMethod] - public void Test_7667() - { - } - [TestMethod] - public void Test_7668() - { - } - [TestMethod] - public void Test_7669() - { - } - [TestMethod] - public void Test_7670() - { - } - [TestMethod] - public void Test_7671() - { - } - [TestMethod] - public void Test_7672() - { - } - [TestMethod] - public void Test_7673() - { - } - [TestMethod] - public void Test_7674() - { - } - [TestMethod] - public void Test_7675() - { - } - [TestMethod] - public void Test_7676() - { - } - [TestMethod] - public void Test_7677() - { - } - [TestMethod] - public void Test_7678() - { - } - [TestMethod] - public void Test_7679() - { - } - [TestMethod] - public void Test_7680() - { - } - [TestMethod] - public void Test_7681() - { - } - [TestMethod] - public void Test_7682() - { - } - [TestMethod] - public void Test_7683() - { - } - [TestMethod] - public void Test_7684() - { - } - [TestMethod] - public void Test_7685() - { - } - [TestMethod] - public void Test_7686() - { - } - [TestMethod] - public void Test_7687() - { - } - [TestMethod] - public void Test_7688() - { - } - [TestMethod] - public void Test_7689() - { - } - [TestMethod] - public void Test_7690() - { - } - [TestMethod] - public void Test_7691() - { - } - [TestMethod] - public void Test_7692() - { - } - [TestMethod] - public void Test_7693() - { - } - [TestMethod] - public void Test_7694() - { - } - [TestMethod] - public void Test_7695() - { - } - [TestMethod] - public void Test_7696() - { - } - [TestMethod] - public void Test_7697() - { - } - [TestMethod] - public void Test_7698() - { - } - [TestMethod] - public void Test_7699() - { - } - [TestMethod] - public void Test_7700() - { - } - [TestMethod] - public void Test_7701() - { - } - [TestMethod] - public void Test_7702() - { - } - [TestMethod] - public void Test_7703() - { - } - [TestMethod] - public void Test_7704() - { - } - [TestMethod] - public void Test_7705() - { - } - [TestMethod] - public void Test_7706() - { - } - [TestMethod] - public void Test_7707() - { - } - [TestMethod] - public void Test_7708() - { - } - [TestMethod] - public void Test_7709() - { - } - [TestMethod] - public void Test_7710() - { - } - [TestMethod] - public void Test_7711() - { - } - [TestMethod] - public void Test_7712() - { - } - [TestMethod] - public void Test_7713() - { - } - [TestMethod] - public void Test_7714() - { - } - [TestMethod] - public void Test_7715() - { - } - [TestMethod] - public void Test_7716() - { - } - [TestMethod] - public void Test_7717() - { - } - [TestMethod] - public void Test_7718() - { - } - [TestMethod] - public void Test_7719() - { - } - [TestMethod] - public void Test_7720() - { - } - [TestMethod] - public void Test_7721() - { - } - [TestMethod] - public void Test_7722() - { - } - [TestMethod] - public void Test_7723() - { - } - [TestMethod] - public void Test_7724() - { - } - [TestMethod] - public void Test_7725() - { - } - [TestMethod] - public void Test_7726() - { - } - [TestMethod] - public void Test_7727() - { - } - [TestMethod] - public void Test_7728() - { - } - [TestMethod] - public void Test_7729() - { - } - [TestMethod] - public void Test_7730() - { - } - [TestMethod] - public void Test_7731() - { - } - [TestMethod] - public void Test_7732() - { - } - [TestMethod] - public void Test_7733() - { - } - [TestMethod] - public void Test_7734() - { - } - [TestMethod] - public void Test_7735() - { - } - [TestMethod] - public void Test_7736() - { - } - [TestMethod] - public void Test_7737() - { - } - [TestMethod] - public void Test_7738() - { - } - [TestMethod] - public void Test_7739() - { - } - [TestMethod] - public void Test_7740() - { - } - [TestMethod] - public void Test_7741() - { - } - [TestMethod] - public void Test_7742() - { - } - [TestMethod] - public void Test_7743() - { - } - [TestMethod] - public void Test_7744() - { - } - [TestMethod] - public void Test_7745() - { - } - [TestMethod] - public void Test_7746() - { - } - [TestMethod] - public void Test_7747() - { - } - [TestMethod] - public void Test_7748() - { - } - [TestMethod] - public void Test_7749() - { - } - [TestMethod] - public void Test_7750() - { - } - [TestMethod] - public void Test_7751() - { - } - [TestMethod] - public void Test_7752() - { - } - [TestMethod] - public void Test_7753() - { - } - [TestMethod] - public void Test_7754() - { - } - [TestMethod] - public void Test_7755() - { - } - [TestMethod] - public void Test_7756() - { - } - [TestMethod] - public void Test_7757() - { - } - [TestMethod] - public void Test_7758() - { - } - [TestMethod] - public void Test_7759() - { - } - [TestMethod] - public void Test_7760() - { - } - [TestMethod] - public void Test_7761() - { - } - [TestMethod] - public void Test_7762() - { - } - [TestMethod] - public void Test_7763() - { - } - [TestMethod] - public void Test_7764() - { - } - [TestMethod] - public void Test_7765() - { - } - [TestMethod] - public void Test_7766() - { - } - [TestMethod] - public void Test_7767() - { - } - [TestMethod] - public void Test_7768() - { - } - [TestMethod] - public void Test_7769() - { - } - [TestMethod] - public void Test_7770() - { - } - [TestMethod] - public void Test_7771() - { - } - [TestMethod] - public void Test_7772() - { - } - [TestMethod] - public void Test_7773() - { - } - [TestMethod] - public void Test_7774() - { - } - [TestMethod] - public void Test_7775() - { - } - [TestMethod] - public void Test_7776() - { - } - [TestMethod] - public void Test_7777() - { - } - [TestMethod] - public void Test_7778() - { - } - [TestMethod] - public void Test_7779() - { - } - [TestMethod] - public void Test_7780() - { - } - [TestMethod] - public void Test_7781() - { - } - [TestMethod] - public void Test_7782() - { - } - [TestMethod] - public void Test_7783() - { - } - [TestMethod] - public void Test_7784() - { - } - [TestMethod] - public void Test_7785() - { - } - [TestMethod] - public void Test_7786() - { - } - [TestMethod] - public void Test_7787() - { - } - [TestMethod] - public void Test_7788() - { - } - [TestMethod] - public void Test_7789() - { - } - [TestMethod] - public void Test_7790() - { - } - [TestMethod] - public void Test_7791() - { - } - [TestMethod] - public void Test_7792() - { - } - [TestMethod] - public void Test_7793() - { - } - [TestMethod] - public void Test_7794() - { - } - [TestMethod] - public void Test_7795() - { - } - [TestMethod] - public void Test_7796() - { - } - [TestMethod] - public void Test_7797() - { - } - [TestMethod] - public void Test_7798() - { - } - [TestMethod] - public void Test_7799() - { - } - [TestMethod] - public void Test_7800() - { - } - [TestMethod] - public void Test_7801() - { - } - [TestMethod] - public void Test_7802() - { - } - [TestMethod] - public void Test_7803() - { - } - [TestMethod] - public void Test_7804() - { - } - [TestMethod] - public void Test_7805() - { - } - [TestMethod] - public void Test_7806() - { - } - [TestMethod] - public void Test_7807() - { - } - [TestMethod] - public void Test_7808() - { - } - [TestMethod] - public void Test_7809() - { - } - [TestMethod] - public void Test_7810() - { - } - [TestMethod] - public void Test_7811() - { - } - [TestMethod] - public void Test_7812() - { - } - [TestMethod] - public void Test_7813() - { - } - [TestMethod] - public void Test_7814() - { - } - [TestMethod] - public void Test_7815() - { - } - [TestMethod] - public void Test_7816() - { - } - [TestMethod] - public void Test_7817() - { - } - [TestMethod] - public void Test_7818() - { - } - [TestMethod] - public void Test_7819() - { - } - [TestMethod] - public void Test_7820() - { - } - [TestMethod] - public void Test_7821() - { - } - [TestMethod] - public void Test_7822() - { - } - [TestMethod] - public void Test_7823() - { - } - [TestMethod] - public void Test_7824() - { - } - [TestMethod] - public void Test_7825() - { - } - [TestMethod] - public void Test_7826() - { - } - [TestMethod] - public void Test_7827() - { - } - [TestMethod] - public void Test_7828() - { - } - [TestMethod] - public void Test_7829() - { - } - [TestMethod] - public void Test_7830() - { - } - [TestMethod] - public void Test_7831() - { - } - [TestMethod] - public void Test_7832() - { - } - [TestMethod] - public void Test_7833() - { - } - [TestMethod] - public void Test_7834() - { - } - [TestMethod] - public void Test_7835() - { - } - [TestMethod] - public void Test_7836() - { - } - [TestMethod] - public void Test_7837() - { - } - [TestMethod] - public void Test_7838() - { - } - [TestMethod] - public void Test_7839() - { - } - [TestMethod] - public void Test_7840() - { - } - [TestMethod] - public void Test_7841() - { - } - [TestMethod] - public void Test_7842() - { - } - [TestMethod] - public void Test_7843() - { - } - [TestMethod] - public void Test_7844() - { - } - [TestMethod] - public void Test_7845() - { - } - [TestMethod] - public void Test_7846() - { - } - [TestMethod] - public void Test_7847() - { - } - [TestMethod] - public void Test_7848() - { - } - [TestMethod] - public void Test_7849() - { - } - [TestMethod] - public void Test_7850() - { - } - [TestMethod] - public void Test_7851() - { - } - [TestMethod] - public void Test_7852() - { - } - [TestMethod] - public void Test_7853() - { - } - [TestMethod] - public void Test_7854() - { - } - [TestMethod] - public void Test_7855() - { - } - [TestMethod] - public void Test_7856() - { - } - [TestMethod] - public void Test_7857() - { - } - [TestMethod] - public void Test_7858() - { - } - [TestMethod] - public void Test_7859() - { - } - [TestMethod] - public void Test_7860() - { - } - [TestMethod] - public void Test_7861() - { - } - [TestMethod] - public void Test_7862() - { - } - [TestMethod] - public void Test_7863() - { - } - [TestMethod] - public void Test_7864() - { - } - [TestMethod] - public void Test_7865() - { - } - [TestMethod] - public void Test_7866() - { - } - [TestMethod] - public void Test_7867() - { - } - [TestMethod] - public void Test_7868() - { - } - [TestMethod] - public void Test_7869() - { - } - [TestMethod] - public void Test_7870() - { - } - [TestMethod] - public void Test_7871() - { - } - [TestMethod] - public void Test_7872() - { - } - [TestMethod] - public void Test_7873() - { - } - [TestMethod] - public void Test_7874() - { - } - [TestMethod] - public void Test_7875() - { - } - [TestMethod] - public void Test_7876() - { - } - [TestMethod] - public void Test_7877() - { - } - [TestMethod] - public void Test_7878() - { - } - [TestMethod] - public void Test_7879() - { - } - [TestMethod] - public void Test_7880() - { - } - [TestMethod] - public void Test_7881() - { - } - [TestMethod] - public void Test_7882() - { - } - [TestMethod] - public void Test_7883() - { - } - [TestMethod] - public void Test_7884() - { - } - [TestMethod] - public void Test_7885() - { - } - [TestMethod] - public void Test_7886() - { - } - [TestMethod] - public void Test_7887() - { - } - [TestMethod] - public void Test_7888() - { - } - [TestMethod] - public void Test_7889() - { - } - [TestMethod] - public void Test_7890() - { - } - [TestMethod] - public void Test_7891() - { - } - [TestMethod] - public void Test_7892() - { - } - [TestMethod] - public void Test_7893() - { - } - [TestMethod] - public void Test_7894() - { - } - [TestMethod] - public void Test_7895() - { - } - [TestMethod] - public void Test_7896() - { - } - [TestMethod] - public void Test_7897() - { - } - [TestMethod] - public void Test_7898() - { - } - [TestMethod] - public void Test_7899() - { - } - [TestMethod] - public void Test_7900() - { - } - [TestMethod] - public void Test_7901() - { - } - [TestMethod] - public void Test_7902() - { - } - [TestMethod] - public void Test_7903() - { - } - [TestMethod] - public void Test_7904() - { - } - [TestMethod] - public void Test_7905() - { - } - [TestMethod] - public void Test_7906() - { - } - [TestMethod] - public void Test_7907() - { - } - [TestMethod] - public void Test_7908() - { - } - [TestMethod] - public void Test_7909() - { - } - [TestMethod] - public void Test_7910() - { - } - [TestMethod] - public void Test_7911() - { - } - [TestMethod] - public void Test_7912() - { - } - [TestMethod] - public void Test_7913() - { - } - [TestMethod] - public void Test_7914() - { - } - [TestMethod] - public void Test_7915() - { - } - [TestMethod] - public void Test_7916() - { - } - [TestMethod] - public void Test_7917() - { - } - [TestMethod] - public void Test_7918() - { - } - [TestMethod] - public void Test_7919() - { - } - [TestMethod] - public void Test_7920() - { - } - [TestMethod] - public void Test_7921() - { - } - [TestMethod] - public void Test_7922() - { - } - [TestMethod] - public void Test_7923() - { - } - [TestMethod] - public void Test_7924() - { - } - [TestMethod] - public void Test_7925() - { - } - [TestMethod] - public void Test_7926() - { - } - [TestMethod] - public void Test_7927() - { - } - [TestMethod] - public void Test_7928() - { - } - [TestMethod] - public void Test_7929() - { - } - [TestMethod] - public void Test_7930() - { - } - [TestMethod] - public void Test_7931() - { - } - [TestMethod] - public void Test_7932() - { - } - [TestMethod] - public void Test_7933() - { - } - [TestMethod] - public void Test_7934() - { - } - [TestMethod] - public void Test_7935() - { - } - [TestMethod] - public void Test_7936() - { - } - [TestMethod] - public void Test_7937() - { - } - [TestMethod] - public void Test_7938() - { - } - [TestMethod] - public void Test_7939() - { - } - [TestMethod] - public void Test_7940() - { - } - [TestMethod] - public void Test_7941() - { - } - [TestMethod] - public void Test_7942() - { - } - [TestMethod] - public void Test_7943() - { - } - [TestMethod] - public void Test_7944() - { - } - [TestMethod] - public void Test_7945() - { - } - [TestMethod] - public void Test_7946() - { - } - [TestMethod] - public void Test_7947() - { - } - [TestMethod] - public void Test_7948() - { - } - [TestMethod] - public void Test_7949() - { - } - [TestMethod] - public void Test_7950() - { - } - [TestMethod] - public void Test_7951() - { - } - [TestMethod] - public void Test_7952() - { - } - [TestMethod] - public void Test_7953() - { - } - [TestMethod] - public void Test_7954() - { - } - [TestMethod] - public void Test_7955() - { - } - [TestMethod] - public void Test_7956() - { - } - [TestMethod] - public void Test_7957() - { - } - [TestMethod] - public void Test_7958() - { - } - [TestMethod] - public void Test_7959() - { - } - [TestMethod] - public void Test_7960() - { - } - [TestMethod] - public void Test_7961() - { - } - [TestMethod] - public void Test_7962() - { - } - [TestMethod] - public void Test_7963() - { - } - [TestMethod] - public void Test_7964() - { - } - [TestMethod] - public void Test_7965() - { - } - [TestMethod] - public void Test_7966() - { - } - [TestMethod] - public void Test_7967() - { - } - [TestMethod] - public void Test_7968() - { - } - [TestMethod] - public void Test_7969() - { - } - [TestMethod] - public void Test_7970() - { - } - [TestMethod] - public void Test_7971() - { - } - [TestMethod] - public void Test_7972() - { - } - [TestMethod] - public void Test_7973() - { - } - [TestMethod] - public void Test_7974() - { - } - [TestMethod] - public void Test_7975() - { - } - [TestMethod] - public void Test_7976() - { - } - [TestMethod] - public void Test_7977() - { - } - [TestMethod] - public void Test_7978() - { - } - [TestMethod] - public void Test_7979() - { - } - [TestMethod] - public void Test_7980() - { - } - [TestMethod] - public void Test_7981() - { - } - [TestMethod] - public void Test_7982() - { - } - [TestMethod] - public void Test_7983() - { - } - [TestMethod] - public void Test_7984() - { - } - [TestMethod] - public void Test_7985() - { - } - [TestMethod] - public void Test_7986() - { - } - [TestMethod] - public void Test_7987() - { - } - [TestMethod] - public void Test_7988() - { - } - [TestMethod] - public void Test_7989() - { - } - [TestMethod] - public void Test_7990() - { - } - [TestMethod] - public void Test_7991() - { - } - [TestMethod] - public void Test_7992() - { - } - [TestMethod] - public void Test_7993() - { - } - [TestMethod] - public void Test_7994() - { - } - [TestMethod] - public void Test_7995() - { - } - [TestMethod] - public void Test_7996() - { - } - [TestMethod] - public void Test_7997() - { - } - [TestMethod] - public void Test_7998() - { - } - [TestMethod] - public void Test_7999() - { - } - [TestMethod] - public void Test_8000() - { - } - [TestMethod] - public void Test_8001() - { - } - [TestMethod] - public void Test_8002() - { - } - [TestMethod] - public void Test_8003() - { - } - [TestMethod] - public void Test_8004() - { - } - [TestMethod] - public void Test_8005() - { - } - [TestMethod] - public void Test_8006() - { - } - [TestMethod] - public void Test_8007() - { - } - [TestMethod] - public void Test_8008() - { - } - [TestMethod] - public void Test_8009() - { - } - [TestMethod] - public void Test_8010() - { - } - [TestMethod] - public void Test_8011() - { - } - [TestMethod] - public void Test_8012() - { - } - [TestMethod] - public void Test_8013() - { - } - [TestMethod] - public void Test_8014() - { - } - [TestMethod] - public void Test_8015() - { - } - [TestMethod] - public void Test_8016() - { - } - [TestMethod] - public void Test_8017() - { - } - [TestMethod] - public void Test_8018() - { - } - [TestMethod] - public void Test_8019() - { - } - [TestMethod] - public void Test_8020() - { - } - [TestMethod] - public void Test_8021() - { - } - [TestMethod] - public void Test_8022() - { - } - [TestMethod] - public void Test_8023() - { - } - [TestMethod] - public void Test_8024() - { - } - [TestMethod] - public void Test_8025() - { - } - [TestMethod] - public void Test_8026() - { - } - [TestMethod] - public void Test_8027() - { - } - [TestMethod] - public void Test_8028() - { - } - [TestMethod] - public void Test_8029() - { - } - [TestMethod] - public void Test_8030() - { - } - [TestMethod] - public void Test_8031() - { - } - [TestMethod] - public void Test_8032() - { - } - [TestMethod] - public void Test_8033() - { - } - [TestMethod] - public void Test_8034() - { - } - [TestMethod] - public void Test_8035() - { - } - [TestMethod] - public void Test_8036() - { - } - [TestMethod] - public void Test_8037() - { - } - [TestMethod] - public void Test_8038() - { - } - [TestMethod] - public void Test_8039() - { - } - [TestMethod] - public void Test_8040() - { - } - [TestMethod] - public void Test_8041() - { - } - [TestMethod] - public void Test_8042() - { - } - [TestMethod] - public void Test_8043() - { - } - [TestMethod] - public void Test_8044() - { - } - [TestMethod] - public void Test_8045() - { - } - [TestMethod] - public void Test_8046() - { - } - [TestMethod] - public void Test_8047() - { - } - [TestMethod] - public void Test_8048() - { - } - [TestMethod] - public void Test_8049() - { - } - [TestMethod] - public void Test_8050() - { - } - [TestMethod] - public void Test_8051() - { - } - [TestMethod] - public void Test_8052() - { - } - [TestMethod] - public void Test_8053() - { - } - [TestMethod] - public void Test_8054() - { - } - [TestMethod] - public void Test_8055() - { - } - [TestMethod] - public void Test_8056() - { - } - [TestMethod] - public void Test_8057() - { - } - [TestMethod] - public void Test_8058() - { - } - [TestMethod] - public void Test_8059() - { - } - [TestMethod] - public void Test_8060() - { - } - [TestMethod] - public void Test_8061() - { - } - [TestMethod] - public void Test_8062() - { - } - [TestMethod] - public void Test_8063() - { - } - [TestMethod] - public void Test_8064() - { - } - [TestMethod] - public void Test_8065() - { - } - [TestMethod] - public void Test_8066() - { - } - [TestMethod] - public void Test_8067() - { - } - [TestMethod] - public void Test_8068() - { - } - [TestMethod] - public void Test_8069() - { - } - [TestMethod] - public void Test_8070() - { - } - [TestMethod] - public void Test_8071() - { - } - [TestMethod] - public void Test_8072() - { - } - [TestMethod] - public void Test_8073() - { - } - [TestMethod] - public void Test_8074() - { - } - [TestMethod] - public void Test_8075() - { - } - [TestMethod] - public void Test_8076() - { - } - [TestMethod] - public void Test_8077() - { - } - [TestMethod] - public void Test_8078() - { - } - [TestMethod] - public void Test_8079() - { - } - [TestMethod] - public void Test_8080() - { - } - [TestMethod] - public void Test_8081() - { - } - [TestMethod] - public void Test_8082() - { - } - [TestMethod] - public void Test_8083() - { - } - [TestMethod] - public void Test_8084() - { - } - [TestMethod] - public void Test_8085() - { - } - [TestMethod] - public void Test_8086() - { - } - [TestMethod] - public void Test_8087() - { - } - [TestMethod] - public void Test_8088() - { - } - [TestMethod] - public void Test_8089() - { - } - [TestMethod] - public void Test_8090() - { - } - [TestMethod] - public void Test_8091() - { - } - [TestMethod] - public void Test_8092() - { - } - [TestMethod] - public void Test_8093() - { - } - [TestMethod] - public void Test_8094() - { - } - [TestMethod] - public void Test_8095() - { - } - [TestMethod] - public void Test_8096() - { - } - [TestMethod] - public void Test_8097() - { - } - [TestMethod] - public void Test_8098() - { - } - [TestMethod] - public void Test_8099() - { - } - [TestMethod] - public void Test_8100() - { - } - [TestMethod] - public void Test_8101() - { - } - [TestMethod] - public void Test_8102() - { - } - [TestMethod] - public void Test_8103() - { - } - [TestMethod] - public void Test_8104() - { - } - [TestMethod] - public void Test_8105() - { - } - [TestMethod] - public void Test_8106() - { - } - [TestMethod] - public void Test_8107() - { - } - [TestMethod] - public void Test_8108() - { - } - [TestMethod] - public void Test_8109() - { - } - [TestMethod] - public void Test_8110() - { - } - [TestMethod] - public void Test_8111() - { - } - [TestMethod] - public void Test_8112() - { - } - [TestMethod] - public void Test_8113() - { - } - [TestMethod] - public void Test_8114() - { - } - [TestMethod] - public void Test_8115() - { - } - [TestMethod] - public void Test_8116() - { - } - [TestMethod] - public void Test_8117() - { - } - [TestMethod] - public void Test_8118() - { - } - [TestMethod] - public void Test_8119() - { - } - [TestMethod] - public void Test_8120() - { - } - [TestMethod] - public void Test_8121() - { - } - [TestMethod] - public void Test_8122() - { - } - [TestMethod] - public void Test_8123() - { - } - [TestMethod] - public void Test_8124() - { - } - [TestMethod] - public void Test_8125() - { - } - [TestMethod] - public void Test_8126() - { - } - [TestMethod] - public void Test_8127() - { - } - [TestMethod] - public void Test_8128() - { - } - [TestMethod] - public void Test_8129() - { - } - [TestMethod] - public void Test_8130() - { - } - [TestMethod] - public void Test_8131() - { - } - [TestMethod] - public void Test_8132() - { - } - [TestMethod] - public void Test_8133() - { - } - [TestMethod] - public void Test_8134() - { - } - [TestMethod] - public void Test_8135() - { - } - [TestMethod] - public void Test_8136() - { - } - [TestMethod] - public void Test_8137() - { - } - [TestMethod] - public void Test_8138() - { - } - [TestMethod] - public void Test_8139() - { - } - [TestMethod] - public void Test_8140() - { - } - [TestMethod] - public void Test_8141() - { - } - [TestMethod] - public void Test_8142() - { - } - [TestMethod] - public void Test_8143() - { - } - [TestMethod] - public void Test_8144() - { - } - [TestMethod] - public void Test_8145() - { - } - [TestMethod] - public void Test_8146() - { - } - [TestMethod] - public void Test_8147() - { - } - [TestMethod] - public void Test_8148() - { - } - [TestMethod] - public void Test_8149() - { - } - [TestMethod] - public void Test_8150() - { - } - [TestMethod] - public void Test_8151() - { - } - [TestMethod] - public void Test_8152() - { - } - [TestMethod] - public void Test_8153() - { - } - [TestMethod] - public void Test_8154() - { - } - [TestMethod] - public void Test_8155() - { - } - [TestMethod] - public void Test_8156() - { - } - [TestMethod] - public void Test_8157() - { - } - [TestMethod] - public void Test_8158() - { - } - [TestMethod] - public void Test_8159() - { - } - [TestMethod] - public void Test_8160() - { - } - [TestMethod] - public void Test_8161() - { - } - [TestMethod] - public void Test_8162() - { - } - [TestMethod] - public void Test_8163() - { - } - [TestMethod] - public void Test_8164() - { - } - [TestMethod] - public void Test_8165() - { - } - [TestMethod] - public void Test_8166() - { - } - [TestMethod] - public void Test_8167() - { - } - [TestMethod] - public void Test_8168() - { - } - [TestMethod] - public void Test_8169() - { - } - [TestMethod] - public void Test_8170() - { - } - [TestMethod] - public void Test_8171() - { - } - [TestMethod] - public void Test_8172() - { - } - [TestMethod] - public void Test_8173() - { - } - [TestMethod] - public void Test_8174() - { - } - [TestMethod] - public void Test_8175() - { - } - [TestMethod] - public void Test_8176() - { - } - [TestMethod] - public void Test_8177() - { - } - [TestMethod] - public void Test_8178() - { - } - [TestMethod] - public void Test_8179() - { - } - [TestMethod] - public void Test_8180() - { - } - [TestMethod] - public void Test_8181() - { - } - [TestMethod] - public void Test_8182() - { - } - [TestMethod] - public void Test_8183() - { - } - [TestMethod] - public void Test_8184() - { - } - [TestMethod] - public void Test_8185() - { - } - [TestMethod] - public void Test_8186() - { - } - [TestMethod] - public void Test_8187() - { - } - [TestMethod] - public void Test_8188() - { - } - [TestMethod] - public void Test_8189() - { - } - [TestMethod] - public void Test_8190() - { - } - [TestMethod] - public void Test_8191() - { - } - [TestMethod] - public void Test_8192() - { - } - [TestMethod] - public void Test_8193() - { - } - [TestMethod] - public void Test_8194() - { - } - [TestMethod] - public void Test_8195() - { - } - [TestMethod] - public void Test_8196() - { - } - [TestMethod] - public void Test_8197() - { - } - [TestMethod] - public void Test_8198() - { - } - [TestMethod] - public void Test_8199() - { - } - [TestMethod] - public void Test_8200() - { - } - [TestMethod] - public void Test_8201() - { - } - [TestMethod] - public void Test_8202() - { - } - [TestMethod] - public void Test_8203() - { - } - [TestMethod] - public void Test_8204() - { - } - [TestMethod] - public void Test_8205() - { - } - [TestMethod] - public void Test_8206() - { - } - [TestMethod] - public void Test_8207() - { - } - [TestMethod] - public void Test_8208() - { - } - [TestMethod] - public void Test_8209() - { - } - [TestMethod] - public void Test_8210() - { - } - [TestMethod] - public void Test_8211() - { - } - [TestMethod] - public void Test_8212() - { - } - [TestMethod] - public void Test_8213() - { - } - [TestMethod] - public void Test_8214() - { - } - [TestMethod] - public void Test_8215() - { - } - [TestMethod] - public void Test_8216() - { - } - [TestMethod] - public void Test_8217() - { - } - [TestMethod] - public void Test_8218() - { - } - [TestMethod] - public void Test_8219() - { - } - [TestMethod] - public void Test_8220() - { - } - [TestMethod] - public void Test_8221() - { - } - [TestMethod] - public void Test_8222() - { - } - [TestMethod] - public void Test_8223() - { - } - [TestMethod] - public void Test_8224() - { - } - [TestMethod] - public void Test_8225() - { - } - [TestMethod] - public void Test_8226() - { - } - [TestMethod] - public void Test_8227() - { - } - [TestMethod] - public void Test_8228() - { - } - [TestMethod] - public void Test_8229() - { - } - [TestMethod] - public void Test_8230() - { - } - [TestMethod] - public void Test_8231() - { - } - [TestMethod] - public void Test_8232() - { - } - [TestMethod] - public void Test_8233() - { - } - [TestMethod] - public void Test_8234() - { - } - [TestMethod] - public void Test_8235() - { - } - [TestMethod] - public void Test_8236() - { - } - [TestMethod] - public void Test_8237() - { - } - [TestMethod] - public void Test_8238() - { - } - [TestMethod] - public void Test_8239() - { - } - [TestMethod] - public void Test_8240() - { - } - [TestMethod] - public void Test_8241() - { - } - [TestMethod] - public void Test_8242() - { - } - [TestMethod] - public void Test_8243() - { - } - [TestMethod] - public void Test_8244() - { - } - [TestMethod] - public void Test_8245() - { - } - [TestMethod] - public void Test_8246() - { - } - [TestMethod] - public void Test_8247() - { - } - [TestMethod] - public void Test_8248() - { - } - [TestMethod] - public void Test_8249() - { - } - [TestMethod] - public void Test_8250() - { - } - [TestMethod] - public void Test_8251() - { - } - [TestMethod] - public void Test_8252() - { - } - [TestMethod] - public void Test_8253() - { - } - [TestMethod] - public void Test_8254() - { - } - [TestMethod] - public void Test_8255() - { - } - [TestMethod] - public void Test_8256() - { - } - [TestMethod] - public void Test_8257() - { - } - [TestMethod] - public void Test_8258() - { - } - [TestMethod] - public void Test_8259() - { - } - [TestMethod] - public void Test_8260() - { - } - [TestMethod] - public void Test_8261() - { - } - [TestMethod] - public void Test_8262() - { - } - [TestMethod] - public void Test_8263() - { - } - [TestMethod] - public void Test_8264() - { - } - [TestMethod] - public void Test_8265() - { - } - [TestMethod] - public void Test_8266() - { - } - [TestMethod] - public void Test_8267() - { - } - [TestMethod] - public void Test_8268() - { - } - [TestMethod] - public void Test_8269() - { - } - [TestMethod] - public void Test_8270() - { - } - [TestMethod] - public void Test_8271() - { - } - [TestMethod] - public void Test_8272() - { - } - [TestMethod] - public void Test_8273() - { - } - [TestMethod] - public void Test_8274() - { - } - [TestMethod] - public void Test_8275() - { - } - [TestMethod] - public void Test_8276() - { - } - [TestMethod] - public void Test_8277() - { - } - [TestMethod] - public void Test_8278() - { - } - [TestMethod] - public void Test_8279() - { - } - [TestMethod] - public void Test_8280() - { - } - [TestMethod] - public void Test_8281() - { - } - [TestMethod] - public void Test_8282() - { - } - [TestMethod] - public void Test_8283() - { - } - [TestMethod] - public void Test_8284() - { - } - [TestMethod] - public void Test_8285() - { - } - [TestMethod] - public void Test_8286() - { - } - [TestMethod] - public void Test_8287() - { - } - [TestMethod] - public void Test_8288() - { - } - [TestMethod] - public void Test_8289() - { - } - [TestMethod] - public void Test_8290() - { - } - [TestMethod] - public void Test_8291() - { - } - [TestMethod] - public void Test_8292() - { - } - [TestMethod] - public void Test_8293() - { - } - [TestMethod] - public void Test_8294() - { - } - [TestMethod] - public void Test_8295() - { - } - [TestMethod] - public void Test_8296() - { - } - [TestMethod] - public void Test_8297() - { - } - [TestMethod] - public void Test_8298() - { - } - [TestMethod] - public void Test_8299() - { - } - [TestMethod] - public void Test_8300() - { - } - [TestMethod] - public void Test_8301() - { - } - [TestMethod] - public void Test_8302() - { - } - [TestMethod] - public void Test_8303() - { - } - [TestMethod] - public void Test_8304() - { - } - [TestMethod] - public void Test_8305() - { - } - [TestMethod] - public void Test_8306() - { - } - [TestMethod] - public void Test_8307() - { - } - [TestMethod] - public void Test_8308() - { - } - [TestMethod] - public void Test_8309() - { - } - [TestMethod] - public void Test_8310() - { - } - [TestMethod] - public void Test_8311() - { - } - [TestMethod] - public void Test_8312() - { - } - [TestMethod] - public void Test_8313() - { - } - [TestMethod] - public void Test_8314() - { - } - [TestMethod] - public void Test_8315() - { - } - [TestMethod] - public void Test_8316() - { - } - [TestMethod] - public void Test_8317() - { - } - [TestMethod] - public void Test_8318() - { - } - [TestMethod] - public void Test_8319() - { - } - [TestMethod] - public void Test_8320() - { - } - [TestMethod] - public void Test_8321() - { - } - [TestMethod] - public void Test_8322() - { - } - [TestMethod] - public void Test_8323() - { - } - [TestMethod] - public void Test_8324() - { - } - [TestMethod] - public void Test_8325() - { - } - [TestMethod] - public void Test_8326() - { - } - [TestMethod] - public void Test_8327() - { - } - [TestMethod] - public void Test_8328() - { - } - [TestMethod] - public void Test_8329() - { - } - [TestMethod] - public void Test_8330() - { - } - [TestMethod] - public void Test_8331() - { - } - [TestMethod] - public void Test_8332() - { - } - [TestMethod] - public void Test_8333() - { - } - [TestMethod] - public void Test_8334() - { - } - [TestMethod] - public void Test_8335() - { - } - [TestMethod] - public void Test_8336() - { - } - [TestMethod] - public void Test_8337() - { - } - [TestMethod] - public void Test_8338() - { - } - [TestMethod] - public void Test_8339() - { - } - [TestMethod] - public void Test_8340() - { - } - [TestMethod] - public void Test_8341() - { - } - [TestMethod] - public void Test_8342() - { - } - [TestMethod] - public void Test_8343() - { - } - [TestMethod] - public void Test_8344() - { - } - [TestMethod] - public void Test_8345() - { - } - [TestMethod] - public void Test_8346() - { - } - [TestMethod] - public void Test_8347() - { - } - [TestMethod] - public void Test_8348() - { - } - [TestMethod] - public void Test_8349() - { - } - [TestMethod] - public void Test_8350() - { - } - [TestMethod] - public void Test_8351() - { - } - [TestMethod] - public void Test_8352() - { - } - [TestMethod] - public void Test_8353() - { - } - [TestMethod] - public void Test_8354() - { - } - [TestMethod] - public void Test_8355() - { - } - [TestMethod] - public void Test_8356() - { - } - [TestMethod] - public void Test_8357() - { - } - [TestMethod] - public void Test_8358() - { - } - [TestMethod] - public void Test_8359() - { - } - [TestMethod] - public void Test_8360() - { - } - [TestMethod] - public void Test_8361() - { - } - [TestMethod] - public void Test_8362() - { - } - [TestMethod] - public void Test_8363() - { - } - [TestMethod] - public void Test_8364() - { - } - [TestMethod] - public void Test_8365() - { - } - [TestMethod] - public void Test_8366() - { - } - [TestMethod] - public void Test_8367() - { - } - [TestMethod] - public void Test_8368() - { - } - [TestMethod] - public void Test_8369() - { - } - [TestMethod] - public void Test_8370() - { - } - [TestMethod] - public void Test_8371() - { - } - [TestMethod] - public void Test_8372() - { - } - [TestMethod] - public void Test_8373() - { - } - [TestMethod] - public void Test_8374() - { - } - [TestMethod] - public void Test_8375() - { - } - [TestMethod] - public void Test_8376() - { - } - [TestMethod] - public void Test_8377() - { - } - [TestMethod] - public void Test_8378() - { - } - [TestMethod] - public void Test_8379() - { - } - [TestMethod] - public void Test_8380() - { - } - [TestMethod] - public void Test_8381() - { - } - [TestMethod] - public void Test_8382() - { - } - [TestMethod] - public void Test_8383() - { - } - [TestMethod] - public void Test_8384() - { - } - [TestMethod] - public void Test_8385() - { - } - [TestMethod] - public void Test_8386() - { - } - [TestMethod] - public void Test_8387() - { - } - [TestMethod] - public void Test_8388() - { - } - [TestMethod] - public void Test_8389() - { - } - [TestMethod] - public void Test_8390() - { - } - [TestMethod] - public void Test_8391() - { - } - [TestMethod] - public void Test_8392() - { - } - [TestMethod] - public void Test_8393() - { - } - [TestMethod] - public void Test_8394() - { - } - [TestMethod] - public void Test_8395() - { - } - [TestMethod] - public void Test_8396() - { - } - [TestMethod] - public void Test_8397() - { - } - [TestMethod] - public void Test_8398() - { - } - [TestMethod] - public void Test_8399() - { - } - [TestMethod] - public void Test_8400() - { - } - [TestMethod] - public void Test_8401() - { - } - [TestMethod] - public void Test_8402() - { - } - [TestMethod] - public void Test_8403() - { - } - [TestMethod] - public void Test_8404() - { - } - [TestMethod] - public void Test_8405() - { - } - [TestMethod] - public void Test_8406() - { - } - [TestMethod] - public void Test_8407() - { - } - [TestMethod] - public void Test_8408() - { - } - [TestMethod] - public void Test_8409() - { - } - [TestMethod] - public void Test_8410() - { - } - [TestMethod] - public void Test_8411() - { - } - [TestMethod] - public void Test_8412() - { - } - [TestMethod] - public void Test_8413() - { - } - [TestMethod] - public void Test_8414() - { - } - [TestMethod] - public void Test_8415() - { - } - [TestMethod] - public void Test_8416() - { - } - [TestMethod] - public void Test_8417() - { - } - [TestMethod] - public void Test_8418() - { - } - [TestMethod] - public void Test_8419() - { - } - [TestMethod] - public void Test_8420() - { - } - [TestMethod] - public void Test_8421() - { - } - [TestMethod] - public void Test_8422() - { - } - [TestMethod] - public void Test_8423() - { - } - [TestMethod] - public void Test_8424() - { - } - [TestMethod] - public void Test_8425() - { - } - [TestMethod] - public void Test_8426() - { - } - [TestMethod] - public void Test_8427() - { - } - [TestMethod] - public void Test_8428() - { - } - [TestMethod] - public void Test_8429() - { - } - [TestMethod] - public void Test_8430() - { - } - [TestMethod] - public void Test_8431() - { - } - [TestMethod] - public void Test_8432() - { - } - [TestMethod] - public void Test_8433() - { - } - [TestMethod] - public void Test_8434() - { - } - [TestMethod] - public void Test_8435() - { - } - [TestMethod] - public void Test_8436() - { - } - [TestMethod] - public void Test_8437() - { - } - [TestMethod] - public void Test_8438() - { - } - [TestMethod] - public void Test_8439() - { - } - [TestMethod] - public void Test_8440() - { - } - [TestMethod] - public void Test_8441() - { - } - [TestMethod] - public void Test_8442() - { - } - [TestMethod] - public void Test_8443() - { - } - [TestMethod] - public void Test_8444() - { - } - [TestMethod] - public void Test_8445() - { - } - [TestMethod] - public void Test_8446() - { - } - [TestMethod] - public void Test_8447() - { - } - [TestMethod] - public void Test_8448() - { - } - [TestMethod] - public void Test_8449() - { - } - [TestMethod] - public void Test_8450() - { - } - [TestMethod] - public void Test_8451() - { - } - [TestMethod] - public void Test_8452() - { - } - [TestMethod] - public void Test_8453() - { - } - [TestMethod] - public void Test_8454() - { - } - [TestMethod] - public void Test_8455() - { - } - [TestMethod] - public void Test_8456() - { - } - [TestMethod] - public void Test_8457() - { - } - [TestMethod] - public void Test_8458() - { - } - [TestMethod] - public void Test_8459() - { - } - [TestMethod] - public void Test_8460() - { - } - [TestMethod] - public void Test_8461() - { - } - [TestMethod] - public void Test_8462() - { - } - [TestMethod] - public void Test_8463() - { - } - [TestMethod] - public void Test_8464() - { - } - [TestMethod] - public void Test_8465() - { - } - [TestMethod] - public void Test_8466() - { - } - [TestMethod] - public void Test_8467() - { - } - [TestMethod] - public void Test_8468() - { - } - [TestMethod] - public void Test_8469() - { - } - [TestMethod] - public void Test_8470() - { - } - [TestMethod] - public void Test_8471() - { - } - [TestMethod] - public void Test_8472() - { - } - [TestMethod] - public void Test_8473() - { - } - [TestMethod] - public void Test_8474() - { - } - [TestMethod] - public void Test_8475() - { - } - [TestMethod] - public void Test_8476() - { - } - [TestMethod] - public void Test_8477() - { - } - [TestMethod] - public void Test_8478() - { - } - [TestMethod] - public void Test_8479() - { - } - [TestMethod] - public void Test_8480() - { - } - [TestMethod] - public void Test_8481() - { - } - [TestMethod] - public void Test_8482() - { - } - [TestMethod] - public void Test_8483() - { - } - [TestMethod] - public void Test_8484() - { - } - [TestMethod] - public void Test_8485() - { - } - [TestMethod] - public void Test_8486() - { - } - [TestMethod] - public void Test_8487() - { - } - [TestMethod] - public void Test_8488() - { - } - [TestMethod] - public void Test_8489() - { - } - [TestMethod] - public void Test_8490() - { - } - [TestMethod] - public void Test_8491() - { - } - [TestMethod] - public void Test_8492() - { - } - [TestMethod] - public void Test_8493() - { - } - [TestMethod] - public void Test_8494() - { - } - [TestMethod] - public void Test_8495() - { - } - [TestMethod] - public void Test_8496() - { - } - [TestMethod] - public void Test_8497() - { - } - [TestMethod] - public void Test_8498() - { - } - [TestMethod] - public void Test_8499() - { - } - [TestMethod] - public void Test_8500() - { - } - [TestMethod] - public void Test_8501() - { - } - [TestMethod] - public void Test_8502() - { - } - [TestMethod] - public void Test_8503() - { - } - [TestMethod] - public void Test_8504() - { - } - [TestMethod] - public void Test_8505() - { - } - [TestMethod] - public void Test_8506() - { - } - [TestMethod] - public void Test_8507() - { - } - [TestMethod] - public void Test_8508() - { - } - [TestMethod] - public void Test_8509() - { - } - [TestMethod] - public void Test_8510() - { - } - [TestMethod] - public void Test_8511() - { - } - [TestMethod] - public void Test_8512() - { - } - [TestMethod] - public void Test_8513() - { - } - [TestMethod] - public void Test_8514() - { - } - [TestMethod] - public void Test_8515() - { - } - [TestMethod] - public void Test_8516() - { - } - [TestMethod] - public void Test_8517() - { - } - [TestMethod] - public void Test_8518() - { - } - [TestMethod] - public void Test_8519() - { - } - [TestMethod] - public void Test_8520() - { - } - [TestMethod] - public void Test_8521() - { - } - [TestMethod] - public void Test_8522() - { - } - [TestMethod] - public void Test_8523() - { - } - [TestMethod] - public void Test_8524() - { - } - [TestMethod] - public void Test_8525() - { - } - [TestMethod] - public void Test_8526() - { - } - [TestMethod] - public void Test_8527() - { - } - [TestMethod] - public void Test_8528() - { - } - [TestMethod] - public void Test_8529() - { - } - [TestMethod] - public void Test_8530() - { - } - [TestMethod] - public void Test_8531() - { - } - [TestMethod] - public void Test_8532() - { - } - [TestMethod] - public void Test_8533() - { - } - [TestMethod] - public void Test_8534() - { - } - [TestMethod] - public void Test_8535() - { - } - [TestMethod] - public void Test_8536() - { - } - [TestMethod] - public void Test_8537() - { - } - [TestMethod] - public void Test_8538() - { - } - [TestMethod] - public void Test_8539() - { - } - [TestMethod] - public void Test_8540() - { - } - [TestMethod] - public void Test_8541() - { - } - [TestMethod] - public void Test_8542() - { - } - [TestMethod] - public void Test_8543() - { - } - [TestMethod] - public void Test_8544() - { - } - [TestMethod] - public void Test_8545() - { - } - [TestMethod] - public void Test_8546() - { - } - [TestMethod] - public void Test_8547() - { - } - [TestMethod] - public void Test_8548() - { - } - [TestMethod] - public void Test_8549() - { - } - [TestMethod] - public void Test_8550() - { - } - [TestMethod] - public void Test_8551() - { - } - [TestMethod] - public void Test_8552() - { - } - [TestMethod] - public void Test_8553() - { - } - [TestMethod] - public void Test_8554() - { - } - [TestMethod] - public void Test_8555() - { - } - [TestMethod] - public void Test_8556() - { - } - [TestMethod] - public void Test_8557() - { - } - [TestMethod] - public void Test_8558() - { - } - [TestMethod] - public void Test_8559() - { - } - [TestMethod] - public void Test_8560() - { - } - [TestMethod] - public void Test_8561() - { - } - [TestMethod] - public void Test_8562() - { - } - [TestMethod] - public void Test_8563() - { - } - [TestMethod] - public void Test_8564() - { - } - [TestMethod] - public void Test_8565() - { - } - [TestMethod] - public void Test_8566() - { - } - [TestMethod] - public void Test_8567() - { - } - [TestMethod] - public void Test_8568() - { - } - [TestMethod] - public void Test_8569() - { - } - [TestMethod] - public void Test_8570() - { - } - [TestMethod] - public void Test_8571() - { - } - [TestMethod] - public void Test_8572() - { - } - [TestMethod] - public void Test_8573() - { - } - [TestMethod] - public void Test_8574() - { - } - [TestMethod] - public void Test_8575() - { - } - [TestMethod] - public void Test_8576() - { - } - [TestMethod] - public void Test_8577() - { - } - [TestMethod] - public void Test_8578() - { - } - [TestMethod] - public void Test_8579() - { - } - [TestMethod] - public void Test_8580() - { - } - [TestMethod] - public void Test_8581() - { - } - [TestMethod] - public void Test_8582() - { - } - [TestMethod] - public void Test_8583() - { - } - [TestMethod] - public void Test_8584() - { - } - [TestMethod] - public void Test_8585() - { - } - [TestMethod] - public void Test_8586() - { - } - [TestMethod] - public void Test_8587() - { - } - [TestMethod] - public void Test_8588() - { - } - [TestMethod] - public void Test_8589() - { - } - [TestMethod] - public void Test_8590() - { - } - [TestMethod] - public void Test_8591() - { - } - [TestMethod] - public void Test_8592() - { - } - [TestMethod] - public void Test_8593() - { - } - [TestMethod] - public void Test_8594() - { - } - [TestMethod] - public void Test_8595() - { - } - [TestMethod] - public void Test_8596() - { - } - [TestMethod] - public void Test_8597() - { - } - [TestMethod] - public void Test_8598() - { - } - [TestMethod] - public void Test_8599() - { - } - [TestMethod] - public void Test_8600() - { - } - [TestMethod] - public void Test_8601() - { - } - [TestMethod] - public void Test_8602() - { - } - [TestMethod] - public void Test_8603() - { - } - [TestMethod] - public void Test_8604() - { - } - [TestMethod] - public void Test_8605() - { - } - [TestMethod] - public void Test_8606() - { - } - [TestMethod] - public void Test_8607() - { - } - [TestMethod] - public void Test_8608() - { - } - [TestMethod] - public void Test_8609() - { - } - [TestMethod] - public void Test_8610() - { - } - [TestMethod] - public void Test_8611() - { - } - [TestMethod] - public void Test_8612() - { - } - [TestMethod] - public void Test_8613() - { - } - [TestMethod] - public void Test_8614() - { - } - [TestMethod] - public void Test_8615() - { - } - [TestMethod] - public void Test_8616() - { - } - [TestMethod] - public void Test_8617() - { - } - [TestMethod] - public void Test_8618() - { - } - [TestMethod] - public void Test_8619() - { - } - [TestMethod] - public void Test_8620() - { - } - [TestMethod] - public void Test_8621() - { - } - [TestMethod] - public void Test_8622() - { - } - [TestMethod] - public void Test_8623() - { - } - [TestMethod] - public void Test_8624() - { - } - [TestMethod] - public void Test_8625() - { - } - [TestMethod] - public void Test_8626() - { - } - [TestMethod] - public void Test_8627() - { - } - [TestMethod] - public void Test_8628() - { - } - [TestMethod] - public void Test_8629() - { - } - [TestMethod] - public void Test_8630() - { - } - [TestMethod] - public void Test_8631() - { - } - [TestMethod] - public void Test_8632() - { - } - [TestMethod] - public void Test_8633() - { - } - [TestMethod] - public void Test_8634() - { - } - [TestMethod] - public void Test_8635() - { - } - [TestMethod] - public void Test_8636() - { - } - [TestMethod] - public void Test_8637() - { - } - [TestMethod] - public void Test_8638() - { - } - [TestMethod] - public void Test_8639() - { - } - [TestMethod] - public void Test_8640() - { - } - [TestMethod] - public void Test_8641() - { - } - [TestMethod] - public void Test_8642() - { - } - [TestMethod] - public void Test_8643() - { - } - [TestMethod] - public void Test_8644() - { - } - [TestMethod] - public void Test_8645() - { - } - [TestMethod] - public void Test_8646() - { - } - [TestMethod] - public void Test_8647() - { - } - [TestMethod] - public void Test_8648() - { - } - [TestMethod] - public void Test_8649() - { - } - [TestMethod] - public void Test_8650() - { - } - [TestMethod] - public void Test_8651() - { - } - [TestMethod] - public void Test_8652() - { - } - [TestMethod] - public void Test_8653() - { - } - [TestMethod] - public void Test_8654() - { - } - [TestMethod] - public void Test_8655() - { - } - [TestMethod] - public void Test_8656() - { - } - [TestMethod] - public void Test_8657() - { - } - [TestMethod] - public void Test_8658() - { - } - [TestMethod] - public void Test_8659() - { - } - [TestMethod] - public void Test_8660() - { - } - [TestMethod] - public void Test_8661() - { - } - [TestMethod] - public void Test_8662() - { - } - [TestMethod] - public void Test_8663() - { - } - [TestMethod] - public void Test_8664() - { - } - [TestMethod] - public void Test_8665() - { - } - [TestMethod] - public void Test_8666() - { - } - [TestMethod] - public void Test_8667() - { - } - [TestMethod] - public void Test_8668() - { - } - [TestMethod] - public void Test_8669() - { - } - [TestMethod] - public void Test_8670() - { - } - [TestMethod] - public void Test_8671() - { - } - [TestMethod] - public void Test_8672() - { - } - [TestMethod] - public void Test_8673() - { - } - [TestMethod] - public void Test_8674() - { - } - [TestMethod] - public void Test_8675() - { - } - [TestMethod] - public void Test_8676() - { - } - [TestMethod] - public void Test_8677() - { - } - [TestMethod] - public void Test_8678() - { - } - [TestMethod] - public void Test_8679() - { - } - [TestMethod] - public void Test_8680() - { - } - [TestMethod] - public void Test_8681() - { - } - [TestMethod] - public void Test_8682() - { - } - [TestMethod] - public void Test_8683() - { - } - [TestMethod] - public void Test_8684() - { - } - [TestMethod] - public void Test_8685() - { - } - [TestMethod] - public void Test_8686() - { - } - [TestMethod] - public void Test_8687() - { - } - [TestMethod] - public void Test_8688() - { - } - [TestMethod] - public void Test_8689() - { - } - [TestMethod] - public void Test_8690() - { - } - [TestMethod] - public void Test_8691() - { - } - [TestMethod] - public void Test_8692() - { - } - [TestMethod] - public void Test_8693() - { - } - [TestMethod] - public void Test_8694() - { - } - [TestMethod] - public void Test_8695() - { - } - [TestMethod] - public void Test_8696() - { - } - [TestMethod] - public void Test_8697() - { - } - [TestMethod] - public void Test_8698() - { - } - [TestMethod] - public void Test_8699() - { - } - [TestMethod] - public void Test_8700() - { - } - [TestMethod] - public void Test_8701() - { - } - [TestMethod] - public void Test_8702() - { - } - [TestMethod] - public void Test_8703() - { - } - [TestMethod] - public void Test_8704() - { - } - [TestMethod] - public void Test_8705() - { - } - [TestMethod] - public void Test_8706() - { - } - [TestMethod] - public void Test_8707() - { - } - [TestMethod] - public void Test_8708() - { - } - [TestMethod] - public void Test_8709() - { - } - [TestMethod] - public void Test_8710() - { - } - [TestMethod] - public void Test_8711() - { - } - [TestMethod] - public void Test_8712() - { - } - [TestMethod] - public void Test_8713() - { - } - [TestMethod] - public void Test_8714() - { - } - [TestMethod] - public void Test_8715() - { - } - [TestMethod] - public void Test_8716() - { - } - [TestMethod] - public void Test_8717() - { - } - [TestMethod] - public void Test_8718() - { - } - [TestMethod] - public void Test_8719() - { - } - [TestMethod] - public void Test_8720() - { - } - [TestMethod] - public void Test_8721() - { - } - [TestMethod] - public void Test_8722() - { - } - [TestMethod] - public void Test_8723() - { - } - [TestMethod] - public void Test_8724() - { - } - [TestMethod] - public void Test_8725() - { - } - [TestMethod] - public void Test_8726() - { - } - [TestMethod] - public void Test_8727() - { - } - [TestMethod] - public void Test_8728() - { - } - [TestMethod] - public void Test_8729() - { - } - [TestMethod] - public void Test_8730() - { - } - [TestMethod] - public void Test_8731() - { - } - [TestMethod] - public void Test_8732() - { - } - [TestMethod] - public void Test_8733() - { - } - [TestMethod] - public void Test_8734() - { - } - [TestMethod] - public void Test_8735() - { - } - [TestMethod] - public void Test_8736() - { - } - [TestMethod] - public void Test_8737() - { - } - [TestMethod] - public void Test_8738() - { - } - [TestMethod] - public void Test_8739() - { - } - [TestMethod] - public void Test_8740() - { - } - [TestMethod] - public void Test_8741() - { - } - [TestMethod] - public void Test_8742() - { - } - [TestMethod] - public void Test_8743() - { - } - [TestMethod] - public void Test_8744() - { - } - [TestMethod] - public void Test_8745() - { - } - [TestMethod] - public void Test_8746() - { - } - [TestMethod] - public void Test_8747() - { - } - [TestMethod] - public void Test_8748() - { - } - [TestMethod] - public void Test_8749() - { - } - [TestMethod] - public void Test_8750() - { - } - [TestMethod] - public void Test_8751() - { - } - [TestMethod] - public void Test_8752() - { - } - [TestMethod] - public void Test_8753() - { - } - [TestMethod] - public void Test_8754() - { - } - [TestMethod] - public void Test_8755() - { - } - [TestMethod] - public void Test_8756() - { - } - [TestMethod] - public void Test_8757() - { - } - [TestMethod] - public void Test_8758() - { - } - [TestMethod] - public void Test_8759() - { - } - [TestMethod] - public void Test_8760() - { - } - [TestMethod] - public void Test_8761() - { - } - [TestMethod] - public void Test_8762() - { - } - [TestMethod] - public void Test_8763() - { - } - [TestMethod] - public void Test_8764() - { - } - [TestMethod] - public void Test_8765() - { - } - [TestMethod] - public void Test_8766() - { - } - [TestMethod] - public void Test_8767() - { - } - [TestMethod] - public void Test_8768() - { - } - [TestMethod] - public void Test_8769() - { - } - [TestMethod] - public void Test_8770() - { - } - [TestMethod] - public void Test_8771() - { - } - [TestMethod] - public void Test_8772() - { - } - [TestMethod] - public void Test_8773() - { - } - [TestMethod] - public void Test_8774() - { - } - [TestMethod] - public void Test_8775() - { - } - [TestMethod] - public void Test_8776() - { - } - [TestMethod] - public void Test_8777() - { - } - [TestMethod] - public void Test_8778() - { - } - [TestMethod] - public void Test_8779() - { - } - [TestMethod] - public void Test_8780() - { - } - [TestMethod] - public void Test_8781() - { - } - [TestMethod] - public void Test_8782() - { - } - [TestMethod] - public void Test_8783() - { - } - [TestMethod] - public void Test_8784() - { - } - [TestMethod] - public void Test_8785() - { - } - [TestMethod] - public void Test_8786() - { - } - [TestMethod] - public void Test_8787() - { - } - [TestMethod] - public void Test_8788() - { - } - [TestMethod] - public void Test_8789() - { - } - [TestMethod] - public void Test_8790() - { - } - [TestMethod] - public void Test_8791() - { - } - [TestMethod] - public void Test_8792() - { - } - [TestMethod] - public void Test_8793() - { - } - [TestMethod] - public void Test_8794() - { - } - [TestMethod] - public void Test_8795() - { - } - [TestMethod] - public void Test_8796() - { - } - [TestMethod] - public void Test_8797() - { - } - [TestMethod] - public void Test_8798() - { - } - [TestMethod] - public void Test_8799() - { - } - [TestMethod] - public void Test_8800() - { - } - [TestMethod] - public void Test_8801() - { - } - [TestMethod] - public void Test_8802() - { - } - [TestMethod] - public void Test_8803() - { - } - [TestMethod] - public void Test_8804() - { - } - [TestMethod] - public void Test_8805() - { - } - [TestMethod] - public void Test_8806() - { - } - [TestMethod] - public void Test_8807() - { - } - [TestMethod] - public void Test_8808() - { - } - [TestMethod] - public void Test_8809() - { - } - [TestMethod] - public void Test_8810() - { - } - [TestMethod] - public void Test_8811() - { - } - [TestMethod] - public void Test_8812() - { - } - [TestMethod] - public void Test_8813() - { - } - [TestMethod] - public void Test_8814() - { - } - [TestMethod] - public void Test_8815() - { - } - [TestMethod] - public void Test_8816() - { - } - [TestMethod] - public void Test_8817() - { - } - [TestMethod] - public void Test_8818() - { - } - [TestMethod] - public void Test_8819() - { - } - [TestMethod] - public void Test_8820() - { - } - [TestMethod] - public void Test_8821() - { - } - [TestMethod] - public void Test_8822() - { - } - [TestMethod] - public void Test_8823() - { - } - [TestMethod] - public void Test_8824() - { - } - [TestMethod] - public void Test_8825() - { - } - [TestMethod] - public void Test_8826() - { - } - [TestMethod] - public void Test_8827() - { - } - [TestMethod] - public void Test_8828() - { - } - [TestMethod] - public void Test_8829() - { - } - [TestMethod] - public void Test_8830() - { - } - [TestMethod] - public void Test_8831() - { - } - [TestMethod] - public void Test_8832() - { - } - [TestMethod] - public void Test_8833() - { - } - [TestMethod] - public void Test_8834() - { - } - [TestMethod] - public void Test_8835() - { - } - [TestMethod] - public void Test_8836() - { - } - [TestMethod] - public void Test_8837() - { - } - [TestMethod] - public void Test_8838() - { - } - [TestMethod] - public void Test_8839() - { - } - [TestMethod] - public void Test_8840() - { - } - [TestMethod] - public void Test_8841() - { - } - [TestMethod] - public void Test_8842() - { - } - [TestMethod] - public void Test_8843() - { - } - [TestMethod] - public void Test_8844() - { - } - [TestMethod] - public void Test_8845() - { - } - [TestMethod] - public void Test_8846() - { - } - [TestMethod] - public void Test_8847() - { - } - [TestMethod] - public void Test_8848() - { - } - [TestMethod] - public void Test_8849() - { - } - [TestMethod] - public void Test_8850() - { - } - [TestMethod] - public void Test_8851() - { - } - [TestMethod] - public void Test_8852() - { - } - [TestMethod] - public void Test_8853() - { - } - [TestMethod] - public void Test_8854() - { - } - [TestMethod] - public void Test_8855() - { - } - [TestMethod] - public void Test_8856() - { - } - [TestMethod] - public void Test_8857() - { - } - [TestMethod] - public void Test_8858() - { - } - [TestMethod] - public void Test_8859() - { - } - [TestMethod] - public void Test_8860() - { - } - [TestMethod] - public void Test_8861() - { - } - [TestMethod] - public void Test_8862() - { - } - [TestMethod] - public void Test_8863() - { - } - [TestMethod] - public void Test_8864() - { - } - [TestMethod] - public void Test_8865() - { - } - [TestMethod] - public void Test_8866() - { - } - [TestMethod] - public void Test_8867() - { - } - [TestMethod] - public void Test_8868() - { - } - [TestMethod] - public void Test_8869() - { - } - [TestMethod] - public void Test_8870() - { - } - [TestMethod] - public void Test_8871() - { - } - [TestMethod] - public void Test_8872() - { - } - [TestMethod] - public void Test_8873() - { - } - [TestMethod] - public void Test_8874() - { - } - [TestMethod] - public void Test_8875() - { - } - [TestMethod] - public void Test_8876() - { - } - [TestMethod] - public void Test_8877() - { - } - [TestMethod] - public void Test_8878() - { - } - [TestMethod] - public void Test_8879() - { - } - [TestMethod] - public void Test_8880() - { - } - [TestMethod] - public void Test_8881() - { - } - [TestMethod] - public void Test_8882() - { - } - [TestMethod] - public void Test_8883() - { - } - [TestMethod] - public void Test_8884() - { - } - [TestMethod] - public void Test_8885() - { - } - [TestMethod] - public void Test_8886() - { - } - [TestMethod] - public void Test_8887() - { - } - [TestMethod] - public void Test_8888() - { - } - [TestMethod] - public void Test_8889() - { - } - [TestMethod] - public void Test_8890() - { - } - [TestMethod] - public void Test_8891() - { - } - [TestMethod] - public void Test_8892() - { - } - [TestMethod] - public void Test_8893() - { - } - [TestMethod] - public void Test_8894() - { - } - [TestMethod] - public void Test_8895() - { - } - [TestMethod] - public void Test_8896() - { - } - [TestMethod] - public void Test_8897() - { - } - [TestMethod] - public void Test_8898() - { - } - [TestMethod] - public void Test_8899() - { - } - [TestMethod] - public void Test_8900() - { - } - [TestMethod] - public void Test_8901() - { - } - [TestMethod] - public void Test_8902() - { - } - [TestMethod] - public void Test_8903() - { - } - [TestMethod] - public void Test_8904() - { - } - [TestMethod] - public void Test_8905() - { - } - [TestMethod] - public void Test_8906() - { - } - [TestMethod] - public void Test_8907() - { - } - [TestMethod] - public void Test_8908() - { - } - [TestMethod] - public void Test_8909() - { - } - [TestMethod] - public void Test_8910() - { - } - [TestMethod] - public void Test_8911() - { - } - [TestMethod] - public void Test_8912() - { - } - [TestMethod] - public void Test_8913() - { - } - [TestMethod] - public void Test_8914() - { - } - [TestMethod] - public void Test_8915() - { - } - [TestMethod] - public void Test_8916() - { - } - [TestMethod] - public void Test_8917() - { - } - [TestMethod] - public void Test_8918() - { - } - [TestMethod] - public void Test_8919() - { - } - [TestMethod] - public void Test_8920() - { - } - [TestMethod] - public void Test_8921() - { - } - [TestMethod] - public void Test_8922() - { - } - [TestMethod] - public void Test_8923() - { - } - [TestMethod] - public void Test_8924() - { - } - [TestMethod] - public void Test_8925() - { - } - [TestMethod] - public void Test_8926() - { - } - [TestMethod] - public void Test_8927() - { - } - [TestMethod] - public void Test_8928() - { - } - [TestMethod] - public void Test_8929() - { - } - [TestMethod] - public void Test_8930() - { - } - [TestMethod] - public void Test_8931() - { - } - [TestMethod] - public void Test_8932() - { - } - [TestMethod] - public void Test_8933() - { - } - [TestMethod] - public void Test_8934() - { - } - [TestMethod] - public void Test_8935() - { - } - [TestMethod] - public void Test_8936() - { - } - [TestMethod] - public void Test_8937() - { - } - [TestMethod] - public void Test_8938() - { - } - [TestMethod] - public void Test_8939() - { - } - [TestMethod] - public void Test_8940() - { - } - [TestMethod] - public void Test_8941() - { - } - [TestMethod] - public void Test_8942() - { - } - [TestMethod] - public void Test_8943() - { - } - [TestMethod] - public void Test_8944() - { - } - [TestMethod] - public void Test_8945() - { - } - [TestMethod] - public void Test_8946() - { - } - [TestMethod] - public void Test_8947() - { - } - [TestMethod] - public void Test_8948() - { - } - [TestMethod] - public void Test_8949() - { - } - [TestMethod] - public void Test_8950() - { - } - [TestMethod] - public void Test_8951() - { - } - [TestMethod] - public void Test_8952() - { - } - [TestMethod] - public void Test_8953() - { - } - [TestMethod] - public void Test_8954() - { - } - [TestMethod] - public void Test_8955() - { - } - [TestMethod] - public void Test_8956() - { - } - [TestMethod] - public void Test_8957() - { - } - [TestMethod] - public void Test_8958() - { - } - [TestMethod] - public void Test_8959() - { - } - [TestMethod] - public void Test_8960() - { - } - [TestMethod] - public void Test_8961() - { - } - [TestMethod] - public void Test_8962() - { - } - [TestMethod] - public void Test_8963() - { - } - [TestMethod] - public void Test_8964() - { - } - [TestMethod] - public void Test_8965() - { - } - [TestMethod] - public void Test_8966() - { - } - [TestMethod] - public void Test_8967() - { - } - [TestMethod] - public void Test_8968() - { - } - [TestMethod] - public void Test_8969() - { - } - [TestMethod] - public void Test_8970() - { - } - [TestMethod] - public void Test_8971() - { - } - [TestMethod] - public void Test_8972() - { - } - [TestMethod] - public void Test_8973() - { - } - [TestMethod] - public void Test_8974() - { - } - [TestMethod] - public void Test_8975() - { - } - [TestMethod] - public void Test_8976() - { - } - [TestMethod] - public void Test_8977() - { - } - [TestMethod] - public void Test_8978() - { - } - [TestMethod] - public void Test_8979() - { - } - [TestMethod] - public void Test_8980() - { - } - [TestMethod] - public void Test_8981() - { - } - [TestMethod] - public void Test_8982() - { - } - [TestMethod] - public void Test_8983() - { - } - [TestMethod] - public void Test_8984() - { - } - [TestMethod] - public void Test_8985() - { - } - [TestMethod] - public void Test_8986() - { - } - [TestMethod] - public void Test_8987() - { - } - [TestMethod] - public void Test_8988() - { - } - [TestMethod] - public void Test_8989() - { - } - [TestMethod] - public void Test_8990() - { - } - [TestMethod] - public void Test_8991() - { - } - [TestMethod] - public void Test_8992() - { - } - [TestMethod] - public void Test_8993() - { - } - [TestMethod] - public void Test_8994() - { - } - [TestMethod] - public void Test_8995() - { - } - [TestMethod] - public void Test_8996() - { - } - [TestMethod] - public void Test_8997() - { - } - [TestMethod] - public void Test_8998() - { - } - [TestMethod] - public void Test_8999() - { - } - [TestMethod] - public void Test_9000() - { - } - [TestMethod] - public void Test_9001() - { - } - [TestMethod] - public void Test_9002() - { - } - [TestMethod] - public void Test_9003() - { - } - [TestMethod] - public void Test_9004() - { - } - [TestMethod] - public void Test_9005() - { - } - [TestMethod] - public void Test_9006() - { - } - [TestMethod] - public void Test_9007() - { - } - [TestMethod] - public void Test_9008() - { - } - [TestMethod] - public void Test_9009() - { - } - [TestMethod] - public void Test_9010() - { - } - [TestMethod] - public void Test_9011() - { - } - [TestMethod] - public void Test_9012() - { - } - [TestMethod] - public void Test_9013() - { - } - [TestMethod] - public void Test_9014() - { - } - [TestMethod] - public void Test_9015() - { - } - [TestMethod] - public void Test_9016() - { - } - [TestMethod] - public void Test_9017() - { - } - [TestMethod] - public void Test_9018() - { - } - [TestMethod] - public void Test_9019() - { - } - [TestMethod] - public void Test_9020() - { - } - [TestMethod] - public void Test_9021() - { - } - [TestMethod] - public void Test_9022() - { - } - [TestMethod] - public void Test_9023() - { - } - [TestMethod] - public void Test_9024() - { - } - [TestMethod] - public void Test_9025() - { - } - [TestMethod] - public void Test_9026() - { - } - [TestMethod] - public void Test_9027() - { - } - [TestMethod] - public void Test_9028() - { - } - [TestMethod] - public void Test_9029() - { - } - [TestMethod] - public void Test_9030() - { - } - [TestMethod] - public void Test_9031() - { - } - [TestMethod] - public void Test_9032() - { - } - [TestMethod] - public void Test_9033() - { - } - [TestMethod] - public void Test_9034() - { - } - [TestMethod] - public void Test_9035() - { - } - [TestMethod] - public void Test_9036() - { - } - [TestMethod] - public void Test_9037() - { - } - [TestMethod] - public void Test_9038() - { - } - [TestMethod] - public void Test_9039() - { - } - [TestMethod] - public void Test_9040() - { - } - [TestMethod] - public void Test_9041() - { - } - [TestMethod] - public void Test_9042() - { - } - [TestMethod] - public void Test_9043() - { - } - [TestMethod] - public void Test_9044() - { - } - [TestMethod] - public void Test_9045() - { - } - [TestMethod] - public void Test_9046() - { - } - [TestMethod] - public void Test_9047() - { - } - [TestMethod] - public void Test_9048() - { - } - [TestMethod] - public void Test_9049() - { - } - [TestMethod] - public void Test_9050() - { - } - [TestMethod] - public void Test_9051() - { - } - [TestMethod] - public void Test_9052() - { - } - [TestMethod] - public void Test_9053() - { - } - [TestMethod] - public void Test_9054() - { - } - [TestMethod] - public void Test_9055() - { - } - [TestMethod] - public void Test_9056() - { - } - [TestMethod] - public void Test_9057() - { - } - [TestMethod] - public void Test_9058() - { - } - [TestMethod] - public void Test_9059() - { - } - [TestMethod] - public void Test_9060() - { - } - [TestMethod] - public void Test_9061() - { - } - [TestMethod] - public void Test_9062() - { - } - [TestMethod] - public void Test_9063() - { - } - [TestMethod] - public void Test_9064() - { - } - [TestMethod] - public void Test_9065() - { - } - [TestMethod] - public void Test_9066() - { - } - [TestMethod] - public void Test_9067() - { - } - [TestMethod] - public void Test_9068() - { - } - [TestMethod] - public void Test_9069() - { - } - [TestMethod] - public void Test_9070() - { - } - [TestMethod] - public void Test_9071() - { - } - [TestMethod] - public void Test_9072() - { - } - [TestMethod] - public void Test_9073() - { - } - [TestMethod] - public void Test_9074() - { - } - [TestMethod] - public void Test_9075() - { - } - [TestMethod] - public void Test_9076() - { - } - [TestMethod] - public void Test_9077() - { - } - [TestMethod] - public void Test_9078() - { - } - [TestMethod] - public void Test_9079() - { - } - [TestMethod] - public void Test_9080() - { - } - [TestMethod] - public void Test_9081() - { - } - [TestMethod] - public void Test_9082() - { - } - [TestMethod] - public void Test_9083() - { - } - [TestMethod] - public void Test_9084() - { - } - [TestMethod] - public void Test_9085() - { - } - [TestMethod] - public void Test_9086() - { - } - [TestMethod] - public void Test_9087() - { - } - [TestMethod] - public void Test_9088() - { - } - [TestMethod] - public void Test_9089() - { - } - [TestMethod] - public void Test_9090() - { - } - [TestMethod] - public void Test_9091() - { - } - [TestMethod] - public void Test_9092() - { - } - [TestMethod] - public void Test_9093() - { - } - [TestMethod] - public void Test_9094() - { - } - [TestMethod] - public void Test_9095() - { - } - [TestMethod] - public void Test_9096() - { - } - [TestMethod] - public void Test_9097() - { - } - [TestMethod] - public void Test_9098() - { - } - [TestMethod] - public void Test_9099() - { - } - [TestMethod] - public void Test_9100() - { - } - [TestMethod] - public void Test_9101() - { - } - [TestMethod] - public void Test_9102() - { - } - [TestMethod] - public void Test_9103() - { - } - [TestMethod] - public void Test_9104() - { - } - [TestMethod] - public void Test_9105() - { - } - [TestMethod] - public void Test_9106() - { - } - [TestMethod] - public void Test_9107() - { - } - [TestMethod] - public void Test_9108() - { - } - [TestMethod] - public void Test_9109() - { - } - [TestMethod] - public void Test_9110() - { - } - [TestMethod] - public void Test_9111() - { - } - [TestMethod] - public void Test_9112() - { - } - [TestMethod] - public void Test_9113() - { - } - [TestMethod] - public void Test_9114() - { - } - [TestMethod] - public void Test_9115() - { - } - [TestMethod] - public void Test_9116() - { - } - [TestMethod] - public void Test_9117() - { - } - [TestMethod] - public void Test_9118() - { - } - [TestMethod] - public void Test_9119() - { - } - [TestMethod] - public void Test_9120() - { - } - [TestMethod] - public void Test_9121() - { - } - [TestMethod] - public void Test_9122() - { - } - [TestMethod] - public void Test_9123() - { - } - [TestMethod] - public void Test_9124() - { - } - [TestMethod] - public void Test_9125() - { - } - [TestMethod] - public void Test_9126() - { - } - [TestMethod] - public void Test_9127() - { - } - [TestMethod] - public void Test_9128() - { - } - [TestMethod] - public void Test_9129() - { - } - [TestMethod] - public void Test_9130() - { - } - [TestMethod] - public void Test_9131() - { - } - [TestMethod] - public void Test_9132() - { - } - [TestMethod] - public void Test_9133() - { - } - [TestMethod] - public void Test_9134() - { - } - [TestMethod] - public void Test_9135() - { - } - [TestMethod] - public void Test_9136() - { - } - [TestMethod] - public void Test_9137() - { - } - [TestMethod] - public void Test_9138() - { - } - [TestMethod] - public void Test_9139() - { - } - [TestMethod] - public void Test_9140() - { - } - [TestMethod] - public void Test_9141() - { - } - [TestMethod] - public void Test_9142() - { - } - [TestMethod] - public void Test_9143() - { - } - [TestMethod] - public void Test_9144() - { - } - [TestMethod] - public void Test_9145() - { - } - [TestMethod] - public void Test_9146() - { - } - [TestMethod] - public void Test_9147() - { - } - [TestMethod] - public void Test_9148() - { - } - [TestMethod] - public void Test_9149() - { - } - [TestMethod] - public void Test_9150() - { - } - [TestMethod] - public void Test_9151() - { - } - [TestMethod] - public void Test_9152() - { - } - [TestMethod] - public void Test_9153() - { - } - [TestMethod] - public void Test_9154() - { - } - [TestMethod] - public void Test_9155() - { - } - [TestMethod] - public void Test_9156() - { - } - [TestMethod] - public void Test_9157() - { - } - [TestMethod] - public void Test_9158() - { - } - [TestMethod] - public void Test_9159() - { - } - [TestMethod] - public void Test_9160() - { - } - [TestMethod] - public void Test_9161() - { - } - [TestMethod] - public void Test_9162() - { - } - [TestMethod] - public void Test_9163() - { - } - [TestMethod] - public void Test_9164() - { - } - [TestMethod] - public void Test_9165() - { - } - [TestMethod] - public void Test_9166() - { - } - [TestMethod] - public void Test_9167() - { - } - [TestMethod] - public void Test_9168() - { - } - [TestMethod] - public void Test_9169() - { - } - [TestMethod] - public void Test_9170() - { - } - [TestMethod] - public void Test_9171() - { - } - [TestMethod] - public void Test_9172() - { - } - [TestMethod] - public void Test_9173() - { - } - [TestMethod] - public void Test_9174() - { - } - [TestMethod] - public void Test_9175() - { - } - [TestMethod] - public void Test_9176() - { - } - [TestMethod] - public void Test_9177() - { - } - [TestMethod] - public void Test_9178() - { - } - [TestMethod] - public void Test_9179() - { - } - [TestMethod] - public void Test_9180() - { - } - [TestMethod] - public void Test_9181() - { - } - [TestMethod] - public void Test_9182() - { - } - [TestMethod] - public void Test_9183() - { - } - [TestMethod] - public void Test_9184() - { - } - [TestMethod] - public void Test_9185() - { - } - [TestMethod] - public void Test_9186() - { - } - [TestMethod] - public void Test_9187() - { - } - [TestMethod] - public void Test_9188() - { - } - [TestMethod] - public void Test_9189() - { - } - [TestMethod] - public void Test_9190() - { - } - [TestMethod] - public void Test_9191() - { - } - [TestMethod] - public void Test_9192() - { - } - [TestMethod] - public void Test_9193() - { - } - [TestMethod] - public void Test_9194() - { - } - [TestMethod] - public void Test_9195() - { - } - [TestMethod] - public void Test_9196() - { - } - [TestMethod] - public void Test_9197() - { - } - [TestMethod] - public void Test_9198() - { - } - [TestMethod] - public void Test_9199() - { - } - [TestMethod] - public void Test_9200() - { - } - [TestMethod] - public void Test_9201() - { - } - [TestMethod] - public void Test_9202() - { - } - [TestMethod] - public void Test_9203() - { - } - [TestMethod] - public void Test_9204() - { - } - [TestMethod] - public void Test_9205() - { - } - [TestMethod] - public void Test_9206() - { - } - [TestMethod] - public void Test_9207() - { - } - [TestMethod] - public void Test_9208() - { - } - [TestMethod] - public void Test_9209() - { - } - [TestMethod] - public void Test_9210() - { - } - [TestMethod] - public void Test_9211() - { - } - [TestMethod] - public void Test_9212() - { - } - [TestMethod] - public void Test_9213() - { - } - [TestMethod] - public void Test_9214() - { - } - [TestMethod] - public void Test_9215() - { - } - [TestMethod] - public void Test_9216() - { - } - [TestMethod] - public void Test_9217() - { - } - [TestMethod] - public void Test_9218() - { - } - [TestMethod] - public void Test_9219() - { - } - [TestMethod] - public void Test_9220() - { - } - [TestMethod] - public void Test_9221() - { - } - [TestMethod] - public void Test_9222() - { - } - [TestMethod] - public void Test_9223() - { - } - [TestMethod] - public void Test_9224() - { - } - [TestMethod] - public void Test_9225() - { - } - [TestMethod] - public void Test_9226() - { - } - [TestMethod] - public void Test_9227() - { - } - [TestMethod] - public void Test_9228() - { - } - [TestMethod] - public void Test_9229() - { - } - [TestMethod] - public void Test_9230() - { - } - [TestMethod] - public void Test_9231() - { - } - [TestMethod] - public void Test_9232() - { - } - [TestMethod] - public void Test_9233() - { - } - [TestMethod] - public void Test_9234() - { - } - [TestMethod] - public void Test_9235() - { - } - [TestMethod] - public void Test_9236() - { - } - [TestMethod] - public void Test_9237() - { - } - [TestMethod] - public void Test_9238() - { - } - [TestMethod] - public void Test_9239() - { - } - [TestMethod] - public void Test_9240() - { - } - [TestMethod] - public void Test_9241() - { - } - [TestMethod] - public void Test_9242() - { - } - [TestMethod] - public void Test_9243() - { - } - [TestMethod] - public void Test_9244() - { - } - [TestMethod] - public void Test_9245() - { - } - [TestMethod] - public void Test_9246() - { - } - [TestMethod] - public void Test_9247() - { - } - [TestMethod] - public void Test_9248() - { - } - [TestMethod] - public void Test_9249() - { - } - [TestMethod] - public void Test_9250() - { - } - [TestMethod] - public void Test_9251() - { - } - [TestMethod] - public void Test_9252() - { - } - [TestMethod] - public void Test_9253() - { - } - [TestMethod] - public void Test_9254() - { - } - [TestMethod] - public void Test_9255() - { - } - [TestMethod] - public void Test_9256() - { - } - [TestMethod] - public void Test_9257() - { - } - [TestMethod] - public void Test_9258() - { - } - [TestMethod] - public void Test_9259() - { - } - [TestMethod] - public void Test_9260() - { - } - [TestMethod] - public void Test_9261() - { - } - [TestMethod] - public void Test_9262() - { - } - [TestMethod] - public void Test_9263() - { - } - [TestMethod] - public void Test_9264() - { - } - [TestMethod] - public void Test_9265() - { - } - [TestMethod] - public void Test_9266() - { - } - [TestMethod] - public void Test_9267() - { - } - [TestMethod] - public void Test_9268() - { - } - [TestMethod] - public void Test_9269() - { - } - [TestMethod] - public void Test_9270() - { - } - [TestMethod] - public void Test_9271() - { - } - [TestMethod] - public void Test_9272() - { - } - [TestMethod] - public void Test_9273() - { - } - [TestMethod] - public void Test_9274() - { - } - [TestMethod] - public void Test_9275() - { - } - [TestMethod] - public void Test_9276() - { - } - [TestMethod] - public void Test_9277() - { - } - [TestMethod] - public void Test_9278() - { - } - [TestMethod] - public void Test_9279() - { - } - [TestMethod] - public void Test_9280() - { - } - [TestMethod] - public void Test_9281() - { - } - [TestMethod] - public void Test_9282() - { - } - [TestMethod] - public void Test_9283() - { - } - [TestMethod] - public void Test_9284() - { - } - [TestMethod] - public void Test_9285() - { - } - [TestMethod] - public void Test_9286() - { - } - [TestMethod] - public void Test_9287() - { - } - [TestMethod] - public void Test_9288() - { - } - [TestMethod] - public void Test_9289() - { - } - [TestMethod] - public void Test_9290() - { - } - [TestMethod] - public void Test_9291() - { - } - [TestMethod] - public void Test_9292() - { - } - [TestMethod] - public void Test_9293() - { - } - [TestMethod] - public void Test_9294() - { - } - [TestMethod] - public void Test_9295() - { - } - [TestMethod] - public void Test_9296() - { - } - [TestMethod] - public void Test_9297() - { - } - [TestMethod] - public void Test_9298() - { - } - [TestMethod] - public void Test_9299() - { - } - [TestMethod] - public void Test_9300() - { - } - [TestMethod] - public void Test_9301() - { - } - [TestMethod] - public void Test_9302() - { - } - [TestMethod] - public void Test_9303() - { - } - [TestMethod] - public void Test_9304() - { - } - [TestMethod] - public void Test_9305() - { - } - [TestMethod] - public void Test_9306() - { - } - [TestMethod] - public void Test_9307() - { - } - [TestMethod] - public void Test_9308() - { - } - [TestMethod] - public void Test_9309() - { - } - [TestMethod] - public void Test_9310() - { - } - [TestMethod] - public void Test_9311() - { - } - [TestMethod] - public void Test_9312() - { - } - [TestMethod] - public void Test_9313() - { - } - [TestMethod] - public void Test_9314() - { - } - [TestMethod] - public void Test_9315() - { - } - [TestMethod] - public void Test_9316() - { - } - [TestMethod] - public void Test_9317() - { - } - [TestMethod] - public void Test_9318() - { - } - [TestMethod] - public void Test_9319() - { - } - [TestMethod] - public void Test_9320() - { - } - [TestMethod] - public void Test_9321() - { - } - [TestMethod] - public void Test_9322() - { - } - [TestMethod] - public void Test_9323() - { - } - [TestMethod] - public void Test_9324() - { - } - [TestMethod] - public void Test_9325() - { - } - [TestMethod] - public void Test_9326() - { - } - [TestMethod] - public void Test_9327() - { - } - [TestMethod] - public void Test_9328() - { - } - [TestMethod] - public void Test_9329() - { - } - [TestMethod] - public void Test_9330() - { - } - [TestMethod] - public void Test_9331() - { - } - [TestMethod] - public void Test_9332() - { - } - [TestMethod] - public void Test_9333() - { - } - [TestMethod] - public void Test_9334() - { - } - [TestMethod] - public void Test_9335() - { - } - [TestMethod] - public void Test_9336() - { - } - [TestMethod] - public void Test_9337() - { - } - [TestMethod] - public void Test_9338() - { - } - [TestMethod] - public void Test_9339() - { - } - [TestMethod] - public void Test_9340() - { - } - [TestMethod] - public void Test_9341() - { - } - [TestMethod] - public void Test_9342() - { - } - [TestMethod] - public void Test_9343() - { - } - [TestMethod] - public void Test_9344() - { - } - [TestMethod] - public void Test_9345() - { - } - [TestMethod] - public void Test_9346() - { - } - [TestMethod] - public void Test_9347() - { - } - [TestMethod] - public void Test_9348() - { - } - [TestMethod] - public void Test_9349() - { - } - [TestMethod] - public void Test_9350() - { - } - [TestMethod] - public void Test_9351() - { - } - [TestMethod] - public void Test_9352() - { - } - [TestMethod] - public void Test_9353() - { - } - [TestMethod] - public void Test_9354() - { - } - [TestMethod] - public void Test_9355() - { - } - [TestMethod] - public void Test_9356() - { - } - [TestMethod] - public void Test_9357() - { - } - [TestMethod] - public void Test_9358() - { - } - [TestMethod] - public void Test_9359() - { - } - [TestMethod] - public void Test_9360() - { - } - [TestMethod] - public void Test_9361() - { - } - [TestMethod] - public void Test_9362() - { - } - [TestMethod] - public void Test_9363() - { - } - [TestMethod] - public void Test_9364() - { - } - [TestMethod] - public void Test_9365() - { - } - [TestMethod] - public void Test_9366() - { - } - [TestMethod] - public void Test_9367() - { - } - [TestMethod] - public void Test_9368() - { - } - [TestMethod] - public void Test_9369() - { - } - [TestMethod] - public void Test_9370() - { - } - [TestMethod] - public void Test_9371() - { - } - [TestMethod] - public void Test_9372() - { - } - [TestMethod] - public void Test_9373() - { - } - [TestMethod] - public void Test_9374() - { - } - [TestMethod] - public void Test_9375() - { - } - [TestMethod] - public void Test_9376() - { - } - [TestMethod] - public void Test_9377() - { - } - [TestMethod] - public void Test_9378() - { - } - [TestMethod] - public void Test_9379() - { - } - [TestMethod] - public void Test_9380() - { - } - [TestMethod] - public void Test_9381() - { - } - [TestMethod] - public void Test_9382() - { - } - [TestMethod] - public void Test_9383() - { - } - [TestMethod] - public void Test_9384() - { - } - [TestMethod] - public void Test_9385() - { - } - [TestMethod] - public void Test_9386() - { - } - [TestMethod] - public void Test_9387() - { - } - [TestMethod] - public void Test_9388() - { - } - [TestMethod] - public void Test_9389() - { - } - [TestMethod] - public void Test_9390() - { - } - [TestMethod] - public void Test_9391() - { - } - [TestMethod] - public void Test_9392() - { - } - [TestMethod] - public void Test_9393() - { - } - [TestMethod] - public void Test_9394() - { - } - [TestMethod] - public void Test_9395() - { - } - [TestMethod] - public void Test_9396() - { - } - [TestMethod] - public void Test_9397() - { - } - [TestMethod] - public void Test_9398() - { - } - [TestMethod] - public void Test_9399() - { - } - [TestMethod] - public void Test_9400() - { - } - [TestMethod] - public void Test_9401() - { - } - [TestMethod] - public void Test_9402() - { - } - [TestMethod] - public void Test_9403() - { - } - [TestMethod] - public void Test_9404() - { - } - [TestMethod] - public void Test_9405() - { - } - [TestMethod] - public void Test_9406() - { - } - [TestMethod] - public void Test_9407() - { - } - [TestMethod] - public void Test_9408() - { - } - [TestMethod] - public void Test_9409() - { - } - [TestMethod] - public void Test_9410() - { - } - [TestMethod] - public void Test_9411() - { - } - [TestMethod] - public void Test_9412() - { - } - [TestMethod] - public void Test_9413() - { - } - [TestMethod] - public void Test_9414() - { - } - [TestMethod] - public void Test_9415() - { - } - [TestMethod] - public void Test_9416() - { - } - [TestMethod] - public void Test_9417() - { - } - [TestMethod] - public void Test_9418() - { - } - [TestMethod] - public void Test_9419() - { - } - [TestMethod] - public void Test_9420() - { - } - [TestMethod] - public void Test_9421() - { - } - [TestMethod] - public void Test_9422() - { - } - [TestMethod] - public void Test_9423() - { - } - [TestMethod] - public void Test_9424() - { - } - [TestMethod] - public void Test_9425() - { - } - [TestMethod] - public void Test_9426() - { - } - [TestMethod] - public void Test_9427() - { - } - [TestMethod] - public void Test_9428() - { - } - [TestMethod] - public void Test_9429() - { - } - [TestMethod] - public void Test_9430() - { - } - [TestMethod] - public void Test_9431() - { - } - [TestMethod] - public void Test_9432() - { - } - [TestMethod] - public void Test_9433() - { - } - [TestMethod] - public void Test_9434() - { - } - [TestMethod] - public void Test_9435() - { - } - [TestMethod] - public void Test_9436() - { - } - [TestMethod] - public void Test_9437() - { - } - [TestMethod] - public void Test_9438() - { - } - [TestMethod] - public void Test_9439() - { - } - [TestMethod] - public void Test_9440() - { - } - [TestMethod] - public void Test_9441() - { - } - [TestMethod] - public void Test_9442() - { - } - [TestMethod] - public void Test_9443() - { - } - [TestMethod] - public void Test_9444() - { - } - [TestMethod] - public void Test_9445() - { - } - [TestMethod] - public void Test_9446() - { - } - [TestMethod] - public void Test_9447() - { - } - [TestMethod] - public void Test_9448() - { - } - [TestMethod] - public void Test_9449() - { - } - [TestMethod] - public void Test_9450() - { - } - [TestMethod] - public void Test_9451() - { - } - [TestMethod] - public void Test_9452() - { - } - [TestMethod] - public void Test_9453() - { - } - [TestMethod] - public void Test_9454() - { - } - [TestMethod] - public void Test_9455() - { - } - [TestMethod] - public void Test_9456() - { - } - [TestMethod] - public void Test_9457() - { - } - [TestMethod] - public void Test_9458() - { - } - [TestMethod] - public void Test_9459() - { - } - [TestMethod] - public void Test_9460() - { - } - [TestMethod] - public void Test_9461() - { - } - [TestMethod] - public void Test_9462() - { - } - [TestMethod] - public void Test_9463() - { - } - [TestMethod] - public void Test_9464() - { - } - [TestMethod] - public void Test_9465() - { - } - [TestMethod] - public void Test_9466() - { - } - [TestMethod] - public void Test_9467() - { - } - [TestMethod] - public void Test_9468() - { - } - [TestMethod] - public void Test_9469() - { - } - [TestMethod] - public void Test_9470() - { - } - [TestMethod] - public void Test_9471() - { - } - [TestMethod] - public void Test_9472() - { - } - [TestMethod] - public void Test_9473() - { - } - [TestMethod] - public void Test_9474() - { - } - [TestMethod] - public void Test_9475() - { - } - [TestMethod] - public void Test_9476() - { - } - [TestMethod] - public void Test_9477() - { - } - [TestMethod] - public void Test_9478() - { - } - [TestMethod] - public void Test_9479() - { - } - [TestMethod] - public void Test_9480() - { - } - [TestMethod] - public void Test_9481() - { - } - [TestMethod] - public void Test_9482() - { - } - [TestMethod] - public void Test_9483() - { - } - [TestMethod] - public void Test_9484() - { - } - [TestMethod] - public void Test_9485() - { - } - [TestMethod] - public void Test_9486() - { - } - [TestMethod] - public void Test_9487() - { - } - [TestMethod] - public void Test_9488() - { - } - [TestMethod] - public void Test_9489() - { - } - [TestMethod] - public void Test_9490() - { - } - [TestMethod] - public void Test_9491() - { - } - [TestMethod] - public void Test_9492() - { - } - [TestMethod] - public void Test_9493() - { - } - [TestMethod] - public void Test_9494() - { - } - [TestMethod] - public void Test_9495() - { - } - [TestMethod] - public void Test_9496() - { - } - [TestMethod] - public void Test_9497() - { - } - [TestMethod] - public void Test_9498() - { - } - [TestMethod] - public void Test_9499() - { - } - [TestMethod] - public void Test_9500() - { - } - [TestMethod] - public void Test_9501() - { - } - [TestMethod] - public void Test_9502() - { - } - [TestMethod] - public void Test_9503() - { - } - [TestMethod] - public void Test_9504() - { - } - [TestMethod] - public void Test_9505() - { - } - [TestMethod] - public void Test_9506() - { - } - [TestMethod] - public void Test_9507() - { - } - [TestMethod] - public void Test_9508() - { - } - [TestMethod] - public void Test_9509() - { - } - [TestMethod] - public void Test_9510() - { - } - [TestMethod] - public void Test_9511() - { - } - [TestMethod] - public void Test_9512() - { - } - [TestMethod] - public void Test_9513() - { - } - [TestMethod] - public void Test_9514() - { - } - [TestMethod] - public void Test_9515() - { - } - [TestMethod] - public void Test_9516() - { - } - [TestMethod] - public void Test_9517() - { - } - [TestMethod] - public void Test_9518() - { - } - [TestMethod] - public void Test_9519() - { - } - [TestMethod] - public void Test_9520() - { - } - [TestMethod] - public void Test_9521() - { - } - [TestMethod] - public void Test_9522() - { - } - [TestMethod] - public void Test_9523() - { - } - [TestMethod] - public void Test_9524() - { - } - [TestMethod] - public void Test_9525() - { - } - [TestMethod] - public void Test_9526() - { - } - [TestMethod] - public void Test_9527() - { - } - [TestMethod] - public void Test_9528() - { - } - [TestMethod] - public void Test_9529() - { - } - [TestMethod] - public void Test_9530() - { - } - [TestMethod] - public void Test_9531() - { - } - [TestMethod] - public void Test_9532() - { - } - [TestMethod] - public void Test_9533() - { - } - [TestMethod] - public void Test_9534() - { - } - [TestMethod] - public void Test_9535() - { - } - [TestMethod] - public void Test_9536() - { - } - [TestMethod] - public void Test_9537() - { - } - [TestMethod] - public void Test_9538() - { - } - [TestMethod] - public void Test_9539() - { - } - [TestMethod] - public void Test_9540() - { - } - [TestMethod] - public void Test_9541() - { - } - [TestMethod] - public void Test_9542() - { - } - [TestMethod] - public void Test_9543() - { - } - [TestMethod] - public void Test_9544() - { - } - [TestMethod] - public void Test_9545() - { - } - [TestMethod] - public void Test_9546() - { - } - [TestMethod] - public void Test_9547() - { - } - [TestMethod] - public void Test_9548() - { - } - [TestMethod] - public void Test_9549() - { - } - [TestMethod] - public void Test_9550() - { - } - [TestMethod] - public void Test_9551() - { - } - [TestMethod] - public void Test_9552() - { - } - [TestMethod] - public void Test_9553() - { - } - [TestMethod] - public void Test_9554() - { - } - [TestMethod] - public void Test_9555() - { - } - [TestMethod] - public void Test_9556() - { - } - [TestMethod] - public void Test_9557() - { - } - [TestMethod] - public void Test_9558() - { - } - [TestMethod] - public void Test_9559() - { - } - [TestMethod] - public void Test_9560() - { - } - [TestMethod] - public void Test_9561() - { - } - [TestMethod] - public void Test_9562() - { - } - [TestMethod] - public void Test_9563() - { - } - [TestMethod] - public void Test_9564() - { - } - [TestMethod] - public void Test_9565() - { - } - [TestMethod] - public void Test_9566() - { - } - [TestMethod] - public void Test_9567() - { - } - [TestMethod] - public void Test_9568() - { - } - [TestMethod] - public void Test_9569() - { - } - [TestMethod] - public void Test_9570() - { - } - [TestMethod] - public void Test_9571() - { - } - [TestMethod] - public void Test_9572() - { - } - [TestMethod] - public void Test_9573() - { - } - [TestMethod] - public void Test_9574() - { - } - [TestMethod] - public void Test_9575() - { - } - [TestMethod] - public void Test_9576() - { - } - [TestMethod] - public void Test_9577() - { - } - [TestMethod] - public void Test_9578() - { - } - [TestMethod] - public void Test_9579() - { - } - [TestMethod] - public void Test_9580() - { - } - [TestMethod] - public void Test_9581() - { - } - [TestMethod] - public void Test_9582() - { - } - [TestMethod] - public void Test_9583() - { - } - [TestMethod] - public void Test_9584() - { - } - [TestMethod] - public void Test_9585() - { - } - [TestMethod] - public void Test_9586() - { - } - [TestMethod] - public void Test_9587() - { - } - [TestMethod] - public void Test_9588() - { - } - [TestMethod] - public void Test_9589() - { - } - [TestMethod] - public void Test_9590() - { - } - [TestMethod] - public void Test_9591() - { - } - [TestMethod] - public void Test_9592() - { - } - [TestMethod] - public void Test_9593() - { - } - [TestMethod] - public void Test_9594() - { - } - [TestMethod] - public void Test_9595() - { - } - [TestMethod] - public void Test_9596() - { - } - [TestMethod] - public void Test_9597() - { - } - [TestMethod] - public void Test_9598() - { - } - [TestMethod] - public void Test_9599() - { - } - [TestMethod] - public void Test_9600() - { - } - [TestMethod] - public void Test_9601() - { - } - [TestMethod] - public void Test_9602() - { - } - [TestMethod] - public void Test_9603() - { - } - [TestMethod] - public void Test_9604() - { - } - [TestMethod] - public void Test_9605() - { - } - [TestMethod] - public void Test_9606() - { - } - [TestMethod] - public void Test_9607() - { - } - [TestMethod] - public void Test_9608() - { - } - [TestMethod] - public void Test_9609() - { - } - [TestMethod] - public void Test_9610() - { - } - [TestMethod] - public void Test_9611() - { - } - [TestMethod] - public void Test_9612() - { - } - [TestMethod] - public void Test_9613() - { - } - [TestMethod] - public void Test_9614() - { - } - [TestMethod] - public void Test_9615() - { - } - [TestMethod] - public void Test_9616() - { - } - [TestMethod] - public void Test_9617() - { - } - [TestMethod] - public void Test_9618() - { - } - [TestMethod] - public void Test_9619() - { - } - [TestMethod] - public void Test_9620() - { - } - [TestMethod] - public void Test_9621() - { - } - [TestMethod] - public void Test_9622() - { - } - [TestMethod] - public void Test_9623() - { - } - [TestMethod] - public void Test_9624() - { - } - [TestMethod] - public void Test_9625() - { - } - [TestMethod] - public void Test_9626() - { - } - [TestMethod] - public void Test_9627() - { - } - [TestMethod] - public void Test_9628() - { - } - [TestMethod] - public void Test_9629() - { - } - [TestMethod] - public void Test_9630() - { - } - [TestMethod] - public void Test_9631() - { - } - [TestMethod] - public void Test_9632() - { - } - [TestMethod] - public void Test_9633() - { - } - [TestMethod] - public void Test_9634() - { - } - [TestMethod] - public void Test_9635() - { - } - [TestMethod] - public void Test_9636() - { - } - [TestMethod] - public void Test_9637() - { - } - [TestMethod] - public void Test_9638() - { - } - [TestMethod] - public void Test_9639() - { - } - [TestMethod] - public void Test_9640() - { - } - [TestMethod] - public void Test_9641() - { - } - [TestMethod] - public void Test_9642() - { - } - [TestMethod] - public void Test_9643() - { - } - [TestMethod] - public void Test_9644() - { - } - [TestMethod] - public void Test_9645() - { - } - [TestMethod] - public void Test_9646() - { - } - [TestMethod] - public void Test_9647() - { - } - [TestMethod] - public void Test_9648() - { - } - [TestMethod] - public void Test_9649() - { - } - [TestMethod] - public void Test_9650() - { - } - [TestMethod] - public void Test_9651() - { - } - [TestMethod] - public void Test_9652() - { - } - [TestMethod] - public void Test_9653() - { - } - [TestMethod] - public void Test_9654() - { - } - [TestMethod] - public void Test_9655() - { - } - [TestMethod] - public void Test_9656() - { - } - [TestMethod] - public void Test_9657() - { - } - [TestMethod] - public void Test_9658() - { - } - [TestMethod] - public void Test_9659() - { - } - [TestMethod] - public void Test_9660() - { - } - [TestMethod] - public void Test_9661() - { - } - [TestMethod] - public void Test_9662() - { - } - [TestMethod] - public void Test_9663() - { - } - [TestMethod] - public void Test_9664() - { - } - [TestMethod] - public void Test_9665() - { - } - [TestMethod] - public void Test_9666() - { - } - [TestMethod] - public void Test_9667() - { - } - [TestMethod] - public void Test_9668() - { - } - [TestMethod] - public void Test_9669() - { - } - [TestMethod] - public void Test_9670() - { - } - [TestMethod] - public void Test_9671() - { - } - [TestMethod] - public void Test_9672() - { - } - [TestMethod] - public void Test_9673() - { - } - [TestMethod] - public void Test_9674() - { - } - [TestMethod] - public void Test_9675() - { - } - [TestMethod] - public void Test_9676() - { - } - [TestMethod] - public void Test_9677() - { - } - [TestMethod] - public void Test_9678() - { - } - [TestMethod] - public void Test_9679() - { - } - [TestMethod] - public void Test_9680() - { - } - [TestMethod] - public void Test_9681() - { - } - [TestMethod] - public void Test_9682() - { - } - [TestMethod] - public void Test_9683() - { - } - [TestMethod] - public void Test_9684() - { - } - [TestMethod] - public void Test_9685() - { - } - [TestMethod] - public void Test_9686() - { - } - [TestMethod] - public void Test_9687() - { - } - [TestMethod] - public void Test_9688() - { - } - [TestMethod] - public void Test_9689() - { - } - [TestMethod] - public void Test_9690() - { - } - [TestMethod] - public void Test_9691() - { - } - [TestMethod] - public void Test_9692() - { - } - [TestMethod] - public void Test_9693() - { - } - [TestMethod] - public void Test_9694() - { - } - [TestMethod] - public void Test_9695() - { - } - [TestMethod] - public void Test_9696() - { - } - [TestMethod] - public void Test_9697() - { - } - [TestMethod] - public void Test_9698() - { - } - [TestMethod] - public void Test_9699() - { - } - [TestMethod] - public void Test_9700() - { - } - [TestMethod] - public void Test_9701() - { - } - [TestMethod] - public void Test_9702() - { - } - [TestMethod] - public void Test_9703() - { - } - [TestMethod] - public void Test_9704() - { - } - [TestMethod] - public void Test_9705() - { - } - [TestMethod] - public void Test_9706() - { - } - [TestMethod] - public void Test_9707() - { - } - [TestMethod] - public void Test_9708() - { - } - [TestMethod] - public void Test_9709() - { - } - [TestMethod] - public void Test_9710() - { - } - [TestMethod] - public void Test_9711() - { - } - [TestMethod] - public void Test_9712() - { - } - [TestMethod] - public void Test_9713() - { - } - [TestMethod] - public void Test_9714() - { - } - [TestMethod] - public void Test_9715() - { - } - [TestMethod] - public void Test_9716() - { - } - [TestMethod] - public void Test_9717() - { - } - [TestMethod] - public void Test_9718() - { - } - [TestMethod] - public void Test_9719() - { - } - [TestMethod] - public void Test_9720() - { - } - [TestMethod] - public void Test_9721() - { - } - [TestMethod] - public void Test_9722() - { - } - [TestMethod] - public void Test_9723() - { - } - [TestMethod] - public void Test_9724() - { - } - [TestMethod] - public void Test_9725() - { - } - [TestMethod] - public void Test_9726() - { - } - [TestMethod] - public void Test_9727() - { - } - [TestMethod] - public void Test_9728() - { - } - [TestMethod] - public void Test_9729() - { - } - [TestMethod] - public void Test_9730() - { - } - [TestMethod] - public void Test_9731() - { - } - [TestMethod] - public void Test_9732() - { - } - [TestMethod] - public void Test_9733() - { - } - [TestMethod] - public void Test_9734() - { - } - [TestMethod] - public void Test_9735() - { - } - [TestMethod] - public void Test_9736() - { - } - [TestMethod] - public void Test_9737() - { - } - [TestMethod] - public void Test_9738() - { - } - [TestMethod] - public void Test_9739() - { - } - [TestMethod] - public void Test_9740() - { - } - [TestMethod] - public void Test_9741() - { - } - [TestMethod] - public void Test_9742() - { - } - [TestMethod] - public void Test_9743() - { - } - [TestMethod] - public void Test_9744() - { - } - [TestMethod] - public void Test_9745() - { - } - [TestMethod] - public void Test_9746() - { - } - [TestMethod] - public void Test_9747() - { - } - [TestMethod] - public void Test_9748() - { - } - [TestMethod] - public void Test_9749() - { - } - [TestMethod] - public void Test_9750() - { - } - [TestMethod] - public void Test_9751() - { - } - [TestMethod] - public void Test_9752() - { - } - [TestMethod] - public void Test_9753() - { - } - [TestMethod] - public void Test_9754() - { - } - [TestMethod] - public void Test_9755() - { - } - [TestMethod] - public void Test_9756() - { - } - [TestMethod] - public void Test_9757() - { - } - [TestMethod] - public void Test_9758() - { - } - [TestMethod] - public void Test_9759() - { - } - [TestMethod] - public void Test_9760() - { - } - [TestMethod] - public void Test_9761() - { - } - [TestMethod] - public void Test_9762() - { - } - [TestMethod] - public void Test_9763() - { - } - [TestMethod] - public void Test_9764() - { - } - [TestMethod] - public void Test_9765() - { - } - [TestMethod] - public void Test_9766() - { - } - [TestMethod] - public void Test_9767() - { - } - [TestMethod] - public void Test_9768() - { - } - [TestMethod] - public void Test_9769() - { - } - [TestMethod] - public void Test_9770() - { - } - [TestMethod] - public void Test_9771() - { - } - [TestMethod] - public void Test_9772() - { - } - [TestMethod] - public void Test_9773() - { - } - [TestMethod] - public void Test_9774() - { - } - [TestMethod] - public void Test_9775() - { - } - [TestMethod] - public void Test_9776() - { - } - [TestMethod] - public void Test_9777() - { - } - [TestMethod] - public void Test_9778() - { - } - [TestMethod] - public void Test_9779() - { - } - [TestMethod] - public void Test_9780() - { - } - [TestMethod] - public void Test_9781() - { - } - [TestMethod] - public void Test_9782() - { - } - [TestMethod] - public void Test_9783() - { - } - [TestMethod] - public void Test_9784() - { - } - [TestMethod] - public void Test_9785() - { - } - [TestMethod] - public void Test_9786() - { - } - [TestMethod] - public void Test_9787() - { - } - [TestMethod] - public void Test_9788() - { - } - [TestMethod] - public void Test_9789() - { - } - [TestMethod] - public void Test_9790() - { - } - [TestMethod] - public void Test_9791() - { - } - [TestMethod] - public void Test_9792() - { - } - [TestMethod] - public void Test_9793() - { - } - [TestMethod] - public void Test_9794() - { - } - [TestMethod] - public void Test_9795() - { - } - [TestMethod] - public void Test_9796() - { - } - [TestMethod] - public void Test_9797() - { - } - [TestMethod] - public void Test_9798() - { - } - [TestMethod] - public void Test_9799() - { - } - [TestMethod] - public void Test_9800() - { - } - [TestMethod] - public void Test_9801() - { - } - [TestMethod] - public void Test_9802() - { - } - [TestMethod] - public void Test_9803() - { - } - [TestMethod] - public void Test_9804() - { - } - [TestMethod] - public void Test_9805() - { - } - [TestMethod] - public void Test_9806() - { - } - [TestMethod] - public void Test_9807() - { - } - [TestMethod] - public void Test_9808() - { - } - [TestMethod] - public void Test_9809() - { - } - [TestMethod] - public void Test_9810() - { - } - [TestMethod] - public void Test_9811() - { - } - [TestMethod] - public void Test_9812() - { - } - [TestMethod] - public void Test_9813() - { - } - [TestMethod] - public void Test_9814() - { - } - [TestMethod] - public void Test_9815() - { - } - [TestMethod] - public void Test_9816() - { - } - [TestMethod] - public void Test_9817() - { - } - [TestMethod] - public void Test_9818() - { - } - [TestMethod] - public void Test_9819() - { - } - [TestMethod] - public void Test_9820() - { - } - [TestMethod] - public void Test_9821() - { - } - [TestMethod] - public void Test_9822() - { - } - [TestMethod] - public void Test_9823() - { - } - [TestMethod] - public void Test_9824() - { - } - [TestMethod] - public void Test_9825() - { - } - [TestMethod] - public void Test_9826() - { - } - [TestMethod] - public void Test_9827() - { - } - [TestMethod] - public void Test_9828() - { - } - [TestMethod] - public void Test_9829() - { - } - [TestMethod] - public void Test_9830() - { - } - [TestMethod] - public void Test_9831() - { - } - [TestMethod] - public void Test_9832() - { - } - [TestMethod] - public void Test_9833() - { - } - [TestMethod] - public void Test_9834() - { - } - [TestMethod] - public void Test_9835() - { - } - [TestMethod] - public void Test_9836() - { - } - [TestMethod] - public void Test_9837() - { - } - [TestMethod] - public void Test_9838() - { - } - [TestMethod] - public void Test_9839() - { - } - [TestMethod] - public void Test_9840() - { - } - [TestMethod] - public void Test_9841() - { - } - [TestMethod] - public void Test_9842() - { - } - [TestMethod] - public void Test_9843() - { - } - [TestMethod] - public void Test_9844() - { - } - [TestMethod] - public void Test_9845() - { - } - [TestMethod] - public void Test_9846() - { - } - [TestMethod] - public void Test_9847() - { - } - [TestMethod] - public void Test_9848() - { - } - [TestMethod] - public void Test_9849() - { - } - [TestMethod] - public void Test_9850() - { - } - [TestMethod] - public void Test_9851() - { - } - [TestMethod] - public void Test_9852() - { - } - [TestMethod] - public void Test_9853() - { - } - [TestMethod] - public void Test_9854() - { - } - [TestMethod] - public void Test_9855() - { - } - [TestMethod] - public void Test_9856() - { - } - [TestMethod] - public void Test_9857() - { - } - [TestMethod] - public void Test_9858() - { - } - [TestMethod] - public void Test_9859() - { - } - [TestMethod] - public void Test_9860() - { - } - [TestMethod] - public void Test_9861() - { - } - [TestMethod] - public void Test_9862() - { - } - [TestMethod] - public void Test_9863() - { - } - [TestMethod] - public void Test_9864() - { - } - [TestMethod] - public void Test_9865() - { - } - [TestMethod] - public void Test_9866() - { - } - [TestMethod] - public void Test_9867() - { - } - [TestMethod] - public void Test_9868() - { - } - [TestMethod] - public void Test_9869() - { - } - [TestMethod] - public void Test_9870() - { - } - [TestMethod] - public void Test_9871() - { - } - [TestMethod] - public void Test_9872() - { - } - [TestMethod] - public void Test_9873() - { - } - [TestMethod] - public void Test_9874() - { - } - [TestMethod] - public void Test_9875() - { - } - [TestMethod] - public void Test_9876() - { - } - [TestMethod] - public void Test_9877() - { - } - [TestMethod] - public void Test_9878() - { - } - [TestMethod] - public void Test_9879() - { - } - [TestMethod] - public void Test_9880() - { - } - [TestMethod] - public void Test_9881() - { - } - [TestMethod] - public void Test_9882() - { - } - [TestMethod] - public void Test_9883() - { - } - [TestMethod] - public void Test_9884() - { - } - [TestMethod] - public void Test_9885() - { - } - [TestMethod] - public void Test_9886() - { - } - [TestMethod] - public void Test_9887() - { - } - [TestMethod] - public void Test_9888() - { - } - [TestMethod] - public void Test_9889() - { - } - [TestMethod] - public void Test_9890() - { - } - [TestMethod] - public void Test_9891() - { - } - [TestMethod] - public void Test_9892() - { - } - [TestMethod] - public void Test_9893() - { - } - [TestMethod] - public void Test_9894() - { - } - [TestMethod] - public void Test_9895() - { - } - [TestMethod] - public void Test_9896() - { - } - [TestMethod] - public void Test_9897() - { - } - [TestMethod] - public void Test_9898() - { - } - [TestMethod] - public void Test_9899() - { - } - [TestMethod] - public void Test_9900() - { - } - [TestMethod] - public void Test_9901() - { - } - [TestMethod] - public void Test_9902() - { - } - [TestMethod] - public void Test_9903() - { - } - [TestMethod] - public void Test_9904() - { - } - [TestMethod] - public void Test_9905() - { - } - [TestMethod] - public void Test_9906() - { - } - [TestMethod] - public void Test_9907() - { - } - [TestMethod] - public void Test_9908() - { - } - [TestMethod] - public void Test_9909() - { - } - [TestMethod] - public void Test_9910() - { - } - [TestMethod] - public void Test_9911() - { - } - [TestMethod] - public void Test_9912() - { - } - [TestMethod] - public void Test_9913() - { - } - [TestMethod] - public void Test_9914() - { - } - [TestMethod] - public void Test_9915() - { - } - [TestMethod] - public void Test_9916() - { - } - [TestMethod] - public void Test_9917() - { - } - [TestMethod] - public void Test_9918() - { - } - [TestMethod] - public void Test_9919() - { - } - [TestMethod] - public void Test_9920() - { - } - [TestMethod] - public void Test_9921() - { - } - [TestMethod] - public void Test_9922() - { - } - [TestMethod] - public void Test_9923() - { - } - [TestMethod] - public void Test_9924() - { - } - [TestMethod] - public void Test_9925() - { - } - [TestMethod] - public void Test_9926() - { - } - [TestMethod] - public void Test_9927() - { - } - [TestMethod] - public void Test_9928() - { - } - [TestMethod] - public void Test_9929() - { - } - [TestMethod] - public void Test_9930() - { - } - [TestMethod] - public void Test_9931() - { - } - [TestMethod] - public void Test_9932() - { - } - [TestMethod] - public void Test_9933() - { - } - [TestMethod] - public void Test_9934() - { - } - [TestMethod] - public void Test_9935() - { - } - [TestMethod] - public void Test_9936() - { - } - [TestMethod] - public void Test_9937() - { - } - [TestMethod] - public void Test_9938() - { - } - [TestMethod] - public void Test_9939() - { - } - [TestMethod] - public void Test_9940() - { - } - [TestMethod] - public void Test_9941() - { - } - [TestMethod] - public void Test_9942() - { - } - [TestMethod] - public void Test_9943() - { - } - [TestMethod] - public void Test_9944() - { - } - [TestMethod] - public void Test_9945() - { - } - [TestMethod] - public void Test_9946() - { - } - [TestMethod] - public void Test_9947() - { - } - [TestMethod] - public void Test_9948() - { - } - [TestMethod] - public void Test_9949() - { - } - [TestMethod] - public void Test_9950() - { - } - [TestMethod] - public void Test_9951() - { - } - [TestMethod] - public void Test_9952() - { - } - [TestMethod] - public void Test_9953() - { - } - [TestMethod] - public void Test_9954() - { - } - [TestMethod] - public void Test_9955() - { - } - [TestMethod] - public void Test_9956() - { - } - [TestMethod] - public void Test_9957() - { - } - [TestMethod] - public void Test_9958() - { - } - [TestMethod] - public void Test_9959() - { - } - [TestMethod] - public void Test_9960() - { - } - [TestMethod] - public void Test_9961() - { - } - [TestMethod] - public void Test_9962() - { - } - [TestMethod] - public void Test_9963() - { - } - [TestMethod] - public void Test_9964() - { - } - [TestMethod] - public void Test_9965() - { - } - [TestMethod] - public void Test_9966() - { - } - [TestMethod] - public void Test_9967() - { - } - [TestMethod] - public void Test_9968() - { - } - [TestMethod] - public void Test_9969() - { - } - [TestMethod] - public void Test_9970() - { - } - [TestMethod] - public void Test_9971() - { - } - [TestMethod] - public void Test_9972() - { - } - [TestMethod] - public void Test_9973() - { - } - [TestMethod] - public void Test_9974() - { - } - [TestMethod] - public void Test_9975() - { - } - [TestMethod] - public void Test_9976() - { - } - [TestMethod] - public void Test_9977() - { - } - [TestMethod] - public void Test_9978() - { - } - [TestMethod] - public void Test_9979() - { - } - [TestMethod] - public void Test_9980() - { - } - [TestMethod] - public void Test_9981() - { - } - [TestMethod] - public void Test_9982() - { - } - [TestMethod] - public void Test_9983() - { - } - [TestMethod] - public void Test_9984() - { - } - [TestMethod] - public void Test_9985() - { - } - [TestMethod] - public void Test_9986() - { - } - [TestMethod] - public void Test_9987() - { - } - [TestMethod] - public void Test_9988() - { - } - [TestMethod] - public void Test_9989() - { - } - [TestMethod] - public void Test_9990() - { - } - [TestMethod] - public void Test_9991() - { - } - [TestMethod] - public void Test_9992() - { - } - [TestMethod] - public void Test_9993() - { - } - [TestMethod] - public void Test_9994() - { - } - [TestMethod] - public void Test_9995() - { - } - [TestMethod] - public void Test_9996() - { - } - [TestMethod] - public void Test_9997() - { - } - [TestMethod] - public void Test_9998() - { - } - [TestMethod] - public void Test_9999() - { - } - [TestMethod] - public void Test_10000() - { - } - #endregion + #region PassingTests + [TestMethod] + public void Test_01() + { + } + [TestMethod] + public void Test_02() + { + } + [TestMethod] + public void Test_03() + { + } + [TestMethod] + public void Test_04() + { + } + [TestMethod] + public void Test_05() + { + } + [TestMethod] + public void Test_06() + { + } + [TestMethod] + public void Test_07() + { + } + [TestMethod] + public void Test_08() + { + } + [TestMethod] + public void Test_09() + { + } + [TestMethod] + public void Test_10() + { + } + [TestMethod] + public void Test_11() + { + } + [TestMethod] + public void Test_12() + { + } + [TestMethod] + public void Test_13() + { + } + [TestMethod] + public void Test_14() + { + } + [TestMethod] + public void Test_15() + { + } + [TestMethod] + public void Test_16() + { + } + [TestMethod] + public void Test_17() + { + } + [TestMethod] + public void Test_18() + { + } + [TestMethod] + public void Test_19() + { + } + [TestMethod] + public void Test_20() + { + } + [TestMethod] + public void Test_21() + { + } + [TestMethod] + public void Test_22() + { + } + [TestMethod] + public void Test_23() + { + } + [TestMethod] + public void Test_24() + { + } + [TestMethod] + public void Test_25() + { + } + [TestMethod] + public void Test_26() + { + } + [TestMethod] + public void Test_27() + { + } + [TestMethod] + public void Test_28() + { + } + [TestMethod] + public void Test_29() + { + } + [TestMethod] + public void Test_30() + { + } + [TestMethod] + public void Test_31() + { + } + [TestMethod] + public void Test_32() + { + } + [TestMethod] + public void Test_33() + { + } + [TestMethod] + public void Test_34() + { + } + [TestMethod] + public void Test_35() + { + } + [TestMethod] + public void Test_36() + { + } + [TestMethod] + public void Test_37() + { + } + [TestMethod] + public void Test_38() + { + } + [TestMethod] + public void Test_39() + { + } + [TestMethod] + public void Test_40() + { + } + [TestMethod] + public void Test_41() + { + } + [TestMethod] + public void Test_42() + { + } + [TestMethod] + public void Test_43() + { + } + [TestMethod] + public void Test_44() + { + } + [TestMethod] + public void Test_45() + { + } + [TestMethod] + public void Test_46() + { + } + [TestMethod] + public void Test_47() + { + } + [TestMethod] + public void Test_48() + { + } + [TestMethod] + public void Test_49() + { + } + [TestMethod] + public void Test_50() + { + } + [TestMethod] + public void Test_51() + { + } + [TestMethod] + public void Test_52() + { + } + [TestMethod] + public void Test_53() + { + } + [TestMethod] + public void Test_54() + { + } + [TestMethod] + public void Test_55() + { + } + [TestMethod] + public void Test_56() + { + } + [TestMethod] + public void Test_57() + { + } + [TestMethod] + public void Test_58() + { + } + [TestMethod] + public void Test_59() + { + } + [TestMethod] + public void Test_60() + { + } + [TestMethod] + public void Test_61() + { + } + [TestMethod] + public void Test_62() + { + } + [TestMethod] + public void Test_63() + { + } + [TestMethod] + public void Test_64() + { + } + [TestMethod] + public void Test_65() + { + } + [TestMethod] + public void Test_66() + { + } + [TestMethod] + public void Test_67() + { + } + [TestMethod] + public void Test_68() + { + } + [TestMethod] + public void Test_69() + { + } + [TestMethod] + public void Test_70() + { + } + [TestMethod] + public void Test_71() + { + } + [TestMethod] + public void Test_72() + { + } + [TestMethod] + public void Test_73() + { + } + [TestMethod] + public void Test_74() + { + } + [TestMethod] + public void Test_75() + { + } + [TestMethod] + public void Test_76() + { + } + [TestMethod] + public void Test_77() + { + } + [TestMethod] + public void Test_78() + { + } + [TestMethod] + public void Test_79() + { + } + [TestMethod] + public void Test_80() + { + } + [TestMethod] + public void Test_81() + { + } + [TestMethod] + public void Test_82() + { + } + [TestMethod] + public void Test_83() + { + } + [TestMethod] + public void Test_84() + { + } + [TestMethod] + public void Test_85() + { + } + [TestMethod] + public void Test_86() + { + } + [TestMethod] + public void Test_87() + { + } + [TestMethod] + public void Test_88() + { + } + [TestMethod] + public void Test_89() + { + } + [TestMethod] + public void Test_90() + { + } + [TestMethod] + public void Test_91() + { + } + [TestMethod] + public void Test_92() + { + } + [TestMethod] + public void Test_93() + { + } + [TestMethod] + public void Test_94() + { + } + [TestMethod] + public void Test_95() + { + } + [TestMethod] + public void Test_96() + { + } + [TestMethod] + public void Test_97() + { + } + [TestMethod] + public void Test_98() + { + } + [TestMethod] + public void Test_99() + { + } + [TestMethod] + public void Test_100() + { + } + [TestMethod] + public void Test_101() + { + } + [TestMethod] + public void Test_102() + { + } + [TestMethod] + public void Test_103() + { + } + [TestMethod] + public void Test_104() + { + } + [TestMethod] + public void Test_105() + { + } + [TestMethod] + public void Test_106() + { + } + [TestMethod] + public void Test_107() + { + } + [TestMethod] + public void Test_108() + { + } + [TestMethod] + public void Test_109() + { + } + [TestMethod] + public void Test_110() + { + } + [TestMethod] + public void Test_111() + { + } + [TestMethod] + public void Test_112() + { + } + [TestMethod] + public void Test_113() + { + } + [TestMethod] + public void Test_114() + { + } + [TestMethod] + public void Test_115() + { + } + [TestMethod] + public void Test_116() + { + } + [TestMethod] + public void Test_117() + { + } + [TestMethod] + public void Test_118() + { + } + [TestMethod] + public void Test_119() + { + } + [TestMethod] + public void Test_120() + { + } + [TestMethod] + public void Test_121() + { + } + [TestMethod] + public void Test_122() + { + } + [TestMethod] + public void Test_123() + { + } + [TestMethod] + public void Test_124() + { + } + [TestMethod] + public void Test_125() + { + } + [TestMethod] + public void Test_126() + { + } + [TestMethod] + public void Test_127() + { + } + [TestMethod] + public void Test_128() + { + } + [TestMethod] + public void Test_129() + { + } + [TestMethod] + public void Test_130() + { + } + [TestMethod] + public void Test_131() + { + } + [TestMethod] + public void Test_132() + { + } + [TestMethod] + public void Test_133() + { + } + [TestMethod] + public void Test_134() + { + } + [TestMethod] + public void Test_135() + { + } + [TestMethod] + public void Test_136() + { + } + [TestMethod] + public void Test_137() + { + } + [TestMethod] + public void Test_138() + { + } + [TestMethod] + public void Test_139() + { + } + [TestMethod] + public void Test_140() + { + } + [TestMethod] + public void Test_141() + { + } + [TestMethod] + public void Test_142() + { + } + [TestMethod] + public void Test_143() + { + } + [TestMethod] + public void Test_144() + { + } + [TestMethod] + public void Test_145() + { + } + [TestMethod] + public void Test_146() + { + } + [TestMethod] + public void Test_147() + { + } + [TestMethod] + public void Test_148() + { + } + [TestMethod] + public void Test_149() + { + } + [TestMethod] + public void Test_150() + { + } + [TestMethod] + public void Test_151() + { + } + [TestMethod] + public void Test_152() + { + } + [TestMethod] + public void Test_153() + { + } + [TestMethod] + public void Test_154() + { + } + [TestMethod] + public void Test_155() + { + } + [TestMethod] + public void Test_156() + { + } + [TestMethod] + public void Test_157() + { + } + [TestMethod] + public void Test_158() + { + } + [TestMethod] + public void Test_159() + { + } + [TestMethod] + public void Test_160() + { + } + [TestMethod] + public void Test_161() + { + } + [TestMethod] + public void Test_162() + { + } + [TestMethod] + public void Test_163() + { + } + [TestMethod] + public void Test_164() + { + } + [TestMethod] + public void Test_165() + { + } + [TestMethod] + public void Test_166() + { + } + [TestMethod] + public void Test_167() + { + } + [TestMethod] + public void Test_168() + { + } + [TestMethod] + public void Test_169() + { + } + [TestMethod] + public void Test_170() + { + } + [TestMethod] + public void Test_171() + { + } + [TestMethod] + public void Test_172() + { + } + [TestMethod] + public void Test_173() + { + } + [TestMethod] + public void Test_174() + { + } + [TestMethod] + public void Test_175() + { + } + [TestMethod] + public void Test_176() + { + } + [TestMethod] + public void Test_177() + { + } + [TestMethod] + public void Test_178() + { + } + [TestMethod] + public void Test_179() + { + } + [TestMethod] + public void Test_180() + { + } + [TestMethod] + public void Test_181() + { + } + [TestMethod] + public void Test_182() + { + } + [TestMethod] + public void Test_183() + { + } + [TestMethod] + public void Test_184() + { + } + [TestMethod] + public void Test_185() + { + } + [TestMethod] + public void Test_186() + { + } + [TestMethod] + public void Test_187() + { + } + [TestMethod] + public void Test_188() + { + } + [TestMethod] + public void Test_189() + { + } + [TestMethod] + public void Test_190() + { + } + [TestMethod] + public void Test_191() + { + } + [TestMethod] + public void Test_192() + { + } + [TestMethod] + public void Test_193() + { + } + [TestMethod] + public void Test_194() + { + } + [TestMethod] + public void Test_195() + { + } + [TestMethod] + public void Test_196() + { + } + [TestMethod] + public void Test_197() + { + } + [TestMethod] + public void Test_198() + { + } + [TestMethod] + public void Test_199() + { + } + [TestMethod] + public void Test_200() + { + } + [TestMethod] + public void Test_201() + { + } + [TestMethod] + public void Test_202() + { + } + [TestMethod] + public void Test_203() + { + } + [TestMethod] + public void Test_204() + { + } + [TestMethod] + public void Test_205() + { + } + [TestMethod] + public void Test_206() + { + } + [TestMethod] + public void Test_207() + { + } + [TestMethod] + public void Test_208() + { + } + [TestMethod] + public void Test_209() + { + } + [TestMethod] + public void Test_210() + { + } + [TestMethod] + public void Test_211() + { + } + [TestMethod] + public void Test_212() + { + } + [TestMethod] + public void Test_213() + { + } + [TestMethod] + public void Test_214() + { + } + [TestMethod] + public void Test_215() + { + } + [TestMethod] + public void Test_216() + { + } + [TestMethod] + public void Test_217() + { + } + [TestMethod] + public void Test_218() + { + } + [TestMethod] + public void Test_219() + { + } + [TestMethod] + public void Test_220() + { + } + [TestMethod] + public void Test_221() + { + } + [TestMethod] + public void Test_222() + { + } + [TestMethod] + public void Test_223() + { + } + [TestMethod] + public void Test_224() + { + } + [TestMethod] + public void Test_225() + { + } + [TestMethod] + public void Test_226() + { + } + [TestMethod] + public void Test_227() + { + } + [TestMethod] + public void Test_228() + { + } + [TestMethod] + public void Test_229() + { + } + [TestMethod] + public void Test_230() + { + } + [TestMethod] + public void Test_231() + { + } + [TestMethod] + public void Test_232() + { + } + [TestMethod] + public void Test_233() + { + } + [TestMethod] + public void Test_234() + { + } + [TestMethod] + public void Test_235() + { + } + [TestMethod] + public void Test_236() + { + } + [TestMethod] + public void Test_237() + { + } + [TestMethod] + public void Test_238() + { + } + [TestMethod] + public void Test_239() + { + } + [TestMethod] + public void Test_240() + { + } + [TestMethod] + public void Test_241() + { + } + [TestMethod] + public void Test_242() + { + } + [TestMethod] + public void Test_243() + { + } + [TestMethod] + public void Test_244() + { + } + [TestMethod] + public void Test_245() + { + } + [TestMethod] + public void Test_246() + { + } + [TestMethod] + public void Test_247() + { + } + [TestMethod] + public void Test_248() + { + } + [TestMethod] + public void Test_249() + { + } + [TestMethod] + public void Test_250() + { + } + [TestMethod] + public void Test_251() + { + } + [TestMethod] + public void Test_252() + { + } + [TestMethod] + public void Test_253() + { + } + [TestMethod] + public void Test_254() + { + } + [TestMethod] + public void Test_255() + { + } + [TestMethod] + public void Test_256() + { + } + [TestMethod] + public void Test_257() + { + } + [TestMethod] + public void Test_258() + { + } + [TestMethod] + public void Test_259() + { + } + [TestMethod] + public void Test_260() + { + } + [TestMethod] + public void Test_261() + { + } + [TestMethod] + public void Test_262() + { + } + [TestMethod] + public void Test_263() + { + } + [TestMethod] + public void Test_264() + { + } + [TestMethod] + public void Test_265() + { + } + [TestMethod] + public void Test_266() + { + } + [TestMethod] + public void Test_267() + { + } + [TestMethod] + public void Test_268() + { + } + [TestMethod] + public void Test_269() + { + } + [TestMethod] + public void Test_270() + { + } + [TestMethod] + public void Test_271() + { + } + [TestMethod] + public void Test_272() + { + } + [TestMethod] + public void Test_273() + { + } + [TestMethod] + public void Test_274() + { + } + [TestMethod] + public void Test_275() + { + } + [TestMethod] + public void Test_276() + { + } + [TestMethod] + public void Test_277() + { + } + [TestMethod] + public void Test_278() + { + } + [TestMethod] + public void Test_279() + { + } + [TestMethod] + public void Test_280() + { + } + [TestMethod] + public void Test_281() + { + } + [TestMethod] + public void Test_282() + { + } + [TestMethod] + public void Test_283() + { + } + [TestMethod] + public void Test_284() + { + } + [TestMethod] + public void Test_285() + { + } + [TestMethod] + public void Test_286() + { + } + [TestMethod] + public void Test_287() + { + } + [TestMethod] + public void Test_288() + { + } + [TestMethod] + public void Test_289() + { + } + [TestMethod] + public void Test_290() + { + } + [TestMethod] + public void Test_291() + { + } + [TestMethod] + public void Test_292() + { + } + [TestMethod] + public void Test_293() + { + } + [TestMethod] + public void Test_294() + { + } + [TestMethod] + public void Test_295() + { + } + [TestMethod] + public void Test_296() + { + } + [TestMethod] + public void Test_297() + { + } + [TestMethod] + public void Test_298() + { + } + [TestMethod] + public void Test_299() + { + } + [TestMethod] + public void Test_300() + { + } + [TestMethod] + public void Test_301() + { + } + [TestMethod] + public void Test_302() + { + } + [TestMethod] + public void Test_303() + { + } + [TestMethod] + public void Test_304() + { + } + [TestMethod] + public void Test_305() + { + } + [TestMethod] + public void Test_306() + { + } + [TestMethod] + public void Test_307() + { + } + [TestMethod] + public void Test_308() + { + } + [TestMethod] + public void Test_309() + { + } + [TestMethod] + public void Test_310() + { + } + [TestMethod] + public void Test_311() + { + } + [TestMethod] + public void Test_312() + { + } + [TestMethod] + public void Test_313() + { + } + [TestMethod] + public void Test_314() + { + } + [TestMethod] + public void Test_315() + { + } + [TestMethod] + public void Test_316() + { + } + [TestMethod] + public void Test_317() + { + } + [TestMethod] + public void Test_318() + { + } + [TestMethod] + public void Test_319() + { + } + [TestMethod] + public void Test_320() + { + } + [TestMethod] + public void Test_321() + { + } + [TestMethod] + public void Test_322() + { + } + [TestMethod] + public void Test_323() + { + } + [TestMethod] + public void Test_324() + { + } + [TestMethod] + public void Test_325() + { + } + [TestMethod] + public void Test_326() + { + } + [TestMethod] + public void Test_327() + { + } + [TestMethod] + public void Test_328() + { + } + [TestMethod] + public void Test_329() + { + } + [TestMethod] + public void Test_330() + { + } + [TestMethod] + public void Test_331() + { + } + [TestMethod] + public void Test_332() + { + } + [TestMethod] + public void Test_333() + { + } + [TestMethod] + public void Test_334() + { + } + [TestMethod] + public void Test_335() + { + } + [TestMethod] + public void Test_336() + { + } + [TestMethod] + public void Test_337() + { + } + [TestMethod] + public void Test_338() + { + } + [TestMethod] + public void Test_339() + { + } + [TestMethod] + public void Test_340() + { + } + [TestMethod] + public void Test_341() + { + } + [TestMethod] + public void Test_342() + { + } + [TestMethod] + public void Test_343() + { + } + [TestMethod] + public void Test_344() + { + } + [TestMethod] + public void Test_345() + { + } + [TestMethod] + public void Test_346() + { + } + [TestMethod] + public void Test_347() + { + } + [TestMethod] + public void Test_348() + { + } + [TestMethod] + public void Test_349() + { + } + [TestMethod] + public void Test_350() + { + } + [TestMethod] + public void Test_351() + { + } + [TestMethod] + public void Test_352() + { + } + [TestMethod] + public void Test_353() + { + } + [TestMethod] + public void Test_354() + { + } + [TestMethod] + public void Test_355() + { + } + [TestMethod] + public void Test_356() + { + } + [TestMethod] + public void Test_357() + { + } + [TestMethod] + public void Test_358() + { + } + [TestMethod] + public void Test_359() + { + } + [TestMethod] + public void Test_360() + { + } + [TestMethod] + public void Test_361() + { + } + [TestMethod] + public void Test_362() + { + } + [TestMethod] + public void Test_363() + { + } + [TestMethod] + public void Test_364() + { + } + [TestMethod] + public void Test_365() + { + } + [TestMethod] + public void Test_366() + { + } + [TestMethod] + public void Test_367() + { + } + [TestMethod] + public void Test_368() + { + } + [TestMethod] + public void Test_369() + { + } + [TestMethod] + public void Test_370() + { + } + [TestMethod] + public void Test_371() + { + } + [TestMethod] + public void Test_372() + { + } + [TestMethod] + public void Test_373() + { + } + [TestMethod] + public void Test_374() + { + } + [TestMethod] + public void Test_375() + { + } + [TestMethod] + public void Test_376() + { + } + [TestMethod] + public void Test_377() + { + } + [TestMethod] + public void Test_378() + { + } + [TestMethod] + public void Test_379() + { + } + [TestMethod] + public void Test_380() + { + } + [TestMethod] + public void Test_381() + { + } + [TestMethod] + public void Test_382() + { + } + [TestMethod] + public void Test_383() + { + } + [TestMethod] + public void Test_384() + { + } + [TestMethod] + public void Test_385() + { + } + [TestMethod] + public void Test_386() + { + } + [TestMethod] + public void Test_387() + { + } + [TestMethod] + public void Test_388() + { + } + [TestMethod] + public void Test_389() + { + } + [TestMethod] + public void Test_390() + { + } + [TestMethod] + public void Test_391() + { + } + [TestMethod] + public void Test_392() + { + } + [TestMethod] + public void Test_393() + { + } + [TestMethod] + public void Test_394() + { + } + [TestMethod] + public void Test_395() + { + } + [TestMethod] + public void Test_396() + { + } + [TestMethod] + public void Test_397() + { + } + [TestMethod] + public void Test_398() + { + } + [TestMethod] + public void Test_399() + { + } + [TestMethod] + public void Test_400() + { + } + [TestMethod] + public void Test_401() + { + } + [TestMethod] + public void Test_402() + { + } + [TestMethod] + public void Test_403() + { + } + [TestMethod] + public void Test_404() + { + } + [TestMethod] + public void Test_405() + { + } + [TestMethod] + public void Test_406() + { + } + [TestMethod] + public void Test_407() + { + } + [TestMethod] + public void Test_408() + { + } + [TestMethod] + public void Test_409() + { + } + [TestMethod] + public void Test_410() + { + } + [TestMethod] + public void Test_411() + { + } + [TestMethod] + public void Test_412() + { + } + [TestMethod] + public void Test_413() + { + } + [TestMethod] + public void Test_414() + { + } + [TestMethod] + public void Test_415() + { + } + [TestMethod] + public void Test_416() + { + } + [TestMethod] + public void Test_417() + { + } + [TestMethod] + public void Test_418() + { + } + [TestMethod] + public void Test_419() + { + } + [TestMethod] + public void Test_420() + { + } + [TestMethod] + public void Test_421() + { + } + [TestMethod] + public void Test_422() + { + } + [TestMethod] + public void Test_423() + { + } + [TestMethod] + public void Test_424() + { + } + [TestMethod] + public void Test_425() + { + } + [TestMethod] + public void Test_426() + { + } + [TestMethod] + public void Test_427() + { + } + [TestMethod] + public void Test_428() + { + } + [TestMethod] + public void Test_429() + { + } + [TestMethod] + public void Test_430() + { + } + [TestMethod] + public void Test_431() + { + } + [TestMethod] + public void Test_432() + { + } + [TestMethod] + public void Test_433() + { + } + [TestMethod] + public void Test_434() + { + } + [TestMethod] + public void Test_435() + { + } + [TestMethod] + public void Test_436() + { + } + [TestMethod] + public void Test_437() + { + } + [TestMethod] + public void Test_438() + { + } + [TestMethod] + public void Test_439() + { + } + [TestMethod] + public void Test_440() + { + } + [TestMethod] + public void Test_441() + { + } + [TestMethod] + public void Test_442() + { + } + [TestMethod] + public void Test_443() + { + } + [TestMethod] + public void Test_444() + { + } + [TestMethod] + public void Test_445() + { + } + [TestMethod] + public void Test_446() + { + } + [TestMethod] + public void Test_447() + { + } + [TestMethod] + public void Test_448() + { + } + [TestMethod] + public void Test_449() + { + } + [TestMethod] + public void Test_450() + { + } + [TestMethod] + public void Test_451() + { + } + [TestMethod] + public void Test_452() + { + } + [TestMethod] + public void Test_453() + { + } + [TestMethod] + public void Test_454() + { + } + [TestMethod] + public void Test_455() + { + } + [TestMethod] + public void Test_456() + { + } + [TestMethod] + public void Test_457() + { + } + [TestMethod] + public void Test_458() + { + } + [TestMethod] + public void Test_459() + { + } + [TestMethod] + public void Test_460() + { + } + [TestMethod] + public void Test_461() + { + } + [TestMethod] + public void Test_462() + { + } + [TestMethod] + public void Test_463() + { + } + [TestMethod] + public void Test_464() + { + } + [TestMethod] + public void Test_465() + { + } + [TestMethod] + public void Test_466() + { + } + [TestMethod] + public void Test_467() + { + } + [TestMethod] + public void Test_468() + { + } + [TestMethod] + public void Test_469() + { + } + [TestMethod] + public void Test_470() + { + } + [TestMethod] + public void Test_471() + { + } + [TestMethod] + public void Test_472() + { + } + [TestMethod] + public void Test_473() + { + } + [TestMethod] + public void Test_474() + { + } + [TestMethod] + public void Test_475() + { + } + [TestMethod] + public void Test_476() + { + } + [TestMethod] + public void Test_477() + { + } + [TestMethod] + public void Test_478() + { + } + [TestMethod] + public void Test_479() + { + } + [TestMethod] + public void Test_480() + { + } + [TestMethod] + public void Test_481() + { + } + [TestMethod] + public void Test_482() + { + } + [TestMethod] + public void Test_483() + { + } + [TestMethod] + public void Test_484() + { + } + [TestMethod] + public void Test_485() + { + } + [TestMethod] + public void Test_486() + { + } + [TestMethod] + public void Test_487() + { + } + [TestMethod] + public void Test_488() + { + } + [TestMethod] + public void Test_489() + { + } + [TestMethod] + public void Test_490() + { + } + [TestMethod] + public void Test_491() + { + } + [TestMethod] + public void Test_492() + { + } + [TestMethod] + public void Test_493() + { + } + [TestMethod] + public void Test_494() + { + } + [TestMethod] + public void Test_495() + { + } + [TestMethod] + public void Test_496() + { + } + [TestMethod] + public void Test_497() + { + } + [TestMethod] + public void Test_498() + { + } + [TestMethod] + public void Test_499() + { + } + [TestMethod] + public void Test_500() + { + } + [TestMethod] + public void Test_501() + { + } + [TestMethod] + public void Test_502() + { + } + [TestMethod] + public void Test_503() + { + } + [TestMethod] + public void Test_504() + { + } + [TestMethod] + public void Test_505() + { + } + [TestMethod] + public void Test_506() + { + } + [TestMethod] + public void Test_507() + { + } + [TestMethod] + public void Test_508() + { + } + [TestMethod] + public void Test_509() + { + } + [TestMethod] + public void Test_510() + { + } + [TestMethod] + public void Test_511() + { + } + [TestMethod] + public void Test_512() + { + } + [TestMethod] + public void Test_513() + { + } + [TestMethod] + public void Test_514() + { + } + [TestMethod] + public void Test_515() + { + } + [TestMethod] + public void Test_516() + { + } + [TestMethod] + public void Test_517() + { + } + [TestMethod] + public void Test_518() + { + } + [TestMethod] + public void Test_519() + { + } + [TestMethod] + public void Test_520() + { + } + [TestMethod] + public void Test_521() + { + } + [TestMethod] + public void Test_522() + { + } + [TestMethod] + public void Test_523() + { + } + [TestMethod] + public void Test_524() + { + } + [TestMethod] + public void Test_525() + { + } + [TestMethod] + public void Test_526() + { + } + [TestMethod] + public void Test_527() + { + } + [TestMethod] + public void Test_528() + { + } + [TestMethod] + public void Test_529() + { + } + [TestMethod] + public void Test_530() + { + } + [TestMethod] + public void Test_531() + { + } + [TestMethod] + public void Test_532() + { + } + [TestMethod] + public void Test_533() + { + } + [TestMethod] + public void Test_534() + { + } + [TestMethod] + public void Test_535() + { + } + [TestMethod] + public void Test_536() + { + } + [TestMethod] + public void Test_537() + { + } + [TestMethod] + public void Test_538() + { + } + [TestMethod] + public void Test_539() + { + } + [TestMethod] + public void Test_540() + { + } + [TestMethod] + public void Test_541() + { + } + [TestMethod] + public void Test_542() + { + } + [TestMethod] + public void Test_543() + { + } + [TestMethod] + public void Test_544() + { + } + [TestMethod] + public void Test_545() + { + } + [TestMethod] + public void Test_546() + { + } + [TestMethod] + public void Test_547() + { + } + [TestMethod] + public void Test_548() + { + } + [TestMethod] + public void Test_549() + { + } + [TestMethod] + public void Test_550() + { + } + [TestMethod] + public void Test_551() + { + } + [TestMethod] + public void Test_552() + { + } + [TestMethod] + public void Test_553() + { + } + [TestMethod] + public void Test_554() + { + } + [TestMethod] + public void Test_555() + { + } + [TestMethod] + public void Test_556() + { + } + [TestMethod] + public void Test_557() + { + } + [TestMethod] + public void Test_558() + { + } + [TestMethod] + public void Test_559() + { + } + [TestMethod] + public void Test_560() + { + } + [TestMethod] + public void Test_561() + { + } + [TestMethod] + public void Test_562() + { + } + [TestMethod] + public void Test_563() + { + } + [TestMethod] + public void Test_564() + { + } + [TestMethod] + public void Test_565() + { + } + [TestMethod] + public void Test_566() + { + } + [TestMethod] + public void Test_567() + { + } + [TestMethod] + public void Test_568() + { + } + [TestMethod] + public void Test_569() + { + } + [TestMethod] + public void Test_570() + { + } + [TestMethod] + public void Test_571() + { + } + [TestMethod] + public void Test_572() + { + } + [TestMethod] + public void Test_573() + { + } + [TestMethod] + public void Test_574() + { + } + [TestMethod] + public void Test_575() + { + } + [TestMethod] + public void Test_576() + { + } + [TestMethod] + public void Test_577() + { + } + [TestMethod] + public void Test_578() + { + } + [TestMethod] + public void Test_579() + { + } + [TestMethod] + public void Test_580() + { + } + [TestMethod] + public void Test_581() + { + } + [TestMethod] + public void Test_582() + { + } + [TestMethod] + public void Test_583() + { + } + [TestMethod] + public void Test_584() + { + } + [TestMethod] + public void Test_585() + { + } + [TestMethod] + public void Test_586() + { + } + [TestMethod] + public void Test_587() + { + } + [TestMethod] + public void Test_588() + { + } + [TestMethod] + public void Test_589() + { + } + [TestMethod] + public void Test_590() + { + } + [TestMethod] + public void Test_591() + { + } + [TestMethod] + public void Test_592() + { + } + [TestMethod] + public void Test_593() + { + } + [TestMethod] + public void Test_594() + { + } + [TestMethod] + public void Test_595() + { + } + [TestMethod] + public void Test_596() + { + } + [TestMethod] + public void Test_597() + { + } + [TestMethod] + public void Test_598() + { + } + [TestMethod] + public void Test_599() + { + } + [TestMethod] + public void Test_600() + { + } + [TestMethod] + public void Test_601() + { + } + [TestMethod] + public void Test_602() + { + } + [TestMethod] + public void Test_603() + { + } + [TestMethod] + public void Test_604() + { + } + [TestMethod] + public void Test_605() + { + } + [TestMethod] + public void Test_606() + { + } + [TestMethod] + public void Test_607() + { + } + [TestMethod] + public void Test_608() + { + } + [TestMethod] + public void Test_609() + { + } + [TestMethod] + public void Test_610() + { + } + [TestMethod] + public void Test_611() + { + } + [TestMethod] + public void Test_612() + { + } + [TestMethod] + public void Test_613() + { + } + [TestMethod] + public void Test_614() + { + } + [TestMethod] + public void Test_615() + { + } + [TestMethod] + public void Test_616() + { + } + [TestMethod] + public void Test_617() + { + } + [TestMethod] + public void Test_618() + { + } + [TestMethod] + public void Test_619() + { + } + [TestMethod] + public void Test_620() + { + } + [TestMethod] + public void Test_621() + { + } + [TestMethod] + public void Test_622() + { + } + [TestMethod] + public void Test_623() + { + } + [TestMethod] + public void Test_624() + { + } + [TestMethod] + public void Test_625() + { + } + [TestMethod] + public void Test_626() + { + } + [TestMethod] + public void Test_627() + { + } + [TestMethod] + public void Test_628() + { + } + [TestMethod] + public void Test_629() + { + } + [TestMethod] + public void Test_630() + { + } + [TestMethod] + public void Test_631() + { + } + [TestMethod] + public void Test_632() + { + } + [TestMethod] + public void Test_633() + { + } + [TestMethod] + public void Test_634() + { + } + [TestMethod] + public void Test_635() + { + } + [TestMethod] + public void Test_636() + { + } + [TestMethod] + public void Test_637() + { + } + [TestMethod] + public void Test_638() + { + } + [TestMethod] + public void Test_639() + { + } + [TestMethod] + public void Test_640() + { + } + [TestMethod] + public void Test_641() + { + } + [TestMethod] + public void Test_642() + { + } + [TestMethod] + public void Test_643() + { + } + [TestMethod] + public void Test_644() + { + } + [TestMethod] + public void Test_645() + { + } + [TestMethod] + public void Test_646() + { + } + [TestMethod] + public void Test_647() + { + } + [TestMethod] + public void Test_648() + { + } + [TestMethod] + public void Test_649() + { + } + [TestMethod] + public void Test_650() + { + } + [TestMethod] + public void Test_651() + { + } + [TestMethod] + public void Test_652() + { + } + [TestMethod] + public void Test_653() + { + } + [TestMethod] + public void Test_654() + { + } + [TestMethod] + public void Test_655() + { + } + [TestMethod] + public void Test_656() + { + } + [TestMethod] + public void Test_657() + { + } + [TestMethod] + public void Test_658() + { + } + [TestMethod] + public void Test_659() + { + } + [TestMethod] + public void Test_660() + { + } + [TestMethod] + public void Test_661() + { + } + [TestMethod] + public void Test_662() + { + } + [TestMethod] + public void Test_663() + { + } + [TestMethod] + public void Test_664() + { + } + [TestMethod] + public void Test_665() + { + } + [TestMethod] + public void Test_666() + { + } + [TestMethod] + public void Test_667() + { + } + [TestMethod] + public void Test_668() + { + } + [TestMethod] + public void Test_669() + { + } + [TestMethod] + public void Test_670() + { + } + [TestMethod] + public void Test_671() + { + } + [TestMethod] + public void Test_672() + { + } + [TestMethod] + public void Test_673() + { + } + [TestMethod] + public void Test_674() + { + } + [TestMethod] + public void Test_675() + { + } + [TestMethod] + public void Test_676() + { + } + [TestMethod] + public void Test_677() + { + } + [TestMethod] + public void Test_678() + { + } + [TestMethod] + public void Test_679() + { + } + [TestMethod] + public void Test_680() + { + } + [TestMethod] + public void Test_681() + { + } + [TestMethod] + public void Test_682() + { + } + [TestMethod] + public void Test_683() + { + } + [TestMethod] + public void Test_684() + { + } + [TestMethod] + public void Test_685() + { + } + [TestMethod] + public void Test_686() + { + } + [TestMethod] + public void Test_687() + { + } + [TestMethod] + public void Test_688() + { + } + [TestMethod] + public void Test_689() + { + } + [TestMethod] + public void Test_690() + { + } + [TestMethod] + public void Test_691() + { + } + [TestMethod] + public void Test_692() + { + } + [TestMethod] + public void Test_693() + { + } + [TestMethod] + public void Test_694() + { + } + [TestMethod] + public void Test_695() + { + } + [TestMethod] + public void Test_696() + { + } + [TestMethod] + public void Test_697() + { + } + [TestMethod] + public void Test_698() + { + } + [TestMethod] + public void Test_699() + { + } + [TestMethod] + public void Test_700() + { + } + [TestMethod] + public void Test_701() + { + } + [TestMethod] + public void Test_702() + { + } + [TestMethod] + public void Test_703() + { + } + [TestMethod] + public void Test_704() + { + } + [TestMethod] + public void Test_705() + { + } + [TestMethod] + public void Test_706() + { + } + [TestMethod] + public void Test_707() + { + } + [TestMethod] + public void Test_708() + { + } + [TestMethod] + public void Test_709() + { + } + [TestMethod] + public void Test_710() + { + } + [TestMethod] + public void Test_711() + { + } + [TestMethod] + public void Test_712() + { + } + [TestMethod] + public void Test_713() + { + } + [TestMethod] + public void Test_714() + { + } + [TestMethod] + public void Test_715() + { + } + [TestMethod] + public void Test_716() + { + } + [TestMethod] + public void Test_717() + { + } + [TestMethod] + public void Test_718() + { + } + [TestMethod] + public void Test_719() + { + } + [TestMethod] + public void Test_720() + { + } + [TestMethod] + public void Test_721() + { + } + [TestMethod] + public void Test_722() + { + } + [TestMethod] + public void Test_723() + { + } + [TestMethod] + public void Test_724() + { + } + [TestMethod] + public void Test_725() + { + } + [TestMethod] + public void Test_726() + { + } + [TestMethod] + public void Test_727() + { + } + [TestMethod] + public void Test_728() + { + } + [TestMethod] + public void Test_729() + { + } + [TestMethod] + public void Test_730() + { + } + [TestMethod] + public void Test_731() + { + } + [TestMethod] + public void Test_732() + { + } + [TestMethod] + public void Test_733() + { + } + [TestMethod] + public void Test_734() + { + } + [TestMethod] + public void Test_735() + { + } + [TestMethod] + public void Test_736() + { + } + [TestMethod] + public void Test_737() + { + } + [TestMethod] + public void Test_738() + { + } + [TestMethod] + public void Test_739() + { + } + [TestMethod] + public void Test_740() + { + } + [TestMethod] + public void Test_741() + { + } + [TestMethod] + public void Test_742() + { + } + [TestMethod] + public void Test_743() + { + } + [TestMethod] + public void Test_744() + { + } + [TestMethod] + public void Test_745() + { + } + [TestMethod] + public void Test_746() + { + } + [TestMethod] + public void Test_747() + { + } + [TestMethod] + public void Test_748() + { + } + [TestMethod] + public void Test_749() + { + } + [TestMethod] + public void Test_750() + { + } + [TestMethod] + public void Test_751() + { + } + [TestMethod] + public void Test_752() + { + } + [TestMethod] + public void Test_753() + { + } + [TestMethod] + public void Test_754() + { + } + [TestMethod] + public void Test_755() + { + } + [TestMethod] + public void Test_756() + { + } + [TestMethod] + public void Test_757() + { + } + [TestMethod] + public void Test_758() + { + } + [TestMethod] + public void Test_759() + { + } + [TestMethod] + public void Test_760() + { + } + [TestMethod] + public void Test_761() + { + } + [TestMethod] + public void Test_762() + { + } + [TestMethod] + public void Test_763() + { + } + [TestMethod] + public void Test_764() + { + } + [TestMethod] + public void Test_765() + { + } + [TestMethod] + public void Test_766() + { + } + [TestMethod] + public void Test_767() + { + } + [TestMethod] + public void Test_768() + { + } + [TestMethod] + public void Test_769() + { + } + [TestMethod] + public void Test_770() + { + } + [TestMethod] + public void Test_771() + { + } + [TestMethod] + public void Test_772() + { + } + [TestMethod] + public void Test_773() + { + } + [TestMethod] + public void Test_774() + { + } + [TestMethod] + public void Test_775() + { + } + [TestMethod] + public void Test_776() + { + } + [TestMethod] + public void Test_777() + { + } + [TestMethod] + public void Test_778() + { + } + [TestMethod] + public void Test_779() + { + } + [TestMethod] + public void Test_780() + { + } + [TestMethod] + public void Test_781() + { + } + [TestMethod] + public void Test_782() + { + } + [TestMethod] + public void Test_783() + { + } + [TestMethod] + public void Test_784() + { + } + [TestMethod] + public void Test_785() + { + } + [TestMethod] + public void Test_786() + { + } + [TestMethod] + public void Test_787() + { + } + [TestMethod] + public void Test_788() + { + } + [TestMethod] + public void Test_789() + { + } + [TestMethod] + public void Test_790() + { + } + [TestMethod] + public void Test_791() + { + } + [TestMethod] + public void Test_792() + { + } + [TestMethod] + public void Test_793() + { + } + [TestMethod] + public void Test_794() + { + } + [TestMethod] + public void Test_795() + { + } + [TestMethod] + public void Test_796() + { + } + [TestMethod] + public void Test_797() + { + } + [TestMethod] + public void Test_798() + { + } + [TestMethod] + public void Test_799() + { + } + [TestMethod] + public void Test_800() + { + } + [TestMethod] + public void Test_801() + { + } + [TestMethod] + public void Test_802() + { + } + [TestMethod] + public void Test_803() + { + } + [TestMethod] + public void Test_804() + { + } + [TestMethod] + public void Test_805() + { + } + [TestMethod] + public void Test_806() + { + } + [TestMethod] + public void Test_807() + { + } + [TestMethod] + public void Test_808() + { + } + [TestMethod] + public void Test_809() + { + } + [TestMethod] + public void Test_810() + { + } + [TestMethod] + public void Test_811() + { + } + [TestMethod] + public void Test_812() + { + } + [TestMethod] + public void Test_813() + { + } + [TestMethod] + public void Test_814() + { + } + [TestMethod] + public void Test_815() + { + } + [TestMethod] + public void Test_816() + { + } + [TestMethod] + public void Test_817() + { + } + [TestMethod] + public void Test_818() + { + } + [TestMethod] + public void Test_819() + { + } + [TestMethod] + public void Test_820() + { + } + [TestMethod] + public void Test_821() + { + } + [TestMethod] + public void Test_822() + { + } + [TestMethod] + public void Test_823() + { + } + [TestMethod] + public void Test_824() + { + } + [TestMethod] + public void Test_825() + { + } + [TestMethod] + public void Test_826() + { + } + [TestMethod] + public void Test_827() + { + } + [TestMethod] + public void Test_828() + { + } + [TestMethod] + public void Test_829() + { + } + [TestMethod] + public void Test_830() + { + } + [TestMethod] + public void Test_831() + { + } + [TestMethod] + public void Test_832() + { + } + [TestMethod] + public void Test_833() + { + } + [TestMethod] + public void Test_834() + { + } + [TestMethod] + public void Test_835() + { + } + [TestMethod] + public void Test_836() + { + } + [TestMethod] + public void Test_837() + { + } + [TestMethod] + public void Test_838() + { + } + [TestMethod] + public void Test_839() + { + } + [TestMethod] + public void Test_840() + { + } + [TestMethod] + public void Test_841() + { + } + [TestMethod] + public void Test_842() + { + } + [TestMethod] + public void Test_843() + { + } + [TestMethod] + public void Test_844() + { + } + [TestMethod] + public void Test_845() + { + } + [TestMethod] + public void Test_846() + { + } + [TestMethod] + public void Test_847() + { + } + [TestMethod] + public void Test_848() + { + } + [TestMethod] + public void Test_849() + { + } + [TestMethod] + public void Test_850() + { + } + [TestMethod] + public void Test_851() + { + } + [TestMethod] + public void Test_852() + { + } + [TestMethod] + public void Test_853() + { + } + [TestMethod] + public void Test_854() + { + } + [TestMethod] + public void Test_855() + { + } + [TestMethod] + public void Test_856() + { + } + [TestMethod] + public void Test_857() + { + } + [TestMethod] + public void Test_858() + { + } + [TestMethod] + public void Test_859() + { + } + [TestMethod] + public void Test_860() + { + } + [TestMethod] + public void Test_861() + { + } + [TestMethod] + public void Test_862() + { + } + [TestMethod] + public void Test_863() + { + } + [TestMethod] + public void Test_864() + { + } + [TestMethod] + public void Test_865() + { + } + [TestMethod] + public void Test_866() + { + } + [TestMethod] + public void Test_867() + { + } + [TestMethod] + public void Test_868() + { + } + [TestMethod] + public void Test_869() + { + } + [TestMethod] + public void Test_870() + { + } + [TestMethod] + public void Test_871() + { + } + [TestMethod] + public void Test_872() + { + } + [TestMethod] + public void Test_873() + { + } + [TestMethod] + public void Test_874() + { + } + [TestMethod] + public void Test_875() + { + } + [TestMethod] + public void Test_876() + { + } + [TestMethod] + public void Test_877() + { + } + [TestMethod] + public void Test_878() + { + } + [TestMethod] + public void Test_879() + { + } + [TestMethod] + public void Test_880() + { + } + [TestMethod] + public void Test_881() + { + } + [TestMethod] + public void Test_882() + { + } + [TestMethod] + public void Test_883() + { + } + [TestMethod] + public void Test_884() + { + } + [TestMethod] + public void Test_885() + { + } + [TestMethod] + public void Test_886() + { + } + [TestMethod] + public void Test_887() + { + } + [TestMethod] + public void Test_888() + { + } + [TestMethod] + public void Test_889() + { + } + [TestMethod] + public void Test_890() + { + } + [TestMethod] + public void Test_891() + { + } + [TestMethod] + public void Test_892() + { + } + [TestMethod] + public void Test_893() + { + } + [TestMethod] + public void Test_894() + { + } + [TestMethod] + public void Test_895() + { + } + [TestMethod] + public void Test_896() + { + } + [TestMethod] + public void Test_897() + { + } + [TestMethod] + public void Test_898() + { + } + [TestMethod] + public void Test_899() + { + } + [TestMethod] + public void Test_900() + { + } + [TestMethod] + public void Test_901() + { + } + [TestMethod] + public void Test_902() + { + } + [TestMethod] + public void Test_903() + { + } + [TestMethod] + public void Test_904() + { + } + [TestMethod] + public void Test_905() + { + } + [TestMethod] + public void Test_906() + { + } + [TestMethod] + public void Test_907() + { + } + [TestMethod] + public void Test_908() + { + } + [TestMethod] + public void Test_909() + { + } + [TestMethod] + public void Test_910() + { + } + [TestMethod] + public void Test_911() + { + } + [TestMethod] + public void Test_912() + { + } + [TestMethod] + public void Test_913() + { + } + [TestMethod] + public void Test_914() + { + } + [TestMethod] + public void Test_915() + { + } + [TestMethod] + public void Test_916() + { + } + [TestMethod] + public void Test_917() + { + } + [TestMethod] + public void Test_918() + { + } + [TestMethod] + public void Test_919() + { + } + [TestMethod] + public void Test_920() + { + } + [TestMethod] + public void Test_921() + { + } + [TestMethod] + public void Test_922() + { + } + [TestMethod] + public void Test_923() + { + } + [TestMethod] + public void Test_924() + { + } + [TestMethod] + public void Test_925() + { + } + [TestMethod] + public void Test_926() + { + } + [TestMethod] + public void Test_927() + { + } + [TestMethod] + public void Test_928() + { + } + [TestMethod] + public void Test_929() + { + } + [TestMethod] + public void Test_930() + { + } + [TestMethod] + public void Test_931() + { + } + [TestMethod] + public void Test_932() + { + } + [TestMethod] + public void Test_933() + { + } + [TestMethod] + public void Test_934() + { + } + [TestMethod] + public void Test_935() + { + } + [TestMethod] + public void Test_936() + { + } + [TestMethod] + public void Test_937() + { + } + [TestMethod] + public void Test_938() + { + } + [TestMethod] + public void Test_939() + { + } + [TestMethod] + public void Test_940() + { + } + [TestMethod] + public void Test_941() + { + } + [TestMethod] + public void Test_942() + { + } + [TestMethod] + public void Test_943() + { + } + [TestMethod] + public void Test_944() + { + } + [TestMethod] + public void Test_945() + { + } + [TestMethod] + public void Test_946() + { + } + [TestMethod] + public void Test_947() + { + } + [TestMethod] + public void Test_948() + { + } + [TestMethod] + public void Test_949() + { + } + [TestMethod] + public void Test_950() + { + } + [TestMethod] + public void Test_951() + { + } + [TestMethod] + public void Test_952() + { + } + [TestMethod] + public void Test_953() + { + } + [TestMethod] + public void Test_954() + { + } + [TestMethod] + public void Test_955() + { + } + [TestMethod] + public void Test_956() + { + } + [TestMethod] + public void Test_957() + { + } + [TestMethod] + public void Test_958() + { + } + [TestMethod] + public void Test_959() + { + } + [TestMethod] + public void Test_960() + { + } + [TestMethod] + public void Test_961() + { + } + [TestMethod] + public void Test_962() + { + } + [TestMethod] + public void Test_963() + { + } + [TestMethod] + public void Test_964() + { + } + [TestMethod] + public void Test_965() + { + } + [TestMethod] + public void Test_966() + { + } + [TestMethod] + public void Test_967() + { + } + [TestMethod] + public void Test_968() + { + } + [TestMethod] + public void Test_969() + { + } + [TestMethod] + public void Test_970() + { + } + [TestMethod] + public void Test_971() + { + } + [TestMethod] + public void Test_972() + { + } + [TestMethod] + public void Test_973() + { + } + [TestMethod] + public void Test_974() + { + } + [TestMethod] + public void Test_975() + { + } + [TestMethod] + public void Test_976() + { + } + [TestMethod] + public void Test_977() + { + } + [TestMethod] + public void Test_978() + { + } + [TestMethod] + public void Test_979() + { + } + [TestMethod] + public void Test_980() + { + } + [TestMethod] + public void Test_981() + { + } + [TestMethod] + public void Test_982() + { + } + [TestMethod] + public void Test_983() + { + } + [TestMethod] + public void Test_984() + { + } + [TestMethod] + public void Test_985() + { + } + [TestMethod] + public void Test_986() + { + } + [TestMethod] + public void Test_987() + { + } + [TestMethod] + public void Test_988() + { + } + [TestMethod] + public void Test_989() + { + } + [TestMethod] + public void Test_990() + { + } + [TestMethod] + public void Test_991() + { + } + [TestMethod] + public void Test_992() + { + } + [TestMethod] + public void Test_993() + { + } + [TestMethod] + public void Test_994() + { + } + [TestMethod] + public void Test_995() + { + } + [TestMethod] + public void Test_996() + { + } + [TestMethod] + public void Test_997() + { + } + [TestMethod] + public void Test_998() + { + } + [TestMethod] + public void Test_999() + { + } + [TestMethod] + public void Test_1000() + { + } + [TestMethod] + public void Test_1001() + { + } + [TestMethod] + public void Test_1002() + { + } + [TestMethod] + public void Test_1003() + { + } + [TestMethod] + public void Test_1004() + { + } + [TestMethod] + public void Test_1005() + { + } + [TestMethod] + public void Test_1006() + { + } + [TestMethod] + public void Test_1007() + { + } + [TestMethod] + public void Test_1008() + { + } + [TestMethod] + public void Test_1009() + { + } + [TestMethod] + public void Test_1010() + { + } + [TestMethod] + public void Test_1011() + { + } + [TestMethod] + public void Test_1012() + { + } + [TestMethod] + public void Test_1013() + { + } + [TestMethod] + public void Test_1014() + { + } + [TestMethod] + public void Test_1015() + { + } + [TestMethod] + public void Test_1016() + { + } + [TestMethod] + public void Test_1017() + { + } + [TestMethod] + public void Test_1018() + { + } + [TestMethod] + public void Test_1019() + { + } + [TestMethod] + public void Test_1020() + { + } + [TestMethod] + public void Test_1021() + { + } + [TestMethod] + public void Test_1022() + { + } + [TestMethod] + public void Test_1023() + { + } + [TestMethod] + public void Test_1024() + { + } + [TestMethod] + public void Test_1025() + { + } + [TestMethod] + public void Test_1026() + { + } + [TestMethod] + public void Test_1027() + { + } + [TestMethod] + public void Test_1028() + { + } + [TestMethod] + public void Test_1029() + { + } + [TestMethod] + public void Test_1030() + { + } + [TestMethod] + public void Test_1031() + { + } + [TestMethod] + public void Test_1032() + { + } + [TestMethod] + public void Test_1033() + { + } + [TestMethod] + public void Test_1034() + { + } + [TestMethod] + public void Test_1035() + { + } + [TestMethod] + public void Test_1036() + { + } + [TestMethod] + public void Test_1037() + { + } + [TestMethod] + public void Test_1038() + { + } + [TestMethod] + public void Test_1039() + { + } + [TestMethod] + public void Test_1040() + { + } + [TestMethod] + public void Test_1041() + { + } + [TestMethod] + public void Test_1042() + { + } + [TestMethod] + public void Test_1043() + { + } + [TestMethod] + public void Test_1044() + { + } + [TestMethod] + public void Test_1045() + { + } + [TestMethod] + public void Test_1046() + { + } + [TestMethod] + public void Test_1047() + { + } + [TestMethod] + public void Test_1048() + { + } + [TestMethod] + public void Test_1049() + { + } + [TestMethod] + public void Test_1050() + { + } + [TestMethod] + public void Test_1051() + { + } + [TestMethod] + public void Test_1052() + { + } + [TestMethod] + public void Test_1053() + { + } + [TestMethod] + public void Test_1054() + { + } + [TestMethod] + public void Test_1055() + { + } + [TestMethod] + public void Test_1056() + { + } + [TestMethod] + public void Test_1057() + { + } + [TestMethod] + public void Test_1058() + { + } + [TestMethod] + public void Test_1059() + { + } + [TestMethod] + public void Test_1060() + { + } + [TestMethod] + public void Test_1061() + { + } + [TestMethod] + public void Test_1062() + { + } + [TestMethod] + public void Test_1063() + { + } + [TestMethod] + public void Test_1064() + { + } + [TestMethod] + public void Test_1065() + { + } + [TestMethod] + public void Test_1066() + { + } + [TestMethod] + public void Test_1067() + { + } + [TestMethod] + public void Test_1068() + { + } + [TestMethod] + public void Test_1069() + { + } + [TestMethod] + public void Test_1070() + { + } + [TestMethod] + public void Test_1071() + { + } + [TestMethod] + public void Test_1072() + { + } + [TestMethod] + public void Test_1073() + { + } + [TestMethod] + public void Test_1074() + { + } + [TestMethod] + public void Test_1075() + { + } + [TestMethod] + public void Test_1076() + { + } + [TestMethod] + public void Test_1077() + { + } + [TestMethod] + public void Test_1078() + { + } + [TestMethod] + public void Test_1079() + { + } + [TestMethod] + public void Test_1080() + { + } + [TestMethod] + public void Test_1081() + { + } + [TestMethod] + public void Test_1082() + { + } + [TestMethod] + public void Test_1083() + { + } + [TestMethod] + public void Test_1084() + { + } + [TestMethod] + public void Test_1085() + { + } + [TestMethod] + public void Test_1086() + { + } + [TestMethod] + public void Test_1087() + { + } + [TestMethod] + public void Test_1088() + { + } + [TestMethod] + public void Test_1089() + { + } + [TestMethod] + public void Test_1090() + { + } + [TestMethod] + public void Test_1091() + { + } + [TestMethod] + public void Test_1092() + { + } + [TestMethod] + public void Test_1093() + { + } + [TestMethod] + public void Test_1094() + { + } + [TestMethod] + public void Test_1095() + { + } + [TestMethod] + public void Test_1096() + { + } + [TestMethod] + public void Test_1097() + { + } + [TestMethod] + public void Test_1098() + { + } + [TestMethod] + public void Test_1099() + { + } + [TestMethod] + public void Test_1100() + { + } + [TestMethod] + public void Test_1101() + { + } + [TestMethod] + public void Test_1102() + { + } + [TestMethod] + public void Test_1103() + { + } + [TestMethod] + public void Test_1104() + { + } + [TestMethod] + public void Test_1105() + { + } + [TestMethod] + public void Test_1106() + { + } + [TestMethod] + public void Test_1107() + { + } + [TestMethod] + public void Test_1108() + { + } + [TestMethod] + public void Test_1109() + { + } + [TestMethod] + public void Test_1110() + { + } + [TestMethod] + public void Test_1111() + { + } + [TestMethod] + public void Test_1112() + { + } + [TestMethod] + public void Test_1113() + { + } + [TestMethod] + public void Test_1114() + { + } + [TestMethod] + public void Test_1115() + { + } + [TestMethod] + public void Test_1116() + { + } + [TestMethod] + public void Test_1117() + { + } + [TestMethod] + public void Test_1118() + { + } + [TestMethod] + public void Test_1119() + { + } + [TestMethod] + public void Test_1120() + { + } + [TestMethod] + public void Test_1121() + { + } + [TestMethod] + public void Test_1122() + { + } + [TestMethod] + public void Test_1123() + { + } + [TestMethod] + public void Test_1124() + { + } + [TestMethod] + public void Test_1125() + { + } + [TestMethod] + public void Test_1126() + { + } + [TestMethod] + public void Test_1127() + { + } + [TestMethod] + public void Test_1128() + { + } + [TestMethod] + public void Test_1129() + { + } + [TestMethod] + public void Test_1130() + { + } + [TestMethod] + public void Test_1131() + { + } + [TestMethod] + public void Test_1132() + { + } + [TestMethod] + public void Test_1133() + { + } + [TestMethod] + public void Test_1134() + { + } + [TestMethod] + public void Test_1135() + { + } + [TestMethod] + public void Test_1136() + { + } + [TestMethod] + public void Test_1137() + { + } + [TestMethod] + public void Test_1138() + { + } + [TestMethod] + public void Test_1139() + { + } + [TestMethod] + public void Test_1140() + { + } + [TestMethod] + public void Test_1141() + { + } + [TestMethod] + public void Test_1142() + { + } + [TestMethod] + public void Test_1143() + { + } + [TestMethod] + public void Test_1144() + { + } + [TestMethod] + public void Test_1145() + { + } + [TestMethod] + public void Test_1146() + { + } + [TestMethod] + public void Test_1147() + { + } + [TestMethod] + public void Test_1148() + { + } + [TestMethod] + public void Test_1149() + { + } + [TestMethod] + public void Test_1150() + { + } + [TestMethod] + public void Test_1151() + { + } + [TestMethod] + public void Test_1152() + { + } + [TestMethod] + public void Test_1153() + { + } + [TestMethod] + public void Test_1154() + { + } + [TestMethod] + public void Test_1155() + { + } + [TestMethod] + public void Test_1156() + { + } + [TestMethod] + public void Test_1157() + { + } + [TestMethod] + public void Test_1158() + { + } + [TestMethod] + public void Test_1159() + { + } + [TestMethod] + public void Test_1160() + { + } + [TestMethod] + public void Test_1161() + { + } + [TestMethod] + public void Test_1162() + { + } + [TestMethod] + public void Test_1163() + { + } + [TestMethod] + public void Test_1164() + { + } + [TestMethod] + public void Test_1165() + { + } + [TestMethod] + public void Test_1166() + { + } + [TestMethod] + public void Test_1167() + { + } + [TestMethod] + public void Test_1168() + { + } + [TestMethod] + public void Test_1169() + { + } + [TestMethod] + public void Test_1170() + { + } + [TestMethod] + public void Test_1171() + { + } + [TestMethod] + public void Test_1172() + { + } + [TestMethod] + public void Test_1173() + { + } + [TestMethod] + public void Test_1174() + { + } + [TestMethod] + public void Test_1175() + { + } + [TestMethod] + public void Test_1176() + { + } + [TestMethod] + public void Test_1177() + { + } + [TestMethod] + public void Test_1178() + { + } + [TestMethod] + public void Test_1179() + { + } + [TestMethod] + public void Test_1180() + { + } + [TestMethod] + public void Test_1181() + { + } + [TestMethod] + public void Test_1182() + { + } + [TestMethod] + public void Test_1183() + { + } + [TestMethod] + public void Test_1184() + { + } + [TestMethod] + public void Test_1185() + { + } + [TestMethod] + public void Test_1186() + { + } + [TestMethod] + public void Test_1187() + { + } + [TestMethod] + public void Test_1188() + { + } + [TestMethod] + public void Test_1189() + { + } + [TestMethod] + public void Test_1190() + { + } + [TestMethod] + public void Test_1191() + { + } + [TestMethod] + public void Test_1192() + { + } + [TestMethod] + public void Test_1193() + { + } + [TestMethod] + public void Test_1194() + { + } + [TestMethod] + public void Test_1195() + { + } + [TestMethod] + public void Test_1196() + { + } + [TestMethod] + public void Test_1197() + { + } + [TestMethod] + public void Test_1198() + { + } + [TestMethod] + public void Test_1199() + { + } + [TestMethod] + public void Test_1200() + { + } + [TestMethod] + public void Test_1201() + { + } + [TestMethod] + public void Test_1202() + { + } + [TestMethod] + public void Test_1203() + { + } + [TestMethod] + public void Test_1204() + { + } + [TestMethod] + public void Test_1205() + { + } + [TestMethod] + public void Test_1206() + { + } + [TestMethod] + public void Test_1207() + { + } + [TestMethod] + public void Test_1208() + { + } + [TestMethod] + public void Test_1209() + { + } + [TestMethod] + public void Test_1210() + { + } + [TestMethod] + public void Test_1211() + { + } + [TestMethod] + public void Test_1212() + { + } + [TestMethod] + public void Test_1213() + { + } + [TestMethod] + public void Test_1214() + { + } + [TestMethod] + public void Test_1215() + { + } + [TestMethod] + public void Test_1216() + { + } + [TestMethod] + public void Test_1217() + { + } + [TestMethod] + public void Test_1218() + { + } + [TestMethod] + public void Test_1219() + { + } + [TestMethod] + public void Test_1220() + { + } + [TestMethod] + public void Test_1221() + { + } + [TestMethod] + public void Test_1222() + { + } + [TestMethod] + public void Test_1223() + { + } + [TestMethod] + public void Test_1224() + { + } + [TestMethod] + public void Test_1225() + { + } + [TestMethod] + public void Test_1226() + { + } + [TestMethod] + public void Test_1227() + { + } + [TestMethod] + public void Test_1228() + { + } + [TestMethod] + public void Test_1229() + { + } + [TestMethod] + public void Test_1230() + { + } + [TestMethod] + public void Test_1231() + { + } + [TestMethod] + public void Test_1232() + { + } + [TestMethod] + public void Test_1233() + { + } + [TestMethod] + public void Test_1234() + { + } + [TestMethod] + public void Test_1235() + { + } + [TestMethod] + public void Test_1236() + { + } + [TestMethod] + public void Test_1237() + { + } + [TestMethod] + public void Test_1238() + { + } + [TestMethod] + public void Test_1239() + { + } + [TestMethod] + public void Test_1240() + { + } + [TestMethod] + public void Test_1241() + { + } + [TestMethod] + public void Test_1242() + { + } + [TestMethod] + public void Test_1243() + { + } + [TestMethod] + public void Test_1244() + { + } + [TestMethod] + public void Test_1245() + { + } + [TestMethod] + public void Test_1246() + { + } + [TestMethod] + public void Test_1247() + { + } + [TestMethod] + public void Test_1248() + { + } + [TestMethod] + public void Test_1249() + { + } + [TestMethod] + public void Test_1250() + { + } + [TestMethod] + public void Test_1251() + { + } + [TestMethod] + public void Test_1252() + { + } + [TestMethod] + public void Test_1253() + { + } + [TestMethod] + public void Test_1254() + { + } + [TestMethod] + public void Test_1255() + { + } + [TestMethod] + public void Test_1256() + { + } + [TestMethod] + public void Test_1257() + { + } + [TestMethod] + public void Test_1258() + { + } + [TestMethod] + public void Test_1259() + { + } + [TestMethod] + public void Test_1260() + { + } + [TestMethod] + public void Test_1261() + { + } + [TestMethod] + public void Test_1262() + { + } + [TestMethod] + public void Test_1263() + { + } + [TestMethod] + public void Test_1264() + { + } + [TestMethod] + public void Test_1265() + { + } + [TestMethod] + public void Test_1266() + { + } + [TestMethod] + public void Test_1267() + { + } + [TestMethod] + public void Test_1268() + { + } + [TestMethod] + public void Test_1269() + { + } + [TestMethod] + public void Test_1270() + { + } + [TestMethod] + public void Test_1271() + { + } + [TestMethod] + public void Test_1272() + { + } + [TestMethod] + public void Test_1273() + { + } + [TestMethod] + public void Test_1274() + { + } + [TestMethod] + public void Test_1275() + { + } + [TestMethod] + public void Test_1276() + { + } + [TestMethod] + public void Test_1277() + { + } + [TestMethod] + public void Test_1278() + { + } + [TestMethod] + public void Test_1279() + { + } + [TestMethod] + public void Test_1280() + { + } + [TestMethod] + public void Test_1281() + { + } + [TestMethod] + public void Test_1282() + { + } + [TestMethod] + public void Test_1283() + { + } + [TestMethod] + public void Test_1284() + { + } + [TestMethod] + public void Test_1285() + { + } + [TestMethod] + public void Test_1286() + { + } + [TestMethod] + public void Test_1287() + { + } + [TestMethod] + public void Test_1288() + { + } + [TestMethod] + public void Test_1289() + { + } + [TestMethod] + public void Test_1290() + { + } + [TestMethod] + public void Test_1291() + { + } + [TestMethod] + public void Test_1292() + { + } + [TestMethod] + public void Test_1293() + { + } + [TestMethod] + public void Test_1294() + { + } + [TestMethod] + public void Test_1295() + { + } + [TestMethod] + public void Test_1296() + { + } + [TestMethod] + public void Test_1297() + { + } + [TestMethod] + public void Test_1298() + { + } + [TestMethod] + public void Test_1299() + { + } + [TestMethod] + public void Test_1300() + { + } + [TestMethod] + public void Test_1301() + { + } + [TestMethod] + public void Test_1302() + { + } + [TestMethod] + public void Test_1303() + { + } + [TestMethod] + public void Test_1304() + { + } + [TestMethod] + public void Test_1305() + { + } + [TestMethod] + public void Test_1306() + { + } + [TestMethod] + public void Test_1307() + { + } + [TestMethod] + public void Test_1308() + { + } + [TestMethod] + public void Test_1309() + { + } + [TestMethod] + public void Test_1310() + { + } + [TestMethod] + public void Test_1311() + { + } + [TestMethod] + public void Test_1312() + { + } + [TestMethod] + public void Test_1313() + { + } + [TestMethod] + public void Test_1314() + { + } + [TestMethod] + public void Test_1315() + { + } + [TestMethod] + public void Test_1316() + { + } + [TestMethod] + public void Test_1317() + { + } + [TestMethod] + public void Test_1318() + { + } + [TestMethod] + public void Test_1319() + { + } + [TestMethod] + public void Test_1320() + { + } + [TestMethod] + public void Test_1321() + { + } + [TestMethod] + public void Test_1322() + { + } + [TestMethod] + public void Test_1323() + { + } + [TestMethod] + public void Test_1324() + { + } + [TestMethod] + public void Test_1325() + { + } + [TestMethod] + public void Test_1326() + { + } + [TestMethod] + public void Test_1327() + { + } + [TestMethod] + public void Test_1328() + { + } + [TestMethod] + public void Test_1329() + { + } + [TestMethod] + public void Test_1330() + { + } + [TestMethod] + public void Test_1331() + { + } + [TestMethod] + public void Test_1332() + { + } + [TestMethod] + public void Test_1333() + { + } + [TestMethod] + public void Test_1334() + { + } + [TestMethod] + public void Test_1335() + { + } + [TestMethod] + public void Test_1336() + { + } + [TestMethod] + public void Test_1337() + { + } + [TestMethod] + public void Test_1338() + { + } + [TestMethod] + public void Test_1339() + { + } + [TestMethod] + public void Test_1340() + { + } + [TestMethod] + public void Test_1341() + { + } + [TestMethod] + public void Test_1342() + { + } + [TestMethod] + public void Test_1343() + { + } + [TestMethod] + public void Test_1344() + { + } + [TestMethod] + public void Test_1345() + { + } + [TestMethod] + public void Test_1346() + { + } + [TestMethod] + public void Test_1347() + { + } + [TestMethod] + public void Test_1348() + { + } + [TestMethod] + public void Test_1349() + { + } + [TestMethod] + public void Test_1350() + { + } + [TestMethod] + public void Test_1351() + { + } + [TestMethod] + public void Test_1352() + { + } + [TestMethod] + public void Test_1353() + { + } + [TestMethod] + public void Test_1354() + { + } + [TestMethod] + public void Test_1355() + { + } + [TestMethod] + public void Test_1356() + { + } + [TestMethod] + public void Test_1357() + { + } + [TestMethod] + public void Test_1358() + { + } + [TestMethod] + public void Test_1359() + { + } + [TestMethod] + public void Test_1360() + { + } + [TestMethod] + public void Test_1361() + { + } + [TestMethod] + public void Test_1362() + { + } + [TestMethod] + public void Test_1363() + { + } + [TestMethod] + public void Test_1364() + { + } + [TestMethod] + public void Test_1365() + { + } + [TestMethod] + public void Test_1366() + { + } + [TestMethod] + public void Test_1367() + { + } + [TestMethod] + public void Test_1368() + { + } + [TestMethod] + public void Test_1369() + { + } + [TestMethod] + public void Test_1370() + { + } + [TestMethod] + public void Test_1371() + { + } + [TestMethod] + public void Test_1372() + { + } + [TestMethod] + public void Test_1373() + { + } + [TestMethod] + public void Test_1374() + { + } + [TestMethod] + public void Test_1375() + { + } + [TestMethod] + public void Test_1376() + { + } + [TestMethod] + public void Test_1377() + { + } + [TestMethod] + public void Test_1378() + { + } + [TestMethod] + public void Test_1379() + { + } + [TestMethod] + public void Test_1380() + { + } + [TestMethod] + public void Test_1381() + { + } + [TestMethod] + public void Test_1382() + { + } + [TestMethod] + public void Test_1383() + { + } + [TestMethod] + public void Test_1384() + { + } + [TestMethod] + public void Test_1385() + { + } + [TestMethod] + public void Test_1386() + { + } + [TestMethod] + public void Test_1387() + { + } + [TestMethod] + public void Test_1388() + { + } + [TestMethod] + public void Test_1389() + { + } + [TestMethod] + public void Test_1390() + { + } + [TestMethod] + public void Test_1391() + { + } + [TestMethod] + public void Test_1392() + { + } + [TestMethod] + public void Test_1393() + { + } + [TestMethod] + public void Test_1394() + { + } + [TestMethod] + public void Test_1395() + { + } + [TestMethod] + public void Test_1396() + { + } + [TestMethod] + public void Test_1397() + { + } + [TestMethod] + public void Test_1398() + { + } + [TestMethod] + public void Test_1399() + { + } + [TestMethod] + public void Test_1400() + { + } + [TestMethod] + public void Test_1401() + { + } + [TestMethod] + public void Test_1402() + { + } + [TestMethod] + public void Test_1403() + { + } + [TestMethod] + public void Test_1404() + { + } + [TestMethod] + public void Test_1405() + { + } + [TestMethod] + public void Test_1406() + { + } + [TestMethod] + public void Test_1407() + { + } + [TestMethod] + public void Test_1408() + { + } + [TestMethod] + public void Test_1409() + { + } + [TestMethod] + public void Test_1410() + { + } + [TestMethod] + public void Test_1411() + { + } + [TestMethod] + public void Test_1412() + { + } + [TestMethod] + public void Test_1413() + { + } + [TestMethod] + public void Test_1414() + { + } + [TestMethod] + public void Test_1415() + { + } + [TestMethod] + public void Test_1416() + { + } + [TestMethod] + public void Test_1417() + { + } + [TestMethod] + public void Test_1418() + { + } + [TestMethod] + public void Test_1419() + { + } + [TestMethod] + public void Test_1420() + { + } + [TestMethod] + public void Test_1421() + { + } + [TestMethod] + public void Test_1422() + { + } + [TestMethod] + public void Test_1423() + { + } + [TestMethod] + public void Test_1424() + { + } + [TestMethod] + public void Test_1425() + { + } + [TestMethod] + public void Test_1426() + { + } + [TestMethod] + public void Test_1427() + { + } + [TestMethod] + public void Test_1428() + { + } + [TestMethod] + public void Test_1429() + { + } + [TestMethod] + public void Test_1430() + { + } + [TestMethod] + public void Test_1431() + { + } + [TestMethod] + public void Test_1432() + { + } + [TestMethod] + public void Test_1433() + { + } + [TestMethod] + public void Test_1434() + { + } + [TestMethod] + public void Test_1435() + { + } + [TestMethod] + public void Test_1436() + { + } + [TestMethod] + public void Test_1437() + { + } + [TestMethod] + public void Test_1438() + { + } + [TestMethod] + public void Test_1439() + { + } + [TestMethod] + public void Test_1440() + { + } + [TestMethod] + public void Test_1441() + { + } + [TestMethod] + public void Test_1442() + { + } + [TestMethod] + public void Test_1443() + { + } + [TestMethod] + public void Test_1444() + { + } + [TestMethod] + public void Test_1445() + { + } + [TestMethod] + public void Test_1446() + { + } + [TestMethod] + public void Test_1447() + { + } + [TestMethod] + public void Test_1448() + { + } + [TestMethod] + public void Test_1449() + { + } + [TestMethod] + public void Test_1450() + { + } + [TestMethod] + public void Test_1451() + { + } + [TestMethod] + public void Test_1452() + { + } + [TestMethod] + public void Test_1453() + { + } + [TestMethod] + public void Test_1454() + { + } + [TestMethod] + public void Test_1455() + { + } + [TestMethod] + public void Test_1456() + { + } + [TestMethod] + public void Test_1457() + { + } + [TestMethod] + public void Test_1458() + { + } + [TestMethod] + public void Test_1459() + { + } + [TestMethod] + public void Test_1460() + { + } + [TestMethod] + public void Test_1461() + { + } + [TestMethod] + public void Test_1462() + { + } + [TestMethod] + public void Test_1463() + { + } + [TestMethod] + public void Test_1464() + { + } + [TestMethod] + public void Test_1465() + { + } + [TestMethod] + public void Test_1466() + { + } + [TestMethod] + public void Test_1467() + { + } + [TestMethod] + public void Test_1468() + { + } + [TestMethod] + public void Test_1469() + { + } + [TestMethod] + public void Test_1470() + { + } + [TestMethod] + public void Test_1471() + { + } + [TestMethod] + public void Test_1472() + { + } + [TestMethod] + public void Test_1473() + { + } + [TestMethod] + public void Test_1474() + { + } + [TestMethod] + public void Test_1475() + { + } + [TestMethod] + public void Test_1476() + { + } + [TestMethod] + public void Test_1477() + { + } + [TestMethod] + public void Test_1478() + { + } + [TestMethod] + public void Test_1479() + { + } + [TestMethod] + public void Test_1480() + { + } + [TestMethod] + public void Test_1481() + { + } + [TestMethod] + public void Test_1482() + { + } + [TestMethod] + public void Test_1483() + { + } + [TestMethod] + public void Test_1484() + { + } + [TestMethod] + public void Test_1485() + { + } + [TestMethod] + public void Test_1486() + { + } + [TestMethod] + public void Test_1487() + { + } + [TestMethod] + public void Test_1488() + { + } + [TestMethod] + public void Test_1489() + { + } + [TestMethod] + public void Test_1490() + { + } + [TestMethod] + public void Test_1491() + { + } + [TestMethod] + public void Test_1492() + { + } + [TestMethod] + public void Test_1493() + { + } + [TestMethod] + public void Test_1494() + { + } + [TestMethod] + public void Test_1495() + { + } + [TestMethod] + public void Test_1496() + { + } + [TestMethod] + public void Test_1497() + { + } + [TestMethod] + public void Test_1498() + { + } + [TestMethod] + public void Test_1499() + { + } + [TestMethod] + public void Test_1500() + { + } + [TestMethod] + public void Test_1501() + { + } + [TestMethod] + public void Test_1502() + { + } + [TestMethod] + public void Test_1503() + { + } + [TestMethod] + public void Test_1504() + { + } + [TestMethod] + public void Test_1505() + { + } + [TestMethod] + public void Test_1506() + { + } + [TestMethod] + public void Test_1507() + { + } + [TestMethod] + public void Test_1508() + { + } + [TestMethod] + public void Test_1509() + { + } + [TestMethod] + public void Test_1510() + { + } + [TestMethod] + public void Test_1511() + { + } + [TestMethod] + public void Test_1512() + { + } + [TestMethod] + public void Test_1513() + { + } + [TestMethod] + public void Test_1514() + { + } + [TestMethod] + public void Test_1515() + { + } + [TestMethod] + public void Test_1516() + { + } + [TestMethod] + public void Test_1517() + { + } + [TestMethod] + public void Test_1518() + { + } + [TestMethod] + public void Test_1519() + { + } + [TestMethod] + public void Test_1520() + { + } + [TestMethod] + public void Test_1521() + { + } + [TestMethod] + public void Test_1522() + { + } + [TestMethod] + public void Test_1523() + { + } + [TestMethod] + public void Test_1524() + { + } + [TestMethod] + public void Test_1525() + { + } + [TestMethod] + public void Test_1526() + { + } + [TestMethod] + public void Test_1527() + { + } + [TestMethod] + public void Test_1528() + { + } + [TestMethod] + public void Test_1529() + { + } + [TestMethod] + public void Test_1530() + { + } + [TestMethod] + public void Test_1531() + { + } + [TestMethod] + public void Test_1532() + { + } + [TestMethod] + public void Test_1533() + { + } + [TestMethod] + public void Test_1534() + { + } + [TestMethod] + public void Test_1535() + { + } + [TestMethod] + public void Test_1536() + { + } + [TestMethod] + public void Test_1537() + { + } + [TestMethod] + public void Test_1538() + { + } + [TestMethod] + public void Test_1539() + { + } + [TestMethod] + public void Test_1540() + { + } + [TestMethod] + public void Test_1541() + { + } + [TestMethod] + public void Test_1542() + { + } + [TestMethod] + public void Test_1543() + { + } + [TestMethod] + public void Test_1544() + { + } + [TestMethod] + public void Test_1545() + { + } + [TestMethod] + public void Test_1546() + { + } + [TestMethod] + public void Test_1547() + { + } + [TestMethod] + public void Test_1548() + { + } + [TestMethod] + public void Test_1549() + { + } + [TestMethod] + public void Test_1550() + { + } + [TestMethod] + public void Test_1551() + { + } + [TestMethod] + public void Test_1552() + { + } + [TestMethod] + public void Test_1553() + { + } + [TestMethod] + public void Test_1554() + { + } + [TestMethod] + public void Test_1555() + { + } + [TestMethod] + public void Test_1556() + { + } + [TestMethod] + public void Test_1557() + { + } + [TestMethod] + public void Test_1558() + { + } + [TestMethod] + public void Test_1559() + { + } + [TestMethod] + public void Test_1560() + { + } + [TestMethod] + public void Test_1561() + { + } + [TestMethod] + public void Test_1562() + { + } + [TestMethod] + public void Test_1563() + { + } + [TestMethod] + public void Test_1564() + { + } + [TestMethod] + public void Test_1565() + { + } + [TestMethod] + public void Test_1566() + { + } + [TestMethod] + public void Test_1567() + { + } + [TestMethod] + public void Test_1568() + { + } + [TestMethod] + public void Test_1569() + { + } + [TestMethod] + public void Test_1570() + { + } + [TestMethod] + public void Test_1571() + { + } + [TestMethod] + public void Test_1572() + { + } + [TestMethod] + public void Test_1573() + { + } + [TestMethod] + public void Test_1574() + { + } + [TestMethod] + public void Test_1575() + { + } + [TestMethod] + public void Test_1576() + { + } + [TestMethod] + public void Test_1577() + { + } + [TestMethod] + public void Test_1578() + { + } + [TestMethod] + public void Test_1579() + { + } + [TestMethod] + public void Test_1580() + { + } + [TestMethod] + public void Test_1581() + { + } + [TestMethod] + public void Test_1582() + { + } + [TestMethod] + public void Test_1583() + { + } + [TestMethod] + public void Test_1584() + { + } + [TestMethod] + public void Test_1585() + { + } + [TestMethod] + public void Test_1586() + { + } + [TestMethod] + public void Test_1587() + { + } + [TestMethod] + public void Test_1588() + { + } + [TestMethod] + public void Test_1589() + { + } + [TestMethod] + public void Test_1590() + { + } + [TestMethod] + public void Test_1591() + { + } + [TestMethod] + public void Test_1592() + { + } + [TestMethod] + public void Test_1593() + { + } + [TestMethod] + public void Test_1594() + { + } + [TestMethod] + public void Test_1595() + { + } + [TestMethod] + public void Test_1596() + { + } + [TestMethod] + public void Test_1597() + { + } + [TestMethod] + public void Test_1598() + { + } + [TestMethod] + public void Test_1599() + { + } + [TestMethod] + public void Test_1600() + { + } + [TestMethod] + public void Test_1601() + { + } + [TestMethod] + public void Test_1602() + { + } + [TestMethod] + public void Test_1603() + { + } + [TestMethod] + public void Test_1604() + { + } + [TestMethod] + public void Test_1605() + { + } + [TestMethod] + public void Test_1606() + { + } + [TestMethod] + public void Test_1607() + { + } + [TestMethod] + public void Test_1608() + { + } + [TestMethod] + public void Test_1609() + { + } + [TestMethod] + public void Test_1610() + { + } + [TestMethod] + public void Test_1611() + { + } + [TestMethod] + public void Test_1612() + { + } + [TestMethod] + public void Test_1613() + { + } + [TestMethod] + public void Test_1614() + { + } + [TestMethod] + public void Test_1615() + { + } + [TestMethod] + public void Test_1616() + { + } + [TestMethod] + public void Test_1617() + { + } + [TestMethod] + public void Test_1618() + { + } + [TestMethod] + public void Test_1619() + { + } + [TestMethod] + public void Test_1620() + { + } + [TestMethod] + public void Test_1621() + { + } + [TestMethod] + public void Test_1622() + { + } + [TestMethod] + public void Test_1623() + { + } + [TestMethod] + public void Test_1624() + { + } + [TestMethod] + public void Test_1625() + { + } + [TestMethod] + public void Test_1626() + { + } + [TestMethod] + public void Test_1627() + { + } + [TestMethod] + public void Test_1628() + { + } + [TestMethod] + public void Test_1629() + { + } + [TestMethod] + public void Test_1630() + { + } + [TestMethod] + public void Test_1631() + { + } + [TestMethod] + public void Test_1632() + { + } + [TestMethod] + public void Test_1633() + { + } + [TestMethod] + public void Test_1634() + { + } + [TestMethod] + public void Test_1635() + { + } + [TestMethod] + public void Test_1636() + { + } + [TestMethod] + public void Test_1637() + { + } + [TestMethod] + public void Test_1638() + { + } + [TestMethod] + public void Test_1639() + { + } + [TestMethod] + public void Test_1640() + { + } + [TestMethod] + public void Test_1641() + { + } + [TestMethod] + public void Test_1642() + { + } + [TestMethod] + public void Test_1643() + { + } + [TestMethod] + public void Test_1644() + { + } + [TestMethod] + public void Test_1645() + { + } + [TestMethod] + public void Test_1646() + { + } + [TestMethod] + public void Test_1647() + { + } + [TestMethod] + public void Test_1648() + { + } + [TestMethod] + public void Test_1649() + { + } + [TestMethod] + public void Test_1650() + { + } + [TestMethod] + public void Test_1651() + { + } + [TestMethod] + public void Test_1652() + { + } + [TestMethod] + public void Test_1653() + { + } + [TestMethod] + public void Test_1654() + { + } + [TestMethod] + public void Test_1655() + { + } + [TestMethod] + public void Test_1656() + { + } + [TestMethod] + public void Test_1657() + { + } + [TestMethod] + public void Test_1658() + { + } + [TestMethod] + public void Test_1659() + { + } + [TestMethod] + public void Test_1660() + { + } + [TestMethod] + public void Test_1661() + { + } + [TestMethod] + public void Test_1662() + { + } + [TestMethod] + public void Test_1663() + { + } + [TestMethod] + public void Test_1664() + { + } + [TestMethod] + public void Test_1665() + { + } + [TestMethod] + public void Test_1666() + { + } + [TestMethod] + public void Test_1667() + { + } + [TestMethod] + public void Test_1668() + { + } + [TestMethod] + public void Test_1669() + { + } + [TestMethod] + public void Test_1670() + { + } + [TestMethod] + public void Test_1671() + { + } + [TestMethod] + public void Test_1672() + { + } + [TestMethod] + public void Test_1673() + { + } + [TestMethod] + public void Test_1674() + { + } + [TestMethod] + public void Test_1675() + { + } + [TestMethod] + public void Test_1676() + { + } + [TestMethod] + public void Test_1677() + { + } + [TestMethod] + public void Test_1678() + { + } + [TestMethod] + public void Test_1679() + { + } + [TestMethod] + public void Test_1680() + { + } + [TestMethod] + public void Test_1681() + { + } + [TestMethod] + public void Test_1682() + { + } + [TestMethod] + public void Test_1683() + { + } + [TestMethod] + public void Test_1684() + { + } + [TestMethod] + public void Test_1685() + { + } + [TestMethod] + public void Test_1686() + { + } + [TestMethod] + public void Test_1687() + { + } + [TestMethod] + public void Test_1688() + { + } + [TestMethod] + public void Test_1689() + { + } + [TestMethod] + public void Test_1690() + { + } + [TestMethod] + public void Test_1691() + { + } + [TestMethod] + public void Test_1692() + { + } + [TestMethod] + public void Test_1693() + { + } + [TestMethod] + public void Test_1694() + { + } + [TestMethod] + public void Test_1695() + { + } + [TestMethod] + public void Test_1696() + { + } + [TestMethod] + public void Test_1697() + { + } + [TestMethod] + public void Test_1698() + { + } + [TestMethod] + public void Test_1699() + { + } + [TestMethod] + public void Test_1700() + { + } + [TestMethod] + public void Test_1701() + { + } + [TestMethod] + public void Test_1702() + { + } + [TestMethod] + public void Test_1703() + { + } + [TestMethod] + public void Test_1704() + { + } + [TestMethod] + public void Test_1705() + { + } + [TestMethod] + public void Test_1706() + { + } + [TestMethod] + public void Test_1707() + { + } + [TestMethod] + public void Test_1708() + { + } + [TestMethod] + public void Test_1709() + { + } + [TestMethod] + public void Test_1710() + { + } + [TestMethod] + public void Test_1711() + { + } + [TestMethod] + public void Test_1712() + { + } + [TestMethod] + public void Test_1713() + { + } + [TestMethod] + public void Test_1714() + { + } + [TestMethod] + public void Test_1715() + { + } + [TestMethod] + public void Test_1716() + { + } + [TestMethod] + public void Test_1717() + { + } + [TestMethod] + public void Test_1718() + { + } + [TestMethod] + public void Test_1719() + { + } + [TestMethod] + public void Test_1720() + { + } + [TestMethod] + public void Test_1721() + { + } + [TestMethod] + public void Test_1722() + { + } + [TestMethod] + public void Test_1723() + { + } + [TestMethod] + public void Test_1724() + { + } + [TestMethod] + public void Test_1725() + { + } + [TestMethod] + public void Test_1726() + { + } + [TestMethod] + public void Test_1727() + { + } + [TestMethod] + public void Test_1728() + { + } + [TestMethod] + public void Test_1729() + { + } + [TestMethod] + public void Test_1730() + { + } + [TestMethod] + public void Test_1731() + { + } + [TestMethod] + public void Test_1732() + { + } + [TestMethod] + public void Test_1733() + { + } + [TestMethod] + public void Test_1734() + { + } + [TestMethod] + public void Test_1735() + { + } + [TestMethod] + public void Test_1736() + { + } + [TestMethod] + public void Test_1737() + { + } + [TestMethod] + public void Test_1738() + { + } + [TestMethod] + public void Test_1739() + { + } + [TestMethod] + public void Test_1740() + { + } + [TestMethod] + public void Test_1741() + { + } + [TestMethod] + public void Test_1742() + { + } + [TestMethod] + public void Test_1743() + { + } + [TestMethod] + public void Test_1744() + { + } + [TestMethod] + public void Test_1745() + { + } + [TestMethod] + public void Test_1746() + { + } + [TestMethod] + public void Test_1747() + { + } + [TestMethod] + public void Test_1748() + { + } + [TestMethod] + public void Test_1749() + { + } + [TestMethod] + public void Test_1750() + { + } + [TestMethod] + public void Test_1751() + { + } + [TestMethod] + public void Test_1752() + { + } + [TestMethod] + public void Test_1753() + { + } + [TestMethod] + public void Test_1754() + { + } + [TestMethod] + public void Test_1755() + { + } + [TestMethod] + public void Test_1756() + { + } + [TestMethod] + public void Test_1757() + { + } + [TestMethod] + public void Test_1758() + { + } + [TestMethod] + public void Test_1759() + { + } + [TestMethod] + public void Test_1760() + { + } + [TestMethod] + public void Test_1761() + { + } + [TestMethod] + public void Test_1762() + { + } + [TestMethod] + public void Test_1763() + { + } + [TestMethod] + public void Test_1764() + { + } + [TestMethod] + public void Test_1765() + { + } + [TestMethod] + public void Test_1766() + { + } + [TestMethod] + public void Test_1767() + { + } + [TestMethod] + public void Test_1768() + { + } + [TestMethod] + public void Test_1769() + { + } + [TestMethod] + public void Test_1770() + { + } + [TestMethod] + public void Test_1771() + { + } + [TestMethod] + public void Test_1772() + { + } + [TestMethod] + public void Test_1773() + { + } + [TestMethod] + public void Test_1774() + { + } + [TestMethod] + public void Test_1775() + { + } + [TestMethod] + public void Test_1776() + { + } + [TestMethod] + public void Test_1777() + { + } + [TestMethod] + public void Test_1778() + { + } + [TestMethod] + public void Test_1779() + { + } + [TestMethod] + public void Test_1780() + { + } + [TestMethod] + public void Test_1781() + { + } + [TestMethod] + public void Test_1782() + { + } + [TestMethod] + public void Test_1783() + { + } + [TestMethod] + public void Test_1784() + { + } + [TestMethod] + public void Test_1785() + { + } + [TestMethod] + public void Test_1786() + { + } + [TestMethod] + public void Test_1787() + { + } + [TestMethod] + public void Test_1788() + { + } + [TestMethod] + public void Test_1789() + { + } + [TestMethod] + public void Test_1790() + { + } + [TestMethod] + public void Test_1791() + { + } + [TestMethod] + public void Test_1792() + { + } + [TestMethod] + public void Test_1793() + { + } + [TestMethod] + public void Test_1794() + { + } + [TestMethod] + public void Test_1795() + { + } + [TestMethod] + public void Test_1796() + { + } + [TestMethod] + public void Test_1797() + { + } + [TestMethod] + public void Test_1798() + { + } + [TestMethod] + public void Test_1799() + { + } + [TestMethod] + public void Test_1800() + { + } + [TestMethod] + public void Test_1801() + { + } + [TestMethod] + public void Test_1802() + { + } + [TestMethod] + public void Test_1803() + { + } + [TestMethod] + public void Test_1804() + { + } + [TestMethod] + public void Test_1805() + { + } + [TestMethod] + public void Test_1806() + { + } + [TestMethod] + public void Test_1807() + { + } + [TestMethod] + public void Test_1808() + { + } + [TestMethod] + public void Test_1809() + { + } + [TestMethod] + public void Test_1810() + { + } + [TestMethod] + public void Test_1811() + { + } + [TestMethod] + public void Test_1812() + { + } + [TestMethod] + public void Test_1813() + { + } + [TestMethod] + public void Test_1814() + { + } + [TestMethod] + public void Test_1815() + { + } + [TestMethod] + public void Test_1816() + { + } + [TestMethod] + public void Test_1817() + { + } + [TestMethod] + public void Test_1818() + { + } + [TestMethod] + public void Test_1819() + { + } + [TestMethod] + public void Test_1820() + { + } + [TestMethod] + public void Test_1821() + { + } + [TestMethod] + public void Test_1822() + { + } + [TestMethod] + public void Test_1823() + { + } + [TestMethod] + public void Test_1824() + { + } + [TestMethod] + public void Test_1825() + { + } + [TestMethod] + public void Test_1826() + { + } + [TestMethod] + public void Test_1827() + { + } + [TestMethod] + public void Test_1828() + { + } + [TestMethod] + public void Test_1829() + { + } + [TestMethod] + public void Test_1830() + { + } + [TestMethod] + public void Test_1831() + { + } + [TestMethod] + public void Test_1832() + { + } + [TestMethod] + public void Test_1833() + { + } + [TestMethod] + public void Test_1834() + { + } + [TestMethod] + public void Test_1835() + { + } + [TestMethod] + public void Test_1836() + { + } + [TestMethod] + public void Test_1837() + { + } + [TestMethod] + public void Test_1838() + { + } + [TestMethod] + public void Test_1839() + { + } + [TestMethod] + public void Test_1840() + { + } + [TestMethod] + public void Test_1841() + { + } + [TestMethod] + public void Test_1842() + { + } + [TestMethod] + public void Test_1843() + { + } + [TestMethod] + public void Test_1844() + { + } + [TestMethod] + public void Test_1845() + { + } + [TestMethod] + public void Test_1846() + { + } + [TestMethod] + public void Test_1847() + { + } + [TestMethod] + public void Test_1848() + { + } + [TestMethod] + public void Test_1849() + { + } + [TestMethod] + public void Test_1850() + { + } + [TestMethod] + public void Test_1851() + { + } + [TestMethod] + public void Test_1852() + { + } + [TestMethod] + public void Test_1853() + { + } + [TestMethod] + public void Test_1854() + { + } + [TestMethod] + public void Test_1855() + { + } + [TestMethod] + public void Test_1856() + { + } + [TestMethod] + public void Test_1857() + { + } + [TestMethod] + public void Test_1858() + { + } + [TestMethod] + public void Test_1859() + { + } + [TestMethod] + public void Test_1860() + { + } + [TestMethod] + public void Test_1861() + { + } + [TestMethod] + public void Test_1862() + { + } + [TestMethod] + public void Test_1863() + { + } + [TestMethod] + public void Test_1864() + { + } + [TestMethod] + public void Test_1865() + { + } + [TestMethod] + public void Test_1866() + { + } + [TestMethod] + public void Test_1867() + { + } + [TestMethod] + public void Test_1868() + { + } + [TestMethod] + public void Test_1869() + { + } + [TestMethod] + public void Test_1870() + { + } + [TestMethod] + public void Test_1871() + { + } + [TestMethod] + public void Test_1872() + { + } + [TestMethod] + public void Test_1873() + { + } + [TestMethod] + public void Test_1874() + { + } + [TestMethod] + public void Test_1875() + { + } + [TestMethod] + public void Test_1876() + { + } + [TestMethod] + public void Test_1877() + { + } + [TestMethod] + public void Test_1878() + { + } + [TestMethod] + public void Test_1879() + { + } + [TestMethod] + public void Test_1880() + { + } + [TestMethod] + public void Test_1881() + { + } + [TestMethod] + public void Test_1882() + { + } + [TestMethod] + public void Test_1883() + { + } + [TestMethod] + public void Test_1884() + { + } + [TestMethod] + public void Test_1885() + { + } + [TestMethod] + public void Test_1886() + { + } + [TestMethod] + public void Test_1887() + { + } + [TestMethod] + public void Test_1888() + { + } + [TestMethod] + public void Test_1889() + { + } + [TestMethod] + public void Test_1890() + { + } + [TestMethod] + public void Test_1891() + { + } + [TestMethod] + public void Test_1892() + { + } + [TestMethod] + public void Test_1893() + { + } + [TestMethod] + public void Test_1894() + { + } + [TestMethod] + public void Test_1895() + { + } + [TestMethod] + public void Test_1896() + { + } + [TestMethod] + public void Test_1897() + { + } + [TestMethod] + public void Test_1898() + { + } + [TestMethod] + public void Test_1899() + { + } + [TestMethod] + public void Test_1900() + { + } + [TestMethod] + public void Test_1901() + { + } + [TestMethod] + public void Test_1902() + { + } + [TestMethod] + public void Test_1903() + { + } + [TestMethod] + public void Test_1904() + { + } + [TestMethod] + public void Test_1905() + { + } + [TestMethod] + public void Test_1906() + { + } + [TestMethod] + public void Test_1907() + { + } + [TestMethod] + public void Test_1908() + { + } + [TestMethod] + public void Test_1909() + { + } + [TestMethod] + public void Test_1910() + { + } + [TestMethod] + public void Test_1911() + { + } + [TestMethod] + public void Test_1912() + { + } + [TestMethod] + public void Test_1913() + { + } + [TestMethod] + public void Test_1914() + { + } + [TestMethod] + public void Test_1915() + { + } + [TestMethod] + public void Test_1916() + { + } + [TestMethod] + public void Test_1917() + { + } + [TestMethod] + public void Test_1918() + { + } + [TestMethod] + public void Test_1919() + { + } + [TestMethod] + public void Test_1920() + { + } + [TestMethod] + public void Test_1921() + { + } + [TestMethod] + public void Test_1922() + { + } + [TestMethod] + public void Test_1923() + { + } + [TestMethod] + public void Test_1924() + { + } + [TestMethod] + public void Test_1925() + { + } + [TestMethod] + public void Test_1926() + { + } + [TestMethod] + public void Test_1927() + { + } + [TestMethod] + public void Test_1928() + { + } + [TestMethod] + public void Test_1929() + { + } + [TestMethod] + public void Test_1930() + { + } + [TestMethod] + public void Test_1931() + { + } + [TestMethod] + public void Test_1932() + { + } + [TestMethod] + public void Test_1933() + { + } + [TestMethod] + public void Test_1934() + { + } + [TestMethod] + public void Test_1935() + { + } + [TestMethod] + public void Test_1936() + { + } + [TestMethod] + public void Test_1937() + { + } + [TestMethod] + public void Test_1938() + { + } + [TestMethod] + public void Test_1939() + { + } + [TestMethod] + public void Test_1940() + { + } + [TestMethod] + public void Test_1941() + { + } + [TestMethod] + public void Test_1942() + { + } + [TestMethod] + public void Test_1943() + { + } + [TestMethod] + public void Test_1944() + { + } + [TestMethod] + public void Test_1945() + { + } + [TestMethod] + public void Test_1946() + { + } + [TestMethod] + public void Test_1947() + { + } + [TestMethod] + public void Test_1948() + { + } + [TestMethod] + public void Test_1949() + { + } + [TestMethod] + public void Test_1950() + { + } + [TestMethod] + public void Test_1951() + { + } + [TestMethod] + public void Test_1952() + { + } + [TestMethod] + public void Test_1953() + { + } + [TestMethod] + public void Test_1954() + { + } + [TestMethod] + public void Test_1955() + { + } + [TestMethod] + public void Test_1956() + { + } + [TestMethod] + public void Test_1957() + { + } + [TestMethod] + public void Test_1958() + { + } + [TestMethod] + public void Test_1959() + { + } + [TestMethod] + public void Test_1960() + { + } + [TestMethod] + public void Test_1961() + { + } + [TestMethod] + public void Test_1962() + { + } + [TestMethod] + public void Test_1963() + { + } + [TestMethod] + public void Test_1964() + { + } + [TestMethod] + public void Test_1965() + { + } + [TestMethod] + public void Test_1966() + { + } + [TestMethod] + public void Test_1967() + { + } + [TestMethod] + public void Test_1968() + { + } + [TestMethod] + public void Test_1969() + { + } + [TestMethod] + public void Test_1970() + { + } + [TestMethod] + public void Test_1971() + { + } + [TestMethod] + public void Test_1972() + { + } + [TestMethod] + public void Test_1973() + { + } + [TestMethod] + public void Test_1974() + { + } + [TestMethod] + public void Test_1975() + { + } + [TestMethod] + public void Test_1976() + { + } + [TestMethod] + public void Test_1977() + { + } + [TestMethod] + public void Test_1978() + { + } + [TestMethod] + public void Test_1979() + { + } + [TestMethod] + public void Test_1980() + { + } + [TestMethod] + public void Test_1981() + { + } + [TestMethod] + public void Test_1982() + { + } + [TestMethod] + public void Test_1983() + { + } + [TestMethod] + public void Test_1984() + { + } + [TestMethod] + public void Test_1985() + { + } + [TestMethod] + public void Test_1986() + { + } + [TestMethod] + public void Test_1987() + { + } + [TestMethod] + public void Test_1988() + { + } + [TestMethod] + public void Test_1989() + { + } + [TestMethod] + public void Test_1990() + { + } + [TestMethod] + public void Test_1991() + { + } + [TestMethod] + public void Test_1992() + { + } + [TestMethod] + public void Test_1993() + { + } + [TestMethod] + public void Test_1994() + { + } + [TestMethod] + public void Test_1995() + { + } + [TestMethod] + public void Test_1996() + { + } + [TestMethod] + public void Test_1997() + { + } + [TestMethod] + public void Test_1998() + { + } + [TestMethod] + public void Test_1999() + { + } + [TestMethod] + public void Test_2000() + { + } + [TestMethod] + public void Test_2001() + { + } + [TestMethod] + public void Test_2002() + { + } + [TestMethod] + public void Test_2003() + { + } + [TestMethod] + public void Test_2004() + { + } + [TestMethod] + public void Test_2005() + { + } + [TestMethod] + public void Test_2006() + { + } + [TestMethod] + public void Test_2007() + { + } + [TestMethod] + public void Test_2008() + { + } + [TestMethod] + public void Test_2009() + { + } + [TestMethod] + public void Test_2010() + { + } + [TestMethod] + public void Test_2011() + { + } + [TestMethod] + public void Test_2012() + { + } + [TestMethod] + public void Test_2013() + { + } + [TestMethod] + public void Test_2014() + { + } + [TestMethod] + public void Test_2015() + { + } + [TestMethod] + public void Test_2016() + { + } + [TestMethod] + public void Test_2017() + { + } + [TestMethod] + public void Test_2018() + { + } + [TestMethod] + public void Test_2019() + { + } + [TestMethod] + public void Test_2020() + { + } + [TestMethod] + public void Test_2021() + { + } + [TestMethod] + public void Test_2022() + { + } + [TestMethod] + public void Test_2023() + { + } + [TestMethod] + public void Test_2024() + { + } + [TestMethod] + public void Test_2025() + { + } + [TestMethod] + public void Test_2026() + { + } + [TestMethod] + public void Test_2027() + { + } + [TestMethod] + public void Test_2028() + { + } + [TestMethod] + public void Test_2029() + { + } + [TestMethod] + public void Test_2030() + { + } + [TestMethod] + public void Test_2031() + { + } + [TestMethod] + public void Test_2032() + { + } + [TestMethod] + public void Test_2033() + { + } + [TestMethod] + public void Test_2034() + { + } + [TestMethod] + public void Test_2035() + { + } + [TestMethod] + public void Test_2036() + { + } + [TestMethod] + public void Test_2037() + { + } + [TestMethod] + public void Test_2038() + { + } + [TestMethod] + public void Test_2039() + { + } + [TestMethod] + public void Test_2040() + { + } + [TestMethod] + public void Test_2041() + { + } + [TestMethod] + public void Test_2042() + { + } + [TestMethod] + public void Test_2043() + { + } + [TestMethod] + public void Test_2044() + { + } + [TestMethod] + public void Test_2045() + { + } + [TestMethod] + public void Test_2046() + { + } + [TestMethod] + public void Test_2047() + { + } + [TestMethod] + public void Test_2048() + { + } + [TestMethod] + public void Test_2049() + { + } + [TestMethod] + public void Test_2050() + { + } + [TestMethod] + public void Test_2051() + { + } + [TestMethod] + public void Test_2052() + { + } + [TestMethod] + public void Test_2053() + { + } + [TestMethod] + public void Test_2054() + { + } + [TestMethod] + public void Test_2055() + { + } + [TestMethod] + public void Test_2056() + { + } + [TestMethod] + public void Test_2057() + { + } + [TestMethod] + public void Test_2058() + { + } + [TestMethod] + public void Test_2059() + { + } + [TestMethod] + public void Test_2060() + { + } + [TestMethod] + public void Test_2061() + { + } + [TestMethod] + public void Test_2062() + { + } + [TestMethod] + public void Test_2063() + { + } + [TestMethod] + public void Test_2064() + { + } + [TestMethod] + public void Test_2065() + { + } + [TestMethod] + public void Test_2066() + { + } + [TestMethod] + public void Test_2067() + { + } + [TestMethod] + public void Test_2068() + { + } + [TestMethod] + public void Test_2069() + { + } + [TestMethod] + public void Test_2070() + { + } + [TestMethod] + public void Test_2071() + { + } + [TestMethod] + public void Test_2072() + { + } + [TestMethod] + public void Test_2073() + { + } + [TestMethod] + public void Test_2074() + { + } + [TestMethod] + public void Test_2075() + { + } + [TestMethod] + public void Test_2076() + { + } + [TestMethod] + public void Test_2077() + { + } + [TestMethod] + public void Test_2078() + { + } + [TestMethod] + public void Test_2079() + { + } + [TestMethod] + public void Test_2080() + { + } + [TestMethod] + public void Test_2081() + { + } + [TestMethod] + public void Test_2082() + { + } + [TestMethod] + public void Test_2083() + { + } + [TestMethod] + public void Test_2084() + { + } + [TestMethod] + public void Test_2085() + { + } + [TestMethod] + public void Test_2086() + { + } + [TestMethod] + public void Test_2087() + { + } + [TestMethod] + public void Test_2088() + { + } + [TestMethod] + public void Test_2089() + { + } + [TestMethod] + public void Test_2090() + { + } + [TestMethod] + public void Test_2091() + { + } + [TestMethod] + public void Test_2092() + { + } + [TestMethod] + public void Test_2093() + { + } + [TestMethod] + public void Test_2094() + { + } + [TestMethod] + public void Test_2095() + { + } + [TestMethod] + public void Test_2096() + { + } + [TestMethod] + public void Test_2097() + { + } + [TestMethod] + public void Test_2098() + { + } + [TestMethod] + public void Test_2099() + { + } + [TestMethod] + public void Test_2100() + { + } + [TestMethod] + public void Test_2101() + { + } + [TestMethod] + public void Test_2102() + { + } + [TestMethod] + public void Test_2103() + { + } + [TestMethod] + public void Test_2104() + { + } + [TestMethod] + public void Test_2105() + { + } + [TestMethod] + public void Test_2106() + { + } + [TestMethod] + public void Test_2107() + { + } + [TestMethod] + public void Test_2108() + { + } + [TestMethod] + public void Test_2109() + { + } + [TestMethod] + public void Test_2110() + { + } + [TestMethod] + public void Test_2111() + { + } + [TestMethod] + public void Test_2112() + { + } + [TestMethod] + public void Test_2113() + { + } + [TestMethod] + public void Test_2114() + { + } + [TestMethod] + public void Test_2115() + { + } + [TestMethod] + public void Test_2116() + { + } + [TestMethod] + public void Test_2117() + { + } + [TestMethod] + public void Test_2118() + { + } + [TestMethod] + public void Test_2119() + { + } + [TestMethod] + public void Test_2120() + { + } + [TestMethod] + public void Test_2121() + { + } + [TestMethod] + public void Test_2122() + { + } + [TestMethod] + public void Test_2123() + { + } + [TestMethod] + public void Test_2124() + { + } + [TestMethod] + public void Test_2125() + { + } + [TestMethod] + public void Test_2126() + { + } + [TestMethod] + public void Test_2127() + { + } + [TestMethod] + public void Test_2128() + { + } + [TestMethod] + public void Test_2129() + { + } + [TestMethod] + public void Test_2130() + { + } + [TestMethod] + public void Test_2131() + { + } + [TestMethod] + public void Test_2132() + { + } + [TestMethod] + public void Test_2133() + { + } + [TestMethod] + public void Test_2134() + { + } + [TestMethod] + public void Test_2135() + { + } + [TestMethod] + public void Test_2136() + { + } + [TestMethod] + public void Test_2137() + { + } + [TestMethod] + public void Test_2138() + { + } + [TestMethod] + public void Test_2139() + { + } + [TestMethod] + public void Test_2140() + { + } + [TestMethod] + public void Test_2141() + { + } + [TestMethod] + public void Test_2142() + { + } + [TestMethod] + public void Test_2143() + { + } + [TestMethod] + public void Test_2144() + { + } + [TestMethod] + public void Test_2145() + { + } + [TestMethod] + public void Test_2146() + { + } + [TestMethod] + public void Test_2147() + { + } + [TestMethod] + public void Test_2148() + { + } + [TestMethod] + public void Test_2149() + { + } + [TestMethod] + public void Test_2150() + { + } + [TestMethod] + public void Test_2151() + { + } + [TestMethod] + public void Test_2152() + { + } + [TestMethod] + public void Test_2153() + { + } + [TestMethod] + public void Test_2154() + { + } + [TestMethod] + public void Test_2155() + { + } + [TestMethod] + public void Test_2156() + { + } + [TestMethod] + public void Test_2157() + { + } + [TestMethod] + public void Test_2158() + { + } + [TestMethod] + public void Test_2159() + { + } + [TestMethod] + public void Test_2160() + { + } + [TestMethod] + public void Test_2161() + { + } + [TestMethod] + public void Test_2162() + { + } + [TestMethod] + public void Test_2163() + { + } + [TestMethod] + public void Test_2164() + { + } + [TestMethod] + public void Test_2165() + { + } + [TestMethod] + public void Test_2166() + { + } + [TestMethod] + public void Test_2167() + { + } + [TestMethod] + public void Test_2168() + { + } + [TestMethod] + public void Test_2169() + { + } + [TestMethod] + public void Test_2170() + { + } + [TestMethod] + public void Test_2171() + { + } + [TestMethod] + public void Test_2172() + { + } + [TestMethod] + public void Test_2173() + { + } + [TestMethod] + public void Test_2174() + { + } + [TestMethod] + public void Test_2175() + { + } + [TestMethod] + public void Test_2176() + { + } + [TestMethod] + public void Test_2177() + { + } + [TestMethod] + public void Test_2178() + { + } + [TestMethod] + public void Test_2179() + { + } + [TestMethod] + public void Test_2180() + { + } + [TestMethod] + public void Test_2181() + { + } + [TestMethod] + public void Test_2182() + { + } + [TestMethod] + public void Test_2183() + { + } + [TestMethod] + public void Test_2184() + { + } + [TestMethod] + public void Test_2185() + { + } + [TestMethod] + public void Test_2186() + { + } + [TestMethod] + public void Test_2187() + { + } + [TestMethod] + public void Test_2188() + { + } + [TestMethod] + public void Test_2189() + { + } + [TestMethod] + public void Test_2190() + { + } + [TestMethod] + public void Test_2191() + { + } + [TestMethod] + public void Test_2192() + { + } + [TestMethod] + public void Test_2193() + { + } + [TestMethod] + public void Test_2194() + { + } + [TestMethod] + public void Test_2195() + { + } + [TestMethod] + public void Test_2196() + { + } + [TestMethod] + public void Test_2197() + { + } + [TestMethod] + public void Test_2198() + { + } + [TestMethod] + public void Test_2199() + { + } + [TestMethod] + public void Test_2200() + { + } + [TestMethod] + public void Test_2201() + { + } + [TestMethod] + public void Test_2202() + { + } + [TestMethod] + public void Test_2203() + { + } + [TestMethod] + public void Test_2204() + { + } + [TestMethod] + public void Test_2205() + { + } + [TestMethod] + public void Test_2206() + { + } + [TestMethod] + public void Test_2207() + { + } + [TestMethod] + public void Test_2208() + { + } + [TestMethod] + public void Test_2209() + { + } + [TestMethod] + public void Test_2210() + { + } + [TestMethod] + public void Test_2211() + { + } + [TestMethod] + public void Test_2212() + { + } + [TestMethod] + public void Test_2213() + { + } + [TestMethod] + public void Test_2214() + { + } + [TestMethod] + public void Test_2215() + { + } + [TestMethod] + public void Test_2216() + { + } + [TestMethod] + public void Test_2217() + { + } + [TestMethod] + public void Test_2218() + { + } + [TestMethod] + public void Test_2219() + { + } + [TestMethod] + public void Test_2220() + { + } + [TestMethod] + public void Test_2221() + { + } + [TestMethod] + public void Test_2222() + { + } + [TestMethod] + public void Test_2223() + { + } + [TestMethod] + public void Test_2224() + { + } + [TestMethod] + public void Test_2225() + { + } + [TestMethod] + public void Test_2226() + { + } + [TestMethod] + public void Test_2227() + { + } + [TestMethod] + public void Test_2228() + { + } + [TestMethod] + public void Test_2229() + { + } + [TestMethod] + public void Test_2230() + { + } + [TestMethod] + public void Test_2231() + { + } + [TestMethod] + public void Test_2232() + { + } + [TestMethod] + public void Test_2233() + { + } + [TestMethod] + public void Test_2234() + { + } + [TestMethod] + public void Test_2235() + { + } + [TestMethod] + public void Test_2236() + { + } + [TestMethod] + public void Test_2237() + { + } + [TestMethod] + public void Test_2238() + { + } + [TestMethod] + public void Test_2239() + { + } + [TestMethod] + public void Test_2240() + { + } + [TestMethod] + public void Test_2241() + { + } + [TestMethod] + public void Test_2242() + { + } + [TestMethod] + public void Test_2243() + { + } + [TestMethod] + public void Test_2244() + { + } + [TestMethod] + public void Test_2245() + { + } + [TestMethod] + public void Test_2246() + { + } + [TestMethod] + public void Test_2247() + { + } + [TestMethod] + public void Test_2248() + { + } + [TestMethod] + public void Test_2249() + { + } + [TestMethod] + public void Test_2250() + { + } + [TestMethod] + public void Test_2251() + { + } + [TestMethod] + public void Test_2252() + { + } + [TestMethod] + public void Test_2253() + { + } + [TestMethod] + public void Test_2254() + { + } + [TestMethod] + public void Test_2255() + { + } + [TestMethod] + public void Test_2256() + { + } + [TestMethod] + public void Test_2257() + { + } + [TestMethod] + public void Test_2258() + { + } + [TestMethod] + public void Test_2259() + { + } + [TestMethod] + public void Test_2260() + { + } + [TestMethod] + public void Test_2261() + { + } + [TestMethod] + public void Test_2262() + { + } + [TestMethod] + public void Test_2263() + { + } + [TestMethod] + public void Test_2264() + { + } + [TestMethod] + public void Test_2265() + { + } + [TestMethod] + public void Test_2266() + { + } + [TestMethod] + public void Test_2267() + { + } + [TestMethod] + public void Test_2268() + { + } + [TestMethod] + public void Test_2269() + { + } + [TestMethod] + public void Test_2270() + { + } + [TestMethod] + public void Test_2271() + { + } + [TestMethod] + public void Test_2272() + { + } + [TestMethod] + public void Test_2273() + { + } + [TestMethod] + public void Test_2274() + { + } + [TestMethod] + public void Test_2275() + { + } + [TestMethod] + public void Test_2276() + { + } + [TestMethod] + public void Test_2277() + { + } + [TestMethod] + public void Test_2278() + { + } + [TestMethod] + public void Test_2279() + { + } + [TestMethod] + public void Test_2280() + { + } + [TestMethod] + public void Test_2281() + { + } + [TestMethod] + public void Test_2282() + { + } + [TestMethod] + public void Test_2283() + { + } + [TestMethod] + public void Test_2284() + { + } + [TestMethod] + public void Test_2285() + { + } + [TestMethod] + public void Test_2286() + { + } + [TestMethod] + public void Test_2287() + { + } + [TestMethod] + public void Test_2288() + { + } + [TestMethod] + public void Test_2289() + { + } + [TestMethod] + public void Test_2290() + { + } + [TestMethod] + public void Test_2291() + { + } + [TestMethod] + public void Test_2292() + { + } + [TestMethod] + public void Test_2293() + { + } + [TestMethod] + public void Test_2294() + { + } + [TestMethod] + public void Test_2295() + { + } + [TestMethod] + public void Test_2296() + { + } + [TestMethod] + public void Test_2297() + { + } + [TestMethod] + public void Test_2298() + { + } + [TestMethod] + public void Test_2299() + { + } + [TestMethod] + public void Test_2300() + { + } + [TestMethod] + public void Test_2301() + { + } + [TestMethod] + public void Test_2302() + { + } + [TestMethod] + public void Test_2303() + { + } + [TestMethod] + public void Test_2304() + { + } + [TestMethod] + public void Test_2305() + { + } + [TestMethod] + public void Test_2306() + { + } + [TestMethod] + public void Test_2307() + { + } + [TestMethod] + public void Test_2308() + { + } + [TestMethod] + public void Test_2309() + { + } + [TestMethod] + public void Test_2310() + { + } + [TestMethod] + public void Test_2311() + { + } + [TestMethod] + public void Test_2312() + { + } + [TestMethod] + public void Test_2313() + { + } + [TestMethod] + public void Test_2314() + { + } + [TestMethod] + public void Test_2315() + { + } + [TestMethod] + public void Test_2316() + { + } + [TestMethod] + public void Test_2317() + { + } + [TestMethod] + public void Test_2318() + { + } + [TestMethod] + public void Test_2319() + { + } + [TestMethod] + public void Test_2320() + { + } + [TestMethod] + public void Test_2321() + { + } + [TestMethod] + public void Test_2322() + { + } + [TestMethod] + public void Test_2323() + { + } + [TestMethod] + public void Test_2324() + { + } + [TestMethod] + public void Test_2325() + { + } + [TestMethod] + public void Test_2326() + { + } + [TestMethod] + public void Test_2327() + { + } + [TestMethod] + public void Test_2328() + { + } + [TestMethod] + public void Test_2329() + { + } + [TestMethod] + public void Test_2330() + { + } + [TestMethod] + public void Test_2331() + { + } + [TestMethod] + public void Test_2332() + { + } + [TestMethod] + public void Test_2333() + { + } + [TestMethod] + public void Test_2334() + { + } + [TestMethod] + public void Test_2335() + { + } + [TestMethod] + public void Test_2336() + { + } + [TestMethod] + public void Test_2337() + { + } + [TestMethod] + public void Test_2338() + { + } + [TestMethod] + public void Test_2339() + { + } + [TestMethod] + public void Test_2340() + { + } + [TestMethod] + public void Test_2341() + { + } + [TestMethod] + public void Test_2342() + { + } + [TestMethod] + public void Test_2343() + { + } + [TestMethod] + public void Test_2344() + { + } + [TestMethod] + public void Test_2345() + { + } + [TestMethod] + public void Test_2346() + { + } + [TestMethod] + public void Test_2347() + { + } + [TestMethod] + public void Test_2348() + { + } + [TestMethod] + public void Test_2349() + { + } + [TestMethod] + public void Test_2350() + { + } + [TestMethod] + public void Test_2351() + { + } + [TestMethod] + public void Test_2352() + { + } + [TestMethod] + public void Test_2353() + { + } + [TestMethod] + public void Test_2354() + { + } + [TestMethod] + public void Test_2355() + { + } + [TestMethod] + public void Test_2356() + { + } + [TestMethod] + public void Test_2357() + { + } + [TestMethod] + public void Test_2358() + { + } + [TestMethod] + public void Test_2359() + { + } + [TestMethod] + public void Test_2360() + { + } + [TestMethod] + public void Test_2361() + { + } + [TestMethod] + public void Test_2362() + { + } + [TestMethod] + public void Test_2363() + { + } + [TestMethod] + public void Test_2364() + { + } + [TestMethod] + public void Test_2365() + { + } + [TestMethod] + public void Test_2366() + { + } + [TestMethod] + public void Test_2367() + { + } + [TestMethod] + public void Test_2368() + { + } + [TestMethod] + public void Test_2369() + { + } + [TestMethod] + public void Test_2370() + { + } + [TestMethod] + public void Test_2371() + { + } + [TestMethod] + public void Test_2372() + { + } + [TestMethod] + public void Test_2373() + { + } + [TestMethod] + public void Test_2374() + { + } + [TestMethod] + public void Test_2375() + { + } + [TestMethod] + public void Test_2376() + { + } + [TestMethod] + public void Test_2377() + { + } + [TestMethod] + public void Test_2378() + { + } + [TestMethod] + public void Test_2379() + { + } + [TestMethod] + public void Test_2380() + { + } + [TestMethod] + public void Test_2381() + { + } + [TestMethod] + public void Test_2382() + { + } + [TestMethod] + public void Test_2383() + { + } + [TestMethod] + public void Test_2384() + { + } + [TestMethod] + public void Test_2385() + { + } + [TestMethod] + public void Test_2386() + { + } + [TestMethod] + public void Test_2387() + { + } + [TestMethod] + public void Test_2388() + { + } + [TestMethod] + public void Test_2389() + { + } + [TestMethod] + public void Test_2390() + { + } + [TestMethod] + public void Test_2391() + { + } + [TestMethod] + public void Test_2392() + { + } + [TestMethod] + public void Test_2393() + { + } + [TestMethod] + public void Test_2394() + { + } + [TestMethod] + public void Test_2395() + { + } + [TestMethod] + public void Test_2396() + { + } + [TestMethod] + public void Test_2397() + { + } + [TestMethod] + public void Test_2398() + { + } + [TestMethod] + public void Test_2399() + { + } + [TestMethod] + public void Test_2400() + { + } + [TestMethod] + public void Test_2401() + { + } + [TestMethod] + public void Test_2402() + { + } + [TestMethod] + public void Test_2403() + { + } + [TestMethod] + public void Test_2404() + { + } + [TestMethod] + public void Test_2405() + { + } + [TestMethod] + public void Test_2406() + { + } + [TestMethod] + public void Test_2407() + { + } + [TestMethod] + public void Test_2408() + { + } + [TestMethod] + public void Test_2409() + { + } + [TestMethod] + public void Test_2410() + { + } + [TestMethod] + public void Test_2411() + { + } + [TestMethod] + public void Test_2412() + { + } + [TestMethod] + public void Test_2413() + { + } + [TestMethod] + public void Test_2414() + { + } + [TestMethod] + public void Test_2415() + { + } + [TestMethod] + public void Test_2416() + { + } + [TestMethod] + public void Test_2417() + { + } + [TestMethod] + public void Test_2418() + { + } + [TestMethod] + public void Test_2419() + { + } + [TestMethod] + public void Test_2420() + { + } + [TestMethod] + public void Test_2421() + { + } + [TestMethod] + public void Test_2422() + { + } + [TestMethod] + public void Test_2423() + { + } + [TestMethod] + public void Test_2424() + { + } + [TestMethod] + public void Test_2425() + { + } + [TestMethod] + public void Test_2426() + { + } + [TestMethod] + public void Test_2427() + { + } + [TestMethod] + public void Test_2428() + { + } + [TestMethod] + public void Test_2429() + { + } + [TestMethod] + public void Test_2430() + { + } + [TestMethod] + public void Test_2431() + { + } + [TestMethod] + public void Test_2432() + { + } + [TestMethod] + public void Test_2433() + { + } + [TestMethod] + public void Test_2434() + { + } + [TestMethod] + public void Test_2435() + { + } + [TestMethod] + public void Test_2436() + { + } + [TestMethod] + public void Test_2437() + { + } + [TestMethod] + public void Test_2438() + { + } + [TestMethod] + public void Test_2439() + { + } + [TestMethod] + public void Test_2440() + { + } + [TestMethod] + public void Test_2441() + { + } + [TestMethod] + public void Test_2442() + { + } + [TestMethod] + public void Test_2443() + { + } + [TestMethod] + public void Test_2444() + { + } + [TestMethod] + public void Test_2445() + { + } + [TestMethod] + public void Test_2446() + { + } + [TestMethod] + public void Test_2447() + { + } + [TestMethod] + public void Test_2448() + { + } + [TestMethod] + public void Test_2449() + { + } + [TestMethod] + public void Test_2450() + { + } + [TestMethod] + public void Test_2451() + { + } + [TestMethod] + public void Test_2452() + { + } + [TestMethod] + public void Test_2453() + { + } + [TestMethod] + public void Test_2454() + { + } + [TestMethod] + public void Test_2455() + { + } + [TestMethod] + public void Test_2456() + { + } + [TestMethod] + public void Test_2457() + { + } + [TestMethod] + public void Test_2458() + { + } + [TestMethod] + public void Test_2459() + { + } + [TestMethod] + public void Test_2460() + { + } + [TestMethod] + public void Test_2461() + { + } + [TestMethod] + public void Test_2462() + { + } + [TestMethod] + public void Test_2463() + { + } + [TestMethod] + public void Test_2464() + { + } + [TestMethod] + public void Test_2465() + { + } + [TestMethod] + public void Test_2466() + { + } + [TestMethod] + public void Test_2467() + { + } + [TestMethod] + public void Test_2468() + { + } + [TestMethod] + public void Test_2469() + { + } + [TestMethod] + public void Test_2470() + { + } + [TestMethod] + public void Test_2471() + { + } + [TestMethod] + public void Test_2472() + { + } + [TestMethod] + public void Test_2473() + { + } + [TestMethod] + public void Test_2474() + { + } + [TestMethod] + public void Test_2475() + { + } + [TestMethod] + public void Test_2476() + { + } + [TestMethod] + public void Test_2477() + { + } + [TestMethod] + public void Test_2478() + { + } + [TestMethod] + public void Test_2479() + { + } + [TestMethod] + public void Test_2480() + { + } + [TestMethod] + public void Test_2481() + { + } + [TestMethod] + public void Test_2482() + { + } + [TestMethod] + public void Test_2483() + { + } + [TestMethod] + public void Test_2484() + { + } + [TestMethod] + public void Test_2485() + { + } + [TestMethod] + public void Test_2486() + { + } + [TestMethod] + public void Test_2487() + { + } + [TestMethod] + public void Test_2488() + { + } + [TestMethod] + public void Test_2489() + { + } + [TestMethod] + public void Test_2490() + { + } + [TestMethod] + public void Test_2491() + { + } + [TestMethod] + public void Test_2492() + { + } + [TestMethod] + public void Test_2493() + { + } + [TestMethod] + public void Test_2494() + { + } + [TestMethod] + public void Test_2495() + { + } + [TestMethod] + public void Test_2496() + { + } + [TestMethod] + public void Test_2497() + { + } + [TestMethod] + public void Test_2498() + { + } + [TestMethod] + public void Test_2499() + { + } + [TestMethod] + public void Test_2500() + { + } + [TestMethod] + public void Test_2501() + { + } + [TestMethod] + public void Test_2502() + { + } + [TestMethod] + public void Test_2503() + { + } + [TestMethod] + public void Test_2504() + { + } + [TestMethod] + public void Test_2505() + { + } + [TestMethod] + public void Test_2506() + { + } + [TestMethod] + public void Test_2507() + { + } + [TestMethod] + public void Test_2508() + { + } + [TestMethod] + public void Test_2509() + { + } + [TestMethod] + public void Test_2510() + { + } + [TestMethod] + public void Test_2511() + { + } + [TestMethod] + public void Test_2512() + { + } + [TestMethod] + public void Test_2513() + { + } + [TestMethod] + public void Test_2514() + { + } + [TestMethod] + public void Test_2515() + { + } + [TestMethod] + public void Test_2516() + { + } + [TestMethod] + public void Test_2517() + { + } + [TestMethod] + public void Test_2518() + { + } + [TestMethod] + public void Test_2519() + { + } + [TestMethod] + public void Test_2520() + { + } + [TestMethod] + public void Test_2521() + { + } + [TestMethod] + public void Test_2522() + { + } + [TestMethod] + public void Test_2523() + { + } + [TestMethod] + public void Test_2524() + { + } + [TestMethod] + public void Test_2525() + { + } + [TestMethod] + public void Test_2526() + { + } + [TestMethod] + public void Test_2527() + { + } + [TestMethod] + public void Test_2528() + { + } + [TestMethod] + public void Test_2529() + { + } + [TestMethod] + public void Test_2530() + { + } + [TestMethod] + public void Test_2531() + { + } + [TestMethod] + public void Test_2532() + { + } + [TestMethod] + public void Test_2533() + { + } + [TestMethod] + public void Test_2534() + { + } + [TestMethod] + public void Test_2535() + { + } + [TestMethod] + public void Test_2536() + { + } + [TestMethod] + public void Test_2537() + { + } + [TestMethod] + public void Test_2538() + { + } + [TestMethod] + public void Test_2539() + { + } + [TestMethod] + public void Test_2540() + { + } + [TestMethod] + public void Test_2541() + { + } + [TestMethod] + public void Test_2542() + { + } + [TestMethod] + public void Test_2543() + { + } + [TestMethod] + public void Test_2544() + { + } + [TestMethod] + public void Test_2545() + { + } + [TestMethod] + public void Test_2546() + { + } + [TestMethod] + public void Test_2547() + { + } + [TestMethod] + public void Test_2548() + { + } + [TestMethod] + public void Test_2549() + { + } + [TestMethod] + public void Test_2550() + { + } + [TestMethod] + public void Test_2551() + { + } + [TestMethod] + public void Test_2552() + { + } + [TestMethod] + public void Test_2553() + { + } + [TestMethod] + public void Test_2554() + { + } + [TestMethod] + public void Test_2555() + { + } + [TestMethod] + public void Test_2556() + { + } + [TestMethod] + public void Test_2557() + { + } + [TestMethod] + public void Test_2558() + { + } + [TestMethod] + public void Test_2559() + { + } + [TestMethod] + public void Test_2560() + { + } + [TestMethod] + public void Test_2561() + { + } + [TestMethod] + public void Test_2562() + { + } + [TestMethod] + public void Test_2563() + { + } + [TestMethod] + public void Test_2564() + { + } + [TestMethod] + public void Test_2565() + { + } + [TestMethod] + public void Test_2566() + { + } + [TestMethod] + public void Test_2567() + { + } + [TestMethod] + public void Test_2568() + { + } + [TestMethod] + public void Test_2569() + { + } + [TestMethod] + public void Test_2570() + { + } + [TestMethod] + public void Test_2571() + { + } + [TestMethod] + public void Test_2572() + { + } + [TestMethod] + public void Test_2573() + { + } + [TestMethod] + public void Test_2574() + { + } + [TestMethod] + public void Test_2575() + { + } + [TestMethod] + public void Test_2576() + { + } + [TestMethod] + public void Test_2577() + { + } + [TestMethod] + public void Test_2578() + { + } + [TestMethod] + public void Test_2579() + { + } + [TestMethod] + public void Test_2580() + { + } + [TestMethod] + public void Test_2581() + { + } + [TestMethod] + public void Test_2582() + { + } + [TestMethod] + public void Test_2583() + { + } + [TestMethod] + public void Test_2584() + { + } + [TestMethod] + public void Test_2585() + { + } + [TestMethod] + public void Test_2586() + { + } + [TestMethod] + public void Test_2587() + { + } + [TestMethod] + public void Test_2588() + { + } + [TestMethod] + public void Test_2589() + { + } + [TestMethod] + public void Test_2590() + { + } + [TestMethod] + public void Test_2591() + { + } + [TestMethod] + public void Test_2592() + { + } + [TestMethod] + public void Test_2593() + { + } + [TestMethod] + public void Test_2594() + { + } + [TestMethod] + public void Test_2595() + { + } + [TestMethod] + public void Test_2596() + { + } + [TestMethod] + public void Test_2597() + { + } + [TestMethod] + public void Test_2598() + { + } + [TestMethod] + public void Test_2599() + { + } + [TestMethod] + public void Test_2600() + { + } + [TestMethod] + public void Test_2601() + { + } + [TestMethod] + public void Test_2602() + { + } + [TestMethod] + public void Test_2603() + { + } + [TestMethod] + public void Test_2604() + { + } + [TestMethod] + public void Test_2605() + { + } + [TestMethod] + public void Test_2606() + { + } + [TestMethod] + public void Test_2607() + { + } + [TestMethod] + public void Test_2608() + { + } + [TestMethod] + public void Test_2609() + { + } + [TestMethod] + public void Test_2610() + { + } + [TestMethod] + public void Test_2611() + { + } + [TestMethod] + public void Test_2612() + { + } + [TestMethod] + public void Test_2613() + { + } + [TestMethod] + public void Test_2614() + { + } + [TestMethod] + public void Test_2615() + { + } + [TestMethod] + public void Test_2616() + { + } + [TestMethod] + public void Test_2617() + { + } + [TestMethod] + public void Test_2618() + { + } + [TestMethod] + public void Test_2619() + { + } + [TestMethod] + public void Test_2620() + { + } + [TestMethod] + public void Test_2621() + { + } + [TestMethod] + public void Test_2622() + { + } + [TestMethod] + public void Test_2623() + { + } + [TestMethod] + public void Test_2624() + { + } + [TestMethod] + public void Test_2625() + { + } + [TestMethod] + public void Test_2626() + { + } + [TestMethod] + public void Test_2627() + { + } + [TestMethod] + public void Test_2628() + { + } + [TestMethod] + public void Test_2629() + { + } + [TestMethod] + public void Test_2630() + { + } + [TestMethod] + public void Test_2631() + { + } + [TestMethod] + public void Test_2632() + { + } + [TestMethod] + public void Test_2633() + { + } + [TestMethod] + public void Test_2634() + { + } + [TestMethod] + public void Test_2635() + { + } + [TestMethod] + public void Test_2636() + { + } + [TestMethod] + public void Test_2637() + { + } + [TestMethod] + public void Test_2638() + { + } + [TestMethod] + public void Test_2639() + { + } + [TestMethod] + public void Test_2640() + { + } + [TestMethod] + public void Test_2641() + { + } + [TestMethod] + public void Test_2642() + { + } + [TestMethod] + public void Test_2643() + { + } + [TestMethod] + public void Test_2644() + { + } + [TestMethod] + public void Test_2645() + { + } + [TestMethod] + public void Test_2646() + { + } + [TestMethod] + public void Test_2647() + { + } + [TestMethod] + public void Test_2648() + { + } + [TestMethod] + public void Test_2649() + { + } + [TestMethod] + public void Test_2650() + { + } + [TestMethod] + public void Test_2651() + { + } + [TestMethod] + public void Test_2652() + { + } + [TestMethod] + public void Test_2653() + { + } + [TestMethod] + public void Test_2654() + { + } + [TestMethod] + public void Test_2655() + { + } + [TestMethod] + public void Test_2656() + { + } + [TestMethod] + public void Test_2657() + { + } + [TestMethod] + public void Test_2658() + { + } + [TestMethod] + public void Test_2659() + { + } + [TestMethod] + public void Test_2660() + { + } + [TestMethod] + public void Test_2661() + { + } + [TestMethod] + public void Test_2662() + { + } + [TestMethod] + public void Test_2663() + { + } + [TestMethod] + public void Test_2664() + { + } + [TestMethod] + public void Test_2665() + { + } + [TestMethod] + public void Test_2666() + { + } + [TestMethod] + public void Test_2667() + { + } + [TestMethod] + public void Test_2668() + { + } + [TestMethod] + public void Test_2669() + { + } + [TestMethod] + public void Test_2670() + { + } + [TestMethod] + public void Test_2671() + { + } + [TestMethod] + public void Test_2672() + { + } + [TestMethod] + public void Test_2673() + { + } + [TestMethod] + public void Test_2674() + { + } + [TestMethod] + public void Test_2675() + { + } + [TestMethod] + public void Test_2676() + { + } + [TestMethod] + public void Test_2677() + { + } + [TestMethod] + public void Test_2678() + { + } + [TestMethod] + public void Test_2679() + { + } + [TestMethod] + public void Test_2680() + { + } + [TestMethod] + public void Test_2681() + { + } + [TestMethod] + public void Test_2682() + { + } + [TestMethod] + public void Test_2683() + { + } + [TestMethod] + public void Test_2684() + { + } + [TestMethod] + public void Test_2685() + { + } + [TestMethod] + public void Test_2686() + { + } + [TestMethod] + public void Test_2687() + { + } + [TestMethod] + public void Test_2688() + { + } + [TestMethod] + public void Test_2689() + { + } + [TestMethod] + public void Test_2690() + { + } + [TestMethod] + public void Test_2691() + { + } + [TestMethod] + public void Test_2692() + { + } + [TestMethod] + public void Test_2693() + { + } + [TestMethod] + public void Test_2694() + { + } + [TestMethod] + public void Test_2695() + { + } + [TestMethod] + public void Test_2696() + { + } + [TestMethod] + public void Test_2697() + { + } + [TestMethod] + public void Test_2698() + { + } + [TestMethod] + public void Test_2699() + { + } + [TestMethod] + public void Test_2700() + { + } + [TestMethod] + public void Test_2701() + { + } + [TestMethod] + public void Test_2702() + { + } + [TestMethod] + public void Test_2703() + { + } + [TestMethod] + public void Test_2704() + { + } + [TestMethod] + public void Test_2705() + { + } + [TestMethod] + public void Test_2706() + { + } + [TestMethod] + public void Test_2707() + { + } + [TestMethod] + public void Test_2708() + { + } + [TestMethod] + public void Test_2709() + { + } + [TestMethod] + public void Test_2710() + { + } + [TestMethod] + public void Test_2711() + { + } + [TestMethod] + public void Test_2712() + { + } + [TestMethod] + public void Test_2713() + { + } + [TestMethod] + public void Test_2714() + { + } + [TestMethod] + public void Test_2715() + { + } + [TestMethod] + public void Test_2716() + { + } + [TestMethod] + public void Test_2717() + { + } + [TestMethod] + public void Test_2718() + { + } + [TestMethod] + public void Test_2719() + { + } + [TestMethod] + public void Test_2720() + { + } + [TestMethod] + public void Test_2721() + { + } + [TestMethod] + public void Test_2722() + { + } + [TestMethod] + public void Test_2723() + { + } + [TestMethod] + public void Test_2724() + { + } + [TestMethod] + public void Test_2725() + { + } + [TestMethod] + public void Test_2726() + { + } + [TestMethod] + public void Test_2727() + { + } + [TestMethod] + public void Test_2728() + { + } + [TestMethod] + public void Test_2729() + { + } + [TestMethod] + public void Test_2730() + { + } + [TestMethod] + public void Test_2731() + { + } + [TestMethod] + public void Test_2732() + { + } + [TestMethod] + public void Test_2733() + { + } + [TestMethod] + public void Test_2734() + { + } + [TestMethod] + public void Test_2735() + { + } + [TestMethod] + public void Test_2736() + { + } + [TestMethod] + public void Test_2737() + { + } + [TestMethod] + public void Test_2738() + { + } + [TestMethod] + public void Test_2739() + { + } + [TestMethod] + public void Test_2740() + { + } + [TestMethod] + public void Test_2741() + { + } + [TestMethod] + public void Test_2742() + { + } + [TestMethod] + public void Test_2743() + { + } + [TestMethod] + public void Test_2744() + { + } + [TestMethod] + public void Test_2745() + { + } + [TestMethod] + public void Test_2746() + { + } + [TestMethod] + public void Test_2747() + { + } + [TestMethod] + public void Test_2748() + { + } + [TestMethod] + public void Test_2749() + { + } + [TestMethod] + public void Test_2750() + { + } + [TestMethod] + public void Test_2751() + { + } + [TestMethod] + public void Test_2752() + { + } + [TestMethod] + public void Test_2753() + { + } + [TestMethod] + public void Test_2754() + { + } + [TestMethod] + public void Test_2755() + { + } + [TestMethod] + public void Test_2756() + { + } + [TestMethod] + public void Test_2757() + { + } + [TestMethod] + public void Test_2758() + { + } + [TestMethod] + public void Test_2759() + { + } + [TestMethod] + public void Test_2760() + { + } + [TestMethod] + public void Test_2761() + { + } + [TestMethod] + public void Test_2762() + { + } + [TestMethod] + public void Test_2763() + { + } + [TestMethod] + public void Test_2764() + { + } + [TestMethod] + public void Test_2765() + { + } + [TestMethod] + public void Test_2766() + { + } + [TestMethod] + public void Test_2767() + { + } + [TestMethod] + public void Test_2768() + { + } + [TestMethod] + public void Test_2769() + { + } + [TestMethod] + public void Test_2770() + { + } + [TestMethod] + public void Test_2771() + { + } + [TestMethod] + public void Test_2772() + { + } + [TestMethod] + public void Test_2773() + { + } + [TestMethod] + public void Test_2774() + { + } + [TestMethod] + public void Test_2775() + { + } + [TestMethod] + public void Test_2776() + { + } + [TestMethod] + public void Test_2777() + { + } + [TestMethod] + public void Test_2778() + { + } + [TestMethod] + public void Test_2779() + { + } + [TestMethod] + public void Test_2780() + { + } + [TestMethod] + public void Test_2781() + { + } + [TestMethod] + public void Test_2782() + { + } + [TestMethod] + public void Test_2783() + { + } + [TestMethod] + public void Test_2784() + { + } + [TestMethod] + public void Test_2785() + { + } + [TestMethod] + public void Test_2786() + { + } + [TestMethod] + public void Test_2787() + { + } + [TestMethod] + public void Test_2788() + { + } + [TestMethod] + public void Test_2789() + { + } + [TestMethod] + public void Test_2790() + { + } + [TestMethod] + public void Test_2791() + { + } + [TestMethod] + public void Test_2792() + { + } + [TestMethod] + public void Test_2793() + { + } + [TestMethod] + public void Test_2794() + { + } + [TestMethod] + public void Test_2795() + { + } + [TestMethod] + public void Test_2796() + { + } + [TestMethod] + public void Test_2797() + { + } + [TestMethod] + public void Test_2798() + { + } + [TestMethod] + public void Test_2799() + { + } + [TestMethod] + public void Test_2800() + { + } + [TestMethod] + public void Test_2801() + { + } + [TestMethod] + public void Test_2802() + { + } + [TestMethod] + public void Test_2803() + { + } + [TestMethod] + public void Test_2804() + { + } + [TestMethod] + public void Test_2805() + { + } + [TestMethod] + public void Test_2806() + { + } + [TestMethod] + public void Test_2807() + { + } + [TestMethod] + public void Test_2808() + { + } + [TestMethod] + public void Test_2809() + { + } + [TestMethod] + public void Test_2810() + { + } + [TestMethod] + public void Test_2811() + { + } + [TestMethod] + public void Test_2812() + { + } + [TestMethod] + public void Test_2813() + { + } + [TestMethod] + public void Test_2814() + { + } + [TestMethod] + public void Test_2815() + { + } + [TestMethod] + public void Test_2816() + { + } + [TestMethod] + public void Test_2817() + { + } + [TestMethod] + public void Test_2818() + { + } + [TestMethod] + public void Test_2819() + { + } + [TestMethod] + public void Test_2820() + { + } + [TestMethod] + public void Test_2821() + { + } + [TestMethod] + public void Test_2822() + { + } + [TestMethod] + public void Test_2823() + { + } + [TestMethod] + public void Test_2824() + { + } + [TestMethod] + public void Test_2825() + { + } + [TestMethod] + public void Test_2826() + { + } + [TestMethod] + public void Test_2827() + { + } + [TestMethod] + public void Test_2828() + { + } + [TestMethod] + public void Test_2829() + { + } + [TestMethod] + public void Test_2830() + { + } + [TestMethod] + public void Test_2831() + { + } + [TestMethod] + public void Test_2832() + { + } + [TestMethod] + public void Test_2833() + { + } + [TestMethod] + public void Test_2834() + { + } + [TestMethod] + public void Test_2835() + { + } + [TestMethod] + public void Test_2836() + { + } + [TestMethod] + public void Test_2837() + { + } + [TestMethod] + public void Test_2838() + { + } + [TestMethod] + public void Test_2839() + { + } + [TestMethod] + public void Test_2840() + { + } + [TestMethod] + public void Test_2841() + { + } + [TestMethod] + public void Test_2842() + { + } + [TestMethod] + public void Test_2843() + { + } + [TestMethod] + public void Test_2844() + { + } + [TestMethod] + public void Test_2845() + { + } + [TestMethod] + public void Test_2846() + { + } + [TestMethod] + public void Test_2847() + { + } + [TestMethod] + public void Test_2848() + { + } + [TestMethod] + public void Test_2849() + { + } + [TestMethod] + public void Test_2850() + { + } + [TestMethod] + public void Test_2851() + { + } + [TestMethod] + public void Test_2852() + { + } + [TestMethod] + public void Test_2853() + { + } + [TestMethod] + public void Test_2854() + { + } + [TestMethod] + public void Test_2855() + { + } + [TestMethod] + public void Test_2856() + { + } + [TestMethod] + public void Test_2857() + { + } + [TestMethod] + public void Test_2858() + { + } + [TestMethod] + public void Test_2859() + { + } + [TestMethod] + public void Test_2860() + { + } + [TestMethod] + public void Test_2861() + { + } + [TestMethod] + public void Test_2862() + { + } + [TestMethod] + public void Test_2863() + { + } + [TestMethod] + public void Test_2864() + { + } + [TestMethod] + public void Test_2865() + { + } + [TestMethod] + public void Test_2866() + { + } + [TestMethod] + public void Test_2867() + { + } + [TestMethod] + public void Test_2868() + { + } + [TestMethod] + public void Test_2869() + { + } + [TestMethod] + public void Test_2870() + { + } + [TestMethod] + public void Test_2871() + { + } + [TestMethod] + public void Test_2872() + { + } + [TestMethod] + public void Test_2873() + { + } + [TestMethod] + public void Test_2874() + { + } + [TestMethod] + public void Test_2875() + { + } + [TestMethod] + public void Test_2876() + { + } + [TestMethod] + public void Test_2877() + { + } + [TestMethod] + public void Test_2878() + { + } + [TestMethod] + public void Test_2879() + { + } + [TestMethod] + public void Test_2880() + { + } + [TestMethod] + public void Test_2881() + { + } + [TestMethod] + public void Test_2882() + { + } + [TestMethod] + public void Test_2883() + { + } + [TestMethod] + public void Test_2884() + { + } + [TestMethod] + public void Test_2885() + { + } + [TestMethod] + public void Test_2886() + { + } + [TestMethod] + public void Test_2887() + { + } + [TestMethod] + public void Test_2888() + { + } + [TestMethod] + public void Test_2889() + { + } + [TestMethod] + public void Test_2890() + { + } + [TestMethod] + public void Test_2891() + { + } + [TestMethod] + public void Test_2892() + { + } + [TestMethod] + public void Test_2893() + { + } + [TestMethod] + public void Test_2894() + { + } + [TestMethod] + public void Test_2895() + { + } + [TestMethod] + public void Test_2896() + { + } + [TestMethod] + public void Test_2897() + { + } + [TestMethod] + public void Test_2898() + { + } + [TestMethod] + public void Test_2899() + { + } + [TestMethod] + public void Test_2900() + { + } + [TestMethod] + public void Test_2901() + { + } + [TestMethod] + public void Test_2902() + { + } + [TestMethod] + public void Test_2903() + { + } + [TestMethod] + public void Test_2904() + { + } + [TestMethod] + public void Test_2905() + { + } + [TestMethod] + public void Test_2906() + { + } + [TestMethod] + public void Test_2907() + { + } + [TestMethod] + public void Test_2908() + { + } + [TestMethod] + public void Test_2909() + { + } + [TestMethod] + public void Test_2910() + { + } + [TestMethod] + public void Test_2911() + { + } + [TestMethod] + public void Test_2912() + { + } + [TestMethod] + public void Test_2913() + { + } + [TestMethod] + public void Test_2914() + { + } + [TestMethod] + public void Test_2915() + { + } + [TestMethod] + public void Test_2916() + { + } + [TestMethod] + public void Test_2917() + { + } + [TestMethod] + public void Test_2918() + { + } + [TestMethod] + public void Test_2919() + { + } + [TestMethod] + public void Test_2920() + { + } + [TestMethod] + public void Test_2921() + { + } + [TestMethod] + public void Test_2922() + { + } + [TestMethod] + public void Test_2923() + { + } + [TestMethod] + public void Test_2924() + { + } + [TestMethod] + public void Test_2925() + { + } + [TestMethod] + public void Test_2926() + { + } + [TestMethod] + public void Test_2927() + { + } + [TestMethod] + public void Test_2928() + { + } + [TestMethod] + public void Test_2929() + { + } + [TestMethod] + public void Test_2930() + { + } + [TestMethod] + public void Test_2931() + { + } + [TestMethod] + public void Test_2932() + { + } + [TestMethod] + public void Test_2933() + { + } + [TestMethod] + public void Test_2934() + { + } + [TestMethod] + public void Test_2935() + { + } + [TestMethod] + public void Test_2936() + { + } + [TestMethod] + public void Test_2937() + { + } + [TestMethod] + public void Test_2938() + { + } + [TestMethod] + public void Test_2939() + { + } + [TestMethod] + public void Test_2940() + { + } + [TestMethod] + public void Test_2941() + { + } + [TestMethod] + public void Test_2942() + { + } + [TestMethod] + public void Test_2943() + { + } + [TestMethod] + public void Test_2944() + { + } + [TestMethod] + public void Test_2945() + { + } + [TestMethod] + public void Test_2946() + { + } + [TestMethod] + public void Test_2947() + { + } + [TestMethod] + public void Test_2948() + { + } + [TestMethod] + public void Test_2949() + { + } + [TestMethod] + public void Test_2950() + { + } + [TestMethod] + public void Test_2951() + { + } + [TestMethod] + public void Test_2952() + { + } + [TestMethod] + public void Test_2953() + { + } + [TestMethod] + public void Test_2954() + { + } + [TestMethod] + public void Test_2955() + { + } + [TestMethod] + public void Test_2956() + { + } + [TestMethod] + public void Test_2957() + { + } + [TestMethod] + public void Test_2958() + { + } + [TestMethod] + public void Test_2959() + { + } + [TestMethod] + public void Test_2960() + { + } + [TestMethod] + public void Test_2961() + { + } + [TestMethod] + public void Test_2962() + { + } + [TestMethod] + public void Test_2963() + { + } + [TestMethod] + public void Test_2964() + { + } + [TestMethod] + public void Test_2965() + { + } + [TestMethod] + public void Test_2966() + { + } + [TestMethod] + public void Test_2967() + { + } + [TestMethod] + public void Test_2968() + { + } + [TestMethod] + public void Test_2969() + { + } + [TestMethod] + public void Test_2970() + { + } + [TestMethod] + public void Test_2971() + { + } + [TestMethod] + public void Test_2972() + { + } + [TestMethod] + public void Test_2973() + { + } + [TestMethod] + public void Test_2974() + { + } + [TestMethod] + public void Test_2975() + { + } + [TestMethod] + public void Test_2976() + { + } + [TestMethod] + public void Test_2977() + { + } + [TestMethod] + public void Test_2978() + { + } + [TestMethod] + public void Test_2979() + { + } + [TestMethod] + public void Test_2980() + { + } + [TestMethod] + public void Test_2981() + { + } + [TestMethod] + public void Test_2982() + { + } + [TestMethod] + public void Test_2983() + { + } + [TestMethod] + public void Test_2984() + { + } + [TestMethod] + public void Test_2985() + { + } + [TestMethod] + public void Test_2986() + { + } + [TestMethod] + public void Test_2987() + { + } + [TestMethod] + public void Test_2988() + { + } + [TestMethod] + public void Test_2989() + { + } + [TestMethod] + public void Test_2990() + { + } + [TestMethod] + public void Test_2991() + { + } + [TestMethod] + public void Test_2992() + { + } + [TestMethod] + public void Test_2993() + { + } + [TestMethod] + public void Test_2994() + { + } + [TestMethod] + public void Test_2995() + { + } + [TestMethod] + public void Test_2996() + { + } + [TestMethod] + public void Test_2997() + { + } + [TestMethod] + public void Test_2998() + { + } + [TestMethod] + public void Test_2999() + { + } + [TestMethod] + public void Test_3000() + { + } + [TestMethod] + public void Test_3001() + { + } + [TestMethod] + public void Test_3002() + { + } + [TestMethod] + public void Test_3003() + { + } + [TestMethod] + public void Test_3004() + { + } + [TestMethod] + public void Test_3005() + { + } + [TestMethod] + public void Test_3006() + { + } + [TestMethod] + public void Test_3007() + { + } + [TestMethod] + public void Test_3008() + { + } + [TestMethod] + public void Test_3009() + { + } + [TestMethod] + public void Test_3010() + { + } + [TestMethod] + public void Test_3011() + { + } + [TestMethod] + public void Test_3012() + { + } + [TestMethod] + public void Test_3013() + { + } + [TestMethod] + public void Test_3014() + { + } + [TestMethod] + public void Test_3015() + { + } + [TestMethod] + public void Test_3016() + { + } + [TestMethod] + public void Test_3017() + { + } + [TestMethod] + public void Test_3018() + { + } + [TestMethod] + public void Test_3019() + { + } + [TestMethod] + public void Test_3020() + { + } + [TestMethod] + public void Test_3021() + { + } + [TestMethod] + public void Test_3022() + { + } + [TestMethod] + public void Test_3023() + { + } + [TestMethod] + public void Test_3024() + { + } + [TestMethod] + public void Test_3025() + { + } + [TestMethod] + public void Test_3026() + { + } + [TestMethod] + public void Test_3027() + { + } + [TestMethod] + public void Test_3028() + { + } + [TestMethod] + public void Test_3029() + { + } + [TestMethod] + public void Test_3030() + { + } + [TestMethod] + public void Test_3031() + { + } + [TestMethod] + public void Test_3032() + { + } + [TestMethod] + public void Test_3033() + { + } + [TestMethod] + public void Test_3034() + { + } + [TestMethod] + public void Test_3035() + { + } + [TestMethod] + public void Test_3036() + { + } + [TestMethod] + public void Test_3037() + { + } + [TestMethod] + public void Test_3038() + { + } + [TestMethod] + public void Test_3039() + { + } + [TestMethod] + public void Test_3040() + { + } + [TestMethod] + public void Test_3041() + { + } + [TestMethod] + public void Test_3042() + { + } + [TestMethod] + public void Test_3043() + { + } + [TestMethod] + public void Test_3044() + { + } + [TestMethod] + public void Test_3045() + { + } + [TestMethod] + public void Test_3046() + { + } + [TestMethod] + public void Test_3047() + { + } + [TestMethod] + public void Test_3048() + { + } + [TestMethod] + public void Test_3049() + { + } + [TestMethod] + public void Test_3050() + { + } + [TestMethod] + public void Test_3051() + { + } + [TestMethod] + public void Test_3052() + { + } + [TestMethod] + public void Test_3053() + { + } + [TestMethod] + public void Test_3054() + { + } + [TestMethod] + public void Test_3055() + { + } + [TestMethod] + public void Test_3056() + { + } + [TestMethod] + public void Test_3057() + { + } + [TestMethod] + public void Test_3058() + { + } + [TestMethod] + public void Test_3059() + { + } + [TestMethod] + public void Test_3060() + { + } + [TestMethod] + public void Test_3061() + { + } + [TestMethod] + public void Test_3062() + { + } + [TestMethod] + public void Test_3063() + { + } + [TestMethod] + public void Test_3064() + { + } + [TestMethod] + public void Test_3065() + { + } + [TestMethod] + public void Test_3066() + { + } + [TestMethod] + public void Test_3067() + { + } + [TestMethod] + public void Test_3068() + { + } + [TestMethod] + public void Test_3069() + { + } + [TestMethod] + public void Test_3070() + { + } + [TestMethod] + public void Test_3071() + { + } + [TestMethod] + public void Test_3072() + { + } + [TestMethod] + public void Test_3073() + { + } + [TestMethod] + public void Test_3074() + { + } + [TestMethod] + public void Test_3075() + { + } + [TestMethod] + public void Test_3076() + { + } + [TestMethod] + public void Test_3077() + { + } + [TestMethod] + public void Test_3078() + { + } + [TestMethod] + public void Test_3079() + { + } + [TestMethod] + public void Test_3080() + { + } + [TestMethod] + public void Test_3081() + { + } + [TestMethod] + public void Test_3082() + { + } + [TestMethod] + public void Test_3083() + { + } + [TestMethod] + public void Test_3084() + { + } + [TestMethod] + public void Test_3085() + { + } + [TestMethod] + public void Test_3086() + { + } + [TestMethod] + public void Test_3087() + { + } + [TestMethod] + public void Test_3088() + { + } + [TestMethod] + public void Test_3089() + { + } + [TestMethod] + public void Test_3090() + { + } + [TestMethod] + public void Test_3091() + { + } + [TestMethod] + public void Test_3092() + { + } + [TestMethod] + public void Test_3093() + { + } + [TestMethod] + public void Test_3094() + { + } + [TestMethod] + public void Test_3095() + { + } + [TestMethod] + public void Test_3096() + { + } + [TestMethod] + public void Test_3097() + { + } + [TestMethod] + public void Test_3098() + { + } + [TestMethod] + public void Test_3099() + { + } + [TestMethod] + public void Test_3100() + { + } + [TestMethod] + public void Test_3101() + { + } + [TestMethod] + public void Test_3102() + { + } + [TestMethod] + public void Test_3103() + { + } + [TestMethod] + public void Test_3104() + { + } + [TestMethod] + public void Test_3105() + { + } + [TestMethod] + public void Test_3106() + { + } + [TestMethod] + public void Test_3107() + { + } + [TestMethod] + public void Test_3108() + { + } + [TestMethod] + public void Test_3109() + { + } + [TestMethod] + public void Test_3110() + { + } + [TestMethod] + public void Test_3111() + { + } + [TestMethod] + public void Test_3112() + { + } + [TestMethod] + public void Test_3113() + { + } + [TestMethod] + public void Test_3114() + { + } + [TestMethod] + public void Test_3115() + { + } + [TestMethod] + public void Test_3116() + { + } + [TestMethod] + public void Test_3117() + { + } + [TestMethod] + public void Test_3118() + { + } + [TestMethod] + public void Test_3119() + { + } + [TestMethod] + public void Test_3120() + { + } + [TestMethod] + public void Test_3121() + { + } + [TestMethod] + public void Test_3122() + { + } + [TestMethod] + public void Test_3123() + { + } + [TestMethod] + public void Test_3124() + { + } + [TestMethod] + public void Test_3125() + { + } + [TestMethod] + public void Test_3126() + { + } + [TestMethod] + public void Test_3127() + { + } + [TestMethod] + public void Test_3128() + { + } + [TestMethod] + public void Test_3129() + { + } + [TestMethod] + public void Test_3130() + { + } + [TestMethod] + public void Test_3131() + { + } + [TestMethod] + public void Test_3132() + { + } + [TestMethod] + public void Test_3133() + { + } + [TestMethod] + public void Test_3134() + { + } + [TestMethod] + public void Test_3135() + { + } + [TestMethod] + public void Test_3136() + { + } + [TestMethod] + public void Test_3137() + { + } + [TestMethod] + public void Test_3138() + { + } + [TestMethod] + public void Test_3139() + { + } + [TestMethod] + public void Test_3140() + { + } + [TestMethod] + public void Test_3141() + { + } + [TestMethod] + public void Test_3142() + { + } + [TestMethod] + public void Test_3143() + { + } + [TestMethod] + public void Test_3144() + { + } + [TestMethod] + public void Test_3145() + { + } + [TestMethod] + public void Test_3146() + { + } + [TestMethod] + public void Test_3147() + { + } + [TestMethod] + public void Test_3148() + { + } + [TestMethod] + public void Test_3149() + { + } + [TestMethod] + public void Test_3150() + { + } + [TestMethod] + public void Test_3151() + { + } + [TestMethod] + public void Test_3152() + { + } + [TestMethod] + public void Test_3153() + { + } + [TestMethod] + public void Test_3154() + { + } + [TestMethod] + public void Test_3155() + { + } + [TestMethod] + public void Test_3156() + { + } + [TestMethod] + public void Test_3157() + { + } + [TestMethod] + public void Test_3158() + { + } + [TestMethod] + public void Test_3159() + { + } + [TestMethod] + public void Test_3160() + { + } + [TestMethod] + public void Test_3161() + { + } + [TestMethod] + public void Test_3162() + { + } + [TestMethod] + public void Test_3163() + { + } + [TestMethod] + public void Test_3164() + { + } + [TestMethod] + public void Test_3165() + { + } + [TestMethod] + public void Test_3166() + { + } + [TestMethod] + public void Test_3167() + { + } + [TestMethod] + public void Test_3168() + { + } + [TestMethod] + public void Test_3169() + { + } + [TestMethod] + public void Test_3170() + { + } + [TestMethod] + public void Test_3171() + { + } + [TestMethod] + public void Test_3172() + { + } + [TestMethod] + public void Test_3173() + { + } + [TestMethod] + public void Test_3174() + { + } + [TestMethod] + public void Test_3175() + { + } + [TestMethod] + public void Test_3176() + { + } + [TestMethod] + public void Test_3177() + { + } + [TestMethod] + public void Test_3178() + { + } + [TestMethod] + public void Test_3179() + { + } + [TestMethod] + public void Test_3180() + { + } + [TestMethod] + public void Test_3181() + { + } + [TestMethod] + public void Test_3182() + { + } + [TestMethod] + public void Test_3183() + { + } + [TestMethod] + public void Test_3184() + { + } + [TestMethod] + public void Test_3185() + { + } + [TestMethod] + public void Test_3186() + { + } + [TestMethod] + public void Test_3187() + { + } + [TestMethod] + public void Test_3188() + { + } + [TestMethod] + public void Test_3189() + { + } + [TestMethod] + public void Test_3190() + { + } + [TestMethod] + public void Test_3191() + { + } + [TestMethod] + public void Test_3192() + { + } + [TestMethod] + public void Test_3193() + { + } + [TestMethod] + public void Test_3194() + { + } + [TestMethod] + public void Test_3195() + { + } + [TestMethod] + public void Test_3196() + { + } + [TestMethod] + public void Test_3197() + { + } + [TestMethod] + public void Test_3198() + { + } + [TestMethod] + public void Test_3199() + { + } + [TestMethod] + public void Test_3200() + { + } + [TestMethod] + public void Test_3201() + { + } + [TestMethod] + public void Test_3202() + { + } + [TestMethod] + public void Test_3203() + { + } + [TestMethod] + public void Test_3204() + { + } + [TestMethod] + public void Test_3205() + { + } + [TestMethod] + public void Test_3206() + { + } + [TestMethod] + public void Test_3207() + { + } + [TestMethod] + public void Test_3208() + { + } + [TestMethod] + public void Test_3209() + { + } + [TestMethod] + public void Test_3210() + { + } + [TestMethod] + public void Test_3211() + { + } + [TestMethod] + public void Test_3212() + { + } + [TestMethod] + public void Test_3213() + { + } + [TestMethod] + public void Test_3214() + { + } + [TestMethod] + public void Test_3215() + { + } + [TestMethod] + public void Test_3216() + { + } + [TestMethod] + public void Test_3217() + { + } + [TestMethod] + public void Test_3218() + { + } + [TestMethod] + public void Test_3219() + { + } + [TestMethod] + public void Test_3220() + { + } + [TestMethod] + public void Test_3221() + { + } + [TestMethod] + public void Test_3222() + { + } + [TestMethod] + public void Test_3223() + { + } + [TestMethod] + public void Test_3224() + { + } + [TestMethod] + public void Test_3225() + { + } + [TestMethod] + public void Test_3226() + { + } + [TestMethod] + public void Test_3227() + { + } + [TestMethod] + public void Test_3228() + { + } + [TestMethod] + public void Test_3229() + { + } + [TestMethod] + public void Test_3230() + { + } + [TestMethod] + public void Test_3231() + { + } + [TestMethod] + public void Test_3232() + { + } + [TestMethod] + public void Test_3233() + { + } + [TestMethod] + public void Test_3234() + { + } + [TestMethod] + public void Test_3235() + { + } + [TestMethod] + public void Test_3236() + { + } + [TestMethod] + public void Test_3237() + { + } + [TestMethod] + public void Test_3238() + { + } + [TestMethod] + public void Test_3239() + { + } + [TestMethod] + public void Test_3240() + { + } + [TestMethod] + public void Test_3241() + { + } + [TestMethod] + public void Test_3242() + { + } + [TestMethod] + public void Test_3243() + { + } + [TestMethod] + public void Test_3244() + { + } + [TestMethod] + public void Test_3245() + { + } + [TestMethod] + public void Test_3246() + { + } + [TestMethod] + public void Test_3247() + { + } + [TestMethod] + public void Test_3248() + { + } + [TestMethod] + public void Test_3249() + { + } + [TestMethod] + public void Test_3250() + { + } + [TestMethod] + public void Test_3251() + { + } + [TestMethod] + public void Test_3252() + { + } + [TestMethod] + public void Test_3253() + { + } + [TestMethod] + public void Test_3254() + { + } + [TestMethod] + public void Test_3255() + { + } + [TestMethod] + public void Test_3256() + { + } + [TestMethod] + public void Test_3257() + { + } + [TestMethod] + public void Test_3258() + { + } + [TestMethod] + public void Test_3259() + { + } + [TestMethod] + public void Test_3260() + { + } + [TestMethod] + public void Test_3261() + { + } + [TestMethod] + public void Test_3262() + { + } + [TestMethod] + public void Test_3263() + { + } + [TestMethod] + public void Test_3264() + { + } + [TestMethod] + public void Test_3265() + { + } + [TestMethod] + public void Test_3266() + { + } + [TestMethod] + public void Test_3267() + { + } + [TestMethod] + public void Test_3268() + { + } + [TestMethod] + public void Test_3269() + { + } + [TestMethod] + public void Test_3270() + { + } + [TestMethod] + public void Test_3271() + { + } + [TestMethod] + public void Test_3272() + { + } + [TestMethod] + public void Test_3273() + { + } + [TestMethod] + public void Test_3274() + { + } + [TestMethod] + public void Test_3275() + { + } + [TestMethod] + public void Test_3276() + { + } + [TestMethod] + public void Test_3277() + { + } + [TestMethod] + public void Test_3278() + { + } + [TestMethod] + public void Test_3279() + { + } + [TestMethod] + public void Test_3280() + { + } + [TestMethod] + public void Test_3281() + { + } + [TestMethod] + public void Test_3282() + { + } + [TestMethod] + public void Test_3283() + { + } + [TestMethod] + public void Test_3284() + { + } + [TestMethod] + public void Test_3285() + { + } + [TestMethod] + public void Test_3286() + { + } + [TestMethod] + public void Test_3287() + { + } + [TestMethod] + public void Test_3288() + { + } + [TestMethod] + public void Test_3289() + { + } + [TestMethod] + public void Test_3290() + { + } + [TestMethod] + public void Test_3291() + { + } + [TestMethod] + public void Test_3292() + { + } + [TestMethod] + public void Test_3293() + { + } + [TestMethod] + public void Test_3294() + { + } + [TestMethod] + public void Test_3295() + { + } + [TestMethod] + public void Test_3296() + { + } + [TestMethod] + public void Test_3297() + { + } + [TestMethod] + public void Test_3298() + { + } + [TestMethod] + public void Test_3299() + { + } + [TestMethod] + public void Test_3300() + { + } + [TestMethod] + public void Test_3301() + { + } + [TestMethod] + public void Test_3302() + { + } + [TestMethod] + public void Test_3303() + { + } + [TestMethod] + public void Test_3304() + { + } + [TestMethod] + public void Test_3305() + { + } + [TestMethod] + public void Test_3306() + { + } + [TestMethod] + public void Test_3307() + { + } + [TestMethod] + public void Test_3308() + { + } + [TestMethod] + public void Test_3309() + { + } + [TestMethod] + public void Test_3310() + { + } + [TestMethod] + public void Test_3311() + { + } + [TestMethod] + public void Test_3312() + { + } + [TestMethod] + public void Test_3313() + { + } + [TestMethod] + public void Test_3314() + { + } + [TestMethod] + public void Test_3315() + { + } + [TestMethod] + public void Test_3316() + { + } + [TestMethod] + public void Test_3317() + { + } + [TestMethod] + public void Test_3318() + { + } + [TestMethod] + public void Test_3319() + { + } + [TestMethod] + public void Test_3320() + { + } + [TestMethod] + public void Test_3321() + { + } + [TestMethod] + public void Test_3322() + { + } + [TestMethod] + public void Test_3323() + { + } + [TestMethod] + public void Test_3324() + { + } + [TestMethod] + public void Test_3325() + { + } + [TestMethod] + public void Test_3326() + { + } + [TestMethod] + public void Test_3327() + { + } + [TestMethod] + public void Test_3328() + { + } + [TestMethod] + public void Test_3329() + { + } + [TestMethod] + public void Test_3330() + { + } + [TestMethod] + public void Test_3331() + { + } + [TestMethod] + public void Test_3332() + { + } + [TestMethod] + public void Test_3333() + { + } + [TestMethod] + public void Test_3334() + { + } + [TestMethod] + public void Test_3335() + { + } + [TestMethod] + public void Test_3336() + { + } + [TestMethod] + public void Test_3337() + { + } + [TestMethod] + public void Test_3338() + { + } + [TestMethod] + public void Test_3339() + { + } + [TestMethod] + public void Test_3340() + { + } + [TestMethod] + public void Test_3341() + { + } + [TestMethod] + public void Test_3342() + { + } + [TestMethod] + public void Test_3343() + { + } + [TestMethod] + public void Test_3344() + { + } + [TestMethod] + public void Test_3345() + { + } + [TestMethod] + public void Test_3346() + { + } + [TestMethod] + public void Test_3347() + { + } + [TestMethod] + public void Test_3348() + { + } + [TestMethod] + public void Test_3349() + { + } + [TestMethod] + public void Test_3350() + { + } + [TestMethod] + public void Test_3351() + { + } + [TestMethod] + public void Test_3352() + { + } + [TestMethod] + public void Test_3353() + { + } + [TestMethod] + public void Test_3354() + { + } + [TestMethod] + public void Test_3355() + { + } + [TestMethod] + public void Test_3356() + { + } + [TestMethod] + public void Test_3357() + { + } + [TestMethod] + public void Test_3358() + { + } + [TestMethod] + public void Test_3359() + { + } + [TestMethod] + public void Test_3360() + { + } + [TestMethod] + public void Test_3361() + { + } + [TestMethod] + public void Test_3362() + { + } + [TestMethod] + public void Test_3363() + { + } + [TestMethod] + public void Test_3364() + { + } + [TestMethod] + public void Test_3365() + { + } + [TestMethod] + public void Test_3366() + { + } + [TestMethod] + public void Test_3367() + { + } + [TestMethod] + public void Test_3368() + { + } + [TestMethod] + public void Test_3369() + { + } + [TestMethod] + public void Test_3370() + { + } + [TestMethod] + public void Test_3371() + { + } + [TestMethod] + public void Test_3372() + { + } + [TestMethod] + public void Test_3373() + { + } + [TestMethod] + public void Test_3374() + { + } + [TestMethod] + public void Test_3375() + { + } + [TestMethod] + public void Test_3376() + { + } + [TestMethod] + public void Test_3377() + { + } + [TestMethod] + public void Test_3378() + { + } + [TestMethod] + public void Test_3379() + { + } + [TestMethod] + public void Test_3380() + { + } + [TestMethod] + public void Test_3381() + { + } + [TestMethod] + public void Test_3382() + { + } + [TestMethod] + public void Test_3383() + { + } + [TestMethod] + public void Test_3384() + { + } + [TestMethod] + public void Test_3385() + { + } + [TestMethod] + public void Test_3386() + { + } + [TestMethod] + public void Test_3387() + { + } + [TestMethod] + public void Test_3388() + { + } + [TestMethod] + public void Test_3389() + { + } + [TestMethod] + public void Test_3390() + { + } + [TestMethod] + public void Test_3391() + { + } + [TestMethod] + public void Test_3392() + { + } + [TestMethod] + public void Test_3393() + { + } + [TestMethod] + public void Test_3394() + { + } + [TestMethod] + public void Test_3395() + { + } + [TestMethod] + public void Test_3396() + { + } + [TestMethod] + public void Test_3397() + { + } + [TestMethod] + public void Test_3398() + { + } + [TestMethod] + public void Test_3399() + { + } + [TestMethod] + public void Test_3400() + { + } + [TestMethod] + public void Test_3401() + { + } + [TestMethod] + public void Test_3402() + { + } + [TestMethod] + public void Test_3403() + { + } + [TestMethod] + public void Test_3404() + { + } + [TestMethod] + public void Test_3405() + { + } + [TestMethod] + public void Test_3406() + { + } + [TestMethod] + public void Test_3407() + { + } + [TestMethod] + public void Test_3408() + { + } + [TestMethod] + public void Test_3409() + { + } + [TestMethod] + public void Test_3410() + { + } + [TestMethod] + public void Test_3411() + { + } + [TestMethod] + public void Test_3412() + { + } + [TestMethod] + public void Test_3413() + { + } + [TestMethod] + public void Test_3414() + { + } + [TestMethod] + public void Test_3415() + { + } + [TestMethod] + public void Test_3416() + { + } + [TestMethod] + public void Test_3417() + { + } + [TestMethod] + public void Test_3418() + { + } + [TestMethod] + public void Test_3419() + { + } + [TestMethod] + public void Test_3420() + { + } + [TestMethod] + public void Test_3421() + { + } + [TestMethod] + public void Test_3422() + { + } + [TestMethod] + public void Test_3423() + { + } + [TestMethod] + public void Test_3424() + { + } + [TestMethod] + public void Test_3425() + { + } + [TestMethod] + public void Test_3426() + { + } + [TestMethod] + public void Test_3427() + { + } + [TestMethod] + public void Test_3428() + { + } + [TestMethod] + public void Test_3429() + { + } + [TestMethod] + public void Test_3430() + { + } + [TestMethod] + public void Test_3431() + { + } + [TestMethod] + public void Test_3432() + { + } + [TestMethod] + public void Test_3433() + { + } + [TestMethod] + public void Test_3434() + { + } + [TestMethod] + public void Test_3435() + { + } + [TestMethod] + public void Test_3436() + { + } + [TestMethod] + public void Test_3437() + { + } + [TestMethod] + public void Test_3438() + { + } + [TestMethod] + public void Test_3439() + { + } + [TestMethod] + public void Test_3440() + { + } + [TestMethod] + public void Test_3441() + { + } + [TestMethod] + public void Test_3442() + { + } + [TestMethod] + public void Test_3443() + { + } + [TestMethod] + public void Test_3444() + { + } + [TestMethod] + public void Test_3445() + { + } + [TestMethod] + public void Test_3446() + { + } + [TestMethod] + public void Test_3447() + { + } + [TestMethod] + public void Test_3448() + { + } + [TestMethod] + public void Test_3449() + { + } + [TestMethod] + public void Test_3450() + { + } + [TestMethod] + public void Test_3451() + { + } + [TestMethod] + public void Test_3452() + { + } + [TestMethod] + public void Test_3453() + { + } + [TestMethod] + public void Test_3454() + { + } + [TestMethod] + public void Test_3455() + { + } + [TestMethod] + public void Test_3456() + { + } + [TestMethod] + public void Test_3457() + { + } + [TestMethod] + public void Test_3458() + { + } + [TestMethod] + public void Test_3459() + { + } + [TestMethod] + public void Test_3460() + { + } + [TestMethod] + public void Test_3461() + { + } + [TestMethod] + public void Test_3462() + { + } + [TestMethod] + public void Test_3463() + { + } + [TestMethod] + public void Test_3464() + { + } + [TestMethod] + public void Test_3465() + { + } + [TestMethod] + public void Test_3466() + { + } + [TestMethod] + public void Test_3467() + { + } + [TestMethod] + public void Test_3468() + { + } + [TestMethod] + public void Test_3469() + { + } + [TestMethod] + public void Test_3470() + { + } + [TestMethod] + public void Test_3471() + { + } + [TestMethod] + public void Test_3472() + { + } + [TestMethod] + public void Test_3473() + { + } + [TestMethod] + public void Test_3474() + { + } + [TestMethod] + public void Test_3475() + { + } + [TestMethod] + public void Test_3476() + { + } + [TestMethod] + public void Test_3477() + { + } + [TestMethod] + public void Test_3478() + { + } + [TestMethod] + public void Test_3479() + { + } + [TestMethod] + public void Test_3480() + { + } + [TestMethod] + public void Test_3481() + { + } + [TestMethod] + public void Test_3482() + { + } + [TestMethod] + public void Test_3483() + { + } + [TestMethod] + public void Test_3484() + { + } + [TestMethod] + public void Test_3485() + { + } + [TestMethod] + public void Test_3486() + { + } + [TestMethod] + public void Test_3487() + { + } + [TestMethod] + public void Test_3488() + { + } + [TestMethod] + public void Test_3489() + { + } + [TestMethod] + public void Test_3490() + { + } + [TestMethod] + public void Test_3491() + { + } + [TestMethod] + public void Test_3492() + { + } + [TestMethod] + public void Test_3493() + { + } + [TestMethod] + public void Test_3494() + { + } + [TestMethod] + public void Test_3495() + { + } + [TestMethod] + public void Test_3496() + { + } + [TestMethod] + public void Test_3497() + { + } + [TestMethod] + public void Test_3498() + { + } + [TestMethod] + public void Test_3499() + { + } + [TestMethod] + public void Test_3500() + { + } + [TestMethod] + public void Test_3501() + { + } + [TestMethod] + public void Test_3502() + { + } + [TestMethod] + public void Test_3503() + { + } + [TestMethod] + public void Test_3504() + { + } + [TestMethod] + public void Test_3505() + { + } + [TestMethod] + public void Test_3506() + { + } + [TestMethod] + public void Test_3507() + { + } + [TestMethod] + public void Test_3508() + { + } + [TestMethod] + public void Test_3509() + { + } + [TestMethod] + public void Test_3510() + { + } + [TestMethod] + public void Test_3511() + { + } + [TestMethod] + public void Test_3512() + { + } + [TestMethod] + public void Test_3513() + { + } + [TestMethod] + public void Test_3514() + { + } + [TestMethod] + public void Test_3515() + { + } + [TestMethod] + public void Test_3516() + { + } + [TestMethod] + public void Test_3517() + { + } + [TestMethod] + public void Test_3518() + { + } + [TestMethod] + public void Test_3519() + { + } + [TestMethod] + public void Test_3520() + { + } + [TestMethod] + public void Test_3521() + { + } + [TestMethod] + public void Test_3522() + { + } + [TestMethod] + public void Test_3523() + { + } + [TestMethod] + public void Test_3524() + { + } + [TestMethod] + public void Test_3525() + { + } + [TestMethod] + public void Test_3526() + { + } + [TestMethod] + public void Test_3527() + { + } + [TestMethod] + public void Test_3528() + { + } + [TestMethod] + public void Test_3529() + { + } + [TestMethod] + public void Test_3530() + { + } + [TestMethod] + public void Test_3531() + { + } + [TestMethod] + public void Test_3532() + { + } + [TestMethod] + public void Test_3533() + { + } + [TestMethod] + public void Test_3534() + { + } + [TestMethod] + public void Test_3535() + { + } + [TestMethod] + public void Test_3536() + { + } + [TestMethod] + public void Test_3537() + { + } + [TestMethod] + public void Test_3538() + { + } + [TestMethod] + public void Test_3539() + { + } + [TestMethod] + public void Test_3540() + { + } + [TestMethod] + public void Test_3541() + { + } + [TestMethod] + public void Test_3542() + { + } + [TestMethod] + public void Test_3543() + { + } + [TestMethod] + public void Test_3544() + { + } + [TestMethod] + public void Test_3545() + { + } + [TestMethod] + public void Test_3546() + { + } + [TestMethod] + public void Test_3547() + { + } + [TestMethod] + public void Test_3548() + { + } + [TestMethod] + public void Test_3549() + { + } + [TestMethod] + public void Test_3550() + { + } + [TestMethod] + public void Test_3551() + { + } + [TestMethod] + public void Test_3552() + { + } + [TestMethod] + public void Test_3553() + { + } + [TestMethod] + public void Test_3554() + { + } + [TestMethod] + public void Test_3555() + { + } + [TestMethod] + public void Test_3556() + { + } + [TestMethod] + public void Test_3557() + { + } + [TestMethod] + public void Test_3558() + { + } + [TestMethod] + public void Test_3559() + { + } + [TestMethod] + public void Test_3560() + { + } + [TestMethod] + public void Test_3561() + { + } + [TestMethod] + public void Test_3562() + { + } + [TestMethod] + public void Test_3563() + { + } + [TestMethod] + public void Test_3564() + { + } + [TestMethod] + public void Test_3565() + { + } + [TestMethod] + public void Test_3566() + { + } + [TestMethod] + public void Test_3567() + { + } + [TestMethod] + public void Test_3568() + { + } + [TestMethod] + public void Test_3569() + { + } + [TestMethod] + public void Test_3570() + { + } + [TestMethod] + public void Test_3571() + { + } + [TestMethod] + public void Test_3572() + { + } + [TestMethod] + public void Test_3573() + { + } + [TestMethod] + public void Test_3574() + { + } + [TestMethod] + public void Test_3575() + { + } + [TestMethod] + public void Test_3576() + { + } + [TestMethod] + public void Test_3577() + { + } + [TestMethod] + public void Test_3578() + { + } + [TestMethod] + public void Test_3579() + { + } + [TestMethod] + public void Test_3580() + { + } + [TestMethod] + public void Test_3581() + { + } + [TestMethod] + public void Test_3582() + { + } + [TestMethod] + public void Test_3583() + { + } + [TestMethod] + public void Test_3584() + { + } + [TestMethod] + public void Test_3585() + { + } + [TestMethod] + public void Test_3586() + { + } + [TestMethod] + public void Test_3587() + { + } + [TestMethod] + public void Test_3588() + { + } + [TestMethod] + public void Test_3589() + { + } + [TestMethod] + public void Test_3590() + { + } + [TestMethod] + public void Test_3591() + { + } + [TestMethod] + public void Test_3592() + { + } + [TestMethod] + public void Test_3593() + { + } + [TestMethod] + public void Test_3594() + { + } + [TestMethod] + public void Test_3595() + { + } + [TestMethod] + public void Test_3596() + { + } + [TestMethod] + public void Test_3597() + { + } + [TestMethod] + public void Test_3598() + { + } + [TestMethod] + public void Test_3599() + { + } + [TestMethod] + public void Test_3600() + { + } + [TestMethod] + public void Test_3601() + { + } + [TestMethod] + public void Test_3602() + { + } + [TestMethod] + public void Test_3603() + { + } + [TestMethod] + public void Test_3604() + { + } + [TestMethod] + public void Test_3605() + { + } + [TestMethod] + public void Test_3606() + { + } + [TestMethod] + public void Test_3607() + { + } + [TestMethod] + public void Test_3608() + { + } + [TestMethod] + public void Test_3609() + { + } + [TestMethod] + public void Test_3610() + { + } + [TestMethod] + public void Test_3611() + { + } + [TestMethod] + public void Test_3612() + { + } + [TestMethod] + public void Test_3613() + { + } + [TestMethod] + public void Test_3614() + { + } + [TestMethod] + public void Test_3615() + { + } + [TestMethod] + public void Test_3616() + { + } + [TestMethod] + public void Test_3617() + { + } + [TestMethod] + public void Test_3618() + { + } + [TestMethod] + public void Test_3619() + { + } + [TestMethod] + public void Test_3620() + { + } + [TestMethod] + public void Test_3621() + { + } + [TestMethod] + public void Test_3622() + { + } + [TestMethod] + public void Test_3623() + { + } + [TestMethod] + public void Test_3624() + { + } + [TestMethod] + public void Test_3625() + { + } + [TestMethod] + public void Test_3626() + { + } + [TestMethod] + public void Test_3627() + { + } + [TestMethod] + public void Test_3628() + { + } + [TestMethod] + public void Test_3629() + { + } + [TestMethod] + public void Test_3630() + { + } + [TestMethod] + public void Test_3631() + { + } + [TestMethod] + public void Test_3632() + { + } + [TestMethod] + public void Test_3633() + { + } + [TestMethod] + public void Test_3634() + { + } + [TestMethod] + public void Test_3635() + { + } + [TestMethod] + public void Test_3636() + { + } + [TestMethod] + public void Test_3637() + { + } + [TestMethod] + public void Test_3638() + { + } + [TestMethod] + public void Test_3639() + { + } + [TestMethod] + public void Test_3640() + { + } + [TestMethod] + public void Test_3641() + { + } + [TestMethod] + public void Test_3642() + { + } + [TestMethod] + public void Test_3643() + { + } + [TestMethod] + public void Test_3644() + { + } + [TestMethod] + public void Test_3645() + { + } + [TestMethod] + public void Test_3646() + { + } + [TestMethod] + public void Test_3647() + { + } + [TestMethod] + public void Test_3648() + { + } + [TestMethod] + public void Test_3649() + { + } + [TestMethod] + public void Test_3650() + { + } + [TestMethod] + public void Test_3651() + { + } + [TestMethod] + public void Test_3652() + { + } + [TestMethod] + public void Test_3653() + { + } + [TestMethod] + public void Test_3654() + { + } + [TestMethod] + public void Test_3655() + { + } + [TestMethod] + public void Test_3656() + { + } + [TestMethod] + public void Test_3657() + { + } + [TestMethod] + public void Test_3658() + { + } + [TestMethod] + public void Test_3659() + { + } + [TestMethod] + public void Test_3660() + { + } + [TestMethod] + public void Test_3661() + { + } + [TestMethod] + public void Test_3662() + { + } + [TestMethod] + public void Test_3663() + { + } + [TestMethod] + public void Test_3664() + { + } + [TestMethod] + public void Test_3665() + { + } + [TestMethod] + public void Test_3666() + { + } + [TestMethod] + public void Test_3667() + { + } + [TestMethod] + public void Test_3668() + { + } + [TestMethod] + public void Test_3669() + { + } + [TestMethod] + public void Test_3670() + { + } + [TestMethod] + public void Test_3671() + { + } + [TestMethod] + public void Test_3672() + { + } + [TestMethod] + public void Test_3673() + { + } + [TestMethod] + public void Test_3674() + { + } + [TestMethod] + public void Test_3675() + { + } + [TestMethod] + public void Test_3676() + { + } + [TestMethod] + public void Test_3677() + { + } + [TestMethod] + public void Test_3678() + { + } + [TestMethod] + public void Test_3679() + { + } + [TestMethod] + public void Test_3680() + { + } + [TestMethod] + public void Test_3681() + { + } + [TestMethod] + public void Test_3682() + { + } + [TestMethod] + public void Test_3683() + { + } + [TestMethod] + public void Test_3684() + { + } + [TestMethod] + public void Test_3685() + { + } + [TestMethod] + public void Test_3686() + { + } + [TestMethod] + public void Test_3687() + { + } + [TestMethod] + public void Test_3688() + { + } + [TestMethod] + public void Test_3689() + { + } + [TestMethod] + public void Test_3690() + { + } + [TestMethod] + public void Test_3691() + { + } + [TestMethod] + public void Test_3692() + { + } + [TestMethod] + public void Test_3693() + { + } + [TestMethod] + public void Test_3694() + { + } + [TestMethod] + public void Test_3695() + { + } + [TestMethod] + public void Test_3696() + { + } + [TestMethod] + public void Test_3697() + { + } + [TestMethod] + public void Test_3698() + { + } + [TestMethod] + public void Test_3699() + { + } + [TestMethod] + public void Test_3700() + { + } + [TestMethod] + public void Test_3701() + { + } + [TestMethod] + public void Test_3702() + { + } + [TestMethod] + public void Test_3703() + { + } + [TestMethod] + public void Test_3704() + { + } + [TestMethod] + public void Test_3705() + { + } + [TestMethod] + public void Test_3706() + { + } + [TestMethod] + public void Test_3707() + { + } + [TestMethod] + public void Test_3708() + { + } + [TestMethod] + public void Test_3709() + { + } + [TestMethod] + public void Test_3710() + { + } + [TestMethod] + public void Test_3711() + { + } + [TestMethod] + public void Test_3712() + { + } + [TestMethod] + public void Test_3713() + { + } + [TestMethod] + public void Test_3714() + { + } + [TestMethod] + public void Test_3715() + { + } + [TestMethod] + public void Test_3716() + { + } + [TestMethod] + public void Test_3717() + { + } + [TestMethod] + public void Test_3718() + { + } + [TestMethod] + public void Test_3719() + { + } + [TestMethod] + public void Test_3720() + { + } + [TestMethod] + public void Test_3721() + { + } + [TestMethod] + public void Test_3722() + { + } + [TestMethod] + public void Test_3723() + { + } + [TestMethod] + public void Test_3724() + { + } + [TestMethod] + public void Test_3725() + { + } + [TestMethod] + public void Test_3726() + { + } + [TestMethod] + public void Test_3727() + { + } + [TestMethod] + public void Test_3728() + { + } + [TestMethod] + public void Test_3729() + { + } + [TestMethod] + public void Test_3730() + { + } + [TestMethod] + public void Test_3731() + { + } + [TestMethod] + public void Test_3732() + { + } + [TestMethod] + public void Test_3733() + { + } + [TestMethod] + public void Test_3734() + { + } + [TestMethod] + public void Test_3735() + { + } + [TestMethod] + public void Test_3736() + { + } + [TestMethod] + public void Test_3737() + { + } + [TestMethod] + public void Test_3738() + { + } + [TestMethod] + public void Test_3739() + { + } + [TestMethod] + public void Test_3740() + { + } + [TestMethod] + public void Test_3741() + { + } + [TestMethod] + public void Test_3742() + { + } + [TestMethod] + public void Test_3743() + { + } + [TestMethod] + public void Test_3744() + { + } + [TestMethod] + public void Test_3745() + { + } + [TestMethod] + public void Test_3746() + { + } + [TestMethod] + public void Test_3747() + { + } + [TestMethod] + public void Test_3748() + { + } + [TestMethod] + public void Test_3749() + { + } + [TestMethod] + public void Test_3750() + { + } + [TestMethod] + public void Test_3751() + { + } + [TestMethod] + public void Test_3752() + { + } + [TestMethod] + public void Test_3753() + { + } + [TestMethod] + public void Test_3754() + { + } + [TestMethod] + public void Test_3755() + { + } + [TestMethod] + public void Test_3756() + { + } + [TestMethod] + public void Test_3757() + { + } + [TestMethod] + public void Test_3758() + { + } + [TestMethod] + public void Test_3759() + { + } + [TestMethod] + public void Test_3760() + { + } + [TestMethod] + public void Test_3761() + { + } + [TestMethod] + public void Test_3762() + { + } + [TestMethod] + public void Test_3763() + { + } + [TestMethod] + public void Test_3764() + { + } + [TestMethod] + public void Test_3765() + { + } + [TestMethod] + public void Test_3766() + { + } + [TestMethod] + public void Test_3767() + { + } + [TestMethod] + public void Test_3768() + { + } + [TestMethod] + public void Test_3769() + { + } + [TestMethod] + public void Test_3770() + { + } + [TestMethod] + public void Test_3771() + { + } + [TestMethod] + public void Test_3772() + { + } + [TestMethod] + public void Test_3773() + { + } + [TestMethod] + public void Test_3774() + { + } + [TestMethod] + public void Test_3775() + { + } + [TestMethod] + public void Test_3776() + { + } + [TestMethod] + public void Test_3777() + { + } + [TestMethod] + public void Test_3778() + { + } + [TestMethod] + public void Test_3779() + { + } + [TestMethod] + public void Test_3780() + { + } + [TestMethod] + public void Test_3781() + { + } + [TestMethod] + public void Test_3782() + { + } + [TestMethod] + public void Test_3783() + { + } + [TestMethod] + public void Test_3784() + { + } + [TestMethod] + public void Test_3785() + { + } + [TestMethod] + public void Test_3786() + { + } + [TestMethod] + public void Test_3787() + { + } + [TestMethod] + public void Test_3788() + { + } + [TestMethod] + public void Test_3789() + { + } + [TestMethod] + public void Test_3790() + { + } + [TestMethod] + public void Test_3791() + { + } + [TestMethod] + public void Test_3792() + { + } + [TestMethod] + public void Test_3793() + { + } + [TestMethod] + public void Test_3794() + { + } + [TestMethod] + public void Test_3795() + { + } + [TestMethod] + public void Test_3796() + { + } + [TestMethod] + public void Test_3797() + { + } + [TestMethod] + public void Test_3798() + { + } + [TestMethod] + public void Test_3799() + { + } + [TestMethod] + public void Test_3800() + { + } + [TestMethod] + public void Test_3801() + { + } + [TestMethod] + public void Test_3802() + { + } + [TestMethod] + public void Test_3803() + { + } + [TestMethod] + public void Test_3804() + { + } + [TestMethod] + public void Test_3805() + { + } + [TestMethod] + public void Test_3806() + { + } + [TestMethod] + public void Test_3807() + { + } + [TestMethod] + public void Test_3808() + { + } + [TestMethod] + public void Test_3809() + { + } + [TestMethod] + public void Test_3810() + { + } + [TestMethod] + public void Test_3811() + { + } + [TestMethod] + public void Test_3812() + { + } + [TestMethod] + public void Test_3813() + { + } + [TestMethod] + public void Test_3814() + { + } + [TestMethod] + public void Test_3815() + { + } + [TestMethod] + public void Test_3816() + { + } + [TestMethod] + public void Test_3817() + { + } + [TestMethod] + public void Test_3818() + { + } + [TestMethod] + public void Test_3819() + { + } + [TestMethod] + public void Test_3820() + { + } + [TestMethod] + public void Test_3821() + { + } + [TestMethod] + public void Test_3822() + { + } + [TestMethod] + public void Test_3823() + { + } + [TestMethod] + public void Test_3824() + { + } + [TestMethod] + public void Test_3825() + { + } + [TestMethod] + public void Test_3826() + { + } + [TestMethod] + public void Test_3827() + { + } + [TestMethod] + public void Test_3828() + { + } + [TestMethod] + public void Test_3829() + { + } + [TestMethod] + public void Test_3830() + { + } + [TestMethod] + public void Test_3831() + { + } + [TestMethod] + public void Test_3832() + { + } + [TestMethod] + public void Test_3833() + { + } + [TestMethod] + public void Test_3834() + { + } + [TestMethod] + public void Test_3835() + { + } + [TestMethod] + public void Test_3836() + { + } + [TestMethod] + public void Test_3837() + { + } + [TestMethod] + public void Test_3838() + { + } + [TestMethod] + public void Test_3839() + { + } + [TestMethod] + public void Test_3840() + { + } + [TestMethod] + public void Test_3841() + { + } + [TestMethod] + public void Test_3842() + { + } + [TestMethod] + public void Test_3843() + { + } + [TestMethod] + public void Test_3844() + { + } + [TestMethod] + public void Test_3845() + { + } + [TestMethod] + public void Test_3846() + { + } + [TestMethod] + public void Test_3847() + { + } + [TestMethod] + public void Test_3848() + { + } + [TestMethod] + public void Test_3849() + { + } + [TestMethod] + public void Test_3850() + { + } + [TestMethod] + public void Test_3851() + { + } + [TestMethod] + public void Test_3852() + { + } + [TestMethod] + public void Test_3853() + { + } + [TestMethod] + public void Test_3854() + { + } + [TestMethod] + public void Test_3855() + { + } + [TestMethod] + public void Test_3856() + { + } + [TestMethod] + public void Test_3857() + { + } + [TestMethod] + public void Test_3858() + { + } + [TestMethod] + public void Test_3859() + { + } + [TestMethod] + public void Test_3860() + { + } + [TestMethod] + public void Test_3861() + { + } + [TestMethod] + public void Test_3862() + { + } + [TestMethod] + public void Test_3863() + { + } + [TestMethod] + public void Test_3864() + { + } + [TestMethod] + public void Test_3865() + { + } + [TestMethod] + public void Test_3866() + { + } + [TestMethod] + public void Test_3867() + { + } + [TestMethod] + public void Test_3868() + { + } + [TestMethod] + public void Test_3869() + { + } + [TestMethod] + public void Test_3870() + { + } + [TestMethod] + public void Test_3871() + { + } + [TestMethod] + public void Test_3872() + { + } + [TestMethod] + public void Test_3873() + { + } + [TestMethod] + public void Test_3874() + { + } + [TestMethod] + public void Test_3875() + { + } + [TestMethod] + public void Test_3876() + { + } + [TestMethod] + public void Test_3877() + { + } + [TestMethod] + public void Test_3878() + { + } + [TestMethod] + public void Test_3879() + { + } + [TestMethod] + public void Test_3880() + { + } + [TestMethod] + public void Test_3881() + { + } + [TestMethod] + public void Test_3882() + { + } + [TestMethod] + public void Test_3883() + { + } + [TestMethod] + public void Test_3884() + { + } + [TestMethod] + public void Test_3885() + { + } + [TestMethod] + public void Test_3886() + { + } + [TestMethod] + public void Test_3887() + { + } + [TestMethod] + public void Test_3888() + { + } + [TestMethod] + public void Test_3889() + { + } + [TestMethod] + public void Test_3890() + { + } + [TestMethod] + public void Test_3891() + { + } + [TestMethod] + public void Test_3892() + { + } + [TestMethod] + public void Test_3893() + { + } + [TestMethod] + public void Test_3894() + { + } + [TestMethod] + public void Test_3895() + { + } + [TestMethod] + public void Test_3896() + { + } + [TestMethod] + public void Test_3897() + { + } + [TestMethod] + public void Test_3898() + { + } + [TestMethod] + public void Test_3899() + { + } + [TestMethod] + public void Test_3900() + { + } + [TestMethod] + public void Test_3901() + { + } + [TestMethod] + public void Test_3902() + { + } + [TestMethod] + public void Test_3903() + { + } + [TestMethod] + public void Test_3904() + { + } + [TestMethod] + public void Test_3905() + { + } + [TestMethod] + public void Test_3906() + { + } + [TestMethod] + public void Test_3907() + { + } + [TestMethod] + public void Test_3908() + { + } + [TestMethod] + public void Test_3909() + { + } + [TestMethod] + public void Test_3910() + { + } + [TestMethod] + public void Test_3911() + { + } + [TestMethod] + public void Test_3912() + { + } + [TestMethod] + public void Test_3913() + { + } + [TestMethod] + public void Test_3914() + { + } + [TestMethod] + public void Test_3915() + { + } + [TestMethod] + public void Test_3916() + { + } + [TestMethod] + public void Test_3917() + { + } + [TestMethod] + public void Test_3918() + { + } + [TestMethod] + public void Test_3919() + { + } + [TestMethod] + public void Test_3920() + { + } + [TestMethod] + public void Test_3921() + { + } + [TestMethod] + public void Test_3922() + { + } + [TestMethod] + public void Test_3923() + { + } + [TestMethod] + public void Test_3924() + { + } + [TestMethod] + public void Test_3925() + { + } + [TestMethod] + public void Test_3926() + { + } + [TestMethod] + public void Test_3927() + { + } + [TestMethod] + public void Test_3928() + { + } + [TestMethod] + public void Test_3929() + { + } + [TestMethod] + public void Test_3930() + { + } + [TestMethod] + public void Test_3931() + { + } + [TestMethod] + public void Test_3932() + { + } + [TestMethod] + public void Test_3933() + { + } + [TestMethod] + public void Test_3934() + { + } + [TestMethod] + public void Test_3935() + { + } + [TestMethod] + public void Test_3936() + { + } + [TestMethod] + public void Test_3937() + { + } + [TestMethod] + public void Test_3938() + { + } + [TestMethod] + public void Test_3939() + { + } + [TestMethod] + public void Test_3940() + { + } + [TestMethod] + public void Test_3941() + { + } + [TestMethod] + public void Test_3942() + { + } + [TestMethod] + public void Test_3943() + { + } + [TestMethod] + public void Test_3944() + { + } + [TestMethod] + public void Test_3945() + { + } + [TestMethod] + public void Test_3946() + { + } + [TestMethod] + public void Test_3947() + { + } + [TestMethod] + public void Test_3948() + { + } + [TestMethod] + public void Test_3949() + { + } + [TestMethod] + public void Test_3950() + { + } + [TestMethod] + public void Test_3951() + { + } + [TestMethod] + public void Test_3952() + { + } + [TestMethod] + public void Test_3953() + { + } + [TestMethod] + public void Test_3954() + { + } + [TestMethod] + public void Test_3955() + { + } + [TestMethod] + public void Test_3956() + { + } + [TestMethod] + public void Test_3957() + { + } + [TestMethod] + public void Test_3958() + { + } + [TestMethod] + public void Test_3959() + { + } + [TestMethod] + public void Test_3960() + { + } + [TestMethod] + public void Test_3961() + { + } + [TestMethod] + public void Test_3962() + { + } + [TestMethod] + public void Test_3963() + { + } + [TestMethod] + public void Test_3964() + { + } + [TestMethod] + public void Test_3965() + { + } + [TestMethod] + public void Test_3966() + { + } + [TestMethod] + public void Test_3967() + { + } + [TestMethod] + public void Test_3968() + { + } + [TestMethod] + public void Test_3969() + { + } + [TestMethod] + public void Test_3970() + { + } + [TestMethod] + public void Test_3971() + { + } + [TestMethod] + public void Test_3972() + { + } + [TestMethod] + public void Test_3973() + { + } + [TestMethod] + public void Test_3974() + { + } + [TestMethod] + public void Test_3975() + { + } + [TestMethod] + public void Test_3976() + { + } + [TestMethod] + public void Test_3977() + { + } + [TestMethod] + public void Test_3978() + { + } + [TestMethod] + public void Test_3979() + { + } + [TestMethod] + public void Test_3980() + { + } + [TestMethod] + public void Test_3981() + { + } + [TestMethod] + public void Test_3982() + { + } + [TestMethod] + public void Test_3983() + { + } + [TestMethod] + public void Test_3984() + { + } + [TestMethod] + public void Test_3985() + { + } + [TestMethod] + public void Test_3986() + { + } + [TestMethod] + public void Test_3987() + { + } + [TestMethod] + public void Test_3988() + { + } + [TestMethod] + public void Test_3989() + { + } + [TestMethod] + public void Test_3990() + { + } + [TestMethod] + public void Test_3991() + { + } + [TestMethod] + public void Test_3992() + { + } + [TestMethod] + public void Test_3993() + { + } + [TestMethod] + public void Test_3994() + { + } + [TestMethod] + public void Test_3995() + { + } + [TestMethod] + public void Test_3996() + { + } + [TestMethod] + public void Test_3997() + { + } + [TestMethod] + public void Test_3998() + { + } + [TestMethod] + public void Test_3999() + { + } + [TestMethod] + public void Test_4000() + { + } + [TestMethod] + public void Test_4001() + { + } + [TestMethod] + public void Test_4002() + { + } + [TestMethod] + public void Test_4003() + { + } + [TestMethod] + public void Test_4004() + { + } + [TestMethod] + public void Test_4005() + { + } + [TestMethod] + public void Test_4006() + { + } + [TestMethod] + public void Test_4007() + { + } + [TestMethod] + public void Test_4008() + { + } + [TestMethod] + public void Test_4009() + { + } + [TestMethod] + public void Test_4010() + { + } + [TestMethod] + public void Test_4011() + { + } + [TestMethod] + public void Test_4012() + { + } + [TestMethod] + public void Test_4013() + { + } + [TestMethod] + public void Test_4014() + { + } + [TestMethod] + public void Test_4015() + { + } + [TestMethod] + public void Test_4016() + { + } + [TestMethod] + public void Test_4017() + { + } + [TestMethod] + public void Test_4018() + { + } + [TestMethod] + public void Test_4019() + { + } + [TestMethod] + public void Test_4020() + { + } + [TestMethod] + public void Test_4021() + { + } + [TestMethod] + public void Test_4022() + { + } + [TestMethod] + public void Test_4023() + { + } + [TestMethod] + public void Test_4024() + { + } + [TestMethod] + public void Test_4025() + { + } + [TestMethod] + public void Test_4026() + { + } + [TestMethod] + public void Test_4027() + { + } + [TestMethod] + public void Test_4028() + { + } + [TestMethod] + public void Test_4029() + { + } + [TestMethod] + public void Test_4030() + { + } + [TestMethod] + public void Test_4031() + { + } + [TestMethod] + public void Test_4032() + { + } + [TestMethod] + public void Test_4033() + { + } + [TestMethod] + public void Test_4034() + { + } + [TestMethod] + public void Test_4035() + { + } + [TestMethod] + public void Test_4036() + { + } + [TestMethod] + public void Test_4037() + { + } + [TestMethod] + public void Test_4038() + { + } + [TestMethod] + public void Test_4039() + { + } + [TestMethod] + public void Test_4040() + { + } + [TestMethod] + public void Test_4041() + { + } + [TestMethod] + public void Test_4042() + { + } + [TestMethod] + public void Test_4043() + { + } + [TestMethod] + public void Test_4044() + { + } + [TestMethod] + public void Test_4045() + { + } + [TestMethod] + public void Test_4046() + { + } + [TestMethod] + public void Test_4047() + { + } + [TestMethod] + public void Test_4048() + { + } + [TestMethod] + public void Test_4049() + { + } + [TestMethod] + public void Test_4050() + { + } + [TestMethod] + public void Test_4051() + { + } + [TestMethod] + public void Test_4052() + { + } + [TestMethod] + public void Test_4053() + { + } + [TestMethod] + public void Test_4054() + { + } + [TestMethod] + public void Test_4055() + { + } + [TestMethod] + public void Test_4056() + { + } + [TestMethod] + public void Test_4057() + { + } + [TestMethod] + public void Test_4058() + { + } + [TestMethod] + public void Test_4059() + { + } + [TestMethod] + public void Test_4060() + { + } + [TestMethod] + public void Test_4061() + { + } + [TestMethod] + public void Test_4062() + { + } + [TestMethod] + public void Test_4063() + { + } + [TestMethod] + public void Test_4064() + { + } + [TestMethod] + public void Test_4065() + { + } + [TestMethod] + public void Test_4066() + { + } + [TestMethod] + public void Test_4067() + { + } + [TestMethod] + public void Test_4068() + { + } + [TestMethod] + public void Test_4069() + { + } + [TestMethod] + public void Test_4070() + { + } + [TestMethod] + public void Test_4071() + { + } + [TestMethod] + public void Test_4072() + { + } + [TestMethod] + public void Test_4073() + { + } + [TestMethod] + public void Test_4074() + { + } + [TestMethod] + public void Test_4075() + { + } + [TestMethod] + public void Test_4076() + { + } + [TestMethod] + public void Test_4077() + { + } + [TestMethod] + public void Test_4078() + { + } + [TestMethod] + public void Test_4079() + { + } + [TestMethod] + public void Test_4080() + { + } + [TestMethod] + public void Test_4081() + { + } + [TestMethod] + public void Test_4082() + { + } + [TestMethod] + public void Test_4083() + { + } + [TestMethod] + public void Test_4084() + { + } + [TestMethod] + public void Test_4085() + { + } + [TestMethod] + public void Test_4086() + { + } + [TestMethod] + public void Test_4087() + { + } + [TestMethod] + public void Test_4088() + { + } + [TestMethod] + public void Test_4089() + { + } + [TestMethod] + public void Test_4090() + { + } + [TestMethod] + public void Test_4091() + { + } + [TestMethod] + public void Test_4092() + { + } + [TestMethod] + public void Test_4093() + { + } + [TestMethod] + public void Test_4094() + { + } + [TestMethod] + public void Test_4095() + { + } + [TestMethod] + public void Test_4096() + { + } + [TestMethod] + public void Test_4097() + { + } + [TestMethod] + public void Test_4098() + { + } + [TestMethod] + public void Test_4099() + { + } + [TestMethod] + public void Test_4100() + { + } + [TestMethod] + public void Test_4101() + { + } + [TestMethod] + public void Test_4102() + { + } + [TestMethod] + public void Test_4103() + { + } + [TestMethod] + public void Test_4104() + { + } + [TestMethod] + public void Test_4105() + { + } + [TestMethod] + public void Test_4106() + { + } + [TestMethod] + public void Test_4107() + { + } + [TestMethod] + public void Test_4108() + { + } + [TestMethod] + public void Test_4109() + { + } + [TestMethod] + public void Test_4110() + { + } + [TestMethod] + public void Test_4111() + { + } + [TestMethod] + public void Test_4112() + { + } + [TestMethod] + public void Test_4113() + { + } + [TestMethod] + public void Test_4114() + { + } + [TestMethod] + public void Test_4115() + { + } + [TestMethod] + public void Test_4116() + { + } + [TestMethod] + public void Test_4117() + { + } + [TestMethod] + public void Test_4118() + { + } + [TestMethod] + public void Test_4119() + { + } + [TestMethod] + public void Test_4120() + { + } + [TestMethod] + public void Test_4121() + { + } + [TestMethod] + public void Test_4122() + { + } + [TestMethod] + public void Test_4123() + { + } + [TestMethod] + public void Test_4124() + { + } + [TestMethod] + public void Test_4125() + { + } + [TestMethod] + public void Test_4126() + { + } + [TestMethod] + public void Test_4127() + { + } + [TestMethod] + public void Test_4128() + { + } + [TestMethod] + public void Test_4129() + { + } + [TestMethod] + public void Test_4130() + { + } + [TestMethod] + public void Test_4131() + { + } + [TestMethod] + public void Test_4132() + { + } + [TestMethod] + public void Test_4133() + { + } + [TestMethod] + public void Test_4134() + { + } + [TestMethod] + public void Test_4135() + { + } + [TestMethod] + public void Test_4136() + { + } + [TestMethod] + public void Test_4137() + { + } + [TestMethod] + public void Test_4138() + { + } + [TestMethod] + public void Test_4139() + { + } + [TestMethod] + public void Test_4140() + { + } + [TestMethod] + public void Test_4141() + { + } + [TestMethod] + public void Test_4142() + { + } + [TestMethod] + public void Test_4143() + { + } + [TestMethod] + public void Test_4144() + { + } + [TestMethod] + public void Test_4145() + { + } + [TestMethod] + public void Test_4146() + { + } + [TestMethod] + public void Test_4147() + { + } + [TestMethod] + public void Test_4148() + { + } + [TestMethod] + public void Test_4149() + { + } + [TestMethod] + public void Test_4150() + { + } + [TestMethod] + public void Test_4151() + { + } + [TestMethod] + public void Test_4152() + { + } + [TestMethod] + public void Test_4153() + { + } + [TestMethod] + public void Test_4154() + { + } + [TestMethod] + public void Test_4155() + { + } + [TestMethod] + public void Test_4156() + { + } + [TestMethod] + public void Test_4157() + { + } + [TestMethod] + public void Test_4158() + { + } + [TestMethod] + public void Test_4159() + { + } + [TestMethod] + public void Test_4160() + { + } + [TestMethod] + public void Test_4161() + { + } + [TestMethod] + public void Test_4162() + { + } + [TestMethod] + public void Test_4163() + { + } + [TestMethod] + public void Test_4164() + { + } + [TestMethod] + public void Test_4165() + { + } + [TestMethod] + public void Test_4166() + { + } + [TestMethod] + public void Test_4167() + { + } + [TestMethod] + public void Test_4168() + { + } + [TestMethod] + public void Test_4169() + { + } + [TestMethod] + public void Test_4170() + { + } + [TestMethod] + public void Test_4171() + { + } + [TestMethod] + public void Test_4172() + { + } + [TestMethod] + public void Test_4173() + { + } + [TestMethod] + public void Test_4174() + { + } + [TestMethod] + public void Test_4175() + { + } + [TestMethod] + public void Test_4176() + { + } + [TestMethod] + public void Test_4177() + { + } + [TestMethod] + public void Test_4178() + { + } + [TestMethod] + public void Test_4179() + { + } + [TestMethod] + public void Test_4180() + { + } + [TestMethod] + public void Test_4181() + { + } + [TestMethod] + public void Test_4182() + { + } + [TestMethod] + public void Test_4183() + { + } + [TestMethod] + public void Test_4184() + { + } + [TestMethod] + public void Test_4185() + { + } + [TestMethod] + public void Test_4186() + { + } + [TestMethod] + public void Test_4187() + { + } + [TestMethod] + public void Test_4188() + { + } + [TestMethod] + public void Test_4189() + { + } + [TestMethod] + public void Test_4190() + { + } + [TestMethod] + public void Test_4191() + { + } + [TestMethod] + public void Test_4192() + { + } + [TestMethod] + public void Test_4193() + { + } + [TestMethod] + public void Test_4194() + { + } + [TestMethod] + public void Test_4195() + { + } + [TestMethod] + public void Test_4196() + { + } + [TestMethod] + public void Test_4197() + { + } + [TestMethod] + public void Test_4198() + { + } + [TestMethod] + public void Test_4199() + { + } + [TestMethod] + public void Test_4200() + { + } + [TestMethod] + public void Test_4201() + { + } + [TestMethod] + public void Test_4202() + { + } + [TestMethod] + public void Test_4203() + { + } + [TestMethod] + public void Test_4204() + { + } + [TestMethod] + public void Test_4205() + { + } + [TestMethod] + public void Test_4206() + { + } + [TestMethod] + public void Test_4207() + { + } + [TestMethod] + public void Test_4208() + { + } + [TestMethod] + public void Test_4209() + { + } + [TestMethod] + public void Test_4210() + { + } + [TestMethod] + public void Test_4211() + { + } + [TestMethod] + public void Test_4212() + { + } + [TestMethod] + public void Test_4213() + { + } + [TestMethod] + public void Test_4214() + { + } + [TestMethod] + public void Test_4215() + { + } + [TestMethod] + public void Test_4216() + { + } + [TestMethod] + public void Test_4217() + { + } + [TestMethod] + public void Test_4218() + { + } + [TestMethod] + public void Test_4219() + { + } + [TestMethod] + public void Test_4220() + { + } + [TestMethod] + public void Test_4221() + { + } + [TestMethod] + public void Test_4222() + { + } + [TestMethod] + public void Test_4223() + { + } + [TestMethod] + public void Test_4224() + { + } + [TestMethod] + public void Test_4225() + { + } + [TestMethod] + public void Test_4226() + { + } + [TestMethod] + public void Test_4227() + { + } + [TestMethod] + public void Test_4228() + { + } + [TestMethod] + public void Test_4229() + { + } + [TestMethod] + public void Test_4230() + { + } + [TestMethod] + public void Test_4231() + { + } + [TestMethod] + public void Test_4232() + { + } + [TestMethod] + public void Test_4233() + { + } + [TestMethod] + public void Test_4234() + { + } + [TestMethod] + public void Test_4235() + { + } + [TestMethod] + public void Test_4236() + { + } + [TestMethod] + public void Test_4237() + { + } + [TestMethod] + public void Test_4238() + { + } + [TestMethod] + public void Test_4239() + { + } + [TestMethod] + public void Test_4240() + { + } + [TestMethod] + public void Test_4241() + { + } + [TestMethod] + public void Test_4242() + { + } + [TestMethod] + public void Test_4243() + { + } + [TestMethod] + public void Test_4244() + { + } + [TestMethod] + public void Test_4245() + { + } + [TestMethod] + public void Test_4246() + { + } + [TestMethod] + public void Test_4247() + { + } + [TestMethod] + public void Test_4248() + { + } + [TestMethod] + public void Test_4249() + { + } + [TestMethod] + public void Test_4250() + { + } + [TestMethod] + public void Test_4251() + { + } + [TestMethod] + public void Test_4252() + { + } + [TestMethod] + public void Test_4253() + { + } + [TestMethod] + public void Test_4254() + { + } + [TestMethod] + public void Test_4255() + { + } + [TestMethod] + public void Test_4256() + { + } + [TestMethod] + public void Test_4257() + { + } + [TestMethod] + public void Test_4258() + { + } + [TestMethod] + public void Test_4259() + { + } + [TestMethod] + public void Test_4260() + { + } + [TestMethod] + public void Test_4261() + { + } + [TestMethod] + public void Test_4262() + { + } + [TestMethod] + public void Test_4263() + { + } + [TestMethod] + public void Test_4264() + { + } + [TestMethod] + public void Test_4265() + { + } + [TestMethod] + public void Test_4266() + { + } + [TestMethod] + public void Test_4267() + { + } + [TestMethod] + public void Test_4268() + { + } + [TestMethod] + public void Test_4269() + { + } + [TestMethod] + public void Test_4270() + { + } + [TestMethod] + public void Test_4271() + { + } + [TestMethod] + public void Test_4272() + { + } + [TestMethod] + public void Test_4273() + { + } + [TestMethod] + public void Test_4274() + { + } + [TestMethod] + public void Test_4275() + { + } + [TestMethod] + public void Test_4276() + { + } + [TestMethod] + public void Test_4277() + { + } + [TestMethod] + public void Test_4278() + { + } + [TestMethod] + public void Test_4279() + { + } + [TestMethod] + public void Test_4280() + { + } + [TestMethod] + public void Test_4281() + { + } + [TestMethod] + public void Test_4282() + { + } + [TestMethod] + public void Test_4283() + { + } + [TestMethod] + public void Test_4284() + { + } + [TestMethod] + public void Test_4285() + { + } + [TestMethod] + public void Test_4286() + { + } + [TestMethod] + public void Test_4287() + { + } + [TestMethod] + public void Test_4288() + { + } + [TestMethod] + public void Test_4289() + { + } + [TestMethod] + public void Test_4290() + { + } + [TestMethod] + public void Test_4291() + { + } + [TestMethod] + public void Test_4292() + { + } + [TestMethod] + public void Test_4293() + { + } + [TestMethod] + public void Test_4294() + { + } + [TestMethod] + public void Test_4295() + { + } + [TestMethod] + public void Test_4296() + { + } + [TestMethod] + public void Test_4297() + { + } + [TestMethod] + public void Test_4298() + { + } + [TestMethod] + public void Test_4299() + { + } + [TestMethod] + public void Test_4300() + { + } + [TestMethod] + public void Test_4301() + { + } + [TestMethod] + public void Test_4302() + { + } + [TestMethod] + public void Test_4303() + { + } + [TestMethod] + public void Test_4304() + { + } + [TestMethod] + public void Test_4305() + { + } + [TestMethod] + public void Test_4306() + { + } + [TestMethod] + public void Test_4307() + { + } + [TestMethod] + public void Test_4308() + { + } + [TestMethod] + public void Test_4309() + { + } + [TestMethod] + public void Test_4310() + { + } + [TestMethod] + public void Test_4311() + { + } + [TestMethod] + public void Test_4312() + { + } + [TestMethod] + public void Test_4313() + { + } + [TestMethod] + public void Test_4314() + { + } + [TestMethod] + public void Test_4315() + { + } + [TestMethod] + public void Test_4316() + { + } + [TestMethod] + public void Test_4317() + { + } + [TestMethod] + public void Test_4318() + { + } + [TestMethod] + public void Test_4319() + { + } + [TestMethod] + public void Test_4320() + { + } + [TestMethod] + public void Test_4321() + { + } + [TestMethod] + public void Test_4322() + { + } + [TestMethod] + public void Test_4323() + { + } + [TestMethod] + public void Test_4324() + { + } + [TestMethod] + public void Test_4325() + { + } + [TestMethod] + public void Test_4326() + { + } + [TestMethod] + public void Test_4327() + { + } + [TestMethod] + public void Test_4328() + { + } + [TestMethod] + public void Test_4329() + { + } + [TestMethod] + public void Test_4330() + { + } + [TestMethod] + public void Test_4331() + { + } + [TestMethod] + public void Test_4332() + { + } + [TestMethod] + public void Test_4333() + { + } + [TestMethod] + public void Test_4334() + { + } + [TestMethod] + public void Test_4335() + { + } + [TestMethod] + public void Test_4336() + { + } + [TestMethod] + public void Test_4337() + { + } + [TestMethod] + public void Test_4338() + { + } + [TestMethod] + public void Test_4339() + { + } + [TestMethod] + public void Test_4340() + { + } + [TestMethod] + public void Test_4341() + { + } + [TestMethod] + public void Test_4342() + { + } + [TestMethod] + public void Test_4343() + { + } + [TestMethod] + public void Test_4344() + { + } + [TestMethod] + public void Test_4345() + { + } + [TestMethod] + public void Test_4346() + { + } + [TestMethod] + public void Test_4347() + { + } + [TestMethod] + public void Test_4348() + { + } + [TestMethod] + public void Test_4349() + { + } + [TestMethod] + public void Test_4350() + { + } + [TestMethod] + public void Test_4351() + { + } + [TestMethod] + public void Test_4352() + { + } + [TestMethod] + public void Test_4353() + { + } + [TestMethod] + public void Test_4354() + { + } + [TestMethod] + public void Test_4355() + { + } + [TestMethod] + public void Test_4356() + { + } + [TestMethod] + public void Test_4357() + { + } + [TestMethod] + public void Test_4358() + { + } + [TestMethod] + public void Test_4359() + { + } + [TestMethod] + public void Test_4360() + { + } + [TestMethod] + public void Test_4361() + { + } + [TestMethod] + public void Test_4362() + { + } + [TestMethod] + public void Test_4363() + { + } + [TestMethod] + public void Test_4364() + { + } + [TestMethod] + public void Test_4365() + { + } + [TestMethod] + public void Test_4366() + { + } + [TestMethod] + public void Test_4367() + { + } + [TestMethod] + public void Test_4368() + { + } + [TestMethod] + public void Test_4369() + { + } + [TestMethod] + public void Test_4370() + { + } + [TestMethod] + public void Test_4371() + { + } + [TestMethod] + public void Test_4372() + { + } + [TestMethod] + public void Test_4373() + { + } + [TestMethod] + public void Test_4374() + { + } + [TestMethod] + public void Test_4375() + { + } + [TestMethod] + public void Test_4376() + { + } + [TestMethod] + public void Test_4377() + { + } + [TestMethod] + public void Test_4378() + { + } + [TestMethod] + public void Test_4379() + { + } + [TestMethod] + public void Test_4380() + { + } + [TestMethod] + public void Test_4381() + { + } + [TestMethod] + public void Test_4382() + { + } + [TestMethod] + public void Test_4383() + { + } + [TestMethod] + public void Test_4384() + { + } + [TestMethod] + public void Test_4385() + { + } + [TestMethod] + public void Test_4386() + { + } + [TestMethod] + public void Test_4387() + { + } + [TestMethod] + public void Test_4388() + { + } + [TestMethod] + public void Test_4389() + { + } + [TestMethod] + public void Test_4390() + { + } + [TestMethod] + public void Test_4391() + { + } + [TestMethod] + public void Test_4392() + { + } + [TestMethod] + public void Test_4393() + { + } + [TestMethod] + public void Test_4394() + { + } + [TestMethod] + public void Test_4395() + { + } + [TestMethod] + public void Test_4396() + { + } + [TestMethod] + public void Test_4397() + { + } + [TestMethod] + public void Test_4398() + { + } + [TestMethod] + public void Test_4399() + { + } + [TestMethod] + public void Test_4400() + { + } + [TestMethod] + public void Test_4401() + { + } + [TestMethod] + public void Test_4402() + { + } + [TestMethod] + public void Test_4403() + { + } + [TestMethod] + public void Test_4404() + { + } + [TestMethod] + public void Test_4405() + { + } + [TestMethod] + public void Test_4406() + { + } + [TestMethod] + public void Test_4407() + { + } + [TestMethod] + public void Test_4408() + { + } + [TestMethod] + public void Test_4409() + { + } + [TestMethod] + public void Test_4410() + { + } + [TestMethod] + public void Test_4411() + { + } + [TestMethod] + public void Test_4412() + { + } + [TestMethod] + public void Test_4413() + { + } + [TestMethod] + public void Test_4414() + { + } + [TestMethod] + public void Test_4415() + { + } + [TestMethod] + public void Test_4416() + { + } + [TestMethod] + public void Test_4417() + { + } + [TestMethod] + public void Test_4418() + { + } + [TestMethod] + public void Test_4419() + { + } + [TestMethod] + public void Test_4420() + { + } + [TestMethod] + public void Test_4421() + { + } + [TestMethod] + public void Test_4422() + { + } + [TestMethod] + public void Test_4423() + { + } + [TestMethod] + public void Test_4424() + { + } + [TestMethod] + public void Test_4425() + { + } + [TestMethod] + public void Test_4426() + { + } + [TestMethod] + public void Test_4427() + { + } + [TestMethod] + public void Test_4428() + { + } + [TestMethod] + public void Test_4429() + { + } + [TestMethod] + public void Test_4430() + { + } + [TestMethod] + public void Test_4431() + { + } + [TestMethod] + public void Test_4432() + { + } + [TestMethod] + public void Test_4433() + { + } + [TestMethod] + public void Test_4434() + { + } + [TestMethod] + public void Test_4435() + { + } + [TestMethod] + public void Test_4436() + { + } + [TestMethod] + public void Test_4437() + { + } + [TestMethod] + public void Test_4438() + { + } + [TestMethod] + public void Test_4439() + { + } + [TestMethod] + public void Test_4440() + { + } + [TestMethod] + public void Test_4441() + { + } + [TestMethod] + public void Test_4442() + { + } + [TestMethod] + public void Test_4443() + { + } + [TestMethod] + public void Test_4444() + { + } + [TestMethod] + public void Test_4445() + { + } + [TestMethod] + public void Test_4446() + { + } + [TestMethod] + public void Test_4447() + { + } + [TestMethod] + public void Test_4448() + { + } + [TestMethod] + public void Test_4449() + { + } + [TestMethod] + public void Test_4450() + { + } + [TestMethod] + public void Test_4451() + { + } + [TestMethod] + public void Test_4452() + { + } + [TestMethod] + public void Test_4453() + { + } + [TestMethod] + public void Test_4454() + { + } + [TestMethod] + public void Test_4455() + { + } + [TestMethod] + public void Test_4456() + { + } + [TestMethod] + public void Test_4457() + { + } + [TestMethod] + public void Test_4458() + { + } + [TestMethod] + public void Test_4459() + { + } + [TestMethod] + public void Test_4460() + { + } + [TestMethod] + public void Test_4461() + { + } + [TestMethod] + public void Test_4462() + { + } + [TestMethod] + public void Test_4463() + { + } + [TestMethod] + public void Test_4464() + { + } + [TestMethod] + public void Test_4465() + { + } + [TestMethod] + public void Test_4466() + { + } + [TestMethod] + public void Test_4467() + { + } + [TestMethod] + public void Test_4468() + { + } + [TestMethod] + public void Test_4469() + { + } + [TestMethod] + public void Test_4470() + { + } + [TestMethod] + public void Test_4471() + { + } + [TestMethod] + public void Test_4472() + { + } + [TestMethod] + public void Test_4473() + { + } + [TestMethod] + public void Test_4474() + { + } + [TestMethod] + public void Test_4475() + { + } + [TestMethod] + public void Test_4476() + { + } + [TestMethod] + public void Test_4477() + { + } + [TestMethod] + public void Test_4478() + { + } + [TestMethod] + public void Test_4479() + { + } + [TestMethod] + public void Test_4480() + { + } + [TestMethod] + public void Test_4481() + { + } + [TestMethod] + public void Test_4482() + { + } + [TestMethod] + public void Test_4483() + { + } + [TestMethod] + public void Test_4484() + { + } + [TestMethod] + public void Test_4485() + { + } + [TestMethod] + public void Test_4486() + { + } + [TestMethod] + public void Test_4487() + { + } + [TestMethod] + public void Test_4488() + { + } + [TestMethod] + public void Test_4489() + { + } + [TestMethod] + public void Test_4490() + { + } + [TestMethod] + public void Test_4491() + { + } + [TestMethod] + public void Test_4492() + { + } + [TestMethod] + public void Test_4493() + { + } + [TestMethod] + public void Test_4494() + { + } + [TestMethod] + public void Test_4495() + { + } + [TestMethod] + public void Test_4496() + { + } + [TestMethod] + public void Test_4497() + { + } + [TestMethod] + public void Test_4498() + { + } + [TestMethod] + public void Test_4499() + { + } + [TestMethod] + public void Test_4500() + { + } + [TestMethod] + public void Test_4501() + { + } + [TestMethod] + public void Test_4502() + { + } + [TestMethod] + public void Test_4503() + { + } + [TestMethod] + public void Test_4504() + { + } + [TestMethod] + public void Test_4505() + { + } + [TestMethod] + public void Test_4506() + { + } + [TestMethod] + public void Test_4507() + { + } + [TestMethod] + public void Test_4508() + { + } + [TestMethod] + public void Test_4509() + { + } + [TestMethod] + public void Test_4510() + { + } + [TestMethod] + public void Test_4511() + { + } + [TestMethod] + public void Test_4512() + { + } + [TestMethod] + public void Test_4513() + { + } + [TestMethod] + public void Test_4514() + { + } + [TestMethod] + public void Test_4515() + { + } + [TestMethod] + public void Test_4516() + { + } + [TestMethod] + public void Test_4517() + { + } + [TestMethod] + public void Test_4518() + { + } + [TestMethod] + public void Test_4519() + { + } + [TestMethod] + public void Test_4520() + { + } + [TestMethod] + public void Test_4521() + { + } + [TestMethod] + public void Test_4522() + { + } + [TestMethod] + public void Test_4523() + { + } + [TestMethod] + public void Test_4524() + { + } + [TestMethod] + public void Test_4525() + { + } + [TestMethod] + public void Test_4526() + { + } + [TestMethod] + public void Test_4527() + { + } + [TestMethod] + public void Test_4528() + { + } + [TestMethod] + public void Test_4529() + { + } + [TestMethod] + public void Test_4530() + { + } + [TestMethod] + public void Test_4531() + { + } + [TestMethod] + public void Test_4532() + { + } + [TestMethod] + public void Test_4533() + { + } + [TestMethod] + public void Test_4534() + { + } + [TestMethod] + public void Test_4535() + { + } + [TestMethod] + public void Test_4536() + { + } + [TestMethod] + public void Test_4537() + { + } + [TestMethod] + public void Test_4538() + { + } + [TestMethod] + public void Test_4539() + { + } + [TestMethod] + public void Test_4540() + { + } + [TestMethod] + public void Test_4541() + { + } + [TestMethod] + public void Test_4542() + { + } + [TestMethod] + public void Test_4543() + { + } + [TestMethod] + public void Test_4544() + { + } + [TestMethod] + public void Test_4545() + { + } + [TestMethod] + public void Test_4546() + { + } + [TestMethod] + public void Test_4547() + { + } + [TestMethod] + public void Test_4548() + { + } + [TestMethod] + public void Test_4549() + { + } + [TestMethod] + public void Test_4550() + { + } + [TestMethod] + public void Test_4551() + { + } + [TestMethod] + public void Test_4552() + { + } + [TestMethod] + public void Test_4553() + { + } + [TestMethod] + public void Test_4554() + { + } + [TestMethod] + public void Test_4555() + { + } + [TestMethod] + public void Test_4556() + { + } + [TestMethod] + public void Test_4557() + { + } + [TestMethod] + public void Test_4558() + { + } + [TestMethod] + public void Test_4559() + { + } + [TestMethod] + public void Test_4560() + { + } + [TestMethod] + public void Test_4561() + { + } + [TestMethod] + public void Test_4562() + { + } + [TestMethod] + public void Test_4563() + { + } + [TestMethod] + public void Test_4564() + { + } + [TestMethod] + public void Test_4565() + { + } + [TestMethod] + public void Test_4566() + { + } + [TestMethod] + public void Test_4567() + { + } + [TestMethod] + public void Test_4568() + { + } + [TestMethod] + public void Test_4569() + { + } + [TestMethod] + public void Test_4570() + { + } + [TestMethod] + public void Test_4571() + { + } + [TestMethod] + public void Test_4572() + { + } + [TestMethod] + public void Test_4573() + { + } + [TestMethod] + public void Test_4574() + { + } + [TestMethod] + public void Test_4575() + { + } + [TestMethod] + public void Test_4576() + { + } + [TestMethod] + public void Test_4577() + { + } + [TestMethod] + public void Test_4578() + { + } + [TestMethod] + public void Test_4579() + { + } + [TestMethod] + public void Test_4580() + { + } + [TestMethod] + public void Test_4581() + { + } + [TestMethod] + public void Test_4582() + { + } + [TestMethod] + public void Test_4583() + { + } + [TestMethod] + public void Test_4584() + { + } + [TestMethod] + public void Test_4585() + { + } + [TestMethod] + public void Test_4586() + { + } + [TestMethod] + public void Test_4587() + { + } + [TestMethod] + public void Test_4588() + { + } + [TestMethod] + public void Test_4589() + { + } + [TestMethod] + public void Test_4590() + { + } + [TestMethod] + public void Test_4591() + { + } + [TestMethod] + public void Test_4592() + { + } + [TestMethod] + public void Test_4593() + { + } + [TestMethod] + public void Test_4594() + { + } + [TestMethod] + public void Test_4595() + { + } + [TestMethod] + public void Test_4596() + { + } + [TestMethod] + public void Test_4597() + { + } + [TestMethod] + public void Test_4598() + { + } + [TestMethod] + public void Test_4599() + { + } + [TestMethod] + public void Test_4600() + { + } + [TestMethod] + public void Test_4601() + { + } + [TestMethod] + public void Test_4602() + { + } + [TestMethod] + public void Test_4603() + { + } + [TestMethod] + public void Test_4604() + { + } + [TestMethod] + public void Test_4605() + { + } + [TestMethod] + public void Test_4606() + { + } + [TestMethod] + public void Test_4607() + { + } + [TestMethod] + public void Test_4608() + { + } + [TestMethod] + public void Test_4609() + { + } + [TestMethod] + public void Test_4610() + { + } + [TestMethod] + public void Test_4611() + { + } + [TestMethod] + public void Test_4612() + { + } + [TestMethod] + public void Test_4613() + { + } + [TestMethod] + public void Test_4614() + { + } + [TestMethod] + public void Test_4615() + { + } + [TestMethod] + public void Test_4616() + { + } + [TestMethod] + public void Test_4617() + { + } + [TestMethod] + public void Test_4618() + { + } + [TestMethod] + public void Test_4619() + { + } + [TestMethod] + public void Test_4620() + { + } + [TestMethod] + public void Test_4621() + { + } + [TestMethod] + public void Test_4622() + { + } + [TestMethod] + public void Test_4623() + { + } + [TestMethod] + public void Test_4624() + { + } + [TestMethod] + public void Test_4625() + { + } + [TestMethod] + public void Test_4626() + { + } + [TestMethod] + public void Test_4627() + { + } + [TestMethod] + public void Test_4628() + { + } + [TestMethod] + public void Test_4629() + { + } + [TestMethod] + public void Test_4630() + { + } + [TestMethod] + public void Test_4631() + { + } + [TestMethod] + public void Test_4632() + { + } + [TestMethod] + public void Test_4633() + { + } + [TestMethod] + public void Test_4634() + { + } + [TestMethod] + public void Test_4635() + { + } + [TestMethod] + public void Test_4636() + { + } + [TestMethod] + public void Test_4637() + { + } + [TestMethod] + public void Test_4638() + { + } + [TestMethod] + public void Test_4639() + { + } + [TestMethod] + public void Test_4640() + { + } + [TestMethod] + public void Test_4641() + { + } + [TestMethod] + public void Test_4642() + { + } + [TestMethod] + public void Test_4643() + { + } + [TestMethod] + public void Test_4644() + { + } + [TestMethod] + public void Test_4645() + { + } + [TestMethod] + public void Test_4646() + { + } + [TestMethod] + public void Test_4647() + { + } + [TestMethod] + public void Test_4648() + { + } + [TestMethod] + public void Test_4649() + { + } + [TestMethod] + public void Test_4650() + { + } + [TestMethod] + public void Test_4651() + { + } + [TestMethod] + public void Test_4652() + { + } + [TestMethod] + public void Test_4653() + { + } + [TestMethod] + public void Test_4654() + { + } + [TestMethod] + public void Test_4655() + { + } + [TestMethod] + public void Test_4656() + { + } + [TestMethod] + public void Test_4657() + { + } + [TestMethod] + public void Test_4658() + { + } + [TestMethod] + public void Test_4659() + { + } + [TestMethod] + public void Test_4660() + { + } + [TestMethod] + public void Test_4661() + { + } + [TestMethod] + public void Test_4662() + { + } + [TestMethod] + public void Test_4663() + { + } + [TestMethod] + public void Test_4664() + { + } + [TestMethod] + public void Test_4665() + { + } + [TestMethod] + public void Test_4666() + { + } + [TestMethod] + public void Test_4667() + { + } + [TestMethod] + public void Test_4668() + { + } + [TestMethod] + public void Test_4669() + { + } + [TestMethod] + public void Test_4670() + { + } + [TestMethod] + public void Test_4671() + { + } + [TestMethod] + public void Test_4672() + { + } + [TestMethod] + public void Test_4673() + { + } + [TestMethod] + public void Test_4674() + { + } + [TestMethod] + public void Test_4675() + { + } + [TestMethod] + public void Test_4676() + { + } + [TestMethod] + public void Test_4677() + { + } + [TestMethod] + public void Test_4678() + { + } + [TestMethod] + public void Test_4679() + { + } + [TestMethod] + public void Test_4680() + { + } + [TestMethod] + public void Test_4681() + { + } + [TestMethod] + public void Test_4682() + { + } + [TestMethod] + public void Test_4683() + { + } + [TestMethod] + public void Test_4684() + { + } + [TestMethod] + public void Test_4685() + { + } + [TestMethod] + public void Test_4686() + { + } + [TestMethod] + public void Test_4687() + { + } + [TestMethod] + public void Test_4688() + { + } + [TestMethod] + public void Test_4689() + { + } + [TestMethod] + public void Test_4690() + { + } + [TestMethod] + public void Test_4691() + { + } + [TestMethod] + public void Test_4692() + { + } + [TestMethod] + public void Test_4693() + { + } + [TestMethod] + public void Test_4694() + { + } + [TestMethod] + public void Test_4695() + { + } + [TestMethod] + public void Test_4696() + { + } + [TestMethod] + public void Test_4697() + { + } + [TestMethod] + public void Test_4698() + { + } + [TestMethod] + public void Test_4699() + { + } + [TestMethod] + public void Test_4700() + { + } + [TestMethod] + public void Test_4701() + { + } + [TestMethod] + public void Test_4702() + { + } + [TestMethod] + public void Test_4703() + { + } + [TestMethod] + public void Test_4704() + { + } + [TestMethod] + public void Test_4705() + { + } + [TestMethod] + public void Test_4706() + { + } + [TestMethod] + public void Test_4707() + { + } + [TestMethod] + public void Test_4708() + { + } + [TestMethod] + public void Test_4709() + { + } + [TestMethod] + public void Test_4710() + { + } + [TestMethod] + public void Test_4711() + { + } + [TestMethod] + public void Test_4712() + { + } + [TestMethod] + public void Test_4713() + { + } + [TestMethod] + public void Test_4714() + { + } + [TestMethod] + public void Test_4715() + { + } + [TestMethod] + public void Test_4716() + { + } + [TestMethod] + public void Test_4717() + { + } + [TestMethod] + public void Test_4718() + { + } + [TestMethod] + public void Test_4719() + { + } + [TestMethod] + public void Test_4720() + { + } + [TestMethod] + public void Test_4721() + { + } + [TestMethod] + public void Test_4722() + { + } + [TestMethod] + public void Test_4723() + { + } + [TestMethod] + public void Test_4724() + { + } + [TestMethod] + public void Test_4725() + { + } + [TestMethod] + public void Test_4726() + { + } + [TestMethod] + public void Test_4727() + { + } + [TestMethod] + public void Test_4728() + { + } + [TestMethod] + public void Test_4729() + { + } + [TestMethod] + public void Test_4730() + { + } + [TestMethod] + public void Test_4731() + { + } + [TestMethod] + public void Test_4732() + { + } + [TestMethod] + public void Test_4733() + { + } + [TestMethod] + public void Test_4734() + { + } + [TestMethod] + public void Test_4735() + { + } + [TestMethod] + public void Test_4736() + { + } + [TestMethod] + public void Test_4737() + { + } + [TestMethod] + public void Test_4738() + { + } + [TestMethod] + public void Test_4739() + { + } + [TestMethod] + public void Test_4740() + { + } + [TestMethod] + public void Test_4741() + { + } + [TestMethod] + public void Test_4742() + { + } + [TestMethod] + public void Test_4743() + { + } + [TestMethod] + public void Test_4744() + { + } + [TestMethod] + public void Test_4745() + { + } + [TestMethod] + public void Test_4746() + { + } + [TestMethod] + public void Test_4747() + { + } + [TestMethod] + public void Test_4748() + { + } + [TestMethod] + public void Test_4749() + { + } + [TestMethod] + public void Test_4750() + { + } + [TestMethod] + public void Test_4751() + { + } + [TestMethod] + public void Test_4752() + { + } + [TestMethod] + public void Test_4753() + { + } + [TestMethod] + public void Test_4754() + { + } + [TestMethod] + public void Test_4755() + { + } + [TestMethod] + public void Test_4756() + { + } + [TestMethod] + public void Test_4757() + { + } + [TestMethod] + public void Test_4758() + { + } + [TestMethod] + public void Test_4759() + { + } + [TestMethod] + public void Test_4760() + { + } + [TestMethod] + public void Test_4761() + { + } + [TestMethod] + public void Test_4762() + { + } + [TestMethod] + public void Test_4763() + { + } + [TestMethod] + public void Test_4764() + { + } + [TestMethod] + public void Test_4765() + { + } + [TestMethod] + public void Test_4766() + { + } + [TestMethod] + public void Test_4767() + { + } + [TestMethod] + public void Test_4768() + { + } + [TestMethod] + public void Test_4769() + { + } + [TestMethod] + public void Test_4770() + { + } + [TestMethod] + public void Test_4771() + { + } + [TestMethod] + public void Test_4772() + { + } + [TestMethod] + public void Test_4773() + { + } + [TestMethod] + public void Test_4774() + { + } + [TestMethod] + public void Test_4775() + { + } + [TestMethod] + public void Test_4776() + { + } + [TestMethod] + public void Test_4777() + { + } + [TestMethod] + public void Test_4778() + { + } + [TestMethod] + public void Test_4779() + { + } + [TestMethod] + public void Test_4780() + { + } + [TestMethod] + public void Test_4781() + { + } + [TestMethod] + public void Test_4782() + { + } + [TestMethod] + public void Test_4783() + { + } + [TestMethod] + public void Test_4784() + { + } + [TestMethod] + public void Test_4785() + { + } + [TestMethod] + public void Test_4786() + { + } + [TestMethod] + public void Test_4787() + { + } + [TestMethod] + public void Test_4788() + { + } + [TestMethod] + public void Test_4789() + { + } + [TestMethod] + public void Test_4790() + { + } + [TestMethod] + public void Test_4791() + { + } + [TestMethod] + public void Test_4792() + { + } + [TestMethod] + public void Test_4793() + { + } + [TestMethod] + public void Test_4794() + { + } + [TestMethod] + public void Test_4795() + { + } + [TestMethod] + public void Test_4796() + { + } + [TestMethod] + public void Test_4797() + { + } + [TestMethod] + public void Test_4798() + { + } + [TestMethod] + public void Test_4799() + { + } + [TestMethod] + public void Test_4800() + { + } + [TestMethod] + public void Test_4801() + { + } + [TestMethod] + public void Test_4802() + { + } + [TestMethod] + public void Test_4803() + { + } + [TestMethod] + public void Test_4804() + { + } + [TestMethod] + public void Test_4805() + { + } + [TestMethod] + public void Test_4806() + { + } + [TestMethod] + public void Test_4807() + { + } + [TestMethod] + public void Test_4808() + { + } + [TestMethod] + public void Test_4809() + { + } + [TestMethod] + public void Test_4810() + { + } + [TestMethod] + public void Test_4811() + { + } + [TestMethod] + public void Test_4812() + { + } + [TestMethod] + public void Test_4813() + { + } + [TestMethod] + public void Test_4814() + { + } + [TestMethod] + public void Test_4815() + { + } + [TestMethod] + public void Test_4816() + { + } + [TestMethod] + public void Test_4817() + { + } + [TestMethod] + public void Test_4818() + { + } + [TestMethod] + public void Test_4819() + { + } + [TestMethod] + public void Test_4820() + { + } + [TestMethod] + public void Test_4821() + { + } + [TestMethod] + public void Test_4822() + { + } + [TestMethod] + public void Test_4823() + { + } + [TestMethod] + public void Test_4824() + { + } + [TestMethod] + public void Test_4825() + { + } + [TestMethod] + public void Test_4826() + { + } + [TestMethod] + public void Test_4827() + { + } + [TestMethod] + public void Test_4828() + { + } + [TestMethod] + public void Test_4829() + { + } + [TestMethod] + public void Test_4830() + { + } + [TestMethod] + public void Test_4831() + { + } + [TestMethod] + public void Test_4832() + { + } + [TestMethod] + public void Test_4833() + { + } + [TestMethod] + public void Test_4834() + { + } + [TestMethod] + public void Test_4835() + { + } + [TestMethod] + public void Test_4836() + { + } + [TestMethod] + public void Test_4837() + { + } + [TestMethod] + public void Test_4838() + { + } + [TestMethod] + public void Test_4839() + { + } + [TestMethod] + public void Test_4840() + { + } + [TestMethod] + public void Test_4841() + { + } + [TestMethod] + public void Test_4842() + { + } + [TestMethod] + public void Test_4843() + { + } + [TestMethod] + public void Test_4844() + { + } + [TestMethod] + public void Test_4845() + { + } + [TestMethod] + public void Test_4846() + { + } + [TestMethod] + public void Test_4847() + { + } + [TestMethod] + public void Test_4848() + { + } + [TestMethod] + public void Test_4849() + { + } + [TestMethod] + public void Test_4850() + { + } + [TestMethod] + public void Test_4851() + { + } + [TestMethod] + public void Test_4852() + { + } + [TestMethod] + public void Test_4853() + { + } + [TestMethod] + public void Test_4854() + { + } + [TestMethod] + public void Test_4855() + { + } + [TestMethod] + public void Test_4856() + { + } + [TestMethod] + public void Test_4857() + { + } + [TestMethod] + public void Test_4858() + { + } + [TestMethod] + public void Test_4859() + { + } + [TestMethod] + public void Test_4860() + { + } + [TestMethod] + public void Test_4861() + { + } + [TestMethod] + public void Test_4862() + { + } + [TestMethod] + public void Test_4863() + { + } + [TestMethod] + public void Test_4864() + { + } + [TestMethod] + public void Test_4865() + { + } + [TestMethod] + public void Test_4866() + { + } + [TestMethod] + public void Test_4867() + { + } + [TestMethod] + public void Test_4868() + { + } + [TestMethod] + public void Test_4869() + { + } + [TestMethod] + public void Test_4870() + { + } + [TestMethod] + public void Test_4871() + { + } + [TestMethod] + public void Test_4872() + { + } + [TestMethod] + public void Test_4873() + { + } + [TestMethod] + public void Test_4874() + { + } + [TestMethod] + public void Test_4875() + { + } + [TestMethod] + public void Test_4876() + { + } + [TestMethod] + public void Test_4877() + { + } + [TestMethod] + public void Test_4878() + { + } + [TestMethod] + public void Test_4879() + { + } + [TestMethod] + public void Test_4880() + { + } + [TestMethod] + public void Test_4881() + { + } + [TestMethod] + public void Test_4882() + { + } + [TestMethod] + public void Test_4883() + { + } + [TestMethod] + public void Test_4884() + { + } + [TestMethod] + public void Test_4885() + { + } + [TestMethod] + public void Test_4886() + { + } + [TestMethod] + public void Test_4887() + { + } + [TestMethod] + public void Test_4888() + { + } + [TestMethod] + public void Test_4889() + { + } + [TestMethod] + public void Test_4890() + { + } + [TestMethod] + public void Test_4891() + { + } + [TestMethod] + public void Test_4892() + { + } + [TestMethod] + public void Test_4893() + { + } + [TestMethod] + public void Test_4894() + { + } + [TestMethod] + public void Test_4895() + { + } + [TestMethod] + public void Test_4896() + { + } + [TestMethod] + public void Test_4897() + { + } + [TestMethod] + public void Test_4898() + { + } + [TestMethod] + public void Test_4899() + { + } + [TestMethod] + public void Test_4900() + { + } + [TestMethod] + public void Test_4901() + { + } + [TestMethod] + public void Test_4902() + { + } + [TestMethod] + public void Test_4903() + { + } + [TestMethod] + public void Test_4904() + { + } + [TestMethod] + public void Test_4905() + { + } + [TestMethod] + public void Test_4906() + { + } + [TestMethod] + public void Test_4907() + { + } + [TestMethod] + public void Test_4908() + { + } + [TestMethod] + public void Test_4909() + { + } + [TestMethod] + public void Test_4910() + { + } + [TestMethod] + public void Test_4911() + { + } + [TestMethod] + public void Test_4912() + { + } + [TestMethod] + public void Test_4913() + { + } + [TestMethod] + public void Test_4914() + { + } + [TestMethod] + public void Test_4915() + { + } + [TestMethod] + public void Test_4916() + { + } + [TestMethod] + public void Test_4917() + { + } + [TestMethod] + public void Test_4918() + { + } + [TestMethod] + public void Test_4919() + { + } + [TestMethod] + public void Test_4920() + { + } + [TestMethod] + public void Test_4921() + { + } + [TestMethod] + public void Test_4922() + { + } + [TestMethod] + public void Test_4923() + { + } + [TestMethod] + public void Test_4924() + { + } + [TestMethod] + public void Test_4925() + { + } + [TestMethod] + public void Test_4926() + { + } + [TestMethod] + public void Test_4927() + { + } + [TestMethod] + public void Test_4928() + { + } + [TestMethod] + public void Test_4929() + { + } + [TestMethod] + public void Test_4930() + { + } + [TestMethod] + public void Test_4931() + { + } + [TestMethod] + public void Test_4932() + { + } + [TestMethod] + public void Test_4933() + { + } + [TestMethod] + public void Test_4934() + { + } + [TestMethod] + public void Test_4935() + { + } + [TestMethod] + public void Test_4936() + { + } + [TestMethod] + public void Test_4937() + { + } + [TestMethod] + public void Test_4938() + { + } + [TestMethod] + public void Test_4939() + { + } + [TestMethod] + public void Test_4940() + { + } + [TestMethod] + public void Test_4941() + { + } + [TestMethod] + public void Test_4942() + { + } + [TestMethod] + public void Test_4943() + { + } + [TestMethod] + public void Test_4944() + { + } + [TestMethod] + public void Test_4945() + { + } + [TestMethod] + public void Test_4946() + { + } + [TestMethod] + public void Test_4947() + { + } + [TestMethod] + public void Test_4948() + { + } + [TestMethod] + public void Test_4949() + { + } + [TestMethod] + public void Test_4950() + { + } + [TestMethod] + public void Test_4951() + { + } + [TestMethod] + public void Test_4952() + { + } + [TestMethod] + public void Test_4953() + { + } + [TestMethod] + public void Test_4954() + { + } + [TestMethod] + public void Test_4955() + { + } + [TestMethod] + public void Test_4956() + { + } + [TestMethod] + public void Test_4957() + { + } + [TestMethod] + public void Test_4958() + { + } + [TestMethod] + public void Test_4959() + { + } + [TestMethod] + public void Test_4960() + { + } + [TestMethod] + public void Test_4961() + { + } + [TestMethod] + public void Test_4962() + { + } + [TestMethod] + public void Test_4963() + { + } + [TestMethod] + public void Test_4964() + { + } + [TestMethod] + public void Test_4965() + { + } + [TestMethod] + public void Test_4966() + { + } + [TestMethod] + public void Test_4967() + { + } + [TestMethod] + public void Test_4968() + { + } + [TestMethod] + public void Test_4969() + { + } + [TestMethod] + public void Test_4970() + { + } + [TestMethod] + public void Test_4971() + { + } + [TestMethod] + public void Test_4972() + { + } + [TestMethod] + public void Test_4973() + { + } + [TestMethod] + public void Test_4974() + { + } + [TestMethod] + public void Test_4975() + { + } + [TestMethod] + public void Test_4976() + { + } + [TestMethod] + public void Test_4977() + { + } + [TestMethod] + public void Test_4978() + { + } + [TestMethod] + public void Test_4979() + { + } + [TestMethod] + public void Test_4980() + { + } + [TestMethod] + public void Test_4981() + { + } + [TestMethod] + public void Test_4982() + { + } + [TestMethod] + public void Test_4983() + { + } + [TestMethod] + public void Test_4984() + { + } + [TestMethod] + public void Test_4985() + { + } + [TestMethod] + public void Test_4986() + { + } + [TestMethod] + public void Test_4987() + { + } + [TestMethod] + public void Test_4988() + { + } + [TestMethod] + public void Test_4989() + { + } + [TestMethod] + public void Test_4990() + { + } + [TestMethod] + public void Test_4991() + { + } + [TestMethod] + public void Test_4992() + { + } + [TestMethod] + public void Test_4993() + { + } + [TestMethod] + public void Test_4994() + { + } + [TestMethod] + public void Test_4995() + { + } + [TestMethod] + public void Test_4996() + { + } + [TestMethod] + public void Test_4997() + { + } + [TestMethod] + public void Test_4998() + { + } + [TestMethod] + public void Test_4999() + { + } + [TestMethod] + public void Test_5000() + { + } + [TestMethod] + public void Test_5001() + { + } + [TestMethod] + public void Test_5002() + { + } + [TestMethod] + public void Test_5003() + { + } + [TestMethod] + public void Test_5004() + { + } + [TestMethod] + public void Test_5005() + { + } + [TestMethod] + public void Test_5006() + { + } + [TestMethod] + public void Test_5007() + { + } + [TestMethod] + public void Test_5008() + { + } + [TestMethod] + public void Test_5009() + { + } + [TestMethod] + public void Test_5010() + { + } + [TestMethod] + public void Test_5011() + { + } + [TestMethod] + public void Test_5012() + { + } + [TestMethod] + public void Test_5013() + { + } + [TestMethod] + public void Test_5014() + { + } + [TestMethod] + public void Test_5015() + { + } + [TestMethod] + public void Test_5016() + { + } + [TestMethod] + public void Test_5017() + { + } + [TestMethod] + public void Test_5018() + { + } + [TestMethod] + public void Test_5019() + { + } + [TestMethod] + public void Test_5020() + { + } + [TestMethod] + public void Test_5021() + { + } + [TestMethod] + public void Test_5022() + { + } + [TestMethod] + public void Test_5023() + { + } + [TestMethod] + public void Test_5024() + { + } + [TestMethod] + public void Test_5025() + { + } + [TestMethod] + public void Test_5026() + { + } + [TestMethod] + public void Test_5027() + { + } + [TestMethod] + public void Test_5028() + { + } + [TestMethod] + public void Test_5029() + { + } + [TestMethod] + public void Test_5030() + { + } + [TestMethod] + public void Test_5031() + { + } + [TestMethod] + public void Test_5032() + { + } + [TestMethod] + public void Test_5033() + { + } + [TestMethod] + public void Test_5034() + { + } + [TestMethod] + public void Test_5035() + { + } + [TestMethod] + public void Test_5036() + { + } + [TestMethod] + public void Test_5037() + { + } + [TestMethod] + public void Test_5038() + { + } + [TestMethod] + public void Test_5039() + { + } + [TestMethod] + public void Test_5040() + { + } + [TestMethod] + public void Test_5041() + { + } + [TestMethod] + public void Test_5042() + { + } + [TestMethod] + public void Test_5043() + { + } + [TestMethod] + public void Test_5044() + { + } + [TestMethod] + public void Test_5045() + { + } + [TestMethod] + public void Test_5046() + { + } + [TestMethod] + public void Test_5047() + { + } + [TestMethod] + public void Test_5048() + { + } + [TestMethod] + public void Test_5049() + { + } + [TestMethod] + public void Test_5050() + { + } + [TestMethod] + public void Test_5051() + { + } + [TestMethod] + public void Test_5052() + { + } + [TestMethod] + public void Test_5053() + { + } + [TestMethod] + public void Test_5054() + { + } + [TestMethod] + public void Test_5055() + { + } + [TestMethod] + public void Test_5056() + { + } + [TestMethod] + public void Test_5057() + { + } + [TestMethod] + public void Test_5058() + { + } + [TestMethod] + public void Test_5059() + { + } + [TestMethod] + public void Test_5060() + { + } + [TestMethod] + public void Test_5061() + { + } + [TestMethod] + public void Test_5062() + { + } + [TestMethod] + public void Test_5063() + { + } + [TestMethod] + public void Test_5064() + { + } + [TestMethod] + public void Test_5065() + { + } + [TestMethod] + public void Test_5066() + { + } + [TestMethod] + public void Test_5067() + { + } + [TestMethod] + public void Test_5068() + { + } + [TestMethod] + public void Test_5069() + { + } + [TestMethod] + public void Test_5070() + { + } + [TestMethod] + public void Test_5071() + { + } + [TestMethod] + public void Test_5072() + { + } + [TestMethod] + public void Test_5073() + { + } + [TestMethod] + public void Test_5074() + { + } + [TestMethod] + public void Test_5075() + { + } + [TestMethod] + public void Test_5076() + { + } + [TestMethod] + public void Test_5077() + { + } + [TestMethod] + public void Test_5078() + { + } + [TestMethod] + public void Test_5079() + { + } + [TestMethod] + public void Test_5080() + { + } + [TestMethod] + public void Test_5081() + { + } + [TestMethod] + public void Test_5082() + { + } + [TestMethod] + public void Test_5083() + { + } + [TestMethod] + public void Test_5084() + { + } + [TestMethod] + public void Test_5085() + { + } + [TestMethod] + public void Test_5086() + { + } + [TestMethod] + public void Test_5087() + { + } + [TestMethod] + public void Test_5088() + { + } + [TestMethod] + public void Test_5089() + { + } + [TestMethod] + public void Test_5090() + { + } + [TestMethod] + public void Test_5091() + { + } + [TestMethod] + public void Test_5092() + { + } + [TestMethod] + public void Test_5093() + { + } + [TestMethod] + public void Test_5094() + { + } + [TestMethod] + public void Test_5095() + { + } + [TestMethod] + public void Test_5096() + { + } + [TestMethod] + public void Test_5097() + { + } + [TestMethod] + public void Test_5098() + { + } + [TestMethod] + public void Test_5099() + { + } + [TestMethod] + public void Test_5100() + { + } + [TestMethod] + public void Test_5101() + { + } + [TestMethod] + public void Test_5102() + { + } + [TestMethod] + public void Test_5103() + { + } + [TestMethod] + public void Test_5104() + { + } + [TestMethod] + public void Test_5105() + { + } + [TestMethod] + public void Test_5106() + { + } + [TestMethod] + public void Test_5107() + { + } + [TestMethod] + public void Test_5108() + { + } + [TestMethod] + public void Test_5109() + { + } + [TestMethod] + public void Test_5110() + { + } + [TestMethod] + public void Test_5111() + { + } + [TestMethod] + public void Test_5112() + { + } + [TestMethod] + public void Test_5113() + { + } + [TestMethod] + public void Test_5114() + { + } + [TestMethod] + public void Test_5115() + { + } + [TestMethod] + public void Test_5116() + { + } + [TestMethod] + public void Test_5117() + { + } + [TestMethod] + public void Test_5118() + { + } + [TestMethod] + public void Test_5119() + { + } + [TestMethod] + public void Test_5120() + { + } + [TestMethod] + public void Test_5121() + { + } + [TestMethod] + public void Test_5122() + { + } + [TestMethod] + public void Test_5123() + { + } + [TestMethod] + public void Test_5124() + { + } + [TestMethod] + public void Test_5125() + { + } + [TestMethod] + public void Test_5126() + { + } + [TestMethod] + public void Test_5127() + { + } + [TestMethod] + public void Test_5128() + { + } + [TestMethod] + public void Test_5129() + { + } + [TestMethod] + public void Test_5130() + { + } + [TestMethod] + public void Test_5131() + { + } + [TestMethod] + public void Test_5132() + { + } + [TestMethod] + public void Test_5133() + { + } + [TestMethod] + public void Test_5134() + { + } + [TestMethod] + public void Test_5135() + { + } + [TestMethod] + public void Test_5136() + { + } + [TestMethod] + public void Test_5137() + { + } + [TestMethod] + public void Test_5138() + { + } + [TestMethod] + public void Test_5139() + { + } + [TestMethod] + public void Test_5140() + { + } + [TestMethod] + public void Test_5141() + { + } + [TestMethod] + public void Test_5142() + { + } + [TestMethod] + public void Test_5143() + { + } + [TestMethod] + public void Test_5144() + { + } + [TestMethod] + public void Test_5145() + { + } + [TestMethod] + public void Test_5146() + { + } + [TestMethod] + public void Test_5147() + { + } + [TestMethod] + public void Test_5148() + { + } + [TestMethod] + public void Test_5149() + { + } + [TestMethod] + public void Test_5150() + { + } + [TestMethod] + public void Test_5151() + { + } + [TestMethod] + public void Test_5152() + { + } + [TestMethod] + public void Test_5153() + { + } + [TestMethod] + public void Test_5154() + { + } + [TestMethod] + public void Test_5155() + { + } + [TestMethod] + public void Test_5156() + { + } + [TestMethod] + public void Test_5157() + { + } + [TestMethod] + public void Test_5158() + { + } + [TestMethod] + public void Test_5159() + { + } + [TestMethod] + public void Test_5160() + { + } + [TestMethod] + public void Test_5161() + { + } + [TestMethod] + public void Test_5162() + { + } + [TestMethod] + public void Test_5163() + { + } + [TestMethod] + public void Test_5164() + { + } + [TestMethod] + public void Test_5165() + { + } + [TestMethod] + public void Test_5166() + { + } + [TestMethod] + public void Test_5167() + { + } + [TestMethod] + public void Test_5168() + { + } + [TestMethod] + public void Test_5169() + { + } + [TestMethod] + public void Test_5170() + { + } + [TestMethod] + public void Test_5171() + { + } + [TestMethod] + public void Test_5172() + { + } + [TestMethod] + public void Test_5173() + { + } + [TestMethod] + public void Test_5174() + { + } + [TestMethod] + public void Test_5175() + { + } + [TestMethod] + public void Test_5176() + { + } + [TestMethod] + public void Test_5177() + { + } + [TestMethod] + public void Test_5178() + { + } + [TestMethod] + public void Test_5179() + { + } + [TestMethod] + public void Test_5180() + { + } + [TestMethod] + public void Test_5181() + { + } + [TestMethod] + public void Test_5182() + { + } + [TestMethod] + public void Test_5183() + { + } + [TestMethod] + public void Test_5184() + { + } + [TestMethod] + public void Test_5185() + { + } + [TestMethod] + public void Test_5186() + { + } + [TestMethod] + public void Test_5187() + { + } + [TestMethod] + public void Test_5188() + { + } + [TestMethod] + public void Test_5189() + { + } + [TestMethod] + public void Test_5190() + { + } + [TestMethod] + public void Test_5191() + { + } + [TestMethod] + public void Test_5192() + { + } + [TestMethod] + public void Test_5193() + { + } + [TestMethod] + public void Test_5194() + { + } + [TestMethod] + public void Test_5195() + { + } + [TestMethod] + public void Test_5196() + { + } + [TestMethod] + public void Test_5197() + { + } + [TestMethod] + public void Test_5198() + { + } + [TestMethod] + public void Test_5199() + { + } + [TestMethod] + public void Test_5200() + { + } + [TestMethod] + public void Test_5201() + { + } + [TestMethod] + public void Test_5202() + { + } + [TestMethod] + public void Test_5203() + { + } + [TestMethod] + public void Test_5204() + { + } + [TestMethod] + public void Test_5205() + { + } + [TestMethod] + public void Test_5206() + { + } + [TestMethod] + public void Test_5207() + { + } + [TestMethod] + public void Test_5208() + { + } + [TestMethod] + public void Test_5209() + { + } + [TestMethod] + public void Test_5210() + { + } + [TestMethod] + public void Test_5211() + { + } + [TestMethod] + public void Test_5212() + { + } + [TestMethod] + public void Test_5213() + { + } + [TestMethod] + public void Test_5214() + { + } + [TestMethod] + public void Test_5215() + { + } + [TestMethod] + public void Test_5216() + { + } + [TestMethod] + public void Test_5217() + { + } + [TestMethod] + public void Test_5218() + { + } + [TestMethod] + public void Test_5219() + { + } + [TestMethod] + public void Test_5220() + { + } + [TestMethod] + public void Test_5221() + { + } + [TestMethod] + public void Test_5222() + { + } + [TestMethod] + public void Test_5223() + { + } + [TestMethod] + public void Test_5224() + { + } + [TestMethod] + public void Test_5225() + { + } + [TestMethod] + public void Test_5226() + { + } + [TestMethod] + public void Test_5227() + { + } + [TestMethod] + public void Test_5228() + { + } + [TestMethod] + public void Test_5229() + { + } + [TestMethod] + public void Test_5230() + { + } + [TestMethod] + public void Test_5231() + { + } + [TestMethod] + public void Test_5232() + { + } + [TestMethod] + public void Test_5233() + { + } + [TestMethod] + public void Test_5234() + { + } + [TestMethod] + public void Test_5235() + { + } + [TestMethod] + public void Test_5236() + { + } + [TestMethod] + public void Test_5237() + { + } + [TestMethod] + public void Test_5238() + { + } + [TestMethod] + public void Test_5239() + { + } + [TestMethod] + public void Test_5240() + { + } + [TestMethod] + public void Test_5241() + { + } + [TestMethod] + public void Test_5242() + { + } + [TestMethod] + public void Test_5243() + { + } + [TestMethod] + public void Test_5244() + { + } + [TestMethod] + public void Test_5245() + { + } + [TestMethod] + public void Test_5246() + { + } + [TestMethod] + public void Test_5247() + { + } + [TestMethod] + public void Test_5248() + { + } + [TestMethod] + public void Test_5249() + { + } + [TestMethod] + public void Test_5250() + { + } + [TestMethod] + public void Test_5251() + { + } + [TestMethod] + public void Test_5252() + { + } + [TestMethod] + public void Test_5253() + { + } + [TestMethod] + public void Test_5254() + { + } + [TestMethod] + public void Test_5255() + { + } + [TestMethod] + public void Test_5256() + { + } + [TestMethod] + public void Test_5257() + { + } + [TestMethod] + public void Test_5258() + { + } + [TestMethod] + public void Test_5259() + { + } + [TestMethod] + public void Test_5260() + { + } + [TestMethod] + public void Test_5261() + { + } + [TestMethod] + public void Test_5262() + { + } + [TestMethod] + public void Test_5263() + { + } + [TestMethod] + public void Test_5264() + { + } + [TestMethod] + public void Test_5265() + { + } + [TestMethod] + public void Test_5266() + { + } + [TestMethod] + public void Test_5267() + { + } + [TestMethod] + public void Test_5268() + { + } + [TestMethod] + public void Test_5269() + { + } + [TestMethod] + public void Test_5270() + { + } + [TestMethod] + public void Test_5271() + { + } + [TestMethod] + public void Test_5272() + { + } + [TestMethod] + public void Test_5273() + { + } + [TestMethod] + public void Test_5274() + { + } + [TestMethod] + public void Test_5275() + { + } + [TestMethod] + public void Test_5276() + { + } + [TestMethod] + public void Test_5277() + { + } + [TestMethod] + public void Test_5278() + { + } + [TestMethod] + public void Test_5279() + { + } + [TestMethod] + public void Test_5280() + { + } + [TestMethod] + public void Test_5281() + { + } + [TestMethod] + public void Test_5282() + { + } + [TestMethod] + public void Test_5283() + { + } + [TestMethod] + public void Test_5284() + { + } + [TestMethod] + public void Test_5285() + { + } + [TestMethod] + public void Test_5286() + { + } + [TestMethod] + public void Test_5287() + { + } + [TestMethod] + public void Test_5288() + { + } + [TestMethod] + public void Test_5289() + { + } + [TestMethod] + public void Test_5290() + { + } + [TestMethod] + public void Test_5291() + { + } + [TestMethod] + public void Test_5292() + { + } + [TestMethod] + public void Test_5293() + { + } + [TestMethod] + public void Test_5294() + { + } + [TestMethod] + public void Test_5295() + { + } + [TestMethod] + public void Test_5296() + { + } + [TestMethod] + public void Test_5297() + { + } + [TestMethod] + public void Test_5298() + { + } + [TestMethod] + public void Test_5299() + { + } + [TestMethod] + public void Test_5300() + { + } + [TestMethod] + public void Test_5301() + { + } + [TestMethod] + public void Test_5302() + { + } + [TestMethod] + public void Test_5303() + { + } + [TestMethod] + public void Test_5304() + { + } + [TestMethod] + public void Test_5305() + { + } + [TestMethod] + public void Test_5306() + { + } + [TestMethod] + public void Test_5307() + { + } + [TestMethod] + public void Test_5308() + { + } + [TestMethod] + public void Test_5309() + { + } + [TestMethod] + public void Test_5310() + { + } + [TestMethod] + public void Test_5311() + { + } + [TestMethod] + public void Test_5312() + { + } + [TestMethod] + public void Test_5313() + { + } + [TestMethod] + public void Test_5314() + { + } + [TestMethod] + public void Test_5315() + { + } + [TestMethod] + public void Test_5316() + { + } + [TestMethod] + public void Test_5317() + { + } + [TestMethod] + public void Test_5318() + { + } + [TestMethod] + public void Test_5319() + { + } + [TestMethod] + public void Test_5320() + { + } + [TestMethod] + public void Test_5321() + { + } + [TestMethod] + public void Test_5322() + { + } + [TestMethod] + public void Test_5323() + { + } + [TestMethod] + public void Test_5324() + { + } + [TestMethod] + public void Test_5325() + { + } + [TestMethod] + public void Test_5326() + { + } + [TestMethod] + public void Test_5327() + { + } + [TestMethod] + public void Test_5328() + { + } + [TestMethod] + public void Test_5329() + { + } + [TestMethod] + public void Test_5330() + { + } + [TestMethod] + public void Test_5331() + { + } + [TestMethod] + public void Test_5332() + { + } + [TestMethod] + public void Test_5333() + { + } + [TestMethod] + public void Test_5334() + { + } + [TestMethod] + public void Test_5335() + { + } + [TestMethod] + public void Test_5336() + { + } + [TestMethod] + public void Test_5337() + { + } + [TestMethod] + public void Test_5338() + { + } + [TestMethod] + public void Test_5339() + { + } + [TestMethod] + public void Test_5340() + { + } + [TestMethod] + public void Test_5341() + { + } + [TestMethod] + public void Test_5342() + { + } + [TestMethod] + public void Test_5343() + { + } + [TestMethod] + public void Test_5344() + { + } + [TestMethod] + public void Test_5345() + { + } + [TestMethod] + public void Test_5346() + { + } + [TestMethod] + public void Test_5347() + { + } + [TestMethod] + public void Test_5348() + { + } + [TestMethod] + public void Test_5349() + { + } + [TestMethod] + public void Test_5350() + { + } + [TestMethod] + public void Test_5351() + { + } + [TestMethod] + public void Test_5352() + { + } + [TestMethod] + public void Test_5353() + { + } + [TestMethod] + public void Test_5354() + { + } + [TestMethod] + public void Test_5355() + { + } + [TestMethod] + public void Test_5356() + { + } + [TestMethod] + public void Test_5357() + { + } + [TestMethod] + public void Test_5358() + { + } + [TestMethod] + public void Test_5359() + { + } + [TestMethod] + public void Test_5360() + { + } + [TestMethod] + public void Test_5361() + { + } + [TestMethod] + public void Test_5362() + { + } + [TestMethod] + public void Test_5363() + { + } + [TestMethod] + public void Test_5364() + { + } + [TestMethod] + public void Test_5365() + { + } + [TestMethod] + public void Test_5366() + { + } + [TestMethod] + public void Test_5367() + { + } + [TestMethod] + public void Test_5368() + { + } + [TestMethod] + public void Test_5369() + { + } + [TestMethod] + public void Test_5370() + { + } + [TestMethod] + public void Test_5371() + { + } + [TestMethod] + public void Test_5372() + { + } + [TestMethod] + public void Test_5373() + { + } + [TestMethod] + public void Test_5374() + { + } + [TestMethod] + public void Test_5375() + { + } + [TestMethod] + public void Test_5376() + { + } + [TestMethod] + public void Test_5377() + { + } + [TestMethod] + public void Test_5378() + { + } + [TestMethod] + public void Test_5379() + { + } + [TestMethod] + public void Test_5380() + { + } + [TestMethod] + public void Test_5381() + { + } + [TestMethod] + public void Test_5382() + { + } + [TestMethod] + public void Test_5383() + { + } + [TestMethod] + public void Test_5384() + { + } + [TestMethod] + public void Test_5385() + { + } + [TestMethod] + public void Test_5386() + { + } + [TestMethod] + public void Test_5387() + { + } + [TestMethod] + public void Test_5388() + { + } + [TestMethod] + public void Test_5389() + { + } + [TestMethod] + public void Test_5390() + { + } + [TestMethod] + public void Test_5391() + { + } + [TestMethod] + public void Test_5392() + { + } + [TestMethod] + public void Test_5393() + { + } + [TestMethod] + public void Test_5394() + { + } + [TestMethod] + public void Test_5395() + { + } + [TestMethod] + public void Test_5396() + { + } + [TestMethod] + public void Test_5397() + { + } + [TestMethod] + public void Test_5398() + { + } + [TestMethod] + public void Test_5399() + { + } + [TestMethod] + public void Test_5400() + { + } + [TestMethod] + public void Test_5401() + { + } + [TestMethod] + public void Test_5402() + { + } + [TestMethod] + public void Test_5403() + { + } + [TestMethod] + public void Test_5404() + { + } + [TestMethod] + public void Test_5405() + { + } + [TestMethod] + public void Test_5406() + { + } + [TestMethod] + public void Test_5407() + { + } + [TestMethod] + public void Test_5408() + { + } + [TestMethod] + public void Test_5409() + { + } + [TestMethod] + public void Test_5410() + { + } + [TestMethod] + public void Test_5411() + { + } + [TestMethod] + public void Test_5412() + { + } + [TestMethod] + public void Test_5413() + { + } + [TestMethod] + public void Test_5414() + { + } + [TestMethod] + public void Test_5415() + { + } + [TestMethod] + public void Test_5416() + { + } + [TestMethod] + public void Test_5417() + { + } + [TestMethod] + public void Test_5418() + { + } + [TestMethod] + public void Test_5419() + { + } + [TestMethod] + public void Test_5420() + { + } + [TestMethod] + public void Test_5421() + { + } + [TestMethod] + public void Test_5422() + { + } + [TestMethod] + public void Test_5423() + { + } + [TestMethod] + public void Test_5424() + { + } + [TestMethod] + public void Test_5425() + { + } + [TestMethod] + public void Test_5426() + { + } + [TestMethod] + public void Test_5427() + { + } + [TestMethod] + public void Test_5428() + { + } + [TestMethod] + public void Test_5429() + { + } + [TestMethod] + public void Test_5430() + { + } + [TestMethod] + public void Test_5431() + { + } + [TestMethod] + public void Test_5432() + { + } + [TestMethod] + public void Test_5433() + { + } + [TestMethod] + public void Test_5434() + { + } + [TestMethod] + public void Test_5435() + { + } + [TestMethod] + public void Test_5436() + { + } + [TestMethod] + public void Test_5437() + { + } + [TestMethod] + public void Test_5438() + { + } + [TestMethod] + public void Test_5439() + { + } + [TestMethod] + public void Test_5440() + { + } + [TestMethod] + public void Test_5441() + { + } + [TestMethod] + public void Test_5442() + { + } + [TestMethod] + public void Test_5443() + { + } + [TestMethod] + public void Test_5444() + { + } + [TestMethod] + public void Test_5445() + { + } + [TestMethod] + public void Test_5446() + { + } + [TestMethod] + public void Test_5447() + { + } + [TestMethod] + public void Test_5448() + { + } + [TestMethod] + public void Test_5449() + { + } + [TestMethod] + public void Test_5450() + { + } + [TestMethod] + public void Test_5451() + { + } + [TestMethod] + public void Test_5452() + { + } + [TestMethod] + public void Test_5453() + { + } + [TestMethod] + public void Test_5454() + { + } + [TestMethod] + public void Test_5455() + { + } + [TestMethod] + public void Test_5456() + { + } + [TestMethod] + public void Test_5457() + { + } + [TestMethod] + public void Test_5458() + { + } + [TestMethod] + public void Test_5459() + { + } + [TestMethod] + public void Test_5460() + { + } + [TestMethod] + public void Test_5461() + { + } + [TestMethod] + public void Test_5462() + { + } + [TestMethod] + public void Test_5463() + { + } + [TestMethod] + public void Test_5464() + { + } + [TestMethod] + public void Test_5465() + { + } + [TestMethod] + public void Test_5466() + { + } + [TestMethod] + public void Test_5467() + { + } + [TestMethod] + public void Test_5468() + { + } + [TestMethod] + public void Test_5469() + { + } + [TestMethod] + public void Test_5470() + { + } + [TestMethod] + public void Test_5471() + { + } + [TestMethod] + public void Test_5472() + { + } + [TestMethod] + public void Test_5473() + { + } + [TestMethod] + public void Test_5474() + { + } + [TestMethod] + public void Test_5475() + { + } + [TestMethod] + public void Test_5476() + { + } + [TestMethod] + public void Test_5477() + { + } + [TestMethod] + public void Test_5478() + { + } + [TestMethod] + public void Test_5479() + { + } + [TestMethod] + public void Test_5480() + { + } + [TestMethod] + public void Test_5481() + { + } + [TestMethod] + public void Test_5482() + { + } + [TestMethod] + public void Test_5483() + { + } + [TestMethod] + public void Test_5484() + { + } + [TestMethod] + public void Test_5485() + { + } + [TestMethod] + public void Test_5486() + { + } + [TestMethod] + public void Test_5487() + { + } + [TestMethod] + public void Test_5488() + { + } + [TestMethod] + public void Test_5489() + { + } + [TestMethod] + public void Test_5490() + { + } + [TestMethod] + public void Test_5491() + { + } + [TestMethod] + public void Test_5492() + { + } + [TestMethod] + public void Test_5493() + { + } + [TestMethod] + public void Test_5494() + { + } + [TestMethod] + public void Test_5495() + { + } + [TestMethod] + public void Test_5496() + { + } + [TestMethod] + public void Test_5497() + { + } + [TestMethod] + public void Test_5498() + { + } + [TestMethod] + public void Test_5499() + { + } + [TestMethod] + public void Test_5500() + { + } + [TestMethod] + public void Test_5501() + { + } + [TestMethod] + public void Test_5502() + { + } + [TestMethod] + public void Test_5503() + { + } + [TestMethod] + public void Test_5504() + { + } + [TestMethod] + public void Test_5505() + { + } + [TestMethod] + public void Test_5506() + { + } + [TestMethod] + public void Test_5507() + { + } + [TestMethod] + public void Test_5508() + { + } + [TestMethod] + public void Test_5509() + { + } + [TestMethod] + public void Test_5510() + { + } + [TestMethod] + public void Test_5511() + { + } + [TestMethod] + public void Test_5512() + { + } + [TestMethod] + public void Test_5513() + { + } + [TestMethod] + public void Test_5514() + { + } + [TestMethod] + public void Test_5515() + { + } + [TestMethod] + public void Test_5516() + { + } + [TestMethod] + public void Test_5517() + { + } + [TestMethod] + public void Test_5518() + { + } + [TestMethod] + public void Test_5519() + { + } + [TestMethod] + public void Test_5520() + { + } + [TestMethod] + public void Test_5521() + { + } + [TestMethod] + public void Test_5522() + { + } + [TestMethod] + public void Test_5523() + { + } + [TestMethod] + public void Test_5524() + { + } + [TestMethod] + public void Test_5525() + { + } + [TestMethod] + public void Test_5526() + { + } + [TestMethod] + public void Test_5527() + { + } + [TestMethod] + public void Test_5528() + { + } + [TestMethod] + public void Test_5529() + { + } + [TestMethod] + public void Test_5530() + { + } + [TestMethod] + public void Test_5531() + { + } + [TestMethod] + public void Test_5532() + { + } + [TestMethod] + public void Test_5533() + { + } + [TestMethod] + public void Test_5534() + { + } + [TestMethod] + public void Test_5535() + { + } + [TestMethod] + public void Test_5536() + { + } + [TestMethod] + public void Test_5537() + { + } + [TestMethod] + public void Test_5538() + { + } + [TestMethod] + public void Test_5539() + { + } + [TestMethod] + public void Test_5540() + { + } + [TestMethod] + public void Test_5541() + { + } + [TestMethod] + public void Test_5542() + { + } + [TestMethod] + public void Test_5543() + { + } + [TestMethod] + public void Test_5544() + { + } + [TestMethod] + public void Test_5545() + { + } + [TestMethod] + public void Test_5546() + { + } + [TestMethod] + public void Test_5547() + { + } + [TestMethod] + public void Test_5548() + { + } + [TestMethod] + public void Test_5549() + { + } + [TestMethod] + public void Test_5550() + { + } + [TestMethod] + public void Test_5551() + { + } + [TestMethod] + public void Test_5552() + { + } + [TestMethod] + public void Test_5553() + { + } + [TestMethod] + public void Test_5554() + { + } + [TestMethod] + public void Test_5555() + { + } + [TestMethod] + public void Test_5556() + { + } + [TestMethod] + public void Test_5557() + { + } + [TestMethod] + public void Test_5558() + { + } + [TestMethod] + public void Test_5559() + { + } + [TestMethod] + public void Test_5560() + { + } + [TestMethod] + public void Test_5561() + { + } + [TestMethod] + public void Test_5562() + { + } + [TestMethod] + public void Test_5563() + { + } + [TestMethod] + public void Test_5564() + { + } + [TestMethod] + public void Test_5565() + { + } + [TestMethod] + public void Test_5566() + { + } + [TestMethod] + public void Test_5567() + { + } + [TestMethod] + public void Test_5568() + { + } + [TestMethod] + public void Test_5569() + { + } + [TestMethod] + public void Test_5570() + { + } + [TestMethod] + public void Test_5571() + { + } + [TestMethod] + public void Test_5572() + { + } + [TestMethod] + public void Test_5573() + { + } + [TestMethod] + public void Test_5574() + { + } + [TestMethod] + public void Test_5575() + { + } + [TestMethod] + public void Test_5576() + { + } + [TestMethod] + public void Test_5577() + { + } + [TestMethod] + public void Test_5578() + { + } + [TestMethod] + public void Test_5579() + { + } + [TestMethod] + public void Test_5580() + { + } + [TestMethod] + public void Test_5581() + { + } + [TestMethod] + public void Test_5582() + { + } + [TestMethod] + public void Test_5583() + { + } + [TestMethod] + public void Test_5584() + { + } + [TestMethod] + public void Test_5585() + { + } + [TestMethod] + public void Test_5586() + { + } + [TestMethod] + public void Test_5587() + { + } + [TestMethod] + public void Test_5588() + { + } + [TestMethod] + public void Test_5589() + { + } + [TestMethod] + public void Test_5590() + { + } + [TestMethod] + public void Test_5591() + { + } + [TestMethod] + public void Test_5592() + { + } + [TestMethod] + public void Test_5593() + { + } + [TestMethod] + public void Test_5594() + { + } + [TestMethod] + public void Test_5595() + { + } + [TestMethod] + public void Test_5596() + { + } + [TestMethod] + public void Test_5597() + { + } + [TestMethod] + public void Test_5598() + { + } + [TestMethod] + public void Test_5599() + { + } + [TestMethod] + public void Test_5600() + { + } + [TestMethod] + public void Test_5601() + { + } + [TestMethod] + public void Test_5602() + { + } + [TestMethod] + public void Test_5603() + { + } + [TestMethod] + public void Test_5604() + { + } + [TestMethod] + public void Test_5605() + { + } + [TestMethod] + public void Test_5606() + { + } + [TestMethod] + public void Test_5607() + { + } + [TestMethod] + public void Test_5608() + { + } + [TestMethod] + public void Test_5609() + { + } + [TestMethod] + public void Test_5610() + { + } + [TestMethod] + public void Test_5611() + { + } + [TestMethod] + public void Test_5612() + { + } + [TestMethod] + public void Test_5613() + { + } + [TestMethod] + public void Test_5614() + { + } + [TestMethod] + public void Test_5615() + { + } + [TestMethod] + public void Test_5616() + { + } + [TestMethod] + public void Test_5617() + { + } + [TestMethod] + public void Test_5618() + { + } + [TestMethod] + public void Test_5619() + { + } + [TestMethod] + public void Test_5620() + { + } + [TestMethod] + public void Test_5621() + { + } + [TestMethod] + public void Test_5622() + { + } + [TestMethod] + public void Test_5623() + { + } + [TestMethod] + public void Test_5624() + { + } + [TestMethod] + public void Test_5625() + { + } + [TestMethod] + public void Test_5626() + { + } + [TestMethod] + public void Test_5627() + { + } + [TestMethod] + public void Test_5628() + { + } + [TestMethod] + public void Test_5629() + { + } + [TestMethod] + public void Test_5630() + { + } + [TestMethod] + public void Test_5631() + { + } + [TestMethod] + public void Test_5632() + { + } + [TestMethod] + public void Test_5633() + { + } + [TestMethod] + public void Test_5634() + { + } + [TestMethod] + public void Test_5635() + { + } + [TestMethod] + public void Test_5636() + { + } + [TestMethod] + public void Test_5637() + { + } + [TestMethod] + public void Test_5638() + { + } + [TestMethod] + public void Test_5639() + { + } + [TestMethod] + public void Test_5640() + { + } + [TestMethod] + public void Test_5641() + { + } + [TestMethod] + public void Test_5642() + { + } + [TestMethod] + public void Test_5643() + { + } + [TestMethod] + public void Test_5644() + { + } + [TestMethod] + public void Test_5645() + { + } + [TestMethod] + public void Test_5646() + { + } + [TestMethod] + public void Test_5647() + { + } + [TestMethod] + public void Test_5648() + { + } + [TestMethod] + public void Test_5649() + { + } + [TestMethod] + public void Test_5650() + { + } + [TestMethod] + public void Test_5651() + { + } + [TestMethod] + public void Test_5652() + { + } + [TestMethod] + public void Test_5653() + { + } + [TestMethod] + public void Test_5654() + { + } + [TestMethod] + public void Test_5655() + { + } + [TestMethod] + public void Test_5656() + { + } + [TestMethod] + public void Test_5657() + { + } + [TestMethod] + public void Test_5658() + { + } + [TestMethod] + public void Test_5659() + { + } + [TestMethod] + public void Test_5660() + { + } + [TestMethod] + public void Test_5661() + { + } + [TestMethod] + public void Test_5662() + { + } + [TestMethod] + public void Test_5663() + { + } + [TestMethod] + public void Test_5664() + { + } + [TestMethod] + public void Test_5665() + { + } + [TestMethod] + public void Test_5666() + { + } + [TestMethod] + public void Test_5667() + { + } + [TestMethod] + public void Test_5668() + { + } + [TestMethod] + public void Test_5669() + { + } + [TestMethod] + public void Test_5670() + { + } + [TestMethod] + public void Test_5671() + { + } + [TestMethod] + public void Test_5672() + { + } + [TestMethod] + public void Test_5673() + { + } + [TestMethod] + public void Test_5674() + { + } + [TestMethod] + public void Test_5675() + { + } + [TestMethod] + public void Test_5676() + { + } + [TestMethod] + public void Test_5677() + { + } + [TestMethod] + public void Test_5678() + { + } + [TestMethod] + public void Test_5679() + { + } + [TestMethod] + public void Test_5680() + { + } + [TestMethod] + public void Test_5681() + { + } + [TestMethod] + public void Test_5682() + { + } + [TestMethod] + public void Test_5683() + { + } + [TestMethod] + public void Test_5684() + { + } + [TestMethod] + public void Test_5685() + { + } + [TestMethod] + public void Test_5686() + { + } + [TestMethod] + public void Test_5687() + { + } + [TestMethod] + public void Test_5688() + { + } + [TestMethod] + public void Test_5689() + { + } + [TestMethod] + public void Test_5690() + { + } + [TestMethod] + public void Test_5691() + { + } + [TestMethod] + public void Test_5692() + { + } + [TestMethod] + public void Test_5693() + { + } + [TestMethod] + public void Test_5694() + { + } + [TestMethod] + public void Test_5695() + { + } + [TestMethod] + public void Test_5696() + { + } + [TestMethod] + public void Test_5697() + { + } + [TestMethod] + public void Test_5698() + { + } + [TestMethod] + public void Test_5699() + { + } + [TestMethod] + public void Test_5700() + { + } + [TestMethod] + public void Test_5701() + { + } + [TestMethod] + public void Test_5702() + { + } + [TestMethod] + public void Test_5703() + { + } + [TestMethod] + public void Test_5704() + { + } + [TestMethod] + public void Test_5705() + { + } + [TestMethod] + public void Test_5706() + { + } + [TestMethod] + public void Test_5707() + { + } + [TestMethod] + public void Test_5708() + { + } + [TestMethod] + public void Test_5709() + { + } + [TestMethod] + public void Test_5710() + { + } + [TestMethod] + public void Test_5711() + { + } + [TestMethod] + public void Test_5712() + { + } + [TestMethod] + public void Test_5713() + { + } + [TestMethod] + public void Test_5714() + { + } + [TestMethod] + public void Test_5715() + { + } + [TestMethod] + public void Test_5716() + { + } + [TestMethod] + public void Test_5717() + { + } + [TestMethod] + public void Test_5718() + { + } + [TestMethod] + public void Test_5719() + { + } + [TestMethod] + public void Test_5720() + { + } + [TestMethod] + public void Test_5721() + { + } + [TestMethod] + public void Test_5722() + { + } + [TestMethod] + public void Test_5723() + { + } + [TestMethod] + public void Test_5724() + { + } + [TestMethod] + public void Test_5725() + { + } + [TestMethod] + public void Test_5726() + { + } + [TestMethod] + public void Test_5727() + { + } + [TestMethod] + public void Test_5728() + { + } + [TestMethod] + public void Test_5729() + { + } + [TestMethod] + public void Test_5730() + { + } + [TestMethod] + public void Test_5731() + { + } + [TestMethod] + public void Test_5732() + { + } + [TestMethod] + public void Test_5733() + { + } + [TestMethod] + public void Test_5734() + { + } + [TestMethod] + public void Test_5735() + { + } + [TestMethod] + public void Test_5736() + { + } + [TestMethod] + public void Test_5737() + { + } + [TestMethod] + public void Test_5738() + { + } + [TestMethod] + public void Test_5739() + { + } + [TestMethod] + public void Test_5740() + { + } + [TestMethod] + public void Test_5741() + { + } + [TestMethod] + public void Test_5742() + { + } + [TestMethod] + public void Test_5743() + { + } + [TestMethod] + public void Test_5744() + { + } + [TestMethod] + public void Test_5745() + { + } + [TestMethod] + public void Test_5746() + { + } + [TestMethod] + public void Test_5747() + { + } + [TestMethod] + public void Test_5748() + { + } + [TestMethod] + public void Test_5749() + { + } + [TestMethod] + public void Test_5750() + { + } + [TestMethod] + public void Test_5751() + { + } + [TestMethod] + public void Test_5752() + { + } + [TestMethod] + public void Test_5753() + { + } + [TestMethod] + public void Test_5754() + { + } + [TestMethod] + public void Test_5755() + { + } + [TestMethod] + public void Test_5756() + { + } + [TestMethod] + public void Test_5757() + { + } + [TestMethod] + public void Test_5758() + { + } + [TestMethod] + public void Test_5759() + { + } + [TestMethod] + public void Test_5760() + { + } + [TestMethod] + public void Test_5761() + { + } + [TestMethod] + public void Test_5762() + { + } + [TestMethod] + public void Test_5763() + { + } + [TestMethod] + public void Test_5764() + { + } + [TestMethod] + public void Test_5765() + { + } + [TestMethod] + public void Test_5766() + { + } + [TestMethod] + public void Test_5767() + { + } + [TestMethod] + public void Test_5768() + { + } + [TestMethod] + public void Test_5769() + { + } + [TestMethod] + public void Test_5770() + { + } + [TestMethod] + public void Test_5771() + { + } + [TestMethod] + public void Test_5772() + { + } + [TestMethod] + public void Test_5773() + { + } + [TestMethod] + public void Test_5774() + { + } + [TestMethod] + public void Test_5775() + { + } + [TestMethod] + public void Test_5776() + { + } + [TestMethod] + public void Test_5777() + { + } + [TestMethod] + public void Test_5778() + { + } + [TestMethod] + public void Test_5779() + { + } + [TestMethod] + public void Test_5780() + { + } + [TestMethod] + public void Test_5781() + { + } + [TestMethod] + public void Test_5782() + { + } + [TestMethod] + public void Test_5783() + { + } + [TestMethod] + public void Test_5784() + { + } + [TestMethod] + public void Test_5785() + { + } + [TestMethod] + public void Test_5786() + { + } + [TestMethod] + public void Test_5787() + { + } + [TestMethod] + public void Test_5788() + { + } + [TestMethod] + public void Test_5789() + { + } + [TestMethod] + public void Test_5790() + { + } + [TestMethod] + public void Test_5791() + { + } + [TestMethod] + public void Test_5792() + { + } + [TestMethod] + public void Test_5793() + { + } + [TestMethod] + public void Test_5794() + { + } + [TestMethod] + public void Test_5795() + { + } + [TestMethod] + public void Test_5796() + { + } + [TestMethod] + public void Test_5797() + { + } + [TestMethod] + public void Test_5798() + { + } + [TestMethod] + public void Test_5799() + { + } + [TestMethod] + public void Test_5800() + { + } + [TestMethod] + public void Test_5801() + { + } + [TestMethod] + public void Test_5802() + { + } + [TestMethod] + public void Test_5803() + { + } + [TestMethod] + public void Test_5804() + { + } + [TestMethod] + public void Test_5805() + { + } + [TestMethod] + public void Test_5806() + { + } + [TestMethod] + public void Test_5807() + { + } + [TestMethod] + public void Test_5808() + { + } + [TestMethod] + public void Test_5809() + { + } + [TestMethod] + public void Test_5810() + { + } + [TestMethod] + public void Test_5811() + { + } + [TestMethod] + public void Test_5812() + { + } + [TestMethod] + public void Test_5813() + { + } + [TestMethod] + public void Test_5814() + { + } + [TestMethod] + public void Test_5815() + { + } + [TestMethod] + public void Test_5816() + { + } + [TestMethod] + public void Test_5817() + { + } + [TestMethod] + public void Test_5818() + { + } + [TestMethod] + public void Test_5819() + { + } + [TestMethod] + public void Test_5820() + { + } + [TestMethod] + public void Test_5821() + { + } + [TestMethod] + public void Test_5822() + { + } + [TestMethod] + public void Test_5823() + { + } + [TestMethod] + public void Test_5824() + { + } + [TestMethod] + public void Test_5825() + { + } + [TestMethod] + public void Test_5826() + { + } + [TestMethod] + public void Test_5827() + { + } + [TestMethod] + public void Test_5828() + { + } + [TestMethod] + public void Test_5829() + { + } + [TestMethod] + public void Test_5830() + { + } + [TestMethod] + public void Test_5831() + { + } + [TestMethod] + public void Test_5832() + { + } + [TestMethod] + public void Test_5833() + { + } + [TestMethod] + public void Test_5834() + { + } + [TestMethod] + public void Test_5835() + { + } + [TestMethod] + public void Test_5836() + { + } + [TestMethod] + public void Test_5837() + { + } + [TestMethod] + public void Test_5838() + { + } + [TestMethod] + public void Test_5839() + { + } + [TestMethod] + public void Test_5840() + { + } + [TestMethod] + public void Test_5841() + { + } + [TestMethod] + public void Test_5842() + { + } + [TestMethod] + public void Test_5843() + { + } + [TestMethod] + public void Test_5844() + { + } + [TestMethod] + public void Test_5845() + { + } + [TestMethod] + public void Test_5846() + { + } + [TestMethod] + public void Test_5847() + { + } + [TestMethod] + public void Test_5848() + { + } + [TestMethod] + public void Test_5849() + { + } + [TestMethod] + public void Test_5850() + { + } + [TestMethod] + public void Test_5851() + { + } + [TestMethod] + public void Test_5852() + { + } + [TestMethod] + public void Test_5853() + { + } + [TestMethod] + public void Test_5854() + { + } + [TestMethod] + public void Test_5855() + { + } + [TestMethod] + public void Test_5856() + { + } + [TestMethod] + public void Test_5857() + { + } + [TestMethod] + public void Test_5858() + { + } + [TestMethod] + public void Test_5859() + { + } + [TestMethod] + public void Test_5860() + { + } + [TestMethod] + public void Test_5861() + { + } + [TestMethod] + public void Test_5862() + { + } + [TestMethod] + public void Test_5863() + { + } + [TestMethod] + public void Test_5864() + { + } + [TestMethod] + public void Test_5865() + { + } + [TestMethod] + public void Test_5866() + { + } + [TestMethod] + public void Test_5867() + { + } + [TestMethod] + public void Test_5868() + { + } + [TestMethod] + public void Test_5869() + { + } + [TestMethod] + public void Test_5870() + { + } + [TestMethod] + public void Test_5871() + { + } + [TestMethod] + public void Test_5872() + { + } + [TestMethod] + public void Test_5873() + { + } + [TestMethod] + public void Test_5874() + { + } + [TestMethod] + public void Test_5875() + { + } + [TestMethod] + public void Test_5876() + { + } + [TestMethod] + public void Test_5877() + { + } + [TestMethod] + public void Test_5878() + { + } + [TestMethod] + public void Test_5879() + { + } + [TestMethod] + public void Test_5880() + { + } + [TestMethod] + public void Test_5881() + { + } + [TestMethod] + public void Test_5882() + { + } + [TestMethod] + public void Test_5883() + { + } + [TestMethod] + public void Test_5884() + { + } + [TestMethod] + public void Test_5885() + { + } + [TestMethod] + public void Test_5886() + { + } + [TestMethod] + public void Test_5887() + { + } + [TestMethod] + public void Test_5888() + { + } + [TestMethod] + public void Test_5889() + { + } + [TestMethod] + public void Test_5890() + { + } + [TestMethod] + public void Test_5891() + { + } + [TestMethod] + public void Test_5892() + { + } + [TestMethod] + public void Test_5893() + { + } + [TestMethod] + public void Test_5894() + { + } + [TestMethod] + public void Test_5895() + { + } + [TestMethod] + public void Test_5896() + { + } + [TestMethod] + public void Test_5897() + { + } + [TestMethod] + public void Test_5898() + { + } + [TestMethod] + public void Test_5899() + { + } + [TestMethod] + public void Test_5900() + { + } + [TestMethod] + public void Test_5901() + { + } + [TestMethod] + public void Test_5902() + { + } + [TestMethod] + public void Test_5903() + { + } + [TestMethod] + public void Test_5904() + { + } + [TestMethod] + public void Test_5905() + { + } + [TestMethod] + public void Test_5906() + { + } + [TestMethod] + public void Test_5907() + { + } + [TestMethod] + public void Test_5908() + { + } + [TestMethod] + public void Test_5909() + { + } + [TestMethod] + public void Test_5910() + { + } + [TestMethod] + public void Test_5911() + { + } + [TestMethod] + public void Test_5912() + { + } + [TestMethod] + public void Test_5913() + { + } + [TestMethod] + public void Test_5914() + { + } + [TestMethod] + public void Test_5915() + { + } + [TestMethod] + public void Test_5916() + { + } + [TestMethod] + public void Test_5917() + { + } + [TestMethod] + public void Test_5918() + { + } + [TestMethod] + public void Test_5919() + { + } + [TestMethod] + public void Test_5920() + { + } + [TestMethod] + public void Test_5921() + { + } + [TestMethod] + public void Test_5922() + { + } + [TestMethod] + public void Test_5923() + { + } + [TestMethod] + public void Test_5924() + { + } + [TestMethod] + public void Test_5925() + { + } + [TestMethod] + public void Test_5926() + { + } + [TestMethod] + public void Test_5927() + { + } + [TestMethod] + public void Test_5928() + { + } + [TestMethod] + public void Test_5929() + { + } + [TestMethod] + public void Test_5930() + { + } + [TestMethod] + public void Test_5931() + { + } + [TestMethod] + public void Test_5932() + { + } + [TestMethod] + public void Test_5933() + { + } + [TestMethod] + public void Test_5934() + { + } + [TestMethod] + public void Test_5935() + { + } + [TestMethod] + public void Test_5936() + { + } + [TestMethod] + public void Test_5937() + { + } + [TestMethod] + public void Test_5938() + { + } + [TestMethod] + public void Test_5939() + { + } + [TestMethod] + public void Test_5940() + { + } + [TestMethod] + public void Test_5941() + { + } + [TestMethod] + public void Test_5942() + { + } + [TestMethod] + public void Test_5943() + { + } + [TestMethod] + public void Test_5944() + { + } + [TestMethod] + public void Test_5945() + { + } + [TestMethod] + public void Test_5946() + { + } + [TestMethod] + public void Test_5947() + { + } + [TestMethod] + public void Test_5948() + { + } + [TestMethod] + public void Test_5949() + { + } + [TestMethod] + public void Test_5950() + { + } + [TestMethod] + public void Test_5951() + { + } + [TestMethod] + public void Test_5952() + { + } + [TestMethod] + public void Test_5953() + { + } + [TestMethod] + public void Test_5954() + { + } + [TestMethod] + public void Test_5955() + { + } + [TestMethod] + public void Test_5956() + { + } + [TestMethod] + public void Test_5957() + { + } + [TestMethod] + public void Test_5958() + { + } + [TestMethod] + public void Test_5959() + { + } + [TestMethod] + public void Test_5960() + { + } + [TestMethod] + public void Test_5961() + { + } + [TestMethod] + public void Test_5962() + { + } + [TestMethod] + public void Test_5963() + { + } + [TestMethod] + public void Test_5964() + { + } + [TestMethod] + public void Test_5965() + { + } + [TestMethod] + public void Test_5966() + { + } + [TestMethod] + public void Test_5967() + { + } + [TestMethod] + public void Test_5968() + { + } + [TestMethod] + public void Test_5969() + { + } + [TestMethod] + public void Test_5970() + { + } + [TestMethod] + public void Test_5971() + { + } + [TestMethod] + public void Test_5972() + { + } + [TestMethod] + public void Test_5973() + { + } + [TestMethod] + public void Test_5974() + { + } + [TestMethod] + public void Test_5975() + { + } + [TestMethod] + public void Test_5976() + { + } + [TestMethod] + public void Test_5977() + { + } + [TestMethod] + public void Test_5978() + { + } + [TestMethod] + public void Test_5979() + { + } + [TestMethod] + public void Test_5980() + { + } + [TestMethod] + public void Test_5981() + { + } + [TestMethod] + public void Test_5982() + { + } + [TestMethod] + public void Test_5983() + { + } + [TestMethod] + public void Test_5984() + { + } + [TestMethod] + public void Test_5985() + { + } + [TestMethod] + public void Test_5986() + { + } + [TestMethod] + public void Test_5987() + { + } + [TestMethod] + public void Test_5988() + { + } + [TestMethod] + public void Test_5989() + { + } + [TestMethod] + public void Test_5990() + { + } + [TestMethod] + public void Test_5991() + { + } + [TestMethod] + public void Test_5992() + { + } + [TestMethod] + public void Test_5993() + { + } + [TestMethod] + public void Test_5994() + { + } + [TestMethod] + public void Test_5995() + { + } + [TestMethod] + public void Test_5996() + { + } + [TestMethod] + public void Test_5997() + { + } + [TestMethod] + public void Test_5998() + { + } + [TestMethod] + public void Test_5999() + { + } + [TestMethod] + public void Test_6000() + { + } + [TestMethod] + public void Test_6001() + { + } + [TestMethod] + public void Test_6002() + { + } + [TestMethod] + public void Test_6003() + { + } + [TestMethod] + public void Test_6004() + { + } + [TestMethod] + public void Test_6005() + { + } + [TestMethod] + public void Test_6006() + { + } + [TestMethod] + public void Test_6007() + { + } + [TestMethod] + public void Test_6008() + { + } + [TestMethod] + public void Test_6009() + { + } + [TestMethod] + public void Test_6010() + { + } + [TestMethod] + public void Test_6011() + { + } + [TestMethod] + public void Test_6012() + { + } + [TestMethod] + public void Test_6013() + { + } + [TestMethod] + public void Test_6014() + { + } + [TestMethod] + public void Test_6015() + { + } + [TestMethod] + public void Test_6016() + { + } + [TestMethod] + public void Test_6017() + { + } + [TestMethod] + public void Test_6018() + { + } + [TestMethod] + public void Test_6019() + { + } + [TestMethod] + public void Test_6020() + { + } + [TestMethod] + public void Test_6021() + { + } + [TestMethod] + public void Test_6022() + { + } + [TestMethod] + public void Test_6023() + { + } + [TestMethod] + public void Test_6024() + { + } + [TestMethod] + public void Test_6025() + { + } + [TestMethod] + public void Test_6026() + { + } + [TestMethod] + public void Test_6027() + { + } + [TestMethod] + public void Test_6028() + { + } + [TestMethod] + public void Test_6029() + { + } + [TestMethod] + public void Test_6030() + { + } + [TestMethod] + public void Test_6031() + { + } + [TestMethod] + public void Test_6032() + { + } + [TestMethod] + public void Test_6033() + { + } + [TestMethod] + public void Test_6034() + { + } + [TestMethod] + public void Test_6035() + { + } + [TestMethod] + public void Test_6036() + { + } + [TestMethod] + public void Test_6037() + { + } + [TestMethod] + public void Test_6038() + { + } + [TestMethod] + public void Test_6039() + { + } + [TestMethod] + public void Test_6040() + { + } + [TestMethod] + public void Test_6041() + { + } + [TestMethod] + public void Test_6042() + { + } + [TestMethod] + public void Test_6043() + { + } + [TestMethod] + public void Test_6044() + { + } + [TestMethod] + public void Test_6045() + { + } + [TestMethod] + public void Test_6046() + { + } + [TestMethod] + public void Test_6047() + { + } + [TestMethod] + public void Test_6048() + { + } + [TestMethod] + public void Test_6049() + { + } + [TestMethod] + public void Test_6050() + { + } + [TestMethod] + public void Test_6051() + { + } + [TestMethod] + public void Test_6052() + { + } + [TestMethod] + public void Test_6053() + { + } + [TestMethod] + public void Test_6054() + { + } + [TestMethod] + public void Test_6055() + { + } + [TestMethod] + public void Test_6056() + { + } + [TestMethod] + public void Test_6057() + { + } + [TestMethod] + public void Test_6058() + { + } + [TestMethod] + public void Test_6059() + { + } + [TestMethod] + public void Test_6060() + { + } + [TestMethod] + public void Test_6061() + { + } + [TestMethod] + public void Test_6062() + { + } + [TestMethod] + public void Test_6063() + { + } + [TestMethod] + public void Test_6064() + { + } + [TestMethod] + public void Test_6065() + { + } + [TestMethod] + public void Test_6066() + { + } + [TestMethod] + public void Test_6067() + { + } + [TestMethod] + public void Test_6068() + { + } + [TestMethod] + public void Test_6069() + { + } + [TestMethod] + public void Test_6070() + { + } + [TestMethod] + public void Test_6071() + { + } + [TestMethod] + public void Test_6072() + { + } + [TestMethod] + public void Test_6073() + { + } + [TestMethod] + public void Test_6074() + { + } + [TestMethod] + public void Test_6075() + { + } + [TestMethod] + public void Test_6076() + { + } + [TestMethod] + public void Test_6077() + { + } + [TestMethod] + public void Test_6078() + { + } + [TestMethod] + public void Test_6079() + { + } + [TestMethod] + public void Test_6080() + { + } + [TestMethod] + public void Test_6081() + { + } + [TestMethod] + public void Test_6082() + { + } + [TestMethod] + public void Test_6083() + { + } + [TestMethod] + public void Test_6084() + { + } + [TestMethod] + public void Test_6085() + { + } + [TestMethod] + public void Test_6086() + { + } + [TestMethod] + public void Test_6087() + { + } + [TestMethod] + public void Test_6088() + { + } + [TestMethod] + public void Test_6089() + { + } + [TestMethod] + public void Test_6090() + { + } + [TestMethod] + public void Test_6091() + { + } + [TestMethod] + public void Test_6092() + { + } + [TestMethod] + public void Test_6093() + { + } + [TestMethod] + public void Test_6094() + { + } + [TestMethod] + public void Test_6095() + { + } + [TestMethod] + public void Test_6096() + { + } + [TestMethod] + public void Test_6097() + { + } + [TestMethod] + public void Test_6098() + { + } + [TestMethod] + public void Test_6099() + { + } + [TestMethod] + public void Test_6100() + { + } + [TestMethod] + public void Test_6101() + { + } + [TestMethod] + public void Test_6102() + { + } + [TestMethod] + public void Test_6103() + { + } + [TestMethod] + public void Test_6104() + { + } + [TestMethod] + public void Test_6105() + { + } + [TestMethod] + public void Test_6106() + { + } + [TestMethod] + public void Test_6107() + { + } + [TestMethod] + public void Test_6108() + { + } + [TestMethod] + public void Test_6109() + { + } + [TestMethod] + public void Test_6110() + { + } + [TestMethod] + public void Test_6111() + { + } + [TestMethod] + public void Test_6112() + { + } + [TestMethod] + public void Test_6113() + { + } + [TestMethod] + public void Test_6114() + { + } + [TestMethod] + public void Test_6115() + { + } + [TestMethod] + public void Test_6116() + { + } + [TestMethod] + public void Test_6117() + { + } + [TestMethod] + public void Test_6118() + { + } + [TestMethod] + public void Test_6119() + { + } + [TestMethod] + public void Test_6120() + { + } + [TestMethod] + public void Test_6121() + { + } + [TestMethod] + public void Test_6122() + { + } + [TestMethod] + public void Test_6123() + { + } + [TestMethod] + public void Test_6124() + { + } + [TestMethod] + public void Test_6125() + { + } + [TestMethod] + public void Test_6126() + { + } + [TestMethod] + public void Test_6127() + { + } + [TestMethod] + public void Test_6128() + { + } + [TestMethod] + public void Test_6129() + { + } + [TestMethod] + public void Test_6130() + { + } + [TestMethod] + public void Test_6131() + { + } + [TestMethod] + public void Test_6132() + { + } + [TestMethod] + public void Test_6133() + { + } + [TestMethod] + public void Test_6134() + { + } + [TestMethod] + public void Test_6135() + { + } + [TestMethod] + public void Test_6136() + { + } + [TestMethod] + public void Test_6137() + { + } + [TestMethod] + public void Test_6138() + { + } + [TestMethod] + public void Test_6139() + { + } + [TestMethod] + public void Test_6140() + { + } + [TestMethod] + public void Test_6141() + { + } + [TestMethod] + public void Test_6142() + { + } + [TestMethod] + public void Test_6143() + { + } + [TestMethod] + public void Test_6144() + { + } + [TestMethod] + public void Test_6145() + { + } + [TestMethod] + public void Test_6146() + { + } + [TestMethod] + public void Test_6147() + { + } + [TestMethod] + public void Test_6148() + { + } + [TestMethod] + public void Test_6149() + { + } + [TestMethod] + public void Test_6150() + { + } + [TestMethod] + public void Test_6151() + { + } + [TestMethod] + public void Test_6152() + { + } + [TestMethod] + public void Test_6153() + { + } + [TestMethod] + public void Test_6154() + { + } + [TestMethod] + public void Test_6155() + { + } + [TestMethod] + public void Test_6156() + { + } + [TestMethod] + public void Test_6157() + { + } + [TestMethod] + public void Test_6158() + { + } + [TestMethod] + public void Test_6159() + { + } + [TestMethod] + public void Test_6160() + { + } + [TestMethod] + public void Test_6161() + { + } + [TestMethod] + public void Test_6162() + { + } + [TestMethod] + public void Test_6163() + { + } + [TestMethod] + public void Test_6164() + { + } + [TestMethod] + public void Test_6165() + { + } + [TestMethod] + public void Test_6166() + { + } + [TestMethod] + public void Test_6167() + { + } + [TestMethod] + public void Test_6168() + { + } + [TestMethod] + public void Test_6169() + { + } + [TestMethod] + public void Test_6170() + { + } + [TestMethod] + public void Test_6171() + { + } + [TestMethod] + public void Test_6172() + { + } + [TestMethod] + public void Test_6173() + { + } + [TestMethod] + public void Test_6174() + { + } + [TestMethod] + public void Test_6175() + { + } + [TestMethod] + public void Test_6176() + { + } + [TestMethod] + public void Test_6177() + { + } + [TestMethod] + public void Test_6178() + { + } + [TestMethod] + public void Test_6179() + { + } + [TestMethod] + public void Test_6180() + { + } + [TestMethod] + public void Test_6181() + { + } + [TestMethod] + public void Test_6182() + { + } + [TestMethod] + public void Test_6183() + { + } + [TestMethod] + public void Test_6184() + { + } + [TestMethod] + public void Test_6185() + { + } + [TestMethod] + public void Test_6186() + { + } + [TestMethod] + public void Test_6187() + { + } + [TestMethod] + public void Test_6188() + { + } + [TestMethod] + public void Test_6189() + { + } + [TestMethod] + public void Test_6190() + { + } + [TestMethod] + public void Test_6191() + { + } + [TestMethod] + public void Test_6192() + { + } + [TestMethod] + public void Test_6193() + { + } + [TestMethod] + public void Test_6194() + { + } + [TestMethod] + public void Test_6195() + { + } + [TestMethod] + public void Test_6196() + { + } + [TestMethod] + public void Test_6197() + { + } + [TestMethod] + public void Test_6198() + { + } + [TestMethod] + public void Test_6199() + { + } + [TestMethod] + public void Test_6200() + { + } + [TestMethod] + public void Test_6201() + { + } + [TestMethod] + public void Test_6202() + { + } + [TestMethod] + public void Test_6203() + { + } + [TestMethod] + public void Test_6204() + { + } + [TestMethod] + public void Test_6205() + { + } + [TestMethod] + public void Test_6206() + { + } + [TestMethod] + public void Test_6207() + { + } + [TestMethod] + public void Test_6208() + { + } + [TestMethod] + public void Test_6209() + { + } + [TestMethod] + public void Test_6210() + { + } + [TestMethod] + public void Test_6211() + { + } + [TestMethod] + public void Test_6212() + { + } + [TestMethod] + public void Test_6213() + { + } + [TestMethod] + public void Test_6214() + { + } + [TestMethod] + public void Test_6215() + { + } + [TestMethod] + public void Test_6216() + { + } + [TestMethod] + public void Test_6217() + { + } + [TestMethod] + public void Test_6218() + { + } + [TestMethod] + public void Test_6219() + { + } + [TestMethod] + public void Test_6220() + { + } + [TestMethod] + public void Test_6221() + { + } + [TestMethod] + public void Test_6222() + { + } + [TestMethod] + public void Test_6223() + { + } + [TestMethod] + public void Test_6224() + { + } + [TestMethod] + public void Test_6225() + { + } + [TestMethod] + public void Test_6226() + { + } + [TestMethod] + public void Test_6227() + { + } + [TestMethod] + public void Test_6228() + { + } + [TestMethod] + public void Test_6229() + { + } + [TestMethod] + public void Test_6230() + { + } + [TestMethod] + public void Test_6231() + { + } + [TestMethod] + public void Test_6232() + { + } + [TestMethod] + public void Test_6233() + { + } + [TestMethod] + public void Test_6234() + { + } + [TestMethod] + public void Test_6235() + { + } + [TestMethod] + public void Test_6236() + { + } + [TestMethod] + public void Test_6237() + { + } + [TestMethod] + public void Test_6238() + { + } + [TestMethod] + public void Test_6239() + { + } + [TestMethod] + public void Test_6240() + { + } + [TestMethod] + public void Test_6241() + { + } + [TestMethod] + public void Test_6242() + { + } + [TestMethod] + public void Test_6243() + { + } + [TestMethod] + public void Test_6244() + { + } + [TestMethod] + public void Test_6245() + { + } + [TestMethod] + public void Test_6246() + { + } + [TestMethod] + public void Test_6247() + { + } + [TestMethod] + public void Test_6248() + { + } + [TestMethod] + public void Test_6249() + { + } + [TestMethod] + public void Test_6250() + { + } + [TestMethod] + public void Test_6251() + { + } + [TestMethod] + public void Test_6252() + { + } + [TestMethod] + public void Test_6253() + { + } + [TestMethod] + public void Test_6254() + { + } + [TestMethod] + public void Test_6255() + { + } + [TestMethod] + public void Test_6256() + { + } + [TestMethod] + public void Test_6257() + { + } + [TestMethod] + public void Test_6258() + { + } + [TestMethod] + public void Test_6259() + { + } + [TestMethod] + public void Test_6260() + { + } + [TestMethod] + public void Test_6261() + { + } + [TestMethod] + public void Test_6262() + { + } + [TestMethod] + public void Test_6263() + { + } + [TestMethod] + public void Test_6264() + { + } + [TestMethod] + public void Test_6265() + { + } + [TestMethod] + public void Test_6266() + { + } + [TestMethod] + public void Test_6267() + { + } + [TestMethod] + public void Test_6268() + { + } + [TestMethod] + public void Test_6269() + { + } + [TestMethod] + public void Test_6270() + { + } + [TestMethod] + public void Test_6271() + { + } + [TestMethod] + public void Test_6272() + { + } + [TestMethod] + public void Test_6273() + { + } + [TestMethod] + public void Test_6274() + { + } + [TestMethod] + public void Test_6275() + { + } + [TestMethod] + public void Test_6276() + { + } + [TestMethod] + public void Test_6277() + { + } + [TestMethod] + public void Test_6278() + { + } + [TestMethod] + public void Test_6279() + { + } + [TestMethod] + public void Test_6280() + { + } + [TestMethod] + public void Test_6281() + { + } + [TestMethod] + public void Test_6282() + { + } + [TestMethod] + public void Test_6283() + { + } + [TestMethod] + public void Test_6284() + { + } + [TestMethod] + public void Test_6285() + { + } + [TestMethod] + public void Test_6286() + { + } + [TestMethod] + public void Test_6287() + { + } + [TestMethod] + public void Test_6288() + { + } + [TestMethod] + public void Test_6289() + { + } + [TestMethod] + public void Test_6290() + { + } + [TestMethod] + public void Test_6291() + { + } + [TestMethod] + public void Test_6292() + { + } + [TestMethod] + public void Test_6293() + { + } + [TestMethod] + public void Test_6294() + { + } + [TestMethod] + public void Test_6295() + { + } + [TestMethod] + public void Test_6296() + { + } + [TestMethod] + public void Test_6297() + { + } + [TestMethod] + public void Test_6298() + { + } + [TestMethod] + public void Test_6299() + { + } + [TestMethod] + public void Test_6300() + { + } + [TestMethod] + public void Test_6301() + { + } + [TestMethod] + public void Test_6302() + { + } + [TestMethod] + public void Test_6303() + { + } + [TestMethod] + public void Test_6304() + { + } + [TestMethod] + public void Test_6305() + { + } + [TestMethod] + public void Test_6306() + { + } + [TestMethod] + public void Test_6307() + { + } + [TestMethod] + public void Test_6308() + { + } + [TestMethod] + public void Test_6309() + { + } + [TestMethod] + public void Test_6310() + { + } + [TestMethod] + public void Test_6311() + { + } + [TestMethod] + public void Test_6312() + { + } + [TestMethod] + public void Test_6313() + { + } + [TestMethod] + public void Test_6314() + { + } + [TestMethod] + public void Test_6315() + { + } + [TestMethod] + public void Test_6316() + { + } + [TestMethod] + public void Test_6317() + { + } + [TestMethod] + public void Test_6318() + { + } + [TestMethod] + public void Test_6319() + { + } + [TestMethod] + public void Test_6320() + { + } + [TestMethod] + public void Test_6321() + { + } + [TestMethod] + public void Test_6322() + { + } + [TestMethod] + public void Test_6323() + { + } + [TestMethod] + public void Test_6324() + { + } + [TestMethod] + public void Test_6325() + { + } + [TestMethod] + public void Test_6326() + { + } + [TestMethod] + public void Test_6327() + { + } + [TestMethod] + public void Test_6328() + { + } + [TestMethod] + public void Test_6329() + { + } + [TestMethod] + public void Test_6330() + { + } + [TestMethod] + public void Test_6331() + { + } + [TestMethod] + public void Test_6332() + { + } + [TestMethod] + public void Test_6333() + { + } + [TestMethod] + public void Test_6334() + { + } + [TestMethod] + public void Test_6335() + { + } + [TestMethod] + public void Test_6336() + { + } + [TestMethod] + public void Test_6337() + { + } + [TestMethod] + public void Test_6338() + { + } + [TestMethod] + public void Test_6339() + { + } + [TestMethod] + public void Test_6340() + { + } + [TestMethod] + public void Test_6341() + { + } + [TestMethod] + public void Test_6342() + { + } + [TestMethod] + public void Test_6343() + { + } + [TestMethod] + public void Test_6344() + { + } + [TestMethod] + public void Test_6345() + { + } + [TestMethod] + public void Test_6346() + { + } + [TestMethod] + public void Test_6347() + { + } + [TestMethod] + public void Test_6348() + { + } + [TestMethod] + public void Test_6349() + { + } + [TestMethod] + public void Test_6350() + { + } + [TestMethod] + public void Test_6351() + { + } + [TestMethod] + public void Test_6352() + { + } + [TestMethod] + public void Test_6353() + { + } + [TestMethod] + public void Test_6354() + { + } + [TestMethod] + public void Test_6355() + { + } + [TestMethod] + public void Test_6356() + { + } + [TestMethod] + public void Test_6357() + { + } + [TestMethod] + public void Test_6358() + { + } + [TestMethod] + public void Test_6359() + { + } + [TestMethod] + public void Test_6360() + { + } + [TestMethod] + public void Test_6361() + { + } + [TestMethod] + public void Test_6362() + { + } + [TestMethod] + public void Test_6363() + { + } + [TestMethod] + public void Test_6364() + { + } + [TestMethod] + public void Test_6365() + { + } + [TestMethod] + public void Test_6366() + { + } + [TestMethod] + public void Test_6367() + { + } + [TestMethod] + public void Test_6368() + { + } + [TestMethod] + public void Test_6369() + { + } + [TestMethod] + public void Test_6370() + { + } + [TestMethod] + public void Test_6371() + { + } + [TestMethod] + public void Test_6372() + { + } + [TestMethod] + public void Test_6373() + { + } + [TestMethod] + public void Test_6374() + { + } + [TestMethod] + public void Test_6375() + { + } + [TestMethod] + public void Test_6376() + { + } + [TestMethod] + public void Test_6377() + { + } + [TestMethod] + public void Test_6378() + { + } + [TestMethod] + public void Test_6379() + { + } + [TestMethod] + public void Test_6380() + { + } + [TestMethod] + public void Test_6381() + { + } + [TestMethod] + public void Test_6382() + { + } + [TestMethod] + public void Test_6383() + { + } + [TestMethod] + public void Test_6384() + { + } + [TestMethod] + public void Test_6385() + { + } + [TestMethod] + public void Test_6386() + { + } + [TestMethod] + public void Test_6387() + { + } + [TestMethod] + public void Test_6388() + { + } + [TestMethod] + public void Test_6389() + { + } + [TestMethod] + public void Test_6390() + { + } + [TestMethod] + public void Test_6391() + { + } + [TestMethod] + public void Test_6392() + { + } + [TestMethod] + public void Test_6393() + { + } + [TestMethod] + public void Test_6394() + { + } + [TestMethod] + public void Test_6395() + { + } + [TestMethod] + public void Test_6396() + { + } + [TestMethod] + public void Test_6397() + { + } + [TestMethod] + public void Test_6398() + { + } + [TestMethod] + public void Test_6399() + { + } + [TestMethod] + public void Test_6400() + { + } + [TestMethod] + public void Test_6401() + { + } + [TestMethod] + public void Test_6402() + { + } + [TestMethod] + public void Test_6403() + { + } + [TestMethod] + public void Test_6404() + { + } + [TestMethod] + public void Test_6405() + { + } + [TestMethod] + public void Test_6406() + { + } + [TestMethod] + public void Test_6407() + { + } + [TestMethod] + public void Test_6408() + { + } + [TestMethod] + public void Test_6409() + { + } + [TestMethod] + public void Test_6410() + { + } + [TestMethod] + public void Test_6411() + { + } + [TestMethod] + public void Test_6412() + { + } + [TestMethod] + public void Test_6413() + { + } + [TestMethod] + public void Test_6414() + { + } + [TestMethod] + public void Test_6415() + { + } + [TestMethod] + public void Test_6416() + { + } + [TestMethod] + public void Test_6417() + { + } + [TestMethod] + public void Test_6418() + { + } + [TestMethod] + public void Test_6419() + { + } + [TestMethod] + public void Test_6420() + { + } + [TestMethod] + public void Test_6421() + { + } + [TestMethod] + public void Test_6422() + { + } + [TestMethod] + public void Test_6423() + { + } + [TestMethod] + public void Test_6424() + { + } + [TestMethod] + public void Test_6425() + { + } + [TestMethod] + public void Test_6426() + { + } + [TestMethod] + public void Test_6427() + { + } + [TestMethod] + public void Test_6428() + { + } + [TestMethod] + public void Test_6429() + { + } + [TestMethod] + public void Test_6430() + { + } + [TestMethod] + public void Test_6431() + { + } + [TestMethod] + public void Test_6432() + { + } + [TestMethod] + public void Test_6433() + { + } + [TestMethod] + public void Test_6434() + { + } + [TestMethod] + public void Test_6435() + { + } + [TestMethod] + public void Test_6436() + { + } + [TestMethod] + public void Test_6437() + { + } + [TestMethod] + public void Test_6438() + { + } + [TestMethod] + public void Test_6439() + { + } + [TestMethod] + public void Test_6440() + { + } + [TestMethod] + public void Test_6441() + { + } + [TestMethod] + public void Test_6442() + { + } + [TestMethod] + public void Test_6443() + { + } + [TestMethod] + public void Test_6444() + { + } + [TestMethod] + public void Test_6445() + { + } + [TestMethod] + public void Test_6446() + { + } + [TestMethod] + public void Test_6447() + { + } + [TestMethod] + public void Test_6448() + { + } + [TestMethod] + public void Test_6449() + { + } + [TestMethod] + public void Test_6450() + { + } + [TestMethod] + public void Test_6451() + { + } + [TestMethod] + public void Test_6452() + { + } + [TestMethod] + public void Test_6453() + { + } + [TestMethod] + public void Test_6454() + { + } + [TestMethod] + public void Test_6455() + { + } + [TestMethod] + public void Test_6456() + { + } + [TestMethod] + public void Test_6457() + { + } + [TestMethod] + public void Test_6458() + { + } + [TestMethod] + public void Test_6459() + { + } + [TestMethod] + public void Test_6460() + { + } + [TestMethod] + public void Test_6461() + { + } + [TestMethod] + public void Test_6462() + { + } + [TestMethod] + public void Test_6463() + { + } + [TestMethod] + public void Test_6464() + { + } + [TestMethod] + public void Test_6465() + { + } + [TestMethod] + public void Test_6466() + { + } + [TestMethod] + public void Test_6467() + { + } + [TestMethod] + public void Test_6468() + { + } + [TestMethod] + public void Test_6469() + { + } + [TestMethod] + public void Test_6470() + { + } + [TestMethod] + public void Test_6471() + { + } + [TestMethod] + public void Test_6472() + { + } + [TestMethod] + public void Test_6473() + { + } + [TestMethod] + public void Test_6474() + { + } + [TestMethod] + public void Test_6475() + { + } + [TestMethod] + public void Test_6476() + { + } + [TestMethod] + public void Test_6477() + { + } + [TestMethod] + public void Test_6478() + { + } + [TestMethod] + public void Test_6479() + { + } + [TestMethod] + public void Test_6480() + { + } + [TestMethod] + public void Test_6481() + { + } + [TestMethod] + public void Test_6482() + { + } + [TestMethod] + public void Test_6483() + { + } + [TestMethod] + public void Test_6484() + { + } + [TestMethod] + public void Test_6485() + { + } + [TestMethod] + public void Test_6486() + { + } + [TestMethod] + public void Test_6487() + { + } + [TestMethod] + public void Test_6488() + { + } + [TestMethod] + public void Test_6489() + { + } + [TestMethod] + public void Test_6490() + { + } + [TestMethod] + public void Test_6491() + { + } + [TestMethod] + public void Test_6492() + { + } + [TestMethod] + public void Test_6493() + { + } + [TestMethod] + public void Test_6494() + { + } + [TestMethod] + public void Test_6495() + { + } + [TestMethod] + public void Test_6496() + { + } + [TestMethod] + public void Test_6497() + { + } + [TestMethod] + public void Test_6498() + { + } + [TestMethod] + public void Test_6499() + { + } + [TestMethod] + public void Test_6500() + { + } + [TestMethod] + public void Test_6501() + { + } + [TestMethod] + public void Test_6502() + { + } + [TestMethod] + public void Test_6503() + { + } + [TestMethod] + public void Test_6504() + { + } + [TestMethod] + public void Test_6505() + { + } + [TestMethod] + public void Test_6506() + { + } + [TestMethod] + public void Test_6507() + { + } + [TestMethod] + public void Test_6508() + { + } + [TestMethod] + public void Test_6509() + { + } + [TestMethod] + public void Test_6510() + { + } + [TestMethod] + public void Test_6511() + { + } + [TestMethod] + public void Test_6512() + { + } + [TestMethod] + public void Test_6513() + { + } + [TestMethod] + public void Test_6514() + { + } + [TestMethod] + public void Test_6515() + { + } + [TestMethod] + public void Test_6516() + { + } + [TestMethod] + public void Test_6517() + { + } + [TestMethod] + public void Test_6518() + { + } + [TestMethod] + public void Test_6519() + { + } + [TestMethod] + public void Test_6520() + { + } + [TestMethod] + public void Test_6521() + { + } + [TestMethod] + public void Test_6522() + { + } + [TestMethod] + public void Test_6523() + { + } + [TestMethod] + public void Test_6524() + { + } + [TestMethod] + public void Test_6525() + { + } + [TestMethod] + public void Test_6526() + { + } + [TestMethod] + public void Test_6527() + { + } + [TestMethod] + public void Test_6528() + { + } + [TestMethod] + public void Test_6529() + { + } + [TestMethod] + public void Test_6530() + { + } + [TestMethod] + public void Test_6531() + { + } + [TestMethod] + public void Test_6532() + { + } + [TestMethod] + public void Test_6533() + { + } + [TestMethod] + public void Test_6534() + { + } + [TestMethod] + public void Test_6535() + { + } + [TestMethod] + public void Test_6536() + { + } + [TestMethod] + public void Test_6537() + { + } + [TestMethod] + public void Test_6538() + { + } + [TestMethod] + public void Test_6539() + { + } + [TestMethod] + public void Test_6540() + { + } + [TestMethod] + public void Test_6541() + { + } + [TestMethod] + public void Test_6542() + { + } + [TestMethod] + public void Test_6543() + { + } + [TestMethod] + public void Test_6544() + { + } + [TestMethod] + public void Test_6545() + { + } + [TestMethod] + public void Test_6546() + { + } + [TestMethod] + public void Test_6547() + { + } + [TestMethod] + public void Test_6548() + { + } + [TestMethod] + public void Test_6549() + { + } + [TestMethod] + public void Test_6550() + { + } + [TestMethod] + public void Test_6551() + { + } + [TestMethod] + public void Test_6552() + { + } + [TestMethod] + public void Test_6553() + { + } + [TestMethod] + public void Test_6554() + { + } + [TestMethod] + public void Test_6555() + { + } + [TestMethod] + public void Test_6556() + { + } + [TestMethod] + public void Test_6557() + { + } + [TestMethod] + public void Test_6558() + { + } + [TestMethod] + public void Test_6559() + { + } + [TestMethod] + public void Test_6560() + { + } + [TestMethod] + public void Test_6561() + { + } + [TestMethod] + public void Test_6562() + { + } + [TestMethod] + public void Test_6563() + { + } + [TestMethod] + public void Test_6564() + { + } + [TestMethod] + public void Test_6565() + { + } + [TestMethod] + public void Test_6566() + { + } + [TestMethod] + public void Test_6567() + { + } + [TestMethod] + public void Test_6568() + { + } + [TestMethod] + public void Test_6569() + { + } + [TestMethod] + public void Test_6570() + { + } + [TestMethod] + public void Test_6571() + { + } + [TestMethod] + public void Test_6572() + { + } + [TestMethod] + public void Test_6573() + { + } + [TestMethod] + public void Test_6574() + { + } + [TestMethod] + public void Test_6575() + { + } + [TestMethod] + public void Test_6576() + { + } + [TestMethod] + public void Test_6577() + { + } + [TestMethod] + public void Test_6578() + { + } + [TestMethod] + public void Test_6579() + { + } + [TestMethod] + public void Test_6580() + { + } + [TestMethod] + public void Test_6581() + { + } + [TestMethod] + public void Test_6582() + { + } + [TestMethod] + public void Test_6583() + { + } + [TestMethod] + public void Test_6584() + { + } + [TestMethod] + public void Test_6585() + { + } + [TestMethod] + public void Test_6586() + { + } + [TestMethod] + public void Test_6587() + { + } + [TestMethod] + public void Test_6588() + { + } + [TestMethod] + public void Test_6589() + { + } + [TestMethod] + public void Test_6590() + { + } + [TestMethod] + public void Test_6591() + { + } + [TestMethod] + public void Test_6592() + { + } + [TestMethod] + public void Test_6593() + { + } + [TestMethod] + public void Test_6594() + { + } + [TestMethod] + public void Test_6595() + { + } + [TestMethod] + public void Test_6596() + { + } + [TestMethod] + public void Test_6597() + { + } + [TestMethod] + public void Test_6598() + { + } + [TestMethod] + public void Test_6599() + { + } + [TestMethod] + public void Test_6600() + { + } + [TestMethod] + public void Test_6601() + { + } + [TestMethod] + public void Test_6602() + { + } + [TestMethod] + public void Test_6603() + { + } + [TestMethod] + public void Test_6604() + { + } + [TestMethod] + public void Test_6605() + { + } + [TestMethod] + public void Test_6606() + { + } + [TestMethod] + public void Test_6607() + { + } + [TestMethod] + public void Test_6608() + { + } + [TestMethod] + public void Test_6609() + { + } + [TestMethod] + public void Test_6610() + { + } + [TestMethod] + public void Test_6611() + { + } + [TestMethod] + public void Test_6612() + { + } + [TestMethod] + public void Test_6613() + { + } + [TestMethod] + public void Test_6614() + { + } + [TestMethod] + public void Test_6615() + { + } + [TestMethod] + public void Test_6616() + { + } + [TestMethod] + public void Test_6617() + { + } + [TestMethod] + public void Test_6618() + { + } + [TestMethod] + public void Test_6619() + { + } + [TestMethod] + public void Test_6620() + { + } + [TestMethod] + public void Test_6621() + { + } + [TestMethod] + public void Test_6622() + { + } + [TestMethod] + public void Test_6623() + { + } + [TestMethod] + public void Test_6624() + { + } + [TestMethod] + public void Test_6625() + { + } + [TestMethod] + public void Test_6626() + { + } + [TestMethod] + public void Test_6627() + { + } + [TestMethod] + public void Test_6628() + { + } + [TestMethod] + public void Test_6629() + { + } + [TestMethod] + public void Test_6630() + { + } + [TestMethod] + public void Test_6631() + { + } + [TestMethod] + public void Test_6632() + { + } + [TestMethod] + public void Test_6633() + { + } + [TestMethod] + public void Test_6634() + { + } + [TestMethod] + public void Test_6635() + { + } + [TestMethod] + public void Test_6636() + { + } + [TestMethod] + public void Test_6637() + { + } + [TestMethod] + public void Test_6638() + { + } + [TestMethod] + public void Test_6639() + { + } + [TestMethod] + public void Test_6640() + { + } + [TestMethod] + public void Test_6641() + { + } + [TestMethod] + public void Test_6642() + { + } + [TestMethod] + public void Test_6643() + { + } + [TestMethod] + public void Test_6644() + { + } + [TestMethod] + public void Test_6645() + { + } + [TestMethod] + public void Test_6646() + { + } + [TestMethod] + public void Test_6647() + { + } + [TestMethod] + public void Test_6648() + { + } + [TestMethod] + public void Test_6649() + { + } + [TestMethod] + public void Test_6650() + { + } + [TestMethod] + public void Test_6651() + { + } + [TestMethod] + public void Test_6652() + { + } + [TestMethod] + public void Test_6653() + { + } + [TestMethod] + public void Test_6654() + { + } + [TestMethod] + public void Test_6655() + { + } + [TestMethod] + public void Test_6656() + { + } + [TestMethod] + public void Test_6657() + { + } + [TestMethod] + public void Test_6658() + { + } + [TestMethod] + public void Test_6659() + { + } + [TestMethod] + public void Test_6660() + { + } + [TestMethod] + public void Test_6661() + { + } + [TestMethod] + public void Test_6662() + { + } + [TestMethod] + public void Test_6663() + { + } + [TestMethod] + public void Test_6664() + { + } + [TestMethod] + public void Test_6665() + { + } + [TestMethod] + public void Test_6666() + { + } + [TestMethod] + public void Test_6667() + { + } + [TestMethod] + public void Test_6668() + { + } + [TestMethod] + public void Test_6669() + { + } + [TestMethod] + public void Test_6670() + { + } + [TestMethod] + public void Test_6671() + { + } + [TestMethod] + public void Test_6672() + { + } + [TestMethod] + public void Test_6673() + { + } + [TestMethod] + public void Test_6674() + { + } + [TestMethod] + public void Test_6675() + { + } + [TestMethod] + public void Test_6676() + { + } + [TestMethod] + public void Test_6677() + { + } + [TestMethod] + public void Test_6678() + { + } + [TestMethod] + public void Test_6679() + { + } + [TestMethod] + public void Test_6680() + { + } + [TestMethod] + public void Test_6681() + { + } + [TestMethod] + public void Test_6682() + { + } + [TestMethod] + public void Test_6683() + { + } + [TestMethod] + public void Test_6684() + { + } + [TestMethod] + public void Test_6685() + { + } + [TestMethod] + public void Test_6686() + { + } + [TestMethod] + public void Test_6687() + { + } + [TestMethod] + public void Test_6688() + { + } + [TestMethod] + public void Test_6689() + { + } + [TestMethod] + public void Test_6690() + { + } + [TestMethod] + public void Test_6691() + { + } + [TestMethod] + public void Test_6692() + { + } + [TestMethod] + public void Test_6693() + { + } + [TestMethod] + public void Test_6694() + { + } + [TestMethod] + public void Test_6695() + { + } + [TestMethod] + public void Test_6696() + { + } + [TestMethod] + public void Test_6697() + { + } + [TestMethod] + public void Test_6698() + { + } + [TestMethod] + public void Test_6699() + { + } + [TestMethod] + public void Test_6700() + { + } + [TestMethod] + public void Test_6701() + { + } + [TestMethod] + public void Test_6702() + { + } + [TestMethod] + public void Test_6703() + { + } + [TestMethod] + public void Test_6704() + { + } + [TestMethod] + public void Test_6705() + { + } + [TestMethod] + public void Test_6706() + { + } + [TestMethod] + public void Test_6707() + { + } + [TestMethod] + public void Test_6708() + { + } + [TestMethod] + public void Test_6709() + { + } + [TestMethod] + public void Test_6710() + { + } + [TestMethod] + public void Test_6711() + { + } + [TestMethod] + public void Test_6712() + { + } + [TestMethod] + public void Test_6713() + { + } + [TestMethod] + public void Test_6714() + { + } + [TestMethod] + public void Test_6715() + { + } + [TestMethod] + public void Test_6716() + { + } + [TestMethod] + public void Test_6717() + { + } + [TestMethod] + public void Test_6718() + { + } + [TestMethod] + public void Test_6719() + { + } + [TestMethod] + public void Test_6720() + { + } + [TestMethod] + public void Test_6721() + { + } + [TestMethod] + public void Test_6722() + { + } + [TestMethod] + public void Test_6723() + { + } + [TestMethod] + public void Test_6724() + { + } + [TestMethod] + public void Test_6725() + { + } + [TestMethod] + public void Test_6726() + { + } + [TestMethod] + public void Test_6727() + { + } + [TestMethod] + public void Test_6728() + { + } + [TestMethod] + public void Test_6729() + { + } + [TestMethod] + public void Test_6730() + { + } + [TestMethod] + public void Test_6731() + { + } + [TestMethod] + public void Test_6732() + { + } + [TestMethod] + public void Test_6733() + { + } + [TestMethod] + public void Test_6734() + { + } + [TestMethod] + public void Test_6735() + { + } + [TestMethod] + public void Test_6736() + { + } + [TestMethod] + public void Test_6737() + { + } + [TestMethod] + public void Test_6738() + { + } + [TestMethod] + public void Test_6739() + { + } + [TestMethod] + public void Test_6740() + { + } + [TestMethod] + public void Test_6741() + { + } + [TestMethod] + public void Test_6742() + { + } + [TestMethod] + public void Test_6743() + { + } + [TestMethod] + public void Test_6744() + { + } + [TestMethod] + public void Test_6745() + { + } + [TestMethod] + public void Test_6746() + { + } + [TestMethod] + public void Test_6747() + { + } + [TestMethod] + public void Test_6748() + { + } + [TestMethod] + public void Test_6749() + { + } + [TestMethod] + public void Test_6750() + { + } + [TestMethod] + public void Test_6751() + { + } + [TestMethod] + public void Test_6752() + { + } + [TestMethod] + public void Test_6753() + { + } + [TestMethod] + public void Test_6754() + { + } + [TestMethod] + public void Test_6755() + { + } + [TestMethod] + public void Test_6756() + { + } + [TestMethod] + public void Test_6757() + { + } + [TestMethod] + public void Test_6758() + { + } + [TestMethod] + public void Test_6759() + { + } + [TestMethod] + public void Test_6760() + { + } + [TestMethod] + public void Test_6761() + { + } + [TestMethod] + public void Test_6762() + { + } + [TestMethod] + public void Test_6763() + { + } + [TestMethod] + public void Test_6764() + { + } + [TestMethod] + public void Test_6765() + { + } + [TestMethod] + public void Test_6766() + { + } + [TestMethod] + public void Test_6767() + { + } + [TestMethod] + public void Test_6768() + { + } + [TestMethod] + public void Test_6769() + { + } + [TestMethod] + public void Test_6770() + { + } + [TestMethod] + public void Test_6771() + { + } + [TestMethod] + public void Test_6772() + { + } + [TestMethod] + public void Test_6773() + { + } + [TestMethod] + public void Test_6774() + { + } + [TestMethod] + public void Test_6775() + { + } + [TestMethod] + public void Test_6776() + { + } + [TestMethod] + public void Test_6777() + { + } + [TestMethod] + public void Test_6778() + { + } + [TestMethod] + public void Test_6779() + { + } + [TestMethod] + public void Test_6780() + { + } + [TestMethod] + public void Test_6781() + { + } + [TestMethod] + public void Test_6782() + { + } + [TestMethod] + public void Test_6783() + { + } + [TestMethod] + public void Test_6784() + { + } + [TestMethod] + public void Test_6785() + { + } + [TestMethod] + public void Test_6786() + { + } + [TestMethod] + public void Test_6787() + { + } + [TestMethod] + public void Test_6788() + { + } + [TestMethod] + public void Test_6789() + { + } + [TestMethod] + public void Test_6790() + { + } + [TestMethod] + public void Test_6791() + { + } + [TestMethod] + public void Test_6792() + { + } + [TestMethod] + public void Test_6793() + { + } + [TestMethod] + public void Test_6794() + { + } + [TestMethod] + public void Test_6795() + { + } + [TestMethod] + public void Test_6796() + { + } + [TestMethod] + public void Test_6797() + { + } + [TestMethod] + public void Test_6798() + { + } + [TestMethod] + public void Test_6799() + { + } + [TestMethod] + public void Test_6800() + { + } + [TestMethod] + public void Test_6801() + { + } + [TestMethod] + public void Test_6802() + { + } + [TestMethod] + public void Test_6803() + { + } + [TestMethod] + public void Test_6804() + { + } + [TestMethod] + public void Test_6805() + { + } + [TestMethod] + public void Test_6806() + { + } + [TestMethod] + public void Test_6807() + { + } + [TestMethod] + public void Test_6808() + { + } + [TestMethod] + public void Test_6809() + { + } + [TestMethod] + public void Test_6810() + { + } + [TestMethod] + public void Test_6811() + { + } + [TestMethod] + public void Test_6812() + { + } + [TestMethod] + public void Test_6813() + { + } + [TestMethod] + public void Test_6814() + { + } + [TestMethod] + public void Test_6815() + { + } + [TestMethod] + public void Test_6816() + { + } + [TestMethod] + public void Test_6817() + { + } + [TestMethod] + public void Test_6818() + { + } + [TestMethod] + public void Test_6819() + { + } + [TestMethod] + public void Test_6820() + { + } + [TestMethod] + public void Test_6821() + { + } + [TestMethod] + public void Test_6822() + { + } + [TestMethod] + public void Test_6823() + { + } + [TestMethod] + public void Test_6824() + { + } + [TestMethod] + public void Test_6825() + { + } + [TestMethod] + public void Test_6826() + { + } + [TestMethod] + public void Test_6827() + { + } + [TestMethod] + public void Test_6828() + { + } + [TestMethod] + public void Test_6829() + { + } + [TestMethod] + public void Test_6830() + { + } + [TestMethod] + public void Test_6831() + { + } + [TestMethod] + public void Test_6832() + { + } + [TestMethod] + public void Test_6833() + { + } + [TestMethod] + public void Test_6834() + { + } + [TestMethod] + public void Test_6835() + { + } + [TestMethod] + public void Test_6836() + { + } + [TestMethod] + public void Test_6837() + { + } + [TestMethod] + public void Test_6838() + { + } + [TestMethod] + public void Test_6839() + { + } + [TestMethod] + public void Test_6840() + { + } + [TestMethod] + public void Test_6841() + { + } + [TestMethod] + public void Test_6842() + { + } + [TestMethod] + public void Test_6843() + { + } + [TestMethod] + public void Test_6844() + { + } + [TestMethod] + public void Test_6845() + { + } + [TestMethod] + public void Test_6846() + { + } + [TestMethod] + public void Test_6847() + { + } + [TestMethod] + public void Test_6848() + { + } + [TestMethod] + public void Test_6849() + { + } + [TestMethod] + public void Test_6850() + { + } + [TestMethod] + public void Test_6851() + { + } + [TestMethod] + public void Test_6852() + { + } + [TestMethod] + public void Test_6853() + { + } + [TestMethod] + public void Test_6854() + { + } + [TestMethod] + public void Test_6855() + { + } + [TestMethod] + public void Test_6856() + { + } + [TestMethod] + public void Test_6857() + { + } + [TestMethod] + public void Test_6858() + { + } + [TestMethod] + public void Test_6859() + { + } + [TestMethod] + public void Test_6860() + { + } + [TestMethod] + public void Test_6861() + { + } + [TestMethod] + public void Test_6862() + { + } + [TestMethod] + public void Test_6863() + { + } + [TestMethod] + public void Test_6864() + { + } + [TestMethod] + public void Test_6865() + { + } + [TestMethod] + public void Test_6866() + { + } + [TestMethod] + public void Test_6867() + { + } + [TestMethod] + public void Test_6868() + { + } + [TestMethod] + public void Test_6869() + { + } + [TestMethod] + public void Test_6870() + { + } + [TestMethod] + public void Test_6871() + { + } + [TestMethod] + public void Test_6872() + { + } + [TestMethod] + public void Test_6873() + { + } + [TestMethod] + public void Test_6874() + { + } + [TestMethod] + public void Test_6875() + { + } + [TestMethod] + public void Test_6876() + { + } + [TestMethod] + public void Test_6877() + { + } + [TestMethod] + public void Test_6878() + { + } + [TestMethod] + public void Test_6879() + { + } + [TestMethod] + public void Test_6880() + { + } + [TestMethod] + public void Test_6881() + { + } + [TestMethod] + public void Test_6882() + { + } + [TestMethod] + public void Test_6883() + { + } + [TestMethod] + public void Test_6884() + { + } + [TestMethod] + public void Test_6885() + { + } + [TestMethod] + public void Test_6886() + { + } + [TestMethod] + public void Test_6887() + { + } + [TestMethod] + public void Test_6888() + { + } + [TestMethod] + public void Test_6889() + { + } + [TestMethod] + public void Test_6890() + { + } + [TestMethod] + public void Test_6891() + { + } + [TestMethod] + public void Test_6892() + { + } + [TestMethod] + public void Test_6893() + { + } + [TestMethod] + public void Test_6894() + { + } + [TestMethod] + public void Test_6895() + { + } + [TestMethod] + public void Test_6896() + { + } + [TestMethod] + public void Test_6897() + { + } + [TestMethod] + public void Test_6898() + { + } + [TestMethod] + public void Test_6899() + { + } + [TestMethod] + public void Test_6900() + { + } + [TestMethod] + public void Test_6901() + { + } + [TestMethod] + public void Test_6902() + { + } + [TestMethod] + public void Test_6903() + { + } + [TestMethod] + public void Test_6904() + { + } + [TestMethod] + public void Test_6905() + { + } + [TestMethod] + public void Test_6906() + { + } + [TestMethod] + public void Test_6907() + { + } + [TestMethod] + public void Test_6908() + { + } + [TestMethod] + public void Test_6909() + { + } + [TestMethod] + public void Test_6910() + { + } + [TestMethod] + public void Test_6911() + { + } + [TestMethod] + public void Test_6912() + { + } + [TestMethod] + public void Test_6913() + { + } + [TestMethod] + public void Test_6914() + { + } + [TestMethod] + public void Test_6915() + { + } + [TestMethod] + public void Test_6916() + { + } + [TestMethod] + public void Test_6917() + { + } + [TestMethod] + public void Test_6918() + { + } + [TestMethod] + public void Test_6919() + { + } + [TestMethod] + public void Test_6920() + { + } + [TestMethod] + public void Test_6921() + { + } + [TestMethod] + public void Test_6922() + { + } + [TestMethod] + public void Test_6923() + { + } + [TestMethod] + public void Test_6924() + { + } + [TestMethod] + public void Test_6925() + { + } + [TestMethod] + public void Test_6926() + { + } + [TestMethod] + public void Test_6927() + { + } + [TestMethod] + public void Test_6928() + { + } + [TestMethod] + public void Test_6929() + { + } + [TestMethod] + public void Test_6930() + { + } + [TestMethod] + public void Test_6931() + { + } + [TestMethod] + public void Test_6932() + { + } + [TestMethod] + public void Test_6933() + { + } + [TestMethod] + public void Test_6934() + { + } + [TestMethod] + public void Test_6935() + { + } + [TestMethod] + public void Test_6936() + { + } + [TestMethod] + public void Test_6937() + { + } + [TestMethod] + public void Test_6938() + { + } + [TestMethod] + public void Test_6939() + { + } + [TestMethod] + public void Test_6940() + { + } + [TestMethod] + public void Test_6941() + { + } + [TestMethod] + public void Test_6942() + { + } + [TestMethod] + public void Test_6943() + { + } + [TestMethod] + public void Test_6944() + { + } + [TestMethod] + public void Test_6945() + { + } + [TestMethod] + public void Test_6946() + { + } + [TestMethod] + public void Test_6947() + { + } + [TestMethod] + public void Test_6948() + { + } + [TestMethod] + public void Test_6949() + { + } + [TestMethod] + public void Test_6950() + { + } + [TestMethod] + public void Test_6951() + { + } + [TestMethod] + public void Test_6952() + { + } + [TestMethod] + public void Test_6953() + { + } + [TestMethod] + public void Test_6954() + { + } + [TestMethod] + public void Test_6955() + { + } + [TestMethod] + public void Test_6956() + { + } + [TestMethod] + public void Test_6957() + { + } + [TestMethod] + public void Test_6958() + { + } + [TestMethod] + public void Test_6959() + { + } + [TestMethod] + public void Test_6960() + { + } + [TestMethod] + public void Test_6961() + { + } + [TestMethod] + public void Test_6962() + { + } + [TestMethod] + public void Test_6963() + { + } + [TestMethod] + public void Test_6964() + { + } + [TestMethod] + public void Test_6965() + { + } + [TestMethod] + public void Test_6966() + { + } + [TestMethod] + public void Test_6967() + { + } + [TestMethod] + public void Test_6968() + { + } + [TestMethod] + public void Test_6969() + { + } + [TestMethod] + public void Test_6970() + { + } + [TestMethod] + public void Test_6971() + { + } + [TestMethod] + public void Test_6972() + { + } + [TestMethod] + public void Test_6973() + { + } + [TestMethod] + public void Test_6974() + { + } + [TestMethod] + public void Test_6975() + { + } + [TestMethod] + public void Test_6976() + { + } + [TestMethod] + public void Test_6977() + { + } + [TestMethod] + public void Test_6978() + { + } + [TestMethod] + public void Test_6979() + { + } + [TestMethod] + public void Test_6980() + { + } + [TestMethod] + public void Test_6981() + { + } + [TestMethod] + public void Test_6982() + { + } + [TestMethod] + public void Test_6983() + { + } + [TestMethod] + public void Test_6984() + { + } + [TestMethod] + public void Test_6985() + { + } + [TestMethod] + public void Test_6986() + { + } + [TestMethod] + public void Test_6987() + { + } + [TestMethod] + public void Test_6988() + { + } + [TestMethod] + public void Test_6989() + { + } + [TestMethod] + public void Test_6990() + { + } + [TestMethod] + public void Test_6991() + { + } + [TestMethod] + public void Test_6992() + { + } + [TestMethod] + public void Test_6993() + { + } + [TestMethod] + public void Test_6994() + { + } + [TestMethod] + public void Test_6995() + { + } + [TestMethod] + public void Test_6996() + { + } + [TestMethod] + public void Test_6997() + { + } + [TestMethod] + public void Test_6998() + { + } + [TestMethod] + public void Test_6999() + { + } + [TestMethod] + public void Test_7000() + { + } + [TestMethod] + public void Test_7001() + { + } + [TestMethod] + public void Test_7002() + { + } + [TestMethod] + public void Test_7003() + { + } + [TestMethod] + public void Test_7004() + { + } + [TestMethod] + public void Test_7005() + { + } + [TestMethod] + public void Test_7006() + { + } + [TestMethod] + public void Test_7007() + { + } + [TestMethod] + public void Test_7008() + { + } + [TestMethod] + public void Test_7009() + { + } + [TestMethod] + public void Test_7010() + { + } + [TestMethod] + public void Test_7011() + { + } + [TestMethod] + public void Test_7012() + { + } + [TestMethod] + public void Test_7013() + { + } + [TestMethod] + public void Test_7014() + { + } + [TestMethod] + public void Test_7015() + { + } + [TestMethod] + public void Test_7016() + { + } + [TestMethod] + public void Test_7017() + { + } + [TestMethod] + public void Test_7018() + { + } + [TestMethod] + public void Test_7019() + { + } + [TestMethod] + public void Test_7020() + { + } + [TestMethod] + public void Test_7021() + { + } + [TestMethod] + public void Test_7022() + { + } + [TestMethod] + public void Test_7023() + { + } + [TestMethod] + public void Test_7024() + { + } + [TestMethod] + public void Test_7025() + { + } + [TestMethod] + public void Test_7026() + { + } + [TestMethod] + public void Test_7027() + { + } + [TestMethod] + public void Test_7028() + { + } + [TestMethod] + public void Test_7029() + { + } + [TestMethod] + public void Test_7030() + { + } + [TestMethod] + public void Test_7031() + { + } + [TestMethod] + public void Test_7032() + { + } + [TestMethod] + public void Test_7033() + { + } + [TestMethod] + public void Test_7034() + { + } + [TestMethod] + public void Test_7035() + { + } + [TestMethod] + public void Test_7036() + { + } + [TestMethod] + public void Test_7037() + { + } + [TestMethod] + public void Test_7038() + { + } + [TestMethod] + public void Test_7039() + { + } + [TestMethod] + public void Test_7040() + { + } + [TestMethod] + public void Test_7041() + { + } + [TestMethod] + public void Test_7042() + { + } + [TestMethod] + public void Test_7043() + { + } + [TestMethod] + public void Test_7044() + { + } + [TestMethod] + public void Test_7045() + { + } + [TestMethod] + public void Test_7046() + { + } + [TestMethod] + public void Test_7047() + { + } + [TestMethod] + public void Test_7048() + { + } + [TestMethod] + public void Test_7049() + { + } + [TestMethod] + public void Test_7050() + { + } + [TestMethod] + public void Test_7051() + { + } + [TestMethod] + public void Test_7052() + { + } + [TestMethod] + public void Test_7053() + { + } + [TestMethod] + public void Test_7054() + { + } + [TestMethod] + public void Test_7055() + { + } + [TestMethod] + public void Test_7056() + { + } + [TestMethod] + public void Test_7057() + { + } + [TestMethod] + public void Test_7058() + { + } + [TestMethod] + public void Test_7059() + { + } + [TestMethod] + public void Test_7060() + { + } + [TestMethod] + public void Test_7061() + { + } + [TestMethod] + public void Test_7062() + { + } + [TestMethod] + public void Test_7063() + { + } + [TestMethod] + public void Test_7064() + { + } + [TestMethod] + public void Test_7065() + { + } + [TestMethod] + public void Test_7066() + { + } + [TestMethod] + public void Test_7067() + { + } + [TestMethod] + public void Test_7068() + { + } + [TestMethod] + public void Test_7069() + { + } + [TestMethod] + public void Test_7070() + { + } + [TestMethod] + public void Test_7071() + { + } + [TestMethod] + public void Test_7072() + { + } + [TestMethod] + public void Test_7073() + { + } + [TestMethod] + public void Test_7074() + { + } + [TestMethod] + public void Test_7075() + { + } + [TestMethod] + public void Test_7076() + { + } + [TestMethod] + public void Test_7077() + { + } + [TestMethod] + public void Test_7078() + { + } + [TestMethod] + public void Test_7079() + { + } + [TestMethod] + public void Test_7080() + { + } + [TestMethod] + public void Test_7081() + { + } + [TestMethod] + public void Test_7082() + { + } + [TestMethod] + public void Test_7083() + { + } + [TestMethod] + public void Test_7084() + { + } + [TestMethod] + public void Test_7085() + { + } + [TestMethod] + public void Test_7086() + { + } + [TestMethod] + public void Test_7087() + { + } + [TestMethod] + public void Test_7088() + { + } + [TestMethod] + public void Test_7089() + { + } + [TestMethod] + public void Test_7090() + { + } + [TestMethod] + public void Test_7091() + { + } + [TestMethod] + public void Test_7092() + { + } + [TestMethod] + public void Test_7093() + { + } + [TestMethod] + public void Test_7094() + { + } + [TestMethod] + public void Test_7095() + { + } + [TestMethod] + public void Test_7096() + { + } + [TestMethod] + public void Test_7097() + { + } + [TestMethod] + public void Test_7098() + { + } + [TestMethod] + public void Test_7099() + { + } + [TestMethod] + public void Test_7100() + { + } + [TestMethod] + public void Test_7101() + { + } + [TestMethod] + public void Test_7102() + { + } + [TestMethod] + public void Test_7103() + { + } + [TestMethod] + public void Test_7104() + { + } + [TestMethod] + public void Test_7105() + { + } + [TestMethod] + public void Test_7106() + { + } + [TestMethod] + public void Test_7107() + { + } + [TestMethod] + public void Test_7108() + { + } + [TestMethod] + public void Test_7109() + { + } + [TestMethod] + public void Test_7110() + { + } + [TestMethod] + public void Test_7111() + { + } + [TestMethod] + public void Test_7112() + { + } + [TestMethod] + public void Test_7113() + { + } + [TestMethod] + public void Test_7114() + { + } + [TestMethod] + public void Test_7115() + { + } + [TestMethod] + public void Test_7116() + { + } + [TestMethod] + public void Test_7117() + { + } + [TestMethod] + public void Test_7118() + { + } + [TestMethod] + public void Test_7119() + { + } + [TestMethod] + public void Test_7120() + { + } + [TestMethod] + public void Test_7121() + { + } + [TestMethod] + public void Test_7122() + { + } + [TestMethod] + public void Test_7123() + { + } + [TestMethod] + public void Test_7124() + { + } + [TestMethod] + public void Test_7125() + { + } + [TestMethod] + public void Test_7126() + { + } + [TestMethod] + public void Test_7127() + { + } + [TestMethod] + public void Test_7128() + { + } + [TestMethod] + public void Test_7129() + { + } + [TestMethod] + public void Test_7130() + { + } + [TestMethod] + public void Test_7131() + { + } + [TestMethod] + public void Test_7132() + { + } + [TestMethod] + public void Test_7133() + { + } + [TestMethod] + public void Test_7134() + { + } + [TestMethod] + public void Test_7135() + { + } + [TestMethod] + public void Test_7136() + { + } + [TestMethod] + public void Test_7137() + { + } + [TestMethod] + public void Test_7138() + { + } + [TestMethod] + public void Test_7139() + { + } + [TestMethod] + public void Test_7140() + { + } + [TestMethod] + public void Test_7141() + { + } + [TestMethod] + public void Test_7142() + { + } + [TestMethod] + public void Test_7143() + { + } + [TestMethod] + public void Test_7144() + { + } + [TestMethod] + public void Test_7145() + { + } + [TestMethod] + public void Test_7146() + { + } + [TestMethod] + public void Test_7147() + { + } + [TestMethod] + public void Test_7148() + { + } + [TestMethod] + public void Test_7149() + { + } + [TestMethod] + public void Test_7150() + { + } + [TestMethod] + public void Test_7151() + { + } + [TestMethod] + public void Test_7152() + { + } + [TestMethod] + public void Test_7153() + { + } + [TestMethod] + public void Test_7154() + { + } + [TestMethod] + public void Test_7155() + { + } + [TestMethod] + public void Test_7156() + { + } + [TestMethod] + public void Test_7157() + { + } + [TestMethod] + public void Test_7158() + { + } + [TestMethod] + public void Test_7159() + { + } + [TestMethod] + public void Test_7160() + { + } + [TestMethod] + public void Test_7161() + { + } + [TestMethod] + public void Test_7162() + { + } + [TestMethod] + public void Test_7163() + { + } + [TestMethod] + public void Test_7164() + { + } + [TestMethod] + public void Test_7165() + { + } + [TestMethod] + public void Test_7166() + { + } + [TestMethod] + public void Test_7167() + { + } + [TestMethod] + public void Test_7168() + { + } + [TestMethod] + public void Test_7169() + { + } + [TestMethod] + public void Test_7170() + { + } + [TestMethod] + public void Test_7171() + { + } + [TestMethod] + public void Test_7172() + { + } + [TestMethod] + public void Test_7173() + { + } + [TestMethod] + public void Test_7174() + { + } + [TestMethod] + public void Test_7175() + { + } + [TestMethod] + public void Test_7176() + { + } + [TestMethod] + public void Test_7177() + { + } + [TestMethod] + public void Test_7178() + { + } + [TestMethod] + public void Test_7179() + { + } + [TestMethod] + public void Test_7180() + { + } + [TestMethod] + public void Test_7181() + { + } + [TestMethod] + public void Test_7182() + { + } + [TestMethod] + public void Test_7183() + { + } + [TestMethod] + public void Test_7184() + { + } + [TestMethod] + public void Test_7185() + { + } + [TestMethod] + public void Test_7186() + { + } + [TestMethod] + public void Test_7187() + { + } + [TestMethod] + public void Test_7188() + { + } + [TestMethod] + public void Test_7189() + { + } + [TestMethod] + public void Test_7190() + { + } + [TestMethod] + public void Test_7191() + { + } + [TestMethod] + public void Test_7192() + { + } + [TestMethod] + public void Test_7193() + { + } + [TestMethod] + public void Test_7194() + { + } + [TestMethod] + public void Test_7195() + { + } + [TestMethod] + public void Test_7196() + { + } + [TestMethod] + public void Test_7197() + { + } + [TestMethod] + public void Test_7198() + { + } + [TestMethod] + public void Test_7199() + { + } + [TestMethod] + public void Test_7200() + { + } + [TestMethod] + public void Test_7201() + { + } + [TestMethod] + public void Test_7202() + { + } + [TestMethod] + public void Test_7203() + { + } + [TestMethod] + public void Test_7204() + { + } + [TestMethod] + public void Test_7205() + { + } + [TestMethod] + public void Test_7206() + { + } + [TestMethod] + public void Test_7207() + { + } + [TestMethod] + public void Test_7208() + { + } + [TestMethod] + public void Test_7209() + { + } + [TestMethod] + public void Test_7210() + { + } + [TestMethod] + public void Test_7211() + { + } + [TestMethod] + public void Test_7212() + { + } + [TestMethod] + public void Test_7213() + { + } + [TestMethod] + public void Test_7214() + { + } + [TestMethod] + public void Test_7215() + { + } + [TestMethod] + public void Test_7216() + { + } + [TestMethod] + public void Test_7217() + { + } + [TestMethod] + public void Test_7218() + { + } + [TestMethod] + public void Test_7219() + { + } + [TestMethod] + public void Test_7220() + { + } + [TestMethod] + public void Test_7221() + { + } + [TestMethod] + public void Test_7222() + { + } + [TestMethod] + public void Test_7223() + { + } + [TestMethod] + public void Test_7224() + { + } + [TestMethod] + public void Test_7225() + { + } + [TestMethod] + public void Test_7226() + { + } + [TestMethod] + public void Test_7227() + { + } + [TestMethod] + public void Test_7228() + { + } + [TestMethod] + public void Test_7229() + { + } + [TestMethod] + public void Test_7230() + { + } + [TestMethod] + public void Test_7231() + { + } + [TestMethod] + public void Test_7232() + { + } + [TestMethod] + public void Test_7233() + { + } + [TestMethod] + public void Test_7234() + { + } + [TestMethod] + public void Test_7235() + { + } + [TestMethod] + public void Test_7236() + { + } + [TestMethod] + public void Test_7237() + { + } + [TestMethod] + public void Test_7238() + { + } + [TestMethod] + public void Test_7239() + { + } + [TestMethod] + public void Test_7240() + { + } + [TestMethod] + public void Test_7241() + { + } + [TestMethod] + public void Test_7242() + { + } + [TestMethod] + public void Test_7243() + { + } + [TestMethod] + public void Test_7244() + { + } + [TestMethod] + public void Test_7245() + { + } + [TestMethod] + public void Test_7246() + { + } + [TestMethod] + public void Test_7247() + { + } + [TestMethod] + public void Test_7248() + { + } + [TestMethod] + public void Test_7249() + { + } + [TestMethod] + public void Test_7250() + { + } + [TestMethod] + public void Test_7251() + { + } + [TestMethod] + public void Test_7252() + { + } + [TestMethod] + public void Test_7253() + { + } + [TestMethod] + public void Test_7254() + { + } + [TestMethod] + public void Test_7255() + { + } + [TestMethod] + public void Test_7256() + { + } + [TestMethod] + public void Test_7257() + { + } + [TestMethod] + public void Test_7258() + { + } + [TestMethod] + public void Test_7259() + { + } + [TestMethod] + public void Test_7260() + { + } + [TestMethod] + public void Test_7261() + { + } + [TestMethod] + public void Test_7262() + { + } + [TestMethod] + public void Test_7263() + { + } + [TestMethod] + public void Test_7264() + { + } + [TestMethod] + public void Test_7265() + { + } + [TestMethod] + public void Test_7266() + { + } + [TestMethod] + public void Test_7267() + { + } + [TestMethod] + public void Test_7268() + { + } + [TestMethod] + public void Test_7269() + { + } + [TestMethod] + public void Test_7270() + { + } + [TestMethod] + public void Test_7271() + { + } + [TestMethod] + public void Test_7272() + { + } + [TestMethod] + public void Test_7273() + { + } + [TestMethod] + public void Test_7274() + { + } + [TestMethod] + public void Test_7275() + { + } + [TestMethod] + public void Test_7276() + { + } + [TestMethod] + public void Test_7277() + { + } + [TestMethod] + public void Test_7278() + { + } + [TestMethod] + public void Test_7279() + { + } + [TestMethod] + public void Test_7280() + { + } + [TestMethod] + public void Test_7281() + { + } + [TestMethod] + public void Test_7282() + { + } + [TestMethod] + public void Test_7283() + { + } + [TestMethod] + public void Test_7284() + { + } + [TestMethod] + public void Test_7285() + { + } + [TestMethod] + public void Test_7286() + { + } + [TestMethod] + public void Test_7287() + { + } + [TestMethod] + public void Test_7288() + { + } + [TestMethod] + public void Test_7289() + { + } + [TestMethod] + public void Test_7290() + { + } + [TestMethod] + public void Test_7291() + { + } + [TestMethod] + public void Test_7292() + { + } + [TestMethod] + public void Test_7293() + { + } + [TestMethod] + public void Test_7294() + { + } + [TestMethod] + public void Test_7295() + { + } + [TestMethod] + public void Test_7296() + { + } + [TestMethod] + public void Test_7297() + { + } + [TestMethod] + public void Test_7298() + { + } + [TestMethod] + public void Test_7299() + { + } + [TestMethod] + public void Test_7300() + { + } + [TestMethod] + public void Test_7301() + { + } + [TestMethod] + public void Test_7302() + { + } + [TestMethod] + public void Test_7303() + { + } + [TestMethod] + public void Test_7304() + { + } + [TestMethod] + public void Test_7305() + { + } + [TestMethod] + public void Test_7306() + { + } + [TestMethod] + public void Test_7307() + { + } + [TestMethod] + public void Test_7308() + { + } + [TestMethod] + public void Test_7309() + { + } + [TestMethod] + public void Test_7310() + { + } + [TestMethod] + public void Test_7311() + { + } + [TestMethod] + public void Test_7312() + { + } + [TestMethod] + public void Test_7313() + { + } + [TestMethod] + public void Test_7314() + { + } + [TestMethod] + public void Test_7315() + { + } + [TestMethod] + public void Test_7316() + { + } + [TestMethod] + public void Test_7317() + { + } + [TestMethod] + public void Test_7318() + { + } + [TestMethod] + public void Test_7319() + { + } + [TestMethod] + public void Test_7320() + { + } + [TestMethod] + public void Test_7321() + { + } + [TestMethod] + public void Test_7322() + { + } + [TestMethod] + public void Test_7323() + { + } + [TestMethod] + public void Test_7324() + { + } + [TestMethod] + public void Test_7325() + { + } + [TestMethod] + public void Test_7326() + { + } + [TestMethod] + public void Test_7327() + { + } + [TestMethod] + public void Test_7328() + { + } + [TestMethod] + public void Test_7329() + { + } + [TestMethod] + public void Test_7330() + { + } + [TestMethod] + public void Test_7331() + { + } + [TestMethod] + public void Test_7332() + { + } + [TestMethod] + public void Test_7333() + { + } + [TestMethod] + public void Test_7334() + { + } + [TestMethod] + public void Test_7335() + { + } + [TestMethod] + public void Test_7336() + { + } + [TestMethod] + public void Test_7337() + { + } + [TestMethod] + public void Test_7338() + { + } + [TestMethod] + public void Test_7339() + { + } + [TestMethod] + public void Test_7340() + { + } + [TestMethod] + public void Test_7341() + { + } + [TestMethod] + public void Test_7342() + { + } + [TestMethod] + public void Test_7343() + { + } + [TestMethod] + public void Test_7344() + { + } + [TestMethod] + public void Test_7345() + { + } + [TestMethod] + public void Test_7346() + { + } + [TestMethod] + public void Test_7347() + { + } + [TestMethod] + public void Test_7348() + { + } + [TestMethod] + public void Test_7349() + { + } + [TestMethod] + public void Test_7350() + { + } + [TestMethod] + public void Test_7351() + { + } + [TestMethod] + public void Test_7352() + { + } + [TestMethod] + public void Test_7353() + { + } + [TestMethod] + public void Test_7354() + { + } + [TestMethod] + public void Test_7355() + { + } + [TestMethod] + public void Test_7356() + { + } + [TestMethod] + public void Test_7357() + { + } + [TestMethod] + public void Test_7358() + { + } + [TestMethod] + public void Test_7359() + { + } + [TestMethod] + public void Test_7360() + { + } + [TestMethod] + public void Test_7361() + { + } + [TestMethod] + public void Test_7362() + { + } + [TestMethod] + public void Test_7363() + { + } + [TestMethod] + public void Test_7364() + { + } + [TestMethod] + public void Test_7365() + { + } + [TestMethod] + public void Test_7366() + { + } + [TestMethod] + public void Test_7367() + { + } + [TestMethod] + public void Test_7368() + { + } + [TestMethod] + public void Test_7369() + { + } + [TestMethod] + public void Test_7370() + { + } + [TestMethod] + public void Test_7371() + { + } + [TestMethod] + public void Test_7372() + { + } + [TestMethod] + public void Test_7373() + { + } + [TestMethod] + public void Test_7374() + { + } + [TestMethod] + public void Test_7375() + { + } + [TestMethod] + public void Test_7376() + { + } + [TestMethod] + public void Test_7377() + { + } + [TestMethod] + public void Test_7378() + { + } + [TestMethod] + public void Test_7379() + { + } + [TestMethod] + public void Test_7380() + { + } + [TestMethod] + public void Test_7381() + { + } + [TestMethod] + public void Test_7382() + { + } + [TestMethod] + public void Test_7383() + { + } + [TestMethod] + public void Test_7384() + { + } + [TestMethod] + public void Test_7385() + { + } + [TestMethod] + public void Test_7386() + { + } + [TestMethod] + public void Test_7387() + { + } + [TestMethod] + public void Test_7388() + { + } + [TestMethod] + public void Test_7389() + { + } + [TestMethod] + public void Test_7390() + { + } + [TestMethod] + public void Test_7391() + { + } + [TestMethod] + public void Test_7392() + { + } + [TestMethod] + public void Test_7393() + { + } + [TestMethod] + public void Test_7394() + { + } + [TestMethod] + public void Test_7395() + { + } + [TestMethod] + public void Test_7396() + { + } + [TestMethod] + public void Test_7397() + { + } + [TestMethod] + public void Test_7398() + { + } + [TestMethod] + public void Test_7399() + { + } + [TestMethod] + public void Test_7400() + { + } + [TestMethod] + public void Test_7401() + { + } + [TestMethod] + public void Test_7402() + { + } + [TestMethod] + public void Test_7403() + { + } + [TestMethod] + public void Test_7404() + { + } + [TestMethod] + public void Test_7405() + { + } + [TestMethod] + public void Test_7406() + { + } + [TestMethod] + public void Test_7407() + { + } + [TestMethod] + public void Test_7408() + { + } + [TestMethod] + public void Test_7409() + { + } + [TestMethod] + public void Test_7410() + { + } + [TestMethod] + public void Test_7411() + { + } + [TestMethod] + public void Test_7412() + { + } + [TestMethod] + public void Test_7413() + { + } + [TestMethod] + public void Test_7414() + { + } + [TestMethod] + public void Test_7415() + { + } + [TestMethod] + public void Test_7416() + { + } + [TestMethod] + public void Test_7417() + { + } + [TestMethod] + public void Test_7418() + { + } + [TestMethod] + public void Test_7419() + { + } + [TestMethod] + public void Test_7420() + { + } + [TestMethod] + public void Test_7421() + { + } + [TestMethod] + public void Test_7422() + { + } + [TestMethod] + public void Test_7423() + { + } + [TestMethod] + public void Test_7424() + { + } + [TestMethod] + public void Test_7425() + { + } + [TestMethod] + public void Test_7426() + { + } + [TestMethod] + public void Test_7427() + { + } + [TestMethod] + public void Test_7428() + { + } + [TestMethod] + public void Test_7429() + { + } + [TestMethod] + public void Test_7430() + { + } + [TestMethod] + public void Test_7431() + { + } + [TestMethod] + public void Test_7432() + { + } + [TestMethod] + public void Test_7433() + { + } + [TestMethod] + public void Test_7434() + { + } + [TestMethod] + public void Test_7435() + { + } + [TestMethod] + public void Test_7436() + { + } + [TestMethod] + public void Test_7437() + { + } + [TestMethod] + public void Test_7438() + { + } + [TestMethod] + public void Test_7439() + { + } + [TestMethod] + public void Test_7440() + { + } + [TestMethod] + public void Test_7441() + { + } + [TestMethod] + public void Test_7442() + { + } + [TestMethod] + public void Test_7443() + { + } + [TestMethod] + public void Test_7444() + { + } + [TestMethod] + public void Test_7445() + { + } + [TestMethod] + public void Test_7446() + { + } + [TestMethod] + public void Test_7447() + { + } + [TestMethod] + public void Test_7448() + { + } + [TestMethod] + public void Test_7449() + { + } + [TestMethod] + public void Test_7450() + { + } + [TestMethod] + public void Test_7451() + { + } + [TestMethod] + public void Test_7452() + { + } + [TestMethod] + public void Test_7453() + { + } + [TestMethod] + public void Test_7454() + { + } + [TestMethod] + public void Test_7455() + { + } + [TestMethod] + public void Test_7456() + { + } + [TestMethod] + public void Test_7457() + { + } + [TestMethod] + public void Test_7458() + { + } + [TestMethod] + public void Test_7459() + { + } + [TestMethod] + public void Test_7460() + { + } + [TestMethod] + public void Test_7461() + { + } + [TestMethod] + public void Test_7462() + { + } + [TestMethod] + public void Test_7463() + { + } + [TestMethod] + public void Test_7464() + { + } + [TestMethod] + public void Test_7465() + { + } + [TestMethod] + public void Test_7466() + { + } + [TestMethod] + public void Test_7467() + { + } + [TestMethod] + public void Test_7468() + { + } + [TestMethod] + public void Test_7469() + { + } + [TestMethod] + public void Test_7470() + { + } + [TestMethod] + public void Test_7471() + { + } + [TestMethod] + public void Test_7472() + { + } + [TestMethod] + public void Test_7473() + { + } + [TestMethod] + public void Test_7474() + { + } + [TestMethod] + public void Test_7475() + { + } + [TestMethod] + public void Test_7476() + { + } + [TestMethod] + public void Test_7477() + { + } + [TestMethod] + public void Test_7478() + { + } + [TestMethod] + public void Test_7479() + { + } + [TestMethod] + public void Test_7480() + { + } + [TestMethod] + public void Test_7481() + { + } + [TestMethod] + public void Test_7482() + { + } + [TestMethod] + public void Test_7483() + { + } + [TestMethod] + public void Test_7484() + { + } + [TestMethod] + public void Test_7485() + { + } + [TestMethod] + public void Test_7486() + { + } + [TestMethod] + public void Test_7487() + { + } + [TestMethod] + public void Test_7488() + { + } + [TestMethod] + public void Test_7489() + { + } + [TestMethod] + public void Test_7490() + { + } + [TestMethod] + public void Test_7491() + { + } + [TestMethod] + public void Test_7492() + { + } + [TestMethod] + public void Test_7493() + { + } + [TestMethod] + public void Test_7494() + { + } + [TestMethod] + public void Test_7495() + { + } + [TestMethod] + public void Test_7496() + { + } + [TestMethod] + public void Test_7497() + { + } + [TestMethod] + public void Test_7498() + { + } + [TestMethod] + public void Test_7499() + { + } + [TestMethod] + public void Test_7500() + { + } + [TestMethod] + public void Test_7501() + { + } + [TestMethod] + public void Test_7502() + { + } + [TestMethod] + public void Test_7503() + { + } + [TestMethod] + public void Test_7504() + { + } + [TestMethod] + public void Test_7505() + { + } + [TestMethod] + public void Test_7506() + { + } + [TestMethod] + public void Test_7507() + { + } + [TestMethod] + public void Test_7508() + { + } + [TestMethod] + public void Test_7509() + { + } + [TestMethod] + public void Test_7510() + { + } + [TestMethod] + public void Test_7511() + { + } + [TestMethod] + public void Test_7512() + { + } + [TestMethod] + public void Test_7513() + { + } + [TestMethod] + public void Test_7514() + { + } + [TestMethod] + public void Test_7515() + { + } + [TestMethod] + public void Test_7516() + { + } + [TestMethod] + public void Test_7517() + { + } + [TestMethod] + public void Test_7518() + { + } + [TestMethod] + public void Test_7519() + { + } + [TestMethod] + public void Test_7520() + { + } + [TestMethod] + public void Test_7521() + { + } + [TestMethod] + public void Test_7522() + { + } + [TestMethod] + public void Test_7523() + { + } + [TestMethod] + public void Test_7524() + { + } + [TestMethod] + public void Test_7525() + { + } + [TestMethod] + public void Test_7526() + { + } + [TestMethod] + public void Test_7527() + { + } + [TestMethod] + public void Test_7528() + { + } + [TestMethod] + public void Test_7529() + { + } + [TestMethod] + public void Test_7530() + { + } + [TestMethod] + public void Test_7531() + { + } + [TestMethod] + public void Test_7532() + { + } + [TestMethod] + public void Test_7533() + { + } + [TestMethod] + public void Test_7534() + { + } + [TestMethod] + public void Test_7535() + { + } + [TestMethod] + public void Test_7536() + { + } + [TestMethod] + public void Test_7537() + { + } + [TestMethod] + public void Test_7538() + { + } + [TestMethod] + public void Test_7539() + { + } + [TestMethod] + public void Test_7540() + { + } + [TestMethod] + public void Test_7541() + { + } + [TestMethod] + public void Test_7542() + { + } + [TestMethod] + public void Test_7543() + { + } + [TestMethod] + public void Test_7544() + { + } + [TestMethod] + public void Test_7545() + { + } + [TestMethod] + public void Test_7546() + { + } + [TestMethod] + public void Test_7547() + { + } + [TestMethod] + public void Test_7548() + { + } + [TestMethod] + public void Test_7549() + { + } + [TestMethod] + public void Test_7550() + { + } + [TestMethod] + public void Test_7551() + { + } + [TestMethod] + public void Test_7552() + { + } + [TestMethod] + public void Test_7553() + { + } + [TestMethod] + public void Test_7554() + { + } + [TestMethod] + public void Test_7555() + { + } + [TestMethod] + public void Test_7556() + { + } + [TestMethod] + public void Test_7557() + { + } + [TestMethod] + public void Test_7558() + { + } + [TestMethod] + public void Test_7559() + { + } + [TestMethod] + public void Test_7560() + { + } + [TestMethod] + public void Test_7561() + { + } + [TestMethod] + public void Test_7562() + { + } + [TestMethod] + public void Test_7563() + { + } + [TestMethod] + public void Test_7564() + { + } + [TestMethod] + public void Test_7565() + { + } + [TestMethod] + public void Test_7566() + { + } + [TestMethod] + public void Test_7567() + { + } + [TestMethod] + public void Test_7568() + { + } + [TestMethod] + public void Test_7569() + { + } + [TestMethod] + public void Test_7570() + { + } + [TestMethod] + public void Test_7571() + { + } + [TestMethod] + public void Test_7572() + { + } + [TestMethod] + public void Test_7573() + { + } + [TestMethod] + public void Test_7574() + { + } + [TestMethod] + public void Test_7575() + { + } + [TestMethod] + public void Test_7576() + { + } + [TestMethod] + public void Test_7577() + { + } + [TestMethod] + public void Test_7578() + { + } + [TestMethod] + public void Test_7579() + { + } + [TestMethod] + public void Test_7580() + { + } + [TestMethod] + public void Test_7581() + { + } + [TestMethod] + public void Test_7582() + { + } + [TestMethod] + public void Test_7583() + { + } + [TestMethod] + public void Test_7584() + { + } + [TestMethod] + public void Test_7585() + { + } + [TestMethod] + public void Test_7586() + { + } + [TestMethod] + public void Test_7587() + { + } + [TestMethod] + public void Test_7588() + { + } + [TestMethod] + public void Test_7589() + { + } + [TestMethod] + public void Test_7590() + { + } + [TestMethod] + public void Test_7591() + { + } + [TestMethod] + public void Test_7592() + { + } + [TestMethod] + public void Test_7593() + { + } + [TestMethod] + public void Test_7594() + { + } + [TestMethod] + public void Test_7595() + { + } + [TestMethod] + public void Test_7596() + { + } + [TestMethod] + public void Test_7597() + { + } + [TestMethod] + public void Test_7598() + { + } + [TestMethod] + public void Test_7599() + { + } + [TestMethod] + public void Test_7600() + { + } + [TestMethod] + public void Test_7601() + { + } + [TestMethod] + public void Test_7602() + { + } + [TestMethod] + public void Test_7603() + { + } + [TestMethod] + public void Test_7604() + { + } + [TestMethod] + public void Test_7605() + { + } + [TestMethod] + public void Test_7606() + { + } + [TestMethod] + public void Test_7607() + { + } + [TestMethod] + public void Test_7608() + { + } + [TestMethod] + public void Test_7609() + { + } + [TestMethod] + public void Test_7610() + { + } + [TestMethod] + public void Test_7611() + { + } + [TestMethod] + public void Test_7612() + { + } + [TestMethod] + public void Test_7613() + { + } + [TestMethod] + public void Test_7614() + { + } + [TestMethod] + public void Test_7615() + { + } + [TestMethod] + public void Test_7616() + { + } + [TestMethod] + public void Test_7617() + { + } + [TestMethod] + public void Test_7618() + { + } + [TestMethod] + public void Test_7619() + { + } + [TestMethod] + public void Test_7620() + { + } + [TestMethod] + public void Test_7621() + { + } + [TestMethod] + public void Test_7622() + { + } + [TestMethod] + public void Test_7623() + { + } + [TestMethod] + public void Test_7624() + { + } + [TestMethod] + public void Test_7625() + { + } + [TestMethod] + public void Test_7626() + { + } + [TestMethod] + public void Test_7627() + { + } + [TestMethod] + public void Test_7628() + { + } + [TestMethod] + public void Test_7629() + { + } + [TestMethod] + public void Test_7630() + { + } + [TestMethod] + public void Test_7631() + { + } + [TestMethod] + public void Test_7632() + { + } + [TestMethod] + public void Test_7633() + { + } + [TestMethod] + public void Test_7634() + { + } + [TestMethod] + public void Test_7635() + { + } + [TestMethod] + public void Test_7636() + { + } + [TestMethod] + public void Test_7637() + { + } + [TestMethod] + public void Test_7638() + { + } + [TestMethod] + public void Test_7639() + { + } + [TestMethod] + public void Test_7640() + { + } + [TestMethod] + public void Test_7641() + { + } + [TestMethod] + public void Test_7642() + { + } + [TestMethod] + public void Test_7643() + { + } + [TestMethod] + public void Test_7644() + { + } + [TestMethod] + public void Test_7645() + { + } + [TestMethod] + public void Test_7646() + { + } + [TestMethod] + public void Test_7647() + { + } + [TestMethod] + public void Test_7648() + { + } + [TestMethod] + public void Test_7649() + { + } + [TestMethod] + public void Test_7650() + { + } + [TestMethod] + public void Test_7651() + { + } + [TestMethod] + public void Test_7652() + { + } + [TestMethod] + public void Test_7653() + { + } + [TestMethod] + public void Test_7654() + { + } + [TestMethod] + public void Test_7655() + { + } + [TestMethod] + public void Test_7656() + { + } + [TestMethod] + public void Test_7657() + { + } + [TestMethod] + public void Test_7658() + { + } + [TestMethod] + public void Test_7659() + { + } + [TestMethod] + public void Test_7660() + { + } + [TestMethod] + public void Test_7661() + { + } + [TestMethod] + public void Test_7662() + { + } + [TestMethod] + public void Test_7663() + { + } + [TestMethod] + public void Test_7664() + { + } + [TestMethod] + public void Test_7665() + { + } + [TestMethod] + public void Test_7666() + { + } + [TestMethod] + public void Test_7667() + { + } + [TestMethod] + public void Test_7668() + { + } + [TestMethod] + public void Test_7669() + { + } + [TestMethod] + public void Test_7670() + { + } + [TestMethod] + public void Test_7671() + { + } + [TestMethod] + public void Test_7672() + { + } + [TestMethod] + public void Test_7673() + { + } + [TestMethod] + public void Test_7674() + { + } + [TestMethod] + public void Test_7675() + { + } + [TestMethod] + public void Test_7676() + { + } + [TestMethod] + public void Test_7677() + { + } + [TestMethod] + public void Test_7678() + { + } + [TestMethod] + public void Test_7679() + { + } + [TestMethod] + public void Test_7680() + { + } + [TestMethod] + public void Test_7681() + { + } + [TestMethod] + public void Test_7682() + { + } + [TestMethod] + public void Test_7683() + { + } + [TestMethod] + public void Test_7684() + { + } + [TestMethod] + public void Test_7685() + { + } + [TestMethod] + public void Test_7686() + { + } + [TestMethod] + public void Test_7687() + { + } + [TestMethod] + public void Test_7688() + { + } + [TestMethod] + public void Test_7689() + { + } + [TestMethod] + public void Test_7690() + { + } + [TestMethod] + public void Test_7691() + { + } + [TestMethod] + public void Test_7692() + { + } + [TestMethod] + public void Test_7693() + { + } + [TestMethod] + public void Test_7694() + { + } + [TestMethod] + public void Test_7695() + { + } + [TestMethod] + public void Test_7696() + { + } + [TestMethod] + public void Test_7697() + { + } + [TestMethod] + public void Test_7698() + { + } + [TestMethod] + public void Test_7699() + { + } + [TestMethod] + public void Test_7700() + { + } + [TestMethod] + public void Test_7701() + { + } + [TestMethod] + public void Test_7702() + { + } + [TestMethod] + public void Test_7703() + { + } + [TestMethod] + public void Test_7704() + { + } + [TestMethod] + public void Test_7705() + { + } + [TestMethod] + public void Test_7706() + { + } + [TestMethod] + public void Test_7707() + { + } + [TestMethod] + public void Test_7708() + { + } + [TestMethod] + public void Test_7709() + { + } + [TestMethod] + public void Test_7710() + { + } + [TestMethod] + public void Test_7711() + { + } + [TestMethod] + public void Test_7712() + { + } + [TestMethod] + public void Test_7713() + { + } + [TestMethod] + public void Test_7714() + { + } + [TestMethod] + public void Test_7715() + { + } + [TestMethod] + public void Test_7716() + { + } + [TestMethod] + public void Test_7717() + { + } + [TestMethod] + public void Test_7718() + { + } + [TestMethod] + public void Test_7719() + { + } + [TestMethod] + public void Test_7720() + { + } + [TestMethod] + public void Test_7721() + { + } + [TestMethod] + public void Test_7722() + { + } + [TestMethod] + public void Test_7723() + { + } + [TestMethod] + public void Test_7724() + { + } + [TestMethod] + public void Test_7725() + { + } + [TestMethod] + public void Test_7726() + { + } + [TestMethod] + public void Test_7727() + { + } + [TestMethod] + public void Test_7728() + { + } + [TestMethod] + public void Test_7729() + { + } + [TestMethod] + public void Test_7730() + { + } + [TestMethod] + public void Test_7731() + { + } + [TestMethod] + public void Test_7732() + { + } + [TestMethod] + public void Test_7733() + { + } + [TestMethod] + public void Test_7734() + { + } + [TestMethod] + public void Test_7735() + { + } + [TestMethod] + public void Test_7736() + { + } + [TestMethod] + public void Test_7737() + { + } + [TestMethod] + public void Test_7738() + { + } + [TestMethod] + public void Test_7739() + { + } + [TestMethod] + public void Test_7740() + { + } + [TestMethod] + public void Test_7741() + { + } + [TestMethod] + public void Test_7742() + { + } + [TestMethod] + public void Test_7743() + { + } + [TestMethod] + public void Test_7744() + { + } + [TestMethod] + public void Test_7745() + { + } + [TestMethod] + public void Test_7746() + { + } + [TestMethod] + public void Test_7747() + { + } + [TestMethod] + public void Test_7748() + { + } + [TestMethod] + public void Test_7749() + { + } + [TestMethod] + public void Test_7750() + { + } + [TestMethod] + public void Test_7751() + { + } + [TestMethod] + public void Test_7752() + { + } + [TestMethod] + public void Test_7753() + { + } + [TestMethod] + public void Test_7754() + { + } + [TestMethod] + public void Test_7755() + { + } + [TestMethod] + public void Test_7756() + { + } + [TestMethod] + public void Test_7757() + { + } + [TestMethod] + public void Test_7758() + { + } + [TestMethod] + public void Test_7759() + { + } + [TestMethod] + public void Test_7760() + { + } + [TestMethod] + public void Test_7761() + { + } + [TestMethod] + public void Test_7762() + { + } + [TestMethod] + public void Test_7763() + { + } + [TestMethod] + public void Test_7764() + { + } + [TestMethod] + public void Test_7765() + { + } + [TestMethod] + public void Test_7766() + { + } + [TestMethod] + public void Test_7767() + { + } + [TestMethod] + public void Test_7768() + { + } + [TestMethod] + public void Test_7769() + { + } + [TestMethod] + public void Test_7770() + { + } + [TestMethod] + public void Test_7771() + { + } + [TestMethod] + public void Test_7772() + { + } + [TestMethod] + public void Test_7773() + { + } + [TestMethod] + public void Test_7774() + { + } + [TestMethod] + public void Test_7775() + { + } + [TestMethod] + public void Test_7776() + { + } + [TestMethod] + public void Test_7777() + { + } + [TestMethod] + public void Test_7778() + { + } + [TestMethod] + public void Test_7779() + { + } + [TestMethod] + public void Test_7780() + { + } + [TestMethod] + public void Test_7781() + { + } + [TestMethod] + public void Test_7782() + { + } + [TestMethod] + public void Test_7783() + { + } + [TestMethod] + public void Test_7784() + { + } + [TestMethod] + public void Test_7785() + { + } + [TestMethod] + public void Test_7786() + { + } + [TestMethod] + public void Test_7787() + { + } + [TestMethod] + public void Test_7788() + { + } + [TestMethod] + public void Test_7789() + { + } + [TestMethod] + public void Test_7790() + { + } + [TestMethod] + public void Test_7791() + { + } + [TestMethod] + public void Test_7792() + { + } + [TestMethod] + public void Test_7793() + { + } + [TestMethod] + public void Test_7794() + { + } + [TestMethod] + public void Test_7795() + { + } + [TestMethod] + public void Test_7796() + { + } + [TestMethod] + public void Test_7797() + { + } + [TestMethod] + public void Test_7798() + { + } + [TestMethod] + public void Test_7799() + { + } + [TestMethod] + public void Test_7800() + { + } + [TestMethod] + public void Test_7801() + { + } + [TestMethod] + public void Test_7802() + { + } + [TestMethod] + public void Test_7803() + { + } + [TestMethod] + public void Test_7804() + { + } + [TestMethod] + public void Test_7805() + { + } + [TestMethod] + public void Test_7806() + { + } + [TestMethod] + public void Test_7807() + { + } + [TestMethod] + public void Test_7808() + { + } + [TestMethod] + public void Test_7809() + { + } + [TestMethod] + public void Test_7810() + { + } + [TestMethod] + public void Test_7811() + { + } + [TestMethod] + public void Test_7812() + { + } + [TestMethod] + public void Test_7813() + { + } + [TestMethod] + public void Test_7814() + { + } + [TestMethod] + public void Test_7815() + { + } + [TestMethod] + public void Test_7816() + { + } + [TestMethod] + public void Test_7817() + { + } + [TestMethod] + public void Test_7818() + { + } + [TestMethod] + public void Test_7819() + { + } + [TestMethod] + public void Test_7820() + { + } + [TestMethod] + public void Test_7821() + { + } + [TestMethod] + public void Test_7822() + { + } + [TestMethod] + public void Test_7823() + { + } + [TestMethod] + public void Test_7824() + { + } + [TestMethod] + public void Test_7825() + { + } + [TestMethod] + public void Test_7826() + { + } + [TestMethod] + public void Test_7827() + { + } + [TestMethod] + public void Test_7828() + { + } + [TestMethod] + public void Test_7829() + { + } + [TestMethod] + public void Test_7830() + { + } + [TestMethod] + public void Test_7831() + { + } + [TestMethod] + public void Test_7832() + { + } + [TestMethod] + public void Test_7833() + { + } + [TestMethod] + public void Test_7834() + { + } + [TestMethod] + public void Test_7835() + { + } + [TestMethod] + public void Test_7836() + { + } + [TestMethod] + public void Test_7837() + { + } + [TestMethod] + public void Test_7838() + { + } + [TestMethod] + public void Test_7839() + { + } + [TestMethod] + public void Test_7840() + { + } + [TestMethod] + public void Test_7841() + { + } + [TestMethod] + public void Test_7842() + { + } + [TestMethod] + public void Test_7843() + { + } + [TestMethod] + public void Test_7844() + { + } + [TestMethod] + public void Test_7845() + { + } + [TestMethod] + public void Test_7846() + { + } + [TestMethod] + public void Test_7847() + { + } + [TestMethod] + public void Test_7848() + { + } + [TestMethod] + public void Test_7849() + { + } + [TestMethod] + public void Test_7850() + { + } + [TestMethod] + public void Test_7851() + { + } + [TestMethod] + public void Test_7852() + { + } + [TestMethod] + public void Test_7853() + { + } + [TestMethod] + public void Test_7854() + { + } + [TestMethod] + public void Test_7855() + { + } + [TestMethod] + public void Test_7856() + { + } + [TestMethod] + public void Test_7857() + { + } + [TestMethod] + public void Test_7858() + { + } + [TestMethod] + public void Test_7859() + { + } + [TestMethod] + public void Test_7860() + { + } + [TestMethod] + public void Test_7861() + { + } + [TestMethod] + public void Test_7862() + { + } + [TestMethod] + public void Test_7863() + { + } + [TestMethod] + public void Test_7864() + { + } + [TestMethod] + public void Test_7865() + { + } + [TestMethod] + public void Test_7866() + { + } + [TestMethod] + public void Test_7867() + { + } + [TestMethod] + public void Test_7868() + { + } + [TestMethod] + public void Test_7869() + { + } + [TestMethod] + public void Test_7870() + { + } + [TestMethod] + public void Test_7871() + { + } + [TestMethod] + public void Test_7872() + { + } + [TestMethod] + public void Test_7873() + { + } + [TestMethod] + public void Test_7874() + { + } + [TestMethod] + public void Test_7875() + { + } + [TestMethod] + public void Test_7876() + { + } + [TestMethod] + public void Test_7877() + { + } + [TestMethod] + public void Test_7878() + { + } + [TestMethod] + public void Test_7879() + { + } + [TestMethod] + public void Test_7880() + { + } + [TestMethod] + public void Test_7881() + { + } + [TestMethod] + public void Test_7882() + { + } + [TestMethod] + public void Test_7883() + { + } + [TestMethod] + public void Test_7884() + { + } + [TestMethod] + public void Test_7885() + { + } + [TestMethod] + public void Test_7886() + { + } + [TestMethod] + public void Test_7887() + { + } + [TestMethod] + public void Test_7888() + { + } + [TestMethod] + public void Test_7889() + { + } + [TestMethod] + public void Test_7890() + { + } + [TestMethod] + public void Test_7891() + { + } + [TestMethod] + public void Test_7892() + { + } + [TestMethod] + public void Test_7893() + { + } + [TestMethod] + public void Test_7894() + { + } + [TestMethod] + public void Test_7895() + { + } + [TestMethod] + public void Test_7896() + { + } + [TestMethod] + public void Test_7897() + { + } + [TestMethod] + public void Test_7898() + { + } + [TestMethod] + public void Test_7899() + { + } + [TestMethod] + public void Test_7900() + { + } + [TestMethod] + public void Test_7901() + { + } + [TestMethod] + public void Test_7902() + { + } + [TestMethod] + public void Test_7903() + { + } + [TestMethod] + public void Test_7904() + { + } + [TestMethod] + public void Test_7905() + { + } + [TestMethod] + public void Test_7906() + { + } + [TestMethod] + public void Test_7907() + { + } + [TestMethod] + public void Test_7908() + { + } + [TestMethod] + public void Test_7909() + { + } + [TestMethod] + public void Test_7910() + { + } + [TestMethod] + public void Test_7911() + { + } + [TestMethod] + public void Test_7912() + { + } + [TestMethod] + public void Test_7913() + { + } + [TestMethod] + public void Test_7914() + { + } + [TestMethod] + public void Test_7915() + { + } + [TestMethod] + public void Test_7916() + { + } + [TestMethod] + public void Test_7917() + { + } + [TestMethod] + public void Test_7918() + { + } + [TestMethod] + public void Test_7919() + { + } + [TestMethod] + public void Test_7920() + { + } + [TestMethod] + public void Test_7921() + { + } + [TestMethod] + public void Test_7922() + { + } + [TestMethod] + public void Test_7923() + { + } + [TestMethod] + public void Test_7924() + { + } + [TestMethod] + public void Test_7925() + { + } + [TestMethod] + public void Test_7926() + { + } + [TestMethod] + public void Test_7927() + { + } + [TestMethod] + public void Test_7928() + { + } + [TestMethod] + public void Test_7929() + { + } + [TestMethod] + public void Test_7930() + { + } + [TestMethod] + public void Test_7931() + { + } + [TestMethod] + public void Test_7932() + { + } + [TestMethod] + public void Test_7933() + { + } + [TestMethod] + public void Test_7934() + { + } + [TestMethod] + public void Test_7935() + { + } + [TestMethod] + public void Test_7936() + { + } + [TestMethod] + public void Test_7937() + { + } + [TestMethod] + public void Test_7938() + { + } + [TestMethod] + public void Test_7939() + { + } + [TestMethod] + public void Test_7940() + { + } + [TestMethod] + public void Test_7941() + { + } + [TestMethod] + public void Test_7942() + { + } + [TestMethod] + public void Test_7943() + { + } + [TestMethod] + public void Test_7944() + { + } + [TestMethod] + public void Test_7945() + { + } + [TestMethod] + public void Test_7946() + { + } + [TestMethod] + public void Test_7947() + { + } + [TestMethod] + public void Test_7948() + { + } + [TestMethod] + public void Test_7949() + { + } + [TestMethod] + public void Test_7950() + { + } + [TestMethod] + public void Test_7951() + { + } + [TestMethod] + public void Test_7952() + { + } + [TestMethod] + public void Test_7953() + { + } + [TestMethod] + public void Test_7954() + { + } + [TestMethod] + public void Test_7955() + { + } + [TestMethod] + public void Test_7956() + { + } + [TestMethod] + public void Test_7957() + { + } + [TestMethod] + public void Test_7958() + { + } + [TestMethod] + public void Test_7959() + { + } + [TestMethod] + public void Test_7960() + { + } + [TestMethod] + public void Test_7961() + { + } + [TestMethod] + public void Test_7962() + { + } + [TestMethod] + public void Test_7963() + { + } + [TestMethod] + public void Test_7964() + { + } + [TestMethod] + public void Test_7965() + { + } + [TestMethod] + public void Test_7966() + { + } + [TestMethod] + public void Test_7967() + { + } + [TestMethod] + public void Test_7968() + { + } + [TestMethod] + public void Test_7969() + { + } + [TestMethod] + public void Test_7970() + { + } + [TestMethod] + public void Test_7971() + { + } + [TestMethod] + public void Test_7972() + { + } + [TestMethod] + public void Test_7973() + { + } + [TestMethod] + public void Test_7974() + { + } + [TestMethod] + public void Test_7975() + { + } + [TestMethod] + public void Test_7976() + { + } + [TestMethod] + public void Test_7977() + { + } + [TestMethod] + public void Test_7978() + { + } + [TestMethod] + public void Test_7979() + { + } + [TestMethod] + public void Test_7980() + { + } + [TestMethod] + public void Test_7981() + { + } + [TestMethod] + public void Test_7982() + { + } + [TestMethod] + public void Test_7983() + { + } + [TestMethod] + public void Test_7984() + { + } + [TestMethod] + public void Test_7985() + { + } + [TestMethod] + public void Test_7986() + { + } + [TestMethod] + public void Test_7987() + { + } + [TestMethod] + public void Test_7988() + { + } + [TestMethod] + public void Test_7989() + { + } + [TestMethod] + public void Test_7990() + { + } + [TestMethod] + public void Test_7991() + { + } + [TestMethod] + public void Test_7992() + { + } + [TestMethod] + public void Test_7993() + { + } + [TestMethod] + public void Test_7994() + { + } + [TestMethod] + public void Test_7995() + { + } + [TestMethod] + public void Test_7996() + { + } + [TestMethod] + public void Test_7997() + { + } + [TestMethod] + public void Test_7998() + { + } + [TestMethod] + public void Test_7999() + { + } + [TestMethod] + public void Test_8000() + { + } + [TestMethod] + public void Test_8001() + { + } + [TestMethod] + public void Test_8002() + { + } + [TestMethod] + public void Test_8003() + { + } + [TestMethod] + public void Test_8004() + { + } + [TestMethod] + public void Test_8005() + { + } + [TestMethod] + public void Test_8006() + { + } + [TestMethod] + public void Test_8007() + { + } + [TestMethod] + public void Test_8008() + { + } + [TestMethod] + public void Test_8009() + { + } + [TestMethod] + public void Test_8010() + { + } + [TestMethod] + public void Test_8011() + { + } + [TestMethod] + public void Test_8012() + { + } + [TestMethod] + public void Test_8013() + { + } + [TestMethod] + public void Test_8014() + { + } + [TestMethod] + public void Test_8015() + { + } + [TestMethod] + public void Test_8016() + { + } + [TestMethod] + public void Test_8017() + { + } + [TestMethod] + public void Test_8018() + { + } + [TestMethod] + public void Test_8019() + { + } + [TestMethod] + public void Test_8020() + { + } + [TestMethod] + public void Test_8021() + { + } + [TestMethod] + public void Test_8022() + { + } + [TestMethod] + public void Test_8023() + { + } + [TestMethod] + public void Test_8024() + { + } + [TestMethod] + public void Test_8025() + { + } + [TestMethod] + public void Test_8026() + { + } + [TestMethod] + public void Test_8027() + { + } + [TestMethod] + public void Test_8028() + { + } + [TestMethod] + public void Test_8029() + { + } + [TestMethod] + public void Test_8030() + { + } + [TestMethod] + public void Test_8031() + { + } + [TestMethod] + public void Test_8032() + { + } + [TestMethod] + public void Test_8033() + { + } + [TestMethod] + public void Test_8034() + { + } + [TestMethod] + public void Test_8035() + { + } + [TestMethod] + public void Test_8036() + { + } + [TestMethod] + public void Test_8037() + { + } + [TestMethod] + public void Test_8038() + { + } + [TestMethod] + public void Test_8039() + { + } + [TestMethod] + public void Test_8040() + { + } + [TestMethod] + public void Test_8041() + { + } + [TestMethod] + public void Test_8042() + { + } + [TestMethod] + public void Test_8043() + { + } + [TestMethod] + public void Test_8044() + { + } + [TestMethod] + public void Test_8045() + { + } + [TestMethod] + public void Test_8046() + { + } + [TestMethod] + public void Test_8047() + { + } + [TestMethod] + public void Test_8048() + { + } + [TestMethod] + public void Test_8049() + { + } + [TestMethod] + public void Test_8050() + { + } + [TestMethod] + public void Test_8051() + { + } + [TestMethod] + public void Test_8052() + { + } + [TestMethod] + public void Test_8053() + { + } + [TestMethod] + public void Test_8054() + { + } + [TestMethod] + public void Test_8055() + { + } + [TestMethod] + public void Test_8056() + { + } + [TestMethod] + public void Test_8057() + { + } + [TestMethod] + public void Test_8058() + { + } + [TestMethod] + public void Test_8059() + { + } + [TestMethod] + public void Test_8060() + { + } + [TestMethod] + public void Test_8061() + { + } + [TestMethod] + public void Test_8062() + { + } + [TestMethod] + public void Test_8063() + { + } + [TestMethod] + public void Test_8064() + { + } + [TestMethod] + public void Test_8065() + { + } + [TestMethod] + public void Test_8066() + { + } + [TestMethod] + public void Test_8067() + { + } + [TestMethod] + public void Test_8068() + { + } + [TestMethod] + public void Test_8069() + { + } + [TestMethod] + public void Test_8070() + { + } + [TestMethod] + public void Test_8071() + { + } + [TestMethod] + public void Test_8072() + { + } + [TestMethod] + public void Test_8073() + { + } + [TestMethod] + public void Test_8074() + { + } + [TestMethod] + public void Test_8075() + { + } + [TestMethod] + public void Test_8076() + { + } + [TestMethod] + public void Test_8077() + { + } + [TestMethod] + public void Test_8078() + { + } + [TestMethod] + public void Test_8079() + { + } + [TestMethod] + public void Test_8080() + { + } + [TestMethod] + public void Test_8081() + { + } + [TestMethod] + public void Test_8082() + { + } + [TestMethod] + public void Test_8083() + { + } + [TestMethod] + public void Test_8084() + { + } + [TestMethod] + public void Test_8085() + { + } + [TestMethod] + public void Test_8086() + { + } + [TestMethod] + public void Test_8087() + { + } + [TestMethod] + public void Test_8088() + { + } + [TestMethod] + public void Test_8089() + { + } + [TestMethod] + public void Test_8090() + { + } + [TestMethod] + public void Test_8091() + { + } + [TestMethod] + public void Test_8092() + { + } + [TestMethod] + public void Test_8093() + { + } + [TestMethod] + public void Test_8094() + { + } + [TestMethod] + public void Test_8095() + { + } + [TestMethod] + public void Test_8096() + { + } + [TestMethod] + public void Test_8097() + { + } + [TestMethod] + public void Test_8098() + { + } + [TestMethod] + public void Test_8099() + { + } + [TestMethod] + public void Test_8100() + { + } + [TestMethod] + public void Test_8101() + { + } + [TestMethod] + public void Test_8102() + { + } + [TestMethod] + public void Test_8103() + { + } + [TestMethod] + public void Test_8104() + { + } + [TestMethod] + public void Test_8105() + { + } + [TestMethod] + public void Test_8106() + { + } + [TestMethod] + public void Test_8107() + { + } + [TestMethod] + public void Test_8108() + { + } + [TestMethod] + public void Test_8109() + { + } + [TestMethod] + public void Test_8110() + { + } + [TestMethod] + public void Test_8111() + { + } + [TestMethod] + public void Test_8112() + { + } + [TestMethod] + public void Test_8113() + { + } + [TestMethod] + public void Test_8114() + { + } + [TestMethod] + public void Test_8115() + { + } + [TestMethod] + public void Test_8116() + { + } + [TestMethod] + public void Test_8117() + { + } + [TestMethod] + public void Test_8118() + { + } + [TestMethod] + public void Test_8119() + { + } + [TestMethod] + public void Test_8120() + { + } + [TestMethod] + public void Test_8121() + { + } + [TestMethod] + public void Test_8122() + { + } + [TestMethod] + public void Test_8123() + { + } + [TestMethod] + public void Test_8124() + { + } + [TestMethod] + public void Test_8125() + { + } + [TestMethod] + public void Test_8126() + { + } + [TestMethod] + public void Test_8127() + { + } + [TestMethod] + public void Test_8128() + { + } + [TestMethod] + public void Test_8129() + { + } + [TestMethod] + public void Test_8130() + { + } + [TestMethod] + public void Test_8131() + { + } + [TestMethod] + public void Test_8132() + { + } + [TestMethod] + public void Test_8133() + { + } + [TestMethod] + public void Test_8134() + { + } + [TestMethod] + public void Test_8135() + { + } + [TestMethod] + public void Test_8136() + { + } + [TestMethod] + public void Test_8137() + { + } + [TestMethod] + public void Test_8138() + { + } + [TestMethod] + public void Test_8139() + { + } + [TestMethod] + public void Test_8140() + { + } + [TestMethod] + public void Test_8141() + { + } + [TestMethod] + public void Test_8142() + { + } + [TestMethod] + public void Test_8143() + { + } + [TestMethod] + public void Test_8144() + { + } + [TestMethod] + public void Test_8145() + { + } + [TestMethod] + public void Test_8146() + { + } + [TestMethod] + public void Test_8147() + { + } + [TestMethod] + public void Test_8148() + { + } + [TestMethod] + public void Test_8149() + { + } + [TestMethod] + public void Test_8150() + { + } + [TestMethod] + public void Test_8151() + { + } + [TestMethod] + public void Test_8152() + { + } + [TestMethod] + public void Test_8153() + { + } + [TestMethod] + public void Test_8154() + { + } + [TestMethod] + public void Test_8155() + { + } + [TestMethod] + public void Test_8156() + { + } + [TestMethod] + public void Test_8157() + { + } + [TestMethod] + public void Test_8158() + { + } + [TestMethod] + public void Test_8159() + { + } + [TestMethod] + public void Test_8160() + { + } + [TestMethod] + public void Test_8161() + { + } + [TestMethod] + public void Test_8162() + { + } + [TestMethod] + public void Test_8163() + { + } + [TestMethod] + public void Test_8164() + { + } + [TestMethod] + public void Test_8165() + { + } + [TestMethod] + public void Test_8166() + { + } + [TestMethod] + public void Test_8167() + { + } + [TestMethod] + public void Test_8168() + { + } + [TestMethod] + public void Test_8169() + { + } + [TestMethod] + public void Test_8170() + { + } + [TestMethod] + public void Test_8171() + { + } + [TestMethod] + public void Test_8172() + { + } + [TestMethod] + public void Test_8173() + { + } + [TestMethod] + public void Test_8174() + { + } + [TestMethod] + public void Test_8175() + { + } + [TestMethod] + public void Test_8176() + { + } + [TestMethod] + public void Test_8177() + { + } + [TestMethod] + public void Test_8178() + { + } + [TestMethod] + public void Test_8179() + { + } + [TestMethod] + public void Test_8180() + { + } + [TestMethod] + public void Test_8181() + { + } + [TestMethod] + public void Test_8182() + { + } + [TestMethod] + public void Test_8183() + { + } + [TestMethod] + public void Test_8184() + { + } + [TestMethod] + public void Test_8185() + { + } + [TestMethod] + public void Test_8186() + { + } + [TestMethod] + public void Test_8187() + { + } + [TestMethod] + public void Test_8188() + { + } + [TestMethod] + public void Test_8189() + { + } + [TestMethod] + public void Test_8190() + { + } + [TestMethod] + public void Test_8191() + { + } + [TestMethod] + public void Test_8192() + { + } + [TestMethod] + public void Test_8193() + { + } + [TestMethod] + public void Test_8194() + { + } + [TestMethod] + public void Test_8195() + { + } + [TestMethod] + public void Test_8196() + { + } + [TestMethod] + public void Test_8197() + { + } + [TestMethod] + public void Test_8198() + { + } + [TestMethod] + public void Test_8199() + { + } + [TestMethod] + public void Test_8200() + { + } + [TestMethod] + public void Test_8201() + { + } + [TestMethod] + public void Test_8202() + { + } + [TestMethod] + public void Test_8203() + { + } + [TestMethod] + public void Test_8204() + { + } + [TestMethod] + public void Test_8205() + { + } + [TestMethod] + public void Test_8206() + { + } + [TestMethod] + public void Test_8207() + { + } + [TestMethod] + public void Test_8208() + { + } + [TestMethod] + public void Test_8209() + { + } + [TestMethod] + public void Test_8210() + { + } + [TestMethod] + public void Test_8211() + { + } + [TestMethod] + public void Test_8212() + { + } + [TestMethod] + public void Test_8213() + { + } + [TestMethod] + public void Test_8214() + { + } + [TestMethod] + public void Test_8215() + { + } + [TestMethod] + public void Test_8216() + { + } + [TestMethod] + public void Test_8217() + { + } + [TestMethod] + public void Test_8218() + { + } + [TestMethod] + public void Test_8219() + { + } + [TestMethod] + public void Test_8220() + { + } + [TestMethod] + public void Test_8221() + { + } + [TestMethod] + public void Test_8222() + { + } + [TestMethod] + public void Test_8223() + { + } + [TestMethod] + public void Test_8224() + { + } + [TestMethod] + public void Test_8225() + { + } + [TestMethod] + public void Test_8226() + { + } + [TestMethod] + public void Test_8227() + { + } + [TestMethod] + public void Test_8228() + { + } + [TestMethod] + public void Test_8229() + { + } + [TestMethod] + public void Test_8230() + { + } + [TestMethod] + public void Test_8231() + { + } + [TestMethod] + public void Test_8232() + { + } + [TestMethod] + public void Test_8233() + { + } + [TestMethod] + public void Test_8234() + { + } + [TestMethod] + public void Test_8235() + { + } + [TestMethod] + public void Test_8236() + { + } + [TestMethod] + public void Test_8237() + { + } + [TestMethod] + public void Test_8238() + { + } + [TestMethod] + public void Test_8239() + { + } + [TestMethod] + public void Test_8240() + { + } + [TestMethod] + public void Test_8241() + { + } + [TestMethod] + public void Test_8242() + { + } + [TestMethod] + public void Test_8243() + { + } + [TestMethod] + public void Test_8244() + { + } + [TestMethod] + public void Test_8245() + { + } + [TestMethod] + public void Test_8246() + { + } + [TestMethod] + public void Test_8247() + { + } + [TestMethod] + public void Test_8248() + { + } + [TestMethod] + public void Test_8249() + { + } + [TestMethod] + public void Test_8250() + { + } + [TestMethod] + public void Test_8251() + { + } + [TestMethod] + public void Test_8252() + { + } + [TestMethod] + public void Test_8253() + { + } + [TestMethod] + public void Test_8254() + { + } + [TestMethod] + public void Test_8255() + { + } + [TestMethod] + public void Test_8256() + { + } + [TestMethod] + public void Test_8257() + { + } + [TestMethod] + public void Test_8258() + { + } + [TestMethod] + public void Test_8259() + { + } + [TestMethod] + public void Test_8260() + { + } + [TestMethod] + public void Test_8261() + { + } + [TestMethod] + public void Test_8262() + { + } + [TestMethod] + public void Test_8263() + { + } + [TestMethod] + public void Test_8264() + { + } + [TestMethod] + public void Test_8265() + { + } + [TestMethod] + public void Test_8266() + { + } + [TestMethod] + public void Test_8267() + { + } + [TestMethod] + public void Test_8268() + { + } + [TestMethod] + public void Test_8269() + { + } + [TestMethod] + public void Test_8270() + { + } + [TestMethod] + public void Test_8271() + { + } + [TestMethod] + public void Test_8272() + { + } + [TestMethod] + public void Test_8273() + { + } + [TestMethod] + public void Test_8274() + { + } + [TestMethod] + public void Test_8275() + { + } + [TestMethod] + public void Test_8276() + { + } + [TestMethod] + public void Test_8277() + { + } + [TestMethod] + public void Test_8278() + { + } + [TestMethod] + public void Test_8279() + { + } + [TestMethod] + public void Test_8280() + { + } + [TestMethod] + public void Test_8281() + { + } + [TestMethod] + public void Test_8282() + { + } + [TestMethod] + public void Test_8283() + { + } + [TestMethod] + public void Test_8284() + { + } + [TestMethod] + public void Test_8285() + { + } + [TestMethod] + public void Test_8286() + { + } + [TestMethod] + public void Test_8287() + { + } + [TestMethod] + public void Test_8288() + { + } + [TestMethod] + public void Test_8289() + { + } + [TestMethod] + public void Test_8290() + { + } + [TestMethod] + public void Test_8291() + { + } + [TestMethod] + public void Test_8292() + { + } + [TestMethod] + public void Test_8293() + { + } + [TestMethod] + public void Test_8294() + { + } + [TestMethod] + public void Test_8295() + { + } + [TestMethod] + public void Test_8296() + { + } + [TestMethod] + public void Test_8297() + { + } + [TestMethod] + public void Test_8298() + { + } + [TestMethod] + public void Test_8299() + { + } + [TestMethod] + public void Test_8300() + { + } + [TestMethod] + public void Test_8301() + { + } + [TestMethod] + public void Test_8302() + { + } + [TestMethod] + public void Test_8303() + { + } + [TestMethod] + public void Test_8304() + { + } + [TestMethod] + public void Test_8305() + { + } + [TestMethod] + public void Test_8306() + { + } + [TestMethod] + public void Test_8307() + { + } + [TestMethod] + public void Test_8308() + { + } + [TestMethod] + public void Test_8309() + { + } + [TestMethod] + public void Test_8310() + { + } + [TestMethod] + public void Test_8311() + { + } + [TestMethod] + public void Test_8312() + { + } + [TestMethod] + public void Test_8313() + { + } + [TestMethod] + public void Test_8314() + { + } + [TestMethod] + public void Test_8315() + { + } + [TestMethod] + public void Test_8316() + { + } + [TestMethod] + public void Test_8317() + { + } + [TestMethod] + public void Test_8318() + { + } + [TestMethod] + public void Test_8319() + { + } + [TestMethod] + public void Test_8320() + { + } + [TestMethod] + public void Test_8321() + { + } + [TestMethod] + public void Test_8322() + { + } + [TestMethod] + public void Test_8323() + { + } + [TestMethod] + public void Test_8324() + { + } + [TestMethod] + public void Test_8325() + { + } + [TestMethod] + public void Test_8326() + { + } + [TestMethod] + public void Test_8327() + { + } + [TestMethod] + public void Test_8328() + { + } + [TestMethod] + public void Test_8329() + { + } + [TestMethod] + public void Test_8330() + { + } + [TestMethod] + public void Test_8331() + { + } + [TestMethod] + public void Test_8332() + { + } + [TestMethod] + public void Test_8333() + { + } + [TestMethod] + public void Test_8334() + { + } + [TestMethod] + public void Test_8335() + { + } + [TestMethod] + public void Test_8336() + { + } + [TestMethod] + public void Test_8337() + { + } + [TestMethod] + public void Test_8338() + { + } + [TestMethod] + public void Test_8339() + { + } + [TestMethod] + public void Test_8340() + { + } + [TestMethod] + public void Test_8341() + { + } + [TestMethod] + public void Test_8342() + { + } + [TestMethod] + public void Test_8343() + { + } + [TestMethod] + public void Test_8344() + { + } + [TestMethod] + public void Test_8345() + { + } + [TestMethod] + public void Test_8346() + { + } + [TestMethod] + public void Test_8347() + { + } + [TestMethod] + public void Test_8348() + { + } + [TestMethod] + public void Test_8349() + { + } + [TestMethod] + public void Test_8350() + { + } + [TestMethod] + public void Test_8351() + { + } + [TestMethod] + public void Test_8352() + { + } + [TestMethod] + public void Test_8353() + { + } + [TestMethod] + public void Test_8354() + { + } + [TestMethod] + public void Test_8355() + { + } + [TestMethod] + public void Test_8356() + { + } + [TestMethod] + public void Test_8357() + { + } + [TestMethod] + public void Test_8358() + { + } + [TestMethod] + public void Test_8359() + { + } + [TestMethod] + public void Test_8360() + { + } + [TestMethod] + public void Test_8361() + { + } + [TestMethod] + public void Test_8362() + { + } + [TestMethod] + public void Test_8363() + { + } + [TestMethod] + public void Test_8364() + { + } + [TestMethod] + public void Test_8365() + { + } + [TestMethod] + public void Test_8366() + { + } + [TestMethod] + public void Test_8367() + { + } + [TestMethod] + public void Test_8368() + { + } + [TestMethod] + public void Test_8369() + { + } + [TestMethod] + public void Test_8370() + { + } + [TestMethod] + public void Test_8371() + { + } + [TestMethod] + public void Test_8372() + { + } + [TestMethod] + public void Test_8373() + { + } + [TestMethod] + public void Test_8374() + { + } + [TestMethod] + public void Test_8375() + { + } + [TestMethod] + public void Test_8376() + { + } + [TestMethod] + public void Test_8377() + { + } + [TestMethod] + public void Test_8378() + { + } + [TestMethod] + public void Test_8379() + { + } + [TestMethod] + public void Test_8380() + { + } + [TestMethod] + public void Test_8381() + { + } + [TestMethod] + public void Test_8382() + { + } + [TestMethod] + public void Test_8383() + { + } + [TestMethod] + public void Test_8384() + { + } + [TestMethod] + public void Test_8385() + { + } + [TestMethod] + public void Test_8386() + { + } + [TestMethod] + public void Test_8387() + { + } + [TestMethod] + public void Test_8388() + { + } + [TestMethod] + public void Test_8389() + { + } + [TestMethod] + public void Test_8390() + { + } + [TestMethod] + public void Test_8391() + { + } + [TestMethod] + public void Test_8392() + { + } + [TestMethod] + public void Test_8393() + { + } + [TestMethod] + public void Test_8394() + { + } + [TestMethod] + public void Test_8395() + { + } + [TestMethod] + public void Test_8396() + { + } + [TestMethod] + public void Test_8397() + { + } + [TestMethod] + public void Test_8398() + { + } + [TestMethod] + public void Test_8399() + { + } + [TestMethod] + public void Test_8400() + { + } + [TestMethod] + public void Test_8401() + { + } + [TestMethod] + public void Test_8402() + { + } + [TestMethod] + public void Test_8403() + { + } + [TestMethod] + public void Test_8404() + { + } + [TestMethod] + public void Test_8405() + { + } + [TestMethod] + public void Test_8406() + { + } + [TestMethod] + public void Test_8407() + { + } + [TestMethod] + public void Test_8408() + { + } + [TestMethod] + public void Test_8409() + { + } + [TestMethod] + public void Test_8410() + { + } + [TestMethod] + public void Test_8411() + { + } + [TestMethod] + public void Test_8412() + { + } + [TestMethod] + public void Test_8413() + { + } + [TestMethod] + public void Test_8414() + { + } + [TestMethod] + public void Test_8415() + { + } + [TestMethod] + public void Test_8416() + { + } + [TestMethod] + public void Test_8417() + { + } + [TestMethod] + public void Test_8418() + { + } + [TestMethod] + public void Test_8419() + { + } + [TestMethod] + public void Test_8420() + { + } + [TestMethod] + public void Test_8421() + { + } + [TestMethod] + public void Test_8422() + { + } + [TestMethod] + public void Test_8423() + { + } + [TestMethod] + public void Test_8424() + { + } + [TestMethod] + public void Test_8425() + { + } + [TestMethod] + public void Test_8426() + { + } + [TestMethod] + public void Test_8427() + { + } + [TestMethod] + public void Test_8428() + { + } + [TestMethod] + public void Test_8429() + { + } + [TestMethod] + public void Test_8430() + { + } + [TestMethod] + public void Test_8431() + { + } + [TestMethod] + public void Test_8432() + { + } + [TestMethod] + public void Test_8433() + { + } + [TestMethod] + public void Test_8434() + { + } + [TestMethod] + public void Test_8435() + { + } + [TestMethod] + public void Test_8436() + { + } + [TestMethod] + public void Test_8437() + { + } + [TestMethod] + public void Test_8438() + { + } + [TestMethod] + public void Test_8439() + { + } + [TestMethod] + public void Test_8440() + { + } + [TestMethod] + public void Test_8441() + { + } + [TestMethod] + public void Test_8442() + { + } + [TestMethod] + public void Test_8443() + { + } + [TestMethod] + public void Test_8444() + { + } + [TestMethod] + public void Test_8445() + { + } + [TestMethod] + public void Test_8446() + { + } + [TestMethod] + public void Test_8447() + { + } + [TestMethod] + public void Test_8448() + { + } + [TestMethod] + public void Test_8449() + { + } + [TestMethod] + public void Test_8450() + { + } + [TestMethod] + public void Test_8451() + { + } + [TestMethod] + public void Test_8452() + { + } + [TestMethod] + public void Test_8453() + { + } + [TestMethod] + public void Test_8454() + { + } + [TestMethod] + public void Test_8455() + { + } + [TestMethod] + public void Test_8456() + { + } + [TestMethod] + public void Test_8457() + { + } + [TestMethod] + public void Test_8458() + { + } + [TestMethod] + public void Test_8459() + { + } + [TestMethod] + public void Test_8460() + { + } + [TestMethod] + public void Test_8461() + { + } + [TestMethod] + public void Test_8462() + { + } + [TestMethod] + public void Test_8463() + { + } + [TestMethod] + public void Test_8464() + { + } + [TestMethod] + public void Test_8465() + { + } + [TestMethod] + public void Test_8466() + { + } + [TestMethod] + public void Test_8467() + { + } + [TestMethod] + public void Test_8468() + { + } + [TestMethod] + public void Test_8469() + { + } + [TestMethod] + public void Test_8470() + { + } + [TestMethod] + public void Test_8471() + { + } + [TestMethod] + public void Test_8472() + { + } + [TestMethod] + public void Test_8473() + { + } + [TestMethod] + public void Test_8474() + { + } + [TestMethod] + public void Test_8475() + { + } + [TestMethod] + public void Test_8476() + { + } + [TestMethod] + public void Test_8477() + { + } + [TestMethod] + public void Test_8478() + { + } + [TestMethod] + public void Test_8479() + { + } + [TestMethod] + public void Test_8480() + { + } + [TestMethod] + public void Test_8481() + { + } + [TestMethod] + public void Test_8482() + { + } + [TestMethod] + public void Test_8483() + { + } + [TestMethod] + public void Test_8484() + { + } + [TestMethod] + public void Test_8485() + { + } + [TestMethod] + public void Test_8486() + { + } + [TestMethod] + public void Test_8487() + { + } + [TestMethod] + public void Test_8488() + { + } + [TestMethod] + public void Test_8489() + { + } + [TestMethod] + public void Test_8490() + { + } + [TestMethod] + public void Test_8491() + { + } + [TestMethod] + public void Test_8492() + { + } + [TestMethod] + public void Test_8493() + { + } + [TestMethod] + public void Test_8494() + { + } + [TestMethod] + public void Test_8495() + { + } + [TestMethod] + public void Test_8496() + { + } + [TestMethod] + public void Test_8497() + { + } + [TestMethod] + public void Test_8498() + { + } + [TestMethod] + public void Test_8499() + { + } + [TestMethod] + public void Test_8500() + { + } + [TestMethod] + public void Test_8501() + { + } + [TestMethod] + public void Test_8502() + { + } + [TestMethod] + public void Test_8503() + { + } + [TestMethod] + public void Test_8504() + { + } + [TestMethod] + public void Test_8505() + { + } + [TestMethod] + public void Test_8506() + { + } + [TestMethod] + public void Test_8507() + { + } + [TestMethod] + public void Test_8508() + { + } + [TestMethod] + public void Test_8509() + { + } + [TestMethod] + public void Test_8510() + { + } + [TestMethod] + public void Test_8511() + { + } + [TestMethod] + public void Test_8512() + { + } + [TestMethod] + public void Test_8513() + { + } + [TestMethod] + public void Test_8514() + { + } + [TestMethod] + public void Test_8515() + { + } + [TestMethod] + public void Test_8516() + { + } + [TestMethod] + public void Test_8517() + { + } + [TestMethod] + public void Test_8518() + { + } + [TestMethod] + public void Test_8519() + { + } + [TestMethod] + public void Test_8520() + { + } + [TestMethod] + public void Test_8521() + { + } + [TestMethod] + public void Test_8522() + { + } + [TestMethod] + public void Test_8523() + { + } + [TestMethod] + public void Test_8524() + { + } + [TestMethod] + public void Test_8525() + { + } + [TestMethod] + public void Test_8526() + { + } + [TestMethod] + public void Test_8527() + { + } + [TestMethod] + public void Test_8528() + { + } + [TestMethod] + public void Test_8529() + { + } + [TestMethod] + public void Test_8530() + { + } + [TestMethod] + public void Test_8531() + { + } + [TestMethod] + public void Test_8532() + { + } + [TestMethod] + public void Test_8533() + { + } + [TestMethod] + public void Test_8534() + { + } + [TestMethod] + public void Test_8535() + { + } + [TestMethod] + public void Test_8536() + { + } + [TestMethod] + public void Test_8537() + { + } + [TestMethod] + public void Test_8538() + { + } + [TestMethod] + public void Test_8539() + { + } + [TestMethod] + public void Test_8540() + { + } + [TestMethod] + public void Test_8541() + { + } + [TestMethod] + public void Test_8542() + { + } + [TestMethod] + public void Test_8543() + { + } + [TestMethod] + public void Test_8544() + { + } + [TestMethod] + public void Test_8545() + { + } + [TestMethod] + public void Test_8546() + { + } + [TestMethod] + public void Test_8547() + { + } + [TestMethod] + public void Test_8548() + { + } + [TestMethod] + public void Test_8549() + { + } + [TestMethod] + public void Test_8550() + { + } + [TestMethod] + public void Test_8551() + { + } + [TestMethod] + public void Test_8552() + { + } + [TestMethod] + public void Test_8553() + { + } + [TestMethod] + public void Test_8554() + { + } + [TestMethod] + public void Test_8555() + { + } + [TestMethod] + public void Test_8556() + { + } + [TestMethod] + public void Test_8557() + { + } + [TestMethod] + public void Test_8558() + { + } + [TestMethod] + public void Test_8559() + { + } + [TestMethod] + public void Test_8560() + { + } + [TestMethod] + public void Test_8561() + { + } + [TestMethod] + public void Test_8562() + { + } + [TestMethod] + public void Test_8563() + { + } + [TestMethod] + public void Test_8564() + { + } + [TestMethod] + public void Test_8565() + { + } + [TestMethod] + public void Test_8566() + { + } + [TestMethod] + public void Test_8567() + { + } + [TestMethod] + public void Test_8568() + { + } + [TestMethod] + public void Test_8569() + { + } + [TestMethod] + public void Test_8570() + { + } + [TestMethod] + public void Test_8571() + { + } + [TestMethod] + public void Test_8572() + { + } + [TestMethod] + public void Test_8573() + { + } + [TestMethod] + public void Test_8574() + { + } + [TestMethod] + public void Test_8575() + { + } + [TestMethod] + public void Test_8576() + { + } + [TestMethod] + public void Test_8577() + { + } + [TestMethod] + public void Test_8578() + { + } + [TestMethod] + public void Test_8579() + { + } + [TestMethod] + public void Test_8580() + { + } + [TestMethod] + public void Test_8581() + { + } + [TestMethod] + public void Test_8582() + { + } + [TestMethod] + public void Test_8583() + { + } + [TestMethod] + public void Test_8584() + { + } + [TestMethod] + public void Test_8585() + { + } + [TestMethod] + public void Test_8586() + { + } + [TestMethod] + public void Test_8587() + { + } + [TestMethod] + public void Test_8588() + { + } + [TestMethod] + public void Test_8589() + { + } + [TestMethod] + public void Test_8590() + { + } + [TestMethod] + public void Test_8591() + { + } + [TestMethod] + public void Test_8592() + { + } + [TestMethod] + public void Test_8593() + { + } + [TestMethod] + public void Test_8594() + { + } + [TestMethod] + public void Test_8595() + { + } + [TestMethod] + public void Test_8596() + { + } + [TestMethod] + public void Test_8597() + { + } + [TestMethod] + public void Test_8598() + { + } + [TestMethod] + public void Test_8599() + { + } + [TestMethod] + public void Test_8600() + { + } + [TestMethod] + public void Test_8601() + { + } + [TestMethod] + public void Test_8602() + { + } + [TestMethod] + public void Test_8603() + { + } + [TestMethod] + public void Test_8604() + { + } + [TestMethod] + public void Test_8605() + { + } + [TestMethod] + public void Test_8606() + { + } + [TestMethod] + public void Test_8607() + { + } + [TestMethod] + public void Test_8608() + { + } + [TestMethod] + public void Test_8609() + { + } + [TestMethod] + public void Test_8610() + { + } + [TestMethod] + public void Test_8611() + { + } + [TestMethod] + public void Test_8612() + { + } + [TestMethod] + public void Test_8613() + { + } + [TestMethod] + public void Test_8614() + { + } + [TestMethod] + public void Test_8615() + { + } + [TestMethod] + public void Test_8616() + { + } + [TestMethod] + public void Test_8617() + { + } + [TestMethod] + public void Test_8618() + { + } + [TestMethod] + public void Test_8619() + { + } + [TestMethod] + public void Test_8620() + { + } + [TestMethod] + public void Test_8621() + { + } + [TestMethod] + public void Test_8622() + { + } + [TestMethod] + public void Test_8623() + { + } + [TestMethod] + public void Test_8624() + { + } + [TestMethod] + public void Test_8625() + { + } + [TestMethod] + public void Test_8626() + { + } + [TestMethod] + public void Test_8627() + { + } + [TestMethod] + public void Test_8628() + { + } + [TestMethod] + public void Test_8629() + { + } + [TestMethod] + public void Test_8630() + { + } + [TestMethod] + public void Test_8631() + { + } + [TestMethod] + public void Test_8632() + { + } + [TestMethod] + public void Test_8633() + { + } + [TestMethod] + public void Test_8634() + { + } + [TestMethod] + public void Test_8635() + { + } + [TestMethod] + public void Test_8636() + { + } + [TestMethod] + public void Test_8637() + { + } + [TestMethod] + public void Test_8638() + { + } + [TestMethod] + public void Test_8639() + { + } + [TestMethod] + public void Test_8640() + { + } + [TestMethod] + public void Test_8641() + { + } + [TestMethod] + public void Test_8642() + { + } + [TestMethod] + public void Test_8643() + { + } + [TestMethod] + public void Test_8644() + { + } + [TestMethod] + public void Test_8645() + { + } + [TestMethod] + public void Test_8646() + { + } + [TestMethod] + public void Test_8647() + { + } + [TestMethod] + public void Test_8648() + { + } + [TestMethod] + public void Test_8649() + { + } + [TestMethod] + public void Test_8650() + { + } + [TestMethod] + public void Test_8651() + { + } + [TestMethod] + public void Test_8652() + { + } + [TestMethod] + public void Test_8653() + { + } + [TestMethod] + public void Test_8654() + { + } + [TestMethod] + public void Test_8655() + { + } + [TestMethod] + public void Test_8656() + { + } + [TestMethod] + public void Test_8657() + { + } + [TestMethod] + public void Test_8658() + { + } + [TestMethod] + public void Test_8659() + { + } + [TestMethod] + public void Test_8660() + { + } + [TestMethod] + public void Test_8661() + { + } + [TestMethod] + public void Test_8662() + { + } + [TestMethod] + public void Test_8663() + { + } + [TestMethod] + public void Test_8664() + { + } + [TestMethod] + public void Test_8665() + { + } + [TestMethod] + public void Test_8666() + { + } + [TestMethod] + public void Test_8667() + { + } + [TestMethod] + public void Test_8668() + { + } + [TestMethod] + public void Test_8669() + { + } + [TestMethod] + public void Test_8670() + { + } + [TestMethod] + public void Test_8671() + { + } + [TestMethod] + public void Test_8672() + { + } + [TestMethod] + public void Test_8673() + { + } + [TestMethod] + public void Test_8674() + { + } + [TestMethod] + public void Test_8675() + { + } + [TestMethod] + public void Test_8676() + { + } + [TestMethod] + public void Test_8677() + { + } + [TestMethod] + public void Test_8678() + { + } + [TestMethod] + public void Test_8679() + { + } + [TestMethod] + public void Test_8680() + { + } + [TestMethod] + public void Test_8681() + { + } + [TestMethod] + public void Test_8682() + { + } + [TestMethod] + public void Test_8683() + { + } + [TestMethod] + public void Test_8684() + { + } + [TestMethod] + public void Test_8685() + { + } + [TestMethod] + public void Test_8686() + { + } + [TestMethod] + public void Test_8687() + { + } + [TestMethod] + public void Test_8688() + { + } + [TestMethod] + public void Test_8689() + { + } + [TestMethod] + public void Test_8690() + { + } + [TestMethod] + public void Test_8691() + { + } + [TestMethod] + public void Test_8692() + { + } + [TestMethod] + public void Test_8693() + { + } + [TestMethod] + public void Test_8694() + { + } + [TestMethod] + public void Test_8695() + { + } + [TestMethod] + public void Test_8696() + { + } + [TestMethod] + public void Test_8697() + { + } + [TestMethod] + public void Test_8698() + { + } + [TestMethod] + public void Test_8699() + { + } + [TestMethod] + public void Test_8700() + { + } + [TestMethod] + public void Test_8701() + { + } + [TestMethod] + public void Test_8702() + { + } + [TestMethod] + public void Test_8703() + { + } + [TestMethod] + public void Test_8704() + { + } + [TestMethod] + public void Test_8705() + { + } + [TestMethod] + public void Test_8706() + { + } + [TestMethod] + public void Test_8707() + { + } + [TestMethod] + public void Test_8708() + { + } + [TestMethod] + public void Test_8709() + { + } + [TestMethod] + public void Test_8710() + { + } + [TestMethod] + public void Test_8711() + { + } + [TestMethod] + public void Test_8712() + { + } + [TestMethod] + public void Test_8713() + { + } + [TestMethod] + public void Test_8714() + { + } + [TestMethod] + public void Test_8715() + { + } + [TestMethod] + public void Test_8716() + { + } + [TestMethod] + public void Test_8717() + { + } + [TestMethod] + public void Test_8718() + { + } + [TestMethod] + public void Test_8719() + { + } + [TestMethod] + public void Test_8720() + { + } + [TestMethod] + public void Test_8721() + { + } + [TestMethod] + public void Test_8722() + { + } + [TestMethod] + public void Test_8723() + { + } + [TestMethod] + public void Test_8724() + { + } + [TestMethod] + public void Test_8725() + { + } + [TestMethod] + public void Test_8726() + { + } + [TestMethod] + public void Test_8727() + { + } + [TestMethod] + public void Test_8728() + { + } + [TestMethod] + public void Test_8729() + { + } + [TestMethod] + public void Test_8730() + { + } + [TestMethod] + public void Test_8731() + { + } + [TestMethod] + public void Test_8732() + { + } + [TestMethod] + public void Test_8733() + { + } + [TestMethod] + public void Test_8734() + { + } + [TestMethod] + public void Test_8735() + { + } + [TestMethod] + public void Test_8736() + { + } + [TestMethod] + public void Test_8737() + { + } + [TestMethod] + public void Test_8738() + { + } + [TestMethod] + public void Test_8739() + { + } + [TestMethod] + public void Test_8740() + { + } + [TestMethod] + public void Test_8741() + { + } + [TestMethod] + public void Test_8742() + { + } + [TestMethod] + public void Test_8743() + { + } + [TestMethod] + public void Test_8744() + { + } + [TestMethod] + public void Test_8745() + { + } + [TestMethod] + public void Test_8746() + { + } + [TestMethod] + public void Test_8747() + { + } + [TestMethod] + public void Test_8748() + { + } + [TestMethod] + public void Test_8749() + { + } + [TestMethod] + public void Test_8750() + { + } + [TestMethod] + public void Test_8751() + { + } + [TestMethod] + public void Test_8752() + { + } + [TestMethod] + public void Test_8753() + { + } + [TestMethod] + public void Test_8754() + { + } + [TestMethod] + public void Test_8755() + { + } + [TestMethod] + public void Test_8756() + { + } + [TestMethod] + public void Test_8757() + { + } + [TestMethod] + public void Test_8758() + { + } + [TestMethod] + public void Test_8759() + { + } + [TestMethod] + public void Test_8760() + { + } + [TestMethod] + public void Test_8761() + { + } + [TestMethod] + public void Test_8762() + { + } + [TestMethod] + public void Test_8763() + { + } + [TestMethod] + public void Test_8764() + { + } + [TestMethod] + public void Test_8765() + { + } + [TestMethod] + public void Test_8766() + { + } + [TestMethod] + public void Test_8767() + { + } + [TestMethod] + public void Test_8768() + { + } + [TestMethod] + public void Test_8769() + { + } + [TestMethod] + public void Test_8770() + { + } + [TestMethod] + public void Test_8771() + { + } + [TestMethod] + public void Test_8772() + { + } + [TestMethod] + public void Test_8773() + { + } + [TestMethod] + public void Test_8774() + { + } + [TestMethod] + public void Test_8775() + { + } + [TestMethod] + public void Test_8776() + { + } + [TestMethod] + public void Test_8777() + { + } + [TestMethod] + public void Test_8778() + { + } + [TestMethod] + public void Test_8779() + { + } + [TestMethod] + public void Test_8780() + { + } + [TestMethod] + public void Test_8781() + { + } + [TestMethod] + public void Test_8782() + { + } + [TestMethod] + public void Test_8783() + { + } + [TestMethod] + public void Test_8784() + { + } + [TestMethod] + public void Test_8785() + { + } + [TestMethod] + public void Test_8786() + { + } + [TestMethod] + public void Test_8787() + { + } + [TestMethod] + public void Test_8788() + { + } + [TestMethod] + public void Test_8789() + { + } + [TestMethod] + public void Test_8790() + { + } + [TestMethod] + public void Test_8791() + { + } + [TestMethod] + public void Test_8792() + { + } + [TestMethod] + public void Test_8793() + { + } + [TestMethod] + public void Test_8794() + { + } + [TestMethod] + public void Test_8795() + { + } + [TestMethod] + public void Test_8796() + { + } + [TestMethod] + public void Test_8797() + { + } + [TestMethod] + public void Test_8798() + { + } + [TestMethod] + public void Test_8799() + { + } + [TestMethod] + public void Test_8800() + { + } + [TestMethod] + public void Test_8801() + { + } + [TestMethod] + public void Test_8802() + { + } + [TestMethod] + public void Test_8803() + { + } + [TestMethod] + public void Test_8804() + { + } + [TestMethod] + public void Test_8805() + { + } + [TestMethod] + public void Test_8806() + { + } + [TestMethod] + public void Test_8807() + { + } + [TestMethod] + public void Test_8808() + { + } + [TestMethod] + public void Test_8809() + { + } + [TestMethod] + public void Test_8810() + { + } + [TestMethod] + public void Test_8811() + { + } + [TestMethod] + public void Test_8812() + { + } + [TestMethod] + public void Test_8813() + { + } + [TestMethod] + public void Test_8814() + { + } + [TestMethod] + public void Test_8815() + { + } + [TestMethod] + public void Test_8816() + { + } + [TestMethod] + public void Test_8817() + { + } + [TestMethod] + public void Test_8818() + { + } + [TestMethod] + public void Test_8819() + { + } + [TestMethod] + public void Test_8820() + { + } + [TestMethod] + public void Test_8821() + { + } + [TestMethod] + public void Test_8822() + { + } + [TestMethod] + public void Test_8823() + { + } + [TestMethod] + public void Test_8824() + { + } + [TestMethod] + public void Test_8825() + { + } + [TestMethod] + public void Test_8826() + { + } + [TestMethod] + public void Test_8827() + { + } + [TestMethod] + public void Test_8828() + { + } + [TestMethod] + public void Test_8829() + { + } + [TestMethod] + public void Test_8830() + { + } + [TestMethod] + public void Test_8831() + { + } + [TestMethod] + public void Test_8832() + { + } + [TestMethod] + public void Test_8833() + { + } + [TestMethod] + public void Test_8834() + { + } + [TestMethod] + public void Test_8835() + { + } + [TestMethod] + public void Test_8836() + { + } + [TestMethod] + public void Test_8837() + { + } + [TestMethod] + public void Test_8838() + { + } + [TestMethod] + public void Test_8839() + { + } + [TestMethod] + public void Test_8840() + { + } + [TestMethod] + public void Test_8841() + { + } + [TestMethod] + public void Test_8842() + { + } + [TestMethod] + public void Test_8843() + { + } + [TestMethod] + public void Test_8844() + { + } + [TestMethod] + public void Test_8845() + { + } + [TestMethod] + public void Test_8846() + { + } + [TestMethod] + public void Test_8847() + { + } + [TestMethod] + public void Test_8848() + { + } + [TestMethod] + public void Test_8849() + { + } + [TestMethod] + public void Test_8850() + { + } + [TestMethod] + public void Test_8851() + { + } + [TestMethod] + public void Test_8852() + { + } + [TestMethod] + public void Test_8853() + { + } + [TestMethod] + public void Test_8854() + { + } + [TestMethod] + public void Test_8855() + { + } + [TestMethod] + public void Test_8856() + { + } + [TestMethod] + public void Test_8857() + { + } + [TestMethod] + public void Test_8858() + { + } + [TestMethod] + public void Test_8859() + { + } + [TestMethod] + public void Test_8860() + { + } + [TestMethod] + public void Test_8861() + { + } + [TestMethod] + public void Test_8862() + { + } + [TestMethod] + public void Test_8863() + { + } + [TestMethod] + public void Test_8864() + { + } + [TestMethod] + public void Test_8865() + { + } + [TestMethod] + public void Test_8866() + { + } + [TestMethod] + public void Test_8867() + { + } + [TestMethod] + public void Test_8868() + { + } + [TestMethod] + public void Test_8869() + { + } + [TestMethod] + public void Test_8870() + { + } + [TestMethod] + public void Test_8871() + { + } + [TestMethod] + public void Test_8872() + { + } + [TestMethod] + public void Test_8873() + { + } + [TestMethod] + public void Test_8874() + { + } + [TestMethod] + public void Test_8875() + { + } + [TestMethod] + public void Test_8876() + { + } + [TestMethod] + public void Test_8877() + { + } + [TestMethod] + public void Test_8878() + { + } + [TestMethod] + public void Test_8879() + { + } + [TestMethod] + public void Test_8880() + { + } + [TestMethod] + public void Test_8881() + { + } + [TestMethod] + public void Test_8882() + { + } + [TestMethod] + public void Test_8883() + { + } + [TestMethod] + public void Test_8884() + { + } + [TestMethod] + public void Test_8885() + { + } + [TestMethod] + public void Test_8886() + { + } + [TestMethod] + public void Test_8887() + { + } + [TestMethod] + public void Test_8888() + { + } + [TestMethod] + public void Test_8889() + { + } + [TestMethod] + public void Test_8890() + { + } + [TestMethod] + public void Test_8891() + { + } + [TestMethod] + public void Test_8892() + { + } + [TestMethod] + public void Test_8893() + { + } + [TestMethod] + public void Test_8894() + { + } + [TestMethod] + public void Test_8895() + { + } + [TestMethod] + public void Test_8896() + { + } + [TestMethod] + public void Test_8897() + { + } + [TestMethod] + public void Test_8898() + { + } + [TestMethod] + public void Test_8899() + { + } + [TestMethod] + public void Test_8900() + { + } + [TestMethod] + public void Test_8901() + { + } + [TestMethod] + public void Test_8902() + { + } + [TestMethod] + public void Test_8903() + { + } + [TestMethod] + public void Test_8904() + { + } + [TestMethod] + public void Test_8905() + { + } + [TestMethod] + public void Test_8906() + { + } + [TestMethod] + public void Test_8907() + { + } + [TestMethod] + public void Test_8908() + { + } + [TestMethod] + public void Test_8909() + { + } + [TestMethod] + public void Test_8910() + { + } + [TestMethod] + public void Test_8911() + { + } + [TestMethod] + public void Test_8912() + { + } + [TestMethod] + public void Test_8913() + { + } + [TestMethod] + public void Test_8914() + { + } + [TestMethod] + public void Test_8915() + { + } + [TestMethod] + public void Test_8916() + { + } + [TestMethod] + public void Test_8917() + { + } + [TestMethod] + public void Test_8918() + { + } + [TestMethod] + public void Test_8919() + { + } + [TestMethod] + public void Test_8920() + { + } + [TestMethod] + public void Test_8921() + { + } + [TestMethod] + public void Test_8922() + { + } + [TestMethod] + public void Test_8923() + { + } + [TestMethod] + public void Test_8924() + { + } + [TestMethod] + public void Test_8925() + { + } + [TestMethod] + public void Test_8926() + { + } + [TestMethod] + public void Test_8927() + { + } + [TestMethod] + public void Test_8928() + { + } + [TestMethod] + public void Test_8929() + { + } + [TestMethod] + public void Test_8930() + { + } + [TestMethod] + public void Test_8931() + { + } + [TestMethod] + public void Test_8932() + { + } + [TestMethod] + public void Test_8933() + { + } + [TestMethod] + public void Test_8934() + { + } + [TestMethod] + public void Test_8935() + { + } + [TestMethod] + public void Test_8936() + { + } + [TestMethod] + public void Test_8937() + { + } + [TestMethod] + public void Test_8938() + { + } + [TestMethod] + public void Test_8939() + { + } + [TestMethod] + public void Test_8940() + { + } + [TestMethod] + public void Test_8941() + { + } + [TestMethod] + public void Test_8942() + { + } + [TestMethod] + public void Test_8943() + { + } + [TestMethod] + public void Test_8944() + { + } + [TestMethod] + public void Test_8945() + { + } + [TestMethod] + public void Test_8946() + { + } + [TestMethod] + public void Test_8947() + { + } + [TestMethod] + public void Test_8948() + { + } + [TestMethod] + public void Test_8949() + { + } + [TestMethod] + public void Test_8950() + { + } + [TestMethod] + public void Test_8951() + { + } + [TestMethod] + public void Test_8952() + { + } + [TestMethod] + public void Test_8953() + { + } + [TestMethod] + public void Test_8954() + { + } + [TestMethod] + public void Test_8955() + { + } + [TestMethod] + public void Test_8956() + { + } + [TestMethod] + public void Test_8957() + { + } + [TestMethod] + public void Test_8958() + { + } + [TestMethod] + public void Test_8959() + { + } + [TestMethod] + public void Test_8960() + { + } + [TestMethod] + public void Test_8961() + { + } + [TestMethod] + public void Test_8962() + { + } + [TestMethod] + public void Test_8963() + { + } + [TestMethod] + public void Test_8964() + { + } + [TestMethod] + public void Test_8965() + { + } + [TestMethod] + public void Test_8966() + { + } + [TestMethod] + public void Test_8967() + { + } + [TestMethod] + public void Test_8968() + { + } + [TestMethod] + public void Test_8969() + { + } + [TestMethod] + public void Test_8970() + { + } + [TestMethod] + public void Test_8971() + { + } + [TestMethod] + public void Test_8972() + { + } + [TestMethod] + public void Test_8973() + { + } + [TestMethod] + public void Test_8974() + { + } + [TestMethod] + public void Test_8975() + { + } + [TestMethod] + public void Test_8976() + { + } + [TestMethod] + public void Test_8977() + { + } + [TestMethod] + public void Test_8978() + { + } + [TestMethod] + public void Test_8979() + { + } + [TestMethod] + public void Test_8980() + { + } + [TestMethod] + public void Test_8981() + { + } + [TestMethod] + public void Test_8982() + { + } + [TestMethod] + public void Test_8983() + { + } + [TestMethod] + public void Test_8984() + { + } + [TestMethod] + public void Test_8985() + { + } + [TestMethod] + public void Test_8986() + { + } + [TestMethod] + public void Test_8987() + { + } + [TestMethod] + public void Test_8988() + { + } + [TestMethod] + public void Test_8989() + { + } + [TestMethod] + public void Test_8990() + { + } + [TestMethod] + public void Test_8991() + { + } + [TestMethod] + public void Test_8992() + { + } + [TestMethod] + public void Test_8993() + { + } + [TestMethod] + public void Test_8994() + { + } + [TestMethod] + public void Test_8995() + { + } + [TestMethod] + public void Test_8996() + { + } + [TestMethod] + public void Test_8997() + { + } + [TestMethod] + public void Test_8998() + { + } + [TestMethod] + public void Test_8999() + { + } + [TestMethod] + public void Test_9000() + { + } + [TestMethod] + public void Test_9001() + { + } + [TestMethod] + public void Test_9002() + { + } + [TestMethod] + public void Test_9003() + { + } + [TestMethod] + public void Test_9004() + { + } + [TestMethod] + public void Test_9005() + { + } + [TestMethod] + public void Test_9006() + { + } + [TestMethod] + public void Test_9007() + { + } + [TestMethod] + public void Test_9008() + { + } + [TestMethod] + public void Test_9009() + { + } + [TestMethod] + public void Test_9010() + { + } + [TestMethod] + public void Test_9011() + { + } + [TestMethod] + public void Test_9012() + { + } + [TestMethod] + public void Test_9013() + { + } + [TestMethod] + public void Test_9014() + { + } + [TestMethod] + public void Test_9015() + { + } + [TestMethod] + public void Test_9016() + { + } + [TestMethod] + public void Test_9017() + { + } + [TestMethod] + public void Test_9018() + { + } + [TestMethod] + public void Test_9019() + { + } + [TestMethod] + public void Test_9020() + { + } + [TestMethod] + public void Test_9021() + { + } + [TestMethod] + public void Test_9022() + { + } + [TestMethod] + public void Test_9023() + { + } + [TestMethod] + public void Test_9024() + { + } + [TestMethod] + public void Test_9025() + { + } + [TestMethod] + public void Test_9026() + { + } + [TestMethod] + public void Test_9027() + { + } + [TestMethod] + public void Test_9028() + { + } + [TestMethod] + public void Test_9029() + { + } + [TestMethod] + public void Test_9030() + { + } + [TestMethod] + public void Test_9031() + { + } + [TestMethod] + public void Test_9032() + { + } + [TestMethod] + public void Test_9033() + { + } + [TestMethod] + public void Test_9034() + { + } + [TestMethod] + public void Test_9035() + { + } + [TestMethod] + public void Test_9036() + { + } + [TestMethod] + public void Test_9037() + { + } + [TestMethod] + public void Test_9038() + { + } + [TestMethod] + public void Test_9039() + { + } + [TestMethod] + public void Test_9040() + { + } + [TestMethod] + public void Test_9041() + { + } + [TestMethod] + public void Test_9042() + { + } + [TestMethod] + public void Test_9043() + { + } + [TestMethod] + public void Test_9044() + { + } + [TestMethod] + public void Test_9045() + { + } + [TestMethod] + public void Test_9046() + { + } + [TestMethod] + public void Test_9047() + { + } + [TestMethod] + public void Test_9048() + { + } + [TestMethod] + public void Test_9049() + { + } + [TestMethod] + public void Test_9050() + { + } + [TestMethod] + public void Test_9051() + { + } + [TestMethod] + public void Test_9052() + { + } + [TestMethod] + public void Test_9053() + { + } + [TestMethod] + public void Test_9054() + { + } + [TestMethod] + public void Test_9055() + { + } + [TestMethod] + public void Test_9056() + { + } + [TestMethod] + public void Test_9057() + { + } + [TestMethod] + public void Test_9058() + { + } + [TestMethod] + public void Test_9059() + { + } + [TestMethod] + public void Test_9060() + { + } + [TestMethod] + public void Test_9061() + { + } + [TestMethod] + public void Test_9062() + { + } + [TestMethod] + public void Test_9063() + { + } + [TestMethod] + public void Test_9064() + { + } + [TestMethod] + public void Test_9065() + { + } + [TestMethod] + public void Test_9066() + { + } + [TestMethod] + public void Test_9067() + { + } + [TestMethod] + public void Test_9068() + { + } + [TestMethod] + public void Test_9069() + { + } + [TestMethod] + public void Test_9070() + { + } + [TestMethod] + public void Test_9071() + { + } + [TestMethod] + public void Test_9072() + { + } + [TestMethod] + public void Test_9073() + { + } + [TestMethod] + public void Test_9074() + { + } + [TestMethod] + public void Test_9075() + { + } + [TestMethod] + public void Test_9076() + { + } + [TestMethod] + public void Test_9077() + { + } + [TestMethod] + public void Test_9078() + { + } + [TestMethod] + public void Test_9079() + { + } + [TestMethod] + public void Test_9080() + { + } + [TestMethod] + public void Test_9081() + { + } + [TestMethod] + public void Test_9082() + { + } + [TestMethod] + public void Test_9083() + { + } + [TestMethod] + public void Test_9084() + { + } + [TestMethod] + public void Test_9085() + { + } + [TestMethod] + public void Test_9086() + { + } + [TestMethod] + public void Test_9087() + { + } + [TestMethod] + public void Test_9088() + { + } + [TestMethod] + public void Test_9089() + { + } + [TestMethod] + public void Test_9090() + { + } + [TestMethod] + public void Test_9091() + { + } + [TestMethod] + public void Test_9092() + { + } + [TestMethod] + public void Test_9093() + { + } + [TestMethod] + public void Test_9094() + { + } + [TestMethod] + public void Test_9095() + { + } + [TestMethod] + public void Test_9096() + { + } + [TestMethod] + public void Test_9097() + { + } + [TestMethod] + public void Test_9098() + { + } + [TestMethod] + public void Test_9099() + { + } + [TestMethod] + public void Test_9100() + { + } + [TestMethod] + public void Test_9101() + { + } + [TestMethod] + public void Test_9102() + { + } + [TestMethod] + public void Test_9103() + { + } + [TestMethod] + public void Test_9104() + { + } + [TestMethod] + public void Test_9105() + { + } + [TestMethod] + public void Test_9106() + { + } + [TestMethod] + public void Test_9107() + { + } + [TestMethod] + public void Test_9108() + { + } + [TestMethod] + public void Test_9109() + { + } + [TestMethod] + public void Test_9110() + { + } + [TestMethod] + public void Test_9111() + { + } + [TestMethod] + public void Test_9112() + { + } + [TestMethod] + public void Test_9113() + { + } + [TestMethod] + public void Test_9114() + { + } + [TestMethod] + public void Test_9115() + { + } + [TestMethod] + public void Test_9116() + { + } + [TestMethod] + public void Test_9117() + { + } + [TestMethod] + public void Test_9118() + { + } + [TestMethod] + public void Test_9119() + { + } + [TestMethod] + public void Test_9120() + { + } + [TestMethod] + public void Test_9121() + { + } + [TestMethod] + public void Test_9122() + { + } + [TestMethod] + public void Test_9123() + { + } + [TestMethod] + public void Test_9124() + { + } + [TestMethod] + public void Test_9125() + { + } + [TestMethod] + public void Test_9126() + { + } + [TestMethod] + public void Test_9127() + { + } + [TestMethod] + public void Test_9128() + { + } + [TestMethod] + public void Test_9129() + { + } + [TestMethod] + public void Test_9130() + { + } + [TestMethod] + public void Test_9131() + { + } + [TestMethod] + public void Test_9132() + { + } + [TestMethod] + public void Test_9133() + { + } + [TestMethod] + public void Test_9134() + { + } + [TestMethod] + public void Test_9135() + { + } + [TestMethod] + public void Test_9136() + { + } + [TestMethod] + public void Test_9137() + { + } + [TestMethod] + public void Test_9138() + { + } + [TestMethod] + public void Test_9139() + { + } + [TestMethod] + public void Test_9140() + { + } + [TestMethod] + public void Test_9141() + { + } + [TestMethod] + public void Test_9142() + { + } + [TestMethod] + public void Test_9143() + { + } + [TestMethod] + public void Test_9144() + { + } + [TestMethod] + public void Test_9145() + { + } + [TestMethod] + public void Test_9146() + { + } + [TestMethod] + public void Test_9147() + { + } + [TestMethod] + public void Test_9148() + { + } + [TestMethod] + public void Test_9149() + { + } + [TestMethod] + public void Test_9150() + { + } + [TestMethod] + public void Test_9151() + { + } + [TestMethod] + public void Test_9152() + { + } + [TestMethod] + public void Test_9153() + { + } + [TestMethod] + public void Test_9154() + { + } + [TestMethod] + public void Test_9155() + { + } + [TestMethod] + public void Test_9156() + { + } + [TestMethod] + public void Test_9157() + { + } + [TestMethod] + public void Test_9158() + { + } + [TestMethod] + public void Test_9159() + { + } + [TestMethod] + public void Test_9160() + { + } + [TestMethod] + public void Test_9161() + { + } + [TestMethod] + public void Test_9162() + { + } + [TestMethod] + public void Test_9163() + { + } + [TestMethod] + public void Test_9164() + { + } + [TestMethod] + public void Test_9165() + { + } + [TestMethod] + public void Test_9166() + { + } + [TestMethod] + public void Test_9167() + { + } + [TestMethod] + public void Test_9168() + { + } + [TestMethod] + public void Test_9169() + { + } + [TestMethod] + public void Test_9170() + { + } + [TestMethod] + public void Test_9171() + { + } + [TestMethod] + public void Test_9172() + { + } + [TestMethod] + public void Test_9173() + { + } + [TestMethod] + public void Test_9174() + { + } + [TestMethod] + public void Test_9175() + { + } + [TestMethod] + public void Test_9176() + { + } + [TestMethod] + public void Test_9177() + { + } + [TestMethod] + public void Test_9178() + { + } + [TestMethod] + public void Test_9179() + { + } + [TestMethod] + public void Test_9180() + { + } + [TestMethod] + public void Test_9181() + { + } + [TestMethod] + public void Test_9182() + { + } + [TestMethod] + public void Test_9183() + { + } + [TestMethod] + public void Test_9184() + { + } + [TestMethod] + public void Test_9185() + { + } + [TestMethod] + public void Test_9186() + { + } + [TestMethod] + public void Test_9187() + { + } + [TestMethod] + public void Test_9188() + { + } + [TestMethod] + public void Test_9189() + { + } + [TestMethod] + public void Test_9190() + { + } + [TestMethod] + public void Test_9191() + { + } + [TestMethod] + public void Test_9192() + { + } + [TestMethod] + public void Test_9193() + { + } + [TestMethod] + public void Test_9194() + { + } + [TestMethod] + public void Test_9195() + { + } + [TestMethod] + public void Test_9196() + { + } + [TestMethod] + public void Test_9197() + { + } + [TestMethod] + public void Test_9198() + { + } + [TestMethod] + public void Test_9199() + { + } + [TestMethod] + public void Test_9200() + { + } + [TestMethod] + public void Test_9201() + { + } + [TestMethod] + public void Test_9202() + { + } + [TestMethod] + public void Test_9203() + { + } + [TestMethod] + public void Test_9204() + { + } + [TestMethod] + public void Test_9205() + { + } + [TestMethod] + public void Test_9206() + { + } + [TestMethod] + public void Test_9207() + { + } + [TestMethod] + public void Test_9208() + { + } + [TestMethod] + public void Test_9209() + { + } + [TestMethod] + public void Test_9210() + { + } + [TestMethod] + public void Test_9211() + { + } + [TestMethod] + public void Test_9212() + { + } + [TestMethod] + public void Test_9213() + { + } + [TestMethod] + public void Test_9214() + { + } + [TestMethod] + public void Test_9215() + { + } + [TestMethod] + public void Test_9216() + { + } + [TestMethod] + public void Test_9217() + { + } + [TestMethod] + public void Test_9218() + { + } + [TestMethod] + public void Test_9219() + { + } + [TestMethod] + public void Test_9220() + { + } + [TestMethod] + public void Test_9221() + { + } + [TestMethod] + public void Test_9222() + { + } + [TestMethod] + public void Test_9223() + { + } + [TestMethod] + public void Test_9224() + { + } + [TestMethod] + public void Test_9225() + { + } + [TestMethod] + public void Test_9226() + { + } + [TestMethod] + public void Test_9227() + { + } + [TestMethod] + public void Test_9228() + { + } + [TestMethod] + public void Test_9229() + { + } + [TestMethod] + public void Test_9230() + { + } + [TestMethod] + public void Test_9231() + { + } + [TestMethod] + public void Test_9232() + { + } + [TestMethod] + public void Test_9233() + { + } + [TestMethod] + public void Test_9234() + { + } + [TestMethod] + public void Test_9235() + { + } + [TestMethod] + public void Test_9236() + { + } + [TestMethod] + public void Test_9237() + { + } + [TestMethod] + public void Test_9238() + { + } + [TestMethod] + public void Test_9239() + { + } + [TestMethod] + public void Test_9240() + { + } + [TestMethod] + public void Test_9241() + { + } + [TestMethod] + public void Test_9242() + { + } + [TestMethod] + public void Test_9243() + { + } + [TestMethod] + public void Test_9244() + { + } + [TestMethod] + public void Test_9245() + { + } + [TestMethod] + public void Test_9246() + { + } + [TestMethod] + public void Test_9247() + { + } + [TestMethod] + public void Test_9248() + { + } + [TestMethod] + public void Test_9249() + { + } + [TestMethod] + public void Test_9250() + { + } + [TestMethod] + public void Test_9251() + { + } + [TestMethod] + public void Test_9252() + { + } + [TestMethod] + public void Test_9253() + { + } + [TestMethod] + public void Test_9254() + { + } + [TestMethod] + public void Test_9255() + { + } + [TestMethod] + public void Test_9256() + { + } + [TestMethod] + public void Test_9257() + { + } + [TestMethod] + public void Test_9258() + { + } + [TestMethod] + public void Test_9259() + { + } + [TestMethod] + public void Test_9260() + { + } + [TestMethod] + public void Test_9261() + { + } + [TestMethod] + public void Test_9262() + { + } + [TestMethod] + public void Test_9263() + { + } + [TestMethod] + public void Test_9264() + { + } + [TestMethod] + public void Test_9265() + { + } + [TestMethod] + public void Test_9266() + { + } + [TestMethod] + public void Test_9267() + { + } + [TestMethod] + public void Test_9268() + { + } + [TestMethod] + public void Test_9269() + { + } + [TestMethod] + public void Test_9270() + { + } + [TestMethod] + public void Test_9271() + { + } + [TestMethod] + public void Test_9272() + { + } + [TestMethod] + public void Test_9273() + { + } + [TestMethod] + public void Test_9274() + { + } + [TestMethod] + public void Test_9275() + { + } + [TestMethod] + public void Test_9276() + { + } + [TestMethod] + public void Test_9277() + { + } + [TestMethod] + public void Test_9278() + { + } + [TestMethod] + public void Test_9279() + { + } + [TestMethod] + public void Test_9280() + { + } + [TestMethod] + public void Test_9281() + { + } + [TestMethod] + public void Test_9282() + { + } + [TestMethod] + public void Test_9283() + { + } + [TestMethod] + public void Test_9284() + { + } + [TestMethod] + public void Test_9285() + { + } + [TestMethod] + public void Test_9286() + { + } + [TestMethod] + public void Test_9287() + { + } + [TestMethod] + public void Test_9288() + { + } + [TestMethod] + public void Test_9289() + { + } + [TestMethod] + public void Test_9290() + { + } + [TestMethod] + public void Test_9291() + { + } + [TestMethod] + public void Test_9292() + { + } + [TestMethod] + public void Test_9293() + { + } + [TestMethod] + public void Test_9294() + { + } + [TestMethod] + public void Test_9295() + { + } + [TestMethod] + public void Test_9296() + { + } + [TestMethod] + public void Test_9297() + { + } + [TestMethod] + public void Test_9298() + { + } + [TestMethod] + public void Test_9299() + { + } + [TestMethod] + public void Test_9300() + { + } + [TestMethod] + public void Test_9301() + { + } + [TestMethod] + public void Test_9302() + { + } + [TestMethod] + public void Test_9303() + { + } + [TestMethod] + public void Test_9304() + { + } + [TestMethod] + public void Test_9305() + { + } + [TestMethod] + public void Test_9306() + { + } + [TestMethod] + public void Test_9307() + { + } + [TestMethod] + public void Test_9308() + { + } + [TestMethod] + public void Test_9309() + { + } + [TestMethod] + public void Test_9310() + { + } + [TestMethod] + public void Test_9311() + { + } + [TestMethod] + public void Test_9312() + { + } + [TestMethod] + public void Test_9313() + { + } + [TestMethod] + public void Test_9314() + { + } + [TestMethod] + public void Test_9315() + { + } + [TestMethod] + public void Test_9316() + { + } + [TestMethod] + public void Test_9317() + { + } + [TestMethod] + public void Test_9318() + { + } + [TestMethod] + public void Test_9319() + { + } + [TestMethod] + public void Test_9320() + { + } + [TestMethod] + public void Test_9321() + { + } + [TestMethod] + public void Test_9322() + { + } + [TestMethod] + public void Test_9323() + { + } + [TestMethod] + public void Test_9324() + { + } + [TestMethod] + public void Test_9325() + { + } + [TestMethod] + public void Test_9326() + { + } + [TestMethod] + public void Test_9327() + { + } + [TestMethod] + public void Test_9328() + { + } + [TestMethod] + public void Test_9329() + { + } + [TestMethod] + public void Test_9330() + { + } + [TestMethod] + public void Test_9331() + { + } + [TestMethod] + public void Test_9332() + { + } + [TestMethod] + public void Test_9333() + { + } + [TestMethod] + public void Test_9334() + { + } + [TestMethod] + public void Test_9335() + { + } + [TestMethod] + public void Test_9336() + { + } + [TestMethod] + public void Test_9337() + { + } + [TestMethod] + public void Test_9338() + { + } + [TestMethod] + public void Test_9339() + { + } + [TestMethod] + public void Test_9340() + { + } + [TestMethod] + public void Test_9341() + { + } + [TestMethod] + public void Test_9342() + { + } + [TestMethod] + public void Test_9343() + { + } + [TestMethod] + public void Test_9344() + { + } + [TestMethod] + public void Test_9345() + { + } + [TestMethod] + public void Test_9346() + { + } + [TestMethod] + public void Test_9347() + { + } + [TestMethod] + public void Test_9348() + { + } + [TestMethod] + public void Test_9349() + { + } + [TestMethod] + public void Test_9350() + { + } + [TestMethod] + public void Test_9351() + { + } + [TestMethod] + public void Test_9352() + { + } + [TestMethod] + public void Test_9353() + { + } + [TestMethod] + public void Test_9354() + { + } + [TestMethod] + public void Test_9355() + { + } + [TestMethod] + public void Test_9356() + { + } + [TestMethod] + public void Test_9357() + { + } + [TestMethod] + public void Test_9358() + { + } + [TestMethod] + public void Test_9359() + { + } + [TestMethod] + public void Test_9360() + { + } + [TestMethod] + public void Test_9361() + { + } + [TestMethod] + public void Test_9362() + { + } + [TestMethod] + public void Test_9363() + { + } + [TestMethod] + public void Test_9364() + { + } + [TestMethod] + public void Test_9365() + { + } + [TestMethod] + public void Test_9366() + { + } + [TestMethod] + public void Test_9367() + { + } + [TestMethod] + public void Test_9368() + { + } + [TestMethod] + public void Test_9369() + { + } + [TestMethod] + public void Test_9370() + { + } + [TestMethod] + public void Test_9371() + { + } + [TestMethod] + public void Test_9372() + { + } + [TestMethod] + public void Test_9373() + { + } + [TestMethod] + public void Test_9374() + { + } + [TestMethod] + public void Test_9375() + { + } + [TestMethod] + public void Test_9376() + { + } + [TestMethod] + public void Test_9377() + { + } + [TestMethod] + public void Test_9378() + { + } + [TestMethod] + public void Test_9379() + { + } + [TestMethod] + public void Test_9380() + { + } + [TestMethod] + public void Test_9381() + { + } + [TestMethod] + public void Test_9382() + { + } + [TestMethod] + public void Test_9383() + { + } + [TestMethod] + public void Test_9384() + { + } + [TestMethod] + public void Test_9385() + { + } + [TestMethod] + public void Test_9386() + { + } + [TestMethod] + public void Test_9387() + { + } + [TestMethod] + public void Test_9388() + { + } + [TestMethod] + public void Test_9389() + { + } + [TestMethod] + public void Test_9390() + { + } + [TestMethod] + public void Test_9391() + { + } + [TestMethod] + public void Test_9392() + { + } + [TestMethod] + public void Test_9393() + { + } + [TestMethod] + public void Test_9394() + { + } + [TestMethod] + public void Test_9395() + { + } + [TestMethod] + public void Test_9396() + { + } + [TestMethod] + public void Test_9397() + { + } + [TestMethod] + public void Test_9398() + { + } + [TestMethod] + public void Test_9399() + { + } + [TestMethod] + public void Test_9400() + { + } + [TestMethod] + public void Test_9401() + { + } + [TestMethod] + public void Test_9402() + { + } + [TestMethod] + public void Test_9403() + { + } + [TestMethod] + public void Test_9404() + { + } + [TestMethod] + public void Test_9405() + { + } + [TestMethod] + public void Test_9406() + { + } + [TestMethod] + public void Test_9407() + { + } + [TestMethod] + public void Test_9408() + { + } + [TestMethod] + public void Test_9409() + { + } + [TestMethod] + public void Test_9410() + { + } + [TestMethod] + public void Test_9411() + { + } + [TestMethod] + public void Test_9412() + { + } + [TestMethod] + public void Test_9413() + { + } + [TestMethod] + public void Test_9414() + { + } + [TestMethod] + public void Test_9415() + { + } + [TestMethod] + public void Test_9416() + { + } + [TestMethod] + public void Test_9417() + { + } + [TestMethod] + public void Test_9418() + { + } + [TestMethod] + public void Test_9419() + { + } + [TestMethod] + public void Test_9420() + { + } + [TestMethod] + public void Test_9421() + { + } + [TestMethod] + public void Test_9422() + { + } + [TestMethod] + public void Test_9423() + { + } + [TestMethod] + public void Test_9424() + { + } + [TestMethod] + public void Test_9425() + { + } + [TestMethod] + public void Test_9426() + { + } + [TestMethod] + public void Test_9427() + { + } + [TestMethod] + public void Test_9428() + { + } + [TestMethod] + public void Test_9429() + { + } + [TestMethod] + public void Test_9430() + { + } + [TestMethod] + public void Test_9431() + { + } + [TestMethod] + public void Test_9432() + { + } + [TestMethod] + public void Test_9433() + { + } + [TestMethod] + public void Test_9434() + { + } + [TestMethod] + public void Test_9435() + { + } + [TestMethod] + public void Test_9436() + { + } + [TestMethod] + public void Test_9437() + { + } + [TestMethod] + public void Test_9438() + { + } + [TestMethod] + public void Test_9439() + { + } + [TestMethod] + public void Test_9440() + { + } + [TestMethod] + public void Test_9441() + { + } + [TestMethod] + public void Test_9442() + { + } + [TestMethod] + public void Test_9443() + { + } + [TestMethod] + public void Test_9444() + { + } + [TestMethod] + public void Test_9445() + { + } + [TestMethod] + public void Test_9446() + { + } + [TestMethod] + public void Test_9447() + { + } + [TestMethod] + public void Test_9448() + { + } + [TestMethod] + public void Test_9449() + { + } + [TestMethod] + public void Test_9450() + { + } + [TestMethod] + public void Test_9451() + { + } + [TestMethod] + public void Test_9452() + { + } + [TestMethod] + public void Test_9453() + { + } + [TestMethod] + public void Test_9454() + { + } + [TestMethod] + public void Test_9455() + { + } + [TestMethod] + public void Test_9456() + { + } + [TestMethod] + public void Test_9457() + { + } + [TestMethod] + public void Test_9458() + { + } + [TestMethod] + public void Test_9459() + { + } + [TestMethod] + public void Test_9460() + { + } + [TestMethod] + public void Test_9461() + { + } + [TestMethod] + public void Test_9462() + { + } + [TestMethod] + public void Test_9463() + { + } + [TestMethod] + public void Test_9464() + { + } + [TestMethod] + public void Test_9465() + { + } + [TestMethod] + public void Test_9466() + { + } + [TestMethod] + public void Test_9467() + { + } + [TestMethod] + public void Test_9468() + { + } + [TestMethod] + public void Test_9469() + { + } + [TestMethod] + public void Test_9470() + { + } + [TestMethod] + public void Test_9471() + { + } + [TestMethod] + public void Test_9472() + { + } + [TestMethod] + public void Test_9473() + { + } + [TestMethod] + public void Test_9474() + { + } + [TestMethod] + public void Test_9475() + { + } + [TestMethod] + public void Test_9476() + { + } + [TestMethod] + public void Test_9477() + { + } + [TestMethod] + public void Test_9478() + { + } + [TestMethod] + public void Test_9479() + { + } + [TestMethod] + public void Test_9480() + { + } + [TestMethod] + public void Test_9481() + { + } + [TestMethod] + public void Test_9482() + { + } + [TestMethod] + public void Test_9483() + { + } + [TestMethod] + public void Test_9484() + { + } + [TestMethod] + public void Test_9485() + { + } + [TestMethod] + public void Test_9486() + { + } + [TestMethod] + public void Test_9487() + { + } + [TestMethod] + public void Test_9488() + { + } + [TestMethod] + public void Test_9489() + { + } + [TestMethod] + public void Test_9490() + { + } + [TestMethod] + public void Test_9491() + { + } + [TestMethod] + public void Test_9492() + { + } + [TestMethod] + public void Test_9493() + { + } + [TestMethod] + public void Test_9494() + { + } + [TestMethod] + public void Test_9495() + { + } + [TestMethod] + public void Test_9496() + { + } + [TestMethod] + public void Test_9497() + { + } + [TestMethod] + public void Test_9498() + { + } + [TestMethod] + public void Test_9499() + { + } + [TestMethod] + public void Test_9500() + { + } + [TestMethod] + public void Test_9501() + { + } + [TestMethod] + public void Test_9502() + { + } + [TestMethod] + public void Test_9503() + { + } + [TestMethod] + public void Test_9504() + { + } + [TestMethod] + public void Test_9505() + { + } + [TestMethod] + public void Test_9506() + { + } + [TestMethod] + public void Test_9507() + { + } + [TestMethod] + public void Test_9508() + { + } + [TestMethod] + public void Test_9509() + { + } + [TestMethod] + public void Test_9510() + { + } + [TestMethod] + public void Test_9511() + { + } + [TestMethod] + public void Test_9512() + { + } + [TestMethod] + public void Test_9513() + { + } + [TestMethod] + public void Test_9514() + { + } + [TestMethod] + public void Test_9515() + { + } + [TestMethod] + public void Test_9516() + { + } + [TestMethod] + public void Test_9517() + { + } + [TestMethod] + public void Test_9518() + { + } + [TestMethod] + public void Test_9519() + { + } + [TestMethod] + public void Test_9520() + { + } + [TestMethod] + public void Test_9521() + { + } + [TestMethod] + public void Test_9522() + { + } + [TestMethod] + public void Test_9523() + { + } + [TestMethod] + public void Test_9524() + { + } + [TestMethod] + public void Test_9525() + { + } + [TestMethod] + public void Test_9526() + { + } + [TestMethod] + public void Test_9527() + { + } + [TestMethod] + public void Test_9528() + { + } + [TestMethod] + public void Test_9529() + { + } + [TestMethod] + public void Test_9530() + { + } + [TestMethod] + public void Test_9531() + { + } + [TestMethod] + public void Test_9532() + { + } + [TestMethod] + public void Test_9533() + { + } + [TestMethod] + public void Test_9534() + { + } + [TestMethod] + public void Test_9535() + { + } + [TestMethod] + public void Test_9536() + { + } + [TestMethod] + public void Test_9537() + { + } + [TestMethod] + public void Test_9538() + { + } + [TestMethod] + public void Test_9539() + { + } + [TestMethod] + public void Test_9540() + { + } + [TestMethod] + public void Test_9541() + { + } + [TestMethod] + public void Test_9542() + { + } + [TestMethod] + public void Test_9543() + { + } + [TestMethod] + public void Test_9544() + { + } + [TestMethod] + public void Test_9545() + { + } + [TestMethod] + public void Test_9546() + { + } + [TestMethod] + public void Test_9547() + { + } + [TestMethod] + public void Test_9548() + { + } + [TestMethod] + public void Test_9549() + { + } + [TestMethod] + public void Test_9550() + { + } + [TestMethod] + public void Test_9551() + { + } + [TestMethod] + public void Test_9552() + { + } + [TestMethod] + public void Test_9553() + { + } + [TestMethod] + public void Test_9554() + { + } + [TestMethod] + public void Test_9555() + { + } + [TestMethod] + public void Test_9556() + { + } + [TestMethod] + public void Test_9557() + { + } + [TestMethod] + public void Test_9558() + { + } + [TestMethod] + public void Test_9559() + { + } + [TestMethod] + public void Test_9560() + { + } + [TestMethod] + public void Test_9561() + { + } + [TestMethod] + public void Test_9562() + { + } + [TestMethod] + public void Test_9563() + { + } + [TestMethod] + public void Test_9564() + { + } + [TestMethod] + public void Test_9565() + { + } + [TestMethod] + public void Test_9566() + { + } + [TestMethod] + public void Test_9567() + { + } + [TestMethod] + public void Test_9568() + { + } + [TestMethod] + public void Test_9569() + { + } + [TestMethod] + public void Test_9570() + { + } + [TestMethod] + public void Test_9571() + { + } + [TestMethod] + public void Test_9572() + { + } + [TestMethod] + public void Test_9573() + { + } + [TestMethod] + public void Test_9574() + { + } + [TestMethod] + public void Test_9575() + { + } + [TestMethod] + public void Test_9576() + { + } + [TestMethod] + public void Test_9577() + { + } + [TestMethod] + public void Test_9578() + { + } + [TestMethod] + public void Test_9579() + { + } + [TestMethod] + public void Test_9580() + { + } + [TestMethod] + public void Test_9581() + { + } + [TestMethod] + public void Test_9582() + { + } + [TestMethod] + public void Test_9583() + { + } + [TestMethod] + public void Test_9584() + { + } + [TestMethod] + public void Test_9585() + { + } + [TestMethod] + public void Test_9586() + { + } + [TestMethod] + public void Test_9587() + { + } + [TestMethod] + public void Test_9588() + { + } + [TestMethod] + public void Test_9589() + { + } + [TestMethod] + public void Test_9590() + { + } + [TestMethod] + public void Test_9591() + { + } + [TestMethod] + public void Test_9592() + { + } + [TestMethod] + public void Test_9593() + { + } + [TestMethod] + public void Test_9594() + { + } + [TestMethod] + public void Test_9595() + { + } + [TestMethod] + public void Test_9596() + { + } + [TestMethod] + public void Test_9597() + { + } + [TestMethod] + public void Test_9598() + { + } + [TestMethod] + public void Test_9599() + { + } + [TestMethod] + public void Test_9600() + { + } + [TestMethod] + public void Test_9601() + { + } + [TestMethod] + public void Test_9602() + { + } + [TestMethod] + public void Test_9603() + { + } + [TestMethod] + public void Test_9604() + { + } + [TestMethod] + public void Test_9605() + { + } + [TestMethod] + public void Test_9606() + { + } + [TestMethod] + public void Test_9607() + { + } + [TestMethod] + public void Test_9608() + { + } + [TestMethod] + public void Test_9609() + { + } + [TestMethod] + public void Test_9610() + { + } + [TestMethod] + public void Test_9611() + { + } + [TestMethod] + public void Test_9612() + { + } + [TestMethod] + public void Test_9613() + { + } + [TestMethod] + public void Test_9614() + { + } + [TestMethod] + public void Test_9615() + { + } + [TestMethod] + public void Test_9616() + { + } + [TestMethod] + public void Test_9617() + { + } + [TestMethod] + public void Test_9618() + { + } + [TestMethod] + public void Test_9619() + { + } + [TestMethod] + public void Test_9620() + { + } + [TestMethod] + public void Test_9621() + { + } + [TestMethod] + public void Test_9622() + { + } + [TestMethod] + public void Test_9623() + { + } + [TestMethod] + public void Test_9624() + { + } + [TestMethod] + public void Test_9625() + { + } + [TestMethod] + public void Test_9626() + { + } + [TestMethod] + public void Test_9627() + { + } + [TestMethod] + public void Test_9628() + { + } + [TestMethod] + public void Test_9629() + { + } + [TestMethod] + public void Test_9630() + { + } + [TestMethod] + public void Test_9631() + { + } + [TestMethod] + public void Test_9632() + { + } + [TestMethod] + public void Test_9633() + { + } + [TestMethod] + public void Test_9634() + { + } + [TestMethod] + public void Test_9635() + { + } + [TestMethod] + public void Test_9636() + { + } + [TestMethod] + public void Test_9637() + { + } + [TestMethod] + public void Test_9638() + { + } + [TestMethod] + public void Test_9639() + { + } + [TestMethod] + public void Test_9640() + { + } + [TestMethod] + public void Test_9641() + { + } + [TestMethod] + public void Test_9642() + { + } + [TestMethod] + public void Test_9643() + { + } + [TestMethod] + public void Test_9644() + { + } + [TestMethod] + public void Test_9645() + { + } + [TestMethod] + public void Test_9646() + { + } + [TestMethod] + public void Test_9647() + { + } + [TestMethod] + public void Test_9648() + { + } + [TestMethod] + public void Test_9649() + { + } + [TestMethod] + public void Test_9650() + { + } + [TestMethod] + public void Test_9651() + { + } + [TestMethod] + public void Test_9652() + { + } + [TestMethod] + public void Test_9653() + { + } + [TestMethod] + public void Test_9654() + { + } + [TestMethod] + public void Test_9655() + { + } + [TestMethod] + public void Test_9656() + { + } + [TestMethod] + public void Test_9657() + { + } + [TestMethod] + public void Test_9658() + { + } + [TestMethod] + public void Test_9659() + { + } + [TestMethod] + public void Test_9660() + { + } + [TestMethod] + public void Test_9661() + { + } + [TestMethod] + public void Test_9662() + { + } + [TestMethod] + public void Test_9663() + { + } + [TestMethod] + public void Test_9664() + { + } + [TestMethod] + public void Test_9665() + { + } + [TestMethod] + public void Test_9666() + { + } + [TestMethod] + public void Test_9667() + { + } + [TestMethod] + public void Test_9668() + { + } + [TestMethod] + public void Test_9669() + { + } + [TestMethod] + public void Test_9670() + { + } + [TestMethod] + public void Test_9671() + { + } + [TestMethod] + public void Test_9672() + { + } + [TestMethod] + public void Test_9673() + { + } + [TestMethod] + public void Test_9674() + { + } + [TestMethod] + public void Test_9675() + { + } + [TestMethod] + public void Test_9676() + { + } + [TestMethod] + public void Test_9677() + { + } + [TestMethod] + public void Test_9678() + { + } + [TestMethod] + public void Test_9679() + { + } + [TestMethod] + public void Test_9680() + { + } + [TestMethod] + public void Test_9681() + { + } + [TestMethod] + public void Test_9682() + { + } + [TestMethod] + public void Test_9683() + { + } + [TestMethod] + public void Test_9684() + { + } + [TestMethod] + public void Test_9685() + { + } + [TestMethod] + public void Test_9686() + { + } + [TestMethod] + public void Test_9687() + { + } + [TestMethod] + public void Test_9688() + { + } + [TestMethod] + public void Test_9689() + { + } + [TestMethod] + public void Test_9690() + { + } + [TestMethod] + public void Test_9691() + { + } + [TestMethod] + public void Test_9692() + { + } + [TestMethod] + public void Test_9693() + { + } + [TestMethod] + public void Test_9694() + { + } + [TestMethod] + public void Test_9695() + { + } + [TestMethod] + public void Test_9696() + { + } + [TestMethod] + public void Test_9697() + { + } + [TestMethod] + public void Test_9698() + { + } + [TestMethod] + public void Test_9699() + { + } + [TestMethod] + public void Test_9700() + { + } + [TestMethod] + public void Test_9701() + { + } + [TestMethod] + public void Test_9702() + { + } + [TestMethod] + public void Test_9703() + { + } + [TestMethod] + public void Test_9704() + { + } + [TestMethod] + public void Test_9705() + { + } + [TestMethod] + public void Test_9706() + { + } + [TestMethod] + public void Test_9707() + { + } + [TestMethod] + public void Test_9708() + { + } + [TestMethod] + public void Test_9709() + { + } + [TestMethod] + public void Test_9710() + { + } + [TestMethod] + public void Test_9711() + { + } + [TestMethod] + public void Test_9712() + { + } + [TestMethod] + public void Test_9713() + { + } + [TestMethod] + public void Test_9714() + { + } + [TestMethod] + public void Test_9715() + { + } + [TestMethod] + public void Test_9716() + { + } + [TestMethod] + public void Test_9717() + { + } + [TestMethod] + public void Test_9718() + { + } + [TestMethod] + public void Test_9719() + { + } + [TestMethod] + public void Test_9720() + { + } + [TestMethod] + public void Test_9721() + { + } + [TestMethod] + public void Test_9722() + { + } + [TestMethod] + public void Test_9723() + { + } + [TestMethod] + public void Test_9724() + { + } + [TestMethod] + public void Test_9725() + { + } + [TestMethod] + public void Test_9726() + { + } + [TestMethod] + public void Test_9727() + { + } + [TestMethod] + public void Test_9728() + { + } + [TestMethod] + public void Test_9729() + { + } + [TestMethod] + public void Test_9730() + { + } + [TestMethod] + public void Test_9731() + { + } + [TestMethod] + public void Test_9732() + { + } + [TestMethod] + public void Test_9733() + { + } + [TestMethod] + public void Test_9734() + { + } + [TestMethod] + public void Test_9735() + { + } + [TestMethod] + public void Test_9736() + { + } + [TestMethod] + public void Test_9737() + { + } + [TestMethod] + public void Test_9738() + { + } + [TestMethod] + public void Test_9739() + { + } + [TestMethod] + public void Test_9740() + { + } + [TestMethod] + public void Test_9741() + { + } + [TestMethod] + public void Test_9742() + { + } + [TestMethod] + public void Test_9743() + { + } + [TestMethod] + public void Test_9744() + { + } + [TestMethod] + public void Test_9745() + { + } + [TestMethod] + public void Test_9746() + { + } + [TestMethod] + public void Test_9747() + { + } + [TestMethod] + public void Test_9748() + { + } + [TestMethod] + public void Test_9749() + { + } + [TestMethod] + public void Test_9750() + { + } + [TestMethod] + public void Test_9751() + { + } + [TestMethod] + public void Test_9752() + { + } + [TestMethod] + public void Test_9753() + { + } + [TestMethod] + public void Test_9754() + { + } + [TestMethod] + public void Test_9755() + { + } + [TestMethod] + public void Test_9756() + { + } + [TestMethod] + public void Test_9757() + { + } + [TestMethod] + public void Test_9758() + { + } + [TestMethod] + public void Test_9759() + { + } + [TestMethod] + public void Test_9760() + { + } + [TestMethod] + public void Test_9761() + { + } + [TestMethod] + public void Test_9762() + { + } + [TestMethod] + public void Test_9763() + { + } + [TestMethod] + public void Test_9764() + { + } + [TestMethod] + public void Test_9765() + { + } + [TestMethod] + public void Test_9766() + { + } + [TestMethod] + public void Test_9767() + { + } + [TestMethod] + public void Test_9768() + { + } + [TestMethod] + public void Test_9769() + { + } + [TestMethod] + public void Test_9770() + { + } + [TestMethod] + public void Test_9771() + { + } + [TestMethod] + public void Test_9772() + { + } + [TestMethod] + public void Test_9773() + { + } + [TestMethod] + public void Test_9774() + { + } + [TestMethod] + public void Test_9775() + { + } + [TestMethod] + public void Test_9776() + { + } + [TestMethod] + public void Test_9777() + { + } + [TestMethod] + public void Test_9778() + { + } + [TestMethod] + public void Test_9779() + { + } + [TestMethod] + public void Test_9780() + { + } + [TestMethod] + public void Test_9781() + { + } + [TestMethod] + public void Test_9782() + { + } + [TestMethod] + public void Test_9783() + { + } + [TestMethod] + public void Test_9784() + { + } + [TestMethod] + public void Test_9785() + { + } + [TestMethod] + public void Test_9786() + { + } + [TestMethod] + public void Test_9787() + { + } + [TestMethod] + public void Test_9788() + { + } + [TestMethod] + public void Test_9789() + { + } + [TestMethod] + public void Test_9790() + { + } + [TestMethod] + public void Test_9791() + { + } + [TestMethod] + public void Test_9792() + { + } + [TestMethod] + public void Test_9793() + { + } + [TestMethod] + public void Test_9794() + { + } + [TestMethod] + public void Test_9795() + { + } + [TestMethod] + public void Test_9796() + { + } + [TestMethod] + public void Test_9797() + { + } + [TestMethod] + public void Test_9798() + { + } + [TestMethod] + public void Test_9799() + { + } + [TestMethod] + public void Test_9800() + { + } + [TestMethod] + public void Test_9801() + { + } + [TestMethod] + public void Test_9802() + { + } + [TestMethod] + public void Test_9803() + { + } + [TestMethod] + public void Test_9804() + { + } + [TestMethod] + public void Test_9805() + { + } + [TestMethod] + public void Test_9806() + { + } + [TestMethod] + public void Test_9807() + { + } + [TestMethod] + public void Test_9808() + { + } + [TestMethod] + public void Test_9809() + { + } + [TestMethod] + public void Test_9810() + { + } + [TestMethod] + public void Test_9811() + { + } + [TestMethod] + public void Test_9812() + { + } + [TestMethod] + public void Test_9813() + { + } + [TestMethod] + public void Test_9814() + { + } + [TestMethod] + public void Test_9815() + { + } + [TestMethod] + public void Test_9816() + { + } + [TestMethod] + public void Test_9817() + { + } + [TestMethod] + public void Test_9818() + { + } + [TestMethod] + public void Test_9819() + { + } + [TestMethod] + public void Test_9820() + { + } + [TestMethod] + public void Test_9821() + { + } + [TestMethod] + public void Test_9822() + { + } + [TestMethod] + public void Test_9823() + { + } + [TestMethod] + public void Test_9824() + { + } + [TestMethod] + public void Test_9825() + { + } + [TestMethod] + public void Test_9826() + { + } + [TestMethod] + public void Test_9827() + { + } + [TestMethod] + public void Test_9828() + { + } + [TestMethod] + public void Test_9829() + { + } + [TestMethod] + public void Test_9830() + { + } + [TestMethod] + public void Test_9831() + { + } + [TestMethod] + public void Test_9832() + { + } + [TestMethod] + public void Test_9833() + { + } + [TestMethod] + public void Test_9834() + { + } + [TestMethod] + public void Test_9835() + { + } + [TestMethod] + public void Test_9836() + { + } + [TestMethod] + public void Test_9837() + { + } + [TestMethod] + public void Test_9838() + { + } + [TestMethod] + public void Test_9839() + { + } + [TestMethod] + public void Test_9840() + { + } + [TestMethod] + public void Test_9841() + { + } + [TestMethod] + public void Test_9842() + { + } + [TestMethod] + public void Test_9843() + { + } + [TestMethod] + public void Test_9844() + { + } + [TestMethod] + public void Test_9845() + { + } + [TestMethod] + public void Test_9846() + { + } + [TestMethod] + public void Test_9847() + { + } + [TestMethod] + public void Test_9848() + { + } + [TestMethod] + public void Test_9849() + { + } + [TestMethod] + public void Test_9850() + { + } + [TestMethod] + public void Test_9851() + { + } + [TestMethod] + public void Test_9852() + { + } + [TestMethod] + public void Test_9853() + { + } + [TestMethod] + public void Test_9854() + { + } + [TestMethod] + public void Test_9855() + { + } + [TestMethod] + public void Test_9856() + { + } + [TestMethod] + public void Test_9857() + { + } + [TestMethod] + public void Test_9858() + { + } + [TestMethod] + public void Test_9859() + { + } + [TestMethod] + public void Test_9860() + { + } + [TestMethod] + public void Test_9861() + { + } + [TestMethod] + public void Test_9862() + { + } + [TestMethod] + public void Test_9863() + { + } + [TestMethod] + public void Test_9864() + { + } + [TestMethod] + public void Test_9865() + { + } + [TestMethod] + public void Test_9866() + { + } + [TestMethod] + public void Test_9867() + { + } + [TestMethod] + public void Test_9868() + { + } + [TestMethod] + public void Test_9869() + { + } + [TestMethod] + public void Test_9870() + { + } + [TestMethod] + public void Test_9871() + { + } + [TestMethod] + public void Test_9872() + { + } + [TestMethod] + public void Test_9873() + { + } + [TestMethod] + public void Test_9874() + { + } + [TestMethod] + public void Test_9875() + { + } + [TestMethod] + public void Test_9876() + { + } + [TestMethod] + public void Test_9877() + { + } + [TestMethod] + public void Test_9878() + { + } + [TestMethod] + public void Test_9879() + { + } + [TestMethod] + public void Test_9880() + { + } + [TestMethod] + public void Test_9881() + { + } + [TestMethod] + public void Test_9882() + { + } + [TestMethod] + public void Test_9883() + { + } + [TestMethod] + public void Test_9884() + { + } + [TestMethod] + public void Test_9885() + { + } + [TestMethod] + public void Test_9886() + { + } + [TestMethod] + public void Test_9887() + { + } + [TestMethod] + public void Test_9888() + { + } + [TestMethod] + public void Test_9889() + { + } + [TestMethod] + public void Test_9890() + { + } + [TestMethod] + public void Test_9891() + { + } + [TestMethod] + public void Test_9892() + { + } + [TestMethod] + public void Test_9893() + { + } + [TestMethod] + public void Test_9894() + { + } + [TestMethod] + public void Test_9895() + { + } + [TestMethod] + public void Test_9896() + { + } + [TestMethod] + public void Test_9897() + { + } + [TestMethod] + public void Test_9898() + { + } + [TestMethod] + public void Test_9899() + { + } + [TestMethod] + public void Test_9900() + { + } + [TestMethod] + public void Test_9901() + { + } + [TestMethod] + public void Test_9902() + { + } + [TestMethod] + public void Test_9903() + { + } + [TestMethod] + public void Test_9904() + { + } + [TestMethod] + public void Test_9905() + { + } + [TestMethod] + public void Test_9906() + { + } + [TestMethod] + public void Test_9907() + { + } + [TestMethod] + public void Test_9908() + { + } + [TestMethod] + public void Test_9909() + { + } + [TestMethod] + public void Test_9910() + { + } + [TestMethod] + public void Test_9911() + { + } + [TestMethod] + public void Test_9912() + { + } + [TestMethod] + public void Test_9913() + { + } + [TestMethod] + public void Test_9914() + { + } + [TestMethod] + public void Test_9915() + { + } + [TestMethod] + public void Test_9916() + { + } + [TestMethod] + public void Test_9917() + { + } + [TestMethod] + public void Test_9918() + { + } + [TestMethod] + public void Test_9919() + { + } + [TestMethod] + public void Test_9920() + { + } + [TestMethod] + public void Test_9921() + { + } + [TestMethod] + public void Test_9922() + { + } + [TestMethod] + public void Test_9923() + { + } + [TestMethod] + public void Test_9924() + { + } + [TestMethod] + public void Test_9925() + { + } + [TestMethod] + public void Test_9926() + { + } + [TestMethod] + public void Test_9927() + { + } + [TestMethod] + public void Test_9928() + { + } + [TestMethod] + public void Test_9929() + { + } + [TestMethod] + public void Test_9930() + { + } + [TestMethod] + public void Test_9931() + { + } + [TestMethod] + public void Test_9932() + { + } + [TestMethod] + public void Test_9933() + { + } + [TestMethod] + public void Test_9934() + { + } + [TestMethod] + public void Test_9935() + { + } + [TestMethod] + public void Test_9936() + { + } + [TestMethod] + public void Test_9937() + { + } + [TestMethod] + public void Test_9938() + { + } + [TestMethod] + public void Test_9939() + { + } + [TestMethod] + public void Test_9940() + { + } + [TestMethod] + public void Test_9941() + { + } + [TestMethod] + public void Test_9942() + { + } + [TestMethod] + public void Test_9943() + { + } + [TestMethod] + public void Test_9944() + { + } + [TestMethod] + public void Test_9945() + { + } + [TestMethod] + public void Test_9946() + { + } + [TestMethod] + public void Test_9947() + { + } + [TestMethod] + public void Test_9948() + { + } + [TestMethod] + public void Test_9949() + { + } + [TestMethod] + public void Test_9950() + { + } + [TestMethod] + public void Test_9951() + { + } + [TestMethod] + public void Test_9952() + { + } + [TestMethod] + public void Test_9953() + { + } + [TestMethod] + public void Test_9954() + { + } + [TestMethod] + public void Test_9955() + { + } + [TestMethod] + public void Test_9956() + { + } + [TestMethod] + public void Test_9957() + { + } + [TestMethod] + public void Test_9958() + { + } + [TestMethod] + public void Test_9959() + { + } + [TestMethod] + public void Test_9960() + { + } + [TestMethod] + public void Test_9961() + { + } + [TestMethod] + public void Test_9962() + { + } + [TestMethod] + public void Test_9963() + { + } + [TestMethod] + public void Test_9964() + { + } + [TestMethod] + public void Test_9965() + { + } + [TestMethod] + public void Test_9966() + { + } + [TestMethod] + public void Test_9967() + { + } + [TestMethod] + public void Test_9968() + { + } + [TestMethod] + public void Test_9969() + { + } + [TestMethod] + public void Test_9970() + { + } + [TestMethod] + public void Test_9971() + { + } + [TestMethod] + public void Test_9972() + { + } + [TestMethod] + public void Test_9973() + { + } + [TestMethod] + public void Test_9974() + { + } + [TestMethod] + public void Test_9975() + { + } + [TestMethod] + public void Test_9976() + { + } + [TestMethod] + public void Test_9977() + { + } + [TestMethod] + public void Test_9978() + { + } + [TestMethod] + public void Test_9979() + { + } + [TestMethod] + public void Test_9980() + { + } + [TestMethod] + public void Test_9981() + { + } + [TestMethod] + public void Test_9982() + { + } + [TestMethod] + public void Test_9983() + { + } + [TestMethod] + public void Test_9984() + { + } + [TestMethod] + public void Test_9985() + { + } + [TestMethod] + public void Test_9986() + { + } + [TestMethod] + public void Test_9987() + { + } + [TestMethod] + public void Test_9988() + { + } + [TestMethod] + public void Test_9989() + { + } + [TestMethod] + public void Test_9990() + { + } + [TestMethod] + public void Test_9991() + { + } + [TestMethod] + public void Test_9992() + { + } + [TestMethod] + public void Test_9993() + { + } + [TestMethod] + public void Test_9994() + { + } + [TestMethod] + public void Test_9995() + { + } + [TestMethod] + public void Test_9996() + { + } + [TestMethod] + public void Test_9997() + { + } + [TestMethod] + public void Test_9998() + { + } + [TestMethod] + public void Test_9999() + { + } + [TestMethod] + public void Test_10000() + { + } + #endregion + + #region FailingTests + #endregion - #region FailingTests - #endregion - } } diff --git a/test/TestAssets/PerfAssets/NUnitAdapterPerfTestProject/NunitTests.cs b/test/TestAssets/PerfAssets/NUnitAdapterPerfTestProject/NunitTests.cs index 0852d0bb7c..20e459b847 100644 --- a/test/TestAssets/PerfAssets/NUnitAdapterPerfTestProject/NunitTests.cs +++ b/test/TestAssets/PerfAssets/NUnitAdapterPerfTestProject/NunitTests.cs @@ -1,40017 +1,40018 @@ -using System; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + using NUnit.Framework; namespace NUnitAdapterPerfTests { - - public class NunitTests + public class NunitTests { - #region PassingTests - [Test] - public void Test_01() - { - } - [Test] - public void Test_02() - { - } - [Test] - public void Test_03() - { - } - [Test] - public void Test_04() - { - } - [Test] - public void Test_05() - { - } - [Test] - public void Test_06() - { - } - [Test] - public void Test_07() - { - } - [Test] - public void Test_08() - { - } - [Test] - public void Test_09() - { - } - [Test] - public void Test_10() - { - } - [Test] - public void Test_11() - { - } - [Test] - public void Test_12() - { - } - [Test] - public void Test_13() - { - } - [Test] - public void Test_14() - { - } - [Test] - public void Test_15() - { - } - [Test] - public void Test_16() - { - } - [Test] - public void Test_17() - { - } - [Test] - public void Test_18() - { - } - [Test] - public void Test_19() - { - } - [Test] - public void Test_20() - { - } - [Test] - public void Test_21() - { - } - [Test] - public void Test_22() - { - } - [Test] - public void Test_23() - { - } - [Test] - public void Test_24() - { - } - [Test] - public void Test_25() - { - } - [Test] - public void Test_26() - { - } - [Test] - public void Test_27() - { - } - [Test] - public void Test_28() - { - } - [Test] - public void Test_29() - { - } - [Test] - public void Test_30() - { - } - [Test] - public void Test_31() - { - } - [Test] - public void Test_32() - { - } - [Test] - public void Test_33() - { - } - [Test] - public void Test_34() - { - } - [Test] - public void Test_35() - { - } - [Test] - public void Test_36() - { - } - [Test] - public void Test_37() - { - } - [Test] - public void Test_38() - { - } - [Test] - public void Test_39() - { - } - [Test] - public void Test_40() - { - } - [Test] - public void Test_41() - { - } - [Test] - public void Test_42() - { - } - [Test] - public void Test_43() - { - } - [Test] - public void Test_44() - { - } - [Test] - public void Test_45() - { - } - [Test] - public void Test_46() - { - } - [Test] - public void Test_47() - { - } - [Test] - public void Test_48() - { - } - [Test] - public void Test_49() - { - } - [Test] - public void Test_50() - { - } - [Test] - public void Test_51() - { - } - [Test] - public void Test_52() - { - } - [Test] - public void Test_53() - { - } - [Test] - public void Test_54() - { - } - [Test] - public void Test_55() - { - } - [Test] - public void Test_56() - { - } - [Test] - public void Test_57() - { - } - [Test] - public void Test_58() - { - } - [Test] - public void Test_59() - { - } - [Test] - public void Test_60() - { - } - [Test] - public void Test_61() - { - } - [Test] - public void Test_62() - { - } - [Test] - public void Test_63() - { - } - [Test] - public void Test_64() - { - } - [Test] - public void Test_65() - { - } - [Test] - public void Test_66() - { - } - [Test] - public void Test_67() - { - } - [Test] - public void Test_68() - { - } - [Test] - public void Test_69() - { - } - [Test] - public void Test_70() - { - } - [Test] - public void Test_71() - { - } - [Test] - public void Test_72() - { - } - [Test] - public void Test_73() - { - } - [Test] - public void Test_74() - { - } - [Test] - public void Test_75() - { - } - [Test] - public void Test_76() - { - } - [Test] - public void Test_77() - { - } - [Test] - public void Test_78() - { - } - [Test] - public void Test_79() - { - } - [Test] - public void Test_80() - { - } - [Test] - public void Test_81() - { - } - [Test] - public void Test_82() - { - } - [Test] - public void Test_83() - { - } - [Test] - public void Test_84() - { - } - [Test] - public void Test_85() - { - } - [Test] - public void Test_86() - { - } - [Test] - public void Test_87() - { - } - [Test] - public void Test_88() - { - } - [Test] - public void Test_89() - { - } - [Test] - public void Test_90() - { - } - [Test] - public void Test_91() - { - } - [Test] - public void Test_92() - { - } - [Test] - public void Test_93() - { - } - [Test] - public void Test_94() - { - } - [Test] - public void Test_95() - { - } - [Test] - public void Test_96() - { - } - [Test] - public void Test_97() - { - } - [Test] - public void Test_98() - { - } - [Test] - public void Test_99() - { - } - [Test] - public void Test_100() - { - } - [Test] - public void Test_101() - { - } - [Test] - public void Test_102() - { - } - [Test] - public void Test_103() - { - } - [Test] - public void Test_104() - { - } - [Test] - public void Test_105() - { - } - [Test] - public void Test_106() - { - } - [Test] - public void Test_107() - { - } - [Test] - public void Test_108() - { - } - [Test] - public void Test_109() - { - } - [Test] - public void Test_110() - { - } - [Test] - public void Test_111() - { - } - [Test] - public void Test_112() - { - } - [Test] - public void Test_113() - { - } - [Test] - public void Test_114() - { - } - [Test] - public void Test_115() - { - } - [Test] - public void Test_116() - { - } - [Test] - public void Test_117() - { - } - [Test] - public void Test_118() - { - } - [Test] - public void Test_119() - { - } - [Test] - public void Test_120() - { - } - [Test] - public void Test_121() - { - } - [Test] - public void Test_122() - { - } - [Test] - public void Test_123() - { - } - [Test] - public void Test_124() - { - } - [Test] - public void Test_125() - { - } - [Test] - public void Test_126() - { - } - [Test] - public void Test_127() - { - } - [Test] - public void Test_128() - { - } - [Test] - public void Test_129() - { - } - [Test] - public void Test_130() - { - } - [Test] - public void Test_131() - { - } - [Test] - public void Test_132() - { - } - [Test] - public void Test_133() - { - } - [Test] - public void Test_134() - { - } - [Test] - public void Test_135() - { - } - [Test] - public void Test_136() - { - } - [Test] - public void Test_137() - { - } - [Test] - public void Test_138() - { - } - [Test] - public void Test_139() - { - } - [Test] - public void Test_140() - { - } - [Test] - public void Test_141() - { - } - [Test] - public void Test_142() - { - } - [Test] - public void Test_143() - { - } - [Test] - public void Test_144() - { - } - [Test] - public void Test_145() - { - } - [Test] - public void Test_146() - { - } - [Test] - public void Test_147() - { - } - [Test] - public void Test_148() - { - } - [Test] - public void Test_149() - { - } - [Test] - public void Test_150() - { - } - [Test] - public void Test_151() - { - } - [Test] - public void Test_152() - { - } - [Test] - public void Test_153() - { - } - [Test] - public void Test_154() - { - } - [Test] - public void Test_155() - { - } - [Test] - public void Test_156() - { - } - [Test] - public void Test_157() - { - } - [Test] - public void Test_158() - { - } - [Test] - public void Test_159() - { - } - [Test] - public void Test_160() - { - } - [Test] - public void Test_161() - { - } - [Test] - public void Test_162() - { - } - [Test] - public void Test_163() - { - } - [Test] - public void Test_164() - { - } - [Test] - public void Test_165() - { - } - [Test] - public void Test_166() - { - } - [Test] - public void Test_167() - { - } - [Test] - public void Test_168() - { - } - [Test] - public void Test_169() - { - } - [Test] - public void Test_170() - { - } - [Test] - public void Test_171() - { - } - [Test] - public void Test_172() - { - } - [Test] - public void Test_173() - { - } - [Test] - public void Test_174() - { - } - [Test] - public void Test_175() - { - } - [Test] - public void Test_176() - { - } - [Test] - public void Test_177() - { - } - [Test] - public void Test_178() - { - } - [Test] - public void Test_179() - { - } - [Test] - public void Test_180() - { - } - [Test] - public void Test_181() - { - } - [Test] - public void Test_182() - { - } - [Test] - public void Test_183() - { - } - [Test] - public void Test_184() - { - } - [Test] - public void Test_185() - { - } - [Test] - public void Test_186() - { - } - [Test] - public void Test_187() - { - } - [Test] - public void Test_188() - { - } - [Test] - public void Test_189() - { - } - [Test] - public void Test_190() - { - } - [Test] - public void Test_191() - { - } - [Test] - public void Test_192() - { - } - [Test] - public void Test_193() - { - } - [Test] - public void Test_194() - { - } - [Test] - public void Test_195() - { - } - [Test] - public void Test_196() - { - } - [Test] - public void Test_197() - { - } - [Test] - public void Test_198() - { - } - [Test] - public void Test_199() - { - } - [Test] - public void Test_200() - { - } - [Test] - public void Test_201() - { - } - [Test] - public void Test_202() - { - } - [Test] - public void Test_203() - { - } - [Test] - public void Test_204() - { - } - [Test] - public void Test_205() - { - } - [Test] - public void Test_206() - { - } - [Test] - public void Test_207() - { - } - [Test] - public void Test_208() - { - } - [Test] - public void Test_209() - { - } - [Test] - public void Test_210() - { - } - [Test] - public void Test_211() - { - } - [Test] - public void Test_212() - { - } - [Test] - public void Test_213() - { - } - [Test] - public void Test_214() - { - } - [Test] - public void Test_215() - { - } - [Test] - public void Test_216() - { - } - [Test] - public void Test_217() - { - } - [Test] - public void Test_218() - { - } - [Test] - public void Test_219() - { - } - [Test] - public void Test_220() - { - } - [Test] - public void Test_221() - { - } - [Test] - public void Test_222() - { - } - [Test] - public void Test_223() - { - } - [Test] - public void Test_224() - { - } - [Test] - public void Test_225() - { - } - [Test] - public void Test_226() - { - } - [Test] - public void Test_227() - { - } - [Test] - public void Test_228() - { - } - [Test] - public void Test_229() - { - } - [Test] - public void Test_230() - { - } - [Test] - public void Test_231() - { - } - [Test] - public void Test_232() - { - } - [Test] - public void Test_233() - { - } - [Test] - public void Test_234() - { - } - [Test] - public void Test_235() - { - } - [Test] - public void Test_236() - { - } - [Test] - public void Test_237() - { - } - [Test] - public void Test_238() - { - } - [Test] - public void Test_239() - { - } - [Test] - public void Test_240() - { - } - [Test] - public void Test_241() - { - } - [Test] - public void Test_242() - { - } - [Test] - public void Test_243() - { - } - [Test] - public void Test_244() - { - } - [Test] - public void Test_245() - { - } - [Test] - public void Test_246() - { - } - [Test] - public void Test_247() - { - } - [Test] - public void Test_248() - { - } - [Test] - public void Test_249() - { - } - [Test] - public void Test_250() - { - } - [Test] - public void Test_251() - { - } - [Test] - public void Test_252() - { - } - [Test] - public void Test_253() - { - } - [Test] - public void Test_254() - { - } - [Test] - public void Test_255() - { - } - [Test] - public void Test_256() - { - } - [Test] - public void Test_257() - { - } - [Test] - public void Test_258() - { - } - [Test] - public void Test_259() - { - } - [Test] - public void Test_260() - { - } - [Test] - public void Test_261() - { - } - [Test] - public void Test_262() - { - } - [Test] - public void Test_263() - { - } - [Test] - public void Test_264() - { - } - [Test] - public void Test_265() - { - } - [Test] - public void Test_266() - { - } - [Test] - public void Test_267() - { - } - [Test] - public void Test_268() - { - } - [Test] - public void Test_269() - { - } - [Test] - public void Test_270() - { - } - [Test] - public void Test_271() - { - } - [Test] - public void Test_272() - { - } - [Test] - public void Test_273() - { - } - [Test] - public void Test_274() - { - } - [Test] - public void Test_275() - { - } - [Test] - public void Test_276() - { - } - [Test] - public void Test_277() - { - } - [Test] - public void Test_278() - { - } - [Test] - public void Test_279() - { - } - [Test] - public void Test_280() - { - } - [Test] - public void Test_281() - { - } - [Test] - public void Test_282() - { - } - [Test] - public void Test_283() - { - } - [Test] - public void Test_284() - { - } - [Test] - public void Test_285() - { - } - [Test] - public void Test_286() - { - } - [Test] - public void Test_287() - { - } - [Test] - public void Test_288() - { - } - [Test] - public void Test_289() - { - } - [Test] - public void Test_290() - { - } - [Test] - public void Test_291() - { - } - [Test] - public void Test_292() - { - } - [Test] - public void Test_293() - { - } - [Test] - public void Test_294() - { - } - [Test] - public void Test_295() - { - } - [Test] - public void Test_296() - { - } - [Test] - public void Test_297() - { - } - [Test] - public void Test_298() - { - } - [Test] - public void Test_299() - { - } - [Test] - public void Test_300() - { - } - [Test] - public void Test_301() - { - } - [Test] - public void Test_302() - { - } - [Test] - public void Test_303() - { - } - [Test] - public void Test_304() - { - } - [Test] - public void Test_305() - { - } - [Test] - public void Test_306() - { - } - [Test] - public void Test_307() - { - } - [Test] - public void Test_308() - { - } - [Test] - public void Test_309() - { - } - [Test] - public void Test_310() - { - } - [Test] - public void Test_311() - { - } - [Test] - public void Test_312() - { - } - [Test] - public void Test_313() - { - } - [Test] - public void Test_314() - { - } - [Test] - public void Test_315() - { - } - [Test] - public void Test_316() - { - } - [Test] - public void Test_317() - { - } - [Test] - public void Test_318() - { - } - [Test] - public void Test_319() - { - } - [Test] - public void Test_320() - { - } - [Test] - public void Test_321() - { - } - [Test] - public void Test_322() - { - } - [Test] - public void Test_323() - { - } - [Test] - public void Test_324() - { - } - [Test] - public void Test_325() - { - } - [Test] - public void Test_326() - { - } - [Test] - public void Test_327() - { - } - [Test] - public void Test_328() - { - } - [Test] - public void Test_329() - { - } - [Test] - public void Test_330() - { - } - [Test] - public void Test_331() - { - } - [Test] - public void Test_332() - { - } - [Test] - public void Test_333() - { - } - [Test] - public void Test_334() - { - } - [Test] - public void Test_335() - { - } - [Test] - public void Test_336() - { - } - [Test] - public void Test_337() - { - } - [Test] - public void Test_338() - { - } - [Test] - public void Test_339() - { - } - [Test] - public void Test_340() - { - } - [Test] - public void Test_341() - { - } - [Test] - public void Test_342() - { - } - [Test] - public void Test_343() - { - } - [Test] - public void Test_344() - { - } - [Test] - public void Test_345() - { - } - [Test] - public void Test_346() - { - } - [Test] - public void Test_347() - { - } - [Test] - public void Test_348() - { - } - [Test] - public void Test_349() - { - } - [Test] - public void Test_350() - { - } - [Test] - public void Test_351() - { - } - [Test] - public void Test_352() - { - } - [Test] - public void Test_353() - { - } - [Test] - public void Test_354() - { - } - [Test] - public void Test_355() - { - } - [Test] - public void Test_356() - { - } - [Test] - public void Test_357() - { - } - [Test] - public void Test_358() - { - } - [Test] - public void Test_359() - { - } - [Test] - public void Test_360() - { - } - [Test] - public void Test_361() - { - } - [Test] - public void Test_362() - { - } - [Test] - public void Test_363() - { - } - [Test] - public void Test_364() - { - } - [Test] - public void Test_365() - { - } - [Test] - public void Test_366() - { - } - [Test] - public void Test_367() - { - } - [Test] - public void Test_368() - { - } - [Test] - public void Test_369() - { - } - [Test] - public void Test_370() - { - } - [Test] - public void Test_371() - { - } - [Test] - public void Test_372() - { - } - [Test] - public void Test_373() - { - } - [Test] - public void Test_374() - { - } - [Test] - public void Test_375() - { - } - [Test] - public void Test_376() - { - } - [Test] - public void Test_377() - { - } - [Test] - public void Test_378() - { - } - [Test] - public void Test_379() - { - } - [Test] - public void Test_380() - { - } - [Test] - public void Test_381() - { - } - [Test] - public void Test_382() - { - } - [Test] - public void Test_383() - { - } - [Test] - public void Test_384() - { - } - [Test] - public void Test_385() - { - } - [Test] - public void Test_386() - { - } - [Test] - public void Test_387() - { - } - [Test] - public void Test_388() - { - } - [Test] - public void Test_389() - { - } - [Test] - public void Test_390() - { - } - [Test] - public void Test_391() - { - } - [Test] - public void Test_392() - { - } - [Test] - public void Test_393() - { - } - [Test] - public void Test_394() - { - } - [Test] - public void Test_395() - { - } - [Test] - public void Test_396() - { - } - [Test] - public void Test_397() - { - } - [Test] - public void Test_398() - { - } - [Test] - public void Test_399() - { - } - [Test] - public void Test_400() - { - } - [Test] - public void Test_401() - { - } - [Test] - public void Test_402() - { - } - [Test] - public void Test_403() - { - } - [Test] - public void Test_404() - { - } - [Test] - public void Test_405() - { - } - [Test] - public void Test_406() - { - } - [Test] - public void Test_407() - { - } - [Test] - public void Test_408() - { - } - [Test] - public void Test_409() - { - } - [Test] - public void Test_410() - { - } - [Test] - public void Test_411() - { - } - [Test] - public void Test_412() - { - } - [Test] - public void Test_413() - { - } - [Test] - public void Test_414() - { - } - [Test] - public void Test_415() - { - } - [Test] - public void Test_416() - { - } - [Test] - public void Test_417() - { - } - [Test] - public void Test_418() - { - } - [Test] - public void Test_419() - { - } - [Test] - public void Test_420() - { - } - [Test] - public void Test_421() - { - } - [Test] - public void Test_422() - { - } - [Test] - public void Test_423() - { - } - [Test] - public void Test_424() - { - } - [Test] - public void Test_425() - { - } - [Test] - public void Test_426() - { - } - [Test] - public void Test_427() - { - } - [Test] - public void Test_428() - { - } - [Test] - public void Test_429() - { - } - [Test] - public void Test_430() - { - } - [Test] - public void Test_431() - { - } - [Test] - public void Test_432() - { - } - [Test] - public void Test_433() - { - } - [Test] - public void Test_434() - { - } - [Test] - public void Test_435() - { - } - [Test] - public void Test_436() - { - } - [Test] - public void Test_437() - { - } - [Test] - public void Test_438() - { - } - [Test] - public void Test_439() - { - } - [Test] - public void Test_440() - { - } - [Test] - public void Test_441() - { - } - [Test] - public void Test_442() - { - } - [Test] - public void Test_443() - { - } - [Test] - public void Test_444() - { - } - [Test] - public void Test_445() - { - } - [Test] - public void Test_446() - { - } - [Test] - public void Test_447() - { - } - [Test] - public void Test_448() - { - } - [Test] - public void Test_449() - { - } - [Test] - public void Test_450() - { - } - [Test] - public void Test_451() - { - } - [Test] - public void Test_452() - { - } - [Test] - public void Test_453() - { - } - [Test] - public void Test_454() - { - } - [Test] - public void Test_455() - { - } - [Test] - public void Test_456() - { - } - [Test] - public void Test_457() - { - } - [Test] - public void Test_458() - { - } - [Test] - public void Test_459() - { - } - [Test] - public void Test_460() - { - } - [Test] - public void Test_461() - { - } - [Test] - public void Test_462() - { - } - [Test] - public void Test_463() - { - } - [Test] - public void Test_464() - { - } - [Test] - public void Test_465() - { - } - [Test] - public void Test_466() - { - } - [Test] - public void Test_467() - { - } - [Test] - public void Test_468() - { - } - [Test] - public void Test_469() - { - } - [Test] - public void Test_470() - { - } - [Test] - public void Test_471() - { - } - [Test] - public void Test_472() - { - } - [Test] - public void Test_473() - { - } - [Test] - public void Test_474() - { - } - [Test] - public void Test_475() - { - } - [Test] - public void Test_476() - { - } - [Test] - public void Test_477() - { - } - [Test] - public void Test_478() - { - } - [Test] - public void Test_479() - { - } - [Test] - public void Test_480() - { - } - [Test] - public void Test_481() - { - } - [Test] - public void Test_482() - { - } - [Test] - public void Test_483() - { - } - [Test] - public void Test_484() - { - } - [Test] - public void Test_485() - { - } - [Test] - public void Test_486() - { - } - [Test] - public void Test_487() - { - } - [Test] - public void Test_488() - { - } - [Test] - public void Test_489() - { - } - [Test] - public void Test_490() - { - } - [Test] - public void Test_491() - { - } - [Test] - public void Test_492() - { - } - [Test] - public void Test_493() - { - } - [Test] - public void Test_494() - { - } - [Test] - public void Test_495() - { - } - [Test] - public void Test_496() - { - } - [Test] - public void Test_497() - { - } - [Test] - public void Test_498() - { - } - [Test] - public void Test_499() - { - } - [Test] - public void Test_500() - { - } - [Test] - public void Test_501() - { - } - [Test] - public void Test_502() - { - } - [Test] - public void Test_503() - { - } - [Test] - public void Test_504() - { - } - [Test] - public void Test_505() - { - } - [Test] - public void Test_506() - { - } - [Test] - public void Test_507() - { - } - [Test] - public void Test_508() - { - } - [Test] - public void Test_509() - { - } - [Test] - public void Test_510() - { - } - [Test] - public void Test_511() - { - } - [Test] - public void Test_512() - { - } - [Test] - public void Test_513() - { - } - [Test] - public void Test_514() - { - } - [Test] - public void Test_515() - { - } - [Test] - public void Test_516() - { - } - [Test] - public void Test_517() - { - } - [Test] - public void Test_518() - { - } - [Test] - public void Test_519() - { - } - [Test] - public void Test_520() - { - } - [Test] - public void Test_521() - { - } - [Test] - public void Test_522() - { - } - [Test] - public void Test_523() - { - } - [Test] - public void Test_524() - { - } - [Test] - public void Test_525() - { - } - [Test] - public void Test_526() - { - } - [Test] - public void Test_527() - { - } - [Test] - public void Test_528() - { - } - [Test] - public void Test_529() - { - } - [Test] - public void Test_530() - { - } - [Test] - public void Test_531() - { - } - [Test] - public void Test_532() - { - } - [Test] - public void Test_533() - { - } - [Test] - public void Test_534() - { - } - [Test] - public void Test_535() - { - } - [Test] - public void Test_536() - { - } - [Test] - public void Test_537() - { - } - [Test] - public void Test_538() - { - } - [Test] - public void Test_539() - { - } - [Test] - public void Test_540() - { - } - [Test] - public void Test_541() - { - } - [Test] - public void Test_542() - { - } - [Test] - public void Test_543() - { - } - [Test] - public void Test_544() - { - } - [Test] - public void Test_545() - { - } - [Test] - public void Test_546() - { - } - [Test] - public void Test_547() - { - } - [Test] - public void Test_548() - { - } - [Test] - public void Test_549() - { - } - [Test] - public void Test_550() - { - } - [Test] - public void Test_551() - { - } - [Test] - public void Test_552() - { - } - [Test] - public void Test_553() - { - } - [Test] - public void Test_554() - { - } - [Test] - public void Test_555() - { - } - [Test] - public void Test_556() - { - } - [Test] - public void Test_557() - { - } - [Test] - public void Test_558() - { - } - [Test] - public void Test_559() - { - } - [Test] - public void Test_560() - { - } - [Test] - public void Test_561() - { - } - [Test] - public void Test_562() - { - } - [Test] - public void Test_563() - { - } - [Test] - public void Test_564() - { - } - [Test] - public void Test_565() - { - } - [Test] - public void Test_566() - { - } - [Test] - public void Test_567() - { - } - [Test] - public void Test_568() - { - } - [Test] - public void Test_569() - { - } - [Test] - public void Test_570() - { - } - [Test] - public void Test_571() - { - } - [Test] - public void Test_572() - { - } - [Test] - public void Test_573() - { - } - [Test] - public void Test_574() - { - } - [Test] - public void Test_575() - { - } - [Test] - public void Test_576() - { - } - [Test] - public void Test_577() - { - } - [Test] - public void Test_578() - { - } - [Test] - public void Test_579() - { - } - [Test] - public void Test_580() - { - } - [Test] - public void Test_581() - { - } - [Test] - public void Test_582() - { - } - [Test] - public void Test_583() - { - } - [Test] - public void Test_584() - { - } - [Test] - public void Test_585() - { - } - [Test] - public void Test_586() - { - } - [Test] - public void Test_587() - { - } - [Test] - public void Test_588() - { - } - [Test] - public void Test_589() - { - } - [Test] - public void Test_590() - { - } - [Test] - public void Test_591() - { - } - [Test] - public void Test_592() - { - } - [Test] - public void Test_593() - { - } - [Test] - public void Test_594() - { - } - [Test] - public void Test_595() - { - } - [Test] - public void Test_596() - { - } - [Test] - public void Test_597() - { - } - [Test] - public void Test_598() - { - } - [Test] - public void Test_599() - { - } - [Test] - public void Test_600() - { - } - [Test] - public void Test_601() - { - } - [Test] - public void Test_602() - { - } - [Test] - public void Test_603() - { - } - [Test] - public void Test_604() - { - } - [Test] - public void Test_605() - { - } - [Test] - public void Test_606() - { - } - [Test] - public void Test_607() - { - } - [Test] - public void Test_608() - { - } - [Test] - public void Test_609() - { - } - [Test] - public void Test_610() - { - } - [Test] - public void Test_611() - { - } - [Test] - public void Test_612() - { - } - [Test] - public void Test_613() - { - } - [Test] - public void Test_614() - { - } - [Test] - public void Test_615() - { - } - [Test] - public void Test_616() - { - } - [Test] - public void Test_617() - { - } - [Test] - public void Test_618() - { - } - [Test] - public void Test_619() - { - } - [Test] - public void Test_620() - { - } - [Test] - public void Test_621() - { - } - [Test] - public void Test_622() - { - } - [Test] - public void Test_623() - { - } - [Test] - public void Test_624() - { - } - [Test] - public void Test_625() - { - } - [Test] - public void Test_626() - { - } - [Test] - public void Test_627() - { - } - [Test] - public void Test_628() - { - } - [Test] - public void Test_629() - { - } - [Test] - public void Test_630() - { - } - [Test] - public void Test_631() - { - } - [Test] - public void Test_632() - { - } - [Test] - public void Test_633() - { - } - [Test] - public void Test_634() - { - } - [Test] - public void Test_635() - { - } - [Test] - public void Test_636() - { - } - [Test] - public void Test_637() - { - } - [Test] - public void Test_638() - { - } - [Test] - public void Test_639() - { - } - [Test] - public void Test_640() - { - } - [Test] - public void Test_641() - { - } - [Test] - public void Test_642() - { - } - [Test] - public void Test_643() - { - } - [Test] - public void Test_644() - { - } - [Test] - public void Test_645() - { - } - [Test] - public void Test_646() - { - } - [Test] - public void Test_647() - { - } - [Test] - public void Test_648() - { - } - [Test] - public void Test_649() - { - } - [Test] - public void Test_650() - { - } - [Test] - public void Test_651() - { - } - [Test] - public void Test_652() - { - } - [Test] - public void Test_653() - { - } - [Test] - public void Test_654() - { - } - [Test] - public void Test_655() - { - } - [Test] - public void Test_656() - { - } - [Test] - public void Test_657() - { - } - [Test] - public void Test_658() - { - } - [Test] - public void Test_659() - { - } - [Test] - public void Test_660() - { - } - [Test] - public void Test_661() - { - } - [Test] - public void Test_662() - { - } - [Test] - public void Test_663() - { - } - [Test] - public void Test_664() - { - } - [Test] - public void Test_665() - { - } - [Test] - public void Test_666() - { - } - [Test] - public void Test_667() - { - } - [Test] - public void Test_668() - { - } - [Test] - public void Test_669() - { - } - [Test] - public void Test_670() - { - } - [Test] - public void Test_671() - { - } - [Test] - public void Test_672() - { - } - [Test] - public void Test_673() - { - } - [Test] - public void Test_674() - { - } - [Test] - public void Test_675() - { - } - [Test] - public void Test_676() - { - } - [Test] - public void Test_677() - { - } - [Test] - public void Test_678() - { - } - [Test] - public void Test_679() - { - } - [Test] - public void Test_680() - { - } - [Test] - public void Test_681() - { - } - [Test] - public void Test_682() - { - } - [Test] - public void Test_683() - { - } - [Test] - public void Test_684() - { - } - [Test] - public void Test_685() - { - } - [Test] - public void Test_686() - { - } - [Test] - public void Test_687() - { - } - [Test] - public void Test_688() - { - } - [Test] - public void Test_689() - { - } - [Test] - public void Test_690() - { - } - [Test] - public void Test_691() - { - } - [Test] - public void Test_692() - { - } - [Test] - public void Test_693() - { - } - [Test] - public void Test_694() - { - } - [Test] - public void Test_695() - { - } - [Test] - public void Test_696() - { - } - [Test] - public void Test_697() - { - } - [Test] - public void Test_698() - { - } - [Test] - public void Test_699() - { - } - [Test] - public void Test_700() - { - } - [Test] - public void Test_701() - { - } - [Test] - public void Test_702() - { - } - [Test] - public void Test_703() - { - } - [Test] - public void Test_704() - { - } - [Test] - public void Test_705() - { - } - [Test] - public void Test_706() - { - } - [Test] - public void Test_707() - { - } - [Test] - public void Test_708() - { - } - [Test] - public void Test_709() - { - } - [Test] - public void Test_710() - { - } - [Test] - public void Test_711() - { - } - [Test] - public void Test_712() - { - } - [Test] - public void Test_713() - { - } - [Test] - public void Test_714() - { - } - [Test] - public void Test_715() - { - } - [Test] - public void Test_716() - { - } - [Test] - public void Test_717() - { - } - [Test] - public void Test_718() - { - } - [Test] - public void Test_719() - { - } - [Test] - public void Test_720() - { - } - [Test] - public void Test_721() - { - } - [Test] - public void Test_722() - { - } - [Test] - public void Test_723() - { - } - [Test] - public void Test_724() - { - } - [Test] - public void Test_725() - { - } - [Test] - public void Test_726() - { - } - [Test] - public void Test_727() - { - } - [Test] - public void Test_728() - { - } - [Test] - public void Test_729() - { - } - [Test] - public void Test_730() - { - } - [Test] - public void Test_731() - { - } - [Test] - public void Test_732() - { - } - [Test] - public void Test_733() - { - } - [Test] - public void Test_734() - { - } - [Test] - public void Test_735() - { - } - [Test] - public void Test_736() - { - } - [Test] - public void Test_737() - { - } - [Test] - public void Test_738() - { - } - [Test] - public void Test_739() - { - } - [Test] - public void Test_740() - { - } - [Test] - public void Test_741() - { - } - [Test] - public void Test_742() - { - } - [Test] - public void Test_743() - { - } - [Test] - public void Test_744() - { - } - [Test] - public void Test_745() - { - } - [Test] - public void Test_746() - { - } - [Test] - public void Test_747() - { - } - [Test] - public void Test_748() - { - } - [Test] - public void Test_749() - { - } - [Test] - public void Test_750() - { - } - [Test] - public void Test_751() - { - } - [Test] - public void Test_752() - { - } - [Test] - public void Test_753() - { - } - [Test] - public void Test_754() - { - } - [Test] - public void Test_755() - { - } - [Test] - public void Test_756() - { - } - [Test] - public void Test_757() - { - } - [Test] - public void Test_758() - { - } - [Test] - public void Test_759() - { - } - [Test] - public void Test_760() - { - } - [Test] - public void Test_761() - { - } - [Test] - public void Test_762() - { - } - [Test] - public void Test_763() - { - } - [Test] - public void Test_764() - { - } - [Test] - public void Test_765() - { - } - [Test] - public void Test_766() - { - } - [Test] - public void Test_767() - { - } - [Test] - public void Test_768() - { - } - [Test] - public void Test_769() - { - } - [Test] - public void Test_770() - { - } - [Test] - public void Test_771() - { - } - [Test] - public void Test_772() - { - } - [Test] - public void Test_773() - { - } - [Test] - public void Test_774() - { - } - [Test] - public void Test_775() - { - } - [Test] - public void Test_776() - { - } - [Test] - public void Test_777() - { - } - [Test] - public void Test_778() - { - } - [Test] - public void Test_779() - { - } - [Test] - public void Test_780() - { - } - [Test] - public void Test_781() - { - } - [Test] - public void Test_782() - { - } - [Test] - public void Test_783() - { - } - [Test] - public void Test_784() - { - } - [Test] - public void Test_785() - { - } - [Test] - public void Test_786() - { - } - [Test] - public void Test_787() - { - } - [Test] - public void Test_788() - { - } - [Test] - public void Test_789() - { - } - [Test] - public void Test_790() - { - } - [Test] - public void Test_791() - { - } - [Test] - public void Test_792() - { - } - [Test] - public void Test_793() - { - } - [Test] - public void Test_794() - { - } - [Test] - public void Test_795() - { - } - [Test] - public void Test_796() - { - } - [Test] - public void Test_797() - { - } - [Test] - public void Test_798() - { - } - [Test] - public void Test_799() - { - } - [Test] - public void Test_800() - { - } - [Test] - public void Test_801() - { - } - [Test] - public void Test_802() - { - } - [Test] - public void Test_803() - { - } - [Test] - public void Test_804() - { - } - [Test] - public void Test_805() - { - } - [Test] - public void Test_806() - { - } - [Test] - public void Test_807() - { - } - [Test] - public void Test_808() - { - } - [Test] - public void Test_809() - { - } - [Test] - public void Test_810() - { - } - [Test] - public void Test_811() - { - } - [Test] - public void Test_812() - { - } - [Test] - public void Test_813() - { - } - [Test] - public void Test_814() - { - } - [Test] - public void Test_815() - { - } - [Test] - public void Test_816() - { - } - [Test] - public void Test_817() - { - } - [Test] - public void Test_818() - { - } - [Test] - public void Test_819() - { - } - [Test] - public void Test_820() - { - } - [Test] - public void Test_821() - { - } - [Test] - public void Test_822() - { - } - [Test] - public void Test_823() - { - } - [Test] - public void Test_824() - { - } - [Test] - public void Test_825() - { - } - [Test] - public void Test_826() - { - } - [Test] - public void Test_827() - { - } - [Test] - public void Test_828() - { - } - [Test] - public void Test_829() - { - } - [Test] - public void Test_830() - { - } - [Test] - public void Test_831() - { - } - [Test] - public void Test_832() - { - } - [Test] - public void Test_833() - { - } - [Test] - public void Test_834() - { - } - [Test] - public void Test_835() - { - } - [Test] - public void Test_836() - { - } - [Test] - public void Test_837() - { - } - [Test] - public void Test_838() - { - } - [Test] - public void Test_839() - { - } - [Test] - public void Test_840() - { - } - [Test] - public void Test_841() - { - } - [Test] - public void Test_842() - { - } - [Test] - public void Test_843() - { - } - [Test] - public void Test_844() - { - } - [Test] - public void Test_845() - { - } - [Test] - public void Test_846() - { - } - [Test] - public void Test_847() - { - } - [Test] - public void Test_848() - { - } - [Test] - public void Test_849() - { - } - [Test] - public void Test_850() - { - } - [Test] - public void Test_851() - { - } - [Test] - public void Test_852() - { - } - [Test] - public void Test_853() - { - } - [Test] - public void Test_854() - { - } - [Test] - public void Test_855() - { - } - [Test] - public void Test_856() - { - } - [Test] - public void Test_857() - { - } - [Test] - public void Test_858() - { - } - [Test] - public void Test_859() - { - } - [Test] - public void Test_860() - { - } - [Test] - public void Test_861() - { - } - [Test] - public void Test_862() - { - } - [Test] - public void Test_863() - { - } - [Test] - public void Test_864() - { - } - [Test] - public void Test_865() - { - } - [Test] - public void Test_866() - { - } - [Test] - public void Test_867() - { - } - [Test] - public void Test_868() - { - } - [Test] - public void Test_869() - { - } - [Test] - public void Test_870() - { - } - [Test] - public void Test_871() - { - } - [Test] - public void Test_872() - { - } - [Test] - public void Test_873() - { - } - [Test] - public void Test_874() - { - } - [Test] - public void Test_875() - { - } - [Test] - public void Test_876() - { - } - [Test] - public void Test_877() - { - } - [Test] - public void Test_878() - { - } - [Test] - public void Test_879() - { - } - [Test] - public void Test_880() - { - } - [Test] - public void Test_881() - { - } - [Test] - public void Test_882() - { - } - [Test] - public void Test_883() - { - } - [Test] - public void Test_884() - { - } - [Test] - public void Test_885() - { - } - [Test] - public void Test_886() - { - } - [Test] - public void Test_887() - { - } - [Test] - public void Test_888() - { - } - [Test] - public void Test_889() - { - } - [Test] - public void Test_890() - { - } - [Test] - public void Test_891() - { - } - [Test] - public void Test_892() - { - } - [Test] - public void Test_893() - { - } - [Test] - public void Test_894() - { - } - [Test] - public void Test_895() - { - } - [Test] - public void Test_896() - { - } - [Test] - public void Test_897() - { - } - [Test] - public void Test_898() - { - } - [Test] - public void Test_899() - { - } - [Test] - public void Test_900() - { - } - [Test] - public void Test_901() - { - } - [Test] - public void Test_902() - { - } - [Test] - public void Test_903() - { - } - [Test] - public void Test_904() - { - } - [Test] - public void Test_905() - { - } - [Test] - public void Test_906() - { - } - [Test] - public void Test_907() - { - } - [Test] - public void Test_908() - { - } - [Test] - public void Test_909() - { - } - [Test] - public void Test_910() - { - } - [Test] - public void Test_911() - { - } - [Test] - public void Test_912() - { - } - [Test] - public void Test_913() - { - } - [Test] - public void Test_914() - { - } - [Test] - public void Test_915() - { - } - [Test] - public void Test_916() - { - } - [Test] - public void Test_917() - { - } - [Test] - public void Test_918() - { - } - [Test] - public void Test_919() - { - } - [Test] - public void Test_920() - { - } - [Test] - public void Test_921() - { - } - [Test] - public void Test_922() - { - } - [Test] - public void Test_923() - { - } - [Test] - public void Test_924() - { - } - [Test] - public void Test_925() - { - } - [Test] - public void Test_926() - { - } - [Test] - public void Test_927() - { - } - [Test] - public void Test_928() - { - } - [Test] - public void Test_929() - { - } - [Test] - public void Test_930() - { - } - [Test] - public void Test_931() - { - } - [Test] - public void Test_932() - { - } - [Test] - public void Test_933() - { - } - [Test] - public void Test_934() - { - } - [Test] - public void Test_935() - { - } - [Test] - public void Test_936() - { - } - [Test] - public void Test_937() - { - } - [Test] - public void Test_938() - { - } - [Test] - public void Test_939() - { - } - [Test] - public void Test_940() - { - } - [Test] - public void Test_941() - { - } - [Test] - public void Test_942() - { - } - [Test] - public void Test_943() - { - } - [Test] - public void Test_944() - { - } - [Test] - public void Test_945() - { - } - [Test] - public void Test_946() - { - } - [Test] - public void Test_947() - { - } - [Test] - public void Test_948() - { - } - [Test] - public void Test_949() - { - } - [Test] - public void Test_950() - { - } - [Test] - public void Test_951() - { - } - [Test] - public void Test_952() - { - } - [Test] - public void Test_953() - { - } - [Test] - public void Test_954() - { - } - [Test] - public void Test_955() - { - } - [Test] - public void Test_956() - { - } - [Test] - public void Test_957() - { - } - [Test] - public void Test_958() - { - } - [Test] - public void Test_959() - { - } - [Test] - public void Test_960() - { - } - [Test] - public void Test_961() - { - } - [Test] - public void Test_962() - { - } - [Test] - public void Test_963() - { - } - [Test] - public void Test_964() - { - } - [Test] - public void Test_965() - { - } - [Test] - public void Test_966() - { - } - [Test] - public void Test_967() - { - } - [Test] - public void Test_968() - { - } - [Test] - public void Test_969() - { - } - [Test] - public void Test_970() - { - } - [Test] - public void Test_971() - { - } - [Test] - public void Test_972() - { - } - [Test] - public void Test_973() - { - } - [Test] - public void Test_974() - { - } - [Test] - public void Test_975() - { - } - [Test] - public void Test_976() - { - } - [Test] - public void Test_977() - { - } - [Test] - public void Test_978() - { - } - [Test] - public void Test_979() - { - } - [Test] - public void Test_980() - { - } - [Test] - public void Test_981() - { - } - [Test] - public void Test_982() - { - } - [Test] - public void Test_983() - { - } - [Test] - public void Test_984() - { - } - [Test] - public void Test_985() - { - } - [Test] - public void Test_986() - { - } - [Test] - public void Test_987() - { - } - [Test] - public void Test_988() - { - } - [Test] - public void Test_989() - { - } - [Test] - public void Test_990() - { - } - [Test] - public void Test_991() - { - } - [Test] - public void Test_992() - { - } - [Test] - public void Test_993() - { - } - [Test] - public void Test_994() - { - } - [Test] - public void Test_995() - { - } - [Test] - public void Test_996() - { - } - [Test] - public void Test_997() - { - } - [Test] - public void Test_998() - { - } - [Test] - public void Test_999() - { - } - [Test] - public void Test_1000() - { - } - [Test] - public void Test_1001() - { - } - [Test] - public void Test_1002() - { - } - [Test] - public void Test_1003() - { - } - [Test] - public void Test_1004() - { - } - [Test] - public void Test_1005() - { - } - [Test] - public void Test_1006() - { - } - [Test] - public void Test_1007() - { - } - [Test] - public void Test_1008() - { - } - [Test] - public void Test_1009() - { - } - [Test] - public void Test_1010() - { - } - [Test] - public void Test_1011() - { - } - [Test] - public void Test_1012() - { - } - [Test] - public void Test_1013() - { - } - [Test] - public void Test_1014() - { - } - [Test] - public void Test_1015() - { - } - [Test] - public void Test_1016() - { - } - [Test] - public void Test_1017() - { - } - [Test] - public void Test_1018() - { - } - [Test] - public void Test_1019() - { - } - [Test] - public void Test_1020() - { - } - [Test] - public void Test_1021() - { - } - [Test] - public void Test_1022() - { - } - [Test] - public void Test_1023() - { - } - [Test] - public void Test_1024() - { - } - [Test] - public void Test_1025() - { - } - [Test] - public void Test_1026() - { - } - [Test] - public void Test_1027() - { - } - [Test] - public void Test_1028() - { - } - [Test] - public void Test_1029() - { - } - [Test] - public void Test_1030() - { - } - [Test] - public void Test_1031() - { - } - [Test] - public void Test_1032() - { - } - [Test] - public void Test_1033() - { - } - [Test] - public void Test_1034() - { - } - [Test] - public void Test_1035() - { - } - [Test] - public void Test_1036() - { - } - [Test] - public void Test_1037() - { - } - [Test] - public void Test_1038() - { - } - [Test] - public void Test_1039() - { - } - [Test] - public void Test_1040() - { - } - [Test] - public void Test_1041() - { - } - [Test] - public void Test_1042() - { - } - [Test] - public void Test_1043() - { - } - [Test] - public void Test_1044() - { - } - [Test] - public void Test_1045() - { - } - [Test] - public void Test_1046() - { - } - [Test] - public void Test_1047() - { - } - [Test] - public void Test_1048() - { - } - [Test] - public void Test_1049() - { - } - [Test] - public void Test_1050() - { - } - [Test] - public void Test_1051() - { - } - [Test] - public void Test_1052() - { - } - [Test] - public void Test_1053() - { - } - [Test] - public void Test_1054() - { - } - [Test] - public void Test_1055() - { - } - [Test] - public void Test_1056() - { - } - [Test] - public void Test_1057() - { - } - [Test] - public void Test_1058() - { - } - [Test] - public void Test_1059() - { - } - [Test] - public void Test_1060() - { - } - [Test] - public void Test_1061() - { - } - [Test] - public void Test_1062() - { - } - [Test] - public void Test_1063() - { - } - [Test] - public void Test_1064() - { - } - [Test] - public void Test_1065() - { - } - [Test] - public void Test_1066() - { - } - [Test] - public void Test_1067() - { - } - [Test] - public void Test_1068() - { - } - [Test] - public void Test_1069() - { - } - [Test] - public void Test_1070() - { - } - [Test] - public void Test_1071() - { - } - [Test] - public void Test_1072() - { - } - [Test] - public void Test_1073() - { - } - [Test] - public void Test_1074() - { - } - [Test] - public void Test_1075() - { - } - [Test] - public void Test_1076() - { - } - [Test] - public void Test_1077() - { - } - [Test] - public void Test_1078() - { - } - [Test] - public void Test_1079() - { - } - [Test] - public void Test_1080() - { - } - [Test] - public void Test_1081() - { - } - [Test] - public void Test_1082() - { - } - [Test] - public void Test_1083() - { - } - [Test] - public void Test_1084() - { - } - [Test] - public void Test_1085() - { - } - [Test] - public void Test_1086() - { - } - [Test] - public void Test_1087() - { - } - [Test] - public void Test_1088() - { - } - [Test] - public void Test_1089() - { - } - [Test] - public void Test_1090() - { - } - [Test] - public void Test_1091() - { - } - [Test] - public void Test_1092() - { - } - [Test] - public void Test_1093() - { - } - [Test] - public void Test_1094() - { - } - [Test] - public void Test_1095() - { - } - [Test] - public void Test_1096() - { - } - [Test] - public void Test_1097() - { - } - [Test] - public void Test_1098() - { - } - [Test] - public void Test_1099() - { - } - [Test] - public void Test_1100() - { - } - [Test] - public void Test_1101() - { - } - [Test] - public void Test_1102() - { - } - [Test] - public void Test_1103() - { - } - [Test] - public void Test_1104() - { - } - [Test] - public void Test_1105() - { - } - [Test] - public void Test_1106() - { - } - [Test] - public void Test_1107() - { - } - [Test] - public void Test_1108() - { - } - [Test] - public void Test_1109() - { - } - [Test] - public void Test_1110() - { - } - [Test] - public void Test_1111() - { - } - [Test] - public void Test_1112() - { - } - [Test] - public void Test_1113() - { - } - [Test] - public void Test_1114() - { - } - [Test] - public void Test_1115() - { - } - [Test] - public void Test_1116() - { - } - [Test] - public void Test_1117() - { - } - [Test] - public void Test_1118() - { - } - [Test] - public void Test_1119() - { - } - [Test] - public void Test_1120() - { - } - [Test] - public void Test_1121() - { - } - [Test] - public void Test_1122() - { - } - [Test] - public void Test_1123() - { - } - [Test] - public void Test_1124() - { - } - [Test] - public void Test_1125() - { - } - [Test] - public void Test_1126() - { - } - [Test] - public void Test_1127() - { - } - [Test] - public void Test_1128() - { - } - [Test] - public void Test_1129() - { - } - [Test] - public void Test_1130() - { - } - [Test] - public void Test_1131() - { - } - [Test] - public void Test_1132() - { - } - [Test] - public void Test_1133() - { - } - [Test] - public void Test_1134() - { - } - [Test] - public void Test_1135() - { - } - [Test] - public void Test_1136() - { - } - [Test] - public void Test_1137() - { - } - [Test] - public void Test_1138() - { - } - [Test] - public void Test_1139() - { - } - [Test] - public void Test_1140() - { - } - [Test] - public void Test_1141() - { - } - [Test] - public void Test_1142() - { - } - [Test] - public void Test_1143() - { - } - [Test] - public void Test_1144() - { - } - [Test] - public void Test_1145() - { - } - [Test] - public void Test_1146() - { - } - [Test] - public void Test_1147() - { - } - [Test] - public void Test_1148() - { - } - [Test] - public void Test_1149() - { - } - [Test] - public void Test_1150() - { - } - [Test] - public void Test_1151() - { - } - [Test] - public void Test_1152() - { - } - [Test] - public void Test_1153() - { - } - [Test] - public void Test_1154() - { - } - [Test] - public void Test_1155() - { - } - [Test] - public void Test_1156() - { - } - [Test] - public void Test_1157() - { - } - [Test] - public void Test_1158() - { - } - [Test] - public void Test_1159() - { - } - [Test] - public void Test_1160() - { - } - [Test] - public void Test_1161() - { - } - [Test] - public void Test_1162() - { - } - [Test] - public void Test_1163() - { - } - [Test] - public void Test_1164() - { - } - [Test] - public void Test_1165() - { - } - [Test] - public void Test_1166() - { - } - [Test] - public void Test_1167() - { - } - [Test] - public void Test_1168() - { - } - [Test] - public void Test_1169() - { - } - [Test] - public void Test_1170() - { - } - [Test] - public void Test_1171() - { - } - [Test] - public void Test_1172() - { - } - [Test] - public void Test_1173() - { - } - [Test] - public void Test_1174() - { - } - [Test] - public void Test_1175() - { - } - [Test] - public void Test_1176() - { - } - [Test] - public void Test_1177() - { - } - [Test] - public void Test_1178() - { - } - [Test] - public void Test_1179() - { - } - [Test] - public void Test_1180() - { - } - [Test] - public void Test_1181() - { - } - [Test] - public void Test_1182() - { - } - [Test] - public void Test_1183() - { - } - [Test] - public void Test_1184() - { - } - [Test] - public void Test_1185() - { - } - [Test] - public void Test_1186() - { - } - [Test] - public void Test_1187() - { - } - [Test] - public void Test_1188() - { - } - [Test] - public void Test_1189() - { - } - [Test] - public void Test_1190() - { - } - [Test] - public void Test_1191() - { - } - [Test] - public void Test_1192() - { - } - [Test] - public void Test_1193() - { - } - [Test] - public void Test_1194() - { - } - [Test] - public void Test_1195() - { - } - [Test] - public void Test_1196() - { - } - [Test] - public void Test_1197() - { - } - [Test] - public void Test_1198() - { - } - [Test] - public void Test_1199() - { - } - [Test] - public void Test_1200() - { - } - [Test] - public void Test_1201() - { - } - [Test] - public void Test_1202() - { - } - [Test] - public void Test_1203() - { - } - [Test] - public void Test_1204() - { - } - [Test] - public void Test_1205() - { - } - [Test] - public void Test_1206() - { - } - [Test] - public void Test_1207() - { - } - [Test] - public void Test_1208() - { - } - [Test] - public void Test_1209() - { - } - [Test] - public void Test_1210() - { - } - [Test] - public void Test_1211() - { - } - [Test] - public void Test_1212() - { - } - [Test] - public void Test_1213() - { - } - [Test] - public void Test_1214() - { - } - [Test] - public void Test_1215() - { - } - [Test] - public void Test_1216() - { - } - [Test] - public void Test_1217() - { - } - [Test] - public void Test_1218() - { - } - [Test] - public void Test_1219() - { - } - [Test] - public void Test_1220() - { - } - [Test] - public void Test_1221() - { - } - [Test] - public void Test_1222() - { - } - [Test] - public void Test_1223() - { - } - [Test] - public void Test_1224() - { - } - [Test] - public void Test_1225() - { - } - [Test] - public void Test_1226() - { - } - [Test] - public void Test_1227() - { - } - [Test] - public void Test_1228() - { - } - [Test] - public void Test_1229() - { - } - [Test] - public void Test_1230() - { - } - [Test] - public void Test_1231() - { - } - [Test] - public void Test_1232() - { - } - [Test] - public void Test_1233() - { - } - [Test] - public void Test_1234() - { - } - [Test] - public void Test_1235() - { - } - [Test] - public void Test_1236() - { - } - [Test] - public void Test_1237() - { - } - [Test] - public void Test_1238() - { - } - [Test] - public void Test_1239() - { - } - [Test] - public void Test_1240() - { - } - [Test] - public void Test_1241() - { - } - [Test] - public void Test_1242() - { - } - [Test] - public void Test_1243() - { - } - [Test] - public void Test_1244() - { - } - [Test] - public void Test_1245() - { - } - [Test] - public void Test_1246() - { - } - [Test] - public void Test_1247() - { - } - [Test] - public void Test_1248() - { - } - [Test] - public void Test_1249() - { - } - [Test] - public void Test_1250() - { - } - [Test] - public void Test_1251() - { - } - [Test] - public void Test_1252() - { - } - [Test] - public void Test_1253() - { - } - [Test] - public void Test_1254() - { - } - [Test] - public void Test_1255() - { - } - [Test] - public void Test_1256() - { - } - [Test] - public void Test_1257() - { - } - [Test] - public void Test_1258() - { - } - [Test] - public void Test_1259() - { - } - [Test] - public void Test_1260() - { - } - [Test] - public void Test_1261() - { - } - [Test] - public void Test_1262() - { - } - [Test] - public void Test_1263() - { - } - [Test] - public void Test_1264() - { - } - [Test] - public void Test_1265() - { - } - [Test] - public void Test_1266() - { - } - [Test] - public void Test_1267() - { - } - [Test] - public void Test_1268() - { - } - [Test] - public void Test_1269() - { - } - [Test] - public void Test_1270() - { - } - [Test] - public void Test_1271() - { - } - [Test] - public void Test_1272() - { - } - [Test] - public void Test_1273() - { - } - [Test] - public void Test_1274() - { - } - [Test] - public void Test_1275() - { - } - [Test] - public void Test_1276() - { - } - [Test] - public void Test_1277() - { - } - [Test] - public void Test_1278() - { - } - [Test] - public void Test_1279() - { - } - [Test] - public void Test_1280() - { - } - [Test] - public void Test_1281() - { - } - [Test] - public void Test_1282() - { - } - [Test] - public void Test_1283() - { - } - [Test] - public void Test_1284() - { - } - [Test] - public void Test_1285() - { - } - [Test] - public void Test_1286() - { - } - [Test] - public void Test_1287() - { - } - [Test] - public void Test_1288() - { - } - [Test] - public void Test_1289() - { - } - [Test] - public void Test_1290() - { - } - [Test] - public void Test_1291() - { - } - [Test] - public void Test_1292() - { - } - [Test] - public void Test_1293() - { - } - [Test] - public void Test_1294() - { - } - [Test] - public void Test_1295() - { - } - [Test] - public void Test_1296() - { - } - [Test] - public void Test_1297() - { - } - [Test] - public void Test_1298() - { - } - [Test] - public void Test_1299() - { - } - [Test] - public void Test_1300() - { - } - [Test] - public void Test_1301() - { - } - [Test] - public void Test_1302() - { - } - [Test] - public void Test_1303() - { - } - [Test] - public void Test_1304() - { - } - [Test] - public void Test_1305() - { - } - [Test] - public void Test_1306() - { - } - [Test] - public void Test_1307() - { - } - [Test] - public void Test_1308() - { - } - [Test] - public void Test_1309() - { - } - [Test] - public void Test_1310() - { - } - [Test] - public void Test_1311() - { - } - [Test] - public void Test_1312() - { - } - [Test] - public void Test_1313() - { - } - [Test] - public void Test_1314() - { - } - [Test] - public void Test_1315() - { - } - [Test] - public void Test_1316() - { - } - [Test] - public void Test_1317() - { - } - [Test] - public void Test_1318() - { - } - [Test] - public void Test_1319() - { - } - [Test] - public void Test_1320() - { - } - [Test] - public void Test_1321() - { - } - [Test] - public void Test_1322() - { - } - [Test] - public void Test_1323() - { - } - [Test] - public void Test_1324() - { - } - [Test] - public void Test_1325() - { - } - [Test] - public void Test_1326() - { - } - [Test] - public void Test_1327() - { - } - [Test] - public void Test_1328() - { - } - [Test] - public void Test_1329() - { - } - [Test] - public void Test_1330() - { - } - [Test] - public void Test_1331() - { - } - [Test] - public void Test_1332() - { - } - [Test] - public void Test_1333() - { - } - [Test] - public void Test_1334() - { - } - [Test] - public void Test_1335() - { - } - [Test] - public void Test_1336() - { - } - [Test] - public void Test_1337() - { - } - [Test] - public void Test_1338() - { - } - [Test] - public void Test_1339() - { - } - [Test] - public void Test_1340() - { - } - [Test] - public void Test_1341() - { - } - [Test] - public void Test_1342() - { - } - [Test] - public void Test_1343() - { - } - [Test] - public void Test_1344() - { - } - [Test] - public void Test_1345() - { - } - [Test] - public void Test_1346() - { - } - [Test] - public void Test_1347() - { - } - [Test] - public void Test_1348() - { - } - [Test] - public void Test_1349() - { - } - [Test] - public void Test_1350() - { - } - [Test] - public void Test_1351() - { - } - [Test] - public void Test_1352() - { - } - [Test] - public void Test_1353() - { - } - [Test] - public void Test_1354() - { - } - [Test] - public void Test_1355() - { - } - [Test] - public void Test_1356() - { - } - [Test] - public void Test_1357() - { - } - [Test] - public void Test_1358() - { - } - [Test] - public void Test_1359() - { - } - [Test] - public void Test_1360() - { - } - [Test] - public void Test_1361() - { - } - [Test] - public void Test_1362() - { - } - [Test] - public void Test_1363() - { - } - [Test] - public void Test_1364() - { - } - [Test] - public void Test_1365() - { - } - [Test] - public void Test_1366() - { - } - [Test] - public void Test_1367() - { - } - [Test] - public void Test_1368() - { - } - [Test] - public void Test_1369() - { - } - [Test] - public void Test_1370() - { - } - [Test] - public void Test_1371() - { - } - [Test] - public void Test_1372() - { - } - [Test] - public void Test_1373() - { - } - [Test] - public void Test_1374() - { - } - [Test] - public void Test_1375() - { - } - [Test] - public void Test_1376() - { - } - [Test] - public void Test_1377() - { - } - [Test] - public void Test_1378() - { - } - [Test] - public void Test_1379() - { - } - [Test] - public void Test_1380() - { - } - [Test] - public void Test_1381() - { - } - [Test] - public void Test_1382() - { - } - [Test] - public void Test_1383() - { - } - [Test] - public void Test_1384() - { - } - [Test] - public void Test_1385() - { - } - [Test] - public void Test_1386() - { - } - [Test] - public void Test_1387() - { - } - [Test] - public void Test_1388() - { - } - [Test] - public void Test_1389() - { - } - [Test] - public void Test_1390() - { - } - [Test] - public void Test_1391() - { - } - [Test] - public void Test_1392() - { - } - [Test] - public void Test_1393() - { - } - [Test] - public void Test_1394() - { - } - [Test] - public void Test_1395() - { - } - [Test] - public void Test_1396() - { - } - [Test] - public void Test_1397() - { - } - [Test] - public void Test_1398() - { - } - [Test] - public void Test_1399() - { - } - [Test] - public void Test_1400() - { - } - [Test] - public void Test_1401() - { - } - [Test] - public void Test_1402() - { - } - [Test] - public void Test_1403() - { - } - [Test] - public void Test_1404() - { - } - [Test] - public void Test_1405() - { - } - [Test] - public void Test_1406() - { - } - [Test] - public void Test_1407() - { - } - [Test] - public void Test_1408() - { - } - [Test] - public void Test_1409() - { - } - [Test] - public void Test_1410() - { - } - [Test] - public void Test_1411() - { - } - [Test] - public void Test_1412() - { - } - [Test] - public void Test_1413() - { - } - [Test] - public void Test_1414() - { - } - [Test] - public void Test_1415() - { - } - [Test] - public void Test_1416() - { - } - [Test] - public void Test_1417() - { - } - [Test] - public void Test_1418() - { - } - [Test] - public void Test_1419() - { - } - [Test] - public void Test_1420() - { - } - [Test] - public void Test_1421() - { - } - [Test] - public void Test_1422() - { - } - [Test] - public void Test_1423() - { - } - [Test] - public void Test_1424() - { - } - [Test] - public void Test_1425() - { - } - [Test] - public void Test_1426() - { - } - [Test] - public void Test_1427() - { - } - [Test] - public void Test_1428() - { - } - [Test] - public void Test_1429() - { - } - [Test] - public void Test_1430() - { - } - [Test] - public void Test_1431() - { - } - [Test] - public void Test_1432() - { - } - [Test] - public void Test_1433() - { - } - [Test] - public void Test_1434() - { - } - [Test] - public void Test_1435() - { - } - [Test] - public void Test_1436() - { - } - [Test] - public void Test_1437() - { - } - [Test] - public void Test_1438() - { - } - [Test] - public void Test_1439() - { - } - [Test] - public void Test_1440() - { - } - [Test] - public void Test_1441() - { - } - [Test] - public void Test_1442() - { - } - [Test] - public void Test_1443() - { - } - [Test] - public void Test_1444() - { - } - [Test] - public void Test_1445() - { - } - [Test] - public void Test_1446() - { - } - [Test] - public void Test_1447() - { - } - [Test] - public void Test_1448() - { - } - [Test] - public void Test_1449() - { - } - [Test] - public void Test_1450() - { - } - [Test] - public void Test_1451() - { - } - [Test] - public void Test_1452() - { - } - [Test] - public void Test_1453() - { - } - [Test] - public void Test_1454() - { - } - [Test] - public void Test_1455() - { - } - [Test] - public void Test_1456() - { - } - [Test] - public void Test_1457() - { - } - [Test] - public void Test_1458() - { - } - [Test] - public void Test_1459() - { - } - [Test] - public void Test_1460() - { - } - [Test] - public void Test_1461() - { - } - [Test] - public void Test_1462() - { - } - [Test] - public void Test_1463() - { - } - [Test] - public void Test_1464() - { - } - [Test] - public void Test_1465() - { - } - [Test] - public void Test_1466() - { - } - [Test] - public void Test_1467() - { - } - [Test] - public void Test_1468() - { - } - [Test] - public void Test_1469() - { - } - [Test] - public void Test_1470() - { - } - [Test] - public void Test_1471() - { - } - [Test] - public void Test_1472() - { - } - [Test] - public void Test_1473() - { - } - [Test] - public void Test_1474() - { - } - [Test] - public void Test_1475() - { - } - [Test] - public void Test_1476() - { - } - [Test] - public void Test_1477() - { - } - [Test] - public void Test_1478() - { - } - [Test] - public void Test_1479() - { - } - [Test] - public void Test_1480() - { - } - [Test] - public void Test_1481() - { - } - [Test] - public void Test_1482() - { - } - [Test] - public void Test_1483() - { - } - [Test] - public void Test_1484() - { - } - [Test] - public void Test_1485() - { - } - [Test] - public void Test_1486() - { - } - [Test] - public void Test_1487() - { - } - [Test] - public void Test_1488() - { - } - [Test] - public void Test_1489() - { - } - [Test] - public void Test_1490() - { - } - [Test] - public void Test_1491() - { - } - [Test] - public void Test_1492() - { - } - [Test] - public void Test_1493() - { - } - [Test] - public void Test_1494() - { - } - [Test] - public void Test_1495() - { - } - [Test] - public void Test_1496() - { - } - [Test] - public void Test_1497() - { - } - [Test] - public void Test_1498() - { - } - [Test] - public void Test_1499() - { - } - [Test] - public void Test_1500() - { - } - [Test] - public void Test_1501() - { - } - [Test] - public void Test_1502() - { - } - [Test] - public void Test_1503() - { - } - [Test] - public void Test_1504() - { - } - [Test] - public void Test_1505() - { - } - [Test] - public void Test_1506() - { - } - [Test] - public void Test_1507() - { - } - [Test] - public void Test_1508() - { - } - [Test] - public void Test_1509() - { - } - [Test] - public void Test_1510() - { - } - [Test] - public void Test_1511() - { - } - [Test] - public void Test_1512() - { - } - [Test] - public void Test_1513() - { - } - [Test] - public void Test_1514() - { - } - [Test] - public void Test_1515() - { - } - [Test] - public void Test_1516() - { - } - [Test] - public void Test_1517() - { - } - [Test] - public void Test_1518() - { - } - [Test] - public void Test_1519() - { - } - [Test] - public void Test_1520() - { - } - [Test] - public void Test_1521() - { - } - [Test] - public void Test_1522() - { - } - [Test] - public void Test_1523() - { - } - [Test] - public void Test_1524() - { - } - [Test] - public void Test_1525() - { - } - [Test] - public void Test_1526() - { - } - [Test] - public void Test_1527() - { - } - [Test] - public void Test_1528() - { - } - [Test] - public void Test_1529() - { - } - [Test] - public void Test_1530() - { - } - [Test] - public void Test_1531() - { - } - [Test] - public void Test_1532() - { - } - [Test] - public void Test_1533() - { - } - [Test] - public void Test_1534() - { - } - [Test] - public void Test_1535() - { - } - [Test] - public void Test_1536() - { - } - [Test] - public void Test_1537() - { - } - [Test] - public void Test_1538() - { - } - [Test] - public void Test_1539() - { - } - [Test] - public void Test_1540() - { - } - [Test] - public void Test_1541() - { - } - [Test] - public void Test_1542() - { - } - [Test] - public void Test_1543() - { - } - [Test] - public void Test_1544() - { - } - [Test] - public void Test_1545() - { - } - [Test] - public void Test_1546() - { - } - [Test] - public void Test_1547() - { - } - [Test] - public void Test_1548() - { - } - [Test] - public void Test_1549() - { - } - [Test] - public void Test_1550() - { - } - [Test] - public void Test_1551() - { - } - [Test] - public void Test_1552() - { - } - [Test] - public void Test_1553() - { - } - [Test] - public void Test_1554() - { - } - [Test] - public void Test_1555() - { - } - [Test] - public void Test_1556() - { - } - [Test] - public void Test_1557() - { - } - [Test] - public void Test_1558() - { - } - [Test] - public void Test_1559() - { - } - [Test] - public void Test_1560() - { - } - [Test] - public void Test_1561() - { - } - [Test] - public void Test_1562() - { - } - [Test] - public void Test_1563() - { - } - [Test] - public void Test_1564() - { - } - [Test] - public void Test_1565() - { - } - [Test] - public void Test_1566() - { - } - [Test] - public void Test_1567() - { - } - [Test] - public void Test_1568() - { - } - [Test] - public void Test_1569() - { - } - [Test] - public void Test_1570() - { - } - [Test] - public void Test_1571() - { - } - [Test] - public void Test_1572() - { - } - [Test] - public void Test_1573() - { - } - [Test] - public void Test_1574() - { - } - [Test] - public void Test_1575() - { - } - [Test] - public void Test_1576() - { - } - [Test] - public void Test_1577() - { - } - [Test] - public void Test_1578() - { - } - [Test] - public void Test_1579() - { - } - [Test] - public void Test_1580() - { - } - [Test] - public void Test_1581() - { - } - [Test] - public void Test_1582() - { - } - [Test] - public void Test_1583() - { - } - [Test] - public void Test_1584() - { - } - [Test] - public void Test_1585() - { - } - [Test] - public void Test_1586() - { - } - [Test] - public void Test_1587() - { - } - [Test] - public void Test_1588() - { - } - [Test] - public void Test_1589() - { - } - [Test] - public void Test_1590() - { - } - [Test] - public void Test_1591() - { - } - [Test] - public void Test_1592() - { - } - [Test] - public void Test_1593() - { - } - [Test] - public void Test_1594() - { - } - [Test] - public void Test_1595() - { - } - [Test] - public void Test_1596() - { - } - [Test] - public void Test_1597() - { - } - [Test] - public void Test_1598() - { - } - [Test] - public void Test_1599() - { - } - [Test] - public void Test_1600() - { - } - [Test] - public void Test_1601() - { - } - [Test] - public void Test_1602() - { - } - [Test] - public void Test_1603() - { - } - [Test] - public void Test_1604() - { - } - [Test] - public void Test_1605() - { - } - [Test] - public void Test_1606() - { - } - [Test] - public void Test_1607() - { - } - [Test] - public void Test_1608() - { - } - [Test] - public void Test_1609() - { - } - [Test] - public void Test_1610() - { - } - [Test] - public void Test_1611() - { - } - [Test] - public void Test_1612() - { - } - [Test] - public void Test_1613() - { - } - [Test] - public void Test_1614() - { - } - [Test] - public void Test_1615() - { - } - [Test] - public void Test_1616() - { - } - [Test] - public void Test_1617() - { - } - [Test] - public void Test_1618() - { - } - [Test] - public void Test_1619() - { - } - [Test] - public void Test_1620() - { - } - [Test] - public void Test_1621() - { - } - [Test] - public void Test_1622() - { - } - [Test] - public void Test_1623() - { - } - [Test] - public void Test_1624() - { - } - [Test] - public void Test_1625() - { - } - [Test] - public void Test_1626() - { - } - [Test] - public void Test_1627() - { - } - [Test] - public void Test_1628() - { - } - [Test] - public void Test_1629() - { - } - [Test] - public void Test_1630() - { - } - [Test] - public void Test_1631() - { - } - [Test] - public void Test_1632() - { - } - [Test] - public void Test_1633() - { - } - [Test] - public void Test_1634() - { - } - [Test] - public void Test_1635() - { - } - [Test] - public void Test_1636() - { - } - [Test] - public void Test_1637() - { - } - [Test] - public void Test_1638() - { - } - [Test] - public void Test_1639() - { - } - [Test] - public void Test_1640() - { - } - [Test] - public void Test_1641() - { - } - [Test] - public void Test_1642() - { - } - [Test] - public void Test_1643() - { - } - [Test] - public void Test_1644() - { - } - [Test] - public void Test_1645() - { - } - [Test] - public void Test_1646() - { - } - [Test] - public void Test_1647() - { - } - [Test] - public void Test_1648() - { - } - [Test] - public void Test_1649() - { - } - [Test] - public void Test_1650() - { - } - [Test] - public void Test_1651() - { - } - [Test] - public void Test_1652() - { - } - [Test] - public void Test_1653() - { - } - [Test] - public void Test_1654() - { - } - [Test] - public void Test_1655() - { - } - [Test] - public void Test_1656() - { - } - [Test] - public void Test_1657() - { - } - [Test] - public void Test_1658() - { - } - [Test] - public void Test_1659() - { - } - [Test] - public void Test_1660() - { - } - [Test] - public void Test_1661() - { - } - [Test] - public void Test_1662() - { - } - [Test] - public void Test_1663() - { - } - [Test] - public void Test_1664() - { - } - [Test] - public void Test_1665() - { - } - [Test] - public void Test_1666() - { - } - [Test] - public void Test_1667() - { - } - [Test] - public void Test_1668() - { - } - [Test] - public void Test_1669() - { - } - [Test] - public void Test_1670() - { - } - [Test] - public void Test_1671() - { - } - [Test] - public void Test_1672() - { - } - [Test] - public void Test_1673() - { - } - [Test] - public void Test_1674() - { - } - [Test] - public void Test_1675() - { - } - [Test] - public void Test_1676() - { - } - [Test] - public void Test_1677() - { - } - [Test] - public void Test_1678() - { - } - [Test] - public void Test_1679() - { - } - [Test] - public void Test_1680() - { - } - [Test] - public void Test_1681() - { - } - [Test] - public void Test_1682() - { - } - [Test] - public void Test_1683() - { - } - [Test] - public void Test_1684() - { - } - [Test] - public void Test_1685() - { - } - [Test] - public void Test_1686() - { - } - [Test] - public void Test_1687() - { - } - [Test] - public void Test_1688() - { - } - [Test] - public void Test_1689() - { - } - [Test] - public void Test_1690() - { - } - [Test] - public void Test_1691() - { - } - [Test] - public void Test_1692() - { - } - [Test] - public void Test_1693() - { - } - [Test] - public void Test_1694() - { - } - [Test] - public void Test_1695() - { - } - [Test] - public void Test_1696() - { - } - [Test] - public void Test_1697() - { - } - [Test] - public void Test_1698() - { - } - [Test] - public void Test_1699() - { - } - [Test] - public void Test_1700() - { - } - [Test] - public void Test_1701() - { - } - [Test] - public void Test_1702() - { - } - [Test] - public void Test_1703() - { - } - [Test] - public void Test_1704() - { - } - [Test] - public void Test_1705() - { - } - [Test] - public void Test_1706() - { - } - [Test] - public void Test_1707() - { - } - [Test] - public void Test_1708() - { - } - [Test] - public void Test_1709() - { - } - [Test] - public void Test_1710() - { - } - [Test] - public void Test_1711() - { - } - [Test] - public void Test_1712() - { - } - [Test] - public void Test_1713() - { - } - [Test] - public void Test_1714() - { - } - [Test] - public void Test_1715() - { - } - [Test] - public void Test_1716() - { - } - [Test] - public void Test_1717() - { - } - [Test] - public void Test_1718() - { - } - [Test] - public void Test_1719() - { - } - [Test] - public void Test_1720() - { - } - [Test] - public void Test_1721() - { - } - [Test] - public void Test_1722() - { - } - [Test] - public void Test_1723() - { - } - [Test] - public void Test_1724() - { - } - [Test] - public void Test_1725() - { - } - [Test] - public void Test_1726() - { - } - [Test] - public void Test_1727() - { - } - [Test] - public void Test_1728() - { - } - [Test] - public void Test_1729() - { - } - [Test] - public void Test_1730() - { - } - [Test] - public void Test_1731() - { - } - [Test] - public void Test_1732() - { - } - [Test] - public void Test_1733() - { - } - [Test] - public void Test_1734() - { - } - [Test] - public void Test_1735() - { - } - [Test] - public void Test_1736() - { - } - [Test] - public void Test_1737() - { - } - [Test] - public void Test_1738() - { - } - [Test] - public void Test_1739() - { - } - [Test] - public void Test_1740() - { - } - [Test] - public void Test_1741() - { - } - [Test] - public void Test_1742() - { - } - [Test] - public void Test_1743() - { - } - [Test] - public void Test_1744() - { - } - [Test] - public void Test_1745() - { - } - [Test] - public void Test_1746() - { - } - [Test] - public void Test_1747() - { - } - [Test] - public void Test_1748() - { - } - [Test] - public void Test_1749() - { - } - [Test] - public void Test_1750() - { - } - [Test] - public void Test_1751() - { - } - [Test] - public void Test_1752() - { - } - [Test] - public void Test_1753() - { - } - [Test] - public void Test_1754() - { - } - [Test] - public void Test_1755() - { - } - [Test] - public void Test_1756() - { - } - [Test] - public void Test_1757() - { - } - [Test] - public void Test_1758() - { - } - [Test] - public void Test_1759() - { - } - [Test] - public void Test_1760() - { - } - [Test] - public void Test_1761() - { - } - [Test] - public void Test_1762() - { - } - [Test] - public void Test_1763() - { - } - [Test] - public void Test_1764() - { - } - [Test] - public void Test_1765() - { - } - [Test] - public void Test_1766() - { - } - [Test] - public void Test_1767() - { - } - [Test] - public void Test_1768() - { - } - [Test] - public void Test_1769() - { - } - [Test] - public void Test_1770() - { - } - [Test] - public void Test_1771() - { - } - [Test] - public void Test_1772() - { - } - [Test] - public void Test_1773() - { - } - [Test] - public void Test_1774() - { - } - [Test] - public void Test_1775() - { - } - [Test] - public void Test_1776() - { - } - [Test] - public void Test_1777() - { - } - [Test] - public void Test_1778() - { - } - [Test] - public void Test_1779() - { - } - [Test] - public void Test_1780() - { - } - [Test] - public void Test_1781() - { - } - [Test] - public void Test_1782() - { - } - [Test] - public void Test_1783() - { - } - [Test] - public void Test_1784() - { - } - [Test] - public void Test_1785() - { - } - [Test] - public void Test_1786() - { - } - [Test] - public void Test_1787() - { - } - [Test] - public void Test_1788() - { - } - [Test] - public void Test_1789() - { - } - [Test] - public void Test_1790() - { - } - [Test] - public void Test_1791() - { - } - [Test] - public void Test_1792() - { - } - [Test] - public void Test_1793() - { - } - [Test] - public void Test_1794() - { - } - [Test] - public void Test_1795() - { - } - [Test] - public void Test_1796() - { - } - [Test] - public void Test_1797() - { - } - [Test] - public void Test_1798() - { - } - [Test] - public void Test_1799() - { - } - [Test] - public void Test_1800() - { - } - [Test] - public void Test_1801() - { - } - [Test] - public void Test_1802() - { - } - [Test] - public void Test_1803() - { - } - [Test] - public void Test_1804() - { - } - [Test] - public void Test_1805() - { - } - [Test] - public void Test_1806() - { - } - [Test] - public void Test_1807() - { - } - [Test] - public void Test_1808() - { - } - [Test] - public void Test_1809() - { - } - [Test] - public void Test_1810() - { - } - [Test] - public void Test_1811() - { - } - [Test] - public void Test_1812() - { - } - [Test] - public void Test_1813() - { - } - [Test] - public void Test_1814() - { - } - [Test] - public void Test_1815() - { - } - [Test] - public void Test_1816() - { - } - [Test] - public void Test_1817() - { - } - [Test] - public void Test_1818() - { - } - [Test] - public void Test_1819() - { - } - [Test] - public void Test_1820() - { - } - [Test] - public void Test_1821() - { - } - [Test] - public void Test_1822() - { - } - [Test] - public void Test_1823() - { - } - [Test] - public void Test_1824() - { - } - [Test] - public void Test_1825() - { - } - [Test] - public void Test_1826() - { - } - [Test] - public void Test_1827() - { - } - [Test] - public void Test_1828() - { - } - [Test] - public void Test_1829() - { - } - [Test] - public void Test_1830() - { - } - [Test] - public void Test_1831() - { - } - [Test] - public void Test_1832() - { - } - [Test] - public void Test_1833() - { - } - [Test] - public void Test_1834() - { - } - [Test] - public void Test_1835() - { - } - [Test] - public void Test_1836() - { - } - [Test] - public void Test_1837() - { - } - [Test] - public void Test_1838() - { - } - [Test] - public void Test_1839() - { - } - [Test] - public void Test_1840() - { - } - [Test] - public void Test_1841() - { - } - [Test] - public void Test_1842() - { - } - [Test] - public void Test_1843() - { - } - [Test] - public void Test_1844() - { - } - [Test] - public void Test_1845() - { - } - [Test] - public void Test_1846() - { - } - [Test] - public void Test_1847() - { - } - [Test] - public void Test_1848() - { - } - [Test] - public void Test_1849() - { - } - [Test] - public void Test_1850() - { - } - [Test] - public void Test_1851() - { - } - [Test] - public void Test_1852() - { - } - [Test] - public void Test_1853() - { - } - [Test] - public void Test_1854() - { - } - [Test] - public void Test_1855() - { - } - [Test] - public void Test_1856() - { - } - [Test] - public void Test_1857() - { - } - [Test] - public void Test_1858() - { - } - [Test] - public void Test_1859() - { - } - [Test] - public void Test_1860() - { - } - [Test] - public void Test_1861() - { - } - [Test] - public void Test_1862() - { - } - [Test] - public void Test_1863() - { - } - [Test] - public void Test_1864() - { - } - [Test] - public void Test_1865() - { - } - [Test] - public void Test_1866() - { - } - [Test] - public void Test_1867() - { - } - [Test] - public void Test_1868() - { - } - [Test] - public void Test_1869() - { - } - [Test] - public void Test_1870() - { - } - [Test] - public void Test_1871() - { - } - [Test] - public void Test_1872() - { - } - [Test] - public void Test_1873() - { - } - [Test] - public void Test_1874() - { - } - [Test] - public void Test_1875() - { - } - [Test] - public void Test_1876() - { - } - [Test] - public void Test_1877() - { - } - [Test] - public void Test_1878() - { - } - [Test] - public void Test_1879() - { - } - [Test] - public void Test_1880() - { - } - [Test] - public void Test_1881() - { - } - [Test] - public void Test_1882() - { - } - [Test] - public void Test_1883() - { - } - [Test] - public void Test_1884() - { - } - [Test] - public void Test_1885() - { - } - [Test] - public void Test_1886() - { - } - [Test] - public void Test_1887() - { - } - [Test] - public void Test_1888() - { - } - [Test] - public void Test_1889() - { - } - [Test] - public void Test_1890() - { - } - [Test] - public void Test_1891() - { - } - [Test] - public void Test_1892() - { - } - [Test] - public void Test_1893() - { - } - [Test] - public void Test_1894() - { - } - [Test] - public void Test_1895() - { - } - [Test] - public void Test_1896() - { - } - [Test] - public void Test_1897() - { - } - [Test] - public void Test_1898() - { - } - [Test] - public void Test_1899() - { - } - [Test] - public void Test_1900() - { - } - [Test] - public void Test_1901() - { - } - [Test] - public void Test_1902() - { - } - [Test] - public void Test_1903() - { - } - [Test] - public void Test_1904() - { - } - [Test] - public void Test_1905() - { - } - [Test] - public void Test_1906() - { - } - [Test] - public void Test_1907() - { - } - [Test] - public void Test_1908() - { - } - [Test] - public void Test_1909() - { - } - [Test] - public void Test_1910() - { - } - [Test] - public void Test_1911() - { - } - [Test] - public void Test_1912() - { - } - [Test] - public void Test_1913() - { - } - [Test] - public void Test_1914() - { - } - [Test] - public void Test_1915() - { - } - [Test] - public void Test_1916() - { - } - [Test] - public void Test_1917() - { - } - [Test] - public void Test_1918() - { - } - [Test] - public void Test_1919() - { - } - [Test] - public void Test_1920() - { - } - [Test] - public void Test_1921() - { - } - [Test] - public void Test_1922() - { - } - [Test] - public void Test_1923() - { - } - [Test] - public void Test_1924() - { - } - [Test] - public void Test_1925() - { - } - [Test] - public void Test_1926() - { - } - [Test] - public void Test_1927() - { - } - [Test] - public void Test_1928() - { - } - [Test] - public void Test_1929() - { - } - [Test] - public void Test_1930() - { - } - [Test] - public void Test_1931() - { - } - [Test] - public void Test_1932() - { - } - [Test] - public void Test_1933() - { - } - [Test] - public void Test_1934() - { - } - [Test] - public void Test_1935() - { - } - [Test] - public void Test_1936() - { - } - [Test] - public void Test_1937() - { - } - [Test] - public void Test_1938() - { - } - [Test] - public void Test_1939() - { - } - [Test] - public void Test_1940() - { - } - [Test] - public void Test_1941() - { - } - [Test] - public void Test_1942() - { - } - [Test] - public void Test_1943() - { - } - [Test] - public void Test_1944() - { - } - [Test] - public void Test_1945() - { - } - [Test] - public void Test_1946() - { - } - [Test] - public void Test_1947() - { - } - [Test] - public void Test_1948() - { - } - [Test] - public void Test_1949() - { - } - [Test] - public void Test_1950() - { - } - [Test] - public void Test_1951() - { - } - [Test] - public void Test_1952() - { - } - [Test] - public void Test_1953() - { - } - [Test] - public void Test_1954() - { - } - [Test] - public void Test_1955() - { - } - [Test] - public void Test_1956() - { - } - [Test] - public void Test_1957() - { - } - [Test] - public void Test_1958() - { - } - [Test] - public void Test_1959() - { - } - [Test] - public void Test_1960() - { - } - [Test] - public void Test_1961() - { - } - [Test] - public void Test_1962() - { - } - [Test] - public void Test_1963() - { - } - [Test] - public void Test_1964() - { - } - [Test] - public void Test_1965() - { - } - [Test] - public void Test_1966() - { - } - [Test] - public void Test_1967() - { - } - [Test] - public void Test_1968() - { - } - [Test] - public void Test_1969() - { - } - [Test] - public void Test_1970() - { - } - [Test] - public void Test_1971() - { - } - [Test] - public void Test_1972() - { - } - [Test] - public void Test_1973() - { - } - [Test] - public void Test_1974() - { - } - [Test] - public void Test_1975() - { - } - [Test] - public void Test_1976() - { - } - [Test] - public void Test_1977() - { - } - [Test] - public void Test_1978() - { - } - [Test] - public void Test_1979() - { - } - [Test] - public void Test_1980() - { - } - [Test] - public void Test_1981() - { - } - [Test] - public void Test_1982() - { - } - [Test] - public void Test_1983() - { - } - [Test] - public void Test_1984() - { - } - [Test] - public void Test_1985() - { - } - [Test] - public void Test_1986() - { - } - [Test] - public void Test_1987() - { - } - [Test] - public void Test_1988() - { - } - [Test] - public void Test_1989() - { - } - [Test] - public void Test_1990() - { - } - [Test] - public void Test_1991() - { - } - [Test] - public void Test_1992() - { - } - [Test] - public void Test_1993() - { - } - [Test] - public void Test_1994() - { - } - [Test] - public void Test_1995() - { - } - [Test] - public void Test_1996() - { - } - [Test] - public void Test_1997() - { - } - [Test] - public void Test_1998() - { - } - [Test] - public void Test_1999() - { - } - [Test] - public void Test_2000() - { - } - [Test] - public void Test_2001() - { - } - [Test] - public void Test_2002() - { - } - [Test] - public void Test_2003() - { - } - [Test] - public void Test_2004() - { - } - [Test] - public void Test_2005() - { - } - [Test] - public void Test_2006() - { - } - [Test] - public void Test_2007() - { - } - [Test] - public void Test_2008() - { - } - [Test] - public void Test_2009() - { - } - [Test] - public void Test_2010() - { - } - [Test] - public void Test_2011() - { - } - [Test] - public void Test_2012() - { - } - [Test] - public void Test_2013() - { - } - [Test] - public void Test_2014() - { - } - [Test] - public void Test_2015() - { - } - [Test] - public void Test_2016() - { - } - [Test] - public void Test_2017() - { - } - [Test] - public void Test_2018() - { - } - [Test] - public void Test_2019() - { - } - [Test] - public void Test_2020() - { - } - [Test] - public void Test_2021() - { - } - [Test] - public void Test_2022() - { - } - [Test] - public void Test_2023() - { - } - [Test] - public void Test_2024() - { - } - [Test] - public void Test_2025() - { - } - [Test] - public void Test_2026() - { - } - [Test] - public void Test_2027() - { - } - [Test] - public void Test_2028() - { - } - [Test] - public void Test_2029() - { - } - [Test] - public void Test_2030() - { - } - [Test] - public void Test_2031() - { - } - [Test] - public void Test_2032() - { - } - [Test] - public void Test_2033() - { - } - [Test] - public void Test_2034() - { - } - [Test] - public void Test_2035() - { - } - [Test] - public void Test_2036() - { - } - [Test] - public void Test_2037() - { - } - [Test] - public void Test_2038() - { - } - [Test] - public void Test_2039() - { - } - [Test] - public void Test_2040() - { - } - [Test] - public void Test_2041() - { - } - [Test] - public void Test_2042() - { - } - [Test] - public void Test_2043() - { - } - [Test] - public void Test_2044() - { - } - [Test] - public void Test_2045() - { - } - [Test] - public void Test_2046() - { - } - [Test] - public void Test_2047() - { - } - [Test] - public void Test_2048() - { - } - [Test] - public void Test_2049() - { - } - [Test] - public void Test_2050() - { - } - [Test] - public void Test_2051() - { - } - [Test] - public void Test_2052() - { - } - [Test] - public void Test_2053() - { - } - [Test] - public void Test_2054() - { - } - [Test] - public void Test_2055() - { - } - [Test] - public void Test_2056() - { - } - [Test] - public void Test_2057() - { - } - [Test] - public void Test_2058() - { - } - [Test] - public void Test_2059() - { - } - [Test] - public void Test_2060() - { - } - [Test] - public void Test_2061() - { - } - [Test] - public void Test_2062() - { - } - [Test] - public void Test_2063() - { - } - [Test] - public void Test_2064() - { - } - [Test] - public void Test_2065() - { - } - [Test] - public void Test_2066() - { - } - [Test] - public void Test_2067() - { - } - [Test] - public void Test_2068() - { - } - [Test] - public void Test_2069() - { - } - [Test] - public void Test_2070() - { - } - [Test] - public void Test_2071() - { - } - [Test] - public void Test_2072() - { - } - [Test] - public void Test_2073() - { - } - [Test] - public void Test_2074() - { - } - [Test] - public void Test_2075() - { - } - [Test] - public void Test_2076() - { - } - [Test] - public void Test_2077() - { - } - [Test] - public void Test_2078() - { - } - [Test] - public void Test_2079() - { - } - [Test] - public void Test_2080() - { - } - [Test] - public void Test_2081() - { - } - [Test] - public void Test_2082() - { - } - [Test] - public void Test_2083() - { - } - [Test] - public void Test_2084() - { - } - [Test] - public void Test_2085() - { - } - [Test] - public void Test_2086() - { - } - [Test] - public void Test_2087() - { - } - [Test] - public void Test_2088() - { - } - [Test] - public void Test_2089() - { - } - [Test] - public void Test_2090() - { - } - [Test] - public void Test_2091() - { - } - [Test] - public void Test_2092() - { - } - [Test] - public void Test_2093() - { - } - [Test] - public void Test_2094() - { - } - [Test] - public void Test_2095() - { - } - [Test] - public void Test_2096() - { - } - [Test] - public void Test_2097() - { - } - [Test] - public void Test_2098() - { - } - [Test] - public void Test_2099() - { - } - [Test] - public void Test_2100() - { - } - [Test] - public void Test_2101() - { - } - [Test] - public void Test_2102() - { - } - [Test] - public void Test_2103() - { - } - [Test] - public void Test_2104() - { - } - [Test] - public void Test_2105() - { - } - [Test] - public void Test_2106() - { - } - [Test] - public void Test_2107() - { - } - [Test] - public void Test_2108() - { - } - [Test] - public void Test_2109() - { - } - [Test] - public void Test_2110() - { - } - [Test] - public void Test_2111() - { - } - [Test] - public void Test_2112() - { - } - [Test] - public void Test_2113() - { - } - [Test] - public void Test_2114() - { - } - [Test] - public void Test_2115() - { - } - [Test] - public void Test_2116() - { - } - [Test] - public void Test_2117() - { - } - [Test] - public void Test_2118() - { - } - [Test] - public void Test_2119() - { - } - [Test] - public void Test_2120() - { - } - [Test] - public void Test_2121() - { - } - [Test] - public void Test_2122() - { - } - [Test] - public void Test_2123() - { - } - [Test] - public void Test_2124() - { - } - [Test] - public void Test_2125() - { - } - [Test] - public void Test_2126() - { - } - [Test] - public void Test_2127() - { - } - [Test] - public void Test_2128() - { - } - [Test] - public void Test_2129() - { - } - [Test] - public void Test_2130() - { - } - [Test] - public void Test_2131() - { - } - [Test] - public void Test_2132() - { - } - [Test] - public void Test_2133() - { - } - [Test] - public void Test_2134() - { - } - [Test] - public void Test_2135() - { - } - [Test] - public void Test_2136() - { - } - [Test] - public void Test_2137() - { - } - [Test] - public void Test_2138() - { - } - [Test] - public void Test_2139() - { - } - [Test] - public void Test_2140() - { - } - [Test] - public void Test_2141() - { - } - [Test] - public void Test_2142() - { - } - [Test] - public void Test_2143() - { - } - [Test] - public void Test_2144() - { - } - [Test] - public void Test_2145() - { - } - [Test] - public void Test_2146() - { - } - [Test] - public void Test_2147() - { - } - [Test] - public void Test_2148() - { - } - [Test] - public void Test_2149() - { - } - [Test] - public void Test_2150() - { - } - [Test] - public void Test_2151() - { - } - [Test] - public void Test_2152() - { - } - [Test] - public void Test_2153() - { - } - [Test] - public void Test_2154() - { - } - [Test] - public void Test_2155() - { - } - [Test] - public void Test_2156() - { - } - [Test] - public void Test_2157() - { - } - [Test] - public void Test_2158() - { - } - [Test] - public void Test_2159() - { - } - [Test] - public void Test_2160() - { - } - [Test] - public void Test_2161() - { - } - [Test] - public void Test_2162() - { - } - [Test] - public void Test_2163() - { - } - [Test] - public void Test_2164() - { - } - [Test] - public void Test_2165() - { - } - [Test] - public void Test_2166() - { - } - [Test] - public void Test_2167() - { - } - [Test] - public void Test_2168() - { - } - [Test] - public void Test_2169() - { - } - [Test] - public void Test_2170() - { - } - [Test] - public void Test_2171() - { - } - [Test] - public void Test_2172() - { - } - [Test] - public void Test_2173() - { - } - [Test] - public void Test_2174() - { - } - [Test] - public void Test_2175() - { - } - [Test] - public void Test_2176() - { - } - [Test] - public void Test_2177() - { - } - [Test] - public void Test_2178() - { - } - [Test] - public void Test_2179() - { - } - [Test] - public void Test_2180() - { - } - [Test] - public void Test_2181() - { - } - [Test] - public void Test_2182() - { - } - [Test] - public void Test_2183() - { - } - [Test] - public void Test_2184() - { - } - [Test] - public void Test_2185() - { - } - [Test] - public void Test_2186() - { - } - [Test] - public void Test_2187() - { - } - [Test] - public void Test_2188() - { - } - [Test] - public void Test_2189() - { - } - [Test] - public void Test_2190() - { - } - [Test] - public void Test_2191() - { - } - [Test] - public void Test_2192() - { - } - [Test] - public void Test_2193() - { - } - [Test] - public void Test_2194() - { - } - [Test] - public void Test_2195() - { - } - [Test] - public void Test_2196() - { - } - [Test] - public void Test_2197() - { - } - [Test] - public void Test_2198() - { - } - [Test] - public void Test_2199() - { - } - [Test] - public void Test_2200() - { - } - [Test] - public void Test_2201() - { - } - [Test] - public void Test_2202() - { - } - [Test] - public void Test_2203() - { - } - [Test] - public void Test_2204() - { - } - [Test] - public void Test_2205() - { - } - [Test] - public void Test_2206() - { - } - [Test] - public void Test_2207() - { - } - [Test] - public void Test_2208() - { - } - [Test] - public void Test_2209() - { - } - [Test] - public void Test_2210() - { - } - [Test] - public void Test_2211() - { - } - [Test] - public void Test_2212() - { - } - [Test] - public void Test_2213() - { - } - [Test] - public void Test_2214() - { - } - [Test] - public void Test_2215() - { - } - [Test] - public void Test_2216() - { - } - [Test] - public void Test_2217() - { - } - [Test] - public void Test_2218() - { - } - [Test] - public void Test_2219() - { - } - [Test] - public void Test_2220() - { - } - [Test] - public void Test_2221() - { - } - [Test] - public void Test_2222() - { - } - [Test] - public void Test_2223() - { - } - [Test] - public void Test_2224() - { - } - [Test] - public void Test_2225() - { - } - [Test] - public void Test_2226() - { - } - [Test] - public void Test_2227() - { - } - [Test] - public void Test_2228() - { - } - [Test] - public void Test_2229() - { - } - [Test] - public void Test_2230() - { - } - [Test] - public void Test_2231() - { - } - [Test] - public void Test_2232() - { - } - [Test] - public void Test_2233() - { - } - [Test] - public void Test_2234() - { - } - [Test] - public void Test_2235() - { - } - [Test] - public void Test_2236() - { - } - [Test] - public void Test_2237() - { - } - [Test] - public void Test_2238() - { - } - [Test] - public void Test_2239() - { - } - [Test] - public void Test_2240() - { - } - [Test] - public void Test_2241() - { - } - [Test] - public void Test_2242() - { - } - [Test] - public void Test_2243() - { - } - [Test] - public void Test_2244() - { - } - [Test] - public void Test_2245() - { - } - [Test] - public void Test_2246() - { - } - [Test] - public void Test_2247() - { - } - [Test] - public void Test_2248() - { - } - [Test] - public void Test_2249() - { - } - [Test] - public void Test_2250() - { - } - [Test] - public void Test_2251() - { - } - [Test] - public void Test_2252() - { - } - [Test] - public void Test_2253() - { - } - [Test] - public void Test_2254() - { - } - [Test] - public void Test_2255() - { - } - [Test] - public void Test_2256() - { - } - [Test] - public void Test_2257() - { - } - [Test] - public void Test_2258() - { - } - [Test] - public void Test_2259() - { - } - [Test] - public void Test_2260() - { - } - [Test] - public void Test_2261() - { - } - [Test] - public void Test_2262() - { - } - [Test] - public void Test_2263() - { - } - [Test] - public void Test_2264() - { - } - [Test] - public void Test_2265() - { - } - [Test] - public void Test_2266() - { - } - [Test] - public void Test_2267() - { - } - [Test] - public void Test_2268() - { - } - [Test] - public void Test_2269() - { - } - [Test] - public void Test_2270() - { - } - [Test] - public void Test_2271() - { - } - [Test] - public void Test_2272() - { - } - [Test] - public void Test_2273() - { - } - [Test] - public void Test_2274() - { - } - [Test] - public void Test_2275() - { - } - [Test] - public void Test_2276() - { - } - [Test] - public void Test_2277() - { - } - [Test] - public void Test_2278() - { - } - [Test] - public void Test_2279() - { - } - [Test] - public void Test_2280() - { - } - [Test] - public void Test_2281() - { - } - [Test] - public void Test_2282() - { - } - [Test] - public void Test_2283() - { - } - [Test] - public void Test_2284() - { - } - [Test] - public void Test_2285() - { - } - [Test] - public void Test_2286() - { - } - [Test] - public void Test_2287() - { - } - [Test] - public void Test_2288() - { - } - [Test] - public void Test_2289() - { - } - [Test] - public void Test_2290() - { - } - [Test] - public void Test_2291() - { - } - [Test] - public void Test_2292() - { - } - [Test] - public void Test_2293() - { - } - [Test] - public void Test_2294() - { - } - [Test] - public void Test_2295() - { - } - [Test] - public void Test_2296() - { - } - [Test] - public void Test_2297() - { - } - [Test] - public void Test_2298() - { - } - [Test] - public void Test_2299() - { - } - [Test] - public void Test_2300() - { - } - [Test] - public void Test_2301() - { - } - [Test] - public void Test_2302() - { - } - [Test] - public void Test_2303() - { - } - [Test] - public void Test_2304() - { - } - [Test] - public void Test_2305() - { - } - [Test] - public void Test_2306() - { - } - [Test] - public void Test_2307() - { - } - [Test] - public void Test_2308() - { - } - [Test] - public void Test_2309() - { - } - [Test] - public void Test_2310() - { - } - [Test] - public void Test_2311() - { - } - [Test] - public void Test_2312() - { - } - [Test] - public void Test_2313() - { - } - [Test] - public void Test_2314() - { - } - [Test] - public void Test_2315() - { - } - [Test] - public void Test_2316() - { - } - [Test] - public void Test_2317() - { - } - [Test] - public void Test_2318() - { - } - [Test] - public void Test_2319() - { - } - [Test] - public void Test_2320() - { - } - [Test] - public void Test_2321() - { - } - [Test] - public void Test_2322() - { - } - [Test] - public void Test_2323() - { - } - [Test] - public void Test_2324() - { - } - [Test] - public void Test_2325() - { - } - [Test] - public void Test_2326() - { - } - [Test] - public void Test_2327() - { - } - [Test] - public void Test_2328() - { - } - [Test] - public void Test_2329() - { - } - [Test] - public void Test_2330() - { - } - [Test] - public void Test_2331() - { - } - [Test] - public void Test_2332() - { - } - [Test] - public void Test_2333() - { - } - [Test] - public void Test_2334() - { - } - [Test] - public void Test_2335() - { - } - [Test] - public void Test_2336() - { - } - [Test] - public void Test_2337() - { - } - [Test] - public void Test_2338() - { - } - [Test] - public void Test_2339() - { - } - [Test] - public void Test_2340() - { - } - [Test] - public void Test_2341() - { - } - [Test] - public void Test_2342() - { - } - [Test] - public void Test_2343() - { - } - [Test] - public void Test_2344() - { - } - [Test] - public void Test_2345() - { - } - [Test] - public void Test_2346() - { - } - [Test] - public void Test_2347() - { - } - [Test] - public void Test_2348() - { - } - [Test] - public void Test_2349() - { - } - [Test] - public void Test_2350() - { - } - [Test] - public void Test_2351() - { - } - [Test] - public void Test_2352() - { - } - [Test] - public void Test_2353() - { - } - [Test] - public void Test_2354() - { - } - [Test] - public void Test_2355() - { - } - [Test] - public void Test_2356() - { - } - [Test] - public void Test_2357() - { - } - [Test] - public void Test_2358() - { - } - [Test] - public void Test_2359() - { - } - [Test] - public void Test_2360() - { - } - [Test] - public void Test_2361() - { - } - [Test] - public void Test_2362() - { - } - [Test] - public void Test_2363() - { - } - [Test] - public void Test_2364() - { - } - [Test] - public void Test_2365() - { - } - [Test] - public void Test_2366() - { - } - [Test] - public void Test_2367() - { - } - [Test] - public void Test_2368() - { - } - [Test] - public void Test_2369() - { - } - [Test] - public void Test_2370() - { - } - [Test] - public void Test_2371() - { - } - [Test] - public void Test_2372() - { - } - [Test] - public void Test_2373() - { - } - [Test] - public void Test_2374() - { - } - [Test] - public void Test_2375() - { - } - [Test] - public void Test_2376() - { - } - [Test] - public void Test_2377() - { - } - [Test] - public void Test_2378() - { - } - [Test] - public void Test_2379() - { - } - [Test] - public void Test_2380() - { - } - [Test] - public void Test_2381() - { - } - [Test] - public void Test_2382() - { - } - [Test] - public void Test_2383() - { - } - [Test] - public void Test_2384() - { - } - [Test] - public void Test_2385() - { - } - [Test] - public void Test_2386() - { - } - [Test] - public void Test_2387() - { - } - [Test] - public void Test_2388() - { - } - [Test] - public void Test_2389() - { - } - [Test] - public void Test_2390() - { - } - [Test] - public void Test_2391() - { - } - [Test] - public void Test_2392() - { - } - [Test] - public void Test_2393() - { - } - [Test] - public void Test_2394() - { - } - [Test] - public void Test_2395() - { - } - [Test] - public void Test_2396() - { - } - [Test] - public void Test_2397() - { - } - [Test] - public void Test_2398() - { - } - [Test] - public void Test_2399() - { - } - [Test] - public void Test_2400() - { - } - [Test] - public void Test_2401() - { - } - [Test] - public void Test_2402() - { - } - [Test] - public void Test_2403() - { - } - [Test] - public void Test_2404() - { - } - [Test] - public void Test_2405() - { - } - [Test] - public void Test_2406() - { - } - [Test] - public void Test_2407() - { - } - [Test] - public void Test_2408() - { - } - [Test] - public void Test_2409() - { - } - [Test] - public void Test_2410() - { - } - [Test] - public void Test_2411() - { - } - [Test] - public void Test_2412() - { - } - [Test] - public void Test_2413() - { - } - [Test] - public void Test_2414() - { - } - [Test] - public void Test_2415() - { - } - [Test] - public void Test_2416() - { - } - [Test] - public void Test_2417() - { - } - [Test] - public void Test_2418() - { - } - [Test] - public void Test_2419() - { - } - [Test] - public void Test_2420() - { - } - [Test] - public void Test_2421() - { - } - [Test] - public void Test_2422() - { - } - [Test] - public void Test_2423() - { - } - [Test] - public void Test_2424() - { - } - [Test] - public void Test_2425() - { - } - [Test] - public void Test_2426() - { - } - [Test] - public void Test_2427() - { - } - [Test] - public void Test_2428() - { - } - [Test] - public void Test_2429() - { - } - [Test] - public void Test_2430() - { - } - [Test] - public void Test_2431() - { - } - [Test] - public void Test_2432() - { - } - [Test] - public void Test_2433() - { - } - [Test] - public void Test_2434() - { - } - [Test] - public void Test_2435() - { - } - [Test] - public void Test_2436() - { - } - [Test] - public void Test_2437() - { - } - [Test] - public void Test_2438() - { - } - [Test] - public void Test_2439() - { - } - [Test] - public void Test_2440() - { - } - [Test] - public void Test_2441() - { - } - [Test] - public void Test_2442() - { - } - [Test] - public void Test_2443() - { - } - [Test] - public void Test_2444() - { - } - [Test] - public void Test_2445() - { - } - [Test] - public void Test_2446() - { - } - [Test] - public void Test_2447() - { - } - [Test] - public void Test_2448() - { - } - [Test] - public void Test_2449() - { - } - [Test] - public void Test_2450() - { - } - [Test] - public void Test_2451() - { - } - [Test] - public void Test_2452() - { - } - [Test] - public void Test_2453() - { - } - [Test] - public void Test_2454() - { - } - [Test] - public void Test_2455() - { - } - [Test] - public void Test_2456() - { - } - [Test] - public void Test_2457() - { - } - [Test] - public void Test_2458() - { - } - [Test] - public void Test_2459() - { - } - [Test] - public void Test_2460() - { - } - [Test] - public void Test_2461() - { - } - [Test] - public void Test_2462() - { - } - [Test] - public void Test_2463() - { - } - [Test] - public void Test_2464() - { - } - [Test] - public void Test_2465() - { - } - [Test] - public void Test_2466() - { - } - [Test] - public void Test_2467() - { - } - [Test] - public void Test_2468() - { - } - [Test] - public void Test_2469() - { - } - [Test] - public void Test_2470() - { - } - [Test] - public void Test_2471() - { - } - [Test] - public void Test_2472() - { - } - [Test] - public void Test_2473() - { - } - [Test] - public void Test_2474() - { - } - [Test] - public void Test_2475() - { - } - [Test] - public void Test_2476() - { - } - [Test] - public void Test_2477() - { - } - [Test] - public void Test_2478() - { - } - [Test] - public void Test_2479() - { - } - [Test] - public void Test_2480() - { - } - [Test] - public void Test_2481() - { - } - [Test] - public void Test_2482() - { - } - [Test] - public void Test_2483() - { - } - [Test] - public void Test_2484() - { - } - [Test] - public void Test_2485() - { - } - [Test] - public void Test_2486() - { - } - [Test] - public void Test_2487() - { - } - [Test] - public void Test_2488() - { - } - [Test] - public void Test_2489() - { - } - [Test] - public void Test_2490() - { - } - [Test] - public void Test_2491() - { - } - [Test] - public void Test_2492() - { - } - [Test] - public void Test_2493() - { - } - [Test] - public void Test_2494() - { - } - [Test] - public void Test_2495() - { - } - [Test] - public void Test_2496() - { - } - [Test] - public void Test_2497() - { - } - [Test] - public void Test_2498() - { - } - [Test] - public void Test_2499() - { - } - [Test] - public void Test_2500() - { - } - [Test] - public void Test_2501() - { - } - [Test] - public void Test_2502() - { - } - [Test] - public void Test_2503() - { - } - [Test] - public void Test_2504() - { - } - [Test] - public void Test_2505() - { - } - [Test] - public void Test_2506() - { - } - [Test] - public void Test_2507() - { - } - [Test] - public void Test_2508() - { - } - [Test] - public void Test_2509() - { - } - [Test] - public void Test_2510() - { - } - [Test] - public void Test_2511() - { - } - [Test] - public void Test_2512() - { - } - [Test] - public void Test_2513() - { - } - [Test] - public void Test_2514() - { - } - [Test] - public void Test_2515() - { - } - [Test] - public void Test_2516() - { - } - [Test] - public void Test_2517() - { - } - [Test] - public void Test_2518() - { - } - [Test] - public void Test_2519() - { - } - [Test] - public void Test_2520() - { - } - [Test] - public void Test_2521() - { - } - [Test] - public void Test_2522() - { - } - [Test] - public void Test_2523() - { - } - [Test] - public void Test_2524() - { - } - [Test] - public void Test_2525() - { - } - [Test] - public void Test_2526() - { - } - [Test] - public void Test_2527() - { - } - [Test] - public void Test_2528() - { - } - [Test] - public void Test_2529() - { - } - [Test] - public void Test_2530() - { - } - [Test] - public void Test_2531() - { - } - [Test] - public void Test_2532() - { - } - [Test] - public void Test_2533() - { - } - [Test] - public void Test_2534() - { - } - [Test] - public void Test_2535() - { - } - [Test] - public void Test_2536() - { - } - [Test] - public void Test_2537() - { - } - [Test] - public void Test_2538() - { - } - [Test] - public void Test_2539() - { - } - [Test] - public void Test_2540() - { - } - [Test] - public void Test_2541() - { - } - [Test] - public void Test_2542() - { - } - [Test] - public void Test_2543() - { - } - [Test] - public void Test_2544() - { - } - [Test] - public void Test_2545() - { - } - [Test] - public void Test_2546() - { - } - [Test] - public void Test_2547() - { - } - [Test] - public void Test_2548() - { - } - [Test] - public void Test_2549() - { - } - [Test] - public void Test_2550() - { - } - [Test] - public void Test_2551() - { - } - [Test] - public void Test_2552() - { - } - [Test] - public void Test_2553() - { - } - [Test] - public void Test_2554() - { - } - [Test] - public void Test_2555() - { - } - [Test] - public void Test_2556() - { - } - [Test] - public void Test_2557() - { - } - [Test] - public void Test_2558() - { - } - [Test] - public void Test_2559() - { - } - [Test] - public void Test_2560() - { - } - [Test] - public void Test_2561() - { - } - [Test] - public void Test_2562() - { - } - [Test] - public void Test_2563() - { - } - [Test] - public void Test_2564() - { - } - [Test] - public void Test_2565() - { - } - [Test] - public void Test_2566() - { - } - [Test] - public void Test_2567() - { - } - [Test] - public void Test_2568() - { - } - [Test] - public void Test_2569() - { - } - [Test] - public void Test_2570() - { - } - [Test] - public void Test_2571() - { - } - [Test] - public void Test_2572() - { - } - [Test] - public void Test_2573() - { - } - [Test] - public void Test_2574() - { - } - [Test] - public void Test_2575() - { - } - [Test] - public void Test_2576() - { - } - [Test] - public void Test_2577() - { - } - [Test] - public void Test_2578() - { - } - [Test] - public void Test_2579() - { - } - [Test] - public void Test_2580() - { - } - [Test] - public void Test_2581() - { - } - [Test] - public void Test_2582() - { - } - [Test] - public void Test_2583() - { - } - [Test] - public void Test_2584() - { - } - [Test] - public void Test_2585() - { - } - [Test] - public void Test_2586() - { - } - [Test] - public void Test_2587() - { - } - [Test] - public void Test_2588() - { - } - [Test] - public void Test_2589() - { - } - [Test] - public void Test_2590() - { - } - [Test] - public void Test_2591() - { - } - [Test] - public void Test_2592() - { - } - [Test] - public void Test_2593() - { - } - [Test] - public void Test_2594() - { - } - [Test] - public void Test_2595() - { - } - [Test] - public void Test_2596() - { - } - [Test] - public void Test_2597() - { - } - [Test] - public void Test_2598() - { - } - [Test] - public void Test_2599() - { - } - [Test] - public void Test_2600() - { - } - [Test] - public void Test_2601() - { - } - [Test] - public void Test_2602() - { - } - [Test] - public void Test_2603() - { - } - [Test] - public void Test_2604() - { - } - [Test] - public void Test_2605() - { - } - [Test] - public void Test_2606() - { - } - [Test] - public void Test_2607() - { - } - [Test] - public void Test_2608() - { - } - [Test] - public void Test_2609() - { - } - [Test] - public void Test_2610() - { - } - [Test] - public void Test_2611() - { - } - [Test] - public void Test_2612() - { - } - [Test] - public void Test_2613() - { - } - [Test] - public void Test_2614() - { - } - [Test] - public void Test_2615() - { - } - [Test] - public void Test_2616() - { - } - [Test] - public void Test_2617() - { - } - [Test] - public void Test_2618() - { - } - [Test] - public void Test_2619() - { - } - [Test] - public void Test_2620() - { - } - [Test] - public void Test_2621() - { - } - [Test] - public void Test_2622() - { - } - [Test] - public void Test_2623() - { - } - [Test] - public void Test_2624() - { - } - [Test] - public void Test_2625() - { - } - [Test] - public void Test_2626() - { - } - [Test] - public void Test_2627() - { - } - [Test] - public void Test_2628() - { - } - [Test] - public void Test_2629() - { - } - [Test] - public void Test_2630() - { - } - [Test] - public void Test_2631() - { - } - [Test] - public void Test_2632() - { - } - [Test] - public void Test_2633() - { - } - [Test] - public void Test_2634() - { - } - [Test] - public void Test_2635() - { - } - [Test] - public void Test_2636() - { - } - [Test] - public void Test_2637() - { - } - [Test] - public void Test_2638() - { - } - [Test] - public void Test_2639() - { - } - [Test] - public void Test_2640() - { - } - [Test] - public void Test_2641() - { - } - [Test] - public void Test_2642() - { - } - [Test] - public void Test_2643() - { - } - [Test] - public void Test_2644() - { - } - [Test] - public void Test_2645() - { - } - [Test] - public void Test_2646() - { - } - [Test] - public void Test_2647() - { - } - [Test] - public void Test_2648() - { - } - [Test] - public void Test_2649() - { - } - [Test] - public void Test_2650() - { - } - [Test] - public void Test_2651() - { - } - [Test] - public void Test_2652() - { - } - [Test] - public void Test_2653() - { - } - [Test] - public void Test_2654() - { - } - [Test] - public void Test_2655() - { - } - [Test] - public void Test_2656() - { - } - [Test] - public void Test_2657() - { - } - [Test] - public void Test_2658() - { - } - [Test] - public void Test_2659() - { - } - [Test] - public void Test_2660() - { - } - [Test] - public void Test_2661() - { - } - [Test] - public void Test_2662() - { - } - [Test] - public void Test_2663() - { - } - [Test] - public void Test_2664() - { - } - [Test] - public void Test_2665() - { - } - [Test] - public void Test_2666() - { - } - [Test] - public void Test_2667() - { - } - [Test] - public void Test_2668() - { - } - [Test] - public void Test_2669() - { - } - [Test] - public void Test_2670() - { - } - [Test] - public void Test_2671() - { - } - [Test] - public void Test_2672() - { - } - [Test] - public void Test_2673() - { - } - [Test] - public void Test_2674() - { - } - [Test] - public void Test_2675() - { - } - [Test] - public void Test_2676() - { - } - [Test] - public void Test_2677() - { - } - [Test] - public void Test_2678() - { - } - [Test] - public void Test_2679() - { - } - [Test] - public void Test_2680() - { - } - [Test] - public void Test_2681() - { - } - [Test] - public void Test_2682() - { - } - [Test] - public void Test_2683() - { - } - [Test] - public void Test_2684() - { - } - [Test] - public void Test_2685() - { - } - [Test] - public void Test_2686() - { - } - [Test] - public void Test_2687() - { - } - [Test] - public void Test_2688() - { - } - [Test] - public void Test_2689() - { - } - [Test] - public void Test_2690() - { - } - [Test] - public void Test_2691() - { - } - [Test] - public void Test_2692() - { - } - [Test] - public void Test_2693() - { - } - [Test] - public void Test_2694() - { - } - [Test] - public void Test_2695() - { - } - [Test] - public void Test_2696() - { - } - [Test] - public void Test_2697() - { - } - [Test] - public void Test_2698() - { - } - [Test] - public void Test_2699() - { - } - [Test] - public void Test_2700() - { - } - [Test] - public void Test_2701() - { - } - [Test] - public void Test_2702() - { - } - [Test] - public void Test_2703() - { - } - [Test] - public void Test_2704() - { - } - [Test] - public void Test_2705() - { - } - [Test] - public void Test_2706() - { - } - [Test] - public void Test_2707() - { - } - [Test] - public void Test_2708() - { - } - [Test] - public void Test_2709() - { - } - [Test] - public void Test_2710() - { - } - [Test] - public void Test_2711() - { - } - [Test] - public void Test_2712() - { - } - [Test] - public void Test_2713() - { - } - [Test] - public void Test_2714() - { - } - [Test] - public void Test_2715() - { - } - [Test] - public void Test_2716() - { - } - [Test] - public void Test_2717() - { - } - [Test] - public void Test_2718() - { - } - [Test] - public void Test_2719() - { - } - [Test] - public void Test_2720() - { - } - [Test] - public void Test_2721() - { - } - [Test] - public void Test_2722() - { - } - [Test] - public void Test_2723() - { - } - [Test] - public void Test_2724() - { - } - [Test] - public void Test_2725() - { - } - [Test] - public void Test_2726() - { - } - [Test] - public void Test_2727() - { - } - [Test] - public void Test_2728() - { - } - [Test] - public void Test_2729() - { - } - [Test] - public void Test_2730() - { - } - [Test] - public void Test_2731() - { - } - [Test] - public void Test_2732() - { - } - [Test] - public void Test_2733() - { - } - [Test] - public void Test_2734() - { - } - [Test] - public void Test_2735() - { - } - [Test] - public void Test_2736() - { - } - [Test] - public void Test_2737() - { - } - [Test] - public void Test_2738() - { - } - [Test] - public void Test_2739() - { - } - [Test] - public void Test_2740() - { - } - [Test] - public void Test_2741() - { - } - [Test] - public void Test_2742() - { - } - [Test] - public void Test_2743() - { - } - [Test] - public void Test_2744() - { - } - [Test] - public void Test_2745() - { - } - [Test] - public void Test_2746() - { - } - [Test] - public void Test_2747() - { - } - [Test] - public void Test_2748() - { - } - [Test] - public void Test_2749() - { - } - [Test] - public void Test_2750() - { - } - [Test] - public void Test_2751() - { - } - [Test] - public void Test_2752() - { - } - [Test] - public void Test_2753() - { - } - [Test] - public void Test_2754() - { - } - [Test] - public void Test_2755() - { - } - [Test] - public void Test_2756() - { - } - [Test] - public void Test_2757() - { - } - [Test] - public void Test_2758() - { - } - [Test] - public void Test_2759() - { - } - [Test] - public void Test_2760() - { - } - [Test] - public void Test_2761() - { - } - [Test] - public void Test_2762() - { - } - [Test] - public void Test_2763() - { - } - [Test] - public void Test_2764() - { - } - [Test] - public void Test_2765() - { - } - [Test] - public void Test_2766() - { - } - [Test] - public void Test_2767() - { - } - [Test] - public void Test_2768() - { - } - [Test] - public void Test_2769() - { - } - [Test] - public void Test_2770() - { - } - [Test] - public void Test_2771() - { - } - [Test] - public void Test_2772() - { - } - [Test] - public void Test_2773() - { - } - [Test] - public void Test_2774() - { - } - [Test] - public void Test_2775() - { - } - [Test] - public void Test_2776() - { - } - [Test] - public void Test_2777() - { - } - [Test] - public void Test_2778() - { - } - [Test] - public void Test_2779() - { - } - [Test] - public void Test_2780() - { - } - [Test] - public void Test_2781() - { - } - [Test] - public void Test_2782() - { - } - [Test] - public void Test_2783() - { - } - [Test] - public void Test_2784() - { - } - [Test] - public void Test_2785() - { - } - [Test] - public void Test_2786() - { - } - [Test] - public void Test_2787() - { - } - [Test] - public void Test_2788() - { - } - [Test] - public void Test_2789() - { - } - [Test] - public void Test_2790() - { - } - [Test] - public void Test_2791() - { - } - [Test] - public void Test_2792() - { - } - [Test] - public void Test_2793() - { - } - [Test] - public void Test_2794() - { - } - [Test] - public void Test_2795() - { - } - [Test] - public void Test_2796() - { - } - [Test] - public void Test_2797() - { - } - [Test] - public void Test_2798() - { - } - [Test] - public void Test_2799() - { - } - [Test] - public void Test_2800() - { - } - [Test] - public void Test_2801() - { - } - [Test] - public void Test_2802() - { - } - [Test] - public void Test_2803() - { - } - [Test] - public void Test_2804() - { - } - [Test] - public void Test_2805() - { - } - [Test] - public void Test_2806() - { - } - [Test] - public void Test_2807() - { - } - [Test] - public void Test_2808() - { - } - [Test] - public void Test_2809() - { - } - [Test] - public void Test_2810() - { - } - [Test] - public void Test_2811() - { - } - [Test] - public void Test_2812() - { - } - [Test] - public void Test_2813() - { - } - [Test] - public void Test_2814() - { - } - [Test] - public void Test_2815() - { - } - [Test] - public void Test_2816() - { - } - [Test] - public void Test_2817() - { - } - [Test] - public void Test_2818() - { - } - [Test] - public void Test_2819() - { - } - [Test] - public void Test_2820() - { - } - [Test] - public void Test_2821() - { - } - [Test] - public void Test_2822() - { - } - [Test] - public void Test_2823() - { - } - [Test] - public void Test_2824() - { - } - [Test] - public void Test_2825() - { - } - [Test] - public void Test_2826() - { - } - [Test] - public void Test_2827() - { - } - [Test] - public void Test_2828() - { - } - [Test] - public void Test_2829() - { - } - [Test] - public void Test_2830() - { - } - [Test] - public void Test_2831() - { - } - [Test] - public void Test_2832() - { - } - [Test] - public void Test_2833() - { - } - [Test] - public void Test_2834() - { - } - [Test] - public void Test_2835() - { - } - [Test] - public void Test_2836() - { - } - [Test] - public void Test_2837() - { - } - [Test] - public void Test_2838() - { - } - [Test] - public void Test_2839() - { - } - [Test] - public void Test_2840() - { - } - [Test] - public void Test_2841() - { - } - [Test] - public void Test_2842() - { - } - [Test] - public void Test_2843() - { - } - [Test] - public void Test_2844() - { - } - [Test] - public void Test_2845() - { - } - [Test] - public void Test_2846() - { - } - [Test] - public void Test_2847() - { - } - [Test] - public void Test_2848() - { - } - [Test] - public void Test_2849() - { - } - [Test] - public void Test_2850() - { - } - [Test] - public void Test_2851() - { - } - [Test] - public void Test_2852() - { - } - [Test] - public void Test_2853() - { - } - [Test] - public void Test_2854() - { - } - [Test] - public void Test_2855() - { - } - [Test] - public void Test_2856() - { - } - [Test] - public void Test_2857() - { - } - [Test] - public void Test_2858() - { - } - [Test] - public void Test_2859() - { - } - [Test] - public void Test_2860() - { - } - [Test] - public void Test_2861() - { - } - [Test] - public void Test_2862() - { - } - [Test] - public void Test_2863() - { - } - [Test] - public void Test_2864() - { - } - [Test] - public void Test_2865() - { - } - [Test] - public void Test_2866() - { - } - [Test] - public void Test_2867() - { - } - [Test] - public void Test_2868() - { - } - [Test] - public void Test_2869() - { - } - [Test] - public void Test_2870() - { - } - [Test] - public void Test_2871() - { - } - [Test] - public void Test_2872() - { - } - [Test] - public void Test_2873() - { - } - [Test] - public void Test_2874() - { - } - [Test] - public void Test_2875() - { - } - [Test] - public void Test_2876() - { - } - [Test] - public void Test_2877() - { - } - [Test] - public void Test_2878() - { - } - [Test] - public void Test_2879() - { - } - [Test] - public void Test_2880() - { - } - [Test] - public void Test_2881() - { - } - [Test] - public void Test_2882() - { - } - [Test] - public void Test_2883() - { - } - [Test] - public void Test_2884() - { - } - [Test] - public void Test_2885() - { - } - [Test] - public void Test_2886() - { - } - [Test] - public void Test_2887() - { - } - [Test] - public void Test_2888() - { - } - [Test] - public void Test_2889() - { - } - [Test] - public void Test_2890() - { - } - [Test] - public void Test_2891() - { - } - [Test] - public void Test_2892() - { - } - [Test] - public void Test_2893() - { - } - [Test] - public void Test_2894() - { - } - [Test] - public void Test_2895() - { - } - [Test] - public void Test_2896() - { - } - [Test] - public void Test_2897() - { - } - [Test] - public void Test_2898() - { - } - [Test] - public void Test_2899() - { - } - [Test] - public void Test_2900() - { - } - [Test] - public void Test_2901() - { - } - [Test] - public void Test_2902() - { - } - [Test] - public void Test_2903() - { - } - [Test] - public void Test_2904() - { - } - [Test] - public void Test_2905() - { - } - [Test] - public void Test_2906() - { - } - [Test] - public void Test_2907() - { - } - [Test] - public void Test_2908() - { - } - [Test] - public void Test_2909() - { - } - [Test] - public void Test_2910() - { - } - [Test] - public void Test_2911() - { - } - [Test] - public void Test_2912() - { - } - [Test] - public void Test_2913() - { - } - [Test] - public void Test_2914() - { - } - [Test] - public void Test_2915() - { - } - [Test] - public void Test_2916() - { - } - [Test] - public void Test_2917() - { - } - [Test] - public void Test_2918() - { - } - [Test] - public void Test_2919() - { - } - [Test] - public void Test_2920() - { - } - [Test] - public void Test_2921() - { - } - [Test] - public void Test_2922() - { - } - [Test] - public void Test_2923() - { - } - [Test] - public void Test_2924() - { - } - [Test] - public void Test_2925() - { - } - [Test] - public void Test_2926() - { - } - [Test] - public void Test_2927() - { - } - [Test] - public void Test_2928() - { - } - [Test] - public void Test_2929() - { - } - [Test] - public void Test_2930() - { - } - [Test] - public void Test_2931() - { - } - [Test] - public void Test_2932() - { - } - [Test] - public void Test_2933() - { - } - [Test] - public void Test_2934() - { - } - [Test] - public void Test_2935() - { - } - [Test] - public void Test_2936() - { - } - [Test] - public void Test_2937() - { - } - [Test] - public void Test_2938() - { - } - [Test] - public void Test_2939() - { - } - [Test] - public void Test_2940() - { - } - [Test] - public void Test_2941() - { - } - [Test] - public void Test_2942() - { - } - [Test] - public void Test_2943() - { - } - [Test] - public void Test_2944() - { - } - [Test] - public void Test_2945() - { - } - [Test] - public void Test_2946() - { - } - [Test] - public void Test_2947() - { - } - [Test] - public void Test_2948() - { - } - [Test] - public void Test_2949() - { - } - [Test] - public void Test_2950() - { - } - [Test] - public void Test_2951() - { - } - [Test] - public void Test_2952() - { - } - [Test] - public void Test_2953() - { - } - [Test] - public void Test_2954() - { - } - [Test] - public void Test_2955() - { - } - [Test] - public void Test_2956() - { - } - [Test] - public void Test_2957() - { - } - [Test] - public void Test_2958() - { - } - [Test] - public void Test_2959() - { - } - [Test] - public void Test_2960() - { - } - [Test] - public void Test_2961() - { - } - [Test] - public void Test_2962() - { - } - [Test] - public void Test_2963() - { - } - [Test] - public void Test_2964() - { - } - [Test] - public void Test_2965() - { - } - [Test] - public void Test_2966() - { - } - [Test] - public void Test_2967() - { - } - [Test] - public void Test_2968() - { - } - [Test] - public void Test_2969() - { - } - [Test] - public void Test_2970() - { - } - [Test] - public void Test_2971() - { - } - [Test] - public void Test_2972() - { - } - [Test] - public void Test_2973() - { - } - [Test] - public void Test_2974() - { - } - [Test] - public void Test_2975() - { - } - [Test] - public void Test_2976() - { - } - [Test] - public void Test_2977() - { - } - [Test] - public void Test_2978() - { - } - [Test] - public void Test_2979() - { - } - [Test] - public void Test_2980() - { - } - [Test] - public void Test_2981() - { - } - [Test] - public void Test_2982() - { - } - [Test] - public void Test_2983() - { - } - [Test] - public void Test_2984() - { - } - [Test] - public void Test_2985() - { - } - [Test] - public void Test_2986() - { - } - [Test] - public void Test_2987() - { - } - [Test] - public void Test_2988() - { - } - [Test] - public void Test_2989() - { - } - [Test] - public void Test_2990() - { - } - [Test] - public void Test_2991() - { - } - [Test] - public void Test_2992() - { - } - [Test] - public void Test_2993() - { - } - [Test] - public void Test_2994() - { - } - [Test] - public void Test_2995() - { - } - [Test] - public void Test_2996() - { - } - [Test] - public void Test_2997() - { - } - [Test] - public void Test_2998() - { - } - [Test] - public void Test_2999() - { - } - [Test] - public void Test_3000() - { - } - [Test] - public void Test_3001() - { - } - [Test] - public void Test_3002() - { - } - [Test] - public void Test_3003() - { - } - [Test] - public void Test_3004() - { - } - [Test] - public void Test_3005() - { - } - [Test] - public void Test_3006() - { - } - [Test] - public void Test_3007() - { - } - [Test] - public void Test_3008() - { - } - [Test] - public void Test_3009() - { - } - [Test] - public void Test_3010() - { - } - [Test] - public void Test_3011() - { - } - [Test] - public void Test_3012() - { - } - [Test] - public void Test_3013() - { - } - [Test] - public void Test_3014() - { - } - [Test] - public void Test_3015() - { - } - [Test] - public void Test_3016() - { - } - [Test] - public void Test_3017() - { - } - [Test] - public void Test_3018() - { - } - [Test] - public void Test_3019() - { - } - [Test] - public void Test_3020() - { - } - [Test] - public void Test_3021() - { - } - [Test] - public void Test_3022() - { - } - [Test] - public void Test_3023() - { - } - [Test] - public void Test_3024() - { - } - [Test] - public void Test_3025() - { - } - [Test] - public void Test_3026() - { - } - [Test] - public void Test_3027() - { - } - [Test] - public void Test_3028() - { - } - [Test] - public void Test_3029() - { - } - [Test] - public void Test_3030() - { - } - [Test] - public void Test_3031() - { - } - [Test] - public void Test_3032() - { - } - [Test] - public void Test_3033() - { - } - [Test] - public void Test_3034() - { - } - [Test] - public void Test_3035() - { - } - [Test] - public void Test_3036() - { - } - [Test] - public void Test_3037() - { - } - [Test] - public void Test_3038() - { - } - [Test] - public void Test_3039() - { - } - [Test] - public void Test_3040() - { - } - [Test] - public void Test_3041() - { - } - [Test] - public void Test_3042() - { - } - [Test] - public void Test_3043() - { - } - [Test] - public void Test_3044() - { - } - [Test] - public void Test_3045() - { - } - [Test] - public void Test_3046() - { - } - [Test] - public void Test_3047() - { - } - [Test] - public void Test_3048() - { - } - [Test] - public void Test_3049() - { - } - [Test] - public void Test_3050() - { - } - [Test] - public void Test_3051() - { - } - [Test] - public void Test_3052() - { - } - [Test] - public void Test_3053() - { - } - [Test] - public void Test_3054() - { - } - [Test] - public void Test_3055() - { - } - [Test] - public void Test_3056() - { - } - [Test] - public void Test_3057() - { - } - [Test] - public void Test_3058() - { - } - [Test] - public void Test_3059() - { - } - [Test] - public void Test_3060() - { - } - [Test] - public void Test_3061() - { - } - [Test] - public void Test_3062() - { - } - [Test] - public void Test_3063() - { - } - [Test] - public void Test_3064() - { - } - [Test] - public void Test_3065() - { - } - [Test] - public void Test_3066() - { - } - [Test] - public void Test_3067() - { - } - [Test] - public void Test_3068() - { - } - [Test] - public void Test_3069() - { - } - [Test] - public void Test_3070() - { - } - [Test] - public void Test_3071() - { - } - [Test] - public void Test_3072() - { - } - [Test] - public void Test_3073() - { - } - [Test] - public void Test_3074() - { - } - [Test] - public void Test_3075() - { - } - [Test] - public void Test_3076() - { - } - [Test] - public void Test_3077() - { - } - [Test] - public void Test_3078() - { - } - [Test] - public void Test_3079() - { - } - [Test] - public void Test_3080() - { - } - [Test] - public void Test_3081() - { - } - [Test] - public void Test_3082() - { - } - [Test] - public void Test_3083() - { - } - [Test] - public void Test_3084() - { - } - [Test] - public void Test_3085() - { - } - [Test] - public void Test_3086() - { - } - [Test] - public void Test_3087() - { - } - [Test] - public void Test_3088() - { - } - [Test] - public void Test_3089() - { - } - [Test] - public void Test_3090() - { - } - [Test] - public void Test_3091() - { - } - [Test] - public void Test_3092() - { - } - [Test] - public void Test_3093() - { - } - [Test] - public void Test_3094() - { - } - [Test] - public void Test_3095() - { - } - [Test] - public void Test_3096() - { - } - [Test] - public void Test_3097() - { - } - [Test] - public void Test_3098() - { - } - [Test] - public void Test_3099() - { - } - [Test] - public void Test_3100() - { - } - [Test] - public void Test_3101() - { - } - [Test] - public void Test_3102() - { - } - [Test] - public void Test_3103() - { - } - [Test] - public void Test_3104() - { - } - [Test] - public void Test_3105() - { - } - [Test] - public void Test_3106() - { - } - [Test] - public void Test_3107() - { - } - [Test] - public void Test_3108() - { - } - [Test] - public void Test_3109() - { - } - [Test] - public void Test_3110() - { - } - [Test] - public void Test_3111() - { - } - [Test] - public void Test_3112() - { - } - [Test] - public void Test_3113() - { - } - [Test] - public void Test_3114() - { - } - [Test] - public void Test_3115() - { - } - [Test] - public void Test_3116() - { - } - [Test] - public void Test_3117() - { - } - [Test] - public void Test_3118() - { - } - [Test] - public void Test_3119() - { - } - [Test] - public void Test_3120() - { - } - [Test] - public void Test_3121() - { - } - [Test] - public void Test_3122() - { - } - [Test] - public void Test_3123() - { - } - [Test] - public void Test_3124() - { - } - [Test] - public void Test_3125() - { - } - [Test] - public void Test_3126() - { - } - [Test] - public void Test_3127() - { - } - [Test] - public void Test_3128() - { - } - [Test] - public void Test_3129() - { - } - [Test] - public void Test_3130() - { - } - [Test] - public void Test_3131() - { - } - [Test] - public void Test_3132() - { - } - [Test] - public void Test_3133() - { - } - [Test] - public void Test_3134() - { - } - [Test] - public void Test_3135() - { - } - [Test] - public void Test_3136() - { - } - [Test] - public void Test_3137() - { - } - [Test] - public void Test_3138() - { - } - [Test] - public void Test_3139() - { - } - [Test] - public void Test_3140() - { - } - [Test] - public void Test_3141() - { - } - [Test] - public void Test_3142() - { - } - [Test] - public void Test_3143() - { - } - [Test] - public void Test_3144() - { - } - [Test] - public void Test_3145() - { - } - [Test] - public void Test_3146() - { - } - [Test] - public void Test_3147() - { - } - [Test] - public void Test_3148() - { - } - [Test] - public void Test_3149() - { - } - [Test] - public void Test_3150() - { - } - [Test] - public void Test_3151() - { - } - [Test] - public void Test_3152() - { - } - [Test] - public void Test_3153() - { - } - [Test] - public void Test_3154() - { - } - [Test] - public void Test_3155() - { - } - [Test] - public void Test_3156() - { - } - [Test] - public void Test_3157() - { - } - [Test] - public void Test_3158() - { - } - [Test] - public void Test_3159() - { - } - [Test] - public void Test_3160() - { - } - [Test] - public void Test_3161() - { - } - [Test] - public void Test_3162() - { - } - [Test] - public void Test_3163() - { - } - [Test] - public void Test_3164() - { - } - [Test] - public void Test_3165() - { - } - [Test] - public void Test_3166() - { - } - [Test] - public void Test_3167() - { - } - [Test] - public void Test_3168() - { - } - [Test] - public void Test_3169() - { - } - [Test] - public void Test_3170() - { - } - [Test] - public void Test_3171() - { - } - [Test] - public void Test_3172() - { - } - [Test] - public void Test_3173() - { - } - [Test] - public void Test_3174() - { - } - [Test] - public void Test_3175() - { - } - [Test] - public void Test_3176() - { - } - [Test] - public void Test_3177() - { - } - [Test] - public void Test_3178() - { - } - [Test] - public void Test_3179() - { - } - [Test] - public void Test_3180() - { - } - [Test] - public void Test_3181() - { - } - [Test] - public void Test_3182() - { - } - [Test] - public void Test_3183() - { - } - [Test] - public void Test_3184() - { - } - [Test] - public void Test_3185() - { - } - [Test] - public void Test_3186() - { - } - [Test] - public void Test_3187() - { - } - [Test] - public void Test_3188() - { - } - [Test] - public void Test_3189() - { - } - [Test] - public void Test_3190() - { - } - [Test] - public void Test_3191() - { - } - [Test] - public void Test_3192() - { - } - [Test] - public void Test_3193() - { - } - [Test] - public void Test_3194() - { - } - [Test] - public void Test_3195() - { - } - [Test] - public void Test_3196() - { - } - [Test] - public void Test_3197() - { - } - [Test] - public void Test_3198() - { - } - [Test] - public void Test_3199() - { - } - [Test] - public void Test_3200() - { - } - [Test] - public void Test_3201() - { - } - [Test] - public void Test_3202() - { - } - [Test] - public void Test_3203() - { - } - [Test] - public void Test_3204() - { - } - [Test] - public void Test_3205() - { - } - [Test] - public void Test_3206() - { - } - [Test] - public void Test_3207() - { - } - [Test] - public void Test_3208() - { - } - [Test] - public void Test_3209() - { - } - [Test] - public void Test_3210() - { - } - [Test] - public void Test_3211() - { - } - [Test] - public void Test_3212() - { - } - [Test] - public void Test_3213() - { - } - [Test] - public void Test_3214() - { - } - [Test] - public void Test_3215() - { - } - [Test] - public void Test_3216() - { - } - [Test] - public void Test_3217() - { - } - [Test] - public void Test_3218() - { - } - [Test] - public void Test_3219() - { - } - [Test] - public void Test_3220() - { - } - [Test] - public void Test_3221() - { - } - [Test] - public void Test_3222() - { - } - [Test] - public void Test_3223() - { - } - [Test] - public void Test_3224() - { - } - [Test] - public void Test_3225() - { - } - [Test] - public void Test_3226() - { - } - [Test] - public void Test_3227() - { - } - [Test] - public void Test_3228() - { - } - [Test] - public void Test_3229() - { - } - [Test] - public void Test_3230() - { - } - [Test] - public void Test_3231() - { - } - [Test] - public void Test_3232() - { - } - [Test] - public void Test_3233() - { - } - [Test] - public void Test_3234() - { - } - [Test] - public void Test_3235() - { - } - [Test] - public void Test_3236() - { - } - [Test] - public void Test_3237() - { - } - [Test] - public void Test_3238() - { - } - [Test] - public void Test_3239() - { - } - [Test] - public void Test_3240() - { - } - [Test] - public void Test_3241() - { - } - [Test] - public void Test_3242() - { - } - [Test] - public void Test_3243() - { - } - [Test] - public void Test_3244() - { - } - [Test] - public void Test_3245() - { - } - [Test] - public void Test_3246() - { - } - [Test] - public void Test_3247() - { - } - [Test] - public void Test_3248() - { - } - [Test] - public void Test_3249() - { - } - [Test] - public void Test_3250() - { - } - [Test] - public void Test_3251() - { - } - [Test] - public void Test_3252() - { - } - [Test] - public void Test_3253() - { - } - [Test] - public void Test_3254() - { - } - [Test] - public void Test_3255() - { - } - [Test] - public void Test_3256() - { - } - [Test] - public void Test_3257() - { - } - [Test] - public void Test_3258() - { - } - [Test] - public void Test_3259() - { - } - [Test] - public void Test_3260() - { - } - [Test] - public void Test_3261() - { - } - [Test] - public void Test_3262() - { - } - [Test] - public void Test_3263() - { - } - [Test] - public void Test_3264() - { - } - [Test] - public void Test_3265() - { - } - [Test] - public void Test_3266() - { - } - [Test] - public void Test_3267() - { - } - [Test] - public void Test_3268() - { - } - [Test] - public void Test_3269() - { - } - [Test] - public void Test_3270() - { - } - [Test] - public void Test_3271() - { - } - [Test] - public void Test_3272() - { - } - [Test] - public void Test_3273() - { - } - [Test] - public void Test_3274() - { - } - [Test] - public void Test_3275() - { - } - [Test] - public void Test_3276() - { - } - [Test] - public void Test_3277() - { - } - [Test] - public void Test_3278() - { - } - [Test] - public void Test_3279() - { - } - [Test] - public void Test_3280() - { - } - [Test] - public void Test_3281() - { - } - [Test] - public void Test_3282() - { - } - [Test] - public void Test_3283() - { - } - [Test] - public void Test_3284() - { - } - [Test] - public void Test_3285() - { - } - [Test] - public void Test_3286() - { - } - [Test] - public void Test_3287() - { - } - [Test] - public void Test_3288() - { - } - [Test] - public void Test_3289() - { - } - [Test] - public void Test_3290() - { - } - [Test] - public void Test_3291() - { - } - [Test] - public void Test_3292() - { - } - [Test] - public void Test_3293() - { - } - [Test] - public void Test_3294() - { - } - [Test] - public void Test_3295() - { - } - [Test] - public void Test_3296() - { - } - [Test] - public void Test_3297() - { - } - [Test] - public void Test_3298() - { - } - [Test] - public void Test_3299() - { - } - [Test] - public void Test_3300() - { - } - [Test] - public void Test_3301() - { - } - [Test] - public void Test_3302() - { - } - [Test] - public void Test_3303() - { - } - [Test] - public void Test_3304() - { - } - [Test] - public void Test_3305() - { - } - [Test] - public void Test_3306() - { - } - [Test] - public void Test_3307() - { - } - [Test] - public void Test_3308() - { - } - [Test] - public void Test_3309() - { - } - [Test] - public void Test_3310() - { - } - [Test] - public void Test_3311() - { - } - [Test] - public void Test_3312() - { - } - [Test] - public void Test_3313() - { - } - [Test] - public void Test_3314() - { - } - [Test] - public void Test_3315() - { - } - [Test] - public void Test_3316() - { - } - [Test] - public void Test_3317() - { - } - [Test] - public void Test_3318() - { - } - [Test] - public void Test_3319() - { - } - [Test] - public void Test_3320() - { - } - [Test] - public void Test_3321() - { - } - [Test] - public void Test_3322() - { - } - [Test] - public void Test_3323() - { - } - [Test] - public void Test_3324() - { - } - [Test] - public void Test_3325() - { - } - [Test] - public void Test_3326() - { - } - [Test] - public void Test_3327() - { - } - [Test] - public void Test_3328() - { - } - [Test] - public void Test_3329() - { - } - [Test] - public void Test_3330() - { - } - [Test] - public void Test_3331() - { - } - [Test] - public void Test_3332() - { - } - [Test] - public void Test_3333() - { - } - [Test] - public void Test_3334() - { - } - [Test] - public void Test_3335() - { - } - [Test] - public void Test_3336() - { - } - [Test] - public void Test_3337() - { - } - [Test] - public void Test_3338() - { - } - [Test] - public void Test_3339() - { - } - [Test] - public void Test_3340() - { - } - [Test] - public void Test_3341() - { - } - [Test] - public void Test_3342() - { - } - [Test] - public void Test_3343() - { - } - [Test] - public void Test_3344() - { - } - [Test] - public void Test_3345() - { - } - [Test] - public void Test_3346() - { - } - [Test] - public void Test_3347() - { - } - [Test] - public void Test_3348() - { - } - [Test] - public void Test_3349() - { - } - [Test] - public void Test_3350() - { - } - [Test] - public void Test_3351() - { - } - [Test] - public void Test_3352() - { - } - [Test] - public void Test_3353() - { - } - [Test] - public void Test_3354() - { - } - [Test] - public void Test_3355() - { - } - [Test] - public void Test_3356() - { - } - [Test] - public void Test_3357() - { - } - [Test] - public void Test_3358() - { - } - [Test] - public void Test_3359() - { - } - [Test] - public void Test_3360() - { - } - [Test] - public void Test_3361() - { - } - [Test] - public void Test_3362() - { - } - [Test] - public void Test_3363() - { - } - [Test] - public void Test_3364() - { - } - [Test] - public void Test_3365() - { - } - [Test] - public void Test_3366() - { - } - [Test] - public void Test_3367() - { - } - [Test] - public void Test_3368() - { - } - [Test] - public void Test_3369() - { - } - [Test] - public void Test_3370() - { - } - [Test] - public void Test_3371() - { - } - [Test] - public void Test_3372() - { - } - [Test] - public void Test_3373() - { - } - [Test] - public void Test_3374() - { - } - [Test] - public void Test_3375() - { - } - [Test] - public void Test_3376() - { - } - [Test] - public void Test_3377() - { - } - [Test] - public void Test_3378() - { - } - [Test] - public void Test_3379() - { - } - [Test] - public void Test_3380() - { - } - [Test] - public void Test_3381() - { - } - [Test] - public void Test_3382() - { - } - [Test] - public void Test_3383() - { - } - [Test] - public void Test_3384() - { - } - [Test] - public void Test_3385() - { - } - [Test] - public void Test_3386() - { - } - [Test] - public void Test_3387() - { - } - [Test] - public void Test_3388() - { - } - [Test] - public void Test_3389() - { - } - [Test] - public void Test_3390() - { - } - [Test] - public void Test_3391() - { - } - [Test] - public void Test_3392() - { - } - [Test] - public void Test_3393() - { - } - [Test] - public void Test_3394() - { - } - [Test] - public void Test_3395() - { - } - [Test] - public void Test_3396() - { - } - [Test] - public void Test_3397() - { - } - [Test] - public void Test_3398() - { - } - [Test] - public void Test_3399() - { - } - [Test] - public void Test_3400() - { - } - [Test] - public void Test_3401() - { - } - [Test] - public void Test_3402() - { - } - [Test] - public void Test_3403() - { - } - [Test] - public void Test_3404() - { - } - [Test] - public void Test_3405() - { - } - [Test] - public void Test_3406() - { - } - [Test] - public void Test_3407() - { - } - [Test] - public void Test_3408() - { - } - [Test] - public void Test_3409() - { - } - [Test] - public void Test_3410() - { - } - [Test] - public void Test_3411() - { - } - [Test] - public void Test_3412() - { - } - [Test] - public void Test_3413() - { - } - [Test] - public void Test_3414() - { - } - [Test] - public void Test_3415() - { - } - [Test] - public void Test_3416() - { - } - [Test] - public void Test_3417() - { - } - [Test] - public void Test_3418() - { - } - [Test] - public void Test_3419() - { - } - [Test] - public void Test_3420() - { - } - [Test] - public void Test_3421() - { - } - [Test] - public void Test_3422() - { - } - [Test] - public void Test_3423() - { - } - [Test] - public void Test_3424() - { - } - [Test] - public void Test_3425() - { - } - [Test] - public void Test_3426() - { - } - [Test] - public void Test_3427() - { - } - [Test] - public void Test_3428() - { - } - [Test] - public void Test_3429() - { - } - [Test] - public void Test_3430() - { - } - [Test] - public void Test_3431() - { - } - [Test] - public void Test_3432() - { - } - [Test] - public void Test_3433() - { - } - [Test] - public void Test_3434() - { - } - [Test] - public void Test_3435() - { - } - [Test] - public void Test_3436() - { - } - [Test] - public void Test_3437() - { - } - [Test] - public void Test_3438() - { - } - [Test] - public void Test_3439() - { - } - [Test] - public void Test_3440() - { - } - [Test] - public void Test_3441() - { - } - [Test] - public void Test_3442() - { - } - [Test] - public void Test_3443() - { - } - [Test] - public void Test_3444() - { - } - [Test] - public void Test_3445() - { - } - [Test] - public void Test_3446() - { - } - [Test] - public void Test_3447() - { - } - [Test] - public void Test_3448() - { - } - [Test] - public void Test_3449() - { - } - [Test] - public void Test_3450() - { - } - [Test] - public void Test_3451() - { - } - [Test] - public void Test_3452() - { - } - [Test] - public void Test_3453() - { - } - [Test] - public void Test_3454() - { - } - [Test] - public void Test_3455() - { - } - [Test] - public void Test_3456() - { - } - [Test] - public void Test_3457() - { - } - [Test] - public void Test_3458() - { - } - [Test] - public void Test_3459() - { - } - [Test] - public void Test_3460() - { - } - [Test] - public void Test_3461() - { - } - [Test] - public void Test_3462() - { - } - [Test] - public void Test_3463() - { - } - [Test] - public void Test_3464() - { - } - [Test] - public void Test_3465() - { - } - [Test] - public void Test_3466() - { - } - [Test] - public void Test_3467() - { - } - [Test] - public void Test_3468() - { - } - [Test] - public void Test_3469() - { - } - [Test] - public void Test_3470() - { - } - [Test] - public void Test_3471() - { - } - [Test] - public void Test_3472() - { - } - [Test] - public void Test_3473() - { - } - [Test] - public void Test_3474() - { - } - [Test] - public void Test_3475() - { - } - [Test] - public void Test_3476() - { - } - [Test] - public void Test_3477() - { - } - [Test] - public void Test_3478() - { - } - [Test] - public void Test_3479() - { - } - [Test] - public void Test_3480() - { - } - [Test] - public void Test_3481() - { - } - [Test] - public void Test_3482() - { - } - [Test] - public void Test_3483() - { - } - [Test] - public void Test_3484() - { - } - [Test] - public void Test_3485() - { - } - [Test] - public void Test_3486() - { - } - [Test] - public void Test_3487() - { - } - [Test] - public void Test_3488() - { - } - [Test] - public void Test_3489() - { - } - [Test] - public void Test_3490() - { - } - [Test] - public void Test_3491() - { - } - [Test] - public void Test_3492() - { - } - [Test] - public void Test_3493() - { - } - [Test] - public void Test_3494() - { - } - [Test] - public void Test_3495() - { - } - [Test] - public void Test_3496() - { - } - [Test] - public void Test_3497() - { - } - [Test] - public void Test_3498() - { - } - [Test] - public void Test_3499() - { - } - [Test] - public void Test_3500() - { - } - [Test] - public void Test_3501() - { - } - [Test] - public void Test_3502() - { - } - [Test] - public void Test_3503() - { - } - [Test] - public void Test_3504() - { - } - [Test] - public void Test_3505() - { - } - [Test] - public void Test_3506() - { - } - [Test] - public void Test_3507() - { - } - [Test] - public void Test_3508() - { - } - [Test] - public void Test_3509() - { - } - [Test] - public void Test_3510() - { - } - [Test] - public void Test_3511() - { - } - [Test] - public void Test_3512() - { - } - [Test] - public void Test_3513() - { - } - [Test] - public void Test_3514() - { - } - [Test] - public void Test_3515() - { - } - [Test] - public void Test_3516() - { - } - [Test] - public void Test_3517() - { - } - [Test] - public void Test_3518() - { - } - [Test] - public void Test_3519() - { - } - [Test] - public void Test_3520() - { - } - [Test] - public void Test_3521() - { - } - [Test] - public void Test_3522() - { - } - [Test] - public void Test_3523() - { - } - [Test] - public void Test_3524() - { - } - [Test] - public void Test_3525() - { - } - [Test] - public void Test_3526() - { - } - [Test] - public void Test_3527() - { - } - [Test] - public void Test_3528() - { - } - [Test] - public void Test_3529() - { - } - [Test] - public void Test_3530() - { - } - [Test] - public void Test_3531() - { - } - [Test] - public void Test_3532() - { - } - [Test] - public void Test_3533() - { - } - [Test] - public void Test_3534() - { - } - [Test] - public void Test_3535() - { - } - [Test] - public void Test_3536() - { - } - [Test] - public void Test_3537() - { - } - [Test] - public void Test_3538() - { - } - [Test] - public void Test_3539() - { - } - [Test] - public void Test_3540() - { - } - [Test] - public void Test_3541() - { - } - [Test] - public void Test_3542() - { - } - [Test] - public void Test_3543() - { - } - [Test] - public void Test_3544() - { - } - [Test] - public void Test_3545() - { - } - [Test] - public void Test_3546() - { - } - [Test] - public void Test_3547() - { - } - [Test] - public void Test_3548() - { - } - [Test] - public void Test_3549() - { - } - [Test] - public void Test_3550() - { - } - [Test] - public void Test_3551() - { - } - [Test] - public void Test_3552() - { - } - [Test] - public void Test_3553() - { - } - [Test] - public void Test_3554() - { - } - [Test] - public void Test_3555() - { - } - [Test] - public void Test_3556() - { - } - [Test] - public void Test_3557() - { - } - [Test] - public void Test_3558() - { - } - [Test] - public void Test_3559() - { - } - [Test] - public void Test_3560() - { - } - [Test] - public void Test_3561() - { - } - [Test] - public void Test_3562() - { - } - [Test] - public void Test_3563() - { - } - [Test] - public void Test_3564() - { - } - [Test] - public void Test_3565() - { - } - [Test] - public void Test_3566() - { - } - [Test] - public void Test_3567() - { - } - [Test] - public void Test_3568() - { - } - [Test] - public void Test_3569() - { - } - [Test] - public void Test_3570() - { - } - [Test] - public void Test_3571() - { - } - [Test] - public void Test_3572() - { - } - [Test] - public void Test_3573() - { - } - [Test] - public void Test_3574() - { - } - [Test] - public void Test_3575() - { - } - [Test] - public void Test_3576() - { - } - [Test] - public void Test_3577() - { - } - [Test] - public void Test_3578() - { - } - [Test] - public void Test_3579() - { - } - [Test] - public void Test_3580() - { - } - [Test] - public void Test_3581() - { - } - [Test] - public void Test_3582() - { - } - [Test] - public void Test_3583() - { - } - [Test] - public void Test_3584() - { - } - [Test] - public void Test_3585() - { - } - [Test] - public void Test_3586() - { - } - [Test] - public void Test_3587() - { - } - [Test] - public void Test_3588() - { - } - [Test] - public void Test_3589() - { - } - [Test] - public void Test_3590() - { - } - [Test] - public void Test_3591() - { - } - [Test] - public void Test_3592() - { - } - [Test] - public void Test_3593() - { - } - [Test] - public void Test_3594() - { - } - [Test] - public void Test_3595() - { - } - [Test] - public void Test_3596() - { - } - [Test] - public void Test_3597() - { - } - [Test] - public void Test_3598() - { - } - [Test] - public void Test_3599() - { - } - [Test] - public void Test_3600() - { - } - [Test] - public void Test_3601() - { - } - [Test] - public void Test_3602() - { - } - [Test] - public void Test_3603() - { - } - [Test] - public void Test_3604() - { - } - [Test] - public void Test_3605() - { - } - [Test] - public void Test_3606() - { - } - [Test] - public void Test_3607() - { - } - [Test] - public void Test_3608() - { - } - [Test] - public void Test_3609() - { - } - [Test] - public void Test_3610() - { - } - [Test] - public void Test_3611() - { - } - [Test] - public void Test_3612() - { - } - [Test] - public void Test_3613() - { - } - [Test] - public void Test_3614() - { - } - [Test] - public void Test_3615() - { - } - [Test] - public void Test_3616() - { - } - [Test] - public void Test_3617() - { - } - [Test] - public void Test_3618() - { - } - [Test] - public void Test_3619() - { - } - [Test] - public void Test_3620() - { - } - [Test] - public void Test_3621() - { - } - [Test] - public void Test_3622() - { - } - [Test] - public void Test_3623() - { - } - [Test] - public void Test_3624() - { - } - [Test] - public void Test_3625() - { - } - [Test] - public void Test_3626() - { - } - [Test] - public void Test_3627() - { - } - [Test] - public void Test_3628() - { - } - [Test] - public void Test_3629() - { - } - [Test] - public void Test_3630() - { - } - [Test] - public void Test_3631() - { - } - [Test] - public void Test_3632() - { - } - [Test] - public void Test_3633() - { - } - [Test] - public void Test_3634() - { - } - [Test] - public void Test_3635() - { - } - [Test] - public void Test_3636() - { - } - [Test] - public void Test_3637() - { - } - [Test] - public void Test_3638() - { - } - [Test] - public void Test_3639() - { - } - [Test] - public void Test_3640() - { - } - [Test] - public void Test_3641() - { - } - [Test] - public void Test_3642() - { - } - [Test] - public void Test_3643() - { - } - [Test] - public void Test_3644() - { - } - [Test] - public void Test_3645() - { - } - [Test] - public void Test_3646() - { - } - [Test] - public void Test_3647() - { - } - [Test] - public void Test_3648() - { - } - [Test] - public void Test_3649() - { - } - [Test] - public void Test_3650() - { - } - [Test] - public void Test_3651() - { - } - [Test] - public void Test_3652() - { - } - [Test] - public void Test_3653() - { - } - [Test] - public void Test_3654() - { - } - [Test] - public void Test_3655() - { - } - [Test] - public void Test_3656() - { - } - [Test] - public void Test_3657() - { - } - [Test] - public void Test_3658() - { - } - [Test] - public void Test_3659() - { - } - [Test] - public void Test_3660() - { - } - [Test] - public void Test_3661() - { - } - [Test] - public void Test_3662() - { - } - [Test] - public void Test_3663() - { - } - [Test] - public void Test_3664() - { - } - [Test] - public void Test_3665() - { - } - [Test] - public void Test_3666() - { - } - [Test] - public void Test_3667() - { - } - [Test] - public void Test_3668() - { - } - [Test] - public void Test_3669() - { - } - [Test] - public void Test_3670() - { - } - [Test] - public void Test_3671() - { - } - [Test] - public void Test_3672() - { - } - [Test] - public void Test_3673() - { - } - [Test] - public void Test_3674() - { - } - [Test] - public void Test_3675() - { - } - [Test] - public void Test_3676() - { - } - [Test] - public void Test_3677() - { - } - [Test] - public void Test_3678() - { - } - [Test] - public void Test_3679() - { - } - [Test] - public void Test_3680() - { - } - [Test] - public void Test_3681() - { - } - [Test] - public void Test_3682() - { - } - [Test] - public void Test_3683() - { - } - [Test] - public void Test_3684() - { - } - [Test] - public void Test_3685() - { - } - [Test] - public void Test_3686() - { - } - [Test] - public void Test_3687() - { - } - [Test] - public void Test_3688() - { - } - [Test] - public void Test_3689() - { - } - [Test] - public void Test_3690() - { - } - [Test] - public void Test_3691() - { - } - [Test] - public void Test_3692() - { - } - [Test] - public void Test_3693() - { - } - [Test] - public void Test_3694() - { - } - [Test] - public void Test_3695() - { - } - [Test] - public void Test_3696() - { - } - [Test] - public void Test_3697() - { - } - [Test] - public void Test_3698() - { - } - [Test] - public void Test_3699() - { - } - [Test] - public void Test_3700() - { - } - [Test] - public void Test_3701() - { - } - [Test] - public void Test_3702() - { - } - [Test] - public void Test_3703() - { - } - [Test] - public void Test_3704() - { - } - [Test] - public void Test_3705() - { - } - [Test] - public void Test_3706() - { - } - [Test] - public void Test_3707() - { - } - [Test] - public void Test_3708() - { - } - [Test] - public void Test_3709() - { - } - [Test] - public void Test_3710() - { - } - [Test] - public void Test_3711() - { - } - [Test] - public void Test_3712() - { - } - [Test] - public void Test_3713() - { - } - [Test] - public void Test_3714() - { - } - [Test] - public void Test_3715() - { - } - [Test] - public void Test_3716() - { - } - [Test] - public void Test_3717() - { - } - [Test] - public void Test_3718() - { - } - [Test] - public void Test_3719() - { - } - [Test] - public void Test_3720() - { - } - [Test] - public void Test_3721() - { - } - [Test] - public void Test_3722() - { - } - [Test] - public void Test_3723() - { - } - [Test] - public void Test_3724() - { - } - [Test] - public void Test_3725() - { - } - [Test] - public void Test_3726() - { - } - [Test] - public void Test_3727() - { - } - [Test] - public void Test_3728() - { - } - [Test] - public void Test_3729() - { - } - [Test] - public void Test_3730() - { - } - [Test] - public void Test_3731() - { - } - [Test] - public void Test_3732() - { - } - [Test] - public void Test_3733() - { - } - [Test] - public void Test_3734() - { - } - [Test] - public void Test_3735() - { - } - [Test] - public void Test_3736() - { - } - [Test] - public void Test_3737() - { - } - [Test] - public void Test_3738() - { - } - [Test] - public void Test_3739() - { - } - [Test] - public void Test_3740() - { - } - [Test] - public void Test_3741() - { - } - [Test] - public void Test_3742() - { - } - [Test] - public void Test_3743() - { - } - [Test] - public void Test_3744() - { - } - [Test] - public void Test_3745() - { - } - [Test] - public void Test_3746() - { - } - [Test] - public void Test_3747() - { - } - [Test] - public void Test_3748() - { - } - [Test] - public void Test_3749() - { - } - [Test] - public void Test_3750() - { - } - [Test] - public void Test_3751() - { - } - [Test] - public void Test_3752() - { - } - [Test] - public void Test_3753() - { - } - [Test] - public void Test_3754() - { - } - [Test] - public void Test_3755() - { - } - [Test] - public void Test_3756() - { - } - [Test] - public void Test_3757() - { - } - [Test] - public void Test_3758() - { - } - [Test] - public void Test_3759() - { - } - [Test] - public void Test_3760() - { - } - [Test] - public void Test_3761() - { - } - [Test] - public void Test_3762() - { - } - [Test] - public void Test_3763() - { - } - [Test] - public void Test_3764() - { - } - [Test] - public void Test_3765() - { - } - [Test] - public void Test_3766() - { - } - [Test] - public void Test_3767() - { - } - [Test] - public void Test_3768() - { - } - [Test] - public void Test_3769() - { - } - [Test] - public void Test_3770() - { - } - [Test] - public void Test_3771() - { - } - [Test] - public void Test_3772() - { - } - [Test] - public void Test_3773() - { - } - [Test] - public void Test_3774() - { - } - [Test] - public void Test_3775() - { - } - [Test] - public void Test_3776() - { - } - [Test] - public void Test_3777() - { - } - [Test] - public void Test_3778() - { - } - [Test] - public void Test_3779() - { - } - [Test] - public void Test_3780() - { - } - [Test] - public void Test_3781() - { - } - [Test] - public void Test_3782() - { - } - [Test] - public void Test_3783() - { - } - [Test] - public void Test_3784() - { - } - [Test] - public void Test_3785() - { - } - [Test] - public void Test_3786() - { - } - [Test] - public void Test_3787() - { - } - [Test] - public void Test_3788() - { - } - [Test] - public void Test_3789() - { - } - [Test] - public void Test_3790() - { - } - [Test] - public void Test_3791() - { - } - [Test] - public void Test_3792() - { - } - [Test] - public void Test_3793() - { - } - [Test] - public void Test_3794() - { - } - [Test] - public void Test_3795() - { - } - [Test] - public void Test_3796() - { - } - [Test] - public void Test_3797() - { - } - [Test] - public void Test_3798() - { - } - [Test] - public void Test_3799() - { - } - [Test] - public void Test_3800() - { - } - [Test] - public void Test_3801() - { - } - [Test] - public void Test_3802() - { - } - [Test] - public void Test_3803() - { - } - [Test] - public void Test_3804() - { - } - [Test] - public void Test_3805() - { - } - [Test] - public void Test_3806() - { - } - [Test] - public void Test_3807() - { - } - [Test] - public void Test_3808() - { - } - [Test] - public void Test_3809() - { - } - [Test] - public void Test_3810() - { - } - [Test] - public void Test_3811() - { - } - [Test] - public void Test_3812() - { - } - [Test] - public void Test_3813() - { - } - [Test] - public void Test_3814() - { - } - [Test] - public void Test_3815() - { - } - [Test] - public void Test_3816() - { - } - [Test] - public void Test_3817() - { - } - [Test] - public void Test_3818() - { - } - [Test] - public void Test_3819() - { - } - [Test] - public void Test_3820() - { - } - [Test] - public void Test_3821() - { - } - [Test] - public void Test_3822() - { - } - [Test] - public void Test_3823() - { - } - [Test] - public void Test_3824() - { - } - [Test] - public void Test_3825() - { - } - [Test] - public void Test_3826() - { - } - [Test] - public void Test_3827() - { - } - [Test] - public void Test_3828() - { - } - [Test] - public void Test_3829() - { - } - [Test] - public void Test_3830() - { - } - [Test] - public void Test_3831() - { - } - [Test] - public void Test_3832() - { - } - [Test] - public void Test_3833() - { - } - [Test] - public void Test_3834() - { - } - [Test] - public void Test_3835() - { - } - [Test] - public void Test_3836() - { - } - [Test] - public void Test_3837() - { - } - [Test] - public void Test_3838() - { - } - [Test] - public void Test_3839() - { - } - [Test] - public void Test_3840() - { - } - [Test] - public void Test_3841() - { - } - [Test] - public void Test_3842() - { - } - [Test] - public void Test_3843() - { - } - [Test] - public void Test_3844() - { - } - [Test] - public void Test_3845() - { - } - [Test] - public void Test_3846() - { - } - [Test] - public void Test_3847() - { - } - [Test] - public void Test_3848() - { - } - [Test] - public void Test_3849() - { - } - [Test] - public void Test_3850() - { - } - [Test] - public void Test_3851() - { - } - [Test] - public void Test_3852() - { - } - [Test] - public void Test_3853() - { - } - [Test] - public void Test_3854() - { - } - [Test] - public void Test_3855() - { - } - [Test] - public void Test_3856() - { - } - [Test] - public void Test_3857() - { - } - [Test] - public void Test_3858() - { - } - [Test] - public void Test_3859() - { - } - [Test] - public void Test_3860() - { - } - [Test] - public void Test_3861() - { - } - [Test] - public void Test_3862() - { - } - [Test] - public void Test_3863() - { - } - [Test] - public void Test_3864() - { - } - [Test] - public void Test_3865() - { - } - [Test] - public void Test_3866() - { - } - [Test] - public void Test_3867() - { - } - [Test] - public void Test_3868() - { - } - [Test] - public void Test_3869() - { - } - [Test] - public void Test_3870() - { - } - [Test] - public void Test_3871() - { - } - [Test] - public void Test_3872() - { - } - [Test] - public void Test_3873() - { - } - [Test] - public void Test_3874() - { - } - [Test] - public void Test_3875() - { - } - [Test] - public void Test_3876() - { - } - [Test] - public void Test_3877() - { - } - [Test] - public void Test_3878() - { - } - [Test] - public void Test_3879() - { - } - [Test] - public void Test_3880() - { - } - [Test] - public void Test_3881() - { - } - [Test] - public void Test_3882() - { - } - [Test] - public void Test_3883() - { - } - [Test] - public void Test_3884() - { - } - [Test] - public void Test_3885() - { - } - [Test] - public void Test_3886() - { - } - [Test] - public void Test_3887() - { - } - [Test] - public void Test_3888() - { - } - [Test] - public void Test_3889() - { - } - [Test] - public void Test_3890() - { - } - [Test] - public void Test_3891() - { - } - [Test] - public void Test_3892() - { - } - [Test] - public void Test_3893() - { - } - [Test] - public void Test_3894() - { - } - [Test] - public void Test_3895() - { - } - [Test] - public void Test_3896() - { - } - [Test] - public void Test_3897() - { - } - [Test] - public void Test_3898() - { - } - [Test] - public void Test_3899() - { - } - [Test] - public void Test_3900() - { - } - [Test] - public void Test_3901() - { - } - [Test] - public void Test_3902() - { - } - [Test] - public void Test_3903() - { - } - [Test] - public void Test_3904() - { - } - [Test] - public void Test_3905() - { - } - [Test] - public void Test_3906() - { - } - [Test] - public void Test_3907() - { - } - [Test] - public void Test_3908() - { - } - [Test] - public void Test_3909() - { - } - [Test] - public void Test_3910() - { - } - [Test] - public void Test_3911() - { - } - [Test] - public void Test_3912() - { - } - [Test] - public void Test_3913() - { - } - [Test] - public void Test_3914() - { - } - [Test] - public void Test_3915() - { - } - [Test] - public void Test_3916() - { - } - [Test] - public void Test_3917() - { - } - [Test] - public void Test_3918() - { - } - [Test] - public void Test_3919() - { - } - [Test] - public void Test_3920() - { - } - [Test] - public void Test_3921() - { - } - [Test] - public void Test_3922() - { - } - [Test] - public void Test_3923() - { - } - [Test] - public void Test_3924() - { - } - [Test] - public void Test_3925() - { - } - [Test] - public void Test_3926() - { - } - [Test] - public void Test_3927() - { - } - [Test] - public void Test_3928() - { - } - [Test] - public void Test_3929() - { - } - [Test] - public void Test_3930() - { - } - [Test] - public void Test_3931() - { - } - [Test] - public void Test_3932() - { - } - [Test] - public void Test_3933() - { - } - [Test] - public void Test_3934() - { - } - [Test] - public void Test_3935() - { - } - [Test] - public void Test_3936() - { - } - [Test] - public void Test_3937() - { - } - [Test] - public void Test_3938() - { - } - [Test] - public void Test_3939() - { - } - [Test] - public void Test_3940() - { - } - [Test] - public void Test_3941() - { - } - [Test] - public void Test_3942() - { - } - [Test] - public void Test_3943() - { - } - [Test] - public void Test_3944() - { - } - [Test] - public void Test_3945() - { - } - [Test] - public void Test_3946() - { - } - [Test] - public void Test_3947() - { - } - [Test] - public void Test_3948() - { - } - [Test] - public void Test_3949() - { - } - [Test] - public void Test_3950() - { - } - [Test] - public void Test_3951() - { - } - [Test] - public void Test_3952() - { - } - [Test] - public void Test_3953() - { - } - [Test] - public void Test_3954() - { - } - [Test] - public void Test_3955() - { - } - [Test] - public void Test_3956() - { - } - [Test] - public void Test_3957() - { - } - [Test] - public void Test_3958() - { - } - [Test] - public void Test_3959() - { - } - [Test] - public void Test_3960() - { - } - [Test] - public void Test_3961() - { - } - [Test] - public void Test_3962() - { - } - [Test] - public void Test_3963() - { - } - [Test] - public void Test_3964() - { - } - [Test] - public void Test_3965() - { - } - [Test] - public void Test_3966() - { - } - [Test] - public void Test_3967() - { - } - [Test] - public void Test_3968() - { - } - [Test] - public void Test_3969() - { - } - [Test] - public void Test_3970() - { - } - [Test] - public void Test_3971() - { - } - [Test] - public void Test_3972() - { - } - [Test] - public void Test_3973() - { - } - [Test] - public void Test_3974() - { - } - [Test] - public void Test_3975() - { - } - [Test] - public void Test_3976() - { - } - [Test] - public void Test_3977() - { - } - [Test] - public void Test_3978() - { - } - [Test] - public void Test_3979() - { - } - [Test] - public void Test_3980() - { - } - [Test] - public void Test_3981() - { - } - [Test] - public void Test_3982() - { - } - [Test] - public void Test_3983() - { - } - [Test] - public void Test_3984() - { - } - [Test] - public void Test_3985() - { - } - [Test] - public void Test_3986() - { - } - [Test] - public void Test_3987() - { - } - [Test] - public void Test_3988() - { - } - [Test] - public void Test_3989() - { - } - [Test] - public void Test_3990() - { - } - [Test] - public void Test_3991() - { - } - [Test] - public void Test_3992() - { - } - [Test] - public void Test_3993() - { - } - [Test] - public void Test_3994() - { - } - [Test] - public void Test_3995() - { - } - [Test] - public void Test_3996() - { - } - [Test] - public void Test_3997() - { - } - [Test] - public void Test_3998() - { - } - [Test] - public void Test_3999() - { - } - [Test] - public void Test_4000() - { - } - [Test] - public void Test_4001() - { - } - [Test] - public void Test_4002() - { - } - [Test] - public void Test_4003() - { - } - [Test] - public void Test_4004() - { - } - [Test] - public void Test_4005() - { - } - [Test] - public void Test_4006() - { - } - [Test] - public void Test_4007() - { - } - [Test] - public void Test_4008() - { - } - [Test] - public void Test_4009() - { - } - [Test] - public void Test_4010() - { - } - [Test] - public void Test_4011() - { - } - [Test] - public void Test_4012() - { - } - [Test] - public void Test_4013() - { - } - [Test] - public void Test_4014() - { - } - [Test] - public void Test_4015() - { - } - [Test] - public void Test_4016() - { - } - [Test] - public void Test_4017() - { - } - [Test] - public void Test_4018() - { - } - [Test] - public void Test_4019() - { - } - [Test] - public void Test_4020() - { - } - [Test] - public void Test_4021() - { - } - [Test] - public void Test_4022() - { - } - [Test] - public void Test_4023() - { - } - [Test] - public void Test_4024() - { - } - [Test] - public void Test_4025() - { - } - [Test] - public void Test_4026() - { - } - [Test] - public void Test_4027() - { - } - [Test] - public void Test_4028() - { - } - [Test] - public void Test_4029() - { - } - [Test] - public void Test_4030() - { - } - [Test] - public void Test_4031() - { - } - [Test] - public void Test_4032() - { - } - [Test] - public void Test_4033() - { - } - [Test] - public void Test_4034() - { - } - [Test] - public void Test_4035() - { - } - [Test] - public void Test_4036() - { - } - [Test] - public void Test_4037() - { - } - [Test] - public void Test_4038() - { - } - [Test] - public void Test_4039() - { - } - [Test] - public void Test_4040() - { - } - [Test] - public void Test_4041() - { - } - [Test] - public void Test_4042() - { - } - [Test] - public void Test_4043() - { - } - [Test] - public void Test_4044() - { - } - [Test] - public void Test_4045() - { - } - [Test] - public void Test_4046() - { - } - [Test] - public void Test_4047() - { - } - [Test] - public void Test_4048() - { - } - [Test] - public void Test_4049() - { - } - [Test] - public void Test_4050() - { - } - [Test] - public void Test_4051() - { - } - [Test] - public void Test_4052() - { - } - [Test] - public void Test_4053() - { - } - [Test] - public void Test_4054() - { - } - [Test] - public void Test_4055() - { - } - [Test] - public void Test_4056() - { - } - [Test] - public void Test_4057() - { - } - [Test] - public void Test_4058() - { - } - [Test] - public void Test_4059() - { - } - [Test] - public void Test_4060() - { - } - [Test] - public void Test_4061() - { - } - [Test] - public void Test_4062() - { - } - [Test] - public void Test_4063() - { - } - [Test] - public void Test_4064() - { - } - [Test] - public void Test_4065() - { - } - [Test] - public void Test_4066() - { - } - [Test] - public void Test_4067() - { - } - [Test] - public void Test_4068() - { - } - [Test] - public void Test_4069() - { - } - [Test] - public void Test_4070() - { - } - [Test] - public void Test_4071() - { - } - [Test] - public void Test_4072() - { - } - [Test] - public void Test_4073() - { - } - [Test] - public void Test_4074() - { - } - [Test] - public void Test_4075() - { - } - [Test] - public void Test_4076() - { - } - [Test] - public void Test_4077() - { - } - [Test] - public void Test_4078() - { - } - [Test] - public void Test_4079() - { - } - [Test] - public void Test_4080() - { - } - [Test] - public void Test_4081() - { - } - [Test] - public void Test_4082() - { - } - [Test] - public void Test_4083() - { - } - [Test] - public void Test_4084() - { - } - [Test] - public void Test_4085() - { - } - [Test] - public void Test_4086() - { - } - [Test] - public void Test_4087() - { - } - [Test] - public void Test_4088() - { - } - [Test] - public void Test_4089() - { - } - [Test] - public void Test_4090() - { - } - [Test] - public void Test_4091() - { - } - [Test] - public void Test_4092() - { - } - [Test] - public void Test_4093() - { - } - [Test] - public void Test_4094() - { - } - [Test] - public void Test_4095() - { - } - [Test] - public void Test_4096() - { - } - [Test] - public void Test_4097() - { - } - [Test] - public void Test_4098() - { - } - [Test] - public void Test_4099() - { - } - [Test] - public void Test_4100() - { - } - [Test] - public void Test_4101() - { - } - [Test] - public void Test_4102() - { - } - [Test] - public void Test_4103() - { - } - [Test] - public void Test_4104() - { - } - [Test] - public void Test_4105() - { - } - [Test] - public void Test_4106() - { - } - [Test] - public void Test_4107() - { - } - [Test] - public void Test_4108() - { - } - [Test] - public void Test_4109() - { - } - [Test] - public void Test_4110() - { - } - [Test] - public void Test_4111() - { - } - [Test] - public void Test_4112() - { - } - [Test] - public void Test_4113() - { - } - [Test] - public void Test_4114() - { - } - [Test] - public void Test_4115() - { - } - [Test] - public void Test_4116() - { - } - [Test] - public void Test_4117() - { - } - [Test] - public void Test_4118() - { - } - [Test] - public void Test_4119() - { - } - [Test] - public void Test_4120() - { - } - [Test] - public void Test_4121() - { - } - [Test] - public void Test_4122() - { - } - [Test] - public void Test_4123() - { - } - [Test] - public void Test_4124() - { - } - [Test] - public void Test_4125() - { - } - [Test] - public void Test_4126() - { - } - [Test] - public void Test_4127() - { - } - [Test] - public void Test_4128() - { - } - [Test] - public void Test_4129() - { - } - [Test] - public void Test_4130() - { - } - [Test] - public void Test_4131() - { - } - [Test] - public void Test_4132() - { - } - [Test] - public void Test_4133() - { - } - [Test] - public void Test_4134() - { - } - [Test] - public void Test_4135() - { - } - [Test] - public void Test_4136() - { - } - [Test] - public void Test_4137() - { - } - [Test] - public void Test_4138() - { - } - [Test] - public void Test_4139() - { - } - [Test] - public void Test_4140() - { - } - [Test] - public void Test_4141() - { - } - [Test] - public void Test_4142() - { - } - [Test] - public void Test_4143() - { - } - [Test] - public void Test_4144() - { - } - [Test] - public void Test_4145() - { - } - [Test] - public void Test_4146() - { - } - [Test] - public void Test_4147() - { - } - [Test] - public void Test_4148() - { - } - [Test] - public void Test_4149() - { - } - [Test] - public void Test_4150() - { - } - [Test] - public void Test_4151() - { - } - [Test] - public void Test_4152() - { - } - [Test] - public void Test_4153() - { - } - [Test] - public void Test_4154() - { - } - [Test] - public void Test_4155() - { - } - [Test] - public void Test_4156() - { - } - [Test] - public void Test_4157() - { - } - [Test] - public void Test_4158() - { - } - [Test] - public void Test_4159() - { - } - [Test] - public void Test_4160() - { - } - [Test] - public void Test_4161() - { - } - [Test] - public void Test_4162() - { - } - [Test] - public void Test_4163() - { - } - [Test] - public void Test_4164() - { - } - [Test] - public void Test_4165() - { - } - [Test] - public void Test_4166() - { - } - [Test] - public void Test_4167() - { - } - [Test] - public void Test_4168() - { - } - [Test] - public void Test_4169() - { - } - [Test] - public void Test_4170() - { - } - [Test] - public void Test_4171() - { - } - [Test] - public void Test_4172() - { - } - [Test] - public void Test_4173() - { - } - [Test] - public void Test_4174() - { - } - [Test] - public void Test_4175() - { - } - [Test] - public void Test_4176() - { - } - [Test] - public void Test_4177() - { - } - [Test] - public void Test_4178() - { - } - [Test] - public void Test_4179() - { - } - [Test] - public void Test_4180() - { - } - [Test] - public void Test_4181() - { - } - [Test] - public void Test_4182() - { - } - [Test] - public void Test_4183() - { - } - [Test] - public void Test_4184() - { - } - [Test] - public void Test_4185() - { - } - [Test] - public void Test_4186() - { - } - [Test] - public void Test_4187() - { - } - [Test] - public void Test_4188() - { - } - [Test] - public void Test_4189() - { - } - [Test] - public void Test_4190() - { - } - [Test] - public void Test_4191() - { - } - [Test] - public void Test_4192() - { - } - [Test] - public void Test_4193() - { - } - [Test] - public void Test_4194() - { - } - [Test] - public void Test_4195() - { - } - [Test] - public void Test_4196() - { - } - [Test] - public void Test_4197() - { - } - [Test] - public void Test_4198() - { - } - [Test] - public void Test_4199() - { - } - [Test] - public void Test_4200() - { - } - [Test] - public void Test_4201() - { - } - [Test] - public void Test_4202() - { - } - [Test] - public void Test_4203() - { - } - [Test] - public void Test_4204() - { - } - [Test] - public void Test_4205() - { - } - [Test] - public void Test_4206() - { - } - [Test] - public void Test_4207() - { - } - [Test] - public void Test_4208() - { - } - [Test] - public void Test_4209() - { - } - [Test] - public void Test_4210() - { - } - [Test] - public void Test_4211() - { - } - [Test] - public void Test_4212() - { - } - [Test] - public void Test_4213() - { - } - [Test] - public void Test_4214() - { - } - [Test] - public void Test_4215() - { - } - [Test] - public void Test_4216() - { - } - [Test] - public void Test_4217() - { - } - [Test] - public void Test_4218() - { - } - [Test] - public void Test_4219() - { - } - [Test] - public void Test_4220() - { - } - [Test] - public void Test_4221() - { - } - [Test] - public void Test_4222() - { - } - [Test] - public void Test_4223() - { - } - [Test] - public void Test_4224() - { - } - [Test] - public void Test_4225() - { - } - [Test] - public void Test_4226() - { - } - [Test] - public void Test_4227() - { - } - [Test] - public void Test_4228() - { - } - [Test] - public void Test_4229() - { - } - [Test] - public void Test_4230() - { - } - [Test] - public void Test_4231() - { - } - [Test] - public void Test_4232() - { - } - [Test] - public void Test_4233() - { - } - [Test] - public void Test_4234() - { - } - [Test] - public void Test_4235() - { - } - [Test] - public void Test_4236() - { - } - [Test] - public void Test_4237() - { - } - [Test] - public void Test_4238() - { - } - [Test] - public void Test_4239() - { - } - [Test] - public void Test_4240() - { - } - [Test] - public void Test_4241() - { - } - [Test] - public void Test_4242() - { - } - [Test] - public void Test_4243() - { - } - [Test] - public void Test_4244() - { - } - [Test] - public void Test_4245() - { - } - [Test] - public void Test_4246() - { - } - [Test] - public void Test_4247() - { - } - [Test] - public void Test_4248() - { - } - [Test] - public void Test_4249() - { - } - [Test] - public void Test_4250() - { - } - [Test] - public void Test_4251() - { - } - [Test] - public void Test_4252() - { - } - [Test] - public void Test_4253() - { - } - [Test] - public void Test_4254() - { - } - [Test] - public void Test_4255() - { - } - [Test] - public void Test_4256() - { - } - [Test] - public void Test_4257() - { - } - [Test] - public void Test_4258() - { - } - [Test] - public void Test_4259() - { - } - [Test] - public void Test_4260() - { - } - [Test] - public void Test_4261() - { - } - [Test] - public void Test_4262() - { - } - [Test] - public void Test_4263() - { - } - [Test] - public void Test_4264() - { - } - [Test] - public void Test_4265() - { - } - [Test] - public void Test_4266() - { - } - [Test] - public void Test_4267() - { - } - [Test] - public void Test_4268() - { - } - [Test] - public void Test_4269() - { - } - [Test] - public void Test_4270() - { - } - [Test] - public void Test_4271() - { - } - [Test] - public void Test_4272() - { - } - [Test] - public void Test_4273() - { - } - [Test] - public void Test_4274() - { - } - [Test] - public void Test_4275() - { - } - [Test] - public void Test_4276() - { - } - [Test] - public void Test_4277() - { - } - [Test] - public void Test_4278() - { - } - [Test] - public void Test_4279() - { - } - [Test] - public void Test_4280() - { - } - [Test] - public void Test_4281() - { - } - [Test] - public void Test_4282() - { - } - [Test] - public void Test_4283() - { - } - [Test] - public void Test_4284() - { - } - [Test] - public void Test_4285() - { - } - [Test] - public void Test_4286() - { - } - [Test] - public void Test_4287() - { - } - [Test] - public void Test_4288() - { - } - [Test] - public void Test_4289() - { - } - [Test] - public void Test_4290() - { - } - [Test] - public void Test_4291() - { - } - [Test] - public void Test_4292() - { - } - [Test] - public void Test_4293() - { - } - [Test] - public void Test_4294() - { - } - [Test] - public void Test_4295() - { - } - [Test] - public void Test_4296() - { - } - [Test] - public void Test_4297() - { - } - [Test] - public void Test_4298() - { - } - [Test] - public void Test_4299() - { - } - [Test] - public void Test_4300() - { - } - [Test] - public void Test_4301() - { - } - [Test] - public void Test_4302() - { - } - [Test] - public void Test_4303() - { - } - [Test] - public void Test_4304() - { - } - [Test] - public void Test_4305() - { - } - [Test] - public void Test_4306() - { - } - [Test] - public void Test_4307() - { - } - [Test] - public void Test_4308() - { - } - [Test] - public void Test_4309() - { - } - [Test] - public void Test_4310() - { - } - [Test] - public void Test_4311() - { - } - [Test] - public void Test_4312() - { - } - [Test] - public void Test_4313() - { - } - [Test] - public void Test_4314() - { - } - [Test] - public void Test_4315() - { - } - [Test] - public void Test_4316() - { - } - [Test] - public void Test_4317() - { - } - [Test] - public void Test_4318() - { - } - [Test] - public void Test_4319() - { - } - [Test] - public void Test_4320() - { - } - [Test] - public void Test_4321() - { - } - [Test] - public void Test_4322() - { - } - [Test] - public void Test_4323() - { - } - [Test] - public void Test_4324() - { - } - [Test] - public void Test_4325() - { - } - [Test] - public void Test_4326() - { - } - [Test] - public void Test_4327() - { - } - [Test] - public void Test_4328() - { - } - [Test] - public void Test_4329() - { - } - [Test] - public void Test_4330() - { - } - [Test] - public void Test_4331() - { - } - [Test] - public void Test_4332() - { - } - [Test] - public void Test_4333() - { - } - [Test] - public void Test_4334() - { - } - [Test] - public void Test_4335() - { - } - [Test] - public void Test_4336() - { - } - [Test] - public void Test_4337() - { - } - [Test] - public void Test_4338() - { - } - [Test] - public void Test_4339() - { - } - [Test] - public void Test_4340() - { - } - [Test] - public void Test_4341() - { - } - [Test] - public void Test_4342() - { - } - [Test] - public void Test_4343() - { - } - [Test] - public void Test_4344() - { - } - [Test] - public void Test_4345() - { - } - [Test] - public void Test_4346() - { - } - [Test] - public void Test_4347() - { - } - [Test] - public void Test_4348() - { - } - [Test] - public void Test_4349() - { - } - [Test] - public void Test_4350() - { - } - [Test] - public void Test_4351() - { - } - [Test] - public void Test_4352() - { - } - [Test] - public void Test_4353() - { - } - [Test] - public void Test_4354() - { - } - [Test] - public void Test_4355() - { - } - [Test] - public void Test_4356() - { - } - [Test] - public void Test_4357() - { - } - [Test] - public void Test_4358() - { - } - [Test] - public void Test_4359() - { - } - [Test] - public void Test_4360() - { - } - [Test] - public void Test_4361() - { - } - [Test] - public void Test_4362() - { - } - [Test] - public void Test_4363() - { - } - [Test] - public void Test_4364() - { - } - [Test] - public void Test_4365() - { - } - [Test] - public void Test_4366() - { - } - [Test] - public void Test_4367() - { - } - [Test] - public void Test_4368() - { - } - [Test] - public void Test_4369() - { - } - [Test] - public void Test_4370() - { - } - [Test] - public void Test_4371() - { - } - [Test] - public void Test_4372() - { - } - [Test] - public void Test_4373() - { - } - [Test] - public void Test_4374() - { - } - [Test] - public void Test_4375() - { - } - [Test] - public void Test_4376() - { - } - [Test] - public void Test_4377() - { - } - [Test] - public void Test_4378() - { - } - [Test] - public void Test_4379() - { - } - [Test] - public void Test_4380() - { - } - [Test] - public void Test_4381() - { - } - [Test] - public void Test_4382() - { - } - [Test] - public void Test_4383() - { - } - [Test] - public void Test_4384() - { - } - [Test] - public void Test_4385() - { - } - [Test] - public void Test_4386() - { - } - [Test] - public void Test_4387() - { - } - [Test] - public void Test_4388() - { - } - [Test] - public void Test_4389() - { - } - [Test] - public void Test_4390() - { - } - [Test] - public void Test_4391() - { - } - [Test] - public void Test_4392() - { - } - [Test] - public void Test_4393() - { - } - [Test] - public void Test_4394() - { - } - [Test] - public void Test_4395() - { - } - [Test] - public void Test_4396() - { - } - [Test] - public void Test_4397() - { - } - [Test] - public void Test_4398() - { - } - [Test] - public void Test_4399() - { - } - [Test] - public void Test_4400() - { - } - [Test] - public void Test_4401() - { - } - [Test] - public void Test_4402() - { - } - [Test] - public void Test_4403() - { - } - [Test] - public void Test_4404() - { - } - [Test] - public void Test_4405() - { - } - [Test] - public void Test_4406() - { - } - [Test] - public void Test_4407() - { - } - [Test] - public void Test_4408() - { - } - [Test] - public void Test_4409() - { - } - [Test] - public void Test_4410() - { - } - [Test] - public void Test_4411() - { - } - [Test] - public void Test_4412() - { - } - [Test] - public void Test_4413() - { - } - [Test] - public void Test_4414() - { - } - [Test] - public void Test_4415() - { - } - [Test] - public void Test_4416() - { - } - [Test] - public void Test_4417() - { - } - [Test] - public void Test_4418() - { - } - [Test] - public void Test_4419() - { - } - [Test] - public void Test_4420() - { - } - [Test] - public void Test_4421() - { - } - [Test] - public void Test_4422() - { - } - [Test] - public void Test_4423() - { - } - [Test] - public void Test_4424() - { - } - [Test] - public void Test_4425() - { - } - [Test] - public void Test_4426() - { - } - [Test] - public void Test_4427() - { - } - [Test] - public void Test_4428() - { - } - [Test] - public void Test_4429() - { - } - [Test] - public void Test_4430() - { - } - [Test] - public void Test_4431() - { - } - [Test] - public void Test_4432() - { - } - [Test] - public void Test_4433() - { - } - [Test] - public void Test_4434() - { - } - [Test] - public void Test_4435() - { - } - [Test] - public void Test_4436() - { - } - [Test] - public void Test_4437() - { - } - [Test] - public void Test_4438() - { - } - [Test] - public void Test_4439() - { - } - [Test] - public void Test_4440() - { - } - [Test] - public void Test_4441() - { - } - [Test] - public void Test_4442() - { - } - [Test] - public void Test_4443() - { - } - [Test] - public void Test_4444() - { - } - [Test] - public void Test_4445() - { - } - [Test] - public void Test_4446() - { - } - [Test] - public void Test_4447() - { - } - [Test] - public void Test_4448() - { - } - [Test] - public void Test_4449() - { - } - [Test] - public void Test_4450() - { - } - [Test] - public void Test_4451() - { - } - [Test] - public void Test_4452() - { - } - [Test] - public void Test_4453() - { - } - [Test] - public void Test_4454() - { - } - [Test] - public void Test_4455() - { - } - [Test] - public void Test_4456() - { - } - [Test] - public void Test_4457() - { - } - [Test] - public void Test_4458() - { - } - [Test] - public void Test_4459() - { - } - [Test] - public void Test_4460() - { - } - [Test] - public void Test_4461() - { - } - [Test] - public void Test_4462() - { - } - [Test] - public void Test_4463() - { - } - [Test] - public void Test_4464() - { - } - [Test] - public void Test_4465() - { - } - [Test] - public void Test_4466() - { - } - [Test] - public void Test_4467() - { - } - [Test] - public void Test_4468() - { - } - [Test] - public void Test_4469() - { - } - [Test] - public void Test_4470() - { - } - [Test] - public void Test_4471() - { - } - [Test] - public void Test_4472() - { - } - [Test] - public void Test_4473() - { - } - [Test] - public void Test_4474() - { - } - [Test] - public void Test_4475() - { - } - [Test] - public void Test_4476() - { - } - [Test] - public void Test_4477() - { - } - [Test] - public void Test_4478() - { - } - [Test] - public void Test_4479() - { - } - [Test] - public void Test_4480() - { - } - [Test] - public void Test_4481() - { - } - [Test] - public void Test_4482() - { - } - [Test] - public void Test_4483() - { - } - [Test] - public void Test_4484() - { - } - [Test] - public void Test_4485() - { - } - [Test] - public void Test_4486() - { - } - [Test] - public void Test_4487() - { - } - [Test] - public void Test_4488() - { - } - [Test] - public void Test_4489() - { - } - [Test] - public void Test_4490() - { - } - [Test] - public void Test_4491() - { - } - [Test] - public void Test_4492() - { - } - [Test] - public void Test_4493() - { - } - [Test] - public void Test_4494() - { - } - [Test] - public void Test_4495() - { - } - [Test] - public void Test_4496() - { - } - [Test] - public void Test_4497() - { - } - [Test] - public void Test_4498() - { - } - [Test] - public void Test_4499() - { - } - [Test] - public void Test_4500() - { - } - [Test] - public void Test_4501() - { - } - [Test] - public void Test_4502() - { - } - [Test] - public void Test_4503() - { - } - [Test] - public void Test_4504() - { - } - [Test] - public void Test_4505() - { - } - [Test] - public void Test_4506() - { - } - [Test] - public void Test_4507() - { - } - [Test] - public void Test_4508() - { - } - [Test] - public void Test_4509() - { - } - [Test] - public void Test_4510() - { - } - [Test] - public void Test_4511() - { - } - [Test] - public void Test_4512() - { - } - [Test] - public void Test_4513() - { - } - [Test] - public void Test_4514() - { - } - [Test] - public void Test_4515() - { - } - [Test] - public void Test_4516() - { - } - [Test] - public void Test_4517() - { - } - [Test] - public void Test_4518() - { - } - [Test] - public void Test_4519() - { - } - [Test] - public void Test_4520() - { - } - [Test] - public void Test_4521() - { - } - [Test] - public void Test_4522() - { - } - [Test] - public void Test_4523() - { - } - [Test] - public void Test_4524() - { - } - [Test] - public void Test_4525() - { - } - [Test] - public void Test_4526() - { - } - [Test] - public void Test_4527() - { - } - [Test] - public void Test_4528() - { - } - [Test] - public void Test_4529() - { - } - [Test] - public void Test_4530() - { - } - [Test] - public void Test_4531() - { - } - [Test] - public void Test_4532() - { - } - [Test] - public void Test_4533() - { - } - [Test] - public void Test_4534() - { - } - [Test] - public void Test_4535() - { - } - [Test] - public void Test_4536() - { - } - [Test] - public void Test_4537() - { - } - [Test] - public void Test_4538() - { - } - [Test] - public void Test_4539() - { - } - [Test] - public void Test_4540() - { - } - [Test] - public void Test_4541() - { - } - [Test] - public void Test_4542() - { - } - [Test] - public void Test_4543() - { - } - [Test] - public void Test_4544() - { - } - [Test] - public void Test_4545() - { - } - [Test] - public void Test_4546() - { - } - [Test] - public void Test_4547() - { - } - [Test] - public void Test_4548() - { - } - [Test] - public void Test_4549() - { - } - [Test] - public void Test_4550() - { - } - [Test] - public void Test_4551() - { - } - [Test] - public void Test_4552() - { - } - [Test] - public void Test_4553() - { - } - [Test] - public void Test_4554() - { - } - [Test] - public void Test_4555() - { - } - [Test] - public void Test_4556() - { - } - [Test] - public void Test_4557() - { - } - [Test] - public void Test_4558() - { - } - [Test] - public void Test_4559() - { - } - [Test] - public void Test_4560() - { - } - [Test] - public void Test_4561() - { - } - [Test] - public void Test_4562() - { - } - [Test] - public void Test_4563() - { - } - [Test] - public void Test_4564() - { - } - [Test] - public void Test_4565() - { - } - [Test] - public void Test_4566() - { - } - [Test] - public void Test_4567() - { - } - [Test] - public void Test_4568() - { - } - [Test] - public void Test_4569() - { - } - [Test] - public void Test_4570() - { - } - [Test] - public void Test_4571() - { - } - [Test] - public void Test_4572() - { - } - [Test] - public void Test_4573() - { - } - [Test] - public void Test_4574() - { - } - [Test] - public void Test_4575() - { - } - [Test] - public void Test_4576() - { - } - [Test] - public void Test_4577() - { - } - [Test] - public void Test_4578() - { - } - [Test] - public void Test_4579() - { - } - [Test] - public void Test_4580() - { - } - [Test] - public void Test_4581() - { - } - [Test] - public void Test_4582() - { - } - [Test] - public void Test_4583() - { - } - [Test] - public void Test_4584() - { - } - [Test] - public void Test_4585() - { - } - [Test] - public void Test_4586() - { - } - [Test] - public void Test_4587() - { - } - [Test] - public void Test_4588() - { - } - [Test] - public void Test_4589() - { - } - [Test] - public void Test_4590() - { - } - [Test] - public void Test_4591() - { - } - [Test] - public void Test_4592() - { - } - [Test] - public void Test_4593() - { - } - [Test] - public void Test_4594() - { - } - [Test] - public void Test_4595() - { - } - [Test] - public void Test_4596() - { - } - [Test] - public void Test_4597() - { - } - [Test] - public void Test_4598() - { - } - [Test] - public void Test_4599() - { - } - [Test] - public void Test_4600() - { - } - [Test] - public void Test_4601() - { - } - [Test] - public void Test_4602() - { - } - [Test] - public void Test_4603() - { - } - [Test] - public void Test_4604() - { - } - [Test] - public void Test_4605() - { - } - [Test] - public void Test_4606() - { - } - [Test] - public void Test_4607() - { - } - [Test] - public void Test_4608() - { - } - [Test] - public void Test_4609() - { - } - [Test] - public void Test_4610() - { - } - [Test] - public void Test_4611() - { - } - [Test] - public void Test_4612() - { - } - [Test] - public void Test_4613() - { - } - [Test] - public void Test_4614() - { - } - [Test] - public void Test_4615() - { - } - [Test] - public void Test_4616() - { - } - [Test] - public void Test_4617() - { - } - [Test] - public void Test_4618() - { - } - [Test] - public void Test_4619() - { - } - [Test] - public void Test_4620() - { - } - [Test] - public void Test_4621() - { - } - [Test] - public void Test_4622() - { - } - [Test] - public void Test_4623() - { - } - [Test] - public void Test_4624() - { - } - [Test] - public void Test_4625() - { - } - [Test] - public void Test_4626() - { - } - [Test] - public void Test_4627() - { - } - [Test] - public void Test_4628() - { - } - [Test] - public void Test_4629() - { - } - [Test] - public void Test_4630() - { - } - [Test] - public void Test_4631() - { - } - [Test] - public void Test_4632() - { - } - [Test] - public void Test_4633() - { - } - [Test] - public void Test_4634() - { - } - [Test] - public void Test_4635() - { - } - [Test] - public void Test_4636() - { - } - [Test] - public void Test_4637() - { - } - [Test] - public void Test_4638() - { - } - [Test] - public void Test_4639() - { - } - [Test] - public void Test_4640() - { - } - [Test] - public void Test_4641() - { - } - [Test] - public void Test_4642() - { - } - [Test] - public void Test_4643() - { - } - [Test] - public void Test_4644() - { - } - [Test] - public void Test_4645() - { - } - [Test] - public void Test_4646() - { - } - [Test] - public void Test_4647() - { - } - [Test] - public void Test_4648() - { - } - [Test] - public void Test_4649() - { - } - [Test] - public void Test_4650() - { - } - [Test] - public void Test_4651() - { - } - [Test] - public void Test_4652() - { - } - [Test] - public void Test_4653() - { - } - [Test] - public void Test_4654() - { - } - [Test] - public void Test_4655() - { - } - [Test] - public void Test_4656() - { - } - [Test] - public void Test_4657() - { - } - [Test] - public void Test_4658() - { - } - [Test] - public void Test_4659() - { - } - [Test] - public void Test_4660() - { - } - [Test] - public void Test_4661() - { - } - [Test] - public void Test_4662() - { - } - [Test] - public void Test_4663() - { - } - [Test] - public void Test_4664() - { - } - [Test] - public void Test_4665() - { - } - [Test] - public void Test_4666() - { - } - [Test] - public void Test_4667() - { - } - [Test] - public void Test_4668() - { - } - [Test] - public void Test_4669() - { - } - [Test] - public void Test_4670() - { - } - [Test] - public void Test_4671() - { - } - [Test] - public void Test_4672() - { - } - [Test] - public void Test_4673() - { - } - [Test] - public void Test_4674() - { - } - [Test] - public void Test_4675() - { - } - [Test] - public void Test_4676() - { - } - [Test] - public void Test_4677() - { - } - [Test] - public void Test_4678() - { - } - [Test] - public void Test_4679() - { - } - [Test] - public void Test_4680() - { - } - [Test] - public void Test_4681() - { - } - [Test] - public void Test_4682() - { - } - [Test] - public void Test_4683() - { - } - [Test] - public void Test_4684() - { - } - [Test] - public void Test_4685() - { - } - [Test] - public void Test_4686() - { - } - [Test] - public void Test_4687() - { - } - [Test] - public void Test_4688() - { - } - [Test] - public void Test_4689() - { - } - [Test] - public void Test_4690() - { - } - [Test] - public void Test_4691() - { - } - [Test] - public void Test_4692() - { - } - [Test] - public void Test_4693() - { - } - [Test] - public void Test_4694() - { - } - [Test] - public void Test_4695() - { - } - [Test] - public void Test_4696() - { - } - [Test] - public void Test_4697() - { - } - [Test] - public void Test_4698() - { - } - [Test] - public void Test_4699() - { - } - [Test] - public void Test_4700() - { - } - [Test] - public void Test_4701() - { - } - [Test] - public void Test_4702() - { - } - [Test] - public void Test_4703() - { - } - [Test] - public void Test_4704() - { - } - [Test] - public void Test_4705() - { - } - [Test] - public void Test_4706() - { - } - [Test] - public void Test_4707() - { - } - [Test] - public void Test_4708() - { - } - [Test] - public void Test_4709() - { - } - [Test] - public void Test_4710() - { - } - [Test] - public void Test_4711() - { - } - [Test] - public void Test_4712() - { - } - [Test] - public void Test_4713() - { - } - [Test] - public void Test_4714() - { - } - [Test] - public void Test_4715() - { - } - [Test] - public void Test_4716() - { - } - [Test] - public void Test_4717() - { - } - [Test] - public void Test_4718() - { - } - [Test] - public void Test_4719() - { - } - [Test] - public void Test_4720() - { - } - [Test] - public void Test_4721() - { - } - [Test] - public void Test_4722() - { - } - [Test] - public void Test_4723() - { - } - [Test] - public void Test_4724() - { - } - [Test] - public void Test_4725() - { - } - [Test] - public void Test_4726() - { - } - [Test] - public void Test_4727() - { - } - [Test] - public void Test_4728() - { - } - [Test] - public void Test_4729() - { - } - [Test] - public void Test_4730() - { - } - [Test] - public void Test_4731() - { - } - [Test] - public void Test_4732() - { - } - [Test] - public void Test_4733() - { - } - [Test] - public void Test_4734() - { - } - [Test] - public void Test_4735() - { - } - [Test] - public void Test_4736() - { - } - [Test] - public void Test_4737() - { - } - [Test] - public void Test_4738() - { - } - [Test] - public void Test_4739() - { - } - [Test] - public void Test_4740() - { - } - [Test] - public void Test_4741() - { - } - [Test] - public void Test_4742() - { - } - [Test] - public void Test_4743() - { - } - [Test] - public void Test_4744() - { - } - [Test] - public void Test_4745() - { - } - [Test] - public void Test_4746() - { - } - [Test] - public void Test_4747() - { - } - [Test] - public void Test_4748() - { - } - [Test] - public void Test_4749() - { - } - [Test] - public void Test_4750() - { - } - [Test] - public void Test_4751() - { - } - [Test] - public void Test_4752() - { - } - [Test] - public void Test_4753() - { - } - [Test] - public void Test_4754() - { - } - [Test] - public void Test_4755() - { - } - [Test] - public void Test_4756() - { - } - [Test] - public void Test_4757() - { - } - [Test] - public void Test_4758() - { - } - [Test] - public void Test_4759() - { - } - [Test] - public void Test_4760() - { - } - [Test] - public void Test_4761() - { - } - [Test] - public void Test_4762() - { - } - [Test] - public void Test_4763() - { - } - [Test] - public void Test_4764() - { - } - [Test] - public void Test_4765() - { - } - [Test] - public void Test_4766() - { - } - [Test] - public void Test_4767() - { - } - [Test] - public void Test_4768() - { - } - [Test] - public void Test_4769() - { - } - [Test] - public void Test_4770() - { - } - [Test] - public void Test_4771() - { - } - [Test] - public void Test_4772() - { - } - [Test] - public void Test_4773() - { - } - [Test] - public void Test_4774() - { - } - [Test] - public void Test_4775() - { - } - [Test] - public void Test_4776() - { - } - [Test] - public void Test_4777() - { - } - [Test] - public void Test_4778() - { - } - [Test] - public void Test_4779() - { - } - [Test] - public void Test_4780() - { - } - [Test] - public void Test_4781() - { - } - [Test] - public void Test_4782() - { - } - [Test] - public void Test_4783() - { - } - [Test] - public void Test_4784() - { - } - [Test] - public void Test_4785() - { - } - [Test] - public void Test_4786() - { - } - [Test] - public void Test_4787() - { - } - [Test] - public void Test_4788() - { - } - [Test] - public void Test_4789() - { - } - [Test] - public void Test_4790() - { - } - [Test] - public void Test_4791() - { - } - [Test] - public void Test_4792() - { - } - [Test] - public void Test_4793() - { - } - [Test] - public void Test_4794() - { - } - [Test] - public void Test_4795() - { - } - [Test] - public void Test_4796() - { - } - [Test] - public void Test_4797() - { - } - [Test] - public void Test_4798() - { - } - [Test] - public void Test_4799() - { - } - [Test] - public void Test_4800() - { - } - [Test] - public void Test_4801() - { - } - [Test] - public void Test_4802() - { - } - [Test] - public void Test_4803() - { - } - [Test] - public void Test_4804() - { - } - [Test] - public void Test_4805() - { - } - [Test] - public void Test_4806() - { - } - [Test] - public void Test_4807() - { - } - [Test] - public void Test_4808() - { - } - [Test] - public void Test_4809() - { - } - [Test] - public void Test_4810() - { - } - [Test] - public void Test_4811() - { - } - [Test] - public void Test_4812() - { - } - [Test] - public void Test_4813() - { - } - [Test] - public void Test_4814() - { - } - [Test] - public void Test_4815() - { - } - [Test] - public void Test_4816() - { - } - [Test] - public void Test_4817() - { - } - [Test] - public void Test_4818() - { - } - [Test] - public void Test_4819() - { - } - [Test] - public void Test_4820() - { - } - [Test] - public void Test_4821() - { - } - [Test] - public void Test_4822() - { - } - [Test] - public void Test_4823() - { - } - [Test] - public void Test_4824() - { - } - [Test] - public void Test_4825() - { - } - [Test] - public void Test_4826() - { - } - [Test] - public void Test_4827() - { - } - [Test] - public void Test_4828() - { - } - [Test] - public void Test_4829() - { - } - [Test] - public void Test_4830() - { - } - [Test] - public void Test_4831() - { - } - [Test] - public void Test_4832() - { - } - [Test] - public void Test_4833() - { - } - [Test] - public void Test_4834() - { - } - [Test] - public void Test_4835() - { - } - [Test] - public void Test_4836() - { - } - [Test] - public void Test_4837() - { - } - [Test] - public void Test_4838() - { - } - [Test] - public void Test_4839() - { - } - [Test] - public void Test_4840() - { - } - [Test] - public void Test_4841() - { - } - [Test] - public void Test_4842() - { - } - [Test] - public void Test_4843() - { - } - [Test] - public void Test_4844() - { - } - [Test] - public void Test_4845() - { - } - [Test] - public void Test_4846() - { - } - [Test] - public void Test_4847() - { - } - [Test] - public void Test_4848() - { - } - [Test] - public void Test_4849() - { - } - [Test] - public void Test_4850() - { - } - [Test] - public void Test_4851() - { - } - [Test] - public void Test_4852() - { - } - [Test] - public void Test_4853() - { - } - [Test] - public void Test_4854() - { - } - [Test] - public void Test_4855() - { - } - [Test] - public void Test_4856() - { - } - [Test] - public void Test_4857() - { - } - [Test] - public void Test_4858() - { - } - [Test] - public void Test_4859() - { - } - [Test] - public void Test_4860() - { - } - [Test] - public void Test_4861() - { - } - [Test] - public void Test_4862() - { - } - [Test] - public void Test_4863() - { - } - [Test] - public void Test_4864() - { - } - [Test] - public void Test_4865() - { - } - [Test] - public void Test_4866() - { - } - [Test] - public void Test_4867() - { - } - [Test] - public void Test_4868() - { - } - [Test] - public void Test_4869() - { - } - [Test] - public void Test_4870() - { - } - [Test] - public void Test_4871() - { - } - [Test] - public void Test_4872() - { - } - [Test] - public void Test_4873() - { - } - [Test] - public void Test_4874() - { - } - [Test] - public void Test_4875() - { - } - [Test] - public void Test_4876() - { - } - [Test] - public void Test_4877() - { - } - [Test] - public void Test_4878() - { - } - [Test] - public void Test_4879() - { - } - [Test] - public void Test_4880() - { - } - [Test] - public void Test_4881() - { - } - [Test] - public void Test_4882() - { - } - [Test] - public void Test_4883() - { - } - [Test] - public void Test_4884() - { - } - [Test] - public void Test_4885() - { - } - [Test] - public void Test_4886() - { - } - [Test] - public void Test_4887() - { - } - [Test] - public void Test_4888() - { - } - [Test] - public void Test_4889() - { - } - [Test] - public void Test_4890() - { - } - [Test] - public void Test_4891() - { - } - [Test] - public void Test_4892() - { - } - [Test] - public void Test_4893() - { - } - [Test] - public void Test_4894() - { - } - [Test] - public void Test_4895() - { - } - [Test] - public void Test_4896() - { - } - [Test] - public void Test_4897() - { - } - [Test] - public void Test_4898() - { - } - [Test] - public void Test_4899() - { - } - [Test] - public void Test_4900() - { - } - [Test] - public void Test_4901() - { - } - [Test] - public void Test_4902() - { - } - [Test] - public void Test_4903() - { - } - [Test] - public void Test_4904() - { - } - [Test] - public void Test_4905() - { - } - [Test] - public void Test_4906() - { - } - [Test] - public void Test_4907() - { - } - [Test] - public void Test_4908() - { - } - [Test] - public void Test_4909() - { - } - [Test] - public void Test_4910() - { - } - [Test] - public void Test_4911() - { - } - [Test] - public void Test_4912() - { - } - [Test] - public void Test_4913() - { - } - [Test] - public void Test_4914() - { - } - [Test] - public void Test_4915() - { - } - [Test] - public void Test_4916() - { - } - [Test] - public void Test_4917() - { - } - [Test] - public void Test_4918() - { - } - [Test] - public void Test_4919() - { - } - [Test] - public void Test_4920() - { - } - [Test] - public void Test_4921() - { - } - [Test] - public void Test_4922() - { - } - [Test] - public void Test_4923() - { - } - [Test] - public void Test_4924() - { - } - [Test] - public void Test_4925() - { - } - [Test] - public void Test_4926() - { - } - [Test] - public void Test_4927() - { - } - [Test] - public void Test_4928() - { - } - [Test] - public void Test_4929() - { - } - [Test] - public void Test_4930() - { - } - [Test] - public void Test_4931() - { - } - [Test] - public void Test_4932() - { - } - [Test] - public void Test_4933() - { - } - [Test] - public void Test_4934() - { - } - [Test] - public void Test_4935() - { - } - [Test] - public void Test_4936() - { - } - [Test] - public void Test_4937() - { - } - [Test] - public void Test_4938() - { - } - [Test] - public void Test_4939() - { - } - [Test] - public void Test_4940() - { - } - [Test] - public void Test_4941() - { - } - [Test] - public void Test_4942() - { - } - [Test] - public void Test_4943() - { - } - [Test] - public void Test_4944() - { - } - [Test] - public void Test_4945() - { - } - [Test] - public void Test_4946() - { - } - [Test] - public void Test_4947() - { - } - [Test] - public void Test_4948() - { - } - [Test] - public void Test_4949() - { - } - [Test] - public void Test_4950() - { - } - [Test] - public void Test_4951() - { - } - [Test] - public void Test_4952() - { - } - [Test] - public void Test_4953() - { - } - [Test] - public void Test_4954() - { - } - [Test] - public void Test_4955() - { - } - [Test] - public void Test_4956() - { - } - [Test] - public void Test_4957() - { - } - [Test] - public void Test_4958() - { - } - [Test] - public void Test_4959() - { - } - [Test] - public void Test_4960() - { - } - [Test] - public void Test_4961() - { - } - [Test] - public void Test_4962() - { - } - [Test] - public void Test_4963() - { - } - [Test] - public void Test_4964() - { - } - [Test] - public void Test_4965() - { - } - [Test] - public void Test_4966() - { - } - [Test] - public void Test_4967() - { - } - [Test] - public void Test_4968() - { - } - [Test] - public void Test_4969() - { - } - [Test] - public void Test_4970() - { - } - [Test] - public void Test_4971() - { - } - [Test] - public void Test_4972() - { - } - [Test] - public void Test_4973() - { - } - [Test] - public void Test_4974() - { - } - [Test] - public void Test_4975() - { - } - [Test] - public void Test_4976() - { - } - [Test] - public void Test_4977() - { - } - [Test] - public void Test_4978() - { - } - [Test] - public void Test_4979() - { - } - [Test] - public void Test_4980() - { - } - [Test] - public void Test_4981() - { - } - [Test] - public void Test_4982() - { - } - [Test] - public void Test_4983() - { - } - [Test] - public void Test_4984() - { - } - [Test] - public void Test_4985() - { - } - [Test] - public void Test_4986() - { - } - [Test] - public void Test_4987() - { - } - [Test] - public void Test_4988() - { - } - [Test] - public void Test_4989() - { - } - [Test] - public void Test_4990() - { - } - [Test] - public void Test_4991() - { - } - [Test] - public void Test_4992() - { - } - [Test] - public void Test_4993() - { - } - [Test] - public void Test_4994() - { - } - [Test] - public void Test_4995() - { - } - [Test] - public void Test_4996() - { - } - [Test] - public void Test_4997() - { - } - [Test] - public void Test_4998() - { - } - [Test] - public void Test_4999() - { - } - [Test] - public void Test_5000() - { - } - [Test] - public void Test_5001() - { - } - [Test] - public void Test_5002() - { - } - [Test] - public void Test_5003() - { - } - [Test] - public void Test_5004() - { - } - [Test] - public void Test_5005() - { - } - [Test] - public void Test_5006() - { - } - [Test] - public void Test_5007() - { - } - [Test] - public void Test_5008() - { - } - [Test] - public void Test_5009() - { - } - [Test] - public void Test_5010() - { - } - [Test] - public void Test_5011() - { - } - [Test] - public void Test_5012() - { - } - [Test] - public void Test_5013() - { - } - [Test] - public void Test_5014() - { - } - [Test] - public void Test_5015() - { - } - [Test] - public void Test_5016() - { - } - [Test] - public void Test_5017() - { - } - [Test] - public void Test_5018() - { - } - [Test] - public void Test_5019() - { - } - [Test] - public void Test_5020() - { - } - [Test] - public void Test_5021() - { - } - [Test] - public void Test_5022() - { - } - [Test] - public void Test_5023() - { - } - [Test] - public void Test_5024() - { - } - [Test] - public void Test_5025() - { - } - [Test] - public void Test_5026() - { - } - [Test] - public void Test_5027() - { - } - [Test] - public void Test_5028() - { - } - [Test] - public void Test_5029() - { - } - [Test] - public void Test_5030() - { - } - [Test] - public void Test_5031() - { - } - [Test] - public void Test_5032() - { - } - [Test] - public void Test_5033() - { - } - [Test] - public void Test_5034() - { - } - [Test] - public void Test_5035() - { - } - [Test] - public void Test_5036() - { - } - [Test] - public void Test_5037() - { - } - [Test] - public void Test_5038() - { - } - [Test] - public void Test_5039() - { - } - [Test] - public void Test_5040() - { - } - [Test] - public void Test_5041() - { - } - [Test] - public void Test_5042() - { - } - [Test] - public void Test_5043() - { - } - [Test] - public void Test_5044() - { - } - [Test] - public void Test_5045() - { - } - [Test] - public void Test_5046() - { - } - [Test] - public void Test_5047() - { - } - [Test] - public void Test_5048() - { - } - [Test] - public void Test_5049() - { - } - [Test] - public void Test_5050() - { - } - [Test] - public void Test_5051() - { - } - [Test] - public void Test_5052() - { - } - [Test] - public void Test_5053() - { - } - [Test] - public void Test_5054() - { - } - [Test] - public void Test_5055() - { - } - [Test] - public void Test_5056() - { - } - [Test] - public void Test_5057() - { - } - [Test] - public void Test_5058() - { - } - [Test] - public void Test_5059() - { - } - [Test] - public void Test_5060() - { - } - [Test] - public void Test_5061() - { - } - [Test] - public void Test_5062() - { - } - [Test] - public void Test_5063() - { - } - [Test] - public void Test_5064() - { - } - [Test] - public void Test_5065() - { - } - [Test] - public void Test_5066() - { - } - [Test] - public void Test_5067() - { - } - [Test] - public void Test_5068() - { - } - [Test] - public void Test_5069() - { - } - [Test] - public void Test_5070() - { - } - [Test] - public void Test_5071() - { - } - [Test] - public void Test_5072() - { - } - [Test] - public void Test_5073() - { - } - [Test] - public void Test_5074() - { - } - [Test] - public void Test_5075() - { - } - [Test] - public void Test_5076() - { - } - [Test] - public void Test_5077() - { - } - [Test] - public void Test_5078() - { - } - [Test] - public void Test_5079() - { - } - [Test] - public void Test_5080() - { - } - [Test] - public void Test_5081() - { - } - [Test] - public void Test_5082() - { - } - [Test] - public void Test_5083() - { - } - [Test] - public void Test_5084() - { - } - [Test] - public void Test_5085() - { - } - [Test] - public void Test_5086() - { - } - [Test] - public void Test_5087() - { - } - [Test] - public void Test_5088() - { - } - [Test] - public void Test_5089() - { - } - [Test] - public void Test_5090() - { - } - [Test] - public void Test_5091() - { - } - [Test] - public void Test_5092() - { - } - [Test] - public void Test_5093() - { - } - [Test] - public void Test_5094() - { - } - [Test] - public void Test_5095() - { - } - [Test] - public void Test_5096() - { - } - [Test] - public void Test_5097() - { - } - [Test] - public void Test_5098() - { - } - [Test] - public void Test_5099() - { - } - [Test] - public void Test_5100() - { - } - [Test] - public void Test_5101() - { - } - [Test] - public void Test_5102() - { - } - [Test] - public void Test_5103() - { - } - [Test] - public void Test_5104() - { - } - [Test] - public void Test_5105() - { - } - [Test] - public void Test_5106() - { - } - [Test] - public void Test_5107() - { - } - [Test] - public void Test_5108() - { - } - [Test] - public void Test_5109() - { - } - [Test] - public void Test_5110() - { - } - [Test] - public void Test_5111() - { - } - [Test] - public void Test_5112() - { - } - [Test] - public void Test_5113() - { - } - [Test] - public void Test_5114() - { - } - [Test] - public void Test_5115() - { - } - [Test] - public void Test_5116() - { - } - [Test] - public void Test_5117() - { - } - [Test] - public void Test_5118() - { - } - [Test] - public void Test_5119() - { - } - [Test] - public void Test_5120() - { - } - [Test] - public void Test_5121() - { - } - [Test] - public void Test_5122() - { - } - [Test] - public void Test_5123() - { - } - [Test] - public void Test_5124() - { - } - [Test] - public void Test_5125() - { - } - [Test] - public void Test_5126() - { - } - [Test] - public void Test_5127() - { - } - [Test] - public void Test_5128() - { - } - [Test] - public void Test_5129() - { - } - [Test] - public void Test_5130() - { - } - [Test] - public void Test_5131() - { - } - [Test] - public void Test_5132() - { - } - [Test] - public void Test_5133() - { - } - [Test] - public void Test_5134() - { - } - [Test] - public void Test_5135() - { - } - [Test] - public void Test_5136() - { - } - [Test] - public void Test_5137() - { - } - [Test] - public void Test_5138() - { - } - [Test] - public void Test_5139() - { - } - [Test] - public void Test_5140() - { - } - [Test] - public void Test_5141() - { - } - [Test] - public void Test_5142() - { - } - [Test] - public void Test_5143() - { - } - [Test] - public void Test_5144() - { - } - [Test] - public void Test_5145() - { - } - [Test] - public void Test_5146() - { - } - [Test] - public void Test_5147() - { - } - [Test] - public void Test_5148() - { - } - [Test] - public void Test_5149() - { - } - [Test] - public void Test_5150() - { - } - [Test] - public void Test_5151() - { - } - [Test] - public void Test_5152() - { - } - [Test] - public void Test_5153() - { - } - [Test] - public void Test_5154() - { - } - [Test] - public void Test_5155() - { - } - [Test] - public void Test_5156() - { - } - [Test] - public void Test_5157() - { - } - [Test] - public void Test_5158() - { - } - [Test] - public void Test_5159() - { - } - [Test] - public void Test_5160() - { - } - [Test] - public void Test_5161() - { - } - [Test] - public void Test_5162() - { - } - [Test] - public void Test_5163() - { - } - [Test] - public void Test_5164() - { - } - [Test] - public void Test_5165() - { - } - [Test] - public void Test_5166() - { - } - [Test] - public void Test_5167() - { - } - [Test] - public void Test_5168() - { - } - [Test] - public void Test_5169() - { - } - [Test] - public void Test_5170() - { - } - [Test] - public void Test_5171() - { - } - [Test] - public void Test_5172() - { - } - [Test] - public void Test_5173() - { - } - [Test] - public void Test_5174() - { - } - [Test] - public void Test_5175() - { - } - [Test] - public void Test_5176() - { - } - [Test] - public void Test_5177() - { - } - [Test] - public void Test_5178() - { - } - [Test] - public void Test_5179() - { - } - [Test] - public void Test_5180() - { - } - [Test] - public void Test_5181() - { - } - [Test] - public void Test_5182() - { - } - [Test] - public void Test_5183() - { - } - [Test] - public void Test_5184() - { - } - [Test] - public void Test_5185() - { - } - [Test] - public void Test_5186() - { - } - [Test] - public void Test_5187() - { - } - [Test] - public void Test_5188() - { - } - [Test] - public void Test_5189() - { - } - [Test] - public void Test_5190() - { - } - [Test] - public void Test_5191() - { - } - [Test] - public void Test_5192() - { - } - [Test] - public void Test_5193() - { - } - [Test] - public void Test_5194() - { - } - [Test] - public void Test_5195() - { - } - [Test] - public void Test_5196() - { - } - [Test] - public void Test_5197() - { - } - [Test] - public void Test_5198() - { - } - [Test] - public void Test_5199() - { - } - [Test] - public void Test_5200() - { - } - [Test] - public void Test_5201() - { - } - [Test] - public void Test_5202() - { - } - [Test] - public void Test_5203() - { - } - [Test] - public void Test_5204() - { - } - [Test] - public void Test_5205() - { - } - [Test] - public void Test_5206() - { - } - [Test] - public void Test_5207() - { - } - [Test] - public void Test_5208() - { - } - [Test] - public void Test_5209() - { - } - [Test] - public void Test_5210() - { - } - [Test] - public void Test_5211() - { - } - [Test] - public void Test_5212() - { - } - [Test] - public void Test_5213() - { - } - [Test] - public void Test_5214() - { - } - [Test] - public void Test_5215() - { - } - [Test] - public void Test_5216() - { - } - [Test] - public void Test_5217() - { - } - [Test] - public void Test_5218() - { - } - [Test] - public void Test_5219() - { - } - [Test] - public void Test_5220() - { - } - [Test] - public void Test_5221() - { - } - [Test] - public void Test_5222() - { - } - [Test] - public void Test_5223() - { - } - [Test] - public void Test_5224() - { - } - [Test] - public void Test_5225() - { - } - [Test] - public void Test_5226() - { - } - [Test] - public void Test_5227() - { - } - [Test] - public void Test_5228() - { - } - [Test] - public void Test_5229() - { - } - [Test] - public void Test_5230() - { - } - [Test] - public void Test_5231() - { - } - [Test] - public void Test_5232() - { - } - [Test] - public void Test_5233() - { - } - [Test] - public void Test_5234() - { - } - [Test] - public void Test_5235() - { - } - [Test] - public void Test_5236() - { - } - [Test] - public void Test_5237() - { - } - [Test] - public void Test_5238() - { - } - [Test] - public void Test_5239() - { - } - [Test] - public void Test_5240() - { - } - [Test] - public void Test_5241() - { - } - [Test] - public void Test_5242() - { - } - [Test] - public void Test_5243() - { - } - [Test] - public void Test_5244() - { - } - [Test] - public void Test_5245() - { - } - [Test] - public void Test_5246() - { - } - [Test] - public void Test_5247() - { - } - [Test] - public void Test_5248() - { - } - [Test] - public void Test_5249() - { - } - [Test] - public void Test_5250() - { - } - [Test] - public void Test_5251() - { - } - [Test] - public void Test_5252() - { - } - [Test] - public void Test_5253() - { - } - [Test] - public void Test_5254() - { - } - [Test] - public void Test_5255() - { - } - [Test] - public void Test_5256() - { - } - [Test] - public void Test_5257() - { - } - [Test] - public void Test_5258() - { - } - [Test] - public void Test_5259() - { - } - [Test] - public void Test_5260() - { - } - [Test] - public void Test_5261() - { - } - [Test] - public void Test_5262() - { - } - [Test] - public void Test_5263() - { - } - [Test] - public void Test_5264() - { - } - [Test] - public void Test_5265() - { - } - [Test] - public void Test_5266() - { - } - [Test] - public void Test_5267() - { - } - [Test] - public void Test_5268() - { - } - [Test] - public void Test_5269() - { - } - [Test] - public void Test_5270() - { - } - [Test] - public void Test_5271() - { - } - [Test] - public void Test_5272() - { - } - [Test] - public void Test_5273() - { - } - [Test] - public void Test_5274() - { - } - [Test] - public void Test_5275() - { - } - [Test] - public void Test_5276() - { - } - [Test] - public void Test_5277() - { - } - [Test] - public void Test_5278() - { - } - [Test] - public void Test_5279() - { - } - [Test] - public void Test_5280() - { - } - [Test] - public void Test_5281() - { - } - [Test] - public void Test_5282() - { - } - [Test] - public void Test_5283() - { - } - [Test] - public void Test_5284() - { - } - [Test] - public void Test_5285() - { - } - [Test] - public void Test_5286() - { - } - [Test] - public void Test_5287() - { - } - [Test] - public void Test_5288() - { - } - [Test] - public void Test_5289() - { - } - [Test] - public void Test_5290() - { - } - [Test] - public void Test_5291() - { - } - [Test] - public void Test_5292() - { - } - [Test] - public void Test_5293() - { - } - [Test] - public void Test_5294() - { - } - [Test] - public void Test_5295() - { - } - [Test] - public void Test_5296() - { - } - [Test] - public void Test_5297() - { - } - [Test] - public void Test_5298() - { - } - [Test] - public void Test_5299() - { - } - [Test] - public void Test_5300() - { - } - [Test] - public void Test_5301() - { - } - [Test] - public void Test_5302() - { - } - [Test] - public void Test_5303() - { - } - [Test] - public void Test_5304() - { - } - [Test] - public void Test_5305() - { - } - [Test] - public void Test_5306() - { - } - [Test] - public void Test_5307() - { - } - [Test] - public void Test_5308() - { - } - [Test] - public void Test_5309() - { - } - [Test] - public void Test_5310() - { - } - [Test] - public void Test_5311() - { - } - [Test] - public void Test_5312() - { - } - [Test] - public void Test_5313() - { - } - [Test] - public void Test_5314() - { - } - [Test] - public void Test_5315() - { - } - [Test] - public void Test_5316() - { - } - [Test] - public void Test_5317() - { - } - [Test] - public void Test_5318() - { - } - [Test] - public void Test_5319() - { - } - [Test] - public void Test_5320() - { - } - [Test] - public void Test_5321() - { - } - [Test] - public void Test_5322() - { - } - [Test] - public void Test_5323() - { - } - [Test] - public void Test_5324() - { - } - [Test] - public void Test_5325() - { - } - [Test] - public void Test_5326() - { - } - [Test] - public void Test_5327() - { - } - [Test] - public void Test_5328() - { - } - [Test] - public void Test_5329() - { - } - [Test] - public void Test_5330() - { - } - [Test] - public void Test_5331() - { - } - [Test] - public void Test_5332() - { - } - [Test] - public void Test_5333() - { - } - [Test] - public void Test_5334() - { - } - [Test] - public void Test_5335() - { - } - [Test] - public void Test_5336() - { - } - [Test] - public void Test_5337() - { - } - [Test] - public void Test_5338() - { - } - [Test] - public void Test_5339() - { - } - [Test] - public void Test_5340() - { - } - [Test] - public void Test_5341() - { - } - [Test] - public void Test_5342() - { - } - [Test] - public void Test_5343() - { - } - [Test] - public void Test_5344() - { - } - [Test] - public void Test_5345() - { - } - [Test] - public void Test_5346() - { - } - [Test] - public void Test_5347() - { - } - [Test] - public void Test_5348() - { - } - [Test] - public void Test_5349() - { - } - [Test] - public void Test_5350() - { - } - [Test] - public void Test_5351() - { - } - [Test] - public void Test_5352() - { - } - [Test] - public void Test_5353() - { - } - [Test] - public void Test_5354() - { - } - [Test] - public void Test_5355() - { - } - [Test] - public void Test_5356() - { - } - [Test] - public void Test_5357() - { - } - [Test] - public void Test_5358() - { - } - [Test] - public void Test_5359() - { - } - [Test] - public void Test_5360() - { - } - [Test] - public void Test_5361() - { - } - [Test] - public void Test_5362() - { - } - [Test] - public void Test_5363() - { - } - [Test] - public void Test_5364() - { - } - [Test] - public void Test_5365() - { - } - [Test] - public void Test_5366() - { - } - [Test] - public void Test_5367() - { - } - [Test] - public void Test_5368() - { - } - [Test] - public void Test_5369() - { - } - [Test] - public void Test_5370() - { - } - [Test] - public void Test_5371() - { - } - [Test] - public void Test_5372() - { - } - [Test] - public void Test_5373() - { - } - [Test] - public void Test_5374() - { - } - [Test] - public void Test_5375() - { - } - [Test] - public void Test_5376() - { - } - [Test] - public void Test_5377() - { - } - [Test] - public void Test_5378() - { - } - [Test] - public void Test_5379() - { - } - [Test] - public void Test_5380() - { - } - [Test] - public void Test_5381() - { - } - [Test] - public void Test_5382() - { - } - [Test] - public void Test_5383() - { - } - [Test] - public void Test_5384() - { - } - [Test] - public void Test_5385() - { - } - [Test] - public void Test_5386() - { - } - [Test] - public void Test_5387() - { - } - [Test] - public void Test_5388() - { - } - [Test] - public void Test_5389() - { - } - [Test] - public void Test_5390() - { - } - [Test] - public void Test_5391() - { - } - [Test] - public void Test_5392() - { - } - [Test] - public void Test_5393() - { - } - [Test] - public void Test_5394() - { - } - [Test] - public void Test_5395() - { - } - [Test] - public void Test_5396() - { - } - [Test] - public void Test_5397() - { - } - [Test] - public void Test_5398() - { - } - [Test] - public void Test_5399() - { - } - [Test] - public void Test_5400() - { - } - [Test] - public void Test_5401() - { - } - [Test] - public void Test_5402() - { - } - [Test] - public void Test_5403() - { - } - [Test] - public void Test_5404() - { - } - [Test] - public void Test_5405() - { - } - [Test] - public void Test_5406() - { - } - [Test] - public void Test_5407() - { - } - [Test] - public void Test_5408() - { - } - [Test] - public void Test_5409() - { - } - [Test] - public void Test_5410() - { - } - [Test] - public void Test_5411() - { - } - [Test] - public void Test_5412() - { - } - [Test] - public void Test_5413() - { - } - [Test] - public void Test_5414() - { - } - [Test] - public void Test_5415() - { - } - [Test] - public void Test_5416() - { - } - [Test] - public void Test_5417() - { - } - [Test] - public void Test_5418() - { - } - [Test] - public void Test_5419() - { - } - [Test] - public void Test_5420() - { - } - [Test] - public void Test_5421() - { - } - [Test] - public void Test_5422() - { - } - [Test] - public void Test_5423() - { - } - [Test] - public void Test_5424() - { - } - [Test] - public void Test_5425() - { - } - [Test] - public void Test_5426() - { - } - [Test] - public void Test_5427() - { - } - [Test] - public void Test_5428() - { - } - [Test] - public void Test_5429() - { - } - [Test] - public void Test_5430() - { - } - [Test] - public void Test_5431() - { - } - [Test] - public void Test_5432() - { - } - [Test] - public void Test_5433() - { - } - [Test] - public void Test_5434() - { - } - [Test] - public void Test_5435() - { - } - [Test] - public void Test_5436() - { - } - [Test] - public void Test_5437() - { - } - [Test] - public void Test_5438() - { - } - [Test] - public void Test_5439() - { - } - [Test] - public void Test_5440() - { - } - [Test] - public void Test_5441() - { - } - [Test] - public void Test_5442() - { - } - [Test] - public void Test_5443() - { - } - [Test] - public void Test_5444() - { - } - [Test] - public void Test_5445() - { - } - [Test] - public void Test_5446() - { - } - [Test] - public void Test_5447() - { - } - [Test] - public void Test_5448() - { - } - [Test] - public void Test_5449() - { - } - [Test] - public void Test_5450() - { - } - [Test] - public void Test_5451() - { - } - [Test] - public void Test_5452() - { - } - [Test] - public void Test_5453() - { - } - [Test] - public void Test_5454() - { - } - [Test] - public void Test_5455() - { - } - [Test] - public void Test_5456() - { - } - [Test] - public void Test_5457() - { - } - [Test] - public void Test_5458() - { - } - [Test] - public void Test_5459() - { - } - [Test] - public void Test_5460() - { - } - [Test] - public void Test_5461() - { - } - [Test] - public void Test_5462() - { - } - [Test] - public void Test_5463() - { - } - [Test] - public void Test_5464() - { - } - [Test] - public void Test_5465() - { - } - [Test] - public void Test_5466() - { - } - [Test] - public void Test_5467() - { - } - [Test] - public void Test_5468() - { - } - [Test] - public void Test_5469() - { - } - [Test] - public void Test_5470() - { - } - [Test] - public void Test_5471() - { - } - [Test] - public void Test_5472() - { - } - [Test] - public void Test_5473() - { - } - [Test] - public void Test_5474() - { - } - [Test] - public void Test_5475() - { - } - [Test] - public void Test_5476() - { - } - [Test] - public void Test_5477() - { - } - [Test] - public void Test_5478() - { - } - [Test] - public void Test_5479() - { - } - [Test] - public void Test_5480() - { - } - [Test] - public void Test_5481() - { - } - [Test] - public void Test_5482() - { - } - [Test] - public void Test_5483() - { - } - [Test] - public void Test_5484() - { - } - [Test] - public void Test_5485() - { - } - [Test] - public void Test_5486() - { - } - [Test] - public void Test_5487() - { - } - [Test] - public void Test_5488() - { - } - [Test] - public void Test_5489() - { - } - [Test] - public void Test_5490() - { - } - [Test] - public void Test_5491() - { - } - [Test] - public void Test_5492() - { - } - [Test] - public void Test_5493() - { - } - [Test] - public void Test_5494() - { - } - [Test] - public void Test_5495() - { - } - [Test] - public void Test_5496() - { - } - [Test] - public void Test_5497() - { - } - [Test] - public void Test_5498() - { - } - [Test] - public void Test_5499() - { - } - [Test] - public void Test_5500() - { - } - [Test] - public void Test_5501() - { - } - [Test] - public void Test_5502() - { - } - [Test] - public void Test_5503() - { - } - [Test] - public void Test_5504() - { - } - [Test] - public void Test_5505() - { - } - [Test] - public void Test_5506() - { - } - [Test] - public void Test_5507() - { - } - [Test] - public void Test_5508() - { - } - [Test] - public void Test_5509() - { - } - [Test] - public void Test_5510() - { - } - [Test] - public void Test_5511() - { - } - [Test] - public void Test_5512() - { - } - [Test] - public void Test_5513() - { - } - [Test] - public void Test_5514() - { - } - [Test] - public void Test_5515() - { - } - [Test] - public void Test_5516() - { - } - [Test] - public void Test_5517() - { - } - [Test] - public void Test_5518() - { - } - [Test] - public void Test_5519() - { - } - [Test] - public void Test_5520() - { - } - [Test] - public void Test_5521() - { - } - [Test] - public void Test_5522() - { - } - [Test] - public void Test_5523() - { - } - [Test] - public void Test_5524() - { - } - [Test] - public void Test_5525() - { - } - [Test] - public void Test_5526() - { - } - [Test] - public void Test_5527() - { - } - [Test] - public void Test_5528() - { - } - [Test] - public void Test_5529() - { - } - [Test] - public void Test_5530() - { - } - [Test] - public void Test_5531() - { - } - [Test] - public void Test_5532() - { - } - [Test] - public void Test_5533() - { - } - [Test] - public void Test_5534() - { - } - [Test] - public void Test_5535() - { - } - [Test] - public void Test_5536() - { - } - [Test] - public void Test_5537() - { - } - [Test] - public void Test_5538() - { - } - [Test] - public void Test_5539() - { - } - [Test] - public void Test_5540() - { - } - [Test] - public void Test_5541() - { - } - [Test] - public void Test_5542() - { - } - [Test] - public void Test_5543() - { - } - [Test] - public void Test_5544() - { - } - [Test] - public void Test_5545() - { - } - [Test] - public void Test_5546() - { - } - [Test] - public void Test_5547() - { - } - [Test] - public void Test_5548() - { - } - [Test] - public void Test_5549() - { - } - [Test] - public void Test_5550() - { - } - [Test] - public void Test_5551() - { - } - [Test] - public void Test_5552() - { - } - [Test] - public void Test_5553() - { - } - [Test] - public void Test_5554() - { - } - [Test] - public void Test_5555() - { - } - [Test] - public void Test_5556() - { - } - [Test] - public void Test_5557() - { - } - [Test] - public void Test_5558() - { - } - [Test] - public void Test_5559() - { - } - [Test] - public void Test_5560() - { - } - [Test] - public void Test_5561() - { - } - [Test] - public void Test_5562() - { - } - [Test] - public void Test_5563() - { - } - [Test] - public void Test_5564() - { - } - [Test] - public void Test_5565() - { - } - [Test] - public void Test_5566() - { - } - [Test] - public void Test_5567() - { - } - [Test] - public void Test_5568() - { - } - [Test] - public void Test_5569() - { - } - [Test] - public void Test_5570() - { - } - [Test] - public void Test_5571() - { - } - [Test] - public void Test_5572() - { - } - [Test] - public void Test_5573() - { - } - [Test] - public void Test_5574() - { - } - [Test] - public void Test_5575() - { - } - [Test] - public void Test_5576() - { - } - [Test] - public void Test_5577() - { - } - [Test] - public void Test_5578() - { - } - [Test] - public void Test_5579() - { - } - [Test] - public void Test_5580() - { - } - [Test] - public void Test_5581() - { - } - [Test] - public void Test_5582() - { - } - [Test] - public void Test_5583() - { - } - [Test] - public void Test_5584() - { - } - [Test] - public void Test_5585() - { - } - [Test] - public void Test_5586() - { - } - [Test] - public void Test_5587() - { - } - [Test] - public void Test_5588() - { - } - [Test] - public void Test_5589() - { - } - [Test] - public void Test_5590() - { - } - [Test] - public void Test_5591() - { - } - [Test] - public void Test_5592() - { - } - [Test] - public void Test_5593() - { - } - [Test] - public void Test_5594() - { - } - [Test] - public void Test_5595() - { - } - [Test] - public void Test_5596() - { - } - [Test] - public void Test_5597() - { - } - [Test] - public void Test_5598() - { - } - [Test] - public void Test_5599() - { - } - [Test] - public void Test_5600() - { - } - [Test] - public void Test_5601() - { - } - [Test] - public void Test_5602() - { - } - [Test] - public void Test_5603() - { - } - [Test] - public void Test_5604() - { - } - [Test] - public void Test_5605() - { - } - [Test] - public void Test_5606() - { - } - [Test] - public void Test_5607() - { - } - [Test] - public void Test_5608() - { - } - [Test] - public void Test_5609() - { - } - [Test] - public void Test_5610() - { - } - [Test] - public void Test_5611() - { - } - [Test] - public void Test_5612() - { - } - [Test] - public void Test_5613() - { - } - [Test] - public void Test_5614() - { - } - [Test] - public void Test_5615() - { - } - [Test] - public void Test_5616() - { - } - [Test] - public void Test_5617() - { - } - [Test] - public void Test_5618() - { - } - [Test] - public void Test_5619() - { - } - [Test] - public void Test_5620() - { - } - [Test] - public void Test_5621() - { - } - [Test] - public void Test_5622() - { - } - [Test] - public void Test_5623() - { - } - [Test] - public void Test_5624() - { - } - [Test] - public void Test_5625() - { - } - [Test] - public void Test_5626() - { - } - [Test] - public void Test_5627() - { - } - [Test] - public void Test_5628() - { - } - [Test] - public void Test_5629() - { - } - [Test] - public void Test_5630() - { - } - [Test] - public void Test_5631() - { - } - [Test] - public void Test_5632() - { - } - [Test] - public void Test_5633() - { - } - [Test] - public void Test_5634() - { - } - [Test] - public void Test_5635() - { - } - [Test] - public void Test_5636() - { - } - [Test] - public void Test_5637() - { - } - [Test] - public void Test_5638() - { - } - [Test] - public void Test_5639() - { - } - [Test] - public void Test_5640() - { - } - [Test] - public void Test_5641() - { - } - [Test] - public void Test_5642() - { - } - [Test] - public void Test_5643() - { - } - [Test] - public void Test_5644() - { - } - [Test] - public void Test_5645() - { - } - [Test] - public void Test_5646() - { - } - [Test] - public void Test_5647() - { - } - [Test] - public void Test_5648() - { - } - [Test] - public void Test_5649() - { - } - [Test] - public void Test_5650() - { - } - [Test] - public void Test_5651() - { - } - [Test] - public void Test_5652() - { - } - [Test] - public void Test_5653() - { - } - [Test] - public void Test_5654() - { - } - [Test] - public void Test_5655() - { - } - [Test] - public void Test_5656() - { - } - [Test] - public void Test_5657() - { - } - [Test] - public void Test_5658() - { - } - [Test] - public void Test_5659() - { - } - [Test] - public void Test_5660() - { - } - [Test] - public void Test_5661() - { - } - [Test] - public void Test_5662() - { - } - [Test] - public void Test_5663() - { - } - [Test] - public void Test_5664() - { - } - [Test] - public void Test_5665() - { - } - [Test] - public void Test_5666() - { - } - [Test] - public void Test_5667() - { - } - [Test] - public void Test_5668() - { - } - [Test] - public void Test_5669() - { - } - [Test] - public void Test_5670() - { - } - [Test] - public void Test_5671() - { - } - [Test] - public void Test_5672() - { - } - [Test] - public void Test_5673() - { - } - [Test] - public void Test_5674() - { - } - [Test] - public void Test_5675() - { - } - [Test] - public void Test_5676() - { - } - [Test] - public void Test_5677() - { - } - [Test] - public void Test_5678() - { - } - [Test] - public void Test_5679() - { - } - [Test] - public void Test_5680() - { - } - [Test] - public void Test_5681() - { - } - [Test] - public void Test_5682() - { - } - [Test] - public void Test_5683() - { - } - [Test] - public void Test_5684() - { - } - [Test] - public void Test_5685() - { - } - [Test] - public void Test_5686() - { - } - [Test] - public void Test_5687() - { - } - [Test] - public void Test_5688() - { - } - [Test] - public void Test_5689() - { - } - [Test] - public void Test_5690() - { - } - [Test] - public void Test_5691() - { - } - [Test] - public void Test_5692() - { - } - [Test] - public void Test_5693() - { - } - [Test] - public void Test_5694() - { - } - [Test] - public void Test_5695() - { - } - [Test] - public void Test_5696() - { - } - [Test] - public void Test_5697() - { - } - [Test] - public void Test_5698() - { - } - [Test] - public void Test_5699() - { - } - [Test] - public void Test_5700() - { - } - [Test] - public void Test_5701() - { - } - [Test] - public void Test_5702() - { - } - [Test] - public void Test_5703() - { - } - [Test] - public void Test_5704() - { - } - [Test] - public void Test_5705() - { - } - [Test] - public void Test_5706() - { - } - [Test] - public void Test_5707() - { - } - [Test] - public void Test_5708() - { - } - [Test] - public void Test_5709() - { - } - [Test] - public void Test_5710() - { - } - [Test] - public void Test_5711() - { - } - [Test] - public void Test_5712() - { - } - [Test] - public void Test_5713() - { - } - [Test] - public void Test_5714() - { - } - [Test] - public void Test_5715() - { - } - [Test] - public void Test_5716() - { - } - [Test] - public void Test_5717() - { - } - [Test] - public void Test_5718() - { - } - [Test] - public void Test_5719() - { - } - [Test] - public void Test_5720() - { - } - [Test] - public void Test_5721() - { - } - [Test] - public void Test_5722() - { - } - [Test] - public void Test_5723() - { - } - [Test] - public void Test_5724() - { - } - [Test] - public void Test_5725() - { - } - [Test] - public void Test_5726() - { - } - [Test] - public void Test_5727() - { - } - [Test] - public void Test_5728() - { - } - [Test] - public void Test_5729() - { - } - [Test] - public void Test_5730() - { - } - [Test] - public void Test_5731() - { - } - [Test] - public void Test_5732() - { - } - [Test] - public void Test_5733() - { - } - [Test] - public void Test_5734() - { - } - [Test] - public void Test_5735() - { - } - [Test] - public void Test_5736() - { - } - [Test] - public void Test_5737() - { - } - [Test] - public void Test_5738() - { - } - [Test] - public void Test_5739() - { - } - [Test] - public void Test_5740() - { - } - [Test] - public void Test_5741() - { - } - [Test] - public void Test_5742() - { - } - [Test] - public void Test_5743() - { - } - [Test] - public void Test_5744() - { - } - [Test] - public void Test_5745() - { - } - [Test] - public void Test_5746() - { - } - [Test] - public void Test_5747() - { - } - [Test] - public void Test_5748() - { - } - [Test] - public void Test_5749() - { - } - [Test] - public void Test_5750() - { - } - [Test] - public void Test_5751() - { - } - [Test] - public void Test_5752() - { - } - [Test] - public void Test_5753() - { - } - [Test] - public void Test_5754() - { - } - [Test] - public void Test_5755() - { - } - [Test] - public void Test_5756() - { - } - [Test] - public void Test_5757() - { - } - [Test] - public void Test_5758() - { - } - [Test] - public void Test_5759() - { - } - [Test] - public void Test_5760() - { - } - [Test] - public void Test_5761() - { - } - [Test] - public void Test_5762() - { - } - [Test] - public void Test_5763() - { - } - [Test] - public void Test_5764() - { - } - [Test] - public void Test_5765() - { - } - [Test] - public void Test_5766() - { - } - [Test] - public void Test_5767() - { - } - [Test] - public void Test_5768() - { - } - [Test] - public void Test_5769() - { - } - [Test] - public void Test_5770() - { - } - [Test] - public void Test_5771() - { - } - [Test] - public void Test_5772() - { - } - [Test] - public void Test_5773() - { - } - [Test] - public void Test_5774() - { - } - [Test] - public void Test_5775() - { - } - [Test] - public void Test_5776() - { - } - [Test] - public void Test_5777() - { - } - [Test] - public void Test_5778() - { - } - [Test] - public void Test_5779() - { - } - [Test] - public void Test_5780() - { - } - [Test] - public void Test_5781() - { - } - [Test] - public void Test_5782() - { - } - [Test] - public void Test_5783() - { - } - [Test] - public void Test_5784() - { - } - [Test] - public void Test_5785() - { - } - [Test] - public void Test_5786() - { - } - [Test] - public void Test_5787() - { - } - [Test] - public void Test_5788() - { - } - [Test] - public void Test_5789() - { - } - [Test] - public void Test_5790() - { - } - [Test] - public void Test_5791() - { - } - [Test] - public void Test_5792() - { - } - [Test] - public void Test_5793() - { - } - [Test] - public void Test_5794() - { - } - [Test] - public void Test_5795() - { - } - [Test] - public void Test_5796() - { - } - [Test] - public void Test_5797() - { - } - [Test] - public void Test_5798() - { - } - [Test] - public void Test_5799() - { - } - [Test] - public void Test_5800() - { - } - [Test] - public void Test_5801() - { - } - [Test] - public void Test_5802() - { - } - [Test] - public void Test_5803() - { - } - [Test] - public void Test_5804() - { - } - [Test] - public void Test_5805() - { - } - [Test] - public void Test_5806() - { - } - [Test] - public void Test_5807() - { - } - [Test] - public void Test_5808() - { - } - [Test] - public void Test_5809() - { - } - [Test] - public void Test_5810() - { - } - [Test] - public void Test_5811() - { - } - [Test] - public void Test_5812() - { - } - [Test] - public void Test_5813() - { - } - [Test] - public void Test_5814() - { - } - [Test] - public void Test_5815() - { - } - [Test] - public void Test_5816() - { - } - [Test] - public void Test_5817() - { - } - [Test] - public void Test_5818() - { - } - [Test] - public void Test_5819() - { - } - [Test] - public void Test_5820() - { - } - [Test] - public void Test_5821() - { - } - [Test] - public void Test_5822() - { - } - [Test] - public void Test_5823() - { - } - [Test] - public void Test_5824() - { - } - [Test] - public void Test_5825() - { - } - [Test] - public void Test_5826() - { - } - [Test] - public void Test_5827() - { - } - [Test] - public void Test_5828() - { - } - [Test] - public void Test_5829() - { - } - [Test] - public void Test_5830() - { - } - [Test] - public void Test_5831() - { - } - [Test] - public void Test_5832() - { - } - [Test] - public void Test_5833() - { - } - [Test] - public void Test_5834() - { - } - [Test] - public void Test_5835() - { - } - [Test] - public void Test_5836() - { - } - [Test] - public void Test_5837() - { - } - [Test] - public void Test_5838() - { - } - [Test] - public void Test_5839() - { - } - [Test] - public void Test_5840() - { - } - [Test] - public void Test_5841() - { - } - [Test] - public void Test_5842() - { - } - [Test] - public void Test_5843() - { - } - [Test] - public void Test_5844() - { - } - [Test] - public void Test_5845() - { - } - [Test] - public void Test_5846() - { - } - [Test] - public void Test_5847() - { - } - [Test] - public void Test_5848() - { - } - [Test] - public void Test_5849() - { - } - [Test] - public void Test_5850() - { - } - [Test] - public void Test_5851() - { - } - [Test] - public void Test_5852() - { - } - [Test] - public void Test_5853() - { - } - [Test] - public void Test_5854() - { - } - [Test] - public void Test_5855() - { - } - [Test] - public void Test_5856() - { - } - [Test] - public void Test_5857() - { - } - [Test] - public void Test_5858() - { - } - [Test] - public void Test_5859() - { - } - [Test] - public void Test_5860() - { - } - [Test] - public void Test_5861() - { - } - [Test] - public void Test_5862() - { - } - [Test] - public void Test_5863() - { - } - [Test] - public void Test_5864() - { - } - [Test] - public void Test_5865() - { - } - [Test] - public void Test_5866() - { - } - [Test] - public void Test_5867() - { - } - [Test] - public void Test_5868() - { - } - [Test] - public void Test_5869() - { - } - [Test] - public void Test_5870() - { - } - [Test] - public void Test_5871() - { - } - [Test] - public void Test_5872() - { - } - [Test] - public void Test_5873() - { - } - [Test] - public void Test_5874() - { - } - [Test] - public void Test_5875() - { - } - [Test] - public void Test_5876() - { - } - [Test] - public void Test_5877() - { - } - [Test] - public void Test_5878() - { - } - [Test] - public void Test_5879() - { - } - [Test] - public void Test_5880() - { - } - [Test] - public void Test_5881() - { - } - [Test] - public void Test_5882() - { - } - [Test] - public void Test_5883() - { - } - [Test] - public void Test_5884() - { - } - [Test] - public void Test_5885() - { - } - [Test] - public void Test_5886() - { - } - [Test] - public void Test_5887() - { - } - [Test] - public void Test_5888() - { - } - [Test] - public void Test_5889() - { - } - [Test] - public void Test_5890() - { - } - [Test] - public void Test_5891() - { - } - [Test] - public void Test_5892() - { - } - [Test] - public void Test_5893() - { - } - [Test] - public void Test_5894() - { - } - [Test] - public void Test_5895() - { - } - [Test] - public void Test_5896() - { - } - [Test] - public void Test_5897() - { - } - [Test] - public void Test_5898() - { - } - [Test] - public void Test_5899() - { - } - [Test] - public void Test_5900() - { - } - [Test] - public void Test_5901() - { - } - [Test] - public void Test_5902() - { - } - [Test] - public void Test_5903() - { - } - [Test] - public void Test_5904() - { - } - [Test] - public void Test_5905() - { - } - [Test] - public void Test_5906() - { - } - [Test] - public void Test_5907() - { - } - [Test] - public void Test_5908() - { - } - [Test] - public void Test_5909() - { - } - [Test] - public void Test_5910() - { - } - [Test] - public void Test_5911() - { - } - [Test] - public void Test_5912() - { - } - [Test] - public void Test_5913() - { - } - [Test] - public void Test_5914() - { - } - [Test] - public void Test_5915() - { - } - [Test] - public void Test_5916() - { - } - [Test] - public void Test_5917() - { - } - [Test] - public void Test_5918() - { - } - [Test] - public void Test_5919() - { - } - [Test] - public void Test_5920() - { - } - [Test] - public void Test_5921() - { - } - [Test] - public void Test_5922() - { - } - [Test] - public void Test_5923() - { - } - [Test] - public void Test_5924() - { - } - [Test] - public void Test_5925() - { - } - [Test] - public void Test_5926() - { - } - [Test] - public void Test_5927() - { - } - [Test] - public void Test_5928() - { - } - [Test] - public void Test_5929() - { - } - [Test] - public void Test_5930() - { - } - [Test] - public void Test_5931() - { - } - [Test] - public void Test_5932() - { - } - [Test] - public void Test_5933() - { - } - [Test] - public void Test_5934() - { - } - [Test] - public void Test_5935() - { - } - [Test] - public void Test_5936() - { - } - [Test] - public void Test_5937() - { - } - [Test] - public void Test_5938() - { - } - [Test] - public void Test_5939() - { - } - [Test] - public void Test_5940() - { - } - [Test] - public void Test_5941() - { - } - [Test] - public void Test_5942() - { - } - [Test] - public void Test_5943() - { - } - [Test] - public void Test_5944() - { - } - [Test] - public void Test_5945() - { - } - [Test] - public void Test_5946() - { - } - [Test] - public void Test_5947() - { - } - [Test] - public void Test_5948() - { - } - [Test] - public void Test_5949() - { - } - [Test] - public void Test_5950() - { - } - [Test] - public void Test_5951() - { - } - [Test] - public void Test_5952() - { - } - [Test] - public void Test_5953() - { - } - [Test] - public void Test_5954() - { - } - [Test] - public void Test_5955() - { - } - [Test] - public void Test_5956() - { - } - [Test] - public void Test_5957() - { - } - [Test] - public void Test_5958() - { - } - [Test] - public void Test_5959() - { - } - [Test] - public void Test_5960() - { - } - [Test] - public void Test_5961() - { - } - [Test] - public void Test_5962() - { - } - [Test] - public void Test_5963() - { - } - [Test] - public void Test_5964() - { - } - [Test] - public void Test_5965() - { - } - [Test] - public void Test_5966() - { - } - [Test] - public void Test_5967() - { - } - [Test] - public void Test_5968() - { - } - [Test] - public void Test_5969() - { - } - [Test] - public void Test_5970() - { - } - [Test] - public void Test_5971() - { - } - [Test] - public void Test_5972() - { - } - [Test] - public void Test_5973() - { - } - [Test] - public void Test_5974() - { - } - [Test] - public void Test_5975() - { - } - [Test] - public void Test_5976() - { - } - [Test] - public void Test_5977() - { - } - [Test] - public void Test_5978() - { - } - [Test] - public void Test_5979() - { - } - [Test] - public void Test_5980() - { - } - [Test] - public void Test_5981() - { - } - [Test] - public void Test_5982() - { - } - [Test] - public void Test_5983() - { - } - [Test] - public void Test_5984() - { - } - [Test] - public void Test_5985() - { - } - [Test] - public void Test_5986() - { - } - [Test] - public void Test_5987() - { - } - [Test] - public void Test_5988() - { - } - [Test] - public void Test_5989() - { - } - [Test] - public void Test_5990() - { - } - [Test] - public void Test_5991() - { - } - [Test] - public void Test_5992() - { - } - [Test] - public void Test_5993() - { - } - [Test] - public void Test_5994() - { - } - [Test] - public void Test_5995() - { - } - [Test] - public void Test_5996() - { - } - [Test] - public void Test_5997() - { - } - [Test] - public void Test_5998() - { - } - [Test] - public void Test_5999() - { - } - [Test] - public void Test_6000() - { - } - [Test] - public void Test_6001() - { - } - [Test] - public void Test_6002() - { - } - [Test] - public void Test_6003() - { - } - [Test] - public void Test_6004() - { - } - [Test] - public void Test_6005() - { - } - [Test] - public void Test_6006() - { - } - [Test] - public void Test_6007() - { - } - [Test] - public void Test_6008() - { - } - [Test] - public void Test_6009() - { - } - [Test] - public void Test_6010() - { - } - [Test] - public void Test_6011() - { - } - [Test] - public void Test_6012() - { - } - [Test] - public void Test_6013() - { - } - [Test] - public void Test_6014() - { - } - [Test] - public void Test_6015() - { - } - [Test] - public void Test_6016() - { - } - [Test] - public void Test_6017() - { - } - [Test] - public void Test_6018() - { - } - [Test] - public void Test_6019() - { - } - [Test] - public void Test_6020() - { - } - [Test] - public void Test_6021() - { - } - [Test] - public void Test_6022() - { - } - [Test] - public void Test_6023() - { - } - [Test] - public void Test_6024() - { - } - [Test] - public void Test_6025() - { - } - [Test] - public void Test_6026() - { - } - [Test] - public void Test_6027() - { - } - [Test] - public void Test_6028() - { - } - [Test] - public void Test_6029() - { - } - [Test] - public void Test_6030() - { - } - [Test] - public void Test_6031() - { - } - [Test] - public void Test_6032() - { - } - [Test] - public void Test_6033() - { - } - [Test] - public void Test_6034() - { - } - [Test] - public void Test_6035() - { - } - [Test] - public void Test_6036() - { - } - [Test] - public void Test_6037() - { - } - [Test] - public void Test_6038() - { - } - [Test] - public void Test_6039() - { - } - [Test] - public void Test_6040() - { - } - [Test] - public void Test_6041() - { - } - [Test] - public void Test_6042() - { - } - [Test] - public void Test_6043() - { - } - [Test] - public void Test_6044() - { - } - [Test] - public void Test_6045() - { - } - [Test] - public void Test_6046() - { - } - [Test] - public void Test_6047() - { - } - [Test] - public void Test_6048() - { - } - [Test] - public void Test_6049() - { - } - [Test] - public void Test_6050() - { - } - [Test] - public void Test_6051() - { - } - [Test] - public void Test_6052() - { - } - [Test] - public void Test_6053() - { - } - [Test] - public void Test_6054() - { - } - [Test] - public void Test_6055() - { - } - [Test] - public void Test_6056() - { - } - [Test] - public void Test_6057() - { - } - [Test] - public void Test_6058() - { - } - [Test] - public void Test_6059() - { - } - [Test] - public void Test_6060() - { - } - [Test] - public void Test_6061() - { - } - [Test] - public void Test_6062() - { - } - [Test] - public void Test_6063() - { - } - [Test] - public void Test_6064() - { - } - [Test] - public void Test_6065() - { - } - [Test] - public void Test_6066() - { - } - [Test] - public void Test_6067() - { - } - [Test] - public void Test_6068() - { - } - [Test] - public void Test_6069() - { - } - [Test] - public void Test_6070() - { - } - [Test] - public void Test_6071() - { - } - [Test] - public void Test_6072() - { - } - [Test] - public void Test_6073() - { - } - [Test] - public void Test_6074() - { - } - [Test] - public void Test_6075() - { - } - [Test] - public void Test_6076() - { - } - [Test] - public void Test_6077() - { - } - [Test] - public void Test_6078() - { - } - [Test] - public void Test_6079() - { - } - [Test] - public void Test_6080() - { - } - [Test] - public void Test_6081() - { - } - [Test] - public void Test_6082() - { - } - [Test] - public void Test_6083() - { - } - [Test] - public void Test_6084() - { - } - [Test] - public void Test_6085() - { - } - [Test] - public void Test_6086() - { - } - [Test] - public void Test_6087() - { - } - [Test] - public void Test_6088() - { - } - [Test] - public void Test_6089() - { - } - [Test] - public void Test_6090() - { - } - [Test] - public void Test_6091() - { - } - [Test] - public void Test_6092() - { - } - [Test] - public void Test_6093() - { - } - [Test] - public void Test_6094() - { - } - [Test] - public void Test_6095() - { - } - [Test] - public void Test_6096() - { - } - [Test] - public void Test_6097() - { - } - [Test] - public void Test_6098() - { - } - [Test] - public void Test_6099() - { - } - [Test] - public void Test_6100() - { - } - [Test] - public void Test_6101() - { - } - [Test] - public void Test_6102() - { - } - [Test] - public void Test_6103() - { - } - [Test] - public void Test_6104() - { - } - [Test] - public void Test_6105() - { - } - [Test] - public void Test_6106() - { - } - [Test] - public void Test_6107() - { - } - [Test] - public void Test_6108() - { - } - [Test] - public void Test_6109() - { - } - [Test] - public void Test_6110() - { - } - [Test] - public void Test_6111() - { - } - [Test] - public void Test_6112() - { - } - [Test] - public void Test_6113() - { - } - [Test] - public void Test_6114() - { - } - [Test] - public void Test_6115() - { - } - [Test] - public void Test_6116() - { - } - [Test] - public void Test_6117() - { - } - [Test] - public void Test_6118() - { - } - [Test] - public void Test_6119() - { - } - [Test] - public void Test_6120() - { - } - [Test] - public void Test_6121() - { - } - [Test] - public void Test_6122() - { - } - [Test] - public void Test_6123() - { - } - [Test] - public void Test_6124() - { - } - [Test] - public void Test_6125() - { - } - [Test] - public void Test_6126() - { - } - [Test] - public void Test_6127() - { - } - [Test] - public void Test_6128() - { - } - [Test] - public void Test_6129() - { - } - [Test] - public void Test_6130() - { - } - [Test] - public void Test_6131() - { - } - [Test] - public void Test_6132() - { - } - [Test] - public void Test_6133() - { - } - [Test] - public void Test_6134() - { - } - [Test] - public void Test_6135() - { - } - [Test] - public void Test_6136() - { - } - [Test] - public void Test_6137() - { - } - [Test] - public void Test_6138() - { - } - [Test] - public void Test_6139() - { - } - [Test] - public void Test_6140() - { - } - [Test] - public void Test_6141() - { - } - [Test] - public void Test_6142() - { - } - [Test] - public void Test_6143() - { - } - [Test] - public void Test_6144() - { - } - [Test] - public void Test_6145() - { - } - [Test] - public void Test_6146() - { - } - [Test] - public void Test_6147() - { - } - [Test] - public void Test_6148() - { - } - [Test] - public void Test_6149() - { - } - [Test] - public void Test_6150() - { - } - [Test] - public void Test_6151() - { - } - [Test] - public void Test_6152() - { - } - [Test] - public void Test_6153() - { - } - [Test] - public void Test_6154() - { - } - [Test] - public void Test_6155() - { - } - [Test] - public void Test_6156() - { - } - [Test] - public void Test_6157() - { - } - [Test] - public void Test_6158() - { - } - [Test] - public void Test_6159() - { - } - [Test] - public void Test_6160() - { - } - [Test] - public void Test_6161() - { - } - [Test] - public void Test_6162() - { - } - [Test] - public void Test_6163() - { - } - [Test] - public void Test_6164() - { - } - [Test] - public void Test_6165() - { - } - [Test] - public void Test_6166() - { - } - [Test] - public void Test_6167() - { - } - [Test] - public void Test_6168() - { - } - [Test] - public void Test_6169() - { - } - [Test] - public void Test_6170() - { - } - [Test] - public void Test_6171() - { - } - [Test] - public void Test_6172() - { - } - [Test] - public void Test_6173() - { - } - [Test] - public void Test_6174() - { - } - [Test] - public void Test_6175() - { - } - [Test] - public void Test_6176() - { - } - [Test] - public void Test_6177() - { - } - [Test] - public void Test_6178() - { - } - [Test] - public void Test_6179() - { - } - [Test] - public void Test_6180() - { - } - [Test] - public void Test_6181() - { - } - [Test] - public void Test_6182() - { - } - [Test] - public void Test_6183() - { - } - [Test] - public void Test_6184() - { - } - [Test] - public void Test_6185() - { - } - [Test] - public void Test_6186() - { - } - [Test] - public void Test_6187() - { - } - [Test] - public void Test_6188() - { - } - [Test] - public void Test_6189() - { - } - [Test] - public void Test_6190() - { - } - [Test] - public void Test_6191() - { - } - [Test] - public void Test_6192() - { - } - [Test] - public void Test_6193() - { - } - [Test] - public void Test_6194() - { - } - [Test] - public void Test_6195() - { - } - [Test] - public void Test_6196() - { - } - [Test] - public void Test_6197() - { - } - [Test] - public void Test_6198() - { - } - [Test] - public void Test_6199() - { - } - [Test] - public void Test_6200() - { - } - [Test] - public void Test_6201() - { - } - [Test] - public void Test_6202() - { - } - [Test] - public void Test_6203() - { - } - [Test] - public void Test_6204() - { - } - [Test] - public void Test_6205() - { - } - [Test] - public void Test_6206() - { - } - [Test] - public void Test_6207() - { - } - [Test] - public void Test_6208() - { - } - [Test] - public void Test_6209() - { - } - [Test] - public void Test_6210() - { - } - [Test] - public void Test_6211() - { - } - [Test] - public void Test_6212() - { - } - [Test] - public void Test_6213() - { - } - [Test] - public void Test_6214() - { - } - [Test] - public void Test_6215() - { - } - [Test] - public void Test_6216() - { - } - [Test] - public void Test_6217() - { - } - [Test] - public void Test_6218() - { - } - [Test] - public void Test_6219() - { - } - [Test] - public void Test_6220() - { - } - [Test] - public void Test_6221() - { - } - [Test] - public void Test_6222() - { - } - [Test] - public void Test_6223() - { - } - [Test] - public void Test_6224() - { - } - [Test] - public void Test_6225() - { - } - [Test] - public void Test_6226() - { - } - [Test] - public void Test_6227() - { - } - [Test] - public void Test_6228() - { - } - [Test] - public void Test_6229() - { - } - [Test] - public void Test_6230() - { - } - [Test] - public void Test_6231() - { - } - [Test] - public void Test_6232() - { - } - [Test] - public void Test_6233() - { - } - [Test] - public void Test_6234() - { - } - [Test] - public void Test_6235() - { - } - [Test] - public void Test_6236() - { - } - [Test] - public void Test_6237() - { - } - [Test] - public void Test_6238() - { - } - [Test] - public void Test_6239() - { - } - [Test] - public void Test_6240() - { - } - [Test] - public void Test_6241() - { - } - [Test] - public void Test_6242() - { - } - [Test] - public void Test_6243() - { - } - [Test] - public void Test_6244() - { - } - [Test] - public void Test_6245() - { - } - [Test] - public void Test_6246() - { - } - [Test] - public void Test_6247() - { - } - [Test] - public void Test_6248() - { - } - [Test] - public void Test_6249() - { - } - [Test] - public void Test_6250() - { - } - [Test] - public void Test_6251() - { - } - [Test] - public void Test_6252() - { - } - [Test] - public void Test_6253() - { - } - [Test] - public void Test_6254() - { - } - [Test] - public void Test_6255() - { - } - [Test] - public void Test_6256() - { - } - [Test] - public void Test_6257() - { - } - [Test] - public void Test_6258() - { - } - [Test] - public void Test_6259() - { - } - [Test] - public void Test_6260() - { - } - [Test] - public void Test_6261() - { - } - [Test] - public void Test_6262() - { - } - [Test] - public void Test_6263() - { - } - [Test] - public void Test_6264() - { - } - [Test] - public void Test_6265() - { - } - [Test] - public void Test_6266() - { - } - [Test] - public void Test_6267() - { - } - [Test] - public void Test_6268() - { - } - [Test] - public void Test_6269() - { - } - [Test] - public void Test_6270() - { - } - [Test] - public void Test_6271() - { - } - [Test] - public void Test_6272() - { - } - [Test] - public void Test_6273() - { - } - [Test] - public void Test_6274() - { - } - [Test] - public void Test_6275() - { - } - [Test] - public void Test_6276() - { - } - [Test] - public void Test_6277() - { - } - [Test] - public void Test_6278() - { - } - [Test] - public void Test_6279() - { - } - [Test] - public void Test_6280() - { - } - [Test] - public void Test_6281() - { - } - [Test] - public void Test_6282() - { - } - [Test] - public void Test_6283() - { - } - [Test] - public void Test_6284() - { - } - [Test] - public void Test_6285() - { - } - [Test] - public void Test_6286() - { - } - [Test] - public void Test_6287() - { - } - [Test] - public void Test_6288() - { - } - [Test] - public void Test_6289() - { - } - [Test] - public void Test_6290() - { - } - [Test] - public void Test_6291() - { - } - [Test] - public void Test_6292() - { - } - [Test] - public void Test_6293() - { - } - [Test] - public void Test_6294() - { - } - [Test] - public void Test_6295() - { - } - [Test] - public void Test_6296() - { - } - [Test] - public void Test_6297() - { - } - [Test] - public void Test_6298() - { - } - [Test] - public void Test_6299() - { - } - [Test] - public void Test_6300() - { - } - [Test] - public void Test_6301() - { - } - [Test] - public void Test_6302() - { - } - [Test] - public void Test_6303() - { - } - [Test] - public void Test_6304() - { - } - [Test] - public void Test_6305() - { - } - [Test] - public void Test_6306() - { - } - [Test] - public void Test_6307() - { - } - [Test] - public void Test_6308() - { - } - [Test] - public void Test_6309() - { - } - [Test] - public void Test_6310() - { - } - [Test] - public void Test_6311() - { - } - [Test] - public void Test_6312() - { - } - [Test] - public void Test_6313() - { - } - [Test] - public void Test_6314() - { - } - [Test] - public void Test_6315() - { - } - [Test] - public void Test_6316() - { - } - [Test] - public void Test_6317() - { - } - [Test] - public void Test_6318() - { - } - [Test] - public void Test_6319() - { - } - [Test] - public void Test_6320() - { - } - [Test] - public void Test_6321() - { - } - [Test] - public void Test_6322() - { - } - [Test] - public void Test_6323() - { - } - [Test] - public void Test_6324() - { - } - [Test] - public void Test_6325() - { - } - [Test] - public void Test_6326() - { - } - [Test] - public void Test_6327() - { - } - [Test] - public void Test_6328() - { - } - [Test] - public void Test_6329() - { - } - [Test] - public void Test_6330() - { - } - [Test] - public void Test_6331() - { - } - [Test] - public void Test_6332() - { - } - [Test] - public void Test_6333() - { - } - [Test] - public void Test_6334() - { - } - [Test] - public void Test_6335() - { - } - [Test] - public void Test_6336() - { - } - [Test] - public void Test_6337() - { - } - [Test] - public void Test_6338() - { - } - [Test] - public void Test_6339() - { - } - [Test] - public void Test_6340() - { - } - [Test] - public void Test_6341() - { - } - [Test] - public void Test_6342() - { - } - [Test] - public void Test_6343() - { - } - [Test] - public void Test_6344() - { - } - [Test] - public void Test_6345() - { - } - [Test] - public void Test_6346() - { - } - [Test] - public void Test_6347() - { - } - [Test] - public void Test_6348() - { - } - [Test] - public void Test_6349() - { - } - [Test] - public void Test_6350() - { - } - [Test] - public void Test_6351() - { - } - [Test] - public void Test_6352() - { - } - [Test] - public void Test_6353() - { - } - [Test] - public void Test_6354() - { - } - [Test] - public void Test_6355() - { - } - [Test] - public void Test_6356() - { - } - [Test] - public void Test_6357() - { - } - [Test] - public void Test_6358() - { - } - [Test] - public void Test_6359() - { - } - [Test] - public void Test_6360() - { - } - [Test] - public void Test_6361() - { - } - [Test] - public void Test_6362() - { - } - [Test] - public void Test_6363() - { - } - [Test] - public void Test_6364() - { - } - [Test] - public void Test_6365() - { - } - [Test] - public void Test_6366() - { - } - [Test] - public void Test_6367() - { - } - [Test] - public void Test_6368() - { - } - [Test] - public void Test_6369() - { - } - [Test] - public void Test_6370() - { - } - [Test] - public void Test_6371() - { - } - [Test] - public void Test_6372() - { - } - [Test] - public void Test_6373() - { - } - [Test] - public void Test_6374() - { - } - [Test] - public void Test_6375() - { - } - [Test] - public void Test_6376() - { - } - [Test] - public void Test_6377() - { - } - [Test] - public void Test_6378() - { - } - [Test] - public void Test_6379() - { - } - [Test] - public void Test_6380() - { - } - [Test] - public void Test_6381() - { - } - [Test] - public void Test_6382() - { - } - [Test] - public void Test_6383() - { - } - [Test] - public void Test_6384() - { - } - [Test] - public void Test_6385() - { - } - [Test] - public void Test_6386() - { - } - [Test] - public void Test_6387() - { - } - [Test] - public void Test_6388() - { - } - [Test] - public void Test_6389() - { - } - [Test] - public void Test_6390() - { - } - [Test] - public void Test_6391() - { - } - [Test] - public void Test_6392() - { - } - [Test] - public void Test_6393() - { - } - [Test] - public void Test_6394() - { - } - [Test] - public void Test_6395() - { - } - [Test] - public void Test_6396() - { - } - [Test] - public void Test_6397() - { - } - [Test] - public void Test_6398() - { - } - [Test] - public void Test_6399() - { - } - [Test] - public void Test_6400() - { - } - [Test] - public void Test_6401() - { - } - [Test] - public void Test_6402() - { - } - [Test] - public void Test_6403() - { - } - [Test] - public void Test_6404() - { - } - [Test] - public void Test_6405() - { - } - [Test] - public void Test_6406() - { - } - [Test] - public void Test_6407() - { - } - [Test] - public void Test_6408() - { - } - [Test] - public void Test_6409() - { - } - [Test] - public void Test_6410() - { - } - [Test] - public void Test_6411() - { - } - [Test] - public void Test_6412() - { - } - [Test] - public void Test_6413() - { - } - [Test] - public void Test_6414() - { - } - [Test] - public void Test_6415() - { - } - [Test] - public void Test_6416() - { - } - [Test] - public void Test_6417() - { - } - [Test] - public void Test_6418() - { - } - [Test] - public void Test_6419() - { - } - [Test] - public void Test_6420() - { - } - [Test] - public void Test_6421() - { - } - [Test] - public void Test_6422() - { - } - [Test] - public void Test_6423() - { - } - [Test] - public void Test_6424() - { - } - [Test] - public void Test_6425() - { - } - [Test] - public void Test_6426() - { - } - [Test] - public void Test_6427() - { - } - [Test] - public void Test_6428() - { - } - [Test] - public void Test_6429() - { - } - [Test] - public void Test_6430() - { - } - [Test] - public void Test_6431() - { - } - [Test] - public void Test_6432() - { - } - [Test] - public void Test_6433() - { - } - [Test] - public void Test_6434() - { - } - [Test] - public void Test_6435() - { - } - [Test] - public void Test_6436() - { - } - [Test] - public void Test_6437() - { - } - [Test] - public void Test_6438() - { - } - [Test] - public void Test_6439() - { - } - [Test] - public void Test_6440() - { - } - [Test] - public void Test_6441() - { - } - [Test] - public void Test_6442() - { - } - [Test] - public void Test_6443() - { - } - [Test] - public void Test_6444() - { - } - [Test] - public void Test_6445() - { - } - [Test] - public void Test_6446() - { - } - [Test] - public void Test_6447() - { - } - [Test] - public void Test_6448() - { - } - [Test] - public void Test_6449() - { - } - [Test] - public void Test_6450() - { - } - [Test] - public void Test_6451() - { - } - [Test] - public void Test_6452() - { - } - [Test] - public void Test_6453() - { - } - [Test] - public void Test_6454() - { - } - [Test] - public void Test_6455() - { - } - [Test] - public void Test_6456() - { - } - [Test] - public void Test_6457() - { - } - [Test] - public void Test_6458() - { - } - [Test] - public void Test_6459() - { - } - [Test] - public void Test_6460() - { - } - [Test] - public void Test_6461() - { - } - [Test] - public void Test_6462() - { - } - [Test] - public void Test_6463() - { - } - [Test] - public void Test_6464() - { - } - [Test] - public void Test_6465() - { - } - [Test] - public void Test_6466() - { - } - [Test] - public void Test_6467() - { - } - [Test] - public void Test_6468() - { - } - [Test] - public void Test_6469() - { - } - [Test] - public void Test_6470() - { - } - [Test] - public void Test_6471() - { - } - [Test] - public void Test_6472() - { - } - [Test] - public void Test_6473() - { - } - [Test] - public void Test_6474() - { - } - [Test] - public void Test_6475() - { - } - [Test] - public void Test_6476() - { - } - [Test] - public void Test_6477() - { - } - [Test] - public void Test_6478() - { - } - [Test] - public void Test_6479() - { - } - [Test] - public void Test_6480() - { - } - [Test] - public void Test_6481() - { - } - [Test] - public void Test_6482() - { - } - [Test] - public void Test_6483() - { - } - [Test] - public void Test_6484() - { - } - [Test] - public void Test_6485() - { - } - [Test] - public void Test_6486() - { - } - [Test] - public void Test_6487() - { - } - [Test] - public void Test_6488() - { - } - [Test] - public void Test_6489() - { - } - [Test] - public void Test_6490() - { - } - [Test] - public void Test_6491() - { - } - [Test] - public void Test_6492() - { - } - [Test] - public void Test_6493() - { - } - [Test] - public void Test_6494() - { - } - [Test] - public void Test_6495() - { - } - [Test] - public void Test_6496() - { - } - [Test] - public void Test_6497() - { - } - [Test] - public void Test_6498() - { - } - [Test] - public void Test_6499() - { - } - [Test] - public void Test_6500() - { - } - [Test] - public void Test_6501() - { - } - [Test] - public void Test_6502() - { - } - [Test] - public void Test_6503() - { - } - [Test] - public void Test_6504() - { - } - [Test] - public void Test_6505() - { - } - [Test] - public void Test_6506() - { - } - [Test] - public void Test_6507() - { - } - [Test] - public void Test_6508() - { - } - [Test] - public void Test_6509() - { - } - [Test] - public void Test_6510() - { - } - [Test] - public void Test_6511() - { - } - [Test] - public void Test_6512() - { - } - [Test] - public void Test_6513() - { - } - [Test] - public void Test_6514() - { - } - [Test] - public void Test_6515() - { - } - [Test] - public void Test_6516() - { - } - [Test] - public void Test_6517() - { - } - [Test] - public void Test_6518() - { - } - [Test] - public void Test_6519() - { - } - [Test] - public void Test_6520() - { - } - [Test] - public void Test_6521() - { - } - [Test] - public void Test_6522() - { - } - [Test] - public void Test_6523() - { - } - [Test] - public void Test_6524() - { - } - [Test] - public void Test_6525() - { - } - [Test] - public void Test_6526() - { - } - [Test] - public void Test_6527() - { - } - [Test] - public void Test_6528() - { - } - [Test] - public void Test_6529() - { - } - [Test] - public void Test_6530() - { - } - [Test] - public void Test_6531() - { - } - [Test] - public void Test_6532() - { - } - [Test] - public void Test_6533() - { - } - [Test] - public void Test_6534() - { - } - [Test] - public void Test_6535() - { - } - [Test] - public void Test_6536() - { - } - [Test] - public void Test_6537() - { - } - [Test] - public void Test_6538() - { - } - [Test] - public void Test_6539() - { - } - [Test] - public void Test_6540() - { - } - [Test] - public void Test_6541() - { - } - [Test] - public void Test_6542() - { - } - [Test] - public void Test_6543() - { - } - [Test] - public void Test_6544() - { - } - [Test] - public void Test_6545() - { - } - [Test] - public void Test_6546() - { - } - [Test] - public void Test_6547() - { - } - [Test] - public void Test_6548() - { - } - [Test] - public void Test_6549() - { - } - [Test] - public void Test_6550() - { - } - [Test] - public void Test_6551() - { - } - [Test] - public void Test_6552() - { - } - [Test] - public void Test_6553() - { - } - [Test] - public void Test_6554() - { - } - [Test] - public void Test_6555() - { - } - [Test] - public void Test_6556() - { - } - [Test] - public void Test_6557() - { - } - [Test] - public void Test_6558() - { - } - [Test] - public void Test_6559() - { - } - [Test] - public void Test_6560() - { - } - [Test] - public void Test_6561() - { - } - [Test] - public void Test_6562() - { - } - [Test] - public void Test_6563() - { - } - [Test] - public void Test_6564() - { - } - [Test] - public void Test_6565() - { - } - [Test] - public void Test_6566() - { - } - [Test] - public void Test_6567() - { - } - [Test] - public void Test_6568() - { - } - [Test] - public void Test_6569() - { - } - [Test] - public void Test_6570() - { - } - [Test] - public void Test_6571() - { - } - [Test] - public void Test_6572() - { - } - [Test] - public void Test_6573() - { - } - [Test] - public void Test_6574() - { - } - [Test] - public void Test_6575() - { - } - [Test] - public void Test_6576() - { - } - [Test] - public void Test_6577() - { - } - [Test] - public void Test_6578() - { - } - [Test] - public void Test_6579() - { - } - [Test] - public void Test_6580() - { - } - [Test] - public void Test_6581() - { - } - [Test] - public void Test_6582() - { - } - [Test] - public void Test_6583() - { - } - [Test] - public void Test_6584() - { - } - [Test] - public void Test_6585() - { - } - [Test] - public void Test_6586() - { - } - [Test] - public void Test_6587() - { - } - [Test] - public void Test_6588() - { - } - [Test] - public void Test_6589() - { - } - [Test] - public void Test_6590() - { - } - [Test] - public void Test_6591() - { - } - [Test] - public void Test_6592() - { - } - [Test] - public void Test_6593() - { - } - [Test] - public void Test_6594() - { - } - [Test] - public void Test_6595() - { - } - [Test] - public void Test_6596() - { - } - [Test] - public void Test_6597() - { - } - [Test] - public void Test_6598() - { - } - [Test] - public void Test_6599() - { - } - [Test] - public void Test_6600() - { - } - [Test] - public void Test_6601() - { - } - [Test] - public void Test_6602() - { - } - [Test] - public void Test_6603() - { - } - [Test] - public void Test_6604() - { - } - [Test] - public void Test_6605() - { - } - [Test] - public void Test_6606() - { - } - [Test] - public void Test_6607() - { - } - [Test] - public void Test_6608() - { - } - [Test] - public void Test_6609() - { - } - [Test] - public void Test_6610() - { - } - [Test] - public void Test_6611() - { - } - [Test] - public void Test_6612() - { - } - [Test] - public void Test_6613() - { - } - [Test] - public void Test_6614() - { - } - [Test] - public void Test_6615() - { - } - [Test] - public void Test_6616() - { - } - [Test] - public void Test_6617() - { - } - [Test] - public void Test_6618() - { - } - [Test] - public void Test_6619() - { - } - [Test] - public void Test_6620() - { - } - [Test] - public void Test_6621() - { - } - [Test] - public void Test_6622() - { - } - [Test] - public void Test_6623() - { - } - [Test] - public void Test_6624() - { - } - [Test] - public void Test_6625() - { - } - [Test] - public void Test_6626() - { - } - [Test] - public void Test_6627() - { - } - [Test] - public void Test_6628() - { - } - [Test] - public void Test_6629() - { - } - [Test] - public void Test_6630() - { - } - [Test] - public void Test_6631() - { - } - [Test] - public void Test_6632() - { - } - [Test] - public void Test_6633() - { - } - [Test] - public void Test_6634() - { - } - [Test] - public void Test_6635() - { - } - [Test] - public void Test_6636() - { - } - [Test] - public void Test_6637() - { - } - [Test] - public void Test_6638() - { - } - [Test] - public void Test_6639() - { - } - [Test] - public void Test_6640() - { - } - [Test] - public void Test_6641() - { - } - [Test] - public void Test_6642() - { - } - [Test] - public void Test_6643() - { - } - [Test] - public void Test_6644() - { - } - [Test] - public void Test_6645() - { - } - [Test] - public void Test_6646() - { - } - [Test] - public void Test_6647() - { - } - [Test] - public void Test_6648() - { - } - [Test] - public void Test_6649() - { - } - [Test] - public void Test_6650() - { - } - [Test] - public void Test_6651() - { - } - [Test] - public void Test_6652() - { - } - [Test] - public void Test_6653() - { - } - [Test] - public void Test_6654() - { - } - [Test] - public void Test_6655() - { - } - [Test] - public void Test_6656() - { - } - [Test] - public void Test_6657() - { - } - [Test] - public void Test_6658() - { - } - [Test] - public void Test_6659() - { - } - [Test] - public void Test_6660() - { - } - [Test] - public void Test_6661() - { - } - [Test] - public void Test_6662() - { - } - [Test] - public void Test_6663() - { - } - [Test] - public void Test_6664() - { - } - [Test] - public void Test_6665() - { - } - [Test] - public void Test_6666() - { - } - [Test] - public void Test_6667() - { - } - [Test] - public void Test_6668() - { - } - [Test] - public void Test_6669() - { - } - [Test] - public void Test_6670() - { - } - [Test] - public void Test_6671() - { - } - [Test] - public void Test_6672() - { - } - [Test] - public void Test_6673() - { - } - [Test] - public void Test_6674() - { - } - [Test] - public void Test_6675() - { - } - [Test] - public void Test_6676() - { - } - [Test] - public void Test_6677() - { - } - [Test] - public void Test_6678() - { - } - [Test] - public void Test_6679() - { - } - [Test] - public void Test_6680() - { - } - [Test] - public void Test_6681() - { - } - [Test] - public void Test_6682() - { - } - [Test] - public void Test_6683() - { - } - [Test] - public void Test_6684() - { - } - [Test] - public void Test_6685() - { - } - [Test] - public void Test_6686() - { - } - [Test] - public void Test_6687() - { - } - [Test] - public void Test_6688() - { - } - [Test] - public void Test_6689() - { - } - [Test] - public void Test_6690() - { - } - [Test] - public void Test_6691() - { - } - [Test] - public void Test_6692() - { - } - [Test] - public void Test_6693() - { - } - [Test] - public void Test_6694() - { - } - [Test] - public void Test_6695() - { - } - [Test] - public void Test_6696() - { - } - [Test] - public void Test_6697() - { - } - [Test] - public void Test_6698() - { - } - [Test] - public void Test_6699() - { - } - [Test] - public void Test_6700() - { - } - [Test] - public void Test_6701() - { - } - [Test] - public void Test_6702() - { - } - [Test] - public void Test_6703() - { - } - [Test] - public void Test_6704() - { - } - [Test] - public void Test_6705() - { - } - [Test] - public void Test_6706() - { - } - [Test] - public void Test_6707() - { - } - [Test] - public void Test_6708() - { - } - [Test] - public void Test_6709() - { - } - [Test] - public void Test_6710() - { - } - [Test] - public void Test_6711() - { - } - [Test] - public void Test_6712() - { - } - [Test] - public void Test_6713() - { - } - [Test] - public void Test_6714() - { - } - [Test] - public void Test_6715() - { - } - [Test] - public void Test_6716() - { - } - [Test] - public void Test_6717() - { - } - [Test] - public void Test_6718() - { - } - [Test] - public void Test_6719() - { - } - [Test] - public void Test_6720() - { - } - [Test] - public void Test_6721() - { - } - [Test] - public void Test_6722() - { - } - [Test] - public void Test_6723() - { - } - [Test] - public void Test_6724() - { - } - [Test] - public void Test_6725() - { - } - [Test] - public void Test_6726() - { - } - [Test] - public void Test_6727() - { - } - [Test] - public void Test_6728() - { - } - [Test] - public void Test_6729() - { - } - [Test] - public void Test_6730() - { - } - [Test] - public void Test_6731() - { - } - [Test] - public void Test_6732() - { - } - [Test] - public void Test_6733() - { - } - [Test] - public void Test_6734() - { - } - [Test] - public void Test_6735() - { - } - [Test] - public void Test_6736() - { - } - [Test] - public void Test_6737() - { - } - [Test] - public void Test_6738() - { - } - [Test] - public void Test_6739() - { - } - [Test] - public void Test_6740() - { - } - [Test] - public void Test_6741() - { - } - [Test] - public void Test_6742() - { - } - [Test] - public void Test_6743() - { - } - [Test] - public void Test_6744() - { - } - [Test] - public void Test_6745() - { - } - [Test] - public void Test_6746() - { - } - [Test] - public void Test_6747() - { - } - [Test] - public void Test_6748() - { - } - [Test] - public void Test_6749() - { - } - [Test] - public void Test_6750() - { - } - [Test] - public void Test_6751() - { - } - [Test] - public void Test_6752() - { - } - [Test] - public void Test_6753() - { - } - [Test] - public void Test_6754() - { - } - [Test] - public void Test_6755() - { - } - [Test] - public void Test_6756() - { - } - [Test] - public void Test_6757() - { - } - [Test] - public void Test_6758() - { - } - [Test] - public void Test_6759() - { - } - [Test] - public void Test_6760() - { - } - [Test] - public void Test_6761() - { - } - [Test] - public void Test_6762() - { - } - [Test] - public void Test_6763() - { - } - [Test] - public void Test_6764() - { - } - [Test] - public void Test_6765() - { - } - [Test] - public void Test_6766() - { - } - [Test] - public void Test_6767() - { - } - [Test] - public void Test_6768() - { - } - [Test] - public void Test_6769() - { - } - [Test] - public void Test_6770() - { - } - [Test] - public void Test_6771() - { - } - [Test] - public void Test_6772() - { - } - [Test] - public void Test_6773() - { - } - [Test] - public void Test_6774() - { - } - [Test] - public void Test_6775() - { - } - [Test] - public void Test_6776() - { - } - [Test] - public void Test_6777() - { - } - [Test] - public void Test_6778() - { - } - [Test] - public void Test_6779() - { - } - [Test] - public void Test_6780() - { - } - [Test] - public void Test_6781() - { - } - [Test] - public void Test_6782() - { - } - [Test] - public void Test_6783() - { - } - [Test] - public void Test_6784() - { - } - [Test] - public void Test_6785() - { - } - [Test] - public void Test_6786() - { - } - [Test] - public void Test_6787() - { - } - [Test] - public void Test_6788() - { - } - [Test] - public void Test_6789() - { - } - [Test] - public void Test_6790() - { - } - [Test] - public void Test_6791() - { - } - [Test] - public void Test_6792() - { - } - [Test] - public void Test_6793() - { - } - [Test] - public void Test_6794() - { - } - [Test] - public void Test_6795() - { - } - [Test] - public void Test_6796() - { - } - [Test] - public void Test_6797() - { - } - [Test] - public void Test_6798() - { - } - [Test] - public void Test_6799() - { - } - [Test] - public void Test_6800() - { - } - [Test] - public void Test_6801() - { - } - [Test] - public void Test_6802() - { - } - [Test] - public void Test_6803() - { - } - [Test] - public void Test_6804() - { - } - [Test] - public void Test_6805() - { - } - [Test] - public void Test_6806() - { - } - [Test] - public void Test_6807() - { - } - [Test] - public void Test_6808() - { - } - [Test] - public void Test_6809() - { - } - [Test] - public void Test_6810() - { - } - [Test] - public void Test_6811() - { - } - [Test] - public void Test_6812() - { - } - [Test] - public void Test_6813() - { - } - [Test] - public void Test_6814() - { - } - [Test] - public void Test_6815() - { - } - [Test] - public void Test_6816() - { - } - [Test] - public void Test_6817() - { - } - [Test] - public void Test_6818() - { - } - [Test] - public void Test_6819() - { - } - [Test] - public void Test_6820() - { - } - [Test] - public void Test_6821() - { - } - [Test] - public void Test_6822() - { - } - [Test] - public void Test_6823() - { - } - [Test] - public void Test_6824() - { - } - [Test] - public void Test_6825() - { - } - [Test] - public void Test_6826() - { - } - [Test] - public void Test_6827() - { - } - [Test] - public void Test_6828() - { - } - [Test] - public void Test_6829() - { - } - [Test] - public void Test_6830() - { - } - [Test] - public void Test_6831() - { - } - [Test] - public void Test_6832() - { - } - [Test] - public void Test_6833() - { - } - [Test] - public void Test_6834() - { - } - [Test] - public void Test_6835() - { - } - [Test] - public void Test_6836() - { - } - [Test] - public void Test_6837() - { - } - [Test] - public void Test_6838() - { - } - [Test] - public void Test_6839() - { - } - [Test] - public void Test_6840() - { - } - [Test] - public void Test_6841() - { - } - [Test] - public void Test_6842() - { - } - [Test] - public void Test_6843() - { - } - [Test] - public void Test_6844() - { - } - [Test] - public void Test_6845() - { - } - [Test] - public void Test_6846() - { - } - [Test] - public void Test_6847() - { - } - [Test] - public void Test_6848() - { - } - [Test] - public void Test_6849() - { - } - [Test] - public void Test_6850() - { - } - [Test] - public void Test_6851() - { - } - [Test] - public void Test_6852() - { - } - [Test] - public void Test_6853() - { - } - [Test] - public void Test_6854() - { - } - [Test] - public void Test_6855() - { - } - [Test] - public void Test_6856() - { - } - [Test] - public void Test_6857() - { - } - [Test] - public void Test_6858() - { - } - [Test] - public void Test_6859() - { - } - [Test] - public void Test_6860() - { - } - [Test] - public void Test_6861() - { - } - [Test] - public void Test_6862() - { - } - [Test] - public void Test_6863() - { - } - [Test] - public void Test_6864() - { - } - [Test] - public void Test_6865() - { - } - [Test] - public void Test_6866() - { - } - [Test] - public void Test_6867() - { - } - [Test] - public void Test_6868() - { - } - [Test] - public void Test_6869() - { - } - [Test] - public void Test_6870() - { - } - [Test] - public void Test_6871() - { - } - [Test] - public void Test_6872() - { - } - [Test] - public void Test_6873() - { - } - [Test] - public void Test_6874() - { - } - [Test] - public void Test_6875() - { - } - [Test] - public void Test_6876() - { - } - [Test] - public void Test_6877() - { - } - [Test] - public void Test_6878() - { - } - [Test] - public void Test_6879() - { - } - [Test] - public void Test_6880() - { - } - [Test] - public void Test_6881() - { - } - [Test] - public void Test_6882() - { - } - [Test] - public void Test_6883() - { - } - [Test] - public void Test_6884() - { - } - [Test] - public void Test_6885() - { - } - [Test] - public void Test_6886() - { - } - [Test] - public void Test_6887() - { - } - [Test] - public void Test_6888() - { - } - [Test] - public void Test_6889() - { - } - [Test] - public void Test_6890() - { - } - [Test] - public void Test_6891() - { - } - [Test] - public void Test_6892() - { - } - [Test] - public void Test_6893() - { - } - [Test] - public void Test_6894() - { - } - [Test] - public void Test_6895() - { - } - [Test] - public void Test_6896() - { - } - [Test] - public void Test_6897() - { - } - [Test] - public void Test_6898() - { - } - [Test] - public void Test_6899() - { - } - [Test] - public void Test_6900() - { - } - [Test] - public void Test_6901() - { - } - [Test] - public void Test_6902() - { - } - [Test] - public void Test_6903() - { - } - [Test] - public void Test_6904() - { - } - [Test] - public void Test_6905() - { - } - [Test] - public void Test_6906() - { - } - [Test] - public void Test_6907() - { - } - [Test] - public void Test_6908() - { - } - [Test] - public void Test_6909() - { - } - [Test] - public void Test_6910() - { - } - [Test] - public void Test_6911() - { - } - [Test] - public void Test_6912() - { - } - [Test] - public void Test_6913() - { - } - [Test] - public void Test_6914() - { - } - [Test] - public void Test_6915() - { - } - [Test] - public void Test_6916() - { - } - [Test] - public void Test_6917() - { - } - [Test] - public void Test_6918() - { - } - [Test] - public void Test_6919() - { - } - [Test] - public void Test_6920() - { - } - [Test] - public void Test_6921() - { - } - [Test] - public void Test_6922() - { - } - [Test] - public void Test_6923() - { - } - [Test] - public void Test_6924() - { - } - [Test] - public void Test_6925() - { - } - [Test] - public void Test_6926() - { - } - [Test] - public void Test_6927() - { - } - [Test] - public void Test_6928() - { - } - [Test] - public void Test_6929() - { - } - [Test] - public void Test_6930() - { - } - [Test] - public void Test_6931() - { - } - [Test] - public void Test_6932() - { - } - [Test] - public void Test_6933() - { - } - [Test] - public void Test_6934() - { - } - [Test] - public void Test_6935() - { - } - [Test] - public void Test_6936() - { - } - [Test] - public void Test_6937() - { - } - [Test] - public void Test_6938() - { - } - [Test] - public void Test_6939() - { - } - [Test] - public void Test_6940() - { - } - [Test] - public void Test_6941() - { - } - [Test] - public void Test_6942() - { - } - [Test] - public void Test_6943() - { - } - [Test] - public void Test_6944() - { - } - [Test] - public void Test_6945() - { - } - [Test] - public void Test_6946() - { - } - [Test] - public void Test_6947() - { - } - [Test] - public void Test_6948() - { - } - [Test] - public void Test_6949() - { - } - [Test] - public void Test_6950() - { - } - [Test] - public void Test_6951() - { - } - [Test] - public void Test_6952() - { - } - [Test] - public void Test_6953() - { - } - [Test] - public void Test_6954() - { - } - [Test] - public void Test_6955() - { - } - [Test] - public void Test_6956() - { - } - [Test] - public void Test_6957() - { - } - [Test] - public void Test_6958() - { - } - [Test] - public void Test_6959() - { - } - [Test] - public void Test_6960() - { - } - [Test] - public void Test_6961() - { - } - [Test] - public void Test_6962() - { - } - [Test] - public void Test_6963() - { - } - [Test] - public void Test_6964() - { - } - [Test] - public void Test_6965() - { - } - [Test] - public void Test_6966() - { - } - [Test] - public void Test_6967() - { - } - [Test] - public void Test_6968() - { - } - [Test] - public void Test_6969() - { - } - [Test] - public void Test_6970() - { - } - [Test] - public void Test_6971() - { - } - [Test] - public void Test_6972() - { - } - [Test] - public void Test_6973() - { - } - [Test] - public void Test_6974() - { - } - [Test] - public void Test_6975() - { - } - [Test] - public void Test_6976() - { - } - [Test] - public void Test_6977() - { - } - [Test] - public void Test_6978() - { - } - [Test] - public void Test_6979() - { - } - [Test] - public void Test_6980() - { - } - [Test] - public void Test_6981() - { - } - [Test] - public void Test_6982() - { - } - [Test] - public void Test_6983() - { - } - [Test] - public void Test_6984() - { - } - [Test] - public void Test_6985() - { - } - [Test] - public void Test_6986() - { - } - [Test] - public void Test_6987() - { - } - [Test] - public void Test_6988() - { - } - [Test] - public void Test_6989() - { - } - [Test] - public void Test_6990() - { - } - [Test] - public void Test_6991() - { - } - [Test] - public void Test_6992() - { - } - [Test] - public void Test_6993() - { - } - [Test] - public void Test_6994() - { - } - [Test] - public void Test_6995() - { - } - [Test] - public void Test_6996() - { - } - [Test] - public void Test_6997() - { - } - [Test] - public void Test_6998() - { - } - [Test] - public void Test_6999() - { - } - [Test] - public void Test_7000() - { - } - [Test] - public void Test_7001() - { - } - [Test] - public void Test_7002() - { - } - [Test] - public void Test_7003() - { - } - [Test] - public void Test_7004() - { - } - [Test] - public void Test_7005() - { - } - [Test] - public void Test_7006() - { - } - [Test] - public void Test_7007() - { - } - [Test] - public void Test_7008() - { - } - [Test] - public void Test_7009() - { - } - [Test] - public void Test_7010() - { - } - [Test] - public void Test_7011() - { - } - [Test] - public void Test_7012() - { - } - [Test] - public void Test_7013() - { - } - [Test] - public void Test_7014() - { - } - [Test] - public void Test_7015() - { - } - [Test] - public void Test_7016() - { - } - [Test] - public void Test_7017() - { - } - [Test] - public void Test_7018() - { - } - [Test] - public void Test_7019() - { - } - [Test] - public void Test_7020() - { - } - [Test] - public void Test_7021() - { - } - [Test] - public void Test_7022() - { - } - [Test] - public void Test_7023() - { - } - [Test] - public void Test_7024() - { - } - [Test] - public void Test_7025() - { - } - [Test] - public void Test_7026() - { - } - [Test] - public void Test_7027() - { - } - [Test] - public void Test_7028() - { - } - [Test] - public void Test_7029() - { - } - [Test] - public void Test_7030() - { - } - [Test] - public void Test_7031() - { - } - [Test] - public void Test_7032() - { - } - [Test] - public void Test_7033() - { - } - [Test] - public void Test_7034() - { - } - [Test] - public void Test_7035() - { - } - [Test] - public void Test_7036() - { - } - [Test] - public void Test_7037() - { - } - [Test] - public void Test_7038() - { - } - [Test] - public void Test_7039() - { - } - [Test] - public void Test_7040() - { - } - [Test] - public void Test_7041() - { - } - [Test] - public void Test_7042() - { - } - [Test] - public void Test_7043() - { - } - [Test] - public void Test_7044() - { - } - [Test] - public void Test_7045() - { - } - [Test] - public void Test_7046() - { - } - [Test] - public void Test_7047() - { - } - [Test] - public void Test_7048() - { - } - [Test] - public void Test_7049() - { - } - [Test] - public void Test_7050() - { - } - [Test] - public void Test_7051() - { - } - [Test] - public void Test_7052() - { - } - [Test] - public void Test_7053() - { - } - [Test] - public void Test_7054() - { - } - [Test] - public void Test_7055() - { - } - [Test] - public void Test_7056() - { - } - [Test] - public void Test_7057() - { - } - [Test] - public void Test_7058() - { - } - [Test] - public void Test_7059() - { - } - [Test] - public void Test_7060() - { - } - [Test] - public void Test_7061() - { - } - [Test] - public void Test_7062() - { - } - [Test] - public void Test_7063() - { - } - [Test] - public void Test_7064() - { - } - [Test] - public void Test_7065() - { - } - [Test] - public void Test_7066() - { - } - [Test] - public void Test_7067() - { - } - [Test] - public void Test_7068() - { - } - [Test] - public void Test_7069() - { - } - [Test] - public void Test_7070() - { - } - [Test] - public void Test_7071() - { - } - [Test] - public void Test_7072() - { - } - [Test] - public void Test_7073() - { - } - [Test] - public void Test_7074() - { - } - [Test] - public void Test_7075() - { - } - [Test] - public void Test_7076() - { - } - [Test] - public void Test_7077() - { - } - [Test] - public void Test_7078() - { - } - [Test] - public void Test_7079() - { - } - [Test] - public void Test_7080() - { - } - [Test] - public void Test_7081() - { - } - [Test] - public void Test_7082() - { - } - [Test] - public void Test_7083() - { - } - [Test] - public void Test_7084() - { - } - [Test] - public void Test_7085() - { - } - [Test] - public void Test_7086() - { - } - [Test] - public void Test_7087() - { - } - [Test] - public void Test_7088() - { - } - [Test] - public void Test_7089() - { - } - [Test] - public void Test_7090() - { - } - [Test] - public void Test_7091() - { - } - [Test] - public void Test_7092() - { - } - [Test] - public void Test_7093() - { - } - [Test] - public void Test_7094() - { - } - [Test] - public void Test_7095() - { - } - [Test] - public void Test_7096() - { - } - [Test] - public void Test_7097() - { - } - [Test] - public void Test_7098() - { - } - [Test] - public void Test_7099() - { - } - [Test] - public void Test_7100() - { - } - [Test] - public void Test_7101() - { - } - [Test] - public void Test_7102() - { - } - [Test] - public void Test_7103() - { - } - [Test] - public void Test_7104() - { - } - [Test] - public void Test_7105() - { - } - [Test] - public void Test_7106() - { - } - [Test] - public void Test_7107() - { - } - [Test] - public void Test_7108() - { - } - [Test] - public void Test_7109() - { - } - [Test] - public void Test_7110() - { - } - [Test] - public void Test_7111() - { - } - [Test] - public void Test_7112() - { - } - [Test] - public void Test_7113() - { - } - [Test] - public void Test_7114() - { - } - [Test] - public void Test_7115() - { - } - [Test] - public void Test_7116() - { - } - [Test] - public void Test_7117() - { - } - [Test] - public void Test_7118() - { - } - [Test] - public void Test_7119() - { - } - [Test] - public void Test_7120() - { - } - [Test] - public void Test_7121() - { - } - [Test] - public void Test_7122() - { - } - [Test] - public void Test_7123() - { - } - [Test] - public void Test_7124() - { - } - [Test] - public void Test_7125() - { - } - [Test] - public void Test_7126() - { - } - [Test] - public void Test_7127() - { - } - [Test] - public void Test_7128() - { - } - [Test] - public void Test_7129() - { - } - [Test] - public void Test_7130() - { - } - [Test] - public void Test_7131() - { - } - [Test] - public void Test_7132() - { - } - [Test] - public void Test_7133() - { - } - [Test] - public void Test_7134() - { - } - [Test] - public void Test_7135() - { - } - [Test] - public void Test_7136() - { - } - [Test] - public void Test_7137() - { - } - [Test] - public void Test_7138() - { - } - [Test] - public void Test_7139() - { - } - [Test] - public void Test_7140() - { - } - [Test] - public void Test_7141() - { - } - [Test] - public void Test_7142() - { - } - [Test] - public void Test_7143() - { - } - [Test] - public void Test_7144() - { - } - [Test] - public void Test_7145() - { - } - [Test] - public void Test_7146() - { - } - [Test] - public void Test_7147() - { - } - [Test] - public void Test_7148() - { - } - [Test] - public void Test_7149() - { - } - [Test] - public void Test_7150() - { - } - [Test] - public void Test_7151() - { - } - [Test] - public void Test_7152() - { - } - [Test] - public void Test_7153() - { - } - [Test] - public void Test_7154() - { - } - [Test] - public void Test_7155() - { - } - [Test] - public void Test_7156() - { - } - [Test] - public void Test_7157() - { - } - [Test] - public void Test_7158() - { - } - [Test] - public void Test_7159() - { - } - [Test] - public void Test_7160() - { - } - [Test] - public void Test_7161() - { - } - [Test] - public void Test_7162() - { - } - [Test] - public void Test_7163() - { - } - [Test] - public void Test_7164() - { - } - [Test] - public void Test_7165() - { - } - [Test] - public void Test_7166() - { - } - [Test] - public void Test_7167() - { - } - [Test] - public void Test_7168() - { - } - [Test] - public void Test_7169() - { - } - [Test] - public void Test_7170() - { - } - [Test] - public void Test_7171() - { - } - [Test] - public void Test_7172() - { - } - [Test] - public void Test_7173() - { - } - [Test] - public void Test_7174() - { - } - [Test] - public void Test_7175() - { - } - [Test] - public void Test_7176() - { - } - [Test] - public void Test_7177() - { - } - [Test] - public void Test_7178() - { - } - [Test] - public void Test_7179() - { - } - [Test] - public void Test_7180() - { - } - [Test] - public void Test_7181() - { - } - [Test] - public void Test_7182() - { - } - [Test] - public void Test_7183() - { - } - [Test] - public void Test_7184() - { - } - [Test] - public void Test_7185() - { - } - [Test] - public void Test_7186() - { - } - [Test] - public void Test_7187() - { - } - [Test] - public void Test_7188() - { - } - [Test] - public void Test_7189() - { - } - [Test] - public void Test_7190() - { - } - [Test] - public void Test_7191() - { - } - [Test] - public void Test_7192() - { - } - [Test] - public void Test_7193() - { - } - [Test] - public void Test_7194() - { - } - [Test] - public void Test_7195() - { - } - [Test] - public void Test_7196() - { - } - [Test] - public void Test_7197() - { - } - [Test] - public void Test_7198() - { - } - [Test] - public void Test_7199() - { - } - [Test] - public void Test_7200() - { - } - [Test] - public void Test_7201() - { - } - [Test] - public void Test_7202() - { - } - [Test] - public void Test_7203() - { - } - [Test] - public void Test_7204() - { - } - [Test] - public void Test_7205() - { - } - [Test] - public void Test_7206() - { - } - [Test] - public void Test_7207() - { - } - [Test] - public void Test_7208() - { - } - [Test] - public void Test_7209() - { - } - [Test] - public void Test_7210() - { - } - [Test] - public void Test_7211() - { - } - [Test] - public void Test_7212() - { - } - [Test] - public void Test_7213() - { - } - [Test] - public void Test_7214() - { - } - [Test] - public void Test_7215() - { - } - [Test] - public void Test_7216() - { - } - [Test] - public void Test_7217() - { - } - [Test] - public void Test_7218() - { - } - [Test] - public void Test_7219() - { - } - [Test] - public void Test_7220() - { - } - [Test] - public void Test_7221() - { - } - [Test] - public void Test_7222() - { - } - [Test] - public void Test_7223() - { - } - [Test] - public void Test_7224() - { - } - [Test] - public void Test_7225() - { - } - [Test] - public void Test_7226() - { - } - [Test] - public void Test_7227() - { - } - [Test] - public void Test_7228() - { - } - [Test] - public void Test_7229() - { - } - [Test] - public void Test_7230() - { - } - [Test] - public void Test_7231() - { - } - [Test] - public void Test_7232() - { - } - [Test] - public void Test_7233() - { - } - [Test] - public void Test_7234() - { - } - [Test] - public void Test_7235() - { - } - [Test] - public void Test_7236() - { - } - [Test] - public void Test_7237() - { - } - [Test] - public void Test_7238() - { - } - [Test] - public void Test_7239() - { - } - [Test] - public void Test_7240() - { - } - [Test] - public void Test_7241() - { - } - [Test] - public void Test_7242() - { - } - [Test] - public void Test_7243() - { - } - [Test] - public void Test_7244() - { - } - [Test] - public void Test_7245() - { - } - [Test] - public void Test_7246() - { - } - [Test] - public void Test_7247() - { - } - [Test] - public void Test_7248() - { - } - [Test] - public void Test_7249() - { - } - [Test] - public void Test_7250() - { - } - [Test] - public void Test_7251() - { - } - [Test] - public void Test_7252() - { - } - [Test] - public void Test_7253() - { - } - [Test] - public void Test_7254() - { - } - [Test] - public void Test_7255() - { - } - [Test] - public void Test_7256() - { - } - [Test] - public void Test_7257() - { - } - [Test] - public void Test_7258() - { - } - [Test] - public void Test_7259() - { - } - [Test] - public void Test_7260() - { - } - [Test] - public void Test_7261() - { - } - [Test] - public void Test_7262() - { - } - [Test] - public void Test_7263() - { - } - [Test] - public void Test_7264() - { - } - [Test] - public void Test_7265() - { - } - [Test] - public void Test_7266() - { - } - [Test] - public void Test_7267() - { - } - [Test] - public void Test_7268() - { - } - [Test] - public void Test_7269() - { - } - [Test] - public void Test_7270() - { - } - [Test] - public void Test_7271() - { - } - [Test] - public void Test_7272() - { - } - [Test] - public void Test_7273() - { - } - [Test] - public void Test_7274() - { - } - [Test] - public void Test_7275() - { - } - [Test] - public void Test_7276() - { - } - [Test] - public void Test_7277() - { - } - [Test] - public void Test_7278() - { - } - [Test] - public void Test_7279() - { - } - [Test] - public void Test_7280() - { - } - [Test] - public void Test_7281() - { - } - [Test] - public void Test_7282() - { - } - [Test] - public void Test_7283() - { - } - [Test] - public void Test_7284() - { - } - [Test] - public void Test_7285() - { - } - [Test] - public void Test_7286() - { - } - [Test] - public void Test_7287() - { - } - [Test] - public void Test_7288() - { - } - [Test] - public void Test_7289() - { - } - [Test] - public void Test_7290() - { - } - [Test] - public void Test_7291() - { - } - [Test] - public void Test_7292() - { - } - [Test] - public void Test_7293() - { - } - [Test] - public void Test_7294() - { - } - [Test] - public void Test_7295() - { - } - [Test] - public void Test_7296() - { - } - [Test] - public void Test_7297() - { - } - [Test] - public void Test_7298() - { - } - [Test] - public void Test_7299() - { - } - [Test] - public void Test_7300() - { - } - [Test] - public void Test_7301() - { - } - [Test] - public void Test_7302() - { - } - [Test] - public void Test_7303() - { - } - [Test] - public void Test_7304() - { - } - [Test] - public void Test_7305() - { - } - [Test] - public void Test_7306() - { - } - [Test] - public void Test_7307() - { - } - [Test] - public void Test_7308() - { - } - [Test] - public void Test_7309() - { - } - [Test] - public void Test_7310() - { - } - [Test] - public void Test_7311() - { - } - [Test] - public void Test_7312() - { - } - [Test] - public void Test_7313() - { - } - [Test] - public void Test_7314() - { - } - [Test] - public void Test_7315() - { - } - [Test] - public void Test_7316() - { - } - [Test] - public void Test_7317() - { - } - [Test] - public void Test_7318() - { - } - [Test] - public void Test_7319() - { - } - [Test] - public void Test_7320() - { - } - [Test] - public void Test_7321() - { - } - [Test] - public void Test_7322() - { - } - [Test] - public void Test_7323() - { - } - [Test] - public void Test_7324() - { - } - [Test] - public void Test_7325() - { - } - [Test] - public void Test_7326() - { - } - [Test] - public void Test_7327() - { - } - [Test] - public void Test_7328() - { - } - [Test] - public void Test_7329() - { - } - [Test] - public void Test_7330() - { - } - [Test] - public void Test_7331() - { - } - [Test] - public void Test_7332() - { - } - [Test] - public void Test_7333() - { - } - [Test] - public void Test_7334() - { - } - [Test] - public void Test_7335() - { - } - [Test] - public void Test_7336() - { - } - [Test] - public void Test_7337() - { - } - [Test] - public void Test_7338() - { - } - [Test] - public void Test_7339() - { - } - [Test] - public void Test_7340() - { - } - [Test] - public void Test_7341() - { - } - [Test] - public void Test_7342() - { - } - [Test] - public void Test_7343() - { - } - [Test] - public void Test_7344() - { - } - [Test] - public void Test_7345() - { - } - [Test] - public void Test_7346() - { - } - [Test] - public void Test_7347() - { - } - [Test] - public void Test_7348() - { - } - [Test] - public void Test_7349() - { - } - [Test] - public void Test_7350() - { - } - [Test] - public void Test_7351() - { - } - [Test] - public void Test_7352() - { - } - [Test] - public void Test_7353() - { - } - [Test] - public void Test_7354() - { - } - [Test] - public void Test_7355() - { - } - [Test] - public void Test_7356() - { - } - [Test] - public void Test_7357() - { - } - [Test] - public void Test_7358() - { - } - [Test] - public void Test_7359() - { - } - [Test] - public void Test_7360() - { - } - [Test] - public void Test_7361() - { - } - [Test] - public void Test_7362() - { - } - [Test] - public void Test_7363() - { - } - [Test] - public void Test_7364() - { - } - [Test] - public void Test_7365() - { - } - [Test] - public void Test_7366() - { - } - [Test] - public void Test_7367() - { - } - [Test] - public void Test_7368() - { - } - [Test] - public void Test_7369() - { - } - [Test] - public void Test_7370() - { - } - [Test] - public void Test_7371() - { - } - [Test] - public void Test_7372() - { - } - [Test] - public void Test_7373() - { - } - [Test] - public void Test_7374() - { - } - [Test] - public void Test_7375() - { - } - [Test] - public void Test_7376() - { - } - [Test] - public void Test_7377() - { - } - [Test] - public void Test_7378() - { - } - [Test] - public void Test_7379() - { - } - [Test] - public void Test_7380() - { - } - [Test] - public void Test_7381() - { - } - [Test] - public void Test_7382() - { - } - [Test] - public void Test_7383() - { - } - [Test] - public void Test_7384() - { - } - [Test] - public void Test_7385() - { - } - [Test] - public void Test_7386() - { - } - [Test] - public void Test_7387() - { - } - [Test] - public void Test_7388() - { - } - [Test] - public void Test_7389() - { - } - [Test] - public void Test_7390() - { - } - [Test] - public void Test_7391() - { - } - [Test] - public void Test_7392() - { - } - [Test] - public void Test_7393() - { - } - [Test] - public void Test_7394() - { - } - [Test] - public void Test_7395() - { - } - [Test] - public void Test_7396() - { - } - [Test] - public void Test_7397() - { - } - [Test] - public void Test_7398() - { - } - [Test] - public void Test_7399() - { - } - [Test] - public void Test_7400() - { - } - [Test] - public void Test_7401() - { - } - [Test] - public void Test_7402() - { - } - [Test] - public void Test_7403() - { - } - [Test] - public void Test_7404() - { - } - [Test] - public void Test_7405() - { - } - [Test] - public void Test_7406() - { - } - [Test] - public void Test_7407() - { - } - [Test] - public void Test_7408() - { - } - [Test] - public void Test_7409() - { - } - [Test] - public void Test_7410() - { - } - [Test] - public void Test_7411() - { - } - [Test] - public void Test_7412() - { - } - [Test] - public void Test_7413() - { - } - [Test] - public void Test_7414() - { - } - [Test] - public void Test_7415() - { - } - [Test] - public void Test_7416() - { - } - [Test] - public void Test_7417() - { - } - [Test] - public void Test_7418() - { - } - [Test] - public void Test_7419() - { - } - [Test] - public void Test_7420() - { - } - [Test] - public void Test_7421() - { - } - [Test] - public void Test_7422() - { - } - [Test] - public void Test_7423() - { - } - [Test] - public void Test_7424() - { - } - [Test] - public void Test_7425() - { - } - [Test] - public void Test_7426() - { - } - [Test] - public void Test_7427() - { - } - [Test] - public void Test_7428() - { - } - [Test] - public void Test_7429() - { - } - [Test] - public void Test_7430() - { - } - [Test] - public void Test_7431() - { - } - [Test] - public void Test_7432() - { - } - [Test] - public void Test_7433() - { - } - [Test] - public void Test_7434() - { - } - [Test] - public void Test_7435() - { - } - [Test] - public void Test_7436() - { - } - [Test] - public void Test_7437() - { - } - [Test] - public void Test_7438() - { - } - [Test] - public void Test_7439() - { - } - [Test] - public void Test_7440() - { - } - [Test] - public void Test_7441() - { - } - [Test] - public void Test_7442() - { - } - [Test] - public void Test_7443() - { - } - [Test] - public void Test_7444() - { - } - [Test] - public void Test_7445() - { - } - [Test] - public void Test_7446() - { - } - [Test] - public void Test_7447() - { - } - [Test] - public void Test_7448() - { - } - [Test] - public void Test_7449() - { - } - [Test] - public void Test_7450() - { - } - [Test] - public void Test_7451() - { - } - [Test] - public void Test_7452() - { - } - [Test] - public void Test_7453() - { - } - [Test] - public void Test_7454() - { - } - [Test] - public void Test_7455() - { - } - [Test] - public void Test_7456() - { - } - [Test] - public void Test_7457() - { - } - [Test] - public void Test_7458() - { - } - [Test] - public void Test_7459() - { - } - [Test] - public void Test_7460() - { - } - [Test] - public void Test_7461() - { - } - [Test] - public void Test_7462() - { - } - [Test] - public void Test_7463() - { - } - [Test] - public void Test_7464() - { - } - [Test] - public void Test_7465() - { - } - [Test] - public void Test_7466() - { - } - [Test] - public void Test_7467() - { - } - [Test] - public void Test_7468() - { - } - [Test] - public void Test_7469() - { - } - [Test] - public void Test_7470() - { - } - [Test] - public void Test_7471() - { - } - [Test] - public void Test_7472() - { - } - [Test] - public void Test_7473() - { - } - [Test] - public void Test_7474() - { - } - [Test] - public void Test_7475() - { - } - [Test] - public void Test_7476() - { - } - [Test] - public void Test_7477() - { - } - [Test] - public void Test_7478() - { - } - [Test] - public void Test_7479() - { - } - [Test] - public void Test_7480() - { - } - [Test] - public void Test_7481() - { - } - [Test] - public void Test_7482() - { - } - [Test] - public void Test_7483() - { - } - [Test] - public void Test_7484() - { - } - [Test] - public void Test_7485() - { - } - [Test] - public void Test_7486() - { - } - [Test] - public void Test_7487() - { - } - [Test] - public void Test_7488() - { - } - [Test] - public void Test_7489() - { - } - [Test] - public void Test_7490() - { - } - [Test] - public void Test_7491() - { - } - [Test] - public void Test_7492() - { - } - [Test] - public void Test_7493() - { - } - [Test] - public void Test_7494() - { - } - [Test] - public void Test_7495() - { - } - [Test] - public void Test_7496() - { - } - [Test] - public void Test_7497() - { - } - [Test] - public void Test_7498() - { - } - [Test] - public void Test_7499() - { - } - [Test] - public void Test_7500() - { - } - [Test] - public void Test_7501() - { - } - [Test] - public void Test_7502() - { - } - [Test] - public void Test_7503() - { - } - [Test] - public void Test_7504() - { - } - [Test] - public void Test_7505() - { - } - [Test] - public void Test_7506() - { - } - [Test] - public void Test_7507() - { - } - [Test] - public void Test_7508() - { - } - [Test] - public void Test_7509() - { - } - [Test] - public void Test_7510() - { - } - [Test] - public void Test_7511() - { - } - [Test] - public void Test_7512() - { - } - [Test] - public void Test_7513() - { - } - [Test] - public void Test_7514() - { - } - [Test] - public void Test_7515() - { - } - [Test] - public void Test_7516() - { - } - [Test] - public void Test_7517() - { - } - [Test] - public void Test_7518() - { - } - [Test] - public void Test_7519() - { - } - [Test] - public void Test_7520() - { - } - [Test] - public void Test_7521() - { - } - [Test] - public void Test_7522() - { - } - [Test] - public void Test_7523() - { - } - [Test] - public void Test_7524() - { - } - [Test] - public void Test_7525() - { - } - [Test] - public void Test_7526() - { - } - [Test] - public void Test_7527() - { - } - [Test] - public void Test_7528() - { - } - [Test] - public void Test_7529() - { - } - [Test] - public void Test_7530() - { - } - [Test] - public void Test_7531() - { - } - [Test] - public void Test_7532() - { - } - [Test] - public void Test_7533() - { - } - [Test] - public void Test_7534() - { - } - [Test] - public void Test_7535() - { - } - [Test] - public void Test_7536() - { - } - [Test] - public void Test_7537() - { - } - [Test] - public void Test_7538() - { - } - [Test] - public void Test_7539() - { - } - [Test] - public void Test_7540() - { - } - [Test] - public void Test_7541() - { - } - [Test] - public void Test_7542() - { - } - [Test] - public void Test_7543() - { - } - [Test] - public void Test_7544() - { - } - [Test] - public void Test_7545() - { - } - [Test] - public void Test_7546() - { - } - [Test] - public void Test_7547() - { - } - [Test] - public void Test_7548() - { - } - [Test] - public void Test_7549() - { - } - [Test] - public void Test_7550() - { - } - [Test] - public void Test_7551() - { - } - [Test] - public void Test_7552() - { - } - [Test] - public void Test_7553() - { - } - [Test] - public void Test_7554() - { - } - [Test] - public void Test_7555() - { - } - [Test] - public void Test_7556() - { - } - [Test] - public void Test_7557() - { - } - [Test] - public void Test_7558() - { - } - [Test] - public void Test_7559() - { - } - [Test] - public void Test_7560() - { - } - [Test] - public void Test_7561() - { - } - [Test] - public void Test_7562() - { - } - [Test] - public void Test_7563() - { - } - [Test] - public void Test_7564() - { - } - [Test] - public void Test_7565() - { - } - [Test] - public void Test_7566() - { - } - [Test] - public void Test_7567() - { - } - [Test] - public void Test_7568() - { - } - [Test] - public void Test_7569() - { - } - [Test] - public void Test_7570() - { - } - [Test] - public void Test_7571() - { - } - [Test] - public void Test_7572() - { - } - [Test] - public void Test_7573() - { - } - [Test] - public void Test_7574() - { - } - [Test] - public void Test_7575() - { - } - [Test] - public void Test_7576() - { - } - [Test] - public void Test_7577() - { - } - [Test] - public void Test_7578() - { - } - [Test] - public void Test_7579() - { - } - [Test] - public void Test_7580() - { - } - [Test] - public void Test_7581() - { - } - [Test] - public void Test_7582() - { - } - [Test] - public void Test_7583() - { - } - [Test] - public void Test_7584() - { - } - [Test] - public void Test_7585() - { - } - [Test] - public void Test_7586() - { - } - [Test] - public void Test_7587() - { - } - [Test] - public void Test_7588() - { - } - [Test] - public void Test_7589() - { - } - [Test] - public void Test_7590() - { - } - [Test] - public void Test_7591() - { - } - [Test] - public void Test_7592() - { - } - [Test] - public void Test_7593() - { - } - [Test] - public void Test_7594() - { - } - [Test] - public void Test_7595() - { - } - [Test] - public void Test_7596() - { - } - [Test] - public void Test_7597() - { - } - [Test] - public void Test_7598() - { - } - [Test] - public void Test_7599() - { - } - [Test] - public void Test_7600() - { - } - [Test] - public void Test_7601() - { - } - [Test] - public void Test_7602() - { - } - [Test] - public void Test_7603() - { - } - [Test] - public void Test_7604() - { - } - [Test] - public void Test_7605() - { - } - [Test] - public void Test_7606() - { - } - [Test] - public void Test_7607() - { - } - [Test] - public void Test_7608() - { - } - [Test] - public void Test_7609() - { - } - [Test] - public void Test_7610() - { - } - [Test] - public void Test_7611() - { - } - [Test] - public void Test_7612() - { - } - [Test] - public void Test_7613() - { - } - [Test] - public void Test_7614() - { - } - [Test] - public void Test_7615() - { - } - [Test] - public void Test_7616() - { - } - [Test] - public void Test_7617() - { - } - [Test] - public void Test_7618() - { - } - [Test] - public void Test_7619() - { - } - [Test] - public void Test_7620() - { - } - [Test] - public void Test_7621() - { - } - [Test] - public void Test_7622() - { - } - [Test] - public void Test_7623() - { - } - [Test] - public void Test_7624() - { - } - [Test] - public void Test_7625() - { - } - [Test] - public void Test_7626() - { - } - [Test] - public void Test_7627() - { - } - [Test] - public void Test_7628() - { - } - [Test] - public void Test_7629() - { - } - [Test] - public void Test_7630() - { - } - [Test] - public void Test_7631() - { - } - [Test] - public void Test_7632() - { - } - [Test] - public void Test_7633() - { - } - [Test] - public void Test_7634() - { - } - [Test] - public void Test_7635() - { - } - [Test] - public void Test_7636() - { - } - [Test] - public void Test_7637() - { - } - [Test] - public void Test_7638() - { - } - [Test] - public void Test_7639() - { - } - [Test] - public void Test_7640() - { - } - [Test] - public void Test_7641() - { - } - [Test] - public void Test_7642() - { - } - [Test] - public void Test_7643() - { - } - [Test] - public void Test_7644() - { - } - [Test] - public void Test_7645() - { - } - [Test] - public void Test_7646() - { - } - [Test] - public void Test_7647() - { - } - [Test] - public void Test_7648() - { - } - [Test] - public void Test_7649() - { - } - [Test] - public void Test_7650() - { - } - [Test] - public void Test_7651() - { - } - [Test] - public void Test_7652() - { - } - [Test] - public void Test_7653() - { - } - [Test] - public void Test_7654() - { - } - [Test] - public void Test_7655() - { - } - [Test] - public void Test_7656() - { - } - [Test] - public void Test_7657() - { - } - [Test] - public void Test_7658() - { - } - [Test] - public void Test_7659() - { - } - [Test] - public void Test_7660() - { - } - [Test] - public void Test_7661() - { - } - [Test] - public void Test_7662() - { - } - [Test] - public void Test_7663() - { - } - [Test] - public void Test_7664() - { - } - [Test] - public void Test_7665() - { - } - [Test] - public void Test_7666() - { - } - [Test] - public void Test_7667() - { - } - [Test] - public void Test_7668() - { - } - [Test] - public void Test_7669() - { - } - [Test] - public void Test_7670() - { - } - [Test] - public void Test_7671() - { - } - [Test] - public void Test_7672() - { - } - [Test] - public void Test_7673() - { - } - [Test] - public void Test_7674() - { - } - [Test] - public void Test_7675() - { - } - [Test] - public void Test_7676() - { - } - [Test] - public void Test_7677() - { - } - [Test] - public void Test_7678() - { - } - [Test] - public void Test_7679() - { - } - [Test] - public void Test_7680() - { - } - [Test] - public void Test_7681() - { - } - [Test] - public void Test_7682() - { - } - [Test] - public void Test_7683() - { - } - [Test] - public void Test_7684() - { - } - [Test] - public void Test_7685() - { - } - [Test] - public void Test_7686() - { - } - [Test] - public void Test_7687() - { - } - [Test] - public void Test_7688() - { - } - [Test] - public void Test_7689() - { - } - [Test] - public void Test_7690() - { - } - [Test] - public void Test_7691() - { - } - [Test] - public void Test_7692() - { - } - [Test] - public void Test_7693() - { - } - [Test] - public void Test_7694() - { - } - [Test] - public void Test_7695() - { - } - [Test] - public void Test_7696() - { - } - [Test] - public void Test_7697() - { - } - [Test] - public void Test_7698() - { - } - [Test] - public void Test_7699() - { - } - [Test] - public void Test_7700() - { - } - [Test] - public void Test_7701() - { - } - [Test] - public void Test_7702() - { - } - [Test] - public void Test_7703() - { - } - [Test] - public void Test_7704() - { - } - [Test] - public void Test_7705() - { - } - [Test] - public void Test_7706() - { - } - [Test] - public void Test_7707() - { - } - [Test] - public void Test_7708() - { - } - [Test] - public void Test_7709() - { - } - [Test] - public void Test_7710() - { - } - [Test] - public void Test_7711() - { - } - [Test] - public void Test_7712() - { - } - [Test] - public void Test_7713() - { - } - [Test] - public void Test_7714() - { - } - [Test] - public void Test_7715() - { - } - [Test] - public void Test_7716() - { - } - [Test] - public void Test_7717() - { - } - [Test] - public void Test_7718() - { - } - [Test] - public void Test_7719() - { - } - [Test] - public void Test_7720() - { - } - [Test] - public void Test_7721() - { - } - [Test] - public void Test_7722() - { - } - [Test] - public void Test_7723() - { - } - [Test] - public void Test_7724() - { - } - [Test] - public void Test_7725() - { - } - [Test] - public void Test_7726() - { - } - [Test] - public void Test_7727() - { - } - [Test] - public void Test_7728() - { - } - [Test] - public void Test_7729() - { - } - [Test] - public void Test_7730() - { - } - [Test] - public void Test_7731() - { - } - [Test] - public void Test_7732() - { - } - [Test] - public void Test_7733() - { - } - [Test] - public void Test_7734() - { - } - [Test] - public void Test_7735() - { - } - [Test] - public void Test_7736() - { - } - [Test] - public void Test_7737() - { - } - [Test] - public void Test_7738() - { - } - [Test] - public void Test_7739() - { - } - [Test] - public void Test_7740() - { - } - [Test] - public void Test_7741() - { - } - [Test] - public void Test_7742() - { - } - [Test] - public void Test_7743() - { - } - [Test] - public void Test_7744() - { - } - [Test] - public void Test_7745() - { - } - [Test] - public void Test_7746() - { - } - [Test] - public void Test_7747() - { - } - [Test] - public void Test_7748() - { - } - [Test] - public void Test_7749() - { - } - [Test] - public void Test_7750() - { - } - [Test] - public void Test_7751() - { - } - [Test] - public void Test_7752() - { - } - [Test] - public void Test_7753() - { - } - [Test] - public void Test_7754() - { - } - [Test] - public void Test_7755() - { - } - [Test] - public void Test_7756() - { - } - [Test] - public void Test_7757() - { - } - [Test] - public void Test_7758() - { - } - [Test] - public void Test_7759() - { - } - [Test] - public void Test_7760() - { - } - [Test] - public void Test_7761() - { - } - [Test] - public void Test_7762() - { - } - [Test] - public void Test_7763() - { - } - [Test] - public void Test_7764() - { - } - [Test] - public void Test_7765() - { - } - [Test] - public void Test_7766() - { - } - [Test] - public void Test_7767() - { - } - [Test] - public void Test_7768() - { - } - [Test] - public void Test_7769() - { - } - [Test] - public void Test_7770() - { - } - [Test] - public void Test_7771() - { - } - [Test] - public void Test_7772() - { - } - [Test] - public void Test_7773() - { - } - [Test] - public void Test_7774() - { - } - [Test] - public void Test_7775() - { - } - [Test] - public void Test_7776() - { - } - [Test] - public void Test_7777() - { - } - [Test] - public void Test_7778() - { - } - [Test] - public void Test_7779() - { - } - [Test] - public void Test_7780() - { - } - [Test] - public void Test_7781() - { - } - [Test] - public void Test_7782() - { - } - [Test] - public void Test_7783() - { - } - [Test] - public void Test_7784() - { - } - [Test] - public void Test_7785() - { - } - [Test] - public void Test_7786() - { - } - [Test] - public void Test_7787() - { - } - [Test] - public void Test_7788() - { - } - [Test] - public void Test_7789() - { - } - [Test] - public void Test_7790() - { - } - [Test] - public void Test_7791() - { - } - [Test] - public void Test_7792() - { - } - [Test] - public void Test_7793() - { - } - [Test] - public void Test_7794() - { - } - [Test] - public void Test_7795() - { - } - [Test] - public void Test_7796() - { - } - [Test] - public void Test_7797() - { - } - [Test] - public void Test_7798() - { - } - [Test] - public void Test_7799() - { - } - [Test] - public void Test_7800() - { - } - [Test] - public void Test_7801() - { - } - [Test] - public void Test_7802() - { - } - [Test] - public void Test_7803() - { - } - [Test] - public void Test_7804() - { - } - [Test] - public void Test_7805() - { - } - [Test] - public void Test_7806() - { - } - [Test] - public void Test_7807() - { - } - [Test] - public void Test_7808() - { - } - [Test] - public void Test_7809() - { - } - [Test] - public void Test_7810() - { - } - [Test] - public void Test_7811() - { - } - [Test] - public void Test_7812() - { - } - [Test] - public void Test_7813() - { - } - [Test] - public void Test_7814() - { - } - [Test] - public void Test_7815() - { - } - [Test] - public void Test_7816() - { - } - [Test] - public void Test_7817() - { - } - [Test] - public void Test_7818() - { - } - [Test] - public void Test_7819() - { - } - [Test] - public void Test_7820() - { - } - [Test] - public void Test_7821() - { - } - [Test] - public void Test_7822() - { - } - [Test] - public void Test_7823() - { - } - [Test] - public void Test_7824() - { - } - [Test] - public void Test_7825() - { - } - [Test] - public void Test_7826() - { - } - [Test] - public void Test_7827() - { - } - [Test] - public void Test_7828() - { - } - [Test] - public void Test_7829() - { - } - [Test] - public void Test_7830() - { - } - [Test] - public void Test_7831() - { - } - [Test] - public void Test_7832() - { - } - [Test] - public void Test_7833() - { - } - [Test] - public void Test_7834() - { - } - [Test] - public void Test_7835() - { - } - [Test] - public void Test_7836() - { - } - [Test] - public void Test_7837() - { - } - [Test] - public void Test_7838() - { - } - [Test] - public void Test_7839() - { - } - [Test] - public void Test_7840() - { - } - [Test] - public void Test_7841() - { - } - [Test] - public void Test_7842() - { - } - [Test] - public void Test_7843() - { - } - [Test] - public void Test_7844() - { - } - [Test] - public void Test_7845() - { - } - [Test] - public void Test_7846() - { - } - [Test] - public void Test_7847() - { - } - [Test] - public void Test_7848() - { - } - [Test] - public void Test_7849() - { - } - [Test] - public void Test_7850() - { - } - [Test] - public void Test_7851() - { - } - [Test] - public void Test_7852() - { - } - [Test] - public void Test_7853() - { - } - [Test] - public void Test_7854() - { - } - [Test] - public void Test_7855() - { - } - [Test] - public void Test_7856() - { - } - [Test] - public void Test_7857() - { - } - [Test] - public void Test_7858() - { - } - [Test] - public void Test_7859() - { - } - [Test] - public void Test_7860() - { - } - [Test] - public void Test_7861() - { - } - [Test] - public void Test_7862() - { - } - [Test] - public void Test_7863() - { - } - [Test] - public void Test_7864() - { - } - [Test] - public void Test_7865() - { - } - [Test] - public void Test_7866() - { - } - [Test] - public void Test_7867() - { - } - [Test] - public void Test_7868() - { - } - [Test] - public void Test_7869() - { - } - [Test] - public void Test_7870() - { - } - [Test] - public void Test_7871() - { - } - [Test] - public void Test_7872() - { - } - [Test] - public void Test_7873() - { - } - [Test] - public void Test_7874() - { - } - [Test] - public void Test_7875() - { - } - [Test] - public void Test_7876() - { - } - [Test] - public void Test_7877() - { - } - [Test] - public void Test_7878() - { - } - [Test] - public void Test_7879() - { - } - [Test] - public void Test_7880() - { - } - [Test] - public void Test_7881() - { - } - [Test] - public void Test_7882() - { - } - [Test] - public void Test_7883() - { - } - [Test] - public void Test_7884() - { - } - [Test] - public void Test_7885() - { - } - [Test] - public void Test_7886() - { - } - [Test] - public void Test_7887() - { - } - [Test] - public void Test_7888() - { - } - [Test] - public void Test_7889() - { - } - [Test] - public void Test_7890() - { - } - [Test] - public void Test_7891() - { - } - [Test] - public void Test_7892() - { - } - [Test] - public void Test_7893() - { - } - [Test] - public void Test_7894() - { - } - [Test] - public void Test_7895() - { - } - [Test] - public void Test_7896() - { - } - [Test] - public void Test_7897() - { - } - [Test] - public void Test_7898() - { - } - [Test] - public void Test_7899() - { - } - [Test] - public void Test_7900() - { - } - [Test] - public void Test_7901() - { - } - [Test] - public void Test_7902() - { - } - [Test] - public void Test_7903() - { - } - [Test] - public void Test_7904() - { - } - [Test] - public void Test_7905() - { - } - [Test] - public void Test_7906() - { - } - [Test] - public void Test_7907() - { - } - [Test] - public void Test_7908() - { - } - [Test] - public void Test_7909() - { - } - [Test] - public void Test_7910() - { - } - [Test] - public void Test_7911() - { - } - [Test] - public void Test_7912() - { - } - [Test] - public void Test_7913() - { - } - [Test] - public void Test_7914() - { - } - [Test] - public void Test_7915() - { - } - [Test] - public void Test_7916() - { - } - [Test] - public void Test_7917() - { - } - [Test] - public void Test_7918() - { - } - [Test] - public void Test_7919() - { - } - [Test] - public void Test_7920() - { - } - [Test] - public void Test_7921() - { - } - [Test] - public void Test_7922() - { - } - [Test] - public void Test_7923() - { - } - [Test] - public void Test_7924() - { - } - [Test] - public void Test_7925() - { - } - [Test] - public void Test_7926() - { - } - [Test] - public void Test_7927() - { - } - [Test] - public void Test_7928() - { - } - [Test] - public void Test_7929() - { - } - [Test] - public void Test_7930() - { - } - [Test] - public void Test_7931() - { - } - [Test] - public void Test_7932() - { - } - [Test] - public void Test_7933() - { - } - [Test] - public void Test_7934() - { - } - [Test] - public void Test_7935() - { - } - [Test] - public void Test_7936() - { - } - [Test] - public void Test_7937() - { - } - [Test] - public void Test_7938() - { - } - [Test] - public void Test_7939() - { - } - [Test] - public void Test_7940() - { - } - [Test] - public void Test_7941() - { - } - [Test] - public void Test_7942() - { - } - [Test] - public void Test_7943() - { - } - [Test] - public void Test_7944() - { - } - [Test] - public void Test_7945() - { - } - [Test] - public void Test_7946() - { - } - [Test] - public void Test_7947() - { - } - [Test] - public void Test_7948() - { - } - [Test] - public void Test_7949() - { - } - [Test] - public void Test_7950() - { - } - [Test] - public void Test_7951() - { - } - [Test] - public void Test_7952() - { - } - [Test] - public void Test_7953() - { - } - [Test] - public void Test_7954() - { - } - [Test] - public void Test_7955() - { - } - [Test] - public void Test_7956() - { - } - [Test] - public void Test_7957() - { - } - [Test] - public void Test_7958() - { - } - [Test] - public void Test_7959() - { - } - [Test] - public void Test_7960() - { - } - [Test] - public void Test_7961() - { - } - [Test] - public void Test_7962() - { - } - [Test] - public void Test_7963() - { - } - [Test] - public void Test_7964() - { - } - [Test] - public void Test_7965() - { - } - [Test] - public void Test_7966() - { - } - [Test] - public void Test_7967() - { - } - [Test] - public void Test_7968() - { - } - [Test] - public void Test_7969() - { - } - [Test] - public void Test_7970() - { - } - [Test] - public void Test_7971() - { - } - [Test] - public void Test_7972() - { - } - [Test] - public void Test_7973() - { - } - [Test] - public void Test_7974() - { - } - [Test] - public void Test_7975() - { - } - [Test] - public void Test_7976() - { - } - [Test] - public void Test_7977() - { - } - [Test] - public void Test_7978() - { - } - [Test] - public void Test_7979() - { - } - [Test] - public void Test_7980() - { - } - [Test] - public void Test_7981() - { - } - [Test] - public void Test_7982() - { - } - [Test] - public void Test_7983() - { - } - [Test] - public void Test_7984() - { - } - [Test] - public void Test_7985() - { - } - [Test] - public void Test_7986() - { - } - [Test] - public void Test_7987() - { - } - [Test] - public void Test_7988() - { - } - [Test] - public void Test_7989() - { - } - [Test] - public void Test_7990() - { - } - [Test] - public void Test_7991() - { - } - [Test] - public void Test_7992() - { - } - [Test] - public void Test_7993() - { - } - [Test] - public void Test_7994() - { - } - [Test] - public void Test_7995() - { - } - [Test] - public void Test_7996() - { - } - [Test] - public void Test_7997() - { - } - [Test] - public void Test_7998() - { - } - [Test] - public void Test_7999() - { - } - [Test] - public void Test_8000() - { - } - [Test] - public void Test_8001() - { - } - [Test] - public void Test_8002() - { - } - [Test] - public void Test_8003() - { - } - [Test] - public void Test_8004() - { - } - [Test] - public void Test_8005() - { - } - [Test] - public void Test_8006() - { - } - [Test] - public void Test_8007() - { - } - [Test] - public void Test_8008() - { - } - [Test] - public void Test_8009() - { - } - [Test] - public void Test_8010() - { - } - [Test] - public void Test_8011() - { - } - [Test] - public void Test_8012() - { - } - [Test] - public void Test_8013() - { - } - [Test] - public void Test_8014() - { - } - [Test] - public void Test_8015() - { - } - [Test] - public void Test_8016() - { - } - [Test] - public void Test_8017() - { - } - [Test] - public void Test_8018() - { - } - [Test] - public void Test_8019() - { - } - [Test] - public void Test_8020() - { - } - [Test] - public void Test_8021() - { - } - [Test] - public void Test_8022() - { - } - [Test] - public void Test_8023() - { - } - [Test] - public void Test_8024() - { - } - [Test] - public void Test_8025() - { - } - [Test] - public void Test_8026() - { - } - [Test] - public void Test_8027() - { - } - [Test] - public void Test_8028() - { - } - [Test] - public void Test_8029() - { - } - [Test] - public void Test_8030() - { - } - [Test] - public void Test_8031() - { - } - [Test] - public void Test_8032() - { - } - [Test] - public void Test_8033() - { - } - [Test] - public void Test_8034() - { - } - [Test] - public void Test_8035() - { - } - [Test] - public void Test_8036() - { - } - [Test] - public void Test_8037() - { - } - [Test] - public void Test_8038() - { - } - [Test] - public void Test_8039() - { - } - [Test] - public void Test_8040() - { - } - [Test] - public void Test_8041() - { - } - [Test] - public void Test_8042() - { - } - [Test] - public void Test_8043() - { - } - [Test] - public void Test_8044() - { - } - [Test] - public void Test_8045() - { - } - [Test] - public void Test_8046() - { - } - [Test] - public void Test_8047() - { - } - [Test] - public void Test_8048() - { - } - [Test] - public void Test_8049() - { - } - [Test] - public void Test_8050() - { - } - [Test] - public void Test_8051() - { - } - [Test] - public void Test_8052() - { - } - [Test] - public void Test_8053() - { - } - [Test] - public void Test_8054() - { - } - [Test] - public void Test_8055() - { - } - [Test] - public void Test_8056() - { - } - [Test] - public void Test_8057() - { - } - [Test] - public void Test_8058() - { - } - [Test] - public void Test_8059() - { - } - [Test] - public void Test_8060() - { - } - [Test] - public void Test_8061() - { - } - [Test] - public void Test_8062() - { - } - [Test] - public void Test_8063() - { - } - [Test] - public void Test_8064() - { - } - [Test] - public void Test_8065() - { - } - [Test] - public void Test_8066() - { - } - [Test] - public void Test_8067() - { - } - [Test] - public void Test_8068() - { - } - [Test] - public void Test_8069() - { - } - [Test] - public void Test_8070() - { - } - [Test] - public void Test_8071() - { - } - [Test] - public void Test_8072() - { - } - [Test] - public void Test_8073() - { - } - [Test] - public void Test_8074() - { - } - [Test] - public void Test_8075() - { - } - [Test] - public void Test_8076() - { - } - [Test] - public void Test_8077() - { - } - [Test] - public void Test_8078() - { - } - [Test] - public void Test_8079() - { - } - [Test] - public void Test_8080() - { - } - [Test] - public void Test_8081() - { - } - [Test] - public void Test_8082() - { - } - [Test] - public void Test_8083() - { - } - [Test] - public void Test_8084() - { - } - [Test] - public void Test_8085() - { - } - [Test] - public void Test_8086() - { - } - [Test] - public void Test_8087() - { - } - [Test] - public void Test_8088() - { - } - [Test] - public void Test_8089() - { - } - [Test] - public void Test_8090() - { - } - [Test] - public void Test_8091() - { - } - [Test] - public void Test_8092() - { - } - [Test] - public void Test_8093() - { - } - [Test] - public void Test_8094() - { - } - [Test] - public void Test_8095() - { - } - [Test] - public void Test_8096() - { - } - [Test] - public void Test_8097() - { - } - [Test] - public void Test_8098() - { - } - [Test] - public void Test_8099() - { - } - [Test] - public void Test_8100() - { - } - [Test] - public void Test_8101() - { - } - [Test] - public void Test_8102() - { - } - [Test] - public void Test_8103() - { - } - [Test] - public void Test_8104() - { - } - [Test] - public void Test_8105() - { - } - [Test] - public void Test_8106() - { - } - [Test] - public void Test_8107() - { - } - [Test] - public void Test_8108() - { - } - [Test] - public void Test_8109() - { - } - [Test] - public void Test_8110() - { - } - [Test] - public void Test_8111() - { - } - [Test] - public void Test_8112() - { - } - [Test] - public void Test_8113() - { - } - [Test] - public void Test_8114() - { - } - [Test] - public void Test_8115() - { - } - [Test] - public void Test_8116() - { - } - [Test] - public void Test_8117() - { - } - [Test] - public void Test_8118() - { - } - [Test] - public void Test_8119() - { - } - [Test] - public void Test_8120() - { - } - [Test] - public void Test_8121() - { - } - [Test] - public void Test_8122() - { - } - [Test] - public void Test_8123() - { - } - [Test] - public void Test_8124() - { - } - [Test] - public void Test_8125() - { - } - [Test] - public void Test_8126() - { - } - [Test] - public void Test_8127() - { - } - [Test] - public void Test_8128() - { - } - [Test] - public void Test_8129() - { - } - [Test] - public void Test_8130() - { - } - [Test] - public void Test_8131() - { - } - [Test] - public void Test_8132() - { - } - [Test] - public void Test_8133() - { - } - [Test] - public void Test_8134() - { - } - [Test] - public void Test_8135() - { - } - [Test] - public void Test_8136() - { - } - [Test] - public void Test_8137() - { - } - [Test] - public void Test_8138() - { - } - [Test] - public void Test_8139() - { - } - [Test] - public void Test_8140() - { - } - [Test] - public void Test_8141() - { - } - [Test] - public void Test_8142() - { - } - [Test] - public void Test_8143() - { - } - [Test] - public void Test_8144() - { - } - [Test] - public void Test_8145() - { - } - [Test] - public void Test_8146() - { - } - [Test] - public void Test_8147() - { - } - [Test] - public void Test_8148() - { - } - [Test] - public void Test_8149() - { - } - [Test] - public void Test_8150() - { - } - [Test] - public void Test_8151() - { - } - [Test] - public void Test_8152() - { - } - [Test] - public void Test_8153() - { - } - [Test] - public void Test_8154() - { - } - [Test] - public void Test_8155() - { - } - [Test] - public void Test_8156() - { - } - [Test] - public void Test_8157() - { - } - [Test] - public void Test_8158() - { - } - [Test] - public void Test_8159() - { - } - [Test] - public void Test_8160() - { - } - [Test] - public void Test_8161() - { - } - [Test] - public void Test_8162() - { - } - [Test] - public void Test_8163() - { - } - [Test] - public void Test_8164() - { - } - [Test] - public void Test_8165() - { - } - [Test] - public void Test_8166() - { - } - [Test] - public void Test_8167() - { - } - [Test] - public void Test_8168() - { - } - [Test] - public void Test_8169() - { - } - [Test] - public void Test_8170() - { - } - [Test] - public void Test_8171() - { - } - [Test] - public void Test_8172() - { - } - [Test] - public void Test_8173() - { - } - [Test] - public void Test_8174() - { - } - [Test] - public void Test_8175() - { - } - [Test] - public void Test_8176() - { - } - [Test] - public void Test_8177() - { - } - [Test] - public void Test_8178() - { - } - [Test] - public void Test_8179() - { - } - [Test] - public void Test_8180() - { - } - [Test] - public void Test_8181() - { - } - [Test] - public void Test_8182() - { - } - [Test] - public void Test_8183() - { - } - [Test] - public void Test_8184() - { - } - [Test] - public void Test_8185() - { - } - [Test] - public void Test_8186() - { - } - [Test] - public void Test_8187() - { - } - [Test] - public void Test_8188() - { - } - [Test] - public void Test_8189() - { - } - [Test] - public void Test_8190() - { - } - [Test] - public void Test_8191() - { - } - [Test] - public void Test_8192() - { - } - [Test] - public void Test_8193() - { - } - [Test] - public void Test_8194() - { - } - [Test] - public void Test_8195() - { - } - [Test] - public void Test_8196() - { - } - [Test] - public void Test_8197() - { - } - [Test] - public void Test_8198() - { - } - [Test] - public void Test_8199() - { - } - [Test] - public void Test_8200() - { - } - [Test] - public void Test_8201() - { - } - [Test] - public void Test_8202() - { - } - [Test] - public void Test_8203() - { - } - [Test] - public void Test_8204() - { - } - [Test] - public void Test_8205() - { - } - [Test] - public void Test_8206() - { - } - [Test] - public void Test_8207() - { - } - [Test] - public void Test_8208() - { - } - [Test] - public void Test_8209() - { - } - [Test] - public void Test_8210() - { - } - [Test] - public void Test_8211() - { - } - [Test] - public void Test_8212() - { - } - [Test] - public void Test_8213() - { - } - [Test] - public void Test_8214() - { - } - [Test] - public void Test_8215() - { - } - [Test] - public void Test_8216() - { - } - [Test] - public void Test_8217() - { - } - [Test] - public void Test_8218() - { - } - [Test] - public void Test_8219() - { - } - [Test] - public void Test_8220() - { - } - [Test] - public void Test_8221() - { - } - [Test] - public void Test_8222() - { - } - [Test] - public void Test_8223() - { - } - [Test] - public void Test_8224() - { - } - [Test] - public void Test_8225() - { - } - [Test] - public void Test_8226() - { - } - [Test] - public void Test_8227() - { - } - [Test] - public void Test_8228() - { - } - [Test] - public void Test_8229() - { - } - [Test] - public void Test_8230() - { - } - [Test] - public void Test_8231() - { - } - [Test] - public void Test_8232() - { - } - [Test] - public void Test_8233() - { - } - [Test] - public void Test_8234() - { - } - [Test] - public void Test_8235() - { - } - [Test] - public void Test_8236() - { - } - [Test] - public void Test_8237() - { - } - [Test] - public void Test_8238() - { - } - [Test] - public void Test_8239() - { - } - [Test] - public void Test_8240() - { - } - [Test] - public void Test_8241() - { - } - [Test] - public void Test_8242() - { - } - [Test] - public void Test_8243() - { - } - [Test] - public void Test_8244() - { - } - [Test] - public void Test_8245() - { - } - [Test] - public void Test_8246() - { - } - [Test] - public void Test_8247() - { - } - [Test] - public void Test_8248() - { - } - [Test] - public void Test_8249() - { - } - [Test] - public void Test_8250() - { - } - [Test] - public void Test_8251() - { - } - [Test] - public void Test_8252() - { - } - [Test] - public void Test_8253() - { - } - [Test] - public void Test_8254() - { - } - [Test] - public void Test_8255() - { - } - [Test] - public void Test_8256() - { - } - [Test] - public void Test_8257() - { - } - [Test] - public void Test_8258() - { - } - [Test] - public void Test_8259() - { - } - [Test] - public void Test_8260() - { - } - [Test] - public void Test_8261() - { - } - [Test] - public void Test_8262() - { - } - [Test] - public void Test_8263() - { - } - [Test] - public void Test_8264() - { - } - [Test] - public void Test_8265() - { - } - [Test] - public void Test_8266() - { - } - [Test] - public void Test_8267() - { - } - [Test] - public void Test_8268() - { - } - [Test] - public void Test_8269() - { - } - [Test] - public void Test_8270() - { - } - [Test] - public void Test_8271() - { - } - [Test] - public void Test_8272() - { - } - [Test] - public void Test_8273() - { - } - [Test] - public void Test_8274() - { - } - [Test] - public void Test_8275() - { - } - [Test] - public void Test_8276() - { - } - [Test] - public void Test_8277() - { - } - [Test] - public void Test_8278() - { - } - [Test] - public void Test_8279() - { - } - [Test] - public void Test_8280() - { - } - [Test] - public void Test_8281() - { - } - [Test] - public void Test_8282() - { - } - [Test] - public void Test_8283() - { - } - [Test] - public void Test_8284() - { - } - [Test] - public void Test_8285() - { - } - [Test] - public void Test_8286() - { - } - [Test] - public void Test_8287() - { - } - [Test] - public void Test_8288() - { - } - [Test] - public void Test_8289() - { - } - [Test] - public void Test_8290() - { - } - [Test] - public void Test_8291() - { - } - [Test] - public void Test_8292() - { - } - [Test] - public void Test_8293() - { - } - [Test] - public void Test_8294() - { - } - [Test] - public void Test_8295() - { - } - [Test] - public void Test_8296() - { - } - [Test] - public void Test_8297() - { - } - [Test] - public void Test_8298() - { - } - [Test] - public void Test_8299() - { - } - [Test] - public void Test_8300() - { - } - [Test] - public void Test_8301() - { - } - [Test] - public void Test_8302() - { - } - [Test] - public void Test_8303() - { - } - [Test] - public void Test_8304() - { - } - [Test] - public void Test_8305() - { - } - [Test] - public void Test_8306() - { - } - [Test] - public void Test_8307() - { - } - [Test] - public void Test_8308() - { - } - [Test] - public void Test_8309() - { - } - [Test] - public void Test_8310() - { - } - [Test] - public void Test_8311() - { - } - [Test] - public void Test_8312() - { - } - [Test] - public void Test_8313() - { - } - [Test] - public void Test_8314() - { - } - [Test] - public void Test_8315() - { - } - [Test] - public void Test_8316() - { - } - [Test] - public void Test_8317() - { - } - [Test] - public void Test_8318() - { - } - [Test] - public void Test_8319() - { - } - [Test] - public void Test_8320() - { - } - [Test] - public void Test_8321() - { - } - [Test] - public void Test_8322() - { - } - [Test] - public void Test_8323() - { - } - [Test] - public void Test_8324() - { - } - [Test] - public void Test_8325() - { - } - [Test] - public void Test_8326() - { - } - [Test] - public void Test_8327() - { - } - [Test] - public void Test_8328() - { - } - [Test] - public void Test_8329() - { - } - [Test] - public void Test_8330() - { - } - [Test] - public void Test_8331() - { - } - [Test] - public void Test_8332() - { - } - [Test] - public void Test_8333() - { - } - [Test] - public void Test_8334() - { - } - [Test] - public void Test_8335() - { - } - [Test] - public void Test_8336() - { - } - [Test] - public void Test_8337() - { - } - [Test] - public void Test_8338() - { - } - [Test] - public void Test_8339() - { - } - [Test] - public void Test_8340() - { - } - [Test] - public void Test_8341() - { - } - [Test] - public void Test_8342() - { - } - [Test] - public void Test_8343() - { - } - [Test] - public void Test_8344() - { - } - [Test] - public void Test_8345() - { - } - [Test] - public void Test_8346() - { - } - [Test] - public void Test_8347() - { - } - [Test] - public void Test_8348() - { - } - [Test] - public void Test_8349() - { - } - [Test] - public void Test_8350() - { - } - [Test] - public void Test_8351() - { - } - [Test] - public void Test_8352() - { - } - [Test] - public void Test_8353() - { - } - [Test] - public void Test_8354() - { - } - [Test] - public void Test_8355() - { - } - [Test] - public void Test_8356() - { - } - [Test] - public void Test_8357() - { - } - [Test] - public void Test_8358() - { - } - [Test] - public void Test_8359() - { - } - [Test] - public void Test_8360() - { - } - [Test] - public void Test_8361() - { - } - [Test] - public void Test_8362() - { - } - [Test] - public void Test_8363() - { - } - [Test] - public void Test_8364() - { - } - [Test] - public void Test_8365() - { - } - [Test] - public void Test_8366() - { - } - [Test] - public void Test_8367() - { - } - [Test] - public void Test_8368() - { - } - [Test] - public void Test_8369() - { - } - [Test] - public void Test_8370() - { - } - [Test] - public void Test_8371() - { - } - [Test] - public void Test_8372() - { - } - [Test] - public void Test_8373() - { - } - [Test] - public void Test_8374() - { - } - [Test] - public void Test_8375() - { - } - [Test] - public void Test_8376() - { - } - [Test] - public void Test_8377() - { - } - [Test] - public void Test_8378() - { - } - [Test] - public void Test_8379() - { - } - [Test] - public void Test_8380() - { - } - [Test] - public void Test_8381() - { - } - [Test] - public void Test_8382() - { - } - [Test] - public void Test_8383() - { - } - [Test] - public void Test_8384() - { - } - [Test] - public void Test_8385() - { - } - [Test] - public void Test_8386() - { - } - [Test] - public void Test_8387() - { - } - [Test] - public void Test_8388() - { - } - [Test] - public void Test_8389() - { - } - [Test] - public void Test_8390() - { - } - [Test] - public void Test_8391() - { - } - [Test] - public void Test_8392() - { - } - [Test] - public void Test_8393() - { - } - [Test] - public void Test_8394() - { - } - [Test] - public void Test_8395() - { - } - [Test] - public void Test_8396() - { - } - [Test] - public void Test_8397() - { - } - [Test] - public void Test_8398() - { - } - [Test] - public void Test_8399() - { - } - [Test] - public void Test_8400() - { - } - [Test] - public void Test_8401() - { - } - [Test] - public void Test_8402() - { - } - [Test] - public void Test_8403() - { - } - [Test] - public void Test_8404() - { - } - [Test] - public void Test_8405() - { - } - [Test] - public void Test_8406() - { - } - [Test] - public void Test_8407() - { - } - [Test] - public void Test_8408() - { - } - [Test] - public void Test_8409() - { - } - [Test] - public void Test_8410() - { - } - [Test] - public void Test_8411() - { - } - [Test] - public void Test_8412() - { - } - [Test] - public void Test_8413() - { - } - [Test] - public void Test_8414() - { - } - [Test] - public void Test_8415() - { - } - [Test] - public void Test_8416() - { - } - [Test] - public void Test_8417() - { - } - [Test] - public void Test_8418() - { - } - [Test] - public void Test_8419() - { - } - [Test] - public void Test_8420() - { - } - [Test] - public void Test_8421() - { - } - [Test] - public void Test_8422() - { - } - [Test] - public void Test_8423() - { - } - [Test] - public void Test_8424() - { - } - [Test] - public void Test_8425() - { - } - [Test] - public void Test_8426() - { - } - [Test] - public void Test_8427() - { - } - [Test] - public void Test_8428() - { - } - [Test] - public void Test_8429() - { - } - [Test] - public void Test_8430() - { - } - [Test] - public void Test_8431() - { - } - [Test] - public void Test_8432() - { - } - [Test] - public void Test_8433() - { - } - [Test] - public void Test_8434() - { - } - [Test] - public void Test_8435() - { - } - [Test] - public void Test_8436() - { - } - [Test] - public void Test_8437() - { - } - [Test] - public void Test_8438() - { - } - [Test] - public void Test_8439() - { - } - [Test] - public void Test_8440() - { - } - [Test] - public void Test_8441() - { - } - [Test] - public void Test_8442() - { - } - [Test] - public void Test_8443() - { - } - [Test] - public void Test_8444() - { - } - [Test] - public void Test_8445() - { - } - [Test] - public void Test_8446() - { - } - [Test] - public void Test_8447() - { - } - [Test] - public void Test_8448() - { - } - [Test] - public void Test_8449() - { - } - [Test] - public void Test_8450() - { - } - [Test] - public void Test_8451() - { - } - [Test] - public void Test_8452() - { - } - [Test] - public void Test_8453() - { - } - [Test] - public void Test_8454() - { - } - [Test] - public void Test_8455() - { - } - [Test] - public void Test_8456() - { - } - [Test] - public void Test_8457() - { - } - [Test] - public void Test_8458() - { - } - [Test] - public void Test_8459() - { - } - [Test] - public void Test_8460() - { - } - [Test] - public void Test_8461() - { - } - [Test] - public void Test_8462() - { - } - [Test] - public void Test_8463() - { - } - [Test] - public void Test_8464() - { - } - [Test] - public void Test_8465() - { - } - [Test] - public void Test_8466() - { - } - [Test] - public void Test_8467() - { - } - [Test] - public void Test_8468() - { - } - [Test] - public void Test_8469() - { - } - [Test] - public void Test_8470() - { - } - [Test] - public void Test_8471() - { - } - [Test] - public void Test_8472() - { - } - [Test] - public void Test_8473() - { - } - [Test] - public void Test_8474() - { - } - [Test] - public void Test_8475() - { - } - [Test] - public void Test_8476() - { - } - [Test] - public void Test_8477() - { - } - [Test] - public void Test_8478() - { - } - [Test] - public void Test_8479() - { - } - [Test] - public void Test_8480() - { - } - [Test] - public void Test_8481() - { - } - [Test] - public void Test_8482() - { - } - [Test] - public void Test_8483() - { - } - [Test] - public void Test_8484() - { - } - [Test] - public void Test_8485() - { - } - [Test] - public void Test_8486() - { - } - [Test] - public void Test_8487() - { - } - [Test] - public void Test_8488() - { - } - [Test] - public void Test_8489() - { - } - [Test] - public void Test_8490() - { - } - [Test] - public void Test_8491() - { - } - [Test] - public void Test_8492() - { - } - [Test] - public void Test_8493() - { - } - [Test] - public void Test_8494() - { - } - [Test] - public void Test_8495() - { - } - [Test] - public void Test_8496() - { - } - [Test] - public void Test_8497() - { - } - [Test] - public void Test_8498() - { - } - [Test] - public void Test_8499() - { - } - [Test] - public void Test_8500() - { - } - [Test] - public void Test_8501() - { - } - [Test] - public void Test_8502() - { - } - [Test] - public void Test_8503() - { - } - [Test] - public void Test_8504() - { - } - [Test] - public void Test_8505() - { - } - [Test] - public void Test_8506() - { - } - [Test] - public void Test_8507() - { - } - [Test] - public void Test_8508() - { - } - [Test] - public void Test_8509() - { - } - [Test] - public void Test_8510() - { - } - [Test] - public void Test_8511() - { - } - [Test] - public void Test_8512() - { - } - [Test] - public void Test_8513() - { - } - [Test] - public void Test_8514() - { - } - [Test] - public void Test_8515() - { - } - [Test] - public void Test_8516() - { - } - [Test] - public void Test_8517() - { - } - [Test] - public void Test_8518() - { - } - [Test] - public void Test_8519() - { - } - [Test] - public void Test_8520() - { - } - [Test] - public void Test_8521() - { - } - [Test] - public void Test_8522() - { - } - [Test] - public void Test_8523() - { - } - [Test] - public void Test_8524() - { - } - [Test] - public void Test_8525() - { - } - [Test] - public void Test_8526() - { - } - [Test] - public void Test_8527() - { - } - [Test] - public void Test_8528() - { - } - [Test] - public void Test_8529() - { - } - [Test] - public void Test_8530() - { - } - [Test] - public void Test_8531() - { - } - [Test] - public void Test_8532() - { - } - [Test] - public void Test_8533() - { - } - [Test] - public void Test_8534() - { - } - [Test] - public void Test_8535() - { - } - [Test] - public void Test_8536() - { - } - [Test] - public void Test_8537() - { - } - [Test] - public void Test_8538() - { - } - [Test] - public void Test_8539() - { - } - [Test] - public void Test_8540() - { - } - [Test] - public void Test_8541() - { - } - [Test] - public void Test_8542() - { - } - [Test] - public void Test_8543() - { - } - [Test] - public void Test_8544() - { - } - [Test] - public void Test_8545() - { - } - [Test] - public void Test_8546() - { - } - [Test] - public void Test_8547() - { - } - [Test] - public void Test_8548() - { - } - [Test] - public void Test_8549() - { - } - [Test] - public void Test_8550() - { - } - [Test] - public void Test_8551() - { - } - [Test] - public void Test_8552() - { - } - [Test] - public void Test_8553() - { - } - [Test] - public void Test_8554() - { - } - [Test] - public void Test_8555() - { - } - [Test] - public void Test_8556() - { - } - [Test] - public void Test_8557() - { - } - [Test] - public void Test_8558() - { - } - [Test] - public void Test_8559() - { - } - [Test] - public void Test_8560() - { - } - [Test] - public void Test_8561() - { - } - [Test] - public void Test_8562() - { - } - [Test] - public void Test_8563() - { - } - [Test] - public void Test_8564() - { - } - [Test] - public void Test_8565() - { - } - [Test] - public void Test_8566() - { - } - [Test] - public void Test_8567() - { - } - [Test] - public void Test_8568() - { - } - [Test] - public void Test_8569() - { - } - [Test] - public void Test_8570() - { - } - [Test] - public void Test_8571() - { - } - [Test] - public void Test_8572() - { - } - [Test] - public void Test_8573() - { - } - [Test] - public void Test_8574() - { - } - [Test] - public void Test_8575() - { - } - [Test] - public void Test_8576() - { - } - [Test] - public void Test_8577() - { - } - [Test] - public void Test_8578() - { - } - [Test] - public void Test_8579() - { - } - [Test] - public void Test_8580() - { - } - [Test] - public void Test_8581() - { - } - [Test] - public void Test_8582() - { - } - [Test] - public void Test_8583() - { - } - [Test] - public void Test_8584() - { - } - [Test] - public void Test_8585() - { - } - [Test] - public void Test_8586() - { - } - [Test] - public void Test_8587() - { - } - [Test] - public void Test_8588() - { - } - [Test] - public void Test_8589() - { - } - [Test] - public void Test_8590() - { - } - [Test] - public void Test_8591() - { - } - [Test] - public void Test_8592() - { - } - [Test] - public void Test_8593() - { - } - [Test] - public void Test_8594() - { - } - [Test] - public void Test_8595() - { - } - [Test] - public void Test_8596() - { - } - [Test] - public void Test_8597() - { - } - [Test] - public void Test_8598() - { - } - [Test] - public void Test_8599() - { - } - [Test] - public void Test_8600() - { - } - [Test] - public void Test_8601() - { - } - [Test] - public void Test_8602() - { - } - [Test] - public void Test_8603() - { - } - [Test] - public void Test_8604() - { - } - [Test] - public void Test_8605() - { - } - [Test] - public void Test_8606() - { - } - [Test] - public void Test_8607() - { - } - [Test] - public void Test_8608() - { - } - [Test] - public void Test_8609() - { - } - [Test] - public void Test_8610() - { - } - [Test] - public void Test_8611() - { - } - [Test] - public void Test_8612() - { - } - [Test] - public void Test_8613() - { - } - [Test] - public void Test_8614() - { - } - [Test] - public void Test_8615() - { - } - [Test] - public void Test_8616() - { - } - [Test] - public void Test_8617() - { - } - [Test] - public void Test_8618() - { - } - [Test] - public void Test_8619() - { - } - [Test] - public void Test_8620() - { - } - [Test] - public void Test_8621() - { - } - [Test] - public void Test_8622() - { - } - [Test] - public void Test_8623() - { - } - [Test] - public void Test_8624() - { - } - [Test] - public void Test_8625() - { - } - [Test] - public void Test_8626() - { - } - [Test] - public void Test_8627() - { - } - [Test] - public void Test_8628() - { - } - [Test] - public void Test_8629() - { - } - [Test] - public void Test_8630() - { - } - [Test] - public void Test_8631() - { - } - [Test] - public void Test_8632() - { - } - [Test] - public void Test_8633() - { - } - [Test] - public void Test_8634() - { - } - [Test] - public void Test_8635() - { - } - [Test] - public void Test_8636() - { - } - [Test] - public void Test_8637() - { - } - [Test] - public void Test_8638() - { - } - [Test] - public void Test_8639() - { - } - [Test] - public void Test_8640() - { - } - [Test] - public void Test_8641() - { - } - [Test] - public void Test_8642() - { - } - [Test] - public void Test_8643() - { - } - [Test] - public void Test_8644() - { - } - [Test] - public void Test_8645() - { - } - [Test] - public void Test_8646() - { - } - [Test] - public void Test_8647() - { - } - [Test] - public void Test_8648() - { - } - [Test] - public void Test_8649() - { - } - [Test] - public void Test_8650() - { - } - [Test] - public void Test_8651() - { - } - [Test] - public void Test_8652() - { - } - [Test] - public void Test_8653() - { - } - [Test] - public void Test_8654() - { - } - [Test] - public void Test_8655() - { - } - [Test] - public void Test_8656() - { - } - [Test] - public void Test_8657() - { - } - [Test] - public void Test_8658() - { - } - [Test] - public void Test_8659() - { - } - [Test] - public void Test_8660() - { - } - [Test] - public void Test_8661() - { - } - [Test] - public void Test_8662() - { - } - [Test] - public void Test_8663() - { - } - [Test] - public void Test_8664() - { - } - [Test] - public void Test_8665() - { - } - [Test] - public void Test_8666() - { - } - [Test] - public void Test_8667() - { - } - [Test] - public void Test_8668() - { - } - [Test] - public void Test_8669() - { - } - [Test] - public void Test_8670() - { - } - [Test] - public void Test_8671() - { - } - [Test] - public void Test_8672() - { - } - [Test] - public void Test_8673() - { - } - [Test] - public void Test_8674() - { - } - [Test] - public void Test_8675() - { - } - [Test] - public void Test_8676() - { - } - [Test] - public void Test_8677() - { - } - [Test] - public void Test_8678() - { - } - [Test] - public void Test_8679() - { - } - [Test] - public void Test_8680() - { - } - [Test] - public void Test_8681() - { - } - [Test] - public void Test_8682() - { - } - [Test] - public void Test_8683() - { - } - [Test] - public void Test_8684() - { - } - [Test] - public void Test_8685() - { - } - [Test] - public void Test_8686() - { - } - [Test] - public void Test_8687() - { - } - [Test] - public void Test_8688() - { - } - [Test] - public void Test_8689() - { - } - [Test] - public void Test_8690() - { - } - [Test] - public void Test_8691() - { - } - [Test] - public void Test_8692() - { - } - [Test] - public void Test_8693() - { - } - [Test] - public void Test_8694() - { - } - [Test] - public void Test_8695() - { - } - [Test] - public void Test_8696() - { - } - [Test] - public void Test_8697() - { - } - [Test] - public void Test_8698() - { - } - [Test] - public void Test_8699() - { - } - [Test] - public void Test_8700() - { - } - [Test] - public void Test_8701() - { - } - [Test] - public void Test_8702() - { - } - [Test] - public void Test_8703() - { - } - [Test] - public void Test_8704() - { - } - [Test] - public void Test_8705() - { - } - [Test] - public void Test_8706() - { - } - [Test] - public void Test_8707() - { - } - [Test] - public void Test_8708() - { - } - [Test] - public void Test_8709() - { - } - [Test] - public void Test_8710() - { - } - [Test] - public void Test_8711() - { - } - [Test] - public void Test_8712() - { - } - [Test] - public void Test_8713() - { - } - [Test] - public void Test_8714() - { - } - [Test] - public void Test_8715() - { - } - [Test] - public void Test_8716() - { - } - [Test] - public void Test_8717() - { - } - [Test] - public void Test_8718() - { - } - [Test] - public void Test_8719() - { - } - [Test] - public void Test_8720() - { - } - [Test] - public void Test_8721() - { - } - [Test] - public void Test_8722() - { - } - [Test] - public void Test_8723() - { - } - [Test] - public void Test_8724() - { - } - [Test] - public void Test_8725() - { - } - [Test] - public void Test_8726() - { - } - [Test] - public void Test_8727() - { - } - [Test] - public void Test_8728() - { - } - [Test] - public void Test_8729() - { - } - [Test] - public void Test_8730() - { - } - [Test] - public void Test_8731() - { - } - [Test] - public void Test_8732() - { - } - [Test] - public void Test_8733() - { - } - [Test] - public void Test_8734() - { - } - [Test] - public void Test_8735() - { - } - [Test] - public void Test_8736() - { - } - [Test] - public void Test_8737() - { - } - [Test] - public void Test_8738() - { - } - [Test] - public void Test_8739() - { - } - [Test] - public void Test_8740() - { - } - [Test] - public void Test_8741() - { - } - [Test] - public void Test_8742() - { - } - [Test] - public void Test_8743() - { - } - [Test] - public void Test_8744() - { - } - [Test] - public void Test_8745() - { - } - [Test] - public void Test_8746() - { - } - [Test] - public void Test_8747() - { - } - [Test] - public void Test_8748() - { - } - [Test] - public void Test_8749() - { - } - [Test] - public void Test_8750() - { - } - [Test] - public void Test_8751() - { - } - [Test] - public void Test_8752() - { - } - [Test] - public void Test_8753() - { - } - [Test] - public void Test_8754() - { - } - [Test] - public void Test_8755() - { - } - [Test] - public void Test_8756() - { - } - [Test] - public void Test_8757() - { - } - [Test] - public void Test_8758() - { - } - [Test] - public void Test_8759() - { - } - [Test] - public void Test_8760() - { - } - [Test] - public void Test_8761() - { - } - [Test] - public void Test_8762() - { - } - [Test] - public void Test_8763() - { - } - [Test] - public void Test_8764() - { - } - [Test] - public void Test_8765() - { - } - [Test] - public void Test_8766() - { - } - [Test] - public void Test_8767() - { - } - [Test] - public void Test_8768() - { - } - [Test] - public void Test_8769() - { - } - [Test] - public void Test_8770() - { - } - [Test] - public void Test_8771() - { - } - [Test] - public void Test_8772() - { - } - [Test] - public void Test_8773() - { - } - [Test] - public void Test_8774() - { - } - [Test] - public void Test_8775() - { - } - [Test] - public void Test_8776() - { - } - [Test] - public void Test_8777() - { - } - [Test] - public void Test_8778() - { - } - [Test] - public void Test_8779() - { - } - [Test] - public void Test_8780() - { - } - [Test] - public void Test_8781() - { - } - [Test] - public void Test_8782() - { - } - [Test] - public void Test_8783() - { - } - [Test] - public void Test_8784() - { - } - [Test] - public void Test_8785() - { - } - [Test] - public void Test_8786() - { - } - [Test] - public void Test_8787() - { - } - [Test] - public void Test_8788() - { - } - [Test] - public void Test_8789() - { - } - [Test] - public void Test_8790() - { - } - [Test] - public void Test_8791() - { - } - [Test] - public void Test_8792() - { - } - [Test] - public void Test_8793() - { - } - [Test] - public void Test_8794() - { - } - [Test] - public void Test_8795() - { - } - [Test] - public void Test_8796() - { - } - [Test] - public void Test_8797() - { - } - [Test] - public void Test_8798() - { - } - [Test] - public void Test_8799() - { - } - [Test] - public void Test_8800() - { - } - [Test] - public void Test_8801() - { - } - [Test] - public void Test_8802() - { - } - [Test] - public void Test_8803() - { - } - [Test] - public void Test_8804() - { - } - [Test] - public void Test_8805() - { - } - [Test] - public void Test_8806() - { - } - [Test] - public void Test_8807() - { - } - [Test] - public void Test_8808() - { - } - [Test] - public void Test_8809() - { - } - [Test] - public void Test_8810() - { - } - [Test] - public void Test_8811() - { - } - [Test] - public void Test_8812() - { - } - [Test] - public void Test_8813() - { - } - [Test] - public void Test_8814() - { - } - [Test] - public void Test_8815() - { - } - [Test] - public void Test_8816() - { - } - [Test] - public void Test_8817() - { - } - [Test] - public void Test_8818() - { - } - [Test] - public void Test_8819() - { - } - [Test] - public void Test_8820() - { - } - [Test] - public void Test_8821() - { - } - [Test] - public void Test_8822() - { - } - [Test] - public void Test_8823() - { - } - [Test] - public void Test_8824() - { - } - [Test] - public void Test_8825() - { - } - [Test] - public void Test_8826() - { - } - [Test] - public void Test_8827() - { - } - [Test] - public void Test_8828() - { - } - [Test] - public void Test_8829() - { - } - [Test] - public void Test_8830() - { - } - [Test] - public void Test_8831() - { - } - [Test] - public void Test_8832() - { - } - [Test] - public void Test_8833() - { - } - [Test] - public void Test_8834() - { - } - [Test] - public void Test_8835() - { - } - [Test] - public void Test_8836() - { - } - [Test] - public void Test_8837() - { - } - [Test] - public void Test_8838() - { - } - [Test] - public void Test_8839() - { - } - [Test] - public void Test_8840() - { - } - [Test] - public void Test_8841() - { - } - [Test] - public void Test_8842() - { - } - [Test] - public void Test_8843() - { - } - [Test] - public void Test_8844() - { - } - [Test] - public void Test_8845() - { - } - [Test] - public void Test_8846() - { - } - [Test] - public void Test_8847() - { - } - [Test] - public void Test_8848() - { - } - [Test] - public void Test_8849() - { - } - [Test] - public void Test_8850() - { - } - [Test] - public void Test_8851() - { - } - [Test] - public void Test_8852() - { - } - [Test] - public void Test_8853() - { - } - [Test] - public void Test_8854() - { - } - [Test] - public void Test_8855() - { - } - [Test] - public void Test_8856() - { - } - [Test] - public void Test_8857() - { - } - [Test] - public void Test_8858() - { - } - [Test] - public void Test_8859() - { - } - [Test] - public void Test_8860() - { - } - [Test] - public void Test_8861() - { - } - [Test] - public void Test_8862() - { - } - [Test] - public void Test_8863() - { - } - [Test] - public void Test_8864() - { - } - [Test] - public void Test_8865() - { - } - [Test] - public void Test_8866() - { - } - [Test] - public void Test_8867() - { - } - [Test] - public void Test_8868() - { - } - [Test] - public void Test_8869() - { - } - [Test] - public void Test_8870() - { - } - [Test] - public void Test_8871() - { - } - [Test] - public void Test_8872() - { - } - [Test] - public void Test_8873() - { - } - [Test] - public void Test_8874() - { - } - [Test] - public void Test_8875() - { - } - [Test] - public void Test_8876() - { - } - [Test] - public void Test_8877() - { - } - [Test] - public void Test_8878() - { - } - [Test] - public void Test_8879() - { - } - [Test] - public void Test_8880() - { - } - [Test] - public void Test_8881() - { - } - [Test] - public void Test_8882() - { - } - [Test] - public void Test_8883() - { - } - [Test] - public void Test_8884() - { - } - [Test] - public void Test_8885() - { - } - [Test] - public void Test_8886() - { - } - [Test] - public void Test_8887() - { - } - [Test] - public void Test_8888() - { - } - [Test] - public void Test_8889() - { - } - [Test] - public void Test_8890() - { - } - [Test] - public void Test_8891() - { - } - [Test] - public void Test_8892() - { - } - [Test] - public void Test_8893() - { - } - [Test] - public void Test_8894() - { - } - [Test] - public void Test_8895() - { - } - [Test] - public void Test_8896() - { - } - [Test] - public void Test_8897() - { - } - [Test] - public void Test_8898() - { - } - [Test] - public void Test_8899() - { - } - [Test] - public void Test_8900() - { - } - [Test] - public void Test_8901() - { - } - [Test] - public void Test_8902() - { - } - [Test] - public void Test_8903() - { - } - [Test] - public void Test_8904() - { - } - [Test] - public void Test_8905() - { - } - [Test] - public void Test_8906() - { - } - [Test] - public void Test_8907() - { - } - [Test] - public void Test_8908() - { - } - [Test] - public void Test_8909() - { - } - [Test] - public void Test_8910() - { - } - [Test] - public void Test_8911() - { - } - [Test] - public void Test_8912() - { - } - [Test] - public void Test_8913() - { - } - [Test] - public void Test_8914() - { - } - [Test] - public void Test_8915() - { - } - [Test] - public void Test_8916() - { - } - [Test] - public void Test_8917() - { - } - [Test] - public void Test_8918() - { - } - [Test] - public void Test_8919() - { - } - [Test] - public void Test_8920() - { - } - [Test] - public void Test_8921() - { - } - [Test] - public void Test_8922() - { - } - [Test] - public void Test_8923() - { - } - [Test] - public void Test_8924() - { - } - [Test] - public void Test_8925() - { - } - [Test] - public void Test_8926() - { - } - [Test] - public void Test_8927() - { - } - [Test] - public void Test_8928() - { - } - [Test] - public void Test_8929() - { - } - [Test] - public void Test_8930() - { - } - [Test] - public void Test_8931() - { - } - [Test] - public void Test_8932() - { - } - [Test] - public void Test_8933() - { - } - [Test] - public void Test_8934() - { - } - [Test] - public void Test_8935() - { - } - [Test] - public void Test_8936() - { - } - [Test] - public void Test_8937() - { - } - [Test] - public void Test_8938() - { - } - [Test] - public void Test_8939() - { - } - [Test] - public void Test_8940() - { - } - [Test] - public void Test_8941() - { - } - [Test] - public void Test_8942() - { - } - [Test] - public void Test_8943() - { - } - [Test] - public void Test_8944() - { - } - [Test] - public void Test_8945() - { - } - [Test] - public void Test_8946() - { - } - [Test] - public void Test_8947() - { - } - [Test] - public void Test_8948() - { - } - [Test] - public void Test_8949() - { - } - [Test] - public void Test_8950() - { - } - [Test] - public void Test_8951() - { - } - [Test] - public void Test_8952() - { - } - [Test] - public void Test_8953() - { - } - [Test] - public void Test_8954() - { - } - [Test] - public void Test_8955() - { - } - [Test] - public void Test_8956() - { - } - [Test] - public void Test_8957() - { - } - [Test] - public void Test_8958() - { - } - [Test] - public void Test_8959() - { - } - [Test] - public void Test_8960() - { - } - [Test] - public void Test_8961() - { - } - [Test] - public void Test_8962() - { - } - [Test] - public void Test_8963() - { - } - [Test] - public void Test_8964() - { - } - [Test] - public void Test_8965() - { - } - [Test] - public void Test_8966() - { - } - [Test] - public void Test_8967() - { - } - [Test] - public void Test_8968() - { - } - [Test] - public void Test_8969() - { - } - [Test] - public void Test_8970() - { - } - [Test] - public void Test_8971() - { - } - [Test] - public void Test_8972() - { - } - [Test] - public void Test_8973() - { - } - [Test] - public void Test_8974() - { - } - [Test] - public void Test_8975() - { - } - [Test] - public void Test_8976() - { - } - [Test] - public void Test_8977() - { - } - [Test] - public void Test_8978() - { - } - [Test] - public void Test_8979() - { - } - [Test] - public void Test_8980() - { - } - [Test] - public void Test_8981() - { - } - [Test] - public void Test_8982() - { - } - [Test] - public void Test_8983() - { - } - [Test] - public void Test_8984() - { - } - [Test] - public void Test_8985() - { - } - [Test] - public void Test_8986() - { - } - [Test] - public void Test_8987() - { - } - [Test] - public void Test_8988() - { - } - [Test] - public void Test_8989() - { - } - [Test] - public void Test_8990() - { - } - [Test] - public void Test_8991() - { - } - [Test] - public void Test_8992() - { - } - [Test] - public void Test_8993() - { - } - [Test] - public void Test_8994() - { - } - [Test] - public void Test_8995() - { - } - [Test] - public void Test_8996() - { - } - [Test] - public void Test_8997() - { - } - [Test] - public void Test_8998() - { - } - [Test] - public void Test_8999() - { - } - [Test] - public void Test_9000() - { - } - [Test] - public void Test_9001() - { - } - [Test] - public void Test_9002() - { - } - [Test] - public void Test_9003() - { - } - [Test] - public void Test_9004() - { - } - [Test] - public void Test_9005() - { - } - [Test] - public void Test_9006() - { - } - [Test] - public void Test_9007() - { - } - [Test] - public void Test_9008() - { - } - [Test] - public void Test_9009() - { - } - [Test] - public void Test_9010() - { - } - [Test] - public void Test_9011() - { - } - [Test] - public void Test_9012() - { - } - [Test] - public void Test_9013() - { - } - [Test] - public void Test_9014() - { - } - [Test] - public void Test_9015() - { - } - [Test] - public void Test_9016() - { - } - [Test] - public void Test_9017() - { - } - [Test] - public void Test_9018() - { - } - [Test] - public void Test_9019() - { - } - [Test] - public void Test_9020() - { - } - [Test] - public void Test_9021() - { - } - [Test] - public void Test_9022() - { - } - [Test] - public void Test_9023() - { - } - [Test] - public void Test_9024() - { - } - [Test] - public void Test_9025() - { - } - [Test] - public void Test_9026() - { - } - [Test] - public void Test_9027() - { - } - [Test] - public void Test_9028() - { - } - [Test] - public void Test_9029() - { - } - [Test] - public void Test_9030() - { - } - [Test] - public void Test_9031() - { - } - [Test] - public void Test_9032() - { - } - [Test] - public void Test_9033() - { - } - [Test] - public void Test_9034() - { - } - [Test] - public void Test_9035() - { - } - [Test] - public void Test_9036() - { - } - [Test] - public void Test_9037() - { - } - [Test] - public void Test_9038() - { - } - [Test] - public void Test_9039() - { - } - [Test] - public void Test_9040() - { - } - [Test] - public void Test_9041() - { - } - [Test] - public void Test_9042() - { - } - [Test] - public void Test_9043() - { - } - [Test] - public void Test_9044() - { - } - [Test] - public void Test_9045() - { - } - [Test] - public void Test_9046() - { - } - [Test] - public void Test_9047() - { - } - [Test] - public void Test_9048() - { - } - [Test] - public void Test_9049() - { - } - [Test] - public void Test_9050() - { - } - [Test] - public void Test_9051() - { - } - [Test] - public void Test_9052() - { - } - [Test] - public void Test_9053() - { - } - [Test] - public void Test_9054() - { - } - [Test] - public void Test_9055() - { - } - [Test] - public void Test_9056() - { - } - [Test] - public void Test_9057() - { - } - [Test] - public void Test_9058() - { - } - [Test] - public void Test_9059() - { - } - [Test] - public void Test_9060() - { - } - [Test] - public void Test_9061() - { - } - [Test] - public void Test_9062() - { - } - [Test] - public void Test_9063() - { - } - [Test] - public void Test_9064() - { - } - [Test] - public void Test_9065() - { - } - [Test] - public void Test_9066() - { - } - [Test] - public void Test_9067() - { - } - [Test] - public void Test_9068() - { - } - [Test] - public void Test_9069() - { - } - [Test] - public void Test_9070() - { - } - [Test] - public void Test_9071() - { - } - [Test] - public void Test_9072() - { - } - [Test] - public void Test_9073() - { - } - [Test] - public void Test_9074() - { - } - [Test] - public void Test_9075() - { - } - [Test] - public void Test_9076() - { - } - [Test] - public void Test_9077() - { - } - [Test] - public void Test_9078() - { - } - [Test] - public void Test_9079() - { - } - [Test] - public void Test_9080() - { - } - [Test] - public void Test_9081() - { - } - [Test] - public void Test_9082() - { - } - [Test] - public void Test_9083() - { - } - [Test] - public void Test_9084() - { - } - [Test] - public void Test_9085() - { - } - [Test] - public void Test_9086() - { - } - [Test] - public void Test_9087() - { - } - [Test] - public void Test_9088() - { - } - [Test] - public void Test_9089() - { - } - [Test] - public void Test_9090() - { - } - [Test] - public void Test_9091() - { - } - [Test] - public void Test_9092() - { - } - [Test] - public void Test_9093() - { - } - [Test] - public void Test_9094() - { - } - [Test] - public void Test_9095() - { - } - [Test] - public void Test_9096() - { - } - [Test] - public void Test_9097() - { - } - [Test] - public void Test_9098() - { - } - [Test] - public void Test_9099() - { - } - [Test] - public void Test_9100() - { - } - [Test] - public void Test_9101() - { - } - [Test] - public void Test_9102() - { - } - [Test] - public void Test_9103() - { - } - [Test] - public void Test_9104() - { - } - [Test] - public void Test_9105() - { - } - [Test] - public void Test_9106() - { - } - [Test] - public void Test_9107() - { - } - [Test] - public void Test_9108() - { - } - [Test] - public void Test_9109() - { - } - [Test] - public void Test_9110() - { - } - [Test] - public void Test_9111() - { - } - [Test] - public void Test_9112() - { - } - [Test] - public void Test_9113() - { - } - [Test] - public void Test_9114() - { - } - [Test] - public void Test_9115() - { - } - [Test] - public void Test_9116() - { - } - [Test] - public void Test_9117() - { - } - [Test] - public void Test_9118() - { - } - [Test] - public void Test_9119() - { - } - [Test] - public void Test_9120() - { - } - [Test] - public void Test_9121() - { - } - [Test] - public void Test_9122() - { - } - [Test] - public void Test_9123() - { - } - [Test] - public void Test_9124() - { - } - [Test] - public void Test_9125() - { - } - [Test] - public void Test_9126() - { - } - [Test] - public void Test_9127() - { - } - [Test] - public void Test_9128() - { - } - [Test] - public void Test_9129() - { - } - [Test] - public void Test_9130() - { - } - [Test] - public void Test_9131() - { - } - [Test] - public void Test_9132() - { - } - [Test] - public void Test_9133() - { - } - [Test] - public void Test_9134() - { - } - [Test] - public void Test_9135() - { - } - [Test] - public void Test_9136() - { - } - [Test] - public void Test_9137() - { - } - [Test] - public void Test_9138() - { - } - [Test] - public void Test_9139() - { - } - [Test] - public void Test_9140() - { - } - [Test] - public void Test_9141() - { - } - [Test] - public void Test_9142() - { - } - [Test] - public void Test_9143() - { - } - [Test] - public void Test_9144() - { - } - [Test] - public void Test_9145() - { - } - [Test] - public void Test_9146() - { - } - [Test] - public void Test_9147() - { - } - [Test] - public void Test_9148() - { - } - [Test] - public void Test_9149() - { - } - [Test] - public void Test_9150() - { - } - [Test] - public void Test_9151() - { - } - [Test] - public void Test_9152() - { - } - [Test] - public void Test_9153() - { - } - [Test] - public void Test_9154() - { - } - [Test] - public void Test_9155() - { - } - [Test] - public void Test_9156() - { - } - [Test] - public void Test_9157() - { - } - [Test] - public void Test_9158() - { - } - [Test] - public void Test_9159() - { - } - [Test] - public void Test_9160() - { - } - [Test] - public void Test_9161() - { - } - [Test] - public void Test_9162() - { - } - [Test] - public void Test_9163() - { - } - [Test] - public void Test_9164() - { - } - [Test] - public void Test_9165() - { - } - [Test] - public void Test_9166() - { - } - [Test] - public void Test_9167() - { - } - [Test] - public void Test_9168() - { - } - [Test] - public void Test_9169() - { - } - [Test] - public void Test_9170() - { - } - [Test] - public void Test_9171() - { - } - [Test] - public void Test_9172() - { - } - [Test] - public void Test_9173() - { - } - [Test] - public void Test_9174() - { - } - [Test] - public void Test_9175() - { - } - [Test] - public void Test_9176() - { - } - [Test] - public void Test_9177() - { - } - [Test] - public void Test_9178() - { - } - [Test] - public void Test_9179() - { - } - [Test] - public void Test_9180() - { - } - [Test] - public void Test_9181() - { - } - [Test] - public void Test_9182() - { - } - [Test] - public void Test_9183() - { - } - [Test] - public void Test_9184() - { - } - [Test] - public void Test_9185() - { - } - [Test] - public void Test_9186() - { - } - [Test] - public void Test_9187() - { - } - [Test] - public void Test_9188() - { - } - [Test] - public void Test_9189() - { - } - [Test] - public void Test_9190() - { - } - [Test] - public void Test_9191() - { - } - [Test] - public void Test_9192() - { - } - [Test] - public void Test_9193() - { - } - [Test] - public void Test_9194() - { - } - [Test] - public void Test_9195() - { - } - [Test] - public void Test_9196() - { - } - [Test] - public void Test_9197() - { - } - [Test] - public void Test_9198() - { - } - [Test] - public void Test_9199() - { - } - [Test] - public void Test_9200() - { - } - [Test] - public void Test_9201() - { - } - [Test] - public void Test_9202() - { - } - [Test] - public void Test_9203() - { - } - [Test] - public void Test_9204() - { - } - [Test] - public void Test_9205() - { - } - [Test] - public void Test_9206() - { - } - [Test] - public void Test_9207() - { - } - [Test] - public void Test_9208() - { - } - [Test] - public void Test_9209() - { - } - [Test] - public void Test_9210() - { - } - [Test] - public void Test_9211() - { - } - [Test] - public void Test_9212() - { - } - [Test] - public void Test_9213() - { - } - [Test] - public void Test_9214() - { - } - [Test] - public void Test_9215() - { - } - [Test] - public void Test_9216() - { - } - [Test] - public void Test_9217() - { - } - [Test] - public void Test_9218() - { - } - [Test] - public void Test_9219() - { - } - [Test] - public void Test_9220() - { - } - [Test] - public void Test_9221() - { - } - [Test] - public void Test_9222() - { - } - [Test] - public void Test_9223() - { - } - [Test] - public void Test_9224() - { - } - [Test] - public void Test_9225() - { - } - [Test] - public void Test_9226() - { - } - [Test] - public void Test_9227() - { - } - [Test] - public void Test_9228() - { - } - [Test] - public void Test_9229() - { - } - [Test] - public void Test_9230() - { - } - [Test] - public void Test_9231() - { - } - [Test] - public void Test_9232() - { - } - [Test] - public void Test_9233() - { - } - [Test] - public void Test_9234() - { - } - [Test] - public void Test_9235() - { - } - [Test] - public void Test_9236() - { - } - [Test] - public void Test_9237() - { - } - [Test] - public void Test_9238() - { - } - [Test] - public void Test_9239() - { - } - [Test] - public void Test_9240() - { - } - [Test] - public void Test_9241() - { - } - [Test] - public void Test_9242() - { - } - [Test] - public void Test_9243() - { - } - [Test] - public void Test_9244() - { - } - [Test] - public void Test_9245() - { - } - [Test] - public void Test_9246() - { - } - [Test] - public void Test_9247() - { - } - [Test] - public void Test_9248() - { - } - [Test] - public void Test_9249() - { - } - [Test] - public void Test_9250() - { - } - [Test] - public void Test_9251() - { - } - [Test] - public void Test_9252() - { - } - [Test] - public void Test_9253() - { - } - [Test] - public void Test_9254() - { - } - [Test] - public void Test_9255() - { - } - [Test] - public void Test_9256() - { - } - [Test] - public void Test_9257() - { - } - [Test] - public void Test_9258() - { - } - [Test] - public void Test_9259() - { - } - [Test] - public void Test_9260() - { - } - [Test] - public void Test_9261() - { - } - [Test] - public void Test_9262() - { - } - [Test] - public void Test_9263() - { - } - [Test] - public void Test_9264() - { - } - [Test] - public void Test_9265() - { - } - [Test] - public void Test_9266() - { - } - [Test] - public void Test_9267() - { - } - [Test] - public void Test_9268() - { - } - [Test] - public void Test_9269() - { - } - [Test] - public void Test_9270() - { - } - [Test] - public void Test_9271() - { - } - [Test] - public void Test_9272() - { - } - [Test] - public void Test_9273() - { - } - [Test] - public void Test_9274() - { - } - [Test] - public void Test_9275() - { - } - [Test] - public void Test_9276() - { - } - [Test] - public void Test_9277() - { - } - [Test] - public void Test_9278() - { - } - [Test] - public void Test_9279() - { - } - [Test] - public void Test_9280() - { - } - [Test] - public void Test_9281() - { - } - [Test] - public void Test_9282() - { - } - [Test] - public void Test_9283() - { - } - [Test] - public void Test_9284() - { - } - [Test] - public void Test_9285() - { - } - [Test] - public void Test_9286() - { - } - [Test] - public void Test_9287() - { - } - [Test] - public void Test_9288() - { - } - [Test] - public void Test_9289() - { - } - [Test] - public void Test_9290() - { - } - [Test] - public void Test_9291() - { - } - [Test] - public void Test_9292() - { - } - [Test] - public void Test_9293() - { - } - [Test] - public void Test_9294() - { - } - [Test] - public void Test_9295() - { - } - [Test] - public void Test_9296() - { - } - [Test] - public void Test_9297() - { - } - [Test] - public void Test_9298() - { - } - [Test] - public void Test_9299() - { - } - [Test] - public void Test_9300() - { - } - [Test] - public void Test_9301() - { - } - [Test] - public void Test_9302() - { - } - [Test] - public void Test_9303() - { - } - [Test] - public void Test_9304() - { - } - [Test] - public void Test_9305() - { - } - [Test] - public void Test_9306() - { - } - [Test] - public void Test_9307() - { - } - [Test] - public void Test_9308() - { - } - [Test] - public void Test_9309() - { - } - [Test] - public void Test_9310() - { - } - [Test] - public void Test_9311() - { - } - [Test] - public void Test_9312() - { - } - [Test] - public void Test_9313() - { - } - [Test] - public void Test_9314() - { - } - [Test] - public void Test_9315() - { - } - [Test] - public void Test_9316() - { - } - [Test] - public void Test_9317() - { - } - [Test] - public void Test_9318() - { - } - [Test] - public void Test_9319() - { - } - [Test] - public void Test_9320() - { - } - [Test] - public void Test_9321() - { - } - [Test] - public void Test_9322() - { - } - [Test] - public void Test_9323() - { - } - [Test] - public void Test_9324() - { - } - [Test] - public void Test_9325() - { - } - [Test] - public void Test_9326() - { - } - [Test] - public void Test_9327() - { - } - [Test] - public void Test_9328() - { - } - [Test] - public void Test_9329() - { - } - [Test] - public void Test_9330() - { - } - [Test] - public void Test_9331() - { - } - [Test] - public void Test_9332() - { - } - [Test] - public void Test_9333() - { - } - [Test] - public void Test_9334() - { - } - [Test] - public void Test_9335() - { - } - [Test] - public void Test_9336() - { - } - [Test] - public void Test_9337() - { - } - [Test] - public void Test_9338() - { - } - [Test] - public void Test_9339() - { - } - [Test] - public void Test_9340() - { - } - [Test] - public void Test_9341() - { - } - [Test] - public void Test_9342() - { - } - [Test] - public void Test_9343() - { - } - [Test] - public void Test_9344() - { - } - [Test] - public void Test_9345() - { - } - [Test] - public void Test_9346() - { - } - [Test] - public void Test_9347() - { - } - [Test] - public void Test_9348() - { - } - [Test] - public void Test_9349() - { - } - [Test] - public void Test_9350() - { - } - [Test] - public void Test_9351() - { - } - [Test] - public void Test_9352() - { - } - [Test] - public void Test_9353() - { - } - [Test] - public void Test_9354() - { - } - [Test] - public void Test_9355() - { - } - [Test] - public void Test_9356() - { - } - [Test] - public void Test_9357() - { - } - [Test] - public void Test_9358() - { - } - [Test] - public void Test_9359() - { - } - [Test] - public void Test_9360() - { - } - [Test] - public void Test_9361() - { - } - [Test] - public void Test_9362() - { - } - [Test] - public void Test_9363() - { - } - [Test] - public void Test_9364() - { - } - [Test] - public void Test_9365() - { - } - [Test] - public void Test_9366() - { - } - [Test] - public void Test_9367() - { - } - [Test] - public void Test_9368() - { - } - [Test] - public void Test_9369() - { - } - [Test] - public void Test_9370() - { - } - [Test] - public void Test_9371() - { - } - [Test] - public void Test_9372() - { - } - [Test] - public void Test_9373() - { - } - [Test] - public void Test_9374() - { - } - [Test] - public void Test_9375() - { - } - [Test] - public void Test_9376() - { - } - [Test] - public void Test_9377() - { - } - [Test] - public void Test_9378() - { - } - [Test] - public void Test_9379() - { - } - [Test] - public void Test_9380() - { - } - [Test] - public void Test_9381() - { - } - [Test] - public void Test_9382() - { - } - [Test] - public void Test_9383() - { - } - [Test] - public void Test_9384() - { - } - [Test] - public void Test_9385() - { - } - [Test] - public void Test_9386() - { - } - [Test] - public void Test_9387() - { - } - [Test] - public void Test_9388() - { - } - [Test] - public void Test_9389() - { - } - [Test] - public void Test_9390() - { - } - [Test] - public void Test_9391() - { - } - [Test] - public void Test_9392() - { - } - [Test] - public void Test_9393() - { - } - [Test] - public void Test_9394() - { - } - [Test] - public void Test_9395() - { - } - [Test] - public void Test_9396() - { - } - [Test] - public void Test_9397() - { - } - [Test] - public void Test_9398() - { - } - [Test] - public void Test_9399() - { - } - [Test] - public void Test_9400() - { - } - [Test] - public void Test_9401() - { - } - [Test] - public void Test_9402() - { - } - [Test] - public void Test_9403() - { - } - [Test] - public void Test_9404() - { - } - [Test] - public void Test_9405() - { - } - [Test] - public void Test_9406() - { - } - [Test] - public void Test_9407() - { - } - [Test] - public void Test_9408() - { - } - [Test] - public void Test_9409() - { - } - [Test] - public void Test_9410() - { - } - [Test] - public void Test_9411() - { - } - [Test] - public void Test_9412() - { - } - [Test] - public void Test_9413() - { - } - [Test] - public void Test_9414() - { - } - [Test] - public void Test_9415() - { - } - [Test] - public void Test_9416() - { - } - [Test] - public void Test_9417() - { - } - [Test] - public void Test_9418() - { - } - [Test] - public void Test_9419() - { - } - [Test] - public void Test_9420() - { - } - [Test] - public void Test_9421() - { - } - [Test] - public void Test_9422() - { - } - [Test] - public void Test_9423() - { - } - [Test] - public void Test_9424() - { - } - [Test] - public void Test_9425() - { - } - [Test] - public void Test_9426() - { - } - [Test] - public void Test_9427() - { - } - [Test] - public void Test_9428() - { - } - [Test] - public void Test_9429() - { - } - [Test] - public void Test_9430() - { - } - [Test] - public void Test_9431() - { - } - [Test] - public void Test_9432() - { - } - [Test] - public void Test_9433() - { - } - [Test] - public void Test_9434() - { - } - [Test] - public void Test_9435() - { - } - [Test] - public void Test_9436() - { - } - [Test] - public void Test_9437() - { - } - [Test] - public void Test_9438() - { - } - [Test] - public void Test_9439() - { - } - [Test] - public void Test_9440() - { - } - [Test] - public void Test_9441() - { - } - [Test] - public void Test_9442() - { - } - [Test] - public void Test_9443() - { - } - [Test] - public void Test_9444() - { - } - [Test] - public void Test_9445() - { - } - [Test] - public void Test_9446() - { - } - [Test] - public void Test_9447() - { - } - [Test] - public void Test_9448() - { - } - [Test] - public void Test_9449() - { - } - [Test] - public void Test_9450() - { - } - [Test] - public void Test_9451() - { - } - [Test] - public void Test_9452() - { - } - [Test] - public void Test_9453() - { - } - [Test] - public void Test_9454() - { - } - [Test] - public void Test_9455() - { - } - [Test] - public void Test_9456() - { - } - [Test] - public void Test_9457() - { - } - [Test] - public void Test_9458() - { - } - [Test] - public void Test_9459() - { - } - [Test] - public void Test_9460() - { - } - [Test] - public void Test_9461() - { - } - [Test] - public void Test_9462() - { - } - [Test] - public void Test_9463() - { - } - [Test] - public void Test_9464() - { - } - [Test] - public void Test_9465() - { - } - [Test] - public void Test_9466() - { - } - [Test] - public void Test_9467() - { - } - [Test] - public void Test_9468() - { - } - [Test] - public void Test_9469() - { - } - [Test] - public void Test_9470() - { - } - [Test] - public void Test_9471() - { - } - [Test] - public void Test_9472() - { - } - [Test] - public void Test_9473() - { - } - [Test] - public void Test_9474() - { - } - [Test] - public void Test_9475() - { - } - [Test] - public void Test_9476() - { - } - [Test] - public void Test_9477() - { - } - [Test] - public void Test_9478() - { - } - [Test] - public void Test_9479() - { - } - [Test] - public void Test_9480() - { - } - [Test] - public void Test_9481() - { - } - [Test] - public void Test_9482() - { - } - [Test] - public void Test_9483() - { - } - [Test] - public void Test_9484() - { - } - [Test] - public void Test_9485() - { - } - [Test] - public void Test_9486() - { - } - [Test] - public void Test_9487() - { - } - [Test] - public void Test_9488() - { - } - [Test] - public void Test_9489() - { - } - [Test] - public void Test_9490() - { - } - [Test] - public void Test_9491() - { - } - [Test] - public void Test_9492() - { - } - [Test] - public void Test_9493() - { - } - [Test] - public void Test_9494() - { - } - [Test] - public void Test_9495() - { - } - [Test] - public void Test_9496() - { - } - [Test] - public void Test_9497() - { - } - [Test] - public void Test_9498() - { - } - [Test] - public void Test_9499() - { - } - [Test] - public void Test_9500() - { - } - [Test] - public void Test_9501() - { - } - [Test] - public void Test_9502() - { - } - [Test] - public void Test_9503() - { - } - [Test] - public void Test_9504() - { - } - [Test] - public void Test_9505() - { - } - [Test] - public void Test_9506() - { - } - [Test] - public void Test_9507() - { - } - [Test] - public void Test_9508() - { - } - [Test] - public void Test_9509() - { - } - [Test] - public void Test_9510() - { - } - [Test] - public void Test_9511() - { - } - [Test] - public void Test_9512() - { - } - [Test] - public void Test_9513() - { - } - [Test] - public void Test_9514() - { - } - [Test] - public void Test_9515() - { - } - [Test] - public void Test_9516() - { - } - [Test] - public void Test_9517() - { - } - [Test] - public void Test_9518() - { - } - [Test] - public void Test_9519() - { - } - [Test] - public void Test_9520() - { - } - [Test] - public void Test_9521() - { - } - [Test] - public void Test_9522() - { - } - [Test] - public void Test_9523() - { - } - [Test] - public void Test_9524() - { - } - [Test] - public void Test_9525() - { - } - [Test] - public void Test_9526() - { - } - [Test] - public void Test_9527() - { - } - [Test] - public void Test_9528() - { - } - [Test] - public void Test_9529() - { - } - [Test] - public void Test_9530() - { - } - [Test] - public void Test_9531() - { - } - [Test] - public void Test_9532() - { - } - [Test] - public void Test_9533() - { - } - [Test] - public void Test_9534() - { - } - [Test] - public void Test_9535() - { - } - [Test] - public void Test_9536() - { - } - [Test] - public void Test_9537() - { - } - [Test] - public void Test_9538() - { - } - [Test] - public void Test_9539() - { - } - [Test] - public void Test_9540() - { - } - [Test] - public void Test_9541() - { - } - [Test] - public void Test_9542() - { - } - [Test] - public void Test_9543() - { - } - [Test] - public void Test_9544() - { - } - [Test] - public void Test_9545() - { - } - [Test] - public void Test_9546() - { - } - [Test] - public void Test_9547() - { - } - [Test] - public void Test_9548() - { - } - [Test] - public void Test_9549() - { - } - [Test] - public void Test_9550() - { - } - [Test] - public void Test_9551() - { - } - [Test] - public void Test_9552() - { - } - [Test] - public void Test_9553() - { - } - [Test] - public void Test_9554() - { - } - [Test] - public void Test_9555() - { - } - [Test] - public void Test_9556() - { - } - [Test] - public void Test_9557() - { - } - [Test] - public void Test_9558() - { - } - [Test] - public void Test_9559() - { - } - [Test] - public void Test_9560() - { - } - [Test] - public void Test_9561() - { - } - [Test] - public void Test_9562() - { - } - [Test] - public void Test_9563() - { - } - [Test] - public void Test_9564() - { - } - [Test] - public void Test_9565() - { - } - [Test] - public void Test_9566() - { - } - [Test] - public void Test_9567() - { - } - [Test] - public void Test_9568() - { - } - [Test] - public void Test_9569() - { - } - [Test] - public void Test_9570() - { - } - [Test] - public void Test_9571() - { - } - [Test] - public void Test_9572() - { - } - [Test] - public void Test_9573() - { - } - [Test] - public void Test_9574() - { - } - [Test] - public void Test_9575() - { - } - [Test] - public void Test_9576() - { - } - [Test] - public void Test_9577() - { - } - [Test] - public void Test_9578() - { - } - [Test] - public void Test_9579() - { - } - [Test] - public void Test_9580() - { - } - [Test] - public void Test_9581() - { - } - [Test] - public void Test_9582() - { - } - [Test] - public void Test_9583() - { - } - [Test] - public void Test_9584() - { - } - [Test] - public void Test_9585() - { - } - [Test] - public void Test_9586() - { - } - [Test] - public void Test_9587() - { - } - [Test] - public void Test_9588() - { - } - [Test] - public void Test_9589() - { - } - [Test] - public void Test_9590() - { - } - [Test] - public void Test_9591() - { - } - [Test] - public void Test_9592() - { - } - [Test] - public void Test_9593() - { - } - [Test] - public void Test_9594() - { - } - [Test] - public void Test_9595() - { - } - [Test] - public void Test_9596() - { - } - [Test] - public void Test_9597() - { - } - [Test] - public void Test_9598() - { - } - [Test] - public void Test_9599() - { - } - [Test] - public void Test_9600() - { - } - [Test] - public void Test_9601() - { - } - [Test] - public void Test_9602() - { - } - [Test] - public void Test_9603() - { - } - [Test] - public void Test_9604() - { - } - [Test] - public void Test_9605() - { - } - [Test] - public void Test_9606() - { - } - [Test] - public void Test_9607() - { - } - [Test] - public void Test_9608() - { - } - [Test] - public void Test_9609() - { - } - [Test] - public void Test_9610() - { - } - [Test] - public void Test_9611() - { - } - [Test] - public void Test_9612() - { - } - [Test] - public void Test_9613() - { - } - [Test] - public void Test_9614() - { - } - [Test] - public void Test_9615() - { - } - [Test] - public void Test_9616() - { - } - [Test] - public void Test_9617() - { - } - [Test] - public void Test_9618() - { - } - [Test] - public void Test_9619() - { - } - [Test] - public void Test_9620() - { - } - [Test] - public void Test_9621() - { - } - [Test] - public void Test_9622() - { - } - [Test] - public void Test_9623() - { - } - [Test] - public void Test_9624() - { - } - [Test] - public void Test_9625() - { - } - [Test] - public void Test_9626() - { - } - [Test] - public void Test_9627() - { - } - [Test] - public void Test_9628() - { - } - [Test] - public void Test_9629() - { - } - [Test] - public void Test_9630() - { - } - [Test] - public void Test_9631() - { - } - [Test] - public void Test_9632() - { - } - [Test] - public void Test_9633() - { - } - [Test] - public void Test_9634() - { - } - [Test] - public void Test_9635() - { - } - [Test] - public void Test_9636() - { - } - [Test] - public void Test_9637() - { - } - [Test] - public void Test_9638() - { - } - [Test] - public void Test_9639() - { - } - [Test] - public void Test_9640() - { - } - [Test] - public void Test_9641() - { - } - [Test] - public void Test_9642() - { - } - [Test] - public void Test_9643() - { - } - [Test] - public void Test_9644() - { - } - [Test] - public void Test_9645() - { - } - [Test] - public void Test_9646() - { - } - [Test] - public void Test_9647() - { - } - [Test] - public void Test_9648() - { - } - [Test] - public void Test_9649() - { - } - [Test] - public void Test_9650() - { - } - [Test] - public void Test_9651() - { - } - [Test] - public void Test_9652() - { - } - [Test] - public void Test_9653() - { - } - [Test] - public void Test_9654() - { - } - [Test] - public void Test_9655() - { - } - [Test] - public void Test_9656() - { - } - [Test] - public void Test_9657() - { - } - [Test] - public void Test_9658() - { - } - [Test] - public void Test_9659() - { - } - [Test] - public void Test_9660() - { - } - [Test] - public void Test_9661() - { - } - [Test] - public void Test_9662() - { - } - [Test] - public void Test_9663() - { - } - [Test] - public void Test_9664() - { - } - [Test] - public void Test_9665() - { - } - [Test] - public void Test_9666() - { - } - [Test] - public void Test_9667() - { - } - [Test] - public void Test_9668() - { - } - [Test] - public void Test_9669() - { - } - [Test] - public void Test_9670() - { - } - [Test] - public void Test_9671() - { - } - [Test] - public void Test_9672() - { - } - [Test] - public void Test_9673() - { - } - [Test] - public void Test_9674() - { - } - [Test] - public void Test_9675() - { - } - [Test] - public void Test_9676() - { - } - [Test] - public void Test_9677() - { - } - [Test] - public void Test_9678() - { - } - [Test] - public void Test_9679() - { - } - [Test] - public void Test_9680() - { - } - [Test] - public void Test_9681() - { - } - [Test] - public void Test_9682() - { - } - [Test] - public void Test_9683() - { - } - [Test] - public void Test_9684() - { - } - [Test] - public void Test_9685() - { - } - [Test] - public void Test_9686() - { - } - [Test] - public void Test_9687() - { - } - [Test] - public void Test_9688() - { - } - [Test] - public void Test_9689() - { - } - [Test] - public void Test_9690() - { - } - [Test] - public void Test_9691() - { - } - [Test] - public void Test_9692() - { - } - [Test] - public void Test_9693() - { - } - [Test] - public void Test_9694() - { - } - [Test] - public void Test_9695() - { - } - [Test] - public void Test_9696() - { - } - [Test] - public void Test_9697() - { - } - [Test] - public void Test_9698() - { - } - [Test] - public void Test_9699() - { - } - [Test] - public void Test_9700() - { - } - [Test] - public void Test_9701() - { - } - [Test] - public void Test_9702() - { - } - [Test] - public void Test_9703() - { - } - [Test] - public void Test_9704() - { - } - [Test] - public void Test_9705() - { - } - [Test] - public void Test_9706() - { - } - [Test] - public void Test_9707() - { - } - [Test] - public void Test_9708() - { - } - [Test] - public void Test_9709() - { - } - [Test] - public void Test_9710() - { - } - [Test] - public void Test_9711() - { - } - [Test] - public void Test_9712() - { - } - [Test] - public void Test_9713() - { - } - [Test] - public void Test_9714() - { - } - [Test] - public void Test_9715() - { - } - [Test] - public void Test_9716() - { - } - [Test] - public void Test_9717() - { - } - [Test] - public void Test_9718() - { - } - [Test] - public void Test_9719() - { - } - [Test] - public void Test_9720() - { - } - [Test] - public void Test_9721() - { - } - [Test] - public void Test_9722() - { - } - [Test] - public void Test_9723() - { - } - [Test] - public void Test_9724() - { - } - [Test] - public void Test_9725() - { - } - [Test] - public void Test_9726() - { - } - [Test] - public void Test_9727() - { - } - [Test] - public void Test_9728() - { - } - [Test] - public void Test_9729() - { - } - [Test] - public void Test_9730() - { - } - [Test] - public void Test_9731() - { - } - [Test] - public void Test_9732() - { - } - [Test] - public void Test_9733() - { - } - [Test] - public void Test_9734() - { - } - [Test] - public void Test_9735() - { - } - [Test] - public void Test_9736() - { - } - [Test] - public void Test_9737() - { - } - [Test] - public void Test_9738() - { - } - [Test] - public void Test_9739() - { - } - [Test] - public void Test_9740() - { - } - [Test] - public void Test_9741() - { - } - [Test] - public void Test_9742() - { - } - [Test] - public void Test_9743() - { - } - [Test] - public void Test_9744() - { - } - [Test] - public void Test_9745() - { - } - [Test] - public void Test_9746() - { - } - [Test] - public void Test_9747() - { - } - [Test] - public void Test_9748() - { - } - [Test] - public void Test_9749() - { - } - [Test] - public void Test_9750() - { - } - [Test] - public void Test_9751() - { - } - [Test] - public void Test_9752() - { - } - [Test] - public void Test_9753() - { - } - [Test] - public void Test_9754() - { - } - [Test] - public void Test_9755() - { - } - [Test] - public void Test_9756() - { - } - [Test] - public void Test_9757() - { - } - [Test] - public void Test_9758() - { - } - [Test] - public void Test_9759() - { - } - [Test] - public void Test_9760() - { - } - [Test] - public void Test_9761() - { - } - [Test] - public void Test_9762() - { - } - [Test] - public void Test_9763() - { - } - [Test] - public void Test_9764() - { - } - [Test] - public void Test_9765() - { - } - [Test] - public void Test_9766() - { - } - [Test] - public void Test_9767() - { - } - [Test] - public void Test_9768() - { - } - [Test] - public void Test_9769() - { - } - [Test] - public void Test_9770() - { - } - [Test] - public void Test_9771() - { - } - [Test] - public void Test_9772() - { - } - [Test] - public void Test_9773() - { - } - [Test] - public void Test_9774() - { - } - [Test] - public void Test_9775() - { - } - [Test] - public void Test_9776() - { - } - [Test] - public void Test_9777() - { - } - [Test] - public void Test_9778() - { - } - [Test] - public void Test_9779() - { - } - [Test] - public void Test_9780() - { - } - [Test] - public void Test_9781() - { - } - [Test] - public void Test_9782() - { - } - [Test] - public void Test_9783() - { - } - [Test] - public void Test_9784() - { - } - [Test] - public void Test_9785() - { - } - [Test] - public void Test_9786() - { - } - [Test] - public void Test_9787() - { - } - [Test] - public void Test_9788() - { - } - [Test] - public void Test_9789() - { - } - [Test] - public void Test_9790() - { - } - [Test] - public void Test_9791() - { - } - [Test] - public void Test_9792() - { - } - [Test] - public void Test_9793() - { - } - [Test] - public void Test_9794() - { - } - [Test] - public void Test_9795() - { - } - [Test] - public void Test_9796() - { - } - [Test] - public void Test_9797() - { - } - [Test] - public void Test_9798() - { - } - [Test] - public void Test_9799() - { - } - [Test] - public void Test_9800() - { - } - [Test] - public void Test_9801() - { - } - [Test] - public void Test_9802() - { - } - [Test] - public void Test_9803() - { - } - [Test] - public void Test_9804() - { - } - [Test] - public void Test_9805() - { - } - [Test] - public void Test_9806() - { - } - [Test] - public void Test_9807() - { - } - [Test] - public void Test_9808() - { - } - [Test] - public void Test_9809() - { - } - [Test] - public void Test_9810() - { - } - [Test] - public void Test_9811() - { - } - [Test] - public void Test_9812() - { - } - [Test] - public void Test_9813() - { - } - [Test] - public void Test_9814() - { - } - [Test] - public void Test_9815() - { - } - [Test] - public void Test_9816() - { - } - [Test] - public void Test_9817() - { - } - [Test] - public void Test_9818() - { - } - [Test] - public void Test_9819() - { - } - [Test] - public void Test_9820() - { - } - [Test] - public void Test_9821() - { - } - [Test] - public void Test_9822() - { - } - [Test] - public void Test_9823() - { - } - [Test] - public void Test_9824() - { - } - [Test] - public void Test_9825() - { - } - [Test] - public void Test_9826() - { - } - [Test] - public void Test_9827() - { - } - [Test] - public void Test_9828() - { - } - [Test] - public void Test_9829() - { - } - [Test] - public void Test_9830() - { - } - [Test] - public void Test_9831() - { - } - [Test] - public void Test_9832() - { - } - [Test] - public void Test_9833() - { - } - [Test] - public void Test_9834() - { - } - [Test] - public void Test_9835() - { - } - [Test] - public void Test_9836() - { - } - [Test] - public void Test_9837() - { - } - [Test] - public void Test_9838() - { - } - [Test] - public void Test_9839() - { - } - [Test] - public void Test_9840() - { - } - [Test] - public void Test_9841() - { - } - [Test] - public void Test_9842() - { - } - [Test] - public void Test_9843() - { - } - [Test] - public void Test_9844() - { - } - [Test] - public void Test_9845() - { - } - [Test] - public void Test_9846() - { - } - [Test] - public void Test_9847() - { - } - [Test] - public void Test_9848() - { - } - [Test] - public void Test_9849() - { - } - [Test] - public void Test_9850() - { - } - [Test] - public void Test_9851() - { - } - [Test] - public void Test_9852() - { - } - [Test] - public void Test_9853() - { - } - [Test] - public void Test_9854() - { - } - [Test] - public void Test_9855() - { - } - [Test] - public void Test_9856() - { - } - [Test] - public void Test_9857() - { - } - [Test] - public void Test_9858() - { - } - [Test] - public void Test_9859() - { - } - [Test] - public void Test_9860() - { - } - [Test] - public void Test_9861() - { - } - [Test] - public void Test_9862() - { - } - [Test] - public void Test_9863() - { - } - [Test] - public void Test_9864() - { - } - [Test] - public void Test_9865() - { - } - [Test] - public void Test_9866() - { - } - [Test] - public void Test_9867() - { - } - [Test] - public void Test_9868() - { - } - [Test] - public void Test_9869() - { - } - [Test] - public void Test_9870() - { - } - [Test] - public void Test_9871() - { - } - [Test] - public void Test_9872() - { - } - [Test] - public void Test_9873() - { - } - [Test] - public void Test_9874() - { - } - [Test] - public void Test_9875() - { - } - [Test] - public void Test_9876() - { - } - [Test] - public void Test_9877() - { - } - [Test] - public void Test_9878() - { - } - [Test] - public void Test_9879() - { - } - [Test] - public void Test_9880() - { - } - [Test] - public void Test_9881() - { - } - [Test] - public void Test_9882() - { - } - [Test] - public void Test_9883() - { - } - [Test] - public void Test_9884() - { - } - [Test] - public void Test_9885() - { - } - [Test] - public void Test_9886() - { - } - [Test] - public void Test_9887() - { - } - [Test] - public void Test_9888() - { - } - [Test] - public void Test_9889() - { - } - [Test] - public void Test_9890() - { - } - [Test] - public void Test_9891() - { - } - [Test] - public void Test_9892() - { - } - [Test] - public void Test_9893() - { - } - [Test] - public void Test_9894() - { - } - [Test] - public void Test_9895() - { - } - [Test] - public void Test_9896() - { - } - [Test] - public void Test_9897() - { - } - [Test] - public void Test_9898() - { - } - [Test] - public void Test_9899() - { - } - [Test] - public void Test_9900() - { - } - [Test] - public void Test_9901() - { - } - [Test] - public void Test_9902() - { - } - [Test] - public void Test_9903() - { - } - [Test] - public void Test_9904() - { - } - [Test] - public void Test_9905() - { - } - [Test] - public void Test_9906() - { - } - [Test] - public void Test_9907() - { - } - [Test] - public void Test_9908() - { - } - [Test] - public void Test_9909() - { - } - [Test] - public void Test_9910() - { - } - [Test] - public void Test_9911() - { - } - [Test] - public void Test_9912() - { - } - [Test] - public void Test_9913() - { - } - [Test] - public void Test_9914() - { - } - [Test] - public void Test_9915() - { - } - [Test] - public void Test_9916() - { - } - [Test] - public void Test_9917() - { - } - [Test] - public void Test_9918() - { - } - [Test] - public void Test_9919() - { - } - [Test] - public void Test_9920() - { - } - [Test] - public void Test_9921() - { - } - [Test] - public void Test_9922() - { - } - [Test] - public void Test_9923() - { - } - [Test] - public void Test_9924() - { - } - [Test] - public void Test_9925() - { - } - [Test] - public void Test_9926() - { - } - [Test] - public void Test_9927() - { - } - [Test] - public void Test_9928() - { - } - [Test] - public void Test_9929() - { - } - [Test] - public void Test_9930() - { - } - [Test] - public void Test_9931() - { - } - [Test] - public void Test_9932() - { - } - [Test] - public void Test_9933() - { - } - [Test] - public void Test_9934() - { - } - [Test] - public void Test_9935() - { - } - [Test] - public void Test_9936() - { - } - [Test] - public void Test_9937() - { - } - [Test] - public void Test_9938() - { - } - [Test] - public void Test_9939() - { - } - [Test] - public void Test_9940() - { - } - [Test] - public void Test_9941() - { - } - [Test] - public void Test_9942() - { - } - [Test] - public void Test_9943() - { - } - [Test] - public void Test_9944() - { - } - [Test] - public void Test_9945() - { - } - [Test] - public void Test_9946() - { - } - [Test] - public void Test_9947() - { - } - [Test] - public void Test_9948() - { - } - [Test] - public void Test_9949() - { - } - [Test] - public void Test_9950() - { - } - [Test] - public void Test_9951() - { - } - [Test] - public void Test_9952() - { - } - [Test] - public void Test_9953() - { - } - [Test] - public void Test_9954() - { - } - [Test] - public void Test_9955() - { - } - [Test] - public void Test_9956() - { - } - [Test] - public void Test_9957() - { - } - [Test] - public void Test_9958() - { - } - [Test] - public void Test_9959() - { - } - [Test] - public void Test_9960() - { - } - [Test] - public void Test_9961() - { - } - [Test] - public void Test_9962() - { - } - [Test] - public void Test_9963() - { - } - [Test] - public void Test_9964() - { - } - [Test] - public void Test_9965() - { - } - [Test] - public void Test_9966() - { - } - [Test] - public void Test_9967() - { - } - [Test] - public void Test_9968() - { - } - [Test] - public void Test_9969() - { - } - [Test] - public void Test_9970() - { - } - [Test] - public void Test_9971() - { - } - [Test] - public void Test_9972() - { - } - [Test] - public void Test_9973() - { - } - [Test] - public void Test_9974() - { - } - [Test] - public void Test_9975() - { - } - [Test] - public void Test_9976() - { - } - [Test] - public void Test_9977() - { - } - [Test] - public void Test_9978() - { - } - [Test] - public void Test_9979() - { - } - [Test] - public void Test_9980() - { - } - [Test] - public void Test_9981() - { - } - [Test] - public void Test_9982() - { - } - [Test] - public void Test_9983() - { - } - [Test] - public void Test_9984() - { - } - [Test] - public void Test_9985() - { - } - [Test] - public void Test_9986() - { - } - [Test] - public void Test_9987() - { - } - [Test] - public void Test_9988() - { - } - [Test] - public void Test_9989() - { - } - [Test] - public void Test_9990() - { - } - [Test] - public void Test_9991() - { - } - [Test] - public void Test_9992() - { - } - [Test] - public void Test_9993() - { - } - [Test] - public void Test_9994() - { - } - [Test] - public void Test_9995() - { - } - [Test] - public void Test_9996() - { - } - [Test] - public void Test_9997() - { - } - [Test] - public void Test_9998() - { - } - [Test] - public void Test_9999() - { - } - [Test] - public void Test_10000() - { - } - #endregion + #region PassingTests + [Test] + public void Test_01() + { + } + [Test] + public void Test_02() + { + } + [Test] + public void Test_03() + { + } + [Test] + public void Test_04() + { + } + [Test] + public void Test_05() + { + } + [Test] + public void Test_06() + { + } + [Test] + public void Test_07() + { + } + [Test] + public void Test_08() + { + } + [Test] + public void Test_09() + { + } + [Test] + public void Test_10() + { + } + [Test] + public void Test_11() + { + } + [Test] + public void Test_12() + { + } + [Test] + public void Test_13() + { + } + [Test] + public void Test_14() + { + } + [Test] + public void Test_15() + { + } + [Test] + public void Test_16() + { + } + [Test] + public void Test_17() + { + } + [Test] + public void Test_18() + { + } + [Test] + public void Test_19() + { + } + [Test] + public void Test_20() + { + } + [Test] + public void Test_21() + { + } + [Test] + public void Test_22() + { + } + [Test] + public void Test_23() + { + } + [Test] + public void Test_24() + { + } + [Test] + public void Test_25() + { + } + [Test] + public void Test_26() + { + } + [Test] + public void Test_27() + { + } + [Test] + public void Test_28() + { + } + [Test] + public void Test_29() + { + } + [Test] + public void Test_30() + { + } + [Test] + public void Test_31() + { + } + [Test] + public void Test_32() + { + } + [Test] + public void Test_33() + { + } + [Test] + public void Test_34() + { + } + [Test] + public void Test_35() + { + } + [Test] + public void Test_36() + { + } + [Test] + public void Test_37() + { + } + [Test] + public void Test_38() + { + } + [Test] + public void Test_39() + { + } + [Test] + public void Test_40() + { + } + [Test] + public void Test_41() + { + } + [Test] + public void Test_42() + { + } + [Test] + public void Test_43() + { + } + [Test] + public void Test_44() + { + } + [Test] + public void Test_45() + { + } + [Test] + public void Test_46() + { + } + [Test] + public void Test_47() + { + } + [Test] + public void Test_48() + { + } + [Test] + public void Test_49() + { + } + [Test] + public void Test_50() + { + } + [Test] + public void Test_51() + { + } + [Test] + public void Test_52() + { + } + [Test] + public void Test_53() + { + } + [Test] + public void Test_54() + { + } + [Test] + public void Test_55() + { + } + [Test] + public void Test_56() + { + } + [Test] + public void Test_57() + { + } + [Test] + public void Test_58() + { + } + [Test] + public void Test_59() + { + } + [Test] + public void Test_60() + { + } + [Test] + public void Test_61() + { + } + [Test] + public void Test_62() + { + } + [Test] + public void Test_63() + { + } + [Test] + public void Test_64() + { + } + [Test] + public void Test_65() + { + } + [Test] + public void Test_66() + { + } + [Test] + public void Test_67() + { + } + [Test] + public void Test_68() + { + } + [Test] + public void Test_69() + { + } + [Test] + public void Test_70() + { + } + [Test] + public void Test_71() + { + } + [Test] + public void Test_72() + { + } + [Test] + public void Test_73() + { + } + [Test] + public void Test_74() + { + } + [Test] + public void Test_75() + { + } + [Test] + public void Test_76() + { + } + [Test] + public void Test_77() + { + } + [Test] + public void Test_78() + { + } + [Test] + public void Test_79() + { + } + [Test] + public void Test_80() + { + } + [Test] + public void Test_81() + { + } + [Test] + public void Test_82() + { + } + [Test] + public void Test_83() + { + } + [Test] + public void Test_84() + { + } + [Test] + public void Test_85() + { + } + [Test] + public void Test_86() + { + } + [Test] + public void Test_87() + { + } + [Test] + public void Test_88() + { + } + [Test] + public void Test_89() + { + } + [Test] + public void Test_90() + { + } + [Test] + public void Test_91() + { + } + [Test] + public void Test_92() + { + } + [Test] + public void Test_93() + { + } + [Test] + public void Test_94() + { + } + [Test] + public void Test_95() + { + } + [Test] + public void Test_96() + { + } + [Test] + public void Test_97() + { + } + [Test] + public void Test_98() + { + } + [Test] + public void Test_99() + { + } + [Test] + public void Test_100() + { + } + [Test] + public void Test_101() + { + } + [Test] + public void Test_102() + { + } + [Test] + public void Test_103() + { + } + [Test] + public void Test_104() + { + } + [Test] + public void Test_105() + { + } + [Test] + public void Test_106() + { + } + [Test] + public void Test_107() + { + } + [Test] + public void Test_108() + { + } + [Test] + public void Test_109() + { + } + [Test] + public void Test_110() + { + } + [Test] + public void Test_111() + { + } + [Test] + public void Test_112() + { + } + [Test] + public void Test_113() + { + } + [Test] + public void Test_114() + { + } + [Test] + public void Test_115() + { + } + [Test] + public void Test_116() + { + } + [Test] + public void Test_117() + { + } + [Test] + public void Test_118() + { + } + [Test] + public void Test_119() + { + } + [Test] + public void Test_120() + { + } + [Test] + public void Test_121() + { + } + [Test] + public void Test_122() + { + } + [Test] + public void Test_123() + { + } + [Test] + public void Test_124() + { + } + [Test] + public void Test_125() + { + } + [Test] + public void Test_126() + { + } + [Test] + public void Test_127() + { + } + [Test] + public void Test_128() + { + } + [Test] + public void Test_129() + { + } + [Test] + public void Test_130() + { + } + [Test] + public void Test_131() + { + } + [Test] + public void Test_132() + { + } + [Test] + public void Test_133() + { + } + [Test] + public void Test_134() + { + } + [Test] + public void Test_135() + { + } + [Test] + public void Test_136() + { + } + [Test] + public void Test_137() + { + } + [Test] + public void Test_138() + { + } + [Test] + public void Test_139() + { + } + [Test] + public void Test_140() + { + } + [Test] + public void Test_141() + { + } + [Test] + public void Test_142() + { + } + [Test] + public void Test_143() + { + } + [Test] + public void Test_144() + { + } + [Test] + public void Test_145() + { + } + [Test] + public void Test_146() + { + } + [Test] + public void Test_147() + { + } + [Test] + public void Test_148() + { + } + [Test] + public void Test_149() + { + } + [Test] + public void Test_150() + { + } + [Test] + public void Test_151() + { + } + [Test] + public void Test_152() + { + } + [Test] + public void Test_153() + { + } + [Test] + public void Test_154() + { + } + [Test] + public void Test_155() + { + } + [Test] + public void Test_156() + { + } + [Test] + public void Test_157() + { + } + [Test] + public void Test_158() + { + } + [Test] + public void Test_159() + { + } + [Test] + public void Test_160() + { + } + [Test] + public void Test_161() + { + } + [Test] + public void Test_162() + { + } + [Test] + public void Test_163() + { + } + [Test] + public void Test_164() + { + } + [Test] + public void Test_165() + { + } + [Test] + public void Test_166() + { + } + [Test] + public void Test_167() + { + } + [Test] + public void Test_168() + { + } + [Test] + public void Test_169() + { + } + [Test] + public void Test_170() + { + } + [Test] + public void Test_171() + { + } + [Test] + public void Test_172() + { + } + [Test] + public void Test_173() + { + } + [Test] + public void Test_174() + { + } + [Test] + public void Test_175() + { + } + [Test] + public void Test_176() + { + } + [Test] + public void Test_177() + { + } + [Test] + public void Test_178() + { + } + [Test] + public void Test_179() + { + } + [Test] + public void Test_180() + { + } + [Test] + public void Test_181() + { + } + [Test] + public void Test_182() + { + } + [Test] + public void Test_183() + { + } + [Test] + public void Test_184() + { + } + [Test] + public void Test_185() + { + } + [Test] + public void Test_186() + { + } + [Test] + public void Test_187() + { + } + [Test] + public void Test_188() + { + } + [Test] + public void Test_189() + { + } + [Test] + public void Test_190() + { + } + [Test] + public void Test_191() + { + } + [Test] + public void Test_192() + { + } + [Test] + public void Test_193() + { + } + [Test] + public void Test_194() + { + } + [Test] + public void Test_195() + { + } + [Test] + public void Test_196() + { + } + [Test] + public void Test_197() + { + } + [Test] + public void Test_198() + { + } + [Test] + public void Test_199() + { + } + [Test] + public void Test_200() + { + } + [Test] + public void Test_201() + { + } + [Test] + public void Test_202() + { + } + [Test] + public void Test_203() + { + } + [Test] + public void Test_204() + { + } + [Test] + public void Test_205() + { + } + [Test] + public void Test_206() + { + } + [Test] + public void Test_207() + { + } + [Test] + public void Test_208() + { + } + [Test] + public void Test_209() + { + } + [Test] + public void Test_210() + { + } + [Test] + public void Test_211() + { + } + [Test] + public void Test_212() + { + } + [Test] + public void Test_213() + { + } + [Test] + public void Test_214() + { + } + [Test] + public void Test_215() + { + } + [Test] + public void Test_216() + { + } + [Test] + public void Test_217() + { + } + [Test] + public void Test_218() + { + } + [Test] + public void Test_219() + { + } + [Test] + public void Test_220() + { + } + [Test] + public void Test_221() + { + } + [Test] + public void Test_222() + { + } + [Test] + public void Test_223() + { + } + [Test] + public void Test_224() + { + } + [Test] + public void Test_225() + { + } + [Test] + public void Test_226() + { + } + [Test] + public void Test_227() + { + } + [Test] + public void Test_228() + { + } + [Test] + public void Test_229() + { + } + [Test] + public void Test_230() + { + } + [Test] + public void Test_231() + { + } + [Test] + public void Test_232() + { + } + [Test] + public void Test_233() + { + } + [Test] + public void Test_234() + { + } + [Test] + public void Test_235() + { + } + [Test] + public void Test_236() + { + } + [Test] + public void Test_237() + { + } + [Test] + public void Test_238() + { + } + [Test] + public void Test_239() + { + } + [Test] + public void Test_240() + { + } + [Test] + public void Test_241() + { + } + [Test] + public void Test_242() + { + } + [Test] + public void Test_243() + { + } + [Test] + public void Test_244() + { + } + [Test] + public void Test_245() + { + } + [Test] + public void Test_246() + { + } + [Test] + public void Test_247() + { + } + [Test] + public void Test_248() + { + } + [Test] + public void Test_249() + { + } + [Test] + public void Test_250() + { + } + [Test] + public void Test_251() + { + } + [Test] + public void Test_252() + { + } + [Test] + public void Test_253() + { + } + [Test] + public void Test_254() + { + } + [Test] + public void Test_255() + { + } + [Test] + public void Test_256() + { + } + [Test] + public void Test_257() + { + } + [Test] + public void Test_258() + { + } + [Test] + public void Test_259() + { + } + [Test] + public void Test_260() + { + } + [Test] + public void Test_261() + { + } + [Test] + public void Test_262() + { + } + [Test] + public void Test_263() + { + } + [Test] + public void Test_264() + { + } + [Test] + public void Test_265() + { + } + [Test] + public void Test_266() + { + } + [Test] + public void Test_267() + { + } + [Test] + public void Test_268() + { + } + [Test] + public void Test_269() + { + } + [Test] + public void Test_270() + { + } + [Test] + public void Test_271() + { + } + [Test] + public void Test_272() + { + } + [Test] + public void Test_273() + { + } + [Test] + public void Test_274() + { + } + [Test] + public void Test_275() + { + } + [Test] + public void Test_276() + { + } + [Test] + public void Test_277() + { + } + [Test] + public void Test_278() + { + } + [Test] + public void Test_279() + { + } + [Test] + public void Test_280() + { + } + [Test] + public void Test_281() + { + } + [Test] + public void Test_282() + { + } + [Test] + public void Test_283() + { + } + [Test] + public void Test_284() + { + } + [Test] + public void Test_285() + { + } + [Test] + public void Test_286() + { + } + [Test] + public void Test_287() + { + } + [Test] + public void Test_288() + { + } + [Test] + public void Test_289() + { + } + [Test] + public void Test_290() + { + } + [Test] + public void Test_291() + { + } + [Test] + public void Test_292() + { + } + [Test] + public void Test_293() + { + } + [Test] + public void Test_294() + { + } + [Test] + public void Test_295() + { + } + [Test] + public void Test_296() + { + } + [Test] + public void Test_297() + { + } + [Test] + public void Test_298() + { + } + [Test] + public void Test_299() + { + } + [Test] + public void Test_300() + { + } + [Test] + public void Test_301() + { + } + [Test] + public void Test_302() + { + } + [Test] + public void Test_303() + { + } + [Test] + public void Test_304() + { + } + [Test] + public void Test_305() + { + } + [Test] + public void Test_306() + { + } + [Test] + public void Test_307() + { + } + [Test] + public void Test_308() + { + } + [Test] + public void Test_309() + { + } + [Test] + public void Test_310() + { + } + [Test] + public void Test_311() + { + } + [Test] + public void Test_312() + { + } + [Test] + public void Test_313() + { + } + [Test] + public void Test_314() + { + } + [Test] + public void Test_315() + { + } + [Test] + public void Test_316() + { + } + [Test] + public void Test_317() + { + } + [Test] + public void Test_318() + { + } + [Test] + public void Test_319() + { + } + [Test] + public void Test_320() + { + } + [Test] + public void Test_321() + { + } + [Test] + public void Test_322() + { + } + [Test] + public void Test_323() + { + } + [Test] + public void Test_324() + { + } + [Test] + public void Test_325() + { + } + [Test] + public void Test_326() + { + } + [Test] + public void Test_327() + { + } + [Test] + public void Test_328() + { + } + [Test] + public void Test_329() + { + } + [Test] + public void Test_330() + { + } + [Test] + public void Test_331() + { + } + [Test] + public void Test_332() + { + } + [Test] + public void Test_333() + { + } + [Test] + public void Test_334() + { + } + [Test] + public void Test_335() + { + } + [Test] + public void Test_336() + { + } + [Test] + public void Test_337() + { + } + [Test] + public void Test_338() + { + } + [Test] + public void Test_339() + { + } + [Test] + public void Test_340() + { + } + [Test] + public void Test_341() + { + } + [Test] + public void Test_342() + { + } + [Test] + public void Test_343() + { + } + [Test] + public void Test_344() + { + } + [Test] + public void Test_345() + { + } + [Test] + public void Test_346() + { + } + [Test] + public void Test_347() + { + } + [Test] + public void Test_348() + { + } + [Test] + public void Test_349() + { + } + [Test] + public void Test_350() + { + } + [Test] + public void Test_351() + { + } + [Test] + public void Test_352() + { + } + [Test] + public void Test_353() + { + } + [Test] + public void Test_354() + { + } + [Test] + public void Test_355() + { + } + [Test] + public void Test_356() + { + } + [Test] + public void Test_357() + { + } + [Test] + public void Test_358() + { + } + [Test] + public void Test_359() + { + } + [Test] + public void Test_360() + { + } + [Test] + public void Test_361() + { + } + [Test] + public void Test_362() + { + } + [Test] + public void Test_363() + { + } + [Test] + public void Test_364() + { + } + [Test] + public void Test_365() + { + } + [Test] + public void Test_366() + { + } + [Test] + public void Test_367() + { + } + [Test] + public void Test_368() + { + } + [Test] + public void Test_369() + { + } + [Test] + public void Test_370() + { + } + [Test] + public void Test_371() + { + } + [Test] + public void Test_372() + { + } + [Test] + public void Test_373() + { + } + [Test] + public void Test_374() + { + } + [Test] + public void Test_375() + { + } + [Test] + public void Test_376() + { + } + [Test] + public void Test_377() + { + } + [Test] + public void Test_378() + { + } + [Test] + public void Test_379() + { + } + [Test] + public void Test_380() + { + } + [Test] + public void Test_381() + { + } + [Test] + public void Test_382() + { + } + [Test] + public void Test_383() + { + } + [Test] + public void Test_384() + { + } + [Test] + public void Test_385() + { + } + [Test] + public void Test_386() + { + } + [Test] + public void Test_387() + { + } + [Test] + public void Test_388() + { + } + [Test] + public void Test_389() + { + } + [Test] + public void Test_390() + { + } + [Test] + public void Test_391() + { + } + [Test] + public void Test_392() + { + } + [Test] + public void Test_393() + { + } + [Test] + public void Test_394() + { + } + [Test] + public void Test_395() + { + } + [Test] + public void Test_396() + { + } + [Test] + public void Test_397() + { + } + [Test] + public void Test_398() + { + } + [Test] + public void Test_399() + { + } + [Test] + public void Test_400() + { + } + [Test] + public void Test_401() + { + } + [Test] + public void Test_402() + { + } + [Test] + public void Test_403() + { + } + [Test] + public void Test_404() + { + } + [Test] + public void Test_405() + { + } + [Test] + public void Test_406() + { + } + [Test] + public void Test_407() + { + } + [Test] + public void Test_408() + { + } + [Test] + public void Test_409() + { + } + [Test] + public void Test_410() + { + } + [Test] + public void Test_411() + { + } + [Test] + public void Test_412() + { + } + [Test] + public void Test_413() + { + } + [Test] + public void Test_414() + { + } + [Test] + public void Test_415() + { + } + [Test] + public void Test_416() + { + } + [Test] + public void Test_417() + { + } + [Test] + public void Test_418() + { + } + [Test] + public void Test_419() + { + } + [Test] + public void Test_420() + { + } + [Test] + public void Test_421() + { + } + [Test] + public void Test_422() + { + } + [Test] + public void Test_423() + { + } + [Test] + public void Test_424() + { + } + [Test] + public void Test_425() + { + } + [Test] + public void Test_426() + { + } + [Test] + public void Test_427() + { + } + [Test] + public void Test_428() + { + } + [Test] + public void Test_429() + { + } + [Test] + public void Test_430() + { + } + [Test] + public void Test_431() + { + } + [Test] + public void Test_432() + { + } + [Test] + public void Test_433() + { + } + [Test] + public void Test_434() + { + } + [Test] + public void Test_435() + { + } + [Test] + public void Test_436() + { + } + [Test] + public void Test_437() + { + } + [Test] + public void Test_438() + { + } + [Test] + public void Test_439() + { + } + [Test] + public void Test_440() + { + } + [Test] + public void Test_441() + { + } + [Test] + public void Test_442() + { + } + [Test] + public void Test_443() + { + } + [Test] + public void Test_444() + { + } + [Test] + public void Test_445() + { + } + [Test] + public void Test_446() + { + } + [Test] + public void Test_447() + { + } + [Test] + public void Test_448() + { + } + [Test] + public void Test_449() + { + } + [Test] + public void Test_450() + { + } + [Test] + public void Test_451() + { + } + [Test] + public void Test_452() + { + } + [Test] + public void Test_453() + { + } + [Test] + public void Test_454() + { + } + [Test] + public void Test_455() + { + } + [Test] + public void Test_456() + { + } + [Test] + public void Test_457() + { + } + [Test] + public void Test_458() + { + } + [Test] + public void Test_459() + { + } + [Test] + public void Test_460() + { + } + [Test] + public void Test_461() + { + } + [Test] + public void Test_462() + { + } + [Test] + public void Test_463() + { + } + [Test] + public void Test_464() + { + } + [Test] + public void Test_465() + { + } + [Test] + public void Test_466() + { + } + [Test] + public void Test_467() + { + } + [Test] + public void Test_468() + { + } + [Test] + public void Test_469() + { + } + [Test] + public void Test_470() + { + } + [Test] + public void Test_471() + { + } + [Test] + public void Test_472() + { + } + [Test] + public void Test_473() + { + } + [Test] + public void Test_474() + { + } + [Test] + public void Test_475() + { + } + [Test] + public void Test_476() + { + } + [Test] + public void Test_477() + { + } + [Test] + public void Test_478() + { + } + [Test] + public void Test_479() + { + } + [Test] + public void Test_480() + { + } + [Test] + public void Test_481() + { + } + [Test] + public void Test_482() + { + } + [Test] + public void Test_483() + { + } + [Test] + public void Test_484() + { + } + [Test] + public void Test_485() + { + } + [Test] + public void Test_486() + { + } + [Test] + public void Test_487() + { + } + [Test] + public void Test_488() + { + } + [Test] + public void Test_489() + { + } + [Test] + public void Test_490() + { + } + [Test] + public void Test_491() + { + } + [Test] + public void Test_492() + { + } + [Test] + public void Test_493() + { + } + [Test] + public void Test_494() + { + } + [Test] + public void Test_495() + { + } + [Test] + public void Test_496() + { + } + [Test] + public void Test_497() + { + } + [Test] + public void Test_498() + { + } + [Test] + public void Test_499() + { + } + [Test] + public void Test_500() + { + } + [Test] + public void Test_501() + { + } + [Test] + public void Test_502() + { + } + [Test] + public void Test_503() + { + } + [Test] + public void Test_504() + { + } + [Test] + public void Test_505() + { + } + [Test] + public void Test_506() + { + } + [Test] + public void Test_507() + { + } + [Test] + public void Test_508() + { + } + [Test] + public void Test_509() + { + } + [Test] + public void Test_510() + { + } + [Test] + public void Test_511() + { + } + [Test] + public void Test_512() + { + } + [Test] + public void Test_513() + { + } + [Test] + public void Test_514() + { + } + [Test] + public void Test_515() + { + } + [Test] + public void Test_516() + { + } + [Test] + public void Test_517() + { + } + [Test] + public void Test_518() + { + } + [Test] + public void Test_519() + { + } + [Test] + public void Test_520() + { + } + [Test] + public void Test_521() + { + } + [Test] + public void Test_522() + { + } + [Test] + public void Test_523() + { + } + [Test] + public void Test_524() + { + } + [Test] + public void Test_525() + { + } + [Test] + public void Test_526() + { + } + [Test] + public void Test_527() + { + } + [Test] + public void Test_528() + { + } + [Test] + public void Test_529() + { + } + [Test] + public void Test_530() + { + } + [Test] + public void Test_531() + { + } + [Test] + public void Test_532() + { + } + [Test] + public void Test_533() + { + } + [Test] + public void Test_534() + { + } + [Test] + public void Test_535() + { + } + [Test] + public void Test_536() + { + } + [Test] + public void Test_537() + { + } + [Test] + public void Test_538() + { + } + [Test] + public void Test_539() + { + } + [Test] + public void Test_540() + { + } + [Test] + public void Test_541() + { + } + [Test] + public void Test_542() + { + } + [Test] + public void Test_543() + { + } + [Test] + public void Test_544() + { + } + [Test] + public void Test_545() + { + } + [Test] + public void Test_546() + { + } + [Test] + public void Test_547() + { + } + [Test] + public void Test_548() + { + } + [Test] + public void Test_549() + { + } + [Test] + public void Test_550() + { + } + [Test] + public void Test_551() + { + } + [Test] + public void Test_552() + { + } + [Test] + public void Test_553() + { + } + [Test] + public void Test_554() + { + } + [Test] + public void Test_555() + { + } + [Test] + public void Test_556() + { + } + [Test] + public void Test_557() + { + } + [Test] + public void Test_558() + { + } + [Test] + public void Test_559() + { + } + [Test] + public void Test_560() + { + } + [Test] + public void Test_561() + { + } + [Test] + public void Test_562() + { + } + [Test] + public void Test_563() + { + } + [Test] + public void Test_564() + { + } + [Test] + public void Test_565() + { + } + [Test] + public void Test_566() + { + } + [Test] + public void Test_567() + { + } + [Test] + public void Test_568() + { + } + [Test] + public void Test_569() + { + } + [Test] + public void Test_570() + { + } + [Test] + public void Test_571() + { + } + [Test] + public void Test_572() + { + } + [Test] + public void Test_573() + { + } + [Test] + public void Test_574() + { + } + [Test] + public void Test_575() + { + } + [Test] + public void Test_576() + { + } + [Test] + public void Test_577() + { + } + [Test] + public void Test_578() + { + } + [Test] + public void Test_579() + { + } + [Test] + public void Test_580() + { + } + [Test] + public void Test_581() + { + } + [Test] + public void Test_582() + { + } + [Test] + public void Test_583() + { + } + [Test] + public void Test_584() + { + } + [Test] + public void Test_585() + { + } + [Test] + public void Test_586() + { + } + [Test] + public void Test_587() + { + } + [Test] + public void Test_588() + { + } + [Test] + public void Test_589() + { + } + [Test] + public void Test_590() + { + } + [Test] + public void Test_591() + { + } + [Test] + public void Test_592() + { + } + [Test] + public void Test_593() + { + } + [Test] + public void Test_594() + { + } + [Test] + public void Test_595() + { + } + [Test] + public void Test_596() + { + } + [Test] + public void Test_597() + { + } + [Test] + public void Test_598() + { + } + [Test] + public void Test_599() + { + } + [Test] + public void Test_600() + { + } + [Test] + public void Test_601() + { + } + [Test] + public void Test_602() + { + } + [Test] + public void Test_603() + { + } + [Test] + public void Test_604() + { + } + [Test] + public void Test_605() + { + } + [Test] + public void Test_606() + { + } + [Test] + public void Test_607() + { + } + [Test] + public void Test_608() + { + } + [Test] + public void Test_609() + { + } + [Test] + public void Test_610() + { + } + [Test] + public void Test_611() + { + } + [Test] + public void Test_612() + { + } + [Test] + public void Test_613() + { + } + [Test] + public void Test_614() + { + } + [Test] + public void Test_615() + { + } + [Test] + public void Test_616() + { + } + [Test] + public void Test_617() + { + } + [Test] + public void Test_618() + { + } + [Test] + public void Test_619() + { + } + [Test] + public void Test_620() + { + } + [Test] + public void Test_621() + { + } + [Test] + public void Test_622() + { + } + [Test] + public void Test_623() + { + } + [Test] + public void Test_624() + { + } + [Test] + public void Test_625() + { + } + [Test] + public void Test_626() + { + } + [Test] + public void Test_627() + { + } + [Test] + public void Test_628() + { + } + [Test] + public void Test_629() + { + } + [Test] + public void Test_630() + { + } + [Test] + public void Test_631() + { + } + [Test] + public void Test_632() + { + } + [Test] + public void Test_633() + { + } + [Test] + public void Test_634() + { + } + [Test] + public void Test_635() + { + } + [Test] + public void Test_636() + { + } + [Test] + public void Test_637() + { + } + [Test] + public void Test_638() + { + } + [Test] + public void Test_639() + { + } + [Test] + public void Test_640() + { + } + [Test] + public void Test_641() + { + } + [Test] + public void Test_642() + { + } + [Test] + public void Test_643() + { + } + [Test] + public void Test_644() + { + } + [Test] + public void Test_645() + { + } + [Test] + public void Test_646() + { + } + [Test] + public void Test_647() + { + } + [Test] + public void Test_648() + { + } + [Test] + public void Test_649() + { + } + [Test] + public void Test_650() + { + } + [Test] + public void Test_651() + { + } + [Test] + public void Test_652() + { + } + [Test] + public void Test_653() + { + } + [Test] + public void Test_654() + { + } + [Test] + public void Test_655() + { + } + [Test] + public void Test_656() + { + } + [Test] + public void Test_657() + { + } + [Test] + public void Test_658() + { + } + [Test] + public void Test_659() + { + } + [Test] + public void Test_660() + { + } + [Test] + public void Test_661() + { + } + [Test] + public void Test_662() + { + } + [Test] + public void Test_663() + { + } + [Test] + public void Test_664() + { + } + [Test] + public void Test_665() + { + } + [Test] + public void Test_666() + { + } + [Test] + public void Test_667() + { + } + [Test] + public void Test_668() + { + } + [Test] + public void Test_669() + { + } + [Test] + public void Test_670() + { + } + [Test] + public void Test_671() + { + } + [Test] + public void Test_672() + { + } + [Test] + public void Test_673() + { + } + [Test] + public void Test_674() + { + } + [Test] + public void Test_675() + { + } + [Test] + public void Test_676() + { + } + [Test] + public void Test_677() + { + } + [Test] + public void Test_678() + { + } + [Test] + public void Test_679() + { + } + [Test] + public void Test_680() + { + } + [Test] + public void Test_681() + { + } + [Test] + public void Test_682() + { + } + [Test] + public void Test_683() + { + } + [Test] + public void Test_684() + { + } + [Test] + public void Test_685() + { + } + [Test] + public void Test_686() + { + } + [Test] + public void Test_687() + { + } + [Test] + public void Test_688() + { + } + [Test] + public void Test_689() + { + } + [Test] + public void Test_690() + { + } + [Test] + public void Test_691() + { + } + [Test] + public void Test_692() + { + } + [Test] + public void Test_693() + { + } + [Test] + public void Test_694() + { + } + [Test] + public void Test_695() + { + } + [Test] + public void Test_696() + { + } + [Test] + public void Test_697() + { + } + [Test] + public void Test_698() + { + } + [Test] + public void Test_699() + { + } + [Test] + public void Test_700() + { + } + [Test] + public void Test_701() + { + } + [Test] + public void Test_702() + { + } + [Test] + public void Test_703() + { + } + [Test] + public void Test_704() + { + } + [Test] + public void Test_705() + { + } + [Test] + public void Test_706() + { + } + [Test] + public void Test_707() + { + } + [Test] + public void Test_708() + { + } + [Test] + public void Test_709() + { + } + [Test] + public void Test_710() + { + } + [Test] + public void Test_711() + { + } + [Test] + public void Test_712() + { + } + [Test] + public void Test_713() + { + } + [Test] + public void Test_714() + { + } + [Test] + public void Test_715() + { + } + [Test] + public void Test_716() + { + } + [Test] + public void Test_717() + { + } + [Test] + public void Test_718() + { + } + [Test] + public void Test_719() + { + } + [Test] + public void Test_720() + { + } + [Test] + public void Test_721() + { + } + [Test] + public void Test_722() + { + } + [Test] + public void Test_723() + { + } + [Test] + public void Test_724() + { + } + [Test] + public void Test_725() + { + } + [Test] + public void Test_726() + { + } + [Test] + public void Test_727() + { + } + [Test] + public void Test_728() + { + } + [Test] + public void Test_729() + { + } + [Test] + public void Test_730() + { + } + [Test] + public void Test_731() + { + } + [Test] + public void Test_732() + { + } + [Test] + public void Test_733() + { + } + [Test] + public void Test_734() + { + } + [Test] + public void Test_735() + { + } + [Test] + public void Test_736() + { + } + [Test] + public void Test_737() + { + } + [Test] + public void Test_738() + { + } + [Test] + public void Test_739() + { + } + [Test] + public void Test_740() + { + } + [Test] + public void Test_741() + { + } + [Test] + public void Test_742() + { + } + [Test] + public void Test_743() + { + } + [Test] + public void Test_744() + { + } + [Test] + public void Test_745() + { + } + [Test] + public void Test_746() + { + } + [Test] + public void Test_747() + { + } + [Test] + public void Test_748() + { + } + [Test] + public void Test_749() + { + } + [Test] + public void Test_750() + { + } + [Test] + public void Test_751() + { + } + [Test] + public void Test_752() + { + } + [Test] + public void Test_753() + { + } + [Test] + public void Test_754() + { + } + [Test] + public void Test_755() + { + } + [Test] + public void Test_756() + { + } + [Test] + public void Test_757() + { + } + [Test] + public void Test_758() + { + } + [Test] + public void Test_759() + { + } + [Test] + public void Test_760() + { + } + [Test] + public void Test_761() + { + } + [Test] + public void Test_762() + { + } + [Test] + public void Test_763() + { + } + [Test] + public void Test_764() + { + } + [Test] + public void Test_765() + { + } + [Test] + public void Test_766() + { + } + [Test] + public void Test_767() + { + } + [Test] + public void Test_768() + { + } + [Test] + public void Test_769() + { + } + [Test] + public void Test_770() + { + } + [Test] + public void Test_771() + { + } + [Test] + public void Test_772() + { + } + [Test] + public void Test_773() + { + } + [Test] + public void Test_774() + { + } + [Test] + public void Test_775() + { + } + [Test] + public void Test_776() + { + } + [Test] + public void Test_777() + { + } + [Test] + public void Test_778() + { + } + [Test] + public void Test_779() + { + } + [Test] + public void Test_780() + { + } + [Test] + public void Test_781() + { + } + [Test] + public void Test_782() + { + } + [Test] + public void Test_783() + { + } + [Test] + public void Test_784() + { + } + [Test] + public void Test_785() + { + } + [Test] + public void Test_786() + { + } + [Test] + public void Test_787() + { + } + [Test] + public void Test_788() + { + } + [Test] + public void Test_789() + { + } + [Test] + public void Test_790() + { + } + [Test] + public void Test_791() + { + } + [Test] + public void Test_792() + { + } + [Test] + public void Test_793() + { + } + [Test] + public void Test_794() + { + } + [Test] + public void Test_795() + { + } + [Test] + public void Test_796() + { + } + [Test] + public void Test_797() + { + } + [Test] + public void Test_798() + { + } + [Test] + public void Test_799() + { + } + [Test] + public void Test_800() + { + } + [Test] + public void Test_801() + { + } + [Test] + public void Test_802() + { + } + [Test] + public void Test_803() + { + } + [Test] + public void Test_804() + { + } + [Test] + public void Test_805() + { + } + [Test] + public void Test_806() + { + } + [Test] + public void Test_807() + { + } + [Test] + public void Test_808() + { + } + [Test] + public void Test_809() + { + } + [Test] + public void Test_810() + { + } + [Test] + public void Test_811() + { + } + [Test] + public void Test_812() + { + } + [Test] + public void Test_813() + { + } + [Test] + public void Test_814() + { + } + [Test] + public void Test_815() + { + } + [Test] + public void Test_816() + { + } + [Test] + public void Test_817() + { + } + [Test] + public void Test_818() + { + } + [Test] + public void Test_819() + { + } + [Test] + public void Test_820() + { + } + [Test] + public void Test_821() + { + } + [Test] + public void Test_822() + { + } + [Test] + public void Test_823() + { + } + [Test] + public void Test_824() + { + } + [Test] + public void Test_825() + { + } + [Test] + public void Test_826() + { + } + [Test] + public void Test_827() + { + } + [Test] + public void Test_828() + { + } + [Test] + public void Test_829() + { + } + [Test] + public void Test_830() + { + } + [Test] + public void Test_831() + { + } + [Test] + public void Test_832() + { + } + [Test] + public void Test_833() + { + } + [Test] + public void Test_834() + { + } + [Test] + public void Test_835() + { + } + [Test] + public void Test_836() + { + } + [Test] + public void Test_837() + { + } + [Test] + public void Test_838() + { + } + [Test] + public void Test_839() + { + } + [Test] + public void Test_840() + { + } + [Test] + public void Test_841() + { + } + [Test] + public void Test_842() + { + } + [Test] + public void Test_843() + { + } + [Test] + public void Test_844() + { + } + [Test] + public void Test_845() + { + } + [Test] + public void Test_846() + { + } + [Test] + public void Test_847() + { + } + [Test] + public void Test_848() + { + } + [Test] + public void Test_849() + { + } + [Test] + public void Test_850() + { + } + [Test] + public void Test_851() + { + } + [Test] + public void Test_852() + { + } + [Test] + public void Test_853() + { + } + [Test] + public void Test_854() + { + } + [Test] + public void Test_855() + { + } + [Test] + public void Test_856() + { + } + [Test] + public void Test_857() + { + } + [Test] + public void Test_858() + { + } + [Test] + public void Test_859() + { + } + [Test] + public void Test_860() + { + } + [Test] + public void Test_861() + { + } + [Test] + public void Test_862() + { + } + [Test] + public void Test_863() + { + } + [Test] + public void Test_864() + { + } + [Test] + public void Test_865() + { + } + [Test] + public void Test_866() + { + } + [Test] + public void Test_867() + { + } + [Test] + public void Test_868() + { + } + [Test] + public void Test_869() + { + } + [Test] + public void Test_870() + { + } + [Test] + public void Test_871() + { + } + [Test] + public void Test_872() + { + } + [Test] + public void Test_873() + { + } + [Test] + public void Test_874() + { + } + [Test] + public void Test_875() + { + } + [Test] + public void Test_876() + { + } + [Test] + public void Test_877() + { + } + [Test] + public void Test_878() + { + } + [Test] + public void Test_879() + { + } + [Test] + public void Test_880() + { + } + [Test] + public void Test_881() + { + } + [Test] + public void Test_882() + { + } + [Test] + public void Test_883() + { + } + [Test] + public void Test_884() + { + } + [Test] + public void Test_885() + { + } + [Test] + public void Test_886() + { + } + [Test] + public void Test_887() + { + } + [Test] + public void Test_888() + { + } + [Test] + public void Test_889() + { + } + [Test] + public void Test_890() + { + } + [Test] + public void Test_891() + { + } + [Test] + public void Test_892() + { + } + [Test] + public void Test_893() + { + } + [Test] + public void Test_894() + { + } + [Test] + public void Test_895() + { + } + [Test] + public void Test_896() + { + } + [Test] + public void Test_897() + { + } + [Test] + public void Test_898() + { + } + [Test] + public void Test_899() + { + } + [Test] + public void Test_900() + { + } + [Test] + public void Test_901() + { + } + [Test] + public void Test_902() + { + } + [Test] + public void Test_903() + { + } + [Test] + public void Test_904() + { + } + [Test] + public void Test_905() + { + } + [Test] + public void Test_906() + { + } + [Test] + public void Test_907() + { + } + [Test] + public void Test_908() + { + } + [Test] + public void Test_909() + { + } + [Test] + public void Test_910() + { + } + [Test] + public void Test_911() + { + } + [Test] + public void Test_912() + { + } + [Test] + public void Test_913() + { + } + [Test] + public void Test_914() + { + } + [Test] + public void Test_915() + { + } + [Test] + public void Test_916() + { + } + [Test] + public void Test_917() + { + } + [Test] + public void Test_918() + { + } + [Test] + public void Test_919() + { + } + [Test] + public void Test_920() + { + } + [Test] + public void Test_921() + { + } + [Test] + public void Test_922() + { + } + [Test] + public void Test_923() + { + } + [Test] + public void Test_924() + { + } + [Test] + public void Test_925() + { + } + [Test] + public void Test_926() + { + } + [Test] + public void Test_927() + { + } + [Test] + public void Test_928() + { + } + [Test] + public void Test_929() + { + } + [Test] + public void Test_930() + { + } + [Test] + public void Test_931() + { + } + [Test] + public void Test_932() + { + } + [Test] + public void Test_933() + { + } + [Test] + public void Test_934() + { + } + [Test] + public void Test_935() + { + } + [Test] + public void Test_936() + { + } + [Test] + public void Test_937() + { + } + [Test] + public void Test_938() + { + } + [Test] + public void Test_939() + { + } + [Test] + public void Test_940() + { + } + [Test] + public void Test_941() + { + } + [Test] + public void Test_942() + { + } + [Test] + public void Test_943() + { + } + [Test] + public void Test_944() + { + } + [Test] + public void Test_945() + { + } + [Test] + public void Test_946() + { + } + [Test] + public void Test_947() + { + } + [Test] + public void Test_948() + { + } + [Test] + public void Test_949() + { + } + [Test] + public void Test_950() + { + } + [Test] + public void Test_951() + { + } + [Test] + public void Test_952() + { + } + [Test] + public void Test_953() + { + } + [Test] + public void Test_954() + { + } + [Test] + public void Test_955() + { + } + [Test] + public void Test_956() + { + } + [Test] + public void Test_957() + { + } + [Test] + public void Test_958() + { + } + [Test] + public void Test_959() + { + } + [Test] + public void Test_960() + { + } + [Test] + public void Test_961() + { + } + [Test] + public void Test_962() + { + } + [Test] + public void Test_963() + { + } + [Test] + public void Test_964() + { + } + [Test] + public void Test_965() + { + } + [Test] + public void Test_966() + { + } + [Test] + public void Test_967() + { + } + [Test] + public void Test_968() + { + } + [Test] + public void Test_969() + { + } + [Test] + public void Test_970() + { + } + [Test] + public void Test_971() + { + } + [Test] + public void Test_972() + { + } + [Test] + public void Test_973() + { + } + [Test] + public void Test_974() + { + } + [Test] + public void Test_975() + { + } + [Test] + public void Test_976() + { + } + [Test] + public void Test_977() + { + } + [Test] + public void Test_978() + { + } + [Test] + public void Test_979() + { + } + [Test] + public void Test_980() + { + } + [Test] + public void Test_981() + { + } + [Test] + public void Test_982() + { + } + [Test] + public void Test_983() + { + } + [Test] + public void Test_984() + { + } + [Test] + public void Test_985() + { + } + [Test] + public void Test_986() + { + } + [Test] + public void Test_987() + { + } + [Test] + public void Test_988() + { + } + [Test] + public void Test_989() + { + } + [Test] + public void Test_990() + { + } + [Test] + public void Test_991() + { + } + [Test] + public void Test_992() + { + } + [Test] + public void Test_993() + { + } + [Test] + public void Test_994() + { + } + [Test] + public void Test_995() + { + } + [Test] + public void Test_996() + { + } + [Test] + public void Test_997() + { + } + [Test] + public void Test_998() + { + } + [Test] + public void Test_999() + { + } + [Test] + public void Test_1000() + { + } + [Test] + public void Test_1001() + { + } + [Test] + public void Test_1002() + { + } + [Test] + public void Test_1003() + { + } + [Test] + public void Test_1004() + { + } + [Test] + public void Test_1005() + { + } + [Test] + public void Test_1006() + { + } + [Test] + public void Test_1007() + { + } + [Test] + public void Test_1008() + { + } + [Test] + public void Test_1009() + { + } + [Test] + public void Test_1010() + { + } + [Test] + public void Test_1011() + { + } + [Test] + public void Test_1012() + { + } + [Test] + public void Test_1013() + { + } + [Test] + public void Test_1014() + { + } + [Test] + public void Test_1015() + { + } + [Test] + public void Test_1016() + { + } + [Test] + public void Test_1017() + { + } + [Test] + public void Test_1018() + { + } + [Test] + public void Test_1019() + { + } + [Test] + public void Test_1020() + { + } + [Test] + public void Test_1021() + { + } + [Test] + public void Test_1022() + { + } + [Test] + public void Test_1023() + { + } + [Test] + public void Test_1024() + { + } + [Test] + public void Test_1025() + { + } + [Test] + public void Test_1026() + { + } + [Test] + public void Test_1027() + { + } + [Test] + public void Test_1028() + { + } + [Test] + public void Test_1029() + { + } + [Test] + public void Test_1030() + { + } + [Test] + public void Test_1031() + { + } + [Test] + public void Test_1032() + { + } + [Test] + public void Test_1033() + { + } + [Test] + public void Test_1034() + { + } + [Test] + public void Test_1035() + { + } + [Test] + public void Test_1036() + { + } + [Test] + public void Test_1037() + { + } + [Test] + public void Test_1038() + { + } + [Test] + public void Test_1039() + { + } + [Test] + public void Test_1040() + { + } + [Test] + public void Test_1041() + { + } + [Test] + public void Test_1042() + { + } + [Test] + public void Test_1043() + { + } + [Test] + public void Test_1044() + { + } + [Test] + public void Test_1045() + { + } + [Test] + public void Test_1046() + { + } + [Test] + public void Test_1047() + { + } + [Test] + public void Test_1048() + { + } + [Test] + public void Test_1049() + { + } + [Test] + public void Test_1050() + { + } + [Test] + public void Test_1051() + { + } + [Test] + public void Test_1052() + { + } + [Test] + public void Test_1053() + { + } + [Test] + public void Test_1054() + { + } + [Test] + public void Test_1055() + { + } + [Test] + public void Test_1056() + { + } + [Test] + public void Test_1057() + { + } + [Test] + public void Test_1058() + { + } + [Test] + public void Test_1059() + { + } + [Test] + public void Test_1060() + { + } + [Test] + public void Test_1061() + { + } + [Test] + public void Test_1062() + { + } + [Test] + public void Test_1063() + { + } + [Test] + public void Test_1064() + { + } + [Test] + public void Test_1065() + { + } + [Test] + public void Test_1066() + { + } + [Test] + public void Test_1067() + { + } + [Test] + public void Test_1068() + { + } + [Test] + public void Test_1069() + { + } + [Test] + public void Test_1070() + { + } + [Test] + public void Test_1071() + { + } + [Test] + public void Test_1072() + { + } + [Test] + public void Test_1073() + { + } + [Test] + public void Test_1074() + { + } + [Test] + public void Test_1075() + { + } + [Test] + public void Test_1076() + { + } + [Test] + public void Test_1077() + { + } + [Test] + public void Test_1078() + { + } + [Test] + public void Test_1079() + { + } + [Test] + public void Test_1080() + { + } + [Test] + public void Test_1081() + { + } + [Test] + public void Test_1082() + { + } + [Test] + public void Test_1083() + { + } + [Test] + public void Test_1084() + { + } + [Test] + public void Test_1085() + { + } + [Test] + public void Test_1086() + { + } + [Test] + public void Test_1087() + { + } + [Test] + public void Test_1088() + { + } + [Test] + public void Test_1089() + { + } + [Test] + public void Test_1090() + { + } + [Test] + public void Test_1091() + { + } + [Test] + public void Test_1092() + { + } + [Test] + public void Test_1093() + { + } + [Test] + public void Test_1094() + { + } + [Test] + public void Test_1095() + { + } + [Test] + public void Test_1096() + { + } + [Test] + public void Test_1097() + { + } + [Test] + public void Test_1098() + { + } + [Test] + public void Test_1099() + { + } + [Test] + public void Test_1100() + { + } + [Test] + public void Test_1101() + { + } + [Test] + public void Test_1102() + { + } + [Test] + public void Test_1103() + { + } + [Test] + public void Test_1104() + { + } + [Test] + public void Test_1105() + { + } + [Test] + public void Test_1106() + { + } + [Test] + public void Test_1107() + { + } + [Test] + public void Test_1108() + { + } + [Test] + public void Test_1109() + { + } + [Test] + public void Test_1110() + { + } + [Test] + public void Test_1111() + { + } + [Test] + public void Test_1112() + { + } + [Test] + public void Test_1113() + { + } + [Test] + public void Test_1114() + { + } + [Test] + public void Test_1115() + { + } + [Test] + public void Test_1116() + { + } + [Test] + public void Test_1117() + { + } + [Test] + public void Test_1118() + { + } + [Test] + public void Test_1119() + { + } + [Test] + public void Test_1120() + { + } + [Test] + public void Test_1121() + { + } + [Test] + public void Test_1122() + { + } + [Test] + public void Test_1123() + { + } + [Test] + public void Test_1124() + { + } + [Test] + public void Test_1125() + { + } + [Test] + public void Test_1126() + { + } + [Test] + public void Test_1127() + { + } + [Test] + public void Test_1128() + { + } + [Test] + public void Test_1129() + { + } + [Test] + public void Test_1130() + { + } + [Test] + public void Test_1131() + { + } + [Test] + public void Test_1132() + { + } + [Test] + public void Test_1133() + { + } + [Test] + public void Test_1134() + { + } + [Test] + public void Test_1135() + { + } + [Test] + public void Test_1136() + { + } + [Test] + public void Test_1137() + { + } + [Test] + public void Test_1138() + { + } + [Test] + public void Test_1139() + { + } + [Test] + public void Test_1140() + { + } + [Test] + public void Test_1141() + { + } + [Test] + public void Test_1142() + { + } + [Test] + public void Test_1143() + { + } + [Test] + public void Test_1144() + { + } + [Test] + public void Test_1145() + { + } + [Test] + public void Test_1146() + { + } + [Test] + public void Test_1147() + { + } + [Test] + public void Test_1148() + { + } + [Test] + public void Test_1149() + { + } + [Test] + public void Test_1150() + { + } + [Test] + public void Test_1151() + { + } + [Test] + public void Test_1152() + { + } + [Test] + public void Test_1153() + { + } + [Test] + public void Test_1154() + { + } + [Test] + public void Test_1155() + { + } + [Test] + public void Test_1156() + { + } + [Test] + public void Test_1157() + { + } + [Test] + public void Test_1158() + { + } + [Test] + public void Test_1159() + { + } + [Test] + public void Test_1160() + { + } + [Test] + public void Test_1161() + { + } + [Test] + public void Test_1162() + { + } + [Test] + public void Test_1163() + { + } + [Test] + public void Test_1164() + { + } + [Test] + public void Test_1165() + { + } + [Test] + public void Test_1166() + { + } + [Test] + public void Test_1167() + { + } + [Test] + public void Test_1168() + { + } + [Test] + public void Test_1169() + { + } + [Test] + public void Test_1170() + { + } + [Test] + public void Test_1171() + { + } + [Test] + public void Test_1172() + { + } + [Test] + public void Test_1173() + { + } + [Test] + public void Test_1174() + { + } + [Test] + public void Test_1175() + { + } + [Test] + public void Test_1176() + { + } + [Test] + public void Test_1177() + { + } + [Test] + public void Test_1178() + { + } + [Test] + public void Test_1179() + { + } + [Test] + public void Test_1180() + { + } + [Test] + public void Test_1181() + { + } + [Test] + public void Test_1182() + { + } + [Test] + public void Test_1183() + { + } + [Test] + public void Test_1184() + { + } + [Test] + public void Test_1185() + { + } + [Test] + public void Test_1186() + { + } + [Test] + public void Test_1187() + { + } + [Test] + public void Test_1188() + { + } + [Test] + public void Test_1189() + { + } + [Test] + public void Test_1190() + { + } + [Test] + public void Test_1191() + { + } + [Test] + public void Test_1192() + { + } + [Test] + public void Test_1193() + { + } + [Test] + public void Test_1194() + { + } + [Test] + public void Test_1195() + { + } + [Test] + public void Test_1196() + { + } + [Test] + public void Test_1197() + { + } + [Test] + public void Test_1198() + { + } + [Test] + public void Test_1199() + { + } + [Test] + public void Test_1200() + { + } + [Test] + public void Test_1201() + { + } + [Test] + public void Test_1202() + { + } + [Test] + public void Test_1203() + { + } + [Test] + public void Test_1204() + { + } + [Test] + public void Test_1205() + { + } + [Test] + public void Test_1206() + { + } + [Test] + public void Test_1207() + { + } + [Test] + public void Test_1208() + { + } + [Test] + public void Test_1209() + { + } + [Test] + public void Test_1210() + { + } + [Test] + public void Test_1211() + { + } + [Test] + public void Test_1212() + { + } + [Test] + public void Test_1213() + { + } + [Test] + public void Test_1214() + { + } + [Test] + public void Test_1215() + { + } + [Test] + public void Test_1216() + { + } + [Test] + public void Test_1217() + { + } + [Test] + public void Test_1218() + { + } + [Test] + public void Test_1219() + { + } + [Test] + public void Test_1220() + { + } + [Test] + public void Test_1221() + { + } + [Test] + public void Test_1222() + { + } + [Test] + public void Test_1223() + { + } + [Test] + public void Test_1224() + { + } + [Test] + public void Test_1225() + { + } + [Test] + public void Test_1226() + { + } + [Test] + public void Test_1227() + { + } + [Test] + public void Test_1228() + { + } + [Test] + public void Test_1229() + { + } + [Test] + public void Test_1230() + { + } + [Test] + public void Test_1231() + { + } + [Test] + public void Test_1232() + { + } + [Test] + public void Test_1233() + { + } + [Test] + public void Test_1234() + { + } + [Test] + public void Test_1235() + { + } + [Test] + public void Test_1236() + { + } + [Test] + public void Test_1237() + { + } + [Test] + public void Test_1238() + { + } + [Test] + public void Test_1239() + { + } + [Test] + public void Test_1240() + { + } + [Test] + public void Test_1241() + { + } + [Test] + public void Test_1242() + { + } + [Test] + public void Test_1243() + { + } + [Test] + public void Test_1244() + { + } + [Test] + public void Test_1245() + { + } + [Test] + public void Test_1246() + { + } + [Test] + public void Test_1247() + { + } + [Test] + public void Test_1248() + { + } + [Test] + public void Test_1249() + { + } + [Test] + public void Test_1250() + { + } + [Test] + public void Test_1251() + { + } + [Test] + public void Test_1252() + { + } + [Test] + public void Test_1253() + { + } + [Test] + public void Test_1254() + { + } + [Test] + public void Test_1255() + { + } + [Test] + public void Test_1256() + { + } + [Test] + public void Test_1257() + { + } + [Test] + public void Test_1258() + { + } + [Test] + public void Test_1259() + { + } + [Test] + public void Test_1260() + { + } + [Test] + public void Test_1261() + { + } + [Test] + public void Test_1262() + { + } + [Test] + public void Test_1263() + { + } + [Test] + public void Test_1264() + { + } + [Test] + public void Test_1265() + { + } + [Test] + public void Test_1266() + { + } + [Test] + public void Test_1267() + { + } + [Test] + public void Test_1268() + { + } + [Test] + public void Test_1269() + { + } + [Test] + public void Test_1270() + { + } + [Test] + public void Test_1271() + { + } + [Test] + public void Test_1272() + { + } + [Test] + public void Test_1273() + { + } + [Test] + public void Test_1274() + { + } + [Test] + public void Test_1275() + { + } + [Test] + public void Test_1276() + { + } + [Test] + public void Test_1277() + { + } + [Test] + public void Test_1278() + { + } + [Test] + public void Test_1279() + { + } + [Test] + public void Test_1280() + { + } + [Test] + public void Test_1281() + { + } + [Test] + public void Test_1282() + { + } + [Test] + public void Test_1283() + { + } + [Test] + public void Test_1284() + { + } + [Test] + public void Test_1285() + { + } + [Test] + public void Test_1286() + { + } + [Test] + public void Test_1287() + { + } + [Test] + public void Test_1288() + { + } + [Test] + public void Test_1289() + { + } + [Test] + public void Test_1290() + { + } + [Test] + public void Test_1291() + { + } + [Test] + public void Test_1292() + { + } + [Test] + public void Test_1293() + { + } + [Test] + public void Test_1294() + { + } + [Test] + public void Test_1295() + { + } + [Test] + public void Test_1296() + { + } + [Test] + public void Test_1297() + { + } + [Test] + public void Test_1298() + { + } + [Test] + public void Test_1299() + { + } + [Test] + public void Test_1300() + { + } + [Test] + public void Test_1301() + { + } + [Test] + public void Test_1302() + { + } + [Test] + public void Test_1303() + { + } + [Test] + public void Test_1304() + { + } + [Test] + public void Test_1305() + { + } + [Test] + public void Test_1306() + { + } + [Test] + public void Test_1307() + { + } + [Test] + public void Test_1308() + { + } + [Test] + public void Test_1309() + { + } + [Test] + public void Test_1310() + { + } + [Test] + public void Test_1311() + { + } + [Test] + public void Test_1312() + { + } + [Test] + public void Test_1313() + { + } + [Test] + public void Test_1314() + { + } + [Test] + public void Test_1315() + { + } + [Test] + public void Test_1316() + { + } + [Test] + public void Test_1317() + { + } + [Test] + public void Test_1318() + { + } + [Test] + public void Test_1319() + { + } + [Test] + public void Test_1320() + { + } + [Test] + public void Test_1321() + { + } + [Test] + public void Test_1322() + { + } + [Test] + public void Test_1323() + { + } + [Test] + public void Test_1324() + { + } + [Test] + public void Test_1325() + { + } + [Test] + public void Test_1326() + { + } + [Test] + public void Test_1327() + { + } + [Test] + public void Test_1328() + { + } + [Test] + public void Test_1329() + { + } + [Test] + public void Test_1330() + { + } + [Test] + public void Test_1331() + { + } + [Test] + public void Test_1332() + { + } + [Test] + public void Test_1333() + { + } + [Test] + public void Test_1334() + { + } + [Test] + public void Test_1335() + { + } + [Test] + public void Test_1336() + { + } + [Test] + public void Test_1337() + { + } + [Test] + public void Test_1338() + { + } + [Test] + public void Test_1339() + { + } + [Test] + public void Test_1340() + { + } + [Test] + public void Test_1341() + { + } + [Test] + public void Test_1342() + { + } + [Test] + public void Test_1343() + { + } + [Test] + public void Test_1344() + { + } + [Test] + public void Test_1345() + { + } + [Test] + public void Test_1346() + { + } + [Test] + public void Test_1347() + { + } + [Test] + public void Test_1348() + { + } + [Test] + public void Test_1349() + { + } + [Test] + public void Test_1350() + { + } + [Test] + public void Test_1351() + { + } + [Test] + public void Test_1352() + { + } + [Test] + public void Test_1353() + { + } + [Test] + public void Test_1354() + { + } + [Test] + public void Test_1355() + { + } + [Test] + public void Test_1356() + { + } + [Test] + public void Test_1357() + { + } + [Test] + public void Test_1358() + { + } + [Test] + public void Test_1359() + { + } + [Test] + public void Test_1360() + { + } + [Test] + public void Test_1361() + { + } + [Test] + public void Test_1362() + { + } + [Test] + public void Test_1363() + { + } + [Test] + public void Test_1364() + { + } + [Test] + public void Test_1365() + { + } + [Test] + public void Test_1366() + { + } + [Test] + public void Test_1367() + { + } + [Test] + public void Test_1368() + { + } + [Test] + public void Test_1369() + { + } + [Test] + public void Test_1370() + { + } + [Test] + public void Test_1371() + { + } + [Test] + public void Test_1372() + { + } + [Test] + public void Test_1373() + { + } + [Test] + public void Test_1374() + { + } + [Test] + public void Test_1375() + { + } + [Test] + public void Test_1376() + { + } + [Test] + public void Test_1377() + { + } + [Test] + public void Test_1378() + { + } + [Test] + public void Test_1379() + { + } + [Test] + public void Test_1380() + { + } + [Test] + public void Test_1381() + { + } + [Test] + public void Test_1382() + { + } + [Test] + public void Test_1383() + { + } + [Test] + public void Test_1384() + { + } + [Test] + public void Test_1385() + { + } + [Test] + public void Test_1386() + { + } + [Test] + public void Test_1387() + { + } + [Test] + public void Test_1388() + { + } + [Test] + public void Test_1389() + { + } + [Test] + public void Test_1390() + { + } + [Test] + public void Test_1391() + { + } + [Test] + public void Test_1392() + { + } + [Test] + public void Test_1393() + { + } + [Test] + public void Test_1394() + { + } + [Test] + public void Test_1395() + { + } + [Test] + public void Test_1396() + { + } + [Test] + public void Test_1397() + { + } + [Test] + public void Test_1398() + { + } + [Test] + public void Test_1399() + { + } + [Test] + public void Test_1400() + { + } + [Test] + public void Test_1401() + { + } + [Test] + public void Test_1402() + { + } + [Test] + public void Test_1403() + { + } + [Test] + public void Test_1404() + { + } + [Test] + public void Test_1405() + { + } + [Test] + public void Test_1406() + { + } + [Test] + public void Test_1407() + { + } + [Test] + public void Test_1408() + { + } + [Test] + public void Test_1409() + { + } + [Test] + public void Test_1410() + { + } + [Test] + public void Test_1411() + { + } + [Test] + public void Test_1412() + { + } + [Test] + public void Test_1413() + { + } + [Test] + public void Test_1414() + { + } + [Test] + public void Test_1415() + { + } + [Test] + public void Test_1416() + { + } + [Test] + public void Test_1417() + { + } + [Test] + public void Test_1418() + { + } + [Test] + public void Test_1419() + { + } + [Test] + public void Test_1420() + { + } + [Test] + public void Test_1421() + { + } + [Test] + public void Test_1422() + { + } + [Test] + public void Test_1423() + { + } + [Test] + public void Test_1424() + { + } + [Test] + public void Test_1425() + { + } + [Test] + public void Test_1426() + { + } + [Test] + public void Test_1427() + { + } + [Test] + public void Test_1428() + { + } + [Test] + public void Test_1429() + { + } + [Test] + public void Test_1430() + { + } + [Test] + public void Test_1431() + { + } + [Test] + public void Test_1432() + { + } + [Test] + public void Test_1433() + { + } + [Test] + public void Test_1434() + { + } + [Test] + public void Test_1435() + { + } + [Test] + public void Test_1436() + { + } + [Test] + public void Test_1437() + { + } + [Test] + public void Test_1438() + { + } + [Test] + public void Test_1439() + { + } + [Test] + public void Test_1440() + { + } + [Test] + public void Test_1441() + { + } + [Test] + public void Test_1442() + { + } + [Test] + public void Test_1443() + { + } + [Test] + public void Test_1444() + { + } + [Test] + public void Test_1445() + { + } + [Test] + public void Test_1446() + { + } + [Test] + public void Test_1447() + { + } + [Test] + public void Test_1448() + { + } + [Test] + public void Test_1449() + { + } + [Test] + public void Test_1450() + { + } + [Test] + public void Test_1451() + { + } + [Test] + public void Test_1452() + { + } + [Test] + public void Test_1453() + { + } + [Test] + public void Test_1454() + { + } + [Test] + public void Test_1455() + { + } + [Test] + public void Test_1456() + { + } + [Test] + public void Test_1457() + { + } + [Test] + public void Test_1458() + { + } + [Test] + public void Test_1459() + { + } + [Test] + public void Test_1460() + { + } + [Test] + public void Test_1461() + { + } + [Test] + public void Test_1462() + { + } + [Test] + public void Test_1463() + { + } + [Test] + public void Test_1464() + { + } + [Test] + public void Test_1465() + { + } + [Test] + public void Test_1466() + { + } + [Test] + public void Test_1467() + { + } + [Test] + public void Test_1468() + { + } + [Test] + public void Test_1469() + { + } + [Test] + public void Test_1470() + { + } + [Test] + public void Test_1471() + { + } + [Test] + public void Test_1472() + { + } + [Test] + public void Test_1473() + { + } + [Test] + public void Test_1474() + { + } + [Test] + public void Test_1475() + { + } + [Test] + public void Test_1476() + { + } + [Test] + public void Test_1477() + { + } + [Test] + public void Test_1478() + { + } + [Test] + public void Test_1479() + { + } + [Test] + public void Test_1480() + { + } + [Test] + public void Test_1481() + { + } + [Test] + public void Test_1482() + { + } + [Test] + public void Test_1483() + { + } + [Test] + public void Test_1484() + { + } + [Test] + public void Test_1485() + { + } + [Test] + public void Test_1486() + { + } + [Test] + public void Test_1487() + { + } + [Test] + public void Test_1488() + { + } + [Test] + public void Test_1489() + { + } + [Test] + public void Test_1490() + { + } + [Test] + public void Test_1491() + { + } + [Test] + public void Test_1492() + { + } + [Test] + public void Test_1493() + { + } + [Test] + public void Test_1494() + { + } + [Test] + public void Test_1495() + { + } + [Test] + public void Test_1496() + { + } + [Test] + public void Test_1497() + { + } + [Test] + public void Test_1498() + { + } + [Test] + public void Test_1499() + { + } + [Test] + public void Test_1500() + { + } + [Test] + public void Test_1501() + { + } + [Test] + public void Test_1502() + { + } + [Test] + public void Test_1503() + { + } + [Test] + public void Test_1504() + { + } + [Test] + public void Test_1505() + { + } + [Test] + public void Test_1506() + { + } + [Test] + public void Test_1507() + { + } + [Test] + public void Test_1508() + { + } + [Test] + public void Test_1509() + { + } + [Test] + public void Test_1510() + { + } + [Test] + public void Test_1511() + { + } + [Test] + public void Test_1512() + { + } + [Test] + public void Test_1513() + { + } + [Test] + public void Test_1514() + { + } + [Test] + public void Test_1515() + { + } + [Test] + public void Test_1516() + { + } + [Test] + public void Test_1517() + { + } + [Test] + public void Test_1518() + { + } + [Test] + public void Test_1519() + { + } + [Test] + public void Test_1520() + { + } + [Test] + public void Test_1521() + { + } + [Test] + public void Test_1522() + { + } + [Test] + public void Test_1523() + { + } + [Test] + public void Test_1524() + { + } + [Test] + public void Test_1525() + { + } + [Test] + public void Test_1526() + { + } + [Test] + public void Test_1527() + { + } + [Test] + public void Test_1528() + { + } + [Test] + public void Test_1529() + { + } + [Test] + public void Test_1530() + { + } + [Test] + public void Test_1531() + { + } + [Test] + public void Test_1532() + { + } + [Test] + public void Test_1533() + { + } + [Test] + public void Test_1534() + { + } + [Test] + public void Test_1535() + { + } + [Test] + public void Test_1536() + { + } + [Test] + public void Test_1537() + { + } + [Test] + public void Test_1538() + { + } + [Test] + public void Test_1539() + { + } + [Test] + public void Test_1540() + { + } + [Test] + public void Test_1541() + { + } + [Test] + public void Test_1542() + { + } + [Test] + public void Test_1543() + { + } + [Test] + public void Test_1544() + { + } + [Test] + public void Test_1545() + { + } + [Test] + public void Test_1546() + { + } + [Test] + public void Test_1547() + { + } + [Test] + public void Test_1548() + { + } + [Test] + public void Test_1549() + { + } + [Test] + public void Test_1550() + { + } + [Test] + public void Test_1551() + { + } + [Test] + public void Test_1552() + { + } + [Test] + public void Test_1553() + { + } + [Test] + public void Test_1554() + { + } + [Test] + public void Test_1555() + { + } + [Test] + public void Test_1556() + { + } + [Test] + public void Test_1557() + { + } + [Test] + public void Test_1558() + { + } + [Test] + public void Test_1559() + { + } + [Test] + public void Test_1560() + { + } + [Test] + public void Test_1561() + { + } + [Test] + public void Test_1562() + { + } + [Test] + public void Test_1563() + { + } + [Test] + public void Test_1564() + { + } + [Test] + public void Test_1565() + { + } + [Test] + public void Test_1566() + { + } + [Test] + public void Test_1567() + { + } + [Test] + public void Test_1568() + { + } + [Test] + public void Test_1569() + { + } + [Test] + public void Test_1570() + { + } + [Test] + public void Test_1571() + { + } + [Test] + public void Test_1572() + { + } + [Test] + public void Test_1573() + { + } + [Test] + public void Test_1574() + { + } + [Test] + public void Test_1575() + { + } + [Test] + public void Test_1576() + { + } + [Test] + public void Test_1577() + { + } + [Test] + public void Test_1578() + { + } + [Test] + public void Test_1579() + { + } + [Test] + public void Test_1580() + { + } + [Test] + public void Test_1581() + { + } + [Test] + public void Test_1582() + { + } + [Test] + public void Test_1583() + { + } + [Test] + public void Test_1584() + { + } + [Test] + public void Test_1585() + { + } + [Test] + public void Test_1586() + { + } + [Test] + public void Test_1587() + { + } + [Test] + public void Test_1588() + { + } + [Test] + public void Test_1589() + { + } + [Test] + public void Test_1590() + { + } + [Test] + public void Test_1591() + { + } + [Test] + public void Test_1592() + { + } + [Test] + public void Test_1593() + { + } + [Test] + public void Test_1594() + { + } + [Test] + public void Test_1595() + { + } + [Test] + public void Test_1596() + { + } + [Test] + public void Test_1597() + { + } + [Test] + public void Test_1598() + { + } + [Test] + public void Test_1599() + { + } + [Test] + public void Test_1600() + { + } + [Test] + public void Test_1601() + { + } + [Test] + public void Test_1602() + { + } + [Test] + public void Test_1603() + { + } + [Test] + public void Test_1604() + { + } + [Test] + public void Test_1605() + { + } + [Test] + public void Test_1606() + { + } + [Test] + public void Test_1607() + { + } + [Test] + public void Test_1608() + { + } + [Test] + public void Test_1609() + { + } + [Test] + public void Test_1610() + { + } + [Test] + public void Test_1611() + { + } + [Test] + public void Test_1612() + { + } + [Test] + public void Test_1613() + { + } + [Test] + public void Test_1614() + { + } + [Test] + public void Test_1615() + { + } + [Test] + public void Test_1616() + { + } + [Test] + public void Test_1617() + { + } + [Test] + public void Test_1618() + { + } + [Test] + public void Test_1619() + { + } + [Test] + public void Test_1620() + { + } + [Test] + public void Test_1621() + { + } + [Test] + public void Test_1622() + { + } + [Test] + public void Test_1623() + { + } + [Test] + public void Test_1624() + { + } + [Test] + public void Test_1625() + { + } + [Test] + public void Test_1626() + { + } + [Test] + public void Test_1627() + { + } + [Test] + public void Test_1628() + { + } + [Test] + public void Test_1629() + { + } + [Test] + public void Test_1630() + { + } + [Test] + public void Test_1631() + { + } + [Test] + public void Test_1632() + { + } + [Test] + public void Test_1633() + { + } + [Test] + public void Test_1634() + { + } + [Test] + public void Test_1635() + { + } + [Test] + public void Test_1636() + { + } + [Test] + public void Test_1637() + { + } + [Test] + public void Test_1638() + { + } + [Test] + public void Test_1639() + { + } + [Test] + public void Test_1640() + { + } + [Test] + public void Test_1641() + { + } + [Test] + public void Test_1642() + { + } + [Test] + public void Test_1643() + { + } + [Test] + public void Test_1644() + { + } + [Test] + public void Test_1645() + { + } + [Test] + public void Test_1646() + { + } + [Test] + public void Test_1647() + { + } + [Test] + public void Test_1648() + { + } + [Test] + public void Test_1649() + { + } + [Test] + public void Test_1650() + { + } + [Test] + public void Test_1651() + { + } + [Test] + public void Test_1652() + { + } + [Test] + public void Test_1653() + { + } + [Test] + public void Test_1654() + { + } + [Test] + public void Test_1655() + { + } + [Test] + public void Test_1656() + { + } + [Test] + public void Test_1657() + { + } + [Test] + public void Test_1658() + { + } + [Test] + public void Test_1659() + { + } + [Test] + public void Test_1660() + { + } + [Test] + public void Test_1661() + { + } + [Test] + public void Test_1662() + { + } + [Test] + public void Test_1663() + { + } + [Test] + public void Test_1664() + { + } + [Test] + public void Test_1665() + { + } + [Test] + public void Test_1666() + { + } + [Test] + public void Test_1667() + { + } + [Test] + public void Test_1668() + { + } + [Test] + public void Test_1669() + { + } + [Test] + public void Test_1670() + { + } + [Test] + public void Test_1671() + { + } + [Test] + public void Test_1672() + { + } + [Test] + public void Test_1673() + { + } + [Test] + public void Test_1674() + { + } + [Test] + public void Test_1675() + { + } + [Test] + public void Test_1676() + { + } + [Test] + public void Test_1677() + { + } + [Test] + public void Test_1678() + { + } + [Test] + public void Test_1679() + { + } + [Test] + public void Test_1680() + { + } + [Test] + public void Test_1681() + { + } + [Test] + public void Test_1682() + { + } + [Test] + public void Test_1683() + { + } + [Test] + public void Test_1684() + { + } + [Test] + public void Test_1685() + { + } + [Test] + public void Test_1686() + { + } + [Test] + public void Test_1687() + { + } + [Test] + public void Test_1688() + { + } + [Test] + public void Test_1689() + { + } + [Test] + public void Test_1690() + { + } + [Test] + public void Test_1691() + { + } + [Test] + public void Test_1692() + { + } + [Test] + public void Test_1693() + { + } + [Test] + public void Test_1694() + { + } + [Test] + public void Test_1695() + { + } + [Test] + public void Test_1696() + { + } + [Test] + public void Test_1697() + { + } + [Test] + public void Test_1698() + { + } + [Test] + public void Test_1699() + { + } + [Test] + public void Test_1700() + { + } + [Test] + public void Test_1701() + { + } + [Test] + public void Test_1702() + { + } + [Test] + public void Test_1703() + { + } + [Test] + public void Test_1704() + { + } + [Test] + public void Test_1705() + { + } + [Test] + public void Test_1706() + { + } + [Test] + public void Test_1707() + { + } + [Test] + public void Test_1708() + { + } + [Test] + public void Test_1709() + { + } + [Test] + public void Test_1710() + { + } + [Test] + public void Test_1711() + { + } + [Test] + public void Test_1712() + { + } + [Test] + public void Test_1713() + { + } + [Test] + public void Test_1714() + { + } + [Test] + public void Test_1715() + { + } + [Test] + public void Test_1716() + { + } + [Test] + public void Test_1717() + { + } + [Test] + public void Test_1718() + { + } + [Test] + public void Test_1719() + { + } + [Test] + public void Test_1720() + { + } + [Test] + public void Test_1721() + { + } + [Test] + public void Test_1722() + { + } + [Test] + public void Test_1723() + { + } + [Test] + public void Test_1724() + { + } + [Test] + public void Test_1725() + { + } + [Test] + public void Test_1726() + { + } + [Test] + public void Test_1727() + { + } + [Test] + public void Test_1728() + { + } + [Test] + public void Test_1729() + { + } + [Test] + public void Test_1730() + { + } + [Test] + public void Test_1731() + { + } + [Test] + public void Test_1732() + { + } + [Test] + public void Test_1733() + { + } + [Test] + public void Test_1734() + { + } + [Test] + public void Test_1735() + { + } + [Test] + public void Test_1736() + { + } + [Test] + public void Test_1737() + { + } + [Test] + public void Test_1738() + { + } + [Test] + public void Test_1739() + { + } + [Test] + public void Test_1740() + { + } + [Test] + public void Test_1741() + { + } + [Test] + public void Test_1742() + { + } + [Test] + public void Test_1743() + { + } + [Test] + public void Test_1744() + { + } + [Test] + public void Test_1745() + { + } + [Test] + public void Test_1746() + { + } + [Test] + public void Test_1747() + { + } + [Test] + public void Test_1748() + { + } + [Test] + public void Test_1749() + { + } + [Test] + public void Test_1750() + { + } + [Test] + public void Test_1751() + { + } + [Test] + public void Test_1752() + { + } + [Test] + public void Test_1753() + { + } + [Test] + public void Test_1754() + { + } + [Test] + public void Test_1755() + { + } + [Test] + public void Test_1756() + { + } + [Test] + public void Test_1757() + { + } + [Test] + public void Test_1758() + { + } + [Test] + public void Test_1759() + { + } + [Test] + public void Test_1760() + { + } + [Test] + public void Test_1761() + { + } + [Test] + public void Test_1762() + { + } + [Test] + public void Test_1763() + { + } + [Test] + public void Test_1764() + { + } + [Test] + public void Test_1765() + { + } + [Test] + public void Test_1766() + { + } + [Test] + public void Test_1767() + { + } + [Test] + public void Test_1768() + { + } + [Test] + public void Test_1769() + { + } + [Test] + public void Test_1770() + { + } + [Test] + public void Test_1771() + { + } + [Test] + public void Test_1772() + { + } + [Test] + public void Test_1773() + { + } + [Test] + public void Test_1774() + { + } + [Test] + public void Test_1775() + { + } + [Test] + public void Test_1776() + { + } + [Test] + public void Test_1777() + { + } + [Test] + public void Test_1778() + { + } + [Test] + public void Test_1779() + { + } + [Test] + public void Test_1780() + { + } + [Test] + public void Test_1781() + { + } + [Test] + public void Test_1782() + { + } + [Test] + public void Test_1783() + { + } + [Test] + public void Test_1784() + { + } + [Test] + public void Test_1785() + { + } + [Test] + public void Test_1786() + { + } + [Test] + public void Test_1787() + { + } + [Test] + public void Test_1788() + { + } + [Test] + public void Test_1789() + { + } + [Test] + public void Test_1790() + { + } + [Test] + public void Test_1791() + { + } + [Test] + public void Test_1792() + { + } + [Test] + public void Test_1793() + { + } + [Test] + public void Test_1794() + { + } + [Test] + public void Test_1795() + { + } + [Test] + public void Test_1796() + { + } + [Test] + public void Test_1797() + { + } + [Test] + public void Test_1798() + { + } + [Test] + public void Test_1799() + { + } + [Test] + public void Test_1800() + { + } + [Test] + public void Test_1801() + { + } + [Test] + public void Test_1802() + { + } + [Test] + public void Test_1803() + { + } + [Test] + public void Test_1804() + { + } + [Test] + public void Test_1805() + { + } + [Test] + public void Test_1806() + { + } + [Test] + public void Test_1807() + { + } + [Test] + public void Test_1808() + { + } + [Test] + public void Test_1809() + { + } + [Test] + public void Test_1810() + { + } + [Test] + public void Test_1811() + { + } + [Test] + public void Test_1812() + { + } + [Test] + public void Test_1813() + { + } + [Test] + public void Test_1814() + { + } + [Test] + public void Test_1815() + { + } + [Test] + public void Test_1816() + { + } + [Test] + public void Test_1817() + { + } + [Test] + public void Test_1818() + { + } + [Test] + public void Test_1819() + { + } + [Test] + public void Test_1820() + { + } + [Test] + public void Test_1821() + { + } + [Test] + public void Test_1822() + { + } + [Test] + public void Test_1823() + { + } + [Test] + public void Test_1824() + { + } + [Test] + public void Test_1825() + { + } + [Test] + public void Test_1826() + { + } + [Test] + public void Test_1827() + { + } + [Test] + public void Test_1828() + { + } + [Test] + public void Test_1829() + { + } + [Test] + public void Test_1830() + { + } + [Test] + public void Test_1831() + { + } + [Test] + public void Test_1832() + { + } + [Test] + public void Test_1833() + { + } + [Test] + public void Test_1834() + { + } + [Test] + public void Test_1835() + { + } + [Test] + public void Test_1836() + { + } + [Test] + public void Test_1837() + { + } + [Test] + public void Test_1838() + { + } + [Test] + public void Test_1839() + { + } + [Test] + public void Test_1840() + { + } + [Test] + public void Test_1841() + { + } + [Test] + public void Test_1842() + { + } + [Test] + public void Test_1843() + { + } + [Test] + public void Test_1844() + { + } + [Test] + public void Test_1845() + { + } + [Test] + public void Test_1846() + { + } + [Test] + public void Test_1847() + { + } + [Test] + public void Test_1848() + { + } + [Test] + public void Test_1849() + { + } + [Test] + public void Test_1850() + { + } + [Test] + public void Test_1851() + { + } + [Test] + public void Test_1852() + { + } + [Test] + public void Test_1853() + { + } + [Test] + public void Test_1854() + { + } + [Test] + public void Test_1855() + { + } + [Test] + public void Test_1856() + { + } + [Test] + public void Test_1857() + { + } + [Test] + public void Test_1858() + { + } + [Test] + public void Test_1859() + { + } + [Test] + public void Test_1860() + { + } + [Test] + public void Test_1861() + { + } + [Test] + public void Test_1862() + { + } + [Test] + public void Test_1863() + { + } + [Test] + public void Test_1864() + { + } + [Test] + public void Test_1865() + { + } + [Test] + public void Test_1866() + { + } + [Test] + public void Test_1867() + { + } + [Test] + public void Test_1868() + { + } + [Test] + public void Test_1869() + { + } + [Test] + public void Test_1870() + { + } + [Test] + public void Test_1871() + { + } + [Test] + public void Test_1872() + { + } + [Test] + public void Test_1873() + { + } + [Test] + public void Test_1874() + { + } + [Test] + public void Test_1875() + { + } + [Test] + public void Test_1876() + { + } + [Test] + public void Test_1877() + { + } + [Test] + public void Test_1878() + { + } + [Test] + public void Test_1879() + { + } + [Test] + public void Test_1880() + { + } + [Test] + public void Test_1881() + { + } + [Test] + public void Test_1882() + { + } + [Test] + public void Test_1883() + { + } + [Test] + public void Test_1884() + { + } + [Test] + public void Test_1885() + { + } + [Test] + public void Test_1886() + { + } + [Test] + public void Test_1887() + { + } + [Test] + public void Test_1888() + { + } + [Test] + public void Test_1889() + { + } + [Test] + public void Test_1890() + { + } + [Test] + public void Test_1891() + { + } + [Test] + public void Test_1892() + { + } + [Test] + public void Test_1893() + { + } + [Test] + public void Test_1894() + { + } + [Test] + public void Test_1895() + { + } + [Test] + public void Test_1896() + { + } + [Test] + public void Test_1897() + { + } + [Test] + public void Test_1898() + { + } + [Test] + public void Test_1899() + { + } + [Test] + public void Test_1900() + { + } + [Test] + public void Test_1901() + { + } + [Test] + public void Test_1902() + { + } + [Test] + public void Test_1903() + { + } + [Test] + public void Test_1904() + { + } + [Test] + public void Test_1905() + { + } + [Test] + public void Test_1906() + { + } + [Test] + public void Test_1907() + { + } + [Test] + public void Test_1908() + { + } + [Test] + public void Test_1909() + { + } + [Test] + public void Test_1910() + { + } + [Test] + public void Test_1911() + { + } + [Test] + public void Test_1912() + { + } + [Test] + public void Test_1913() + { + } + [Test] + public void Test_1914() + { + } + [Test] + public void Test_1915() + { + } + [Test] + public void Test_1916() + { + } + [Test] + public void Test_1917() + { + } + [Test] + public void Test_1918() + { + } + [Test] + public void Test_1919() + { + } + [Test] + public void Test_1920() + { + } + [Test] + public void Test_1921() + { + } + [Test] + public void Test_1922() + { + } + [Test] + public void Test_1923() + { + } + [Test] + public void Test_1924() + { + } + [Test] + public void Test_1925() + { + } + [Test] + public void Test_1926() + { + } + [Test] + public void Test_1927() + { + } + [Test] + public void Test_1928() + { + } + [Test] + public void Test_1929() + { + } + [Test] + public void Test_1930() + { + } + [Test] + public void Test_1931() + { + } + [Test] + public void Test_1932() + { + } + [Test] + public void Test_1933() + { + } + [Test] + public void Test_1934() + { + } + [Test] + public void Test_1935() + { + } + [Test] + public void Test_1936() + { + } + [Test] + public void Test_1937() + { + } + [Test] + public void Test_1938() + { + } + [Test] + public void Test_1939() + { + } + [Test] + public void Test_1940() + { + } + [Test] + public void Test_1941() + { + } + [Test] + public void Test_1942() + { + } + [Test] + public void Test_1943() + { + } + [Test] + public void Test_1944() + { + } + [Test] + public void Test_1945() + { + } + [Test] + public void Test_1946() + { + } + [Test] + public void Test_1947() + { + } + [Test] + public void Test_1948() + { + } + [Test] + public void Test_1949() + { + } + [Test] + public void Test_1950() + { + } + [Test] + public void Test_1951() + { + } + [Test] + public void Test_1952() + { + } + [Test] + public void Test_1953() + { + } + [Test] + public void Test_1954() + { + } + [Test] + public void Test_1955() + { + } + [Test] + public void Test_1956() + { + } + [Test] + public void Test_1957() + { + } + [Test] + public void Test_1958() + { + } + [Test] + public void Test_1959() + { + } + [Test] + public void Test_1960() + { + } + [Test] + public void Test_1961() + { + } + [Test] + public void Test_1962() + { + } + [Test] + public void Test_1963() + { + } + [Test] + public void Test_1964() + { + } + [Test] + public void Test_1965() + { + } + [Test] + public void Test_1966() + { + } + [Test] + public void Test_1967() + { + } + [Test] + public void Test_1968() + { + } + [Test] + public void Test_1969() + { + } + [Test] + public void Test_1970() + { + } + [Test] + public void Test_1971() + { + } + [Test] + public void Test_1972() + { + } + [Test] + public void Test_1973() + { + } + [Test] + public void Test_1974() + { + } + [Test] + public void Test_1975() + { + } + [Test] + public void Test_1976() + { + } + [Test] + public void Test_1977() + { + } + [Test] + public void Test_1978() + { + } + [Test] + public void Test_1979() + { + } + [Test] + public void Test_1980() + { + } + [Test] + public void Test_1981() + { + } + [Test] + public void Test_1982() + { + } + [Test] + public void Test_1983() + { + } + [Test] + public void Test_1984() + { + } + [Test] + public void Test_1985() + { + } + [Test] + public void Test_1986() + { + } + [Test] + public void Test_1987() + { + } + [Test] + public void Test_1988() + { + } + [Test] + public void Test_1989() + { + } + [Test] + public void Test_1990() + { + } + [Test] + public void Test_1991() + { + } + [Test] + public void Test_1992() + { + } + [Test] + public void Test_1993() + { + } + [Test] + public void Test_1994() + { + } + [Test] + public void Test_1995() + { + } + [Test] + public void Test_1996() + { + } + [Test] + public void Test_1997() + { + } + [Test] + public void Test_1998() + { + } + [Test] + public void Test_1999() + { + } + [Test] + public void Test_2000() + { + } + [Test] + public void Test_2001() + { + } + [Test] + public void Test_2002() + { + } + [Test] + public void Test_2003() + { + } + [Test] + public void Test_2004() + { + } + [Test] + public void Test_2005() + { + } + [Test] + public void Test_2006() + { + } + [Test] + public void Test_2007() + { + } + [Test] + public void Test_2008() + { + } + [Test] + public void Test_2009() + { + } + [Test] + public void Test_2010() + { + } + [Test] + public void Test_2011() + { + } + [Test] + public void Test_2012() + { + } + [Test] + public void Test_2013() + { + } + [Test] + public void Test_2014() + { + } + [Test] + public void Test_2015() + { + } + [Test] + public void Test_2016() + { + } + [Test] + public void Test_2017() + { + } + [Test] + public void Test_2018() + { + } + [Test] + public void Test_2019() + { + } + [Test] + public void Test_2020() + { + } + [Test] + public void Test_2021() + { + } + [Test] + public void Test_2022() + { + } + [Test] + public void Test_2023() + { + } + [Test] + public void Test_2024() + { + } + [Test] + public void Test_2025() + { + } + [Test] + public void Test_2026() + { + } + [Test] + public void Test_2027() + { + } + [Test] + public void Test_2028() + { + } + [Test] + public void Test_2029() + { + } + [Test] + public void Test_2030() + { + } + [Test] + public void Test_2031() + { + } + [Test] + public void Test_2032() + { + } + [Test] + public void Test_2033() + { + } + [Test] + public void Test_2034() + { + } + [Test] + public void Test_2035() + { + } + [Test] + public void Test_2036() + { + } + [Test] + public void Test_2037() + { + } + [Test] + public void Test_2038() + { + } + [Test] + public void Test_2039() + { + } + [Test] + public void Test_2040() + { + } + [Test] + public void Test_2041() + { + } + [Test] + public void Test_2042() + { + } + [Test] + public void Test_2043() + { + } + [Test] + public void Test_2044() + { + } + [Test] + public void Test_2045() + { + } + [Test] + public void Test_2046() + { + } + [Test] + public void Test_2047() + { + } + [Test] + public void Test_2048() + { + } + [Test] + public void Test_2049() + { + } + [Test] + public void Test_2050() + { + } + [Test] + public void Test_2051() + { + } + [Test] + public void Test_2052() + { + } + [Test] + public void Test_2053() + { + } + [Test] + public void Test_2054() + { + } + [Test] + public void Test_2055() + { + } + [Test] + public void Test_2056() + { + } + [Test] + public void Test_2057() + { + } + [Test] + public void Test_2058() + { + } + [Test] + public void Test_2059() + { + } + [Test] + public void Test_2060() + { + } + [Test] + public void Test_2061() + { + } + [Test] + public void Test_2062() + { + } + [Test] + public void Test_2063() + { + } + [Test] + public void Test_2064() + { + } + [Test] + public void Test_2065() + { + } + [Test] + public void Test_2066() + { + } + [Test] + public void Test_2067() + { + } + [Test] + public void Test_2068() + { + } + [Test] + public void Test_2069() + { + } + [Test] + public void Test_2070() + { + } + [Test] + public void Test_2071() + { + } + [Test] + public void Test_2072() + { + } + [Test] + public void Test_2073() + { + } + [Test] + public void Test_2074() + { + } + [Test] + public void Test_2075() + { + } + [Test] + public void Test_2076() + { + } + [Test] + public void Test_2077() + { + } + [Test] + public void Test_2078() + { + } + [Test] + public void Test_2079() + { + } + [Test] + public void Test_2080() + { + } + [Test] + public void Test_2081() + { + } + [Test] + public void Test_2082() + { + } + [Test] + public void Test_2083() + { + } + [Test] + public void Test_2084() + { + } + [Test] + public void Test_2085() + { + } + [Test] + public void Test_2086() + { + } + [Test] + public void Test_2087() + { + } + [Test] + public void Test_2088() + { + } + [Test] + public void Test_2089() + { + } + [Test] + public void Test_2090() + { + } + [Test] + public void Test_2091() + { + } + [Test] + public void Test_2092() + { + } + [Test] + public void Test_2093() + { + } + [Test] + public void Test_2094() + { + } + [Test] + public void Test_2095() + { + } + [Test] + public void Test_2096() + { + } + [Test] + public void Test_2097() + { + } + [Test] + public void Test_2098() + { + } + [Test] + public void Test_2099() + { + } + [Test] + public void Test_2100() + { + } + [Test] + public void Test_2101() + { + } + [Test] + public void Test_2102() + { + } + [Test] + public void Test_2103() + { + } + [Test] + public void Test_2104() + { + } + [Test] + public void Test_2105() + { + } + [Test] + public void Test_2106() + { + } + [Test] + public void Test_2107() + { + } + [Test] + public void Test_2108() + { + } + [Test] + public void Test_2109() + { + } + [Test] + public void Test_2110() + { + } + [Test] + public void Test_2111() + { + } + [Test] + public void Test_2112() + { + } + [Test] + public void Test_2113() + { + } + [Test] + public void Test_2114() + { + } + [Test] + public void Test_2115() + { + } + [Test] + public void Test_2116() + { + } + [Test] + public void Test_2117() + { + } + [Test] + public void Test_2118() + { + } + [Test] + public void Test_2119() + { + } + [Test] + public void Test_2120() + { + } + [Test] + public void Test_2121() + { + } + [Test] + public void Test_2122() + { + } + [Test] + public void Test_2123() + { + } + [Test] + public void Test_2124() + { + } + [Test] + public void Test_2125() + { + } + [Test] + public void Test_2126() + { + } + [Test] + public void Test_2127() + { + } + [Test] + public void Test_2128() + { + } + [Test] + public void Test_2129() + { + } + [Test] + public void Test_2130() + { + } + [Test] + public void Test_2131() + { + } + [Test] + public void Test_2132() + { + } + [Test] + public void Test_2133() + { + } + [Test] + public void Test_2134() + { + } + [Test] + public void Test_2135() + { + } + [Test] + public void Test_2136() + { + } + [Test] + public void Test_2137() + { + } + [Test] + public void Test_2138() + { + } + [Test] + public void Test_2139() + { + } + [Test] + public void Test_2140() + { + } + [Test] + public void Test_2141() + { + } + [Test] + public void Test_2142() + { + } + [Test] + public void Test_2143() + { + } + [Test] + public void Test_2144() + { + } + [Test] + public void Test_2145() + { + } + [Test] + public void Test_2146() + { + } + [Test] + public void Test_2147() + { + } + [Test] + public void Test_2148() + { + } + [Test] + public void Test_2149() + { + } + [Test] + public void Test_2150() + { + } + [Test] + public void Test_2151() + { + } + [Test] + public void Test_2152() + { + } + [Test] + public void Test_2153() + { + } + [Test] + public void Test_2154() + { + } + [Test] + public void Test_2155() + { + } + [Test] + public void Test_2156() + { + } + [Test] + public void Test_2157() + { + } + [Test] + public void Test_2158() + { + } + [Test] + public void Test_2159() + { + } + [Test] + public void Test_2160() + { + } + [Test] + public void Test_2161() + { + } + [Test] + public void Test_2162() + { + } + [Test] + public void Test_2163() + { + } + [Test] + public void Test_2164() + { + } + [Test] + public void Test_2165() + { + } + [Test] + public void Test_2166() + { + } + [Test] + public void Test_2167() + { + } + [Test] + public void Test_2168() + { + } + [Test] + public void Test_2169() + { + } + [Test] + public void Test_2170() + { + } + [Test] + public void Test_2171() + { + } + [Test] + public void Test_2172() + { + } + [Test] + public void Test_2173() + { + } + [Test] + public void Test_2174() + { + } + [Test] + public void Test_2175() + { + } + [Test] + public void Test_2176() + { + } + [Test] + public void Test_2177() + { + } + [Test] + public void Test_2178() + { + } + [Test] + public void Test_2179() + { + } + [Test] + public void Test_2180() + { + } + [Test] + public void Test_2181() + { + } + [Test] + public void Test_2182() + { + } + [Test] + public void Test_2183() + { + } + [Test] + public void Test_2184() + { + } + [Test] + public void Test_2185() + { + } + [Test] + public void Test_2186() + { + } + [Test] + public void Test_2187() + { + } + [Test] + public void Test_2188() + { + } + [Test] + public void Test_2189() + { + } + [Test] + public void Test_2190() + { + } + [Test] + public void Test_2191() + { + } + [Test] + public void Test_2192() + { + } + [Test] + public void Test_2193() + { + } + [Test] + public void Test_2194() + { + } + [Test] + public void Test_2195() + { + } + [Test] + public void Test_2196() + { + } + [Test] + public void Test_2197() + { + } + [Test] + public void Test_2198() + { + } + [Test] + public void Test_2199() + { + } + [Test] + public void Test_2200() + { + } + [Test] + public void Test_2201() + { + } + [Test] + public void Test_2202() + { + } + [Test] + public void Test_2203() + { + } + [Test] + public void Test_2204() + { + } + [Test] + public void Test_2205() + { + } + [Test] + public void Test_2206() + { + } + [Test] + public void Test_2207() + { + } + [Test] + public void Test_2208() + { + } + [Test] + public void Test_2209() + { + } + [Test] + public void Test_2210() + { + } + [Test] + public void Test_2211() + { + } + [Test] + public void Test_2212() + { + } + [Test] + public void Test_2213() + { + } + [Test] + public void Test_2214() + { + } + [Test] + public void Test_2215() + { + } + [Test] + public void Test_2216() + { + } + [Test] + public void Test_2217() + { + } + [Test] + public void Test_2218() + { + } + [Test] + public void Test_2219() + { + } + [Test] + public void Test_2220() + { + } + [Test] + public void Test_2221() + { + } + [Test] + public void Test_2222() + { + } + [Test] + public void Test_2223() + { + } + [Test] + public void Test_2224() + { + } + [Test] + public void Test_2225() + { + } + [Test] + public void Test_2226() + { + } + [Test] + public void Test_2227() + { + } + [Test] + public void Test_2228() + { + } + [Test] + public void Test_2229() + { + } + [Test] + public void Test_2230() + { + } + [Test] + public void Test_2231() + { + } + [Test] + public void Test_2232() + { + } + [Test] + public void Test_2233() + { + } + [Test] + public void Test_2234() + { + } + [Test] + public void Test_2235() + { + } + [Test] + public void Test_2236() + { + } + [Test] + public void Test_2237() + { + } + [Test] + public void Test_2238() + { + } + [Test] + public void Test_2239() + { + } + [Test] + public void Test_2240() + { + } + [Test] + public void Test_2241() + { + } + [Test] + public void Test_2242() + { + } + [Test] + public void Test_2243() + { + } + [Test] + public void Test_2244() + { + } + [Test] + public void Test_2245() + { + } + [Test] + public void Test_2246() + { + } + [Test] + public void Test_2247() + { + } + [Test] + public void Test_2248() + { + } + [Test] + public void Test_2249() + { + } + [Test] + public void Test_2250() + { + } + [Test] + public void Test_2251() + { + } + [Test] + public void Test_2252() + { + } + [Test] + public void Test_2253() + { + } + [Test] + public void Test_2254() + { + } + [Test] + public void Test_2255() + { + } + [Test] + public void Test_2256() + { + } + [Test] + public void Test_2257() + { + } + [Test] + public void Test_2258() + { + } + [Test] + public void Test_2259() + { + } + [Test] + public void Test_2260() + { + } + [Test] + public void Test_2261() + { + } + [Test] + public void Test_2262() + { + } + [Test] + public void Test_2263() + { + } + [Test] + public void Test_2264() + { + } + [Test] + public void Test_2265() + { + } + [Test] + public void Test_2266() + { + } + [Test] + public void Test_2267() + { + } + [Test] + public void Test_2268() + { + } + [Test] + public void Test_2269() + { + } + [Test] + public void Test_2270() + { + } + [Test] + public void Test_2271() + { + } + [Test] + public void Test_2272() + { + } + [Test] + public void Test_2273() + { + } + [Test] + public void Test_2274() + { + } + [Test] + public void Test_2275() + { + } + [Test] + public void Test_2276() + { + } + [Test] + public void Test_2277() + { + } + [Test] + public void Test_2278() + { + } + [Test] + public void Test_2279() + { + } + [Test] + public void Test_2280() + { + } + [Test] + public void Test_2281() + { + } + [Test] + public void Test_2282() + { + } + [Test] + public void Test_2283() + { + } + [Test] + public void Test_2284() + { + } + [Test] + public void Test_2285() + { + } + [Test] + public void Test_2286() + { + } + [Test] + public void Test_2287() + { + } + [Test] + public void Test_2288() + { + } + [Test] + public void Test_2289() + { + } + [Test] + public void Test_2290() + { + } + [Test] + public void Test_2291() + { + } + [Test] + public void Test_2292() + { + } + [Test] + public void Test_2293() + { + } + [Test] + public void Test_2294() + { + } + [Test] + public void Test_2295() + { + } + [Test] + public void Test_2296() + { + } + [Test] + public void Test_2297() + { + } + [Test] + public void Test_2298() + { + } + [Test] + public void Test_2299() + { + } + [Test] + public void Test_2300() + { + } + [Test] + public void Test_2301() + { + } + [Test] + public void Test_2302() + { + } + [Test] + public void Test_2303() + { + } + [Test] + public void Test_2304() + { + } + [Test] + public void Test_2305() + { + } + [Test] + public void Test_2306() + { + } + [Test] + public void Test_2307() + { + } + [Test] + public void Test_2308() + { + } + [Test] + public void Test_2309() + { + } + [Test] + public void Test_2310() + { + } + [Test] + public void Test_2311() + { + } + [Test] + public void Test_2312() + { + } + [Test] + public void Test_2313() + { + } + [Test] + public void Test_2314() + { + } + [Test] + public void Test_2315() + { + } + [Test] + public void Test_2316() + { + } + [Test] + public void Test_2317() + { + } + [Test] + public void Test_2318() + { + } + [Test] + public void Test_2319() + { + } + [Test] + public void Test_2320() + { + } + [Test] + public void Test_2321() + { + } + [Test] + public void Test_2322() + { + } + [Test] + public void Test_2323() + { + } + [Test] + public void Test_2324() + { + } + [Test] + public void Test_2325() + { + } + [Test] + public void Test_2326() + { + } + [Test] + public void Test_2327() + { + } + [Test] + public void Test_2328() + { + } + [Test] + public void Test_2329() + { + } + [Test] + public void Test_2330() + { + } + [Test] + public void Test_2331() + { + } + [Test] + public void Test_2332() + { + } + [Test] + public void Test_2333() + { + } + [Test] + public void Test_2334() + { + } + [Test] + public void Test_2335() + { + } + [Test] + public void Test_2336() + { + } + [Test] + public void Test_2337() + { + } + [Test] + public void Test_2338() + { + } + [Test] + public void Test_2339() + { + } + [Test] + public void Test_2340() + { + } + [Test] + public void Test_2341() + { + } + [Test] + public void Test_2342() + { + } + [Test] + public void Test_2343() + { + } + [Test] + public void Test_2344() + { + } + [Test] + public void Test_2345() + { + } + [Test] + public void Test_2346() + { + } + [Test] + public void Test_2347() + { + } + [Test] + public void Test_2348() + { + } + [Test] + public void Test_2349() + { + } + [Test] + public void Test_2350() + { + } + [Test] + public void Test_2351() + { + } + [Test] + public void Test_2352() + { + } + [Test] + public void Test_2353() + { + } + [Test] + public void Test_2354() + { + } + [Test] + public void Test_2355() + { + } + [Test] + public void Test_2356() + { + } + [Test] + public void Test_2357() + { + } + [Test] + public void Test_2358() + { + } + [Test] + public void Test_2359() + { + } + [Test] + public void Test_2360() + { + } + [Test] + public void Test_2361() + { + } + [Test] + public void Test_2362() + { + } + [Test] + public void Test_2363() + { + } + [Test] + public void Test_2364() + { + } + [Test] + public void Test_2365() + { + } + [Test] + public void Test_2366() + { + } + [Test] + public void Test_2367() + { + } + [Test] + public void Test_2368() + { + } + [Test] + public void Test_2369() + { + } + [Test] + public void Test_2370() + { + } + [Test] + public void Test_2371() + { + } + [Test] + public void Test_2372() + { + } + [Test] + public void Test_2373() + { + } + [Test] + public void Test_2374() + { + } + [Test] + public void Test_2375() + { + } + [Test] + public void Test_2376() + { + } + [Test] + public void Test_2377() + { + } + [Test] + public void Test_2378() + { + } + [Test] + public void Test_2379() + { + } + [Test] + public void Test_2380() + { + } + [Test] + public void Test_2381() + { + } + [Test] + public void Test_2382() + { + } + [Test] + public void Test_2383() + { + } + [Test] + public void Test_2384() + { + } + [Test] + public void Test_2385() + { + } + [Test] + public void Test_2386() + { + } + [Test] + public void Test_2387() + { + } + [Test] + public void Test_2388() + { + } + [Test] + public void Test_2389() + { + } + [Test] + public void Test_2390() + { + } + [Test] + public void Test_2391() + { + } + [Test] + public void Test_2392() + { + } + [Test] + public void Test_2393() + { + } + [Test] + public void Test_2394() + { + } + [Test] + public void Test_2395() + { + } + [Test] + public void Test_2396() + { + } + [Test] + public void Test_2397() + { + } + [Test] + public void Test_2398() + { + } + [Test] + public void Test_2399() + { + } + [Test] + public void Test_2400() + { + } + [Test] + public void Test_2401() + { + } + [Test] + public void Test_2402() + { + } + [Test] + public void Test_2403() + { + } + [Test] + public void Test_2404() + { + } + [Test] + public void Test_2405() + { + } + [Test] + public void Test_2406() + { + } + [Test] + public void Test_2407() + { + } + [Test] + public void Test_2408() + { + } + [Test] + public void Test_2409() + { + } + [Test] + public void Test_2410() + { + } + [Test] + public void Test_2411() + { + } + [Test] + public void Test_2412() + { + } + [Test] + public void Test_2413() + { + } + [Test] + public void Test_2414() + { + } + [Test] + public void Test_2415() + { + } + [Test] + public void Test_2416() + { + } + [Test] + public void Test_2417() + { + } + [Test] + public void Test_2418() + { + } + [Test] + public void Test_2419() + { + } + [Test] + public void Test_2420() + { + } + [Test] + public void Test_2421() + { + } + [Test] + public void Test_2422() + { + } + [Test] + public void Test_2423() + { + } + [Test] + public void Test_2424() + { + } + [Test] + public void Test_2425() + { + } + [Test] + public void Test_2426() + { + } + [Test] + public void Test_2427() + { + } + [Test] + public void Test_2428() + { + } + [Test] + public void Test_2429() + { + } + [Test] + public void Test_2430() + { + } + [Test] + public void Test_2431() + { + } + [Test] + public void Test_2432() + { + } + [Test] + public void Test_2433() + { + } + [Test] + public void Test_2434() + { + } + [Test] + public void Test_2435() + { + } + [Test] + public void Test_2436() + { + } + [Test] + public void Test_2437() + { + } + [Test] + public void Test_2438() + { + } + [Test] + public void Test_2439() + { + } + [Test] + public void Test_2440() + { + } + [Test] + public void Test_2441() + { + } + [Test] + public void Test_2442() + { + } + [Test] + public void Test_2443() + { + } + [Test] + public void Test_2444() + { + } + [Test] + public void Test_2445() + { + } + [Test] + public void Test_2446() + { + } + [Test] + public void Test_2447() + { + } + [Test] + public void Test_2448() + { + } + [Test] + public void Test_2449() + { + } + [Test] + public void Test_2450() + { + } + [Test] + public void Test_2451() + { + } + [Test] + public void Test_2452() + { + } + [Test] + public void Test_2453() + { + } + [Test] + public void Test_2454() + { + } + [Test] + public void Test_2455() + { + } + [Test] + public void Test_2456() + { + } + [Test] + public void Test_2457() + { + } + [Test] + public void Test_2458() + { + } + [Test] + public void Test_2459() + { + } + [Test] + public void Test_2460() + { + } + [Test] + public void Test_2461() + { + } + [Test] + public void Test_2462() + { + } + [Test] + public void Test_2463() + { + } + [Test] + public void Test_2464() + { + } + [Test] + public void Test_2465() + { + } + [Test] + public void Test_2466() + { + } + [Test] + public void Test_2467() + { + } + [Test] + public void Test_2468() + { + } + [Test] + public void Test_2469() + { + } + [Test] + public void Test_2470() + { + } + [Test] + public void Test_2471() + { + } + [Test] + public void Test_2472() + { + } + [Test] + public void Test_2473() + { + } + [Test] + public void Test_2474() + { + } + [Test] + public void Test_2475() + { + } + [Test] + public void Test_2476() + { + } + [Test] + public void Test_2477() + { + } + [Test] + public void Test_2478() + { + } + [Test] + public void Test_2479() + { + } + [Test] + public void Test_2480() + { + } + [Test] + public void Test_2481() + { + } + [Test] + public void Test_2482() + { + } + [Test] + public void Test_2483() + { + } + [Test] + public void Test_2484() + { + } + [Test] + public void Test_2485() + { + } + [Test] + public void Test_2486() + { + } + [Test] + public void Test_2487() + { + } + [Test] + public void Test_2488() + { + } + [Test] + public void Test_2489() + { + } + [Test] + public void Test_2490() + { + } + [Test] + public void Test_2491() + { + } + [Test] + public void Test_2492() + { + } + [Test] + public void Test_2493() + { + } + [Test] + public void Test_2494() + { + } + [Test] + public void Test_2495() + { + } + [Test] + public void Test_2496() + { + } + [Test] + public void Test_2497() + { + } + [Test] + public void Test_2498() + { + } + [Test] + public void Test_2499() + { + } + [Test] + public void Test_2500() + { + } + [Test] + public void Test_2501() + { + } + [Test] + public void Test_2502() + { + } + [Test] + public void Test_2503() + { + } + [Test] + public void Test_2504() + { + } + [Test] + public void Test_2505() + { + } + [Test] + public void Test_2506() + { + } + [Test] + public void Test_2507() + { + } + [Test] + public void Test_2508() + { + } + [Test] + public void Test_2509() + { + } + [Test] + public void Test_2510() + { + } + [Test] + public void Test_2511() + { + } + [Test] + public void Test_2512() + { + } + [Test] + public void Test_2513() + { + } + [Test] + public void Test_2514() + { + } + [Test] + public void Test_2515() + { + } + [Test] + public void Test_2516() + { + } + [Test] + public void Test_2517() + { + } + [Test] + public void Test_2518() + { + } + [Test] + public void Test_2519() + { + } + [Test] + public void Test_2520() + { + } + [Test] + public void Test_2521() + { + } + [Test] + public void Test_2522() + { + } + [Test] + public void Test_2523() + { + } + [Test] + public void Test_2524() + { + } + [Test] + public void Test_2525() + { + } + [Test] + public void Test_2526() + { + } + [Test] + public void Test_2527() + { + } + [Test] + public void Test_2528() + { + } + [Test] + public void Test_2529() + { + } + [Test] + public void Test_2530() + { + } + [Test] + public void Test_2531() + { + } + [Test] + public void Test_2532() + { + } + [Test] + public void Test_2533() + { + } + [Test] + public void Test_2534() + { + } + [Test] + public void Test_2535() + { + } + [Test] + public void Test_2536() + { + } + [Test] + public void Test_2537() + { + } + [Test] + public void Test_2538() + { + } + [Test] + public void Test_2539() + { + } + [Test] + public void Test_2540() + { + } + [Test] + public void Test_2541() + { + } + [Test] + public void Test_2542() + { + } + [Test] + public void Test_2543() + { + } + [Test] + public void Test_2544() + { + } + [Test] + public void Test_2545() + { + } + [Test] + public void Test_2546() + { + } + [Test] + public void Test_2547() + { + } + [Test] + public void Test_2548() + { + } + [Test] + public void Test_2549() + { + } + [Test] + public void Test_2550() + { + } + [Test] + public void Test_2551() + { + } + [Test] + public void Test_2552() + { + } + [Test] + public void Test_2553() + { + } + [Test] + public void Test_2554() + { + } + [Test] + public void Test_2555() + { + } + [Test] + public void Test_2556() + { + } + [Test] + public void Test_2557() + { + } + [Test] + public void Test_2558() + { + } + [Test] + public void Test_2559() + { + } + [Test] + public void Test_2560() + { + } + [Test] + public void Test_2561() + { + } + [Test] + public void Test_2562() + { + } + [Test] + public void Test_2563() + { + } + [Test] + public void Test_2564() + { + } + [Test] + public void Test_2565() + { + } + [Test] + public void Test_2566() + { + } + [Test] + public void Test_2567() + { + } + [Test] + public void Test_2568() + { + } + [Test] + public void Test_2569() + { + } + [Test] + public void Test_2570() + { + } + [Test] + public void Test_2571() + { + } + [Test] + public void Test_2572() + { + } + [Test] + public void Test_2573() + { + } + [Test] + public void Test_2574() + { + } + [Test] + public void Test_2575() + { + } + [Test] + public void Test_2576() + { + } + [Test] + public void Test_2577() + { + } + [Test] + public void Test_2578() + { + } + [Test] + public void Test_2579() + { + } + [Test] + public void Test_2580() + { + } + [Test] + public void Test_2581() + { + } + [Test] + public void Test_2582() + { + } + [Test] + public void Test_2583() + { + } + [Test] + public void Test_2584() + { + } + [Test] + public void Test_2585() + { + } + [Test] + public void Test_2586() + { + } + [Test] + public void Test_2587() + { + } + [Test] + public void Test_2588() + { + } + [Test] + public void Test_2589() + { + } + [Test] + public void Test_2590() + { + } + [Test] + public void Test_2591() + { + } + [Test] + public void Test_2592() + { + } + [Test] + public void Test_2593() + { + } + [Test] + public void Test_2594() + { + } + [Test] + public void Test_2595() + { + } + [Test] + public void Test_2596() + { + } + [Test] + public void Test_2597() + { + } + [Test] + public void Test_2598() + { + } + [Test] + public void Test_2599() + { + } + [Test] + public void Test_2600() + { + } + [Test] + public void Test_2601() + { + } + [Test] + public void Test_2602() + { + } + [Test] + public void Test_2603() + { + } + [Test] + public void Test_2604() + { + } + [Test] + public void Test_2605() + { + } + [Test] + public void Test_2606() + { + } + [Test] + public void Test_2607() + { + } + [Test] + public void Test_2608() + { + } + [Test] + public void Test_2609() + { + } + [Test] + public void Test_2610() + { + } + [Test] + public void Test_2611() + { + } + [Test] + public void Test_2612() + { + } + [Test] + public void Test_2613() + { + } + [Test] + public void Test_2614() + { + } + [Test] + public void Test_2615() + { + } + [Test] + public void Test_2616() + { + } + [Test] + public void Test_2617() + { + } + [Test] + public void Test_2618() + { + } + [Test] + public void Test_2619() + { + } + [Test] + public void Test_2620() + { + } + [Test] + public void Test_2621() + { + } + [Test] + public void Test_2622() + { + } + [Test] + public void Test_2623() + { + } + [Test] + public void Test_2624() + { + } + [Test] + public void Test_2625() + { + } + [Test] + public void Test_2626() + { + } + [Test] + public void Test_2627() + { + } + [Test] + public void Test_2628() + { + } + [Test] + public void Test_2629() + { + } + [Test] + public void Test_2630() + { + } + [Test] + public void Test_2631() + { + } + [Test] + public void Test_2632() + { + } + [Test] + public void Test_2633() + { + } + [Test] + public void Test_2634() + { + } + [Test] + public void Test_2635() + { + } + [Test] + public void Test_2636() + { + } + [Test] + public void Test_2637() + { + } + [Test] + public void Test_2638() + { + } + [Test] + public void Test_2639() + { + } + [Test] + public void Test_2640() + { + } + [Test] + public void Test_2641() + { + } + [Test] + public void Test_2642() + { + } + [Test] + public void Test_2643() + { + } + [Test] + public void Test_2644() + { + } + [Test] + public void Test_2645() + { + } + [Test] + public void Test_2646() + { + } + [Test] + public void Test_2647() + { + } + [Test] + public void Test_2648() + { + } + [Test] + public void Test_2649() + { + } + [Test] + public void Test_2650() + { + } + [Test] + public void Test_2651() + { + } + [Test] + public void Test_2652() + { + } + [Test] + public void Test_2653() + { + } + [Test] + public void Test_2654() + { + } + [Test] + public void Test_2655() + { + } + [Test] + public void Test_2656() + { + } + [Test] + public void Test_2657() + { + } + [Test] + public void Test_2658() + { + } + [Test] + public void Test_2659() + { + } + [Test] + public void Test_2660() + { + } + [Test] + public void Test_2661() + { + } + [Test] + public void Test_2662() + { + } + [Test] + public void Test_2663() + { + } + [Test] + public void Test_2664() + { + } + [Test] + public void Test_2665() + { + } + [Test] + public void Test_2666() + { + } + [Test] + public void Test_2667() + { + } + [Test] + public void Test_2668() + { + } + [Test] + public void Test_2669() + { + } + [Test] + public void Test_2670() + { + } + [Test] + public void Test_2671() + { + } + [Test] + public void Test_2672() + { + } + [Test] + public void Test_2673() + { + } + [Test] + public void Test_2674() + { + } + [Test] + public void Test_2675() + { + } + [Test] + public void Test_2676() + { + } + [Test] + public void Test_2677() + { + } + [Test] + public void Test_2678() + { + } + [Test] + public void Test_2679() + { + } + [Test] + public void Test_2680() + { + } + [Test] + public void Test_2681() + { + } + [Test] + public void Test_2682() + { + } + [Test] + public void Test_2683() + { + } + [Test] + public void Test_2684() + { + } + [Test] + public void Test_2685() + { + } + [Test] + public void Test_2686() + { + } + [Test] + public void Test_2687() + { + } + [Test] + public void Test_2688() + { + } + [Test] + public void Test_2689() + { + } + [Test] + public void Test_2690() + { + } + [Test] + public void Test_2691() + { + } + [Test] + public void Test_2692() + { + } + [Test] + public void Test_2693() + { + } + [Test] + public void Test_2694() + { + } + [Test] + public void Test_2695() + { + } + [Test] + public void Test_2696() + { + } + [Test] + public void Test_2697() + { + } + [Test] + public void Test_2698() + { + } + [Test] + public void Test_2699() + { + } + [Test] + public void Test_2700() + { + } + [Test] + public void Test_2701() + { + } + [Test] + public void Test_2702() + { + } + [Test] + public void Test_2703() + { + } + [Test] + public void Test_2704() + { + } + [Test] + public void Test_2705() + { + } + [Test] + public void Test_2706() + { + } + [Test] + public void Test_2707() + { + } + [Test] + public void Test_2708() + { + } + [Test] + public void Test_2709() + { + } + [Test] + public void Test_2710() + { + } + [Test] + public void Test_2711() + { + } + [Test] + public void Test_2712() + { + } + [Test] + public void Test_2713() + { + } + [Test] + public void Test_2714() + { + } + [Test] + public void Test_2715() + { + } + [Test] + public void Test_2716() + { + } + [Test] + public void Test_2717() + { + } + [Test] + public void Test_2718() + { + } + [Test] + public void Test_2719() + { + } + [Test] + public void Test_2720() + { + } + [Test] + public void Test_2721() + { + } + [Test] + public void Test_2722() + { + } + [Test] + public void Test_2723() + { + } + [Test] + public void Test_2724() + { + } + [Test] + public void Test_2725() + { + } + [Test] + public void Test_2726() + { + } + [Test] + public void Test_2727() + { + } + [Test] + public void Test_2728() + { + } + [Test] + public void Test_2729() + { + } + [Test] + public void Test_2730() + { + } + [Test] + public void Test_2731() + { + } + [Test] + public void Test_2732() + { + } + [Test] + public void Test_2733() + { + } + [Test] + public void Test_2734() + { + } + [Test] + public void Test_2735() + { + } + [Test] + public void Test_2736() + { + } + [Test] + public void Test_2737() + { + } + [Test] + public void Test_2738() + { + } + [Test] + public void Test_2739() + { + } + [Test] + public void Test_2740() + { + } + [Test] + public void Test_2741() + { + } + [Test] + public void Test_2742() + { + } + [Test] + public void Test_2743() + { + } + [Test] + public void Test_2744() + { + } + [Test] + public void Test_2745() + { + } + [Test] + public void Test_2746() + { + } + [Test] + public void Test_2747() + { + } + [Test] + public void Test_2748() + { + } + [Test] + public void Test_2749() + { + } + [Test] + public void Test_2750() + { + } + [Test] + public void Test_2751() + { + } + [Test] + public void Test_2752() + { + } + [Test] + public void Test_2753() + { + } + [Test] + public void Test_2754() + { + } + [Test] + public void Test_2755() + { + } + [Test] + public void Test_2756() + { + } + [Test] + public void Test_2757() + { + } + [Test] + public void Test_2758() + { + } + [Test] + public void Test_2759() + { + } + [Test] + public void Test_2760() + { + } + [Test] + public void Test_2761() + { + } + [Test] + public void Test_2762() + { + } + [Test] + public void Test_2763() + { + } + [Test] + public void Test_2764() + { + } + [Test] + public void Test_2765() + { + } + [Test] + public void Test_2766() + { + } + [Test] + public void Test_2767() + { + } + [Test] + public void Test_2768() + { + } + [Test] + public void Test_2769() + { + } + [Test] + public void Test_2770() + { + } + [Test] + public void Test_2771() + { + } + [Test] + public void Test_2772() + { + } + [Test] + public void Test_2773() + { + } + [Test] + public void Test_2774() + { + } + [Test] + public void Test_2775() + { + } + [Test] + public void Test_2776() + { + } + [Test] + public void Test_2777() + { + } + [Test] + public void Test_2778() + { + } + [Test] + public void Test_2779() + { + } + [Test] + public void Test_2780() + { + } + [Test] + public void Test_2781() + { + } + [Test] + public void Test_2782() + { + } + [Test] + public void Test_2783() + { + } + [Test] + public void Test_2784() + { + } + [Test] + public void Test_2785() + { + } + [Test] + public void Test_2786() + { + } + [Test] + public void Test_2787() + { + } + [Test] + public void Test_2788() + { + } + [Test] + public void Test_2789() + { + } + [Test] + public void Test_2790() + { + } + [Test] + public void Test_2791() + { + } + [Test] + public void Test_2792() + { + } + [Test] + public void Test_2793() + { + } + [Test] + public void Test_2794() + { + } + [Test] + public void Test_2795() + { + } + [Test] + public void Test_2796() + { + } + [Test] + public void Test_2797() + { + } + [Test] + public void Test_2798() + { + } + [Test] + public void Test_2799() + { + } + [Test] + public void Test_2800() + { + } + [Test] + public void Test_2801() + { + } + [Test] + public void Test_2802() + { + } + [Test] + public void Test_2803() + { + } + [Test] + public void Test_2804() + { + } + [Test] + public void Test_2805() + { + } + [Test] + public void Test_2806() + { + } + [Test] + public void Test_2807() + { + } + [Test] + public void Test_2808() + { + } + [Test] + public void Test_2809() + { + } + [Test] + public void Test_2810() + { + } + [Test] + public void Test_2811() + { + } + [Test] + public void Test_2812() + { + } + [Test] + public void Test_2813() + { + } + [Test] + public void Test_2814() + { + } + [Test] + public void Test_2815() + { + } + [Test] + public void Test_2816() + { + } + [Test] + public void Test_2817() + { + } + [Test] + public void Test_2818() + { + } + [Test] + public void Test_2819() + { + } + [Test] + public void Test_2820() + { + } + [Test] + public void Test_2821() + { + } + [Test] + public void Test_2822() + { + } + [Test] + public void Test_2823() + { + } + [Test] + public void Test_2824() + { + } + [Test] + public void Test_2825() + { + } + [Test] + public void Test_2826() + { + } + [Test] + public void Test_2827() + { + } + [Test] + public void Test_2828() + { + } + [Test] + public void Test_2829() + { + } + [Test] + public void Test_2830() + { + } + [Test] + public void Test_2831() + { + } + [Test] + public void Test_2832() + { + } + [Test] + public void Test_2833() + { + } + [Test] + public void Test_2834() + { + } + [Test] + public void Test_2835() + { + } + [Test] + public void Test_2836() + { + } + [Test] + public void Test_2837() + { + } + [Test] + public void Test_2838() + { + } + [Test] + public void Test_2839() + { + } + [Test] + public void Test_2840() + { + } + [Test] + public void Test_2841() + { + } + [Test] + public void Test_2842() + { + } + [Test] + public void Test_2843() + { + } + [Test] + public void Test_2844() + { + } + [Test] + public void Test_2845() + { + } + [Test] + public void Test_2846() + { + } + [Test] + public void Test_2847() + { + } + [Test] + public void Test_2848() + { + } + [Test] + public void Test_2849() + { + } + [Test] + public void Test_2850() + { + } + [Test] + public void Test_2851() + { + } + [Test] + public void Test_2852() + { + } + [Test] + public void Test_2853() + { + } + [Test] + public void Test_2854() + { + } + [Test] + public void Test_2855() + { + } + [Test] + public void Test_2856() + { + } + [Test] + public void Test_2857() + { + } + [Test] + public void Test_2858() + { + } + [Test] + public void Test_2859() + { + } + [Test] + public void Test_2860() + { + } + [Test] + public void Test_2861() + { + } + [Test] + public void Test_2862() + { + } + [Test] + public void Test_2863() + { + } + [Test] + public void Test_2864() + { + } + [Test] + public void Test_2865() + { + } + [Test] + public void Test_2866() + { + } + [Test] + public void Test_2867() + { + } + [Test] + public void Test_2868() + { + } + [Test] + public void Test_2869() + { + } + [Test] + public void Test_2870() + { + } + [Test] + public void Test_2871() + { + } + [Test] + public void Test_2872() + { + } + [Test] + public void Test_2873() + { + } + [Test] + public void Test_2874() + { + } + [Test] + public void Test_2875() + { + } + [Test] + public void Test_2876() + { + } + [Test] + public void Test_2877() + { + } + [Test] + public void Test_2878() + { + } + [Test] + public void Test_2879() + { + } + [Test] + public void Test_2880() + { + } + [Test] + public void Test_2881() + { + } + [Test] + public void Test_2882() + { + } + [Test] + public void Test_2883() + { + } + [Test] + public void Test_2884() + { + } + [Test] + public void Test_2885() + { + } + [Test] + public void Test_2886() + { + } + [Test] + public void Test_2887() + { + } + [Test] + public void Test_2888() + { + } + [Test] + public void Test_2889() + { + } + [Test] + public void Test_2890() + { + } + [Test] + public void Test_2891() + { + } + [Test] + public void Test_2892() + { + } + [Test] + public void Test_2893() + { + } + [Test] + public void Test_2894() + { + } + [Test] + public void Test_2895() + { + } + [Test] + public void Test_2896() + { + } + [Test] + public void Test_2897() + { + } + [Test] + public void Test_2898() + { + } + [Test] + public void Test_2899() + { + } + [Test] + public void Test_2900() + { + } + [Test] + public void Test_2901() + { + } + [Test] + public void Test_2902() + { + } + [Test] + public void Test_2903() + { + } + [Test] + public void Test_2904() + { + } + [Test] + public void Test_2905() + { + } + [Test] + public void Test_2906() + { + } + [Test] + public void Test_2907() + { + } + [Test] + public void Test_2908() + { + } + [Test] + public void Test_2909() + { + } + [Test] + public void Test_2910() + { + } + [Test] + public void Test_2911() + { + } + [Test] + public void Test_2912() + { + } + [Test] + public void Test_2913() + { + } + [Test] + public void Test_2914() + { + } + [Test] + public void Test_2915() + { + } + [Test] + public void Test_2916() + { + } + [Test] + public void Test_2917() + { + } + [Test] + public void Test_2918() + { + } + [Test] + public void Test_2919() + { + } + [Test] + public void Test_2920() + { + } + [Test] + public void Test_2921() + { + } + [Test] + public void Test_2922() + { + } + [Test] + public void Test_2923() + { + } + [Test] + public void Test_2924() + { + } + [Test] + public void Test_2925() + { + } + [Test] + public void Test_2926() + { + } + [Test] + public void Test_2927() + { + } + [Test] + public void Test_2928() + { + } + [Test] + public void Test_2929() + { + } + [Test] + public void Test_2930() + { + } + [Test] + public void Test_2931() + { + } + [Test] + public void Test_2932() + { + } + [Test] + public void Test_2933() + { + } + [Test] + public void Test_2934() + { + } + [Test] + public void Test_2935() + { + } + [Test] + public void Test_2936() + { + } + [Test] + public void Test_2937() + { + } + [Test] + public void Test_2938() + { + } + [Test] + public void Test_2939() + { + } + [Test] + public void Test_2940() + { + } + [Test] + public void Test_2941() + { + } + [Test] + public void Test_2942() + { + } + [Test] + public void Test_2943() + { + } + [Test] + public void Test_2944() + { + } + [Test] + public void Test_2945() + { + } + [Test] + public void Test_2946() + { + } + [Test] + public void Test_2947() + { + } + [Test] + public void Test_2948() + { + } + [Test] + public void Test_2949() + { + } + [Test] + public void Test_2950() + { + } + [Test] + public void Test_2951() + { + } + [Test] + public void Test_2952() + { + } + [Test] + public void Test_2953() + { + } + [Test] + public void Test_2954() + { + } + [Test] + public void Test_2955() + { + } + [Test] + public void Test_2956() + { + } + [Test] + public void Test_2957() + { + } + [Test] + public void Test_2958() + { + } + [Test] + public void Test_2959() + { + } + [Test] + public void Test_2960() + { + } + [Test] + public void Test_2961() + { + } + [Test] + public void Test_2962() + { + } + [Test] + public void Test_2963() + { + } + [Test] + public void Test_2964() + { + } + [Test] + public void Test_2965() + { + } + [Test] + public void Test_2966() + { + } + [Test] + public void Test_2967() + { + } + [Test] + public void Test_2968() + { + } + [Test] + public void Test_2969() + { + } + [Test] + public void Test_2970() + { + } + [Test] + public void Test_2971() + { + } + [Test] + public void Test_2972() + { + } + [Test] + public void Test_2973() + { + } + [Test] + public void Test_2974() + { + } + [Test] + public void Test_2975() + { + } + [Test] + public void Test_2976() + { + } + [Test] + public void Test_2977() + { + } + [Test] + public void Test_2978() + { + } + [Test] + public void Test_2979() + { + } + [Test] + public void Test_2980() + { + } + [Test] + public void Test_2981() + { + } + [Test] + public void Test_2982() + { + } + [Test] + public void Test_2983() + { + } + [Test] + public void Test_2984() + { + } + [Test] + public void Test_2985() + { + } + [Test] + public void Test_2986() + { + } + [Test] + public void Test_2987() + { + } + [Test] + public void Test_2988() + { + } + [Test] + public void Test_2989() + { + } + [Test] + public void Test_2990() + { + } + [Test] + public void Test_2991() + { + } + [Test] + public void Test_2992() + { + } + [Test] + public void Test_2993() + { + } + [Test] + public void Test_2994() + { + } + [Test] + public void Test_2995() + { + } + [Test] + public void Test_2996() + { + } + [Test] + public void Test_2997() + { + } + [Test] + public void Test_2998() + { + } + [Test] + public void Test_2999() + { + } + [Test] + public void Test_3000() + { + } + [Test] + public void Test_3001() + { + } + [Test] + public void Test_3002() + { + } + [Test] + public void Test_3003() + { + } + [Test] + public void Test_3004() + { + } + [Test] + public void Test_3005() + { + } + [Test] + public void Test_3006() + { + } + [Test] + public void Test_3007() + { + } + [Test] + public void Test_3008() + { + } + [Test] + public void Test_3009() + { + } + [Test] + public void Test_3010() + { + } + [Test] + public void Test_3011() + { + } + [Test] + public void Test_3012() + { + } + [Test] + public void Test_3013() + { + } + [Test] + public void Test_3014() + { + } + [Test] + public void Test_3015() + { + } + [Test] + public void Test_3016() + { + } + [Test] + public void Test_3017() + { + } + [Test] + public void Test_3018() + { + } + [Test] + public void Test_3019() + { + } + [Test] + public void Test_3020() + { + } + [Test] + public void Test_3021() + { + } + [Test] + public void Test_3022() + { + } + [Test] + public void Test_3023() + { + } + [Test] + public void Test_3024() + { + } + [Test] + public void Test_3025() + { + } + [Test] + public void Test_3026() + { + } + [Test] + public void Test_3027() + { + } + [Test] + public void Test_3028() + { + } + [Test] + public void Test_3029() + { + } + [Test] + public void Test_3030() + { + } + [Test] + public void Test_3031() + { + } + [Test] + public void Test_3032() + { + } + [Test] + public void Test_3033() + { + } + [Test] + public void Test_3034() + { + } + [Test] + public void Test_3035() + { + } + [Test] + public void Test_3036() + { + } + [Test] + public void Test_3037() + { + } + [Test] + public void Test_3038() + { + } + [Test] + public void Test_3039() + { + } + [Test] + public void Test_3040() + { + } + [Test] + public void Test_3041() + { + } + [Test] + public void Test_3042() + { + } + [Test] + public void Test_3043() + { + } + [Test] + public void Test_3044() + { + } + [Test] + public void Test_3045() + { + } + [Test] + public void Test_3046() + { + } + [Test] + public void Test_3047() + { + } + [Test] + public void Test_3048() + { + } + [Test] + public void Test_3049() + { + } + [Test] + public void Test_3050() + { + } + [Test] + public void Test_3051() + { + } + [Test] + public void Test_3052() + { + } + [Test] + public void Test_3053() + { + } + [Test] + public void Test_3054() + { + } + [Test] + public void Test_3055() + { + } + [Test] + public void Test_3056() + { + } + [Test] + public void Test_3057() + { + } + [Test] + public void Test_3058() + { + } + [Test] + public void Test_3059() + { + } + [Test] + public void Test_3060() + { + } + [Test] + public void Test_3061() + { + } + [Test] + public void Test_3062() + { + } + [Test] + public void Test_3063() + { + } + [Test] + public void Test_3064() + { + } + [Test] + public void Test_3065() + { + } + [Test] + public void Test_3066() + { + } + [Test] + public void Test_3067() + { + } + [Test] + public void Test_3068() + { + } + [Test] + public void Test_3069() + { + } + [Test] + public void Test_3070() + { + } + [Test] + public void Test_3071() + { + } + [Test] + public void Test_3072() + { + } + [Test] + public void Test_3073() + { + } + [Test] + public void Test_3074() + { + } + [Test] + public void Test_3075() + { + } + [Test] + public void Test_3076() + { + } + [Test] + public void Test_3077() + { + } + [Test] + public void Test_3078() + { + } + [Test] + public void Test_3079() + { + } + [Test] + public void Test_3080() + { + } + [Test] + public void Test_3081() + { + } + [Test] + public void Test_3082() + { + } + [Test] + public void Test_3083() + { + } + [Test] + public void Test_3084() + { + } + [Test] + public void Test_3085() + { + } + [Test] + public void Test_3086() + { + } + [Test] + public void Test_3087() + { + } + [Test] + public void Test_3088() + { + } + [Test] + public void Test_3089() + { + } + [Test] + public void Test_3090() + { + } + [Test] + public void Test_3091() + { + } + [Test] + public void Test_3092() + { + } + [Test] + public void Test_3093() + { + } + [Test] + public void Test_3094() + { + } + [Test] + public void Test_3095() + { + } + [Test] + public void Test_3096() + { + } + [Test] + public void Test_3097() + { + } + [Test] + public void Test_3098() + { + } + [Test] + public void Test_3099() + { + } + [Test] + public void Test_3100() + { + } + [Test] + public void Test_3101() + { + } + [Test] + public void Test_3102() + { + } + [Test] + public void Test_3103() + { + } + [Test] + public void Test_3104() + { + } + [Test] + public void Test_3105() + { + } + [Test] + public void Test_3106() + { + } + [Test] + public void Test_3107() + { + } + [Test] + public void Test_3108() + { + } + [Test] + public void Test_3109() + { + } + [Test] + public void Test_3110() + { + } + [Test] + public void Test_3111() + { + } + [Test] + public void Test_3112() + { + } + [Test] + public void Test_3113() + { + } + [Test] + public void Test_3114() + { + } + [Test] + public void Test_3115() + { + } + [Test] + public void Test_3116() + { + } + [Test] + public void Test_3117() + { + } + [Test] + public void Test_3118() + { + } + [Test] + public void Test_3119() + { + } + [Test] + public void Test_3120() + { + } + [Test] + public void Test_3121() + { + } + [Test] + public void Test_3122() + { + } + [Test] + public void Test_3123() + { + } + [Test] + public void Test_3124() + { + } + [Test] + public void Test_3125() + { + } + [Test] + public void Test_3126() + { + } + [Test] + public void Test_3127() + { + } + [Test] + public void Test_3128() + { + } + [Test] + public void Test_3129() + { + } + [Test] + public void Test_3130() + { + } + [Test] + public void Test_3131() + { + } + [Test] + public void Test_3132() + { + } + [Test] + public void Test_3133() + { + } + [Test] + public void Test_3134() + { + } + [Test] + public void Test_3135() + { + } + [Test] + public void Test_3136() + { + } + [Test] + public void Test_3137() + { + } + [Test] + public void Test_3138() + { + } + [Test] + public void Test_3139() + { + } + [Test] + public void Test_3140() + { + } + [Test] + public void Test_3141() + { + } + [Test] + public void Test_3142() + { + } + [Test] + public void Test_3143() + { + } + [Test] + public void Test_3144() + { + } + [Test] + public void Test_3145() + { + } + [Test] + public void Test_3146() + { + } + [Test] + public void Test_3147() + { + } + [Test] + public void Test_3148() + { + } + [Test] + public void Test_3149() + { + } + [Test] + public void Test_3150() + { + } + [Test] + public void Test_3151() + { + } + [Test] + public void Test_3152() + { + } + [Test] + public void Test_3153() + { + } + [Test] + public void Test_3154() + { + } + [Test] + public void Test_3155() + { + } + [Test] + public void Test_3156() + { + } + [Test] + public void Test_3157() + { + } + [Test] + public void Test_3158() + { + } + [Test] + public void Test_3159() + { + } + [Test] + public void Test_3160() + { + } + [Test] + public void Test_3161() + { + } + [Test] + public void Test_3162() + { + } + [Test] + public void Test_3163() + { + } + [Test] + public void Test_3164() + { + } + [Test] + public void Test_3165() + { + } + [Test] + public void Test_3166() + { + } + [Test] + public void Test_3167() + { + } + [Test] + public void Test_3168() + { + } + [Test] + public void Test_3169() + { + } + [Test] + public void Test_3170() + { + } + [Test] + public void Test_3171() + { + } + [Test] + public void Test_3172() + { + } + [Test] + public void Test_3173() + { + } + [Test] + public void Test_3174() + { + } + [Test] + public void Test_3175() + { + } + [Test] + public void Test_3176() + { + } + [Test] + public void Test_3177() + { + } + [Test] + public void Test_3178() + { + } + [Test] + public void Test_3179() + { + } + [Test] + public void Test_3180() + { + } + [Test] + public void Test_3181() + { + } + [Test] + public void Test_3182() + { + } + [Test] + public void Test_3183() + { + } + [Test] + public void Test_3184() + { + } + [Test] + public void Test_3185() + { + } + [Test] + public void Test_3186() + { + } + [Test] + public void Test_3187() + { + } + [Test] + public void Test_3188() + { + } + [Test] + public void Test_3189() + { + } + [Test] + public void Test_3190() + { + } + [Test] + public void Test_3191() + { + } + [Test] + public void Test_3192() + { + } + [Test] + public void Test_3193() + { + } + [Test] + public void Test_3194() + { + } + [Test] + public void Test_3195() + { + } + [Test] + public void Test_3196() + { + } + [Test] + public void Test_3197() + { + } + [Test] + public void Test_3198() + { + } + [Test] + public void Test_3199() + { + } + [Test] + public void Test_3200() + { + } + [Test] + public void Test_3201() + { + } + [Test] + public void Test_3202() + { + } + [Test] + public void Test_3203() + { + } + [Test] + public void Test_3204() + { + } + [Test] + public void Test_3205() + { + } + [Test] + public void Test_3206() + { + } + [Test] + public void Test_3207() + { + } + [Test] + public void Test_3208() + { + } + [Test] + public void Test_3209() + { + } + [Test] + public void Test_3210() + { + } + [Test] + public void Test_3211() + { + } + [Test] + public void Test_3212() + { + } + [Test] + public void Test_3213() + { + } + [Test] + public void Test_3214() + { + } + [Test] + public void Test_3215() + { + } + [Test] + public void Test_3216() + { + } + [Test] + public void Test_3217() + { + } + [Test] + public void Test_3218() + { + } + [Test] + public void Test_3219() + { + } + [Test] + public void Test_3220() + { + } + [Test] + public void Test_3221() + { + } + [Test] + public void Test_3222() + { + } + [Test] + public void Test_3223() + { + } + [Test] + public void Test_3224() + { + } + [Test] + public void Test_3225() + { + } + [Test] + public void Test_3226() + { + } + [Test] + public void Test_3227() + { + } + [Test] + public void Test_3228() + { + } + [Test] + public void Test_3229() + { + } + [Test] + public void Test_3230() + { + } + [Test] + public void Test_3231() + { + } + [Test] + public void Test_3232() + { + } + [Test] + public void Test_3233() + { + } + [Test] + public void Test_3234() + { + } + [Test] + public void Test_3235() + { + } + [Test] + public void Test_3236() + { + } + [Test] + public void Test_3237() + { + } + [Test] + public void Test_3238() + { + } + [Test] + public void Test_3239() + { + } + [Test] + public void Test_3240() + { + } + [Test] + public void Test_3241() + { + } + [Test] + public void Test_3242() + { + } + [Test] + public void Test_3243() + { + } + [Test] + public void Test_3244() + { + } + [Test] + public void Test_3245() + { + } + [Test] + public void Test_3246() + { + } + [Test] + public void Test_3247() + { + } + [Test] + public void Test_3248() + { + } + [Test] + public void Test_3249() + { + } + [Test] + public void Test_3250() + { + } + [Test] + public void Test_3251() + { + } + [Test] + public void Test_3252() + { + } + [Test] + public void Test_3253() + { + } + [Test] + public void Test_3254() + { + } + [Test] + public void Test_3255() + { + } + [Test] + public void Test_3256() + { + } + [Test] + public void Test_3257() + { + } + [Test] + public void Test_3258() + { + } + [Test] + public void Test_3259() + { + } + [Test] + public void Test_3260() + { + } + [Test] + public void Test_3261() + { + } + [Test] + public void Test_3262() + { + } + [Test] + public void Test_3263() + { + } + [Test] + public void Test_3264() + { + } + [Test] + public void Test_3265() + { + } + [Test] + public void Test_3266() + { + } + [Test] + public void Test_3267() + { + } + [Test] + public void Test_3268() + { + } + [Test] + public void Test_3269() + { + } + [Test] + public void Test_3270() + { + } + [Test] + public void Test_3271() + { + } + [Test] + public void Test_3272() + { + } + [Test] + public void Test_3273() + { + } + [Test] + public void Test_3274() + { + } + [Test] + public void Test_3275() + { + } + [Test] + public void Test_3276() + { + } + [Test] + public void Test_3277() + { + } + [Test] + public void Test_3278() + { + } + [Test] + public void Test_3279() + { + } + [Test] + public void Test_3280() + { + } + [Test] + public void Test_3281() + { + } + [Test] + public void Test_3282() + { + } + [Test] + public void Test_3283() + { + } + [Test] + public void Test_3284() + { + } + [Test] + public void Test_3285() + { + } + [Test] + public void Test_3286() + { + } + [Test] + public void Test_3287() + { + } + [Test] + public void Test_3288() + { + } + [Test] + public void Test_3289() + { + } + [Test] + public void Test_3290() + { + } + [Test] + public void Test_3291() + { + } + [Test] + public void Test_3292() + { + } + [Test] + public void Test_3293() + { + } + [Test] + public void Test_3294() + { + } + [Test] + public void Test_3295() + { + } + [Test] + public void Test_3296() + { + } + [Test] + public void Test_3297() + { + } + [Test] + public void Test_3298() + { + } + [Test] + public void Test_3299() + { + } + [Test] + public void Test_3300() + { + } + [Test] + public void Test_3301() + { + } + [Test] + public void Test_3302() + { + } + [Test] + public void Test_3303() + { + } + [Test] + public void Test_3304() + { + } + [Test] + public void Test_3305() + { + } + [Test] + public void Test_3306() + { + } + [Test] + public void Test_3307() + { + } + [Test] + public void Test_3308() + { + } + [Test] + public void Test_3309() + { + } + [Test] + public void Test_3310() + { + } + [Test] + public void Test_3311() + { + } + [Test] + public void Test_3312() + { + } + [Test] + public void Test_3313() + { + } + [Test] + public void Test_3314() + { + } + [Test] + public void Test_3315() + { + } + [Test] + public void Test_3316() + { + } + [Test] + public void Test_3317() + { + } + [Test] + public void Test_3318() + { + } + [Test] + public void Test_3319() + { + } + [Test] + public void Test_3320() + { + } + [Test] + public void Test_3321() + { + } + [Test] + public void Test_3322() + { + } + [Test] + public void Test_3323() + { + } + [Test] + public void Test_3324() + { + } + [Test] + public void Test_3325() + { + } + [Test] + public void Test_3326() + { + } + [Test] + public void Test_3327() + { + } + [Test] + public void Test_3328() + { + } + [Test] + public void Test_3329() + { + } + [Test] + public void Test_3330() + { + } + [Test] + public void Test_3331() + { + } + [Test] + public void Test_3332() + { + } + [Test] + public void Test_3333() + { + } + [Test] + public void Test_3334() + { + } + [Test] + public void Test_3335() + { + } + [Test] + public void Test_3336() + { + } + [Test] + public void Test_3337() + { + } + [Test] + public void Test_3338() + { + } + [Test] + public void Test_3339() + { + } + [Test] + public void Test_3340() + { + } + [Test] + public void Test_3341() + { + } + [Test] + public void Test_3342() + { + } + [Test] + public void Test_3343() + { + } + [Test] + public void Test_3344() + { + } + [Test] + public void Test_3345() + { + } + [Test] + public void Test_3346() + { + } + [Test] + public void Test_3347() + { + } + [Test] + public void Test_3348() + { + } + [Test] + public void Test_3349() + { + } + [Test] + public void Test_3350() + { + } + [Test] + public void Test_3351() + { + } + [Test] + public void Test_3352() + { + } + [Test] + public void Test_3353() + { + } + [Test] + public void Test_3354() + { + } + [Test] + public void Test_3355() + { + } + [Test] + public void Test_3356() + { + } + [Test] + public void Test_3357() + { + } + [Test] + public void Test_3358() + { + } + [Test] + public void Test_3359() + { + } + [Test] + public void Test_3360() + { + } + [Test] + public void Test_3361() + { + } + [Test] + public void Test_3362() + { + } + [Test] + public void Test_3363() + { + } + [Test] + public void Test_3364() + { + } + [Test] + public void Test_3365() + { + } + [Test] + public void Test_3366() + { + } + [Test] + public void Test_3367() + { + } + [Test] + public void Test_3368() + { + } + [Test] + public void Test_3369() + { + } + [Test] + public void Test_3370() + { + } + [Test] + public void Test_3371() + { + } + [Test] + public void Test_3372() + { + } + [Test] + public void Test_3373() + { + } + [Test] + public void Test_3374() + { + } + [Test] + public void Test_3375() + { + } + [Test] + public void Test_3376() + { + } + [Test] + public void Test_3377() + { + } + [Test] + public void Test_3378() + { + } + [Test] + public void Test_3379() + { + } + [Test] + public void Test_3380() + { + } + [Test] + public void Test_3381() + { + } + [Test] + public void Test_3382() + { + } + [Test] + public void Test_3383() + { + } + [Test] + public void Test_3384() + { + } + [Test] + public void Test_3385() + { + } + [Test] + public void Test_3386() + { + } + [Test] + public void Test_3387() + { + } + [Test] + public void Test_3388() + { + } + [Test] + public void Test_3389() + { + } + [Test] + public void Test_3390() + { + } + [Test] + public void Test_3391() + { + } + [Test] + public void Test_3392() + { + } + [Test] + public void Test_3393() + { + } + [Test] + public void Test_3394() + { + } + [Test] + public void Test_3395() + { + } + [Test] + public void Test_3396() + { + } + [Test] + public void Test_3397() + { + } + [Test] + public void Test_3398() + { + } + [Test] + public void Test_3399() + { + } + [Test] + public void Test_3400() + { + } + [Test] + public void Test_3401() + { + } + [Test] + public void Test_3402() + { + } + [Test] + public void Test_3403() + { + } + [Test] + public void Test_3404() + { + } + [Test] + public void Test_3405() + { + } + [Test] + public void Test_3406() + { + } + [Test] + public void Test_3407() + { + } + [Test] + public void Test_3408() + { + } + [Test] + public void Test_3409() + { + } + [Test] + public void Test_3410() + { + } + [Test] + public void Test_3411() + { + } + [Test] + public void Test_3412() + { + } + [Test] + public void Test_3413() + { + } + [Test] + public void Test_3414() + { + } + [Test] + public void Test_3415() + { + } + [Test] + public void Test_3416() + { + } + [Test] + public void Test_3417() + { + } + [Test] + public void Test_3418() + { + } + [Test] + public void Test_3419() + { + } + [Test] + public void Test_3420() + { + } + [Test] + public void Test_3421() + { + } + [Test] + public void Test_3422() + { + } + [Test] + public void Test_3423() + { + } + [Test] + public void Test_3424() + { + } + [Test] + public void Test_3425() + { + } + [Test] + public void Test_3426() + { + } + [Test] + public void Test_3427() + { + } + [Test] + public void Test_3428() + { + } + [Test] + public void Test_3429() + { + } + [Test] + public void Test_3430() + { + } + [Test] + public void Test_3431() + { + } + [Test] + public void Test_3432() + { + } + [Test] + public void Test_3433() + { + } + [Test] + public void Test_3434() + { + } + [Test] + public void Test_3435() + { + } + [Test] + public void Test_3436() + { + } + [Test] + public void Test_3437() + { + } + [Test] + public void Test_3438() + { + } + [Test] + public void Test_3439() + { + } + [Test] + public void Test_3440() + { + } + [Test] + public void Test_3441() + { + } + [Test] + public void Test_3442() + { + } + [Test] + public void Test_3443() + { + } + [Test] + public void Test_3444() + { + } + [Test] + public void Test_3445() + { + } + [Test] + public void Test_3446() + { + } + [Test] + public void Test_3447() + { + } + [Test] + public void Test_3448() + { + } + [Test] + public void Test_3449() + { + } + [Test] + public void Test_3450() + { + } + [Test] + public void Test_3451() + { + } + [Test] + public void Test_3452() + { + } + [Test] + public void Test_3453() + { + } + [Test] + public void Test_3454() + { + } + [Test] + public void Test_3455() + { + } + [Test] + public void Test_3456() + { + } + [Test] + public void Test_3457() + { + } + [Test] + public void Test_3458() + { + } + [Test] + public void Test_3459() + { + } + [Test] + public void Test_3460() + { + } + [Test] + public void Test_3461() + { + } + [Test] + public void Test_3462() + { + } + [Test] + public void Test_3463() + { + } + [Test] + public void Test_3464() + { + } + [Test] + public void Test_3465() + { + } + [Test] + public void Test_3466() + { + } + [Test] + public void Test_3467() + { + } + [Test] + public void Test_3468() + { + } + [Test] + public void Test_3469() + { + } + [Test] + public void Test_3470() + { + } + [Test] + public void Test_3471() + { + } + [Test] + public void Test_3472() + { + } + [Test] + public void Test_3473() + { + } + [Test] + public void Test_3474() + { + } + [Test] + public void Test_3475() + { + } + [Test] + public void Test_3476() + { + } + [Test] + public void Test_3477() + { + } + [Test] + public void Test_3478() + { + } + [Test] + public void Test_3479() + { + } + [Test] + public void Test_3480() + { + } + [Test] + public void Test_3481() + { + } + [Test] + public void Test_3482() + { + } + [Test] + public void Test_3483() + { + } + [Test] + public void Test_3484() + { + } + [Test] + public void Test_3485() + { + } + [Test] + public void Test_3486() + { + } + [Test] + public void Test_3487() + { + } + [Test] + public void Test_3488() + { + } + [Test] + public void Test_3489() + { + } + [Test] + public void Test_3490() + { + } + [Test] + public void Test_3491() + { + } + [Test] + public void Test_3492() + { + } + [Test] + public void Test_3493() + { + } + [Test] + public void Test_3494() + { + } + [Test] + public void Test_3495() + { + } + [Test] + public void Test_3496() + { + } + [Test] + public void Test_3497() + { + } + [Test] + public void Test_3498() + { + } + [Test] + public void Test_3499() + { + } + [Test] + public void Test_3500() + { + } + [Test] + public void Test_3501() + { + } + [Test] + public void Test_3502() + { + } + [Test] + public void Test_3503() + { + } + [Test] + public void Test_3504() + { + } + [Test] + public void Test_3505() + { + } + [Test] + public void Test_3506() + { + } + [Test] + public void Test_3507() + { + } + [Test] + public void Test_3508() + { + } + [Test] + public void Test_3509() + { + } + [Test] + public void Test_3510() + { + } + [Test] + public void Test_3511() + { + } + [Test] + public void Test_3512() + { + } + [Test] + public void Test_3513() + { + } + [Test] + public void Test_3514() + { + } + [Test] + public void Test_3515() + { + } + [Test] + public void Test_3516() + { + } + [Test] + public void Test_3517() + { + } + [Test] + public void Test_3518() + { + } + [Test] + public void Test_3519() + { + } + [Test] + public void Test_3520() + { + } + [Test] + public void Test_3521() + { + } + [Test] + public void Test_3522() + { + } + [Test] + public void Test_3523() + { + } + [Test] + public void Test_3524() + { + } + [Test] + public void Test_3525() + { + } + [Test] + public void Test_3526() + { + } + [Test] + public void Test_3527() + { + } + [Test] + public void Test_3528() + { + } + [Test] + public void Test_3529() + { + } + [Test] + public void Test_3530() + { + } + [Test] + public void Test_3531() + { + } + [Test] + public void Test_3532() + { + } + [Test] + public void Test_3533() + { + } + [Test] + public void Test_3534() + { + } + [Test] + public void Test_3535() + { + } + [Test] + public void Test_3536() + { + } + [Test] + public void Test_3537() + { + } + [Test] + public void Test_3538() + { + } + [Test] + public void Test_3539() + { + } + [Test] + public void Test_3540() + { + } + [Test] + public void Test_3541() + { + } + [Test] + public void Test_3542() + { + } + [Test] + public void Test_3543() + { + } + [Test] + public void Test_3544() + { + } + [Test] + public void Test_3545() + { + } + [Test] + public void Test_3546() + { + } + [Test] + public void Test_3547() + { + } + [Test] + public void Test_3548() + { + } + [Test] + public void Test_3549() + { + } + [Test] + public void Test_3550() + { + } + [Test] + public void Test_3551() + { + } + [Test] + public void Test_3552() + { + } + [Test] + public void Test_3553() + { + } + [Test] + public void Test_3554() + { + } + [Test] + public void Test_3555() + { + } + [Test] + public void Test_3556() + { + } + [Test] + public void Test_3557() + { + } + [Test] + public void Test_3558() + { + } + [Test] + public void Test_3559() + { + } + [Test] + public void Test_3560() + { + } + [Test] + public void Test_3561() + { + } + [Test] + public void Test_3562() + { + } + [Test] + public void Test_3563() + { + } + [Test] + public void Test_3564() + { + } + [Test] + public void Test_3565() + { + } + [Test] + public void Test_3566() + { + } + [Test] + public void Test_3567() + { + } + [Test] + public void Test_3568() + { + } + [Test] + public void Test_3569() + { + } + [Test] + public void Test_3570() + { + } + [Test] + public void Test_3571() + { + } + [Test] + public void Test_3572() + { + } + [Test] + public void Test_3573() + { + } + [Test] + public void Test_3574() + { + } + [Test] + public void Test_3575() + { + } + [Test] + public void Test_3576() + { + } + [Test] + public void Test_3577() + { + } + [Test] + public void Test_3578() + { + } + [Test] + public void Test_3579() + { + } + [Test] + public void Test_3580() + { + } + [Test] + public void Test_3581() + { + } + [Test] + public void Test_3582() + { + } + [Test] + public void Test_3583() + { + } + [Test] + public void Test_3584() + { + } + [Test] + public void Test_3585() + { + } + [Test] + public void Test_3586() + { + } + [Test] + public void Test_3587() + { + } + [Test] + public void Test_3588() + { + } + [Test] + public void Test_3589() + { + } + [Test] + public void Test_3590() + { + } + [Test] + public void Test_3591() + { + } + [Test] + public void Test_3592() + { + } + [Test] + public void Test_3593() + { + } + [Test] + public void Test_3594() + { + } + [Test] + public void Test_3595() + { + } + [Test] + public void Test_3596() + { + } + [Test] + public void Test_3597() + { + } + [Test] + public void Test_3598() + { + } + [Test] + public void Test_3599() + { + } + [Test] + public void Test_3600() + { + } + [Test] + public void Test_3601() + { + } + [Test] + public void Test_3602() + { + } + [Test] + public void Test_3603() + { + } + [Test] + public void Test_3604() + { + } + [Test] + public void Test_3605() + { + } + [Test] + public void Test_3606() + { + } + [Test] + public void Test_3607() + { + } + [Test] + public void Test_3608() + { + } + [Test] + public void Test_3609() + { + } + [Test] + public void Test_3610() + { + } + [Test] + public void Test_3611() + { + } + [Test] + public void Test_3612() + { + } + [Test] + public void Test_3613() + { + } + [Test] + public void Test_3614() + { + } + [Test] + public void Test_3615() + { + } + [Test] + public void Test_3616() + { + } + [Test] + public void Test_3617() + { + } + [Test] + public void Test_3618() + { + } + [Test] + public void Test_3619() + { + } + [Test] + public void Test_3620() + { + } + [Test] + public void Test_3621() + { + } + [Test] + public void Test_3622() + { + } + [Test] + public void Test_3623() + { + } + [Test] + public void Test_3624() + { + } + [Test] + public void Test_3625() + { + } + [Test] + public void Test_3626() + { + } + [Test] + public void Test_3627() + { + } + [Test] + public void Test_3628() + { + } + [Test] + public void Test_3629() + { + } + [Test] + public void Test_3630() + { + } + [Test] + public void Test_3631() + { + } + [Test] + public void Test_3632() + { + } + [Test] + public void Test_3633() + { + } + [Test] + public void Test_3634() + { + } + [Test] + public void Test_3635() + { + } + [Test] + public void Test_3636() + { + } + [Test] + public void Test_3637() + { + } + [Test] + public void Test_3638() + { + } + [Test] + public void Test_3639() + { + } + [Test] + public void Test_3640() + { + } + [Test] + public void Test_3641() + { + } + [Test] + public void Test_3642() + { + } + [Test] + public void Test_3643() + { + } + [Test] + public void Test_3644() + { + } + [Test] + public void Test_3645() + { + } + [Test] + public void Test_3646() + { + } + [Test] + public void Test_3647() + { + } + [Test] + public void Test_3648() + { + } + [Test] + public void Test_3649() + { + } + [Test] + public void Test_3650() + { + } + [Test] + public void Test_3651() + { + } + [Test] + public void Test_3652() + { + } + [Test] + public void Test_3653() + { + } + [Test] + public void Test_3654() + { + } + [Test] + public void Test_3655() + { + } + [Test] + public void Test_3656() + { + } + [Test] + public void Test_3657() + { + } + [Test] + public void Test_3658() + { + } + [Test] + public void Test_3659() + { + } + [Test] + public void Test_3660() + { + } + [Test] + public void Test_3661() + { + } + [Test] + public void Test_3662() + { + } + [Test] + public void Test_3663() + { + } + [Test] + public void Test_3664() + { + } + [Test] + public void Test_3665() + { + } + [Test] + public void Test_3666() + { + } + [Test] + public void Test_3667() + { + } + [Test] + public void Test_3668() + { + } + [Test] + public void Test_3669() + { + } + [Test] + public void Test_3670() + { + } + [Test] + public void Test_3671() + { + } + [Test] + public void Test_3672() + { + } + [Test] + public void Test_3673() + { + } + [Test] + public void Test_3674() + { + } + [Test] + public void Test_3675() + { + } + [Test] + public void Test_3676() + { + } + [Test] + public void Test_3677() + { + } + [Test] + public void Test_3678() + { + } + [Test] + public void Test_3679() + { + } + [Test] + public void Test_3680() + { + } + [Test] + public void Test_3681() + { + } + [Test] + public void Test_3682() + { + } + [Test] + public void Test_3683() + { + } + [Test] + public void Test_3684() + { + } + [Test] + public void Test_3685() + { + } + [Test] + public void Test_3686() + { + } + [Test] + public void Test_3687() + { + } + [Test] + public void Test_3688() + { + } + [Test] + public void Test_3689() + { + } + [Test] + public void Test_3690() + { + } + [Test] + public void Test_3691() + { + } + [Test] + public void Test_3692() + { + } + [Test] + public void Test_3693() + { + } + [Test] + public void Test_3694() + { + } + [Test] + public void Test_3695() + { + } + [Test] + public void Test_3696() + { + } + [Test] + public void Test_3697() + { + } + [Test] + public void Test_3698() + { + } + [Test] + public void Test_3699() + { + } + [Test] + public void Test_3700() + { + } + [Test] + public void Test_3701() + { + } + [Test] + public void Test_3702() + { + } + [Test] + public void Test_3703() + { + } + [Test] + public void Test_3704() + { + } + [Test] + public void Test_3705() + { + } + [Test] + public void Test_3706() + { + } + [Test] + public void Test_3707() + { + } + [Test] + public void Test_3708() + { + } + [Test] + public void Test_3709() + { + } + [Test] + public void Test_3710() + { + } + [Test] + public void Test_3711() + { + } + [Test] + public void Test_3712() + { + } + [Test] + public void Test_3713() + { + } + [Test] + public void Test_3714() + { + } + [Test] + public void Test_3715() + { + } + [Test] + public void Test_3716() + { + } + [Test] + public void Test_3717() + { + } + [Test] + public void Test_3718() + { + } + [Test] + public void Test_3719() + { + } + [Test] + public void Test_3720() + { + } + [Test] + public void Test_3721() + { + } + [Test] + public void Test_3722() + { + } + [Test] + public void Test_3723() + { + } + [Test] + public void Test_3724() + { + } + [Test] + public void Test_3725() + { + } + [Test] + public void Test_3726() + { + } + [Test] + public void Test_3727() + { + } + [Test] + public void Test_3728() + { + } + [Test] + public void Test_3729() + { + } + [Test] + public void Test_3730() + { + } + [Test] + public void Test_3731() + { + } + [Test] + public void Test_3732() + { + } + [Test] + public void Test_3733() + { + } + [Test] + public void Test_3734() + { + } + [Test] + public void Test_3735() + { + } + [Test] + public void Test_3736() + { + } + [Test] + public void Test_3737() + { + } + [Test] + public void Test_3738() + { + } + [Test] + public void Test_3739() + { + } + [Test] + public void Test_3740() + { + } + [Test] + public void Test_3741() + { + } + [Test] + public void Test_3742() + { + } + [Test] + public void Test_3743() + { + } + [Test] + public void Test_3744() + { + } + [Test] + public void Test_3745() + { + } + [Test] + public void Test_3746() + { + } + [Test] + public void Test_3747() + { + } + [Test] + public void Test_3748() + { + } + [Test] + public void Test_3749() + { + } + [Test] + public void Test_3750() + { + } + [Test] + public void Test_3751() + { + } + [Test] + public void Test_3752() + { + } + [Test] + public void Test_3753() + { + } + [Test] + public void Test_3754() + { + } + [Test] + public void Test_3755() + { + } + [Test] + public void Test_3756() + { + } + [Test] + public void Test_3757() + { + } + [Test] + public void Test_3758() + { + } + [Test] + public void Test_3759() + { + } + [Test] + public void Test_3760() + { + } + [Test] + public void Test_3761() + { + } + [Test] + public void Test_3762() + { + } + [Test] + public void Test_3763() + { + } + [Test] + public void Test_3764() + { + } + [Test] + public void Test_3765() + { + } + [Test] + public void Test_3766() + { + } + [Test] + public void Test_3767() + { + } + [Test] + public void Test_3768() + { + } + [Test] + public void Test_3769() + { + } + [Test] + public void Test_3770() + { + } + [Test] + public void Test_3771() + { + } + [Test] + public void Test_3772() + { + } + [Test] + public void Test_3773() + { + } + [Test] + public void Test_3774() + { + } + [Test] + public void Test_3775() + { + } + [Test] + public void Test_3776() + { + } + [Test] + public void Test_3777() + { + } + [Test] + public void Test_3778() + { + } + [Test] + public void Test_3779() + { + } + [Test] + public void Test_3780() + { + } + [Test] + public void Test_3781() + { + } + [Test] + public void Test_3782() + { + } + [Test] + public void Test_3783() + { + } + [Test] + public void Test_3784() + { + } + [Test] + public void Test_3785() + { + } + [Test] + public void Test_3786() + { + } + [Test] + public void Test_3787() + { + } + [Test] + public void Test_3788() + { + } + [Test] + public void Test_3789() + { + } + [Test] + public void Test_3790() + { + } + [Test] + public void Test_3791() + { + } + [Test] + public void Test_3792() + { + } + [Test] + public void Test_3793() + { + } + [Test] + public void Test_3794() + { + } + [Test] + public void Test_3795() + { + } + [Test] + public void Test_3796() + { + } + [Test] + public void Test_3797() + { + } + [Test] + public void Test_3798() + { + } + [Test] + public void Test_3799() + { + } + [Test] + public void Test_3800() + { + } + [Test] + public void Test_3801() + { + } + [Test] + public void Test_3802() + { + } + [Test] + public void Test_3803() + { + } + [Test] + public void Test_3804() + { + } + [Test] + public void Test_3805() + { + } + [Test] + public void Test_3806() + { + } + [Test] + public void Test_3807() + { + } + [Test] + public void Test_3808() + { + } + [Test] + public void Test_3809() + { + } + [Test] + public void Test_3810() + { + } + [Test] + public void Test_3811() + { + } + [Test] + public void Test_3812() + { + } + [Test] + public void Test_3813() + { + } + [Test] + public void Test_3814() + { + } + [Test] + public void Test_3815() + { + } + [Test] + public void Test_3816() + { + } + [Test] + public void Test_3817() + { + } + [Test] + public void Test_3818() + { + } + [Test] + public void Test_3819() + { + } + [Test] + public void Test_3820() + { + } + [Test] + public void Test_3821() + { + } + [Test] + public void Test_3822() + { + } + [Test] + public void Test_3823() + { + } + [Test] + public void Test_3824() + { + } + [Test] + public void Test_3825() + { + } + [Test] + public void Test_3826() + { + } + [Test] + public void Test_3827() + { + } + [Test] + public void Test_3828() + { + } + [Test] + public void Test_3829() + { + } + [Test] + public void Test_3830() + { + } + [Test] + public void Test_3831() + { + } + [Test] + public void Test_3832() + { + } + [Test] + public void Test_3833() + { + } + [Test] + public void Test_3834() + { + } + [Test] + public void Test_3835() + { + } + [Test] + public void Test_3836() + { + } + [Test] + public void Test_3837() + { + } + [Test] + public void Test_3838() + { + } + [Test] + public void Test_3839() + { + } + [Test] + public void Test_3840() + { + } + [Test] + public void Test_3841() + { + } + [Test] + public void Test_3842() + { + } + [Test] + public void Test_3843() + { + } + [Test] + public void Test_3844() + { + } + [Test] + public void Test_3845() + { + } + [Test] + public void Test_3846() + { + } + [Test] + public void Test_3847() + { + } + [Test] + public void Test_3848() + { + } + [Test] + public void Test_3849() + { + } + [Test] + public void Test_3850() + { + } + [Test] + public void Test_3851() + { + } + [Test] + public void Test_3852() + { + } + [Test] + public void Test_3853() + { + } + [Test] + public void Test_3854() + { + } + [Test] + public void Test_3855() + { + } + [Test] + public void Test_3856() + { + } + [Test] + public void Test_3857() + { + } + [Test] + public void Test_3858() + { + } + [Test] + public void Test_3859() + { + } + [Test] + public void Test_3860() + { + } + [Test] + public void Test_3861() + { + } + [Test] + public void Test_3862() + { + } + [Test] + public void Test_3863() + { + } + [Test] + public void Test_3864() + { + } + [Test] + public void Test_3865() + { + } + [Test] + public void Test_3866() + { + } + [Test] + public void Test_3867() + { + } + [Test] + public void Test_3868() + { + } + [Test] + public void Test_3869() + { + } + [Test] + public void Test_3870() + { + } + [Test] + public void Test_3871() + { + } + [Test] + public void Test_3872() + { + } + [Test] + public void Test_3873() + { + } + [Test] + public void Test_3874() + { + } + [Test] + public void Test_3875() + { + } + [Test] + public void Test_3876() + { + } + [Test] + public void Test_3877() + { + } + [Test] + public void Test_3878() + { + } + [Test] + public void Test_3879() + { + } + [Test] + public void Test_3880() + { + } + [Test] + public void Test_3881() + { + } + [Test] + public void Test_3882() + { + } + [Test] + public void Test_3883() + { + } + [Test] + public void Test_3884() + { + } + [Test] + public void Test_3885() + { + } + [Test] + public void Test_3886() + { + } + [Test] + public void Test_3887() + { + } + [Test] + public void Test_3888() + { + } + [Test] + public void Test_3889() + { + } + [Test] + public void Test_3890() + { + } + [Test] + public void Test_3891() + { + } + [Test] + public void Test_3892() + { + } + [Test] + public void Test_3893() + { + } + [Test] + public void Test_3894() + { + } + [Test] + public void Test_3895() + { + } + [Test] + public void Test_3896() + { + } + [Test] + public void Test_3897() + { + } + [Test] + public void Test_3898() + { + } + [Test] + public void Test_3899() + { + } + [Test] + public void Test_3900() + { + } + [Test] + public void Test_3901() + { + } + [Test] + public void Test_3902() + { + } + [Test] + public void Test_3903() + { + } + [Test] + public void Test_3904() + { + } + [Test] + public void Test_3905() + { + } + [Test] + public void Test_3906() + { + } + [Test] + public void Test_3907() + { + } + [Test] + public void Test_3908() + { + } + [Test] + public void Test_3909() + { + } + [Test] + public void Test_3910() + { + } + [Test] + public void Test_3911() + { + } + [Test] + public void Test_3912() + { + } + [Test] + public void Test_3913() + { + } + [Test] + public void Test_3914() + { + } + [Test] + public void Test_3915() + { + } + [Test] + public void Test_3916() + { + } + [Test] + public void Test_3917() + { + } + [Test] + public void Test_3918() + { + } + [Test] + public void Test_3919() + { + } + [Test] + public void Test_3920() + { + } + [Test] + public void Test_3921() + { + } + [Test] + public void Test_3922() + { + } + [Test] + public void Test_3923() + { + } + [Test] + public void Test_3924() + { + } + [Test] + public void Test_3925() + { + } + [Test] + public void Test_3926() + { + } + [Test] + public void Test_3927() + { + } + [Test] + public void Test_3928() + { + } + [Test] + public void Test_3929() + { + } + [Test] + public void Test_3930() + { + } + [Test] + public void Test_3931() + { + } + [Test] + public void Test_3932() + { + } + [Test] + public void Test_3933() + { + } + [Test] + public void Test_3934() + { + } + [Test] + public void Test_3935() + { + } + [Test] + public void Test_3936() + { + } + [Test] + public void Test_3937() + { + } + [Test] + public void Test_3938() + { + } + [Test] + public void Test_3939() + { + } + [Test] + public void Test_3940() + { + } + [Test] + public void Test_3941() + { + } + [Test] + public void Test_3942() + { + } + [Test] + public void Test_3943() + { + } + [Test] + public void Test_3944() + { + } + [Test] + public void Test_3945() + { + } + [Test] + public void Test_3946() + { + } + [Test] + public void Test_3947() + { + } + [Test] + public void Test_3948() + { + } + [Test] + public void Test_3949() + { + } + [Test] + public void Test_3950() + { + } + [Test] + public void Test_3951() + { + } + [Test] + public void Test_3952() + { + } + [Test] + public void Test_3953() + { + } + [Test] + public void Test_3954() + { + } + [Test] + public void Test_3955() + { + } + [Test] + public void Test_3956() + { + } + [Test] + public void Test_3957() + { + } + [Test] + public void Test_3958() + { + } + [Test] + public void Test_3959() + { + } + [Test] + public void Test_3960() + { + } + [Test] + public void Test_3961() + { + } + [Test] + public void Test_3962() + { + } + [Test] + public void Test_3963() + { + } + [Test] + public void Test_3964() + { + } + [Test] + public void Test_3965() + { + } + [Test] + public void Test_3966() + { + } + [Test] + public void Test_3967() + { + } + [Test] + public void Test_3968() + { + } + [Test] + public void Test_3969() + { + } + [Test] + public void Test_3970() + { + } + [Test] + public void Test_3971() + { + } + [Test] + public void Test_3972() + { + } + [Test] + public void Test_3973() + { + } + [Test] + public void Test_3974() + { + } + [Test] + public void Test_3975() + { + } + [Test] + public void Test_3976() + { + } + [Test] + public void Test_3977() + { + } + [Test] + public void Test_3978() + { + } + [Test] + public void Test_3979() + { + } + [Test] + public void Test_3980() + { + } + [Test] + public void Test_3981() + { + } + [Test] + public void Test_3982() + { + } + [Test] + public void Test_3983() + { + } + [Test] + public void Test_3984() + { + } + [Test] + public void Test_3985() + { + } + [Test] + public void Test_3986() + { + } + [Test] + public void Test_3987() + { + } + [Test] + public void Test_3988() + { + } + [Test] + public void Test_3989() + { + } + [Test] + public void Test_3990() + { + } + [Test] + public void Test_3991() + { + } + [Test] + public void Test_3992() + { + } + [Test] + public void Test_3993() + { + } + [Test] + public void Test_3994() + { + } + [Test] + public void Test_3995() + { + } + [Test] + public void Test_3996() + { + } + [Test] + public void Test_3997() + { + } + [Test] + public void Test_3998() + { + } + [Test] + public void Test_3999() + { + } + [Test] + public void Test_4000() + { + } + [Test] + public void Test_4001() + { + } + [Test] + public void Test_4002() + { + } + [Test] + public void Test_4003() + { + } + [Test] + public void Test_4004() + { + } + [Test] + public void Test_4005() + { + } + [Test] + public void Test_4006() + { + } + [Test] + public void Test_4007() + { + } + [Test] + public void Test_4008() + { + } + [Test] + public void Test_4009() + { + } + [Test] + public void Test_4010() + { + } + [Test] + public void Test_4011() + { + } + [Test] + public void Test_4012() + { + } + [Test] + public void Test_4013() + { + } + [Test] + public void Test_4014() + { + } + [Test] + public void Test_4015() + { + } + [Test] + public void Test_4016() + { + } + [Test] + public void Test_4017() + { + } + [Test] + public void Test_4018() + { + } + [Test] + public void Test_4019() + { + } + [Test] + public void Test_4020() + { + } + [Test] + public void Test_4021() + { + } + [Test] + public void Test_4022() + { + } + [Test] + public void Test_4023() + { + } + [Test] + public void Test_4024() + { + } + [Test] + public void Test_4025() + { + } + [Test] + public void Test_4026() + { + } + [Test] + public void Test_4027() + { + } + [Test] + public void Test_4028() + { + } + [Test] + public void Test_4029() + { + } + [Test] + public void Test_4030() + { + } + [Test] + public void Test_4031() + { + } + [Test] + public void Test_4032() + { + } + [Test] + public void Test_4033() + { + } + [Test] + public void Test_4034() + { + } + [Test] + public void Test_4035() + { + } + [Test] + public void Test_4036() + { + } + [Test] + public void Test_4037() + { + } + [Test] + public void Test_4038() + { + } + [Test] + public void Test_4039() + { + } + [Test] + public void Test_4040() + { + } + [Test] + public void Test_4041() + { + } + [Test] + public void Test_4042() + { + } + [Test] + public void Test_4043() + { + } + [Test] + public void Test_4044() + { + } + [Test] + public void Test_4045() + { + } + [Test] + public void Test_4046() + { + } + [Test] + public void Test_4047() + { + } + [Test] + public void Test_4048() + { + } + [Test] + public void Test_4049() + { + } + [Test] + public void Test_4050() + { + } + [Test] + public void Test_4051() + { + } + [Test] + public void Test_4052() + { + } + [Test] + public void Test_4053() + { + } + [Test] + public void Test_4054() + { + } + [Test] + public void Test_4055() + { + } + [Test] + public void Test_4056() + { + } + [Test] + public void Test_4057() + { + } + [Test] + public void Test_4058() + { + } + [Test] + public void Test_4059() + { + } + [Test] + public void Test_4060() + { + } + [Test] + public void Test_4061() + { + } + [Test] + public void Test_4062() + { + } + [Test] + public void Test_4063() + { + } + [Test] + public void Test_4064() + { + } + [Test] + public void Test_4065() + { + } + [Test] + public void Test_4066() + { + } + [Test] + public void Test_4067() + { + } + [Test] + public void Test_4068() + { + } + [Test] + public void Test_4069() + { + } + [Test] + public void Test_4070() + { + } + [Test] + public void Test_4071() + { + } + [Test] + public void Test_4072() + { + } + [Test] + public void Test_4073() + { + } + [Test] + public void Test_4074() + { + } + [Test] + public void Test_4075() + { + } + [Test] + public void Test_4076() + { + } + [Test] + public void Test_4077() + { + } + [Test] + public void Test_4078() + { + } + [Test] + public void Test_4079() + { + } + [Test] + public void Test_4080() + { + } + [Test] + public void Test_4081() + { + } + [Test] + public void Test_4082() + { + } + [Test] + public void Test_4083() + { + } + [Test] + public void Test_4084() + { + } + [Test] + public void Test_4085() + { + } + [Test] + public void Test_4086() + { + } + [Test] + public void Test_4087() + { + } + [Test] + public void Test_4088() + { + } + [Test] + public void Test_4089() + { + } + [Test] + public void Test_4090() + { + } + [Test] + public void Test_4091() + { + } + [Test] + public void Test_4092() + { + } + [Test] + public void Test_4093() + { + } + [Test] + public void Test_4094() + { + } + [Test] + public void Test_4095() + { + } + [Test] + public void Test_4096() + { + } + [Test] + public void Test_4097() + { + } + [Test] + public void Test_4098() + { + } + [Test] + public void Test_4099() + { + } + [Test] + public void Test_4100() + { + } + [Test] + public void Test_4101() + { + } + [Test] + public void Test_4102() + { + } + [Test] + public void Test_4103() + { + } + [Test] + public void Test_4104() + { + } + [Test] + public void Test_4105() + { + } + [Test] + public void Test_4106() + { + } + [Test] + public void Test_4107() + { + } + [Test] + public void Test_4108() + { + } + [Test] + public void Test_4109() + { + } + [Test] + public void Test_4110() + { + } + [Test] + public void Test_4111() + { + } + [Test] + public void Test_4112() + { + } + [Test] + public void Test_4113() + { + } + [Test] + public void Test_4114() + { + } + [Test] + public void Test_4115() + { + } + [Test] + public void Test_4116() + { + } + [Test] + public void Test_4117() + { + } + [Test] + public void Test_4118() + { + } + [Test] + public void Test_4119() + { + } + [Test] + public void Test_4120() + { + } + [Test] + public void Test_4121() + { + } + [Test] + public void Test_4122() + { + } + [Test] + public void Test_4123() + { + } + [Test] + public void Test_4124() + { + } + [Test] + public void Test_4125() + { + } + [Test] + public void Test_4126() + { + } + [Test] + public void Test_4127() + { + } + [Test] + public void Test_4128() + { + } + [Test] + public void Test_4129() + { + } + [Test] + public void Test_4130() + { + } + [Test] + public void Test_4131() + { + } + [Test] + public void Test_4132() + { + } + [Test] + public void Test_4133() + { + } + [Test] + public void Test_4134() + { + } + [Test] + public void Test_4135() + { + } + [Test] + public void Test_4136() + { + } + [Test] + public void Test_4137() + { + } + [Test] + public void Test_4138() + { + } + [Test] + public void Test_4139() + { + } + [Test] + public void Test_4140() + { + } + [Test] + public void Test_4141() + { + } + [Test] + public void Test_4142() + { + } + [Test] + public void Test_4143() + { + } + [Test] + public void Test_4144() + { + } + [Test] + public void Test_4145() + { + } + [Test] + public void Test_4146() + { + } + [Test] + public void Test_4147() + { + } + [Test] + public void Test_4148() + { + } + [Test] + public void Test_4149() + { + } + [Test] + public void Test_4150() + { + } + [Test] + public void Test_4151() + { + } + [Test] + public void Test_4152() + { + } + [Test] + public void Test_4153() + { + } + [Test] + public void Test_4154() + { + } + [Test] + public void Test_4155() + { + } + [Test] + public void Test_4156() + { + } + [Test] + public void Test_4157() + { + } + [Test] + public void Test_4158() + { + } + [Test] + public void Test_4159() + { + } + [Test] + public void Test_4160() + { + } + [Test] + public void Test_4161() + { + } + [Test] + public void Test_4162() + { + } + [Test] + public void Test_4163() + { + } + [Test] + public void Test_4164() + { + } + [Test] + public void Test_4165() + { + } + [Test] + public void Test_4166() + { + } + [Test] + public void Test_4167() + { + } + [Test] + public void Test_4168() + { + } + [Test] + public void Test_4169() + { + } + [Test] + public void Test_4170() + { + } + [Test] + public void Test_4171() + { + } + [Test] + public void Test_4172() + { + } + [Test] + public void Test_4173() + { + } + [Test] + public void Test_4174() + { + } + [Test] + public void Test_4175() + { + } + [Test] + public void Test_4176() + { + } + [Test] + public void Test_4177() + { + } + [Test] + public void Test_4178() + { + } + [Test] + public void Test_4179() + { + } + [Test] + public void Test_4180() + { + } + [Test] + public void Test_4181() + { + } + [Test] + public void Test_4182() + { + } + [Test] + public void Test_4183() + { + } + [Test] + public void Test_4184() + { + } + [Test] + public void Test_4185() + { + } + [Test] + public void Test_4186() + { + } + [Test] + public void Test_4187() + { + } + [Test] + public void Test_4188() + { + } + [Test] + public void Test_4189() + { + } + [Test] + public void Test_4190() + { + } + [Test] + public void Test_4191() + { + } + [Test] + public void Test_4192() + { + } + [Test] + public void Test_4193() + { + } + [Test] + public void Test_4194() + { + } + [Test] + public void Test_4195() + { + } + [Test] + public void Test_4196() + { + } + [Test] + public void Test_4197() + { + } + [Test] + public void Test_4198() + { + } + [Test] + public void Test_4199() + { + } + [Test] + public void Test_4200() + { + } + [Test] + public void Test_4201() + { + } + [Test] + public void Test_4202() + { + } + [Test] + public void Test_4203() + { + } + [Test] + public void Test_4204() + { + } + [Test] + public void Test_4205() + { + } + [Test] + public void Test_4206() + { + } + [Test] + public void Test_4207() + { + } + [Test] + public void Test_4208() + { + } + [Test] + public void Test_4209() + { + } + [Test] + public void Test_4210() + { + } + [Test] + public void Test_4211() + { + } + [Test] + public void Test_4212() + { + } + [Test] + public void Test_4213() + { + } + [Test] + public void Test_4214() + { + } + [Test] + public void Test_4215() + { + } + [Test] + public void Test_4216() + { + } + [Test] + public void Test_4217() + { + } + [Test] + public void Test_4218() + { + } + [Test] + public void Test_4219() + { + } + [Test] + public void Test_4220() + { + } + [Test] + public void Test_4221() + { + } + [Test] + public void Test_4222() + { + } + [Test] + public void Test_4223() + { + } + [Test] + public void Test_4224() + { + } + [Test] + public void Test_4225() + { + } + [Test] + public void Test_4226() + { + } + [Test] + public void Test_4227() + { + } + [Test] + public void Test_4228() + { + } + [Test] + public void Test_4229() + { + } + [Test] + public void Test_4230() + { + } + [Test] + public void Test_4231() + { + } + [Test] + public void Test_4232() + { + } + [Test] + public void Test_4233() + { + } + [Test] + public void Test_4234() + { + } + [Test] + public void Test_4235() + { + } + [Test] + public void Test_4236() + { + } + [Test] + public void Test_4237() + { + } + [Test] + public void Test_4238() + { + } + [Test] + public void Test_4239() + { + } + [Test] + public void Test_4240() + { + } + [Test] + public void Test_4241() + { + } + [Test] + public void Test_4242() + { + } + [Test] + public void Test_4243() + { + } + [Test] + public void Test_4244() + { + } + [Test] + public void Test_4245() + { + } + [Test] + public void Test_4246() + { + } + [Test] + public void Test_4247() + { + } + [Test] + public void Test_4248() + { + } + [Test] + public void Test_4249() + { + } + [Test] + public void Test_4250() + { + } + [Test] + public void Test_4251() + { + } + [Test] + public void Test_4252() + { + } + [Test] + public void Test_4253() + { + } + [Test] + public void Test_4254() + { + } + [Test] + public void Test_4255() + { + } + [Test] + public void Test_4256() + { + } + [Test] + public void Test_4257() + { + } + [Test] + public void Test_4258() + { + } + [Test] + public void Test_4259() + { + } + [Test] + public void Test_4260() + { + } + [Test] + public void Test_4261() + { + } + [Test] + public void Test_4262() + { + } + [Test] + public void Test_4263() + { + } + [Test] + public void Test_4264() + { + } + [Test] + public void Test_4265() + { + } + [Test] + public void Test_4266() + { + } + [Test] + public void Test_4267() + { + } + [Test] + public void Test_4268() + { + } + [Test] + public void Test_4269() + { + } + [Test] + public void Test_4270() + { + } + [Test] + public void Test_4271() + { + } + [Test] + public void Test_4272() + { + } + [Test] + public void Test_4273() + { + } + [Test] + public void Test_4274() + { + } + [Test] + public void Test_4275() + { + } + [Test] + public void Test_4276() + { + } + [Test] + public void Test_4277() + { + } + [Test] + public void Test_4278() + { + } + [Test] + public void Test_4279() + { + } + [Test] + public void Test_4280() + { + } + [Test] + public void Test_4281() + { + } + [Test] + public void Test_4282() + { + } + [Test] + public void Test_4283() + { + } + [Test] + public void Test_4284() + { + } + [Test] + public void Test_4285() + { + } + [Test] + public void Test_4286() + { + } + [Test] + public void Test_4287() + { + } + [Test] + public void Test_4288() + { + } + [Test] + public void Test_4289() + { + } + [Test] + public void Test_4290() + { + } + [Test] + public void Test_4291() + { + } + [Test] + public void Test_4292() + { + } + [Test] + public void Test_4293() + { + } + [Test] + public void Test_4294() + { + } + [Test] + public void Test_4295() + { + } + [Test] + public void Test_4296() + { + } + [Test] + public void Test_4297() + { + } + [Test] + public void Test_4298() + { + } + [Test] + public void Test_4299() + { + } + [Test] + public void Test_4300() + { + } + [Test] + public void Test_4301() + { + } + [Test] + public void Test_4302() + { + } + [Test] + public void Test_4303() + { + } + [Test] + public void Test_4304() + { + } + [Test] + public void Test_4305() + { + } + [Test] + public void Test_4306() + { + } + [Test] + public void Test_4307() + { + } + [Test] + public void Test_4308() + { + } + [Test] + public void Test_4309() + { + } + [Test] + public void Test_4310() + { + } + [Test] + public void Test_4311() + { + } + [Test] + public void Test_4312() + { + } + [Test] + public void Test_4313() + { + } + [Test] + public void Test_4314() + { + } + [Test] + public void Test_4315() + { + } + [Test] + public void Test_4316() + { + } + [Test] + public void Test_4317() + { + } + [Test] + public void Test_4318() + { + } + [Test] + public void Test_4319() + { + } + [Test] + public void Test_4320() + { + } + [Test] + public void Test_4321() + { + } + [Test] + public void Test_4322() + { + } + [Test] + public void Test_4323() + { + } + [Test] + public void Test_4324() + { + } + [Test] + public void Test_4325() + { + } + [Test] + public void Test_4326() + { + } + [Test] + public void Test_4327() + { + } + [Test] + public void Test_4328() + { + } + [Test] + public void Test_4329() + { + } + [Test] + public void Test_4330() + { + } + [Test] + public void Test_4331() + { + } + [Test] + public void Test_4332() + { + } + [Test] + public void Test_4333() + { + } + [Test] + public void Test_4334() + { + } + [Test] + public void Test_4335() + { + } + [Test] + public void Test_4336() + { + } + [Test] + public void Test_4337() + { + } + [Test] + public void Test_4338() + { + } + [Test] + public void Test_4339() + { + } + [Test] + public void Test_4340() + { + } + [Test] + public void Test_4341() + { + } + [Test] + public void Test_4342() + { + } + [Test] + public void Test_4343() + { + } + [Test] + public void Test_4344() + { + } + [Test] + public void Test_4345() + { + } + [Test] + public void Test_4346() + { + } + [Test] + public void Test_4347() + { + } + [Test] + public void Test_4348() + { + } + [Test] + public void Test_4349() + { + } + [Test] + public void Test_4350() + { + } + [Test] + public void Test_4351() + { + } + [Test] + public void Test_4352() + { + } + [Test] + public void Test_4353() + { + } + [Test] + public void Test_4354() + { + } + [Test] + public void Test_4355() + { + } + [Test] + public void Test_4356() + { + } + [Test] + public void Test_4357() + { + } + [Test] + public void Test_4358() + { + } + [Test] + public void Test_4359() + { + } + [Test] + public void Test_4360() + { + } + [Test] + public void Test_4361() + { + } + [Test] + public void Test_4362() + { + } + [Test] + public void Test_4363() + { + } + [Test] + public void Test_4364() + { + } + [Test] + public void Test_4365() + { + } + [Test] + public void Test_4366() + { + } + [Test] + public void Test_4367() + { + } + [Test] + public void Test_4368() + { + } + [Test] + public void Test_4369() + { + } + [Test] + public void Test_4370() + { + } + [Test] + public void Test_4371() + { + } + [Test] + public void Test_4372() + { + } + [Test] + public void Test_4373() + { + } + [Test] + public void Test_4374() + { + } + [Test] + public void Test_4375() + { + } + [Test] + public void Test_4376() + { + } + [Test] + public void Test_4377() + { + } + [Test] + public void Test_4378() + { + } + [Test] + public void Test_4379() + { + } + [Test] + public void Test_4380() + { + } + [Test] + public void Test_4381() + { + } + [Test] + public void Test_4382() + { + } + [Test] + public void Test_4383() + { + } + [Test] + public void Test_4384() + { + } + [Test] + public void Test_4385() + { + } + [Test] + public void Test_4386() + { + } + [Test] + public void Test_4387() + { + } + [Test] + public void Test_4388() + { + } + [Test] + public void Test_4389() + { + } + [Test] + public void Test_4390() + { + } + [Test] + public void Test_4391() + { + } + [Test] + public void Test_4392() + { + } + [Test] + public void Test_4393() + { + } + [Test] + public void Test_4394() + { + } + [Test] + public void Test_4395() + { + } + [Test] + public void Test_4396() + { + } + [Test] + public void Test_4397() + { + } + [Test] + public void Test_4398() + { + } + [Test] + public void Test_4399() + { + } + [Test] + public void Test_4400() + { + } + [Test] + public void Test_4401() + { + } + [Test] + public void Test_4402() + { + } + [Test] + public void Test_4403() + { + } + [Test] + public void Test_4404() + { + } + [Test] + public void Test_4405() + { + } + [Test] + public void Test_4406() + { + } + [Test] + public void Test_4407() + { + } + [Test] + public void Test_4408() + { + } + [Test] + public void Test_4409() + { + } + [Test] + public void Test_4410() + { + } + [Test] + public void Test_4411() + { + } + [Test] + public void Test_4412() + { + } + [Test] + public void Test_4413() + { + } + [Test] + public void Test_4414() + { + } + [Test] + public void Test_4415() + { + } + [Test] + public void Test_4416() + { + } + [Test] + public void Test_4417() + { + } + [Test] + public void Test_4418() + { + } + [Test] + public void Test_4419() + { + } + [Test] + public void Test_4420() + { + } + [Test] + public void Test_4421() + { + } + [Test] + public void Test_4422() + { + } + [Test] + public void Test_4423() + { + } + [Test] + public void Test_4424() + { + } + [Test] + public void Test_4425() + { + } + [Test] + public void Test_4426() + { + } + [Test] + public void Test_4427() + { + } + [Test] + public void Test_4428() + { + } + [Test] + public void Test_4429() + { + } + [Test] + public void Test_4430() + { + } + [Test] + public void Test_4431() + { + } + [Test] + public void Test_4432() + { + } + [Test] + public void Test_4433() + { + } + [Test] + public void Test_4434() + { + } + [Test] + public void Test_4435() + { + } + [Test] + public void Test_4436() + { + } + [Test] + public void Test_4437() + { + } + [Test] + public void Test_4438() + { + } + [Test] + public void Test_4439() + { + } + [Test] + public void Test_4440() + { + } + [Test] + public void Test_4441() + { + } + [Test] + public void Test_4442() + { + } + [Test] + public void Test_4443() + { + } + [Test] + public void Test_4444() + { + } + [Test] + public void Test_4445() + { + } + [Test] + public void Test_4446() + { + } + [Test] + public void Test_4447() + { + } + [Test] + public void Test_4448() + { + } + [Test] + public void Test_4449() + { + } + [Test] + public void Test_4450() + { + } + [Test] + public void Test_4451() + { + } + [Test] + public void Test_4452() + { + } + [Test] + public void Test_4453() + { + } + [Test] + public void Test_4454() + { + } + [Test] + public void Test_4455() + { + } + [Test] + public void Test_4456() + { + } + [Test] + public void Test_4457() + { + } + [Test] + public void Test_4458() + { + } + [Test] + public void Test_4459() + { + } + [Test] + public void Test_4460() + { + } + [Test] + public void Test_4461() + { + } + [Test] + public void Test_4462() + { + } + [Test] + public void Test_4463() + { + } + [Test] + public void Test_4464() + { + } + [Test] + public void Test_4465() + { + } + [Test] + public void Test_4466() + { + } + [Test] + public void Test_4467() + { + } + [Test] + public void Test_4468() + { + } + [Test] + public void Test_4469() + { + } + [Test] + public void Test_4470() + { + } + [Test] + public void Test_4471() + { + } + [Test] + public void Test_4472() + { + } + [Test] + public void Test_4473() + { + } + [Test] + public void Test_4474() + { + } + [Test] + public void Test_4475() + { + } + [Test] + public void Test_4476() + { + } + [Test] + public void Test_4477() + { + } + [Test] + public void Test_4478() + { + } + [Test] + public void Test_4479() + { + } + [Test] + public void Test_4480() + { + } + [Test] + public void Test_4481() + { + } + [Test] + public void Test_4482() + { + } + [Test] + public void Test_4483() + { + } + [Test] + public void Test_4484() + { + } + [Test] + public void Test_4485() + { + } + [Test] + public void Test_4486() + { + } + [Test] + public void Test_4487() + { + } + [Test] + public void Test_4488() + { + } + [Test] + public void Test_4489() + { + } + [Test] + public void Test_4490() + { + } + [Test] + public void Test_4491() + { + } + [Test] + public void Test_4492() + { + } + [Test] + public void Test_4493() + { + } + [Test] + public void Test_4494() + { + } + [Test] + public void Test_4495() + { + } + [Test] + public void Test_4496() + { + } + [Test] + public void Test_4497() + { + } + [Test] + public void Test_4498() + { + } + [Test] + public void Test_4499() + { + } + [Test] + public void Test_4500() + { + } + [Test] + public void Test_4501() + { + } + [Test] + public void Test_4502() + { + } + [Test] + public void Test_4503() + { + } + [Test] + public void Test_4504() + { + } + [Test] + public void Test_4505() + { + } + [Test] + public void Test_4506() + { + } + [Test] + public void Test_4507() + { + } + [Test] + public void Test_4508() + { + } + [Test] + public void Test_4509() + { + } + [Test] + public void Test_4510() + { + } + [Test] + public void Test_4511() + { + } + [Test] + public void Test_4512() + { + } + [Test] + public void Test_4513() + { + } + [Test] + public void Test_4514() + { + } + [Test] + public void Test_4515() + { + } + [Test] + public void Test_4516() + { + } + [Test] + public void Test_4517() + { + } + [Test] + public void Test_4518() + { + } + [Test] + public void Test_4519() + { + } + [Test] + public void Test_4520() + { + } + [Test] + public void Test_4521() + { + } + [Test] + public void Test_4522() + { + } + [Test] + public void Test_4523() + { + } + [Test] + public void Test_4524() + { + } + [Test] + public void Test_4525() + { + } + [Test] + public void Test_4526() + { + } + [Test] + public void Test_4527() + { + } + [Test] + public void Test_4528() + { + } + [Test] + public void Test_4529() + { + } + [Test] + public void Test_4530() + { + } + [Test] + public void Test_4531() + { + } + [Test] + public void Test_4532() + { + } + [Test] + public void Test_4533() + { + } + [Test] + public void Test_4534() + { + } + [Test] + public void Test_4535() + { + } + [Test] + public void Test_4536() + { + } + [Test] + public void Test_4537() + { + } + [Test] + public void Test_4538() + { + } + [Test] + public void Test_4539() + { + } + [Test] + public void Test_4540() + { + } + [Test] + public void Test_4541() + { + } + [Test] + public void Test_4542() + { + } + [Test] + public void Test_4543() + { + } + [Test] + public void Test_4544() + { + } + [Test] + public void Test_4545() + { + } + [Test] + public void Test_4546() + { + } + [Test] + public void Test_4547() + { + } + [Test] + public void Test_4548() + { + } + [Test] + public void Test_4549() + { + } + [Test] + public void Test_4550() + { + } + [Test] + public void Test_4551() + { + } + [Test] + public void Test_4552() + { + } + [Test] + public void Test_4553() + { + } + [Test] + public void Test_4554() + { + } + [Test] + public void Test_4555() + { + } + [Test] + public void Test_4556() + { + } + [Test] + public void Test_4557() + { + } + [Test] + public void Test_4558() + { + } + [Test] + public void Test_4559() + { + } + [Test] + public void Test_4560() + { + } + [Test] + public void Test_4561() + { + } + [Test] + public void Test_4562() + { + } + [Test] + public void Test_4563() + { + } + [Test] + public void Test_4564() + { + } + [Test] + public void Test_4565() + { + } + [Test] + public void Test_4566() + { + } + [Test] + public void Test_4567() + { + } + [Test] + public void Test_4568() + { + } + [Test] + public void Test_4569() + { + } + [Test] + public void Test_4570() + { + } + [Test] + public void Test_4571() + { + } + [Test] + public void Test_4572() + { + } + [Test] + public void Test_4573() + { + } + [Test] + public void Test_4574() + { + } + [Test] + public void Test_4575() + { + } + [Test] + public void Test_4576() + { + } + [Test] + public void Test_4577() + { + } + [Test] + public void Test_4578() + { + } + [Test] + public void Test_4579() + { + } + [Test] + public void Test_4580() + { + } + [Test] + public void Test_4581() + { + } + [Test] + public void Test_4582() + { + } + [Test] + public void Test_4583() + { + } + [Test] + public void Test_4584() + { + } + [Test] + public void Test_4585() + { + } + [Test] + public void Test_4586() + { + } + [Test] + public void Test_4587() + { + } + [Test] + public void Test_4588() + { + } + [Test] + public void Test_4589() + { + } + [Test] + public void Test_4590() + { + } + [Test] + public void Test_4591() + { + } + [Test] + public void Test_4592() + { + } + [Test] + public void Test_4593() + { + } + [Test] + public void Test_4594() + { + } + [Test] + public void Test_4595() + { + } + [Test] + public void Test_4596() + { + } + [Test] + public void Test_4597() + { + } + [Test] + public void Test_4598() + { + } + [Test] + public void Test_4599() + { + } + [Test] + public void Test_4600() + { + } + [Test] + public void Test_4601() + { + } + [Test] + public void Test_4602() + { + } + [Test] + public void Test_4603() + { + } + [Test] + public void Test_4604() + { + } + [Test] + public void Test_4605() + { + } + [Test] + public void Test_4606() + { + } + [Test] + public void Test_4607() + { + } + [Test] + public void Test_4608() + { + } + [Test] + public void Test_4609() + { + } + [Test] + public void Test_4610() + { + } + [Test] + public void Test_4611() + { + } + [Test] + public void Test_4612() + { + } + [Test] + public void Test_4613() + { + } + [Test] + public void Test_4614() + { + } + [Test] + public void Test_4615() + { + } + [Test] + public void Test_4616() + { + } + [Test] + public void Test_4617() + { + } + [Test] + public void Test_4618() + { + } + [Test] + public void Test_4619() + { + } + [Test] + public void Test_4620() + { + } + [Test] + public void Test_4621() + { + } + [Test] + public void Test_4622() + { + } + [Test] + public void Test_4623() + { + } + [Test] + public void Test_4624() + { + } + [Test] + public void Test_4625() + { + } + [Test] + public void Test_4626() + { + } + [Test] + public void Test_4627() + { + } + [Test] + public void Test_4628() + { + } + [Test] + public void Test_4629() + { + } + [Test] + public void Test_4630() + { + } + [Test] + public void Test_4631() + { + } + [Test] + public void Test_4632() + { + } + [Test] + public void Test_4633() + { + } + [Test] + public void Test_4634() + { + } + [Test] + public void Test_4635() + { + } + [Test] + public void Test_4636() + { + } + [Test] + public void Test_4637() + { + } + [Test] + public void Test_4638() + { + } + [Test] + public void Test_4639() + { + } + [Test] + public void Test_4640() + { + } + [Test] + public void Test_4641() + { + } + [Test] + public void Test_4642() + { + } + [Test] + public void Test_4643() + { + } + [Test] + public void Test_4644() + { + } + [Test] + public void Test_4645() + { + } + [Test] + public void Test_4646() + { + } + [Test] + public void Test_4647() + { + } + [Test] + public void Test_4648() + { + } + [Test] + public void Test_4649() + { + } + [Test] + public void Test_4650() + { + } + [Test] + public void Test_4651() + { + } + [Test] + public void Test_4652() + { + } + [Test] + public void Test_4653() + { + } + [Test] + public void Test_4654() + { + } + [Test] + public void Test_4655() + { + } + [Test] + public void Test_4656() + { + } + [Test] + public void Test_4657() + { + } + [Test] + public void Test_4658() + { + } + [Test] + public void Test_4659() + { + } + [Test] + public void Test_4660() + { + } + [Test] + public void Test_4661() + { + } + [Test] + public void Test_4662() + { + } + [Test] + public void Test_4663() + { + } + [Test] + public void Test_4664() + { + } + [Test] + public void Test_4665() + { + } + [Test] + public void Test_4666() + { + } + [Test] + public void Test_4667() + { + } + [Test] + public void Test_4668() + { + } + [Test] + public void Test_4669() + { + } + [Test] + public void Test_4670() + { + } + [Test] + public void Test_4671() + { + } + [Test] + public void Test_4672() + { + } + [Test] + public void Test_4673() + { + } + [Test] + public void Test_4674() + { + } + [Test] + public void Test_4675() + { + } + [Test] + public void Test_4676() + { + } + [Test] + public void Test_4677() + { + } + [Test] + public void Test_4678() + { + } + [Test] + public void Test_4679() + { + } + [Test] + public void Test_4680() + { + } + [Test] + public void Test_4681() + { + } + [Test] + public void Test_4682() + { + } + [Test] + public void Test_4683() + { + } + [Test] + public void Test_4684() + { + } + [Test] + public void Test_4685() + { + } + [Test] + public void Test_4686() + { + } + [Test] + public void Test_4687() + { + } + [Test] + public void Test_4688() + { + } + [Test] + public void Test_4689() + { + } + [Test] + public void Test_4690() + { + } + [Test] + public void Test_4691() + { + } + [Test] + public void Test_4692() + { + } + [Test] + public void Test_4693() + { + } + [Test] + public void Test_4694() + { + } + [Test] + public void Test_4695() + { + } + [Test] + public void Test_4696() + { + } + [Test] + public void Test_4697() + { + } + [Test] + public void Test_4698() + { + } + [Test] + public void Test_4699() + { + } + [Test] + public void Test_4700() + { + } + [Test] + public void Test_4701() + { + } + [Test] + public void Test_4702() + { + } + [Test] + public void Test_4703() + { + } + [Test] + public void Test_4704() + { + } + [Test] + public void Test_4705() + { + } + [Test] + public void Test_4706() + { + } + [Test] + public void Test_4707() + { + } + [Test] + public void Test_4708() + { + } + [Test] + public void Test_4709() + { + } + [Test] + public void Test_4710() + { + } + [Test] + public void Test_4711() + { + } + [Test] + public void Test_4712() + { + } + [Test] + public void Test_4713() + { + } + [Test] + public void Test_4714() + { + } + [Test] + public void Test_4715() + { + } + [Test] + public void Test_4716() + { + } + [Test] + public void Test_4717() + { + } + [Test] + public void Test_4718() + { + } + [Test] + public void Test_4719() + { + } + [Test] + public void Test_4720() + { + } + [Test] + public void Test_4721() + { + } + [Test] + public void Test_4722() + { + } + [Test] + public void Test_4723() + { + } + [Test] + public void Test_4724() + { + } + [Test] + public void Test_4725() + { + } + [Test] + public void Test_4726() + { + } + [Test] + public void Test_4727() + { + } + [Test] + public void Test_4728() + { + } + [Test] + public void Test_4729() + { + } + [Test] + public void Test_4730() + { + } + [Test] + public void Test_4731() + { + } + [Test] + public void Test_4732() + { + } + [Test] + public void Test_4733() + { + } + [Test] + public void Test_4734() + { + } + [Test] + public void Test_4735() + { + } + [Test] + public void Test_4736() + { + } + [Test] + public void Test_4737() + { + } + [Test] + public void Test_4738() + { + } + [Test] + public void Test_4739() + { + } + [Test] + public void Test_4740() + { + } + [Test] + public void Test_4741() + { + } + [Test] + public void Test_4742() + { + } + [Test] + public void Test_4743() + { + } + [Test] + public void Test_4744() + { + } + [Test] + public void Test_4745() + { + } + [Test] + public void Test_4746() + { + } + [Test] + public void Test_4747() + { + } + [Test] + public void Test_4748() + { + } + [Test] + public void Test_4749() + { + } + [Test] + public void Test_4750() + { + } + [Test] + public void Test_4751() + { + } + [Test] + public void Test_4752() + { + } + [Test] + public void Test_4753() + { + } + [Test] + public void Test_4754() + { + } + [Test] + public void Test_4755() + { + } + [Test] + public void Test_4756() + { + } + [Test] + public void Test_4757() + { + } + [Test] + public void Test_4758() + { + } + [Test] + public void Test_4759() + { + } + [Test] + public void Test_4760() + { + } + [Test] + public void Test_4761() + { + } + [Test] + public void Test_4762() + { + } + [Test] + public void Test_4763() + { + } + [Test] + public void Test_4764() + { + } + [Test] + public void Test_4765() + { + } + [Test] + public void Test_4766() + { + } + [Test] + public void Test_4767() + { + } + [Test] + public void Test_4768() + { + } + [Test] + public void Test_4769() + { + } + [Test] + public void Test_4770() + { + } + [Test] + public void Test_4771() + { + } + [Test] + public void Test_4772() + { + } + [Test] + public void Test_4773() + { + } + [Test] + public void Test_4774() + { + } + [Test] + public void Test_4775() + { + } + [Test] + public void Test_4776() + { + } + [Test] + public void Test_4777() + { + } + [Test] + public void Test_4778() + { + } + [Test] + public void Test_4779() + { + } + [Test] + public void Test_4780() + { + } + [Test] + public void Test_4781() + { + } + [Test] + public void Test_4782() + { + } + [Test] + public void Test_4783() + { + } + [Test] + public void Test_4784() + { + } + [Test] + public void Test_4785() + { + } + [Test] + public void Test_4786() + { + } + [Test] + public void Test_4787() + { + } + [Test] + public void Test_4788() + { + } + [Test] + public void Test_4789() + { + } + [Test] + public void Test_4790() + { + } + [Test] + public void Test_4791() + { + } + [Test] + public void Test_4792() + { + } + [Test] + public void Test_4793() + { + } + [Test] + public void Test_4794() + { + } + [Test] + public void Test_4795() + { + } + [Test] + public void Test_4796() + { + } + [Test] + public void Test_4797() + { + } + [Test] + public void Test_4798() + { + } + [Test] + public void Test_4799() + { + } + [Test] + public void Test_4800() + { + } + [Test] + public void Test_4801() + { + } + [Test] + public void Test_4802() + { + } + [Test] + public void Test_4803() + { + } + [Test] + public void Test_4804() + { + } + [Test] + public void Test_4805() + { + } + [Test] + public void Test_4806() + { + } + [Test] + public void Test_4807() + { + } + [Test] + public void Test_4808() + { + } + [Test] + public void Test_4809() + { + } + [Test] + public void Test_4810() + { + } + [Test] + public void Test_4811() + { + } + [Test] + public void Test_4812() + { + } + [Test] + public void Test_4813() + { + } + [Test] + public void Test_4814() + { + } + [Test] + public void Test_4815() + { + } + [Test] + public void Test_4816() + { + } + [Test] + public void Test_4817() + { + } + [Test] + public void Test_4818() + { + } + [Test] + public void Test_4819() + { + } + [Test] + public void Test_4820() + { + } + [Test] + public void Test_4821() + { + } + [Test] + public void Test_4822() + { + } + [Test] + public void Test_4823() + { + } + [Test] + public void Test_4824() + { + } + [Test] + public void Test_4825() + { + } + [Test] + public void Test_4826() + { + } + [Test] + public void Test_4827() + { + } + [Test] + public void Test_4828() + { + } + [Test] + public void Test_4829() + { + } + [Test] + public void Test_4830() + { + } + [Test] + public void Test_4831() + { + } + [Test] + public void Test_4832() + { + } + [Test] + public void Test_4833() + { + } + [Test] + public void Test_4834() + { + } + [Test] + public void Test_4835() + { + } + [Test] + public void Test_4836() + { + } + [Test] + public void Test_4837() + { + } + [Test] + public void Test_4838() + { + } + [Test] + public void Test_4839() + { + } + [Test] + public void Test_4840() + { + } + [Test] + public void Test_4841() + { + } + [Test] + public void Test_4842() + { + } + [Test] + public void Test_4843() + { + } + [Test] + public void Test_4844() + { + } + [Test] + public void Test_4845() + { + } + [Test] + public void Test_4846() + { + } + [Test] + public void Test_4847() + { + } + [Test] + public void Test_4848() + { + } + [Test] + public void Test_4849() + { + } + [Test] + public void Test_4850() + { + } + [Test] + public void Test_4851() + { + } + [Test] + public void Test_4852() + { + } + [Test] + public void Test_4853() + { + } + [Test] + public void Test_4854() + { + } + [Test] + public void Test_4855() + { + } + [Test] + public void Test_4856() + { + } + [Test] + public void Test_4857() + { + } + [Test] + public void Test_4858() + { + } + [Test] + public void Test_4859() + { + } + [Test] + public void Test_4860() + { + } + [Test] + public void Test_4861() + { + } + [Test] + public void Test_4862() + { + } + [Test] + public void Test_4863() + { + } + [Test] + public void Test_4864() + { + } + [Test] + public void Test_4865() + { + } + [Test] + public void Test_4866() + { + } + [Test] + public void Test_4867() + { + } + [Test] + public void Test_4868() + { + } + [Test] + public void Test_4869() + { + } + [Test] + public void Test_4870() + { + } + [Test] + public void Test_4871() + { + } + [Test] + public void Test_4872() + { + } + [Test] + public void Test_4873() + { + } + [Test] + public void Test_4874() + { + } + [Test] + public void Test_4875() + { + } + [Test] + public void Test_4876() + { + } + [Test] + public void Test_4877() + { + } + [Test] + public void Test_4878() + { + } + [Test] + public void Test_4879() + { + } + [Test] + public void Test_4880() + { + } + [Test] + public void Test_4881() + { + } + [Test] + public void Test_4882() + { + } + [Test] + public void Test_4883() + { + } + [Test] + public void Test_4884() + { + } + [Test] + public void Test_4885() + { + } + [Test] + public void Test_4886() + { + } + [Test] + public void Test_4887() + { + } + [Test] + public void Test_4888() + { + } + [Test] + public void Test_4889() + { + } + [Test] + public void Test_4890() + { + } + [Test] + public void Test_4891() + { + } + [Test] + public void Test_4892() + { + } + [Test] + public void Test_4893() + { + } + [Test] + public void Test_4894() + { + } + [Test] + public void Test_4895() + { + } + [Test] + public void Test_4896() + { + } + [Test] + public void Test_4897() + { + } + [Test] + public void Test_4898() + { + } + [Test] + public void Test_4899() + { + } + [Test] + public void Test_4900() + { + } + [Test] + public void Test_4901() + { + } + [Test] + public void Test_4902() + { + } + [Test] + public void Test_4903() + { + } + [Test] + public void Test_4904() + { + } + [Test] + public void Test_4905() + { + } + [Test] + public void Test_4906() + { + } + [Test] + public void Test_4907() + { + } + [Test] + public void Test_4908() + { + } + [Test] + public void Test_4909() + { + } + [Test] + public void Test_4910() + { + } + [Test] + public void Test_4911() + { + } + [Test] + public void Test_4912() + { + } + [Test] + public void Test_4913() + { + } + [Test] + public void Test_4914() + { + } + [Test] + public void Test_4915() + { + } + [Test] + public void Test_4916() + { + } + [Test] + public void Test_4917() + { + } + [Test] + public void Test_4918() + { + } + [Test] + public void Test_4919() + { + } + [Test] + public void Test_4920() + { + } + [Test] + public void Test_4921() + { + } + [Test] + public void Test_4922() + { + } + [Test] + public void Test_4923() + { + } + [Test] + public void Test_4924() + { + } + [Test] + public void Test_4925() + { + } + [Test] + public void Test_4926() + { + } + [Test] + public void Test_4927() + { + } + [Test] + public void Test_4928() + { + } + [Test] + public void Test_4929() + { + } + [Test] + public void Test_4930() + { + } + [Test] + public void Test_4931() + { + } + [Test] + public void Test_4932() + { + } + [Test] + public void Test_4933() + { + } + [Test] + public void Test_4934() + { + } + [Test] + public void Test_4935() + { + } + [Test] + public void Test_4936() + { + } + [Test] + public void Test_4937() + { + } + [Test] + public void Test_4938() + { + } + [Test] + public void Test_4939() + { + } + [Test] + public void Test_4940() + { + } + [Test] + public void Test_4941() + { + } + [Test] + public void Test_4942() + { + } + [Test] + public void Test_4943() + { + } + [Test] + public void Test_4944() + { + } + [Test] + public void Test_4945() + { + } + [Test] + public void Test_4946() + { + } + [Test] + public void Test_4947() + { + } + [Test] + public void Test_4948() + { + } + [Test] + public void Test_4949() + { + } + [Test] + public void Test_4950() + { + } + [Test] + public void Test_4951() + { + } + [Test] + public void Test_4952() + { + } + [Test] + public void Test_4953() + { + } + [Test] + public void Test_4954() + { + } + [Test] + public void Test_4955() + { + } + [Test] + public void Test_4956() + { + } + [Test] + public void Test_4957() + { + } + [Test] + public void Test_4958() + { + } + [Test] + public void Test_4959() + { + } + [Test] + public void Test_4960() + { + } + [Test] + public void Test_4961() + { + } + [Test] + public void Test_4962() + { + } + [Test] + public void Test_4963() + { + } + [Test] + public void Test_4964() + { + } + [Test] + public void Test_4965() + { + } + [Test] + public void Test_4966() + { + } + [Test] + public void Test_4967() + { + } + [Test] + public void Test_4968() + { + } + [Test] + public void Test_4969() + { + } + [Test] + public void Test_4970() + { + } + [Test] + public void Test_4971() + { + } + [Test] + public void Test_4972() + { + } + [Test] + public void Test_4973() + { + } + [Test] + public void Test_4974() + { + } + [Test] + public void Test_4975() + { + } + [Test] + public void Test_4976() + { + } + [Test] + public void Test_4977() + { + } + [Test] + public void Test_4978() + { + } + [Test] + public void Test_4979() + { + } + [Test] + public void Test_4980() + { + } + [Test] + public void Test_4981() + { + } + [Test] + public void Test_4982() + { + } + [Test] + public void Test_4983() + { + } + [Test] + public void Test_4984() + { + } + [Test] + public void Test_4985() + { + } + [Test] + public void Test_4986() + { + } + [Test] + public void Test_4987() + { + } + [Test] + public void Test_4988() + { + } + [Test] + public void Test_4989() + { + } + [Test] + public void Test_4990() + { + } + [Test] + public void Test_4991() + { + } + [Test] + public void Test_4992() + { + } + [Test] + public void Test_4993() + { + } + [Test] + public void Test_4994() + { + } + [Test] + public void Test_4995() + { + } + [Test] + public void Test_4996() + { + } + [Test] + public void Test_4997() + { + } + [Test] + public void Test_4998() + { + } + [Test] + public void Test_4999() + { + } + [Test] + public void Test_5000() + { + } + [Test] + public void Test_5001() + { + } + [Test] + public void Test_5002() + { + } + [Test] + public void Test_5003() + { + } + [Test] + public void Test_5004() + { + } + [Test] + public void Test_5005() + { + } + [Test] + public void Test_5006() + { + } + [Test] + public void Test_5007() + { + } + [Test] + public void Test_5008() + { + } + [Test] + public void Test_5009() + { + } + [Test] + public void Test_5010() + { + } + [Test] + public void Test_5011() + { + } + [Test] + public void Test_5012() + { + } + [Test] + public void Test_5013() + { + } + [Test] + public void Test_5014() + { + } + [Test] + public void Test_5015() + { + } + [Test] + public void Test_5016() + { + } + [Test] + public void Test_5017() + { + } + [Test] + public void Test_5018() + { + } + [Test] + public void Test_5019() + { + } + [Test] + public void Test_5020() + { + } + [Test] + public void Test_5021() + { + } + [Test] + public void Test_5022() + { + } + [Test] + public void Test_5023() + { + } + [Test] + public void Test_5024() + { + } + [Test] + public void Test_5025() + { + } + [Test] + public void Test_5026() + { + } + [Test] + public void Test_5027() + { + } + [Test] + public void Test_5028() + { + } + [Test] + public void Test_5029() + { + } + [Test] + public void Test_5030() + { + } + [Test] + public void Test_5031() + { + } + [Test] + public void Test_5032() + { + } + [Test] + public void Test_5033() + { + } + [Test] + public void Test_5034() + { + } + [Test] + public void Test_5035() + { + } + [Test] + public void Test_5036() + { + } + [Test] + public void Test_5037() + { + } + [Test] + public void Test_5038() + { + } + [Test] + public void Test_5039() + { + } + [Test] + public void Test_5040() + { + } + [Test] + public void Test_5041() + { + } + [Test] + public void Test_5042() + { + } + [Test] + public void Test_5043() + { + } + [Test] + public void Test_5044() + { + } + [Test] + public void Test_5045() + { + } + [Test] + public void Test_5046() + { + } + [Test] + public void Test_5047() + { + } + [Test] + public void Test_5048() + { + } + [Test] + public void Test_5049() + { + } + [Test] + public void Test_5050() + { + } + [Test] + public void Test_5051() + { + } + [Test] + public void Test_5052() + { + } + [Test] + public void Test_5053() + { + } + [Test] + public void Test_5054() + { + } + [Test] + public void Test_5055() + { + } + [Test] + public void Test_5056() + { + } + [Test] + public void Test_5057() + { + } + [Test] + public void Test_5058() + { + } + [Test] + public void Test_5059() + { + } + [Test] + public void Test_5060() + { + } + [Test] + public void Test_5061() + { + } + [Test] + public void Test_5062() + { + } + [Test] + public void Test_5063() + { + } + [Test] + public void Test_5064() + { + } + [Test] + public void Test_5065() + { + } + [Test] + public void Test_5066() + { + } + [Test] + public void Test_5067() + { + } + [Test] + public void Test_5068() + { + } + [Test] + public void Test_5069() + { + } + [Test] + public void Test_5070() + { + } + [Test] + public void Test_5071() + { + } + [Test] + public void Test_5072() + { + } + [Test] + public void Test_5073() + { + } + [Test] + public void Test_5074() + { + } + [Test] + public void Test_5075() + { + } + [Test] + public void Test_5076() + { + } + [Test] + public void Test_5077() + { + } + [Test] + public void Test_5078() + { + } + [Test] + public void Test_5079() + { + } + [Test] + public void Test_5080() + { + } + [Test] + public void Test_5081() + { + } + [Test] + public void Test_5082() + { + } + [Test] + public void Test_5083() + { + } + [Test] + public void Test_5084() + { + } + [Test] + public void Test_5085() + { + } + [Test] + public void Test_5086() + { + } + [Test] + public void Test_5087() + { + } + [Test] + public void Test_5088() + { + } + [Test] + public void Test_5089() + { + } + [Test] + public void Test_5090() + { + } + [Test] + public void Test_5091() + { + } + [Test] + public void Test_5092() + { + } + [Test] + public void Test_5093() + { + } + [Test] + public void Test_5094() + { + } + [Test] + public void Test_5095() + { + } + [Test] + public void Test_5096() + { + } + [Test] + public void Test_5097() + { + } + [Test] + public void Test_5098() + { + } + [Test] + public void Test_5099() + { + } + [Test] + public void Test_5100() + { + } + [Test] + public void Test_5101() + { + } + [Test] + public void Test_5102() + { + } + [Test] + public void Test_5103() + { + } + [Test] + public void Test_5104() + { + } + [Test] + public void Test_5105() + { + } + [Test] + public void Test_5106() + { + } + [Test] + public void Test_5107() + { + } + [Test] + public void Test_5108() + { + } + [Test] + public void Test_5109() + { + } + [Test] + public void Test_5110() + { + } + [Test] + public void Test_5111() + { + } + [Test] + public void Test_5112() + { + } + [Test] + public void Test_5113() + { + } + [Test] + public void Test_5114() + { + } + [Test] + public void Test_5115() + { + } + [Test] + public void Test_5116() + { + } + [Test] + public void Test_5117() + { + } + [Test] + public void Test_5118() + { + } + [Test] + public void Test_5119() + { + } + [Test] + public void Test_5120() + { + } + [Test] + public void Test_5121() + { + } + [Test] + public void Test_5122() + { + } + [Test] + public void Test_5123() + { + } + [Test] + public void Test_5124() + { + } + [Test] + public void Test_5125() + { + } + [Test] + public void Test_5126() + { + } + [Test] + public void Test_5127() + { + } + [Test] + public void Test_5128() + { + } + [Test] + public void Test_5129() + { + } + [Test] + public void Test_5130() + { + } + [Test] + public void Test_5131() + { + } + [Test] + public void Test_5132() + { + } + [Test] + public void Test_5133() + { + } + [Test] + public void Test_5134() + { + } + [Test] + public void Test_5135() + { + } + [Test] + public void Test_5136() + { + } + [Test] + public void Test_5137() + { + } + [Test] + public void Test_5138() + { + } + [Test] + public void Test_5139() + { + } + [Test] + public void Test_5140() + { + } + [Test] + public void Test_5141() + { + } + [Test] + public void Test_5142() + { + } + [Test] + public void Test_5143() + { + } + [Test] + public void Test_5144() + { + } + [Test] + public void Test_5145() + { + } + [Test] + public void Test_5146() + { + } + [Test] + public void Test_5147() + { + } + [Test] + public void Test_5148() + { + } + [Test] + public void Test_5149() + { + } + [Test] + public void Test_5150() + { + } + [Test] + public void Test_5151() + { + } + [Test] + public void Test_5152() + { + } + [Test] + public void Test_5153() + { + } + [Test] + public void Test_5154() + { + } + [Test] + public void Test_5155() + { + } + [Test] + public void Test_5156() + { + } + [Test] + public void Test_5157() + { + } + [Test] + public void Test_5158() + { + } + [Test] + public void Test_5159() + { + } + [Test] + public void Test_5160() + { + } + [Test] + public void Test_5161() + { + } + [Test] + public void Test_5162() + { + } + [Test] + public void Test_5163() + { + } + [Test] + public void Test_5164() + { + } + [Test] + public void Test_5165() + { + } + [Test] + public void Test_5166() + { + } + [Test] + public void Test_5167() + { + } + [Test] + public void Test_5168() + { + } + [Test] + public void Test_5169() + { + } + [Test] + public void Test_5170() + { + } + [Test] + public void Test_5171() + { + } + [Test] + public void Test_5172() + { + } + [Test] + public void Test_5173() + { + } + [Test] + public void Test_5174() + { + } + [Test] + public void Test_5175() + { + } + [Test] + public void Test_5176() + { + } + [Test] + public void Test_5177() + { + } + [Test] + public void Test_5178() + { + } + [Test] + public void Test_5179() + { + } + [Test] + public void Test_5180() + { + } + [Test] + public void Test_5181() + { + } + [Test] + public void Test_5182() + { + } + [Test] + public void Test_5183() + { + } + [Test] + public void Test_5184() + { + } + [Test] + public void Test_5185() + { + } + [Test] + public void Test_5186() + { + } + [Test] + public void Test_5187() + { + } + [Test] + public void Test_5188() + { + } + [Test] + public void Test_5189() + { + } + [Test] + public void Test_5190() + { + } + [Test] + public void Test_5191() + { + } + [Test] + public void Test_5192() + { + } + [Test] + public void Test_5193() + { + } + [Test] + public void Test_5194() + { + } + [Test] + public void Test_5195() + { + } + [Test] + public void Test_5196() + { + } + [Test] + public void Test_5197() + { + } + [Test] + public void Test_5198() + { + } + [Test] + public void Test_5199() + { + } + [Test] + public void Test_5200() + { + } + [Test] + public void Test_5201() + { + } + [Test] + public void Test_5202() + { + } + [Test] + public void Test_5203() + { + } + [Test] + public void Test_5204() + { + } + [Test] + public void Test_5205() + { + } + [Test] + public void Test_5206() + { + } + [Test] + public void Test_5207() + { + } + [Test] + public void Test_5208() + { + } + [Test] + public void Test_5209() + { + } + [Test] + public void Test_5210() + { + } + [Test] + public void Test_5211() + { + } + [Test] + public void Test_5212() + { + } + [Test] + public void Test_5213() + { + } + [Test] + public void Test_5214() + { + } + [Test] + public void Test_5215() + { + } + [Test] + public void Test_5216() + { + } + [Test] + public void Test_5217() + { + } + [Test] + public void Test_5218() + { + } + [Test] + public void Test_5219() + { + } + [Test] + public void Test_5220() + { + } + [Test] + public void Test_5221() + { + } + [Test] + public void Test_5222() + { + } + [Test] + public void Test_5223() + { + } + [Test] + public void Test_5224() + { + } + [Test] + public void Test_5225() + { + } + [Test] + public void Test_5226() + { + } + [Test] + public void Test_5227() + { + } + [Test] + public void Test_5228() + { + } + [Test] + public void Test_5229() + { + } + [Test] + public void Test_5230() + { + } + [Test] + public void Test_5231() + { + } + [Test] + public void Test_5232() + { + } + [Test] + public void Test_5233() + { + } + [Test] + public void Test_5234() + { + } + [Test] + public void Test_5235() + { + } + [Test] + public void Test_5236() + { + } + [Test] + public void Test_5237() + { + } + [Test] + public void Test_5238() + { + } + [Test] + public void Test_5239() + { + } + [Test] + public void Test_5240() + { + } + [Test] + public void Test_5241() + { + } + [Test] + public void Test_5242() + { + } + [Test] + public void Test_5243() + { + } + [Test] + public void Test_5244() + { + } + [Test] + public void Test_5245() + { + } + [Test] + public void Test_5246() + { + } + [Test] + public void Test_5247() + { + } + [Test] + public void Test_5248() + { + } + [Test] + public void Test_5249() + { + } + [Test] + public void Test_5250() + { + } + [Test] + public void Test_5251() + { + } + [Test] + public void Test_5252() + { + } + [Test] + public void Test_5253() + { + } + [Test] + public void Test_5254() + { + } + [Test] + public void Test_5255() + { + } + [Test] + public void Test_5256() + { + } + [Test] + public void Test_5257() + { + } + [Test] + public void Test_5258() + { + } + [Test] + public void Test_5259() + { + } + [Test] + public void Test_5260() + { + } + [Test] + public void Test_5261() + { + } + [Test] + public void Test_5262() + { + } + [Test] + public void Test_5263() + { + } + [Test] + public void Test_5264() + { + } + [Test] + public void Test_5265() + { + } + [Test] + public void Test_5266() + { + } + [Test] + public void Test_5267() + { + } + [Test] + public void Test_5268() + { + } + [Test] + public void Test_5269() + { + } + [Test] + public void Test_5270() + { + } + [Test] + public void Test_5271() + { + } + [Test] + public void Test_5272() + { + } + [Test] + public void Test_5273() + { + } + [Test] + public void Test_5274() + { + } + [Test] + public void Test_5275() + { + } + [Test] + public void Test_5276() + { + } + [Test] + public void Test_5277() + { + } + [Test] + public void Test_5278() + { + } + [Test] + public void Test_5279() + { + } + [Test] + public void Test_5280() + { + } + [Test] + public void Test_5281() + { + } + [Test] + public void Test_5282() + { + } + [Test] + public void Test_5283() + { + } + [Test] + public void Test_5284() + { + } + [Test] + public void Test_5285() + { + } + [Test] + public void Test_5286() + { + } + [Test] + public void Test_5287() + { + } + [Test] + public void Test_5288() + { + } + [Test] + public void Test_5289() + { + } + [Test] + public void Test_5290() + { + } + [Test] + public void Test_5291() + { + } + [Test] + public void Test_5292() + { + } + [Test] + public void Test_5293() + { + } + [Test] + public void Test_5294() + { + } + [Test] + public void Test_5295() + { + } + [Test] + public void Test_5296() + { + } + [Test] + public void Test_5297() + { + } + [Test] + public void Test_5298() + { + } + [Test] + public void Test_5299() + { + } + [Test] + public void Test_5300() + { + } + [Test] + public void Test_5301() + { + } + [Test] + public void Test_5302() + { + } + [Test] + public void Test_5303() + { + } + [Test] + public void Test_5304() + { + } + [Test] + public void Test_5305() + { + } + [Test] + public void Test_5306() + { + } + [Test] + public void Test_5307() + { + } + [Test] + public void Test_5308() + { + } + [Test] + public void Test_5309() + { + } + [Test] + public void Test_5310() + { + } + [Test] + public void Test_5311() + { + } + [Test] + public void Test_5312() + { + } + [Test] + public void Test_5313() + { + } + [Test] + public void Test_5314() + { + } + [Test] + public void Test_5315() + { + } + [Test] + public void Test_5316() + { + } + [Test] + public void Test_5317() + { + } + [Test] + public void Test_5318() + { + } + [Test] + public void Test_5319() + { + } + [Test] + public void Test_5320() + { + } + [Test] + public void Test_5321() + { + } + [Test] + public void Test_5322() + { + } + [Test] + public void Test_5323() + { + } + [Test] + public void Test_5324() + { + } + [Test] + public void Test_5325() + { + } + [Test] + public void Test_5326() + { + } + [Test] + public void Test_5327() + { + } + [Test] + public void Test_5328() + { + } + [Test] + public void Test_5329() + { + } + [Test] + public void Test_5330() + { + } + [Test] + public void Test_5331() + { + } + [Test] + public void Test_5332() + { + } + [Test] + public void Test_5333() + { + } + [Test] + public void Test_5334() + { + } + [Test] + public void Test_5335() + { + } + [Test] + public void Test_5336() + { + } + [Test] + public void Test_5337() + { + } + [Test] + public void Test_5338() + { + } + [Test] + public void Test_5339() + { + } + [Test] + public void Test_5340() + { + } + [Test] + public void Test_5341() + { + } + [Test] + public void Test_5342() + { + } + [Test] + public void Test_5343() + { + } + [Test] + public void Test_5344() + { + } + [Test] + public void Test_5345() + { + } + [Test] + public void Test_5346() + { + } + [Test] + public void Test_5347() + { + } + [Test] + public void Test_5348() + { + } + [Test] + public void Test_5349() + { + } + [Test] + public void Test_5350() + { + } + [Test] + public void Test_5351() + { + } + [Test] + public void Test_5352() + { + } + [Test] + public void Test_5353() + { + } + [Test] + public void Test_5354() + { + } + [Test] + public void Test_5355() + { + } + [Test] + public void Test_5356() + { + } + [Test] + public void Test_5357() + { + } + [Test] + public void Test_5358() + { + } + [Test] + public void Test_5359() + { + } + [Test] + public void Test_5360() + { + } + [Test] + public void Test_5361() + { + } + [Test] + public void Test_5362() + { + } + [Test] + public void Test_5363() + { + } + [Test] + public void Test_5364() + { + } + [Test] + public void Test_5365() + { + } + [Test] + public void Test_5366() + { + } + [Test] + public void Test_5367() + { + } + [Test] + public void Test_5368() + { + } + [Test] + public void Test_5369() + { + } + [Test] + public void Test_5370() + { + } + [Test] + public void Test_5371() + { + } + [Test] + public void Test_5372() + { + } + [Test] + public void Test_5373() + { + } + [Test] + public void Test_5374() + { + } + [Test] + public void Test_5375() + { + } + [Test] + public void Test_5376() + { + } + [Test] + public void Test_5377() + { + } + [Test] + public void Test_5378() + { + } + [Test] + public void Test_5379() + { + } + [Test] + public void Test_5380() + { + } + [Test] + public void Test_5381() + { + } + [Test] + public void Test_5382() + { + } + [Test] + public void Test_5383() + { + } + [Test] + public void Test_5384() + { + } + [Test] + public void Test_5385() + { + } + [Test] + public void Test_5386() + { + } + [Test] + public void Test_5387() + { + } + [Test] + public void Test_5388() + { + } + [Test] + public void Test_5389() + { + } + [Test] + public void Test_5390() + { + } + [Test] + public void Test_5391() + { + } + [Test] + public void Test_5392() + { + } + [Test] + public void Test_5393() + { + } + [Test] + public void Test_5394() + { + } + [Test] + public void Test_5395() + { + } + [Test] + public void Test_5396() + { + } + [Test] + public void Test_5397() + { + } + [Test] + public void Test_5398() + { + } + [Test] + public void Test_5399() + { + } + [Test] + public void Test_5400() + { + } + [Test] + public void Test_5401() + { + } + [Test] + public void Test_5402() + { + } + [Test] + public void Test_5403() + { + } + [Test] + public void Test_5404() + { + } + [Test] + public void Test_5405() + { + } + [Test] + public void Test_5406() + { + } + [Test] + public void Test_5407() + { + } + [Test] + public void Test_5408() + { + } + [Test] + public void Test_5409() + { + } + [Test] + public void Test_5410() + { + } + [Test] + public void Test_5411() + { + } + [Test] + public void Test_5412() + { + } + [Test] + public void Test_5413() + { + } + [Test] + public void Test_5414() + { + } + [Test] + public void Test_5415() + { + } + [Test] + public void Test_5416() + { + } + [Test] + public void Test_5417() + { + } + [Test] + public void Test_5418() + { + } + [Test] + public void Test_5419() + { + } + [Test] + public void Test_5420() + { + } + [Test] + public void Test_5421() + { + } + [Test] + public void Test_5422() + { + } + [Test] + public void Test_5423() + { + } + [Test] + public void Test_5424() + { + } + [Test] + public void Test_5425() + { + } + [Test] + public void Test_5426() + { + } + [Test] + public void Test_5427() + { + } + [Test] + public void Test_5428() + { + } + [Test] + public void Test_5429() + { + } + [Test] + public void Test_5430() + { + } + [Test] + public void Test_5431() + { + } + [Test] + public void Test_5432() + { + } + [Test] + public void Test_5433() + { + } + [Test] + public void Test_5434() + { + } + [Test] + public void Test_5435() + { + } + [Test] + public void Test_5436() + { + } + [Test] + public void Test_5437() + { + } + [Test] + public void Test_5438() + { + } + [Test] + public void Test_5439() + { + } + [Test] + public void Test_5440() + { + } + [Test] + public void Test_5441() + { + } + [Test] + public void Test_5442() + { + } + [Test] + public void Test_5443() + { + } + [Test] + public void Test_5444() + { + } + [Test] + public void Test_5445() + { + } + [Test] + public void Test_5446() + { + } + [Test] + public void Test_5447() + { + } + [Test] + public void Test_5448() + { + } + [Test] + public void Test_5449() + { + } + [Test] + public void Test_5450() + { + } + [Test] + public void Test_5451() + { + } + [Test] + public void Test_5452() + { + } + [Test] + public void Test_5453() + { + } + [Test] + public void Test_5454() + { + } + [Test] + public void Test_5455() + { + } + [Test] + public void Test_5456() + { + } + [Test] + public void Test_5457() + { + } + [Test] + public void Test_5458() + { + } + [Test] + public void Test_5459() + { + } + [Test] + public void Test_5460() + { + } + [Test] + public void Test_5461() + { + } + [Test] + public void Test_5462() + { + } + [Test] + public void Test_5463() + { + } + [Test] + public void Test_5464() + { + } + [Test] + public void Test_5465() + { + } + [Test] + public void Test_5466() + { + } + [Test] + public void Test_5467() + { + } + [Test] + public void Test_5468() + { + } + [Test] + public void Test_5469() + { + } + [Test] + public void Test_5470() + { + } + [Test] + public void Test_5471() + { + } + [Test] + public void Test_5472() + { + } + [Test] + public void Test_5473() + { + } + [Test] + public void Test_5474() + { + } + [Test] + public void Test_5475() + { + } + [Test] + public void Test_5476() + { + } + [Test] + public void Test_5477() + { + } + [Test] + public void Test_5478() + { + } + [Test] + public void Test_5479() + { + } + [Test] + public void Test_5480() + { + } + [Test] + public void Test_5481() + { + } + [Test] + public void Test_5482() + { + } + [Test] + public void Test_5483() + { + } + [Test] + public void Test_5484() + { + } + [Test] + public void Test_5485() + { + } + [Test] + public void Test_5486() + { + } + [Test] + public void Test_5487() + { + } + [Test] + public void Test_5488() + { + } + [Test] + public void Test_5489() + { + } + [Test] + public void Test_5490() + { + } + [Test] + public void Test_5491() + { + } + [Test] + public void Test_5492() + { + } + [Test] + public void Test_5493() + { + } + [Test] + public void Test_5494() + { + } + [Test] + public void Test_5495() + { + } + [Test] + public void Test_5496() + { + } + [Test] + public void Test_5497() + { + } + [Test] + public void Test_5498() + { + } + [Test] + public void Test_5499() + { + } + [Test] + public void Test_5500() + { + } + [Test] + public void Test_5501() + { + } + [Test] + public void Test_5502() + { + } + [Test] + public void Test_5503() + { + } + [Test] + public void Test_5504() + { + } + [Test] + public void Test_5505() + { + } + [Test] + public void Test_5506() + { + } + [Test] + public void Test_5507() + { + } + [Test] + public void Test_5508() + { + } + [Test] + public void Test_5509() + { + } + [Test] + public void Test_5510() + { + } + [Test] + public void Test_5511() + { + } + [Test] + public void Test_5512() + { + } + [Test] + public void Test_5513() + { + } + [Test] + public void Test_5514() + { + } + [Test] + public void Test_5515() + { + } + [Test] + public void Test_5516() + { + } + [Test] + public void Test_5517() + { + } + [Test] + public void Test_5518() + { + } + [Test] + public void Test_5519() + { + } + [Test] + public void Test_5520() + { + } + [Test] + public void Test_5521() + { + } + [Test] + public void Test_5522() + { + } + [Test] + public void Test_5523() + { + } + [Test] + public void Test_5524() + { + } + [Test] + public void Test_5525() + { + } + [Test] + public void Test_5526() + { + } + [Test] + public void Test_5527() + { + } + [Test] + public void Test_5528() + { + } + [Test] + public void Test_5529() + { + } + [Test] + public void Test_5530() + { + } + [Test] + public void Test_5531() + { + } + [Test] + public void Test_5532() + { + } + [Test] + public void Test_5533() + { + } + [Test] + public void Test_5534() + { + } + [Test] + public void Test_5535() + { + } + [Test] + public void Test_5536() + { + } + [Test] + public void Test_5537() + { + } + [Test] + public void Test_5538() + { + } + [Test] + public void Test_5539() + { + } + [Test] + public void Test_5540() + { + } + [Test] + public void Test_5541() + { + } + [Test] + public void Test_5542() + { + } + [Test] + public void Test_5543() + { + } + [Test] + public void Test_5544() + { + } + [Test] + public void Test_5545() + { + } + [Test] + public void Test_5546() + { + } + [Test] + public void Test_5547() + { + } + [Test] + public void Test_5548() + { + } + [Test] + public void Test_5549() + { + } + [Test] + public void Test_5550() + { + } + [Test] + public void Test_5551() + { + } + [Test] + public void Test_5552() + { + } + [Test] + public void Test_5553() + { + } + [Test] + public void Test_5554() + { + } + [Test] + public void Test_5555() + { + } + [Test] + public void Test_5556() + { + } + [Test] + public void Test_5557() + { + } + [Test] + public void Test_5558() + { + } + [Test] + public void Test_5559() + { + } + [Test] + public void Test_5560() + { + } + [Test] + public void Test_5561() + { + } + [Test] + public void Test_5562() + { + } + [Test] + public void Test_5563() + { + } + [Test] + public void Test_5564() + { + } + [Test] + public void Test_5565() + { + } + [Test] + public void Test_5566() + { + } + [Test] + public void Test_5567() + { + } + [Test] + public void Test_5568() + { + } + [Test] + public void Test_5569() + { + } + [Test] + public void Test_5570() + { + } + [Test] + public void Test_5571() + { + } + [Test] + public void Test_5572() + { + } + [Test] + public void Test_5573() + { + } + [Test] + public void Test_5574() + { + } + [Test] + public void Test_5575() + { + } + [Test] + public void Test_5576() + { + } + [Test] + public void Test_5577() + { + } + [Test] + public void Test_5578() + { + } + [Test] + public void Test_5579() + { + } + [Test] + public void Test_5580() + { + } + [Test] + public void Test_5581() + { + } + [Test] + public void Test_5582() + { + } + [Test] + public void Test_5583() + { + } + [Test] + public void Test_5584() + { + } + [Test] + public void Test_5585() + { + } + [Test] + public void Test_5586() + { + } + [Test] + public void Test_5587() + { + } + [Test] + public void Test_5588() + { + } + [Test] + public void Test_5589() + { + } + [Test] + public void Test_5590() + { + } + [Test] + public void Test_5591() + { + } + [Test] + public void Test_5592() + { + } + [Test] + public void Test_5593() + { + } + [Test] + public void Test_5594() + { + } + [Test] + public void Test_5595() + { + } + [Test] + public void Test_5596() + { + } + [Test] + public void Test_5597() + { + } + [Test] + public void Test_5598() + { + } + [Test] + public void Test_5599() + { + } + [Test] + public void Test_5600() + { + } + [Test] + public void Test_5601() + { + } + [Test] + public void Test_5602() + { + } + [Test] + public void Test_5603() + { + } + [Test] + public void Test_5604() + { + } + [Test] + public void Test_5605() + { + } + [Test] + public void Test_5606() + { + } + [Test] + public void Test_5607() + { + } + [Test] + public void Test_5608() + { + } + [Test] + public void Test_5609() + { + } + [Test] + public void Test_5610() + { + } + [Test] + public void Test_5611() + { + } + [Test] + public void Test_5612() + { + } + [Test] + public void Test_5613() + { + } + [Test] + public void Test_5614() + { + } + [Test] + public void Test_5615() + { + } + [Test] + public void Test_5616() + { + } + [Test] + public void Test_5617() + { + } + [Test] + public void Test_5618() + { + } + [Test] + public void Test_5619() + { + } + [Test] + public void Test_5620() + { + } + [Test] + public void Test_5621() + { + } + [Test] + public void Test_5622() + { + } + [Test] + public void Test_5623() + { + } + [Test] + public void Test_5624() + { + } + [Test] + public void Test_5625() + { + } + [Test] + public void Test_5626() + { + } + [Test] + public void Test_5627() + { + } + [Test] + public void Test_5628() + { + } + [Test] + public void Test_5629() + { + } + [Test] + public void Test_5630() + { + } + [Test] + public void Test_5631() + { + } + [Test] + public void Test_5632() + { + } + [Test] + public void Test_5633() + { + } + [Test] + public void Test_5634() + { + } + [Test] + public void Test_5635() + { + } + [Test] + public void Test_5636() + { + } + [Test] + public void Test_5637() + { + } + [Test] + public void Test_5638() + { + } + [Test] + public void Test_5639() + { + } + [Test] + public void Test_5640() + { + } + [Test] + public void Test_5641() + { + } + [Test] + public void Test_5642() + { + } + [Test] + public void Test_5643() + { + } + [Test] + public void Test_5644() + { + } + [Test] + public void Test_5645() + { + } + [Test] + public void Test_5646() + { + } + [Test] + public void Test_5647() + { + } + [Test] + public void Test_5648() + { + } + [Test] + public void Test_5649() + { + } + [Test] + public void Test_5650() + { + } + [Test] + public void Test_5651() + { + } + [Test] + public void Test_5652() + { + } + [Test] + public void Test_5653() + { + } + [Test] + public void Test_5654() + { + } + [Test] + public void Test_5655() + { + } + [Test] + public void Test_5656() + { + } + [Test] + public void Test_5657() + { + } + [Test] + public void Test_5658() + { + } + [Test] + public void Test_5659() + { + } + [Test] + public void Test_5660() + { + } + [Test] + public void Test_5661() + { + } + [Test] + public void Test_5662() + { + } + [Test] + public void Test_5663() + { + } + [Test] + public void Test_5664() + { + } + [Test] + public void Test_5665() + { + } + [Test] + public void Test_5666() + { + } + [Test] + public void Test_5667() + { + } + [Test] + public void Test_5668() + { + } + [Test] + public void Test_5669() + { + } + [Test] + public void Test_5670() + { + } + [Test] + public void Test_5671() + { + } + [Test] + public void Test_5672() + { + } + [Test] + public void Test_5673() + { + } + [Test] + public void Test_5674() + { + } + [Test] + public void Test_5675() + { + } + [Test] + public void Test_5676() + { + } + [Test] + public void Test_5677() + { + } + [Test] + public void Test_5678() + { + } + [Test] + public void Test_5679() + { + } + [Test] + public void Test_5680() + { + } + [Test] + public void Test_5681() + { + } + [Test] + public void Test_5682() + { + } + [Test] + public void Test_5683() + { + } + [Test] + public void Test_5684() + { + } + [Test] + public void Test_5685() + { + } + [Test] + public void Test_5686() + { + } + [Test] + public void Test_5687() + { + } + [Test] + public void Test_5688() + { + } + [Test] + public void Test_5689() + { + } + [Test] + public void Test_5690() + { + } + [Test] + public void Test_5691() + { + } + [Test] + public void Test_5692() + { + } + [Test] + public void Test_5693() + { + } + [Test] + public void Test_5694() + { + } + [Test] + public void Test_5695() + { + } + [Test] + public void Test_5696() + { + } + [Test] + public void Test_5697() + { + } + [Test] + public void Test_5698() + { + } + [Test] + public void Test_5699() + { + } + [Test] + public void Test_5700() + { + } + [Test] + public void Test_5701() + { + } + [Test] + public void Test_5702() + { + } + [Test] + public void Test_5703() + { + } + [Test] + public void Test_5704() + { + } + [Test] + public void Test_5705() + { + } + [Test] + public void Test_5706() + { + } + [Test] + public void Test_5707() + { + } + [Test] + public void Test_5708() + { + } + [Test] + public void Test_5709() + { + } + [Test] + public void Test_5710() + { + } + [Test] + public void Test_5711() + { + } + [Test] + public void Test_5712() + { + } + [Test] + public void Test_5713() + { + } + [Test] + public void Test_5714() + { + } + [Test] + public void Test_5715() + { + } + [Test] + public void Test_5716() + { + } + [Test] + public void Test_5717() + { + } + [Test] + public void Test_5718() + { + } + [Test] + public void Test_5719() + { + } + [Test] + public void Test_5720() + { + } + [Test] + public void Test_5721() + { + } + [Test] + public void Test_5722() + { + } + [Test] + public void Test_5723() + { + } + [Test] + public void Test_5724() + { + } + [Test] + public void Test_5725() + { + } + [Test] + public void Test_5726() + { + } + [Test] + public void Test_5727() + { + } + [Test] + public void Test_5728() + { + } + [Test] + public void Test_5729() + { + } + [Test] + public void Test_5730() + { + } + [Test] + public void Test_5731() + { + } + [Test] + public void Test_5732() + { + } + [Test] + public void Test_5733() + { + } + [Test] + public void Test_5734() + { + } + [Test] + public void Test_5735() + { + } + [Test] + public void Test_5736() + { + } + [Test] + public void Test_5737() + { + } + [Test] + public void Test_5738() + { + } + [Test] + public void Test_5739() + { + } + [Test] + public void Test_5740() + { + } + [Test] + public void Test_5741() + { + } + [Test] + public void Test_5742() + { + } + [Test] + public void Test_5743() + { + } + [Test] + public void Test_5744() + { + } + [Test] + public void Test_5745() + { + } + [Test] + public void Test_5746() + { + } + [Test] + public void Test_5747() + { + } + [Test] + public void Test_5748() + { + } + [Test] + public void Test_5749() + { + } + [Test] + public void Test_5750() + { + } + [Test] + public void Test_5751() + { + } + [Test] + public void Test_5752() + { + } + [Test] + public void Test_5753() + { + } + [Test] + public void Test_5754() + { + } + [Test] + public void Test_5755() + { + } + [Test] + public void Test_5756() + { + } + [Test] + public void Test_5757() + { + } + [Test] + public void Test_5758() + { + } + [Test] + public void Test_5759() + { + } + [Test] + public void Test_5760() + { + } + [Test] + public void Test_5761() + { + } + [Test] + public void Test_5762() + { + } + [Test] + public void Test_5763() + { + } + [Test] + public void Test_5764() + { + } + [Test] + public void Test_5765() + { + } + [Test] + public void Test_5766() + { + } + [Test] + public void Test_5767() + { + } + [Test] + public void Test_5768() + { + } + [Test] + public void Test_5769() + { + } + [Test] + public void Test_5770() + { + } + [Test] + public void Test_5771() + { + } + [Test] + public void Test_5772() + { + } + [Test] + public void Test_5773() + { + } + [Test] + public void Test_5774() + { + } + [Test] + public void Test_5775() + { + } + [Test] + public void Test_5776() + { + } + [Test] + public void Test_5777() + { + } + [Test] + public void Test_5778() + { + } + [Test] + public void Test_5779() + { + } + [Test] + public void Test_5780() + { + } + [Test] + public void Test_5781() + { + } + [Test] + public void Test_5782() + { + } + [Test] + public void Test_5783() + { + } + [Test] + public void Test_5784() + { + } + [Test] + public void Test_5785() + { + } + [Test] + public void Test_5786() + { + } + [Test] + public void Test_5787() + { + } + [Test] + public void Test_5788() + { + } + [Test] + public void Test_5789() + { + } + [Test] + public void Test_5790() + { + } + [Test] + public void Test_5791() + { + } + [Test] + public void Test_5792() + { + } + [Test] + public void Test_5793() + { + } + [Test] + public void Test_5794() + { + } + [Test] + public void Test_5795() + { + } + [Test] + public void Test_5796() + { + } + [Test] + public void Test_5797() + { + } + [Test] + public void Test_5798() + { + } + [Test] + public void Test_5799() + { + } + [Test] + public void Test_5800() + { + } + [Test] + public void Test_5801() + { + } + [Test] + public void Test_5802() + { + } + [Test] + public void Test_5803() + { + } + [Test] + public void Test_5804() + { + } + [Test] + public void Test_5805() + { + } + [Test] + public void Test_5806() + { + } + [Test] + public void Test_5807() + { + } + [Test] + public void Test_5808() + { + } + [Test] + public void Test_5809() + { + } + [Test] + public void Test_5810() + { + } + [Test] + public void Test_5811() + { + } + [Test] + public void Test_5812() + { + } + [Test] + public void Test_5813() + { + } + [Test] + public void Test_5814() + { + } + [Test] + public void Test_5815() + { + } + [Test] + public void Test_5816() + { + } + [Test] + public void Test_5817() + { + } + [Test] + public void Test_5818() + { + } + [Test] + public void Test_5819() + { + } + [Test] + public void Test_5820() + { + } + [Test] + public void Test_5821() + { + } + [Test] + public void Test_5822() + { + } + [Test] + public void Test_5823() + { + } + [Test] + public void Test_5824() + { + } + [Test] + public void Test_5825() + { + } + [Test] + public void Test_5826() + { + } + [Test] + public void Test_5827() + { + } + [Test] + public void Test_5828() + { + } + [Test] + public void Test_5829() + { + } + [Test] + public void Test_5830() + { + } + [Test] + public void Test_5831() + { + } + [Test] + public void Test_5832() + { + } + [Test] + public void Test_5833() + { + } + [Test] + public void Test_5834() + { + } + [Test] + public void Test_5835() + { + } + [Test] + public void Test_5836() + { + } + [Test] + public void Test_5837() + { + } + [Test] + public void Test_5838() + { + } + [Test] + public void Test_5839() + { + } + [Test] + public void Test_5840() + { + } + [Test] + public void Test_5841() + { + } + [Test] + public void Test_5842() + { + } + [Test] + public void Test_5843() + { + } + [Test] + public void Test_5844() + { + } + [Test] + public void Test_5845() + { + } + [Test] + public void Test_5846() + { + } + [Test] + public void Test_5847() + { + } + [Test] + public void Test_5848() + { + } + [Test] + public void Test_5849() + { + } + [Test] + public void Test_5850() + { + } + [Test] + public void Test_5851() + { + } + [Test] + public void Test_5852() + { + } + [Test] + public void Test_5853() + { + } + [Test] + public void Test_5854() + { + } + [Test] + public void Test_5855() + { + } + [Test] + public void Test_5856() + { + } + [Test] + public void Test_5857() + { + } + [Test] + public void Test_5858() + { + } + [Test] + public void Test_5859() + { + } + [Test] + public void Test_5860() + { + } + [Test] + public void Test_5861() + { + } + [Test] + public void Test_5862() + { + } + [Test] + public void Test_5863() + { + } + [Test] + public void Test_5864() + { + } + [Test] + public void Test_5865() + { + } + [Test] + public void Test_5866() + { + } + [Test] + public void Test_5867() + { + } + [Test] + public void Test_5868() + { + } + [Test] + public void Test_5869() + { + } + [Test] + public void Test_5870() + { + } + [Test] + public void Test_5871() + { + } + [Test] + public void Test_5872() + { + } + [Test] + public void Test_5873() + { + } + [Test] + public void Test_5874() + { + } + [Test] + public void Test_5875() + { + } + [Test] + public void Test_5876() + { + } + [Test] + public void Test_5877() + { + } + [Test] + public void Test_5878() + { + } + [Test] + public void Test_5879() + { + } + [Test] + public void Test_5880() + { + } + [Test] + public void Test_5881() + { + } + [Test] + public void Test_5882() + { + } + [Test] + public void Test_5883() + { + } + [Test] + public void Test_5884() + { + } + [Test] + public void Test_5885() + { + } + [Test] + public void Test_5886() + { + } + [Test] + public void Test_5887() + { + } + [Test] + public void Test_5888() + { + } + [Test] + public void Test_5889() + { + } + [Test] + public void Test_5890() + { + } + [Test] + public void Test_5891() + { + } + [Test] + public void Test_5892() + { + } + [Test] + public void Test_5893() + { + } + [Test] + public void Test_5894() + { + } + [Test] + public void Test_5895() + { + } + [Test] + public void Test_5896() + { + } + [Test] + public void Test_5897() + { + } + [Test] + public void Test_5898() + { + } + [Test] + public void Test_5899() + { + } + [Test] + public void Test_5900() + { + } + [Test] + public void Test_5901() + { + } + [Test] + public void Test_5902() + { + } + [Test] + public void Test_5903() + { + } + [Test] + public void Test_5904() + { + } + [Test] + public void Test_5905() + { + } + [Test] + public void Test_5906() + { + } + [Test] + public void Test_5907() + { + } + [Test] + public void Test_5908() + { + } + [Test] + public void Test_5909() + { + } + [Test] + public void Test_5910() + { + } + [Test] + public void Test_5911() + { + } + [Test] + public void Test_5912() + { + } + [Test] + public void Test_5913() + { + } + [Test] + public void Test_5914() + { + } + [Test] + public void Test_5915() + { + } + [Test] + public void Test_5916() + { + } + [Test] + public void Test_5917() + { + } + [Test] + public void Test_5918() + { + } + [Test] + public void Test_5919() + { + } + [Test] + public void Test_5920() + { + } + [Test] + public void Test_5921() + { + } + [Test] + public void Test_5922() + { + } + [Test] + public void Test_5923() + { + } + [Test] + public void Test_5924() + { + } + [Test] + public void Test_5925() + { + } + [Test] + public void Test_5926() + { + } + [Test] + public void Test_5927() + { + } + [Test] + public void Test_5928() + { + } + [Test] + public void Test_5929() + { + } + [Test] + public void Test_5930() + { + } + [Test] + public void Test_5931() + { + } + [Test] + public void Test_5932() + { + } + [Test] + public void Test_5933() + { + } + [Test] + public void Test_5934() + { + } + [Test] + public void Test_5935() + { + } + [Test] + public void Test_5936() + { + } + [Test] + public void Test_5937() + { + } + [Test] + public void Test_5938() + { + } + [Test] + public void Test_5939() + { + } + [Test] + public void Test_5940() + { + } + [Test] + public void Test_5941() + { + } + [Test] + public void Test_5942() + { + } + [Test] + public void Test_5943() + { + } + [Test] + public void Test_5944() + { + } + [Test] + public void Test_5945() + { + } + [Test] + public void Test_5946() + { + } + [Test] + public void Test_5947() + { + } + [Test] + public void Test_5948() + { + } + [Test] + public void Test_5949() + { + } + [Test] + public void Test_5950() + { + } + [Test] + public void Test_5951() + { + } + [Test] + public void Test_5952() + { + } + [Test] + public void Test_5953() + { + } + [Test] + public void Test_5954() + { + } + [Test] + public void Test_5955() + { + } + [Test] + public void Test_5956() + { + } + [Test] + public void Test_5957() + { + } + [Test] + public void Test_5958() + { + } + [Test] + public void Test_5959() + { + } + [Test] + public void Test_5960() + { + } + [Test] + public void Test_5961() + { + } + [Test] + public void Test_5962() + { + } + [Test] + public void Test_5963() + { + } + [Test] + public void Test_5964() + { + } + [Test] + public void Test_5965() + { + } + [Test] + public void Test_5966() + { + } + [Test] + public void Test_5967() + { + } + [Test] + public void Test_5968() + { + } + [Test] + public void Test_5969() + { + } + [Test] + public void Test_5970() + { + } + [Test] + public void Test_5971() + { + } + [Test] + public void Test_5972() + { + } + [Test] + public void Test_5973() + { + } + [Test] + public void Test_5974() + { + } + [Test] + public void Test_5975() + { + } + [Test] + public void Test_5976() + { + } + [Test] + public void Test_5977() + { + } + [Test] + public void Test_5978() + { + } + [Test] + public void Test_5979() + { + } + [Test] + public void Test_5980() + { + } + [Test] + public void Test_5981() + { + } + [Test] + public void Test_5982() + { + } + [Test] + public void Test_5983() + { + } + [Test] + public void Test_5984() + { + } + [Test] + public void Test_5985() + { + } + [Test] + public void Test_5986() + { + } + [Test] + public void Test_5987() + { + } + [Test] + public void Test_5988() + { + } + [Test] + public void Test_5989() + { + } + [Test] + public void Test_5990() + { + } + [Test] + public void Test_5991() + { + } + [Test] + public void Test_5992() + { + } + [Test] + public void Test_5993() + { + } + [Test] + public void Test_5994() + { + } + [Test] + public void Test_5995() + { + } + [Test] + public void Test_5996() + { + } + [Test] + public void Test_5997() + { + } + [Test] + public void Test_5998() + { + } + [Test] + public void Test_5999() + { + } + [Test] + public void Test_6000() + { + } + [Test] + public void Test_6001() + { + } + [Test] + public void Test_6002() + { + } + [Test] + public void Test_6003() + { + } + [Test] + public void Test_6004() + { + } + [Test] + public void Test_6005() + { + } + [Test] + public void Test_6006() + { + } + [Test] + public void Test_6007() + { + } + [Test] + public void Test_6008() + { + } + [Test] + public void Test_6009() + { + } + [Test] + public void Test_6010() + { + } + [Test] + public void Test_6011() + { + } + [Test] + public void Test_6012() + { + } + [Test] + public void Test_6013() + { + } + [Test] + public void Test_6014() + { + } + [Test] + public void Test_6015() + { + } + [Test] + public void Test_6016() + { + } + [Test] + public void Test_6017() + { + } + [Test] + public void Test_6018() + { + } + [Test] + public void Test_6019() + { + } + [Test] + public void Test_6020() + { + } + [Test] + public void Test_6021() + { + } + [Test] + public void Test_6022() + { + } + [Test] + public void Test_6023() + { + } + [Test] + public void Test_6024() + { + } + [Test] + public void Test_6025() + { + } + [Test] + public void Test_6026() + { + } + [Test] + public void Test_6027() + { + } + [Test] + public void Test_6028() + { + } + [Test] + public void Test_6029() + { + } + [Test] + public void Test_6030() + { + } + [Test] + public void Test_6031() + { + } + [Test] + public void Test_6032() + { + } + [Test] + public void Test_6033() + { + } + [Test] + public void Test_6034() + { + } + [Test] + public void Test_6035() + { + } + [Test] + public void Test_6036() + { + } + [Test] + public void Test_6037() + { + } + [Test] + public void Test_6038() + { + } + [Test] + public void Test_6039() + { + } + [Test] + public void Test_6040() + { + } + [Test] + public void Test_6041() + { + } + [Test] + public void Test_6042() + { + } + [Test] + public void Test_6043() + { + } + [Test] + public void Test_6044() + { + } + [Test] + public void Test_6045() + { + } + [Test] + public void Test_6046() + { + } + [Test] + public void Test_6047() + { + } + [Test] + public void Test_6048() + { + } + [Test] + public void Test_6049() + { + } + [Test] + public void Test_6050() + { + } + [Test] + public void Test_6051() + { + } + [Test] + public void Test_6052() + { + } + [Test] + public void Test_6053() + { + } + [Test] + public void Test_6054() + { + } + [Test] + public void Test_6055() + { + } + [Test] + public void Test_6056() + { + } + [Test] + public void Test_6057() + { + } + [Test] + public void Test_6058() + { + } + [Test] + public void Test_6059() + { + } + [Test] + public void Test_6060() + { + } + [Test] + public void Test_6061() + { + } + [Test] + public void Test_6062() + { + } + [Test] + public void Test_6063() + { + } + [Test] + public void Test_6064() + { + } + [Test] + public void Test_6065() + { + } + [Test] + public void Test_6066() + { + } + [Test] + public void Test_6067() + { + } + [Test] + public void Test_6068() + { + } + [Test] + public void Test_6069() + { + } + [Test] + public void Test_6070() + { + } + [Test] + public void Test_6071() + { + } + [Test] + public void Test_6072() + { + } + [Test] + public void Test_6073() + { + } + [Test] + public void Test_6074() + { + } + [Test] + public void Test_6075() + { + } + [Test] + public void Test_6076() + { + } + [Test] + public void Test_6077() + { + } + [Test] + public void Test_6078() + { + } + [Test] + public void Test_6079() + { + } + [Test] + public void Test_6080() + { + } + [Test] + public void Test_6081() + { + } + [Test] + public void Test_6082() + { + } + [Test] + public void Test_6083() + { + } + [Test] + public void Test_6084() + { + } + [Test] + public void Test_6085() + { + } + [Test] + public void Test_6086() + { + } + [Test] + public void Test_6087() + { + } + [Test] + public void Test_6088() + { + } + [Test] + public void Test_6089() + { + } + [Test] + public void Test_6090() + { + } + [Test] + public void Test_6091() + { + } + [Test] + public void Test_6092() + { + } + [Test] + public void Test_6093() + { + } + [Test] + public void Test_6094() + { + } + [Test] + public void Test_6095() + { + } + [Test] + public void Test_6096() + { + } + [Test] + public void Test_6097() + { + } + [Test] + public void Test_6098() + { + } + [Test] + public void Test_6099() + { + } + [Test] + public void Test_6100() + { + } + [Test] + public void Test_6101() + { + } + [Test] + public void Test_6102() + { + } + [Test] + public void Test_6103() + { + } + [Test] + public void Test_6104() + { + } + [Test] + public void Test_6105() + { + } + [Test] + public void Test_6106() + { + } + [Test] + public void Test_6107() + { + } + [Test] + public void Test_6108() + { + } + [Test] + public void Test_6109() + { + } + [Test] + public void Test_6110() + { + } + [Test] + public void Test_6111() + { + } + [Test] + public void Test_6112() + { + } + [Test] + public void Test_6113() + { + } + [Test] + public void Test_6114() + { + } + [Test] + public void Test_6115() + { + } + [Test] + public void Test_6116() + { + } + [Test] + public void Test_6117() + { + } + [Test] + public void Test_6118() + { + } + [Test] + public void Test_6119() + { + } + [Test] + public void Test_6120() + { + } + [Test] + public void Test_6121() + { + } + [Test] + public void Test_6122() + { + } + [Test] + public void Test_6123() + { + } + [Test] + public void Test_6124() + { + } + [Test] + public void Test_6125() + { + } + [Test] + public void Test_6126() + { + } + [Test] + public void Test_6127() + { + } + [Test] + public void Test_6128() + { + } + [Test] + public void Test_6129() + { + } + [Test] + public void Test_6130() + { + } + [Test] + public void Test_6131() + { + } + [Test] + public void Test_6132() + { + } + [Test] + public void Test_6133() + { + } + [Test] + public void Test_6134() + { + } + [Test] + public void Test_6135() + { + } + [Test] + public void Test_6136() + { + } + [Test] + public void Test_6137() + { + } + [Test] + public void Test_6138() + { + } + [Test] + public void Test_6139() + { + } + [Test] + public void Test_6140() + { + } + [Test] + public void Test_6141() + { + } + [Test] + public void Test_6142() + { + } + [Test] + public void Test_6143() + { + } + [Test] + public void Test_6144() + { + } + [Test] + public void Test_6145() + { + } + [Test] + public void Test_6146() + { + } + [Test] + public void Test_6147() + { + } + [Test] + public void Test_6148() + { + } + [Test] + public void Test_6149() + { + } + [Test] + public void Test_6150() + { + } + [Test] + public void Test_6151() + { + } + [Test] + public void Test_6152() + { + } + [Test] + public void Test_6153() + { + } + [Test] + public void Test_6154() + { + } + [Test] + public void Test_6155() + { + } + [Test] + public void Test_6156() + { + } + [Test] + public void Test_6157() + { + } + [Test] + public void Test_6158() + { + } + [Test] + public void Test_6159() + { + } + [Test] + public void Test_6160() + { + } + [Test] + public void Test_6161() + { + } + [Test] + public void Test_6162() + { + } + [Test] + public void Test_6163() + { + } + [Test] + public void Test_6164() + { + } + [Test] + public void Test_6165() + { + } + [Test] + public void Test_6166() + { + } + [Test] + public void Test_6167() + { + } + [Test] + public void Test_6168() + { + } + [Test] + public void Test_6169() + { + } + [Test] + public void Test_6170() + { + } + [Test] + public void Test_6171() + { + } + [Test] + public void Test_6172() + { + } + [Test] + public void Test_6173() + { + } + [Test] + public void Test_6174() + { + } + [Test] + public void Test_6175() + { + } + [Test] + public void Test_6176() + { + } + [Test] + public void Test_6177() + { + } + [Test] + public void Test_6178() + { + } + [Test] + public void Test_6179() + { + } + [Test] + public void Test_6180() + { + } + [Test] + public void Test_6181() + { + } + [Test] + public void Test_6182() + { + } + [Test] + public void Test_6183() + { + } + [Test] + public void Test_6184() + { + } + [Test] + public void Test_6185() + { + } + [Test] + public void Test_6186() + { + } + [Test] + public void Test_6187() + { + } + [Test] + public void Test_6188() + { + } + [Test] + public void Test_6189() + { + } + [Test] + public void Test_6190() + { + } + [Test] + public void Test_6191() + { + } + [Test] + public void Test_6192() + { + } + [Test] + public void Test_6193() + { + } + [Test] + public void Test_6194() + { + } + [Test] + public void Test_6195() + { + } + [Test] + public void Test_6196() + { + } + [Test] + public void Test_6197() + { + } + [Test] + public void Test_6198() + { + } + [Test] + public void Test_6199() + { + } + [Test] + public void Test_6200() + { + } + [Test] + public void Test_6201() + { + } + [Test] + public void Test_6202() + { + } + [Test] + public void Test_6203() + { + } + [Test] + public void Test_6204() + { + } + [Test] + public void Test_6205() + { + } + [Test] + public void Test_6206() + { + } + [Test] + public void Test_6207() + { + } + [Test] + public void Test_6208() + { + } + [Test] + public void Test_6209() + { + } + [Test] + public void Test_6210() + { + } + [Test] + public void Test_6211() + { + } + [Test] + public void Test_6212() + { + } + [Test] + public void Test_6213() + { + } + [Test] + public void Test_6214() + { + } + [Test] + public void Test_6215() + { + } + [Test] + public void Test_6216() + { + } + [Test] + public void Test_6217() + { + } + [Test] + public void Test_6218() + { + } + [Test] + public void Test_6219() + { + } + [Test] + public void Test_6220() + { + } + [Test] + public void Test_6221() + { + } + [Test] + public void Test_6222() + { + } + [Test] + public void Test_6223() + { + } + [Test] + public void Test_6224() + { + } + [Test] + public void Test_6225() + { + } + [Test] + public void Test_6226() + { + } + [Test] + public void Test_6227() + { + } + [Test] + public void Test_6228() + { + } + [Test] + public void Test_6229() + { + } + [Test] + public void Test_6230() + { + } + [Test] + public void Test_6231() + { + } + [Test] + public void Test_6232() + { + } + [Test] + public void Test_6233() + { + } + [Test] + public void Test_6234() + { + } + [Test] + public void Test_6235() + { + } + [Test] + public void Test_6236() + { + } + [Test] + public void Test_6237() + { + } + [Test] + public void Test_6238() + { + } + [Test] + public void Test_6239() + { + } + [Test] + public void Test_6240() + { + } + [Test] + public void Test_6241() + { + } + [Test] + public void Test_6242() + { + } + [Test] + public void Test_6243() + { + } + [Test] + public void Test_6244() + { + } + [Test] + public void Test_6245() + { + } + [Test] + public void Test_6246() + { + } + [Test] + public void Test_6247() + { + } + [Test] + public void Test_6248() + { + } + [Test] + public void Test_6249() + { + } + [Test] + public void Test_6250() + { + } + [Test] + public void Test_6251() + { + } + [Test] + public void Test_6252() + { + } + [Test] + public void Test_6253() + { + } + [Test] + public void Test_6254() + { + } + [Test] + public void Test_6255() + { + } + [Test] + public void Test_6256() + { + } + [Test] + public void Test_6257() + { + } + [Test] + public void Test_6258() + { + } + [Test] + public void Test_6259() + { + } + [Test] + public void Test_6260() + { + } + [Test] + public void Test_6261() + { + } + [Test] + public void Test_6262() + { + } + [Test] + public void Test_6263() + { + } + [Test] + public void Test_6264() + { + } + [Test] + public void Test_6265() + { + } + [Test] + public void Test_6266() + { + } + [Test] + public void Test_6267() + { + } + [Test] + public void Test_6268() + { + } + [Test] + public void Test_6269() + { + } + [Test] + public void Test_6270() + { + } + [Test] + public void Test_6271() + { + } + [Test] + public void Test_6272() + { + } + [Test] + public void Test_6273() + { + } + [Test] + public void Test_6274() + { + } + [Test] + public void Test_6275() + { + } + [Test] + public void Test_6276() + { + } + [Test] + public void Test_6277() + { + } + [Test] + public void Test_6278() + { + } + [Test] + public void Test_6279() + { + } + [Test] + public void Test_6280() + { + } + [Test] + public void Test_6281() + { + } + [Test] + public void Test_6282() + { + } + [Test] + public void Test_6283() + { + } + [Test] + public void Test_6284() + { + } + [Test] + public void Test_6285() + { + } + [Test] + public void Test_6286() + { + } + [Test] + public void Test_6287() + { + } + [Test] + public void Test_6288() + { + } + [Test] + public void Test_6289() + { + } + [Test] + public void Test_6290() + { + } + [Test] + public void Test_6291() + { + } + [Test] + public void Test_6292() + { + } + [Test] + public void Test_6293() + { + } + [Test] + public void Test_6294() + { + } + [Test] + public void Test_6295() + { + } + [Test] + public void Test_6296() + { + } + [Test] + public void Test_6297() + { + } + [Test] + public void Test_6298() + { + } + [Test] + public void Test_6299() + { + } + [Test] + public void Test_6300() + { + } + [Test] + public void Test_6301() + { + } + [Test] + public void Test_6302() + { + } + [Test] + public void Test_6303() + { + } + [Test] + public void Test_6304() + { + } + [Test] + public void Test_6305() + { + } + [Test] + public void Test_6306() + { + } + [Test] + public void Test_6307() + { + } + [Test] + public void Test_6308() + { + } + [Test] + public void Test_6309() + { + } + [Test] + public void Test_6310() + { + } + [Test] + public void Test_6311() + { + } + [Test] + public void Test_6312() + { + } + [Test] + public void Test_6313() + { + } + [Test] + public void Test_6314() + { + } + [Test] + public void Test_6315() + { + } + [Test] + public void Test_6316() + { + } + [Test] + public void Test_6317() + { + } + [Test] + public void Test_6318() + { + } + [Test] + public void Test_6319() + { + } + [Test] + public void Test_6320() + { + } + [Test] + public void Test_6321() + { + } + [Test] + public void Test_6322() + { + } + [Test] + public void Test_6323() + { + } + [Test] + public void Test_6324() + { + } + [Test] + public void Test_6325() + { + } + [Test] + public void Test_6326() + { + } + [Test] + public void Test_6327() + { + } + [Test] + public void Test_6328() + { + } + [Test] + public void Test_6329() + { + } + [Test] + public void Test_6330() + { + } + [Test] + public void Test_6331() + { + } + [Test] + public void Test_6332() + { + } + [Test] + public void Test_6333() + { + } + [Test] + public void Test_6334() + { + } + [Test] + public void Test_6335() + { + } + [Test] + public void Test_6336() + { + } + [Test] + public void Test_6337() + { + } + [Test] + public void Test_6338() + { + } + [Test] + public void Test_6339() + { + } + [Test] + public void Test_6340() + { + } + [Test] + public void Test_6341() + { + } + [Test] + public void Test_6342() + { + } + [Test] + public void Test_6343() + { + } + [Test] + public void Test_6344() + { + } + [Test] + public void Test_6345() + { + } + [Test] + public void Test_6346() + { + } + [Test] + public void Test_6347() + { + } + [Test] + public void Test_6348() + { + } + [Test] + public void Test_6349() + { + } + [Test] + public void Test_6350() + { + } + [Test] + public void Test_6351() + { + } + [Test] + public void Test_6352() + { + } + [Test] + public void Test_6353() + { + } + [Test] + public void Test_6354() + { + } + [Test] + public void Test_6355() + { + } + [Test] + public void Test_6356() + { + } + [Test] + public void Test_6357() + { + } + [Test] + public void Test_6358() + { + } + [Test] + public void Test_6359() + { + } + [Test] + public void Test_6360() + { + } + [Test] + public void Test_6361() + { + } + [Test] + public void Test_6362() + { + } + [Test] + public void Test_6363() + { + } + [Test] + public void Test_6364() + { + } + [Test] + public void Test_6365() + { + } + [Test] + public void Test_6366() + { + } + [Test] + public void Test_6367() + { + } + [Test] + public void Test_6368() + { + } + [Test] + public void Test_6369() + { + } + [Test] + public void Test_6370() + { + } + [Test] + public void Test_6371() + { + } + [Test] + public void Test_6372() + { + } + [Test] + public void Test_6373() + { + } + [Test] + public void Test_6374() + { + } + [Test] + public void Test_6375() + { + } + [Test] + public void Test_6376() + { + } + [Test] + public void Test_6377() + { + } + [Test] + public void Test_6378() + { + } + [Test] + public void Test_6379() + { + } + [Test] + public void Test_6380() + { + } + [Test] + public void Test_6381() + { + } + [Test] + public void Test_6382() + { + } + [Test] + public void Test_6383() + { + } + [Test] + public void Test_6384() + { + } + [Test] + public void Test_6385() + { + } + [Test] + public void Test_6386() + { + } + [Test] + public void Test_6387() + { + } + [Test] + public void Test_6388() + { + } + [Test] + public void Test_6389() + { + } + [Test] + public void Test_6390() + { + } + [Test] + public void Test_6391() + { + } + [Test] + public void Test_6392() + { + } + [Test] + public void Test_6393() + { + } + [Test] + public void Test_6394() + { + } + [Test] + public void Test_6395() + { + } + [Test] + public void Test_6396() + { + } + [Test] + public void Test_6397() + { + } + [Test] + public void Test_6398() + { + } + [Test] + public void Test_6399() + { + } + [Test] + public void Test_6400() + { + } + [Test] + public void Test_6401() + { + } + [Test] + public void Test_6402() + { + } + [Test] + public void Test_6403() + { + } + [Test] + public void Test_6404() + { + } + [Test] + public void Test_6405() + { + } + [Test] + public void Test_6406() + { + } + [Test] + public void Test_6407() + { + } + [Test] + public void Test_6408() + { + } + [Test] + public void Test_6409() + { + } + [Test] + public void Test_6410() + { + } + [Test] + public void Test_6411() + { + } + [Test] + public void Test_6412() + { + } + [Test] + public void Test_6413() + { + } + [Test] + public void Test_6414() + { + } + [Test] + public void Test_6415() + { + } + [Test] + public void Test_6416() + { + } + [Test] + public void Test_6417() + { + } + [Test] + public void Test_6418() + { + } + [Test] + public void Test_6419() + { + } + [Test] + public void Test_6420() + { + } + [Test] + public void Test_6421() + { + } + [Test] + public void Test_6422() + { + } + [Test] + public void Test_6423() + { + } + [Test] + public void Test_6424() + { + } + [Test] + public void Test_6425() + { + } + [Test] + public void Test_6426() + { + } + [Test] + public void Test_6427() + { + } + [Test] + public void Test_6428() + { + } + [Test] + public void Test_6429() + { + } + [Test] + public void Test_6430() + { + } + [Test] + public void Test_6431() + { + } + [Test] + public void Test_6432() + { + } + [Test] + public void Test_6433() + { + } + [Test] + public void Test_6434() + { + } + [Test] + public void Test_6435() + { + } + [Test] + public void Test_6436() + { + } + [Test] + public void Test_6437() + { + } + [Test] + public void Test_6438() + { + } + [Test] + public void Test_6439() + { + } + [Test] + public void Test_6440() + { + } + [Test] + public void Test_6441() + { + } + [Test] + public void Test_6442() + { + } + [Test] + public void Test_6443() + { + } + [Test] + public void Test_6444() + { + } + [Test] + public void Test_6445() + { + } + [Test] + public void Test_6446() + { + } + [Test] + public void Test_6447() + { + } + [Test] + public void Test_6448() + { + } + [Test] + public void Test_6449() + { + } + [Test] + public void Test_6450() + { + } + [Test] + public void Test_6451() + { + } + [Test] + public void Test_6452() + { + } + [Test] + public void Test_6453() + { + } + [Test] + public void Test_6454() + { + } + [Test] + public void Test_6455() + { + } + [Test] + public void Test_6456() + { + } + [Test] + public void Test_6457() + { + } + [Test] + public void Test_6458() + { + } + [Test] + public void Test_6459() + { + } + [Test] + public void Test_6460() + { + } + [Test] + public void Test_6461() + { + } + [Test] + public void Test_6462() + { + } + [Test] + public void Test_6463() + { + } + [Test] + public void Test_6464() + { + } + [Test] + public void Test_6465() + { + } + [Test] + public void Test_6466() + { + } + [Test] + public void Test_6467() + { + } + [Test] + public void Test_6468() + { + } + [Test] + public void Test_6469() + { + } + [Test] + public void Test_6470() + { + } + [Test] + public void Test_6471() + { + } + [Test] + public void Test_6472() + { + } + [Test] + public void Test_6473() + { + } + [Test] + public void Test_6474() + { + } + [Test] + public void Test_6475() + { + } + [Test] + public void Test_6476() + { + } + [Test] + public void Test_6477() + { + } + [Test] + public void Test_6478() + { + } + [Test] + public void Test_6479() + { + } + [Test] + public void Test_6480() + { + } + [Test] + public void Test_6481() + { + } + [Test] + public void Test_6482() + { + } + [Test] + public void Test_6483() + { + } + [Test] + public void Test_6484() + { + } + [Test] + public void Test_6485() + { + } + [Test] + public void Test_6486() + { + } + [Test] + public void Test_6487() + { + } + [Test] + public void Test_6488() + { + } + [Test] + public void Test_6489() + { + } + [Test] + public void Test_6490() + { + } + [Test] + public void Test_6491() + { + } + [Test] + public void Test_6492() + { + } + [Test] + public void Test_6493() + { + } + [Test] + public void Test_6494() + { + } + [Test] + public void Test_6495() + { + } + [Test] + public void Test_6496() + { + } + [Test] + public void Test_6497() + { + } + [Test] + public void Test_6498() + { + } + [Test] + public void Test_6499() + { + } + [Test] + public void Test_6500() + { + } + [Test] + public void Test_6501() + { + } + [Test] + public void Test_6502() + { + } + [Test] + public void Test_6503() + { + } + [Test] + public void Test_6504() + { + } + [Test] + public void Test_6505() + { + } + [Test] + public void Test_6506() + { + } + [Test] + public void Test_6507() + { + } + [Test] + public void Test_6508() + { + } + [Test] + public void Test_6509() + { + } + [Test] + public void Test_6510() + { + } + [Test] + public void Test_6511() + { + } + [Test] + public void Test_6512() + { + } + [Test] + public void Test_6513() + { + } + [Test] + public void Test_6514() + { + } + [Test] + public void Test_6515() + { + } + [Test] + public void Test_6516() + { + } + [Test] + public void Test_6517() + { + } + [Test] + public void Test_6518() + { + } + [Test] + public void Test_6519() + { + } + [Test] + public void Test_6520() + { + } + [Test] + public void Test_6521() + { + } + [Test] + public void Test_6522() + { + } + [Test] + public void Test_6523() + { + } + [Test] + public void Test_6524() + { + } + [Test] + public void Test_6525() + { + } + [Test] + public void Test_6526() + { + } + [Test] + public void Test_6527() + { + } + [Test] + public void Test_6528() + { + } + [Test] + public void Test_6529() + { + } + [Test] + public void Test_6530() + { + } + [Test] + public void Test_6531() + { + } + [Test] + public void Test_6532() + { + } + [Test] + public void Test_6533() + { + } + [Test] + public void Test_6534() + { + } + [Test] + public void Test_6535() + { + } + [Test] + public void Test_6536() + { + } + [Test] + public void Test_6537() + { + } + [Test] + public void Test_6538() + { + } + [Test] + public void Test_6539() + { + } + [Test] + public void Test_6540() + { + } + [Test] + public void Test_6541() + { + } + [Test] + public void Test_6542() + { + } + [Test] + public void Test_6543() + { + } + [Test] + public void Test_6544() + { + } + [Test] + public void Test_6545() + { + } + [Test] + public void Test_6546() + { + } + [Test] + public void Test_6547() + { + } + [Test] + public void Test_6548() + { + } + [Test] + public void Test_6549() + { + } + [Test] + public void Test_6550() + { + } + [Test] + public void Test_6551() + { + } + [Test] + public void Test_6552() + { + } + [Test] + public void Test_6553() + { + } + [Test] + public void Test_6554() + { + } + [Test] + public void Test_6555() + { + } + [Test] + public void Test_6556() + { + } + [Test] + public void Test_6557() + { + } + [Test] + public void Test_6558() + { + } + [Test] + public void Test_6559() + { + } + [Test] + public void Test_6560() + { + } + [Test] + public void Test_6561() + { + } + [Test] + public void Test_6562() + { + } + [Test] + public void Test_6563() + { + } + [Test] + public void Test_6564() + { + } + [Test] + public void Test_6565() + { + } + [Test] + public void Test_6566() + { + } + [Test] + public void Test_6567() + { + } + [Test] + public void Test_6568() + { + } + [Test] + public void Test_6569() + { + } + [Test] + public void Test_6570() + { + } + [Test] + public void Test_6571() + { + } + [Test] + public void Test_6572() + { + } + [Test] + public void Test_6573() + { + } + [Test] + public void Test_6574() + { + } + [Test] + public void Test_6575() + { + } + [Test] + public void Test_6576() + { + } + [Test] + public void Test_6577() + { + } + [Test] + public void Test_6578() + { + } + [Test] + public void Test_6579() + { + } + [Test] + public void Test_6580() + { + } + [Test] + public void Test_6581() + { + } + [Test] + public void Test_6582() + { + } + [Test] + public void Test_6583() + { + } + [Test] + public void Test_6584() + { + } + [Test] + public void Test_6585() + { + } + [Test] + public void Test_6586() + { + } + [Test] + public void Test_6587() + { + } + [Test] + public void Test_6588() + { + } + [Test] + public void Test_6589() + { + } + [Test] + public void Test_6590() + { + } + [Test] + public void Test_6591() + { + } + [Test] + public void Test_6592() + { + } + [Test] + public void Test_6593() + { + } + [Test] + public void Test_6594() + { + } + [Test] + public void Test_6595() + { + } + [Test] + public void Test_6596() + { + } + [Test] + public void Test_6597() + { + } + [Test] + public void Test_6598() + { + } + [Test] + public void Test_6599() + { + } + [Test] + public void Test_6600() + { + } + [Test] + public void Test_6601() + { + } + [Test] + public void Test_6602() + { + } + [Test] + public void Test_6603() + { + } + [Test] + public void Test_6604() + { + } + [Test] + public void Test_6605() + { + } + [Test] + public void Test_6606() + { + } + [Test] + public void Test_6607() + { + } + [Test] + public void Test_6608() + { + } + [Test] + public void Test_6609() + { + } + [Test] + public void Test_6610() + { + } + [Test] + public void Test_6611() + { + } + [Test] + public void Test_6612() + { + } + [Test] + public void Test_6613() + { + } + [Test] + public void Test_6614() + { + } + [Test] + public void Test_6615() + { + } + [Test] + public void Test_6616() + { + } + [Test] + public void Test_6617() + { + } + [Test] + public void Test_6618() + { + } + [Test] + public void Test_6619() + { + } + [Test] + public void Test_6620() + { + } + [Test] + public void Test_6621() + { + } + [Test] + public void Test_6622() + { + } + [Test] + public void Test_6623() + { + } + [Test] + public void Test_6624() + { + } + [Test] + public void Test_6625() + { + } + [Test] + public void Test_6626() + { + } + [Test] + public void Test_6627() + { + } + [Test] + public void Test_6628() + { + } + [Test] + public void Test_6629() + { + } + [Test] + public void Test_6630() + { + } + [Test] + public void Test_6631() + { + } + [Test] + public void Test_6632() + { + } + [Test] + public void Test_6633() + { + } + [Test] + public void Test_6634() + { + } + [Test] + public void Test_6635() + { + } + [Test] + public void Test_6636() + { + } + [Test] + public void Test_6637() + { + } + [Test] + public void Test_6638() + { + } + [Test] + public void Test_6639() + { + } + [Test] + public void Test_6640() + { + } + [Test] + public void Test_6641() + { + } + [Test] + public void Test_6642() + { + } + [Test] + public void Test_6643() + { + } + [Test] + public void Test_6644() + { + } + [Test] + public void Test_6645() + { + } + [Test] + public void Test_6646() + { + } + [Test] + public void Test_6647() + { + } + [Test] + public void Test_6648() + { + } + [Test] + public void Test_6649() + { + } + [Test] + public void Test_6650() + { + } + [Test] + public void Test_6651() + { + } + [Test] + public void Test_6652() + { + } + [Test] + public void Test_6653() + { + } + [Test] + public void Test_6654() + { + } + [Test] + public void Test_6655() + { + } + [Test] + public void Test_6656() + { + } + [Test] + public void Test_6657() + { + } + [Test] + public void Test_6658() + { + } + [Test] + public void Test_6659() + { + } + [Test] + public void Test_6660() + { + } + [Test] + public void Test_6661() + { + } + [Test] + public void Test_6662() + { + } + [Test] + public void Test_6663() + { + } + [Test] + public void Test_6664() + { + } + [Test] + public void Test_6665() + { + } + [Test] + public void Test_6666() + { + } + [Test] + public void Test_6667() + { + } + [Test] + public void Test_6668() + { + } + [Test] + public void Test_6669() + { + } + [Test] + public void Test_6670() + { + } + [Test] + public void Test_6671() + { + } + [Test] + public void Test_6672() + { + } + [Test] + public void Test_6673() + { + } + [Test] + public void Test_6674() + { + } + [Test] + public void Test_6675() + { + } + [Test] + public void Test_6676() + { + } + [Test] + public void Test_6677() + { + } + [Test] + public void Test_6678() + { + } + [Test] + public void Test_6679() + { + } + [Test] + public void Test_6680() + { + } + [Test] + public void Test_6681() + { + } + [Test] + public void Test_6682() + { + } + [Test] + public void Test_6683() + { + } + [Test] + public void Test_6684() + { + } + [Test] + public void Test_6685() + { + } + [Test] + public void Test_6686() + { + } + [Test] + public void Test_6687() + { + } + [Test] + public void Test_6688() + { + } + [Test] + public void Test_6689() + { + } + [Test] + public void Test_6690() + { + } + [Test] + public void Test_6691() + { + } + [Test] + public void Test_6692() + { + } + [Test] + public void Test_6693() + { + } + [Test] + public void Test_6694() + { + } + [Test] + public void Test_6695() + { + } + [Test] + public void Test_6696() + { + } + [Test] + public void Test_6697() + { + } + [Test] + public void Test_6698() + { + } + [Test] + public void Test_6699() + { + } + [Test] + public void Test_6700() + { + } + [Test] + public void Test_6701() + { + } + [Test] + public void Test_6702() + { + } + [Test] + public void Test_6703() + { + } + [Test] + public void Test_6704() + { + } + [Test] + public void Test_6705() + { + } + [Test] + public void Test_6706() + { + } + [Test] + public void Test_6707() + { + } + [Test] + public void Test_6708() + { + } + [Test] + public void Test_6709() + { + } + [Test] + public void Test_6710() + { + } + [Test] + public void Test_6711() + { + } + [Test] + public void Test_6712() + { + } + [Test] + public void Test_6713() + { + } + [Test] + public void Test_6714() + { + } + [Test] + public void Test_6715() + { + } + [Test] + public void Test_6716() + { + } + [Test] + public void Test_6717() + { + } + [Test] + public void Test_6718() + { + } + [Test] + public void Test_6719() + { + } + [Test] + public void Test_6720() + { + } + [Test] + public void Test_6721() + { + } + [Test] + public void Test_6722() + { + } + [Test] + public void Test_6723() + { + } + [Test] + public void Test_6724() + { + } + [Test] + public void Test_6725() + { + } + [Test] + public void Test_6726() + { + } + [Test] + public void Test_6727() + { + } + [Test] + public void Test_6728() + { + } + [Test] + public void Test_6729() + { + } + [Test] + public void Test_6730() + { + } + [Test] + public void Test_6731() + { + } + [Test] + public void Test_6732() + { + } + [Test] + public void Test_6733() + { + } + [Test] + public void Test_6734() + { + } + [Test] + public void Test_6735() + { + } + [Test] + public void Test_6736() + { + } + [Test] + public void Test_6737() + { + } + [Test] + public void Test_6738() + { + } + [Test] + public void Test_6739() + { + } + [Test] + public void Test_6740() + { + } + [Test] + public void Test_6741() + { + } + [Test] + public void Test_6742() + { + } + [Test] + public void Test_6743() + { + } + [Test] + public void Test_6744() + { + } + [Test] + public void Test_6745() + { + } + [Test] + public void Test_6746() + { + } + [Test] + public void Test_6747() + { + } + [Test] + public void Test_6748() + { + } + [Test] + public void Test_6749() + { + } + [Test] + public void Test_6750() + { + } + [Test] + public void Test_6751() + { + } + [Test] + public void Test_6752() + { + } + [Test] + public void Test_6753() + { + } + [Test] + public void Test_6754() + { + } + [Test] + public void Test_6755() + { + } + [Test] + public void Test_6756() + { + } + [Test] + public void Test_6757() + { + } + [Test] + public void Test_6758() + { + } + [Test] + public void Test_6759() + { + } + [Test] + public void Test_6760() + { + } + [Test] + public void Test_6761() + { + } + [Test] + public void Test_6762() + { + } + [Test] + public void Test_6763() + { + } + [Test] + public void Test_6764() + { + } + [Test] + public void Test_6765() + { + } + [Test] + public void Test_6766() + { + } + [Test] + public void Test_6767() + { + } + [Test] + public void Test_6768() + { + } + [Test] + public void Test_6769() + { + } + [Test] + public void Test_6770() + { + } + [Test] + public void Test_6771() + { + } + [Test] + public void Test_6772() + { + } + [Test] + public void Test_6773() + { + } + [Test] + public void Test_6774() + { + } + [Test] + public void Test_6775() + { + } + [Test] + public void Test_6776() + { + } + [Test] + public void Test_6777() + { + } + [Test] + public void Test_6778() + { + } + [Test] + public void Test_6779() + { + } + [Test] + public void Test_6780() + { + } + [Test] + public void Test_6781() + { + } + [Test] + public void Test_6782() + { + } + [Test] + public void Test_6783() + { + } + [Test] + public void Test_6784() + { + } + [Test] + public void Test_6785() + { + } + [Test] + public void Test_6786() + { + } + [Test] + public void Test_6787() + { + } + [Test] + public void Test_6788() + { + } + [Test] + public void Test_6789() + { + } + [Test] + public void Test_6790() + { + } + [Test] + public void Test_6791() + { + } + [Test] + public void Test_6792() + { + } + [Test] + public void Test_6793() + { + } + [Test] + public void Test_6794() + { + } + [Test] + public void Test_6795() + { + } + [Test] + public void Test_6796() + { + } + [Test] + public void Test_6797() + { + } + [Test] + public void Test_6798() + { + } + [Test] + public void Test_6799() + { + } + [Test] + public void Test_6800() + { + } + [Test] + public void Test_6801() + { + } + [Test] + public void Test_6802() + { + } + [Test] + public void Test_6803() + { + } + [Test] + public void Test_6804() + { + } + [Test] + public void Test_6805() + { + } + [Test] + public void Test_6806() + { + } + [Test] + public void Test_6807() + { + } + [Test] + public void Test_6808() + { + } + [Test] + public void Test_6809() + { + } + [Test] + public void Test_6810() + { + } + [Test] + public void Test_6811() + { + } + [Test] + public void Test_6812() + { + } + [Test] + public void Test_6813() + { + } + [Test] + public void Test_6814() + { + } + [Test] + public void Test_6815() + { + } + [Test] + public void Test_6816() + { + } + [Test] + public void Test_6817() + { + } + [Test] + public void Test_6818() + { + } + [Test] + public void Test_6819() + { + } + [Test] + public void Test_6820() + { + } + [Test] + public void Test_6821() + { + } + [Test] + public void Test_6822() + { + } + [Test] + public void Test_6823() + { + } + [Test] + public void Test_6824() + { + } + [Test] + public void Test_6825() + { + } + [Test] + public void Test_6826() + { + } + [Test] + public void Test_6827() + { + } + [Test] + public void Test_6828() + { + } + [Test] + public void Test_6829() + { + } + [Test] + public void Test_6830() + { + } + [Test] + public void Test_6831() + { + } + [Test] + public void Test_6832() + { + } + [Test] + public void Test_6833() + { + } + [Test] + public void Test_6834() + { + } + [Test] + public void Test_6835() + { + } + [Test] + public void Test_6836() + { + } + [Test] + public void Test_6837() + { + } + [Test] + public void Test_6838() + { + } + [Test] + public void Test_6839() + { + } + [Test] + public void Test_6840() + { + } + [Test] + public void Test_6841() + { + } + [Test] + public void Test_6842() + { + } + [Test] + public void Test_6843() + { + } + [Test] + public void Test_6844() + { + } + [Test] + public void Test_6845() + { + } + [Test] + public void Test_6846() + { + } + [Test] + public void Test_6847() + { + } + [Test] + public void Test_6848() + { + } + [Test] + public void Test_6849() + { + } + [Test] + public void Test_6850() + { + } + [Test] + public void Test_6851() + { + } + [Test] + public void Test_6852() + { + } + [Test] + public void Test_6853() + { + } + [Test] + public void Test_6854() + { + } + [Test] + public void Test_6855() + { + } + [Test] + public void Test_6856() + { + } + [Test] + public void Test_6857() + { + } + [Test] + public void Test_6858() + { + } + [Test] + public void Test_6859() + { + } + [Test] + public void Test_6860() + { + } + [Test] + public void Test_6861() + { + } + [Test] + public void Test_6862() + { + } + [Test] + public void Test_6863() + { + } + [Test] + public void Test_6864() + { + } + [Test] + public void Test_6865() + { + } + [Test] + public void Test_6866() + { + } + [Test] + public void Test_6867() + { + } + [Test] + public void Test_6868() + { + } + [Test] + public void Test_6869() + { + } + [Test] + public void Test_6870() + { + } + [Test] + public void Test_6871() + { + } + [Test] + public void Test_6872() + { + } + [Test] + public void Test_6873() + { + } + [Test] + public void Test_6874() + { + } + [Test] + public void Test_6875() + { + } + [Test] + public void Test_6876() + { + } + [Test] + public void Test_6877() + { + } + [Test] + public void Test_6878() + { + } + [Test] + public void Test_6879() + { + } + [Test] + public void Test_6880() + { + } + [Test] + public void Test_6881() + { + } + [Test] + public void Test_6882() + { + } + [Test] + public void Test_6883() + { + } + [Test] + public void Test_6884() + { + } + [Test] + public void Test_6885() + { + } + [Test] + public void Test_6886() + { + } + [Test] + public void Test_6887() + { + } + [Test] + public void Test_6888() + { + } + [Test] + public void Test_6889() + { + } + [Test] + public void Test_6890() + { + } + [Test] + public void Test_6891() + { + } + [Test] + public void Test_6892() + { + } + [Test] + public void Test_6893() + { + } + [Test] + public void Test_6894() + { + } + [Test] + public void Test_6895() + { + } + [Test] + public void Test_6896() + { + } + [Test] + public void Test_6897() + { + } + [Test] + public void Test_6898() + { + } + [Test] + public void Test_6899() + { + } + [Test] + public void Test_6900() + { + } + [Test] + public void Test_6901() + { + } + [Test] + public void Test_6902() + { + } + [Test] + public void Test_6903() + { + } + [Test] + public void Test_6904() + { + } + [Test] + public void Test_6905() + { + } + [Test] + public void Test_6906() + { + } + [Test] + public void Test_6907() + { + } + [Test] + public void Test_6908() + { + } + [Test] + public void Test_6909() + { + } + [Test] + public void Test_6910() + { + } + [Test] + public void Test_6911() + { + } + [Test] + public void Test_6912() + { + } + [Test] + public void Test_6913() + { + } + [Test] + public void Test_6914() + { + } + [Test] + public void Test_6915() + { + } + [Test] + public void Test_6916() + { + } + [Test] + public void Test_6917() + { + } + [Test] + public void Test_6918() + { + } + [Test] + public void Test_6919() + { + } + [Test] + public void Test_6920() + { + } + [Test] + public void Test_6921() + { + } + [Test] + public void Test_6922() + { + } + [Test] + public void Test_6923() + { + } + [Test] + public void Test_6924() + { + } + [Test] + public void Test_6925() + { + } + [Test] + public void Test_6926() + { + } + [Test] + public void Test_6927() + { + } + [Test] + public void Test_6928() + { + } + [Test] + public void Test_6929() + { + } + [Test] + public void Test_6930() + { + } + [Test] + public void Test_6931() + { + } + [Test] + public void Test_6932() + { + } + [Test] + public void Test_6933() + { + } + [Test] + public void Test_6934() + { + } + [Test] + public void Test_6935() + { + } + [Test] + public void Test_6936() + { + } + [Test] + public void Test_6937() + { + } + [Test] + public void Test_6938() + { + } + [Test] + public void Test_6939() + { + } + [Test] + public void Test_6940() + { + } + [Test] + public void Test_6941() + { + } + [Test] + public void Test_6942() + { + } + [Test] + public void Test_6943() + { + } + [Test] + public void Test_6944() + { + } + [Test] + public void Test_6945() + { + } + [Test] + public void Test_6946() + { + } + [Test] + public void Test_6947() + { + } + [Test] + public void Test_6948() + { + } + [Test] + public void Test_6949() + { + } + [Test] + public void Test_6950() + { + } + [Test] + public void Test_6951() + { + } + [Test] + public void Test_6952() + { + } + [Test] + public void Test_6953() + { + } + [Test] + public void Test_6954() + { + } + [Test] + public void Test_6955() + { + } + [Test] + public void Test_6956() + { + } + [Test] + public void Test_6957() + { + } + [Test] + public void Test_6958() + { + } + [Test] + public void Test_6959() + { + } + [Test] + public void Test_6960() + { + } + [Test] + public void Test_6961() + { + } + [Test] + public void Test_6962() + { + } + [Test] + public void Test_6963() + { + } + [Test] + public void Test_6964() + { + } + [Test] + public void Test_6965() + { + } + [Test] + public void Test_6966() + { + } + [Test] + public void Test_6967() + { + } + [Test] + public void Test_6968() + { + } + [Test] + public void Test_6969() + { + } + [Test] + public void Test_6970() + { + } + [Test] + public void Test_6971() + { + } + [Test] + public void Test_6972() + { + } + [Test] + public void Test_6973() + { + } + [Test] + public void Test_6974() + { + } + [Test] + public void Test_6975() + { + } + [Test] + public void Test_6976() + { + } + [Test] + public void Test_6977() + { + } + [Test] + public void Test_6978() + { + } + [Test] + public void Test_6979() + { + } + [Test] + public void Test_6980() + { + } + [Test] + public void Test_6981() + { + } + [Test] + public void Test_6982() + { + } + [Test] + public void Test_6983() + { + } + [Test] + public void Test_6984() + { + } + [Test] + public void Test_6985() + { + } + [Test] + public void Test_6986() + { + } + [Test] + public void Test_6987() + { + } + [Test] + public void Test_6988() + { + } + [Test] + public void Test_6989() + { + } + [Test] + public void Test_6990() + { + } + [Test] + public void Test_6991() + { + } + [Test] + public void Test_6992() + { + } + [Test] + public void Test_6993() + { + } + [Test] + public void Test_6994() + { + } + [Test] + public void Test_6995() + { + } + [Test] + public void Test_6996() + { + } + [Test] + public void Test_6997() + { + } + [Test] + public void Test_6998() + { + } + [Test] + public void Test_6999() + { + } + [Test] + public void Test_7000() + { + } + [Test] + public void Test_7001() + { + } + [Test] + public void Test_7002() + { + } + [Test] + public void Test_7003() + { + } + [Test] + public void Test_7004() + { + } + [Test] + public void Test_7005() + { + } + [Test] + public void Test_7006() + { + } + [Test] + public void Test_7007() + { + } + [Test] + public void Test_7008() + { + } + [Test] + public void Test_7009() + { + } + [Test] + public void Test_7010() + { + } + [Test] + public void Test_7011() + { + } + [Test] + public void Test_7012() + { + } + [Test] + public void Test_7013() + { + } + [Test] + public void Test_7014() + { + } + [Test] + public void Test_7015() + { + } + [Test] + public void Test_7016() + { + } + [Test] + public void Test_7017() + { + } + [Test] + public void Test_7018() + { + } + [Test] + public void Test_7019() + { + } + [Test] + public void Test_7020() + { + } + [Test] + public void Test_7021() + { + } + [Test] + public void Test_7022() + { + } + [Test] + public void Test_7023() + { + } + [Test] + public void Test_7024() + { + } + [Test] + public void Test_7025() + { + } + [Test] + public void Test_7026() + { + } + [Test] + public void Test_7027() + { + } + [Test] + public void Test_7028() + { + } + [Test] + public void Test_7029() + { + } + [Test] + public void Test_7030() + { + } + [Test] + public void Test_7031() + { + } + [Test] + public void Test_7032() + { + } + [Test] + public void Test_7033() + { + } + [Test] + public void Test_7034() + { + } + [Test] + public void Test_7035() + { + } + [Test] + public void Test_7036() + { + } + [Test] + public void Test_7037() + { + } + [Test] + public void Test_7038() + { + } + [Test] + public void Test_7039() + { + } + [Test] + public void Test_7040() + { + } + [Test] + public void Test_7041() + { + } + [Test] + public void Test_7042() + { + } + [Test] + public void Test_7043() + { + } + [Test] + public void Test_7044() + { + } + [Test] + public void Test_7045() + { + } + [Test] + public void Test_7046() + { + } + [Test] + public void Test_7047() + { + } + [Test] + public void Test_7048() + { + } + [Test] + public void Test_7049() + { + } + [Test] + public void Test_7050() + { + } + [Test] + public void Test_7051() + { + } + [Test] + public void Test_7052() + { + } + [Test] + public void Test_7053() + { + } + [Test] + public void Test_7054() + { + } + [Test] + public void Test_7055() + { + } + [Test] + public void Test_7056() + { + } + [Test] + public void Test_7057() + { + } + [Test] + public void Test_7058() + { + } + [Test] + public void Test_7059() + { + } + [Test] + public void Test_7060() + { + } + [Test] + public void Test_7061() + { + } + [Test] + public void Test_7062() + { + } + [Test] + public void Test_7063() + { + } + [Test] + public void Test_7064() + { + } + [Test] + public void Test_7065() + { + } + [Test] + public void Test_7066() + { + } + [Test] + public void Test_7067() + { + } + [Test] + public void Test_7068() + { + } + [Test] + public void Test_7069() + { + } + [Test] + public void Test_7070() + { + } + [Test] + public void Test_7071() + { + } + [Test] + public void Test_7072() + { + } + [Test] + public void Test_7073() + { + } + [Test] + public void Test_7074() + { + } + [Test] + public void Test_7075() + { + } + [Test] + public void Test_7076() + { + } + [Test] + public void Test_7077() + { + } + [Test] + public void Test_7078() + { + } + [Test] + public void Test_7079() + { + } + [Test] + public void Test_7080() + { + } + [Test] + public void Test_7081() + { + } + [Test] + public void Test_7082() + { + } + [Test] + public void Test_7083() + { + } + [Test] + public void Test_7084() + { + } + [Test] + public void Test_7085() + { + } + [Test] + public void Test_7086() + { + } + [Test] + public void Test_7087() + { + } + [Test] + public void Test_7088() + { + } + [Test] + public void Test_7089() + { + } + [Test] + public void Test_7090() + { + } + [Test] + public void Test_7091() + { + } + [Test] + public void Test_7092() + { + } + [Test] + public void Test_7093() + { + } + [Test] + public void Test_7094() + { + } + [Test] + public void Test_7095() + { + } + [Test] + public void Test_7096() + { + } + [Test] + public void Test_7097() + { + } + [Test] + public void Test_7098() + { + } + [Test] + public void Test_7099() + { + } + [Test] + public void Test_7100() + { + } + [Test] + public void Test_7101() + { + } + [Test] + public void Test_7102() + { + } + [Test] + public void Test_7103() + { + } + [Test] + public void Test_7104() + { + } + [Test] + public void Test_7105() + { + } + [Test] + public void Test_7106() + { + } + [Test] + public void Test_7107() + { + } + [Test] + public void Test_7108() + { + } + [Test] + public void Test_7109() + { + } + [Test] + public void Test_7110() + { + } + [Test] + public void Test_7111() + { + } + [Test] + public void Test_7112() + { + } + [Test] + public void Test_7113() + { + } + [Test] + public void Test_7114() + { + } + [Test] + public void Test_7115() + { + } + [Test] + public void Test_7116() + { + } + [Test] + public void Test_7117() + { + } + [Test] + public void Test_7118() + { + } + [Test] + public void Test_7119() + { + } + [Test] + public void Test_7120() + { + } + [Test] + public void Test_7121() + { + } + [Test] + public void Test_7122() + { + } + [Test] + public void Test_7123() + { + } + [Test] + public void Test_7124() + { + } + [Test] + public void Test_7125() + { + } + [Test] + public void Test_7126() + { + } + [Test] + public void Test_7127() + { + } + [Test] + public void Test_7128() + { + } + [Test] + public void Test_7129() + { + } + [Test] + public void Test_7130() + { + } + [Test] + public void Test_7131() + { + } + [Test] + public void Test_7132() + { + } + [Test] + public void Test_7133() + { + } + [Test] + public void Test_7134() + { + } + [Test] + public void Test_7135() + { + } + [Test] + public void Test_7136() + { + } + [Test] + public void Test_7137() + { + } + [Test] + public void Test_7138() + { + } + [Test] + public void Test_7139() + { + } + [Test] + public void Test_7140() + { + } + [Test] + public void Test_7141() + { + } + [Test] + public void Test_7142() + { + } + [Test] + public void Test_7143() + { + } + [Test] + public void Test_7144() + { + } + [Test] + public void Test_7145() + { + } + [Test] + public void Test_7146() + { + } + [Test] + public void Test_7147() + { + } + [Test] + public void Test_7148() + { + } + [Test] + public void Test_7149() + { + } + [Test] + public void Test_7150() + { + } + [Test] + public void Test_7151() + { + } + [Test] + public void Test_7152() + { + } + [Test] + public void Test_7153() + { + } + [Test] + public void Test_7154() + { + } + [Test] + public void Test_7155() + { + } + [Test] + public void Test_7156() + { + } + [Test] + public void Test_7157() + { + } + [Test] + public void Test_7158() + { + } + [Test] + public void Test_7159() + { + } + [Test] + public void Test_7160() + { + } + [Test] + public void Test_7161() + { + } + [Test] + public void Test_7162() + { + } + [Test] + public void Test_7163() + { + } + [Test] + public void Test_7164() + { + } + [Test] + public void Test_7165() + { + } + [Test] + public void Test_7166() + { + } + [Test] + public void Test_7167() + { + } + [Test] + public void Test_7168() + { + } + [Test] + public void Test_7169() + { + } + [Test] + public void Test_7170() + { + } + [Test] + public void Test_7171() + { + } + [Test] + public void Test_7172() + { + } + [Test] + public void Test_7173() + { + } + [Test] + public void Test_7174() + { + } + [Test] + public void Test_7175() + { + } + [Test] + public void Test_7176() + { + } + [Test] + public void Test_7177() + { + } + [Test] + public void Test_7178() + { + } + [Test] + public void Test_7179() + { + } + [Test] + public void Test_7180() + { + } + [Test] + public void Test_7181() + { + } + [Test] + public void Test_7182() + { + } + [Test] + public void Test_7183() + { + } + [Test] + public void Test_7184() + { + } + [Test] + public void Test_7185() + { + } + [Test] + public void Test_7186() + { + } + [Test] + public void Test_7187() + { + } + [Test] + public void Test_7188() + { + } + [Test] + public void Test_7189() + { + } + [Test] + public void Test_7190() + { + } + [Test] + public void Test_7191() + { + } + [Test] + public void Test_7192() + { + } + [Test] + public void Test_7193() + { + } + [Test] + public void Test_7194() + { + } + [Test] + public void Test_7195() + { + } + [Test] + public void Test_7196() + { + } + [Test] + public void Test_7197() + { + } + [Test] + public void Test_7198() + { + } + [Test] + public void Test_7199() + { + } + [Test] + public void Test_7200() + { + } + [Test] + public void Test_7201() + { + } + [Test] + public void Test_7202() + { + } + [Test] + public void Test_7203() + { + } + [Test] + public void Test_7204() + { + } + [Test] + public void Test_7205() + { + } + [Test] + public void Test_7206() + { + } + [Test] + public void Test_7207() + { + } + [Test] + public void Test_7208() + { + } + [Test] + public void Test_7209() + { + } + [Test] + public void Test_7210() + { + } + [Test] + public void Test_7211() + { + } + [Test] + public void Test_7212() + { + } + [Test] + public void Test_7213() + { + } + [Test] + public void Test_7214() + { + } + [Test] + public void Test_7215() + { + } + [Test] + public void Test_7216() + { + } + [Test] + public void Test_7217() + { + } + [Test] + public void Test_7218() + { + } + [Test] + public void Test_7219() + { + } + [Test] + public void Test_7220() + { + } + [Test] + public void Test_7221() + { + } + [Test] + public void Test_7222() + { + } + [Test] + public void Test_7223() + { + } + [Test] + public void Test_7224() + { + } + [Test] + public void Test_7225() + { + } + [Test] + public void Test_7226() + { + } + [Test] + public void Test_7227() + { + } + [Test] + public void Test_7228() + { + } + [Test] + public void Test_7229() + { + } + [Test] + public void Test_7230() + { + } + [Test] + public void Test_7231() + { + } + [Test] + public void Test_7232() + { + } + [Test] + public void Test_7233() + { + } + [Test] + public void Test_7234() + { + } + [Test] + public void Test_7235() + { + } + [Test] + public void Test_7236() + { + } + [Test] + public void Test_7237() + { + } + [Test] + public void Test_7238() + { + } + [Test] + public void Test_7239() + { + } + [Test] + public void Test_7240() + { + } + [Test] + public void Test_7241() + { + } + [Test] + public void Test_7242() + { + } + [Test] + public void Test_7243() + { + } + [Test] + public void Test_7244() + { + } + [Test] + public void Test_7245() + { + } + [Test] + public void Test_7246() + { + } + [Test] + public void Test_7247() + { + } + [Test] + public void Test_7248() + { + } + [Test] + public void Test_7249() + { + } + [Test] + public void Test_7250() + { + } + [Test] + public void Test_7251() + { + } + [Test] + public void Test_7252() + { + } + [Test] + public void Test_7253() + { + } + [Test] + public void Test_7254() + { + } + [Test] + public void Test_7255() + { + } + [Test] + public void Test_7256() + { + } + [Test] + public void Test_7257() + { + } + [Test] + public void Test_7258() + { + } + [Test] + public void Test_7259() + { + } + [Test] + public void Test_7260() + { + } + [Test] + public void Test_7261() + { + } + [Test] + public void Test_7262() + { + } + [Test] + public void Test_7263() + { + } + [Test] + public void Test_7264() + { + } + [Test] + public void Test_7265() + { + } + [Test] + public void Test_7266() + { + } + [Test] + public void Test_7267() + { + } + [Test] + public void Test_7268() + { + } + [Test] + public void Test_7269() + { + } + [Test] + public void Test_7270() + { + } + [Test] + public void Test_7271() + { + } + [Test] + public void Test_7272() + { + } + [Test] + public void Test_7273() + { + } + [Test] + public void Test_7274() + { + } + [Test] + public void Test_7275() + { + } + [Test] + public void Test_7276() + { + } + [Test] + public void Test_7277() + { + } + [Test] + public void Test_7278() + { + } + [Test] + public void Test_7279() + { + } + [Test] + public void Test_7280() + { + } + [Test] + public void Test_7281() + { + } + [Test] + public void Test_7282() + { + } + [Test] + public void Test_7283() + { + } + [Test] + public void Test_7284() + { + } + [Test] + public void Test_7285() + { + } + [Test] + public void Test_7286() + { + } + [Test] + public void Test_7287() + { + } + [Test] + public void Test_7288() + { + } + [Test] + public void Test_7289() + { + } + [Test] + public void Test_7290() + { + } + [Test] + public void Test_7291() + { + } + [Test] + public void Test_7292() + { + } + [Test] + public void Test_7293() + { + } + [Test] + public void Test_7294() + { + } + [Test] + public void Test_7295() + { + } + [Test] + public void Test_7296() + { + } + [Test] + public void Test_7297() + { + } + [Test] + public void Test_7298() + { + } + [Test] + public void Test_7299() + { + } + [Test] + public void Test_7300() + { + } + [Test] + public void Test_7301() + { + } + [Test] + public void Test_7302() + { + } + [Test] + public void Test_7303() + { + } + [Test] + public void Test_7304() + { + } + [Test] + public void Test_7305() + { + } + [Test] + public void Test_7306() + { + } + [Test] + public void Test_7307() + { + } + [Test] + public void Test_7308() + { + } + [Test] + public void Test_7309() + { + } + [Test] + public void Test_7310() + { + } + [Test] + public void Test_7311() + { + } + [Test] + public void Test_7312() + { + } + [Test] + public void Test_7313() + { + } + [Test] + public void Test_7314() + { + } + [Test] + public void Test_7315() + { + } + [Test] + public void Test_7316() + { + } + [Test] + public void Test_7317() + { + } + [Test] + public void Test_7318() + { + } + [Test] + public void Test_7319() + { + } + [Test] + public void Test_7320() + { + } + [Test] + public void Test_7321() + { + } + [Test] + public void Test_7322() + { + } + [Test] + public void Test_7323() + { + } + [Test] + public void Test_7324() + { + } + [Test] + public void Test_7325() + { + } + [Test] + public void Test_7326() + { + } + [Test] + public void Test_7327() + { + } + [Test] + public void Test_7328() + { + } + [Test] + public void Test_7329() + { + } + [Test] + public void Test_7330() + { + } + [Test] + public void Test_7331() + { + } + [Test] + public void Test_7332() + { + } + [Test] + public void Test_7333() + { + } + [Test] + public void Test_7334() + { + } + [Test] + public void Test_7335() + { + } + [Test] + public void Test_7336() + { + } + [Test] + public void Test_7337() + { + } + [Test] + public void Test_7338() + { + } + [Test] + public void Test_7339() + { + } + [Test] + public void Test_7340() + { + } + [Test] + public void Test_7341() + { + } + [Test] + public void Test_7342() + { + } + [Test] + public void Test_7343() + { + } + [Test] + public void Test_7344() + { + } + [Test] + public void Test_7345() + { + } + [Test] + public void Test_7346() + { + } + [Test] + public void Test_7347() + { + } + [Test] + public void Test_7348() + { + } + [Test] + public void Test_7349() + { + } + [Test] + public void Test_7350() + { + } + [Test] + public void Test_7351() + { + } + [Test] + public void Test_7352() + { + } + [Test] + public void Test_7353() + { + } + [Test] + public void Test_7354() + { + } + [Test] + public void Test_7355() + { + } + [Test] + public void Test_7356() + { + } + [Test] + public void Test_7357() + { + } + [Test] + public void Test_7358() + { + } + [Test] + public void Test_7359() + { + } + [Test] + public void Test_7360() + { + } + [Test] + public void Test_7361() + { + } + [Test] + public void Test_7362() + { + } + [Test] + public void Test_7363() + { + } + [Test] + public void Test_7364() + { + } + [Test] + public void Test_7365() + { + } + [Test] + public void Test_7366() + { + } + [Test] + public void Test_7367() + { + } + [Test] + public void Test_7368() + { + } + [Test] + public void Test_7369() + { + } + [Test] + public void Test_7370() + { + } + [Test] + public void Test_7371() + { + } + [Test] + public void Test_7372() + { + } + [Test] + public void Test_7373() + { + } + [Test] + public void Test_7374() + { + } + [Test] + public void Test_7375() + { + } + [Test] + public void Test_7376() + { + } + [Test] + public void Test_7377() + { + } + [Test] + public void Test_7378() + { + } + [Test] + public void Test_7379() + { + } + [Test] + public void Test_7380() + { + } + [Test] + public void Test_7381() + { + } + [Test] + public void Test_7382() + { + } + [Test] + public void Test_7383() + { + } + [Test] + public void Test_7384() + { + } + [Test] + public void Test_7385() + { + } + [Test] + public void Test_7386() + { + } + [Test] + public void Test_7387() + { + } + [Test] + public void Test_7388() + { + } + [Test] + public void Test_7389() + { + } + [Test] + public void Test_7390() + { + } + [Test] + public void Test_7391() + { + } + [Test] + public void Test_7392() + { + } + [Test] + public void Test_7393() + { + } + [Test] + public void Test_7394() + { + } + [Test] + public void Test_7395() + { + } + [Test] + public void Test_7396() + { + } + [Test] + public void Test_7397() + { + } + [Test] + public void Test_7398() + { + } + [Test] + public void Test_7399() + { + } + [Test] + public void Test_7400() + { + } + [Test] + public void Test_7401() + { + } + [Test] + public void Test_7402() + { + } + [Test] + public void Test_7403() + { + } + [Test] + public void Test_7404() + { + } + [Test] + public void Test_7405() + { + } + [Test] + public void Test_7406() + { + } + [Test] + public void Test_7407() + { + } + [Test] + public void Test_7408() + { + } + [Test] + public void Test_7409() + { + } + [Test] + public void Test_7410() + { + } + [Test] + public void Test_7411() + { + } + [Test] + public void Test_7412() + { + } + [Test] + public void Test_7413() + { + } + [Test] + public void Test_7414() + { + } + [Test] + public void Test_7415() + { + } + [Test] + public void Test_7416() + { + } + [Test] + public void Test_7417() + { + } + [Test] + public void Test_7418() + { + } + [Test] + public void Test_7419() + { + } + [Test] + public void Test_7420() + { + } + [Test] + public void Test_7421() + { + } + [Test] + public void Test_7422() + { + } + [Test] + public void Test_7423() + { + } + [Test] + public void Test_7424() + { + } + [Test] + public void Test_7425() + { + } + [Test] + public void Test_7426() + { + } + [Test] + public void Test_7427() + { + } + [Test] + public void Test_7428() + { + } + [Test] + public void Test_7429() + { + } + [Test] + public void Test_7430() + { + } + [Test] + public void Test_7431() + { + } + [Test] + public void Test_7432() + { + } + [Test] + public void Test_7433() + { + } + [Test] + public void Test_7434() + { + } + [Test] + public void Test_7435() + { + } + [Test] + public void Test_7436() + { + } + [Test] + public void Test_7437() + { + } + [Test] + public void Test_7438() + { + } + [Test] + public void Test_7439() + { + } + [Test] + public void Test_7440() + { + } + [Test] + public void Test_7441() + { + } + [Test] + public void Test_7442() + { + } + [Test] + public void Test_7443() + { + } + [Test] + public void Test_7444() + { + } + [Test] + public void Test_7445() + { + } + [Test] + public void Test_7446() + { + } + [Test] + public void Test_7447() + { + } + [Test] + public void Test_7448() + { + } + [Test] + public void Test_7449() + { + } + [Test] + public void Test_7450() + { + } + [Test] + public void Test_7451() + { + } + [Test] + public void Test_7452() + { + } + [Test] + public void Test_7453() + { + } + [Test] + public void Test_7454() + { + } + [Test] + public void Test_7455() + { + } + [Test] + public void Test_7456() + { + } + [Test] + public void Test_7457() + { + } + [Test] + public void Test_7458() + { + } + [Test] + public void Test_7459() + { + } + [Test] + public void Test_7460() + { + } + [Test] + public void Test_7461() + { + } + [Test] + public void Test_7462() + { + } + [Test] + public void Test_7463() + { + } + [Test] + public void Test_7464() + { + } + [Test] + public void Test_7465() + { + } + [Test] + public void Test_7466() + { + } + [Test] + public void Test_7467() + { + } + [Test] + public void Test_7468() + { + } + [Test] + public void Test_7469() + { + } + [Test] + public void Test_7470() + { + } + [Test] + public void Test_7471() + { + } + [Test] + public void Test_7472() + { + } + [Test] + public void Test_7473() + { + } + [Test] + public void Test_7474() + { + } + [Test] + public void Test_7475() + { + } + [Test] + public void Test_7476() + { + } + [Test] + public void Test_7477() + { + } + [Test] + public void Test_7478() + { + } + [Test] + public void Test_7479() + { + } + [Test] + public void Test_7480() + { + } + [Test] + public void Test_7481() + { + } + [Test] + public void Test_7482() + { + } + [Test] + public void Test_7483() + { + } + [Test] + public void Test_7484() + { + } + [Test] + public void Test_7485() + { + } + [Test] + public void Test_7486() + { + } + [Test] + public void Test_7487() + { + } + [Test] + public void Test_7488() + { + } + [Test] + public void Test_7489() + { + } + [Test] + public void Test_7490() + { + } + [Test] + public void Test_7491() + { + } + [Test] + public void Test_7492() + { + } + [Test] + public void Test_7493() + { + } + [Test] + public void Test_7494() + { + } + [Test] + public void Test_7495() + { + } + [Test] + public void Test_7496() + { + } + [Test] + public void Test_7497() + { + } + [Test] + public void Test_7498() + { + } + [Test] + public void Test_7499() + { + } + [Test] + public void Test_7500() + { + } + [Test] + public void Test_7501() + { + } + [Test] + public void Test_7502() + { + } + [Test] + public void Test_7503() + { + } + [Test] + public void Test_7504() + { + } + [Test] + public void Test_7505() + { + } + [Test] + public void Test_7506() + { + } + [Test] + public void Test_7507() + { + } + [Test] + public void Test_7508() + { + } + [Test] + public void Test_7509() + { + } + [Test] + public void Test_7510() + { + } + [Test] + public void Test_7511() + { + } + [Test] + public void Test_7512() + { + } + [Test] + public void Test_7513() + { + } + [Test] + public void Test_7514() + { + } + [Test] + public void Test_7515() + { + } + [Test] + public void Test_7516() + { + } + [Test] + public void Test_7517() + { + } + [Test] + public void Test_7518() + { + } + [Test] + public void Test_7519() + { + } + [Test] + public void Test_7520() + { + } + [Test] + public void Test_7521() + { + } + [Test] + public void Test_7522() + { + } + [Test] + public void Test_7523() + { + } + [Test] + public void Test_7524() + { + } + [Test] + public void Test_7525() + { + } + [Test] + public void Test_7526() + { + } + [Test] + public void Test_7527() + { + } + [Test] + public void Test_7528() + { + } + [Test] + public void Test_7529() + { + } + [Test] + public void Test_7530() + { + } + [Test] + public void Test_7531() + { + } + [Test] + public void Test_7532() + { + } + [Test] + public void Test_7533() + { + } + [Test] + public void Test_7534() + { + } + [Test] + public void Test_7535() + { + } + [Test] + public void Test_7536() + { + } + [Test] + public void Test_7537() + { + } + [Test] + public void Test_7538() + { + } + [Test] + public void Test_7539() + { + } + [Test] + public void Test_7540() + { + } + [Test] + public void Test_7541() + { + } + [Test] + public void Test_7542() + { + } + [Test] + public void Test_7543() + { + } + [Test] + public void Test_7544() + { + } + [Test] + public void Test_7545() + { + } + [Test] + public void Test_7546() + { + } + [Test] + public void Test_7547() + { + } + [Test] + public void Test_7548() + { + } + [Test] + public void Test_7549() + { + } + [Test] + public void Test_7550() + { + } + [Test] + public void Test_7551() + { + } + [Test] + public void Test_7552() + { + } + [Test] + public void Test_7553() + { + } + [Test] + public void Test_7554() + { + } + [Test] + public void Test_7555() + { + } + [Test] + public void Test_7556() + { + } + [Test] + public void Test_7557() + { + } + [Test] + public void Test_7558() + { + } + [Test] + public void Test_7559() + { + } + [Test] + public void Test_7560() + { + } + [Test] + public void Test_7561() + { + } + [Test] + public void Test_7562() + { + } + [Test] + public void Test_7563() + { + } + [Test] + public void Test_7564() + { + } + [Test] + public void Test_7565() + { + } + [Test] + public void Test_7566() + { + } + [Test] + public void Test_7567() + { + } + [Test] + public void Test_7568() + { + } + [Test] + public void Test_7569() + { + } + [Test] + public void Test_7570() + { + } + [Test] + public void Test_7571() + { + } + [Test] + public void Test_7572() + { + } + [Test] + public void Test_7573() + { + } + [Test] + public void Test_7574() + { + } + [Test] + public void Test_7575() + { + } + [Test] + public void Test_7576() + { + } + [Test] + public void Test_7577() + { + } + [Test] + public void Test_7578() + { + } + [Test] + public void Test_7579() + { + } + [Test] + public void Test_7580() + { + } + [Test] + public void Test_7581() + { + } + [Test] + public void Test_7582() + { + } + [Test] + public void Test_7583() + { + } + [Test] + public void Test_7584() + { + } + [Test] + public void Test_7585() + { + } + [Test] + public void Test_7586() + { + } + [Test] + public void Test_7587() + { + } + [Test] + public void Test_7588() + { + } + [Test] + public void Test_7589() + { + } + [Test] + public void Test_7590() + { + } + [Test] + public void Test_7591() + { + } + [Test] + public void Test_7592() + { + } + [Test] + public void Test_7593() + { + } + [Test] + public void Test_7594() + { + } + [Test] + public void Test_7595() + { + } + [Test] + public void Test_7596() + { + } + [Test] + public void Test_7597() + { + } + [Test] + public void Test_7598() + { + } + [Test] + public void Test_7599() + { + } + [Test] + public void Test_7600() + { + } + [Test] + public void Test_7601() + { + } + [Test] + public void Test_7602() + { + } + [Test] + public void Test_7603() + { + } + [Test] + public void Test_7604() + { + } + [Test] + public void Test_7605() + { + } + [Test] + public void Test_7606() + { + } + [Test] + public void Test_7607() + { + } + [Test] + public void Test_7608() + { + } + [Test] + public void Test_7609() + { + } + [Test] + public void Test_7610() + { + } + [Test] + public void Test_7611() + { + } + [Test] + public void Test_7612() + { + } + [Test] + public void Test_7613() + { + } + [Test] + public void Test_7614() + { + } + [Test] + public void Test_7615() + { + } + [Test] + public void Test_7616() + { + } + [Test] + public void Test_7617() + { + } + [Test] + public void Test_7618() + { + } + [Test] + public void Test_7619() + { + } + [Test] + public void Test_7620() + { + } + [Test] + public void Test_7621() + { + } + [Test] + public void Test_7622() + { + } + [Test] + public void Test_7623() + { + } + [Test] + public void Test_7624() + { + } + [Test] + public void Test_7625() + { + } + [Test] + public void Test_7626() + { + } + [Test] + public void Test_7627() + { + } + [Test] + public void Test_7628() + { + } + [Test] + public void Test_7629() + { + } + [Test] + public void Test_7630() + { + } + [Test] + public void Test_7631() + { + } + [Test] + public void Test_7632() + { + } + [Test] + public void Test_7633() + { + } + [Test] + public void Test_7634() + { + } + [Test] + public void Test_7635() + { + } + [Test] + public void Test_7636() + { + } + [Test] + public void Test_7637() + { + } + [Test] + public void Test_7638() + { + } + [Test] + public void Test_7639() + { + } + [Test] + public void Test_7640() + { + } + [Test] + public void Test_7641() + { + } + [Test] + public void Test_7642() + { + } + [Test] + public void Test_7643() + { + } + [Test] + public void Test_7644() + { + } + [Test] + public void Test_7645() + { + } + [Test] + public void Test_7646() + { + } + [Test] + public void Test_7647() + { + } + [Test] + public void Test_7648() + { + } + [Test] + public void Test_7649() + { + } + [Test] + public void Test_7650() + { + } + [Test] + public void Test_7651() + { + } + [Test] + public void Test_7652() + { + } + [Test] + public void Test_7653() + { + } + [Test] + public void Test_7654() + { + } + [Test] + public void Test_7655() + { + } + [Test] + public void Test_7656() + { + } + [Test] + public void Test_7657() + { + } + [Test] + public void Test_7658() + { + } + [Test] + public void Test_7659() + { + } + [Test] + public void Test_7660() + { + } + [Test] + public void Test_7661() + { + } + [Test] + public void Test_7662() + { + } + [Test] + public void Test_7663() + { + } + [Test] + public void Test_7664() + { + } + [Test] + public void Test_7665() + { + } + [Test] + public void Test_7666() + { + } + [Test] + public void Test_7667() + { + } + [Test] + public void Test_7668() + { + } + [Test] + public void Test_7669() + { + } + [Test] + public void Test_7670() + { + } + [Test] + public void Test_7671() + { + } + [Test] + public void Test_7672() + { + } + [Test] + public void Test_7673() + { + } + [Test] + public void Test_7674() + { + } + [Test] + public void Test_7675() + { + } + [Test] + public void Test_7676() + { + } + [Test] + public void Test_7677() + { + } + [Test] + public void Test_7678() + { + } + [Test] + public void Test_7679() + { + } + [Test] + public void Test_7680() + { + } + [Test] + public void Test_7681() + { + } + [Test] + public void Test_7682() + { + } + [Test] + public void Test_7683() + { + } + [Test] + public void Test_7684() + { + } + [Test] + public void Test_7685() + { + } + [Test] + public void Test_7686() + { + } + [Test] + public void Test_7687() + { + } + [Test] + public void Test_7688() + { + } + [Test] + public void Test_7689() + { + } + [Test] + public void Test_7690() + { + } + [Test] + public void Test_7691() + { + } + [Test] + public void Test_7692() + { + } + [Test] + public void Test_7693() + { + } + [Test] + public void Test_7694() + { + } + [Test] + public void Test_7695() + { + } + [Test] + public void Test_7696() + { + } + [Test] + public void Test_7697() + { + } + [Test] + public void Test_7698() + { + } + [Test] + public void Test_7699() + { + } + [Test] + public void Test_7700() + { + } + [Test] + public void Test_7701() + { + } + [Test] + public void Test_7702() + { + } + [Test] + public void Test_7703() + { + } + [Test] + public void Test_7704() + { + } + [Test] + public void Test_7705() + { + } + [Test] + public void Test_7706() + { + } + [Test] + public void Test_7707() + { + } + [Test] + public void Test_7708() + { + } + [Test] + public void Test_7709() + { + } + [Test] + public void Test_7710() + { + } + [Test] + public void Test_7711() + { + } + [Test] + public void Test_7712() + { + } + [Test] + public void Test_7713() + { + } + [Test] + public void Test_7714() + { + } + [Test] + public void Test_7715() + { + } + [Test] + public void Test_7716() + { + } + [Test] + public void Test_7717() + { + } + [Test] + public void Test_7718() + { + } + [Test] + public void Test_7719() + { + } + [Test] + public void Test_7720() + { + } + [Test] + public void Test_7721() + { + } + [Test] + public void Test_7722() + { + } + [Test] + public void Test_7723() + { + } + [Test] + public void Test_7724() + { + } + [Test] + public void Test_7725() + { + } + [Test] + public void Test_7726() + { + } + [Test] + public void Test_7727() + { + } + [Test] + public void Test_7728() + { + } + [Test] + public void Test_7729() + { + } + [Test] + public void Test_7730() + { + } + [Test] + public void Test_7731() + { + } + [Test] + public void Test_7732() + { + } + [Test] + public void Test_7733() + { + } + [Test] + public void Test_7734() + { + } + [Test] + public void Test_7735() + { + } + [Test] + public void Test_7736() + { + } + [Test] + public void Test_7737() + { + } + [Test] + public void Test_7738() + { + } + [Test] + public void Test_7739() + { + } + [Test] + public void Test_7740() + { + } + [Test] + public void Test_7741() + { + } + [Test] + public void Test_7742() + { + } + [Test] + public void Test_7743() + { + } + [Test] + public void Test_7744() + { + } + [Test] + public void Test_7745() + { + } + [Test] + public void Test_7746() + { + } + [Test] + public void Test_7747() + { + } + [Test] + public void Test_7748() + { + } + [Test] + public void Test_7749() + { + } + [Test] + public void Test_7750() + { + } + [Test] + public void Test_7751() + { + } + [Test] + public void Test_7752() + { + } + [Test] + public void Test_7753() + { + } + [Test] + public void Test_7754() + { + } + [Test] + public void Test_7755() + { + } + [Test] + public void Test_7756() + { + } + [Test] + public void Test_7757() + { + } + [Test] + public void Test_7758() + { + } + [Test] + public void Test_7759() + { + } + [Test] + public void Test_7760() + { + } + [Test] + public void Test_7761() + { + } + [Test] + public void Test_7762() + { + } + [Test] + public void Test_7763() + { + } + [Test] + public void Test_7764() + { + } + [Test] + public void Test_7765() + { + } + [Test] + public void Test_7766() + { + } + [Test] + public void Test_7767() + { + } + [Test] + public void Test_7768() + { + } + [Test] + public void Test_7769() + { + } + [Test] + public void Test_7770() + { + } + [Test] + public void Test_7771() + { + } + [Test] + public void Test_7772() + { + } + [Test] + public void Test_7773() + { + } + [Test] + public void Test_7774() + { + } + [Test] + public void Test_7775() + { + } + [Test] + public void Test_7776() + { + } + [Test] + public void Test_7777() + { + } + [Test] + public void Test_7778() + { + } + [Test] + public void Test_7779() + { + } + [Test] + public void Test_7780() + { + } + [Test] + public void Test_7781() + { + } + [Test] + public void Test_7782() + { + } + [Test] + public void Test_7783() + { + } + [Test] + public void Test_7784() + { + } + [Test] + public void Test_7785() + { + } + [Test] + public void Test_7786() + { + } + [Test] + public void Test_7787() + { + } + [Test] + public void Test_7788() + { + } + [Test] + public void Test_7789() + { + } + [Test] + public void Test_7790() + { + } + [Test] + public void Test_7791() + { + } + [Test] + public void Test_7792() + { + } + [Test] + public void Test_7793() + { + } + [Test] + public void Test_7794() + { + } + [Test] + public void Test_7795() + { + } + [Test] + public void Test_7796() + { + } + [Test] + public void Test_7797() + { + } + [Test] + public void Test_7798() + { + } + [Test] + public void Test_7799() + { + } + [Test] + public void Test_7800() + { + } + [Test] + public void Test_7801() + { + } + [Test] + public void Test_7802() + { + } + [Test] + public void Test_7803() + { + } + [Test] + public void Test_7804() + { + } + [Test] + public void Test_7805() + { + } + [Test] + public void Test_7806() + { + } + [Test] + public void Test_7807() + { + } + [Test] + public void Test_7808() + { + } + [Test] + public void Test_7809() + { + } + [Test] + public void Test_7810() + { + } + [Test] + public void Test_7811() + { + } + [Test] + public void Test_7812() + { + } + [Test] + public void Test_7813() + { + } + [Test] + public void Test_7814() + { + } + [Test] + public void Test_7815() + { + } + [Test] + public void Test_7816() + { + } + [Test] + public void Test_7817() + { + } + [Test] + public void Test_7818() + { + } + [Test] + public void Test_7819() + { + } + [Test] + public void Test_7820() + { + } + [Test] + public void Test_7821() + { + } + [Test] + public void Test_7822() + { + } + [Test] + public void Test_7823() + { + } + [Test] + public void Test_7824() + { + } + [Test] + public void Test_7825() + { + } + [Test] + public void Test_7826() + { + } + [Test] + public void Test_7827() + { + } + [Test] + public void Test_7828() + { + } + [Test] + public void Test_7829() + { + } + [Test] + public void Test_7830() + { + } + [Test] + public void Test_7831() + { + } + [Test] + public void Test_7832() + { + } + [Test] + public void Test_7833() + { + } + [Test] + public void Test_7834() + { + } + [Test] + public void Test_7835() + { + } + [Test] + public void Test_7836() + { + } + [Test] + public void Test_7837() + { + } + [Test] + public void Test_7838() + { + } + [Test] + public void Test_7839() + { + } + [Test] + public void Test_7840() + { + } + [Test] + public void Test_7841() + { + } + [Test] + public void Test_7842() + { + } + [Test] + public void Test_7843() + { + } + [Test] + public void Test_7844() + { + } + [Test] + public void Test_7845() + { + } + [Test] + public void Test_7846() + { + } + [Test] + public void Test_7847() + { + } + [Test] + public void Test_7848() + { + } + [Test] + public void Test_7849() + { + } + [Test] + public void Test_7850() + { + } + [Test] + public void Test_7851() + { + } + [Test] + public void Test_7852() + { + } + [Test] + public void Test_7853() + { + } + [Test] + public void Test_7854() + { + } + [Test] + public void Test_7855() + { + } + [Test] + public void Test_7856() + { + } + [Test] + public void Test_7857() + { + } + [Test] + public void Test_7858() + { + } + [Test] + public void Test_7859() + { + } + [Test] + public void Test_7860() + { + } + [Test] + public void Test_7861() + { + } + [Test] + public void Test_7862() + { + } + [Test] + public void Test_7863() + { + } + [Test] + public void Test_7864() + { + } + [Test] + public void Test_7865() + { + } + [Test] + public void Test_7866() + { + } + [Test] + public void Test_7867() + { + } + [Test] + public void Test_7868() + { + } + [Test] + public void Test_7869() + { + } + [Test] + public void Test_7870() + { + } + [Test] + public void Test_7871() + { + } + [Test] + public void Test_7872() + { + } + [Test] + public void Test_7873() + { + } + [Test] + public void Test_7874() + { + } + [Test] + public void Test_7875() + { + } + [Test] + public void Test_7876() + { + } + [Test] + public void Test_7877() + { + } + [Test] + public void Test_7878() + { + } + [Test] + public void Test_7879() + { + } + [Test] + public void Test_7880() + { + } + [Test] + public void Test_7881() + { + } + [Test] + public void Test_7882() + { + } + [Test] + public void Test_7883() + { + } + [Test] + public void Test_7884() + { + } + [Test] + public void Test_7885() + { + } + [Test] + public void Test_7886() + { + } + [Test] + public void Test_7887() + { + } + [Test] + public void Test_7888() + { + } + [Test] + public void Test_7889() + { + } + [Test] + public void Test_7890() + { + } + [Test] + public void Test_7891() + { + } + [Test] + public void Test_7892() + { + } + [Test] + public void Test_7893() + { + } + [Test] + public void Test_7894() + { + } + [Test] + public void Test_7895() + { + } + [Test] + public void Test_7896() + { + } + [Test] + public void Test_7897() + { + } + [Test] + public void Test_7898() + { + } + [Test] + public void Test_7899() + { + } + [Test] + public void Test_7900() + { + } + [Test] + public void Test_7901() + { + } + [Test] + public void Test_7902() + { + } + [Test] + public void Test_7903() + { + } + [Test] + public void Test_7904() + { + } + [Test] + public void Test_7905() + { + } + [Test] + public void Test_7906() + { + } + [Test] + public void Test_7907() + { + } + [Test] + public void Test_7908() + { + } + [Test] + public void Test_7909() + { + } + [Test] + public void Test_7910() + { + } + [Test] + public void Test_7911() + { + } + [Test] + public void Test_7912() + { + } + [Test] + public void Test_7913() + { + } + [Test] + public void Test_7914() + { + } + [Test] + public void Test_7915() + { + } + [Test] + public void Test_7916() + { + } + [Test] + public void Test_7917() + { + } + [Test] + public void Test_7918() + { + } + [Test] + public void Test_7919() + { + } + [Test] + public void Test_7920() + { + } + [Test] + public void Test_7921() + { + } + [Test] + public void Test_7922() + { + } + [Test] + public void Test_7923() + { + } + [Test] + public void Test_7924() + { + } + [Test] + public void Test_7925() + { + } + [Test] + public void Test_7926() + { + } + [Test] + public void Test_7927() + { + } + [Test] + public void Test_7928() + { + } + [Test] + public void Test_7929() + { + } + [Test] + public void Test_7930() + { + } + [Test] + public void Test_7931() + { + } + [Test] + public void Test_7932() + { + } + [Test] + public void Test_7933() + { + } + [Test] + public void Test_7934() + { + } + [Test] + public void Test_7935() + { + } + [Test] + public void Test_7936() + { + } + [Test] + public void Test_7937() + { + } + [Test] + public void Test_7938() + { + } + [Test] + public void Test_7939() + { + } + [Test] + public void Test_7940() + { + } + [Test] + public void Test_7941() + { + } + [Test] + public void Test_7942() + { + } + [Test] + public void Test_7943() + { + } + [Test] + public void Test_7944() + { + } + [Test] + public void Test_7945() + { + } + [Test] + public void Test_7946() + { + } + [Test] + public void Test_7947() + { + } + [Test] + public void Test_7948() + { + } + [Test] + public void Test_7949() + { + } + [Test] + public void Test_7950() + { + } + [Test] + public void Test_7951() + { + } + [Test] + public void Test_7952() + { + } + [Test] + public void Test_7953() + { + } + [Test] + public void Test_7954() + { + } + [Test] + public void Test_7955() + { + } + [Test] + public void Test_7956() + { + } + [Test] + public void Test_7957() + { + } + [Test] + public void Test_7958() + { + } + [Test] + public void Test_7959() + { + } + [Test] + public void Test_7960() + { + } + [Test] + public void Test_7961() + { + } + [Test] + public void Test_7962() + { + } + [Test] + public void Test_7963() + { + } + [Test] + public void Test_7964() + { + } + [Test] + public void Test_7965() + { + } + [Test] + public void Test_7966() + { + } + [Test] + public void Test_7967() + { + } + [Test] + public void Test_7968() + { + } + [Test] + public void Test_7969() + { + } + [Test] + public void Test_7970() + { + } + [Test] + public void Test_7971() + { + } + [Test] + public void Test_7972() + { + } + [Test] + public void Test_7973() + { + } + [Test] + public void Test_7974() + { + } + [Test] + public void Test_7975() + { + } + [Test] + public void Test_7976() + { + } + [Test] + public void Test_7977() + { + } + [Test] + public void Test_7978() + { + } + [Test] + public void Test_7979() + { + } + [Test] + public void Test_7980() + { + } + [Test] + public void Test_7981() + { + } + [Test] + public void Test_7982() + { + } + [Test] + public void Test_7983() + { + } + [Test] + public void Test_7984() + { + } + [Test] + public void Test_7985() + { + } + [Test] + public void Test_7986() + { + } + [Test] + public void Test_7987() + { + } + [Test] + public void Test_7988() + { + } + [Test] + public void Test_7989() + { + } + [Test] + public void Test_7990() + { + } + [Test] + public void Test_7991() + { + } + [Test] + public void Test_7992() + { + } + [Test] + public void Test_7993() + { + } + [Test] + public void Test_7994() + { + } + [Test] + public void Test_7995() + { + } + [Test] + public void Test_7996() + { + } + [Test] + public void Test_7997() + { + } + [Test] + public void Test_7998() + { + } + [Test] + public void Test_7999() + { + } + [Test] + public void Test_8000() + { + } + [Test] + public void Test_8001() + { + } + [Test] + public void Test_8002() + { + } + [Test] + public void Test_8003() + { + } + [Test] + public void Test_8004() + { + } + [Test] + public void Test_8005() + { + } + [Test] + public void Test_8006() + { + } + [Test] + public void Test_8007() + { + } + [Test] + public void Test_8008() + { + } + [Test] + public void Test_8009() + { + } + [Test] + public void Test_8010() + { + } + [Test] + public void Test_8011() + { + } + [Test] + public void Test_8012() + { + } + [Test] + public void Test_8013() + { + } + [Test] + public void Test_8014() + { + } + [Test] + public void Test_8015() + { + } + [Test] + public void Test_8016() + { + } + [Test] + public void Test_8017() + { + } + [Test] + public void Test_8018() + { + } + [Test] + public void Test_8019() + { + } + [Test] + public void Test_8020() + { + } + [Test] + public void Test_8021() + { + } + [Test] + public void Test_8022() + { + } + [Test] + public void Test_8023() + { + } + [Test] + public void Test_8024() + { + } + [Test] + public void Test_8025() + { + } + [Test] + public void Test_8026() + { + } + [Test] + public void Test_8027() + { + } + [Test] + public void Test_8028() + { + } + [Test] + public void Test_8029() + { + } + [Test] + public void Test_8030() + { + } + [Test] + public void Test_8031() + { + } + [Test] + public void Test_8032() + { + } + [Test] + public void Test_8033() + { + } + [Test] + public void Test_8034() + { + } + [Test] + public void Test_8035() + { + } + [Test] + public void Test_8036() + { + } + [Test] + public void Test_8037() + { + } + [Test] + public void Test_8038() + { + } + [Test] + public void Test_8039() + { + } + [Test] + public void Test_8040() + { + } + [Test] + public void Test_8041() + { + } + [Test] + public void Test_8042() + { + } + [Test] + public void Test_8043() + { + } + [Test] + public void Test_8044() + { + } + [Test] + public void Test_8045() + { + } + [Test] + public void Test_8046() + { + } + [Test] + public void Test_8047() + { + } + [Test] + public void Test_8048() + { + } + [Test] + public void Test_8049() + { + } + [Test] + public void Test_8050() + { + } + [Test] + public void Test_8051() + { + } + [Test] + public void Test_8052() + { + } + [Test] + public void Test_8053() + { + } + [Test] + public void Test_8054() + { + } + [Test] + public void Test_8055() + { + } + [Test] + public void Test_8056() + { + } + [Test] + public void Test_8057() + { + } + [Test] + public void Test_8058() + { + } + [Test] + public void Test_8059() + { + } + [Test] + public void Test_8060() + { + } + [Test] + public void Test_8061() + { + } + [Test] + public void Test_8062() + { + } + [Test] + public void Test_8063() + { + } + [Test] + public void Test_8064() + { + } + [Test] + public void Test_8065() + { + } + [Test] + public void Test_8066() + { + } + [Test] + public void Test_8067() + { + } + [Test] + public void Test_8068() + { + } + [Test] + public void Test_8069() + { + } + [Test] + public void Test_8070() + { + } + [Test] + public void Test_8071() + { + } + [Test] + public void Test_8072() + { + } + [Test] + public void Test_8073() + { + } + [Test] + public void Test_8074() + { + } + [Test] + public void Test_8075() + { + } + [Test] + public void Test_8076() + { + } + [Test] + public void Test_8077() + { + } + [Test] + public void Test_8078() + { + } + [Test] + public void Test_8079() + { + } + [Test] + public void Test_8080() + { + } + [Test] + public void Test_8081() + { + } + [Test] + public void Test_8082() + { + } + [Test] + public void Test_8083() + { + } + [Test] + public void Test_8084() + { + } + [Test] + public void Test_8085() + { + } + [Test] + public void Test_8086() + { + } + [Test] + public void Test_8087() + { + } + [Test] + public void Test_8088() + { + } + [Test] + public void Test_8089() + { + } + [Test] + public void Test_8090() + { + } + [Test] + public void Test_8091() + { + } + [Test] + public void Test_8092() + { + } + [Test] + public void Test_8093() + { + } + [Test] + public void Test_8094() + { + } + [Test] + public void Test_8095() + { + } + [Test] + public void Test_8096() + { + } + [Test] + public void Test_8097() + { + } + [Test] + public void Test_8098() + { + } + [Test] + public void Test_8099() + { + } + [Test] + public void Test_8100() + { + } + [Test] + public void Test_8101() + { + } + [Test] + public void Test_8102() + { + } + [Test] + public void Test_8103() + { + } + [Test] + public void Test_8104() + { + } + [Test] + public void Test_8105() + { + } + [Test] + public void Test_8106() + { + } + [Test] + public void Test_8107() + { + } + [Test] + public void Test_8108() + { + } + [Test] + public void Test_8109() + { + } + [Test] + public void Test_8110() + { + } + [Test] + public void Test_8111() + { + } + [Test] + public void Test_8112() + { + } + [Test] + public void Test_8113() + { + } + [Test] + public void Test_8114() + { + } + [Test] + public void Test_8115() + { + } + [Test] + public void Test_8116() + { + } + [Test] + public void Test_8117() + { + } + [Test] + public void Test_8118() + { + } + [Test] + public void Test_8119() + { + } + [Test] + public void Test_8120() + { + } + [Test] + public void Test_8121() + { + } + [Test] + public void Test_8122() + { + } + [Test] + public void Test_8123() + { + } + [Test] + public void Test_8124() + { + } + [Test] + public void Test_8125() + { + } + [Test] + public void Test_8126() + { + } + [Test] + public void Test_8127() + { + } + [Test] + public void Test_8128() + { + } + [Test] + public void Test_8129() + { + } + [Test] + public void Test_8130() + { + } + [Test] + public void Test_8131() + { + } + [Test] + public void Test_8132() + { + } + [Test] + public void Test_8133() + { + } + [Test] + public void Test_8134() + { + } + [Test] + public void Test_8135() + { + } + [Test] + public void Test_8136() + { + } + [Test] + public void Test_8137() + { + } + [Test] + public void Test_8138() + { + } + [Test] + public void Test_8139() + { + } + [Test] + public void Test_8140() + { + } + [Test] + public void Test_8141() + { + } + [Test] + public void Test_8142() + { + } + [Test] + public void Test_8143() + { + } + [Test] + public void Test_8144() + { + } + [Test] + public void Test_8145() + { + } + [Test] + public void Test_8146() + { + } + [Test] + public void Test_8147() + { + } + [Test] + public void Test_8148() + { + } + [Test] + public void Test_8149() + { + } + [Test] + public void Test_8150() + { + } + [Test] + public void Test_8151() + { + } + [Test] + public void Test_8152() + { + } + [Test] + public void Test_8153() + { + } + [Test] + public void Test_8154() + { + } + [Test] + public void Test_8155() + { + } + [Test] + public void Test_8156() + { + } + [Test] + public void Test_8157() + { + } + [Test] + public void Test_8158() + { + } + [Test] + public void Test_8159() + { + } + [Test] + public void Test_8160() + { + } + [Test] + public void Test_8161() + { + } + [Test] + public void Test_8162() + { + } + [Test] + public void Test_8163() + { + } + [Test] + public void Test_8164() + { + } + [Test] + public void Test_8165() + { + } + [Test] + public void Test_8166() + { + } + [Test] + public void Test_8167() + { + } + [Test] + public void Test_8168() + { + } + [Test] + public void Test_8169() + { + } + [Test] + public void Test_8170() + { + } + [Test] + public void Test_8171() + { + } + [Test] + public void Test_8172() + { + } + [Test] + public void Test_8173() + { + } + [Test] + public void Test_8174() + { + } + [Test] + public void Test_8175() + { + } + [Test] + public void Test_8176() + { + } + [Test] + public void Test_8177() + { + } + [Test] + public void Test_8178() + { + } + [Test] + public void Test_8179() + { + } + [Test] + public void Test_8180() + { + } + [Test] + public void Test_8181() + { + } + [Test] + public void Test_8182() + { + } + [Test] + public void Test_8183() + { + } + [Test] + public void Test_8184() + { + } + [Test] + public void Test_8185() + { + } + [Test] + public void Test_8186() + { + } + [Test] + public void Test_8187() + { + } + [Test] + public void Test_8188() + { + } + [Test] + public void Test_8189() + { + } + [Test] + public void Test_8190() + { + } + [Test] + public void Test_8191() + { + } + [Test] + public void Test_8192() + { + } + [Test] + public void Test_8193() + { + } + [Test] + public void Test_8194() + { + } + [Test] + public void Test_8195() + { + } + [Test] + public void Test_8196() + { + } + [Test] + public void Test_8197() + { + } + [Test] + public void Test_8198() + { + } + [Test] + public void Test_8199() + { + } + [Test] + public void Test_8200() + { + } + [Test] + public void Test_8201() + { + } + [Test] + public void Test_8202() + { + } + [Test] + public void Test_8203() + { + } + [Test] + public void Test_8204() + { + } + [Test] + public void Test_8205() + { + } + [Test] + public void Test_8206() + { + } + [Test] + public void Test_8207() + { + } + [Test] + public void Test_8208() + { + } + [Test] + public void Test_8209() + { + } + [Test] + public void Test_8210() + { + } + [Test] + public void Test_8211() + { + } + [Test] + public void Test_8212() + { + } + [Test] + public void Test_8213() + { + } + [Test] + public void Test_8214() + { + } + [Test] + public void Test_8215() + { + } + [Test] + public void Test_8216() + { + } + [Test] + public void Test_8217() + { + } + [Test] + public void Test_8218() + { + } + [Test] + public void Test_8219() + { + } + [Test] + public void Test_8220() + { + } + [Test] + public void Test_8221() + { + } + [Test] + public void Test_8222() + { + } + [Test] + public void Test_8223() + { + } + [Test] + public void Test_8224() + { + } + [Test] + public void Test_8225() + { + } + [Test] + public void Test_8226() + { + } + [Test] + public void Test_8227() + { + } + [Test] + public void Test_8228() + { + } + [Test] + public void Test_8229() + { + } + [Test] + public void Test_8230() + { + } + [Test] + public void Test_8231() + { + } + [Test] + public void Test_8232() + { + } + [Test] + public void Test_8233() + { + } + [Test] + public void Test_8234() + { + } + [Test] + public void Test_8235() + { + } + [Test] + public void Test_8236() + { + } + [Test] + public void Test_8237() + { + } + [Test] + public void Test_8238() + { + } + [Test] + public void Test_8239() + { + } + [Test] + public void Test_8240() + { + } + [Test] + public void Test_8241() + { + } + [Test] + public void Test_8242() + { + } + [Test] + public void Test_8243() + { + } + [Test] + public void Test_8244() + { + } + [Test] + public void Test_8245() + { + } + [Test] + public void Test_8246() + { + } + [Test] + public void Test_8247() + { + } + [Test] + public void Test_8248() + { + } + [Test] + public void Test_8249() + { + } + [Test] + public void Test_8250() + { + } + [Test] + public void Test_8251() + { + } + [Test] + public void Test_8252() + { + } + [Test] + public void Test_8253() + { + } + [Test] + public void Test_8254() + { + } + [Test] + public void Test_8255() + { + } + [Test] + public void Test_8256() + { + } + [Test] + public void Test_8257() + { + } + [Test] + public void Test_8258() + { + } + [Test] + public void Test_8259() + { + } + [Test] + public void Test_8260() + { + } + [Test] + public void Test_8261() + { + } + [Test] + public void Test_8262() + { + } + [Test] + public void Test_8263() + { + } + [Test] + public void Test_8264() + { + } + [Test] + public void Test_8265() + { + } + [Test] + public void Test_8266() + { + } + [Test] + public void Test_8267() + { + } + [Test] + public void Test_8268() + { + } + [Test] + public void Test_8269() + { + } + [Test] + public void Test_8270() + { + } + [Test] + public void Test_8271() + { + } + [Test] + public void Test_8272() + { + } + [Test] + public void Test_8273() + { + } + [Test] + public void Test_8274() + { + } + [Test] + public void Test_8275() + { + } + [Test] + public void Test_8276() + { + } + [Test] + public void Test_8277() + { + } + [Test] + public void Test_8278() + { + } + [Test] + public void Test_8279() + { + } + [Test] + public void Test_8280() + { + } + [Test] + public void Test_8281() + { + } + [Test] + public void Test_8282() + { + } + [Test] + public void Test_8283() + { + } + [Test] + public void Test_8284() + { + } + [Test] + public void Test_8285() + { + } + [Test] + public void Test_8286() + { + } + [Test] + public void Test_8287() + { + } + [Test] + public void Test_8288() + { + } + [Test] + public void Test_8289() + { + } + [Test] + public void Test_8290() + { + } + [Test] + public void Test_8291() + { + } + [Test] + public void Test_8292() + { + } + [Test] + public void Test_8293() + { + } + [Test] + public void Test_8294() + { + } + [Test] + public void Test_8295() + { + } + [Test] + public void Test_8296() + { + } + [Test] + public void Test_8297() + { + } + [Test] + public void Test_8298() + { + } + [Test] + public void Test_8299() + { + } + [Test] + public void Test_8300() + { + } + [Test] + public void Test_8301() + { + } + [Test] + public void Test_8302() + { + } + [Test] + public void Test_8303() + { + } + [Test] + public void Test_8304() + { + } + [Test] + public void Test_8305() + { + } + [Test] + public void Test_8306() + { + } + [Test] + public void Test_8307() + { + } + [Test] + public void Test_8308() + { + } + [Test] + public void Test_8309() + { + } + [Test] + public void Test_8310() + { + } + [Test] + public void Test_8311() + { + } + [Test] + public void Test_8312() + { + } + [Test] + public void Test_8313() + { + } + [Test] + public void Test_8314() + { + } + [Test] + public void Test_8315() + { + } + [Test] + public void Test_8316() + { + } + [Test] + public void Test_8317() + { + } + [Test] + public void Test_8318() + { + } + [Test] + public void Test_8319() + { + } + [Test] + public void Test_8320() + { + } + [Test] + public void Test_8321() + { + } + [Test] + public void Test_8322() + { + } + [Test] + public void Test_8323() + { + } + [Test] + public void Test_8324() + { + } + [Test] + public void Test_8325() + { + } + [Test] + public void Test_8326() + { + } + [Test] + public void Test_8327() + { + } + [Test] + public void Test_8328() + { + } + [Test] + public void Test_8329() + { + } + [Test] + public void Test_8330() + { + } + [Test] + public void Test_8331() + { + } + [Test] + public void Test_8332() + { + } + [Test] + public void Test_8333() + { + } + [Test] + public void Test_8334() + { + } + [Test] + public void Test_8335() + { + } + [Test] + public void Test_8336() + { + } + [Test] + public void Test_8337() + { + } + [Test] + public void Test_8338() + { + } + [Test] + public void Test_8339() + { + } + [Test] + public void Test_8340() + { + } + [Test] + public void Test_8341() + { + } + [Test] + public void Test_8342() + { + } + [Test] + public void Test_8343() + { + } + [Test] + public void Test_8344() + { + } + [Test] + public void Test_8345() + { + } + [Test] + public void Test_8346() + { + } + [Test] + public void Test_8347() + { + } + [Test] + public void Test_8348() + { + } + [Test] + public void Test_8349() + { + } + [Test] + public void Test_8350() + { + } + [Test] + public void Test_8351() + { + } + [Test] + public void Test_8352() + { + } + [Test] + public void Test_8353() + { + } + [Test] + public void Test_8354() + { + } + [Test] + public void Test_8355() + { + } + [Test] + public void Test_8356() + { + } + [Test] + public void Test_8357() + { + } + [Test] + public void Test_8358() + { + } + [Test] + public void Test_8359() + { + } + [Test] + public void Test_8360() + { + } + [Test] + public void Test_8361() + { + } + [Test] + public void Test_8362() + { + } + [Test] + public void Test_8363() + { + } + [Test] + public void Test_8364() + { + } + [Test] + public void Test_8365() + { + } + [Test] + public void Test_8366() + { + } + [Test] + public void Test_8367() + { + } + [Test] + public void Test_8368() + { + } + [Test] + public void Test_8369() + { + } + [Test] + public void Test_8370() + { + } + [Test] + public void Test_8371() + { + } + [Test] + public void Test_8372() + { + } + [Test] + public void Test_8373() + { + } + [Test] + public void Test_8374() + { + } + [Test] + public void Test_8375() + { + } + [Test] + public void Test_8376() + { + } + [Test] + public void Test_8377() + { + } + [Test] + public void Test_8378() + { + } + [Test] + public void Test_8379() + { + } + [Test] + public void Test_8380() + { + } + [Test] + public void Test_8381() + { + } + [Test] + public void Test_8382() + { + } + [Test] + public void Test_8383() + { + } + [Test] + public void Test_8384() + { + } + [Test] + public void Test_8385() + { + } + [Test] + public void Test_8386() + { + } + [Test] + public void Test_8387() + { + } + [Test] + public void Test_8388() + { + } + [Test] + public void Test_8389() + { + } + [Test] + public void Test_8390() + { + } + [Test] + public void Test_8391() + { + } + [Test] + public void Test_8392() + { + } + [Test] + public void Test_8393() + { + } + [Test] + public void Test_8394() + { + } + [Test] + public void Test_8395() + { + } + [Test] + public void Test_8396() + { + } + [Test] + public void Test_8397() + { + } + [Test] + public void Test_8398() + { + } + [Test] + public void Test_8399() + { + } + [Test] + public void Test_8400() + { + } + [Test] + public void Test_8401() + { + } + [Test] + public void Test_8402() + { + } + [Test] + public void Test_8403() + { + } + [Test] + public void Test_8404() + { + } + [Test] + public void Test_8405() + { + } + [Test] + public void Test_8406() + { + } + [Test] + public void Test_8407() + { + } + [Test] + public void Test_8408() + { + } + [Test] + public void Test_8409() + { + } + [Test] + public void Test_8410() + { + } + [Test] + public void Test_8411() + { + } + [Test] + public void Test_8412() + { + } + [Test] + public void Test_8413() + { + } + [Test] + public void Test_8414() + { + } + [Test] + public void Test_8415() + { + } + [Test] + public void Test_8416() + { + } + [Test] + public void Test_8417() + { + } + [Test] + public void Test_8418() + { + } + [Test] + public void Test_8419() + { + } + [Test] + public void Test_8420() + { + } + [Test] + public void Test_8421() + { + } + [Test] + public void Test_8422() + { + } + [Test] + public void Test_8423() + { + } + [Test] + public void Test_8424() + { + } + [Test] + public void Test_8425() + { + } + [Test] + public void Test_8426() + { + } + [Test] + public void Test_8427() + { + } + [Test] + public void Test_8428() + { + } + [Test] + public void Test_8429() + { + } + [Test] + public void Test_8430() + { + } + [Test] + public void Test_8431() + { + } + [Test] + public void Test_8432() + { + } + [Test] + public void Test_8433() + { + } + [Test] + public void Test_8434() + { + } + [Test] + public void Test_8435() + { + } + [Test] + public void Test_8436() + { + } + [Test] + public void Test_8437() + { + } + [Test] + public void Test_8438() + { + } + [Test] + public void Test_8439() + { + } + [Test] + public void Test_8440() + { + } + [Test] + public void Test_8441() + { + } + [Test] + public void Test_8442() + { + } + [Test] + public void Test_8443() + { + } + [Test] + public void Test_8444() + { + } + [Test] + public void Test_8445() + { + } + [Test] + public void Test_8446() + { + } + [Test] + public void Test_8447() + { + } + [Test] + public void Test_8448() + { + } + [Test] + public void Test_8449() + { + } + [Test] + public void Test_8450() + { + } + [Test] + public void Test_8451() + { + } + [Test] + public void Test_8452() + { + } + [Test] + public void Test_8453() + { + } + [Test] + public void Test_8454() + { + } + [Test] + public void Test_8455() + { + } + [Test] + public void Test_8456() + { + } + [Test] + public void Test_8457() + { + } + [Test] + public void Test_8458() + { + } + [Test] + public void Test_8459() + { + } + [Test] + public void Test_8460() + { + } + [Test] + public void Test_8461() + { + } + [Test] + public void Test_8462() + { + } + [Test] + public void Test_8463() + { + } + [Test] + public void Test_8464() + { + } + [Test] + public void Test_8465() + { + } + [Test] + public void Test_8466() + { + } + [Test] + public void Test_8467() + { + } + [Test] + public void Test_8468() + { + } + [Test] + public void Test_8469() + { + } + [Test] + public void Test_8470() + { + } + [Test] + public void Test_8471() + { + } + [Test] + public void Test_8472() + { + } + [Test] + public void Test_8473() + { + } + [Test] + public void Test_8474() + { + } + [Test] + public void Test_8475() + { + } + [Test] + public void Test_8476() + { + } + [Test] + public void Test_8477() + { + } + [Test] + public void Test_8478() + { + } + [Test] + public void Test_8479() + { + } + [Test] + public void Test_8480() + { + } + [Test] + public void Test_8481() + { + } + [Test] + public void Test_8482() + { + } + [Test] + public void Test_8483() + { + } + [Test] + public void Test_8484() + { + } + [Test] + public void Test_8485() + { + } + [Test] + public void Test_8486() + { + } + [Test] + public void Test_8487() + { + } + [Test] + public void Test_8488() + { + } + [Test] + public void Test_8489() + { + } + [Test] + public void Test_8490() + { + } + [Test] + public void Test_8491() + { + } + [Test] + public void Test_8492() + { + } + [Test] + public void Test_8493() + { + } + [Test] + public void Test_8494() + { + } + [Test] + public void Test_8495() + { + } + [Test] + public void Test_8496() + { + } + [Test] + public void Test_8497() + { + } + [Test] + public void Test_8498() + { + } + [Test] + public void Test_8499() + { + } + [Test] + public void Test_8500() + { + } + [Test] + public void Test_8501() + { + } + [Test] + public void Test_8502() + { + } + [Test] + public void Test_8503() + { + } + [Test] + public void Test_8504() + { + } + [Test] + public void Test_8505() + { + } + [Test] + public void Test_8506() + { + } + [Test] + public void Test_8507() + { + } + [Test] + public void Test_8508() + { + } + [Test] + public void Test_8509() + { + } + [Test] + public void Test_8510() + { + } + [Test] + public void Test_8511() + { + } + [Test] + public void Test_8512() + { + } + [Test] + public void Test_8513() + { + } + [Test] + public void Test_8514() + { + } + [Test] + public void Test_8515() + { + } + [Test] + public void Test_8516() + { + } + [Test] + public void Test_8517() + { + } + [Test] + public void Test_8518() + { + } + [Test] + public void Test_8519() + { + } + [Test] + public void Test_8520() + { + } + [Test] + public void Test_8521() + { + } + [Test] + public void Test_8522() + { + } + [Test] + public void Test_8523() + { + } + [Test] + public void Test_8524() + { + } + [Test] + public void Test_8525() + { + } + [Test] + public void Test_8526() + { + } + [Test] + public void Test_8527() + { + } + [Test] + public void Test_8528() + { + } + [Test] + public void Test_8529() + { + } + [Test] + public void Test_8530() + { + } + [Test] + public void Test_8531() + { + } + [Test] + public void Test_8532() + { + } + [Test] + public void Test_8533() + { + } + [Test] + public void Test_8534() + { + } + [Test] + public void Test_8535() + { + } + [Test] + public void Test_8536() + { + } + [Test] + public void Test_8537() + { + } + [Test] + public void Test_8538() + { + } + [Test] + public void Test_8539() + { + } + [Test] + public void Test_8540() + { + } + [Test] + public void Test_8541() + { + } + [Test] + public void Test_8542() + { + } + [Test] + public void Test_8543() + { + } + [Test] + public void Test_8544() + { + } + [Test] + public void Test_8545() + { + } + [Test] + public void Test_8546() + { + } + [Test] + public void Test_8547() + { + } + [Test] + public void Test_8548() + { + } + [Test] + public void Test_8549() + { + } + [Test] + public void Test_8550() + { + } + [Test] + public void Test_8551() + { + } + [Test] + public void Test_8552() + { + } + [Test] + public void Test_8553() + { + } + [Test] + public void Test_8554() + { + } + [Test] + public void Test_8555() + { + } + [Test] + public void Test_8556() + { + } + [Test] + public void Test_8557() + { + } + [Test] + public void Test_8558() + { + } + [Test] + public void Test_8559() + { + } + [Test] + public void Test_8560() + { + } + [Test] + public void Test_8561() + { + } + [Test] + public void Test_8562() + { + } + [Test] + public void Test_8563() + { + } + [Test] + public void Test_8564() + { + } + [Test] + public void Test_8565() + { + } + [Test] + public void Test_8566() + { + } + [Test] + public void Test_8567() + { + } + [Test] + public void Test_8568() + { + } + [Test] + public void Test_8569() + { + } + [Test] + public void Test_8570() + { + } + [Test] + public void Test_8571() + { + } + [Test] + public void Test_8572() + { + } + [Test] + public void Test_8573() + { + } + [Test] + public void Test_8574() + { + } + [Test] + public void Test_8575() + { + } + [Test] + public void Test_8576() + { + } + [Test] + public void Test_8577() + { + } + [Test] + public void Test_8578() + { + } + [Test] + public void Test_8579() + { + } + [Test] + public void Test_8580() + { + } + [Test] + public void Test_8581() + { + } + [Test] + public void Test_8582() + { + } + [Test] + public void Test_8583() + { + } + [Test] + public void Test_8584() + { + } + [Test] + public void Test_8585() + { + } + [Test] + public void Test_8586() + { + } + [Test] + public void Test_8587() + { + } + [Test] + public void Test_8588() + { + } + [Test] + public void Test_8589() + { + } + [Test] + public void Test_8590() + { + } + [Test] + public void Test_8591() + { + } + [Test] + public void Test_8592() + { + } + [Test] + public void Test_8593() + { + } + [Test] + public void Test_8594() + { + } + [Test] + public void Test_8595() + { + } + [Test] + public void Test_8596() + { + } + [Test] + public void Test_8597() + { + } + [Test] + public void Test_8598() + { + } + [Test] + public void Test_8599() + { + } + [Test] + public void Test_8600() + { + } + [Test] + public void Test_8601() + { + } + [Test] + public void Test_8602() + { + } + [Test] + public void Test_8603() + { + } + [Test] + public void Test_8604() + { + } + [Test] + public void Test_8605() + { + } + [Test] + public void Test_8606() + { + } + [Test] + public void Test_8607() + { + } + [Test] + public void Test_8608() + { + } + [Test] + public void Test_8609() + { + } + [Test] + public void Test_8610() + { + } + [Test] + public void Test_8611() + { + } + [Test] + public void Test_8612() + { + } + [Test] + public void Test_8613() + { + } + [Test] + public void Test_8614() + { + } + [Test] + public void Test_8615() + { + } + [Test] + public void Test_8616() + { + } + [Test] + public void Test_8617() + { + } + [Test] + public void Test_8618() + { + } + [Test] + public void Test_8619() + { + } + [Test] + public void Test_8620() + { + } + [Test] + public void Test_8621() + { + } + [Test] + public void Test_8622() + { + } + [Test] + public void Test_8623() + { + } + [Test] + public void Test_8624() + { + } + [Test] + public void Test_8625() + { + } + [Test] + public void Test_8626() + { + } + [Test] + public void Test_8627() + { + } + [Test] + public void Test_8628() + { + } + [Test] + public void Test_8629() + { + } + [Test] + public void Test_8630() + { + } + [Test] + public void Test_8631() + { + } + [Test] + public void Test_8632() + { + } + [Test] + public void Test_8633() + { + } + [Test] + public void Test_8634() + { + } + [Test] + public void Test_8635() + { + } + [Test] + public void Test_8636() + { + } + [Test] + public void Test_8637() + { + } + [Test] + public void Test_8638() + { + } + [Test] + public void Test_8639() + { + } + [Test] + public void Test_8640() + { + } + [Test] + public void Test_8641() + { + } + [Test] + public void Test_8642() + { + } + [Test] + public void Test_8643() + { + } + [Test] + public void Test_8644() + { + } + [Test] + public void Test_8645() + { + } + [Test] + public void Test_8646() + { + } + [Test] + public void Test_8647() + { + } + [Test] + public void Test_8648() + { + } + [Test] + public void Test_8649() + { + } + [Test] + public void Test_8650() + { + } + [Test] + public void Test_8651() + { + } + [Test] + public void Test_8652() + { + } + [Test] + public void Test_8653() + { + } + [Test] + public void Test_8654() + { + } + [Test] + public void Test_8655() + { + } + [Test] + public void Test_8656() + { + } + [Test] + public void Test_8657() + { + } + [Test] + public void Test_8658() + { + } + [Test] + public void Test_8659() + { + } + [Test] + public void Test_8660() + { + } + [Test] + public void Test_8661() + { + } + [Test] + public void Test_8662() + { + } + [Test] + public void Test_8663() + { + } + [Test] + public void Test_8664() + { + } + [Test] + public void Test_8665() + { + } + [Test] + public void Test_8666() + { + } + [Test] + public void Test_8667() + { + } + [Test] + public void Test_8668() + { + } + [Test] + public void Test_8669() + { + } + [Test] + public void Test_8670() + { + } + [Test] + public void Test_8671() + { + } + [Test] + public void Test_8672() + { + } + [Test] + public void Test_8673() + { + } + [Test] + public void Test_8674() + { + } + [Test] + public void Test_8675() + { + } + [Test] + public void Test_8676() + { + } + [Test] + public void Test_8677() + { + } + [Test] + public void Test_8678() + { + } + [Test] + public void Test_8679() + { + } + [Test] + public void Test_8680() + { + } + [Test] + public void Test_8681() + { + } + [Test] + public void Test_8682() + { + } + [Test] + public void Test_8683() + { + } + [Test] + public void Test_8684() + { + } + [Test] + public void Test_8685() + { + } + [Test] + public void Test_8686() + { + } + [Test] + public void Test_8687() + { + } + [Test] + public void Test_8688() + { + } + [Test] + public void Test_8689() + { + } + [Test] + public void Test_8690() + { + } + [Test] + public void Test_8691() + { + } + [Test] + public void Test_8692() + { + } + [Test] + public void Test_8693() + { + } + [Test] + public void Test_8694() + { + } + [Test] + public void Test_8695() + { + } + [Test] + public void Test_8696() + { + } + [Test] + public void Test_8697() + { + } + [Test] + public void Test_8698() + { + } + [Test] + public void Test_8699() + { + } + [Test] + public void Test_8700() + { + } + [Test] + public void Test_8701() + { + } + [Test] + public void Test_8702() + { + } + [Test] + public void Test_8703() + { + } + [Test] + public void Test_8704() + { + } + [Test] + public void Test_8705() + { + } + [Test] + public void Test_8706() + { + } + [Test] + public void Test_8707() + { + } + [Test] + public void Test_8708() + { + } + [Test] + public void Test_8709() + { + } + [Test] + public void Test_8710() + { + } + [Test] + public void Test_8711() + { + } + [Test] + public void Test_8712() + { + } + [Test] + public void Test_8713() + { + } + [Test] + public void Test_8714() + { + } + [Test] + public void Test_8715() + { + } + [Test] + public void Test_8716() + { + } + [Test] + public void Test_8717() + { + } + [Test] + public void Test_8718() + { + } + [Test] + public void Test_8719() + { + } + [Test] + public void Test_8720() + { + } + [Test] + public void Test_8721() + { + } + [Test] + public void Test_8722() + { + } + [Test] + public void Test_8723() + { + } + [Test] + public void Test_8724() + { + } + [Test] + public void Test_8725() + { + } + [Test] + public void Test_8726() + { + } + [Test] + public void Test_8727() + { + } + [Test] + public void Test_8728() + { + } + [Test] + public void Test_8729() + { + } + [Test] + public void Test_8730() + { + } + [Test] + public void Test_8731() + { + } + [Test] + public void Test_8732() + { + } + [Test] + public void Test_8733() + { + } + [Test] + public void Test_8734() + { + } + [Test] + public void Test_8735() + { + } + [Test] + public void Test_8736() + { + } + [Test] + public void Test_8737() + { + } + [Test] + public void Test_8738() + { + } + [Test] + public void Test_8739() + { + } + [Test] + public void Test_8740() + { + } + [Test] + public void Test_8741() + { + } + [Test] + public void Test_8742() + { + } + [Test] + public void Test_8743() + { + } + [Test] + public void Test_8744() + { + } + [Test] + public void Test_8745() + { + } + [Test] + public void Test_8746() + { + } + [Test] + public void Test_8747() + { + } + [Test] + public void Test_8748() + { + } + [Test] + public void Test_8749() + { + } + [Test] + public void Test_8750() + { + } + [Test] + public void Test_8751() + { + } + [Test] + public void Test_8752() + { + } + [Test] + public void Test_8753() + { + } + [Test] + public void Test_8754() + { + } + [Test] + public void Test_8755() + { + } + [Test] + public void Test_8756() + { + } + [Test] + public void Test_8757() + { + } + [Test] + public void Test_8758() + { + } + [Test] + public void Test_8759() + { + } + [Test] + public void Test_8760() + { + } + [Test] + public void Test_8761() + { + } + [Test] + public void Test_8762() + { + } + [Test] + public void Test_8763() + { + } + [Test] + public void Test_8764() + { + } + [Test] + public void Test_8765() + { + } + [Test] + public void Test_8766() + { + } + [Test] + public void Test_8767() + { + } + [Test] + public void Test_8768() + { + } + [Test] + public void Test_8769() + { + } + [Test] + public void Test_8770() + { + } + [Test] + public void Test_8771() + { + } + [Test] + public void Test_8772() + { + } + [Test] + public void Test_8773() + { + } + [Test] + public void Test_8774() + { + } + [Test] + public void Test_8775() + { + } + [Test] + public void Test_8776() + { + } + [Test] + public void Test_8777() + { + } + [Test] + public void Test_8778() + { + } + [Test] + public void Test_8779() + { + } + [Test] + public void Test_8780() + { + } + [Test] + public void Test_8781() + { + } + [Test] + public void Test_8782() + { + } + [Test] + public void Test_8783() + { + } + [Test] + public void Test_8784() + { + } + [Test] + public void Test_8785() + { + } + [Test] + public void Test_8786() + { + } + [Test] + public void Test_8787() + { + } + [Test] + public void Test_8788() + { + } + [Test] + public void Test_8789() + { + } + [Test] + public void Test_8790() + { + } + [Test] + public void Test_8791() + { + } + [Test] + public void Test_8792() + { + } + [Test] + public void Test_8793() + { + } + [Test] + public void Test_8794() + { + } + [Test] + public void Test_8795() + { + } + [Test] + public void Test_8796() + { + } + [Test] + public void Test_8797() + { + } + [Test] + public void Test_8798() + { + } + [Test] + public void Test_8799() + { + } + [Test] + public void Test_8800() + { + } + [Test] + public void Test_8801() + { + } + [Test] + public void Test_8802() + { + } + [Test] + public void Test_8803() + { + } + [Test] + public void Test_8804() + { + } + [Test] + public void Test_8805() + { + } + [Test] + public void Test_8806() + { + } + [Test] + public void Test_8807() + { + } + [Test] + public void Test_8808() + { + } + [Test] + public void Test_8809() + { + } + [Test] + public void Test_8810() + { + } + [Test] + public void Test_8811() + { + } + [Test] + public void Test_8812() + { + } + [Test] + public void Test_8813() + { + } + [Test] + public void Test_8814() + { + } + [Test] + public void Test_8815() + { + } + [Test] + public void Test_8816() + { + } + [Test] + public void Test_8817() + { + } + [Test] + public void Test_8818() + { + } + [Test] + public void Test_8819() + { + } + [Test] + public void Test_8820() + { + } + [Test] + public void Test_8821() + { + } + [Test] + public void Test_8822() + { + } + [Test] + public void Test_8823() + { + } + [Test] + public void Test_8824() + { + } + [Test] + public void Test_8825() + { + } + [Test] + public void Test_8826() + { + } + [Test] + public void Test_8827() + { + } + [Test] + public void Test_8828() + { + } + [Test] + public void Test_8829() + { + } + [Test] + public void Test_8830() + { + } + [Test] + public void Test_8831() + { + } + [Test] + public void Test_8832() + { + } + [Test] + public void Test_8833() + { + } + [Test] + public void Test_8834() + { + } + [Test] + public void Test_8835() + { + } + [Test] + public void Test_8836() + { + } + [Test] + public void Test_8837() + { + } + [Test] + public void Test_8838() + { + } + [Test] + public void Test_8839() + { + } + [Test] + public void Test_8840() + { + } + [Test] + public void Test_8841() + { + } + [Test] + public void Test_8842() + { + } + [Test] + public void Test_8843() + { + } + [Test] + public void Test_8844() + { + } + [Test] + public void Test_8845() + { + } + [Test] + public void Test_8846() + { + } + [Test] + public void Test_8847() + { + } + [Test] + public void Test_8848() + { + } + [Test] + public void Test_8849() + { + } + [Test] + public void Test_8850() + { + } + [Test] + public void Test_8851() + { + } + [Test] + public void Test_8852() + { + } + [Test] + public void Test_8853() + { + } + [Test] + public void Test_8854() + { + } + [Test] + public void Test_8855() + { + } + [Test] + public void Test_8856() + { + } + [Test] + public void Test_8857() + { + } + [Test] + public void Test_8858() + { + } + [Test] + public void Test_8859() + { + } + [Test] + public void Test_8860() + { + } + [Test] + public void Test_8861() + { + } + [Test] + public void Test_8862() + { + } + [Test] + public void Test_8863() + { + } + [Test] + public void Test_8864() + { + } + [Test] + public void Test_8865() + { + } + [Test] + public void Test_8866() + { + } + [Test] + public void Test_8867() + { + } + [Test] + public void Test_8868() + { + } + [Test] + public void Test_8869() + { + } + [Test] + public void Test_8870() + { + } + [Test] + public void Test_8871() + { + } + [Test] + public void Test_8872() + { + } + [Test] + public void Test_8873() + { + } + [Test] + public void Test_8874() + { + } + [Test] + public void Test_8875() + { + } + [Test] + public void Test_8876() + { + } + [Test] + public void Test_8877() + { + } + [Test] + public void Test_8878() + { + } + [Test] + public void Test_8879() + { + } + [Test] + public void Test_8880() + { + } + [Test] + public void Test_8881() + { + } + [Test] + public void Test_8882() + { + } + [Test] + public void Test_8883() + { + } + [Test] + public void Test_8884() + { + } + [Test] + public void Test_8885() + { + } + [Test] + public void Test_8886() + { + } + [Test] + public void Test_8887() + { + } + [Test] + public void Test_8888() + { + } + [Test] + public void Test_8889() + { + } + [Test] + public void Test_8890() + { + } + [Test] + public void Test_8891() + { + } + [Test] + public void Test_8892() + { + } + [Test] + public void Test_8893() + { + } + [Test] + public void Test_8894() + { + } + [Test] + public void Test_8895() + { + } + [Test] + public void Test_8896() + { + } + [Test] + public void Test_8897() + { + } + [Test] + public void Test_8898() + { + } + [Test] + public void Test_8899() + { + } + [Test] + public void Test_8900() + { + } + [Test] + public void Test_8901() + { + } + [Test] + public void Test_8902() + { + } + [Test] + public void Test_8903() + { + } + [Test] + public void Test_8904() + { + } + [Test] + public void Test_8905() + { + } + [Test] + public void Test_8906() + { + } + [Test] + public void Test_8907() + { + } + [Test] + public void Test_8908() + { + } + [Test] + public void Test_8909() + { + } + [Test] + public void Test_8910() + { + } + [Test] + public void Test_8911() + { + } + [Test] + public void Test_8912() + { + } + [Test] + public void Test_8913() + { + } + [Test] + public void Test_8914() + { + } + [Test] + public void Test_8915() + { + } + [Test] + public void Test_8916() + { + } + [Test] + public void Test_8917() + { + } + [Test] + public void Test_8918() + { + } + [Test] + public void Test_8919() + { + } + [Test] + public void Test_8920() + { + } + [Test] + public void Test_8921() + { + } + [Test] + public void Test_8922() + { + } + [Test] + public void Test_8923() + { + } + [Test] + public void Test_8924() + { + } + [Test] + public void Test_8925() + { + } + [Test] + public void Test_8926() + { + } + [Test] + public void Test_8927() + { + } + [Test] + public void Test_8928() + { + } + [Test] + public void Test_8929() + { + } + [Test] + public void Test_8930() + { + } + [Test] + public void Test_8931() + { + } + [Test] + public void Test_8932() + { + } + [Test] + public void Test_8933() + { + } + [Test] + public void Test_8934() + { + } + [Test] + public void Test_8935() + { + } + [Test] + public void Test_8936() + { + } + [Test] + public void Test_8937() + { + } + [Test] + public void Test_8938() + { + } + [Test] + public void Test_8939() + { + } + [Test] + public void Test_8940() + { + } + [Test] + public void Test_8941() + { + } + [Test] + public void Test_8942() + { + } + [Test] + public void Test_8943() + { + } + [Test] + public void Test_8944() + { + } + [Test] + public void Test_8945() + { + } + [Test] + public void Test_8946() + { + } + [Test] + public void Test_8947() + { + } + [Test] + public void Test_8948() + { + } + [Test] + public void Test_8949() + { + } + [Test] + public void Test_8950() + { + } + [Test] + public void Test_8951() + { + } + [Test] + public void Test_8952() + { + } + [Test] + public void Test_8953() + { + } + [Test] + public void Test_8954() + { + } + [Test] + public void Test_8955() + { + } + [Test] + public void Test_8956() + { + } + [Test] + public void Test_8957() + { + } + [Test] + public void Test_8958() + { + } + [Test] + public void Test_8959() + { + } + [Test] + public void Test_8960() + { + } + [Test] + public void Test_8961() + { + } + [Test] + public void Test_8962() + { + } + [Test] + public void Test_8963() + { + } + [Test] + public void Test_8964() + { + } + [Test] + public void Test_8965() + { + } + [Test] + public void Test_8966() + { + } + [Test] + public void Test_8967() + { + } + [Test] + public void Test_8968() + { + } + [Test] + public void Test_8969() + { + } + [Test] + public void Test_8970() + { + } + [Test] + public void Test_8971() + { + } + [Test] + public void Test_8972() + { + } + [Test] + public void Test_8973() + { + } + [Test] + public void Test_8974() + { + } + [Test] + public void Test_8975() + { + } + [Test] + public void Test_8976() + { + } + [Test] + public void Test_8977() + { + } + [Test] + public void Test_8978() + { + } + [Test] + public void Test_8979() + { + } + [Test] + public void Test_8980() + { + } + [Test] + public void Test_8981() + { + } + [Test] + public void Test_8982() + { + } + [Test] + public void Test_8983() + { + } + [Test] + public void Test_8984() + { + } + [Test] + public void Test_8985() + { + } + [Test] + public void Test_8986() + { + } + [Test] + public void Test_8987() + { + } + [Test] + public void Test_8988() + { + } + [Test] + public void Test_8989() + { + } + [Test] + public void Test_8990() + { + } + [Test] + public void Test_8991() + { + } + [Test] + public void Test_8992() + { + } + [Test] + public void Test_8993() + { + } + [Test] + public void Test_8994() + { + } + [Test] + public void Test_8995() + { + } + [Test] + public void Test_8996() + { + } + [Test] + public void Test_8997() + { + } + [Test] + public void Test_8998() + { + } + [Test] + public void Test_8999() + { + } + [Test] + public void Test_9000() + { + } + [Test] + public void Test_9001() + { + } + [Test] + public void Test_9002() + { + } + [Test] + public void Test_9003() + { + } + [Test] + public void Test_9004() + { + } + [Test] + public void Test_9005() + { + } + [Test] + public void Test_9006() + { + } + [Test] + public void Test_9007() + { + } + [Test] + public void Test_9008() + { + } + [Test] + public void Test_9009() + { + } + [Test] + public void Test_9010() + { + } + [Test] + public void Test_9011() + { + } + [Test] + public void Test_9012() + { + } + [Test] + public void Test_9013() + { + } + [Test] + public void Test_9014() + { + } + [Test] + public void Test_9015() + { + } + [Test] + public void Test_9016() + { + } + [Test] + public void Test_9017() + { + } + [Test] + public void Test_9018() + { + } + [Test] + public void Test_9019() + { + } + [Test] + public void Test_9020() + { + } + [Test] + public void Test_9021() + { + } + [Test] + public void Test_9022() + { + } + [Test] + public void Test_9023() + { + } + [Test] + public void Test_9024() + { + } + [Test] + public void Test_9025() + { + } + [Test] + public void Test_9026() + { + } + [Test] + public void Test_9027() + { + } + [Test] + public void Test_9028() + { + } + [Test] + public void Test_9029() + { + } + [Test] + public void Test_9030() + { + } + [Test] + public void Test_9031() + { + } + [Test] + public void Test_9032() + { + } + [Test] + public void Test_9033() + { + } + [Test] + public void Test_9034() + { + } + [Test] + public void Test_9035() + { + } + [Test] + public void Test_9036() + { + } + [Test] + public void Test_9037() + { + } + [Test] + public void Test_9038() + { + } + [Test] + public void Test_9039() + { + } + [Test] + public void Test_9040() + { + } + [Test] + public void Test_9041() + { + } + [Test] + public void Test_9042() + { + } + [Test] + public void Test_9043() + { + } + [Test] + public void Test_9044() + { + } + [Test] + public void Test_9045() + { + } + [Test] + public void Test_9046() + { + } + [Test] + public void Test_9047() + { + } + [Test] + public void Test_9048() + { + } + [Test] + public void Test_9049() + { + } + [Test] + public void Test_9050() + { + } + [Test] + public void Test_9051() + { + } + [Test] + public void Test_9052() + { + } + [Test] + public void Test_9053() + { + } + [Test] + public void Test_9054() + { + } + [Test] + public void Test_9055() + { + } + [Test] + public void Test_9056() + { + } + [Test] + public void Test_9057() + { + } + [Test] + public void Test_9058() + { + } + [Test] + public void Test_9059() + { + } + [Test] + public void Test_9060() + { + } + [Test] + public void Test_9061() + { + } + [Test] + public void Test_9062() + { + } + [Test] + public void Test_9063() + { + } + [Test] + public void Test_9064() + { + } + [Test] + public void Test_9065() + { + } + [Test] + public void Test_9066() + { + } + [Test] + public void Test_9067() + { + } + [Test] + public void Test_9068() + { + } + [Test] + public void Test_9069() + { + } + [Test] + public void Test_9070() + { + } + [Test] + public void Test_9071() + { + } + [Test] + public void Test_9072() + { + } + [Test] + public void Test_9073() + { + } + [Test] + public void Test_9074() + { + } + [Test] + public void Test_9075() + { + } + [Test] + public void Test_9076() + { + } + [Test] + public void Test_9077() + { + } + [Test] + public void Test_9078() + { + } + [Test] + public void Test_9079() + { + } + [Test] + public void Test_9080() + { + } + [Test] + public void Test_9081() + { + } + [Test] + public void Test_9082() + { + } + [Test] + public void Test_9083() + { + } + [Test] + public void Test_9084() + { + } + [Test] + public void Test_9085() + { + } + [Test] + public void Test_9086() + { + } + [Test] + public void Test_9087() + { + } + [Test] + public void Test_9088() + { + } + [Test] + public void Test_9089() + { + } + [Test] + public void Test_9090() + { + } + [Test] + public void Test_9091() + { + } + [Test] + public void Test_9092() + { + } + [Test] + public void Test_9093() + { + } + [Test] + public void Test_9094() + { + } + [Test] + public void Test_9095() + { + } + [Test] + public void Test_9096() + { + } + [Test] + public void Test_9097() + { + } + [Test] + public void Test_9098() + { + } + [Test] + public void Test_9099() + { + } + [Test] + public void Test_9100() + { + } + [Test] + public void Test_9101() + { + } + [Test] + public void Test_9102() + { + } + [Test] + public void Test_9103() + { + } + [Test] + public void Test_9104() + { + } + [Test] + public void Test_9105() + { + } + [Test] + public void Test_9106() + { + } + [Test] + public void Test_9107() + { + } + [Test] + public void Test_9108() + { + } + [Test] + public void Test_9109() + { + } + [Test] + public void Test_9110() + { + } + [Test] + public void Test_9111() + { + } + [Test] + public void Test_9112() + { + } + [Test] + public void Test_9113() + { + } + [Test] + public void Test_9114() + { + } + [Test] + public void Test_9115() + { + } + [Test] + public void Test_9116() + { + } + [Test] + public void Test_9117() + { + } + [Test] + public void Test_9118() + { + } + [Test] + public void Test_9119() + { + } + [Test] + public void Test_9120() + { + } + [Test] + public void Test_9121() + { + } + [Test] + public void Test_9122() + { + } + [Test] + public void Test_9123() + { + } + [Test] + public void Test_9124() + { + } + [Test] + public void Test_9125() + { + } + [Test] + public void Test_9126() + { + } + [Test] + public void Test_9127() + { + } + [Test] + public void Test_9128() + { + } + [Test] + public void Test_9129() + { + } + [Test] + public void Test_9130() + { + } + [Test] + public void Test_9131() + { + } + [Test] + public void Test_9132() + { + } + [Test] + public void Test_9133() + { + } + [Test] + public void Test_9134() + { + } + [Test] + public void Test_9135() + { + } + [Test] + public void Test_9136() + { + } + [Test] + public void Test_9137() + { + } + [Test] + public void Test_9138() + { + } + [Test] + public void Test_9139() + { + } + [Test] + public void Test_9140() + { + } + [Test] + public void Test_9141() + { + } + [Test] + public void Test_9142() + { + } + [Test] + public void Test_9143() + { + } + [Test] + public void Test_9144() + { + } + [Test] + public void Test_9145() + { + } + [Test] + public void Test_9146() + { + } + [Test] + public void Test_9147() + { + } + [Test] + public void Test_9148() + { + } + [Test] + public void Test_9149() + { + } + [Test] + public void Test_9150() + { + } + [Test] + public void Test_9151() + { + } + [Test] + public void Test_9152() + { + } + [Test] + public void Test_9153() + { + } + [Test] + public void Test_9154() + { + } + [Test] + public void Test_9155() + { + } + [Test] + public void Test_9156() + { + } + [Test] + public void Test_9157() + { + } + [Test] + public void Test_9158() + { + } + [Test] + public void Test_9159() + { + } + [Test] + public void Test_9160() + { + } + [Test] + public void Test_9161() + { + } + [Test] + public void Test_9162() + { + } + [Test] + public void Test_9163() + { + } + [Test] + public void Test_9164() + { + } + [Test] + public void Test_9165() + { + } + [Test] + public void Test_9166() + { + } + [Test] + public void Test_9167() + { + } + [Test] + public void Test_9168() + { + } + [Test] + public void Test_9169() + { + } + [Test] + public void Test_9170() + { + } + [Test] + public void Test_9171() + { + } + [Test] + public void Test_9172() + { + } + [Test] + public void Test_9173() + { + } + [Test] + public void Test_9174() + { + } + [Test] + public void Test_9175() + { + } + [Test] + public void Test_9176() + { + } + [Test] + public void Test_9177() + { + } + [Test] + public void Test_9178() + { + } + [Test] + public void Test_9179() + { + } + [Test] + public void Test_9180() + { + } + [Test] + public void Test_9181() + { + } + [Test] + public void Test_9182() + { + } + [Test] + public void Test_9183() + { + } + [Test] + public void Test_9184() + { + } + [Test] + public void Test_9185() + { + } + [Test] + public void Test_9186() + { + } + [Test] + public void Test_9187() + { + } + [Test] + public void Test_9188() + { + } + [Test] + public void Test_9189() + { + } + [Test] + public void Test_9190() + { + } + [Test] + public void Test_9191() + { + } + [Test] + public void Test_9192() + { + } + [Test] + public void Test_9193() + { + } + [Test] + public void Test_9194() + { + } + [Test] + public void Test_9195() + { + } + [Test] + public void Test_9196() + { + } + [Test] + public void Test_9197() + { + } + [Test] + public void Test_9198() + { + } + [Test] + public void Test_9199() + { + } + [Test] + public void Test_9200() + { + } + [Test] + public void Test_9201() + { + } + [Test] + public void Test_9202() + { + } + [Test] + public void Test_9203() + { + } + [Test] + public void Test_9204() + { + } + [Test] + public void Test_9205() + { + } + [Test] + public void Test_9206() + { + } + [Test] + public void Test_9207() + { + } + [Test] + public void Test_9208() + { + } + [Test] + public void Test_9209() + { + } + [Test] + public void Test_9210() + { + } + [Test] + public void Test_9211() + { + } + [Test] + public void Test_9212() + { + } + [Test] + public void Test_9213() + { + } + [Test] + public void Test_9214() + { + } + [Test] + public void Test_9215() + { + } + [Test] + public void Test_9216() + { + } + [Test] + public void Test_9217() + { + } + [Test] + public void Test_9218() + { + } + [Test] + public void Test_9219() + { + } + [Test] + public void Test_9220() + { + } + [Test] + public void Test_9221() + { + } + [Test] + public void Test_9222() + { + } + [Test] + public void Test_9223() + { + } + [Test] + public void Test_9224() + { + } + [Test] + public void Test_9225() + { + } + [Test] + public void Test_9226() + { + } + [Test] + public void Test_9227() + { + } + [Test] + public void Test_9228() + { + } + [Test] + public void Test_9229() + { + } + [Test] + public void Test_9230() + { + } + [Test] + public void Test_9231() + { + } + [Test] + public void Test_9232() + { + } + [Test] + public void Test_9233() + { + } + [Test] + public void Test_9234() + { + } + [Test] + public void Test_9235() + { + } + [Test] + public void Test_9236() + { + } + [Test] + public void Test_9237() + { + } + [Test] + public void Test_9238() + { + } + [Test] + public void Test_9239() + { + } + [Test] + public void Test_9240() + { + } + [Test] + public void Test_9241() + { + } + [Test] + public void Test_9242() + { + } + [Test] + public void Test_9243() + { + } + [Test] + public void Test_9244() + { + } + [Test] + public void Test_9245() + { + } + [Test] + public void Test_9246() + { + } + [Test] + public void Test_9247() + { + } + [Test] + public void Test_9248() + { + } + [Test] + public void Test_9249() + { + } + [Test] + public void Test_9250() + { + } + [Test] + public void Test_9251() + { + } + [Test] + public void Test_9252() + { + } + [Test] + public void Test_9253() + { + } + [Test] + public void Test_9254() + { + } + [Test] + public void Test_9255() + { + } + [Test] + public void Test_9256() + { + } + [Test] + public void Test_9257() + { + } + [Test] + public void Test_9258() + { + } + [Test] + public void Test_9259() + { + } + [Test] + public void Test_9260() + { + } + [Test] + public void Test_9261() + { + } + [Test] + public void Test_9262() + { + } + [Test] + public void Test_9263() + { + } + [Test] + public void Test_9264() + { + } + [Test] + public void Test_9265() + { + } + [Test] + public void Test_9266() + { + } + [Test] + public void Test_9267() + { + } + [Test] + public void Test_9268() + { + } + [Test] + public void Test_9269() + { + } + [Test] + public void Test_9270() + { + } + [Test] + public void Test_9271() + { + } + [Test] + public void Test_9272() + { + } + [Test] + public void Test_9273() + { + } + [Test] + public void Test_9274() + { + } + [Test] + public void Test_9275() + { + } + [Test] + public void Test_9276() + { + } + [Test] + public void Test_9277() + { + } + [Test] + public void Test_9278() + { + } + [Test] + public void Test_9279() + { + } + [Test] + public void Test_9280() + { + } + [Test] + public void Test_9281() + { + } + [Test] + public void Test_9282() + { + } + [Test] + public void Test_9283() + { + } + [Test] + public void Test_9284() + { + } + [Test] + public void Test_9285() + { + } + [Test] + public void Test_9286() + { + } + [Test] + public void Test_9287() + { + } + [Test] + public void Test_9288() + { + } + [Test] + public void Test_9289() + { + } + [Test] + public void Test_9290() + { + } + [Test] + public void Test_9291() + { + } + [Test] + public void Test_9292() + { + } + [Test] + public void Test_9293() + { + } + [Test] + public void Test_9294() + { + } + [Test] + public void Test_9295() + { + } + [Test] + public void Test_9296() + { + } + [Test] + public void Test_9297() + { + } + [Test] + public void Test_9298() + { + } + [Test] + public void Test_9299() + { + } + [Test] + public void Test_9300() + { + } + [Test] + public void Test_9301() + { + } + [Test] + public void Test_9302() + { + } + [Test] + public void Test_9303() + { + } + [Test] + public void Test_9304() + { + } + [Test] + public void Test_9305() + { + } + [Test] + public void Test_9306() + { + } + [Test] + public void Test_9307() + { + } + [Test] + public void Test_9308() + { + } + [Test] + public void Test_9309() + { + } + [Test] + public void Test_9310() + { + } + [Test] + public void Test_9311() + { + } + [Test] + public void Test_9312() + { + } + [Test] + public void Test_9313() + { + } + [Test] + public void Test_9314() + { + } + [Test] + public void Test_9315() + { + } + [Test] + public void Test_9316() + { + } + [Test] + public void Test_9317() + { + } + [Test] + public void Test_9318() + { + } + [Test] + public void Test_9319() + { + } + [Test] + public void Test_9320() + { + } + [Test] + public void Test_9321() + { + } + [Test] + public void Test_9322() + { + } + [Test] + public void Test_9323() + { + } + [Test] + public void Test_9324() + { + } + [Test] + public void Test_9325() + { + } + [Test] + public void Test_9326() + { + } + [Test] + public void Test_9327() + { + } + [Test] + public void Test_9328() + { + } + [Test] + public void Test_9329() + { + } + [Test] + public void Test_9330() + { + } + [Test] + public void Test_9331() + { + } + [Test] + public void Test_9332() + { + } + [Test] + public void Test_9333() + { + } + [Test] + public void Test_9334() + { + } + [Test] + public void Test_9335() + { + } + [Test] + public void Test_9336() + { + } + [Test] + public void Test_9337() + { + } + [Test] + public void Test_9338() + { + } + [Test] + public void Test_9339() + { + } + [Test] + public void Test_9340() + { + } + [Test] + public void Test_9341() + { + } + [Test] + public void Test_9342() + { + } + [Test] + public void Test_9343() + { + } + [Test] + public void Test_9344() + { + } + [Test] + public void Test_9345() + { + } + [Test] + public void Test_9346() + { + } + [Test] + public void Test_9347() + { + } + [Test] + public void Test_9348() + { + } + [Test] + public void Test_9349() + { + } + [Test] + public void Test_9350() + { + } + [Test] + public void Test_9351() + { + } + [Test] + public void Test_9352() + { + } + [Test] + public void Test_9353() + { + } + [Test] + public void Test_9354() + { + } + [Test] + public void Test_9355() + { + } + [Test] + public void Test_9356() + { + } + [Test] + public void Test_9357() + { + } + [Test] + public void Test_9358() + { + } + [Test] + public void Test_9359() + { + } + [Test] + public void Test_9360() + { + } + [Test] + public void Test_9361() + { + } + [Test] + public void Test_9362() + { + } + [Test] + public void Test_9363() + { + } + [Test] + public void Test_9364() + { + } + [Test] + public void Test_9365() + { + } + [Test] + public void Test_9366() + { + } + [Test] + public void Test_9367() + { + } + [Test] + public void Test_9368() + { + } + [Test] + public void Test_9369() + { + } + [Test] + public void Test_9370() + { + } + [Test] + public void Test_9371() + { + } + [Test] + public void Test_9372() + { + } + [Test] + public void Test_9373() + { + } + [Test] + public void Test_9374() + { + } + [Test] + public void Test_9375() + { + } + [Test] + public void Test_9376() + { + } + [Test] + public void Test_9377() + { + } + [Test] + public void Test_9378() + { + } + [Test] + public void Test_9379() + { + } + [Test] + public void Test_9380() + { + } + [Test] + public void Test_9381() + { + } + [Test] + public void Test_9382() + { + } + [Test] + public void Test_9383() + { + } + [Test] + public void Test_9384() + { + } + [Test] + public void Test_9385() + { + } + [Test] + public void Test_9386() + { + } + [Test] + public void Test_9387() + { + } + [Test] + public void Test_9388() + { + } + [Test] + public void Test_9389() + { + } + [Test] + public void Test_9390() + { + } + [Test] + public void Test_9391() + { + } + [Test] + public void Test_9392() + { + } + [Test] + public void Test_9393() + { + } + [Test] + public void Test_9394() + { + } + [Test] + public void Test_9395() + { + } + [Test] + public void Test_9396() + { + } + [Test] + public void Test_9397() + { + } + [Test] + public void Test_9398() + { + } + [Test] + public void Test_9399() + { + } + [Test] + public void Test_9400() + { + } + [Test] + public void Test_9401() + { + } + [Test] + public void Test_9402() + { + } + [Test] + public void Test_9403() + { + } + [Test] + public void Test_9404() + { + } + [Test] + public void Test_9405() + { + } + [Test] + public void Test_9406() + { + } + [Test] + public void Test_9407() + { + } + [Test] + public void Test_9408() + { + } + [Test] + public void Test_9409() + { + } + [Test] + public void Test_9410() + { + } + [Test] + public void Test_9411() + { + } + [Test] + public void Test_9412() + { + } + [Test] + public void Test_9413() + { + } + [Test] + public void Test_9414() + { + } + [Test] + public void Test_9415() + { + } + [Test] + public void Test_9416() + { + } + [Test] + public void Test_9417() + { + } + [Test] + public void Test_9418() + { + } + [Test] + public void Test_9419() + { + } + [Test] + public void Test_9420() + { + } + [Test] + public void Test_9421() + { + } + [Test] + public void Test_9422() + { + } + [Test] + public void Test_9423() + { + } + [Test] + public void Test_9424() + { + } + [Test] + public void Test_9425() + { + } + [Test] + public void Test_9426() + { + } + [Test] + public void Test_9427() + { + } + [Test] + public void Test_9428() + { + } + [Test] + public void Test_9429() + { + } + [Test] + public void Test_9430() + { + } + [Test] + public void Test_9431() + { + } + [Test] + public void Test_9432() + { + } + [Test] + public void Test_9433() + { + } + [Test] + public void Test_9434() + { + } + [Test] + public void Test_9435() + { + } + [Test] + public void Test_9436() + { + } + [Test] + public void Test_9437() + { + } + [Test] + public void Test_9438() + { + } + [Test] + public void Test_9439() + { + } + [Test] + public void Test_9440() + { + } + [Test] + public void Test_9441() + { + } + [Test] + public void Test_9442() + { + } + [Test] + public void Test_9443() + { + } + [Test] + public void Test_9444() + { + } + [Test] + public void Test_9445() + { + } + [Test] + public void Test_9446() + { + } + [Test] + public void Test_9447() + { + } + [Test] + public void Test_9448() + { + } + [Test] + public void Test_9449() + { + } + [Test] + public void Test_9450() + { + } + [Test] + public void Test_9451() + { + } + [Test] + public void Test_9452() + { + } + [Test] + public void Test_9453() + { + } + [Test] + public void Test_9454() + { + } + [Test] + public void Test_9455() + { + } + [Test] + public void Test_9456() + { + } + [Test] + public void Test_9457() + { + } + [Test] + public void Test_9458() + { + } + [Test] + public void Test_9459() + { + } + [Test] + public void Test_9460() + { + } + [Test] + public void Test_9461() + { + } + [Test] + public void Test_9462() + { + } + [Test] + public void Test_9463() + { + } + [Test] + public void Test_9464() + { + } + [Test] + public void Test_9465() + { + } + [Test] + public void Test_9466() + { + } + [Test] + public void Test_9467() + { + } + [Test] + public void Test_9468() + { + } + [Test] + public void Test_9469() + { + } + [Test] + public void Test_9470() + { + } + [Test] + public void Test_9471() + { + } + [Test] + public void Test_9472() + { + } + [Test] + public void Test_9473() + { + } + [Test] + public void Test_9474() + { + } + [Test] + public void Test_9475() + { + } + [Test] + public void Test_9476() + { + } + [Test] + public void Test_9477() + { + } + [Test] + public void Test_9478() + { + } + [Test] + public void Test_9479() + { + } + [Test] + public void Test_9480() + { + } + [Test] + public void Test_9481() + { + } + [Test] + public void Test_9482() + { + } + [Test] + public void Test_9483() + { + } + [Test] + public void Test_9484() + { + } + [Test] + public void Test_9485() + { + } + [Test] + public void Test_9486() + { + } + [Test] + public void Test_9487() + { + } + [Test] + public void Test_9488() + { + } + [Test] + public void Test_9489() + { + } + [Test] + public void Test_9490() + { + } + [Test] + public void Test_9491() + { + } + [Test] + public void Test_9492() + { + } + [Test] + public void Test_9493() + { + } + [Test] + public void Test_9494() + { + } + [Test] + public void Test_9495() + { + } + [Test] + public void Test_9496() + { + } + [Test] + public void Test_9497() + { + } + [Test] + public void Test_9498() + { + } + [Test] + public void Test_9499() + { + } + [Test] + public void Test_9500() + { + } + [Test] + public void Test_9501() + { + } + [Test] + public void Test_9502() + { + } + [Test] + public void Test_9503() + { + } + [Test] + public void Test_9504() + { + } + [Test] + public void Test_9505() + { + } + [Test] + public void Test_9506() + { + } + [Test] + public void Test_9507() + { + } + [Test] + public void Test_9508() + { + } + [Test] + public void Test_9509() + { + } + [Test] + public void Test_9510() + { + } + [Test] + public void Test_9511() + { + } + [Test] + public void Test_9512() + { + } + [Test] + public void Test_9513() + { + } + [Test] + public void Test_9514() + { + } + [Test] + public void Test_9515() + { + } + [Test] + public void Test_9516() + { + } + [Test] + public void Test_9517() + { + } + [Test] + public void Test_9518() + { + } + [Test] + public void Test_9519() + { + } + [Test] + public void Test_9520() + { + } + [Test] + public void Test_9521() + { + } + [Test] + public void Test_9522() + { + } + [Test] + public void Test_9523() + { + } + [Test] + public void Test_9524() + { + } + [Test] + public void Test_9525() + { + } + [Test] + public void Test_9526() + { + } + [Test] + public void Test_9527() + { + } + [Test] + public void Test_9528() + { + } + [Test] + public void Test_9529() + { + } + [Test] + public void Test_9530() + { + } + [Test] + public void Test_9531() + { + } + [Test] + public void Test_9532() + { + } + [Test] + public void Test_9533() + { + } + [Test] + public void Test_9534() + { + } + [Test] + public void Test_9535() + { + } + [Test] + public void Test_9536() + { + } + [Test] + public void Test_9537() + { + } + [Test] + public void Test_9538() + { + } + [Test] + public void Test_9539() + { + } + [Test] + public void Test_9540() + { + } + [Test] + public void Test_9541() + { + } + [Test] + public void Test_9542() + { + } + [Test] + public void Test_9543() + { + } + [Test] + public void Test_9544() + { + } + [Test] + public void Test_9545() + { + } + [Test] + public void Test_9546() + { + } + [Test] + public void Test_9547() + { + } + [Test] + public void Test_9548() + { + } + [Test] + public void Test_9549() + { + } + [Test] + public void Test_9550() + { + } + [Test] + public void Test_9551() + { + } + [Test] + public void Test_9552() + { + } + [Test] + public void Test_9553() + { + } + [Test] + public void Test_9554() + { + } + [Test] + public void Test_9555() + { + } + [Test] + public void Test_9556() + { + } + [Test] + public void Test_9557() + { + } + [Test] + public void Test_9558() + { + } + [Test] + public void Test_9559() + { + } + [Test] + public void Test_9560() + { + } + [Test] + public void Test_9561() + { + } + [Test] + public void Test_9562() + { + } + [Test] + public void Test_9563() + { + } + [Test] + public void Test_9564() + { + } + [Test] + public void Test_9565() + { + } + [Test] + public void Test_9566() + { + } + [Test] + public void Test_9567() + { + } + [Test] + public void Test_9568() + { + } + [Test] + public void Test_9569() + { + } + [Test] + public void Test_9570() + { + } + [Test] + public void Test_9571() + { + } + [Test] + public void Test_9572() + { + } + [Test] + public void Test_9573() + { + } + [Test] + public void Test_9574() + { + } + [Test] + public void Test_9575() + { + } + [Test] + public void Test_9576() + { + } + [Test] + public void Test_9577() + { + } + [Test] + public void Test_9578() + { + } + [Test] + public void Test_9579() + { + } + [Test] + public void Test_9580() + { + } + [Test] + public void Test_9581() + { + } + [Test] + public void Test_9582() + { + } + [Test] + public void Test_9583() + { + } + [Test] + public void Test_9584() + { + } + [Test] + public void Test_9585() + { + } + [Test] + public void Test_9586() + { + } + [Test] + public void Test_9587() + { + } + [Test] + public void Test_9588() + { + } + [Test] + public void Test_9589() + { + } + [Test] + public void Test_9590() + { + } + [Test] + public void Test_9591() + { + } + [Test] + public void Test_9592() + { + } + [Test] + public void Test_9593() + { + } + [Test] + public void Test_9594() + { + } + [Test] + public void Test_9595() + { + } + [Test] + public void Test_9596() + { + } + [Test] + public void Test_9597() + { + } + [Test] + public void Test_9598() + { + } + [Test] + public void Test_9599() + { + } + [Test] + public void Test_9600() + { + } + [Test] + public void Test_9601() + { + } + [Test] + public void Test_9602() + { + } + [Test] + public void Test_9603() + { + } + [Test] + public void Test_9604() + { + } + [Test] + public void Test_9605() + { + } + [Test] + public void Test_9606() + { + } + [Test] + public void Test_9607() + { + } + [Test] + public void Test_9608() + { + } + [Test] + public void Test_9609() + { + } + [Test] + public void Test_9610() + { + } + [Test] + public void Test_9611() + { + } + [Test] + public void Test_9612() + { + } + [Test] + public void Test_9613() + { + } + [Test] + public void Test_9614() + { + } + [Test] + public void Test_9615() + { + } + [Test] + public void Test_9616() + { + } + [Test] + public void Test_9617() + { + } + [Test] + public void Test_9618() + { + } + [Test] + public void Test_9619() + { + } + [Test] + public void Test_9620() + { + } + [Test] + public void Test_9621() + { + } + [Test] + public void Test_9622() + { + } + [Test] + public void Test_9623() + { + } + [Test] + public void Test_9624() + { + } + [Test] + public void Test_9625() + { + } + [Test] + public void Test_9626() + { + } + [Test] + public void Test_9627() + { + } + [Test] + public void Test_9628() + { + } + [Test] + public void Test_9629() + { + } + [Test] + public void Test_9630() + { + } + [Test] + public void Test_9631() + { + } + [Test] + public void Test_9632() + { + } + [Test] + public void Test_9633() + { + } + [Test] + public void Test_9634() + { + } + [Test] + public void Test_9635() + { + } + [Test] + public void Test_9636() + { + } + [Test] + public void Test_9637() + { + } + [Test] + public void Test_9638() + { + } + [Test] + public void Test_9639() + { + } + [Test] + public void Test_9640() + { + } + [Test] + public void Test_9641() + { + } + [Test] + public void Test_9642() + { + } + [Test] + public void Test_9643() + { + } + [Test] + public void Test_9644() + { + } + [Test] + public void Test_9645() + { + } + [Test] + public void Test_9646() + { + } + [Test] + public void Test_9647() + { + } + [Test] + public void Test_9648() + { + } + [Test] + public void Test_9649() + { + } + [Test] + public void Test_9650() + { + } + [Test] + public void Test_9651() + { + } + [Test] + public void Test_9652() + { + } + [Test] + public void Test_9653() + { + } + [Test] + public void Test_9654() + { + } + [Test] + public void Test_9655() + { + } + [Test] + public void Test_9656() + { + } + [Test] + public void Test_9657() + { + } + [Test] + public void Test_9658() + { + } + [Test] + public void Test_9659() + { + } + [Test] + public void Test_9660() + { + } + [Test] + public void Test_9661() + { + } + [Test] + public void Test_9662() + { + } + [Test] + public void Test_9663() + { + } + [Test] + public void Test_9664() + { + } + [Test] + public void Test_9665() + { + } + [Test] + public void Test_9666() + { + } + [Test] + public void Test_9667() + { + } + [Test] + public void Test_9668() + { + } + [Test] + public void Test_9669() + { + } + [Test] + public void Test_9670() + { + } + [Test] + public void Test_9671() + { + } + [Test] + public void Test_9672() + { + } + [Test] + public void Test_9673() + { + } + [Test] + public void Test_9674() + { + } + [Test] + public void Test_9675() + { + } + [Test] + public void Test_9676() + { + } + [Test] + public void Test_9677() + { + } + [Test] + public void Test_9678() + { + } + [Test] + public void Test_9679() + { + } + [Test] + public void Test_9680() + { + } + [Test] + public void Test_9681() + { + } + [Test] + public void Test_9682() + { + } + [Test] + public void Test_9683() + { + } + [Test] + public void Test_9684() + { + } + [Test] + public void Test_9685() + { + } + [Test] + public void Test_9686() + { + } + [Test] + public void Test_9687() + { + } + [Test] + public void Test_9688() + { + } + [Test] + public void Test_9689() + { + } + [Test] + public void Test_9690() + { + } + [Test] + public void Test_9691() + { + } + [Test] + public void Test_9692() + { + } + [Test] + public void Test_9693() + { + } + [Test] + public void Test_9694() + { + } + [Test] + public void Test_9695() + { + } + [Test] + public void Test_9696() + { + } + [Test] + public void Test_9697() + { + } + [Test] + public void Test_9698() + { + } + [Test] + public void Test_9699() + { + } + [Test] + public void Test_9700() + { + } + [Test] + public void Test_9701() + { + } + [Test] + public void Test_9702() + { + } + [Test] + public void Test_9703() + { + } + [Test] + public void Test_9704() + { + } + [Test] + public void Test_9705() + { + } + [Test] + public void Test_9706() + { + } + [Test] + public void Test_9707() + { + } + [Test] + public void Test_9708() + { + } + [Test] + public void Test_9709() + { + } + [Test] + public void Test_9710() + { + } + [Test] + public void Test_9711() + { + } + [Test] + public void Test_9712() + { + } + [Test] + public void Test_9713() + { + } + [Test] + public void Test_9714() + { + } + [Test] + public void Test_9715() + { + } + [Test] + public void Test_9716() + { + } + [Test] + public void Test_9717() + { + } + [Test] + public void Test_9718() + { + } + [Test] + public void Test_9719() + { + } + [Test] + public void Test_9720() + { + } + [Test] + public void Test_9721() + { + } + [Test] + public void Test_9722() + { + } + [Test] + public void Test_9723() + { + } + [Test] + public void Test_9724() + { + } + [Test] + public void Test_9725() + { + } + [Test] + public void Test_9726() + { + } + [Test] + public void Test_9727() + { + } + [Test] + public void Test_9728() + { + } + [Test] + public void Test_9729() + { + } + [Test] + public void Test_9730() + { + } + [Test] + public void Test_9731() + { + } + [Test] + public void Test_9732() + { + } + [Test] + public void Test_9733() + { + } + [Test] + public void Test_9734() + { + } + [Test] + public void Test_9735() + { + } + [Test] + public void Test_9736() + { + } + [Test] + public void Test_9737() + { + } + [Test] + public void Test_9738() + { + } + [Test] + public void Test_9739() + { + } + [Test] + public void Test_9740() + { + } + [Test] + public void Test_9741() + { + } + [Test] + public void Test_9742() + { + } + [Test] + public void Test_9743() + { + } + [Test] + public void Test_9744() + { + } + [Test] + public void Test_9745() + { + } + [Test] + public void Test_9746() + { + } + [Test] + public void Test_9747() + { + } + [Test] + public void Test_9748() + { + } + [Test] + public void Test_9749() + { + } + [Test] + public void Test_9750() + { + } + [Test] + public void Test_9751() + { + } + [Test] + public void Test_9752() + { + } + [Test] + public void Test_9753() + { + } + [Test] + public void Test_9754() + { + } + [Test] + public void Test_9755() + { + } + [Test] + public void Test_9756() + { + } + [Test] + public void Test_9757() + { + } + [Test] + public void Test_9758() + { + } + [Test] + public void Test_9759() + { + } + [Test] + public void Test_9760() + { + } + [Test] + public void Test_9761() + { + } + [Test] + public void Test_9762() + { + } + [Test] + public void Test_9763() + { + } + [Test] + public void Test_9764() + { + } + [Test] + public void Test_9765() + { + } + [Test] + public void Test_9766() + { + } + [Test] + public void Test_9767() + { + } + [Test] + public void Test_9768() + { + } + [Test] + public void Test_9769() + { + } + [Test] + public void Test_9770() + { + } + [Test] + public void Test_9771() + { + } + [Test] + public void Test_9772() + { + } + [Test] + public void Test_9773() + { + } + [Test] + public void Test_9774() + { + } + [Test] + public void Test_9775() + { + } + [Test] + public void Test_9776() + { + } + [Test] + public void Test_9777() + { + } + [Test] + public void Test_9778() + { + } + [Test] + public void Test_9779() + { + } + [Test] + public void Test_9780() + { + } + [Test] + public void Test_9781() + { + } + [Test] + public void Test_9782() + { + } + [Test] + public void Test_9783() + { + } + [Test] + public void Test_9784() + { + } + [Test] + public void Test_9785() + { + } + [Test] + public void Test_9786() + { + } + [Test] + public void Test_9787() + { + } + [Test] + public void Test_9788() + { + } + [Test] + public void Test_9789() + { + } + [Test] + public void Test_9790() + { + } + [Test] + public void Test_9791() + { + } + [Test] + public void Test_9792() + { + } + [Test] + public void Test_9793() + { + } + [Test] + public void Test_9794() + { + } + [Test] + public void Test_9795() + { + } + [Test] + public void Test_9796() + { + } + [Test] + public void Test_9797() + { + } + [Test] + public void Test_9798() + { + } + [Test] + public void Test_9799() + { + } + [Test] + public void Test_9800() + { + } + [Test] + public void Test_9801() + { + } + [Test] + public void Test_9802() + { + } + [Test] + public void Test_9803() + { + } + [Test] + public void Test_9804() + { + } + [Test] + public void Test_9805() + { + } + [Test] + public void Test_9806() + { + } + [Test] + public void Test_9807() + { + } + [Test] + public void Test_9808() + { + } + [Test] + public void Test_9809() + { + } + [Test] + public void Test_9810() + { + } + [Test] + public void Test_9811() + { + } + [Test] + public void Test_9812() + { + } + [Test] + public void Test_9813() + { + } + [Test] + public void Test_9814() + { + } + [Test] + public void Test_9815() + { + } + [Test] + public void Test_9816() + { + } + [Test] + public void Test_9817() + { + } + [Test] + public void Test_9818() + { + } + [Test] + public void Test_9819() + { + } + [Test] + public void Test_9820() + { + } + [Test] + public void Test_9821() + { + } + [Test] + public void Test_9822() + { + } + [Test] + public void Test_9823() + { + } + [Test] + public void Test_9824() + { + } + [Test] + public void Test_9825() + { + } + [Test] + public void Test_9826() + { + } + [Test] + public void Test_9827() + { + } + [Test] + public void Test_9828() + { + } + [Test] + public void Test_9829() + { + } + [Test] + public void Test_9830() + { + } + [Test] + public void Test_9831() + { + } + [Test] + public void Test_9832() + { + } + [Test] + public void Test_9833() + { + } + [Test] + public void Test_9834() + { + } + [Test] + public void Test_9835() + { + } + [Test] + public void Test_9836() + { + } + [Test] + public void Test_9837() + { + } + [Test] + public void Test_9838() + { + } + [Test] + public void Test_9839() + { + } + [Test] + public void Test_9840() + { + } + [Test] + public void Test_9841() + { + } + [Test] + public void Test_9842() + { + } + [Test] + public void Test_9843() + { + } + [Test] + public void Test_9844() + { + } + [Test] + public void Test_9845() + { + } + [Test] + public void Test_9846() + { + } + [Test] + public void Test_9847() + { + } + [Test] + public void Test_9848() + { + } + [Test] + public void Test_9849() + { + } + [Test] + public void Test_9850() + { + } + [Test] + public void Test_9851() + { + } + [Test] + public void Test_9852() + { + } + [Test] + public void Test_9853() + { + } + [Test] + public void Test_9854() + { + } + [Test] + public void Test_9855() + { + } + [Test] + public void Test_9856() + { + } + [Test] + public void Test_9857() + { + } + [Test] + public void Test_9858() + { + } + [Test] + public void Test_9859() + { + } + [Test] + public void Test_9860() + { + } + [Test] + public void Test_9861() + { + } + [Test] + public void Test_9862() + { + } + [Test] + public void Test_9863() + { + } + [Test] + public void Test_9864() + { + } + [Test] + public void Test_9865() + { + } + [Test] + public void Test_9866() + { + } + [Test] + public void Test_9867() + { + } + [Test] + public void Test_9868() + { + } + [Test] + public void Test_9869() + { + } + [Test] + public void Test_9870() + { + } + [Test] + public void Test_9871() + { + } + [Test] + public void Test_9872() + { + } + [Test] + public void Test_9873() + { + } + [Test] + public void Test_9874() + { + } + [Test] + public void Test_9875() + { + } + [Test] + public void Test_9876() + { + } + [Test] + public void Test_9877() + { + } + [Test] + public void Test_9878() + { + } + [Test] + public void Test_9879() + { + } + [Test] + public void Test_9880() + { + } + [Test] + public void Test_9881() + { + } + [Test] + public void Test_9882() + { + } + [Test] + public void Test_9883() + { + } + [Test] + public void Test_9884() + { + } + [Test] + public void Test_9885() + { + } + [Test] + public void Test_9886() + { + } + [Test] + public void Test_9887() + { + } + [Test] + public void Test_9888() + { + } + [Test] + public void Test_9889() + { + } + [Test] + public void Test_9890() + { + } + [Test] + public void Test_9891() + { + } + [Test] + public void Test_9892() + { + } + [Test] + public void Test_9893() + { + } + [Test] + public void Test_9894() + { + } + [Test] + public void Test_9895() + { + } + [Test] + public void Test_9896() + { + } + [Test] + public void Test_9897() + { + } + [Test] + public void Test_9898() + { + } + [Test] + public void Test_9899() + { + } + [Test] + public void Test_9900() + { + } + [Test] + public void Test_9901() + { + } + [Test] + public void Test_9902() + { + } + [Test] + public void Test_9903() + { + } + [Test] + public void Test_9904() + { + } + [Test] + public void Test_9905() + { + } + [Test] + public void Test_9906() + { + } + [Test] + public void Test_9907() + { + } + [Test] + public void Test_9908() + { + } + [Test] + public void Test_9909() + { + } + [Test] + public void Test_9910() + { + } + [Test] + public void Test_9911() + { + } + [Test] + public void Test_9912() + { + } + [Test] + public void Test_9913() + { + } + [Test] + public void Test_9914() + { + } + [Test] + public void Test_9915() + { + } + [Test] + public void Test_9916() + { + } + [Test] + public void Test_9917() + { + } + [Test] + public void Test_9918() + { + } + [Test] + public void Test_9919() + { + } + [Test] + public void Test_9920() + { + } + [Test] + public void Test_9921() + { + } + [Test] + public void Test_9922() + { + } + [Test] + public void Test_9923() + { + } + [Test] + public void Test_9924() + { + } + [Test] + public void Test_9925() + { + } + [Test] + public void Test_9926() + { + } + [Test] + public void Test_9927() + { + } + [Test] + public void Test_9928() + { + } + [Test] + public void Test_9929() + { + } + [Test] + public void Test_9930() + { + } + [Test] + public void Test_9931() + { + } + [Test] + public void Test_9932() + { + } + [Test] + public void Test_9933() + { + } + [Test] + public void Test_9934() + { + } + [Test] + public void Test_9935() + { + } + [Test] + public void Test_9936() + { + } + [Test] + public void Test_9937() + { + } + [Test] + public void Test_9938() + { + } + [Test] + public void Test_9939() + { + } + [Test] + public void Test_9940() + { + } + [Test] + public void Test_9941() + { + } + [Test] + public void Test_9942() + { + } + [Test] + public void Test_9943() + { + } + [Test] + public void Test_9944() + { + } + [Test] + public void Test_9945() + { + } + [Test] + public void Test_9946() + { + } + [Test] + public void Test_9947() + { + } + [Test] + public void Test_9948() + { + } + [Test] + public void Test_9949() + { + } + [Test] + public void Test_9950() + { + } + [Test] + public void Test_9951() + { + } + [Test] + public void Test_9952() + { + } + [Test] + public void Test_9953() + { + } + [Test] + public void Test_9954() + { + } + [Test] + public void Test_9955() + { + } + [Test] + public void Test_9956() + { + } + [Test] + public void Test_9957() + { + } + [Test] + public void Test_9958() + { + } + [Test] + public void Test_9959() + { + } + [Test] + public void Test_9960() + { + } + [Test] + public void Test_9961() + { + } + [Test] + public void Test_9962() + { + } + [Test] + public void Test_9963() + { + } + [Test] + public void Test_9964() + { + } + [Test] + public void Test_9965() + { + } + [Test] + public void Test_9966() + { + } + [Test] + public void Test_9967() + { + } + [Test] + public void Test_9968() + { + } + [Test] + public void Test_9969() + { + } + [Test] + public void Test_9970() + { + } + [Test] + public void Test_9971() + { + } + [Test] + public void Test_9972() + { + } + [Test] + public void Test_9973() + { + } + [Test] + public void Test_9974() + { + } + [Test] + public void Test_9975() + { + } + [Test] + public void Test_9976() + { + } + [Test] + public void Test_9977() + { + } + [Test] + public void Test_9978() + { + } + [Test] + public void Test_9979() + { + } + [Test] + public void Test_9980() + { + } + [Test] + public void Test_9981() + { + } + [Test] + public void Test_9982() + { + } + [Test] + public void Test_9983() + { + } + [Test] + public void Test_9984() + { + } + [Test] + public void Test_9985() + { + } + [Test] + public void Test_9986() + { + } + [Test] + public void Test_9987() + { + } + [Test] + public void Test_9988() + { + } + [Test] + public void Test_9989() + { + } + [Test] + public void Test_9990() + { + } + [Test] + public void Test_9991() + { + } + [Test] + public void Test_9992() + { + } + [Test] + public void Test_9993() + { + } + [Test] + public void Test_9994() + { + } + [Test] + public void Test_9995() + { + } + [Test] + public void Test_9996() + { + } + [Test] + public void Test_9997() + { + } + [Test] + public void Test_9998() + { + } + [Test] + public void Test_9999() + { + } + [Test] + public void Test_10000() + { + } + #endregion + + #region FailingTests + #endregion - #region FailingTests - #endregion - } } diff --git a/test/TestAssets/PerfAssets/XUnitAdapterPerfTestProject/XunitTests.cs b/test/TestAssets/PerfAssets/XUnitAdapterPerfTestProject/XunitTests.cs index 25fbbeff35..0411c0cfb1 100644 --- a/test/TestAssets/PerfAssets/XUnitAdapterPerfTestProject/XunitTests.cs +++ b/test/TestAssets/PerfAssets/XUnitAdapterPerfTestProject/XunitTests.cs @@ -1,40015 +1,40018 @@ -using Xunit; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Xunit; namespace XUnitAdapterPerfTests { - public class XuniTests + public class XuniTests { - #region PassingTests - [Fact] - public void Test_01() - { - } - [Fact] - public void Test_02() - { - } - [Fact] - public void Test_03() - { - } - [Fact] - public void Test_04() - { - } - [Fact] - public void Test_05() - { - } - [Fact] - public void Test_06() - { - } - [Fact] - public void Test_07() - { - } - [Fact] - public void Test_08() - { - } - [Fact] - public void Test_09() - { - } - [Fact] - public void Test_10() - { - } - [Fact] - public void Test_11() - { - } - [Fact] - public void Test_12() - { - } - [Fact] - public void Test_13() - { - } - [Fact] - public void Test_14() - { - } - [Fact] - public void Test_15() - { - } - [Fact] - public void Test_16() - { - } - [Fact] - public void Test_17() - { - } - [Fact] - public void Test_18() - { - } - [Fact] - public void Test_19() - { - } - [Fact] - public void Test_20() - { - } - [Fact] - public void Test_21() - { - } - [Fact] - public void Test_22() - { - } - [Fact] - public void Test_23() - { - } - [Fact] - public void Test_24() - { - } - [Fact] - public void Test_25() - { - } - [Fact] - public void Test_26() - { - } - [Fact] - public void Test_27() - { - } - [Fact] - public void Test_28() - { - } - [Fact] - public void Test_29() - { - } - [Fact] - public void Test_30() - { - } - [Fact] - public void Test_31() - { - } - [Fact] - public void Test_32() - { - } - [Fact] - public void Test_33() - { - } - [Fact] - public void Test_34() - { - } - [Fact] - public void Test_35() - { - } - [Fact] - public void Test_36() - { - } - [Fact] - public void Test_37() - { - } - [Fact] - public void Test_38() - { - } - [Fact] - public void Test_39() - { - } - [Fact] - public void Test_40() - { - } - [Fact] - public void Test_41() - { - } - [Fact] - public void Test_42() - { - } - [Fact] - public void Test_43() - { - } - [Fact] - public void Test_44() - { - } - [Fact] - public void Test_45() - { - } - [Fact] - public void Test_46() - { - } - [Fact] - public void Test_47() - { - } - [Fact] - public void Test_48() - { - } - [Fact] - public void Test_49() - { - } - [Fact] - public void Test_50() - { - } - [Fact] - public void Test_51() - { - } - [Fact] - public void Test_52() - { - } - [Fact] - public void Test_53() - { - } - [Fact] - public void Test_54() - { - } - [Fact] - public void Test_55() - { - } - [Fact] - public void Test_56() - { - } - [Fact] - public void Test_57() - { - } - [Fact] - public void Test_58() - { - } - [Fact] - public void Test_59() - { - } - [Fact] - public void Test_60() - { - } - [Fact] - public void Test_61() - { - } - [Fact] - public void Test_62() - { - } - [Fact] - public void Test_63() - { - } - [Fact] - public void Test_64() - { - } - [Fact] - public void Test_65() - { - } - [Fact] - public void Test_66() - { - } - [Fact] - public void Test_67() - { - } - [Fact] - public void Test_68() - { - } - [Fact] - public void Test_69() - { - } - [Fact] - public void Test_70() - { - } - [Fact] - public void Test_71() - { - } - [Fact] - public void Test_72() - { - } - [Fact] - public void Test_73() - { - } - [Fact] - public void Test_74() - { - } - [Fact] - public void Test_75() - { - } - [Fact] - public void Test_76() - { - } - [Fact] - public void Test_77() - { - } - [Fact] - public void Test_78() - { - } - [Fact] - public void Test_79() - { - } - [Fact] - public void Test_80() - { - } - [Fact] - public void Test_81() - { - } - [Fact] - public void Test_82() - { - } - [Fact] - public void Test_83() - { - } - [Fact] - public void Test_84() - { - } - [Fact] - public void Test_85() - { - } - [Fact] - public void Test_86() - { - } - [Fact] - public void Test_87() - { - } - [Fact] - public void Test_88() - { - } - [Fact] - public void Test_89() - { - } - [Fact] - public void Test_90() - { - } - [Fact] - public void Test_91() - { - } - [Fact] - public void Test_92() - { - } - [Fact] - public void Test_93() - { - } - [Fact] - public void Test_94() - { - } - [Fact] - public void Test_95() - { - } - [Fact] - public void Test_96() - { - } - [Fact] - public void Test_97() - { - } - [Fact] - public void Test_98() - { - } - [Fact] - public void Test_99() - { - } - [Fact] - public void Test_100() - { - } - [Fact] - public void Test_101() - { - } - [Fact] - public void Test_102() - { - } - [Fact] - public void Test_103() - { - } - [Fact] - public void Test_104() - { - } - [Fact] - public void Test_105() - { - } - [Fact] - public void Test_106() - { - } - [Fact] - public void Test_107() - { - } - [Fact] - public void Test_108() - { - } - [Fact] - public void Test_109() - { - } - [Fact] - public void Test_110() - { - } - [Fact] - public void Test_111() - { - } - [Fact] - public void Test_112() - { - } - [Fact] - public void Test_113() - { - } - [Fact] - public void Test_114() - { - } - [Fact] - public void Test_115() - { - } - [Fact] - public void Test_116() - { - } - [Fact] - public void Test_117() - { - } - [Fact] - public void Test_118() - { - } - [Fact] - public void Test_119() - { - } - [Fact] - public void Test_120() - { - } - [Fact] - public void Test_121() - { - } - [Fact] - public void Test_122() - { - } - [Fact] - public void Test_123() - { - } - [Fact] - public void Test_124() - { - } - [Fact] - public void Test_125() - { - } - [Fact] - public void Test_126() - { - } - [Fact] - public void Test_127() - { - } - [Fact] - public void Test_128() - { - } - [Fact] - public void Test_129() - { - } - [Fact] - public void Test_130() - { - } - [Fact] - public void Test_131() - { - } - [Fact] - public void Test_132() - { - } - [Fact] - public void Test_133() - { - } - [Fact] - public void Test_134() - { - } - [Fact] - public void Test_135() - { - } - [Fact] - public void Test_136() - { - } - [Fact] - public void Test_137() - { - } - [Fact] - public void Test_138() - { - } - [Fact] - public void Test_139() - { - } - [Fact] - public void Test_140() - { - } - [Fact] - public void Test_141() - { - } - [Fact] - public void Test_142() - { - } - [Fact] - public void Test_143() - { - } - [Fact] - public void Test_144() - { - } - [Fact] - public void Test_145() - { - } - [Fact] - public void Test_146() - { - } - [Fact] - public void Test_147() - { - } - [Fact] - public void Test_148() - { - } - [Fact] - public void Test_149() - { - } - [Fact] - public void Test_150() - { - } - [Fact] - public void Test_151() - { - } - [Fact] - public void Test_152() - { - } - [Fact] - public void Test_153() - { - } - [Fact] - public void Test_154() - { - } - [Fact] - public void Test_155() - { - } - [Fact] - public void Test_156() - { - } - [Fact] - public void Test_157() - { - } - [Fact] - public void Test_158() - { - } - [Fact] - public void Test_159() - { - } - [Fact] - public void Test_160() - { - } - [Fact] - public void Test_161() - { - } - [Fact] - public void Test_162() - { - } - [Fact] - public void Test_163() - { - } - [Fact] - public void Test_164() - { - } - [Fact] - public void Test_165() - { - } - [Fact] - public void Test_166() - { - } - [Fact] - public void Test_167() - { - } - [Fact] - public void Test_168() - { - } - [Fact] - public void Test_169() - { - } - [Fact] - public void Test_170() - { - } - [Fact] - public void Test_171() - { - } - [Fact] - public void Test_172() - { - } - [Fact] - public void Test_173() - { - } - [Fact] - public void Test_174() - { - } - [Fact] - public void Test_175() - { - } - [Fact] - public void Test_176() - { - } - [Fact] - public void Test_177() - { - } - [Fact] - public void Test_178() - { - } - [Fact] - public void Test_179() - { - } - [Fact] - public void Test_180() - { - } - [Fact] - public void Test_181() - { - } - [Fact] - public void Test_182() - { - } - [Fact] - public void Test_183() - { - } - [Fact] - public void Test_184() - { - } - [Fact] - public void Test_185() - { - } - [Fact] - public void Test_186() - { - } - [Fact] - public void Test_187() - { - } - [Fact] - public void Test_188() - { - } - [Fact] - public void Test_189() - { - } - [Fact] - public void Test_190() - { - } - [Fact] - public void Test_191() - { - } - [Fact] - public void Test_192() - { - } - [Fact] - public void Test_193() - { - } - [Fact] - public void Test_194() - { - } - [Fact] - public void Test_195() - { - } - [Fact] - public void Test_196() - { - } - [Fact] - public void Test_197() - { - } - [Fact] - public void Test_198() - { - } - [Fact] - public void Test_199() - { - } - [Fact] - public void Test_200() - { - } - [Fact] - public void Test_201() - { - } - [Fact] - public void Test_202() - { - } - [Fact] - public void Test_203() - { - } - [Fact] - public void Test_204() - { - } - [Fact] - public void Test_205() - { - } - [Fact] - public void Test_206() - { - } - [Fact] - public void Test_207() - { - } - [Fact] - public void Test_208() - { - } - [Fact] - public void Test_209() - { - } - [Fact] - public void Test_210() - { - } - [Fact] - public void Test_211() - { - } - [Fact] - public void Test_212() - { - } - [Fact] - public void Test_213() - { - } - [Fact] - public void Test_214() - { - } - [Fact] - public void Test_215() - { - } - [Fact] - public void Test_216() - { - } - [Fact] - public void Test_217() - { - } - [Fact] - public void Test_218() - { - } - [Fact] - public void Test_219() - { - } - [Fact] - public void Test_220() - { - } - [Fact] - public void Test_221() - { - } - [Fact] - public void Test_222() - { - } - [Fact] - public void Test_223() - { - } - [Fact] - public void Test_224() - { - } - [Fact] - public void Test_225() - { - } - [Fact] - public void Test_226() - { - } - [Fact] - public void Test_227() - { - } - [Fact] - public void Test_228() - { - } - [Fact] - public void Test_229() - { - } - [Fact] - public void Test_230() - { - } - [Fact] - public void Test_231() - { - } - [Fact] - public void Test_232() - { - } - [Fact] - public void Test_233() - { - } - [Fact] - public void Test_234() - { - } - [Fact] - public void Test_235() - { - } - [Fact] - public void Test_236() - { - } - [Fact] - public void Test_237() - { - } - [Fact] - public void Test_238() - { - } - [Fact] - public void Test_239() - { - } - [Fact] - public void Test_240() - { - } - [Fact] - public void Test_241() - { - } - [Fact] - public void Test_242() - { - } - [Fact] - public void Test_243() - { - } - [Fact] - public void Test_244() - { - } - [Fact] - public void Test_245() - { - } - [Fact] - public void Test_246() - { - } - [Fact] - public void Test_247() - { - } - [Fact] - public void Test_248() - { - } - [Fact] - public void Test_249() - { - } - [Fact] - public void Test_250() - { - } - [Fact] - public void Test_251() - { - } - [Fact] - public void Test_252() - { - } - [Fact] - public void Test_253() - { - } - [Fact] - public void Test_254() - { - } - [Fact] - public void Test_255() - { - } - [Fact] - public void Test_256() - { - } - [Fact] - public void Test_257() - { - } - [Fact] - public void Test_258() - { - } - [Fact] - public void Test_259() - { - } - [Fact] - public void Test_260() - { - } - [Fact] - public void Test_261() - { - } - [Fact] - public void Test_262() - { - } - [Fact] - public void Test_263() - { - } - [Fact] - public void Test_264() - { - } - [Fact] - public void Test_265() - { - } - [Fact] - public void Test_266() - { - } - [Fact] - public void Test_267() - { - } - [Fact] - public void Test_268() - { - } - [Fact] - public void Test_269() - { - } - [Fact] - public void Test_270() - { - } - [Fact] - public void Test_271() - { - } - [Fact] - public void Test_272() - { - } - [Fact] - public void Test_273() - { - } - [Fact] - public void Test_274() - { - } - [Fact] - public void Test_275() - { - } - [Fact] - public void Test_276() - { - } - [Fact] - public void Test_277() - { - } - [Fact] - public void Test_278() - { - } - [Fact] - public void Test_279() - { - } - [Fact] - public void Test_280() - { - } - [Fact] - public void Test_281() - { - } - [Fact] - public void Test_282() - { - } - [Fact] - public void Test_283() - { - } - [Fact] - public void Test_284() - { - } - [Fact] - public void Test_285() - { - } - [Fact] - public void Test_286() - { - } - [Fact] - public void Test_287() - { - } - [Fact] - public void Test_288() - { - } - [Fact] - public void Test_289() - { - } - [Fact] - public void Test_290() - { - } - [Fact] - public void Test_291() - { - } - [Fact] - public void Test_292() - { - } - [Fact] - public void Test_293() - { - } - [Fact] - public void Test_294() - { - } - [Fact] - public void Test_295() - { - } - [Fact] - public void Test_296() - { - } - [Fact] - public void Test_297() - { - } - [Fact] - public void Test_298() - { - } - [Fact] - public void Test_299() - { - } - [Fact] - public void Test_300() - { - } - [Fact] - public void Test_301() - { - } - [Fact] - public void Test_302() - { - } - [Fact] - public void Test_303() - { - } - [Fact] - public void Test_304() - { - } - [Fact] - public void Test_305() - { - } - [Fact] - public void Test_306() - { - } - [Fact] - public void Test_307() - { - } - [Fact] - public void Test_308() - { - } - [Fact] - public void Test_309() - { - } - [Fact] - public void Test_310() - { - } - [Fact] - public void Test_311() - { - } - [Fact] - public void Test_312() - { - } - [Fact] - public void Test_313() - { - } - [Fact] - public void Test_314() - { - } - [Fact] - public void Test_315() - { - } - [Fact] - public void Test_316() - { - } - [Fact] - public void Test_317() - { - } - [Fact] - public void Test_318() - { - } - [Fact] - public void Test_319() - { - } - [Fact] - public void Test_320() - { - } - [Fact] - public void Test_321() - { - } - [Fact] - public void Test_322() - { - } - [Fact] - public void Test_323() - { - } - [Fact] - public void Test_324() - { - } - [Fact] - public void Test_325() - { - } - [Fact] - public void Test_326() - { - } - [Fact] - public void Test_327() - { - } - [Fact] - public void Test_328() - { - } - [Fact] - public void Test_329() - { - } - [Fact] - public void Test_330() - { - } - [Fact] - public void Test_331() - { - } - [Fact] - public void Test_332() - { - } - [Fact] - public void Test_333() - { - } - [Fact] - public void Test_334() - { - } - [Fact] - public void Test_335() - { - } - [Fact] - public void Test_336() - { - } - [Fact] - public void Test_337() - { - } - [Fact] - public void Test_338() - { - } - [Fact] - public void Test_339() - { - } - [Fact] - public void Test_340() - { - } - [Fact] - public void Test_341() - { - } - [Fact] - public void Test_342() - { - } - [Fact] - public void Test_343() - { - } - [Fact] - public void Test_344() - { - } - [Fact] - public void Test_345() - { - } - [Fact] - public void Test_346() - { - } - [Fact] - public void Test_347() - { - } - [Fact] - public void Test_348() - { - } - [Fact] - public void Test_349() - { - } - [Fact] - public void Test_350() - { - } - [Fact] - public void Test_351() - { - } - [Fact] - public void Test_352() - { - } - [Fact] - public void Test_353() - { - } - [Fact] - public void Test_354() - { - } - [Fact] - public void Test_355() - { - } - [Fact] - public void Test_356() - { - } - [Fact] - public void Test_357() - { - } - [Fact] - public void Test_358() - { - } - [Fact] - public void Test_359() - { - } - [Fact] - public void Test_360() - { - } - [Fact] - public void Test_361() - { - } - [Fact] - public void Test_362() - { - } - [Fact] - public void Test_363() - { - } - [Fact] - public void Test_364() - { - } - [Fact] - public void Test_365() - { - } - [Fact] - public void Test_366() - { - } - [Fact] - public void Test_367() - { - } - [Fact] - public void Test_368() - { - } - [Fact] - public void Test_369() - { - } - [Fact] - public void Test_370() - { - } - [Fact] - public void Test_371() - { - } - [Fact] - public void Test_372() - { - } - [Fact] - public void Test_373() - { - } - [Fact] - public void Test_374() - { - } - [Fact] - public void Test_375() - { - } - [Fact] - public void Test_376() - { - } - [Fact] - public void Test_377() - { - } - [Fact] - public void Test_378() - { - } - [Fact] - public void Test_379() - { - } - [Fact] - public void Test_380() - { - } - [Fact] - public void Test_381() - { - } - [Fact] - public void Test_382() - { - } - [Fact] - public void Test_383() - { - } - [Fact] - public void Test_384() - { - } - [Fact] - public void Test_385() - { - } - [Fact] - public void Test_386() - { - } - [Fact] - public void Test_387() - { - } - [Fact] - public void Test_388() - { - } - [Fact] - public void Test_389() - { - } - [Fact] - public void Test_390() - { - } - [Fact] - public void Test_391() - { - } - [Fact] - public void Test_392() - { - } - [Fact] - public void Test_393() - { - } - [Fact] - public void Test_394() - { - } - [Fact] - public void Test_395() - { - } - [Fact] - public void Test_396() - { - } - [Fact] - public void Test_397() - { - } - [Fact] - public void Test_398() - { - } - [Fact] - public void Test_399() - { - } - [Fact] - public void Test_400() - { - } - [Fact] - public void Test_401() - { - } - [Fact] - public void Test_402() - { - } - [Fact] - public void Test_403() - { - } - [Fact] - public void Test_404() - { - } - [Fact] - public void Test_405() - { - } - [Fact] - public void Test_406() - { - } - [Fact] - public void Test_407() - { - } - [Fact] - public void Test_408() - { - } - [Fact] - public void Test_409() - { - } - [Fact] - public void Test_410() - { - } - [Fact] - public void Test_411() - { - } - [Fact] - public void Test_412() - { - } - [Fact] - public void Test_413() - { - } - [Fact] - public void Test_414() - { - } - [Fact] - public void Test_415() - { - } - [Fact] - public void Test_416() - { - } - [Fact] - public void Test_417() - { - } - [Fact] - public void Test_418() - { - } - [Fact] - public void Test_419() - { - } - [Fact] - public void Test_420() - { - } - [Fact] - public void Test_421() - { - } - [Fact] - public void Test_422() - { - } - [Fact] - public void Test_423() - { - } - [Fact] - public void Test_424() - { - } - [Fact] - public void Test_425() - { - } - [Fact] - public void Test_426() - { - } - [Fact] - public void Test_427() - { - } - [Fact] - public void Test_428() - { - } - [Fact] - public void Test_429() - { - } - [Fact] - public void Test_430() - { - } - [Fact] - public void Test_431() - { - } - [Fact] - public void Test_432() - { - } - [Fact] - public void Test_433() - { - } - [Fact] - public void Test_434() - { - } - [Fact] - public void Test_435() - { - } - [Fact] - public void Test_436() - { - } - [Fact] - public void Test_437() - { - } - [Fact] - public void Test_438() - { - } - [Fact] - public void Test_439() - { - } - [Fact] - public void Test_440() - { - } - [Fact] - public void Test_441() - { - } - [Fact] - public void Test_442() - { - } - [Fact] - public void Test_443() - { - } - [Fact] - public void Test_444() - { - } - [Fact] - public void Test_445() - { - } - [Fact] - public void Test_446() - { - } - [Fact] - public void Test_447() - { - } - [Fact] - public void Test_448() - { - } - [Fact] - public void Test_449() - { - } - [Fact] - public void Test_450() - { - } - [Fact] - public void Test_451() - { - } - [Fact] - public void Test_452() - { - } - [Fact] - public void Test_453() - { - } - [Fact] - public void Test_454() - { - } - [Fact] - public void Test_455() - { - } - [Fact] - public void Test_456() - { - } - [Fact] - public void Test_457() - { - } - [Fact] - public void Test_458() - { - } - [Fact] - public void Test_459() - { - } - [Fact] - public void Test_460() - { - } - [Fact] - public void Test_461() - { - } - [Fact] - public void Test_462() - { - } - [Fact] - public void Test_463() - { - } - [Fact] - public void Test_464() - { - } - [Fact] - public void Test_465() - { - } - [Fact] - public void Test_466() - { - } - [Fact] - public void Test_467() - { - } - [Fact] - public void Test_468() - { - } - [Fact] - public void Test_469() - { - } - [Fact] - public void Test_470() - { - } - [Fact] - public void Test_471() - { - } - [Fact] - public void Test_472() - { - } - [Fact] - public void Test_473() - { - } - [Fact] - public void Test_474() - { - } - [Fact] - public void Test_475() - { - } - [Fact] - public void Test_476() - { - } - [Fact] - public void Test_477() - { - } - [Fact] - public void Test_478() - { - } - [Fact] - public void Test_479() - { - } - [Fact] - public void Test_480() - { - } - [Fact] - public void Test_481() - { - } - [Fact] - public void Test_482() - { - } - [Fact] - public void Test_483() - { - } - [Fact] - public void Test_484() - { - } - [Fact] - public void Test_485() - { - } - [Fact] - public void Test_486() - { - } - [Fact] - public void Test_487() - { - } - [Fact] - public void Test_488() - { - } - [Fact] - public void Test_489() - { - } - [Fact] - public void Test_490() - { - } - [Fact] - public void Test_491() - { - } - [Fact] - public void Test_492() - { - } - [Fact] - public void Test_493() - { - } - [Fact] - public void Test_494() - { - } - [Fact] - public void Test_495() - { - } - [Fact] - public void Test_496() - { - } - [Fact] - public void Test_497() - { - } - [Fact] - public void Test_498() - { - } - [Fact] - public void Test_499() - { - } - [Fact] - public void Test_500() - { - } - [Fact] - public void Test_501() - { - } - [Fact] - public void Test_502() - { - } - [Fact] - public void Test_503() - { - } - [Fact] - public void Test_504() - { - } - [Fact] - public void Test_505() - { - } - [Fact] - public void Test_506() - { - } - [Fact] - public void Test_507() - { - } - [Fact] - public void Test_508() - { - } - [Fact] - public void Test_509() - { - } - [Fact] - public void Test_510() - { - } - [Fact] - public void Test_511() - { - } - [Fact] - public void Test_512() - { - } - [Fact] - public void Test_513() - { - } - [Fact] - public void Test_514() - { - } - [Fact] - public void Test_515() - { - } - [Fact] - public void Test_516() - { - } - [Fact] - public void Test_517() - { - } - [Fact] - public void Test_518() - { - } - [Fact] - public void Test_519() - { - } - [Fact] - public void Test_520() - { - } - [Fact] - public void Test_521() - { - } - [Fact] - public void Test_522() - { - } - [Fact] - public void Test_523() - { - } - [Fact] - public void Test_524() - { - } - [Fact] - public void Test_525() - { - } - [Fact] - public void Test_526() - { - } - [Fact] - public void Test_527() - { - } - [Fact] - public void Test_528() - { - } - [Fact] - public void Test_529() - { - } - [Fact] - public void Test_530() - { - } - [Fact] - public void Test_531() - { - } - [Fact] - public void Test_532() - { - } - [Fact] - public void Test_533() - { - } - [Fact] - public void Test_534() - { - } - [Fact] - public void Test_535() - { - } - [Fact] - public void Test_536() - { - } - [Fact] - public void Test_537() - { - } - [Fact] - public void Test_538() - { - } - [Fact] - public void Test_539() - { - } - [Fact] - public void Test_540() - { - } - [Fact] - public void Test_541() - { - } - [Fact] - public void Test_542() - { - } - [Fact] - public void Test_543() - { - } - [Fact] - public void Test_544() - { - } - [Fact] - public void Test_545() - { - } - [Fact] - public void Test_546() - { - } - [Fact] - public void Test_547() - { - } - [Fact] - public void Test_548() - { - } - [Fact] - public void Test_549() - { - } - [Fact] - public void Test_550() - { - } - [Fact] - public void Test_551() - { - } - [Fact] - public void Test_552() - { - } - [Fact] - public void Test_553() - { - } - [Fact] - public void Test_554() - { - } - [Fact] - public void Test_555() - { - } - [Fact] - public void Test_556() - { - } - [Fact] - public void Test_557() - { - } - [Fact] - public void Test_558() - { - } - [Fact] - public void Test_559() - { - } - [Fact] - public void Test_560() - { - } - [Fact] - public void Test_561() - { - } - [Fact] - public void Test_562() - { - } - [Fact] - public void Test_563() - { - } - [Fact] - public void Test_564() - { - } - [Fact] - public void Test_565() - { - } - [Fact] - public void Test_566() - { - } - [Fact] - public void Test_567() - { - } - [Fact] - public void Test_568() - { - } - [Fact] - public void Test_569() - { - } - [Fact] - public void Test_570() - { - } - [Fact] - public void Test_571() - { - } - [Fact] - public void Test_572() - { - } - [Fact] - public void Test_573() - { - } - [Fact] - public void Test_574() - { - } - [Fact] - public void Test_575() - { - } - [Fact] - public void Test_576() - { - } - [Fact] - public void Test_577() - { - } - [Fact] - public void Test_578() - { - } - [Fact] - public void Test_579() - { - } - [Fact] - public void Test_580() - { - } - [Fact] - public void Test_581() - { - } - [Fact] - public void Test_582() - { - } - [Fact] - public void Test_583() - { - } - [Fact] - public void Test_584() - { - } - [Fact] - public void Test_585() - { - } - [Fact] - public void Test_586() - { - } - [Fact] - public void Test_587() - { - } - [Fact] - public void Test_588() - { - } - [Fact] - public void Test_589() - { - } - [Fact] - public void Test_590() - { - } - [Fact] - public void Test_591() - { - } - [Fact] - public void Test_592() - { - } - [Fact] - public void Test_593() - { - } - [Fact] - public void Test_594() - { - } - [Fact] - public void Test_595() - { - } - [Fact] - public void Test_596() - { - } - [Fact] - public void Test_597() - { - } - [Fact] - public void Test_598() - { - } - [Fact] - public void Test_599() - { - } - [Fact] - public void Test_600() - { - } - [Fact] - public void Test_601() - { - } - [Fact] - public void Test_602() - { - } - [Fact] - public void Test_603() - { - } - [Fact] - public void Test_604() - { - } - [Fact] - public void Test_605() - { - } - [Fact] - public void Test_606() - { - } - [Fact] - public void Test_607() - { - } - [Fact] - public void Test_608() - { - } - [Fact] - public void Test_609() - { - } - [Fact] - public void Test_610() - { - } - [Fact] - public void Test_611() - { - } - [Fact] - public void Test_612() - { - } - [Fact] - public void Test_613() - { - } - [Fact] - public void Test_614() - { - } - [Fact] - public void Test_615() - { - } - [Fact] - public void Test_616() - { - } - [Fact] - public void Test_617() - { - } - [Fact] - public void Test_618() - { - } - [Fact] - public void Test_619() - { - } - [Fact] - public void Test_620() - { - } - [Fact] - public void Test_621() - { - } - [Fact] - public void Test_622() - { - } - [Fact] - public void Test_623() - { - } - [Fact] - public void Test_624() - { - } - [Fact] - public void Test_625() - { - } - [Fact] - public void Test_626() - { - } - [Fact] - public void Test_627() - { - } - [Fact] - public void Test_628() - { - } - [Fact] - public void Test_629() - { - } - [Fact] - public void Test_630() - { - } - [Fact] - public void Test_631() - { - } - [Fact] - public void Test_632() - { - } - [Fact] - public void Test_633() - { - } - [Fact] - public void Test_634() - { - } - [Fact] - public void Test_635() - { - } - [Fact] - public void Test_636() - { - } - [Fact] - public void Test_637() - { - } - [Fact] - public void Test_638() - { - } - [Fact] - public void Test_639() - { - } - [Fact] - public void Test_640() - { - } - [Fact] - public void Test_641() - { - } - [Fact] - public void Test_642() - { - } - [Fact] - public void Test_643() - { - } - [Fact] - public void Test_644() - { - } - [Fact] - public void Test_645() - { - } - [Fact] - public void Test_646() - { - } - [Fact] - public void Test_647() - { - } - [Fact] - public void Test_648() - { - } - [Fact] - public void Test_649() - { - } - [Fact] - public void Test_650() - { - } - [Fact] - public void Test_651() - { - } - [Fact] - public void Test_652() - { - } - [Fact] - public void Test_653() - { - } - [Fact] - public void Test_654() - { - } - [Fact] - public void Test_655() - { - } - [Fact] - public void Test_656() - { - } - [Fact] - public void Test_657() - { - } - [Fact] - public void Test_658() - { - } - [Fact] - public void Test_659() - { - } - [Fact] - public void Test_660() - { - } - [Fact] - public void Test_661() - { - } - [Fact] - public void Test_662() - { - } - [Fact] - public void Test_663() - { - } - [Fact] - public void Test_664() - { - } - [Fact] - public void Test_665() - { - } - [Fact] - public void Test_666() - { - } - [Fact] - public void Test_667() - { - } - [Fact] - public void Test_668() - { - } - [Fact] - public void Test_669() - { - } - [Fact] - public void Test_670() - { - } - [Fact] - public void Test_671() - { - } - [Fact] - public void Test_672() - { - } - [Fact] - public void Test_673() - { - } - [Fact] - public void Test_674() - { - } - [Fact] - public void Test_675() - { - } - [Fact] - public void Test_676() - { - } - [Fact] - public void Test_677() - { - } - [Fact] - public void Test_678() - { - } - [Fact] - public void Test_679() - { - } - [Fact] - public void Test_680() - { - } - [Fact] - public void Test_681() - { - } - [Fact] - public void Test_682() - { - } - [Fact] - public void Test_683() - { - } - [Fact] - public void Test_684() - { - } - [Fact] - public void Test_685() - { - } - [Fact] - public void Test_686() - { - } - [Fact] - public void Test_687() - { - } - [Fact] - public void Test_688() - { - } - [Fact] - public void Test_689() - { - } - [Fact] - public void Test_690() - { - } - [Fact] - public void Test_691() - { - } - [Fact] - public void Test_692() - { - } - [Fact] - public void Test_693() - { - } - [Fact] - public void Test_694() - { - } - [Fact] - public void Test_695() - { - } - [Fact] - public void Test_696() - { - } - [Fact] - public void Test_697() - { - } - [Fact] - public void Test_698() - { - } - [Fact] - public void Test_699() - { - } - [Fact] - public void Test_700() - { - } - [Fact] - public void Test_701() - { - } - [Fact] - public void Test_702() - { - } - [Fact] - public void Test_703() - { - } - [Fact] - public void Test_704() - { - } - [Fact] - public void Test_705() - { - } - [Fact] - public void Test_706() - { - } - [Fact] - public void Test_707() - { - } - [Fact] - public void Test_708() - { - } - [Fact] - public void Test_709() - { - } - [Fact] - public void Test_710() - { - } - [Fact] - public void Test_711() - { - } - [Fact] - public void Test_712() - { - } - [Fact] - public void Test_713() - { - } - [Fact] - public void Test_714() - { - } - [Fact] - public void Test_715() - { - } - [Fact] - public void Test_716() - { - } - [Fact] - public void Test_717() - { - } - [Fact] - public void Test_718() - { - } - [Fact] - public void Test_719() - { - } - [Fact] - public void Test_720() - { - } - [Fact] - public void Test_721() - { - } - [Fact] - public void Test_722() - { - } - [Fact] - public void Test_723() - { - } - [Fact] - public void Test_724() - { - } - [Fact] - public void Test_725() - { - } - [Fact] - public void Test_726() - { - } - [Fact] - public void Test_727() - { - } - [Fact] - public void Test_728() - { - } - [Fact] - public void Test_729() - { - } - [Fact] - public void Test_730() - { - } - [Fact] - public void Test_731() - { - } - [Fact] - public void Test_732() - { - } - [Fact] - public void Test_733() - { - } - [Fact] - public void Test_734() - { - } - [Fact] - public void Test_735() - { - } - [Fact] - public void Test_736() - { - } - [Fact] - public void Test_737() - { - } - [Fact] - public void Test_738() - { - } - [Fact] - public void Test_739() - { - } - [Fact] - public void Test_740() - { - } - [Fact] - public void Test_741() - { - } - [Fact] - public void Test_742() - { - } - [Fact] - public void Test_743() - { - } - [Fact] - public void Test_744() - { - } - [Fact] - public void Test_745() - { - } - [Fact] - public void Test_746() - { - } - [Fact] - public void Test_747() - { - } - [Fact] - public void Test_748() - { - } - [Fact] - public void Test_749() - { - } - [Fact] - public void Test_750() - { - } - [Fact] - public void Test_751() - { - } - [Fact] - public void Test_752() - { - } - [Fact] - public void Test_753() - { - } - [Fact] - public void Test_754() - { - } - [Fact] - public void Test_755() - { - } - [Fact] - public void Test_756() - { - } - [Fact] - public void Test_757() - { - } - [Fact] - public void Test_758() - { - } - [Fact] - public void Test_759() - { - } - [Fact] - public void Test_760() - { - } - [Fact] - public void Test_761() - { - } - [Fact] - public void Test_762() - { - } - [Fact] - public void Test_763() - { - } - [Fact] - public void Test_764() - { - } - [Fact] - public void Test_765() - { - } - [Fact] - public void Test_766() - { - } - [Fact] - public void Test_767() - { - } - [Fact] - public void Test_768() - { - } - [Fact] - public void Test_769() - { - } - [Fact] - public void Test_770() - { - } - [Fact] - public void Test_771() - { - } - [Fact] - public void Test_772() - { - } - [Fact] - public void Test_773() - { - } - [Fact] - public void Test_774() - { - } - [Fact] - public void Test_775() - { - } - [Fact] - public void Test_776() - { - } - [Fact] - public void Test_777() - { - } - [Fact] - public void Test_778() - { - } - [Fact] - public void Test_779() - { - } - [Fact] - public void Test_780() - { - } - [Fact] - public void Test_781() - { - } - [Fact] - public void Test_782() - { - } - [Fact] - public void Test_783() - { - } - [Fact] - public void Test_784() - { - } - [Fact] - public void Test_785() - { - } - [Fact] - public void Test_786() - { - } - [Fact] - public void Test_787() - { - } - [Fact] - public void Test_788() - { - } - [Fact] - public void Test_789() - { - } - [Fact] - public void Test_790() - { - } - [Fact] - public void Test_791() - { - } - [Fact] - public void Test_792() - { - } - [Fact] - public void Test_793() - { - } - [Fact] - public void Test_794() - { - } - [Fact] - public void Test_795() - { - } - [Fact] - public void Test_796() - { - } - [Fact] - public void Test_797() - { - } - [Fact] - public void Test_798() - { - } - [Fact] - public void Test_799() - { - } - [Fact] - public void Test_800() - { - } - [Fact] - public void Test_801() - { - } - [Fact] - public void Test_802() - { - } - [Fact] - public void Test_803() - { - } - [Fact] - public void Test_804() - { - } - [Fact] - public void Test_805() - { - } - [Fact] - public void Test_806() - { - } - [Fact] - public void Test_807() - { - } - [Fact] - public void Test_808() - { - } - [Fact] - public void Test_809() - { - } - [Fact] - public void Test_810() - { - } - [Fact] - public void Test_811() - { - } - [Fact] - public void Test_812() - { - } - [Fact] - public void Test_813() - { - } - [Fact] - public void Test_814() - { - } - [Fact] - public void Test_815() - { - } - [Fact] - public void Test_816() - { - } - [Fact] - public void Test_817() - { - } - [Fact] - public void Test_818() - { - } - [Fact] - public void Test_819() - { - } - [Fact] - public void Test_820() - { - } - [Fact] - public void Test_821() - { - } - [Fact] - public void Test_822() - { - } - [Fact] - public void Test_823() - { - } - [Fact] - public void Test_824() - { - } - [Fact] - public void Test_825() - { - } - [Fact] - public void Test_826() - { - } - [Fact] - public void Test_827() - { - } - [Fact] - public void Test_828() - { - } - [Fact] - public void Test_829() - { - } - [Fact] - public void Test_830() - { - } - [Fact] - public void Test_831() - { - } - [Fact] - public void Test_832() - { - } - [Fact] - public void Test_833() - { - } - [Fact] - public void Test_834() - { - } - [Fact] - public void Test_835() - { - } - [Fact] - public void Test_836() - { - } - [Fact] - public void Test_837() - { - } - [Fact] - public void Test_838() - { - } - [Fact] - public void Test_839() - { - } - [Fact] - public void Test_840() - { - } - [Fact] - public void Test_841() - { - } - [Fact] - public void Test_842() - { - } - [Fact] - public void Test_843() - { - } - [Fact] - public void Test_844() - { - } - [Fact] - public void Test_845() - { - } - [Fact] - public void Test_846() - { - } - [Fact] - public void Test_847() - { - } - [Fact] - public void Test_848() - { - } - [Fact] - public void Test_849() - { - } - [Fact] - public void Test_850() - { - } - [Fact] - public void Test_851() - { - } - [Fact] - public void Test_852() - { - } - [Fact] - public void Test_853() - { - } - [Fact] - public void Test_854() - { - } - [Fact] - public void Test_855() - { - } - [Fact] - public void Test_856() - { - } - [Fact] - public void Test_857() - { - } - [Fact] - public void Test_858() - { - } - [Fact] - public void Test_859() - { - } - [Fact] - public void Test_860() - { - } - [Fact] - public void Test_861() - { - } - [Fact] - public void Test_862() - { - } - [Fact] - public void Test_863() - { - } - [Fact] - public void Test_864() - { - } - [Fact] - public void Test_865() - { - } - [Fact] - public void Test_866() - { - } - [Fact] - public void Test_867() - { - } - [Fact] - public void Test_868() - { - } - [Fact] - public void Test_869() - { - } - [Fact] - public void Test_870() - { - } - [Fact] - public void Test_871() - { - } - [Fact] - public void Test_872() - { - } - [Fact] - public void Test_873() - { - } - [Fact] - public void Test_874() - { - } - [Fact] - public void Test_875() - { - } - [Fact] - public void Test_876() - { - } - [Fact] - public void Test_877() - { - } - [Fact] - public void Test_878() - { - } - [Fact] - public void Test_879() - { - } - [Fact] - public void Test_880() - { - } - [Fact] - public void Test_881() - { - } - [Fact] - public void Test_882() - { - } - [Fact] - public void Test_883() - { - } - [Fact] - public void Test_884() - { - } - [Fact] - public void Test_885() - { - } - [Fact] - public void Test_886() - { - } - [Fact] - public void Test_887() - { - } - [Fact] - public void Test_888() - { - } - [Fact] - public void Test_889() - { - } - [Fact] - public void Test_890() - { - } - [Fact] - public void Test_891() - { - } - [Fact] - public void Test_892() - { - } - [Fact] - public void Test_893() - { - } - [Fact] - public void Test_894() - { - } - [Fact] - public void Test_895() - { - } - [Fact] - public void Test_896() - { - } - [Fact] - public void Test_897() - { - } - [Fact] - public void Test_898() - { - } - [Fact] - public void Test_899() - { - } - [Fact] - public void Test_900() - { - } - [Fact] - public void Test_901() - { - } - [Fact] - public void Test_902() - { - } - [Fact] - public void Test_903() - { - } - [Fact] - public void Test_904() - { - } - [Fact] - public void Test_905() - { - } - [Fact] - public void Test_906() - { - } - [Fact] - public void Test_907() - { - } - [Fact] - public void Test_908() - { - } - [Fact] - public void Test_909() - { - } - [Fact] - public void Test_910() - { - } - [Fact] - public void Test_911() - { - } - [Fact] - public void Test_912() - { - } - [Fact] - public void Test_913() - { - } - [Fact] - public void Test_914() - { - } - [Fact] - public void Test_915() - { - } - [Fact] - public void Test_916() - { - } - [Fact] - public void Test_917() - { - } - [Fact] - public void Test_918() - { - } - [Fact] - public void Test_919() - { - } - [Fact] - public void Test_920() - { - } - [Fact] - public void Test_921() - { - } - [Fact] - public void Test_922() - { - } - [Fact] - public void Test_923() - { - } - [Fact] - public void Test_924() - { - } - [Fact] - public void Test_925() - { - } - [Fact] - public void Test_926() - { - } - [Fact] - public void Test_927() - { - } - [Fact] - public void Test_928() - { - } - [Fact] - public void Test_929() - { - } - [Fact] - public void Test_930() - { - } - [Fact] - public void Test_931() - { - } - [Fact] - public void Test_932() - { - } - [Fact] - public void Test_933() - { - } - [Fact] - public void Test_934() - { - } - [Fact] - public void Test_935() - { - } - [Fact] - public void Test_936() - { - } - [Fact] - public void Test_937() - { - } - [Fact] - public void Test_938() - { - } - [Fact] - public void Test_939() - { - } - [Fact] - public void Test_940() - { - } - [Fact] - public void Test_941() - { - } - [Fact] - public void Test_942() - { - } - [Fact] - public void Test_943() - { - } - [Fact] - public void Test_944() - { - } - [Fact] - public void Test_945() - { - } - [Fact] - public void Test_946() - { - } - [Fact] - public void Test_947() - { - } - [Fact] - public void Test_948() - { - } - [Fact] - public void Test_949() - { - } - [Fact] - public void Test_950() - { - } - [Fact] - public void Test_951() - { - } - [Fact] - public void Test_952() - { - } - [Fact] - public void Test_953() - { - } - [Fact] - public void Test_954() - { - } - [Fact] - public void Test_955() - { - } - [Fact] - public void Test_956() - { - } - [Fact] - public void Test_957() - { - } - [Fact] - public void Test_958() - { - } - [Fact] - public void Test_959() - { - } - [Fact] - public void Test_960() - { - } - [Fact] - public void Test_961() - { - } - [Fact] - public void Test_962() - { - } - [Fact] - public void Test_963() - { - } - [Fact] - public void Test_964() - { - } - [Fact] - public void Test_965() - { - } - [Fact] - public void Test_966() - { - } - [Fact] - public void Test_967() - { - } - [Fact] - public void Test_968() - { - } - [Fact] - public void Test_969() - { - } - [Fact] - public void Test_970() - { - } - [Fact] - public void Test_971() - { - } - [Fact] - public void Test_972() - { - } - [Fact] - public void Test_973() - { - } - [Fact] - public void Test_974() - { - } - [Fact] - public void Test_975() - { - } - [Fact] - public void Test_976() - { - } - [Fact] - public void Test_977() - { - } - [Fact] - public void Test_978() - { - } - [Fact] - public void Test_979() - { - } - [Fact] - public void Test_980() - { - } - [Fact] - public void Test_981() - { - } - [Fact] - public void Test_982() - { - } - [Fact] - public void Test_983() - { - } - [Fact] - public void Test_984() - { - } - [Fact] - public void Test_985() - { - } - [Fact] - public void Test_986() - { - } - [Fact] - public void Test_987() - { - } - [Fact] - public void Test_988() - { - } - [Fact] - public void Test_989() - { - } - [Fact] - public void Test_990() - { - } - [Fact] - public void Test_991() - { - } - [Fact] - public void Test_992() - { - } - [Fact] - public void Test_993() - { - } - [Fact] - public void Test_994() - { - } - [Fact] - public void Test_995() - { - } - [Fact] - public void Test_996() - { - } - [Fact] - public void Test_997() - { - } - [Fact] - public void Test_998() - { - } - [Fact] - public void Test_999() - { - } - [Fact] - public void Test_1000() - { - } - [Fact] - public void Test_1001() - { - } - [Fact] - public void Test_1002() - { - } - [Fact] - public void Test_1003() - { - } - [Fact] - public void Test_1004() - { - } - [Fact] - public void Test_1005() - { - } - [Fact] - public void Test_1006() - { - } - [Fact] - public void Test_1007() - { - } - [Fact] - public void Test_1008() - { - } - [Fact] - public void Test_1009() - { - } - [Fact] - public void Test_1010() - { - } - [Fact] - public void Test_1011() - { - } - [Fact] - public void Test_1012() - { - } - [Fact] - public void Test_1013() - { - } - [Fact] - public void Test_1014() - { - } - [Fact] - public void Test_1015() - { - } - [Fact] - public void Test_1016() - { - } - [Fact] - public void Test_1017() - { - } - [Fact] - public void Test_1018() - { - } - [Fact] - public void Test_1019() - { - } - [Fact] - public void Test_1020() - { - } - [Fact] - public void Test_1021() - { - } - [Fact] - public void Test_1022() - { - } - [Fact] - public void Test_1023() - { - } - [Fact] - public void Test_1024() - { - } - [Fact] - public void Test_1025() - { - } - [Fact] - public void Test_1026() - { - } - [Fact] - public void Test_1027() - { - } - [Fact] - public void Test_1028() - { - } - [Fact] - public void Test_1029() - { - } - [Fact] - public void Test_1030() - { - } - [Fact] - public void Test_1031() - { - } - [Fact] - public void Test_1032() - { - } - [Fact] - public void Test_1033() - { - } - [Fact] - public void Test_1034() - { - } - [Fact] - public void Test_1035() - { - } - [Fact] - public void Test_1036() - { - } - [Fact] - public void Test_1037() - { - } - [Fact] - public void Test_1038() - { - } - [Fact] - public void Test_1039() - { - } - [Fact] - public void Test_1040() - { - } - [Fact] - public void Test_1041() - { - } - [Fact] - public void Test_1042() - { - } - [Fact] - public void Test_1043() - { - } - [Fact] - public void Test_1044() - { - } - [Fact] - public void Test_1045() - { - } - [Fact] - public void Test_1046() - { - } - [Fact] - public void Test_1047() - { - } - [Fact] - public void Test_1048() - { - } - [Fact] - public void Test_1049() - { - } - [Fact] - public void Test_1050() - { - } - [Fact] - public void Test_1051() - { - } - [Fact] - public void Test_1052() - { - } - [Fact] - public void Test_1053() - { - } - [Fact] - public void Test_1054() - { - } - [Fact] - public void Test_1055() - { - } - [Fact] - public void Test_1056() - { - } - [Fact] - public void Test_1057() - { - } - [Fact] - public void Test_1058() - { - } - [Fact] - public void Test_1059() - { - } - [Fact] - public void Test_1060() - { - } - [Fact] - public void Test_1061() - { - } - [Fact] - public void Test_1062() - { - } - [Fact] - public void Test_1063() - { - } - [Fact] - public void Test_1064() - { - } - [Fact] - public void Test_1065() - { - } - [Fact] - public void Test_1066() - { - } - [Fact] - public void Test_1067() - { - } - [Fact] - public void Test_1068() - { - } - [Fact] - public void Test_1069() - { - } - [Fact] - public void Test_1070() - { - } - [Fact] - public void Test_1071() - { - } - [Fact] - public void Test_1072() - { - } - [Fact] - public void Test_1073() - { - } - [Fact] - public void Test_1074() - { - } - [Fact] - public void Test_1075() - { - } - [Fact] - public void Test_1076() - { - } - [Fact] - public void Test_1077() - { - } - [Fact] - public void Test_1078() - { - } - [Fact] - public void Test_1079() - { - } - [Fact] - public void Test_1080() - { - } - [Fact] - public void Test_1081() - { - } - [Fact] - public void Test_1082() - { - } - [Fact] - public void Test_1083() - { - } - [Fact] - public void Test_1084() - { - } - [Fact] - public void Test_1085() - { - } - [Fact] - public void Test_1086() - { - } - [Fact] - public void Test_1087() - { - } - [Fact] - public void Test_1088() - { - } - [Fact] - public void Test_1089() - { - } - [Fact] - public void Test_1090() - { - } - [Fact] - public void Test_1091() - { - } - [Fact] - public void Test_1092() - { - } - [Fact] - public void Test_1093() - { - } - [Fact] - public void Test_1094() - { - } - [Fact] - public void Test_1095() - { - } - [Fact] - public void Test_1096() - { - } - [Fact] - public void Test_1097() - { - } - [Fact] - public void Test_1098() - { - } - [Fact] - public void Test_1099() - { - } - [Fact] - public void Test_1100() - { - } - [Fact] - public void Test_1101() - { - } - [Fact] - public void Test_1102() - { - } - [Fact] - public void Test_1103() - { - } - [Fact] - public void Test_1104() - { - } - [Fact] - public void Test_1105() - { - } - [Fact] - public void Test_1106() - { - } - [Fact] - public void Test_1107() - { - } - [Fact] - public void Test_1108() - { - } - [Fact] - public void Test_1109() - { - } - [Fact] - public void Test_1110() - { - } - [Fact] - public void Test_1111() - { - } - [Fact] - public void Test_1112() - { - } - [Fact] - public void Test_1113() - { - } - [Fact] - public void Test_1114() - { - } - [Fact] - public void Test_1115() - { - } - [Fact] - public void Test_1116() - { - } - [Fact] - public void Test_1117() - { - } - [Fact] - public void Test_1118() - { - } - [Fact] - public void Test_1119() - { - } - [Fact] - public void Test_1120() - { - } - [Fact] - public void Test_1121() - { - } - [Fact] - public void Test_1122() - { - } - [Fact] - public void Test_1123() - { - } - [Fact] - public void Test_1124() - { - } - [Fact] - public void Test_1125() - { - } - [Fact] - public void Test_1126() - { - } - [Fact] - public void Test_1127() - { - } - [Fact] - public void Test_1128() - { - } - [Fact] - public void Test_1129() - { - } - [Fact] - public void Test_1130() - { - } - [Fact] - public void Test_1131() - { - } - [Fact] - public void Test_1132() - { - } - [Fact] - public void Test_1133() - { - } - [Fact] - public void Test_1134() - { - } - [Fact] - public void Test_1135() - { - } - [Fact] - public void Test_1136() - { - } - [Fact] - public void Test_1137() - { - } - [Fact] - public void Test_1138() - { - } - [Fact] - public void Test_1139() - { - } - [Fact] - public void Test_1140() - { - } - [Fact] - public void Test_1141() - { - } - [Fact] - public void Test_1142() - { - } - [Fact] - public void Test_1143() - { - } - [Fact] - public void Test_1144() - { - } - [Fact] - public void Test_1145() - { - } - [Fact] - public void Test_1146() - { - } - [Fact] - public void Test_1147() - { - } - [Fact] - public void Test_1148() - { - } - [Fact] - public void Test_1149() - { - } - [Fact] - public void Test_1150() - { - } - [Fact] - public void Test_1151() - { - } - [Fact] - public void Test_1152() - { - } - [Fact] - public void Test_1153() - { - } - [Fact] - public void Test_1154() - { - } - [Fact] - public void Test_1155() - { - } - [Fact] - public void Test_1156() - { - } - [Fact] - public void Test_1157() - { - } - [Fact] - public void Test_1158() - { - } - [Fact] - public void Test_1159() - { - } - [Fact] - public void Test_1160() - { - } - [Fact] - public void Test_1161() - { - } - [Fact] - public void Test_1162() - { - } - [Fact] - public void Test_1163() - { - } - [Fact] - public void Test_1164() - { - } - [Fact] - public void Test_1165() - { - } - [Fact] - public void Test_1166() - { - } - [Fact] - public void Test_1167() - { - } - [Fact] - public void Test_1168() - { - } - [Fact] - public void Test_1169() - { - } - [Fact] - public void Test_1170() - { - } - [Fact] - public void Test_1171() - { - } - [Fact] - public void Test_1172() - { - } - [Fact] - public void Test_1173() - { - } - [Fact] - public void Test_1174() - { - } - [Fact] - public void Test_1175() - { - } - [Fact] - public void Test_1176() - { - } - [Fact] - public void Test_1177() - { - } - [Fact] - public void Test_1178() - { - } - [Fact] - public void Test_1179() - { - } - [Fact] - public void Test_1180() - { - } - [Fact] - public void Test_1181() - { - } - [Fact] - public void Test_1182() - { - } - [Fact] - public void Test_1183() - { - } - [Fact] - public void Test_1184() - { - } - [Fact] - public void Test_1185() - { - } - [Fact] - public void Test_1186() - { - } - [Fact] - public void Test_1187() - { - } - [Fact] - public void Test_1188() - { - } - [Fact] - public void Test_1189() - { - } - [Fact] - public void Test_1190() - { - } - [Fact] - public void Test_1191() - { - } - [Fact] - public void Test_1192() - { - } - [Fact] - public void Test_1193() - { - } - [Fact] - public void Test_1194() - { - } - [Fact] - public void Test_1195() - { - } - [Fact] - public void Test_1196() - { - } - [Fact] - public void Test_1197() - { - } - [Fact] - public void Test_1198() - { - } - [Fact] - public void Test_1199() - { - } - [Fact] - public void Test_1200() - { - } - [Fact] - public void Test_1201() - { - } - [Fact] - public void Test_1202() - { - } - [Fact] - public void Test_1203() - { - } - [Fact] - public void Test_1204() - { - } - [Fact] - public void Test_1205() - { - } - [Fact] - public void Test_1206() - { - } - [Fact] - public void Test_1207() - { - } - [Fact] - public void Test_1208() - { - } - [Fact] - public void Test_1209() - { - } - [Fact] - public void Test_1210() - { - } - [Fact] - public void Test_1211() - { - } - [Fact] - public void Test_1212() - { - } - [Fact] - public void Test_1213() - { - } - [Fact] - public void Test_1214() - { - } - [Fact] - public void Test_1215() - { - } - [Fact] - public void Test_1216() - { - } - [Fact] - public void Test_1217() - { - } - [Fact] - public void Test_1218() - { - } - [Fact] - public void Test_1219() - { - } - [Fact] - public void Test_1220() - { - } - [Fact] - public void Test_1221() - { - } - [Fact] - public void Test_1222() - { - } - [Fact] - public void Test_1223() - { - } - [Fact] - public void Test_1224() - { - } - [Fact] - public void Test_1225() - { - } - [Fact] - public void Test_1226() - { - } - [Fact] - public void Test_1227() - { - } - [Fact] - public void Test_1228() - { - } - [Fact] - public void Test_1229() - { - } - [Fact] - public void Test_1230() - { - } - [Fact] - public void Test_1231() - { - } - [Fact] - public void Test_1232() - { - } - [Fact] - public void Test_1233() - { - } - [Fact] - public void Test_1234() - { - } - [Fact] - public void Test_1235() - { - } - [Fact] - public void Test_1236() - { - } - [Fact] - public void Test_1237() - { - } - [Fact] - public void Test_1238() - { - } - [Fact] - public void Test_1239() - { - } - [Fact] - public void Test_1240() - { - } - [Fact] - public void Test_1241() - { - } - [Fact] - public void Test_1242() - { - } - [Fact] - public void Test_1243() - { - } - [Fact] - public void Test_1244() - { - } - [Fact] - public void Test_1245() - { - } - [Fact] - public void Test_1246() - { - } - [Fact] - public void Test_1247() - { - } - [Fact] - public void Test_1248() - { - } - [Fact] - public void Test_1249() - { - } - [Fact] - public void Test_1250() - { - } - [Fact] - public void Test_1251() - { - } - [Fact] - public void Test_1252() - { - } - [Fact] - public void Test_1253() - { - } - [Fact] - public void Test_1254() - { - } - [Fact] - public void Test_1255() - { - } - [Fact] - public void Test_1256() - { - } - [Fact] - public void Test_1257() - { - } - [Fact] - public void Test_1258() - { - } - [Fact] - public void Test_1259() - { - } - [Fact] - public void Test_1260() - { - } - [Fact] - public void Test_1261() - { - } - [Fact] - public void Test_1262() - { - } - [Fact] - public void Test_1263() - { - } - [Fact] - public void Test_1264() - { - } - [Fact] - public void Test_1265() - { - } - [Fact] - public void Test_1266() - { - } - [Fact] - public void Test_1267() - { - } - [Fact] - public void Test_1268() - { - } - [Fact] - public void Test_1269() - { - } - [Fact] - public void Test_1270() - { - } - [Fact] - public void Test_1271() - { - } - [Fact] - public void Test_1272() - { - } - [Fact] - public void Test_1273() - { - } - [Fact] - public void Test_1274() - { - } - [Fact] - public void Test_1275() - { - } - [Fact] - public void Test_1276() - { - } - [Fact] - public void Test_1277() - { - } - [Fact] - public void Test_1278() - { - } - [Fact] - public void Test_1279() - { - } - [Fact] - public void Test_1280() - { - } - [Fact] - public void Test_1281() - { - } - [Fact] - public void Test_1282() - { - } - [Fact] - public void Test_1283() - { - } - [Fact] - public void Test_1284() - { - } - [Fact] - public void Test_1285() - { - } - [Fact] - public void Test_1286() - { - } - [Fact] - public void Test_1287() - { - } - [Fact] - public void Test_1288() - { - } - [Fact] - public void Test_1289() - { - } - [Fact] - public void Test_1290() - { - } - [Fact] - public void Test_1291() - { - } - [Fact] - public void Test_1292() - { - } - [Fact] - public void Test_1293() - { - } - [Fact] - public void Test_1294() - { - } - [Fact] - public void Test_1295() - { - } - [Fact] - public void Test_1296() - { - } - [Fact] - public void Test_1297() - { - } - [Fact] - public void Test_1298() - { - } - [Fact] - public void Test_1299() - { - } - [Fact] - public void Test_1300() - { - } - [Fact] - public void Test_1301() - { - } - [Fact] - public void Test_1302() - { - } - [Fact] - public void Test_1303() - { - } - [Fact] - public void Test_1304() - { - } - [Fact] - public void Test_1305() - { - } - [Fact] - public void Test_1306() - { - } - [Fact] - public void Test_1307() - { - } - [Fact] - public void Test_1308() - { - } - [Fact] - public void Test_1309() - { - } - [Fact] - public void Test_1310() - { - } - [Fact] - public void Test_1311() - { - } - [Fact] - public void Test_1312() - { - } - [Fact] - public void Test_1313() - { - } - [Fact] - public void Test_1314() - { - } - [Fact] - public void Test_1315() - { - } - [Fact] - public void Test_1316() - { - } - [Fact] - public void Test_1317() - { - } - [Fact] - public void Test_1318() - { - } - [Fact] - public void Test_1319() - { - } - [Fact] - public void Test_1320() - { - } - [Fact] - public void Test_1321() - { - } - [Fact] - public void Test_1322() - { - } - [Fact] - public void Test_1323() - { - } - [Fact] - public void Test_1324() - { - } - [Fact] - public void Test_1325() - { - } - [Fact] - public void Test_1326() - { - } - [Fact] - public void Test_1327() - { - } - [Fact] - public void Test_1328() - { - } - [Fact] - public void Test_1329() - { - } - [Fact] - public void Test_1330() - { - } - [Fact] - public void Test_1331() - { - } - [Fact] - public void Test_1332() - { - } - [Fact] - public void Test_1333() - { - } - [Fact] - public void Test_1334() - { - } - [Fact] - public void Test_1335() - { - } - [Fact] - public void Test_1336() - { - } - [Fact] - public void Test_1337() - { - } - [Fact] - public void Test_1338() - { - } - [Fact] - public void Test_1339() - { - } - [Fact] - public void Test_1340() - { - } - [Fact] - public void Test_1341() - { - } - [Fact] - public void Test_1342() - { - } - [Fact] - public void Test_1343() - { - } - [Fact] - public void Test_1344() - { - } - [Fact] - public void Test_1345() - { - } - [Fact] - public void Test_1346() - { - } - [Fact] - public void Test_1347() - { - } - [Fact] - public void Test_1348() - { - } - [Fact] - public void Test_1349() - { - } - [Fact] - public void Test_1350() - { - } - [Fact] - public void Test_1351() - { - } - [Fact] - public void Test_1352() - { - } - [Fact] - public void Test_1353() - { - } - [Fact] - public void Test_1354() - { - } - [Fact] - public void Test_1355() - { - } - [Fact] - public void Test_1356() - { - } - [Fact] - public void Test_1357() - { - } - [Fact] - public void Test_1358() - { - } - [Fact] - public void Test_1359() - { - } - [Fact] - public void Test_1360() - { - } - [Fact] - public void Test_1361() - { - } - [Fact] - public void Test_1362() - { - } - [Fact] - public void Test_1363() - { - } - [Fact] - public void Test_1364() - { - } - [Fact] - public void Test_1365() - { - } - [Fact] - public void Test_1366() - { - } - [Fact] - public void Test_1367() - { - } - [Fact] - public void Test_1368() - { - } - [Fact] - public void Test_1369() - { - } - [Fact] - public void Test_1370() - { - } - [Fact] - public void Test_1371() - { - } - [Fact] - public void Test_1372() - { - } - [Fact] - public void Test_1373() - { - } - [Fact] - public void Test_1374() - { - } - [Fact] - public void Test_1375() - { - } - [Fact] - public void Test_1376() - { - } - [Fact] - public void Test_1377() - { - } - [Fact] - public void Test_1378() - { - } - [Fact] - public void Test_1379() - { - } - [Fact] - public void Test_1380() - { - } - [Fact] - public void Test_1381() - { - } - [Fact] - public void Test_1382() - { - } - [Fact] - public void Test_1383() - { - } - [Fact] - public void Test_1384() - { - } - [Fact] - public void Test_1385() - { - } - [Fact] - public void Test_1386() - { - } - [Fact] - public void Test_1387() - { - } - [Fact] - public void Test_1388() - { - } - [Fact] - public void Test_1389() - { - } - [Fact] - public void Test_1390() - { - } - [Fact] - public void Test_1391() - { - } - [Fact] - public void Test_1392() - { - } - [Fact] - public void Test_1393() - { - } - [Fact] - public void Test_1394() - { - } - [Fact] - public void Test_1395() - { - } - [Fact] - public void Test_1396() - { - } - [Fact] - public void Test_1397() - { - } - [Fact] - public void Test_1398() - { - } - [Fact] - public void Test_1399() - { - } - [Fact] - public void Test_1400() - { - } - [Fact] - public void Test_1401() - { - } - [Fact] - public void Test_1402() - { - } - [Fact] - public void Test_1403() - { - } - [Fact] - public void Test_1404() - { - } - [Fact] - public void Test_1405() - { - } - [Fact] - public void Test_1406() - { - } - [Fact] - public void Test_1407() - { - } - [Fact] - public void Test_1408() - { - } - [Fact] - public void Test_1409() - { - } - [Fact] - public void Test_1410() - { - } - [Fact] - public void Test_1411() - { - } - [Fact] - public void Test_1412() - { - } - [Fact] - public void Test_1413() - { - } - [Fact] - public void Test_1414() - { - } - [Fact] - public void Test_1415() - { - } - [Fact] - public void Test_1416() - { - } - [Fact] - public void Test_1417() - { - } - [Fact] - public void Test_1418() - { - } - [Fact] - public void Test_1419() - { - } - [Fact] - public void Test_1420() - { - } - [Fact] - public void Test_1421() - { - } - [Fact] - public void Test_1422() - { - } - [Fact] - public void Test_1423() - { - } - [Fact] - public void Test_1424() - { - } - [Fact] - public void Test_1425() - { - } - [Fact] - public void Test_1426() - { - } - [Fact] - public void Test_1427() - { - } - [Fact] - public void Test_1428() - { - } - [Fact] - public void Test_1429() - { - } - [Fact] - public void Test_1430() - { - } - [Fact] - public void Test_1431() - { - } - [Fact] - public void Test_1432() - { - } - [Fact] - public void Test_1433() - { - } - [Fact] - public void Test_1434() - { - } - [Fact] - public void Test_1435() - { - } - [Fact] - public void Test_1436() - { - } - [Fact] - public void Test_1437() - { - } - [Fact] - public void Test_1438() - { - } - [Fact] - public void Test_1439() - { - } - [Fact] - public void Test_1440() - { - } - [Fact] - public void Test_1441() - { - } - [Fact] - public void Test_1442() - { - } - [Fact] - public void Test_1443() - { - } - [Fact] - public void Test_1444() - { - } - [Fact] - public void Test_1445() - { - } - [Fact] - public void Test_1446() - { - } - [Fact] - public void Test_1447() - { - } - [Fact] - public void Test_1448() - { - } - [Fact] - public void Test_1449() - { - } - [Fact] - public void Test_1450() - { - } - [Fact] - public void Test_1451() - { - } - [Fact] - public void Test_1452() - { - } - [Fact] - public void Test_1453() - { - } - [Fact] - public void Test_1454() - { - } - [Fact] - public void Test_1455() - { - } - [Fact] - public void Test_1456() - { - } - [Fact] - public void Test_1457() - { - } - [Fact] - public void Test_1458() - { - } - [Fact] - public void Test_1459() - { - } - [Fact] - public void Test_1460() - { - } - [Fact] - public void Test_1461() - { - } - [Fact] - public void Test_1462() - { - } - [Fact] - public void Test_1463() - { - } - [Fact] - public void Test_1464() - { - } - [Fact] - public void Test_1465() - { - } - [Fact] - public void Test_1466() - { - } - [Fact] - public void Test_1467() - { - } - [Fact] - public void Test_1468() - { - } - [Fact] - public void Test_1469() - { - } - [Fact] - public void Test_1470() - { - } - [Fact] - public void Test_1471() - { - } - [Fact] - public void Test_1472() - { - } - [Fact] - public void Test_1473() - { - } - [Fact] - public void Test_1474() - { - } - [Fact] - public void Test_1475() - { - } - [Fact] - public void Test_1476() - { - } - [Fact] - public void Test_1477() - { - } - [Fact] - public void Test_1478() - { - } - [Fact] - public void Test_1479() - { - } - [Fact] - public void Test_1480() - { - } - [Fact] - public void Test_1481() - { - } - [Fact] - public void Test_1482() - { - } - [Fact] - public void Test_1483() - { - } - [Fact] - public void Test_1484() - { - } - [Fact] - public void Test_1485() - { - } - [Fact] - public void Test_1486() - { - } - [Fact] - public void Test_1487() - { - } - [Fact] - public void Test_1488() - { - } - [Fact] - public void Test_1489() - { - } - [Fact] - public void Test_1490() - { - } - [Fact] - public void Test_1491() - { - } - [Fact] - public void Test_1492() - { - } - [Fact] - public void Test_1493() - { - } - [Fact] - public void Test_1494() - { - } - [Fact] - public void Test_1495() - { - } - [Fact] - public void Test_1496() - { - } - [Fact] - public void Test_1497() - { - } - [Fact] - public void Test_1498() - { - } - [Fact] - public void Test_1499() - { - } - [Fact] - public void Test_1500() - { - } - [Fact] - public void Test_1501() - { - } - [Fact] - public void Test_1502() - { - } - [Fact] - public void Test_1503() - { - } - [Fact] - public void Test_1504() - { - } - [Fact] - public void Test_1505() - { - } - [Fact] - public void Test_1506() - { - } - [Fact] - public void Test_1507() - { - } - [Fact] - public void Test_1508() - { - } - [Fact] - public void Test_1509() - { - } - [Fact] - public void Test_1510() - { - } - [Fact] - public void Test_1511() - { - } - [Fact] - public void Test_1512() - { - } - [Fact] - public void Test_1513() - { - } - [Fact] - public void Test_1514() - { - } - [Fact] - public void Test_1515() - { - } - [Fact] - public void Test_1516() - { - } - [Fact] - public void Test_1517() - { - } - [Fact] - public void Test_1518() - { - } - [Fact] - public void Test_1519() - { - } - [Fact] - public void Test_1520() - { - } - [Fact] - public void Test_1521() - { - } - [Fact] - public void Test_1522() - { - } - [Fact] - public void Test_1523() - { - } - [Fact] - public void Test_1524() - { - } - [Fact] - public void Test_1525() - { - } - [Fact] - public void Test_1526() - { - } - [Fact] - public void Test_1527() - { - } - [Fact] - public void Test_1528() - { - } - [Fact] - public void Test_1529() - { - } - [Fact] - public void Test_1530() - { - } - [Fact] - public void Test_1531() - { - } - [Fact] - public void Test_1532() - { - } - [Fact] - public void Test_1533() - { - } - [Fact] - public void Test_1534() - { - } - [Fact] - public void Test_1535() - { - } - [Fact] - public void Test_1536() - { - } - [Fact] - public void Test_1537() - { - } - [Fact] - public void Test_1538() - { - } - [Fact] - public void Test_1539() - { - } - [Fact] - public void Test_1540() - { - } - [Fact] - public void Test_1541() - { - } - [Fact] - public void Test_1542() - { - } - [Fact] - public void Test_1543() - { - } - [Fact] - public void Test_1544() - { - } - [Fact] - public void Test_1545() - { - } - [Fact] - public void Test_1546() - { - } - [Fact] - public void Test_1547() - { - } - [Fact] - public void Test_1548() - { - } - [Fact] - public void Test_1549() - { - } - [Fact] - public void Test_1550() - { - } - [Fact] - public void Test_1551() - { - } - [Fact] - public void Test_1552() - { - } - [Fact] - public void Test_1553() - { - } - [Fact] - public void Test_1554() - { - } - [Fact] - public void Test_1555() - { - } - [Fact] - public void Test_1556() - { - } - [Fact] - public void Test_1557() - { - } - [Fact] - public void Test_1558() - { - } - [Fact] - public void Test_1559() - { - } - [Fact] - public void Test_1560() - { - } - [Fact] - public void Test_1561() - { - } - [Fact] - public void Test_1562() - { - } - [Fact] - public void Test_1563() - { - } - [Fact] - public void Test_1564() - { - } - [Fact] - public void Test_1565() - { - } - [Fact] - public void Test_1566() - { - } - [Fact] - public void Test_1567() - { - } - [Fact] - public void Test_1568() - { - } - [Fact] - public void Test_1569() - { - } - [Fact] - public void Test_1570() - { - } - [Fact] - public void Test_1571() - { - } - [Fact] - public void Test_1572() - { - } - [Fact] - public void Test_1573() - { - } - [Fact] - public void Test_1574() - { - } - [Fact] - public void Test_1575() - { - } - [Fact] - public void Test_1576() - { - } - [Fact] - public void Test_1577() - { - } - [Fact] - public void Test_1578() - { - } - [Fact] - public void Test_1579() - { - } - [Fact] - public void Test_1580() - { - } - [Fact] - public void Test_1581() - { - } - [Fact] - public void Test_1582() - { - } - [Fact] - public void Test_1583() - { - } - [Fact] - public void Test_1584() - { - } - [Fact] - public void Test_1585() - { - } - [Fact] - public void Test_1586() - { - } - [Fact] - public void Test_1587() - { - } - [Fact] - public void Test_1588() - { - } - [Fact] - public void Test_1589() - { - } - [Fact] - public void Test_1590() - { - } - [Fact] - public void Test_1591() - { - } - [Fact] - public void Test_1592() - { - } - [Fact] - public void Test_1593() - { - } - [Fact] - public void Test_1594() - { - } - [Fact] - public void Test_1595() - { - } - [Fact] - public void Test_1596() - { - } - [Fact] - public void Test_1597() - { - } - [Fact] - public void Test_1598() - { - } - [Fact] - public void Test_1599() - { - } - [Fact] - public void Test_1600() - { - } - [Fact] - public void Test_1601() - { - } - [Fact] - public void Test_1602() - { - } - [Fact] - public void Test_1603() - { - } - [Fact] - public void Test_1604() - { - } - [Fact] - public void Test_1605() - { - } - [Fact] - public void Test_1606() - { - } - [Fact] - public void Test_1607() - { - } - [Fact] - public void Test_1608() - { - } - [Fact] - public void Test_1609() - { - } - [Fact] - public void Test_1610() - { - } - [Fact] - public void Test_1611() - { - } - [Fact] - public void Test_1612() - { - } - [Fact] - public void Test_1613() - { - } - [Fact] - public void Test_1614() - { - } - [Fact] - public void Test_1615() - { - } - [Fact] - public void Test_1616() - { - } - [Fact] - public void Test_1617() - { - } - [Fact] - public void Test_1618() - { - } - [Fact] - public void Test_1619() - { - } - [Fact] - public void Test_1620() - { - } - [Fact] - public void Test_1621() - { - } - [Fact] - public void Test_1622() - { - } - [Fact] - public void Test_1623() - { - } - [Fact] - public void Test_1624() - { - } - [Fact] - public void Test_1625() - { - } - [Fact] - public void Test_1626() - { - } - [Fact] - public void Test_1627() - { - } - [Fact] - public void Test_1628() - { - } - [Fact] - public void Test_1629() - { - } - [Fact] - public void Test_1630() - { - } - [Fact] - public void Test_1631() - { - } - [Fact] - public void Test_1632() - { - } - [Fact] - public void Test_1633() - { - } - [Fact] - public void Test_1634() - { - } - [Fact] - public void Test_1635() - { - } - [Fact] - public void Test_1636() - { - } - [Fact] - public void Test_1637() - { - } - [Fact] - public void Test_1638() - { - } - [Fact] - public void Test_1639() - { - } - [Fact] - public void Test_1640() - { - } - [Fact] - public void Test_1641() - { - } - [Fact] - public void Test_1642() - { - } - [Fact] - public void Test_1643() - { - } - [Fact] - public void Test_1644() - { - } - [Fact] - public void Test_1645() - { - } - [Fact] - public void Test_1646() - { - } - [Fact] - public void Test_1647() - { - } - [Fact] - public void Test_1648() - { - } - [Fact] - public void Test_1649() - { - } - [Fact] - public void Test_1650() - { - } - [Fact] - public void Test_1651() - { - } - [Fact] - public void Test_1652() - { - } - [Fact] - public void Test_1653() - { - } - [Fact] - public void Test_1654() - { - } - [Fact] - public void Test_1655() - { - } - [Fact] - public void Test_1656() - { - } - [Fact] - public void Test_1657() - { - } - [Fact] - public void Test_1658() - { - } - [Fact] - public void Test_1659() - { - } - [Fact] - public void Test_1660() - { - } - [Fact] - public void Test_1661() - { - } - [Fact] - public void Test_1662() - { - } - [Fact] - public void Test_1663() - { - } - [Fact] - public void Test_1664() - { - } - [Fact] - public void Test_1665() - { - } - [Fact] - public void Test_1666() - { - } - [Fact] - public void Test_1667() - { - } - [Fact] - public void Test_1668() - { - } - [Fact] - public void Test_1669() - { - } - [Fact] - public void Test_1670() - { - } - [Fact] - public void Test_1671() - { - } - [Fact] - public void Test_1672() - { - } - [Fact] - public void Test_1673() - { - } - [Fact] - public void Test_1674() - { - } - [Fact] - public void Test_1675() - { - } - [Fact] - public void Test_1676() - { - } - [Fact] - public void Test_1677() - { - } - [Fact] - public void Test_1678() - { - } - [Fact] - public void Test_1679() - { - } - [Fact] - public void Test_1680() - { - } - [Fact] - public void Test_1681() - { - } - [Fact] - public void Test_1682() - { - } - [Fact] - public void Test_1683() - { - } - [Fact] - public void Test_1684() - { - } - [Fact] - public void Test_1685() - { - } - [Fact] - public void Test_1686() - { - } - [Fact] - public void Test_1687() - { - } - [Fact] - public void Test_1688() - { - } - [Fact] - public void Test_1689() - { - } - [Fact] - public void Test_1690() - { - } - [Fact] - public void Test_1691() - { - } - [Fact] - public void Test_1692() - { - } - [Fact] - public void Test_1693() - { - } - [Fact] - public void Test_1694() - { - } - [Fact] - public void Test_1695() - { - } - [Fact] - public void Test_1696() - { - } - [Fact] - public void Test_1697() - { - } - [Fact] - public void Test_1698() - { - } - [Fact] - public void Test_1699() - { - } - [Fact] - public void Test_1700() - { - } - [Fact] - public void Test_1701() - { - } - [Fact] - public void Test_1702() - { - } - [Fact] - public void Test_1703() - { - } - [Fact] - public void Test_1704() - { - } - [Fact] - public void Test_1705() - { - } - [Fact] - public void Test_1706() - { - } - [Fact] - public void Test_1707() - { - } - [Fact] - public void Test_1708() - { - } - [Fact] - public void Test_1709() - { - } - [Fact] - public void Test_1710() - { - } - [Fact] - public void Test_1711() - { - } - [Fact] - public void Test_1712() - { - } - [Fact] - public void Test_1713() - { - } - [Fact] - public void Test_1714() - { - } - [Fact] - public void Test_1715() - { - } - [Fact] - public void Test_1716() - { - } - [Fact] - public void Test_1717() - { - } - [Fact] - public void Test_1718() - { - } - [Fact] - public void Test_1719() - { - } - [Fact] - public void Test_1720() - { - } - [Fact] - public void Test_1721() - { - } - [Fact] - public void Test_1722() - { - } - [Fact] - public void Test_1723() - { - } - [Fact] - public void Test_1724() - { - } - [Fact] - public void Test_1725() - { - } - [Fact] - public void Test_1726() - { - } - [Fact] - public void Test_1727() - { - } - [Fact] - public void Test_1728() - { - } - [Fact] - public void Test_1729() - { - } - [Fact] - public void Test_1730() - { - } - [Fact] - public void Test_1731() - { - } - [Fact] - public void Test_1732() - { - } - [Fact] - public void Test_1733() - { - } - [Fact] - public void Test_1734() - { - } - [Fact] - public void Test_1735() - { - } - [Fact] - public void Test_1736() - { - } - [Fact] - public void Test_1737() - { - } - [Fact] - public void Test_1738() - { - } - [Fact] - public void Test_1739() - { - } - [Fact] - public void Test_1740() - { - } - [Fact] - public void Test_1741() - { - } - [Fact] - public void Test_1742() - { - } - [Fact] - public void Test_1743() - { - } - [Fact] - public void Test_1744() - { - } - [Fact] - public void Test_1745() - { - } - [Fact] - public void Test_1746() - { - } - [Fact] - public void Test_1747() - { - } - [Fact] - public void Test_1748() - { - } - [Fact] - public void Test_1749() - { - } - [Fact] - public void Test_1750() - { - } - [Fact] - public void Test_1751() - { - } - [Fact] - public void Test_1752() - { - } - [Fact] - public void Test_1753() - { - } - [Fact] - public void Test_1754() - { - } - [Fact] - public void Test_1755() - { - } - [Fact] - public void Test_1756() - { - } - [Fact] - public void Test_1757() - { - } - [Fact] - public void Test_1758() - { - } - [Fact] - public void Test_1759() - { - } - [Fact] - public void Test_1760() - { - } - [Fact] - public void Test_1761() - { - } - [Fact] - public void Test_1762() - { - } - [Fact] - public void Test_1763() - { - } - [Fact] - public void Test_1764() - { - } - [Fact] - public void Test_1765() - { - } - [Fact] - public void Test_1766() - { - } - [Fact] - public void Test_1767() - { - } - [Fact] - public void Test_1768() - { - } - [Fact] - public void Test_1769() - { - } - [Fact] - public void Test_1770() - { - } - [Fact] - public void Test_1771() - { - } - [Fact] - public void Test_1772() - { - } - [Fact] - public void Test_1773() - { - } - [Fact] - public void Test_1774() - { - } - [Fact] - public void Test_1775() - { - } - [Fact] - public void Test_1776() - { - } - [Fact] - public void Test_1777() - { - } - [Fact] - public void Test_1778() - { - } - [Fact] - public void Test_1779() - { - } - [Fact] - public void Test_1780() - { - } - [Fact] - public void Test_1781() - { - } - [Fact] - public void Test_1782() - { - } - [Fact] - public void Test_1783() - { - } - [Fact] - public void Test_1784() - { - } - [Fact] - public void Test_1785() - { - } - [Fact] - public void Test_1786() - { - } - [Fact] - public void Test_1787() - { - } - [Fact] - public void Test_1788() - { - } - [Fact] - public void Test_1789() - { - } - [Fact] - public void Test_1790() - { - } - [Fact] - public void Test_1791() - { - } - [Fact] - public void Test_1792() - { - } - [Fact] - public void Test_1793() - { - } - [Fact] - public void Test_1794() - { - } - [Fact] - public void Test_1795() - { - } - [Fact] - public void Test_1796() - { - } - [Fact] - public void Test_1797() - { - } - [Fact] - public void Test_1798() - { - } - [Fact] - public void Test_1799() - { - } - [Fact] - public void Test_1800() - { - } - [Fact] - public void Test_1801() - { - } - [Fact] - public void Test_1802() - { - } - [Fact] - public void Test_1803() - { - } - [Fact] - public void Test_1804() - { - } - [Fact] - public void Test_1805() - { - } - [Fact] - public void Test_1806() - { - } - [Fact] - public void Test_1807() - { - } - [Fact] - public void Test_1808() - { - } - [Fact] - public void Test_1809() - { - } - [Fact] - public void Test_1810() - { - } - [Fact] - public void Test_1811() - { - } - [Fact] - public void Test_1812() - { - } - [Fact] - public void Test_1813() - { - } - [Fact] - public void Test_1814() - { - } - [Fact] - public void Test_1815() - { - } - [Fact] - public void Test_1816() - { - } - [Fact] - public void Test_1817() - { - } - [Fact] - public void Test_1818() - { - } - [Fact] - public void Test_1819() - { - } - [Fact] - public void Test_1820() - { - } - [Fact] - public void Test_1821() - { - } - [Fact] - public void Test_1822() - { - } - [Fact] - public void Test_1823() - { - } - [Fact] - public void Test_1824() - { - } - [Fact] - public void Test_1825() - { - } - [Fact] - public void Test_1826() - { - } - [Fact] - public void Test_1827() - { - } - [Fact] - public void Test_1828() - { - } - [Fact] - public void Test_1829() - { - } - [Fact] - public void Test_1830() - { - } - [Fact] - public void Test_1831() - { - } - [Fact] - public void Test_1832() - { - } - [Fact] - public void Test_1833() - { - } - [Fact] - public void Test_1834() - { - } - [Fact] - public void Test_1835() - { - } - [Fact] - public void Test_1836() - { - } - [Fact] - public void Test_1837() - { - } - [Fact] - public void Test_1838() - { - } - [Fact] - public void Test_1839() - { - } - [Fact] - public void Test_1840() - { - } - [Fact] - public void Test_1841() - { - } - [Fact] - public void Test_1842() - { - } - [Fact] - public void Test_1843() - { - } - [Fact] - public void Test_1844() - { - } - [Fact] - public void Test_1845() - { - } - [Fact] - public void Test_1846() - { - } - [Fact] - public void Test_1847() - { - } - [Fact] - public void Test_1848() - { - } - [Fact] - public void Test_1849() - { - } - [Fact] - public void Test_1850() - { - } - [Fact] - public void Test_1851() - { - } - [Fact] - public void Test_1852() - { - } - [Fact] - public void Test_1853() - { - } - [Fact] - public void Test_1854() - { - } - [Fact] - public void Test_1855() - { - } - [Fact] - public void Test_1856() - { - } - [Fact] - public void Test_1857() - { - } - [Fact] - public void Test_1858() - { - } - [Fact] - public void Test_1859() - { - } - [Fact] - public void Test_1860() - { - } - [Fact] - public void Test_1861() - { - } - [Fact] - public void Test_1862() - { - } - [Fact] - public void Test_1863() - { - } - [Fact] - public void Test_1864() - { - } - [Fact] - public void Test_1865() - { - } - [Fact] - public void Test_1866() - { - } - [Fact] - public void Test_1867() - { - } - [Fact] - public void Test_1868() - { - } - [Fact] - public void Test_1869() - { - } - [Fact] - public void Test_1870() - { - } - [Fact] - public void Test_1871() - { - } - [Fact] - public void Test_1872() - { - } - [Fact] - public void Test_1873() - { - } - [Fact] - public void Test_1874() - { - } - [Fact] - public void Test_1875() - { - } - [Fact] - public void Test_1876() - { - } - [Fact] - public void Test_1877() - { - } - [Fact] - public void Test_1878() - { - } - [Fact] - public void Test_1879() - { - } - [Fact] - public void Test_1880() - { - } - [Fact] - public void Test_1881() - { - } - [Fact] - public void Test_1882() - { - } - [Fact] - public void Test_1883() - { - } - [Fact] - public void Test_1884() - { - } - [Fact] - public void Test_1885() - { - } - [Fact] - public void Test_1886() - { - } - [Fact] - public void Test_1887() - { - } - [Fact] - public void Test_1888() - { - } - [Fact] - public void Test_1889() - { - } - [Fact] - public void Test_1890() - { - } - [Fact] - public void Test_1891() - { - } - [Fact] - public void Test_1892() - { - } - [Fact] - public void Test_1893() - { - } - [Fact] - public void Test_1894() - { - } - [Fact] - public void Test_1895() - { - } - [Fact] - public void Test_1896() - { - } - [Fact] - public void Test_1897() - { - } - [Fact] - public void Test_1898() - { - } - [Fact] - public void Test_1899() - { - } - [Fact] - public void Test_1900() - { - } - [Fact] - public void Test_1901() - { - } - [Fact] - public void Test_1902() - { - } - [Fact] - public void Test_1903() - { - } - [Fact] - public void Test_1904() - { - } - [Fact] - public void Test_1905() - { - } - [Fact] - public void Test_1906() - { - } - [Fact] - public void Test_1907() - { - } - [Fact] - public void Test_1908() - { - } - [Fact] - public void Test_1909() - { - } - [Fact] - public void Test_1910() - { - } - [Fact] - public void Test_1911() - { - } - [Fact] - public void Test_1912() - { - } - [Fact] - public void Test_1913() - { - } - [Fact] - public void Test_1914() - { - } - [Fact] - public void Test_1915() - { - } - [Fact] - public void Test_1916() - { - } - [Fact] - public void Test_1917() - { - } - [Fact] - public void Test_1918() - { - } - [Fact] - public void Test_1919() - { - } - [Fact] - public void Test_1920() - { - } - [Fact] - public void Test_1921() - { - } - [Fact] - public void Test_1922() - { - } - [Fact] - public void Test_1923() - { - } - [Fact] - public void Test_1924() - { - } - [Fact] - public void Test_1925() - { - } - [Fact] - public void Test_1926() - { - } - [Fact] - public void Test_1927() - { - } - [Fact] - public void Test_1928() - { - } - [Fact] - public void Test_1929() - { - } - [Fact] - public void Test_1930() - { - } - [Fact] - public void Test_1931() - { - } - [Fact] - public void Test_1932() - { - } - [Fact] - public void Test_1933() - { - } - [Fact] - public void Test_1934() - { - } - [Fact] - public void Test_1935() - { - } - [Fact] - public void Test_1936() - { - } - [Fact] - public void Test_1937() - { - } - [Fact] - public void Test_1938() - { - } - [Fact] - public void Test_1939() - { - } - [Fact] - public void Test_1940() - { - } - [Fact] - public void Test_1941() - { - } - [Fact] - public void Test_1942() - { - } - [Fact] - public void Test_1943() - { - } - [Fact] - public void Test_1944() - { - } - [Fact] - public void Test_1945() - { - } - [Fact] - public void Test_1946() - { - } - [Fact] - public void Test_1947() - { - } - [Fact] - public void Test_1948() - { - } - [Fact] - public void Test_1949() - { - } - [Fact] - public void Test_1950() - { - } - [Fact] - public void Test_1951() - { - } - [Fact] - public void Test_1952() - { - } - [Fact] - public void Test_1953() - { - } - [Fact] - public void Test_1954() - { - } - [Fact] - public void Test_1955() - { - } - [Fact] - public void Test_1956() - { - } - [Fact] - public void Test_1957() - { - } - [Fact] - public void Test_1958() - { - } - [Fact] - public void Test_1959() - { - } - [Fact] - public void Test_1960() - { - } - [Fact] - public void Test_1961() - { - } - [Fact] - public void Test_1962() - { - } - [Fact] - public void Test_1963() - { - } - [Fact] - public void Test_1964() - { - } - [Fact] - public void Test_1965() - { - } - [Fact] - public void Test_1966() - { - } - [Fact] - public void Test_1967() - { - } - [Fact] - public void Test_1968() - { - } - [Fact] - public void Test_1969() - { - } - [Fact] - public void Test_1970() - { - } - [Fact] - public void Test_1971() - { - } - [Fact] - public void Test_1972() - { - } - [Fact] - public void Test_1973() - { - } - [Fact] - public void Test_1974() - { - } - [Fact] - public void Test_1975() - { - } - [Fact] - public void Test_1976() - { - } - [Fact] - public void Test_1977() - { - } - [Fact] - public void Test_1978() - { - } - [Fact] - public void Test_1979() - { - } - [Fact] - public void Test_1980() - { - } - [Fact] - public void Test_1981() - { - } - [Fact] - public void Test_1982() - { - } - [Fact] - public void Test_1983() - { - } - [Fact] - public void Test_1984() - { - } - [Fact] - public void Test_1985() - { - } - [Fact] - public void Test_1986() - { - } - [Fact] - public void Test_1987() - { - } - [Fact] - public void Test_1988() - { - } - [Fact] - public void Test_1989() - { - } - [Fact] - public void Test_1990() - { - } - [Fact] - public void Test_1991() - { - } - [Fact] - public void Test_1992() - { - } - [Fact] - public void Test_1993() - { - } - [Fact] - public void Test_1994() - { - } - [Fact] - public void Test_1995() - { - } - [Fact] - public void Test_1996() - { - } - [Fact] - public void Test_1997() - { - } - [Fact] - public void Test_1998() - { - } - [Fact] - public void Test_1999() - { - } - [Fact] - public void Test_2000() - { - } - [Fact] - public void Test_2001() - { - } - [Fact] - public void Test_2002() - { - } - [Fact] - public void Test_2003() - { - } - [Fact] - public void Test_2004() - { - } - [Fact] - public void Test_2005() - { - } - [Fact] - public void Test_2006() - { - } - [Fact] - public void Test_2007() - { - } - [Fact] - public void Test_2008() - { - } - [Fact] - public void Test_2009() - { - } - [Fact] - public void Test_2010() - { - } - [Fact] - public void Test_2011() - { - } - [Fact] - public void Test_2012() - { - } - [Fact] - public void Test_2013() - { - } - [Fact] - public void Test_2014() - { - } - [Fact] - public void Test_2015() - { - } - [Fact] - public void Test_2016() - { - } - [Fact] - public void Test_2017() - { - } - [Fact] - public void Test_2018() - { - } - [Fact] - public void Test_2019() - { - } - [Fact] - public void Test_2020() - { - } - [Fact] - public void Test_2021() - { - } - [Fact] - public void Test_2022() - { - } - [Fact] - public void Test_2023() - { - } - [Fact] - public void Test_2024() - { - } - [Fact] - public void Test_2025() - { - } - [Fact] - public void Test_2026() - { - } - [Fact] - public void Test_2027() - { - } - [Fact] - public void Test_2028() - { - } - [Fact] - public void Test_2029() - { - } - [Fact] - public void Test_2030() - { - } - [Fact] - public void Test_2031() - { - } - [Fact] - public void Test_2032() - { - } - [Fact] - public void Test_2033() - { - } - [Fact] - public void Test_2034() - { - } - [Fact] - public void Test_2035() - { - } - [Fact] - public void Test_2036() - { - } - [Fact] - public void Test_2037() - { - } - [Fact] - public void Test_2038() - { - } - [Fact] - public void Test_2039() - { - } - [Fact] - public void Test_2040() - { - } - [Fact] - public void Test_2041() - { - } - [Fact] - public void Test_2042() - { - } - [Fact] - public void Test_2043() - { - } - [Fact] - public void Test_2044() - { - } - [Fact] - public void Test_2045() - { - } - [Fact] - public void Test_2046() - { - } - [Fact] - public void Test_2047() - { - } - [Fact] - public void Test_2048() - { - } - [Fact] - public void Test_2049() - { - } - [Fact] - public void Test_2050() - { - } - [Fact] - public void Test_2051() - { - } - [Fact] - public void Test_2052() - { - } - [Fact] - public void Test_2053() - { - } - [Fact] - public void Test_2054() - { - } - [Fact] - public void Test_2055() - { - } - [Fact] - public void Test_2056() - { - } - [Fact] - public void Test_2057() - { - } - [Fact] - public void Test_2058() - { - } - [Fact] - public void Test_2059() - { - } - [Fact] - public void Test_2060() - { - } - [Fact] - public void Test_2061() - { - } - [Fact] - public void Test_2062() - { - } - [Fact] - public void Test_2063() - { - } - [Fact] - public void Test_2064() - { - } - [Fact] - public void Test_2065() - { - } - [Fact] - public void Test_2066() - { - } - [Fact] - public void Test_2067() - { - } - [Fact] - public void Test_2068() - { - } - [Fact] - public void Test_2069() - { - } - [Fact] - public void Test_2070() - { - } - [Fact] - public void Test_2071() - { - } - [Fact] - public void Test_2072() - { - } - [Fact] - public void Test_2073() - { - } - [Fact] - public void Test_2074() - { - } - [Fact] - public void Test_2075() - { - } - [Fact] - public void Test_2076() - { - } - [Fact] - public void Test_2077() - { - } - [Fact] - public void Test_2078() - { - } - [Fact] - public void Test_2079() - { - } - [Fact] - public void Test_2080() - { - } - [Fact] - public void Test_2081() - { - } - [Fact] - public void Test_2082() - { - } - [Fact] - public void Test_2083() - { - } - [Fact] - public void Test_2084() - { - } - [Fact] - public void Test_2085() - { - } - [Fact] - public void Test_2086() - { - } - [Fact] - public void Test_2087() - { - } - [Fact] - public void Test_2088() - { - } - [Fact] - public void Test_2089() - { - } - [Fact] - public void Test_2090() - { - } - [Fact] - public void Test_2091() - { - } - [Fact] - public void Test_2092() - { - } - [Fact] - public void Test_2093() - { - } - [Fact] - public void Test_2094() - { - } - [Fact] - public void Test_2095() - { - } - [Fact] - public void Test_2096() - { - } - [Fact] - public void Test_2097() - { - } - [Fact] - public void Test_2098() - { - } - [Fact] - public void Test_2099() - { - } - [Fact] - public void Test_2100() - { - } - [Fact] - public void Test_2101() - { - } - [Fact] - public void Test_2102() - { - } - [Fact] - public void Test_2103() - { - } - [Fact] - public void Test_2104() - { - } - [Fact] - public void Test_2105() - { - } - [Fact] - public void Test_2106() - { - } - [Fact] - public void Test_2107() - { - } - [Fact] - public void Test_2108() - { - } - [Fact] - public void Test_2109() - { - } - [Fact] - public void Test_2110() - { - } - [Fact] - public void Test_2111() - { - } - [Fact] - public void Test_2112() - { - } - [Fact] - public void Test_2113() - { - } - [Fact] - public void Test_2114() - { - } - [Fact] - public void Test_2115() - { - } - [Fact] - public void Test_2116() - { - } - [Fact] - public void Test_2117() - { - } - [Fact] - public void Test_2118() - { - } - [Fact] - public void Test_2119() - { - } - [Fact] - public void Test_2120() - { - } - [Fact] - public void Test_2121() - { - } - [Fact] - public void Test_2122() - { - } - [Fact] - public void Test_2123() - { - } - [Fact] - public void Test_2124() - { - } - [Fact] - public void Test_2125() - { - } - [Fact] - public void Test_2126() - { - } - [Fact] - public void Test_2127() - { - } - [Fact] - public void Test_2128() - { - } - [Fact] - public void Test_2129() - { - } - [Fact] - public void Test_2130() - { - } - [Fact] - public void Test_2131() - { - } - [Fact] - public void Test_2132() - { - } - [Fact] - public void Test_2133() - { - } - [Fact] - public void Test_2134() - { - } - [Fact] - public void Test_2135() - { - } - [Fact] - public void Test_2136() - { - } - [Fact] - public void Test_2137() - { - } - [Fact] - public void Test_2138() - { - } - [Fact] - public void Test_2139() - { - } - [Fact] - public void Test_2140() - { - } - [Fact] - public void Test_2141() - { - } - [Fact] - public void Test_2142() - { - } - [Fact] - public void Test_2143() - { - } - [Fact] - public void Test_2144() - { - } - [Fact] - public void Test_2145() - { - } - [Fact] - public void Test_2146() - { - } - [Fact] - public void Test_2147() - { - } - [Fact] - public void Test_2148() - { - } - [Fact] - public void Test_2149() - { - } - [Fact] - public void Test_2150() - { - } - [Fact] - public void Test_2151() - { - } - [Fact] - public void Test_2152() - { - } - [Fact] - public void Test_2153() - { - } - [Fact] - public void Test_2154() - { - } - [Fact] - public void Test_2155() - { - } - [Fact] - public void Test_2156() - { - } - [Fact] - public void Test_2157() - { - } - [Fact] - public void Test_2158() - { - } - [Fact] - public void Test_2159() - { - } - [Fact] - public void Test_2160() - { - } - [Fact] - public void Test_2161() - { - } - [Fact] - public void Test_2162() - { - } - [Fact] - public void Test_2163() - { - } - [Fact] - public void Test_2164() - { - } - [Fact] - public void Test_2165() - { - } - [Fact] - public void Test_2166() - { - } - [Fact] - public void Test_2167() - { - } - [Fact] - public void Test_2168() - { - } - [Fact] - public void Test_2169() - { - } - [Fact] - public void Test_2170() - { - } - [Fact] - public void Test_2171() - { - } - [Fact] - public void Test_2172() - { - } - [Fact] - public void Test_2173() - { - } - [Fact] - public void Test_2174() - { - } - [Fact] - public void Test_2175() - { - } - [Fact] - public void Test_2176() - { - } - [Fact] - public void Test_2177() - { - } - [Fact] - public void Test_2178() - { - } - [Fact] - public void Test_2179() - { - } - [Fact] - public void Test_2180() - { - } - [Fact] - public void Test_2181() - { - } - [Fact] - public void Test_2182() - { - } - [Fact] - public void Test_2183() - { - } - [Fact] - public void Test_2184() - { - } - [Fact] - public void Test_2185() - { - } - [Fact] - public void Test_2186() - { - } - [Fact] - public void Test_2187() - { - } - [Fact] - public void Test_2188() - { - } - [Fact] - public void Test_2189() - { - } - [Fact] - public void Test_2190() - { - } - [Fact] - public void Test_2191() - { - } - [Fact] - public void Test_2192() - { - } - [Fact] - public void Test_2193() - { - } - [Fact] - public void Test_2194() - { - } - [Fact] - public void Test_2195() - { - } - [Fact] - public void Test_2196() - { - } - [Fact] - public void Test_2197() - { - } - [Fact] - public void Test_2198() - { - } - [Fact] - public void Test_2199() - { - } - [Fact] - public void Test_2200() - { - } - [Fact] - public void Test_2201() - { - } - [Fact] - public void Test_2202() - { - } - [Fact] - public void Test_2203() - { - } - [Fact] - public void Test_2204() - { - } - [Fact] - public void Test_2205() - { - } - [Fact] - public void Test_2206() - { - } - [Fact] - public void Test_2207() - { - } - [Fact] - public void Test_2208() - { - } - [Fact] - public void Test_2209() - { - } - [Fact] - public void Test_2210() - { - } - [Fact] - public void Test_2211() - { - } - [Fact] - public void Test_2212() - { - } - [Fact] - public void Test_2213() - { - } - [Fact] - public void Test_2214() - { - } - [Fact] - public void Test_2215() - { - } - [Fact] - public void Test_2216() - { - } - [Fact] - public void Test_2217() - { - } - [Fact] - public void Test_2218() - { - } - [Fact] - public void Test_2219() - { - } - [Fact] - public void Test_2220() - { - } - [Fact] - public void Test_2221() - { - } - [Fact] - public void Test_2222() - { - } - [Fact] - public void Test_2223() - { - } - [Fact] - public void Test_2224() - { - } - [Fact] - public void Test_2225() - { - } - [Fact] - public void Test_2226() - { - } - [Fact] - public void Test_2227() - { - } - [Fact] - public void Test_2228() - { - } - [Fact] - public void Test_2229() - { - } - [Fact] - public void Test_2230() - { - } - [Fact] - public void Test_2231() - { - } - [Fact] - public void Test_2232() - { - } - [Fact] - public void Test_2233() - { - } - [Fact] - public void Test_2234() - { - } - [Fact] - public void Test_2235() - { - } - [Fact] - public void Test_2236() - { - } - [Fact] - public void Test_2237() - { - } - [Fact] - public void Test_2238() - { - } - [Fact] - public void Test_2239() - { - } - [Fact] - public void Test_2240() - { - } - [Fact] - public void Test_2241() - { - } - [Fact] - public void Test_2242() - { - } - [Fact] - public void Test_2243() - { - } - [Fact] - public void Test_2244() - { - } - [Fact] - public void Test_2245() - { - } - [Fact] - public void Test_2246() - { - } - [Fact] - public void Test_2247() - { - } - [Fact] - public void Test_2248() - { - } - [Fact] - public void Test_2249() - { - } - [Fact] - public void Test_2250() - { - } - [Fact] - public void Test_2251() - { - } - [Fact] - public void Test_2252() - { - } - [Fact] - public void Test_2253() - { - } - [Fact] - public void Test_2254() - { - } - [Fact] - public void Test_2255() - { - } - [Fact] - public void Test_2256() - { - } - [Fact] - public void Test_2257() - { - } - [Fact] - public void Test_2258() - { - } - [Fact] - public void Test_2259() - { - } - [Fact] - public void Test_2260() - { - } - [Fact] - public void Test_2261() - { - } - [Fact] - public void Test_2262() - { - } - [Fact] - public void Test_2263() - { - } - [Fact] - public void Test_2264() - { - } - [Fact] - public void Test_2265() - { - } - [Fact] - public void Test_2266() - { - } - [Fact] - public void Test_2267() - { - } - [Fact] - public void Test_2268() - { - } - [Fact] - public void Test_2269() - { - } - [Fact] - public void Test_2270() - { - } - [Fact] - public void Test_2271() - { - } - [Fact] - public void Test_2272() - { - } - [Fact] - public void Test_2273() - { - } - [Fact] - public void Test_2274() - { - } - [Fact] - public void Test_2275() - { - } - [Fact] - public void Test_2276() - { - } - [Fact] - public void Test_2277() - { - } - [Fact] - public void Test_2278() - { - } - [Fact] - public void Test_2279() - { - } - [Fact] - public void Test_2280() - { - } - [Fact] - public void Test_2281() - { - } - [Fact] - public void Test_2282() - { - } - [Fact] - public void Test_2283() - { - } - [Fact] - public void Test_2284() - { - } - [Fact] - public void Test_2285() - { - } - [Fact] - public void Test_2286() - { - } - [Fact] - public void Test_2287() - { - } - [Fact] - public void Test_2288() - { - } - [Fact] - public void Test_2289() - { - } - [Fact] - public void Test_2290() - { - } - [Fact] - public void Test_2291() - { - } - [Fact] - public void Test_2292() - { - } - [Fact] - public void Test_2293() - { - } - [Fact] - public void Test_2294() - { - } - [Fact] - public void Test_2295() - { - } - [Fact] - public void Test_2296() - { - } - [Fact] - public void Test_2297() - { - } - [Fact] - public void Test_2298() - { - } - [Fact] - public void Test_2299() - { - } - [Fact] - public void Test_2300() - { - } - [Fact] - public void Test_2301() - { - } - [Fact] - public void Test_2302() - { - } - [Fact] - public void Test_2303() - { - } - [Fact] - public void Test_2304() - { - } - [Fact] - public void Test_2305() - { - } - [Fact] - public void Test_2306() - { - } - [Fact] - public void Test_2307() - { - } - [Fact] - public void Test_2308() - { - } - [Fact] - public void Test_2309() - { - } - [Fact] - public void Test_2310() - { - } - [Fact] - public void Test_2311() - { - } - [Fact] - public void Test_2312() - { - } - [Fact] - public void Test_2313() - { - } - [Fact] - public void Test_2314() - { - } - [Fact] - public void Test_2315() - { - } - [Fact] - public void Test_2316() - { - } - [Fact] - public void Test_2317() - { - } - [Fact] - public void Test_2318() - { - } - [Fact] - public void Test_2319() - { - } - [Fact] - public void Test_2320() - { - } - [Fact] - public void Test_2321() - { - } - [Fact] - public void Test_2322() - { - } - [Fact] - public void Test_2323() - { - } - [Fact] - public void Test_2324() - { - } - [Fact] - public void Test_2325() - { - } - [Fact] - public void Test_2326() - { - } - [Fact] - public void Test_2327() - { - } - [Fact] - public void Test_2328() - { - } - [Fact] - public void Test_2329() - { - } - [Fact] - public void Test_2330() - { - } - [Fact] - public void Test_2331() - { - } - [Fact] - public void Test_2332() - { - } - [Fact] - public void Test_2333() - { - } - [Fact] - public void Test_2334() - { - } - [Fact] - public void Test_2335() - { - } - [Fact] - public void Test_2336() - { - } - [Fact] - public void Test_2337() - { - } - [Fact] - public void Test_2338() - { - } - [Fact] - public void Test_2339() - { - } - [Fact] - public void Test_2340() - { - } - [Fact] - public void Test_2341() - { - } - [Fact] - public void Test_2342() - { - } - [Fact] - public void Test_2343() - { - } - [Fact] - public void Test_2344() - { - } - [Fact] - public void Test_2345() - { - } - [Fact] - public void Test_2346() - { - } - [Fact] - public void Test_2347() - { - } - [Fact] - public void Test_2348() - { - } - [Fact] - public void Test_2349() - { - } - [Fact] - public void Test_2350() - { - } - [Fact] - public void Test_2351() - { - } - [Fact] - public void Test_2352() - { - } - [Fact] - public void Test_2353() - { - } - [Fact] - public void Test_2354() - { - } - [Fact] - public void Test_2355() - { - } - [Fact] - public void Test_2356() - { - } - [Fact] - public void Test_2357() - { - } - [Fact] - public void Test_2358() - { - } - [Fact] - public void Test_2359() - { - } - [Fact] - public void Test_2360() - { - } - [Fact] - public void Test_2361() - { - } - [Fact] - public void Test_2362() - { - } - [Fact] - public void Test_2363() - { - } - [Fact] - public void Test_2364() - { - } - [Fact] - public void Test_2365() - { - } - [Fact] - public void Test_2366() - { - } - [Fact] - public void Test_2367() - { - } - [Fact] - public void Test_2368() - { - } - [Fact] - public void Test_2369() - { - } - [Fact] - public void Test_2370() - { - } - [Fact] - public void Test_2371() - { - } - [Fact] - public void Test_2372() - { - } - [Fact] - public void Test_2373() - { - } - [Fact] - public void Test_2374() - { - } - [Fact] - public void Test_2375() - { - } - [Fact] - public void Test_2376() - { - } - [Fact] - public void Test_2377() - { - } - [Fact] - public void Test_2378() - { - } - [Fact] - public void Test_2379() - { - } - [Fact] - public void Test_2380() - { - } - [Fact] - public void Test_2381() - { - } - [Fact] - public void Test_2382() - { - } - [Fact] - public void Test_2383() - { - } - [Fact] - public void Test_2384() - { - } - [Fact] - public void Test_2385() - { - } - [Fact] - public void Test_2386() - { - } - [Fact] - public void Test_2387() - { - } - [Fact] - public void Test_2388() - { - } - [Fact] - public void Test_2389() - { - } - [Fact] - public void Test_2390() - { - } - [Fact] - public void Test_2391() - { - } - [Fact] - public void Test_2392() - { - } - [Fact] - public void Test_2393() - { - } - [Fact] - public void Test_2394() - { - } - [Fact] - public void Test_2395() - { - } - [Fact] - public void Test_2396() - { - } - [Fact] - public void Test_2397() - { - } - [Fact] - public void Test_2398() - { - } - [Fact] - public void Test_2399() - { - } - [Fact] - public void Test_2400() - { - } - [Fact] - public void Test_2401() - { - } - [Fact] - public void Test_2402() - { - } - [Fact] - public void Test_2403() - { - } - [Fact] - public void Test_2404() - { - } - [Fact] - public void Test_2405() - { - } - [Fact] - public void Test_2406() - { - } - [Fact] - public void Test_2407() - { - } - [Fact] - public void Test_2408() - { - } - [Fact] - public void Test_2409() - { - } - [Fact] - public void Test_2410() - { - } - [Fact] - public void Test_2411() - { - } - [Fact] - public void Test_2412() - { - } - [Fact] - public void Test_2413() - { - } - [Fact] - public void Test_2414() - { - } - [Fact] - public void Test_2415() - { - } - [Fact] - public void Test_2416() - { - } - [Fact] - public void Test_2417() - { - } - [Fact] - public void Test_2418() - { - } - [Fact] - public void Test_2419() - { - } - [Fact] - public void Test_2420() - { - } - [Fact] - public void Test_2421() - { - } - [Fact] - public void Test_2422() - { - } - [Fact] - public void Test_2423() - { - } - [Fact] - public void Test_2424() - { - } - [Fact] - public void Test_2425() - { - } - [Fact] - public void Test_2426() - { - } - [Fact] - public void Test_2427() - { - } - [Fact] - public void Test_2428() - { - } - [Fact] - public void Test_2429() - { - } - [Fact] - public void Test_2430() - { - } - [Fact] - public void Test_2431() - { - } - [Fact] - public void Test_2432() - { - } - [Fact] - public void Test_2433() - { - } - [Fact] - public void Test_2434() - { - } - [Fact] - public void Test_2435() - { - } - [Fact] - public void Test_2436() - { - } - [Fact] - public void Test_2437() - { - } - [Fact] - public void Test_2438() - { - } - [Fact] - public void Test_2439() - { - } - [Fact] - public void Test_2440() - { - } - [Fact] - public void Test_2441() - { - } - [Fact] - public void Test_2442() - { - } - [Fact] - public void Test_2443() - { - } - [Fact] - public void Test_2444() - { - } - [Fact] - public void Test_2445() - { - } - [Fact] - public void Test_2446() - { - } - [Fact] - public void Test_2447() - { - } - [Fact] - public void Test_2448() - { - } - [Fact] - public void Test_2449() - { - } - [Fact] - public void Test_2450() - { - } - [Fact] - public void Test_2451() - { - } - [Fact] - public void Test_2452() - { - } - [Fact] - public void Test_2453() - { - } - [Fact] - public void Test_2454() - { - } - [Fact] - public void Test_2455() - { - } - [Fact] - public void Test_2456() - { - } - [Fact] - public void Test_2457() - { - } - [Fact] - public void Test_2458() - { - } - [Fact] - public void Test_2459() - { - } - [Fact] - public void Test_2460() - { - } - [Fact] - public void Test_2461() - { - } - [Fact] - public void Test_2462() - { - } - [Fact] - public void Test_2463() - { - } - [Fact] - public void Test_2464() - { - } - [Fact] - public void Test_2465() - { - } - [Fact] - public void Test_2466() - { - } - [Fact] - public void Test_2467() - { - } - [Fact] - public void Test_2468() - { - } - [Fact] - public void Test_2469() - { - } - [Fact] - public void Test_2470() - { - } - [Fact] - public void Test_2471() - { - } - [Fact] - public void Test_2472() - { - } - [Fact] - public void Test_2473() - { - } - [Fact] - public void Test_2474() - { - } - [Fact] - public void Test_2475() - { - } - [Fact] - public void Test_2476() - { - } - [Fact] - public void Test_2477() - { - } - [Fact] - public void Test_2478() - { - } - [Fact] - public void Test_2479() - { - } - [Fact] - public void Test_2480() - { - } - [Fact] - public void Test_2481() - { - } - [Fact] - public void Test_2482() - { - } - [Fact] - public void Test_2483() - { - } - [Fact] - public void Test_2484() - { - } - [Fact] - public void Test_2485() - { - } - [Fact] - public void Test_2486() - { - } - [Fact] - public void Test_2487() - { - } - [Fact] - public void Test_2488() - { - } - [Fact] - public void Test_2489() - { - } - [Fact] - public void Test_2490() - { - } - [Fact] - public void Test_2491() - { - } - [Fact] - public void Test_2492() - { - } - [Fact] - public void Test_2493() - { - } - [Fact] - public void Test_2494() - { - } - [Fact] - public void Test_2495() - { - } - [Fact] - public void Test_2496() - { - } - [Fact] - public void Test_2497() - { - } - [Fact] - public void Test_2498() - { - } - [Fact] - public void Test_2499() - { - } - [Fact] - public void Test_2500() - { - } - [Fact] - public void Test_2501() - { - } - [Fact] - public void Test_2502() - { - } - [Fact] - public void Test_2503() - { - } - [Fact] - public void Test_2504() - { - } - [Fact] - public void Test_2505() - { - } - [Fact] - public void Test_2506() - { - } - [Fact] - public void Test_2507() - { - } - [Fact] - public void Test_2508() - { - } - [Fact] - public void Test_2509() - { - } - [Fact] - public void Test_2510() - { - } - [Fact] - public void Test_2511() - { - } - [Fact] - public void Test_2512() - { - } - [Fact] - public void Test_2513() - { - } - [Fact] - public void Test_2514() - { - } - [Fact] - public void Test_2515() - { - } - [Fact] - public void Test_2516() - { - } - [Fact] - public void Test_2517() - { - } - [Fact] - public void Test_2518() - { - } - [Fact] - public void Test_2519() - { - } - [Fact] - public void Test_2520() - { - } - [Fact] - public void Test_2521() - { - } - [Fact] - public void Test_2522() - { - } - [Fact] - public void Test_2523() - { - } - [Fact] - public void Test_2524() - { - } - [Fact] - public void Test_2525() - { - } - [Fact] - public void Test_2526() - { - } - [Fact] - public void Test_2527() - { - } - [Fact] - public void Test_2528() - { - } - [Fact] - public void Test_2529() - { - } - [Fact] - public void Test_2530() - { - } - [Fact] - public void Test_2531() - { - } - [Fact] - public void Test_2532() - { - } - [Fact] - public void Test_2533() - { - } - [Fact] - public void Test_2534() - { - } - [Fact] - public void Test_2535() - { - } - [Fact] - public void Test_2536() - { - } - [Fact] - public void Test_2537() - { - } - [Fact] - public void Test_2538() - { - } - [Fact] - public void Test_2539() - { - } - [Fact] - public void Test_2540() - { - } - [Fact] - public void Test_2541() - { - } - [Fact] - public void Test_2542() - { - } - [Fact] - public void Test_2543() - { - } - [Fact] - public void Test_2544() - { - } - [Fact] - public void Test_2545() - { - } - [Fact] - public void Test_2546() - { - } - [Fact] - public void Test_2547() - { - } - [Fact] - public void Test_2548() - { - } - [Fact] - public void Test_2549() - { - } - [Fact] - public void Test_2550() - { - } - [Fact] - public void Test_2551() - { - } - [Fact] - public void Test_2552() - { - } - [Fact] - public void Test_2553() - { - } - [Fact] - public void Test_2554() - { - } - [Fact] - public void Test_2555() - { - } - [Fact] - public void Test_2556() - { - } - [Fact] - public void Test_2557() - { - } - [Fact] - public void Test_2558() - { - } - [Fact] - public void Test_2559() - { - } - [Fact] - public void Test_2560() - { - } - [Fact] - public void Test_2561() - { - } - [Fact] - public void Test_2562() - { - } - [Fact] - public void Test_2563() - { - } - [Fact] - public void Test_2564() - { - } - [Fact] - public void Test_2565() - { - } - [Fact] - public void Test_2566() - { - } - [Fact] - public void Test_2567() - { - } - [Fact] - public void Test_2568() - { - } - [Fact] - public void Test_2569() - { - } - [Fact] - public void Test_2570() - { - } - [Fact] - public void Test_2571() - { - } - [Fact] - public void Test_2572() - { - } - [Fact] - public void Test_2573() - { - } - [Fact] - public void Test_2574() - { - } - [Fact] - public void Test_2575() - { - } - [Fact] - public void Test_2576() - { - } - [Fact] - public void Test_2577() - { - } - [Fact] - public void Test_2578() - { - } - [Fact] - public void Test_2579() - { - } - [Fact] - public void Test_2580() - { - } - [Fact] - public void Test_2581() - { - } - [Fact] - public void Test_2582() - { - } - [Fact] - public void Test_2583() - { - } - [Fact] - public void Test_2584() - { - } - [Fact] - public void Test_2585() - { - } - [Fact] - public void Test_2586() - { - } - [Fact] - public void Test_2587() - { - } - [Fact] - public void Test_2588() - { - } - [Fact] - public void Test_2589() - { - } - [Fact] - public void Test_2590() - { - } - [Fact] - public void Test_2591() - { - } - [Fact] - public void Test_2592() - { - } - [Fact] - public void Test_2593() - { - } - [Fact] - public void Test_2594() - { - } - [Fact] - public void Test_2595() - { - } - [Fact] - public void Test_2596() - { - } - [Fact] - public void Test_2597() - { - } - [Fact] - public void Test_2598() - { - } - [Fact] - public void Test_2599() - { - } - [Fact] - public void Test_2600() - { - } - [Fact] - public void Test_2601() - { - } - [Fact] - public void Test_2602() - { - } - [Fact] - public void Test_2603() - { - } - [Fact] - public void Test_2604() - { - } - [Fact] - public void Test_2605() - { - } - [Fact] - public void Test_2606() - { - } - [Fact] - public void Test_2607() - { - } - [Fact] - public void Test_2608() - { - } - [Fact] - public void Test_2609() - { - } - [Fact] - public void Test_2610() - { - } - [Fact] - public void Test_2611() - { - } - [Fact] - public void Test_2612() - { - } - [Fact] - public void Test_2613() - { - } - [Fact] - public void Test_2614() - { - } - [Fact] - public void Test_2615() - { - } - [Fact] - public void Test_2616() - { - } - [Fact] - public void Test_2617() - { - } - [Fact] - public void Test_2618() - { - } - [Fact] - public void Test_2619() - { - } - [Fact] - public void Test_2620() - { - } - [Fact] - public void Test_2621() - { - } - [Fact] - public void Test_2622() - { - } - [Fact] - public void Test_2623() - { - } - [Fact] - public void Test_2624() - { - } - [Fact] - public void Test_2625() - { - } - [Fact] - public void Test_2626() - { - } - [Fact] - public void Test_2627() - { - } - [Fact] - public void Test_2628() - { - } - [Fact] - public void Test_2629() - { - } - [Fact] - public void Test_2630() - { - } - [Fact] - public void Test_2631() - { - } - [Fact] - public void Test_2632() - { - } - [Fact] - public void Test_2633() - { - } - [Fact] - public void Test_2634() - { - } - [Fact] - public void Test_2635() - { - } - [Fact] - public void Test_2636() - { - } - [Fact] - public void Test_2637() - { - } - [Fact] - public void Test_2638() - { - } - [Fact] - public void Test_2639() - { - } - [Fact] - public void Test_2640() - { - } - [Fact] - public void Test_2641() - { - } - [Fact] - public void Test_2642() - { - } - [Fact] - public void Test_2643() - { - } - [Fact] - public void Test_2644() - { - } - [Fact] - public void Test_2645() - { - } - [Fact] - public void Test_2646() - { - } - [Fact] - public void Test_2647() - { - } - [Fact] - public void Test_2648() - { - } - [Fact] - public void Test_2649() - { - } - [Fact] - public void Test_2650() - { - } - [Fact] - public void Test_2651() - { - } - [Fact] - public void Test_2652() - { - } - [Fact] - public void Test_2653() - { - } - [Fact] - public void Test_2654() - { - } - [Fact] - public void Test_2655() - { - } - [Fact] - public void Test_2656() - { - } - [Fact] - public void Test_2657() - { - } - [Fact] - public void Test_2658() - { - } - [Fact] - public void Test_2659() - { - } - [Fact] - public void Test_2660() - { - } - [Fact] - public void Test_2661() - { - } - [Fact] - public void Test_2662() - { - } - [Fact] - public void Test_2663() - { - } - [Fact] - public void Test_2664() - { - } - [Fact] - public void Test_2665() - { - } - [Fact] - public void Test_2666() - { - } - [Fact] - public void Test_2667() - { - } - [Fact] - public void Test_2668() - { - } - [Fact] - public void Test_2669() - { - } - [Fact] - public void Test_2670() - { - } - [Fact] - public void Test_2671() - { - } - [Fact] - public void Test_2672() - { - } - [Fact] - public void Test_2673() - { - } - [Fact] - public void Test_2674() - { - } - [Fact] - public void Test_2675() - { - } - [Fact] - public void Test_2676() - { - } - [Fact] - public void Test_2677() - { - } - [Fact] - public void Test_2678() - { - } - [Fact] - public void Test_2679() - { - } - [Fact] - public void Test_2680() - { - } - [Fact] - public void Test_2681() - { - } - [Fact] - public void Test_2682() - { - } - [Fact] - public void Test_2683() - { - } - [Fact] - public void Test_2684() - { - } - [Fact] - public void Test_2685() - { - } - [Fact] - public void Test_2686() - { - } - [Fact] - public void Test_2687() - { - } - [Fact] - public void Test_2688() - { - } - [Fact] - public void Test_2689() - { - } - [Fact] - public void Test_2690() - { - } - [Fact] - public void Test_2691() - { - } - [Fact] - public void Test_2692() - { - } - [Fact] - public void Test_2693() - { - } - [Fact] - public void Test_2694() - { - } - [Fact] - public void Test_2695() - { - } - [Fact] - public void Test_2696() - { - } - [Fact] - public void Test_2697() - { - } - [Fact] - public void Test_2698() - { - } - [Fact] - public void Test_2699() - { - } - [Fact] - public void Test_2700() - { - } - [Fact] - public void Test_2701() - { - } - [Fact] - public void Test_2702() - { - } - [Fact] - public void Test_2703() - { - } - [Fact] - public void Test_2704() - { - } - [Fact] - public void Test_2705() - { - } - [Fact] - public void Test_2706() - { - } - [Fact] - public void Test_2707() - { - } - [Fact] - public void Test_2708() - { - } - [Fact] - public void Test_2709() - { - } - [Fact] - public void Test_2710() - { - } - [Fact] - public void Test_2711() - { - } - [Fact] - public void Test_2712() - { - } - [Fact] - public void Test_2713() - { - } - [Fact] - public void Test_2714() - { - } - [Fact] - public void Test_2715() - { - } - [Fact] - public void Test_2716() - { - } - [Fact] - public void Test_2717() - { - } - [Fact] - public void Test_2718() - { - } - [Fact] - public void Test_2719() - { - } - [Fact] - public void Test_2720() - { - } - [Fact] - public void Test_2721() - { - } - [Fact] - public void Test_2722() - { - } - [Fact] - public void Test_2723() - { - } - [Fact] - public void Test_2724() - { - } - [Fact] - public void Test_2725() - { - } - [Fact] - public void Test_2726() - { - } - [Fact] - public void Test_2727() - { - } - [Fact] - public void Test_2728() - { - } - [Fact] - public void Test_2729() - { - } - [Fact] - public void Test_2730() - { - } - [Fact] - public void Test_2731() - { - } - [Fact] - public void Test_2732() - { - } - [Fact] - public void Test_2733() - { - } - [Fact] - public void Test_2734() - { - } - [Fact] - public void Test_2735() - { - } - [Fact] - public void Test_2736() - { - } - [Fact] - public void Test_2737() - { - } - [Fact] - public void Test_2738() - { - } - [Fact] - public void Test_2739() - { - } - [Fact] - public void Test_2740() - { - } - [Fact] - public void Test_2741() - { - } - [Fact] - public void Test_2742() - { - } - [Fact] - public void Test_2743() - { - } - [Fact] - public void Test_2744() - { - } - [Fact] - public void Test_2745() - { - } - [Fact] - public void Test_2746() - { - } - [Fact] - public void Test_2747() - { - } - [Fact] - public void Test_2748() - { - } - [Fact] - public void Test_2749() - { - } - [Fact] - public void Test_2750() - { - } - [Fact] - public void Test_2751() - { - } - [Fact] - public void Test_2752() - { - } - [Fact] - public void Test_2753() - { - } - [Fact] - public void Test_2754() - { - } - [Fact] - public void Test_2755() - { - } - [Fact] - public void Test_2756() - { - } - [Fact] - public void Test_2757() - { - } - [Fact] - public void Test_2758() - { - } - [Fact] - public void Test_2759() - { - } - [Fact] - public void Test_2760() - { - } - [Fact] - public void Test_2761() - { - } - [Fact] - public void Test_2762() - { - } - [Fact] - public void Test_2763() - { - } - [Fact] - public void Test_2764() - { - } - [Fact] - public void Test_2765() - { - } - [Fact] - public void Test_2766() - { - } - [Fact] - public void Test_2767() - { - } - [Fact] - public void Test_2768() - { - } - [Fact] - public void Test_2769() - { - } - [Fact] - public void Test_2770() - { - } - [Fact] - public void Test_2771() - { - } - [Fact] - public void Test_2772() - { - } - [Fact] - public void Test_2773() - { - } - [Fact] - public void Test_2774() - { - } - [Fact] - public void Test_2775() - { - } - [Fact] - public void Test_2776() - { - } - [Fact] - public void Test_2777() - { - } - [Fact] - public void Test_2778() - { - } - [Fact] - public void Test_2779() - { - } - [Fact] - public void Test_2780() - { - } - [Fact] - public void Test_2781() - { - } - [Fact] - public void Test_2782() - { - } - [Fact] - public void Test_2783() - { - } - [Fact] - public void Test_2784() - { - } - [Fact] - public void Test_2785() - { - } - [Fact] - public void Test_2786() - { - } - [Fact] - public void Test_2787() - { - } - [Fact] - public void Test_2788() - { - } - [Fact] - public void Test_2789() - { - } - [Fact] - public void Test_2790() - { - } - [Fact] - public void Test_2791() - { - } - [Fact] - public void Test_2792() - { - } - [Fact] - public void Test_2793() - { - } - [Fact] - public void Test_2794() - { - } - [Fact] - public void Test_2795() - { - } - [Fact] - public void Test_2796() - { - } - [Fact] - public void Test_2797() - { - } - [Fact] - public void Test_2798() - { - } - [Fact] - public void Test_2799() - { - } - [Fact] - public void Test_2800() - { - } - [Fact] - public void Test_2801() - { - } - [Fact] - public void Test_2802() - { - } - [Fact] - public void Test_2803() - { - } - [Fact] - public void Test_2804() - { - } - [Fact] - public void Test_2805() - { - } - [Fact] - public void Test_2806() - { - } - [Fact] - public void Test_2807() - { - } - [Fact] - public void Test_2808() - { - } - [Fact] - public void Test_2809() - { - } - [Fact] - public void Test_2810() - { - } - [Fact] - public void Test_2811() - { - } - [Fact] - public void Test_2812() - { - } - [Fact] - public void Test_2813() - { - } - [Fact] - public void Test_2814() - { - } - [Fact] - public void Test_2815() - { - } - [Fact] - public void Test_2816() - { - } - [Fact] - public void Test_2817() - { - } - [Fact] - public void Test_2818() - { - } - [Fact] - public void Test_2819() - { - } - [Fact] - public void Test_2820() - { - } - [Fact] - public void Test_2821() - { - } - [Fact] - public void Test_2822() - { - } - [Fact] - public void Test_2823() - { - } - [Fact] - public void Test_2824() - { - } - [Fact] - public void Test_2825() - { - } - [Fact] - public void Test_2826() - { - } - [Fact] - public void Test_2827() - { - } - [Fact] - public void Test_2828() - { - } - [Fact] - public void Test_2829() - { - } - [Fact] - public void Test_2830() - { - } - [Fact] - public void Test_2831() - { - } - [Fact] - public void Test_2832() - { - } - [Fact] - public void Test_2833() - { - } - [Fact] - public void Test_2834() - { - } - [Fact] - public void Test_2835() - { - } - [Fact] - public void Test_2836() - { - } - [Fact] - public void Test_2837() - { - } - [Fact] - public void Test_2838() - { - } - [Fact] - public void Test_2839() - { - } - [Fact] - public void Test_2840() - { - } - [Fact] - public void Test_2841() - { - } - [Fact] - public void Test_2842() - { - } - [Fact] - public void Test_2843() - { - } - [Fact] - public void Test_2844() - { - } - [Fact] - public void Test_2845() - { - } - [Fact] - public void Test_2846() - { - } - [Fact] - public void Test_2847() - { - } - [Fact] - public void Test_2848() - { - } - [Fact] - public void Test_2849() - { - } - [Fact] - public void Test_2850() - { - } - [Fact] - public void Test_2851() - { - } - [Fact] - public void Test_2852() - { - } - [Fact] - public void Test_2853() - { - } - [Fact] - public void Test_2854() - { - } - [Fact] - public void Test_2855() - { - } - [Fact] - public void Test_2856() - { - } - [Fact] - public void Test_2857() - { - } - [Fact] - public void Test_2858() - { - } - [Fact] - public void Test_2859() - { - } - [Fact] - public void Test_2860() - { - } - [Fact] - public void Test_2861() - { - } - [Fact] - public void Test_2862() - { - } - [Fact] - public void Test_2863() - { - } - [Fact] - public void Test_2864() - { - } - [Fact] - public void Test_2865() - { - } - [Fact] - public void Test_2866() - { - } - [Fact] - public void Test_2867() - { - } - [Fact] - public void Test_2868() - { - } - [Fact] - public void Test_2869() - { - } - [Fact] - public void Test_2870() - { - } - [Fact] - public void Test_2871() - { - } - [Fact] - public void Test_2872() - { - } - [Fact] - public void Test_2873() - { - } - [Fact] - public void Test_2874() - { - } - [Fact] - public void Test_2875() - { - } - [Fact] - public void Test_2876() - { - } - [Fact] - public void Test_2877() - { - } - [Fact] - public void Test_2878() - { - } - [Fact] - public void Test_2879() - { - } - [Fact] - public void Test_2880() - { - } - [Fact] - public void Test_2881() - { - } - [Fact] - public void Test_2882() - { - } - [Fact] - public void Test_2883() - { - } - [Fact] - public void Test_2884() - { - } - [Fact] - public void Test_2885() - { - } - [Fact] - public void Test_2886() - { - } - [Fact] - public void Test_2887() - { - } - [Fact] - public void Test_2888() - { - } - [Fact] - public void Test_2889() - { - } - [Fact] - public void Test_2890() - { - } - [Fact] - public void Test_2891() - { - } - [Fact] - public void Test_2892() - { - } - [Fact] - public void Test_2893() - { - } - [Fact] - public void Test_2894() - { - } - [Fact] - public void Test_2895() - { - } - [Fact] - public void Test_2896() - { - } - [Fact] - public void Test_2897() - { - } - [Fact] - public void Test_2898() - { - } - [Fact] - public void Test_2899() - { - } - [Fact] - public void Test_2900() - { - } - [Fact] - public void Test_2901() - { - } - [Fact] - public void Test_2902() - { - } - [Fact] - public void Test_2903() - { - } - [Fact] - public void Test_2904() - { - } - [Fact] - public void Test_2905() - { - } - [Fact] - public void Test_2906() - { - } - [Fact] - public void Test_2907() - { - } - [Fact] - public void Test_2908() - { - } - [Fact] - public void Test_2909() - { - } - [Fact] - public void Test_2910() - { - } - [Fact] - public void Test_2911() - { - } - [Fact] - public void Test_2912() - { - } - [Fact] - public void Test_2913() - { - } - [Fact] - public void Test_2914() - { - } - [Fact] - public void Test_2915() - { - } - [Fact] - public void Test_2916() - { - } - [Fact] - public void Test_2917() - { - } - [Fact] - public void Test_2918() - { - } - [Fact] - public void Test_2919() - { - } - [Fact] - public void Test_2920() - { - } - [Fact] - public void Test_2921() - { - } - [Fact] - public void Test_2922() - { - } - [Fact] - public void Test_2923() - { - } - [Fact] - public void Test_2924() - { - } - [Fact] - public void Test_2925() - { - } - [Fact] - public void Test_2926() - { - } - [Fact] - public void Test_2927() - { - } - [Fact] - public void Test_2928() - { - } - [Fact] - public void Test_2929() - { - } - [Fact] - public void Test_2930() - { - } - [Fact] - public void Test_2931() - { - } - [Fact] - public void Test_2932() - { - } - [Fact] - public void Test_2933() - { - } - [Fact] - public void Test_2934() - { - } - [Fact] - public void Test_2935() - { - } - [Fact] - public void Test_2936() - { - } - [Fact] - public void Test_2937() - { - } - [Fact] - public void Test_2938() - { - } - [Fact] - public void Test_2939() - { - } - [Fact] - public void Test_2940() - { - } - [Fact] - public void Test_2941() - { - } - [Fact] - public void Test_2942() - { - } - [Fact] - public void Test_2943() - { - } - [Fact] - public void Test_2944() - { - } - [Fact] - public void Test_2945() - { - } - [Fact] - public void Test_2946() - { - } - [Fact] - public void Test_2947() - { - } - [Fact] - public void Test_2948() - { - } - [Fact] - public void Test_2949() - { - } - [Fact] - public void Test_2950() - { - } - [Fact] - public void Test_2951() - { - } - [Fact] - public void Test_2952() - { - } - [Fact] - public void Test_2953() - { - } - [Fact] - public void Test_2954() - { - } - [Fact] - public void Test_2955() - { - } - [Fact] - public void Test_2956() - { - } - [Fact] - public void Test_2957() - { - } - [Fact] - public void Test_2958() - { - } - [Fact] - public void Test_2959() - { - } - [Fact] - public void Test_2960() - { - } - [Fact] - public void Test_2961() - { - } - [Fact] - public void Test_2962() - { - } - [Fact] - public void Test_2963() - { - } - [Fact] - public void Test_2964() - { - } - [Fact] - public void Test_2965() - { - } - [Fact] - public void Test_2966() - { - } - [Fact] - public void Test_2967() - { - } - [Fact] - public void Test_2968() - { - } - [Fact] - public void Test_2969() - { - } - [Fact] - public void Test_2970() - { - } - [Fact] - public void Test_2971() - { - } - [Fact] - public void Test_2972() - { - } - [Fact] - public void Test_2973() - { - } - [Fact] - public void Test_2974() - { - } - [Fact] - public void Test_2975() - { - } - [Fact] - public void Test_2976() - { - } - [Fact] - public void Test_2977() - { - } - [Fact] - public void Test_2978() - { - } - [Fact] - public void Test_2979() - { - } - [Fact] - public void Test_2980() - { - } - [Fact] - public void Test_2981() - { - } - [Fact] - public void Test_2982() - { - } - [Fact] - public void Test_2983() - { - } - [Fact] - public void Test_2984() - { - } - [Fact] - public void Test_2985() - { - } - [Fact] - public void Test_2986() - { - } - [Fact] - public void Test_2987() - { - } - [Fact] - public void Test_2988() - { - } - [Fact] - public void Test_2989() - { - } - [Fact] - public void Test_2990() - { - } - [Fact] - public void Test_2991() - { - } - [Fact] - public void Test_2992() - { - } - [Fact] - public void Test_2993() - { - } - [Fact] - public void Test_2994() - { - } - [Fact] - public void Test_2995() - { - } - [Fact] - public void Test_2996() - { - } - [Fact] - public void Test_2997() - { - } - [Fact] - public void Test_2998() - { - } - [Fact] - public void Test_2999() - { - } - [Fact] - public void Test_3000() - { - } - [Fact] - public void Test_3001() - { - } - [Fact] - public void Test_3002() - { - } - [Fact] - public void Test_3003() - { - } - [Fact] - public void Test_3004() - { - } - [Fact] - public void Test_3005() - { - } - [Fact] - public void Test_3006() - { - } - [Fact] - public void Test_3007() - { - } - [Fact] - public void Test_3008() - { - } - [Fact] - public void Test_3009() - { - } - [Fact] - public void Test_3010() - { - } - [Fact] - public void Test_3011() - { - } - [Fact] - public void Test_3012() - { - } - [Fact] - public void Test_3013() - { - } - [Fact] - public void Test_3014() - { - } - [Fact] - public void Test_3015() - { - } - [Fact] - public void Test_3016() - { - } - [Fact] - public void Test_3017() - { - } - [Fact] - public void Test_3018() - { - } - [Fact] - public void Test_3019() - { - } - [Fact] - public void Test_3020() - { - } - [Fact] - public void Test_3021() - { - } - [Fact] - public void Test_3022() - { - } - [Fact] - public void Test_3023() - { - } - [Fact] - public void Test_3024() - { - } - [Fact] - public void Test_3025() - { - } - [Fact] - public void Test_3026() - { - } - [Fact] - public void Test_3027() - { - } - [Fact] - public void Test_3028() - { - } - [Fact] - public void Test_3029() - { - } - [Fact] - public void Test_3030() - { - } - [Fact] - public void Test_3031() - { - } - [Fact] - public void Test_3032() - { - } - [Fact] - public void Test_3033() - { - } - [Fact] - public void Test_3034() - { - } - [Fact] - public void Test_3035() - { - } - [Fact] - public void Test_3036() - { - } - [Fact] - public void Test_3037() - { - } - [Fact] - public void Test_3038() - { - } - [Fact] - public void Test_3039() - { - } - [Fact] - public void Test_3040() - { - } - [Fact] - public void Test_3041() - { - } - [Fact] - public void Test_3042() - { - } - [Fact] - public void Test_3043() - { - } - [Fact] - public void Test_3044() - { - } - [Fact] - public void Test_3045() - { - } - [Fact] - public void Test_3046() - { - } - [Fact] - public void Test_3047() - { - } - [Fact] - public void Test_3048() - { - } - [Fact] - public void Test_3049() - { - } - [Fact] - public void Test_3050() - { - } - [Fact] - public void Test_3051() - { - } - [Fact] - public void Test_3052() - { - } - [Fact] - public void Test_3053() - { - } - [Fact] - public void Test_3054() - { - } - [Fact] - public void Test_3055() - { - } - [Fact] - public void Test_3056() - { - } - [Fact] - public void Test_3057() - { - } - [Fact] - public void Test_3058() - { - } - [Fact] - public void Test_3059() - { - } - [Fact] - public void Test_3060() - { - } - [Fact] - public void Test_3061() - { - } - [Fact] - public void Test_3062() - { - } - [Fact] - public void Test_3063() - { - } - [Fact] - public void Test_3064() - { - } - [Fact] - public void Test_3065() - { - } - [Fact] - public void Test_3066() - { - } - [Fact] - public void Test_3067() - { - } - [Fact] - public void Test_3068() - { - } - [Fact] - public void Test_3069() - { - } - [Fact] - public void Test_3070() - { - } - [Fact] - public void Test_3071() - { - } - [Fact] - public void Test_3072() - { - } - [Fact] - public void Test_3073() - { - } - [Fact] - public void Test_3074() - { - } - [Fact] - public void Test_3075() - { - } - [Fact] - public void Test_3076() - { - } - [Fact] - public void Test_3077() - { - } - [Fact] - public void Test_3078() - { - } - [Fact] - public void Test_3079() - { - } - [Fact] - public void Test_3080() - { - } - [Fact] - public void Test_3081() - { - } - [Fact] - public void Test_3082() - { - } - [Fact] - public void Test_3083() - { - } - [Fact] - public void Test_3084() - { - } - [Fact] - public void Test_3085() - { - } - [Fact] - public void Test_3086() - { - } - [Fact] - public void Test_3087() - { - } - [Fact] - public void Test_3088() - { - } - [Fact] - public void Test_3089() - { - } - [Fact] - public void Test_3090() - { - } - [Fact] - public void Test_3091() - { - } - [Fact] - public void Test_3092() - { - } - [Fact] - public void Test_3093() - { - } - [Fact] - public void Test_3094() - { - } - [Fact] - public void Test_3095() - { - } - [Fact] - public void Test_3096() - { - } - [Fact] - public void Test_3097() - { - } - [Fact] - public void Test_3098() - { - } - [Fact] - public void Test_3099() - { - } - [Fact] - public void Test_3100() - { - } - [Fact] - public void Test_3101() - { - } - [Fact] - public void Test_3102() - { - } - [Fact] - public void Test_3103() - { - } - [Fact] - public void Test_3104() - { - } - [Fact] - public void Test_3105() - { - } - [Fact] - public void Test_3106() - { - } - [Fact] - public void Test_3107() - { - } - [Fact] - public void Test_3108() - { - } - [Fact] - public void Test_3109() - { - } - [Fact] - public void Test_3110() - { - } - [Fact] - public void Test_3111() - { - } - [Fact] - public void Test_3112() - { - } - [Fact] - public void Test_3113() - { - } - [Fact] - public void Test_3114() - { - } - [Fact] - public void Test_3115() - { - } - [Fact] - public void Test_3116() - { - } - [Fact] - public void Test_3117() - { - } - [Fact] - public void Test_3118() - { - } - [Fact] - public void Test_3119() - { - } - [Fact] - public void Test_3120() - { - } - [Fact] - public void Test_3121() - { - } - [Fact] - public void Test_3122() - { - } - [Fact] - public void Test_3123() - { - } - [Fact] - public void Test_3124() - { - } - [Fact] - public void Test_3125() - { - } - [Fact] - public void Test_3126() - { - } - [Fact] - public void Test_3127() - { - } - [Fact] - public void Test_3128() - { - } - [Fact] - public void Test_3129() - { - } - [Fact] - public void Test_3130() - { - } - [Fact] - public void Test_3131() - { - } - [Fact] - public void Test_3132() - { - } - [Fact] - public void Test_3133() - { - } - [Fact] - public void Test_3134() - { - } - [Fact] - public void Test_3135() - { - } - [Fact] - public void Test_3136() - { - } - [Fact] - public void Test_3137() - { - } - [Fact] - public void Test_3138() - { - } - [Fact] - public void Test_3139() - { - } - [Fact] - public void Test_3140() - { - } - [Fact] - public void Test_3141() - { - } - [Fact] - public void Test_3142() - { - } - [Fact] - public void Test_3143() - { - } - [Fact] - public void Test_3144() - { - } - [Fact] - public void Test_3145() - { - } - [Fact] - public void Test_3146() - { - } - [Fact] - public void Test_3147() - { - } - [Fact] - public void Test_3148() - { - } - [Fact] - public void Test_3149() - { - } - [Fact] - public void Test_3150() - { - } - [Fact] - public void Test_3151() - { - } - [Fact] - public void Test_3152() - { - } - [Fact] - public void Test_3153() - { - } - [Fact] - public void Test_3154() - { - } - [Fact] - public void Test_3155() - { - } - [Fact] - public void Test_3156() - { - } - [Fact] - public void Test_3157() - { - } - [Fact] - public void Test_3158() - { - } - [Fact] - public void Test_3159() - { - } - [Fact] - public void Test_3160() - { - } - [Fact] - public void Test_3161() - { - } - [Fact] - public void Test_3162() - { - } - [Fact] - public void Test_3163() - { - } - [Fact] - public void Test_3164() - { - } - [Fact] - public void Test_3165() - { - } - [Fact] - public void Test_3166() - { - } - [Fact] - public void Test_3167() - { - } - [Fact] - public void Test_3168() - { - } - [Fact] - public void Test_3169() - { - } - [Fact] - public void Test_3170() - { - } - [Fact] - public void Test_3171() - { - } - [Fact] - public void Test_3172() - { - } - [Fact] - public void Test_3173() - { - } - [Fact] - public void Test_3174() - { - } - [Fact] - public void Test_3175() - { - } - [Fact] - public void Test_3176() - { - } - [Fact] - public void Test_3177() - { - } - [Fact] - public void Test_3178() - { - } - [Fact] - public void Test_3179() - { - } - [Fact] - public void Test_3180() - { - } - [Fact] - public void Test_3181() - { - } - [Fact] - public void Test_3182() - { - } - [Fact] - public void Test_3183() - { - } - [Fact] - public void Test_3184() - { - } - [Fact] - public void Test_3185() - { - } - [Fact] - public void Test_3186() - { - } - [Fact] - public void Test_3187() - { - } - [Fact] - public void Test_3188() - { - } - [Fact] - public void Test_3189() - { - } - [Fact] - public void Test_3190() - { - } - [Fact] - public void Test_3191() - { - } - [Fact] - public void Test_3192() - { - } - [Fact] - public void Test_3193() - { - } - [Fact] - public void Test_3194() - { - } - [Fact] - public void Test_3195() - { - } - [Fact] - public void Test_3196() - { - } - [Fact] - public void Test_3197() - { - } - [Fact] - public void Test_3198() - { - } - [Fact] - public void Test_3199() - { - } - [Fact] - public void Test_3200() - { - } - [Fact] - public void Test_3201() - { - } - [Fact] - public void Test_3202() - { - } - [Fact] - public void Test_3203() - { - } - [Fact] - public void Test_3204() - { - } - [Fact] - public void Test_3205() - { - } - [Fact] - public void Test_3206() - { - } - [Fact] - public void Test_3207() - { - } - [Fact] - public void Test_3208() - { - } - [Fact] - public void Test_3209() - { - } - [Fact] - public void Test_3210() - { - } - [Fact] - public void Test_3211() - { - } - [Fact] - public void Test_3212() - { - } - [Fact] - public void Test_3213() - { - } - [Fact] - public void Test_3214() - { - } - [Fact] - public void Test_3215() - { - } - [Fact] - public void Test_3216() - { - } - [Fact] - public void Test_3217() - { - } - [Fact] - public void Test_3218() - { - } - [Fact] - public void Test_3219() - { - } - [Fact] - public void Test_3220() - { - } - [Fact] - public void Test_3221() - { - } - [Fact] - public void Test_3222() - { - } - [Fact] - public void Test_3223() - { - } - [Fact] - public void Test_3224() - { - } - [Fact] - public void Test_3225() - { - } - [Fact] - public void Test_3226() - { - } - [Fact] - public void Test_3227() - { - } - [Fact] - public void Test_3228() - { - } - [Fact] - public void Test_3229() - { - } - [Fact] - public void Test_3230() - { - } - [Fact] - public void Test_3231() - { - } - [Fact] - public void Test_3232() - { - } - [Fact] - public void Test_3233() - { - } - [Fact] - public void Test_3234() - { - } - [Fact] - public void Test_3235() - { - } - [Fact] - public void Test_3236() - { - } - [Fact] - public void Test_3237() - { - } - [Fact] - public void Test_3238() - { - } - [Fact] - public void Test_3239() - { - } - [Fact] - public void Test_3240() - { - } - [Fact] - public void Test_3241() - { - } - [Fact] - public void Test_3242() - { - } - [Fact] - public void Test_3243() - { - } - [Fact] - public void Test_3244() - { - } - [Fact] - public void Test_3245() - { - } - [Fact] - public void Test_3246() - { - } - [Fact] - public void Test_3247() - { - } - [Fact] - public void Test_3248() - { - } - [Fact] - public void Test_3249() - { - } - [Fact] - public void Test_3250() - { - } - [Fact] - public void Test_3251() - { - } - [Fact] - public void Test_3252() - { - } - [Fact] - public void Test_3253() - { - } - [Fact] - public void Test_3254() - { - } - [Fact] - public void Test_3255() - { - } - [Fact] - public void Test_3256() - { - } - [Fact] - public void Test_3257() - { - } - [Fact] - public void Test_3258() - { - } - [Fact] - public void Test_3259() - { - } - [Fact] - public void Test_3260() - { - } - [Fact] - public void Test_3261() - { - } - [Fact] - public void Test_3262() - { - } - [Fact] - public void Test_3263() - { - } - [Fact] - public void Test_3264() - { - } - [Fact] - public void Test_3265() - { - } - [Fact] - public void Test_3266() - { - } - [Fact] - public void Test_3267() - { - } - [Fact] - public void Test_3268() - { - } - [Fact] - public void Test_3269() - { - } - [Fact] - public void Test_3270() - { - } - [Fact] - public void Test_3271() - { - } - [Fact] - public void Test_3272() - { - } - [Fact] - public void Test_3273() - { - } - [Fact] - public void Test_3274() - { - } - [Fact] - public void Test_3275() - { - } - [Fact] - public void Test_3276() - { - } - [Fact] - public void Test_3277() - { - } - [Fact] - public void Test_3278() - { - } - [Fact] - public void Test_3279() - { - } - [Fact] - public void Test_3280() - { - } - [Fact] - public void Test_3281() - { - } - [Fact] - public void Test_3282() - { - } - [Fact] - public void Test_3283() - { - } - [Fact] - public void Test_3284() - { - } - [Fact] - public void Test_3285() - { - } - [Fact] - public void Test_3286() - { - } - [Fact] - public void Test_3287() - { - } - [Fact] - public void Test_3288() - { - } - [Fact] - public void Test_3289() - { - } - [Fact] - public void Test_3290() - { - } - [Fact] - public void Test_3291() - { - } - [Fact] - public void Test_3292() - { - } - [Fact] - public void Test_3293() - { - } - [Fact] - public void Test_3294() - { - } - [Fact] - public void Test_3295() - { - } - [Fact] - public void Test_3296() - { - } - [Fact] - public void Test_3297() - { - } - [Fact] - public void Test_3298() - { - } - [Fact] - public void Test_3299() - { - } - [Fact] - public void Test_3300() - { - } - [Fact] - public void Test_3301() - { - } - [Fact] - public void Test_3302() - { - } - [Fact] - public void Test_3303() - { - } - [Fact] - public void Test_3304() - { - } - [Fact] - public void Test_3305() - { - } - [Fact] - public void Test_3306() - { - } - [Fact] - public void Test_3307() - { - } - [Fact] - public void Test_3308() - { - } - [Fact] - public void Test_3309() - { - } - [Fact] - public void Test_3310() - { - } - [Fact] - public void Test_3311() - { - } - [Fact] - public void Test_3312() - { - } - [Fact] - public void Test_3313() - { - } - [Fact] - public void Test_3314() - { - } - [Fact] - public void Test_3315() - { - } - [Fact] - public void Test_3316() - { - } - [Fact] - public void Test_3317() - { - } - [Fact] - public void Test_3318() - { - } - [Fact] - public void Test_3319() - { - } - [Fact] - public void Test_3320() - { - } - [Fact] - public void Test_3321() - { - } - [Fact] - public void Test_3322() - { - } - [Fact] - public void Test_3323() - { - } - [Fact] - public void Test_3324() - { - } - [Fact] - public void Test_3325() - { - } - [Fact] - public void Test_3326() - { - } - [Fact] - public void Test_3327() - { - } - [Fact] - public void Test_3328() - { - } - [Fact] - public void Test_3329() - { - } - [Fact] - public void Test_3330() - { - } - [Fact] - public void Test_3331() - { - } - [Fact] - public void Test_3332() - { - } - [Fact] - public void Test_3333() - { - } - [Fact] - public void Test_3334() - { - } - [Fact] - public void Test_3335() - { - } - [Fact] - public void Test_3336() - { - } - [Fact] - public void Test_3337() - { - } - [Fact] - public void Test_3338() - { - } - [Fact] - public void Test_3339() - { - } - [Fact] - public void Test_3340() - { - } - [Fact] - public void Test_3341() - { - } - [Fact] - public void Test_3342() - { - } - [Fact] - public void Test_3343() - { - } - [Fact] - public void Test_3344() - { - } - [Fact] - public void Test_3345() - { - } - [Fact] - public void Test_3346() - { - } - [Fact] - public void Test_3347() - { - } - [Fact] - public void Test_3348() - { - } - [Fact] - public void Test_3349() - { - } - [Fact] - public void Test_3350() - { - } - [Fact] - public void Test_3351() - { - } - [Fact] - public void Test_3352() - { - } - [Fact] - public void Test_3353() - { - } - [Fact] - public void Test_3354() - { - } - [Fact] - public void Test_3355() - { - } - [Fact] - public void Test_3356() - { - } - [Fact] - public void Test_3357() - { - } - [Fact] - public void Test_3358() - { - } - [Fact] - public void Test_3359() - { - } - [Fact] - public void Test_3360() - { - } - [Fact] - public void Test_3361() - { - } - [Fact] - public void Test_3362() - { - } - [Fact] - public void Test_3363() - { - } - [Fact] - public void Test_3364() - { - } - [Fact] - public void Test_3365() - { - } - [Fact] - public void Test_3366() - { - } - [Fact] - public void Test_3367() - { - } - [Fact] - public void Test_3368() - { - } - [Fact] - public void Test_3369() - { - } - [Fact] - public void Test_3370() - { - } - [Fact] - public void Test_3371() - { - } - [Fact] - public void Test_3372() - { - } - [Fact] - public void Test_3373() - { - } - [Fact] - public void Test_3374() - { - } - [Fact] - public void Test_3375() - { - } - [Fact] - public void Test_3376() - { - } - [Fact] - public void Test_3377() - { - } - [Fact] - public void Test_3378() - { - } - [Fact] - public void Test_3379() - { - } - [Fact] - public void Test_3380() - { - } - [Fact] - public void Test_3381() - { - } - [Fact] - public void Test_3382() - { - } - [Fact] - public void Test_3383() - { - } - [Fact] - public void Test_3384() - { - } - [Fact] - public void Test_3385() - { - } - [Fact] - public void Test_3386() - { - } - [Fact] - public void Test_3387() - { - } - [Fact] - public void Test_3388() - { - } - [Fact] - public void Test_3389() - { - } - [Fact] - public void Test_3390() - { - } - [Fact] - public void Test_3391() - { - } - [Fact] - public void Test_3392() - { - } - [Fact] - public void Test_3393() - { - } - [Fact] - public void Test_3394() - { - } - [Fact] - public void Test_3395() - { - } - [Fact] - public void Test_3396() - { - } - [Fact] - public void Test_3397() - { - } - [Fact] - public void Test_3398() - { - } - [Fact] - public void Test_3399() - { - } - [Fact] - public void Test_3400() - { - } - [Fact] - public void Test_3401() - { - } - [Fact] - public void Test_3402() - { - } - [Fact] - public void Test_3403() - { - } - [Fact] - public void Test_3404() - { - } - [Fact] - public void Test_3405() - { - } - [Fact] - public void Test_3406() - { - } - [Fact] - public void Test_3407() - { - } - [Fact] - public void Test_3408() - { - } - [Fact] - public void Test_3409() - { - } - [Fact] - public void Test_3410() - { - } - [Fact] - public void Test_3411() - { - } - [Fact] - public void Test_3412() - { - } - [Fact] - public void Test_3413() - { - } - [Fact] - public void Test_3414() - { - } - [Fact] - public void Test_3415() - { - } - [Fact] - public void Test_3416() - { - } - [Fact] - public void Test_3417() - { - } - [Fact] - public void Test_3418() - { - } - [Fact] - public void Test_3419() - { - } - [Fact] - public void Test_3420() - { - } - [Fact] - public void Test_3421() - { - } - [Fact] - public void Test_3422() - { - } - [Fact] - public void Test_3423() - { - } - [Fact] - public void Test_3424() - { - } - [Fact] - public void Test_3425() - { - } - [Fact] - public void Test_3426() - { - } - [Fact] - public void Test_3427() - { - } - [Fact] - public void Test_3428() - { - } - [Fact] - public void Test_3429() - { - } - [Fact] - public void Test_3430() - { - } - [Fact] - public void Test_3431() - { - } - [Fact] - public void Test_3432() - { - } - [Fact] - public void Test_3433() - { - } - [Fact] - public void Test_3434() - { - } - [Fact] - public void Test_3435() - { - } - [Fact] - public void Test_3436() - { - } - [Fact] - public void Test_3437() - { - } - [Fact] - public void Test_3438() - { - } - [Fact] - public void Test_3439() - { - } - [Fact] - public void Test_3440() - { - } - [Fact] - public void Test_3441() - { - } - [Fact] - public void Test_3442() - { - } - [Fact] - public void Test_3443() - { - } - [Fact] - public void Test_3444() - { - } - [Fact] - public void Test_3445() - { - } - [Fact] - public void Test_3446() - { - } - [Fact] - public void Test_3447() - { - } - [Fact] - public void Test_3448() - { - } - [Fact] - public void Test_3449() - { - } - [Fact] - public void Test_3450() - { - } - [Fact] - public void Test_3451() - { - } - [Fact] - public void Test_3452() - { - } - [Fact] - public void Test_3453() - { - } - [Fact] - public void Test_3454() - { - } - [Fact] - public void Test_3455() - { - } - [Fact] - public void Test_3456() - { - } - [Fact] - public void Test_3457() - { - } - [Fact] - public void Test_3458() - { - } - [Fact] - public void Test_3459() - { - } - [Fact] - public void Test_3460() - { - } - [Fact] - public void Test_3461() - { - } - [Fact] - public void Test_3462() - { - } - [Fact] - public void Test_3463() - { - } - [Fact] - public void Test_3464() - { - } - [Fact] - public void Test_3465() - { - } - [Fact] - public void Test_3466() - { - } - [Fact] - public void Test_3467() - { - } - [Fact] - public void Test_3468() - { - } - [Fact] - public void Test_3469() - { - } - [Fact] - public void Test_3470() - { - } - [Fact] - public void Test_3471() - { - } - [Fact] - public void Test_3472() - { - } - [Fact] - public void Test_3473() - { - } - [Fact] - public void Test_3474() - { - } - [Fact] - public void Test_3475() - { - } - [Fact] - public void Test_3476() - { - } - [Fact] - public void Test_3477() - { - } - [Fact] - public void Test_3478() - { - } - [Fact] - public void Test_3479() - { - } - [Fact] - public void Test_3480() - { - } - [Fact] - public void Test_3481() - { - } - [Fact] - public void Test_3482() - { - } - [Fact] - public void Test_3483() - { - } - [Fact] - public void Test_3484() - { - } - [Fact] - public void Test_3485() - { - } - [Fact] - public void Test_3486() - { - } - [Fact] - public void Test_3487() - { - } - [Fact] - public void Test_3488() - { - } - [Fact] - public void Test_3489() - { - } - [Fact] - public void Test_3490() - { - } - [Fact] - public void Test_3491() - { - } - [Fact] - public void Test_3492() - { - } - [Fact] - public void Test_3493() - { - } - [Fact] - public void Test_3494() - { - } - [Fact] - public void Test_3495() - { - } - [Fact] - public void Test_3496() - { - } - [Fact] - public void Test_3497() - { - } - [Fact] - public void Test_3498() - { - } - [Fact] - public void Test_3499() - { - } - [Fact] - public void Test_3500() - { - } - [Fact] - public void Test_3501() - { - } - [Fact] - public void Test_3502() - { - } - [Fact] - public void Test_3503() - { - } - [Fact] - public void Test_3504() - { - } - [Fact] - public void Test_3505() - { - } - [Fact] - public void Test_3506() - { - } - [Fact] - public void Test_3507() - { - } - [Fact] - public void Test_3508() - { - } - [Fact] - public void Test_3509() - { - } - [Fact] - public void Test_3510() - { - } - [Fact] - public void Test_3511() - { - } - [Fact] - public void Test_3512() - { - } - [Fact] - public void Test_3513() - { - } - [Fact] - public void Test_3514() - { - } - [Fact] - public void Test_3515() - { - } - [Fact] - public void Test_3516() - { - } - [Fact] - public void Test_3517() - { - } - [Fact] - public void Test_3518() - { - } - [Fact] - public void Test_3519() - { - } - [Fact] - public void Test_3520() - { - } - [Fact] - public void Test_3521() - { - } - [Fact] - public void Test_3522() - { - } - [Fact] - public void Test_3523() - { - } - [Fact] - public void Test_3524() - { - } - [Fact] - public void Test_3525() - { - } - [Fact] - public void Test_3526() - { - } - [Fact] - public void Test_3527() - { - } - [Fact] - public void Test_3528() - { - } - [Fact] - public void Test_3529() - { - } - [Fact] - public void Test_3530() - { - } - [Fact] - public void Test_3531() - { - } - [Fact] - public void Test_3532() - { - } - [Fact] - public void Test_3533() - { - } - [Fact] - public void Test_3534() - { - } - [Fact] - public void Test_3535() - { - } - [Fact] - public void Test_3536() - { - } - [Fact] - public void Test_3537() - { - } - [Fact] - public void Test_3538() - { - } - [Fact] - public void Test_3539() - { - } - [Fact] - public void Test_3540() - { - } - [Fact] - public void Test_3541() - { - } - [Fact] - public void Test_3542() - { - } - [Fact] - public void Test_3543() - { - } - [Fact] - public void Test_3544() - { - } - [Fact] - public void Test_3545() - { - } - [Fact] - public void Test_3546() - { - } - [Fact] - public void Test_3547() - { - } - [Fact] - public void Test_3548() - { - } - [Fact] - public void Test_3549() - { - } - [Fact] - public void Test_3550() - { - } - [Fact] - public void Test_3551() - { - } - [Fact] - public void Test_3552() - { - } - [Fact] - public void Test_3553() - { - } - [Fact] - public void Test_3554() - { - } - [Fact] - public void Test_3555() - { - } - [Fact] - public void Test_3556() - { - } - [Fact] - public void Test_3557() - { - } - [Fact] - public void Test_3558() - { - } - [Fact] - public void Test_3559() - { - } - [Fact] - public void Test_3560() - { - } - [Fact] - public void Test_3561() - { - } - [Fact] - public void Test_3562() - { - } - [Fact] - public void Test_3563() - { - } - [Fact] - public void Test_3564() - { - } - [Fact] - public void Test_3565() - { - } - [Fact] - public void Test_3566() - { - } - [Fact] - public void Test_3567() - { - } - [Fact] - public void Test_3568() - { - } - [Fact] - public void Test_3569() - { - } - [Fact] - public void Test_3570() - { - } - [Fact] - public void Test_3571() - { - } - [Fact] - public void Test_3572() - { - } - [Fact] - public void Test_3573() - { - } - [Fact] - public void Test_3574() - { - } - [Fact] - public void Test_3575() - { - } - [Fact] - public void Test_3576() - { - } - [Fact] - public void Test_3577() - { - } - [Fact] - public void Test_3578() - { - } - [Fact] - public void Test_3579() - { - } - [Fact] - public void Test_3580() - { - } - [Fact] - public void Test_3581() - { - } - [Fact] - public void Test_3582() - { - } - [Fact] - public void Test_3583() - { - } - [Fact] - public void Test_3584() - { - } - [Fact] - public void Test_3585() - { - } - [Fact] - public void Test_3586() - { - } - [Fact] - public void Test_3587() - { - } - [Fact] - public void Test_3588() - { - } - [Fact] - public void Test_3589() - { - } - [Fact] - public void Test_3590() - { - } - [Fact] - public void Test_3591() - { - } - [Fact] - public void Test_3592() - { - } - [Fact] - public void Test_3593() - { - } - [Fact] - public void Test_3594() - { - } - [Fact] - public void Test_3595() - { - } - [Fact] - public void Test_3596() - { - } - [Fact] - public void Test_3597() - { - } - [Fact] - public void Test_3598() - { - } - [Fact] - public void Test_3599() - { - } - [Fact] - public void Test_3600() - { - } - [Fact] - public void Test_3601() - { - } - [Fact] - public void Test_3602() - { - } - [Fact] - public void Test_3603() - { - } - [Fact] - public void Test_3604() - { - } - [Fact] - public void Test_3605() - { - } - [Fact] - public void Test_3606() - { - } - [Fact] - public void Test_3607() - { - } - [Fact] - public void Test_3608() - { - } - [Fact] - public void Test_3609() - { - } - [Fact] - public void Test_3610() - { - } - [Fact] - public void Test_3611() - { - } - [Fact] - public void Test_3612() - { - } - [Fact] - public void Test_3613() - { - } - [Fact] - public void Test_3614() - { - } - [Fact] - public void Test_3615() - { - } - [Fact] - public void Test_3616() - { - } - [Fact] - public void Test_3617() - { - } - [Fact] - public void Test_3618() - { - } - [Fact] - public void Test_3619() - { - } - [Fact] - public void Test_3620() - { - } - [Fact] - public void Test_3621() - { - } - [Fact] - public void Test_3622() - { - } - [Fact] - public void Test_3623() - { - } - [Fact] - public void Test_3624() - { - } - [Fact] - public void Test_3625() - { - } - [Fact] - public void Test_3626() - { - } - [Fact] - public void Test_3627() - { - } - [Fact] - public void Test_3628() - { - } - [Fact] - public void Test_3629() - { - } - [Fact] - public void Test_3630() - { - } - [Fact] - public void Test_3631() - { - } - [Fact] - public void Test_3632() - { - } - [Fact] - public void Test_3633() - { - } - [Fact] - public void Test_3634() - { - } - [Fact] - public void Test_3635() - { - } - [Fact] - public void Test_3636() - { - } - [Fact] - public void Test_3637() - { - } - [Fact] - public void Test_3638() - { - } - [Fact] - public void Test_3639() - { - } - [Fact] - public void Test_3640() - { - } - [Fact] - public void Test_3641() - { - } - [Fact] - public void Test_3642() - { - } - [Fact] - public void Test_3643() - { - } - [Fact] - public void Test_3644() - { - } - [Fact] - public void Test_3645() - { - } - [Fact] - public void Test_3646() - { - } - [Fact] - public void Test_3647() - { - } - [Fact] - public void Test_3648() - { - } - [Fact] - public void Test_3649() - { - } - [Fact] - public void Test_3650() - { - } - [Fact] - public void Test_3651() - { - } - [Fact] - public void Test_3652() - { - } - [Fact] - public void Test_3653() - { - } - [Fact] - public void Test_3654() - { - } - [Fact] - public void Test_3655() - { - } - [Fact] - public void Test_3656() - { - } - [Fact] - public void Test_3657() - { - } - [Fact] - public void Test_3658() - { - } - [Fact] - public void Test_3659() - { - } - [Fact] - public void Test_3660() - { - } - [Fact] - public void Test_3661() - { - } - [Fact] - public void Test_3662() - { - } - [Fact] - public void Test_3663() - { - } - [Fact] - public void Test_3664() - { - } - [Fact] - public void Test_3665() - { - } - [Fact] - public void Test_3666() - { - } - [Fact] - public void Test_3667() - { - } - [Fact] - public void Test_3668() - { - } - [Fact] - public void Test_3669() - { - } - [Fact] - public void Test_3670() - { - } - [Fact] - public void Test_3671() - { - } - [Fact] - public void Test_3672() - { - } - [Fact] - public void Test_3673() - { - } - [Fact] - public void Test_3674() - { - } - [Fact] - public void Test_3675() - { - } - [Fact] - public void Test_3676() - { - } - [Fact] - public void Test_3677() - { - } - [Fact] - public void Test_3678() - { - } - [Fact] - public void Test_3679() - { - } - [Fact] - public void Test_3680() - { - } - [Fact] - public void Test_3681() - { - } - [Fact] - public void Test_3682() - { - } - [Fact] - public void Test_3683() - { - } - [Fact] - public void Test_3684() - { - } - [Fact] - public void Test_3685() - { - } - [Fact] - public void Test_3686() - { - } - [Fact] - public void Test_3687() - { - } - [Fact] - public void Test_3688() - { - } - [Fact] - public void Test_3689() - { - } - [Fact] - public void Test_3690() - { - } - [Fact] - public void Test_3691() - { - } - [Fact] - public void Test_3692() - { - } - [Fact] - public void Test_3693() - { - } - [Fact] - public void Test_3694() - { - } - [Fact] - public void Test_3695() - { - } - [Fact] - public void Test_3696() - { - } - [Fact] - public void Test_3697() - { - } - [Fact] - public void Test_3698() - { - } - [Fact] - public void Test_3699() - { - } - [Fact] - public void Test_3700() - { - } - [Fact] - public void Test_3701() - { - } - [Fact] - public void Test_3702() - { - } - [Fact] - public void Test_3703() - { - } - [Fact] - public void Test_3704() - { - } - [Fact] - public void Test_3705() - { - } - [Fact] - public void Test_3706() - { - } - [Fact] - public void Test_3707() - { - } - [Fact] - public void Test_3708() - { - } - [Fact] - public void Test_3709() - { - } - [Fact] - public void Test_3710() - { - } - [Fact] - public void Test_3711() - { - } - [Fact] - public void Test_3712() - { - } - [Fact] - public void Test_3713() - { - } - [Fact] - public void Test_3714() - { - } - [Fact] - public void Test_3715() - { - } - [Fact] - public void Test_3716() - { - } - [Fact] - public void Test_3717() - { - } - [Fact] - public void Test_3718() - { - } - [Fact] - public void Test_3719() - { - } - [Fact] - public void Test_3720() - { - } - [Fact] - public void Test_3721() - { - } - [Fact] - public void Test_3722() - { - } - [Fact] - public void Test_3723() - { - } - [Fact] - public void Test_3724() - { - } - [Fact] - public void Test_3725() - { - } - [Fact] - public void Test_3726() - { - } - [Fact] - public void Test_3727() - { - } - [Fact] - public void Test_3728() - { - } - [Fact] - public void Test_3729() - { - } - [Fact] - public void Test_3730() - { - } - [Fact] - public void Test_3731() - { - } - [Fact] - public void Test_3732() - { - } - [Fact] - public void Test_3733() - { - } - [Fact] - public void Test_3734() - { - } - [Fact] - public void Test_3735() - { - } - [Fact] - public void Test_3736() - { - } - [Fact] - public void Test_3737() - { - } - [Fact] - public void Test_3738() - { - } - [Fact] - public void Test_3739() - { - } - [Fact] - public void Test_3740() - { - } - [Fact] - public void Test_3741() - { - } - [Fact] - public void Test_3742() - { - } - [Fact] - public void Test_3743() - { - } - [Fact] - public void Test_3744() - { - } - [Fact] - public void Test_3745() - { - } - [Fact] - public void Test_3746() - { - } - [Fact] - public void Test_3747() - { - } - [Fact] - public void Test_3748() - { - } - [Fact] - public void Test_3749() - { - } - [Fact] - public void Test_3750() - { - } - [Fact] - public void Test_3751() - { - } - [Fact] - public void Test_3752() - { - } - [Fact] - public void Test_3753() - { - } - [Fact] - public void Test_3754() - { - } - [Fact] - public void Test_3755() - { - } - [Fact] - public void Test_3756() - { - } - [Fact] - public void Test_3757() - { - } - [Fact] - public void Test_3758() - { - } - [Fact] - public void Test_3759() - { - } - [Fact] - public void Test_3760() - { - } - [Fact] - public void Test_3761() - { - } - [Fact] - public void Test_3762() - { - } - [Fact] - public void Test_3763() - { - } - [Fact] - public void Test_3764() - { - } - [Fact] - public void Test_3765() - { - } - [Fact] - public void Test_3766() - { - } - [Fact] - public void Test_3767() - { - } - [Fact] - public void Test_3768() - { - } - [Fact] - public void Test_3769() - { - } - [Fact] - public void Test_3770() - { - } - [Fact] - public void Test_3771() - { - } - [Fact] - public void Test_3772() - { - } - [Fact] - public void Test_3773() - { - } - [Fact] - public void Test_3774() - { - } - [Fact] - public void Test_3775() - { - } - [Fact] - public void Test_3776() - { - } - [Fact] - public void Test_3777() - { - } - [Fact] - public void Test_3778() - { - } - [Fact] - public void Test_3779() - { - } - [Fact] - public void Test_3780() - { - } - [Fact] - public void Test_3781() - { - } - [Fact] - public void Test_3782() - { - } - [Fact] - public void Test_3783() - { - } - [Fact] - public void Test_3784() - { - } - [Fact] - public void Test_3785() - { - } - [Fact] - public void Test_3786() - { - } - [Fact] - public void Test_3787() - { - } - [Fact] - public void Test_3788() - { - } - [Fact] - public void Test_3789() - { - } - [Fact] - public void Test_3790() - { - } - [Fact] - public void Test_3791() - { - } - [Fact] - public void Test_3792() - { - } - [Fact] - public void Test_3793() - { - } - [Fact] - public void Test_3794() - { - } - [Fact] - public void Test_3795() - { - } - [Fact] - public void Test_3796() - { - } - [Fact] - public void Test_3797() - { - } - [Fact] - public void Test_3798() - { - } - [Fact] - public void Test_3799() - { - } - [Fact] - public void Test_3800() - { - } - [Fact] - public void Test_3801() - { - } - [Fact] - public void Test_3802() - { - } - [Fact] - public void Test_3803() - { - } - [Fact] - public void Test_3804() - { - } - [Fact] - public void Test_3805() - { - } - [Fact] - public void Test_3806() - { - } - [Fact] - public void Test_3807() - { - } - [Fact] - public void Test_3808() - { - } - [Fact] - public void Test_3809() - { - } - [Fact] - public void Test_3810() - { - } - [Fact] - public void Test_3811() - { - } - [Fact] - public void Test_3812() - { - } - [Fact] - public void Test_3813() - { - } - [Fact] - public void Test_3814() - { - } - [Fact] - public void Test_3815() - { - } - [Fact] - public void Test_3816() - { - } - [Fact] - public void Test_3817() - { - } - [Fact] - public void Test_3818() - { - } - [Fact] - public void Test_3819() - { - } - [Fact] - public void Test_3820() - { - } - [Fact] - public void Test_3821() - { - } - [Fact] - public void Test_3822() - { - } - [Fact] - public void Test_3823() - { - } - [Fact] - public void Test_3824() - { - } - [Fact] - public void Test_3825() - { - } - [Fact] - public void Test_3826() - { - } - [Fact] - public void Test_3827() - { - } - [Fact] - public void Test_3828() - { - } - [Fact] - public void Test_3829() - { - } - [Fact] - public void Test_3830() - { - } - [Fact] - public void Test_3831() - { - } - [Fact] - public void Test_3832() - { - } - [Fact] - public void Test_3833() - { - } - [Fact] - public void Test_3834() - { - } - [Fact] - public void Test_3835() - { - } - [Fact] - public void Test_3836() - { - } - [Fact] - public void Test_3837() - { - } - [Fact] - public void Test_3838() - { - } - [Fact] - public void Test_3839() - { - } - [Fact] - public void Test_3840() - { - } - [Fact] - public void Test_3841() - { - } - [Fact] - public void Test_3842() - { - } - [Fact] - public void Test_3843() - { - } - [Fact] - public void Test_3844() - { - } - [Fact] - public void Test_3845() - { - } - [Fact] - public void Test_3846() - { - } - [Fact] - public void Test_3847() - { - } - [Fact] - public void Test_3848() - { - } - [Fact] - public void Test_3849() - { - } - [Fact] - public void Test_3850() - { - } - [Fact] - public void Test_3851() - { - } - [Fact] - public void Test_3852() - { - } - [Fact] - public void Test_3853() - { - } - [Fact] - public void Test_3854() - { - } - [Fact] - public void Test_3855() - { - } - [Fact] - public void Test_3856() - { - } - [Fact] - public void Test_3857() - { - } - [Fact] - public void Test_3858() - { - } - [Fact] - public void Test_3859() - { - } - [Fact] - public void Test_3860() - { - } - [Fact] - public void Test_3861() - { - } - [Fact] - public void Test_3862() - { - } - [Fact] - public void Test_3863() - { - } - [Fact] - public void Test_3864() - { - } - [Fact] - public void Test_3865() - { - } - [Fact] - public void Test_3866() - { - } - [Fact] - public void Test_3867() - { - } - [Fact] - public void Test_3868() - { - } - [Fact] - public void Test_3869() - { - } - [Fact] - public void Test_3870() - { - } - [Fact] - public void Test_3871() - { - } - [Fact] - public void Test_3872() - { - } - [Fact] - public void Test_3873() - { - } - [Fact] - public void Test_3874() - { - } - [Fact] - public void Test_3875() - { - } - [Fact] - public void Test_3876() - { - } - [Fact] - public void Test_3877() - { - } - [Fact] - public void Test_3878() - { - } - [Fact] - public void Test_3879() - { - } - [Fact] - public void Test_3880() - { - } - [Fact] - public void Test_3881() - { - } - [Fact] - public void Test_3882() - { - } - [Fact] - public void Test_3883() - { - } - [Fact] - public void Test_3884() - { - } - [Fact] - public void Test_3885() - { - } - [Fact] - public void Test_3886() - { - } - [Fact] - public void Test_3887() - { - } - [Fact] - public void Test_3888() - { - } - [Fact] - public void Test_3889() - { - } - [Fact] - public void Test_3890() - { - } - [Fact] - public void Test_3891() - { - } - [Fact] - public void Test_3892() - { - } - [Fact] - public void Test_3893() - { - } - [Fact] - public void Test_3894() - { - } - [Fact] - public void Test_3895() - { - } - [Fact] - public void Test_3896() - { - } - [Fact] - public void Test_3897() - { - } - [Fact] - public void Test_3898() - { - } - [Fact] - public void Test_3899() - { - } - [Fact] - public void Test_3900() - { - } - [Fact] - public void Test_3901() - { - } - [Fact] - public void Test_3902() - { - } - [Fact] - public void Test_3903() - { - } - [Fact] - public void Test_3904() - { - } - [Fact] - public void Test_3905() - { - } - [Fact] - public void Test_3906() - { - } - [Fact] - public void Test_3907() - { - } - [Fact] - public void Test_3908() - { - } - [Fact] - public void Test_3909() - { - } - [Fact] - public void Test_3910() - { - } - [Fact] - public void Test_3911() - { - } - [Fact] - public void Test_3912() - { - } - [Fact] - public void Test_3913() - { - } - [Fact] - public void Test_3914() - { - } - [Fact] - public void Test_3915() - { - } - [Fact] - public void Test_3916() - { - } - [Fact] - public void Test_3917() - { - } - [Fact] - public void Test_3918() - { - } - [Fact] - public void Test_3919() - { - } - [Fact] - public void Test_3920() - { - } - [Fact] - public void Test_3921() - { - } - [Fact] - public void Test_3922() - { - } - [Fact] - public void Test_3923() - { - } - [Fact] - public void Test_3924() - { - } - [Fact] - public void Test_3925() - { - } - [Fact] - public void Test_3926() - { - } - [Fact] - public void Test_3927() - { - } - [Fact] - public void Test_3928() - { - } - [Fact] - public void Test_3929() - { - } - [Fact] - public void Test_3930() - { - } - [Fact] - public void Test_3931() - { - } - [Fact] - public void Test_3932() - { - } - [Fact] - public void Test_3933() - { - } - [Fact] - public void Test_3934() - { - } - [Fact] - public void Test_3935() - { - } - [Fact] - public void Test_3936() - { - } - [Fact] - public void Test_3937() - { - } - [Fact] - public void Test_3938() - { - } - [Fact] - public void Test_3939() - { - } - [Fact] - public void Test_3940() - { - } - [Fact] - public void Test_3941() - { - } - [Fact] - public void Test_3942() - { - } - [Fact] - public void Test_3943() - { - } - [Fact] - public void Test_3944() - { - } - [Fact] - public void Test_3945() - { - } - [Fact] - public void Test_3946() - { - } - [Fact] - public void Test_3947() - { - } - [Fact] - public void Test_3948() - { - } - [Fact] - public void Test_3949() - { - } - [Fact] - public void Test_3950() - { - } - [Fact] - public void Test_3951() - { - } - [Fact] - public void Test_3952() - { - } - [Fact] - public void Test_3953() - { - } - [Fact] - public void Test_3954() - { - } - [Fact] - public void Test_3955() - { - } - [Fact] - public void Test_3956() - { - } - [Fact] - public void Test_3957() - { - } - [Fact] - public void Test_3958() - { - } - [Fact] - public void Test_3959() - { - } - [Fact] - public void Test_3960() - { - } - [Fact] - public void Test_3961() - { - } - [Fact] - public void Test_3962() - { - } - [Fact] - public void Test_3963() - { - } - [Fact] - public void Test_3964() - { - } - [Fact] - public void Test_3965() - { - } - [Fact] - public void Test_3966() - { - } - [Fact] - public void Test_3967() - { - } - [Fact] - public void Test_3968() - { - } - [Fact] - public void Test_3969() - { - } - [Fact] - public void Test_3970() - { - } - [Fact] - public void Test_3971() - { - } - [Fact] - public void Test_3972() - { - } - [Fact] - public void Test_3973() - { - } - [Fact] - public void Test_3974() - { - } - [Fact] - public void Test_3975() - { - } - [Fact] - public void Test_3976() - { - } - [Fact] - public void Test_3977() - { - } - [Fact] - public void Test_3978() - { - } - [Fact] - public void Test_3979() - { - } - [Fact] - public void Test_3980() - { - } - [Fact] - public void Test_3981() - { - } - [Fact] - public void Test_3982() - { - } - [Fact] - public void Test_3983() - { - } - [Fact] - public void Test_3984() - { - } - [Fact] - public void Test_3985() - { - } - [Fact] - public void Test_3986() - { - } - [Fact] - public void Test_3987() - { - } - [Fact] - public void Test_3988() - { - } - [Fact] - public void Test_3989() - { - } - [Fact] - public void Test_3990() - { - } - [Fact] - public void Test_3991() - { - } - [Fact] - public void Test_3992() - { - } - [Fact] - public void Test_3993() - { - } - [Fact] - public void Test_3994() - { - } - [Fact] - public void Test_3995() - { - } - [Fact] - public void Test_3996() - { - } - [Fact] - public void Test_3997() - { - } - [Fact] - public void Test_3998() - { - } - [Fact] - public void Test_3999() - { - } - [Fact] - public void Test_4000() - { - } - [Fact] - public void Test_4001() - { - } - [Fact] - public void Test_4002() - { - } - [Fact] - public void Test_4003() - { - } - [Fact] - public void Test_4004() - { - } - [Fact] - public void Test_4005() - { - } - [Fact] - public void Test_4006() - { - } - [Fact] - public void Test_4007() - { - } - [Fact] - public void Test_4008() - { - } - [Fact] - public void Test_4009() - { - } - [Fact] - public void Test_4010() - { - } - [Fact] - public void Test_4011() - { - } - [Fact] - public void Test_4012() - { - } - [Fact] - public void Test_4013() - { - } - [Fact] - public void Test_4014() - { - } - [Fact] - public void Test_4015() - { - } - [Fact] - public void Test_4016() - { - } - [Fact] - public void Test_4017() - { - } - [Fact] - public void Test_4018() - { - } - [Fact] - public void Test_4019() - { - } - [Fact] - public void Test_4020() - { - } - [Fact] - public void Test_4021() - { - } - [Fact] - public void Test_4022() - { - } - [Fact] - public void Test_4023() - { - } - [Fact] - public void Test_4024() - { - } - [Fact] - public void Test_4025() - { - } - [Fact] - public void Test_4026() - { - } - [Fact] - public void Test_4027() - { - } - [Fact] - public void Test_4028() - { - } - [Fact] - public void Test_4029() - { - } - [Fact] - public void Test_4030() - { - } - [Fact] - public void Test_4031() - { - } - [Fact] - public void Test_4032() - { - } - [Fact] - public void Test_4033() - { - } - [Fact] - public void Test_4034() - { - } - [Fact] - public void Test_4035() - { - } - [Fact] - public void Test_4036() - { - } - [Fact] - public void Test_4037() - { - } - [Fact] - public void Test_4038() - { - } - [Fact] - public void Test_4039() - { - } - [Fact] - public void Test_4040() - { - } - [Fact] - public void Test_4041() - { - } - [Fact] - public void Test_4042() - { - } - [Fact] - public void Test_4043() - { - } - [Fact] - public void Test_4044() - { - } - [Fact] - public void Test_4045() - { - } - [Fact] - public void Test_4046() - { - } - [Fact] - public void Test_4047() - { - } - [Fact] - public void Test_4048() - { - } - [Fact] - public void Test_4049() - { - } - [Fact] - public void Test_4050() - { - } - [Fact] - public void Test_4051() - { - } - [Fact] - public void Test_4052() - { - } - [Fact] - public void Test_4053() - { - } - [Fact] - public void Test_4054() - { - } - [Fact] - public void Test_4055() - { - } - [Fact] - public void Test_4056() - { - } - [Fact] - public void Test_4057() - { - } - [Fact] - public void Test_4058() - { - } - [Fact] - public void Test_4059() - { - } - [Fact] - public void Test_4060() - { - } - [Fact] - public void Test_4061() - { - } - [Fact] - public void Test_4062() - { - } - [Fact] - public void Test_4063() - { - } - [Fact] - public void Test_4064() - { - } - [Fact] - public void Test_4065() - { - } - [Fact] - public void Test_4066() - { - } - [Fact] - public void Test_4067() - { - } - [Fact] - public void Test_4068() - { - } - [Fact] - public void Test_4069() - { - } - [Fact] - public void Test_4070() - { - } - [Fact] - public void Test_4071() - { - } - [Fact] - public void Test_4072() - { - } - [Fact] - public void Test_4073() - { - } - [Fact] - public void Test_4074() - { - } - [Fact] - public void Test_4075() - { - } - [Fact] - public void Test_4076() - { - } - [Fact] - public void Test_4077() - { - } - [Fact] - public void Test_4078() - { - } - [Fact] - public void Test_4079() - { - } - [Fact] - public void Test_4080() - { - } - [Fact] - public void Test_4081() - { - } - [Fact] - public void Test_4082() - { - } - [Fact] - public void Test_4083() - { - } - [Fact] - public void Test_4084() - { - } - [Fact] - public void Test_4085() - { - } - [Fact] - public void Test_4086() - { - } - [Fact] - public void Test_4087() - { - } - [Fact] - public void Test_4088() - { - } - [Fact] - public void Test_4089() - { - } - [Fact] - public void Test_4090() - { - } - [Fact] - public void Test_4091() - { - } - [Fact] - public void Test_4092() - { - } - [Fact] - public void Test_4093() - { - } - [Fact] - public void Test_4094() - { - } - [Fact] - public void Test_4095() - { - } - [Fact] - public void Test_4096() - { - } - [Fact] - public void Test_4097() - { - } - [Fact] - public void Test_4098() - { - } - [Fact] - public void Test_4099() - { - } - [Fact] - public void Test_4100() - { - } - [Fact] - public void Test_4101() - { - } - [Fact] - public void Test_4102() - { - } - [Fact] - public void Test_4103() - { - } - [Fact] - public void Test_4104() - { - } - [Fact] - public void Test_4105() - { - } - [Fact] - public void Test_4106() - { - } - [Fact] - public void Test_4107() - { - } - [Fact] - public void Test_4108() - { - } - [Fact] - public void Test_4109() - { - } - [Fact] - public void Test_4110() - { - } - [Fact] - public void Test_4111() - { - } - [Fact] - public void Test_4112() - { - } - [Fact] - public void Test_4113() - { - } - [Fact] - public void Test_4114() - { - } - [Fact] - public void Test_4115() - { - } - [Fact] - public void Test_4116() - { - } - [Fact] - public void Test_4117() - { - } - [Fact] - public void Test_4118() - { - } - [Fact] - public void Test_4119() - { - } - [Fact] - public void Test_4120() - { - } - [Fact] - public void Test_4121() - { - } - [Fact] - public void Test_4122() - { - } - [Fact] - public void Test_4123() - { - } - [Fact] - public void Test_4124() - { - } - [Fact] - public void Test_4125() - { - } - [Fact] - public void Test_4126() - { - } - [Fact] - public void Test_4127() - { - } - [Fact] - public void Test_4128() - { - } - [Fact] - public void Test_4129() - { - } - [Fact] - public void Test_4130() - { - } - [Fact] - public void Test_4131() - { - } - [Fact] - public void Test_4132() - { - } - [Fact] - public void Test_4133() - { - } - [Fact] - public void Test_4134() - { - } - [Fact] - public void Test_4135() - { - } - [Fact] - public void Test_4136() - { - } - [Fact] - public void Test_4137() - { - } - [Fact] - public void Test_4138() - { - } - [Fact] - public void Test_4139() - { - } - [Fact] - public void Test_4140() - { - } - [Fact] - public void Test_4141() - { - } - [Fact] - public void Test_4142() - { - } - [Fact] - public void Test_4143() - { - } - [Fact] - public void Test_4144() - { - } - [Fact] - public void Test_4145() - { - } - [Fact] - public void Test_4146() - { - } - [Fact] - public void Test_4147() - { - } - [Fact] - public void Test_4148() - { - } - [Fact] - public void Test_4149() - { - } - [Fact] - public void Test_4150() - { - } - [Fact] - public void Test_4151() - { - } - [Fact] - public void Test_4152() - { - } - [Fact] - public void Test_4153() - { - } - [Fact] - public void Test_4154() - { - } - [Fact] - public void Test_4155() - { - } - [Fact] - public void Test_4156() - { - } - [Fact] - public void Test_4157() - { - } - [Fact] - public void Test_4158() - { - } - [Fact] - public void Test_4159() - { - } - [Fact] - public void Test_4160() - { - } - [Fact] - public void Test_4161() - { - } - [Fact] - public void Test_4162() - { - } - [Fact] - public void Test_4163() - { - } - [Fact] - public void Test_4164() - { - } - [Fact] - public void Test_4165() - { - } - [Fact] - public void Test_4166() - { - } - [Fact] - public void Test_4167() - { - } - [Fact] - public void Test_4168() - { - } - [Fact] - public void Test_4169() - { - } - [Fact] - public void Test_4170() - { - } - [Fact] - public void Test_4171() - { - } - [Fact] - public void Test_4172() - { - } - [Fact] - public void Test_4173() - { - } - [Fact] - public void Test_4174() - { - } - [Fact] - public void Test_4175() - { - } - [Fact] - public void Test_4176() - { - } - [Fact] - public void Test_4177() - { - } - [Fact] - public void Test_4178() - { - } - [Fact] - public void Test_4179() - { - } - [Fact] - public void Test_4180() - { - } - [Fact] - public void Test_4181() - { - } - [Fact] - public void Test_4182() - { - } - [Fact] - public void Test_4183() - { - } - [Fact] - public void Test_4184() - { - } - [Fact] - public void Test_4185() - { - } - [Fact] - public void Test_4186() - { - } - [Fact] - public void Test_4187() - { - } - [Fact] - public void Test_4188() - { - } - [Fact] - public void Test_4189() - { - } - [Fact] - public void Test_4190() - { - } - [Fact] - public void Test_4191() - { - } - [Fact] - public void Test_4192() - { - } - [Fact] - public void Test_4193() - { - } - [Fact] - public void Test_4194() - { - } - [Fact] - public void Test_4195() - { - } - [Fact] - public void Test_4196() - { - } - [Fact] - public void Test_4197() - { - } - [Fact] - public void Test_4198() - { - } - [Fact] - public void Test_4199() - { - } - [Fact] - public void Test_4200() - { - } - [Fact] - public void Test_4201() - { - } - [Fact] - public void Test_4202() - { - } - [Fact] - public void Test_4203() - { - } - [Fact] - public void Test_4204() - { - } - [Fact] - public void Test_4205() - { - } - [Fact] - public void Test_4206() - { - } - [Fact] - public void Test_4207() - { - } - [Fact] - public void Test_4208() - { - } - [Fact] - public void Test_4209() - { - } - [Fact] - public void Test_4210() - { - } - [Fact] - public void Test_4211() - { - } - [Fact] - public void Test_4212() - { - } - [Fact] - public void Test_4213() - { - } - [Fact] - public void Test_4214() - { - } - [Fact] - public void Test_4215() - { - } - [Fact] - public void Test_4216() - { - } - [Fact] - public void Test_4217() - { - } - [Fact] - public void Test_4218() - { - } - [Fact] - public void Test_4219() - { - } - [Fact] - public void Test_4220() - { - } - [Fact] - public void Test_4221() - { - } - [Fact] - public void Test_4222() - { - } - [Fact] - public void Test_4223() - { - } - [Fact] - public void Test_4224() - { - } - [Fact] - public void Test_4225() - { - } - [Fact] - public void Test_4226() - { - } - [Fact] - public void Test_4227() - { - } - [Fact] - public void Test_4228() - { - } - [Fact] - public void Test_4229() - { - } - [Fact] - public void Test_4230() - { - } - [Fact] - public void Test_4231() - { - } - [Fact] - public void Test_4232() - { - } - [Fact] - public void Test_4233() - { - } - [Fact] - public void Test_4234() - { - } - [Fact] - public void Test_4235() - { - } - [Fact] - public void Test_4236() - { - } - [Fact] - public void Test_4237() - { - } - [Fact] - public void Test_4238() - { - } - [Fact] - public void Test_4239() - { - } - [Fact] - public void Test_4240() - { - } - [Fact] - public void Test_4241() - { - } - [Fact] - public void Test_4242() - { - } - [Fact] - public void Test_4243() - { - } - [Fact] - public void Test_4244() - { - } - [Fact] - public void Test_4245() - { - } - [Fact] - public void Test_4246() - { - } - [Fact] - public void Test_4247() - { - } - [Fact] - public void Test_4248() - { - } - [Fact] - public void Test_4249() - { - } - [Fact] - public void Test_4250() - { - } - [Fact] - public void Test_4251() - { - } - [Fact] - public void Test_4252() - { - } - [Fact] - public void Test_4253() - { - } - [Fact] - public void Test_4254() - { - } - [Fact] - public void Test_4255() - { - } - [Fact] - public void Test_4256() - { - } - [Fact] - public void Test_4257() - { - } - [Fact] - public void Test_4258() - { - } - [Fact] - public void Test_4259() - { - } - [Fact] - public void Test_4260() - { - } - [Fact] - public void Test_4261() - { - } - [Fact] - public void Test_4262() - { - } - [Fact] - public void Test_4263() - { - } - [Fact] - public void Test_4264() - { - } - [Fact] - public void Test_4265() - { - } - [Fact] - public void Test_4266() - { - } - [Fact] - public void Test_4267() - { - } - [Fact] - public void Test_4268() - { - } - [Fact] - public void Test_4269() - { - } - [Fact] - public void Test_4270() - { - } - [Fact] - public void Test_4271() - { - } - [Fact] - public void Test_4272() - { - } - [Fact] - public void Test_4273() - { - } - [Fact] - public void Test_4274() - { - } - [Fact] - public void Test_4275() - { - } - [Fact] - public void Test_4276() - { - } - [Fact] - public void Test_4277() - { - } - [Fact] - public void Test_4278() - { - } - [Fact] - public void Test_4279() - { - } - [Fact] - public void Test_4280() - { - } - [Fact] - public void Test_4281() - { - } - [Fact] - public void Test_4282() - { - } - [Fact] - public void Test_4283() - { - } - [Fact] - public void Test_4284() - { - } - [Fact] - public void Test_4285() - { - } - [Fact] - public void Test_4286() - { - } - [Fact] - public void Test_4287() - { - } - [Fact] - public void Test_4288() - { - } - [Fact] - public void Test_4289() - { - } - [Fact] - public void Test_4290() - { - } - [Fact] - public void Test_4291() - { - } - [Fact] - public void Test_4292() - { - } - [Fact] - public void Test_4293() - { - } - [Fact] - public void Test_4294() - { - } - [Fact] - public void Test_4295() - { - } - [Fact] - public void Test_4296() - { - } - [Fact] - public void Test_4297() - { - } - [Fact] - public void Test_4298() - { - } - [Fact] - public void Test_4299() - { - } - [Fact] - public void Test_4300() - { - } - [Fact] - public void Test_4301() - { - } - [Fact] - public void Test_4302() - { - } - [Fact] - public void Test_4303() - { - } - [Fact] - public void Test_4304() - { - } - [Fact] - public void Test_4305() - { - } - [Fact] - public void Test_4306() - { - } - [Fact] - public void Test_4307() - { - } - [Fact] - public void Test_4308() - { - } - [Fact] - public void Test_4309() - { - } - [Fact] - public void Test_4310() - { - } - [Fact] - public void Test_4311() - { - } - [Fact] - public void Test_4312() - { - } - [Fact] - public void Test_4313() - { - } - [Fact] - public void Test_4314() - { - } - [Fact] - public void Test_4315() - { - } - [Fact] - public void Test_4316() - { - } - [Fact] - public void Test_4317() - { - } - [Fact] - public void Test_4318() - { - } - [Fact] - public void Test_4319() - { - } - [Fact] - public void Test_4320() - { - } - [Fact] - public void Test_4321() - { - } - [Fact] - public void Test_4322() - { - } - [Fact] - public void Test_4323() - { - } - [Fact] - public void Test_4324() - { - } - [Fact] - public void Test_4325() - { - } - [Fact] - public void Test_4326() - { - } - [Fact] - public void Test_4327() - { - } - [Fact] - public void Test_4328() - { - } - [Fact] - public void Test_4329() - { - } - [Fact] - public void Test_4330() - { - } - [Fact] - public void Test_4331() - { - } - [Fact] - public void Test_4332() - { - } - [Fact] - public void Test_4333() - { - } - [Fact] - public void Test_4334() - { - } - [Fact] - public void Test_4335() - { - } - [Fact] - public void Test_4336() - { - } - [Fact] - public void Test_4337() - { - } - [Fact] - public void Test_4338() - { - } - [Fact] - public void Test_4339() - { - } - [Fact] - public void Test_4340() - { - } - [Fact] - public void Test_4341() - { - } - [Fact] - public void Test_4342() - { - } - [Fact] - public void Test_4343() - { - } - [Fact] - public void Test_4344() - { - } - [Fact] - public void Test_4345() - { - } - [Fact] - public void Test_4346() - { - } - [Fact] - public void Test_4347() - { - } - [Fact] - public void Test_4348() - { - } - [Fact] - public void Test_4349() - { - } - [Fact] - public void Test_4350() - { - } - [Fact] - public void Test_4351() - { - } - [Fact] - public void Test_4352() - { - } - [Fact] - public void Test_4353() - { - } - [Fact] - public void Test_4354() - { - } - [Fact] - public void Test_4355() - { - } - [Fact] - public void Test_4356() - { - } - [Fact] - public void Test_4357() - { - } - [Fact] - public void Test_4358() - { - } - [Fact] - public void Test_4359() - { - } - [Fact] - public void Test_4360() - { - } - [Fact] - public void Test_4361() - { - } - [Fact] - public void Test_4362() - { - } - [Fact] - public void Test_4363() - { - } - [Fact] - public void Test_4364() - { - } - [Fact] - public void Test_4365() - { - } - [Fact] - public void Test_4366() - { - } - [Fact] - public void Test_4367() - { - } - [Fact] - public void Test_4368() - { - } - [Fact] - public void Test_4369() - { - } - [Fact] - public void Test_4370() - { - } - [Fact] - public void Test_4371() - { - } - [Fact] - public void Test_4372() - { - } - [Fact] - public void Test_4373() - { - } - [Fact] - public void Test_4374() - { - } - [Fact] - public void Test_4375() - { - } - [Fact] - public void Test_4376() - { - } - [Fact] - public void Test_4377() - { - } - [Fact] - public void Test_4378() - { - } - [Fact] - public void Test_4379() - { - } - [Fact] - public void Test_4380() - { - } - [Fact] - public void Test_4381() - { - } - [Fact] - public void Test_4382() - { - } - [Fact] - public void Test_4383() - { - } - [Fact] - public void Test_4384() - { - } - [Fact] - public void Test_4385() - { - } - [Fact] - public void Test_4386() - { - } - [Fact] - public void Test_4387() - { - } - [Fact] - public void Test_4388() - { - } - [Fact] - public void Test_4389() - { - } - [Fact] - public void Test_4390() - { - } - [Fact] - public void Test_4391() - { - } - [Fact] - public void Test_4392() - { - } - [Fact] - public void Test_4393() - { - } - [Fact] - public void Test_4394() - { - } - [Fact] - public void Test_4395() - { - } - [Fact] - public void Test_4396() - { - } - [Fact] - public void Test_4397() - { - } - [Fact] - public void Test_4398() - { - } - [Fact] - public void Test_4399() - { - } - [Fact] - public void Test_4400() - { - } - [Fact] - public void Test_4401() - { - } - [Fact] - public void Test_4402() - { - } - [Fact] - public void Test_4403() - { - } - [Fact] - public void Test_4404() - { - } - [Fact] - public void Test_4405() - { - } - [Fact] - public void Test_4406() - { - } - [Fact] - public void Test_4407() - { - } - [Fact] - public void Test_4408() - { - } - [Fact] - public void Test_4409() - { - } - [Fact] - public void Test_4410() - { - } - [Fact] - public void Test_4411() - { - } - [Fact] - public void Test_4412() - { - } - [Fact] - public void Test_4413() - { - } - [Fact] - public void Test_4414() - { - } - [Fact] - public void Test_4415() - { - } - [Fact] - public void Test_4416() - { - } - [Fact] - public void Test_4417() - { - } - [Fact] - public void Test_4418() - { - } - [Fact] - public void Test_4419() - { - } - [Fact] - public void Test_4420() - { - } - [Fact] - public void Test_4421() - { - } - [Fact] - public void Test_4422() - { - } - [Fact] - public void Test_4423() - { - } - [Fact] - public void Test_4424() - { - } - [Fact] - public void Test_4425() - { - } - [Fact] - public void Test_4426() - { - } - [Fact] - public void Test_4427() - { - } - [Fact] - public void Test_4428() - { - } - [Fact] - public void Test_4429() - { - } - [Fact] - public void Test_4430() - { - } - [Fact] - public void Test_4431() - { - } - [Fact] - public void Test_4432() - { - } - [Fact] - public void Test_4433() - { - } - [Fact] - public void Test_4434() - { - } - [Fact] - public void Test_4435() - { - } - [Fact] - public void Test_4436() - { - } - [Fact] - public void Test_4437() - { - } - [Fact] - public void Test_4438() - { - } - [Fact] - public void Test_4439() - { - } - [Fact] - public void Test_4440() - { - } - [Fact] - public void Test_4441() - { - } - [Fact] - public void Test_4442() - { - } - [Fact] - public void Test_4443() - { - } - [Fact] - public void Test_4444() - { - } - [Fact] - public void Test_4445() - { - } - [Fact] - public void Test_4446() - { - } - [Fact] - public void Test_4447() - { - } - [Fact] - public void Test_4448() - { - } - [Fact] - public void Test_4449() - { - } - [Fact] - public void Test_4450() - { - } - [Fact] - public void Test_4451() - { - } - [Fact] - public void Test_4452() - { - } - [Fact] - public void Test_4453() - { - } - [Fact] - public void Test_4454() - { - } - [Fact] - public void Test_4455() - { - } - [Fact] - public void Test_4456() - { - } - [Fact] - public void Test_4457() - { - } - [Fact] - public void Test_4458() - { - } - [Fact] - public void Test_4459() - { - } - [Fact] - public void Test_4460() - { - } - [Fact] - public void Test_4461() - { - } - [Fact] - public void Test_4462() - { - } - [Fact] - public void Test_4463() - { - } - [Fact] - public void Test_4464() - { - } - [Fact] - public void Test_4465() - { - } - [Fact] - public void Test_4466() - { - } - [Fact] - public void Test_4467() - { - } - [Fact] - public void Test_4468() - { - } - [Fact] - public void Test_4469() - { - } - [Fact] - public void Test_4470() - { - } - [Fact] - public void Test_4471() - { - } - [Fact] - public void Test_4472() - { - } - [Fact] - public void Test_4473() - { - } - [Fact] - public void Test_4474() - { - } - [Fact] - public void Test_4475() - { - } - [Fact] - public void Test_4476() - { - } - [Fact] - public void Test_4477() - { - } - [Fact] - public void Test_4478() - { - } - [Fact] - public void Test_4479() - { - } - [Fact] - public void Test_4480() - { - } - [Fact] - public void Test_4481() - { - } - [Fact] - public void Test_4482() - { - } - [Fact] - public void Test_4483() - { - } - [Fact] - public void Test_4484() - { - } - [Fact] - public void Test_4485() - { - } - [Fact] - public void Test_4486() - { - } - [Fact] - public void Test_4487() - { - } - [Fact] - public void Test_4488() - { - } - [Fact] - public void Test_4489() - { - } - [Fact] - public void Test_4490() - { - } - [Fact] - public void Test_4491() - { - } - [Fact] - public void Test_4492() - { - } - [Fact] - public void Test_4493() - { - } - [Fact] - public void Test_4494() - { - } - [Fact] - public void Test_4495() - { - } - [Fact] - public void Test_4496() - { - } - [Fact] - public void Test_4497() - { - } - [Fact] - public void Test_4498() - { - } - [Fact] - public void Test_4499() - { - } - [Fact] - public void Test_4500() - { - } - [Fact] - public void Test_4501() - { - } - [Fact] - public void Test_4502() - { - } - [Fact] - public void Test_4503() - { - } - [Fact] - public void Test_4504() - { - } - [Fact] - public void Test_4505() - { - } - [Fact] - public void Test_4506() - { - } - [Fact] - public void Test_4507() - { - } - [Fact] - public void Test_4508() - { - } - [Fact] - public void Test_4509() - { - } - [Fact] - public void Test_4510() - { - } - [Fact] - public void Test_4511() - { - } - [Fact] - public void Test_4512() - { - } - [Fact] - public void Test_4513() - { - } - [Fact] - public void Test_4514() - { - } - [Fact] - public void Test_4515() - { - } - [Fact] - public void Test_4516() - { - } - [Fact] - public void Test_4517() - { - } - [Fact] - public void Test_4518() - { - } - [Fact] - public void Test_4519() - { - } - [Fact] - public void Test_4520() - { - } - [Fact] - public void Test_4521() - { - } - [Fact] - public void Test_4522() - { - } - [Fact] - public void Test_4523() - { - } - [Fact] - public void Test_4524() - { - } - [Fact] - public void Test_4525() - { - } - [Fact] - public void Test_4526() - { - } - [Fact] - public void Test_4527() - { - } - [Fact] - public void Test_4528() - { - } - [Fact] - public void Test_4529() - { - } - [Fact] - public void Test_4530() - { - } - [Fact] - public void Test_4531() - { - } - [Fact] - public void Test_4532() - { - } - [Fact] - public void Test_4533() - { - } - [Fact] - public void Test_4534() - { - } - [Fact] - public void Test_4535() - { - } - [Fact] - public void Test_4536() - { - } - [Fact] - public void Test_4537() - { - } - [Fact] - public void Test_4538() - { - } - [Fact] - public void Test_4539() - { - } - [Fact] - public void Test_4540() - { - } - [Fact] - public void Test_4541() - { - } - [Fact] - public void Test_4542() - { - } - [Fact] - public void Test_4543() - { - } - [Fact] - public void Test_4544() - { - } - [Fact] - public void Test_4545() - { - } - [Fact] - public void Test_4546() - { - } - [Fact] - public void Test_4547() - { - } - [Fact] - public void Test_4548() - { - } - [Fact] - public void Test_4549() - { - } - [Fact] - public void Test_4550() - { - } - [Fact] - public void Test_4551() - { - } - [Fact] - public void Test_4552() - { - } - [Fact] - public void Test_4553() - { - } - [Fact] - public void Test_4554() - { - } - [Fact] - public void Test_4555() - { - } - [Fact] - public void Test_4556() - { - } - [Fact] - public void Test_4557() - { - } - [Fact] - public void Test_4558() - { - } - [Fact] - public void Test_4559() - { - } - [Fact] - public void Test_4560() - { - } - [Fact] - public void Test_4561() - { - } - [Fact] - public void Test_4562() - { - } - [Fact] - public void Test_4563() - { - } - [Fact] - public void Test_4564() - { - } - [Fact] - public void Test_4565() - { - } - [Fact] - public void Test_4566() - { - } - [Fact] - public void Test_4567() - { - } - [Fact] - public void Test_4568() - { - } - [Fact] - public void Test_4569() - { - } - [Fact] - public void Test_4570() - { - } - [Fact] - public void Test_4571() - { - } - [Fact] - public void Test_4572() - { - } - [Fact] - public void Test_4573() - { - } - [Fact] - public void Test_4574() - { - } - [Fact] - public void Test_4575() - { - } - [Fact] - public void Test_4576() - { - } - [Fact] - public void Test_4577() - { - } - [Fact] - public void Test_4578() - { - } - [Fact] - public void Test_4579() - { - } - [Fact] - public void Test_4580() - { - } - [Fact] - public void Test_4581() - { - } - [Fact] - public void Test_4582() - { - } - [Fact] - public void Test_4583() - { - } - [Fact] - public void Test_4584() - { - } - [Fact] - public void Test_4585() - { - } - [Fact] - public void Test_4586() - { - } - [Fact] - public void Test_4587() - { - } - [Fact] - public void Test_4588() - { - } - [Fact] - public void Test_4589() - { - } - [Fact] - public void Test_4590() - { - } - [Fact] - public void Test_4591() - { - } - [Fact] - public void Test_4592() - { - } - [Fact] - public void Test_4593() - { - } - [Fact] - public void Test_4594() - { - } - [Fact] - public void Test_4595() - { - } - [Fact] - public void Test_4596() - { - } - [Fact] - public void Test_4597() - { - } - [Fact] - public void Test_4598() - { - } - [Fact] - public void Test_4599() - { - } - [Fact] - public void Test_4600() - { - } - [Fact] - public void Test_4601() - { - } - [Fact] - public void Test_4602() - { - } - [Fact] - public void Test_4603() - { - } - [Fact] - public void Test_4604() - { - } - [Fact] - public void Test_4605() - { - } - [Fact] - public void Test_4606() - { - } - [Fact] - public void Test_4607() - { - } - [Fact] - public void Test_4608() - { - } - [Fact] - public void Test_4609() - { - } - [Fact] - public void Test_4610() - { - } - [Fact] - public void Test_4611() - { - } - [Fact] - public void Test_4612() - { - } - [Fact] - public void Test_4613() - { - } - [Fact] - public void Test_4614() - { - } - [Fact] - public void Test_4615() - { - } - [Fact] - public void Test_4616() - { - } - [Fact] - public void Test_4617() - { - } - [Fact] - public void Test_4618() - { - } - [Fact] - public void Test_4619() - { - } - [Fact] - public void Test_4620() - { - } - [Fact] - public void Test_4621() - { - } - [Fact] - public void Test_4622() - { - } - [Fact] - public void Test_4623() - { - } - [Fact] - public void Test_4624() - { - } - [Fact] - public void Test_4625() - { - } - [Fact] - public void Test_4626() - { - } - [Fact] - public void Test_4627() - { - } - [Fact] - public void Test_4628() - { - } - [Fact] - public void Test_4629() - { - } - [Fact] - public void Test_4630() - { - } - [Fact] - public void Test_4631() - { - } - [Fact] - public void Test_4632() - { - } - [Fact] - public void Test_4633() - { - } - [Fact] - public void Test_4634() - { - } - [Fact] - public void Test_4635() - { - } - [Fact] - public void Test_4636() - { - } - [Fact] - public void Test_4637() - { - } - [Fact] - public void Test_4638() - { - } - [Fact] - public void Test_4639() - { - } - [Fact] - public void Test_4640() - { - } - [Fact] - public void Test_4641() - { - } - [Fact] - public void Test_4642() - { - } - [Fact] - public void Test_4643() - { - } - [Fact] - public void Test_4644() - { - } - [Fact] - public void Test_4645() - { - } - [Fact] - public void Test_4646() - { - } - [Fact] - public void Test_4647() - { - } - [Fact] - public void Test_4648() - { - } - [Fact] - public void Test_4649() - { - } - [Fact] - public void Test_4650() - { - } - [Fact] - public void Test_4651() - { - } - [Fact] - public void Test_4652() - { - } - [Fact] - public void Test_4653() - { - } - [Fact] - public void Test_4654() - { - } - [Fact] - public void Test_4655() - { - } - [Fact] - public void Test_4656() - { - } - [Fact] - public void Test_4657() - { - } - [Fact] - public void Test_4658() - { - } - [Fact] - public void Test_4659() - { - } - [Fact] - public void Test_4660() - { - } - [Fact] - public void Test_4661() - { - } - [Fact] - public void Test_4662() - { - } - [Fact] - public void Test_4663() - { - } - [Fact] - public void Test_4664() - { - } - [Fact] - public void Test_4665() - { - } - [Fact] - public void Test_4666() - { - } - [Fact] - public void Test_4667() - { - } - [Fact] - public void Test_4668() - { - } - [Fact] - public void Test_4669() - { - } - [Fact] - public void Test_4670() - { - } - [Fact] - public void Test_4671() - { - } - [Fact] - public void Test_4672() - { - } - [Fact] - public void Test_4673() - { - } - [Fact] - public void Test_4674() - { - } - [Fact] - public void Test_4675() - { - } - [Fact] - public void Test_4676() - { - } - [Fact] - public void Test_4677() - { - } - [Fact] - public void Test_4678() - { - } - [Fact] - public void Test_4679() - { - } - [Fact] - public void Test_4680() - { - } - [Fact] - public void Test_4681() - { - } - [Fact] - public void Test_4682() - { - } - [Fact] - public void Test_4683() - { - } - [Fact] - public void Test_4684() - { - } - [Fact] - public void Test_4685() - { - } - [Fact] - public void Test_4686() - { - } - [Fact] - public void Test_4687() - { - } - [Fact] - public void Test_4688() - { - } - [Fact] - public void Test_4689() - { - } - [Fact] - public void Test_4690() - { - } - [Fact] - public void Test_4691() - { - } - [Fact] - public void Test_4692() - { - } - [Fact] - public void Test_4693() - { - } - [Fact] - public void Test_4694() - { - } - [Fact] - public void Test_4695() - { - } - [Fact] - public void Test_4696() - { - } - [Fact] - public void Test_4697() - { - } - [Fact] - public void Test_4698() - { - } - [Fact] - public void Test_4699() - { - } - [Fact] - public void Test_4700() - { - } - [Fact] - public void Test_4701() - { - } - [Fact] - public void Test_4702() - { - } - [Fact] - public void Test_4703() - { - } - [Fact] - public void Test_4704() - { - } - [Fact] - public void Test_4705() - { - } - [Fact] - public void Test_4706() - { - } - [Fact] - public void Test_4707() - { - } - [Fact] - public void Test_4708() - { - } - [Fact] - public void Test_4709() - { - } - [Fact] - public void Test_4710() - { - } - [Fact] - public void Test_4711() - { - } - [Fact] - public void Test_4712() - { - } - [Fact] - public void Test_4713() - { - } - [Fact] - public void Test_4714() - { - } - [Fact] - public void Test_4715() - { - } - [Fact] - public void Test_4716() - { - } - [Fact] - public void Test_4717() - { - } - [Fact] - public void Test_4718() - { - } - [Fact] - public void Test_4719() - { - } - [Fact] - public void Test_4720() - { - } - [Fact] - public void Test_4721() - { - } - [Fact] - public void Test_4722() - { - } - [Fact] - public void Test_4723() - { - } - [Fact] - public void Test_4724() - { - } - [Fact] - public void Test_4725() - { - } - [Fact] - public void Test_4726() - { - } - [Fact] - public void Test_4727() - { - } - [Fact] - public void Test_4728() - { - } - [Fact] - public void Test_4729() - { - } - [Fact] - public void Test_4730() - { - } - [Fact] - public void Test_4731() - { - } - [Fact] - public void Test_4732() - { - } - [Fact] - public void Test_4733() - { - } - [Fact] - public void Test_4734() - { - } - [Fact] - public void Test_4735() - { - } - [Fact] - public void Test_4736() - { - } - [Fact] - public void Test_4737() - { - } - [Fact] - public void Test_4738() - { - } - [Fact] - public void Test_4739() - { - } - [Fact] - public void Test_4740() - { - } - [Fact] - public void Test_4741() - { - } - [Fact] - public void Test_4742() - { - } - [Fact] - public void Test_4743() - { - } - [Fact] - public void Test_4744() - { - } - [Fact] - public void Test_4745() - { - } - [Fact] - public void Test_4746() - { - } - [Fact] - public void Test_4747() - { - } - [Fact] - public void Test_4748() - { - } - [Fact] - public void Test_4749() - { - } - [Fact] - public void Test_4750() - { - } - [Fact] - public void Test_4751() - { - } - [Fact] - public void Test_4752() - { - } - [Fact] - public void Test_4753() - { - } - [Fact] - public void Test_4754() - { - } - [Fact] - public void Test_4755() - { - } - [Fact] - public void Test_4756() - { - } - [Fact] - public void Test_4757() - { - } - [Fact] - public void Test_4758() - { - } - [Fact] - public void Test_4759() - { - } - [Fact] - public void Test_4760() - { - } - [Fact] - public void Test_4761() - { - } - [Fact] - public void Test_4762() - { - } - [Fact] - public void Test_4763() - { - } - [Fact] - public void Test_4764() - { - } - [Fact] - public void Test_4765() - { - } - [Fact] - public void Test_4766() - { - } - [Fact] - public void Test_4767() - { - } - [Fact] - public void Test_4768() - { - } - [Fact] - public void Test_4769() - { - } - [Fact] - public void Test_4770() - { - } - [Fact] - public void Test_4771() - { - } - [Fact] - public void Test_4772() - { - } - [Fact] - public void Test_4773() - { - } - [Fact] - public void Test_4774() - { - } - [Fact] - public void Test_4775() - { - } - [Fact] - public void Test_4776() - { - } - [Fact] - public void Test_4777() - { - } - [Fact] - public void Test_4778() - { - } - [Fact] - public void Test_4779() - { - } - [Fact] - public void Test_4780() - { - } - [Fact] - public void Test_4781() - { - } - [Fact] - public void Test_4782() - { - } - [Fact] - public void Test_4783() - { - } - [Fact] - public void Test_4784() - { - } - [Fact] - public void Test_4785() - { - } - [Fact] - public void Test_4786() - { - } - [Fact] - public void Test_4787() - { - } - [Fact] - public void Test_4788() - { - } - [Fact] - public void Test_4789() - { - } - [Fact] - public void Test_4790() - { - } - [Fact] - public void Test_4791() - { - } - [Fact] - public void Test_4792() - { - } - [Fact] - public void Test_4793() - { - } - [Fact] - public void Test_4794() - { - } - [Fact] - public void Test_4795() - { - } - [Fact] - public void Test_4796() - { - } - [Fact] - public void Test_4797() - { - } - [Fact] - public void Test_4798() - { - } - [Fact] - public void Test_4799() - { - } - [Fact] - public void Test_4800() - { - } - [Fact] - public void Test_4801() - { - } - [Fact] - public void Test_4802() - { - } - [Fact] - public void Test_4803() - { - } - [Fact] - public void Test_4804() - { - } - [Fact] - public void Test_4805() - { - } - [Fact] - public void Test_4806() - { - } - [Fact] - public void Test_4807() - { - } - [Fact] - public void Test_4808() - { - } - [Fact] - public void Test_4809() - { - } - [Fact] - public void Test_4810() - { - } - [Fact] - public void Test_4811() - { - } - [Fact] - public void Test_4812() - { - } - [Fact] - public void Test_4813() - { - } - [Fact] - public void Test_4814() - { - } - [Fact] - public void Test_4815() - { - } - [Fact] - public void Test_4816() - { - } - [Fact] - public void Test_4817() - { - } - [Fact] - public void Test_4818() - { - } - [Fact] - public void Test_4819() - { - } - [Fact] - public void Test_4820() - { - } - [Fact] - public void Test_4821() - { - } - [Fact] - public void Test_4822() - { - } - [Fact] - public void Test_4823() - { - } - [Fact] - public void Test_4824() - { - } - [Fact] - public void Test_4825() - { - } - [Fact] - public void Test_4826() - { - } - [Fact] - public void Test_4827() - { - } - [Fact] - public void Test_4828() - { - } - [Fact] - public void Test_4829() - { - } - [Fact] - public void Test_4830() - { - } - [Fact] - public void Test_4831() - { - } - [Fact] - public void Test_4832() - { - } - [Fact] - public void Test_4833() - { - } - [Fact] - public void Test_4834() - { - } - [Fact] - public void Test_4835() - { - } - [Fact] - public void Test_4836() - { - } - [Fact] - public void Test_4837() - { - } - [Fact] - public void Test_4838() - { - } - [Fact] - public void Test_4839() - { - } - [Fact] - public void Test_4840() - { - } - [Fact] - public void Test_4841() - { - } - [Fact] - public void Test_4842() - { - } - [Fact] - public void Test_4843() - { - } - [Fact] - public void Test_4844() - { - } - [Fact] - public void Test_4845() - { - } - [Fact] - public void Test_4846() - { - } - [Fact] - public void Test_4847() - { - } - [Fact] - public void Test_4848() - { - } - [Fact] - public void Test_4849() - { - } - [Fact] - public void Test_4850() - { - } - [Fact] - public void Test_4851() - { - } - [Fact] - public void Test_4852() - { - } - [Fact] - public void Test_4853() - { - } - [Fact] - public void Test_4854() - { - } - [Fact] - public void Test_4855() - { - } - [Fact] - public void Test_4856() - { - } - [Fact] - public void Test_4857() - { - } - [Fact] - public void Test_4858() - { - } - [Fact] - public void Test_4859() - { - } - [Fact] - public void Test_4860() - { - } - [Fact] - public void Test_4861() - { - } - [Fact] - public void Test_4862() - { - } - [Fact] - public void Test_4863() - { - } - [Fact] - public void Test_4864() - { - } - [Fact] - public void Test_4865() - { - } - [Fact] - public void Test_4866() - { - } - [Fact] - public void Test_4867() - { - } - [Fact] - public void Test_4868() - { - } - [Fact] - public void Test_4869() - { - } - [Fact] - public void Test_4870() - { - } - [Fact] - public void Test_4871() - { - } - [Fact] - public void Test_4872() - { - } - [Fact] - public void Test_4873() - { - } - [Fact] - public void Test_4874() - { - } - [Fact] - public void Test_4875() - { - } - [Fact] - public void Test_4876() - { - } - [Fact] - public void Test_4877() - { - } - [Fact] - public void Test_4878() - { - } - [Fact] - public void Test_4879() - { - } - [Fact] - public void Test_4880() - { - } - [Fact] - public void Test_4881() - { - } - [Fact] - public void Test_4882() - { - } - [Fact] - public void Test_4883() - { - } - [Fact] - public void Test_4884() - { - } - [Fact] - public void Test_4885() - { - } - [Fact] - public void Test_4886() - { - } - [Fact] - public void Test_4887() - { - } - [Fact] - public void Test_4888() - { - } - [Fact] - public void Test_4889() - { - } - [Fact] - public void Test_4890() - { - } - [Fact] - public void Test_4891() - { - } - [Fact] - public void Test_4892() - { - } - [Fact] - public void Test_4893() - { - } - [Fact] - public void Test_4894() - { - } - [Fact] - public void Test_4895() - { - } - [Fact] - public void Test_4896() - { - } - [Fact] - public void Test_4897() - { - } - [Fact] - public void Test_4898() - { - } - [Fact] - public void Test_4899() - { - } - [Fact] - public void Test_4900() - { - } - [Fact] - public void Test_4901() - { - } - [Fact] - public void Test_4902() - { - } - [Fact] - public void Test_4903() - { - } - [Fact] - public void Test_4904() - { - } - [Fact] - public void Test_4905() - { - } - [Fact] - public void Test_4906() - { - } - [Fact] - public void Test_4907() - { - } - [Fact] - public void Test_4908() - { - } - [Fact] - public void Test_4909() - { - } - [Fact] - public void Test_4910() - { - } - [Fact] - public void Test_4911() - { - } - [Fact] - public void Test_4912() - { - } - [Fact] - public void Test_4913() - { - } - [Fact] - public void Test_4914() - { - } - [Fact] - public void Test_4915() - { - } - [Fact] - public void Test_4916() - { - } - [Fact] - public void Test_4917() - { - } - [Fact] - public void Test_4918() - { - } - [Fact] - public void Test_4919() - { - } - [Fact] - public void Test_4920() - { - } - [Fact] - public void Test_4921() - { - } - [Fact] - public void Test_4922() - { - } - [Fact] - public void Test_4923() - { - } - [Fact] - public void Test_4924() - { - } - [Fact] - public void Test_4925() - { - } - [Fact] - public void Test_4926() - { - } - [Fact] - public void Test_4927() - { - } - [Fact] - public void Test_4928() - { - } - [Fact] - public void Test_4929() - { - } - [Fact] - public void Test_4930() - { - } - [Fact] - public void Test_4931() - { - } - [Fact] - public void Test_4932() - { - } - [Fact] - public void Test_4933() - { - } - [Fact] - public void Test_4934() - { - } - [Fact] - public void Test_4935() - { - } - [Fact] - public void Test_4936() - { - } - [Fact] - public void Test_4937() - { - } - [Fact] - public void Test_4938() - { - } - [Fact] - public void Test_4939() - { - } - [Fact] - public void Test_4940() - { - } - [Fact] - public void Test_4941() - { - } - [Fact] - public void Test_4942() - { - } - [Fact] - public void Test_4943() - { - } - [Fact] - public void Test_4944() - { - } - [Fact] - public void Test_4945() - { - } - [Fact] - public void Test_4946() - { - } - [Fact] - public void Test_4947() - { - } - [Fact] - public void Test_4948() - { - } - [Fact] - public void Test_4949() - { - } - [Fact] - public void Test_4950() - { - } - [Fact] - public void Test_4951() - { - } - [Fact] - public void Test_4952() - { - } - [Fact] - public void Test_4953() - { - } - [Fact] - public void Test_4954() - { - } - [Fact] - public void Test_4955() - { - } - [Fact] - public void Test_4956() - { - } - [Fact] - public void Test_4957() - { - } - [Fact] - public void Test_4958() - { - } - [Fact] - public void Test_4959() - { - } - [Fact] - public void Test_4960() - { - } - [Fact] - public void Test_4961() - { - } - [Fact] - public void Test_4962() - { - } - [Fact] - public void Test_4963() - { - } - [Fact] - public void Test_4964() - { - } - [Fact] - public void Test_4965() - { - } - [Fact] - public void Test_4966() - { - } - [Fact] - public void Test_4967() - { - } - [Fact] - public void Test_4968() - { - } - [Fact] - public void Test_4969() - { - } - [Fact] - public void Test_4970() - { - } - [Fact] - public void Test_4971() - { - } - [Fact] - public void Test_4972() - { - } - [Fact] - public void Test_4973() - { - } - [Fact] - public void Test_4974() - { - } - [Fact] - public void Test_4975() - { - } - [Fact] - public void Test_4976() - { - } - [Fact] - public void Test_4977() - { - } - [Fact] - public void Test_4978() - { - } - [Fact] - public void Test_4979() - { - } - [Fact] - public void Test_4980() - { - } - [Fact] - public void Test_4981() - { - } - [Fact] - public void Test_4982() - { - } - [Fact] - public void Test_4983() - { - } - [Fact] - public void Test_4984() - { - } - [Fact] - public void Test_4985() - { - } - [Fact] - public void Test_4986() - { - } - [Fact] - public void Test_4987() - { - } - [Fact] - public void Test_4988() - { - } - [Fact] - public void Test_4989() - { - } - [Fact] - public void Test_4990() - { - } - [Fact] - public void Test_4991() - { - } - [Fact] - public void Test_4992() - { - } - [Fact] - public void Test_4993() - { - } - [Fact] - public void Test_4994() - { - } - [Fact] - public void Test_4995() - { - } - [Fact] - public void Test_4996() - { - } - [Fact] - public void Test_4997() - { - } - [Fact] - public void Test_4998() - { - } - [Fact] - public void Test_4999() - { - } - [Fact] - public void Test_5000() - { - } - [Fact] - public void Test_5001() - { - } - [Fact] - public void Test_5002() - { - } - [Fact] - public void Test_5003() - { - } - [Fact] - public void Test_5004() - { - } - [Fact] - public void Test_5005() - { - } - [Fact] - public void Test_5006() - { - } - [Fact] - public void Test_5007() - { - } - [Fact] - public void Test_5008() - { - } - [Fact] - public void Test_5009() - { - } - [Fact] - public void Test_5010() - { - } - [Fact] - public void Test_5011() - { - } - [Fact] - public void Test_5012() - { - } - [Fact] - public void Test_5013() - { - } - [Fact] - public void Test_5014() - { - } - [Fact] - public void Test_5015() - { - } - [Fact] - public void Test_5016() - { - } - [Fact] - public void Test_5017() - { - } - [Fact] - public void Test_5018() - { - } - [Fact] - public void Test_5019() - { - } - [Fact] - public void Test_5020() - { - } - [Fact] - public void Test_5021() - { - } - [Fact] - public void Test_5022() - { - } - [Fact] - public void Test_5023() - { - } - [Fact] - public void Test_5024() - { - } - [Fact] - public void Test_5025() - { - } - [Fact] - public void Test_5026() - { - } - [Fact] - public void Test_5027() - { - } - [Fact] - public void Test_5028() - { - } - [Fact] - public void Test_5029() - { - } - [Fact] - public void Test_5030() - { - } - [Fact] - public void Test_5031() - { - } - [Fact] - public void Test_5032() - { - } - [Fact] - public void Test_5033() - { - } - [Fact] - public void Test_5034() - { - } - [Fact] - public void Test_5035() - { - } - [Fact] - public void Test_5036() - { - } - [Fact] - public void Test_5037() - { - } - [Fact] - public void Test_5038() - { - } - [Fact] - public void Test_5039() - { - } - [Fact] - public void Test_5040() - { - } - [Fact] - public void Test_5041() - { - } - [Fact] - public void Test_5042() - { - } - [Fact] - public void Test_5043() - { - } - [Fact] - public void Test_5044() - { - } - [Fact] - public void Test_5045() - { - } - [Fact] - public void Test_5046() - { - } - [Fact] - public void Test_5047() - { - } - [Fact] - public void Test_5048() - { - } - [Fact] - public void Test_5049() - { - } - [Fact] - public void Test_5050() - { - } - [Fact] - public void Test_5051() - { - } - [Fact] - public void Test_5052() - { - } - [Fact] - public void Test_5053() - { - } - [Fact] - public void Test_5054() - { - } - [Fact] - public void Test_5055() - { - } - [Fact] - public void Test_5056() - { - } - [Fact] - public void Test_5057() - { - } - [Fact] - public void Test_5058() - { - } - [Fact] - public void Test_5059() - { - } - [Fact] - public void Test_5060() - { - } - [Fact] - public void Test_5061() - { - } - [Fact] - public void Test_5062() - { - } - [Fact] - public void Test_5063() - { - } - [Fact] - public void Test_5064() - { - } - [Fact] - public void Test_5065() - { - } - [Fact] - public void Test_5066() - { - } - [Fact] - public void Test_5067() - { - } - [Fact] - public void Test_5068() - { - } - [Fact] - public void Test_5069() - { - } - [Fact] - public void Test_5070() - { - } - [Fact] - public void Test_5071() - { - } - [Fact] - public void Test_5072() - { - } - [Fact] - public void Test_5073() - { - } - [Fact] - public void Test_5074() - { - } - [Fact] - public void Test_5075() - { - } - [Fact] - public void Test_5076() - { - } - [Fact] - public void Test_5077() - { - } - [Fact] - public void Test_5078() - { - } - [Fact] - public void Test_5079() - { - } - [Fact] - public void Test_5080() - { - } - [Fact] - public void Test_5081() - { - } - [Fact] - public void Test_5082() - { - } - [Fact] - public void Test_5083() - { - } - [Fact] - public void Test_5084() - { - } - [Fact] - public void Test_5085() - { - } - [Fact] - public void Test_5086() - { - } - [Fact] - public void Test_5087() - { - } - [Fact] - public void Test_5088() - { - } - [Fact] - public void Test_5089() - { - } - [Fact] - public void Test_5090() - { - } - [Fact] - public void Test_5091() - { - } - [Fact] - public void Test_5092() - { - } - [Fact] - public void Test_5093() - { - } - [Fact] - public void Test_5094() - { - } - [Fact] - public void Test_5095() - { - } - [Fact] - public void Test_5096() - { - } - [Fact] - public void Test_5097() - { - } - [Fact] - public void Test_5098() - { - } - [Fact] - public void Test_5099() - { - } - [Fact] - public void Test_5100() - { - } - [Fact] - public void Test_5101() - { - } - [Fact] - public void Test_5102() - { - } - [Fact] - public void Test_5103() - { - } - [Fact] - public void Test_5104() - { - } - [Fact] - public void Test_5105() - { - } - [Fact] - public void Test_5106() - { - } - [Fact] - public void Test_5107() - { - } - [Fact] - public void Test_5108() - { - } - [Fact] - public void Test_5109() - { - } - [Fact] - public void Test_5110() - { - } - [Fact] - public void Test_5111() - { - } - [Fact] - public void Test_5112() - { - } - [Fact] - public void Test_5113() - { - } - [Fact] - public void Test_5114() - { - } - [Fact] - public void Test_5115() - { - } - [Fact] - public void Test_5116() - { - } - [Fact] - public void Test_5117() - { - } - [Fact] - public void Test_5118() - { - } - [Fact] - public void Test_5119() - { - } - [Fact] - public void Test_5120() - { - } - [Fact] - public void Test_5121() - { - } - [Fact] - public void Test_5122() - { - } - [Fact] - public void Test_5123() - { - } - [Fact] - public void Test_5124() - { - } - [Fact] - public void Test_5125() - { - } - [Fact] - public void Test_5126() - { - } - [Fact] - public void Test_5127() - { - } - [Fact] - public void Test_5128() - { - } - [Fact] - public void Test_5129() - { - } - [Fact] - public void Test_5130() - { - } - [Fact] - public void Test_5131() - { - } - [Fact] - public void Test_5132() - { - } - [Fact] - public void Test_5133() - { - } - [Fact] - public void Test_5134() - { - } - [Fact] - public void Test_5135() - { - } - [Fact] - public void Test_5136() - { - } - [Fact] - public void Test_5137() - { - } - [Fact] - public void Test_5138() - { - } - [Fact] - public void Test_5139() - { - } - [Fact] - public void Test_5140() - { - } - [Fact] - public void Test_5141() - { - } - [Fact] - public void Test_5142() - { - } - [Fact] - public void Test_5143() - { - } - [Fact] - public void Test_5144() - { - } - [Fact] - public void Test_5145() - { - } - [Fact] - public void Test_5146() - { - } - [Fact] - public void Test_5147() - { - } - [Fact] - public void Test_5148() - { - } - [Fact] - public void Test_5149() - { - } - [Fact] - public void Test_5150() - { - } - [Fact] - public void Test_5151() - { - } - [Fact] - public void Test_5152() - { - } - [Fact] - public void Test_5153() - { - } - [Fact] - public void Test_5154() - { - } - [Fact] - public void Test_5155() - { - } - [Fact] - public void Test_5156() - { - } - [Fact] - public void Test_5157() - { - } - [Fact] - public void Test_5158() - { - } - [Fact] - public void Test_5159() - { - } - [Fact] - public void Test_5160() - { - } - [Fact] - public void Test_5161() - { - } - [Fact] - public void Test_5162() - { - } - [Fact] - public void Test_5163() - { - } - [Fact] - public void Test_5164() - { - } - [Fact] - public void Test_5165() - { - } - [Fact] - public void Test_5166() - { - } - [Fact] - public void Test_5167() - { - } - [Fact] - public void Test_5168() - { - } - [Fact] - public void Test_5169() - { - } - [Fact] - public void Test_5170() - { - } - [Fact] - public void Test_5171() - { - } - [Fact] - public void Test_5172() - { - } - [Fact] - public void Test_5173() - { - } - [Fact] - public void Test_5174() - { - } - [Fact] - public void Test_5175() - { - } - [Fact] - public void Test_5176() - { - } - [Fact] - public void Test_5177() - { - } - [Fact] - public void Test_5178() - { - } - [Fact] - public void Test_5179() - { - } - [Fact] - public void Test_5180() - { - } - [Fact] - public void Test_5181() - { - } - [Fact] - public void Test_5182() - { - } - [Fact] - public void Test_5183() - { - } - [Fact] - public void Test_5184() - { - } - [Fact] - public void Test_5185() - { - } - [Fact] - public void Test_5186() - { - } - [Fact] - public void Test_5187() - { - } - [Fact] - public void Test_5188() - { - } - [Fact] - public void Test_5189() - { - } - [Fact] - public void Test_5190() - { - } - [Fact] - public void Test_5191() - { - } - [Fact] - public void Test_5192() - { - } - [Fact] - public void Test_5193() - { - } - [Fact] - public void Test_5194() - { - } - [Fact] - public void Test_5195() - { - } - [Fact] - public void Test_5196() - { - } - [Fact] - public void Test_5197() - { - } - [Fact] - public void Test_5198() - { - } - [Fact] - public void Test_5199() - { - } - [Fact] - public void Test_5200() - { - } - [Fact] - public void Test_5201() - { - } - [Fact] - public void Test_5202() - { - } - [Fact] - public void Test_5203() - { - } - [Fact] - public void Test_5204() - { - } - [Fact] - public void Test_5205() - { - } - [Fact] - public void Test_5206() - { - } - [Fact] - public void Test_5207() - { - } - [Fact] - public void Test_5208() - { - } - [Fact] - public void Test_5209() - { - } - [Fact] - public void Test_5210() - { - } - [Fact] - public void Test_5211() - { - } - [Fact] - public void Test_5212() - { - } - [Fact] - public void Test_5213() - { - } - [Fact] - public void Test_5214() - { - } - [Fact] - public void Test_5215() - { - } - [Fact] - public void Test_5216() - { - } - [Fact] - public void Test_5217() - { - } - [Fact] - public void Test_5218() - { - } - [Fact] - public void Test_5219() - { - } - [Fact] - public void Test_5220() - { - } - [Fact] - public void Test_5221() - { - } - [Fact] - public void Test_5222() - { - } - [Fact] - public void Test_5223() - { - } - [Fact] - public void Test_5224() - { - } - [Fact] - public void Test_5225() - { - } - [Fact] - public void Test_5226() - { - } - [Fact] - public void Test_5227() - { - } - [Fact] - public void Test_5228() - { - } - [Fact] - public void Test_5229() - { - } - [Fact] - public void Test_5230() - { - } - [Fact] - public void Test_5231() - { - } - [Fact] - public void Test_5232() - { - } - [Fact] - public void Test_5233() - { - } - [Fact] - public void Test_5234() - { - } - [Fact] - public void Test_5235() - { - } - [Fact] - public void Test_5236() - { - } - [Fact] - public void Test_5237() - { - } - [Fact] - public void Test_5238() - { - } - [Fact] - public void Test_5239() - { - } - [Fact] - public void Test_5240() - { - } - [Fact] - public void Test_5241() - { - } - [Fact] - public void Test_5242() - { - } - [Fact] - public void Test_5243() - { - } - [Fact] - public void Test_5244() - { - } - [Fact] - public void Test_5245() - { - } - [Fact] - public void Test_5246() - { - } - [Fact] - public void Test_5247() - { - } - [Fact] - public void Test_5248() - { - } - [Fact] - public void Test_5249() - { - } - [Fact] - public void Test_5250() - { - } - [Fact] - public void Test_5251() - { - } - [Fact] - public void Test_5252() - { - } - [Fact] - public void Test_5253() - { - } - [Fact] - public void Test_5254() - { - } - [Fact] - public void Test_5255() - { - } - [Fact] - public void Test_5256() - { - } - [Fact] - public void Test_5257() - { - } - [Fact] - public void Test_5258() - { - } - [Fact] - public void Test_5259() - { - } - [Fact] - public void Test_5260() - { - } - [Fact] - public void Test_5261() - { - } - [Fact] - public void Test_5262() - { - } - [Fact] - public void Test_5263() - { - } - [Fact] - public void Test_5264() - { - } - [Fact] - public void Test_5265() - { - } - [Fact] - public void Test_5266() - { - } - [Fact] - public void Test_5267() - { - } - [Fact] - public void Test_5268() - { - } - [Fact] - public void Test_5269() - { - } - [Fact] - public void Test_5270() - { - } - [Fact] - public void Test_5271() - { - } - [Fact] - public void Test_5272() - { - } - [Fact] - public void Test_5273() - { - } - [Fact] - public void Test_5274() - { - } - [Fact] - public void Test_5275() - { - } - [Fact] - public void Test_5276() - { - } - [Fact] - public void Test_5277() - { - } - [Fact] - public void Test_5278() - { - } - [Fact] - public void Test_5279() - { - } - [Fact] - public void Test_5280() - { - } - [Fact] - public void Test_5281() - { - } - [Fact] - public void Test_5282() - { - } - [Fact] - public void Test_5283() - { - } - [Fact] - public void Test_5284() - { - } - [Fact] - public void Test_5285() - { - } - [Fact] - public void Test_5286() - { - } - [Fact] - public void Test_5287() - { - } - [Fact] - public void Test_5288() - { - } - [Fact] - public void Test_5289() - { - } - [Fact] - public void Test_5290() - { - } - [Fact] - public void Test_5291() - { - } - [Fact] - public void Test_5292() - { - } - [Fact] - public void Test_5293() - { - } - [Fact] - public void Test_5294() - { - } - [Fact] - public void Test_5295() - { - } - [Fact] - public void Test_5296() - { - } - [Fact] - public void Test_5297() - { - } - [Fact] - public void Test_5298() - { - } - [Fact] - public void Test_5299() - { - } - [Fact] - public void Test_5300() - { - } - [Fact] - public void Test_5301() - { - } - [Fact] - public void Test_5302() - { - } - [Fact] - public void Test_5303() - { - } - [Fact] - public void Test_5304() - { - } - [Fact] - public void Test_5305() - { - } - [Fact] - public void Test_5306() - { - } - [Fact] - public void Test_5307() - { - } - [Fact] - public void Test_5308() - { - } - [Fact] - public void Test_5309() - { - } - [Fact] - public void Test_5310() - { - } - [Fact] - public void Test_5311() - { - } - [Fact] - public void Test_5312() - { - } - [Fact] - public void Test_5313() - { - } - [Fact] - public void Test_5314() - { - } - [Fact] - public void Test_5315() - { - } - [Fact] - public void Test_5316() - { - } - [Fact] - public void Test_5317() - { - } - [Fact] - public void Test_5318() - { - } - [Fact] - public void Test_5319() - { - } - [Fact] - public void Test_5320() - { - } - [Fact] - public void Test_5321() - { - } - [Fact] - public void Test_5322() - { - } - [Fact] - public void Test_5323() - { - } - [Fact] - public void Test_5324() - { - } - [Fact] - public void Test_5325() - { - } - [Fact] - public void Test_5326() - { - } - [Fact] - public void Test_5327() - { - } - [Fact] - public void Test_5328() - { - } - [Fact] - public void Test_5329() - { - } - [Fact] - public void Test_5330() - { - } - [Fact] - public void Test_5331() - { - } - [Fact] - public void Test_5332() - { - } - [Fact] - public void Test_5333() - { - } - [Fact] - public void Test_5334() - { - } - [Fact] - public void Test_5335() - { - } - [Fact] - public void Test_5336() - { - } - [Fact] - public void Test_5337() - { - } - [Fact] - public void Test_5338() - { - } - [Fact] - public void Test_5339() - { - } - [Fact] - public void Test_5340() - { - } - [Fact] - public void Test_5341() - { - } - [Fact] - public void Test_5342() - { - } - [Fact] - public void Test_5343() - { - } - [Fact] - public void Test_5344() - { - } - [Fact] - public void Test_5345() - { - } - [Fact] - public void Test_5346() - { - } - [Fact] - public void Test_5347() - { - } - [Fact] - public void Test_5348() - { - } - [Fact] - public void Test_5349() - { - } - [Fact] - public void Test_5350() - { - } - [Fact] - public void Test_5351() - { - } - [Fact] - public void Test_5352() - { - } - [Fact] - public void Test_5353() - { - } - [Fact] - public void Test_5354() - { - } - [Fact] - public void Test_5355() - { - } - [Fact] - public void Test_5356() - { - } - [Fact] - public void Test_5357() - { - } - [Fact] - public void Test_5358() - { - } - [Fact] - public void Test_5359() - { - } - [Fact] - public void Test_5360() - { - } - [Fact] - public void Test_5361() - { - } - [Fact] - public void Test_5362() - { - } - [Fact] - public void Test_5363() - { - } - [Fact] - public void Test_5364() - { - } - [Fact] - public void Test_5365() - { - } - [Fact] - public void Test_5366() - { - } - [Fact] - public void Test_5367() - { - } - [Fact] - public void Test_5368() - { - } - [Fact] - public void Test_5369() - { - } - [Fact] - public void Test_5370() - { - } - [Fact] - public void Test_5371() - { - } - [Fact] - public void Test_5372() - { - } - [Fact] - public void Test_5373() - { - } - [Fact] - public void Test_5374() - { - } - [Fact] - public void Test_5375() - { - } - [Fact] - public void Test_5376() - { - } - [Fact] - public void Test_5377() - { - } - [Fact] - public void Test_5378() - { - } - [Fact] - public void Test_5379() - { - } - [Fact] - public void Test_5380() - { - } - [Fact] - public void Test_5381() - { - } - [Fact] - public void Test_5382() - { - } - [Fact] - public void Test_5383() - { - } - [Fact] - public void Test_5384() - { - } - [Fact] - public void Test_5385() - { - } - [Fact] - public void Test_5386() - { - } - [Fact] - public void Test_5387() - { - } - [Fact] - public void Test_5388() - { - } - [Fact] - public void Test_5389() - { - } - [Fact] - public void Test_5390() - { - } - [Fact] - public void Test_5391() - { - } - [Fact] - public void Test_5392() - { - } - [Fact] - public void Test_5393() - { - } - [Fact] - public void Test_5394() - { - } - [Fact] - public void Test_5395() - { - } - [Fact] - public void Test_5396() - { - } - [Fact] - public void Test_5397() - { - } - [Fact] - public void Test_5398() - { - } - [Fact] - public void Test_5399() - { - } - [Fact] - public void Test_5400() - { - } - [Fact] - public void Test_5401() - { - } - [Fact] - public void Test_5402() - { - } - [Fact] - public void Test_5403() - { - } - [Fact] - public void Test_5404() - { - } - [Fact] - public void Test_5405() - { - } - [Fact] - public void Test_5406() - { - } - [Fact] - public void Test_5407() - { - } - [Fact] - public void Test_5408() - { - } - [Fact] - public void Test_5409() - { - } - [Fact] - public void Test_5410() - { - } - [Fact] - public void Test_5411() - { - } - [Fact] - public void Test_5412() - { - } - [Fact] - public void Test_5413() - { - } - [Fact] - public void Test_5414() - { - } - [Fact] - public void Test_5415() - { - } - [Fact] - public void Test_5416() - { - } - [Fact] - public void Test_5417() - { - } - [Fact] - public void Test_5418() - { - } - [Fact] - public void Test_5419() - { - } - [Fact] - public void Test_5420() - { - } - [Fact] - public void Test_5421() - { - } - [Fact] - public void Test_5422() - { - } - [Fact] - public void Test_5423() - { - } - [Fact] - public void Test_5424() - { - } - [Fact] - public void Test_5425() - { - } - [Fact] - public void Test_5426() - { - } - [Fact] - public void Test_5427() - { - } - [Fact] - public void Test_5428() - { - } - [Fact] - public void Test_5429() - { - } - [Fact] - public void Test_5430() - { - } - [Fact] - public void Test_5431() - { - } - [Fact] - public void Test_5432() - { - } - [Fact] - public void Test_5433() - { - } - [Fact] - public void Test_5434() - { - } - [Fact] - public void Test_5435() - { - } - [Fact] - public void Test_5436() - { - } - [Fact] - public void Test_5437() - { - } - [Fact] - public void Test_5438() - { - } - [Fact] - public void Test_5439() - { - } - [Fact] - public void Test_5440() - { - } - [Fact] - public void Test_5441() - { - } - [Fact] - public void Test_5442() - { - } - [Fact] - public void Test_5443() - { - } - [Fact] - public void Test_5444() - { - } - [Fact] - public void Test_5445() - { - } - [Fact] - public void Test_5446() - { - } - [Fact] - public void Test_5447() - { - } - [Fact] - public void Test_5448() - { - } - [Fact] - public void Test_5449() - { - } - [Fact] - public void Test_5450() - { - } - [Fact] - public void Test_5451() - { - } - [Fact] - public void Test_5452() - { - } - [Fact] - public void Test_5453() - { - } - [Fact] - public void Test_5454() - { - } - [Fact] - public void Test_5455() - { - } - [Fact] - public void Test_5456() - { - } - [Fact] - public void Test_5457() - { - } - [Fact] - public void Test_5458() - { - } - [Fact] - public void Test_5459() - { - } - [Fact] - public void Test_5460() - { - } - [Fact] - public void Test_5461() - { - } - [Fact] - public void Test_5462() - { - } - [Fact] - public void Test_5463() - { - } - [Fact] - public void Test_5464() - { - } - [Fact] - public void Test_5465() - { - } - [Fact] - public void Test_5466() - { - } - [Fact] - public void Test_5467() - { - } - [Fact] - public void Test_5468() - { - } - [Fact] - public void Test_5469() - { - } - [Fact] - public void Test_5470() - { - } - [Fact] - public void Test_5471() - { - } - [Fact] - public void Test_5472() - { - } - [Fact] - public void Test_5473() - { - } - [Fact] - public void Test_5474() - { - } - [Fact] - public void Test_5475() - { - } - [Fact] - public void Test_5476() - { - } - [Fact] - public void Test_5477() - { - } - [Fact] - public void Test_5478() - { - } - [Fact] - public void Test_5479() - { - } - [Fact] - public void Test_5480() - { - } - [Fact] - public void Test_5481() - { - } - [Fact] - public void Test_5482() - { - } - [Fact] - public void Test_5483() - { - } - [Fact] - public void Test_5484() - { - } - [Fact] - public void Test_5485() - { - } - [Fact] - public void Test_5486() - { - } - [Fact] - public void Test_5487() - { - } - [Fact] - public void Test_5488() - { - } - [Fact] - public void Test_5489() - { - } - [Fact] - public void Test_5490() - { - } - [Fact] - public void Test_5491() - { - } - [Fact] - public void Test_5492() - { - } - [Fact] - public void Test_5493() - { - } - [Fact] - public void Test_5494() - { - } - [Fact] - public void Test_5495() - { - } - [Fact] - public void Test_5496() - { - } - [Fact] - public void Test_5497() - { - } - [Fact] - public void Test_5498() - { - } - [Fact] - public void Test_5499() - { - } - [Fact] - public void Test_5500() - { - } - [Fact] - public void Test_5501() - { - } - [Fact] - public void Test_5502() - { - } - [Fact] - public void Test_5503() - { - } - [Fact] - public void Test_5504() - { - } - [Fact] - public void Test_5505() - { - } - [Fact] - public void Test_5506() - { - } - [Fact] - public void Test_5507() - { - } - [Fact] - public void Test_5508() - { - } - [Fact] - public void Test_5509() - { - } - [Fact] - public void Test_5510() - { - } - [Fact] - public void Test_5511() - { - } - [Fact] - public void Test_5512() - { - } - [Fact] - public void Test_5513() - { - } - [Fact] - public void Test_5514() - { - } - [Fact] - public void Test_5515() - { - } - [Fact] - public void Test_5516() - { - } - [Fact] - public void Test_5517() - { - } - [Fact] - public void Test_5518() - { - } - [Fact] - public void Test_5519() - { - } - [Fact] - public void Test_5520() - { - } - [Fact] - public void Test_5521() - { - } - [Fact] - public void Test_5522() - { - } - [Fact] - public void Test_5523() - { - } - [Fact] - public void Test_5524() - { - } - [Fact] - public void Test_5525() - { - } - [Fact] - public void Test_5526() - { - } - [Fact] - public void Test_5527() - { - } - [Fact] - public void Test_5528() - { - } - [Fact] - public void Test_5529() - { - } - [Fact] - public void Test_5530() - { - } - [Fact] - public void Test_5531() - { - } - [Fact] - public void Test_5532() - { - } - [Fact] - public void Test_5533() - { - } - [Fact] - public void Test_5534() - { - } - [Fact] - public void Test_5535() - { - } - [Fact] - public void Test_5536() - { - } - [Fact] - public void Test_5537() - { - } - [Fact] - public void Test_5538() - { - } - [Fact] - public void Test_5539() - { - } - [Fact] - public void Test_5540() - { - } - [Fact] - public void Test_5541() - { - } - [Fact] - public void Test_5542() - { - } - [Fact] - public void Test_5543() - { - } - [Fact] - public void Test_5544() - { - } - [Fact] - public void Test_5545() - { - } - [Fact] - public void Test_5546() - { - } - [Fact] - public void Test_5547() - { - } - [Fact] - public void Test_5548() - { - } - [Fact] - public void Test_5549() - { - } - [Fact] - public void Test_5550() - { - } - [Fact] - public void Test_5551() - { - } - [Fact] - public void Test_5552() - { - } - [Fact] - public void Test_5553() - { - } - [Fact] - public void Test_5554() - { - } - [Fact] - public void Test_5555() - { - } - [Fact] - public void Test_5556() - { - } - [Fact] - public void Test_5557() - { - } - [Fact] - public void Test_5558() - { - } - [Fact] - public void Test_5559() - { - } - [Fact] - public void Test_5560() - { - } - [Fact] - public void Test_5561() - { - } - [Fact] - public void Test_5562() - { - } - [Fact] - public void Test_5563() - { - } - [Fact] - public void Test_5564() - { - } - [Fact] - public void Test_5565() - { - } - [Fact] - public void Test_5566() - { - } - [Fact] - public void Test_5567() - { - } - [Fact] - public void Test_5568() - { - } - [Fact] - public void Test_5569() - { - } - [Fact] - public void Test_5570() - { - } - [Fact] - public void Test_5571() - { - } - [Fact] - public void Test_5572() - { - } - [Fact] - public void Test_5573() - { - } - [Fact] - public void Test_5574() - { - } - [Fact] - public void Test_5575() - { - } - [Fact] - public void Test_5576() - { - } - [Fact] - public void Test_5577() - { - } - [Fact] - public void Test_5578() - { - } - [Fact] - public void Test_5579() - { - } - [Fact] - public void Test_5580() - { - } - [Fact] - public void Test_5581() - { - } - [Fact] - public void Test_5582() - { - } - [Fact] - public void Test_5583() - { - } - [Fact] - public void Test_5584() - { - } - [Fact] - public void Test_5585() - { - } - [Fact] - public void Test_5586() - { - } - [Fact] - public void Test_5587() - { - } - [Fact] - public void Test_5588() - { - } - [Fact] - public void Test_5589() - { - } - [Fact] - public void Test_5590() - { - } - [Fact] - public void Test_5591() - { - } - [Fact] - public void Test_5592() - { - } - [Fact] - public void Test_5593() - { - } - [Fact] - public void Test_5594() - { - } - [Fact] - public void Test_5595() - { - } - [Fact] - public void Test_5596() - { - } - [Fact] - public void Test_5597() - { - } - [Fact] - public void Test_5598() - { - } - [Fact] - public void Test_5599() - { - } - [Fact] - public void Test_5600() - { - } - [Fact] - public void Test_5601() - { - } - [Fact] - public void Test_5602() - { - } - [Fact] - public void Test_5603() - { - } - [Fact] - public void Test_5604() - { - } - [Fact] - public void Test_5605() - { - } - [Fact] - public void Test_5606() - { - } - [Fact] - public void Test_5607() - { - } - [Fact] - public void Test_5608() - { - } - [Fact] - public void Test_5609() - { - } - [Fact] - public void Test_5610() - { - } - [Fact] - public void Test_5611() - { - } - [Fact] - public void Test_5612() - { - } - [Fact] - public void Test_5613() - { - } - [Fact] - public void Test_5614() - { - } - [Fact] - public void Test_5615() - { - } - [Fact] - public void Test_5616() - { - } - [Fact] - public void Test_5617() - { - } - [Fact] - public void Test_5618() - { - } - [Fact] - public void Test_5619() - { - } - [Fact] - public void Test_5620() - { - } - [Fact] - public void Test_5621() - { - } - [Fact] - public void Test_5622() - { - } - [Fact] - public void Test_5623() - { - } - [Fact] - public void Test_5624() - { - } - [Fact] - public void Test_5625() - { - } - [Fact] - public void Test_5626() - { - } - [Fact] - public void Test_5627() - { - } - [Fact] - public void Test_5628() - { - } - [Fact] - public void Test_5629() - { - } - [Fact] - public void Test_5630() - { - } - [Fact] - public void Test_5631() - { - } - [Fact] - public void Test_5632() - { - } - [Fact] - public void Test_5633() - { - } - [Fact] - public void Test_5634() - { - } - [Fact] - public void Test_5635() - { - } - [Fact] - public void Test_5636() - { - } - [Fact] - public void Test_5637() - { - } - [Fact] - public void Test_5638() - { - } - [Fact] - public void Test_5639() - { - } - [Fact] - public void Test_5640() - { - } - [Fact] - public void Test_5641() - { - } - [Fact] - public void Test_5642() - { - } - [Fact] - public void Test_5643() - { - } - [Fact] - public void Test_5644() - { - } - [Fact] - public void Test_5645() - { - } - [Fact] - public void Test_5646() - { - } - [Fact] - public void Test_5647() - { - } - [Fact] - public void Test_5648() - { - } - [Fact] - public void Test_5649() - { - } - [Fact] - public void Test_5650() - { - } - [Fact] - public void Test_5651() - { - } - [Fact] - public void Test_5652() - { - } - [Fact] - public void Test_5653() - { - } - [Fact] - public void Test_5654() - { - } - [Fact] - public void Test_5655() - { - } - [Fact] - public void Test_5656() - { - } - [Fact] - public void Test_5657() - { - } - [Fact] - public void Test_5658() - { - } - [Fact] - public void Test_5659() - { - } - [Fact] - public void Test_5660() - { - } - [Fact] - public void Test_5661() - { - } - [Fact] - public void Test_5662() - { - } - [Fact] - public void Test_5663() - { - } - [Fact] - public void Test_5664() - { - } - [Fact] - public void Test_5665() - { - } - [Fact] - public void Test_5666() - { - } - [Fact] - public void Test_5667() - { - } - [Fact] - public void Test_5668() - { - } - [Fact] - public void Test_5669() - { - } - [Fact] - public void Test_5670() - { - } - [Fact] - public void Test_5671() - { - } - [Fact] - public void Test_5672() - { - } - [Fact] - public void Test_5673() - { - } - [Fact] - public void Test_5674() - { - } - [Fact] - public void Test_5675() - { - } - [Fact] - public void Test_5676() - { - } - [Fact] - public void Test_5677() - { - } - [Fact] - public void Test_5678() - { - } - [Fact] - public void Test_5679() - { - } - [Fact] - public void Test_5680() - { - } - [Fact] - public void Test_5681() - { - } - [Fact] - public void Test_5682() - { - } - [Fact] - public void Test_5683() - { - } - [Fact] - public void Test_5684() - { - } - [Fact] - public void Test_5685() - { - } - [Fact] - public void Test_5686() - { - } - [Fact] - public void Test_5687() - { - } - [Fact] - public void Test_5688() - { - } - [Fact] - public void Test_5689() - { - } - [Fact] - public void Test_5690() - { - } - [Fact] - public void Test_5691() - { - } - [Fact] - public void Test_5692() - { - } - [Fact] - public void Test_5693() - { - } - [Fact] - public void Test_5694() - { - } - [Fact] - public void Test_5695() - { - } - [Fact] - public void Test_5696() - { - } - [Fact] - public void Test_5697() - { - } - [Fact] - public void Test_5698() - { - } - [Fact] - public void Test_5699() - { - } - [Fact] - public void Test_5700() - { - } - [Fact] - public void Test_5701() - { - } - [Fact] - public void Test_5702() - { - } - [Fact] - public void Test_5703() - { - } - [Fact] - public void Test_5704() - { - } - [Fact] - public void Test_5705() - { - } - [Fact] - public void Test_5706() - { - } - [Fact] - public void Test_5707() - { - } - [Fact] - public void Test_5708() - { - } - [Fact] - public void Test_5709() - { - } - [Fact] - public void Test_5710() - { - } - [Fact] - public void Test_5711() - { - } - [Fact] - public void Test_5712() - { - } - [Fact] - public void Test_5713() - { - } - [Fact] - public void Test_5714() - { - } - [Fact] - public void Test_5715() - { - } - [Fact] - public void Test_5716() - { - } - [Fact] - public void Test_5717() - { - } - [Fact] - public void Test_5718() - { - } - [Fact] - public void Test_5719() - { - } - [Fact] - public void Test_5720() - { - } - [Fact] - public void Test_5721() - { - } - [Fact] - public void Test_5722() - { - } - [Fact] - public void Test_5723() - { - } - [Fact] - public void Test_5724() - { - } - [Fact] - public void Test_5725() - { - } - [Fact] - public void Test_5726() - { - } - [Fact] - public void Test_5727() - { - } - [Fact] - public void Test_5728() - { - } - [Fact] - public void Test_5729() - { - } - [Fact] - public void Test_5730() - { - } - [Fact] - public void Test_5731() - { - } - [Fact] - public void Test_5732() - { - } - [Fact] - public void Test_5733() - { - } - [Fact] - public void Test_5734() - { - } - [Fact] - public void Test_5735() - { - } - [Fact] - public void Test_5736() - { - } - [Fact] - public void Test_5737() - { - } - [Fact] - public void Test_5738() - { - } - [Fact] - public void Test_5739() - { - } - [Fact] - public void Test_5740() - { - } - [Fact] - public void Test_5741() - { - } - [Fact] - public void Test_5742() - { - } - [Fact] - public void Test_5743() - { - } - [Fact] - public void Test_5744() - { - } - [Fact] - public void Test_5745() - { - } - [Fact] - public void Test_5746() - { - } - [Fact] - public void Test_5747() - { - } - [Fact] - public void Test_5748() - { - } - [Fact] - public void Test_5749() - { - } - [Fact] - public void Test_5750() - { - } - [Fact] - public void Test_5751() - { - } - [Fact] - public void Test_5752() - { - } - [Fact] - public void Test_5753() - { - } - [Fact] - public void Test_5754() - { - } - [Fact] - public void Test_5755() - { - } - [Fact] - public void Test_5756() - { - } - [Fact] - public void Test_5757() - { - } - [Fact] - public void Test_5758() - { - } - [Fact] - public void Test_5759() - { - } - [Fact] - public void Test_5760() - { - } - [Fact] - public void Test_5761() - { - } - [Fact] - public void Test_5762() - { - } - [Fact] - public void Test_5763() - { - } - [Fact] - public void Test_5764() - { - } - [Fact] - public void Test_5765() - { - } - [Fact] - public void Test_5766() - { - } - [Fact] - public void Test_5767() - { - } - [Fact] - public void Test_5768() - { - } - [Fact] - public void Test_5769() - { - } - [Fact] - public void Test_5770() - { - } - [Fact] - public void Test_5771() - { - } - [Fact] - public void Test_5772() - { - } - [Fact] - public void Test_5773() - { - } - [Fact] - public void Test_5774() - { - } - [Fact] - public void Test_5775() - { - } - [Fact] - public void Test_5776() - { - } - [Fact] - public void Test_5777() - { - } - [Fact] - public void Test_5778() - { - } - [Fact] - public void Test_5779() - { - } - [Fact] - public void Test_5780() - { - } - [Fact] - public void Test_5781() - { - } - [Fact] - public void Test_5782() - { - } - [Fact] - public void Test_5783() - { - } - [Fact] - public void Test_5784() - { - } - [Fact] - public void Test_5785() - { - } - [Fact] - public void Test_5786() - { - } - [Fact] - public void Test_5787() - { - } - [Fact] - public void Test_5788() - { - } - [Fact] - public void Test_5789() - { - } - [Fact] - public void Test_5790() - { - } - [Fact] - public void Test_5791() - { - } - [Fact] - public void Test_5792() - { - } - [Fact] - public void Test_5793() - { - } - [Fact] - public void Test_5794() - { - } - [Fact] - public void Test_5795() - { - } - [Fact] - public void Test_5796() - { - } - [Fact] - public void Test_5797() - { - } - [Fact] - public void Test_5798() - { - } - [Fact] - public void Test_5799() - { - } - [Fact] - public void Test_5800() - { - } - [Fact] - public void Test_5801() - { - } - [Fact] - public void Test_5802() - { - } - [Fact] - public void Test_5803() - { - } - [Fact] - public void Test_5804() - { - } - [Fact] - public void Test_5805() - { - } - [Fact] - public void Test_5806() - { - } - [Fact] - public void Test_5807() - { - } - [Fact] - public void Test_5808() - { - } - [Fact] - public void Test_5809() - { - } - [Fact] - public void Test_5810() - { - } - [Fact] - public void Test_5811() - { - } - [Fact] - public void Test_5812() - { - } - [Fact] - public void Test_5813() - { - } - [Fact] - public void Test_5814() - { - } - [Fact] - public void Test_5815() - { - } - [Fact] - public void Test_5816() - { - } - [Fact] - public void Test_5817() - { - } - [Fact] - public void Test_5818() - { - } - [Fact] - public void Test_5819() - { - } - [Fact] - public void Test_5820() - { - } - [Fact] - public void Test_5821() - { - } - [Fact] - public void Test_5822() - { - } - [Fact] - public void Test_5823() - { - } - [Fact] - public void Test_5824() - { - } - [Fact] - public void Test_5825() - { - } - [Fact] - public void Test_5826() - { - } - [Fact] - public void Test_5827() - { - } - [Fact] - public void Test_5828() - { - } - [Fact] - public void Test_5829() - { - } - [Fact] - public void Test_5830() - { - } - [Fact] - public void Test_5831() - { - } - [Fact] - public void Test_5832() - { - } - [Fact] - public void Test_5833() - { - } - [Fact] - public void Test_5834() - { - } - [Fact] - public void Test_5835() - { - } - [Fact] - public void Test_5836() - { - } - [Fact] - public void Test_5837() - { - } - [Fact] - public void Test_5838() - { - } - [Fact] - public void Test_5839() - { - } - [Fact] - public void Test_5840() - { - } - [Fact] - public void Test_5841() - { - } - [Fact] - public void Test_5842() - { - } - [Fact] - public void Test_5843() - { - } - [Fact] - public void Test_5844() - { - } - [Fact] - public void Test_5845() - { - } - [Fact] - public void Test_5846() - { - } - [Fact] - public void Test_5847() - { - } - [Fact] - public void Test_5848() - { - } - [Fact] - public void Test_5849() - { - } - [Fact] - public void Test_5850() - { - } - [Fact] - public void Test_5851() - { - } - [Fact] - public void Test_5852() - { - } - [Fact] - public void Test_5853() - { - } - [Fact] - public void Test_5854() - { - } - [Fact] - public void Test_5855() - { - } - [Fact] - public void Test_5856() - { - } - [Fact] - public void Test_5857() - { - } - [Fact] - public void Test_5858() - { - } - [Fact] - public void Test_5859() - { - } - [Fact] - public void Test_5860() - { - } - [Fact] - public void Test_5861() - { - } - [Fact] - public void Test_5862() - { - } - [Fact] - public void Test_5863() - { - } - [Fact] - public void Test_5864() - { - } - [Fact] - public void Test_5865() - { - } - [Fact] - public void Test_5866() - { - } - [Fact] - public void Test_5867() - { - } - [Fact] - public void Test_5868() - { - } - [Fact] - public void Test_5869() - { - } - [Fact] - public void Test_5870() - { - } - [Fact] - public void Test_5871() - { - } - [Fact] - public void Test_5872() - { - } - [Fact] - public void Test_5873() - { - } - [Fact] - public void Test_5874() - { - } - [Fact] - public void Test_5875() - { - } - [Fact] - public void Test_5876() - { - } - [Fact] - public void Test_5877() - { - } - [Fact] - public void Test_5878() - { - } - [Fact] - public void Test_5879() - { - } - [Fact] - public void Test_5880() - { - } - [Fact] - public void Test_5881() - { - } - [Fact] - public void Test_5882() - { - } - [Fact] - public void Test_5883() - { - } - [Fact] - public void Test_5884() - { - } - [Fact] - public void Test_5885() - { - } - [Fact] - public void Test_5886() - { - } - [Fact] - public void Test_5887() - { - } - [Fact] - public void Test_5888() - { - } - [Fact] - public void Test_5889() - { - } - [Fact] - public void Test_5890() - { - } - [Fact] - public void Test_5891() - { - } - [Fact] - public void Test_5892() - { - } - [Fact] - public void Test_5893() - { - } - [Fact] - public void Test_5894() - { - } - [Fact] - public void Test_5895() - { - } - [Fact] - public void Test_5896() - { - } - [Fact] - public void Test_5897() - { - } - [Fact] - public void Test_5898() - { - } - [Fact] - public void Test_5899() - { - } - [Fact] - public void Test_5900() - { - } - [Fact] - public void Test_5901() - { - } - [Fact] - public void Test_5902() - { - } - [Fact] - public void Test_5903() - { - } - [Fact] - public void Test_5904() - { - } - [Fact] - public void Test_5905() - { - } - [Fact] - public void Test_5906() - { - } - [Fact] - public void Test_5907() - { - } - [Fact] - public void Test_5908() - { - } - [Fact] - public void Test_5909() - { - } - [Fact] - public void Test_5910() - { - } - [Fact] - public void Test_5911() - { - } - [Fact] - public void Test_5912() - { - } - [Fact] - public void Test_5913() - { - } - [Fact] - public void Test_5914() - { - } - [Fact] - public void Test_5915() - { - } - [Fact] - public void Test_5916() - { - } - [Fact] - public void Test_5917() - { - } - [Fact] - public void Test_5918() - { - } - [Fact] - public void Test_5919() - { - } - [Fact] - public void Test_5920() - { - } - [Fact] - public void Test_5921() - { - } - [Fact] - public void Test_5922() - { - } - [Fact] - public void Test_5923() - { - } - [Fact] - public void Test_5924() - { - } - [Fact] - public void Test_5925() - { - } - [Fact] - public void Test_5926() - { - } - [Fact] - public void Test_5927() - { - } - [Fact] - public void Test_5928() - { - } - [Fact] - public void Test_5929() - { - } - [Fact] - public void Test_5930() - { - } - [Fact] - public void Test_5931() - { - } - [Fact] - public void Test_5932() - { - } - [Fact] - public void Test_5933() - { - } - [Fact] - public void Test_5934() - { - } - [Fact] - public void Test_5935() - { - } - [Fact] - public void Test_5936() - { - } - [Fact] - public void Test_5937() - { - } - [Fact] - public void Test_5938() - { - } - [Fact] - public void Test_5939() - { - } - [Fact] - public void Test_5940() - { - } - [Fact] - public void Test_5941() - { - } - [Fact] - public void Test_5942() - { - } - [Fact] - public void Test_5943() - { - } - [Fact] - public void Test_5944() - { - } - [Fact] - public void Test_5945() - { - } - [Fact] - public void Test_5946() - { - } - [Fact] - public void Test_5947() - { - } - [Fact] - public void Test_5948() - { - } - [Fact] - public void Test_5949() - { - } - [Fact] - public void Test_5950() - { - } - [Fact] - public void Test_5951() - { - } - [Fact] - public void Test_5952() - { - } - [Fact] - public void Test_5953() - { - } - [Fact] - public void Test_5954() - { - } - [Fact] - public void Test_5955() - { - } - [Fact] - public void Test_5956() - { - } - [Fact] - public void Test_5957() - { - } - [Fact] - public void Test_5958() - { - } - [Fact] - public void Test_5959() - { - } - [Fact] - public void Test_5960() - { - } - [Fact] - public void Test_5961() - { - } - [Fact] - public void Test_5962() - { - } - [Fact] - public void Test_5963() - { - } - [Fact] - public void Test_5964() - { - } - [Fact] - public void Test_5965() - { - } - [Fact] - public void Test_5966() - { - } - [Fact] - public void Test_5967() - { - } - [Fact] - public void Test_5968() - { - } - [Fact] - public void Test_5969() - { - } - [Fact] - public void Test_5970() - { - } - [Fact] - public void Test_5971() - { - } - [Fact] - public void Test_5972() - { - } - [Fact] - public void Test_5973() - { - } - [Fact] - public void Test_5974() - { - } - [Fact] - public void Test_5975() - { - } - [Fact] - public void Test_5976() - { - } - [Fact] - public void Test_5977() - { - } - [Fact] - public void Test_5978() - { - } - [Fact] - public void Test_5979() - { - } - [Fact] - public void Test_5980() - { - } - [Fact] - public void Test_5981() - { - } - [Fact] - public void Test_5982() - { - } - [Fact] - public void Test_5983() - { - } - [Fact] - public void Test_5984() - { - } - [Fact] - public void Test_5985() - { - } - [Fact] - public void Test_5986() - { - } - [Fact] - public void Test_5987() - { - } - [Fact] - public void Test_5988() - { - } - [Fact] - public void Test_5989() - { - } - [Fact] - public void Test_5990() - { - } - [Fact] - public void Test_5991() - { - } - [Fact] - public void Test_5992() - { - } - [Fact] - public void Test_5993() - { - } - [Fact] - public void Test_5994() - { - } - [Fact] - public void Test_5995() - { - } - [Fact] - public void Test_5996() - { - } - [Fact] - public void Test_5997() - { - } - [Fact] - public void Test_5998() - { - } - [Fact] - public void Test_5999() - { - } - [Fact] - public void Test_6000() - { - } - [Fact] - public void Test_6001() - { - } - [Fact] - public void Test_6002() - { - } - [Fact] - public void Test_6003() - { - } - [Fact] - public void Test_6004() - { - } - [Fact] - public void Test_6005() - { - } - [Fact] - public void Test_6006() - { - } - [Fact] - public void Test_6007() - { - } - [Fact] - public void Test_6008() - { - } - [Fact] - public void Test_6009() - { - } - [Fact] - public void Test_6010() - { - } - [Fact] - public void Test_6011() - { - } - [Fact] - public void Test_6012() - { - } - [Fact] - public void Test_6013() - { - } - [Fact] - public void Test_6014() - { - } - [Fact] - public void Test_6015() - { - } - [Fact] - public void Test_6016() - { - } - [Fact] - public void Test_6017() - { - } - [Fact] - public void Test_6018() - { - } - [Fact] - public void Test_6019() - { - } - [Fact] - public void Test_6020() - { - } - [Fact] - public void Test_6021() - { - } - [Fact] - public void Test_6022() - { - } - [Fact] - public void Test_6023() - { - } - [Fact] - public void Test_6024() - { - } - [Fact] - public void Test_6025() - { - } - [Fact] - public void Test_6026() - { - } - [Fact] - public void Test_6027() - { - } - [Fact] - public void Test_6028() - { - } - [Fact] - public void Test_6029() - { - } - [Fact] - public void Test_6030() - { - } - [Fact] - public void Test_6031() - { - } - [Fact] - public void Test_6032() - { - } - [Fact] - public void Test_6033() - { - } - [Fact] - public void Test_6034() - { - } - [Fact] - public void Test_6035() - { - } - [Fact] - public void Test_6036() - { - } - [Fact] - public void Test_6037() - { - } - [Fact] - public void Test_6038() - { - } - [Fact] - public void Test_6039() - { - } - [Fact] - public void Test_6040() - { - } - [Fact] - public void Test_6041() - { - } - [Fact] - public void Test_6042() - { - } - [Fact] - public void Test_6043() - { - } - [Fact] - public void Test_6044() - { - } - [Fact] - public void Test_6045() - { - } - [Fact] - public void Test_6046() - { - } - [Fact] - public void Test_6047() - { - } - [Fact] - public void Test_6048() - { - } - [Fact] - public void Test_6049() - { - } - [Fact] - public void Test_6050() - { - } - [Fact] - public void Test_6051() - { - } - [Fact] - public void Test_6052() - { - } - [Fact] - public void Test_6053() - { - } - [Fact] - public void Test_6054() - { - } - [Fact] - public void Test_6055() - { - } - [Fact] - public void Test_6056() - { - } - [Fact] - public void Test_6057() - { - } - [Fact] - public void Test_6058() - { - } - [Fact] - public void Test_6059() - { - } - [Fact] - public void Test_6060() - { - } - [Fact] - public void Test_6061() - { - } - [Fact] - public void Test_6062() - { - } - [Fact] - public void Test_6063() - { - } - [Fact] - public void Test_6064() - { - } - [Fact] - public void Test_6065() - { - } - [Fact] - public void Test_6066() - { - } - [Fact] - public void Test_6067() - { - } - [Fact] - public void Test_6068() - { - } - [Fact] - public void Test_6069() - { - } - [Fact] - public void Test_6070() - { - } - [Fact] - public void Test_6071() - { - } - [Fact] - public void Test_6072() - { - } - [Fact] - public void Test_6073() - { - } - [Fact] - public void Test_6074() - { - } - [Fact] - public void Test_6075() - { - } - [Fact] - public void Test_6076() - { - } - [Fact] - public void Test_6077() - { - } - [Fact] - public void Test_6078() - { - } - [Fact] - public void Test_6079() - { - } - [Fact] - public void Test_6080() - { - } - [Fact] - public void Test_6081() - { - } - [Fact] - public void Test_6082() - { - } - [Fact] - public void Test_6083() - { - } - [Fact] - public void Test_6084() - { - } - [Fact] - public void Test_6085() - { - } - [Fact] - public void Test_6086() - { - } - [Fact] - public void Test_6087() - { - } - [Fact] - public void Test_6088() - { - } - [Fact] - public void Test_6089() - { - } - [Fact] - public void Test_6090() - { - } - [Fact] - public void Test_6091() - { - } - [Fact] - public void Test_6092() - { - } - [Fact] - public void Test_6093() - { - } - [Fact] - public void Test_6094() - { - } - [Fact] - public void Test_6095() - { - } - [Fact] - public void Test_6096() - { - } - [Fact] - public void Test_6097() - { - } - [Fact] - public void Test_6098() - { - } - [Fact] - public void Test_6099() - { - } - [Fact] - public void Test_6100() - { - } - [Fact] - public void Test_6101() - { - } - [Fact] - public void Test_6102() - { - } - [Fact] - public void Test_6103() - { - } - [Fact] - public void Test_6104() - { - } - [Fact] - public void Test_6105() - { - } - [Fact] - public void Test_6106() - { - } - [Fact] - public void Test_6107() - { - } - [Fact] - public void Test_6108() - { - } - [Fact] - public void Test_6109() - { - } - [Fact] - public void Test_6110() - { - } - [Fact] - public void Test_6111() - { - } - [Fact] - public void Test_6112() - { - } - [Fact] - public void Test_6113() - { - } - [Fact] - public void Test_6114() - { - } - [Fact] - public void Test_6115() - { - } - [Fact] - public void Test_6116() - { - } - [Fact] - public void Test_6117() - { - } - [Fact] - public void Test_6118() - { - } - [Fact] - public void Test_6119() - { - } - [Fact] - public void Test_6120() - { - } - [Fact] - public void Test_6121() - { - } - [Fact] - public void Test_6122() - { - } - [Fact] - public void Test_6123() - { - } - [Fact] - public void Test_6124() - { - } - [Fact] - public void Test_6125() - { - } - [Fact] - public void Test_6126() - { - } - [Fact] - public void Test_6127() - { - } - [Fact] - public void Test_6128() - { - } - [Fact] - public void Test_6129() - { - } - [Fact] - public void Test_6130() - { - } - [Fact] - public void Test_6131() - { - } - [Fact] - public void Test_6132() - { - } - [Fact] - public void Test_6133() - { - } - [Fact] - public void Test_6134() - { - } - [Fact] - public void Test_6135() - { - } - [Fact] - public void Test_6136() - { - } - [Fact] - public void Test_6137() - { - } - [Fact] - public void Test_6138() - { - } - [Fact] - public void Test_6139() - { - } - [Fact] - public void Test_6140() - { - } - [Fact] - public void Test_6141() - { - } - [Fact] - public void Test_6142() - { - } - [Fact] - public void Test_6143() - { - } - [Fact] - public void Test_6144() - { - } - [Fact] - public void Test_6145() - { - } - [Fact] - public void Test_6146() - { - } - [Fact] - public void Test_6147() - { - } - [Fact] - public void Test_6148() - { - } - [Fact] - public void Test_6149() - { - } - [Fact] - public void Test_6150() - { - } - [Fact] - public void Test_6151() - { - } - [Fact] - public void Test_6152() - { - } - [Fact] - public void Test_6153() - { - } - [Fact] - public void Test_6154() - { - } - [Fact] - public void Test_6155() - { - } - [Fact] - public void Test_6156() - { - } - [Fact] - public void Test_6157() - { - } - [Fact] - public void Test_6158() - { - } - [Fact] - public void Test_6159() - { - } - [Fact] - public void Test_6160() - { - } - [Fact] - public void Test_6161() - { - } - [Fact] - public void Test_6162() - { - } - [Fact] - public void Test_6163() - { - } - [Fact] - public void Test_6164() - { - } - [Fact] - public void Test_6165() - { - } - [Fact] - public void Test_6166() - { - } - [Fact] - public void Test_6167() - { - } - [Fact] - public void Test_6168() - { - } - [Fact] - public void Test_6169() - { - } - [Fact] - public void Test_6170() - { - } - [Fact] - public void Test_6171() - { - } - [Fact] - public void Test_6172() - { - } - [Fact] - public void Test_6173() - { - } - [Fact] - public void Test_6174() - { - } - [Fact] - public void Test_6175() - { - } - [Fact] - public void Test_6176() - { - } - [Fact] - public void Test_6177() - { - } - [Fact] - public void Test_6178() - { - } - [Fact] - public void Test_6179() - { - } - [Fact] - public void Test_6180() - { - } - [Fact] - public void Test_6181() - { - } - [Fact] - public void Test_6182() - { - } - [Fact] - public void Test_6183() - { - } - [Fact] - public void Test_6184() - { - } - [Fact] - public void Test_6185() - { - } - [Fact] - public void Test_6186() - { - } - [Fact] - public void Test_6187() - { - } - [Fact] - public void Test_6188() - { - } - [Fact] - public void Test_6189() - { - } - [Fact] - public void Test_6190() - { - } - [Fact] - public void Test_6191() - { - } - [Fact] - public void Test_6192() - { - } - [Fact] - public void Test_6193() - { - } - [Fact] - public void Test_6194() - { - } - [Fact] - public void Test_6195() - { - } - [Fact] - public void Test_6196() - { - } - [Fact] - public void Test_6197() - { - } - [Fact] - public void Test_6198() - { - } - [Fact] - public void Test_6199() - { - } - [Fact] - public void Test_6200() - { - } - [Fact] - public void Test_6201() - { - } - [Fact] - public void Test_6202() - { - } - [Fact] - public void Test_6203() - { - } - [Fact] - public void Test_6204() - { - } - [Fact] - public void Test_6205() - { - } - [Fact] - public void Test_6206() - { - } - [Fact] - public void Test_6207() - { - } - [Fact] - public void Test_6208() - { - } - [Fact] - public void Test_6209() - { - } - [Fact] - public void Test_6210() - { - } - [Fact] - public void Test_6211() - { - } - [Fact] - public void Test_6212() - { - } - [Fact] - public void Test_6213() - { - } - [Fact] - public void Test_6214() - { - } - [Fact] - public void Test_6215() - { - } - [Fact] - public void Test_6216() - { - } - [Fact] - public void Test_6217() - { - } - [Fact] - public void Test_6218() - { - } - [Fact] - public void Test_6219() - { - } - [Fact] - public void Test_6220() - { - } - [Fact] - public void Test_6221() - { - } - [Fact] - public void Test_6222() - { - } - [Fact] - public void Test_6223() - { - } - [Fact] - public void Test_6224() - { - } - [Fact] - public void Test_6225() - { - } - [Fact] - public void Test_6226() - { - } - [Fact] - public void Test_6227() - { - } - [Fact] - public void Test_6228() - { - } - [Fact] - public void Test_6229() - { - } - [Fact] - public void Test_6230() - { - } - [Fact] - public void Test_6231() - { - } - [Fact] - public void Test_6232() - { - } - [Fact] - public void Test_6233() - { - } - [Fact] - public void Test_6234() - { - } - [Fact] - public void Test_6235() - { - } - [Fact] - public void Test_6236() - { - } - [Fact] - public void Test_6237() - { - } - [Fact] - public void Test_6238() - { - } - [Fact] - public void Test_6239() - { - } - [Fact] - public void Test_6240() - { - } - [Fact] - public void Test_6241() - { - } - [Fact] - public void Test_6242() - { - } - [Fact] - public void Test_6243() - { - } - [Fact] - public void Test_6244() - { - } - [Fact] - public void Test_6245() - { - } - [Fact] - public void Test_6246() - { - } - [Fact] - public void Test_6247() - { - } - [Fact] - public void Test_6248() - { - } - [Fact] - public void Test_6249() - { - } - [Fact] - public void Test_6250() - { - } - [Fact] - public void Test_6251() - { - } - [Fact] - public void Test_6252() - { - } - [Fact] - public void Test_6253() - { - } - [Fact] - public void Test_6254() - { - } - [Fact] - public void Test_6255() - { - } - [Fact] - public void Test_6256() - { - } - [Fact] - public void Test_6257() - { - } - [Fact] - public void Test_6258() - { - } - [Fact] - public void Test_6259() - { - } - [Fact] - public void Test_6260() - { - } - [Fact] - public void Test_6261() - { - } - [Fact] - public void Test_6262() - { - } - [Fact] - public void Test_6263() - { - } - [Fact] - public void Test_6264() - { - } - [Fact] - public void Test_6265() - { - } - [Fact] - public void Test_6266() - { - } - [Fact] - public void Test_6267() - { - } - [Fact] - public void Test_6268() - { - } - [Fact] - public void Test_6269() - { - } - [Fact] - public void Test_6270() - { - } - [Fact] - public void Test_6271() - { - } - [Fact] - public void Test_6272() - { - } - [Fact] - public void Test_6273() - { - } - [Fact] - public void Test_6274() - { - } - [Fact] - public void Test_6275() - { - } - [Fact] - public void Test_6276() - { - } - [Fact] - public void Test_6277() - { - } - [Fact] - public void Test_6278() - { - } - [Fact] - public void Test_6279() - { - } - [Fact] - public void Test_6280() - { - } - [Fact] - public void Test_6281() - { - } - [Fact] - public void Test_6282() - { - } - [Fact] - public void Test_6283() - { - } - [Fact] - public void Test_6284() - { - } - [Fact] - public void Test_6285() - { - } - [Fact] - public void Test_6286() - { - } - [Fact] - public void Test_6287() - { - } - [Fact] - public void Test_6288() - { - } - [Fact] - public void Test_6289() - { - } - [Fact] - public void Test_6290() - { - } - [Fact] - public void Test_6291() - { - } - [Fact] - public void Test_6292() - { - } - [Fact] - public void Test_6293() - { - } - [Fact] - public void Test_6294() - { - } - [Fact] - public void Test_6295() - { - } - [Fact] - public void Test_6296() - { - } - [Fact] - public void Test_6297() - { - } - [Fact] - public void Test_6298() - { - } - [Fact] - public void Test_6299() - { - } - [Fact] - public void Test_6300() - { - } - [Fact] - public void Test_6301() - { - } - [Fact] - public void Test_6302() - { - } - [Fact] - public void Test_6303() - { - } - [Fact] - public void Test_6304() - { - } - [Fact] - public void Test_6305() - { - } - [Fact] - public void Test_6306() - { - } - [Fact] - public void Test_6307() - { - } - [Fact] - public void Test_6308() - { - } - [Fact] - public void Test_6309() - { - } - [Fact] - public void Test_6310() - { - } - [Fact] - public void Test_6311() - { - } - [Fact] - public void Test_6312() - { - } - [Fact] - public void Test_6313() - { - } - [Fact] - public void Test_6314() - { - } - [Fact] - public void Test_6315() - { - } - [Fact] - public void Test_6316() - { - } - [Fact] - public void Test_6317() - { - } - [Fact] - public void Test_6318() - { - } - [Fact] - public void Test_6319() - { - } - [Fact] - public void Test_6320() - { - } - [Fact] - public void Test_6321() - { - } - [Fact] - public void Test_6322() - { - } - [Fact] - public void Test_6323() - { - } - [Fact] - public void Test_6324() - { - } - [Fact] - public void Test_6325() - { - } - [Fact] - public void Test_6326() - { - } - [Fact] - public void Test_6327() - { - } - [Fact] - public void Test_6328() - { - } - [Fact] - public void Test_6329() - { - } - [Fact] - public void Test_6330() - { - } - [Fact] - public void Test_6331() - { - } - [Fact] - public void Test_6332() - { - } - [Fact] - public void Test_6333() - { - } - [Fact] - public void Test_6334() - { - } - [Fact] - public void Test_6335() - { - } - [Fact] - public void Test_6336() - { - } - [Fact] - public void Test_6337() - { - } - [Fact] - public void Test_6338() - { - } - [Fact] - public void Test_6339() - { - } - [Fact] - public void Test_6340() - { - } - [Fact] - public void Test_6341() - { - } - [Fact] - public void Test_6342() - { - } - [Fact] - public void Test_6343() - { - } - [Fact] - public void Test_6344() - { - } - [Fact] - public void Test_6345() - { - } - [Fact] - public void Test_6346() - { - } - [Fact] - public void Test_6347() - { - } - [Fact] - public void Test_6348() - { - } - [Fact] - public void Test_6349() - { - } - [Fact] - public void Test_6350() - { - } - [Fact] - public void Test_6351() - { - } - [Fact] - public void Test_6352() - { - } - [Fact] - public void Test_6353() - { - } - [Fact] - public void Test_6354() - { - } - [Fact] - public void Test_6355() - { - } - [Fact] - public void Test_6356() - { - } - [Fact] - public void Test_6357() - { - } - [Fact] - public void Test_6358() - { - } - [Fact] - public void Test_6359() - { - } - [Fact] - public void Test_6360() - { - } - [Fact] - public void Test_6361() - { - } - [Fact] - public void Test_6362() - { - } - [Fact] - public void Test_6363() - { - } - [Fact] - public void Test_6364() - { - } - [Fact] - public void Test_6365() - { - } - [Fact] - public void Test_6366() - { - } - [Fact] - public void Test_6367() - { - } - [Fact] - public void Test_6368() - { - } - [Fact] - public void Test_6369() - { - } - [Fact] - public void Test_6370() - { - } - [Fact] - public void Test_6371() - { - } - [Fact] - public void Test_6372() - { - } - [Fact] - public void Test_6373() - { - } - [Fact] - public void Test_6374() - { - } - [Fact] - public void Test_6375() - { - } - [Fact] - public void Test_6376() - { - } - [Fact] - public void Test_6377() - { - } - [Fact] - public void Test_6378() - { - } - [Fact] - public void Test_6379() - { - } - [Fact] - public void Test_6380() - { - } - [Fact] - public void Test_6381() - { - } - [Fact] - public void Test_6382() - { - } - [Fact] - public void Test_6383() - { - } - [Fact] - public void Test_6384() - { - } - [Fact] - public void Test_6385() - { - } - [Fact] - public void Test_6386() - { - } - [Fact] - public void Test_6387() - { - } - [Fact] - public void Test_6388() - { - } - [Fact] - public void Test_6389() - { - } - [Fact] - public void Test_6390() - { - } - [Fact] - public void Test_6391() - { - } - [Fact] - public void Test_6392() - { - } - [Fact] - public void Test_6393() - { - } - [Fact] - public void Test_6394() - { - } - [Fact] - public void Test_6395() - { - } - [Fact] - public void Test_6396() - { - } - [Fact] - public void Test_6397() - { - } - [Fact] - public void Test_6398() - { - } - [Fact] - public void Test_6399() - { - } - [Fact] - public void Test_6400() - { - } - [Fact] - public void Test_6401() - { - } - [Fact] - public void Test_6402() - { - } - [Fact] - public void Test_6403() - { - } - [Fact] - public void Test_6404() - { - } - [Fact] - public void Test_6405() - { - } - [Fact] - public void Test_6406() - { - } - [Fact] - public void Test_6407() - { - } - [Fact] - public void Test_6408() - { - } - [Fact] - public void Test_6409() - { - } - [Fact] - public void Test_6410() - { - } - [Fact] - public void Test_6411() - { - } - [Fact] - public void Test_6412() - { - } - [Fact] - public void Test_6413() - { - } - [Fact] - public void Test_6414() - { - } - [Fact] - public void Test_6415() - { - } - [Fact] - public void Test_6416() - { - } - [Fact] - public void Test_6417() - { - } - [Fact] - public void Test_6418() - { - } - [Fact] - public void Test_6419() - { - } - [Fact] - public void Test_6420() - { - } - [Fact] - public void Test_6421() - { - } - [Fact] - public void Test_6422() - { - } - [Fact] - public void Test_6423() - { - } - [Fact] - public void Test_6424() - { - } - [Fact] - public void Test_6425() - { - } - [Fact] - public void Test_6426() - { - } - [Fact] - public void Test_6427() - { - } - [Fact] - public void Test_6428() - { - } - [Fact] - public void Test_6429() - { - } - [Fact] - public void Test_6430() - { - } - [Fact] - public void Test_6431() - { - } - [Fact] - public void Test_6432() - { - } - [Fact] - public void Test_6433() - { - } - [Fact] - public void Test_6434() - { - } - [Fact] - public void Test_6435() - { - } - [Fact] - public void Test_6436() - { - } - [Fact] - public void Test_6437() - { - } - [Fact] - public void Test_6438() - { - } - [Fact] - public void Test_6439() - { - } - [Fact] - public void Test_6440() - { - } - [Fact] - public void Test_6441() - { - } - [Fact] - public void Test_6442() - { - } - [Fact] - public void Test_6443() - { - } - [Fact] - public void Test_6444() - { - } - [Fact] - public void Test_6445() - { - } - [Fact] - public void Test_6446() - { - } - [Fact] - public void Test_6447() - { - } - [Fact] - public void Test_6448() - { - } - [Fact] - public void Test_6449() - { - } - [Fact] - public void Test_6450() - { - } - [Fact] - public void Test_6451() - { - } - [Fact] - public void Test_6452() - { - } - [Fact] - public void Test_6453() - { - } - [Fact] - public void Test_6454() - { - } - [Fact] - public void Test_6455() - { - } - [Fact] - public void Test_6456() - { - } - [Fact] - public void Test_6457() - { - } - [Fact] - public void Test_6458() - { - } - [Fact] - public void Test_6459() - { - } - [Fact] - public void Test_6460() - { - } - [Fact] - public void Test_6461() - { - } - [Fact] - public void Test_6462() - { - } - [Fact] - public void Test_6463() - { - } - [Fact] - public void Test_6464() - { - } - [Fact] - public void Test_6465() - { - } - [Fact] - public void Test_6466() - { - } - [Fact] - public void Test_6467() - { - } - [Fact] - public void Test_6468() - { - } - [Fact] - public void Test_6469() - { - } - [Fact] - public void Test_6470() - { - } - [Fact] - public void Test_6471() - { - } - [Fact] - public void Test_6472() - { - } - [Fact] - public void Test_6473() - { - } - [Fact] - public void Test_6474() - { - } - [Fact] - public void Test_6475() - { - } - [Fact] - public void Test_6476() - { - } - [Fact] - public void Test_6477() - { - } - [Fact] - public void Test_6478() - { - } - [Fact] - public void Test_6479() - { - } - [Fact] - public void Test_6480() - { - } - [Fact] - public void Test_6481() - { - } - [Fact] - public void Test_6482() - { - } - [Fact] - public void Test_6483() - { - } - [Fact] - public void Test_6484() - { - } - [Fact] - public void Test_6485() - { - } - [Fact] - public void Test_6486() - { - } - [Fact] - public void Test_6487() - { - } - [Fact] - public void Test_6488() - { - } - [Fact] - public void Test_6489() - { - } - [Fact] - public void Test_6490() - { - } - [Fact] - public void Test_6491() - { - } - [Fact] - public void Test_6492() - { - } - [Fact] - public void Test_6493() - { - } - [Fact] - public void Test_6494() - { - } - [Fact] - public void Test_6495() - { - } - [Fact] - public void Test_6496() - { - } - [Fact] - public void Test_6497() - { - } - [Fact] - public void Test_6498() - { - } - [Fact] - public void Test_6499() - { - } - [Fact] - public void Test_6500() - { - } - [Fact] - public void Test_6501() - { - } - [Fact] - public void Test_6502() - { - } - [Fact] - public void Test_6503() - { - } - [Fact] - public void Test_6504() - { - } - [Fact] - public void Test_6505() - { - } - [Fact] - public void Test_6506() - { - } - [Fact] - public void Test_6507() - { - } - [Fact] - public void Test_6508() - { - } - [Fact] - public void Test_6509() - { - } - [Fact] - public void Test_6510() - { - } - [Fact] - public void Test_6511() - { - } - [Fact] - public void Test_6512() - { - } - [Fact] - public void Test_6513() - { - } - [Fact] - public void Test_6514() - { - } - [Fact] - public void Test_6515() - { - } - [Fact] - public void Test_6516() - { - } - [Fact] - public void Test_6517() - { - } - [Fact] - public void Test_6518() - { - } - [Fact] - public void Test_6519() - { - } - [Fact] - public void Test_6520() - { - } - [Fact] - public void Test_6521() - { - } - [Fact] - public void Test_6522() - { - } - [Fact] - public void Test_6523() - { - } - [Fact] - public void Test_6524() - { - } - [Fact] - public void Test_6525() - { - } - [Fact] - public void Test_6526() - { - } - [Fact] - public void Test_6527() - { - } - [Fact] - public void Test_6528() - { - } - [Fact] - public void Test_6529() - { - } - [Fact] - public void Test_6530() - { - } - [Fact] - public void Test_6531() - { - } - [Fact] - public void Test_6532() - { - } - [Fact] - public void Test_6533() - { - } - [Fact] - public void Test_6534() - { - } - [Fact] - public void Test_6535() - { - } - [Fact] - public void Test_6536() - { - } - [Fact] - public void Test_6537() - { - } - [Fact] - public void Test_6538() - { - } - [Fact] - public void Test_6539() - { - } - [Fact] - public void Test_6540() - { - } - [Fact] - public void Test_6541() - { - } - [Fact] - public void Test_6542() - { - } - [Fact] - public void Test_6543() - { - } - [Fact] - public void Test_6544() - { - } - [Fact] - public void Test_6545() - { - } - [Fact] - public void Test_6546() - { - } - [Fact] - public void Test_6547() - { - } - [Fact] - public void Test_6548() - { - } - [Fact] - public void Test_6549() - { - } - [Fact] - public void Test_6550() - { - } - [Fact] - public void Test_6551() - { - } - [Fact] - public void Test_6552() - { - } - [Fact] - public void Test_6553() - { - } - [Fact] - public void Test_6554() - { - } - [Fact] - public void Test_6555() - { - } - [Fact] - public void Test_6556() - { - } - [Fact] - public void Test_6557() - { - } - [Fact] - public void Test_6558() - { - } - [Fact] - public void Test_6559() - { - } - [Fact] - public void Test_6560() - { - } - [Fact] - public void Test_6561() - { - } - [Fact] - public void Test_6562() - { - } - [Fact] - public void Test_6563() - { - } - [Fact] - public void Test_6564() - { - } - [Fact] - public void Test_6565() - { - } - [Fact] - public void Test_6566() - { - } - [Fact] - public void Test_6567() - { - } - [Fact] - public void Test_6568() - { - } - [Fact] - public void Test_6569() - { - } - [Fact] - public void Test_6570() - { - } - [Fact] - public void Test_6571() - { - } - [Fact] - public void Test_6572() - { - } - [Fact] - public void Test_6573() - { - } - [Fact] - public void Test_6574() - { - } - [Fact] - public void Test_6575() - { - } - [Fact] - public void Test_6576() - { - } - [Fact] - public void Test_6577() - { - } - [Fact] - public void Test_6578() - { - } - [Fact] - public void Test_6579() - { - } - [Fact] - public void Test_6580() - { - } - [Fact] - public void Test_6581() - { - } - [Fact] - public void Test_6582() - { - } - [Fact] - public void Test_6583() - { - } - [Fact] - public void Test_6584() - { - } - [Fact] - public void Test_6585() - { - } - [Fact] - public void Test_6586() - { - } - [Fact] - public void Test_6587() - { - } - [Fact] - public void Test_6588() - { - } - [Fact] - public void Test_6589() - { - } - [Fact] - public void Test_6590() - { - } - [Fact] - public void Test_6591() - { - } - [Fact] - public void Test_6592() - { - } - [Fact] - public void Test_6593() - { - } - [Fact] - public void Test_6594() - { - } - [Fact] - public void Test_6595() - { - } - [Fact] - public void Test_6596() - { - } - [Fact] - public void Test_6597() - { - } - [Fact] - public void Test_6598() - { - } - [Fact] - public void Test_6599() - { - } - [Fact] - public void Test_6600() - { - } - [Fact] - public void Test_6601() - { - } - [Fact] - public void Test_6602() - { - } - [Fact] - public void Test_6603() - { - } - [Fact] - public void Test_6604() - { - } - [Fact] - public void Test_6605() - { - } - [Fact] - public void Test_6606() - { - } - [Fact] - public void Test_6607() - { - } - [Fact] - public void Test_6608() - { - } - [Fact] - public void Test_6609() - { - } - [Fact] - public void Test_6610() - { - } - [Fact] - public void Test_6611() - { - } - [Fact] - public void Test_6612() - { - } - [Fact] - public void Test_6613() - { - } - [Fact] - public void Test_6614() - { - } - [Fact] - public void Test_6615() - { - } - [Fact] - public void Test_6616() - { - } - [Fact] - public void Test_6617() - { - } - [Fact] - public void Test_6618() - { - } - [Fact] - public void Test_6619() - { - } - [Fact] - public void Test_6620() - { - } - [Fact] - public void Test_6621() - { - } - [Fact] - public void Test_6622() - { - } - [Fact] - public void Test_6623() - { - } - [Fact] - public void Test_6624() - { - } - [Fact] - public void Test_6625() - { - } - [Fact] - public void Test_6626() - { - } - [Fact] - public void Test_6627() - { - } - [Fact] - public void Test_6628() - { - } - [Fact] - public void Test_6629() - { - } - [Fact] - public void Test_6630() - { - } - [Fact] - public void Test_6631() - { - } - [Fact] - public void Test_6632() - { - } - [Fact] - public void Test_6633() - { - } - [Fact] - public void Test_6634() - { - } - [Fact] - public void Test_6635() - { - } - [Fact] - public void Test_6636() - { - } - [Fact] - public void Test_6637() - { - } - [Fact] - public void Test_6638() - { - } - [Fact] - public void Test_6639() - { - } - [Fact] - public void Test_6640() - { - } - [Fact] - public void Test_6641() - { - } - [Fact] - public void Test_6642() - { - } - [Fact] - public void Test_6643() - { - } - [Fact] - public void Test_6644() - { - } - [Fact] - public void Test_6645() - { - } - [Fact] - public void Test_6646() - { - } - [Fact] - public void Test_6647() - { - } - [Fact] - public void Test_6648() - { - } - [Fact] - public void Test_6649() - { - } - [Fact] - public void Test_6650() - { - } - [Fact] - public void Test_6651() - { - } - [Fact] - public void Test_6652() - { - } - [Fact] - public void Test_6653() - { - } - [Fact] - public void Test_6654() - { - } - [Fact] - public void Test_6655() - { - } - [Fact] - public void Test_6656() - { - } - [Fact] - public void Test_6657() - { - } - [Fact] - public void Test_6658() - { - } - [Fact] - public void Test_6659() - { - } - [Fact] - public void Test_6660() - { - } - [Fact] - public void Test_6661() - { - } - [Fact] - public void Test_6662() - { - } - [Fact] - public void Test_6663() - { - } - [Fact] - public void Test_6664() - { - } - [Fact] - public void Test_6665() - { - } - [Fact] - public void Test_6666() - { - } - [Fact] - public void Test_6667() - { - } - [Fact] - public void Test_6668() - { - } - [Fact] - public void Test_6669() - { - } - [Fact] - public void Test_6670() - { - } - [Fact] - public void Test_6671() - { - } - [Fact] - public void Test_6672() - { - } - [Fact] - public void Test_6673() - { - } - [Fact] - public void Test_6674() - { - } - [Fact] - public void Test_6675() - { - } - [Fact] - public void Test_6676() - { - } - [Fact] - public void Test_6677() - { - } - [Fact] - public void Test_6678() - { - } - [Fact] - public void Test_6679() - { - } - [Fact] - public void Test_6680() - { - } - [Fact] - public void Test_6681() - { - } - [Fact] - public void Test_6682() - { - } - [Fact] - public void Test_6683() - { - } - [Fact] - public void Test_6684() - { - } - [Fact] - public void Test_6685() - { - } - [Fact] - public void Test_6686() - { - } - [Fact] - public void Test_6687() - { - } - [Fact] - public void Test_6688() - { - } - [Fact] - public void Test_6689() - { - } - [Fact] - public void Test_6690() - { - } - [Fact] - public void Test_6691() - { - } - [Fact] - public void Test_6692() - { - } - [Fact] - public void Test_6693() - { - } - [Fact] - public void Test_6694() - { - } - [Fact] - public void Test_6695() - { - } - [Fact] - public void Test_6696() - { - } - [Fact] - public void Test_6697() - { - } - [Fact] - public void Test_6698() - { - } - [Fact] - public void Test_6699() - { - } - [Fact] - public void Test_6700() - { - } - [Fact] - public void Test_6701() - { - } - [Fact] - public void Test_6702() - { - } - [Fact] - public void Test_6703() - { - } - [Fact] - public void Test_6704() - { - } - [Fact] - public void Test_6705() - { - } - [Fact] - public void Test_6706() - { - } - [Fact] - public void Test_6707() - { - } - [Fact] - public void Test_6708() - { - } - [Fact] - public void Test_6709() - { - } - [Fact] - public void Test_6710() - { - } - [Fact] - public void Test_6711() - { - } - [Fact] - public void Test_6712() - { - } - [Fact] - public void Test_6713() - { - } - [Fact] - public void Test_6714() - { - } - [Fact] - public void Test_6715() - { - } - [Fact] - public void Test_6716() - { - } - [Fact] - public void Test_6717() - { - } - [Fact] - public void Test_6718() - { - } - [Fact] - public void Test_6719() - { - } - [Fact] - public void Test_6720() - { - } - [Fact] - public void Test_6721() - { - } - [Fact] - public void Test_6722() - { - } - [Fact] - public void Test_6723() - { - } - [Fact] - public void Test_6724() - { - } - [Fact] - public void Test_6725() - { - } - [Fact] - public void Test_6726() - { - } - [Fact] - public void Test_6727() - { - } - [Fact] - public void Test_6728() - { - } - [Fact] - public void Test_6729() - { - } - [Fact] - public void Test_6730() - { - } - [Fact] - public void Test_6731() - { - } - [Fact] - public void Test_6732() - { - } - [Fact] - public void Test_6733() - { - } - [Fact] - public void Test_6734() - { - } - [Fact] - public void Test_6735() - { - } - [Fact] - public void Test_6736() - { - } - [Fact] - public void Test_6737() - { - } - [Fact] - public void Test_6738() - { - } - [Fact] - public void Test_6739() - { - } - [Fact] - public void Test_6740() - { - } - [Fact] - public void Test_6741() - { - } - [Fact] - public void Test_6742() - { - } - [Fact] - public void Test_6743() - { - } - [Fact] - public void Test_6744() - { - } - [Fact] - public void Test_6745() - { - } - [Fact] - public void Test_6746() - { - } - [Fact] - public void Test_6747() - { - } - [Fact] - public void Test_6748() - { - } - [Fact] - public void Test_6749() - { - } - [Fact] - public void Test_6750() - { - } - [Fact] - public void Test_6751() - { - } - [Fact] - public void Test_6752() - { - } - [Fact] - public void Test_6753() - { - } - [Fact] - public void Test_6754() - { - } - [Fact] - public void Test_6755() - { - } - [Fact] - public void Test_6756() - { - } - [Fact] - public void Test_6757() - { - } - [Fact] - public void Test_6758() - { - } - [Fact] - public void Test_6759() - { - } - [Fact] - public void Test_6760() - { - } - [Fact] - public void Test_6761() - { - } - [Fact] - public void Test_6762() - { - } - [Fact] - public void Test_6763() - { - } - [Fact] - public void Test_6764() - { - } - [Fact] - public void Test_6765() - { - } - [Fact] - public void Test_6766() - { - } - [Fact] - public void Test_6767() - { - } - [Fact] - public void Test_6768() - { - } - [Fact] - public void Test_6769() - { - } - [Fact] - public void Test_6770() - { - } - [Fact] - public void Test_6771() - { - } - [Fact] - public void Test_6772() - { - } - [Fact] - public void Test_6773() - { - } - [Fact] - public void Test_6774() - { - } - [Fact] - public void Test_6775() - { - } - [Fact] - public void Test_6776() - { - } - [Fact] - public void Test_6777() - { - } - [Fact] - public void Test_6778() - { - } - [Fact] - public void Test_6779() - { - } - [Fact] - public void Test_6780() - { - } - [Fact] - public void Test_6781() - { - } - [Fact] - public void Test_6782() - { - } - [Fact] - public void Test_6783() - { - } - [Fact] - public void Test_6784() - { - } - [Fact] - public void Test_6785() - { - } - [Fact] - public void Test_6786() - { - } - [Fact] - public void Test_6787() - { - } - [Fact] - public void Test_6788() - { - } - [Fact] - public void Test_6789() - { - } - [Fact] - public void Test_6790() - { - } - [Fact] - public void Test_6791() - { - } - [Fact] - public void Test_6792() - { - } - [Fact] - public void Test_6793() - { - } - [Fact] - public void Test_6794() - { - } - [Fact] - public void Test_6795() - { - } - [Fact] - public void Test_6796() - { - } - [Fact] - public void Test_6797() - { - } - [Fact] - public void Test_6798() - { - } - [Fact] - public void Test_6799() - { - } - [Fact] - public void Test_6800() - { - } - [Fact] - public void Test_6801() - { - } - [Fact] - public void Test_6802() - { - } - [Fact] - public void Test_6803() - { - } - [Fact] - public void Test_6804() - { - } - [Fact] - public void Test_6805() - { - } - [Fact] - public void Test_6806() - { - } - [Fact] - public void Test_6807() - { - } - [Fact] - public void Test_6808() - { - } - [Fact] - public void Test_6809() - { - } - [Fact] - public void Test_6810() - { - } - [Fact] - public void Test_6811() - { - } - [Fact] - public void Test_6812() - { - } - [Fact] - public void Test_6813() - { - } - [Fact] - public void Test_6814() - { - } - [Fact] - public void Test_6815() - { - } - [Fact] - public void Test_6816() - { - } - [Fact] - public void Test_6817() - { - } - [Fact] - public void Test_6818() - { - } - [Fact] - public void Test_6819() - { - } - [Fact] - public void Test_6820() - { - } - [Fact] - public void Test_6821() - { - } - [Fact] - public void Test_6822() - { - } - [Fact] - public void Test_6823() - { - } - [Fact] - public void Test_6824() - { - } - [Fact] - public void Test_6825() - { - } - [Fact] - public void Test_6826() - { - } - [Fact] - public void Test_6827() - { - } - [Fact] - public void Test_6828() - { - } - [Fact] - public void Test_6829() - { - } - [Fact] - public void Test_6830() - { - } - [Fact] - public void Test_6831() - { - } - [Fact] - public void Test_6832() - { - } - [Fact] - public void Test_6833() - { - } - [Fact] - public void Test_6834() - { - } - [Fact] - public void Test_6835() - { - } - [Fact] - public void Test_6836() - { - } - [Fact] - public void Test_6837() - { - } - [Fact] - public void Test_6838() - { - } - [Fact] - public void Test_6839() - { - } - [Fact] - public void Test_6840() - { - } - [Fact] - public void Test_6841() - { - } - [Fact] - public void Test_6842() - { - } - [Fact] - public void Test_6843() - { - } - [Fact] - public void Test_6844() - { - } - [Fact] - public void Test_6845() - { - } - [Fact] - public void Test_6846() - { - } - [Fact] - public void Test_6847() - { - } - [Fact] - public void Test_6848() - { - } - [Fact] - public void Test_6849() - { - } - [Fact] - public void Test_6850() - { - } - [Fact] - public void Test_6851() - { - } - [Fact] - public void Test_6852() - { - } - [Fact] - public void Test_6853() - { - } - [Fact] - public void Test_6854() - { - } - [Fact] - public void Test_6855() - { - } - [Fact] - public void Test_6856() - { - } - [Fact] - public void Test_6857() - { - } - [Fact] - public void Test_6858() - { - } - [Fact] - public void Test_6859() - { - } - [Fact] - public void Test_6860() - { - } - [Fact] - public void Test_6861() - { - } - [Fact] - public void Test_6862() - { - } - [Fact] - public void Test_6863() - { - } - [Fact] - public void Test_6864() - { - } - [Fact] - public void Test_6865() - { - } - [Fact] - public void Test_6866() - { - } - [Fact] - public void Test_6867() - { - } - [Fact] - public void Test_6868() - { - } - [Fact] - public void Test_6869() - { - } - [Fact] - public void Test_6870() - { - } - [Fact] - public void Test_6871() - { - } - [Fact] - public void Test_6872() - { - } - [Fact] - public void Test_6873() - { - } - [Fact] - public void Test_6874() - { - } - [Fact] - public void Test_6875() - { - } - [Fact] - public void Test_6876() - { - } - [Fact] - public void Test_6877() - { - } - [Fact] - public void Test_6878() - { - } - [Fact] - public void Test_6879() - { - } - [Fact] - public void Test_6880() - { - } - [Fact] - public void Test_6881() - { - } - [Fact] - public void Test_6882() - { - } - [Fact] - public void Test_6883() - { - } - [Fact] - public void Test_6884() - { - } - [Fact] - public void Test_6885() - { - } - [Fact] - public void Test_6886() - { - } - [Fact] - public void Test_6887() - { - } - [Fact] - public void Test_6888() - { - } - [Fact] - public void Test_6889() - { - } - [Fact] - public void Test_6890() - { - } - [Fact] - public void Test_6891() - { - } - [Fact] - public void Test_6892() - { - } - [Fact] - public void Test_6893() - { - } - [Fact] - public void Test_6894() - { - } - [Fact] - public void Test_6895() - { - } - [Fact] - public void Test_6896() - { - } - [Fact] - public void Test_6897() - { - } - [Fact] - public void Test_6898() - { - } - [Fact] - public void Test_6899() - { - } - [Fact] - public void Test_6900() - { - } - [Fact] - public void Test_6901() - { - } - [Fact] - public void Test_6902() - { - } - [Fact] - public void Test_6903() - { - } - [Fact] - public void Test_6904() - { - } - [Fact] - public void Test_6905() - { - } - [Fact] - public void Test_6906() - { - } - [Fact] - public void Test_6907() - { - } - [Fact] - public void Test_6908() - { - } - [Fact] - public void Test_6909() - { - } - [Fact] - public void Test_6910() - { - } - [Fact] - public void Test_6911() - { - } - [Fact] - public void Test_6912() - { - } - [Fact] - public void Test_6913() - { - } - [Fact] - public void Test_6914() - { - } - [Fact] - public void Test_6915() - { - } - [Fact] - public void Test_6916() - { - } - [Fact] - public void Test_6917() - { - } - [Fact] - public void Test_6918() - { - } - [Fact] - public void Test_6919() - { - } - [Fact] - public void Test_6920() - { - } - [Fact] - public void Test_6921() - { - } - [Fact] - public void Test_6922() - { - } - [Fact] - public void Test_6923() - { - } - [Fact] - public void Test_6924() - { - } - [Fact] - public void Test_6925() - { - } - [Fact] - public void Test_6926() - { - } - [Fact] - public void Test_6927() - { - } - [Fact] - public void Test_6928() - { - } - [Fact] - public void Test_6929() - { - } - [Fact] - public void Test_6930() - { - } - [Fact] - public void Test_6931() - { - } - [Fact] - public void Test_6932() - { - } - [Fact] - public void Test_6933() - { - } - [Fact] - public void Test_6934() - { - } - [Fact] - public void Test_6935() - { - } - [Fact] - public void Test_6936() - { - } - [Fact] - public void Test_6937() - { - } - [Fact] - public void Test_6938() - { - } - [Fact] - public void Test_6939() - { - } - [Fact] - public void Test_6940() - { - } - [Fact] - public void Test_6941() - { - } - [Fact] - public void Test_6942() - { - } - [Fact] - public void Test_6943() - { - } - [Fact] - public void Test_6944() - { - } - [Fact] - public void Test_6945() - { - } - [Fact] - public void Test_6946() - { - } - [Fact] - public void Test_6947() - { - } - [Fact] - public void Test_6948() - { - } - [Fact] - public void Test_6949() - { - } - [Fact] - public void Test_6950() - { - } - [Fact] - public void Test_6951() - { - } - [Fact] - public void Test_6952() - { - } - [Fact] - public void Test_6953() - { - } - [Fact] - public void Test_6954() - { - } - [Fact] - public void Test_6955() - { - } - [Fact] - public void Test_6956() - { - } - [Fact] - public void Test_6957() - { - } - [Fact] - public void Test_6958() - { - } - [Fact] - public void Test_6959() - { - } - [Fact] - public void Test_6960() - { - } - [Fact] - public void Test_6961() - { - } - [Fact] - public void Test_6962() - { - } - [Fact] - public void Test_6963() - { - } - [Fact] - public void Test_6964() - { - } - [Fact] - public void Test_6965() - { - } - [Fact] - public void Test_6966() - { - } - [Fact] - public void Test_6967() - { - } - [Fact] - public void Test_6968() - { - } - [Fact] - public void Test_6969() - { - } - [Fact] - public void Test_6970() - { - } - [Fact] - public void Test_6971() - { - } - [Fact] - public void Test_6972() - { - } - [Fact] - public void Test_6973() - { - } - [Fact] - public void Test_6974() - { - } - [Fact] - public void Test_6975() - { - } - [Fact] - public void Test_6976() - { - } - [Fact] - public void Test_6977() - { - } - [Fact] - public void Test_6978() - { - } - [Fact] - public void Test_6979() - { - } - [Fact] - public void Test_6980() - { - } - [Fact] - public void Test_6981() - { - } - [Fact] - public void Test_6982() - { - } - [Fact] - public void Test_6983() - { - } - [Fact] - public void Test_6984() - { - } - [Fact] - public void Test_6985() - { - } - [Fact] - public void Test_6986() - { - } - [Fact] - public void Test_6987() - { - } - [Fact] - public void Test_6988() - { - } - [Fact] - public void Test_6989() - { - } - [Fact] - public void Test_6990() - { - } - [Fact] - public void Test_6991() - { - } - [Fact] - public void Test_6992() - { - } - [Fact] - public void Test_6993() - { - } - [Fact] - public void Test_6994() - { - } - [Fact] - public void Test_6995() - { - } - [Fact] - public void Test_6996() - { - } - [Fact] - public void Test_6997() - { - } - [Fact] - public void Test_6998() - { - } - [Fact] - public void Test_6999() - { - } - [Fact] - public void Test_7000() - { - } - [Fact] - public void Test_7001() - { - } - [Fact] - public void Test_7002() - { - } - [Fact] - public void Test_7003() - { - } - [Fact] - public void Test_7004() - { - } - [Fact] - public void Test_7005() - { - } - [Fact] - public void Test_7006() - { - } - [Fact] - public void Test_7007() - { - } - [Fact] - public void Test_7008() - { - } - [Fact] - public void Test_7009() - { - } - [Fact] - public void Test_7010() - { - } - [Fact] - public void Test_7011() - { - } - [Fact] - public void Test_7012() - { - } - [Fact] - public void Test_7013() - { - } - [Fact] - public void Test_7014() - { - } - [Fact] - public void Test_7015() - { - } - [Fact] - public void Test_7016() - { - } - [Fact] - public void Test_7017() - { - } - [Fact] - public void Test_7018() - { - } - [Fact] - public void Test_7019() - { - } - [Fact] - public void Test_7020() - { - } - [Fact] - public void Test_7021() - { - } - [Fact] - public void Test_7022() - { - } - [Fact] - public void Test_7023() - { - } - [Fact] - public void Test_7024() - { - } - [Fact] - public void Test_7025() - { - } - [Fact] - public void Test_7026() - { - } - [Fact] - public void Test_7027() - { - } - [Fact] - public void Test_7028() - { - } - [Fact] - public void Test_7029() - { - } - [Fact] - public void Test_7030() - { - } - [Fact] - public void Test_7031() - { - } - [Fact] - public void Test_7032() - { - } - [Fact] - public void Test_7033() - { - } - [Fact] - public void Test_7034() - { - } - [Fact] - public void Test_7035() - { - } - [Fact] - public void Test_7036() - { - } - [Fact] - public void Test_7037() - { - } - [Fact] - public void Test_7038() - { - } - [Fact] - public void Test_7039() - { - } - [Fact] - public void Test_7040() - { - } - [Fact] - public void Test_7041() - { - } - [Fact] - public void Test_7042() - { - } - [Fact] - public void Test_7043() - { - } - [Fact] - public void Test_7044() - { - } - [Fact] - public void Test_7045() - { - } - [Fact] - public void Test_7046() - { - } - [Fact] - public void Test_7047() - { - } - [Fact] - public void Test_7048() - { - } - [Fact] - public void Test_7049() - { - } - [Fact] - public void Test_7050() - { - } - [Fact] - public void Test_7051() - { - } - [Fact] - public void Test_7052() - { - } - [Fact] - public void Test_7053() - { - } - [Fact] - public void Test_7054() - { - } - [Fact] - public void Test_7055() - { - } - [Fact] - public void Test_7056() - { - } - [Fact] - public void Test_7057() - { - } - [Fact] - public void Test_7058() - { - } - [Fact] - public void Test_7059() - { - } - [Fact] - public void Test_7060() - { - } - [Fact] - public void Test_7061() - { - } - [Fact] - public void Test_7062() - { - } - [Fact] - public void Test_7063() - { - } - [Fact] - public void Test_7064() - { - } - [Fact] - public void Test_7065() - { - } - [Fact] - public void Test_7066() - { - } - [Fact] - public void Test_7067() - { - } - [Fact] - public void Test_7068() - { - } - [Fact] - public void Test_7069() - { - } - [Fact] - public void Test_7070() - { - } - [Fact] - public void Test_7071() - { - } - [Fact] - public void Test_7072() - { - } - [Fact] - public void Test_7073() - { - } - [Fact] - public void Test_7074() - { - } - [Fact] - public void Test_7075() - { - } - [Fact] - public void Test_7076() - { - } - [Fact] - public void Test_7077() - { - } - [Fact] - public void Test_7078() - { - } - [Fact] - public void Test_7079() - { - } - [Fact] - public void Test_7080() - { - } - [Fact] - public void Test_7081() - { - } - [Fact] - public void Test_7082() - { - } - [Fact] - public void Test_7083() - { - } - [Fact] - public void Test_7084() - { - } - [Fact] - public void Test_7085() - { - } - [Fact] - public void Test_7086() - { - } - [Fact] - public void Test_7087() - { - } - [Fact] - public void Test_7088() - { - } - [Fact] - public void Test_7089() - { - } - [Fact] - public void Test_7090() - { - } - [Fact] - public void Test_7091() - { - } - [Fact] - public void Test_7092() - { - } - [Fact] - public void Test_7093() - { - } - [Fact] - public void Test_7094() - { - } - [Fact] - public void Test_7095() - { - } - [Fact] - public void Test_7096() - { - } - [Fact] - public void Test_7097() - { - } - [Fact] - public void Test_7098() - { - } - [Fact] - public void Test_7099() - { - } - [Fact] - public void Test_7100() - { - } - [Fact] - public void Test_7101() - { - } - [Fact] - public void Test_7102() - { - } - [Fact] - public void Test_7103() - { - } - [Fact] - public void Test_7104() - { - } - [Fact] - public void Test_7105() - { - } - [Fact] - public void Test_7106() - { - } - [Fact] - public void Test_7107() - { - } - [Fact] - public void Test_7108() - { - } - [Fact] - public void Test_7109() - { - } - [Fact] - public void Test_7110() - { - } - [Fact] - public void Test_7111() - { - } - [Fact] - public void Test_7112() - { - } - [Fact] - public void Test_7113() - { - } - [Fact] - public void Test_7114() - { - } - [Fact] - public void Test_7115() - { - } - [Fact] - public void Test_7116() - { - } - [Fact] - public void Test_7117() - { - } - [Fact] - public void Test_7118() - { - } - [Fact] - public void Test_7119() - { - } - [Fact] - public void Test_7120() - { - } - [Fact] - public void Test_7121() - { - } - [Fact] - public void Test_7122() - { - } - [Fact] - public void Test_7123() - { - } - [Fact] - public void Test_7124() - { - } - [Fact] - public void Test_7125() - { - } - [Fact] - public void Test_7126() - { - } - [Fact] - public void Test_7127() - { - } - [Fact] - public void Test_7128() - { - } - [Fact] - public void Test_7129() - { - } - [Fact] - public void Test_7130() - { - } - [Fact] - public void Test_7131() - { - } - [Fact] - public void Test_7132() - { - } - [Fact] - public void Test_7133() - { - } - [Fact] - public void Test_7134() - { - } - [Fact] - public void Test_7135() - { - } - [Fact] - public void Test_7136() - { - } - [Fact] - public void Test_7137() - { - } - [Fact] - public void Test_7138() - { - } - [Fact] - public void Test_7139() - { - } - [Fact] - public void Test_7140() - { - } - [Fact] - public void Test_7141() - { - } - [Fact] - public void Test_7142() - { - } - [Fact] - public void Test_7143() - { - } - [Fact] - public void Test_7144() - { - } - [Fact] - public void Test_7145() - { - } - [Fact] - public void Test_7146() - { - } - [Fact] - public void Test_7147() - { - } - [Fact] - public void Test_7148() - { - } - [Fact] - public void Test_7149() - { - } - [Fact] - public void Test_7150() - { - } - [Fact] - public void Test_7151() - { - } - [Fact] - public void Test_7152() - { - } - [Fact] - public void Test_7153() - { - } - [Fact] - public void Test_7154() - { - } - [Fact] - public void Test_7155() - { - } - [Fact] - public void Test_7156() - { - } - [Fact] - public void Test_7157() - { - } - [Fact] - public void Test_7158() - { - } - [Fact] - public void Test_7159() - { - } - [Fact] - public void Test_7160() - { - } - [Fact] - public void Test_7161() - { - } - [Fact] - public void Test_7162() - { - } - [Fact] - public void Test_7163() - { - } - [Fact] - public void Test_7164() - { - } - [Fact] - public void Test_7165() - { - } - [Fact] - public void Test_7166() - { - } - [Fact] - public void Test_7167() - { - } - [Fact] - public void Test_7168() - { - } - [Fact] - public void Test_7169() - { - } - [Fact] - public void Test_7170() - { - } - [Fact] - public void Test_7171() - { - } - [Fact] - public void Test_7172() - { - } - [Fact] - public void Test_7173() - { - } - [Fact] - public void Test_7174() - { - } - [Fact] - public void Test_7175() - { - } - [Fact] - public void Test_7176() - { - } - [Fact] - public void Test_7177() - { - } - [Fact] - public void Test_7178() - { - } - [Fact] - public void Test_7179() - { - } - [Fact] - public void Test_7180() - { - } - [Fact] - public void Test_7181() - { - } - [Fact] - public void Test_7182() - { - } - [Fact] - public void Test_7183() - { - } - [Fact] - public void Test_7184() - { - } - [Fact] - public void Test_7185() - { - } - [Fact] - public void Test_7186() - { - } - [Fact] - public void Test_7187() - { - } - [Fact] - public void Test_7188() - { - } - [Fact] - public void Test_7189() - { - } - [Fact] - public void Test_7190() - { - } - [Fact] - public void Test_7191() - { - } - [Fact] - public void Test_7192() - { - } - [Fact] - public void Test_7193() - { - } - [Fact] - public void Test_7194() - { - } - [Fact] - public void Test_7195() - { - } - [Fact] - public void Test_7196() - { - } - [Fact] - public void Test_7197() - { - } - [Fact] - public void Test_7198() - { - } - [Fact] - public void Test_7199() - { - } - [Fact] - public void Test_7200() - { - } - [Fact] - public void Test_7201() - { - } - [Fact] - public void Test_7202() - { - } - [Fact] - public void Test_7203() - { - } - [Fact] - public void Test_7204() - { - } - [Fact] - public void Test_7205() - { - } - [Fact] - public void Test_7206() - { - } - [Fact] - public void Test_7207() - { - } - [Fact] - public void Test_7208() - { - } - [Fact] - public void Test_7209() - { - } - [Fact] - public void Test_7210() - { - } - [Fact] - public void Test_7211() - { - } - [Fact] - public void Test_7212() - { - } - [Fact] - public void Test_7213() - { - } - [Fact] - public void Test_7214() - { - } - [Fact] - public void Test_7215() - { - } - [Fact] - public void Test_7216() - { - } - [Fact] - public void Test_7217() - { - } - [Fact] - public void Test_7218() - { - } - [Fact] - public void Test_7219() - { - } - [Fact] - public void Test_7220() - { - } - [Fact] - public void Test_7221() - { - } - [Fact] - public void Test_7222() - { - } - [Fact] - public void Test_7223() - { - } - [Fact] - public void Test_7224() - { - } - [Fact] - public void Test_7225() - { - } - [Fact] - public void Test_7226() - { - } - [Fact] - public void Test_7227() - { - } - [Fact] - public void Test_7228() - { - } - [Fact] - public void Test_7229() - { - } - [Fact] - public void Test_7230() - { - } - [Fact] - public void Test_7231() - { - } - [Fact] - public void Test_7232() - { - } - [Fact] - public void Test_7233() - { - } - [Fact] - public void Test_7234() - { - } - [Fact] - public void Test_7235() - { - } - [Fact] - public void Test_7236() - { - } - [Fact] - public void Test_7237() - { - } - [Fact] - public void Test_7238() - { - } - [Fact] - public void Test_7239() - { - } - [Fact] - public void Test_7240() - { - } - [Fact] - public void Test_7241() - { - } - [Fact] - public void Test_7242() - { - } - [Fact] - public void Test_7243() - { - } - [Fact] - public void Test_7244() - { - } - [Fact] - public void Test_7245() - { - } - [Fact] - public void Test_7246() - { - } - [Fact] - public void Test_7247() - { - } - [Fact] - public void Test_7248() - { - } - [Fact] - public void Test_7249() - { - } - [Fact] - public void Test_7250() - { - } - [Fact] - public void Test_7251() - { - } - [Fact] - public void Test_7252() - { - } - [Fact] - public void Test_7253() - { - } - [Fact] - public void Test_7254() - { - } - [Fact] - public void Test_7255() - { - } - [Fact] - public void Test_7256() - { - } - [Fact] - public void Test_7257() - { - } - [Fact] - public void Test_7258() - { - } - [Fact] - public void Test_7259() - { - } - [Fact] - public void Test_7260() - { - } - [Fact] - public void Test_7261() - { - } - [Fact] - public void Test_7262() - { - } - [Fact] - public void Test_7263() - { - } - [Fact] - public void Test_7264() - { - } - [Fact] - public void Test_7265() - { - } - [Fact] - public void Test_7266() - { - } - [Fact] - public void Test_7267() - { - } - [Fact] - public void Test_7268() - { - } - [Fact] - public void Test_7269() - { - } - [Fact] - public void Test_7270() - { - } - [Fact] - public void Test_7271() - { - } - [Fact] - public void Test_7272() - { - } - [Fact] - public void Test_7273() - { - } - [Fact] - public void Test_7274() - { - } - [Fact] - public void Test_7275() - { - } - [Fact] - public void Test_7276() - { - } - [Fact] - public void Test_7277() - { - } - [Fact] - public void Test_7278() - { - } - [Fact] - public void Test_7279() - { - } - [Fact] - public void Test_7280() - { - } - [Fact] - public void Test_7281() - { - } - [Fact] - public void Test_7282() - { - } - [Fact] - public void Test_7283() - { - } - [Fact] - public void Test_7284() - { - } - [Fact] - public void Test_7285() - { - } - [Fact] - public void Test_7286() - { - } - [Fact] - public void Test_7287() - { - } - [Fact] - public void Test_7288() - { - } - [Fact] - public void Test_7289() - { - } - [Fact] - public void Test_7290() - { - } - [Fact] - public void Test_7291() - { - } - [Fact] - public void Test_7292() - { - } - [Fact] - public void Test_7293() - { - } - [Fact] - public void Test_7294() - { - } - [Fact] - public void Test_7295() - { - } - [Fact] - public void Test_7296() - { - } - [Fact] - public void Test_7297() - { - } - [Fact] - public void Test_7298() - { - } - [Fact] - public void Test_7299() - { - } - [Fact] - public void Test_7300() - { - } - [Fact] - public void Test_7301() - { - } - [Fact] - public void Test_7302() - { - } - [Fact] - public void Test_7303() - { - } - [Fact] - public void Test_7304() - { - } - [Fact] - public void Test_7305() - { - } - [Fact] - public void Test_7306() - { - } - [Fact] - public void Test_7307() - { - } - [Fact] - public void Test_7308() - { - } - [Fact] - public void Test_7309() - { - } - [Fact] - public void Test_7310() - { - } - [Fact] - public void Test_7311() - { - } - [Fact] - public void Test_7312() - { - } - [Fact] - public void Test_7313() - { - } - [Fact] - public void Test_7314() - { - } - [Fact] - public void Test_7315() - { - } - [Fact] - public void Test_7316() - { - } - [Fact] - public void Test_7317() - { - } - [Fact] - public void Test_7318() - { - } - [Fact] - public void Test_7319() - { - } - [Fact] - public void Test_7320() - { - } - [Fact] - public void Test_7321() - { - } - [Fact] - public void Test_7322() - { - } - [Fact] - public void Test_7323() - { - } - [Fact] - public void Test_7324() - { - } - [Fact] - public void Test_7325() - { - } - [Fact] - public void Test_7326() - { - } - [Fact] - public void Test_7327() - { - } - [Fact] - public void Test_7328() - { - } - [Fact] - public void Test_7329() - { - } - [Fact] - public void Test_7330() - { - } - [Fact] - public void Test_7331() - { - } - [Fact] - public void Test_7332() - { - } - [Fact] - public void Test_7333() - { - } - [Fact] - public void Test_7334() - { - } - [Fact] - public void Test_7335() - { - } - [Fact] - public void Test_7336() - { - } - [Fact] - public void Test_7337() - { - } - [Fact] - public void Test_7338() - { - } - [Fact] - public void Test_7339() - { - } - [Fact] - public void Test_7340() - { - } - [Fact] - public void Test_7341() - { - } - [Fact] - public void Test_7342() - { - } - [Fact] - public void Test_7343() - { - } - [Fact] - public void Test_7344() - { - } - [Fact] - public void Test_7345() - { - } - [Fact] - public void Test_7346() - { - } - [Fact] - public void Test_7347() - { - } - [Fact] - public void Test_7348() - { - } - [Fact] - public void Test_7349() - { - } - [Fact] - public void Test_7350() - { - } - [Fact] - public void Test_7351() - { - } - [Fact] - public void Test_7352() - { - } - [Fact] - public void Test_7353() - { - } - [Fact] - public void Test_7354() - { - } - [Fact] - public void Test_7355() - { - } - [Fact] - public void Test_7356() - { - } - [Fact] - public void Test_7357() - { - } - [Fact] - public void Test_7358() - { - } - [Fact] - public void Test_7359() - { - } - [Fact] - public void Test_7360() - { - } - [Fact] - public void Test_7361() - { - } - [Fact] - public void Test_7362() - { - } - [Fact] - public void Test_7363() - { - } - [Fact] - public void Test_7364() - { - } - [Fact] - public void Test_7365() - { - } - [Fact] - public void Test_7366() - { - } - [Fact] - public void Test_7367() - { - } - [Fact] - public void Test_7368() - { - } - [Fact] - public void Test_7369() - { - } - [Fact] - public void Test_7370() - { - } - [Fact] - public void Test_7371() - { - } - [Fact] - public void Test_7372() - { - } - [Fact] - public void Test_7373() - { - } - [Fact] - public void Test_7374() - { - } - [Fact] - public void Test_7375() - { - } - [Fact] - public void Test_7376() - { - } - [Fact] - public void Test_7377() - { - } - [Fact] - public void Test_7378() - { - } - [Fact] - public void Test_7379() - { - } - [Fact] - public void Test_7380() - { - } - [Fact] - public void Test_7381() - { - } - [Fact] - public void Test_7382() - { - } - [Fact] - public void Test_7383() - { - } - [Fact] - public void Test_7384() - { - } - [Fact] - public void Test_7385() - { - } - [Fact] - public void Test_7386() - { - } - [Fact] - public void Test_7387() - { - } - [Fact] - public void Test_7388() - { - } - [Fact] - public void Test_7389() - { - } - [Fact] - public void Test_7390() - { - } - [Fact] - public void Test_7391() - { - } - [Fact] - public void Test_7392() - { - } - [Fact] - public void Test_7393() - { - } - [Fact] - public void Test_7394() - { - } - [Fact] - public void Test_7395() - { - } - [Fact] - public void Test_7396() - { - } - [Fact] - public void Test_7397() - { - } - [Fact] - public void Test_7398() - { - } - [Fact] - public void Test_7399() - { - } - [Fact] - public void Test_7400() - { - } - [Fact] - public void Test_7401() - { - } - [Fact] - public void Test_7402() - { - } - [Fact] - public void Test_7403() - { - } - [Fact] - public void Test_7404() - { - } - [Fact] - public void Test_7405() - { - } - [Fact] - public void Test_7406() - { - } - [Fact] - public void Test_7407() - { - } - [Fact] - public void Test_7408() - { - } - [Fact] - public void Test_7409() - { - } - [Fact] - public void Test_7410() - { - } - [Fact] - public void Test_7411() - { - } - [Fact] - public void Test_7412() - { - } - [Fact] - public void Test_7413() - { - } - [Fact] - public void Test_7414() - { - } - [Fact] - public void Test_7415() - { - } - [Fact] - public void Test_7416() - { - } - [Fact] - public void Test_7417() - { - } - [Fact] - public void Test_7418() - { - } - [Fact] - public void Test_7419() - { - } - [Fact] - public void Test_7420() - { - } - [Fact] - public void Test_7421() - { - } - [Fact] - public void Test_7422() - { - } - [Fact] - public void Test_7423() - { - } - [Fact] - public void Test_7424() - { - } - [Fact] - public void Test_7425() - { - } - [Fact] - public void Test_7426() - { - } - [Fact] - public void Test_7427() - { - } - [Fact] - public void Test_7428() - { - } - [Fact] - public void Test_7429() - { - } - [Fact] - public void Test_7430() - { - } - [Fact] - public void Test_7431() - { - } - [Fact] - public void Test_7432() - { - } - [Fact] - public void Test_7433() - { - } - [Fact] - public void Test_7434() - { - } - [Fact] - public void Test_7435() - { - } - [Fact] - public void Test_7436() - { - } - [Fact] - public void Test_7437() - { - } - [Fact] - public void Test_7438() - { - } - [Fact] - public void Test_7439() - { - } - [Fact] - public void Test_7440() - { - } - [Fact] - public void Test_7441() - { - } - [Fact] - public void Test_7442() - { - } - [Fact] - public void Test_7443() - { - } - [Fact] - public void Test_7444() - { - } - [Fact] - public void Test_7445() - { - } - [Fact] - public void Test_7446() - { - } - [Fact] - public void Test_7447() - { - } - [Fact] - public void Test_7448() - { - } - [Fact] - public void Test_7449() - { - } - [Fact] - public void Test_7450() - { - } - [Fact] - public void Test_7451() - { - } - [Fact] - public void Test_7452() - { - } - [Fact] - public void Test_7453() - { - } - [Fact] - public void Test_7454() - { - } - [Fact] - public void Test_7455() - { - } - [Fact] - public void Test_7456() - { - } - [Fact] - public void Test_7457() - { - } - [Fact] - public void Test_7458() - { - } - [Fact] - public void Test_7459() - { - } - [Fact] - public void Test_7460() - { - } - [Fact] - public void Test_7461() - { - } - [Fact] - public void Test_7462() - { - } - [Fact] - public void Test_7463() - { - } - [Fact] - public void Test_7464() - { - } - [Fact] - public void Test_7465() - { - } - [Fact] - public void Test_7466() - { - } - [Fact] - public void Test_7467() - { - } - [Fact] - public void Test_7468() - { - } - [Fact] - public void Test_7469() - { - } - [Fact] - public void Test_7470() - { - } - [Fact] - public void Test_7471() - { - } - [Fact] - public void Test_7472() - { - } - [Fact] - public void Test_7473() - { - } - [Fact] - public void Test_7474() - { - } - [Fact] - public void Test_7475() - { - } - [Fact] - public void Test_7476() - { - } - [Fact] - public void Test_7477() - { - } - [Fact] - public void Test_7478() - { - } - [Fact] - public void Test_7479() - { - } - [Fact] - public void Test_7480() - { - } - [Fact] - public void Test_7481() - { - } - [Fact] - public void Test_7482() - { - } - [Fact] - public void Test_7483() - { - } - [Fact] - public void Test_7484() - { - } - [Fact] - public void Test_7485() - { - } - [Fact] - public void Test_7486() - { - } - [Fact] - public void Test_7487() - { - } - [Fact] - public void Test_7488() - { - } - [Fact] - public void Test_7489() - { - } - [Fact] - public void Test_7490() - { - } - [Fact] - public void Test_7491() - { - } - [Fact] - public void Test_7492() - { - } - [Fact] - public void Test_7493() - { - } - [Fact] - public void Test_7494() - { - } - [Fact] - public void Test_7495() - { - } - [Fact] - public void Test_7496() - { - } - [Fact] - public void Test_7497() - { - } - [Fact] - public void Test_7498() - { - } - [Fact] - public void Test_7499() - { - } - [Fact] - public void Test_7500() - { - } - [Fact] - public void Test_7501() - { - } - [Fact] - public void Test_7502() - { - } - [Fact] - public void Test_7503() - { - } - [Fact] - public void Test_7504() - { - } - [Fact] - public void Test_7505() - { - } - [Fact] - public void Test_7506() - { - } - [Fact] - public void Test_7507() - { - } - [Fact] - public void Test_7508() - { - } - [Fact] - public void Test_7509() - { - } - [Fact] - public void Test_7510() - { - } - [Fact] - public void Test_7511() - { - } - [Fact] - public void Test_7512() - { - } - [Fact] - public void Test_7513() - { - } - [Fact] - public void Test_7514() - { - } - [Fact] - public void Test_7515() - { - } - [Fact] - public void Test_7516() - { - } - [Fact] - public void Test_7517() - { - } - [Fact] - public void Test_7518() - { - } - [Fact] - public void Test_7519() - { - } - [Fact] - public void Test_7520() - { - } - [Fact] - public void Test_7521() - { - } - [Fact] - public void Test_7522() - { - } - [Fact] - public void Test_7523() - { - } - [Fact] - public void Test_7524() - { - } - [Fact] - public void Test_7525() - { - } - [Fact] - public void Test_7526() - { - } - [Fact] - public void Test_7527() - { - } - [Fact] - public void Test_7528() - { - } - [Fact] - public void Test_7529() - { - } - [Fact] - public void Test_7530() - { - } - [Fact] - public void Test_7531() - { - } - [Fact] - public void Test_7532() - { - } - [Fact] - public void Test_7533() - { - } - [Fact] - public void Test_7534() - { - } - [Fact] - public void Test_7535() - { - } - [Fact] - public void Test_7536() - { - } - [Fact] - public void Test_7537() - { - } - [Fact] - public void Test_7538() - { - } - [Fact] - public void Test_7539() - { - } - [Fact] - public void Test_7540() - { - } - [Fact] - public void Test_7541() - { - } - [Fact] - public void Test_7542() - { - } - [Fact] - public void Test_7543() - { - } - [Fact] - public void Test_7544() - { - } - [Fact] - public void Test_7545() - { - } - [Fact] - public void Test_7546() - { - } - [Fact] - public void Test_7547() - { - } - [Fact] - public void Test_7548() - { - } - [Fact] - public void Test_7549() - { - } - [Fact] - public void Test_7550() - { - } - [Fact] - public void Test_7551() - { - } - [Fact] - public void Test_7552() - { - } - [Fact] - public void Test_7553() - { - } - [Fact] - public void Test_7554() - { - } - [Fact] - public void Test_7555() - { - } - [Fact] - public void Test_7556() - { - } - [Fact] - public void Test_7557() - { - } - [Fact] - public void Test_7558() - { - } - [Fact] - public void Test_7559() - { - } - [Fact] - public void Test_7560() - { - } - [Fact] - public void Test_7561() - { - } - [Fact] - public void Test_7562() - { - } - [Fact] - public void Test_7563() - { - } - [Fact] - public void Test_7564() - { - } - [Fact] - public void Test_7565() - { - } - [Fact] - public void Test_7566() - { - } - [Fact] - public void Test_7567() - { - } - [Fact] - public void Test_7568() - { - } - [Fact] - public void Test_7569() - { - } - [Fact] - public void Test_7570() - { - } - [Fact] - public void Test_7571() - { - } - [Fact] - public void Test_7572() - { - } - [Fact] - public void Test_7573() - { - } - [Fact] - public void Test_7574() - { - } - [Fact] - public void Test_7575() - { - } - [Fact] - public void Test_7576() - { - } - [Fact] - public void Test_7577() - { - } - [Fact] - public void Test_7578() - { - } - [Fact] - public void Test_7579() - { - } - [Fact] - public void Test_7580() - { - } - [Fact] - public void Test_7581() - { - } - [Fact] - public void Test_7582() - { - } - [Fact] - public void Test_7583() - { - } - [Fact] - public void Test_7584() - { - } - [Fact] - public void Test_7585() - { - } - [Fact] - public void Test_7586() - { - } - [Fact] - public void Test_7587() - { - } - [Fact] - public void Test_7588() - { - } - [Fact] - public void Test_7589() - { - } - [Fact] - public void Test_7590() - { - } - [Fact] - public void Test_7591() - { - } - [Fact] - public void Test_7592() - { - } - [Fact] - public void Test_7593() - { - } - [Fact] - public void Test_7594() - { - } - [Fact] - public void Test_7595() - { - } - [Fact] - public void Test_7596() - { - } - [Fact] - public void Test_7597() - { - } - [Fact] - public void Test_7598() - { - } - [Fact] - public void Test_7599() - { - } - [Fact] - public void Test_7600() - { - } - [Fact] - public void Test_7601() - { - } - [Fact] - public void Test_7602() - { - } - [Fact] - public void Test_7603() - { - } - [Fact] - public void Test_7604() - { - } - [Fact] - public void Test_7605() - { - } - [Fact] - public void Test_7606() - { - } - [Fact] - public void Test_7607() - { - } - [Fact] - public void Test_7608() - { - } - [Fact] - public void Test_7609() - { - } - [Fact] - public void Test_7610() - { - } - [Fact] - public void Test_7611() - { - } - [Fact] - public void Test_7612() - { - } - [Fact] - public void Test_7613() - { - } - [Fact] - public void Test_7614() - { - } - [Fact] - public void Test_7615() - { - } - [Fact] - public void Test_7616() - { - } - [Fact] - public void Test_7617() - { - } - [Fact] - public void Test_7618() - { - } - [Fact] - public void Test_7619() - { - } - [Fact] - public void Test_7620() - { - } - [Fact] - public void Test_7621() - { - } - [Fact] - public void Test_7622() - { - } - [Fact] - public void Test_7623() - { - } - [Fact] - public void Test_7624() - { - } - [Fact] - public void Test_7625() - { - } - [Fact] - public void Test_7626() - { - } - [Fact] - public void Test_7627() - { - } - [Fact] - public void Test_7628() - { - } - [Fact] - public void Test_7629() - { - } - [Fact] - public void Test_7630() - { - } - [Fact] - public void Test_7631() - { - } - [Fact] - public void Test_7632() - { - } - [Fact] - public void Test_7633() - { - } - [Fact] - public void Test_7634() - { - } - [Fact] - public void Test_7635() - { - } - [Fact] - public void Test_7636() - { - } - [Fact] - public void Test_7637() - { - } - [Fact] - public void Test_7638() - { - } - [Fact] - public void Test_7639() - { - } - [Fact] - public void Test_7640() - { - } - [Fact] - public void Test_7641() - { - } - [Fact] - public void Test_7642() - { - } - [Fact] - public void Test_7643() - { - } - [Fact] - public void Test_7644() - { - } - [Fact] - public void Test_7645() - { - } - [Fact] - public void Test_7646() - { - } - [Fact] - public void Test_7647() - { - } - [Fact] - public void Test_7648() - { - } - [Fact] - public void Test_7649() - { - } - [Fact] - public void Test_7650() - { - } - [Fact] - public void Test_7651() - { - } - [Fact] - public void Test_7652() - { - } - [Fact] - public void Test_7653() - { - } - [Fact] - public void Test_7654() - { - } - [Fact] - public void Test_7655() - { - } - [Fact] - public void Test_7656() - { - } - [Fact] - public void Test_7657() - { - } - [Fact] - public void Test_7658() - { - } - [Fact] - public void Test_7659() - { - } - [Fact] - public void Test_7660() - { - } - [Fact] - public void Test_7661() - { - } - [Fact] - public void Test_7662() - { - } - [Fact] - public void Test_7663() - { - } - [Fact] - public void Test_7664() - { - } - [Fact] - public void Test_7665() - { - } - [Fact] - public void Test_7666() - { - } - [Fact] - public void Test_7667() - { - } - [Fact] - public void Test_7668() - { - } - [Fact] - public void Test_7669() - { - } - [Fact] - public void Test_7670() - { - } - [Fact] - public void Test_7671() - { - } - [Fact] - public void Test_7672() - { - } - [Fact] - public void Test_7673() - { - } - [Fact] - public void Test_7674() - { - } - [Fact] - public void Test_7675() - { - } - [Fact] - public void Test_7676() - { - } - [Fact] - public void Test_7677() - { - } - [Fact] - public void Test_7678() - { - } - [Fact] - public void Test_7679() - { - } - [Fact] - public void Test_7680() - { - } - [Fact] - public void Test_7681() - { - } - [Fact] - public void Test_7682() - { - } - [Fact] - public void Test_7683() - { - } - [Fact] - public void Test_7684() - { - } - [Fact] - public void Test_7685() - { - } - [Fact] - public void Test_7686() - { - } - [Fact] - public void Test_7687() - { - } - [Fact] - public void Test_7688() - { - } - [Fact] - public void Test_7689() - { - } - [Fact] - public void Test_7690() - { - } - [Fact] - public void Test_7691() - { - } - [Fact] - public void Test_7692() - { - } - [Fact] - public void Test_7693() - { - } - [Fact] - public void Test_7694() - { - } - [Fact] - public void Test_7695() - { - } - [Fact] - public void Test_7696() - { - } - [Fact] - public void Test_7697() - { - } - [Fact] - public void Test_7698() - { - } - [Fact] - public void Test_7699() - { - } - [Fact] - public void Test_7700() - { - } - [Fact] - public void Test_7701() - { - } - [Fact] - public void Test_7702() - { - } - [Fact] - public void Test_7703() - { - } - [Fact] - public void Test_7704() - { - } - [Fact] - public void Test_7705() - { - } - [Fact] - public void Test_7706() - { - } - [Fact] - public void Test_7707() - { - } - [Fact] - public void Test_7708() - { - } - [Fact] - public void Test_7709() - { - } - [Fact] - public void Test_7710() - { - } - [Fact] - public void Test_7711() - { - } - [Fact] - public void Test_7712() - { - } - [Fact] - public void Test_7713() - { - } - [Fact] - public void Test_7714() - { - } - [Fact] - public void Test_7715() - { - } - [Fact] - public void Test_7716() - { - } - [Fact] - public void Test_7717() - { - } - [Fact] - public void Test_7718() - { - } - [Fact] - public void Test_7719() - { - } - [Fact] - public void Test_7720() - { - } - [Fact] - public void Test_7721() - { - } - [Fact] - public void Test_7722() - { - } - [Fact] - public void Test_7723() - { - } - [Fact] - public void Test_7724() - { - } - [Fact] - public void Test_7725() - { - } - [Fact] - public void Test_7726() - { - } - [Fact] - public void Test_7727() - { - } - [Fact] - public void Test_7728() - { - } - [Fact] - public void Test_7729() - { - } - [Fact] - public void Test_7730() - { - } - [Fact] - public void Test_7731() - { - } - [Fact] - public void Test_7732() - { - } - [Fact] - public void Test_7733() - { - } - [Fact] - public void Test_7734() - { - } - [Fact] - public void Test_7735() - { - } - [Fact] - public void Test_7736() - { - } - [Fact] - public void Test_7737() - { - } - [Fact] - public void Test_7738() - { - } - [Fact] - public void Test_7739() - { - } - [Fact] - public void Test_7740() - { - } - [Fact] - public void Test_7741() - { - } - [Fact] - public void Test_7742() - { - } - [Fact] - public void Test_7743() - { - } - [Fact] - public void Test_7744() - { - } - [Fact] - public void Test_7745() - { - } - [Fact] - public void Test_7746() - { - } - [Fact] - public void Test_7747() - { - } - [Fact] - public void Test_7748() - { - } - [Fact] - public void Test_7749() - { - } - [Fact] - public void Test_7750() - { - } - [Fact] - public void Test_7751() - { - } - [Fact] - public void Test_7752() - { - } - [Fact] - public void Test_7753() - { - } - [Fact] - public void Test_7754() - { - } - [Fact] - public void Test_7755() - { - } - [Fact] - public void Test_7756() - { - } - [Fact] - public void Test_7757() - { - } - [Fact] - public void Test_7758() - { - } - [Fact] - public void Test_7759() - { - } - [Fact] - public void Test_7760() - { - } - [Fact] - public void Test_7761() - { - } - [Fact] - public void Test_7762() - { - } - [Fact] - public void Test_7763() - { - } - [Fact] - public void Test_7764() - { - } - [Fact] - public void Test_7765() - { - } - [Fact] - public void Test_7766() - { - } - [Fact] - public void Test_7767() - { - } - [Fact] - public void Test_7768() - { - } - [Fact] - public void Test_7769() - { - } - [Fact] - public void Test_7770() - { - } - [Fact] - public void Test_7771() - { - } - [Fact] - public void Test_7772() - { - } - [Fact] - public void Test_7773() - { - } - [Fact] - public void Test_7774() - { - } - [Fact] - public void Test_7775() - { - } - [Fact] - public void Test_7776() - { - } - [Fact] - public void Test_7777() - { - } - [Fact] - public void Test_7778() - { - } - [Fact] - public void Test_7779() - { - } - [Fact] - public void Test_7780() - { - } - [Fact] - public void Test_7781() - { - } - [Fact] - public void Test_7782() - { - } - [Fact] - public void Test_7783() - { - } - [Fact] - public void Test_7784() - { - } - [Fact] - public void Test_7785() - { - } - [Fact] - public void Test_7786() - { - } - [Fact] - public void Test_7787() - { - } - [Fact] - public void Test_7788() - { - } - [Fact] - public void Test_7789() - { - } - [Fact] - public void Test_7790() - { - } - [Fact] - public void Test_7791() - { - } - [Fact] - public void Test_7792() - { - } - [Fact] - public void Test_7793() - { - } - [Fact] - public void Test_7794() - { - } - [Fact] - public void Test_7795() - { - } - [Fact] - public void Test_7796() - { - } - [Fact] - public void Test_7797() - { - } - [Fact] - public void Test_7798() - { - } - [Fact] - public void Test_7799() - { - } - [Fact] - public void Test_7800() - { - } - [Fact] - public void Test_7801() - { - } - [Fact] - public void Test_7802() - { - } - [Fact] - public void Test_7803() - { - } - [Fact] - public void Test_7804() - { - } - [Fact] - public void Test_7805() - { - } - [Fact] - public void Test_7806() - { - } - [Fact] - public void Test_7807() - { - } - [Fact] - public void Test_7808() - { - } - [Fact] - public void Test_7809() - { - } - [Fact] - public void Test_7810() - { - } - [Fact] - public void Test_7811() - { - } - [Fact] - public void Test_7812() - { - } - [Fact] - public void Test_7813() - { - } - [Fact] - public void Test_7814() - { - } - [Fact] - public void Test_7815() - { - } - [Fact] - public void Test_7816() - { - } - [Fact] - public void Test_7817() - { - } - [Fact] - public void Test_7818() - { - } - [Fact] - public void Test_7819() - { - } - [Fact] - public void Test_7820() - { - } - [Fact] - public void Test_7821() - { - } - [Fact] - public void Test_7822() - { - } - [Fact] - public void Test_7823() - { - } - [Fact] - public void Test_7824() - { - } - [Fact] - public void Test_7825() - { - } - [Fact] - public void Test_7826() - { - } - [Fact] - public void Test_7827() - { - } - [Fact] - public void Test_7828() - { - } - [Fact] - public void Test_7829() - { - } - [Fact] - public void Test_7830() - { - } - [Fact] - public void Test_7831() - { - } - [Fact] - public void Test_7832() - { - } - [Fact] - public void Test_7833() - { - } - [Fact] - public void Test_7834() - { - } - [Fact] - public void Test_7835() - { - } - [Fact] - public void Test_7836() - { - } - [Fact] - public void Test_7837() - { - } - [Fact] - public void Test_7838() - { - } - [Fact] - public void Test_7839() - { - } - [Fact] - public void Test_7840() - { - } - [Fact] - public void Test_7841() - { - } - [Fact] - public void Test_7842() - { - } - [Fact] - public void Test_7843() - { - } - [Fact] - public void Test_7844() - { - } - [Fact] - public void Test_7845() - { - } - [Fact] - public void Test_7846() - { - } - [Fact] - public void Test_7847() - { - } - [Fact] - public void Test_7848() - { - } - [Fact] - public void Test_7849() - { - } - [Fact] - public void Test_7850() - { - } - [Fact] - public void Test_7851() - { - } - [Fact] - public void Test_7852() - { - } - [Fact] - public void Test_7853() - { - } - [Fact] - public void Test_7854() - { - } - [Fact] - public void Test_7855() - { - } - [Fact] - public void Test_7856() - { - } - [Fact] - public void Test_7857() - { - } - [Fact] - public void Test_7858() - { - } - [Fact] - public void Test_7859() - { - } - [Fact] - public void Test_7860() - { - } - [Fact] - public void Test_7861() - { - } - [Fact] - public void Test_7862() - { - } - [Fact] - public void Test_7863() - { - } - [Fact] - public void Test_7864() - { - } - [Fact] - public void Test_7865() - { - } - [Fact] - public void Test_7866() - { - } - [Fact] - public void Test_7867() - { - } - [Fact] - public void Test_7868() - { - } - [Fact] - public void Test_7869() - { - } - [Fact] - public void Test_7870() - { - } - [Fact] - public void Test_7871() - { - } - [Fact] - public void Test_7872() - { - } - [Fact] - public void Test_7873() - { - } - [Fact] - public void Test_7874() - { - } - [Fact] - public void Test_7875() - { - } - [Fact] - public void Test_7876() - { - } - [Fact] - public void Test_7877() - { - } - [Fact] - public void Test_7878() - { - } - [Fact] - public void Test_7879() - { - } - [Fact] - public void Test_7880() - { - } - [Fact] - public void Test_7881() - { - } - [Fact] - public void Test_7882() - { - } - [Fact] - public void Test_7883() - { - } - [Fact] - public void Test_7884() - { - } - [Fact] - public void Test_7885() - { - } - [Fact] - public void Test_7886() - { - } - [Fact] - public void Test_7887() - { - } - [Fact] - public void Test_7888() - { - } - [Fact] - public void Test_7889() - { - } - [Fact] - public void Test_7890() - { - } - [Fact] - public void Test_7891() - { - } - [Fact] - public void Test_7892() - { - } - [Fact] - public void Test_7893() - { - } - [Fact] - public void Test_7894() - { - } - [Fact] - public void Test_7895() - { - } - [Fact] - public void Test_7896() - { - } - [Fact] - public void Test_7897() - { - } - [Fact] - public void Test_7898() - { - } - [Fact] - public void Test_7899() - { - } - [Fact] - public void Test_7900() - { - } - [Fact] - public void Test_7901() - { - } - [Fact] - public void Test_7902() - { - } - [Fact] - public void Test_7903() - { - } - [Fact] - public void Test_7904() - { - } - [Fact] - public void Test_7905() - { - } - [Fact] - public void Test_7906() - { - } - [Fact] - public void Test_7907() - { - } - [Fact] - public void Test_7908() - { - } - [Fact] - public void Test_7909() - { - } - [Fact] - public void Test_7910() - { - } - [Fact] - public void Test_7911() - { - } - [Fact] - public void Test_7912() - { - } - [Fact] - public void Test_7913() - { - } - [Fact] - public void Test_7914() - { - } - [Fact] - public void Test_7915() - { - } - [Fact] - public void Test_7916() - { - } - [Fact] - public void Test_7917() - { - } - [Fact] - public void Test_7918() - { - } - [Fact] - public void Test_7919() - { - } - [Fact] - public void Test_7920() - { - } - [Fact] - public void Test_7921() - { - } - [Fact] - public void Test_7922() - { - } - [Fact] - public void Test_7923() - { - } - [Fact] - public void Test_7924() - { - } - [Fact] - public void Test_7925() - { - } - [Fact] - public void Test_7926() - { - } - [Fact] - public void Test_7927() - { - } - [Fact] - public void Test_7928() - { - } - [Fact] - public void Test_7929() - { - } - [Fact] - public void Test_7930() - { - } - [Fact] - public void Test_7931() - { - } - [Fact] - public void Test_7932() - { - } - [Fact] - public void Test_7933() - { - } - [Fact] - public void Test_7934() - { - } - [Fact] - public void Test_7935() - { - } - [Fact] - public void Test_7936() - { - } - [Fact] - public void Test_7937() - { - } - [Fact] - public void Test_7938() - { - } - [Fact] - public void Test_7939() - { - } - [Fact] - public void Test_7940() - { - } - [Fact] - public void Test_7941() - { - } - [Fact] - public void Test_7942() - { - } - [Fact] - public void Test_7943() - { - } - [Fact] - public void Test_7944() - { - } - [Fact] - public void Test_7945() - { - } - [Fact] - public void Test_7946() - { - } - [Fact] - public void Test_7947() - { - } - [Fact] - public void Test_7948() - { - } - [Fact] - public void Test_7949() - { - } - [Fact] - public void Test_7950() - { - } - [Fact] - public void Test_7951() - { - } - [Fact] - public void Test_7952() - { - } - [Fact] - public void Test_7953() - { - } - [Fact] - public void Test_7954() - { - } - [Fact] - public void Test_7955() - { - } - [Fact] - public void Test_7956() - { - } - [Fact] - public void Test_7957() - { - } - [Fact] - public void Test_7958() - { - } - [Fact] - public void Test_7959() - { - } - [Fact] - public void Test_7960() - { - } - [Fact] - public void Test_7961() - { - } - [Fact] - public void Test_7962() - { - } - [Fact] - public void Test_7963() - { - } - [Fact] - public void Test_7964() - { - } - [Fact] - public void Test_7965() - { - } - [Fact] - public void Test_7966() - { - } - [Fact] - public void Test_7967() - { - } - [Fact] - public void Test_7968() - { - } - [Fact] - public void Test_7969() - { - } - [Fact] - public void Test_7970() - { - } - [Fact] - public void Test_7971() - { - } - [Fact] - public void Test_7972() - { - } - [Fact] - public void Test_7973() - { - } - [Fact] - public void Test_7974() - { - } - [Fact] - public void Test_7975() - { - } - [Fact] - public void Test_7976() - { - } - [Fact] - public void Test_7977() - { - } - [Fact] - public void Test_7978() - { - } - [Fact] - public void Test_7979() - { - } - [Fact] - public void Test_7980() - { - } - [Fact] - public void Test_7981() - { - } - [Fact] - public void Test_7982() - { - } - [Fact] - public void Test_7983() - { - } - [Fact] - public void Test_7984() - { - } - [Fact] - public void Test_7985() - { - } - [Fact] - public void Test_7986() - { - } - [Fact] - public void Test_7987() - { - } - [Fact] - public void Test_7988() - { - } - [Fact] - public void Test_7989() - { - } - [Fact] - public void Test_7990() - { - } - [Fact] - public void Test_7991() - { - } - [Fact] - public void Test_7992() - { - } - [Fact] - public void Test_7993() - { - } - [Fact] - public void Test_7994() - { - } - [Fact] - public void Test_7995() - { - } - [Fact] - public void Test_7996() - { - } - [Fact] - public void Test_7997() - { - } - [Fact] - public void Test_7998() - { - } - [Fact] - public void Test_7999() - { - } - [Fact] - public void Test_8000() - { - } - [Fact] - public void Test_8001() - { - } - [Fact] - public void Test_8002() - { - } - [Fact] - public void Test_8003() - { - } - [Fact] - public void Test_8004() - { - } - [Fact] - public void Test_8005() - { - } - [Fact] - public void Test_8006() - { - } - [Fact] - public void Test_8007() - { - } - [Fact] - public void Test_8008() - { - } - [Fact] - public void Test_8009() - { - } - [Fact] - public void Test_8010() - { - } - [Fact] - public void Test_8011() - { - } - [Fact] - public void Test_8012() - { - } - [Fact] - public void Test_8013() - { - } - [Fact] - public void Test_8014() - { - } - [Fact] - public void Test_8015() - { - } - [Fact] - public void Test_8016() - { - } - [Fact] - public void Test_8017() - { - } - [Fact] - public void Test_8018() - { - } - [Fact] - public void Test_8019() - { - } - [Fact] - public void Test_8020() - { - } - [Fact] - public void Test_8021() - { - } - [Fact] - public void Test_8022() - { - } - [Fact] - public void Test_8023() - { - } - [Fact] - public void Test_8024() - { - } - [Fact] - public void Test_8025() - { - } - [Fact] - public void Test_8026() - { - } - [Fact] - public void Test_8027() - { - } - [Fact] - public void Test_8028() - { - } - [Fact] - public void Test_8029() - { - } - [Fact] - public void Test_8030() - { - } - [Fact] - public void Test_8031() - { - } - [Fact] - public void Test_8032() - { - } - [Fact] - public void Test_8033() - { - } - [Fact] - public void Test_8034() - { - } - [Fact] - public void Test_8035() - { - } - [Fact] - public void Test_8036() - { - } - [Fact] - public void Test_8037() - { - } - [Fact] - public void Test_8038() - { - } - [Fact] - public void Test_8039() - { - } - [Fact] - public void Test_8040() - { - } - [Fact] - public void Test_8041() - { - } - [Fact] - public void Test_8042() - { - } - [Fact] - public void Test_8043() - { - } - [Fact] - public void Test_8044() - { - } - [Fact] - public void Test_8045() - { - } - [Fact] - public void Test_8046() - { - } - [Fact] - public void Test_8047() - { - } - [Fact] - public void Test_8048() - { - } - [Fact] - public void Test_8049() - { - } - [Fact] - public void Test_8050() - { - } - [Fact] - public void Test_8051() - { - } - [Fact] - public void Test_8052() - { - } - [Fact] - public void Test_8053() - { - } - [Fact] - public void Test_8054() - { - } - [Fact] - public void Test_8055() - { - } - [Fact] - public void Test_8056() - { - } - [Fact] - public void Test_8057() - { - } - [Fact] - public void Test_8058() - { - } - [Fact] - public void Test_8059() - { - } - [Fact] - public void Test_8060() - { - } - [Fact] - public void Test_8061() - { - } - [Fact] - public void Test_8062() - { - } - [Fact] - public void Test_8063() - { - } - [Fact] - public void Test_8064() - { - } - [Fact] - public void Test_8065() - { - } - [Fact] - public void Test_8066() - { - } - [Fact] - public void Test_8067() - { - } - [Fact] - public void Test_8068() - { - } - [Fact] - public void Test_8069() - { - } - [Fact] - public void Test_8070() - { - } - [Fact] - public void Test_8071() - { - } - [Fact] - public void Test_8072() - { - } - [Fact] - public void Test_8073() - { - } - [Fact] - public void Test_8074() - { - } - [Fact] - public void Test_8075() - { - } - [Fact] - public void Test_8076() - { - } - [Fact] - public void Test_8077() - { - } - [Fact] - public void Test_8078() - { - } - [Fact] - public void Test_8079() - { - } - [Fact] - public void Test_8080() - { - } - [Fact] - public void Test_8081() - { - } - [Fact] - public void Test_8082() - { - } - [Fact] - public void Test_8083() - { - } - [Fact] - public void Test_8084() - { - } - [Fact] - public void Test_8085() - { - } - [Fact] - public void Test_8086() - { - } - [Fact] - public void Test_8087() - { - } - [Fact] - public void Test_8088() - { - } - [Fact] - public void Test_8089() - { - } - [Fact] - public void Test_8090() - { - } - [Fact] - public void Test_8091() - { - } - [Fact] - public void Test_8092() - { - } - [Fact] - public void Test_8093() - { - } - [Fact] - public void Test_8094() - { - } - [Fact] - public void Test_8095() - { - } - [Fact] - public void Test_8096() - { - } - [Fact] - public void Test_8097() - { - } - [Fact] - public void Test_8098() - { - } - [Fact] - public void Test_8099() - { - } - [Fact] - public void Test_8100() - { - } - [Fact] - public void Test_8101() - { - } - [Fact] - public void Test_8102() - { - } - [Fact] - public void Test_8103() - { - } - [Fact] - public void Test_8104() - { - } - [Fact] - public void Test_8105() - { - } - [Fact] - public void Test_8106() - { - } - [Fact] - public void Test_8107() - { - } - [Fact] - public void Test_8108() - { - } - [Fact] - public void Test_8109() - { - } - [Fact] - public void Test_8110() - { - } - [Fact] - public void Test_8111() - { - } - [Fact] - public void Test_8112() - { - } - [Fact] - public void Test_8113() - { - } - [Fact] - public void Test_8114() - { - } - [Fact] - public void Test_8115() - { - } - [Fact] - public void Test_8116() - { - } - [Fact] - public void Test_8117() - { - } - [Fact] - public void Test_8118() - { - } - [Fact] - public void Test_8119() - { - } - [Fact] - public void Test_8120() - { - } - [Fact] - public void Test_8121() - { - } - [Fact] - public void Test_8122() - { - } - [Fact] - public void Test_8123() - { - } - [Fact] - public void Test_8124() - { - } - [Fact] - public void Test_8125() - { - } - [Fact] - public void Test_8126() - { - } - [Fact] - public void Test_8127() - { - } - [Fact] - public void Test_8128() - { - } - [Fact] - public void Test_8129() - { - } - [Fact] - public void Test_8130() - { - } - [Fact] - public void Test_8131() - { - } - [Fact] - public void Test_8132() - { - } - [Fact] - public void Test_8133() - { - } - [Fact] - public void Test_8134() - { - } - [Fact] - public void Test_8135() - { - } - [Fact] - public void Test_8136() - { - } - [Fact] - public void Test_8137() - { - } - [Fact] - public void Test_8138() - { - } - [Fact] - public void Test_8139() - { - } - [Fact] - public void Test_8140() - { - } - [Fact] - public void Test_8141() - { - } - [Fact] - public void Test_8142() - { - } - [Fact] - public void Test_8143() - { - } - [Fact] - public void Test_8144() - { - } - [Fact] - public void Test_8145() - { - } - [Fact] - public void Test_8146() - { - } - [Fact] - public void Test_8147() - { - } - [Fact] - public void Test_8148() - { - } - [Fact] - public void Test_8149() - { - } - [Fact] - public void Test_8150() - { - } - [Fact] - public void Test_8151() - { - } - [Fact] - public void Test_8152() - { - } - [Fact] - public void Test_8153() - { - } - [Fact] - public void Test_8154() - { - } - [Fact] - public void Test_8155() - { - } - [Fact] - public void Test_8156() - { - } - [Fact] - public void Test_8157() - { - } - [Fact] - public void Test_8158() - { - } - [Fact] - public void Test_8159() - { - } - [Fact] - public void Test_8160() - { - } - [Fact] - public void Test_8161() - { - } - [Fact] - public void Test_8162() - { - } - [Fact] - public void Test_8163() - { - } - [Fact] - public void Test_8164() - { - } - [Fact] - public void Test_8165() - { - } - [Fact] - public void Test_8166() - { - } - [Fact] - public void Test_8167() - { - } - [Fact] - public void Test_8168() - { - } - [Fact] - public void Test_8169() - { - } - [Fact] - public void Test_8170() - { - } - [Fact] - public void Test_8171() - { - } - [Fact] - public void Test_8172() - { - } - [Fact] - public void Test_8173() - { - } - [Fact] - public void Test_8174() - { - } - [Fact] - public void Test_8175() - { - } - [Fact] - public void Test_8176() - { - } - [Fact] - public void Test_8177() - { - } - [Fact] - public void Test_8178() - { - } - [Fact] - public void Test_8179() - { - } - [Fact] - public void Test_8180() - { - } - [Fact] - public void Test_8181() - { - } - [Fact] - public void Test_8182() - { - } - [Fact] - public void Test_8183() - { - } - [Fact] - public void Test_8184() - { - } - [Fact] - public void Test_8185() - { - } - [Fact] - public void Test_8186() - { - } - [Fact] - public void Test_8187() - { - } - [Fact] - public void Test_8188() - { - } - [Fact] - public void Test_8189() - { - } - [Fact] - public void Test_8190() - { - } - [Fact] - public void Test_8191() - { - } - [Fact] - public void Test_8192() - { - } - [Fact] - public void Test_8193() - { - } - [Fact] - public void Test_8194() - { - } - [Fact] - public void Test_8195() - { - } - [Fact] - public void Test_8196() - { - } - [Fact] - public void Test_8197() - { - } - [Fact] - public void Test_8198() - { - } - [Fact] - public void Test_8199() - { - } - [Fact] - public void Test_8200() - { - } - [Fact] - public void Test_8201() - { - } - [Fact] - public void Test_8202() - { - } - [Fact] - public void Test_8203() - { - } - [Fact] - public void Test_8204() - { - } - [Fact] - public void Test_8205() - { - } - [Fact] - public void Test_8206() - { - } - [Fact] - public void Test_8207() - { - } - [Fact] - public void Test_8208() - { - } - [Fact] - public void Test_8209() - { - } - [Fact] - public void Test_8210() - { - } - [Fact] - public void Test_8211() - { - } - [Fact] - public void Test_8212() - { - } - [Fact] - public void Test_8213() - { - } - [Fact] - public void Test_8214() - { - } - [Fact] - public void Test_8215() - { - } - [Fact] - public void Test_8216() - { - } - [Fact] - public void Test_8217() - { - } - [Fact] - public void Test_8218() - { - } - [Fact] - public void Test_8219() - { - } - [Fact] - public void Test_8220() - { - } - [Fact] - public void Test_8221() - { - } - [Fact] - public void Test_8222() - { - } - [Fact] - public void Test_8223() - { - } - [Fact] - public void Test_8224() - { - } - [Fact] - public void Test_8225() - { - } - [Fact] - public void Test_8226() - { - } - [Fact] - public void Test_8227() - { - } - [Fact] - public void Test_8228() - { - } - [Fact] - public void Test_8229() - { - } - [Fact] - public void Test_8230() - { - } - [Fact] - public void Test_8231() - { - } - [Fact] - public void Test_8232() - { - } - [Fact] - public void Test_8233() - { - } - [Fact] - public void Test_8234() - { - } - [Fact] - public void Test_8235() - { - } - [Fact] - public void Test_8236() - { - } - [Fact] - public void Test_8237() - { - } - [Fact] - public void Test_8238() - { - } - [Fact] - public void Test_8239() - { - } - [Fact] - public void Test_8240() - { - } - [Fact] - public void Test_8241() - { - } - [Fact] - public void Test_8242() - { - } - [Fact] - public void Test_8243() - { - } - [Fact] - public void Test_8244() - { - } - [Fact] - public void Test_8245() - { - } - [Fact] - public void Test_8246() - { - } - [Fact] - public void Test_8247() - { - } - [Fact] - public void Test_8248() - { - } - [Fact] - public void Test_8249() - { - } - [Fact] - public void Test_8250() - { - } - [Fact] - public void Test_8251() - { - } - [Fact] - public void Test_8252() - { - } - [Fact] - public void Test_8253() - { - } - [Fact] - public void Test_8254() - { - } - [Fact] - public void Test_8255() - { - } - [Fact] - public void Test_8256() - { - } - [Fact] - public void Test_8257() - { - } - [Fact] - public void Test_8258() - { - } - [Fact] - public void Test_8259() - { - } - [Fact] - public void Test_8260() - { - } - [Fact] - public void Test_8261() - { - } - [Fact] - public void Test_8262() - { - } - [Fact] - public void Test_8263() - { - } - [Fact] - public void Test_8264() - { - } - [Fact] - public void Test_8265() - { - } - [Fact] - public void Test_8266() - { - } - [Fact] - public void Test_8267() - { - } - [Fact] - public void Test_8268() - { - } - [Fact] - public void Test_8269() - { - } - [Fact] - public void Test_8270() - { - } - [Fact] - public void Test_8271() - { - } - [Fact] - public void Test_8272() - { - } - [Fact] - public void Test_8273() - { - } - [Fact] - public void Test_8274() - { - } - [Fact] - public void Test_8275() - { - } - [Fact] - public void Test_8276() - { - } - [Fact] - public void Test_8277() - { - } - [Fact] - public void Test_8278() - { - } - [Fact] - public void Test_8279() - { - } - [Fact] - public void Test_8280() - { - } - [Fact] - public void Test_8281() - { - } - [Fact] - public void Test_8282() - { - } - [Fact] - public void Test_8283() - { - } - [Fact] - public void Test_8284() - { - } - [Fact] - public void Test_8285() - { - } - [Fact] - public void Test_8286() - { - } - [Fact] - public void Test_8287() - { - } - [Fact] - public void Test_8288() - { - } - [Fact] - public void Test_8289() - { - } - [Fact] - public void Test_8290() - { - } - [Fact] - public void Test_8291() - { - } - [Fact] - public void Test_8292() - { - } - [Fact] - public void Test_8293() - { - } - [Fact] - public void Test_8294() - { - } - [Fact] - public void Test_8295() - { - } - [Fact] - public void Test_8296() - { - } - [Fact] - public void Test_8297() - { - } - [Fact] - public void Test_8298() - { - } - [Fact] - public void Test_8299() - { - } - [Fact] - public void Test_8300() - { - } - [Fact] - public void Test_8301() - { - } - [Fact] - public void Test_8302() - { - } - [Fact] - public void Test_8303() - { - } - [Fact] - public void Test_8304() - { - } - [Fact] - public void Test_8305() - { - } - [Fact] - public void Test_8306() - { - } - [Fact] - public void Test_8307() - { - } - [Fact] - public void Test_8308() - { - } - [Fact] - public void Test_8309() - { - } - [Fact] - public void Test_8310() - { - } - [Fact] - public void Test_8311() - { - } - [Fact] - public void Test_8312() - { - } - [Fact] - public void Test_8313() - { - } - [Fact] - public void Test_8314() - { - } - [Fact] - public void Test_8315() - { - } - [Fact] - public void Test_8316() - { - } - [Fact] - public void Test_8317() - { - } - [Fact] - public void Test_8318() - { - } - [Fact] - public void Test_8319() - { - } - [Fact] - public void Test_8320() - { - } - [Fact] - public void Test_8321() - { - } - [Fact] - public void Test_8322() - { - } - [Fact] - public void Test_8323() - { - } - [Fact] - public void Test_8324() - { - } - [Fact] - public void Test_8325() - { - } - [Fact] - public void Test_8326() - { - } - [Fact] - public void Test_8327() - { - } - [Fact] - public void Test_8328() - { - } - [Fact] - public void Test_8329() - { - } - [Fact] - public void Test_8330() - { - } - [Fact] - public void Test_8331() - { - } - [Fact] - public void Test_8332() - { - } - [Fact] - public void Test_8333() - { - } - [Fact] - public void Test_8334() - { - } - [Fact] - public void Test_8335() - { - } - [Fact] - public void Test_8336() - { - } - [Fact] - public void Test_8337() - { - } - [Fact] - public void Test_8338() - { - } - [Fact] - public void Test_8339() - { - } - [Fact] - public void Test_8340() - { - } - [Fact] - public void Test_8341() - { - } - [Fact] - public void Test_8342() - { - } - [Fact] - public void Test_8343() - { - } - [Fact] - public void Test_8344() - { - } - [Fact] - public void Test_8345() - { - } - [Fact] - public void Test_8346() - { - } - [Fact] - public void Test_8347() - { - } - [Fact] - public void Test_8348() - { - } - [Fact] - public void Test_8349() - { - } - [Fact] - public void Test_8350() - { - } - [Fact] - public void Test_8351() - { - } - [Fact] - public void Test_8352() - { - } - [Fact] - public void Test_8353() - { - } - [Fact] - public void Test_8354() - { - } - [Fact] - public void Test_8355() - { - } - [Fact] - public void Test_8356() - { - } - [Fact] - public void Test_8357() - { - } - [Fact] - public void Test_8358() - { - } - [Fact] - public void Test_8359() - { - } - [Fact] - public void Test_8360() - { - } - [Fact] - public void Test_8361() - { - } - [Fact] - public void Test_8362() - { - } - [Fact] - public void Test_8363() - { - } - [Fact] - public void Test_8364() - { - } - [Fact] - public void Test_8365() - { - } - [Fact] - public void Test_8366() - { - } - [Fact] - public void Test_8367() - { - } - [Fact] - public void Test_8368() - { - } - [Fact] - public void Test_8369() - { - } - [Fact] - public void Test_8370() - { - } - [Fact] - public void Test_8371() - { - } - [Fact] - public void Test_8372() - { - } - [Fact] - public void Test_8373() - { - } - [Fact] - public void Test_8374() - { - } - [Fact] - public void Test_8375() - { - } - [Fact] - public void Test_8376() - { - } - [Fact] - public void Test_8377() - { - } - [Fact] - public void Test_8378() - { - } - [Fact] - public void Test_8379() - { - } - [Fact] - public void Test_8380() - { - } - [Fact] - public void Test_8381() - { - } - [Fact] - public void Test_8382() - { - } - [Fact] - public void Test_8383() - { - } - [Fact] - public void Test_8384() - { - } - [Fact] - public void Test_8385() - { - } - [Fact] - public void Test_8386() - { - } - [Fact] - public void Test_8387() - { - } - [Fact] - public void Test_8388() - { - } - [Fact] - public void Test_8389() - { - } - [Fact] - public void Test_8390() - { - } - [Fact] - public void Test_8391() - { - } - [Fact] - public void Test_8392() - { - } - [Fact] - public void Test_8393() - { - } - [Fact] - public void Test_8394() - { - } - [Fact] - public void Test_8395() - { - } - [Fact] - public void Test_8396() - { - } - [Fact] - public void Test_8397() - { - } - [Fact] - public void Test_8398() - { - } - [Fact] - public void Test_8399() - { - } - [Fact] - public void Test_8400() - { - } - [Fact] - public void Test_8401() - { - } - [Fact] - public void Test_8402() - { - } - [Fact] - public void Test_8403() - { - } - [Fact] - public void Test_8404() - { - } - [Fact] - public void Test_8405() - { - } - [Fact] - public void Test_8406() - { - } - [Fact] - public void Test_8407() - { - } - [Fact] - public void Test_8408() - { - } - [Fact] - public void Test_8409() - { - } - [Fact] - public void Test_8410() - { - } - [Fact] - public void Test_8411() - { - } - [Fact] - public void Test_8412() - { - } - [Fact] - public void Test_8413() - { - } - [Fact] - public void Test_8414() - { - } - [Fact] - public void Test_8415() - { - } - [Fact] - public void Test_8416() - { - } - [Fact] - public void Test_8417() - { - } - [Fact] - public void Test_8418() - { - } - [Fact] - public void Test_8419() - { - } - [Fact] - public void Test_8420() - { - } - [Fact] - public void Test_8421() - { - } - [Fact] - public void Test_8422() - { - } - [Fact] - public void Test_8423() - { - } - [Fact] - public void Test_8424() - { - } - [Fact] - public void Test_8425() - { - } - [Fact] - public void Test_8426() - { - } - [Fact] - public void Test_8427() - { - } - [Fact] - public void Test_8428() - { - } - [Fact] - public void Test_8429() - { - } - [Fact] - public void Test_8430() - { - } - [Fact] - public void Test_8431() - { - } - [Fact] - public void Test_8432() - { - } - [Fact] - public void Test_8433() - { - } - [Fact] - public void Test_8434() - { - } - [Fact] - public void Test_8435() - { - } - [Fact] - public void Test_8436() - { - } - [Fact] - public void Test_8437() - { - } - [Fact] - public void Test_8438() - { - } - [Fact] - public void Test_8439() - { - } - [Fact] - public void Test_8440() - { - } - [Fact] - public void Test_8441() - { - } - [Fact] - public void Test_8442() - { - } - [Fact] - public void Test_8443() - { - } - [Fact] - public void Test_8444() - { - } - [Fact] - public void Test_8445() - { - } - [Fact] - public void Test_8446() - { - } - [Fact] - public void Test_8447() - { - } - [Fact] - public void Test_8448() - { - } - [Fact] - public void Test_8449() - { - } - [Fact] - public void Test_8450() - { - } - [Fact] - public void Test_8451() - { - } - [Fact] - public void Test_8452() - { - } - [Fact] - public void Test_8453() - { - } - [Fact] - public void Test_8454() - { - } - [Fact] - public void Test_8455() - { - } - [Fact] - public void Test_8456() - { - } - [Fact] - public void Test_8457() - { - } - [Fact] - public void Test_8458() - { - } - [Fact] - public void Test_8459() - { - } - [Fact] - public void Test_8460() - { - } - [Fact] - public void Test_8461() - { - } - [Fact] - public void Test_8462() - { - } - [Fact] - public void Test_8463() - { - } - [Fact] - public void Test_8464() - { - } - [Fact] - public void Test_8465() - { - } - [Fact] - public void Test_8466() - { - } - [Fact] - public void Test_8467() - { - } - [Fact] - public void Test_8468() - { - } - [Fact] - public void Test_8469() - { - } - [Fact] - public void Test_8470() - { - } - [Fact] - public void Test_8471() - { - } - [Fact] - public void Test_8472() - { - } - [Fact] - public void Test_8473() - { - } - [Fact] - public void Test_8474() - { - } - [Fact] - public void Test_8475() - { - } - [Fact] - public void Test_8476() - { - } - [Fact] - public void Test_8477() - { - } - [Fact] - public void Test_8478() - { - } - [Fact] - public void Test_8479() - { - } - [Fact] - public void Test_8480() - { - } - [Fact] - public void Test_8481() - { - } - [Fact] - public void Test_8482() - { - } - [Fact] - public void Test_8483() - { - } - [Fact] - public void Test_8484() - { - } - [Fact] - public void Test_8485() - { - } - [Fact] - public void Test_8486() - { - } - [Fact] - public void Test_8487() - { - } - [Fact] - public void Test_8488() - { - } - [Fact] - public void Test_8489() - { - } - [Fact] - public void Test_8490() - { - } - [Fact] - public void Test_8491() - { - } - [Fact] - public void Test_8492() - { - } - [Fact] - public void Test_8493() - { - } - [Fact] - public void Test_8494() - { - } - [Fact] - public void Test_8495() - { - } - [Fact] - public void Test_8496() - { - } - [Fact] - public void Test_8497() - { - } - [Fact] - public void Test_8498() - { - } - [Fact] - public void Test_8499() - { - } - [Fact] - public void Test_8500() - { - } - [Fact] - public void Test_8501() - { - } - [Fact] - public void Test_8502() - { - } - [Fact] - public void Test_8503() - { - } - [Fact] - public void Test_8504() - { - } - [Fact] - public void Test_8505() - { - } - [Fact] - public void Test_8506() - { - } - [Fact] - public void Test_8507() - { - } - [Fact] - public void Test_8508() - { - } - [Fact] - public void Test_8509() - { - } - [Fact] - public void Test_8510() - { - } - [Fact] - public void Test_8511() - { - } - [Fact] - public void Test_8512() - { - } - [Fact] - public void Test_8513() - { - } - [Fact] - public void Test_8514() - { - } - [Fact] - public void Test_8515() - { - } - [Fact] - public void Test_8516() - { - } - [Fact] - public void Test_8517() - { - } - [Fact] - public void Test_8518() - { - } - [Fact] - public void Test_8519() - { - } - [Fact] - public void Test_8520() - { - } - [Fact] - public void Test_8521() - { - } - [Fact] - public void Test_8522() - { - } - [Fact] - public void Test_8523() - { - } - [Fact] - public void Test_8524() - { - } - [Fact] - public void Test_8525() - { - } - [Fact] - public void Test_8526() - { - } - [Fact] - public void Test_8527() - { - } - [Fact] - public void Test_8528() - { - } - [Fact] - public void Test_8529() - { - } - [Fact] - public void Test_8530() - { - } - [Fact] - public void Test_8531() - { - } - [Fact] - public void Test_8532() - { - } - [Fact] - public void Test_8533() - { - } - [Fact] - public void Test_8534() - { - } - [Fact] - public void Test_8535() - { - } - [Fact] - public void Test_8536() - { - } - [Fact] - public void Test_8537() - { - } - [Fact] - public void Test_8538() - { - } - [Fact] - public void Test_8539() - { - } - [Fact] - public void Test_8540() - { - } - [Fact] - public void Test_8541() - { - } - [Fact] - public void Test_8542() - { - } - [Fact] - public void Test_8543() - { - } - [Fact] - public void Test_8544() - { - } - [Fact] - public void Test_8545() - { - } - [Fact] - public void Test_8546() - { - } - [Fact] - public void Test_8547() - { - } - [Fact] - public void Test_8548() - { - } - [Fact] - public void Test_8549() - { - } - [Fact] - public void Test_8550() - { - } - [Fact] - public void Test_8551() - { - } - [Fact] - public void Test_8552() - { - } - [Fact] - public void Test_8553() - { - } - [Fact] - public void Test_8554() - { - } - [Fact] - public void Test_8555() - { - } - [Fact] - public void Test_8556() - { - } - [Fact] - public void Test_8557() - { - } - [Fact] - public void Test_8558() - { - } - [Fact] - public void Test_8559() - { - } - [Fact] - public void Test_8560() - { - } - [Fact] - public void Test_8561() - { - } - [Fact] - public void Test_8562() - { - } - [Fact] - public void Test_8563() - { - } - [Fact] - public void Test_8564() - { - } - [Fact] - public void Test_8565() - { - } - [Fact] - public void Test_8566() - { - } - [Fact] - public void Test_8567() - { - } - [Fact] - public void Test_8568() - { - } - [Fact] - public void Test_8569() - { - } - [Fact] - public void Test_8570() - { - } - [Fact] - public void Test_8571() - { - } - [Fact] - public void Test_8572() - { - } - [Fact] - public void Test_8573() - { - } - [Fact] - public void Test_8574() - { - } - [Fact] - public void Test_8575() - { - } - [Fact] - public void Test_8576() - { - } - [Fact] - public void Test_8577() - { - } - [Fact] - public void Test_8578() - { - } - [Fact] - public void Test_8579() - { - } - [Fact] - public void Test_8580() - { - } - [Fact] - public void Test_8581() - { - } - [Fact] - public void Test_8582() - { - } - [Fact] - public void Test_8583() - { - } - [Fact] - public void Test_8584() - { - } - [Fact] - public void Test_8585() - { - } - [Fact] - public void Test_8586() - { - } - [Fact] - public void Test_8587() - { - } - [Fact] - public void Test_8588() - { - } - [Fact] - public void Test_8589() - { - } - [Fact] - public void Test_8590() - { - } - [Fact] - public void Test_8591() - { - } - [Fact] - public void Test_8592() - { - } - [Fact] - public void Test_8593() - { - } - [Fact] - public void Test_8594() - { - } - [Fact] - public void Test_8595() - { - } - [Fact] - public void Test_8596() - { - } - [Fact] - public void Test_8597() - { - } - [Fact] - public void Test_8598() - { - } - [Fact] - public void Test_8599() - { - } - [Fact] - public void Test_8600() - { - } - [Fact] - public void Test_8601() - { - } - [Fact] - public void Test_8602() - { - } - [Fact] - public void Test_8603() - { - } - [Fact] - public void Test_8604() - { - } - [Fact] - public void Test_8605() - { - } - [Fact] - public void Test_8606() - { - } - [Fact] - public void Test_8607() - { - } - [Fact] - public void Test_8608() - { - } - [Fact] - public void Test_8609() - { - } - [Fact] - public void Test_8610() - { - } - [Fact] - public void Test_8611() - { - } - [Fact] - public void Test_8612() - { - } - [Fact] - public void Test_8613() - { - } - [Fact] - public void Test_8614() - { - } - [Fact] - public void Test_8615() - { - } - [Fact] - public void Test_8616() - { - } - [Fact] - public void Test_8617() - { - } - [Fact] - public void Test_8618() - { - } - [Fact] - public void Test_8619() - { - } - [Fact] - public void Test_8620() - { - } - [Fact] - public void Test_8621() - { - } - [Fact] - public void Test_8622() - { - } - [Fact] - public void Test_8623() - { - } - [Fact] - public void Test_8624() - { - } - [Fact] - public void Test_8625() - { - } - [Fact] - public void Test_8626() - { - } - [Fact] - public void Test_8627() - { - } - [Fact] - public void Test_8628() - { - } - [Fact] - public void Test_8629() - { - } - [Fact] - public void Test_8630() - { - } - [Fact] - public void Test_8631() - { - } - [Fact] - public void Test_8632() - { - } - [Fact] - public void Test_8633() - { - } - [Fact] - public void Test_8634() - { - } - [Fact] - public void Test_8635() - { - } - [Fact] - public void Test_8636() - { - } - [Fact] - public void Test_8637() - { - } - [Fact] - public void Test_8638() - { - } - [Fact] - public void Test_8639() - { - } - [Fact] - public void Test_8640() - { - } - [Fact] - public void Test_8641() - { - } - [Fact] - public void Test_8642() - { - } - [Fact] - public void Test_8643() - { - } - [Fact] - public void Test_8644() - { - } - [Fact] - public void Test_8645() - { - } - [Fact] - public void Test_8646() - { - } - [Fact] - public void Test_8647() - { - } - [Fact] - public void Test_8648() - { - } - [Fact] - public void Test_8649() - { - } - [Fact] - public void Test_8650() - { - } - [Fact] - public void Test_8651() - { - } - [Fact] - public void Test_8652() - { - } - [Fact] - public void Test_8653() - { - } - [Fact] - public void Test_8654() - { - } - [Fact] - public void Test_8655() - { - } - [Fact] - public void Test_8656() - { - } - [Fact] - public void Test_8657() - { - } - [Fact] - public void Test_8658() - { - } - [Fact] - public void Test_8659() - { - } - [Fact] - public void Test_8660() - { - } - [Fact] - public void Test_8661() - { - } - [Fact] - public void Test_8662() - { - } - [Fact] - public void Test_8663() - { - } - [Fact] - public void Test_8664() - { - } - [Fact] - public void Test_8665() - { - } - [Fact] - public void Test_8666() - { - } - [Fact] - public void Test_8667() - { - } - [Fact] - public void Test_8668() - { - } - [Fact] - public void Test_8669() - { - } - [Fact] - public void Test_8670() - { - } - [Fact] - public void Test_8671() - { - } - [Fact] - public void Test_8672() - { - } - [Fact] - public void Test_8673() - { - } - [Fact] - public void Test_8674() - { - } - [Fact] - public void Test_8675() - { - } - [Fact] - public void Test_8676() - { - } - [Fact] - public void Test_8677() - { - } - [Fact] - public void Test_8678() - { - } - [Fact] - public void Test_8679() - { - } - [Fact] - public void Test_8680() - { - } - [Fact] - public void Test_8681() - { - } - [Fact] - public void Test_8682() - { - } - [Fact] - public void Test_8683() - { - } - [Fact] - public void Test_8684() - { - } - [Fact] - public void Test_8685() - { - } - [Fact] - public void Test_8686() - { - } - [Fact] - public void Test_8687() - { - } - [Fact] - public void Test_8688() - { - } - [Fact] - public void Test_8689() - { - } - [Fact] - public void Test_8690() - { - } - [Fact] - public void Test_8691() - { - } - [Fact] - public void Test_8692() - { - } - [Fact] - public void Test_8693() - { - } - [Fact] - public void Test_8694() - { - } - [Fact] - public void Test_8695() - { - } - [Fact] - public void Test_8696() - { - } - [Fact] - public void Test_8697() - { - } - [Fact] - public void Test_8698() - { - } - [Fact] - public void Test_8699() - { - } - [Fact] - public void Test_8700() - { - } - [Fact] - public void Test_8701() - { - } - [Fact] - public void Test_8702() - { - } - [Fact] - public void Test_8703() - { - } - [Fact] - public void Test_8704() - { - } - [Fact] - public void Test_8705() - { - } - [Fact] - public void Test_8706() - { - } - [Fact] - public void Test_8707() - { - } - [Fact] - public void Test_8708() - { - } - [Fact] - public void Test_8709() - { - } - [Fact] - public void Test_8710() - { - } - [Fact] - public void Test_8711() - { - } - [Fact] - public void Test_8712() - { - } - [Fact] - public void Test_8713() - { - } - [Fact] - public void Test_8714() - { - } - [Fact] - public void Test_8715() - { - } - [Fact] - public void Test_8716() - { - } - [Fact] - public void Test_8717() - { - } - [Fact] - public void Test_8718() - { - } - [Fact] - public void Test_8719() - { - } - [Fact] - public void Test_8720() - { - } - [Fact] - public void Test_8721() - { - } - [Fact] - public void Test_8722() - { - } - [Fact] - public void Test_8723() - { - } - [Fact] - public void Test_8724() - { - } - [Fact] - public void Test_8725() - { - } - [Fact] - public void Test_8726() - { - } - [Fact] - public void Test_8727() - { - } - [Fact] - public void Test_8728() - { - } - [Fact] - public void Test_8729() - { - } - [Fact] - public void Test_8730() - { - } - [Fact] - public void Test_8731() - { - } - [Fact] - public void Test_8732() - { - } - [Fact] - public void Test_8733() - { - } - [Fact] - public void Test_8734() - { - } - [Fact] - public void Test_8735() - { - } - [Fact] - public void Test_8736() - { - } - [Fact] - public void Test_8737() - { - } - [Fact] - public void Test_8738() - { - } - [Fact] - public void Test_8739() - { - } - [Fact] - public void Test_8740() - { - } - [Fact] - public void Test_8741() - { - } - [Fact] - public void Test_8742() - { - } - [Fact] - public void Test_8743() - { - } - [Fact] - public void Test_8744() - { - } - [Fact] - public void Test_8745() - { - } - [Fact] - public void Test_8746() - { - } - [Fact] - public void Test_8747() - { - } - [Fact] - public void Test_8748() - { - } - [Fact] - public void Test_8749() - { - } - [Fact] - public void Test_8750() - { - } - [Fact] - public void Test_8751() - { - } - [Fact] - public void Test_8752() - { - } - [Fact] - public void Test_8753() - { - } - [Fact] - public void Test_8754() - { - } - [Fact] - public void Test_8755() - { - } - [Fact] - public void Test_8756() - { - } - [Fact] - public void Test_8757() - { - } - [Fact] - public void Test_8758() - { - } - [Fact] - public void Test_8759() - { - } - [Fact] - public void Test_8760() - { - } - [Fact] - public void Test_8761() - { - } - [Fact] - public void Test_8762() - { - } - [Fact] - public void Test_8763() - { - } - [Fact] - public void Test_8764() - { - } - [Fact] - public void Test_8765() - { - } - [Fact] - public void Test_8766() - { - } - [Fact] - public void Test_8767() - { - } - [Fact] - public void Test_8768() - { - } - [Fact] - public void Test_8769() - { - } - [Fact] - public void Test_8770() - { - } - [Fact] - public void Test_8771() - { - } - [Fact] - public void Test_8772() - { - } - [Fact] - public void Test_8773() - { - } - [Fact] - public void Test_8774() - { - } - [Fact] - public void Test_8775() - { - } - [Fact] - public void Test_8776() - { - } - [Fact] - public void Test_8777() - { - } - [Fact] - public void Test_8778() - { - } - [Fact] - public void Test_8779() - { - } - [Fact] - public void Test_8780() - { - } - [Fact] - public void Test_8781() - { - } - [Fact] - public void Test_8782() - { - } - [Fact] - public void Test_8783() - { - } - [Fact] - public void Test_8784() - { - } - [Fact] - public void Test_8785() - { - } - [Fact] - public void Test_8786() - { - } - [Fact] - public void Test_8787() - { - } - [Fact] - public void Test_8788() - { - } - [Fact] - public void Test_8789() - { - } - [Fact] - public void Test_8790() - { - } - [Fact] - public void Test_8791() - { - } - [Fact] - public void Test_8792() - { - } - [Fact] - public void Test_8793() - { - } - [Fact] - public void Test_8794() - { - } - [Fact] - public void Test_8795() - { - } - [Fact] - public void Test_8796() - { - } - [Fact] - public void Test_8797() - { - } - [Fact] - public void Test_8798() - { - } - [Fact] - public void Test_8799() - { - } - [Fact] - public void Test_8800() - { - } - [Fact] - public void Test_8801() - { - } - [Fact] - public void Test_8802() - { - } - [Fact] - public void Test_8803() - { - } - [Fact] - public void Test_8804() - { - } - [Fact] - public void Test_8805() - { - } - [Fact] - public void Test_8806() - { - } - [Fact] - public void Test_8807() - { - } - [Fact] - public void Test_8808() - { - } - [Fact] - public void Test_8809() - { - } - [Fact] - public void Test_8810() - { - } - [Fact] - public void Test_8811() - { - } - [Fact] - public void Test_8812() - { - } - [Fact] - public void Test_8813() - { - } - [Fact] - public void Test_8814() - { - } - [Fact] - public void Test_8815() - { - } - [Fact] - public void Test_8816() - { - } - [Fact] - public void Test_8817() - { - } - [Fact] - public void Test_8818() - { - } - [Fact] - public void Test_8819() - { - } - [Fact] - public void Test_8820() - { - } - [Fact] - public void Test_8821() - { - } - [Fact] - public void Test_8822() - { - } - [Fact] - public void Test_8823() - { - } - [Fact] - public void Test_8824() - { - } - [Fact] - public void Test_8825() - { - } - [Fact] - public void Test_8826() - { - } - [Fact] - public void Test_8827() - { - } - [Fact] - public void Test_8828() - { - } - [Fact] - public void Test_8829() - { - } - [Fact] - public void Test_8830() - { - } - [Fact] - public void Test_8831() - { - } - [Fact] - public void Test_8832() - { - } - [Fact] - public void Test_8833() - { - } - [Fact] - public void Test_8834() - { - } - [Fact] - public void Test_8835() - { - } - [Fact] - public void Test_8836() - { - } - [Fact] - public void Test_8837() - { - } - [Fact] - public void Test_8838() - { - } - [Fact] - public void Test_8839() - { - } - [Fact] - public void Test_8840() - { - } - [Fact] - public void Test_8841() - { - } - [Fact] - public void Test_8842() - { - } - [Fact] - public void Test_8843() - { - } - [Fact] - public void Test_8844() - { - } - [Fact] - public void Test_8845() - { - } - [Fact] - public void Test_8846() - { - } - [Fact] - public void Test_8847() - { - } - [Fact] - public void Test_8848() - { - } - [Fact] - public void Test_8849() - { - } - [Fact] - public void Test_8850() - { - } - [Fact] - public void Test_8851() - { - } - [Fact] - public void Test_8852() - { - } - [Fact] - public void Test_8853() - { - } - [Fact] - public void Test_8854() - { - } - [Fact] - public void Test_8855() - { - } - [Fact] - public void Test_8856() - { - } - [Fact] - public void Test_8857() - { - } - [Fact] - public void Test_8858() - { - } - [Fact] - public void Test_8859() - { - } - [Fact] - public void Test_8860() - { - } - [Fact] - public void Test_8861() - { - } - [Fact] - public void Test_8862() - { - } - [Fact] - public void Test_8863() - { - } - [Fact] - public void Test_8864() - { - } - [Fact] - public void Test_8865() - { - } - [Fact] - public void Test_8866() - { - } - [Fact] - public void Test_8867() - { - } - [Fact] - public void Test_8868() - { - } - [Fact] - public void Test_8869() - { - } - [Fact] - public void Test_8870() - { - } - [Fact] - public void Test_8871() - { - } - [Fact] - public void Test_8872() - { - } - [Fact] - public void Test_8873() - { - } - [Fact] - public void Test_8874() - { - } - [Fact] - public void Test_8875() - { - } - [Fact] - public void Test_8876() - { - } - [Fact] - public void Test_8877() - { - } - [Fact] - public void Test_8878() - { - } - [Fact] - public void Test_8879() - { - } - [Fact] - public void Test_8880() - { - } - [Fact] - public void Test_8881() - { - } - [Fact] - public void Test_8882() - { - } - [Fact] - public void Test_8883() - { - } - [Fact] - public void Test_8884() - { - } - [Fact] - public void Test_8885() - { - } - [Fact] - public void Test_8886() - { - } - [Fact] - public void Test_8887() - { - } - [Fact] - public void Test_8888() - { - } - [Fact] - public void Test_8889() - { - } - [Fact] - public void Test_8890() - { - } - [Fact] - public void Test_8891() - { - } - [Fact] - public void Test_8892() - { - } - [Fact] - public void Test_8893() - { - } - [Fact] - public void Test_8894() - { - } - [Fact] - public void Test_8895() - { - } - [Fact] - public void Test_8896() - { - } - [Fact] - public void Test_8897() - { - } - [Fact] - public void Test_8898() - { - } - [Fact] - public void Test_8899() - { - } - [Fact] - public void Test_8900() - { - } - [Fact] - public void Test_8901() - { - } - [Fact] - public void Test_8902() - { - } - [Fact] - public void Test_8903() - { - } - [Fact] - public void Test_8904() - { - } - [Fact] - public void Test_8905() - { - } - [Fact] - public void Test_8906() - { - } - [Fact] - public void Test_8907() - { - } - [Fact] - public void Test_8908() - { - } - [Fact] - public void Test_8909() - { - } - [Fact] - public void Test_8910() - { - } - [Fact] - public void Test_8911() - { - } - [Fact] - public void Test_8912() - { - } - [Fact] - public void Test_8913() - { - } - [Fact] - public void Test_8914() - { - } - [Fact] - public void Test_8915() - { - } - [Fact] - public void Test_8916() - { - } - [Fact] - public void Test_8917() - { - } - [Fact] - public void Test_8918() - { - } - [Fact] - public void Test_8919() - { - } - [Fact] - public void Test_8920() - { - } - [Fact] - public void Test_8921() - { - } - [Fact] - public void Test_8922() - { - } - [Fact] - public void Test_8923() - { - } - [Fact] - public void Test_8924() - { - } - [Fact] - public void Test_8925() - { - } - [Fact] - public void Test_8926() - { - } - [Fact] - public void Test_8927() - { - } - [Fact] - public void Test_8928() - { - } - [Fact] - public void Test_8929() - { - } - [Fact] - public void Test_8930() - { - } - [Fact] - public void Test_8931() - { - } - [Fact] - public void Test_8932() - { - } - [Fact] - public void Test_8933() - { - } - [Fact] - public void Test_8934() - { - } - [Fact] - public void Test_8935() - { - } - [Fact] - public void Test_8936() - { - } - [Fact] - public void Test_8937() - { - } - [Fact] - public void Test_8938() - { - } - [Fact] - public void Test_8939() - { - } - [Fact] - public void Test_8940() - { - } - [Fact] - public void Test_8941() - { - } - [Fact] - public void Test_8942() - { - } - [Fact] - public void Test_8943() - { - } - [Fact] - public void Test_8944() - { - } - [Fact] - public void Test_8945() - { - } - [Fact] - public void Test_8946() - { - } - [Fact] - public void Test_8947() - { - } - [Fact] - public void Test_8948() - { - } - [Fact] - public void Test_8949() - { - } - [Fact] - public void Test_8950() - { - } - [Fact] - public void Test_8951() - { - } - [Fact] - public void Test_8952() - { - } - [Fact] - public void Test_8953() - { - } - [Fact] - public void Test_8954() - { - } - [Fact] - public void Test_8955() - { - } - [Fact] - public void Test_8956() - { - } - [Fact] - public void Test_8957() - { - } - [Fact] - public void Test_8958() - { - } - [Fact] - public void Test_8959() - { - } - [Fact] - public void Test_8960() - { - } - [Fact] - public void Test_8961() - { - } - [Fact] - public void Test_8962() - { - } - [Fact] - public void Test_8963() - { - } - [Fact] - public void Test_8964() - { - } - [Fact] - public void Test_8965() - { - } - [Fact] - public void Test_8966() - { - } - [Fact] - public void Test_8967() - { - } - [Fact] - public void Test_8968() - { - } - [Fact] - public void Test_8969() - { - } - [Fact] - public void Test_8970() - { - } - [Fact] - public void Test_8971() - { - } - [Fact] - public void Test_8972() - { - } - [Fact] - public void Test_8973() - { - } - [Fact] - public void Test_8974() - { - } - [Fact] - public void Test_8975() - { - } - [Fact] - public void Test_8976() - { - } - [Fact] - public void Test_8977() - { - } - [Fact] - public void Test_8978() - { - } - [Fact] - public void Test_8979() - { - } - [Fact] - public void Test_8980() - { - } - [Fact] - public void Test_8981() - { - } - [Fact] - public void Test_8982() - { - } - [Fact] - public void Test_8983() - { - } - [Fact] - public void Test_8984() - { - } - [Fact] - public void Test_8985() - { - } - [Fact] - public void Test_8986() - { - } - [Fact] - public void Test_8987() - { - } - [Fact] - public void Test_8988() - { - } - [Fact] - public void Test_8989() - { - } - [Fact] - public void Test_8990() - { - } - [Fact] - public void Test_8991() - { - } - [Fact] - public void Test_8992() - { - } - [Fact] - public void Test_8993() - { - } - [Fact] - public void Test_8994() - { - } - [Fact] - public void Test_8995() - { - } - [Fact] - public void Test_8996() - { - } - [Fact] - public void Test_8997() - { - } - [Fact] - public void Test_8998() - { - } - [Fact] - public void Test_8999() - { - } - [Fact] - public void Test_9000() - { - } - [Fact] - public void Test_9001() - { - } - [Fact] - public void Test_9002() - { - } - [Fact] - public void Test_9003() - { - } - [Fact] - public void Test_9004() - { - } - [Fact] - public void Test_9005() - { - } - [Fact] - public void Test_9006() - { - } - [Fact] - public void Test_9007() - { - } - [Fact] - public void Test_9008() - { - } - [Fact] - public void Test_9009() - { - } - [Fact] - public void Test_9010() - { - } - [Fact] - public void Test_9011() - { - } - [Fact] - public void Test_9012() - { - } - [Fact] - public void Test_9013() - { - } - [Fact] - public void Test_9014() - { - } - [Fact] - public void Test_9015() - { - } - [Fact] - public void Test_9016() - { - } - [Fact] - public void Test_9017() - { - } - [Fact] - public void Test_9018() - { - } - [Fact] - public void Test_9019() - { - } - [Fact] - public void Test_9020() - { - } - [Fact] - public void Test_9021() - { - } - [Fact] - public void Test_9022() - { - } - [Fact] - public void Test_9023() - { - } - [Fact] - public void Test_9024() - { - } - [Fact] - public void Test_9025() - { - } - [Fact] - public void Test_9026() - { - } - [Fact] - public void Test_9027() - { - } - [Fact] - public void Test_9028() - { - } - [Fact] - public void Test_9029() - { - } - [Fact] - public void Test_9030() - { - } - [Fact] - public void Test_9031() - { - } - [Fact] - public void Test_9032() - { - } - [Fact] - public void Test_9033() - { - } - [Fact] - public void Test_9034() - { - } - [Fact] - public void Test_9035() - { - } - [Fact] - public void Test_9036() - { - } - [Fact] - public void Test_9037() - { - } - [Fact] - public void Test_9038() - { - } - [Fact] - public void Test_9039() - { - } - [Fact] - public void Test_9040() - { - } - [Fact] - public void Test_9041() - { - } - [Fact] - public void Test_9042() - { - } - [Fact] - public void Test_9043() - { - } - [Fact] - public void Test_9044() - { - } - [Fact] - public void Test_9045() - { - } - [Fact] - public void Test_9046() - { - } - [Fact] - public void Test_9047() - { - } - [Fact] - public void Test_9048() - { - } - [Fact] - public void Test_9049() - { - } - [Fact] - public void Test_9050() - { - } - [Fact] - public void Test_9051() - { - } - [Fact] - public void Test_9052() - { - } - [Fact] - public void Test_9053() - { - } - [Fact] - public void Test_9054() - { - } - [Fact] - public void Test_9055() - { - } - [Fact] - public void Test_9056() - { - } - [Fact] - public void Test_9057() - { - } - [Fact] - public void Test_9058() - { - } - [Fact] - public void Test_9059() - { - } - [Fact] - public void Test_9060() - { - } - [Fact] - public void Test_9061() - { - } - [Fact] - public void Test_9062() - { - } - [Fact] - public void Test_9063() - { - } - [Fact] - public void Test_9064() - { - } - [Fact] - public void Test_9065() - { - } - [Fact] - public void Test_9066() - { - } - [Fact] - public void Test_9067() - { - } - [Fact] - public void Test_9068() - { - } - [Fact] - public void Test_9069() - { - } - [Fact] - public void Test_9070() - { - } - [Fact] - public void Test_9071() - { - } - [Fact] - public void Test_9072() - { - } - [Fact] - public void Test_9073() - { - } - [Fact] - public void Test_9074() - { - } - [Fact] - public void Test_9075() - { - } - [Fact] - public void Test_9076() - { - } - [Fact] - public void Test_9077() - { - } - [Fact] - public void Test_9078() - { - } - [Fact] - public void Test_9079() - { - } - [Fact] - public void Test_9080() - { - } - [Fact] - public void Test_9081() - { - } - [Fact] - public void Test_9082() - { - } - [Fact] - public void Test_9083() - { - } - [Fact] - public void Test_9084() - { - } - [Fact] - public void Test_9085() - { - } - [Fact] - public void Test_9086() - { - } - [Fact] - public void Test_9087() - { - } - [Fact] - public void Test_9088() - { - } - [Fact] - public void Test_9089() - { - } - [Fact] - public void Test_9090() - { - } - [Fact] - public void Test_9091() - { - } - [Fact] - public void Test_9092() - { - } - [Fact] - public void Test_9093() - { - } - [Fact] - public void Test_9094() - { - } - [Fact] - public void Test_9095() - { - } - [Fact] - public void Test_9096() - { - } - [Fact] - public void Test_9097() - { - } - [Fact] - public void Test_9098() - { - } - [Fact] - public void Test_9099() - { - } - [Fact] - public void Test_9100() - { - } - [Fact] - public void Test_9101() - { - } - [Fact] - public void Test_9102() - { - } - [Fact] - public void Test_9103() - { - } - [Fact] - public void Test_9104() - { - } - [Fact] - public void Test_9105() - { - } - [Fact] - public void Test_9106() - { - } - [Fact] - public void Test_9107() - { - } - [Fact] - public void Test_9108() - { - } - [Fact] - public void Test_9109() - { - } - [Fact] - public void Test_9110() - { - } - [Fact] - public void Test_9111() - { - } - [Fact] - public void Test_9112() - { - } - [Fact] - public void Test_9113() - { - } - [Fact] - public void Test_9114() - { - } - [Fact] - public void Test_9115() - { - } - [Fact] - public void Test_9116() - { - } - [Fact] - public void Test_9117() - { - } - [Fact] - public void Test_9118() - { - } - [Fact] - public void Test_9119() - { - } - [Fact] - public void Test_9120() - { - } - [Fact] - public void Test_9121() - { - } - [Fact] - public void Test_9122() - { - } - [Fact] - public void Test_9123() - { - } - [Fact] - public void Test_9124() - { - } - [Fact] - public void Test_9125() - { - } - [Fact] - public void Test_9126() - { - } - [Fact] - public void Test_9127() - { - } - [Fact] - public void Test_9128() - { - } - [Fact] - public void Test_9129() - { - } - [Fact] - public void Test_9130() - { - } - [Fact] - public void Test_9131() - { - } - [Fact] - public void Test_9132() - { - } - [Fact] - public void Test_9133() - { - } - [Fact] - public void Test_9134() - { - } - [Fact] - public void Test_9135() - { - } - [Fact] - public void Test_9136() - { - } - [Fact] - public void Test_9137() - { - } - [Fact] - public void Test_9138() - { - } - [Fact] - public void Test_9139() - { - } - [Fact] - public void Test_9140() - { - } - [Fact] - public void Test_9141() - { - } - [Fact] - public void Test_9142() - { - } - [Fact] - public void Test_9143() - { - } - [Fact] - public void Test_9144() - { - } - [Fact] - public void Test_9145() - { - } - [Fact] - public void Test_9146() - { - } - [Fact] - public void Test_9147() - { - } - [Fact] - public void Test_9148() - { - } - [Fact] - public void Test_9149() - { - } - [Fact] - public void Test_9150() - { - } - [Fact] - public void Test_9151() - { - } - [Fact] - public void Test_9152() - { - } - [Fact] - public void Test_9153() - { - } - [Fact] - public void Test_9154() - { - } - [Fact] - public void Test_9155() - { - } - [Fact] - public void Test_9156() - { - } - [Fact] - public void Test_9157() - { - } - [Fact] - public void Test_9158() - { - } - [Fact] - public void Test_9159() - { - } - [Fact] - public void Test_9160() - { - } - [Fact] - public void Test_9161() - { - } - [Fact] - public void Test_9162() - { - } - [Fact] - public void Test_9163() - { - } - [Fact] - public void Test_9164() - { - } - [Fact] - public void Test_9165() - { - } - [Fact] - public void Test_9166() - { - } - [Fact] - public void Test_9167() - { - } - [Fact] - public void Test_9168() - { - } - [Fact] - public void Test_9169() - { - } - [Fact] - public void Test_9170() - { - } - [Fact] - public void Test_9171() - { - } - [Fact] - public void Test_9172() - { - } - [Fact] - public void Test_9173() - { - } - [Fact] - public void Test_9174() - { - } - [Fact] - public void Test_9175() - { - } - [Fact] - public void Test_9176() - { - } - [Fact] - public void Test_9177() - { - } - [Fact] - public void Test_9178() - { - } - [Fact] - public void Test_9179() - { - } - [Fact] - public void Test_9180() - { - } - [Fact] - public void Test_9181() - { - } - [Fact] - public void Test_9182() - { - } - [Fact] - public void Test_9183() - { - } - [Fact] - public void Test_9184() - { - } - [Fact] - public void Test_9185() - { - } - [Fact] - public void Test_9186() - { - } - [Fact] - public void Test_9187() - { - } - [Fact] - public void Test_9188() - { - } - [Fact] - public void Test_9189() - { - } - [Fact] - public void Test_9190() - { - } - [Fact] - public void Test_9191() - { - } - [Fact] - public void Test_9192() - { - } - [Fact] - public void Test_9193() - { - } - [Fact] - public void Test_9194() - { - } - [Fact] - public void Test_9195() - { - } - [Fact] - public void Test_9196() - { - } - [Fact] - public void Test_9197() - { - } - [Fact] - public void Test_9198() - { - } - [Fact] - public void Test_9199() - { - } - [Fact] - public void Test_9200() - { - } - [Fact] - public void Test_9201() - { - } - [Fact] - public void Test_9202() - { - } - [Fact] - public void Test_9203() - { - } - [Fact] - public void Test_9204() - { - } - [Fact] - public void Test_9205() - { - } - [Fact] - public void Test_9206() - { - } - [Fact] - public void Test_9207() - { - } - [Fact] - public void Test_9208() - { - } - [Fact] - public void Test_9209() - { - } - [Fact] - public void Test_9210() - { - } - [Fact] - public void Test_9211() - { - } - [Fact] - public void Test_9212() - { - } - [Fact] - public void Test_9213() - { - } - [Fact] - public void Test_9214() - { - } - [Fact] - public void Test_9215() - { - } - [Fact] - public void Test_9216() - { - } - [Fact] - public void Test_9217() - { - } - [Fact] - public void Test_9218() - { - } - [Fact] - public void Test_9219() - { - } - [Fact] - public void Test_9220() - { - } - [Fact] - public void Test_9221() - { - } - [Fact] - public void Test_9222() - { - } - [Fact] - public void Test_9223() - { - } - [Fact] - public void Test_9224() - { - } - [Fact] - public void Test_9225() - { - } - [Fact] - public void Test_9226() - { - } - [Fact] - public void Test_9227() - { - } - [Fact] - public void Test_9228() - { - } - [Fact] - public void Test_9229() - { - } - [Fact] - public void Test_9230() - { - } - [Fact] - public void Test_9231() - { - } - [Fact] - public void Test_9232() - { - } - [Fact] - public void Test_9233() - { - } - [Fact] - public void Test_9234() - { - } - [Fact] - public void Test_9235() - { - } - [Fact] - public void Test_9236() - { - } - [Fact] - public void Test_9237() - { - } - [Fact] - public void Test_9238() - { - } - [Fact] - public void Test_9239() - { - } - [Fact] - public void Test_9240() - { - } - [Fact] - public void Test_9241() - { - } - [Fact] - public void Test_9242() - { - } - [Fact] - public void Test_9243() - { - } - [Fact] - public void Test_9244() - { - } - [Fact] - public void Test_9245() - { - } - [Fact] - public void Test_9246() - { - } - [Fact] - public void Test_9247() - { - } - [Fact] - public void Test_9248() - { - } - [Fact] - public void Test_9249() - { - } - [Fact] - public void Test_9250() - { - } - [Fact] - public void Test_9251() - { - } - [Fact] - public void Test_9252() - { - } - [Fact] - public void Test_9253() - { - } - [Fact] - public void Test_9254() - { - } - [Fact] - public void Test_9255() - { - } - [Fact] - public void Test_9256() - { - } - [Fact] - public void Test_9257() - { - } - [Fact] - public void Test_9258() - { - } - [Fact] - public void Test_9259() - { - } - [Fact] - public void Test_9260() - { - } - [Fact] - public void Test_9261() - { - } - [Fact] - public void Test_9262() - { - } - [Fact] - public void Test_9263() - { - } - [Fact] - public void Test_9264() - { - } - [Fact] - public void Test_9265() - { - } - [Fact] - public void Test_9266() - { - } - [Fact] - public void Test_9267() - { - } - [Fact] - public void Test_9268() - { - } - [Fact] - public void Test_9269() - { - } - [Fact] - public void Test_9270() - { - } - [Fact] - public void Test_9271() - { - } - [Fact] - public void Test_9272() - { - } - [Fact] - public void Test_9273() - { - } - [Fact] - public void Test_9274() - { - } - [Fact] - public void Test_9275() - { - } - [Fact] - public void Test_9276() - { - } - [Fact] - public void Test_9277() - { - } - [Fact] - public void Test_9278() - { - } - [Fact] - public void Test_9279() - { - } - [Fact] - public void Test_9280() - { - } - [Fact] - public void Test_9281() - { - } - [Fact] - public void Test_9282() - { - } - [Fact] - public void Test_9283() - { - } - [Fact] - public void Test_9284() - { - } - [Fact] - public void Test_9285() - { - } - [Fact] - public void Test_9286() - { - } - [Fact] - public void Test_9287() - { - } - [Fact] - public void Test_9288() - { - } - [Fact] - public void Test_9289() - { - } - [Fact] - public void Test_9290() - { - } - [Fact] - public void Test_9291() - { - } - [Fact] - public void Test_9292() - { - } - [Fact] - public void Test_9293() - { - } - [Fact] - public void Test_9294() - { - } - [Fact] - public void Test_9295() - { - } - [Fact] - public void Test_9296() - { - } - [Fact] - public void Test_9297() - { - } - [Fact] - public void Test_9298() - { - } - [Fact] - public void Test_9299() - { - } - [Fact] - public void Test_9300() - { - } - [Fact] - public void Test_9301() - { - } - [Fact] - public void Test_9302() - { - } - [Fact] - public void Test_9303() - { - } - [Fact] - public void Test_9304() - { - } - [Fact] - public void Test_9305() - { - } - [Fact] - public void Test_9306() - { - } - [Fact] - public void Test_9307() - { - } - [Fact] - public void Test_9308() - { - } - [Fact] - public void Test_9309() - { - } - [Fact] - public void Test_9310() - { - } - [Fact] - public void Test_9311() - { - } - [Fact] - public void Test_9312() - { - } - [Fact] - public void Test_9313() - { - } - [Fact] - public void Test_9314() - { - } - [Fact] - public void Test_9315() - { - } - [Fact] - public void Test_9316() - { - } - [Fact] - public void Test_9317() - { - } - [Fact] - public void Test_9318() - { - } - [Fact] - public void Test_9319() - { - } - [Fact] - public void Test_9320() - { - } - [Fact] - public void Test_9321() - { - } - [Fact] - public void Test_9322() - { - } - [Fact] - public void Test_9323() - { - } - [Fact] - public void Test_9324() - { - } - [Fact] - public void Test_9325() - { - } - [Fact] - public void Test_9326() - { - } - [Fact] - public void Test_9327() - { - } - [Fact] - public void Test_9328() - { - } - [Fact] - public void Test_9329() - { - } - [Fact] - public void Test_9330() - { - } - [Fact] - public void Test_9331() - { - } - [Fact] - public void Test_9332() - { - } - [Fact] - public void Test_9333() - { - } - [Fact] - public void Test_9334() - { - } - [Fact] - public void Test_9335() - { - } - [Fact] - public void Test_9336() - { - } - [Fact] - public void Test_9337() - { - } - [Fact] - public void Test_9338() - { - } - [Fact] - public void Test_9339() - { - } - [Fact] - public void Test_9340() - { - } - [Fact] - public void Test_9341() - { - } - [Fact] - public void Test_9342() - { - } - [Fact] - public void Test_9343() - { - } - [Fact] - public void Test_9344() - { - } - [Fact] - public void Test_9345() - { - } - [Fact] - public void Test_9346() - { - } - [Fact] - public void Test_9347() - { - } - [Fact] - public void Test_9348() - { - } - [Fact] - public void Test_9349() - { - } - [Fact] - public void Test_9350() - { - } - [Fact] - public void Test_9351() - { - } - [Fact] - public void Test_9352() - { - } - [Fact] - public void Test_9353() - { - } - [Fact] - public void Test_9354() - { - } - [Fact] - public void Test_9355() - { - } - [Fact] - public void Test_9356() - { - } - [Fact] - public void Test_9357() - { - } - [Fact] - public void Test_9358() - { - } - [Fact] - public void Test_9359() - { - } - [Fact] - public void Test_9360() - { - } - [Fact] - public void Test_9361() - { - } - [Fact] - public void Test_9362() - { - } - [Fact] - public void Test_9363() - { - } - [Fact] - public void Test_9364() - { - } - [Fact] - public void Test_9365() - { - } - [Fact] - public void Test_9366() - { - } - [Fact] - public void Test_9367() - { - } - [Fact] - public void Test_9368() - { - } - [Fact] - public void Test_9369() - { - } - [Fact] - public void Test_9370() - { - } - [Fact] - public void Test_9371() - { - } - [Fact] - public void Test_9372() - { - } - [Fact] - public void Test_9373() - { - } - [Fact] - public void Test_9374() - { - } - [Fact] - public void Test_9375() - { - } - [Fact] - public void Test_9376() - { - } - [Fact] - public void Test_9377() - { - } - [Fact] - public void Test_9378() - { - } - [Fact] - public void Test_9379() - { - } - [Fact] - public void Test_9380() - { - } - [Fact] - public void Test_9381() - { - } - [Fact] - public void Test_9382() - { - } - [Fact] - public void Test_9383() - { - } - [Fact] - public void Test_9384() - { - } - [Fact] - public void Test_9385() - { - } - [Fact] - public void Test_9386() - { - } - [Fact] - public void Test_9387() - { - } - [Fact] - public void Test_9388() - { - } - [Fact] - public void Test_9389() - { - } - [Fact] - public void Test_9390() - { - } - [Fact] - public void Test_9391() - { - } - [Fact] - public void Test_9392() - { - } - [Fact] - public void Test_9393() - { - } - [Fact] - public void Test_9394() - { - } - [Fact] - public void Test_9395() - { - } - [Fact] - public void Test_9396() - { - } - [Fact] - public void Test_9397() - { - } - [Fact] - public void Test_9398() - { - } - [Fact] - public void Test_9399() - { - } - [Fact] - public void Test_9400() - { - } - [Fact] - public void Test_9401() - { - } - [Fact] - public void Test_9402() - { - } - [Fact] - public void Test_9403() - { - } - [Fact] - public void Test_9404() - { - } - [Fact] - public void Test_9405() - { - } - [Fact] - public void Test_9406() - { - } - [Fact] - public void Test_9407() - { - } - [Fact] - public void Test_9408() - { - } - [Fact] - public void Test_9409() - { - } - [Fact] - public void Test_9410() - { - } - [Fact] - public void Test_9411() - { - } - [Fact] - public void Test_9412() - { - } - [Fact] - public void Test_9413() - { - } - [Fact] - public void Test_9414() - { - } - [Fact] - public void Test_9415() - { - } - [Fact] - public void Test_9416() - { - } - [Fact] - public void Test_9417() - { - } - [Fact] - public void Test_9418() - { - } - [Fact] - public void Test_9419() - { - } - [Fact] - public void Test_9420() - { - } - [Fact] - public void Test_9421() - { - } - [Fact] - public void Test_9422() - { - } - [Fact] - public void Test_9423() - { - } - [Fact] - public void Test_9424() - { - } - [Fact] - public void Test_9425() - { - } - [Fact] - public void Test_9426() - { - } - [Fact] - public void Test_9427() - { - } - [Fact] - public void Test_9428() - { - } - [Fact] - public void Test_9429() - { - } - [Fact] - public void Test_9430() - { - } - [Fact] - public void Test_9431() - { - } - [Fact] - public void Test_9432() - { - } - [Fact] - public void Test_9433() - { - } - [Fact] - public void Test_9434() - { - } - [Fact] - public void Test_9435() - { - } - [Fact] - public void Test_9436() - { - } - [Fact] - public void Test_9437() - { - } - [Fact] - public void Test_9438() - { - } - [Fact] - public void Test_9439() - { - } - [Fact] - public void Test_9440() - { - } - [Fact] - public void Test_9441() - { - } - [Fact] - public void Test_9442() - { - } - [Fact] - public void Test_9443() - { - } - [Fact] - public void Test_9444() - { - } - [Fact] - public void Test_9445() - { - } - [Fact] - public void Test_9446() - { - } - [Fact] - public void Test_9447() - { - } - [Fact] - public void Test_9448() - { - } - [Fact] - public void Test_9449() - { - } - [Fact] - public void Test_9450() - { - } - [Fact] - public void Test_9451() - { - } - [Fact] - public void Test_9452() - { - } - [Fact] - public void Test_9453() - { - } - [Fact] - public void Test_9454() - { - } - [Fact] - public void Test_9455() - { - } - [Fact] - public void Test_9456() - { - } - [Fact] - public void Test_9457() - { - } - [Fact] - public void Test_9458() - { - } - [Fact] - public void Test_9459() - { - } - [Fact] - public void Test_9460() - { - } - [Fact] - public void Test_9461() - { - } - [Fact] - public void Test_9462() - { - } - [Fact] - public void Test_9463() - { - } - [Fact] - public void Test_9464() - { - } - [Fact] - public void Test_9465() - { - } - [Fact] - public void Test_9466() - { - } - [Fact] - public void Test_9467() - { - } - [Fact] - public void Test_9468() - { - } - [Fact] - public void Test_9469() - { - } - [Fact] - public void Test_9470() - { - } - [Fact] - public void Test_9471() - { - } - [Fact] - public void Test_9472() - { - } - [Fact] - public void Test_9473() - { - } - [Fact] - public void Test_9474() - { - } - [Fact] - public void Test_9475() - { - } - [Fact] - public void Test_9476() - { - } - [Fact] - public void Test_9477() - { - } - [Fact] - public void Test_9478() - { - } - [Fact] - public void Test_9479() - { - } - [Fact] - public void Test_9480() - { - } - [Fact] - public void Test_9481() - { - } - [Fact] - public void Test_9482() - { - } - [Fact] - public void Test_9483() - { - } - [Fact] - public void Test_9484() - { - } - [Fact] - public void Test_9485() - { - } - [Fact] - public void Test_9486() - { - } - [Fact] - public void Test_9487() - { - } - [Fact] - public void Test_9488() - { - } - [Fact] - public void Test_9489() - { - } - [Fact] - public void Test_9490() - { - } - [Fact] - public void Test_9491() - { - } - [Fact] - public void Test_9492() - { - } - [Fact] - public void Test_9493() - { - } - [Fact] - public void Test_9494() - { - } - [Fact] - public void Test_9495() - { - } - [Fact] - public void Test_9496() - { - } - [Fact] - public void Test_9497() - { - } - [Fact] - public void Test_9498() - { - } - [Fact] - public void Test_9499() - { - } - [Fact] - public void Test_9500() - { - } - [Fact] - public void Test_9501() - { - } - [Fact] - public void Test_9502() - { - } - [Fact] - public void Test_9503() - { - } - [Fact] - public void Test_9504() - { - } - [Fact] - public void Test_9505() - { - } - [Fact] - public void Test_9506() - { - } - [Fact] - public void Test_9507() - { - } - [Fact] - public void Test_9508() - { - } - [Fact] - public void Test_9509() - { - } - [Fact] - public void Test_9510() - { - } - [Fact] - public void Test_9511() - { - } - [Fact] - public void Test_9512() - { - } - [Fact] - public void Test_9513() - { - } - [Fact] - public void Test_9514() - { - } - [Fact] - public void Test_9515() - { - } - [Fact] - public void Test_9516() - { - } - [Fact] - public void Test_9517() - { - } - [Fact] - public void Test_9518() - { - } - [Fact] - public void Test_9519() - { - } - [Fact] - public void Test_9520() - { - } - [Fact] - public void Test_9521() - { - } - [Fact] - public void Test_9522() - { - } - [Fact] - public void Test_9523() - { - } - [Fact] - public void Test_9524() - { - } - [Fact] - public void Test_9525() - { - } - [Fact] - public void Test_9526() - { - } - [Fact] - public void Test_9527() - { - } - [Fact] - public void Test_9528() - { - } - [Fact] - public void Test_9529() - { - } - [Fact] - public void Test_9530() - { - } - [Fact] - public void Test_9531() - { - } - [Fact] - public void Test_9532() - { - } - [Fact] - public void Test_9533() - { - } - [Fact] - public void Test_9534() - { - } - [Fact] - public void Test_9535() - { - } - [Fact] - public void Test_9536() - { - } - [Fact] - public void Test_9537() - { - } - [Fact] - public void Test_9538() - { - } - [Fact] - public void Test_9539() - { - } - [Fact] - public void Test_9540() - { - } - [Fact] - public void Test_9541() - { - } - [Fact] - public void Test_9542() - { - } - [Fact] - public void Test_9543() - { - } - [Fact] - public void Test_9544() - { - } - [Fact] - public void Test_9545() - { - } - [Fact] - public void Test_9546() - { - } - [Fact] - public void Test_9547() - { - } - [Fact] - public void Test_9548() - { - } - [Fact] - public void Test_9549() - { - } - [Fact] - public void Test_9550() - { - } - [Fact] - public void Test_9551() - { - } - [Fact] - public void Test_9552() - { - } - [Fact] - public void Test_9553() - { - } - [Fact] - public void Test_9554() - { - } - [Fact] - public void Test_9555() - { - } - [Fact] - public void Test_9556() - { - } - [Fact] - public void Test_9557() - { - } - [Fact] - public void Test_9558() - { - } - [Fact] - public void Test_9559() - { - } - [Fact] - public void Test_9560() - { - } - [Fact] - public void Test_9561() - { - } - [Fact] - public void Test_9562() - { - } - [Fact] - public void Test_9563() - { - } - [Fact] - public void Test_9564() - { - } - [Fact] - public void Test_9565() - { - } - [Fact] - public void Test_9566() - { - } - [Fact] - public void Test_9567() - { - } - [Fact] - public void Test_9568() - { - } - [Fact] - public void Test_9569() - { - } - [Fact] - public void Test_9570() - { - } - [Fact] - public void Test_9571() - { - } - [Fact] - public void Test_9572() - { - } - [Fact] - public void Test_9573() - { - } - [Fact] - public void Test_9574() - { - } - [Fact] - public void Test_9575() - { - } - [Fact] - public void Test_9576() - { - } - [Fact] - public void Test_9577() - { - } - [Fact] - public void Test_9578() - { - } - [Fact] - public void Test_9579() - { - } - [Fact] - public void Test_9580() - { - } - [Fact] - public void Test_9581() - { - } - [Fact] - public void Test_9582() - { - } - [Fact] - public void Test_9583() - { - } - [Fact] - public void Test_9584() - { - } - [Fact] - public void Test_9585() - { - } - [Fact] - public void Test_9586() - { - } - [Fact] - public void Test_9587() - { - } - [Fact] - public void Test_9588() - { - } - [Fact] - public void Test_9589() - { - } - [Fact] - public void Test_9590() - { - } - [Fact] - public void Test_9591() - { - } - [Fact] - public void Test_9592() - { - } - [Fact] - public void Test_9593() - { - } - [Fact] - public void Test_9594() - { - } - [Fact] - public void Test_9595() - { - } - [Fact] - public void Test_9596() - { - } - [Fact] - public void Test_9597() - { - } - [Fact] - public void Test_9598() - { - } - [Fact] - public void Test_9599() - { - } - [Fact] - public void Test_9600() - { - } - [Fact] - public void Test_9601() - { - } - [Fact] - public void Test_9602() - { - } - [Fact] - public void Test_9603() - { - } - [Fact] - public void Test_9604() - { - } - [Fact] - public void Test_9605() - { - } - [Fact] - public void Test_9606() - { - } - [Fact] - public void Test_9607() - { - } - [Fact] - public void Test_9608() - { - } - [Fact] - public void Test_9609() - { - } - [Fact] - public void Test_9610() - { - } - [Fact] - public void Test_9611() - { - } - [Fact] - public void Test_9612() - { - } - [Fact] - public void Test_9613() - { - } - [Fact] - public void Test_9614() - { - } - [Fact] - public void Test_9615() - { - } - [Fact] - public void Test_9616() - { - } - [Fact] - public void Test_9617() - { - } - [Fact] - public void Test_9618() - { - } - [Fact] - public void Test_9619() - { - } - [Fact] - public void Test_9620() - { - } - [Fact] - public void Test_9621() - { - } - [Fact] - public void Test_9622() - { - } - [Fact] - public void Test_9623() - { - } - [Fact] - public void Test_9624() - { - } - [Fact] - public void Test_9625() - { - } - [Fact] - public void Test_9626() - { - } - [Fact] - public void Test_9627() - { - } - [Fact] - public void Test_9628() - { - } - [Fact] - public void Test_9629() - { - } - [Fact] - public void Test_9630() - { - } - [Fact] - public void Test_9631() - { - } - [Fact] - public void Test_9632() - { - } - [Fact] - public void Test_9633() - { - } - [Fact] - public void Test_9634() - { - } - [Fact] - public void Test_9635() - { - } - [Fact] - public void Test_9636() - { - } - [Fact] - public void Test_9637() - { - } - [Fact] - public void Test_9638() - { - } - [Fact] - public void Test_9639() - { - } - [Fact] - public void Test_9640() - { - } - [Fact] - public void Test_9641() - { - } - [Fact] - public void Test_9642() - { - } - [Fact] - public void Test_9643() - { - } - [Fact] - public void Test_9644() - { - } - [Fact] - public void Test_9645() - { - } - [Fact] - public void Test_9646() - { - } - [Fact] - public void Test_9647() - { - } - [Fact] - public void Test_9648() - { - } - [Fact] - public void Test_9649() - { - } - [Fact] - public void Test_9650() - { - } - [Fact] - public void Test_9651() - { - } - [Fact] - public void Test_9652() - { - } - [Fact] - public void Test_9653() - { - } - [Fact] - public void Test_9654() - { - } - [Fact] - public void Test_9655() - { - } - [Fact] - public void Test_9656() - { - } - [Fact] - public void Test_9657() - { - } - [Fact] - public void Test_9658() - { - } - [Fact] - public void Test_9659() - { - } - [Fact] - public void Test_9660() - { - } - [Fact] - public void Test_9661() - { - } - [Fact] - public void Test_9662() - { - } - [Fact] - public void Test_9663() - { - } - [Fact] - public void Test_9664() - { - } - [Fact] - public void Test_9665() - { - } - [Fact] - public void Test_9666() - { - } - [Fact] - public void Test_9667() - { - } - [Fact] - public void Test_9668() - { - } - [Fact] - public void Test_9669() - { - } - [Fact] - public void Test_9670() - { - } - [Fact] - public void Test_9671() - { - } - [Fact] - public void Test_9672() - { - } - [Fact] - public void Test_9673() - { - } - [Fact] - public void Test_9674() - { - } - [Fact] - public void Test_9675() - { - } - [Fact] - public void Test_9676() - { - } - [Fact] - public void Test_9677() - { - } - [Fact] - public void Test_9678() - { - } - [Fact] - public void Test_9679() - { - } - [Fact] - public void Test_9680() - { - } - [Fact] - public void Test_9681() - { - } - [Fact] - public void Test_9682() - { - } - [Fact] - public void Test_9683() - { - } - [Fact] - public void Test_9684() - { - } - [Fact] - public void Test_9685() - { - } - [Fact] - public void Test_9686() - { - } - [Fact] - public void Test_9687() - { - } - [Fact] - public void Test_9688() - { - } - [Fact] - public void Test_9689() - { - } - [Fact] - public void Test_9690() - { - } - [Fact] - public void Test_9691() - { - } - [Fact] - public void Test_9692() - { - } - [Fact] - public void Test_9693() - { - } - [Fact] - public void Test_9694() - { - } - [Fact] - public void Test_9695() - { - } - [Fact] - public void Test_9696() - { - } - [Fact] - public void Test_9697() - { - } - [Fact] - public void Test_9698() - { - } - [Fact] - public void Test_9699() - { - } - [Fact] - public void Test_9700() - { - } - [Fact] - public void Test_9701() - { - } - [Fact] - public void Test_9702() - { - } - [Fact] - public void Test_9703() - { - } - [Fact] - public void Test_9704() - { - } - [Fact] - public void Test_9705() - { - } - [Fact] - public void Test_9706() - { - } - [Fact] - public void Test_9707() - { - } - [Fact] - public void Test_9708() - { - } - [Fact] - public void Test_9709() - { - } - [Fact] - public void Test_9710() - { - } - [Fact] - public void Test_9711() - { - } - [Fact] - public void Test_9712() - { - } - [Fact] - public void Test_9713() - { - } - [Fact] - public void Test_9714() - { - } - [Fact] - public void Test_9715() - { - } - [Fact] - public void Test_9716() - { - } - [Fact] - public void Test_9717() - { - } - [Fact] - public void Test_9718() - { - } - [Fact] - public void Test_9719() - { - } - [Fact] - public void Test_9720() - { - } - [Fact] - public void Test_9721() - { - } - [Fact] - public void Test_9722() - { - } - [Fact] - public void Test_9723() - { - } - [Fact] - public void Test_9724() - { - } - [Fact] - public void Test_9725() - { - } - [Fact] - public void Test_9726() - { - } - [Fact] - public void Test_9727() - { - } - [Fact] - public void Test_9728() - { - } - [Fact] - public void Test_9729() - { - } - [Fact] - public void Test_9730() - { - } - [Fact] - public void Test_9731() - { - } - [Fact] - public void Test_9732() - { - } - [Fact] - public void Test_9733() - { - } - [Fact] - public void Test_9734() - { - } - [Fact] - public void Test_9735() - { - } - [Fact] - public void Test_9736() - { - } - [Fact] - public void Test_9737() - { - } - [Fact] - public void Test_9738() - { - } - [Fact] - public void Test_9739() - { - } - [Fact] - public void Test_9740() - { - } - [Fact] - public void Test_9741() - { - } - [Fact] - public void Test_9742() - { - } - [Fact] - public void Test_9743() - { - } - [Fact] - public void Test_9744() - { - } - [Fact] - public void Test_9745() - { - } - [Fact] - public void Test_9746() - { - } - [Fact] - public void Test_9747() - { - } - [Fact] - public void Test_9748() - { - } - [Fact] - public void Test_9749() - { - } - [Fact] - public void Test_9750() - { - } - [Fact] - public void Test_9751() - { - } - [Fact] - public void Test_9752() - { - } - [Fact] - public void Test_9753() - { - } - [Fact] - public void Test_9754() - { - } - [Fact] - public void Test_9755() - { - } - [Fact] - public void Test_9756() - { - } - [Fact] - public void Test_9757() - { - } - [Fact] - public void Test_9758() - { - } - [Fact] - public void Test_9759() - { - } - [Fact] - public void Test_9760() - { - } - [Fact] - public void Test_9761() - { - } - [Fact] - public void Test_9762() - { - } - [Fact] - public void Test_9763() - { - } - [Fact] - public void Test_9764() - { - } - [Fact] - public void Test_9765() - { - } - [Fact] - public void Test_9766() - { - } - [Fact] - public void Test_9767() - { - } - [Fact] - public void Test_9768() - { - } - [Fact] - public void Test_9769() - { - } - [Fact] - public void Test_9770() - { - } - [Fact] - public void Test_9771() - { - } - [Fact] - public void Test_9772() - { - } - [Fact] - public void Test_9773() - { - } - [Fact] - public void Test_9774() - { - } - [Fact] - public void Test_9775() - { - } - [Fact] - public void Test_9776() - { - } - [Fact] - public void Test_9777() - { - } - [Fact] - public void Test_9778() - { - } - [Fact] - public void Test_9779() - { - } - [Fact] - public void Test_9780() - { - } - [Fact] - public void Test_9781() - { - } - [Fact] - public void Test_9782() - { - } - [Fact] - public void Test_9783() - { - } - [Fact] - public void Test_9784() - { - } - [Fact] - public void Test_9785() - { - } - [Fact] - public void Test_9786() - { - } - [Fact] - public void Test_9787() - { - } - [Fact] - public void Test_9788() - { - } - [Fact] - public void Test_9789() - { - } - [Fact] - public void Test_9790() - { - } - [Fact] - public void Test_9791() - { - } - [Fact] - public void Test_9792() - { - } - [Fact] - public void Test_9793() - { - } - [Fact] - public void Test_9794() - { - } - [Fact] - public void Test_9795() - { - } - [Fact] - public void Test_9796() - { - } - [Fact] - public void Test_9797() - { - } - [Fact] - public void Test_9798() - { - } - [Fact] - public void Test_9799() - { - } - [Fact] - public void Test_9800() - { - } - [Fact] - public void Test_9801() - { - } - [Fact] - public void Test_9802() - { - } - [Fact] - public void Test_9803() - { - } - [Fact] - public void Test_9804() - { - } - [Fact] - public void Test_9805() - { - } - [Fact] - public void Test_9806() - { - } - [Fact] - public void Test_9807() - { - } - [Fact] - public void Test_9808() - { - } - [Fact] - public void Test_9809() - { - } - [Fact] - public void Test_9810() - { - } - [Fact] - public void Test_9811() - { - } - [Fact] - public void Test_9812() - { - } - [Fact] - public void Test_9813() - { - } - [Fact] - public void Test_9814() - { - } - [Fact] - public void Test_9815() - { - } - [Fact] - public void Test_9816() - { - } - [Fact] - public void Test_9817() - { - } - [Fact] - public void Test_9818() - { - } - [Fact] - public void Test_9819() - { - } - [Fact] - public void Test_9820() - { - } - [Fact] - public void Test_9821() - { - } - [Fact] - public void Test_9822() - { - } - [Fact] - public void Test_9823() - { - } - [Fact] - public void Test_9824() - { - } - [Fact] - public void Test_9825() - { - } - [Fact] - public void Test_9826() - { - } - [Fact] - public void Test_9827() - { - } - [Fact] - public void Test_9828() - { - } - [Fact] - public void Test_9829() - { - } - [Fact] - public void Test_9830() - { - } - [Fact] - public void Test_9831() - { - } - [Fact] - public void Test_9832() - { - } - [Fact] - public void Test_9833() - { - } - [Fact] - public void Test_9834() - { - } - [Fact] - public void Test_9835() - { - } - [Fact] - public void Test_9836() - { - } - [Fact] - public void Test_9837() - { - } - [Fact] - public void Test_9838() - { - } - [Fact] - public void Test_9839() - { - } - [Fact] - public void Test_9840() - { - } - [Fact] - public void Test_9841() - { - } - [Fact] - public void Test_9842() - { - } - [Fact] - public void Test_9843() - { - } - [Fact] - public void Test_9844() - { - } - [Fact] - public void Test_9845() - { - } - [Fact] - public void Test_9846() - { - } - [Fact] - public void Test_9847() - { - } - [Fact] - public void Test_9848() - { - } - [Fact] - public void Test_9849() - { - } - [Fact] - public void Test_9850() - { - } - [Fact] - public void Test_9851() - { - } - [Fact] - public void Test_9852() - { - } - [Fact] - public void Test_9853() - { - } - [Fact] - public void Test_9854() - { - } - [Fact] - public void Test_9855() - { - } - [Fact] - public void Test_9856() - { - } - [Fact] - public void Test_9857() - { - } - [Fact] - public void Test_9858() - { - } - [Fact] - public void Test_9859() - { - } - [Fact] - public void Test_9860() - { - } - [Fact] - public void Test_9861() - { - } - [Fact] - public void Test_9862() - { - } - [Fact] - public void Test_9863() - { - } - [Fact] - public void Test_9864() - { - } - [Fact] - public void Test_9865() - { - } - [Fact] - public void Test_9866() - { - } - [Fact] - public void Test_9867() - { - } - [Fact] - public void Test_9868() - { - } - [Fact] - public void Test_9869() - { - } - [Fact] - public void Test_9870() - { - } - [Fact] - public void Test_9871() - { - } - [Fact] - public void Test_9872() - { - } - [Fact] - public void Test_9873() - { - } - [Fact] - public void Test_9874() - { - } - [Fact] - public void Test_9875() - { - } - [Fact] - public void Test_9876() - { - } - [Fact] - public void Test_9877() - { - } - [Fact] - public void Test_9878() - { - } - [Fact] - public void Test_9879() - { - } - [Fact] - public void Test_9880() - { - } - [Fact] - public void Test_9881() - { - } - [Fact] - public void Test_9882() - { - } - [Fact] - public void Test_9883() - { - } - [Fact] - public void Test_9884() - { - } - [Fact] - public void Test_9885() - { - } - [Fact] - public void Test_9886() - { - } - [Fact] - public void Test_9887() - { - } - [Fact] - public void Test_9888() - { - } - [Fact] - public void Test_9889() - { - } - [Fact] - public void Test_9890() - { - } - [Fact] - public void Test_9891() - { - } - [Fact] - public void Test_9892() - { - } - [Fact] - public void Test_9893() - { - } - [Fact] - public void Test_9894() - { - } - [Fact] - public void Test_9895() - { - } - [Fact] - public void Test_9896() - { - } - [Fact] - public void Test_9897() - { - } - [Fact] - public void Test_9898() - { - } - [Fact] - public void Test_9899() - { - } - [Fact] - public void Test_9900() - { - } - [Fact] - public void Test_9901() - { - } - [Fact] - public void Test_9902() - { - } - [Fact] - public void Test_9903() - { - } - [Fact] - public void Test_9904() - { - } - [Fact] - public void Test_9905() - { - } - [Fact] - public void Test_9906() - { - } - [Fact] - public void Test_9907() - { - } - [Fact] - public void Test_9908() - { - } - [Fact] - public void Test_9909() - { - } - [Fact] - public void Test_9910() - { - } - [Fact] - public void Test_9911() - { - } - [Fact] - public void Test_9912() - { - } - [Fact] - public void Test_9913() - { - } - [Fact] - public void Test_9914() - { - } - [Fact] - public void Test_9915() - { - } - [Fact] - public void Test_9916() - { - } - [Fact] - public void Test_9917() - { - } - [Fact] - public void Test_9918() - { - } - [Fact] - public void Test_9919() - { - } - [Fact] - public void Test_9920() - { - } - [Fact] - public void Test_9921() - { - } - [Fact] - public void Test_9922() - { - } - [Fact] - public void Test_9923() - { - } - [Fact] - public void Test_9924() - { - } - [Fact] - public void Test_9925() - { - } - [Fact] - public void Test_9926() - { - } - [Fact] - public void Test_9927() - { - } - [Fact] - public void Test_9928() - { - } - [Fact] - public void Test_9929() - { - } - [Fact] - public void Test_9930() - { - } - [Fact] - public void Test_9931() - { - } - [Fact] - public void Test_9932() - { - } - [Fact] - public void Test_9933() - { - } - [Fact] - public void Test_9934() - { - } - [Fact] - public void Test_9935() - { - } - [Fact] - public void Test_9936() - { - } - [Fact] - public void Test_9937() - { - } - [Fact] - public void Test_9938() - { - } - [Fact] - public void Test_9939() - { - } - [Fact] - public void Test_9940() - { - } - [Fact] - public void Test_9941() - { - } - [Fact] - public void Test_9942() - { - } - [Fact] - public void Test_9943() - { - } - [Fact] - public void Test_9944() - { - } - [Fact] - public void Test_9945() - { - } - [Fact] - public void Test_9946() - { - } - [Fact] - public void Test_9947() - { - } - [Fact] - public void Test_9948() - { - } - [Fact] - public void Test_9949() - { - } - [Fact] - public void Test_9950() - { - } - [Fact] - public void Test_9951() - { - } - [Fact] - public void Test_9952() - { - } - [Fact] - public void Test_9953() - { - } - [Fact] - public void Test_9954() - { - } - [Fact] - public void Test_9955() - { - } - [Fact] - public void Test_9956() - { - } - [Fact] - public void Test_9957() - { - } - [Fact] - public void Test_9958() - { - } - [Fact] - public void Test_9959() - { - } - [Fact] - public void Test_9960() - { - } - [Fact] - public void Test_9961() - { - } - [Fact] - public void Test_9962() - { - } - [Fact] - public void Test_9963() - { - } - [Fact] - public void Test_9964() - { - } - [Fact] - public void Test_9965() - { - } - [Fact] - public void Test_9966() - { - } - [Fact] - public void Test_9967() - { - } - [Fact] - public void Test_9968() - { - } - [Fact] - public void Test_9969() - { - } - [Fact] - public void Test_9970() - { - } - [Fact] - public void Test_9971() - { - } - [Fact] - public void Test_9972() - { - } - [Fact] - public void Test_9973() - { - } - [Fact] - public void Test_9974() - { - } - [Fact] - public void Test_9975() - { - } - [Fact] - public void Test_9976() - { - } - [Fact] - public void Test_9977() - { - } - [Fact] - public void Test_9978() - { - } - [Fact] - public void Test_9979() - { - } - [Fact] - public void Test_9980() - { - } - [Fact] - public void Test_9981() - { - } - [Fact] - public void Test_9982() - { - } - [Fact] - public void Test_9983() - { - } - [Fact] - public void Test_9984() - { - } - [Fact] - public void Test_9985() - { - } - [Fact] - public void Test_9986() - { - } - [Fact] - public void Test_9987() - { - } - [Fact] - public void Test_9988() - { - } - [Fact] - public void Test_9989() - { - } - [Fact] - public void Test_9990() - { - } - [Fact] - public void Test_9991() - { - } - [Fact] - public void Test_9992() - { - } - [Fact] - public void Test_9993() - { - } - [Fact] - public void Test_9994() - { - } - [Fact] - public void Test_9995() - { - } - [Fact] - public void Test_9996() - { - } - [Fact] - public void Test_9997() - { - } - [Fact] - public void Test_9998() - { - } - [Fact] - public void Test_9999() - { - } - [Fact] - public void Test_10000() - { - } - #endregion + #region PassingTests + [Fact] + public void Test_01() + { + } + [Fact] + public void Test_02() + { + } + [Fact] + public void Test_03() + { + } + [Fact] + public void Test_04() + { + } + [Fact] + public void Test_05() + { + } + [Fact] + public void Test_06() + { + } + [Fact] + public void Test_07() + { + } + [Fact] + public void Test_08() + { + } + [Fact] + public void Test_09() + { + } + [Fact] + public void Test_10() + { + } + [Fact] + public void Test_11() + { + } + [Fact] + public void Test_12() + { + } + [Fact] + public void Test_13() + { + } + [Fact] + public void Test_14() + { + } + [Fact] + public void Test_15() + { + } + [Fact] + public void Test_16() + { + } + [Fact] + public void Test_17() + { + } + [Fact] + public void Test_18() + { + } + [Fact] + public void Test_19() + { + } + [Fact] + public void Test_20() + { + } + [Fact] + public void Test_21() + { + } + [Fact] + public void Test_22() + { + } + [Fact] + public void Test_23() + { + } + [Fact] + public void Test_24() + { + } + [Fact] + public void Test_25() + { + } + [Fact] + public void Test_26() + { + } + [Fact] + public void Test_27() + { + } + [Fact] + public void Test_28() + { + } + [Fact] + public void Test_29() + { + } + [Fact] + public void Test_30() + { + } + [Fact] + public void Test_31() + { + } + [Fact] + public void Test_32() + { + } + [Fact] + public void Test_33() + { + } + [Fact] + public void Test_34() + { + } + [Fact] + public void Test_35() + { + } + [Fact] + public void Test_36() + { + } + [Fact] + public void Test_37() + { + } + [Fact] + public void Test_38() + { + } + [Fact] + public void Test_39() + { + } + [Fact] + public void Test_40() + { + } + [Fact] + public void Test_41() + { + } + [Fact] + public void Test_42() + { + } + [Fact] + public void Test_43() + { + } + [Fact] + public void Test_44() + { + } + [Fact] + public void Test_45() + { + } + [Fact] + public void Test_46() + { + } + [Fact] + public void Test_47() + { + } + [Fact] + public void Test_48() + { + } + [Fact] + public void Test_49() + { + } + [Fact] + public void Test_50() + { + } + [Fact] + public void Test_51() + { + } + [Fact] + public void Test_52() + { + } + [Fact] + public void Test_53() + { + } + [Fact] + public void Test_54() + { + } + [Fact] + public void Test_55() + { + } + [Fact] + public void Test_56() + { + } + [Fact] + public void Test_57() + { + } + [Fact] + public void Test_58() + { + } + [Fact] + public void Test_59() + { + } + [Fact] + public void Test_60() + { + } + [Fact] + public void Test_61() + { + } + [Fact] + public void Test_62() + { + } + [Fact] + public void Test_63() + { + } + [Fact] + public void Test_64() + { + } + [Fact] + public void Test_65() + { + } + [Fact] + public void Test_66() + { + } + [Fact] + public void Test_67() + { + } + [Fact] + public void Test_68() + { + } + [Fact] + public void Test_69() + { + } + [Fact] + public void Test_70() + { + } + [Fact] + public void Test_71() + { + } + [Fact] + public void Test_72() + { + } + [Fact] + public void Test_73() + { + } + [Fact] + public void Test_74() + { + } + [Fact] + public void Test_75() + { + } + [Fact] + public void Test_76() + { + } + [Fact] + public void Test_77() + { + } + [Fact] + public void Test_78() + { + } + [Fact] + public void Test_79() + { + } + [Fact] + public void Test_80() + { + } + [Fact] + public void Test_81() + { + } + [Fact] + public void Test_82() + { + } + [Fact] + public void Test_83() + { + } + [Fact] + public void Test_84() + { + } + [Fact] + public void Test_85() + { + } + [Fact] + public void Test_86() + { + } + [Fact] + public void Test_87() + { + } + [Fact] + public void Test_88() + { + } + [Fact] + public void Test_89() + { + } + [Fact] + public void Test_90() + { + } + [Fact] + public void Test_91() + { + } + [Fact] + public void Test_92() + { + } + [Fact] + public void Test_93() + { + } + [Fact] + public void Test_94() + { + } + [Fact] + public void Test_95() + { + } + [Fact] + public void Test_96() + { + } + [Fact] + public void Test_97() + { + } + [Fact] + public void Test_98() + { + } + [Fact] + public void Test_99() + { + } + [Fact] + public void Test_100() + { + } + [Fact] + public void Test_101() + { + } + [Fact] + public void Test_102() + { + } + [Fact] + public void Test_103() + { + } + [Fact] + public void Test_104() + { + } + [Fact] + public void Test_105() + { + } + [Fact] + public void Test_106() + { + } + [Fact] + public void Test_107() + { + } + [Fact] + public void Test_108() + { + } + [Fact] + public void Test_109() + { + } + [Fact] + public void Test_110() + { + } + [Fact] + public void Test_111() + { + } + [Fact] + public void Test_112() + { + } + [Fact] + public void Test_113() + { + } + [Fact] + public void Test_114() + { + } + [Fact] + public void Test_115() + { + } + [Fact] + public void Test_116() + { + } + [Fact] + public void Test_117() + { + } + [Fact] + public void Test_118() + { + } + [Fact] + public void Test_119() + { + } + [Fact] + public void Test_120() + { + } + [Fact] + public void Test_121() + { + } + [Fact] + public void Test_122() + { + } + [Fact] + public void Test_123() + { + } + [Fact] + public void Test_124() + { + } + [Fact] + public void Test_125() + { + } + [Fact] + public void Test_126() + { + } + [Fact] + public void Test_127() + { + } + [Fact] + public void Test_128() + { + } + [Fact] + public void Test_129() + { + } + [Fact] + public void Test_130() + { + } + [Fact] + public void Test_131() + { + } + [Fact] + public void Test_132() + { + } + [Fact] + public void Test_133() + { + } + [Fact] + public void Test_134() + { + } + [Fact] + public void Test_135() + { + } + [Fact] + public void Test_136() + { + } + [Fact] + public void Test_137() + { + } + [Fact] + public void Test_138() + { + } + [Fact] + public void Test_139() + { + } + [Fact] + public void Test_140() + { + } + [Fact] + public void Test_141() + { + } + [Fact] + public void Test_142() + { + } + [Fact] + public void Test_143() + { + } + [Fact] + public void Test_144() + { + } + [Fact] + public void Test_145() + { + } + [Fact] + public void Test_146() + { + } + [Fact] + public void Test_147() + { + } + [Fact] + public void Test_148() + { + } + [Fact] + public void Test_149() + { + } + [Fact] + public void Test_150() + { + } + [Fact] + public void Test_151() + { + } + [Fact] + public void Test_152() + { + } + [Fact] + public void Test_153() + { + } + [Fact] + public void Test_154() + { + } + [Fact] + public void Test_155() + { + } + [Fact] + public void Test_156() + { + } + [Fact] + public void Test_157() + { + } + [Fact] + public void Test_158() + { + } + [Fact] + public void Test_159() + { + } + [Fact] + public void Test_160() + { + } + [Fact] + public void Test_161() + { + } + [Fact] + public void Test_162() + { + } + [Fact] + public void Test_163() + { + } + [Fact] + public void Test_164() + { + } + [Fact] + public void Test_165() + { + } + [Fact] + public void Test_166() + { + } + [Fact] + public void Test_167() + { + } + [Fact] + public void Test_168() + { + } + [Fact] + public void Test_169() + { + } + [Fact] + public void Test_170() + { + } + [Fact] + public void Test_171() + { + } + [Fact] + public void Test_172() + { + } + [Fact] + public void Test_173() + { + } + [Fact] + public void Test_174() + { + } + [Fact] + public void Test_175() + { + } + [Fact] + public void Test_176() + { + } + [Fact] + public void Test_177() + { + } + [Fact] + public void Test_178() + { + } + [Fact] + public void Test_179() + { + } + [Fact] + public void Test_180() + { + } + [Fact] + public void Test_181() + { + } + [Fact] + public void Test_182() + { + } + [Fact] + public void Test_183() + { + } + [Fact] + public void Test_184() + { + } + [Fact] + public void Test_185() + { + } + [Fact] + public void Test_186() + { + } + [Fact] + public void Test_187() + { + } + [Fact] + public void Test_188() + { + } + [Fact] + public void Test_189() + { + } + [Fact] + public void Test_190() + { + } + [Fact] + public void Test_191() + { + } + [Fact] + public void Test_192() + { + } + [Fact] + public void Test_193() + { + } + [Fact] + public void Test_194() + { + } + [Fact] + public void Test_195() + { + } + [Fact] + public void Test_196() + { + } + [Fact] + public void Test_197() + { + } + [Fact] + public void Test_198() + { + } + [Fact] + public void Test_199() + { + } + [Fact] + public void Test_200() + { + } + [Fact] + public void Test_201() + { + } + [Fact] + public void Test_202() + { + } + [Fact] + public void Test_203() + { + } + [Fact] + public void Test_204() + { + } + [Fact] + public void Test_205() + { + } + [Fact] + public void Test_206() + { + } + [Fact] + public void Test_207() + { + } + [Fact] + public void Test_208() + { + } + [Fact] + public void Test_209() + { + } + [Fact] + public void Test_210() + { + } + [Fact] + public void Test_211() + { + } + [Fact] + public void Test_212() + { + } + [Fact] + public void Test_213() + { + } + [Fact] + public void Test_214() + { + } + [Fact] + public void Test_215() + { + } + [Fact] + public void Test_216() + { + } + [Fact] + public void Test_217() + { + } + [Fact] + public void Test_218() + { + } + [Fact] + public void Test_219() + { + } + [Fact] + public void Test_220() + { + } + [Fact] + public void Test_221() + { + } + [Fact] + public void Test_222() + { + } + [Fact] + public void Test_223() + { + } + [Fact] + public void Test_224() + { + } + [Fact] + public void Test_225() + { + } + [Fact] + public void Test_226() + { + } + [Fact] + public void Test_227() + { + } + [Fact] + public void Test_228() + { + } + [Fact] + public void Test_229() + { + } + [Fact] + public void Test_230() + { + } + [Fact] + public void Test_231() + { + } + [Fact] + public void Test_232() + { + } + [Fact] + public void Test_233() + { + } + [Fact] + public void Test_234() + { + } + [Fact] + public void Test_235() + { + } + [Fact] + public void Test_236() + { + } + [Fact] + public void Test_237() + { + } + [Fact] + public void Test_238() + { + } + [Fact] + public void Test_239() + { + } + [Fact] + public void Test_240() + { + } + [Fact] + public void Test_241() + { + } + [Fact] + public void Test_242() + { + } + [Fact] + public void Test_243() + { + } + [Fact] + public void Test_244() + { + } + [Fact] + public void Test_245() + { + } + [Fact] + public void Test_246() + { + } + [Fact] + public void Test_247() + { + } + [Fact] + public void Test_248() + { + } + [Fact] + public void Test_249() + { + } + [Fact] + public void Test_250() + { + } + [Fact] + public void Test_251() + { + } + [Fact] + public void Test_252() + { + } + [Fact] + public void Test_253() + { + } + [Fact] + public void Test_254() + { + } + [Fact] + public void Test_255() + { + } + [Fact] + public void Test_256() + { + } + [Fact] + public void Test_257() + { + } + [Fact] + public void Test_258() + { + } + [Fact] + public void Test_259() + { + } + [Fact] + public void Test_260() + { + } + [Fact] + public void Test_261() + { + } + [Fact] + public void Test_262() + { + } + [Fact] + public void Test_263() + { + } + [Fact] + public void Test_264() + { + } + [Fact] + public void Test_265() + { + } + [Fact] + public void Test_266() + { + } + [Fact] + public void Test_267() + { + } + [Fact] + public void Test_268() + { + } + [Fact] + public void Test_269() + { + } + [Fact] + public void Test_270() + { + } + [Fact] + public void Test_271() + { + } + [Fact] + public void Test_272() + { + } + [Fact] + public void Test_273() + { + } + [Fact] + public void Test_274() + { + } + [Fact] + public void Test_275() + { + } + [Fact] + public void Test_276() + { + } + [Fact] + public void Test_277() + { + } + [Fact] + public void Test_278() + { + } + [Fact] + public void Test_279() + { + } + [Fact] + public void Test_280() + { + } + [Fact] + public void Test_281() + { + } + [Fact] + public void Test_282() + { + } + [Fact] + public void Test_283() + { + } + [Fact] + public void Test_284() + { + } + [Fact] + public void Test_285() + { + } + [Fact] + public void Test_286() + { + } + [Fact] + public void Test_287() + { + } + [Fact] + public void Test_288() + { + } + [Fact] + public void Test_289() + { + } + [Fact] + public void Test_290() + { + } + [Fact] + public void Test_291() + { + } + [Fact] + public void Test_292() + { + } + [Fact] + public void Test_293() + { + } + [Fact] + public void Test_294() + { + } + [Fact] + public void Test_295() + { + } + [Fact] + public void Test_296() + { + } + [Fact] + public void Test_297() + { + } + [Fact] + public void Test_298() + { + } + [Fact] + public void Test_299() + { + } + [Fact] + public void Test_300() + { + } + [Fact] + public void Test_301() + { + } + [Fact] + public void Test_302() + { + } + [Fact] + public void Test_303() + { + } + [Fact] + public void Test_304() + { + } + [Fact] + public void Test_305() + { + } + [Fact] + public void Test_306() + { + } + [Fact] + public void Test_307() + { + } + [Fact] + public void Test_308() + { + } + [Fact] + public void Test_309() + { + } + [Fact] + public void Test_310() + { + } + [Fact] + public void Test_311() + { + } + [Fact] + public void Test_312() + { + } + [Fact] + public void Test_313() + { + } + [Fact] + public void Test_314() + { + } + [Fact] + public void Test_315() + { + } + [Fact] + public void Test_316() + { + } + [Fact] + public void Test_317() + { + } + [Fact] + public void Test_318() + { + } + [Fact] + public void Test_319() + { + } + [Fact] + public void Test_320() + { + } + [Fact] + public void Test_321() + { + } + [Fact] + public void Test_322() + { + } + [Fact] + public void Test_323() + { + } + [Fact] + public void Test_324() + { + } + [Fact] + public void Test_325() + { + } + [Fact] + public void Test_326() + { + } + [Fact] + public void Test_327() + { + } + [Fact] + public void Test_328() + { + } + [Fact] + public void Test_329() + { + } + [Fact] + public void Test_330() + { + } + [Fact] + public void Test_331() + { + } + [Fact] + public void Test_332() + { + } + [Fact] + public void Test_333() + { + } + [Fact] + public void Test_334() + { + } + [Fact] + public void Test_335() + { + } + [Fact] + public void Test_336() + { + } + [Fact] + public void Test_337() + { + } + [Fact] + public void Test_338() + { + } + [Fact] + public void Test_339() + { + } + [Fact] + public void Test_340() + { + } + [Fact] + public void Test_341() + { + } + [Fact] + public void Test_342() + { + } + [Fact] + public void Test_343() + { + } + [Fact] + public void Test_344() + { + } + [Fact] + public void Test_345() + { + } + [Fact] + public void Test_346() + { + } + [Fact] + public void Test_347() + { + } + [Fact] + public void Test_348() + { + } + [Fact] + public void Test_349() + { + } + [Fact] + public void Test_350() + { + } + [Fact] + public void Test_351() + { + } + [Fact] + public void Test_352() + { + } + [Fact] + public void Test_353() + { + } + [Fact] + public void Test_354() + { + } + [Fact] + public void Test_355() + { + } + [Fact] + public void Test_356() + { + } + [Fact] + public void Test_357() + { + } + [Fact] + public void Test_358() + { + } + [Fact] + public void Test_359() + { + } + [Fact] + public void Test_360() + { + } + [Fact] + public void Test_361() + { + } + [Fact] + public void Test_362() + { + } + [Fact] + public void Test_363() + { + } + [Fact] + public void Test_364() + { + } + [Fact] + public void Test_365() + { + } + [Fact] + public void Test_366() + { + } + [Fact] + public void Test_367() + { + } + [Fact] + public void Test_368() + { + } + [Fact] + public void Test_369() + { + } + [Fact] + public void Test_370() + { + } + [Fact] + public void Test_371() + { + } + [Fact] + public void Test_372() + { + } + [Fact] + public void Test_373() + { + } + [Fact] + public void Test_374() + { + } + [Fact] + public void Test_375() + { + } + [Fact] + public void Test_376() + { + } + [Fact] + public void Test_377() + { + } + [Fact] + public void Test_378() + { + } + [Fact] + public void Test_379() + { + } + [Fact] + public void Test_380() + { + } + [Fact] + public void Test_381() + { + } + [Fact] + public void Test_382() + { + } + [Fact] + public void Test_383() + { + } + [Fact] + public void Test_384() + { + } + [Fact] + public void Test_385() + { + } + [Fact] + public void Test_386() + { + } + [Fact] + public void Test_387() + { + } + [Fact] + public void Test_388() + { + } + [Fact] + public void Test_389() + { + } + [Fact] + public void Test_390() + { + } + [Fact] + public void Test_391() + { + } + [Fact] + public void Test_392() + { + } + [Fact] + public void Test_393() + { + } + [Fact] + public void Test_394() + { + } + [Fact] + public void Test_395() + { + } + [Fact] + public void Test_396() + { + } + [Fact] + public void Test_397() + { + } + [Fact] + public void Test_398() + { + } + [Fact] + public void Test_399() + { + } + [Fact] + public void Test_400() + { + } + [Fact] + public void Test_401() + { + } + [Fact] + public void Test_402() + { + } + [Fact] + public void Test_403() + { + } + [Fact] + public void Test_404() + { + } + [Fact] + public void Test_405() + { + } + [Fact] + public void Test_406() + { + } + [Fact] + public void Test_407() + { + } + [Fact] + public void Test_408() + { + } + [Fact] + public void Test_409() + { + } + [Fact] + public void Test_410() + { + } + [Fact] + public void Test_411() + { + } + [Fact] + public void Test_412() + { + } + [Fact] + public void Test_413() + { + } + [Fact] + public void Test_414() + { + } + [Fact] + public void Test_415() + { + } + [Fact] + public void Test_416() + { + } + [Fact] + public void Test_417() + { + } + [Fact] + public void Test_418() + { + } + [Fact] + public void Test_419() + { + } + [Fact] + public void Test_420() + { + } + [Fact] + public void Test_421() + { + } + [Fact] + public void Test_422() + { + } + [Fact] + public void Test_423() + { + } + [Fact] + public void Test_424() + { + } + [Fact] + public void Test_425() + { + } + [Fact] + public void Test_426() + { + } + [Fact] + public void Test_427() + { + } + [Fact] + public void Test_428() + { + } + [Fact] + public void Test_429() + { + } + [Fact] + public void Test_430() + { + } + [Fact] + public void Test_431() + { + } + [Fact] + public void Test_432() + { + } + [Fact] + public void Test_433() + { + } + [Fact] + public void Test_434() + { + } + [Fact] + public void Test_435() + { + } + [Fact] + public void Test_436() + { + } + [Fact] + public void Test_437() + { + } + [Fact] + public void Test_438() + { + } + [Fact] + public void Test_439() + { + } + [Fact] + public void Test_440() + { + } + [Fact] + public void Test_441() + { + } + [Fact] + public void Test_442() + { + } + [Fact] + public void Test_443() + { + } + [Fact] + public void Test_444() + { + } + [Fact] + public void Test_445() + { + } + [Fact] + public void Test_446() + { + } + [Fact] + public void Test_447() + { + } + [Fact] + public void Test_448() + { + } + [Fact] + public void Test_449() + { + } + [Fact] + public void Test_450() + { + } + [Fact] + public void Test_451() + { + } + [Fact] + public void Test_452() + { + } + [Fact] + public void Test_453() + { + } + [Fact] + public void Test_454() + { + } + [Fact] + public void Test_455() + { + } + [Fact] + public void Test_456() + { + } + [Fact] + public void Test_457() + { + } + [Fact] + public void Test_458() + { + } + [Fact] + public void Test_459() + { + } + [Fact] + public void Test_460() + { + } + [Fact] + public void Test_461() + { + } + [Fact] + public void Test_462() + { + } + [Fact] + public void Test_463() + { + } + [Fact] + public void Test_464() + { + } + [Fact] + public void Test_465() + { + } + [Fact] + public void Test_466() + { + } + [Fact] + public void Test_467() + { + } + [Fact] + public void Test_468() + { + } + [Fact] + public void Test_469() + { + } + [Fact] + public void Test_470() + { + } + [Fact] + public void Test_471() + { + } + [Fact] + public void Test_472() + { + } + [Fact] + public void Test_473() + { + } + [Fact] + public void Test_474() + { + } + [Fact] + public void Test_475() + { + } + [Fact] + public void Test_476() + { + } + [Fact] + public void Test_477() + { + } + [Fact] + public void Test_478() + { + } + [Fact] + public void Test_479() + { + } + [Fact] + public void Test_480() + { + } + [Fact] + public void Test_481() + { + } + [Fact] + public void Test_482() + { + } + [Fact] + public void Test_483() + { + } + [Fact] + public void Test_484() + { + } + [Fact] + public void Test_485() + { + } + [Fact] + public void Test_486() + { + } + [Fact] + public void Test_487() + { + } + [Fact] + public void Test_488() + { + } + [Fact] + public void Test_489() + { + } + [Fact] + public void Test_490() + { + } + [Fact] + public void Test_491() + { + } + [Fact] + public void Test_492() + { + } + [Fact] + public void Test_493() + { + } + [Fact] + public void Test_494() + { + } + [Fact] + public void Test_495() + { + } + [Fact] + public void Test_496() + { + } + [Fact] + public void Test_497() + { + } + [Fact] + public void Test_498() + { + } + [Fact] + public void Test_499() + { + } + [Fact] + public void Test_500() + { + } + [Fact] + public void Test_501() + { + } + [Fact] + public void Test_502() + { + } + [Fact] + public void Test_503() + { + } + [Fact] + public void Test_504() + { + } + [Fact] + public void Test_505() + { + } + [Fact] + public void Test_506() + { + } + [Fact] + public void Test_507() + { + } + [Fact] + public void Test_508() + { + } + [Fact] + public void Test_509() + { + } + [Fact] + public void Test_510() + { + } + [Fact] + public void Test_511() + { + } + [Fact] + public void Test_512() + { + } + [Fact] + public void Test_513() + { + } + [Fact] + public void Test_514() + { + } + [Fact] + public void Test_515() + { + } + [Fact] + public void Test_516() + { + } + [Fact] + public void Test_517() + { + } + [Fact] + public void Test_518() + { + } + [Fact] + public void Test_519() + { + } + [Fact] + public void Test_520() + { + } + [Fact] + public void Test_521() + { + } + [Fact] + public void Test_522() + { + } + [Fact] + public void Test_523() + { + } + [Fact] + public void Test_524() + { + } + [Fact] + public void Test_525() + { + } + [Fact] + public void Test_526() + { + } + [Fact] + public void Test_527() + { + } + [Fact] + public void Test_528() + { + } + [Fact] + public void Test_529() + { + } + [Fact] + public void Test_530() + { + } + [Fact] + public void Test_531() + { + } + [Fact] + public void Test_532() + { + } + [Fact] + public void Test_533() + { + } + [Fact] + public void Test_534() + { + } + [Fact] + public void Test_535() + { + } + [Fact] + public void Test_536() + { + } + [Fact] + public void Test_537() + { + } + [Fact] + public void Test_538() + { + } + [Fact] + public void Test_539() + { + } + [Fact] + public void Test_540() + { + } + [Fact] + public void Test_541() + { + } + [Fact] + public void Test_542() + { + } + [Fact] + public void Test_543() + { + } + [Fact] + public void Test_544() + { + } + [Fact] + public void Test_545() + { + } + [Fact] + public void Test_546() + { + } + [Fact] + public void Test_547() + { + } + [Fact] + public void Test_548() + { + } + [Fact] + public void Test_549() + { + } + [Fact] + public void Test_550() + { + } + [Fact] + public void Test_551() + { + } + [Fact] + public void Test_552() + { + } + [Fact] + public void Test_553() + { + } + [Fact] + public void Test_554() + { + } + [Fact] + public void Test_555() + { + } + [Fact] + public void Test_556() + { + } + [Fact] + public void Test_557() + { + } + [Fact] + public void Test_558() + { + } + [Fact] + public void Test_559() + { + } + [Fact] + public void Test_560() + { + } + [Fact] + public void Test_561() + { + } + [Fact] + public void Test_562() + { + } + [Fact] + public void Test_563() + { + } + [Fact] + public void Test_564() + { + } + [Fact] + public void Test_565() + { + } + [Fact] + public void Test_566() + { + } + [Fact] + public void Test_567() + { + } + [Fact] + public void Test_568() + { + } + [Fact] + public void Test_569() + { + } + [Fact] + public void Test_570() + { + } + [Fact] + public void Test_571() + { + } + [Fact] + public void Test_572() + { + } + [Fact] + public void Test_573() + { + } + [Fact] + public void Test_574() + { + } + [Fact] + public void Test_575() + { + } + [Fact] + public void Test_576() + { + } + [Fact] + public void Test_577() + { + } + [Fact] + public void Test_578() + { + } + [Fact] + public void Test_579() + { + } + [Fact] + public void Test_580() + { + } + [Fact] + public void Test_581() + { + } + [Fact] + public void Test_582() + { + } + [Fact] + public void Test_583() + { + } + [Fact] + public void Test_584() + { + } + [Fact] + public void Test_585() + { + } + [Fact] + public void Test_586() + { + } + [Fact] + public void Test_587() + { + } + [Fact] + public void Test_588() + { + } + [Fact] + public void Test_589() + { + } + [Fact] + public void Test_590() + { + } + [Fact] + public void Test_591() + { + } + [Fact] + public void Test_592() + { + } + [Fact] + public void Test_593() + { + } + [Fact] + public void Test_594() + { + } + [Fact] + public void Test_595() + { + } + [Fact] + public void Test_596() + { + } + [Fact] + public void Test_597() + { + } + [Fact] + public void Test_598() + { + } + [Fact] + public void Test_599() + { + } + [Fact] + public void Test_600() + { + } + [Fact] + public void Test_601() + { + } + [Fact] + public void Test_602() + { + } + [Fact] + public void Test_603() + { + } + [Fact] + public void Test_604() + { + } + [Fact] + public void Test_605() + { + } + [Fact] + public void Test_606() + { + } + [Fact] + public void Test_607() + { + } + [Fact] + public void Test_608() + { + } + [Fact] + public void Test_609() + { + } + [Fact] + public void Test_610() + { + } + [Fact] + public void Test_611() + { + } + [Fact] + public void Test_612() + { + } + [Fact] + public void Test_613() + { + } + [Fact] + public void Test_614() + { + } + [Fact] + public void Test_615() + { + } + [Fact] + public void Test_616() + { + } + [Fact] + public void Test_617() + { + } + [Fact] + public void Test_618() + { + } + [Fact] + public void Test_619() + { + } + [Fact] + public void Test_620() + { + } + [Fact] + public void Test_621() + { + } + [Fact] + public void Test_622() + { + } + [Fact] + public void Test_623() + { + } + [Fact] + public void Test_624() + { + } + [Fact] + public void Test_625() + { + } + [Fact] + public void Test_626() + { + } + [Fact] + public void Test_627() + { + } + [Fact] + public void Test_628() + { + } + [Fact] + public void Test_629() + { + } + [Fact] + public void Test_630() + { + } + [Fact] + public void Test_631() + { + } + [Fact] + public void Test_632() + { + } + [Fact] + public void Test_633() + { + } + [Fact] + public void Test_634() + { + } + [Fact] + public void Test_635() + { + } + [Fact] + public void Test_636() + { + } + [Fact] + public void Test_637() + { + } + [Fact] + public void Test_638() + { + } + [Fact] + public void Test_639() + { + } + [Fact] + public void Test_640() + { + } + [Fact] + public void Test_641() + { + } + [Fact] + public void Test_642() + { + } + [Fact] + public void Test_643() + { + } + [Fact] + public void Test_644() + { + } + [Fact] + public void Test_645() + { + } + [Fact] + public void Test_646() + { + } + [Fact] + public void Test_647() + { + } + [Fact] + public void Test_648() + { + } + [Fact] + public void Test_649() + { + } + [Fact] + public void Test_650() + { + } + [Fact] + public void Test_651() + { + } + [Fact] + public void Test_652() + { + } + [Fact] + public void Test_653() + { + } + [Fact] + public void Test_654() + { + } + [Fact] + public void Test_655() + { + } + [Fact] + public void Test_656() + { + } + [Fact] + public void Test_657() + { + } + [Fact] + public void Test_658() + { + } + [Fact] + public void Test_659() + { + } + [Fact] + public void Test_660() + { + } + [Fact] + public void Test_661() + { + } + [Fact] + public void Test_662() + { + } + [Fact] + public void Test_663() + { + } + [Fact] + public void Test_664() + { + } + [Fact] + public void Test_665() + { + } + [Fact] + public void Test_666() + { + } + [Fact] + public void Test_667() + { + } + [Fact] + public void Test_668() + { + } + [Fact] + public void Test_669() + { + } + [Fact] + public void Test_670() + { + } + [Fact] + public void Test_671() + { + } + [Fact] + public void Test_672() + { + } + [Fact] + public void Test_673() + { + } + [Fact] + public void Test_674() + { + } + [Fact] + public void Test_675() + { + } + [Fact] + public void Test_676() + { + } + [Fact] + public void Test_677() + { + } + [Fact] + public void Test_678() + { + } + [Fact] + public void Test_679() + { + } + [Fact] + public void Test_680() + { + } + [Fact] + public void Test_681() + { + } + [Fact] + public void Test_682() + { + } + [Fact] + public void Test_683() + { + } + [Fact] + public void Test_684() + { + } + [Fact] + public void Test_685() + { + } + [Fact] + public void Test_686() + { + } + [Fact] + public void Test_687() + { + } + [Fact] + public void Test_688() + { + } + [Fact] + public void Test_689() + { + } + [Fact] + public void Test_690() + { + } + [Fact] + public void Test_691() + { + } + [Fact] + public void Test_692() + { + } + [Fact] + public void Test_693() + { + } + [Fact] + public void Test_694() + { + } + [Fact] + public void Test_695() + { + } + [Fact] + public void Test_696() + { + } + [Fact] + public void Test_697() + { + } + [Fact] + public void Test_698() + { + } + [Fact] + public void Test_699() + { + } + [Fact] + public void Test_700() + { + } + [Fact] + public void Test_701() + { + } + [Fact] + public void Test_702() + { + } + [Fact] + public void Test_703() + { + } + [Fact] + public void Test_704() + { + } + [Fact] + public void Test_705() + { + } + [Fact] + public void Test_706() + { + } + [Fact] + public void Test_707() + { + } + [Fact] + public void Test_708() + { + } + [Fact] + public void Test_709() + { + } + [Fact] + public void Test_710() + { + } + [Fact] + public void Test_711() + { + } + [Fact] + public void Test_712() + { + } + [Fact] + public void Test_713() + { + } + [Fact] + public void Test_714() + { + } + [Fact] + public void Test_715() + { + } + [Fact] + public void Test_716() + { + } + [Fact] + public void Test_717() + { + } + [Fact] + public void Test_718() + { + } + [Fact] + public void Test_719() + { + } + [Fact] + public void Test_720() + { + } + [Fact] + public void Test_721() + { + } + [Fact] + public void Test_722() + { + } + [Fact] + public void Test_723() + { + } + [Fact] + public void Test_724() + { + } + [Fact] + public void Test_725() + { + } + [Fact] + public void Test_726() + { + } + [Fact] + public void Test_727() + { + } + [Fact] + public void Test_728() + { + } + [Fact] + public void Test_729() + { + } + [Fact] + public void Test_730() + { + } + [Fact] + public void Test_731() + { + } + [Fact] + public void Test_732() + { + } + [Fact] + public void Test_733() + { + } + [Fact] + public void Test_734() + { + } + [Fact] + public void Test_735() + { + } + [Fact] + public void Test_736() + { + } + [Fact] + public void Test_737() + { + } + [Fact] + public void Test_738() + { + } + [Fact] + public void Test_739() + { + } + [Fact] + public void Test_740() + { + } + [Fact] + public void Test_741() + { + } + [Fact] + public void Test_742() + { + } + [Fact] + public void Test_743() + { + } + [Fact] + public void Test_744() + { + } + [Fact] + public void Test_745() + { + } + [Fact] + public void Test_746() + { + } + [Fact] + public void Test_747() + { + } + [Fact] + public void Test_748() + { + } + [Fact] + public void Test_749() + { + } + [Fact] + public void Test_750() + { + } + [Fact] + public void Test_751() + { + } + [Fact] + public void Test_752() + { + } + [Fact] + public void Test_753() + { + } + [Fact] + public void Test_754() + { + } + [Fact] + public void Test_755() + { + } + [Fact] + public void Test_756() + { + } + [Fact] + public void Test_757() + { + } + [Fact] + public void Test_758() + { + } + [Fact] + public void Test_759() + { + } + [Fact] + public void Test_760() + { + } + [Fact] + public void Test_761() + { + } + [Fact] + public void Test_762() + { + } + [Fact] + public void Test_763() + { + } + [Fact] + public void Test_764() + { + } + [Fact] + public void Test_765() + { + } + [Fact] + public void Test_766() + { + } + [Fact] + public void Test_767() + { + } + [Fact] + public void Test_768() + { + } + [Fact] + public void Test_769() + { + } + [Fact] + public void Test_770() + { + } + [Fact] + public void Test_771() + { + } + [Fact] + public void Test_772() + { + } + [Fact] + public void Test_773() + { + } + [Fact] + public void Test_774() + { + } + [Fact] + public void Test_775() + { + } + [Fact] + public void Test_776() + { + } + [Fact] + public void Test_777() + { + } + [Fact] + public void Test_778() + { + } + [Fact] + public void Test_779() + { + } + [Fact] + public void Test_780() + { + } + [Fact] + public void Test_781() + { + } + [Fact] + public void Test_782() + { + } + [Fact] + public void Test_783() + { + } + [Fact] + public void Test_784() + { + } + [Fact] + public void Test_785() + { + } + [Fact] + public void Test_786() + { + } + [Fact] + public void Test_787() + { + } + [Fact] + public void Test_788() + { + } + [Fact] + public void Test_789() + { + } + [Fact] + public void Test_790() + { + } + [Fact] + public void Test_791() + { + } + [Fact] + public void Test_792() + { + } + [Fact] + public void Test_793() + { + } + [Fact] + public void Test_794() + { + } + [Fact] + public void Test_795() + { + } + [Fact] + public void Test_796() + { + } + [Fact] + public void Test_797() + { + } + [Fact] + public void Test_798() + { + } + [Fact] + public void Test_799() + { + } + [Fact] + public void Test_800() + { + } + [Fact] + public void Test_801() + { + } + [Fact] + public void Test_802() + { + } + [Fact] + public void Test_803() + { + } + [Fact] + public void Test_804() + { + } + [Fact] + public void Test_805() + { + } + [Fact] + public void Test_806() + { + } + [Fact] + public void Test_807() + { + } + [Fact] + public void Test_808() + { + } + [Fact] + public void Test_809() + { + } + [Fact] + public void Test_810() + { + } + [Fact] + public void Test_811() + { + } + [Fact] + public void Test_812() + { + } + [Fact] + public void Test_813() + { + } + [Fact] + public void Test_814() + { + } + [Fact] + public void Test_815() + { + } + [Fact] + public void Test_816() + { + } + [Fact] + public void Test_817() + { + } + [Fact] + public void Test_818() + { + } + [Fact] + public void Test_819() + { + } + [Fact] + public void Test_820() + { + } + [Fact] + public void Test_821() + { + } + [Fact] + public void Test_822() + { + } + [Fact] + public void Test_823() + { + } + [Fact] + public void Test_824() + { + } + [Fact] + public void Test_825() + { + } + [Fact] + public void Test_826() + { + } + [Fact] + public void Test_827() + { + } + [Fact] + public void Test_828() + { + } + [Fact] + public void Test_829() + { + } + [Fact] + public void Test_830() + { + } + [Fact] + public void Test_831() + { + } + [Fact] + public void Test_832() + { + } + [Fact] + public void Test_833() + { + } + [Fact] + public void Test_834() + { + } + [Fact] + public void Test_835() + { + } + [Fact] + public void Test_836() + { + } + [Fact] + public void Test_837() + { + } + [Fact] + public void Test_838() + { + } + [Fact] + public void Test_839() + { + } + [Fact] + public void Test_840() + { + } + [Fact] + public void Test_841() + { + } + [Fact] + public void Test_842() + { + } + [Fact] + public void Test_843() + { + } + [Fact] + public void Test_844() + { + } + [Fact] + public void Test_845() + { + } + [Fact] + public void Test_846() + { + } + [Fact] + public void Test_847() + { + } + [Fact] + public void Test_848() + { + } + [Fact] + public void Test_849() + { + } + [Fact] + public void Test_850() + { + } + [Fact] + public void Test_851() + { + } + [Fact] + public void Test_852() + { + } + [Fact] + public void Test_853() + { + } + [Fact] + public void Test_854() + { + } + [Fact] + public void Test_855() + { + } + [Fact] + public void Test_856() + { + } + [Fact] + public void Test_857() + { + } + [Fact] + public void Test_858() + { + } + [Fact] + public void Test_859() + { + } + [Fact] + public void Test_860() + { + } + [Fact] + public void Test_861() + { + } + [Fact] + public void Test_862() + { + } + [Fact] + public void Test_863() + { + } + [Fact] + public void Test_864() + { + } + [Fact] + public void Test_865() + { + } + [Fact] + public void Test_866() + { + } + [Fact] + public void Test_867() + { + } + [Fact] + public void Test_868() + { + } + [Fact] + public void Test_869() + { + } + [Fact] + public void Test_870() + { + } + [Fact] + public void Test_871() + { + } + [Fact] + public void Test_872() + { + } + [Fact] + public void Test_873() + { + } + [Fact] + public void Test_874() + { + } + [Fact] + public void Test_875() + { + } + [Fact] + public void Test_876() + { + } + [Fact] + public void Test_877() + { + } + [Fact] + public void Test_878() + { + } + [Fact] + public void Test_879() + { + } + [Fact] + public void Test_880() + { + } + [Fact] + public void Test_881() + { + } + [Fact] + public void Test_882() + { + } + [Fact] + public void Test_883() + { + } + [Fact] + public void Test_884() + { + } + [Fact] + public void Test_885() + { + } + [Fact] + public void Test_886() + { + } + [Fact] + public void Test_887() + { + } + [Fact] + public void Test_888() + { + } + [Fact] + public void Test_889() + { + } + [Fact] + public void Test_890() + { + } + [Fact] + public void Test_891() + { + } + [Fact] + public void Test_892() + { + } + [Fact] + public void Test_893() + { + } + [Fact] + public void Test_894() + { + } + [Fact] + public void Test_895() + { + } + [Fact] + public void Test_896() + { + } + [Fact] + public void Test_897() + { + } + [Fact] + public void Test_898() + { + } + [Fact] + public void Test_899() + { + } + [Fact] + public void Test_900() + { + } + [Fact] + public void Test_901() + { + } + [Fact] + public void Test_902() + { + } + [Fact] + public void Test_903() + { + } + [Fact] + public void Test_904() + { + } + [Fact] + public void Test_905() + { + } + [Fact] + public void Test_906() + { + } + [Fact] + public void Test_907() + { + } + [Fact] + public void Test_908() + { + } + [Fact] + public void Test_909() + { + } + [Fact] + public void Test_910() + { + } + [Fact] + public void Test_911() + { + } + [Fact] + public void Test_912() + { + } + [Fact] + public void Test_913() + { + } + [Fact] + public void Test_914() + { + } + [Fact] + public void Test_915() + { + } + [Fact] + public void Test_916() + { + } + [Fact] + public void Test_917() + { + } + [Fact] + public void Test_918() + { + } + [Fact] + public void Test_919() + { + } + [Fact] + public void Test_920() + { + } + [Fact] + public void Test_921() + { + } + [Fact] + public void Test_922() + { + } + [Fact] + public void Test_923() + { + } + [Fact] + public void Test_924() + { + } + [Fact] + public void Test_925() + { + } + [Fact] + public void Test_926() + { + } + [Fact] + public void Test_927() + { + } + [Fact] + public void Test_928() + { + } + [Fact] + public void Test_929() + { + } + [Fact] + public void Test_930() + { + } + [Fact] + public void Test_931() + { + } + [Fact] + public void Test_932() + { + } + [Fact] + public void Test_933() + { + } + [Fact] + public void Test_934() + { + } + [Fact] + public void Test_935() + { + } + [Fact] + public void Test_936() + { + } + [Fact] + public void Test_937() + { + } + [Fact] + public void Test_938() + { + } + [Fact] + public void Test_939() + { + } + [Fact] + public void Test_940() + { + } + [Fact] + public void Test_941() + { + } + [Fact] + public void Test_942() + { + } + [Fact] + public void Test_943() + { + } + [Fact] + public void Test_944() + { + } + [Fact] + public void Test_945() + { + } + [Fact] + public void Test_946() + { + } + [Fact] + public void Test_947() + { + } + [Fact] + public void Test_948() + { + } + [Fact] + public void Test_949() + { + } + [Fact] + public void Test_950() + { + } + [Fact] + public void Test_951() + { + } + [Fact] + public void Test_952() + { + } + [Fact] + public void Test_953() + { + } + [Fact] + public void Test_954() + { + } + [Fact] + public void Test_955() + { + } + [Fact] + public void Test_956() + { + } + [Fact] + public void Test_957() + { + } + [Fact] + public void Test_958() + { + } + [Fact] + public void Test_959() + { + } + [Fact] + public void Test_960() + { + } + [Fact] + public void Test_961() + { + } + [Fact] + public void Test_962() + { + } + [Fact] + public void Test_963() + { + } + [Fact] + public void Test_964() + { + } + [Fact] + public void Test_965() + { + } + [Fact] + public void Test_966() + { + } + [Fact] + public void Test_967() + { + } + [Fact] + public void Test_968() + { + } + [Fact] + public void Test_969() + { + } + [Fact] + public void Test_970() + { + } + [Fact] + public void Test_971() + { + } + [Fact] + public void Test_972() + { + } + [Fact] + public void Test_973() + { + } + [Fact] + public void Test_974() + { + } + [Fact] + public void Test_975() + { + } + [Fact] + public void Test_976() + { + } + [Fact] + public void Test_977() + { + } + [Fact] + public void Test_978() + { + } + [Fact] + public void Test_979() + { + } + [Fact] + public void Test_980() + { + } + [Fact] + public void Test_981() + { + } + [Fact] + public void Test_982() + { + } + [Fact] + public void Test_983() + { + } + [Fact] + public void Test_984() + { + } + [Fact] + public void Test_985() + { + } + [Fact] + public void Test_986() + { + } + [Fact] + public void Test_987() + { + } + [Fact] + public void Test_988() + { + } + [Fact] + public void Test_989() + { + } + [Fact] + public void Test_990() + { + } + [Fact] + public void Test_991() + { + } + [Fact] + public void Test_992() + { + } + [Fact] + public void Test_993() + { + } + [Fact] + public void Test_994() + { + } + [Fact] + public void Test_995() + { + } + [Fact] + public void Test_996() + { + } + [Fact] + public void Test_997() + { + } + [Fact] + public void Test_998() + { + } + [Fact] + public void Test_999() + { + } + [Fact] + public void Test_1000() + { + } + [Fact] + public void Test_1001() + { + } + [Fact] + public void Test_1002() + { + } + [Fact] + public void Test_1003() + { + } + [Fact] + public void Test_1004() + { + } + [Fact] + public void Test_1005() + { + } + [Fact] + public void Test_1006() + { + } + [Fact] + public void Test_1007() + { + } + [Fact] + public void Test_1008() + { + } + [Fact] + public void Test_1009() + { + } + [Fact] + public void Test_1010() + { + } + [Fact] + public void Test_1011() + { + } + [Fact] + public void Test_1012() + { + } + [Fact] + public void Test_1013() + { + } + [Fact] + public void Test_1014() + { + } + [Fact] + public void Test_1015() + { + } + [Fact] + public void Test_1016() + { + } + [Fact] + public void Test_1017() + { + } + [Fact] + public void Test_1018() + { + } + [Fact] + public void Test_1019() + { + } + [Fact] + public void Test_1020() + { + } + [Fact] + public void Test_1021() + { + } + [Fact] + public void Test_1022() + { + } + [Fact] + public void Test_1023() + { + } + [Fact] + public void Test_1024() + { + } + [Fact] + public void Test_1025() + { + } + [Fact] + public void Test_1026() + { + } + [Fact] + public void Test_1027() + { + } + [Fact] + public void Test_1028() + { + } + [Fact] + public void Test_1029() + { + } + [Fact] + public void Test_1030() + { + } + [Fact] + public void Test_1031() + { + } + [Fact] + public void Test_1032() + { + } + [Fact] + public void Test_1033() + { + } + [Fact] + public void Test_1034() + { + } + [Fact] + public void Test_1035() + { + } + [Fact] + public void Test_1036() + { + } + [Fact] + public void Test_1037() + { + } + [Fact] + public void Test_1038() + { + } + [Fact] + public void Test_1039() + { + } + [Fact] + public void Test_1040() + { + } + [Fact] + public void Test_1041() + { + } + [Fact] + public void Test_1042() + { + } + [Fact] + public void Test_1043() + { + } + [Fact] + public void Test_1044() + { + } + [Fact] + public void Test_1045() + { + } + [Fact] + public void Test_1046() + { + } + [Fact] + public void Test_1047() + { + } + [Fact] + public void Test_1048() + { + } + [Fact] + public void Test_1049() + { + } + [Fact] + public void Test_1050() + { + } + [Fact] + public void Test_1051() + { + } + [Fact] + public void Test_1052() + { + } + [Fact] + public void Test_1053() + { + } + [Fact] + public void Test_1054() + { + } + [Fact] + public void Test_1055() + { + } + [Fact] + public void Test_1056() + { + } + [Fact] + public void Test_1057() + { + } + [Fact] + public void Test_1058() + { + } + [Fact] + public void Test_1059() + { + } + [Fact] + public void Test_1060() + { + } + [Fact] + public void Test_1061() + { + } + [Fact] + public void Test_1062() + { + } + [Fact] + public void Test_1063() + { + } + [Fact] + public void Test_1064() + { + } + [Fact] + public void Test_1065() + { + } + [Fact] + public void Test_1066() + { + } + [Fact] + public void Test_1067() + { + } + [Fact] + public void Test_1068() + { + } + [Fact] + public void Test_1069() + { + } + [Fact] + public void Test_1070() + { + } + [Fact] + public void Test_1071() + { + } + [Fact] + public void Test_1072() + { + } + [Fact] + public void Test_1073() + { + } + [Fact] + public void Test_1074() + { + } + [Fact] + public void Test_1075() + { + } + [Fact] + public void Test_1076() + { + } + [Fact] + public void Test_1077() + { + } + [Fact] + public void Test_1078() + { + } + [Fact] + public void Test_1079() + { + } + [Fact] + public void Test_1080() + { + } + [Fact] + public void Test_1081() + { + } + [Fact] + public void Test_1082() + { + } + [Fact] + public void Test_1083() + { + } + [Fact] + public void Test_1084() + { + } + [Fact] + public void Test_1085() + { + } + [Fact] + public void Test_1086() + { + } + [Fact] + public void Test_1087() + { + } + [Fact] + public void Test_1088() + { + } + [Fact] + public void Test_1089() + { + } + [Fact] + public void Test_1090() + { + } + [Fact] + public void Test_1091() + { + } + [Fact] + public void Test_1092() + { + } + [Fact] + public void Test_1093() + { + } + [Fact] + public void Test_1094() + { + } + [Fact] + public void Test_1095() + { + } + [Fact] + public void Test_1096() + { + } + [Fact] + public void Test_1097() + { + } + [Fact] + public void Test_1098() + { + } + [Fact] + public void Test_1099() + { + } + [Fact] + public void Test_1100() + { + } + [Fact] + public void Test_1101() + { + } + [Fact] + public void Test_1102() + { + } + [Fact] + public void Test_1103() + { + } + [Fact] + public void Test_1104() + { + } + [Fact] + public void Test_1105() + { + } + [Fact] + public void Test_1106() + { + } + [Fact] + public void Test_1107() + { + } + [Fact] + public void Test_1108() + { + } + [Fact] + public void Test_1109() + { + } + [Fact] + public void Test_1110() + { + } + [Fact] + public void Test_1111() + { + } + [Fact] + public void Test_1112() + { + } + [Fact] + public void Test_1113() + { + } + [Fact] + public void Test_1114() + { + } + [Fact] + public void Test_1115() + { + } + [Fact] + public void Test_1116() + { + } + [Fact] + public void Test_1117() + { + } + [Fact] + public void Test_1118() + { + } + [Fact] + public void Test_1119() + { + } + [Fact] + public void Test_1120() + { + } + [Fact] + public void Test_1121() + { + } + [Fact] + public void Test_1122() + { + } + [Fact] + public void Test_1123() + { + } + [Fact] + public void Test_1124() + { + } + [Fact] + public void Test_1125() + { + } + [Fact] + public void Test_1126() + { + } + [Fact] + public void Test_1127() + { + } + [Fact] + public void Test_1128() + { + } + [Fact] + public void Test_1129() + { + } + [Fact] + public void Test_1130() + { + } + [Fact] + public void Test_1131() + { + } + [Fact] + public void Test_1132() + { + } + [Fact] + public void Test_1133() + { + } + [Fact] + public void Test_1134() + { + } + [Fact] + public void Test_1135() + { + } + [Fact] + public void Test_1136() + { + } + [Fact] + public void Test_1137() + { + } + [Fact] + public void Test_1138() + { + } + [Fact] + public void Test_1139() + { + } + [Fact] + public void Test_1140() + { + } + [Fact] + public void Test_1141() + { + } + [Fact] + public void Test_1142() + { + } + [Fact] + public void Test_1143() + { + } + [Fact] + public void Test_1144() + { + } + [Fact] + public void Test_1145() + { + } + [Fact] + public void Test_1146() + { + } + [Fact] + public void Test_1147() + { + } + [Fact] + public void Test_1148() + { + } + [Fact] + public void Test_1149() + { + } + [Fact] + public void Test_1150() + { + } + [Fact] + public void Test_1151() + { + } + [Fact] + public void Test_1152() + { + } + [Fact] + public void Test_1153() + { + } + [Fact] + public void Test_1154() + { + } + [Fact] + public void Test_1155() + { + } + [Fact] + public void Test_1156() + { + } + [Fact] + public void Test_1157() + { + } + [Fact] + public void Test_1158() + { + } + [Fact] + public void Test_1159() + { + } + [Fact] + public void Test_1160() + { + } + [Fact] + public void Test_1161() + { + } + [Fact] + public void Test_1162() + { + } + [Fact] + public void Test_1163() + { + } + [Fact] + public void Test_1164() + { + } + [Fact] + public void Test_1165() + { + } + [Fact] + public void Test_1166() + { + } + [Fact] + public void Test_1167() + { + } + [Fact] + public void Test_1168() + { + } + [Fact] + public void Test_1169() + { + } + [Fact] + public void Test_1170() + { + } + [Fact] + public void Test_1171() + { + } + [Fact] + public void Test_1172() + { + } + [Fact] + public void Test_1173() + { + } + [Fact] + public void Test_1174() + { + } + [Fact] + public void Test_1175() + { + } + [Fact] + public void Test_1176() + { + } + [Fact] + public void Test_1177() + { + } + [Fact] + public void Test_1178() + { + } + [Fact] + public void Test_1179() + { + } + [Fact] + public void Test_1180() + { + } + [Fact] + public void Test_1181() + { + } + [Fact] + public void Test_1182() + { + } + [Fact] + public void Test_1183() + { + } + [Fact] + public void Test_1184() + { + } + [Fact] + public void Test_1185() + { + } + [Fact] + public void Test_1186() + { + } + [Fact] + public void Test_1187() + { + } + [Fact] + public void Test_1188() + { + } + [Fact] + public void Test_1189() + { + } + [Fact] + public void Test_1190() + { + } + [Fact] + public void Test_1191() + { + } + [Fact] + public void Test_1192() + { + } + [Fact] + public void Test_1193() + { + } + [Fact] + public void Test_1194() + { + } + [Fact] + public void Test_1195() + { + } + [Fact] + public void Test_1196() + { + } + [Fact] + public void Test_1197() + { + } + [Fact] + public void Test_1198() + { + } + [Fact] + public void Test_1199() + { + } + [Fact] + public void Test_1200() + { + } + [Fact] + public void Test_1201() + { + } + [Fact] + public void Test_1202() + { + } + [Fact] + public void Test_1203() + { + } + [Fact] + public void Test_1204() + { + } + [Fact] + public void Test_1205() + { + } + [Fact] + public void Test_1206() + { + } + [Fact] + public void Test_1207() + { + } + [Fact] + public void Test_1208() + { + } + [Fact] + public void Test_1209() + { + } + [Fact] + public void Test_1210() + { + } + [Fact] + public void Test_1211() + { + } + [Fact] + public void Test_1212() + { + } + [Fact] + public void Test_1213() + { + } + [Fact] + public void Test_1214() + { + } + [Fact] + public void Test_1215() + { + } + [Fact] + public void Test_1216() + { + } + [Fact] + public void Test_1217() + { + } + [Fact] + public void Test_1218() + { + } + [Fact] + public void Test_1219() + { + } + [Fact] + public void Test_1220() + { + } + [Fact] + public void Test_1221() + { + } + [Fact] + public void Test_1222() + { + } + [Fact] + public void Test_1223() + { + } + [Fact] + public void Test_1224() + { + } + [Fact] + public void Test_1225() + { + } + [Fact] + public void Test_1226() + { + } + [Fact] + public void Test_1227() + { + } + [Fact] + public void Test_1228() + { + } + [Fact] + public void Test_1229() + { + } + [Fact] + public void Test_1230() + { + } + [Fact] + public void Test_1231() + { + } + [Fact] + public void Test_1232() + { + } + [Fact] + public void Test_1233() + { + } + [Fact] + public void Test_1234() + { + } + [Fact] + public void Test_1235() + { + } + [Fact] + public void Test_1236() + { + } + [Fact] + public void Test_1237() + { + } + [Fact] + public void Test_1238() + { + } + [Fact] + public void Test_1239() + { + } + [Fact] + public void Test_1240() + { + } + [Fact] + public void Test_1241() + { + } + [Fact] + public void Test_1242() + { + } + [Fact] + public void Test_1243() + { + } + [Fact] + public void Test_1244() + { + } + [Fact] + public void Test_1245() + { + } + [Fact] + public void Test_1246() + { + } + [Fact] + public void Test_1247() + { + } + [Fact] + public void Test_1248() + { + } + [Fact] + public void Test_1249() + { + } + [Fact] + public void Test_1250() + { + } + [Fact] + public void Test_1251() + { + } + [Fact] + public void Test_1252() + { + } + [Fact] + public void Test_1253() + { + } + [Fact] + public void Test_1254() + { + } + [Fact] + public void Test_1255() + { + } + [Fact] + public void Test_1256() + { + } + [Fact] + public void Test_1257() + { + } + [Fact] + public void Test_1258() + { + } + [Fact] + public void Test_1259() + { + } + [Fact] + public void Test_1260() + { + } + [Fact] + public void Test_1261() + { + } + [Fact] + public void Test_1262() + { + } + [Fact] + public void Test_1263() + { + } + [Fact] + public void Test_1264() + { + } + [Fact] + public void Test_1265() + { + } + [Fact] + public void Test_1266() + { + } + [Fact] + public void Test_1267() + { + } + [Fact] + public void Test_1268() + { + } + [Fact] + public void Test_1269() + { + } + [Fact] + public void Test_1270() + { + } + [Fact] + public void Test_1271() + { + } + [Fact] + public void Test_1272() + { + } + [Fact] + public void Test_1273() + { + } + [Fact] + public void Test_1274() + { + } + [Fact] + public void Test_1275() + { + } + [Fact] + public void Test_1276() + { + } + [Fact] + public void Test_1277() + { + } + [Fact] + public void Test_1278() + { + } + [Fact] + public void Test_1279() + { + } + [Fact] + public void Test_1280() + { + } + [Fact] + public void Test_1281() + { + } + [Fact] + public void Test_1282() + { + } + [Fact] + public void Test_1283() + { + } + [Fact] + public void Test_1284() + { + } + [Fact] + public void Test_1285() + { + } + [Fact] + public void Test_1286() + { + } + [Fact] + public void Test_1287() + { + } + [Fact] + public void Test_1288() + { + } + [Fact] + public void Test_1289() + { + } + [Fact] + public void Test_1290() + { + } + [Fact] + public void Test_1291() + { + } + [Fact] + public void Test_1292() + { + } + [Fact] + public void Test_1293() + { + } + [Fact] + public void Test_1294() + { + } + [Fact] + public void Test_1295() + { + } + [Fact] + public void Test_1296() + { + } + [Fact] + public void Test_1297() + { + } + [Fact] + public void Test_1298() + { + } + [Fact] + public void Test_1299() + { + } + [Fact] + public void Test_1300() + { + } + [Fact] + public void Test_1301() + { + } + [Fact] + public void Test_1302() + { + } + [Fact] + public void Test_1303() + { + } + [Fact] + public void Test_1304() + { + } + [Fact] + public void Test_1305() + { + } + [Fact] + public void Test_1306() + { + } + [Fact] + public void Test_1307() + { + } + [Fact] + public void Test_1308() + { + } + [Fact] + public void Test_1309() + { + } + [Fact] + public void Test_1310() + { + } + [Fact] + public void Test_1311() + { + } + [Fact] + public void Test_1312() + { + } + [Fact] + public void Test_1313() + { + } + [Fact] + public void Test_1314() + { + } + [Fact] + public void Test_1315() + { + } + [Fact] + public void Test_1316() + { + } + [Fact] + public void Test_1317() + { + } + [Fact] + public void Test_1318() + { + } + [Fact] + public void Test_1319() + { + } + [Fact] + public void Test_1320() + { + } + [Fact] + public void Test_1321() + { + } + [Fact] + public void Test_1322() + { + } + [Fact] + public void Test_1323() + { + } + [Fact] + public void Test_1324() + { + } + [Fact] + public void Test_1325() + { + } + [Fact] + public void Test_1326() + { + } + [Fact] + public void Test_1327() + { + } + [Fact] + public void Test_1328() + { + } + [Fact] + public void Test_1329() + { + } + [Fact] + public void Test_1330() + { + } + [Fact] + public void Test_1331() + { + } + [Fact] + public void Test_1332() + { + } + [Fact] + public void Test_1333() + { + } + [Fact] + public void Test_1334() + { + } + [Fact] + public void Test_1335() + { + } + [Fact] + public void Test_1336() + { + } + [Fact] + public void Test_1337() + { + } + [Fact] + public void Test_1338() + { + } + [Fact] + public void Test_1339() + { + } + [Fact] + public void Test_1340() + { + } + [Fact] + public void Test_1341() + { + } + [Fact] + public void Test_1342() + { + } + [Fact] + public void Test_1343() + { + } + [Fact] + public void Test_1344() + { + } + [Fact] + public void Test_1345() + { + } + [Fact] + public void Test_1346() + { + } + [Fact] + public void Test_1347() + { + } + [Fact] + public void Test_1348() + { + } + [Fact] + public void Test_1349() + { + } + [Fact] + public void Test_1350() + { + } + [Fact] + public void Test_1351() + { + } + [Fact] + public void Test_1352() + { + } + [Fact] + public void Test_1353() + { + } + [Fact] + public void Test_1354() + { + } + [Fact] + public void Test_1355() + { + } + [Fact] + public void Test_1356() + { + } + [Fact] + public void Test_1357() + { + } + [Fact] + public void Test_1358() + { + } + [Fact] + public void Test_1359() + { + } + [Fact] + public void Test_1360() + { + } + [Fact] + public void Test_1361() + { + } + [Fact] + public void Test_1362() + { + } + [Fact] + public void Test_1363() + { + } + [Fact] + public void Test_1364() + { + } + [Fact] + public void Test_1365() + { + } + [Fact] + public void Test_1366() + { + } + [Fact] + public void Test_1367() + { + } + [Fact] + public void Test_1368() + { + } + [Fact] + public void Test_1369() + { + } + [Fact] + public void Test_1370() + { + } + [Fact] + public void Test_1371() + { + } + [Fact] + public void Test_1372() + { + } + [Fact] + public void Test_1373() + { + } + [Fact] + public void Test_1374() + { + } + [Fact] + public void Test_1375() + { + } + [Fact] + public void Test_1376() + { + } + [Fact] + public void Test_1377() + { + } + [Fact] + public void Test_1378() + { + } + [Fact] + public void Test_1379() + { + } + [Fact] + public void Test_1380() + { + } + [Fact] + public void Test_1381() + { + } + [Fact] + public void Test_1382() + { + } + [Fact] + public void Test_1383() + { + } + [Fact] + public void Test_1384() + { + } + [Fact] + public void Test_1385() + { + } + [Fact] + public void Test_1386() + { + } + [Fact] + public void Test_1387() + { + } + [Fact] + public void Test_1388() + { + } + [Fact] + public void Test_1389() + { + } + [Fact] + public void Test_1390() + { + } + [Fact] + public void Test_1391() + { + } + [Fact] + public void Test_1392() + { + } + [Fact] + public void Test_1393() + { + } + [Fact] + public void Test_1394() + { + } + [Fact] + public void Test_1395() + { + } + [Fact] + public void Test_1396() + { + } + [Fact] + public void Test_1397() + { + } + [Fact] + public void Test_1398() + { + } + [Fact] + public void Test_1399() + { + } + [Fact] + public void Test_1400() + { + } + [Fact] + public void Test_1401() + { + } + [Fact] + public void Test_1402() + { + } + [Fact] + public void Test_1403() + { + } + [Fact] + public void Test_1404() + { + } + [Fact] + public void Test_1405() + { + } + [Fact] + public void Test_1406() + { + } + [Fact] + public void Test_1407() + { + } + [Fact] + public void Test_1408() + { + } + [Fact] + public void Test_1409() + { + } + [Fact] + public void Test_1410() + { + } + [Fact] + public void Test_1411() + { + } + [Fact] + public void Test_1412() + { + } + [Fact] + public void Test_1413() + { + } + [Fact] + public void Test_1414() + { + } + [Fact] + public void Test_1415() + { + } + [Fact] + public void Test_1416() + { + } + [Fact] + public void Test_1417() + { + } + [Fact] + public void Test_1418() + { + } + [Fact] + public void Test_1419() + { + } + [Fact] + public void Test_1420() + { + } + [Fact] + public void Test_1421() + { + } + [Fact] + public void Test_1422() + { + } + [Fact] + public void Test_1423() + { + } + [Fact] + public void Test_1424() + { + } + [Fact] + public void Test_1425() + { + } + [Fact] + public void Test_1426() + { + } + [Fact] + public void Test_1427() + { + } + [Fact] + public void Test_1428() + { + } + [Fact] + public void Test_1429() + { + } + [Fact] + public void Test_1430() + { + } + [Fact] + public void Test_1431() + { + } + [Fact] + public void Test_1432() + { + } + [Fact] + public void Test_1433() + { + } + [Fact] + public void Test_1434() + { + } + [Fact] + public void Test_1435() + { + } + [Fact] + public void Test_1436() + { + } + [Fact] + public void Test_1437() + { + } + [Fact] + public void Test_1438() + { + } + [Fact] + public void Test_1439() + { + } + [Fact] + public void Test_1440() + { + } + [Fact] + public void Test_1441() + { + } + [Fact] + public void Test_1442() + { + } + [Fact] + public void Test_1443() + { + } + [Fact] + public void Test_1444() + { + } + [Fact] + public void Test_1445() + { + } + [Fact] + public void Test_1446() + { + } + [Fact] + public void Test_1447() + { + } + [Fact] + public void Test_1448() + { + } + [Fact] + public void Test_1449() + { + } + [Fact] + public void Test_1450() + { + } + [Fact] + public void Test_1451() + { + } + [Fact] + public void Test_1452() + { + } + [Fact] + public void Test_1453() + { + } + [Fact] + public void Test_1454() + { + } + [Fact] + public void Test_1455() + { + } + [Fact] + public void Test_1456() + { + } + [Fact] + public void Test_1457() + { + } + [Fact] + public void Test_1458() + { + } + [Fact] + public void Test_1459() + { + } + [Fact] + public void Test_1460() + { + } + [Fact] + public void Test_1461() + { + } + [Fact] + public void Test_1462() + { + } + [Fact] + public void Test_1463() + { + } + [Fact] + public void Test_1464() + { + } + [Fact] + public void Test_1465() + { + } + [Fact] + public void Test_1466() + { + } + [Fact] + public void Test_1467() + { + } + [Fact] + public void Test_1468() + { + } + [Fact] + public void Test_1469() + { + } + [Fact] + public void Test_1470() + { + } + [Fact] + public void Test_1471() + { + } + [Fact] + public void Test_1472() + { + } + [Fact] + public void Test_1473() + { + } + [Fact] + public void Test_1474() + { + } + [Fact] + public void Test_1475() + { + } + [Fact] + public void Test_1476() + { + } + [Fact] + public void Test_1477() + { + } + [Fact] + public void Test_1478() + { + } + [Fact] + public void Test_1479() + { + } + [Fact] + public void Test_1480() + { + } + [Fact] + public void Test_1481() + { + } + [Fact] + public void Test_1482() + { + } + [Fact] + public void Test_1483() + { + } + [Fact] + public void Test_1484() + { + } + [Fact] + public void Test_1485() + { + } + [Fact] + public void Test_1486() + { + } + [Fact] + public void Test_1487() + { + } + [Fact] + public void Test_1488() + { + } + [Fact] + public void Test_1489() + { + } + [Fact] + public void Test_1490() + { + } + [Fact] + public void Test_1491() + { + } + [Fact] + public void Test_1492() + { + } + [Fact] + public void Test_1493() + { + } + [Fact] + public void Test_1494() + { + } + [Fact] + public void Test_1495() + { + } + [Fact] + public void Test_1496() + { + } + [Fact] + public void Test_1497() + { + } + [Fact] + public void Test_1498() + { + } + [Fact] + public void Test_1499() + { + } + [Fact] + public void Test_1500() + { + } + [Fact] + public void Test_1501() + { + } + [Fact] + public void Test_1502() + { + } + [Fact] + public void Test_1503() + { + } + [Fact] + public void Test_1504() + { + } + [Fact] + public void Test_1505() + { + } + [Fact] + public void Test_1506() + { + } + [Fact] + public void Test_1507() + { + } + [Fact] + public void Test_1508() + { + } + [Fact] + public void Test_1509() + { + } + [Fact] + public void Test_1510() + { + } + [Fact] + public void Test_1511() + { + } + [Fact] + public void Test_1512() + { + } + [Fact] + public void Test_1513() + { + } + [Fact] + public void Test_1514() + { + } + [Fact] + public void Test_1515() + { + } + [Fact] + public void Test_1516() + { + } + [Fact] + public void Test_1517() + { + } + [Fact] + public void Test_1518() + { + } + [Fact] + public void Test_1519() + { + } + [Fact] + public void Test_1520() + { + } + [Fact] + public void Test_1521() + { + } + [Fact] + public void Test_1522() + { + } + [Fact] + public void Test_1523() + { + } + [Fact] + public void Test_1524() + { + } + [Fact] + public void Test_1525() + { + } + [Fact] + public void Test_1526() + { + } + [Fact] + public void Test_1527() + { + } + [Fact] + public void Test_1528() + { + } + [Fact] + public void Test_1529() + { + } + [Fact] + public void Test_1530() + { + } + [Fact] + public void Test_1531() + { + } + [Fact] + public void Test_1532() + { + } + [Fact] + public void Test_1533() + { + } + [Fact] + public void Test_1534() + { + } + [Fact] + public void Test_1535() + { + } + [Fact] + public void Test_1536() + { + } + [Fact] + public void Test_1537() + { + } + [Fact] + public void Test_1538() + { + } + [Fact] + public void Test_1539() + { + } + [Fact] + public void Test_1540() + { + } + [Fact] + public void Test_1541() + { + } + [Fact] + public void Test_1542() + { + } + [Fact] + public void Test_1543() + { + } + [Fact] + public void Test_1544() + { + } + [Fact] + public void Test_1545() + { + } + [Fact] + public void Test_1546() + { + } + [Fact] + public void Test_1547() + { + } + [Fact] + public void Test_1548() + { + } + [Fact] + public void Test_1549() + { + } + [Fact] + public void Test_1550() + { + } + [Fact] + public void Test_1551() + { + } + [Fact] + public void Test_1552() + { + } + [Fact] + public void Test_1553() + { + } + [Fact] + public void Test_1554() + { + } + [Fact] + public void Test_1555() + { + } + [Fact] + public void Test_1556() + { + } + [Fact] + public void Test_1557() + { + } + [Fact] + public void Test_1558() + { + } + [Fact] + public void Test_1559() + { + } + [Fact] + public void Test_1560() + { + } + [Fact] + public void Test_1561() + { + } + [Fact] + public void Test_1562() + { + } + [Fact] + public void Test_1563() + { + } + [Fact] + public void Test_1564() + { + } + [Fact] + public void Test_1565() + { + } + [Fact] + public void Test_1566() + { + } + [Fact] + public void Test_1567() + { + } + [Fact] + public void Test_1568() + { + } + [Fact] + public void Test_1569() + { + } + [Fact] + public void Test_1570() + { + } + [Fact] + public void Test_1571() + { + } + [Fact] + public void Test_1572() + { + } + [Fact] + public void Test_1573() + { + } + [Fact] + public void Test_1574() + { + } + [Fact] + public void Test_1575() + { + } + [Fact] + public void Test_1576() + { + } + [Fact] + public void Test_1577() + { + } + [Fact] + public void Test_1578() + { + } + [Fact] + public void Test_1579() + { + } + [Fact] + public void Test_1580() + { + } + [Fact] + public void Test_1581() + { + } + [Fact] + public void Test_1582() + { + } + [Fact] + public void Test_1583() + { + } + [Fact] + public void Test_1584() + { + } + [Fact] + public void Test_1585() + { + } + [Fact] + public void Test_1586() + { + } + [Fact] + public void Test_1587() + { + } + [Fact] + public void Test_1588() + { + } + [Fact] + public void Test_1589() + { + } + [Fact] + public void Test_1590() + { + } + [Fact] + public void Test_1591() + { + } + [Fact] + public void Test_1592() + { + } + [Fact] + public void Test_1593() + { + } + [Fact] + public void Test_1594() + { + } + [Fact] + public void Test_1595() + { + } + [Fact] + public void Test_1596() + { + } + [Fact] + public void Test_1597() + { + } + [Fact] + public void Test_1598() + { + } + [Fact] + public void Test_1599() + { + } + [Fact] + public void Test_1600() + { + } + [Fact] + public void Test_1601() + { + } + [Fact] + public void Test_1602() + { + } + [Fact] + public void Test_1603() + { + } + [Fact] + public void Test_1604() + { + } + [Fact] + public void Test_1605() + { + } + [Fact] + public void Test_1606() + { + } + [Fact] + public void Test_1607() + { + } + [Fact] + public void Test_1608() + { + } + [Fact] + public void Test_1609() + { + } + [Fact] + public void Test_1610() + { + } + [Fact] + public void Test_1611() + { + } + [Fact] + public void Test_1612() + { + } + [Fact] + public void Test_1613() + { + } + [Fact] + public void Test_1614() + { + } + [Fact] + public void Test_1615() + { + } + [Fact] + public void Test_1616() + { + } + [Fact] + public void Test_1617() + { + } + [Fact] + public void Test_1618() + { + } + [Fact] + public void Test_1619() + { + } + [Fact] + public void Test_1620() + { + } + [Fact] + public void Test_1621() + { + } + [Fact] + public void Test_1622() + { + } + [Fact] + public void Test_1623() + { + } + [Fact] + public void Test_1624() + { + } + [Fact] + public void Test_1625() + { + } + [Fact] + public void Test_1626() + { + } + [Fact] + public void Test_1627() + { + } + [Fact] + public void Test_1628() + { + } + [Fact] + public void Test_1629() + { + } + [Fact] + public void Test_1630() + { + } + [Fact] + public void Test_1631() + { + } + [Fact] + public void Test_1632() + { + } + [Fact] + public void Test_1633() + { + } + [Fact] + public void Test_1634() + { + } + [Fact] + public void Test_1635() + { + } + [Fact] + public void Test_1636() + { + } + [Fact] + public void Test_1637() + { + } + [Fact] + public void Test_1638() + { + } + [Fact] + public void Test_1639() + { + } + [Fact] + public void Test_1640() + { + } + [Fact] + public void Test_1641() + { + } + [Fact] + public void Test_1642() + { + } + [Fact] + public void Test_1643() + { + } + [Fact] + public void Test_1644() + { + } + [Fact] + public void Test_1645() + { + } + [Fact] + public void Test_1646() + { + } + [Fact] + public void Test_1647() + { + } + [Fact] + public void Test_1648() + { + } + [Fact] + public void Test_1649() + { + } + [Fact] + public void Test_1650() + { + } + [Fact] + public void Test_1651() + { + } + [Fact] + public void Test_1652() + { + } + [Fact] + public void Test_1653() + { + } + [Fact] + public void Test_1654() + { + } + [Fact] + public void Test_1655() + { + } + [Fact] + public void Test_1656() + { + } + [Fact] + public void Test_1657() + { + } + [Fact] + public void Test_1658() + { + } + [Fact] + public void Test_1659() + { + } + [Fact] + public void Test_1660() + { + } + [Fact] + public void Test_1661() + { + } + [Fact] + public void Test_1662() + { + } + [Fact] + public void Test_1663() + { + } + [Fact] + public void Test_1664() + { + } + [Fact] + public void Test_1665() + { + } + [Fact] + public void Test_1666() + { + } + [Fact] + public void Test_1667() + { + } + [Fact] + public void Test_1668() + { + } + [Fact] + public void Test_1669() + { + } + [Fact] + public void Test_1670() + { + } + [Fact] + public void Test_1671() + { + } + [Fact] + public void Test_1672() + { + } + [Fact] + public void Test_1673() + { + } + [Fact] + public void Test_1674() + { + } + [Fact] + public void Test_1675() + { + } + [Fact] + public void Test_1676() + { + } + [Fact] + public void Test_1677() + { + } + [Fact] + public void Test_1678() + { + } + [Fact] + public void Test_1679() + { + } + [Fact] + public void Test_1680() + { + } + [Fact] + public void Test_1681() + { + } + [Fact] + public void Test_1682() + { + } + [Fact] + public void Test_1683() + { + } + [Fact] + public void Test_1684() + { + } + [Fact] + public void Test_1685() + { + } + [Fact] + public void Test_1686() + { + } + [Fact] + public void Test_1687() + { + } + [Fact] + public void Test_1688() + { + } + [Fact] + public void Test_1689() + { + } + [Fact] + public void Test_1690() + { + } + [Fact] + public void Test_1691() + { + } + [Fact] + public void Test_1692() + { + } + [Fact] + public void Test_1693() + { + } + [Fact] + public void Test_1694() + { + } + [Fact] + public void Test_1695() + { + } + [Fact] + public void Test_1696() + { + } + [Fact] + public void Test_1697() + { + } + [Fact] + public void Test_1698() + { + } + [Fact] + public void Test_1699() + { + } + [Fact] + public void Test_1700() + { + } + [Fact] + public void Test_1701() + { + } + [Fact] + public void Test_1702() + { + } + [Fact] + public void Test_1703() + { + } + [Fact] + public void Test_1704() + { + } + [Fact] + public void Test_1705() + { + } + [Fact] + public void Test_1706() + { + } + [Fact] + public void Test_1707() + { + } + [Fact] + public void Test_1708() + { + } + [Fact] + public void Test_1709() + { + } + [Fact] + public void Test_1710() + { + } + [Fact] + public void Test_1711() + { + } + [Fact] + public void Test_1712() + { + } + [Fact] + public void Test_1713() + { + } + [Fact] + public void Test_1714() + { + } + [Fact] + public void Test_1715() + { + } + [Fact] + public void Test_1716() + { + } + [Fact] + public void Test_1717() + { + } + [Fact] + public void Test_1718() + { + } + [Fact] + public void Test_1719() + { + } + [Fact] + public void Test_1720() + { + } + [Fact] + public void Test_1721() + { + } + [Fact] + public void Test_1722() + { + } + [Fact] + public void Test_1723() + { + } + [Fact] + public void Test_1724() + { + } + [Fact] + public void Test_1725() + { + } + [Fact] + public void Test_1726() + { + } + [Fact] + public void Test_1727() + { + } + [Fact] + public void Test_1728() + { + } + [Fact] + public void Test_1729() + { + } + [Fact] + public void Test_1730() + { + } + [Fact] + public void Test_1731() + { + } + [Fact] + public void Test_1732() + { + } + [Fact] + public void Test_1733() + { + } + [Fact] + public void Test_1734() + { + } + [Fact] + public void Test_1735() + { + } + [Fact] + public void Test_1736() + { + } + [Fact] + public void Test_1737() + { + } + [Fact] + public void Test_1738() + { + } + [Fact] + public void Test_1739() + { + } + [Fact] + public void Test_1740() + { + } + [Fact] + public void Test_1741() + { + } + [Fact] + public void Test_1742() + { + } + [Fact] + public void Test_1743() + { + } + [Fact] + public void Test_1744() + { + } + [Fact] + public void Test_1745() + { + } + [Fact] + public void Test_1746() + { + } + [Fact] + public void Test_1747() + { + } + [Fact] + public void Test_1748() + { + } + [Fact] + public void Test_1749() + { + } + [Fact] + public void Test_1750() + { + } + [Fact] + public void Test_1751() + { + } + [Fact] + public void Test_1752() + { + } + [Fact] + public void Test_1753() + { + } + [Fact] + public void Test_1754() + { + } + [Fact] + public void Test_1755() + { + } + [Fact] + public void Test_1756() + { + } + [Fact] + public void Test_1757() + { + } + [Fact] + public void Test_1758() + { + } + [Fact] + public void Test_1759() + { + } + [Fact] + public void Test_1760() + { + } + [Fact] + public void Test_1761() + { + } + [Fact] + public void Test_1762() + { + } + [Fact] + public void Test_1763() + { + } + [Fact] + public void Test_1764() + { + } + [Fact] + public void Test_1765() + { + } + [Fact] + public void Test_1766() + { + } + [Fact] + public void Test_1767() + { + } + [Fact] + public void Test_1768() + { + } + [Fact] + public void Test_1769() + { + } + [Fact] + public void Test_1770() + { + } + [Fact] + public void Test_1771() + { + } + [Fact] + public void Test_1772() + { + } + [Fact] + public void Test_1773() + { + } + [Fact] + public void Test_1774() + { + } + [Fact] + public void Test_1775() + { + } + [Fact] + public void Test_1776() + { + } + [Fact] + public void Test_1777() + { + } + [Fact] + public void Test_1778() + { + } + [Fact] + public void Test_1779() + { + } + [Fact] + public void Test_1780() + { + } + [Fact] + public void Test_1781() + { + } + [Fact] + public void Test_1782() + { + } + [Fact] + public void Test_1783() + { + } + [Fact] + public void Test_1784() + { + } + [Fact] + public void Test_1785() + { + } + [Fact] + public void Test_1786() + { + } + [Fact] + public void Test_1787() + { + } + [Fact] + public void Test_1788() + { + } + [Fact] + public void Test_1789() + { + } + [Fact] + public void Test_1790() + { + } + [Fact] + public void Test_1791() + { + } + [Fact] + public void Test_1792() + { + } + [Fact] + public void Test_1793() + { + } + [Fact] + public void Test_1794() + { + } + [Fact] + public void Test_1795() + { + } + [Fact] + public void Test_1796() + { + } + [Fact] + public void Test_1797() + { + } + [Fact] + public void Test_1798() + { + } + [Fact] + public void Test_1799() + { + } + [Fact] + public void Test_1800() + { + } + [Fact] + public void Test_1801() + { + } + [Fact] + public void Test_1802() + { + } + [Fact] + public void Test_1803() + { + } + [Fact] + public void Test_1804() + { + } + [Fact] + public void Test_1805() + { + } + [Fact] + public void Test_1806() + { + } + [Fact] + public void Test_1807() + { + } + [Fact] + public void Test_1808() + { + } + [Fact] + public void Test_1809() + { + } + [Fact] + public void Test_1810() + { + } + [Fact] + public void Test_1811() + { + } + [Fact] + public void Test_1812() + { + } + [Fact] + public void Test_1813() + { + } + [Fact] + public void Test_1814() + { + } + [Fact] + public void Test_1815() + { + } + [Fact] + public void Test_1816() + { + } + [Fact] + public void Test_1817() + { + } + [Fact] + public void Test_1818() + { + } + [Fact] + public void Test_1819() + { + } + [Fact] + public void Test_1820() + { + } + [Fact] + public void Test_1821() + { + } + [Fact] + public void Test_1822() + { + } + [Fact] + public void Test_1823() + { + } + [Fact] + public void Test_1824() + { + } + [Fact] + public void Test_1825() + { + } + [Fact] + public void Test_1826() + { + } + [Fact] + public void Test_1827() + { + } + [Fact] + public void Test_1828() + { + } + [Fact] + public void Test_1829() + { + } + [Fact] + public void Test_1830() + { + } + [Fact] + public void Test_1831() + { + } + [Fact] + public void Test_1832() + { + } + [Fact] + public void Test_1833() + { + } + [Fact] + public void Test_1834() + { + } + [Fact] + public void Test_1835() + { + } + [Fact] + public void Test_1836() + { + } + [Fact] + public void Test_1837() + { + } + [Fact] + public void Test_1838() + { + } + [Fact] + public void Test_1839() + { + } + [Fact] + public void Test_1840() + { + } + [Fact] + public void Test_1841() + { + } + [Fact] + public void Test_1842() + { + } + [Fact] + public void Test_1843() + { + } + [Fact] + public void Test_1844() + { + } + [Fact] + public void Test_1845() + { + } + [Fact] + public void Test_1846() + { + } + [Fact] + public void Test_1847() + { + } + [Fact] + public void Test_1848() + { + } + [Fact] + public void Test_1849() + { + } + [Fact] + public void Test_1850() + { + } + [Fact] + public void Test_1851() + { + } + [Fact] + public void Test_1852() + { + } + [Fact] + public void Test_1853() + { + } + [Fact] + public void Test_1854() + { + } + [Fact] + public void Test_1855() + { + } + [Fact] + public void Test_1856() + { + } + [Fact] + public void Test_1857() + { + } + [Fact] + public void Test_1858() + { + } + [Fact] + public void Test_1859() + { + } + [Fact] + public void Test_1860() + { + } + [Fact] + public void Test_1861() + { + } + [Fact] + public void Test_1862() + { + } + [Fact] + public void Test_1863() + { + } + [Fact] + public void Test_1864() + { + } + [Fact] + public void Test_1865() + { + } + [Fact] + public void Test_1866() + { + } + [Fact] + public void Test_1867() + { + } + [Fact] + public void Test_1868() + { + } + [Fact] + public void Test_1869() + { + } + [Fact] + public void Test_1870() + { + } + [Fact] + public void Test_1871() + { + } + [Fact] + public void Test_1872() + { + } + [Fact] + public void Test_1873() + { + } + [Fact] + public void Test_1874() + { + } + [Fact] + public void Test_1875() + { + } + [Fact] + public void Test_1876() + { + } + [Fact] + public void Test_1877() + { + } + [Fact] + public void Test_1878() + { + } + [Fact] + public void Test_1879() + { + } + [Fact] + public void Test_1880() + { + } + [Fact] + public void Test_1881() + { + } + [Fact] + public void Test_1882() + { + } + [Fact] + public void Test_1883() + { + } + [Fact] + public void Test_1884() + { + } + [Fact] + public void Test_1885() + { + } + [Fact] + public void Test_1886() + { + } + [Fact] + public void Test_1887() + { + } + [Fact] + public void Test_1888() + { + } + [Fact] + public void Test_1889() + { + } + [Fact] + public void Test_1890() + { + } + [Fact] + public void Test_1891() + { + } + [Fact] + public void Test_1892() + { + } + [Fact] + public void Test_1893() + { + } + [Fact] + public void Test_1894() + { + } + [Fact] + public void Test_1895() + { + } + [Fact] + public void Test_1896() + { + } + [Fact] + public void Test_1897() + { + } + [Fact] + public void Test_1898() + { + } + [Fact] + public void Test_1899() + { + } + [Fact] + public void Test_1900() + { + } + [Fact] + public void Test_1901() + { + } + [Fact] + public void Test_1902() + { + } + [Fact] + public void Test_1903() + { + } + [Fact] + public void Test_1904() + { + } + [Fact] + public void Test_1905() + { + } + [Fact] + public void Test_1906() + { + } + [Fact] + public void Test_1907() + { + } + [Fact] + public void Test_1908() + { + } + [Fact] + public void Test_1909() + { + } + [Fact] + public void Test_1910() + { + } + [Fact] + public void Test_1911() + { + } + [Fact] + public void Test_1912() + { + } + [Fact] + public void Test_1913() + { + } + [Fact] + public void Test_1914() + { + } + [Fact] + public void Test_1915() + { + } + [Fact] + public void Test_1916() + { + } + [Fact] + public void Test_1917() + { + } + [Fact] + public void Test_1918() + { + } + [Fact] + public void Test_1919() + { + } + [Fact] + public void Test_1920() + { + } + [Fact] + public void Test_1921() + { + } + [Fact] + public void Test_1922() + { + } + [Fact] + public void Test_1923() + { + } + [Fact] + public void Test_1924() + { + } + [Fact] + public void Test_1925() + { + } + [Fact] + public void Test_1926() + { + } + [Fact] + public void Test_1927() + { + } + [Fact] + public void Test_1928() + { + } + [Fact] + public void Test_1929() + { + } + [Fact] + public void Test_1930() + { + } + [Fact] + public void Test_1931() + { + } + [Fact] + public void Test_1932() + { + } + [Fact] + public void Test_1933() + { + } + [Fact] + public void Test_1934() + { + } + [Fact] + public void Test_1935() + { + } + [Fact] + public void Test_1936() + { + } + [Fact] + public void Test_1937() + { + } + [Fact] + public void Test_1938() + { + } + [Fact] + public void Test_1939() + { + } + [Fact] + public void Test_1940() + { + } + [Fact] + public void Test_1941() + { + } + [Fact] + public void Test_1942() + { + } + [Fact] + public void Test_1943() + { + } + [Fact] + public void Test_1944() + { + } + [Fact] + public void Test_1945() + { + } + [Fact] + public void Test_1946() + { + } + [Fact] + public void Test_1947() + { + } + [Fact] + public void Test_1948() + { + } + [Fact] + public void Test_1949() + { + } + [Fact] + public void Test_1950() + { + } + [Fact] + public void Test_1951() + { + } + [Fact] + public void Test_1952() + { + } + [Fact] + public void Test_1953() + { + } + [Fact] + public void Test_1954() + { + } + [Fact] + public void Test_1955() + { + } + [Fact] + public void Test_1956() + { + } + [Fact] + public void Test_1957() + { + } + [Fact] + public void Test_1958() + { + } + [Fact] + public void Test_1959() + { + } + [Fact] + public void Test_1960() + { + } + [Fact] + public void Test_1961() + { + } + [Fact] + public void Test_1962() + { + } + [Fact] + public void Test_1963() + { + } + [Fact] + public void Test_1964() + { + } + [Fact] + public void Test_1965() + { + } + [Fact] + public void Test_1966() + { + } + [Fact] + public void Test_1967() + { + } + [Fact] + public void Test_1968() + { + } + [Fact] + public void Test_1969() + { + } + [Fact] + public void Test_1970() + { + } + [Fact] + public void Test_1971() + { + } + [Fact] + public void Test_1972() + { + } + [Fact] + public void Test_1973() + { + } + [Fact] + public void Test_1974() + { + } + [Fact] + public void Test_1975() + { + } + [Fact] + public void Test_1976() + { + } + [Fact] + public void Test_1977() + { + } + [Fact] + public void Test_1978() + { + } + [Fact] + public void Test_1979() + { + } + [Fact] + public void Test_1980() + { + } + [Fact] + public void Test_1981() + { + } + [Fact] + public void Test_1982() + { + } + [Fact] + public void Test_1983() + { + } + [Fact] + public void Test_1984() + { + } + [Fact] + public void Test_1985() + { + } + [Fact] + public void Test_1986() + { + } + [Fact] + public void Test_1987() + { + } + [Fact] + public void Test_1988() + { + } + [Fact] + public void Test_1989() + { + } + [Fact] + public void Test_1990() + { + } + [Fact] + public void Test_1991() + { + } + [Fact] + public void Test_1992() + { + } + [Fact] + public void Test_1993() + { + } + [Fact] + public void Test_1994() + { + } + [Fact] + public void Test_1995() + { + } + [Fact] + public void Test_1996() + { + } + [Fact] + public void Test_1997() + { + } + [Fact] + public void Test_1998() + { + } + [Fact] + public void Test_1999() + { + } + [Fact] + public void Test_2000() + { + } + [Fact] + public void Test_2001() + { + } + [Fact] + public void Test_2002() + { + } + [Fact] + public void Test_2003() + { + } + [Fact] + public void Test_2004() + { + } + [Fact] + public void Test_2005() + { + } + [Fact] + public void Test_2006() + { + } + [Fact] + public void Test_2007() + { + } + [Fact] + public void Test_2008() + { + } + [Fact] + public void Test_2009() + { + } + [Fact] + public void Test_2010() + { + } + [Fact] + public void Test_2011() + { + } + [Fact] + public void Test_2012() + { + } + [Fact] + public void Test_2013() + { + } + [Fact] + public void Test_2014() + { + } + [Fact] + public void Test_2015() + { + } + [Fact] + public void Test_2016() + { + } + [Fact] + public void Test_2017() + { + } + [Fact] + public void Test_2018() + { + } + [Fact] + public void Test_2019() + { + } + [Fact] + public void Test_2020() + { + } + [Fact] + public void Test_2021() + { + } + [Fact] + public void Test_2022() + { + } + [Fact] + public void Test_2023() + { + } + [Fact] + public void Test_2024() + { + } + [Fact] + public void Test_2025() + { + } + [Fact] + public void Test_2026() + { + } + [Fact] + public void Test_2027() + { + } + [Fact] + public void Test_2028() + { + } + [Fact] + public void Test_2029() + { + } + [Fact] + public void Test_2030() + { + } + [Fact] + public void Test_2031() + { + } + [Fact] + public void Test_2032() + { + } + [Fact] + public void Test_2033() + { + } + [Fact] + public void Test_2034() + { + } + [Fact] + public void Test_2035() + { + } + [Fact] + public void Test_2036() + { + } + [Fact] + public void Test_2037() + { + } + [Fact] + public void Test_2038() + { + } + [Fact] + public void Test_2039() + { + } + [Fact] + public void Test_2040() + { + } + [Fact] + public void Test_2041() + { + } + [Fact] + public void Test_2042() + { + } + [Fact] + public void Test_2043() + { + } + [Fact] + public void Test_2044() + { + } + [Fact] + public void Test_2045() + { + } + [Fact] + public void Test_2046() + { + } + [Fact] + public void Test_2047() + { + } + [Fact] + public void Test_2048() + { + } + [Fact] + public void Test_2049() + { + } + [Fact] + public void Test_2050() + { + } + [Fact] + public void Test_2051() + { + } + [Fact] + public void Test_2052() + { + } + [Fact] + public void Test_2053() + { + } + [Fact] + public void Test_2054() + { + } + [Fact] + public void Test_2055() + { + } + [Fact] + public void Test_2056() + { + } + [Fact] + public void Test_2057() + { + } + [Fact] + public void Test_2058() + { + } + [Fact] + public void Test_2059() + { + } + [Fact] + public void Test_2060() + { + } + [Fact] + public void Test_2061() + { + } + [Fact] + public void Test_2062() + { + } + [Fact] + public void Test_2063() + { + } + [Fact] + public void Test_2064() + { + } + [Fact] + public void Test_2065() + { + } + [Fact] + public void Test_2066() + { + } + [Fact] + public void Test_2067() + { + } + [Fact] + public void Test_2068() + { + } + [Fact] + public void Test_2069() + { + } + [Fact] + public void Test_2070() + { + } + [Fact] + public void Test_2071() + { + } + [Fact] + public void Test_2072() + { + } + [Fact] + public void Test_2073() + { + } + [Fact] + public void Test_2074() + { + } + [Fact] + public void Test_2075() + { + } + [Fact] + public void Test_2076() + { + } + [Fact] + public void Test_2077() + { + } + [Fact] + public void Test_2078() + { + } + [Fact] + public void Test_2079() + { + } + [Fact] + public void Test_2080() + { + } + [Fact] + public void Test_2081() + { + } + [Fact] + public void Test_2082() + { + } + [Fact] + public void Test_2083() + { + } + [Fact] + public void Test_2084() + { + } + [Fact] + public void Test_2085() + { + } + [Fact] + public void Test_2086() + { + } + [Fact] + public void Test_2087() + { + } + [Fact] + public void Test_2088() + { + } + [Fact] + public void Test_2089() + { + } + [Fact] + public void Test_2090() + { + } + [Fact] + public void Test_2091() + { + } + [Fact] + public void Test_2092() + { + } + [Fact] + public void Test_2093() + { + } + [Fact] + public void Test_2094() + { + } + [Fact] + public void Test_2095() + { + } + [Fact] + public void Test_2096() + { + } + [Fact] + public void Test_2097() + { + } + [Fact] + public void Test_2098() + { + } + [Fact] + public void Test_2099() + { + } + [Fact] + public void Test_2100() + { + } + [Fact] + public void Test_2101() + { + } + [Fact] + public void Test_2102() + { + } + [Fact] + public void Test_2103() + { + } + [Fact] + public void Test_2104() + { + } + [Fact] + public void Test_2105() + { + } + [Fact] + public void Test_2106() + { + } + [Fact] + public void Test_2107() + { + } + [Fact] + public void Test_2108() + { + } + [Fact] + public void Test_2109() + { + } + [Fact] + public void Test_2110() + { + } + [Fact] + public void Test_2111() + { + } + [Fact] + public void Test_2112() + { + } + [Fact] + public void Test_2113() + { + } + [Fact] + public void Test_2114() + { + } + [Fact] + public void Test_2115() + { + } + [Fact] + public void Test_2116() + { + } + [Fact] + public void Test_2117() + { + } + [Fact] + public void Test_2118() + { + } + [Fact] + public void Test_2119() + { + } + [Fact] + public void Test_2120() + { + } + [Fact] + public void Test_2121() + { + } + [Fact] + public void Test_2122() + { + } + [Fact] + public void Test_2123() + { + } + [Fact] + public void Test_2124() + { + } + [Fact] + public void Test_2125() + { + } + [Fact] + public void Test_2126() + { + } + [Fact] + public void Test_2127() + { + } + [Fact] + public void Test_2128() + { + } + [Fact] + public void Test_2129() + { + } + [Fact] + public void Test_2130() + { + } + [Fact] + public void Test_2131() + { + } + [Fact] + public void Test_2132() + { + } + [Fact] + public void Test_2133() + { + } + [Fact] + public void Test_2134() + { + } + [Fact] + public void Test_2135() + { + } + [Fact] + public void Test_2136() + { + } + [Fact] + public void Test_2137() + { + } + [Fact] + public void Test_2138() + { + } + [Fact] + public void Test_2139() + { + } + [Fact] + public void Test_2140() + { + } + [Fact] + public void Test_2141() + { + } + [Fact] + public void Test_2142() + { + } + [Fact] + public void Test_2143() + { + } + [Fact] + public void Test_2144() + { + } + [Fact] + public void Test_2145() + { + } + [Fact] + public void Test_2146() + { + } + [Fact] + public void Test_2147() + { + } + [Fact] + public void Test_2148() + { + } + [Fact] + public void Test_2149() + { + } + [Fact] + public void Test_2150() + { + } + [Fact] + public void Test_2151() + { + } + [Fact] + public void Test_2152() + { + } + [Fact] + public void Test_2153() + { + } + [Fact] + public void Test_2154() + { + } + [Fact] + public void Test_2155() + { + } + [Fact] + public void Test_2156() + { + } + [Fact] + public void Test_2157() + { + } + [Fact] + public void Test_2158() + { + } + [Fact] + public void Test_2159() + { + } + [Fact] + public void Test_2160() + { + } + [Fact] + public void Test_2161() + { + } + [Fact] + public void Test_2162() + { + } + [Fact] + public void Test_2163() + { + } + [Fact] + public void Test_2164() + { + } + [Fact] + public void Test_2165() + { + } + [Fact] + public void Test_2166() + { + } + [Fact] + public void Test_2167() + { + } + [Fact] + public void Test_2168() + { + } + [Fact] + public void Test_2169() + { + } + [Fact] + public void Test_2170() + { + } + [Fact] + public void Test_2171() + { + } + [Fact] + public void Test_2172() + { + } + [Fact] + public void Test_2173() + { + } + [Fact] + public void Test_2174() + { + } + [Fact] + public void Test_2175() + { + } + [Fact] + public void Test_2176() + { + } + [Fact] + public void Test_2177() + { + } + [Fact] + public void Test_2178() + { + } + [Fact] + public void Test_2179() + { + } + [Fact] + public void Test_2180() + { + } + [Fact] + public void Test_2181() + { + } + [Fact] + public void Test_2182() + { + } + [Fact] + public void Test_2183() + { + } + [Fact] + public void Test_2184() + { + } + [Fact] + public void Test_2185() + { + } + [Fact] + public void Test_2186() + { + } + [Fact] + public void Test_2187() + { + } + [Fact] + public void Test_2188() + { + } + [Fact] + public void Test_2189() + { + } + [Fact] + public void Test_2190() + { + } + [Fact] + public void Test_2191() + { + } + [Fact] + public void Test_2192() + { + } + [Fact] + public void Test_2193() + { + } + [Fact] + public void Test_2194() + { + } + [Fact] + public void Test_2195() + { + } + [Fact] + public void Test_2196() + { + } + [Fact] + public void Test_2197() + { + } + [Fact] + public void Test_2198() + { + } + [Fact] + public void Test_2199() + { + } + [Fact] + public void Test_2200() + { + } + [Fact] + public void Test_2201() + { + } + [Fact] + public void Test_2202() + { + } + [Fact] + public void Test_2203() + { + } + [Fact] + public void Test_2204() + { + } + [Fact] + public void Test_2205() + { + } + [Fact] + public void Test_2206() + { + } + [Fact] + public void Test_2207() + { + } + [Fact] + public void Test_2208() + { + } + [Fact] + public void Test_2209() + { + } + [Fact] + public void Test_2210() + { + } + [Fact] + public void Test_2211() + { + } + [Fact] + public void Test_2212() + { + } + [Fact] + public void Test_2213() + { + } + [Fact] + public void Test_2214() + { + } + [Fact] + public void Test_2215() + { + } + [Fact] + public void Test_2216() + { + } + [Fact] + public void Test_2217() + { + } + [Fact] + public void Test_2218() + { + } + [Fact] + public void Test_2219() + { + } + [Fact] + public void Test_2220() + { + } + [Fact] + public void Test_2221() + { + } + [Fact] + public void Test_2222() + { + } + [Fact] + public void Test_2223() + { + } + [Fact] + public void Test_2224() + { + } + [Fact] + public void Test_2225() + { + } + [Fact] + public void Test_2226() + { + } + [Fact] + public void Test_2227() + { + } + [Fact] + public void Test_2228() + { + } + [Fact] + public void Test_2229() + { + } + [Fact] + public void Test_2230() + { + } + [Fact] + public void Test_2231() + { + } + [Fact] + public void Test_2232() + { + } + [Fact] + public void Test_2233() + { + } + [Fact] + public void Test_2234() + { + } + [Fact] + public void Test_2235() + { + } + [Fact] + public void Test_2236() + { + } + [Fact] + public void Test_2237() + { + } + [Fact] + public void Test_2238() + { + } + [Fact] + public void Test_2239() + { + } + [Fact] + public void Test_2240() + { + } + [Fact] + public void Test_2241() + { + } + [Fact] + public void Test_2242() + { + } + [Fact] + public void Test_2243() + { + } + [Fact] + public void Test_2244() + { + } + [Fact] + public void Test_2245() + { + } + [Fact] + public void Test_2246() + { + } + [Fact] + public void Test_2247() + { + } + [Fact] + public void Test_2248() + { + } + [Fact] + public void Test_2249() + { + } + [Fact] + public void Test_2250() + { + } + [Fact] + public void Test_2251() + { + } + [Fact] + public void Test_2252() + { + } + [Fact] + public void Test_2253() + { + } + [Fact] + public void Test_2254() + { + } + [Fact] + public void Test_2255() + { + } + [Fact] + public void Test_2256() + { + } + [Fact] + public void Test_2257() + { + } + [Fact] + public void Test_2258() + { + } + [Fact] + public void Test_2259() + { + } + [Fact] + public void Test_2260() + { + } + [Fact] + public void Test_2261() + { + } + [Fact] + public void Test_2262() + { + } + [Fact] + public void Test_2263() + { + } + [Fact] + public void Test_2264() + { + } + [Fact] + public void Test_2265() + { + } + [Fact] + public void Test_2266() + { + } + [Fact] + public void Test_2267() + { + } + [Fact] + public void Test_2268() + { + } + [Fact] + public void Test_2269() + { + } + [Fact] + public void Test_2270() + { + } + [Fact] + public void Test_2271() + { + } + [Fact] + public void Test_2272() + { + } + [Fact] + public void Test_2273() + { + } + [Fact] + public void Test_2274() + { + } + [Fact] + public void Test_2275() + { + } + [Fact] + public void Test_2276() + { + } + [Fact] + public void Test_2277() + { + } + [Fact] + public void Test_2278() + { + } + [Fact] + public void Test_2279() + { + } + [Fact] + public void Test_2280() + { + } + [Fact] + public void Test_2281() + { + } + [Fact] + public void Test_2282() + { + } + [Fact] + public void Test_2283() + { + } + [Fact] + public void Test_2284() + { + } + [Fact] + public void Test_2285() + { + } + [Fact] + public void Test_2286() + { + } + [Fact] + public void Test_2287() + { + } + [Fact] + public void Test_2288() + { + } + [Fact] + public void Test_2289() + { + } + [Fact] + public void Test_2290() + { + } + [Fact] + public void Test_2291() + { + } + [Fact] + public void Test_2292() + { + } + [Fact] + public void Test_2293() + { + } + [Fact] + public void Test_2294() + { + } + [Fact] + public void Test_2295() + { + } + [Fact] + public void Test_2296() + { + } + [Fact] + public void Test_2297() + { + } + [Fact] + public void Test_2298() + { + } + [Fact] + public void Test_2299() + { + } + [Fact] + public void Test_2300() + { + } + [Fact] + public void Test_2301() + { + } + [Fact] + public void Test_2302() + { + } + [Fact] + public void Test_2303() + { + } + [Fact] + public void Test_2304() + { + } + [Fact] + public void Test_2305() + { + } + [Fact] + public void Test_2306() + { + } + [Fact] + public void Test_2307() + { + } + [Fact] + public void Test_2308() + { + } + [Fact] + public void Test_2309() + { + } + [Fact] + public void Test_2310() + { + } + [Fact] + public void Test_2311() + { + } + [Fact] + public void Test_2312() + { + } + [Fact] + public void Test_2313() + { + } + [Fact] + public void Test_2314() + { + } + [Fact] + public void Test_2315() + { + } + [Fact] + public void Test_2316() + { + } + [Fact] + public void Test_2317() + { + } + [Fact] + public void Test_2318() + { + } + [Fact] + public void Test_2319() + { + } + [Fact] + public void Test_2320() + { + } + [Fact] + public void Test_2321() + { + } + [Fact] + public void Test_2322() + { + } + [Fact] + public void Test_2323() + { + } + [Fact] + public void Test_2324() + { + } + [Fact] + public void Test_2325() + { + } + [Fact] + public void Test_2326() + { + } + [Fact] + public void Test_2327() + { + } + [Fact] + public void Test_2328() + { + } + [Fact] + public void Test_2329() + { + } + [Fact] + public void Test_2330() + { + } + [Fact] + public void Test_2331() + { + } + [Fact] + public void Test_2332() + { + } + [Fact] + public void Test_2333() + { + } + [Fact] + public void Test_2334() + { + } + [Fact] + public void Test_2335() + { + } + [Fact] + public void Test_2336() + { + } + [Fact] + public void Test_2337() + { + } + [Fact] + public void Test_2338() + { + } + [Fact] + public void Test_2339() + { + } + [Fact] + public void Test_2340() + { + } + [Fact] + public void Test_2341() + { + } + [Fact] + public void Test_2342() + { + } + [Fact] + public void Test_2343() + { + } + [Fact] + public void Test_2344() + { + } + [Fact] + public void Test_2345() + { + } + [Fact] + public void Test_2346() + { + } + [Fact] + public void Test_2347() + { + } + [Fact] + public void Test_2348() + { + } + [Fact] + public void Test_2349() + { + } + [Fact] + public void Test_2350() + { + } + [Fact] + public void Test_2351() + { + } + [Fact] + public void Test_2352() + { + } + [Fact] + public void Test_2353() + { + } + [Fact] + public void Test_2354() + { + } + [Fact] + public void Test_2355() + { + } + [Fact] + public void Test_2356() + { + } + [Fact] + public void Test_2357() + { + } + [Fact] + public void Test_2358() + { + } + [Fact] + public void Test_2359() + { + } + [Fact] + public void Test_2360() + { + } + [Fact] + public void Test_2361() + { + } + [Fact] + public void Test_2362() + { + } + [Fact] + public void Test_2363() + { + } + [Fact] + public void Test_2364() + { + } + [Fact] + public void Test_2365() + { + } + [Fact] + public void Test_2366() + { + } + [Fact] + public void Test_2367() + { + } + [Fact] + public void Test_2368() + { + } + [Fact] + public void Test_2369() + { + } + [Fact] + public void Test_2370() + { + } + [Fact] + public void Test_2371() + { + } + [Fact] + public void Test_2372() + { + } + [Fact] + public void Test_2373() + { + } + [Fact] + public void Test_2374() + { + } + [Fact] + public void Test_2375() + { + } + [Fact] + public void Test_2376() + { + } + [Fact] + public void Test_2377() + { + } + [Fact] + public void Test_2378() + { + } + [Fact] + public void Test_2379() + { + } + [Fact] + public void Test_2380() + { + } + [Fact] + public void Test_2381() + { + } + [Fact] + public void Test_2382() + { + } + [Fact] + public void Test_2383() + { + } + [Fact] + public void Test_2384() + { + } + [Fact] + public void Test_2385() + { + } + [Fact] + public void Test_2386() + { + } + [Fact] + public void Test_2387() + { + } + [Fact] + public void Test_2388() + { + } + [Fact] + public void Test_2389() + { + } + [Fact] + public void Test_2390() + { + } + [Fact] + public void Test_2391() + { + } + [Fact] + public void Test_2392() + { + } + [Fact] + public void Test_2393() + { + } + [Fact] + public void Test_2394() + { + } + [Fact] + public void Test_2395() + { + } + [Fact] + public void Test_2396() + { + } + [Fact] + public void Test_2397() + { + } + [Fact] + public void Test_2398() + { + } + [Fact] + public void Test_2399() + { + } + [Fact] + public void Test_2400() + { + } + [Fact] + public void Test_2401() + { + } + [Fact] + public void Test_2402() + { + } + [Fact] + public void Test_2403() + { + } + [Fact] + public void Test_2404() + { + } + [Fact] + public void Test_2405() + { + } + [Fact] + public void Test_2406() + { + } + [Fact] + public void Test_2407() + { + } + [Fact] + public void Test_2408() + { + } + [Fact] + public void Test_2409() + { + } + [Fact] + public void Test_2410() + { + } + [Fact] + public void Test_2411() + { + } + [Fact] + public void Test_2412() + { + } + [Fact] + public void Test_2413() + { + } + [Fact] + public void Test_2414() + { + } + [Fact] + public void Test_2415() + { + } + [Fact] + public void Test_2416() + { + } + [Fact] + public void Test_2417() + { + } + [Fact] + public void Test_2418() + { + } + [Fact] + public void Test_2419() + { + } + [Fact] + public void Test_2420() + { + } + [Fact] + public void Test_2421() + { + } + [Fact] + public void Test_2422() + { + } + [Fact] + public void Test_2423() + { + } + [Fact] + public void Test_2424() + { + } + [Fact] + public void Test_2425() + { + } + [Fact] + public void Test_2426() + { + } + [Fact] + public void Test_2427() + { + } + [Fact] + public void Test_2428() + { + } + [Fact] + public void Test_2429() + { + } + [Fact] + public void Test_2430() + { + } + [Fact] + public void Test_2431() + { + } + [Fact] + public void Test_2432() + { + } + [Fact] + public void Test_2433() + { + } + [Fact] + public void Test_2434() + { + } + [Fact] + public void Test_2435() + { + } + [Fact] + public void Test_2436() + { + } + [Fact] + public void Test_2437() + { + } + [Fact] + public void Test_2438() + { + } + [Fact] + public void Test_2439() + { + } + [Fact] + public void Test_2440() + { + } + [Fact] + public void Test_2441() + { + } + [Fact] + public void Test_2442() + { + } + [Fact] + public void Test_2443() + { + } + [Fact] + public void Test_2444() + { + } + [Fact] + public void Test_2445() + { + } + [Fact] + public void Test_2446() + { + } + [Fact] + public void Test_2447() + { + } + [Fact] + public void Test_2448() + { + } + [Fact] + public void Test_2449() + { + } + [Fact] + public void Test_2450() + { + } + [Fact] + public void Test_2451() + { + } + [Fact] + public void Test_2452() + { + } + [Fact] + public void Test_2453() + { + } + [Fact] + public void Test_2454() + { + } + [Fact] + public void Test_2455() + { + } + [Fact] + public void Test_2456() + { + } + [Fact] + public void Test_2457() + { + } + [Fact] + public void Test_2458() + { + } + [Fact] + public void Test_2459() + { + } + [Fact] + public void Test_2460() + { + } + [Fact] + public void Test_2461() + { + } + [Fact] + public void Test_2462() + { + } + [Fact] + public void Test_2463() + { + } + [Fact] + public void Test_2464() + { + } + [Fact] + public void Test_2465() + { + } + [Fact] + public void Test_2466() + { + } + [Fact] + public void Test_2467() + { + } + [Fact] + public void Test_2468() + { + } + [Fact] + public void Test_2469() + { + } + [Fact] + public void Test_2470() + { + } + [Fact] + public void Test_2471() + { + } + [Fact] + public void Test_2472() + { + } + [Fact] + public void Test_2473() + { + } + [Fact] + public void Test_2474() + { + } + [Fact] + public void Test_2475() + { + } + [Fact] + public void Test_2476() + { + } + [Fact] + public void Test_2477() + { + } + [Fact] + public void Test_2478() + { + } + [Fact] + public void Test_2479() + { + } + [Fact] + public void Test_2480() + { + } + [Fact] + public void Test_2481() + { + } + [Fact] + public void Test_2482() + { + } + [Fact] + public void Test_2483() + { + } + [Fact] + public void Test_2484() + { + } + [Fact] + public void Test_2485() + { + } + [Fact] + public void Test_2486() + { + } + [Fact] + public void Test_2487() + { + } + [Fact] + public void Test_2488() + { + } + [Fact] + public void Test_2489() + { + } + [Fact] + public void Test_2490() + { + } + [Fact] + public void Test_2491() + { + } + [Fact] + public void Test_2492() + { + } + [Fact] + public void Test_2493() + { + } + [Fact] + public void Test_2494() + { + } + [Fact] + public void Test_2495() + { + } + [Fact] + public void Test_2496() + { + } + [Fact] + public void Test_2497() + { + } + [Fact] + public void Test_2498() + { + } + [Fact] + public void Test_2499() + { + } + [Fact] + public void Test_2500() + { + } + [Fact] + public void Test_2501() + { + } + [Fact] + public void Test_2502() + { + } + [Fact] + public void Test_2503() + { + } + [Fact] + public void Test_2504() + { + } + [Fact] + public void Test_2505() + { + } + [Fact] + public void Test_2506() + { + } + [Fact] + public void Test_2507() + { + } + [Fact] + public void Test_2508() + { + } + [Fact] + public void Test_2509() + { + } + [Fact] + public void Test_2510() + { + } + [Fact] + public void Test_2511() + { + } + [Fact] + public void Test_2512() + { + } + [Fact] + public void Test_2513() + { + } + [Fact] + public void Test_2514() + { + } + [Fact] + public void Test_2515() + { + } + [Fact] + public void Test_2516() + { + } + [Fact] + public void Test_2517() + { + } + [Fact] + public void Test_2518() + { + } + [Fact] + public void Test_2519() + { + } + [Fact] + public void Test_2520() + { + } + [Fact] + public void Test_2521() + { + } + [Fact] + public void Test_2522() + { + } + [Fact] + public void Test_2523() + { + } + [Fact] + public void Test_2524() + { + } + [Fact] + public void Test_2525() + { + } + [Fact] + public void Test_2526() + { + } + [Fact] + public void Test_2527() + { + } + [Fact] + public void Test_2528() + { + } + [Fact] + public void Test_2529() + { + } + [Fact] + public void Test_2530() + { + } + [Fact] + public void Test_2531() + { + } + [Fact] + public void Test_2532() + { + } + [Fact] + public void Test_2533() + { + } + [Fact] + public void Test_2534() + { + } + [Fact] + public void Test_2535() + { + } + [Fact] + public void Test_2536() + { + } + [Fact] + public void Test_2537() + { + } + [Fact] + public void Test_2538() + { + } + [Fact] + public void Test_2539() + { + } + [Fact] + public void Test_2540() + { + } + [Fact] + public void Test_2541() + { + } + [Fact] + public void Test_2542() + { + } + [Fact] + public void Test_2543() + { + } + [Fact] + public void Test_2544() + { + } + [Fact] + public void Test_2545() + { + } + [Fact] + public void Test_2546() + { + } + [Fact] + public void Test_2547() + { + } + [Fact] + public void Test_2548() + { + } + [Fact] + public void Test_2549() + { + } + [Fact] + public void Test_2550() + { + } + [Fact] + public void Test_2551() + { + } + [Fact] + public void Test_2552() + { + } + [Fact] + public void Test_2553() + { + } + [Fact] + public void Test_2554() + { + } + [Fact] + public void Test_2555() + { + } + [Fact] + public void Test_2556() + { + } + [Fact] + public void Test_2557() + { + } + [Fact] + public void Test_2558() + { + } + [Fact] + public void Test_2559() + { + } + [Fact] + public void Test_2560() + { + } + [Fact] + public void Test_2561() + { + } + [Fact] + public void Test_2562() + { + } + [Fact] + public void Test_2563() + { + } + [Fact] + public void Test_2564() + { + } + [Fact] + public void Test_2565() + { + } + [Fact] + public void Test_2566() + { + } + [Fact] + public void Test_2567() + { + } + [Fact] + public void Test_2568() + { + } + [Fact] + public void Test_2569() + { + } + [Fact] + public void Test_2570() + { + } + [Fact] + public void Test_2571() + { + } + [Fact] + public void Test_2572() + { + } + [Fact] + public void Test_2573() + { + } + [Fact] + public void Test_2574() + { + } + [Fact] + public void Test_2575() + { + } + [Fact] + public void Test_2576() + { + } + [Fact] + public void Test_2577() + { + } + [Fact] + public void Test_2578() + { + } + [Fact] + public void Test_2579() + { + } + [Fact] + public void Test_2580() + { + } + [Fact] + public void Test_2581() + { + } + [Fact] + public void Test_2582() + { + } + [Fact] + public void Test_2583() + { + } + [Fact] + public void Test_2584() + { + } + [Fact] + public void Test_2585() + { + } + [Fact] + public void Test_2586() + { + } + [Fact] + public void Test_2587() + { + } + [Fact] + public void Test_2588() + { + } + [Fact] + public void Test_2589() + { + } + [Fact] + public void Test_2590() + { + } + [Fact] + public void Test_2591() + { + } + [Fact] + public void Test_2592() + { + } + [Fact] + public void Test_2593() + { + } + [Fact] + public void Test_2594() + { + } + [Fact] + public void Test_2595() + { + } + [Fact] + public void Test_2596() + { + } + [Fact] + public void Test_2597() + { + } + [Fact] + public void Test_2598() + { + } + [Fact] + public void Test_2599() + { + } + [Fact] + public void Test_2600() + { + } + [Fact] + public void Test_2601() + { + } + [Fact] + public void Test_2602() + { + } + [Fact] + public void Test_2603() + { + } + [Fact] + public void Test_2604() + { + } + [Fact] + public void Test_2605() + { + } + [Fact] + public void Test_2606() + { + } + [Fact] + public void Test_2607() + { + } + [Fact] + public void Test_2608() + { + } + [Fact] + public void Test_2609() + { + } + [Fact] + public void Test_2610() + { + } + [Fact] + public void Test_2611() + { + } + [Fact] + public void Test_2612() + { + } + [Fact] + public void Test_2613() + { + } + [Fact] + public void Test_2614() + { + } + [Fact] + public void Test_2615() + { + } + [Fact] + public void Test_2616() + { + } + [Fact] + public void Test_2617() + { + } + [Fact] + public void Test_2618() + { + } + [Fact] + public void Test_2619() + { + } + [Fact] + public void Test_2620() + { + } + [Fact] + public void Test_2621() + { + } + [Fact] + public void Test_2622() + { + } + [Fact] + public void Test_2623() + { + } + [Fact] + public void Test_2624() + { + } + [Fact] + public void Test_2625() + { + } + [Fact] + public void Test_2626() + { + } + [Fact] + public void Test_2627() + { + } + [Fact] + public void Test_2628() + { + } + [Fact] + public void Test_2629() + { + } + [Fact] + public void Test_2630() + { + } + [Fact] + public void Test_2631() + { + } + [Fact] + public void Test_2632() + { + } + [Fact] + public void Test_2633() + { + } + [Fact] + public void Test_2634() + { + } + [Fact] + public void Test_2635() + { + } + [Fact] + public void Test_2636() + { + } + [Fact] + public void Test_2637() + { + } + [Fact] + public void Test_2638() + { + } + [Fact] + public void Test_2639() + { + } + [Fact] + public void Test_2640() + { + } + [Fact] + public void Test_2641() + { + } + [Fact] + public void Test_2642() + { + } + [Fact] + public void Test_2643() + { + } + [Fact] + public void Test_2644() + { + } + [Fact] + public void Test_2645() + { + } + [Fact] + public void Test_2646() + { + } + [Fact] + public void Test_2647() + { + } + [Fact] + public void Test_2648() + { + } + [Fact] + public void Test_2649() + { + } + [Fact] + public void Test_2650() + { + } + [Fact] + public void Test_2651() + { + } + [Fact] + public void Test_2652() + { + } + [Fact] + public void Test_2653() + { + } + [Fact] + public void Test_2654() + { + } + [Fact] + public void Test_2655() + { + } + [Fact] + public void Test_2656() + { + } + [Fact] + public void Test_2657() + { + } + [Fact] + public void Test_2658() + { + } + [Fact] + public void Test_2659() + { + } + [Fact] + public void Test_2660() + { + } + [Fact] + public void Test_2661() + { + } + [Fact] + public void Test_2662() + { + } + [Fact] + public void Test_2663() + { + } + [Fact] + public void Test_2664() + { + } + [Fact] + public void Test_2665() + { + } + [Fact] + public void Test_2666() + { + } + [Fact] + public void Test_2667() + { + } + [Fact] + public void Test_2668() + { + } + [Fact] + public void Test_2669() + { + } + [Fact] + public void Test_2670() + { + } + [Fact] + public void Test_2671() + { + } + [Fact] + public void Test_2672() + { + } + [Fact] + public void Test_2673() + { + } + [Fact] + public void Test_2674() + { + } + [Fact] + public void Test_2675() + { + } + [Fact] + public void Test_2676() + { + } + [Fact] + public void Test_2677() + { + } + [Fact] + public void Test_2678() + { + } + [Fact] + public void Test_2679() + { + } + [Fact] + public void Test_2680() + { + } + [Fact] + public void Test_2681() + { + } + [Fact] + public void Test_2682() + { + } + [Fact] + public void Test_2683() + { + } + [Fact] + public void Test_2684() + { + } + [Fact] + public void Test_2685() + { + } + [Fact] + public void Test_2686() + { + } + [Fact] + public void Test_2687() + { + } + [Fact] + public void Test_2688() + { + } + [Fact] + public void Test_2689() + { + } + [Fact] + public void Test_2690() + { + } + [Fact] + public void Test_2691() + { + } + [Fact] + public void Test_2692() + { + } + [Fact] + public void Test_2693() + { + } + [Fact] + public void Test_2694() + { + } + [Fact] + public void Test_2695() + { + } + [Fact] + public void Test_2696() + { + } + [Fact] + public void Test_2697() + { + } + [Fact] + public void Test_2698() + { + } + [Fact] + public void Test_2699() + { + } + [Fact] + public void Test_2700() + { + } + [Fact] + public void Test_2701() + { + } + [Fact] + public void Test_2702() + { + } + [Fact] + public void Test_2703() + { + } + [Fact] + public void Test_2704() + { + } + [Fact] + public void Test_2705() + { + } + [Fact] + public void Test_2706() + { + } + [Fact] + public void Test_2707() + { + } + [Fact] + public void Test_2708() + { + } + [Fact] + public void Test_2709() + { + } + [Fact] + public void Test_2710() + { + } + [Fact] + public void Test_2711() + { + } + [Fact] + public void Test_2712() + { + } + [Fact] + public void Test_2713() + { + } + [Fact] + public void Test_2714() + { + } + [Fact] + public void Test_2715() + { + } + [Fact] + public void Test_2716() + { + } + [Fact] + public void Test_2717() + { + } + [Fact] + public void Test_2718() + { + } + [Fact] + public void Test_2719() + { + } + [Fact] + public void Test_2720() + { + } + [Fact] + public void Test_2721() + { + } + [Fact] + public void Test_2722() + { + } + [Fact] + public void Test_2723() + { + } + [Fact] + public void Test_2724() + { + } + [Fact] + public void Test_2725() + { + } + [Fact] + public void Test_2726() + { + } + [Fact] + public void Test_2727() + { + } + [Fact] + public void Test_2728() + { + } + [Fact] + public void Test_2729() + { + } + [Fact] + public void Test_2730() + { + } + [Fact] + public void Test_2731() + { + } + [Fact] + public void Test_2732() + { + } + [Fact] + public void Test_2733() + { + } + [Fact] + public void Test_2734() + { + } + [Fact] + public void Test_2735() + { + } + [Fact] + public void Test_2736() + { + } + [Fact] + public void Test_2737() + { + } + [Fact] + public void Test_2738() + { + } + [Fact] + public void Test_2739() + { + } + [Fact] + public void Test_2740() + { + } + [Fact] + public void Test_2741() + { + } + [Fact] + public void Test_2742() + { + } + [Fact] + public void Test_2743() + { + } + [Fact] + public void Test_2744() + { + } + [Fact] + public void Test_2745() + { + } + [Fact] + public void Test_2746() + { + } + [Fact] + public void Test_2747() + { + } + [Fact] + public void Test_2748() + { + } + [Fact] + public void Test_2749() + { + } + [Fact] + public void Test_2750() + { + } + [Fact] + public void Test_2751() + { + } + [Fact] + public void Test_2752() + { + } + [Fact] + public void Test_2753() + { + } + [Fact] + public void Test_2754() + { + } + [Fact] + public void Test_2755() + { + } + [Fact] + public void Test_2756() + { + } + [Fact] + public void Test_2757() + { + } + [Fact] + public void Test_2758() + { + } + [Fact] + public void Test_2759() + { + } + [Fact] + public void Test_2760() + { + } + [Fact] + public void Test_2761() + { + } + [Fact] + public void Test_2762() + { + } + [Fact] + public void Test_2763() + { + } + [Fact] + public void Test_2764() + { + } + [Fact] + public void Test_2765() + { + } + [Fact] + public void Test_2766() + { + } + [Fact] + public void Test_2767() + { + } + [Fact] + public void Test_2768() + { + } + [Fact] + public void Test_2769() + { + } + [Fact] + public void Test_2770() + { + } + [Fact] + public void Test_2771() + { + } + [Fact] + public void Test_2772() + { + } + [Fact] + public void Test_2773() + { + } + [Fact] + public void Test_2774() + { + } + [Fact] + public void Test_2775() + { + } + [Fact] + public void Test_2776() + { + } + [Fact] + public void Test_2777() + { + } + [Fact] + public void Test_2778() + { + } + [Fact] + public void Test_2779() + { + } + [Fact] + public void Test_2780() + { + } + [Fact] + public void Test_2781() + { + } + [Fact] + public void Test_2782() + { + } + [Fact] + public void Test_2783() + { + } + [Fact] + public void Test_2784() + { + } + [Fact] + public void Test_2785() + { + } + [Fact] + public void Test_2786() + { + } + [Fact] + public void Test_2787() + { + } + [Fact] + public void Test_2788() + { + } + [Fact] + public void Test_2789() + { + } + [Fact] + public void Test_2790() + { + } + [Fact] + public void Test_2791() + { + } + [Fact] + public void Test_2792() + { + } + [Fact] + public void Test_2793() + { + } + [Fact] + public void Test_2794() + { + } + [Fact] + public void Test_2795() + { + } + [Fact] + public void Test_2796() + { + } + [Fact] + public void Test_2797() + { + } + [Fact] + public void Test_2798() + { + } + [Fact] + public void Test_2799() + { + } + [Fact] + public void Test_2800() + { + } + [Fact] + public void Test_2801() + { + } + [Fact] + public void Test_2802() + { + } + [Fact] + public void Test_2803() + { + } + [Fact] + public void Test_2804() + { + } + [Fact] + public void Test_2805() + { + } + [Fact] + public void Test_2806() + { + } + [Fact] + public void Test_2807() + { + } + [Fact] + public void Test_2808() + { + } + [Fact] + public void Test_2809() + { + } + [Fact] + public void Test_2810() + { + } + [Fact] + public void Test_2811() + { + } + [Fact] + public void Test_2812() + { + } + [Fact] + public void Test_2813() + { + } + [Fact] + public void Test_2814() + { + } + [Fact] + public void Test_2815() + { + } + [Fact] + public void Test_2816() + { + } + [Fact] + public void Test_2817() + { + } + [Fact] + public void Test_2818() + { + } + [Fact] + public void Test_2819() + { + } + [Fact] + public void Test_2820() + { + } + [Fact] + public void Test_2821() + { + } + [Fact] + public void Test_2822() + { + } + [Fact] + public void Test_2823() + { + } + [Fact] + public void Test_2824() + { + } + [Fact] + public void Test_2825() + { + } + [Fact] + public void Test_2826() + { + } + [Fact] + public void Test_2827() + { + } + [Fact] + public void Test_2828() + { + } + [Fact] + public void Test_2829() + { + } + [Fact] + public void Test_2830() + { + } + [Fact] + public void Test_2831() + { + } + [Fact] + public void Test_2832() + { + } + [Fact] + public void Test_2833() + { + } + [Fact] + public void Test_2834() + { + } + [Fact] + public void Test_2835() + { + } + [Fact] + public void Test_2836() + { + } + [Fact] + public void Test_2837() + { + } + [Fact] + public void Test_2838() + { + } + [Fact] + public void Test_2839() + { + } + [Fact] + public void Test_2840() + { + } + [Fact] + public void Test_2841() + { + } + [Fact] + public void Test_2842() + { + } + [Fact] + public void Test_2843() + { + } + [Fact] + public void Test_2844() + { + } + [Fact] + public void Test_2845() + { + } + [Fact] + public void Test_2846() + { + } + [Fact] + public void Test_2847() + { + } + [Fact] + public void Test_2848() + { + } + [Fact] + public void Test_2849() + { + } + [Fact] + public void Test_2850() + { + } + [Fact] + public void Test_2851() + { + } + [Fact] + public void Test_2852() + { + } + [Fact] + public void Test_2853() + { + } + [Fact] + public void Test_2854() + { + } + [Fact] + public void Test_2855() + { + } + [Fact] + public void Test_2856() + { + } + [Fact] + public void Test_2857() + { + } + [Fact] + public void Test_2858() + { + } + [Fact] + public void Test_2859() + { + } + [Fact] + public void Test_2860() + { + } + [Fact] + public void Test_2861() + { + } + [Fact] + public void Test_2862() + { + } + [Fact] + public void Test_2863() + { + } + [Fact] + public void Test_2864() + { + } + [Fact] + public void Test_2865() + { + } + [Fact] + public void Test_2866() + { + } + [Fact] + public void Test_2867() + { + } + [Fact] + public void Test_2868() + { + } + [Fact] + public void Test_2869() + { + } + [Fact] + public void Test_2870() + { + } + [Fact] + public void Test_2871() + { + } + [Fact] + public void Test_2872() + { + } + [Fact] + public void Test_2873() + { + } + [Fact] + public void Test_2874() + { + } + [Fact] + public void Test_2875() + { + } + [Fact] + public void Test_2876() + { + } + [Fact] + public void Test_2877() + { + } + [Fact] + public void Test_2878() + { + } + [Fact] + public void Test_2879() + { + } + [Fact] + public void Test_2880() + { + } + [Fact] + public void Test_2881() + { + } + [Fact] + public void Test_2882() + { + } + [Fact] + public void Test_2883() + { + } + [Fact] + public void Test_2884() + { + } + [Fact] + public void Test_2885() + { + } + [Fact] + public void Test_2886() + { + } + [Fact] + public void Test_2887() + { + } + [Fact] + public void Test_2888() + { + } + [Fact] + public void Test_2889() + { + } + [Fact] + public void Test_2890() + { + } + [Fact] + public void Test_2891() + { + } + [Fact] + public void Test_2892() + { + } + [Fact] + public void Test_2893() + { + } + [Fact] + public void Test_2894() + { + } + [Fact] + public void Test_2895() + { + } + [Fact] + public void Test_2896() + { + } + [Fact] + public void Test_2897() + { + } + [Fact] + public void Test_2898() + { + } + [Fact] + public void Test_2899() + { + } + [Fact] + public void Test_2900() + { + } + [Fact] + public void Test_2901() + { + } + [Fact] + public void Test_2902() + { + } + [Fact] + public void Test_2903() + { + } + [Fact] + public void Test_2904() + { + } + [Fact] + public void Test_2905() + { + } + [Fact] + public void Test_2906() + { + } + [Fact] + public void Test_2907() + { + } + [Fact] + public void Test_2908() + { + } + [Fact] + public void Test_2909() + { + } + [Fact] + public void Test_2910() + { + } + [Fact] + public void Test_2911() + { + } + [Fact] + public void Test_2912() + { + } + [Fact] + public void Test_2913() + { + } + [Fact] + public void Test_2914() + { + } + [Fact] + public void Test_2915() + { + } + [Fact] + public void Test_2916() + { + } + [Fact] + public void Test_2917() + { + } + [Fact] + public void Test_2918() + { + } + [Fact] + public void Test_2919() + { + } + [Fact] + public void Test_2920() + { + } + [Fact] + public void Test_2921() + { + } + [Fact] + public void Test_2922() + { + } + [Fact] + public void Test_2923() + { + } + [Fact] + public void Test_2924() + { + } + [Fact] + public void Test_2925() + { + } + [Fact] + public void Test_2926() + { + } + [Fact] + public void Test_2927() + { + } + [Fact] + public void Test_2928() + { + } + [Fact] + public void Test_2929() + { + } + [Fact] + public void Test_2930() + { + } + [Fact] + public void Test_2931() + { + } + [Fact] + public void Test_2932() + { + } + [Fact] + public void Test_2933() + { + } + [Fact] + public void Test_2934() + { + } + [Fact] + public void Test_2935() + { + } + [Fact] + public void Test_2936() + { + } + [Fact] + public void Test_2937() + { + } + [Fact] + public void Test_2938() + { + } + [Fact] + public void Test_2939() + { + } + [Fact] + public void Test_2940() + { + } + [Fact] + public void Test_2941() + { + } + [Fact] + public void Test_2942() + { + } + [Fact] + public void Test_2943() + { + } + [Fact] + public void Test_2944() + { + } + [Fact] + public void Test_2945() + { + } + [Fact] + public void Test_2946() + { + } + [Fact] + public void Test_2947() + { + } + [Fact] + public void Test_2948() + { + } + [Fact] + public void Test_2949() + { + } + [Fact] + public void Test_2950() + { + } + [Fact] + public void Test_2951() + { + } + [Fact] + public void Test_2952() + { + } + [Fact] + public void Test_2953() + { + } + [Fact] + public void Test_2954() + { + } + [Fact] + public void Test_2955() + { + } + [Fact] + public void Test_2956() + { + } + [Fact] + public void Test_2957() + { + } + [Fact] + public void Test_2958() + { + } + [Fact] + public void Test_2959() + { + } + [Fact] + public void Test_2960() + { + } + [Fact] + public void Test_2961() + { + } + [Fact] + public void Test_2962() + { + } + [Fact] + public void Test_2963() + { + } + [Fact] + public void Test_2964() + { + } + [Fact] + public void Test_2965() + { + } + [Fact] + public void Test_2966() + { + } + [Fact] + public void Test_2967() + { + } + [Fact] + public void Test_2968() + { + } + [Fact] + public void Test_2969() + { + } + [Fact] + public void Test_2970() + { + } + [Fact] + public void Test_2971() + { + } + [Fact] + public void Test_2972() + { + } + [Fact] + public void Test_2973() + { + } + [Fact] + public void Test_2974() + { + } + [Fact] + public void Test_2975() + { + } + [Fact] + public void Test_2976() + { + } + [Fact] + public void Test_2977() + { + } + [Fact] + public void Test_2978() + { + } + [Fact] + public void Test_2979() + { + } + [Fact] + public void Test_2980() + { + } + [Fact] + public void Test_2981() + { + } + [Fact] + public void Test_2982() + { + } + [Fact] + public void Test_2983() + { + } + [Fact] + public void Test_2984() + { + } + [Fact] + public void Test_2985() + { + } + [Fact] + public void Test_2986() + { + } + [Fact] + public void Test_2987() + { + } + [Fact] + public void Test_2988() + { + } + [Fact] + public void Test_2989() + { + } + [Fact] + public void Test_2990() + { + } + [Fact] + public void Test_2991() + { + } + [Fact] + public void Test_2992() + { + } + [Fact] + public void Test_2993() + { + } + [Fact] + public void Test_2994() + { + } + [Fact] + public void Test_2995() + { + } + [Fact] + public void Test_2996() + { + } + [Fact] + public void Test_2997() + { + } + [Fact] + public void Test_2998() + { + } + [Fact] + public void Test_2999() + { + } + [Fact] + public void Test_3000() + { + } + [Fact] + public void Test_3001() + { + } + [Fact] + public void Test_3002() + { + } + [Fact] + public void Test_3003() + { + } + [Fact] + public void Test_3004() + { + } + [Fact] + public void Test_3005() + { + } + [Fact] + public void Test_3006() + { + } + [Fact] + public void Test_3007() + { + } + [Fact] + public void Test_3008() + { + } + [Fact] + public void Test_3009() + { + } + [Fact] + public void Test_3010() + { + } + [Fact] + public void Test_3011() + { + } + [Fact] + public void Test_3012() + { + } + [Fact] + public void Test_3013() + { + } + [Fact] + public void Test_3014() + { + } + [Fact] + public void Test_3015() + { + } + [Fact] + public void Test_3016() + { + } + [Fact] + public void Test_3017() + { + } + [Fact] + public void Test_3018() + { + } + [Fact] + public void Test_3019() + { + } + [Fact] + public void Test_3020() + { + } + [Fact] + public void Test_3021() + { + } + [Fact] + public void Test_3022() + { + } + [Fact] + public void Test_3023() + { + } + [Fact] + public void Test_3024() + { + } + [Fact] + public void Test_3025() + { + } + [Fact] + public void Test_3026() + { + } + [Fact] + public void Test_3027() + { + } + [Fact] + public void Test_3028() + { + } + [Fact] + public void Test_3029() + { + } + [Fact] + public void Test_3030() + { + } + [Fact] + public void Test_3031() + { + } + [Fact] + public void Test_3032() + { + } + [Fact] + public void Test_3033() + { + } + [Fact] + public void Test_3034() + { + } + [Fact] + public void Test_3035() + { + } + [Fact] + public void Test_3036() + { + } + [Fact] + public void Test_3037() + { + } + [Fact] + public void Test_3038() + { + } + [Fact] + public void Test_3039() + { + } + [Fact] + public void Test_3040() + { + } + [Fact] + public void Test_3041() + { + } + [Fact] + public void Test_3042() + { + } + [Fact] + public void Test_3043() + { + } + [Fact] + public void Test_3044() + { + } + [Fact] + public void Test_3045() + { + } + [Fact] + public void Test_3046() + { + } + [Fact] + public void Test_3047() + { + } + [Fact] + public void Test_3048() + { + } + [Fact] + public void Test_3049() + { + } + [Fact] + public void Test_3050() + { + } + [Fact] + public void Test_3051() + { + } + [Fact] + public void Test_3052() + { + } + [Fact] + public void Test_3053() + { + } + [Fact] + public void Test_3054() + { + } + [Fact] + public void Test_3055() + { + } + [Fact] + public void Test_3056() + { + } + [Fact] + public void Test_3057() + { + } + [Fact] + public void Test_3058() + { + } + [Fact] + public void Test_3059() + { + } + [Fact] + public void Test_3060() + { + } + [Fact] + public void Test_3061() + { + } + [Fact] + public void Test_3062() + { + } + [Fact] + public void Test_3063() + { + } + [Fact] + public void Test_3064() + { + } + [Fact] + public void Test_3065() + { + } + [Fact] + public void Test_3066() + { + } + [Fact] + public void Test_3067() + { + } + [Fact] + public void Test_3068() + { + } + [Fact] + public void Test_3069() + { + } + [Fact] + public void Test_3070() + { + } + [Fact] + public void Test_3071() + { + } + [Fact] + public void Test_3072() + { + } + [Fact] + public void Test_3073() + { + } + [Fact] + public void Test_3074() + { + } + [Fact] + public void Test_3075() + { + } + [Fact] + public void Test_3076() + { + } + [Fact] + public void Test_3077() + { + } + [Fact] + public void Test_3078() + { + } + [Fact] + public void Test_3079() + { + } + [Fact] + public void Test_3080() + { + } + [Fact] + public void Test_3081() + { + } + [Fact] + public void Test_3082() + { + } + [Fact] + public void Test_3083() + { + } + [Fact] + public void Test_3084() + { + } + [Fact] + public void Test_3085() + { + } + [Fact] + public void Test_3086() + { + } + [Fact] + public void Test_3087() + { + } + [Fact] + public void Test_3088() + { + } + [Fact] + public void Test_3089() + { + } + [Fact] + public void Test_3090() + { + } + [Fact] + public void Test_3091() + { + } + [Fact] + public void Test_3092() + { + } + [Fact] + public void Test_3093() + { + } + [Fact] + public void Test_3094() + { + } + [Fact] + public void Test_3095() + { + } + [Fact] + public void Test_3096() + { + } + [Fact] + public void Test_3097() + { + } + [Fact] + public void Test_3098() + { + } + [Fact] + public void Test_3099() + { + } + [Fact] + public void Test_3100() + { + } + [Fact] + public void Test_3101() + { + } + [Fact] + public void Test_3102() + { + } + [Fact] + public void Test_3103() + { + } + [Fact] + public void Test_3104() + { + } + [Fact] + public void Test_3105() + { + } + [Fact] + public void Test_3106() + { + } + [Fact] + public void Test_3107() + { + } + [Fact] + public void Test_3108() + { + } + [Fact] + public void Test_3109() + { + } + [Fact] + public void Test_3110() + { + } + [Fact] + public void Test_3111() + { + } + [Fact] + public void Test_3112() + { + } + [Fact] + public void Test_3113() + { + } + [Fact] + public void Test_3114() + { + } + [Fact] + public void Test_3115() + { + } + [Fact] + public void Test_3116() + { + } + [Fact] + public void Test_3117() + { + } + [Fact] + public void Test_3118() + { + } + [Fact] + public void Test_3119() + { + } + [Fact] + public void Test_3120() + { + } + [Fact] + public void Test_3121() + { + } + [Fact] + public void Test_3122() + { + } + [Fact] + public void Test_3123() + { + } + [Fact] + public void Test_3124() + { + } + [Fact] + public void Test_3125() + { + } + [Fact] + public void Test_3126() + { + } + [Fact] + public void Test_3127() + { + } + [Fact] + public void Test_3128() + { + } + [Fact] + public void Test_3129() + { + } + [Fact] + public void Test_3130() + { + } + [Fact] + public void Test_3131() + { + } + [Fact] + public void Test_3132() + { + } + [Fact] + public void Test_3133() + { + } + [Fact] + public void Test_3134() + { + } + [Fact] + public void Test_3135() + { + } + [Fact] + public void Test_3136() + { + } + [Fact] + public void Test_3137() + { + } + [Fact] + public void Test_3138() + { + } + [Fact] + public void Test_3139() + { + } + [Fact] + public void Test_3140() + { + } + [Fact] + public void Test_3141() + { + } + [Fact] + public void Test_3142() + { + } + [Fact] + public void Test_3143() + { + } + [Fact] + public void Test_3144() + { + } + [Fact] + public void Test_3145() + { + } + [Fact] + public void Test_3146() + { + } + [Fact] + public void Test_3147() + { + } + [Fact] + public void Test_3148() + { + } + [Fact] + public void Test_3149() + { + } + [Fact] + public void Test_3150() + { + } + [Fact] + public void Test_3151() + { + } + [Fact] + public void Test_3152() + { + } + [Fact] + public void Test_3153() + { + } + [Fact] + public void Test_3154() + { + } + [Fact] + public void Test_3155() + { + } + [Fact] + public void Test_3156() + { + } + [Fact] + public void Test_3157() + { + } + [Fact] + public void Test_3158() + { + } + [Fact] + public void Test_3159() + { + } + [Fact] + public void Test_3160() + { + } + [Fact] + public void Test_3161() + { + } + [Fact] + public void Test_3162() + { + } + [Fact] + public void Test_3163() + { + } + [Fact] + public void Test_3164() + { + } + [Fact] + public void Test_3165() + { + } + [Fact] + public void Test_3166() + { + } + [Fact] + public void Test_3167() + { + } + [Fact] + public void Test_3168() + { + } + [Fact] + public void Test_3169() + { + } + [Fact] + public void Test_3170() + { + } + [Fact] + public void Test_3171() + { + } + [Fact] + public void Test_3172() + { + } + [Fact] + public void Test_3173() + { + } + [Fact] + public void Test_3174() + { + } + [Fact] + public void Test_3175() + { + } + [Fact] + public void Test_3176() + { + } + [Fact] + public void Test_3177() + { + } + [Fact] + public void Test_3178() + { + } + [Fact] + public void Test_3179() + { + } + [Fact] + public void Test_3180() + { + } + [Fact] + public void Test_3181() + { + } + [Fact] + public void Test_3182() + { + } + [Fact] + public void Test_3183() + { + } + [Fact] + public void Test_3184() + { + } + [Fact] + public void Test_3185() + { + } + [Fact] + public void Test_3186() + { + } + [Fact] + public void Test_3187() + { + } + [Fact] + public void Test_3188() + { + } + [Fact] + public void Test_3189() + { + } + [Fact] + public void Test_3190() + { + } + [Fact] + public void Test_3191() + { + } + [Fact] + public void Test_3192() + { + } + [Fact] + public void Test_3193() + { + } + [Fact] + public void Test_3194() + { + } + [Fact] + public void Test_3195() + { + } + [Fact] + public void Test_3196() + { + } + [Fact] + public void Test_3197() + { + } + [Fact] + public void Test_3198() + { + } + [Fact] + public void Test_3199() + { + } + [Fact] + public void Test_3200() + { + } + [Fact] + public void Test_3201() + { + } + [Fact] + public void Test_3202() + { + } + [Fact] + public void Test_3203() + { + } + [Fact] + public void Test_3204() + { + } + [Fact] + public void Test_3205() + { + } + [Fact] + public void Test_3206() + { + } + [Fact] + public void Test_3207() + { + } + [Fact] + public void Test_3208() + { + } + [Fact] + public void Test_3209() + { + } + [Fact] + public void Test_3210() + { + } + [Fact] + public void Test_3211() + { + } + [Fact] + public void Test_3212() + { + } + [Fact] + public void Test_3213() + { + } + [Fact] + public void Test_3214() + { + } + [Fact] + public void Test_3215() + { + } + [Fact] + public void Test_3216() + { + } + [Fact] + public void Test_3217() + { + } + [Fact] + public void Test_3218() + { + } + [Fact] + public void Test_3219() + { + } + [Fact] + public void Test_3220() + { + } + [Fact] + public void Test_3221() + { + } + [Fact] + public void Test_3222() + { + } + [Fact] + public void Test_3223() + { + } + [Fact] + public void Test_3224() + { + } + [Fact] + public void Test_3225() + { + } + [Fact] + public void Test_3226() + { + } + [Fact] + public void Test_3227() + { + } + [Fact] + public void Test_3228() + { + } + [Fact] + public void Test_3229() + { + } + [Fact] + public void Test_3230() + { + } + [Fact] + public void Test_3231() + { + } + [Fact] + public void Test_3232() + { + } + [Fact] + public void Test_3233() + { + } + [Fact] + public void Test_3234() + { + } + [Fact] + public void Test_3235() + { + } + [Fact] + public void Test_3236() + { + } + [Fact] + public void Test_3237() + { + } + [Fact] + public void Test_3238() + { + } + [Fact] + public void Test_3239() + { + } + [Fact] + public void Test_3240() + { + } + [Fact] + public void Test_3241() + { + } + [Fact] + public void Test_3242() + { + } + [Fact] + public void Test_3243() + { + } + [Fact] + public void Test_3244() + { + } + [Fact] + public void Test_3245() + { + } + [Fact] + public void Test_3246() + { + } + [Fact] + public void Test_3247() + { + } + [Fact] + public void Test_3248() + { + } + [Fact] + public void Test_3249() + { + } + [Fact] + public void Test_3250() + { + } + [Fact] + public void Test_3251() + { + } + [Fact] + public void Test_3252() + { + } + [Fact] + public void Test_3253() + { + } + [Fact] + public void Test_3254() + { + } + [Fact] + public void Test_3255() + { + } + [Fact] + public void Test_3256() + { + } + [Fact] + public void Test_3257() + { + } + [Fact] + public void Test_3258() + { + } + [Fact] + public void Test_3259() + { + } + [Fact] + public void Test_3260() + { + } + [Fact] + public void Test_3261() + { + } + [Fact] + public void Test_3262() + { + } + [Fact] + public void Test_3263() + { + } + [Fact] + public void Test_3264() + { + } + [Fact] + public void Test_3265() + { + } + [Fact] + public void Test_3266() + { + } + [Fact] + public void Test_3267() + { + } + [Fact] + public void Test_3268() + { + } + [Fact] + public void Test_3269() + { + } + [Fact] + public void Test_3270() + { + } + [Fact] + public void Test_3271() + { + } + [Fact] + public void Test_3272() + { + } + [Fact] + public void Test_3273() + { + } + [Fact] + public void Test_3274() + { + } + [Fact] + public void Test_3275() + { + } + [Fact] + public void Test_3276() + { + } + [Fact] + public void Test_3277() + { + } + [Fact] + public void Test_3278() + { + } + [Fact] + public void Test_3279() + { + } + [Fact] + public void Test_3280() + { + } + [Fact] + public void Test_3281() + { + } + [Fact] + public void Test_3282() + { + } + [Fact] + public void Test_3283() + { + } + [Fact] + public void Test_3284() + { + } + [Fact] + public void Test_3285() + { + } + [Fact] + public void Test_3286() + { + } + [Fact] + public void Test_3287() + { + } + [Fact] + public void Test_3288() + { + } + [Fact] + public void Test_3289() + { + } + [Fact] + public void Test_3290() + { + } + [Fact] + public void Test_3291() + { + } + [Fact] + public void Test_3292() + { + } + [Fact] + public void Test_3293() + { + } + [Fact] + public void Test_3294() + { + } + [Fact] + public void Test_3295() + { + } + [Fact] + public void Test_3296() + { + } + [Fact] + public void Test_3297() + { + } + [Fact] + public void Test_3298() + { + } + [Fact] + public void Test_3299() + { + } + [Fact] + public void Test_3300() + { + } + [Fact] + public void Test_3301() + { + } + [Fact] + public void Test_3302() + { + } + [Fact] + public void Test_3303() + { + } + [Fact] + public void Test_3304() + { + } + [Fact] + public void Test_3305() + { + } + [Fact] + public void Test_3306() + { + } + [Fact] + public void Test_3307() + { + } + [Fact] + public void Test_3308() + { + } + [Fact] + public void Test_3309() + { + } + [Fact] + public void Test_3310() + { + } + [Fact] + public void Test_3311() + { + } + [Fact] + public void Test_3312() + { + } + [Fact] + public void Test_3313() + { + } + [Fact] + public void Test_3314() + { + } + [Fact] + public void Test_3315() + { + } + [Fact] + public void Test_3316() + { + } + [Fact] + public void Test_3317() + { + } + [Fact] + public void Test_3318() + { + } + [Fact] + public void Test_3319() + { + } + [Fact] + public void Test_3320() + { + } + [Fact] + public void Test_3321() + { + } + [Fact] + public void Test_3322() + { + } + [Fact] + public void Test_3323() + { + } + [Fact] + public void Test_3324() + { + } + [Fact] + public void Test_3325() + { + } + [Fact] + public void Test_3326() + { + } + [Fact] + public void Test_3327() + { + } + [Fact] + public void Test_3328() + { + } + [Fact] + public void Test_3329() + { + } + [Fact] + public void Test_3330() + { + } + [Fact] + public void Test_3331() + { + } + [Fact] + public void Test_3332() + { + } + [Fact] + public void Test_3333() + { + } + [Fact] + public void Test_3334() + { + } + [Fact] + public void Test_3335() + { + } + [Fact] + public void Test_3336() + { + } + [Fact] + public void Test_3337() + { + } + [Fact] + public void Test_3338() + { + } + [Fact] + public void Test_3339() + { + } + [Fact] + public void Test_3340() + { + } + [Fact] + public void Test_3341() + { + } + [Fact] + public void Test_3342() + { + } + [Fact] + public void Test_3343() + { + } + [Fact] + public void Test_3344() + { + } + [Fact] + public void Test_3345() + { + } + [Fact] + public void Test_3346() + { + } + [Fact] + public void Test_3347() + { + } + [Fact] + public void Test_3348() + { + } + [Fact] + public void Test_3349() + { + } + [Fact] + public void Test_3350() + { + } + [Fact] + public void Test_3351() + { + } + [Fact] + public void Test_3352() + { + } + [Fact] + public void Test_3353() + { + } + [Fact] + public void Test_3354() + { + } + [Fact] + public void Test_3355() + { + } + [Fact] + public void Test_3356() + { + } + [Fact] + public void Test_3357() + { + } + [Fact] + public void Test_3358() + { + } + [Fact] + public void Test_3359() + { + } + [Fact] + public void Test_3360() + { + } + [Fact] + public void Test_3361() + { + } + [Fact] + public void Test_3362() + { + } + [Fact] + public void Test_3363() + { + } + [Fact] + public void Test_3364() + { + } + [Fact] + public void Test_3365() + { + } + [Fact] + public void Test_3366() + { + } + [Fact] + public void Test_3367() + { + } + [Fact] + public void Test_3368() + { + } + [Fact] + public void Test_3369() + { + } + [Fact] + public void Test_3370() + { + } + [Fact] + public void Test_3371() + { + } + [Fact] + public void Test_3372() + { + } + [Fact] + public void Test_3373() + { + } + [Fact] + public void Test_3374() + { + } + [Fact] + public void Test_3375() + { + } + [Fact] + public void Test_3376() + { + } + [Fact] + public void Test_3377() + { + } + [Fact] + public void Test_3378() + { + } + [Fact] + public void Test_3379() + { + } + [Fact] + public void Test_3380() + { + } + [Fact] + public void Test_3381() + { + } + [Fact] + public void Test_3382() + { + } + [Fact] + public void Test_3383() + { + } + [Fact] + public void Test_3384() + { + } + [Fact] + public void Test_3385() + { + } + [Fact] + public void Test_3386() + { + } + [Fact] + public void Test_3387() + { + } + [Fact] + public void Test_3388() + { + } + [Fact] + public void Test_3389() + { + } + [Fact] + public void Test_3390() + { + } + [Fact] + public void Test_3391() + { + } + [Fact] + public void Test_3392() + { + } + [Fact] + public void Test_3393() + { + } + [Fact] + public void Test_3394() + { + } + [Fact] + public void Test_3395() + { + } + [Fact] + public void Test_3396() + { + } + [Fact] + public void Test_3397() + { + } + [Fact] + public void Test_3398() + { + } + [Fact] + public void Test_3399() + { + } + [Fact] + public void Test_3400() + { + } + [Fact] + public void Test_3401() + { + } + [Fact] + public void Test_3402() + { + } + [Fact] + public void Test_3403() + { + } + [Fact] + public void Test_3404() + { + } + [Fact] + public void Test_3405() + { + } + [Fact] + public void Test_3406() + { + } + [Fact] + public void Test_3407() + { + } + [Fact] + public void Test_3408() + { + } + [Fact] + public void Test_3409() + { + } + [Fact] + public void Test_3410() + { + } + [Fact] + public void Test_3411() + { + } + [Fact] + public void Test_3412() + { + } + [Fact] + public void Test_3413() + { + } + [Fact] + public void Test_3414() + { + } + [Fact] + public void Test_3415() + { + } + [Fact] + public void Test_3416() + { + } + [Fact] + public void Test_3417() + { + } + [Fact] + public void Test_3418() + { + } + [Fact] + public void Test_3419() + { + } + [Fact] + public void Test_3420() + { + } + [Fact] + public void Test_3421() + { + } + [Fact] + public void Test_3422() + { + } + [Fact] + public void Test_3423() + { + } + [Fact] + public void Test_3424() + { + } + [Fact] + public void Test_3425() + { + } + [Fact] + public void Test_3426() + { + } + [Fact] + public void Test_3427() + { + } + [Fact] + public void Test_3428() + { + } + [Fact] + public void Test_3429() + { + } + [Fact] + public void Test_3430() + { + } + [Fact] + public void Test_3431() + { + } + [Fact] + public void Test_3432() + { + } + [Fact] + public void Test_3433() + { + } + [Fact] + public void Test_3434() + { + } + [Fact] + public void Test_3435() + { + } + [Fact] + public void Test_3436() + { + } + [Fact] + public void Test_3437() + { + } + [Fact] + public void Test_3438() + { + } + [Fact] + public void Test_3439() + { + } + [Fact] + public void Test_3440() + { + } + [Fact] + public void Test_3441() + { + } + [Fact] + public void Test_3442() + { + } + [Fact] + public void Test_3443() + { + } + [Fact] + public void Test_3444() + { + } + [Fact] + public void Test_3445() + { + } + [Fact] + public void Test_3446() + { + } + [Fact] + public void Test_3447() + { + } + [Fact] + public void Test_3448() + { + } + [Fact] + public void Test_3449() + { + } + [Fact] + public void Test_3450() + { + } + [Fact] + public void Test_3451() + { + } + [Fact] + public void Test_3452() + { + } + [Fact] + public void Test_3453() + { + } + [Fact] + public void Test_3454() + { + } + [Fact] + public void Test_3455() + { + } + [Fact] + public void Test_3456() + { + } + [Fact] + public void Test_3457() + { + } + [Fact] + public void Test_3458() + { + } + [Fact] + public void Test_3459() + { + } + [Fact] + public void Test_3460() + { + } + [Fact] + public void Test_3461() + { + } + [Fact] + public void Test_3462() + { + } + [Fact] + public void Test_3463() + { + } + [Fact] + public void Test_3464() + { + } + [Fact] + public void Test_3465() + { + } + [Fact] + public void Test_3466() + { + } + [Fact] + public void Test_3467() + { + } + [Fact] + public void Test_3468() + { + } + [Fact] + public void Test_3469() + { + } + [Fact] + public void Test_3470() + { + } + [Fact] + public void Test_3471() + { + } + [Fact] + public void Test_3472() + { + } + [Fact] + public void Test_3473() + { + } + [Fact] + public void Test_3474() + { + } + [Fact] + public void Test_3475() + { + } + [Fact] + public void Test_3476() + { + } + [Fact] + public void Test_3477() + { + } + [Fact] + public void Test_3478() + { + } + [Fact] + public void Test_3479() + { + } + [Fact] + public void Test_3480() + { + } + [Fact] + public void Test_3481() + { + } + [Fact] + public void Test_3482() + { + } + [Fact] + public void Test_3483() + { + } + [Fact] + public void Test_3484() + { + } + [Fact] + public void Test_3485() + { + } + [Fact] + public void Test_3486() + { + } + [Fact] + public void Test_3487() + { + } + [Fact] + public void Test_3488() + { + } + [Fact] + public void Test_3489() + { + } + [Fact] + public void Test_3490() + { + } + [Fact] + public void Test_3491() + { + } + [Fact] + public void Test_3492() + { + } + [Fact] + public void Test_3493() + { + } + [Fact] + public void Test_3494() + { + } + [Fact] + public void Test_3495() + { + } + [Fact] + public void Test_3496() + { + } + [Fact] + public void Test_3497() + { + } + [Fact] + public void Test_3498() + { + } + [Fact] + public void Test_3499() + { + } + [Fact] + public void Test_3500() + { + } + [Fact] + public void Test_3501() + { + } + [Fact] + public void Test_3502() + { + } + [Fact] + public void Test_3503() + { + } + [Fact] + public void Test_3504() + { + } + [Fact] + public void Test_3505() + { + } + [Fact] + public void Test_3506() + { + } + [Fact] + public void Test_3507() + { + } + [Fact] + public void Test_3508() + { + } + [Fact] + public void Test_3509() + { + } + [Fact] + public void Test_3510() + { + } + [Fact] + public void Test_3511() + { + } + [Fact] + public void Test_3512() + { + } + [Fact] + public void Test_3513() + { + } + [Fact] + public void Test_3514() + { + } + [Fact] + public void Test_3515() + { + } + [Fact] + public void Test_3516() + { + } + [Fact] + public void Test_3517() + { + } + [Fact] + public void Test_3518() + { + } + [Fact] + public void Test_3519() + { + } + [Fact] + public void Test_3520() + { + } + [Fact] + public void Test_3521() + { + } + [Fact] + public void Test_3522() + { + } + [Fact] + public void Test_3523() + { + } + [Fact] + public void Test_3524() + { + } + [Fact] + public void Test_3525() + { + } + [Fact] + public void Test_3526() + { + } + [Fact] + public void Test_3527() + { + } + [Fact] + public void Test_3528() + { + } + [Fact] + public void Test_3529() + { + } + [Fact] + public void Test_3530() + { + } + [Fact] + public void Test_3531() + { + } + [Fact] + public void Test_3532() + { + } + [Fact] + public void Test_3533() + { + } + [Fact] + public void Test_3534() + { + } + [Fact] + public void Test_3535() + { + } + [Fact] + public void Test_3536() + { + } + [Fact] + public void Test_3537() + { + } + [Fact] + public void Test_3538() + { + } + [Fact] + public void Test_3539() + { + } + [Fact] + public void Test_3540() + { + } + [Fact] + public void Test_3541() + { + } + [Fact] + public void Test_3542() + { + } + [Fact] + public void Test_3543() + { + } + [Fact] + public void Test_3544() + { + } + [Fact] + public void Test_3545() + { + } + [Fact] + public void Test_3546() + { + } + [Fact] + public void Test_3547() + { + } + [Fact] + public void Test_3548() + { + } + [Fact] + public void Test_3549() + { + } + [Fact] + public void Test_3550() + { + } + [Fact] + public void Test_3551() + { + } + [Fact] + public void Test_3552() + { + } + [Fact] + public void Test_3553() + { + } + [Fact] + public void Test_3554() + { + } + [Fact] + public void Test_3555() + { + } + [Fact] + public void Test_3556() + { + } + [Fact] + public void Test_3557() + { + } + [Fact] + public void Test_3558() + { + } + [Fact] + public void Test_3559() + { + } + [Fact] + public void Test_3560() + { + } + [Fact] + public void Test_3561() + { + } + [Fact] + public void Test_3562() + { + } + [Fact] + public void Test_3563() + { + } + [Fact] + public void Test_3564() + { + } + [Fact] + public void Test_3565() + { + } + [Fact] + public void Test_3566() + { + } + [Fact] + public void Test_3567() + { + } + [Fact] + public void Test_3568() + { + } + [Fact] + public void Test_3569() + { + } + [Fact] + public void Test_3570() + { + } + [Fact] + public void Test_3571() + { + } + [Fact] + public void Test_3572() + { + } + [Fact] + public void Test_3573() + { + } + [Fact] + public void Test_3574() + { + } + [Fact] + public void Test_3575() + { + } + [Fact] + public void Test_3576() + { + } + [Fact] + public void Test_3577() + { + } + [Fact] + public void Test_3578() + { + } + [Fact] + public void Test_3579() + { + } + [Fact] + public void Test_3580() + { + } + [Fact] + public void Test_3581() + { + } + [Fact] + public void Test_3582() + { + } + [Fact] + public void Test_3583() + { + } + [Fact] + public void Test_3584() + { + } + [Fact] + public void Test_3585() + { + } + [Fact] + public void Test_3586() + { + } + [Fact] + public void Test_3587() + { + } + [Fact] + public void Test_3588() + { + } + [Fact] + public void Test_3589() + { + } + [Fact] + public void Test_3590() + { + } + [Fact] + public void Test_3591() + { + } + [Fact] + public void Test_3592() + { + } + [Fact] + public void Test_3593() + { + } + [Fact] + public void Test_3594() + { + } + [Fact] + public void Test_3595() + { + } + [Fact] + public void Test_3596() + { + } + [Fact] + public void Test_3597() + { + } + [Fact] + public void Test_3598() + { + } + [Fact] + public void Test_3599() + { + } + [Fact] + public void Test_3600() + { + } + [Fact] + public void Test_3601() + { + } + [Fact] + public void Test_3602() + { + } + [Fact] + public void Test_3603() + { + } + [Fact] + public void Test_3604() + { + } + [Fact] + public void Test_3605() + { + } + [Fact] + public void Test_3606() + { + } + [Fact] + public void Test_3607() + { + } + [Fact] + public void Test_3608() + { + } + [Fact] + public void Test_3609() + { + } + [Fact] + public void Test_3610() + { + } + [Fact] + public void Test_3611() + { + } + [Fact] + public void Test_3612() + { + } + [Fact] + public void Test_3613() + { + } + [Fact] + public void Test_3614() + { + } + [Fact] + public void Test_3615() + { + } + [Fact] + public void Test_3616() + { + } + [Fact] + public void Test_3617() + { + } + [Fact] + public void Test_3618() + { + } + [Fact] + public void Test_3619() + { + } + [Fact] + public void Test_3620() + { + } + [Fact] + public void Test_3621() + { + } + [Fact] + public void Test_3622() + { + } + [Fact] + public void Test_3623() + { + } + [Fact] + public void Test_3624() + { + } + [Fact] + public void Test_3625() + { + } + [Fact] + public void Test_3626() + { + } + [Fact] + public void Test_3627() + { + } + [Fact] + public void Test_3628() + { + } + [Fact] + public void Test_3629() + { + } + [Fact] + public void Test_3630() + { + } + [Fact] + public void Test_3631() + { + } + [Fact] + public void Test_3632() + { + } + [Fact] + public void Test_3633() + { + } + [Fact] + public void Test_3634() + { + } + [Fact] + public void Test_3635() + { + } + [Fact] + public void Test_3636() + { + } + [Fact] + public void Test_3637() + { + } + [Fact] + public void Test_3638() + { + } + [Fact] + public void Test_3639() + { + } + [Fact] + public void Test_3640() + { + } + [Fact] + public void Test_3641() + { + } + [Fact] + public void Test_3642() + { + } + [Fact] + public void Test_3643() + { + } + [Fact] + public void Test_3644() + { + } + [Fact] + public void Test_3645() + { + } + [Fact] + public void Test_3646() + { + } + [Fact] + public void Test_3647() + { + } + [Fact] + public void Test_3648() + { + } + [Fact] + public void Test_3649() + { + } + [Fact] + public void Test_3650() + { + } + [Fact] + public void Test_3651() + { + } + [Fact] + public void Test_3652() + { + } + [Fact] + public void Test_3653() + { + } + [Fact] + public void Test_3654() + { + } + [Fact] + public void Test_3655() + { + } + [Fact] + public void Test_3656() + { + } + [Fact] + public void Test_3657() + { + } + [Fact] + public void Test_3658() + { + } + [Fact] + public void Test_3659() + { + } + [Fact] + public void Test_3660() + { + } + [Fact] + public void Test_3661() + { + } + [Fact] + public void Test_3662() + { + } + [Fact] + public void Test_3663() + { + } + [Fact] + public void Test_3664() + { + } + [Fact] + public void Test_3665() + { + } + [Fact] + public void Test_3666() + { + } + [Fact] + public void Test_3667() + { + } + [Fact] + public void Test_3668() + { + } + [Fact] + public void Test_3669() + { + } + [Fact] + public void Test_3670() + { + } + [Fact] + public void Test_3671() + { + } + [Fact] + public void Test_3672() + { + } + [Fact] + public void Test_3673() + { + } + [Fact] + public void Test_3674() + { + } + [Fact] + public void Test_3675() + { + } + [Fact] + public void Test_3676() + { + } + [Fact] + public void Test_3677() + { + } + [Fact] + public void Test_3678() + { + } + [Fact] + public void Test_3679() + { + } + [Fact] + public void Test_3680() + { + } + [Fact] + public void Test_3681() + { + } + [Fact] + public void Test_3682() + { + } + [Fact] + public void Test_3683() + { + } + [Fact] + public void Test_3684() + { + } + [Fact] + public void Test_3685() + { + } + [Fact] + public void Test_3686() + { + } + [Fact] + public void Test_3687() + { + } + [Fact] + public void Test_3688() + { + } + [Fact] + public void Test_3689() + { + } + [Fact] + public void Test_3690() + { + } + [Fact] + public void Test_3691() + { + } + [Fact] + public void Test_3692() + { + } + [Fact] + public void Test_3693() + { + } + [Fact] + public void Test_3694() + { + } + [Fact] + public void Test_3695() + { + } + [Fact] + public void Test_3696() + { + } + [Fact] + public void Test_3697() + { + } + [Fact] + public void Test_3698() + { + } + [Fact] + public void Test_3699() + { + } + [Fact] + public void Test_3700() + { + } + [Fact] + public void Test_3701() + { + } + [Fact] + public void Test_3702() + { + } + [Fact] + public void Test_3703() + { + } + [Fact] + public void Test_3704() + { + } + [Fact] + public void Test_3705() + { + } + [Fact] + public void Test_3706() + { + } + [Fact] + public void Test_3707() + { + } + [Fact] + public void Test_3708() + { + } + [Fact] + public void Test_3709() + { + } + [Fact] + public void Test_3710() + { + } + [Fact] + public void Test_3711() + { + } + [Fact] + public void Test_3712() + { + } + [Fact] + public void Test_3713() + { + } + [Fact] + public void Test_3714() + { + } + [Fact] + public void Test_3715() + { + } + [Fact] + public void Test_3716() + { + } + [Fact] + public void Test_3717() + { + } + [Fact] + public void Test_3718() + { + } + [Fact] + public void Test_3719() + { + } + [Fact] + public void Test_3720() + { + } + [Fact] + public void Test_3721() + { + } + [Fact] + public void Test_3722() + { + } + [Fact] + public void Test_3723() + { + } + [Fact] + public void Test_3724() + { + } + [Fact] + public void Test_3725() + { + } + [Fact] + public void Test_3726() + { + } + [Fact] + public void Test_3727() + { + } + [Fact] + public void Test_3728() + { + } + [Fact] + public void Test_3729() + { + } + [Fact] + public void Test_3730() + { + } + [Fact] + public void Test_3731() + { + } + [Fact] + public void Test_3732() + { + } + [Fact] + public void Test_3733() + { + } + [Fact] + public void Test_3734() + { + } + [Fact] + public void Test_3735() + { + } + [Fact] + public void Test_3736() + { + } + [Fact] + public void Test_3737() + { + } + [Fact] + public void Test_3738() + { + } + [Fact] + public void Test_3739() + { + } + [Fact] + public void Test_3740() + { + } + [Fact] + public void Test_3741() + { + } + [Fact] + public void Test_3742() + { + } + [Fact] + public void Test_3743() + { + } + [Fact] + public void Test_3744() + { + } + [Fact] + public void Test_3745() + { + } + [Fact] + public void Test_3746() + { + } + [Fact] + public void Test_3747() + { + } + [Fact] + public void Test_3748() + { + } + [Fact] + public void Test_3749() + { + } + [Fact] + public void Test_3750() + { + } + [Fact] + public void Test_3751() + { + } + [Fact] + public void Test_3752() + { + } + [Fact] + public void Test_3753() + { + } + [Fact] + public void Test_3754() + { + } + [Fact] + public void Test_3755() + { + } + [Fact] + public void Test_3756() + { + } + [Fact] + public void Test_3757() + { + } + [Fact] + public void Test_3758() + { + } + [Fact] + public void Test_3759() + { + } + [Fact] + public void Test_3760() + { + } + [Fact] + public void Test_3761() + { + } + [Fact] + public void Test_3762() + { + } + [Fact] + public void Test_3763() + { + } + [Fact] + public void Test_3764() + { + } + [Fact] + public void Test_3765() + { + } + [Fact] + public void Test_3766() + { + } + [Fact] + public void Test_3767() + { + } + [Fact] + public void Test_3768() + { + } + [Fact] + public void Test_3769() + { + } + [Fact] + public void Test_3770() + { + } + [Fact] + public void Test_3771() + { + } + [Fact] + public void Test_3772() + { + } + [Fact] + public void Test_3773() + { + } + [Fact] + public void Test_3774() + { + } + [Fact] + public void Test_3775() + { + } + [Fact] + public void Test_3776() + { + } + [Fact] + public void Test_3777() + { + } + [Fact] + public void Test_3778() + { + } + [Fact] + public void Test_3779() + { + } + [Fact] + public void Test_3780() + { + } + [Fact] + public void Test_3781() + { + } + [Fact] + public void Test_3782() + { + } + [Fact] + public void Test_3783() + { + } + [Fact] + public void Test_3784() + { + } + [Fact] + public void Test_3785() + { + } + [Fact] + public void Test_3786() + { + } + [Fact] + public void Test_3787() + { + } + [Fact] + public void Test_3788() + { + } + [Fact] + public void Test_3789() + { + } + [Fact] + public void Test_3790() + { + } + [Fact] + public void Test_3791() + { + } + [Fact] + public void Test_3792() + { + } + [Fact] + public void Test_3793() + { + } + [Fact] + public void Test_3794() + { + } + [Fact] + public void Test_3795() + { + } + [Fact] + public void Test_3796() + { + } + [Fact] + public void Test_3797() + { + } + [Fact] + public void Test_3798() + { + } + [Fact] + public void Test_3799() + { + } + [Fact] + public void Test_3800() + { + } + [Fact] + public void Test_3801() + { + } + [Fact] + public void Test_3802() + { + } + [Fact] + public void Test_3803() + { + } + [Fact] + public void Test_3804() + { + } + [Fact] + public void Test_3805() + { + } + [Fact] + public void Test_3806() + { + } + [Fact] + public void Test_3807() + { + } + [Fact] + public void Test_3808() + { + } + [Fact] + public void Test_3809() + { + } + [Fact] + public void Test_3810() + { + } + [Fact] + public void Test_3811() + { + } + [Fact] + public void Test_3812() + { + } + [Fact] + public void Test_3813() + { + } + [Fact] + public void Test_3814() + { + } + [Fact] + public void Test_3815() + { + } + [Fact] + public void Test_3816() + { + } + [Fact] + public void Test_3817() + { + } + [Fact] + public void Test_3818() + { + } + [Fact] + public void Test_3819() + { + } + [Fact] + public void Test_3820() + { + } + [Fact] + public void Test_3821() + { + } + [Fact] + public void Test_3822() + { + } + [Fact] + public void Test_3823() + { + } + [Fact] + public void Test_3824() + { + } + [Fact] + public void Test_3825() + { + } + [Fact] + public void Test_3826() + { + } + [Fact] + public void Test_3827() + { + } + [Fact] + public void Test_3828() + { + } + [Fact] + public void Test_3829() + { + } + [Fact] + public void Test_3830() + { + } + [Fact] + public void Test_3831() + { + } + [Fact] + public void Test_3832() + { + } + [Fact] + public void Test_3833() + { + } + [Fact] + public void Test_3834() + { + } + [Fact] + public void Test_3835() + { + } + [Fact] + public void Test_3836() + { + } + [Fact] + public void Test_3837() + { + } + [Fact] + public void Test_3838() + { + } + [Fact] + public void Test_3839() + { + } + [Fact] + public void Test_3840() + { + } + [Fact] + public void Test_3841() + { + } + [Fact] + public void Test_3842() + { + } + [Fact] + public void Test_3843() + { + } + [Fact] + public void Test_3844() + { + } + [Fact] + public void Test_3845() + { + } + [Fact] + public void Test_3846() + { + } + [Fact] + public void Test_3847() + { + } + [Fact] + public void Test_3848() + { + } + [Fact] + public void Test_3849() + { + } + [Fact] + public void Test_3850() + { + } + [Fact] + public void Test_3851() + { + } + [Fact] + public void Test_3852() + { + } + [Fact] + public void Test_3853() + { + } + [Fact] + public void Test_3854() + { + } + [Fact] + public void Test_3855() + { + } + [Fact] + public void Test_3856() + { + } + [Fact] + public void Test_3857() + { + } + [Fact] + public void Test_3858() + { + } + [Fact] + public void Test_3859() + { + } + [Fact] + public void Test_3860() + { + } + [Fact] + public void Test_3861() + { + } + [Fact] + public void Test_3862() + { + } + [Fact] + public void Test_3863() + { + } + [Fact] + public void Test_3864() + { + } + [Fact] + public void Test_3865() + { + } + [Fact] + public void Test_3866() + { + } + [Fact] + public void Test_3867() + { + } + [Fact] + public void Test_3868() + { + } + [Fact] + public void Test_3869() + { + } + [Fact] + public void Test_3870() + { + } + [Fact] + public void Test_3871() + { + } + [Fact] + public void Test_3872() + { + } + [Fact] + public void Test_3873() + { + } + [Fact] + public void Test_3874() + { + } + [Fact] + public void Test_3875() + { + } + [Fact] + public void Test_3876() + { + } + [Fact] + public void Test_3877() + { + } + [Fact] + public void Test_3878() + { + } + [Fact] + public void Test_3879() + { + } + [Fact] + public void Test_3880() + { + } + [Fact] + public void Test_3881() + { + } + [Fact] + public void Test_3882() + { + } + [Fact] + public void Test_3883() + { + } + [Fact] + public void Test_3884() + { + } + [Fact] + public void Test_3885() + { + } + [Fact] + public void Test_3886() + { + } + [Fact] + public void Test_3887() + { + } + [Fact] + public void Test_3888() + { + } + [Fact] + public void Test_3889() + { + } + [Fact] + public void Test_3890() + { + } + [Fact] + public void Test_3891() + { + } + [Fact] + public void Test_3892() + { + } + [Fact] + public void Test_3893() + { + } + [Fact] + public void Test_3894() + { + } + [Fact] + public void Test_3895() + { + } + [Fact] + public void Test_3896() + { + } + [Fact] + public void Test_3897() + { + } + [Fact] + public void Test_3898() + { + } + [Fact] + public void Test_3899() + { + } + [Fact] + public void Test_3900() + { + } + [Fact] + public void Test_3901() + { + } + [Fact] + public void Test_3902() + { + } + [Fact] + public void Test_3903() + { + } + [Fact] + public void Test_3904() + { + } + [Fact] + public void Test_3905() + { + } + [Fact] + public void Test_3906() + { + } + [Fact] + public void Test_3907() + { + } + [Fact] + public void Test_3908() + { + } + [Fact] + public void Test_3909() + { + } + [Fact] + public void Test_3910() + { + } + [Fact] + public void Test_3911() + { + } + [Fact] + public void Test_3912() + { + } + [Fact] + public void Test_3913() + { + } + [Fact] + public void Test_3914() + { + } + [Fact] + public void Test_3915() + { + } + [Fact] + public void Test_3916() + { + } + [Fact] + public void Test_3917() + { + } + [Fact] + public void Test_3918() + { + } + [Fact] + public void Test_3919() + { + } + [Fact] + public void Test_3920() + { + } + [Fact] + public void Test_3921() + { + } + [Fact] + public void Test_3922() + { + } + [Fact] + public void Test_3923() + { + } + [Fact] + public void Test_3924() + { + } + [Fact] + public void Test_3925() + { + } + [Fact] + public void Test_3926() + { + } + [Fact] + public void Test_3927() + { + } + [Fact] + public void Test_3928() + { + } + [Fact] + public void Test_3929() + { + } + [Fact] + public void Test_3930() + { + } + [Fact] + public void Test_3931() + { + } + [Fact] + public void Test_3932() + { + } + [Fact] + public void Test_3933() + { + } + [Fact] + public void Test_3934() + { + } + [Fact] + public void Test_3935() + { + } + [Fact] + public void Test_3936() + { + } + [Fact] + public void Test_3937() + { + } + [Fact] + public void Test_3938() + { + } + [Fact] + public void Test_3939() + { + } + [Fact] + public void Test_3940() + { + } + [Fact] + public void Test_3941() + { + } + [Fact] + public void Test_3942() + { + } + [Fact] + public void Test_3943() + { + } + [Fact] + public void Test_3944() + { + } + [Fact] + public void Test_3945() + { + } + [Fact] + public void Test_3946() + { + } + [Fact] + public void Test_3947() + { + } + [Fact] + public void Test_3948() + { + } + [Fact] + public void Test_3949() + { + } + [Fact] + public void Test_3950() + { + } + [Fact] + public void Test_3951() + { + } + [Fact] + public void Test_3952() + { + } + [Fact] + public void Test_3953() + { + } + [Fact] + public void Test_3954() + { + } + [Fact] + public void Test_3955() + { + } + [Fact] + public void Test_3956() + { + } + [Fact] + public void Test_3957() + { + } + [Fact] + public void Test_3958() + { + } + [Fact] + public void Test_3959() + { + } + [Fact] + public void Test_3960() + { + } + [Fact] + public void Test_3961() + { + } + [Fact] + public void Test_3962() + { + } + [Fact] + public void Test_3963() + { + } + [Fact] + public void Test_3964() + { + } + [Fact] + public void Test_3965() + { + } + [Fact] + public void Test_3966() + { + } + [Fact] + public void Test_3967() + { + } + [Fact] + public void Test_3968() + { + } + [Fact] + public void Test_3969() + { + } + [Fact] + public void Test_3970() + { + } + [Fact] + public void Test_3971() + { + } + [Fact] + public void Test_3972() + { + } + [Fact] + public void Test_3973() + { + } + [Fact] + public void Test_3974() + { + } + [Fact] + public void Test_3975() + { + } + [Fact] + public void Test_3976() + { + } + [Fact] + public void Test_3977() + { + } + [Fact] + public void Test_3978() + { + } + [Fact] + public void Test_3979() + { + } + [Fact] + public void Test_3980() + { + } + [Fact] + public void Test_3981() + { + } + [Fact] + public void Test_3982() + { + } + [Fact] + public void Test_3983() + { + } + [Fact] + public void Test_3984() + { + } + [Fact] + public void Test_3985() + { + } + [Fact] + public void Test_3986() + { + } + [Fact] + public void Test_3987() + { + } + [Fact] + public void Test_3988() + { + } + [Fact] + public void Test_3989() + { + } + [Fact] + public void Test_3990() + { + } + [Fact] + public void Test_3991() + { + } + [Fact] + public void Test_3992() + { + } + [Fact] + public void Test_3993() + { + } + [Fact] + public void Test_3994() + { + } + [Fact] + public void Test_3995() + { + } + [Fact] + public void Test_3996() + { + } + [Fact] + public void Test_3997() + { + } + [Fact] + public void Test_3998() + { + } + [Fact] + public void Test_3999() + { + } + [Fact] + public void Test_4000() + { + } + [Fact] + public void Test_4001() + { + } + [Fact] + public void Test_4002() + { + } + [Fact] + public void Test_4003() + { + } + [Fact] + public void Test_4004() + { + } + [Fact] + public void Test_4005() + { + } + [Fact] + public void Test_4006() + { + } + [Fact] + public void Test_4007() + { + } + [Fact] + public void Test_4008() + { + } + [Fact] + public void Test_4009() + { + } + [Fact] + public void Test_4010() + { + } + [Fact] + public void Test_4011() + { + } + [Fact] + public void Test_4012() + { + } + [Fact] + public void Test_4013() + { + } + [Fact] + public void Test_4014() + { + } + [Fact] + public void Test_4015() + { + } + [Fact] + public void Test_4016() + { + } + [Fact] + public void Test_4017() + { + } + [Fact] + public void Test_4018() + { + } + [Fact] + public void Test_4019() + { + } + [Fact] + public void Test_4020() + { + } + [Fact] + public void Test_4021() + { + } + [Fact] + public void Test_4022() + { + } + [Fact] + public void Test_4023() + { + } + [Fact] + public void Test_4024() + { + } + [Fact] + public void Test_4025() + { + } + [Fact] + public void Test_4026() + { + } + [Fact] + public void Test_4027() + { + } + [Fact] + public void Test_4028() + { + } + [Fact] + public void Test_4029() + { + } + [Fact] + public void Test_4030() + { + } + [Fact] + public void Test_4031() + { + } + [Fact] + public void Test_4032() + { + } + [Fact] + public void Test_4033() + { + } + [Fact] + public void Test_4034() + { + } + [Fact] + public void Test_4035() + { + } + [Fact] + public void Test_4036() + { + } + [Fact] + public void Test_4037() + { + } + [Fact] + public void Test_4038() + { + } + [Fact] + public void Test_4039() + { + } + [Fact] + public void Test_4040() + { + } + [Fact] + public void Test_4041() + { + } + [Fact] + public void Test_4042() + { + } + [Fact] + public void Test_4043() + { + } + [Fact] + public void Test_4044() + { + } + [Fact] + public void Test_4045() + { + } + [Fact] + public void Test_4046() + { + } + [Fact] + public void Test_4047() + { + } + [Fact] + public void Test_4048() + { + } + [Fact] + public void Test_4049() + { + } + [Fact] + public void Test_4050() + { + } + [Fact] + public void Test_4051() + { + } + [Fact] + public void Test_4052() + { + } + [Fact] + public void Test_4053() + { + } + [Fact] + public void Test_4054() + { + } + [Fact] + public void Test_4055() + { + } + [Fact] + public void Test_4056() + { + } + [Fact] + public void Test_4057() + { + } + [Fact] + public void Test_4058() + { + } + [Fact] + public void Test_4059() + { + } + [Fact] + public void Test_4060() + { + } + [Fact] + public void Test_4061() + { + } + [Fact] + public void Test_4062() + { + } + [Fact] + public void Test_4063() + { + } + [Fact] + public void Test_4064() + { + } + [Fact] + public void Test_4065() + { + } + [Fact] + public void Test_4066() + { + } + [Fact] + public void Test_4067() + { + } + [Fact] + public void Test_4068() + { + } + [Fact] + public void Test_4069() + { + } + [Fact] + public void Test_4070() + { + } + [Fact] + public void Test_4071() + { + } + [Fact] + public void Test_4072() + { + } + [Fact] + public void Test_4073() + { + } + [Fact] + public void Test_4074() + { + } + [Fact] + public void Test_4075() + { + } + [Fact] + public void Test_4076() + { + } + [Fact] + public void Test_4077() + { + } + [Fact] + public void Test_4078() + { + } + [Fact] + public void Test_4079() + { + } + [Fact] + public void Test_4080() + { + } + [Fact] + public void Test_4081() + { + } + [Fact] + public void Test_4082() + { + } + [Fact] + public void Test_4083() + { + } + [Fact] + public void Test_4084() + { + } + [Fact] + public void Test_4085() + { + } + [Fact] + public void Test_4086() + { + } + [Fact] + public void Test_4087() + { + } + [Fact] + public void Test_4088() + { + } + [Fact] + public void Test_4089() + { + } + [Fact] + public void Test_4090() + { + } + [Fact] + public void Test_4091() + { + } + [Fact] + public void Test_4092() + { + } + [Fact] + public void Test_4093() + { + } + [Fact] + public void Test_4094() + { + } + [Fact] + public void Test_4095() + { + } + [Fact] + public void Test_4096() + { + } + [Fact] + public void Test_4097() + { + } + [Fact] + public void Test_4098() + { + } + [Fact] + public void Test_4099() + { + } + [Fact] + public void Test_4100() + { + } + [Fact] + public void Test_4101() + { + } + [Fact] + public void Test_4102() + { + } + [Fact] + public void Test_4103() + { + } + [Fact] + public void Test_4104() + { + } + [Fact] + public void Test_4105() + { + } + [Fact] + public void Test_4106() + { + } + [Fact] + public void Test_4107() + { + } + [Fact] + public void Test_4108() + { + } + [Fact] + public void Test_4109() + { + } + [Fact] + public void Test_4110() + { + } + [Fact] + public void Test_4111() + { + } + [Fact] + public void Test_4112() + { + } + [Fact] + public void Test_4113() + { + } + [Fact] + public void Test_4114() + { + } + [Fact] + public void Test_4115() + { + } + [Fact] + public void Test_4116() + { + } + [Fact] + public void Test_4117() + { + } + [Fact] + public void Test_4118() + { + } + [Fact] + public void Test_4119() + { + } + [Fact] + public void Test_4120() + { + } + [Fact] + public void Test_4121() + { + } + [Fact] + public void Test_4122() + { + } + [Fact] + public void Test_4123() + { + } + [Fact] + public void Test_4124() + { + } + [Fact] + public void Test_4125() + { + } + [Fact] + public void Test_4126() + { + } + [Fact] + public void Test_4127() + { + } + [Fact] + public void Test_4128() + { + } + [Fact] + public void Test_4129() + { + } + [Fact] + public void Test_4130() + { + } + [Fact] + public void Test_4131() + { + } + [Fact] + public void Test_4132() + { + } + [Fact] + public void Test_4133() + { + } + [Fact] + public void Test_4134() + { + } + [Fact] + public void Test_4135() + { + } + [Fact] + public void Test_4136() + { + } + [Fact] + public void Test_4137() + { + } + [Fact] + public void Test_4138() + { + } + [Fact] + public void Test_4139() + { + } + [Fact] + public void Test_4140() + { + } + [Fact] + public void Test_4141() + { + } + [Fact] + public void Test_4142() + { + } + [Fact] + public void Test_4143() + { + } + [Fact] + public void Test_4144() + { + } + [Fact] + public void Test_4145() + { + } + [Fact] + public void Test_4146() + { + } + [Fact] + public void Test_4147() + { + } + [Fact] + public void Test_4148() + { + } + [Fact] + public void Test_4149() + { + } + [Fact] + public void Test_4150() + { + } + [Fact] + public void Test_4151() + { + } + [Fact] + public void Test_4152() + { + } + [Fact] + public void Test_4153() + { + } + [Fact] + public void Test_4154() + { + } + [Fact] + public void Test_4155() + { + } + [Fact] + public void Test_4156() + { + } + [Fact] + public void Test_4157() + { + } + [Fact] + public void Test_4158() + { + } + [Fact] + public void Test_4159() + { + } + [Fact] + public void Test_4160() + { + } + [Fact] + public void Test_4161() + { + } + [Fact] + public void Test_4162() + { + } + [Fact] + public void Test_4163() + { + } + [Fact] + public void Test_4164() + { + } + [Fact] + public void Test_4165() + { + } + [Fact] + public void Test_4166() + { + } + [Fact] + public void Test_4167() + { + } + [Fact] + public void Test_4168() + { + } + [Fact] + public void Test_4169() + { + } + [Fact] + public void Test_4170() + { + } + [Fact] + public void Test_4171() + { + } + [Fact] + public void Test_4172() + { + } + [Fact] + public void Test_4173() + { + } + [Fact] + public void Test_4174() + { + } + [Fact] + public void Test_4175() + { + } + [Fact] + public void Test_4176() + { + } + [Fact] + public void Test_4177() + { + } + [Fact] + public void Test_4178() + { + } + [Fact] + public void Test_4179() + { + } + [Fact] + public void Test_4180() + { + } + [Fact] + public void Test_4181() + { + } + [Fact] + public void Test_4182() + { + } + [Fact] + public void Test_4183() + { + } + [Fact] + public void Test_4184() + { + } + [Fact] + public void Test_4185() + { + } + [Fact] + public void Test_4186() + { + } + [Fact] + public void Test_4187() + { + } + [Fact] + public void Test_4188() + { + } + [Fact] + public void Test_4189() + { + } + [Fact] + public void Test_4190() + { + } + [Fact] + public void Test_4191() + { + } + [Fact] + public void Test_4192() + { + } + [Fact] + public void Test_4193() + { + } + [Fact] + public void Test_4194() + { + } + [Fact] + public void Test_4195() + { + } + [Fact] + public void Test_4196() + { + } + [Fact] + public void Test_4197() + { + } + [Fact] + public void Test_4198() + { + } + [Fact] + public void Test_4199() + { + } + [Fact] + public void Test_4200() + { + } + [Fact] + public void Test_4201() + { + } + [Fact] + public void Test_4202() + { + } + [Fact] + public void Test_4203() + { + } + [Fact] + public void Test_4204() + { + } + [Fact] + public void Test_4205() + { + } + [Fact] + public void Test_4206() + { + } + [Fact] + public void Test_4207() + { + } + [Fact] + public void Test_4208() + { + } + [Fact] + public void Test_4209() + { + } + [Fact] + public void Test_4210() + { + } + [Fact] + public void Test_4211() + { + } + [Fact] + public void Test_4212() + { + } + [Fact] + public void Test_4213() + { + } + [Fact] + public void Test_4214() + { + } + [Fact] + public void Test_4215() + { + } + [Fact] + public void Test_4216() + { + } + [Fact] + public void Test_4217() + { + } + [Fact] + public void Test_4218() + { + } + [Fact] + public void Test_4219() + { + } + [Fact] + public void Test_4220() + { + } + [Fact] + public void Test_4221() + { + } + [Fact] + public void Test_4222() + { + } + [Fact] + public void Test_4223() + { + } + [Fact] + public void Test_4224() + { + } + [Fact] + public void Test_4225() + { + } + [Fact] + public void Test_4226() + { + } + [Fact] + public void Test_4227() + { + } + [Fact] + public void Test_4228() + { + } + [Fact] + public void Test_4229() + { + } + [Fact] + public void Test_4230() + { + } + [Fact] + public void Test_4231() + { + } + [Fact] + public void Test_4232() + { + } + [Fact] + public void Test_4233() + { + } + [Fact] + public void Test_4234() + { + } + [Fact] + public void Test_4235() + { + } + [Fact] + public void Test_4236() + { + } + [Fact] + public void Test_4237() + { + } + [Fact] + public void Test_4238() + { + } + [Fact] + public void Test_4239() + { + } + [Fact] + public void Test_4240() + { + } + [Fact] + public void Test_4241() + { + } + [Fact] + public void Test_4242() + { + } + [Fact] + public void Test_4243() + { + } + [Fact] + public void Test_4244() + { + } + [Fact] + public void Test_4245() + { + } + [Fact] + public void Test_4246() + { + } + [Fact] + public void Test_4247() + { + } + [Fact] + public void Test_4248() + { + } + [Fact] + public void Test_4249() + { + } + [Fact] + public void Test_4250() + { + } + [Fact] + public void Test_4251() + { + } + [Fact] + public void Test_4252() + { + } + [Fact] + public void Test_4253() + { + } + [Fact] + public void Test_4254() + { + } + [Fact] + public void Test_4255() + { + } + [Fact] + public void Test_4256() + { + } + [Fact] + public void Test_4257() + { + } + [Fact] + public void Test_4258() + { + } + [Fact] + public void Test_4259() + { + } + [Fact] + public void Test_4260() + { + } + [Fact] + public void Test_4261() + { + } + [Fact] + public void Test_4262() + { + } + [Fact] + public void Test_4263() + { + } + [Fact] + public void Test_4264() + { + } + [Fact] + public void Test_4265() + { + } + [Fact] + public void Test_4266() + { + } + [Fact] + public void Test_4267() + { + } + [Fact] + public void Test_4268() + { + } + [Fact] + public void Test_4269() + { + } + [Fact] + public void Test_4270() + { + } + [Fact] + public void Test_4271() + { + } + [Fact] + public void Test_4272() + { + } + [Fact] + public void Test_4273() + { + } + [Fact] + public void Test_4274() + { + } + [Fact] + public void Test_4275() + { + } + [Fact] + public void Test_4276() + { + } + [Fact] + public void Test_4277() + { + } + [Fact] + public void Test_4278() + { + } + [Fact] + public void Test_4279() + { + } + [Fact] + public void Test_4280() + { + } + [Fact] + public void Test_4281() + { + } + [Fact] + public void Test_4282() + { + } + [Fact] + public void Test_4283() + { + } + [Fact] + public void Test_4284() + { + } + [Fact] + public void Test_4285() + { + } + [Fact] + public void Test_4286() + { + } + [Fact] + public void Test_4287() + { + } + [Fact] + public void Test_4288() + { + } + [Fact] + public void Test_4289() + { + } + [Fact] + public void Test_4290() + { + } + [Fact] + public void Test_4291() + { + } + [Fact] + public void Test_4292() + { + } + [Fact] + public void Test_4293() + { + } + [Fact] + public void Test_4294() + { + } + [Fact] + public void Test_4295() + { + } + [Fact] + public void Test_4296() + { + } + [Fact] + public void Test_4297() + { + } + [Fact] + public void Test_4298() + { + } + [Fact] + public void Test_4299() + { + } + [Fact] + public void Test_4300() + { + } + [Fact] + public void Test_4301() + { + } + [Fact] + public void Test_4302() + { + } + [Fact] + public void Test_4303() + { + } + [Fact] + public void Test_4304() + { + } + [Fact] + public void Test_4305() + { + } + [Fact] + public void Test_4306() + { + } + [Fact] + public void Test_4307() + { + } + [Fact] + public void Test_4308() + { + } + [Fact] + public void Test_4309() + { + } + [Fact] + public void Test_4310() + { + } + [Fact] + public void Test_4311() + { + } + [Fact] + public void Test_4312() + { + } + [Fact] + public void Test_4313() + { + } + [Fact] + public void Test_4314() + { + } + [Fact] + public void Test_4315() + { + } + [Fact] + public void Test_4316() + { + } + [Fact] + public void Test_4317() + { + } + [Fact] + public void Test_4318() + { + } + [Fact] + public void Test_4319() + { + } + [Fact] + public void Test_4320() + { + } + [Fact] + public void Test_4321() + { + } + [Fact] + public void Test_4322() + { + } + [Fact] + public void Test_4323() + { + } + [Fact] + public void Test_4324() + { + } + [Fact] + public void Test_4325() + { + } + [Fact] + public void Test_4326() + { + } + [Fact] + public void Test_4327() + { + } + [Fact] + public void Test_4328() + { + } + [Fact] + public void Test_4329() + { + } + [Fact] + public void Test_4330() + { + } + [Fact] + public void Test_4331() + { + } + [Fact] + public void Test_4332() + { + } + [Fact] + public void Test_4333() + { + } + [Fact] + public void Test_4334() + { + } + [Fact] + public void Test_4335() + { + } + [Fact] + public void Test_4336() + { + } + [Fact] + public void Test_4337() + { + } + [Fact] + public void Test_4338() + { + } + [Fact] + public void Test_4339() + { + } + [Fact] + public void Test_4340() + { + } + [Fact] + public void Test_4341() + { + } + [Fact] + public void Test_4342() + { + } + [Fact] + public void Test_4343() + { + } + [Fact] + public void Test_4344() + { + } + [Fact] + public void Test_4345() + { + } + [Fact] + public void Test_4346() + { + } + [Fact] + public void Test_4347() + { + } + [Fact] + public void Test_4348() + { + } + [Fact] + public void Test_4349() + { + } + [Fact] + public void Test_4350() + { + } + [Fact] + public void Test_4351() + { + } + [Fact] + public void Test_4352() + { + } + [Fact] + public void Test_4353() + { + } + [Fact] + public void Test_4354() + { + } + [Fact] + public void Test_4355() + { + } + [Fact] + public void Test_4356() + { + } + [Fact] + public void Test_4357() + { + } + [Fact] + public void Test_4358() + { + } + [Fact] + public void Test_4359() + { + } + [Fact] + public void Test_4360() + { + } + [Fact] + public void Test_4361() + { + } + [Fact] + public void Test_4362() + { + } + [Fact] + public void Test_4363() + { + } + [Fact] + public void Test_4364() + { + } + [Fact] + public void Test_4365() + { + } + [Fact] + public void Test_4366() + { + } + [Fact] + public void Test_4367() + { + } + [Fact] + public void Test_4368() + { + } + [Fact] + public void Test_4369() + { + } + [Fact] + public void Test_4370() + { + } + [Fact] + public void Test_4371() + { + } + [Fact] + public void Test_4372() + { + } + [Fact] + public void Test_4373() + { + } + [Fact] + public void Test_4374() + { + } + [Fact] + public void Test_4375() + { + } + [Fact] + public void Test_4376() + { + } + [Fact] + public void Test_4377() + { + } + [Fact] + public void Test_4378() + { + } + [Fact] + public void Test_4379() + { + } + [Fact] + public void Test_4380() + { + } + [Fact] + public void Test_4381() + { + } + [Fact] + public void Test_4382() + { + } + [Fact] + public void Test_4383() + { + } + [Fact] + public void Test_4384() + { + } + [Fact] + public void Test_4385() + { + } + [Fact] + public void Test_4386() + { + } + [Fact] + public void Test_4387() + { + } + [Fact] + public void Test_4388() + { + } + [Fact] + public void Test_4389() + { + } + [Fact] + public void Test_4390() + { + } + [Fact] + public void Test_4391() + { + } + [Fact] + public void Test_4392() + { + } + [Fact] + public void Test_4393() + { + } + [Fact] + public void Test_4394() + { + } + [Fact] + public void Test_4395() + { + } + [Fact] + public void Test_4396() + { + } + [Fact] + public void Test_4397() + { + } + [Fact] + public void Test_4398() + { + } + [Fact] + public void Test_4399() + { + } + [Fact] + public void Test_4400() + { + } + [Fact] + public void Test_4401() + { + } + [Fact] + public void Test_4402() + { + } + [Fact] + public void Test_4403() + { + } + [Fact] + public void Test_4404() + { + } + [Fact] + public void Test_4405() + { + } + [Fact] + public void Test_4406() + { + } + [Fact] + public void Test_4407() + { + } + [Fact] + public void Test_4408() + { + } + [Fact] + public void Test_4409() + { + } + [Fact] + public void Test_4410() + { + } + [Fact] + public void Test_4411() + { + } + [Fact] + public void Test_4412() + { + } + [Fact] + public void Test_4413() + { + } + [Fact] + public void Test_4414() + { + } + [Fact] + public void Test_4415() + { + } + [Fact] + public void Test_4416() + { + } + [Fact] + public void Test_4417() + { + } + [Fact] + public void Test_4418() + { + } + [Fact] + public void Test_4419() + { + } + [Fact] + public void Test_4420() + { + } + [Fact] + public void Test_4421() + { + } + [Fact] + public void Test_4422() + { + } + [Fact] + public void Test_4423() + { + } + [Fact] + public void Test_4424() + { + } + [Fact] + public void Test_4425() + { + } + [Fact] + public void Test_4426() + { + } + [Fact] + public void Test_4427() + { + } + [Fact] + public void Test_4428() + { + } + [Fact] + public void Test_4429() + { + } + [Fact] + public void Test_4430() + { + } + [Fact] + public void Test_4431() + { + } + [Fact] + public void Test_4432() + { + } + [Fact] + public void Test_4433() + { + } + [Fact] + public void Test_4434() + { + } + [Fact] + public void Test_4435() + { + } + [Fact] + public void Test_4436() + { + } + [Fact] + public void Test_4437() + { + } + [Fact] + public void Test_4438() + { + } + [Fact] + public void Test_4439() + { + } + [Fact] + public void Test_4440() + { + } + [Fact] + public void Test_4441() + { + } + [Fact] + public void Test_4442() + { + } + [Fact] + public void Test_4443() + { + } + [Fact] + public void Test_4444() + { + } + [Fact] + public void Test_4445() + { + } + [Fact] + public void Test_4446() + { + } + [Fact] + public void Test_4447() + { + } + [Fact] + public void Test_4448() + { + } + [Fact] + public void Test_4449() + { + } + [Fact] + public void Test_4450() + { + } + [Fact] + public void Test_4451() + { + } + [Fact] + public void Test_4452() + { + } + [Fact] + public void Test_4453() + { + } + [Fact] + public void Test_4454() + { + } + [Fact] + public void Test_4455() + { + } + [Fact] + public void Test_4456() + { + } + [Fact] + public void Test_4457() + { + } + [Fact] + public void Test_4458() + { + } + [Fact] + public void Test_4459() + { + } + [Fact] + public void Test_4460() + { + } + [Fact] + public void Test_4461() + { + } + [Fact] + public void Test_4462() + { + } + [Fact] + public void Test_4463() + { + } + [Fact] + public void Test_4464() + { + } + [Fact] + public void Test_4465() + { + } + [Fact] + public void Test_4466() + { + } + [Fact] + public void Test_4467() + { + } + [Fact] + public void Test_4468() + { + } + [Fact] + public void Test_4469() + { + } + [Fact] + public void Test_4470() + { + } + [Fact] + public void Test_4471() + { + } + [Fact] + public void Test_4472() + { + } + [Fact] + public void Test_4473() + { + } + [Fact] + public void Test_4474() + { + } + [Fact] + public void Test_4475() + { + } + [Fact] + public void Test_4476() + { + } + [Fact] + public void Test_4477() + { + } + [Fact] + public void Test_4478() + { + } + [Fact] + public void Test_4479() + { + } + [Fact] + public void Test_4480() + { + } + [Fact] + public void Test_4481() + { + } + [Fact] + public void Test_4482() + { + } + [Fact] + public void Test_4483() + { + } + [Fact] + public void Test_4484() + { + } + [Fact] + public void Test_4485() + { + } + [Fact] + public void Test_4486() + { + } + [Fact] + public void Test_4487() + { + } + [Fact] + public void Test_4488() + { + } + [Fact] + public void Test_4489() + { + } + [Fact] + public void Test_4490() + { + } + [Fact] + public void Test_4491() + { + } + [Fact] + public void Test_4492() + { + } + [Fact] + public void Test_4493() + { + } + [Fact] + public void Test_4494() + { + } + [Fact] + public void Test_4495() + { + } + [Fact] + public void Test_4496() + { + } + [Fact] + public void Test_4497() + { + } + [Fact] + public void Test_4498() + { + } + [Fact] + public void Test_4499() + { + } + [Fact] + public void Test_4500() + { + } + [Fact] + public void Test_4501() + { + } + [Fact] + public void Test_4502() + { + } + [Fact] + public void Test_4503() + { + } + [Fact] + public void Test_4504() + { + } + [Fact] + public void Test_4505() + { + } + [Fact] + public void Test_4506() + { + } + [Fact] + public void Test_4507() + { + } + [Fact] + public void Test_4508() + { + } + [Fact] + public void Test_4509() + { + } + [Fact] + public void Test_4510() + { + } + [Fact] + public void Test_4511() + { + } + [Fact] + public void Test_4512() + { + } + [Fact] + public void Test_4513() + { + } + [Fact] + public void Test_4514() + { + } + [Fact] + public void Test_4515() + { + } + [Fact] + public void Test_4516() + { + } + [Fact] + public void Test_4517() + { + } + [Fact] + public void Test_4518() + { + } + [Fact] + public void Test_4519() + { + } + [Fact] + public void Test_4520() + { + } + [Fact] + public void Test_4521() + { + } + [Fact] + public void Test_4522() + { + } + [Fact] + public void Test_4523() + { + } + [Fact] + public void Test_4524() + { + } + [Fact] + public void Test_4525() + { + } + [Fact] + public void Test_4526() + { + } + [Fact] + public void Test_4527() + { + } + [Fact] + public void Test_4528() + { + } + [Fact] + public void Test_4529() + { + } + [Fact] + public void Test_4530() + { + } + [Fact] + public void Test_4531() + { + } + [Fact] + public void Test_4532() + { + } + [Fact] + public void Test_4533() + { + } + [Fact] + public void Test_4534() + { + } + [Fact] + public void Test_4535() + { + } + [Fact] + public void Test_4536() + { + } + [Fact] + public void Test_4537() + { + } + [Fact] + public void Test_4538() + { + } + [Fact] + public void Test_4539() + { + } + [Fact] + public void Test_4540() + { + } + [Fact] + public void Test_4541() + { + } + [Fact] + public void Test_4542() + { + } + [Fact] + public void Test_4543() + { + } + [Fact] + public void Test_4544() + { + } + [Fact] + public void Test_4545() + { + } + [Fact] + public void Test_4546() + { + } + [Fact] + public void Test_4547() + { + } + [Fact] + public void Test_4548() + { + } + [Fact] + public void Test_4549() + { + } + [Fact] + public void Test_4550() + { + } + [Fact] + public void Test_4551() + { + } + [Fact] + public void Test_4552() + { + } + [Fact] + public void Test_4553() + { + } + [Fact] + public void Test_4554() + { + } + [Fact] + public void Test_4555() + { + } + [Fact] + public void Test_4556() + { + } + [Fact] + public void Test_4557() + { + } + [Fact] + public void Test_4558() + { + } + [Fact] + public void Test_4559() + { + } + [Fact] + public void Test_4560() + { + } + [Fact] + public void Test_4561() + { + } + [Fact] + public void Test_4562() + { + } + [Fact] + public void Test_4563() + { + } + [Fact] + public void Test_4564() + { + } + [Fact] + public void Test_4565() + { + } + [Fact] + public void Test_4566() + { + } + [Fact] + public void Test_4567() + { + } + [Fact] + public void Test_4568() + { + } + [Fact] + public void Test_4569() + { + } + [Fact] + public void Test_4570() + { + } + [Fact] + public void Test_4571() + { + } + [Fact] + public void Test_4572() + { + } + [Fact] + public void Test_4573() + { + } + [Fact] + public void Test_4574() + { + } + [Fact] + public void Test_4575() + { + } + [Fact] + public void Test_4576() + { + } + [Fact] + public void Test_4577() + { + } + [Fact] + public void Test_4578() + { + } + [Fact] + public void Test_4579() + { + } + [Fact] + public void Test_4580() + { + } + [Fact] + public void Test_4581() + { + } + [Fact] + public void Test_4582() + { + } + [Fact] + public void Test_4583() + { + } + [Fact] + public void Test_4584() + { + } + [Fact] + public void Test_4585() + { + } + [Fact] + public void Test_4586() + { + } + [Fact] + public void Test_4587() + { + } + [Fact] + public void Test_4588() + { + } + [Fact] + public void Test_4589() + { + } + [Fact] + public void Test_4590() + { + } + [Fact] + public void Test_4591() + { + } + [Fact] + public void Test_4592() + { + } + [Fact] + public void Test_4593() + { + } + [Fact] + public void Test_4594() + { + } + [Fact] + public void Test_4595() + { + } + [Fact] + public void Test_4596() + { + } + [Fact] + public void Test_4597() + { + } + [Fact] + public void Test_4598() + { + } + [Fact] + public void Test_4599() + { + } + [Fact] + public void Test_4600() + { + } + [Fact] + public void Test_4601() + { + } + [Fact] + public void Test_4602() + { + } + [Fact] + public void Test_4603() + { + } + [Fact] + public void Test_4604() + { + } + [Fact] + public void Test_4605() + { + } + [Fact] + public void Test_4606() + { + } + [Fact] + public void Test_4607() + { + } + [Fact] + public void Test_4608() + { + } + [Fact] + public void Test_4609() + { + } + [Fact] + public void Test_4610() + { + } + [Fact] + public void Test_4611() + { + } + [Fact] + public void Test_4612() + { + } + [Fact] + public void Test_4613() + { + } + [Fact] + public void Test_4614() + { + } + [Fact] + public void Test_4615() + { + } + [Fact] + public void Test_4616() + { + } + [Fact] + public void Test_4617() + { + } + [Fact] + public void Test_4618() + { + } + [Fact] + public void Test_4619() + { + } + [Fact] + public void Test_4620() + { + } + [Fact] + public void Test_4621() + { + } + [Fact] + public void Test_4622() + { + } + [Fact] + public void Test_4623() + { + } + [Fact] + public void Test_4624() + { + } + [Fact] + public void Test_4625() + { + } + [Fact] + public void Test_4626() + { + } + [Fact] + public void Test_4627() + { + } + [Fact] + public void Test_4628() + { + } + [Fact] + public void Test_4629() + { + } + [Fact] + public void Test_4630() + { + } + [Fact] + public void Test_4631() + { + } + [Fact] + public void Test_4632() + { + } + [Fact] + public void Test_4633() + { + } + [Fact] + public void Test_4634() + { + } + [Fact] + public void Test_4635() + { + } + [Fact] + public void Test_4636() + { + } + [Fact] + public void Test_4637() + { + } + [Fact] + public void Test_4638() + { + } + [Fact] + public void Test_4639() + { + } + [Fact] + public void Test_4640() + { + } + [Fact] + public void Test_4641() + { + } + [Fact] + public void Test_4642() + { + } + [Fact] + public void Test_4643() + { + } + [Fact] + public void Test_4644() + { + } + [Fact] + public void Test_4645() + { + } + [Fact] + public void Test_4646() + { + } + [Fact] + public void Test_4647() + { + } + [Fact] + public void Test_4648() + { + } + [Fact] + public void Test_4649() + { + } + [Fact] + public void Test_4650() + { + } + [Fact] + public void Test_4651() + { + } + [Fact] + public void Test_4652() + { + } + [Fact] + public void Test_4653() + { + } + [Fact] + public void Test_4654() + { + } + [Fact] + public void Test_4655() + { + } + [Fact] + public void Test_4656() + { + } + [Fact] + public void Test_4657() + { + } + [Fact] + public void Test_4658() + { + } + [Fact] + public void Test_4659() + { + } + [Fact] + public void Test_4660() + { + } + [Fact] + public void Test_4661() + { + } + [Fact] + public void Test_4662() + { + } + [Fact] + public void Test_4663() + { + } + [Fact] + public void Test_4664() + { + } + [Fact] + public void Test_4665() + { + } + [Fact] + public void Test_4666() + { + } + [Fact] + public void Test_4667() + { + } + [Fact] + public void Test_4668() + { + } + [Fact] + public void Test_4669() + { + } + [Fact] + public void Test_4670() + { + } + [Fact] + public void Test_4671() + { + } + [Fact] + public void Test_4672() + { + } + [Fact] + public void Test_4673() + { + } + [Fact] + public void Test_4674() + { + } + [Fact] + public void Test_4675() + { + } + [Fact] + public void Test_4676() + { + } + [Fact] + public void Test_4677() + { + } + [Fact] + public void Test_4678() + { + } + [Fact] + public void Test_4679() + { + } + [Fact] + public void Test_4680() + { + } + [Fact] + public void Test_4681() + { + } + [Fact] + public void Test_4682() + { + } + [Fact] + public void Test_4683() + { + } + [Fact] + public void Test_4684() + { + } + [Fact] + public void Test_4685() + { + } + [Fact] + public void Test_4686() + { + } + [Fact] + public void Test_4687() + { + } + [Fact] + public void Test_4688() + { + } + [Fact] + public void Test_4689() + { + } + [Fact] + public void Test_4690() + { + } + [Fact] + public void Test_4691() + { + } + [Fact] + public void Test_4692() + { + } + [Fact] + public void Test_4693() + { + } + [Fact] + public void Test_4694() + { + } + [Fact] + public void Test_4695() + { + } + [Fact] + public void Test_4696() + { + } + [Fact] + public void Test_4697() + { + } + [Fact] + public void Test_4698() + { + } + [Fact] + public void Test_4699() + { + } + [Fact] + public void Test_4700() + { + } + [Fact] + public void Test_4701() + { + } + [Fact] + public void Test_4702() + { + } + [Fact] + public void Test_4703() + { + } + [Fact] + public void Test_4704() + { + } + [Fact] + public void Test_4705() + { + } + [Fact] + public void Test_4706() + { + } + [Fact] + public void Test_4707() + { + } + [Fact] + public void Test_4708() + { + } + [Fact] + public void Test_4709() + { + } + [Fact] + public void Test_4710() + { + } + [Fact] + public void Test_4711() + { + } + [Fact] + public void Test_4712() + { + } + [Fact] + public void Test_4713() + { + } + [Fact] + public void Test_4714() + { + } + [Fact] + public void Test_4715() + { + } + [Fact] + public void Test_4716() + { + } + [Fact] + public void Test_4717() + { + } + [Fact] + public void Test_4718() + { + } + [Fact] + public void Test_4719() + { + } + [Fact] + public void Test_4720() + { + } + [Fact] + public void Test_4721() + { + } + [Fact] + public void Test_4722() + { + } + [Fact] + public void Test_4723() + { + } + [Fact] + public void Test_4724() + { + } + [Fact] + public void Test_4725() + { + } + [Fact] + public void Test_4726() + { + } + [Fact] + public void Test_4727() + { + } + [Fact] + public void Test_4728() + { + } + [Fact] + public void Test_4729() + { + } + [Fact] + public void Test_4730() + { + } + [Fact] + public void Test_4731() + { + } + [Fact] + public void Test_4732() + { + } + [Fact] + public void Test_4733() + { + } + [Fact] + public void Test_4734() + { + } + [Fact] + public void Test_4735() + { + } + [Fact] + public void Test_4736() + { + } + [Fact] + public void Test_4737() + { + } + [Fact] + public void Test_4738() + { + } + [Fact] + public void Test_4739() + { + } + [Fact] + public void Test_4740() + { + } + [Fact] + public void Test_4741() + { + } + [Fact] + public void Test_4742() + { + } + [Fact] + public void Test_4743() + { + } + [Fact] + public void Test_4744() + { + } + [Fact] + public void Test_4745() + { + } + [Fact] + public void Test_4746() + { + } + [Fact] + public void Test_4747() + { + } + [Fact] + public void Test_4748() + { + } + [Fact] + public void Test_4749() + { + } + [Fact] + public void Test_4750() + { + } + [Fact] + public void Test_4751() + { + } + [Fact] + public void Test_4752() + { + } + [Fact] + public void Test_4753() + { + } + [Fact] + public void Test_4754() + { + } + [Fact] + public void Test_4755() + { + } + [Fact] + public void Test_4756() + { + } + [Fact] + public void Test_4757() + { + } + [Fact] + public void Test_4758() + { + } + [Fact] + public void Test_4759() + { + } + [Fact] + public void Test_4760() + { + } + [Fact] + public void Test_4761() + { + } + [Fact] + public void Test_4762() + { + } + [Fact] + public void Test_4763() + { + } + [Fact] + public void Test_4764() + { + } + [Fact] + public void Test_4765() + { + } + [Fact] + public void Test_4766() + { + } + [Fact] + public void Test_4767() + { + } + [Fact] + public void Test_4768() + { + } + [Fact] + public void Test_4769() + { + } + [Fact] + public void Test_4770() + { + } + [Fact] + public void Test_4771() + { + } + [Fact] + public void Test_4772() + { + } + [Fact] + public void Test_4773() + { + } + [Fact] + public void Test_4774() + { + } + [Fact] + public void Test_4775() + { + } + [Fact] + public void Test_4776() + { + } + [Fact] + public void Test_4777() + { + } + [Fact] + public void Test_4778() + { + } + [Fact] + public void Test_4779() + { + } + [Fact] + public void Test_4780() + { + } + [Fact] + public void Test_4781() + { + } + [Fact] + public void Test_4782() + { + } + [Fact] + public void Test_4783() + { + } + [Fact] + public void Test_4784() + { + } + [Fact] + public void Test_4785() + { + } + [Fact] + public void Test_4786() + { + } + [Fact] + public void Test_4787() + { + } + [Fact] + public void Test_4788() + { + } + [Fact] + public void Test_4789() + { + } + [Fact] + public void Test_4790() + { + } + [Fact] + public void Test_4791() + { + } + [Fact] + public void Test_4792() + { + } + [Fact] + public void Test_4793() + { + } + [Fact] + public void Test_4794() + { + } + [Fact] + public void Test_4795() + { + } + [Fact] + public void Test_4796() + { + } + [Fact] + public void Test_4797() + { + } + [Fact] + public void Test_4798() + { + } + [Fact] + public void Test_4799() + { + } + [Fact] + public void Test_4800() + { + } + [Fact] + public void Test_4801() + { + } + [Fact] + public void Test_4802() + { + } + [Fact] + public void Test_4803() + { + } + [Fact] + public void Test_4804() + { + } + [Fact] + public void Test_4805() + { + } + [Fact] + public void Test_4806() + { + } + [Fact] + public void Test_4807() + { + } + [Fact] + public void Test_4808() + { + } + [Fact] + public void Test_4809() + { + } + [Fact] + public void Test_4810() + { + } + [Fact] + public void Test_4811() + { + } + [Fact] + public void Test_4812() + { + } + [Fact] + public void Test_4813() + { + } + [Fact] + public void Test_4814() + { + } + [Fact] + public void Test_4815() + { + } + [Fact] + public void Test_4816() + { + } + [Fact] + public void Test_4817() + { + } + [Fact] + public void Test_4818() + { + } + [Fact] + public void Test_4819() + { + } + [Fact] + public void Test_4820() + { + } + [Fact] + public void Test_4821() + { + } + [Fact] + public void Test_4822() + { + } + [Fact] + public void Test_4823() + { + } + [Fact] + public void Test_4824() + { + } + [Fact] + public void Test_4825() + { + } + [Fact] + public void Test_4826() + { + } + [Fact] + public void Test_4827() + { + } + [Fact] + public void Test_4828() + { + } + [Fact] + public void Test_4829() + { + } + [Fact] + public void Test_4830() + { + } + [Fact] + public void Test_4831() + { + } + [Fact] + public void Test_4832() + { + } + [Fact] + public void Test_4833() + { + } + [Fact] + public void Test_4834() + { + } + [Fact] + public void Test_4835() + { + } + [Fact] + public void Test_4836() + { + } + [Fact] + public void Test_4837() + { + } + [Fact] + public void Test_4838() + { + } + [Fact] + public void Test_4839() + { + } + [Fact] + public void Test_4840() + { + } + [Fact] + public void Test_4841() + { + } + [Fact] + public void Test_4842() + { + } + [Fact] + public void Test_4843() + { + } + [Fact] + public void Test_4844() + { + } + [Fact] + public void Test_4845() + { + } + [Fact] + public void Test_4846() + { + } + [Fact] + public void Test_4847() + { + } + [Fact] + public void Test_4848() + { + } + [Fact] + public void Test_4849() + { + } + [Fact] + public void Test_4850() + { + } + [Fact] + public void Test_4851() + { + } + [Fact] + public void Test_4852() + { + } + [Fact] + public void Test_4853() + { + } + [Fact] + public void Test_4854() + { + } + [Fact] + public void Test_4855() + { + } + [Fact] + public void Test_4856() + { + } + [Fact] + public void Test_4857() + { + } + [Fact] + public void Test_4858() + { + } + [Fact] + public void Test_4859() + { + } + [Fact] + public void Test_4860() + { + } + [Fact] + public void Test_4861() + { + } + [Fact] + public void Test_4862() + { + } + [Fact] + public void Test_4863() + { + } + [Fact] + public void Test_4864() + { + } + [Fact] + public void Test_4865() + { + } + [Fact] + public void Test_4866() + { + } + [Fact] + public void Test_4867() + { + } + [Fact] + public void Test_4868() + { + } + [Fact] + public void Test_4869() + { + } + [Fact] + public void Test_4870() + { + } + [Fact] + public void Test_4871() + { + } + [Fact] + public void Test_4872() + { + } + [Fact] + public void Test_4873() + { + } + [Fact] + public void Test_4874() + { + } + [Fact] + public void Test_4875() + { + } + [Fact] + public void Test_4876() + { + } + [Fact] + public void Test_4877() + { + } + [Fact] + public void Test_4878() + { + } + [Fact] + public void Test_4879() + { + } + [Fact] + public void Test_4880() + { + } + [Fact] + public void Test_4881() + { + } + [Fact] + public void Test_4882() + { + } + [Fact] + public void Test_4883() + { + } + [Fact] + public void Test_4884() + { + } + [Fact] + public void Test_4885() + { + } + [Fact] + public void Test_4886() + { + } + [Fact] + public void Test_4887() + { + } + [Fact] + public void Test_4888() + { + } + [Fact] + public void Test_4889() + { + } + [Fact] + public void Test_4890() + { + } + [Fact] + public void Test_4891() + { + } + [Fact] + public void Test_4892() + { + } + [Fact] + public void Test_4893() + { + } + [Fact] + public void Test_4894() + { + } + [Fact] + public void Test_4895() + { + } + [Fact] + public void Test_4896() + { + } + [Fact] + public void Test_4897() + { + } + [Fact] + public void Test_4898() + { + } + [Fact] + public void Test_4899() + { + } + [Fact] + public void Test_4900() + { + } + [Fact] + public void Test_4901() + { + } + [Fact] + public void Test_4902() + { + } + [Fact] + public void Test_4903() + { + } + [Fact] + public void Test_4904() + { + } + [Fact] + public void Test_4905() + { + } + [Fact] + public void Test_4906() + { + } + [Fact] + public void Test_4907() + { + } + [Fact] + public void Test_4908() + { + } + [Fact] + public void Test_4909() + { + } + [Fact] + public void Test_4910() + { + } + [Fact] + public void Test_4911() + { + } + [Fact] + public void Test_4912() + { + } + [Fact] + public void Test_4913() + { + } + [Fact] + public void Test_4914() + { + } + [Fact] + public void Test_4915() + { + } + [Fact] + public void Test_4916() + { + } + [Fact] + public void Test_4917() + { + } + [Fact] + public void Test_4918() + { + } + [Fact] + public void Test_4919() + { + } + [Fact] + public void Test_4920() + { + } + [Fact] + public void Test_4921() + { + } + [Fact] + public void Test_4922() + { + } + [Fact] + public void Test_4923() + { + } + [Fact] + public void Test_4924() + { + } + [Fact] + public void Test_4925() + { + } + [Fact] + public void Test_4926() + { + } + [Fact] + public void Test_4927() + { + } + [Fact] + public void Test_4928() + { + } + [Fact] + public void Test_4929() + { + } + [Fact] + public void Test_4930() + { + } + [Fact] + public void Test_4931() + { + } + [Fact] + public void Test_4932() + { + } + [Fact] + public void Test_4933() + { + } + [Fact] + public void Test_4934() + { + } + [Fact] + public void Test_4935() + { + } + [Fact] + public void Test_4936() + { + } + [Fact] + public void Test_4937() + { + } + [Fact] + public void Test_4938() + { + } + [Fact] + public void Test_4939() + { + } + [Fact] + public void Test_4940() + { + } + [Fact] + public void Test_4941() + { + } + [Fact] + public void Test_4942() + { + } + [Fact] + public void Test_4943() + { + } + [Fact] + public void Test_4944() + { + } + [Fact] + public void Test_4945() + { + } + [Fact] + public void Test_4946() + { + } + [Fact] + public void Test_4947() + { + } + [Fact] + public void Test_4948() + { + } + [Fact] + public void Test_4949() + { + } + [Fact] + public void Test_4950() + { + } + [Fact] + public void Test_4951() + { + } + [Fact] + public void Test_4952() + { + } + [Fact] + public void Test_4953() + { + } + [Fact] + public void Test_4954() + { + } + [Fact] + public void Test_4955() + { + } + [Fact] + public void Test_4956() + { + } + [Fact] + public void Test_4957() + { + } + [Fact] + public void Test_4958() + { + } + [Fact] + public void Test_4959() + { + } + [Fact] + public void Test_4960() + { + } + [Fact] + public void Test_4961() + { + } + [Fact] + public void Test_4962() + { + } + [Fact] + public void Test_4963() + { + } + [Fact] + public void Test_4964() + { + } + [Fact] + public void Test_4965() + { + } + [Fact] + public void Test_4966() + { + } + [Fact] + public void Test_4967() + { + } + [Fact] + public void Test_4968() + { + } + [Fact] + public void Test_4969() + { + } + [Fact] + public void Test_4970() + { + } + [Fact] + public void Test_4971() + { + } + [Fact] + public void Test_4972() + { + } + [Fact] + public void Test_4973() + { + } + [Fact] + public void Test_4974() + { + } + [Fact] + public void Test_4975() + { + } + [Fact] + public void Test_4976() + { + } + [Fact] + public void Test_4977() + { + } + [Fact] + public void Test_4978() + { + } + [Fact] + public void Test_4979() + { + } + [Fact] + public void Test_4980() + { + } + [Fact] + public void Test_4981() + { + } + [Fact] + public void Test_4982() + { + } + [Fact] + public void Test_4983() + { + } + [Fact] + public void Test_4984() + { + } + [Fact] + public void Test_4985() + { + } + [Fact] + public void Test_4986() + { + } + [Fact] + public void Test_4987() + { + } + [Fact] + public void Test_4988() + { + } + [Fact] + public void Test_4989() + { + } + [Fact] + public void Test_4990() + { + } + [Fact] + public void Test_4991() + { + } + [Fact] + public void Test_4992() + { + } + [Fact] + public void Test_4993() + { + } + [Fact] + public void Test_4994() + { + } + [Fact] + public void Test_4995() + { + } + [Fact] + public void Test_4996() + { + } + [Fact] + public void Test_4997() + { + } + [Fact] + public void Test_4998() + { + } + [Fact] + public void Test_4999() + { + } + [Fact] + public void Test_5000() + { + } + [Fact] + public void Test_5001() + { + } + [Fact] + public void Test_5002() + { + } + [Fact] + public void Test_5003() + { + } + [Fact] + public void Test_5004() + { + } + [Fact] + public void Test_5005() + { + } + [Fact] + public void Test_5006() + { + } + [Fact] + public void Test_5007() + { + } + [Fact] + public void Test_5008() + { + } + [Fact] + public void Test_5009() + { + } + [Fact] + public void Test_5010() + { + } + [Fact] + public void Test_5011() + { + } + [Fact] + public void Test_5012() + { + } + [Fact] + public void Test_5013() + { + } + [Fact] + public void Test_5014() + { + } + [Fact] + public void Test_5015() + { + } + [Fact] + public void Test_5016() + { + } + [Fact] + public void Test_5017() + { + } + [Fact] + public void Test_5018() + { + } + [Fact] + public void Test_5019() + { + } + [Fact] + public void Test_5020() + { + } + [Fact] + public void Test_5021() + { + } + [Fact] + public void Test_5022() + { + } + [Fact] + public void Test_5023() + { + } + [Fact] + public void Test_5024() + { + } + [Fact] + public void Test_5025() + { + } + [Fact] + public void Test_5026() + { + } + [Fact] + public void Test_5027() + { + } + [Fact] + public void Test_5028() + { + } + [Fact] + public void Test_5029() + { + } + [Fact] + public void Test_5030() + { + } + [Fact] + public void Test_5031() + { + } + [Fact] + public void Test_5032() + { + } + [Fact] + public void Test_5033() + { + } + [Fact] + public void Test_5034() + { + } + [Fact] + public void Test_5035() + { + } + [Fact] + public void Test_5036() + { + } + [Fact] + public void Test_5037() + { + } + [Fact] + public void Test_5038() + { + } + [Fact] + public void Test_5039() + { + } + [Fact] + public void Test_5040() + { + } + [Fact] + public void Test_5041() + { + } + [Fact] + public void Test_5042() + { + } + [Fact] + public void Test_5043() + { + } + [Fact] + public void Test_5044() + { + } + [Fact] + public void Test_5045() + { + } + [Fact] + public void Test_5046() + { + } + [Fact] + public void Test_5047() + { + } + [Fact] + public void Test_5048() + { + } + [Fact] + public void Test_5049() + { + } + [Fact] + public void Test_5050() + { + } + [Fact] + public void Test_5051() + { + } + [Fact] + public void Test_5052() + { + } + [Fact] + public void Test_5053() + { + } + [Fact] + public void Test_5054() + { + } + [Fact] + public void Test_5055() + { + } + [Fact] + public void Test_5056() + { + } + [Fact] + public void Test_5057() + { + } + [Fact] + public void Test_5058() + { + } + [Fact] + public void Test_5059() + { + } + [Fact] + public void Test_5060() + { + } + [Fact] + public void Test_5061() + { + } + [Fact] + public void Test_5062() + { + } + [Fact] + public void Test_5063() + { + } + [Fact] + public void Test_5064() + { + } + [Fact] + public void Test_5065() + { + } + [Fact] + public void Test_5066() + { + } + [Fact] + public void Test_5067() + { + } + [Fact] + public void Test_5068() + { + } + [Fact] + public void Test_5069() + { + } + [Fact] + public void Test_5070() + { + } + [Fact] + public void Test_5071() + { + } + [Fact] + public void Test_5072() + { + } + [Fact] + public void Test_5073() + { + } + [Fact] + public void Test_5074() + { + } + [Fact] + public void Test_5075() + { + } + [Fact] + public void Test_5076() + { + } + [Fact] + public void Test_5077() + { + } + [Fact] + public void Test_5078() + { + } + [Fact] + public void Test_5079() + { + } + [Fact] + public void Test_5080() + { + } + [Fact] + public void Test_5081() + { + } + [Fact] + public void Test_5082() + { + } + [Fact] + public void Test_5083() + { + } + [Fact] + public void Test_5084() + { + } + [Fact] + public void Test_5085() + { + } + [Fact] + public void Test_5086() + { + } + [Fact] + public void Test_5087() + { + } + [Fact] + public void Test_5088() + { + } + [Fact] + public void Test_5089() + { + } + [Fact] + public void Test_5090() + { + } + [Fact] + public void Test_5091() + { + } + [Fact] + public void Test_5092() + { + } + [Fact] + public void Test_5093() + { + } + [Fact] + public void Test_5094() + { + } + [Fact] + public void Test_5095() + { + } + [Fact] + public void Test_5096() + { + } + [Fact] + public void Test_5097() + { + } + [Fact] + public void Test_5098() + { + } + [Fact] + public void Test_5099() + { + } + [Fact] + public void Test_5100() + { + } + [Fact] + public void Test_5101() + { + } + [Fact] + public void Test_5102() + { + } + [Fact] + public void Test_5103() + { + } + [Fact] + public void Test_5104() + { + } + [Fact] + public void Test_5105() + { + } + [Fact] + public void Test_5106() + { + } + [Fact] + public void Test_5107() + { + } + [Fact] + public void Test_5108() + { + } + [Fact] + public void Test_5109() + { + } + [Fact] + public void Test_5110() + { + } + [Fact] + public void Test_5111() + { + } + [Fact] + public void Test_5112() + { + } + [Fact] + public void Test_5113() + { + } + [Fact] + public void Test_5114() + { + } + [Fact] + public void Test_5115() + { + } + [Fact] + public void Test_5116() + { + } + [Fact] + public void Test_5117() + { + } + [Fact] + public void Test_5118() + { + } + [Fact] + public void Test_5119() + { + } + [Fact] + public void Test_5120() + { + } + [Fact] + public void Test_5121() + { + } + [Fact] + public void Test_5122() + { + } + [Fact] + public void Test_5123() + { + } + [Fact] + public void Test_5124() + { + } + [Fact] + public void Test_5125() + { + } + [Fact] + public void Test_5126() + { + } + [Fact] + public void Test_5127() + { + } + [Fact] + public void Test_5128() + { + } + [Fact] + public void Test_5129() + { + } + [Fact] + public void Test_5130() + { + } + [Fact] + public void Test_5131() + { + } + [Fact] + public void Test_5132() + { + } + [Fact] + public void Test_5133() + { + } + [Fact] + public void Test_5134() + { + } + [Fact] + public void Test_5135() + { + } + [Fact] + public void Test_5136() + { + } + [Fact] + public void Test_5137() + { + } + [Fact] + public void Test_5138() + { + } + [Fact] + public void Test_5139() + { + } + [Fact] + public void Test_5140() + { + } + [Fact] + public void Test_5141() + { + } + [Fact] + public void Test_5142() + { + } + [Fact] + public void Test_5143() + { + } + [Fact] + public void Test_5144() + { + } + [Fact] + public void Test_5145() + { + } + [Fact] + public void Test_5146() + { + } + [Fact] + public void Test_5147() + { + } + [Fact] + public void Test_5148() + { + } + [Fact] + public void Test_5149() + { + } + [Fact] + public void Test_5150() + { + } + [Fact] + public void Test_5151() + { + } + [Fact] + public void Test_5152() + { + } + [Fact] + public void Test_5153() + { + } + [Fact] + public void Test_5154() + { + } + [Fact] + public void Test_5155() + { + } + [Fact] + public void Test_5156() + { + } + [Fact] + public void Test_5157() + { + } + [Fact] + public void Test_5158() + { + } + [Fact] + public void Test_5159() + { + } + [Fact] + public void Test_5160() + { + } + [Fact] + public void Test_5161() + { + } + [Fact] + public void Test_5162() + { + } + [Fact] + public void Test_5163() + { + } + [Fact] + public void Test_5164() + { + } + [Fact] + public void Test_5165() + { + } + [Fact] + public void Test_5166() + { + } + [Fact] + public void Test_5167() + { + } + [Fact] + public void Test_5168() + { + } + [Fact] + public void Test_5169() + { + } + [Fact] + public void Test_5170() + { + } + [Fact] + public void Test_5171() + { + } + [Fact] + public void Test_5172() + { + } + [Fact] + public void Test_5173() + { + } + [Fact] + public void Test_5174() + { + } + [Fact] + public void Test_5175() + { + } + [Fact] + public void Test_5176() + { + } + [Fact] + public void Test_5177() + { + } + [Fact] + public void Test_5178() + { + } + [Fact] + public void Test_5179() + { + } + [Fact] + public void Test_5180() + { + } + [Fact] + public void Test_5181() + { + } + [Fact] + public void Test_5182() + { + } + [Fact] + public void Test_5183() + { + } + [Fact] + public void Test_5184() + { + } + [Fact] + public void Test_5185() + { + } + [Fact] + public void Test_5186() + { + } + [Fact] + public void Test_5187() + { + } + [Fact] + public void Test_5188() + { + } + [Fact] + public void Test_5189() + { + } + [Fact] + public void Test_5190() + { + } + [Fact] + public void Test_5191() + { + } + [Fact] + public void Test_5192() + { + } + [Fact] + public void Test_5193() + { + } + [Fact] + public void Test_5194() + { + } + [Fact] + public void Test_5195() + { + } + [Fact] + public void Test_5196() + { + } + [Fact] + public void Test_5197() + { + } + [Fact] + public void Test_5198() + { + } + [Fact] + public void Test_5199() + { + } + [Fact] + public void Test_5200() + { + } + [Fact] + public void Test_5201() + { + } + [Fact] + public void Test_5202() + { + } + [Fact] + public void Test_5203() + { + } + [Fact] + public void Test_5204() + { + } + [Fact] + public void Test_5205() + { + } + [Fact] + public void Test_5206() + { + } + [Fact] + public void Test_5207() + { + } + [Fact] + public void Test_5208() + { + } + [Fact] + public void Test_5209() + { + } + [Fact] + public void Test_5210() + { + } + [Fact] + public void Test_5211() + { + } + [Fact] + public void Test_5212() + { + } + [Fact] + public void Test_5213() + { + } + [Fact] + public void Test_5214() + { + } + [Fact] + public void Test_5215() + { + } + [Fact] + public void Test_5216() + { + } + [Fact] + public void Test_5217() + { + } + [Fact] + public void Test_5218() + { + } + [Fact] + public void Test_5219() + { + } + [Fact] + public void Test_5220() + { + } + [Fact] + public void Test_5221() + { + } + [Fact] + public void Test_5222() + { + } + [Fact] + public void Test_5223() + { + } + [Fact] + public void Test_5224() + { + } + [Fact] + public void Test_5225() + { + } + [Fact] + public void Test_5226() + { + } + [Fact] + public void Test_5227() + { + } + [Fact] + public void Test_5228() + { + } + [Fact] + public void Test_5229() + { + } + [Fact] + public void Test_5230() + { + } + [Fact] + public void Test_5231() + { + } + [Fact] + public void Test_5232() + { + } + [Fact] + public void Test_5233() + { + } + [Fact] + public void Test_5234() + { + } + [Fact] + public void Test_5235() + { + } + [Fact] + public void Test_5236() + { + } + [Fact] + public void Test_5237() + { + } + [Fact] + public void Test_5238() + { + } + [Fact] + public void Test_5239() + { + } + [Fact] + public void Test_5240() + { + } + [Fact] + public void Test_5241() + { + } + [Fact] + public void Test_5242() + { + } + [Fact] + public void Test_5243() + { + } + [Fact] + public void Test_5244() + { + } + [Fact] + public void Test_5245() + { + } + [Fact] + public void Test_5246() + { + } + [Fact] + public void Test_5247() + { + } + [Fact] + public void Test_5248() + { + } + [Fact] + public void Test_5249() + { + } + [Fact] + public void Test_5250() + { + } + [Fact] + public void Test_5251() + { + } + [Fact] + public void Test_5252() + { + } + [Fact] + public void Test_5253() + { + } + [Fact] + public void Test_5254() + { + } + [Fact] + public void Test_5255() + { + } + [Fact] + public void Test_5256() + { + } + [Fact] + public void Test_5257() + { + } + [Fact] + public void Test_5258() + { + } + [Fact] + public void Test_5259() + { + } + [Fact] + public void Test_5260() + { + } + [Fact] + public void Test_5261() + { + } + [Fact] + public void Test_5262() + { + } + [Fact] + public void Test_5263() + { + } + [Fact] + public void Test_5264() + { + } + [Fact] + public void Test_5265() + { + } + [Fact] + public void Test_5266() + { + } + [Fact] + public void Test_5267() + { + } + [Fact] + public void Test_5268() + { + } + [Fact] + public void Test_5269() + { + } + [Fact] + public void Test_5270() + { + } + [Fact] + public void Test_5271() + { + } + [Fact] + public void Test_5272() + { + } + [Fact] + public void Test_5273() + { + } + [Fact] + public void Test_5274() + { + } + [Fact] + public void Test_5275() + { + } + [Fact] + public void Test_5276() + { + } + [Fact] + public void Test_5277() + { + } + [Fact] + public void Test_5278() + { + } + [Fact] + public void Test_5279() + { + } + [Fact] + public void Test_5280() + { + } + [Fact] + public void Test_5281() + { + } + [Fact] + public void Test_5282() + { + } + [Fact] + public void Test_5283() + { + } + [Fact] + public void Test_5284() + { + } + [Fact] + public void Test_5285() + { + } + [Fact] + public void Test_5286() + { + } + [Fact] + public void Test_5287() + { + } + [Fact] + public void Test_5288() + { + } + [Fact] + public void Test_5289() + { + } + [Fact] + public void Test_5290() + { + } + [Fact] + public void Test_5291() + { + } + [Fact] + public void Test_5292() + { + } + [Fact] + public void Test_5293() + { + } + [Fact] + public void Test_5294() + { + } + [Fact] + public void Test_5295() + { + } + [Fact] + public void Test_5296() + { + } + [Fact] + public void Test_5297() + { + } + [Fact] + public void Test_5298() + { + } + [Fact] + public void Test_5299() + { + } + [Fact] + public void Test_5300() + { + } + [Fact] + public void Test_5301() + { + } + [Fact] + public void Test_5302() + { + } + [Fact] + public void Test_5303() + { + } + [Fact] + public void Test_5304() + { + } + [Fact] + public void Test_5305() + { + } + [Fact] + public void Test_5306() + { + } + [Fact] + public void Test_5307() + { + } + [Fact] + public void Test_5308() + { + } + [Fact] + public void Test_5309() + { + } + [Fact] + public void Test_5310() + { + } + [Fact] + public void Test_5311() + { + } + [Fact] + public void Test_5312() + { + } + [Fact] + public void Test_5313() + { + } + [Fact] + public void Test_5314() + { + } + [Fact] + public void Test_5315() + { + } + [Fact] + public void Test_5316() + { + } + [Fact] + public void Test_5317() + { + } + [Fact] + public void Test_5318() + { + } + [Fact] + public void Test_5319() + { + } + [Fact] + public void Test_5320() + { + } + [Fact] + public void Test_5321() + { + } + [Fact] + public void Test_5322() + { + } + [Fact] + public void Test_5323() + { + } + [Fact] + public void Test_5324() + { + } + [Fact] + public void Test_5325() + { + } + [Fact] + public void Test_5326() + { + } + [Fact] + public void Test_5327() + { + } + [Fact] + public void Test_5328() + { + } + [Fact] + public void Test_5329() + { + } + [Fact] + public void Test_5330() + { + } + [Fact] + public void Test_5331() + { + } + [Fact] + public void Test_5332() + { + } + [Fact] + public void Test_5333() + { + } + [Fact] + public void Test_5334() + { + } + [Fact] + public void Test_5335() + { + } + [Fact] + public void Test_5336() + { + } + [Fact] + public void Test_5337() + { + } + [Fact] + public void Test_5338() + { + } + [Fact] + public void Test_5339() + { + } + [Fact] + public void Test_5340() + { + } + [Fact] + public void Test_5341() + { + } + [Fact] + public void Test_5342() + { + } + [Fact] + public void Test_5343() + { + } + [Fact] + public void Test_5344() + { + } + [Fact] + public void Test_5345() + { + } + [Fact] + public void Test_5346() + { + } + [Fact] + public void Test_5347() + { + } + [Fact] + public void Test_5348() + { + } + [Fact] + public void Test_5349() + { + } + [Fact] + public void Test_5350() + { + } + [Fact] + public void Test_5351() + { + } + [Fact] + public void Test_5352() + { + } + [Fact] + public void Test_5353() + { + } + [Fact] + public void Test_5354() + { + } + [Fact] + public void Test_5355() + { + } + [Fact] + public void Test_5356() + { + } + [Fact] + public void Test_5357() + { + } + [Fact] + public void Test_5358() + { + } + [Fact] + public void Test_5359() + { + } + [Fact] + public void Test_5360() + { + } + [Fact] + public void Test_5361() + { + } + [Fact] + public void Test_5362() + { + } + [Fact] + public void Test_5363() + { + } + [Fact] + public void Test_5364() + { + } + [Fact] + public void Test_5365() + { + } + [Fact] + public void Test_5366() + { + } + [Fact] + public void Test_5367() + { + } + [Fact] + public void Test_5368() + { + } + [Fact] + public void Test_5369() + { + } + [Fact] + public void Test_5370() + { + } + [Fact] + public void Test_5371() + { + } + [Fact] + public void Test_5372() + { + } + [Fact] + public void Test_5373() + { + } + [Fact] + public void Test_5374() + { + } + [Fact] + public void Test_5375() + { + } + [Fact] + public void Test_5376() + { + } + [Fact] + public void Test_5377() + { + } + [Fact] + public void Test_5378() + { + } + [Fact] + public void Test_5379() + { + } + [Fact] + public void Test_5380() + { + } + [Fact] + public void Test_5381() + { + } + [Fact] + public void Test_5382() + { + } + [Fact] + public void Test_5383() + { + } + [Fact] + public void Test_5384() + { + } + [Fact] + public void Test_5385() + { + } + [Fact] + public void Test_5386() + { + } + [Fact] + public void Test_5387() + { + } + [Fact] + public void Test_5388() + { + } + [Fact] + public void Test_5389() + { + } + [Fact] + public void Test_5390() + { + } + [Fact] + public void Test_5391() + { + } + [Fact] + public void Test_5392() + { + } + [Fact] + public void Test_5393() + { + } + [Fact] + public void Test_5394() + { + } + [Fact] + public void Test_5395() + { + } + [Fact] + public void Test_5396() + { + } + [Fact] + public void Test_5397() + { + } + [Fact] + public void Test_5398() + { + } + [Fact] + public void Test_5399() + { + } + [Fact] + public void Test_5400() + { + } + [Fact] + public void Test_5401() + { + } + [Fact] + public void Test_5402() + { + } + [Fact] + public void Test_5403() + { + } + [Fact] + public void Test_5404() + { + } + [Fact] + public void Test_5405() + { + } + [Fact] + public void Test_5406() + { + } + [Fact] + public void Test_5407() + { + } + [Fact] + public void Test_5408() + { + } + [Fact] + public void Test_5409() + { + } + [Fact] + public void Test_5410() + { + } + [Fact] + public void Test_5411() + { + } + [Fact] + public void Test_5412() + { + } + [Fact] + public void Test_5413() + { + } + [Fact] + public void Test_5414() + { + } + [Fact] + public void Test_5415() + { + } + [Fact] + public void Test_5416() + { + } + [Fact] + public void Test_5417() + { + } + [Fact] + public void Test_5418() + { + } + [Fact] + public void Test_5419() + { + } + [Fact] + public void Test_5420() + { + } + [Fact] + public void Test_5421() + { + } + [Fact] + public void Test_5422() + { + } + [Fact] + public void Test_5423() + { + } + [Fact] + public void Test_5424() + { + } + [Fact] + public void Test_5425() + { + } + [Fact] + public void Test_5426() + { + } + [Fact] + public void Test_5427() + { + } + [Fact] + public void Test_5428() + { + } + [Fact] + public void Test_5429() + { + } + [Fact] + public void Test_5430() + { + } + [Fact] + public void Test_5431() + { + } + [Fact] + public void Test_5432() + { + } + [Fact] + public void Test_5433() + { + } + [Fact] + public void Test_5434() + { + } + [Fact] + public void Test_5435() + { + } + [Fact] + public void Test_5436() + { + } + [Fact] + public void Test_5437() + { + } + [Fact] + public void Test_5438() + { + } + [Fact] + public void Test_5439() + { + } + [Fact] + public void Test_5440() + { + } + [Fact] + public void Test_5441() + { + } + [Fact] + public void Test_5442() + { + } + [Fact] + public void Test_5443() + { + } + [Fact] + public void Test_5444() + { + } + [Fact] + public void Test_5445() + { + } + [Fact] + public void Test_5446() + { + } + [Fact] + public void Test_5447() + { + } + [Fact] + public void Test_5448() + { + } + [Fact] + public void Test_5449() + { + } + [Fact] + public void Test_5450() + { + } + [Fact] + public void Test_5451() + { + } + [Fact] + public void Test_5452() + { + } + [Fact] + public void Test_5453() + { + } + [Fact] + public void Test_5454() + { + } + [Fact] + public void Test_5455() + { + } + [Fact] + public void Test_5456() + { + } + [Fact] + public void Test_5457() + { + } + [Fact] + public void Test_5458() + { + } + [Fact] + public void Test_5459() + { + } + [Fact] + public void Test_5460() + { + } + [Fact] + public void Test_5461() + { + } + [Fact] + public void Test_5462() + { + } + [Fact] + public void Test_5463() + { + } + [Fact] + public void Test_5464() + { + } + [Fact] + public void Test_5465() + { + } + [Fact] + public void Test_5466() + { + } + [Fact] + public void Test_5467() + { + } + [Fact] + public void Test_5468() + { + } + [Fact] + public void Test_5469() + { + } + [Fact] + public void Test_5470() + { + } + [Fact] + public void Test_5471() + { + } + [Fact] + public void Test_5472() + { + } + [Fact] + public void Test_5473() + { + } + [Fact] + public void Test_5474() + { + } + [Fact] + public void Test_5475() + { + } + [Fact] + public void Test_5476() + { + } + [Fact] + public void Test_5477() + { + } + [Fact] + public void Test_5478() + { + } + [Fact] + public void Test_5479() + { + } + [Fact] + public void Test_5480() + { + } + [Fact] + public void Test_5481() + { + } + [Fact] + public void Test_5482() + { + } + [Fact] + public void Test_5483() + { + } + [Fact] + public void Test_5484() + { + } + [Fact] + public void Test_5485() + { + } + [Fact] + public void Test_5486() + { + } + [Fact] + public void Test_5487() + { + } + [Fact] + public void Test_5488() + { + } + [Fact] + public void Test_5489() + { + } + [Fact] + public void Test_5490() + { + } + [Fact] + public void Test_5491() + { + } + [Fact] + public void Test_5492() + { + } + [Fact] + public void Test_5493() + { + } + [Fact] + public void Test_5494() + { + } + [Fact] + public void Test_5495() + { + } + [Fact] + public void Test_5496() + { + } + [Fact] + public void Test_5497() + { + } + [Fact] + public void Test_5498() + { + } + [Fact] + public void Test_5499() + { + } + [Fact] + public void Test_5500() + { + } + [Fact] + public void Test_5501() + { + } + [Fact] + public void Test_5502() + { + } + [Fact] + public void Test_5503() + { + } + [Fact] + public void Test_5504() + { + } + [Fact] + public void Test_5505() + { + } + [Fact] + public void Test_5506() + { + } + [Fact] + public void Test_5507() + { + } + [Fact] + public void Test_5508() + { + } + [Fact] + public void Test_5509() + { + } + [Fact] + public void Test_5510() + { + } + [Fact] + public void Test_5511() + { + } + [Fact] + public void Test_5512() + { + } + [Fact] + public void Test_5513() + { + } + [Fact] + public void Test_5514() + { + } + [Fact] + public void Test_5515() + { + } + [Fact] + public void Test_5516() + { + } + [Fact] + public void Test_5517() + { + } + [Fact] + public void Test_5518() + { + } + [Fact] + public void Test_5519() + { + } + [Fact] + public void Test_5520() + { + } + [Fact] + public void Test_5521() + { + } + [Fact] + public void Test_5522() + { + } + [Fact] + public void Test_5523() + { + } + [Fact] + public void Test_5524() + { + } + [Fact] + public void Test_5525() + { + } + [Fact] + public void Test_5526() + { + } + [Fact] + public void Test_5527() + { + } + [Fact] + public void Test_5528() + { + } + [Fact] + public void Test_5529() + { + } + [Fact] + public void Test_5530() + { + } + [Fact] + public void Test_5531() + { + } + [Fact] + public void Test_5532() + { + } + [Fact] + public void Test_5533() + { + } + [Fact] + public void Test_5534() + { + } + [Fact] + public void Test_5535() + { + } + [Fact] + public void Test_5536() + { + } + [Fact] + public void Test_5537() + { + } + [Fact] + public void Test_5538() + { + } + [Fact] + public void Test_5539() + { + } + [Fact] + public void Test_5540() + { + } + [Fact] + public void Test_5541() + { + } + [Fact] + public void Test_5542() + { + } + [Fact] + public void Test_5543() + { + } + [Fact] + public void Test_5544() + { + } + [Fact] + public void Test_5545() + { + } + [Fact] + public void Test_5546() + { + } + [Fact] + public void Test_5547() + { + } + [Fact] + public void Test_5548() + { + } + [Fact] + public void Test_5549() + { + } + [Fact] + public void Test_5550() + { + } + [Fact] + public void Test_5551() + { + } + [Fact] + public void Test_5552() + { + } + [Fact] + public void Test_5553() + { + } + [Fact] + public void Test_5554() + { + } + [Fact] + public void Test_5555() + { + } + [Fact] + public void Test_5556() + { + } + [Fact] + public void Test_5557() + { + } + [Fact] + public void Test_5558() + { + } + [Fact] + public void Test_5559() + { + } + [Fact] + public void Test_5560() + { + } + [Fact] + public void Test_5561() + { + } + [Fact] + public void Test_5562() + { + } + [Fact] + public void Test_5563() + { + } + [Fact] + public void Test_5564() + { + } + [Fact] + public void Test_5565() + { + } + [Fact] + public void Test_5566() + { + } + [Fact] + public void Test_5567() + { + } + [Fact] + public void Test_5568() + { + } + [Fact] + public void Test_5569() + { + } + [Fact] + public void Test_5570() + { + } + [Fact] + public void Test_5571() + { + } + [Fact] + public void Test_5572() + { + } + [Fact] + public void Test_5573() + { + } + [Fact] + public void Test_5574() + { + } + [Fact] + public void Test_5575() + { + } + [Fact] + public void Test_5576() + { + } + [Fact] + public void Test_5577() + { + } + [Fact] + public void Test_5578() + { + } + [Fact] + public void Test_5579() + { + } + [Fact] + public void Test_5580() + { + } + [Fact] + public void Test_5581() + { + } + [Fact] + public void Test_5582() + { + } + [Fact] + public void Test_5583() + { + } + [Fact] + public void Test_5584() + { + } + [Fact] + public void Test_5585() + { + } + [Fact] + public void Test_5586() + { + } + [Fact] + public void Test_5587() + { + } + [Fact] + public void Test_5588() + { + } + [Fact] + public void Test_5589() + { + } + [Fact] + public void Test_5590() + { + } + [Fact] + public void Test_5591() + { + } + [Fact] + public void Test_5592() + { + } + [Fact] + public void Test_5593() + { + } + [Fact] + public void Test_5594() + { + } + [Fact] + public void Test_5595() + { + } + [Fact] + public void Test_5596() + { + } + [Fact] + public void Test_5597() + { + } + [Fact] + public void Test_5598() + { + } + [Fact] + public void Test_5599() + { + } + [Fact] + public void Test_5600() + { + } + [Fact] + public void Test_5601() + { + } + [Fact] + public void Test_5602() + { + } + [Fact] + public void Test_5603() + { + } + [Fact] + public void Test_5604() + { + } + [Fact] + public void Test_5605() + { + } + [Fact] + public void Test_5606() + { + } + [Fact] + public void Test_5607() + { + } + [Fact] + public void Test_5608() + { + } + [Fact] + public void Test_5609() + { + } + [Fact] + public void Test_5610() + { + } + [Fact] + public void Test_5611() + { + } + [Fact] + public void Test_5612() + { + } + [Fact] + public void Test_5613() + { + } + [Fact] + public void Test_5614() + { + } + [Fact] + public void Test_5615() + { + } + [Fact] + public void Test_5616() + { + } + [Fact] + public void Test_5617() + { + } + [Fact] + public void Test_5618() + { + } + [Fact] + public void Test_5619() + { + } + [Fact] + public void Test_5620() + { + } + [Fact] + public void Test_5621() + { + } + [Fact] + public void Test_5622() + { + } + [Fact] + public void Test_5623() + { + } + [Fact] + public void Test_5624() + { + } + [Fact] + public void Test_5625() + { + } + [Fact] + public void Test_5626() + { + } + [Fact] + public void Test_5627() + { + } + [Fact] + public void Test_5628() + { + } + [Fact] + public void Test_5629() + { + } + [Fact] + public void Test_5630() + { + } + [Fact] + public void Test_5631() + { + } + [Fact] + public void Test_5632() + { + } + [Fact] + public void Test_5633() + { + } + [Fact] + public void Test_5634() + { + } + [Fact] + public void Test_5635() + { + } + [Fact] + public void Test_5636() + { + } + [Fact] + public void Test_5637() + { + } + [Fact] + public void Test_5638() + { + } + [Fact] + public void Test_5639() + { + } + [Fact] + public void Test_5640() + { + } + [Fact] + public void Test_5641() + { + } + [Fact] + public void Test_5642() + { + } + [Fact] + public void Test_5643() + { + } + [Fact] + public void Test_5644() + { + } + [Fact] + public void Test_5645() + { + } + [Fact] + public void Test_5646() + { + } + [Fact] + public void Test_5647() + { + } + [Fact] + public void Test_5648() + { + } + [Fact] + public void Test_5649() + { + } + [Fact] + public void Test_5650() + { + } + [Fact] + public void Test_5651() + { + } + [Fact] + public void Test_5652() + { + } + [Fact] + public void Test_5653() + { + } + [Fact] + public void Test_5654() + { + } + [Fact] + public void Test_5655() + { + } + [Fact] + public void Test_5656() + { + } + [Fact] + public void Test_5657() + { + } + [Fact] + public void Test_5658() + { + } + [Fact] + public void Test_5659() + { + } + [Fact] + public void Test_5660() + { + } + [Fact] + public void Test_5661() + { + } + [Fact] + public void Test_5662() + { + } + [Fact] + public void Test_5663() + { + } + [Fact] + public void Test_5664() + { + } + [Fact] + public void Test_5665() + { + } + [Fact] + public void Test_5666() + { + } + [Fact] + public void Test_5667() + { + } + [Fact] + public void Test_5668() + { + } + [Fact] + public void Test_5669() + { + } + [Fact] + public void Test_5670() + { + } + [Fact] + public void Test_5671() + { + } + [Fact] + public void Test_5672() + { + } + [Fact] + public void Test_5673() + { + } + [Fact] + public void Test_5674() + { + } + [Fact] + public void Test_5675() + { + } + [Fact] + public void Test_5676() + { + } + [Fact] + public void Test_5677() + { + } + [Fact] + public void Test_5678() + { + } + [Fact] + public void Test_5679() + { + } + [Fact] + public void Test_5680() + { + } + [Fact] + public void Test_5681() + { + } + [Fact] + public void Test_5682() + { + } + [Fact] + public void Test_5683() + { + } + [Fact] + public void Test_5684() + { + } + [Fact] + public void Test_5685() + { + } + [Fact] + public void Test_5686() + { + } + [Fact] + public void Test_5687() + { + } + [Fact] + public void Test_5688() + { + } + [Fact] + public void Test_5689() + { + } + [Fact] + public void Test_5690() + { + } + [Fact] + public void Test_5691() + { + } + [Fact] + public void Test_5692() + { + } + [Fact] + public void Test_5693() + { + } + [Fact] + public void Test_5694() + { + } + [Fact] + public void Test_5695() + { + } + [Fact] + public void Test_5696() + { + } + [Fact] + public void Test_5697() + { + } + [Fact] + public void Test_5698() + { + } + [Fact] + public void Test_5699() + { + } + [Fact] + public void Test_5700() + { + } + [Fact] + public void Test_5701() + { + } + [Fact] + public void Test_5702() + { + } + [Fact] + public void Test_5703() + { + } + [Fact] + public void Test_5704() + { + } + [Fact] + public void Test_5705() + { + } + [Fact] + public void Test_5706() + { + } + [Fact] + public void Test_5707() + { + } + [Fact] + public void Test_5708() + { + } + [Fact] + public void Test_5709() + { + } + [Fact] + public void Test_5710() + { + } + [Fact] + public void Test_5711() + { + } + [Fact] + public void Test_5712() + { + } + [Fact] + public void Test_5713() + { + } + [Fact] + public void Test_5714() + { + } + [Fact] + public void Test_5715() + { + } + [Fact] + public void Test_5716() + { + } + [Fact] + public void Test_5717() + { + } + [Fact] + public void Test_5718() + { + } + [Fact] + public void Test_5719() + { + } + [Fact] + public void Test_5720() + { + } + [Fact] + public void Test_5721() + { + } + [Fact] + public void Test_5722() + { + } + [Fact] + public void Test_5723() + { + } + [Fact] + public void Test_5724() + { + } + [Fact] + public void Test_5725() + { + } + [Fact] + public void Test_5726() + { + } + [Fact] + public void Test_5727() + { + } + [Fact] + public void Test_5728() + { + } + [Fact] + public void Test_5729() + { + } + [Fact] + public void Test_5730() + { + } + [Fact] + public void Test_5731() + { + } + [Fact] + public void Test_5732() + { + } + [Fact] + public void Test_5733() + { + } + [Fact] + public void Test_5734() + { + } + [Fact] + public void Test_5735() + { + } + [Fact] + public void Test_5736() + { + } + [Fact] + public void Test_5737() + { + } + [Fact] + public void Test_5738() + { + } + [Fact] + public void Test_5739() + { + } + [Fact] + public void Test_5740() + { + } + [Fact] + public void Test_5741() + { + } + [Fact] + public void Test_5742() + { + } + [Fact] + public void Test_5743() + { + } + [Fact] + public void Test_5744() + { + } + [Fact] + public void Test_5745() + { + } + [Fact] + public void Test_5746() + { + } + [Fact] + public void Test_5747() + { + } + [Fact] + public void Test_5748() + { + } + [Fact] + public void Test_5749() + { + } + [Fact] + public void Test_5750() + { + } + [Fact] + public void Test_5751() + { + } + [Fact] + public void Test_5752() + { + } + [Fact] + public void Test_5753() + { + } + [Fact] + public void Test_5754() + { + } + [Fact] + public void Test_5755() + { + } + [Fact] + public void Test_5756() + { + } + [Fact] + public void Test_5757() + { + } + [Fact] + public void Test_5758() + { + } + [Fact] + public void Test_5759() + { + } + [Fact] + public void Test_5760() + { + } + [Fact] + public void Test_5761() + { + } + [Fact] + public void Test_5762() + { + } + [Fact] + public void Test_5763() + { + } + [Fact] + public void Test_5764() + { + } + [Fact] + public void Test_5765() + { + } + [Fact] + public void Test_5766() + { + } + [Fact] + public void Test_5767() + { + } + [Fact] + public void Test_5768() + { + } + [Fact] + public void Test_5769() + { + } + [Fact] + public void Test_5770() + { + } + [Fact] + public void Test_5771() + { + } + [Fact] + public void Test_5772() + { + } + [Fact] + public void Test_5773() + { + } + [Fact] + public void Test_5774() + { + } + [Fact] + public void Test_5775() + { + } + [Fact] + public void Test_5776() + { + } + [Fact] + public void Test_5777() + { + } + [Fact] + public void Test_5778() + { + } + [Fact] + public void Test_5779() + { + } + [Fact] + public void Test_5780() + { + } + [Fact] + public void Test_5781() + { + } + [Fact] + public void Test_5782() + { + } + [Fact] + public void Test_5783() + { + } + [Fact] + public void Test_5784() + { + } + [Fact] + public void Test_5785() + { + } + [Fact] + public void Test_5786() + { + } + [Fact] + public void Test_5787() + { + } + [Fact] + public void Test_5788() + { + } + [Fact] + public void Test_5789() + { + } + [Fact] + public void Test_5790() + { + } + [Fact] + public void Test_5791() + { + } + [Fact] + public void Test_5792() + { + } + [Fact] + public void Test_5793() + { + } + [Fact] + public void Test_5794() + { + } + [Fact] + public void Test_5795() + { + } + [Fact] + public void Test_5796() + { + } + [Fact] + public void Test_5797() + { + } + [Fact] + public void Test_5798() + { + } + [Fact] + public void Test_5799() + { + } + [Fact] + public void Test_5800() + { + } + [Fact] + public void Test_5801() + { + } + [Fact] + public void Test_5802() + { + } + [Fact] + public void Test_5803() + { + } + [Fact] + public void Test_5804() + { + } + [Fact] + public void Test_5805() + { + } + [Fact] + public void Test_5806() + { + } + [Fact] + public void Test_5807() + { + } + [Fact] + public void Test_5808() + { + } + [Fact] + public void Test_5809() + { + } + [Fact] + public void Test_5810() + { + } + [Fact] + public void Test_5811() + { + } + [Fact] + public void Test_5812() + { + } + [Fact] + public void Test_5813() + { + } + [Fact] + public void Test_5814() + { + } + [Fact] + public void Test_5815() + { + } + [Fact] + public void Test_5816() + { + } + [Fact] + public void Test_5817() + { + } + [Fact] + public void Test_5818() + { + } + [Fact] + public void Test_5819() + { + } + [Fact] + public void Test_5820() + { + } + [Fact] + public void Test_5821() + { + } + [Fact] + public void Test_5822() + { + } + [Fact] + public void Test_5823() + { + } + [Fact] + public void Test_5824() + { + } + [Fact] + public void Test_5825() + { + } + [Fact] + public void Test_5826() + { + } + [Fact] + public void Test_5827() + { + } + [Fact] + public void Test_5828() + { + } + [Fact] + public void Test_5829() + { + } + [Fact] + public void Test_5830() + { + } + [Fact] + public void Test_5831() + { + } + [Fact] + public void Test_5832() + { + } + [Fact] + public void Test_5833() + { + } + [Fact] + public void Test_5834() + { + } + [Fact] + public void Test_5835() + { + } + [Fact] + public void Test_5836() + { + } + [Fact] + public void Test_5837() + { + } + [Fact] + public void Test_5838() + { + } + [Fact] + public void Test_5839() + { + } + [Fact] + public void Test_5840() + { + } + [Fact] + public void Test_5841() + { + } + [Fact] + public void Test_5842() + { + } + [Fact] + public void Test_5843() + { + } + [Fact] + public void Test_5844() + { + } + [Fact] + public void Test_5845() + { + } + [Fact] + public void Test_5846() + { + } + [Fact] + public void Test_5847() + { + } + [Fact] + public void Test_5848() + { + } + [Fact] + public void Test_5849() + { + } + [Fact] + public void Test_5850() + { + } + [Fact] + public void Test_5851() + { + } + [Fact] + public void Test_5852() + { + } + [Fact] + public void Test_5853() + { + } + [Fact] + public void Test_5854() + { + } + [Fact] + public void Test_5855() + { + } + [Fact] + public void Test_5856() + { + } + [Fact] + public void Test_5857() + { + } + [Fact] + public void Test_5858() + { + } + [Fact] + public void Test_5859() + { + } + [Fact] + public void Test_5860() + { + } + [Fact] + public void Test_5861() + { + } + [Fact] + public void Test_5862() + { + } + [Fact] + public void Test_5863() + { + } + [Fact] + public void Test_5864() + { + } + [Fact] + public void Test_5865() + { + } + [Fact] + public void Test_5866() + { + } + [Fact] + public void Test_5867() + { + } + [Fact] + public void Test_5868() + { + } + [Fact] + public void Test_5869() + { + } + [Fact] + public void Test_5870() + { + } + [Fact] + public void Test_5871() + { + } + [Fact] + public void Test_5872() + { + } + [Fact] + public void Test_5873() + { + } + [Fact] + public void Test_5874() + { + } + [Fact] + public void Test_5875() + { + } + [Fact] + public void Test_5876() + { + } + [Fact] + public void Test_5877() + { + } + [Fact] + public void Test_5878() + { + } + [Fact] + public void Test_5879() + { + } + [Fact] + public void Test_5880() + { + } + [Fact] + public void Test_5881() + { + } + [Fact] + public void Test_5882() + { + } + [Fact] + public void Test_5883() + { + } + [Fact] + public void Test_5884() + { + } + [Fact] + public void Test_5885() + { + } + [Fact] + public void Test_5886() + { + } + [Fact] + public void Test_5887() + { + } + [Fact] + public void Test_5888() + { + } + [Fact] + public void Test_5889() + { + } + [Fact] + public void Test_5890() + { + } + [Fact] + public void Test_5891() + { + } + [Fact] + public void Test_5892() + { + } + [Fact] + public void Test_5893() + { + } + [Fact] + public void Test_5894() + { + } + [Fact] + public void Test_5895() + { + } + [Fact] + public void Test_5896() + { + } + [Fact] + public void Test_5897() + { + } + [Fact] + public void Test_5898() + { + } + [Fact] + public void Test_5899() + { + } + [Fact] + public void Test_5900() + { + } + [Fact] + public void Test_5901() + { + } + [Fact] + public void Test_5902() + { + } + [Fact] + public void Test_5903() + { + } + [Fact] + public void Test_5904() + { + } + [Fact] + public void Test_5905() + { + } + [Fact] + public void Test_5906() + { + } + [Fact] + public void Test_5907() + { + } + [Fact] + public void Test_5908() + { + } + [Fact] + public void Test_5909() + { + } + [Fact] + public void Test_5910() + { + } + [Fact] + public void Test_5911() + { + } + [Fact] + public void Test_5912() + { + } + [Fact] + public void Test_5913() + { + } + [Fact] + public void Test_5914() + { + } + [Fact] + public void Test_5915() + { + } + [Fact] + public void Test_5916() + { + } + [Fact] + public void Test_5917() + { + } + [Fact] + public void Test_5918() + { + } + [Fact] + public void Test_5919() + { + } + [Fact] + public void Test_5920() + { + } + [Fact] + public void Test_5921() + { + } + [Fact] + public void Test_5922() + { + } + [Fact] + public void Test_5923() + { + } + [Fact] + public void Test_5924() + { + } + [Fact] + public void Test_5925() + { + } + [Fact] + public void Test_5926() + { + } + [Fact] + public void Test_5927() + { + } + [Fact] + public void Test_5928() + { + } + [Fact] + public void Test_5929() + { + } + [Fact] + public void Test_5930() + { + } + [Fact] + public void Test_5931() + { + } + [Fact] + public void Test_5932() + { + } + [Fact] + public void Test_5933() + { + } + [Fact] + public void Test_5934() + { + } + [Fact] + public void Test_5935() + { + } + [Fact] + public void Test_5936() + { + } + [Fact] + public void Test_5937() + { + } + [Fact] + public void Test_5938() + { + } + [Fact] + public void Test_5939() + { + } + [Fact] + public void Test_5940() + { + } + [Fact] + public void Test_5941() + { + } + [Fact] + public void Test_5942() + { + } + [Fact] + public void Test_5943() + { + } + [Fact] + public void Test_5944() + { + } + [Fact] + public void Test_5945() + { + } + [Fact] + public void Test_5946() + { + } + [Fact] + public void Test_5947() + { + } + [Fact] + public void Test_5948() + { + } + [Fact] + public void Test_5949() + { + } + [Fact] + public void Test_5950() + { + } + [Fact] + public void Test_5951() + { + } + [Fact] + public void Test_5952() + { + } + [Fact] + public void Test_5953() + { + } + [Fact] + public void Test_5954() + { + } + [Fact] + public void Test_5955() + { + } + [Fact] + public void Test_5956() + { + } + [Fact] + public void Test_5957() + { + } + [Fact] + public void Test_5958() + { + } + [Fact] + public void Test_5959() + { + } + [Fact] + public void Test_5960() + { + } + [Fact] + public void Test_5961() + { + } + [Fact] + public void Test_5962() + { + } + [Fact] + public void Test_5963() + { + } + [Fact] + public void Test_5964() + { + } + [Fact] + public void Test_5965() + { + } + [Fact] + public void Test_5966() + { + } + [Fact] + public void Test_5967() + { + } + [Fact] + public void Test_5968() + { + } + [Fact] + public void Test_5969() + { + } + [Fact] + public void Test_5970() + { + } + [Fact] + public void Test_5971() + { + } + [Fact] + public void Test_5972() + { + } + [Fact] + public void Test_5973() + { + } + [Fact] + public void Test_5974() + { + } + [Fact] + public void Test_5975() + { + } + [Fact] + public void Test_5976() + { + } + [Fact] + public void Test_5977() + { + } + [Fact] + public void Test_5978() + { + } + [Fact] + public void Test_5979() + { + } + [Fact] + public void Test_5980() + { + } + [Fact] + public void Test_5981() + { + } + [Fact] + public void Test_5982() + { + } + [Fact] + public void Test_5983() + { + } + [Fact] + public void Test_5984() + { + } + [Fact] + public void Test_5985() + { + } + [Fact] + public void Test_5986() + { + } + [Fact] + public void Test_5987() + { + } + [Fact] + public void Test_5988() + { + } + [Fact] + public void Test_5989() + { + } + [Fact] + public void Test_5990() + { + } + [Fact] + public void Test_5991() + { + } + [Fact] + public void Test_5992() + { + } + [Fact] + public void Test_5993() + { + } + [Fact] + public void Test_5994() + { + } + [Fact] + public void Test_5995() + { + } + [Fact] + public void Test_5996() + { + } + [Fact] + public void Test_5997() + { + } + [Fact] + public void Test_5998() + { + } + [Fact] + public void Test_5999() + { + } + [Fact] + public void Test_6000() + { + } + [Fact] + public void Test_6001() + { + } + [Fact] + public void Test_6002() + { + } + [Fact] + public void Test_6003() + { + } + [Fact] + public void Test_6004() + { + } + [Fact] + public void Test_6005() + { + } + [Fact] + public void Test_6006() + { + } + [Fact] + public void Test_6007() + { + } + [Fact] + public void Test_6008() + { + } + [Fact] + public void Test_6009() + { + } + [Fact] + public void Test_6010() + { + } + [Fact] + public void Test_6011() + { + } + [Fact] + public void Test_6012() + { + } + [Fact] + public void Test_6013() + { + } + [Fact] + public void Test_6014() + { + } + [Fact] + public void Test_6015() + { + } + [Fact] + public void Test_6016() + { + } + [Fact] + public void Test_6017() + { + } + [Fact] + public void Test_6018() + { + } + [Fact] + public void Test_6019() + { + } + [Fact] + public void Test_6020() + { + } + [Fact] + public void Test_6021() + { + } + [Fact] + public void Test_6022() + { + } + [Fact] + public void Test_6023() + { + } + [Fact] + public void Test_6024() + { + } + [Fact] + public void Test_6025() + { + } + [Fact] + public void Test_6026() + { + } + [Fact] + public void Test_6027() + { + } + [Fact] + public void Test_6028() + { + } + [Fact] + public void Test_6029() + { + } + [Fact] + public void Test_6030() + { + } + [Fact] + public void Test_6031() + { + } + [Fact] + public void Test_6032() + { + } + [Fact] + public void Test_6033() + { + } + [Fact] + public void Test_6034() + { + } + [Fact] + public void Test_6035() + { + } + [Fact] + public void Test_6036() + { + } + [Fact] + public void Test_6037() + { + } + [Fact] + public void Test_6038() + { + } + [Fact] + public void Test_6039() + { + } + [Fact] + public void Test_6040() + { + } + [Fact] + public void Test_6041() + { + } + [Fact] + public void Test_6042() + { + } + [Fact] + public void Test_6043() + { + } + [Fact] + public void Test_6044() + { + } + [Fact] + public void Test_6045() + { + } + [Fact] + public void Test_6046() + { + } + [Fact] + public void Test_6047() + { + } + [Fact] + public void Test_6048() + { + } + [Fact] + public void Test_6049() + { + } + [Fact] + public void Test_6050() + { + } + [Fact] + public void Test_6051() + { + } + [Fact] + public void Test_6052() + { + } + [Fact] + public void Test_6053() + { + } + [Fact] + public void Test_6054() + { + } + [Fact] + public void Test_6055() + { + } + [Fact] + public void Test_6056() + { + } + [Fact] + public void Test_6057() + { + } + [Fact] + public void Test_6058() + { + } + [Fact] + public void Test_6059() + { + } + [Fact] + public void Test_6060() + { + } + [Fact] + public void Test_6061() + { + } + [Fact] + public void Test_6062() + { + } + [Fact] + public void Test_6063() + { + } + [Fact] + public void Test_6064() + { + } + [Fact] + public void Test_6065() + { + } + [Fact] + public void Test_6066() + { + } + [Fact] + public void Test_6067() + { + } + [Fact] + public void Test_6068() + { + } + [Fact] + public void Test_6069() + { + } + [Fact] + public void Test_6070() + { + } + [Fact] + public void Test_6071() + { + } + [Fact] + public void Test_6072() + { + } + [Fact] + public void Test_6073() + { + } + [Fact] + public void Test_6074() + { + } + [Fact] + public void Test_6075() + { + } + [Fact] + public void Test_6076() + { + } + [Fact] + public void Test_6077() + { + } + [Fact] + public void Test_6078() + { + } + [Fact] + public void Test_6079() + { + } + [Fact] + public void Test_6080() + { + } + [Fact] + public void Test_6081() + { + } + [Fact] + public void Test_6082() + { + } + [Fact] + public void Test_6083() + { + } + [Fact] + public void Test_6084() + { + } + [Fact] + public void Test_6085() + { + } + [Fact] + public void Test_6086() + { + } + [Fact] + public void Test_6087() + { + } + [Fact] + public void Test_6088() + { + } + [Fact] + public void Test_6089() + { + } + [Fact] + public void Test_6090() + { + } + [Fact] + public void Test_6091() + { + } + [Fact] + public void Test_6092() + { + } + [Fact] + public void Test_6093() + { + } + [Fact] + public void Test_6094() + { + } + [Fact] + public void Test_6095() + { + } + [Fact] + public void Test_6096() + { + } + [Fact] + public void Test_6097() + { + } + [Fact] + public void Test_6098() + { + } + [Fact] + public void Test_6099() + { + } + [Fact] + public void Test_6100() + { + } + [Fact] + public void Test_6101() + { + } + [Fact] + public void Test_6102() + { + } + [Fact] + public void Test_6103() + { + } + [Fact] + public void Test_6104() + { + } + [Fact] + public void Test_6105() + { + } + [Fact] + public void Test_6106() + { + } + [Fact] + public void Test_6107() + { + } + [Fact] + public void Test_6108() + { + } + [Fact] + public void Test_6109() + { + } + [Fact] + public void Test_6110() + { + } + [Fact] + public void Test_6111() + { + } + [Fact] + public void Test_6112() + { + } + [Fact] + public void Test_6113() + { + } + [Fact] + public void Test_6114() + { + } + [Fact] + public void Test_6115() + { + } + [Fact] + public void Test_6116() + { + } + [Fact] + public void Test_6117() + { + } + [Fact] + public void Test_6118() + { + } + [Fact] + public void Test_6119() + { + } + [Fact] + public void Test_6120() + { + } + [Fact] + public void Test_6121() + { + } + [Fact] + public void Test_6122() + { + } + [Fact] + public void Test_6123() + { + } + [Fact] + public void Test_6124() + { + } + [Fact] + public void Test_6125() + { + } + [Fact] + public void Test_6126() + { + } + [Fact] + public void Test_6127() + { + } + [Fact] + public void Test_6128() + { + } + [Fact] + public void Test_6129() + { + } + [Fact] + public void Test_6130() + { + } + [Fact] + public void Test_6131() + { + } + [Fact] + public void Test_6132() + { + } + [Fact] + public void Test_6133() + { + } + [Fact] + public void Test_6134() + { + } + [Fact] + public void Test_6135() + { + } + [Fact] + public void Test_6136() + { + } + [Fact] + public void Test_6137() + { + } + [Fact] + public void Test_6138() + { + } + [Fact] + public void Test_6139() + { + } + [Fact] + public void Test_6140() + { + } + [Fact] + public void Test_6141() + { + } + [Fact] + public void Test_6142() + { + } + [Fact] + public void Test_6143() + { + } + [Fact] + public void Test_6144() + { + } + [Fact] + public void Test_6145() + { + } + [Fact] + public void Test_6146() + { + } + [Fact] + public void Test_6147() + { + } + [Fact] + public void Test_6148() + { + } + [Fact] + public void Test_6149() + { + } + [Fact] + public void Test_6150() + { + } + [Fact] + public void Test_6151() + { + } + [Fact] + public void Test_6152() + { + } + [Fact] + public void Test_6153() + { + } + [Fact] + public void Test_6154() + { + } + [Fact] + public void Test_6155() + { + } + [Fact] + public void Test_6156() + { + } + [Fact] + public void Test_6157() + { + } + [Fact] + public void Test_6158() + { + } + [Fact] + public void Test_6159() + { + } + [Fact] + public void Test_6160() + { + } + [Fact] + public void Test_6161() + { + } + [Fact] + public void Test_6162() + { + } + [Fact] + public void Test_6163() + { + } + [Fact] + public void Test_6164() + { + } + [Fact] + public void Test_6165() + { + } + [Fact] + public void Test_6166() + { + } + [Fact] + public void Test_6167() + { + } + [Fact] + public void Test_6168() + { + } + [Fact] + public void Test_6169() + { + } + [Fact] + public void Test_6170() + { + } + [Fact] + public void Test_6171() + { + } + [Fact] + public void Test_6172() + { + } + [Fact] + public void Test_6173() + { + } + [Fact] + public void Test_6174() + { + } + [Fact] + public void Test_6175() + { + } + [Fact] + public void Test_6176() + { + } + [Fact] + public void Test_6177() + { + } + [Fact] + public void Test_6178() + { + } + [Fact] + public void Test_6179() + { + } + [Fact] + public void Test_6180() + { + } + [Fact] + public void Test_6181() + { + } + [Fact] + public void Test_6182() + { + } + [Fact] + public void Test_6183() + { + } + [Fact] + public void Test_6184() + { + } + [Fact] + public void Test_6185() + { + } + [Fact] + public void Test_6186() + { + } + [Fact] + public void Test_6187() + { + } + [Fact] + public void Test_6188() + { + } + [Fact] + public void Test_6189() + { + } + [Fact] + public void Test_6190() + { + } + [Fact] + public void Test_6191() + { + } + [Fact] + public void Test_6192() + { + } + [Fact] + public void Test_6193() + { + } + [Fact] + public void Test_6194() + { + } + [Fact] + public void Test_6195() + { + } + [Fact] + public void Test_6196() + { + } + [Fact] + public void Test_6197() + { + } + [Fact] + public void Test_6198() + { + } + [Fact] + public void Test_6199() + { + } + [Fact] + public void Test_6200() + { + } + [Fact] + public void Test_6201() + { + } + [Fact] + public void Test_6202() + { + } + [Fact] + public void Test_6203() + { + } + [Fact] + public void Test_6204() + { + } + [Fact] + public void Test_6205() + { + } + [Fact] + public void Test_6206() + { + } + [Fact] + public void Test_6207() + { + } + [Fact] + public void Test_6208() + { + } + [Fact] + public void Test_6209() + { + } + [Fact] + public void Test_6210() + { + } + [Fact] + public void Test_6211() + { + } + [Fact] + public void Test_6212() + { + } + [Fact] + public void Test_6213() + { + } + [Fact] + public void Test_6214() + { + } + [Fact] + public void Test_6215() + { + } + [Fact] + public void Test_6216() + { + } + [Fact] + public void Test_6217() + { + } + [Fact] + public void Test_6218() + { + } + [Fact] + public void Test_6219() + { + } + [Fact] + public void Test_6220() + { + } + [Fact] + public void Test_6221() + { + } + [Fact] + public void Test_6222() + { + } + [Fact] + public void Test_6223() + { + } + [Fact] + public void Test_6224() + { + } + [Fact] + public void Test_6225() + { + } + [Fact] + public void Test_6226() + { + } + [Fact] + public void Test_6227() + { + } + [Fact] + public void Test_6228() + { + } + [Fact] + public void Test_6229() + { + } + [Fact] + public void Test_6230() + { + } + [Fact] + public void Test_6231() + { + } + [Fact] + public void Test_6232() + { + } + [Fact] + public void Test_6233() + { + } + [Fact] + public void Test_6234() + { + } + [Fact] + public void Test_6235() + { + } + [Fact] + public void Test_6236() + { + } + [Fact] + public void Test_6237() + { + } + [Fact] + public void Test_6238() + { + } + [Fact] + public void Test_6239() + { + } + [Fact] + public void Test_6240() + { + } + [Fact] + public void Test_6241() + { + } + [Fact] + public void Test_6242() + { + } + [Fact] + public void Test_6243() + { + } + [Fact] + public void Test_6244() + { + } + [Fact] + public void Test_6245() + { + } + [Fact] + public void Test_6246() + { + } + [Fact] + public void Test_6247() + { + } + [Fact] + public void Test_6248() + { + } + [Fact] + public void Test_6249() + { + } + [Fact] + public void Test_6250() + { + } + [Fact] + public void Test_6251() + { + } + [Fact] + public void Test_6252() + { + } + [Fact] + public void Test_6253() + { + } + [Fact] + public void Test_6254() + { + } + [Fact] + public void Test_6255() + { + } + [Fact] + public void Test_6256() + { + } + [Fact] + public void Test_6257() + { + } + [Fact] + public void Test_6258() + { + } + [Fact] + public void Test_6259() + { + } + [Fact] + public void Test_6260() + { + } + [Fact] + public void Test_6261() + { + } + [Fact] + public void Test_6262() + { + } + [Fact] + public void Test_6263() + { + } + [Fact] + public void Test_6264() + { + } + [Fact] + public void Test_6265() + { + } + [Fact] + public void Test_6266() + { + } + [Fact] + public void Test_6267() + { + } + [Fact] + public void Test_6268() + { + } + [Fact] + public void Test_6269() + { + } + [Fact] + public void Test_6270() + { + } + [Fact] + public void Test_6271() + { + } + [Fact] + public void Test_6272() + { + } + [Fact] + public void Test_6273() + { + } + [Fact] + public void Test_6274() + { + } + [Fact] + public void Test_6275() + { + } + [Fact] + public void Test_6276() + { + } + [Fact] + public void Test_6277() + { + } + [Fact] + public void Test_6278() + { + } + [Fact] + public void Test_6279() + { + } + [Fact] + public void Test_6280() + { + } + [Fact] + public void Test_6281() + { + } + [Fact] + public void Test_6282() + { + } + [Fact] + public void Test_6283() + { + } + [Fact] + public void Test_6284() + { + } + [Fact] + public void Test_6285() + { + } + [Fact] + public void Test_6286() + { + } + [Fact] + public void Test_6287() + { + } + [Fact] + public void Test_6288() + { + } + [Fact] + public void Test_6289() + { + } + [Fact] + public void Test_6290() + { + } + [Fact] + public void Test_6291() + { + } + [Fact] + public void Test_6292() + { + } + [Fact] + public void Test_6293() + { + } + [Fact] + public void Test_6294() + { + } + [Fact] + public void Test_6295() + { + } + [Fact] + public void Test_6296() + { + } + [Fact] + public void Test_6297() + { + } + [Fact] + public void Test_6298() + { + } + [Fact] + public void Test_6299() + { + } + [Fact] + public void Test_6300() + { + } + [Fact] + public void Test_6301() + { + } + [Fact] + public void Test_6302() + { + } + [Fact] + public void Test_6303() + { + } + [Fact] + public void Test_6304() + { + } + [Fact] + public void Test_6305() + { + } + [Fact] + public void Test_6306() + { + } + [Fact] + public void Test_6307() + { + } + [Fact] + public void Test_6308() + { + } + [Fact] + public void Test_6309() + { + } + [Fact] + public void Test_6310() + { + } + [Fact] + public void Test_6311() + { + } + [Fact] + public void Test_6312() + { + } + [Fact] + public void Test_6313() + { + } + [Fact] + public void Test_6314() + { + } + [Fact] + public void Test_6315() + { + } + [Fact] + public void Test_6316() + { + } + [Fact] + public void Test_6317() + { + } + [Fact] + public void Test_6318() + { + } + [Fact] + public void Test_6319() + { + } + [Fact] + public void Test_6320() + { + } + [Fact] + public void Test_6321() + { + } + [Fact] + public void Test_6322() + { + } + [Fact] + public void Test_6323() + { + } + [Fact] + public void Test_6324() + { + } + [Fact] + public void Test_6325() + { + } + [Fact] + public void Test_6326() + { + } + [Fact] + public void Test_6327() + { + } + [Fact] + public void Test_6328() + { + } + [Fact] + public void Test_6329() + { + } + [Fact] + public void Test_6330() + { + } + [Fact] + public void Test_6331() + { + } + [Fact] + public void Test_6332() + { + } + [Fact] + public void Test_6333() + { + } + [Fact] + public void Test_6334() + { + } + [Fact] + public void Test_6335() + { + } + [Fact] + public void Test_6336() + { + } + [Fact] + public void Test_6337() + { + } + [Fact] + public void Test_6338() + { + } + [Fact] + public void Test_6339() + { + } + [Fact] + public void Test_6340() + { + } + [Fact] + public void Test_6341() + { + } + [Fact] + public void Test_6342() + { + } + [Fact] + public void Test_6343() + { + } + [Fact] + public void Test_6344() + { + } + [Fact] + public void Test_6345() + { + } + [Fact] + public void Test_6346() + { + } + [Fact] + public void Test_6347() + { + } + [Fact] + public void Test_6348() + { + } + [Fact] + public void Test_6349() + { + } + [Fact] + public void Test_6350() + { + } + [Fact] + public void Test_6351() + { + } + [Fact] + public void Test_6352() + { + } + [Fact] + public void Test_6353() + { + } + [Fact] + public void Test_6354() + { + } + [Fact] + public void Test_6355() + { + } + [Fact] + public void Test_6356() + { + } + [Fact] + public void Test_6357() + { + } + [Fact] + public void Test_6358() + { + } + [Fact] + public void Test_6359() + { + } + [Fact] + public void Test_6360() + { + } + [Fact] + public void Test_6361() + { + } + [Fact] + public void Test_6362() + { + } + [Fact] + public void Test_6363() + { + } + [Fact] + public void Test_6364() + { + } + [Fact] + public void Test_6365() + { + } + [Fact] + public void Test_6366() + { + } + [Fact] + public void Test_6367() + { + } + [Fact] + public void Test_6368() + { + } + [Fact] + public void Test_6369() + { + } + [Fact] + public void Test_6370() + { + } + [Fact] + public void Test_6371() + { + } + [Fact] + public void Test_6372() + { + } + [Fact] + public void Test_6373() + { + } + [Fact] + public void Test_6374() + { + } + [Fact] + public void Test_6375() + { + } + [Fact] + public void Test_6376() + { + } + [Fact] + public void Test_6377() + { + } + [Fact] + public void Test_6378() + { + } + [Fact] + public void Test_6379() + { + } + [Fact] + public void Test_6380() + { + } + [Fact] + public void Test_6381() + { + } + [Fact] + public void Test_6382() + { + } + [Fact] + public void Test_6383() + { + } + [Fact] + public void Test_6384() + { + } + [Fact] + public void Test_6385() + { + } + [Fact] + public void Test_6386() + { + } + [Fact] + public void Test_6387() + { + } + [Fact] + public void Test_6388() + { + } + [Fact] + public void Test_6389() + { + } + [Fact] + public void Test_6390() + { + } + [Fact] + public void Test_6391() + { + } + [Fact] + public void Test_6392() + { + } + [Fact] + public void Test_6393() + { + } + [Fact] + public void Test_6394() + { + } + [Fact] + public void Test_6395() + { + } + [Fact] + public void Test_6396() + { + } + [Fact] + public void Test_6397() + { + } + [Fact] + public void Test_6398() + { + } + [Fact] + public void Test_6399() + { + } + [Fact] + public void Test_6400() + { + } + [Fact] + public void Test_6401() + { + } + [Fact] + public void Test_6402() + { + } + [Fact] + public void Test_6403() + { + } + [Fact] + public void Test_6404() + { + } + [Fact] + public void Test_6405() + { + } + [Fact] + public void Test_6406() + { + } + [Fact] + public void Test_6407() + { + } + [Fact] + public void Test_6408() + { + } + [Fact] + public void Test_6409() + { + } + [Fact] + public void Test_6410() + { + } + [Fact] + public void Test_6411() + { + } + [Fact] + public void Test_6412() + { + } + [Fact] + public void Test_6413() + { + } + [Fact] + public void Test_6414() + { + } + [Fact] + public void Test_6415() + { + } + [Fact] + public void Test_6416() + { + } + [Fact] + public void Test_6417() + { + } + [Fact] + public void Test_6418() + { + } + [Fact] + public void Test_6419() + { + } + [Fact] + public void Test_6420() + { + } + [Fact] + public void Test_6421() + { + } + [Fact] + public void Test_6422() + { + } + [Fact] + public void Test_6423() + { + } + [Fact] + public void Test_6424() + { + } + [Fact] + public void Test_6425() + { + } + [Fact] + public void Test_6426() + { + } + [Fact] + public void Test_6427() + { + } + [Fact] + public void Test_6428() + { + } + [Fact] + public void Test_6429() + { + } + [Fact] + public void Test_6430() + { + } + [Fact] + public void Test_6431() + { + } + [Fact] + public void Test_6432() + { + } + [Fact] + public void Test_6433() + { + } + [Fact] + public void Test_6434() + { + } + [Fact] + public void Test_6435() + { + } + [Fact] + public void Test_6436() + { + } + [Fact] + public void Test_6437() + { + } + [Fact] + public void Test_6438() + { + } + [Fact] + public void Test_6439() + { + } + [Fact] + public void Test_6440() + { + } + [Fact] + public void Test_6441() + { + } + [Fact] + public void Test_6442() + { + } + [Fact] + public void Test_6443() + { + } + [Fact] + public void Test_6444() + { + } + [Fact] + public void Test_6445() + { + } + [Fact] + public void Test_6446() + { + } + [Fact] + public void Test_6447() + { + } + [Fact] + public void Test_6448() + { + } + [Fact] + public void Test_6449() + { + } + [Fact] + public void Test_6450() + { + } + [Fact] + public void Test_6451() + { + } + [Fact] + public void Test_6452() + { + } + [Fact] + public void Test_6453() + { + } + [Fact] + public void Test_6454() + { + } + [Fact] + public void Test_6455() + { + } + [Fact] + public void Test_6456() + { + } + [Fact] + public void Test_6457() + { + } + [Fact] + public void Test_6458() + { + } + [Fact] + public void Test_6459() + { + } + [Fact] + public void Test_6460() + { + } + [Fact] + public void Test_6461() + { + } + [Fact] + public void Test_6462() + { + } + [Fact] + public void Test_6463() + { + } + [Fact] + public void Test_6464() + { + } + [Fact] + public void Test_6465() + { + } + [Fact] + public void Test_6466() + { + } + [Fact] + public void Test_6467() + { + } + [Fact] + public void Test_6468() + { + } + [Fact] + public void Test_6469() + { + } + [Fact] + public void Test_6470() + { + } + [Fact] + public void Test_6471() + { + } + [Fact] + public void Test_6472() + { + } + [Fact] + public void Test_6473() + { + } + [Fact] + public void Test_6474() + { + } + [Fact] + public void Test_6475() + { + } + [Fact] + public void Test_6476() + { + } + [Fact] + public void Test_6477() + { + } + [Fact] + public void Test_6478() + { + } + [Fact] + public void Test_6479() + { + } + [Fact] + public void Test_6480() + { + } + [Fact] + public void Test_6481() + { + } + [Fact] + public void Test_6482() + { + } + [Fact] + public void Test_6483() + { + } + [Fact] + public void Test_6484() + { + } + [Fact] + public void Test_6485() + { + } + [Fact] + public void Test_6486() + { + } + [Fact] + public void Test_6487() + { + } + [Fact] + public void Test_6488() + { + } + [Fact] + public void Test_6489() + { + } + [Fact] + public void Test_6490() + { + } + [Fact] + public void Test_6491() + { + } + [Fact] + public void Test_6492() + { + } + [Fact] + public void Test_6493() + { + } + [Fact] + public void Test_6494() + { + } + [Fact] + public void Test_6495() + { + } + [Fact] + public void Test_6496() + { + } + [Fact] + public void Test_6497() + { + } + [Fact] + public void Test_6498() + { + } + [Fact] + public void Test_6499() + { + } + [Fact] + public void Test_6500() + { + } + [Fact] + public void Test_6501() + { + } + [Fact] + public void Test_6502() + { + } + [Fact] + public void Test_6503() + { + } + [Fact] + public void Test_6504() + { + } + [Fact] + public void Test_6505() + { + } + [Fact] + public void Test_6506() + { + } + [Fact] + public void Test_6507() + { + } + [Fact] + public void Test_6508() + { + } + [Fact] + public void Test_6509() + { + } + [Fact] + public void Test_6510() + { + } + [Fact] + public void Test_6511() + { + } + [Fact] + public void Test_6512() + { + } + [Fact] + public void Test_6513() + { + } + [Fact] + public void Test_6514() + { + } + [Fact] + public void Test_6515() + { + } + [Fact] + public void Test_6516() + { + } + [Fact] + public void Test_6517() + { + } + [Fact] + public void Test_6518() + { + } + [Fact] + public void Test_6519() + { + } + [Fact] + public void Test_6520() + { + } + [Fact] + public void Test_6521() + { + } + [Fact] + public void Test_6522() + { + } + [Fact] + public void Test_6523() + { + } + [Fact] + public void Test_6524() + { + } + [Fact] + public void Test_6525() + { + } + [Fact] + public void Test_6526() + { + } + [Fact] + public void Test_6527() + { + } + [Fact] + public void Test_6528() + { + } + [Fact] + public void Test_6529() + { + } + [Fact] + public void Test_6530() + { + } + [Fact] + public void Test_6531() + { + } + [Fact] + public void Test_6532() + { + } + [Fact] + public void Test_6533() + { + } + [Fact] + public void Test_6534() + { + } + [Fact] + public void Test_6535() + { + } + [Fact] + public void Test_6536() + { + } + [Fact] + public void Test_6537() + { + } + [Fact] + public void Test_6538() + { + } + [Fact] + public void Test_6539() + { + } + [Fact] + public void Test_6540() + { + } + [Fact] + public void Test_6541() + { + } + [Fact] + public void Test_6542() + { + } + [Fact] + public void Test_6543() + { + } + [Fact] + public void Test_6544() + { + } + [Fact] + public void Test_6545() + { + } + [Fact] + public void Test_6546() + { + } + [Fact] + public void Test_6547() + { + } + [Fact] + public void Test_6548() + { + } + [Fact] + public void Test_6549() + { + } + [Fact] + public void Test_6550() + { + } + [Fact] + public void Test_6551() + { + } + [Fact] + public void Test_6552() + { + } + [Fact] + public void Test_6553() + { + } + [Fact] + public void Test_6554() + { + } + [Fact] + public void Test_6555() + { + } + [Fact] + public void Test_6556() + { + } + [Fact] + public void Test_6557() + { + } + [Fact] + public void Test_6558() + { + } + [Fact] + public void Test_6559() + { + } + [Fact] + public void Test_6560() + { + } + [Fact] + public void Test_6561() + { + } + [Fact] + public void Test_6562() + { + } + [Fact] + public void Test_6563() + { + } + [Fact] + public void Test_6564() + { + } + [Fact] + public void Test_6565() + { + } + [Fact] + public void Test_6566() + { + } + [Fact] + public void Test_6567() + { + } + [Fact] + public void Test_6568() + { + } + [Fact] + public void Test_6569() + { + } + [Fact] + public void Test_6570() + { + } + [Fact] + public void Test_6571() + { + } + [Fact] + public void Test_6572() + { + } + [Fact] + public void Test_6573() + { + } + [Fact] + public void Test_6574() + { + } + [Fact] + public void Test_6575() + { + } + [Fact] + public void Test_6576() + { + } + [Fact] + public void Test_6577() + { + } + [Fact] + public void Test_6578() + { + } + [Fact] + public void Test_6579() + { + } + [Fact] + public void Test_6580() + { + } + [Fact] + public void Test_6581() + { + } + [Fact] + public void Test_6582() + { + } + [Fact] + public void Test_6583() + { + } + [Fact] + public void Test_6584() + { + } + [Fact] + public void Test_6585() + { + } + [Fact] + public void Test_6586() + { + } + [Fact] + public void Test_6587() + { + } + [Fact] + public void Test_6588() + { + } + [Fact] + public void Test_6589() + { + } + [Fact] + public void Test_6590() + { + } + [Fact] + public void Test_6591() + { + } + [Fact] + public void Test_6592() + { + } + [Fact] + public void Test_6593() + { + } + [Fact] + public void Test_6594() + { + } + [Fact] + public void Test_6595() + { + } + [Fact] + public void Test_6596() + { + } + [Fact] + public void Test_6597() + { + } + [Fact] + public void Test_6598() + { + } + [Fact] + public void Test_6599() + { + } + [Fact] + public void Test_6600() + { + } + [Fact] + public void Test_6601() + { + } + [Fact] + public void Test_6602() + { + } + [Fact] + public void Test_6603() + { + } + [Fact] + public void Test_6604() + { + } + [Fact] + public void Test_6605() + { + } + [Fact] + public void Test_6606() + { + } + [Fact] + public void Test_6607() + { + } + [Fact] + public void Test_6608() + { + } + [Fact] + public void Test_6609() + { + } + [Fact] + public void Test_6610() + { + } + [Fact] + public void Test_6611() + { + } + [Fact] + public void Test_6612() + { + } + [Fact] + public void Test_6613() + { + } + [Fact] + public void Test_6614() + { + } + [Fact] + public void Test_6615() + { + } + [Fact] + public void Test_6616() + { + } + [Fact] + public void Test_6617() + { + } + [Fact] + public void Test_6618() + { + } + [Fact] + public void Test_6619() + { + } + [Fact] + public void Test_6620() + { + } + [Fact] + public void Test_6621() + { + } + [Fact] + public void Test_6622() + { + } + [Fact] + public void Test_6623() + { + } + [Fact] + public void Test_6624() + { + } + [Fact] + public void Test_6625() + { + } + [Fact] + public void Test_6626() + { + } + [Fact] + public void Test_6627() + { + } + [Fact] + public void Test_6628() + { + } + [Fact] + public void Test_6629() + { + } + [Fact] + public void Test_6630() + { + } + [Fact] + public void Test_6631() + { + } + [Fact] + public void Test_6632() + { + } + [Fact] + public void Test_6633() + { + } + [Fact] + public void Test_6634() + { + } + [Fact] + public void Test_6635() + { + } + [Fact] + public void Test_6636() + { + } + [Fact] + public void Test_6637() + { + } + [Fact] + public void Test_6638() + { + } + [Fact] + public void Test_6639() + { + } + [Fact] + public void Test_6640() + { + } + [Fact] + public void Test_6641() + { + } + [Fact] + public void Test_6642() + { + } + [Fact] + public void Test_6643() + { + } + [Fact] + public void Test_6644() + { + } + [Fact] + public void Test_6645() + { + } + [Fact] + public void Test_6646() + { + } + [Fact] + public void Test_6647() + { + } + [Fact] + public void Test_6648() + { + } + [Fact] + public void Test_6649() + { + } + [Fact] + public void Test_6650() + { + } + [Fact] + public void Test_6651() + { + } + [Fact] + public void Test_6652() + { + } + [Fact] + public void Test_6653() + { + } + [Fact] + public void Test_6654() + { + } + [Fact] + public void Test_6655() + { + } + [Fact] + public void Test_6656() + { + } + [Fact] + public void Test_6657() + { + } + [Fact] + public void Test_6658() + { + } + [Fact] + public void Test_6659() + { + } + [Fact] + public void Test_6660() + { + } + [Fact] + public void Test_6661() + { + } + [Fact] + public void Test_6662() + { + } + [Fact] + public void Test_6663() + { + } + [Fact] + public void Test_6664() + { + } + [Fact] + public void Test_6665() + { + } + [Fact] + public void Test_6666() + { + } + [Fact] + public void Test_6667() + { + } + [Fact] + public void Test_6668() + { + } + [Fact] + public void Test_6669() + { + } + [Fact] + public void Test_6670() + { + } + [Fact] + public void Test_6671() + { + } + [Fact] + public void Test_6672() + { + } + [Fact] + public void Test_6673() + { + } + [Fact] + public void Test_6674() + { + } + [Fact] + public void Test_6675() + { + } + [Fact] + public void Test_6676() + { + } + [Fact] + public void Test_6677() + { + } + [Fact] + public void Test_6678() + { + } + [Fact] + public void Test_6679() + { + } + [Fact] + public void Test_6680() + { + } + [Fact] + public void Test_6681() + { + } + [Fact] + public void Test_6682() + { + } + [Fact] + public void Test_6683() + { + } + [Fact] + public void Test_6684() + { + } + [Fact] + public void Test_6685() + { + } + [Fact] + public void Test_6686() + { + } + [Fact] + public void Test_6687() + { + } + [Fact] + public void Test_6688() + { + } + [Fact] + public void Test_6689() + { + } + [Fact] + public void Test_6690() + { + } + [Fact] + public void Test_6691() + { + } + [Fact] + public void Test_6692() + { + } + [Fact] + public void Test_6693() + { + } + [Fact] + public void Test_6694() + { + } + [Fact] + public void Test_6695() + { + } + [Fact] + public void Test_6696() + { + } + [Fact] + public void Test_6697() + { + } + [Fact] + public void Test_6698() + { + } + [Fact] + public void Test_6699() + { + } + [Fact] + public void Test_6700() + { + } + [Fact] + public void Test_6701() + { + } + [Fact] + public void Test_6702() + { + } + [Fact] + public void Test_6703() + { + } + [Fact] + public void Test_6704() + { + } + [Fact] + public void Test_6705() + { + } + [Fact] + public void Test_6706() + { + } + [Fact] + public void Test_6707() + { + } + [Fact] + public void Test_6708() + { + } + [Fact] + public void Test_6709() + { + } + [Fact] + public void Test_6710() + { + } + [Fact] + public void Test_6711() + { + } + [Fact] + public void Test_6712() + { + } + [Fact] + public void Test_6713() + { + } + [Fact] + public void Test_6714() + { + } + [Fact] + public void Test_6715() + { + } + [Fact] + public void Test_6716() + { + } + [Fact] + public void Test_6717() + { + } + [Fact] + public void Test_6718() + { + } + [Fact] + public void Test_6719() + { + } + [Fact] + public void Test_6720() + { + } + [Fact] + public void Test_6721() + { + } + [Fact] + public void Test_6722() + { + } + [Fact] + public void Test_6723() + { + } + [Fact] + public void Test_6724() + { + } + [Fact] + public void Test_6725() + { + } + [Fact] + public void Test_6726() + { + } + [Fact] + public void Test_6727() + { + } + [Fact] + public void Test_6728() + { + } + [Fact] + public void Test_6729() + { + } + [Fact] + public void Test_6730() + { + } + [Fact] + public void Test_6731() + { + } + [Fact] + public void Test_6732() + { + } + [Fact] + public void Test_6733() + { + } + [Fact] + public void Test_6734() + { + } + [Fact] + public void Test_6735() + { + } + [Fact] + public void Test_6736() + { + } + [Fact] + public void Test_6737() + { + } + [Fact] + public void Test_6738() + { + } + [Fact] + public void Test_6739() + { + } + [Fact] + public void Test_6740() + { + } + [Fact] + public void Test_6741() + { + } + [Fact] + public void Test_6742() + { + } + [Fact] + public void Test_6743() + { + } + [Fact] + public void Test_6744() + { + } + [Fact] + public void Test_6745() + { + } + [Fact] + public void Test_6746() + { + } + [Fact] + public void Test_6747() + { + } + [Fact] + public void Test_6748() + { + } + [Fact] + public void Test_6749() + { + } + [Fact] + public void Test_6750() + { + } + [Fact] + public void Test_6751() + { + } + [Fact] + public void Test_6752() + { + } + [Fact] + public void Test_6753() + { + } + [Fact] + public void Test_6754() + { + } + [Fact] + public void Test_6755() + { + } + [Fact] + public void Test_6756() + { + } + [Fact] + public void Test_6757() + { + } + [Fact] + public void Test_6758() + { + } + [Fact] + public void Test_6759() + { + } + [Fact] + public void Test_6760() + { + } + [Fact] + public void Test_6761() + { + } + [Fact] + public void Test_6762() + { + } + [Fact] + public void Test_6763() + { + } + [Fact] + public void Test_6764() + { + } + [Fact] + public void Test_6765() + { + } + [Fact] + public void Test_6766() + { + } + [Fact] + public void Test_6767() + { + } + [Fact] + public void Test_6768() + { + } + [Fact] + public void Test_6769() + { + } + [Fact] + public void Test_6770() + { + } + [Fact] + public void Test_6771() + { + } + [Fact] + public void Test_6772() + { + } + [Fact] + public void Test_6773() + { + } + [Fact] + public void Test_6774() + { + } + [Fact] + public void Test_6775() + { + } + [Fact] + public void Test_6776() + { + } + [Fact] + public void Test_6777() + { + } + [Fact] + public void Test_6778() + { + } + [Fact] + public void Test_6779() + { + } + [Fact] + public void Test_6780() + { + } + [Fact] + public void Test_6781() + { + } + [Fact] + public void Test_6782() + { + } + [Fact] + public void Test_6783() + { + } + [Fact] + public void Test_6784() + { + } + [Fact] + public void Test_6785() + { + } + [Fact] + public void Test_6786() + { + } + [Fact] + public void Test_6787() + { + } + [Fact] + public void Test_6788() + { + } + [Fact] + public void Test_6789() + { + } + [Fact] + public void Test_6790() + { + } + [Fact] + public void Test_6791() + { + } + [Fact] + public void Test_6792() + { + } + [Fact] + public void Test_6793() + { + } + [Fact] + public void Test_6794() + { + } + [Fact] + public void Test_6795() + { + } + [Fact] + public void Test_6796() + { + } + [Fact] + public void Test_6797() + { + } + [Fact] + public void Test_6798() + { + } + [Fact] + public void Test_6799() + { + } + [Fact] + public void Test_6800() + { + } + [Fact] + public void Test_6801() + { + } + [Fact] + public void Test_6802() + { + } + [Fact] + public void Test_6803() + { + } + [Fact] + public void Test_6804() + { + } + [Fact] + public void Test_6805() + { + } + [Fact] + public void Test_6806() + { + } + [Fact] + public void Test_6807() + { + } + [Fact] + public void Test_6808() + { + } + [Fact] + public void Test_6809() + { + } + [Fact] + public void Test_6810() + { + } + [Fact] + public void Test_6811() + { + } + [Fact] + public void Test_6812() + { + } + [Fact] + public void Test_6813() + { + } + [Fact] + public void Test_6814() + { + } + [Fact] + public void Test_6815() + { + } + [Fact] + public void Test_6816() + { + } + [Fact] + public void Test_6817() + { + } + [Fact] + public void Test_6818() + { + } + [Fact] + public void Test_6819() + { + } + [Fact] + public void Test_6820() + { + } + [Fact] + public void Test_6821() + { + } + [Fact] + public void Test_6822() + { + } + [Fact] + public void Test_6823() + { + } + [Fact] + public void Test_6824() + { + } + [Fact] + public void Test_6825() + { + } + [Fact] + public void Test_6826() + { + } + [Fact] + public void Test_6827() + { + } + [Fact] + public void Test_6828() + { + } + [Fact] + public void Test_6829() + { + } + [Fact] + public void Test_6830() + { + } + [Fact] + public void Test_6831() + { + } + [Fact] + public void Test_6832() + { + } + [Fact] + public void Test_6833() + { + } + [Fact] + public void Test_6834() + { + } + [Fact] + public void Test_6835() + { + } + [Fact] + public void Test_6836() + { + } + [Fact] + public void Test_6837() + { + } + [Fact] + public void Test_6838() + { + } + [Fact] + public void Test_6839() + { + } + [Fact] + public void Test_6840() + { + } + [Fact] + public void Test_6841() + { + } + [Fact] + public void Test_6842() + { + } + [Fact] + public void Test_6843() + { + } + [Fact] + public void Test_6844() + { + } + [Fact] + public void Test_6845() + { + } + [Fact] + public void Test_6846() + { + } + [Fact] + public void Test_6847() + { + } + [Fact] + public void Test_6848() + { + } + [Fact] + public void Test_6849() + { + } + [Fact] + public void Test_6850() + { + } + [Fact] + public void Test_6851() + { + } + [Fact] + public void Test_6852() + { + } + [Fact] + public void Test_6853() + { + } + [Fact] + public void Test_6854() + { + } + [Fact] + public void Test_6855() + { + } + [Fact] + public void Test_6856() + { + } + [Fact] + public void Test_6857() + { + } + [Fact] + public void Test_6858() + { + } + [Fact] + public void Test_6859() + { + } + [Fact] + public void Test_6860() + { + } + [Fact] + public void Test_6861() + { + } + [Fact] + public void Test_6862() + { + } + [Fact] + public void Test_6863() + { + } + [Fact] + public void Test_6864() + { + } + [Fact] + public void Test_6865() + { + } + [Fact] + public void Test_6866() + { + } + [Fact] + public void Test_6867() + { + } + [Fact] + public void Test_6868() + { + } + [Fact] + public void Test_6869() + { + } + [Fact] + public void Test_6870() + { + } + [Fact] + public void Test_6871() + { + } + [Fact] + public void Test_6872() + { + } + [Fact] + public void Test_6873() + { + } + [Fact] + public void Test_6874() + { + } + [Fact] + public void Test_6875() + { + } + [Fact] + public void Test_6876() + { + } + [Fact] + public void Test_6877() + { + } + [Fact] + public void Test_6878() + { + } + [Fact] + public void Test_6879() + { + } + [Fact] + public void Test_6880() + { + } + [Fact] + public void Test_6881() + { + } + [Fact] + public void Test_6882() + { + } + [Fact] + public void Test_6883() + { + } + [Fact] + public void Test_6884() + { + } + [Fact] + public void Test_6885() + { + } + [Fact] + public void Test_6886() + { + } + [Fact] + public void Test_6887() + { + } + [Fact] + public void Test_6888() + { + } + [Fact] + public void Test_6889() + { + } + [Fact] + public void Test_6890() + { + } + [Fact] + public void Test_6891() + { + } + [Fact] + public void Test_6892() + { + } + [Fact] + public void Test_6893() + { + } + [Fact] + public void Test_6894() + { + } + [Fact] + public void Test_6895() + { + } + [Fact] + public void Test_6896() + { + } + [Fact] + public void Test_6897() + { + } + [Fact] + public void Test_6898() + { + } + [Fact] + public void Test_6899() + { + } + [Fact] + public void Test_6900() + { + } + [Fact] + public void Test_6901() + { + } + [Fact] + public void Test_6902() + { + } + [Fact] + public void Test_6903() + { + } + [Fact] + public void Test_6904() + { + } + [Fact] + public void Test_6905() + { + } + [Fact] + public void Test_6906() + { + } + [Fact] + public void Test_6907() + { + } + [Fact] + public void Test_6908() + { + } + [Fact] + public void Test_6909() + { + } + [Fact] + public void Test_6910() + { + } + [Fact] + public void Test_6911() + { + } + [Fact] + public void Test_6912() + { + } + [Fact] + public void Test_6913() + { + } + [Fact] + public void Test_6914() + { + } + [Fact] + public void Test_6915() + { + } + [Fact] + public void Test_6916() + { + } + [Fact] + public void Test_6917() + { + } + [Fact] + public void Test_6918() + { + } + [Fact] + public void Test_6919() + { + } + [Fact] + public void Test_6920() + { + } + [Fact] + public void Test_6921() + { + } + [Fact] + public void Test_6922() + { + } + [Fact] + public void Test_6923() + { + } + [Fact] + public void Test_6924() + { + } + [Fact] + public void Test_6925() + { + } + [Fact] + public void Test_6926() + { + } + [Fact] + public void Test_6927() + { + } + [Fact] + public void Test_6928() + { + } + [Fact] + public void Test_6929() + { + } + [Fact] + public void Test_6930() + { + } + [Fact] + public void Test_6931() + { + } + [Fact] + public void Test_6932() + { + } + [Fact] + public void Test_6933() + { + } + [Fact] + public void Test_6934() + { + } + [Fact] + public void Test_6935() + { + } + [Fact] + public void Test_6936() + { + } + [Fact] + public void Test_6937() + { + } + [Fact] + public void Test_6938() + { + } + [Fact] + public void Test_6939() + { + } + [Fact] + public void Test_6940() + { + } + [Fact] + public void Test_6941() + { + } + [Fact] + public void Test_6942() + { + } + [Fact] + public void Test_6943() + { + } + [Fact] + public void Test_6944() + { + } + [Fact] + public void Test_6945() + { + } + [Fact] + public void Test_6946() + { + } + [Fact] + public void Test_6947() + { + } + [Fact] + public void Test_6948() + { + } + [Fact] + public void Test_6949() + { + } + [Fact] + public void Test_6950() + { + } + [Fact] + public void Test_6951() + { + } + [Fact] + public void Test_6952() + { + } + [Fact] + public void Test_6953() + { + } + [Fact] + public void Test_6954() + { + } + [Fact] + public void Test_6955() + { + } + [Fact] + public void Test_6956() + { + } + [Fact] + public void Test_6957() + { + } + [Fact] + public void Test_6958() + { + } + [Fact] + public void Test_6959() + { + } + [Fact] + public void Test_6960() + { + } + [Fact] + public void Test_6961() + { + } + [Fact] + public void Test_6962() + { + } + [Fact] + public void Test_6963() + { + } + [Fact] + public void Test_6964() + { + } + [Fact] + public void Test_6965() + { + } + [Fact] + public void Test_6966() + { + } + [Fact] + public void Test_6967() + { + } + [Fact] + public void Test_6968() + { + } + [Fact] + public void Test_6969() + { + } + [Fact] + public void Test_6970() + { + } + [Fact] + public void Test_6971() + { + } + [Fact] + public void Test_6972() + { + } + [Fact] + public void Test_6973() + { + } + [Fact] + public void Test_6974() + { + } + [Fact] + public void Test_6975() + { + } + [Fact] + public void Test_6976() + { + } + [Fact] + public void Test_6977() + { + } + [Fact] + public void Test_6978() + { + } + [Fact] + public void Test_6979() + { + } + [Fact] + public void Test_6980() + { + } + [Fact] + public void Test_6981() + { + } + [Fact] + public void Test_6982() + { + } + [Fact] + public void Test_6983() + { + } + [Fact] + public void Test_6984() + { + } + [Fact] + public void Test_6985() + { + } + [Fact] + public void Test_6986() + { + } + [Fact] + public void Test_6987() + { + } + [Fact] + public void Test_6988() + { + } + [Fact] + public void Test_6989() + { + } + [Fact] + public void Test_6990() + { + } + [Fact] + public void Test_6991() + { + } + [Fact] + public void Test_6992() + { + } + [Fact] + public void Test_6993() + { + } + [Fact] + public void Test_6994() + { + } + [Fact] + public void Test_6995() + { + } + [Fact] + public void Test_6996() + { + } + [Fact] + public void Test_6997() + { + } + [Fact] + public void Test_6998() + { + } + [Fact] + public void Test_6999() + { + } + [Fact] + public void Test_7000() + { + } + [Fact] + public void Test_7001() + { + } + [Fact] + public void Test_7002() + { + } + [Fact] + public void Test_7003() + { + } + [Fact] + public void Test_7004() + { + } + [Fact] + public void Test_7005() + { + } + [Fact] + public void Test_7006() + { + } + [Fact] + public void Test_7007() + { + } + [Fact] + public void Test_7008() + { + } + [Fact] + public void Test_7009() + { + } + [Fact] + public void Test_7010() + { + } + [Fact] + public void Test_7011() + { + } + [Fact] + public void Test_7012() + { + } + [Fact] + public void Test_7013() + { + } + [Fact] + public void Test_7014() + { + } + [Fact] + public void Test_7015() + { + } + [Fact] + public void Test_7016() + { + } + [Fact] + public void Test_7017() + { + } + [Fact] + public void Test_7018() + { + } + [Fact] + public void Test_7019() + { + } + [Fact] + public void Test_7020() + { + } + [Fact] + public void Test_7021() + { + } + [Fact] + public void Test_7022() + { + } + [Fact] + public void Test_7023() + { + } + [Fact] + public void Test_7024() + { + } + [Fact] + public void Test_7025() + { + } + [Fact] + public void Test_7026() + { + } + [Fact] + public void Test_7027() + { + } + [Fact] + public void Test_7028() + { + } + [Fact] + public void Test_7029() + { + } + [Fact] + public void Test_7030() + { + } + [Fact] + public void Test_7031() + { + } + [Fact] + public void Test_7032() + { + } + [Fact] + public void Test_7033() + { + } + [Fact] + public void Test_7034() + { + } + [Fact] + public void Test_7035() + { + } + [Fact] + public void Test_7036() + { + } + [Fact] + public void Test_7037() + { + } + [Fact] + public void Test_7038() + { + } + [Fact] + public void Test_7039() + { + } + [Fact] + public void Test_7040() + { + } + [Fact] + public void Test_7041() + { + } + [Fact] + public void Test_7042() + { + } + [Fact] + public void Test_7043() + { + } + [Fact] + public void Test_7044() + { + } + [Fact] + public void Test_7045() + { + } + [Fact] + public void Test_7046() + { + } + [Fact] + public void Test_7047() + { + } + [Fact] + public void Test_7048() + { + } + [Fact] + public void Test_7049() + { + } + [Fact] + public void Test_7050() + { + } + [Fact] + public void Test_7051() + { + } + [Fact] + public void Test_7052() + { + } + [Fact] + public void Test_7053() + { + } + [Fact] + public void Test_7054() + { + } + [Fact] + public void Test_7055() + { + } + [Fact] + public void Test_7056() + { + } + [Fact] + public void Test_7057() + { + } + [Fact] + public void Test_7058() + { + } + [Fact] + public void Test_7059() + { + } + [Fact] + public void Test_7060() + { + } + [Fact] + public void Test_7061() + { + } + [Fact] + public void Test_7062() + { + } + [Fact] + public void Test_7063() + { + } + [Fact] + public void Test_7064() + { + } + [Fact] + public void Test_7065() + { + } + [Fact] + public void Test_7066() + { + } + [Fact] + public void Test_7067() + { + } + [Fact] + public void Test_7068() + { + } + [Fact] + public void Test_7069() + { + } + [Fact] + public void Test_7070() + { + } + [Fact] + public void Test_7071() + { + } + [Fact] + public void Test_7072() + { + } + [Fact] + public void Test_7073() + { + } + [Fact] + public void Test_7074() + { + } + [Fact] + public void Test_7075() + { + } + [Fact] + public void Test_7076() + { + } + [Fact] + public void Test_7077() + { + } + [Fact] + public void Test_7078() + { + } + [Fact] + public void Test_7079() + { + } + [Fact] + public void Test_7080() + { + } + [Fact] + public void Test_7081() + { + } + [Fact] + public void Test_7082() + { + } + [Fact] + public void Test_7083() + { + } + [Fact] + public void Test_7084() + { + } + [Fact] + public void Test_7085() + { + } + [Fact] + public void Test_7086() + { + } + [Fact] + public void Test_7087() + { + } + [Fact] + public void Test_7088() + { + } + [Fact] + public void Test_7089() + { + } + [Fact] + public void Test_7090() + { + } + [Fact] + public void Test_7091() + { + } + [Fact] + public void Test_7092() + { + } + [Fact] + public void Test_7093() + { + } + [Fact] + public void Test_7094() + { + } + [Fact] + public void Test_7095() + { + } + [Fact] + public void Test_7096() + { + } + [Fact] + public void Test_7097() + { + } + [Fact] + public void Test_7098() + { + } + [Fact] + public void Test_7099() + { + } + [Fact] + public void Test_7100() + { + } + [Fact] + public void Test_7101() + { + } + [Fact] + public void Test_7102() + { + } + [Fact] + public void Test_7103() + { + } + [Fact] + public void Test_7104() + { + } + [Fact] + public void Test_7105() + { + } + [Fact] + public void Test_7106() + { + } + [Fact] + public void Test_7107() + { + } + [Fact] + public void Test_7108() + { + } + [Fact] + public void Test_7109() + { + } + [Fact] + public void Test_7110() + { + } + [Fact] + public void Test_7111() + { + } + [Fact] + public void Test_7112() + { + } + [Fact] + public void Test_7113() + { + } + [Fact] + public void Test_7114() + { + } + [Fact] + public void Test_7115() + { + } + [Fact] + public void Test_7116() + { + } + [Fact] + public void Test_7117() + { + } + [Fact] + public void Test_7118() + { + } + [Fact] + public void Test_7119() + { + } + [Fact] + public void Test_7120() + { + } + [Fact] + public void Test_7121() + { + } + [Fact] + public void Test_7122() + { + } + [Fact] + public void Test_7123() + { + } + [Fact] + public void Test_7124() + { + } + [Fact] + public void Test_7125() + { + } + [Fact] + public void Test_7126() + { + } + [Fact] + public void Test_7127() + { + } + [Fact] + public void Test_7128() + { + } + [Fact] + public void Test_7129() + { + } + [Fact] + public void Test_7130() + { + } + [Fact] + public void Test_7131() + { + } + [Fact] + public void Test_7132() + { + } + [Fact] + public void Test_7133() + { + } + [Fact] + public void Test_7134() + { + } + [Fact] + public void Test_7135() + { + } + [Fact] + public void Test_7136() + { + } + [Fact] + public void Test_7137() + { + } + [Fact] + public void Test_7138() + { + } + [Fact] + public void Test_7139() + { + } + [Fact] + public void Test_7140() + { + } + [Fact] + public void Test_7141() + { + } + [Fact] + public void Test_7142() + { + } + [Fact] + public void Test_7143() + { + } + [Fact] + public void Test_7144() + { + } + [Fact] + public void Test_7145() + { + } + [Fact] + public void Test_7146() + { + } + [Fact] + public void Test_7147() + { + } + [Fact] + public void Test_7148() + { + } + [Fact] + public void Test_7149() + { + } + [Fact] + public void Test_7150() + { + } + [Fact] + public void Test_7151() + { + } + [Fact] + public void Test_7152() + { + } + [Fact] + public void Test_7153() + { + } + [Fact] + public void Test_7154() + { + } + [Fact] + public void Test_7155() + { + } + [Fact] + public void Test_7156() + { + } + [Fact] + public void Test_7157() + { + } + [Fact] + public void Test_7158() + { + } + [Fact] + public void Test_7159() + { + } + [Fact] + public void Test_7160() + { + } + [Fact] + public void Test_7161() + { + } + [Fact] + public void Test_7162() + { + } + [Fact] + public void Test_7163() + { + } + [Fact] + public void Test_7164() + { + } + [Fact] + public void Test_7165() + { + } + [Fact] + public void Test_7166() + { + } + [Fact] + public void Test_7167() + { + } + [Fact] + public void Test_7168() + { + } + [Fact] + public void Test_7169() + { + } + [Fact] + public void Test_7170() + { + } + [Fact] + public void Test_7171() + { + } + [Fact] + public void Test_7172() + { + } + [Fact] + public void Test_7173() + { + } + [Fact] + public void Test_7174() + { + } + [Fact] + public void Test_7175() + { + } + [Fact] + public void Test_7176() + { + } + [Fact] + public void Test_7177() + { + } + [Fact] + public void Test_7178() + { + } + [Fact] + public void Test_7179() + { + } + [Fact] + public void Test_7180() + { + } + [Fact] + public void Test_7181() + { + } + [Fact] + public void Test_7182() + { + } + [Fact] + public void Test_7183() + { + } + [Fact] + public void Test_7184() + { + } + [Fact] + public void Test_7185() + { + } + [Fact] + public void Test_7186() + { + } + [Fact] + public void Test_7187() + { + } + [Fact] + public void Test_7188() + { + } + [Fact] + public void Test_7189() + { + } + [Fact] + public void Test_7190() + { + } + [Fact] + public void Test_7191() + { + } + [Fact] + public void Test_7192() + { + } + [Fact] + public void Test_7193() + { + } + [Fact] + public void Test_7194() + { + } + [Fact] + public void Test_7195() + { + } + [Fact] + public void Test_7196() + { + } + [Fact] + public void Test_7197() + { + } + [Fact] + public void Test_7198() + { + } + [Fact] + public void Test_7199() + { + } + [Fact] + public void Test_7200() + { + } + [Fact] + public void Test_7201() + { + } + [Fact] + public void Test_7202() + { + } + [Fact] + public void Test_7203() + { + } + [Fact] + public void Test_7204() + { + } + [Fact] + public void Test_7205() + { + } + [Fact] + public void Test_7206() + { + } + [Fact] + public void Test_7207() + { + } + [Fact] + public void Test_7208() + { + } + [Fact] + public void Test_7209() + { + } + [Fact] + public void Test_7210() + { + } + [Fact] + public void Test_7211() + { + } + [Fact] + public void Test_7212() + { + } + [Fact] + public void Test_7213() + { + } + [Fact] + public void Test_7214() + { + } + [Fact] + public void Test_7215() + { + } + [Fact] + public void Test_7216() + { + } + [Fact] + public void Test_7217() + { + } + [Fact] + public void Test_7218() + { + } + [Fact] + public void Test_7219() + { + } + [Fact] + public void Test_7220() + { + } + [Fact] + public void Test_7221() + { + } + [Fact] + public void Test_7222() + { + } + [Fact] + public void Test_7223() + { + } + [Fact] + public void Test_7224() + { + } + [Fact] + public void Test_7225() + { + } + [Fact] + public void Test_7226() + { + } + [Fact] + public void Test_7227() + { + } + [Fact] + public void Test_7228() + { + } + [Fact] + public void Test_7229() + { + } + [Fact] + public void Test_7230() + { + } + [Fact] + public void Test_7231() + { + } + [Fact] + public void Test_7232() + { + } + [Fact] + public void Test_7233() + { + } + [Fact] + public void Test_7234() + { + } + [Fact] + public void Test_7235() + { + } + [Fact] + public void Test_7236() + { + } + [Fact] + public void Test_7237() + { + } + [Fact] + public void Test_7238() + { + } + [Fact] + public void Test_7239() + { + } + [Fact] + public void Test_7240() + { + } + [Fact] + public void Test_7241() + { + } + [Fact] + public void Test_7242() + { + } + [Fact] + public void Test_7243() + { + } + [Fact] + public void Test_7244() + { + } + [Fact] + public void Test_7245() + { + } + [Fact] + public void Test_7246() + { + } + [Fact] + public void Test_7247() + { + } + [Fact] + public void Test_7248() + { + } + [Fact] + public void Test_7249() + { + } + [Fact] + public void Test_7250() + { + } + [Fact] + public void Test_7251() + { + } + [Fact] + public void Test_7252() + { + } + [Fact] + public void Test_7253() + { + } + [Fact] + public void Test_7254() + { + } + [Fact] + public void Test_7255() + { + } + [Fact] + public void Test_7256() + { + } + [Fact] + public void Test_7257() + { + } + [Fact] + public void Test_7258() + { + } + [Fact] + public void Test_7259() + { + } + [Fact] + public void Test_7260() + { + } + [Fact] + public void Test_7261() + { + } + [Fact] + public void Test_7262() + { + } + [Fact] + public void Test_7263() + { + } + [Fact] + public void Test_7264() + { + } + [Fact] + public void Test_7265() + { + } + [Fact] + public void Test_7266() + { + } + [Fact] + public void Test_7267() + { + } + [Fact] + public void Test_7268() + { + } + [Fact] + public void Test_7269() + { + } + [Fact] + public void Test_7270() + { + } + [Fact] + public void Test_7271() + { + } + [Fact] + public void Test_7272() + { + } + [Fact] + public void Test_7273() + { + } + [Fact] + public void Test_7274() + { + } + [Fact] + public void Test_7275() + { + } + [Fact] + public void Test_7276() + { + } + [Fact] + public void Test_7277() + { + } + [Fact] + public void Test_7278() + { + } + [Fact] + public void Test_7279() + { + } + [Fact] + public void Test_7280() + { + } + [Fact] + public void Test_7281() + { + } + [Fact] + public void Test_7282() + { + } + [Fact] + public void Test_7283() + { + } + [Fact] + public void Test_7284() + { + } + [Fact] + public void Test_7285() + { + } + [Fact] + public void Test_7286() + { + } + [Fact] + public void Test_7287() + { + } + [Fact] + public void Test_7288() + { + } + [Fact] + public void Test_7289() + { + } + [Fact] + public void Test_7290() + { + } + [Fact] + public void Test_7291() + { + } + [Fact] + public void Test_7292() + { + } + [Fact] + public void Test_7293() + { + } + [Fact] + public void Test_7294() + { + } + [Fact] + public void Test_7295() + { + } + [Fact] + public void Test_7296() + { + } + [Fact] + public void Test_7297() + { + } + [Fact] + public void Test_7298() + { + } + [Fact] + public void Test_7299() + { + } + [Fact] + public void Test_7300() + { + } + [Fact] + public void Test_7301() + { + } + [Fact] + public void Test_7302() + { + } + [Fact] + public void Test_7303() + { + } + [Fact] + public void Test_7304() + { + } + [Fact] + public void Test_7305() + { + } + [Fact] + public void Test_7306() + { + } + [Fact] + public void Test_7307() + { + } + [Fact] + public void Test_7308() + { + } + [Fact] + public void Test_7309() + { + } + [Fact] + public void Test_7310() + { + } + [Fact] + public void Test_7311() + { + } + [Fact] + public void Test_7312() + { + } + [Fact] + public void Test_7313() + { + } + [Fact] + public void Test_7314() + { + } + [Fact] + public void Test_7315() + { + } + [Fact] + public void Test_7316() + { + } + [Fact] + public void Test_7317() + { + } + [Fact] + public void Test_7318() + { + } + [Fact] + public void Test_7319() + { + } + [Fact] + public void Test_7320() + { + } + [Fact] + public void Test_7321() + { + } + [Fact] + public void Test_7322() + { + } + [Fact] + public void Test_7323() + { + } + [Fact] + public void Test_7324() + { + } + [Fact] + public void Test_7325() + { + } + [Fact] + public void Test_7326() + { + } + [Fact] + public void Test_7327() + { + } + [Fact] + public void Test_7328() + { + } + [Fact] + public void Test_7329() + { + } + [Fact] + public void Test_7330() + { + } + [Fact] + public void Test_7331() + { + } + [Fact] + public void Test_7332() + { + } + [Fact] + public void Test_7333() + { + } + [Fact] + public void Test_7334() + { + } + [Fact] + public void Test_7335() + { + } + [Fact] + public void Test_7336() + { + } + [Fact] + public void Test_7337() + { + } + [Fact] + public void Test_7338() + { + } + [Fact] + public void Test_7339() + { + } + [Fact] + public void Test_7340() + { + } + [Fact] + public void Test_7341() + { + } + [Fact] + public void Test_7342() + { + } + [Fact] + public void Test_7343() + { + } + [Fact] + public void Test_7344() + { + } + [Fact] + public void Test_7345() + { + } + [Fact] + public void Test_7346() + { + } + [Fact] + public void Test_7347() + { + } + [Fact] + public void Test_7348() + { + } + [Fact] + public void Test_7349() + { + } + [Fact] + public void Test_7350() + { + } + [Fact] + public void Test_7351() + { + } + [Fact] + public void Test_7352() + { + } + [Fact] + public void Test_7353() + { + } + [Fact] + public void Test_7354() + { + } + [Fact] + public void Test_7355() + { + } + [Fact] + public void Test_7356() + { + } + [Fact] + public void Test_7357() + { + } + [Fact] + public void Test_7358() + { + } + [Fact] + public void Test_7359() + { + } + [Fact] + public void Test_7360() + { + } + [Fact] + public void Test_7361() + { + } + [Fact] + public void Test_7362() + { + } + [Fact] + public void Test_7363() + { + } + [Fact] + public void Test_7364() + { + } + [Fact] + public void Test_7365() + { + } + [Fact] + public void Test_7366() + { + } + [Fact] + public void Test_7367() + { + } + [Fact] + public void Test_7368() + { + } + [Fact] + public void Test_7369() + { + } + [Fact] + public void Test_7370() + { + } + [Fact] + public void Test_7371() + { + } + [Fact] + public void Test_7372() + { + } + [Fact] + public void Test_7373() + { + } + [Fact] + public void Test_7374() + { + } + [Fact] + public void Test_7375() + { + } + [Fact] + public void Test_7376() + { + } + [Fact] + public void Test_7377() + { + } + [Fact] + public void Test_7378() + { + } + [Fact] + public void Test_7379() + { + } + [Fact] + public void Test_7380() + { + } + [Fact] + public void Test_7381() + { + } + [Fact] + public void Test_7382() + { + } + [Fact] + public void Test_7383() + { + } + [Fact] + public void Test_7384() + { + } + [Fact] + public void Test_7385() + { + } + [Fact] + public void Test_7386() + { + } + [Fact] + public void Test_7387() + { + } + [Fact] + public void Test_7388() + { + } + [Fact] + public void Test_7389() + { + } + [Fact] + public void Test_7390() + { + } + [Fact] + public void Test_7391() + { + } + [Fact] + public void Test_7392() + { + } + [Fact] + public void Test_7393() + { + } + [Fact] + public void Test_7394() + { + } + [Fact] + public void Test_7395() + { + } + [Fact] + public void Test_7396() + { + } + [Fact] + public void Test_7397() + { + } + [Fact] + public void Test_7398() + { + } + [Fact] + public void Test_7399() + { + } + [Fact] + public void Test_7400() + { + } + [Fact] + public void Test_7401() + { + } + [Fact] + public void Test_7402() + { + } + [Fact] + public void Test_7403() + { + } + [Fact] + public void Test_7404() + { + } + [Fact] + public void Test_7405() + { + } + [Fact] + public void Test_7406() + { + } + [Fact] + public void Test_7407() + { + } + [Fact] + public void Test_7408() + { + } + [Fact] + public void Test_7409() + { + } + [Fact] + public void Test_7410() + { + } + [Fact] + public void Test_7411() + { + } + [Fact] + public void Test_7412() + { + } + [Fact] + public void Test_7413() + { + } + [Fact] + public void Test_7414() + { + } + [Fact] + public void Test_7415() + { + } + [Fact] + public void Test_7416() + { + } + [Fact] + public void Test_7417() + { + } + [Fact] + public void Test_7418() + { + } + [Fact] + public void Test_7419() + { + } + [Fact] + public void Test_7420() + { + } + [Fact] + public void Test_7421() + { + } + [Fact] + public void Test_7422() + { + } + [Fact] + public void Test_7423() + { + } + [Fact] + public void Test_7424() + { + } + [Fact] + public void Test_7425() + { + } + [Fact] + public void Test_7426() + { + } + [Fact] + public void Test_7427() + { + } + [Fact] + public void Test_7428() + { + } + [Fact] + public void Test_7429() + { + } + [Fact] + public void Test_7430() + { + } + [Fact] + public void Test_7431() + { + } + [Fact] + public void Test_7432() + { + } + [Fact] + public void Test_7433() + { + } + [Fact] + public void Test_7434() + { + } + [Fact] + public void Test_7435() + { + } + [Fact] + public void Test_7436() + { + } + [Fact] + public void Test_7437() + { + } + [Fact] + public void Test_7438() + { + } + [Fact] + public void Test_7439() + { + } + [Fact] + public void Test_7440() + { + } + [Fact] + public void Test_7441() + { + } + [Fact] + public void Test_7442() + { + } + [Fact] + public void Test_7443() + { + } + [Fact] + public void Test_7444() + { + } + [Fact] + public void Test_7445() + { + } + [Fact] + public void Test_7446() + { + } + [Fact] + public void Test_7447() + { + } + [Fact] + public void Test_7448() + { + } + [Fact] + public void Test_7449() + { + } + [Fact] + public void Test_7450() + { + } + [Fact] + public void Test_7451() + { + } + [Fact] + public void Test_7452() + { + } + [Fact] + public void Test_7453() + { + } + [Fact] + public void Test_7454() + { + } + [Fact] + public void Test_7455() + { + } + [Fact] + public void Test_7456() + { + } + [Fact] + public void Test_7457() + { + } + [Fact] + public void Test_7458() + { + } + [Fact] + public void Test_7459() + { + } + [Fact] + public void Test_7460() + { + } + [Fact] + public void Test_7461() + { + } + [Fact] + public void Test_7462() + { + } + [Fact] + public void Test_7463() + { + } + [Fact] + public void Test_7464() + { + } + [Fact] + public void Test_7465() + { + } + [Fact] + public void Test_7466() + { + } + [Fact] + public void Test_7467() + { + } + [Fact] + public void Test_7468() + { + } + [Fact] + public void Test_7469() + { + } + [Fact] + public void Test_7470() + { + } + [Fact] + public void Test_7471() + { + } + [Fact] + public void Test_7472() + { + } + [Fact] + public void Test_7473() + { + } + [Fact] + public void Test_7474() + { + } + [Fact] + public void Test_7475() + { + } + [Fact] + public void Test_7476() + { + } + [Fact] + public void Test_7477() + { + } + [Fact] + public void Test_7478() + { + } + [Fact] + public void Test_7479() + { + } + [Fact] + public void Test_7480() + { + } + [Fact] + public void Test_7481() + { + } + [Fact] + public void Test_7482() + { + } + [Fact] + public void Test_7483() + { + } + [Fact] + public void Test_7484() + { + } + [Fact] + public void Test_7485() + { + } + [Fact] + public void Test_7486() + { + } + [Fact] + public void Test_7487() + { + } + [Fact] + public void Test_7488() + { + } + [Fact] + public void Test_7489() + { + } + [Fact] + public void Test_7490() + { + } + [Fact] + public void Test_7491() + { + } + [Fact] + public void Test_7492() + { + } + [Fact] + public void Test_7493() + { + } + [Fact] + public void Test_7494() + { + } + [Fact] + public void Test_7495() + { + } + [Fact] + public void Test_7496() + { + } + [Fact] + public void Test_7497() + { + } + [Fact] + public void Test_7498() + { + } + [Fact] + public void Test_7499() + { + } + [Fact] + public void Test_7500() + { + } + [Fact] + public void Test_7501() + { + } + [Fact] + public void Test_7502() + { + } + [Fact] + public void Test_7503() + { + } + [Fact] + public void Test_7504() + { + } + [Fact] + public void Test_7505() + { + } + [Fact] + public void Test_7506() + { + } + [Fact] + public void Test_7507() + { + } + [Fact] + public void Test_7508() + { + } + [Fact] + public void Test_7509() + { + } + [Fact] + public void Test_7510() + { + } + [Fact] + public void Test_7511() + { + } + [Fact] + public void Test_7512() + { + } + [Fact] + public void Test_7513() + { + } + [Fact] + public void Test_7514() + { + } + [Fact] + public void Test_7515() + { + } + [Fact] + public void Test_7516() + { + } + [Fact] + public void Test_7517() + { + } + [Fact] + public void Test_7518() + { + } + [Fact] + public void Test_7519() + { + } + [Fact] + public void Test_7520() + { + } + [Fact] + public void Test_7521() + { + } + [Fact] + public void Test_7522() + { + } + [Fact] + public void Test_7523() + { + } + [Fact] + public void Test_7524() + { + } + [Fact] + public void Test_7525() + { + } + [Fact] + public void Test_7526() + { + } + [Fact] + public void Test_7527() + { + } + [Fact] + public void Test_7528() + { + } + [Fact] + public void Test_7529() + { + } + [Fact] + public void Test_7530() + { + } + [Fact] + public void Test_7531() + { + } + [Fact] + public void Test_7532() + { + } + [Fact] + public void Test_7533() + { + } + [Fact] + public void Test_7534() + { + } + [Fact] + public void Test_7535() + { + } + [Fact] + public void Test_7536() + { + } + [Fact] + public void Test_7537() + { + } + [Fact] + public void Test_7538() + { + } + [Fact] + public void Test_7539() + { + } + [Fact] + public void Test_7540() + { + } + [Fact] + public void Test_7541() + { + } + [Fact] + public void Test_7542() + { + } + [Fact] + public void Test_7543() + { + } + [Fact] + public void Test_7544() + { + } + [Fact] + public void Test_7545() + { + } + [Fact] + public void Test_7546() + { + } + [Fact] + public void Test_7547() + { + } + [Fact] + public void Test_7548() + { + } + [Fact] + public void Test_7549() + { + } + [Fact] + public void Test_7550() + { + } + [Fact] + public void Test_7551() + { + } + [Fact] + public void Test_7552() + { + } + [Fact] + public void Test_7553() + { + } + [Fact] + public void Test_7554() + { + } + [Fact] + public void Test_7555() + { + } + [Fact] + public void Test_7556() + { + } + [Fact] + public void Test_7557() + { + } + [Fact] + public void Test_7558() + { + } + [Fact] + public void Test_7559() + { + } + [Fact] + public void Test_7560() + { + } + [Fact] + public void Test_7561() + { + } + [Fact] + public void Test_7562() + { + } + [Fact] + public void Test_7563() + { + } + [Fact] + public void Test_7564() + { + } + [Fact] + public void Test_7565() + { + } + [Fact] + public void Test_7566() + { + } + [Fact] + public void Test_7567() + { + } + [Fact] + public void Test_7568() + { + } + [Fact] + public void Test_7569() + { + } + [Fact] + public void Test_7570() + { + } + [Fact] + public void Test_7571() + { + } + [Fact] + public void Test_7572() + { + } + [Fact] + public void Test_7573() + { + } + [Fact] + public void Test_7574() + { + } + [Fact] + public void Test_7575() + { + } + [Fact] + public void Test_7576() + { + } + [Fact] + public void Test_7577() + { + } + [Fact] + public void Test_7578() + { + } + [Fact] + public void Test_7579() + { + } + [Fact] + public void Test_7580() + { + } + [Fact] + public void Test_7581() + { + } + [Fact] + public void Test_7582() + { + } + [Fact] + public void Test_7583() + { + } + [Fact] + public void Test_7584() + { + } + [Fact] + public void Test_7585() + { + } + [Fact] + public void Test_7586() + { + } + [Fact] + public void Test_7587() + { + } + [Fact] + public void Test_7588() + { + } + [Fact] + public void Test_7589() + { + } + [Fact] + public void Test_7590() + { + } + [Fact] + public void Test_7591() + { + } + [Fact] + public void Test_7592() + { + } + [Fact] + public void Test_7593() + { + } + [Fact] + public void Test_7594() + { + } + [Fact] + public void Test_7595() + { + } + [Fact] + public void Test_7596() + { + } + [Fact] + public void Test_7597() + { + } + [Fact] + public void Test_7598() + { + } + [Fact] + public void Test_7599() + { + } + [Fact] + public void Test_7600() + { + } + [Fact] + public void Test_7601() + { + } + [Fact] + public void Test_7602() + { + } + [Fact] + public void Test_7603() + { + } + [Fact] + public void Test_7604() + { + } + [Fact] + public void Test_7605() + { + } + [Fact] + public void Test_7606() + { + } + [Fact] + public void Test_7607() + { + } + [Fact] + public void Test_7608() + { + } + [Fact] + public void Test_7609() + { + } + [Fact] + public void Test_7610() + { + } + [Fact] + public void Test_7611() + { + } + [Fact] + public void Test_7612() + { + } + [Fact] + public void Test_7613() + { + } + [Fact] + public void Test_7614() + { + } + [Fact] + public void Test_7615() + { + } + [Fact] + public void Test_7616() + { + } + [Fact] + public void Test_7617() + { + } + [Fact] + public void Test_7618() + { + } + [Fact] + public void Test_7619() + { + } + [Fact] + public void Test_7620() + { + } + [Fact] + public void Test_7621() + { + } + [Fact] + public void Test_7622() + { + } + [Fact] + public void Test_7623() + { + } + [Fact] + public void Test_7624() + { + } + [Fact] + public void Test_7625() + { + } + [Fact] + public void Test_7626() + { + } + [Fact] + public void Test_7627() + { + } + [Fact] + public void Test_7628() + { + } + [Fact] + public void Test_7629() + { + } + [Fact] + public void Test_7630() + { + } + [Fact] + public void Test_7631() + { + } + [Fact] + public void Test_7632() + { + } + [Fact] + public void Test_7633() + { + } + [Fact] + public void Test_7634() + { + } + [Fact] + public void Test_7635() + { + } + [Fact] + public void Test_7636() + { + } + [Fact] + public void Test_7637() + { + } + [Fact] + public void Test_7638() + { + } + [Fact] + public void Test_7639() + { + } + [Fact] + public void Test_7640() + { + } + [Fact] + public void Test_7641() + { + } + [Fact] + public void Test_7642() + { + } + [Fact] + public void Test_7643() + { + } + [Fact] + public void Test_7644() + { + } + [Fact] + public void Test_7645() + { + } + [Fact] + public void Test_7646() + { + } + [Fact] + public void Test_7647() + { + } + [Fact] + public void Test_7648() + { + } + [Fact] + public void Test_7649() + { + } + [Fact] + public void Test_7650() + { + } + [Fact] + public void Test_7651() + { + } + [Fact] + public void Test_7652() + { + } + [Fact] + public void Test_7653() + { + } + [Fact] + public void Test_7654() + { + } + [Fact] + public void Test_7655() + { + } + [Fact] + public void Test_7656() + { + } + [Fact] + public void Test_7657() + { + } + [Fact] + public void Test_7658() + { + } + [Fact] + public void Test_7659() + { + } + [Fact] + public void Test_7660() + { + } + [Fact] + public void Test_7661() + { + } + [Fact] + public void Test_7662() + { + } + [Fact] + public void Test_7663() + { + } + [Fact] + public void Test_7664() + { + } + [Fact] + public void Test_7665() + { + } + [Fact] + public void Test_7666() + { + } + [Fact] + public void Test_7667() + { + } + [Fact] + public void Test_7668() + { + } + [Fact] + public void Test_7669() + { + } + [Fact] + public void Test_7670() + { + } + [Fact] + public void Test_7671() + { + } + [Fact] + public void Test_7672() + { + } + [Fact] + public void Test_7673() + { + } + [Fact] + public void Test_7674() + { + } + [Fact] + public void Test_7675() + { + } + [Fact] + public void Test_7676() + { + } + [Fact] + public void Test_7677() + { + } + [Fact] + public void Test_7678() + { + } + [Fact] + public void Test_7679() + { + } + [Fact] + public void Test_7680() + { + } + [Fact] + public void Test_7681() + { + } + [Fact] + public void Test_7682() + { + } + [Fact] + public void Test_7683() + { + } + [Fact] + public void Test_7684() + { + } + [Fact] + public void Test_7685() + { + } + [Fact] + public void Test_7686() + { + } + [Fact] + public void Test_7687() + { + } + [Fact] + public void Test_7688() + { + } + [Fact] + public void Test_7689() + { + } + [Fact] + public void Test_7690() + { + } + [Fact] + public void Test_7691() + { + } + [Fact] + public void Test_7692() + { + } + [Fact] + public void Test_7693() + { + } + [Fact] + public void Test_7694() + { + } + [Fact] + public void Test_7695() + { + } + [Fact] + public void Test_7696() + { + } + [Fact] + public void Test_7697() + { + } + [Fact] + public void Test_7698() + { + } + [Fact] + public void Test_7699() + { + } + [Fact] + public void Test_7700() + { + } + [Fact] + public void Test_7701() + { + } + [Fact] + public void Test_7702() + { + } + [Fact] + public void Test_7703() + { + } + [Fact] + public void Test_7704() + { + } + [Fact] + public void Test_7705() + { + } + [Fact] + public void Test_7706() + { + } + [Fact] + public void Test_7707() + { + } + [Fact] + public void Test_7708() + { + } + [Fact] + public void Test_7709() + { + } + [Fact] + public void Test_7710() + { + } + [Fact] + public void Test_7711() + { + } + [Fact] + public void Test_7712() + { + } + [Fact] + public void Test_7713() + { + } + [Fact] + public void Test_7714() + { + } + [Fact] + public void Test_7715() + { + } + [Fact] + public void Test_7716() + { + } + [Fact] + public void Test_7717() + { + } + [Fact] + public void Test_7718() + { + } + [Fact] + public void Test_7719() + { + } + [Fact] + public void Test_7720() + { + } + [Fact] + public void Test_7721() + { + } + [Fact] + public void Test_7722() + { + } + [Fact] + public void Test_7723() + { + } + [Fact] + public void Test_7724() + { + } + [Fact] + public void Test_7725() + { + } + [Fact] + public void Test_7726() + { + } + [Fact] + public void Test_7727() + { + } + [Fact] + public void Test_7728() + { + } + [Fact] + public void Test_7729() + { + } + [Fact] + public void Test_7730() + { + } + [Fact] + public void Test_7731() + { + } + [Fact] + public void Test_7732() + { + } + [Fact] + public void Test_7733() + { + } + [Fact] + public void Test_7734() + { + } + [Fact] + public void Test_7735() + { + } + [Fact] + public void Test_7736() + { + } + [Fact] + public void Test_7737() + { + } + [Fact] + public void Test_7738() + { + } + [Fact] + public void Test_7739() + { + } + [Fact] + public void Test_7740() + { + } + [Fact] + public void Test_7741() + { + } + [Fact] + public void Test_7742() + { + } + [Fact] + public void Test_7743() + { + } + [Fact] + public void Test_7744() + { + } + [Fact] + public void Test_7745() + { + } + [Fact] + public void Test_7746() + { + } + [Fact] + public void Test_7747() + { + } + [Fact] + public void Test_7748() + { + } + [Fact] + public void Test_7749() + { + } + [Fact] + public void Test_7750() + { + } + [Fact] + public void Test_7751() + { + } + [Fact] + public void Test_7752() + { + } + [Fact] + public void Test_7753() + { + } + [Fact] + public void Test_7754() + { + } + [Fact] + public void Test_7755() + { + } + [Fact] + public void Test_7756() + { + } + [Fact] + public void Test_7757() + { + } + [Fact] + public void Test_7758() + { + } + [Fact] + public void Test_7759() + { + } + [Fact] + public void Test_7760() + { + } + [Fact] + public void Test_7761() + { + } + [Fact] + public void Test_7762() + { + } + [Fact] + public void Test_7763() + { + } + [Fact] + public void Test_7764() + { + } + [Fact] + public void Test_7765() + { + } + [Fact] + public void Test_7766() + { + } + [Fact] + public void Test_7767() + { + } + [Fact] + public void Test_7768() + { + } + [Fact] + public void Test_7769() + { + } + [Fact] + public void Test_7770() + { + } + [Fact] + public void Test_7771() + { + } + [Fact] + public void Test_7772() + { + } + [Fact] + public void Test_7773() + { + } + [Fact] + public void Test_7774() + { + } + [Fact] + public void Test_7775() + { + } + [Fact] + public void Test_7776() + { + } + [Fact] + public void Test_7777() + { + } + [Fact] + public void Test_7778() + { + } + [Fact] + public void Test_7779() + { + } + [Fact] + public void Test_7780() + { + } + [Fact] + public void Test_7781() + { + } + [Fact] + public void Test_7782() + { + } + [Fact] + public void Test_7783() + { + } + [Fact] + public void Test_7784() + { + } + [Fact] + public void Test_7785() + { + } + [Fact] + public void Test_7786() + { + } + [Fact] + public void Test_7787() + { + } + [Fact] + public void Test_7788() + { + } + [Fact] + public void Test_7789() + { + } + [Fact] + public void Test_7790() + { + } + [Fact] + public void Test_7791() + { + } + [Fact] + public void Test_7792() + { + } + [Fact] + public void Test_7793() + { + } + [Fact] + public void Test_7794() + { + } + [Fact] + public void Test_7795() + { + } + [Fact] + public void Test_7796() + { + } + [Fact] + public void Test_7797() + { + } + [Fact] + public void Test_7798() + { + } + [Fact] + public void Test_7799() + { + } + [Fact] + public void Test_7800() + { + } + [Fact] + public void Test_7801() + { + } + [Fact] + public void Test_7802() + { + } + [Fact] + public void Test_7803() + { + } + [Fact] + public void Test_7804() + { + } + [Fact] + public void Test_7805() + { + } + [Fact] + public void Test_7806() + { + } + [Fact] + public void Test_7807() + { + } + [Fact] + public void Test_7808() + { + } + [Fact] + public void Test_7809() + { + } + [Fact] + public void Test_7810() + { + } + [Fact] + public void Test_7811() + { + } + [Fact] + public void Test_7812() + { + } + [Fact] + public void Test_7813() + { + } + [Fact] + public void Test_7814() + { + } + [Fact] + public void Test_7815() + { + } + [Fact] + public void Test_7816() + { + } + [Fact] + public void Test_7817() + { + } + [Fact] + public void Test_7818() + { + } + [Fact] + public void Test_7819() + { + } + [Fact] + public void Test_7820() + { + } + [Fact] + public void Test_7821() + { + } + [Fact] + public void Test_7822() + { + } + [Fact] + public void Test_7823() + { + } + [Fact] + public void Test_7824() + { + } + [Fact] + public void Test_7825() + { + } + [Fact] + public void Test_7826() + { + } + [Fact] + public void Test_7827() + { + } + [Fact] + public void Test_7828() + { + } + [Fact] + public void Test_7829() + { + } + [Fact] + public void Test_7830() + { + } + [Fact] + public void Test_7831() + { + } + [Fact] + public void Test_7832() + { + } + [Fact] + public void Test_7833() + { + } + [Fact] + public void Test_7834() + { + } + [Fact] + public void Test_7835() + { + } + [Fact] + public void Test_7836() + { + } + [Fact] + public void Test_7837() + { + } + [Fact] + public void Test_7838() + { + } + [Fact] + public void Test_7839() + { + } + [Fact] + public void Test_7840() + { + } + [Fact] + public void Test_7841() + { + } + [Fact] + public void Test_7842() + { + } + [Fact] + public void Test_7843() + { + } + [Fact] + public void Test_7844() + { + } + [Fact] + public void Test_7845() + { + } + [Fact] + public void Test_7846() + { + } + [Fact] + public void Test_7847() + { + } + [Fact] + public void Test_7848() + { + } + [Fact] + public void Test_7849() + { + } + [Fact] + public void Test_7850() + { + } + [Fact] + public void Test_7851() + { + } + [Fact] + public void Test_7852() + { + } + [Fact] + public void Test_7853() + { + } + [Fact] + public void Test_7854() + { + } + [Fact] + public void Test_7855() + { + } + [Fact] + public void Test_7856() + { + } + [Fact] + public void Test_7857() + { + } + [Fact] + public void Test_7858() + { + } + [Fact] + public void Test_7859() + { + } + [Fact] + public void Test_7860() + { + } + [Fact] + public void Test_7861() + { + } + [Fact] + public void Test_7862() + { + } + [Fact] + public void Test_7863() + { + } + [Fact] + public void Test_7864() + { + } + [Fact] + public void Test_7865() + { + } + [Fact] + public void Test_7866() + { + } + [Fact] + public void Test_7867() + { + } + [Fact] + public void Test_7868() + { + } + [Fact] + public void Test_7869() + { + } + [Fact] + public void Test_7870() + { + } + [Fact] + public void Test_7871() + { + } + [Fact] + public void Test_7872() + { + } + [Fact] + public void Test_7873() + { + } + [Fact] + public void Test_7874() + { + } + [Fact] + public void Test_7875() + { + } + [Fact] + public void Test_7876() + { + } + [Fact] + public void Test_7877() + { + } + [Fact] + public void Test_7878() + { + } + [Fact] + public void Test_7879() + { + } + [Fact] + public void Test_7880() + { + } + [Fact] + public void Test_7881() + { + } + [Fact] + public void Test_7882() + { + } + [Fact] + public void Test_7883() + { + } + [Fact] + public void Test_7884() + { + } + [Fact] + public void Test_7885() + { + } + [Fact] + public void Test_7886() + { + } + [Fact] + public void Test_7887() + { + } + [Fact] + public void Test_7888() + { + } + [Fact] + public void Test_7889() + { + } + [Fact] + public void Test_7890() + { + } + [Fact] + public void Test_7891() + { + } + [Fact] + public void Test_7892() + { + } + [Fact] + public void Test_7893() + { + } + [Fact] + public void Test_7894() + { + } + [Fact] + public void Test_7895() + { + } + [Fact] + public void Test_7896() + { + } + [Fact] + public void Test_7897() + { + } + [Fact] + public void Test_7898() + { + } + [Fact] + public void Test_7899() + { + } + [Fact] + public void Test_7900() + { + } + [Fact] + public void Test_7901() + { + } + [Fact] + public void Test_7902() + { + } + [Fact] + public void Test_7903() + { + } + [Fact] + public void Test_7904() + { + } + [Fact] + public void Test_7905() + { + } + [Fact] + public void Test_7906() + { + } + [Fact] + public void Test_7907() + { + } + [Fact] + public void Test_7908() + { + } + [Fact] + public void Test_7909() + { + } + [Fact] + public void Test_7910() + { + } + [Fact] + public void Test_7911() + { + } + [Fact] + public void Test_7912() + { + } + [Fact] + public void Test_7913() + { + } + [Fact] + public void Test_7914() + { + } + [Fact] + public void Test_7915() + { + } + [Fact] + public void Test_7916() + { + } + [Fact] + public void Test_7917() + { + } + [Fact] + public void Test_7918() + { + } + [Fact] + public void Test_7919() + { + } + [Fact] + public void Test_7920() + { + } + [Fact] + public void Test_7921() + { + } + [Fact] + public void Test_7922() + { + } + [Fact] + public void Test_7923() + { + } + [Fact] + public void Test_7924() + { + } + [Fact] + public void Test_7925() + { + } + [Fact] + public void Test_7926() + { + } + [Fact] + public void Test_7927() + { + } + [Fact] + public void Test_7928() + { + } + [Fact] + public void Test_7929() + { + } + [Fact] + public void Test_7930() + { + } + [Fact] + public void Test_7931() + { + } + [Fact] + public void Test_7932() + { + } + [Fact] + public void Test_7933() + { + } + [Fact] + public void Test_7934() + { + } + [Fact] + public void Test_7935() + { + } + [Fact] + public void Test_7936() + { + } + [Fact] + public void Test_7937() + { + } + [Fact] + public void Test_7938() + { + } + [Fact] + public void Test_7939() + { + } + [Fact] + public void Test_7940() + { + } + [Fact] + public void Test_7941() + { + } + [Fact] + public void Test_7942() + { + } + [Fact] + public void Test_7943() + { + } + [Fact] + public void Test_7944() + { + } + [Fact] + public void Test_7945() + { + } + [Fact] + public void Test_7946() + { + } + [Fact] + public void Test_7947() + { + } + [Fact] + public void Test_7948() + { + } + [Fact] + public void Test_7949() + { + } + [Fact] + public void Test_7950() + { + } + [Fact] + public void Test_7951() + { + } + [Fact] + public void Test_7952() + { + } + [Fact] + public void Test_7953() + { + } + [Fact] + public void Test_7954() + { + } + [Fact] + public void Test_7955() + { + } + [Fact] + public void Test_7956() + { + } + [Fact] + public void Test_7957() + { + } + [Fact] + public void Test_7958() + { + } + [Fact] + public void Test_7959() + { + } + [Fact] + public void Test_7960() + { + } + [Fact] + public void Test_7961() + { + } + [Fact] + public void Test_7962() + { + } + [Fact] + public void Test_7963() + { + } + [Fact] + public void Test_7964() + { + } + [Fact] + public void Test_7965() + { + } + [Fact] + public void Test_7966() + { + } + [Fact] + public void Test_7967() + { + } + [Fact] + public void Test_7968() + { + } + [Fact] + public void Test_7969() + { + } + [Fact] + public void Test_7970() + { + } + [Fact] + public void Test_7971() + { + } + [Fact] + public void Test_7972() + { + } + [Fact] + public void Test_7973() + { + } + [Fact] + public void Test_7974() + { + } + [Fact] + public void Test_7975() + { + } + [Fact] + public void Test_7976() + { + } + [Fact] + public void Test_7977() + { + } + [Fact] + public void Test_7978() + { + } + [Fact] + public void Test_7979() + { + } + [Fact] + public void Test_7980() + { + } + [Fact] + public void Test_7981() + { + } + [Fact] + public void Test_7982() + { + } + [Fact] + public void Test_7983() + { + } + [Fact] + public void Test_7984() + { + } + [Fact] + public void Test_7985() + { + } + [Fact] + public void Test_7986() + { + } + [Fact] + public void Test_7987() + { + } + [Fact] + public void Test_7988() + { + } + [Fact] + public void Test_7989() + { + } + [Fact] + public void Test_7990() + { + } + [Fact] + public void Test_7991() + { + } + [Fact] + public void Test_7992() + { + } + [Fact] + public void Test_7993() + { + } + [Fact] + public void Test_7994() + { + } + [Fact] + public void Test_7995() + { + } + [Fact] + public void Test_7996() + { + } + [Fact] + public void Test_7997() + { + } + [Fact] + public void Test_7998() + { + } + [Fact] + public void Test_7999() + { + } + [Fact] + public void Test_8000() + { + } + [Fact] + public void Test_8001() + { + } + [Fact] + public void Test_8002() + { + } + [Fact] + public void Test_8003() + { + } + [Fact] + public void Test_8004() + { + } + [Fact] + public void Test_8005() + { + } + [Fact] + public void Test_8006() + { + } + [Fact] + public void Test_8007() + { + } + [Fact] + public void Test_8008() + { + } + [Fact] + public void Test_8009() + { + } + [Fact] + public void Test_8010() + { + } + [Fact] + public void Test_8011() + { + } + [Fact] + public void Test_8012() + { + } + [Fact] + public void Test_8013() + { + } + [Fact] + public void Test_8014() + { + } + [Fact] + public void Test_8015() + { + } + [Fact] + public void Test_8016() + { + } + [Fact] + public void Test_8017() + { + } + [Fact] + public void Test_8018() + { + } + [Fact] + public void Test_8019() + { + } + [Fact] + public void Test_8020() + { + } + [Fact] + public void Test_8021() + { + } + [Fact] + public void Test_8022() + { + } + [Fact] + public void Test_8023() + { + } + [Fact] + public void Test_8024() + { + } + [Fact] + public void Test_8025() + { + } + [Fact] + public void Test_8026() + { + } + [Fact] + public void Test_8027() + { + } + [Fact] + public void Test_8028() + { + } + [Fact] + public void Test_8029() + { + } + [Fact] + public void Test_8030() + { + } + [Fact] + public void Test_8031() + { + } + [Fact] + public void Test_8032() + { + } + [Fact] + public void Test_8033() + { + } + [Fact] + public void Test_8034() + { + } + [Fact] + public void Test_8035() + { + } + [Fact] + public void Test_8036() + { + } + [Fact] + public void Test_8037() + { + } + [Fact] + public void Test_8038() + { + } + [Fact] + public void Test_8039() + { + } + [Fact] + public void Test_8040() + { + } + [Fact] + public void Test_8041() + { + } + [Fact] + public void Test_8042() + { + } + [Fact] + public void Test_8043() + { + } + [Fact] + public void Test_8044() + { + } + [Fact] + public void Test_8045() + { + } + [Fact] + public void Test_8046() + { + } + [Fact] + public void Test_8047() + { + } + [Fact] + public void Test_8048() + { + } + [Fact] + public void Test_8049() + { + } + [Fact] + public void Test_8050() + { + } + [Fact] + public void Test_8051() + { + } + [Fact] + public void Test_8052() + { + } + [Fact] + public void Test_8053() + { + } + [Fact] + public void Test_8054() + { + } + [Fact] + public void Test_8055() + { + } + [Fact] + public void Test_8056() + { + } + [Fact] + public void Test_8057() + { + } + [Fact] + public void Test_8058() + { + } + [Fact] + public void Test_8059() + { + } + [Fact] + public void Test_8060() + { + } + [Fact] + public void Test_8061() + { + } + [Fact] + public void Test_8062() + { + } + [Fact] + public void Test_8063() + { + } + [Fact] + public void Test_8064() + { + } + [Fact] + public void Test_8065() + { + } + [Fact] + public void Test_8066() + { + } + [Fact] + public void Test_8067() + { + } + [Fact] + public void Test_8068() + { + } + [Fact] + public void Test_8069() + { + } + [Fact] + public void Test_8070() + { + } + [Fact] + public void Test_8071() + { + } + [Fact] + public void Test_8072() + { + } + [Fact] + public void Test_8073() + { + } + [Fact] + public void Test_8074() + { + } + [Fact] + public void Test_8075() + { + } + [Fact] + public void Test_8076() + { + } + [Fact] + public void Test_8077() + { + } + [Fact] + public void Test_8078() + { + } + [Fact] + public void Test_8079() + { + } + [Fact] + public void Test_8080() + { + } + [Fact] + public void Test_8081() + { + } + [Fact] + public void Test_8082() + { + } + [Fact] + public void Test_8083() + { + } + [Fact] + public void Test_8084() + { + } + [Fact] + public void Test_8085() + { + } + [Fact] + public void Test_8086() + { + } + [Fact] + public void Test_8087() + { + } + [Fact] + public void Test_8088() + { + } + [Fact] + public void Test_8089() + { + } + [Fact] + public void Test_8090() + { + } + [Fact] + public void Test_8091() + { + } + [Fact] + public void Test_8092() + { + } + [Fact] + public void Test_8093() + { + } + [Fact] + public void Test_8094() + { + } + [Fact] + public void Test_8095() + { + } + [Fact] + public void Test_8096() + { + } + [Fact] + public void Test_8097() + { + } + [Fact] + public void Test_8098() + { + } + [Fact] + public void Test_8099() + { + } + [Fact] + public void Test_8100() + { + } + [Fact] + public void Test_8101() + { + } + [Fact] + public void Test_8102() + { + } + [Fact] + public void Test_8103() + { + } + [Fact] + public void Test_8104() + { + } + [Fact] + public void Test_8105() + { + } + [Fact] + public void Test_8106() + { + } + [Fact] + public void Test_8107() + { + } + [Fact] + public void Test_8108() + { + } + [Fact] + public void Test_8109() + { + } + [Fact] + public void Test_8110() + { + } + [Fact] + public void Test_8111() + { + } + [Fact] + public void Test_8112() + { + } + [Fact] + public void Test_8113() + { + } + [Fact] + public void Test_8114() + { + } + [Fact] + public void Test_8115() + { + } + [Fact] + public void Test_8116() + { + } + [Fact] + public void Test_8117() + { + } + [Fact] + public void Test_8118() + { + } + [Fact] + public void Test_8119() + { + } + [Fact] + public void Test_8120() + { + } + [Fact] + public void Test_8121() + { + } + [Fact] + public void Test_8122() + { + } + [Fact] + public void Test_8123() + { + } + [Fact] + public void Test_8124() + { + } + [Fact] + public void Test_8125() + { + } + [Fact] + public void Test_8126() + { + } + [Fact] + public void Test_8127() + { + } + [Fact] + public void Test_8128() + { + } + [Fact] + public void Test_8129() + { + } + [Fact] + public void Test_8130() + { + } + [Fact] + public void Test_8131() + { + } + [Fact] + public void Test_8132() + { + } + [Fact] + public void Test_8133() + { + } + [Fact] + public void Test_8134() + { + } + [Fact] + public void Test_8135() + { + } + [Fact] + public void Test_8136() + { + } + [Fact] + public void Test_8137() + { + } + [Fact] + public void Test_8138() + { + } + [Fact] + public void Test_8139() + { + } + [Fact] + public void Test_8140() + { + } + [Fact] + public void Test_8141() + { + } + [Fact] + public void Test_8142() + { + } + [Fact] + public void Test_8143() + { + } + [Fact] + public void Test_8144() + { + } + [Fact] + public void Test_8145() + { + } + [Fact] + public void Test_8146() + { + } + [Fact] + public void Test_8147() + { + } + [Fact] + public void Test_8148() + { + } + [Fact] + public void Test_8149() + { + } + [Fact] + public void Test_8150() + { + } + [Fact] + public void Test_8151() + { + } + [Fact] + public void Test_8152() + { + } + [Fact] + public void Test_8153() + { + } + [Fact] + public void Test_8154() + { + } + [Fact] + public void Test_8155() + { + } + [Fact] + public void Test_8156() + { + } + [Fact] + public void Test_8157() + { + } + [Fact] + public void Test_8158() + { + } + [Fact] + public void Test_8159() + { + } + [Fact] + public void Test_8160() + { + } + [Fact] + public void Test_8161() + { + } + [Fact] + public void Test_8162() + { + } + [Fact] + public void Test_8163() + { + } + [Fact] + public void Test_8164() + { + } + [Fact] + public void Test_8165() + { + } + [Fact] + public void Test_8166() + { + } + [Fact] + public void Test_8167() + { + } + [Fact] + public void Test_8168() + { + } + [Fact] + public void Test_8169() + { + } + [Fact] + public void Test_8170() + { + } + [Fact] + public void Test_8171() + { + } + [Fact] + public void Test_8172() + { + } + [Fact] + public void Test_8173() + { + } + [Fact] + public void Test_8174() + { + } + [Fact] + public void Test_8175() + { + } + [Fact] + public void Test_8176() + { + } + [Fact] + public void Test_8177() + { + } + [Fact] + public void Test_8178() + { + } + [Fact] + public void Test_8179() + { + } + [Fact] + public void Test_8180() + { + } + [Fact] + public void Test_8181() + { + } + [Fact] + public void Test_8182() + { + } + [Fact] + public void Test_8183() + { + } + [Fact] + public void Test_8184() + { + } + [Fact] + public void Test_8185() + { + } + [Fact] + public void Test_8186() + { + } + [Fact] + public void Test_8187() + { + } + [Fact] + public void Test_8188() + { + } + [Fact] + public void Test_8189() + { + } + [Fact] + public void Test_8190() + { + } + [Fact] + public void Test_8191() + { + } + [Fact] + public void Test_8192() + { + } + [Fact] + public void Test_8193() + { + } + [Fact] + public void Test_8194() + { + } + [Fact] + public void Test_8195() + { + } + [Fact] + public void Test_8196() + { + } + [Fact] + public void Test_8197() + { + } + [Fact] + public void Test_8198() + { + } + [Fact] + public void Test_8199() + { + } + [Fact] + public void Test_8200() + { + } + [Fact] + public void Test_8201() + { + } + [Fact] + public void Test_8202() + { + } + [Fact] + public void Test_8203() + { + } + [Fact] + public void Test_8204() + { + } + [Fact] + public void Test_8205() + { + } + [Fact] + public void Test_8206() + { + } + [Fact] + public void Test_8207() + { + } + [Fact] + public void Test_8208() + { + } + [Fact] + public void Test_8209() + { + } + [Fact] + public void Test_8210() + { + } + [Fact] + public void Test_8211() + { + } + [Fact] + public void Test_8212() + { + } + [Fact] + public void Test_8213() + { + } + [Fact] + public void Test_8214() + { + } + [Fact] + public void Test_8215() + { + } + [Fact] + public void Test_8216() + { + } + [Fact] + public void Test_8217() + { + } + [Fact] + public void Test_8218() + { + } + [Fact] + public void Test_8219() + { + } + [Fact] + public void Test_8220() + { + } + [Fact] + public void Test_8221() + { + } + [Fact] + public void Test_8222() + { + } + [Fact] + public void Test_8223() + { + } + [Fact] + public void Test_8224() + { + } + [Fact] + public void Test_8225() + { + } + [Fact] + public void Test_8226() + { + } + [Fact] + public void Test_8227() + { + } + [Fact] + public void Test_8228() + { + } + [Fact] + public void Test_8229() + { + } + [Fact] + public void Test_8230() + { + } + [Fact] + public void Test_8231() + { + } + [Fact] + public void Test_8232() + { + } + [Fact] + public void Test_8233() + { + } + [Fact] + public void Test_8234() + { + } + [Fact] + public void Test_8235() + { + } + [Fact] + public void Test_8236() + { + } + [Fact] + public void Test_8237() + { + } + [Fact] + public void Test_8238() + { + } + [Fact] + public void Test_8239() + { + } + [Fact] + public void Test_8240() + { + } + [Fact] + public void Test_8241() + { + } + [Fact] + public void Test_8242() + { + } + [Fact] + public void Test_8243() + { + } + [Fact] + public void Test_8244() + { + } + [Fact] + public void Test_8245() + { + } + [Fact] + public void Test_8246() + { + } + [Fact] + public void Test_8247() + { + } + [Fact] + public void Test_8248() + { + } + [Fact] + public void Test_8249() + { + } + [Fact] + public void Test_8250() + { + } + [Fact] + public void Test_8251() + { + } + [Fact] + public void Test_8252() + { + } + [Fact] + public void Test_8253() + { + } + [Fact] + public void Test_8254() + { + } + [Fact] + public void Test_8255() + { + } + [Fact] + public void Test_8256() + { + } + [Fact] + public void Test_8257() + { + } + [Fact] + public void Test_8258() + { + } + [Fact] + public void Test_8259() + { + } + [Fact] + public void Test_8260() + { + } + [Fact] + public void Test_8261() + { + } + [Fact] + public void Test_8262() + { + } + [Fact] + public void Test_8263() + { + } + [Fact] + public void Test_8264() + { + } + [Fact] + public void Test_8265() + { + } + [Fact] + public void Test_8266() + { + } + [Fact] + public void Test_8267() + { + } + [Fact] + public void Test_8268() + { + } + [Fact] + public void Test_8269() + { + } + [Fact] + public void Test_8270() + { + } + [Fact] + public void Test_8271() + { + } + [Fact] + public void Test_8272() + { + } + [Fact] + public void Test_8273() + { + } + [Fact] + public void Test_8274() + { + } + [Fact] + public void Test_8275() + { + } + [Fact] + public void Test_8276() + { + } + [Fact] + public void Test_8277() + { + } + [Fact] + public void Test_8278() + { + } + [Fact] + public void Test_8279() + { + } + [Fact] + public void Test_8280() + { + } + [Fact] + public void Test_8281() + { + } + [Fact] + public void Test_8282() + { + } + [Fact] + public void Test_8283() + { + } + [Fact] + public void Test_8284() + { + } + [Fact] + public void Test_8285() + { + } + [Fact] + public void Test_8286() + { + } + [Fact] + public void Test_8287() + { + } + [Fact] + public void Test_8288() + { + } + [Fact] + public void Test_8289() + { + } + [Fact] + public void Test_8290() + { + } + [Fact] + public void Test_8291() + { + } + [Fact] + public void Test_8292() + { + } + [Fact] + public void Test_8293() + { + } + [Fact] + public void Test_8294() + { + } + [Fact] + public void Test_8295() + { + } + [Fact] + public void Test_8296() + { + } + [Fact] + public void Test_8297() + { + } + [Fact] + public void Test_8298() + { + } + [Fact] + public void Test_8299() + { + } + [Fact] + public void Test_8300() + { + } + [Fact] + public void Test_8301() + { + } + [Fact] + public void Test_8302() + { + } + [Fact] + public void Test_8303() + { + } + [Fact] + public void Test_8304() + { + } + [Fact] + public void Test_8305() + { + } + [Fact] + public void Test_8306() + { + } + [Fact] + public void Test_8307() + { + } + [Fact] + public void Test_8308() + { + } + [Fact] + public void Test_8309() + { + } + [Fact] + public void Test_8310() + { + } + [Fact] + public void Test_8311() + { + } + [Fact] + public void Test_8312() + { + } + [Fact] + public void Test_8313() + { + } + [Fact] + public void Test_8314() + { + } + [Fact] + public void Test_8315() + { + } + [Fact] + public void Test_8316() + { + } + [Fact] + public void Test_8317() + { + } + [Fact] + public void Test_8318() + { + } + [Fact] + public void Test_8319() + { + } + [Fact] + public void Test_8320() + { + } + [Fact] + public void Test_8321() + { + } + [Fact] + public void Test_8322() + { + } + [Fact] + public void Test_8323() + { + } + [Fact] + public void Test_8324() + { + } + [Fact] + public void Test_8325() + { + } + [Fact] + public void Test_8326() + { + } + [Fact] + public void Test_8327() + { + } + [Fact] + public void Test_8328() + { + } + [Fact] + public void Test_8329() + { + } + [Fact] + public void Test_8330() + { + } + [Fact] + public void Test_8331() + { + } + [Fact] + public void Test_8332() + { + } + [Fact] + public void Test_8333() + { + } + [Fact] + public void Test_8334() + { + } + [Fact] + public void Test_8335() + { + } + [Fact] + public void Test_8336() + { + } + [Fact] + public void Test_8337() + { + } + [Fact] + public void Test_8338() + { + } + [Fact] + public void Test_8339() + { + } + [Fact] + public void Test_8340() + { + } + [Fact] + public void Test_8341() + { + } + [Fact] + public void Test_8342() + { + } + [Fact] + public void Test_8343() + { + } + [Fact] + public void Test_8344() + { + } + [Fact] + public void Test_8345() + { + } + [Fact] + public void Test_8346() + { + } + [Fact] + public void Test_8347() + { + } + [Fact] + public void Test_8348() + { + } + [Fact] + public void Test_8349() + { + } + [Fact] + public void Test_8350() + { + } + [Fact] + public void Test_8351() + { + } + [Fact] + public void Test_8352() + { + } + [Fact] + public void Test_8353() + { + } + [Fact] + public void Test_8354() + { + } + [Fact] + public void Test_8355() + { + } + [Fact] + public void Test_8356() + { + } + [Fact] + public void Test_8357() + { + } + [Fact] + public void Test_8358() + { + } + [Fact] + public void Test_8359() + { + } + [Fact] + public void Test_8360() + { + } + [Fact] + public void Test_8361() + { + } + [Fact] + public void Test_8362() + { + } + [Fact] + public void Test_8363() + { + } + [Fact] + public void Test_8364() + { + } + [Fact] + public void Test_8365() + { + } + [Fact] + public void Test_8366() + { + } + [Fact] + public void Test_8367() + { + } + [Fact] + public void Test_8368() + { + } + [Fact] + public void Test_8369() + { + } + [Fact] + public void Test_8370() + { + } + [Fact] + public void Test_8371() + { + } + [Fact] + public void Test_8372() + { + } + [Fact] + public void Test_8373() + { + } + [Fact] + public void Test_8374() + { + } + [Fact] + public void Test_8375() + { + } + [Fact] + public void Test_8376() + { + } + [Fact] + public void Test_8377() + { + } + [Fact] + public void Test_8378() + { + } + [Fact] + public void Test_8379() + { + } + [Fact] + public void Test_8380() + { + } + [Fact] + public void Test_8381() + { + } + [Fact] + public void Test_8382() + { + } + [Fact] + public void Test_8383() + { + } + [Fact] + public void Test_8384() + { + } + [Fact] + public void Test_8385() + { + } + [Fact] + public void Test_8386() + { + } + [Fact] + public void Test_8387() + { + } + [Fact] + public void Test_8388() + { + } + [Fact] + public void Test_8389() + { + } + [Fact] + public void Test_8390() + { + } + [Fact] + public void Test_8391() + { + } + [Fact] + public void Test_8392() + { + } + [Fact] + public void Test_8393() + { + } + [Fact] + public void Test_8394() + { + } + [Fact] + public void Test_8395() + { + } + [Fact] + public void Test_8396() + { + } + [Fact] + public void Test_8397() + { + } + [Fact] + public void Test_8398() + { + } + [Fact] + public void Test_8399() + { + } + [Fact] + public void Test_8400() + { + } + [Fact] + public void Test_8401() + { + } + [Fact] + public void Test_8402() + { + } + [Fact] + public void Test_8403() + { + } + [Fact] + public void Test_8404() + { + } + [Fact] + public void Test_8405() + { + } + [Fact] + public void Test_8406() + { + } + [Fact] + public void Test_8407() + { + } + [Fact] + public void Test_8408() + { + } + [Fact] + public void Test_8409() + { + } + [Fact] + public void Test_8410() + { + } + [Fact] + public void Test_8411() + { + } + [Fact] + public void Test_8412() + { + } + [Fact] + public void Test_8413() + { + } + [Fact] + public void Test_8414() + { + } + [Fact] + public void Test_8415() + { + } + [Fact] + public void Test_8416() + { + } + [Fact] + public void Test_8417() + { + } + [Fact] + public void Test_8418() + { + } + [Fact] + public void Test_8419() + { + } + [Fact] + public void Test_8420() + { + } + [Fact] + public void Test_8421() + { + } + [Fact] + public void Test_8422() + { + } + [Fact] + public void Test_8423() + { + } + [Fact] + public void Test_8424() + { + } + [Fact] + public void Test_8425() + { + } + [Fact] + public void Test_8426() + { + } + [Fact] + public void Test_8427() + { + } + [Fact] + public void Test_8428() + { + } + [Fact] + public void Test_8429() + { + } + [Fact] + public void Test_8430() + { + } + [Fact] + public void Test_8431() + { + } + [Fact] + public void Test_8432() + { + } + [Fact] + public void Test_8433() + { + } + [Fact] + public void Test_8434() + { + } + [Fact] + public void Test_8435() + { + } + [Fact] + public void Test_8436() + { + } + [Fact] + public void Test_8437() + { + } + [Fact] + public void Test_8438() + { + } + [Fact] + public void Test_8439() + { + } + [Fact] + public void Test_8440() + { + } + [Fact] + public void Test_8441() + { + } + [Fact] + public void Test_8442() + { + } + [Fact] + public void Test_8443() + { + } + [Fact] + public void Test_8444() + { + } + [Fact] + public void Test_8445() + { + } + [Fact] + public void Test_8446() + { + } + [Fact] + public void Test_8447() + { + } + [Fact] + public void Test_8448() + { + } + [Fact] + public void Test_8449() + { + } + [Fact] + public void Test_8450() + { + } + [Fact] + public void Test_8451() + { + } + [Fact] + public void Test_8452() + { + } + [Fact] + public void Test_8453() + { + } + [Fact] + public void Test_8454() + { + } + [Fact] + public void Test_8455() + { + } + [Fact] + public void Test_8456() + { + } + [Fact] + public void Test_8457() + { + } + [Fact] + public void Test_8458() + { + } + [Fact] + public void Test_8459() + { + } + [Fact] + public void Test_8460() + { + } + [Fact] + public void Test_8461() + { + } + [Fact] + public void Test_8462() + { + } + [Fact] + public void Test_8463() + { + } + [Fact] + public void Test_8464() + { + } + [Fact] + public void Test_8465() + { + } + [Fact] + public void Test_8466() + { + } + [Fact] + public void Test_8467() + { + } + [Fact] + public void Test_8468() + { + } + [Fact] + public void Test_8469() + { + } + [Fact] + public void Test_8470() + { + } + [Fact] + public void Test_8471() + { + } + [Fact] + public void Test_8472() + { + } + [Fact] + public void Test_8473() + { + } + [Fact] + public void Test_8474() + { + } + [Fact] + public void Test_8475() + { + } + [Fact] + public void Test_8476() + { + } + [Fact] + public void Test_8477() + { + } + [Fact] + public void Test_8478() + { + } + [Fact] + public void Test_8479() + { + } + [Fact] + public void Test_8480() + { + } + [Fact] + public void Test_8481() + { + } + [Fact] + public void Test_8482() + { + } + [Fact] + public void Test_8483() + { + } + [Fact] + public void Test_8484() + { + } + [Fact] + public void Test_8485() + { + } + [Fact] + public void Test_8486() + { + } + [Fact] + public void Test_8487() + { + } + [Fact] + public void Test_8488() + { + } + [Fact] + public void Test_8489() + { + } + [Fact] + public void Test_8490() + { + } + [Fact] + public void Test_8491() + { + } + [Fact] + public void Test_8492() + { + } + [Fact] + public void Test_8493() + { + } + [Fact] + public void Test_8494() + { + } + [Fact] + public void Test_8495() + { + } + [Fact] + public void Test_8496() + { + } + [Fact] + public void Test_8497() + { + } + [Fact] + public void Test_8498() + { + } + [Fact] + public void Test_8499() + { + } + [Fact] + public void Test_8500() + { + } + [Fact] + public void Test_8501() + { + } + [Fact] + public void Test_8502() + { + } + [Fact] + public void Test_8503() + { + } + [Fact] + public void Test_8504() + { + } + [Fact] + public void Test_8505() + { + } + [Fact] + public void Test_8506() + { + } + [Fact] + public void Test_8507() + { + } + [Fact] + public void Test_8508() + { + } + [Fact] + public void Test_8509() + { + } + [Fact] + public void Test_8510() + { + } + [Fact] + public void Test_8511() + { + } + [Fact] + public void Test_8512() + { + } + [Fact] + public void Test_8513() + { + } + [Fact] + public void Test_8514() + { + } + [Fact] + public void Test_8515() + { + } + [Fact] + public void Test_8516() + { + } + [Fact] + public void Test_8517() + { + } + [Fact] + public void Test_8518() + { + } + [Fact] + public void Test_8519() + { + } + [Fact] + public void Test_8520() + { + } + [Fact] + public void Test_8521() + { + } + [Fact] + public void Test_8522() + { + } + [Fact] + public void Test_8523() + { + } + [Fact] + public void Test_8524() + { + } + [Fact] + public void Test_8525() + { + } + [Fact] + public void Test_8526() + { + } + [Fact] + public void Test_8527() + { + } + [Fact] + public void Test_8528() + { + } + [Fact] + public void Test_8529() + { + } + [Fact] + public void Test_8530() + { + } + [Fact] + public void Test_8531() + { + } + [Fact] + public void Test_8532() + { + } + [Fact] + public void Test_8533() + { + } + [Fact] + public void Test_8534() + { + } + [Fact] + public void Test_8535() + { + } + [Fact] + public void Test_8536() + { + } + [Fact] + public void Test_8537() + { + } + [Fact] + public void Test_8538() + { + } + [Fact] + public void Test_8539() + { + } + [Fact] + public void Test_8540() + { + } + [Fact] + public void Test_8541() + { + } + [Fact] + public void Test_8542() + { + } + [Fact] + public void Test_8543() + { + } + [Fact] + public void Test_8544() + { + } + [Fact] + public void Test_8545() + { + } + [Fact] + public void Test_8546() + { + } + [Fact] + public void Test_8547() + { + } + [Fact] + public void Test_8548() + { + } + [Fact] + public void Test_8549() + { + } + [Fact] + public void Test_8550() + { + } + [Fact] + public void Test_8551() + { + } + [Fact] + public void Test_8552() + { + } + [Fact] + public void Test_8553() + { + } + [Fact] + public void Test_8554() + { + } + [Fact] + public void Test_8555() + { + } + [Fact] + public void Test_8556() + { + } + [Fact] + public void Test_8557() + { + } + [Fact] + public void Test_8558() + { + } + [Fact] + public void Test_8559() + { + } + [Fact] + public void Test_8560() + { + } + [Fact] + public void Test_8561() + { + } + [Fact] + public void Test_8562() + { + } + [Fact] + public void Test_8563() + { + } + [Fact] + public void Test_8564() + { + } + [Fact] + public void Test_8565() + { + } + [Fact] + public void Test_8566() + { + } + [Fact] + public void Test_8567() + { + } + [Fact] + public void Test_8568() + { + } + [Fact] + public void Test_8569() + { + } + [Fact] + public void Test_8570() + { + } + [Fact] + public void Test_8571() + { + } + [Fact] + public void Test_8572() + { + } + [Fact] + public void Test_8573() + { + } + [Fact] + public void Test_8574() + { + } + [Fact] + public void Test_8575() + { + } + [Fact] + public void Test_8576() + { + } + [Fact] + public void Test_8577() + { + } + [Fact] + public void Test_8578() + { + } + [Fact] + public void Test_8579() + { + } + [Fact] + public void Test_8580() + { + } + [Fact] + public void Test_8581() + { + } + [Fact] + public void Test_8582() + { + } + [Fact] + public void Test_8583() + { + } + [Fact] + public void Test_8584() + { + } + [Fact] + public void Test_8585() + { + } + [Fact] + public void Test_8586() + { + } + [Fact] + public void Test_8587() + { + } + [Fact] + public void Test_8588() + { + } + [Fact] + public void Test_8589() + { + } + [Fact] + public void Test_8590() + { + } + [Fact] + public void Test_8591() + { + } + [Fact] + public void Test_8592() + { + } + [Fact] + public void Test_8593() + { + } + [Fact] + public void Test_8594() + { + } + [Fact] + public void Test_8595() + { + } + [Fact] + public void Test_8596() + { + } + [Fact] + public void Test_8597() + { + } + [Fact] + public void Test_8598() + { + } + [Fact] + public void Test_8599() + { + } + [Fact] + public void Test_8600() + { + } + [Fact] + public void Test_8601() + { + } + [Fact] + public void Test_8602() + { + } + [Fact] + public void Test_8603() + { + } + [Fact] + public void Test_8604() + { + } + [Fact] + public void Test_8605() + { + } + [Fact] + public void Test_8606() + { + } + [Fact] + public void Test_8607() + { + } + [Fact] + public void Test_8608() + { + } + [Fact] + public void Test_8609() + { + } + [Fact] + public void Test_8610() + { + } + [Fact] + public void Test_8611() + { + } + [Fact] + public void Test_8612() + { + } + [Fact] + public void Test_8613() + { + } + [Fact] + public void Test_8614() + { + } + [Fact] + public void Test_8615() + { + } + [Fact] + public void Test_8616() + { + } + [Fact] + public void Test_8617() + { + } + [Fact] + public void Test_8618() + { + } + [Fact] + public void Test_8619() + { + } + [Fact] + public void Test_8620() + { + } + [Fact] + public void Test_8621() + { + } + [Fact] + public void Test_8622() + { + } + [Fact] + public void Test_8623() + { + } + [Fact] + public void Test_8624() + { + } + [Fact] + public void Test_8625() + { + } + [Fact] + public void Test_8626() + { + } + [Fact] + public void Test_8627() + { + } + [Fact] + public void Test_8628() + { + } + [Fact] + public void Test_8629() + { + } + [Fact] + public void Test_8630() + { + } + [Fact] + public void Test_8631() + { + } + [Fact] + public void Test_8632() + { + } + [Fact] + public void Test_8633() + { + } + [Fact] + public void Test_8634() + { + } + [Fact] + public void Test_8635() + { + } + [Fact] + public void Test_8636() + { + } + [Fact] + public void Test_8637() + { + } + [Fact] + public void Test_8638() + { + } + [Fact] + public void Test_8639() + { + } + [Fact] + public void Test_8640() + { + } + [Fact] + public void Test_8641() + { + } + [Fact] + public void Test_8642() + { + } + [Fact] + public void Test_8643() + { + } + [Fact] + public void Test_8644() + { + } + [Fact] + public void Test_8645() + { + } + [Fact] + public void Test_8646() + { + } + [Fact] + public void Test_8647() + { + } + [Fact] + public void Test_8648() + { + } + [Fact] + public void Test_8649() + { + } + [Fact] + public void Test_8650() + { + } + [Fact] + public void Test_8651() + { + } + [Fact] + public void Test_8652() + { + } + [Fact] + public void Test_8653() + { + } + [Fact] + public void Test_8654() + { + } + [Fact] + public void Test_8655() + { + } + [Fact] + public void Test_8656() + { + } + [Fact] + public void Test_8657() + { + } + [Fact] + public void Test_8658() + { + } + [Fact] + public void Test_8659() + { + } + [Fact] + public void Test_8660() + { + } + [Fact] + public void Test_8661() + { + } + [Fact] + public void Test_8662() + { + } + [Fact] + public void Test_8663() + { + } + [Fact] + public void Test_8664() + { + } + [Fact] + public void Test_8665() + { + } + [Fact] + public void Test_8666() + { + } + [Fact] + public void Test_8667() + { + } + [Fact] + public void Test_8668() + { + } + [Fact] + public void Test_8669() + { + } + [Fact] + public void Test_8670() + { + } + [Fact] + public void Test_8671() + { + } + [Fact] + public void Test_8672() + { + } + [Fact] + public void Test_8673() + { + } + [Fact] + public void Test_8674() + { + } + [Fact] + public void Test_8675() + { + } + [Fact] + public void Test_8676() + { + } + [Fact] + public void Test_8677() + { + } + [Fact] + public void Test_8678() + { + } + [Fact] + public void Test_8679() + { + } + [Fact] + public void Test_8680() + { + } + [Fact] + public void Test_8681() + { + } + [Fact] + public void Test_8682() + { + } + [Fact] + public void Test_8683() + { + } + [Fact] + public void Test_8684() + { + } + [Fact] + public void Test_8685() + { + } + [Fact] + public void Test_8686() + { + } + [Fact] + public void Test_8687() + { + } + [Fact] + public void Test_8688() + { + } + [Fact] + public void Test_8689() + { + } + [Fact] + public void Test_8690() + { + } + [Fact] + public void Test_8691() + { + } + [Fact] + public void Test_8692() + { + } + [Fact] + public void Test_8693() + { + } + [Fact] + public void Test_8694() + { + } + [Fact] + public void Test_8695() + { + } + [Fact] + public void Test_8696() + { + } + [Fact] + public void Test_8697() + { + } + [Fact] + public void Test_8698() + { + } + [Fact] + public void Test_8699() + { + } + [Fact] + public void Test_8700() + { + } + [Fact] + public void Test_8701() + { + } + [Fact] + public void Test_8702() + { + } + [Fact] + public void Test_8703() + { + } + [Fact] + public void Test_8704() + { + } + [Fact] + public void Test_8705() + { + } + [Fact] + public void Test_8706() + { + } + [Fact] + public void Test_8707() + { + } + [Fact] + public void Test_8708() + { + } + [Fact] + public void Test_8709() + { + } + [Fact] + public void Test_8710() + { + } + [Fact] + public void Test_8711() + { + } + [Fact] + public void Test_8712() + { + } + [Fact] + public void Test_8713() + { + } + [Fact] + public void Test_8714() + { + } + [Fact] + public void Test_8715() + { + } + [Fact] + public void Test_8716() + { + } + [Fact] + public void Test_8717() + { + } + [Fact] + public void Test_8718() + { + } + [Fact] + public void Test_8719() + { + } + [Fact] + public void Test_8720() + { + } + [Fact] + public void Test_8721() + { + } + [Fact] + public void Test_8722() + { + } + [Fact] + public void Test_8723() + { + } + [Fact] + public void Test_8724() + { + } + [Fact] + public void Test_8725() + { + } + [Fact] + public void Test_8726() + { + } + [Fact] + public void Test_8727() + { + } + [Fact] + public void Test_8728() + { + } + [Fact] + public void Test_8729() + { + } + [Fact] + public void Test_8730() + { + } + [Fact] + public void Test_8731() + { + } + [Fact] + public void Test_8732() + { + } + [Fact] + public void Test_8733() + { + } + [Fact] + public void Test_8734() + { + } + [Fact] + public void Test_8735() + { + } + [Fact] + public void Test_8736() + { + } + [Fact] + public void Test_8737() + { + } + [Fact] + public void Test_8738() + { + } + [Fact] + public void Test_8739() + { + } + [Fact] + public void Test_8740() + { + } + [Fact] + public void Test_8741() + { + } + [Fact] + public void Test_8742() + { + } + [Fact] + public void Test_8743() + { + } + [Fact] + public void Test_8744() + { + } + [Fact] + public void Test_8745() + { + } + [Fact] + public void Test_8746() + { + } + [Fact] + public void Test_8747() + { + } + [Fact] + public void Test_8748() + { + } + [Fact] + public void Test_8749() + { + } + [Fact] + public void Test_8750() + { + } + [Fact] + public void Test_8751() + { + } + [Fact] + public void Test_8752() + { + } + [Fact] + public void Test_8753() + { + } + [Fact] + public void Test_8754() + { + } + [Fact] + public void Test_8755() + { + } + [Fact] + public void Test_8756() + { + } + [Fact] + public void Test_8757() + { + } + [Fact] + public void Test_8758() + { + } + [Fact] + public void Test_8759() + { + } + [Fact] + public void Test_8760() + { + } + [Fact] + public void Test_8761() + { + } + [Fact] + public void Test_8762() + { + } + [Fact] + public void Test_8763() + { + } + [Fact] + public void Test_8764() + { + } + [Fact] + public void Test_8765() + { + } + [Fact] + public void Test_8766() + { + } + [Fact] + public void Test_8767() + { + } + [Fact] + public void Test_8768() + { + } + [Fact] + public void Test_8769() + { + } + [Fact] + public void Test_8770() + { + } + [Fact] + public void Test_8771() + { + } + [Fact] + public void Test_8772() + { + } + [Fact] + public void Test_8773() + { + } + [Fact] + public void Test_8774() + { + } + [Fact] + public void Test_8775() + { + } + [Fact] + public void Test_8776() + { + } + [Fact] + public void Test_8777() + { + } + [Fact] + public void Test_8778() + { + } + [Fact] + public void Test_8779() + { + } + [Fact] + public void Test_8780() + { + } + [Fact] + public void Test_8781() + { + } + [Fact] + public void Test_8782() + { + } + [Fact] + public void Test_8783() + { + } + [Fact] + public void Test_8784() + { + } + [Fact] + public void Test_8785() + { + } + [Fact] + public void Test_8786() + { + } + [Fact] + public void Test_8787() + { + } + [Fact] + public void Test_8788() + { + } + [Fact] + public void Test_8789() + { + } + [Fact] + public void Test_8790() + { + } + [Fact] + public void Test_8791() + { + } + [Fact] + public void Test_8792() + { + } + [Fact] + public void Test_8793() + { + } + [Fact] + public void Test_8794() + { + } + [Fact] + public void Test_8795() + { + } + [Fact] + public void Test_8796() + { + } + [Fact] + public void Test_8797() + { + } + [Fact] + public void Test_8798() + { + } + [Fact] + public void Test_8799() + { + } + [Fact] + public void Test_8800() + { + } + [Fact] + public void Test_8801() + { + } + [Fact] + public void Test_8802() + { + } + [Fact] + public void Test_8803() + { + } + [Fact] + public void Test_8804() + { + } + [Fact] + public void Test_8805() + { + } + [Fact] + public void Test_8806() + { + } + [Fact] + public void Test_8807() + { + } + [Fact] + public void Test_8808() + { + } + [Fact] + public void Test_8809() + { + } + [Fact] + public void Test_8810() + { + } + [Fact] + public void Test_8811() + { + } + [Fact] + public void Test_8812() + { + } + [Fact] + public void Test_8813() + { + } + [Fact] + public void Test_8814() + { + } + [Fact] + public void Test_8815() + { + } + [Fact] + public void Test_8816() + { + } + [Fact] + public void Test_8817() + { + } + [Fact] + public void Test_8818() + { + } + [Fact] + public void Test_8819() + { + } + [Fact] + public void Test_8820() + { + } + [Fact] + public void Test_8821() + { + } + [Fact] + public void Test_8822() + { + } + [Fact] + public void Test_8823() + { + } + [Fact] + public void Test_8824() + { + } + [Fact] + public void Test_8825() + { + } + [Fact] + public void Test_8826() + { + } + [Fact] + public void Test_8827() + { + } + [Fact] + public void Test_8828() + { + } + [Fact] + public void Test_8829() + { + } + [Fact] + public void Test_8830() + { + } + [Fact] + public void Test_8831() + { + } + [Fact] + public void Test_8832() + { + } + [Fact] + public void Test_8833() + { + } + [Fact] + public void Test_8834() + { + } + [Fact] + public void Test_8835() + { + } + [Fact] + public void Test_8836() + { + } + [Fact] + public void Test_8837() + { + } + [Fact] + public void Test_8838() + { + } + [Fact] + public void Test_8839() + { + } + [Fact] + public void Test_8840() + { + } + [Fact] + public void Test_8841() + { + } + [Fact] + public void Test_8842() + { + } + [Fact] + public void Test_8843() + { + } + [Fact] + public void Test_8844() + { + } + [Fact] + public void Test_8845() + { + } + [Fact] + public void Test_8846() + { + } + [Fact] + public void Test_8847() + { + } + [Fact] + public void Test_8848() + { + } + [Fact] + public void Test_8849() + { + } + [Fact] + public void Test_8850() + { + } + [Fact] + public void Test_8851() + { + } + [Fact] + public void Test_8852() + { + } + [Fact] + public void Test_8853() + { + } + [Fact] + public void Test_8854() + { + } + [Fact] + public void Test_8855() + { + } + [Fact] + public void Test_8856() + { + } + [Fact] + public void Test_8857() + { + } + [Fact] + public void Test_8858() + { + } + [Fact] + public void Test_8859() + { + } + [Fact] + public void Test_8860() + { + } + [Fact] + public void Test_8861() + { + } + [Fact] + public void Test_8862() + { + } + [Fact] + public void Test_8863() + { + } + [Fact] + public void Test_8864() + { + } + [Fact] + public void Test_8865() + { + } + [Fact] + public void Test_8866() + { + } + [Fact] + public void Test_8867() + { + } + [Fact] + public void Test_8868() + { + } + [Fact] + public void Test_8869() + { + } + [Fact] + public void Test_8870() + { + } + [Fact] + public void Test_8871() + { + } + [Fact] + public void Test_8872() + { + } + [Fact] + public void Test_8873() + { + } + [Fact] + public void Test_8874() + { + } + [Fact] + public void Test_8875() + { + } + [Fact] + public void Test_8876() + { + } + [Fact] + public void Test_8877() + { + } + [Fact] + public void Test_8878() + { + } + [Fact] + public void Test_8879() + { + } + [Fact] + public void Test_8880() + { + } + [Fact] + public void Test_8881() + { + } + [Fact] + public void Test_8882() + { + } + [Fact] + public void Test_8883() + { + } + [Fact] + public void Test_8884() + { + } + [Fact] + public void Test_8885() + { + } + [Fact] + public void Test_8886() + { + } + [Fact] + public void Test_8887() + { + } + [Fact] + public void Test_8888() + { + } + [Fact] + public void Test_8889() + { + } + [Fact] + public void Test_8890() + { + } + [Fact] + public void Test_8891() + { + } + [Fact] + public void Test_8892() + { + } + [Fact] + public void Test_8893() + { + } + [Fact] + public void Test_8894() + { + } + [Fact] + public void Test_8895() + { + } + [Fact] + public void Test_8896() + { + } + [Fact] + public void Test_8897() + { + } + [Fact] + public void Test_8898() + { + } + [Fact] + public void Test_8899() + { + } + [Fact] + public void Test_8900() + { + } + [Fact] + public void Test_8901() + { + } + [Fact] + public void Test_8902() + { + } + [Fact] + public void Test_8903() + { + } + [Fact] + public void Test_8904() + { + } + [Fact] + public void Test_8905() + { + } + [Fact] + public void Test_8906() + { + } + [Fact] + public void Test_8907() + { + } + [Fact] + public void Test_8908() + { + } + [Fact] + public void Test_8909() + { + } + [Fact] + public void Test_8910() + { + } + [Fact] + public void Test_8911() + { + } + [Fact] + public void Test_8912() + { + } + [Fact] + public void Test_8913() + { + } + [Fact] + public void Test_8914() + { + } + [Fact] + public void Test_8915() + { + } + [Fact] + public void Test_8916() + { + } + [Fact] + public void Test_8917() + { + } + [Fact] + public void Test_8918() + { + } + [Fact] + public void Test_8919() + { + } + [Fact] + public void Test_8920() + { + } + [Fact] + public void Test_8921() + { + } + [Fact] + public void Test_8922() + { + } + [Fact] + public void Test_8923() + { + } + [Fact] + public void Test_8924() + { + } + [Fact] + public void Test_8925() + { + } + [Fact] + public void Test_8926() + { + } + [Fact] + public void Test_8927() + { + } + [Fact] + public void Test_8928() + { + } + [Fact] + public void Test_8929() + { + } + [Fact] + public void Test_8930() + { + } + [Fact] + public void Test_8931() + { + } + [Fact] + public void Test_8932() + { + } + [Fact] + public void Test_8933() + { + } + [Fact] + public void Test_8934() + { + } + [Fact] + public void Test_8935() + { + } + [Fact] + public void Test_8936() + { + } + [Fact] + public void Test_8937() + { + } + [Fact] + public void Test_8938() + { + } + [Fact] + public void Test_8939() + { + } + [Fact] + public void Test_8940() + { + } + [Fact] + public void Test_8941() + { + } + [Fact] + public void Test_8942() + { + } + [Fact] + public void Test_8943() + { + } + [Fact] + public void Test_8944() + { + } + [Fact] + public void Test_8945() + { + } + [Fact] + public void Test_8946() + { + } + [Fact] + public void Test_8947() + { + } + [Fact] + public void Test_8948() + { + } + [Fact] + public void Test_8949() + { + } + [Fact] + public void Test_8950() + { + } + [Fact] + public void Test_8951() + { + } + [Fact] + public void Test_8952() + { + } + [Fact] + public void Test_8953() + { + } + [Fact] + public void Test_8954() + { + } + [Fact] + public void Test_8955() + { + } + [Fact] + public void Test_8956() + { + } + [Fact] + public void Test_8957() + { + } + [Fact] + public void Test_8958() + { + } + [Fact] + public void Test_8959() + { + } + [Fact] + public void Test_8960() + { + } + [Fact] + public void Test_8961() + { + } + [Fact] + public void Test_8962() + { + } + [Fact] + public void Test_8963() + { + } + [Fact] + public void Test_8964() + { + } + [Fact] + public void Test_8965() + { + } + [Fact] + public void Test_8966() + { + } + [Fact] + public void Test_8967() + { + } + [Fact] + public void Test_8968() + { + } + [Fact] + public void Test_8969() + { + } + [Fact] + public void Test_8970() + { + } + [Fact] + public void Test_8971() + { + } + [Fact] + public void Test_8972() + { + } + [Fact] + public void Test_8973() + { + } + [Fact] + public void Test_8974() + { + } + [Fact] + public void Test_8975() + { + } + [Fact] + public void Test_8976() + { + } + [Fact] + public void Test_8977() + { + } + [Fact] + public void Test_8978() + { + } + [Fact] + public void Test_8979() + { + } + [Fact] + public void Test_8980() + { + } + [Fact] + public void Test_8981() + { + } + [Fact] + public void Test_8982() + { + } + [Fact] + public void Test_8983() + { + } + [Fact] + public void Test_8984() + { + } + [Fact] + public void Test_8985() + { + } + [Fact] + public void Test_8986() + { + } + [Fact] + public void Test_8987() + { + } + [Fact] + public void Test_8988() + { + } + [Fact] + public void Test_8989() + { + } + [Fact] + public void Test_8990() + { + } + [Fact] + public void Test_8991() + { + } + [Fact] + public void Test_8992() + { + } + [Fact] + public void Test_8993() + { + } + [Fact] + public void Test_8994() + { + } + [Fact] + public void Test_8995() + { + } + [Fact] + public void Test_8996() + { + } + [Fact] + public void Test_8997() + { + } + [Fact] + public void Test_8998() + { + } + [Fact] + public void Test_8999() + { + } + [Fact] + public void Test_9000() + { + } + [Fact] + public void Test_9001() + { + } + [Fact] + public void Test_9002() + { + } + [Fact] + public void Test_9003() + { + } + [Fact] + public void Test_9004() + { + } + [Fact] + public void Test_9005() + { + } + [Fact] + public void Test_9006() + { + } + [Fact] + public void Test_9007() + { + } + [Fact] + public void Test_9008() + { + } + [Fact] + public void Test_9009() + { + } + [Fact] + public void Test_9010() + { + } + [Fact] + public void Test_9011() + { + } + [Fact] + public void Test_9012() + { + } + [Fact] + public void Test_9013() + { + } + [Fact] + public void Test_9014() + { + } + [Fact] + public void Test_9015() + { + } + [Fact] + public void Test_9016() + { + } + [Fact] + public void Test_9017() + { + } + [Fact] + public void Test_9018() + { + } + [Fact] + public void Test_9019() + { + } + [Fact] + public void Test_9020() + { + } + [Fact] + public void Test_9021() + { + } + [Fact] + public void Test_9022() + { + } + [Fact] + public void Test_9023() + { + } + [Fact] + public void Test_9024() + { + } + [Fact] + public void Test_9025() + { + } + [Fact] + public void Test_9026() + { + } + [Fact] + public void Test_9027() + { + } + [Fact] + public void Test_9028() + { + } + [Fact] + public void Test_9029() + { + } + [Fact] + public void Test_9030() + { + } + [Fact] + public void Test_9031() + { + } + [Fact] + public void Test_9032() + { + } + [Fact] + public void Test_9033() + { + } + [Fact] + public void Test_9034() + { + } + [Fact] + public void Test_9035() + { + } + [Fact] + public void Test_9036() + { + } + [Fact] + public void Test_9037() + { + } + [Fact] + public void Test_9038() + { + } + [Fact] + public void Test_9039() + { + } + [Fact] + public void Test_9040() + { + } + [Fact] + public void Test_9041() + { + } + [Fact] + public void Test_9042() + { + } + [Fact] + public void Test_9043() + { + } + [Fact] + public void Test_9044() + { + } + [Fact] + public void Test_9045() + { + } + [Fact] + public void Test_9046() + { + } + [Fact] + public void Test_9047() + { + } + [Fact] + public void Test_9048() + { + } + [Fact] + public void Test_9049() + { + } + [Fact] + public void Test_9050() + { + } + [Fact] + public void Test_9051() + { + } + [Fact] + public void Test_9052() + { + } + [Fact] + public void Test_9053() + { + } + [Fact] + public void Test_9054() + { + } + [Fact] + public void Test_9055() + { + } + [Fact] + public void Test_9056() + { + } + [Fact] + public void Test_9057() + { + } + [Fact] + public void Test_9058() + { + } + [Fact] + public void Test_9059() + { + } + [Fact] + public void Test_9060() + { + } + [Fact] + public void Test_9061() + { + } + [Fact] + public void Test_9062() + { + } + [Fact] + public void Test_9063() + { + } + [Fact] + public void Test_9064() + { + } + [Fact] + public void Test_9065() + { + } + [Fact] + public void Test_9066() + { + } + [Fact] + public void Test_9067() + { + } + [Fact] + public void Test_9068() + { + } + [Fact] + public void Test_9069() + { + } + [Fact] + public void Test_9070() + { + } + [Fact] + public void Test_9071() + { + } + [Fact] + public void Test_9072() + { + } + [Fact] + public void Test_9073() + { + } + [Fact] + public void Test_9074() + { + } + [Fact] + public void Test_9075() + { + } + [Fact] + public void Test_9076() + { + } + [Fact] + public void Test_9077() + { + } + [Fact] + public void Test_9078() + { + } + [Fact] + public void Test_9079() + { + } + [Fact] + public void Test_9080() + { + } + [Fact] + public void Test_9081() + { + } + [Fact] + public void Test_9082() + { + } + [Fact] + public void Test_9083() + { + } + [Fact] + public void Test_9084() + { + } + [Fact] + public void Test_9085() + { + } + [Fact] + public void Test_9086() + { + } + [Fact] + public void Test_9087() + { + } + [Fact] + public void Test_9088() + { + } + [Fact] + public void Test_9089() + { + } + [Fact] + public void Test_9090() + { + } + [Fact] + public void Test_9091() + { + } + [Fact] + public void Test_9092() + { + } + [Fact] + public void Test_9093() + { + } + [Fact] + public void Test_9094() + { + } + [Fact] + public void Test_9095() + { + } + [Fact] + public void Test_9096() + { + } + [Fact] + public void Test_9097() + { + } + [Fact] + public void Test_9098() + { + } + [Fact] + public void Test_9099() + { + } + [Fact] + public void Test_9100() + { + } + [Fact] + public void Test_9101() + { + } + [Fact] + public void Test_9102() + { + } + [Fact] + public void Test_9103() + { + } + [Fact] + public void Test_9104() + { + } + [Fact] + public void Test_9105() + { + } + [Fact] + public void Test_9106() + { + } + [Fact] + public void Test_9107() + { + } + [Fact] + public void Test_9108() + { + } + [Fact] + public void Test_9109() + { + } + [Fact] + public void Test_9110() + { + } + [Fact] + public void Test_9111() + { + } + [Fact] + public void Test_9112() + { + } + [Fact] + public void Test_9113() + { + } + [Fact] + public void Test_9114() + { + } + [Fact] + public void Test_9115() + { + } + [Fact] + public void Test_9116() + { + } + [Fact] + public void Test_9117() + { + } + [Fact] + public void Test_9118() + { + } + [Fact] + public void Test_9119() + { + } + [Fact] + public void Test_9120() + { + } + [Fact] + public void Test_9121() + { + } + [Fact] + public void Test_9122() + { + } + [Fact] + public void Test_9123() + { + } + [Fact] + public void Test_9124() + { + } + [Fact] + public void Test_9125() + { + } + [Fact] + public void Test_9126() + { + } + [Fact] + public void Test_9127() + { + } + [Fact] + public void Test_9128() + { + } + [Fact] + public void Test_9129() + { + } + [Fact] + public void Test_9130() + { + } + [Fact] + public void Test_9131() + { + } + [Fact] + public void Test_9132() + { + } + [Fact] + public void Test_9133() + { + } + [Fact] + public void Test_9134() + { + } + [Fact] + public void Test_9135() + { + } + [Fact] + public void Test_9136() + { + } + [Fact] + public void Test_9137() + { + } + [Fact] + public void Test_9138() + { + } + [Fact] + public void Test_9139() + { + } + [Fact] + public void Test_9140() + { + } + [Fact] + public void Test_9141() + { + } + [Fact] + public void Test_9142() + { + } + [Fact] + public void Test_9143() + { + } + [Fact] + public void Test_9144() + { + } + [Fact] + public void Test_9145() + { + } + [Fact] + public void Test_9146() + { + } + [Fact] + public void Test_9147() + { + } + [Fact] + public void Test_9148() + { + } + [Fact] + public void Test_9149() + { + } + [Fact] + public void Test_9150() + { + } + [Fact] + public void Test_9151() + { + } + [Fact] + public void Test_9152() + { + } + [Fact] + public void Test_9153() + { + } + [Fact] + public void Test_9154() + { + } + [Fact] + public void Test_9155() + { + } + [Fact] + public void Test_9156() + { + } + [Fact] + public void Test_9157() + { + } + [Fact] + public void Test_9158() + { + } + [Fact] + public void Test_9159() + { + } + [Fact] + public void Test_9160() + { + } + [Fact] + public void Test_9161() + { + } + [Fact] + public void Test_9162() + { + } + [Fact] + public void Test_9163() + { + } + [Fact] + public void Test_9164() + { + } + [Fact] + public void Test_9165() + { + } + [Fact] + public void Test_9166() + { + } + [Fact] + public void Test_9167() + { + } + [Fact] + public void Test_9168() + { + } + [Fact] + public void Test_9169() + { + } + [Fact] + public void Test_9170() + { + } + [Fact] + public void Test_9171() + { + } + [Fact] + public void Test_9172() + { + } + [Fact] + public void Test_9173() + { + } + [Fact] + public void Test_9174() + { + } + [Fact] + public void Test_9175() + { + } + [Fact] + public void Test_9176() + { + } + [Fact] + public void Test_9177() + { + } + [Fact] + public void Test_9178() + { + } + [Fact] + public void Test_9179() + { + } + [Fact] + public void Test_9180() + { + } + [Fact] + public void Test_9181() + { + } + [Fact] + public void Test_9182() + { + } + [Fact] + public void Test_9183() + { + } + [Fact] + public void Test_9184() + { + } + [Fact] + public void Test_9185() + { + } + [Fact] + public void Test_9186() + { + } + [Fact] + public void Test_9187() + { + } + [Fact] + public void Test_9188() + { + } + [Fact] + public void Test_9189() + { + } + [Fact] + public void Test_9190() + { + } + [Fact] + public void Test_9191() + { + } + [Fact] + public void Test_9192() + { + } + [Fact] + public void Test_9193() + { + } + [Fact] + public void Test_9194() + { + } + [Fact] + public void Test_9195() + { + } + [Fact] + public void Test_9196() + { + } + [Fact] + public void Test_9197() + { + } + [Fact] + public void Test_9198() + { + } + [Fact] + public void Test_9199() + { + } + [Fact] + public void Test_9200() + { + } + [Fact] + public void Test_9201() + { + } + [Fact] + public void Test_9202() + { + } + [Fact] + public void Test_9203() + { + } + [Fact] + public void Test_9204() + { + } + [Fact] + public void Test_9205() + { + } + [Fact] + public void Test_9206() + { + } + [Fact] + public void Test_9207() + { + } + [Fact] + public void Test_9208() + { + } + [Fact] + public void Test_9209() + { + } + [Fact] + public void Test_9210() + { + } + [Fact] + public void Test_9211() + { + } + [Fact] + public void Test_9212() + { + } + [Fact] + public void Test_9213() + { + } + [Fact] + public void Test_9214() + { + } + [Fact] + public void Test_9215() + { + } + [Fact] + public void Test_9216() + { + } + [Fact] + public void Test_9217() + { + } + [Fact] + public void Test_9218() + { + } + [Fact] + public void Test_9219() + { + } + [Fact] + public void Test_9220() + { + } + [Fact] + public void Test_9221() + { + } + [Fact] + public void Test_9222() + { + } + [Fact] + public void Test_9223() + { + } + [Fact] + public void Test_9224() + { + } + [Fact] + public void Test_9225() + { + } + [Fact] + public void Test_9226() + { + } + [Fact] + public void Test_9227() + { + } + [Fact] + public void Test_9228() + { + } + [Fact] + public void Test_9229() + { + } + [Fact] + public void Test_9230() + { + } + [Fact] + public void Test_9231() + { + } + [Fact] + public void Test_9232() + { + } + [Fact] + public void Test_9233() + { + } + [Fact] + public void Test_9234() + { + } + [Fact] + public void Test_9235() + { + } + [Fact] + public void Test_9236() + { + } + [Fact] + public void Test_9237() + { + } + [Fact] + public void Test_9238() + { + } + [Fact] + public void Test_9239() + { + } + [Fact] + public void Test_9240() + { + } + [Fact] + public void Test_9241() + { + } + [Fact] + public void Test_9242() + { + } + [Fact] + public void Test_9243() + { + } + [Fact] + public void Test_9244() + { + } + [Fact] + public void Test_9245() + { + } + [Fact] + public void Test_9246() + { + } + [Fact] + public void Test_9247() + { + } + [Fact] + public void Test_9248() + { + } + [Fact] + public void Test_9249() + { + } + [Fact] + public void Test_9250() + { + } + [Fact] + public void Test_9251() + { + } + [Fact] + public void Test_9252() + { + } + [Fact] + public void Test_9253() + { + } + [Fact] + public void Test_9254() + { + } + [Fact] + public void Test_9255() + { + } + [Fact] + public void Test_9256() + { + } + [Fact] + public void Test_9257() + { + } + [Fact] + public void Test_9258() + { + } + [Fact] + public void Test_9259() + { + } + [Fact] + public void Test_9260() + { + } + [Fact] + public void Test_9261() + { + } + [Fact] + public void Test_9262() + { + } + [Fact] + public void Test_9263() + { + } + [Fact] + public void Test_9264() + { + } + [Fact] + public void Test_9265() + { + } + [Fact] + public void Test_9266() + { + } + [Fact] + public void Test_9267() + { + } + [Fact] + public void Test_9268() + { + } + [Fact] + public void Test_9269() + { + } + [Fact] + public void Test_9270() + { + } + [Fact] + public void Test_9271() + { + } + [Fact] + public void Test_9272() + { + } + [Fact] + public void Test_9273() + { + } + [Fact] + public void Test_9274() + { + } + [Fact] + public void Test_9275() + { + } + [Fact] + public void Test_9276() + { + } + [Fact] + public void Test_9277() + { + } + [Fact] + public void Test_9278() + { + } + [Fact] + public void Test_9279() + { + } + [Fact] + public void Test_9280() + { + } + [Fact] + public void Test_9281() + { + } + [Fact] + public void Test_9282() + { + } + [Fact] + public void Test_9283() + { + } + [Fact] + public void Test_9284() + { + } + [Fact] + public void Test_9285() + { + } + [Fact] + public void Test_9286() + { + } + [Fact] + public void Test_9287() + { + } + [Fact] + public void Test_9288() + { + } + [Fact] + public void Test_9289() + { + } + [Fact] + public void Test_9290() + { + } + [Fact] + public void Test_9291() + { + } + [Fact] + public void Test_9292() + { + } + [Fact] + public void Test_9293() + { + } + [Fact] + public void Test_9294() + { + } + [Fact] + public void Test_9295() + { + } + [Fact] + public void Test_9296() + { + } + [Fact] + public void Test_9297() + { + } + [Fact] + public void Test_9298() + { + } + [Fact] + public void Test_9299() + { + } + [Fact] + public void Test_9300() + { + } + [Fact] + public void Test_9301() + { + } + [Fact] + public void Test_9302() + { + } + [Fact] + public void Test_9303() + { + } + [Fact] + public void Test_9304() + { + } + [Fact] + public void Test_9305() + { + } + [Fact] + public void Test_9306() + { + } + [Fact] + public void Test_9307() + { + } + [Fact] + public void Test_9308() + { + } + [Fact] + public void Test_9309() + { + } + [Fact] + public void Test_9310() + { + } + [Fact] + public void Test_9311() + { + } + [Fact] + public void Test_9312() + { + } + [Fact] + public void Test_9313() + { + } + [Fact] + public void Test_9314() + { + } + [Fact] + public void Test_9315() + { + } + [Fact] + public void Test_9316() + { + } + [Fact] + public void Test_9317() + { + } + [Fact] + public void Test_9318() + { + } + [Fact] + public void Test_9319() + { + } + [Fact] + public void Test_9320() + { + } + [Fact] + public void Test_9321() + { + } + [Fact] + public void Test_9322() + { + } + [Fact] + public void Test_9323() + { + } + [Fact] + public void Test_9324() + { + } + [Fact] + public void Test_9325() + { + } + [Fact] + public void Test_9326() + { + } + [Fact] + public void Test_9327() + { + } + [Fact] + public void Test_9328() + { + } + [Fact] + public void Test_9329() + { + } + [Fact] + public void Test_9330() + { + } + [Fact] + public void Test_9331() + { + } + [Fact] + public void Test_9332() + { + } + [Fact] + public void Test_9333() + { + } + [Fact] + public void Test_9334() + { + } + [Fact] + public void Test_9335() + { + } + [Fact] + public void Test_9336() + { + } + [Fact] + public void Test_9337() + { + } + [Fact] + public void Test_9338() + { + } + [Fact] + public void Test_9339() + { + } + [Fact] + public void Test_9340() + { + } + [Fact] + public void Test_9341() + { + } + [Fact] + public void Test_9342() + { + } + [Fact] + public void Test_9343() + { + } + [Fact] + public void Test_9344() + { + } + [Fact] + public void Test_9345() + { + } + [Fact] + public void Test_9346() + { + } + [Fact] + public void Test_9347() + { + } + [Fact] + public void Test_9348() + { + } + [Fact] + public void Test_9349() + { + } + [Fact] + public void Test_9350() + { + } + [Fact] + public void Test_9351() + { + } + [Fact] + public void Test_9352() + { + } + [Fact] + public void Test_9353() + { + } + [Fact] + public void Test_9354() + { + } + [Fact] + public void Test_9355() + { + } + [Fact] + public void Test_9356() + { + } + [Fact] + public void Test_9357() + { + } + [Fact] + public void Test_9358() + { + } + [Fact] + public void Test_9359() + { + } + [Fact] + public void Test_9360() + { + } + [Fact] + public void Test_9361() + { + } + [Fact] + public void Test_9362() + { + } + [Fact] + public void Test_9363() + { + } + [Fact] + public void Test_9364() + { + } + [Fact] + public void Test_9365() + { + } + [Fact] + public void Test_9366() + { + } + [Fact] + public void Test_9367() + { + } + [Fact] + public void Test_9368() + { + } + [Fact] + public void Test_9369() + { + } + [Fact] + public void Test_9370() + { + } + [Fact] + public void Test_9371() + { + } + [Fact] + public void Test_9372() + { + } + [Fact] + public void Test_9373() + { + } + [Fact] + public void Test_9374() + { + } + [Fact] + public void Test_9375() + { + } + [Fact] + public void Test_9376() + { + } + [Fact] + public void Test_9377() + { + } + [Fact] + public void Test_9378() + { + } + [Fact] + public void Test_9379() + { + } + [Fact] + public void Test_9380() + { + } + [Fact] + public void Test_9381() + { + } + [Fact] + public void Test_9382() + { + } + [Fact] + public void Test_9383() + { + } + [Fact] + public void Test_9384() + { + } + [Fact] + public void Test_9385() + { + } + [Fact] + public void Test_9386() + { + } + [Fact] + public void Test_9387() + { + } + [Fact] + public void Test_9388() + { + } + [Fact] + public void Test_9389() + { + } + [Fact] + public void Test_9390() + { + } + [Fact] + public void Test_9391() + { + } + [Fact] + public void Test_9392() + { + } + [Fact] + public void Test_9393() + { + } + [Fact] + public void Test_9394() + { + } + [Fact] + public void Test_9395() + { + } + [Fact] + public void Test_9396() + { + } + [Fact] + public void Test_9397() + { + } + [Fact] + public void Test_9398() + { + } + [Fact] + public void Test_9399() + { + } + [Fact] + public void Test_9400() + { + } + [Fact] + public void Test_9401() + { + } + [Fact] + public void Test_9402() + { + } + [Fact] + public void Test_9403() + { + } + [Fact] + public void Test_9404() + { + } + [Fact] + public void Test_9405() + { + } + [Fact] + public void Test_9406() + { + } + [Fact] + public void Test_9407() + { + } + [Fact] + public void Test_9408() + { + } + [Fact] + public void Test_9409() + { + } + [Fact] + public void Test_9410() + { + } + [Fact] + public void Test_9411() + { + } + [Fact] + public void Test_9412() + { + } + [Fact] + public void Test_9413() + { + } + [Fact] + public void Test_9414() + { + } + [Fact] + public void Test_9415() + { + } + [Fact] + public void Test_9416() + { + } + [Fact] + public void Test_9417() + { + } + [Fact] + public void Test_9418() + { + } + [Fact] + public void Test_9419() + { + } + [Fact] + public void Test_9420() + { + } + [Fact] + public void Test_9421() + { + } + [Fact] + public void Test_9422() + { + } + [Fact] + public void Test_9423() + { + } + [Fact] + public void Test_9424() + { + } + [Fact] + public void Test_9425() + { + } + [Fact] + public void Test_9426() + { + } + [Fact] + public void Test_9427() + { + } + [Fact] + public void Test_9428() + { + } + [Fact] + public void Test_9429() + { + } + [Fact] + public void Test_9430() + { + } + [Fact] + public void Test_9431() + { + } + [Fact] + public void Test_9432() + { + } + [Fact] + public void Test_9433() + { + } + [Fact] + public void Test_9434() + { + } + [Fact] + public void Test_9435() + { + } + [Fact] + public void Test_9436() + { + } + [Fact] + public void Test_9437() + { + } + [Fact] + public void Test_9438() + { + } + [Fact] + public void Test_9439() + { + } + [Fact] + public void Test_9440() + { + } + [Fact] + public void Test_9441() + { + } + [Fact] + public void Test_9442() + { + } + [Fact] + public void Test_9443() + { + } + [Fact] + public void Test_9444() + { + } + [Fact] + public void Test_9445() + { + } + [Fact] + public void Test_9446() + { + } + [Fact] + public void Test_9447() + { + } + [Fact] + public void Test_9448() + { + } + [Fact] + public void Test_9449() + { + } + [Fact] + public void Test_9450() + { + } + [Fact] + public void Test_9451() + { + } + [Fact] + public void Test_9452() + { + } + [Fact] + public void Test_9453() + { + } + [Fact] + public void Test_9454() + { + } + [Fact] + public void Test_9455() + { + } + [Fact] + public void Test_9456() + { + } + [Fact] + public void Test_9457() + { + } + [Fact] + public void Test_9458() + { + } + [Fact] + public void Test_9459() + { + } + [Fact] + public void Test_9460() + { + } + [Fact] + public void Test_9461() + { + } + [Fact] + public void Test_9462() + { + } + [Fact] + public void Test_9463() + { + } + [Fact] + public void Test_9464() + { + } + [Fact] + public void Test_9465() + { + } + [Fact] + public void Test_9466() + { + } + [Fact] + public void Test_9467() + { + } + [Fact] + public void Test_9468() + { + } + [Fact] + public void Test_9469() + { + } + [Fact] + public void Test_9470() + { + } + [Fact] + public void Test_9471() + { + } + [Fact] + public void Test_9472() + { + } + [Fact] + public void Test_9473() + { + } + [Fact] + public void Test_9474() + { + } + [Fact] + public void Test_9475() + { + } + [Fact] + public void Test_9476() + { + } + [Fact] + public void Test_9477() + { + } + [Fact] + public void Test_9478() + { + } + [Fact] + public void Test_9479() + { + } + [Fact] + public void Test_9480() + { + } + [Fact] + public void Test_9481() + { + } + [Fact] + public void Test_9482() + { + } + [Fact] + public void Test_9483() + { + } + [Fact] + public void Test_9484() + { + } + [Fact] + public void Test_9485() + { + } + [Fact] + public void Test_9486() + { + } + [Fact] + public void Test_9487() + { + } + [Fact] + public void Test_9488() + { + } + [Fact] + public void Test_9489() + { + } + [Fact] + public void Test_9490() + { + } + [Fact] + public void Test_9491() + { + } + [Fact] + public void Test_9492() + { + } + [Fact] + public void Test_9493() + { + } + [Fact] + public void Test_9494() + { + } + [Fact] + public void Test_9495() + { + } + [Fact] + public void Test_9496() + { + } + [Fact] + public void Test_9497() + { + } + [Fact] + public void Test_9498() + { + } + [Fact] + public void Test_9499() + { + } + [Fact] + public void Test_9500() + { + } + [Fact] + public void Test_9501() + { + } + [Fact] + public void Test_9502() + { + } + [Fact] + public void Test_9503() + { + } + [Fact] + public void Test_9504() + { + } + [Fact] + public void Test_9505() + { + } + [Fact] + public void Test_9506() + { + } + [Fact] + public void Test_9507() + { + } + [Fact] + public void Test_9508() + { + } + [Fact] + public void Test_9509() + { + } + [Fact] + public void Test_9510() + { + } + [Fact] + public void Test_9511() + { + } + [Fact] + public void Test_9512() + { + } + [Fact] + public void Test_9513() + { + } + [Fact] + public void Test_9514() + { + } + [Fact] + public void Test_9515() + { + } + [Fact] + public void Test_9516() + { + } + [Fact] + public void Test_9517() + { + } + [Fact] + public void Test_9518() + { + } + [Fact] + public void Test_9519() + { + } + [Fact] + public void Test_9520() + { + } + [Fact] + public void Test_9521() + { + } + [Fact] + public void Test_9522() + { + } + [Fact] + public void Test_9523() + { + } + [Fact] + public void Test_9524() + { + } + [Fact] + public void Test_9525() + { + } + [Fact] + public void Test_9526() + { + } + [Fact] + public void Test_9527() + { + } + [Fact] + public void Test_9528() + { + } + [Fact] + public void Test_9529() + { + } + [Fact] + public void Test_9530() + { + } + [Fact] + public void Test_9531() + { + } + [Fact] + public void Test_9532() + { + } + [Fact] + public void Test_9533() + { + } + [Fact] + public void Test_9534() + { + } + [Fact] + public void Test_9535() + { + } + [Fact] + public void Test_9536() + { + } + [Fact] + public void Test_9537() + { + } + [Fact] + public void Test_9538() + { + } + [Fact] + public void Test_9539() + { + } + [Fact] + public void Test_9540() + { + } + [Fact] + public void Test_9541() + { + } + [Fact] + public void Test_9542() + { + } + [Fact] + public void Test_9543() + { + } + [Fact] + public void Test_9544() + { + } + [Fact] + public void Test_9545() + { + } + [Fact] + public void Test_9546() + { + } + [Fact] + public void Test_9547() + { + } + [Fact] + public void Test_9548() + { + } + [Fact] + public void Test_9549() + { + } + [Fact] + public void Test_9550() + { + } + [Fact] + public void Test_9551() + { + } + [Fact] + public void Test_9552() + { + } + [Fact] + public void Test_9553() + { + } + [Fact] + public void Test_9554() + { + } + [Fact] + public void Test_9555() + { + } + [Fact] + public void Test_9556() + { + } + [Fact] + public void Test_9557() + { + } + [Fact] + public void Test_9558() + { + } + [Fact] + public void Test_9559() + { + } + [Fact] + public void Test_9560() + { + } + [Fact] + public void Test_9561() + { + } + [Fact] + public void Test_9562() + { + } + [Fact] + public void Test_9563() + { + } + [Fact] + public void Test_9564() + { + } + [Fact] + public void Test_9565() + { + } + [Fact] + public void Test_9566() + { + } + [Fact] + public void Test_9567() + { + } + [Fact] + public void Test_9568() + { + } + [Fact] + public void Test_9569() + { + } + [Fact] + public void Test_9570() + { + } + [Fact] + public void Test_9571() + { + } + [Fact] + public void Test_9572() + { + } + [Fact] + public void Test_9573() + { + } + [Fact] + public void Test_9574() + { + } + [Fact] + public void Test_9575() + { + } + [Fact] + public void Test_9576() + { + } + [Fact] + public void Test_9577() + { + } + [Fact] + public void Test_9578() + { + } + [Fact] + public void Test_9579() + { + } + [Fact] + public void Test_9580() + { + } + [Fact] + public void Test_9581() + { + } + [Fact] + public void Test_9582() + { + } + [Fact] + public void Test_9583() + { + } + [Fact] + public void Test_9584() + { + } + [Fact] + public void Test_9585() + { + } + [Fact] + public void Test_9586() + { + } + [Fact] + public void Test_9587() + { + } + [Fact] + public void Test_9588() + { + } + [Fact] + public void Test_9589() + { + } + [Fact] + public void Test_9590() + { + } + [Fact] + public void Test_9591() + { + } + [Fact] + public void Test_9592() + { + } + [Fact] + public void Test_9593() + { + } + [Fact] + public void Test_9594() + { + } + [Fact] + public void Test_9595() + { + } + [Fact] + public void Test_9596() + { + } + [Fact] + public void Test_9597() + { + } + [Fact] + public void Test_9598() + { + } + [Fact] + public void Test_9599() + { + } + [Fact] + public void Test_9600() + { + } + [Fact] + public void Test_9601() + { + } + [Fact] + public void Test_9602() + { + } + [Fact] + public void Test_9603() + { + } + [Fact] + public void Test_9604() + { + } + [Fact] + public void Test_9605() + { + } + [Fact] + public void Test_9606() + { + } + [Fact] + public void Test_9607() + { + } + [Fact] + public void Test_9608() + { + } + [Fact] + public void Test_9609() + { + } + [Fact] + public void Test_9610() + { + } + [Fact] + public void Test_9611() + { + } + [Fact] + public void Test_9612() + { + } + [Fact] + public void Test_9613() + { + } + [Fact] + public void Test_9614() + { + } + [Fact] + public void Test_9615() + { + } + [Fact] + public void Test_9616() + { + } + [Fact] + public void Test_9617() + { + } + [Fact] + public void Test_9618() + { + } + [Fact] + public void Test_9619() + { + } + [Fact] + public void Test_9620() + { + } + [Fact] + public void Test_9621() + { + } + [Fact] + public void Test_9622() + { + } + [Fact] + public void Test_9623() + { + } + [Fact] + public void Test_9624() + { + } + [Fact] + public void Test_9625() + { + } + [Fact] + public void Test_9626() + { + } + [Fact] + public void Test_9627() + { + } + [Fact] + public void Test_9628() + { + } + [Fact] + public void Test_9629() + { + } + [Fact] + public void Test_9630() + { + } + [Fact] + public void Test_9631() + { + } + [Fact] + public void Test_9632() + { + } + [Fact] + public void Test_9633() + { + } + [Fact] + public void Test_9634() + { + } + [Fact] + public void Test_9635() + { + } + [Fact] + public void Test_9636() + { + } + [Fact] + public void Test_9637() + { + } + [Fact] + public void Test_9638() + { + } + [Fact] + public void Test_9639() + { + } + [Fact] + public void Test_9640() + { + } + [Fact] + public void Test_9641() + { + } + [Fact] + public void Test_9642() + { + } + [Fact] + public void Test_9643() + { + } + [Fact] + public void Test_9644() + { + } + [Fact] + public void Test_9645() + { + } + [Fact] + public void Test_9646() + { + } + [Fact] + public void Test_9647() + { + } + [Fact] + public void Test_9648() + { + } + [Fact] + public void Test_9649() + { + } + [Fact] + public void Test_9650() + { + } + [Fact] + public void Test_9651() + { + } + [Fact] + public void Test_9652() + { + } + [Fact] + public void Test_9653() + { + } + [Fact] + public void Test_9654() + { + } + [Fact] + public void Test_9655() + { + } + [Fact] + public void Test_9656() + { + } + [Fact] + public void Test_9657() + { + } + [Fact] + public void Test_9658() + { + } + [Fact] + public void Test_9659() + { + } + [Fact] + public void Test_9660() + { + } + [Fact] + public void Test_9661() + { + } + [Fact] + public void Test_9662() + { + } + [Fact] + public void Test_9663() + { + } + [Fact] + public void Test_9664() + { + } + [Fact] + public void Test_9665() + { + } + [Fact] + public void Test_9666() + { + } + [Fact] + public void Test_9667() + { + } + [Fact] + public void Test_9668() + { + } + [Fact] + public void Test_9669() + { + } + [Fact] + public void Test_9670() + { + } + [Fact] + public void Test_9671() + { + } + [Fact] + public void Test_9672() + { + } + [Fact] + public void Test_9673() + { + } + [Fact] + public void Test_9674() + { + } + [Fact] + public void Test_9675() + { + } + [Fact] + public void Test_9676() + { + } + [Fact] + public void Test_9677() + { + } + [Fact] + public void Test_9678() + { + } + [Fact] + public void Test_9679() + { + } + [Fact] + public void Test_9680() + { + } + [Fact] + public void Test_9681() + { + } + [Fact] + public void Test_9682() + { + } + [Fact] + public void Test_9683() + { + } + [Fact] + public void Test_9684() + { + } + [Fact] + public void Test_9685() + { + } + [Fact] + public void Test_9686() + { + } + [Fact] + public void Test_9687() + { + } + [Fact] + public void Test_9688() + { + } + [Fact] + public void Test_9689() + { + } + [Fact] + public void Test_9690() + { + } + [Fact] + public void Test_9691() + { + } + [Fact] + public void Test_9692() + { + } + [Fact] + public void Test_9693() + { + } + [Fact] + public void Test_9694() + { + } + [Fact] + public void Test_9695() + { + } + [Fact] + public void Test_9696() + { + } + [Fact] + public void Test_9697() + { + } + [Fact] + public void Test_9698() + { + } + [Fact] + public void Test_9699() + { + } + [Fact] + public void Test_9700() + { + } + [Fact] + public void Test_9701() + { + } + [Fact] + public void Test_9702() + { + } + [Fact] + public void Test_9703() + { + } + [Fact] + public void Test_9704() + { + } + [Fact] + public void Test_9705() + { + } + [Fact] + public void Test_9706() + { + } + [Fact] + public void Test_9707() + { + } + [Fact] + public void Test_9708() + { + } + [Fact] + public void Test_9709() + { + } + [Fact] + public void Test_9710() + { + } + [Fact] + public void Test_9711() + { + } + [Fact] + public void Test_9712() + { + } + [Fact] + public void Test_9713() + { + } + [Fact] + public void Test_9714() + { + } + [Fact] + public void Test_9715() + { + } + [Fact] + public void Test_9716() + { + } + [Fact] + public void Test_9717() + { + } + [Fact] + public void Test_9718() + { + } + [Fact] + public void Test_9719() + { + } + [Fact] + public void Test_9720() + { + } + [Fact] + public void Test_9721() + { + } + [Fact] + public void Test_9722() + { + } + [Fact] + public void Test_9723() + { + } + [Fact] + public void Test_9724() + { + } + [Fact] + public void Test_9725() + { + } + [Fact] + public void Test_9726() + { + } + [Fact] + public void Test_9727() + { + } + [Fact] + public void Test_9728() + { + } + [Fact] + public void Test_9729() + { + } + [Fact] + public void Test_9730() + { + } + [Fact] + public void Test_9731() + { + } + [Fact] + public void Test_9732() + { + } + [Fact] + public void Test_9733() + { + } + [Fact] + public void Test_9734() + { + } + [Fact] + public void Test_9735() + { + } + [Fact] + public void Test_9736() + { + } + [Fact] + public void Test_9737() + { + } + [Fact] + public void Test_9738() + { + } + [Fact] + public void Test_9739() + { + } + [Fact] + public void Test_9740() + { + } + [Fact] + public void Test_9741() + { + } + [Fact] + public void Test_9742() + { + } + [Fact] + public void Test_9743() + { + } + [Fact] + public void Test_9744() + { + } + [Fact] + public void Test_9745() + { + } + [Fact] + public void Test_9746() + { + } + [Fact] + public void Test_9747() + { + } + [Fact] + public void Test_9748() + { + } + [Fact] + public void Test_9749() + { + } + [Fact] + public void Test_9750() + { + } + [Fact] + public void Test_9751() + { + } + [Fact] + public void Test_9752() + { + } + [Fact] + public void Test_9753() + { + } + [Fact] + public void Test_9754() + { + } + [Fact] + public void Test_9755() + { + } + [Fact] + public void Test_9756() + { + } + [Fact] + public void Test_9757() + { + } + [Fact] + public void Test_9758() + { + } + [Fact] + public void Test_9759() + { + } + [Fact] + public void Test_9760() + { + } + [Fact] + public void Test_9761() + { + } + [Fact] + public void Test_9762() + { + } + [Fact] + public void Test_9763() + { + } + [Fact] + public void Test_9764() + { + } + [Fact] + public void Test_9765() + { + } + [Fact] + public void Test_9766() + { + } + [Fact] + public void Test_9767() + { + } + [Fact] + public void Test_9768() + { + } + [Fact] + public void Test_9769() + { + } + [Fact] + public void Test_9770() + { + } + [Fact] + public void Test_9771() + { + } + [Fact] + public void Test_9772() + { + } + [Fact] + public void Test_9773() + { + } + [Fact] + public void Test_9774() + { + } + [Fact] + public void Test_9775() + { + } + [Fact] + public void Test_9776() + { + } + [Fact] + public void Test_9777() + { + } + [Fact] + public void Test_9778() + { + } + [Fact] + public void Test_9779() + { + } + [Fact] + public void Test_9780() + { + } + [Fact] + public void Test_9781() + { + } + [Fact] + public void Test_9782() + { + } + [Fact] + public void Test_9783() + { + } + [Fact] + public void Test_9784() + { + } + [Fact] + public void Test_9785() + { + } + [Fact] + public void Test_9786() + { + } + [Fact] + public void Test_9787() + { + } + [Fact] + public void Test_9788() + { + } + [Fact] + public void Test_9789() + { + } + [Fact] + public void Test_9790() + { + } + [Fact] + public void Test_9791() + { + } + [Fact] + public void Test_9792() + { + } + [Fact] + public void Test_9793() + { + } + [Fact] + public void Test_9794() + { + } + [Fact] + public void Test_9795() + { + } + [Fact] + public void Test_9796() + { + } + [Fact] + public void Test_9797() + { + } + [Fact] + public void Test_9798() + { + } + [Fact] + public void Test_9799() + { + } + [Fact] + public void Test_9800() + { + } + [Fact] + public void Test_9801() + { + } + [Fact] + public void Test_9802() + { + } + [Fact] + public void Test_9803() + { + } + [Fact] + public void Test_9804() + { + } + [Fact] + public void Test_9805() + { + } + [Fact] + public void Test_9806() + { + } + [Fact] + public void Test_9807() + { + } + [Fact] + public void Test_9808() + { + } + [Fact] + public void Test_9809() + { + } + [Fact] + public void Test_9810() + { + } + [Fact] + public void Test_9811() + { + } + [Fact] + public void Test_9812() + { + } + [Fact] + public void Test_9813() + { + } + [Fact] + public void Test_9814() + { + } + [Fact] + public void Test_9815() + { + } + [Fact] + public void Test_9816() + { + } + [Fact] + public void Test_9817() + { + } + [Fact] + public void Test_9818() + { + } + [Fact] + public void Test_9819() + { + } + [Fact] + public void Test_9820() + { + } + [Fact] + public void Test_9821() + { + } + [Fact] + public void Test_9822() + { + } + [Fact] + public void Test_9823() + { + } + [Fact] + public void Test_9824() + { + } + [Fact] + public void Test_9825() + { + } + [Fact] + public void Test_9826() + { + } + [Fact] + public void Test_9827() + { + } + [Fact] + public void Test_9828() + { + } + [Fact] + public void Test_9829() + { + } + [Fact] + public void Test_9830() + { + } + [Fact] + public void Test_9831() + { + } + [Fact] + public void Test_9832() + { + } + [Fact] + public void Test_9833() + { + } + [Fact] + public void Test_9834() + { + } + [Fact] + public void Test_9835() + { + } + [Fact] + public void Test_9836() + { + } + [Fact] + public void Test_9837() + { + } + [Fact] + public void Test_9838() + { + } + [Fact] + public void Test_9839() + { + } + [Fact] + public void Test_9840() + { + } + [Fact] + public void Test_9841() + { + } + [Fact] + public void Test_9842() + { + } + [Fact] + public void Test_9843() + { + } + [Fact] + public void Test_9844() + { + } + [Fact] + public void Test_9845() + { + } + [Fact] + public void Test_9846() + { + } + [Fact] + public void Test_9847() + { + } + [Fact] + public void Test_9848() + { + } + [Fact] + public void Test_9849() + { + } + [Fact] + public void Test_9850() + { + } + [Fact] + public void Test_9851() + { + } + [Fact] + public void Test_9852() + { + } + [Fact] + public void Test_9853() + { + } + [Fact] + public void Test_9854() + { + } + [Fact] + public void Test_9855() + { + } + [Fact] + public void Test_9856() + { + } + [Fact] + public void Test_9857() + { + } + [Fact] + public void Test_9858() + { + } + [Fact] + public void Test_9859() + { + } + [Fact] + public void Test_9860() + { + } + [Fact] + public void Test_9861() + { + } + [Fact] + public void Test_9862() + { + } + [Fact] + public void Test_9863() + { + } + [Fact] + public void Test_9864() + { + } + [Fact] + public void Test_9865() + { + } + [Fact] + public void Test_9866() + { + } + [Fact] + public void Test_9867() + { + } + [Fact] + public void Test_9868() + { + } + [Fact] + public void Test_9869() + { + } + [Fact] + public void Test_9870() + { + } + [Fact] + public void Test_9871() + { + } + [Fact] + public void Test_9872() + { + } + [Fact] + public void Test_9873() + { + } + [Fact] + public void Test_9874() + { + } + [Fact] + public void Test_9875() + { + } + [Fact] + public void Test_9876() + { + } + [Fact] + public void Test_9877() + { + } + [Fact] + public void Test_9878() + { + } + [Fact] + public void Test_9879() + { + } + [Fact] + public void Test_9880() + { + } + [Fact] + public void Test_9881() + { + } + [Fact] + public void Test_9882() + { + } + [Fact] + public void Test_9883() + { + } + [Fact] + public void Test_9884() + { + } + [Fact] + public void Test_9885() + { + } + [Fact] + public void Test_9886() + { + } + [Fact] + public void Test_9887() + { + } + [Fact] + public void Test_9888() + { + } + [Fact] + public void Test_9889() + { + } + [Fact] + public void Test_9890() + { + } + [Fact] + public void Test_9891() + { + } + [Fact] + public void Test_9892() + { + } + [Fact] + public void Test_9893() + { + } + [Fact] + public void Test_9894() + { + } + [Fact] + public void Test_9895() + { + } + [Fact] + public void Test_9896() + { + } + [Fact] + public void Test_9897() + { + } + [Fact] + public void Test_9898() + { + } + [Fact] + public void Test_9899() + { + } + [Fact] + public void Test_9900() + { + } + [Fact] + public void Test_9901() + { + } + [Fact] + public void Test_9902() + { + } + [Fact] + public void Test_9903() + { + } + [Fact] + public void Test_9904() + { + } + [Fact] + public void Test_9905() + { + } + [Fact] + public void Test_9906() + { + } + [Fact] + public void Test_9907() + { + } + [Fact] + public void Test_9908() + { + } + [Fact] + public void Test_9909() + { + } + [Fact] + public void Test_9910() + { + } + [Fact] + public void Test_9911() + { + } + [Fact] + public void Test_9912() + { + } + [Fact] + public void Test_9913() + { + } + [Fact] + public void Test_9914() + { + } + [Fact] + public void Test_9915() + { + } + [Fact] + public void Test_9916() + { + } + [Fact] + public void Test_9917() + { + } + [Fact] + public void Test_9918() + { + } + [Fact] + public void Test_9919() + { + } + [Fact] + public void Test_9920() + { + } + [Fact] + public void Test_9921() + { + } + [Fact] + public void Test_9922() + { + } + [Fact] + public void Test_9923() + { + } + [Fact] + public void Test_9924() + { + } + [Fact] + public void Test_9925() + { + } + [Fact] + public void Test_9926() + { + } + [Fact] + public void Test_9927() + { + } + [Fact] + public void Test_9928() + { + } + [Fact] + public void Test_9929() + { + } + [Fact] + public void Test_9930() + { + } + [Fact] + public void Test_9931() + { + } + [Fact] + public void Test_9932() + { + } + [Fact] + public void Test_9933() + { + } + [Fact] + public void Test_9934() + { + } + [Fact] + public void Test_9935() + { + } + [Fact] + public void Test_9936() + { + } + [Fact] + public void Test_9937() + { + } + [Fact] + public void Test_9938() + { + } + [Fact] + public void Test_9939() + { + } + [Fact] + public void Test_9940() + { + } + [Fact] + public void Test_9941() + { + } + [Fact] + public void Test_9942() + { + } + [Fact] + public void Test_9943() + { + } + [Fact] + public void Test_9944() + { + } + [Fact] + public void Test_9945() + { + } + [Fact] + public void Test_9946() + { + } + [Fact] + public void Test_9947() + { + } + [Fact] + public void Test_9948() + { + } + [Fact] + public void Test_9949() + { + } + [Fact] + public void Test_9950() + { + } + [Fact] + public void Test_9951() + { + } + [Fact] + public void Test_9952() + { + } + [Fact] + public void Test_9953() + { + } + [Fact] + public void Test_9954() + { + } + [Fact] + public void Test_9955() + { + } + [Fact] + public void Test_9956() + { + } + [Fact] + public void Test_9957() + { + } + [Fact] + public void Test_9958() + { + } + [Fact] + public void Test_9959() + { + } + [Fact] + public void Test_9960() + { + } + [Fact] + public void Test_9961() + { + } + [Fact] + public void Test_9962() + { + } + [Fact] + public void Test_9963() + { + } + [Fact] + public void Test_9964() + { + } + [Fact] + public void Test_9965() + { + } + [Fact] + public void Test_9966() + { + } + [Fact] + public void Test_9967() + { + } + [Fact] + public void Test_9968() + { + } + [Fact] + public void Test_9969() + { + } + [Fact] + public void Test_9970() + { + } + [Fact] + public void Test_9971() + { + } + [Fact] + public void Test_9972() + { + } + [Fact] + public void Test_9973() + { + } + [Fact] + public void Test_9974() + { + } + [Fact] + public void Test_9975() + { + } + [Fact] + public void Test_9976() + { + } + [Fact] + public void Test_9977() + { + } + [Fact] + public void Test_9978() + { + } + [Fact] + public void Test_9979() + { + } + [Fact] + public void Test_9980() + { + } + [Fact] + public void Test_9981() + { + } + [Fact] + public void Test_9982() + { + } + [Fact] + public void Test_9983() + { + } + [Fact] + public void Test_9984() + { + } + [Fact] + public void Test_9985() + { + } + [Fact] + public void Test_9986() + { + } + [Fact] + public void Test_9987() + { + } + [Fact] + public void Test_9988() + { + } + [Fact] + public void Test_9989() + { + } + [Fact] + public void Test_9990() + { + } + [Fact] + public void Test_9991() + { + } + [Fact] + public void Test_9992() + { + } + [Fact] + public void Test_9993() + { + } + [Fact] + public void Test_9994() + { + } + [Fact] + public void Test_9995() + { + } + [Fact] + public void Test_9996() + { + } + [Fact] + public void Test_9997() + { + } + [Fact] + public void Test_9998() + { + } + [Fact] + public void Test_9999() + { + } + [Fact] + public void Test_10000() + { + } + #endregion + + #region FailingTests + #endregion - #region FailingTests - #endregion - } } diff --git a/test/TestAssets/PerfTestProject/Program.cs b/test/TestAssets/PerfTestProject/Program.cs index 3ee39b8af8..e3f41f1d63 100644 --- a/test/TestAssets/PerfTestProject/Program.cs +++ b/test/TestAssets/PerfTestProject/Program.cs @@ -1,13 +1,12 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace PerfTestProject +namespace PerfTestProject; + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } diff --git a/test/TestAssets/ProjectFileRunSettingsTestProject/UnitTest1.cs b/test/TestAssets/ProjectFileRunSettingsTestProject/UnitTest1.cs index 0ec4b790f2..ee1491d65d 100644 --- a/test/TestAssets/ProjectFileRunSettingsTestProject/UnitTest1.cs +++ b/test/TestAssets/ProjectFileRunSettingsTestProject/UnitTest1.cs @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + using Microsoft.VisualStudio.TestTools.UnitTesting; namespace ProjectFileRunSettingsTestProject diff --git a/test/TestAssets/SampleProjectWithOldTestHost/UnitTest1.cs b/test/TestAssets/SampleProjectWithOldTestHost/UnitTest1.cs index 4df22575dc..873d2d5853 100644 --- a/test/TestAssets/SampleProjectWithOldTestHost/UnitTest1.cs +++ b/test/TestAssets/SampleProjectWithOldTestHost/UnitTest1.cs @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + using Microsoft.VisualStudio.TestTools.UnitTesting; namespace SampleProjectWithOldTestHost diff --git a/test/TestAssets/SelfContainedAppTestProject/UnitTest1.cs b/test/TestAssets/SelfContainedAppTestProject/UnitTest1.cs index 6b5e36fa0b..418fed62d3 100644 --- a/test/TestAssets/SelfContainedAppTestProject/UnitTest1.cs +++ b/test/TestAssets/SelfContainedAppTestProject/UnitTest1.cs @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + using Microsoft.VisualStudio.TestTools.UnitTesting; namespace SelfContainedAppTestProject diff --git a/test/TestAssets/SimpleClassLibrary/Class1.cs b/test/TestAssets/SimpleClassLibrary/Class1.cs index b84cb4118f..8549cd302b 100644 --- a/test/TestAssets/SimpleClassLibrary/Class1.cs +++ b/test/TestAssets/SimpleClassLibrary/Class1.cs @@ -3,7 +3,6 @@ namespace SimpleClassLibrary { - using System.Diagnostics; using System.Threading.Tasks; public class Class1 diff --git a/test/TestAssets/SimpleDataCollector/Class1.cs b/test/TestAssets/SimpleDataCollector/Class1.cs index a31019508a..b6a88e8a8f 100644 --- a/test/TestAssets/SimpleDataCollector/Class1.cs +++ b/test/TestAssets/SimpleDataCollector/Class1.cs @@ -5,6 +5,7 @@ namespace SimpleDataCollector { using System; using System.IO; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; using Microsoft.VisualStudio.TestPlatform.ObjectModel.InProcDataCollector; @@ -14,19 +15,19 @@ namespace SimpleDataCollector /// public class SimpleDataCollector : InProcDataCollection { - private readonly string fileName; + private readonly string _fileName; /// /// Initializes a new instance of the class. /// public SimpleDataCollector() { - this.fileName = Path.Combine(Path.GetTempPath(), "inproctest.txt"); + _fileName = Path.Combine(Path.GetTempPath(), "inproctest.txt"); } public void Initialize(IDataCollectionSink dataCollectionSink) { - // Do Nothing + // Do Nothing } /// @@ -38,10 +39,10 @@ public void Initialize(IDataCollectionSink dataCollectionSink) public void TestSessionStart(TestSessionStartArgs testSessionStartArgs) { Console.WriteLine(testSessionStartArgs.Configuration); - File.WriteAllText(this.fileName, "TestSessionStart : " + testSessionStartArgs.Configuration + "\r\n"); + File.WriteAllText(_fileName, "TestSessionStart : " + testSessionStartArgs.Configuration + "\r\n"); #if NETFRAMEWORK var appDomainFilePath = Environment.GetEnvironmentVariable("TEST_ASSET_APPDOMAIN_COLLECTOR_PATH") ?? Path.Combine(Path.GetTempPath(), "appdomain_datacollector.txt"); - File.WriteAllText(appDomainFilePath, "AppDomain FriendlyName: "+ AppDomain.CurrentDomain.FriendlyName); + File.WriteAllText(appDomainFilePath, "AppDomain FriendlyName: " + AppDomain.CurrentDomain.FriendlyName); #endif } @@ -57,7 +58,7 @@ public void TestCaseStart(TestCaseStartArgs testCaseStartArgs) "TestCase Name : {0}, TestCase ID:{1}", testCaseStartArgs.TestCase.DisplayName, testCaseStartArgs.TestCase.Id); - File.AppendAllText(this.fileName, "TestCaseStart : " + testCaseStartArgs.TestCase.DisplayName + "\r\n"); + File.AppendAllText(_fileName, "TestCaseStart : " + testCaseStartArgs.TestCase.DisplayName + "\r\n"); } /// @@ -69,7 +70,7 @@ public void TestCaseStart(TestCaseStartArgs testCaseStartArgs) public void TestCaseEnd(TestCaseEndArgs testCaseEndArgs) { Console.WriteLine("TestCase Name:{0}, TestCase ID:{1}, OutCome:{2}", testCaseEndArgs.DataCollectionContext.TestCase.DisplayName, testCaseEndArgs.DataCollectionContext.TestCase.Id, testCaseEndArgs.TestOutcome); - File.AppendAllText(this.fileName, "TestCaseEnd : " + testCaseEndArgs.DataCollectionContext.TestCase.DisplayName + "\r\n"); + File.AppendAllText(_fileName, "TestCaseEnd : " + testCaseEndArgs.DataCollectionContext.TestCase.DisplayName + "\r\n"); } /// @@ -81,7 +82,7 @@ public void TestCaseEnd(TestCaseEndArgs testCaseEndArgs) public void TestSessionEnd(TestSessionEndArgs testSessionEndArgs) { Console.WriteLine("TestSession Ended"); - File.AppendAllText(this.fileName, "TestSessionEnd"); + File.AppendAllText(_fileName, "TestSessionEnd"); } } } diff --git a/test/TestAssets/SimpleTestProject2/UnitTest1.cs b/test/TestAssets/SimpleTestProject2/UnitTest1.cs index b97b671bb9..bc02a24b35 100644 --- a/test/TestAssets/SimpleTestProject2/UnitTest1.cs +++ b/test/TestAssets/SimpleTestProject2/UnitTest1.cs @@ -1,40 +1,40 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace SampleUnitTestProject2 -{ - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace SampleUnitTestProject2; + +using Microsoft.VisualStudio.TestTools.UnitTesting; +/// +/// The unit test 1. +/// +[TestClass] +public class UnitTest1 +{ /// - /// The unit test 1. + /// The passing test. /// - [TestClass] - public class UnitTest1 + [TestMethod] + public void PassingTest2() { - /// - /// The passing test. - /// - [TestMethod] - public void PassingTest2() - { - Assert.AreEqual(2, 2); - } + Assert.AreEqual(2, 2); + } - /// - /// The failing test. - /// - [TestMethod] - public void FailingTest2() - { - Assert.AreEqual(2, 3); - } + /// + /// The failing test. + /// + [TestMethod] + public void FailingTest2() + { + Assert.AreEqual(2, 3); + } - /// - /// The skipping test. - /// - [Ignore] - [TestMethod] - public void SkippingTest2() - { - } + /// + /// The skipping test. + /// + [Ignore] + [TestMethod] + public void SkippingTest2() + { } } diff --git a/test/TestAssets/SimpleTestProject3/TestSessionTimeoutTest.cs b/test/TestAssets/SimpleTestProject3/TestSessionTimeoutTest.cs index 9de44ab9a5..694bb6e524 100644 --- a/test/TestAssets/SimpleTestProject3/TestSessionTimeoutTest.cs +++ b/test/TestAssets/SimpleTestProject3/TestSessionTimeoutTest.cs @@ -1,4 +1,5 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. namespace SampleUnitTestProject3 { diff --git a/test/TestAssets/SimpleTestProject3/UnitTest1.cs b/test/TestAssets/SimpleTestProject3/UnitTest1.cs index 3ce4c563cc..5c916237bc 100644 --- a/test/TestAssets/SimpleTestProject3/UnitTest1.cs +++ b/test/TestAssets/SimpleTestProject3/UnitTest1.cs @@ -1,8 +1,10 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. namespace SampleUnitTestProject3 { using Microsoft.VisualStudio.TestTools.UnitTesting; + using System; using System.IO; using System.Reflection; diff --git a/test/TestAssets/SimpleTestProjectARM/UnitTest1.cs b/test/TestAssets/SimpleTestProjectARM/UnitTest1.cs index cddcbc7f11..88953d9bd4 100644 --- a/test/TestAssets/SimpleTestProjectARM/UnitTest1.cs +++ b/test/TestAssets/SimpleTestProjectARM/UnitTest1.cs @@ -1,4 +1,5 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. namespace SimpleTestProjectARM { diff --git a/test/TestAssets/SimpleTestProjectx86/UnitTest1.cs b/test/TestAssets/SimpleTestProjectx86/UnitTest1.cs index db8897be24..7226e771a8 100644 --- a/test/TestAssets/SimpleTestProjectx86/UnitTest1.cs +++ b/test/TestAssets/SimpleTestProjectx86/UnitTest1.cs @@ -1,4 +1,5 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. namespace SimpleTestProjectx86 { diff --git a/test/TestAssets/XUTestProject/Class1.cs b/test/TestAssets/XUTestProject/Class1.cs index e1d33d201f..99fc19a272 100644 --- a/test/TestAssets/XUTestProject/Class1.cs +++ b/test/TestAssets/XUTestProject/Class1.cs @@ -1,11 +1,10 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +#pragma warning disable IDE1006 // Naming Styles namespace xUnitTestProject +#pragma warning restore IDE1006 // Naming Styles { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; using Xunit; public class Class1 diff --git a/test/TestAssets/child-crash/UnitTest1.cs b/test/TestAssets/child-crash/UnitTest1.cs index f35ac67928..1fe5409160 100644 --- a/test/TestAssets/child-crash/UnitTest1.cs +++ b/test/TestAssets/child-crash/UnitTest1.cs @@ -1,10 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + using Microsoft.VisualStudio.TestTools.UnitTesting; + using System; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; +#pragma warning disable IDE1006 // Naming Styles namespace child_crash +#pragma warning restore IDE1006 // Naming Styles { [TestClass] public class UnitTest1 diff --git a/test/TestAssets/child-hang/UnitTest1.cs b/test/TestAssets/child-hang/UnitTest1.cs index 1c0f378c8e..8a357193a9 100644 --- a/test/TestAssets/child-hang/UnitTest1.cs +++ b/test/TestAssets/child-hang/UnitTest1.cs @@ -1,11 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + using Microsoft.VisualStudio.TestTools.UnitTesting; + using System; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; using System.Threading; +#pragma warning disable IDE1006 // Naming Styles namespace child_hang +#pragma warning restore IDE1006 // Naming Styles { [TestClass] public class UnitTest1 @@ -19,7 +25,7 @@ public void TestMethod1() var directory = "Release"; #endif // wait for two children to crash - var childProcess = Path.GetFullPath($@"../../../../hanging-child/bin/{directory}/net5.0/hanging-child{(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : ".dll")}"); + var childProcess = Path.GetFullPath($@"../../../../hanging-child/bin/{directory}/net5.0/hanging-child{(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : ".dll")}"); // 2 chidren, that is 3 hanging processes var process = (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? Process.Start(childProcess, "2") : Process.Start(GetFullPath("dotnet"), $"{childProcess} 2")); process.WaitForExit(); diff --git a/test/TestAssets/crash/UnitTest1.cs b/test/TestAssets/crash/UnitTest1.cs index c3e0e3a547..cfcb1181c3 100644 --- a/test/TestAssets/crash/UnitTest1.cs +++ b/test/TestAssets/crash/UnitTest1.cs @@ -1,7 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + using Microsoft.VisualStudio.TestTools.UnitTesting; + using System; +#pragma warning disable IDE1006 // Naming Styles namespace timeout +#pragma warning restore IDE1006 // Naming Styles { [TestClass] public class UnitTest1 diff --git a/test/TestAssets/hanging-child/Program.cs b/test/TestAssets/hanging-child/Program.cs index 62719c9a47..540a957517 100644 --- a/test/TestAssets/hanging-child/Program.cs +++ b/test/TestAssets/hanging-child/Program.cs @@ -1,11 +1,16 @@ -using System; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.InteropServices; using System.Threading; +#pragma warning disable IDE1006 // Naming Styles namespace hanging_child +#pragma warning restore IDE1006 // Naming Styles { class Program { diff --git a/test/TestAssets/problematic-child/Program.cs b/test/TestAssets/problematic-child/Program.cs index 882c6972b4..ae2a396ca5 100644 --- a/test/TestAssets/problematic-child/Program.cs +++ b/test/TestAssets/problematic-child/Program.cs @@ -1,11 +1,15 @@ -using System; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.InteropServices; -using System.Threading; +#pragma warning disable IDE1006 // Naming Styles namespace problematic_child +#pragma warning restore IDE1006 // Naming Styles { class Program { diff --git a/test/TestAssets/timeout/UnitTest1.cs b/test/TestAssets/timeout/UnitTest1.cs index 22cf1b532a..609ccd7e0a 100644 --- a/test/TestAssets/timeout/UnitTest1.cs +++ b/test/TestAssets/timeout/UnitTest1.cs @@ -1,7 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + using Microsoft.VisualStudio.TestTools.UnitTesting; + using System.Threading; +#pragma warning disable IDE1006 // Naming Styles namespace timeout +#pragma warning restore IDE1006 // Naming Styles { [TestClass] public class UnitTest1 diff --git a/test/TranslationLayer.UnitTests/ConsoleParametersTests.cs b/test/TranslationLayer.UnitTests/ConsoleParametersTests.cs index f99796731c..c913dfaef7 100644 --- a/test/TranslationLayer.UnitTests/ConsoleParametersTests.cs +++ b/test/TranslationLayer.UnitTests/ConsoleParametersTests.cs @@ -1,38 +1,37 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.UnitTests -{ - using System.Diagnostics; +namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.UnitTests; + +using System.Diagnostics; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using VisualStudio.TestTools.UnitTesting; +using Moq; - [TestClass] - public class ConsoleParametersTests +[TestClass] +public class ConsoleParametersTests +{ + [TestMethod] + public void LogFilePathShouldEnsureDoubleQuote() { - [TestMethod] - public void LogFilePathShouldEnsureDoubleQuote() - { - var moqFileHelper = new Mock(); - moqFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); + var moqFileHelper = new Mock(); + moqFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); - var sut = new ConsoleParameters(moqFileHelper.Object); + var sut = new ConsoleParameters(moqFileHelper.Object); - sut.LogFilePath = "c:\\users\\file location\\o.txt"; + sut.LogFilePath = "c:\\users\\file location\\o.txt"; - string result = sut.LogFilePath; + string result = sut.LogFilePath; - Assert.IsTrue(result.StartsWith("\"")); - } + Assert.IsTrue(result.StartsWith("\"")); + } - [TestMethod] - public void TraceLevelShouldHaveVerboseAsDefaultValue() - { - var consoleParameters = new ConsoleParameters(new FileHelper()); - Assert.AreEqual(consoleParameters.TraceLevel, TraceLevel.Verbose); - } + [TestMethod] + public void TraceLevelShouldHaveVerboseAsDefaultValue() + { + var consoleParameters = new ConsoleParameters(new FileHelper()); + Assert.AreEqual(consoleParameters.TraceLevel, TraceLevel.Verbose); } -} +} \ No newline at end of file diff --git a/test/TranslationLayer.UnitTests/DiscoveryEventsHandleConverterTests.cs b/test/TranslationLayer.UnitTests/DiscoveryEventsHandleConverterTests.cs index b53aa25f89..ebce9e9cd8 100644 --- a/test/TranslationLayer.UnitTests/DiscoveryEventsHandleConverterTests.cs +++ b/test/TranslationLayer.UnitTests/DiscoveryEventsHandleConverterTests.cs @@ -3,68 +3,67 @@ using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; -namespace TranslationLayer.UnitTests -{ - using System; +namespace TranslationLayer.UnitTests; + +using System; - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.TestPlatform.VsTestConsole.TranslationLayer; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; +using Moq; - [TestClass] - public class DiscoveryEventsHandleConverterTests +[TestClass] +public class DiscoveryEventsHandleConverterTests +{ + private readonly Mock _mockTestdiscoveryEventsHandler; + public DiscoveryEventsHandleConverterTests() { - private Mock mockTestdiscoveryEventsHandler; - public DiscoveryEventsHandleConverterTests() - { - this.mockTestdiscoveryEventsHandler = new Mock(); - } + _mockTestdiscoveryEventsHandler = new Mock(); + } - [TestMethod] - public void ConstructorShouldThrowArgumentExceptionIfTestDiscoveryEventHandlerIsNull() - { - Assert.ThrowsException( () => new DiscoveryEventsHandleConverter(null)); - } + [TestMethod] + public void ConstructorShouldThrowArgumentExceptionIfTestDiscoveryEventHandlerIsNull() + { + Assert.ThrowsException(() => new DiscoveryEventsHandleConverter(null)); + } - [TestMethod] - public void HandleDiscoveryCompleteShouldCallTestDiscoveryHandler1Method() - { - var discoveryEventsHandler = new DiscoveryEventsHandleConverter(this.mockTestdiscoveryEventsHandler.Object); + [TestMethod] + public void HandleDiscoveryCompleteShouldCallTestDiscoveryHandler1Method() + { + var discoveryEventsHandler = new DiscoveryEventsHandleConverter(_mockTestdiscoveryEventsHandler.Object); - discoveryEventsHandler.HandleDiscoveryComplete(new DiscoveryCompleteEventArgs(-1, false), null); - this.mockTestdiscoveryEventsHandler.Verify(o => o.HandleDiscoveryComplete(-1, null, false), Times.Once); - } + discoveryEventsHandler.HandleDiscoveryComplete(new DiscoveryCompleteEventArgs(-1, false), null); + _mockTestdiscoveryEventsHandler.Verify(o => o.HandleDiscoveryComplete(-1, null, false), Times.Once); + } - [TestMethod] - public void HandleDiscoveryTestsShouldCallTestDiscoveryHandler1Method() - { - var discoveryEventsHandler = new DiscoveryEventsHandleConverter(this.mockTestdiscoveryEventsHandler.Object); + [TestMethod] + public void HandleDiscoveryTestsShouldCallTestDiscoveryHandler1Method() + { + var discoveryEventsHandler = new DiscoveryEventsHandleConverter(_mockTestdiscoveryEventsHandler.Object); - discoveryEventsHandler.HandleDiscoveredTests(null); + discoveryEventsHandler.HandleDiscoveredTests(null); - this.mockTestdiscoveryEventsHandler.Verify(o => o.HandleDiscoveredTests(null), Times.Once); - } + _mockTestdiscoveryEventsHandler.Verify(o => o.HandleDiscoveredTests(null), Times.Once); + } - [TestMethod] - public void HandleRawMessageShouldCallTestDiscoveryHandler1Method() - { - var discoveryEventsHandler = new DiscoveryEventsHandleConverter(this.mockTestdiscoveryEventsHandler.Object); + [TestMethod] + public void HandleRawMessageShouldCallTestDiscoveryHandler1Method() + { + var discoveryEventsHandler = new DiscoveryEventsHandleConverter(_mockTestdiscoveryEventsHandler.Object); - discoveryEventsHandler.HandleRawMessage("DummyMessage"); + discoveryEventsHandler.HandleRawMessage("DummyMessage"); - this.mockTestdiscoveryEventsHandler.Verify(o => o.HandleRawMessage("DummyMessage"), Times.Once); - } + _mockTestdiscoveryEventsHandler.Verify(o => o.HandleRawMessage("DummyMessage"), Times.Once); + } - [TestMethod] - public void HandleLogMessageShouldCallTestDiscoveryHandler1Method() - { - var discoveryEventsHandler = new DiscoveryEventsHandleConverter(this.mockTestdiscoveryEventsHandler.Object); + [TestMethod] + public void HandleLogMessageShouldCallTestDiscoveryHandler1Method() + { + var discoveryEventsHandler = new DiscoveryEventsHandleConverter(_mockTestdiscoveryEventsHandler.Object); - discoveryEventsHandler.HandleLogMessage(TestMessageLevel.Warning, "DummyMessage"); + discoveryEventsHandler.HandleLogMessage(TestMessageLevel.Warning, "DummyMessage"); - this.mockTestdiscoveryEventsHandler.Verify(o => o.HandleLogMessage(TestMessageLevel.Warning, "DummyMessage"), Times.Once); - } + _mockTestdiscoveryEventsHandler.Verify(o => o.HandleLogMessage(TestMessageLevel.Warning, "DummyMessage"), Times.Once); } -} +} \ No newline at end of file diff --git a/test/TranslationLayer.UnitTests/Program.cs b/test/TranslationLayer.UnitTests/Program.cs index cb4dfb25dc..281425adce 100644 --- a/test/TranslationLayer.UnitTests/Program.cs +++ b/test/TranslationLayer.UnitTests/Program.cs @@ -1,11 +1,11 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.UnitTests +namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.UnitTests; + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/TranslationLayer.UnitTests/TestSessionTests.cs b/test/TranslationLayer.UnitTests/TestSessionTests.cs index 01989a2f6a..9d02eceef1 100644 --- a/test/TranslationLayer.UnitTests/TestSessionTests.cs +++ b/test/TranslationLayer.UnitTests/TestSessionTests.cs @@ -1,587 +1,586 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.UnitTests +namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.UnitTests; + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +using Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using Microsoft.VisualStudio.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; +using VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +[Obsolete("This API is not final yet and is subject to changes.", false)] +public class TestSessionTests { - using System; - using System.Collections.Generic; - using System.Threading.Tasks; - - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - [TestClass] - [Obsolete("This API is not final yet and is subject to changes.", false)] - public class TestSessionTests + private readonly string _testSettings = "TestSettings"; + private readonly List _testSources = new() { "Hello", "World" }; + private readonly List _testCases = new() + { + new TestCase("a.b.c", new Uri("d://uri"), "a.dll"), + new TestCase("d.e.f", new Uri("g://uri"), "d.dll") + }; + + private TestSessionInfo _testSessionInfo; + private ITestSession _testSession; + private Mock _mockTestSessionEventsHandler; + private Mock _mockVsTestConsoleWrapper; + + [TestInitialize] + public void TestInitialize() + { + _testSessionInfo = new TestSessionInfo(); + _mockTestSessionEventsHandler = new Mock(); + _mockVsTestConsoleWrapper = new Mock(); + + _testSession = new TestSession( + _testSessionInfo, + _mockTestSessionEventsHandler.Object, + _mockVsTestConsoleWrapper.Object); + } + + #region ITestSession + [TestMethod] + public void AbortTestRunShouldCallConsoleWrapperAbortTestRun() + { + _testSession.AbortTestRun(); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.AbortTestRun(), + Times.Once); + } + + [TestMethod] + public void CancelDiscoveryShouldCallConsoleWrapperCancelDiscovery() + { + _testSession.CancelDiscovery(); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.CancelDiscovery(), + Times.Once); + } + + [TestMethod] + public void CancelTestRunShouldCallConsoleWrapperCancelTestRun() + { + _testSession.CancelTestRun(); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.CancelTestRun(), + Times.Once); + } + + [TestMethod] + public void DiscoverTestsShouldCallConsoleWrapperDiscoverTestsWithCorrectArguments1() + { + _testSession.DiscoverTests( + _testSources, + _testSettings, + new Mock().Object); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.DiscoverTests( + _testSources, + _testSettings, + null, + _testSessionInfo, + It.IsAny()), + Times.Once); + } + + [TestMethod] + public void DiscoverTestsShouldCallConsoleWrapperDiscoverTestsWithCorrectArguments2() { - private readonly string testSettings = "TestSettings"; - private readonly List testSources = new List { "Hello", "World" }; - private readonly List testCases = new List - { - new TestCase("a.b.c", new Uri("d://uri"), "a.dll"), - new TestCase("d.e.f", new Uri("g://uri"), "d.dll") - }; - - private TestSessionInfo testSessionInfo; - private ITestSession testSession; - private Mock mockTestSessionEventsHandler; - private Mock mockVsTestConsoleWrapper; - - [TestInitialize] - public void TestInitialize() - { - this.testSessionInfo = new TestSessionInfo(); - this.mockTestSessionEventsHandler = new Mock(); - this.mockVsTestConsoleWrapper = new Mock(); - - this.testSession = new TestSession( - this.testSessionInfo, - this.mockTestSessionEventsHandler.Object, - this.mockVsTestConsoleWrapper.Object); - } - - #region ITestSession - [TestMethod] - public void AbortTestRunShouldCallConsoleWrapperAbortTestRun() - { - this.testSession.AbortTestRun(); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.AbortTestRun(), - Times.Once); - } - - [TestMethod] - public void CancelDiscoveryShouldCallConsoleWrapperCancelDiscovery() - { - this.testSession.CancelDiscovery(); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.CancelDiscovery(), - Times.Once); - } - - [TestMethod] - public void CancelTestRunShouldCallConsoleWrapperCancelTestRun() - { - this.testSession.CancelTestRun(); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.CancelTestRun(), - Times.Once); - } - - [TestMethod] - public void DiscoverTestsShouldCallConsoleWrapperDiscoverTestsWithCorrectArguments1() - { - this.testSession.DiscoverTests( - this.testSources, - this.testSettings, - new Mock().Object); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.DiscoverTests( - this.testSources, - this.testSettings, - null, - this.testSessionInfo, - It.IsAny()), - Times.Once); - } - - [TestMethod] - public void DiscoverTestsShouldCallConsoleWrapperDiscoverTestsWithCorrectArguments2() - { - var testPlatformOptions = new TestPlatformOptions(); - var mockTestDiscoveryEventsHandler = new Mock(); - - this.testSession.DiscoverTests( - this.testSources, - this.testSettings, + var testPlatformOptions = new TestPlatformOptions(); + var mockTestDiscoveryEventsHandler = new Mock(); + + _testSession.DiscoverTests( + _testSources, + _testSettings, + testPlatformOptions, + mockTestDiscoveryEventsHandler.Object); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.DiscoverTests( + _testSources, + _testSettings, testPlatformOptions, - mockTestDiscoveryEventsHandler.Object); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.DiscoverTests( - this.testSources, - this.testSettings, - testPlatformOptions, - this.testSessionInfo, - mockTestDiscoveryEventsHandler.Object), - Times.Once); - } - - [TestMethod] - public void RunTestsWithSourcesShouldCallConsoleWrapperRunTestsWithCorrectArguments1() - { - var mockTestRunEventsHandler = new Mock(); - - this.testSession.RunTests( - this.testSources, - this.testSettings, - mockTestRunEventsHandler.Object); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.RunTests( - this.testSources, - this.testSettings, - null, - this.testSessionInfo, - mockTestRunEventsHandler.Object), - Times.Once); - } - - [TestMethod] - public void RunTestsWithSourcesShouldCallConsoleWrapperRunTestsWithCorrectArguments2() - { - var testPlatformOptions = new TestPlatformOptions(); - var mockTestRunEventsHandler = new Mock(); - - this.testSession.RunTests( - this.testSources, - this.testSettings, + _testSessionInfo, + mockTestDiscoveryEventsHandler.Object), + Times.Once); + } + + [TestMethod] + public void RunTestsWithSourcesShouldCallConsoleWrapperRunTestsWithCorrectArguments1() + { + var mockTestRunEventsHandler = new Mock(); + + _testSession.RunTests( + _testSources, + _testSettings, + mockTestRunEventsHandler.Object); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.RunTests( + _testSources, + _testSettings, + null, + _testSessionInfo, + mockTestRunEventsHandler.Object), + Times.Once); + } + + [TestMethod] + public void RunTestsWithSourcesShouldCallConsoleWrapperRunTestsWithCorrectArguments2() + { + var testPlatformOptions = new TestPlatformOptions(); + var mockTestRunEventsHandler = new Mock(); + + _testSession.RunTests( + _testSources, + _testSettings, + testPlatformOptions, + mockTestRunEventsHandler.Object); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.RunTests( + _testSources, + _testSettings, testPlatformOptions, - mockTestRunEventsHandler.Object); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.RunTests( - this.testSources, - this.testSettings, - testPlatformOptions, - this.testSessionInfo, - mockTestRunEventsHandler.Object), - Times.Once); - } - - [TestMethod] - public void RunTestsWithTestCasesShouldCallConsoleWrapperRunTestsWithCorrectArguments1() - { - var mockTestRunEventsHandler = new Mock(); - - this.testSession.RunTests( - this.testCases, - this.testSettings, - mockTestRunEventsHandler.Object); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.RunTests( - this.testCases, - this.testSettings, - null, - this.testSessionInfo, - mockTestRunEventsHandler.Object), - Times.Once); - } - - [TestMethod] - public void RunTestsWithTestCasesShouldCallConsoleWrapperRunTestsWithCorrectArguments2() - { - var testPlatformOptions = new TestPlatformOptions(); - var mockTestRunEventsHandler = new Mock(); - - this.testSession.RunTests( - this.testCases, - this.testSettings, + _testSessionInfo, + mockTestRunEventsHandler.Object), + Times.Once); + } + + [TestMethod] + public void RunTestsWithTestCasesShouldCallConsoleWrapperRunTestsWithCorrectArguments1() + { + var mockTestRunEventsHandler = new Mock(); + + _testSession.RunTests( + _testCases, + _testSettings, + mockTestRunEventsHandler.Object); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.RunTests( + _testCases, + _testSettings, + null, + _testSessionInfo, + mockTestRunEventsHandler.Object), + Times.Once); + } + + [TestMethod] + public void RunTestsWithTestCasesShouldCallConsoleWrapperRunTestsWithCorrectArguments2() + { + var testPlatformOptions = new TestPlatformOptions(); + var mockTestRunEventsHandler = new Mock(); + + _testSession.RunTests( + _testCases, + _testSettings, + testPlatformOptions, + mockTestRunEventsHandler.Object); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.RunTests( + _testCases, + _testSettings, testPlatformOptions, - mockTestRunEventsHandler.Object); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.RunTests( - this.testCases, - this.testSettings, - testPlatformOptions, - this.testSessionInfo, - mockTestRunEventsHandler.Object), - Times.Once); - } - - [TestMethod] - public void RunTestsWithSourcesAndCustomTesthostShouldCallConsoleWrapperRunTestsWithCorrectArguments1() - { - var mockTestRunEventsHandler = new Mock(); - var mockTestHostLauncher = new Mock(); - - this.testSession.RunTestsWithCustomTestHost( - this.testSources, - this.testSettings, + _testSessionInfo, + mockTestRunEventsHandler.Object), + Times.Once); + } + + [TestMethod] + public void RunTestsWithSourcesAndCustomTesthostShouldCallConsoleWrapperRunTestsWithCorrectArguments1() + { + var mockTestRunEventsHandler = new Mock(); + var mockTestHostLauncher = new Mock(); + + _testSession.RunTestsWithCustomTestHost( + _testSources, + _testSettings, + mockTestRunEventsHandler.Object, + mockTestHostLauncher.Object); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.RunTestsWithCustomTestHost( + _testSources, + _testSettings, + null, + _testSessionInfo, mockTestRunEventsHandler.Object, - mockTestHostLauncher.Object); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.RunTestsWithCustomTestHost( - this.testSources, - this.testSettings, - null, - this.testSessionInfo, - mockTestRunEventsHandler.Object, - mockTestHostLauncher.Object), - Times.Once); - } - - [TestMethod] - public void RunTestsWithSourcesAndCustomTesthostShouldCallConsoleWrapperRunTestsWithCorrectArguments2() - { - var testPlatformOptions = new TestPlatformOptions(); - var mockTestRunEventsHandler = new Mock(); - var mockTestHostLauncher = new Mock(); - - this.testSession.RunTestsWithCustomTestHost( - this.testSources, - this.testSettings, + mockTestHostLauncher.Object), + Times.Once); + } + + [TestMethod] + public void RunTestsWithSourcesAndCustomTesthostShouldCallConsoleWrapperRunTestsWithCorrectArguments2() + { + var testPlatformOptions = new TestPlatformOptions(); + var mockTestRunEventsHandler = new Mock(); + var mockTestHostLauncher = new Mock(); + + _testSession.RunTestsWithCustomTestHost( + _testSources, + _testSettings, + testPlatformOptions, + mockTestRunEventsHandler.Object, + mockTestHostLauncher.Object); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.RunTestsWithCustomTestHost( + _testSources, + _testSettings, testPlatformOptions, + _testSessionInfo, mockTestRunEventsHandler.Object, - mockTestHostLauncher.Object); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.RunTestsWithCustomTestHost( - this.testSources, - this.testSettings, - testPlatformOptions, - this.testSessionInfo, - mockTestRunEventsHandler.Object, - mockTestHostLauncher.Object), - Times.Once); - } - - [TestMethod] - public void RunTestsWithTestCasesAndCustomTesthostShouldCallConsoleWrapperRunTestsWithCorrectArguments1() - { - var mockTestRunEventsHandler = new Mock(); - var mockTestHostLauncher = new Mock(); - - this.testSession.RunTestsWithCustomTestHost( - this.testCases, - this.testSettings, + mockTestHostLauncher.Object), + Times.Once); + } + + [TestMethod] + public void RunTestsWithTestCasesAndCustomTesthostShouldCallConsoleWrapperRunTestsWithCorrectArguments1() + { + var mockTestRunEventsHandler = new Mock(); + var mockTestHostLauncher = new Mock(); + + _testSession.RunTestsWithCustomTestHost( + _testCases, + _testSettings, + mockTestRunEventsHandler.Object, + mockTestHostLauncher.Object); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.RunTestsWithCustomTestHost( + _testCases, + _testSettings, + null, + _testSessionInfo, mockTestRunEventsHandler.Object, - mockTestHostLauncher.Object); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.RunTestsWithCustomTestHost( - this.testCases, - this.testSettings, - null, - this.testSessionInfo, - mockTestRunEventsHandler.Object, - mockTestHostLauncher.Object), - Times.Once); - } - - [TestMethod] - public void RunTestsWithTestCasesAndCustomTesthostShouldCallConsoleWrapperRunTestsWithCorrectArguments2() - { - var testPlatformOptions = new TestPlatformOptions(); - var mockTestRunEventsHandler = new Mock(); - var mockTestHostLauncher = new Mock(); - - this.testSession.RunTestsWithCustomTestHost( - this.testCases, - this.testSettings, + mockTestHostLauncher.Object), + Times.Once); + } + + [TestMethod] + public void RunTestsWithTestCasesAndCustomTesthostShouldCallConsoleWrapperRunTestsWithCorrectArguments2() + { + var testPlatformOptions = new TestPlatformOptions(); + var mockTestRunEventsHandler = new Mock(); + var mockTestHostLauncher = new Mock(); + + _testSession.RunTestsWithCustomTestHost( + _testCases, + _testSettings, + testPlatformOptions, + mockTestRunEventsHandler.Object, + mockTestHostLauncher.Object); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.RunTestsWithCustomTestHost( + _testCases, + _testSettings, testPlatformOptions, + _testSessionInfo, mockTestRunEventsHandler.Object, - mockTestHostLauncher.Object); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.RunTestsWithCustomTestHost( - this.testCases, - this.testSettings, - testPlatformOptions, - this.testSessionInfo, - mockTestRunEventsHandler.Object, - mockTestHostLauncher.Object), - Times.Once); - } - - [TestMethod] - public void StopTestSessionShouldCallConsoleWrapperStopTestSessionWithCorrectArguments1() - { - this.testSession.StopTestSession(); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.StopTestSession( - this.testSessionInfo, - this.mockTestSessionEventsHandler.Object), - Times.Once); - } - - [TestMethod] - public void StopTestSessionShouldCallConsoleWrapperStopTestSessionWithCorrectArguments2() - { - var mockTestSessionEventsHandler2 = new Mock(); - - this.testSession.StopTestSession(mockTestSessionEventsHandler2.Object); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.StopTestSession( - this.testSessionInfo, - mockTestSessionEventsHandler2.Object), - Times.Once); - } - #endregion - - #region ITestSessionAsync - [TestMethod] - public async Task DiscoverTestsAsyncShouldCallConsoleWrapperDiscoverTestsWithCorrectArguments1() - { - await this.testSession.DiscoverTestsAsync( - this.testSources, - this.testSettings, - new Mock().Object) - .ConfigureAwait(false); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.DiscoverTestsAsync( - this.testSources, - this.testSettings, - null, - this.testSessionInfo, - It.IsAny()), - Times.Once); - } - - [TestMethod] - public async Task DiscoverTestsAsyncShouldCallConsoleWrapperDiscoverTestsWithCorrectArguments2() - { - var testPlatformOptions = new TestPlatformOptions(); - var mockTestDiscoveryEventsHandler = new Mock(); - - await this.testSession.DiscoverTestsAsync( - this.testSources, - this.testSettings, - testPlatformOptions, - mockTestDiscoveryEventsHandler.Object) - .ConfigureAwait(false); ; - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.DiscoverTestsAsync( - this.testSources, - this.testSettings, - testPlatformOptions, - this.testSessionInfo, - mockTestDiscoveryEventsHandler.Object), - Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithSourcesShouldCallConsoleWrapperRunTestsWithCorrectArguments1() - { - var mockTestRunEventsHandler = new Mock(); - - await this.testSession.RunTestsAsync( - this.testSources, - this.testSettings, - mockTestRunEventsHandler.Object) - .ConfigureAwait(false); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.RunTestsAsync( - this.testSources, - this.testSettings, - null, - this.testSessionInfo, - mockTestRunEventsHandler.Object), - Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithSourcesShouldCallConsoleWrapperRunTestsWithCorrectArguments2() - { - var testPlatformOptions = new TestPlatformOptions(); - var mockTestRunEventsHandler = new Mock(); - - await this.testSession.RunTestsAsync( - this.testSources, - this.testSettings, - testPlatformOptions, - mockTestRunEventsHandler.Object) - .ConfigureAwait(false); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.RunTestsAsync( - this.testSources, - this.testSettings, - testPlatformOptions, - this.testSessionInfo, - mockTestRunEventsHandler.Object), - Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithTestCasesShouldCallConsoleWrapperRunTestsWithCorrectArguments1() - { - var mockTestRunEventsHandler = new Mock(); - - await this.testSession.RunTestsAsync( - this.testCases, - this.testSettings, - mockTestRunEventsHandler.Object) - .ConfigureAwait(false); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.RunTestsAsync( - this.testCases, - this.testSettings, - null, - this.testSessionInfo, - mockTestRunEventsHandler.Object), - Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithTestCasesShouldCallConsoleWrapperRunTestsWithCorrectArguments2() - { - var testPlatformOptions = new TestPlatformOptions(); - var mockTestRunEventsHandler = new Mock(); - - await this.testSession.RunTestsAsync( - this.testCases, - this.testSettings, - testPlatformOptions, - mockTestRunEventsHandler.Object) - .ConfigureAwait(false); ; - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.RunTestsAsync( - this.testCases, - this.testSettings, - testPlatformOptions, - this.testSessionInfo, - mockTestRunEventsHandler.Object), - Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithSourcesAndCustomTesthostShouldCallConsoleWrapperRunTestsWithCorrectArguments1() - { - var mockTestRunEventsHandler = new Mock(); - var mockTestHostLauncher = new Mock(); - - await this.testSession.RunTestsWithCustomTestHostAsync( - this.testSources, - this.testSettings, - mockTestRunEventsHandler.Object, - mockTestHostLauncher.Object) - .ConfigureAwait(false); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.RunTestsWithCustomTestHostAsync( - this.testSources, - this.testSettings, - null, - this.testSessionInfo, - mockTestRunEventsHandler.Object, - mockTestHostLauncher.Object), - Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithSourcesAndCustomTesthostShouldCallConsoleWrapperRunTestsWithCorrectArguments2() - { - var testPlatformOptions = new TestPlatformOptions(); - var mockTestRunEventsHandler = new Mock(); - var mockTestHostLauncher = new Mock(); - - await this.testSession.RunTestsWithCustomTestHostAsync( - this.testSources, - this.testSettings, - testPlatformOptions, - mockTestRunEventsHandler.Object, - mockTestHostLauncher.Object) - .ConfigureAwait(false); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.RunTestsWithCustomTestHostAsync( - this.testSources, - this.testSettings, - testPlatformOptions, - this.testSessionInfo, - mockTestRunEventsHandler.Object, - mockTestHostLauncher.Object), - Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithTestCasesAndCustomTesthostShouldCallConsoleWrapperRunTestsWithCorrectArguments1() - { - var mockTestRunEventsHandler = new Mock(); - var mockTestHostLauncher = new Mock(); - - await this.testSession.RunTestsWithCustomTestHostAsync( - this.testCases, - this.testSettings, - mockTestRunEventsHandler.Object, - mockTestHostLauncher.Object) - .ConfigureAwait(false); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.RunTestsWithCustomTestHostAsync( - this.testCases, - this.testSettings, - null, - this.testSessionInfo, - mockTestRunEventsHandler.Object, - mockTestHostLauncher.Object), - Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithTestCasesAndCustomTesthostShouldCallConsoleWrapperRunTestsWithCorrectArguments2() - { - var testPlatformOptions = new TestPlatformOptions(); - var mockTestRunEventsHandler = new Mock(); - var mockTestHostLauncher = new Mock(); - - await this.testSession.RunTestsWithCustomTestHostAsync( - this.testCases, - this.testSettings, - testPlatformOptions, - mockTestRunEventsHandler.Object, - mockTestHostLauncher.Object) - .ConfigureAwait(false); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.RunTestsWithCustomTestHostAsync( - this.testCases, - this.testSettings, - testPlatformOptions, - this.testSessionInfo, - mockTestRunEventsHandler.Object, - mockTestHostLauncher.Object), - Times.Once); - } - - [TestMethod] - public async Task StopTestSessionAsyncShouldCallConsoleWrapperStopTestSessionWithCorrectArguments1() - { - await this.testSession.StopTestSessionAsync().ConfigureAwait(false); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.StopTestSessionAsync( - this.testSessionInfo, - this.mockTestSessionEventsHandler.Object), - Times.Once); - } - - [TestMethod] - public async Task StopTestSessionAsyncShouldCallConsoleWrapperStopTestSessionWithCorrectArguments2() - { - var mockTestSessionEventsHandler2 = new Mock(); - - await this.testSession.StopTestSessionAsync( - mockTestSessionEventsHandler2.Object) - .ConfigureAwait(false); - - this.mockVsTestConsoleWrapper.Verify( - vtcw => vtcw.StopTestSessionAsync( - this.testSessionInfo, - mockTestSessionEventsHandler2.Object), - Times.Once); - } - #endregion + mockTestHostLauncher.Object), + Times.Once); + } + + [TestMethod] + public void StopTestSessionShouldCallConsoleWrapperStopTestSessionWithCorrectArguments1() + { + _testSession.StopTestSession(); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.StopTestSession( + _testSessionInfo, + _mockTestSessionEventsHandler.Object), + Times.Once); + } + + [TestMethod] + public void StopTestSessionShouldCallConsoleWrapperStopTestSessionWithCorrectArguments2() + { + var mockTestSessionEventsHandler2 = new Mock(); + + _testSession.StopTestSession(mockTestSessionEventsHandler2.Object); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.StopTestSession( + _testSessionInfo, + mockTestSessionEventsHandler2.Object), + Times.Once); + } + #endregion + + #region ITestSessionAsync + [TestMethod] + public async Task DiscoverTestsAsyncShouldCallConsoleWrapperDiscoverTestsWithCorrectArguments1() + { + await _testSession.DiscoverTestsAsync( + _testSources, + _testSettings, + new Mock().Object) + .ConfigureAwait(false); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.DiscoverTestsAsync( + _testSources, + _testSettings, + null, + _testSessionInfo, + It.IsAny()), + Times.Once); + } + + [TestMethod] + public async Task DiscoverTestsAsyncShouldCallConsoleWrapperDiscoverTestsWithCorrectArguments2() + { + var testPlatformOptions = new TestPlatformOptions(); + var mockTestDiscoveryEventsHandler = new Mock(); + + await _testSession.DiscoverTestsAsync( + _testSources, + _testSettings, + testPlatformOptions, + mockTestDiscoveryEventsHandler.Object) + .ConfigureAwait(false); ; + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.DiscoverTestsAsync( + _testSources, + _testSettings, + testPlatformOptions, + _testSessionInfo, + mockTestDiscoveryEventsHandler.Object), + Times.Once); + } + + [TestMethod] + public async Task RunTestsAsyncWithSourcesShouldCallConsoleWrapperRunTestsWithCorrectArguments1() + { + var mockTestRunEventsHandler = new Mock(); + + await _testSession.RunTestsAsync( + _testSources, + _testSettings, + mockTestRunEventsHandler.Object) + .ConfigureAwait(false); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.RunTestsAsync( + _testSources, + _testSettings, + null, + _testSessionInfo, + mockTestRunEventsHandler.Object), + Times.Once); + } + + [TestMethod] + public async Task RunTestsAsyncWithSourcesShouldCallConsoleWrapperRunTestsWithCorrectArguments2() + { + var testPlatformOptions = new TestPlatformOptions(); + var mockTestRunEventsHandler = new Mock(); + + await _testSession.RunTestsAsync( + _testSources, + _testSettings, + testPlatformOptions, + mockTestRunEventsHandler.Object) + .ConfigureAwait(false); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.RunTestsAsync( + _testSources, + _testSettings, + testPlatformOptions, + _testSessionInfo, + mockTestRunEventsHandler.Object), + Times.Once); + } + + [TestMethod] + public async Task RunTestsAsyncWithTestCasesShouldCallConsoleWrapperRunTestsWithCorrectArguments1() + { + var mockTestRunEventsHandler = new Mock(); + + await _testSession.RunTestsAsync( + _testCases, + _testSettings, + mockTestRunEventsHandler.Object) + .ConfigureAwait(false); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.RunTestsAsync( + _testCases, + _testSettings, + null, + _testSessionInfo, + mockTestRunEventsHandler.Object), + Times.Once); + } + + [TestMethod] + public async Task RunTestsAsyncWithTestCasesShouldCallConsoleWrapperRunTestsWithCorrectArguments2() + { + var testPlatformOptions = new TestPlatformOptions(); + var mockTestRunEventsHandler = new Mock(); + + await _testSession.RunTestsAsync( + _testCases, + _testSettings, + testPlatformOptions, + mockTestRunEventsHandler.Object) + .ConfigureAwait(false); ; + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.RunTestsAsync( + _testCases, + _testSettings, + testPlatformOptions, + _testSessionInfo, + mockTestRunEventsHandler.Object), + Times.Once); + } + + [TestMethod] + public async Task RunTestsAsyncWithSourcesAndCustomTesthostShouldCallConsoleWrapperRunTestsWithCorrectArguments1() + { + var mockTestRunEventsHandler = new Mock(); + var mockTestHostLauncher = new Mock(); + + await _testSession.RunTestsWithCustomTestHostAsync( + _testSources, + _testSettings, + mockTestRunEventsHandler.Object, + mockTestHostLauncher.Object) + .ConfigureAwait(false); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.RunTestsWithCustomTestHostAsync( + _testSources, + _testSettings, + null, + _testSessionInfo, + mockTestRunEventsHandler.Object, + mockTestHostLauncher.Object), + Times.Once); + } + + [TestMethod] + public async Task RunTestsAsyncWithSourcesAndCustomTesthostShouldCallConsoleWrapperRunTestsWithCorrectArguments2() + { + var testPlatformOptions = new TestPlatformOptions(); + var mockTestRunEventsHandler = new Mock(); + var mockTestHostLauncher = new Mock(); + + await _testSession.RunTestsWithCustomTestHostAsync( + _testSources, + _testSettings, + testPlatformOptions, + mockTestRunEventsHandler.Object, + mockTestHostLauncher.Object) + .ConfigureAwait(false); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.RunTestsWithCustomTestHostAsync( + _testSources, + _testSettings, + testPlatformOptions, + _testSessionInfo, + mockTestRunEventsHandler.Object, + mockTestHostLauncher.Object), + Times.Once); + } + + [TestMethod] + public async Task RunTestsAsyncWithTestCasesAndCustomTesthostShouldCallConsoleWrapperRunTestsWithCorrectArguments1() + { + var mockTestRunEventsHandler = new Mock(); + var mockTestHostLauncher = new Mock(); + + await _testSession.RunTestsWithCustomTestHostAsync( + _testCases, + _testSettings, + mockTestRunEventsHandler.Object, + mockTestHostLauncher.Object) + .ConfigureAwait(false); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.RunTestsWithCustomTestHostAsync( + _testCases, + _testSettings, + null, + _testSessionInfo, + mockTestRunEventsHandler.Object, + mockTestHostLauncher.Object), + Times.Once); + } + + [TestMethod] + public async Task RunTestsAsyncWithTestCasesAndCustomTesthostShouldCallConsoleWrapperRunTestsWithCorrectArguments2() + { + var testPlatformOptions = new TestPlatformOptions(); + var mockTestRunEventsHandler = new Mock(); + var mockTestHostLauncher = new Mock(); + + await _testSession.RunTestsWithCustomTestHostAsync( + _testCases, + _testSettings, + testPlatformOptions, + mockTestRunEventsHandler.Object, + mockTestHostLauncher.Object) + .ConfigureAwait(false); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.RunTestsWithCustomTestHostAsync( + _testCases, + _testSettings, + testPlatformOptions, + _testSessionInfo, + mockTestRunEventsHandler.Object, + mockTestHostLauncher.Object), + Times.Once); + } + + [TestMethod] + public async Task StopTestSessionAsyncShouldCallConsoleWrapperStopTestSessionWithCorrectArguments1() + { + await _testSession.StopTestSessionAsync().ConfigureAwait(false); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.StopTestSessionAsync( + _testSessionInfo, + _mockTestSessionEventsHandler.Object), + Times.Once); + } + + [TestMethod] + public async Task StopTestSessionAsyncShouldCallConsoleWrapperStopTestSessionWithCorrectArguments2() + { + var mockTestSessionEventsHandler2 = new Mock(); + + await _testSession.StopTestSessionAsync( + mockTestSessionEventsHandler2.Object) + .ConfigureAwait(false); + + _mockVsTestConsoleWrapper.Verify( + vtcw => vtcw.StopTestSessionAsync( + _testSessionInfo, + mockTestSessionEventsHandler2.Object), + Times.Once); } -} + #endregion +} \ No newline at end of file diff --git a/test/TranslationLayer.UnitTests/VsTestConsoleRequestSenderTests.cs b/test/TranslationLayer.UnitTests/VsTestConsoleRequestSenderTests.cs index 9759acdac3..4ccc08fa9d 100644 --- a/test/TranslationLayer.UnitTests/VsTestConsoleRequestSenderTests.cs +++ b/test/TranslationLayer.UnitTests/VsTestConsoleRequestSenderTests.cs @@ -1,2634 +1,2566 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.UnitTests +namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.UnitTests; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Threading; +using System.Threading.Tasks; + +using Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using VisualStudio.TestTools.UnitTesting; + +using Moq; + +using Newtonsoft.Json.Linq; + +using TestResult = VisualStudio.TestPlatform.ObjectModel.TestResult; +using Payloads = VisualStudio.TestPlatform.ObjectModel.Client.Payloads; + +[TestClass] +public class VsTestConsoleRequestSenderTests { - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Threading; - using System.Threading.Tasks; + private readonly ITranslationLayerRequestSender _requestSender; - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; + private readonly Mock _mockCommunicationManager; - using Moq; + private readonly int _waitTimeout = 2000; - using Newtonsoft.Json.Linq; + private readonly int _protocolVersion = 5; + private readonly IDataSerializer _serializer = JsonDataSerializer.Instance; - using TestResult = Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult; - using Payloads = Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; - using NuGet.Frameworks; - - [TestClass] - public class VsTestConsoleRequestSenderTests + public VsTestConsoleRequestSenderTests() { - private readonly ITranslationLayerRequestSender requestSender; + _mockCommunicationManager = new Mock(); + _requestSender = new VsTestConsoleRequestSender( + _mockCommunicationManager.Object, + JsonDataSerializer.Instance, + new Mock().Object); + } - private readonly Mock mockCommunicationManager; + #region Communication Tests - private readonly int WaitTimeout = 2000; + [TestMethod] + public void InitializeCommunicationShouldSucceed() + { + InitializeCommunication(); - private int protocolVersion = 5; - private IDataSerializer serializer = JsonDataSerializer.Instance; + _mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); + _mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); + _mockCommunicationManager.Verify(cm => cm.WaitForClientConnection(Timeout.Infinite), Times.Once); + _mockCommunicationManager.Verify(cm => cm.ReceiveMessage(), Times.Exactly(2)); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, _protocolVersion), Times.Once); + } - public VsTestConsoleRequestSenderTests() - { - this.mockCommunicationManager = new Mock(); - this.requestSender = new VsTestConsoleRequestSender( - this.mockCommunicationManager.Object, - JsonDataSerializer.Instance, - new Mock().Object); - } + [TestMethod] + public async Task InitializeCommunicationAsyncShouldSucceed() + { + await InitializeCommunicationAsync(); - #region Communication Tests + _mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); + _mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); + _mockCommunicationManager.Verify(cm => cm.ReceiveMessageAsync(It.IsAny()), Times.Exactly(2)); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, _protocolVersion), Times.Once); + } - [TestMethod] - public void InitializeCommunicationShouldSucceed() - { - this.InitializeCommunication(); + [TestMethod] + public void InitializeCommunicationShouldReturnInvalidPortNumberIfHostServerFails() + { + _mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Throws(new Exception("Fail")); + _mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)); - this.mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.WaitForClientConnection(Timeout.Infinite), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.ReceiveMessage(), Times.Exactly(2)); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, this.protocolVersion), Times.Once); - } + var portOutput = _requestSender.InitializeCommunication(); + Assert.IsTrue(portOutput < 0, "Negative port number must be returned if Hosting Server fails."); - [TestMethod] - public async Task InitializeCommunicationAsyncShouldSucceed() - { - await this.InitializeCommunicationAsync(); + var connectionSuccess = _requestSender.WaitForRequestHandlerConnection(_waitTimeout); + Assert.IsFalse(connectionSuccess, "Connection must fail as server failed to host."); - this.mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.ReceiveMessageAsync(It.IsAny()), Times.Exactly(2)); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, this.protocolVersion), Times.Once); - } + _mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); + _mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Never); + _mockCommunicationManager.Verify(cm => cm.WaitForClientConnection(Timeout.Infinite), Times.Never); + _mockCommunicationManager.Verify(cm => cm.ReceiveMessage(), Times.Never); + } - [TestMethod] - public void InitializeCommunicationShouldReturnInvalidPortNumberIfHostServerFails() - { - this.mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Throws(new Exception("Fail")); - this.mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)); + [TestMethod] + public async Task InitializeCommunicationAsyncShouldReturnInvalidPortNumberIfHostServerFails() + { + _mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Throws(new Exception("Fail")); + _mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)); - var portOutput = this.requestSender.InitializeCommunication(); - Assert.IsTrue(portOutput < 0, "Negative port number must be returned if Hosting Server fails."); + var portOutput = await _requestSender.InitializeCommunicationAsync(_waitTimeout); + Assert.IsTrue(portOutput < 0, "Negative port number must be returned if Hosting Server fails."); - var connectionSuccess = this.requestSender.WaitForRequestHandlerConnection(this.WaitTimeout); - Assert.IsFalse(connectionSuccess, "Connection must fail as server failed to host."); + _mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); + _mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Never); + _mockCommunicationManager.Verify(cm => cm.ReceiveMessageAsync(It.IsAny()), Times.Never); + } - this.mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Never); - this.mockCommunicationManager.Verify(cm => cm.WaitForClientConnection(Timeout.Infinite), Times.Never); - this.mockCommunicationManager.Verify(cm => cm.ReceiveMessage(), Times.Never); - } + [TestMethod] + public void InitializeCommunicationShouldFailConnectionIfMessageReceiveFailed() + { + var dummyPortInput = 123; + _mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); + _mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); + _mockCommunicationManager.Setup(cm => cm.WaitForClientConnection(Timeout.Infinite)) + .Callback((int timeout) => Task.Delay(200).Wait()); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessage()).Throws(new Exception("Fail")); + + var portOutput = _requestSender.InitializeCommunication(); + + // Hosting server didn't server, so port number should still be valid + Assert.AreEqual(dummyPortInput, portOutput, "Port number must return without changes."); + + // Connection must not succeed as handshake failed + var connectionSuccess = _requestSender.WaitForRequestHandlerConnection(_waitTimeout); + Assert.IsFalse(connectionSuccess, "Connection must fail if handshake failed."); + _mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); + _mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); + _mockCommunicationManager.Verify(cm => cm.WaitForClientConnection(Timeout.Infinite), Times.Once); + } - [TestMethod] - public async Task InitializeCommunicationAsyncShouldReturnInvalidPortNumberIfHostServerFails() - { - this.mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Throws(new Exception("Fail")); - this.mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)); + [TestMethod] + public async Task InitializeCommunicationAsyncShouldFailConnectionIfMessageReceiveFailed() + { + var dummyPortInput = 123; + _mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); + _mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).ThrowsAsync(new Exception("Fail")); - var portOutput = await this.requestSender.InitializeCommunicationAsync(this.WaitTimeout); - Assert.IsTrue(portOutput < 0, "Negative port number must be returned if Hosting Server fails."); + var portOutput = await _requestSender.InitializeCommunicationAsync(_waitTimeout); - this.mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Never); - this.mockCommunicationManager.Verify(cm => cm.ReceiveMessageAsync(It.IsAny()), Times.Never); - } + // Connection must not succeed as handshake failed + Assert.AreEqual(-1, portOutput, "Connection must fail if handshake failed."); + _mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); + _mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); + } - [TestMethod] - public void InitializeCommunicationShouldFailConnectionIfMessageReceiveFailed() - { - var dummyPortInput = 123; - this.mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); - this.mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); - this.mockCommunicationManager.Setup(cm => cm.WaitForClientConnection(Timeout.Infinite)) - .Callback((int timeout) => Task.Delay(200).Wait()); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessage()).Throws(new Exception("Fail")); - - var portOutput = this.requestSender.InitializeCommunication(); - - // Hosting server didn't server, so port number should still be valid - Assert.AreEqual(dummyPortInput, portOutput, "Port number must return without changes."); - - // Connection must not succeed as handshake failed - var connectionSuccess = this.requestSender.WaitForRequestHandlerConnection(this.WaitTimeout); - Assert.IsFalse(connectionSuccess, "Connection must fail if handshake failed."); - this.mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.WaitForClientConnection(Timeout.Infinite), Times.Once); - } - - [TestMethod] - public async Task InitializeCommunicationAsyncShouldFailConnectionIfMessageReceiveFailed() - { - var dummyPortInput = 123; - this.mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); - this.mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).ThrowsAsync(new Exception("Fail")); + [TestMethod] + public void InitializeCommunicationShouldFailConnectionIfSessionConnectedDidNotComeFirst() + { + var dummyPortInput = 123; + _mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); + _mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); + _mockCommunicationManager.Setup(cm => cm.WaitForClientConnection(Timeout.Infinite)) + .Callback((int timeout) => Task.Delay(200).Wait()); - var portOutput = await this.requestSender.InitializeCommunicationAsync(this.WaitTimeout); + var discoveryMessage = new Message() { MessageType = MessageType.StartDiscovery }; - // Connection must not succeed as handshake failed - Assert.AreEqual(-1, portOutput, "Connection must fail if handshake failed."); - this.mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); - } + _mockCommunicationManager.Setup(cm => cm.ReceiveMessage()).Returns(discoveryMessage); - [TestMethod] - public void InitializeCommunicationShouldFailConnectionIfSessionConnectedDidNotComeFirst() - { - var dummyPortInput = 123; - this.mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); - this.mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); - this.mockCommunicationManager.Setup(cm => cm.WaitForClientConnection(Timeout.Infinite)) - .Callback((int timeout) => Task.Delay(200).Wait()); + var portOutput = _requestSender.InitializeCommunication(); + Assert.AreEqual(dummyPortInput, portOutput, "Port number must return without changes."); + var connectionSuccess = _requestSender.WaitForRequestHandlerConnection(_waitTimeout); + Assert.IsFalse(connectionSuccess, "Connection must fail if version check failed."); - var discoveryMessage = new Message() { MessageType = MessageType.StartDiscovery }; + _mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); + _mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessage()).Returns(discoveryMessage); + _mockCommunicationManager.Verify(cm => cm.WaitForClientConnection(Timeout.Infinite), Times.Once); - var portOutput = this.requestSender.InitializeCommunication(); - Assert.AreEqual(dummyPortInput, portOutput, "Port number must return without changes."); - var connectionSuccess = this.requestSender.WaitForRequestHandlerConnection(this.WaitTimeout); - Assert.IsFalse(connectionSuccess, "Connection must fail if version check failed."); + _mockCommunicationManager.Verify(cm => cm.ReceiveMessage(), Times.Once); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, _protocolVersion), Times.Never); + } - this.mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); + [TestMethod] + public async Task InitializeCommunicationAsyncShouldFailConnectionIfSessionConnectedDidNotComeFirst() + { + var dummyPortInput = 123; + _mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); + _mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); - this.mockCommunicationManager.Verify(cm => cm.WaitForClientConnection(Timeout.Infinite), Times.Once); + var discoveryMessage = new Message() { MessageType = MessageType.StartDiscovery }; - this.mockCommunicationManager.Verify(cm => cm.ReceiveMessage(), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, this.protocolVersion), Times.Never); - } + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(discoveryMessage)); - [TestMethod] - public async Task InitializeCommunicationAsyncShouldFailConnectionIfSessionConnectedDidNotComeFirst() - { - var dummyPortInput = 123; - this.mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); - this.mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); + var portOutput = await _requestSender.InitializeCommunicationAsync(_waitTimeout); + Assert.AreEqual(-1, portOutput, "Connection must fail if version check failed."); - var discoveryMessage = new Message() { MessageType = MessageType.StartDiscovery }; + _mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); + _mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(discoveryMessage)); + _mockCommunicationManager.Verify(cm => cm.ReceiveMessageAsync(It.IsAny()), Times.Once); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, _protocolVersion), Times.Never); + } - var portOutput = await this.requestSender.InitializeCommunicationAsync(this.WaitTimeout); - Assert.AreEqual(-1, portOutput, "Connection must fail if version check failed."); + [TestMethod] + public void InitializeCommunicationShouldFailConnectionIfSendMessageFailed() + { + var dummyPortInput = 123; + _mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); + _mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); + _mockCommunicationManager.Setup(cm => cm.WaitForClientConnection(Timeout.Infinite)) + .Callback((int timeout) => Task.Delay(200).Wait()); - this.mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); + var sessionConnected = new Message() { MessageType = MessageType.SessionConnected }; - this.mockCommunicationManager.Verify(cm => cm.ReceiveMessageAsync(It.IsAny()), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, this.protocolVersion), Times.Never); - } + _mockCommunicationManager.Setup(cm => cm.ReceiveMessage()).Returns(sessionConnected); + _mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.VersionCheck, _protocolVersion)).Throws(new Exception("Fail")); - [TestMethod] - public void InitializeCommunicationShouldFailConnectionIfSendMessageFailed() - { - var dummyPortInput = 123; - this.mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); - this.mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); - this.mockCommunicationManager.Setup(cm => cm.WaitForClientConnection(Timeout.Infinite)) - .Callback((int timeout) => Task.Delay(200).Wait()); + var portOutput = _requestSender.InitializeCommunication(); + Assert.AreEqual(dummyPortInput, portOutput, "Port number must return without changes."); + var connectionSuccess = _requestSender.WaitForRequestHandlerConnection(_waitTimeout); + Assert.IsFalse(connectionSuccess, "Connection must fail if version check failed."); - var sessionConnected = new Message() { MessageType = MessageType.SessionConnected }; + _mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); + _mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessage()).Returns(sessionConnected); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.VersionCheck, this.protocolVersion)).Throws(new Exception("Fail")); + _mockCommunicationManager.Verify(cm => cm.WaitForClientConnection(Timeout.Infinite), Times.Once); - var portOutput = this.requestSender.InitializeCommunication(); - Assert.AreEqual(dummyPortInput, portOutput, "Port number must return without changes."); - var connectionSuccess = this.requestSender.WaitForRequestHandlerConnection(this.WaitTimeout); - Assert.IsFalse(connectionSuccess, "Connection must fail if version check failed."); + _mockCommunicationManager.Verify(cm => cm.ReceiveMessage(), Times.Once); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, _protocolVersion), Times.Once); + } - this.mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); + [TestMethod] + public async Task InitializeCommunicationAsyncShouldFailConnectionIfSendMessageFailed() + { + var dummyPortInput = 123; + _mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); + _mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); - this.mockCommunicationManager.Verify(cm => cm.WaitForClientConnection(Timeout.Infinite), Times.Once); + var sessionConnected = new Message() { MessageType = MessageType.SessionConnected }; - this.mockCommunicationManager.Verify(cm => cm.ReceiveMessage(), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, this.protocolVersion), Times.Once); - } + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(sessionConnected)); + _mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.VersionCheck, _protocolVersion)).Throws(new Exception("Fail")); - [TestMethod] - public async Task InitializeCommunicationAsyncShouldFailConnectionIfSendMessageFailed() - { - var dummyPortInput = 123; - this.mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); - this.mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); + var portOutput = await _requestSender.InitializeCommunicationAsync(_waitTimeout); + Assert.AreEqual(-1, portOutput, "Connection must fail if version check failed."); - var sessionConnected = new Message() { MessageType = MessageType.SessionConnected }; + _mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); + _mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(sessionConnected)); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.VersionCheck, this.protocolVersion)).Throws(new Exception("Fail")); + _mockCommunicationManager.Verify(cm => cm.ReceiveMessageAsync(It.IsAny()), Times.Once); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, _protocolVersion), Times.Once); + } - var portOutput = await this.requestSender.InitializeCommunicationAsync(this.WaitTimeout); - Assert.AreEqual(-1, portOutput, "Connection must fail if version check failed."); + [TestMethod] + public void InitializeCommunicationShouldFailConnectionIfProtocolIsNotCompatible() + { + var dummyPortInput = 123; + _mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); + _mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); - this.mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); + _mockCommunicationManager.Setup(cm => cm.WaitForClientConnection(Timeout.Infinite)) + .Callback((int timeout) => Task.Delay(200).Wait()); - this.mockCommunicationManager.Verify(cm => cm.ReceiveMessageAsync(It.IsAny()), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, this.protocolVersion), Times.Once); - } + var sessionConnected = new Message() { MessageType = MessageType.SessionConnected }; - [TestMethod] - public void InitializeCommunicationShouldFailConnectionIfProtocolIsNotCompatible() + // Give wrong version + var protocolError = new Message() { - var dummyPortInput = 123; - this.mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); - this.mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); - - this.mockCommunicationManager.Setup(cm => cm.WaitForClientConnection(Timeout.Infinite)) - .Callback((int timeout) => Task.Delay(200).Wait()); + MessageType = MessageType.ProtocolError, + Payload = null + }; - var sessionConnected = new Message() { MessageType = MessageType.SessionConnected }; + Action changedMessage = + () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessage()).Returns(protocolError); - // Give wrong version - var protocolError = new Message() - { - MessageType = MessageType.ProtocolError, - Payload = null - }; + _mockCommunicationManager.Setup(cm => cm.ReceiveMessage()).Returns(sessionConnected); + _mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.VersionCheck)).Callback(changedMessage); - Action changedMessage = - () => { this.mockCommunicationManager.Setup(cm => cm.ReceiveMessage()).Returns(protocolError); }; + var portOutput = _requestSender.InitializeCommunication(); + Assert.AreEqual(dummyPortInput, portOutput, "Port number must return without changes."); + var connectionSuccess = _requestSender.WaitForRequestHandlerConnection(_waitTimeout); + Assert.IsFalse(connectionSuccess, "Connection must fail if version check failed."); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessage()).Returns(sessionConnected); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.VersionCheck)).Callback(changedMessage); + _mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); + _mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); - var portOutput = this.requestSender.InitializeCommunication(); - Assert.AreEqual(dummyPortInput, portOutput, "Port number must return without changes."); - var connectionSuccess = this.requestSender.WaitForRequestHandlerConnection(this.WaitTimeout); - Assert.IsFalse(connectionSuccess, "Connection must fail if version check failed."); + _mockCommunicationManager.Verify(cm => cm.WaitForClientConnection(Timeout.Infinite), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); + _mockCommunicationManager.Verify(cm => cm.ReceiveMessage(), Times.Exactly(2)); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, _protocolVersion), Times.Once); + } - this.mockCommunicationManager.Verify(cm => cm.WaitForClientConnection(Timeout.Infinite), Times.Once); + [TestMethod] + public async Task InitializeCommunicationAsyncShouldFailConnectionIfProtocolIsNotCompatible() + { + var dummyPortInput = 123; + _mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); + _mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); - this.mockCommunicationManager.Verify(cm => cm.ReceiveMessage(), Times.Exactly(2)); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, this.protocolVersion), Times.Once); - } + var sessionConnected = new Message() { MessageType = MessageType.SessionConnected }; - [TestMethod] - public async Task InitializeCommunicationAsyncShouldFailConnectionIfProtocolIsNotCompatible() + // Give wrong version + var protocolError = new Message() { - var dummyPortInput = 123; - this.mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); - this.mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); + MessageType = MessageType.ProtocolError, + Payload = null + }; - var sessionConnected = new Message() { MessageType = MessageType.SessionConnected }; + Action changedMessage = + () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(protocolError)); - // Give wrong version - var protocolError = new Message() - { - MessageType = MessageType.ProtocolError, - Payload = null - }; + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(sessionConnected)); + _mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.VersionCheck)).Callback(changedMessage); - Action changedMessage = - () => { this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(protocolError)); }; + var portOutput = await _requestSender.InitializeCommunicationAsync(_waitTimeout); + Assert.AreEqual(-1, portOutput, "Connection must fail if version check failed."); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(sessionConnected)); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.VersionCheck)).Callback(changedMessage); + _mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); + _mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); - var portOutput = await this.requestSender.InitializeCommunicationAsync(this.WaitTimeout); - Assert.AreEqual(-1, portOutput, "Connection must fail if version check failed."); + _mockCommunicationManager.Verify(cm => cm.ReceiveMessageAsync(It.IsAny()), Times.Exactly(2)); + _mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, _protocolVersion), Times.Once); + } - this.mockCommunicationManager.Verify(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); - this.mockCommunicationManager.Verify(cm => cm.AcceptClientAsync(), Times.Once); + #endregion - this.mockCommunicationManager.Verify(cm => cm.ReceiveMessageAsync(It.IsAny()), Times.Exactly(2)); - this.mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.VersionCheck, this.protocolVersion), Times.Once); - } + #region Discovery Tests - #endregion + [TestMethod] + public void DiscoverTestsShouldCompleteWithZeroTests() + { + InitializeCommunication(); - #region Discovery Tests + var mockHandler = new Mock(); - [TestMethod] - public void DiscoverTestsShouldCompleteWithZeroTests() + var payload = new DiscoveryCompletePayload() { TotalTests = 0, LastDiscoveredTests = null, IsAborted = false }; + var discoveryComplete = new Message() { - this.InitializeCommunication(); + MessageType = MessageType.DiscoveryComplete, + Payload = JToken.FromObject(payload) + }; + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(discoveryComplete)); - var mockHandler = new Mock(); + _requestSender.DiscoverTests(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); - var payload = new DiscoveryCompletePayload() { TotalTests = 0, LastDiscoveredTests = null, IsAborted = false }; - var discoveryComplete = new Message() - { - MessageType = MessageType.DiscoveryComplete, - Payload = JToken.FromObject(payload) - }; - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(discoveryComplete)); + mockHandler.Verify(mh => mh.HandleDiscoveryComplete(It.IsAny(), null), Times.Once, "Discovery Complete must be called"); + mockHandler.Verify(mh => mh.HandleDiscoveredTests(It.IsAny>()), Times.Never, "DiscoveredTests must not be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); + } - this.requestSender.DiscoverTests(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); + [TestMethod] + public async Task DiscoverTestsAsyncShouldCompleteWithZeroTests() + { + await InitializeCommunicationAsync(); - mockHandler.Verify(mh => mh.HandleDiscoveryComplete(It.IsAny(), null), Times.Once, "Discovery Complete must be called"); - mockHandler.Verify(mh => mh.HandleDiscoveredTests(It.IsAny>()), Times.Never, "DiscoveredTests must not be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); - } + var mockHandler = new Mock(); - [TestMethod] - public async Task DiscoverTestsAsyncShouldCompleteWithZeroTests() + var payload = new DiscoveryCompletePayload() { TotalTests = 0, LastDiscoveredTests = null, IsAborted = false }; + var discoveryComplete = new Message() { - await this.InitializeCommunicationAsync(); + MessageType = MessageType.DiscoveryComplete, + Payload = JToken.FromObject(payload) + }; + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(discoveryComplete)); - var mockHandler = new Mock(); + await _requestSender.DiscoverTestsAsync(new List() { "1.dll" }, null, null, null, mockHandler.Object); - var payload = new DiscoveryCompletePayload() { TotalTests = 0, LastDiscoveredTests = null, IsAborted = false }; - var discoveryComplete = new Message() - { - MessageType = MessageType.DiscoveryComplete, - Payload = JToken.FromObject(payload) - }; - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(discoveryComplete)); + mockHandler.Verify(mh => mh.HandleDiscoveryComplete(It.IsAny(), null), Times.Once, "Discovery Complete must be called"); + mockHandler.Verify(mh => mh.HandleDiscoveredTests(It.IsAny>()), Times.Never, "DiscoveredTests must not be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); + } - await this.requestSender.DiscoverTestsAsync(new List() { "1.dll" }, null, null, null, mockHandler.Object); + [TestMethod] + public void DiscoverTestsShouldCompleteWithSingleTest() + { + InitializeCommunication(); - mockHandler.Verify(mh => mh.HandleDiscoveryComplete(It.IsAny(), null), Times.Once, "Discovery Complete must be called"); - mockHandler.Verify(mh => mh.HandleDiscoveredTests(It.IsAny>()), Times.Never, "DiscoveredTests must not be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); - } + var mockHandler = new Mock(); - [TestMethod] - public void DiscoverTestsShouldCompleteWithSingleTest() + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + var testCaseList = new List() { testCase }; + var testsFound = new Message() { - this.InitializeCommunication(); + MessageType = MessageType.TestCasesFound, + Payload = JToken.FromObject(testCaseList) + }; - var mockHandler = new Mock(); + var payload = new DiscoveryCompletePayload() { TotalTests = 1, LastDiscoveredTests = null, IsAborted = false }; + var discoveryComplete = new Message() + { + MessageType = MessageType.DiscoveryComplete, + Payload = JToken.FromObject(payload) + }; - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - var testCaseList = new List() { testCase }; - var testsFound = new Message() - { - MessageType = MessageType.TestCasesFound, - Payload = JToken.FromObject(testCaseList) - }; + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsFound)); + mockHandler.Setup(mh => mh.HandleDiscoveredTests(It.IsAny>())).Callback( + () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(discoveryComplete))); - var payload = new DiscoveryCompletePayload() { TotalTests = 1, LastDiscoveredTests = null, IsAborted = false }; - var discoveryComplete = new Message() - { - MessageType = MessageType.DiscoveryComplete, - Payload = JToken.FromObject(payload) - }; + _requestSender.DiscoverTests(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsFound)); - mockHandler.Setup(mh => mh.HandleDiscoveredTests(It.IsAny>())).Callback( - () => this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(discoveryComplete))); + mockHandler.Verify(mh => mh.HandleDiscoveryComplete(It.IsAny(), null), Times.Once, "Discovery Complete must be called"); + mockHandler.Verify(mh => mh.HandleDiscoveredTests(It.IsAny>()), Times.Once, "DiscoveredTests must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); + } - this.requestSender.DiscoverTests(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); + [TestMethod] + public async Task DiscoverTestsAsyncShouldCompleteWithSingleTest() + { + await InitializeCommunicationAsync(); - mockHandler.Verify(mh => mh.HandleDiscoveryComplete(It.IsAny(), null), Times.Once, "Discovery Complete must be called"); - mockHandler.Verify(mh => mh.HandleDiscoveredTests(It.IsAny>()), Times.Once, "DiscoveredTests must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); - } + var mockHandler = new Mock(); - [TestMethod] - public async Task DiscoverTestsAsyncShouldCompleteWithSingleTest() + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + var testCaseList = new List() { testCase }; + var testsFound = new Message() { - await this.InitializeCommunicationAsync(); + MessageType = MessageType.TestCasesFound, + Payload = JToken.FromObject(testCaseList) + }; - var mockHandler = new Mock(); + var payload = new DiscoveryCompletePayload() { TotalTests = 1, LastDiscoveredTests = null, IsAborted = false }; + var discoveryComplete = new Message() + { + MessageType = MessageType.DiscoveryComplete, + Payload = JToken.FromObject(payload) + }; - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - var testCaseList = new List() { testCase }; - var testsFound = new Message() - { - MessageType = MessageType.TestCasesFound, - Payload = JToken.FromObject(testCaseList) - }; + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsFound)); + mockHandler.Setup(mh => mh.HandleDiscoveredTests(It.IsAny>())).Callback( + () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(discoveryComplete))); - var payload = new DiscoveryCompletePayload() { TotalTests = 1, LastDiscoveredTests = null, IsAborted = false }; - var discoveryComplete = new Message() - { - MessageType = MessageType.DiscoveryComplete, - Payload = JToken.FromObject(payload) - }; + await _requestSender.DiscoverTestsAsync(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); + + mockHandler.Verify(mh => mh.HandleDiscoveryComplete(It.IsAny(), null), Times.Once, "Discovery Complete must be called"); + mockHandler.Verify(mh => mh.HandleDiscoveredTests(It.IsAny>()), Times.Once, "DiscoveredTests must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); + } - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsFound)); - mockHandler.Setup(mh => mh.HandleDiscoveredTests(It.IsAny>())).Callback( - () => this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(discoveryComplete))); + [TestMethod] + public void DiscoverTestsShouldReportBackTestsWithTraitsInTestsFoundMessage() + { + InitializeCommunication(); - await this.requestSender.DiscoverTestsAsync(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); + var mockHandler = new Mock(); - mockHandler.Verify(mh => mh.HandleDiscoveryComplete(It.IsAny(), null), Times.Once, "Discovery Complete must be called"); - mockHandler.Verify(mh => mh.HandleDiscoveredTests(It.IsAny>()), Times.Once, "DiscoveredTests must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); - } + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + testCase.Traits.Add(new Trait("a", "b")); - [TestMethod] - public void DiscoverTestsShouldReportBackTestsWithTraitsInTestsFoundMessage() - { - this.InitializeCommunication(); + List receivedTestCases = null; + var testCaseList = new List() { testCase }; + var testsFound = CreateMessage(MessageType.TestCasesFound, testCaseList); - var mockHandler = new Mock(); + var payload = new DiscoveryCompletePayload() { TotalTests = 1, LastDiscoveredTests = null, IsAborted = false }; + var discoveryComplete = CreateMessage(MessageType.DiscoveryComplete, payload); - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - testCase.Traits.Add(new Trait("a", "b")); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsFound)); + mockHandler.Setup(mh => mh.HandleDiscoveredTests(It.IsAny>())) + .Callback( + (IEnumerable tests) => + { + receivedTestCases = tests?.ToList(); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult((discoveryComplete))); + }); + + _requestSender.DiscoverTests(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); - List receivedTestCases = null; - var testCaseList = new List() { testCase }; - var testsFound = CreateMessage(MessageType.TestCasesFound, testCaseList); + Assert.IsNotNull(receivedTestCases); + Assert.AreEqual(1, receivedTestCases.Count); - var payload = new DiscoveryCompletePayload() { TotalTests = 1, LastDiscoveredTests = null, IsAborted = false }; - var discoveryComplete = CreateMessage(MessageType.DiscoveryComplete, payload); + // Verify that the traits are passed through properly. + var traits = receivedTestCases.ToArray()[0].Traits; + Assert.IsNotNull(traits); + Assert.AreEqual("a", traits.ToArray()[0].Name); + Assert.AreEqual("b", traits.ToArray()[0].Value); + } - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsFound)); - mockHandler.Setup(mh => mh.HandleDiscoveredTests(It.IsAny>())) - .Callback( - (IEnumerable tests) => - { - receivedTestCases = tests?.ToList(); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult((discoveryComplete))); - }); + [TestMethod] + public async Task DiscoverTestsAsyncShouldReportBackTestsWithTraitsInTestsFoundMessage() + { + await InitializeCommunicationAsync(); - this.requestSender.DiscoverTests(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); + var mockHandler = new Mock(); - Assert.IsNotNull(receivedTestCases); - Assert.AreEqual(1, receivedTestCases.Count); + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + testCase.Traits.Add(new Trait("a", "b")); - // Verify that the traits are passed through properly. - var traits = receivedTestCases.ToArray()[0].Traits; - Assert.IsNotNull(traits); - Assert.AreEqual("a", traits.ToArray()[0].Name); - Assert.AreEqual("b", traits.ToArray()[0].Value); - } + List receivedTestCases = null; + var testCaseList = new List() { testCase }; + var testsFound = CreateMessage(MessageType.TestCasesFound, testCaseList); - [TestMethod] - public async Task DiscoverTestsAsyncShouldReportBackTestsWithTraitsInTestsFoundMessage() - { - await this.InitializeCommunicationAsync(); + var payload = new DiscoveryCompletePayload() { TotalTests = 1, LastDiscoveredTests = null, IsAborted = false }; + var discoveryComplete = CreateMessage(MessageType.DiscoveryComplete, payload); - var mockHandler = new Mock(); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsFound)); + mockHandler.Setup(mh => mh.HandleDiscoveredTests(It.IsAny>())) + .Callback( + (IEnumerable tests) => + { + receivedTestCases = tests?.ToList(); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult((discoveryComplete))); + }); - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - testCase.Traits.Add(new Trait("a", "b")); + await _requestSender.DiscoverTestsAsync(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); - List receivedTestCases = null; - var testCaseList = new List() { testCase }; - var testsFound = CreateMessage(MessageType.TestCasesFound, testCaseList); + Assert.IsNotNull(receivedTestCases); + Assert.AreEqual(1, receivedTestCases.Count); - var payload = new DiscoveryCompletePayload() { TotalTests = 1, LastDiscoveredTests = null, IsAborted = false }; - var discoveryComplete = CreateMessage(MessageType.DiscoveryComplete, payload); + // Verify that the traits are passed through properly. + var traits = receivedTestCases.ToArray()[0].Traits; + Assert.IsNotNull(traits); + Assert.AreEqual("a", traits.ToArray()[0].Name); + Assert.AreEqual("b", traits.ToArray()[0].Value); + } - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsFound)); - mockHandler.Setup(mh => mh.HandleDiscoveredTests(It.IsAny>())) - .Callback( - (IEnumerable tests) => - { - receivedTestCases = tests?.ToList(); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult((discoveryComplete))); - }); + [TestMethod] + public void DiscoverTestsShouldReportBackTestsWithTraitsInDiscoveryCompleteMessage() + { + InitializeCommunication(); - await this.requestSender.DiscoverTestsAsync(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); + var mockHandler = new Mock(); - Assert.IsNotNull(receivedTestCases); - Assert.AreEqual(1, receivedTestCases.Count); + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + testCase.Traits.Add(new Trait("a", "b")); - // Verify that the traits are passed through properly. - var traits = receivedTestCases.ToArray()[0].Traits; - Assert.IsNotNull(traits); - Assert.AreEqual("a", traits.ToArray()[0].Name); - Assert.AreEqual("b", traits.ToArray()[0].Value); - } + List receivedTestCases = null; + var testCaseList = new List() { testCase }; - [TestMethod] - public void DiscoverTestsShouldReportBackTestsWithTraitsInDiscoveryCompleteMessage() - { - this.InitializeCommunication(); + var payload = new DiscoveryCompletePayload() { TotalTests = 1, LastDiscoveredTests = testCaseList, IsAborted = false }; + var discoveryComplete = CreateMessage(MessageType.DiscoveryComplete, payload); - var mockHandler = new Mock(); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(discoveryComplete)); + mockHandler.Setup(mh => mh.HandleDiscoveryComplete(It.IsAny(), It.IsAny>())) + .Callback( + (DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable tests) => receivedTestCases = tests?.ToList()); - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - testCase.Traits.Add(new Trait("a", "b")); + _requestSender.DiscoverTests(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); - List receivedTestCases = null; - var testCaseList = new List() { testCase }; + Assert.IsNotNull(receivedTestCases); + Assert.AreEqual(1, receivedTestCases.Count); - var payload = new DiscoveryCompletePayload() { TotalTests = 1, LastDiscoveredTests = testCaseList, IsAborted = false }; - var discoveryComplete = CreateMessage(MessageType.DiscoveryComplete, payload); + // Verify that the traits are passed through properly. + var traits = receivedTestCases.ToArray()[0].Traits; + Assert.IsNotNull(traits); + Assert.AreEqual("a", traits.ToArray()[0].Name); + Assert.AreEqual("b", traits.ToArray()[0].Value); + } - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(discoveryComplete)); - mockHandler.Setup(mh => mh.HandleDiscoveryComplete(It.IsAny(), It.IsAny>())) - .Callback( - (DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable tests) => - { - receivedTestCases = tests?.ToList(); - }); + [TestMethod] + public async Task DiscoverTestsAsyncShouldReportBackTestsWithTraitsInDiscoveryCompleteMessage() + { + await InitializeCommunicationAsync(); - this.requestSender.DiscoverTests(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); + var mockHandler = new Mock(); - Assert.IsNotNull(receivedTestCases); - Assert.AreEqual(1, receivedTestCases.Count); + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + testCase.Traits.Add(new Trait("a", "b")); - // Verify that the traits are passed through properly. - var traits = receivedTestCases.ToArray()[0].Traits; - Assert.IsNotNull(traits); - Assert.AreEqual("a", traits.ToArray()[0].Name); - Assert.AreEqual("b", traits.ToArray()[0].Value); - } + List receivedTestCases = null; + var testCaseList = new List() { testCase }; - [TestMethod] - public async Task DiscoverTestsAsyncShouldReportBackTestsWithTraitsInDiscoveryCompleteMessage() - { - await this.InitializeCommunicationAsync(); + var payload = new DiscoveryCompletePayload() { TotalTests = 1, LastDiscoveredTests = testCaseList, IsAborted = false }; + var discoveryComplete = CreateMessage(MessageType.DiscoveryComplete, payload); - var mockHandler = new Mock(); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(discoveryComplete)); + mockHandler.Setup(mh => mh.HandleDiscoveryComplete(It.IsAny(), It.IsAny>())) + .Callback( + (DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable tests) => receivedTestCases = tests?.ToList()); - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - testCase.Traits.Add(new Trait("a", "b")); + await _requestSender.DiscoverTestsAsync(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); - List receivedTestCases = null; - var testCaseList = new List() { testCase }; + Assert.IsNotNull(receivedTestCases); + Assert.AreEqual(1, receivedTestCases.Count); - var payload = new DiscoveryCompletePayload() { TotalTests = 1, LastDiscoveredTests = testCaseList, IsAborted = false }; - var discoveryComplete = CreateMessage(MessageType.DiscoveryComplete, payload); + // Verify that the traits are passed through properly. + var traits = receivedTestCases.ToArray()[0].Traits; + Assert.IsNotNull(traits); + Assert.AreEqual("a", traits.ToArray()[0].Name); + Assert.AreEqual("b", traits.ToArray()[0].Value); + } - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(discoveryComplete)); - mockHandler.Setup(mh => mh.HandleDiscoveryComplete(It.IsAny(), It.IsAny>())) - .Callback( - (DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable tests) => - { - receivedTestCases = tests?.ToList(); - }); + [TestMethod] + public void DiscoverTestsShouldCompleteWithTestMessage() + { + InitializeCommunication(); - await this.requestSender.DiscoverTestsAsync(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); + var mockHandler = new Mock(); - Assert.IsNotNull(receivedTestCases); - Assert.AreEqual(1, receivedTestCases.Count); + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + var testCaseList = new List() { testCase }; + var testsFound = CreateMessage(MessageType.TestCasesFound, testCaseList); - // Verify that the traits are passed through properly. - var traits = receivedTestCases.ToArray()[0].Traits; - Assert.IsNotNull(traits); - Assert.AreEqual("a", traits.ToArray()[0].Name); - Assert.AreEqual("b", traits.ToArray()[0].Value); - } + var payload = new DiscoveryCompletePayload() { TotalTests = 1, LastDiscoveredTests = null, IsAborted = false }; + var discoveryComplete = CreateMessage(MessageType.DiscoveryComplete, payload); - [TestMethod] - public void DiscoverTestsShouldCompleteWithTestMessage() - { - this.InitializeCommunication(); + var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; + var message = CreateMessage(MessageType.TestMessage, mpayload); - var mockHandler = new Mock(); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsFound)); + mockHandler.Setup(mh => mh.HandleDiscoveredTests(It.IsAny>())).Callback( + () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message))); + mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( + () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(discoveryComplete))); - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - var testCaseList = new List() { testCase }; - var testsFound = CreateMessage(MessageType.TestCasesFound, testCaseList); + _requestSender.DiscoverTests(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); - var payload = new DiscoveryCompletePayload() { TotalTests = 1, LastDiscoveredTests = null, IsAborted = false }; - var discoveryComplete = CreateMessage(MessageType.DiscoveryComplete, payload); + mockHandler.Verify(mh => mh.HandleDiscoveryComplete(It.IsAny(), null), Times.Once, "Discovery Complete must be called"); + mockHandler.Verify(mh => mh.HandleDiscoveredTests(It.IsAny>()), Times.Once, "DiscoveredTests must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Informational, "Hello"), Times.Once, "TestMessage event must be called"); + } - var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; - var message = CreateMessage(MessageType.TestMessage, mpayload); + [TestMethod] + public async Task DiscoverTestsAsyncShouldCompleteWithTestMessage() + { + await InitializeCommunicationAsync(); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsFound)); - mockHandler.Setup(mh => mh.HandleDiscoveredTests(It.IsAny>())).Callback( - () => this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message))); - mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( - () => this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(discoveryComplete))); + var mockHandler = new Mock(); - this.requestSender.DiscoverTests(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + var testCaseList = new List() { testCase }; + var testsFound = CreateMessage(MessageType.TestCasesFound, testCaseList); - mockHandler.Verify(mh => mh.HandleDiscoveryComplete(It.IsAny(), null), Times.Once, "Discovery Complete must be called"); - mockHandler.Verify(mh => mh.HandleDiscoveredTests(It.IsAny>()), Times.Once, "DiscoveredTests must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Informational, "Hello"), Times.Once, "TestMessage event must be called"); - } + var payload = new DiscoveryCompletePayload() { TotalTests = 1, LastDiscoveredTests = null, IsAborted = false }; + var discoveryComplete = CreateMessage(MessageType.DiscoveryComplete, payload); - [TestMethod] - public async Task DiscoverTestsAsyncShouldCompleteWithTestMessage() - { - await this.InitializeCommunicationAsync(); + var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; + var message = CreateMessage(MessageType.TestMessage, mpayload); - var mockHandler = new Mock(); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsFound)); + mockHandler.Setup(mh => mh.HandleDiscoveredTests(It.IsAny>())).Callback( + () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message))); + mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( + () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(discoveryComplete))); - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - var testCaseList = new List() { testCase }; - var testsFound = CreateMessage(MessageType.TestCasesFound, testCaseList); + await _requestSender.DiscoverTestsAsync(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); - var payload = new DiscoveryCompletePayload() { TotalTests = 1, LastDiscoveredTests = null, IsAborted = false }; - var discoveryComplete = CreateMessage(MessageType.DiscoveryComplete, payload); + mockHandler.Verify(mh => mh.HandleDiscoveryComplete(It.IsAny(), null), Times.Once, "Discovery Complete must be called"); + mockHandler.Verify(mh => mh.HandleDiscoveredTests(It.IsAny>()), Times.Once, "DiscoveredTests must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Informational, "Hello"), Times.Once, "TestMessage event must be called"); + } - var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; - var message = CreateMessage(MessageType.TestMessage, mpayload); + [TestMethod] + public void DiscoverTestsShouldAbortOnExceptionInSendMessage() + { + var mockHandler = new Mock(); + var sources = new List { "1.dll" }; + var payload = new DiscoveryRequestPayload { Sources = sources, RunSettings = null }; + _mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.StartDiscovery, payload)).Throws(new IOException()); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsFound)); - mockHandler.Setup(mh => mh.HandleDiscoveredTests(It.IsAny>())).Callback( - () => this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message))); - mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( - () => this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(discoveryComplete))); + _requestSender.DiscoverTests(sources, null, new TestPlatformOptions(), null, mockHandler.Object); - await this.requestSender.DiscoverTestsAsync(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); + mockHandler.Verify(mh => mh.HandleDiscoveryComplete(It.IsAny(), null), Times.Once, "Discovery Complete must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once, "TestMessage event must be called"); + _mockCommunicationManager.Verify(cm => cm.StopServer(), Times.Never); + } - mockHandler.Verify(mh => mh.HandleDiscoveryComplete(It.IsAny(), null), Times.Once, "Discovery Complete must be called"); - mockHandler.Verify(mh => mh.HandleDiscoveredTests(It.IsAny>()), Times.Once, "DiscoveredTests must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Informational, "Hello"), Times.Once, "TestMessage event must be called"); - } + [TestMethod] + public async Task DiscoverTestsAsyncShouldAbortOnExceptionInSendMessage() + { + var mockHandler = new Mock(); + var sources = new List { "1.dll" }; + var payload = new DiscoveryRequestPayload { Sources = sources, RunSettings = null }; + _mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.StartDiscovery, payload)).Throws(new IOException()); - [TestMethod] - public void DiscoverTestsShouldAbortOnExceptionInSendMessage() - { - var mockHandler = new Mock(); - var sources = new List { "1.dll" }; - var payload = new DiscoveryRequestPayload { Sources = sources, RunSettings = null }; - this.mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.StartDiscovery, payload)).Throws(new IOException()); + await _requestSender.DiscoverTestsAsync(sources, null, new TestPlatformOptions(), null, mockHandler.Object); - this.requestSender.DiscoverTests(sources, null, new TestPlatformOptions(), null, mockHandler.Object); + mockHandler.Verify(mh => mh.HandleDiscoveryComplete(It.IsAny(), null), Times.Once, "Discovery Complete must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once, "TestMessage event must be called"); + _mockCommunicationManager.Verify(cm => cm.StopServer(), Times.Never); + } - mockHandler.Verify(mh => mh.HandleDiscoveryComplete(It.IsAny(), null), Times.Once, "Discovery Complete must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once, "TestMessage event must be called"); - this.mockCommunicationManager.Verify(cm => cm.StopServer(), Times.Never); - } + [TestMethod] + public void DiscoverTestsShouldLogErrorWhenProcessExited() + { + var mockHandler = new Mock(); + var sources = new List { "1.dll" }; + var payload = new DiscoveryRequestPayload { Sources = sources, RunSettings = null }; + var manualEvent = new ManualResetEvent(false); - [TestMethod] - public async Task DiscoverTestsAsyncShouldAbortOnExceptionInSendMessage() - { - var mockHandler = new Mock(); - var sources = new List { "1.dll" }; - var payload = new DiscoveryRequestPayload { Sources = sources, RunSettings = null }; - this.mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.StartDiscovery, payload)).Throws(new IOException()); + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + var testCaseList = new List() { testCase }; + var testsFound = CreateMessage(MessageType.TestCasesFound, testCaseList); + _requestSender.InitializeCommunication(); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Callback( + (CancellationToken c) => + { + Task.Run(() => _requestSender.OnProcessExited()).Wait(); - await this.requestSender.DiscoverTestsAsync(sources, null, new TestPlatformOptions(), null, mockHandler.Object); + Assert.IsTrue(c.IsCancellationRequested); + }).Returns(Task.FromResult((Message)null)); - mockHandler.Verify(mh => mh.HandleDiscoveryComplete(It.IsAny(), null), Times.Once, "Discovery Complete must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once, "TestMessage event must be called"); - this.mockCommunicationManager.Verify(cm => cm.StopServer(), Times.Never); - } + mockHandler.Setup(mh => mh.HandleDiscoveryComplete(It.IsAny(), null)).Callback(() => manualEvent.Set()); - [TestMethod] - public void DiscoverTestsShouldLogErrorWhenProcessExited() - { - var mockHandler = new Mock(); - var sources = new List { "1.dll" }; - var payload = new DiscoveryRequestPayload { Sources = sources, RunSettings = null }; - var manualEvent = new ManualResetEvent(false); - - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - var testCaseList = new List() { testCase }; - var testsFound = CreateMessage(MessageType.TestCasesFound, testCaseList); - this.requestSender.InitializeCommunication(); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Callback( - (CancellationToken c) => - { - Task.Run(() => this.requestSender.OnProcessExited()).Wait(); + _requestSender.DiscoverTests(sources, null, new TestPlatformOptions(), null, mockHandler.Object); + + manualEvent.WaitOne(); + mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); + } - Assert.IsTrue(c.IsCancellationRequested); - }).Returns(Task.FromResult((Message)null)); + [TestMethod] + public async Task DiscoverTestsAsyncShouldLogErrorWhenProcessExited() + { + var mockHandler = new Mock(); + var sources = new List { "1.dll" }; + var payload = new DiscoveryRequestPayload { Sources = sources, RunSettings = null }; - mockHandler.Setup(mh => mh.HandleDiscoveryComplete(It.IsAny(), null)).Callback(() => manualEvent.Set()); + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + var testCaseList = new List() { testCase }; + var testsFound = CreateMessage(MessageType.TestCasesFound, testCaseList); + await _requestSender.InitializeCommunicationAsync(_waitTimeout); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Callback( + (CancellationToken c) => + { + Task.Run(() => _requestSender.OnProcessExited()).Wait(); - this.requestSender.DiscoverTests(sources, null, new TestPlatformOptions(), null, mockHandler.Object); + Assert.IsTrue(c.IsCancellationRequested); + }).Returns(Task.FromResult((Message)null)); - manualEvent.WaitOne(); - mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); - } + await _requestSender.DiscoverTestsAsync(sources, null, new TestPlatformOptions(), null, mockHandler.Object); - [TestMethod] - public async Task DiscoverTestsAsyncShouldLogErrorWhenProcessExited() - { - var mockHandler = new Mock(); - var sources = new List { "1.dll" }; - var payload = new DiscoveryRequestPayload { Sources = sources, RunSettings = null }; - - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - var testCaseList = new List() { testCase }; - var testsFound = CreateMessage(MessageType.TestCasesFound, testCaseList); - await this.requestSender.InitializeCommunicationAsync(this.WaitTimeout); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Callback( - (CancellationToken c) => - { - Task.Run(() => this.requestSender.OnProcessExited()).Wait(); + mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); + } - Assert.IsTrue(c.IsCancellationRequested); - }).Returns(Task.FromResult((Message)null)); + #endregion - await this.requestSender.DiscoverTestsAsync(sources, null, new TestPlatformOptions(), null, mockHandler.Object); + #region RunTests - mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); - } + [TestMethod] + public void StartTestRunShouldCompleteWithZeroTests() + { + InitializeCommunication(); - #endregion + var mockHandler = new Mock(); - #region RunTests + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); - [TestMethod] - public void StartTestRunShouldCompleteWithZeroTests() + var payload = new TestRunCompletePayload() { - this.InitializeCommunication(); + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; - var mockHandler = new Mock(); + var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + _requestSender.StartTestRun(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); - var payload = new TestRunCompletePayload() - { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; + mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), + It.IsAny(), null, null), Times.Once, "Run Complete must be called"); + mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Never, "RunChangedArgs must not be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); + } - var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); + [TestMethod] + public async Task StartTestRunAsyncShouldCompleteWithZeroTests() + { + await InitializeCommunicationAsync(); - this.requestSender.StartTestRun(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); + var mockHandler = new Mock(); - mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), - It.IsAny(), null, null), Times.Once, "Run Complete must be called"); - mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Never, "RunChangedArgs must not be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); - } + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); - [TestMethod] - public async Task StartTestRunAsyncShouldCompleteWithZeroTests() + var payload = new TestRunCompletePayload() { - await this.InitializeCommunicationAsync(); + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; - var mockHandler = new Mock(); + var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + await _requestSender.StartTestRunAsync(new List() { "1.dll" }, null, null, null, mockHandler.Object); - var payload = new TestRunCompletePayload() - { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; + mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), + It.IsAny(), null, null), Times.Once, "Run Complete must be called"); + mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Never, "RunChangedArgs must not be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); + } - var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); + [TestMethod] + public void StartTestRunShouldCompleteWithSingleTestAndMessage() + { + InitializeCommunication(); - await this.requestSender.StartTestRunAsync(new List() { "1.dll" }, null, null, null, mockHandler.Object); + var mockHandler = new Mock(); - mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), - It.IsAny(), null, null), Times.Once, "Run Complete must be called"); - mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Never, "RunChangedArgs must not be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); - } + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + var testResult = new TestResult(testCase); + testResult.Outcome = TestOutcome.Passed; - [TestMethod] - public void StartTestRunShouldCompleteWithSingleTestAndMessage() - { - this.InitializeCommunication(); + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); - var mockHandler = new Mock(); + var testsChangedArgs = new TestRunChangedEventArgs(null, + new List() { testResult }, null); - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - var testResult = new VisualStudio.TestPlatform.ObjectModel.TestResult(testCase); - testResult.Outcome = TestOutcome.Passed; + var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + var payload = new TestRunCompletePayload() + { + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; + + var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); - var testsChangedArgs = new TestRunChangedEventArgs(null, - new List() { testResult }, null); + var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; + var message = CreateMessage(MessageType.TestMessage, mpayload); - var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsPayload)); - var payload = new TestRunCompletePayload() + mockHandler.Setup(mh => mh.HandleTestRunStatsChange(It.IsAny())).Callback( + (testRunChangedArgs) => { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; + Assert.IsTrue(testRunChangedArgs.NewTestResults != null && testsChangedArgs.NewTestResults.Any(), "TestResults must be passed properly"); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); + }); - var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); + mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( + () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete))); - var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; - var message = CreateMessage(MessageType.TestMessage, mpayload); + _requestSender.StartTestRun(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsPayload)); + mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), + It.IsAny(), null, null), Times.Once, "Run Complete must be called"); + mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Once, "RunChangedArgs must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once, "TestMessage event must be called"); + } - mockHandler.Setup(mh => mh.HandleTestRunStatsChange(It.IsAny())).Callback( - (testRunChangedArgs) => - { - Assert.IsTrue(testRunChangedArgs.NewTestResults != null && testsChangedArgs.NewTestResults.Any(), "TestResults must be passed properly"); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); - }); + [TestMethod] + public async Task StartTestRunAsyncShouldCompleteWithSingleTestAndMessage() + { + await InitializeCommunicationAsync(); - mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( - () => - { - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - }); + var mockHandler = new Mock(); - this.requestSender.StartTestRun(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object); + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + var testResult = new TestResult(testCase); + testResult.Outcome = TestOutcome.Passed; - mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), - It.IsAny(), null, null), Times.Once, "Run Complete must be called"); - mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Once, "RunChangedArgs must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once, "TestMessage event must be called"); - } + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); - [TestMethod] - public async Task StartTestRunAsyncShouldCompleteWithSingleTestAndMessage() - { - await this.InitializeCommunicationAsync(); + var testsChangedArgs = new TestRunChangedEventArgs(null, + new List() { testResult }, null); - var mockHandler = new Mock(); + var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - var testResult = new TestResult(testCase); - testResult.Outcome = TestOutcome.Passed; + var payload = new TestRunCompletePayload() + { + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); - var testsChangedArgs = new TestRunChangedEventArgs(null, - new List() { testResult }, null); + var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; + var message = CreateMessage(MessageType.TestMessage, mpayload); - var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsPayload)); - var payload = new TestRunCompletePayload() + mockHandler.Setup(mh => mh.HandleTestRunStatsChange(It.IsAny())).Callback( + (testRunChangedArgs) => { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; + Assert.IsTrue(testRunChangedArgs.NewTestResults != null && testsChangedArgs.NewTestResults.Any(), "TestResults must be passed properly"); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); + }); - var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); + mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( + () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete))); - var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; - var message = CreateMessage(MessageType.TestMessage, mpayload); + await _requestSender.StartTestRunAsync(new List() { "1.dll" }, null, null, null, mockHandler.Object); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsPayload)); + mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), + It.IsAny(), null, null), Times.Once, "Run Complete must be called"); + mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Once, "RunChangedArgs must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once, "TestMessage event must be called"); + } - mockHandler.Setup(mh => mh.HandleTestRunStatsChange(It.IsAny())).Callback( - (testRunChangedArgs) => - { - Assert.IsTrue(testRunChangedArgs.NewTestResults != null && testsChangedArgs.NewTestResults.Any(), "TestResults must be passed properly"); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); - }); + [TestMethod] + public void StartTestRunShouldNotThrowIfTestPlatformOptionsIsNull() + { + // Arrange. + var sources = new List() { "1.dll" }; + TestRunRequestPayload receivedRequest = null; - mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( - () => - { - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - }); + var mockHandler = new Mock(); - await this.requestSender.StartTestRunAsync(new List() { "1.dll" }, null, null, null, mockHandler.Object); + SetupMockCommunicationForRunRequest(mockHandler); + _mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.TestRunAllSourcesWithDefaultHost, It.IsAny(), It.IsAny())). + Callback((string msg, object requestpayload, int protocol) => receivedRequest = (TestRunRequestPayload)requestpayload); - mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), - It.IsAny(), null, null), Times.Once, "Run Complete must be called"); - mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Once, "RunChangedArgs must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once, "TestMessage event must be called"); - } + // Act. + _requestSender.StartTestRun(sources, null, null, null, mockHandler.Object); - [TestMethod] - public void StartTestRunShouldNotThrowIfTestPlatformOptionsIsNull() - { - // Arrange. - var sources = new List() { "1.dll" }; - TestRunRequestPayload receivedRequest = null; + // Assert. + Assert.IsNotNull(receivedRequest); + CollectionAssert.AreEqual(sources, receivedRequest.Sources); + Assert.IsNull(receivedRequest.TestPlatformOptions, "The run request message should include a null test case filter"); + } + + [TestMethod] + public void StartTestRunShouldIncludeFilterInRequestPayload() + { + // Arrange. + var sources = new List() { "1.dll" }; + var filter = "GivingCampaign"; + TestRunRequestPayload receivedRequest = null; - var mockHandler = new Mock(); + var mockHandler = new Mock(); - this.SetupMockCommunicationForRunRequest(mockHandler); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.TestRunAllSourcesWithDefaultHost, It.IsAny(), It.IsAny())). - Callback((string msg, object requestpayload, int protocol) => { receivedRequest = (TestRunRequestPayload)requestpayload; }); + SetupMockCommunicationForRunRequest(mockHandler); + _mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.TestRunAllSourcesWithDefaultHost, It.IsAny(), It.IsAny())). + Callback((string msg, object requestpayload, int protocol) => receivedRequest = (TestRunRequestPayload)requestpayload); - // Act. - this.requestSender.StartTestRun(sources, null, null, null, mockHandler.Object); + // Act. + _requestSender.StartTestRun(sources, null, new TestPlatformOptions() { TestCaseFilter = filter }, null, mockHandler.Object); - // Assert. - Assert.IsNotNull(receivedRequest); - CollectionAssert.AreEqual(sources, receivedRequest.Sources); - Assert.IsNull(receivedRequest.TestPlatformOptions, "The run request message should include a null test case filter"); - } + // Assert. + Assert.IsNotNull(receivedRequest); + CollectionAssert.AreEqual(sources, receivedRequest.Sources); + Assert.AreEqual(filter, receivedRequest.TestPlatformOptions.TestCaseFilter, "The run request message should include test case filter"); + } - [TestMethod] - public void StartTestRunShouldIncludeFilterInRequestPayload() - { - // Arrange. - var sources = new List() { "1.dll" }; - var filter = "GivingCampaign"; - TestRunRequestPayload receivedRequest = null; + [TestMethod] + public void StartTestRunWithCustomHostShouldComplete() + { + InitializeCommunication(); - var mockHandler = new Mock(); + var mockHandler = new Mock(); - this.SetupMockCommunicationForRunRequest(mockHandler); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.TestRunAllSourcesWithDefaultHost, It.IsAny(), It.IsAny())). - Callback((string msg, object requestpayload, int protocol) => { receivedRequest = (TestRunRequestPayload)requestpayload; }); + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + var testResult = new TestResult(testCase); + testResult.Outcome = TestOutcome.Passed; - // Act. - this.requestSender.StartTestRun(sources, null, new TestPlatformOptions() { TestCaseFilter = filter }, null, mockHandler.Object); + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); - // Assert. - Assert.IsNotNull(receivedRequest); - CollectionAssert.AreEqual(sources, receivedRequest.Sources); - Assert.AreEqual(filter, receivedRequest.TestPlatformOptions.TestCaseFilter, "The run request message should include test case filter"); - } + var testsChangedArgs = new TestRunChangedEventArgs(null, new List() { testResult }, null); + var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); - [TestMethod] - public void StartTestRunWithCustomHostShouldComplete() + var payload = new TestRunCompletePayload() { - this.InitializeCommunication(); + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; + var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); - var mockHandler = new Mock(); + var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; + var message = CreateMessage(MessageType.TestMessage, mpayload); - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - var testResult = new TestResult(testCase); - testResult.Outcome = TestOutcome.Passed; - - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + var runprocessInfoPayload = new Message() + { + MessageType = MessageType.CustomTestHostLaunch, + Payload = JToken.FromObject(new TestProcessStartInfo()) + }; - var testsChangedArgs = new TestRunChangedEventArgs(null, new List() { testResult }, null); - var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); - var payload = new TestRunCompletePayload() + mockHandler.Setup(mh => mh.HandleTestRunStatsChange(It.IsAny())).Callback( + (testRunChangedArgs) => { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; - var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); + Assert.IsTrue(testRunChangedArgs.NewTestResults != null && testsChangedArgs.NewTestResults.Any(), "TestResults must be passed properly"); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); + }); - var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; - var message = CreateMessage(MessageType.TestMessage, mpayload); + mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( + () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete))); - var runprocessInfoPayload = new Message() - { - MessageType = MessageType.CustomTestHostLaunch, - Payload = JToken.FromObject(new TestProcessStartInfo()) - }; + var mockLauncher = new Mock(); + mockLauncher.Setup(ml => ml.LaunchTestHost(It.IsAny())).Callback + (() => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsPayload))); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runprocessInfoPayload)); - mockHandler.Setup(mh => mh.HandleTestRunStatsChange(It.IsAny())).Callback( - (testRunChangedArgs) => - { - Assert.IsTrue(testRunChangedArgs.NewTestResults != null && testsChangedArgs.NewTestResults.Any(), "TestResults must be passed properly"); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); - }); + _requestSender.StartTestRunWithCustomHost(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object, mockLauncher.Object); - mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( - () => - { - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - }); + mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), + It.IsAny(), null, null), Times.Once, "Run Complete must be called"); + mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Once, "RunChangedArgs must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once, "TestMessage event must be called"); + mockLauncher.Verify(ml => ml.LaunchTestHost(It.IsAny()), Times.Once, "Custom TestHostLauncher must be called"); + } + + [TestMethod] + public async Task StartTestRunAsyncWithCustomHostShouldComplete() + { + await InitializeCommunicationAsync(); - var mockLauncher = new Mock(); - mockLauncher.Setup(ml => ml.LaunchTestHost(It.IsAny())).Callback - (() => this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsPayload))); + var mockHandler = new Mock(); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runprocessInfoPayload)); + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + var testResult = new TestResult(testCase); + testResult.Outcome = TestOutcome.Passed; - this.requestSender.StartTestRunWithCustomHost(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object, mockLauncher.Object); + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); - mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), - It.IsAny(), null, null), Times.Once, "Run Complete must be called"); - mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Once, "RunChangedArgs must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once, "TestMessage event must be called"); - mockLauncher.Verify(ml => ml.LaunchTestHost(It.IsAny()), Times.Once, "Custom TestHostLauncher must be called"); - } + var testsChangedArgs = new TestRunChangedEventArgs(null, new List() { testResult }, null); + var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); - [TestMethod] - public async Task StartTestRunAsyncWithCustomHostShouldComplete() + var payload = new TestRunCompletePayload() { - await this.InitializeCommunicationAsync(); - - var mockHandler = new Mock(); + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; + var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - var testResult = new TestResult(testCase); - testResult.Outcome = TestOutcome.Passed; + var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; + var message = CreateMessage(MessageType.TestMessage, mpayload); - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + var runprocessInfoPayload = new Message() + { + MessageType = MessageType.CustomTestHostLaunch, + Payload = JToken.FromObject(new TestProcessStartInfo()) + }; - var testsChangedArgs = new TestRunChangedEventArgs(null, new List() { testResult }, null); - var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); - var payload = new TestRunCompletePayload() + mockHandler.Setup(mh => mh.HandleTestRunStatsChange(It.IsAny())).Callback( + (testRunChangedArgs) => { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; - var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); + Assert.IsTrue(testRunChangedArgs.NewTestResults != null && testsChangedArgs.NewTestResults.Any(), "TestResults must be passed properly"); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); + }); - var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; - var message = CreateMessage(MessageType.TestMessage, mpayload); + mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( + () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete))); - var runprocessInfoPayload = new Message() - { - MessageType = MessageType.CustomTestHostLaunch, - Payload = JToken.FromObject(new TestProcessStartInfo()) - }; + var mockLauncher = new Mock(); + mockLauncher.Setup(ml => ml.LaunchTestHost(It.IsAny())).Callback + (() => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsPayload))); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runprocessInfoPayload)); - mockHandler.Setup(mh => mh.HandleTestRunStatsChange(It.IsAny())).Callback( - (testRunChangedArgs) => - { - Assert.IsTrue(testRunChangedArgs.NewTestResults != null && testsChangedArgs.NewTestResults.Any(), "TestResults must be passed properly"); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); - }); + await _requestSender.StartTestRunWithCustomHostAsync(new List() { "1.dll" }, null, null, null, mockHandler.Object, mockLauncher.Object); - mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( - () => - { - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - }); + mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), + It.IsAny(), null, null), Times.Once, "Run Complete must be called"); + mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Once, "RunChangedArgs must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once, "TestMessage event must be called"); + mockLauncher.Verify(ml => ml.LaunchTestHost(It.IsAny()), Times.Once, "Custom TestHostLauncher must be called"); + } - var mockLauncher = new Mock(); - mockLauncher.Setup(ml => ml.LaunchTestHost(It.IsAny())).Callback - (() => this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsPayload))); + [TestMethod] + public void StartTestRunWithCustomHostShouldNotAbortAndSendErrorToVstestConsoleInErrorScenario() + { + InitializeCommunication(); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runprocessInfoPayload)); + var mockHandler = new Mock(); - await this.requestSender.StartTestRunWithCustomHostAsync(new List() { "1.dll" }, null, null, null, mockHandler.Object, mockLauncher.Object); + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + var testResult = new TestResult(testCase); + testResult.Outcome = TestOutcome.Passed; - mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), - It.IsAny(), null, null), Times.Once, "Run Complete must be called"); - mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Once, "RunChangedArgs must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once, "TestMessage event must be called"); - mockLauncher.Verify(ml => ml.LaunchTestHost(It.IsAny()), Times.Once, "Custom TestHostLauncher must be called"); - } + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); - [TestMethod] - public void StartTestRunWithCustomHostShouldNotAbortAndSendErrorToVstestConsoleInErrorScenario() + var testsChangedArgs = new TestRunChangedEventArgs(null, new List() { testResult }, null); + var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); + + var payload = new TestRunCompletePayload() { - this.InitializeCommunication(); + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; + var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); - var mockHandler = new Mock(); + var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; + var message = CreateMessage(MessageType.TestMessage, mpayload); - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - var testResult = new TestResult(testCase); - testResult.Outcome = TestOutcome.Passed; + Message runprocessInfoPayload = new VersionedMessage() + { + MessageType = MessageType.CustomTestHostLaunch, + Payload = JToken.FromObject(new TestProcessStartInfo()) + }; - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + var mockLauncher = new Mock(); + mockLauncher.Setup(ml => ml.LaunchTestHost(It.IsAny())).Throws(new Exception("BadError")); - var testsChangedArgs = new TestRunChangedEventArgs(null, new List() { testResult }, null); - var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runprocessInfoPayload)); - var payload = new TestRunCompletePayload() - { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; - var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); + _mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny(), It.IsAny(), _protocolVersion)). + Callback(() => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete))); - var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; - var message = CreateMessage(MessageType.TestMessage, mpayload); + _requestSender.StartTestRunWithCustomHost(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object, mockLauncher.Object); - Message runprocessInfoPayload = new VersionedMessage() - { - MessageType = MessageType.CustomTestHostLaunch, - Payload = JToken.FromObject(new TestProcessStartInfo()) - }; + mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), + It.IsAny(), null, null), Times.Once, "Run Complete must be called"); + } - var mockLauncher = new Mock(); - mockLauncher.Setup(ml => ml.LaunchTestHost(It.IsAny())).Throws(new Exception("BadError")); + [TestMethod] + public async Task StartTestRunAsyncWithCustomHostShouldNotAbortAndSendErrorToVstestConsoleInErrorScenario() + { + await InitializeCommunicationAsync(); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runprocessInfoPayload)); + var mockHandler = new Mock(); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny(), It.IsAny(), this.protocolVersion)). - Callback(() => this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete))); + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + var testResult = new TestResult(testCase); + testResult.Outcome = TestOutcome.Passed; - this.requestSender.StartTestRunWithCustomHost(new List() { "1.dll" }, null, new TestPlatformOptions(), null, mockHandler.Object, mockLauncher.Object); + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); - mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), - It.IsAny(), null, null), Times.Once, "Run Complete must be called"); - } + var testsChangedArgs = new TestRunChangedEventArgs(null, new List() { testResult }, null); + var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); - [TestMethod] - public async Task StartTestRunAsyncWithCustomHostShouldNotAbortAndSendErrorToVstestConsoleInErrorScenario() + var payload = new TestRunCompletePayload() { - await this.InitializeCommunicationAsync(); + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; + var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); - var mockHandler = new Mock(); + var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; + var message = CreateMessage(MessageType.TestMessage, mpayload); - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - var testResult = new TestResult(testCase); - testResult.Outcome = TestOutcome.Passed; + Message runprocessInfoPayload = new VersionedMessage() + { + MessageType = MessageType.CustomTestHostLaunch, + Payload = JToken.FromObject(new TestProcessStartInfo()) + }; - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + var mockLauncher = new Mock(); + mockLauncher.Setup(ml => ml.LaunchTestHost(It.IsAny())).Throws(new Exception("BadError")); - var testsChangedArgs = new TestRunChangedEventArgs(null, new List() { testResult }, null); - var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runprocessInfoPayload)); - var payload = new TestRunCompletePayload() - { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; - var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); + _mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny(), It.IsAny(), _protocolVersion)). + Callback(() => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete))); - var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; - var message = CreateMessage(MessageType.TestMessage, mpayload); + await _requestSender.StartTestRunWithCustomHostAsync(new List() { "1.dll" }, null, null, null, mockHandler.Object, mockLauncher.Object); - Message runprocessInfoPayload = new VersionedMessage() - { - MessageType = MessageType.CustomTestHostLaunch, - Payload = JToken.FromObject(new TestProcessStartInfo()) - }; + mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), + It.IsAny(), null, null), Times.Once, "Run Complete must be called"); + } - var mockLauncher = new Mock(); - mockLauncher.Setup(ml => ml.LaunchTestHost(It.IsAny())).Throws(new Exception("BadError")); + [TestMethod] + public void StartTestRunWithCustomHostShouldNotThrowIfTestPlatformOptionsIsNull() + { + // Arrange. + var sources = new List() { "1.dll" }; + TestRunRequestPayload receivedRequest = null; - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runprocessInfoPayload)); + var mockHandler = new Mock(); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny(), It.IsAny(), this.protocolVersion)). - Callback(() => this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete))); + SetupMockCommunicationForRunRequest(mockHandler); + _mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.GetTestRunnerProcessStartInfoForRunAll, It.IsAny(), It.IsAny())). + Callback((string msg, object requestpayload, int protocol) => receivedRequest = (TestRunRequestPayload)requestpayload); - await this.requestSender.StartTestRunWithCustomHostAsync(new List() { "1.dll" }, null, null, null, mockHandler.Object, mockLauncher.Object); + // Act. + _requestSender.StartTestRunWithCustomHost(sources, null, null, null, mockHandler.Object, new Mock().Object); - mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), - It.IsAny(), null, null), Times.Once, "Run Complete must be called"); - } + // Assert. + Assert.IsNotNull(receivedRequest); + CollectionAssert.AreEqual(sources, receivedRequest.Sources); + Assert.IsNull(receivedRequest.TestPlatformOptions, "The run request message should include a null test case filter"); + } - [TestMethod] - public void StartTestRunWithCustomHostShouldNotThrowIfTestPlatformOptionsIsNull() - { - // Arrange. - var sources = new List() { "1.dll" }; - TestRunRequestPayload receivedRequest = null; + [TestMethod] + public void StartTestRunWithCustomHostShouldIncludeFilterInRequestPayload() + { + // Arrange. + var sources = new List() { "1.dll" }; + var filter = "GivingCampaign"; + TestRunRequestPayload receivedRequest = null; - var mockHandler = new Mock(); + var mockHandler = new Mock(); - this.SetupMockCommunicationForRunRequest(mockHandler); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.GetTestRunnerProcessStartInfoForRunAll, It.IsAny(), It.IsAny())). - Callback((string msg, object requestpayload, int protocol) => { receivedRequest = (TestRunRequestPayload)requestpayload; }); + SetupMockCommunicationForRunRequest(mockHandler); + _mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.GetTestRunnerProcessStartInfoForRunAll, It.IsAny(), It.IsAny())). + Callback((string msg, object requestpayload, int protocol) => receivedRequest = (TestRunRequestPayload)requestpayload); - // Act. - this.requestSender.StartTestRunWithCustomHost(sources, null, null, null, mockHandler.Object, new Mock().Object); + // Act. + _requestSender.StartTestRunWithCustomHost(sources, null, new TestPlatformOptions() { TestCaseFilter = filter }, null, mockHandler.Object, new Mock().Object); - // Assert. - Assert.IsNotNull(receivedRequest); - CollectionAssert.AreEqual(sources, receivedRequest.Sources); - Assert.IsNull(receivedRequest.TestPlatformOptions, "The run request message should include a null test case filter"); - } + // Assert. + Assert.IsNotNull(receivedRequest); + CollectionAssert.AreEqual(sources, receivedRequest.Sources); + Assert.AreEqual(filter, receivedRequest.TestPlatformOptions.TestCaseFilter, "The run request message should include test case filter"); + } + + [TestMethod] + public void StartTestRunWithSelectedTestsShouldCompleteWithZeroTests() + { + InitializeCommunication(); - [TestMethod] - public void StartTestRunWithCustomHostShouldIncludeFilterInRequestPayload() + var mockHandler = new Mock(); + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + + var payload = new TestRunCompletePayload() { - // Arrange. - var sources = new List() { "1.dll" }; - var filter = "GivingCampaign"; - TestRunRequestPayload receivedRequest = null; + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; + var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - var mockHandler = new Mock(); + _requestSender.StartTestRun(new List(), null, new TestPlatformOptions(), null, mockHandler.Object); - this.SetupMockCommunicationForRunRequest(mockHandler); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.GetTestRunnerProcessStartInfoForRunAll, It.IsAny(), It.IsAny())). - Callback((string msg, object requestpayload, int protocol) => { receivedRequest = (TestRunRequestPayload)requestpayload; }); + mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), + It.IsAny(), null, null), Times.Once, "Run Complete must be called"); + mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Never, "RunChangedArgs must not be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); + } - // Act. - this.requestSender.StartTestRunWithCustomHost(sources, null, new TestPlatformOptions() { TestCaseFilter = filter }, null, mockHandler.Object, new Mock().Object); + [TestMethod] + public async Task StartTestRunAsyncWithSelectedTestsShouldCompleteWithZeroTests() + { + await InitializeCommunicationAsync(); - // Assert. - Assert.IsNotNull(receivedRequest); - CollectionAssert.AreEqual(sources, receivedRequest.Sources); - Assert.AreEqual(filter, receivedRequest.TestPlatformOptions.TestCaseFilter, "The run request message should include test case filter"); - } + var mockHandler = new Mock(); + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); - [TestMethod] - public void StartTestRunWithSelectedTestsShouldCompleteWithZeroTests() + var payload = new TestRunCompletePayload() { - this.InitializeCommunication(); + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; + var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - var mockHandler = new Mock(); - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + await _requestSender.StartTestRunAsync(new List(), null, new TestPlatformOptions(), null, mockHandler.Object); - var payload = new TestRunCompletePayload() - { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; - var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - - this.requestSender.StartTestRun(new List(), null, new TestPlatformOptions(), null, mockHandler.Object); - - mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), - It.IsAny(), null, null), Times.Once, "Run Complete must be called"); - mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Never, "RunChangedArgs must not be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); - } - - [TestMethod] - public async Task StartTestRunAsyncWithSelectedTestsShouldCompleteWithZeroTests() - { - await this.InitializeCommunicationAsync(); + mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), + It.IsAny(), null, null), Times.Once, "Run Complete must be called"); + mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Never, "RunChangedArgs must not be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); + } + + [TestMethod] + public void StartTestRunWithSelectedTestsShouldCompleteWithSingleTestAndMessage() + { + InitializeCommunication(); - var mockHandler = new Mock(); - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + var mockHandler = new Mock(); - var payload = new TestRunCompletePayload() - { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; - var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - - await this.requestSender.StartTestRunAsync(new List(), null, new TestPlatformOptions(), null, mockHandler.Object); - - mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), - It.IsAny(), null, null), Times.Once, "Run Complete must be called"); - mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Never, "RunChangedArgs must not be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); - } - - [TestMethod] - public void StartTestRunWithSelectedTestsShouldCompleteWithSingleTestAndMessage() - { - this.InitializeCommunication(); + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + var testResult = new TestResult(testCase); + testResult.Outcome = TestOutcome.Passed; - var mockHandler = new Mock(); + var testCaseList = new List() { testCase }; - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - var testResult = new VisualStudio.TestPlatform.ObjectModel.TestResult(testCase); - testResult.Outcome = TestOutcome.Passed; + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); - var testCaseList = new List() { testCase }; + var testsChangedArgs = new TestRunChangedEventArgs(null, new List() { testResult }, null); + var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + var payload = new TestRunCompletePayload() + { + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; + var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); - var testsChangedArgs = new TestRunChangedEventArgs(null, new List() { testResult }, null); - var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); + var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; + var message = CreateMessage(MessageType.TestMessage, mpayload); - var payload = new TestRunCompletePayload() + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsPayload)); + + mockHandler.Setup(mh => mh.HandleTestRunStatsChange(It.IsAny())).Callback( + (testRunChangedArgs) => { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; - var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); + Assert.IsTrue(testRunChangedArgs.NewTestResults != null && testsChangedArgs.NewTestResults.Any(), "TestResults must be passed properly"); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); + }); - var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; - var message = CreateMessage(MessageType.TestMessage, mpayload); + mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( + () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete))); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsPayload)); + _requestSender.StartTestRun(testCaseList, null, new TestPlatformOptions(), null, mockHandler.Object); - mockHandler.Setup(mh => mh.HandleTestRunStatsChange(It.IsAny())).Callback( - (testRunChangedArgs) => - { - Assert.IsTrue(testRunChangedArgs.NewTestResults != null && testsChangedArgs.NewTestResults.Any(), "TestResults must be passed properly"); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); - }); + mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), + It.IsAny(), null, null), Times.Once, "Run Complete must be called"); + mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Once, "RunChangedArgs must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once, "TestMessage event must be called"); + } - mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( - () => - { - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - }); + [TestMethod] + public async Task StartTestRunAsyncWithSelectedTestsShouldCompleteWithSingleTestAndMessage() + { + await InitializeCommunicationAsync(); - this.requestSender.StartTestRun(testCaseList, null, new TestPlatformOptions(), null, mockHandler.Object); + var mockHandler = new Mock(); - mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), - It.IsAny(), null, null), Times.Once, "Run Complete must be called"); - mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Once, "RunChangedArgs must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once, "TestMessage event must be called"); - } + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + var testResult = new TestResult(testCase); + testResult.Outcome = TestOutcome.Passed; - [TestMethod] - public async Task StartTestRunAsyncWithSelectedTestsShouldCompleteWithSingleTestAndMessage() - { - await this.InitializeCommunicationAsync(); + var testCaseList = new List() { testCase }; - var mockHandler = new Mock(); + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - var testResult = new TestResult(testCase); - testResult.Outcome = TestOutcome.Passed; + var testsChangedArgs = new TestRunChangedEventArgs(null, new List() { testResult }, null); + var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); - var testCaseList = new List() { testCase }; + var payload = new TestRunCompletePayload() + { + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; + var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; + var message = CreateMessage(MessageType.TestMessage, mpayload); - var testsChangedArgs = new TestRunChangedEventArgs(null, new List() { testResult }, null); - var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsPayload)); - var payload = new TestRunCompletePayload() + mockHandler.Setup(mh => mh.HandleTestRunStatsChange(It.IsAny())).Callback( + (testRunChangedArgs) => { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; - var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); + Assert.IsTrue(testRunChangedArgs.NewTestResults != null && testsChangedArgs.NewTestResults.Any(), "TestResults must be passed properly"); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); + }); - var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; - var message = CreateMessage(MessageType.TestMessage, mpayload); + mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( + () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete))); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsPayload)); + await _requestSender.StartTestRunAsync(testCaseList, null, new TestPlatformOptions(), null, mockHandler.Object); - mockHandler.Setup(mh => mh.HandleTestRunStatsChange(It.IsAny())).Callback( - (testRunChangedArgs) => - { - Assert.IsTrue(testRunChangedArgs.NewTestResults != null && testsChangedArgs.NewTestResults.Any(), "TestResults must be passed properly"); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); - }); + mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), + It.IsAny(), null, null), Times.Once, "Run Complete must be called"); + mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Once, "RunChangedArgs must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once, "TestMessage event must be called"); + } - mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( - () => - { - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - }); + [TestMethod] + public void StartTestRunWithSelectedTestsHavingTraitsShouldReturnTestRunCompleteWithTraitsIntact() + { + InitializeCommunication(); - await this.requestSender.StartTestRunAsync(testCaseList, null, new TestPlatformOptions(), null, mockHandler.Object); + var mockHandler = new Mock(); - mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), - It.IsAny(), null, null), Times.Once, "Run Complete must be called"); - mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Once, "RunChangedArgs must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once, "TestMessage event must be called"); - } + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + testCase.Traits.Add(new Trait("a", "b")); - [TestMethod] - public void StartTestRunWithSelectedTestsHavingTraitsShouldReturnTestRunCompleteWithTraitsIntact() + var testResult = new TestResult(testCase); + testResult.Outcome = TestOutcome.Passed; + + var testCaseList = new List() { testCase }; + + TestRunChangedEventArgs receivedChangeEventArgs = null; + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, new List { testResult }, null); + + var payload = new TestRunCompletePayload() { - this.InitializeCommunication(); + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; + var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); - var mockHandler = new Mock(); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - testCase.Traits.Add(new Trait("a", "b")); + mockHandler.Setup(mh => mh.HandleTestRunComplete( + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>())) + .Callback( + (TestRunCompleteEventArgs complete, + TestRunChangedEventArgs stats, + ICollection attachments, + ICollection executorUris) => receivedChangeEventArgs = stats); - var testResult = new VisualStudio.TestPlatform.ObjectModel.TestResult(testCase); - testResult.Outcome = TestOutcome.Passed; + _requestSender.StartTestRun(testCaseList, null, new TestPlatformOptions(), null, mockHandler.Object); - var testCaseList = new List() { testCase }; + Assert.IsNotNull(receivedChangeEventArgs); + Assert.IsTrue(receivedChangeEventArgs.NewTestResults.Any()); - TestRunChangedEventArgs receivedChangeEventArgs = null; - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, new List { testResult }, null); + // Verify that the traits are passed through properly. + var traits = receivedChangeEventArgs.NewTestResults.ToArray()[0].TestCase.Traits; + Assert.IsNotNull(traits); + Assert.AreEqual("a", traits.ToArray()[0].Name); + Assert.AreEqual("b", traits.ToArray()[0].Value); + } - var payload = new TestRunCompletePayload() - { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; - var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); - - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - - mockHandler.Setup(mh => mh.HandleTestRunComplete( - It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>())) - .Callback( - (TestRunCompleteEventArgs complete, - TestRunChangedEventArgs stats, - ICollection attachments, - ICollection executorUris) => - { - receivedChangeEventArgs = stats; - }); - - this.requestSender.StartTestRun(testCaseList, null, new TestPlatformOptions(), null, mockHandler.Object); - - Assert.IsNotNull(receivedChangeEventArgs); - Assert.IsTrue(receivedChangeEventArgs.NewTestResults.Any()); - - // Verify that the traits are passed through properly. - var traits = receivedChangeEventArgs.NewTestResults.ToArray()[0].TestCase.Traits; - Assert.IsNotNull(traits); - Assert.AreEqual("a", traits.ToArray()[0].Name); - Assert.AreEqual("b", traits.ToArray()[0].Value); - } - - [TestMethod] - public async Task StartTestRunAsyncWithSelectedTestsHavingTraitsShouldReturnTestRunCompleteWithTraitsIntact() - { - await this.InitializeCommunicationAsync(); + [TestMethod] + public async Task StartTestRunAsyncWithSelectedTestsHavingTraitsShouldReturnTestRunCompleteWithTraitsIntact() + { + await InitializeCommunicationAsync(); - var mockHandler = new Mock(); + var mockHandler = new Mock(); - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - testCase.Traits.Add(new Trait("a", "b")); + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + testCase.Traits.Add(new Trait("a", "b")); - var testResult = new TestResult(testCase); - testResult.Outcome = TestOutcome.Passed; + var testResult = new TestResult(testCase); + testResult.Outcome = TestOutcome.Passed; - var testCaseList = new List() { testCase }; + var testCaseList = new List() { testCase }; - TestRunChangedEventArgs receivedChangeEventArgs = null; - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, new List { testResult }, null); + TestRunChangedEventArgs receivedChangeEventArgs = null; + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, new List { testResult }, null); - var payload = new TestRunCompletePayload() - { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; - var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); - - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - - mockHandler.Setup(mh => mh.HandleTestRunComplete( - It.IsAny(), - It.IsAny(), - It.IsAny>(), - It.IsAny>())) - .Callback( - (TestRunCompleteEventArgs complete, - TestRunChangedEventArgs stats, - ICollection attachments, - ICollection executorUris) => - { - receivedChangeEventArgs = stats; - }); - - await this.requestSender.StartTestRunAsync(testCaseList, null, new TestPlatformOptions(), null, mockHandler.Object); - - Assert.IsNotNull(receivedChangeEventArgs); - Assert.IsTrue(receivedChangeEventArgs.NewTestResults.Any()); - - // Verify that the traits are passed through properly. - var traits = receivedChangeEventArgs.NewTestResults.ToArray()[0].TestCase.Traits; - Assert.IsNotNull(traits); - Assert.AreEqual("a", traits.ToArray()[0].Name); - Assert.AreEqual("b", traits.ToArray()[0].Value); - } - - [TestMethod] - public void StartTestRunWithSelectedTestsHavingTraitsShouldReturnTestRunStatsWithTraitsIntact() + var payload = new TestRunCompletePayload() { - this.InitializeCommunication(); + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; + var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); - var mockHandler = new Mock(); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - testCase.Traits.Add(new Trait("a", "b")); + mockHandler.Setup(mh => mh.HandleTestRunComplete( + It.IsAny(), + It.IsAny(), + It.IsAny>(), + It.IsAny>())) + .Callback( + (TestRunCompleteEventArgs complete, + TestRunChangedEventArgs stats, + ICollection attachments, + ICollection executorUris) => receivedChangeEventArgs = stats); - var testResult = new VisualStudio.TestPlatform.ObjectModel.TestResult(testCase); - testResult.Outcome = TestOutcome.Passed; + await _requestSender.StartTestRunAsync(testCaseList, null, new TestPlatformOptions(), null, mockHandler.Object); - var testCaseList = new List() { testCase }; + Assert.IsNotNull(receivedChangeEventArgs); + Assert.IsTrue(receivedChangeEventArgs.NewTestResults.Any()); - TestRunChangedEventArgs receivedChangeEventArgs = null; - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + // Verify that the traits are passed through properly. + var traits = receivedChangeEventArgs.NewTestResults.ToArray()[0].TestCase.Traits; + Assert.IsNotNull(traits); + Assert.AreEqual("a", traits.ToArray()[0].Name); + Assert.AreEqual("b", traits.ToArray()[0].Value); + } - var testsChangedArgs = new TestRunChangedEventArgs( - null, - new List() { testResult }, - null); - var testsRunStatsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); + [TestMethod] + public void StartTestRunWithSelectedTestsHavingTraitsShouldReturnTestRunStatsWithTraitsIntact() + { + InitializeCommunication(); - var testRunCompletepayload = new TestRunCompletePayload() - { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; - var runComplete = CreateMessage(MessageType.ExecutionComplete, testRunCompletepayload); - - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsRunStatsPayload)); - - mockHandler.Setup(mh => mh.HandleTestRunStatsChange( - It.IsAny())) - .Callback( - (TestRunChangedEventArgs stats) => - { - receivedChangeEventArgs = stats; - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - }); - - this.requestSender.StartTestRun(testCaseList, null, new TestPlatformOptions(), null, mockHandler.Object); - - Assert.IsNotNull(receivedChangeEventArgs); - Assert.IsTrue(receivedChangeEventArgs.NewTestResults.Any()); - - // Verify that the traits are passed through properly. - var traits = receivedChangeEventArgs.NewTestResults.ToArray()[0].TestCase.Traits; - Assert.IsNotNull(traits); - Assert.AreEqual("a", traits.ToArray()[0].Name); - Assert.AreEqual("b", traits.ToArray()[0].Value); - } - - [TestMethod] - public async Task StartTestRunAsyncWithSelectedTestsHavingTraitsShouldReturnTestRunStatsWithTraitsIntact() - { - await this.InitializeCommunicationAsync(); + var mockHandler = new Mock(); - var mockHandler = new Mock(); + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + testCase.Traits.Add(new Trait("a", "b")); - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - testCase.Traits.Add(new Trait("a", "b")); + var testResult = new TestResult(testCase); + testResult.Outcome = TestOutcome.Passed; - var testResult = new VisualStudio.TestPlatform.ObjectModel.TestResult(testCase); - testResult.Outcome = TestOutcome.Passed; + var testCaseList = new List() { testCase }; - var testCaseList = new List() { testCase }; + TestRunChangedEventArgs receivedChangeEventArgs = null; + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); - TestRunChangedEventArgs receivedChangeEventArgs = null; - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + var testsChangedArgs = new TestRunChangedEventArgs( + null, + new List() { testResult }, + null); + var testsRunStatsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); - var testsChangedArgs = new TestRunChangedEventArgs( - null, - new List() { testResult }, - null); - var testsRunStatsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); - - var testRunCompletepayload = new TestRunCompletePayload() - { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; - var runComplete = CreateMessage(MessageType.ExecutionComplete, testRunCompletepayload); - - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsRunStatsPayload)); - - mockHandler.Setup(mh => mh.HandleTestRunStatsChange( - It.IsAny())) - .Callback( - (TestRunChangedEventArgs stats) => - { - receivedChangeEventArgs = stats; - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - }); - - await this.requestSender.StartTestRunAsync(testCaseList, null, new TestPlatformOptions(), null, mockHandler.Object); - - Assert.IsNotNull(receivedChangeEventArgs); - Assert.IsTrue(receivedChangeEventArgs.NewTestResults.Any()); - - // Verify that the traits are passed through properly. - var traits = receivedChangeEventArgs.NewTestResults.ToArray()[0].TestCase.Traits; - Assert.IsNotNull(traits); - Assert.AreEqual("a", traits.ToArray()[0].Name); - Assert.AreEqual("b", traits.ToArray()[0].Value); - } - - [TestMethod] - public void StartTestRunWithCustomHostWithSelectedTestsComplete() + var testRunCompletepayload = new TestRunCompletePayload() { - this.InitializeCommunication(); + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; + var runComplete = CreateMessage(MessageType.ExecutionComplete, testRunCompletepayload); - var mockHandler = new Mock(); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsRunStatsPayload)); - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - var testResult = new VisualStudio.TestPlatform.ObjectModel.TestResult(testCase); - testResult.Outcome = TestOutcome.Passed; + mockHandler.Setup(mh => mh.HandleTestRunStatsChange( + It.IsAny())) + .Callback( + (TestRunChangedEventArgs stats) => + { + receivedChangeEventArgs = stats; + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); + }); - var testCaseList = new List() { testCase }; + _requestSender.StartTestRun(testCaseList, null, new TestPlatformOptions(), null, mockHandler.Object); - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + Assert.IsNotNull(receivedChangeEventArgs); + Assert.IsTrue(receivedChangeEventArgs.NewTestResults.Any()); - var testsChangedArgs = new TestRunChangedEventArgs(null, new List() { testResult }, null); + // Verify that the traits are passed through properly. + var traits = receivedChangeEventArgs.NewTestResults.ToArray()[0].TestCase.Traits; + Assert.IsNotNull(traits); + Assert.AreEqual("a", traits.ToArray()[0].Name); + Assert.AreEqual("b", traits.ToArray()[0].Value); + } - var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); + [TestMethod] + public async Task StartTestRunAsyncWithSelectedTestsHavingTraitsShouldReturnTestRunStatsWithTraitsIntact() + { + await InitializeCommunicationAsync(); - var payload = new TestRunCompletePayload() - { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; + var mockHandler = new Mock(); - var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + testCase.Traits.Add(new Trait("a", "b")); - var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; - var message = CreateMessage(MessageType.TestMessage, mpayload); - var runprocessInfoPayload = CreateMessage(MessageType.CustomTestHostLaunch, new TestProcessStartInfo()); + var testResult = new TestResult(testCase); + testResult.Outcome = TestOutcome.Passed; - mockHandler.Setup(mh => mh.HandleTestRunStatsChange(It.IsAny())).Callback( - (testRunChangedArgs) => - { - Assert.IsTrue(testRunChangedArgs.NewTestResults != null && testsChangedArgs.NewTestResults.Any(), "TestResults must be passed properly"); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); - }); + var testCaseList = new List() { testCase }; + + TestRunChangedEventArgs receivedChangeEventArgs = null; + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + + var testsChangedArgs = new TestRunChangedEventArgs( + null, + new List() { testResult }, + null); + var testsRunStatsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); + + var testRunCompletepayload = new TestRunCompletePayload() + { + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; + var runComplete = CreateMessage(MessageType.ExecutionComplete, testRunCompletepayload); - mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( - () => + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsRunStatsPayload)); + + mockHandler.Setup(mh => mh.HandleTestRunStatsChange( + It.IsAny())) + .Callback( + (TestRunChangedEventArgs stats) => { - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); + receivedChangeEventArgs = stats; + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); }); - var mockLauncher = new Mock(); - mockLauncher.Setup(ml => ml.LaunchTestHost(It.IsAny())).Callback - (() => this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsPayload))); + await _requestSender.StartTestRunAsync(testCaseList, null, new TestPlatformOptions(), null, mockHandler.Object); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runprocessInfoPayload)); + Assert.IsNotNull(receivedChangeEventArgs); + Assert.IsTrue(receivedChangeEventArgs.NewTestResults.Any()); - this.requestSender.StartTestRunWithCustomHost(testCaseList, null, new TestPlatformOptions(), null, mockHandler.Object, mockLauncher.Object); + // Verify that the traits are passed through properly. + var traits = receivedChangeEventArgs.NewTestResults.ToArray()[0].TestCase.Traits; + Assert.IsNotNull(traits); + Assert.AreEqual("a", traits.ToArray()[0].Name); + Assert.AreEqual("b", traits.ToArray()[0].Value); + } - mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), - It.IsAny(), null, null), Times.Once, "Run Complete must be called"); - mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Once, "RunChangedArgs must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once, "TestMessage event must be called"); - mockLauncher.Verify(ml => ml.LaunchTestHost(It.IsAny()), Times.Once, "Custom TestHostLauncher must be called"); - } + [TestMethod] + public void StartTestRunWithCustomHostWithSelectedTestsComplete() + { + InitializeCommunication(); - [TestMethod] - public async Task StartTestRunWithCustomHostAsyncWithSelectedTestsShouldComplete() - { - await this.InitializeCommunicationAsync(); + var mockHandler = new Mock(); - var mockHandler = new Mock(); + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + var testResult = new TestResult(testCase); + testResult.Outcome = TestOutcome.Passed; - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - var testResult = new VisualStudio.TestPlatform.ObjectModel.TestResult(testCase); - testResult.Outcome = TestOutcome.Passed; + var testCaseList = new List() { testCase }; - var testCaseList = new List() { testCase }; + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + var testsChangedArgs = new TestRunChangedEventArgs(null, new List() { testResult }, null); - var testsChangedArgs = new TestRunChangedEventArgs(null, new List() { testResult }, null); + var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); - var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); + var payload = new TestRunCompletePayload() + { + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; - var payload = new TestRunCompletePayload() - { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; + var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); + + var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; + var message = CreateMessage(MessageType.TestMessage, mpayload); + var runprocessInfoPayload = CreateMessage(MessageType.CustomTestHostLaunch, new TestProcessStartInfo()); - var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); + mockHandler.Setup(mh => mh.HandleTestRunStatsChange(It.IsAny())).Callback( + (testRunChangedArgs) => + { + Assert.IsTrue(testRunChangedArgs.NewTestResults != null && testsChangedArgs.NewTestResults.Any(), "TestResults must be passed properly"); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); + }); - var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; - var message = CreateMessage(MessageType.TestMessage, mpayload); - var runprocessInfoPayload = CreateMessage(MessageType.CustomTestHostLaunch, new TestProcessStartInfo()); + mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( + () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete))); - mockHandler.Setup(mh => mh.HandleTestRunStatsChange(It.IsAny())).Callback( - (testRunChangedArgs) => - { - Assert.IsTrue(testRunChangedArgs.NewTestResults != null && testsChangedArgs.NewTestResults.Any(), "TestResults must be passed properly"); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); - }); + var mockLauncher = new Mock(); + mockLauncher.Setup(ml => ml.LaunchTestHost(It.IsAny())).Callback + (() => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsPayload))); - mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( - () => - { - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - }); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runprocessInfoPayload)); - var mockLauncher = new Mock(); - mockLauncher.Setup(ml => ml.LaunchTestHost(It.IsAny())).Callback - (() => this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsPayload))); + _requestSender.StartTestRunWithCustomHost(testCaseList, null, new TestPlatformOptions(), null, mockHandler.Object, mockLauncher.Object); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runprocessInfoPayload)); + mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), + It.IsAny(), null, null), Times.Once, "Run Complete must be called"); + mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Once, "RunChangedArgs must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once, "TestMessage event must be called"); + mockLauncher.Verify(ml => ml.LaunchTestHost(It.IsAny()), Times.Once, "Custom TestHostLauncher must be called"); + } - await this.requestSender.StartTestRunWithCustomHostAsync(testCaseList, null, new TestPlatformOptions(), null, mockHandler.Object, mockLauncher.Object); + [TestMethod] + public async Task StartTestRunWithCustomHostAsyncWithSelectedTestsShouldComplete() + { + await InitializeCommunicationAsync(); - mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), - It.IsAny(), null, null), Times.Once, "Run Complete must be called"); - mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Once, "RunChangedArgs must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once, "TestMessage event must be called"); - mockLauncher.Verify(ml => ml.LaunchTestHost(It.IsAny()), Times.Once, "Custom TestHostLauncher must be called"); - } + var mockHandler = new Mock(); - [TestMethod] - public void StartTestRunWithCustomHostInParallelShouldCallCustomHostMultipleTimes() - { - var mockLauncher = new Mock(); - var mockHandler = new Mock(); - IEnumerable sources = new List { "1.dll" }; - var p1 = new TestProcessStartInfo() { FileName = "X" }; - var p2 = new TestProcessStartInfo() { FileName = "Y" }; - var message1 = CreateMessage(MessageType.CustomTestHostLaunch, p1); - var message2 = CreateMessage(MessageType.CustomTestHostLaunch, p2); - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var completepayload = new TestRunCompletePayload() - { - ExecutorUris = null, - LastRunTests = null, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; - var runComplete = CreateMessage(MessageType.ExecutionComplete, completepayload); - - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message1)); - mockLauncher.Setup(ml => ml.LaunchTestHost(It.IsAny())) - .Callback((startInfo) => - { - if (startInfo.FileName.Equals(p1.FileName)) - { - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message2)); - } - else if (startInfo.FileName.Equals(p2.FileName)) - { - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - } - }); - this.requestSender.InitializeCommunication(); - this.requestSender.StartTestRunWithCustomHost(sources, null, new TestPlatformOptions(), null, mockHandler.Object, mockLauncher.Object); + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + var testResult = new TestResult(testCase); + testResult.Outcome = TestOutcome.Passed; - mockLauncher.Verify(ml => ml.LaunchTestHost(It.IsAny()), Times.Exactly(2)); - } + var testCaseList = new List() { testCase }; - [TestMethod] - public async Task StartTestRunWithCustomHostAsyncInParallelShouldCallCustomHostMultipleTimes() - { - var mockLauncher = new Mock(); - var mockHandler = new Mock(); - IEnumerable sources = new List { "1.dll" }; - var p1 = new TestProcessStartInfo() { FileName = "X" }; - var p2 = new TestProcessStartInfo() { FileName = "Y" }; - var message1 = CreateMessage(MessageType.CustomTestHostLaunch, p1); - var message2 = CreateMessage(MessageType.CustomTestHostLaunch, p2); - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var completepayload = new TestRunCompletePayload() - { - ExecutorUris = null, - LastRunTests = null, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; - var runComplete = CreateMessage(MessageType.ExecutionComplete, completepayload); - - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message1)); - mockLauncher.Setup(ml => ml.LaunchTestHost(It.IsAny())) - .Callback((startInfo) => - { - if (startInfo.FileName.Equals(p1.FileName)) - { - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message2)); - } - else if (startInfo.FileName.Equals(p2.FileName)) - { - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - } - }); + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); - await this.requestSender.InitializeCommunicationAsync(this.WaitTimeout); - await this.requestSender.StartTestRunWithCustomHostAsync(sources, null, null, null, mockHandler.Object, mockLauncher.Object); + var testsChangedArgs = new TestRunChangedEventArgs(null, new List() { testResult }, null); - mockLauncher.Verify(ml => ml.LaunchTestHost(It.IsAny()), Times.Exactly(2)); - } + var testsPayload = CreateMessage(MessageType.TestRunStatsChange, testsChangedArgs); - [TestMethod] - public void StartTestRunShouldAbortOnExceptionInSendMessage() + var payload = new TestRunCompletePayload() { - var mockHandler = new Mock(); - var sources = new List { "1.dll" }; - var payload = new TestRunRequestPayload { Sources = sources, RunSettings = null }; - var exception = new IOException(); + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; - this.mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.TestRunAllSourcesWithDefaultHost, payload, this.protocolVersion)).Throws(exception); + var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); - this.requestSender.StartTestRun(sources, null, new TestPlatformOptions(), null, mockHandler.Object); + var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; + var message = CreateMessage(MessageType.TestMessage, mpayload); + var runprocessInfoPayload = CreateMessage(MessageType.CustomTestHostLaunch, new TestProcessStartInfo()); - mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), null, null, null), Times.Once, "Test Run Complete must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once, "TestMessage event must be called"); - this.mockCommunicationManager.Verify(cm => cm.StopServer(), Times.Never); - } + mockHandler.Setup(mh => mh.HandleTestRunStatsChange(It.IsAny())).Callback( + (testRunChangedArgs) => + { + Assert.IsTrue(testRunChangedArgs.NewTestResults != null && testsChangedArgs.NewTestResults.Any(), "TestResults must be passed properly"); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); + }); - [TestMethod] - public async Task StartTestRunAsyncShouldAbortOnExceptionInSendMessage() - { - var mockHandler = new Mock(); - var sources = new List { "1.dll" }; - var payload = new TestRunRequestPayload { Sources = sources, RunSettings = null }; - var exception = new IOException(); + mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( + () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete))); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.TestRunAllSourcesWithDefaultHost, payload, this.protocolVersion)).Throws(exception); + var mockLauncher = new Mock(); + mockLauncher.Setup(ml => ml.LaunchTestHost(It.IsAny())).Callback + (() => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(testsPayload))); - await this.requestSender.StartTestRunAsync(sources, null, null, null, mockHandler.Object); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runprocessInfoPayload)); - mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), null, null, null), Times.Once, "Test Run Complete must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once, "TestMessage event must be called"); - this.mockCommunicationManager.Verify(cm => cm.StopServer(), Times.Never); - } + await _requestSender.StartTestRunWithCustomHostAsync(testCaseList, null, new TestPlatformOptions(), null, mockHandler.Object, mockLauncher.Object); - [TestMethod] - public void StartTestRunShouldLogErrorOnProcessExited() - { - var mockHandler = new Mock(); - var manualEvent = new ManualResetEvent(false); - var sources = new List { "1.dll" }; - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); - var payload = new TestRunCompletePayload() - { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; - this.requestSender.InitializeCommunication(); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) - .Callback((CancellationToken c) => - { - Task.Run(() => this.requestSender.OnProcessExited()).Wait(); + mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), + It.IsAny(), null, null), Times.Once, "Run Complete must be called"); + mockHandler.Verify(mh => mh.HandleTestRunStatsChange(It.IsAny()), Times.Once, "RunChangedArgs must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Once, "TestMessage event must be called"); + mockLauncher.Verify(ml => ml.LaunchTestHost(It.IsAny()), Times.Once, "Custom TestHostLauncher must be called"); + } - Assert.IsTrue(c.IsCancellationRequested); - }).Returns(Task.FromResult((Message)null)); + [TestMethod] + public void StartTestRunWithCustomHostInParallelShouldCallCustomHostMultipleTimes() + { + var mockLauncher = new Mock(); + var mockHandler = new Mock(); + IEnumerable sources = new List { "1.dll" }; + var p1 = new TestProcessStartInfo() { FileName = "X" }; + var p2 = new TestProcessStartInfo() { FileName = "Y" }; + var message1 = CreateMessage(MessageType.CustomTestHostLaunch, p1); + var message2 = CreateMessage(MessageType.CustomTestHostLaunch, p2); + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var completepayload = new TestRunCompletePayload() + { + ExecutorUris = null, + LastRunTests = null, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; + var runComplete = CreateMessage(MessageType.ExecutionComplete, completepayload); + + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message1)); + mockLauncher.Setup(ml => ml.LaunchTestHost(It.IsAny())) + .Callback((startInfo) => + { + if (startInfo.FileName.Equals(p1.FileName)) + { + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message2)); + } + else if (startInfo.FileName.Equals(p2.FileName)) + { + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); + } + }); + _requestSender.InitializeCommunication(); + _requestSender.StartTestRunWithCustomHost(sources, null, new TestPlatformOptions(), null, mockHandler.Object, mockLauncher.Object); - mockHandler.Setup(mh => mh.HandleTestRunComplete(It.IsAny(), null, null, null)).Callback(() => manualEvent.Set()); + mockLauncher.Verify(ml => ml.LaunchTestHost(It.IsAny()), Times.Exactly(2)); + } - this.requestSender.StartTestRun(sources, null, new TestPlatformOptions(), null, mockHandler.Object); + [TestMethod] + public async Task StartTestRunWithCustomHostAsyncInParallelShouldCallCustomHostMultipleTimes() + { + var mockLauncher = new Mock(); + var mockHandler = new Mock(); + IEnumerable sources = new List { "1.dll" }; + var p1 = new TestProcessStartInfo() { FileName = "X" }; + var p2 = new TestProcessStartInfo() { FileName = "Y" }; + var message1 = CreateMessage(MessageType.CustomTestHostLaunch, p1); + var message2 = CreateMessage(MessageType.CustomTestHostLaunch, p2); + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var completepayload = new TestRunCompletePayload() + { + ExecutorUris = null, + LastRunTests = null, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; + var runComplete = CreateMessage(MessageType.ExecutionComplete, completepayload); + + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message1)); + mockLauncher.Setup(ml => ml.LaunchTestHost(It.IsAny())) + .Callback((startInfo) => + { + if (startInfo.FileName.Equals(p1.FileName)) + { + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message2)); + } + else if (startInfo.FileName.Equals(p2.FileName)) + { + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); + } + }); - manualEvent.WaitOne(); - mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); - } + await _requestSender.InitializeCommunicationAsync(_waitTimeout); + await _requestSender.StartTestRunWithCustomHostAsync(sources, null, null, null, mockHandler.Object, mockLauncher.Object); - [TestMethod] - public async Task StartTestRunAsyncShouldLogErrorOnProcessExited() - { - var mockHandler = new Mock(); - var sources = new List { "1.dll" }; - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); - var payload = new TestRunCompletePayload() - { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; - await this.requestSender.InitializeCommunicationAsync(this.WaitTimeout); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) - .Callback((CancellationToken c) => - { - Task.Run(() => this.requestSender.OnProcessExited()).Wait(); + mockLauncher.Verify(ml => ml.LaunchTestHost(It.IsAny()), Times.Exactly(2)); + } - Assert.IsTrue(c.IsCancellationRequested); - }).Returns(Task.FromResult((Message)null)); + [TestMethod] + public void StartTestRunShouldAbortOnExceptionInSendMessage() + { + var mockHandler = new Mock(); + var sources = new List { "1.dll" }; + var payload = new TestRunRequestPayload { Sources = sources, RunSettings = null }; + var exception = new IOException(); - await this.requestSender.StartTestRunAsync(sources, null, null, null, mockHandler.Object); + _mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.TestRunAllSourcesWithDefaultHost, payload, _protocolVersion)).Throws(exception); - mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); - } + _requestSender.StartTestRun(sources, null, new TestPlatformOptions(), null, mockHandler.Object); - #endregion + mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), null, null, null), Times.Once, "Test Run Complete must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once, "TestMessage event must be called"); + _mockCommunicationManager.Verify(cm => cm.StopServer(), Times.Never); + } - #region Attachments Processing Tests + [TestMethod] + public async Task StartTestRunAsyncShouldAbortOnExceptionInSendMessage() + { + var mockHandler = new Mock(); + var sources = new List { "1.dll" }; + var payload = new TestRunRequestPayload { Sources = sources, RunSettings = null }; + var exception = new IOException(); - [TestMethod] - public async Task ProcessTestRunAttachmentsAsyncShouldCompleteWithZeroAttachments() - { - await this.InitializeCommunicationAsync(); + _mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.TestRunAllSourcesWithDefaultHost, payload, _protocolVersion)).Throws(exception); - var mockHandler = new Mock(); + await _requestSender.StartTestRunAsync(sources, null, null, null, mockHandler.Object); - var payload = new TestRunAttachmentsProcessingCompletePayload() - { - AttachmentsProcessingCompleteEventArgs = new TestRunAttachmentsProcessingCompleteEventArgs(false, null), - Attachments = new AttachmentSet[0] - }; + mockHandler.Verify(mh => mh.HandleTestRunComplete(It.IsAny(), null, null, null), Times.Once, "Test Run Complete must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once, "TestMessage event must be called"); + _mockCommunicationManager.Verify(cm => cm.StopServer(), Times.Never); + } - var attachmentsProcessingComplete = new Message() - { - MessageType = MessageType.TestRunAttachmentsProcessingComplete, - Payload = JToken.FromObject(payload) - }; - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(attachmentsProcessingComplete)); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny(), It.IsAny())).Callback((string _, object o) => + [TestMethod] + public void StartTestRunShouldLogErrorOnProcessExited() + { + var mockHandler = new Mock(); + var manualEvent = new ManualResetEvent(false); + var sources = new List { "1.dll" }; + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + var payload = new TestRunCompletePayload() + { + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; + _requestSender.InitializeCommunication(); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) + .Callback((CancellationToken c) => { - Assert.AreEqual(Constants.EmptyRunSettings, ((TestRunAttachmentsProcessingPayload)o).RunSettings); - Assert.AreEqual(1, ((TestRunAttachmentsProcessingPayload)o).InvokedDataCollectors.Count()); - }); + Task.Run(() => _requestSender.OnProcessExited()).Wait(); - await this.requestSender.ProcessTestRunAttachmentsAsync( - new List { new AttachmentSet(new Uri("http://www.bing.com"), "a") }, - new List() { new InvokedDataCollector(new Uri("datacollector://sample"), "sample", typeof(string).AssemblyQualifiedName, typeof(string).Assembly.Location, false) }, - Constants.EmptyRunSettings, - true, - mockHandler.Object, - CancellationToken.None); + Assert.IsTrue(c.IsCancellationRequested); + }).Returns(Task.FromResult((Message)null)); - mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingStart, It.IsAny())); - mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingCancel), Times.Never); - mockHandler.Verify(mh => mh.HandleTestRunAttachmentsProcessingComplete(It.Is(a => !a.IsCanceled && a.Error == null), It.Is>(a => a.Count == 0)), Times.Once, "Attachments Processing Complete must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); - } + mockHandler.Setup(mh => mh.HandleTestRunComplete(It.IsAny(), null, null, null)).Callback(() => manualEvent.Set()); - [TestMethod] - public async Task ProcessTestRunAttachmentsAsyncShouldCompleteWithOneAttachment() - { - await this.InitializeCommunicationAsync(); + _requestSender.StartTestRun(sources, null, new TestPlatformOptions(), null, mockHandler.Object); - var mockHandler = new Mock(); + manualEvent.WaitOne(); + mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); + } - var payload = new TestRunAttachmentsProcessingCompletePayload() - { - AttachmentsProcessingCompleteEventArgs = new TestRunAttachmentsProcessingCompleteEventArgs(true, new Exception("msg")), - Attachments = new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") } - }; - var attachmentsProcessingComplete = new Message() + [TestMethod] + public async Task StartTestRunAsyncShouldLogErrorOnProcessExited() + { + var mockHandler = new Mock(); + var sources = new List { "1.dll" }; + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + var payload = new TestRunCompletePayload() + { + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; + await _requestSender.InitializeCommunicationAsync(_waitTimeout); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) + .Callback((CancellationToken c) => { - MessageType = MessageType.TestRunAttachmentsProcessingComplete, - Payload = JToken.FromObject(payload) - }; + Task.Run(() => _requestSender.OnProcessExited()).Wait(); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(attachmentsProcessingComplete)); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny(), It.IsAny())).Callback((string _, object o) => - { - Assert.AreEqual(Constants.EmptyRunSettings, ((TestRunAttachmentsProcessingPayload)o).RunSettings); - Assert.AreEqual(1, ((TestRunAttachmentsProcessingPayload)o).InvokedDataCollectors.Count()); - }); + Assert.IsTrue(c.IsCancellationRequested); + }).Returns(Task.FromResult((Message)null)); - await this.requestSender.ProcessTestRunAttachmentsAsync( - new List { new AttachmentSet(new Uri("http://www.bing.com"), "a") }, - new List() { new InvokedDataCollector(new Uri("datacollector://sample"), "sample", typeof(string).AssemblyQualifiedName, typeof(string).Assembly.Location, false) }, - Constants.EmptyRunSettings, - true, - mockHandler.Object, - CancellationToken.None); + await _requestSender.StartTestRunAsync(sources, null, null, null, mockHandler.Object); - mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingStart, It.IsAny())); - mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingCancel), Times.Never); - mockHandler.Verify(mh => mh.HandleTestRunAttachmentsProcessingComplete(It.Is(a => a.IsCanceled && a.Error != null), It.Is>(a => a.Count == 1)), Times.Once, "Attachments Processing Complete must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); - } + mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once); + } - [TestMethod] - public async Task ProcessTestRunAttachmentsAsyncShouldCompleteWithOneAttachmentAndTestMessage() - { - await this.InitializeCommunicationAsync(); + #endregion - var mockHandler = new Mock(); + #region Attachments Processing Tests - var payload = new TestRunAttachmentsProcessingCompletePayload() - { - AttachmentsProcessingCompleteEventArgs = new TestRunAttachmentsProcessingCompleteEventArgs(false, null), - Attachments = new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") } - }; + [TestMethod] + public async Task ProcessTestRunAttachmentsAsyncShouldCompleteWithZeroAttachments() + { + await InitializeCommunicationAsync(); - var attachmentsProcessingComplete = new Message() - { - MessageType = MessageType.TestRunAttachmentsProcessingComplete, - Payload = JToken.FromObject(payload) - }; + var mockHandler = new Mock(); - var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; - var message = CreateMessage(MessageType.TestMessage, mpayload); + var payload = new TestRunAttachmentsProcessingCompletePayload() + { + AttachmentsProcessingCompleteEventArgs = new TestRunAttachmentsProcessingCompleteEventArgs(false, null), + Attachments = new AttachmentSet[0] + }; - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny(), It.IsAny())).Callback((string _, object o) => - { - Assert.AreEqual(Constants.EmptyRunSettings, ((TestRunAttachmentsProcessingPayload)o).RunSettings); - Assert.AreEqual(1, ((TestRunAttachmentsProcessingPayload)o).InvokedDataCollectors.Count()); - }); - mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( - () => this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(attachmentsProcessingComplete))); - - await this.requestSender.ProcessTestRunAttachmentsAsync( - new List { new AttachmentSet(new Uri("http://www.bing.com"), "a") }, - new List() { new InvokedDataCollector(new Uri("datacollector://sample"), "sample", typeof(string).AssemblyQualifiedName, typeof(string).Assembly.Location, false) }, - Constants.EmptyRunSettings, - false, - mockHandler.Object, - CancellationToken.None); + var attachmentsProcessingComplete = new Message() + { + MessageType = MessageType.TestRunAttachmentsProcessingComplete, + Payload = JToken.FromObject(payload) + }; + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(attachmentsProcessingComplete)); + _mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny(), It.IsAny())).Callback((string _, object o) => + { + Assert.AreEqual(Constants.EmptyRunSettings, ((TestRunAttachmentsProcessingPayload)o).RunSettings); + Assert.AreEqual(1, ((TestRunAttachmentsProcessingPayload)o).InvokedDataCollectors.Count()); + }); - mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingStart, It.IsAny())); - mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingCancel), Times.Never); - mockHandler.Verify(mh => mh.HandleTestRunAttachmentsProcessingComplete(It.IsAny(), It.Is>(a => a.Count == 1)), Times.Once, "Attachments Processing Complete must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Informational, "Hello"), Times.Once, "TestMessage event must be called"); - } + await _requestSender.ProcessTestRunAttachmentsAsync( + new List { new AttachmentSet(new Uri("http://www.bing.com"), "a") }, + new List() { new InvokedDataCollector(new Uri("datacollector://sample"), "sample", typeof(string).AssemblyQualifiedName, typeof(string).Assembly.Location, false) }, + Constants.EmptyRunSettings, + true, + mockHandler.Object, + CancellationToken.None); - [TestMethod] - public async Task ProcessTestRunAttachmentsAsyncShouldCompleteWithOneAttachmentAndProgressMessage() - { - await this.InitializeCommunicationAsync(); + _mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingStart, It.IsAny())); + _mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingCancel), Times.Never); + mockHandler.Verify(mh => mh.HandleTestRunAttachmentsProcessingComplete(It.Is(a => !a.IsCanceled && a.Error == null), It.Is>(a => a.Count == 0)), Times.Once, "Attachments Processing Complete must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); + } - var mockHandler = new Mock(); + [TestMethod] + public async Task ProcessTestRunAttachmentsAsyncShouldCompleteWithOneAttachment() + { + await InitializeCommunicationAsync(); - var completePayload = new TestRunAttachmentsProcessingCompletePayload() - { - AttachmentsProcessingCompleteEventArgs = new TestRunAttachmentsProcessingCompleteEventArgs(false, null), - Attachments = new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") } - }; + var mockHandler = new Mock(); - var attachmentsProcessingComplete = new Message() - { - MessageType = MessageType.TestRunAttachmentsProcessingComplete, - Payload = JToken.FromObject(completePayload) - }; + var payload = new TestRunAttachmentsProcessingCompletePayload() + { + AttachmentsProcessingCompleteEventArgs = new TestRunAttachmentsProcessingCompleteEventArgs(true, new Exception("msg")), + Attachments = new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") } + }; + var attachmentsProcessingComplete = new Message() + { + MessageType = MessageType.TestRunAttachmentsProcessingComplete, + Payload = JToken.FromObject(payload) + }; - var progressPayload = new TestRunAttachmentsProcessingProgressPayload() - { - AttachmentsProcessingProgressEventArgs = new TestRunAttachmentsProcessingProgressEventArgs(1, new[] { new Uri("http://www.bing.com/") }, 50, 2) - }; + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(attachmentsProcessingComplete)); + _mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny(), It.IsAny())).Callback((string _, object o) => + { + Assert.AreEqual(Constants.EmptyRunSettings, ((TestRunAttachmentsProcessingPayload)o).RunSettings); + Assert.AreEqual(1, ((TestRunAttachmentsProcessingPayload)o).InvokedDataCollectors.Count()); + }); - var attachmentsProcessingProgress = new Message() - { - MessageType = MessageType.TestRunAttachmentsProcessingProgress, - Payload = JToken.FromObject(progressPayload) - }; - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(attachmentsProcessingProgress)); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny(), It.IsAny())).Callback((string _, object o) => - { - Assert.AreEqual(Constants.EmptyRunSettings, ((TestRunAttachmentsProcessingPayload)o).RunSettings); - Assert.AreEqual(1, ((TestRunAttachmentsProcessingPayload)o).InvokedDataCollectors.Count()); - }); + await _requestSender.ProcessTestRunAttachmentsAsync( + new List { new AttachmentSet(new Uri("http://www.bing.com"), "a") }, + new List() { new InvokedDataCollector(new Uri("datacollector://sample"), "sample", typeof(string).AssemblyQualifiedName, typeof(string).Assembly.Location, false) }, + Constants.EmptyRunSettings, + true, + mockHandler.Object, + CancellationToken.None); - mockHandler.Setup(mh => mh.HandleTestRunAttachmentsProcessingProgress(It.IsAny())).Callback( - () => this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(attachmentsProcessingComplete))); + _mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingStart, It.IsAny())); + _mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingCancel), Times.Never); + mockHandler.Verify(mh => mh.HandleTestRunAttachmentsProcessingComplete(It.Is(a => a.IsCanceled && a.Error != null), It.Is>(a => a.Count == 1)), Times.Once, "Attachments Processing Complete must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); + } - await this.requestSender.ProcessTestRunAttachmentsAsync( - new List { new AttachmentSet(new Uri("http://www.bing.com"), "a") }, - new List() { new InvokedDataCollector(new Uri("datacollector://sample"), "sample", typeof(string).AssemblyQualifiedName, typeof(string).Assembly.Location, false) }, - Constants.EmptyRunSettings, - false, - mockHandler.Object, - CancellationToken.None); + [TestMethod] + public async Task ProcessTestRunAttachmentsAsyncShouldCompleteWithOneAttachmentAndTestMessage() + { + await InitializeCommunicationAsync(); - mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingStart, It.IsAny())); - mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingCancel), Times.Never); - mockHandler.Verify(mh => mh.HandleTestRunAttachmentsProcessingComplete(It.IsAny(), It.Is>(a => a.Count == 1)), Times.Once, "Attachments Processing Complete must be called"); - mockHandler.Verify(mh => mh.HandleTestRunAttachmentsProcessingProgress(It.Is(a => a.CurrentAttachmentProcessorIndex == 1 && a.CurrentAttachmentProcessorUris.First() == new Uri("http://www.bing.com/") && a.CurrentAttachmentProcessorProgress == 50 && a.AttachmentProcessorsCount == 2)), Times.Once, "Attachments processing Progress must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Informational, "Hello"), Times.Never); - } + var mockHandler = new Mock(); - [TestMethod] - public async Task ProcessTestRunAttachmentsAsyncShouldSendCancelMessageIfCancellationTokenCancelled() + var payload = new TestRunAttachmentsProcessingCompletePayload() { - await this.InitializeCommunicationAsync(); + AttachmentsProcessingCompleteEventArgs = new TestRunAttachmentsProcessingCompleteEventArgs(false, null), + Attachments = new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") } + }; - var cts = new CancellationTokenSource(); + var attachmentsProcessingComplete = new Message() + { + MessageType = MessageType.TestRunAttachmentsProcessingComplete, + Payload = JToken.FromObject(payload) + }; - var mockHandler = new Mock(); + var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; + var message = CreateMessage(MessageType.TestMessage, mpayload); - var payload = new TestRunAttachmentsProcessingCompletePayload() - { - Attachments = new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") } - }; - var attachmentsProcessingComplete = new Message() - { - MessageType = MessageType.TestRunAttachmentsProcessingComplete, - Payload = JToken.FromObject(payload) - }; + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); + _mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny(), It.IsAny())).Callback((string _, object o) => + { + Assert.AreEqual(Constants.EmptyRunSettings, ((TestRunAttachmentsProcessingPayload)o).RunSettings); + Assert.AreEqual(1, ((TestRunAttachmentsProcessingPayload)o).InvokedDataCollectors.Count()); + }); + mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback( + () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(attachmentsProcessingComplete))); - var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; - var message = CreateMessage(MessageType.TestMessage, mpayload); + await _requestSender.ProcessTestRunAttachmentsAsync( + new List { new AttachmentSet(new Uri("http://www.bing.com"), "a") }, + new List() { new InvokedDataCollector(new Uri("datacollector://sample"), "sample", typeof(string).AssemblyQualifiedName, typeof(string).Assembly.Location, false) }, + Constants.EmptyRunSettings, + false, + mockHandler.Object, + CancellationToken.None); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny(), It.IsAny())).Callback((string _, object o) => - { - Assert.AreEqual(Constants.EmptyRunSettings, ((TestRunAttachmentsProcessingPayload)o).RunSettings); - Assert.AreEqual(1, ((TestRunAttachmentsProcessingPayload)o).InvokedDataCollectors.Count()); - }); - mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback(() => - { - cts.Cancel(); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(attachmentsProcessingComplete)); - }); + _mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingStart, It.IsAny())); + _mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingCancel), Times.Never); + mockHandler.Verify(mh => mh.HandleTestRunAttachmentsProcessingComplete(It.IsAny(), It.Is>(a => a.Count == 1)), Times.Once, "Attachments Processing Complete must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Informational, "Hello"), Times.Once, "TestMessage event must be called"); + } - await this.requestSender.ProcessTestRunAttachmentsAsync( - new List { new AttachmentSet(new Uri("http://www.bing.com"), "a") }, - new List() { new InvokedDataCollector(new Uri("datacollector://sample"), "sample", typeof(string).AssemblyQualifiedName, typeof(string).Assembly.Location, false) }, - Constants.EmptyRunSettings, - false, - mockHandler.Object, - cts.Token); + [TestMethod] + public async Task ProcessTestRunAttachmentsAsyncShouldCompleteWithOneAttachmentAndProgressMessage() + { + await InitializeCommunicationAsync(); - mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingStart, It.IsAny())); - mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingCancel)); - mockHandler.Verify(mh => mh.HandleTestRunAttachmentsProcessingComplete(It.IsAny(), It.Is>(a => a.Count == 1)), Times.Once, "Attachments Processing Complete must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Informational, "Hello"), Times.Once, "TestMessage event must be called"); - } + var mockHandler = new Mock(); - [TestMethod] - public async Task ProcessTestRunAttachmentsAsyncShouldSendCancelMessageIfCancellationTokenCancelledAtTheBeginning() + var completePayload = new TestRunAttachmentsProcessingCompletePayload() { - await this.InitializeCommunicationAsync(); + AttachmentsProcessingCompleteEventArgs = new TestRunAttachmentsProcessingCompleteEventArgs(false, null), + Attachments = new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") } + }; - var cts = new CancellationTokenSource(); - cts.Cancel(); + var attachmentsProcessingComplete = new Message() + { + MessageType = MessageType.TestRunAttachmentsProcessingComplete, + Payload = JToken.FromObject(completePayload) + }; - var mockHandler = new Mock(); + var progressPayload = new TestRunAttachmentsProcessingProgressPayload() + { + AttachmentsProcessingProgressEventArgs = new TestRunAttachmentsProcessingProgressEventArgs(1, new[] { new Uri("http://www.bing.com/") }, 50, 2) + }; - var payload = new TestRunAttachmentsProcessingCompletePayload() - { - Attachments = new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") } - }; - var attachmentsProcessingComplete = new Message() - { - MessageType = MessageType.TestRunAttachmentsProcessingComplete, - Payload = JToken.FromObject(payload) - }; + var attachmentsProcessingProgress = new Message() + { + MessageType = MessageType.TestRunAttachmentsProcessingProgress, + Payload = JToken.FromObject(progressPayload) + }; + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(attachmentsProcessingProgress)); + _mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny(), It.IsAny())).Callback((string _, object o) => + { + Assert.AreEqual(Constants.EmptyRunSettings, ((TestRunAttachmentsProcessingPayload)o).RunSettings); + Assert.AreEqual(1, ((TestRunAttachmentsProcessingPayload)o).InvokedDataCollectors.Count()); + }); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(attachmentsProcessingComplete)); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny(), It.IsAny())).Callback((string _, object o) => - { - Assert.AreEqual(Constants.EmptyRunSettings, ((TestRunAttachmentsProcessingPayload)o).RunSettings); - Assert.AreEqual(1, ((TestRunAttachmentsProcessingPayload)o).InvokedDataCollectors.Count()); - }); + mockHandler.Setup(mh => mh.HandleTestRunAttachmentsProcessingProgress(It.IsAny())).Callback( + () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(attachmentsProcessingComplete))); - await this.requestSender.ProcessTestRunAttachmentsAsync( - new List { new AttachmentSet(new Uri("http://www.bing.com"), "a") }, - new List() { new InvokedDataCollector(new Uri("datacollector://sample"), "sample", typeof(string).AssemblyQualifiedName, typeof(string).Assembly.Location, false) }, - Constants.EmptyRunSettings, - true, - mockHandler.Object, - cts.Token); + await _requestSender.ProcessTestRunAttachmentsAsync( + new List { new AttachmentSet(new Uri("http://www.bing.com"), "a") }, + new List() { new InvokedDataCollector(new Uri("datacollector://sample"), "sample", typeof(string).AssemblyQualifiedName, typeof(string).Assembly.Location, false) }, + Constants.EmptyRunSettings, + false, + mockHandler.Object, + CancellationToken.None); - mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingStart, It.IsAny())); - mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingCancel)); - mockHandler.Verify(mh => mh.HandleTestRunAttachmentsProcessingComplete(It.IsAny(), It.Is>(a => a.Count == 1)), Times.Once, "Attachments Processing Complete must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Informational, "Hello"), Times.Never, "TestMessage event must be called"); - } + _mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingStart, It.IsAny())); + _mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingCancel), Times.Never); + mockHandler.Verify(mh => mh.HandleTestRunAttachmentsProcessingComplete(It.IsAny(), It.Is>(a => a.Count == 1)), Times.Once, "Attachments Processing Complete must be called"); + mockHandler.Verify(mh => mh.HandleTestRunAttachmentsProcessingProgress(It.Is(a => a.CurrentAttachmentProcessorIndex == 1 && a.CurrentAttachmentProcessorUris.First() == new Uri("http://www.bing.com/") && a.CurrentAttachmentProcessorProgress == 50 && a.AttachmentProcessorsCount == 2)), Times.Once, "Attachments processing Progress must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Informational, "Hello"), Times.Never); + } - [TestMethod] - public async Task ProcessTestRunAttachmentsAsyncShouldAbortOnExceptionInSendMessage() - { - var mockHandler = new Mock(); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.TestRunAttachmentsProcessingStart, It.IsAny())).Throws(new IOException()); + [TestMethod] + public async Task ProcessTestRunAttachmentsAsyncShouldSendCancelMessageIfCancellationTokenCancelled() + { + await InitializeCommunicationAsync(); - await this.requestSender.ProcessTestRunAttachmentsAsync(new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") }, new List(), Constants.EmptyRunSettings, false, mockHandler.Object, CancellationToken.None); + var cts = new CancellationTokenSource(); - mockHandler.Verify(mh => mh.HandleTestRunAttachmentsProcessingComplete(It.Is(a => !a.IsCanceled && a.Error is IOException), null), Times.Once, "Attachments Processing Complete must be called"); - mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once, "TestMessage event must be called"); - this.mockCommunicationManager.Verify(cm => cm.StopServer(), Times.Never); - } + var mockHandler = new Mock(); - #endregion + var payload = new TestRunAttachmentsProcessingCompletePayload() + { + Attachments = new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") } + }; + var attachmentsProcessingComplete = new Message() + { + MessageType = MessageType.TestRunAttachmentsProcessingComplete, + Payload = JToken.FromObject(payload) + }; - #region Sessions API - private const int MinimumProtocolVersionWithTestSessionSupport = 5; - private const int TesthostPid = 5000; + var mpayload = new TestMessagePayload() { MessageLevel = TestMessageLevel.Informational, Message = "Hello" }; + var message = CreateMessage(MessageType.TestMessage, mpayload); - [TestMethod] - public void StartTestSessionShouldFailIfWrongProtocolVersionIsNegotiated() + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(message)); + _mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny(), It.IsAny())).Callback((string _, object o) => + { + Assert.AreEqual(Constants.EmptyRunSettings, ((TestRunAttachmentsProcessingPayload)o).RunSettings); + Assert.AreEqual(1, ((TestRunAttachmentsProcessingPayload)o).InvokedDataCollectors.Count()); + }); + mockHandler.Setup(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny())).Callback(() => { - this.InitializeCommunication(MinimumProtocolVersionWithTestSessionSupport - 1); + cts.Cancel(); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(attachmentsProcessingComplete)); + }); + + await _requestSender.ProcessTestRunAttachmentsAsync( + new List { new AttachmentSet(new Uri("http://www.bing.com"), "a") }, + new List() { new InvokedDataCollector(new Uri("datacollector://sample"), "sample", typeof(string).AssemblyQualifiedName, typeof(string).Assembly.Location, false) }, + Constants.EmptyRunSettings, + false, + mockHandler.Object, + cts.Token); + + _mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingStart, It.IsAny())); + _mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingCancel)); + mockHandler.Verify(mh => mh.HandleTestRunAttachmentsProcessingComplete(It.IsAny(), It.Is>(a => a.Count == 1)), Times.Once, "Attachments Processing Complete must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Informational, "Hello"), Times.Once, "TestMessage event must be called"); + } - var mockHandler = new Mock(); - mockHandler.Setup(mh => mh.HandleStartTestSessionComplete(It.IsAny())).Callback(() => { }); + [TestMethod] + public async Task ProcessTestRunAttachmentsAsyncShouldSendCancelMessageIfCancellationTokenCancelledAtTheBeginning() + { + await InitializeCommunicationAsync(); - Assert.IsNull(this.requestSender.StartTestSession( - new List() { "DummyTestAssembly.dll" }, - string.Empty, - null, - mockHandler.Object, - null)); + var cts = new CancellationTokenSource(); + cts.Cancel(); - mockHandler.Verify(mh => mh.HandleStartTestSessionComplete(null), Times.Once); - } + var mockHandler = new Mock(); - [TestMethod] - public async Task StartTestSessionAsyncShouldFailIfWrongProtocolVersionIsNegotiated() + var payload = new TestRunAttachmentsProcessingCompletePayload() { - await this.InitializeCommunicationAsync(MinimumProtocolVersionWithTestSessionSupport - 1).ConfigureAwait(false); - - var mockHandler = new Mock(); - mockHandler.Setup(mh => mh.HandleStartTestSessionComplete(It.IsAny())).Callback(() => { }); + Attachments = new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") } + }; + var attachmentsProcessingComplete = new Message() + { + MessageType = MessageType.TestRunAttachmentsProcessingComplete, + Payload = JToken.FromObject(payload) + }; - Assert.IsNull(await this.requestSender.StartTestSessionAsync( - new List() { "DummyTestAssembly.dll" }, - string.Empty, - null, - mockHandler.Object, - null).ConfigureAwait(false)); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(attachmentsProcessingComplete)); + _mockCommunicationManager.Setup(cm => cm.SendMessage(It.IsAny(), It.IsAny())).Callback((string _, object o) => + { + Assert.AreEqual(Constants.EmptyRunSettings, ((TestRunAttachmentsProcessingPayload)o).RunSettings); + Assert.AreEqual(1, ((TestRunAttachmentsProcessingPayload)o).InvokedDataCollectors.Count()); + }); - mockHandler.Verify(mh => mh.HandleStartTestSessionComplete(null), Times.Once); - } + await _requestSender.ProcessTestRunAttachmentsAsync( + new List { new AttachmentSet(new Uri("http://www.bing.com"), "a") }, + new List() { new InvokedDataCollector(new Uri("datacollector://sample"), "sample", typeof(string).AssemblyQualifiedName, typeof(string).Assembly.Location, false) }, + Constants.EmptyRunSettings, + true, + mockHandler.Object, + cts.Token); - [TestMethod] - public void StartTestSessionShouldSucceed() - { - this.InitializeCommunication(); + _mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingStart, It.IsAny())); + _mockCommunicationManager.Verify(c => c.SendMessage(MessageType.TestRunAttachmentsProcessingCancel)); + mockHandler.Verify(mh => mh.HandleTestRunAttachmentsProcessingComplete(It.IsAny(), It.Is>(a => a.Count == 1)), Times.Once, "Attachments Processing Complete must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Informational, "Hello"), Times.Never, "TestMessage event must be called"); + } - var mockHandler = new Mock(); - mockHandler.Setup(mh => mh.HandleStartTestSessionComplete(It.IsAny())).Callback(() => { }); + [TestMethod] + public async Task ProcessTestRunAttachmentsAsyncShouldAbortOnExceptionInSendMessage() + { + var mockHandler = new Mock(); + _mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.TestRunAttachmentsProcessingStart, It.IsAny())).Throws(new IOException()); - var testSessionInfo = new TestSessionInfo(); - var ackPayload = new Payloads.StartTestSessionAckPayload() - { - TestSessionInfo = testSessionInfo - }; - var message = this.CreateMessage( - MessageType.StartTestSessionCallback, - ackPayload); - - this.mockCommunicationManager.Setup(cm => cm.SendMessage( - MessageType.StartTestSession, - It.IsAny(), - this.protocolVersion)).Callback(() => { }); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) - .Returns(Task.FromResult(message)); - - Assert.AreEqual( - testSessionInfo, - this.requestSender.StartTestSession( - new List() { "DummyTestAssembly.dll" }, - string.Empty, - null, - mockHandler.Object, - null)); - mockHandler.Verify(mh => mh.HandleStartTestSessionComplete(testSessionInfo), Times.Once); - } - - [TestMethod] - public async Task StartTestSessionAsyncShouldSucceed() - { - await this.InitializeCommunicationAsync().ConfigureAwait(false); + await _requestSender.ProcessTestRunAttachmentsAsync(new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") }, new List(), Constants.EmptyRunSettings, false, mockHandler.Object, CancellationToken.None); - var mockHandler = new Mock(); - mockHandler.Setup(mh => mh.HandleStartTestSessionComplete(It.IsAny())).Callback(() => { }); + mockHandler.Verify(mh => mh.HandleTestRunAttachmentsProcessingComplete(It.Is(a => !a.IsCanceled && a.Error is IOException), null), Times.Once, "Attachments Processing Complete must be called"); + mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once, "TestMessage event must be called"); + _mockCommunicationManager.Verify(cm => cm.StopServer(), Times.Never); + } - var testSessionInfo = new TestSessionInfo(); - var ackPayload = new Payloads.StartTestSessionAckPayload() - { - TestSessionInfo = testSessionInfo - }; - var message = this.CreateMessage( - MessageType.StartTestSessionCallback, - ackPayload); - - this.mockCommunicationManager.Setup(cm => cm.SendMessage( - MessageType.StartTestSession, - It.IsAny(), - this.protocolVersion)).Callback(() => { }); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) - .Returns(Task.FromResult(message)); - - Assert.AreEqual( - testSessionInfo, - await this.requestSender.StartTestSessionAsync( - new List() { "DummyTestAssembly.dll" }, - string.Empty, - null, - mockHandler.Object, - null).ConfigureAwait(false)); - } - - [TestMethod] - public void StartTestSessionWithTesthostLauncherShouldSucceed() - { - this.InitializeCommunication(); + #endregion - // Setup - var mockHandler = new Mock(); - mockHandler.Setup(mh => mh.HandleStartTestSessionComplete(It.IsAny())).Callback(() => { }); - var mockTesthostLauncher = new Mock(); - mockTesthostLauncher.Setup(tl => tl.LaunchTestHost(It.IsAny())).Returns(TesthostPid); + #region Sessions API + private const int MinimumProtocolVersionWithTestSessionSupport = 5; + private const int TesthostPid = 5000; - var launchInfo = new TestProcessStartInfo(); - var launchMessage = this.CreateMessage( - MessageType.CustomTestHostLaunch, - launchInfo); + [TestMethod] + public void StartTestSessionShouldFailIfWrongProtocolVersionIsNegotiated() + { + InitializeCommunication(MinimumProtocolVersionWithTestSessionSupport - 1); - var testSessionInfo = new TestSessionInfo(); - var ackPayload = new Payloads.StartTestSessionAckPayload() - { - TestSessionInfo = testSessionInfo - }; - var ackMessage = this.CreateMessage( - MessageType.StartTestSessionCallback, - ackPayload); + var mockHandler = new Mock(); + mockHandler.Setup(mh => mh.HandleStartTestSessionComplete(It.IsAny())).Callback(() => { }); - Action reconfigureAction = () => - { - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) - .Returns(Task.FromResult(ackMessage)); - }; - - this.mockCommunicationManager.Setup(cm => cm.SendMessage( - MessageType.StartTestSession, - It.IsAny(), - this.protocolVersion)).Callback(() => { }); - this.mockCommunicationManager.Setup(cm => cm.SendMessage( - MessageType.CustomTestHostLaunchCallback, - It.IsAny(), - this.protocolVersion)) - .Callback((string messageType, object payload, int version) => - { - Assert.AreEqual(((CustomHostLaunchAckPayload)payload).HostProcessId, TesthostPid); - }); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) - .Returns(Task.FromResult(launchMessage)) - .Callback(reconfigureAction); - - // Act - Assert.AreEqual( - testSessionInfo, - this.requestSender.StartTestSession( - new List() { "DummyTestAssembly.dll" }, - string.Empty, - null, - mockHandler.Object, - mockTesthostLauncher.Object)); - - // Verify - mockTesthostLauncher.Verify(tl => tl.LaunchTestHost(It.IsAny()), Times.Once); - mockHandler.Verify(mh => mh.HandleStartTestSessionComplete(testSessionInfo), Times.Once); - } - - [TestMethod] - public async Task StartTestSessionAsyncWithTesthostLauncherShouldSucceed() - { - await this.InitializeCommunicationAsync().ConfigureAwait(false); + Assert.IsNull(_requestSender.StartTestSession( + new List() { "DummyTestAssembly.dll" }, + string.Empty, + null, + mockHandler.Object, + null)); - // Setup - var mockHandler = new Mock(); - mockHandler.Setup(mh => mh.HandleStartTestSessionComplete(It.IsAny())).Callback(() => { }); - var mockTesthostLauncher = new Mock(); - mockTesthostLauncher.Setup(tl => tl.LaunchTestHost(It.IsAny())).Returns(TesthostPid); + mockHandler.Verify(mh => mh.HandleStartTestSessionComplete(null), Times.Once); + } - var launchInfo = new TestProcessStartInfo(); - var launchMessage = this.CreateMessage( - MessageType.CustomTestHostLaunch, - launchInfo); + [TestMethod] + public async Task StartTestSessionAsyncShouldFailIfWrongProtocolVersionIsNegotiated() + { + await InitializeCommunicationAsync(MinimumProtocolVersionWithTestSessionSupport - 1).ConfigureAwait(false); - var testSessionInfo = new TestSessionInfo(); - var ackPayload = new Payloads.StartTestSessionAckPayload() - { - TestSessionInfo = testSessionInfo - }; - var ackMessage = this.CreateMessage( - MessageType.StartTestSessionCallback, - ackPayload); + var mockHandler = new Mock(); + mockHandler.Setup(mh => mh.HandleStartTestSessionComplete(It.IsAny())).Callback(() => { }); - Action reconfigureAction = () => - { - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) - .Returns(Task.FromResult(ackMessage)); - }; - - this.mockCommunicationManager.Setup(cm => cm.SendMessage( - MessageType.StartTestSession, - It.IsAny(), - this.protocolVersion)).Callback(() => { }); - this.mockCommunicationManager.Setup(cm => cm.SendMessage( - MessageType.CustomTestHostLaunchCallback, - It.IsAny(), - this.protocolVersion)) - .Callback((string messageType, object payload, int version) => - { - Assert.AreEqual(((CustomHostLaunchAckPayload)payload).HostProcessId, TesthostPid); - }); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) - .Returns(Task.FromResult(launchMessage)) - .Callback(reconfigureAction); - - // Act - Assert.AreEqual( - testSessionInfo, - await this.requestSender.StartTestSessionAsync( - new List() { "DummyTestAssembly.dll" }, - string.Empty, - null, - mockHandler.Object, - mockTesthostLauncher.Object).ConfigureAwait(false)); - - // Verify - mockTesthostLauncher.Verify(tl => tl.LaunchTestHost(It.IsAny()), Times.Once); - mockHandler.Verify(mh => mh.HandleStartTestSessionComplete(testSessionInfo), Times.Once); - } - - [TestMethod] - public void StartTestSessionWithTesthostLauncherAttachingToProcessShouldSucceed() - { - this.InitializeCommunication(); + Assert.IsNull(await _requestSender.StartTestSessionAsync( + new List() { "DummyTestAssembly.dll" }, + string.Empty, + null, + mockHandler.Object, + null).ConfigureAwait(false)); - // Setup - var mockHandler = new Mock(); - mockHandler.Setup(mh => mh.HandleStartTestSessionComplete(It.IsAny())).Callback(() => { }); - var mockTesthostLauncher = new Mock(); - mockTesthostLauncher.Setup(tl => tl.AttachDebuggerToProcess(TesthostPid)).Returns(true); + mockHandler.Verify(mh => mh.HandleStartTestSessionComplete(null), Times.Once); + } - var launchMessage = this.CreateMessage( - MessageType.EditorAttachDebugger, - TesthostPid); + [TestMethod] + public void StartTestSessionShouldSucceed() + { + InitializeCommunication(); + + var mockHandler = new Mock(); + mockHandler.Setup(mh => mh.HandleStartTestSessionComplete(It.IsAny())).Callback(() => { }); + + var testSessionInfo = new TestSessionInfo(); + var ackPayload = new Payloads.StartTestSessionAckPayload() + { + TestSessionInfo = testSessionInfo + }; + var message = CreateMessage( + MessageType.StartTestSessionCallback, + ackPayload); + + _mockCommunicationManager.Setup(cm => cm.SendMessage( + MessageType.StartTestSession, + It.IsAny(), + _protocolVersion)).Callback(() => { }); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) + .Returns(Task.FromResult(message)); + + Assert.AreEqual( + testSessionInfo, + _requestSender.StartTestSession( + new List() { "DummyTestAssembly.dll" }, + string.Empty, + null, + mockHandler.Object, + null)); + mockHandler.Verify(mh => mh.HandleStartTestSessionComplete(testSessionInfo), Times.Once); + } - var testSessionInfo = new TestSessionInfo(); - var ackPayload = new Payloads.StartTestSessionAckPayload() - { - TestSessionInfo = testSessionInfo - }; - var ackMessage = this.CreateMessage( - MessageType.StartTestSessionCallback, - ackPayload); + [TestMethod] + public async Task StartTestSessionAsyncShouldSucceed() + { + await InitializeCommunicationAsync().ConfigureAwait(false); + + var mockHandler = new Mock(); + mockHandler.Setup(mh => mh.HandleStartTestSessionComplete(It.IsAny())).Callback(() => { }); + + var testSessionInfo = new TestSessionInfo(); + var ackPayload = new Payloads.StartTestSessionAckPayload() + { + TestSessionInfo = testSessionInfo + }; + var message = CreateMessage( + MessageType.StartTestSessionCallback, + ackPayload); + + _mockCommunicationManager.Setup(cm => cm.SendMessage( + MessageType.StartTestSession, + It.IsAny(), + _protocolVersion)).Callback(() => { }); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) + .Returns(Task.FromResult(message)); + + Assert.AreEqual( + testSessionInfo, + await _requestSender.StartTestSessionAsync( + new List() { "DummyTestAssembly.dll" }, + string.Empty, + null, + mockHandler.Object, + null).ConfigureAwait(false)); + } - Action reconfigureAction = () => - { - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) - .Returns(Task.FromResult(ackMessage)); - }; - - this.mockCommunicationManager.Setup(cm => cm.SendMessage( - MessageType.StartTestSession, - It.IsAny(), - this.protocolVersion)).Callback(() => { }); - this.mockCommunicationManager.Setup(cm => cm.SendMessage( - MessageType.EditorAttachDebuggerCallback, - It.IsAny(), - this.protocolVersion)) - .Callback((string messageType, object payload, int version) => - { - Assert.IsTrue(((EditorAttachDebuggerAckPayload)payload).Attached); - }); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) - .Returns(Task.FromResult(launchMessage)) - .Callback(reconfigureAction); - - // Act - Assert.AreEqual( - testSessionInfo, - this.requestSender.StartTestSession( - new List() { "DummyTestAssembly.dll" }, - string.Empty, - null, - mockHandler.Object, - mockTesthostLauncher.Object)); - - // Verify - mockTesthostLauncher.Verify(tl => tl.AttachDebuggerToProcess(TesthostPid), Times.Once); - mockHandler.Verify(mh => mh.HandleStartTestSessionComplete(testSessionInfo), Times.Once); - } - - [TestMethod] - public async Task StartTestSessionAsyncWithTesthostLauncherAttachingToProcessShouldSucceed() - { - await this.InitializeCommunicationAsync().ConfigureAwait(false); + [TestMethod] + public void StartTestSessionWithTesthostLauncherShouldSucceed() + { + InitializeCommunication(); + + // Setup + var mockHandler = new Mock(); + mockHandler.Setup(mh => mh.HandleStartTestSessionComplete(It.IsAny())).Callback(() => { }); + var mockTesthostLauncher = new Mock(); + mockTesthostLauncher.Setup(tl => tl.LaunchTestHost(It.IsAny())).Returns(TesthostPid); + + var launchInfo = new TestProcessStartInfo(); + var launchMessage = CreateMessage( + MessageType.CustomTestHostLaunch, + launchInfo); + + var testSessionInfo = new TestSessionInfo(); + var ackPayload = new Payloads.StartTestSessionAckPayload() + { + TestSessionInfo = testSessionInfo + }; + var ackMessage = CreateMessage( + MessageType.StartTestSessionCallback, + ackPayload); + + Action reconfigureAction = () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) + .Returns(Task.FromResult(ackMessage)); + + _mockCommunicationManager.Setup(cm => cm.SendMessage( + MessageType.StartTestSession, + It.IsAny(), + _protocolVersion)).Callback(() => { }); + _mockCommunicationManager.Setup(cm => cm.SendMessage( + MessageType.CustomTestHostLaunchCallback, + It.IsAny(), + _protocolVersion)) + .Callback((string messageType, object payload, int version) => Assert.AreEqual(((CustomHostLaunchAckPayload)payload).HostProcessId, TesthostPid)); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) + .Returns(Task.FromResult(launchMessage)) + .Callback(reconfigureAction); + + // Act + Assert.AreEqual( + testSessionInfo, + _requestSender.StartTestSession( + new List() { "DummyTestAssembly.dll" }, + string.Empty, + null, + mockHandler.Object, + mockTesthostLauncher.Object)); - // Setup - var mockHandler = new Mock(); - mockHandler.Setup(mh => mh.HandleStartTestSessionComplete(It.IsAny())).Callback(() => { }); - var mockTesthostLauncher = new Mock(); - mockTesthostLauncher.Setup(tl => tl.AttachDebuggerToProcess(TesthostPid)).Returns(true); + // Verify + mockTesthostLauncher.Verify(tl => tl.LaunchTestHost(It.IsAny()), Times.Once); + mockHandler.Verify(mh => mh.HandleStartTestSessionComplete(testSessionInfo), Times.Once); + } - var launchMessage = this.CreateMessage( - MessageType.EditorAttachDebugger, - TesthostPid); + [TestMethod] + public async Task StartTestSessionAsyncWithTesthostLauncherShouldSucceed() + { + await InitializeCommunicationAsync().ConfigureAwait(false); + + // Setup + var mockHandler = new Mock(); + mockHandler.Setup(mh => mh.HandleStartTestSessionComplete(It.IsAny())).Callback(() => { }); + var mockTesthostLauncher = new Mock(); + mockTesthostLauncher.Setup(tl => tl.LaunchTestHost(It.IsAny())).Returns(TesthostPid); + + var launchInfo = new TestProcessStartInfo(); + var launchMessage = CreateMessage( + MessageType.CustomTestHostLaunch, + launchInfo); + + var testSessionInfo = new TestSessionInfo(); + var ackPayload = new Payloads.StartTestSessionAckPayload() + { + TestSessionInfo = testSessionInfo + }; + var ackMessage = CreateMessage( + MessageType.StartTestSessionCallback, + ackPayload); + + Action reconfigureAction = () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) + .Returns(Task.FromResult(ackMessage)); + + _mockCommunicationManager.Setup(cm => cm.SendMessage( + MessageType.StartTestSession, + It.IsAny(), + _protocolVersion)).Callback(() => { }); + _mockCommunicationManager.Setup(cm => cm.SendMessage( + MessageType.CustomTestHostLaunchCallback, + It.IsAny(), + _protocolVersion)) + .Callback((string messageType, object payload, int version) => Assert.AreEqual(((CustomHostLaunchAckPayload)payload).HostProcessId, TesthostPid)); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) + .Returns(Task.FromResult(launchMessage)) + .Callback(reconfigureAction); + + // Act + Assert.AreEqual( + testSessionInfo, + await _requestSender.StartTestSessionAsync( + new List() { "DummyTestAssembly.dll" }, + string.Empty, + null, + mockHandler.Object, + mockTesthostLauncher.Object).ConfigureAwait(false)); - var testSessionInfo = new TestSessionInfo(); - var ackPayload = new Payloads.StartTestSessionAckPayload() - { - TestSessionInfo = testSessionInfo - }; - var ackMessage = this.CreateMessage( - MessageType.StartTestSessionCallback, - ackPayload); + // Verify + mockTesthostLauncher.Verify(tl => tl.LaunchTestHost(It.IsAny()), Times.Once); + mockHandler.Verify(mh => mh.HandleStartTestSessionComplete(testSessionInfo), Times.Once); + } - Action reconfigureAction = () => - { - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) - .Returns(Task.FromResult(ackMessage)); - }; - - this.mockCommunicationManager.Setup(cm => cm.SendMessage( - MessageType.StartTestSession, - It.IsAny(), - this.protocolVersion)).Callback(() => { }); - this.mockCommunicationManager.Setup(cm => cm.SendMessage( - MessageType.EditorAttachDebuggerCallback, - It.IsAny(), - this.protocolVersion)) - .Callback((string messageType, object payload, int version) => - { - Assert.IsTrue(((EditorAttachDebuggerAckPayload)payload).Attached); - }); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) - .Returns(Task.FromResult(launchMessage)) - .Callback(reconfigureAction); - - // Act - Assert.AreEqual( - testSessionInfo, - await this.requestSender.StartTestSessionAsync( - new List() { "DummyTestAssembly.dll" }, - string.Empty, - null, - mockHandler.Object, - mockTesthostLauncher.Object).ConfigureAwait(false)); - - // Verify - mockTesthostLauncher.Verify(tl => tl.AttachDebuggerToProcess(TesthostPid), Times.Once); - mockHandler.Verify(mh => mh.HandleStartTestSessionComplete(testSessionInfo), Times.Once); - } - #endregion - - #region Private Methods - - /// - /// Serialize and Deserialize message as it would happen for real. - /// - /// - /// - /// - /// - private Message CreateMessage(string messageType, T payload) - { - return this.serializer.DeserializeMessage(this.serializer.SerializePayload(messageType, payload, this.protocolVersion)); - } + [TestMethod] + public void StartTestSessionWithTesthostLauncherAttachingToProcessShouldSucceed() + { + InitializeCommunication(); + + // Setup + var mockHandler = new Mock(); + mockHandler.Setup(mh => mh.HandleStartTestSessionComplete(It.IsAny())).Callback(() => { }); + var mockTesthostLauncher = new Mock(); + mockTesthostLauncher.Setup(tl => tl.AttachDebuggerToProcess(TesthostPid)).Returns(true); + + var launchMessage = CreateMessage( + MessageType.EditorAttachDebugger, + TesthostPid); + + var testSessionInfo = new TestSessionInfo(); + var ackPayload = new Payloads.StartTestSessionAckPayload() + { + TestSessionInfo = testSessionInfo + }; + var ackMessage = CreateMessage( + MessageType.StartTestSessionCallback, + ackPayload); + + Action reconfigureAction = () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) + .Returns(Task.FromResult(ackMessage)); + + _mockCommunicationManager.Setup(cm => cm.SendMessage( + MessageType.StartTestSession, + It.IsAny(), + _protocolVersion)).Callback(() => { }); + _mockCommunicationManager.Setup(cm => cm.SendMessage( + MessageType.EditorAttachDebuggerCallback, + It.IsAny(), + _protocolVersion)) + .Callback((string messageType, object payload, int version) => Assert.IsTrue(((EditorAttachDebuggerAckPayload)payload).Attached)); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) + .Returns(Task.FromResult(launchMessage)) + .Callback(reconfigureAction); + + // Act + Assert.AreEqual( + testSessionInfo, + _requestSender.StartTestSession( + new List() { "DummyTestAssembly.dll" }, + string.Empty, + null, + mockHandler.Object, + mockTesthostLauncher.Object)); - private void InitializeCommunication() - { - this.InitializeCommunication(this.protocolVersion); - } + // Verify + mockTesthostLauncher.Verify(tl => tl.AttachDebuggerToProcess(TesthostPid), Times.Once); + mockHandler.Verify(mh => mh.HandleStartTestSessionComplete(testSessionInfo), Times.Once); + } - private void InitializeCommunication(int protocolVersion) - { - var dummyPortInput = 123; - this.mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); - this.mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); + [TestMethod] + public async Task StartTestSessionAsyncWithTesthostLauncherAttachingToProcessShouldSucceed() + { + await InitializeCommunicationAsync().ConfigureAwait(false); + + // Setup + var mockHandler = new Mock(); + mockHandler.Setup(mh => mh.HandleStartTestSessionComplete(It.IsAny())).Callback(() => { }); + var mockTesthostLauncher = new Mock(); + mockTesthostLauncher.Setup(tl => tl.AttachDebuggerToProcess(TesthostPid)).Returns(true); + + var launchMessage = CreateMessage( + MessageType.EditorAttachDebugger, + TesthostPid); + + var testSessionInfo = new TestSessionInfo(); + var ackPayload = new Payloads.StartTestSessionAckPayload() + { + TestSessionInfo = testSessionInfo + }; + var ackMessage = CreateMessage( + MessageType.StartTestSessionCallback, + ackPayload); + + Action reconfigureAction = () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) + .Returns(Task.FromResult(ackMessage)); + + _mockCommunicationManager.Setup(cm => cm.SendMessage( + MessageType.StartTestSession, + It.IsAny(), + _protocolVersion)).Callback(() => { }); + _mockCommunicationManager.Setup(cm => cm.SendMessage( + MessageType.EditorAttachDebuggerCallback, + It.IsAny(), + _protocolVersion)) + .Callback((string messageType, object payload, int version) => Assert.IsTrue(((EditorAttachDebuggerAckPayload)payload).Attached)); + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())) + .Returns(Task.FromResult(launchMessage)) + .Callback(reconfigureAction); + + // Act + Assert.AreEqual( + testSessionInfo, + await _requestSender.StartTestSessionAsync( + new List() { "DummyTestAssembly.dll" }, + string.Empty, + null, + mockHandler.Object, + mockTesthostLauncher.Object).ConfigureAwait(false)); - this.mockCommunicationManager.Setup(cm => cm.WaitForClientConnection(Timeout.Infinite)) - .Callback((int timeout) => Task.Delay(200).Wait()); + // Verify + mockTesthostLauncher.Verify(tl => tl.AttachDebuggerToProcess(TesthostPid), Times.Once); + mockHandler.Verify(mh => mh.HandleStartTestSessionComplete(testSessionInfo), Times.Once); + } + #endregion + + #region Private Methods + + /// + /// Serialize and Deserialize message as it would happen for real. + /// + /// + /// + /// + /// + private Message CreateMessage(string messageType, T payload) + { + return _serializer.DeserializeMessage(_serializer.SerializePayload(messageType, payload, _protocolVersion)); + } - var sessionConnected = new Message() { MessageType = MessageType.SessionConnected }; - var versionCheck = new Message() { MessageType = MessageType.VersionCheck, Payload = protocolVersion }; + private void InitializeCommunication() + { + InitializeCommunication(_protocolVersion); + } - Action changedMessage = () => - { - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessage()).Returns(versionCheck); - }; + private void InitializeCommunication(int protocolVersion) + { + var dummyPortInput = 123; + _mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); + _mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessage()).Returns(sessionConnected); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.VersionCheck, It.IsAny())).Callback(changedMessage); + _mockCommunicationManager.Setup(cm => cm.WaitForClientConnection(Timeout.Infinite)) + .Callback((int timeout) => Task.Delay(200).Wait()); - var portOutput = this.requestSender.InitializeCommunication(); - Assert.AreEqual(dummyPortInput, portOutput, "Port number must return without changes."); - var connectionSuccess = this.requestSender.WaitForRequestHandlerConnection(this.WaitTimeout); - Assert.IsTrue(connectionSuccess, "Connection must succeed."); - } + var sessionConnected = new Message() { MessageType = MessageType.SessionConnected }; + var versionCheck = new Message() { MessageType = MessageType.VersionCheck, Payload = protocolVersion }; - private void SetupMockCommunicationForRunRequest(Mock mockHandler) - { - this.InitializeCommunication(); + Action changedMessage = () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessage()).Returns(versionCheck); - var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); - var testResult = new VisualStudio.TestPlatform.ObjectModel.TestResult(testCase); - testResult.Outcome = TestOutcome.Passed; + _mockCommunicationManager.Setup(cm => cm.ReceiveMessage()).Returns(sessionConnected); + _mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.VersionCheck, It.IsAny())).Callback(changedMessage); - var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); - var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); + var portOutput = _requestSender.InitializeCommunication(); + Assert.AreEqual(dummyPortInput, portOutput, "Port number must return without changes."); + var connectionSuccess = _requestSender.WaitForRequestHandlerConnection(_waitTimeout); + Assert.IsTrue(connectionSuccess, "Connection must succeed."); + } - var payload = new TestRunCompletePayload() - { - ExecutorUris = null, - LastRunTests = dummyLastRunArgs, - RunAttachments = null, - TestRunCompleteArgs = dummyCompleteArgs - }; + private void SetupMockCommunicationForRunRequest(Mock mockHandler) + { + InitializeCommunication(); - var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); + var testCase = new TestCase("hello", new Uri("world://how"), "1.dll"); + var testResult = new TestResult(testCase); + testResult.Outcome = TestOutcome.Passed; - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); - } + var dummyCompleteArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, TimeSpan.FromMilliseconds(1)); + var dummyLastRunArgs = new TestRunChangedEventArgs(null, null, null); - private async Task InitializeCommunicationAsync() + var payload = new TestRunCompletePayload() { - await this.InitializeCommunicationAsync(this.protocolVersion); - } + ExecutorUris = null, + LastRunTests = dummyLastRunArgs, + RunAttachments = null, + TestRunCompleteArgs = dummyCompleteArgs + }; - private async Task InitializeCommunicationAsync(int protocolVersion) - { - var dummyPortInput = 123; - this.mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); - this.mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); + var runComplete = CreateMessage(MessageType.ExecutionComplete, payload); - var sessionConnected = new Message() { MessageType = MessageType.SessionConnected }; - var versionCheck = new Message() { MessageType = MessageType.VersionCheck, Payload = protocolVersion }; + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(runComplete)); + } - Action changedMessage = () => - { - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(versionCheck)); - }; + private async Task InitializeCommunicationAsync() + { + await InitializeCommunicationAsync(_protocolVersion); + } + + private async Task InitializeCommunicationAsync(int protocolVersion) + { + var dummyPortInput = 123; + _mockCommunicationManager.Setup(cm => cm.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, dummyPortInput)); + _mockCommunicationManager.Setup(cm => cm.AcceptClientAsync()).Returns(Task.FromResult(false)).Callback(() => { }); + + var sessionConnected = new Message() { MessageType = MessageType.SessionConnected }; + var versionCheck = new Message() { MessageType = MessageType.VersionCheck, Payload = protocolVersion }; - this.mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(sessionConnected)); - this.mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.VersionCheck, It.IsAny())).Callback(changedMessage); + Action changedMessage = () => _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(versionCheck)); - var portOutput = await this.requestSender.InitializeCommunicationAsync(this.WaitTimeout); - Assert.AreEqual(dummyPortInput, portOutput, "Connection must succeed."); - } + _mockCommunicationManager.Setup(cm => cm.ReceiveMessageAsync(It.IsAny())).Returns(Task.FromResult(sessionConnected)); + _mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.VersionCheck, It.IsAny())).Callback(changedMessage); - #endregion + var portOutput = await _requestSender.InitializeCommunicationAsync(_waitTimeout); + Assert.AreEqual(dummyPortInput, portOutput, "Connection must succeed."); } -} + + #endregion +} \ No newline at end of file diff --git a/test/TranslationLayer.UnitTests/VsTestConsoleWrapperAsyncTests.cs b/test/TranslationLayer.UnitTests/VsTestConsoleWrapperAsyncTests.cs index e92b43081c..f717271300 100644 --- a/test/TranslationLayer.UnitTests/VsTestConsoleWrapperAsyncTests.cs +++ b/test/TranslationLayer.UnitTests/VsTestConsoleWrapperAsyncTests.cs @@ -1,591 +1,590 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.UnitTests +namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.UnitTests; + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Threading; +using System.Threading.Tasks; + +using Interfaces; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class VsTestConsoleWrapperAsyncTests { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Threading; - using System.Threading.Tasks; + private IVsTestConsoleWrapper _consoleWrapper; - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; + private Mock _mockProcessManager; - using Moq; + private Mock _mockRequestSender; - [TestClass] - public class VsTestConsoleWrapperAsyncTests - { - private IVsTestConsoleWrapper consoleWrapper; - - private Mock mockProcessManager; - - private Mock mockRequestSender; - - private Mock mockProcessHelper; - - private readonly List testSources = new List { "Hello", "World" }; + private Mock _mockProcessHelper; - private readonly List testCases = new List - { - new TestCase("a.b.c", new Uri("d://uri"), "a.dll"), - new TestCase("d.e.f", new Uri("g://uri"), "d.dll") - }; + private readonly List _testSources = new() { "Hello", "World" }; - private ConsoleParameters consoleParameters; - - [TestInitialize] - public void TestInitialize() - { - this.consoleParameters = new ConsoleParameters(); + private readonly List _testCases = new() + { + new TestCase("a.b.c", new Uri("d://uri"), "a.dll"), + new TestCase("d.e.f", new Uri("g://uri"), "d.dll") + }; - this.mockRequestSender = new Mock(); - this.mockProcessManager = new Mock(); - this.mockProcessHelper = new Mock(); - this.consoleWrapper = new VsTestConsoleWrapper( - this.mockRequestSender.Object, - this.mockProcessManager.Object, - this.consoleParameters, - new Mock().Object, - this.mockProcessHelper.Object); + private ConsoleParameters _consoleParameters; - this.mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(It.IsAny())).Returns(true); - this.mockRequestSender.Setup(rs => rs.InitializeCommunication()).Returns(100); - this.mockRequestSender.Setup(rs => rs.InitializeCommunicationAsync(It.IsAny())).Returns(Task.FromResult(100)); - } + [TestInitialize] + public void TestInitialize() + { + _consoleParameters = new ConsoleParameters(); + + _mockRequestSender = new Mock(); + _mockProcessManager = new Mock(); + _mockProcessHelper = new Mock(); + _consoleWrapper = new VsTestConsoleWrapper( + _mockRequestSender.Object, + _mockProcessManager.Object, + _consoleParameters, + new Mock().Object, + _mockProcessHelper.Object); + + _mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(It.IsAny())).Returns(true); + _mockRequestSender.Setup(rs => rs.InitializeCommunication()).Returns(100); + _mockRequestSender.Setup(rs => rs.InitializeCommunicationAsync(It.IsAny())).Returns(Task.FromResult(100)); + } - [TestMethod] - public async Task StartSessionAsyncShouldStartVsTestConsoleWithCorrectArguments() - { - var inputPort = 123; - int expectedParentProcessId = System.Diagnostics.Process.GetCurrentProcess().Id; - this.mockRequestSender.Setup(rs => rs.InitializeCommunicationAsync(It.IsAny())).Returns(Task.FromResult(inputPort)); + [TestMethod] + public async Task StartSessionAsyncShouldStartVsTestConsoleWithCorrectArguments() + { + var inputPort = 123; + int expectedParentProcessId = System.Diagnostics.Process.GetCurrentProcess().Id; + _mockRequestSender.Setup(rs => rs.InitializeCommunicationAsync(It.IsAny())).Returns(Task.FromResult(inputPort)); - await this.consoleWrapper.StartSessionAsync(); + await _consoleWrapper.StartSessionAsync(); - Assert.AreEqual(expectedParentProcessId, this.consoleParameters.ParentProcessId, "Parent process Id must be set"); - Assert.AreEqual(inputPort, this.consoleParameters.PortNumber, "Port number must be set"); + Assert.AreEqual(expectedParentProcessId, _consoleParameters.ParentProcessId, "Parent process Id must be set"); + Assert.AreEqual(inputPort, _consoleParameters.PortNumber, "Port number must be set"); - this.mockProcessManager.Verify(pm => pm.StartProcess(this.consoleParameters), Times.Once); - } + _mockProcessManager.Verify(pm => pm.StartProcess(_consoleParameters), Times.Once); + } - [TestMethod] - public void StartSessionAsyncShouldThrowExceptionOnBadPort() - { - this.mockRequestSender.Setup(rs => rs.InitializeCommunicationAsync(It.IsAny())).Returns(Task.FromResult(-1)); + [TestMethod] + public void StartSessionAsyncShouldThrowExceptionOnBadPort() + { + _mockRequestSender.Setup(rs => rs.InitializeCommunicationAsync(It.IsAny())).Returns(Task.FromResult(-1)); - Assert.ThrowsExceptionAsync(async () => await this.consoleWrapper.StartSessionAsync()); - } + Assert.ThrowsExceptionAsync(async () => await _consoleWrapper.StartSessionAsync()); + } - [TestMethod] - public async Task StartSessionShouldCallWhenProcessNotInitializedAsync() - { - this.mockProcessManager.Setup(pm => pm.IsProcessInitialized()).Returns(false); + [TestMethod] + public async Task StartSessionShouldCallWhenProcessNotInitializedAsync() + { + _mockProcessManager.Setup(pm => pm.IsProcessInitialized()).Returns(false); - // To call private method EnsureInitialize call InitializeExtensions - await this.consoleWrapper.InitializeExtensionsAsync(new[] { "path/to/adapter" }); + // To call private method EnsureInitialize call InitializeExtensions + await _consoleWrapper.InitializeExtensionsAsync(new[] { "path/to/adapter" }); - this.mockProcessManager.Verify(pm => pm.StartProcess(It.IsAny())); - } + _mockProcessManager.Verify(pm => pm.StartProcess(It.IsAny())); + } - [TestMethod] - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task StartTestSessionAsyncShouldCallRequestSenderWithCorrectArguments1() - { - var testSessionInfo = new TestSessionInfo(); - var mockEventsHandler = new Mock(); + [TestMethod] + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task StartTestSessionAsyncShouldCallRequestSenderWithCorrectArguments1() + { + var testSessionInfo = new TestSessionInfo(); + var mockEventsHandler = new Mock(); - this.mockRequestSender.Setup( + _mockRequestSender.Setup( rs => rs.StartTestSessionAsync( - this.testSources, + _testSources, null, null, mockEventsHandler.Object, null)) - .Returns(Task.FromResult(testSessionInfo)); + .Returns(Task.FromResult(testSessionInfo)); - Assert.AreEqual( - (await this.consoleWrapper.StartTestSessionAsync( - this.testSources, - null, - mockEventsHandler.Object).ConfigureAwait(false)).TestSessionInfo, - testSessionInfo); + Assert.AreEqual( + (await _consoleWrapper.StartTestSessionAsync( + _testSources, + null, + mockEventsHandler.Object).ConfigureAwait(false)).TestSessionInfo, + testSessionInfo); - this.mockRequestSender.Verify( - rs => rs.StartTestSessionAsync( - this.testSources, - null, - null, - mockEventsHandler.Object, - null), - Times.Once); - } - - [TestMethod] - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task StartTestSessionAsyncShouldCallRequestSenderWithCorrectArguments2() - { - var testSessionInfo = new TestSessionInfo(); - var testPlatformOptions = new TestPlatformOptions(); - var mockEventsHandler = new Mock(); - - this.mockRequestSender.Setup( + _mockRequestSender.Verify( + rs => rs.StartTestSessionAsync( + _testSources, + null, + null, + mockEventsHandler.Object, + null), + Times.Once); + } + + [TestMethod] + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task StartTestSessionAsyncShouldCallRequestSenderWithCorrectArguments2() + { + var testSessionInfo = new TestSessionInfo(); + var testPlatformOptions = new TestPlatformOptions(); + var mockEventsHandler = new Mock(); + + _mockRequestSender.Setup( rs => rs.StartTestSessionAsync( - this.testSources, + _testSources, null, testPlatformOptions, mockEventsHandler.Object, null)) - .Returns(Task.FromResult(testSessionInfo)); + .Returns(Task.FromResult(testSessionInfo)); - Assert.AreEqual( - (await this.consoleWrapper.StartTestSessionAsync( - this.testSources, - null, - testPlatformOptions, - mockEventsHandler.Object).ConfigureAwait(false)).TestSessionInfo, - testSessionInfo); + Assert.AreEqual( + (await _consoleWrapper.StartTestSessionAsync( + _testSources, + null, + testPlatformOptions, + mockEventsHandler.Object).ConfigureAwait(false)).TestSessionInfo, + testSessionInfo); - this.mockRequestSender.Verify( - rs => rs.StartTestSessionAsync( - this.testSources, - null, - testPlatformOptions, - mockEventsHandler.Object, - null), - Times.Once); - } - - [TestMethod] - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task StartTestSessionAsyncShouldCallRequestSenderWithCorrectArguments3() - { - var testSessionInfo = new TestSessionInfo(); - var testPlatformOptions = new TestPlatformOptions(); - var mockEventsHandler = new Mock(); - var mockTesthostLauncher = new Mock(); - - this.mockRequestSender.Setup( + _mockRequestSender.Verify( + rs => rs.StartTestSessionAsync( + _testSources, + null, + testPlatformOptions, + mockEventsHandler.Object, + null), + Times.Once); + } + + [TestMethod] + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task StartTestSessionAsyncShouldCallRequestSenderWithCorrectArguments3() + { + var testSessionInfo = new TestSessionInfo(); + var testPlatformOptions = new TestPlatformOptions(); + var mockEventsHandler = new Mock(); + var mockTesthostLauncher = new Mock(); + + _mockRequestSender.Setup( rs => rs.StartTestSessionAsync( - this.testSources, + _testSources, null, testPlatformOptions, mockEventsHandler.Object, mockTesthostLauncher.Object)) - .Returns(Task.FromResult(testSessionInfo)); + .Returns(Task.FromResult(testSessionInfo)); - Assert.AreEqual( - (await this.consoleWrapper.StartTestSessionAsync( - this.testSources, - null, - testPlatformOptions, - mockEventsHandler.Object, - mockTesthostLauncher.Object).ConfigureAwait(false)).TestSessionInfo, - testSessionInfo); + Assert.AreEqual( + (await _consoleWrapper.StartTestSessionAsync( + _testSources, + null, + testPlatformOptions, + mockEventsHandler.Object, + mockTesthostLauncher.Object).ConfigureAwait(false)).TestSessionInfo, + testSessionInfo); + + _mockRequestSender.Verify( + rs => rs.StartTestSessionAsync( + _testSources, + null, + testPlatformOptions, + mockEventsHandler.Object, + mockTesthostLauncher.Object), + Times.Once); + } - this.mockRequestSender.Verify( - rs => rs.StartTestSessionAsync( - this.testSources, - null, - testPlatformOptions, - mockEventsHandler.Object, - mockTesthostLauncher.Object), - Times.Once); - } - - [TestMethod] - [Obsolete("This API is not final yet and is subject to changes.", false)] - public async Task StopTestSessionAsyncShouldCallRequestSenderWithCorrectArguments() - { - var testSessionInfo = new TestSessionInfo(); - var mockEventsHandler = new Mock(); - - this.mockRequestSender.Setup( + [TestMethod] + [Obsolete("This API is not final yet and is subject to changes.", false)] + public async Task StopTestSessionAsyncShouldCallRequestSenderWithCorrectArguments() + { + var testSessionInfo = new TestSessionInfo(); + var mockEventsHandler = new Mock(); + + _mockRequestSender.Setup( rs => rs.StopTestSessionAsync( It.IsAny(), It.IsAny())) - .Returns(Task.FromResult(true)); + .Returns(Task.FromResult(true)); + + Assert.IsTrue( + await _consoleWrapper.StopTestSessionAsync( + testSessionInfo, + mockEventsHandler.Object).ConfigureAwait(false)); + + _mockRequestSender.Verify( + rs => rs.StopTestSessionAsync( + testSessionInfo, + mockEventsHandler.Object), + Times.Once); + } - Assert.IsTrue( - await this.consoleWrapper.StopTestSessionAsync( - testSessionInfo, - mockEventsHandler.Object).ConfigureAwait(false)); + [TestMethod] + public async Task InitializeExtensionsAsyncShouldCachePathToExtensions() + { + var pathToExtensions = new[] { "path/to/adapter" }; + _mockProcessManager.Setup(pm => pm.IsProcessInitialized()).Returns(true); - this.mockRequestSender.Verify( - rs => rs.StopTestSessionAsync( - testSessionInfo, - mockEventsHandler.Object), - Times.Once); - } + await _consoleWrapper.InitializeExtensionsAsync(pathToExtensions); - [TestMethod] - public async Task InitializeExtensionsAsyncShouldCachePathToExtensions() - { - var pathToExtensions = new[] { "path/to/adapter" }; - this.mockProcessManager.Setup(pm => pm.IsProcessInitialized()).Returns(true); + _mockProcessManager.Setup(pm => pm.IsProcessInitialized()).Returns(false); + _mockRequestSender.Setup(rs => rs.InitializeCommunicationAsync(It.IsAny())).Returns(Task.FromResult(100)); - await this.consoleWrapper.InitializeExtensionsAsync(pathToExtensions); + await _consoleWrapper.InitializeExtensionsAsync(pathToExtensions); - this.mockProcessManager.Setup(pm => pm.IsProcessInitialized()).Returns(false); - this.mockRequestSender.Setup(rs => rs.InitializeCommunicationAsync(It.IsAny())).Returns(Task.FromResult(100)); + _mockRequestSender.Verify(rs => rs.InitializeExtensions(pathToExtensions), Times.Exactly(3)); + } - await this.consoleWrapper.InitializeExtensionsAsync(pathToExtensions); + [TestMethod] + public void ProcessExitedEventShouldSetOnProcessExit() + { + _mockProcessManager.Raise(pm => pm.ProcessExited += null, EventArgs.Empty); - this.mockRequestSender.Verify(rs => rs.InitializeExtensions(pathToExtensions), Times.Exactly(3)); - } + _mockRequestSender.Verify(rs => rs.OnProcessExited(), Times.Once); + } - [TestMethod] - public void ProcessExitedEventShouldSetOnProcessExit() - { - this.mockProcessManager.Raise(pm => pm.ProcessExited += null, EventArgs.Empty); + [TestMethod] + public async Task InitializeExtensionsAsyncShouldSucceed() + { + var pathToAdditionalExtensions = new List { "Hello", "World" }; - this.mockRequestSender.Verify(rs => rs.OnProcessExited(), Times.Once); - } + await _consoleWrapper.InitializeExtensionsAsync(pathToAdditionalExtensions); - [TestMethod] - public async Task InitializeExtensionsAsyncShouldSucceed() - { - var pathToAdditionalExtensions = new List { "Hello", "World" }; + _mockRequestSender.Verify(rs => rs.InitializeExtensions(pathToAdditionalExtensions), Times.Once); + } - await this.consoleWrapper.InitializeExtensionsAsync(pathToAdditionalExtensions); + [TestMethod] + public void InitializeExtensionsAsyncShouldThrowExceptionOnBadConnection() + { + _mockRequestSender.Setup(rs => rs.InitializeCommunicationAsync(It.IsAny())).Returns(Task.FromResult(-1)); - this.mockRequestSender.Verify(rs => rs.InitializeExtensions(pathToAdditionalExtensions), Times.Once); - } + Assert.ThrowsExceptionAsync(async () => await _consoleWrapper.InitializeExtensionsAsync(new List { "Hello", "World" })); + _mockRequestSender.Verify(rs => rs.InitializeExtensions(It.IsAny>()), Times.Never); + } - [TestMethod] - public void InitializeExtensionsAsyncShouldThrowExceptionOnBadConnection() - { - this.mockRequestSender.Setup(rs => rs.InitializeCommunicationAsync(It.IsAny())).Returns(Task.FromResult(-1)); + [TestMethod] + public async Task DiscoverTestsAsyncShouldSucceed() + { + await _consoleWrapper.DiscoverTestsAsync(_testSources, null, new TestPlatformOptions(), new Mock().Object); - Assert.ThrowsExceptionAsync(async () => await this.consoleWrapper.InitializeExtensionsAsync(new List { "Hello", "World" })); - this.mockRequestSender.Verify(rs => rs.InitializeExtensions(It.IsAny>()), Times.Never); - } + _mockRequestSender.Verify(rs => rs.DiscoverTestsAsync(_testSources, null, It.IsAny(), null, It.IsAny()), Times.Once); + } - [TestMethod] - public async Task DiscoverTestsAsyncShouldSucceed() - { - await this.consoleWrapper.DiscoverTestsAsync(this.testSources, null, new TestPlatformOptions(), new Mock().Object); + [TestMethod] + public async Task DiscoverTestsAsyncShouldPassTestDiscoveryHandler2IfTestDiscoveryHandler1IsInput() + { + await _consoleWrapper.DiscoverTestsAsync(_testSources, null, new TestPlatformOptions(), new Mock().Object); - this.mockRequestSender.Verify(rs => rs.DiscoverTestsAsync(this.testSources, null, It.IsAny(), null, It.IsAny()), Times.Once); - } + _mockRequestSender.Verify(rs => rs.DiscoverTestsAsync(_testSources, null, It.IsAny(), null, It.IsAny()), Times.Once); + } - [TestMethod] - public async Task DiscoverTestsAsyncShouldPassTestDiscoveryHandler2IfTestDiscoveryHandler1IsInput() - { - await this.consoleWrapper.DiscoverTestsAsync(this.testSources, null, new TestPlatformOptions(), new Mock().Object); + [TestMethod] + public async Task DiscoverTestsAndNullOptionsAsyncShouldSucceedOnNullOptions() + { + await _consoleWrapper.DiscoverTestsAsync(_testSources, null, null, new Mock().Object); - this.mockRequestSender.Verify(rs => rs.DiscoverTestsAsync(this.testSources, null, It.IsAny(), null, It.IsAny()), Times.Once); - } + _mockRequestSender.Verify(rs => rs.DiscoverTestsAsync(_testSources, null, null, null, It.IsAny()), Times.Once); + } - [TestMethod] - public async Task DiscoverTestsAndNullOptionsAsyncShouldSucceedOnNullOptions() - { - await this.consoleWrapper.DiscoverTestsAsync(this.testSources, null, null, new Mock().Object); + [TestMethod] + public async Task DiscoverTestsAndOptionsAsyncShouldSucceedOnOptions() + { + var options = new TestPlatformOptions(); + await _consoleWrapper.DiscoverTestsAsync(_testSources, null, options, new Mock().Object); - this.mockRequestSender.Verify(rs => rs.DiscoverTestsAsync(this.testSources, null, null, null, It.IsAny()), Times.Once); - } + _mockRequestSender.Verify(rs => rs.DiscoverTestsAsync(_testSources, null, options, null, It.IsAny()), Times.Once); + } - [TestMethod] - public async Task DiscoverTestsAndOptionsAsyncShouldSucceedOnOptions() - { - var options = new TestPlatformOptions(); - await this.consoleWrapper.DiscoverTestsAsync(this.testSources, null, options, new Mock().Object); + [TestMethod] + public void DiscoverTestsAsyncShouldThrowExceptionOnBadConnection() + { + _mockRequestSender.Setup(rs => rs.InitializeCommunicationAsync(It.IsAny())).Returns(Task.FromResult(-1)); - this.mockRequestSender.Verify(rs => rs.DiscoverTestsAsync(this.testSources, null, options, null, It.IsAny()), Times.Once); - } + Assert.ThrowsExceptionAsync(async () => await _consoleWrapper.DiscoverTestsAsync(new List { "Hello", "World" }, null, new TestPlatformOptions(), new Mock().Object)); + _mockRequestSender.Verify(rs => rs.DiscoverTestsAsync(It.IsAny>(), It.IsAny(), It.IsAny(), null, It.IsAny()), Times.Never); + } - [TestMethod] - public void DiscoverTestsAsyncShouldThrowExceptionOnBadConnection() - { - this.mockRequestSender.Setup(rs => rs.InitializeCommunicationAsync(It.IsAny())).Returns(Task.FromResult(-1)); + [TestMethod] + public async Task DiscoverTestsShouldSucceedWhenUsingSessions() + { + var testSessionInfo = new TestSessionInfo(); - Assert.ThrowsExceptionAsync(async () => await this.consoleWrapper.DiscoverTestsAsync(new List { "Hello", "World" }, null, new TestPlatformOptions(), new Mock().Object)); - this.mockRequestSender.Verify(rs => rs.DiscoverTestsAsync(It.IsAny>(), It.IsAny(), It.IsAny(), null, It.IsAny()), Times.Never); - } + await _consoleWrapper.DiscoverTestsAsync( + _testSources, + null, + null, + testSessionInfo, + new Mock().Object) + .ConfigureAwait(false); - [TestMethod] - public async Task DiscoverTestsShouldSucceedWhenUsingSessions() - { - var testSessionInfo = new TestSessionInfo(); + _mockRequestSender.Verify( + rs => rs.DiscoverTestsAsync( + _testSources, + null, + null, + testSessionInfo, + It.IsAny()), + Times.Once); + } - await this.consoleWrapper.DiscoverTestsAsync( - this.testSources, - null, - null, - testSessionInfo, - new Mock().Object) - .ConfigureAwait(false); + [TestMethod] + public async Task RunTestsAsyncWithSourcesShouldSucceed() + { + await _consoleWrapper.RunTestsAsync(_testSources, "RunSettings", new Mock().Object); - this.mockRequestSender.Verify( - rs => rs.DiscoverTestsAsync( - this.testSources, - null, - null, - testSessionInfo, - It.IsAny()), - Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithSourcesShouldSucceed() - { - await this.consoleWrapper.RunTestsAsync(this.testSources, "RunSettings", new Mock().Object); - - this.mockRequestSender.Verify(rs => rs.StartTestRunAsync(this.testSources, "RunSettings", null, null, It.IsAny()), Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithSourcesAndNullOptionsShouldSucceedOnNullOptions() - { - await this.consoleWrapper.RunTestsAsync(this.testSources, "RunSettings", null, new Mock().Object); - - this.mockRequestSender.Verify(rs => rs.StartTestRunAsync(this.testSources, "RunSettings", null, null, It.IsAny()), Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithSourcesAndOptionsShouldSucceedOnOptions() - { - var options = new TestPlatformOptions(); - await this.consoleWrapper.RunTestsAsync(this.testSources, "RunSettings", options, new Mock().Object); - - this.mockRequestSender.Verify(rs => rs.StartTestRunAsync(this.testSources, "RunSettings", options, null, It.IsAny()), Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithSourcesShouldSucceedWhenUsingSessions() - { - var testSessionInfo = new TestSessionInfo(); - var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; - await this.consoleWrapper.RunTestsAsync( - this.testSources, - "RunSettings", - options, - testSessionInfo, - new Mock().Object) - .ConfigureAwait(false); - - this.mockRequestSender.Verify( - rs => rs.StartTestRunAsync( - this.testSources, - "RunSettings", - options, - testSessionInfo, - It.IsAny()), - Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithSourcesAndCustomHostShouldSucceed() - { - await this.consoleWrapper.RunTestsWithCustomTestHostAsync( - this.testSources, - "RunSettings", - new Mock().Object, - new Mock().Object); + _mockRequestSender.Verify(rs => rs.StartTestRunAsync(_testSources, "RunSettings", null, null, It.IsAny()), Times.Once); + } + + [TestMethod] + public async Task RunTestsAsyncWithSourcesAndNullOptionsShouldSucceedOnNullOptions() + { + await _consoleWrapper.RunTestsAsync(_testSources, "RunSettings", null, new Mock().Object); + + _mockRequestSender.Verify(rs => rs.StartTestRunAsync(_testSources, "RunSettings", null, null, It.IsAny()), Times.Once); + } - this.mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHostAsync(this.testSources, "RunSettings", null, null, It.IsAny(), It.IsAny()), Times.Once); - } + [TestMethod] + public async Task RunTestsAsyncWithSourcesAndOptionsShouldSucceedOnOptions() + { + var options = new TestPlatformOptions(); + await _consoleWrapper.RunTestsAsync(_testSources, "RunSettings", options, new Mock().Object); + + _mockRequestSender.Verify(rs => rs.StartTestRunAsync(_testSources, "RunSettings", options, null, It.IsAny()), Times.Once); + } - [TestMethod] - public async Task RunTestsAsyncWithSourcesAndOptionsUsingCustomHostShouldSucceedOnNullOptions() - { - await this.consoleWrapper.RunTestsWithCustomTestHostAsync( - this.testSources, + [TestMethod] + public async Task RunTestsAsyncWithSourcesShouldSucceedWhenUsingSessions() + { + var testSessionInfo = new TestSessionInfo(); + var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; + await _consoleWrapper.RunTestsAsync( + _testSources, "RunSettings", - null, - new Mock().Object, - new Mock().Object); + options, + testSessionInfo, + new Mock().Object) + .ConfigureAwait(false); + + _mockRequestSender.Verify( + rs => rs.StartTestRunAsync( + _testSources, + "RunSettings", + options, + testSessionInfo, + It.IsAny()), + Times.Once); + } + + [TestMethod] + public async Task RunTestsAsyncWithSourcesAndCustomHostShouldSucceed() + { + await _consoleWrapper.RunTestsWithCustomTestHostAsync( + _testSources, + "RunSettings", + new Mock().Object, + new Mock().Object); + + _mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHostAsync(_testSources, "RunSettings", null, null, It.IsAny(), It.IsAny()), Times.Once); + } + + [TestMethod] + public async Task RunTestsAsyncWithSourcesAndOptionsUsingCustomHostShouldSucceedOnNullOptions() + { + await _consoleWrapper.RunTestsWithCustomTestHostAsync( + _testSources, + "RunSettings", + null, + new Mock().Object, + new Mock().Object); + + _mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHostAsync(_testSources, "RunSettings", null, null, It.IsAny(), It.IsAny()), Times.Once); + } + + [TestMethod] + public async Task RunTestsAsyncWithSourcesOnOptionsUsingCustomHostShouldSucceedOnOptions() + { + var options = new TestPlatformOptions(); - this.mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHostAsync(this.testSources, "RunSettings", null, null, It.IsAny(), It.IsAny()), Times.Once); - } + await _consoleWrapper.RunTestsWithCustomTestHostAsync( + _testSources, + "RunSettings", + options, + new Mock().Object, + new Mock().Object); - [TestMethod] - public async Task RunTestsAsyncWithSourcesOnOptionsUsingCustomHostShouldSucceedOnOptions() - { - var options = new TestPlatformOptions(); + _mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHostAsync(_testSources, "RunSettings", options, null, It.IsAny(), It.IsAny()), Times.Once); + } - await this.consoleWrapper.RunTestsWithCustomTestHostAsync( - this.testSources, + [TestMethod] + public async Task RunTestsAsyncWithSourcesAndACustomHostShouldSucceedWhenUsingSessions() + { + var testSessionInfo = new TestSessionInfo(); + var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; + await _consoleWrapper.RunTestsWithCustomTestHostAsync( + _testSources, "RunSettings", options, + testSessionInfo, new Mock().Object, - new Mock().Object); - - this.mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHostAsync(this.testSources, "RunSettings", options, null, It.IsAny(), It.IsAny()), Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithSourcesAndACustomHostShouldSucceedWhenUsingSessions() - { - var testSessionInfo = new TestSessionInfo(); - var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; - await this.consoleWrapper.RunTestsWithCustomTestHostAsync( - this.testSources, - "RunSettings", - options, - testSessionInfo, - new Mock().Object, - new Mock().Object) - .ConfigureAwait(false); - - this.mockRequestSender.Verify( - rs => rs.StartTestRunWithCustomHostAsync( - this.testSources, - "RunSettings", - options, - testSessionInfo, - It.IsAny(), - It.IsAny()), - Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithSelectedTestsShouldSucceed() - { - await this.consoleWrapper.RunTestsAsync(this.testCases, "RunSettings", new Mock().Object); - - this.mockRequestSender.Verify(rs => rs.StartTestRunAsync(this.testCases, "RunSettings", It.IsAny(), null, It.IsAny()), Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithSelectedTestsAndOptionsShouldSucceedOnNullOptions() - { - await this.consoleWrapper.RunTestsAsync(this.testCases, "RunSettings", null, new Mock().Object); - - this.mockRequestSender.Verify(rs => rs.StartTestRunAsync(this.testCases, "RunSettings", null, null, It.IsAny()), Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithSelectedTestsAndOptionsShouldSucceedOnOptions() - { - var options = new TestPlatformOptions(); - - await this.consoleWrapper.RunTestsAsync(this.testCases, "RunSettings", options, new Mock().Object); - - this.mockRequestSender.Verify(rs => rs.StartTestRunAsync(this.testCases, "RunSettings", options, null, It.IsAny()), Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithSelectedTestsShouldSucceedWhenUsingSessions() - { - var testSessionInfo = new TestSessionInfo(); - var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; - - await this.consoleWrapper.RunTestsAsync( - this.testCases, - "RunSettings", - options, - testSessionInfo, - new Mock().Object) - .ConfigureAwait(false); - - this.mockRequestSender.Verify( - rs => rs.StartTestRunAsync( - this.testCases, - "RunSettings", - options, - testSessionInfo, - It.IsAny()), - Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithSelectedTestsAndCustomLauncherShouldSucceed() - { - await this.consoleWrapper.RunTestsWithCustomTestHostAsync( - this.testCases, + new Mock().Object) + .ConfigureAwait(false); + + _mockRequestSender.Verify( + rs => rs.StartTestRunWithCustomHostAsync( + _testSources, "RunSettings", - new Mock().Object, - new Mock().Object); + options, + testSessionInfo, + It.IsAny(), + It.IsAny()), + Times.Once); + } - this.mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHostAsync(this.testCases, "RunSettings", It.IsAny(), null, It.IsAny(), It.IsAny()), Times.Once); - } + [TestMethod] + public async Task RunTestsAsyncWithSelectedTestsShouldSucceed() + { + await _consoleWrapper.RunTestsAsync(_testCases, "RunSettings", new Mock().Object); - [TestMethod] - public async Task RunTestsAsyncWithSelectedTestsAndOptionsUsingCustomLauncherShouldSucceedOnNullOptions() - { - await this.consoleWrapper.RunTestsWithCustomTestHostAsync( - this.testCases, + _mockRequestSender.Verify(rs => rs.StartTestRunAsync(_testCases, "RunSettings", It.IsAny(), null, It.IsAny()), Times.Once); + } + + [TestMethod] + public async Task RunTestsAsyncWithSelectedTestsAndOptionsShouldSucceedOnNullOptions() + { + await _consoleWrapper.RunTestsAsync(_testCases, "RunSettings", null, new Mock().Object); + + _mockRequestSender.Verify(rs => rs.StartTestRunAsync(_testCases, "RunSettings", null, null, It.IsAny()), Times.Once); + } + + [TestMethod] + public async Task RunTestsAsyncWithSelectedTestsAndOptionsShouldSucceedOnOptions() + { + var options = new TestPlatformOptions(); + + await _consoleWrapper.RunTestsAsync(_testCases, "RunSettings", options, new Mock().Object); + + _mockRequestSender.Verify(rs => rs.StartTestRunAsync(_testCases, "RunSettings", options, null, It.IsAny()), Times.Once); + } + + [TestMethod] + public async Task RunTestsAsyncWithSelectedTestsShouldSucceedWhenUsingSessions() + { + var testSessionInfo = new TestSessionInfo(); + var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; + + await _consoleWrapper.RunTestsAsync( + _testCases, "RunSettings", - null, - new Mock().Object, - new Mock().Object); + options, + testSessionInfo, + new Mock().Object) + .ConfigureAwait(false); + + _mockRequestSender.Verify( + rs => rs.StartTestRunAsync( + _testCases, + "RunSettings", + options, + testSessionInfo, + It.IsAny()), + Times.Once); + } - this.mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHostAsync(this.testCases, "RunSettings", null, null, It.IsAny(), It.IsAny()), Times.Once); - } + [TestMethod] + public async Task RunTestsAsyncWithSelectedTestsAndCustomLauncherShouldSucceed() + { + await _consoleWrapper.RunTestsWithCustomTestHostAsync( + _testCases, + "RunSettings", + new Mock().Object, + new Mock().Object); + + _mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHostAsync(_testCases, "RunSettings", It.IsAny(), null, It.IsAny(), It.IsAny()), Times.Once); + } - [TestMethod] - public async Task RunTestsAsyncWithSelectedTestsAndOptionsUsingCustomLauncherShouldSucceedOnOptions() - { - var options = new TestPlatformOptions(); - await this.consoleWrapper.RunTestsWithCustomTestHostAsync( - this.testCases, + [TestMethod] + public async Task RunTestsAsyncWithSelectedTestsAndOptionsUsingCustomLauncherShouldSucceedOnNullOptions() + { + await _consoleWrapper.RunTestsWithCustomTestHostAsync( + _testCases, + "RunSettings", + null, + new Mock().Object, + new Mock().Object); + + _mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHostAsync(_testCases, "RunSettings", null, null, It.IsAny(), It.IsAny()), Times.Once); + } + + [TestMethod] + public async Task RunTestsAsyncWithSelectedTestsAndOptionsUsingCustomLauncherShouldSucceedOnOptions() + { + var options = new TestPlatformOptions(); + await _consoleWrapper.RunTestsWithCustomTestHostAsync( + _testCases, + "RunSettings", + options, + new Mock().Object, + new Mock().Object); + + _mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHostAsync(_testCases, "RunSettings", options, null, It.IsAny(), It.IsAny()), Times.Once); + } + + [TestMethod] + public async Task RunTestsAsyncWithSelectedTestsAndACustomHostShouldSucceedWhenUsingSessions() + { + var testSessionInfo = new TestSessionInfo(); + var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; + + await _consoleWrapper.RunTestsWithCustomTestHostAsync( + _testCases, "RunSettings", options, + testSessionInfo, new Mock().Object, - new Mock().Object); - - this.mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHostAsync(this.testCases, "RunSettings", options, null, It.IsAny(), It.IsAny()), Times.Once); - } - - [TestMethod] - public async Task RunTestsAsyncWithSelectedTestsAndACustomHostShouldSucceedWhenUsingSessions() - { - var testSessionInfo = new TestSessionInfo(); - var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; - - await this.consoleWrapper.RunTestsWithCustomTestHostAsync( - this.testCases, - "RunSettings", - options, - testSessionInfo, - new Mock().Object, - new Mock().Object) - .ConfigureAwait(false); - - this.mockRequestSender.Verify( - rs => rs.StartTestRunWithCustomHostAsync( - this.testCases, - "RunSettings", - options, - testSessionInfo, - It.IsAny(), - It.IsAny()), - Times.Once); - } - - [TestMethod] - public async Task ProcessTestRunAttachmentsAsyncShouldSucceed() - { - var attachments = new Collection(); - var invokedDataCollectors = new Collection(); - var cancellationToken = new CancellationToken(); - - await this.consoleWrapper.ProcessTestRunAttachmentsAsync( - attachments, - invokedDataCollectors, - Constants.EmptyRunSettings, - true, - true, - new Mock().Object, - cancellationToken); - - this.mockRequestSender.Verify(rs => rs.ProcessTestRunAttachmentsAsync(attachments, invokedDataCollectors, Constants.EmptyRunSettings, true, It.IsAny(), cancellationToken)); - } - - [TestMethod] - public void EndSessionShouldSucceed() - { - this.consoleWrapper.EndSession(); - - this.mockRequestSender.Verify(rs => rs.EndSession(), Times.Once); - this.mockRequestSender.Verify(rs => rs.Close(), Times.Once); - } - } -} + new Mock().Object) + .ConfigureAwait(false); + + _mockRequestSender.Verify( + rs => rs.StartTestRunWithCustomHostAsync( + _testCases, + "RunSettings", + options, + testSessionInfo, + It.IsAny(), + It.IsAny()), + Times.Once); + } + + [TestMethod] + public async Task ProcessTestRunAttachmentsAsyncShouldSucceed() + { + var attachments = new Collection(); + var invokedDataCollectors = new Collection(); + var cancellationToken = new CancellationToken(); + + await _consoleWrapper.ProcessTestRunAttachmentsAsync( + attachments, + invokedDataCollectors, + Constants.EmptyRunSettings, + true, + true, + new Mock().Object, + cancellationToken); + + _mockRequestSender.Verify(rs => rs.ProcessTestRunAttachmentsAsync(attachments, invokedDataCollectors, Constants.EmptyRunSettings, true, It.IsAny(), cancellationToken)); + } + + [TestMethod] + public void EndSessionShouldSucceed() + { + _consoleWrapper.EndSession(); + + _mockRequestSender.Verify(rs => rs.EndSession(), Times.Once); + _mockRequestSender.Verify(rs => rs.Close(), Times.Once); + } +} \ No newline at end of file diff --git a/test/TranslationLayer.UnitTests/VsTestConsoleWrapperTests.cs b/test/TranslationLayer.UnitTests/VsTestConsoleWrapperTests.cs index d47cb5440b..2f48f8babf 100644 --- a/test/TranslationLayer.UnitTests/VsTestConsoleWrapperTests.cs +++ b/test/TranslationLayer.UnitTests/VsTestConsoleWrapperTests.cs @@ -1,586 +1,585 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.UnitTests +namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer.UnitTests; + +using Interfaces; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using VisualStudio.TestTools.UnitTesting; +using Moq; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; + +[TestClass] +public class VsTestConsoleWrapperTests { - using Microsoft.TestPlatform.VsTestConsole.TranslationLayer.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Diagnostics; - using System.Threading; - using System.Threading.Tasks; - - [TestClass] - public class VsTestConsoleWrapperTests - { - private IVsTestConsoleWrapper consoleWrapper; - - private Mock mockProcessManager; - - private Mock mockProcessHelper; - - private Mock mockRequestSender; - - private readonly List testSources = new List { "Hello", "World" }; - - private readonly List testCases = new List - { - new TestCase("a.b.c", new Uri("d://uri"), "a.dll"), - new TestCase("d.e.f", new Uri("g://uri"), "d.dll") - }; - - private ConsoleParameters consoleParameters; - - [TestInitialize] - public void TestInitialize() - { - this.consoleParameters = new ConsoleParameters(); - - this.mockRequestSender = new Mock(); - this.mockProcessManager = new Mock(); - this.mockProcessHelper = new Mock(); - this.consoleWrapper = new VsTestConsoleWrapper( - this.mockRequestSender.Object, - this.mockProcessManager.Object, - this.consoleParameters, - new Mock().Object, - this.mockProcessHelper.Object); - - this.mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(It.IsAny())).Returns(true); - this.mockRequestSender.Setup(rs => rs.InitializeCommunication()).Returns(100); - this.mockRequestSender.Setup(rs => rs.InitializeCommunicationAsync(It.IsAny())).Returns(Task.FromResult(100)); - } - - [TestMethod] - public void StartSessionShouldStartVsTestConsoleWithCorrectArguments() - { - var inputPort = 123; - int expectedParentProcessId = System.Diagnostics.Process.GetCurrentProcess().Id; - this.mockRequestSender.Setup(rs => rs.InitializeCommunication()).Returns(inputPort); - - this.consoleWrapper.StartSession(); - - Assert.AreEqual(expectedParentProcessId, this.consoleParameters.ParentProcessId, "Parent process Id must be set"); - Assert.AreEqual(inputPort, this.consoleParameters.PortNumber, "Port number must be set"); - Assert.AreEqual(TraceLevel.Verbose, this.consoleParameters.TraceLevel, "Default value of trace level should be verbose."); - - this.mockProcessManager.Verify(pm => pm.StartProcess(this.consoleParameters), Times.Once); - } - - [TestMethod] - public void StartSessionShouldThrowExceptionOnBadPort() - { - this.mockRequestSender.Setup(rs => rs.InitializeCommunication()).Returns(-1); - - Assert.ThrowsException(() => this.consoleWrapper.StartSession()); - } - - [TestMethod] - public void StartSessionShouldCallWhenProcessNotInitialized() - { - this.mockProcessManager.Setup(pm => pm.IsProcessInitialized()).Returns(false); - - // To call private method EnsureInitialize call InitializeExtensions - this.consoleWrapper.InitializeExtensions(new[] { "path/to/adapter" }); - - this.mockProcessManager.Verify(pm => pm.StartProcess(It.IsAny())); - } - - [TestMethod] - [Obsolete("This API is not final yet and is subject to changes.", false)] - public void StartTestSessionShouldCallRequestSenderWithCorrectArguments1() - { - var testSessionInfo = new TestSessionInfo(); - var mockEventsHandler = new Mock(); - - this.mockRequestSender.Setup( + private IVsTestConsoleWrapper _consoleWrapper; + + private Mock _mockProcessManager; + + private Mock _mockProcessHelper; + + private Mock _mockRequestSender; + + private readonly List _testSources = new() { "Hello", "World" }; + + private readonly List _testCases = new() + { + new TestCase("a.b.c", new Uri("d://uri"), "a.dll"), + new TestCase("d.e.f", new Uri("g://uri"), "d.dll") + }; + + private ConsoleParameters _consoleParameters; + + [TestInitialize] + public void TestInitialize() + { + _consoleParameters = new ConsoleParameters(); + + _mockRequestSender = new Mock(); + _mockProcessManager = new Mock(); + _mockProcessHelper = new Mock(); + _consoleWrapper = new VsTestConsoleWrapper( + _mockRequestSender.Object, + _mockProcessManager.Object, + _consoleParameters, + new Mock().Object, + _mockProcessHelper.Object); + + _mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(It.IsAny())).Returns(true); + _mockRequestSender.Setup(rs => rs.InitializeCommunication()).Returns(100); + _mockRequestSender.Setup(rs => rs.InitializeCommunicationAsync(It.IsAny())).Returns(Task.FromResult(100)); + } + + [TestMethod] + public void StartSessionShouldStartVsTestConsoleWithCorrectArguments() + { + var inputPort = 123; + int expectedParentProcessId = Process.GetCurrentProcess().Id; + _mockRequestSender.Setup(rs => rs.InitializeCommunication()).Returns(inputPort); + + _consoleWrapper.StartSession(); + + Assert.AreEqual(expectedParentProcessId, _consoleParameters.ParentProcessId, "Parent process Id must be set"); + Assert.AreEqual(inputPort, _consoleParameters.PortNumber, "Port number must be set"); + Assert.AreEqual(TraceLevel.Verbose, _consoleParameters.TraceLevel, "Default value of trace level should be verbose."); + + _mockProcessManager.Verify(pm => pm.StartProcess(_consoleParameters), Times.Once); + } + + [TestMethod] + public void StartSessionShouldThrowExceptionOnBadPort() + { + _mockRequestSender.Setup(rs => rs.InitializeCommunication()).Returns(-1); + + Assert.ThrowsException(() => _consoleWrapper.StartSession()); + } + + [TestMethod] + public void StartSessionShouldCallWhenProcessNotInitialized() + { + _mockProcessManager.Setup(pm => pm.IsProcessInitialized()).Returns(false); + + // To call private method EnsureInitialize call InitializeExtensions + _consoleWrapper.InitializeExtensions(new[] { "path/to/adapter" }); + + _mockProcessManager.Verify(pm => pm.StartProcess(It.IsAny())); + } + + [TestMethod] + [Obsolete("This API is not final yet and is subject to changes.", false)] + public void StartTestSessionShouldCallRequestSenderWithCorrectArguments1() + { + var testSessionInfo = new TestSessionInfo(); + var mockEventsHandler = new Mock(); + + _mockRequestSender.Setup( rs => rs.StartTestSession( - this.testSources, + _testSources, null, null, mockEventsHandler.Object, null)) - .Returns(testSessionInfo); + .Returns(testSessionInfo); - Assert.AreEqual( - this.consoleWrapper.StartTestSession( - this.testSources, - null, - mockEventsHandler.Object).TestSessionInfo, - testSessionInfo); + Assert.AreEqual( + _consoleWrapper.StartTestSession( + _testSources, + null, + mockEventsHandler.Object).TestSessionInfo, + testSessionInfo); - this.mockRequestSender.Verify( - rs => rs.StartTestSession( - this.testSources, - null, - null, - mockEventsHandler.Object, - null), - Times.Once); - } - - [TestMethod] - [Obsolete("This API is not final yet and is subject to changes.", false)] - public void StartTestSessionShouldCallRequestSenderWithCorrectArguments2() - { - var testSessionInfo = new TestSessionInfo(); - var testPlatformOptions = new TestPlatformOptions(); - var mockEventsHandler = new Mock(); - - this.mockRequestSender.Setup( + _mockRequestSender.Verify( + rs => rs.StartTestSession( + _testSources, + null, + null, + mockEventsHandler.Object, + null), + Times.Once); + } + + [TestMethod] + [Obsolete("This API is not final yet and is subject to changes.", false)] + public void StartTestSessionShouldCallRequestSenderWithCorrectArguments2() + { + var testSessionInfo = new TestSessionInfo(); + var testPlatformOptions = new TestPlatformOptions(); + var mockEventsHandler = new Mock(); + + _mockRequestSender.Setup( rs => rs.StartTestSession( - this.testSources, + _testSources, null, testPlatformOptions, mockEventsHandler.Object, null)) - .Returns(testSessionInfo); + .Returns(testSessionInfo); - Assert.AreEqual( - this.consoleWrapper.StartTestSession( - this.testSources, - null, - testPlatformOptions, - mockEventsHandler.Object).TestSessionInfo, - testSessionInfo); + Assert.AreEqual( + _consoleWrapper.StartTestSession( + _testSources, + null, + testPlatformOptions, + mockEventsHandler.Object).TestSessionInfo, + testSessionInfo); - this.mockRequestSender.Verify( - rs => rs.StartTestSession( - this.testSources, - null, - testPlatformOptions, - mockEventsHandler.Object, - null), - Times.Once); - } - - [TestMethod] - [Obsolete("This API is not final yet and is subject to changes.", false)] - public void StartTestSessionShouldCallRequestSenderWithCorrectArguments3() - { - var testSessionInfo = new TestSessionInfo(); - var testPlatformOptions = new TestPlatformOptions(); - var mockEventsHandler = new Mock(); - var mockTesthostLauncher = new Mock(); - - this.mockRequestSender.Setup( + _mockRequestSender.Verify( + rs => rs.StartTestSession( + _testSources, + null, + testPlatformOptions, + mockEventsHandler.Object, + null), + Times.Once); + } + + [TestMethod] + [Obsolete("This API is not final yet and is subject to changes.", false)] + public void StartTestSessionShouldCallRequestSenderWithCorrectArguments3() + { + var testSessionInfo = new TestSessionInfo(); + var testPlatformOptions = new TestPlatformOptions(); + var mockEventsHandler = new Mock(); + var mockTesthostLauncher = new Mock(); + + _mockRequestSender.Setup( rs => rs.StartTestSession( - this.testSources, + _testSources, null, testPlatformOptions, mockEventsHandler.Object, mockTesthostLauncher.Object)) - .Returns(testSessionInfo); + .Returns(testSessionInfo); - Assert.AreEqual( - this.consoleWrapper.StartTestSession( - this.testSources, - null, - testPlatformOptions, - mockEventsHandler.Object, - mockTesthostLauncher.Object).TestSessionInfo, - testSessionInfo); + Assert.AreEqual( + _consoleWrapper.StartTestSession( + _testSources, + null, + testPlatformOptions, + mockEventsHandler.Object, + mockTesthostLauncher.Object).TestSessionInfo, + testSessionInfo); + + _mockRequestSender.Verify( + rs => rs.StartTestSession( + _testSources, + null, + testPlatformOptions, + mockEventsHandler.Object, + mockTesthostLauncher.Object), + Times.Once); + } - this.mockRequestSender.Verify( - rs => rs.StartTestSession( - this.testSources, - null, - testPlatformOptions, - mockEventsHandler.Object, - mockTesthostLauncher.Object), - Times.Once); - } - - [TestMethod] - [Obsolete("This API is not final yet and is subject to changes.", false)] - public void StopTestSessionShouldCallRequestSenderWithCorrectArguments() - { - var testSessionInfo = new TestSessionInfo(); - var mockEventsHandler = new Mock(); - - this.mockRequestSender.Setup( + [TestMethod] + [Obsolete("This API is not final yet and is subject to changes.", false)] + public void StopTestSessionShouldCallRequestSenderWithCorrectArguments() + { + var testSessionInfo = new TestSessionInfo(); + var mockEventsHandler = new Mock(); + + _mockRequestSender.Setup( rs => rs.StopTestSession( It.IsAny(), It.IsAny())) - .Returns(true); - - Assert.IsTrue( - this.consoleWrapper.StopTestSession( - testSessionInfo, - mockEventsHandler.Object)); + .Returns(true); - this.mockRequestSender.Verify( - rs => rs.StopTestSession( - testSessionInfo, - mockEventsHandler.Object), - Times.Once); - } + Assert.IsTrue( + _consoleWrapper.StopTestSession( + testSessionInfo, + mockEventsHandler.Object)); - [TestMethod] - public void InitializeExtensionsShouldCachePathToExtensions() - { - var pathToExtensions = new[] { "path/to/adapter" }; - this.mockProcessManager.Setup(pm => pm.IsProcessInitialized()).Returns(true); + _mockRequestSender.Verify( + rs => rs.StopTestSession( + testSessionInfo, + mockEventsHandler.Object), + Times.Once); + } - this.consoleWrapper.InitializeExtensions(pathToExtensions); + [TestMethod] + public void InitializeExtensionsShouldCachePathToExtensions() + { + var pathToExtensions = new[] { "path/to/adapter" }; + _mockProcessManager.Setup(pm => pm.IsProcessInitialized()).Returns(true); - this.mockProcessManager.Setup(pm => pm.IsProcessInitialized()).Returns(false); - this.mockRequestSender.Setup(rs => rs.InitializeCommunication()).Returns(100); + _consoleWrapper.InitializeExtensions(pathToExtensions); - this.consoleWrapper.InitializeExtensions(pathToExtensions); + _mockProcessManager.Setup(pm => pm.IsProcessInitialized()).Returns(false); + _mockRequestSender.Setup(rs => rs.InitializeCommunication()).Returns(100); - this.mockRequestSender.Verify(rs => rs.InitializeExtensions(pathToExtensions), Times.Exactly(3)); - } + _consoleWrapper.InitializeExtensions(pathToExtensions); - [TestMethod] - public void ProcessExitedEventShouldSetOnProcessExit() - { - this.mockProcessManager.Raise(pm => pm.ProcessExited += null, EventArgs.Empty); + _mockRequestSender.Verify(rs => rs.InitializeExtensions(pathToExtensions), Times.Exactly(3)); + } - this.mockRequestSender.Verify(rs => rs.OnProcessExited(), Times.Once); - } + [TestMethod] + public void ProcessExitedEventShouldSetOnProcessExit() + { + _mockProcessManager.Raise(pm => pm.ProcessExited += null, EventArgs.Empty); - [TestMethod] - public void InitializeExtensionsShouldSucceed() - { - var pathToAdditionalExtensions = new List { "Hello", "World" }; + _mockRequestSender.Verify(rs => rs.OnProcessExited(), Times.Once); + } - this.consoleWrapper.InitializeExtensions(pathToAdditionalExtensions); + [TestMethod] + public void InitializeExtensionsShouldSucceed() + { + var pathToAdditionalExtensions = new List { "Hello", "World" }; - this.mockRequestSender.Verify(rs => rs.InitializeExtensions(pathToAdditionalExtensions), Times.Once); - } + _consoleWrapper.InitializeExtensions(pathToAdditionalExtensions); - [TestMethod] - public void InitializeExtensionsShouldThrowExceptionOnBadConnection() - { - this.mockProcessHelper.Setup(x => x.GetCurrentProcessFileName()).Returns("DummyProcess"); - this.mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(It.IsAny())).Returns(false); + _mockRequestSender.Verify(rs => rs.InitializeExtensions(pathToAdditionalExtensions), Times.Once); + } - var exception = Assert.ThrowsException(() => this.consoleWrapper.InitializeExtensions(new List { "Hello", "World" })); - Assert.AreEqual("DummyProcess process failed to connect to vstest.console process after 90 seconds. This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout.", exception.Message); - this.mockRequestSender.Verify(rs => rs.InitializeExtensions(It.IsAny>()), Times.Never); - } + [TestMethod] + public void InitializeExtensionsShouldThrowExceptionOnBadConnection() + { + _mockProcessHelper.Setup(x => x.GetCurrentProcessFileName()).Returns("DummyProcess"); + _mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(It.IsAny())).Returns(false); - [TestMethod] - public void DiscoverTestsShouldSucceed() - { - var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; - this.consoleWrapper.DiscoverTests(this.testSources, null, options, new Mock().Object); + var exception = Assert.ThrowsException(() => _consoleWrapper.InitializeExtensions(new List { "Hello", "World" })); + Assert.AreEqual("DummyProcess process failed to connect to vstest.console process after 90 seconds. This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout.", exception.Message); + _mockRequestSender.Verify(rs => rs.InitializeExtensions(It.IsAny>()), Times.Never); + } - this.mockRequestSender.Verify(rs => rs.DiscoverTests(this.testSources, null, options, null, It.IsAny()), Times.Once); - } + [TestMethod] + public void DiscoverTestsShouldSucceed() + { + var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; + _consoleWrapper.DiscoverTests(_testSources, null, options, new Mock().Object); - [TestMethod] - public void DiscoverTestsShouldPassOnNullOptions() - { - this.consoleWrapper.DiscoverTests(this.testSources, null, null, new Mock().Object); + _mockRequestSender.Verify(rs => rs.DiscoverTests(_testSources, null, options, null, It.IsAny()), Times.Once); + } - this.mockRequestSender.Verify(rs => rs.DiscoverTests(this.testSources, null, null, null, It.IsAny()), Times.Once); - } + [TestMethod] + public void DiscoverTestsShouldPassOnNullOptions() + { + _consoleWrapper.DiscoverTests(_testSources, null, null, new Mock().Object); - [TestMethod] - public void DiscoverTestsShouldCallTestDiscoveryHandler2IfTestDiscoveryHandler1IsUsed() - { - this.consoleWrapper.DiscoverTests(this.testSources, null, new Mock().Object); + _mockRequestSender.Verify(rs => rs.DiscoverTests(_testSources, null, null, null, It.IsAny()), Times.Once); + } - this.mockRequestSender.Verify(rs => rs.DiscoverTests(this.testSources, null, null, null, It.IsAny()), Times.Once); - } + [TestMethod] + public void DiscoverTestsShouldCallTestDiscoveryHandler2IfTestDiscoveryHandler1IsUsed() + { + _consoleWrapper.DiscoverTests(_testSources, null, new Mock().Object); - [TestMethod] - public void DiscoverTestsShouldSucceedWhenUsingSessions() - { - var testSessionInfo = new TestSessionInfo(); + _mockRequestSender.Verify(rs => rs.DiscoverTests(_testSources, null, null, null, It.IsAny()), Times.Once); + } - this.consoleWrapper.DiscoverTests( - this.testSources, + [TestMethod] + public void DiscoverTestsShouldSucceedWhenUsingSessions() + { + var testSessionInfo = new TestSessionInfo(); + + _consoleWrapper.DiscoverTests( + _testSources, + null, + null, + testSessionInfo, + new Mock().Object); + + _mockRequestSender.Verify( + rs => rs.DiscoverTests( + _testSources, null, null, testSessionInfo, - new Mock().Object); + It.IsAny()), + Times.Once); + } - this.mockRequestSender.Verify( - rs => rs.DiscoverTests( - this.testSources, - null, - null, - testSessionInfo, - It.IsAny()), - Times.Once); - } - - [TestMethod] - public void DiscoverTestsShouldThrowExceptionOnBadConnection() - { - this.mockProcessHelper.Setup(x => x.GetCurrentProcessFileName()).Returns("DummyProcess"); - this.mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(It.IsAny())).Returns(false); - - var exception = Assert.ThrowsException(() => this.consoleWrapper.DiscoverTests(new List { "Hello", "World" }, null, null, new Mock().Object)); - Assert.AreEqual("DummyProcess process failed to connect to vstest.console process after 90 seconds. This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout.", exception.Message); - this.mockRequestSender.Verify(rs => rs.DiscoverTests(It.IsAny>(), It.IsAny(), null, null, It.IsAny()), Times.Never); - } - - [TestMethod] - public void RunTestsWithSourcesShouldSucceed() - { - this.consoleWrapper.RunTests(this.testSources, "RunSettings", new Mock().Object); - - this.mockRequestSender.Verify(rs => rs.StartTestRun(this.testSources, "RunSettings", It.IsAny(), null, It.IsAny()), Times.Once); - } - - [TestMethod] - public void RunTestsWithSourcesAndNullOptionsShouldPassOnNullOptions() - { - this.consoleWrapper.RunTests( - this.testSources, - "RunSettings", - null, - new Mock().Object); - - this.mockRequestSender.Verify(rs => rs.StartTestRun(this.testSources, "RunSettings", null, null, It.IsAny()), Times.Once); - } - - [TestMethod] - public void RunTestsWithSourcesAndOptionsShouldPassOnOptions() - { - var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; - this.consoleWrapper.RunTests( - this.testSources, - "RunSettings", - options, - new Mock().Object); - - this.mockRequestSender.Verify(rs => rs.StartTestRun(this.testSources, "RunSettings", options, null, It.IsAny()), Times.Once); - } - - [TestMethod] - public void RunTestsWithSourcesShouldSucceedWhenUsingSessions() - { - var testSessionInfo = new TestSessionInfo(); - var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; - this.consoleWrapper.RunTests( - this.testSources, + [TestMethod] + public void DiscoverTestsShouldThrowExceptionOnBadConnection() + { + _mockProcessHelper.Setup(x => x.GetCurrentProcessFileName()).Returns("DummyProcess"); + _mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(It.IsAny())).Returns(false); + + var exception = Assert.ThrowsException(() => _consoleWrapper.DiscoverTests(new List { "Hello", "World" }, null, null, new Mock().Object)); + Assert.AreEqual("DummyProcess process failed to connect to vstest.console process after 90 seconds. This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout.", exception.Message); + _mockRequestSender.Verify(rs => rs.DiscoverTests(It.IsAny>(), It.IsAny(), null, null, It.IsAny()), Times.Never); + } + + [TestMethod] + public void RunTestsWithSourcesShouldSucceed() + { + _consoleWrapper.RunTests(_testSources, "RunSettings", new Mock().Object); + + _mockRequestSender.Verify(rs => rs.StartTestRun(_testSources, "RunSettings", It.IsAny(), null, It.IsAny()), Times.Once); + } + + [TestMethod] + public void RunTestsWithSourcesAndNullOptionsShouldPassOnNullOptions() + { + _consoleWrapper.RunTests( + _testSources, + "RunSettings", + null, + new Mock().Object); + + _mockRequestSender.Verify(rs => rs.StartTestRun(_testSources, "RunSettings", null, null, It.IsAny()), Times.Once); + } + + [TestMethod] + public void RunTestsWithSourcesAndOptionsShouldPassOnOptions() + { + var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; + _consoleWrapper.RunTests( + _testSources, + "RunSettings", + options, + new Mock().Object); + + _mockRequestSender.Verify(rs => rs.StartTestRun(_testSources, "RunSettings", options, null, It.IsAny()), Times.Once); + } + + [TestMethod] + public void RunTestsWithSourcesShouldSucceedWhenUsingSessions() + { + var testSessionInfo = new TestSessionInfo(); + var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; + _consoleWrapper.RunTests( + _testSources, + "RunSettings", + options, + testSessionInfo, + new Mock().Object); + + _mockRequestSender.Verify( + rs => rs.StartTestRun( + _testSources, "RunSettings", options, testSessionInfo, - new Mock().Object); - - this.mockRequestSender.Verify( - rs => rs.StartTestRun( - this.testSources, - "RunSettings", - options, - testSessionInfo, - It.IsAny()), - Times.Once); - } - - [TestMethod] - public void RunTestsWithSourcesAndCustomHostShouldSucceed() - { - this.consoleWrapper.RunTestsWithCustomTestHost( - this.testSources, - "RunSettings", - new Mock().Object, - new Mock().Object); - - this.mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHost(this.testSources, "RunSettings", It.IsAny(), null, It.IsAny(), It.IsAny()), Times.Once); - } - - [TestMethod] - public void RunTestsWithSourcesAndOptionsUsingACustomHostShouldPassOnOptions() - { - var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; - this.consoleWrapper.RunTestsWithCustomTestHost( - this.testSources, - "RunSettings", - options, - new Mock().Object, - new Mock().Object); - - this.mockRequestSender.Verify( - rs => rs.StartTestRunWithCustomHost( - this.testSources, - "RunSettings", - options, - null, - It.IsAny(), - It.IsAny()), - Times.Once); - } - - [TestMethod] - public void RunTestsWithSourcesAndACustomHostShouldSucceedWhenUsingSessions() - { - var testSessionInfo = new TestSessionInfo(); - var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; - this.consoleWrapper.RunTestsWithCustomTestHost( - this.testSources, + It.IsAny()), + Times.Once); + } + + [TestMethod] + public void RunTestsWithSourcesAndCustomHostShouldSucceed() + { + _consoleWrapper.RunTestsWithCustomTestHost( + _testSources, + "RunSettings", + new Mock().Object, + new Mock().Object); + + _mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHost(_testSources, "RunSettings", It.IsAny(), null, It.IsAny(), It.IsAny()), Times.Once); + } + + [TestMethod] + public void RunTestsWithSourcesAndOptionsUsingACustomHostShouldPassOnOptions() + { + var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; + _consoleWrapper.RunTestsWithCustomTestHost( + _testSources, + "RunSettings", + options, + new Mock().Object, + new Mock().Object); + + _mockRequestSender.Verify( + rs => rs.StartTestRunWithCustomHost( + _testSources, "RunSettings", options, - testSessionInfo, - new Mock().Object, - new Mock().Object); - - this.mockRequestSender.Verify( - rs => rs.StartTestRunWithCustomHost( - this.testSources, - "RunSettings", - options, - testSessionInfo, - It.IsAny(), - It.IsAny()), - Times.Once); - } - - [TestMethod] - public void RunTestsWithSelectedTestsShouldSucceed() - { - this.consoleWrapper.RunTests(this.testCases, "RunSettings", new Mock().Object); - - this.mockRequestSender.Verify(rs => rs.StartTestRun(this.testCases, "RunSettings", It.IsAny(), null, It.IsAny()), Times.Once); - } - - [TestMethod] - public void RunTestsWithSelectedTestsAndNullOptionsShouldPassOnNullOptions() - { - this.consoleWrapper.RunTests(this.testCases, "RunSettings", null, new Mock().Object); - - this.mockRequestSender.Verify(rs => rs.StartTestRun(this.testCases, "RunSettings", null, null, It.IsAny()), Times.Once); - } - - [TestMethod] - public void RunTestsWithSelectedTestsAndOptionsShouldPassOnOptions() - { - var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; - - this.consoleWrapper.RunTests(this.testCases, "RunSettings", options, new Mock().Object); - - this.mockRequestSender.Verify(rs => rs.StartTestRun(this.testCases, "RunSettings", options, null, It.IsAny()), Times.Once); - } - - [TestMethod] - public void RunTestsWithSelectedTestsShouldSucceedWhenUsingSessions() - { - var testSessionInfo = new TestSessionInfo(); - var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; - - this.consoleWrapper.RunTests( - this.testCases, + null, + It.IsAny(), + It.IsAny()), + Times.Once); + } + + [TestMethod] + public void RunTestsWithSourcesAndACustomHostShouldSucceedWhenUsingSessions() + { + var testSessionInfo = new TestSessionInfo(); + var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; + _consoleWrapper.RunTestsWithCustomTestHost( + _testSources, + "RunSettings", + options, + testSessionInfo, + new Mock().Object, + new Mock().Object); + + _mockRequestSender.Verify( + rs => rs.StartTestRunWithCustomHost( + _testSources, "RunSettings", options, testSessionInfo, - new Mock().Object); - - this.mockRequestSender.Verify( - rs => rs.StartTestRun( - this.testCases, - "RunSettings", - options, - testSessionInfo, - It.IsAny()), - Times.Once); - } - - [TestMethod] - public void RunTestsWithSelectedTestsAndCustomLauncherShouldSucceed() - { - this.consoleWrapper.RunTestsWithCustomTestHost( - this.testCases, - "RunSettings", - new Mock().Object, - new Mock().Object); + It.IsAny(), + It.IsAny()), + Times.Once); + } - this.mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHost(this.testCases, "RunSettings", It.IsAny(), null, It.IsAny(), It.IsAny()), Times.Once); - } + [TestMethod] + public void RunTestsWithSelectedTestsShouldSucceed() + { + _consoleWrapper.RunTests(_testCases, "RunSettings", new Mock().Object); - [TestMethod] - public void RunTestsWithSelectedTestsAndNullOptionsUsingACustomHostShouldPassOnNullOptions() - { - this.consoleWrapper.RunTestsWithCustomTestHost( - this.testCases, - "RunSettings", - null, - new Mock().Object, - new Mock().Object); + _mockRequestSender.Verify(rs => rs.StartTestRun(_testCases, "RunSettings", It.IsAny(), null, It.IsAny()), Times.Once); + } - this.mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHost(this.testCases, "RunSettings", null, null, It.IsAny(), It.IsAny()), Times.Once); - } + [TestMethod] + public void RunTestsWithSelectedTestsAndNullOptionsShouldPassOnNullOptions() + { + _consoleWrapper.RunTests(_testCases, "RunSettings", null, new Mock().Object); - [TestMethod] - public void RunTestsWithSelectedTestsAndOptionsUsingACustomHostShouldPassOnOptions() - { - var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; + _mockRequestSender.Verify(rs => rs.StartTestRun(_testCases, "RunSettings", null, null, It.IsAny()), Times.Once); + } + + [TestMethod] + public void RunTestsWithSelectedTestsAndOptionsShouldPassOnOptions() + { + var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; - this.consoleWrapper.RunTestsWithCustomTestHost( - this.testCases, + _consoleWrapper.RunTests(_testCases, "RunSettings", options, new Mock().Object); + + _mockRequestSender.Verify(rs => rs.StartTestRun(_testCases, "RunSettings", options, null, It.IsAny()), Times.Once); + } + + [TestMethod] + public void RunTestsWithSelectedTestsShouldSucceedWhenUsingSessions() + { + var testSessionInfo = new TestSessionInfo(); + var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; + + _consoleWrapper.RunTests( + _testCases, + "RunSettings", + options, + testSessionInfo, + new Mock().Object); + + _mockRequestSender.Verify( + rs => rs.StartTestRun( + _testCases, "RunSettings", options, - new Mock().Object, - new Mock().Object); + testSessionInfo, + It.IsAny()), + Times.Once); + } - this.mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHost(this.testCases, "RunSettings", options, null, It.IsAny(), It.IsAny()), Times.Once); - } + [TestMethod] + public void RunTestsWithSelectedTestsAndCustomLauncherShouldSucceed() + { + _consoleWrapper.RunTestsWithCustomTestHost( + _testCases, + "RunSettings", + new Mock().Object, + new Mock().Object); + + _mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHost(_testCases, "RunSettings", It.IsAny(), null, It.IsAny(), It.IsAny()), Times.Once); + } + + [TestMethod] + public void RunTestsWithSelectedTestsAndNullOptionsUsingACustomHostShouldPassOnNullOptions() + { + _consoleWrapper.RunTestsWithCustomTestHost( + _testCases, + "RunSettings", + null, + new Mock().Object, + new Mock().Object); + + _mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHost(_testCases, "RunSettings", null, null, It.IsAny(), It.IsAny()), Times.Once); + } + + [TestMethod] + public void RunTestsWithSelectedTestsAndOptionsUsingACustomHostShouldPassOnOptions() + { + var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; - [TestMethod] - public void RunTestsWithSelectedTestsAndACustomHostShouldSucceedWhenUsingSessions() - { - var testSessionInfo = new TestSessionInfo(); - var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; + _consoleWrapper.RunTestsWithCustomTestHost( + _testCases, + "RunSettings", + options, + new Mock().Object, + new Mock().Object); + + _mockRequestSender.Verify(rs => rs.StartTestRunWithCustomHost(_testCases, "RunSettings", options, null, It.IsAny(), It.IsAny()), Times.Once); + } - this.consoleWrapper.RunTestsWithCustomTestHost( - this.testCases, + [TestMethod] + public void RunTestsWithSelectedTestsAndACustomHostShouldSucceedWhenUsingSessions() + { + var testSessionInfo = new TestSessionInfo(); + var options = new TestPlatformOptions() { TestCaseFilter = "PacMan" }; + + _consoleWrapper.RunTestsWithCustomTestHost( + _testCases, + "RunSettings", + options, + testSessionInfo, + new Mock().Object, + new Mock().Object); + + _mockRequestSender.Verify( + rs => rs.StartTestRunWithCustomHost( + _testCases, "RunSettings", options, testSessionInfo, - new Mock().Object, - new Mock().Object); - - this.mockRequestSender.Verify( - rs => rs.StartTestRunWithCustomHost( - this.testCases, - "RunSettings", - options, - testSessionInfo, - It.IsAny(), - It.IsAny()), - Times.Once); - } - - [TestMethod] - public async Task ProcessTestRunAttachmentsAsyncShouldSucceed() - { - var attachments = new Collection(); - var invokedDataCollectors = new Collection(); - var cancellationToken = new CancellationToken(); - - await this.consoleWrapper.ProcessTestRunAttachmentsAsync( - attachments, - invokedDataCollectors, - Constants.EmptyRunSettings, - true, - true, - new Mock().Object, - cancellationToken); - - this.mockRequestSender.Verify(rs => rs.ProcessTestRunAttachmentsAsync(attachments, invokedDataCollectors, Constants.EmptyRunSettings, true, It.IsAny(), cancellationToken)); - } - - [TestMethod] - public void EndSessionShouldSucceed() - { - this.consoleWrapper.EndSession(); - - this.mockRequestSender.Verify(rs => rs.EndSession(), Times.Once); - this.mockRequestSender.Verify(rs => rs.Close(), Times.Once); - this.mockProcessManager.Verify(x => x.ShutdownProcess(), Times.Once); - } - } -} + It.IsAny(), + It.IsAny()), + Times.Once); + } + + [TestMethod] + public async Task ProcessTestRunAttachmentsAsyncShouldSucceed() + { + var attachments = new Collection(); + var invokedDataCollectors = new Collection(); + var cancellationToken = new CancellationToken(); + + await _consoleWrapper.ProcessTestRunAttachmentsAsync( + attachments, + invokedDataCollectors, + Constants.EmptyRunSettings, + true, + true, + new Mock().Object, + cancellationToken); + + _mockRequestSender.Verify(rs => rs.ProcessTestRunAttachmentsAsync(attachments, invokedDataCollectors, Constants.EmptyRunSettings, true, It.IsAny(), cancellationToken)); + } + + [TestMethod] + public void EndSessionShouldSucceed() + { + _consoleWrapper.EndSession(); + + _mockRequestSender.Verify(rs => rs.EndSession(), Times.Once); + _mockRequestSender.Verify(rs => rs.Close(), Times.Once); + _mockProcessManager.Verify(x => x.ShutdownProcess(), Times.Once); + } +} \ No newline at end of file diff --git a/test/datacollector.PlatformTests/CommunicationLayerIntegrationTests.cs b/test/datacollector.PlatformTests/CommunicationLayerIntegrationTests.cs index 4040508d97..27f9959ffe 100644 --- a/test/datacollector.PlatformTests/CommunicationLayerIntegrationTests.cs +++ b/test/datacollector.PlatformTests/CommunicationLayerIntegrationTests.cs @@ -1,107 +1,100 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.DataCollector.PlatformTests +namespace Microsoft.VisualStudio.TestPlatform.DataCollector.PlatformTests; + +using System.Collections.Generic; +using System.Diagnostics; +using System.Reflection; + +using CommunicationUtilities; +using CommunicationUtilities.DataCollection; +using CrossPlatEngine.DataCollection; +using CrossPlatEngine.DataCollection.Interfaces; +using ObjectModel.Client; +using PlatformAbstractions; +using PlatformAbstractions.Interfaces; +using TestTools.UnitTesting; + +using Moq; + +[TestClass] +[Ignore] // Tests are flaky +public class CommunicationLayerIntegrationTests { - using System.Collections.Generic; - using System.Diagnostics; - using System.Reflection; - - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - [TestClass] - [Ignore] // Tests are flaky - public class CommunicationLayerIntegrationTests + private readonly string _defaultRunSettings = "\r\n\r\n \r\n {0}\r\n \r\n"; + private readonly Mock _mockTestMessageEventHandler; + private readonly string _dataCollectorSettings, _runSettings; + private readonly IDataCollectionLauncher _dataCollectionLauncher; + private readonly IProcessHelper _processHelper; + private readonly Mock _mockRequestData; + private readonly Mock _mockMetricsCollection; + private readonly List _testSources; + + public CommunicationLayerIntegrationTests() { - private string defaultRunSettings = "\r\n\r\n \r\n {0}\r\n \r\n"; - private Mock mockTestMessageEventHandler; - private string dataCollectorSettings, runSettings; - private IDataCollectionLauncher dataCollectionLauncher; - private IProcessHelper processHelper; - private Mock mockRequestData; - private Mock mockMetricsCollection; - private List testSources; - - public CommunicationLayerIntegrationTests() - { - this.mockTestMessageEventHandler = new Mock(); - this.mockRequestData = new Mock(); - this.mockMetricsCollection = new Mock(); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(this.mockMetricsCollection.Object); - this.dataCollectorSettings = string.Format("", typeof(CustomDataCollector).AssemblyQualifiedName, typeof(CustomDataCollector).GetTypeInfo().Assembly.Location); - this.runSettings = string.Format(this.defaultRunSettings, this.dataCollectorSettings); - this.testSources = new List() { "testsource1.dll" }; - this.processHelper = new ProcessHelper(); - this.dataCollectionLauncher = DataCollectionLauncherFactory.GetDataCollectorLauncher(this.processHelper, this.runSettings); - } - - [TestMethod] - public void BeforeTestRunStartShouldGetEnviornmentVariables() - { - var dataCollectionRequestSender = new DataCollectionRequestSender(); - - using (var proxyDataCollectionManager = new ProxyDataCollectionManager(this.mockRequestData.Object, this.runSettings, this.testSources, dataCollectionRequestSender, this.processHelper, this.dataCollectionLauncher)) - { - proxyDataCollectionManager.Initialize(); - - var result = proxyDataCollectionManager.BeforeTestRunStart(true, true, this.mockTestMessageEventHandler.Object); - - Assert.AreEqual(1, result.EnvironmentVariables.Count); - } - } - - [TestMethod] - public void AfterTestRunShouldSendGetAttachments() - { - var dataCollectionRequestSender = new DataCollectionRequestSender(); - - using (var proxyDataCollectionManager = new ProxyDataCollectionManager(this.mockRequestData.Object, this.runSettings, this.testSources, dataCollectionRequestSender, this.processHelper, this.dataCollectionLauncher)) - { - proxyDataCollectionManager.Initialize(); - - proxyDataCollectionManager.BeforeTestRunStart(true, true, this.mockTestMessageEventHandler.Object); - - var dataCollectionResult = proxyDataCollectionManager.AfterTestRunEnd(false, this.mockTestMessageEventHandler.Object); - - Assert.AreEqual("CustomDataCollector", dataCollectionResult.Attachments[0].DisplayName); - Assert.AreEqual("my://custom/datacollector", dataCollectionResult.Attachments[0].Uri.ToString()); - Assert.IsTrue(dataCollectionResult.Attachments[0].Attachments[0].Uri.ToString().Contains("filename.txt")); - } - } - - [TestMethod] - public void AfterTestRunShouldHandleSocketFailureGracefully() - { - var socketCommManager = new SocketCommunicationManager(); - var dataCollectionRequestSender = new DataCollectionRequestSender(socketCommManager, JsonDataSerializer.Instance); - var dataCollectionLauncher = DataCollectionLauncherFactory.GetDataCollectorLauncher(this.processHelper, this.runSettings); - - using (var proxyDataCollectionManager = new ProxyDataCollectionManager(this.mockRequestData.Object, this.runSettings, this.testSources, dataCollectionRequestSender, this.processHelper, dataCollectionLauncher)) - { - proxyDataCollectionManager.Initialize(); - proxyDataCollectionManager.BeforeTestRunStart(true, true, this.mockTestMessageEventHandler.Object); - - var result = Process.GetProcessById(dataCollectionLauncher.DataCollectorProcessId); - Assert.IsNotNull(result); - - socketCommManager.StopClient(); - - var attachments = proxyDataCollectionManager.AfterTestRunEnd(false, this.mockTestMessageEventHandler.Object); - - Assert.IsNull(attachments); - - // Give time to datacollector process to exit. - Assert.IsTrue(result.WaitForExit(500)); - } - } + _mockTestMessageEventHandler = new Mock(); + _mockRequestData = new Mock(); + _mockMetricsCollection = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(_mockMetricsCollection.Object); + _dataCollectorSettings = string.Format("", typeof(CustomDataCollector).AssemblyQualifiedName, typeof(CustomDataCollector).GetTypeInfo().Assembly.Location); + _runSettings = string.Format(_defaultRunSettings, _dataCollectorSettings); + _testSources = new List() { "testsource1.dll" }; + _processHelper = new ProcessHelper(); + _dataCollectionLauncher = DataCollectionLauncherFactory.GetDataCollectorLauncher(_processHelper, _runSettings); + } + + [TestMethod] + public void BeforeTestRunStartShouldGetEnviornmentVariables() + { + var dataCollectionRequestSender = new DataCollectionRequestSender(); + + using var proxyDataCollectionManager = new ProxyDataCollectionManager(_mockRequestData.Object, _runSettings, _testSources, dataCollectionRequestSender, _processHelper, _dataCollectionLauncher); + proxyDataCollectionManager.Initialize(); + + var result = proxyDataCollectionManager.BeforeTestRunStart(true, true, _mockTestMessageEventHandler.Object); + + Assert.AreEqual(1, result.EnvironmentVariables.Count); + } + + [TestMethod] + public void AfterTestRunShouldSendGetAttachments() + { + var dataCollectionRequestSender = new DataCollectionRequestSender(); + + using var proxyDataCollectionManager = new ProxyDataCollectionManager(_mockRequestData.Object, _runSettings, _testSources, dataCollectionRequestSender, _processHelper, _dataCollectionLauncher); + proxyDataCollectionManager.Initialize(); + + proxyDataCollectionManager.BeforeTestRunStart(true, true, _mockTestMessageEventHandler.Object); + + var dataCollectionResult = proxyDataCollectionManager.AfterTestRunEnd(false, _mockTestMessageEventHandler.Object); + + Assert.AreEqual("CustomDataCollector", dataCollectionResult.Attachments[0].DisplayName); + Assert.AreEqual("my://custom/datacollector", dataCollectionResult.Attachments[0].Uri.ToString()); + Assert.IsTrue(dataCollectionResult.Attachments[0].Attachments[0].Uri.ToString().Contains("filename.txt")); + } + + [TestMethod] + public void AfterTestRunShouldHandleSocketFailureGracefully() + { + var socketCommManager = new SocketCommunicationManager(); + var dataCollectionRequestSender = new DataCollectionRequestSender(socketCommManager, JsonDataSerializer.Instance); + var dataCollectionLauncher = DataCollectionLauncherFactory.GetDataCollectorLauncher(_processHelper, _runSettings); + + using var proxyDataCollectionManager = new ProxyDataCollectionManager(_mockRequestData.Object, _runSettings, _testSources, dataCollectionRequestSender, _processHelper, dataCollectionLauncher); + proxyDataCollectionManager.Initialize(); + proxyDataCollectionManager.BeforeTestRunStart(true, true, _mockTestMessageEventHandler.Object); + + var result = Process.GetProcessById(dataCollectionLauncher.DataCollectorProcessId); + Assert.IsNotNull(result); + + socketCommManager.StopClient(); + + var attachments = proxyDataCollectionManager.AfterTestRunEnd(false, _mockTestMessageEventHandler.Object); + + Assert.IsNull(attachments); + + // Give time to datacollector process to exit. + Assert.IsTrue(result.WaitForExit(500)); } } \ No newline at end of file diff --git a/test/datacollector.PlatformTests/CustomDataCollector.cs b/test/datacollector.PlatformTests/CustomDataCollector.cs index 4a335e363c..25559b9b92 100644 --- a/test/datacollector.PlatformTests/CustomDataCollector.cs +++ b/test/datacollector.PlatformTests/CustomDataCollector.cs @@ -1,57 +1,56 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.DataCollector.PlatformTests +namespace Microsoft.VisualStudio.TestPlatform.DataCollector.PlatformTests; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml; + +using ObjectModel.DataCollection; + +[DataCollectorFriendlyName("CustomDataCollector")] +[DataCollectorTypeUri("my://custom/datacollector")] +public class CustomDataCollector : DataCollector, ITestExecutionEnvironmentSpecifier { - using System; - using System.Collections.Generic; - using System.IO; - using System.Xml; + private DataCollectionSink _dataCollectionSink; + private DataCollectionEnvironmentContext _context; + private DataCollectionLogger _logger; + + public override void Initialize( + XmlElement configurationElement, + DataCollectionEvents events, + DataCollectionSink dataSink, + DataCollectionLogger logger, + DataCollectionEnvironmentContext environmentContext) + { + events.SessionStart += new EventHandler(SessionStarted_Handler); + events.SessionEnd += new EventHandler(SessionEnded_Handler); + _dataCollectionSink = dataSink; + _context = environmentContext; + _logger = logger; + } - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + private void SessionStarted_Handler(object sender, SessionStartEventArgs args) + { + var filename = Path.Combine(Path.GetTempPath(), "filename.txt"); + File.WriteAllText(filename, string.Empty); + _dataCollectionSink.SendFileAsync(_context.SessionDataCollectionContext, filename, true); + _logger.LogWarning(_context.SessionDataCollectionContext, "SessionEnded"); + } + + private void SessionEnded_Handler(object sender, SessionEndEventArgs args) + { + //logger.LogError(this.context.SessionDataCollectionContext, new Exception("my exception")); + //logger.LogWarning(this.context.SessionDataCollectionContext, "my arning"); + //logger.LogException(context.SessionDataCollectionContext, new Exception("abc"), DataCollectorMessageLevel.Error); + + _logger.LogWarning(_context.SessionDataCollectionContext, "SessionEnded"); + } - [DataCollectorFriendlyName("CustomDataCollector")] - [DataCollectorTypeUri("my://custom/datacollector")] - public class CustomDataCollector : DataCollector, ITestExecutionEnvironmentSpecifier + public IEnumerable> GetTestExecutionEnvironmentVariables() { - private DataCollectionSink dataCollectionSink; - private DataCollectionEnvironmentContext context; - private DataCollectionLogger logger; - - public override void Initialize( - System.Xml.XmlElement configurationElement, - DataCollectionEvents events, - DataCollectionSink dataSink, - DataCollectionLogger logger, - DataCollectionEnvironmentContext environmentContext) - { - events.SessionStart += new EventHandler(this.SessionStarted_Handler); - events.SessionEnd += new EventHandler(this.SessionEnded_Handler); - this.dataCollectionSink = dataSink; - this.context = environmentContext; - this.logger = logger; - } - - private void SessionStarted_Handler(object sender, SessionStartEventArgs args) - { - var filename = Path.Combine(Path.GetTempPath(), "filename.txt"); - File.WriteAllText(filename, string.Empty); - this.dataCollectionSink.SendFileAsync(context.SessionDataCollectionContext, filename, true); - this.logger.LogWarning(this.context.SessionDataCollectionContext, "SessionEnded"); - } - - private void SessionEnded_Handler(object sender, SessionEndEventArgs args) - { - //logger.LogError(this.context.SessionDataCollectionContext, new Exception("my exception")); - //logger.LogWarning(this.context.SessionDataCollectionContext, "my arning"); - //logger.LogException(context.SessionDataCollectionContext, new Exception("abc"), DataCollectorMessageLevel.Error); - - this.logger.LogWarning(this.context.SessionDataCollectionContext, "SessionEnded"); - } - - public IEnumerable> GetTestExecutionEnvironmentVariables() - { - return new List> { new KeyValuePair("key", "value") }; - } + return new List> { new KeyValuePair("key", "value") }; } -} +} \ No newline at end of file diff --git a/test/datacollector.PlatformTests/Program.cs b/test/datacollector.PlatformTests/Program.cs index 2ff9995413..2be6d51aa8 100644 --- a/test/datacollector.PlatformTests/Program.cs +++ b/test/datacollector.PlatformTests/Program.cs @@ -1,15 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.DataCollector.ComponentTests +namespace Microsoft.VisualStudio.TestPlatform.DataCollector.ComponentTests; + +/// +/// Main entry point for the command line runner. +/// +public static class Program { - /// - /// Main entry point for the command line runner. - /// - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } -} +} \ No newline at end of file diff --git a/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs b/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs index 3a5ead9182..7045ef1cf0 100644 --- a/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs +++ b/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs @@ -1,296 +1,286 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests -{ - using System; - using System.ComponentModel; - using System.IO; - using System.Threading; +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.ComponentModel; +using System.IO; +using System.Threading; - using Moq; +using Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using TestTools.UnitTesting; - [TestClass] - public class DataCollectionAttachmentManagerTests - { - private const int Timeout = 10 * 60 * 1000; - private DataCollectionAttachmentManager attachmentManager; - private Mock messageSink; - private SessionId sessionId; - private static readonly string TempDirectoryPath = Path.GetTempPath(); +using Moq; - public DataCollectionAttachmentManagerTests() - { - this.attachmentManager = new DataCollectionAttachmentManager(); - this.messageSink = new Mock(); - var guid = Guid.NewGuid(); - this.sessionId = new SessionId(guid); - } +[TestClass] +public class DataCollectionAttachmentManagerTests +{ + private const int Timeout = 10 * 60 * 1000; + private readonly DataCollectionAttachmentManager _attachmentManager; + private readonly Mock _messageSink; + private readonly SessionId _sessionId; + private static readonly string TempDirectoryPath = Path.GetTempPath(); - [TestCleanup] - public void Cleanup() - { - File.Delete(Path.Combine(TempDirectoryPath, "filename.txt")); - File.Delete(Path.Combine(TempDirectoryPath, "filename1.txt")); - } + public DataCollectionAttachmentManagerTests() + { + _attachmentManager = new DataCollectionAttachmentManager(); + _messageSink = new Mock(); + var guid = Guid.NewGuid(); + _sessionId = new SessionId(guid); + } - [TestMethod] - public void InitializeShouldThrowExceptionIfSessionIdIsNull() - { - Assert.ThrowsException(() => - { - this.attachmentManager.Initialize((SessionId)null, string.Empty, this.messageSink.Object); - }); - } + [TestCleanup] + public void Cleanup() + { + File.Delete(Path.Combine(TempDirectoryPath, "filename.txt")); + File.Delete(Path.Combine(TempDirectoryPath, "filename1.txt")); + } - [TestMethod] - public void InitializeShouldThrowExceptionIfMessageSinkIsNull() - { - Assert.ThrowsException(() => - { - this.attachmentManager.Initialize(this.sessionId, string.Empty, null); - }); - } + [TestMethod] + public void InitializeShouldThrowExceptionIfSessionIdIsNull() + { + Assert.ThrowsException(() => _attachmentManager.Initialize((SessionId)null, string.Empty, _messageSink.Object)); + } - [TestMethod] - public void InitializeShouldSetDefaultPathIfOutputDirectoryPathIsNull() - { - this.attachmentManager.Initialize(this.sessionId, string.Empty, this.messageSink.Object); + [TestMethod] + public void InitializeShouldThrowExceptionIfMessageSinkIsNull() + { + Assert.ThrowsException(() => _attachmentManager.Initialize(_sessionId, string.Empty, null)); + } - Assert.AreEqual(this.attachmentManager.SessionOutputDirectory, Path.Combine(Path.GetTempPath(), "TestResults", this.sessionId.Id.ToString())); - } + [TestMethod] + public void InitializeShouldSetDefaultPathIfOutputDirectoryPathIsNull() + { + _attachmentManager.Initialize(_sessionId, string.Empty, _messageSink.Object); - [TestMethod] - public void InitializeShouldSetCorrectGuidAndOutputPath() - { - this.attachmentManager.Initialize(this.sessionId, TempDirectoryPath, this.messageSink.Object); + Assert.AreEqual(_attachmentManager.SessionOutputDirectory, Path.Combine(Path.GetTempPath(), "TestResults", _sessionId.Id.ToString())); + } - Assert.AreEqual(Path.Combine(TempDirectoryPath, this.sessionId.Id.ToString()), this.attachmentManager.SessionOutputDirectory); - } + [TestMethod] + public void InitializeShouldSetCorrectGuidAndOutputPath() + { + _attachmentManager.Initialize(_sessionId, TempDirectoryPath, _messageSink.Object); - [TestMethod] - public void AddAttachmentShouldNotAddNewFileTransferIfSessionIsNotConfigured() - { - var filename = "filename.txt"; - File.WriteAllText(Path.Combine(TempDirectoryPath, filename), string.Empty); + Assert.AreEqual(Path.Combine(TempDirectoryPath, _sessionId.Id.ToString()), _attachmentManager.SessionOutputDirectory); + } - var datacollectioncontext = new DataCollectionContext(this.sessionId); - var friendlyName = "TestDataCollector"; - var uri = new Uri("datacollector://Company/Product/Version"); + [TestMethod] + public void AddAttachmentShouldNotAddNewFileTransferIfSessionIsNotConfigured() + { + var filename = "filename.txt"; + File.WriteAllText(Path.Combine(TempDirectoryPath, filename), string.Empty); - var dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, Path.Combine(TempDirectoryPath, filename), false); + var datacollectioncontext = new DataCollectionContext(_sessionId); + var friendlyName = "TestDataCollector"; + var uri = new Uri("datacollector://Company/Product/Version"); - this.attachmentManager.AddAttachment(dataCollectorDataMessage, null, uri, friendlyName); + var dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, Path.Combine(TempDirectoryPath, filename), false); - Assert.AreEqual(0, this.attachmentManager.AttachmentSets.Count); - } + _attachmentManager.AddAttachment(dataCollectorDataMessage, null, uri, friendlyName); - [TestMethod] - public void AddAttachmentShouldAddNewFileTransferAndCopyFileToOutputDirectoryIfDeleteFileIsFalse() - { - var filename = "filename.txt"; - File.WriteAllText(Path.Combine(TempDirectoryPath, filename), string.Empty); + Assert.AreEqual(0, _attachmentManager.AttachmentSets.Count); + } + [TestMethod] + public void AddAttachmentShouldAddNewFileTransferAndCopyFileToOutputDirectoryIfDeleteFileIsFalse() + { + var filename = "filename.txt"; + File.WriteAllText(Path.Combine(TempDirectoryPath, filename), string.Empty); - this.attachmentManager.Initialize(this.sessionId, TempDirectoryPath, this.messageSink.Object); - var datacollectioncontext = new DataCollectionContext(this.sessionId); - var friendlyName = "TestDataCollector"; - var uri = new Uri("datacollector://Company/Product/Version"); + _attachmentManager.Initialize(_sessionId, TempDirectoryPath, _messageSink.Object); - EventWaitHandle waitHandle = new AutoResetEvent(false); - var handler = new AsyncCompletedEventHandler((a, e) => { waitHandle.Set(); }); - var dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, Path.Combine(TempDirectoryPath, filename), false); + var datacollectioncontext = new DataCollectionContext(_sessionId); + var friendlyName = "TestDataCollector"; + var uri = new Uri("datacollector://Company/Product/Version"); + EventWaitHandle waitHandle = new AutoResetEvent(false); + var handler = new AsyncCompletedEventHandler((a, e) => waitHandle.Set()); + var dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, Path.Combine(TempDirectoryPath, filename), false); - this.attachmentManager.AddAttachment(dataCollectorDataMessage, handler, uri, friendlyName); - // Wait for file operations to complete - waitHandle.WaitOne(Timeout); + _attachmentManager.AddAttachment(dataCollectorDataMessage, handler, uri, friendlyName); - Assert.IsTrue(File.Exists(Path.Combine(TempDirectoryPath, filename))); - Assert.IsTrue(File.Exists(Path.Combine(TempDirectoryPath, this.sessionId.Id.ToString(), filename))); - Assert.AreEqual(1, this.attachmentManager.AttachmentSets[datacollectioncontext][uri].Attachments.Count); - } + // Wait for file operations to complete + waitHandle.WaitOne(Timeout); - [TestMethod] - public void AddAttachmentsShouldAddFilesCorrespondingToDifferentDataCollectors() - { - var filename = "filename.txt"; - var filename1 = "filename1.txt"; - File.WriteAllText(Path.Combine(TempDirectoryPath, filename), string.Empty); - File.WriteAllText(Path.Combine(TempDirectoryPath, filename1), string.Empty); + Assert.IsTrue(File.Exists(Path.Combine(TempDirectoryPath, filename))); + Assert.IsTrue(File.Exists(Path.Combine(TempDirectoryPath, _sessionId.Id.ToString(), filename))); + Assert.AreEqual(1, _attachmentManager.AttachmentSets[datacollectioncontext][uri].Attachments.Count); + } - this.attachmentManager.Initialize(this.sessionId, TempDirectoryPath, this.messageSink.Object); + [TestMethod] + public void AddAttachmentsShouldAddFilesCorrespondingToDifferentDataCollectors() + { + var filename = "filename.txt"; + var filename1 = "filename1.txt"; + File.WriteAllText(Path.Combine(TempDirectoryPath, filename), string.Empty); + File.WriteAllText(Path.Combine(TempDirectoryPath, filename1), string.Empty); - var datacollectioncontext = new DataCollectionContext(this.sessionId); - var friendlyName = "TestDataCollector"; - var uri = new Uri("datacollector://Company/Product/Version"); - var uri1 = new Uri("datacollector://Company/Product/Version1"); + _attachmentManager.Initialize(_sessionId, TempDirectoryPath, _messageSink.Object); - EventWaitHandle waitHandle = new AutoResetEvent(false); - var handler = new AsyncCompletedEventHandler((a, e) => { waitHandle.Set(); }); - var dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, Path.Combine(TempDirectoryPath, filename), false); + var datacollectioncontext = new DataCollectionContext(_sessionId); + var friendlyName = "TestDataCollector"; + var uri = new Uri("datacollector://Company/Product/Version"); + var uri1 = new Uri("datacollector://Company/Product/Version1"); - this.attachmentManager.AddAttachment(dataCollectorDataMessage, handler, uri, friendlyName); + EventWaitHandle waitHandle = new AutoResetEvent(false); + var handler = new AsyncCompletedEventHandler((a, e) => waitHandle.Set()); + var dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, Path.Combine(TempDirectoryPath, filename), false); - // Wait for file operations to complete - waitHandle.WaitOne(Timeout); + _attachmentManager.AddAttachment(dataCollectorDataMessage, handler, uri, friendlyName); - waitHandle.Reset(); - dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, Path.Combine(TempDirectoryPath, filename1), false); - this.attachmentManager.AddAttachment(dataCollectorDataMessage, handler, uri1, friendlyName); + // Wait for file operations to complete + waitHandle.WaitOne(Timeout); - // Wait for file operations to complete - waitHandle.WaitOne(Timeout); + waitHandle.Reset(); + dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, Path.Combine(TempDirectoryPath, filename1), false); + _attachmentManager.AddAttachment(dataCollectorDataMessage, handler, uri1, friendlyName); - Assert.AreEqual(1, this.attachmentManager.AttachmentSets[datacollectioncontext][uri].Attachments.Count); - Assert.AreEqual(1, this.attachmentManager.AttachmentSets[datacollectioncontext][uri1].Attachments.Count); - } + // Wait for file operations to complete + waitHandle.WaitOne(Timeout); - [TestMethod] - public void AddAttachmentShouldAddNewFileTransferAndMoveFileToOutputDirectoryIfDeleteFileIsTrue() - { - var filename = "filename1.txt"; - File.WriteAllText(Path.Combine(TempDirectoryPath, filename), string.Empty); + Assert.AreEqual(1, _attachmentManager.AttachmentSets[datacollectioncontext][uri].Attachments.Count); + Assert.AreEqual(1, _attachmentManager.AttachmentSets[datacollectioncontext][uri1].Attachments.Count); + } + [TestMethod] + public void AddAttachmentShouldAddNewFileTransferAndMoveFileToOutputDirectoryIfDeleteFileIsTrue() + { + var filename = "filename1.txt"; + File.WriteAllText(Path.Combine(TempDirectoryPath, filename), string.Empty); - this.attachmentManager.Initialize(this.sessionId, TempDirectoryPath, this.messageSink.Object); - var datacollectioncontext = new DataCollectionContext(this.sessionId); - var friendlyName = "TestDataCollector"; - var uri = new Uri("datacollector://Company/Product/Version"); + _attachmentManager.Initialize(_sessionId, TempDirectoryPath, _messageSink.Object); - var waitHandle = new AutoResetEvent(false); - var handler = new AsyncCompletedEventHandler((a, e) => { waitHandle.Set(); }); - var dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, Path.Combine(TempDirectoryPath, filename), true); + var datacollectioncontext = new DataCollectionContext(_sessionId); + var friendlyName = "TestDataCollector"; + var uri = new Uri("datacollector://Company/Product/Version"); - this.attachmentManager.AddAttachment(dataCollectorDataMessage, handler, uri, friendlyName); + var waitHandle = new AutoResetEvent(false); + var handler = new AsyncCompletedEventHandler((a, e) => waitHandle.Set()); + var dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, Path.Combine(TempDirectoryPath, filename), true); - // Wait for file operations to complete - waitHandle.WaitOne(Timeout); + _attachmentManager.AddAttachment(dataCollectorDataMessage, handler, uri, friendlyName); - Assert.AreEqual(1, this.attachmentManager.AttachmentSets[datacollectioncontext][uri].Attachments.Count); - Assert.IsTrue(File.Exists(Path.Combine(TempDirectoryPath, this.sessionId.Id.ToString(), filename))); - Assert.IsFalse(File.Exists(Path.Combine(TempDirectoryPath, filename))); - } + // Wait for file operations to complete + waitHandle.WaitOne(Timeout); - [TestMethod] - public void AddAttachmentShouldAddMultipleAttachmentsForSameDC() - { - var filename = "filename.txt"; - var filename1 = "filename1.txt"; - File.WriteAllText(Path.Combine(TempDirectoryPath, filename), string.Empty); - File.WriteAllText(Path.Combine(TempDirectoryPath, filename1), string.Empty); + Assert.AreEqual(1, _attachmentManager.AttachmentSets[datacollectioncontext][uri].Attachments.Count); + Assert.IsTrue(File.Exists(Path.Combine(TempDirectoryPath, _sessionId.Id.ToString(), filename))); + Assert.IsFalse(File.Exists(Path.Combine(TempDirectoryPath, filename))); + } - this.attachmentManager.Initialize(this.sessionId, TempDirectoryPath, this.messageSink.Object); + [TestMethod] + public void AddAttachmentShouldAddMultipleAttachmentsForSameDc() + { + var filename = "filename.txt"; + var filename1 = "filename1.txt"; + File.WriteAllText(Path.Combine(TempDirectoryPath, filename), string.Empty); + File.WriteAllText(Path.Combine(TempDirectoryPath, filename1), string.Empty); - var datacollectioncontext = new DataCollectionContext(this.sessionId); - var friendlyName = "TestDataCollector"; - var uri = new Uri("datacollector://Company/Product/Version"); + _attachmentManager.Initialize(_sessionId, TempDirectoryPath, _messageSink.Object); - EventWaitHandle waitHandle = new AutoResetEvent(false); - var handler = new AsyncCompletedEventHandler((a, e) => { waitHandle.Set(); }); - var dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, Path.Combine(TempDirectoryPath, filename), false); + var datacollectioncontext = new DataCollectionContext(_sessionId); + var friendlyName = "TestDataCollector"; + var uri = new Uri("datacollector://Company/Product/Version"); - this.attachmentManager.AddAttachment(dataCollectorDataMessage, handler, uri, friendlyName); + EventWaitHandle waitHandle = new AutoResetEvent(false); + var handler = new AsyncCompletedEventHandler((a, e) => waitHandle.Set()); + var dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, Path.Combine(TempDirectoryPath, filename), false); - // Wait for file operations to complete - waitHandle.WaitOne(Timeout); + _attachmentManager.AddAttachment(dataCollectorDataMessage, handler, uri, friendlyName); - waitHandle.Reset(); - dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, Path.Combine(TempDirectoryPath, filename1), false); - this.attachmentManager.AddAttachment(dataCollectorDataMessage, handler, uri, friendlyName); + // Wait for file operations to complete + waitHandle.WaitOne(Timeout); - // Wait for file operations to complete - waitHandle.WaitOne(Timeout); + waitHandle.Reset(); + dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, Path.Combine(TempDirectoryPath, filename1), false); + _attachmentManager.AddAttachment(dataCollectorDataMessage, handler, uri, friendlyName); - Assert.AreEqual(2, this.attachmentManager.AttachmentSets[datacollectioncontext][uri].Attachments.Count); - } + // Wait for file operations to complete + waitHandle.WaitOne(Timeout); - [TestMethod] - public void AddAttachmentShouldNotAddNewFileTransferIfNullIsPassed() - { - Assert.ThrowsException(() => - { - this.attachmentManager.AddAttachment(null, null, null, null); - }); - } + Assert.AreEqual(2, _attachmentManager.AttachmentSets[datacollectioncontext][uri].Attachments.Count); + } - [TestMethod] - public void GetAttachmentsShouldReturnAllAttachmets() - { - var filename = "filename1.txt"; - File.WriteAllText(Path.Combine(TempDirectoryPath, filename), string.Empty); + [TestMethod] + public void AddAttachmentShouldNotAddNewFileTransferIfNullIsPassed() + { + Assert.ThrowsException(() => _attachmentManager.AddAttachment(null, null, null, null)); + } + + [TestMethod] + public void GetAttachmentsShouldReturnAllAttachmets() + { + var filename = "filename1.txt"; + File.WriteAllText(Path.Combine(TempDirectoryPath, filename), string.Empty); - this.attachmentManager.Initialize(this.sessionId, TempDirectoryPath, this.messageSink.Object); + _attachmentManager.Initialize(_sessionId, TempDirectoryPath, _messageSink.Object); - var datacollectioncontext = new DataCollectionContext(this.sessionId); - var friendlyName = "TestDataCollector"; - var uri = new Uri("datacollector://Company/Product/Version"); + var datacollectioncontext = new DataCollectionContext(_sessionId); + var friendlyName = "TestDataCollector"; + var uri = new Uri("datacollector://Company/Product/Version"); - var dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, Path.Combine(TempDirectoryPath, filename), true); + var dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, Path.Combine(TempDirectoryPath, filename), true); - this.attachmentManager.AddAttachment(dataCollectorDataMessage, null, uri, friendlyName); + _attachmentManager.AddAttachment(dataCollectorDataMessage, null, uri, friendlyName); - Assert.AreEqual(1, this.attachmentManager.AttachmentSets.Count); - var result = this.attachmentManager.GetAttachments(datacollectioncontext); + Assert.AreEqual(1, _attachmentManager.AttachmentSets.Count); + var result = _attachmentManager.GetAttachments(datacollectioncontext); - Assert.AreEqual(0, this.attachmentManager.AttachmentSets.Count); - Assert.AreEqual(1, result.Count); - Assert.AreEqual(friendlyName, result[0].DisplayName); - Assert.AreEqual(uri, result[0].Uri); - Assert.AreEqual(1, result[0].Attachments.Count); - } + Assert.AreEqual(0, _attachmentManager.AttachmentSets.Count); + Assert.AreEqual(1, result.Count); + Assert.AreEqual(friendlyName, result[0].DisplayName); + Assert.AreEqual(uri, result[0].Uri); + Assert.AreEqual(1, result[0].Attachments.Count); + } - [TestMethod] - public void GetAttachmentsShouldNotReutrnAnyDataWhenActiveFileTransferAreNotPresent() - { - this.attachmentManager.Initialize(this.sessionId, TempDirectoryPath, this.messageSink.Object); + [TestMethod] + public void GetAttachmentsShouldNotReutrnAnyDataWhenActiveFileTransferAreNotPresent() + { + _attachmentManager.Initialize(_sessionId, TempDirectoryPath, _messageSink.Object); - var datacollectioncontext = new DataCollectionContext(this.sessionId); + var datacollectioncontext = new DataCollectionContext(_sessionId); - var result = this.attachmentManager.GetAttachments(datacollectioncontext); - Assert.AreEqual(0, result.Count); - } + var result = _attachmentManager.GetAttachments(datacollectioncontext); + Assert.AreEqual(0, result.Count); + } - [TestMethod] - public void GetAttachmentsShouldNotReturnAttachmentsAfterCancelled() - { - var fileHelper = new Mock(); - var testableAttachmentManager = new TestableDataCollectionAttachmentManager(fileHelper.Object); - var attachmentPath = Path.Combine(TempDirectoryPath, "filename.txt"); - File.WriteAllText(attachmentPath, string.Empty); - var datacollectioncontext = new DataCollectionContext(this.sessionId); - var friendlyName = "TestDataCollector"; - var uri = new Uri("datacollector://Company/Product/Version"); - var dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, attachmentPath, true); - var waitHandle = new AutoResetEvent(false); - var handler = new AsyncCompletedEventHandler((a, e) => { Assert.Fail("Handler shouldn't be called since operation is canceled."); }); - - // We cancel the operation in the actual operation. This ensures the follow up task to is never called, attachments - // are not added. - Action cancelAddAttachment = () => testableAttachmentManager.Cancel(); - fileHelper.Setup(fh => fh.MoveFile(It.IsAny(), It.IsAny())).Callback(cancelAddAttachment); - testableAttachmentManager.Initialize(this.sessionId, TempDirectoryPath, this.messageSink.Object); - testableAttachmentManager.AddAttachment(dataCollectorDataMessage, handler, uri, friendlyName); - - // Wait for the attachment transfer tasks to complete - var result = testableAttachmentManager.GetAttachments(datacollectioncontext); - Assert.AreEqual(0, result[0].Attachments.Count); - } + [TestMethod] + public void GetAttachmentsShouldNotReturnAttachmentsAfterCancelled() + { + var fileHelper = new Mock(); + var testableAttachmentManager = new TestableDataCollectionAttachmentManager(fileHelper.Object); + var attachmentPath = Path.Combine(TempDirectoryPath, "filename.txt"); + File.WriteAllText(attachmentPath, string.Empty); + var datacollectioncontext = new DataCollectionContext(_sessionId); + var friendlyName = "TestDataCollector"; + var uri = new Uri("datacollector://Company/Product/Version"); + var dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, attachmentPath, true); + var waitHandle = new AutoResetEvent(false); + var handler = new AsyncCompletedEventHandler((a, e) => Assert.Fail("Handler shouldn't be called since operation is canceled.")); + + // We cancel the operation in the actual operation. This ensures the follow up task to is never called, attachments + // are not added. + Action cancelAddAttachment = () => testableAttachmentManager.Cancel(); + fileHelper.Setup(fh => fh.MoveFile(It.IsAny(), It.IsAny())).Callback(cancelAddAttachment); + testableAttachmentManager.Initialize(_sessionId, TempDirectoryPath, _messageSink.Object); + testableAttachmentManager.AddAttachment(dataCollectorDataMessage, handler, uri, friendlyName); + + // Wait for the attachment transfer tasks to complete + var result = testableAttachmentManager.GetAttachments(datacollectioncontext); + Assert.AreEqual(0, result[0].Attachments.Count); + } - private class TestableDataCollectionAttachmentManager : DataCollectionAttachmentManager + private class TestableDataCollectionAttachmentManager : DataCollectionAttachmentManager + { + public TestableDataCollectionAttachmentManager(IFileHelper fileHelper) + : base(fileHelper) { - public TestableDataCollectionAttachmentManager(IFileHelper fileHelper) - : base(fileHelper) - { - } } } } \ No newline at end of file diff --git a/test/datacollector.UnitTests/DataCollectionEnvironmentVariableTests.cs b/test/datacollector.UnitTests/DataCollectionEnvironmentVariableTests.cs index baece1333a..bad9abe64e 100644 --- a/test/datacollector.UnitTests/DataCollectionEnvironmentVariableTests.cs +++ b/test/datacollector.UnitTests/DataCollectionEnvironmentVariableTests.cs @@ -1,45 +1,44 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests; + +using System; +using System.Collections.Generic; + +using TestTools.UnitTesting; + +[TestClass] +public class DataCollectionEnvironmentVariableTests { - using System; - using System.Collections.Generic; + [TestMethod] + public void ConstructorShouldThrowExceptionIfKeyValueIsNull() + { + Assert.ThrowsException( + () => + { + var envvariable = new DataCollectionEnvironmentVariable(default, null); + }); + } - using Microsoft.VisualStudio.TestTools.UnitTesting; + [TestMethod] + public void FirstDataCollectorThatRequestedShouldReturnTheFirstdataCollectorRequestingThatEnvVariable() + { + var envValPair = new KeyValuePair("key", "value"); + var envvariable = new DataCollectionEnvironmentVariable(envValPair, "datacollector"); + envvariable.AddRequestingDataCollector("datacollector1"); + + Assert.AreEqual("datacollector", envvariable.FirstDataCollectorThatRequested); + } - [TestClass] - public class DataCollectionEnvironmentVariableTests + [TestMethod] + public void FirstDataCollectorThatRequestedShouldSetNameAndValue() { - [TestMethod] - public void ConstructorShouldThrowExceptionIfKeyValueIsNull() - { - Assert.ThrowsException( - () => - { - var envvariable = new DataCollectionEnvironmentVariable(default, null); - }); - } - - [TestMethod] - public void FirstDataCollectorThatRequestedShouldReturnTheFirstdataCollectorRequestingThatEnvVariable() - { - var envValPair = new KeyValuePair("key", "value"); - var envvariable = new DataCollectionEnvironmentVariable(envValPair, "datacollector"); - envvariable.AddRequestingDataCollector("datacollector1"); - - Assert.AreEqual("datacollector", envvariable.FirstDataCollectorThatRequested); - } - - [TestMethod] - public void FirstDataCollectorThatRequestedShouldSetNameAndValue() - { - var envValPair = new KeyValuePair("key", "value"); - var envvariable = new DataCollectionEnvironmentVariable(envValPair, "datacollector"); - envvariable.AddRequestingDataCollector("datacollector1"); - - Assert.AreEqual("key", envvariable.Name); - Assert.AreEqual("value", envvariable.Value); - } + var envValPair = new KeyValuePair("key", "value"); + var envvariable = new DataCollectionEnvironmentVariable(envValPair, "datacollector"); + envvariable.AddRequestingDataCollector("datacollector1"); + + Assert.AreEqual("key", envvariable.Name); + Assert.AreEqual("value", envvariable.Value); } -} +} \ No newline at end of file diff --git a/test/datacollector.UnitTests/DataCollectionManagerTests.cs b/test/datacollector.UnitTests/DataCollectionManagerTests.cs index 37ae957b66..e85ad1bede 100644 --- a/test/datacollector.UnitTests/DataCollectionManagerTests.cs +++ b/test/datacollector.UnitTests/DataCollectionManagerTests.cs @@ -1,619 +1,618 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Threading; +using System.Threading.Tasks; +using System.Xml; + +using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class DataCollectionManagerTests { - using System; - using System.Collections.Generic; - using System.IO; - using System.Reflection; - using System.Threading; - using System.Threading.Tasks; - using System.Xml; - - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - [TestClass] - public class DataCollectionManagerTests - { - private DataCollectionManager dataCollectionManager; - private string defaultRunSettings = "\r\n\r\n \r\n {0}\r\n \r\n"; - private string defaultDataCollectionSettings = ""; - private string dataCollectorSettings; - private string friendlyName; - private string uri; - private Mock mockMessageSink; - private Mock mockDataCollector; - private Mock mockCodeCoverageDataCollector; - private List> envVarList; - private List> codeCoverageEnvVarList; - private Mock mockDataCollectionAttachmentManager; - private Mock mockDataCollectionTelemetryManager; - - public DataCollectionManagerTests() - { - this.friendlyName = "CustomDataCollector"; - this.uri = "my://custom/datacollector"; - this.envVarList = new List>(); - this.codeCoverageEnvVarList = new List>(); - this.mockDataCollector = new Mock(); - this.mockDataCollector.As().Setup(x => x.GetTestExecutionEnvironmentVariables()).Returns(this.envVarList); - this.mockCodeCoverageDataCollector = new Mock(); - this.mockCodeCoverageDataCollector.As().Setup(x => x.GetTestExecutionEnvironmentVariables()).Returns(this.codeCoverageEnvVarList); - this.dataCollectorSettings = string.Format(this.defaultRunSettings, string.Format(this.defaultDataCollectionSettings, this.friendlyName, this.uri, this.mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); - this.mockMessageSink = new Mock(); - this.mockDataCollectionAttachmentManager = new Mock(); - this.mockDataCollectionAttachmentManager.SetReturnsDefault>(new List()); - this.mockDataCollectionTelemetryManager = new Mock(); - - this.dataCollectionManager = new TestableDataCollectionManager(this.mockDataCollectionAttachmentManager.Object, this.mockMessageSink.Object, this.mockDataCollector.Object, this.mockCodeCoverageDataCollector.Object, this.mockDataCollectionTelemetryManager.Object); - } + private readonly DataCollectionManager _dataCollectionManager; + private readonly string _defaultRunSettings = "\r\n\r\n \r\n {0}\r\n \r\n"; + private readonly string _defaultDataCollectionSettings = ""; + private string _dataCollectorSettings; + private readonly string _friendlyName; + private readonly string _uri; + private readonly Mock _mockMessageSink; + private readonly Mock _mockDataCollector; + private readonly Mock _mockCodeCoverageDataCollector; + private readonly List> _envVarList; + private readonly List> _codeCoverageEnvVarList; + private readonly Mock _mockDataCollectionAttachmentManager; + private readonly Mock _mockDataCollectionTelemetryManager; + + public DataCollectionManagerTests() + { + _friendlyName = "CustomDataCollector"; + _uri = "my://custom/datacollector"; + _envVarList = new List>(); + _codeCoverageEnvVarList = new List>(); + _mockDataCollector = new Mock(); + _mockDataCollector.As().Setup(x => x.GetTestExecutionEnvironmentVariables()).Returns(_envVarList); + _mockCodeCoverageDataCollector = new Mock(); + _mockCodeCoverageDataCollector.As().Setup(x => x.GetTestExecutionEnvironmentVariables()).Returns(_codeCoverageEnvVarList); + _dataCollectorSettings = string.Format(_defaultRunSettings, string.Format(_defaultDataCollectionSettings, _friendlyName, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); + _mockMessageSink = new Mock(); + _mockDataCollectionAttachmentManager = new Mock(); + _mockDataCollectionAttachmentManager.SetReturnsDefault>(new List()); + _mockDataCollectionTelemetryManager = new Mock(); + + _dataCollectionManager = new TestableDataCollectionManager(_mockDataCollectionAttachmentManager.Object, _mockMessageSink.Object, _mockDataCollector.Object, _mockCodeCoverageDataCollector.Object, _mockDataCollectionTelemetryManager.Object); + } - [TestMethod] - public void InitializeDataCollectorsShouldThrowExceptionIfSettingsXmlIsNull() + [TestMethod] + public void InitializeDataCollectorsShouldThrowExceptionIfSettingsXmlIsNull() + { + Assert.ThrowsException(() => { - Assert.ThrowsException(() => - { - this.dataCollectionManager.InitializeDataCollectors(null); - }); - } + _dataCollectionManager.InitializeDataCollectors(null); + }); + } - [TestMethod] - public void InitializeDataCollectorsShouldReturnEmptyDictionaryIfDataCollectorsAreNotConfigured() - { - var runSettings = string.Format(this.defaultRunSettings, string.Empty); - this.dataCollectionManager.InitializeDataCollectors(runSettings); + [TestMethod] + public void InitializeDataCollectorsShouldReturnEmptyDictionaryIfDataCollectorsAreNotConfigured() + { + var runSettings = string.Format(_defaultRunSettings, string.Empty); + _dataCollectionManager.InitializeDataCollectors(runSettings); - Assert.AreEqual(0, this.dataCollectionManager.RunDataCollectors.Count); - } + Assert.AreEqual(0, _dataCollectionManager.RunDataCollectors.Count); + } - [TestMethod] - public void InitializeDataCollectorsShouldLoadDataCollector() - { - var dataCollectorSettings = string.Format(this.defaultRunSettings, string.Format(this.defaultDataCollectionSettings, friendlyName, uri, this.mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); - this.dataCollectionManager.InitializeDataCollectors(dataCollectorSettings); + [TestMethod] + public void InitializeDataCollectorsShouldLoadDataCollector() + { + var dataCollectorSettings = string.Format(_defaultRunSettings, string.Format(_defaultDataCollectionSettings, _friendlyName, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); + _dataCollectionManager.InitializeDataCollectors(dataCollectorSettings); - Assert.IsTrue(this.dataCollectionManager.RunDataCollectors.ContainsKey(this.mockDataCollector.Object.GetType())); - Assert.AreEqual(typeof(AttachmentProcessorDataCollector2), this.dataCollectionManager.RunDataCollectors[this.mockDataCollector.Object.GetType()].DataCollectorConfig.AttachmentsProcessorType); - Assert.IsTrue(this.dataCollectionManager.RunDataCollectors[this.mockDataCollector.Object.GetType()].DataCollectorConfig.Metadata.Contains(true)); - this.mockDataCollector.Verify(x => x.Initialize(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); - } + Assert.IsTrue(_dataCollectionManager.RunDataCollectors.ContainsKey(_mockDataCollector.Object.GetType())); + Assert.AreEqual(typeof(AttachmentProcessorDataCollector2), _dataCollectionManager.RunDataCollectors[_mockDataCollector.Object.GetType()].DataCollectorConfig.AttachmentsProcessorType); + Assert.IsTrue(_dataCollectionManager.RunDataCollectors[_mockDataCollector.Object.GetType()].DataCollectorConfig.Metadata.Contains(true)); + _mockDataCollector.Verify(x => x.Initialize(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); + } - [TestMethod] - public void InitializeShouldNotAddDataCollectorIfItIsDisabled() - { - var dataCollectorSettingsDisabled = string.Format(this.defaultRunSettings, string.Format(this.defaultDataCollectionSettings, friendlyName, uri, this.mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, "enabled=\"false\"")); - this.dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsDisabled); + [TestMethod] + public void InitializeShouldNotAddDataCollectorIfItIsDisabled() + { + var dataCollectorSettingsDisabled = string.Format(_defaultRunSettings, string.Format(_defaultDataCollectionSettings, _friendlyName, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, "enabled=\"false\"")); + _dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsDisabled); - Assert.AreEqual(0, this.dataCollectionManager.RunDataCollectors.Count); - this.mockDataCollector.Verify(x => x.Initialize(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); - } + Assert.AreEqual(0, _dataCollectionManager.RunDataCollectors.Count); + _mockDataCollector.Verify(x => x.Initialize(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); + } - [TestMethod] - public void InitializeShouldAddDataCollectorIfItIsEnabled() - { - var dataCollectorSettingsEnabled = string.Format(this.defaultRunSettings, string.Format(this.defaultDataCollectionSettings, friendlyName, uri, this.mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, "enabled=\"true\"")); - this.dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsEnabled); + [TestMethod] + public void InitializeShouldAddDataCollectorIfItIsEnabled() + { + var dataCollectorSettingsEnabled = string.Format(_defaultRunSettings, string.Format(_defaultDataCollectionSettings, _friendlyName, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, "enabled=\"true\"")); + _dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsEnabled); - Assert.IsTrue(this.dataCollectionManager.RunDataCollectors.ContainsKey(this.mockDataCollector.Object.GetType())); - this.mockDataCollector.Verify(x => x.Initialize(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); - } + Assert.IsTrue(_dataCollectionManager.RunDataCollectors.ContainsKey(_mockDataCollector.Object.GetType())); + _mockDataCollector.Verify(x => x.Initialize(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); + } - [TestMethod] - public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsNotCorrectAndUriIsCorrect() - { - var dataCollectorSettingsWithWrongFriendlyName = string.Format(this.defaultRunSettings, string.Format(this.defaultDataCollectionSettings, "anyFriendlyName", uri, this.mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); - this.dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithWrongFriendlyName); + [TestMethod] + public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsNotCorrectAndUriIsCorrect() + { + var dataCollectorSettingsWithWrongFriendlyName = string.Format(_defaultRunSettings, string.Format(_defaultDataCollectionSettings, "anyFriendlyName", _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); + _dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithWrongFriendlyName); - Assert.AreEqual(1, this.dataCollectionManager.RunDataCollectors.Count); - this.mockDataCollector.Verify(x => x.Initialize(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); - } + Assert.AreEqual(1, _dataCollectionManager.RunDataCollectors.Count); + _mockDataCollector.Verify(x => x.Initialize(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); + } - [TestMethod] - public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsCorrectAndUriIsNotCorrect() - { - var dataCollectorSettingsWithWrongUri = string.Format(this.defaultRunSettings, string.Format(this.defaultDataCollectionSettings, friendlyName, "my://custom/WrongDatacollector", this.mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); - this.dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithWrongUri); + [TestMethod] + public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsCorrectAndUriIsNotCorrect() + { + var dataCollectorSettingsWithWrongUri = string.Format(_defaultRunSettings, string.Format(_defaultDataCollectionSettings, _friendlyName, "my://custom/WrongDatacollector", _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); + _dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithWrongUri); - Assert.AreEqual(1, this.dataCollectionManager.RunDataCollectors.Count); - this.mockDataCollector.Verify(x => x.Initialize(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); - } + Assert.AreEqual(1, _dataCollectionManager.RunDataCollectors.Count); + _mockDataCollector.Verify(x => x.Initialize(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); + } - [TestMethod] - public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsCorrectAndUriIsNull() - { - var dataCollectorSettingsWithNullUri = string.Format(this.defaultRunSettings, string.Format(this.defaultDataCollectionSettings, friendlyName, string.Empty, this.mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty).Replace("uri=\"\"", string.Empty)); - this.dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithNullUri); + [TestMethod] + public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsCorrectAndUriIsNull() + { + var dataCollectorSettingsWithNullUri = string.Format(_defaultRunSettings, string.Format(_defaultDataCollectionSettings, _friendlyName, string.Empty, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty).Replace("uri=\"\"", string.Empty)); + _dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithNullUri); - Assert.AreEqual(0, this.dataCollectionManager.RunDataCollectors.Count); - this.mockDataCollector.Verify(x => x.Initialize(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); - } + Assert.AreEqual(0, _dataCollectionManager.RunDataCollectors.Count); + _mockDataCollector.Verify(x => x.Initialize(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); + } - [TestMethod] - public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsNullAndUriIsCorrect() - { - var dataCollectorSettingsWithNullFriendlyName = string.Format(this.defaultRunSettings, string.Format(this.defaultDataCollectionSettings, string.Empty, uri, this.mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty).Replace("friendlyName=\"\"", string.Empty)); - this.dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithNullFriendlyName); + [TestMethod] + public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsNullAndUriIsCorrect() + { + var dataCollectorSettingsWithNullFriendlyName = string.Format(_defaultRunSettings, string.Format(_defaultDataCollectionSettings, string.Empty, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty).Replace("friendlyName=\"\"", string.Empty)); + _dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithNullFriendlyName); - Assert.AreEqual(1, this.dataCollectionManager.RunDataCollectors.Count); - this.mockDataCollector.Verify(x => x.Initialize(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); - } + Assert.AreEqual(1, _dataCollectionManager.RunDataCollectors.Count); + _mockDataCollector.Verify(x => x.Initialize(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); + } - [TestMethod] - public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsCorrectAndUriIsEmpty() - { - var dataCollectorSettingsWithEmptyUri = string.Format(this.defaultRunSettings, string.Format(this.defaultDataCollectionSettings, friendlyName, string.Empty, this.mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); - Assert.ThrowsException(() => this.dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithEmptyUri)); - } + [TestMethod] + public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsCorrectAndUriIsEmpty() + { + var dataCollectorSettingsWithEmptyUri = string.Format(_defaultRunSettings, string.Format(_defaultDataCollectionSettings, _friendlyName, string.Empty, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); + Assert.ThrowsException(() => _dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithEmptyUri)); + } - [TestMethod] - public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsEmptyAndUriIsCorrect() - { - var dataCollectorSettingsWithEmptyFriendlyName = string.Format(this.defaultRunSettings, string.Format(this.defaultDataCollectionSettings, friendlyName, string.Empty, this.mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); - Assert.ThrowsException(() => this.dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithEmptyFriendlyName)); - } + [TestMethod] + public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsEmptyAndUriIsCorrect() + { + var dataCollectorSettingsWithEmptyFriendlyName = string.Format(_defaultRunSettings, string.Format(_defaultDataCollectionSettings, _friendlyName, string.Empty, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); + Assert.ThrowsException(() => _dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithEmptyFriendlyName)); + } - [TestMethod] - public void InitializeDataCollectorsShouldNotLoadDataCollectorIfFriendlyNameIsNotCorrectAndUriIsNotCorrect() - { - var dataCollectorSettingsWithWrongFriendlyNameAndWrongUri = string.Format(this.defaultRunSettings, string.Format(this.defaultDataCollectionSettings, "anyFriendlyName", "datacollector://data", this.mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); - this.dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithWrongFriendlyNameAndWrongUri); + [TestMethod] + public void InitializeDataCollectorsShouldNotLoadDataCollectorIfFriendlyNameIsNotCorrectAndUriIsNotCorrect() + { + var dataCollectorSettingsWithWrongFriendlyNameAndWrongUri = string.Format(_defaultRunSettings, string.Format(_defaultDataCollectionSettings, "anyFriendlyName", "datacollector://data", _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); + _dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithWrongFriendlyNameAndWrongUri); - Assert.AreEqual(0, this.dataCollectionManager.RunDataCollectors.Count); - this.mockDataCollector.Verify(x => x.Initialize(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); - } + Assert.AreEqual(0, _dataCollectionManager.RunDataCollectors.Count); + _mockDataCollector.Verify(x => x.Initialize(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); + } - [TestMethod] - public void InitializeDataCollectorsShouldNotAddSameDataCollectorMoreThanOnce() - { - var datacollecterSettings = string.Format(this.defaultDataCollectionSettings, "CustomDataCollector", "my://custom/datacollector", this.mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, "enabled =\"true\""); - var runSettings = string.Format(this.defaultRunSettings, datacollecterSettings + datacollecterSettings); + [TestMethod] + public void InitializeDataCollectorsShouldNotAddSameDataCollectorMoreThanOnce() + { + var datacollecterSettings = string.Format(_defaultDataCollectionSettings, "CustomDataCollector", "my://custom/datacollector", _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, "enabled =\"true\""); + var runSettings = string.Format(_defaultRunSettings, datacollecterSettings + datacollecterSettings); - this.dataCollectionManager.InitializeDataCollectors(runSettings); + _dataCollectionManager.InitializeDataCollectors(runSettings); - Assert.IsTrue(this.dataCollectionManager.RunDataCollectors.ContainsKey(this.mockDataCollector.Object.GetType())); - this.mockDataCollector.Verify(x => x.Initialize(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); - } + Assert.IsTrue(_dataCollectionManager.RunDataCollectors.ContainsKey(_mockDataCollector.Object.GetType())); + _mockDataCollector.Verify(x => x.Initialize(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); + } - [TestMethod] - public void InitializeDataCollectorsShouldLoadDataCollectorAndReturnEnvironmentVariables() - { - this.envVarList.Add(new KeyValuePair("key", "value")); + [TestMethod] + public void InitializeDataCollectorsShouldLoadDataCollectorAndReturnEnvironmentVariables() + { + _envVarList.Add(new KeyValuePair("key", "value")); - var result = this.dataCollectionManager.InitializeDataCollectors(this.dataCollectorSettings); + var result = _dataCollectionManager.InitializeDataCollectors(_dataCollectorSettings); - Assert.AreEqual("value", result["key"]); + Assert.AreEqual("value", result["key"]); - this.mockDataCollectionTelemetryManager.Verify(tm => tm.RecordEnvironmentVariableAddition(It.IsAny(), "key", "value")); - } + _mockDataCollectionTelemetryManager.Verify(tm => tm.RecordEnvironmentVariableAddition(It.IsAny(), "key", "value")); + } - [TestMethod] - public void InitializeDataCollectorsShouldLogExceptionToMessageSinkIfInitializationFails() - { - this.mockDataCollector.Setup( - x => - x.Initialize( - It.IsAny(), - It.IsAny(), - It.IsAny(), - It.IsAny(), - It.IsAny())).Throws(); - - this.dataCollectionManager.InitializeDataCollectors(this.dataCollectorSettings); - - Assert.AreEqual(0, this.dataCollectionManager.RunDataCollectors.Count); - this.mockMessageSink.Verify(x => x.SendMessage(It.IsAny()), Times.Once); - } + [TestMethod] + public void InitializeDataCollectorsShouldLogExceptionToMessageSinkIfInitializationFails() + { + _mockDataCollector.Setup( + x => + x.Initialize( + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny())).Throws(); + + _dataCollectionManager.InitializeDataCollectors(_dataCollectorSettings); + + Assert.AreEqual(0, _dataCollectionManager.RunDataCollectors.Count); + _mockMessageSink.Verify(x => x.SendMessage(It.IsAny()), Times.Once); + } - [TestMethod] - public void InitializeDataCollectorsShouldLogExceptionToMessageSinkIfSetEnvironmentVariableFails() - { - this.mockDataCollector.As().Setup(x => x.GetTestExecutionEnvironmentVariables()).Throws(); + [TestMethod] + public void InitializeDataCollectorsShouldLogExceptionToMessageSinkIfSetEnvironmentVariableFails() + { + _mockDataCollector.As().Setup(x => x.GetTestExecutionEnvironmentVariables()).Throws(); - this.dataCollectionManager.InitializeDataCollectors(this.dataCollectorSettings); + _dataCollectionManager.InitializeDataCollectors(_dataCollectorSettings); - Assert.AreEqual(0, this.dataCollectionManager.RunDataCollectors.Count); - this.mockMessageSink.Verify(x => x.SendMessage(It.IsAny()), Times.Once); - } + Assert.AreEqual(0, _dataCollectionManager.RunDataCollectors.Count); + _mockMessageSink.Verify(x => x.SendMessage(It.IsAny()), Times.Once); + } - [TestMethod] - public void InitializeDataCollectorsShouldReturnFirstEnvironmentVariableIfMoreThanOneVariablesWithSameKeyIsSpecified() - { - this.envVarList.Add(new KeyValuePair("key", "value")); - this.envVarList.Add(new KeyValuePair("key", "value1")); + [TestMethod] + public void InitializeDataCollectorsShouldReturnFirstEnvironmentVariableIfMoreThanOneVariablesWithSameKeyIsSpecified() + { + _envVarList.Add(new KeyValuePair("key", "value")); + _envVarList.Add(new KeyValuePair("key", "value1")); - var result = this.dataCollectionManager.InitializeDataCollectors(this.dataCollectorSettings); + var result = _dataCollectionManager.InitializeDataCollectors(_dataCollectorSettings); - Assert.AreEqual("value", result["key"]); + Assert.AreEqual("value", result["key"]); - this.mockDataCollectionTelemetryManager.Verify(tm => tm.RecordEnvironmentVariableAddition(It.IsAny(), "key", "value")); - this.mockDataCollectionTelemetryManager.Verify(tm => tm.RecordEnvironmentVariableConflict(It.IsAny(), "key", "value1", "value")); - } + _mockDataCollectionTelemetryManager.Verify(tm => tm.RecordEnvironmentVariableAddition(It.IsAny(), "key", "value")); + _mockDataCollectionTelemetryManager.Verify(tm => tm.RecordEnvironmentVariableConflict(It.IsAny(), "key", "value1", "value")); + } - [TestMethod] - public void InitializeDataCollectorsShouldReturnOtherThanCodeCoverageEnvironmentVariableIfMoreThanOneVariablesWithSameKeyIsSpecified() - { - this.envVarList.Add(new KeyValuePair("cor_profiler", "clrie")); - this.envVarList.Add(new KeyValuePair("same_key", "same_value")); - this.codeCoverageEnvVarList.Add(new KeyValuePair("cor_profiler", "direct")); - this.codeCoverageEnvVarList.Add(new KeyValuePair("clrie_profiler_vanguard", "path")); - this.codeCoverageEnvVarList.Add(new KeyValuePair("same_key", "same_value")); - - this.dataCollectorSettings = string.Format(this.defaultRunSettings, - string.Format(this.defaultDataCollectionSettings, "Code Coverage", "my://custom/ccdatacollector", this.mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty) + - string.Format(this.defaultDataCollectionSettings, this.friendlyName, this.uri, this.mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); - - var result = this.dataCollectionManager.InitializeDataCollectors(this.dataCollectorSettings); - - Assert.AreEqual(3, result.Count); - Assert.AreEqual("clrie", result["cor_profiler"]); - Assert.AreEqual("path", result["clrie_profiler_vanguard"]); - Assert.AreEqual("same_value", result["same_key"]); - - this.mockDataCollectionTelemetryManager.Verify(tm => tm.RecordEnvironmentVariableAddition(It.Is(i => i.DataCollectorConfig.FriendlyName == this.friendlyName), "cor_profiler", "clrie")); - this.mockDataCollectionTelemetryManager.Verify(tm => tm.RecordEnvironmentVariableConflict(It.Is(i => i.DataCollectorConfig.FriendlyName == "Code Coverage"), "cor_profiler", "direct", "clrie")); - this.mockDataCollectionTelemetryManager.Verify(tm => tm.RecordEnvironmentVariableAddition(It.Is(i => i.DataCollectorConfig.FriendlyName == "Code Coverage"), "clrie_profiler_vanguard", "path")); - this.mockDataCollectionTelemetryManager.Verify(tm => tm.RecordEnvironmentVariableAddition(It.Is(i => i.DataCollectorConfig.FriendlyName == this.friendlyName), "same_key", "same_value")); - this.mockDataCollectionTelemetryManager.Verify(tm => tm.RecordEnvironmentVariableConflict(It.Is(i => i.DataCollectorConfig.FriendlyName == "Code Coverage"), "same_key", "same_value", "same_value")); - } + [TestMethod] + public void InitializeDataCollectorsShouldReturnOtherThanCodeCoverageEnvironmentVariableIfMoreThanOneVariablesWithSameKeyIsSpecified() + { + _envVarList.Add(new KeyValuePair("cor_profiler", "clrie")); + _envVarList.Add(new KeyValuePair("same_key", "same_value")); + _codeCoverageEnvVarList.Add(new KeyValuePair("cor_profiler", "direct")); + _codeCoverageEnvVarList.Add(new KeyValuePair("clrie_profiler_vanguard", "path")); + _codeCoverageEnvVarList.Add(new KeyValuePair("same_key", "same_value")); + + _dataCollectorSettings = string.Format(_defaultRunSettings, + string.Format(_defaultDataCollectionSettings, "Code Coverage", "my://custom/ccdatacollector", _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty) + + string.Format(_defaultDataCollectionSettings, _friendlyName, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); + + var result = _dataCollectionManager.InitializeDataCollectors(_dataCollectorSettings); + + Assert.AreEqual(3, result.Count); + Assert.AreEqual("clrie", result["cor_profiler"]); + Assert.AreEqual("path", result["clrie_profiler_vanguard"]); + Assert.AreEqual("same_value", result["same_key"]); + + _mockDataCollectionTelemetryManager.Verify(tm => tm.RecordEnvironmentVariableAddition(It.Is(i => i.DataCollectorConfig.FriendlyName == _friendlyName), "cor_profiler", "clrie")); + _mockDataCollectionTelemetryManager.Verify(tm => tm.RecordEnvironmentVariableConflict(It.Is(i => i.DataCollectorConfig.FriendlyName == "Code Coverage"), "cor_profiler", "direct", "clrie")); + _mockDataCollectionTelemetryManager.Verify(tm => tm.RecordEnvironmentVariableAddition(It.Is(i => i.DataCollectorConfig.FriendlyName == "Code Coverage"), "clrie_profiler_vanguard", "path")); + _mockDataCollectionTelemetryManager.Verify(tm => tm.RecordEnvironmentVariableAddition(It.Is(i => i.DataCollectorConfig.FriendlyName == _friendlyName), "same_key", "same_value")); + _mockDataCollectionTelemetryManager.Verify(tm => tm.RecordEnvironmentVariableConflict(It.Is(i => i.DataCollectorConfig.FriendlyName == "Code Coverage"), "same_key", "same_value", "same_value")); + } - [TestMethod] - public void SessionStartedShouldReturnFalseIfDataCollectionIsNotConfiguredInRunSettings() - { - var runSettings = string.Format(this.defaultRunSettings, string.Empty); - this.dataCollectionManager.InitializeDataCollectors(runSettings); + [TestMethod] + public void SessionStartedShouldReturnFalseIfDataCollectionIsNotConfiguredInRunSettings() + { + var runSettings = string.Format(_defaultRunSettings, string.Empty); + _dataCollectionManager.InitializeDataCollectors(runSettings); - var sessionStartEventArgs = new SessionStartEventArgs(); - var result = this.dataCollectionManager.SessionStarted(sessionStartEventArgs); + var sessionStartEventArgs = new SessionStartEventArgs(); + var result = _dataCollectionManager.SessionStarted(sessionStartEventArgs); - Assert.IsFalse(result); - } + Assert.IsFalse(result); + } - [TestMethod] - public void SessionStartedShouldSendEventToDataCollector() + [TestMethod] + public void SessionStartedShouldSendEventToDataCollector() + { + var isStartInvoked = false; + SetupMockDataCollector((XmlElement a, DataCollectionEvents b, DataCollectionSink c, DataCollectionLogger d, DataCollectionEnvironmentContext e) => { - var isStartInvoked = false; - this.SetupMockDataCollector((XmlElement a, DataCollectionEvents b, DataCollectionSink c, DataCollectionLogger d, DataCollectionEnvironmentContext e) => - { - b.SessionStart += (sender, eventArgs) => isStartInvoked = true; - }); + b.SessionStart += (sender, eventArgs) => isStartInvoked = true; + }); - this.dataCollectionManager.InitializeDataCollectors(this.dataCollectorSettings); + _dataCollectionManager.InitializeDataCollectors(_dataCollectorSettings); - var sessionStartEventArgs = new SessionStartEventArgs(); - var areTestCaseEventsSubscribed = this.dataCollectionManager.SessionStarted(sessionStartEventArgs); + var sessionStartEventArgs = new SessionStartEventArgs(); + var areTestCaseEventsSubscribed = _dataCollectionManager.SessionStarted(sessionStartEventArgs); - Assert.IsTrue(isStartInvoked); - Assert.IsFalse(areTestCaseEventsSubscribed); - } + Assert.IsTrue(isStartInvoked); + Assert.IsFalse(areTestCaseEventsSubscribed); + } - [TestMethod] - public void SessionStartedShouldReturnTrueIfTestCaseStartIsSubscribed() + [TestMethod] + public void SessionStartedShouldReturnTrueIfTestCaseStartIsSubscribed() + { + SetupMockDataCollector((XmlElement a, DataCollectionEvents b, DataCollectionSink c, DataCollectionLogger d, DataCollectionEnvironmentContext e) => { - this.SetupMockDataCollector((XmlElement a, DataCollectionEvents b, DataCollectionSink c, DataCollectionLogger d, DataCollectionEnvironmentContext e) => - { - b.TestCaseStart += (sender, eventArgs) => { }; - }); + b.TestCaseStart += (sender, eventArgs) => { }; + }); - this.dataCollectionManager.InitializeDataCollectors(this.dataCollectorSettings); + _dataCollectionManager.InitializeDataCollectors(_dataCollectorSettings); - var sessionStartEventArgs = new SessionStartEventArgs(); - var areTestCaseEventsSubscribed = this.dataCollectionManager.SessionStarted(sessionStartEventArgs); + var sessionStartEventArgs = new SessionStartEventArgs(); + var areTestCaseEventsSubscribed = _dataCollectionManager.SessionStarted(sessionStartEventArgs); - Assert.IsTrue(areTestCaseEventsSubscribed); - } + Assert.IsTrue(areTestCaseEventsSubscribed); + } - [TestMethod] - public void SessionStaretedShouldContinueDataCollectionIfExceptionIsThrownWhileSendingEventsToDataCollector() + [TestMethod] + public void SessionStaretedShouldContinueDataCollectionIfExceptionIsThrownWhileSendingEventsToDataCollector() + { + SetupMockDataCollector((XmlElement a, DataCollectionEvents b, DataCollectionSink c, DataCollectionLogger d, DataCollectionEnvironmentContext e) => { - this.SetupMockDataCollector((XmlElement a, DataCollectionEvents b, DataCollectionSink c, DataCollectionLogger d, DataCollectionEnvironmentContext e) => - { - b.SessionStart += (sender, eventArgs) => throw new Exception(); - }); + b.SessionStart += (sender, eventArgs) => throw new Exception(); + }); - this.dataCollectionManager.InitializeDataCollectors(this.dataCollectorSettings); + _dataCollectionManager.InitializeDataCollectors(_dataCollectorSettings); - var sessionStartEventArgs = new SessionStartEventArgs(); - var result = this.dataCollectionManager.SessionStarted(sessionStartEventArgs); + var sessionStartEventArgs = new SessionStartEventArgs(); + var result = _dataCollectionManager.SessionStarted(sessionStartEventArgs); - Assert.IsFalse(result); - } + Assert.IsFalse(result); + } - [TestMethod] - public void SessionStartedShouldReturnFalseIfDataCollectorsAreNotInitialized() - { - var sessionStartEventArgs = new SessionStartEventArgs(); - var result = this.dataCollectionManager.SessionStarted(sessionStartEventArgs); + [TestMethod] + public void SessionStartedShouldReturnFalseIfDataCollectorsAreNotInitialized() + { + var sessionStartEventArgs = new SessionStartEventArgs(); + var result = _dataCollectionManager.SessionStarted(sessionStartEventArgs); - Assert.IsFalse(result); - } + Assert.IsFalse(result); + } - [TestMethod] - public void SessionStartedShouldHaveCorrectSessionContext() - { - this.dataCollectionManager.InitializeDataCollectors(this.dataCollectorSettings); + [TestMethod] + public void SessionStartedShouldHaveCorrectSessionContext() + { + _dataCollectionManager.InitializeDataCollectors(_dataCollectorSettings); - var sessionStartEventArgs = new SessionStartEventArgs(); + var sessionStartEventArgs = new SessionStartEventArgs(); - Assert.AreEqual(new SessionId(Guid.Empty), sessionStartEventArgs.Context.SessionId); + Assert.AreEqual(new SessionId(Guid.Empty), sessionStartEventArgs.Context.SessionId); - this.dataCollectionManager.SessionStarted(sessionStartEventArgs); + _dataCollectionManager.SessionStarted(sessionStartEventArgs); - Assert.AreNotEqual(new SessionId(Guid.Empty), sessionStartEventArgs.Context.SessionId); - } + Assert.AreNotEqual(new SessionId(Guid.Empty), sessionStartEventArgs.Context.SessionId); + } - [TestMethod] - public void SessionEndedShouldReturnEmptyCollectionIfDataCollectionIsNotEnabled() - { - var runSettings = string.Format(this.defaultRunSettings, string.Empty); - this.dataCollectionManager.InitializeDataCollectors(runSettings); + [TestMethod] + public void SessionEndedShouldReturnEmptyCollectionIfDataCollectionIsNotEnabled() + { + var runSettings = string.Format(_defaultRunSettings, string.Empty); + _dataCollectionManager.InitializeDataCollectors(runSettings); - var result = this.dataCollectionManager.SessionEnded(); + var result = _dataCollectionManager.SessionEnded(); - Assert.AreEqual(0, result.Count); - } + Assert.AreEqual(0, result.Count); + } - [TestMethod] - public void GetInvokedDataCollectorsShouldReturnDataCollector() - { - var dataCollectorSettingsWithNullFriendlyName = string.Format(this.defaultRunSettings, string.Format(this.defaultDataCollectionSettings, string.Empty, uri, this.mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty).Replace("friendlyName=\"\"", string.Empty)); - this.dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithNullFriendlyName); - var invokedDataCollector = this.dataCollectionManager.GetInvokedDataCollectors(); - Assert.AreEqual(1, invokedDataCollector.Count); - Assert.IsTrue(invokedDataCollector[0].HasAttachmentProcessor); - } + [TestMethod] + public void GetInvokedDataCollectorsShouldReturnDataCollector() + { + var dataCollectorSettingsWithNullFriendlyName = string.Format(_defaultRunSettings, string.Format(_defaultDataCollectionSettings, string.Empty, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty).Replace("friendlyName=\"\"", string.Empty)); + _dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithNullFriendlyName); + var invokedDataCollector = _dataCollectionManager.GetInvokedDataCollectors(); + Assert.AreEqual(1, invokedDataCollector.Count); + Assert.IsTrue(invokedDataCollector[0].HasAttachmentProcessor); + } - [TestMethod] - public void SessionEndedShouldReturnAttachments() - { - var attachment = new AttachmentSet(new Uri("my://custom/datacollector"), "CustomDataCollector"); - attachment.Attachments.Add(new UriDataAttachment(new Uri("my://filename.txt"), "filename.txt")); + [TestMethod] + public void SessionEndedShouldReturnAttachments() + { + var attachment = new AttachmentSet(new Uri("my://custom/datacollector"), "CustomDataCollector"); + attachment.Attachments.Add(new UriDataAttachment(new Uri("my://filename.txt"), "filename.txt")); - this.mockDataCollectionAttachmentManager.Setup(x => x.GetAttachments(It.IsAny())).Returns(new List() { attachment }); + _mockDataCollectionAttachmentManager.Setup(x => x.GetAttachments(It.IsAny())).Returns(new List() { attachment }); - this.dataCollectionManager.InitializeDataCollectors(this.dataCollectorSettings); - var sessionStartEventArgs = new SessionStartEventArgs(); - this.dataCollectionManager.SessionStarted(sessionStartEventArgs); + _dataCollectionManager.InitializeDataCollectors(_dataCollectorSettings); + var sessionStartEventArgs = new SessionStartEventArgs(); + _dataCollectionManager.SessionStarted(sessionStartEventArgs); - var result = this.dataCollectionManager.SessionEnded(); + var result = _dataCollectionManager.SessionEnded(); - Assert.IsTrue(result[0].Attachments[0].Uri.ToString().Contains("filename.txt")); - } + Assert.IsTrue(result[0].Attachments[0].Uri.ToString().Contains("filename.txt")); + } - [TestMethod] - public void SessionEndedShouldNotReturnAttachmentsIfExceptionIsThrownWhileGettingAttachments() - { - this.mockDataCollectionAttachmentManager.Setup(x => x.GetAttachments(It.IsAny())).Throws(); - this.dataCollectionManager.InitializeDataCollectors(this.dataCollectorSettings); + [TestMethod] + public void SessionEndedShouldNotReturnAttachmentsIfExceptionIsThrownWhileGettingAttachments() + { + _mockDataCollectionAttachmentManager.Setup(x => x.GetAttachments(It.IsAny())).Throws(); + _dataCollectionManager.InitializeDataCollectors(_dataCollectorSettings); - var result = this.dataCollectionManager.SessionEnded(); + var result = _dataCollectionManager.SessionEnded(); - Assert.AreEqual(0, result.Count); - } + Assert.AreEqual(0, result.Count); + } - [TestMethod] - public void SessionEndedShouldContinueDataCollectionIfExceptionIsThrownWhileSendingSessionEndEventToDataCollector() - { - var attachment = new AttachmentSet(new Uri("my://custom/datacollector"), "CustomDataCollector"); - attachment.Attachments.Add(new UriDataAttachment(new Uri("my://filename.txt"), "filename.txt")); + [TestMethod] + public void SessionEndedShouldContinueDataCollectionIfExceptionIsThrownWhileSendingSessionEndEventToDataCollector() + { + var attachment = new AttachmentSet(new Uri("my://custom/datacollector"), "CustomDataCollector"); + attachment.Attachments.Add(new UriDataAttachment(new Uri("my://filename.txt"), "filename.txt")); - this.mockDataCollectionAttachmentManager.Setup(x => x.GetAttachments(It.IsAny())).Returns(new List() { attachment }); + _mockDataCollectionAttachmentManager.Setup(x => x.GetAttachments(It.IsAny())).Returns(new List() { attachment }); - this.SetupMockDataCollector((XmlElement a, DataCollectionEvents b, DataCollectionSink c, DataCollectionLogger d, DataCollectionEnvironmentContext e) => + SetupMockDataCollector((XmlElement a, DataCollectionEvents b, DataCollectionSink c, DataCollectionLogger d, DataCollectionEnvironmentContext e) => + { + b.SessionEnd += (sender, ev) => { - b.SessionEnd += (sender, ev) => - { - c.SendFileAsync(e.SessionDataCollectionContext, "filename.txt", true); - throw new Exception(); - }; - }); + c.SendFileAsync(e.SessionDataCollectionContext, "filename.txt", true); + throw new Exception(); + }; + }); - this.dataCollectionManager.InitializeDataCollectors(this.dataCollectorSettings); - var sessionStartEventArgs = new SessionStartEventArgs(); - this.dataCollectionManager.SessionStarted(sessionStartEventArgs); + _dataCollectionManager.InitializeDataCollectors(_dataCollectorSettings); + var sessionStartEventArgs = new SessionStartEventArgs(); + _dataCollectionManager.SessionStarted(sessionStartEventArgs); - var result = this.dataCollectionManager.SessionEnded(); + var result = _dataCollectionManager.SessionEnded(); - Assert.AreEqual(1, result.Count); - } + Assert.AreEqual(1, result.Count); + } - [TestMethod] - public void SessionEndedShouldCancelProcessingAttachmentRequestsIfSessionIsCancelled() - { - this.dataCollectionManager.InitializeDataCollectors(this.dataCollectorSettings); - var sessionStartEventArgs = new SessionStartEventArgs(); - this.dataCollectionManager.SessionStarted(sessionStartEventArgs); + [TestMethod] + public void SessionEndedShouldCancelProcessingAttachmentRequestsIfSessionIsCancelled() + { + _dataCollectionManager.InitializeDataCollectors(_dataCollectorSettings); + var sessionStartEventArgs = new SessionStartEventArgs(); + _dataCollectionManager.SessionStarted(sessionStartEventArgs); - var result = this.dataCollectionManager.SessionEnded(true); + var result = _dataCollectionManager.SessionEnded(true); - this.mockDataCollectionAttachmentManager.Verify(x => x.Cancel(), Times.Once); - } + _mockDataCollectionAttachmentManager.Verify(x => x.Cancel(), Times.Once); + } - #region TestCaseEventsTest + #region TestCaseEventsTest - [TestMethod] - public void TestCaseStartedShouldSendEventToDataCollector() - { - var isStartInvoked = false; - this.SetupMockDataCollector((XmlElement a, DataCollectionEvents b, DataCollectionSink c, DataCollectionLogger d, DataCollectionEnvironmentContext e) => { b.TestCaseStart += (sender, eventArgs) => isStartInvoked = true; }); + [TestMethod] + public void TestCaseStartedShouldSendEventToDataCollector() + { + var isStartInvoked = false; + SetupMockDataCollector((XmlElement a, DataCollectionEvents b, DataCollectionSink c, DataCollectionLogger d, DataCollectionEnvironmentContext e) => { b.TestCaseStart += (sender, eventArgs) => isStartInvoked = true; }); - this.dataCollectionManager.InitializeDataCollectors(this.dataCollectorSettings); - var args = new TestCaseStartEventArgs(new TestCase()); - this.dataCollectionManager.TestCaseStarted(args); + _dataCollectionManager.InitializeDataCollectors(_dataCollectorSettings); + var args = new TestCaseStartEventArgs(new TestCase()); + _dataCollectionManager.TestCaseStarted(args); - Assert.IsTrue(isStartInvoked); - } + Assert.IsTrue(isStartInvoked); + } - [TestMethod] - public void TestCaseStartedShouldNotSendEventToDataCollectorIfDataColletionIsNotEnbled() - { - var isStartInvoked = false; - this.SetupMockDataCollector((XmlElement a, DataCollectionEvents b, DataCollectionSink c, DataCollectionLogger d, DataCollectionEnvironmentContext e) => { b.TestCaseStart += (sender, eventArgs) => isStartInvoked = true; }); + [TestMethod] + public void TestCaseStartedShouldNotSendEventToDataCollectorIfDataColletionIsNotEnbled() + { + var isStartInvoked = false; + SetupMockDataCollector((XmlElement a, DataCollectionEvents b, DataCollectionSink c, DataCollectionLogger d, DataCollectionEnvironmentContext e) => { b.TestCaseStart += (sender, eventArgs) => isStartInvoked = true; }); - var args = new TestCaseStartEventArgs(new TestCase()); - this.dataCollectionManager.TestCaseStarted(args); + var args = new TestCaseStartEventArgs(new TestCase()); + _dataCollectionManager.TestCaseStarted(args); - Assert.IsFalse(isStartInvoked); - } + Assert.IsFalse(isStartInvoked); + } - [TestMethod] - public void TestCaseEndedShouldSendEventToDataCollector() - { - var isEndInvoked = false; - this.SetupMockDataCollector((XmlElement a, DataCollectionEvents b, DataCollectionSink c, DataCollectionLogger d, DataCollectionEnvironmentContext e) => { b.TestCaseEnd += (sender, eventArgs) => isEndInvoked = true; }); + [TestMethod] + public void TestCaseEndedShouldSendEventToDataCollector() + { + var isEndInvoked = false; + SetupMockDataCollector((XmlElement a, DataCollectionEvents b, DataCollectionSink c, DataCollectionLogger d, DataCollectionEnvironmentContext e) => { b.TestCaseEnd += (sender, eventArgs) => isEndInvoked = true; }); - this.dataCollectionManager.InitializeDataCollectors(this.dataCollectorSettings); - var args = new TestCaseEndEventArgs(); - args.TestElement = new TestCase(); - this.dataCollectionManager.TestCaseEnded(args); + _dataCollectionManager.InitializeDataCollectors(_dataCollectorSettings); + var args = new TestCaseEndEventArgs(); + args.TestElement = new TestCase(); + _dataCollectionManager.TestCaseEnded(args); - Assert.IsTrue(isEndInvoked); - } + Assert.IsTrue(isEndInvoked); + } - [TestMethod] - public void TestCaseEndedShouldNotSendEventToDataCollectorIfDataColletionIsNotEnbled() + [TestMethod] + public void TestCaseEndedShouldNotSendEventToDataCollectorIfDataColletionIsNotEnbled() + { + var isEndInvoked = false; + var runSettings = string.Format(_defaultRunSettings, _dataCollectorSettings); + SetupMockDataCollector((XmlElement a, DataCollectionEvents b, DataCollectionSink c, DataCollectionLogger d, DataCollectionEnvironmentContext e) => { - var isEndInvoked = false; - var runSettings = string.Format(this.defaultRunSettings, this.dataCollectorSettings); - this.SetupMockDataCollector((XmlElement a, DataCollectionEvents b, DataCollectionSink c, DataCollectionLogger d, DataCollectionEnvironmentContext e) => - { - b.TestCaseEnd += (sender, eventArgs) => isEndInvoked = true; - }); + b.TestCaseEnd += (sender, eventArgs) => isEndInvoked = true; + }); - var args = new TestCaseEndEventArgs(); - Assert.IsFalse(isEndInvoked); - } + var args = new TestCaseEndEventArgs(); + Assert.IsFalse(isEndInvoked); + } - private void SetupMockDataCollector(Action callback) - { - this.mockDataCollector.Setup( - x => - x.Initialize( - It.IsAny(), - It.IsAny(), - It.IsAny(), - It.IsAny(), - It.IsAny())).Callback((a, b, c, d, e) => - { - callback.Invoke(a, b, c, d, e); - }); - } + private void SetupMockDataCollector(Action callback) + { + _mockDataCollector.Setup( + x => + x.Initialize( + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny())).Callback((a, b, c, d, e) => + { + callback.Invoke(a, b, c, d, e); + }); + } - #endregion + #endregion +} + +internal class TestableDataCollectionManager : DataCollectionManager +{ + private readonly DataCollector _dataCollector; + private readonly DataCollector _ccDataCollector; + + public TestableDataCollectionManager(IDataCollectionAttachmentManager datacollectionAttachmentManager, IMessageSink messageSink, DataCollector dataCollector, DataCollector ccDataCollector, IDataCollectionTelemetryManager dataCollectionTelemetryManager) : this(datacollectionAttachmentManager, messageSink, dataCollectionTelemetryManager) + { + _dataCollector = dataCollector; + _ccDataCollector = ccDataCollector; } - internal class TestableDataCollectionManager : DataCollectionManager + internal TestableDataCollectionManager(IDataCollectionAttachmentManager datacollectionAttachmentManager, IMessageSink messageSink, IDataCollectionTelemetryManager dataCollectionTelemetryManager) : base(datacollectionAttachmentManager, messageSink, dataCollectionTelemetryManager) { - DataCollector dataCollector; - DataCollector ccDataCollector; + } - public TestableDataCollectionManager(IDataCollectionAttachmentManager datacollectionAttachmentManager, IMessageSink messageSink, DataCollector dataCollector, DataCollector ccDataCollector, IDataCollectionTelemetryManager dataCollectionTelemetryManager) : this(datacollectionAttachmentManager, messageSink, dataCollectionTelemetryManager) + protected override bool TryGetUriFromFriendlyName(string friendlyName, out string dataCollectorUri) + { + if (friendlyName.Equals("CustomDataCollector")) { - this.dataCollector = dataCollector; - this.ccDataCollector = ccDataCollector; + dataCollectorUri = "my://custom/datacollector"; + return true; } - - internal TestableDataCollectionManager(IDataCollectionAttachmentManager datacollectionAttachmentManager, IMessageSink messageSink, IDataCollectionTelemetryManager dataCollectionTelemetryManager) : base(datacollectionAttachmentManager, messageSink, dataCollectionTelemetryManager) + else if (friendlyName.Equals("Code Coverage")) + { + dataCollectorUri = "my://custom/ccdatacollector"; + return true; + } + else { + dataCollectorUri = string.Empty; + return false; } + } - protected override bool TryGetUriFromFriendlyName(string friendlyName, out string dataCollectorUri) + protected override bool IsUriValid(string uri) + { + if (uri.Equals("my://custom/datacollector") || uri.Equals("my://custom/ccdatacollector")) { - if (friendlyName.Equals("CustomDataCollector")) - { - dataCollectorUri = "my://custom/datacollector"; - return true; - } - else if (friendlyName.Equals("Code Coverage")) - { - dataCollectorUri = "my://custom/ccdatacollector"; - return true; - } - else - { - dataCollectorUri = string.Empty; - return false; - } + return true; } + else + { + return false; + } + } - protected override bool IsUriValid(string uri) + protected override DataCollector TryGetTestExtension(string extensionUri) + { + if (extensionUri.Equals("my://custom/datacollector")) { - if (uri.Equals("my://custom/datacollector") || uri.Equals("my://custom/ccdatacollector")) - { - return true; - } - else - { - return false; - } + return _dataCollector; } - protected override DataCollector TryGetTestExtension(string extensionUri) + if (extensionUri.Equals("my://custom/ccdatacollector")) { - if (extensionUri.Equals("my://custom/datacollector")) - { - return dataCollector; - } + return _ccDataCollector; + } - if (extensionUri.Equals("my://custom/ccdatacollector")) - { - return ccDataCollector; - } + return null; + } - return null; + protected override DataCollectorConfig TryGetDataCollectorConfig(string extensionUri) + { + if (extensionUri.Equals("my://custom/datacollector")) + { + var dc = new DataCollectorConfig(_dataCollector.GetType()); + dc.FilePath = Path.GetTempFileName(); + return dc; } - protected override DataCollectorConfig TryGetDataCollectorConfig(string extensionUri) + if (extensionUri.Equals("my://custom/ccdatacollector")) { - if (extensionUri.Equals("my://custom/datacollector")) - { - var dc = new DataCollectorConfig(dataCollector.GetType()); - dc.FilePath = Path.GetTempFileName(); - return dc; - } - - if (extensionUri.Equals("my://custom/ccdatacollector")) - { - var dc = new DataCollectorConfig(ccDataCollector.GetType()); - dc.FilePath = Path.GetTempFileName(); - return dc; - } - - return null; + var dc = new DataCollectorConfig(_ccDataCollector.GetType()); + dc.FilePath = Path.GetTempFileName(); + return dc; } - } - [DataCollectorFriendlyName("CustomDataCollector")] - [DataCollectorTypeUri("my://custom/datacollector")] - [DataCollectorAttachmentProcessor(typeof(AttachmentProcessorDataCollector2))] - public abstract class DataCollector2 : DataCollector - { + return null; } +} + +[DataCollectorFriendlyName("CustomDataCollector")] +[DataCollectorTypeUri("my://custom/datacollector")] +[DataCollectorAttachmentProcessor(typeof(AttachmentProcessorDataCollector2))] +public abstract class DataCollector2 : DataCollector +{ +} + +[DataCollectorFriendlyName("Code Coverage")] +[DataCollectorTypeUri("my://custom/ccdatacollector")] +public abstract class CodeCoverageDataCollector : DataCollector +{ +} + +public class AttachmentProcessorDataCollector2 : IDataCollectorAttachmentProcessor +{ + public bool SupportsIncrementalProcessing => throw new NotImplementedException(); - [DataCollectorFriendlyName("Code Coverage")] - [DataCollectorTypeUri("my://custom/ccdatacollector")] - public abstract class CodeCoverageDataCollector : DataCollector + public IEnumerable GetExtensionUris() { + throw new NotImplementedException(); } - public class AttachmentProcessorDataCollector2 : IDataCollectorAttachmentProcessor + public Task> ProcessAttachmentSetsAsync(XmlElement configurationElement, ICollection attachments, IProgress progressReporter, IMessageLogger logger, CancellationToken cancellationToken) { - public bool SupportsIncrementalProcessing => throw new NotImplementedException(); - - public IEnumerable GetExtensionUris() - { - throw new NotImplementedException(); - } - - public Task> ProcessAttachmentSetsAsync(XmlElement configurationElement, ICollection attachments, IProgress progressReporter, IMessageLogger logger, CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } } diff --git a/test/datacollector.UnitTests/DataCollectionTelemetryManagerTests.cs b/test/datacollector.UnitTests/DataCollectionTelemetryManagerTests.cs index a0fbdb3bd2..010e4e2178 100644 --- a/test/datacollector.UnitTests/DataCollectionTelemetryManagerTests.cs +++ b/test/datacollector.UnitTests/DataCollectionTelemetryManagerTests.cs @@ -1,228 +1,232 @@ -using Microsoft.VisualStudio.TestPlatform.Common.DataCollector; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.VisualStudio.TestPlatform.Common.DataCollector; using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Moq; + using System; using System.Collections.Generic; -namespace Microsoft.VisualStudio.TestPlatform.DataCollector.UnitTests +namespace Microsoft.VisualStudio.TestPlatform.DataCollector.UnitTests; + +[TestClass] +public class DataCollectionTelemetryManagerTests { - [TestClass] - public class DataCollectionTelemetryManagerTests + private readonly Mock _mockRequestData; + private readonly Mock _mockMetricsCollection; + private readonly DataCollectionTelemetryManager _telemetryManager; + private readonly DataCollectorInformation _dataCollectorInformation; + + public DataCollectionTelemetryManagerTests() { - private readonly Mock mockRequestData; - private readonly Mock mockMetricsCollection; - private readonly DataCollectionTelemetryManager telemetryManager; - private readonly DataCollectorInformation dataCollectorInformation; + _mockRequestData = new Mock(); + _mockMetricsCollection = new Mock(); + _mockRequestData.Setup(m => m.MetricsCollection).Returns(_mockMetricsCollection.Object); - public DataCollectionTelemetryManagerTests() - { - this.mockRequestData = new Mock(); - this.mockMetricsCollection = new Mock(); - this.mockRequestData.Setup(m => m.MetricsCollection).Returns(this.mockMetricsCollection.Object); - - var dataCollectorMock = new Mock(); - var evnVariablesMock = dataCollectorMock.As(); - evnVariablesMock.Setup(a => a.GetTestExecutionEnvironmentVariables()).Returns(new KeyValuePair[] - { - new KeyValuePair("MicrosoftInstrumentationEngine_ConfigPath32_VanguardInstrumentationProfiler", "path1"), - new KeyValuePair("MicrosoftInstrumentationEngine_ConfigPath64_VanguardInstrumentationProfiler", "path2") - }); - - this.dataCollectorInformation = new DataCollectorInformation( - dataCollectorMock.Object, - null, - new DataCollectorConfig(typeof(CustomDataCollector)), - null, - new Mock().Object, - new TestPlatformDataCollectionEvents(), - new Mock().Object, - string.Empty); - - this.telemetryManager = new DataCollectionTelemetryManager(this.mockRequestData.Object); - } - - [TestMethod] - public void RecordEnvironmentVariableAddition_ShouldDoNothing_IfNotProfilerVariable() + var dataCollectorMock = new Mock(); + var evnVariablesMock = dataCollectorMock.As(); + evnVariablesMock.Setup(a => a.GetTestExecutionEnvironmentVariables()).Returns(new KeyValuePair[] { - // act - this.telemetryManager.RecordEnvironmentVariableAddition(this.dataCollectorInformation, "key", "value"); + new KeyValuePair("MicrosoftInstrumentationEngine_ConfigPath32_VanguardInstrumentationProfiler", "path1"), + new KeyValuePair("MicrosoftInstrumentationEngine_ConfigPath64_VanguardInstrumentationProfiler", "path2") + }); + + _dataCollectorInformation = new DataCollectorInformation( + dataCollectorMock.Object, + null, + new DataCollectorConfig(typeof(CustomDataCollector)), + null, + new Mock().Object, + new TestPlatformDataCollectionEvents(), + new Mock().Object, + string.Empty); + + _telemetryManager = new DataCollectionTelemetryManager(_mockRequestData.Object); + } - // assert - this.mockMetricsCollection.Verify(c => c.Add(It.IsAny(), It.IsAny()), Times.Never); - } + [TestMethod] + public void RecordEnvironmentVariableAddition_ShouldDoNothing_IfNotProfilerVariable() + { + // act + _telemetryManager.RecordEnvironmentVariableAddition(_dataCollectorInformation, "key", "value"); - [TestMethod] - public void RecordEnvironmentVariableConflict_ShouldDoNothing_IfNotProfilerVariable_ValuesSame() - { - // act - this.telemetryManager.RecordEnvironmentVariableConflict(this.dataCollectorInformation, "key", "value", "value"); + // assert + _mockMetricsCollection.Verify(c => c.Add(It.IsAny(), It.IsAny()), Times.Never); + } - // assert - this.mockMetricsCollection.Verify(c => c.Add(It.IsAny(), It.IsAny()), Times.Never); - } + [TestMethod] + public void RecordEnvironmentVariableConflict_ShouldDoNothing_IfNotProfilerVariable_ValuesSame() + { + // act + _telemetryManager.RecordEnvironmentVariableConflict(_dataCollectorInformation, "key", "value", "value"); - [TestMethod] - public void RecordEnvironmentVariableConflict_ShouldDoNothing_IfNotProfilerVariable_ValuesDifferent() - { - // act - this.telemetryManager.RecordEnvironmentVariableConflict(this.dataCollectorInformation, "key", "value", "othervalue"); - - // assert - this.mockMetricsCollection.Verify(c => c.Add(It.IsAny(), It.IsAny()), Times.Never); - } - - [TestMethod] - [DataRow("{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] - [DataRow("{324F817A-7420-4E6D-B3C1-143FBED6D855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] - [DataRow("{9317ae81-bcd8-47b7-aaa1-a28062e41c71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] - [DataRow("{aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71}", "aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71")] - [DataRow("{E5F256DC-7959-4DD6-8E4F-c11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] - [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] - [DataRow("{9317AE81-bcd8-47b7-AAA1-A28062E41C71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] - [DataRow("AAAAAAAAAAAAA", "00000000-0000-0000-0000-000000000000")] - public void RecordEnvironmentVariableAddition_ShouldCollectTelemetry_IfCorProfilerVariable(string profilerGuid, string profilerName) - { - // act - this.telemetryManager.RecordEnvironmentVariableAddition(this.dataCollectorInformation, "COR_PROFILER", profilerGuid); - - // assert - this.mockMetricsCollection.Verify(c => c.Add($"VS.TestPlatform.DataCollector.CorProfiler.{dataCollectorInformation.DataCollectorConfig.TypeUri}", profilerName), Times.Once); - } - - [TestMethod] - [DataRow("{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] - [DataRow("{324F817A-7420-4E6D-B3C1-143FBED6D855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] - [DataRow("{9317ae81-bcd8-47b7-aaa1-a28062e41c71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] - [DataRow("{aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71}", "aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71")] - [DataRow("{E5F256DC-7959-4DD6-8E4F-c11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] - [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] - [DataRow("{9317AE81-bcd8-47b7-AAA1-A28062E41C71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] - [DataRow("AAAAAAAAAAAAA", "00000000-0000-0000-0000-000000000000")] - public void RecordEnvironmentVariableAddition_ShouldCollectTelemetry_IfCoreClrProfilerVariable(string profilerGuid, string profilerName) - { - // act - this.telemetryManager.RecordEnvironmentVariableAddition(this.dataCollectorInformation, "CORECLR_PROFILER", profilerGuid); - - // assert - this.mockMetricsCollection.Verify(c => c.Add($"VS.TestPlatform.DataCollector.CoreClrProfiler.{dataCollectorInformation.DataCollectorConfig.TypeUri}", profilerName), Times.Once); - } - - [TestMethod] - [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] - [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{324F817A-7420-4E6D-B3C1-143FBED6D855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] - [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{9317ae81-bcd8-47b7-aaa1-a28062e41c71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] - [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71}", "aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71")] - [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "{E5F256DC-7959-4DD6-8E4F-c11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] - [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] - [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "{9317AE81-bcd8-47b7-AAA1-A28062E41C71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] - [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "AAAAAAAAAAAAA", "00000000-0000-0000-0000-000000000000")] - public void RecordEnvironmentVariableConflict_ShouldCollectOverwrittenTelemetry_IfCorProfilerVariable(string existingProfilerGuid, string profilerGuid, string expectedOverwrittenProfiler) - { - // act - this.telemetryManager.RecordEnvironmentVariableConflict(this.dataCollectorInformation, "COR_PROFILER", profilerGuid, existingProfilerGuid); - - // assert - this.mockMetricsCollection.Verify(c => c.Add($"VS.TestPlatform.DataCollector.CorProfiler.{dataCollectorInformation.DataCollectorConfig.TypeUri}", $"{Guid.Parse(existingProfilerGuid)}(overwritten:{expectedOverwrittenProfiler})"), Times.Once); - } - - [TestMethod] - [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] - [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{324F817A-7420-4E6D-B3C1-143FBED6D855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] - [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{9317ae81-bcd8-47b7-aaa1-a28062e41c71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] - [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71}", "aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71")] - [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "{E5F256DC-7959-4DD6-8E4F-c11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] - [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] - [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "{9317AE81-bcd8-47b7-AAA1-A28062E41C71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] - [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "AAAAAAAAAAAAA", "00000000-0000-0000-0000-000000000000")] - public void RecordEnvironmentVariableConflict_ShouldCollectOverwrittenTelemetry_IfCoreClrProfilerVariable(string existingProfilerGuid, string profilerGuid, string expectedOverwrittenProfiler) - { - // act - this.telemetryManager.RecordEnvironmentVariableConflict(this.dataCollectorInformation, "CORECLR_PROFILER", profilerGuid, existingProfilerGuid); - - // assert - this.mockMetricsCollection.Verify(c => c.Add($"VS.TestPlatform.DataCollector.CoreClrProfiler.{dataCollectorInformation.DataCollectorConfig.TypeUri}", $"{Guid.Parse(existingProfilerGuid)}(overwritten:{expectedOverwrittenProfiler})"), Times.Once); - } - - [TestMethod] - [DataRow("{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}")] - [DataRow("{324F817A-7420-4E6D-B3C1-143FBED6D855}")] - [DataRow("{9317ae81-bcd8-47b7-aaa1-a28062e41c71}")] - [DataRow("{aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71}")] - [DataRow("{E5F256DC-7959-4DD6-8E4F-c11150AB28E0}")] - [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}")] - [DataRow("{9317AE81-bcd8-47b7-AAA1-A28062E41C71}")] - [DataRow("AAAAAAAAAAAAA")] - public void RecordEnvironmentVariableConflict_ShouldCollectClrIeTelemetry_IfCorProfilerVariableAndCollectorSpecifiesClrIeProfile(string profilerGuid) - { - // arrange - this.dataCollectorInformation.SetTestExecutionEnvironmentVariables(); - - // act - this.telemetryManager.RecordEnvironmentVariableConflict(this.dataCollectorInformation, "COR_PROFILER", profilerGuid, "{324F817A-7420-4E6D-B3C1-143FBED6D855}"); - - // assert - this.mockMetricsCollection.Verify(c => c.Add($"VS.TestPlatform.DataCollector.CorProfiler.{dataCollectorInformation.DataCollectorConfig.TypeUri}", "324f817a-7420-4e6d-b3c1-143fbed6d855"), Times.Once); - } - - [TestMethod] - [DataRow("{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}")] - [DataRow("{324F817A-7420-4E6D-B3C1-143FBED6D855}")] - [DataRow("{9317ae81-bcd8-47b7-aaa1-a28062e41c71}")] - [DataRow("{aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71}")] - [DataRow("{E5F256DC-7959-4DD6-8E4F-c11150AB28E0}")] - [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}")] - [DataRow("{9317AE81-bcd8-47b7-AAA1-A28062E41C71}")] - [DataRow("AAAAAAAAAAAAA")] - public void RecordEnvironmentVariableConflict_ShouldCollectClrIeTelemetry_IfCoreClrProfilerVariableAndCollectorSpecifiesClrIeProfile(string profilerGuid) - { - // arrange - this.dataCollectorInformation.SetTestExecutionEnvironmentVariables(); - - // act - this.telemetryManager.RecordEnvironmentVariableConflict(this.dataCollectorInformation, "CORECLR_PROFILER", profilerGuid, "{324F817A-7420-4E6D-B3C1-143FBED6D855}"); - - // assert - this.mockMetricsCollection.Verify(c => c.Add($"VS.TestPlatform.DataCollector.CoreClrProfiler.{dataCollectorInformation.DataCollectorConfig.TypeUri}", "324f817a-7420-4e6d-b3c1-143fbed6d855"), Times.Once); - } - - [TestMethod] - [DataRow("{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] - [DataRow("{324F817A-7420-4E6D-B3C1-143FBED6D855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] - [DataRow("{9317ae81-bcd8-47b7-aaa1-a28062e41c71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] - [DataRow("{aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71}", "aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71")] - [DataRow("{E5F256DC-7959-4DD6-8E4F-c11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] - [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] - [DataRow("{9317AE81-bcd8-47b7-AAA1-A28062E41C71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] - [DataRow("AAAAAAAAAAAAA", "00000000-0000-0000-0000-000000000000")] - public void RecordEnvironmentVariableConflict_ShouldCollectTelemetry_IfCorProfilerVariableAndBothValuesSame(string profilerGuid, string profilerName) - { - // act - this.telemetryManager.RecordEnvironmentVariableConflict(this.dataCollectorInformation, "COR_PROFILER", profilerGuid, profilerGuid.ToLower()); - - // assert - this.mockMetricsCollection.Verify(c => c.Add($"VS.TestPlatform.DataCollector.CorProfiler.{dataCollectorInformation.DataCollectorConfig.TypeUri}", profilerName), Times.Once); - } - - [TestMethod] - [DataRow("{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] - [DataRow("{324F817A-7420-4E6D-B3C1-143FBED6D855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] - [DataRow("{9317ae81-bcd8-47b7-aaa1-a28062e41c71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] - [DataRow("{aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71}", "aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71")] - [DataRow("{E5F256DC-7959-4DD6-8E4F-c11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] - [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] - [DataRow("{9317AE81-bcd8-47b7-AAA1-A28062E41C71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] - [DataRow("AAAAAAAAAAAAA", "00000000-0000-0000-0000-000000000000")] - public void RecordEnvironmentVariableConflict_ShouldCollectTelemetry_IfCoreClrProfilerVariableAndBothValuesSame(string profilerGuid, string profilerName) - { - // act - this.telemetryManager.RecordEnvironmentVariableConflict(this.dataCollectorInformation, "CORECLR_PROFILER", profilerGuid, profilerGuid.ToUpper()); + // assert + _mockMetricsCollection.Verify(c => c.Add(It.IsAny(), It.IsAny()), Times.Never); + } + + [TestMethod] + public void RecordEnvironmentVariableConflict_ShouldDoNothing_IfNotProfilerVariable_ValuesDifferent() + { + // act + _telemetryManager.RecordEnvironmentVariableConflict(_dataCollectorInformation, "key", "value", "othervalue"); + + // assert + _mockMetricsCollection.Verify(c => c.Add(It.IsAny(), It.IsAny()), Times.Never); + } + + [TestMethod] + [DataRow("{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] + [DataRow("{324F817A-7420-4E6D-B3C1-143FBED6D855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] + [DataRow("{9317ae81-bcd8-47b7-aaa1-a28062e41c71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] + [DataRow("{aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71}", "aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71")] + [DataRow("{E5F256DC-7959-4DD6-8E4F-c11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] + [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] + [DataRow("{9317AE81-bcd8-47b7-AAA1-A28062E41C71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] + [DataRow("AAAAAAAAAAAAA", "00000000-0000-0000-0000-000000000000")] + public void RecordEnvironmentVariableAddition_ShouldCollectTelemetry_IfCorProfilerVariable(string profilerGuid, string profilerName) + { + // act + _telemetryManager.RecordEnvironmentVariableAddition(_dataCollectorInformation, "COR_PROFILER", profilerGuid); + + // assert + _mockMetricsCollection.Verify(c => c.Add($"VS.TestPlatform.DataCollector.CorProfiler.{_dataCollectorInformation.DataCollectorConfig.TypeUri}", profilerName), Times.Once); + } + + [TestMethod] + [DataRow("{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] + [DataRow("{324F817A-7420-4E6D-B3C1-143FBED6D855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] + [DataRow("{9317ae81-bcd8-47b7-aaa1-a28062e41c71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] + [DataRow("{aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71}", "aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71")] + [DataRow("{E5F256DC-7959-4DD6-8E4F-c11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] + [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] + [DataRow("{9317AE81-bcd8-47b7-AAA1-A28062E41C71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] + [DataRow("AAAAAAAAAAAAA", "00000000-0000-0000-0000-000000000000")] + public void RecordEnvironmentVariableAddition_ShouldCollectTelemetry_IfCoreClrProfilerVariable(string profilerGuid, string profilerName) + { + // act + _telemetryManager.RecordEnvironmentVariableAddition(_dataCollectorInformation, "CORECLR_PROFILER", profilerGuid); + + // assert + _mockMetricsCollection.Verify(c => c.Add($"VS.TestPlatform.DataCollector.CoreClrProfiler.{_dataCollectorInformation.DataCollectorConfig.TypeUri}", profilerName), Times.Once); + } + + [TestMethod] + [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] + [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{324F817A-7420-4E6D-B3C1-143FBED6D855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] + [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{9317ae81-bcd8-47b7-aaa1-a28062e41c71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] + [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71}", "aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71")] + [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "{E5F256DC-7959-4DD6-8E4F-c11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] + [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] + [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "{9317AE81-bcd8-47b7-AAA1-A28062E41C71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] + [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "AAAAAAAAAAAAA", "00000000-0000-0000-0000-000000000000")] + public void RecordEnvironmentVariableConflict_ShouldCollectOverwrittenTelemetry_IfCorProfilerVariable(string existingProfilerGuid, string profilerGuid, string expectedOverwrittenProfiler) + { + // act + _telemetryManager.RecordEnvironmentVariableConflict(_dataCollectorInformation, "COR_PROFILER", profilerGuid, existingProfilerGuid); + + // assert + _mockMetricsCollection.Verify(c => c.Add($"VS.TestPlatform.DataCollector.CorProfiler.{_dataCollectorInformation.DataCollectorConfig.TypeUri}", $"{Guid.Parse(existingProfilerGuid)}(overwritten:{expectedOverwrittenProfiler})"), Times.Once); + } + + [TestMethod] + [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] + [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{324F817A-7420-4E6D-B3C1-143FBED6D855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] + [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{9317ae81-bcd8-47b7-aaa1-a28062e41c71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] + [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71}", "aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71")] + [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "{E5F256DC-7959-4DD6-8E4F-c11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] + [DataRow("{0f8fad5b-d9cb-469f-a165-70867728950e}", "{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] + [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "{9317AE81-bcd8-47b7-AAA1-A28062E41C71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] + [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "AAAAAAAAAAAAA", "00000000-0000-0000-0000-000000000000")] + public void RecordEnvironmentVariableConflict_ShouldCollectOverwrittenTelemetry_IfCoreClrProfilerVariable(string existingProfilerGuid, string profilerGuid, string expectedOverwrittenProfiler) + { + // act + _telemetryManager.RecordEnvironmentVariableConflict(_dataCollectorInformation, "CORECLR_PROFILER", profilerGuid, existingProfilerGuid); + + // assert + _mockMetricsCollection.Verify(c => c.Add($"VS.TestPlatform.DataCollector.CoreClrProfiler.{_dataCollectorInformation.DataCollectorConfig.TypeUri}", $"{Guid.Parse(existingProfilerGuid)}(overwritten:{expectedOverwrittenProfiler})"), Times.Once); + } + + [TestMethod] + [DataRow("{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}")] + [DataRow("{324F817A-7420-4E6D-B3C1-143FBED6D855}")] + [DataRow("{9317ae81-bcd8-47b7-aaa1-a28062e41c71}")] + [DataRow("{aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71}")] + [DataRow("{E5F256DC-7959-4DD6-8E4F-c11150AB28E0}")] + [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}")] + [DataRow("{9317AE81-bcd8-47b7-AAA1-A28062E41C71}")] + [DataRow("AAAAAAAAAAAAA")] + public void RecordEnvironmentVariableConflict_ShouldCollectClrIeTelemetry_IfCorProfilerVariableAndCollectorSpecifiesClrIeProfile(string profilerGuid) + { + // arrange + _dataCollectorInformation.SetTestExecutionEnvironmentVariables(); + + // act + _telemetryManager.RecordEnvironmentVariableConflict(_dataCollectorInformation, "COR_PROFILER", profilerGuid, "{324F817A-7420-4E6D-B3C1-143FBED6D855}"); + + // assert + _mockMetricsCollection.Verify(c => c.Add($"VS.TestPlatform.DataCollector.CorProfiler.{_dataCollectorInformation.DataCollectorConfig.TypeUri}", "324f817a-7420-4e6d-b3c1-143fbed6d855"), Times.Once); + } + + [TestMethod] + [DataRow("{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}")] + [DataRow("{324F817A-7420-4E6D-B3C1-143FBED6D855}")] + [DataRow("{9317ae81-bcd8-47b7-aaa1-a28062e41c71}")] + [DataRow("{aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71}")] + [DataRow("{E5F256DC-7959-4DD6-8E4F-c11150AB28E0}")] + [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}")] + [DataRow("{9317AE81-bcd8-47b7-AAA1-A28062E41C71}")] + [DataRow("AAAAAAAAAAAAA")] + public void RecordEnvironmentVariableConflict_ShouldCollectClrIeTelemetry_IfCoreClrProfilerVariableAndCollectorSpecifiesClrIeProfile(string profilerGuid) + { + // arrange + _dataCollectorInformation.SetTestExecutionEnvironmentVariables(); + + // act + _telemetryManager.RecordEnvironmentVariableConflict(_dataCollectorInformation, "CORECLR_PROFILER", profilerGuid, "{324F817A-7420-4E6D-B3C1-143FBED6D855}"); + + // assert + _mockMetricsCollection.Verify(c => c.Add($"VS.TestPlatform.DataCollector.CoreClrProfiler.{_dataCollectorInformation.DataCollectorConfig.TypeUri}", "324f817a-7420-4e6d-b3c1-143fbed6d855"), Times.Once); + } + + [TestMethod] + [DataRow("{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] + [DataRow("{324F817A-7420-4E6D-B3C1-143FBED6D855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] + [DataRow("{9317ae81-bcd8-47b7-aaa1-a28062e41c71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] + [DataRow("{aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71}", "aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71")] + [DataRow("{E5F256DC-7959-4DD6-8E4F-c11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] + [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] + [DataRow("{9317AE81-bcd8-47b7-AAA1-A28062E41C71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] + [DataRow("AAAAAAAAAAAAA", "00000000-0000-0000-0000-000000000000")] + public void RecordEnvironmentVariableConflict_ShouldCollectTelemetry_IfCorProfilerVariableAndBothValuesSame(string profilerGuid, string profilerName) + { + // act + _telemetryManager.RecordEnvironmentVariableConflict(_dataCollectorInformation, "COR_PROFILER", profilerGuid, profilerGuid.ToLower()); + + // assert + _mockMetricsCollection.Verify(c => c.Add($"VS.TestPlatform.DataCollector.CorProfiler.{_dataCollectorInformation.DataCollectorConfig.TypeUri}", profilerName), Times.Once); + } + + [TestMethod] + [DataRow("{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] + [DataRow("{324F817A-7420-4E6D-B3C1-143FBED6D855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] + [DataRow("{9317ae81-bcd8-47b7-aaa1-a28062e41c71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] + [DataRow("{aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71}", "aaaaaaaa-bcd8-47b7-aaa1-a28062e41c71")] + [DataRow("{E5F256DC-7959-4DD6-8E4F-c11150AB28E0}", "e5f256dc-7959-4dd6-8e4f-c11150ab28e0")] + [DataRow("{324f817a-7420-4e6d-b3c1-143fbEd6d855}", "324f817a-7420-4e6d-b3c1-143fbed6d855")] + [DataRow("{9317AE81-bcd8-47b7-AAA1-A28062E41C71}", "9317ae81-bcd8-47b7-aaa1-a28062e41c71")] + [DataRow("AAAAAAAAAAAAA", "00000000-0000-0000-0000-000000000000")] + public void RecordEnvironmentVariableConflict_ShouldCollectTelemetry_IfCoreClrProfilerVariableAndBothValuesSame(string profilerGuid, string profilerName) + { + // act + _telemetryManager.RecordEnvironmentVariableConflict(_dataCollectorInformation, "CORECLR_PROFILER", profilerGuid, profilerGuid.ToUpper()); - // assert - this.mockMetricsCollection.Verify(c => c.Add($"VS.TestPlatform.DataCollector.CoreClrProfiler.{dataCollectorInformation.DataCollectorConfig.TypeUri}", profilerName), Times.Once); - } + // assert + _mockMetricsCollection.Verify(c => c.Add($"VS.TestPlatform.DataCollector.CoreClrProfiler.{_dataCollectorInformation.DataCollectorConfig.TypeUri}", profilerName), Times.Once); } -} +} \ No newline at end of file diff --git a/test/datacollector.UnitTests/DataCollectorConfigTests.cs b/test/datacollector.UnitTests/DataCollectorConfigTests.cs index 17b6e466df..e3ef0f659c 100644 --- a/test/datacollector.UnitTests/DataCollectorConfigTests.cs +++ b/test/datacollector.UnitTests/DataCollectorConfigTests.cs @@ -1,56 +1,52 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests; + +using System; + +using TestTools.UnitTesting; + +[TestClass] +public class DataCollectorConfigTests { - using System; + [TestMethod] + public void ConstructorShouldSetCorrectFriendlyNameAndUri() + { + var dataCollectorConfig = new DataCollectorConfig(typeof(CustomDataCollector)); + + Assert.AreEqual("CustomDataCollector", dataCollectorConfig.FriendlyName); + Assert.AreEqual("my://custom/datacollector", dataCollectorConfig.TypeUri.ToString()); + } + + [TestMethod] + public void ConstructorShouldThrowExceptionIfTypeIsNull() + { + Assert.ThrowsException( + () => new DataCollectorConfig(null)); + } - using Microsoft.VisualStudio.TestTools.UnitTesting; + [TestMethod] + public void ConstructorShouldNotThrowExceptionIfUriIsNotSpecifiedInDataCollector() + { + var dataCollectorConfig = new DataCollectorConfig(typeof(CustomDataCollectorWithoutUri)); + Assert.AreEqual("CustomDataCollector", dataCollectorConfig.FriendlyName); + Assert.IsNull(dataCollectorConfig.TypeUri); + } + + [TestMethod] + public void ConstructorShouldNotThrowExceptionIfFriendlyNameIsEmpty() + { + var dataCollectorConfig = new DataCollectorConfig(typeof(CustomDataCollectorWithEmptyFriendlyName)); + Assert.AreEqual("", dataCollectorConfig.FriendlyName); + Assert.AreEqual("my://custom/datacollector", dataCollectorConfig.TypeUri.ToString()); + } - [TestClass] - public class DataCollectorConfigTests + [TestMethod] + public void ConstructorShouldNotThrowExceptionIfFriendlyNameIsNotSpecified() { - [TestMethod] - public void ConstructorShouldSetCorrectFriendlyNameAndUri() - { - var dataCollectorConfig = new DataCollectorConfig(typeof(CustomDataCollector)); - - Assert.AreEqual("CustomDataCollector", dataCollectorConfig.FriendlyName); - Assert.AreEqual("my://custom/datacollector", dataCollectorConfig.TypeUri.ToString()); - } - - [TestMethod] - public void ConstructorShouldThrowExceptionIfTypeIsNull() - { - Assert.ThrowsException( - () => - { - new DataCollectorConfig(null); - }); - } - - [TestMethod] - public void ConstructorShouldNotThrowExceptionIfUriIsNotSpecifiedInDataCollector() - { - var dataCollectorConfig = new DataCollectorConfig(typeof(CustomDataCollectorWithoutUri)); - Assert.AreEqual("CustomDataCollector", dataCollectorConfig.FriendlyName); - Assert.IsNull(dataCollectorConfig.TypeUri); - } - - [TestMethod] - public void ConstructorShouldNotThrowExceptionIfFriendlyNameIsEmpty() - { - var dataCollectorConfig = new DataCollectorConfig(typeof(CustomDataCollectorWithEmptyFriendlyName)); - Assert.AreEqual("", dataCollectorConfig.FriendlyName); - Assert.AreEqual("my://custom/datacollector", dataCollectorConfig.TypeUri.ToString()); - } - - [TestMethod] - public void ConstructorShouldNotThrowExceptionIfFriendlyNameIsNotSpecified() - { - var dataCollectorConfig = new DataCollectorConfig(typeof(CustomDataCollectorWithoutFriendlyName)); - Assert.AreEqual("", dataCollectorConfig.FriendlyName); - Assert.AreEqual("my://custom/datacollector", dataCollectorConfig.TypeUri.ToString()); - } + var dataCollectorConfig = new DataCollectorConfig(typeof(CustomDataCollectorWithoutFriendlyName)); + Assert.AreEqual("", dataCollectorConfig.FriendlyName); + Assert.AreEqual("my://custom/datacollector", dataCollectorConfig.TypeUri.ToString()); } -} +} \ No newline at end of file diff --git a/test/datacollector.UnitTests/DataCollectorInformationTests.cs b/test/datacollector.UnitTests/DataCollectorInformationTests.cs index f79b91a1b4..0981be8a31 100644 --- a/test/datacollector.UnitTests/DataCollectorInformationTests.cs +++ b/test/datacollector.UnitTests/DataCollectorInformationTests.cs @@ -1,64 +1,61 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests -{ - using System; - using System.Collections.Generic; - using System.Linq; +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests; +using System.Collections.Generic; +using System.Linq; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using Interfaces; +using TestTools.UnitTesting; - using Moq; - using Moq.Protected; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Moq; +using Moq.Protected; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - [TestClass] - public class DataCollectorInformationTests - { - private DataCollectorInformation dataCollectorInfo; +[TestClass] +public class DataCollectorInformationTests +{ + private readonly DataCollectorInformation _dataCollectorInfo; - private List> envVarList; + private readonly List> _envVarList; - private Mock mockDataCollector; + private readonly Mock _mockDataCollector; - public DataCollectorInformationTests() - { - this.envVarList = new List>(); - this.mockDataCollector = new Mock(); - this.mockDataCollector.As().Setup(x => x.GetTestExecutionEnvironmentVariables()).Returns(this.envVarList); - this.mockDataCollector.Protected().Setup("Dispose", true); - var mockMessageSink = new Mock(); - this.dataCollectorInfo = new DataCollectorInformation( - this.mockDataCollector.Object, - null, - new DataCollectorConfig(typeof(CustomDataCollector)), - null, - new Mock().Object, - new TestPlatformDataCollectionEvents(), - mockMessageSink.Object, - string.Empty); - } + public DataCollectorInformationTests() + { + _envVarList = new List>(); + _mockDataCollector = new Mock(); + _mockDataCollector.As().Setup(x => x.GetTestExecutionEnvironmentVariables()).Returns(_envVarList); + _mockDataCollector.Protected().Setup("Dispose", false, true); + var mockMessageSink = new Mock(); + _dataCollectorInfo = new DataCollectorInformation( + _mockDataCollector.Object, + null, + new DataCollectorConfig(typeof(CustomDataCollector)), + null, + new Mock().Object, + new TestPlatformDataCollectionEvents(), + mockMessageSink.Object, + string.Empty); + } - [TestMethod] - public void InitializeDataCollectorShouldInitializeDataCollector() - { - this.envVarList.Add(new KeyValuePair("key", "value")); + [TestMethod] + public void InitializeDataCollectorShouldInitializeDataCollector() + { + _envVarList.Add(new KeyValuePair("key", "value")); - this.dataCollectorInfo.InitializeDataCollector(); - this.dataCollectorInfo.SetTestExecutionEnvironmentVariables(); + _dataCollectorInfo.InitializeDataCollector(); + _dataCollectorInfo.SetTestExecutionEnvironmentVariables(); - CollectionAssert.AreEqual(this.envVarList, this.dataCollectorInfo.TestExecutionEnvironmentVariables.ToList()); - } + CollectionAssert.AreEqual(_envVarList, _dataCollectorInfo.TestExecutionEnvironmentVariables.ToList()); + } - [TestMethod] - public void DisposeShouldInvokeDisposeOfDatacollector() - { - this.dataCollectorInfo.InitializeDataCollector(); - this.dataCollectorInfo.DisposeDataCollector(); + [TestMethod] + public void DisposeShouldInvokeDisposeOfDatacollector() + { + _dataCollectorInfo.InitializeDataCollector(); + _dataCollectorInfo.DisposeDataCollector(); - this.mockDataCollector.Protected().Verify("Dispose", Times.Once(), true); - } + _mockDataCollector.Protected().Verify("Dispose", Times.Once(), false, true); } -} +} \ No newline at end of file diff --git a/test/datacollector.UnitTests/DataCollectorMainTests.cs b/test/datacollector.UnitTests/DataCollectorMainTests.cs index f25a3b8c05..c124f8f492 100644 --- a/test/datacollector.UnitTests/DataCollectorMainTests.cs +++ b/test/datacollector.UnitTests/DataCollectorMainTests.cs @@ -1,118 +1,122 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests; + +using System; +using System.Diagnostics; + +using CommunicationUtilities.DataCollection.Interfaces; + +using CoreUtilities.Helpers; + +using ObjectModel; +using TestTools.UnitTesting; + +using Moq; + +using PlatformAbstractions.Interfaces; + +using TestPlatform.DataCollector; + +[TestClass] +public class DataCollectorMainTests { - using System; - using System.Diagnostics; - - using CommunicationUtilities.DataCollection.Interfaces; - using CoreUtilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using PlatformAbstractions.Interfaces; - using TestPlatform.DataCollector; - - [TestClass] - public class DataCollectorMainTests + private readonly string[] _args = { "--port", "1025", "--parentprocessid", "100", "--diag", "abc.txt", "--tracelevel", "3" }; + private readonly string[] _argsWithEmptyDiagArg = { "--port", "1025", "--parentprocessid", "100", "--diag", "", "--tracelevel", "3" }; + private readonly string[] _argsWithInvalidTraceLevel = { "--port", "1025", "--parentprocessid", "100", "--diag", "abc.txt", "--tracelevel", "5" }; + + private static readonly string TimoutErrorMessage = + "datacollector process failed to connect to vstest.console process after 90 seconds. This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout."; + private readonly Mock _mockProcessHelper; + private readonly Mock _mockEnvironment; + private readonly Mock _mockDataCollectionRequestHandler; + private readonly DataCollectorMain _dataCollectorMain; + + public DataCollectorMainTests() { - private readonly string[] args = {"--port", "1025", "--parentprocessid", "100", "--diag", "abc.txt", "--tracelevel", "3" }; - private readonly string[] argsWithEmptyDiagArg = { "--port", "1025", "--parentprocessid", "100", "--diag", "", "--tracelevel", "3" }; - private readonly string[] argsWithInvalidTraceLevel = { "--port", "1025", "--parentprocessid", "100", "--diag", "abc.txt", "--tracelevel", "5" }; - - private static readonly string TimoutErrorMessage = - "datacollector process failed to connect to vstest.console process after 90 seconds. This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout."; - private Mock mockProcessHelper; - private Mock mockEnvironment; - private Mock mockDataCollectionRequestHandler; - private DataCollectorMain dataCollectorMain; - - public DataCollectorMainTests() - { - this.mockProcessHelper = new Mock(); - this.mockEnvironment = new Mock(); - this.mockDataCollectionRequestHandler = new Mock(); - this.dataCollectorMain = new DataCollectorMain(this.mockProcessHelper.Object, this.mockEnvironment.Object, this.mockDataCollectionRequestHandler.Object); - this.mockDataCollectionRequestHandler.Setup(rh => rh.WaitForRequestSenderConnection(It.IsAny())).Returns(true); - } - - [TestCleanup] - public void CleanUp() - { - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, ""); - } - - [TestMethod] - public void RunShouldTimeoutBasedOnEnvVariable() - { - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, "10"); - this.dataCollectorMain.Run(args); - this.mockDataCollectionRequestHandler.Verify(rh => rh.WaitForRequestSenderConnection(10 * 1000)); - } - - [TestMethod] - public void RunShouldTimeoutBasedDefaulValueIfEnvVariableNotSet() - { - this.dataCollectorMain.Run(args); - - this.mockDataCollectionRequestHandler.Verify(rh => rh.WaitForRequestSenderConnection(EnvironmentHelper.DefaultConnectionTimeout * 1000)); - } - - [TestMethod] - public void RunShouldInitializeTraceWithTraceLevelOffIfDiagArgIsEmpty() - { - // Setting EqtTrace.TraceLevel to a value other than info. + _mockProcessHelper = new Mock(); + _mockEnvironment = new Mock(); + _mockDataCollectionRequestHandler = new Mock(); + _dataCollectorMain = new DataCollectorMain(_mockProcessHelper.Object, _mockEnvironment.Object, _mockDataCollectionRequestHandler.Object); + _mockDataCollectionRequestHandler.Setup(rh => rh.WaitForRequestSenderConnection(It.IsAny())).Returns(true); + } + + [TestCleanup] + public void CleanUp() + { + Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, ""); + } + + [TestMethod] + public void RunShouldTimeoutBasedOnEnvVariable() + { + Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, "10"); + _dataCollectorMain.Run(_args); + _mockDataCollectionRequestHandler.Verify(rh => rh.WaitForRequestSenderConnection(10 * 1000)); + } + + [TestMethod] + public void RunShouldTimeoutBasedDefaulValueIfEnvVariableNotSet() + { + _dataCollectorMain.Run(_args); + + _mockDataCollectionRequestHandler.Verify(rh => rh.WaitForRequestSenderConnection(EnvironmentHelper.DefaultConnectionTimeout * 1000)); + } + + [TestMethod] + public void RunShouldInitializeTraceWithTraceLevelOffIfDiagArgIsEmpty() + { + // Setting EqtTrace.TraceLevel to a value other than info. #if NETFRAMEWORK - EqtTrace.TraceLevel = TraceLevel.Verbose; + EqtTrace.TraceLevel = TraceLevel.Verbose; #else - EqtTrace.TraceLevel = PlatformTraceLevel.Verbose; + EqtTrace.TraceLevel = PlatformTraceLevel.Verbose; #endif - // Action - this.dataCollectorMain.Run(argsWithEmptyDiagArg); // Passing tracelevel as info and diag file path is empty. + // Action + _dataCollectorMain.Run(_argsWithEmptyDiagArg); // Passing tracelevel as info and diag file path is empty. - // Verify - Assert.AreEqual(TraceLevel.Off, (TraceLevel)EqtTrace.TraceLevel); - } + // Verify + Assert.AreEqual(TraceLevel.Off, (TraceLevel)EqtTrace.TraceLevel); + } - [TestMethod] - public void RunShouldInitializeTraceWithVerboseTraceLevelIfInvalidTraceLevelPassed() - { - // Setting EqtTrace.TraceLevel to a value other than info. + [TestMethod] + public void RunShouldInitializeTraceWithVerboseTraceLevelIfInvalidTraceLevelPassed() + { + // Setting EqtTrace.TraceLevel to a value other than info. #if NETFRAMEWORK - EqtTrace.TraceLevel = TraceLevel.Info; + EqtTrace.TraceLevel = TraceLevel.Info; #else - EqtTrace.TraceLevel = PlatformTraceLevel.Info; + EqtTrace.TraceLevel = PlatformTraceLevel.Info; #endif - // Action - this.dataCollectorMain.Run(argsWithInvalidTraceLevel); + // Action + _dataCollectorMain.Run(_argsWithInvalidTraceLevel); - // Verify - Assert.AreEqual(TraceLevel.Verbose, (TraceLevel)EqtTrace.TraceLevel); - } + // Verify + Assert.AreEqual(TraceLevel.Verbose, (TraceLevel)EqtTrace.TraceLevel); + } - [TestMethod] - public void RunShouldInitializeTraceWithCorrectVerboseTraceLevel() - { - // Setting EqtTrace.TraceLevel to a value other than info. + [TestMethod] + public void RunShouldInitializeTraceWithCorrectVerboseTraceLevel() + { + // Setting EqtTrace.TraceLevel to a value other than info. #if NETFRAMEWORK - EqtTrace.TraceLevel = TraceLevel.Verbose; + EqtTrace.TraceLevel = TraceLevel.Verbose; #else - EqtTrace.TraceLevel = PlatformTraceLevel.Verbose; + EqtTrace.TraceLevel = PlatformTraceLevel.Verbose; #endif - // Action - this.dataCollectorMain.Run(args); // Trace level is set as info in args. - - // Verify - Assert.AreEqual(TraceLevel.Info, (TraceLevel)EqtTrace.TraceLevel); - } - - [TestMethod] - public void RunShouldThrowIfTimeoutOccured() - { - this.mockDataCollectionRequestHandler.Setup(rh => rh.WaitForRequestSenderConnection(It.IsAny())).Returns(false); - var message = Assert.ThrowsException(() => this.dataCollectorMain.Run(args)).Message; - Assert.AreEqual(DataCollectorMainTests.TimoutErrorMessage, message); - } + // Action + _dataCollectorMain.Run(_args); // Trace level is set as info in args. + + // Verify + Assert.AreEqual(TraceLevel.Info, (TraceLevel)EqtTrace.TraceLevel); + } + + [TestMethod] + public void RunShouldThrowIfTimeoutOccured() + { + _mockDataCollectionRequestHandler.Setup(rh => rh.WaitForRequestSenderConnection(It.IsAny())).Returns(false); + var message = Assert.ThrowsException(() => _dataCollectorMain.Run(_args)).Message; + Assert.AreEqual(TimoutErrorMessage, message); } -} +} \ No newline at end of file diff --git a/test/datacollector.UnitTests/DummyDataCollectors.cs b/test/datacollector.UnitTests/DummyDataCollectors.cs index 3b8e7858b5..1b2d35759b 100644 --- a/test/datacollector.UnitTests/DummyDataCollectors.cs +++ b/test/datacollector.UnitTests/DummyDataCollectors.cs @@ -1,77 +1,76 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests -{ - using System.Collections.Generic; - using System.Xml; +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using System.Collections.Generic; +using System.Xml; - [DataCollectorFriendlyName("CustomDataCollector")] - [DataCollectorTypeUri("my://custom/datacollector")] - public class CustomDataCollector : DataCollector, ITestExecutionEnvironmentSpecifier - { - public DataCollectionEnvironmentContext DataCollectionEnvironmentContext { get; set; } +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + +[DataCollectorFriendlyName("CustomDataCollector")] +[DataCollectorTypeUri("my://custom/datacollector")] +public class CustomDataCollector : DataCollector, ITestExecutionEnvironmentSpecifier +{ + public DataCollectionEnvironmentContext DataCollectionEnvironmentContext { get; set; } - public DataCollectionSink DataSink { get; set; } + public DataCollectionSink DataSink { get; set; } - public override void Initialize( - XmlElement configurationElement, - DataCollectionEvents events, - DataCollectionSink dataSink, - DataCollectionLogger logger, - DataCollectionEnvironmentContext environmentContext) - { - } + public override void Initialize( + XmlElement configurationElement, + DataCollectionEvents events, + DataCollectionSink dataSink, + DataCollectionLogger logger, + DataCollectionEnvironmentContext environmentContext) + { + } - public IEnumerable> GetTestExecutionEnvironmentVariables() - { - return default; - } + public IEnumerable> GetTestExecutionEnvironmentVariables() + { + return default; + } - protected override void Dispose(bool disposing) - { - } + protected override void Dispose(bool disposing) + { } +} - [DataCollectorFriendlyName("CustomDataCollector")] - public class CustomDataCollectorWithoutUri : DataCollector +[DataCollectorFriendlyName("CustomDataCollector")] +public class CustomDataCollectorWithoutUri : DataCollector +{ + public override void Initialize( + XmlElement configurationElement, + DataCollectionEvents events, + DataCollectionSink dataSink, + DataCollectionLogger logger, + DataCollectionEnvironmentContext environmentContext) { - public override void Initialize( - XmlElement configurationElement, - DataCollectionEvents events, - DataCollectionSink dataSink, - DataCollectionLogger logger, - DataCollectionEnvironmentContext environmentContext) - { - } } +} - [DataCollectorTypeUri("my://custom/datacollector")] - public class CustomDataCollectorWithoutFriendlyName : DataCollector +[DataCollectorTypeUri("my://custom/datacollector")] +public class CustomDataCollectorWithoutFriendlyName : DataCollector +{ + public override void Initialize( + XmlElement configurationElement, + DataCollectionEvents events, + DataCollectionSink dataSink, + DataCollectionLogger logger, + DataCollectionEnvironmentContext environmentContext) { - public override void Initialize( - XmlElement configurationElement, - DataCollectionEvents events, - DataCollectionSink dataSink, - DataCollectionLogger logger, - DataCollectionEnvironmentContext environmentContext) - { - } } +} - [DataCollectorFriendlyName("")] - [DataCollectorTypeUri("my://custom/datacollector")] - public class CustomDataCollectorWithEmptyFriendlyName : DataCollector +[DataCollectorFriendlyName("")] +[DataCollectorTypeUri("my://custom/datacollector")] +public class CustomDataCollectorWithEmptyFriendlyName : DataCollector +{ + public override void Initialize( + XmlElement configurationElement, + DataCollectionEvents events, + DataCollectionSink dataSink, + DataCollectionLogger logger, + DataCollectionEnvironmentContext environmentContext) { - public override void Initialize( - XmlElement configurationElement, - DataCollectionEvents events, - DataCollectionSink dataSink, - DataCollectionLogger logger, - DataCollectionEnvironmentContext environmentContext) - { - } } } \ No newline at end of file diff --git a/test/datacollector.UnitTests/Program.cs b/test/datacollector.UnitTests/Program.cs index 7f39953476..05d6103873 100644 --- a/test/datacollector.UnitTests/Program.cs +++ b/test/datacollector.UnitTests/Program.cs @@ -1,14 +1,14 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests; + +/// +/// Main entry point for the command line runner. +/// +public static class Program { - /// - /// Main entry point for the command line runner. - /// - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/datacollector.UnitTests/TestPlatformDataCollectionEventsTests.cs b/test/datacollector.UnitTests/TestPlatformDataCollectionEventsTests.cs index 1ee6ba7980..459e4d48cc 100644 --- a/test/datacollector.UnitTests/TestPlatformDataCollectionEventsTests.cs +++ b/test/datacollector.UnitTests/TestPlatformDataCollectionEventsTests.cs @@ -1,161 +1,158 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests; + +using System; +using System.Collections.Generic; + +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using TestTools.UnitTesting; + +[TestClass] +public class TestPlatformDataCollectionEventsTests { - using System; - using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public class TestPlatformDataCollectionEventsTests + private readonly TestPlatformDataCollectionEvents _events; + + private DataCollectionContext _context; + + private bool _isEventRaised; + + public TestPlatformDataCollectionEventsTests() + { + _events = new TestPlatformDataCollectionEvents(); + } + + [TestMethod] + public void RaiseEventsShouldThrowExceptionIfEventArgsIsNull() + { + Assert.ThrowsException(() => _events.RaiseEvent(null)); + } + + [TestMethod] + public void RaiseEventsShouldRaiseEventsIfSessionStartEventArgsIsPassed() + { + _isEventRaised = false; + var testCase = new TestCase(); + _context = new DataCollectionContext(testCase); + + _events.SessionStart += SessionStartMessageHandler; + var eventArgs = new SessionStartEventArgs(_context, new Dictionary()); + _events.RaiseEvent(eventArgs); + + Assert.IsTrue(_isEventRaised); + } + + [TestMethod] + public void RaiseEventsShouldNotRaiseEventsIfEventIsNotRegisterd() + { + _isEventRaised = false; + var testCase = new TestCase(); + _context = new DataCollectionContext(testCase); + + var eventArgs = new SessionStartEventArgs(_context, new Dictionary()); + _events.RaiseEvent(eventArgs); + + Assert.IsFalse(_isEventRaised); + } + + [TestMethod] + public void RaiseEventsShouldNotRaiseEventsIfEventIsUnRegisterd() + { + _isEventRaised = false; + var testCase = new TestCase(); + _context = new DataCollectionContext(testCase); + + _events.SessionStart += SessionStartMessageHandler; + _events.SessionStart -= SessionStartMessageHandler; + var eventArgs = new SessionStartEventArgs(_context, new Dictionary()); + _events.RaiseEvent(eventArgs); + + Assert.IsFalse(_isEventRaised); + } + + [TestMethod] + public void RaiseEventsShouldRaiseEventsIfSessionEndEventArgsIsPassed() + { + _isEventRaised = false; + var testCase = new TestCase(); + _context = new DataCollectionContext(testCase); + + _events.SessionEnd += SessionEndMessageHandler; + var eventArgs = new SessionEndEventArgs(_context); + _events.RaiseEvent(eventArgs); + + Assert.IsTrue(_isEventRaised); + } + + [TestMethod] + public void RaiseEventsShouldRaiseEventsIfTestCaseStartEventArgsIsPassed() + { + _isEventRaised = false; + var testCase = new TestCase(); + _context = new DataCollectionContext(testCase); + + _events.TestCaseStart += TestCaseStartMessageHandler; + var eventArgs = new TestCaseStartEventArgs(_context, testCase); + _events.RaiseEvent(eventArgs); + + Assert.IsTrue(_isEventRaised); + } + + [TestMethod] + public void RaiseEventsShouldRaiseEventsIfTestCaseEndEventArgsIsPassed() + { + _isEventRaised = false; + var testCase = new TestCase(); + _context = new DataCollectionContext(testCase); + + _events.TestCaseEnd += TestCaseEndMessageHandler; + var eventArgs = new TestCaseEndEventArgs(_context, testCase, TestOutcome.Passed); + _events.RaiseEvent(eventArgs); + + Assert.IsTrue(_isEventRaised); + } + + [TestMethod] + public void AreTestCaseEventsSubscribedShouldReturnTrueIfTestCaseStartIsSubscribed() + { + _events.TestCaseStart += TestCaseStartMessageHandler; + + Assert.IsTrue(_events.AreTestCaseEventsSubscribed()); + } + + [TestMethod] + public void AreTestCaseEventsSubscribedShouldReturnTrueIfTestCaseEndIsSubscribed() + { + _events.TestCaseEnd += TestCaseEndMessageHandler; + + Assert.IsTrue(_events.AreTestCaseEventsSubscribed()); + } + + [TestMethod] + public void AreTestCaseEventsSubscribedShouldFalseIfTestCaseEventsAreNotSubscribed() + { + Assert.IsFalse(_events.AreTestCaseEventsSubscribed()); + } + + private void SessionStartMessageHandler(object sender, SessionStartEventArgs e) + { + _isEventRaised = true; + } + + private void SessionEndMessageHandler(object sender, SessionEndEventArgs e) + { + _isEventRaised = true; + } + + private void TestCaseStartMessageHandler(object sender, TestCaseStartEventArgs e) + { + _isEventRaised = true; + } + + private void TestCaseEndMessageHandler(object sender, TestCaseEndEventArgs e) { - private TestPlatformDataCollectionEvents events; - - private DataCollectionContext context; - - private bool isEventRaised; - - public TestPlatformDataCollectionEventsTests() - { - this.events = new TestPlatformDataCollectionEvents(); - } - - [TestMethod] - public void RaiseEventsShouldThrowExceptionIfEventArgsIsNull() - { - Assert.ThrowsException(() => - { - this.events.RaiseEvent(null); - }); - } - - [TestMethod] - public void RaiseEventsShouldRaiseEventsIfSessionStartEventArgsIsPassed() - { - this.isEventRaised = false; - var testCase = new TestCase(); - this.context = new DataCollectionContext(testCase); - - this.events.SessionStart += this.SessionStartMessageHandler; - var eventArgs = new SessionStartEventArgs(this.context, new Dictionary()); - this.events.RaiseEvent(eventArgs); - - Assert.IsTrue(this.isEventRaised); - } - - [TestMethod] - public void RaiseEventsShouldNotRaiseEventsIfEventIsNotRegisterd() - { - this.isEventRaised = false; - var testCase = new TestCase(); - this.context = new DataCollectionContext(testCase); - - var eventArgs = new SessionStartEventArgs(this.context, new Dictionary()); - this.events.RaiseEvent(eventArgs); - - Assert.IsFalse(this.isEventRaised); - } - - [TestMethod] - public void RaiseEventsShouldNotRaiseEventsIfEventIsUnRegisterd() - { - this.isEventRaised = false; - var testCase = new TestCase(); - this.context = new DataCollectionContext(testCase); - - this.events.SessionStart += this.SessionStartMessageHandler; - this.events.SessionStart -= this.SessionStartMessageHandler; - var eventArgs = new SessionStartEventArgs(this.context, new Dictionary()); - this.events.RaiseEvent(eventArgs); - - Assert.IsFalse(this.isEventRaised); - } - - [TestMethod] - public void RaiseEventsShouldRaiseEventsIfSessionEndEventArgsIsPassed() - { - this.isEventRaised = false; - var testCase = new TestCase(); - this.context = new DataCollectionContext(testCase); - - this.events.SessionEnd += this.SessionEndMessageHandler; - var eventArgs = new SessionEndEventArgs(this.context); - this.events.RaiseEvent(eventArgs); - - Assert.IsTrue(this.isEventRaised); - } - - [TestMethod] - public void RaiseEventsShouldRaiseEventsIfTestCaseStartEventArgsIsPassed() - { - this.isEventRaised = false; - var testCase = new TestCase(); - this.context = new DataCollectionContext(testCase); - - this.events.TestCaseStart += this.TestCaseStartMessageHandler; - var eventArgs = new TestCaseStartEventArgs(this.context, testCase); - this.events.RaiseEvent(eventArgs); - - Assert.IsTrue(this.isEventRaised); - } - - [TestMethod] - public void RaiseEventsShouldRaiseEventsIfTestCaseEndEventArgsIsPassed() - { - this.isEventRaised = false; - var testCase = new TestCase(); - this.context = new DataCollectionContext(testCase); - - this.events.TestCaseEnd += this.TestCaseEndMessageHandler; - var eventArgs = new TestCaseEndEventArgs(this.context, testCase, TestOutcome.Passed); - this.events.RaiseEvent(eventArgs); - - Assert.IsTrue(this.isEventRaised); - } - - [TestMethod] - public void AreTestCaseEventsSubscribedShouldReturnTrueIfTestCaseStartIsSubscribed() - { - this.events.TestCaseStart += this.TestCaseStartMessageHandler; - - Assert.IsTrue(this.events.AreTestCaseEventsSubscribed()); - } - - [TestMethod] - public void AreTestCaseEventsSubscribedShouldReturnTrueIfTestCaseEndIsSubscribed() - { - this.events.TestCaseEnd += this.TestCaseEndMessageHandler; - - Assert.IsTrue(this.events.AreTestCaseEventsSubscribed()); - } - - [TestMethod] - public void AreTestCaseEventsSubscribedShouldFalseIfTestCaseEventsAreNotSubscribed() - { - Assert.IsFalse(this.events.AreTestCaseEventsSubscribed()); - } - - private void SessionStartMessageHandler(object sender, SessionStartEventArgs e) - { - this.isEventRaised = true; - } - - private void SessionEndMessageHandler(object sender, SessionEndEventArgs e) - { - this.isEventRaised = true; - } - - private void TestCaseStartMessageHandler(object sender, TestCaseStartEventArgs e) - { - this.isEventRaised = true; - } - - private void TestCaseEndMessageHandler(object sender, TestCaseEndEventArgs e) - { - this.isEventRaised = true; - } + _isEventRaised = true; } -} +} \ No newline at end of file diff --git a/test/datacollector.UnitTests/TestPlatformDataCollectionLoggerTests.cs b/test/datacollector.UnitTests/TestPlatformDataCollectionLoggerTests.cs index 7c744c1b54..50973135d9 100644 --- a/test/datacollector.UnitTests/TestPlatformDataCollectionLoggerTests.cs +++ b/test/datacollector.UnitTests/TestPlatformDataCollectionLoggerTests.cs @@ -1,105 +1,83 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests; + +using System; + +using Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class TestPlatformDataCollectionLoggerTests { - using System; + private readonly TestPlatformDataCollectionLogger _logger; + private readonly Mock _messageSink; + private readonly DataCollectorConfig _dataCollectorConfig; + private readonly DataCollectionContext _context; + + public TestPlatformDataCollectionLoggerTests() + { + _messageSink = new Mock(); + _dataCollectorConfig = new DataCollectorConfig(typeof(CustomDataCollector)); + _logger = new TestPlatformDataCollectionLogger(_messageSink.Object, _dataCollectorConfig); + + var guid = Guid.NewGuid(); + var sessionId = new SessionId(guid); + _context = new DataCollectionContext(sessionId); + } + + [TestMethod] + public void LogErrorShouldThrowExceptionIfContextIsNull() + { + Assert.ThrowsException(() => _logger.LogError(null, string.Empty)); + + Assert.ThrowsException(() => _logger.LogError(null, new Exception())); + + Assert.ThrowsException(() => _logger.LogError(null, string.Empty, new Exception())); + } - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestTools.UnitTesting; + [TestMethod] + public void LogErrorShouldThrowExceptionIfTextIsNull() + { + Assert.ThrowsException(() => _logger.LogError(_context, (string)null)); - using Moq; + Assert.ThrowsException(() => _logger.LogError(_context, null, new Exception())); + } - [TestClass] - public class TestPlatformDataCollectionLoggerTests + [TestMethod] + public void LogErrorShouldThrowExceptionIfExceptionIsNull() { - private TestPlatformDataCollectionLogger logger; - private Mock messageSink; - private DataCollectorConfig dataCollectorConfig; - private DataCollectionContext context; - - public TestPlatformDataCollectionLoggerTests() - { - this.messageSink = new Mock(); - this.dataCollectorConfig = new DataCollectorConfig(typeof(CustomDataCollector)); - this.logger = new TestPlatformDataCollectionLogger(this.messageSink.Object, this.dataCollectorConfig); - - var guid = Guid.NewGuid(); - var sessionId = new SessionId(guid); - this.context = new DataCollectionContext(sessionId); - } - - [TestMethod] - public void LogErrorShouldThrowExceptionIfContextIsNull() - { - Assert.ThrowsException(() => - { - this.logger.LogError(null, string.Empty); - }); - - Assert.ThrowsException(() => - { - this.logger.LogError(null, new Exception()); - }); - - Assert.ThrowsException(() => - { - this.logger.LogError(null, string.Empty, new Exception()); - }); - } - - [TestMethod] - public void LogErrorShouldThrowExceptionIfTextIsNull() - { - Assert.ThrowsException(() => - { - this.logger.LogError(this.context, (string)null); - }); - - Assert.ThrowsException(() => - { - this.logger.LogError(this.context, null, new Exception()); - }); - } - - [TestMethod] - public void LogErrorShouldThrowExceptionIfExceptionIsNull() - { - Assert.ThrowsException(() => - { - this.logger.LogError(this.context, (Exception)null); - }); - - Assert.ThrowsException(() => - { - this.logger.LogError(this.context, string.Empty, (Exception)null); - }); - } - - [TestMethod] - public void LogErrorShouldSendMessageToMessageSink() - { - var text = "customtext"; - this.logger.LogError(this.context, text); - - this.messageSink.Verify(x => x.SendMessage(It.IsAny()), Times.Once()); - - this.logger.LogError(this.context, new Exception(text)); - this.messageSink.Verify(x => x.SendMessage(It.IsAny()), Times.Exactly(2)); - - this.logger.LogError(this.context, text, new Exception(text)); - this.messageSink.Verify(x => x.SendMessage(It.IsAny()), Times.Exactly(3)); - } - - [TestMethod] - public void LogWarningShouldSendMessageToMessageSink() - { - var text = "customtext"; - this.logger.LogWarning(this.context, text); - - this.messageSink.Verify(x => x.SendMessage(It.IsAny()), Times.Once()); - } + Assert.ThrowsException(() => _logger.LogError(_context, (Exception)null)); + + Assert.ThrowsException(() => _logger.LogError(_context, string.Empty, (Exception)null)); + } + + [TestMethod] + public void LogErrorShouldSendMessageToMessageSink() + { + var text = "customtext"; + _logger.LogError(_context, text); + + _messageSink.Verify(x => x.SendMessage(It.IsAny()), Times.Once()); + + _logger.LogError(_context, new Exception(text)); + _messageSink.Verify(x => x.SendMessage(It.IsAny()), Times.Exactly(2)); + + _logger.LogError(_context, text, new Exception(text)); + _messageSink.Verify(x => x.SendMessage(It.IsAny()), Times.Exactly(3)); + } + + [TestMethod] + public void LogWarningShouldSendMessageToMessageSink() + { + var text = "customtext"; + _logger.LogWarning(_context, text); + + _messageSink.Verify(x => x.SendMessage(It.IsAny()), Times.Once()); } -} +} \ No newline at end of file diff --git a/test/datacollector.UnitTests/TestPlatformDataCollectionSinkTests.cs b/test/datacollector.UnitTests/TestPlatformDataCollectionSinkTests.cs index 9522d1b4bd..bcea8254cd 100644 --- a/test/datacollector.UnitTests/TestPlatformDataCollectionSinkTests.cs +++ b/test/datacollector.UnitTests/TestPlatformDataCollectionSinkTests.cs @@ -1,128 +1,124 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests -{ - using System; - using System.ComponentModel; - using System.IO; +namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.ComponentModel; +using System.IO; - using Moq; +using Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; +using TestTools.UnitTesting; - [TestClass] - public class TestPlatformDataCollectionSinkTests - { - private Mock attachmentManager; +using Moq; - private DataCollectorConfig dataCollectorConfig; +[TestClass] +public class TestPlatformDataCollectionSinkTests +{ + private readonly Mock _attachmentManager; - private TestPlatformDataCollectionSink dataCollectionSink; + private readonly DataCollectorConfig _dataCollectorConfig; - private bool isEventHandlerInvoked = false; - private static readonly string TempDirectoryPath = Path.GetTempPath(); + private TestPlatformDataCollectionSink _dataCollectionSink; - public TestPlatformDataCollectionSinkTests() - { - this.attachmentManager = new Mock(); - this.dataCollectorConfig = new DataCollectorConfig(typeof(CustomDataCollector)); - this.dataCollectionSink = new TestPlatformDataCollectionSink(this.attachmentManager.Object, this.dataCollectorConfig); - this.isEventHandlerInvoked = false; - } + private bool _isEventHandlerInvoked = false; + private static readonly string TempDirectoryPath = Path.GetTempPath(); - [TestCleanup] - public void Cleanup() - { - File.Delete(Path.Combine(TempDirectoryPath, "filename.txt")); - } + public TestPlatformDataCollectionSinkTests() + { + _attachmentManager = new Mock(); + _dataCollectorConfig = new DataCollectorConfig(typeof(CustomDataCollector)); + _dataCollectionSink = new TestPlatformDataCollectionSink(_attachmentManager.Object, _dataCollectorConfig); + _isEventHandlerInvoked = false; + } - [TestMethod] - public void SendFileAsyncShouldThrowExceptionIfFileTransferInformationIsNull() - { - Assert.ThrowsException(() => - { - this.dataCollectionSink.SendFileAsync(default); - }); - } + [TestCleanup] + public void Cleanup() + { + File.Delete(Path.Combine(TempDirectoryPath, "filename.txt")); + } - [TestMethod] - public void SendFileAsyncShouldInvokeAttachmentManagerWithValidFileTransferInfo() - { - var filename = Path.Combine(TempDirectoryPath, "filename.txt"); - File.WriteAllText(filename, string.Empty); + [TestMethod] + public void SendFileAsyncShouldThrowExceptionIfFileTransferInformationIsNull() + { + Assert.ThrowsException(() => _dataCollectionSink.SendFileAsync(default)); + } - var guid = Guid.NewGuid(); - var sessionId = new SessionId(guid); - var context = new DataCollectionContext(sessionId); + [TestMethod] + public void SendFileAsyncShouldInvokeAttachmentManagerWithValidFileTransferInfo() + { + var filename = Path.Combine(TempDirectoryPath, "filename.txt"); + File.WriteAllText(filename, string.Empty); - var fileTransferInfo = new FileTransferInformation(context, filename, false); + var guid = Guid.NewGuid(); + var sessionId = new SessionId(guid); + var context = new DataCollectionContext(sessionId); - this.dataCollectionSink.SendFileAsync(fileTransferInfo); + var fileTransferInfo = new FileTransferInformation(context, filename, false); - this.attachmentManager.Verify(x => x.AddAttachment(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once()); - } + _dataCollectionSink.SendFileAsync(fileTransferInfo); - [TestMethod] - public void SendFileAsyncShouldInvokeSendFileCompletedIfRegistered() - { - var filename = Path.Combine(TempDirectoryPath, "filename.txt"); - File.WriteAllText(filename, string.Empty); + _attachmentManager.Verify(x => x.AddAttachment(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once()); + } - var guid = Guid.NewGuid(); - var sessionId = new SessionId(guid); - var context = new DataCollectionContext(sessionId); + [TestMethod] + public void SendFileAsyncShouldInvokeSendFileCompletedIfRegistered() + { + var filename = Path.Combine(TempDirectoryPath, "filename.txt"); + File.WriteAllText(filename, string.Empty); - var fileTransferInfo = new FileTransferInformation(context, filename, false); + var guid = Guid.NewGuid(); + var sessionId = new SessionId(guid); + var context = new DataCollectionContext(sessionId); - var attachmentManager = new DataCollectionAttachmentManager(); - attachmentManager.Initialize(sessionId, TempDirectoryPath, new Mock().Object); + var fileTransferInfo = new FileTransferInformation(context, filename, false); - this.dataCollectionSink = new TestPlatformDataCollectionSink(attachmentManager, this.dataCollectorConfig); - this.dataCollectionSink.SendFileCompleted += SendFileCompleted_Handler; - this.dataCollectionSink.SendFileAsync(fileTransferInfo); + var attachmentManager = new DataCollectionAttachmentManager(); + attachmentManager.Initialize(sessionId, TempDirectoryPath, new Mock().Object); - var result = attachmentManager.GetAttachments(context); + _dataCollectionSink = new TestPlatformDataCollectionSink(attachmentManager, _dataCollectorConfig); + _dataCollectionSink.SendFileCompleted += SendFileCompleted_Handler; + _dataCollectionSink.SendFileAsync(fileTransferInfo); - Assert.IsNotNull(result); - Assert.IsTrue(this.isEventHandlerInvoked); - } + var result = attachmentManager.GetAttachments(context); - [TestMethod] - public void SendFileAsyncShouldInvokeAttachmentManagerWithValidFileTransferInfoOverLoaded1() - { - var filename = Path.Combine(TempDirectoryPath, "filename.txt"); - File.WriteAllText(filename, string.Empty); + Assert.IsNotNull(result); + Assert.IsTrue(_isEventHandlerInvoked); + } - var guid = Guid.NewGuid(); - var sessionId = new SessionId(guid); - var context = new DataCollectionContext(sessionId); + [TestMethod] + public void SendFileAsyncShouldInvokeAttachmentManagerWithValidFileTransferInfoOverLoaded1() + { + var filename = Path.Combine(TempDirectoryPath, "filename.txt"); + File.WriteAllText(filename, string.Empty); - this.dataCollectionSink.SendFileAsync(context, filename, false); + var guid = Guid.NewGuid(); + var sessionId = new SessionId(guid); + var context = new DataCollectionContext(sessionId); - this.attachmentManager.Verify(x => x.AddAttachment(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once()); - } + _dataCollectionSink.SendFileAsync(context, filename, false); - [TestMethod] - public void SendFileAsyncShouldInvokeAttachmentManagerWithValidFileTransferInfoOverLoaded2() - { - var filename = Path.Combine(TempDirectoryPath, "filename.txt"); - File.WriteAllText(filename, string.Empty); + _attachmentManager.Verify(x => x.AddAttachment(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once()); + } - var guid = Guid.NewGuid(); - var sessionId = new SessionId(guid); - var context = new DataCollectionContext(sessionId); + [TestMethod] + public void SendFileAsyncShouldInvokeAttachmentManagerWithValidFileTransferInfoOverLoaded2() + { + var filename = Path.Combine(TempDirectoryPath, "filename.txt"); + File.WriteAllText(filename, string.Empty); + + var guid = Guid.NewGuid(); + var sessionId = new SessionId(guid); + var context = new DataCollectionContext(sessionId); - this.dataCollectionSink.SendFileAsync(context, filename, string.Empty, false); + _dataCollectionSink.SendFileAsync(context, filename, string.Empty, false); - this.attachmentManager.Verify(x => x.AddAttachment(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once()); - } + _attachmentManager.Verify(x => x.AddAttachment(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once()); + } - void SendFileCompleted_Handler(object sender, AsyncCompletedEventArgs e) - { - this.isEventHandlerInvoked = true; - } + void SendFileCompleted_Handler(object sender, AsyncCompletedEventArgs e) + { + _isEventHandlerInvoked = true; } } \ No newline at end of file diff --git a/test/testhost.UnitTests/AppDomainEngineInvokerTests.cs b/test/testhost.UnitTests/AppDomainEngineInvokerTests.cs index 4d75b7ec9c..7f827c325f 100644 --- a/test/testhost.UnitTests/AppDomainEngineInvokerTests.cs +++ b/test/testhost.UnitTests/AppDomainEngineInvokerTests.cs @@ -1,24 +1,23 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace testhost.UnitTests -{ #if NETFRAMEWORK - using Microsoft.VisualStudio.TestPlatform.TestHost; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System; - using System.IO; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; - using System.Xml.Linq; - using System.Text; - - [TestClass] - public class AppDomainEngineInvokerTests - { - private const string XmlNamespace = "urn:schemas-microsoft-com:asm.v1"; - private const string testHostConfigXml = @" +namespace testhost.UnitTests; + +using Microsoft.VisualStudio.TestPlatform.TestHost; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.IO; +using System.Collections.Generic; +using System.Linq; +using System.Xml.Linq; +using System.Text; + +[TestClass] +public class AppDomainEngineInvokerTests +{ + private const string XmlNamespace = "urn:schemas-microsoft-com:asm.v1"; + private const string TestHostConfigXml = @" @@ -43,86 +42,86 @@ public class AppDomainEngineInvokerTests "; - [TestMethod] - public void AppDomainEngineInvokerShouldCreateNewAppDomain() - { - var tempFile = Path.GetTempFileName(); - var appDomainInvoker = new TestableEngineInvoker(tempFile); + [TestMethod] + public void AppDomainEngineInvokerShouldCreateNewAppDomain() + { + var tempFile = Path.GetTempFileName(); + var appDomainInvoker = new TestableEngineInvoker(tempFile); - Assert.IsNotNull(appDomainInvoker.NewAppDomain, "New AppDomain must be created."); - Assert.IsNotNull(appDomainInvoker.ActualInvoker, "Invoker must be created."); - Assert.AreNotEqual(AppDomain.CurrentDomain.FriendlyName, appDomainInvoker.NewAppDomain.FriendlyName, - "New AppDomain must be different from default one."); - } + Assert.IsNotNull(appDomainInvoker.NewAppDomain, "New AppDomain must be created."); + Assert.IsNotNull(appDomainInvoker.ActualInvoker, "Invoker must be created."); + Assert.AreNotEqual(AppDomain.CurrentDomain.FriendlyName, appDomainInvoker.NewAppDomain.FriendlyName, + "New AppDomain must be different from default one."); + } - [TestMethod] - public void AppDomainEngineInvokerShouldInvokeEngineInNewDomainAndUseTestHostConfigFile() - { - var tempFile = Path.GetTempFileName(); - var appDomainInvoker = new TestableEngineInvoker(tempFile); + [TestMethod] + public void AppDomainEngineInvokerShouldInvokeEngineInNewDomainAndUseTestHostConfigFile() + { + var tempFile = Path.GetTempFileName(); + var appDomainInvoker = new TestableEngineInvoker(tempFile); - var newAppDomain = appDomainInvoker.NewAppDomain; + var newAppDomain = appDomainInvoker.NewAppDomain; - Assert.IsNotNull(newAppDomain, "New AppDomain must be created."); - Assert.IsNotNull(appDomainInvoker.ActualInvoker, "Invoker must be created."); - Assert.AreNotEqual(AppDomain.CurrentDomain.FriendlyName, - (appDomainInvoker.ActualInvoker as MockEngineInvoker).DomainFriendlyName, - "Engine must be invoked in new domain."); + Assert.IsNotNull(newAppDomain, "New AppDomain must be created."); + Assert.IsNotNull(appDomainInvoker.ActualInvoker, "Invoker must be created."); + Assert.AreNotEqual(AppDomain.CurrentDomain.FriendlyName, + (appDomainInvoker.ActualInvoker as MockEngineInvoker).DomainFriendlyName, + "Engine must be invoked in new domain."); - Assert.AreEqual(newAppDomain.SetupInformation.ConfigurationFile, AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, - "TestHost config file must be used in the absence of user config file."); - } + Assert.AreEqual(newAppDomain.SetupInformation.ConfigurationFile, AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, + "TestHost config file must be used in the absence of user config file."); + } - [TestMethod] - public void AppDomainEngineInvokerShouldUseTestHostStartupConfigAndRuntimeAfterMerging() - { - string appConfig = @" + [TestMethod] + public void AppDomainEngineInvokerShouldUseTestHostStartupConfigAndRuntimeAfterMerging() + { + string appConfig = @" "; - var doc = TestableEngineInvoker.MergeConfigXmls(appConfig, testHostConfigXml); + var doc = TestableEngineInvoker.MergeConfigXmls(appConfig, TestHostConfigXml); - var startupElements = doc.Descendants("startup"); + var startupElements = doc.Descendants("startup"); - Assert.AreEqual(1, startupElements.Count(), "Merged config must have only one 'startup' element"); + Assert.AreEqual(1, startupElements.Count(), "Merged config must have only one 'startup' element"); - var supportedRuntimeXml = startupElements.First().Descendants("supportedRuntime").FirstOrDefault()?.ToString(); - Assert.AreEqual(@"", supportedRuntimeXml, - "TestHost Supported Runtime must be used on merging"); + var supportedRuntimeXml = startupElements.First().Descendants("supportedRuntime").FirstOrDefault()?.ToString(); + Assert.AreEqual(@"", supportedRuntimeXml, + "TestHost Supported Runtime must be used on merging"); - var runtimeEle = doc.Descendants("runtime").FirstOrDefault(); - Assert.IsNotNull(runtimeEle, "Runtime element must be present"); + var runtimeEle = doc.Descendants("runtime").FirstOrDefault(); + Assert.IsNotNull(runtimeEle, "Runtime element must be present"); - var legacyUnhandledEleExpectedXml = @""; + var legacyUnhandledEleExpectedXml = @""; - Assert.AreEqual(legacyUnhandledEleExpectedXml, runtimeEle.Descendants("legacyUnhandledExceptionPolicy").First()?.ToString(), - "legacyUnhandledExceptionPolicy element must be of the TestHost one."); + Assert.AreEqual(legacyUnhandledEleExpectedXml, runtimeEle.Descendants("legacyUnhandledExceptionPolicy").First()?.ToString(), + "legacyUnhandledExceptionPolicy element must be of the TestHost one."); - Assert.IsFalse(runtimeEle.ToString().Contains("probing"), "Probing element of TestHost must not be present."); + Assert.IsFalse(runtimeEle.ToString().Contains("probing"), "Probing element of TestHost must not be present."); - var assemblyBindingXName = XName.Get("assemblyBinding", XmlNamespace); - var mergedDocAssemblyBindingNodes = runtimeEle.Descendants(assemblyBindingXName); - Assert.AreEqual(1, mergedDocAssemblyBindingNodes.Count(), "AssemblyRedirect of TestHost must be present."); + var assemblyBindingXName = XName.Get("assemblyBinding", XmlNamespace); + var mergedDocAssemblyBindingNodes = runtimeEle.Descendants(assemblyBindingXName); + Assert.AreEqual(1, mergedDocAssemblyBindingNodes.Count(), "AssemblyRedirect of TestHost must be present."); - var dependentAssemblyXName = XName.Get("dependentAssembly", XmlNamespace); - var dependentAssemblyNodes = mergedDocAssemblyBindingNodes.First().Descendants(dependentAssemblyXName); - Assert.AreEqual(1, dependentAssemblyNodes.Count(), "AssemblyRedirect of TestHost must be present."); - Assert.IsTrue(dependentAssemblyNodes.First().ToString().Contains("Microsoft.VisualStudio.TestPlatform.ObjectModel"), "Correct AssemblyRedirect must be present."); + var dependentAssemblyXName = XName.Get("dependentAssembly", XmlNamespace); + var dependentAssemblyNodes = mergedDocAssemblyBindingNodes.First().Descendants(dependentAssemblyXName); + Assert.AreEqual(1, dependentAssemblyNodes.Count(), "AssemblyRedirect of TestHost must be present."); + Assert.IsTrue(dependentAssemblyNodes.First().ToString().Contains("Microsoft.VisualStudio.TestPlatform.ObjectModel"), "Correct AssemblyRedirect must be present."); - var diagEle = doc.Descendants("system.diagnostics").FirstOrDefault(); - var appSettingsEle = doc.Descendants("appSettings").FirstOrDefault(); + var diagEle = doc.Descendants("system.diagnostics").FirstOrDefault(); + var appSettingsEle = doc.Descendants("appSettings").FirstOrDefault(); - Assert.IsNull(diagEle, "No Diagnostics element must be present as user config does not have it."); - Assert.IsNull(appSettingsEle, "No AppSettings element must be present as user config does not have it."); - } + Assert.IsNull(diagEle, "No Diagnostics element must be present as user config does not have it."); + Assert.IsNull(appSettingsEle, "No AppSettings element must be present as user config does not have it."); + } - [TestMethod] - public void AppDomainEngineInvokerShouldOnlyMergeAssemblyRedirectionsFromTestHost() - { - string appConfig = @" + [TestMethod] + public void AppDomainEngineInvokerShouldOnlyMergeAssemblyRedirectionsFromTestHost() + { + string appConfig = @" @@ -135,39 +134,39 @@ public void AppDomainEngineInvokerShouldOnlyMergeAssemblyRedirectionsFromTestHos "; - var doc = TestableEngineInvoker.MergeConfigXmls(appConfig, testHostConfigXml); + var doc = TestableEngineInvoker.MergeConfigXmls(appConfig, TestHostConfigXml); - var runtimeEle = doc.Descendants("runtime").FirstOrDefault(); + var runtimeEle = doc.Descendants("runtime").FirstOrDefault(); - Assert.AreEqual(0, runtimeEle.Descendants("legacyUnhandledExceptionPolicy").Count(), "legacyUnhandledExceptionPolicy element must NOT be present."); + Assert.AreEqual(0, runtimeEle.Descendants("legacyUnhandledExceptionPolicy").Count(), "legacyUnhandledExceptionPolicy element must NOT be present."); - var probingXName = XName.Get("probing", XmlNamespace); - var probingEleNodes = runtimeEle.Descendants(probingXName); - Assert.AreEqual(1, probingEleNodes.Count(), "Only one Probing element of UserConfig must be present."); - Assert.AreEqual(@"", probingEleNodes.First().ToString(), "Probing element must be correct."); + var probingXName = XName.Get("probing", XmlNamespace); + var probingEleNodes = runtimeEle.Descendants(probingXName); + Assert.AreEqual(1, probingEleNodes.Count(), "Only one Probing element of UserConfig must be present."); + Assert.AreEqual(@"", probingEleNodes.First().ToString(), "Probing element must be correct."); - var assemblyBindingXName = XName.Get("assemblyBinding", XmlNamespace); - var mergedDocAssemblyBindingNodes = runtimeEle.Descendants(assemblyBindingXName); - Assert.AreEqual(1, mergedDocAssemblyBindingNodes.Count(), "AssemblyBinding Ele must be present."); + var assemblyBindingXName = XName.Get("assemblyBinding", XmlNamespace); + var mergedDocAssemblyBindingNodes = runtimeEle.Descendants(assemblyBindingXName); + Assert.AreEqual(1, mergedDocAssemblyBindingNodes.Count(), "AssemblyBinding Ele must be present."); - var dependentAssemblyXName = XName.Get("dependentAssembly", XmlNamespace); - var dependentAssemblyNodes = mergedDocAssemblyBindingNodes.First().Descendants(dependentAssemblyXName); - Assert.AreEqual(2, dependentAssemblyNodes.Count(), "AssemblyBinding of TestHost must be present."); + var dependentAssemblyXName = XName.Get("dependentAssembly", XmlNamespace); + var dependentAssemblyNodes = mergedDocAssemblyBindingNodes.First().Descendants(dependentAssemblyXName); + Assert.AreEqual(2, dependentAssemblyNodes.Count(), "AssemblyBinding of TestHost must be present."); - Assert.IsTrue(dependentAssemblyNodes.ElementAt(0).ToString().Contains("Microsoft.VisualStudio.UnitTests"), "First AssemblyRedirect must be of UserConfig."); - Assert.IsTrue(dependentAssemblyNodes.ElementAt(1).ToString().Contains("Microsoft.VisualStudio.TestPlatform.ObjectModel"), "Second AssemblyRedirect must be from TestHost Node."); + Assert.IsTrue(dependentAssemblyNodes.ElementAt(0).ToString().Contains("Microsoft.VisualStudio.UnitTests"), "First AssemblyRedirect must be of UserConfig."); + Assert.IsTrue(dependentAssemblyNodes.ElementAt(1).ToString().Contains("Microsoft.VisualStudio.TestPlatform.ObjectModel"), "Second AssemblyRedirect must be from TestHost Node."); - var diagEle = doc.Descendants("system.diagnostics").FirstOrDefault(); - var appSettingsEle = doc.Descendants("appSettings").FirstOrDefault(); + var diagEle = doc.Descendants("system.diagnostics").FirstOrDefault(); + var appSettingsEle = doc.Descendants("appSettings").FirstOrDefault(); - Assert.IsNull(diagEle, "No Diagnostics element must be present as user config does not have it."); - Assert.IsNull(appSettingsEle, "No AppSettings element must be present as user config does not have it."); - } + Assert.IsNull(diagEle, "No Diagnostics element must be present as user config does not have it."); + Assert.IsNull(appSettingsEle, "No AppSettings element must be present as user config does not have it."); + } - [TestMethod] - public void AppDomainEngineInvokerShouldUseDiagAndAppSettingsElementsUnMergedFromUserConfig() - { - string appConfig = @" + [TestMethod] + public void AppDomainEngineInvokerShouldUseDiagAndAppSettingsElementsUnMergedFromUserConfig() + { + string appConfig = @" @@ -179,52 +178,51 @@ public void AppDomainEngineInvokerShouldUseDiagAndAppSettingsElementsUnMergedFro "; - var doc = TestableEngineInvoker.MergeConfigXmls(appConfig,testHostConfigXml); + var doc = TestableEngineInvoker.MergeConfigXmls(appConfig, TestHostConfigXml); - var diagEle = doc.Descendants("system.diagnostics").FirstOrDefault(); - var appSettingsEle = doc.Descendants("appSettings").FirstOrDefault(); + var diagEle = doc.Descendants("system.diagnostics").FirstOrDefault(); + var appSettingsEle = doc.Descendants("appSettings").FirstOrDefault(); - Assert.IsNotNull(diagEle, "Diagnostics element must be retained from user config."); - Assert.IsNotNull(appSettingsEle, "AppSettings element must be retained from user config."); + Assert.IsNotNull(diagEle, "Diagnostics element must be retained from user config."); + Assert.IsNotNull(appSettingsEle, "AppSettings element must be retained from user config."); - var diagAddNodes = diagEle.Descendants("add"); - Assert.AreEqual(1, diagAddNodes.Count(), "Only switches from user config should be present."); - Assert.AreEqual(@"", diagAddNodes.First().ToString(), - "Correct Switch must be merged."); + var diagAddNodes = diagEle.Descendants("add"); + Assert.AreEqual(1, diagAddNodes.Count(), "Only switches from user config should be present."); + Assert.AreEqual(@"", diagAddNodes.First().ToString(), + "Correct Switch must be merged."); + + var appSettingsAddNodes = appSettingsEle.Descendants("add"); + Assert.AreEqual(1, appSettingsAddNodes.Count(), "Only switches from user config should be present."); + Assert.AreEqual(@"", appSettingsAddNodes.First().ToString(), + "Correct Switch must be merged."); + } - var appSettingsAddNodes = appSettingsEle.Descendants("add"); - Assert.AreEqual(1, appSettingsAddNodes.Count(), "Only switches from user config should be present."); - Assert.AreEqual(@"", appSettingsAddNodes.First().ToString(), - "Correct Switch must be merged."); + private class TestableEngineInvoker : AppDomainEngineInvoker + { + public TestableEngineInvoker(string testSourcePath) : base(testSourcePath) + { } - private class TestableEngineInvoker : AppDomainEngineInvoker + public static XDocument MergeConfigXmls(string userConfigText, string testHostConfigText) { - public TestableEngineInvoker(string testSourcePath) : base(testSourcePath) - { - } + return MergeApplicationConfigFiles( + XDocument.Load(new MemoryStream(Encoding.UTF8.GetBytes(userConfigText))), + XDocument.Load(new MemoryStream(Encoding.UTF8.GetBytes(testHostConfigText)))); + } - public static XDocument MergeConfigXmls(string userConfigText, string testHostConfigText) - { - return MergeApplicationConfigFiles( - XDocument.Load(new MemoryStream(Encoding.UTF8.GetBytes(userConfigText))), - XDocument.Load(new MemoryStream(Encoding.UTF8.GetBytes(testHostConfigText)))); - } + public AppDomain NewAppDomain => _appDomain; - public AppDomain NewAppDomain => this.appDomain; + public IEngineInvoker ActualInvoker => _actualInvoker; + } - public IEngineInvoker ActualInvoker => this.actualInvoker; - } + private class MockEngineInvoker : MarshalByRefObject, IEngineInvoker + { + public string DomainFriendlyName { get; private set; } - private class MockEngineInvoker : MarshalByRefObject, IEngineInvoker + public void Invoke(IDictionary argsDictionary) { - public string DomainFriendlyName { get; private set; } - - public void Invoke(IDictionary argsDictionary) - { - this.DomainFriendlyName = AppDomain.CurrentDomain.FriendlyName; - } + DomainFriendlyName = AppDomain.CurrentDomain.FriendlyName; } } -#endif -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/test/testhost.UnitTests/DefaultEngineInvokerTests.cs b/test/testhost.UnitTests/DefaultEngineInvokerTests.cs index 34fb8c9a31..606470b266 100644 --- a/test/testhost.UnitTests/DefaultEngineInvokerTests.cs +++ b/test/testhost.UnitTests/DefaultEngineInvokerTests.cs @@ -1,137 +1,135 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace testhost.UnitTests +namespace testhost.UnitTests; + +using System; +using System.Collections.Generic; +using System.Diagnostics; + +using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.TestHost; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class DefaultEngineInvokerTests { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.TestHost; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - - using CommunicationUtilitiesResources = - Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources.Resources; - using CoreUtilitiesConstants = Microsoft.VisualStudio.TestPlatform.CoreUtilities.Constants; - - [TestClass] - public class DefaultEngineInvokerTests + private const int ParentProcessId = 27524; + private static readonly IDictionary ArgsDictionary = new Dictionary { - private const int ParentProcessId = 27524; - private static readonly IDictionary argsDictionary = new Dictionary - { - { "--port", "21291" }, - { "--endpoint", "127.0.0.1:021291" }, - { "--role", "client"}, - { "--parentprocessid", ParentProcessId.ToString() }, - { "--diag", "temp.txt"}, - { "--tracelevel", "3"}, - { "--telemetryoptedin", "false"}, - { "--datacollectionport", "21290"} - }; - private static readonly string TimoutErrorMessage = - "testhost process failed to connect to datacollector process after 90 seconds. This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout."; - - private Mock mockTestRequestHandler; - private Mock mockDataCollectionTestCaseEventSender; - private Mock mockProcssHelper; - private DefaultEngineInvoker engineInvoker; - - public DefaultEngineInvokerTests() - { - this.mockDataCollectionTestCaseEventSender = new Mock(); - this.mockTestRequestHandler = new Mock(); - this.mockProcssHelper = new Mock(); - this.engineInvoker = new DefaultEngineInvoker( - this.mockTestRequestHandler.Object, - this.mockDataCollectionTestCaseEventSender.Object, - this.mockProcssHelper.Object); - this.mockTestRequestHandler.Setup(h => h.WaitForRequestSenderConnection(It.IsAny())).Returns(true); - this.mockDataCollectionTestCaseEventSender.Setup(s => s.WaitForRequestSenderConnection(It.IsAny())).Returns(true); - } + { "--port", "21291" }, + { "--endpoint", "127.0.0.1:021291" }, + { "--role", "client"}, + { "--parentprocessid", ParentProcessId.ToString() }, + { "--diag", "temp.txt"}, + { "--tracelevel", "3"}, + { "--telemetryoptedin", "false"}, + { "--datacollectionport", "21290"} + }; + private static readonly string TimeoutErrorMessage = + "testhost process failed to connect to datacollector process after 90 seconds. This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout."; + + private readonly Mock _mockTestRequestHandler; + private readonly Mock _mockDataCollectionTestCaseEventSender; + private readonly Mock _mockProcessHelper; + private readonly DefaultEngineInvoker _engineInvoker; + + public DefaultEngineInvokerTests() + { + _mockDataCollectionTestCaseEventSender = new Mock(); + _mockTestRequestHandler = new Mock(); + _mockProcessHelper = new Mock(); + _engineInvoker = new DefaultEngineInvoker( + _mockTestRequestHandler.Object, + _mockDataCollectionTestCaseEventSender.Object, + _mockProcessHelper.Object); + _mockTestRequestHandler.Setup(h => h.WaitForRequestSenderConnection(It.IsAny())).Returns(true); + _mockDataCollectionTestCaseEventSender.Setup(s => s.WaitForRequestSenderConnection(It.IsAny())).Returns(true); + } - [TestCleanup] - public void Cleanup() - { - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, string.Empty); - } + [TestCleanup] + public void Cleanup() + { + Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, string.Empty); + } - [TestMethod] - public void InvokeShouldWaitForDefaultTimeoutIfNoEnvVariableSetDuringDataCollectorConnection() - { - this.engineInvoker.Invoke(argsDictionary); + [TestMethod] + public void InvokeShouldWaitForDefaultTimeoutIfNoEnvVariableSetDuringDataCollectorConnection() + { + _engineInvoker.Invoke(ArgsDictionary); - this.mockDataCollectionTestCaseEventSender.Verify(s => s.WaitForRequestSenderConnection(EnvironmentHelper.DefaultConnectionTimeout * 1000)); - } + _mockDataCollectionTestCaseEventSender.Verify(s => s.WaitForRequestSenderConnection(EnvironmentHelper.DefaultConnectionTimeout * 1000)); + } - [TestMethod] - public void InvokeShouldWaitBasedOnTimeoutEnvVariableDuringDataCollectorConnection() - { - var timeout = 10; - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, timeout.ToString()); - this.engineInvoker.Invoke(argsDictionary); + [TestMethod] + public void InvokeShouldWaitBasedOnTimeoutEnvVariableDuringDataCollectorConnection() + { + var timeout = 10; + Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, timeout.ToString()); + _engineInvoker.Invoke(ArgsDictionary); - this.mockDataCollectionTestCaseEventSender.Verify(s => s.WaitForRequestSenderConnection(timeout * 1000)); - } + _mockDataCollectionTestCaseEventSender.Verify(s => s.WaitForRequestSenderConnection(timeout * 1000)); + } - [TestMethod] - public void InvokeShouldThrowExceptionIfDataCollectorConnection() - { - this.mockDataCollectionTestCaseEventSender.Setup(s => s.WaitForRequestSenderConnection(It.IsAny())).Returns(false); - var message = Assert.ThrowsException(() => this.engineInvoker.Invoke(argsDictionary)).Message; + [TestMethod] + public void InvokeShouldThrowExceptionIfDataCollectorConnection() + { + _mockDataCollectionTestCaseEventSender.Setup(s => s.WaitForRequestSenderConnection(It.IsAny())).Returns(false); + var message = Assert.ThrowsException(() => _engineInvoker.Invoke(ArgsDictionary)).Message; - Assert.AreEqual(message, DefaultEngineInvokerTests.TimoutErrorMessage); - } + Assert.AreEqual(message, TimeoutErrorMessage); + } - [TestMethod] - public void InvokeShouldSetParentProcessExistCallback() - { - this.engineInvoker.Invoke(argsDictionary); + [TestMethod] + public void InvokeShouldSetParentProcessExistCallback() + { + _engineInvoker.Invoke(ArgsDictionary); - this.mockProcssHelper.Verify(h => h.SetExitCallback(ParentProcessId, It.IsAny>())); - } + _mockProcessHelper.Verify(h => h.SetExitCallback(ParentProcessId, It.IsAny>())); + } - [TestMethod] - public void InvokeShouldInitializeTraceWithCorrectTraceLevel() - { - // Setting EqtTrace.TraceLevel to a value other than info. + [TestMethod] + public void InvokeShouldInitializeTraceWithCorrectTraceLevel() + { + // Setting EqtTrace.TraceLevel to a value other than info. #if NETFRAMEWORK - EqtTrace.TraceLevel = TraceLevel.Verbose; + EqtTrace.TraceLevel = TraceLevel.Verbose; #else - EqtTrace.TraceLevel = PlatformTraceLevel.Verbose; + EqtTrace.TraceLevel = PlatformTraceLevel.Verbose; #endif - this.engineInvoker.Invoke(argsDictionary); + _engineInvoker.Invoke(ArgsDictionary); - // Verify - Assert.AreEqual(TraceLevel.Info, (TraceLevel)EqtTrace.TraceLevel); - } + // Verify + Assert.AreEqual(TraceLevel.Info, (TraceLevel)EqtTrace.TraceLevel); + } - [TestMethod] - public void InvokeShouldInitializeTraceWithVerboseTraceLevelIfInvalidTraceLevelPassed() - { - // Setting EqtTrace.TraceLevel to a value other than info. + [TestMethod] + public void InvokeShouldInitializeTraceWithVerboseTraceLevelIfInvalidTraceLevelPassed() + { + // Setting EqtTrace.TraceLevel to a value other than info. #if NETFRAMEWORK - EqtTrace.TraceLevel = TraceLevel.Warning; + EqtTrace.TraceLevel = TraceLevel.Warning; #else - EqtTrace.TraceLevel = PlatformTraceLevel.Warning; + EqtTrace.TraceLevel = PlatformTraceLevel.Warning; #endif - try - { - argsDictionary["--tracelevel"] = "5"; // int value which is not defined in TraceLevel. - this.engineInvoker.Invoke(argsDictionary); - } - finally{ - argsDictionary["--tracelevel"] = "3"; // Setting to default value of 3. - } - - // Verify - Assert.AreEqual(TraceLevel.Verbose, (TraceLevel)EqtTrace.TraceLevel); + try + { + ArgsDictionary["--tracelevel"] = "5"; // int value which is not defined in TraceLevel. + _engineInvoker.Invoke(ArgsDictionary); + } + finally + { + ArgsDictionary["--tracelevel"] = "3"; // Setting to default value of 3. } + + // Verify + Assert.AreEqual(TraceLevel.Verbose, (TraceLevel)EqtTrace.TraceLevel); } -} +} \ No newline at end of file diff --git a/test/testhost.UnitTests/DummyTests.cs b/test/testhost.UnitTests/DummyTests.cs index d7d43bd873..596f6306fd 100644 --- a/test/testhost.UnitTests/DummyTests.cs +++ b/test/testhost.UnitTests/DummyTests.cs @@ -1,19 +1,18 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace testhost.UnitTests -{ - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace testhost.UnitTests; + +using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestClass] - public class DummyTests +[TestClass] +public class DummyTests +{ + /// + /// This test is added as at least one test is required for dotnet core tfm for test scripts to succeed. + /// + [TestMethod] + public void DummyUnitTest() { - /// - /// This test is added as at least one test is required for dotnet core tfm for test scripts to succeed. - /// - [TestMethod] - public void DummyUnitTest() - { - } } -} +} \ No newline at end of file diff --git a/test/testhost.UnitTests/GlobalSuppressions.cs b/test/testhost.UnitTests/GlobalSuppressions.cs new file mode 100644 index 0000000000..3294d71d53 --- /dev/null +++ b/test/testhost.UnitTests/GlobalSuppressions.cs @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "", Scope = "namespace", Target = "~N:testhost.UnitTests")] diff --git a/test/testhost.UnitTests/Program.cs b/test/testhost.UnitTests/Program.cs index f51a7b7fe2..349a11ec30 100644 --- a/test/testhost.UnitTests/Program.cs +++ b/test/testhost.UnitTests/Program.cs @@ -1,11 +1,11 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace testhost.UnitTests +namespace testhost.UnitTests; + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/testhost.UnitTests/TestHostTraceListenerTests.cs b/test/testhost.UnitTests/TestHostTraceListenerTests.cs index fa070f1e59..86e6d9de58 100644 --- a/test/testhost.UnitTests/TestHostTraceListenerTests.cs +++ b/test/testhost.UnitTests/TestHostTraceListenerTests.cs @@ -4,156 +4,158 @@ // define trace and debug to trigger the Debug.Assert calls even when we build in Release #define DEBUG -namespace testhost.UnitTests -{ +namespace testhost.UnitTests; + #if NETCOREAPP - using Microsoft.VisualStudio.TestPlatform.TestHost; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System.Collections.Generic; - using System.Diagnostics; +using Microsoft.VisualStudio.TestPlatform.TestHost; +using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestClass] - public class TestHostTraceListenerTests - { - TraceListener[] listeners; +using System.Collections.Generic; +using System.Diagnostics; - [TestInitialize()] - public void Initialize() - { - this.listeners = new TraceListener[Trace.Listeners.Count]; - Trace.Listeners.CopyTo(this.listeners, 0); - // not using the TestHostTraceListener.Setup method here - // because that detects only default trace listeners and there won't - // be any when this is in production, so this would end up testing against - // an older version of the trace listener - Trace.Listeners.Clear(); - Trace.Listeners.Add(new TestHostTraceListener()); - } +[TestClass] +public class TestHostTraceListenerTests +{ + TraceListener[] _listeners; - [TestCleanup()] - public void Cleanup() { - Trace.Listeners.Clear(); - foreach(var listener in this.listeners) - { - Trace.Listeners.Add(listener); - } - } + [TestInitialize()] + public void Initialize() + { + _listeners = new TraceListener[Trace.Listeners.Count]; + Trace.Listeners.CopyTo(_listeners, 0); + // not using the TestHostTraceListener.Setup method here + // because that detects only default trace listeners and there won't + // be any when this is in production, so this would end up testing against + // an older version of the trace listener + Trace.Listeners.Clear(); + Trace.Listeners.Add(new TestHostTraceListener()); + } - [TestMethod] - [ExpectedException(typeof(DebugAssertException))] - public void DebugAssertThrowsDebugAssertException() + [TestCleanup()] + public void Cleanup() + { + Trace.Listeners.Clear(); + foreach (var listener in _listeners) { - Debug.Assert(false); + Trace.Listeners.Add(listener); } + } - [TestMethod] - [ExpectedException(typeof(DebugAssertException))] - public void DebugFailThrowsDebugAssertException() - { - Debug.Fail("fail"); - } + [TestMethod] + [ExpectedException(typeof(DebugAssertException))] + public void DebugAssertThrowsDebugAssertException() + { + Debug.Assert(false); + } - [TestMethod] - [ExpectedException(typeof(DebugAssertException))] - public void TraceAssertThrowsDebugAssertException() - { - Trace.Assert(false); - } + [TestMethod] + [ExpectedException(typeof(DebugAssertException))] + public void DebugFailThrowsDebugAssertException() + { + Debug.Fail("fail"); + } - [TestMethod] - [ExpectedException(typeof(DebugAssertException))] - public void TraceFailThrowsDebugAssertException() - { - Trace.Fail("fail"); - } + [TestMethod] + [ExpectedException(typeof(DebugAssertException))] + public void TraceAssertThrowsDebugAssertException() + { + Trace.Assert(false); + } - [TestMethod] - public void TraceWriteDoesNotFailTheTest() - { - Trace.Write("hello"); - } + [TestMethod] + [ExpectedException(typeof(DebugAssertException))] + public void TraceFailThrowsDebugAssertException() + { + Trace.Fail("fail"); + } - [TestMethod] - public void TraceWriteLineDoesNotFailTheTest() - { - Trace.WriteLine("hello"); - } + [TestMethod] + public void TraceWriteDoesNotFailTheTest() + { + Trace.Write("hello"); + } - [TestMethod] - public void DebugWriteDoesNotFailTheTest() - { - Debug.Write("hello"); - } + [TestMethod] + public void TraceWriteLineDoesNotFailTheTest() + { + Trace.WriteLine("hello"); + } - [TestMethod] - public void DebugWriteLineDoesNotFailTheTest() - { - Debug.WriteLine("hello"); - } + [TestMethod] + public void DebugWriteDoesNotFailTheTest() + { + Debug.Write("hello"); } - [TestClass] - public class TestHostTraceListenerRegistrationTests + [TestMethod] + public void DebugWriteLineDoesNotFailTheTest() { - TraceListener[] listeners; + Debug.WriteLine("hello"); + } +} - [TestInitialize()] - public void Initialize() - { - this.listeners = new TraceListener[Trace.Listeners.Count]; - Trace.Listeners.CopyTo(this.listeners, 0); - } +[TestClass] +public class TestHostTraceListenerRegistrationTests +{ + TraceListener[] _listeners; - [TestCleanup()] - public void Cleanup() - { - Trace.Listeners.Clear(); - foreach (var listener in this.listeners) - { - Trace.Listeners.Add(listener); - } - } + [TestInitialize()] + public void Initialize() + { + _listeners = new TraceListener[Trace.Listeners.Count]; + Trace.Listeners.CopyTo(_listeners, 0); + } - [TestMethod] - public void SetupReplacesDefaultTraceListener() + [TestCleanup()] + public void Cleanup() + { + Trace.Listeners.Clear(); + foreach (var listener in _listeners) { - Trace.Listeners.Clear(); - Trace.Listeners.Add(new DefaultTraceListener()); - TestHostTraceListener.Setup(); - - // this is what will happen in the majority of cases, there will be a single - // trace listener that will be the default trace listener and we will replace it - // with ours - Assert.IsInstanceOfType(Trace.Listeners[0], typeof(TestHostTraceListener)); + Trace.Listeners.Add(listener); } + } + + [TestMethod] + public void SetupReplacesDefaultTraceListener() + { + Trace.Listeners.Clear(); + Trace.Listeners.Add(new DefaultTraceListener()); + TestHostTraceListener.Setup(); + + // this is what will happen in the majority of cases, there will be a single + // trace listener that will be the default trace listener and we will replace it + // with ours + Assert.IsInstanceOfType(Trace.Listeners[0], typeof(TestHostTraceListener)); + } - [TestMethod] - public void SetupKeepsNonDefaultTraceListeners() + [TestMethod] + public void SetupKeepsNonDefaultTraceListeners() + { + Trace.Listeners.Clear(); + Trace.Listeners.Add(new DummyTraceListener()); + Trace.Listeners.Add(new DefaultTraceListener()); + Trace.Listeners.Add(new DummyTraceListener()); + TestHostTraceListener.Setup(); + + Assert.IsInstanceOfType(Trace.Listeners[0], typeof(DummyTraceListener)); + Assert.IsInstanceOfType(Trace.Listeners[1], typeof(TestHostTraceListener)); + Assert.IsInstanceOfType(Trace.Listeners[2], typeof(DummyTraceListener)); + } + + private class DummyTraceListener : TraceListener + { + public List Lines { get; } = new List(); + public override void Write(string message) { - Trace.Listeners.Clear(); - Trace.Listeners.Add(new DummyTraceListener()); - Trace.Listeners.Add(new DefaultTraceListener()); - Trace.Listeners.Add(new DummyTraceListener()); - TestHostTraceListener.Setup(); - - Assert.IsInstanceOfType(Trace.Listeners[0], typeof(DummyTraceListener)); - Assert.IsInstanceOfType(Trace.Listeners[1], typeof(TestHostTraceListener)); - Assert.IsInstanceOfType(Trace.Listeners[2], typeof(DummyTraceListener)); + Lines.Add(message); } - private class DummyTraceListener : TraceListener + public override void WriteLine(string message) { - public List Lines { get; } = new List(); - public override void Write(string message) - { - Lines.Add(message); - } - - public override void WriteLine(string message) - { - Lines.Add(message); - } + Lines.Add(message); } } -#endif } + +#endif \ No newline at end of file diff --git a/test/testhost.UnitTests/UnitTestClientTests.cs b/test/testhost.UnitTests/UnitTestClientTests.cs index 840e526daa..8c7bd30ef7 100644 --- a/test/testhost.UnitTests/UnitTestClientTests.cs +++ b/test/testhost.UnitTests/UnitTestClientTests.cs @@ -1,44 +1,43 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.TestExecutor.Tests +namespace Microsoft.VisualStudio.TestPlatform.TestExecutor.Tests; + +using TestTools.UnitTesting; + +[TestClass] +public class UnitTestClientTests { - using Microsoft.VisualStudio.TestTools.UnitTesting; + [TestMethod] + public void SplitArgumentsShouldHonorDoubleQuotes() + { + var expected = new string[] { "--port", "8080", "--endpoint", "127.0.0.1:8020", "--diag", "\"abc txt\"" }; + var argument = "--port 8080 --endpoint 127.0.0.1:8020 --diag \"abc txt\""; + string[] argsArr = UnitTestClient.SplitArguments(argument); + + Assert.AreEqual(6, argsArr.Length); + CollectionAssert.AreEqual(argsArr, expected); + } - [TestClass] - public class UnitTestClientTests + [TestMethod] + public void SplitArgumentsShouldHonorSingleQuotes() { - [TestMethod] - public void SplitArgumentsShouldHonorDoubleQuotes() - { - var expected = new string[] { "--port", "8080", "--endpoint", "127.0.0.1:8020", "--diag", "\"abc txt\"" }; - var argument = "--port 8080 --endpoint 127.0.0.1:8020 --diag \"abc txt\""; - string[] argsArr = UnitTestClient.SplitArguments(argument); - - Assert.AreEqual(6, argsArr.Length); - CollectionAssert.AreEqual(argsArr, expected); - } - - [TestMethod] - public void SplitArgumentsShouldHonorSingleQuotes() - { - var expected = new string[] { "--port", "8080", "--endpoint", "127.0.0.1:8020", "--diag", "\'abc txt\'" }; - var argument = "--port 8080 --endpoint 127.0.0.1:8020 --diag \'abc txt\'"; - string[] argsArr = UnitTestClient.SplitArguments(argument); - - Assert.AreEqual(6, argsArr.Length); - CollectionAssert.AreEqual(expected, argsArr); - } - - [TestMethod] - public void SplitArgumentsShouldSplitAtSpacesOutsideOfQuotes() - { - var expected = new string[] { "--port", "8080", "--endpoint", "127.0.0.1:8020", "--diag", "abc", "txt" }; - var argument = "--port 8080 --endpoint 127.0.0.1:8020 --diag abc txt"; - string[] argsArr = UnitTestClient.SplitArguments(argument); - - Assert.AreEqual(7, argsArr.Length); - CollectionAssert.AreEqual(expected, argsArr); - } + var expected = new string[] { "--port", "8080", "--endpoint", "127.0.0.1:8020", "--diag", "\'abc txt\'" }; + var argument = "--port 8080 --endpoint 127.0.0.1:8020 --diag \'abc txt\'"; + string[] argsArr = UnitTestClient.SplitArguments(argument); + + Assert.AreEqual(6, argsArr.Length); + CollectionAssert.AreEqual(expected, argsArr); + } + + [TestMethod] + public void SplitArgumentsShouldSplitAtSpacesOutsideOfQuotes() + { + var expected = new string[] { "--port", "8080", "--endpoint", "127.0.0.1:8020", "--diag", "abc", "txt" }; + var argument = "--port 8080 --endpoint 127.0.0.1:8020 --diag abc txt"; + string[] argsArr = UnitTestClient.SplitArguments(argument); + + Assert.AreEqual(7, argsArr.Length); + CollectionAssert.AreEqual(expected, argsArr); } -} +} \ No newline at end of file diff --git a/test/vstest.console.PlatformTests/AssemblyMetadataProviderTests.cs b/test/vstest.console.PlatformTests/AssemblyMetadataProviderTests.cs index e479237fa8..1cd00461ae 100644 --- a/test/vstest.console.PlatformTests/AssemblyMetadataProviderTests.cs +++ b/test/vstest.console.PlatformTests/AssemblyMetadataProviderTests.cs @@ -1,175 +1,174 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.PlatformTests +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.PlatformTests; + +using System; +using System.Diagnostics; +using System.IO; +using Microsoft.TestPlatform.TestUtilities; +using Processors; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; +using ObjectModel; +using TestTools.UnitTesting; +using Moq; +using Utilities.Helpers; +using Utilities.Helpers.Interfaces; + +[TestClass] +public class AssemblyMetadataProviderTests : IntegrationTestBase { - using System; - using System.Diagnostics; - using System.IO; - using Microsoft.TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using Utilities.Helpers; - using Utilities.Helpers.Interfaces; - - [TestClass] - public class AssemblyMetadataProviderTests : IntegrationTestBase - { - private const int ExpectedTimeForFindingArchForDotNetAssembly = 15; // In milliseconds. - private const string PerfAssertMessageFormat = "Expected Elapsed Time: {0} ms, Actual Elapsed Time: {1} ms"; + private const int ExpectedTimeForFindingArchForDotNetAssembly = 15; // In milliseconds. + private const string PerfAssertMessageFormat = "Expected Elapsed Time: {0} ms, Actual Elapsed Time: {1} ms"; - private IAssemblyMetadataProvider assemblyMetadataProvider; + private readonly IAssemblyMetadataProvider _assemblyMetadataProvider; - private Mock fileHelperMock; + private readonly Mock _fileHelperMock; - private FileHelper fileHelper; + private readonly FileHelper _fileHelper; - private bool isManagedAssemblyArchitectureTest; + private bool _isManagedAssemblyArchitectureTest; - public AssemblyMetadataProviderTests() - { - this.fileHelper = new FileHelper(); - this.fileHelperMock = new Mock(); - this.isManagedAssemblyArchitectureTest = false; - this.assemblyMetadataProvider = new AssemblyMetadataProvider(this.fileHelperMock.Object); - - this.fileHelperMock.Setup(f => - f.GetStream(It.IsAny(), FileMode.Open, FileAccess.Read)) - .Returns((filePath, mode, access) => this.fileHelper.GetStream(filePath, mode, access)); - } + public AssemblyMetadataProviderTests() + { + _fileHelper = new FileHelper(); + _fileHelperMock = new Mock(); + _isManagedAssemblyArchitectureTest = false; + _assemblyMetadataProvider = new AssemblyMetadataProvider(_fileHelperMock.Object); + + _fileHelperMock.Setup(f => + f.GetStream(It.IsAny(), FileMode.Open, FileAccess.Read)) + .Returns((filePath, mode, access) => _fileHelper.GetStream(filePath, mode, access)); + } - [TestCleanup] - public void Cleanup() + [TestCleanup] + public void Cleanup() + { + if (!_isManagedAssemblyArchitectureTest) { - if (!this.isManagedAssemblyArchitectureTest) - { - this.fileHelperMock.Verify( - f => f.GetStream(It.IsAny(), FileMode.Open, FileAccess.Read), Times.Once); - } + _fileHelperMock.Verify( + f => f.GetStream(It.IsAny(), FileMode.Open, FileAccess.Read), Times.Once); } + } - [TestMethod] - [DataRow("net451")] - [DataRow("netcoreapp2.1")] - public void GetArchitectureShouldReturnCorrentArchForx64Assembly(string framework) - { - this.TestDotnetAssemblyArch("SimpleTestProject3", framework, Architecture.X64, expectedElapsedTime: ExpectedTimeForFindingArchForDotNetAssembly); - } + [TestMethod] + [DataRow("net451")] + [DataRow("netcoreapp2.1")] + public void GetArchitectureShouldReturnCorrentArchForx64Assembly(string framework) + { + TestDotnetAssemblyArch("SimpleTestProject3", framework, Architecture.X64, expectedElapsedTime: ExpectedTimeForFindingArchForDotNetAssembly); + } - [TestMethod] - [DataRow("net451")] - [DataRow("netcoreapp2.1")] - public void GetArchitectureShouldReturnCorrentArchForx86Assembly(string framework) - { - this.TestDotnetAssemblyArch("SimpleTestProjectx86", framework, Architecture.X86, expectedElapsedTime: ExpectedTimeForFindingArchForDotNetAssembly); - } + [TestMethod] + [DataRow("net451")] + [DataRow("netcoreapp2.1")] + public void GetArchitectureShouldReturnCorrentArchForx86Assembly(string framework) + { + TestDotnetAssemblyArch("SimpleTestProjectx86", framework, Architecture.X86, expectedElapsedTime: ExpectedTimeForFindingArchForDotNetAssembly); + } - [TestMethod] - [DataRow("net451")] - [DataRow("netcoreapp2.1")] - public void GetArchitectureShouldReturnCorrentArchForAnyCPUAssembly(string framework) - { - this.TestDotnetAssemblyArch("SimpleTestProject", framework, Architecture.AnyCPU, expectedElapsedTime: ExpectedTimeForFindingArchForDotNetAssembly); - } + [TestMethod] + [DataRow("net451")] + [DataRow("netcoreapp2.1")] + public void GetArchitectureShouldReturnCorrentArchForAnyCpuAssembly(string framework) + { + TestDotnetAssemblyArch("SimpleTestProject", framework, Architecture.AnyCPU, expectedElapsedTime: ExpectedTimeForFindingArchForDotNetAssembly); + } - [TestMethod] - [DataRow("net451")] - [DataRow("netcoreapp2.1")] - public void GetArchitectureShouldReturnCorrentArchForARMAssembly(string framework) - { - this.TestDotnetAssemblyArch("SimpleTestProjectARM", framework, Architecture.ARM, expectedElapsedTime: ExpectedTimeForFindingArchForDotNetAssembly); - } + [TestMethod] + [DataRow("net451")] + [DataRow("netcoreapp2.1")] + public void GetArchitectureShouldReturnCorrentArchForArmAssembly(string framework) + { + TestDotnetAssemblyArch("SimpleTestProjectARM", framework, Architecture.ARM, expectedElapsedTime: ExpectedTimeForFindingArchForDotNetAssembly); + } - [TestMethod] - [DataRow("x86")] - [DataRow("x64")] - public void GetArchitectureForNativeDll(string platform) - { - var expectedElapsedTime = 5; - var platformPath = platform.Equals("x64") ? platform : string.Empty; - var assemblyPath = $@"{this.testEnvironment.PackageDirectory}\microsoft.testplatform.testasset.nativecpp\2.0.0\" - + $@"contentFiles\any\any\{platformPath}\Microsoft.TestPlatform.TestAsset.NativeCPP.dll"; - this.LoadAssemblyIntoMemory(assemblyPath); - var stopWatch = Stopwatch.StartNew(); - var arch = this.assemblyMetadataProvider.GetArchitecture(assemblyPath); - stopWatch.Stop(); - - Console.WriteLine("Platform:{0}, {1}", platform, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds)); - Assert.AreEqual(Enum.Parse(typeof(Architecture), platform, ignoreCase: true), arch); - - // We should not assert on time elapsed, it will vary depending on machine, & their state, commenting below assert - // Assert.IsTrue(stopWatch.ElapsedMilliseconds < expectedElapsedTime, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds)); - } + [TestMethod] + [DataRow("x86")] + [DataRow("x64")] + public void GetArchitectureForNativeDll(string platform) + { + var expectedElapsedTime = 5; + var platformPath = platform.Equals("x64") ? platform : string.Empty; + var assemblyPath = $@"{_testEnvironment.PackageDirectory}\microsoft.testplatform.testasset.nativecpp\2.0.0\" + + $@"contentFiles\any\any\{platformPath}\Microsoft.TestPlatform.TestAsset.NativeCPP.dll"; + LoadAssemblyIntoMemory(assemblyPath); + var stopWatch = Stopwatch.StartNew(); + var arch = _assemblyMetadataProvider.GetArchitecture(assemblyPath); + stopWatch.Stop(); + + Console.WriteLine("Platform:{0}, {1}", platform, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds)); + Assert.AreEqual(Enum.Parse(typeof(Architecture), platform, ignoreCase: true), arch); + + // We should not assert on time elapsed, it will vary depending on machine, & their state, commenting below assert + // Assert.IsTrue(stopWatch.ElapsedMilliseconds < expectedElapsedTime, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds)); + } - [TestMethod] - [DataRow("net451")] - [DataRow("netcoreapp2.1")] - public void GetFrameWorkForDotNetAssembly(string framework) + [TestMethod] + [DataRow("net451")] + [DataRow("netcoreapp2.1")] + public void GetFrameWorkForDotNetAssembly(string framework) + { + var expectedElapsedTime = 5; + var assemblyPath = _testEnvironment.GetTestAsset("SimpleTestProject3.dll", framework); + LoadAssemblyIntoMemory(assemblyPath); + var stopWatch = Stopwatch.StartNew(); + var actualFx = _assemblyMetadataProvider.GetFrameWork(assemblyPath); + stopWatch.Stop(); + + if (framework.Equals("net451")) { - var expectedElapsedTime = 5; - var assemblyPath = this.testEnvironment.GetTestAsset("SimpleTestProject3.dll", framework); - this.LoadAssemblyIntoMemory(assemblyPath); - var stopWatch = Stopwatch.StartNew(); - var actualFx = this.assemblyMetadataProvider.GetFrameWork(assemblyPath); - stopWatch.Stop(); - - if (framework.Equals("net451")) - { - // Reason is unknown for why full framework it is taking more time. Need to investigate. - expectedElapsedTime = 100; - Assert.AreEqual(Constants.DotNetFramework451, actualFx.FullName); - } - else - { - Assert.AreEqual(".NETCoreApp,Version=v2.1", actualFx.FullName); - } - - Console.WriteLine("Framework:{0}, {1}", framework, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds)); - - // We should not assert on time elapsed, it will vary depending on machine, & their state. - // Assert.IsTrue(stopWatch.ElapsedMilliseconds < expectedElapsedTime, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds)); + // Reason is unknown for why full framework it is taking more time. Need to investigate. + expectedElapsedTime = 100; + Assert.AreEqual(Constants.DotNetFramework451, actualFx.FullName); } - - [TestMethod] - public void GetFrameWorkForNativeDll() + else { - var expectedElapsedTime = 5; - var assemblyPath = $@"{this.testEnvironment.PackageDirectory}\microsoft.testplatform.testasset.nativecpp\2.0.0\contentFiles\any\any\Microsoft.TestPlatform.TestAsset.NativeCPP.dll"; - this.LoadAssemblyIntoMemory(assemblyPath); - var stopWatch = Stopwatch.StartNew(); - var fx = this.assemblyMetadataProvider.GetFrameWork(assemblyPath); - stopWatch.Stop(); - - Console.WriteLine(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds); - Assert.AreEqual(Framework.DefaultFramework.Name, fx.FullName); - - // We should not assert on time elapsed, it will vary depending on machine, & their state. - // Assert.IsTrue(stopWatch.ElapsedMilliseconds < expectedElapsedTime, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds)); + Assert.AreEqual(".NETCoreApp,Version=v2.1", actualFx.FullName); } - private void TestDotnetAssemblyArch(string projectName, string framework, Architecture expectedArch, long expectedElapsedTime) - { - this.isManagedAssemblyArchitectureTest = true; - var assemblyPath = this.testEnvironment.GetTestAsset(projectName + ".dll", framework); - this.LoadAssemblyIntoMemory(assemblyPath); - var stopWatch = Stopwatch.StartNew(); - var arch = this.assemblyMetadataProvider.GetArchitecture(assemblyPath); - stopWatch.Stop(); - - Console.WriteLine("Framework:{0}, {1}", framework, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds)); - Assert.AreEqual(expectedArch, arch, $"Expected: {expectedArch} Actual: {arch}"); - - // We should not assert on time elapsed, it will vary depending on machine, & their state. - // Assert.IsTrue(stopWatch.ElapsedMilliseconds < expectedElapsedTime, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds)); - } + Console.WriteLine("Framework:{0}, {1}", framework, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds)); - private void LoadAssemblyIntoMemory(string assemblyPath) - { - // Load the file into RAM in ahead to avoid performance number(expectedElapsedTime) dependence on disk read time. - File.ReadAllBytes(assemblyPath); - } + // We should not assert on time elapsed, it will vary depending on machine, & their state. + // Assert.IsTrue(stopWatch.ElapsedMilliseconds < expectedElapsedTime, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds)); + } + + [TestMethod] + public void GetFrameWorkForNativeDll() + { + var expectedElapsedTime = 5; + var assemblyPath = $@"{_testEnvironment.PackageDirectory}\microsoft.testplatform.testasset.nativecpp\2.0.0\contentFiles\any\any\Microsoft.TestPlatform.TestAsset.NativeCPP.dll"; + LoadAssemblyIntoMemory(assemblyPath); + var stopWatch = Stopwatch.StartNew(); + var fx = _assemblyMetadataProvider.GetFrameWork(assemblyPath); + stopWatch.Stop(); + + Console.WriteLine(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds); + Assert.AreEqual(Framework.DefaultFramework.Name, fx.FullName); + + // We should not assert on time elapsed, it will vary depending on machine, & their state. + // Assert.IsTrue(stopWatch.ElapsedMilliseconds < expectedElapsedTime, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds)); + } + + private void TestDotnetAssemblyArch(string projectName, string framework, Architecture expectedArch, long expectedElapsedTime) + { + _isManagedAssemblyArchitectureTest = true; + var assemblyPath = _testEnvironment.GetTestAsset(projectName + ".dll", framework); + LoadAssemblyIntoMemory(assemblyPath); + var stopWatch = Stopwatch.StartNew(); + var arch = _assemblyMetadataProvider.GetArchitecture(assemblyPath); + stopWatch.Stop(); + + Console.WriteLine("Framework:{0}, {1}", framework, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds)); + Assert.AreEqual(expectedArch, arch, $"Expected: {expectedArch} Actual: {arch}"); + + // We should not assert on time elapsed, it will vary depending on machine, & their state. + // Assert.IsTrue(stopWatch.ElapsedMilliseconds < expectedElapsedTime, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds)); + } + + private void LoadAssemblyIntoMemory(string assemblyPath) + { + // Load the file into RAM in ahead to avoid performance number(expectedElapsedTime) dependence on disk read time. + File.ReadAllBytes(assemblyPath); } -} +} \ No newline at end of file diff --git a/test/vstest.console.PlatformTests/Program.cs b/test/vstest.console.PlatformTests/Program.cs index c4dbddbd90..a57f9ce607 100644 --- a/test/vstest.console.PlatformTests/Program.cs +++ b/test/vstest.console.PlatformTests/Program.cs @@ -1,12 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.PlatformTests +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.PlatformTests; + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } -} +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/CommandLine/CommandLineOptionsTests.cs b/test/vstest.console.UnitTests/CommandLine/CommandLineOptionsTests.cs index b4dc8ff3a5..1f291b842a 100644 --- a/test/vstest.console.UnitTests/CommandLine/CommandLineOptionsTests.cs +++ b/test/vstest.console.UnitTests/CommandLine/CommandLineOptionsTests.cs @@ -1,98 +1,97 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.CommandLine +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.CommandLine; + +using System; +using System.Collections.ObjectModel; +using System.Linq; + +using Utilities.Helpers.Interfaces; +using TestTools.UnitTesting; +using Moq; +using System.IO; +using vstest.console.Internal; +using Extensions.FileSystemGlobbing; + +[TestClass] +public class CommandLineOptionsTests { - using System; - using System.Collections.ObjectModel; - using System.Linq; - - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using System.IO; - using vstest.console.Internal; - using Microsoft.Extensions.FileSystemGlobbing; - - [TestClass] - public class CommandLineOptionsTests + private readonly Mock _fileHelper; + private readonly FilePatternParser _filePatternParser; + private readonly string _currentDirectory = @"C:\\Temp"; + + public CommandLineOptionsTests() + { + _fileHelper = new Mock(); + _filePatternParser = new FilePatternParser(new Mock().Object, _fileHelper.Object); + CommandLineOptions.Instance.Reset(); + CommandLineOptions.Instance.FileHelper = _fileHelper.Object; + CommandLineOptions.Instance.FilePatternParser = _filePatternParser; + _fileHelper.Setup(fh => fh.GetCurrentDirectory()).Returns(_currentDirectory); + } + + [TestMethod] + public void CommandLineOptionsDefaultBatchSizeIsTen() + { + Assert.AreEqual(10, CommandLineOptions.Instance.BatchSize); + } + + [TestMethod] + public void CommandLineOptionsDefaultTestRunStatsEventTimeoutIsOnePointFiveSec() + { + var timeout = new TimeSpan(0, 0, 0, 1, 500); + Assert.AreEqual(timeout, CommandLineOptions.Instance.TestStatsEventTimeout); + } + + [TestMethod] + public void CommandLineOptionsGetForSourcesPropertyShouldReturnReadonlySourcesEnumerable() + { + Assert.IsTrue(CommandLineOptions.Instance.Sources is ReadOnlyCollection); + } + + [TestMethod] + public void CommandLineOptionsGetForHasPhoneContextPropertyIfTargetDeviceIsSetReturnsTrue() { - private readonly Mock fileHelper; - private FilePatternParser filePatternParser; - private readonly string currentDirectory = @"C:\\Temp"; - - public CommandLineOptionsTests() - { - this.fileHelper = new Mock(); - this.filePatternParser = new FilePatternParser(new Mock().Object, this.fileHelper.Object); - CommandLineOptions.Instance.Reset(); - CommandLineOptions.Instance.FileHelper = this.fileHelper.Object; - CommandLineOptions.Instance.FilePatternParser = this.filePatternParser; - this.fileHelper.Setup(fh => fh.GetCurrentDirectory()).Returns(currentDirectory); - } - - [TestMethod] - public void CommandLineOptionsDefaultBatchSizeIsTen() - { - Assert.AreEqual(10, CommandLineOptions.Instance.BatchSize); - } - - [TestMethod] - public void CommandLineOptionsDefaultTestRunStatsEventTimeoutIsOnePointFiveSec() - { - var timeout = new TimeSpan(0, 0, 0, 1, 500); - Assert.AreEqual(timeout, CommandLineOptions.Instance.TestStatsEventTimeout); - } - - [TestMethod] - public void CommandLineOptionsGetForSourcesPropertyShouldReturnReadonlySourcesEnumerable() - { - Assert.IsTrue(CommandLineOptions.Instance.Sources is ReadOnlyCollection); - } - - [TestMethod] - public void CommandLineOptionsGetForHasPhoneContextPropertyIfTargetDeviceIsSetReturnsTrue() - { - Assert.IsFalse(CommandLineOptions.Instance.HasPhoneContext); - - // Set some not null value - CommandLineOptions.Instance.TargetDevice = "TargetDevice"; - Assert.IsTrue(CommandLineOptions.Instance.HasPhoneContext); - } - - [TestMethod] - public void CommandLineOptionsAddSourceShouldThrowCommandLineExceptionForNullSource() - { - Assert.ThrowsException(() => CommandLineOptions.Instance.AddSource(null)); - } - - [TestMethod] - public void CommandLineOptionsAddSourceShouldConvertRelativePathToAbsolutePath() - { - string relativeTestFilePath = "DummyTestFile.txt"; - var absolutePath = Path.Combine(currentDirectory, relativeTestFilePath); - this.fileHelper.Setup(fh => fh.Exists(absolutePath)).Returns(true); - - // Pass relative path - CommandLineOptions.Instance.AddSource(relativeTestFilePath); - Assert.IsTrue(CommandLineOptions.Instance.Sources.Contains(absolutePath)); - } - - [TestMethod] - public void CommandLineOptionsAddSourceShouldThrowCommandLineExceptionForInvalidSource() - { - Assert.ThrowsException(() => CommandLineOptions.Instance.AddSource("DummySource")); - } - - [TestMethod] - public void CommandLineOptionsAddSourceShouldAddSourceForValidSource() - { - string testFilePath = Path.Combine(Path.GetTempPath(), "DummyTestFile.txt"); - this.fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); - - CommandLineOptions.Instance.AddSource(testFilePath); - - Assert.IsTrue(CommandLineOptions.Instance.Sources.Contains(testFilePath)); - } + Assert.IsFalse(CommandLineOptions.Instance.HasPhoneContext); + + // Set some not null value + CommandLineOptions.Instance.TargetDevice = "TargetDevice"; + Assert.IsTrue(CommandLineOptions.Instance.HasPhoneContext); + } + + [TestMethod] + public void CommandLineOptionsAddSourceShouldThrowCommandLineExceptionForNullSource() + { + Assert.ThrowsException(() => CommandLineOptions.Instance.AddSource(null)); + } + + [TestMethod] + public void CommandLineOptionsAddSourceShouldConvertRelativePathToAbsolutePath() + { + string relativeTestFilePath = "DummyTestFile.txt"; + var absolutePath = Path.Combine(_currentDirectory, relativeTestFilePath); + _fileHelper.Setup(fh => fh.Exists(absolutePath)).Returns(true); + + // Pass relative path + CommandLineOptions.Instance.AddSource(relativeTestFilePath); + Assert.IsTrue(CommandLineOptions.Instance.Sources.Contains(absolutePath)); + } + + [TestMethod] + public void CommandLineOptionsAddSourceShouldThrowCommandLineExceptionForInvalidSource() + { + Assert.ThrowsException(() => CommandLineOptions.Instance.AddSource("DummySource")); + } + + [TestMethod] + public void CommandLineOptionsAddSourceShouldAddSourceForValidSource() + { + string testFilePath = Path.Combine(Path.GetTempPath(), "DummyTestFile.txt"); + _fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); + + CommandLineOptions.Instance.AddSource(testFilePath); + + Assert.IsTrue(CommandLineOptions.Instance.Sources.Contains(testFilePath)); } -} +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/CommandLine/GenerateFakesUtilitiesTests.cs b/test/vstest.console.UnitTests/CommandLine/GenerateFakesUtilitiesTests.cs index 11fd95ee4a..2a870ceda7 100644 --- a/test/vstest.console.UnitTests/CommandLine/GenerateFakesUtilitiesTests.cs +++ b/test/vstest.console.UnitTests/CommandLine/GenerateFakesUtilitiesTests.cs @@ -1,44 +1,43 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.CommandLine +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.CommandLine; + +using CommandLineUtilities; +using Utilities.Helpers.Interfaces; +using TestTools.UnitTesting; +using Moq; + +[TestClass] +public class GenerateFakesUtilitiesTests { - using Microsoft.VisualStudio.TestPlatform.CommandLineUtilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; + private readonly Mock _fileHelper; + private readonly string _currentDirectory = @"C:\\Temp"; + private readonly string _runSettings = string.Empty; - [TestClass] - public class GenerateFakesUtilitiesTests + public GenerateFakesUtilitiesTests() { - private readonly Mock fileHelper; - private readonly string currentDirectory = @"C:\\Temp"; - private string runSettings = string.Empty; - - public GenerateFakesUtilitiesTests() - { - this.fileHelper = new Mock(); - CommandLineOptions.Instance.Reset(); - CommandLineOptions.Instance.FileHelper = this.fileHelper.Object; - this.fileHelper.Setup(fh => fh.GetCurrentDirectory()).Returns(currentDirectory); - this.runSettings = @".netstandard,Version=5.0"; - } - - [TestMethod] - public void CommandLineOptionsDefaultDisableAutoFakesIsFalse() - { - Assert.IsFalse(CommandLineOptions.Instance.DisableAutoFakes); - } - - [TestMethod] - public void FakesShouldNotBeGeneratedIfDisableAutoFakesSetToTrue() - { - CommandLineOptions.Instance.DisableAutoFakes = true; - string runSettingsXml = @".netstandard,Version=5.0"; - - GenerateFakesUtilities.GenerateFakesSettings(CommandLineOptions.Instance, new string[] { }, ref runSettingsXml); - Assert.AreEqual(runSettingsXml, this.runSettings); - } + _fileHelper = new Mock(); + CommandLineOptions.Instance.Reset(); + CommandLineOptions.Instance.FileHelper = _fileHelper.Object; + _fileHelper.Setup(fh => fh.GetCurrentDirectory()).Returns(_currentDirectory); + _runSettings = @".netstandard,Version=5.0"; + } + [TestMethod] + public void CommandLineOptionsDefaultDisableAutoFakesIsFalse() + { + Assert.IsFalse(CommandLineOptions.Instance.DisableAutoFakes); } -} + + [TestMethod] + public void FakesShouldNotBeGeneratedIfDisableAutoFakesSetToTrue() + { + CommandLineOptions.Instance.DisableAutoFakes = true; + string runSettingsXml = @".netstandard,Version=5.0"; + + GenerateFakesUtilities.GenerateFakesSettings(CommandLineOptions.Instance, new string[] { }, ref runSettingsXml); + Assert.AreEqual(runSettingsXml, _runSettings); + } + +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs b/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs index 720986a29e..4ccdfcc855 100644 --- a/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs +++ b/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs @@ -1,275 +1,274 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.CommandLine; + using System.Collections.Generic; using System.Runtime.Versioning; + using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using CommandLineUtilities; +using TestTools.UnitTesting; +using Moq; -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.CommandLine +[TestClass] +public class InferHelperTests { - using Microsoft.VisualStudio.TestPlatform.CommandLineUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - - [TestClass] - public class InferHelperTests + private readonly Mock _mockAssemblyHelper; + private readonly InferHelper _inferHelper; + private readonly Framework _defaultFramework = Framework.DefaultFramework; + private readonly Architecture _defaultArchitecture = Architecture.X64; + private readonly Framework _frameworkNet45 = Framework.FromString(".NETFramework,Version=4.5"); + private readonly Framework _frameworkNet46 = Framework.FromString(".NETFramework,Version=4.6"); + private readonly Framework _frameworkNet47 = Framework.FromString(".NETFramework,Version=4.7"); + private readonly Framework _frameworkCore10 = Framework.FromString(".NETCoreApp,Version=1.0"); + private readonly Framework _frameworkCore11 = Framework.FromString(".NETCoreApp,Version=1.1"); + private readonly IDictionary _sourceFrameworks; + private readonly IDictionary _sourceArchitectures; + + public InferHelperTests() { - private readonly Mock mockAssemblyHelper; - private InferHelper inferHelper; - private readonly Framework defaultFramework = Framework.DefaultFramework; - private readonly Architecture DefaultArchitecture = Architecture.X64; - private readonly Framework frameworkNet45 = Framework.FromString(".NETFramework,Version=4.5"); - private readonly Framework frameworkNet46 = Framework.FromString(".NETFramework,Version=4.6"); - private readonly Framework frameworkNet47 = Framework.FromString(".NETFramework,Version=4.7"); - private readonly Framework frameworkCore10 = Framework.FromString(".NETCoreApp,Version=1.0"); - private readonly Framework frameworkCore11 = Framework.FromString(".NETCoreApp,Version=1.1"); - private IDictionary sourceFrameworks; - private IDictionary sourceArchitectures; - - public InferHelperTests() - { - this.mockAssemblyHelper = new Mock(); - inferHelper = new InferHelper(this.mockAssemblyHelper.Object); - sourceFrameworks = new Dictionary(); - sourceArchitectures = new Dictionary(); - } + _mockAssemblyHelper = new Mock(); + _inferHelper = new InferHelper(_mockAssemblyHelper.Object); + _sourceFrameworks = new Dictionary(); + _sourceArchitectures = new Dictionary(); + } - [TestMethod] - public void AutoDetectArchitectureShouldReturnDefaultArchitectureOnNullSources() - { - Assert.AreEqual(DefaultArchitecture, inferHelper.AutoDetectArchitecture(null, sourceArchitectures, DefaultArchitecture)); - } + [TestMethod] + public void AutoDetectArchitectureShouldReturnDefaultArchitectureOnNullSources() + { + Assert.AreEqual(_defaultArchitecture, _inferHelper.AutoDetectArchitecture(null, _sourceArchitectures, _defaultArchitecture)); + } - [TestMethod] - public void AutoDetectArchitectureShouldReturnDefaultArchitectureOnEmptySources() - { - Assert.AreEqual(DefaultArchitecture, inferHelper.AutoDetectArchitecture(new List(0), sourceArchitectures, DefaultArchitecture)); - } + [TestMethod] + public void AutoDetectArchitectureShouldReturnDefaultArchitectureOnEmptySources() + { + Assert.AreEqual(_defaultArchitecture, _inferHelper.AutoDetectArchitecture(new List(0), _sourceArchitectures, _defaultArchitecture)); + } - [TestMethod] - public void AutoDetectArchitectureShouldReturnDefaultArchitectureOnNullItemInSources() - { - Assert.AreEqual(DefaultArchitecture, inferHelper.AutoDetectArchitecture(new List(){null}, sourceArchitectures, DefaultArchitecture)); - } + [TestMethod] + public void AutoDetectArchitectureShouldReturnDefaultArchitectureOnNullItemInSources() + { + Assert.AreEqual(_defaultArchitecture, _inferHelper.AutoDetectArchitecture(new List() { null }, _sourceArchitectures, _defaultArchitecture)); + } - [TestMethod] - public void AutoDetectArchitectureShouldReturnDefaultArchitectureOnWhiteSpaceItemInSources() - { - Assert.AreEqual(DefaultArchitecture, inferHelper.AutoDetectArchitecture(new List() { " "}, sourceArchitectures, DefaultArchitecture)); - } + [TestMethod] + public void AutoDetectArchitectureShouldReturnDefaultArchitectureOnWhiteSpaceItemInSources() + { + Assert.AreEqual(_defaultArchitecture, _inferHelper.AutoDetectArchitecture(new List() { " " }, _sourceArchitectures, _defaultArchitecture)); + } - [TestMethod] - public void AutoDetectArchitectureShouldReturnCorrectArchForOneSource() - { - this.mockAssemblyHelper.Setup(ah => ah.GetArchitecture(It.IsAny())).Returns(Architecture.X86); - Assert.AreEqual(Architecture.X86, inferHelper.AutoDetectArchitecture(new List(){"1.dll"}, sourceArchitectures, DefaultArchitecture)); - this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny())); - } + [TestMethod] + public void AutoDetectArchitectureShouldReturnCorrectArchForOneSource() + { + _mockAssemblyHelper.Setup(ah => ah.GetArchitecture(It.IsAny())).Returns(Architecture.X86); + Assert.AreEqual(Architecture.X86, _inferHelper.AutoDetectArchitecture(new List() { "1.dll" }, _sourceArchitectures, _defaultArchitecture)); + _mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny())); + } - [TestMethod] - public void AutoDetectArchitectureShouldReturnCorrectDefaultArchForNotDotNetAssembly() - { - Assert.AreEqual(DefaultArchitecture, inferHelper.AutoDetectArchitecture(new List() { "NotDotNetAssebly.appx" }, sourceArchitectures, DefaultArchitecture)); - this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Never); - } + [TestMethod] + public void AutoDetectArchitectureShouldReturnCorrectDefaultArchForNotDotNetAssembly() + { + Assert.AreEqual(_defaultArchitecture, _inferHelper.AutoDetectArchitecture(new List() { "NotDotNetAssebly.appx" }, _sourceArchitectures, _defaultArchitecture)); + _mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Never); + } - [TestMethod] - public void AutoDetectArchitectureShouldSetAnyCpuArchForNotDotNetAssembly() - { - inferHelper.AutoDetectArchitecture(new List() { "NotDotNetAssebly.appx" }, sourceArchitectures, DefaultArchitecture); - Assert.AreEqual(Architecture.AnyCPU, sourceArchitectures["NotDotNetAssebly.appx"]); - } + [TestMethod] + public void AutoDetectArchitectureShouldSetAnyCpuArchForNotDotNetAssembly() + { + _inferHelper.AutoDetectArchitecture(new List() { "NotDotNetAssebly.appx" }, _sourceArchitectures, _defaultArchitecture); + Assert.AreEqual(Architecture.AnyCPU, _sourceArchitectures["NotDotNetAssebly.appx"]); + } - [TestMethod] - public void AutoDetectArchitectureShouldReturnDefaultArchForAllAnyCpuAssemblies() - { - this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) - .Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU); - Assert.AreEqual(DefaultArchitecture, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "AnyCPU2.exe", "AnyCPU3.dll" }, sourceArchitectures, DefaultArchitecture)); - this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); - } + [TestMethod] + public void AutoDetectArchitectureShouldReturnDefaultArchForAllAnyCpuAssemblies() + { + _mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) + .Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU); + Assert.AreEqual(_defaultArchitecture, _inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "AnyCPU2.exe", "AnyCPU3.dll" }, _sourceArchitectures, _defaultArchitecture)); + _mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); + } - [TestMethod] - public void AutoDetectArchitectureShouldReturnX86ArchIfOneX86AssemblyAndRestAnyCPU() - { - this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) - .Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU).Returns(Architecture.X86); - Assert.AreEqual(Architecture.X86, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "AnyCPU2.exe", "x86.dll" }, sourceArchitectures, DefaultArchitecture)); - this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); - } + [TestMethod] + public void AutoDetectArchitectureShouldReturnX86ArchIfOneX86AssemblyAndRestAnyCPU() + { + _mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) + .Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU).Returns(Architecture.X86); + Assert.AreEqual(Architecture.X86, _inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "AnyCPU2.exe", "x86.dll" }, _sourceArchitectures, _defaultArchitecture)); + _mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); + } - [TestMethod] - public void AutoDetectArchitectureShouldReturnARMArchIfOneARMAssemblyAndRestAnyCPU() - { - this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) - .Returns(Architecture.ARM).Returns(Architecture.ARM).Returns(Architecture.ARM); - Assert.AreEqual(Architecture.ARM, inferHelper.AutoDetectArchitecture(new List() { "ARM1.dll", "ARM2.dll", "ARM3.dll" }, sourceArchitectures, DefaultArchitecture)); - this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); - } + [TestMethod] + public void AutoDetectArchitectureShouldReturnARMArchIfOneARMAssemblyAndRestAnyCPU() + { + _mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) + .Returns(Architecture.ARM).Returns(Architecture.ARM).Returns(Architecture.ARM); + Assert.AreEqual(Architecture.ARM, _inferHelper.AutoDetectArchitecture(new List() { "ARM1.dll", "ARM2.dll", "ARM3.dll" }, _sourceArchitectures, _defaultArchitecture)); + _mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); + } - [TestMethod] - public void AutoDetectArchitectureShouldReturnX64ArchIfOneX64AssemblyAndRestAnyCPU() - { - this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) - .Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU).Returns(Architecture.X64); - Assert.AreEqual(Architecture.X64, inferHelper.AutoDetectArchitecture(new List() { "x64.dll", "AnyCPU2.exe", "x64.dll" }, sourceArchitectures, DefaultArchitecture)); - this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); - } + [TestMethod] + public void AutoDetectArchitectureShouldReturnX64ArchIfOneX64AssemblyAndRestAnyCPU() + { + _mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) + .Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU).Returns(Architecture.X64); + Assert.AreEqual(Architecture.X64, _inferHelper.AutoDetectArchitecture(new List() { "x64.dll", "AnyCPU2.exe", "x64.dll" }, _sourceArchitectures, _defaultArchitecture)); + _mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); + } - [TestMethod] - public void AutoDetectArchitectureShouldReturnDefaultArchOnConflictArches() - { - this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) - .Returns(Architecture.AnyCPU).Returns(Architecture.X64).Returns(Architecture.X86); - Assert.AreEqual(DefaultArchitecture, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "x64.exe", "x86.dll" }, sourceArchitectures, DefaultArchitecture)); - this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); - } + [TestMethod] + public void AutoDetectArchitectureShouldReturnDefaultArchOnConflictArches() + { + _mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) + .Returns(Architecture.AnyCPU).Returns(Architecture.X64).Returns(Architecture.X86); + Assert.AreEqual(_defaultArchitecture, _inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "x64.exe", "x86.dll" }, _sourceArchitectures, _defaultArchitecture)); + _mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); + } - [TestMethod] - public void AutoDetectArchitectureShouldPoulateSourceArchitectureDictionary() - { - this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) - .Returns(Architecture.AnyCPU).Returns(Architecture.X64).Returns(Architecture.X86); + [TestMethod] + public void AutoDetectArchitectureShouldPoulateSourceArchitectureDictionary() + { + _mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) + .Returns(Architecture.AnyCPU).Returns(Architecture.X64).Returns(Architecture.X86); - Assert.AreEqual(DefaultArchitecture, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "x64.exe", "x86.dll" }, sourceArchitectures, DefaultArchitecture)); - Assert.AreEqual(3, sourceArchitectures.Count); - Assert.AreEqual(Architecture.AnyCPU, sourceArchitectures["AnyCPU1.dll"]); - Assert.AreEqual(Architecture.X64, sourceArchitectures["x64.exe"]); - Assert.AreEqual(Architecture.X86, sourceArchitectures["x86.dll"]); + Assert.AreEqual(_defaultArchitecture, _inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "x64.exe", "x86.dll" }, _sourceArchitectures, _defaultArchitecture)); + Assert.AreEqual(3, _sourceArchitectures.Count); + Assert.AreEqual(Architecture.AnyCPU, _sourceArchitectures["AnyCPU1.dll"]); + Assert.AreEqual(Architecture.X64, _sourceArchitectures["x64.exe"]); + Assert.AreEqual(Architecture.X86, _sourceArchitectures["x86.dll"]); - this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); - } + _mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); + } - [TestMethod] - public void AutoDetectArchitectureShouldReturnDefaultArchIfthereIsNotDotNetAssemblyInSources() - { - this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) - .Returns(Architecture.AnyCPU); - Assert.AreEqual(DefaultArchitecture, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "NotDotNetAssebly.appx" }, sourceArchitectures, DefaultArchitecture)); - this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(1)); - } + [TestMethod] + public void AutoDetectArchitectureShouldReturnDefaultArchIfthereIsNotDotNetAssemblyInSources() + { + _mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) + .Returns(Architecture.AnyCPU); + Assert.AreEqual(_defaultArchitecture, _inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "NotDotNetAssebly.appx" }, _sourceArchitectures, _defaultArchitecture)); + _mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(1)); + } - [TestMethod] - public void AutoDetectFrameworkShouldReturnDefaultFrameworkOnNullSources() - { - Assert.AreEqual(defaultFramework, inferHelper.AutoDetectFramework(null, sourceFrameworks)); - } + [TestMethod] + public void AutoDetectFrameworkShouldReturnDefaultFrameworkOnNullSources() + { + Assert.AreEqual(_defaultFramework, _inferHelper.AutoDetectFramework(null, _sourceFrameworks)); + } - [TestMethod] - public void AutoDetectFrameworkShouldReturnDefaultFrameworkOnEmptySources() - { - Assert.AreEqual(defaultFramework, inferHelper.AutoDetectFramework(new List(0), sourceFrameworks)); - } + [TestMethod] + public void AutoDetectFrameworkShouldReturnDefaultFrameworkOnEmptySources() + { + Assert.AreEqual(_defaultFramework, _inferHelper.AutoDetectFramework(new List(0), _sourceFrameworks)); + } - [TestMethod] - public void AutoDetectFrameworkShouldReturnDefaultFrameworkOnNullItemInSources() - { - Assert.AreEqual(defaultFramework, inferHelper.AutoDetectFramework(new List(){null}, sourceFrameworks)); - } + [TestMethod] + public void AutoDetectFrameworkShouldReturnDefaultFrameworkOnNullItemInSources() + { + Assert.AreEqual(_defaultFramework, _inferHelper.AutoDetectFramework(new List() { null }, _sourceFrameworks)); + } - [TestMethod] - public void AutoDetectFrameworkShouldReturnDefaultFrameworkOnEmptyItemInSources() - { - Assert.AreEqual(defaultFramework.Name, inferHelper.AutoDetectFramework(new List() { string.Empty }, sourceFrameworks).Name); - } + [TestMethod] + public void AutoDetectFrameworkShouldReturnDefaultFrameworkOnEmptyItemInSources() + { + Assert.AreEqual(_defaultFramework.Name, _inferHelper.AutoDetectFramework(new List() { string.Empty }, _sourceFrameworks).Name); + } - [TestMethod] - public void AutoDetectFrameworkShouldReturnFrameworkCore10OnCore10Sources() - { - var fx = frameworkCore10; - var assemblyName = "netcoreapp.dll"; - SetupAndValidateForSingleAssembly(assemblyName, fx, true); - } + [TestMethod] + public void AutoDetectFrameworkShouldReturnFrameworkCore10OnCore10Sources() + { + var fx = _frameworkCore10; + var assemblyName = "netcoreapp.dll"; + SetupAndValidateForSingleAssembly(assemblyName, fx, true); + } - [TestMethod] - public void AutoDetectFrameworkShouldReturnFramework46On46Sources() - { - var fx = frameworkNet46; - var assemblyName = "net46.dll"; - SetupAndValidateForSingleAssembly(assemblyName, fx, true); - } + [TestMethod] + public void AutoDetectFrameworkShouldReturnFramework46On46Sources() + { + var fx = _frameworkNet46; + var assemblyName = "net46.dll"; + SetupAndValidateForSingleAssembly(assemblyName, fx, true); + } - [TestMethod] - public void AutoDetectFrameworkShouldReturnFrameworkUap10ForAppxFiles() - { - var fx = Framework.FromString(Constants.DotNetFrameworkUap10); - var assemblyName = "uwp10.appx"; - SetupAndValidateForSingleAssembly(assemblyName, fx, false); - } + [TestMethod] + public void AutoDetectFrameworkShouldReturnFrameworkUap10ForAppxFiles() + { + var fx = Framework.FromString(Constants.DotNetFrameworkUap10); + var assemblyName = "uwp10.appx"; + SetupAndValidateForSingleAssembly(assemblyName, fx, false); + } - [TestMethod] - public void AutoDetectFrameworkShouldReturnFrameworkUap10ForMsixFiles() - { - var fx = Framework.FromString(Constants.DotNetFrameworkUap10); - var assemblyName = "uwp10.msix"; - SetupAndValidateForSingleAssembly(assemblyName, fx, false); - } + [TestMethod] + public void AutoDetectFrameworkShouldReturnFrameworkUap10ForMsixFiles() + { + var fx = Framework.FromString(Constants.DotNetFrameworkUap10); + var assemblyName = "uwp10.msix"; + SetupAndValidateForSingleAssembly(assemblyName, fx, false); + } - [TestMethod] - public void AutoDetectFrameworkShouldReturnFrameworkUap10ForAppxrecipeFiles() - { - var fx = Framework.FromString(Constants.DotNetFrameworkUap10); - var assemblyName = "uwp10.appxrecipe"; - SetupAndValidateForSingleAssembly(assemblyName, fx, false); - } + [TestMethod] + public void AutoDetectFrameworkShouldReturnFrameworkUap10ForAppxrecipeFiles() + { + var fx = Framework.FromString(Constants.DotNetFrameworkUap10); + var assemblyName = "uwp10.appxrecipe"; + SetupAndValidateForSingleAssembly(assemblyName, fx, false); + } - [TestMethod] - public void AutoDetectFrameworkShouldReturnDefaultFullFrameworkForJsFiles() - { - var fx = Framework.FromString(Constants.DotNetFramework40); - var assemblyName = "vstests.js"; - SetupAndValidateForSingleAssembly(assemblyName, fx, false); - } + [TestMethod] + public void AutoDetectFrameworkShouldReturnDefaultFullFrameworkForJsFiles() + { + var fx = Framework.FromString(Constants.DotNetFramework40); + var assemblyName = "vstests.js"; + SetupAndValidateForSingleAssembly(assemblyName, fx, false); + } - [TestMethod] - public void AutoDetectFrameworkShouldReturnHighestVersionFxOnSameFxName() - { - this.mockAssemblyHelper.SetupSequence(sh => sh.GetFrameWork(It.IsAny())) - .Returns(new FrameworkName(frameworkNet46.Name)) - .Returns(new FrameworkName(frameworkNet47.Name)) - .Returns(new FrameworkName(frameworkNet45.Name)); - Assert.AreEqual(frameworkNet47.Name, inferHelper.AutoDetectFramework(new List() { "net46.dll", "net47.exe", "net45.dll" }, sourceFrameworks).Name); - this.mockAssemblyHelper.Verify(ah => ah.GetFrameWork(It.IsAny()),Times.Exactly(3)); - } + [TestMethod] + public void AutoDetectFrameworkShouldReturnHighestVersionFxOnSameFxName() + { + _mockAssemblyHelper.SetupSequence(sh => sh.GetFrameWork(It.IsAny())) + .Returns(new FrameworkName(_frameworkNet46.Name)) + .Returns(new FrameworkName(_frameworkNet47.Name)) + .Returns(new FrameworkName(_frameworkNet45.Name)); + Assert.AreEqual(_frameworkNet47.Name, _inferHelper.AutoDetectFramework(new List() { "net46.dll", "net47.exe", "net45.dll" }, _sourceFrameworks).Name); + _mockAssemblyHelper.Verify(ah => ah.GetFrameWork(It.IsAny()), Times.Exactly(3)); + } - [TestMethod] - public void AutoDetectFrameworkShouldPopulatetheDictionaryForAllTheSources() - { - this.mockAssemblyHelper.SetupSequence(sh => sh.GetFrameWork(It.IsAny())) - .Returns(new FrameworkName(frameworkNet46.Name)) - .Returns(new FrameworkName(frameworkNet47.Name)) - .Returns(new FrameworkName(frameworkNet45.Name)); - - Assert.AreEqual(frameworkNet47.Name, inferHelper.AutoDetectFramework(new List() { "net46.dll", "net47.exe", "net45.dll" }, sourceFrameworks).Name); - - Assert.AreEqual(3, sourceFrameworks.Count); - Assert.AreEqual(frameworkNet46.Name, sourceFrameworks["net46.dll"].Name); - Assert.AreEqual(frameworkNet47.Name, sourceFrameworks["net47.exe"].Name); - Assert.AreEqual(frameworkNet45.Name, sourceFrameworks["net45.dll"].Name); - this.mockAssemblyHelper.Verify(ah => ah.GetFrameWork(It.IsAny()), Times.Exactly(3)); - } + [TestMethod] + public void AutoDetectFrameworkShouldPopulatetheDictionaryForAllTheSources() + { + _mockAssemblyHelper.SetupSequence(sh => sh.GetFrameWork(It.IsAny())) + .Returns(new FrameworkName(_frameworkNet46.Name)) + .Returns(new FrameworkName(_frameworkNet47.Name)) + .Returns(new FrameworkName(_frameworkNet45.Name)); + + Assert.AreEqual(_frameworkNet47.Name, _inferHelper.AutoDetectFramework(new List() { "net46.dll", "net47.exe", "net45.dll" }, _sourceFrameworks).Name); + + Assert.AreEqual(3, _sourceFrameworks.Count); + Assert.AreEqual(_frameworkNet46.Name, _sourceFrameworks["net46.dll"].Name); + Assert.AreEqual(_frameworkNet47.Name, _sourceFrameworks["net47.exe"].Name); + Assert.AreEqual(_frameworkNet45.Name, _sourceFrameworks["net45.dll"].Name); + _mockAssemblyHelper.Verify(ah => ah.GetFrameWork(It.IsAny()), Times.Exactly(3)); + } - [TestMethod] - public void AutoDetectFrameworkShouldReturnHighestVersionFxOnEvenManyLowerVersionFxNameExists() - { - this.mockAssemblyHelper.SetupSequence(sh => sh.GetFrameWork(It.IsAny())) - .Returns(new FrameworkName(frameworkCore10.Name)) - .Returns(new FrameworkName(frameworkCore11.Name)) - .Returns(new FrameworkName(frameworkCore10.Name)); - Assert.AreEqual(frameworkCore11.Name, inferHelper.AutoDetectFramework(new List() { "netcore10_1.dll", "netcore11.dll", "netcore10_2.dll" }, sourceFrameworks).Name); - this.mockAssemblyHelper.Verify(ah => ah.GetFrameWork(It.IsAny()), Times.Exactly(3)); - } + [TestMethod] + public void AutoDetectFrameworkShouldReturnHighestVersionFxOnEvenManyLowerVersionFxNameExists() + { + _mockAssemblyHelper.SetupSequence(sh => sh.GetFrameWork(It.IsAny())) + .Returns(new FrameworkName(_frameworkCore10.Name)) + .Returns(new FrameworkName(_frameworkCore11.Name)) + .Returns(new FrameworkName(_frameworkCore10.Name)); + Assert.AreEqual(_frameworkCore11.Name, _inferHelper.AutoDetectFramework(new List() { "netcore10_1.dll", "netcore11.dll", "netcore10_2.dll" }, _sourceFrameworks).Name); + _mockAssemblyHelper.Verify(ah => ah.GetFrameWork(It.IsAny()), Times.Exactly(3)); + } - private void SetupAndValidateForSingleAssembly(string assemblyName, Framework fx, bool verify) + private void SetupAndValidateForSingleAssembly(string assemblyName, Framework fx, bool verify) + { + _mockAssemblyHelper.Setup(sh => sh.GetFrameWork(assemblyName)) + .Returns(new FrameworkName(fx.Name)); + Assert.AreEqual(fx.Name, _inferHelper.AutoDetectFramework(new List() { assemblyName }, _sourceFrameworks).Name); + if (verify) { - this.mockAssemblyHelper.Setup(sh => sh.GetFrameWork(assemblyName)) - .Returns(new FrameworkName(fx.Name)); - Assert.AreEqual(fx.Name, inferHelper.AutoDetectFramework(new List() { assemblyName }, sourceFrameworks).Name); - if (verify) - { - this.mockAssemblyHelper.Verify(ah => ah.GetFrameWork(assemblyName)); - } + _mockAssemblyHelper.Verify(ah => ah.GetFrameWork(assemblyName)); } } -} +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/CommandLine/TestRunResultAggregatorTests.cs b/test/vstest.console.UnitTests/CommandLine/TestRunResultAggregatorTests.cs index 5795a32591..58e693b987 100644 --- a/test/vstest.console.UnitTests/CommandLine/TestRunResultAggregatorTests.cs +++ b/test/vstest.console.UnitTests/CommandLine/TestRunResultAggregatorTests.cs @@ -1,141 +1,141 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.CommandLine -{ - using System; - using System.Collections.Generic; - using System.Runtime.Serialization; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.CommandLine; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; - using Moq; +using TestTools.UnitTesting; - using ObjectModel; - using ObjectModel.Client; - using ObjectModel.Logging; +using Moq; - [TestClass] - public class TestRunResultAggregatorTests - { - TestRunResultAggregator resultAggregator = TestRunResultAggregator.Instance; - Mock mockTestRunRequest; +using ObjectModel; +using ObjectModel.Client; +using ObjectModel.Logging; - [TestInitialize] - public void TestInit() - { - resultAggregator.Reset(); - mockTestRunRequest = new Mock(); - resultAggregator.RegisterTestRunEvents(mockTestRunRequest.Object); - } +[TestClass] +public class TestRunResultAggregatorTests +{ + readonly TestRunResultAggregator _resultAggregator = TestRunResultAggregator.Instance; + Mock _mockTestRunRequest; - [TestCleanup] - public void TestCleanup() - { - resultAggregator.UnregisterTestRunEvents(mockTestRunRequest.Object); - } + [TestInitialize] + public void TestInit() + { + _resultAggregator.Reset(); + _mockTestRunRequest = new Mock(); + _resultAggregator.RegisterTestRunEvents(_mockTestRunRequest.Object); + } - [TestMethod] - public void DefaultOutcomeIsPassed() - { - Assert.AreEqual(TestOutcome.Passed, resultAggregator.Outcome); - } + [TestCleanup] + public void TestCleanup() + { + _resultAggregator.UnregisterTestRunEvents(_mockTestRunRequest.Object); + } - [TestMethod] - public void MarkTestRunFailedSetsOutcomeToFailed() - { - resultAggregator.MarkTestRunFailed(); - Assert.AreEqual(TestOutcome.Failed, resultAggregator.Outcome); - } + [TestMethod] + public void DefaultOutcomeIsPassed() + { + Assert.AreEqual(TestOutcome.Passed, _resultAggregator.Outcome); + } - [TestMethod] - public void TestRunMessageHandlerForMessageLevelErrorSetsOutcomeToFailed() - { - var messageArgs = new TestRunMessageEventArgs(TestMessageLevel.Error, "bad stuff"); - mockTestRunRequest.Raise(tr => tr.TestRunMessage += null, messageArgs); - Assert.AreEqual(TestOutcome.Failed, resultAggregator.Outcome); - } + [TestMethod] + public void MarkTestRunFailedSetsOutcomeToFailed() + { + _resultAggregator.MarkTestRunFailed(); + Assert.AreEqual(TestOutcome.Failed, _resultAggregator.Outcome); + } - [TestMethod] - public void TestRunCompletionHandlerForTestRunStatisticsNullSetsOutcomeToFailed() - { - var messageArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, new TimeSpan()); - mockTestRunRequest.Raise(tr => tr.OnRunCompletion += null, messageArgs); - Assert.AreEqual(TestOutcome.Failed, resultAggregator.Outcome); - } + [TestMethod] + public void TestRunMessageHandlerForMessageLevelErrorSetsOutcomeToFailed() + { + var messageArgs = new TestRunMessageEventArgs(TestMessageLevel.Error, "bad stuff"); + _mockTestRunRequest.Raise(tr => tr.TestRunMessage += null, messageArgs); + Assert.AreEqual(TestOutcome.Failed, _resultAggregator.Outcome); + } + + [TestMethod] + public void TestRunCompletionHandlerForTestRunStatisticsNullSetsOutcomeToFailed() + { + var messageArgs = new TestRunCompleteEventArgs(null, false, false, null, null, null, new TimeSpan()); + _mockTestRunRequest.Raise(tr => tr.OnRunCompletion += null, messageArgs); + Assert.AreEqual(TestOutcome.Failed, _resultAggregator.Outcome); + } - [TestMethod] - public void TestRunCompletionHandlerForTestRunStatsWithOneOrMoreFailingTestsSetsOutcomeToFailed() + [TestMethod] + public void TestRunCompletionHandlerForTestRunStatsWithOneOrMoreFailingTestsSetsOutcomeToFailed() + { + var testOutcomeDict = new Dictionary { - var testOutcomeDict = new System.Collections.Generic.Dictionary(); - testOutcomeDict.Add(TestOutcome.Failed, 1); - var stats = new TestableTestRunStats(testOutcomeDict); + { TestOutcome.Failed, 1 } + }; + var stats = new TestableTestRunStats(testOutcomeDict); - var messageArgs = new TestRunCompleteEventArgs(stats, false, false, null, null, null, new TimeSpan()); - this.mockTestRunRequest.Raise(tr => tr.OnRunCompletion += null, messageArgs); - Assert.AreEqual(TestOutcome.Failed, resultAggregator.Outcome); - } + var messageArgs = new TestRunCompleteEventArgs(stats, false, false, null, null, null, new TimeSpan()); + _mockTestRunRequest.Raise(tr => tr.OnRunCompletion += null, messageArgs); + Assert.AreEqual(TestOutcome.Failed, _resultAggregator.Outcome); + } - [TestMethod] - public void TestRunCompletionHandlerForCanceledRunShouldSetsOutcomeToFailed() + [TestMethod] + public void TestRunCompletionHandlerForCanceledRunShouldSetsOutcomeToFailed() + { + var testOutcomeDict = new Dictionary { - var testOutcomeDict = new System.Collections.Generic.Dictionary(); - testOutcomeDict.Add(TestOutcome.Passed, 1); - var stats = new TestableTestRunStats(testOutcomeDict); + { TestOutcome.Passed, 1 } + }; + var stats = new TestableTestRunStats(testOutcomeDict); - var messageArgs = new TestRunCompleteEventArgs(stats, true, false, null, null, null, new TimeSpan()); - this.mockTestRunRequest.Raise(tr => tr.OnRunCompletion += null, messageArgs); - Assert.AreEqual(TestOutcome.Failed, resultAggregator.Outcome); - } + var messageArgs = new TestRunCompleteEventArgs(stats, true, false, null, null, null, new TimeSpan()); + _mockTestRunRequest.Raise(tr => tr.OnRunCompletion += null, messageArgs); + Assert.AreEqual(TestOutcome.Failed, _resultAggregator.Outcome); + } - [TestMethod] - public void TestRunCompletionHandlerForAbortedRunShouldSetsOutcomeToFailed() + [TestMethod] + public void TestRunCompletionHandlerForAbortedRunShouldSetsOutcomeToFailed() + { + var testOutcomeDict = new Dictionary { - var testOutcomeDict = new System.Collections.Generic.Dictionary(); - testOutcomeDict.Add(TestOutcome.Passed, 1); - var stats = new TestableTestRunStats(testOutcomeDict); + { TestOutcome.Passed, 1 } + }; + var stats = new TestableTestRunStats(testOutcomeDict); - var messageArgs = new TestRunCompleteEventArgs(stats, false, true, null, null, null, new TimeSpan()); - this.mockTestRunRequest.Raise(tr => tr.OnRunCompletion += null, messageArgs); - Assert.AreEqual(TestOutcome.Failed, resultAggregator.Outcome); - } + var messageArgs = new TestRunCompleteEventArgs(stats, false, true, null, null, null, new TimeSpan()); + _mockTestRunRequest.Raise(tr => tr.OnRunCompletion += null, messageArgs); + Assert.AreEqual(TestOutcome.Failed, _resultAggregator.Outcome); + } - #region Implementation + #region Implementation - private class TestableTestRunStats : ITestRunStatistics + private class TestableTestRunStats : ITestRunStatistics + { + public TestableTestRunStats(Dictionary stats) { - public TestableTestRunStats(Dictionary stats) - { - this.Stats = stats; - } + Stats = stats; + } - public long ExecutedTests { get; set; } + public long ExecutedTests { get; set; } - /// - /// Gets the test stats which is the test outcome versus its state. - /// - [DataMember] - public IDictionary Stats { get; private set; } + /// + /// Gets the test stats which is the test outcome versus its state. + /// + [DataMember] + public IDictionary Stats { get; private set; } - /// - /// Gets the number of tests with a specified outcome. - /// - /// The test outcome. - /// The number of tests with this outcome. - public long this[TestOutcome testOutcome] + /// + /// Gets the number of tests with a specified outcome. + /// + /// The test outcome. + /// The number of tests with this outcome. + public long this[TestOutcome testOutcome] + { + get { - get - { - if (this.Stats.TryGetValue(testOutcome, out var count)) - { - return count; - } - - return 0; - } + return Stats.TryGetValue(testOutcome, out var count) ? count : 0; } } - - #endregion } -} + + #endregion +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/ExceptionUtilities.cs b/test/vstest.console.UnitTests/ExceptionUtilities.cs index e9e6839bea..a4a4bdd323 100644 --- a/test/vstest.console.UnitTests/ExceptionUtilities.cs +++ b/test/vstest.console.UnitTests/ExceptionUtilities.cs @@ -1,35 +1,34 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; - /// - /// This only exists because there is an issue with MSTest v2 and ThrowsException with a message API. - /// Move to Assert.ThrowException() with a message once the bug is fixed. - /// - public static class ExceptionUtilities - { - public static void ThrowsException(Action action , string format, params string[] args) - { - var isExceptionThrown = false; +using TestTools.UnitTesting; - try - { - action(); - } - catch (Exception ex) - { - Assert.AreEqual(typeof(T), ex.GetType()); - isExceptionThrown = true; - var message = string.Format(format, args); - StringAssert.Contains(ex.Message, message); - } +/// +/// This only exists because there is an issue with MSTest v2 and ThrowsException with a message API. +/// Move to Assert.ThrowException() with a message once the bug is fixed. +/// +public static class ExceptionUtilities +{ + public static void ThrowsException(Action action, string format, params string[] args) + { + var isExceptionThrown = false; - Assert.IsTrue(isExceptionThrown, "No Exception Thrown"); + try + { + action(); + } + catch (Exception ex) + { + Assert.AreEqual(typeof(T), ex.GetType()); + isExceptionThrown = true; + var message = string.Format(format, args); + StringAssert.Contains(ex.Message, message); } + + Assert.IsTrue(isExceptionThrown, "No Exception Thrown"); } -} +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/ExecutorUnitTests.cs b/test/vstest.console.UnitTests/ExecutorUnitTests.cs index f5748b8c49..a9b9409a51 100644 --- a/test/vstest.console.UnitTests/ExecutorUnitTests.cs +++ b/test/vstest.console.UnitTests/ExecutorUnitTests.cs @@ -1,205 +1,204 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests -{ - using System.Collections.Generic; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Reflection; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests; - using CoreUtilities.Tracing.Interfaces; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using CoreUtilities.Tracing.Interfaces; - using Moq; +using TestTools.UnitTesting; +using Common; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Utilities; +using Moq; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; - using System; +using Utilities; - [TestClass] - public class ExecutorUnitTests - { - private Mock mockTestPlatformEventSource; +using CommandLineResources = Resources.Resources; - [TestInitialize] - public void TestInit() - { - this.mockTestPlatformEventSource = new Mock(); - } +[TestClass] +public class ExecutorUnitTests +{ + private Mock _mockTestPlatformEventSource; - /// - /// Executor should Print splash screen first - /// - [TestMethod] - public void ExecutorPrintsSplashScreenTest() - { - var mockOutput = new MockOutput(); - var exitCode = new Executor(mockOutput, this.mockTestPlatformEventSource.Object).Execute("/badArgument"); - var assemblyVersion = typeof(Executor).GetTypeInfo().Assembly.GetCustomAttribute().InformationalVersion; + [TestInitialize] + public void TestInit() + { + _mockTestPlatformEventSource = new Mock(); + } - Assert.AreEqual(1, exitCode, "Exit code must be One for bad arguments"); + /// + /// Executor should Print splash screen first + /// + [TestMethod] + public void ExecutorPrintsSplashScreenTest() + { + var mockOutput = new MockOutput(); + var exitCode = new Executor(mockOutput, _mockTestPlatformEventSource.Object).Execute("/badArgument"); + var assemblyVersion = typeof(Executor).GetTypeInfo().Assembly.GetCustomAttribute().InformationalVersion; - // Verify that messages exist - Assert.IsTrue(mockOutput.Messages.Count > 0, "Executor must print at least copyright info"); - Assert.IsNotNull(mockOutput.Messages.First().Message, "First Printed Message cannot be null or empty"); + Assert.AreEqual(1, exitCode, "Exit code must be One for bad arguments"); - // Just check first 20 characters - don't need to check whole thing as assembly version is variable - // "First Printed message must be Microsoft Copyright"); - StringAssert.Contains(mockOutput.Messages.First().Message, - CommandLineResources.MicrosoftCommandLineTitle.Substring(0, 20)); + // Verify that messages exist + Assert.IsTrue(mockOutput.Messages.Count > 0, "Executor must print at least copyright info"); + Assert.IsNotNull(mockOutput.Messages.First().Message, "First Printed Message cannot be null or empty"); - var suffixIndex = assemblyVersion.IndexOf("-"); - var version = suffixIndex == -1 ? assemblyVersion : assemblyVersion.Substring(0, suffixIndex); - StringAssert.Contains(mockOutput.Messages.First().Message, - version); - } + // Just check first 20 characters - don't need to check whole thing as assembly version is variable + // "First Printed message must be Microsoft Copyright"); + StringAssert.Contains(mockOutput.Messages.First().Message, + CommandLineResources.MicrosoftCommandLineTitle.Substring(0, 20)); - [TestMethod] - public void ExecutorShouldNotPrintsSplashScreenIfNoLogoPassed() - { - var mockOutput = new MockOutput(); - var exitCode = new Executor(mockOutput, this.mockTestPlatformEventSource.Object).Execute("--nologo"); + var suffixIndex = assemblyVersion.IndexOf("-"); + var version = suffixIndex == -1 ? assemblyVersion : assemblyVersion.Substring(0, suffixIndex); + StringAssert.Contains(mockOutput.Messages.First().Message, + version); + } - Assert.AreEqual(1, exitCode, "Exit code must be One for bad arguments"); + [TestMethod] + public void ExecutorShouldNotPrintsSplashScreenIfNoLogoPassed() + { + var mockOutput = new MockOutput(); + var exitCode = new Executor(mockOutput, _mockTestPlatformEventSource.Object).Execute("--nologo"); - // Verify that messages exist - Assert.IsTrue(mockOutput.Messages.Count == 1, "Executor should not print no valid arguments provided"); + Assert.AreEqual(1, exitCode, "Exit code must be One for bad arguments"); - // Just check first 20 characters - don't need to check whole thing as assembly version is variable - Assert.IsFalse( - mockOutput.Messages.First() - .Message.Contains(CommandLineResources.MicrosoftCommandLineTitle.Substring(0, 20)), - "First Printed message must be Microsoft Copyright"); - } + // Verify that messages exist + Assert.IsTrue(mockOutput.Messages.Count == 1, "Executor should not print no valid arguments provided"); - [TestMethod] - public void ExecutorShouldSanitizeNoLogoInput() - { - var mockOutput = new MockOutput(); - var exitCode = new Executor(mockOutput, this.mockTestPlatformEventSource.Object).Execute("--nologo"); + // Just check first 20 characters - don't need to check whole thing as assembly version is variable + Assert.IsFalse( + mockOutput.Messages.First() + .Message.Contains(CommandLineResources.MicrosoftCommandLineTitle.Substring(0, 20)), + "First Printed message must be Microsoft Copyright"); + } - Assert.AreEqual(1, exitCode, "Exit code must be One when no arguments are provided."); + [TestMethod] + public void ExecutorShouldSanitizeNoLogoInput() + { + var mockOutput = new MockOutput(); + var exitCode = new Executor(mockOutput, _mockTestPlatformEventSource.Object).Execute("--nologo"); - Assert.IsTrue(mockOutput.Messages.Any(message => message.Message.Contains(CommandLineResources.NoArgumentsProvided))); - } + Assert.AreEqual(1, exitCode, "Exit code must be One when no arguments are provided."); - /// - /// Executor should Print Error message and Help contents when no arguments are provided. - /// - [TestMethod] - public void ExecutorEmptyArgsPrintsErrorAndHelpMessage() - { - var mockOutput = new MockOutput(); - var exitCode = new Executor(mockOutput, this.mockTestPlatformEventSource.Object).Execute(null); + Assert.IsTrue(mockOutput.Messages.Any(message => message.Message.Contains(CommandLineResources.NoArgumentsProvided))); + } - Assert.AreEqual(1, exitCode, "Exit code must be One when no arguments are provided."); + /// + /// Executor should Print Error message and Help contents when no arguments are provided. + /// + [TestMethod] + public void ExecutorEmptyArgsPrintsErrorAndHelpMessage() + { + var mockOutput = new MockOutput(); + var exitCode = new Executor(mockOutput, _mockTestPlatformEventSource.Object).Execute(null); - Assert.IsTrue(mockOutput.Messages.Any(message => message.Message.Contains(CommandLineResources.NoArgumentsProvided))); - } + Assert.AreEqual(1, exitCode, "Exit code must be One when no arguments are provided."); - [TestMethod] - public void ExecutorWithInvalidArgsShouldPrintErrorMessage() - { - var mockOutput = new MockOutput(); - string badArg = "/badArgument"; - var exitCode = new Executor(mockOutput, this.mockTestPlatformEventSource.Object).Execute(badArg); + Assert.IsTrue(mockOutput.Messages.Any(message => message.Message.Contains(CommandLineResources.NoArgumentsProvided))); + } - Assert.AreEqual(1, exitCode, "Exit code must be One when no arguments are provided."); + [TestMethod] + public void ExecutorWithInvalidArgsShouldPrintErrorMessage() + { + var mockOutput = new MockOutput(); + string badArg = "/badArgument"; + var exitCode = new Executor(mockOutput, _mockTestPlatformEventSource.Object).Execute(badArg); - Assert.IsTrue(mockOutput.Messages.Any(message => message.Message.Contains(string.Format(CommandLineResources.InvalidArgument, badArg)))); - } + Assert.AreEqual(1, exitCode, "Exit code must be One when no arguments are provided."); - [TestMethod] - public void ExecutorWithInvalidArgsShouldPrintHowToUseHelpOption() - { - var mockOutput = new MockOutput(); - string badArg = "--invalidArg"; - var exitCode = new Executor(mockOutput, this.mockTestPlatformEventSource.Object).Execute(badArg); + Assert.IsTrue(mockOutput.Messages.Any(message => message.Message.Contains(string.Format(CommandLineResources.InvalidArgument, badArg)))); + } - Assert.AreEqual(1, exitCode, "Exit code must be One when no arguments are provided."); + [TestMethod] + public void ExecutorWithInvalidArgsShouldPrintHowToUseHelpOption() + { + var mockOutput = new MockOutput(); + string badArg = "--invalidArg"; + var exitCode = new Executor(mockOutput, _mockTestPlatformEventSource.Object).Execute(badArg); - Assert.IsTrue(mockOutput.Messages.Any(message => message.Message.Contains(string.Format(CommandLineResources.InvalidArgument, badArg)))); - } + Assert.AreEqual(1, exitCode, "Exit code must be One when no arguments are provided."); - [TestMethod] - public void ExecutorWithInvalidArgsAndValueShouldPrintErrorMessage() - { - var mockOutput = new MockOutput(); - string badArg = "--invalidArg:xyz"; - var exitCode = new Executor(mockOutput, this.mockTestPlatformEventSource.Object).Execute(badArg); + Assert.IsTrue(mockOutput.Messages.Any(message => message.Message.Contains(string.Format(CommandLineResources.InvalidArgument, badArg)))); + } - Assert.AreEqual(1, exitCode, "Exit code must be One when no arguments are provided."); + [TestMethod] + public void ExecutorWithInvalidArgsAndValueShouldPrintErrorMessage() + { + var mockOutput = new MockOutput(); + string badArg = "--invalidArg:xyz"; + var exitCode = new Executor(mockOutput, _mockTestPlatformEventSource.Object).Execute(badArg); - Assert.IsTrue(mockOutput.Messages.Any(message => message.Message.Contains(string.Format(CommandLineResources.InvalidArgument, badArg)))); - } + Assert.AreEqual(1, exitCode, "Exit code must be One when no arguments are provided."); - /// - /// Executor should set default runsettings value even there is no processor - /// - [TestMethod] - public void ExecuteShouldInitializeDefaultRunsettings() - { - var mockOutput = new MockOutput(); - var exitCode = new Executor(mockOutput, this.mockTestPlatformEventSource.Object).Execute(null); - RunConfiguration runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(RunSettingsManager.Instance.ActiveRunSettings.SettingsXml); - Assert.AreEqual(Constants.DefaultResultsDirectory, runConfiguration.ResultsDirectory); - Assert.AreEqual(Framework.DefaultFramework.ToString(), runConfiguration.TargetFramework.ToString()); - Assert.AreEqual(Constants.DefaultPlatform, runConfiguration.TargetPlatform); - } + Assert.IsTrue(mockOutput.Messages.Any(message => message.Message.Contains(string.Format(CommandLineResources.InvalidArgument, badArg)))); + } - [TestMethod] - public void ExecuteShouldInstrumentVsTestConsoleStart() - { - var mockOutput = new MockOutput(); - var exitCode = new Executor(mockOutput, this.mockTestPlatformEventSource.Object).Execute(It.IsAny()); + /// + /// Executor should set default runsettings value even there is no processor + /// + [TestMethod] + public void ExecuteShouldInitializeDefaultRunsettings() + { + var mockOutput = new MockOutput(); + _ = new Executor(mockOutput, _mockTestPlatformEventSource.Object).Execute(null); + RunConfiguration runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(RunSettingsManager.Instance.ActiveRunSettings.SettingsXml); + Assert.AreEqual(Constants.DefaultResultsDirectory, runConfiguration.ResultsDirectory); + Assert.AreEqual(Framework.DefaultFramework.ToString(), runConfiguration.TargetFramework.ToString()); + Assert.AreEqual(Constants.DefaultPlatform, runConfiguration.TargetPlatform); + } - this.mockTestPlatformEventSource.Verify(x => x.VsTestConsoleStart(), Times.Once); - } + [TestMethod] + public void ExecuteShouldInstrumentVsTestConsoleStart() + { + var mockOutput = new MockOutput(); + var exitCode = new Executor(mockOutput, _mockTestPlatformEventSource.Object).Execute(It.IsAny()); - [TestMethod] - public void ExecuteShouldInstrumentVsTestConsoleStop() - { - var mockOutput = new MockOutput(); - var exitCode = new Executor(mockOutput, this.mockTestPlatformEventSource.Object).Execute(It.IsAny()); + _mockTestPlatformEventSource.Verify(x => x.VsTestConsoleStart(), Times.Once); + } - this.mockTestPlatformEventSource.Verify(x => x.VsTestConsoleStop(), Times.Once); - } + [TestMethod] + public void ExecuteShouldInstrumentVsTestConsoleStop() + { + var mockOutput = new MockOutput(); + var exitCode = new Executor(mockOutput, _mockTestPlatformEventSource.Object).Execute(It.IsAny()); - [TestMethod] - public void ExecuteShouldExitWithErrorOnResponseFileException() - { - string[] args = { "@FileDoesNotExist.rsp" }; - var mockOutput = new MockOutput(); + _mockTestPlatformEventSource.Verify(x => x.VsTestConsoleStop(), Times.Once); + } - var exitCode = new Executor(mockOutput, this.mockTestPlatformEventSource.Object).Execute(args); + [TestMethod] + public void ExecuteShouldExitWithErrorOnResponseFileException() + { + string[] args = { "@FileDoesNotExist.rsp" }; + var mockOutput = new MockOutput(); - var errorMessageCount = mockOutput.Messages.Count(msg => msg.Level == OutputLevel.Error && msg.Message.Contains( + var exitCode = new Executor(mockOutput, _mockTestPlatformEventSource.Object).Execute(args); + + var errorMessageCount = mockOutput.Messages.Count(msg => msg.Level == OutputLevel.Error && msg.Message.Contains( string.Format(CultureInfo.CurrentCulture, CommandLineResources.OpenResponseFileError, args[0].Substring(1)))); - Assert.AreEqual(1, errorMessageCount, "Response File Exception should display error."); - Assert.AreEqual(1, exitCode, "Response File Exception execution should exit with error."); - } + Assert.AreEqual(1, errorMessageCount, "Response File Exception should display error."); + Assert.AreEqual(1, exitCode, "Response File Exception execution should exit with error."); + } - [TestMethod] - public void ExecuteShouldNotThrowSettingsExceptionButLogOutput() - { - var activeRunSetting = RunSettingsManager.Instance.ActiveRunSettings; - var runSettingsFile = Path.Combine(Path.GetTempPath(), "ExecutorShouldShowRightErrorMessage.runsettings"); + [TestMethod] + public void ExecuteShouldNotThrowSettingsExceptionButLogOutput() + { + var activeRunSetting = RunSettingsManager.Instance.ActiveRunSettings; + var runSettingsFile = Path.Combine(Path.GetTempPath(), "ExecutorShouldShowRightErrorMessage.runsettings"); - try + try + { + if (File.Exists(runSettingsFile)) { - if (File.Exists(runSettingsFile)) - { - File.Delete(runSettingsFile); - } + File.Delete(runSettingsFile); + } - var fileContents = @" + var fileContents = @" @@ -207,38 +206,38 @@ public void ExecuteShouldNotThrowSettingsExceptionButLogOutput() "; - File.WriteAllText(runSettingsFile, fileContents); + File.WriteAllText(runSettingsFile, fileContents); - var testSourceDllPath = Path.GetTempFileName(); - string[] args = { testSourceDllPath, "/settings:" + runSettingsFile }; - var mockOutput = new MockOutput(); + var testSourceDllPath = Path.GetTempFileName(); + string[] args = { testSourceDllPath, "/settings:" + runSettingsFile }; + var mockOutput = new MockOutput(); - var exitCode = new Executor(mockOutput, this.mockTestPlatformEventSource.Object).Execute(args); + var exitCode = new Executor(mockOutput, _mockTestPlatformEventSource.Object).Execute(args); - var result = mockOutput.Messages.Any(o => o.Level == OutputLevel.Error && o.Message.Contains("Invalid settings 'Logger'. Unexpected XmlAttribute: 'invalidName'.")); - Assert.IsTrue(result, "expecting error message : Invalid settings 'Logger'.Unexpected XmlAttribute: 'invalidName'."); - } - finally - { - File.Delete(runSettingsFile); - RunSettingsManager.Instance.SetActiveRunSettings(activeRunSetting); - } + var result = mockOutput.Messages.Any(o => o.Level == OutputLevel.Error && o.Message.Contains("Invalid settings 'Logger'. Unexpected XmlAttribute: 'invalidName'.")); + Assert.IsTrue(result, "expecting error message : Invalid settings 'Logger'.Unexpected XmlAttribute: 'invalidName'."); } - - [TestMethod] - public void ExecuteShouldReturnNonZeroExitCodeIfSettingsException() + finally { - var activeRunSetting = RunSettingsManager.Instance.ActiveRunSettings; - var runSettingsFile = Path.Combine(Path.GetTempPath(), "ExecutorShouldShowRightErrorMessage.runsettings"); + File.Delete(runSettingsFile); + RunSettingsManager.Instance.SetActiveRunSettings(activeRunSetting); + } + } + + [TestMethod] + public void ExecuteShouldReturnNonZeroExitCodeIfSettingsException() + { + var activeRunSetting = RunSettingsManager.Instance.ActiveRunSettings; + var runSettingsFile = Path.Combine(Path.GetTempPath(), "ExecutorShouldShowRightErrorMessage.runsettings"); - try + try + { + if (File.Exists(runSettingsFile)) { - if (File.Exists(runSettingsFile)) - { - File.Delete(runSettingsFile); - } + File.Delete(runSettingsFile); + } - var fileContents = @" + var fileContents = @" @@ -246,78 +245,77 @@ public void ExecuteShouldReturnNonZeroExitCodeIfSettingsException() "; - File.WriteAllText(runSettingsFile, fileContents); + File.WriteAllText(runSettingsFile, fileContents); - string[] args = { "/settings:" + runSettingsFile }; - var mockOutput = new MockOutput(); + string[] args = { "/settings:" + runSettingsFile }; + var mockOutput = new MockOutput(); - var exitCode = new Executor(mockOutput, this.mockTestPlatformEventSource.Object).Execute(args); + var exitCode = new Executor(mockOutput, _mockTestPlatformEventSource.Object).Execute(args); - Assert.AreEqual(1, exitCode, "Exit code should be one because it throws exception"); - } - finally - { - File.Delete(runSettingsFile); - RunSettingsManager.Instance.SetActiveRunSettings(activeRunSetting); - } + Assert.AreEqual(1, exitCode, "Exit code should be one because it throws exception"); } - - [TestMethod] - public void ExecutorShouldShowRightErrorMessage() + finally { - var activeRunSetting = RunSettingsManager.Instance.ActiveRunSettings; - var runSettingsFile = Path.Combine(Path.GetTempPath(), "ExecutorShouldShowRightErrorMessage.runsettings"); + File.Delete(runSettingsFile); + RunSettingsManager.Instance.SetActiveRunSettings(activeRunSetting); + } + } + + [TestMethod] + public void ExecutorShouldShowRightErrorMessage() + { + var activeRunSetting = RunSettingsManager.Instance.ActiveRunSettings; + var runSettingsFile = Path.Combine(Path.GetTempPath(), "ExecutorShouldShowRightErrorMessage.runsettings"); - try + try + { + if (File.Exists(runSettingsFile)) { - if (File.Exists(runSettingsFile)) - { - File.Delete(runSettingsFile); - } + File.Delete(runSettingsFile); + } - var fileContents = @" + var fileContents = @" Invalid "; - File.WriteAllText(runSettingsFile, fileContents); + File.WriteAllText(runSettingsFile, fileContents); - string[] args = { "/settings:" + runSettingsFile }; - var mockOutput = new MockOutput(); + string[] args = { "/settings:" + runSettingsFile }; + var mockOutput = new MockOutput(); - var exitCode = new Executor(mockOutput, this.mockTestPlatformEventSource.Object).Execute(args); + var exitCode = new Executor(mockOutput, _mockTestPlatformEventSource.Object).Execute(args); - var result = mockOutput.Messages.Any(o => o.Level == OutputLevel.Error && o.Message.Contains("Invalid setting 'RunConfiguration'. Invalid value 'Invalid' specified for 'TargetPlatform'.")); - Assert.AreEqual(1, exitCode, "Exit code should be one because it throws exception"); - Assert.IsTrue(result, "expecting error message : Invalid setting 'RunConfiguration'. Invalid value 'Invalid' specified for 'TargetPlatform'."); - } - finally - { - File.Delete(runSettingsFile); - RunSettingsManager.Instance.SetActiveRunSettings(activeRunSetting); - } + var result = mockOutput.Messages.Any(o => o.Level == OutputLevel.Error && o.Message.Contains("Invalid setting 'RunConfiguration'. Invalid value 'Invalid' specified for 'TargetPlatform'.")); + Assert.AreEqual(1, exitCode, "Exit code should be one because it throws exception"); + Assert.IsTrue(result, "expecting error message : Invalid setting 'RunConfiguration'. Invalid value 'Invalid' specified for 'TargetPlatform'."); } - - private class MockOutput : IOutput + finally { - public List Messages { get; set; } = new List(); + File.Delete(runSettingsFile); + RunSettingsManager.Instance.SetActiveRunSettings(activeRunSetting); + } + } - public void Write(string message, OutputLevel level) - { - Messages.Add(new OutputMessage() { Message = message, Level = level }); - } + private class MockOutput : IOutput + { + public List Messages { get; set; } = new List(); - public void WriteLine(string message, OutputLevel level) - { - Messages.Add(new OutputMessage() { Message = message, Level = level }); - } + public void Write(string message, OutputLevel level) + { + Messages.Add(new OutputMessage() { Message = message, Level = level }); } - private class OutputMessage + public void WriteLine(string message, OutputLevel level) { - public string Message { get; set; } - public OutputLevel Level { get; set; } + Messages.Add(new OutputMessage() { Message = message, Level = level }); } } -} + + private class OutputMessage + { + public string Message { get; set; } + public OutputLevel Level { get; set; } + } +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/GlobalSuppressions.cs b/test/vstest.console.UnitTests/GlobalSuppressions.cs new file mode 100644 index 0000000000..1eb087e831 --- /dev/null +++ b/test/vstest.console.UnitTests/GlobalSuppressions.cs @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Tool name is using lower-case.", Scope = "namespace", Target = "~N:vstest.console.UnitTests.Internal")] +[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Tool name is using lower-case.", Scope = "namespace", Target = "~N:vstest.console.UnitTests.Processors")] +[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Tool name is using lower-case.", Scope = "namespace", Target = "~N:vstest.console.UnitTests.Publisher")] +[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Tool name is using lower-case.", Scope = "namespace", Target = "~N:vstest.console.UnitTests.TestDoubles")] +[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Tool name is using lower-case.", Scope = "namespace", Target = "~N:vstest.console.UnitTests.TestPlatformHelpers")] diff --git a/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs b/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs index 91f7e136a2..145e2f373d 100644 --- a/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs +++ b/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs @@ -1,1297 +1,1322 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Internal +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Internal; + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Threading; +using Extensions.FileSystemGlobbing; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; +using Processors; +using Common.Logging; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Logging; +using Utilities; +using Utilities.Helpers.Interfaces; +using TestTools.UnitTesting; +using Moq; +using vstest.console.Internal; +using CommandLineResources = Resources.Resources; + +[TestClass] +public class ConsoleLoggerTests { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Threading; - using Microsoft.Extensions.FileSystemGlobbing; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; - using Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using vstest.console.Internal; - using CommandLineResources = Resources.Resources; - - [TestClass] - public class ConsoleLoggerTests + private Mock _mockRequestData; + private Mock _mockMetricsCollection; + private Mock _mockOutput; + private ConsoleLogger _consoleLogger; + private Mock _mockProgressIndicator; + + private const string PassedTestIndicator = " Passed "; + private const string FailedTestIndicator = " Failed "; + private const string SkippedTestIndicator = " Skipped "; + + [TestInitialize] + public void Initialize() { - private Mock mockRequestData; - private Mock mockMetricsCollection; - private Mock mockOutput; - private ConsoleLogger consoleLogger; - private Mock mockProgressIndicator; + RunTestsArgumentProcessorTests.SetupMockExtensions(); - private const string PassedTestIndicator = " Passed "; - private const string FailedTestIndicator = " Failed "; - private const string SkippedTestIndicator = " Skipped "; - - [TestInitialize] - public void Initialize() - { - RunTestsArgumentProcessorTests.SetupMockExtensions(); - - // Setup Mocks and other dependencies - this.Setup(); - } + // Setup Mocks and other dependencies + Setup(); + } - [TestMethod] - public void InitializeShouldThrowExceptionIfEventsIsNull() - { - Assert.ThrowsException(() => - { - this.consoleLogger.Initialize(null, string.Empty); - }); - } + [TestMethod] + public void InitializeShouldThrowExceptionIfEventsIsNull() + { + Assert.ThrowsException(() => _consoleLogger.Initialize(null, string.Empty)); + } - [TestMethod] - public void InitializeShouldNotThrowExceptionIfEventsIsNotNull() - { - this.consoleLogger.Initialize(new Mock().Object, string.Empty); - } + [TestMethod] + public void InitializeShouldNotThrowExceptionIfEventsIsNotNull() + { + _consoleLogger.Initialize(new Mock().Object, string.Empty); + } - [TestMethod] - public void InitializeWithParametersShouldThrowExceptionIfEventsIsNull() + [TestMethod] + public void InitializeWithParametersShouldThrowExceptionIfEventsIsNull() + { + var parameters = new Dictionary { - var parameters = new Dictionary - { - { "param1", "value" }, - }; + { "param1", "value" }, + }; - Assert.ThrowsException(() => - { - this.consoleLogger.Initialize(null, parameters); - }); - } + Assert.ThrowsException(() => _consoleLogger.Initialize(null, parameters)); + } - [TestMethod] - public void InitializeWithParametersShouldThrowExceptionIfParametersIsEmpty() - { - Assert.ThrowsException(() => - { - this.consoleLogger.Initialize(new Mock().Object, new Dictionary()); - }); - } + [TestMethod] + public void InitializeWithParametersShouldThrowExceptionIfParametersIsEmpty() + { + Assert.ThrowsException(() => _consoleLogger.Initialize(new Mock().Object, new Dictionary())); + } - [TestMethod] - public void InitializeWithParametersShouldThrowExceptionIfParametersIsNull() - { - Assert.ThrowsException(() => - { - this.consoleLogger.Initialize(new Mock().Object, (Dictionary)null); - }); - } + [TestMethod] + public void InitializeWithParametersShouldThrowExceptionIfParametersIsNull() + { + Assert.ThrowsException(() => _consoleLogger.Initialize(new Mock().Object, (Dictionary)null)); + } - [TestMethod] - public void InitializeWithParametersShouldSetVerbosityLevel() + [TestMethod] + public void InitializeWithParametersShouldSetVerbosityLevel() + { + var parameters = new Dictionary { - var parameters = new Dictionary - { - { "verbosity", "minimal" }, - { DefaultLoggerParameterNames.TargetFramework , "net451"} - }; - this.consoleLogger.Initialize(new Mock().Object, parameters); + { "verbosity", "minimal" }, + { DefaultLoggerParameterNames.TargetFramework , "net451"} + }; + _consoleLogger.Initialize(new Mock().Object, parameters); - Assert.AreEqual(ConsoleLogger.Verbosity.Minimal, this.consoleLogger.VerbosityLevel); - } + Assert.AreEqual(ConsoleLogger.Verbosity.Minimal, _consoleLogger.VerbosityLevel); + } - [TestMethod] - public void InitializeWithParametersShouldDefaultToNormalVerbosityLevelForInvalidVerbosity() + [TestMethod] + public void InitializeWithParametersShouldDefaultToNormalVerbosityLevelForInvalidVerbosity() + { + var parameters = new Dictionary { - var parameters = new Dictionary - { - { "verbosity", "" }, - }; + { "verbosity", "" }, + }; - this.consoleLogger.Initialize(new Mock().Object, parameters); + _consoleLogger.Initialize(new Mock().Object, parameters); #if NETFRAMEWORK - Assert.AreEqual(ConsoleLogger.Verbosity.Normal, this.consoleLogger.VerbosityLevel); + Assert.AreEqual(ConsoleLogger.Verbosity.Normal, _consoleLogger.VerbosityLevel); #else - Assert.AreEqual(ConsoleLogger.Verbosity.Minimal, this.consoleLogger.VerbosityLevel); + Assert.AreEqual(ConsoleLogger.Verbosity.Minimal, _consoleLogger.VerbosityLevel); #endif - } + } - [TestMethod] - public void InitializeWithParametersShouldSetPrefixValue() + [TestMethod] + public void InitializeWithParametersShouldSetPrefixValue() + { + var parameters = new Dictionary { - var parameters = new Dictionary - { - { "prefix", "true" }, - }; - Assert.IsFalse(ConsoleLogger.AppendPrefix); + { "prefix", "true" }, + }; + Assert.IsFalse(ConsoleLogger.AppendPrefix); - this.consoleLogger.Initialize(new Mock().Object, parameters); + _consoleLogger.Initialize(new Mock().Object, parameters); - Assert.IsTrue(ConsoleLogger.AppendPrefix); - ConsoleLogger.AppendPrefix = false; - } + Assert.IsTrue(ConsoleLogger.AppendPrefix); + ConsoleLogger.AppendPrefix = false; + } - [TestMethod] - public void InitializeWithParametersShouldSetNoProgress() - { - var parameters = new Dictionary(); + [TestMethod] + public void InitializeWithParametersShouldSetNoProgress() + { + var parameters = new Dictionary(); - Assert.IsFalse(ConsoleLogger.EnableProgress); + Assert.IsFalse(ConsoleLogger.EnableProgress); - parameters.Add("progress", "true"); - this.consoleLogger.Initialize(new Mock().Object, parameters); + parameters.Add("progress", "true"); + _consoleLogger.Initialize(new Mock().Object, parameters); - Assert.IsTrue(ConsoleLogger.EnableProgress); + Assert.IsTrue(ConsoleLogger.EnableProgress); - ConsoleLogger.EnableProgress = false; - } + ConsoleLogger.EnableProgress = false; + } - [TestMethod] - public void TestMessageHandlerShouldThrowExceptionIfEventArgsIsNull() - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); + [TestMethod] + public void TestMessageHandlerShouldThrowExceptionIfEventArgsIsNull() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); - Assert.ThrowsException(() => - { - loggerEvents.RaiseTestRunMessage(default); - }); - } + Assert.ThrowsException(() => loggerEvents.RaiseTestRunMessage(default)); + } + + [TestMethod] + public void TestMessageHandlerShouldWriteToConsoleWhenTestRunMessageIsRaised() + { + var count = 0; + _mockOutput.Setup(o => o.WriteLine(It.IsAny(), It.IsAny())).Callback( + (s, o) => count++); + + SetupForTestMessageHandler(out var loggerEvents); + + loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Informational, "Informational123")); + loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Error, "Error123")); + loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Warning, "Warning123")); + loggerEvents.WaitForEventCompletion(); + + // Added this for synchronization + SpinWait.SpinUntil(() => count == 3, 300); + + AssertsForTestMessageHandler(); + _mockProgressIndicator.Verify(pi => pi.Pause(), Times.Exactly(3)); + _mockProgressIndicator.Verify(pi => pi.Start(), Times.Exactly(3)); + } + + [TestMethod] + public void TestMessageHandlerShouldWriteToConsoleWhenTestDiscoveryMessageIsRaised() + { + var count = 0; + _mockOutput.Setup(o => o.WriteLine(It.IsAny(), It.IsAny())).Callback( + (s, o) => count++); + + SetupForTestMessageHandler(out var loggerEvents); - [TestMethod] - public void TestMessageHandlerShouldWriteToConsoleWhenTestRunMessageIsRaised() + loggerEvents.RaiseDiscoveryMessage(new TestRunMessageEventArgs(TestMessageLevel.Informational, "Informational123")); + loggerEvents.RaiseDiscoveryMessage(new TestRunMessageEventArgs(TestMessageLevel.Error, "Error123")); + loggerEvents.RaiseDiscoveryMessage(new TestRunMessageEventArgs(TestMessageLevel.Warning, "Warning123")); + loggerEvents.WaitForEventCompletion(); + + // Added this for synchronization + SpinWait.SpinUntil(() => count == 3, 300); + + AssertsForTestMessageHandler(); + _mockProgressIndicator.Verify(pi => pi.Pause(), Times.Exactly(3)); + _mockProgressIndicator.Verify(pi => pi.Start(), Times.Exactly(3)); + } + + private void AssertsForTestMessageHandler() + { + _mockOutput.Verify(o => o.WriteLine("Informational123", OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine("Warning123", OutputLevel.Warning), Times.Once()); + _mockOutput.Verify(o => o.WriteLine("Error123", OutputLevel.Error), Times.Once()); + } + + private void SetupForTestMessageHandler(out InternalTestLoggerEvents loggerEvents) + { + loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary { - var count = 0; - this.mockOutput.Setup(o => o.WriteLine(It.IsAny(), It.IsAny())).Callback( - (s, o) => { count++; }); + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); + } - this.SetupForTestMessageHandler(out var loggerEvents); + [TestMethod] + public void TestResultHandlerShouldThowExceptionIfEventArgsIsNull() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); - loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Informational, "Informational123")); - loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Error, "Error123")); - loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Warning, "Warning123")); - loggerEvents.WaitForEventCompletion(); + Assert.ThrowsException(() => loggerEvents.RaiseTestResult(default)); + } - // Added this for synchronization - SpinWait.SpinUntil(() => count == 3, 300); + [TestMethod] + public void TestResultHandlerShouldShowStdOutMessagesBannerIfStdOutIsNotEmpty() + { + var count = 0; + _mockOutput.Setup(o => o.WriteLine(It.IsAny(), It.IsAny())).Callback( + (s, o) => count++); - this.AssertsForTestMessageHandler(); - this.mockProgressIndicator.Verify(pi => pi.Pause(), Times.Exactly(3)); - this.mockProgressIndicator.Verify(pi => pi.Start(), Times.Exactly(3)); - } + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); + + string message = "Dummy message"; + var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); + TestResultMessage testResultMessage = new(TestResultMessage.StandardOutCategory, message); + var testresult = new ObjectModel.TestResult(testcase) + { + Outcome = TestOutcome.Failed + }; + testresult.Messages.Add(testResultMessage); + + loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); + loggerEvents.WaitForEventCompletion(); + + // Added this for synchronization + SpinWait.SpinUntil(() => count == 2, 300); - [TestMethod] - public void TestMessageHandlerShouldWriteToConsoleWhenTestDiscoveryMessageIsRaised() + _mockOutput.Verify(o => o.WriteLine(" Standard Output Messages:", OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(" " + message, OutputLevel.Information), Times.Once()); + } + + [TestMethod] + public void NormalVerbosityShowNotStdOutMessagesForPassedTests() + { + // Setup + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary { - var count = 0; - this.mockOutput.Setup(o => o.WriteLine(It.IsAny(), It.IsAny())).Callback( - (s, o) => { count++; }); + { "verbosity", "normal" } + }; - this.SetupForTestMessageHandler(out var loggerEvents); + _consoleLogger.Initialize(loggerEvents, parameters); + var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); + string message = "Dummy message"; + TestResultMessage testResultMessage = new(TestResultMessage.StandardOutCategory, message); - loggerEvents.RaiseDiscoveryMessage(new TestRunMessageEventArgs(TestMessageLevel.Informational, "Informational123")); - loggerEvents.RaiseDiscoveryMessage(new TestRunMessageEventArgs(TestMessageLevel.Error, "Error123")); - loggerEvents.RaiseDiscoveryMessage(new TestRunMessageEventArgs(TestMessageLevel.Warning, "Warning123")); - loggerEvents.WaitForEventCompletion(); + var testresult = new ObjectModel.TestResult(testcase); + testresult.Outcome = TestOutcome.Passed; + testresult.Messages.Add(testResultMessage); - // Added this for synchronization - SpinWait.SpinUntil(() => count == 3, 300); + // Raise an event on mock object + loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); + loggerEvents.WaitForEventCompletion(); - this.AssertsForTestMessageHandler(); - this.mockProgressIndicator.Verify(pi => pi.Pause(), Times.Exactly(3)); - this.mockProgressIndicator.Verify(pi => pi.Start(), Times.Exactly(3)); - } + // Verify + _mockOutput.Verify(o => o.WriteLine(CommandLineResources.StdOutMessagesBanner, OutputLevel.Information), Times.Never()); + _mockOutput.Verify(o => o.WriteLine(" " + message, OutputLevel.Information), Times.Never()); + } - private void AssertsForTestMessageHandler() + [TestMethod] + public void DetailedVerbosityShowStdOutMessagesForPassedTests() + { + // Setup + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary { - this.mockOutput.Verify(o => o.WriteLine("Informational123", OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine("Warning123", OutputLevel.Warning), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine("Error123", OutputLevel.Error), Times.Once()); - } + { "verbosity", "detailed" } + }; - private void SetupForTestMessageHandler(out InternalTestLoggerEvents loggerEvents) + _consoleLogger.Initialize(loggerEvents, parameters); + var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); + string message = "Dummy message"; + + TestResultMessage testResultMessage = new(TestResultMessage.StandardOutCategory, message); + var testresult = new ObjectModel.TestResult(testcase) { - loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); - } + Outcome = TestOutcome.Passed + }; - [TestMethod] - public void TestResultHandlerShouldThowExceptionIfEventArgsIsNull() + testresult.Messages.Add(testResultMessage); + + // Act. Raise an event on mock object + loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); + loggerEvents.WaitForEventCompletion(); + + // Verify + _mockOutput.Verify(o => o.WriteLine(" Standard Output Messages:", OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(" " + message, OutputLevel.Information), Times.Once()); + } + + [TestMethod] + public void TestRunErrorMessageShowShouldTestRunFailed() + { + // Setup + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); + { "verbosity", "detailed" } + }; - Assert.ThrowsException(() => - { - loggerEvents.RaiseTestResult(default); - }); - } + _consoleLogger.Initialize(loggerEvents, parameters); + string message = "Adapter Error"; - [TestMethod] - public void TestResultHandlerShouldShowStdOutMessagesBannerIfStdOutIsNotEmpty() - { - var count = 0; - this.mockOutput.Setup(o => o.WriteLine(It.IsAny(), It.IsAny())).Callback( - (s, o) => { count++; }); - - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary - { - { "verbosity", "normal" } - }; - this.consoleLogger.Initialize(loggerEvents, parameters); - - string message = "Dummy message"; - var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); - TestResultMessage testResultMessage = new TestResultMessage(TestResultMessage.StandardOutCategory, message); - var testresult = new ObjectModel.TestResult(testcase) - { - Outcome = TestOutcome.Failed - }; - testresult.Messages.Add(testResultMessage); - - loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); - loggerEvents.WaitForEventCompletion(); - - // Added this for synchronization - SpinWait.SpinUntil(() => count == 2, 300); - - this.mockOutput.Verify(o => o.WriteLine(" Standard Output Messages:", OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(" " + message, OutputLevel.Information), Times.Once()); - } + // Act. Raise an event on mock object + loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Error, message)); + loggerEvents.RaiseTestRunComplete(new TestRunCompleteEventArgs(new Mock().Object, false, false, null, new Collection(), new Collection(), TimeSpan.FromSeconds(1))); + loggerEvents.WaitForEventCompletion(); - [TestMethod] - public void NormalVerbosityShowNotStdOutMessagesForPassedTests() - { - // Setup - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary - { - { "verbosity", "normal" } - }; - - this.consoleLogger.Initialize(loggerEvents, parameters); - var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); - string message = "Dummy message"; - TestResultMessage testResultMessage = new TestResultMessage(TestResultMessage.StandardOutCategory, message); - - var testresult = new ObjectModel.TestResult(testcase); - testresult.Outcome = TestOutcome.Passed; - testresult.Messages.Add(testResultMessage); - - // Raise an event on mock object - loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); - loggerEvents.WaitForEventCompletion(); - - // Verify - this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.StdOutMessagesBanner, OutputLevel.Information), Times.Never()); - this.mockOutput.Verify(o => o.WriteLine(" " + message, OutputLevel.Information), Times.Never()); - } + // Verify + _mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunFailed, OutputLevel.Error), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(message, OutputLevel.Error), Times.Once()); + } - [TestMethod] - public void DetailedVerbosityShowStdOutMessagesForPassedTests() + [TestMethod] + public void InQuietModeTestErrorMessageShouldShowTestRunFailed() + { + // Setup + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary { - // Setup - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary - { - { "verbosity", "detailed" } - }; + { "verbosity", "quiet" }, + { DefaultLoggerParameterNames.TargetFramework , "abc" } + }; - this.consoleLogger.Initialize(loggerEvents, parameters); - var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); - string message = "Dummy message"; + _consoleLogger.Initialize(loggerEvents, parameters); + string message = "Adapter Error"; - TestResultMessage testResultMessage = new TestResultMessage(TestResultMessage.StandardOutCategory, message); - var testresult = new ObjectModel.TestResult(testcase) - { - Outcome = TestOutcome.Passed - }; + // Act. Raise an event on mock object + loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Error, message)); + loggerEvents.RaiseTestRunComplete(new TestRunCompleteEventArgs(new Mock().Object, false, false, null, new Collection(), new Collection(), TimeSpan.FromSeconds(1))); + loggerEvents.WaitForEventCompletion(); - testresult.Messages.Add(testResultMessage); + // Verify + _mockOutput.Verify(o => o.WriteLine(message, OutputLevel.Error), Times.Once()); + } - // Act. Raise an event on mock object - loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); - loggerEvents.WaitForEventCompletion(); + [TestMethod] + public void InQuietModeTestWarningMessageShouldNotShow() + { + // Setup + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", "quiet" }, + { DefaultLoggerParameterNames.TargetFramework , "abc" } + }; - // Verify - this.mockOutput.Verify(o => o.WriteLine(" Standard Output Messages:", OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(" " + message, OutputLevel.Information), Times.Once()); - } + _consoleLogger.Initialize(loggerEvents, parameters); + string message = "Adapter Warning"; + + // Act. Raise an event on mock object + loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Warning, message)); + loggerEvents.RaiseTestRunComplete(new TestRunCompleteEventArgs(new Mock().Object, false, false, null, new Collection(), new Collection(), TimeSpan.FromSeconds(1))); + loggerEvents.WaitForEventCompletion(); + + // Verify + _mockOutput.Verify(o => o.WriteLine(message, OutputLevel.Warning), Times.Never()); + } - [TestMethod] - public void TestRunErrorMessageShowShouldTestRunFailed() + [TestMethod] + public void InNormalModeTestWarningAndErrorMessagesShouldShow() + { + // Setup + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", "normal" } + }; + + _consoleLogger.Initialize(loggerEvents, parameters); + string message = "Adapter Warning"; + string errorMessage = "Adapter Error"; + + // Act. Raise an event on mock object + loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Warning, message)); + loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Error, errorMessage)); + loggerEvents.RaiseTestRunComplete(new TestRunCompleteEventArgs(new Mock().Object, false, false, null, new Collection(), new Collection(), TimeSpan.FromSeconds(1))); + loggerEvents.WaitForEventCompletion(); + + // Verify + _mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunFailed, OutputLevel.Error), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(message, OutputLevel.Warning), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(errorMessage, OutputLevel.Error), Times.Once()); + } + + [TestMethod] + public void TestResultHandlerShouldNotShowStdOutMessagesBannerIfStdOutIsEmpty() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary { - // Setup - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary - { - { "verbosity", "detailed" } - }; + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); - this.consoleLogger.Initialize(loggerEvents, parameters); - string message = "Adapter Error"; + var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); + TestResultMessage testResultMessage = new(TestResultMessage.StandardOutCategory, null); + var testresult = new ObjectModel.TestResult(testcase) + { + Outcome = TestOutcome.Failed + }; + testresult.Messages.Add(testResultMessage); - // Act. Raise an event on mock object - loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Error, message)); - loggerEvents.RaiseTestRunComplete(new TestRunCompleteEventArgs(new Mock().Object, false, false, null, new Collection(), new Collection(), TimeSpan.FromSeconds(1))); - loggerEvents.WaitForEventCompletion(); + loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); + loggerEvents.WaitForEventCompletion(); - // Verify - this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunFailed, OutputLevel.Error), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(message, OutputLevel.Error), Times.Once()); - } + _mockOutput.Verify(o => o.WriteLine(CommandLineResources.StdOutMessagesBanner, OutputLevel.Information), Times.Never()); + } - [TestMethod] - public void InQuietModeTestErrorMessageShouldShowTestRunFailed() + [TestMethod] + public void TestResultHandlerShouldShowStdErrMessagesBannerIfStdErrIsNotEmpty() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); + + var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); + string message = "Dummy message"; + TestResultMessage testResultMessage = new(TestResultMessage.StandardErrorCategory, message); + var testresult = new ObjectModel.TestResult(testcase) { - // Setup - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary - { - { "verbosity", "quiet" }, - { DefaultLoggerParameterNames.TargetFramework , "abc" } - }; + Outcome = TestOutcome.Failed + }; + testresult.Messages.Add(testResultMessage); - this.consoleLogger.Initialize(loggerEvents, parameters); - string message = "Adapter Error"; + loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); + loggerEvents.WaitForEventCompletion(); - // Act. Raise an event on mock object - loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Error, message)); - loggerEvents.RaiseTestRunComplete(new TestRunCompleteEventArgs(new Mock().Object, false, false, null, new Collection(), new Collection(), TimeSpan.FromSeconds(1))); - loggerEvents.WaitForEventCompletion(); + _mockOutput.Verify(o => o.WriteLine(" Standard Error Messages:", OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(" " + message, OutputLevel.Information), Times.Once()); + } - // Verify - this.mockOutput.Verify(o => o.WriteLine(message, OutputLevel.Error), Times.Once()); - } + [TestMethod] + public void TestResultHandlerShouldNotShowStdErrMessagesBannerIfStdErrIsEmpty() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); - [TestMethod] - public void InQuietModeTestWarningMessageShouldNotShow() + var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); + TestResultMessage testResultMessage = new(TestResultMessage.StandardErrorCategory, null); + var testresult = new ObjectModel.TestResult(testcase) { - // Setup - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary - { - { "verbosity", "quiet" }, - { DefaultLoggerParameterNames.TargetFramework , "abc" } - }; + Outcome = TestOutcome.Failed + }; + testresult.Messages.Add(testResultMessage); - this.consoleLogger.Initialize(loggerEvents, parameters); - string message = "Adapter Warning"; + loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); + loggerEvents.WaitForEventCompletion(); - // Act. Raise an event on mock object - loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Warning, message)); - loggerEvents.RaiseTestRunComplete(new TestRunCompleteEventArgs(new Mock().Object, false, false, null, new Collection(), new Collection(), TimeSpan.FromSeconds(1))); - loggerEvents.WaitForEventCompletion(); + _mockOutput.Verify(o => o.WriteLine(CommandLineResources.StdErrMessagesBanner, OutputLevel.Information), Times.Never()); + } - // Verify - this.mockOutput.Verify(o => o.WriteLine(message, OutputLevel.Warning), Times.Never()); - } + [TestMethod] + public void TestResultHandlerShouldShowAdditionalInfoBannerIfAdditionalInfoIsNotEmpty() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); + + var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); + string message = "Dummy message"; + TestResultMessage testResultMessage = new(TestResultMessage.AdditionalInfoCategory, message); + var testresult = new ObjectModel.TestResult(testcase) + { + Outcome = TestOutcome.Failed + }; + testresult.Messages.Add(testResultMessage); - [TestMethod] - public void InNormalModeTestWarningAndErrorMessagesShouldShow() - { - // Setup - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary - { - { "verbosity", "normal" } - }; - - this.consoleLogger.Initialize(loggerEvents, parameters); - string message = "Adapter Warning"; - string errorMessage = "Adapter Error"; - - // Act. Raise an event on mock object - loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Warning, message)); - loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Error, errorMessage)); - loggerEvents.RaiseTestRunComplete(new TestRunCompleteEventArgs(new Mock().Object, false, false, null, new Collection(), new Collection(), TimeSpan.FromSeconds(1))); - loggerEvents.WaitForEventCompletion(); - - // Verify - this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunFailed, OutputLevel.Error), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(message, OutputLevel.Warning), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(errorMessage, OutputLevel.Error), Times.Once()); - } + loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); + loggerEvents.WaitForEventCompletion(); - [TestMethod] - public void TestResultHandlerShouldNotShowStdOutMessagesBannerIfStdOutIsEmpty() - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary - { - { "verbosity", "normal" } - }; - this.consoleLogger.Initialize(loggerEvents, parameters); - - var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); - TestResultMessage testResultMessage = new TestResultMessage(TestResultMessage.StandardOutCategory, null); - var testresult = new ObjectModel.TestResult(testcase) - { - Outcome = TestOutcome.Failed - }; - testresult.Messages.Add(testResultMessage); - - loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); - loggerEvents.WaitForEventCompletion(); - - this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.StdOutMessagesBanner, OutputLevel.Information), Times.Never()); - } + _mockOutput.Verify(o => o.WriteLine(" Additional Information Messages:", OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(" " + message, OutputLevel.Information), Times.Once()); + } - [TestMethod] - public void TestResultHandlerShouldShowStdErrMessagesBannerIfStdErrIsNotEmpty() - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); - - var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); - string message = "Dummy message"; - TestResultMessage testResultMessage = new TestResultMessage(TestResultMessage.StandardErrorCategory, message); - var testresult = new ObjectModel.TestResult(testcase) - { - Outcome = TestOutcome.Failed - }; - testresult.Messages.Add(testResultMessage); - - loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); - loggerEvents.WaitForEventCompletion(); - - this.mockOutput.Verify(o => o.WriteLine(" Standard Error Messages:", OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(" " + message, OutputLevel.Information), Times.Once()); - } + [TestMethod] + public void TestResultHandlerShouldNotShowAdditionalInfoBannerIfAdditionalInfoIsEmpty() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); - [TestMethod] - public void TestResultHandlerShouldNotShowStdErrMessagesBannerIfStdErrIsEmpty() - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary - { - { "verbosity", "normal" } - }; - this.consoleLogger.Initialize(loggerEvents, parameters); - - var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); - TestResultMessage testResultMessage = new TestResultMessage(TestResultMessage.StandardErrorCategory, null); - var testresult = new ObjectModel.TestResult(testcase) - { - Outcome = TestOutcome.Failed - }; - testresult.Messages.Add(testResultMessage); - - loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); - loggerEvents.WaitForEventCompletion(); - - this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.StdErrMessagesBanner, OutputLevel.Information), Times.Never()); - } + var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); - [TestMethod] - public void TestResultHandlerShouldShowAdditionalInfoBannerIfAdditionalInfoIsNotEmpty() - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); - - var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); - string message = "Dummy message"; - TestResultMessage testResultMessage = new TestResultMessage(TestResultMessage.AdditionalInfoCategory, message); - var testresult = new ObjectModel.TestResult(testcase) - { - Outcome = TestOutcome.Failed - }; - testresult.Messages.Add(testResultMessage); - - loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); - loggerEvents.WaitForEventCompletion(); - - this.mockOutput.Verify(o => o.WriteLine(" Additional Information Messages:", OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(" " + message, OutputLevel.Information), Times.Once()); - } + TestResultMessage testResultMessage = new(TestResultMessage.AdditionalInfoCategory, null); - [TestMethod] - public void TestResultHandlerShouldNotShowAdditionalInfoBannerIfAdditionalInfoIsEmpty() + var testresult = new ObjectModel.TestResult(testcase) { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary - { - { "verbosity", "normal" } - }; - this.consoleLogger.Initialize(loggerEvents, parameters); + Outcome = TestOutcome.Failed + }; + testresult.Messages.Add(testResultMessage); - var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); + loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); + loggerEvents.WaitForEventCompletion(); + + _mockOutput.Verify(o => o.WriteLine(CommandLineResources.AddnlInfoMessagesBanner, OutputLevel.Information), Times.Never()); + } - TestResultMessage testResultMessage = new TestResultMessage(TestResultMessage.AdditionalInfoCategory, null); + [TestMethod] + public void TestResultHandlerShouldShowPassedTestsForNormalVebosity() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); - var testresult = new ObjectModel.TestResult(testcase) - { - Outcome = TestOutcome.Failed - }; - testresult.Messages.Add(testResultMessage); + foreach (var testResult in GetTestResultsObject()) + { + loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); + } + loggerEvents.WaitForEventCompletion(); + + _mockOutput.Verify(o => o.Write(PassedTestIndicator, OutputLevel.Information), Times.Once); + _mockOutput.Verify(o => o.WriteLine("TestName [1 h 2 m]", OutputLevel.Information), Times.Once); + _mockOutput.Verify(o => o.Write(FailedTestIndicator, OutputLevel.Information), Times.Once); + _mockOutput.Verify(o => o.WriteLine("TestName [4 m 5 s]", OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.Write(SkippedTestIndicator, OutputLevel.Information), Times.Exactly(3)); + _mockOutput.Verify(o => o.WriteLine("TestName", OutputLevel.Information), Times.Exactly(3)); + _mockProgressIndicator.Verify(pi => pi.Pause(), Times.Exactly(5)); + _mockProgressIndicator.Verify(pi => pi.Start(), Times.Exactly(5)); + } - loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); - loggerEvents.WaitForEventCompletion(); + [DataRow(".NETFramework,version=v4.5.1", "(net451)", "quiet")] + [DataRow(".NETFramework,version=v4.5.1", "(net451)", "minimal")] + [DataRow(null, null, "quiet")] + [DataRow(null, null, "minimal")] + [TestMethod] + public void TestResultHandlerShouldShowFailedTestsAndPassedTestsForQuietVebosity(string framework, string expectedFramework, string verbosityLevel) + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", verbosityLevel }, + { DefaultLoggerParameterNames.TargetFramework , framework} + }; + _consoleLogger.Initialize(loggerEvents, parameters); - this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.AddnlInfoMessagesBanner, OutputLevel.Information), Times.Never()); + foreach (var testResult in GetTestResultsObject()) + { + loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); } - [TestMethod] - public void TestResultHandlerShouldShowPassedTestsForNormalVebosity() - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); - - foreach (var testResult in this.GetTestResultsObject()) - { - loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); - } - loggerEvents.WaitForEventCompletion(); - - this.mockOutput.Verify(o => o.Write(PassedTestIndicator, OutputLevel.Information), Times.Once); - this.mockOutput.Verify(o => o.WriteLine("TestName [1 h 2 m]", OutputLevel.Information), Times.Once); - this.mockOutput.Verify(o => o.Write(FailedTestIndicator, OutputLevel.Information), Times.Once); - this.mockOutput.Verify(o => o.WriteLine("TestName [4 m 5 s]", OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.Write(SkippedTestIndicator, OutputLevel.Information), Times.Exactly(3)); - this.mockOutput.Verify(o => o.WriteLine("TestName", OutputLevel.Information), Times.Exactly(3)); - this.mockProgressIndicator.Verify(pi => pi.Pause(), Times.Exactly(5)); - this.mockProgressIndicator.Verify(pi => pi.Start(), Times.Exactly(5)); + foreach (var testResult in GetPassedTestResultsObject()) + { + loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); } - [DataRow(".NETFramework,version=v4.5.1", "(net451)", "quiet")] - [DataRow(".NETFramework,version=v4.5.1", "(net451)", "minimal")] - [DataRow(null, null, "quiet")] - [DataRow(null, null, "minimal")] - [TestMethod] - public void TestResultHandlerShouldShowFailedTestsAndPassedTestsForQuietVebosity(string framework, string expectedFramework, string verbosityLevel) - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary - { - { "verbosity", verbosityLevel }, - { DefaultLoggerParameterNames.TargetFramework , framework} - }; - this.consoleLogger.Initialize(loggerEvents, parameters); - - foreach (var testResult in this.GetTestResultsObject()) - { - loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); - } - - foreach (var testResult in this.GetPassedTestResultsObject()) - { - loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); - } - - loggerEvents.RaiseTestRunComplete(new TestRunCompleteEventArgs(new Mock().Object, false, false, null, new Collection(), new Collection(), TimeSpan.FromSeconds(1))); - loggerEvents.WaitForEventCompletion(); - - this.mockOutput.Verify(o => o.Write(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummary, - (CommandLineResources.PassedTestIndicator + "!").PadRight(8), - 0.ToString().PadLeft(5), - 1.ToString().PadLeft(5), - 1.ToString().PadLeft(5), 2 + loggerEvents.RaiseTestRunComplete(new TestRunCompleteEventArgs(new Mock().Object, false, false, null, new Collection(), new Collection(), TimeSpan.FromSeconds(1))); + loggerEvents.WaitForEventCompletion(); + + _mockOutput.Verify(o => o.Write(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummary, + (CommandLineResources.PassedTestIndicator + "!").PadRight(8), + 0.ToString().PadLeft(5), + 1.ToString().PadLeft(5), + 1.ToString().PadLeft(5), 2 .ToString().PadLeft(5), - "1 m 2 s"), OutputLevel.Information), Times.Once); - - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryAssemblyAndFramework, - "TestSourcePassed", - expectedFramework), OutputLevel.Information), Times.Once); - - this.mockOutput.Verify(o => o.Write(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummary, - (CommandLineResources.FailedTestIndicator + "!").PadRight(8), - 1.ToString().PadLeft(5), - 1.ToString().PadLeft(5), - 1.ToString().PadLeft(5), - 3.ToString().PadLeft(5), - "1 h 2 m"), OutputLevel.Information), Times.Once); - - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryAssemblyAndFramework, - "TestSource", - expectedFramework), OutputLevel.Information), Times.Once); - } + "1 m 2 s"), OutputLevel.Information), Times.Once); + + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryAssemblyAndFramework, + "TestSourcePassed", + expectedFramework), OutputLevel.Information), Times.Once); + + _mockOutput.Verify(o => o.Write(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummary, + (CommandLineResources.FailedTestIndicator + "!").PadRight(8), + 1.ToString().PadLeft(5), + 1.ToString().PadLeft(5), + 1.ToString().PadLeft(5), + 3.ToString().PadLeft(5), + "1 h 2 m"), OutputLevel.Information), Times.Once); + + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryAssemblyAndFramework, + "TestSource", + expectedFramework), OutputLevel.Information), Times.Once); + } - [TestMethod] - [DataRow("normal")] - [DataRow("detailed")] - public void TestResultHandlerShouldNotShowformattedFailedTestsAndPassedTestsForOtherThanQuietVebosity(string verbosityLevel) - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary - { - { "verbosity", verbosityLevel }, - { DefaultLoggerParameterNames.TargetFramework , "net451"} - }; - this.consoleLogger.Initialize(loggerEvents, parameters); - - foreach (var testResult in this.GetTestResultsObject()) - { - loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); - } - - foreach (var testResult in this.GetPassedTestResultsObject()) - { - loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); - } - - loggerEvents.RaiseTestRunComplete(new TestRunCompleteEventArgs(new Mock().Object, false, false, null, new Collection(), new Collection(), TimeSpan.FromSeconds(1))); - loggerEvents.WaitForEventCompletion(); - - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummary, CommandLineResources.PassedTestIndicator, 2, 1, 0, 1, "1 m 2 s", "TestSourcePassed", "(net451)"), OutputLevel.Information), Times.Never); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummary, CommandLineResources.FailedTestIndicator, 5, 1, 1, 1, "1 h 6 m", "TestSource", "(net451)"), OutputLevel.Information), Times.Never); - } + [TestMethod] + [DataRow("normal")] + [DataRow("detailed")] + public void TestResultHandlerShouldNotShowformattedFailedTestsAndPassedTestsForOtherThanQuietVebosity(string verbosityLevel) + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", verbosityLevel }, + { DefaultLoggerParameterNames.TargetFramework , "net451"} + }; + _consoleLogger.Initialize(loggerEvents, parameters); - [TestMethod] - public void TestResultHandlerShouldNotShowNotStdOutMsgOfPassedTestIfVerbosityIsNormal() - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); - - var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); - string message = "Dummy message"; - TestResultMessage testResultMessage = new TestResultMessage(TestResultMessage.StandardOutCategory, message); - var testresult = new ObjectModel.TestResult(testcase) - { - Outcome = TestOutcome.Passed - }; - testresult.Messages.Add(testResultMessage); - - loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); - loggerEvents.WaitForEventCompletion(); - - this.mockOutput.Verify(o => o.WriteLine("", OutputLevel.Information), Times.Never()); - this.mockOutput.Verify(o => o.WriteLine(" " + message, OutputLevel.Information), Times.Never()); + foreach (var testResult in GetTestResultsObject()) + { + loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); } - [TestMethod] - public void TestResultHandlerShouldNotShowDbgTrcMsg() - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); - - var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); - string message = "Dummy message"; - TestResultMessage testResultMessage = new TestResultMessage(TestResultMessage.DebugTraceCategory, message); - var testresult = new ObjectModel.TestResult(testcase) - { - Outcome = TestOutcome.Passed - }; - testresult.Messages.Add(testResultMessage); - - loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); - loggerEvents.WaitForEventCompletion(); - - this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.DbgTrcMessagesBanner, OutputLevel.Information), Times.Never()); - this.mockOutput.Verify(o => o.WriteLine(" " + message, OutputLevel.Information), Times.Never()); + foreach (var testResult in GetPassedTestResultsObject()) + { + loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); } - [TestMethod] - public void TestResultHandlerShouldWriteToConsoleButSkipPassedTestsForMinimalVerbosity() - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary - { - { "verbosity", "minimal" }, - { DefaultLoggerParameterNames.TargetFramework , "net451"} - }; - this.consoleLogger.Initialize(loggerEvents, parameters); - - foreach (var testResult in this.GetTestResultsObject()) - { - loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); - } - loggerEvents.WaitForEventCompletion(); - - this.mockOutput.Verify(o => o.Write(PassedTestIndicator, OutputLevel.Information), Times.Never); - this.mockOutput.Verify(o => o.WriteLine("TestName [1 h 2 m]", OutputLevel.Information), Times.Never); - this.mockOutput.Verify(o => o.Write(FailedTestIndicator, OutputLevel.Information), Times.Once); - this.mockOutput.Verify(o => o.WriteLine("TestName [4 m 5 s]", OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.Write(SkippedTestIndicator, OutputLevel.Information), Times.Exactly(3)); - this.mockOutput.Verify(o => o.WriteLine("TestName", OutputLevel.Information), Times.Exactly(3)); - } + loggerEvents.RaiseTestRunComplete(new TestRunCompleteEventArgs(new Mock().Object, false, false, null, new Collection(), new Collection(), TimeSpan.FromSeconds(1))); + loggerEvents.WaitForEventCompletion(); - [TestMethod] - public void TestResultHandlerShouldWriteToNoTestResultForQuietVerbosity() - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary - { - { "verbosity", "quiet" }, - { DefaultLoggerParameterNames.TargetFramework , "net451"} - }; - this.consoleLogger.Initialize(loggerEvents, parameters); - - foreach (var testResult in this.GetTestResultsObject()) - { - loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); - } - loggerEvents.WaitForEventCompletion(); - - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.PassedTestIndicator, "TestName [1 h 2 m]"), OutputLevel.Information), Times.Never); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.FailedTestIndicator, "TestName [4 m 5 s]"), OutputLevel.Information), Times.Never); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.SkippedTestIndicator, "TestName"), OutputLevel.Warning), Times.Never); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.NotRunTestIndicator, "TestName"), OutputLevel.Information), Times.Never); - } + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummary, CommandLineResources.PassedTestIndicator, 2, 1, 0, 1, "1 m 2 s", "TestSourcePassed", "(net451)"), OutputLevel.Information), Times.Never); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummary, CommandLineResources.FailedTestIndicator, 5, 1, 1, 1, "1 h 6 m", "TestSource", "(net451)"), OutputLevel.Information), Times.Never); + } - [DataRow("[1 h 2 m]", new int[5] { 0, 1, 2, 3, 78 })] - [DataRow("[4 m 3 s]", new int[5] { 0, 0, 4, 3, 78 })] - [DataRow("[3 s]", new int[5] { 0, 0, 0, 3, 78 })] - [DataRow("[78 ms]", new int[5] { 0, 0, 0, 0, 78 })] - [DataRow("[1 h]", new int[5] { 0, 1, 0, 5, 78 })] - [DataRow("[5 m]", new int[5] { 0, 0, 5, 0, 78 })] - [DataRow("[4 s]", new int[5] { 0, 0, 0, 4, 0 })] - [DataTestMethod] - public void TestResultHandlerForTestResultWithDurationShouldPrintDurationInfo(string expectedDuration, int[] timeSpanArgs) - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); - var TestResultWithHrMinSecMs = new ObjectModel.TestResult(new TestCase("DymmyNamespace.DummyClass.TestName", new Uri("some://uri"), "TestSource") { DisplayName = "TestName" }) - { - Outcome = TestOutcome.Passed, - Duration = new TimeSpan(timeSpanArgs[0], timeSpanArgs[1], timeSpanArgs[2], timeSpanArgs[3], timeSpanArgs[4]) - }; - - loggerEvents.RaiseTestResult(new TestResultEventArgs(TestResultWithHrMinSecMs)); - loggerEvents.WaitForEventCompletion(); - - this.mockOutput.Verify(o => o.Write(PassedTestIndicator, OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine("TestName " + expectedDuration, OutputLevel.Information), Times.Once()); - } + [TestMethod] + public void TestResultHandlerShouldNotShowNotStdOutMsgOfPassedTestIfVerbosityIsNormal() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); + + var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); + string message = "Dummy message"; + TestResultMessage testResultMessage = new(TestResultMessage.StandardOutCategory, message); + var testresult = new ObjectModel.TestResult(testcase) + { + Outcome = TestOutcome.Passed + }; + testresult.Messages.Add(testResultMessage); - [DataTestMethod] - public void TestResultHandlerForTestResultWithDurationLessThanOneMsShouldPrintDurationInfo() - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); - var TestResultWithHrMinSecMs = new ObjectModel.TestResult(new TestCase("DymmyNamespace.DummyClass.TestName", new Uri("some://uri"), "TestSource") { DisplayName = "TestName" }) - { - Outcome = TestOutcome.Passed, - Duration = TimeSpan.FromTicks(50) - }; - - loggerEvents.RaiseTestResult(new TestResultEventArgs(TestResultWithHrMinSecMs)); - loggerEvents.WaitForEventCompletion(); - - this.mockOutput.Verify(o => o.Write(PassedTestIndicator, OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine("TestName [< 1 ms]", OutputLevel.Information), Times.Once()); - } + loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); + loggerEvents.WaitForEventCompletion(); - [TestMethod] - public void TestRunCompleteHandlerShouldWriteToConsoleIfTestsPass() - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); - - foreach (var testResult in this.GetTestResultObject(TestOutcome.Passed)) - { - loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); - } - loggerEvents.CompleteTestRun(null, false, false, null, null, null, new TimeSpan(1, 0, 0, 0)); - - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryTotalTests, 1), OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryPassedTests, 1), OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryFailedTests, 0), OutputLevel.Information), Times.Never()); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummarySkippedTests, 0), OutputLevel.Information), Times.Never()); - this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunSuccessful, OutputLevel.Information), Times.Once()); - this.mockProgressIndicator.Verify(pi => pi.Stop(), Times.Once); - } + _mockOutput.Verify(o => o.WriteLine("", OutputLevel.Information), Times.Never()); + _mockOutput.Verify(o => o.WriteLine(" " + message, OutputLevel.Information), Times.Never()); + } + + [TestMethod] + public void TestResultHandlerShouldNotShowDbgTrcMsg() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); + + var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); + string message = "Dummy message"; + TestResultMessage testResultMessage = new(TestResultMessage.DebugTraceCategory, message); + var testresult = new ObjectModel.TestResult(testcase) + { + Outcome = TestOutcome.Passed + }; + testresult.Messages.Add(testResultMessage); + + loggerEvents.RaiseTestResult(new TestResultEventArgs(testresult)); + loggerEvents.WaitForEventCompletion(); + + _mockOutput.Verify(o => o.WriteLine(CommandLineResources.DbgTrcMessagesBanner, OutputLevel.Information), Times.Never()); + _mockOutput.Verify(o => o.WriteLine(" " + message, OutputLevel.Information), Times.Never()); + } - [TestMethod] - public void TestRunCompleteHandlerShouldWriteToConsoleIfTestsFail() - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); - - foreach (var testResult in this.GetTestResultObject(TestOutcome.Failed)) - { - loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); - } - loggerEvents.CompleteTestRun(null, false, false, null, null, null, new TimeSpan(1, 0, 0, 0)); - - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryTotalTests, 1), OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryFailedTests, 1), OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryPassedTests, 0), OutputLevel.Information), Times.Never()); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummarySkippedTests, 0), OutputLevel.Information), Times.Never()); - this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunFailed, OutputLevel.Error), Times.Once()); + [TestMethod] + public void TestResultHandlerShouldWriteToConsoleButSkipPassedTestsForMinimalVerbosity() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", "minimal" }, + { DefaultLoggerParameterNames.TargetFramework , "net451"} + }; + _consoleLogger.Initialize(loggerEvents, parameters); + + foreach (var testResult in GetTestResultsObject()) + { + loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); } + loggerEvents.WaitForEventCompletion(); + + _mockOutput.Verify(o => o.Write(PassedTestIndicator, OutputLevel.Information), Times.Never); + _mockOutput.Verify(o => o.WriteLine("TestName [1 h 2 m]", OutputLevel.Information), Times.Never); + _mockOutput.Verify(o => o.Write(FailedTestIndicator, OutputLevel.Information), Times.Once); + _mockOutput.Verify(o => o.WriteLine("TestName [4 m 5 s]", OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.Write(SkippedTestIndicator, OutputLevel.Information), Times.Exactly(3)); + _mockOutput.Verify(o => o.WriteLine("TestName", OutputLevel.Information), Times.Exactly(3)); + } + + [TestMethod] + public void TestResultHandlerShouldWriteToNoTestResultForQuietVerbosity() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", "quiet" }, + { DefaultLoggerParameterNames.TargetFramework , "net451"} + }; + _consoleLogger.Initialize(loggerEvents, parameters); - [TestMethod] - public void TestRunCompleteHandlerShouldWriteToConsoleIfTestsCanceled() - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary - { - { "verbosity", "normal" } - }; - this.consoleLogger.Initialize(loggerEvents, parameters); - - foreach (var testResult in this.GetTestResultObject(TestOutcome.Failed)) - { - loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); - } - loggerEvents.CompleteTestRun(null, true, false, null, null, null, new TimeSpan(1, 0, 0, 0)); - - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryForCanceledOrAbortedRun), OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryFailedTests, 1), OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryPassedTests, 0), OutputLevel.Information), Times.Never()); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummarySkippedTests, 0), OutputLevel.Information), Times.Never()); - this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunCanceled, OutputLevel.Error), Times.Once()); + foreach (var testResult in GetTestResultsObject()) + { + loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); } + loggerEvents.WaitForEventCompletion(); + + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.PassedTestIndicator, "TestName [1 h 2 m]"), OutputLevel.Information), Times.Never); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.FailedTestIndicator, "TestName [4 m 5 s]"), OutputLevel.Information), Times.Never); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.SkippedTestIndicator, "TestName"), OutputLevel.Warning), Times.Never); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.NotRunTestIndicator, "TestName"), OutputLevel.Information), Times.Never); + } - [TestMethod] - public void TestRunCompleteHandlerShouldWriteToConsoleIfTestsCanceledWithoutRunningAnyTest() + [DataRow("[1 h 2 m]", new int[5] { 0, 1, 2, 3, 78 })] + [DataRow("[4 m 3 s]", new int[5] { 0, 0, 4, 3, 78 })] + [DataRow("[3 s]", new int[5] { 0, 0, 0, 3, 78 })] + [DataRow("[78 ms]", new int[5] { 0, 0, 0, 0, 78 })] + [DataRow("[1 h]", new int[5] { 0, 1, 0, 5, 78 })] + [DataRow("[5 m]", new int[5] { 0, 0, 5, 0, 78 })] + [DataRow("[4 s]", new int[5] { 0, 0, 0, 4, 0 })] + [DataTestMethod] + public void TestResultHandlerForTestResultWithDurationShouldPrintDurationInfo(string expectedDuration, int[] timeSpanArgs) + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); + var testResultWithHrMinSecMs = new ObjectModel.TestResult(new TestCase("DymmyNamespace.DummyClass.TestName", new Uri("some://uri"), "TestSource") { DisplayName = "TestName" }) + { + Outcome = TestOutcome.Passed, + Duration = new TimeSpan(timeSpanArgs[0], timeSpanArgs[1], timeSpanArgs[2], timeSpanArgs[3], timeSpanArgs[4]) + }; - loggerEvents.CompleteTestRun(null, true, false, null, null, null, new TimeSpan(1, 0, 0, 0)); + loggerEvents.RaiseTestResult(new TestResultEventArgs(testResultWithHrMinSecMs)); + loggerEvents.WaitForEventCompletion(); - this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunCanceled, OutputLevel.Error), Times.Once()); - } + _mockOutput.Verify(o => o.Write(PassedTestIndicator, OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine("TestName " + expectedDuration, OutputLevel.Information), Times.Once()); + } - [TestMethod] - public void TestRunCompleteHandlerShouldWriteToConsoleIfTestsAborted() + [DataTestMethod] + public void TestResultHandlerForTestResultWithDurationLessThanOneMsShouldPrintDurationInfo() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); + var testResultWithHrMinSecMs = new ObjectModel.TestResult(new TestCase("DymmyNamespace.DummyClass.TestName", new Uri("some://uri"), "TestSource") { DisplayName = "TestName" }) { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); + Outcome = TestOutcome.Passed, + Duration = TimeSpan.FromTicks(50) + }; - foreach (var testResult in this.GetTestResultObject(TestOutcome.Failed)) - { - loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); - } - loggerEvents.CompleteTestRun(null, false, true, null, null, null, new TimeSpan(1, 0, 0, 0)); + loggerEvents.RaiseTestResult(new TestResultEventArgs(testResultWithHrMinSecMs)); + loggerEvents.WaitForEventCompletion(); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryForCanceledOrAbortedRun), OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunAborted, OutputLevel.Error), Times.Once()); - } + _mockOutput.Verify(o => o.Write(PassedTestIndicator, OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine("TestName [< 1 ms]", OutputLevel.Information), Times.Once()); + } - [TestMethod] - public void TestRunCompleteHandlerShouldWriteToConsoleIfTestsAbortedWithoutRunningAnyTest() + [TestMethod] + public void TestRunCompleteHandlerShouldWriteToConsoleIfTestsPass() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); - loggerEvents.CompleteTestRun(null, false, true, null, null, null, new TimeSpan(1, 0, 0, 0)); + foreach (var testResult in GetTestResultObject(TestOutcome.Passed)) + { + loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); + } + loggerEvents.CompleteTestRun(null, false, false, null, null, null, new TimeSpan(1, 0, 0, 0)); + + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryTotalTests, 1), OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryPassedTests, 1), OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryFailedTests, 0), OutputLevel.Information), Times.Never()); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummarySkippedTests, 0), OutputLevel.Information), Times.Never()); + _mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunSuccessful, OutputLevel.Information), Times.Once()); + _mockProgressIndicator.Verify(pi => pi.Stop(), Times.Once); + } + + [TestMethod] + public void TestRunCompleteHandlerShouldWriteToConsoleIfTestsFail() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); - this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunAborted, OutputLevel.Error), Times.Once()); + foreach (var testResult in GetTestResultObject(TestOutcome.Failed)) + { + loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); } + loggerEvents.CompleteTestRun(null, false, false, null, null, null, new TimeSpan(1, 0, 0, 0)); + + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryTotalTests, 1), OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryFailedTests, 1), OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryPassedTests, 0), OutputLevel.Information), Times.Never()); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummarySkippedTests, 0), OutputLevel.Information), Times.Never()); + _mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunFailed, OutputLevel.Error), Times.Once()); + } - [TestMethod] - public void TestRunStartHandlerShouldWriteNumberOfTestSourcesDiscoveredOnConsole() + [TestMethod] + public void TestRunCompleteHandlerShouldWriteToConsoleIfTestsCanceled() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); - var fileHelper = new Mock(); - CommandLineOptions.Instance.Reset(); - CommandLineOptions.Instance.FileHelper = fileHelper.Object; - CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, fileHelper.Object); - string testFilePath = Path.Combine(Path.GetTempPath(), "DmmyTestFile.dll"); - fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); + foreach (var testResult in GetTestResultObject(TestOutcome.Failed)) + { + loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); + } + loggerEvents.CompleteTestRun(null, true, false, null, null, null, new TimeSpan(1, 0, 0, 0)); - CommandLineOptions.Instance.AddSource(testFilePath); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryForCanceledOrAbortedRun), OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryFailedTests, 1), OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryPassedTests, 0), OutputLevel.Information), Times.Never()); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummarySkippedTests, 0), OutputLevel.Information), Times.Never()); + _mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunCanceled, OutputLevel.Error), Times.Once()); + } - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); + [TestMethod] + public void TestRunCompleteHandlerShouldWriteToConsoleIfTestsCanceledWithoutRunningAnyTest() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); + + loggerEvents.CompleteTestRun(null, true, false, null, null, null, new TimeSpan(1, 0, 0, 0)); - var testRunStartEventArgs = new TestRunStartEventArgs(new TestRunCriteria(new List { testFilePath }, 1)); - loggerEvents.RaiseTestRunStart(testRunStartEventArgs); - loggerEvents.WaitForEventCompletion(); + _mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunCanceled, OutputLevel.Error), Times.Once()); + } - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestSourcesDiscovered, CommandLineOptions.Instance.Sources.Count()), OutputLevel.Information), Times.Once()); + [TestMethod] + public void TestRunCompleteHandlerShouldWriteToConsoleIfTestsAborted() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); + + foreach (var testResult in GetTestResultObject(TestOutcome.Failed)) + { + loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); } + loggerEvents.CompleteTestRun(null, false, true, null, null, null, new TimeSpan(1, 0, 0, 0)); + + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryForCanceledOrAbortedRun), OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunAborted, OutputLevel.Error), Times.Once()); + } - [TestMethod] - public void TestRunStartHandlerShouldWriteTestSourcesDiscoveredOnConsoleIfVerbosityDetailed() + [TestMethod] + public void TestRunCompleteHandlerShouldWriteToConsoleIfTestsAbortedWithoutRunningAnyTest() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); - var fileHelper = new Mock(); - CommandLineOptions.Instance.Reset(); - CommandLineOptions.Instance.FileHelper = fileHelper.Object; - CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, fileHelper.Object); - var temp = Path.GetTempPath(); - string testFilePath = Path.Combine(temp, "DummyTestFile.dll"); - fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); - string testFilePath2 = Path.Combine(temp, "DummyTestFile2.dll"); - fileHelper.Setup(fh => fh.Exists(testFilePath2)).Returns(true); + loggerEvents.CompleteTestRun(null, false, true, null, null, null, new TimeSpan(1, 0, 0, 0)); - CommandLineOptions.Instance.AddSource(testFilePath); - CommandLineOptions.Instance.AddSource(testFilePath2); + _mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunAborted, OutputLevel.Error), Times.Once()); + } - var parameters = new Dictionary(); - parameters.Add("verbosity", "detailed"); - this.consoleLogger.Initialize(loggerEvents, parameters); + [TestMethod] + public void TestRunStartHandlerShouldWriteNumberOfTestSourcesDiscoveredOnConsole() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); - var testRunStartEventArgs = new TestRunStartEventArgs(new TestRunCriteria(new List { testFilePath }, 1)); - loggerEvents.RaiseTestRunStart(testRunStartEventArgs); - loggerEvents.WaitForEventCompletion(); + var fileHelper = new Mock(); + CommandLineOptions.Instance.Reset(); + CommandLineOptions.Instance.FileHelper = fileHelper.Object; + CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, fileHelper.Object); + string testFilePath = Path.Combine(Path.GetTempPath(), "DmmyTestFile.dll"); + fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestSourcesDiscovered, CommandLineOptions.Instance.Sources.Count()), OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(testFilePath, OutputLevel.Information), Times.Once); - this.mockOutput.Verify(o => o.WriteLine(testFilePath, OutputLevel.Information), Times.Once); - } + CommandLineOptions.Instance.AddSource(testFilePath); - [TestMethod] - public void TestRunStartHandlerShouldNotWriteTestSourcesDiscoveredOnConsoleIfVerbosityNotDetailed() + var parameters = new Dictionary { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); - var fileHelper = new Mock(); - CommandLineOptions.Instance.Reset(); - CommandLineOptions.Instance.FileHelper = fileHelper.Object; - CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, fileHelper.Object); - var temp = Path.GetTempPath(); - string testFilePath = Path.Combine(temp, "DummyTestFile.dll"); - fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); - string testFilePath2 = Path.Combine(temp, "DummyTestFile2.dll"); - fileHelper.Setup(fh => fh.Exists(testFilePath2)).Returns(true); + var testRunStartEventArgs = new TestRunStartEventArgs(new TestRunCriteria(new List { testFilePath }, 1)); + loggerEvents.RaiseTestRunStart(testRunStartEventArgs); + loggerEvents.WaitForEventCompletion(); - CommandLineOptions.Instance.AddSource(testFilePath); - CommandLineOptions.Instance.AddSource(testFilePath2); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestSourcesDiscovered, CommandLineOptions.Instance.Sources.Count()), OutputLevel.Information), Times.Once()); + } - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); + [TestMethod] + public void TestRunStartHandlerShouldWriteTestSourcesDiscoveredOnConsoleIfVerbosityDetailed() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + + var fileHelper = new Mock(); + CommandLineOptions.Instance.Reset(); + CommandLineOptions.Instance.FileHelper = fileHelper.Object; + CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, fileHelper.Object); + var temp = Path.GetTempPath(); + string testFilePath = Path.Combine(temp, "DummyTestFile.dll"); + fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); + string testFilePath2 = Path.Combine(temp, "DummyTestFile2.dll"); + fileHelper.Setup(fh => fh.Exists(testFilePath2)).Returns(true); + + CommandLineOptions.Instance.AddSource(testFilePath); + CommandLineOptions.Instance.AddSource(testFilePath2); + + var parameters = new Dictionary + { + { "verbosity", "detailed" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); - var testRunStartEventArgs = new TestRunStartEventArgs(new TestRunCriteria(new List { testFilePath }, 1)); - loggerEvents.RaiseTestRunStart(testRunStartEventArgs); - loggerEvents.WaitForEventCompletion(); + var testRunStartEventArgs = new TestRunStartEventArgs(new TestRunCriteria(new List { testFilePath }, 1)); + loggerEvents.RaiseTestRunStart(testRunStartEventArgs); + loggerEvents.WaitForEventCompletion(); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestSourcesDiscovered, CommandLineOptions.Instance.Sources.Count()), OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(testFilePath, OutputLevel.Information), Times.Never); - this.mockOutput.Verify(o => o.WriteLine(testFilePath2, OutputLevel.Information), Times.Never); - } + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestSourcesDiscovered, CommandLineOptions.Instance.Sources.Count()), OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(testFilePath, OutputLevel.Information), Times.Once); + _mockOutput.Verify(o => o.WriteLine(testFilePath, OutputLevel.Information), Times.Once); + } - [TestMethod] - public void PrintTimeHandlerShouldPrintElapsedTimeOnConsole() - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); - - foreach (var testResult in this.GetTestResultObject(TestOutcome.Passed)) - { - loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); - } - loggerEvents.CompleteTestRun(null, false, false, null, null, null, new TimeSpan(1, 0, 0, 0)); - loggerEvents.CompleteTestRun(null, false, false, null, null, null, new TimeSpan(0, 1, 0, 0)); - loggerEvents.CompleteTestRun(null, false, false, null, null, null, new TimeSpan(0, 0, 1, 0)); - loggerEvents.CompleteTestRun(null, false, false, null, null, null, new TimeSpan(0, 0, 0, 1)); - - // Verify PrintTimeSpan with different formats - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.ExecutionTimeFormatString, 1, CommandLineResources.Days), OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.ExecutionTimeFormatString, 1, CommandLineResources.Hours), OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.ExecutionTimeFormatString, 1, CommandLineResources.Minutes), OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.ExecutionTimeFormatString, 1, CommandLineResources.Seconds), OutputLevel.Information), Times.Once()); - } + [TestMethod] + public void TestRunStartHandlerShouldNotWriteTestSourcesDiscoveredOnConsoleIfVerbosityNotDetailed() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + + var fileHelper = new Mock(); + CommandLineOptions.Instance.Reset(); + CommandLineOptions.Instance.FileHelper = fileHelper.Object; + CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, fileHelper.Object); + var temp = Path.GetTempPath(); + string testFilePath = Path.Combine(temp, "DummyTestFile.dll"); + fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); + string testFilePath2 = Path.Combine(temp, "DummyTestFile2.dll"); + fileHelper.Setup(fh => fh.Exists(testFilePath2)).Returns(true); + + CommandLineOptions.Instance.AddSource(testFilePath); + CommandLineOptions.Instance.AddSource(testFilePath2); + + var parameters = new Dictionary + { + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); - [TestMethod] - public void DisplayFullInformationShouldWriteErrorMessageAndStackTraceToConsole() - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); - - var testresults = this.GetTestResultObject(TestOutcome.Failed); - testresults[0].ErrorMessage = "ErrorMessage"; - testresults[0].ErrorStackTrace = "ErrorStackTrace"; - foreach (var testResult in testresults) - { - loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); - } - loggerEvents.WaitForEventCompletion(); - - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, "{0}", " ErrorMessage"), OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, "{0}", " ErrorStackTrace"), OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(" Error Message:", OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(" Stack Trace:", OutputLevel.Information), Times.Once()); + var testRunStartEventArgs = new TestRunStartEventArgs(new TestRunCriteria(new List { testFilePath }, 1)); + loggerEvents.RaiseTestRunStart(testRunStartEventArgs); + loggerEvents.WaitForEventCompletion(); + + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestSourcesDiscovered, CommandLineOptions.Instance.Sources.Count()), OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(testFilePath, OutputLevel.Information), Times.Never); + _mockOutput.Verify(o => o.WriteLine(testFilePath2, OutputLevel.Information), Times.Never); + } + + [TestMethod] + public void PrintTimeHandlerShouldPrintElapsedTimeOnConsole() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); + + foreach (var testResult in GetTestResultObject(TestOutcome.Passed)) + { + loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); } + loggerEvents.CompleteTestRun(null, false, false, null, null, null, new TimeSpan(1, 0, 0, 0)); + loggerEvents.CompleteTestRun(null, false, false, null, null, null, new TimeSpan(0, 1, 0, 0)); + loggerEvents.CompleteTestRun(null, false, false, null, null, null, new TimeSpan(0, 0, 1, 0)); + loggerEvents.CompleteTestRun(null, false, false, null, null, null, new TimeSpan(0, 0, 0, 1)); + + // Verify PrintTimeSpan with different formats + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.ExecutionTimeFormatString, 1, CommandLineResources.Days), OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.ExecutionTimeFormatString, 1, CommandLineResources.Hours), OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.ExecutionTimeFormatString, 1, CommandLineResources.Minutes), OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.ExecutionTimeFormatString, 1, CommandLineResources.Seconds), OutputLevel.Information), Times.Once()); + } - [TestMethod] - public void DisplayFullInformationShouldWriteStdMessageWithNewLine() + [TestMethod] + public void DisplayFullInformationShouldWriteErrorMessageAndStackTraceToConsole() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); + + var testresults = GetTestResultObject(TestOutcome.Failed); + testresults[0].ErrorMessage = "ErrorMessage"; + testresults[0].ErrorStackTrace = "ErrorStackTrace"; + foreach (var testResult in testresults) { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", "detailed"); - this.consoleLogger.Initialize(loggerEvents, parameters); + loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); + } + loggerEvents.WaitForEventCompletion(); - var testresults = this.GetTestResultObject(TestOutcome.Passed); - testresults[0].Messages.Add(new TestResultMessage(TestResultMessage.StandardOutCategory, "Hello")); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, "{0}", " ErrorMessage"), OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, "{0}", " ErrorStackTrace"), OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(" Error Message:", OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(" Stack Trace:", OutputLevel.Information), Times.Once()); + } - foreach (var testResult in testresults) - { - loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); - } - loggerEvents.WaitForEventCompletion(); + [TestMethod] + public void DisplayFullInformationShouldWriteStdMessageWithNewLine() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", "detailed" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); + + var testresults = GetTestResultObject(TestOutcome.Passed); + testresults[0].Messages.Add(new TestResultMessage(TestResultMessage.StandardOutCategory, "Hello")); - this.mockOutput.Verify(o => o.Write(PassedTestIndicator, OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine("TestName", OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(" Hello", OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(String.Empty, OutputLevel.Information), Times.AtLeastOnce); + foreach (var testResult in testresults) + { + loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); } + loggerEvents.WaitForEventCompletion(); - [TestMethod] - public void GetTestMessagesShouldWriteMessageAndStackTraceToConsole() + _mockOutput.Verify(o => o.Write(PassedTestIndicator, OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine("TestName", OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(" Hello", OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(String.Empty, OutputLevel.Information), Times.AtLeastOnce); + } + + [TestMethod] + public void GetTestMessagesShouldWriteMessageAndStackTraceToConsole() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); - var testresults = this.GetTestResultObject(TestOutcome.Failed); - testresults[0].Messages.Add(new TestResultMessage(TestResultMessage.StandardOutCategory, "StandardOutCategory")); - testresults[0].Messages.Add(new TestResultMessage(TestResultMessage.StandardErrorCategory, "StandardErrorCategory")); - testresults[0].Messages.Add(new TestResultMessage(TestResultMessage.AdditionalInfoCategory, "AdditionalInfoCategory")); - testresults[0].Messages.Add(new TestResultMessage(TestResultMessage.AdditionalInfoCategory, "AnotherAdditionalInfoCategory")); + var testresults = GetTestResultObject(TestOutcome.Failed); + testresults[0].Messages.Add(new TestResultMessage(TestResultMessage.StandardOutCategory, "StandardOutCategory")); + testresults[0].Messages.Add(new TestResultMessage(TestResultMessage.StandardErrorCategory, "StandardErrorCategory")); + testresults[0].Messages.Add(new TestResultMessage(TestResultMessage.AdditionalInfoCategory, "AdditionalInfoCategory")); + testresults[0].Messages.Add(new TestResultMessage(TestResultMessage.AdditionalInfoCategory, "AnotherAdditionalInfoCategory")); - foreach (var testResult in testresults) - { - loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); - } - loggerEvents.WaitForEventCompletion(); + foreach (var testResult in testresults) + { + loggerEvents.RaiseTestResult(new TestResultEventArgs(testResult)); + } + loggerEvents.WaitForEventCompletion(); - this.mockOutput.Verify(o => o.WriteLine(" Standard Output Messages:", OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(" StandardOutCategory", OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(" Standard Output Messages:", OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(" StandardOutCategory", OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(" Standard Error Messages:", OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(" StandardErrorCategory", OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(" Standard Error Messages:", OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(" StandardErrorCategory", OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(" Additional Information Messages:", OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(" AdditionalInfoCategory AnotherAdditionalInfoCategory", OutputLevel.Information), Times.Once()); - } + _mockOutput.Verify(o => o.WriteLine(" Additional Information Messages:", OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(" AdditionalInfoCategory AnotherAdditionalInfoCategory", OutputLevel.Information), Times.Once()); + } - [DataRow("quiet")] - [DataRow("Normal")] - [DataRow("minimal")] - [DataRow("detailed")] - [TestMethod] - public void AttachmentInformationShouldBeWrittenToConsoleIfAttachmentsArePresent(string verbosityLevel) - { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", verbosityLevel); - this.consoleLogger.Initialize(loggerEvents, parameters); - - var attachmentSet = new AttachmentSet(new Uri("test://uri"), "myattachmentset"); - var uriDataAttachment = new UriDataAttachment(new Uri("file://server/filename.ext"), "description"); - attachmentSet.Attachments.Add(uriDataAttachment); - var uriDataAttachment1 = new UriDataAttachment(new Uri("file://server/filename1.ext"), "description"); - attachmentSet.Attachments.Add(uriDataAttachment1); - var attachmentSetList = new List - { - attachmentSet - }; - loggerEvents.CompleteTestRun(null, false, false, null, new Collection(attachmentSetList), new Collection(), new TimeSpan(1, 0, 0, 0)); - - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.AttachmentOutputFormat, uriDataAttachment.Uri.LocalPath), OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.AttachmentOutputFormat, uriDataAttachment1.Uri.LocalPath), OutputLevel.Information), Times.Once()); - } + [DataRow("quiet")] + [DataRow("Normal")] + [DataRow("minimal")] + [DataRow("detailed")] + [TestMethod] + public void AttachmentInformationShouldBeWrittenToConsoleIfAttachmentsArePresent(string verbosityLevel) + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary + { + { "verbosity", verbosityLevel } + }; + _consoleLogger.Initialize(loggerEvents, parameters); + + var attachmentSet = new AttachmentSet(new Uri("test://uri"), "myattachmentset"); + var uriDataAttachment = new UriDataAttachment(new Uri("file://server/filename.ext"), "description"); + attachmentSet.Attachments.Add(uriDataAttachment); + var uriDataAttachment1 = new UriDataAttachment(new Uri("file://server/filename1.ext"), "description"); + attachmentSet.Attachments.Add(uriDataAttachment1); + var attachmentSetList = new List + { + attachmentSet + }; + loggerEvents.CompleteTestRun(null, false, false, null, new Collection(attachmentSetList), new Collection(), new TimeSpan(1, 0, 0, 0)); - [TestMethod] - public void ResultsInHeirarchichalOrderShouldReportCorrectCount() + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.AttachmentOutputFormat, uriDataAttachment.Uri.LocalPath), OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.AttachmentOutputFormat, uriDataAttachment1.Uri.LocalPath), OutputLevel.Information), Times.Once()); + } + + [TestMethod] + public void ResultsInHeirarchichalOrderShouldReportCorrectCount() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary { - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); + { "verbosity", "normal" } + }; + _consoleLogger.Initialize(loggerEvents, parameters); - TestCase testCase1 = CreateTestCase("TestCase1"); - TestCase testCase2 = CreateTestCase("TestCase2"); - TestCase testCase3 = CreateTestCase("TestCase3"); + TestCase testCase1 = CreateTestCase("TestCase1"); + TestCase testCase2 = CreateTestCase("TestCase2"); + TestCase testCase3 = CreateTestCase("TestCase3"); - Guid parentExecutionId = Guid.NewGuid(); - TestProperty ParentExecIdProperty = TestProperty.Register("ParentExecId", "ParentExecId", typeof(Guid), TestPropertyAttributes.Hidden, typeof(ObjectModel.TestResult)); - TestProperty ExecutionIdProperty = TestProperty.Register("ExecutionId", "ExecutionId", typeof(Guid), TestPropertyAttributes.Hidden, typeof(ObjectModel.TestResult)); - TestProperty TestTypeProperty = TestProperty.Register("TestType", "TestType", typeof(Guid), TestPropertyAttributes.Hidden, typeof(ObjectModel.TestResult)); + Guid parentExecutionId = Guid.NewGuid(); + TestProperty parentExecIdProperty = TestProperty.Register("ParentExecId", "ParentExecId", typeof(Guid), TestPropertyAttributes.Hidden, typeof(ObjectModel.TestResult)); + TestProperty executionIdProperty = TestProperty.Register("ExecutionId", "ExecutionId", typeof(Guid), TestPropertyAttributes.Hidden, typeof(ObjectModel.TestResult)); + TestProperty testTypeProperty = TestProperty.Register("TestType", "TestType", typeof(Guid), TestPropertyAttributes.Hidden, typeof(ObjectModel.TestResult)); - var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; - result1.SetPropertyValue(ExecutionIdProperty, parentExecutionId); + var result1 = new ObjectModel.TestResult(testCase1) { Outcome = TestOutcome.Failed }; + result1.SetPropertyValue(executionIdProperty, parentExecutionId); - var result2 = new ObjectModel.TestResult(testCase2) { Outcome = TestOutcome.Passed }; - result2.SetPropertyValue(ExecutionIdProperty, Guid.NewGuid()); - result2.SetPropertyValue(ParentExecIdProperty, parentExecutionId); + var result2 = new ObjectModel.TestResult(testCase2) { Outcome = TestOutcome.Passed }; + result2.SetPropertyValue(executionIdProperty, Guid.NewGuid()); + result2.SetPropertyValue(parentExecIdProperty, parentExecutionId); - var result3 = new ObjectModel.TestResult(testCase3) { Outcome = TestOutcome.Failed }; - result3.SetPropertyValue(ExecutionIdProperty, Guid.NewGuid()); - result3.SetPropertyValue(ParentExecIdProperty, parentExecutionId); + var result3 = new ObjectModel.TestResult(testCase3) { Outcome = TestOutcome.Failed }; + result3.SetPropertyValue(executionIdProperty, Guid.NewGuid()); + result3.SetPropertyValue(parentExecIdProperty, parentExecutionId); - loggerEvents.RaiseTestResult(new TestResultEventArgs(result1)); - loggerEvents.RaiseTestResult(new TestResultEventArgs(result2)); - loggerEvents.RaiseTestResult(new TestResultEventArgs(result3)); + loggerEvents.RaiseTestResult(new TestResultEventArgs(result1)); + loggerEvents.RaiseTestResult(new TestResultEventArgs(result2)); + loggerEvents.RaiseTestResult(new TestResultEventArgs(result3)); - loggerEvents.CompleteTestRun(null, false, false, null, null, null, new TimeSpan(1, 0, 0, 0)); + loggerEvents.CompleteTestRun(null, false, false, null, null, null, new TimeSpan(1, 0, 0, 0)); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryFailedTests, 1), OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryPassedTests, 1), OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryTotalTests, 2), OutputLevel.Information), Times.Once()); - } + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryFailedTests, 1), OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryPassedTests, 1), OutputLevel.Information), Times.Once()); + _mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryTotalTests, 2), OutputLevel.Information), Times.Once()); + } - private TestCase CreateTestCase(string testCaseName) + private TestCase CreateTestCase(string testCaseName) + { + return new TestCase(testCaseName, new Uri("some://uri"), "DummySourceFileName"); + } + + private void Setup() + { + _mockRequestData = new Mock(); + _mockMetricsCollection = new Mock(); + _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(_mockMetricsCollection.Object); + + _mockOutput = new Mock(); + _mockProgressIndicator = new Mock(); + _consoleLogger = new ConsoleLogger(_mockOutput.Object, _mockProgressIndicator.Object); + } + + private List GetTestResultsObject() + { + var testcase = new TestCase("DymmyNamespace.DummyClass.TestName", new Uri("some://uri"), "TestSource") { - return new TestCase(testCaseName, new Uri("some://uri"), "DummySourceFileName"); - } + DisplayName = "TestName" + }; - private void Setup() + var duration = new TimeSpan(1, 2, 3); + var testresult = new ObjectModel.TestResult(testcase) + { + Outcome = TestOutcome.Passed, + Duration = duration, + StartTime = DateTime.Now - duration, + EndTime = DateTime.Now + }; + + var duration1 = new TimeSpan(0, 0, 4, 5, 60); + var testresult1 = new ObjectModel.TestResult(testcase) { - this.mockRequestData = new Mock(); - this.mockMetricsCollection = new Mock(); - mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); + Outcome = TestOutcome.Failed, + Duration = duration1, + StartTime = DateTime.Now - duration1, + EndTime = DateTime.Now + }; - this.mockOutput = new Mock(); - this.mockProgressIndicator = new Mock(); - this.consoleLogger = new ConsoleLogger(this.mockOutput.Object, this.mockProgressIndicator.Object); - } + var testresult2 = new ObjectModel.TestResult(testcase) + { + Outcome = TestOutcome.None + }; - private List GetTestResultsObject() - { - var testcase = new TestCase("DymmyNamespace.DummyClass.TestName", new Uri("some://uri"), "TestSource") - { - DisplayName = "TestName" - }; - - var duration = new TimeSpan(1, 2, 3); - var testresult = new ObjectModel.TestResult(testcase) - { - Outcome = TestOutcome.Passed, - Duration = duration, - StartTime = DateTime.Now - duration, - EndTime = DateTime.Now - }; - - var duration1 = new TimeSpan(0, 0, 4, 5, 60); - var testresult1 = new ObjectModel.TestResult(testcase) - { - Outcome = TestOutcome.Failed, - Duration = duration1, - StartTime = DateTime.Now - duration1, - EndTime = DateTime.Now - }; - - var testresult2 = new ObjectModel.TestResult(testcase) - { - Outcome = TestOutcome.None - }; - - var testresult3 = new ObjectModel.TestResult(testcase) - { - Outcome = TestOutcome.NotFound - }; - - var testresult4 = new ObjectModel.TestResult(testcase) - { - Outcome = TestOutcome.Skipped - }; - - var testresultList = new List { testresult, testresult1, testresult2, testresult3, testresult4 }; - - return testresultList; - } + var testresult3 = new ObjectModel.TestResult(testcase) + { + Outcome = TestOutcome.NotFound + }; - private List GetPassedTestResultsObject() + var testresult4 = new ObjectModel.TestResult(testcase) { - var testcase = new TestCase("DymmyNamespace.DummyClass.TestName", new Uri("some://uri"), "TestSourcePassed") - { - DisplayName = "TestName" - }; + Outcome = TestOutcome.Skipped + }; - var duration = new TimeSpan(0, 0, 1, 2, 3); - var testresult = new ObjectModel.TestResult(testcase) - { - Outcome = TestOutcome.Passed, - Duration = duration, - StartTime = DateTime.Now - duration, - EndTime = DateTime.Now - }; + var testresultList = new List { testresult, testresult1, testresult2, testresult3, testresult4 }; - var testresult1 = new ObjectModel.TestResult(testcase) - { - Outcome = TestOutcome.Skipped - }; + return testresultList; + } - var testresultList = new List { testresult, testresult1 }; + private List GetPassedTestResultsObject() + { + var testcase = new TestCase("DymmyNamespace.DummyClass.TestName", new Uri("some://uri"), "TestSourcePassed") + { + DisplayName = "TestName" + }; - return testresultList; - } + var duration = new TimeSpan(0, 0, 1, 2, 3); + var testresult = new ObjectModel.TestResult(testcase) + { + Outcome = TestOutcome.Passed, + Duration = duration, + StartTime = DateTime.Now - duration, + EndTime = DateTime.Now + }; + + var testresult1 = new ObjectModel.TestResult(testcase) + { + Outcome = TestOutcome.Skipped + }; + + var testresultList = new List { testresult, testresult1 }; + + return testresultList; + } - private List GetTestResultObject(TestOutcome outcome) + private List GetTestResultObject(TestOutcome outcome) + { + var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); + var testresult = new ObjectModel.TestResult(testcase) { - var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource"); - var testresult = new ObjectModel.TestResult(testcase) - { - Outcome = outcome - }; - var testresultList = new List { testresult }; - return testresultList; - } + Outcome = outcome + }; + var testresultList = new List { testresult }; + return testresultList; } -} +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs index 13ae7d8fb8..7e9bb92378 100644 --- a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs +++ b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs @@ -1,125 +1,125 @@ -// Copyright(c) Microsoft Corporation.All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +namespace vstest.console.UnitTests.Internal; + +using Microsoft.Extensions.FileSystemGlobbing; +using Microsoft.Extensions.FileSystemGlobbing.Abstractions; +using Microsoft.VisualStudio.TestPlatform.CommandLine; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + using System; +using System.Collections.Generic; using System.Text.RegularExpressions; -namespace vstest.console.UnitTests.Internal +using vstest.console.Internal; + +[TestClass] +public class FilePatternParserTests { - using Microsoft.Extensions.FileSystemGlobbing; - using Microsoft.Extensions.FileSystemGlobbing.Abstractions; - using Microsoft.VisualStudio.TestPlatform.CommandLine; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using System.Collections.Generic; - using vstest.console.Internal; - - [TestClass] - public class FilePatternParserTests + private FilePatternParser _filePatternParser; + private Mock _mockMatcherHelper; + private Mock _mockFileHelper; + + [TestInitialize] + public void TestInit() + { + _mockMatcherHelper = new Mock(); + _mockFileHelper = new Mock(); + _filePatternParser = new FilePatternParser(_mockMatcherHelper.Object, _mockFileHelper.Object); + } + + [TestMethod] + public void FilePatternParserShouldCorrectlySplitPatternAndDirectory() + { + var patternMatchingResult = new PatternMatchingResult(new List()); + _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); + _filePatternParser.GetMatchingFiles(TranslatePath(@"C:\Users\vanidhi\Desktop\a\c\*bc.dll")); + + // Assert + _mockMatcherHelper.Verify(x => x.AddInclude(TranslatePath(@"*bc.dll"))); + _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(TranslatePath(@"C:\Users\vanidhi\Desktop\a\c"))))); + } + + [TestMethod] + public void FilePatternParserShouldCorrectlySplitWithArbitraryDirectoryDepth() + { + var patternMatchingResult = new PatternMatchingResult(new List()); + _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); + _filePatternParser.GetMatchingFiles(TranslatePath(@"C:\Users\vanidhi\**\c\*bc.txt")); + + // Assert + _mockMatcherHelper.Verify(x => x.AddInclude(TranslatePath(@"**\c\*bc.txt"))); + _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(TranslatePath(@"C:\Users\vanidhi"))))); + } + + [TestMethod] + public void FilePatternParserShouldCorrectlySplitWithWildCardInMultipleDirectory() + { + var patternMatchingResult = new PatternMatchingResult(new List()); + _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); + _filePatternParser.GetMatchingFiles(TranslatePath(@"E:\path\to\project\tests\**.Tests\**\*.Tests.dll")); + + // Assert + _mockMatcherHelper.Verify(x => x.AddInclude(TranslatePath(@"**.Tests\**\*.Tests.dll"))); + _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(TranslatePath(@"E:\path\to\project\tests"))))); + } + + [TestMethod] + public void FilePatternParserShouldCorrectlySplitWithMultipleWildCardInPattern() + { + var patternMatchingResult = new PatternMatchingResult(new List()); + _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); + _filePatternParser.GetMatchingFiles(TranslatePath(@"E:\path\to\project\tests\Tests*.Blame*.dll")); + + // Assert + _mockMatcherHelper.Verify(x => x.AddInclude(TranslatePath(@"Tests*.Blame*.dll"))); + _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(TranslatePath(@"E:\path\to\project\tests"))))); + } + + [TestMethod] + public void FilePatternParserShouldCorrectlySplitWithMultipleWildCardInMultipleDirectory() + { + var patternMatchingResult = new PatternMatchingResult(new List()); + _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); + _filePatternParser.GetMatchingFiles(TranslatePath(@"E:\path\to\project\*tests\Tests*.Blame*.dll")); + + // Assert + _mockMatcherHelper.Verify(x => x.AddInclude(TranslatePath(@"*tests\Tests*.Blame*.dll"))); + _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(TranslatePath(@"E:\path\to\project"))))); + } + + [TestMethod] + public void FilePatternParserShouldCheckIfFileExistsIfFullPathGiven() + { + var patternMatchingResult = new PatternMatchingResult(new List()); + _mockFileHelper.Setup(x => x.Exists(TranslatePath(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll"))).Returns(true); + _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); + var matchingFiles = _filePatternParser.GetMatchingFiles(TranslatePath(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll")); + + // Assert + _mockFileHelper.Verify(x => x.Exists(TranslatePath(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll"))); + Assert.IsTrue(matchingFiles.Contains(TranslatePath(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll"))); + } + + [TestMethod] + public void FilePatternParserShouldThrowCommandLineExceptionIfFileDoesNotExist() + { + var patternMatchingResult = new PatternMatchingResult(new List()); + _mockFileHelper.Setup(x => x.Exists(TranslatePath(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll"))).Returns(false); + _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); + + Assert.ThrowsException(() => _filePatternParser.GetMatchingFiles(TranslatePath(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll"))); + } + + private string TranslatePath(string path) { - private FilePatternParser filePatternParser; - private Mock mockMatcherHelper; - private Mock mockFileHelper; - - [TestInitialize] - public void TestInit() - { - this.mockMatcherHelper = new Mock(); - this.mockFileHelper = new Mock(); - this.filePatternParser = new FilePatternParser(this.mockMatcherHelper.Object, this.mockFileHelper.Object); - } - - [TestMethod] - public void FilePatternParserShouldCorrectlySplitPatternAndDirectory() - { - var patternMatchingResult = new PatternMatchingResult(new List()); - this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - this.filePatternParser.GetMatchingFiles(TranslatePath(@"C:\Users\vanidhi\Desktop\a\c\*bc.dll")); - - // Assert - this.mockMatcherHelper.Verify(x => x.AddInclude(TranslatePath(@"*bc.dll"))); - this.mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(TranslatePath(@"C:\Users\vanidhi\Desktop\a\c"))))); - } - - [TestMethod] - public void FilePatternParserShouldCorrectlySplitWithArbitraryDirectoryDepth() - { - var patternMatchingResult = new PatternMatchingResult(new List()); - this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - this.filePatternParser.GetMatchingFiles(TranslatePath(@"C:\Users\vanidhi\**\c\*bc.txt")); - - // Assert - this.mockMatcherHelper.Verify(x => x.AddInclude(TranslatePath(@"**\c\*bc.txt"))); - this.mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(TranslatePath(@"C:\Users\vanidhi"))))); - } - - [TestMethod] - public void FilePatternParserShouldCorrectlySplitWithWildCardInMultipleDirectory() - { - var patternMatchingResult = new PatternMatchingResult(new List()); - this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - this.filePatternParser.GetMatchingFiles(TranslatePath(@"E:\path\to\project\tests\**.Tests\**\*.Tests.dll")); - - // Assert - this.mockMatcherHelper.Verify(x => x.AddInclude(TranslatePath(@"**.Tests\**\*.Tests.dll"))); - this.mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(TranslatePath(@"E:\path\to\project\tests"))))); - } - - [TestMethod] - public void FilePatternParserShouldCorrectlySplitWithMultpleWildCardInPattern() - { - var patternMatchingResult = new PatternMatchingResult(new List()); - this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - this.filePatternParser.GetMatchingFiles(TranslatePath(@"E:\path\to\project\tests\Tests*.Blame*.dll")); - - // Assert - this.mockMatcherHelper.Verify(x => x.AddInclude(TranslatePath(@"Tests*.Blame*.dll"))); - this.mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(TranslatePath(@"E:\path\to\project\tests"))))); - } - - [TestMethod] - public void FilePatternParserShouldCorrectlySplitWithMultpleWildCardInMultipleDirectory() - { - var patternMatchingResult = new PatternMatchingResult(new List()); - this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - this.filePatternParser.GetMatchingFiles(TranslatePath(@"E:\path\to\project\*tests\Tests*.Blame*.dll")); - - // Assert - this.mockMatcherHelper.Verify(x => x.AddInclude(TranslatePath(@"*tests\Tests*.Blame*.dll"))); - this.mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(TranslatePath(@"E:\path\to\project"))))); - } - - [TestMethod] - public void FilePatternParserShouldCheckIfFileExistsIfFullPathGiven() - { - var patternMatchingResult = new PatternMatchingResult(new List()); - this.mockFileHelper.Setup(x => x.Exists(TranslatePath(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll"))).Returns(true); - this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - var matchingFiles = this.filePatternParser.GetMatchingFiles(TranslatePath(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll")); - - // Assert - this.mockFileHelper.Verify(x => x.Exists(TranslatePath(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll"))); - Assert.IsTrue(matchingFiles.Contains(TranslatePath(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll"))); - } - - [TestMethod] - public void FilePatternParserShouldThrowCommandLineExceptionIfFileDoesNotExist() - { - var patternMatchingResult = new PatternMatchingResult(new List()); - this.mockFileHelper.Setup(x => x.Exists(TranslatePath(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll"))).Returns(false); - this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - - Assert.ThrowsException(() => this.filePatternParser.GetMatchingFiles(TranslatePath(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll"))); - } - - private string TranslatePath(string path) - { - // RuntimeInformation has conflict when used - if (Environment.OSVersion.Platform.ToString().StartsWith("Win")) - return path; - - return Regex.Replace(path.Replace("\\", "/"), @"(\w)\:/", @"/mnt/$1/"); - } + // RuntimeInformation has conflict when used + return Environment.OSVersion.Platform.ToString().StartsWith("Win") + ? path + : Regex.Replace(path.Replace("\\", "/"), @"(\w)\:/", @"/mnt/$1/"); } } diff --git a/test/vstest.console.UnitTests/Internal/ProgressIndicatorTests.cs b/test/vstest.console.UnitTests/Internal/ProgressIndicatorTests.cs index 9097d0ee5c..b56d541c8b 100644 --- a/test/vstest.console.UnitTests/Internal/ProgressIndicatorTests.cs +++ b/test/vstest.console.UnitTests/Internal/ProgressIndicatorTests.cs @@ -1,97 +1,96 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Internal +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Internal; + +using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; +using Utilities; +using TestTools.UnitTesting; +using Moq; + +[TestClass] +public class ProgressIndicatorTests { - using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; + ProgressIndicator _indicator; + Mock _consoleOutput; + Mock _consoleHelper; + + [TestInitialize] + public void TestInit() + { + _consoleOutput = new Mock(); + _consoleHelper = new Mock(); + _consoleHelper.Setup(c => c.WindowWidth).Returns(100); + _consoleHelper.Setup(c => c.CursorTop).Returns(20); + _indicator = new ProgressIndicator(_consoleOutput.Object, _consoleHelper.Object); + } + + [TestCleanup] + public void TestCleanup() + { + _indicator.Stop(); + } + + [TestMethod] + public void StartShouldStartPrintingProgressMessage() + { + _indicator.Start(); + _consoleOutput.Verify(m => m.Write("Test run in progress.", OutputLevel.Information), Times.Once); + Assert.IsTrue(_indicator.IsRunning); + } + + [TestMethod] + public void StartShouldShowProgressMessage() + { + _indicator.Start(); - [TestClass] - public class ProgressIndicatorTests + _consoleHelper.Setup(c => c.CursorLeft).Returns(30); + System.Threading.Thread.Sleep(1500); + + Assert.IsTrue(_indicator.IsRunning); + _consoleOutput.Verify(m => m.Write("Test run in progress.", OutputLevel.Information), Times.Once); + _consoleOutput.Verify(m => m.Write(".", OutputLevel.Information), Times.Once); + } + + [TestMethod] + public void PauseShouldClearTheStdOutMessage() { - ProgressIndicator indicator; - Mock consoleOutput; - Mock consoleHelper; - - [TestInitialize] - public void TestInit() - { - consoleOutput = new Mock(); - consoleHelper = new Mock(); - consoleHelper.Setup(c => c.WindowWidth).Returns(100); - consoleHelper.Setup(c => c.CursorTop).Returns(20); - indicator = new ProgressIndicator(consoleOutput.Object, consoleHelper.Object); - } - - [TestCleanup] - public void TestCleanup() - { - indicator.Stop(); - } - - [TestMethod] - public void StartShouldStartPrintingProgressMessage() - { - indicator.Start(); - consoleOutput.Verify(m => m.Write("Test run in progress.", OutputLevel.Information), Times.Once); - Assert.IsTrue(indicator.IsRunning); - } - - [TestMethod] - public void StartShouldShowProgressMessage() - { - indicator.Start(); - - consoleHelper.Setup(c => c.CursorLeft).Returns(30); - System.Threading.Thread.Sleep(1500); - - Assert.IsTrue(indicator.IsRunning); - consoleOutput.Verify(m => m.Write("Test run in progress.", OutputLevel.Information), Times.Once); - consoleOutput.Verify(m => m.Write(".", OutputLevel.Information), Times.Once); - } - - [TestMethod] - public void PauseShouldClearTheStdOutMessage() - { - indicator.Start(); - indicator.Pause(); - - Assert.IsFalse(indicator.IsRunning); - string clearMessage = new string(' ', consoleHelper.Object.WindowWidth); - consoleOutput.Verify(m => m.Write("Test run in progress.", OutputLevel.Information), Times.Once); - consoleOutput.Verify(m => m.Write(clearMessage, OutputLevel.Information), Times.Once); - - consoleHelper.Verify(ch => ch.SetCursorPosition(0, 20), Times.Exactly(2)); - } - - [TestMethod] - public void PauseStartAndStopShouldClearPrintProgressAndThenClearTheStdOutMessage() - { - indicator.Start(); - indicator.Pause(); - indicator.Start(); - indicator.Stop(); - - Assert.IsFalse(indicator.IsRunning); - string clearMessage = new string(' ', consoleHelper.Object.WindowWidth); - consoleOutput.Verify(m => m.Write("Test run in progress.", OutputLevel.Information), Times.Exactly(2)); - consoleOutput.Verify(m => m.Write(clearMessage, OutputLevel.Information), Times.Exactly(2)); - consoleHelper.Verify(ch => ch.SetCursorPosition(0, 20), Times.Exactly(4)); - } - - [TestMethod] - public void StopShouldClearTheStdOutMessage() - { - indicator.Start(); - indicator.Stop(); - - Assert.IsFalse(indicator.IsRunning); - string clearMessage = new string(' ', consoleHelper.Object.WindowWidth); - consoleOutput.Verify(m => m.Write("Test run in progress.", OutputLevel.Information), Times.Once); - consoleOutput.Verify(m => m.Write(clearMessage, OutputLevel.Information), Times.Once); - consoleHelper.Verify(ch => ch.SetCursorPosition(0, 20), Times.Exactly(2)); - } + _indicator.Start(); + _indicator.Pause(); + + Assert.IsFalse(_indicator.IsRunning); + string clearMessage = new(' ', _consoleHelper.Object.WindowWidth); + _consoleOutput.Verify(m => m.Write("Test run in progress.", OutputLevel.Information), Times.Once); + _consoleOutput.Verify(m => m.Write(clearMessage, OutputLevel.Information), Times.Once); + + _consoleHelper.Verify(ch => ch.SetCursorPosition(0, 20), Times.Exactly(2)); + } + + [TestMethod] + public void PauseStartAndStopShouldClearPrintProgressAndThenClearTheStdOutMessage() + { + _indicator.Start(); + _indicator.Pause(); + _indicator.Start(); + _indicator.Stop(); + + Assert.IsFalse(_indicator.IsRunning); + string clearMessage = new(' ', _consoleHelper.Object.WindowWidth); + _consoleOutput.Verify(m => m.Write("Test run in progress.", OutputLevel.Information), Times.Exactly(2)); + _consoleOutput.Verify(m => m.Write(clearMessage, OutputLevel.Information), Times.Exactly(2)); + _consoleHelper.Verify(ch => ch.SetCursorPosition(0, 20), Times.Exactly(4)); + } + + [TestMethod] + public void StopShouldClearTheStdOutMessage() + { + _indicator.Start(); + _indicator.Stop(); + + Assert.IsFalse(_indicator.IsRunning); + string clearMessage = new(' ', _consoleHelper.Object.WindowWidth); + _consoleOutput.Verify(m => m.Write("Test run in progress.", OutputLevel.Information), Times.Once); + _consoleOutput.Verify(m => m.Write(clearMessage, OutputLevel.Information), Times.Once); + _consoleHelper.Verify(ch => ch.SetCursorPosition(0, 20), Times.Exactly(2)); } } \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/CLIRunSettingsArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/CLIRunSettingsArgumentProcessorTests.cs index d12f1d3b86..1407e8261d 100644 --- a/test/vstest.console.UnitTests/Processors/CLIRunSettingsArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/CLIRunSettingsArgumentProcessorTests.cs @@ -1,479 +1,479 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace vstest.console.UnitTests.Processors +namespace vstest.console.UnitTests.Processors; + +using System; +using System.Collections.Generic; + +using Microsoft.VisualStudio.TestPlatform.CommandLine; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests; +using Microsoft.VisualStudio.TestPlatform.Common; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; + +[TestClass] +public class CliRunSettingsArgumentProcessorTests { - using System; - using System.Collections.Generic; - - using Microsoft.VisualStudio.TestPlatform.CommandLine; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; - - [TestClass] - public class CLIRunSettingsArgumentProcessorTests - { - private TestableRunSettingsProvider settingsProvider; - private CLIRunSettingsArgumentExecutor executor; - private CommandLineOptions commandLineOptions; - private readonly string DefaultRunSettings = string.Join(Environment.NewLine, + private TestableRunSettingsProvider _settingsProvider; + private CliRunSettingsArgumentExecutor _executor; + private CommandLineOptions _commandLineOptions; + private readonly string _defaultRunSettings = string.Join(Environment.NewLine, "", -"", -" ", -" ", -" ", -""); + "", + " ", + " ", + " ", + ""); - private readonly string RunSettingsWithDeploymentDisabled = string.Join(Environment.NewLine, - "", + private readonly string _runSettingsWithDeploymentDisabled = string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " False", + " ", + ""); + + private readonly string _runSettingsWithDeploymentEnabled = string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " True", + " ", + ""); + + [TestInitialize] + public void Init() + { + _commandLineOptions = CommandLineOptions.Instance; + _settingsProvider = new TestableRunSettingsProvider(); + _executor = new CliRunSettingsArgumentExecutor(_settingsProvider, _commandLineOptions); + } + + [TestCleanup] + public void Cleanup() + { + _commandLineOptions.Reset(); + } + + [TestMethod] + public void GetMetadataShouldReturnRunSettingsArgumentProcessorCapabilities() + { + var processor = new CliRunSettingsArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is CliRunSettingsArgumentProcessorCapabilities); + } + + [TestMethod] + public void GetExecuterShouldReturnRunSettingsArgumentProcessorCapabilities() + { + var processor = new CliRunSettingsArgumentProcessor(); + Assert.IsTrue(processor.Executor.Value is CliRunSettingsArgumentExecutor); + } + + #region CLIRunSettingsArgumentProcessorCapabilities tests + + [TestMethod] + public void CapabilitiesShouldReturnAppropriateProperties() + { + var capabilities = new CliRunSettingsArgumentProcessorCapabilities(); + + Assert.AreEqual("--", capabilities.CommandName); + var expected = "RunSettings arguments:\r\n Arguments to pass runsettings configurations through commandline. Arguments may be specified as name-value pair of the form [name]=[value] after \"-- \". Note the space after --. \r\n Use a space to separate multiple [name]=[value].\r\n More info on RunSettings arguments support: https://aka.ms/vstest-runsettings-arguments"; + Assert.AreEqual(expected.NormalizeLineEndings().ShowWhiteSpace(), capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); + + Assert.AreEqual(HelpContentPriority.CliRunSettingsArgumentProcessorHelpPriority, capabilities.HelpPriority); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.CliRunSettings, capabilities.Priority); + + Assert.IsFalse(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } + + #endregion + + #region CLIRunSettingsArgumentExecutor tests + + [TestMethod] + public void InitializeShouldNotThrowExceptionIfArgumentIsNull() + { + _executor.Initialize((string[])null); + + Assert.IsNull(_settingsProvider.ActiveRunSettings); + } + + [TestMethod] + public void InitializeShouldNotThrowExceptionIfArgumentIsEmpty() + { + _executor.Initialize(new string[0]); + + Assert.IsNull(_settingsProvider.ActiveRunSettings); + } + + [TestMethod] + public void InitializeShouldCreateEmptyRunSettingsIfArgumentsHasOnlyWhiteSpace() + { + _executor.Initialize(new string[] { " " }); + + Assert.IsNull(_settingsProvider.ActiveRunSettings); + } + + [TestMethod] + public void InitializeShouldSetValueInRunSettings() + { + var args = new string[] { "MSTest.DeploymentEnabled=False" }; + + _executor.Initialize(args); + + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual(_runSettingsWithDeploymentDisabled, _settingsProvider.ActiveRunSettings.SettingsXml); + } + + [TestMethod] + public void InitializeShouldIgnoreKeyIfValueIsNotPassed() + { + var args = new string[] { "MSTest.DeploymentEnabled=False", "MSTest1" }; + + _executor.Initialize(args); + + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual(_runSettingsWithDeploymentDisabled, _settingsProvider.ActiveRunSettings.SettingsXml); + } + + [DataRow("Testameter.Parameter(name=\"asf\",value=\"rgq\")")] + [DataRow("TestRunParameter.Parameter(name=\"asf\",value=\"rgq\")")] + [TestMethod] + public void InitializeShouldThrowErrorIfArgumentIsInValid(string arg) + { + var args = new string[] { arg }; + var str = string.Format(CommandLineResources.MalformedRunSettingsKey); + + CommandLineException ex = Assert.ThrowsException(() => _executor.Initialize(args)); + + Assert.AreEqual(str, ex.Message); + } + + [TestMethod] + public void InitializeShouldIgnoreWhiteSpaceInBeginningOrEndOfKey() + { + var args = new string[] { " MSTest.DeploymentEnabled =False" }; + + _executor.Initialize(args); + + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual(_runSettingsWithDeploymentDisabled, _settingsProvider.ActiveRunSettings.SettingsXml); + } + + [TestMethod] + public void InitializeShouldIgnoreThrowExceptionIfKeyHasWhiteSpace() + { + var args = new string[] { "MST est.DeploymentEnabled=False" }; + + Action action = () => _executor.Initialize(args); + + ExceptionUtilities.ThrowsException( + action, + "One or more runsettings provided contain invalid token"); + } + + [TestMethod] + public void InitializeShouldEncodeXmlIfInvalidXmlCharsArePresent() + { + var args = new string[] { "MSTest.DeploymentEnabled=F>a>", "", " ", " ", " ", " ", - " False", + " F>a><l<se", " ", - ""); + ""), _settingsProvider.ActiveRunSettings.SettingsXml); + } - private readonly string RunSettingsWithDeploymentEnabled = string.Join(Environment.NewLine, - "", + [TestMethod] + public void InitializeShouldIgnoreIfKeyIsNotPassed() + { + var args = new string[] { "MSTest.DeploymentEnabled=False", "=value" }; + + _executor.Initialize(args); + + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual(_runSettingsWithDeploymentDisabled, _settingsProvider.ActiveRunSettings.SettingsXml); + } + + [TestMethod] + public void InitializeShouldIgnoreIfEmptyValueIsPassed() + { + + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(_defaultRunSettings); + _settingsProvider.SetActiveRunSettings(runSettings); + + var args = new string[] { "MSTest.DeploymentEnabled=" }; + _executor.Initialize(args); + + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual(_defaultRunSettings, _settingsProvider.ActiveRunSettings.SettingsXml); + } + + [TestMethod] + public void InitializeShouldOverwriteValueIfNodeAlreadyExists() + { + + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(_defaultRunSettings); + _settingsProvider.SetActiveRunSettings(runSettings); + + var args = new string[] { "MSTest.DeploymentEnabled=True" }; + _executor.Initialize(args); + + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual(_runSettingsWithDeploymentEnabled, _settingsProvider.ActiveRunSettings.SettingsXml); + } + + + [TestMethod] + public void InitializeShouldOverwriteValueIfWhitSpaceIsPassedAndNodeAlreadyExists() + { + + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(_defaultRunSettings); + _settingsProvider.SetActiveRunSettings(runSettings); + + var args = new string[] { "MSTest.DeploymentEnabled= " }; + _executor.Initialize(args); + + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual(string.Join(Environment.NewLine, "", "", " ", " ", " ", " ", - " True", + " ", + " ", " ", - ""); - - [TestInitialize] - public void Init() - { - this.commandLineOptions = CommandLineOptions.Instance; - this.settingsProvider = new TestableRunSettingsProvider(); - this.executor = new CLIRunSettingsArgumentExecutor(this.settingsProvider, this.commandLineOptions); - } - - [TestCleanup] - public void Cleanup() - { - this.commandLineOptions.Reset(); - } - - [TestMethod] - public void GetMetadataShouldReturnRunSettingsArgumentProcessorCapabilities() - { - var processor = new CLIRunSettingsArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is CLIRunSettingsArgumentProcessorCapabilities); - } - - [TestMethod] - public void GetExecuterShouldReturnRunSettingsArgumentProcessorCapabilities() - { - var processor = new CLIRunSettingsArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is CLIRunSettingsArgumentExecutor); - } - - #region CLIRunSettingsArgumentProcessorCapabilities tests - - [TestMethod] - public void CapabilitiesShouldReturnAppropriateProperties() - { - var capabilities = new CLIRunSettingsArgumentProcessorCapabilities(); - - Assert.AreEqual("--", capabilities.CommandName); - var expected = "RunSettings arguments:\r\n Arguments to pass runsettings configurations through commandline. Arguments may be specified as name-value pair of the form [name]=[value] after \"-- \". Note the space after --. \r\n Use a space to separate multiple [name]=[value].\r\n More info on RunSettings arguments support: https://aka.ms/vstest-runsettings-arguments"; - Assert.AreEqual(expected.NormalizeLineEndings().ShowWhiteSpace(), capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); - - Assert.AreEqual(HelpContentPriority.CLIRunSettingsArgumentProcessorHelpPriority, capabilities.HelpPriority); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.CLIRunSettings, capabilities.Priority); - - Assert.IsFalse(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); - } - - #endregion - - #region CLIRunSettingsArgumentExecutor tests - - [TestMethod] - public void InitializeShouldNotThrowExceptionIfArgumentIsNull() - { - this.executor.Initialize((string[])null); - - Assert.IsNull(this.settingsProvider.ActiveRunSettings); - } - - [TestMethod] - public void InitializeShouldNotThrowExceptionIfArgumentIsEmpty() - { - this.executor.Initialize(new string[0]); - - Assert.IsNull(this.settingsProvider.ActiveRunSettings); - } - - [TestMethod] - public void InitializeShouldCreateEmptyRunSettingsIfArgumentsHasOnlyWhiteSpace() - { - this.executor.Initialize(new string[] { " " }); - - Assert.IsNull(this.settingsProvider.ActiveRunSettings); - } - - [TestMethod] - public void InitializeShouldSetValueInRunSettings() - { - var args = new string[] { "MSTest.DeploymentEnabled=False" }; - - this.executor.Initialize(args); - - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual(RunSettingsWithDeploymentDisabled, settingsProvider.ActiveRunSettings.SettingsXml); - } - - [TestMethod] - public void InitializeShouldIgnoreKeyIfValueIsNotPassed() - { - var args = new string[] { "MSTest.DeploymentEnabled=False", "MSTest1" }; - - this.executor.Initialize(args); - - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual(RunSettingsWithDeploymentDisabled, settingsProvider.ActiveRunSettings.SettingsXml); - } - - [DataRow("Testameter.Parameter(name=\"asf\",value=\"rgq\")")] - [DataRow("TestRunParameter.Parameter(name=\"asf\",value=\"rgq\")")] - [TestMethod] - public void InitializeShouldThrowErrorIfArgumentIsInValid(string arg) - { - var args = new string[] { arg }; - var str = string.Format(CommandLineResources.MalformedRunSettingsKey); + ""), _settingsProvider.ActiveRunSettings.SettingsXml); + } + + [TestMethod] + public void InitializeShouldUpdateCommandLineOptionsFrameworkIfProvided() + { - CommandLineException ex = Assert.ThrowsException(() => this.executor.Initialize(args)); + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(_defaultRunSettings); + _settingsProvider.SetActiveRunSettings(runSettings); - Assert.AreEqual(str, ex.Message); - } - - [TestMethod] - public void InitializeShouldIgnoreWhiteSpaceInBeginningOrEndOfKey() - { - var args = new string[] { " MSTest.DeploymentEnabled =False" }; - - this.executor.Initialize(args); - - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual(RunSettingsWithDeploymentDisabled, settingsProvider.ActiveRunSettings.SettingsXml); - } - - [TestMethod] - public void InitializeShouldIgnoreThrowExceptionIfKeyHasWhiteSpace() - { - var args = new string[] { "MST est.DeploymentEnabled=False" }; + var args = new string[] { $"RunConfiguration.TargetFrameworkVersion={Constants.DotNetFramework46}" }; + _executor.Initialize(args); - Action action = () => this.executor.Initialize(args); - - ExceptionUtilities.ThrowsException( - action, - "One or more runsettings provided contain invalid token"); - } + Assert.IsTrue(_commandLineOptions.FrameworkVersionSpecified); + Assert.AreEqual(Constants.DotNetFramework46, _commandLineOptions.TargetFrameworkVersion.Name); + } - [TestMethod] - public void InitializeShouldEncodeXMLIfInvalidXMLCharsArePresent() - { - var args = new string[] { "MSTest.DeploymentEnabled=F>a>", -"", -" ", -" ", -" ", -" ", -" F>a><l<se", -" ", -""), settingsProvider.ActiveRunSettings.SettingsXml); - } - - [TestMethod] - public void InitializeShouldIgnoreIfKeyIsNotPassed() - { - var args = new string[] { "MSTest.DeploymentEnabled=False", "=value" }; - - this.executor.Initialize(args); + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(_defaultRunSettings); + _settingsProvider.SetActiveRunSettings(runSettings); - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual(RunSettingsWithDeploymentDisabled, settingsProvider.ActiveRunSettings.SettingsXml); - } + var args = new string[] { $"RunConfiguration.TargetPlatform={nameof(Architecture.ARM)}" }; + _executor.Initialize(args); - [TestMethod] - public void InitializeShouldIgnoreIfEmptyValueIsPassed() - { - - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(DefaultRunSettings); - this.settingsProvider.SetActiveRunSettings(runSettings); + Assert.IsTrue(_commandLineOptions.ArchitectureSpecified); + Assert.AreEqual(Architecture.ARM, _commandLineOptions.TargetArchitecture); + } - var args = new string[] { "MSTest.DeploymentEnabled=" }; - this.executor.Initialize(args); - - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual(DefaultRunSettings, this.settingsProvider.ActiveRunSettings.SettingsXml); - } - - [TestMethod] - public void InitializeShouldOverwriteValueIfNodeAlreadyExists() - { - - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(DefaultRunSettings); - settingsProvider.SetActiveRunSettings(runSettings); - - var args = new string[] { "MSTest.DeploymentEnabled=True" }; - this.executor.Initialize(args); - - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual(RunSettingsWithDeploymentEnabled, settingsProvider.ActiveRunSettings.SettingsXml); - } - - - [TestMethod] - public void InitializeShouldOverwriteValueIfWhitSpaceIsPassedAndNodeAlreadyExists() - { - - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(DefaultRunSettings); - settingsProvider.SetActiveRunSettings(runSettings); - - var args = new string[] { "MSTest.DeploymentEnabled= " }; - this.executor.Initialize(args); - - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual(string.Join(Environment.NewLine, "", -"", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -""), settingsProvider.ActiveRunSettings.SettingsXml); - } - - [TestMethod] - public void InitializeShouldUpdateCommandLineOptionsFrameworkIfProvided() - { - - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(DefaultRunSettings); - settingsProvider.SetActiveRunSettings(runSettings); - - var args = new string[] { $"RunConfiguration.TargetFrameworkVersion={Constants.DotNetFramework46}" }; - this.executor.Initialize(args); - - Assert.IsTrue(this.commandLineOptions.FrameworkVersionSpecified); - Assert.AreEqual(Constants.DotNetFramework46, this.commandLineOptions.TargetFrameworkVersion.Name); - } - - [TestMethod] - public void InitializeShouldUpdateCommandLineOptionsArchitectureIfProvided() - { - - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(DefaultRunSettings); - settingsProvider.SetActiveRunSettings(runSettings); - - var args = new string[] { $"RunConfiguration.TargetPlatform={nameof(Architecture.ARM)}" }; - this.executor.Initialize(args); - - Assert.IsTrue(this.commandLineOptions.ArchitectureSpecified); - Assert.AreEqual(Architecture.ARM, this.commandLineOptions.TargetArchitecture); - } - - [TestMethod] - public void InitializeShouldNotUpdateCommandLineOptionsArchitectureAndFxIfNotProvided() - { - - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(DefaultRunSettings); - settingsProvider.SetActiveRunSettings(runSettings); - - var args = new string[] { }; - this.executor.Initialize(args); - - Assert.IsFalse(this.commandLineOptions.ArchitectureSpecified); - Assert.IsFalse(this.commandLineOptions.FrameworkVersionSpecified); - } - - [DynamicData(nameof(TestRunParameterArgValidTestCases), DynamicDataSourceType.Method)] - [DataTestMethod] - public void InitializeShouldValidateTestRunParameter(string arg, string runSettingsWithTestRunParameters) - { - var args = new string[] { arg }; - - this.executor.Initialize(args); - - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual(runSettingsWithTestRunParameters, settingsProvider.ActiveRunSettings.SettingsXml); - } - - [DynamicData(nameof(TestRunParameterArgInvalidTestCases), DynamicDataSourceType.Method)] - [DataTestMethod] - public void InitializeShouldThrowErrorIfTestRunParameterNodeIsInValid(string arg) - { - var args = new string[] { arg }; - var str = string.Format(CommandLineResources.InvalidTestRunParameterArgument, arg); - - CommandLineException ex = Assert.ThrowsException(() => this.executor.Initialize(args)); - - Assert.AreEqual(str, ex.Message); - } - - public static IEnumerable TestRunParameterArgInvalidTestCases() - { - return invalidTestCases; - } - - private static readonly List invalidTestCases = new List - { - new object[] { "TestRunParameters.Parameter(name=asf,value=rgq)" }, - new object[] { "TestRunParameters.Parameter(name=\"asf\",value=\"rgq\" )"}, - new object[] { "TestRunParameters.Parameter( name=\"asf\",value=\"rgq\")" }, - new object[] { "TestRunParametersParameter(name=\"asf\",value=\"rgq\")" }, - new object[] { "TestRunParameters.Paramete(name=\"asf\",value=\"rgq\")" }, - new object[] { "TestRunParameters.Parametername=\"asf\",value=\"rgq\")" }, - new object[] { "TestRunParameters.Parameter(ame=\"asf\",value=\"rgq\")" }, - new object[] { "TestRunParameters.Parameter(name\"asf\",value=\"rgq\")" }, - new object[] { "TestRunParameters.Parameter(name=\"asf\" value=\"rgq\")" }, - new object[] { "TestRunParameters.Parameter(name=\"asf\",alue=\"rgq\")" }, - new object[] { "TestRunParameters.Parameter(name=\"asf\",value\"rgq\")" }, - new object[] { "TestRunParameters.Parameter(name=\"asf\",value=\"rgq\"" }, - new object[] { "TestRunParameters.Parameter(name=\"asf\",value=\"rgq\")wfds" }, - new object[] { "TestRunParameters.Parameter(name=\"\",value=\"rgq\")" }, - new object[] { "TestRunParameters.Parameter(name=\"asf\",value=\"\")" }, - new object[] { "TestRunParameters.Parameter(name=asf\",value=\"rgq\")" }, - new object[] { "TestRunParameters.Parameter(name=\"asf,value=\"rgq\")" }, - new object[] { "TestRunParameters.Parameter(name=\"asf\",value=rgq\")" }, - new object[] { "TestRunParameters.Parameter(name=\"asf\",value=\"rgq)" }, - new object[] { "TestRunParameters.Parameter(name=\"asf@#!\",value=\"rgq\")" }, - new object[] { "TestRunParameters.Parameter(name=\"\",value=\"fgf\")" }, - new object[] { "TestRunParameters.Parameter(name=\"gag\",value=\"\")" }, - new object[] { "TestRunParameters.Parameter(name=\"gag\")" } - }; + [TestMethod] + public void InitializeShouldNotUpdateCommandLineOptionsArchitectureAndFxIfNotProvided() + { - public static IEnumerable TestRunParameterArgValidTestCases() - { - return validTestCases; - } - - private static readonly List validTestCases = new List - { - new object[] { "TestRunParameters.Parameter(name=\"weburl\",value=\"&><\")" , - string.Join(Environment.NewLine, "", -"", -" ", -" ", -" ", -" ", -" ", -" ", -"") - }, - new object[] { "TestRunParameters.Parameter(name=\"weburl\",value=\"http://localhost//abc\")" , - string.Join(Environment.NewLine, "", -"", -" ", -" ", -" ", -" ", -" ", -" ", -"") - }, - new object[] { "TestRunParameters.Parameter(name= \"a_sf123_12\",value= \"2324346a!@#$%^*()_+-=':;.,/?{}[]|\")" , - string.Join(Environment.NewLine, "", -"", -" ", -" ", -" ", -" ", -" ", -" ", -"") - }, - new object[] { "TestRunParameters.Parameter(name = \"weburl\" , value = \"http://localhost//abc\")" , - string.Join(Environment.NewLine, "", -"", -" ", -" ", -" ", -" ", -" ", -" ", -"") - }, - }; - #endregion - - [TestMethod] - public void InitializeShouldMergeTestRunParametersWithSpaces() - { - // in powershell call: ConsoleApp1.exe --% --TestRunParameters.Parameter(name =\"myParam\", value=\"myValue\") - // args: - //-- - //TestRunParameters.Parameter(name = "myParam", - //value = "myValue") - - // in cmd: ConsoleApp1.exe -- TestRunParameters.Parameter(name=\"myParam\", value=\"myValue\") - // args: - //-- - //TestRunParameters.Parameter(name = "myParam", - //value = "myValue") - - // in ubuntu wsl without escaping the space: ConsoleApp1.exe-- TestRunParameters.Parameter\(name =\"myParam\", value=\"myValue\"\) - // args: - //-- - //TestRunParameters.Parameter(name = "myParam", - //value = "myValue") - - // in ubuntu wsl with escaping the space: ConsoleApp1.exe-- TestRunParameters.Parameter\(name =\"myParam\",\ value=\"myValue\"\) - // args: - //-- - //TestRunParameters.Parameter(name = "myParam", value = "myValue") - - var args = new string[] { - "--", - "TestRunParameters.Parameter(name=\"myParam\",", - "value=\"myValue\")", - "TestRunParameters.Parameter(name=\"myParam2\",", - "value=\"myValue 2\")", - }; - - var runsettings = string.Join(Environment.NewLine, new[]{ - "", + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(_defaultRunSettings); + _settingsProvider.SetActiveRunSettings(runSettings); + + var args = new string[] { }; + _executor.Initialize(args); + + Assert.IsFalse(_commandLineOptions.ArchitectureSpecified); + Assert.IsFalse(_commandLineOptions.FrameworkVersionSpecified); + } + + [DynamicData(nameof(TestRunParameterArgValidTestCases), DynamicDataSourceType.Method)] + [DataTestMethod] + public void InitializeShouldValidateTestRunParameter(string arg, string runSettingsWithTestRunParameters) + { + var args = new string[] { arg }; + + _executor.Initialize(args); + + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual(runSettingsWithTestRunParameters, _settingsProvider.ActiveRunSettings.SettingsXml); + } + + [DynamicData(nameof(TestRunParameterArgInvalidTestCases), DynamicDataSourceType.Method)] + [DataTestMethod] + public void InitializeShouldThrowErrorIfTestRunParameterNodeIsInValid(string arg) + { + var args = new string[] { arg }; + var str = string.Format(CommandLineResources.InvalidTestRunParameterArgument, arg); + + CommandLineException ex = Assert.ThrowsException(() => _executor.Initialize(args)); + + Assert.AreEqual(str, ex.Message); + } + + public static IEnumerable TestRunParameterArgInvalidTestCases() + { + return InvalidTestCases; + } + + private static readonly List InvalidTestCases = new() + { + new object[] { "TestRunParameters.Parameter(name=asf,value=rgq)" }, + new object[] { "TestRunParameters.Parameter(name=\"asf\",value=\"rgq\" )" }, + new object[] { "TestRunParameters.Parameter( name=\"asf\",value=\"rgq\")" }, + new object[] { "TestRunParametersParameter(name=\"asf\",value=\"rgq\")" }, + new object[] { "TestRunParameters.Paramete(name=\"asf\",value=\"rgq\")" }, + new object[] { "TestRunParameters.Parametername=\"asf\",value=\"rgq\")" }, + new object[] { "TestRunParameters.Parameter(ame=\"asf\",value=\"rgq\")" }, + new object[] { "TestRunParameters.Parameter(name\"asf\",value=\"rgq\")" }, + new object[] { "TestRunParameters.Parameter(name=\"asf\" value=\"rgq\")" }, + new object[] { "TestRunParameters.Parameter(name=\"asf\",alue=\"rgq\")" }, + new object[] { "TestRunParameters.Parameter(name=\"asf\",value\"rgq\")" }, + new object[] { "TestRunParameters.Parameter(name=\"asf\",value=\"rgq\"" }, + new object[] { "TestRunParameters.Parameter(name=\"asf\",value=\"rgq\")wfds" }, + new object[] { "TestRunParameters.Parameter(name=\"\",value=\"rgq\")" }, + new object[] { "TestRunParameters.Parameter(name=\"asf\",value=\"\")" }, + new object[] { "TestRunParameters.Parameter(name=asf\",value=\"rgq\")" }, + new object[] { "TestRunParameters.Parameter(name=\"asf,value=\"rgq\")" }, + new object[] { "TestRunParameters.Parameter(name=\"asf\",value=rgq\")" }, + new object[] { "TestRunParameters.Parameter(name=\"asf\",value=\"rgq)" }, + new object[] { "TestRunParameters.Parameter(name=\"asf@#!\",value=\"rgq\")" }, + new object[] { "TestRunParameters.Parameter(name=\"\",value=\"fgf\")" }, + new object[] { "TestRunParameters.Parameter(name=\"gag\",value=\"\")" }, + new object[] { "TestRunParameters.Parameter(name=\"gag\")" } + }; + + public static IEnumerable TestRunParameterArgValidTestCases() + { + return ValidTestCases; + } + + private static readonly List ValidTestCases = new() + { + new object[] { "TestRunParameters.Parameter(name=\"weburl\",value=\"&><\")" , + string.Join(Environment.NewLine, "", "", " ", " ", " ", " ", - " ", - " ", + " ", " ", - ""}); + "") + }, + new object[] { "TestRunParameters.Parameter(name=\"weburl\",value=\"http://localhost//abc\")" , + string.Join(Environment.NewLine, "", + "", + " ", + " ", + " ", + " ", + " ", + " ", + "") + }, + new object[] { "TestRunParameters.Parameter(name= \"a_sf123_12\",value= \"2324346a!@#$%^*()_+-=':;.,/?{}[]|\")" , + string.Join(Environment.NewLine, "", + "", + " ", + " ", + " ", + " ", + " ", + " ", + "") + }, + new object[] { "TestRunParameters.Parameter(name = \"weburl\" , value = \"http://localhost//abc\")" , + string.Join(Environment.NewLine, "", + "", + " ", + " ", + " ", + " ", + " ", + " ", + "") + }, + }; + #endregion + + [TestMethod] + public void InitializeShouldMergeTestRunParametersWithSpaces() + { + // in powershell call: ConsoleApp1.exe --% --TestRunParameters.Parameter(name =\"myParam\", value=\"myValue\") + // args: + //-- + //TestRunParameters.Parameter(name = "myParam", + //value = "myValue") + + // in cmd: ConsoleApp1.exe -- TestRunParameters.Parameter(name=\"myParam\", value=\"myValue\") + // args: + //-- + //TestRunParameters.Parameter(name = "myParam", + //value = "myValue") + + // in ubuntu wsl without escaping the space: ConsoleApp1.exe-- TestRunParameters.Parameter\(name =\"myParam\", value=\"myValue\"\) + // args: + //-- + //TestRunParameters.Parameter(name = "myParam", + //value = "myValue") + + // in ubuntu wsl with escaping the space: ConsoleApp1.exe-- TestRunParameters.Parameter\(name =\"myParam\",\ value=\"myValue\"\) + // args: + //-- + //TestRunParameters.Parameter(name = "myParam", value = "myValue") + + var args = new string[] { + "--", + "TestRunParameters.Parameter(name=\"myParam\",", + "value=\"myValue\")", + "TestRunParameters.Parameter(name=\"myParam2\",", + "value=\"myValue 2\")", + }; + + var runsettings = string.Join(Environment.NewLine, new[]{ + "", + "", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + ""}); - this.executor.Initialize(args); + _executor.Initialize(args); - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual(runsettings, settingsProvider.ActiveRunSettings.SettingsXml); - } + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual(runsettings, _settingsProvider.ActiveRunSettings.SettingsXml); } -} +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs index 3afcc9f8d7..dd1d680b12 100644 --- a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs @@ -1,708 +1,710 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace vstest.console.UnitTests.Processors -{ - using System; - using System.IO; - using Microsoft.VisualStudio.TestPlatform.CommandLine; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using static Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.CollectArgumentExecutor; - - [TestClass] - public class CollectArgumentProcessorTests - { - private readonly TestableRunSettingsProvider settingsProvider; - private readonly CollectArgumentExecutor executor; +namespace vstest.console.UnitTests.Processors; - private readonly string DefaultRunSettings = string.Join(Environment.NewLine, - "", - "", - " ", - " c:\\AdapterFolderPath", - " ", - " ", - " {0}", - " ", - ""); +using System; +using System.IO; - public CollectArgumentProcessorTests() - { - this.settingsProvider = new TestableRunSettingsProvider(); - this.executor = new CollectArgumentExecutor(this.settingsProvider, new Mock().Object); - CollectArgumentExecutor.EnabledDataCollectors.Clear(); - } +using Microsoft.VisualStudio.TestPlatform.CommandLine; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests; +using Microsoft.VisualStudio.TestPlatform.Common; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestMethod] - public void GetMetadataShouldReturnCollectArgumentProcessorCapabilities() - { - var processor = new CollectArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is CollectArgumentProcessorCapabilities); - } +using Moq; - [TestMethod] - public void GetExecuterShouldReturnCollectArgumentProcessorCapabilities() - { - var processor = new CollectArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is CollectArgumentExecutor); - } +using static Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.CollectArgumentExecutor; - #region CollectArgumentProcessorCapabilities tests +[TestClass] +public class CollectArgumentProcessorTests +{ + private readonly TestableRunSettingsProvider _settingsProvider; + private readonly CollectArgumentExecutor _executor; + + private readonly string _defaultRunSettings = string.Join(Environment.NewLine, + "", + "", + " ", + " c:\\AdapterFolderPath", + " ", + " ", + " {0}", + " ", + ""); + + public CollectArgumentProcessorTests() + { + _settingsProvider = new TestableRunSettingsProvider(); + _executor = new CollectArgumentExecutor(_settingsProvider, new Mock().Object); + EnabledDataCollectors.Clear(); + } - [TestMethod] - public void CapabilitiesShouldReturnAppropriateProperties() - { - var capabilities = new CollectArgumentProcessorCapabilities(); + [TestMethod] + public void GetMetadataShouldReturnCollectArgumentProcessorCapabilities() + { + var processor = new CollectArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is CollectArgumentProcessorCapabilities); + } - Assert.AreEqual("/Collect", capabilities.CommandName); - var expected = - $"--Collect|/Collect:{Environment.NewLine} Enables data collector for the test run. More info here : https://aka.ms/vstest-collect"; - Assert.AreEqual(expected.NormalizeLineEndings().ShowWhiteSpace(), - capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); + [TestMethod] + public void GetExecuterShouldReturnCollectArgumentProcessorCapabilities() + { + var processor = new CollectArgumentProcessor(); + Assert.IsTrue(processor.Executor.Value is CollectArgumentExecutor); + } - Assert.AreEqual(HelpContentPriority.CollectArgumentProcessorHelpPriority, capabilities.HelpPriority); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.AutoUpdateRunSettings, capabilities.Priority); + #region CollectArgumentProcessorCapabilities tests - Assert.IsTrue(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); - } + [TestMethod] + public void CapabilitiesShouldReturnAppropriateProperties() + { + var capabilities = new CollectArgumentProcessorCapabilities(); - #endregion + Assert.AreEqual("/Collect", capabilities.CommandName); + var expected = + $"--Collect|/Collect:{Environment.NewLine} Enables data collector for the test run. More info here : https://aka.ms/vstest-collect"; + Assert.AreEqual(expected.NormalizeLineEndings().ShowWhiteSpace(), + capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); - #region CollectArgumentExecutor tests + Assert.AreEqual(HelpContentPriority.CollectArgumentProcessorHelpPriority, capabilities.HelpPriority); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.AutoUpdateRunSettings, capabilities.Priority); - [TestMethod] - public void InitializeShouldThrowIfArguemntIsNull() - { - Assert.ThrowsException(() => { this.executor.Initialize(null); }); - } + Assert.IsTrue(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } - [TestMethod] - public void InitializeShouldNotThrowIfArgumentIsEmpty() - { - Assert.ThrowsException(() => { this.executor.Initialize(String.Empty); }); - } + #endregion - [TestMethod] - public void InitializeShouldNotThrowIfArgumentIsWhiteSpace() - { - Assert.ThrowsException(() => { this.executor.Initialize(" "); }); - } + #region CollectArgumentExecutor tests - [TestMethod] - public void InitializeShouldThrowExceptionWhenTestSettingsIsEnabled() - { - string runsettingsString = @" + [TestMethod] + public void InitializeShouldThrowIfArguemntIsNull() + { + Assert.ThrowsException(() => _executor.Initialize(null)); + } + + [TestMethod] + public void InitializeShouldNotThrowIfArgumentIsEmpty() + { + Assert.ThrowsException(() => _executor.Initialize(String.Empty)); + } + + [TestMethod] + public void InitializeShouldNotThrowIfArgumentIsWhiteSpace() + { + Assert.ThrowsException(() => _executor.Initialize(" ")); + } + + [TestMethod] + public void InitializeShouldThrowExceptionWhenTestSettingsIsEnabled() + { + string runsettingsString = @" C:\temp.testsettings true "; - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - - bool exceptionThrown = false; - - try - { - this.executor.Initialize("MyDataCollector"); - } - catch (SettingsException ex) - { - exceptionThrown = true; - Assert.AreEqual( - "--Collect|/Collect:\"MyDataCollector\" is not supported if test run is configured using testsettings.", - ex.Message); - } - - Assert.IsTrue(exceptionThrown, "Initialize should throw exception"); - } + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); - [TestMethod] - public void InitializeShouldCreateEntryForDataCollectorInRunSettingsIfNotAlreadyPresent() - { - var runsettingsString = string.Format(DefaultRunSettings, ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - - this.executor.Initialize("MyDataCollector"); - - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " c:\\AdapterFolderPath", - " ", - " ", - " ", - " ", - " ", - " ", - ""), this.settingsProvider.ActiveRunSettings.SettingsXml); - } + bool exceptionThrown = false; - [TestMethod] - public void InitializeShouldEnableDataCollectorIfDisabledInRunSettings() + try { - var runsettingsString = string.Format(DefaultRunSettings, - ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - - this.executor.Initialize("MyDataCollector"); - - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " c:\\AdapterFolderPath", - " ", - " ", - " ", - " ", - " ", - " ", - ""), this.settingsProvider.ActiveRunSettings.SettingsXml); + _executor.Initialize("MyDataCollector"); } - - [TestMethod] - public void InitializeShouldNotDisableOtherDataCollectorsIfEnabled() + catch (SettingsException ex) { - var runsettingsString = string.Format(DefaultRunSettings, - ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - - this.executor.Initialize("MyDataCollector"); - this.executor.Initialize("MyDataCollector2"); - - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " c:\\AdapterFolderPath", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - ""), this.settingsProvider.ActiveRunSettings.SettingsXml); + exceptionThrown = true; + Assert.AreEqual( + "--Collect|/Collect:\"MyDataCollector\" is not supported if test run is configured using testsettings.", + ex.Message); } - [TestMethod] - public void InitializeShouldNotEnableOtherDataCollectorsIfDisabled() - { - var runsettingsString = string.Format(DefaultRunSettings, - ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - - this.executor.Initialize("MyDataCollector"); - this.executor.Initialize("MyDataCollector2"); - - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " c:\\AdapterFolderPath", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - ""), this.settingsProvider.ActiveRunSettings.SettingsXml); - } + Assert.IsTrue(exceptionThrown, "Initialize should throw exception"); + } - [TestMethod] - public void InitializeShouldEnableMultipleCollectorsWhenCalledMoreThanOnce() - { - var runsettingsString = string.Format(DefaultRunSettings, string.Empty); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - this.executor.Initialize("MyDataCollector"); - this.executor.Initialize("MyDataCollector1"); - - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " c:\\AdapterFolderPath", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - ""), this.settingsProvider.ActiveRunSettings.SettingsXml); - } + [TestMethod] + public void InitializeShouldCreateEntryForDataCollectorInRunSettingsIfNotAlreadyPresent() + { + var runsettingsString = string.Format(_defaultRunSettings, ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); - [TestMethod] - public void InitializeShouldAddOutProcAndInprocCollectorWhenXPlatCodeCoverageIsEnabled() - { - var runsettingsString = string.Format(DefaultRunSettings, string.Empty); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - this.executor.Initialize("XPlat Code Coverage"); - - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " c:\\AdapterFolderPath", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - ""), this.settingsProvider.ActiveRunSettings.SettingsXml); - } + _executor.Initialize("MyDataCollector"); - [TestMethod] - public void UpdageXPlatCodeCoverageCodebaseWithFullPathFromTestAdaptersPaths_Found() - { - var runsettingsString = string.Format(DefaultRunSettings, string.Empty); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - Mock fileHelper = new Mock(); - fileHelper.Setup(f => f.Exists(It.IsAny())).Returns(true); - CollectArgumentExecutor executor = new CollectArgumentExecutor(settingsProvider, fileHelper.Object); - executor.Initialize("XPlat Code Coverage"); - executor.Execute(); - - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " c:\\AdapterFolderPath", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - $" ", - " ", - " ", - "").ShowWhiteSpace(), this.settingsProvider.ActiveRunSettings.SettingsXml.ShowWhiteSpace()); - } + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " c:\\AdapterFolderPath", + " ", + " ", + " ", + " ", + " ", + " ", + ""), _settingsProvider.ActiveRunSettings.SettingsXml); + } - [TestMethod] - public void UpdageXPlatCodeCoverageCodebaseWithFullPathFromTestAdaptersPaths_NotFound() - { - var runsettingsString = string.Format(DefaultRunSettings, string.Empty); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - Mock fileHelper = new Mock(); - fileHelper.Setup(f => f.Exists(It.IsAny())).Returns(false); - CollectArgumentExecutor executor = new CollectArgumentExecutor(settingsProvider, fileHelper.Object); - executor.Initialize("XPlat Code Coverage"); - executor.Execute(); - - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " c:\\AdapterFolderPath", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - ""), this.settingsProvider.ActiveRunSettings.SettingsXml); - } + [TestMethod] + public void InitializeShouldEnableDataCollectorIfDisabledInRunSettings() + { + var runsettingsString = string.Format(_defaultRunSettings, + ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); - [TestMethod] - public void InitializeXPlatCodeCoverageShouldNotChangeExistingDataCollectors() - { - var runsettingsString = string.Join(Environment.NewLine, - "", - "", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - ""); - runsettingsString = string.Format(runsettingsString, string.Empty); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - this.executor.Initialize("XPlat Code Coverage"); - - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - $" ", - " ", - " ", - ""), this.settingsProvider.ActiveRunSettings.SettingsXml); - } + _executor.Initialize("MyDataCollector"); - [TestMethod] - public void InitializeXPlatCodeCoverageShouldNotChangeExistingXPlatDataCollectorSetting() - { - var runsettingsString = string.Join(Environment.NewLine, - "", - "", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " "); - runsettingsString = string.Format(runsettingsString, string.Empty); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - this.executor.Initialize("XPlat Code Coverage"); - - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - $" ", - " ", - " ", - ""), this.settingsProvider.ActiveRunSettings.SettingsXml); - } + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " c:\\AdapterFolderPath", + " ", + " ", + " ", + " ", + " ", + " ", + ""), _settingsProvider.ActiveRunSettings.SettingsXml); + } - [TestMethod] - public void InitializeXPlatCodeCoverageShouldNotChangeExistingXPlatInProcDataCollectorSetting() - { - var runsettingsString = string.Join(Environment.NewLine, - "", - "", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - ""); - runsettingsString = string.Format(runsettingsString, string.Empty); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - this.executor.Initialize("XPlat Code Coverage"); - - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - ""), this.settingsProvider.ActiveRunSettings.SettingsXml); - } + [TestMethod] + public void InitializeShouldNotDisableOtherDataCollectorsIfEnabled() + { + var runsettingsString = string.Format(_defaultRunSettings, + ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); - [TestMethod] - public void InitializeXPlatCodeCoverageShouldAddXPlatOutProcProcDataCollectorSetting() - { - var runsettingsString = string.Join(Environment.NewLine, - "", - "", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - $" ", - " ", - " ", - ""); - runsettingsString = string.Format(runsettingsString, string.Empty); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - this.executor.Initialize("XPlat Code Coverage"); - - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " ", - " ", - " ", - " ", - $" ", - " ", - " ", - " ", - " ", - $" ", - " ", - " ", - ""), this.settingsProvider.ActiveRunSettings.SettingsXml); - } + _executor.Initialize("MyDataCollector"); + _executor.Initialize("MyDataCollector2"); - [TestMethod] - public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPropertiesIfNotPresent() - { - var runsettingsString = $"\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"; - runsettingsString = string.Format(runsettingsString, string.Empty); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - Mock fileHelper = new Mock(); - fileHelper.Setup(f => f.Exists(It.IsAny())).Returns(true); - CollectArgumentExecutor executor = new CollectArgumentExecutor(settingsProvider, fileHelper.Object); - executor.Initialize("XPlat Code Coverage"); - - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " ", - " ", - " ", - " ", - $" ", - " ", - " ", - " ", - " ", - $" ", - " ", - " ", - ""), this.settingsProvider.ActiveRunSettings.SettingsXml); - } + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " c:\\AdapterFolderPath", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + ""), _settingsProvider.ActiveRunSettings.SettingsXml); + } - [TestMethod] - public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPropertiesIfNotPresent_NoTestAdaptersPaths() - { - var runsettingsString = $"\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"; - runsettingsString = string.Format(runsettingsString, string.Empty); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - Mock fileHelper = new Mock(); - // Suppose file exists to be sure that we won't find adapter path on runsettings config - fileHelper.Setup(f => f.Exists(It.IsAny())).Returns(true); - CollectArgumentExecutor executor = new CollectArgumentExecutor(settingsProvider, fileHelper.Object); - executor.Initialize("XPlat Code Coverage"); - - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - $" ", - " ", - " ", - " ", - " ", - $" ", - " ", - " ", - ""), this.settingsProvider.ActiveRunSettings.SettingsXml); - } + [TestMethod] + public void InitializeShouldNotEnableOtherDataCollectorsIfDisabled() + { + var runsettingsString = string.Format(_defaultRunSettings, + ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); - [TestMethod] - public void InitializeShouldThrowExceptionWhenInvalidCollectorNameProvided() - { - var runsettingsString = string.Format(DefaultRunSettings, ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); + _executor.Initialize("MyDataCollector"); + _executor.Initialize("MyDataCollector2"); - Assert.ThrowsException(() => this.executor.Initialize("MyDataCollector=SomeSetting")); - } + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " c:\\AdapterFolderPath", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + ""), _settingsProvider.ActiveRunSettings.SettingsXml); + } - [TestMethod] - public void InitializeShouldThrowExceptionWhenInvalidConfigurationsProvided() - { - var runsettingsString = string.Format(DefaultRunSettings, ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); + [TestMethod] + public void InitializeShouldEnableMultipleCollectorsWhenCalledMoreThanOnce() + { + var runsettingsString = string.Format(_defaultRunSettings, string.Empty); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + _executor.Initialize("MyDataCollector"); + _executor.Initialize("MyDataCollector1"); + + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " c:\\AdapterFolderPath", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + ""), _settingsProvider.ActiveRunSettings.SettingsXml); + } - Assert.ThrowsException(() => this.executor.Initialize("MyDataCollector;SomeSetting")); - } + [TestMethod] + public void InitializeShouldAddOutProcAndInprocCollectorWhenXPlatCodeCoverageIsEnabled() + { + var runsettingsString = string.Format(_defaultRunSettings, string.Empty); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + _executor.Initialize("XPlat Code Coverage"); - [TestMethod] - public void InitializeShouldCreateConfigurationsForNewDataCollectorInRunSettings() - { - var runsettingsString = string.Format(DefaultRunSettings, ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - - this.executor.Initialize("MyDataCollector;SomeSetting=SomeValue;AnotherSetting=AnotherValue"); - - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " c:\\AdapterFolderPath", - " ", - " ", - " ", - " ", - " ", - " SomeValue", - " AnotherValue", - " ", - " ", - " ", - " ", - ""), this.settingsProvider.ActiveRunSettings.SettingsXml); - } + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " c:\\AdapterFolderPath", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + ""), _settingsProvider.ActiveRunSettings.SettingsXml); + } - [TestMethod] - public void InitializeShouldCreateConfigurationsForExistingDataCollectorInRunSettings() - { - var runsettingsString = string.Format(DefaultRunSettings, - "" + - " " + - " SomeValue" + - " " + - ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - - this.executor.Initialize("MyDataCollector;AnotherSetting=AnotherValue"); - - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " c:\\AdapterFolderPath", - " ", - " ", - " ", - " ", - " ", - " SomeValue", - " AnotherValue", - " ", - " ", - " ", - " ", - ""), this.settingsProvider.ActiveRunSettings.SettingsXml); - } + [TestMethod] + public void UpdageXPlatCodeCoverageCodebaseWithFullPathFromTestAdaptersPaths_Found() + { + var runsettingsString = string.Format(_defaultRunSettings, string.Empty); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + Mock fileHelper = new(); + fileHelper.Setup(f => f.Exists(It.IsAny())).Returns(true); + CollectArgumentExecutor executor = new(_settingsProvider, fileHelper.Object); + executor.Initialize("XPlat Code Coverage"); + executor.Execute(); + + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " c:\\AdapterFolderPath", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + $" ", + " ", + " ", + "").ShowWhiteSpace(), _settingsProvider.ActiveRunSettings.SettingsXml.ShowWhiteSpace()); + } - [TestMethod] - public void InitializeShouldUpdateConfigurationsForExistingDataCollectorInRunSettings() - { - var runsettingsString = string.Format(DefaultRunSettings, - "" + - " " + - " SomeValue" + - " " + - ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - - this.executor.Initialize("MyDataCollector;SomeSetting=AnotherValue"); - - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " c:\\AdapterFolderPath", - " ", - " ", - " ", - " ", - " ", - " AnotherValue", - " ", - " ", - " ", - " ", - ""), this.settingsProvider.ActiveRunSettings.SettingsXml); - } - #endregion + [TestMethod] + public void UpdageXPlatCodeCoverageCodebaseWithFullPathFromTestAdaptersPaths_NotFound() + { + var runsettingsString = string.Format(_defaultRunSettings, string.Empty); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + Mock fileHelper = new(); + fileHelper.Setup(f => f.Exists(It.IsAny())).Returns(false); + CollectArgumentExecutor executor = new(_settingsProvider, fileHelper.Object); + executor.Initialize("XPlat Code Coverage"); + executor.Execute(); + + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " c:\\AdapterFolderPath", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + ""), _settingsProvider.ActiveRunSettings.SettingsXml); + } + + [TestMethod] + public void InitializeXPlatCodeCoverageShouldNotChangeExistingDataCollectors() + { + var runsettingsString = string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + ""); + runsettingsString = string.Format(runsettingsString, string.Empty); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + _executor.Initialize("XPlat Code Coverage"); + + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + $" ", + " ", + " ", + ""), _settingsProvider.ActiveRunSettings.SettingsXml); + } + + [TestMethod] + public void InitializeXPlatCodeCoverageShouldNotChangeExistingXPlatDataCollectorSetting() + { + var runsettingsString = string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " "); + runsettingsString = string.Format(runsettingsString, string.Empty); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + _executor.Initialize("XPlat Code Coverage"); + + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + $" ", + " ", + " ", + ""), _settingsProvider.ActiveRunSettings.SettingsXml); + } + + [TestMethod] + public void InitializeXPlatCodeCoverageShouldNotChangeExistingXPlatInProcDataCollectorSetting() + { + var runsettingsString = string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + ""); + runsettingsString = string.Format(runsettingsString, string.Empty); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + _executor.Initialize("XPlat Code Coverage"); + + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + ""), _settingsProvider.ActiveRunSettings.SettingsXml); + } + + [TestMethod] + public void InitializeXPlatCodeCoverageShouldAddXPlatOutProcProcDataCollectorSetting() + { + var runsettingsString = string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + $" ", + " ", + " ", + ""); + runsettingsString = string.Format(runsettingsString, string.Empty); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + _executor.Initialize("XPlat Code Coverage"); + + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " ", + $" ", + " ", + " ", + " ", + " ", + $" ", + " ", + " ", + ""), _settingsProvider.ActiveRunSettings.SettingsXml); + } + + [TestMethod] + public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPropertiesIfNotPresent() + { + var runsettingsString = $"\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"; + runsettingsString = string.Format(runsettingsString, string.Empty); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + Mock fileHelper = new(); + fileHelper.Setup(f => f.Exists(It.IsAny())).Returns(true); + CollectArgumentExecutor executor = new(_settingsProvider, fileHelper.Object); + executor.Initialize("XPlat Code Coverage"); + + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " ", + $" ", + " ", + " ", + " ", + " ", + $" ", + " ", + " ", + ""), _settingsProvider.ActiveRunSettings.SettingsXml); + } + + [TestMethod] + public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPropertiesIfNotPresent_NoTestAdaptersPaths() + { + var runsettingsString = $"\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"; + runsettingsString = string.Format(runsettingsString, string.Empty); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + Mock fileHelper = new(); + // Suppose file exists to be sure that we won't find adapter path on runsettings config + fileHelper.Setup(f => f.Exists(It.IsAny())).Returns(true); + CollectArgumentExecutor executor = new(_settingsProvider, fileHelper.Object); + executor.Initialize("XPlat Code Coverage"); + + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + $" ", + " ", + " ", + " ", + " ", + $" ", + " ", + " ", + ""), _settingsProvider.ActiveRunSettings.SettingsXml); + } + + [TestMethod] + public void InitializeShouldThrowExceptionWhenInvalidCollectorNameProvided() + { + var runsettingsString = string.Format(_defaultRunSettings, ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + + Assert.ThrowsException(() => _executor.Initialize("MyDataCollector=SomeSetting")); + } + + [TestMethod] + public void InitializeShouldThrowExceptionWhenInvalidConfigurationsProvided() + { + var runsettingsString = string.Format(_defaultRunSettings, ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + + Assert.ThrowsException(() => _executor.Initialize("MyDataCollector;SomeSetting")); + } + + [TestMethod] + public void InitializeShouldCreateConfigurationsForNewDataCollectorInRunSettings() + { + var runsettingsString = string.Format(_defaultRunSettings, ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + + _executor.Initialize("MyDataCollector;SomeSetting=SomeValue;AnotherSetting=AnotherValue"); + + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " c:\\AdapterFolderPath", + " ", + " ", + " ", + " ", + " ", + " SomeValue", + " AnotherValue", + " ", + " ", + " ", + " ", + ""), _settingsProvider.ActiveRunSettings.SettingsXml); + } + + [TestMethod] + public void InitializeShouldCreateConfigurationsForExistingDataCollectorInRunSettings() + { + var runsettingsString = string.Format(_defaultRunSettings, + "" + + " " + + " SomeValue" + + " " + + ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + + _executor.Initialize("MyDataCollector;AnotherSetting=AnotherValue"); + + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " c:\\AdapterFolderPath", + " ", + " ", + " ", + " ", + " ", + " SomeValue", + " AnotherValue", + " ", + " ", + " ", + " ", + ""), _settingsProvider.ActiveRunSettings.SettingsXml); + } + + [TestMethod] + public void InitializeShouldUpdateConfigurationsForExistingDataCollectorInRunSettings() + { + var runsettingsString = string.Format(_defaultRunSettings, + "" + + " " + + " SomeValue" + + " " + + ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + + _executor.Initialize("MyDataCollector;SomeSetting=AnotherValue"); + + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " c:\\AdapterFolderPath", + " ", + " ", + " ", + " ", + " ", + " AnotherValue", + " ", + " ", + " ", + " ", + ""), _settingsProvider.ActiveRunSettings.SettingsXml); } -} + #endregion +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/DisableAutoFakesArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/DisableAutoFakesArgumentProcessorTests.cs index 584f8fd50b..cf3fdd981e 100644 --- a/test/vstest.console.UnitTests/Processors/DisableAutoFakesArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/DisableAutoFakesArgumentProcessorTests.cs @@ -1,53 +1,53 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; + +using TestTools.UnitTesting; + +[TestClass] +public class DisableAutoFakesArgumentProcessorTests { - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestTools.UnitTesting; + private readonly DisableAutoFakesArgumentProcessor _disableAutoFakesArgumentProcessor; + + public DisableAutoFakesArgumentProcessorTests() + { + _disableAutoFakesArgumentProcessor = new DisableAutoFakesArgumentProcessor(); + } + + [TestMethod] + public void DisableAutoFakesArgumentProcessorMetadataShouldProvideAppropriateCapabilities() + { + Assert.IsFalse(_disableAutoFakesArgumentProcessor.Metadata.Value.AllowMultiple); + Assert.IsFalse(_disableAutoFakesArgumentProcessor.Metadata.Value.AlwaysExecute); + Assert.IsFalse(_disableAutoFakesArgumentProcessor.Metadata.Value.IsAction); + Assert.IsFalse(_disableAutoFakesArgumentProcessor.Metadata.Value.IsSpecialCommand); + Assert.AreEqual(DisableAutoFakesArgumentProcessor.CommandName, _disableAutoFakesArgumentProcessor.Metadata.Value.CommandName); + Assert.IsNull(_disableAutoFakesArgumentProcessor.Metadata.Value.ShortCommandName); + Assert.AreEqual(ArgumentProcessorPriority.Normal, _disableAutoFakesArgumentProcessor.Metadata.Value.Priority); + Assert.AreEqual(HelpContentPriority.DisableAutoFakesArgumentProcessorHelpPriority, _disableAutoFakesArgumentProcessor.Metadata.Value.HelpPriority); + } + + + [TestMethod] + public void DisableAutoFakesArgumentProcessorExecutorShouldThrowIfArgumentIsNullOrEmpty() + { + Assert.ThrowsException(() => _disableAutoFakesArgumentProcessor.Executor.Value.Initialize(string.Empty)); + Assert.ThrowsException(() => _disableAutoFakesArgumentProcessor.Executor.Value.Initialize(" ")); + } + + [TestMethod] + public void DisableAutoFakesArgumentProcessorExecutorShouldThrowIfArgumentIsNotBooleanString() + { + Assert.ThrowsException(() => _disableAutoFakesArgumentProcessor.Executor.Value.Initialize("DisableAutoFakes")); + } - [TestClass] - public class DisableAutoFakesArgumentProcessorTests + [TestMethod] + public void DisableAutoFakesArgumentProcessorExecutorShouldSetCommandLineDisableAutoFakeValueAsPerArgumentProvided() { - private readonly DisableAutoFakesArgumentProcessor disableAutoFakesArgumentProcessor; - - public DisableAutoFakesArgumentProcessorTests() - { - this.disableAutoFakesArgumentProcessor = new DisableAutoFakesArgumentProcessor(); - } - - [TestMethod] - public void DisableAutoFakesArgumentProcessorMetadataShouldProvideAppropriateCapabilities() - { - Assert.IsFalse(this.disableAutoFakesArgumentProcessor.Metadata.Value.AllowMultiple); - Assert.IsFalse(this.disableAutoFakesArgumentProcessor.Metadata.Value.AlwaysExecute); - Assert.IsFalse(this.disableAutoFakesArgumentProcessor.Metadata.Value.IsAction); - Assert.IsFalse(this.disableAutoFakesArgumentProcessor.Metadata.Value.IsSpecialCommand); - Assert.AreEqual(DisableAutoFakesArgumentProcessor.CommandName, this.disableAutoFakesArgumentProcessor.Metadata.Value.CommandName); - Assert.IsNull(this.disableAutoFakesArgumentProcessor.Metadata.Value.ShortCommandName); - Assert.AreEqual(ArgumentProcessorPriority.Normal, this.disableAutoFakesArgumentProcessor.Metadata.Value.Priority); - Assert.AreEqual(HelpContentPriority.DisableAutoFakesArgumentProcessorHelpPriority, this.disableAutoFakesArgumentProcessor.Metadata.Value.HelpPriority); - } - - - [TestMethod] - public void DisableAutoFakesArgumentProcessorExecutorShouldThrowIfArgumentIsNullOrEmpty() - { - Assert.ThrowsException(() => this.disableAutoFakesArgumentProcessor.Executor.Value.Initialize(string.Empty)); - Assert.ThrowsException(() => this.disableAutoFakesArgumentProcessor.Executor.Value.Initialize(" ")); - } - - [TestMethod] - public void DisableAutoFakesArgumentProcessorExecutorShouldThrowIfArgumentIsNotBooleanString() - { - Assert.ThrowsException(() => this.disableAutoFakesArgumentProcessor.Executor.Value.Initialize("DisableAutoFakes")); - } - - [TestMethod] - public void DisableAutoFakesArgumentProcessorExecutorShouldSetCommandLineDisableAutoFakeValueAsPerArgumentProvided() - { - this.disableAutoFakesArgumentProcessor.Executor.Value.Initialize("true"); - Assert.IsTrue(CommandLineOptions.Instance.DisableAutoFakes); - } + _disableAutoFakesArgumentProcessor.Executor.Value.Initialize("true"); + Assert.IsTrue(CommandLineOptions.Instance.DisableAutoFakes); } } \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/EnableBlameArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/EnableBlameArgumentProcessorTests.cs index 24566e7ab1..41b6eb5320 100644 --- a/test/vstest.console.UnitTests/Processors/EnableBlameArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/EnableBlameArgumentProcessorTests.cs @@ -1,147 +1,150 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace vstest.console.UnitTests.Processors -{ - using System; - using System.Collections.Generic; - using System.Globalization; - using Microsoft.VisualStudio.TestPlatform.CommandLine; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; - - [TestClass] - public class EnableBlameArgumentProcessorTests - { - private Mock mockEnvronment; - private Mock mockOutput; - private TestableRunSettingsProvider settingsProvider; - private EnableBlameArgumentExecutor executor; - private string DefaultRunSettings = string.Join(Environment.NewLine, - "", - "", - " ", - " ", - " ", - " C:\\dir\\TestResults", - " "); +namespace vstest.console.UnitTests.Processors; - public EnableBlameArgumentProcessorTests() - { - this.settingsProvider = new TestableRunSettingsProvider(); - this.mockEnvronment = new Mock(); - this.mockOutput = new Mock(); +using System; +using System.Collections.Generic; +using System.Globalization; - this.executor = new TestableEnableBlameArgumentExecutor(this.settingsProvider, this.mockEnvronment.Object, this.mockOutput.Object); - CollectArgumentExecutor.EnabledDataCollectors.Clear(); - } +using Microsoft.VisualStudio.TestPlatform.CommandLine; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using Microsoft.VisualStudio.TestPlatform.Common; +using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestMethod] - public void GetMetadataShouldReturnEnableBlameArgumentProcessorCapabilities() - { - var processor = new EnableBlameArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is EnableBlameArgumentProcessorCapabilities); - } +using Moq; - [TestMethod] - public void GetExecuterShouldReturnEnableBlameArgumentProcessorCapabilities() - { - var processor = new EnableBlameArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is EnableBlameArgumentExecutor); - } +using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; - [TestMethod] - public void CapabilitiesShouldReturnAppropriateProperties() - { - var capabilities = new EnableBlameArgumentProcessorCapabilities(); +[TestClass] +public class EnableBlameArgumentProcessorTests +{ + private readonly Mock _mockEnvronment; + private readonly Mock _mockOutput; + private readonly TestableRunSettingsProvider _settingsProvider; + private readonly EnableBlameArgumentExecutor _executor; + private readonly string _defaultRunSettings = string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " "); + + public EnableBlameArgumentProcessorTests() + { + _settingsProvider = new TestableRunSettingsProvider(); + _mockEnvronment = new Mock(); + _mockOutput = new Mock(); - Assert.AreEqual("/Blame", capabilities.CommandName); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.Logging, capabilities.Priority); - Assert.AreEqual(HelpContentPriority.EnableDiagArgumentProcessorHelpPriority, capabilities.HelpPriority); - Assert.AreEqual(CommandLineResources.EnableBlameUsage, capabilities.HelpContentResourceName); + _executor = new TestableEnableBlameArgumentExecutor(_settingsProvider, _mockEnvronment.Object, _mockOutput.Object); + CollectArgumentExecutor.EnabledDataCollectors.Clear(); + } - Assert.IsFalse(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); - } + [TestMethod] + public void GetMetadataShouldReturnEnableBlameArgumentProcessorCapabilities() + { + var processor = new EnableBlameArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is EnableBlameArgumentProcessorCapabilities); + } - [TestMethod] - public void InitializeShouldCreateEntryForBlameInRunSettingsIfNotAlreadyPresent() - { - var runsettingsString = string.Format(DefaultRunSettings, ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(DefaultRunSettings); - this.settingsProvider.SetActiveRunSettings(runsettings); + [TestMethod] + public void GetExecuterShouldReturnEnableBlameArgumentProcessorCapabilities() + { + var processor = new EnableBlameArgumentProcessor(); + Assert.IsTrue(processor.Executor.Value is EnableBlameArgumentExecutor); + } - this.executor.Initialize(""); + [TestMethod] + public void CapabilitiesShouldReturnAppropriateProperties() + { + var capabilities = new EnableBlameArgumentProcessorCapabilities(); - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " ", - " ", - " ", - " C:\\dir\\TestResults", - " ", - " ", - " ", - " ", - " ", - " C:\\dir\\TestResults", - " ", - " ", - " ", - " ", - " ", - " ", - "" - ), this.settingsProvider.ActiveRunSettings.SettingsXml); - } + Assert.AreEqual("/Blame", capabilities.CommandName); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.Logging, capabilities.Priority); + Assert.AreEqual(HelpContentPriority.EnableDiagArgumentProcessorHelpPriority, capabilities.HelpPriority); + Assert.AreEqual(CommandLineResources.EnableBlameUsage, capabilities.HelpContentResourceName); - [TestMethod] - public void InitializeShouldOverwriteEntryForBlameInRunSettingsIfAlreadyPresent() - { - var runsettingsString = string.Format(DefaultRunSettings, ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(string.Join(Environment.NewLine, - "", - "", - " ", - " ", - " ", - " ", - " C:\\dir\\TestResults", - " ", - " ", - " ", - " ", - " ", - " ", - " C:\\dir\\TestResults", - " ", - " ", - " ", - " ", - " ", - " ", - "")); - this.settingsProvider.SetActiveRunSettings(runsettings); + Assert.IsFalse(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } + + [TestMethod] + public void InitializeShouldCreateEntryForBlameInRunSettingsIfNotAlreadyPresent() + { + _ = string.Format(_defaultRunSettings, ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(_defaultRunSettings); + _settingsProvider.SetActiveRunSettings(runsettings); - this.executor.Initialize("CollectDump;DumpType=full;CollectAlways=true"); + _executor.Initialize(""); - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual(string.Join(Environment.NewLine, + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + "" + ), _settingsProvider.ActiveRunSettings.SettingsXml); + } + + [TestMethod] + public void InitializeShouldOverwriteEntryForBlameInRunSettingsIfAlreadyPresent() + { + _ = string.Format(_defaultRunSettings, ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + "")); + _settingsProvider.SetActiveRunSettings(runsettings); + + _executor.Initialize("CollectDump;DumpType=full;CollectAlways=true"); + + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual(string.Join(Environment.NewLine, "", "", " ", @@ -163,76 +166,76 @@ public void InitializeShouldOverwriteEntryForBlameInRunSettingsIfAlreadyPresent( " ", " ", ""), - this.settingsProvider.ActiveRunSettings.SettingsXml); - } + _settingsProvider.ActiveRunSettings.SettingsXml); + } - [TestMethod] - public void InitializeShouldWarnIfPlatformNotSupportedForCollectDumpOption() - { - var runsettingsString = string.Format(DefaultRunSettings, ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(DefaultRunSettings); - this.settingsProvider.SetActiveRunSettings(runsettings); - - var unsupportedPlatforms = new List>() - { - Tuple.Create(PlatformOperatingSystem.Windows, PlatformArchitecture.ARM), - Tuple.Create(PlatformOperatingSystem.Windows, PlatformArchitecture.ARM64) - }; - - foreach (var tuple in unsupportedPlatforms) - { - this.mockEnvronment.SetupGet(s => s.OperatingSystem).Returns(tuple.Item1); - this.mockEnvronment.SetupGet(s => s.Architecture).Returns(tuple.Item2); - - this.executor.Initialize("collectdump"); - this.mockOutput.Verify(x => x.WriteLine(CommandLineResources.BlameCollectDumpNotSupportedForPlatform, OutputLevel.Warning)); - - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " ", - " ", - " ", - " C:\\dir\\TestResults", - " ", - " ", - " ", - " ", - " ", - " C:\\dir\\TestResults", - " ", - " ", - " ", - " ", - " ", - " ", - ""), - this.settingsProvider.ActiveRunSettings.SettingsXml); - } - } + [TestMethod] + public void InitializeShouldWarnIfPlatformNotSupportedForCollectDumpOption() + { + var runsettingsString = string.Format(_defaultRunSettings, ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(_defaultRunSettings); + _settingsProvider.SetActiveRunSettings(runsettings); - [TestMethod] - public void InitializeShouldWarnIfIncorrectParameterIsSpecifiedForCollectDumpOption() + var unsupportedPlatforms = new List>() { - var invalidParameter = "CollectDumpXX"; - var runsettingsString = string.Format(DefaultRunSettings, ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(DefaultRunSettings); - this.settingsProvider.SetActiveRunSettings(runsettings); + Tuple.Create(PlatformOperatingSystem.Windows, PlatformArchitecture.ARM), + Tuple.Create(PlatformOperatingSystem.Windows, PlatformArchitecture.ARM64) + }; - this.mockEnvronment.Setup(x => x.OperatingSystem) - .Returns(PlatformOperatingSystem.Windows); - this.mockEnvronment.Setup(x => x.Architecture) - .Returns(PlatformArchitecture.X64); + foreach (var tuple in unsupportedPlatforms) + { + _mockEnvronment.SetupGet(s => s.OperatingSystem).Returns(tuple.Item1); + _mockEnvronment.SetupGet(s => s.Architecture).Returns(tuple.Item2); - this.executor.Initialize(invalidParameter); - this.mockOutput.Verify(x => x.WriteLine(string.Format(CultureInfo.CurrentUICulture, CommandLineResources.BlameIncorrectOption, invalidParameter), OutputLevel.Warning)); + _executor.Initialize("collectdump"); + _mockOutput.Verify(x => x.WriteLine(CommandLineResources.BlameCollectDumpNotSupportedForPlatform, OutputLevel.Warning)); - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + ""), + _settingsProvider.ActiveRunSettings.SettingsXml); + } + } + + [TestMethod] + public void InitializeShouldWarnIfIncorrectParameterIsSpecifiedForCollectDumpOption() + { + var invalidParameter = "CollectDumpXX"; + var runsettingsString = string.Format(_defaultRunSettings, ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(_defaultRunSettings); + _settingsProvider.SetActiveRunSettings(runsettings); + + _mockEnvronment.Setup(x => x.OperatingSystem) + .Returns(PlatformOperatingSystem.Windows); + _mockEnvronment.Setup(x => x.Architecture) + .Returns(PlatformArchitecture.X64); + + _executor.Initialize(invalidParameter); + _mockOutput.Verify(x => x.WriteLine(string.Format(CultureInfo.CurrentUICulture, CommandLineResources.BlameIncorrectOption, invalidParameter), OutputLevel.Warning)); + + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual(string.Join(Environment.NewLine, "", "", " ", @@ -253,29 +256,29 @@ public void InitializeShouldWarnIfIncorrectParameterIsSpecifiedForCollectDumpOpt " ", " ", ""), - this.settingsProvider.ActiveRunSettings.SettingsXml); - } - - [TestMethod] - [ExpectedException(typeof(CommandLineException))] - public void InitializeShouldThrowIfInvalidParameterFormatIsSpecifiedForCollectDumpOption() - { - var invalidString = "CollectDump;sdf=sdg;;as;a="; - var runsettingsString = string.Format(DefaultRunSettings, ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(DefaultRunSettings); - this.settingsProvider.SetActiveRunSettings(runsettings); - - this.mockEnvronment.Setup(x => x.OperatingSystem) - .Returns(PlatformOperatingSystem.Windows); - this.mockEnvronment.Setup(x => x.Architecture) - .Returns(PlatformArchitecture.X64); - - this.executor.Initialize(invalidString); - this.mockOutput.Verify(x => x.WriteLine(string.Format(CultureInfo.CurrentUICulture, CommandLineResources.InvalidBlameArgument, invalidString), OutputLevel.Warning)); + _settingsProvider.ActiveRunSettings.SettingsXml); + } - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual(string.Join(Environment.NewLine, + [TestMethod] + [ExpectedException(typeof(CommandLineException))] + public void InitializeShouldThrowIfInvalidParameterFormatIsSpecifiedForCollectDumpOption() + { + var invalidString = "CollectDump;sdf=sdg;;as;a="; + var runsettingsString = string.Format(_defaultRunSettings, ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(_defaultRunSettings); + _settingsProvider.SetActiveRunSettings(runsettings); + + _mockEnvronment.Setup(x => x.OperatingSystem) + .Returns(PlatformOperatingSystem.Windows); + _mockEnvronment.Setup(x => x.Architecture) + .Returns(PlatformArchitecture.X64); + + _executor.Initialize(invalidString); + _mockOutput.Verify(x => x.WriteLine(string.Format(CultureInfo.CurrentUICulture, CommandLineResources.InvalidBlameArgument, invalidString), OutputLevel.Warning)); + + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual(string.Join(Environment.NewLine, "", "", " ", @@ -296,26 +299,26 @@ public void InitializeShouldThrowIfInvalidParameterFormatIsSpecifiedForCollectDu " ", " ", ""), - this.settingsProvider.ActiveRunSettings.SettingsXml); - } + _settingsProvider.ActiveRunSettings.SettingsXml); + } - [TestMethod] - public void InitializeShouldCreateEntryForBlameAlongWithCollectDumpEntryIfEnabled() - { - var runsettingsString = string.Format(DefaultRunSettings, ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(DefaultRunSettings); - this.settingsProvider.SetActiveRunSettings(runsettings); + [TestMethod] + public void InitializeShouldCreateEntryForBlameAlongWithCollectDumpEntryIfEnabled() + { + var runsettingsString = string.Format(_defaultRunSettings, ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(_defaultRunSettings); + _settingsProvider.SetActiveRunSettings(runsettings); - this.mockEnvronment.Setup(x => x.OperatingSystem) - .Returns(PlatformOperatingSystem.Windows); - this.mockEnvronment.Setup(x => x.Architecture) - .Returns(PlatformArchitecture.X64); + _mockEnvronment.Setup(x => x.OperatingSystem) + .Returns(PlatformOperatingSystem.Windows); + _mockEnvronment.Setup(x => x.Architecture) + .Returns(PlatformArchitecture.X64); - this.executor.Initialize("CollectDump"); + _executor.Initialize("CollectDump"); - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual(string.Join(Environment.NewLine, + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual(string.Join(Environment.NewLine, "", "", " ", @@ -337,26 +340,26 @@ public void InitializeShouldCreateEntryForBlameAlongWithCollectDumpEntryIfEnable " ", " ", ""), - this.settingsProvider.ActiveRunSettings.SettingsXml); - } + _settingsProvider.ActiveRunSettings.SettingsXml); + } - [TestMethod] - public void InitializeShouldCreateEntryForBlameAlongWithCollectDumpParametersIfEnabled() - { - var runsettingsString = string.Format(DefaultRunSettings, ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(DefaultRunSettings); - this.settingsProvider.SetActiveRunSettings(runsettings); + [TestMethod] + public void InitializeShouldCreateEntryForBlameAlongWithCollectDumpParametersIfEnabled() + { + var runsettingsString = string.Format(_defaultRunSettings, ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(_defaultRunSettings); + _settingsProvider.SetActiveRunSettings(runsettings); - this.mockEnvronment.Setup(x => x.OperatingSystem) - .Returns(PlatformOperatingSystem.Windows); - this.mockEnvronment.Setup(x => x.Architecture) - .Returns(PlatformArchitecture.X64); + _mockEnvronment.Setup(x => x.OperatingSystem) + .Returns(PlatformOperatingSystem.Windows); + _mockEnvronment.Setup(x => x.Architecture) + .Returns(PlatformArchitecture.X64); - this.executor.Initialize("CollectDump;DumpType=full;CollectAlways=true"); + _executor.Initialize("CollectDump;DumpType=full;CollectAlways=true"); - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual(string.Join(Environment.NewLine, + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual(string.Join(Environment.NewLine, "", "", " ", @@ -378,27 +381,27 @@ public void InitializeShouldCreateEntryForBlameAlongWithCollectDumpParametersIfE " ", " ", ""), - this.settingsProvider.ActiveRunSettings.SettingsXml); - } + _settingsProvider.ActiveRunSettings.SettingsXml); + } - [TestMethod] - public void InitializeShouldCreateEntryForBlameAlongWithCollectHangDumpEntryIfEnabled() - { - var runsettingsString = string.Format(DefaultRunSettings, ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(DefaultRunSettings); - this.settingsProvider.SetActiveRunSettings(runsettings); + [TestMethod] + public void InitializeShouldCreateEntryForBlameAlongWithCollectHangDumpEntryIfEnabled() + { + var runsettingsString = string.Format(_defaultRunSettings, ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(_defaultRunSettings); + _settingsProvider.SetActiveRunSettings(runsettings); - this.mockEnvronment.Setup(x => x.OperatingSystem) - .Returns(PlatformOperatingSystem.Windows); - this.mockEnvronment.Setup(x => x.Architecture) - .Returns(PlatformArchitecture.X64); + _mockEnvronment.Setup(x => x.OperatingSystem) + .Returns(PlatformOperatingSystem.Windows); + _mockEnvronment.Setup(x => x.Architecture) + .Returns(PlatformArchitecture.X64); - this.executor.Initialize("CollectHangDump"); + _executor.Initialize("CollectHangDump"); - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual( - string.Join(Environment.NewLine, + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual( + string.Join(Environment.NewLine, "", "", " ", @@ -420,26 +423,26 @@ public void InitializeShouldCreateEntryForBlameAlongWithCollectHangDumpEntryIfEn " ", " ", ""), - this.settingsProvider.ActiveRunSettings.SettingsXml); - } + _settingsProvider.ActiveRunSettings.SettingsXml); + } - [TestMethod] - public void InitializeShouldCreateEntryForBlameAlongWithCollectHangDumpParametersIfEnabled() - { - var runsettingsString = string.Format(DefaultRunSettings, ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(DefaultRunSettings); - this.settingsProvider.SetActiveRunSettings(runsettings); + [TestMethod] + public void InitializeShouldCreateEntryForBlameAlongWithCollectHangDumpParametersIfEnabled() + { + var runsettingsString = string.Format(_defaultRunSettings, ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(_defaultRunSettings); + _settingsProvider.SetActiveRunSettings(runsettings); - this.mockEnvronment.Setup(x => x.OperatingSystem) - .Returns(PlatformOperatingSystem.Windows); - this.mockEnvronment.Setup(x => x.Architecture) - .Returns(PlatformArchitecture.X64); + _mockEnvronment.Setup(x => x.OperatingSystem) + .Returns(PlatformOperatingSystem.Windows); + _mockEnvronment.Setup(x => x.Architecture) + .Returns(PlatformArchitecture.X64); - this.executor.Initialize("CollectHangDump;TestTimeout=10min;HangDumpType=Mini"); + _executor.Initialize("CollectHangDump;TestTimeout=10min;HangDumpType=Mini"); - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual(string.Join(Environment.NewLine, + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual(string.Join(Environment.NewLine, "", "", " ", @@ -461,16 +464,15 @@ public void InitializeShouldCreateEntryForBlameAlongWithCollectHangDumpParameter " ", " ", ""), - this.settingsProvider.ActiveRunSettings.SettingsXml); - } + _settingsProvider.ActiveRunSettings.SettingsXml); + } - internal class TestableEnableBlameArgumentExecutor : EnableBlameArgumentExecutor + internal class TestableEnableBlameArgumentExecutor : EnableBlameArgumentExecutor + { + internal TestableEnableBlameArgumentExecutor(IRunSettingsProvider runSettingsManager, IEnvironment environment, IOutput output) + : base(runSettingsManager, environment, new Mock().Object) { - internal TestableEnableBlameArgumentExecutor(IRunSettingsProvider runSettingsManager, IEnvironment environment, IOutput output) - : base(runSettingsManager, environment, new Mock().Object) - { - this.Output = output; - } + Output = output; } } -} +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/EnableCodeCoverageArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/EnableCodeCoverageArgumentProcessorTests.cs index 95737ecd53..1dfabe5ae6 100644 --- a/test/vstest.console.UnitTests/Processors/EnableCodeCoverageArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/EnableCodeCoverageArgumentProcessorTests.cs @@ -1,176 +1,177 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace vstest.console.UnitTests.Processors +namespace vstest.console.UnitTests.Processors; + +using System; + +using Microsoft.VisualStudio.TestPlatform.CommandLine; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using Microsoft.VisualStudio.TestPlatform.Common; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class EnableCodeCoverageArgumentProcessorTests { - using System; - using Microsoft.VisualStudio.TestPlatform.CommandLine; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - - [TestClass] - public class EnableCodeCoverageArgumentProcessorTests + private readonly TestableRunSettingsProvider _settingsProvider; + private readonly EnableCodeCoverageArgumentExecutor _executor; + + private readonly string _defaultRunSettings = string.Join(Environment.NewLine, + "", + "", + " ", + " {0}", + " ", + ""); + + public EnableCodeCoverageArgumentProcessorTests() + { + _settingsProvider = new TestableRunSettingsProvider(); + _executor = new EnableCodeCoverageArgumentExecutor(CommandLineOptions.Instance, _settingsProvider, + new Mock().Object); + CollectArgumentExecutor.EnabledDataCollectors.Clear(); + } + + [TestMethod] + public void GetMetadataShouldReturnEnableCodeCoverageArgumentProcessorCapabilities() + { + var processor = new EnableCodeCoverageArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is EnableCodeCoverageArgumentProcessorCapabilities); + } + + [TestMethod] + public void GetExecuterShouldReturnEnableCodeCoverageArgumentProcessorCapabilities() + { + var processor = new EnableCodeCoverageArgumentProcessor(); + Assert.IsTrue(processor.Executor.Value is EnableCodeCoverageArgumentExecutor); + } + + #region EnableCodeCoverageArgumentProcessorCapabilities tests + + [TestMethod] + public void CapabilitiesShouldReturnAppropriateProperties() + { + var capabilities = new EnableCodeCoverageArgumentProcessorCapabilities(); + + Assert.AreEqual("/EnableCodeCoverage", capabilities.CommandName); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.AutoUpdateRunSettings, capabilities.Priority); + + Assert.IsFalse(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } + + #endregion + + #region EnableCodeCoverageArgumentExecutor tests + + [TestMethod] + public void InitializeShouldSetEnableCodeCoverageOfCommandLineOption() + { + var runsettingsString = string.Format(_defaultRunSettings, ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + + CommandLineOptions.Instance.EnableCodeCoverage = false; + + _executor.Initialize(string.Empty); + + Assert.IsTrue(CommandLineOptions.Instance.EnableCodeCoverage, + "/EnableCoverage should set CommandLineOption.EnableCodeCoverage to true"); + } + + [TestMethod] + public void InitializeShouldCreateEntryForCodeCoverageInRunSettingsIfNotAlreadyPresent() { - private TestableRunSettingsProvider settingsProvider; - private EnableCodeCoverageArgumentExecutor executor; + var runsettingsString = string.Format(_defaultRunSettings, ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + + _executor.Initialize(string.Empty); + + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + var dataCollectorsFriendlyNames = + XmlRunSettingsUtilities.GetDataCollectorsFriendlyName(_settingsProvider.ActiveRunSettings + .SettingsXml); + Assert.IsTrue(dataCollectorsFriendlyNames.Contains("Code Coverage"), + "Code coverage setting in not available in runsettings"); + } - private readonly string DefaultRunSettings = string.Join(Environment.NewLine, + [TestMethod] + public void InitializeShouldEnableCodeCoverageIfDisabledInRunSettings() + { + var runsettingsString = string.Format(_defaultRunSettings, + ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + + _executor.Initialize(string.Empty); + + Assert.AreEqual(string.Join(Environment.NewLine, "", "", " ", - " {0}", + " ", + " ", + " ", " ", - ""); - - public EnableCodeCoverageArgumentProcessorTests() - { - this.settingsProvider = new TestableRunSettingsProvider(); - this.executor = new EnableCodeCoverageArgumentExecutor(CommandLineOptions.Instance, this.settingsProvider, - new Mock().Object); - CollectArgumentExecutor.EnabledDataCollectors.Clear(); - } - - [TestMethod] - public void GetMetadataShouldReturnEnableCodeCoverageArgumentProcessorCapabilities() - { - var processor = new EnableCodeCoverageArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is EnableCodeCoverageArgumentProcessorCapabilities); - } - - [TestMethod] - public void GetExecuterShouldReturnEnableCodeCoverageArgumentProcessorCapabilities() - { - var processor = new EnableCodeCoverageArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is EnableCodeCoverageArgumentExecutor); - } - - #region EnableCodeCoverageArgumentProcessorCapabilities tests - - [TestMethod] - public void CapabilitiesShouldReturnAppropriateProperties() - { - var capabilities = new EnableCodeCoverageArgumentProcessorCapabilities(); - - Assert.AreEqual("/EnableCodeCoverage", capabilities.CommandName); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.AutoUpdateRunSettings, capabilities.Priority); - - Assert.IsFalse(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); - } - - #endregion - - #region EnableCodeCoverageArgumentExecutor tests - - [TestMethod] - public void InitializeShouldSetEnableCodeCoverageOfCommandLineOption() - { - var runsettingsString = string.Format(DefaultRunSettings, ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - - CommandLineOptions.Instance.EnableCodeCoverage = false; - - this.executor.Initialize(string.Empty); - - Assert.IsTrue(CommandLineOptions.Instance.EnableCodeCoverage, - "/EnableCoverage should set CommandLineOption.EnableCodeCoverage to true"); - } - - [TestMethod] - public void InitializeShouldCreateEntryForCodeCoverageInRunSettingsIfNotAlreadyPresent() - { - var runsettingsString = string.Format(DefaultRunSettings, ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - - this.executor.Initialize(string.Empty); - - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - var dataCollectorsFriendlyNames = - XmlRunSettingsUtilities.GetDataCollectorsFriendlyName(this.settingsProvider.ActiveRunSettings - .SettingsXml); - Assert.IsTrue(dataCollectorsFriendlyNames.Contains("Code Coverage"), - "Code coverage setting in not available in runsettings"); - } - - [TestMethod] - public void InitializeShouldEnableCodeCoverageIfDisabledInRunSettings() - { - var runsettingsString = string.Format(DefaultRunSettings, - ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - - this.executor.Initialize(string.Empty); - - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " ", - " ", - " ", - " ", - ""), this.settingsProvider.ActiveRunSettings.SettingsXml); - } - - [TestMethod] - public void InitializeShouldNotDisableOtherDataCollectors() - { - CollectArgumentExecutor.EnabledDataCollectors.Add("mydatacollector1"); - var runsettingsString = string.Format(DefaultRunSettings, - ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - - this.executor.Initialize(string.Empty); - - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " ", - " ", - " ", - " ", - " ", - ""), this.settingsProvider.ActiveRunSettings.SettingsXml); - } - - [TestMethod] - public void InitializeShouldNotEnableOtherDataCollectors() - { - var runsettingsString = string.Format(DefaultRunSettings, - ""); - var runsettings = new RunSettings(); - runsettings.LoadSettingsXml(runsettingsString); - this.settingsProvider.SetActiveRunSettings(runsettings); - - this.executor.Initialize(string.Empty); - - Assert.AreEqual(string.Join(Environment.NewLine, - "", - "", - " ", - " ", - " ", - " ", - " ", - " ", - ""), this.settingsProvider.ActiveRunSettings.SettingsXml); - } - - #endregion + ""), _settingsProvider.ActiveRunSettings.SettingsXml); } + + [TestMethod] + public void InitializeShouldNotDisableOtherDataCollectors() + { + CollectArgumentExecutor.EnabledDataCollectors.Add("mydatacollector1"); + var runsettingsString = string.Format(_defaultRunSettings, + ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + + _executor.Initialize(string.Empty); + + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " ", + " ", + ""), _settingsProvider.ActiveRunSettings.SettingsXml); + } + + [TestMethod] + public void InitializeShouldNotEnableOtherDataCollectors() + { + var runsettingsString = string.Format(_defaultRunSettings, + ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + _settingsProvider.SetActiveRunSettings(runsettings); + + _executor.Initialize(string.Empty); + + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " ", + " ", + ""), _settingsProvider.ActiveRunSettings.SettingsXml); + } + + #endregion } \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/EnableDiagArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/EnableDiagArgumentProcessorTests.cs index d944b752fc..72f15b52f7 100644 --- a/test/vstest.console.UnitTests/Processors/EnableDiagArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/EnableDiagArgumentProcessorTests.cs @@ -1,199 +1,198 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors -{ - using System; - using System.Diagnostics; - using System.Globalization; - using System.IO; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Diagnostics; +using System.Globalization; +using System.IO; - using Moq; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using TestTools.UnitTesting; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; +using Moq; - [TestClass] - public class EnableDiagArgumentProcessorTests - { - private string dummyFilePath = Path.Combine(Path.DirectorySeparatorChar.ToString(), $"{System.Guid.NewGuid()}", $"{System.Guid.NewGuid()}.txt"); +using CommandLineResources = Resources.Resources; - private readonly EnableDiagArgumentProcessor diagProcessor; +[TestClass] +public class EnableDiagArgumentProcessorTests +{ + private readonly string _dummyFilePath = Path.Combine(Path.DirectorySeparatorChar.ToString(), $"{Guid.NewGuid()}", $"{Guid.NewGuid()}.txt"); - private readonly Mock mockFileHelper; + private readonly EnableDiagArgumentProcessor _diagProcessor; - private TraceLevel traceLevel; - private string traceFileName; + private readonly Mock _mockFileHelper; - public EnableDiagArgumentProcessorTests() - { - this.mockFileHelper = new Mock(); - this.diagProcessor = new TestableEnableDiagArgumentProcessor(this.mockFileHelper.Object); + private readonly TraceLevel _traceLevel; + private readonly string _traceFileName; - // Saving the EqtTrace state + public EnableDiagArgumentProcessorTests() + { + _mockFileHelper = new Mock(); + _diagProcessor = new TestableEnableDiagArgumentProcessor(_mockFileHelper.Object); + + // Saving the EqtTrace state #if NETFRAMEWORK - traceLevel = EqtTrace.TraceLevel; - EqtTrace.TraceLevel = TraceLevel.Off; + _traceLevel = EqtTrace.TraceLevel; + EqtTrace.TraceLevel = TraceLevel.Off; #else - traceLevel = (TraceLevel)EqtTrace.TraceLevel; - EqtTrace.TraceLevel = (PlatformTraceLevel)TraceLevel.Off; + _traceLevel = (TraceLevel)EqtTrace.TraceLevel; + EqtTrace.TraceLevel = (PlatformTraceLevel)TraceLevel.Off; #endif - traceFileName = EqtTrace.LogFile; - } + _traceFileName = EqtTrace.LogFile; + } - [TestCleanup] - public void Cleanup() - { - // Restoring to initial state for EqtTrace - EqtTrace.InitializeTrace(traceFileName, PlatformTraceLevel.Verbose); + [TestCleanup] + public void Cleanup() + { + // Restoring to initial state for EqtTrace + EqtTrace.InitializeTrace(_traceFileName, PlatformTraceLevel.Verbose); #if NETFRAMEWORK - EqtTrace.TraceLevel = traceLevel; + EqtTrace.TraceLevel = _traceLevel; #else - EqtTrace.TraceLevel = (PlatformTraceLevel)traceLevel; + EqtTrace.TraceLevel = (PlatformTraceLevel)_traceLevel; #endif - } + } - [TestMethod] - public void EnableDiagArgumentProcessorMetadataShouldProvideAppropriateCapabilities() - { - Assert.IsFalse(this.diagProcessor.Metadata.Value.AllowMultiple); - Assert.IsFalse(this.diagProcessor.Metadata.Value.AlwaysExecute); - Assert.IsFalse(this.diagProcessor.Metadata.Value.IsAction); - Assert.IsFalse(this.diagProcessor.Metadata.Value.IsSpecialCommand); - Assert.AreEqual(EnableDiagArgumentProcessor.CommandName, this.diagProcessor.Metadata.Value.CommandName); - Assert.IsNull(this.diagProcessor.Metadata.Value.ShortCommandName); - Assert.AreEqual(ArgumentProcessorPriority.Diag, this.diagProcessor.Metadata.Value.Priority); - Assert.AreEqual(HelpContentPriority.EnableDiagArgumentProcessorHelpPriority, this.diagProcessor.Metadata.Value.HelpPriority); - Assert.AreEqual(CommandLineResources.EnableDiagUsage, this.diagProcessor.Metadata.Value.HelpContentResourceName); - } + [TestMethod] + public void EnableDiagArgumentProcessorMetadataShouldProvideAppropriateCapabilities() + { + Assert.IsFalse(_diagProcessor.Metadata.Value.AllowMultiple); + Assert.IsFalse(_diagProcessor.Metadata.Value.AlwaysExecute); + Assert.IsFalse(_diagProcessor.Metadata.Value.IsAction); + Assert.IsFalse(_diagProcessor.Metadata.Value.IsSpecialCommand); + Assert.AreEqual(EnableDiagArgumentProcessor.CommandName, _diagProcessor.Metadata.Value.CommandName); + Assert.IsNull(_diagProcessor.Metadata.Value.ShortCommandName); + Assert.AreEqual(ArgumentProcessorPriority.Diag, _diagProcessor.Metadata.Value.Priority); + Assert.AreEqual(HelpContentPriority.EnableDiagArgumentProcessorHelpPriority, _diagProcessor.Metadata.Value.HelpPriority); + Assert.AreEqual(CommandLineResources.EnableDiagUsage, _diagProcessor.Metadata.Value.HelpContentResourceName); + } - [TestMethod] - [DataRow(null)] - [DataRow(" ")] - [DataRow("")] - public void EnableDiagArgumentProcessorExecutorThrowsIfDiagArgumentIsNullOrEmpty(string argument) - { - string exceptionMessage = string.Format(CultureInfo.CurrentUICulture, CommandLineResources.InvalidDiagArgument, argument); - EnableDiagArgumentProcessorExecutorShouldThrowIfInvalidArgument(argument, exceptionMessage); - } + [TestMethod] + [DataRow(null)] + [DataRow(" ")] + [DataRow("")] + public void EnableDiagArgumentProcessorExecutorThrowsIfDiagArgumentIsNullOrEmpty(string argument) + { + string exceptionMessage = string.Format(CultureInfo.CurrentUICulture, CommandLineResources.InvalidDiagArgument, argument); + EnableDiagArgumentProcessorExecutorShouldThrowIfInvalidArgument(argument, exceptionMessage); + } - [TestMethod] - public void EnableDiagArgumentProcessorExecutorDoesNotThrowsIfFileDotOpenThrow() - { - this.mockFileHelper.Setup(fh => fh.DirectoryExists(Path.GetDirectoryName(this.dummyFilePath))).Returns(true); + [TestMethod] + public void EnableDiagArgumentProcessorExecutorDoesNotThrowsIfFileDotOpenThrow() + { + _mockFileHelper.Setup(fh => fh.DirectoryExists(Path.GetDirectoryName(_dummyFilePath))).Returns(true); - this.diagProcessor.Executor.Value.Initialize(this.dummyFilePath); - } + _diagProcessor.Executor.Value.Initialize(_dummyFilePath); + } - [TestMethod] - [DataRow("abc.txt;verbosity=normal=verbose")] // Multiple '=' in parameter - [DataRow("abc.txt;verbosity;key1=value1")] // No '=' in parameter - [DataRow("\"abst;dfsdc.txt\";verbosity=normal")] // Too many parameters - [DataRow("abs;dfsdc.txt;verbosity=normal")] // Too many parameters - public void EnableDiagArgumentProcessorExecutorShouldThrowIfInvalidArgument(string argument) + [TestMethod] + [DataRow("abc.txt;verbosity=normal=verbose")] // Multiple '=' in parameter + [DataRow("abc.txt;verbosity;key1=value1")] // No '=' in parameter + [DataRow("\"abst;dfsdc.txt\";verbosity=normal")] // Too many parameters + [DataRow("abs;dfsdc.txt;verbosity=normal")] // Too many parameters + public void EnableDiagArgumentProcessorExecutorShouldThrowIfInvalidArgument(string argument) + { + string exceptionMessage = string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidDiagArgument, argument); + EnableDiagArgumentProcessorExecutorShouldThrowIfInvalidArgument(argument, exceptionMessage); + } + + [TestMethod] + [DataRow("abc.txt")] + [DataRow("abc.txt;verbosity=normal")] + [DataRow("abc.txt;tracelevel=info;newkey=newvalue")] + [DataRow("\"abc.txt\";verbosity=normal;newkey=newvalue")] //escaped double quotes are allowed for file path. + [DataRow(";;abc.txt;;;;verbosity=normal;;;;")] + // Files with no extension are totally valid files. + // When we delegate to host or datacollector we change the name in GetTimestampedLogFile + // Path.ChangeExtension replaces the curent extension with our new one that is timestamp and + // the name of the target (e.g. host). When there is no extension it just adds it, so we do either: + // log.txt -> log.host.21-09-10_12-25-41_68765_5.txt + // log.my.txt -> log.my.host.21-09-10_12-25-50_55183_5.txt + // log -> log.host.21-09-10_12-25-27_94286_5 + [DataRow("log")] + [DataRow("log.log")] + public void EnableDiagArgumentProcessorExecutorShouldNotThrowIfValidArgument(string argument) + { + try { - string exceptionMessage = string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidDiagArgument, argument); - EnableDiagArgumentProcessorExecutorShouldThrowIfInvalidArgument(argument, exceptionMessage); + _diagProcessor.Executor.Value.Initialize(argument); } - - [TestMethod] - [DataRow("abc.txt")] - [DataRow("abc.txt;verbosity=normal")] - [DataRow("abc.txt;tracelevel=info;newkey=newvalue")] - [DataRow("\"abc.txt\";verbosity=normal;newkey=newvalue")] //escaped double quotes are allowed for file path. - [DataRow(";;abc.txt;;;;verbosity=normal;;;;")] - // Files with no extension are totally valid files. - // When we delegate to host or datacollector we change the name in GetTimestampedLogFile - // Path.ChangeExtension replaces the curent extension with our new one that is timestamp and - // the name of the target (e.g. host). When there is no extension it just adds it, so we do either: - // log.txt -> log.host.21-09-10_12-25-41_68765_5.txt - // log.my.txt -> log.my.host.21-09-10_12-25-50_55183_5.txt - // log -> log.host.21-09-10_12-25-27_94286_5 - [DataRow("log")] - [DataRow("log.log")] - public void EnableDiagArgumentProcessorExecutorShouldNotThrowIfValidArgument(string argument) + catch (Exception ex) { - try - { - this.diagProcessor.Executor.Value.Initialize(argument); - } - catch (Exception ex) - { - Assert.Fail("Expected no exception, but got: " + ex.Message); - } + Assert.Fail("Expected no exception, but got: " + ex.Message); } + } - [TestMethod] - [DataRow("abc.txt;tracelevel=info;newkey=newvalue")] - [DataRow("abc.txt;tracelevel=info;")] - [DataRow("abc.txt;tracelevel=INfO")] - [DataRow("abc.txt;traCELevel=info")] - [DataRow("abc.txt;traCELevel=INfO")] - public void EnableDiagArgumentProcessorExecutorShouldInitializeTraceWithCorrectTraceLevel(string argument) - { - // Setting any trace level other than info. + [TestMethod] + [DataRow("abc.txt;tracelevel=info;newkey=newvalue")] + [DataRow("abc.txt;tracelevel=info;")] + [DataRow("abc.txt;tracelevel=INfO")] + [DataRow("abc.txt;traCELevel=info")] + [DataRow("abc.txt;traCELevel=INfO")] + public void EnableDiagArgumentProcessorExecutorShouldInitializeTraceWithCorrectTraceLevel(string argument) + { + // Setting any trace level other than info. #if NETFRAMEWORK - EqtTrace.TraceLevel = TraceLevel.Verbose; + EqtTrace.TraceLevel = TraceLevel.Verbose; #else - EqtTrace.TraceLevel = PlatformTraceLevel.Verbose; + EqtTrace.TraceLevel = PlatformTraceLevel.Verbose; #endif - this.diagProcessor.Executor.Value.Initialize(argument); + _diagProcessor.Executor.Value.Initialize(argument); - Assert.AreEqual(TraceLevel.Info, (TraceLevel)EqtTrace.TraceLevel); - Assert.IsTrue(EqtTrace.LogFile.Contains("abc.txt")); - } + Assert.AreEqual(TraceLevel.Info, (TraceLevel)EqtTrace.TraceLevel); + Assert.IsTrue(EqtTrace.LogFile.Contains("abc.txt")); + } - [TestMethod] - public void EnableDiagArgumentProcessorExecutorShouldCreateDirectoryOfLogFileIfNotExists() - { - this.mockFileHelper.Setup(fh => fh.DirectoryExists(Path.GetDirectoryName(this.dummyFilePath))).Returns(false); + [TestMethod] + public void EnableDiagArgumentProcessorExecutorShouldCreateDirectoryOfLogFileIfNotExists() + { + _mockFileHelper.Setup(fh => fh.DirectoryExists(Path.GetDirectoryName(_dummyFilePath))).Returns(false); - this.diagProcessor.Executor.Value.Initialize(this.dummyFilePath); + _diagProcessor.Executor.Value.Initialize(_dummyFilePath); - this.mockFileHelper.Verify(fh => fh.CreateDirectory(Path.GetDirectoryName(this.dummyFilePath)), Times.Once); - } + _mockFileHelper.Verify(fh => fh.CreateDirectory(Path.GetDirectoryName(_dummyFilePath)), Times.Once); + } - [TestMethod] - public void EnableDiagArgumentProcessorExecutorShouldNotCreateDirectoryIfAFileIsProvided() - { - this.diagProcessor.Executor.Value.Initialize("log.txt"); + [TestMethod] + public void EnableDiagArgumentProcessorExecutorShouldNotCreateDirectoryIfAFileIsProvided() + { + _diagProcessor.Executor.Value.Initialize("log.txt"); - this.mockFileHelper.Verify(fh => fh.CreateDirectory(It.IsAny()), Times.Never); - } + _mockFileHelper.Verify(fh => fh.CreateDirectory(It.IsAny()), Times.Never); + } - [TestMethod] - public void EnableDiagArgumentProcessorExecutorShouldDisableVerboseLoggingIfEqtTraceThowException() - { - this.mockFileHelper.Setup(fh => fh.DirectoryExists(Path.GetDirectoryName(this.dummyFilePath))).Returns(true); - this.diagProcessor.Executor.Value.Initialize(this.dummyFilePath); + [TestMethod] + public void EnableDiagArgumentProcessorExecutorShouldDisableVerboseLoggingIfEqtTraceThowException() + { + _mockFileHelper.Setup(fh => fh.DirectoryExists(Path.GetDirectoryName(_dummyFilePath))).Returns(true); + _diagProcessor.Executor.Value.Initialize(_dummyFilePath); - Assert.IsFalse(EqtTrace.IsVerboseEnabled); + Assert.IsFalse(EqtTrace.IsVerboseEnabled); #if NETFRAMEWORK - EqtTrace.TraceLevel = TraceLevel.Off; + EqtTrace.TraceLevel = TraceLevel.Off; #else - EqtTrace.TraceLevel = PlatformTraceLevel.Off; + EqtTrace.TraceLevel = PlatformTraceLevel.Off; #endif - } + } - private class TestableEnableDiagArgumentProcessor : EnableDiagArgumentProcessor + private class TestableEnableDiagArgumentProcessor : EnableDiagArgumentProcessor + { + /// + public TestableEnableDiagArgumentProcessor(IFileHelper fileHelper) + : base(fileHelper) { - /// - public TestableEnableDiagArgumentProcessor(IFileHelper fileHelper) - : base(fileHelper) - { - } } + } - private void EnableDiagArgumentProcessorExecutorShouldThrowIfInvalidArgument(string argument, string exceptionMessage) - { - var e = Assert.ThrowsException(() => this.diagProcessor.Executor.Value.Initialize(argument)); - StringAssert.Contains(e.Message, exceptionMessage); - } + private void EnableDiagArgumentProcessorExecutorShouldThrowIfInvalidArgument(string argument, string exceptionMessage) + { + var e = Assert.ThrowsException(() => _diagProcessor.Executor.Value.Initialize(argument)); + StringAssert.Contains(e.Message, exceptionMessage); } } \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/EnableLoggersArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/EnableLoggersArgumentProcessorTests.cs index c7c7d367b2..73a4939e37 100644 --- a/test/vstest.console.UnitTests/Processors/EnableLoggersArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/EnableLoggersArgumentProcessorTests.cs @@ -1,92 +1,92 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors -{ - using System; - using System.Globalization; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +using System; +using System.Globalization; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using Common; +using TestTools.UnitTesting; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; +using CommandLineResources = Resources.Resources; - [TestClass] - public class EnableLoggersArgumentProcessorTests +[TestClass] +public class EnableLoggersArgumentProcessorTests +{ + [TestInitialize] + public void Initialize() { - [TestInitialize] - public void Initialize() - { - RunTestsArgumentProcessorTests.SetupMockExtensions(); - } + RunTestsArgumentProcessorTests.SetupMockExtensions(); + } - [TestMethod] - public void GetMetadataShouldReturnEnableLoggerArgumentProcessorCapabilities() - { - EnableLoggerArgumentProcessor processor = new EnableLoggerArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is EnableLoggerArgumentProcessorCapabilities); - } + [TestMethod] + public void GetMetadataShouldReturnEnableLoggerArgumentProcessorCapabilities() + { + EnableLoggerArgumentProcessor processor = new(); + Assert.IsTrue(processor.Metadata.Value is EnableLoggerArgumentProcessorCapabilities); + } - [TestMethod] - public void GetExecuterShouldReturnEnableLoggerArgumentExecutor() - { - EnableLoggerArgumentProcessor processor = new EnableLoggerArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is EnableLoggerArgumentExecutor); - } + [TestMethod] + public void GetExecuterShouldReturnEnableLoggerArgumentExecutor() + { + EnableLoggerArgumentProcessor processor = new(); + Assert.IsTrue(processor.Executor.Value is EnableLoggerArgumentExecutor); + } - [TestMethod] - public void CapabilitiesShouldAppropriateProperties() - { - EnableLoggerArgumentProcessorCapabilities capabilities = new EnableLoggerArgumentProcessorCapabilities(); - Assert.AreEqual("/Logger", capabilities.CommandName); + [TestMethod] + public void CapabilitiesShouldAppropriateProperties() + { + EnableLoggerArgumentProcessorCapabilities capabilities = new(); + Assert.AreEqual("/Logger", capabilities.CommandName); #if NETFRAMEWORK - Assert.AreEqual("--logger|/logger:" + Environment.NewLine + " Specify a logger for test results. For example, to log results into a " + Environment.NewLine + " Visual Studio Test Results File (TRX) use /logger:trx[;LogFileName=]" + Environment.NewLine + " Creates file in TestResults directory with given LogFileName." + Environment.NewLine + "" + Environment.NewLine + " Change the verbosity level in log messages for console logger as shown below" + Environment.NewLine + " Example: /logger:console;verbosity=" + Environment.NewLine + " Allowed values for verbosity: quiet, minimal, normal and detailed." + Environment.NewLine + "" + Environment.NewLine + " Change the diagnostic level prefix for console logger as shown below" + Environment.NewLine + " Example: /logger:console;prefix=" + Environment.NewLine + " More info on Console Logger here : https://aka.ms/console-logger", capabilities.HelpContentResourceName); + Assert.AreEqual("--logger|/logger:" + Environment.NewLine + " Specify a logger for test results. For example, to log results into a " + Environment.NewLine + " Visual Studio Test Results File (TRX) use /logger:trx[;LogFileName=]" + Environment.NewLine + " Creates file in TestResults directory with given LogFileName." + Environment.NewLine + "" + Environment.NewLine + " Change the verbosity level in log messages for console logger as shown below" + Environment.NewLine + " Example: /logger:console;verbosity=" + Environment.NewLine + " Allowed values for verbosity: quiet, minimal, normal and detailed." + Environment.NewLine + "" + Environment.NewLine + " Change the diagnostic level prefix for console logger as shown below" + Environment.NewLine + " Example: /logger:console;prefix=" + Environment.NewLine + " More info on Console Logger here : https://aka.ms/console-logger", capabilities.HelpContentResourceName); #else - Assert.AreEqual("--logger|/logger:" + Environment.NewLine + " Specify a logger for test results. For example, to log results into a " + Environment.NewLine + " Visual Studio Test Results File (TRX) use /logger:trx[;LogFileName=]" + Environment.NewLine + " Creates file in TestResults directory with given LogFileName." + Environment.NewLine + "" + Environment.NewLine + " Change the verbosity level in log messages for console logger as shown below" + Environment.NewLine + " Example: /logger:console;verbosity=" + Environment.NewLine + " Allowed values for verbosity: quiet, minimal, normal and detailed." + Environment.NewLine + "" + Environment.NewLine + " Change the diagnostic level prefix for console logger as shown below" + Environment.NewLine + " Example: /logger:console;prefix=" + Environment.NewLine + " More info on Console Logger here : https://aka.ms/console-logger", capabilities.HelpContentResourceName); + Assert.AreEqual("--logger|/logger:" + Environment.NewLine + " Specify a logger for test results. For example, to log results into a " + Environment.NewLine + " Visual Studio Test Results File (TRX) use /logger:trx[;LogFileName=]" + Environment.NewLine + " Creates file in TestResults directory with given LogFileName." + Environment.NewLine + "" + Environment.NewLine + " Change the verbosity level in log messages for console logger as shown below" + Environment.NewLine + " Example: /logger:console;verbosity=" + Environment.NewLine + " Allowed values for verbosity: quiet, minimal, normal and detailed." + Environment.NewLine + "" + Environment.NewLine + " Change the diagnostic level prefix for console logger as shown below" + Environment.NewLine + " Example: /logger:console;prefix=" + Environment.NewLine + " More info on Console Logger here : https://aka.ms/console-logger", capabilities.HelpContentResourceName); #endif - Assert.AreEqual(HelpContentPriority.EnableLoggerArgumentProcessorHelpPriority, capabilities.HelpPriority); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.Logging, capabilities.Priority); + Assert.AreEqual(HelpContentPriority.EnableLoggerArgumentProcessorHelpPriority, capabilities.HelpPriority); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.Logging, capabilities.Priority); - Assert.IsTrue(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); - } + Assert.IsTrue(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } - [TestMethod] - [DataRow(" ")] - [DataRow(null)] - [DataRow("TestLoggerExtension;==;;;Collection=http://localhost:8080/tfs/DefaultCollection;TeamProject=MyProject;BuildName=DailyBuild_20121130.1")] - public void ExectorInitializeShouldThrowExceptionIfInvalidArgumentIsPassed(string argument) + [TestMethod] + [DataRow(" ")] + [DataRow(null)] + [DataRow("TestLoggerExtension;==;;;Collection=http://localhost:8080/tfs/DefaultCollection;TeamProject=MyProject;BuildName=DailyBuild_20121130.1")] + public void ExectorInitializeShouldThrowExceptionIfInvalidArgumentIsPassed(string argument) + { + var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); + try { - var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); - try - { - executor.Initialize(argument); - } - catch (Exception e) - { - string exceptionMessage = string.Format(CultureInfo.CurrentUICulture, CommandLineResources.LoggerUriInvalid, argument); - Assert.IsTrue(e.GetType().Equals(typeof(CommandLineException))); - Assert.IsTrue(e.Message.Contains(exceptionMessage)); - } + executor.Initialize(argument); } - - [TestMethod] - public void ExecutorExecuteShouldReturnArgumentProcessorResultSuccess() + catch (Exception e) { - var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); - var result = executor.Execute(); - Assert.AreEqual(ArgumentProcessorResult.Success, result); + string exceptionMessage = string.Format(CultureInfo.CurrentUICulture, CommandLineResources.LoggerUriInvalid, argument); + Assert.IsTrue(e.GetType().Equals(typeof(CommandLineException))); + Assert.IsTrue(e.Message.Contains(exceptionMessage)); } + } - [TestMethod] - public void ExecutorInitializeShouldAddLoggerWithFriendlyNameInRunSettingsIfNamePresentInArg() - { - string settingsXml = - @" + [TestMethod] + public void ExecutorExecuteShouldReturnArgumentProcessorResultSuccess() + { + var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); + var result = executor.Execute(); + Assert.AreEqual(ArgumentProcessorResult.Success, result); + } + + [TestMethod] + public void ExecutorInitializeShouldAddLoggerWithFriendlyNameInRunSettingsIfNamePresentInArg() + { + string settingsXml = + @" @@ -98,15 +98,15 @@ public void ExecutorInitializeShouldAddLoggerWithFriendlyNameInRunSettingsIfName "; - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(settingsXml); - RunSettingsManager.Instance.SetActiveRunSettings(runSettings); + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(settingsXml); + RunSettingsManager.Instance.SetActiveRunSettings(runSettings); - var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); - executor.Initialize("DummyLoggerExtension"); + var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); + executor.Initialize("DummyLoggerExtension"); - string expectedSettingsXml = -@" + string expectedSettingsXml = + @" @@ -123,14 +123,14 @@ public void ExecutorInitializeShouldAddLoggerWithFriendlyNameInRunSettingsIfName "; - Assert.AreEqual(expectedSettingsXml, RunSettingsManager.Instance.ActiveRunSettings?.SettingsXml); - } + Assert.AreEqual(expectedSettingsXml, RunSettingsManager.Instance.ActiveRunSettings?.SettingsXml); + } - [TestMethod] - public void ExecutorInitializeShouldAddLoggerWithUriInRunSettingsIfUriPresentInArg() - { - string settingsXml = - @" + [TestMethod] + public void ExecutorInitializeShouldAddLoggerWithUriInRunSettingsIfUriPresentInArg() + { + string settingsXml = + @" @@ -142,15 +142,15 @@ public void ExecutorInitializeShouldAddLoggerWithUriInRunSettingsIfUriPresentInA "; - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(settingsXml); - RunSettingsManager.Instance.SetActiveRunSettings(runSettings); + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(settingsXml); + RunSettingsManager.Instance.SetActiveRunSettings(runSettings); - var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); - executor.Initialize("logger://DummyLoggerUri"); + var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); + executor.Initialize("logger://DummyLoggerUri"); - string expectedSettingsXml = -@" + string expectedSettingsXml = + @" @@ -167,14 +167,14 @@ public void ExecutorInitializeShouldAddLoggerWithUriInRunSettingsIfUriPresentInA "; - Assert.AreEqual(expectedSettingsXml, RunSettingsManager.Instance.ActiveRunSettings?.SettingsXml); - } + Assert.AreEqual(expectedSettingsXml, RunSettingsManager.Instance.ActiveRunSettings?.SettingsXml); + } - [TestMethod] - public void ExecutorInitializeShouldCorrectlyAddLoggerParametersInRunSettings() - { - string settingsXml = - @" + [TestMethod] + public void ExecutorInitializeShouldCorrectlyAddLoggerParametersInRunSettings() + { + string settingsXml = + @" @@ -186,15 +186,15 @@ public void ExecutorInitializeShouldCorrectlyAddLoggerParametersInRunSettings() "; - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(settingsXml); - RunSettingsManager.Instance.SetActiveRunSettings(runSettings); + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(settingsXml); + RunSettingsManager.Instance.SetActiveRunSettings(runSettings); - var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); - executor.Initialize("logger://DummyLoggerUri;Collection=http://localhost:8080/tfs/DefaultCollection;TeamProject=MyProject;BuildName=DailyBuild_20121130.1"); + var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); + executor.Initialize("logger://DummyLoggerUri;Collection=http://localhost:8080/tfs/DefaultCollection;TeamProject=MyProject;BuildName=DailyBuild_20121130.1"); - string expectedSettingsXml = -@" + string expectedSettingsXml = + @" @@ -217,19 +217,19 @@ public void ExecutorInitializeShouldCorrectlyAddLoggerParametersInRunSettings() "; - Assert.AreEqual(expectedSettingsXml, RunSettingsManager.Instance.ActiveRunSettings?.SettingsXml); - } + Assert.AreEqual(expectedSettingsXml, RunSettingsManager.Instance.ActiveRunSettings?.SettingsXml); + } - [TestMethod] - public void ExecutorInitializeShouldCorrectlyAddLoggerWhenRunSettingsNotPassed() - { - RunSettingsManager.Instance.SetActiveRunSettings(new RunSettings()); + [TestMethod] + public void ExecutorInitializeShouldCorrectlyAddLoggerWhenRunSettingsNotPassed() + { + RunSettingsManager.Instance.SetActiveRunSettings(new RunSettings()); - var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); - executor.Initialize("logger://DummyLoggerUri;Collection=http://localhost:8080/tfs/DefaultCollection;TeamProject=MyProject;BuildName=DailyBuild_20121130.1"); + var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); + executor.Initialize("logger://DummyLoggerUri;Collection=http://localhost:8080/tfs/DefaultCollection;TeamProject=MyProject;BuildName=DailyBuild_20121130.1"); - string expectedSettingsXml = - @" + string expectedSettingsXml = + @" @@ -241,14 +241,14 @@ public void ExecutorInitializeShouldCorrectlyAddLoggerWhenRunSettingsNotPassed() "; - Assert.IsTrue(RunSettingsManager.Instance.ActiveRunSettings.SettingsXml.Contains(expectedSettingsXml)); - } + Assert.IsTrue(RunSettingsManager.Instance.ActiveRunSettings.SettingsXml.Contains(expectedSettingsXml)); + } - [TestMethod] - public void ExecutorInitializeShouldCorrectlyAddLoggerInRunSettingsWhenOtherLoggersAlreadyPresent() - { - string settingsXml = - @" + [TestMethod] + public void ExecutorInitializeShouldCorrectlyAddLoggerInRunSettingsWhenOtherLoggersAlreadyPresent() + { + string settingsXml = + @" @@ -274,15 +274,15 @@ public void ExecutorInitializeShouldCorrectlyAddLoggerInRunSettingsWhenOtherLogg "; - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(settingsXml); - RunSettingsManager.Instance.SetActiveRunSettings(runSettings); + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(settingsXml); + RunSettingsManager.Instance.SetActiveRunSettings(runSettings); - var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); - executor.Initialize("logger://DummyLoggerUri;Collection=http://localhost:8080/tfs/DefaultCollection;TeamProject=MyProject;BuildName=DailyBuild_20121130.1"); + var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); + executor.Initialize("logger://DummyLoggerUri;Collection=http://localhost:8080/tfs/DefaultCollection;TeamProject=MyProject;BuildName=DailyBuild_20121130.1"); - string expectedSettingsXml = - @" + string expectedSettingsXml = + @" @@ -314,14 +314,14 @@ public void ExecutorInitializeShouldCorrectlyAddLoggerInRunSettingsWhenOtherLogg "; - Assert.AreEqual(expectedSettingsXml, RunSettingsManager.Instance.ActiveRunSettings?.SettingsXml); - } + Assert.AreEqual(expectedSettingsXml, RunSettingsManager.Instance.ActiveRunSettings?.SettingsXml); + } - [TestMethod] - public void ExecutorInitializeShouldPreferCommandLineLoggerOverRunSettingsLoggerIfSame() - { - string settingsXml = - @" + [TestMethod] + public void ExecutorInitializeShouldPreferCommandLineLoggerOverRunSettingsLoggerIfSame() + { + string settingsXml = + @" @@ -347,15 +347,15 @@ public void ExecutorInitializeShouldPreferCommandLineLoggerOverRunSettingsLogger "; - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(settingsXml); - RunSettingsManager.Instance.SetActiveRunSettings(runSettings); + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(settingsXml); + RunSettingsManager.Instance.SetActiveRunSettings(runSettings); - var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); - executor.Initialize("tempLogger2"); + var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); + executor.Initialize("tempLogger2"); - string expectedSettingsXml = - @" + string expectedSettingsXml = + @" @@ -380,14 +380,14 @@ public void ExecutorInitializeShouldPreferCommandLineLoggerOverRunSettingsLogger "; - Assert.AreEqual(expectedSettingsXml, RunSettingsManager.Instance.ActiveRunSettings?.SettingsXml); - } + Assert.AreEqual(expectedSettingsXml, RunSettingsManager.Instance.ActiveRunSettings?.SettingsXml); + } - [TestMethod] - public void ExecutorInitializeShouldPreferCommandLineLoggerOverRunSettingsLoggerEvenIfCaseMismatch() - { - string settingsXml = - @" + [TestMethod] + public void ExecutorInitializeShouldPreferCommandLineLoggerOverRunSettingsLoggerEvenIfCaseMismatch() + { + string settingsXml = + @" @@ -413,15 +413,15 @@ public void ExecutorInitializeShouldPreferCommandLineLoggerOverRunSettingsLogger "; - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(settingsXml); - RunSettingsManager.Instance.SetActiveRunSettings(runSettings); + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(settingsXml); + RunSettingsManager.Instance.SetActiveRunSettings(runSettings); - var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); - executor.Initialize("tempLoggER2"); + var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); + executor.Initialize("tempLoggER2"); - string expectedSettingsXml = - @" + string expectedSettingsXml = + @" @@ -446,14 +446,14 @@ public void ExecutorInitializeShouldPreferCommandLineLoggerOverRunSettingsLogger "; - Assert.AreEqual(expectedSettingsXml, RunSettingsManager.Instance.ActiveRunSettings?.SettingsXml); - } + Assert.AreEqual(expectedSettingsXml, RunSettingsManager.Instance.ActiveRunSettings?.SettingsXml); + } - [TestMethod] - public void ExecutorInitializeShouldPreferCommandLineLoggerWithParamsOverRunSettingsLoggerIfSame() - { - string settingsXml = - @" + [TestMethod] + public void ExecutorInitializeShouldPreferCommandLineLoggerWithParamsOverRunSettingsLoggerIfSame() + { + string settingsXml = + @" @@ -487,15 +487,15 @@ public void ExecutorInitializeShouldPreferCommandLineLoggerWithParamsOverRunSett "; - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(settingsXml); - RunSettingsManager.Instance.SetActiveRunSettings(runSettings); + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(settingsXml); + RunSettingsManager.Instance.SetActiveRunSettings(runSettings); - var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); - executor.Initialize("logger://DummyLoggerUri;Collection=http://localhost:8080/tfs/DefaultCollectionOverride;TeamProjectOverride=MyProject;BuildName=DailyBuild_20121130.1Override;NewAttr=value"); + var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); + executor.Initialize("logger://DummyLoggerUri;Collection=http://localhost:8080/tfs/DefaultCollectionOverride;TeamProjectOverride=MyProject;BuildName=DailyBuild_20121130.1Override;NewAttr=value"); - string expectedSettingsXml = - @" + string expectedSettingsXml = + @" @@ -528,7 +528,6 @@ public void ExecutorInitializeShouldPreferCommandLineLoggerWithParamsOverRunSett "; - Assert.AreEqual(expectedSettingsXml, RunSettingsManager.Instance.ActiveRunSettings?.SettingsXml); - } + Assert.AreEqual(expectedSettingsXml, RunSettingsManager.Instance.ActiveRunSettings?.SettingsXml); } -} +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/EnvironmentArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/EnvironmentArgumentProcessorTests.cs index 524a9cb0d4..59be9880c0 100644 --- a/test/vstest.console.UnitTests/Processors/EnvironmentArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/EnvironmentArgumentProcessorTests.cs @@ -1,205 +1,208 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +using System; +using System.Linq; +using System.Xml.Linq; + +using Microsoft.VisualStudio.TestPlatform.CommandLine; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using TestTools.UnitTesting; + +using Moq; + +using vstest.console.UnitTests.Processors; + +using CommandLineResources = Resources.Resources; + +[TestClass] +public class EnvironmentArgumentProcessorTests { - using System; - using System.Linq; - using System.Xml.Linq; - using Microsoft.VisualStudio.TestPlatform.CommandLine; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using vstest.console.UnitTests.Processors; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; - - [TestClass] - public class EnvironmentArgumentProcessorTests - { - private const string DefaultRunSettings = - ""; + private const string DefaultRunSettings = + ""; - private TestableRunSettingsProvider settingsProvider; - private Mock mockOutput; - private CommandLineOptions commandLineOptions; + private TestableRunSettingsProvider _settingsProvider; + private Mock _mockOutput; + private CommandLineOptions _commandLineOptions; - [TestInitialize] - public void Initialize() - { - this.commandLineOptions = CommandLineOptions.Instance; - this.settingsProvider = new TestableRunSettingsProvider(); - this.settingsProvider.UpdateRunSettings(DefaultRunSettings); - this.mockOutput = new Mock(); - } + [TestInitialize] + public void Initialize() + { + _commandLineOptions = CommandLineOptions.Instance; + _settingsProvider = new TestableRunSettingsProvider(); + _settingsProvider.UpdateRunSettings(DefaultRunSettings); + _mockOutput = new Mock(); + } - [TestCleanup] - public void Cleanup() - { - this.commandLineOptions.Reset(); - } + [TestCleanup] + public void Cleanup() + { + _commandLineOptions.Reset(); + } - [TestMethod] - public void CapabilitiesShouldReturnAppropriateValues() - { - // Arrange & Act - var capabilities = new EnvironmentArgumentProcessor.ArgumentProcessorCapabilities(); - - // Assert - Assert.AreEqual("/Environment", capabilities.CommandName); - Assert.AreEqual("/e", capabilities.ShortCommandName); - Assert.IsTrue(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.Normal, capabilities.Priority); - Assert.AreEqual(HelpContentPriority.EnvironmentArgumentProcessorHelpPriority, capabilities.HelpPriority); - } + [TestMethod] + public void CapabilitiesShouldReturnAppropriateValues() + { + // Arrange & Act + var capabilities = new EnvironmentArgumentProcessor.ArgumentProcessorCapabilities(); + + // Assert + Assert.AreEqual("/Environment", capabilities.CommandName); + Assert.AreEqual("/e", capabilities.ShortCommandName); + Assert.IsTrue(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.Normal, capabilities.Priority); + Assert.AreEqual(HelpContentPriority.EnvironmentArgumentProcessorHelpPriority, capabilities.HelpPriority); + } - [TestMethod] - public void AppendsEnvironmentVariableToRunSettings() - { - // Arrange - var executor = GetExecutor(); + [TestMethod] + public void AppendsEnvironmentVariableToRunSettings() + { + // Arrange + var executor = GetExecutor(); - // Act - executor.Initialize("VARIABLE=VALUE"); + // Act + executor.Initialize("VARIABLE=VALUE"); - // Assert - var result = ParseSettingsXML(this.settingsProvider); - var environmentVariables = result.variables; - var inIsolation = result.inIsolation; - var variables = environmentVariables?.Elements()?.ToArray(); + // Assert + var result = ParseSettingsXml(_settingsProvider); + var environmentVariables = result.Variables; + var inIsolation = result.InIsolation; + var variables = environmentVariables?.Elements()?.ToArray(); - Assert.IsNotNull(environmentVariables, "Environment variable cannot found in RunSettings.xml."); - Assert.IsNotNull(inIsolation, "Isolation must be forced, an InIsolation entry was missing!"); - Assert.AreEqual(1, variables?.Length ?? 0, "Environment variable count mismatched!"); + Assert.IsNotNull(environmentVariables, "Environment variable cannot found in RunSettings.xml."); + Assert.IsNotNull(inIsolation, "Isolation must be forced, an InIsolation entry was missing!"); + Assert.AreEqual(1, variables?.Length ?? 0, "Environment variable count mismatched!"); - Assert.AreEqual("true", inIsolation.Value, "Isolation must be forced, InIsolation is not set to true."); - Assert.AreEqual("VARIABLE", variables[0].Name.LocalName); - Assert.AreEqual("VALUE", variables[0].Value); + Assert.AreEqual("true", inIsolation.Value, "Isolation must be forced, InIsolation is not set to true."); + Assert.AreEqual("VARIABLE", variables[0].Name.LocalName); + Assert.AreEqual("VALUE", variables[0].Value); - } + } - [TestMethod] - public void AppendsMultipleEnvironmentVariablesToRunSettings() - { - // Arrange - var executor1 = GetExecutor(); - var executor2 = GetExecutor(); - var executor3 = GetExecutor(); + [TestMethod] + public void AppendsMultipleEnvironmentVariablesToRunSettings() + { + // Arrange + var executor1 = GetExecutor(); + var executor2 = GetExecutor(); + var executor3 = GetExecutor(); - // Act - executor1.Initialize("VARIABLE_ONE=VALUE"); - executor2.Initialize("VARIABLE_TWO=VALUE WITH SPACE"); - executor3.Initialize("VARIABLE_THREE=VALUE WITH SPACE;AND SEMICOLON"); + // Act + executor1.Initialize("VARIABLE_ONE=VALUE"); + executor2.Initialize("VARIABLE_TWO=VALUE WITH SPACE"); + executor3.Initialize("VARIABLE_THREE=VALUE WITH SPACE;AND SEMICOLON"); - // Assert - var result = ParseSettingsXML(this.settingsProvider); - var environmentVariables = result.variables; - var inIsolation = result.inIsolation; - var variables = environmentVariables?.Elements()?.ToArray(); + // Assert + var result = ParseSettingsXml(_settingsProvider); + var environmentVariables = result.Variables; + var inIsolation = result.InIsolation; + var variables = environmentVariables?.Elements()?.ToArray(); - Assert.IsNotNull(environmentVariables, "Environment variable cannot found in RunSettings.xml."); - Assert.IsNotNull(inIsolation, "Isolation must be forced, an InIsolation entry was missing!"); + Assert.IsNotNull(environmentVariables, "Environment variable cannot found in RunSettings.xml."); + Assert.IsNotNull(inIsolation, "Isolation must be forced, an InIsolation entry was missing!"); - Assert.AreEqual("true", inIsolation.Value, "Isolation must be forced, InIsolation is not set to true."); - Assert.AreEqual(3, variables?.Length ?? 0, "Environment variable count mismatched!"); + Assert.AreEqual("true", inIsolation.Value, "Isolation must be forced, InIsolation is not set to true."); + Assert.AreEqual(3, variables?.Length ?? 0, "Environment variable count mismatched!"); - Assert.AreEqual("VARIABLE_ONE", variables[0].Name.LocalName); - Assert.AreEqual("VALUE", variables[0].Value); + Assert.AreEqual("VARIABLE_ONE", variables[0].Name.LocalName); + Assert.AreEqual("VALUE", variables[0].Value); - Assert.AreEqual("VARIABLE_TWO", variables[1].Name.LocalName); - Assert.AreEqual("VALUE WITH SPACE", variables[1].Value); + Assert.AreEqual("VARIABLE_TWO", variables[1].Name.LocalName); + Assert.AreEqual("VALUE WITH SPACE", variables[1].Value); - Assert.AreEqual("VARIABLE_THREE", variables[2].Name.LocalName); - Assert.AreEqual("VALUE WITH SPACE;AND SEMICOLON", variables[2].Value); - } + Assert.AreEqual("VARIABLE_THREE", variables[2].Name.LocalName); + Assert.AreEqual("VALUE WITH SPACE;AND SEMICOLON", variables[2].Value); + } - [TestMethod] - public void InIsolationValueShouldBeOverriden() - { - // Arrange - this.commandLineOptions.InIsolation = false; - this.settingsProvider.UpdateRunSettingsNode(InIsolationArgumentExecutor.RunSettingsPath, "false"); - var executor = GetExecutor(); + [TestMethod] + public void InIsolationValueShouldBeOverriden() + { + // Arrange + _commandLineOptions.InIsolation = false; + _settingsProvider.UpdateRunSettingsNode(InIsolationArgumentExecutor.RunSettingsPath, "false"); + var executor = GetExecutor(); - // Act - executor.Initialize("VARIABLE=VALUE"); + // Act + executor.Initialize("VARIABLE=VALUE"); - // Assert - var result = ParseSettingsXML(this.settingsProvider); - var environmentVariables = result.variables; - var inIsolation = result.inIsolation; - var variables = environmentVariables?.Elements()?.ToArray(); + // Assert + var result = ParseSettingsXml(_settingsProvider); + var environmentVariables = result.Variables; + var inIsolation = result.InIsolation; + var variables = environmentVariables?.Elements()?.ToArray(); - Assert.IsNotNull(environmentVariables, "Environment variable cannot found in RunSettings.xml."); - Assert.IsNotNull(inIsolation, "Isolation must be forced, an InIsolation entry was missing!"); + Assert.IsNotNull(environmentVariables, "Environment variable cannot found in RunSettings.xml."); + Assert.IsNotNull(inIsolation, "Isolation must be forced, an InIsolation entry was missing!"); - Assert.AreEqual("true", inIsolation.Value, "Isolation must be forced, InIsolation is overriden to true."); - Assert.AreEqual(1, variables?.Length ?? 0, "Environment variable count mismatched!"); + Assert.AreEqual("true", inIsolation.Value, "Isolation must be forced, InIsolation is overriden to true."); + Assert.AreEqual(1, variables?.Length ?? 0, "Environment variable count mismatched!"); - Assert.AreEqual("VARIABLE", variables[0].Name.LocalName); - Assert.AreEqual("VALUE", variables[0].Value); - } + Assert.AreEqual("VARIABLE", variables[0].Name.LocalName); + Assert.AreEqual("VALUE", variables[0].Value); + } - [TestMethod] - public void ShoudWarnWhenAValueIsOverriden() - { - // Arrange - this.settingsProvider.UpdateRunSettingsNode("RunConfiguration.EnvironmentVariables.VARIABLE", - "Initial value"); - var warningMessage = String.Format(CommandLineResources.CommandLineWarning, - String.Format(CommandLineResources.EnvironmentVariableXIsOverriden, "VARIABLE") - ); - this.mockOutput.Setup(mock => - mock.WriteLine( - It.Is(message => message == warningMessage), - It.Is(level => level == OutputLevel.Warning) - ) - ).Verifiable(); - var executor = GetExecutor(); - - // Act - executor.Initialize("VARIABLE=New value"); - - // Assert - this.mockOutput.VerifyAll(); - } + [TestMethod] + public void ShoudWarnWhenAValueIsOverriden() + { + // Arrange + _settingsProvider.UpdateRunSettingsNode("RunConfiguration.EnvironmentVariables.VARIABLE", + "Initial value"); + var warningMessage = String.Format(CommandLineResources.CommandLineWarning, + String.Format(CommandLineResources.EnvironmentVariableXIsOverriden, "VARIABLE") + ); + _mockOutput.Setup(mock => + mock.WriteLine( + It.Is(message => message == warningMessage), + It.Is(level => level == OutputLevel.Warning) + ) + ).Verifiable(); + var executor = GetExecutor(); + + // Act + executor.Initialize("VARIABLE=New value"); + + // Assert + _mockOutput.VerifyAll(); + } - private XmlParseResult ParseSettingsXML(IRunSettingsProvider provider) - { - var document = XDocument.Parse(provider.ActiveRunSettings.SettingsXml); + private XmlParseResult ParseSettingsXml(IRunSettingsProvider provider) + { + var document = XDocument.Parse(provider.ActiveRunSettings.SettingsXml); - var runConfiguration = document - ?.Root - ?.Element("RunConfiguration"); + var runConfiguration = document + ?.Root + ?.Element("RunConfiguration"); - var variables = runConfiguration?.Element("EnvironmentVariables"); - var inIsolation = runConfiguration?.Element("InIsolation"); + var variables = runConfiguration?.Element("EnvironmentVariables"); + var inIsolation = runConfiguration?.Element("InIsolation"); - return new XmlParseResult(variables, inIsolation); - } + return new XmlParseResult(variables, inIsolation); + } - private IArgumentExecutor GetExecutor() - { - return new EnvironmentArgumentProcessor.ArgumentExecutor( - this.commandLineOptions, - this.settingsProvider, - mockOutput.Object - ); - } + private IArgumentExecutor GetExecutor() + { + return new EnvironmentArgumentProcessor.ArgumentExecutor( + _commandLineOptions, + _settingsProvider, + _mockOutput.Object + ); + } - private class XmlParseResult + private class XmlParseResult + { + public XmlParseResult(XElement variables, XElement inIsolation) { - public XmlParseResult(XElement variables, XElement inIsolation) - { - this.variables = variables; - this.inIsolation = inIsolation; - } - - internal XElement variables; - internal XElement inIsolation; + Variables = variables; + InIsolation = inIsolation; } + + internal readonly XElement Variables; + internal readonly XElement InIsolation; } -} +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/FrameworkArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/FrameworkArgumentProcessorTests.cs index 018638fd23..e22e840c4f 100644 --- a/test/vstest.console.UnitTests/Processors/FrameworkArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/FrameworkArgumentProcessorTests.cs @@ -1,141 +1,140 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +using TestTools.UnitTesting; +using TestPlatform.CommandLine.Processors; +using vstest.console.UnitTests.Processors; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; + +using ExceptionUtilities = ExceptionUtilities; + +[TestClass] +public class FrameworkArgumentProcessorTests { - using Microsoft.VisualStudio.TestTools.UnitTesting; - using TestPlatform.CommandLine.Processors; - using vstest.console.UnitTests.Processors; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; + private FrameworkArgumentExecutor _executor; + private TestableRunSettingsProvider _runSettingsProvider; + + [TestInitialize] + public void Init() + { + _runSettingsProvider = new TestableRunSettingsProvider(); + _executor = new FrameworkArgumentExecutor(CommandLineOptions.Instance, _runSettingsProvider); + } + [TestCleanup] + public void TestCleanup() + { + CommandLineOptions.Instance.Reset(); + } + + [TestMethod] + public void GetMetadataShouldReturnFrameworkArgumentProcessorCapabilities() + { + var processor = new FrameworkArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is FrameworkArgumentProcessorCapabilities); + } + + [TestMethod] + public void GetExecuterShouldReturnFrameworkArgumentExecutor() + { + var processor = new FrameworkArgumentProcessor(); + Assert.IsTrue(processor.Executor.Value is FrameworkArgumentExecutor); + } + + #region FrameworkArgumentProcessorCapabilities tests + + [TestMethod] + public void CapabilitiesShouldReturnAppropriateProperties() + { + var capabilities = new FrameworkArgumentProcessorCapabilities(); + Assert.AreEqual("/Framework", capabilities.CommandName); + StringAssert.Contains(capabilities.HelpContentResourceName, "Valid values are \".NETFramework,Version=v4.5.1\", \".NETCoreApp,Version=v1.0\""); + + Assert.AreEqual(HelpContentPriority.FrameworkArgumentProcessorHelpPriority, capabilities.HelpPriority); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.AutoUpdateRunSettings, capabilities.Priority); + + Assert.IsFalse(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } + + #endregion + + #region FrameworkArgumentExecutor Initialize tests + + [TestMethod] + public void InitializeShouldThrowIfArgumentIsNull() + { + + ExceptionUtilities.ThrowsException( + () => _executor.Initialize(null), + "The /Framework argument requires the target .Net Framework version for the test run. Example: /Framework:\".NETFramework,Version=v4.5.1\""); + } + + [TestMethod] + public void InitializeShouldThrowIfArgumentIsEmpty() + { + ExceptionUtilities.ThrowsException( + () => _executor.Initialize(" "), + "The /Framework argument requires the target .Net Framework version for the test run. Example: /Framework:\".NETFramework,Version=v4.5.1\""); + } - using ExceptionUtilities = Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.ExceptionUtilities; + [TestMethod] + public void InitializeShouldThrowIfArgumentIsInvalid() + { + ExceptionUtilities.ThrowsException( + () => _executor.Initialize("foo"), + "Invalid .Net Framework version:{0}. Please give the fullname of the TargetFramework(Example: .NETCoreApp,Version=v2.0). Other supported .Net Framework versions are Framework40, Framework45, FrameworkCore10 and FrameworkUap10.", + "foo"); + } - [TestClass] - public class FrameworkArgumentProcessorTests + [TestMethod] + public void InitializeShouldSetCommandLineOptionsAndRunSettingsFramework() { - private FrameworkArgumentExecutor executor; - private TestableRunSettingsProvider runSettingsProvider; - - [TestInitialize] - public void Init() - { - this.runSettingsProvider = new TestableRunSettingsProvider(); - this.executor = new FrameworkArgumentExecutor(CommandLineOptions.Instance, runSettingsProvider); - } - [TestCleanup] - public void TestCleanup() - { - CommandLineOptions.Instance.Reset(); - } - - [TestMethod] - public void GetMetadataShouldReturnFrameworkArgumentProcessorCapabilities() - { - var processor = new FrameworkArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is FrameworkArgumentProcessorCapabilities); - } - - [TestMethod] - public void GetExecuterShouldReturnFrameworkArgumentExecutor() - { - var processor = new FrameworkArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is FrameworkArgumentExecutor); - } - - #region FrameworkArgumentProcessorCapabilities tests - - [TestMethod] - public void CapabilitiesShouldReturnAppropriateProperties() - { - var capabilities = new FrameworkArgumentProcessorCapabilities(); - Assert.AreEqual("/Framework", capabilities.CommandName); - StringAssert.Contains(capabilities.HelpContentResourceName, "Valid values are \".NETFramework,Version=v4.5.1\", \".NETCoreApp,Version=v1.0\""); - - Assert.AreEqual(HelpContentPriority.FrameworkArgumentProcessorHelpPriority, capabilities.HelpPriority); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.AutoUpdateRunSettings, capabilities.Priority); - - Assert.IsFalse(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); - } - - #endregion - - #region FrameworkArgumentExecutor Initialize tests - - [TestMethod] - public void InitializeShouldThrowIfArgumentIsNull() - { - - ExceptionUtilities.ThrowsException( - () => this.executor.Initialize(null), - "The /Framework argument requires the target .Net Framework version for the test run. Example: /Framework:\".NETFramework,Version=v4.5.1\""); - } - - [TestMethod] - public void InitializeShouldThrowIfArgumentIsEmpty() - { - ExceptionUtilities.ThrowsException( - () => executor.Initialize(" "), - "The /Framework argument requires the target .Net Framework version for the test run. Example: /Framework:\".NETFramework,Version=v4.5.1\""); - } - - [TestMethod] - public void InitializeShouldThrowIfArgumentIsInvalid() - { - ExceptionUtilities.ThrowsException( - () => this.executor.Initialize("foo"), - "Invalid .Net Framework version:{0}. Please give the fullname of the TargetFramework(Example: .NETCoreApp,Version=v2.0). Other supported .Net Framework versions are Framework40, Framework45, FrameworkCore10 and FrameworkUap10.", - "foo"); - } - - [TestMethod] - public void InitializeShouldSetCommandLineOptionsAndRunSettingsFramework() - { - this.executor.Initialize(".NETCoreApp,Version=v1.0"); - Assert.AreEqual(".NETCoreApp,Version=v1.0", CommandLineOptions.Instance.TargetFrameworkVersion.Name); - Assert.AreEqual(".NETCoreApp,Version=v1.0", this.runSettingsProvider.QueryRunSettingsNode(FrameworkArgumentExecutor.RunSettingsPath)); - } - - [TestMethod] - public void InitializeShouldSetCommandLineOptionsFrameworkForOlderFrameworks() - { - this.executor.Initialize("Framework35"); - Assert.AreEqual(".NETFramework,Version=v3.5", CommandLineOptions.Instance.TargetFrameworkVersion.Name); - Assert.AreEqual(".NETFramework,Version=v3.5", this.runSettingsProvider.QueryRunSettingsNode(FrameworkArgumentExecutor.RunSettingsPath)); - } - - [TestMethod] - public void InitializeShouldSetCommandLineOptionsFrameworkForCaseInsensitiveFramework() - { - this.executor.Initialize(".netcoreApp,Version=v1.0"); - Assert.AreEqual(".NETCoreApp,Version=v1.0", CommandLineOptions.Instance.TargetFrameworkVersion.Name); - Assert.AreEqual(".NETCoreApp,Version=v1.0", this.runSettingsProvider.QueryRunSettingsNode(FrameworkArgumentExecutor.RunSettingsPath)); - } - - [TestMethod] - public void InitializeShouldNotSetFrameworkIfSettingsFileIsLegacy() - { - this.runSettingsProvider.UpdateRunSettingsNode(FrameworkArgumentExecutor.RunSettingsPath, nameof(FrameworkVersion.Framework45)); - CommandLineOptions.Instance.SettingsFile = @"c:\tmp\settings.testsettings"; - this.executor.Initialize(".NETFramework,Version=v3.5"); - Assert.AreEqual(".NETFramework,Version=v3.5", CommandLineOptions.Instance.TargetFrameworkVersion.Name); - Assert.AreEqual(nameof(FrameworkVersion.Framework45), this.runSettingsProvider.QueryRunSettingsNode(FrameworkArgumentExecutor.RunSettingsPath)); - } - - #endregion - - #region FrameworkArgumentExecutor Execute tests - - [TestMethod] - public void ExecuteShouldReturnSuccess() - { - Assert.AreEqual(ArgumentProcessorResult.Success, this.executor.Execute()); - } - - #endregion + _executor.Initialize(".NETCoreApp,Version=v1.0"); + Assert.AreEqual(".NETCoreApp,Version=v1.0", CommandLineOptions.Instance.TargetFrameworkVersion.Name); + Assert.AreEqual(".NETCoreApp,Version=v1.0", _runSettingsProvider.QueryRunSettingsNode(FrameworkArgumentExecutor.RunSettingsPath)); + } + [TestMethod] + public void InitializeShouldSetCommandLineOptionsFrameworkForOlderFrameworks() + { + _executor.Initialize("Framework35"); + Assert.AreEqual(".NETFramework,Version=v3.5", CommandLineOptions.Instance.TargetFrameworkVersion.Name); + Assert.AreEqual(".NETFramework,Version=v3.5", _runSettingsProvider.QueryRunSettingsNode(FrameworkArgumentExecutor.RunSettingsPath)); } -} + + [TestMethod] + public void InitializeShouldSetCommandLineOptionsFrameworkForCaseInsensitiveFramework() + { + _executor.Initialize(".netcoreApp,Version=v1.0"); + Assert.AreEqual(".NETCoreApp,Version=v1.0", CommandLineOptions.Instance.TargetFrameworkVersion.Name); + Assert.AreEqual(".NETCoreApp,Version=v1.0", _runSettingsProvider.QueryRunSettingsNode(FrameworkArgumentExecutor.RunSettingsPath)); + } + + [TestMethod] + public void InitializeShouldNotSetFrameworkIfSettingsFileIsLegacy() + { + _runSettingsProvider.UpdateRunSettingsNode(FrameworkArgumentExecutor.RunSettingsPath, nameof(FrameworkVersion.Framework45)); + CommandLineOptions.Instance.SettingsFile = @"c:\tmp\settings.testsettings"; + _executor.Initialize(".NETFramework,Version=v3.5"); + Assert.AreEqual(".NETFramework,Version=v3.5", CommandLineOptions.Instance.TargetFrameworkVersion.Name); + Assert.AreEqual(nameof(FrameworkVersion.Framework45), _runSettingsProvider.QueryRunSettingsNode(FrameworkArgumentExecutor.RunSettingsPath)); + } + + #endregion + + #region FrameworkArgumentExecutor Execute tests + + [TestMethod] + public void ExecuteShouldReturnSuccess() + { + Assert.AreEqual(ArgumentProcessorResult.Success, _executor.Execute()); + } + + #endregion + +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/HelpArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/HelpArgumentProcessorTests.cs index 9dd22f9691..7475a75ccc 100644 --- a/test/vstest.console.UnitTests/Processors/HelpArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/HelpArgumentProcessorTests.cs @@ -1,101 +1,101 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +using System; +using System.Collections.Generic; + +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using Microsoft.VisualStudio.TestPlatform.Utilities; + +using TestTools.UnitTesting; + +[TestClass] +public class HelpArgumentProcessorTests { - using System; - using System.Collections.Generic; + /// + /// The help argument processor get metadata should return help argument processor capabilities. + /// + [TestMethod] + public void GetMetadataShouldReturnHelpArgumentProcessorCapabilities() + { + HelpArgumentProcessor processor = new(); + Assert.IsTrue(processor.Metadata.Value is HelpArgumentProcessorCapabilities); + } + + /// + /// The help argument processor get executer should return help argument processor capabilities. + /// + [TestMethod] + public void GetExecuterShouldReturnHelpArgumentProcessorCapabilities() + { + HelpArgumentProcessor processor = new(); + Assert.IsTrue(processor.Executor.Value is HelpArgumentExecutor); + } + + #region HelpArgumentProcessorCapabilitiesTests + + [TestMethod] + public void CapabilitiesShouldAppropriateProperties() + { + HelpArgumentProcessorCapabilities capabilities = new(); + Assert.AreEqual("/Help", capabilities.CommandName); + Assert.AreEqual("-?|--Help|/?|/Help" + Environment.NewLine + " Display this usage message.", capabilities.HelpContentResourceName); + + Assert.AreEqual(HelpContentPriority.HelpArgumentProcessorHelpPriority, capabilities.HelpPriority); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.Help, capabilities.Priority); - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; + Assert.IsTrue(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } + + #endregion - [TestClass] - public class HelpArgumentProcessorTests + [TestMethod] + public void ExecuterExecuteReturnArgumentProcessorResultAbort() { - /// - /// The help argument processor get metadata should return help argument processor capabilities. - /// - [TestMethod] - public void GetMetadataShouldReturnHelpArgumentProcessorCapabilities() - { - HelpArgumentProcessor processor = new HelpArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is HelpArgumentProcessorCapabilities); - } - - /// - /// The help argument processor get executer should return help argument processor capabilities. - /// - [TestMethod] - public void GetExecuterShouldReturnHelpArgumentProcessorCapabilities() - { - HelpArgumentProcessor processor = new HelpArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is HelpArgumentExecutor); - } - - #region HelpArgumentProcessorCapabilitiesTests - - [TestMethod] - public void CapabilitiesShouldAppropriateProperties() - { - HelpArgumentProcessorCapabilities capabilities = new HelpArgumentProcessorCapabilities(); - Assert.AreEqual("/Help", capabilities.CommandName); - Assert.AreEqual("-?|--Help|/?|/Help" + Environment.NewLine + " Display this usage message.", capabilities.HelpContentResourceName); - - Assert.AreEqual(HelpContentPriority.HelpArgumentProcessorHelpPriority, capabilities.HelpPriority); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.Help, capabilities.Priority); - - Assert.IsTrue(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); - } - - #endregion - - [TestMethod] - public void ExecuterExecuteReturnArgumentProcessorResultAbort() - { - HelpArgumentExecutor executor = new HelpArgumentExecutor(); - var result = executor.Execute(); - Assert.AreEqual(ArgumentProcessorResult.Abort, result); - } - - [TestMethod] - public void ExecuterExecuteWritesAppropriateDataToConsole() - { - HelpArgumentExecutor executor = new HelpArgumentExecutor(); - var output = new DummyConsoleOutput(); - executor.Output = output; - var result = executor.Execute(); - Assert.IsTrue(output.Lines.Contains("Usage: vstest.console.exe [Arguments] [Options] [[--] ...]]")); - Assert.IsTrue(output.Lines.Contains("Arguments:")); - Assert.IsTrue(output.Lines.Contains("Options:")); - Assert.IsTrue(output.Lines.Contains("Description: Runs tests from the specified files.")); - Assert.IsTrue(output.Lines.Contains(" To run tests:" + Environment.NewLine + " >vstest.console.exe tests.dll " + Environment.NewLine + " To run tests with additional settings such as data collectors:" + Environment.NewLine + " >vstest.console.exe tests.dll /Settings:Local.RunSettings")); - } + HelpArgumentExecutor executor = new(); + var result = executor.Execute(); + Assert.AreEqual(ArgumentProcessorResult.Abort, result); } - internal class DummyConsoleOutput : IOutput + [TestMethod] + public void ExecuterExecuteWritesAppropriateDataToConsole() { - /// - /// The lines. - /// - internal List Lines; - - public DummyConsoleOutput() - { - this.Lines = new List(); - } - - public void WriteLine(string message, OutputLevel level) - { - this.Lines.Add(message); - } - - public void Write(string message, OutputLevel level) - { - throw new System.NotImplementedException(); - } + HelpArgumentExecutor executor = new(); + var output = new DummyConsoleOutput(); + executor.Output = output; + _ = executor.Execute(); + Assert.IsTrue(output.Lines.Contains("Usage: vstest.console.exe [Arguments] [Options] [[--] ...]]")); + Assert.IsTrue(output.Lines.Contains("Arguments:")); + Assert.IsTrue(output.Lines.Contains("Options:")); + Assert.IsTrue(output.Lines.Contains("Description: Runs tests from the specified files.")); + Assert.IsTrue(output.Lines.Contains(" To run tests:" + Environment.NewLine + " >vstest.console.exe tests.dll " + Environment.NewLine + " To run tests with additional settings such as data collectors:" + Environment.NewLine + " >vstest.console.exe tests.dll /Settings:Local.RunSettings")); } } + +internal class DummyConsoleOutput : IOutput +{ + /// + /// The lines. + /// + internal List Lines; + + public DummyConsoleOutput() + { + Lines = new List(); + } + + public void WriteLine(string message, OutputLevel level) + { + Lines.Add(message); + } + + public void Write(string message, OutputLevel level) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/InIsolationArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/InIsolationArgumentProcessorTests.cs index 59632690eb..c391d8e410 100644 --- a/test/vstest.console.UnitTests/Processors/InIsolationArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/InIsolationArgumentProcessorTests.cs @@ -1,85 +1,86 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors -{ - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using System; - using vstest.console.UnitTests.Processors; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; - using ExceptionUtilities = Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.ExceptionUtilities; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using TestTools.UnitTesting; - [TestClass] - public class InIsolationArgumentProcessorTests - { - private InIsolationArgumentExecutor executor; - private TestableRunSettingsProvider runSettingsProvider; +using System; - [TestInitialize] - public void Init() - { - this.runSettingsProvider = new TestableRunSettingsProvider(); - this.executor = new InIsolationArgumentExecutor(CommandLineOptions.Instance, this.runSettingsProvider); - } +using vstest.console.UnitTests.Processors; - [TestCleanup] - public void TestCleanup() - { - CommandLineOptions.Instance.Reset(); - } +using ExceptionUtilities = ExceptionUtilities; - [TestMethod] - public void GetMetadataShouldReturnInProcessArgumentProcessorCapabilities() - { - var processor = new InIsolationArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is InIsolationArgumentProcessorCapabilities); - } +[TestClass] +public class InIsolationArgumentProcessorTests +{ + private InIsolationArgumentExecutor _executor; + private TestableRunSettingsProvider _runSettingsProvider; - [TestMethod] - public void GetExecuterShouldReturnInProcessArgumentExecutor() - { - var processor = new InIsolationArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is InIsolationArgumentExecutor); - } + [TestInitialize] + public void Init() + { + _runSettingsProvider = new TestableRunSettingsProvider(); + _executor = new InIsolationArgumentExecutor(CommandLineOptions.Instance, _runSettingsProvider); + } - [TestMethod] - public void InIsolationArgumentProcessorMetadataShouldProvideAppropriateCapabilities() - { - var isolationProcessor = new InIsolationArgumentProcessor(); - Assert.IsFalse(isolationProcessor.Metadata.Value.AllowMultiple); - Assert.IsFalse(isolationProcessor.Metadata.Value.AlwaysExecute); - Assert.IsFalse(isolationProcessor.Metadata.Value.IsAction); - Assert.IsFalse(isolationProcessor.Metadata.Value.IsSpecialCommand); - Assert.AreEqual(InIsolationArgumentProcessor.CommandName, isolationProcessor.Metadata.Value.CommandName); - Assert.IsNull(isolationProcessor.Metadata.Value.ShortCommandName); - Assert.AreEqual(ArgumentProcessorPriority.AutoUpdateRunSettings, isolationProcessor.Metadata.Value.Priority); - Assert.AreEqual(HelpContentPriority.InIsolationArgumentProcessorHelpPriority, isolationProcessor.Metadata.Value.HelpPriority); - Assert.AreEqual("--InIsolation|/InIsolation" + Environment.NewLine + " Runs the tests in an isolated process. This makes vstest.console.exe " + Environment.NewLine + " process less likely to be stopped on an error in the tests, but tests " + Environment.NewLine + " may run slower.", isolationProcessor.Metadata.Value.HelpContentResourceName); - } + [TestCleanup] + public void TestCleanup() + { + CommandLineOptions.Instance.Reset(); + } - [TestMethod] - public void InIsolationArgumentProcessorExecutorShouldThrowIfArgumentIsProvided() - { - // InProcess should not have any values or arguments - ExceptionUtilities.ThrowsException( - () => this.executor.Initialize("true"), - "Argument true is not expected in the 'InIsolation' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InIsolation) and try again."); - } + [TestMethod] + public void GetMetadataShouldReturnInProcessArgumentProcessorCapabilities() + { + var processor = new InIsolationArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is InIsolationArgumentProcessorCapabilities); + } - [TestMethod] - public void InitializeShouldSetInIsolationValue() - { - this.executor.Initialize(null); - Assert.IsTrue(CommandLineOptions.Instance.InIsolation, "InProcess option must be set to true."); - Assert.AreEqual("true", this.runSettingsProvider.QueryRunSettingsNode(InIsolationArgumentExecutor.RunSettingsPath)); - } + [TestMethod] + public void GetExecuterShouldReturnInProcessArgumentExecutor() + { + var processor = new InIsolationArgumentProcessor(); + Assert.IsTrue(processor.Executor.Value is InIsolationArgumentExecutor); + } - [TestMethod] - public void ExecuteShouldReturnSuccess() - { - Assert.AreEqual(ArgumentProcessorResult.Success, this.executor.Execute()); - } + [TestMethod] + public void InIsolationArgumentProcessorMetadataShouldProvideAppropriateCapabilities() + { + var isolationProcessor = new InIsolationArgumentProcessor(); + Assert.IsFalse(isolationProcessor.Metadata.Value.AllowMultiple); + Assert.IsFalse(isolationProcessor.Metadata.Value.AlwaysExecute); + Assert.IsFalse(isolationProcessor.Metadata.Value.IsAction); + Assert.IsFalse(isolationProcessor.Metadata.Value.IsSpecialCommand); + Assert.AreEqual(InIsolationArgumentProcessor.CommandName, isolationProcessor.Metadata.Value.CommandName); + Assert.IsNull(isolationProcessor.Metadata.Value.ShortCommandName); + Assert.AreEqual(ArgumentProcessorPriority.AutoUpdateRunSettings, isolationProcessor.Metadata.Value.Priority); + Assert.AreEqual(HelpContentPriority.InIsolationArgumentProcessorHelpPriority, isolationProcessor.Metadata.Value.HelpPriority); + Assert.AreEqual("--InIsolation|/InIsolation" + Environment.NewLine + " Runs the tests in an isolated process. This makes vstest.console.exe " + Environment.NewLine + " process less likely to be stopped on an error in the tests, but tests " + Environment.NewLine + " may run slower.", isolationProcessor.Metadata.Value.HelpContentResourceName); + } + + [TestMethod] + public void InIsolationArgumentProcessorExecutorShouldThrowIfArgumentIsProvided() + { + // InProcess should not have any values or arguments + ExceptionUtilities.ThrowsException( + () => _executor.Initialize("true"), + "Argument true is not expected in the 'InIsolation' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /InIsolation) and try again."); + } + + [TestMethod] + public void InitializeShouldSetInIsolationValue() + { + _executor.Initialize(null); + Assert.IsTrue(CommandLineOptions.Instance.InIsolation, "InProcess option must be set to true."); + Assert.AreEqual("true", _runSettingsProvider.QueryRunSettingsNode(InIsolationArgumentExecutor.RunSettingsPath)); + } + + [TestMethod] + public void ExecuteShouldReturnSuccess() + { + Assert.AreEqual(ArgumentProcessorResult.Success, _executor.Execute()); } } \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/ListFullyQualifiedTestsArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/ListFullyQualifiedTestsArgumentProcessorTests.cs index 63309d5341..d560347272 100644 --- a/test/vstest.console.UnitTests/Processors/ListFullyQualifiedTestsArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/ListFullyQualifiedTestsArgumentProcessorTests.cs @@ -1,343 +1,343 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.Versioning; +using System.Threading.Tasks; + +using CoreUtilities.Tracing.Interfaces; + +using Extensions.FileSystemGlobbing; +using Client; +using Client.RequestHelper; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using Publisher; +using CommandLineUtilities; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using ObjectModel.Engine; +using PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using TestTools.UnitTesting; + +using Moq; + +using ObjectModel; +using ObjectModel.Client; + +using TestPlatform.Utilities; + +using TestPlatformHelpers; + +using vstest.console.Internal; +using vstest.console.UnitTests.Processors; + +// +// Tests for ListFullyQualifiedTestsArgumentProcessor +// +[TestClass] +public class ListFullyQualifiedTestsArgumentProcessorTests { - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Runtime.Versioning; - using System.Threading.Tasks; - - using CoreUtilities.Tracing.Interfaces; - using Microsoft.Extensions.FileSystemGlobbing; - using Microsoft.VisualStudio.TestPlatform.Client; - using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Publisher; - using Microsoft.VisualStudio.TestPlatform.CommandLineUtilities; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using ObjectModel; - using ObjectModel.Client; - using TestPlatform.Utilities; - using TestPlatformHelpers; - using vstest.console.Internal; - using vstest.console.UnitTests.Processors; - - // - // Tests for ListFullyQualifiedTestsArgumentProcessor - // - [TestClass] - public class ListFullyQualifiedTestsArgumentProcessorTests + private readonly Mock _mockFileHelper; + private readonly Mock _mockAssemblyMetadataProvider; + private readonly InferHelper _inferHelper; + private readonly string _dummyTestFilePath = "DummyTest.dll"; + private readonly string _dummyFilePath = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}.txt"); + private readonly Mock _mockTestPlatformEventSource; + private readonly Task _mockMetricsPublisherTask; + private readonly Mock _mockMetricsPublisher; + private readonly Mock _mockProcessHelper; + private readonly Mock _mockAttachmentsProcessingManager; + + private static ListFullyQualifiedTestsArgumentExecutor GetExecutor(ITestRequestManager testRequestManager, IOutput output) { - private readonly Mock mockFileHelper; - private Mock mockAssemblyMetadataProvider; - private InferHelper inferHelper; - private string dummyTestFilePath = "DummyTest.dll"; - private string dummyFilePath = Path.Combine(Path.GetTempPath(), $"{System.Guid.NewGuid()}.txt"); - private readonly Mock mockTestPlatformEventSource; - private Task mockMetricsPublisherTask; - private Mock mockMetricsPublisher; - private Mock mockProcessHelper; - private Mock mockAttachmentsProcessingManager; - - private static ListFullyQualifiedTestsArgumentExecutor GetExecutor(ITestRequestManager testRequestManager, IOutput output) - { - var runSettingsProvider = new TestableRunSettingsProvider(); - runSettingsProvider.AddDefaultRunSettings(); - var listFullyQualifiedTestsArgumentExecutor = - new ListFullyQualifiedTestsArgumentExecutor( - CommandLineOptions.Instance, - runSettingsProvider, - testRequestManager, - output ?? ConsoleOutput.Instance); - return listFullyQualifiedTestsArgumentExecutor; - } - - [TestCleanup] - public void Cleanup() - { - File.Delete(dummyFilePath); - CommandLineOptions.Instance.Reset(); - } + var runSettingsProvider = new TestableRunSettingsProvider(); + runSettingsProvider.AddDefaultRunSettings(); + var listFullyQualifiedTestsArgumentExecutor = + new ListFullyQualifiedTestsArgumentExecutor( + CommandLineOptions.Instance, + runSettingsProvider, + testRequestManager, + output ?? ConsoleOutput.Instance); + return listFullyQualifiedTestsArgumentExecutor; + } - public ListFullyQualifiedTestsArgumentProcessorTests() - { - this.mockFileHelper = new Mock(); - this.mockFileHelper.Setup(fh => fh.Exists(this.dummyTestFilePath)).Returns(true); - this.mockFileHelper.Setup(x => x.GetCurrentDirectory()).Returns(""); - this.mockMetricsPublisher = new Mock(); - this.mockMetricsPublisherTask = Task.FromResult(this.mockMetricsPublisher.Object); - this.mockTestPlatformEventSource = new Mock(); - this.mockAssemblyMetadataProvider = new Mock(); - this.mockAssemblyMetadataProvider.Setup(x => x.GetArchitecture(It.IsAny())).Returns(Architecture.X64); - this.mockAssemblyMetadataProvider.Setup(x => x.GetFrameWork(It.IsAny())).Returns(new FrameworkName(Constants.DotNetFramework40)); - this.inferHelper = new InferHelper(this.mockAssemblyMetadataProvider.Object); - this.mockProcessHelper = new Mock(); - this.mockAttachmentsProcessingManager = new Mock(); - } - - /// - /// The help argument processor get metadata should return help argument processor capabilities. - /// - [TestMethod] - public void GetMetadataShouldReturnListFullyQualifiedTestsArgumentProcessorCapabilities() - { - var processor = new ListTestsArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is ListTestsArgumentProcessorCapabilities); - } - - /// - /// The help argument processor get executer should return help argument processor capabilities. - /// - [TestMethod] - public void GetExecuterShouldReturnListFullyQualifiedTestsArgumentProcessorCapabilities() - { - var processor = new ListFullyQualifiedTestsArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is ListFullyQualifiedTestsArgumentExecutor); - } + [TestCleanup] + public void Cleanup() + { + File.Delete(_dummyFilePath); + CommandLineOptions.Instance.Reset(); + } - #region ListTestsArgumentProcessorCapabilitiesTests + public ListFullyQualifiedTestsArgumentProcessorTests() + { + _mockFileHelper = new Mock(); + _mockFileHelper.Setup(fh => fh.Exists(_dummyTestFilePath)).Returns(true); + _mockFileHelper.Setup(x => x.GetCurrentDirectory()).Returns(""); + _mockMetricsPublisher = new Mock(); + _mockMetricsPublisherTask = Task.FromResult(_mockMetricsPublisher.Object); + _mockTestPlatformEventSource = new Mock(); + _mockAssemblyMetadataProvider = new Mock(); + _mockAssemblyMetadataProvider.Setup(x => x.GetArchitecture(It.IsAny())).Returns(Architecture.X64); + _mockAssemblyMetadataProvider.Setup(x => x.GetFrameWork(It.IsAny())).Returns(new FrameworkName(Constants.DotNetFramework40)); + _inferHelper = new InferHelper(_mockAssemblyMetadataProvider.Object); + _mockProcessHelper = new Mock(); + _mockAttachmentsProcessingManager = new Mock(); + } - [TestMethod] - public void CapabilitiesShouldReturnAppropriateProperties() - { - var capabilities = new ListFullyQualifiedTestsArgumentProcessorCapabilities(); - Assert.AreEqual("/ListFullyQualifiedTests", capabilities.CommandName); + /// + /// The help argument processor get metadata should return help argument processor capabilities. + /// + [TestMethod] + public void GetMetadataShouldReturnListFullyQualifiedTestsArgumentProcessorCapabilities() + { + var processor = new ListTestsArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is ListTestsArgumentProcessorCapabilities); + } - Assert.IsTrue(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.Normal, capabilities.Priority); + /// + /// The help argument processor get executer should return help argument processor capabilities. + /// + [TestMethod] + public void GetExecuterShouldReturnListFullyQualifiedTestsArgumentProcessorCapabilities() + { + var processor = new ListFullyQualifiedTestsArgumentProcessor(); + Assert.IsTrue(processor.Executor.Value is ListFullyQualifiedTestsArgumentExecutor); + } - Assert.IsFalse(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); - } - #endregion + #region ListTestsArgumentProcessorCapabilitiesTests - #region ListTestsArgumentExecutorTests + [TestMethod] + public void CapabilitiesShouldReturnAppropriateProperties() + { + var capabilities = new ListFullyQualifiedTestsArgumentProcessorCapabilities(); + Assert.AreEqual("/ListFullyQualifiedTests", capabilities.CommandName); - [TestMethod] - public void ExecutorInitializeWithValidSourceShouldAddItToTestSources() - { - CommandLineOptions.Instance.FileHelper = this.mockFileHelper.Object; - CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, this.mockFileHelper.Object); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager, null); + Assert.IsTrue(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.Normal, capabilities.Priority); - executor.Initialize(this.dummyTestFilePath); + Assert.IsFalse(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } + #endregion - Assert.IsTrue(Enumerable.Contains(CommandLineOptions.Instance.Sources, this.dummyTestFilePath)); - } + #region ListTestsArgumentExecutorTests - [TestMethod] - public void ExecutorExecuteForNoSourcesShouldReturnFail() - { - CommandLineOptions.Instance.Reset(); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager, null); + [TestMethod] + public void ExecutorInitializeWithValidSourceShouldAddItToTestSources() + { + CommandLineOptions.Instance.FileHelper = _mockFileHelper.Object; + CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, _mockFileHelper.Object); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager, null); - Assert.ThrowsException(() => executor.Execute()); - } + executor.Initialize(_dummyTestFilePath); - [TestMethod] - public void ExecutorExecuteShouldThrowTestPlatformException() - { - var mockTestPlatform = new Mock(); - var mockDiscoveryRequest = new Mock(); + Assert.IsTrue(Enumerable.Contains(CommandLineOptions.Instance.Sources, _dummyTestFilePath)); + } - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new TestPlatformException("DummyTestPlatformException")); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + [TestMethod] + public void ExecutorExecuteForNoSourcesShouldReturnFail() + { + CommandLineOptions.Instance.Reset(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager, null); - this.ResetAndAddSourceToCommandLineOptions(true); + Assert.ThrowsException(() => executor.Execute()); + } - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); + [TestMethod] + public void ExecutorExecuteShouldThrowTestPlatformException() + { + var mockTestPlatform = new Mock(); + var mockDiscoveryRequest = new Mock(); - var executor = GetExecutor(testRequestManager, null); + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new TestPlatformException("DummyTestPlatformException")); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - Assert.ThrowsException(() => executor.Execute()); - } + ResetAndAddSourceToCommandLineOptions(true); - [TestMethod] - public void ExecutorExecuteShouldThrowSettingsException() - { - var mockTestPlatform = new Mock(); - var mockDiscoveryRequest = new Mock(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new SettingsException("DummySettingsException")); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - this.ResetAndAddSourceToCommandLineOptions(true); + var executor = GetExecutor(testRequestManager, null); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); + Assert.ThrowsException(() => executor.Execute()); + } - var listTestsArgumentExecutor = GetExecutor(testRequestManager, null); + [TestMethod] + public void ExecutorExecuteShouldThrowSettingsException() + { + var mockTestPlatform = new Mock(); + var mockDiscoveryRequest = new Mock(); - Assert.ThrowsException(() => listTestsArgumentExecutor.Execute()); - } + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new SettingsException("DummySettingsException")); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + ResetAndAddSourceToCommandLineOptions(true); - [TestMethod] - public void ExecutorExecuteShouldThrowInvalidOperationException() - { - var mockTestPlatform = new Mock(); - var mockDiscoveryRequest = new Mock(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new InvalidOperationException("DummyInvalidOperationException")); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + var listTestsArgumentExecutor = GetExecutor(testRequestManager, null); - this.ResetAndAddSourceToCommandLineOptions(true); + Assert.ThrowsException(() => listTestsArgumentExecutor.Execute()); + } + [TestMethod] + public void ExecutorExecuteShouldThrowInvalidOperationException() + { + var mockTestPlatform = new Mock(); + var mockDiscoveryRequest = new Mock(); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new InvalidOperationException("DummyInvalidOperationException")); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - var listTestsArgumentExecutor = GetExecutor(testRequestManager, null); + ResetAndAddSourceToCommandLineOptions(true); - Assert.ThrowsException(() => listTestsArgumentExecutor.Execute()); - } - [TestMethod] - public void ExecutorExecuteShouldThrowOtherExceptions() - { - var mockTestPlatform = new Mock(); - var mockDiscoveryRequest = new Mock(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new Exception("DummyException")); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + var listTestsArgumentExecutor = GetExecutor(testRequestManager, null); - this.ResetAndAddSourceToCommandLineOptions(true); + Assert.ThrowsException(() => listTestsArgumentExecutor.Execute()); + } - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); + [TestMethod] + public void ExecutorExecuteShouldThrowOtherExceptions() + { + var mockTestPlatform = new Mock(); + var mockDiscoveryRequest = new Mock(); - var executor = GetExecutor(testRequestManager, null); + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new Exception("DummyException")); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - Assert.ThrowsException(() => executor.Execute()); - } + ResetAndAddSourceToCommandLineOptions(true); - [TestMethod] - public void ExecutorExecuteShouldOutputDiscoveredTestsAndReturnSuccess() - { - var mockDiscoveryRequest = new Mock(); - var mockConsoleOutput = new Mock(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); - this.RunListFullyQualifiedTestArgumentProcessorExecuteWithMockSetup(mockDiscoveryRequest, mockConsoleOutput); + var executor = GetExecutor(testRequestManager, null); - mockDiscoveryRequest.Verify(dr => dr.DiscoverAsync(), Times.Once); + Assert.ThrowsException(() => executor.Execute()); + } - var fileOutput = File.ReadAllLines(this.dummyFilePath); - Assert.IsTrue(fileOutput.Length == 2); - Assert.IsTrue(fileOutput.Contains("Test1")); - Assert.IsTrue(fileOutput.Contains("Test2")); - } + [TestMethod] + public void ExecutorExecuteShouldOutputDiscoveredTestsAndReturnSuccess() + { + var mockDiscoveryRequest = new Mock(); + var mockConsoleOutput = new Mock(); - [TestMethod] - public void DiscoveryShouldFilterCategoryTestsAndReturnSuccess() - { - var mockDiscoveryRequest = new Mock(); - var mockConsoleOutput = new Mock(); + RunListFullyQualifiedTestArgumentProcessorExecuteWithMockSetup(mockDiscoveryRequest, mockConsoleOutput); - this.RunListFullyQualifiedTestArgumentProcessorWithTraits(mockDiscoveryRequest, mockConsoleOutput); + mockDiscoveryRequest.Verify(dr => dr.DiscoverAsync(), Times.Once); - mockDiscoveryRequest.Verify(dr => dr.DiscoverAsync(), Times.Once); + var fileOutput = File.ReadAllLines(_dummyFilePath); + Assert.IsTrue(fileOutput.Length == 2); + Assert.IsTrue(fileOutput.Contains("Test1")); + Assert.IsTrue(fileOutput.Contains("Test2")); + } - var fileOutput = File.ReadAllLines(this.dummyFilePath); - Assert.IsTrue(fileOutput.Length == 1); - Assert.IsTrue(fileOutput.Contains("Test1")); - Assert.IsFalse(fileOutput.Contains("Test2")); - } + [TestMethod] + public void DiscoveryShouldFilterCategoryTestsAndReturnSuccess() + { + var mockDiscoveryRequest = new Mock(); + var mockConsoleOutput = new Mock(); - [ExpectedException(typeof(CommandLineException))] - [TestMethod] - public void ExecutorExecuteShouldThrowWhenListFullyQualifiedTestsTargetPathIsEmpty() - { - var mockDiscoveryRequest = new Mock(); - var mockConsoleOutput = new Mock(); + RunListFullyQualifiedTestArgumentProcessorWithTraits(mockDiscoveryRequest, mockConsoleOutput); - this.RunListFullyQualifiedTestArgumentProcessorExecuteWithMockSetup(mockDiscoveryRequest, mockConsoleOutput, false); - } + mockDiscoveryRequest.Verify(dr => dr.DiscoverAsync(), Times.Once); - [TestMethod] - public void ListFullyQualifiedTestsArgumentProcessorExecuteShouldInstrumentDiscoveryRequestStart() - { - var mockDiscoveryRequest = new Mock(); - var mockConsoleOutput = new Mock(); + var fileOutput = File.ReadAllLines(_dummyFilePath); + Assert.IsTrue(fileOutput.Length == 1); + Assert.IsTrue(fileOutput.Contains("Test1")); + Assert.IsFalse(fileOutput.Contains("Test2")); + } - this.RunListFullyQualifiedTestArgumentProcessorExecuteWithMockSetup(mockDiscoveryRequest, mockConsoleOutput); + [ExpectedException(typeof(CommandLineException))] + [TestMethod] + public void ExecutorExecuteShouldThrowWhenListFullyQualifiedTestsTargetPathIsEmpty() + { + var mockDiscoveryRequest = new Mock(); + var mockConsoleOutput = new Mock(); - this.mockTestPlatformEventSource.Verify(x => x.DiscoveryRequestStart(), Times.Once); - } + RunListFullyQualifiedTestArgumentProcessorExecuteWithMockSetup(mockDiscoveryRequest, mockConsoleOutput, false); + } - [TestMethod] - public void ListFullyQualifiedTestsArgumentProcessorExecuteShouldInstrumentDiscoveryRequestStop() - { - var mockDiscoveryRequest = new Mock(); - var mockConsoleOutput = new Mock(); + [TestMethod] + public void ListFullyQualifiedTestsArgumentProcessorExecuteShouldInstrumentDiscoveryRequestStart() + { + var mockDiscoveryRequest = new Mock(); + var mockConsoleOutput = new Mock(); - this.RunListFullyQualifiedTestArgumentProcessorExecuteWithMockSetup(mockDiscoveryRequest, mockConsoleOutput); + RunListFullyQualifiedTestArgumentProcessorExecuteWithMockSetup(mockDiscoveryRequest, mockConsoleOutput); - this.mockTestPlatformEventSource.Verify(x => x.DiscoveryRequestStop(), Times.Once); - } - #endregion + _mockTestPlatformEventSource.Verify(x => x.DiscoveryRequestStart(), Times.Once); + } - private void RunListFullyQualifiedTestArgumentProcessorWithTraits(Mock mockDiscoveryRequest, Mock mockConsoleOutput, bool legitPath = true) - { - var mockTestPlatform = new Mock(); - var list = new List(); + [TestMethod] + public void ListFullyQualifiedTestsArgumentProcessorExecuteShouldInstrumentDiscoveryRequestStop() + { + var mockDiscoveryRequest = new Mock(); + var mockConsoleOutput = new Mock(); - var t1 = new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1"); - t1.Traits.Add(new Trait("Category", "MyCat")); - list.Add(t1); + RunListFullyQualifiedTestArgumentProcessorExecuteWithMockSetup(mockDiscoveryRequest, mockConsoleOutput); + + _mockTestPlatformEventSource.Verify(x => x.DiscoveryRequestStop(), Times.Once); + } + #endregion + + private void RunListFullyQualifiedTestArgumentProcessorWithTraits(Mock mockDiscoveryRequest, Mock mockConsoleOutput, bool legitPath = true) + { + var mockTestPlatform = new Mock(); + var list = new List(); - var t2 = new TestCase("Test2", new Uri("http://FooTestUri2"), "Source2"); - t2.Traits.Add(new Trait("Category", "MyBat")); - list.Add(t2); + var t1 = new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1"); + t1.Traits.Add(new Trait("Category", "MyCat")); + list.Add(t1); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + var t2 = new TestCase("Test2", new Uri("http://FooTestUri2"), "Source2"); + t2.Traits.Add(new Trait("Category", "MyBat")); + list.Add(t2); - this.ResetAndAddSourceToCommandLineOptions(legitPath); - var cmdOptions = CommandLineOptions.Instance; - cmdOptions.TestCaseFilterValue = "TestCategory=MyCat"; + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - var testRequestManager = new TestRequestManager(cmdOptions, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); + ResetAndAddSourceToCommandLineOptions(legitPath); + var cmdOptions = CommandLineOptions.Instance; + cmdOptions.TestCaseFilterValue = "TestCategory=MyCat"; - GetExecutor(testRequestManager, mockConsoleOutput.Object).Execute(); - } + var testRequestManager = new TestRequestManager(cmdOptions, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); - private void RunListFullyQualifiedTestArgumentProcessorExecuteWithMockSetup(Mock mockDiscoveryRequest, Mock mockConsoleOutput, bool legitPath = true) + GetExecutor(testRequestManager, mockConsoleOutput.Object).Execute(); + } + + private void RunListFullyQualifiedTestArgumentProcessorExecuteWithMockSetup(Mock mockDiscoveryRequest, Mock mockConsoleOutput, bool legitPath = true) + { + var mockTestPlatform = new Mock(); + var list = new List { - var mockTestPlatform = new Mock(); - var list = new List(); - list.Add(new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1")); - list.Add(new TestCase("Test2", new Uri("http://FooTestUri2"), "Source2")); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1"), + new TestCase("Test2", new Uri("http://FooTestUri2"), "Source2") + }; + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - this.ResetAndAddSourceToCommandLineOptions(legitPath); + ResetAndAddSourceToCommandLineOptions(legitPath); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); - GetExecutor(testRequestManager, mockConsoleOutput.Object).Execute(); - } + GetExecutor(testRequestManager, mockConsoleOutput.Object).Execute(); + } - private void ResetAndAddSourceToCommandLineOptions(bool legitPath) - { - CommandLineOptions.Instance.Reset(); - - CommandLineOptions.Instance.FileHelper = this.mockFileHelper.Object; - CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, this.mockFileHelper.Object); - CommandLineOptions.Instance.AddSource(this.dummyTestFilePath); - if (legitPath) - { - CommandLineOptions.Instance.ListTestsTargetPath = this.dummyFilePath; - } - else - { - CommandLineOptions.Instance.ListTestsTargetPath = string.Empty; - } - } + private void ResetAndAddSourceToCommandLineOptions(bool legitPath) + { + CommandLineOptions.Instance.Reset(); + + CommandLineOptions.Instance.FileHelper = _mockFileHelper.Object; + CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, _mockFileHelper.Object); + CommandLineOptions.Instance.AddSource(_dummyTestFilePath); + CommandLineOptions.Instance.ListTestsTargetPath = legitPath ? _dummyFilePath : string.Empty; } -} +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/ListTestsArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/ListTestsArgumentProcessorTests.cs index 8c00ed0477..a13fb5ba5b 100644 --- a/test/vstest.console.UnitTests/Processors/ListTestsArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/ListTestsArgumentProcessorTests.cs @@ -1,283 +1,290 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Versioning; +using System.Threading.Tasks; + +using CoreUtilities.Tracing.Interfaces; + +using Extensions.FileSystemGlobbing; +using Client; +using Client.RequestHelper; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using Publisher; +using CommandLineUtilities; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using ObjectModel.Engine; +using PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using TestTools.UnitTesting; + +using Moq; + +using ObjectModel; +using ObjectModel.Client; + +using TestPlatform.Utilities; + +using TestPlatformHelpers; + +using vstest.console.Internal; +using vstest.console.UnitTests.Processors; + +// +// Tests for ListTestsArgumentProcessor +// +[TestClass] +public class ListTestsArgumentProcessorTests { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Runtime.Versioning; - using System.Threading.Tasks; - - using CoreUtilities.Tracing.Interfaces; - using Microsoft.Extensions.FileSystemGlobbing; - using Microsoft.VisualStudio.TestPlatform.Client; - using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Publisher; - using Microsoft.VisualStudio.TestPlatform.CommandLineUtilities; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using ObjectModel; - using ObjectModel.Client; - using TestPlatform.Utilities; - using TestPlatformHelpers; - using vstest.console.Internal; - using vstest.console.UnitTests.Processors; - - // - // Tests for ListTestsArgumentProcessor - // - [TestClass] - public class ListTestsArgumentProcessorTests + private readonly Mock _mockFileHelper; + private readonly Mock _mockAssemblyMetadataProvider; + private readonly InferHelper _inferHelper; + private readonly string _dummyTestFilePath = "DummyTest.dll"; + private readonly Mock _mockTestPlatformEventSource; + private readonly Task _mockMetricsPublisherTask; + private readonly Mock _mockMetricsPublisher; + private readonly Mock _mockProcessHelper; + private readonly Mock _mockAttachmentsProcessingManager; + + private static ListTestsArgumentExecutor GetExecutor(ITestRequestManager testRequestManager, IOutput output) { - private readonly Mock mockFileHelper; - private Mock mockAssemblyMetadataProvider; - private InferHelper inferHelper; - private string dummyTestFilePath = "DummyTest.dll"; - private readonly Mock mockTestPlatformEventSource; - private Task mockMetricsPublisherTask; - private Mock mockMetricsPublisher; - private Mock mockProcessHelper; - private Mock mockAttachmentsProcessingManager; - - private static ListTestsArgumentExecutor GetExecutor(ITestRequestManager testRequestManager, IOutput output) - { - var runSettingsProvider = new TestableRunSettingsProvider(); - - runSettingsProvider.AddDefaultRunSettings(); - var listTestsArgumentExecutor = - new ListTestsArgumentExecutor( - CommandLineOptions.Instance, - runSettingsProvider, - testRequestManager, - output ?? ConsoleOutput.Instance); - return listTestsArgumentExecutor; - } - - [TestCleanup] - public void Cleanup() - { - CommandLineOptions.Instance.Reset(); - } + var runSettingsProvider = new TestableRunSettingsProvider(); + + runSettingsProvider.AddDefaultRunSettings(); + var listTestsArgumentExecutor = + new ListTestsArgumentExecutor( + CommandLineOptions.Instance, + runSettingsProvider, + testRequestManager, + output ?? ConsoleOutput.Instance); + return listTestsArgumentExecutor; + } - public ListTestsArgumentProcessorTests() - { - this.mockFileHelper = new Mock(); - this.mockFileHelper.Setup(fh => fh.Exists(this.dummyTestFilePath)).Returns(true); - this.mockFileHelper.Setup(x => x.GetCurrentDirectory()).Returns(""); - this.mockMetricsPublisher = new Mock(); - this.mockMetricsPublisherTask = Task.FromResult(this.mockMetricsPublisher.Object); - this.mockTestPlatformEventSource = new Mock(); - this.mockAssemblyMetadataProvider = new Mock(); - this.mockAssemblyMetadataProvider.Setup(x => x.GetArchitecture(It.IsAny())).Returns(Architecture.X64); - this.mockAssemblyMetadataProvider.Setup(x => x.GetFrameWork(It.IsAny())).Returns(new FrameworkName(Constants.DotNetFramework40)); - this.inferHelper = new InferHelper(this.mockAssemblyMetadataProvider.Object); - this.mockProcessHelper = new Mock(); - this.mockAttachmentsProcessingManager = new Mock(); - } - - /// - /// The help argument processor get metadata should return help argument processor capabilities. - /// - [TestMethod] - public void GetMetadataShouldReturnListTestsArgumentProcessorCapabilities() - { - var processor = new ListTestsArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is ListTestsArgumentProcessorCapabilities); - } - - /// - /// The help argument processor get executer should return help argument processor capabilities. - /// - [TestMethod] - public void GetExecuterShouldReturnListTestsArgumentProcessorCapabilities() - { - var processor = new ListTestsArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is ListTestsArgumentExecutor); - } + [TestCleanup] + public void Cleanup() + { + CommandLineOptions.Instance.Reset(); + } - #region ListTestsArgumentProcessorCapabilitiesTests + public ListTestsArgumentProcessorTests() + { + _mockFileHelper = new Mock(); + _mockFileHelper.Setup(fh => fh.Exists(_dummyTestFilePath)).Returns(true); + _mockFileHelper.Setup(x => x.GetCurrentDirectory()).Returns(""); + _mockMetricsPublisher = new Mock(); + _mockMetricsPublisherTask = Task.FromResult(_mockMetricsPublisher.Object); + _mockTestPlatformEventSource = new Mock(); + _mockAssemblyMetadataProvider = new Mock(); + _mockAssemblyMetadataProvider.Setup(x => x.GetArchitecture(It.IsAny())).Returns(Architecture.X64); + _mockAssemblyMetadataProvider.Setup(x => x.GetFrameWork(It.IsAny())).Returns(new FrameworkName(Constants.DotNetFramework40)); + _inferHelper = new InferHelper(_mockAssemblyMetadataProvider.Object); + _mockProcessHelper = new Mock(); + _mockAttachmentsProcessingManager = new Mock(); + } - [TestMethod] - public void CapabilitiesShouldReturnAppropriateProperties() - { - var capabilities = new ListTestsArgumentProcessorCapabilities(); - Assert.AreEqual("/ListTests", capabilities.CommandName); - Assert.AreEqual("/lt", capabilities.ShortCommandName); - var expected = "-lt|--ListTests|/lt|/ListTests:\r\n Lists all discovered tests from the given test container."; - Assert.AreEqual(expected.NormalizeLineEndings().ShowWhiteSpace(), capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); - - Assert.AreEqual(HelpContentPriority.ListTestsArgumentProcessorHelpPriority, capabilities.HelpPriority); - Assert.IsTrue(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.Normal, capabilities.Priority); - - Assert.IsFalse(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); - } - #endregion - - #region ListTestsArgumentExecutorTests - - [TestMethod] - public void ExecutorInitializeWithValidSourceShouldAddItToTestSources() - { - CommandLineOptions.Instance.FileHelper = this.mockFileHelper.Object; - CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, this.mockFileHelper.Object); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager, null); + /// + /// The help argument processor get metadata should return help argument processor capabilities. + /// + [TestMethod] + public void GetMetadataShouldReturnListTestsArgumentProcessorCapabilities() + { + var processor = new ListTestsArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is ListTestsArgumentProcessorCapabilities); + } - executor.Initialize(this.dummyTestFilePath); + /// + /// The help argument processor get executer should return help argument processor capabilities. + /// + [TestMethod] + public void GetExecuterShouldReturnListTestsArgumentProcessorCapabilities() + { + var processor = new ListTestsArgumentProcessor(); + Assert.IsTrue(processor.Executor.Value is ListTestsArgumentExecutor); + } - Assert.IsTrue(Enumerable.Contains(CommandLineOptions.Instance.Sources, this.dummyTestFilePath)); - } + #region ListTestsArgumentProcessorCapabilitiesTests - [TestMethod] - public void ExecutorExecuteForNoSourcesShouldReturnFail() - { - CommandLineOptions.Instance.Reset(); + [TestMethod] + public void CapabilitiesShouldReturnAppropriateProperties() + { + var capabilities = new ListTestsArgumentProcessorCapabilities(); + Assert.AreEqual("/ListTests", capabilities.CommandName); + Assert.AreEqual("/lt", capabilities.ShortCommandName); + var expected = "-lt|--ListTests|/lt|/ListTests:\r\n Lists all discovered tests from the given test container."; + Assert.AreEqual(expected.NormalizeLineEndings().ShowWhiteSpace(), capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); + + Assert.AreEqual(HelpContentPriority.ListTestsArgumentProcessorHelpPriority, capabilities.HelpPriority); + Assert.IsTrue(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.Normal, capabilities.Priority); + + Assert.IsFalse(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } + #endregion - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager, null); + #region ListTestsArgumentExecutorTests - Assert.ThrowsException(() => executor.Execute()); - } + [TestMethod] + public void ExecutorInitializeWithValidSourceShouldAddItToTestSources() + { + CommandLineOptions.Instance.FileHelper = _mockFileHelper.Object; + CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, _mockFileHelper.Object); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager, null); - [TestMethod] - public void ExecutorExecuteShouldThrowTestPlatformException() - { - var mockTestPlatform = new Mock(); - var mockDiscoveryRequest = new Mock(); + executor.Initialize(_dummyTestFilePath); + + Assert.IsTrue(Enumerable.Contains(CommandLineOptions.Instance.Sources, _dummyTestFilePath)); + } - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new TestPlatformException("DummyTestPlatformException")); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + [TestMethod] + public void ExecutorExecuteForNoSourcesShouldReturnFail() + { + CommandLineOptions.Instance.Reset(); - this.ResetAndAddSourceToCommandLineOptions(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager, null); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager, null); + Assert.ThrowsException(() => executor.Execute()); + } - Assert.ThrowsException(() => executor.Execute()); - } + [TestMethod] + public void ExecutorExecuteShouldThrowTestPlatformException() + { + var mockTestPlatform = new Mock(); + var mockDiscoveryRequest = new Mock(); - [TestMethod] - public void ExecutorExecuteShouldThrowSettingsException() - { - var mockTestPlatform = new Mock(); - var mockDiscoveryRequest = new Mock(); + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new TestPlatformException("DummyTestPlatformException")); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new SettingsException("DummySettingsException")); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + ResetAndAddSourceToCommandLineOptions(); - this.ResetAndAddSourceToCommandLineOptions(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager, null); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var listTestsArgumentExecutor = GetExecutor(testRequestManager, null); + Assert.ThrowsException(() => executor.Execute()); + } - Assert.ThrowsException(() => listTestsArgumentExecutor.Execute()); - } + [TestMethod] + public void ExecutorExecuteShouldThrowSettingsException() + { + var mockTestPlatform = new Mock(); + var mockDiscoveryRequest = new Mock(); - [TestMethod] - public void ExecutorExecuteShouldThrowInvalidOperationException() - { - var mockTestPlatform = new Mock(); - var mockDiscoveryRequest = new Mock(); + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new SettingsException("DummySettingsException")); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new InvalidOperationException("DummyInvalidOperationException")); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + ResetAndAddSourceToCommandLineOptions(); - this.ResetAndAddSourceToCommandLineOptions(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var listTestsArgumentExecutor = GetExecutor(testRequestManager, null); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var listTestsArgumentExecutor = GetExecutor(testRequestManager, null); + Assert.ThrowsException(() => listTestsArgumentExecutor.Execute()); + } - Assert.ThrowsException(() => listTestsArgumentExecutor.Execute()); - } + [TestMethod] + public void ExecutorExecuteShouldThrowInvalidOperationException() + { + var mockTestPlatform = new Mock(); + var mockDiscoveryRequest = new Mock(); - [TestMethod] - public void ExecutorExecuteShouldThrowOtherExceptions() - { - var mockTestPlatform = new Mock(); - var mockDiscoveryRequest = new Mock(); + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new InvalidOperationException("DummyInvalidOperationException")); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new Exception("DummyException")); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + ResetAndAddSourceToCommandLineOptions(); - this.ResetAndAddSourceToCommandLineOptions(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var listTestsArgumentExecutor = GetExecutor(testRequestManager, null); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager, null); + Assert.ThrowsException(() => listTestsArgumentExecutor.Execute()); + } - Assert.ThrowsException(() => executor.Execute()); - } + [TestMethod] + public void ExecutorExecuteShouldThrowOtherExceptions() + { + var mockTestPlatform = new Mock(); + var mockDiscoveryRequest = new Mock(); - [TestMethod] - public void ExecutorExecuteShouldOutputDiscoveredTestsAndReturnSuccess() - { - var mockDiscoveryRequest = new Mock(); - var mockConsoleOutput = new Mock(); + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new Exception("DummyException")); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - this.RunListTestArgumentProcessorExecuteWithMockSetup(mockDiscoveryRequest, mockConsoleOutput); + ResetAndAddSourceToCommandLineOptions(); - // Assert - mockDiscoveryRequest.Verify(dr => dr.DiscoverAsync(), Times.Once); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager, null); - mockConsoleOutput.Verify((IOutput co) => co.WriteLine(" Test1", OutputLevel.Information)); - mockConsoleOutput.Verify((IOutput co) => co.WriteLine(" Test2", OutputLevel.Information)); - } + Assert.ThrowsException(() => executor.Execute()); + } - [TestMethod] - public void ListTestArgumentProcessorExecuteShouldInstrumentDiscoveryRequestStart() - { - var mockDiscoveryRequest = new Mock(); - var mockConsoleOutput = new Mock(); + [TestMethod] + public void ExecutorExecuteShouldOutputDiscoveredTestsAndReturnSuccess() + { + var mockDiscoveryRequest = new Mock(); + var mockConsoleOutput = new Mock(); - this.RunListTestArgumentProcessorExecuteWithMockSetup(mockDiscoveryRequest, mockConsoleOutput); + RunListTestArgumentProcessorExecuteWithMockSetup(mockDiscoveryRequest, mockConsoleOutput); - this.mockTestPlatformEventSource.Verify(x => x.DiscoveryRequestStart(), Times.Once); - } + // Assert + mockDiscoveryRequest.Verify(dr => dr.DiscoverAsync(), Times.Once); - [TestMethod] - public void ListTestArgumentProcessorExecuteShouldInstrumentDiscoveryRequestStop() - { - var mockDiscoveryRequest = new Mock(); - var mockConsoleOutput = new Mock(); + mockConsoleOutput.Verify((IOutput co) => co.WriteLine(" Test1", OutputLevel.Information)); + mockConsoleOutput.Verify((IOutput co) => co.WriteLine(" Test2", OutputLevel.Information)); + } + + [TestMethod] + public void ListTestArgumentProcessorExecuteShouldInstrumentDiscoveryRequestStart() + { + var mockDiscoveryRequest = new Mock(); + var mockConsoleOutput = new Mock(); + + RunListTestArgumentProcessorExecuteWithMockSetup(mockDiscoveryRequest, mockConsoleOutput); - this.RunListTestArgumentProcessorExecuteWithMockSetup(mockDiscoveryRequest, mockConsoleOutput); + _mockTestPlatformEventSource.Verify(x => x.DiscoveryRequestStart(), Times.Once); + } - this.mockTestPlatformEventSource.Verify(x => x.DiscoveryRequestStop(), Times.Once); - } - #endregion + [TestMethod] + public void ListTestArgumentProcessorExecuteShouldInstrumentDiscoveryRequestStop() + { + var mockDiscoveryRequest = new Mock(); + var mockConsoleOutput = new Mock(); - private void RunListTestArgumentProcessorExecuteWithMockSetup(Mock mockDiscoveryRequest, Mock mockConsoleOutput) + RunListTestArgumentProcessorExecuteWithMockSetup(mockDiscoveryRequest, mockConsoleOutput); + + _mockTestPlatformEventSource.Verify(x => x.DiscoveryRequestStop(), Times.Once); + } + #endregion + + private void RunListTestArgumentProcessorExecuteWithMockSetup(Mock mockDiscoveryRequest, Mock mockConsoleOutput) + { + var mockTestPlatform = new Mock(); + var list = new List { - var mockTestPlatform = new Mock(); - var list = new List(); - list.Add(new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1")); - list.Add(new TestCase("Test2", new Uri("http://FooTestUri2"), "Source2")); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); + new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1"), + new TestCase("Test2", new Uri("http://FooTestUri2"), "Source2") + }; + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - this.ResetAndAddSourceToCommandLineOptions(); + ResetAndAddSourceToCommandLineOptions(); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - GetExecutor(testRequestManager, mockConsoleOutput.Object).Execute(); - } + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + GetExecutor(testRequestManager, mockConsoleOutput.Object).Execute(); + } - private void ResetAndAddSourceToCommandLineOptions() - { - CommandLineOptions.Instance.Reset(); + private void ResetAndAddSourceToCommandLineOptions() + { + CommandLineOptions.Instance.Reset(); - CommandLineOptions.Instance.FileHelper = this.mockFileHelper.Object; - CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, this.mockFileHelper.Object); - CommandLineOptions.Instance.AddSource(this.dummyTestFilePath); - } + CommandLineOptions.Instance.FileHelper = _mockFileHelper.Object; + CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, _mockFileHelper.Object); + CommandLineOptions.Instance.AddSource(_dummyTestFilePath); } -} +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/ListTestsTargetPathArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/ListTestsTargetPathArgumentProcessorTests.cs index 272aa54763..f59f1961d5 100644 --- a/test/vstest.console.UnitTests/Processors/ListTestsTargetPathArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/ListTestsTargetPathArgumentProcessorTests.cs @@ -1,82 +1,81 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +using System; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using TestTools.UnitTesting; - using TestPlatform.CommandLine.Processors; +using TestPlatform.CommandLine.Processors; - [TestClass] - public class ListTestsTargetPathArgumentProcessorTests +[TestClass] +public class ListTestsTargetPathArgumentProcessorTests +{ + [TestMethod] + public void GetMetadataShouldReturnListTestsTargetPathArgumentProcessorCapabilities() { - [TestMethod] - public void GetMetadataShouldReturnListTestsTargetPathArgumentProcessorCapabilities() - { - ListTestsTargetPathArgumentProcessor processor = new ListTestsTargetPathArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is ListTestsTargetPathArgumentProcessorCapabilities); - } + ListTestsTargetPathArgumentProcessor processor = new(); + Assert.IsTrue(processor.Metadata.Value is ListTestsTargetPathArgumentProcessorCapabilities); + } - [TestMethod] - public void GetExecutorShouldReturnListTestsTargetPathArgumentProcessorCapabilities() - { - ListTestsTargetPathArgumentProcessor processor = new ListTestsTargetPathArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is ListTestsTargetPathArgumentExecutor); - } + [TestMethod] + public void GetExecutorShouldReturnListTestsTargetPathArgumentProcessorCapabilities() + { + ListTestsTargetPathArgumentProcessor processor = new(); + Assert.IsTrue(processor.Executor.Value is ListTestsTargetPathArgumentExecutor); + } - #region TestCaseFilterArgumentProcessorCapabilitiesTests + #region TestCaseFilterArgumentProcessorCapabilitiesTests - [TestMethod] - public void CapabilitiesShouldAppropriateProperties() - { - ListTestsTargetPathArgumentProcessorCapabilities capabilities = new ListTestsTargetPathArgumentProcessorCapabilities(); - Assert.AreEqual("/ListTestsTargetPath", capabilities.CommandName); + [TestMethod] + public void CapabilitiesShouldAppropriateProperties() + { + ListTestsTargetPathArgumentProcessorCapabilities capabilities = new(); + Assert.AreEqual("/ListTestsTargetPath", capabilities.CommandName); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.Normal, capabilities.Priority); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.Normal, capabilities.Priority); - Assert.IsFalse(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); - } + Assert.IsFalse(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } - #endregion + #endregion - [TestMethod] - public void ExecutorInitializeWithNullOrEmptyListTestsTargetPathShouldThrowCommandLineException() - { - var options = CommandLineOptions.Instance; - ListTestsTargetPathArgumentExecutor executor = new ListTestsTargetPathArgumentExecutor(options); - - try - { - executor.Initialize(null); - } - catch (Exception ex) - { - Assert.IsTrue(ex is CommandLineException); - StringAssert.Contains(ex.Message, "ListTestsTargetPath is required with ListFullyQualifiedTests!"); - } - } + [TestMethod] + public void ExecutorInitializeWithNullOrEmptyListTestsTargetPathShouldThrowCommandLineException() + { + var options = CommandLineOptions.Instance; + ListTestsTargetPathArgumentExecutor executor = new(options); - [TestMethod] - public void ExecutorInitializeWithValidListTestsTargetPathShouldAddListTestsTargetPathToCommandLineOptions() + try { - var options = CommandLineOptions.Instance; - ListTestsTargetPathArgumentExecutor executor = new ListTestsTargetPathArgumentExecutor(options); - - executor.Initialize(@"C:\sample.txt"); - Assert.AreEqual(@"C:\sample.txt", options.ListTestsTargetPath); + executor.Initialize(null); } - - [TestMethod] - public void ExecutorListTestsTargetPathArgumentProcessorResultSuccess() + catch (Exception ex) { - var executor = new ListTestsTargetPathArgumentExecutor(CommandLineOptions.Instance); - var result = executor.Execute(); - Assert.AreEqual(ArgumentProcessorResult.Success, result); + Assert.IsTrue(ex is CommandLineException); + StringAssert.Contains(ex.Message, "ListTestsTargetPath is required with ListFullyQualifiedTests!"); } } -} + + [TestMethod] + public void ExecutorInitializeWithValidListTestsTargetPathShouldAddListTestsTargetPathToCommandLineOptions() + { + var options = CommandLineOptions.Instance; + ListTestsTargetPathArgumentExecutor executor = new(options); + + executor.Initialize(@"C:\sample.txt"); + Assert.AreEqual(@"C:\sample.txt", options.ListTestsTargetPath); + } + + [TestMethod] + public void ExecutorListTestsTargetPathArgumentProcessorResultSuccess() + { + var executor = new ListTestsTargetPathArgumentExecutor(CommandLineOptions.Instance); + var result = executor.Execute(); + Assert.AreEqual(ArgumentProcessorResult.Success, result); + } +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/ParallelArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/ParallelArgumentProcessorTests.cs index e6d9147018..63d6221db3 100644 --- a/test/vstest.console.UnitTests/Processors/ParallelArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/ParallelArgumentProcessorTests.cs @@ -1,99 +1,97 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +using TestTools.UnitTesting; +using TestPlatform.CommandLine.Processors; +using vstest.console.UnitTests.Processors; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; + +using ExceptionUtilities = ExceptionUtilities; + +[TestClass] +public class ParallelArgumentProcessorTests { - using Microsoft.VisualStudio.TestTools.UnitTesting; - using TestPlatform.CommandLine.Processors; - using vstest.console.UnitTests.Processors; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; + private ParallelArgumentExecutor _executor; + private TestableRunSettingsProvider _runSettingsProvider; - using ExceptionUtilities = Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.ExceptionUtilities; - using System; + [TestInitialize] + public void Init() + { + _runSettingsProvider = new TestableRunSettingsProvider(); + _executor = new ParallelArgumentExecutor(CommandLineOptions.Instance, _runSettingsProvider); + } + [TestCleanup] + public void TestCleanup() + { + CommandLineOptions.Instance.Reset(); + } - [TestClass] - public class ParallelArgumentProcessorTests + [TestMethod] + public void GetMetadataShouldReturnParallelArgumentProcessorCapabilities() { - private ParallelArgumentExecutor executor; - private TestableRunSettingsProvider runSettingsProvider; - - [TestInitialize] - public void Init() - { - this.runSettingsProvider = new TestableRunSettingsProvider(); - this.executor = new ParallelArgumentExecutor(CommandLineOptions.Instance, this.runSettingsProvider); - } - [TestCleanup] - public void TestCleanup() - { - CommandLineOptions.Instance.Reset(); - } - - [TestMethod] - public void GetMetadataShouldReturnParallelArgumentProcessorCapabilities() - { - var processor = new ParallelArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is ParallelArgumentProcessorCapabilities); - } - - [TestMethod] - public void GetExecuterShouldReturnParallelArgumentExecutor() - { - var processor = new ParallelArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is ParallelArgumentExecutor); - } - - #region ParallelArgumentProcessorCapabilities tests - - [TestMethod] - public void CapabilitiesShouldReturnAppropriateProperties() - { - var capabilities = new ParallelArgumentProcessorCapabilities(); - Assert.AreEqual("/Parallel", capabilities.CommandName); - var expected = "--Parallel|/Parallel\r\n Specifies that the tests be executed in parallel. By default up\r\n to all available cores on the machine may be used.\r\n The number of cores to use may be configured using a settings file."; - Assert.AreEqual(expected.NormalizeLineEndings().ShowWhiteSpace(), capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); - - Assert.AreEqual(HelpContentPriority.ParallelArgumentProcessorHelpPriority, capabilities.HelpPriority); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.AutoUpdateRunSettings, capabilities.Priority); - - Assert.IsFalse(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); - } - - #endregion - - #region ParallelArgumentExecutor Initialize tests - - [TestMethod] - public void InitializeShouldThrowIfArgumentIsNonNull() - { - - // Parallel should not have any values or arguments - ExceptionUtilities.ThrowsException( - () => this.executor.Initialize("123"), - "Argument " + 123 + " is not expected in the 'Parallel' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /Parallel) and try again."); - } - - [TestMethod] - public void InitializeShouldSetParallelValue() - { - this.executor.Initialize(null); - Assert.IsTrue(CommandLineOptions.Instance.Parallel, "Parallel option must be set to true."); - Assert.AreEqual("0", this.runSettingsProvider.QueryRunSettingsNode(ParallelArgumentExecutor.RunSettingsPath)); - } - - #endregion - - #region ParallelArgumentExecutor Execute tests - - [TestMethod] - public void ExecuteShouldReturnSuccess() - { - Assert.AreEqual(ArgumentProcessorResult.Success, this.executor.Execute()); - } - - #endregion + var processor = new ParallelArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is ParallelArgumentProcessorCapabilities); } -} + + [TestMethod] + public void GetExecuterShouldReturnParallelArgumentExecutor() + { + var processor = new ParallelArgumentProcessor(); + Assert.IsTrue(processor.Executor.Value is ParallelArgumentExecutor); + } + + #region ParallelArgumentProcessorCapabilities tests + + [TestMethod] + public void CapabilitiesShouldReturnAppropriateProperties() + { + var capabilities = new ParallelArgumentProcessorCapabilities(); + Assert.AreEqual("/Parallel", capabilities.CommandName); + var expected = "--Parallel|/Parallel\r\n Specifies that the tests be executed in parallel. By default up\r\n to all available cores on the machine may be used.\r\n The number of cores to use may be configured using a settings file."; + Assert.AreEqual(expected.NormalizeLineEndings().ShowWhiteSpace(), capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); + + Assert.AreEqual(HelpContentPriority.ParallelArgumentProcessorHelpPriority, capabilities.HelpPriority); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.AutoUpdateRunSettings, capabilities.Priority); + + Assert.IsFalse(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } + + #endregion + + #region ParallelArgumentExecutor Initialize tests + + [TestMethod] + public void InitializeShouldThrowIfArgumentIsNonNull() + { + + // Parallel should not have any values or arguments + ExceptionUtilities.ThrowsException( + () => _executor.Initialize("123"), + "Argument " + 123 + " is not expected in the 'Parallel' command. Specify the command without the argument (Example: vstest.console.exe myTests.dll /Parallel) and try again."); + } + + [TestMethod] + public void InitializeShouldSetParallelValue() + { + _executor.Initialize(null); + Assert.IsTrue(CommandLineOptions.Instance.Parallel, "Parallel option must be set to true."); + Assert.AreEqual("0", _runSettingsProvider.QueryRunSettingsNode(ParallelArgumentExecutor.RunSettingsPath)); + } + + #endregion + + #region ParallelArgumentExecutor Execute tests + + [TestMethod] + public void ExecuteShouldReturnSuccess() + { + Assert.AreEqual(ArgumentProcessorResult.Success, _executor.Execute()); + } + + #endregion +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/ParentProcessIdArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/ParentProcessIdArgumentProcessorTests.cs index a8bb3f1e7d..9b916a9a16 100644 --- a/test/vstest.console.UnitTests/Processors/ParentProcessIdArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/ParentProcessIdArgumentProcessorTests.cs @@ -3,103 +3,103 @@ using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; using Microsoft.VisualStudio.TestTools.UnitTesting; + using System; -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +[TestClass] +public class ParentProcessIdArgumentProcessorTests { - [TestClass] - public class ParentProcessIdArgumentProcessorTests + [TestMethod] + public void GetMetadataShouldReturnParentProcessIdArgumentProcessorCapabilities() { - [TestMethod] - public void GetMetadataShouldReturnParentProcessIdArgumentProcessorCapabilities() - { - var processor = new ParentProcessIdArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is ParentProcessIdArgumentProcessorCapabilities); - } + var processor = new ParentProcessIdArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is ParentProcessIdArgumentProcessorCapabilities); + } - [TestMethod] - public void GetExecutorShouldReturnParentProcessIdArgumentProcessorCapabilities() - { - var processor = new ParentProcessIdArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is ParentProcessIdArgumentExecutor); - } + [TestMethod] + public void GetExecutorShouldReturnParentProcessIdArgumentProcessorCapabilities() + { + var processor = new ParentProcessIdArgumentProcessor(); + Assert.IsTrue(processor.Executor.Value is ParentProcessIdArgumentExecutor); + } - [TestMethod] - public void CapabilitiesShouldHaveHigherPriorityThanPortCapabilities() - { - var parentProcessIdCapabilities = new ParentProcessIdArgumentProcessorCapabilities(); - var portCapabilities = new PortArgumentProcessorCapabilities(); + [TestMethod] + public void CapabilitiesShouldHaveHigherPriorityThanPortCapabilities() + { + var parentProcessIdCapabilities = new ParentProcessIdArgumentProcessorCapabilities(); + var portCapabilities = new PortArgumentProcessorCapabilities(); - // Less the number, high the priority - Assert.IsTrue(parentProcessIdCapabilities.Priority == portCapabilities.Priority, "ParentProcessId must have higher priority than Port."); - } + // Less the number, high the priority + Assert.IsTrue(parentProcessIdCapabilities.Priority == portCapabilities.Priority, "ParentProcessId must have higher priority than Port."); + } + + [TestMethod] + public void CapabilitiesShouldReturnAppropriateProperties() + { + var capabilities = new ParentProcessIdArgumentProcessorCapabilities(); + Assert.AreEqual("/ParentProcessId", capabilities.CommandName); + var expected = "--ParentProcessId|/ParentProcessId:\r\n Process Id of the Parent Process responsible for launching current process."; + Assert.AreEqual(expected.NormalizeLineEndings().ShowWhiteSpace(), capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); - [TestMethod] - public void CapabilitiesShouldReturnAppropriateProperties() + Assert.AreEqual(HelpContentPriority.ParentProcessIdArgumentProcessorHelpPriority, capabilities.HelpPriority); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.DesignMode, capabilities.Priority); + + Assert.IsFalse(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } + + [TestMethod] + public void ExecutorInitializeWithNullOrEmptyParentProcessIdShouldThrowCommandLineException() + { + var executor = new ParentProcessIdArgumentExecutor(CommandLineOptions.Instance); + try { - var capabilities = new ParentProcessIdArgumentProcessorCapabilities(); - Assert.AreEqual("/ParentProcessId", capabilities.CommandName); - var expected = "--ParentProcessId|/ParentProcessId:\r\n Process Id of the Parent Process responsible for launching current process."; - Assert.AreEqual(expected.NormalizeLineEndings().ShowWhiteSpace(), capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); - - Assert.AreEqual(HelpContentPriority.ParentProcessIdArgumentProcessorHelpPriority, capabilities.HelpPriority); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.DesignMode, capabilities.Priority); - - Assert.IsFalse(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); + executor.Initialize(null); } - - [TestMethod] - public void ExecutorInitializeWithNullOrEmptyParentProcessIdShouldThrowCommandLineException() + catch (Exception ex) { - var executor = new ParentProcessIdArgumentExecutor(CommandLineOptions.Instance); - try - { - executor.Initialize(null); - } - catch (Exception ex) - { - Assert.IsTrue(ex is CommandLineException); - Assert.AreEqual("The --ParentProcessId|/ParentProcessId argument requires the process id which is an integer. Specify the process id of the parent process that launched this process.", ex.Message); - } + Assert.IsTrue(ex is CommandLineException); + Assert.AreEqual("The --ParentProcessId|/ParentProcessId argument requires the process id which is an integer. Specify the process id of the parent process that launched this process.", ex.Message); } + } - [TestMethod] - public void ExecutorInitializeWithInvalidParentProcessIdShouldThrowCommandLineException() + [TestMethod] + public void ExecutorInitializeWithInvalidParentProcessIdShouldThrowCommandLineException() + { + var executor = new ParentProcessIdArgumentExecutor(CommandLineOptions.Instance); + try { - var executor = new ParentProcessIdArgumentExecutor(CommandLineOptions.Instance); - try - { - executor.Initialize("Foo"); - } - catch (Exception ex) - { - Assert.IsTrue(ex is CommandLineException); - Assert.AreEqual("The --ParentProcessId|/ParentProcessId argument requires the process id which is an integer. Specify the process id of the parent process that launched this process.", ex.Message); - } + executor.Initialize("Foo"); } - - [TestMethod] - public void ExecutorInitializeWithValidPortShouldAddParentProcessIdToCommandLineOptions() + catch (Exception ex) { - var executor = new ParentProcessIdArgumentExecutor(CommandLineOptions.Instance); - int parentProcessId = 2345; - executor.Initialize(parentProcessId.ToString()); - Assert.AreEqual(parentProcessId, CommandLineOptions.Instance.ParentProcessId); + Assert.IsTrue(ex is CommandLineException); + Assert.AreEqual("The --ParentProcessId|/ParentProcessId argument requires the process id which is an integer. Specify the process id of the parent process that launched this process.", ex.Message); } + } - [TestMethod] - public void ExecutorExecuteReturnsArgumentProcessorResultSuccess() - { - var executor = new ParentProcessIdArgumentExecutor(CommandLineOptions.Instance); + [TestMethod] + public void ExecutorInitializeWithValidPortShouldAddParentProcessIdToCommandLineOptions() + { + var executor = new ParentProcessIdArgumentExecutor(CommandLineOptions.Instance); + int parentProcessId = 2345; + executor.Initialize(parentProcessId.ToString()); + Assert.AreEqual(parentProcessId, CommandLineOptions.Instance.ParentProcessId); + } - int parentProcessId = 2345; - executor.Initialize(parentProcessId.ToString()); - var result = executor.Execute(); + [TestMethod] + public void ExecutorExecuteReturnsArgumentProcessorResultSuccess() + { + var executor = new ParentProcessIdArgumentExecutor(CommandLineOptions.Instance); - Assert.AreEqual(ArgumentProcessorResult.Success, result); - } + int parentProcessId = 2345; + executor.Initialize(parentProcessId.ToString()); + var result = executor.Execute(); + + Assert.AreEqual(ArgumentProcessorResult.Success, result); } -} +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/PlatformArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/PlatformArgumentProcessorTests.cs index 84092f3741..317a7ff91b 100644 --- a/test/vstest.console.UnitTests/Processors/PlatformArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/PlatformArgumentProcessorTests.cs @@ -1,131 +1,129 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +using TestTools.UnitTesting; +using TestPlatform.CommandLine.Processors; +using vstest.console.UnitTests.Processors; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using ExceptionUtilities = ExceptionUtilities; + +[TestClass] +public class PlatformArgumentProcessorTests { - using Microsoft.VisualStudio.TestTools.UnitTesting; - using TestPlatform.CommandLine.Processors; - using vstest.console.UnitTests.Processors; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using ExceptionUtilities = Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.ExceptionUtilities; - using System; - - [TestClass] - public class PlatformArgumentProcessorTests + private PlatformArgumentExecutor _executor; + private TestableRunSettingsProvider _runSettingsProvider; + + [TestInitialize] + public void Init() + { + _runSettingsProvider = new TestableRunSettingsProvider(); + _executor = new PlatformArgumentExecutor(CommandLineOptions.Instance, _runSettingsProvider); + } + + [TestCleanup] + public void TestCleanup() + { + CommandLineOptions.Instance.Reset(); + } + + [TestMethod] + public void GetMetadataShouldReturnPlatformArgumentProcessorCapabilities() + { + var processor = new PlatformArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is PlatformArgumentProcessorCapabilities); + } + + [TestMethod] + public void GetExecuterShouldReturnPlatformArgumentExecutor() + { + var processor = new PlatformArgumentProcessor(); + Assert.IsTrue(processor.Executor.Value is PlatformArgumentExecutor); + } + + #region PlatformArgumentProcessorCapabilities tests + + [TestMethod] + public void CapabilitiesShouldReturnAppropriateProperties() + { + var capabilities = new PlatformArgumentProcessorCapabilities(); + Assert.AreEqual("/Platform", capabilities.CommandName); + var expected = "--Platform|/Platform:\r\n Target platform architecture to be used for test execution. \r\n Valid values are x86, x64 and ARM."; + Assert.AreEqual(expected: expected.NormalizeLineEndings().ShowWhiteSpace(), capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); + + Assert.AreEqual(HelpContentPriority.PlatformArgumentProcessorHelpPriority, capabilities.HelpPriority); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.AutoUpdateRunSettings, capabilities.Priority); + + Assert.IsFalse(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } + + #endregion + + #region PlatformArgumentExecutor Initialize tests + + [TestMethod] + public void InitializeShouldThrowIfArgumentIsNull() { - private PlatformArgumentExecutor executor; - private TestableRunSettingsProvider runSettingsProvider; - - [TestInitialize] - public void Init() - { - this.runSettingsProvider = new TestableRunSettingsProvider(); - this.executor = new PlatformArgumentExecutor(CommandLineOptions.Instance, runSettingsProvider); - } - - [TestCleanup] - public void TestCleanup() - { - CommandLineOptions.Instance.Reset(); - } - - [TestMethod] - public void GetMetadataShouldReturnPlatformArgumentProcessorCapabilities() - { - var processor = new PlatformArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is PlatformArgumentProcessorCapabilities); - } - - [TestMethod] - public void GetExecuterShouldReturnPlatformArgumentExecutor() - { - var processor = new PlatformArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is PlatformArgumentExecutor); - } - - #region PlatformArgumentProcessorCapabilities tests - - [TestMethod] - public void CapabilitiesShouldReturnAppropriateProperties() - { - var capabilities = new PlatformArgumentProcessorCapabilities(); - Assert.AreEqual("/Platform", capabilities.CommandName); - var expected = "--Platform|/Platform:\r\n Target platform architecture to be used for test execution. \r\n Valid values are x86, x64 and ARM."; - Assert.AreEqual(expected: expected.NormalizeLineEndings().ShowWhiteSpace(), capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); - - Assert.AreEqual(HelpContentPriority.PlatformArgumentProcessorHelpPriority, capabilities.HelpPriority); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.AutoUpdateRunSettings, capabilities.Priority); - - Assert.IsFalse(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); - } - - #endregion - - #region PlatformArgumentExecutor Initialize tests - - [TestMethod] - public void InitializeShouldThrowIfArgumentIsNull() - { - ExceptionUtilities.ThrowsException( - () => this.executor.Initialize(null), - "The /Platform argument requires the target platform type for the test run to be provided. Example: /Platform:x86"); - } - - [TestMethod] - public void InitializeShouldThrowIfArgumentIsEmpty() - { - ExceptionUtilities.ThrowsException( - () => this.executor.Initialize(" "), - "The /Platform argument requires the target platform type for the test run to be provided. Example: /Platform:x86"); - } - - [TestMethod] - public void InitializeShouldThrowIfArgumentIsNotAnArchitecture() - { - ExceptionUtilities.ThrowsException( - () => this.executor.Initialize("foo"), - "Invalid platform type: {0}. Valid platform types are X86, X64, ARM, ARM64.", - "foo"); - } - - [TestMethod] - public void InitializeShouldThrowIfArgumentIsNotASupportedArchitecture() - { - ExceptionUtilities.ThrowsException( - () => this.executor.Initialize("AnyCPU"), - "Invalid platform type: {0}. Valid platform types are X86, X64, ARM, ARM64.", - "AnyCPU"); - } - - [TestMethod] - public void InitializeShouldSetCommandLineOptionsArchitecture() - { - this.executor.Initialize("x64"); - Assert.AreEqual(ObjectModel.Architecture.X64, CommandLineOptions.Instance.TargetArchitecture); - Assert.AreEqual(nameof(ObjectModel.Architecture.X64), this.runSettingsProvider.QueryRunSettingsNode(PlatformArgumentExecutor.RunSettingsPath)); - } - - [TestMethod] - public void InitializeShouldNotConsiderCaseSensitivityOfTheArgumentPassed() - { - executor.Initialize("ArM"); - Assert.AreEqual(ObjectModel.Architecture.ARM, CommandLineOptions.Instance.TargetArchitecture); - Assert.AreEqual(nameof(ObjectModel.Architecture.ARM), this.runSettingsProvider.QueryRunSettingsNode(PlatformArgumentExecutor.RunSettingsPath)); - } - - #endregion - - #region PlatformArgumentExecutor Execute tests - - [TestMethod] - public void ExecuteShouldReturnSuccess() - { - Assert.AreEqual(ArgumentProcessorResult.Success, this.executor.Execute()); - } - - #endregion + ExceptionUtilities.ThrowsException( + () => _executor.Initialize(null), + "The /Platform argument requires the target platform type for the test run to be provided. Example: /Platform:x86"); } -} + + [TestMethod] + public void InitializeShouldThrowIfArgumentIsEmpty() + { + ExceptionUtilities.ThrowsException( + () => _executor.Initialize(" "), + "The /Platform argument requires the target platform type for the test run to be provided. Example: /Platform:x86"); + } + + [TestMethod] + public void InitializeShouldThrowIfArgumentIsNotAnArchitecture() + { + ExceptionUtilities.ThrowsException( + () => _executor.Initialize("foo"), + "Invalid platform type: {0}. Valid platform types are X86, X64, ARM, ARM64.", + "foo"); + } + + [TestMethod] + public void InitializeShouldThrowIfArgumentIsNotASupportedArchitecture() + { + ExceptionUtilities.ThrowsException( + () => _executor.Initialize("AnyCPU"), + "Invalid platform type: {0}. Valid platform types are X86, X64, ARM, ARM64.", + "AnyCPU"); + } + + [TestMethod] + public void InitializeShouldSetCommandLineOptionsArchitecture() + { + _executor.Initialize("x64"); + Assert.AreEqual(ObjectModel.Architecture.X64, CommandLineOptions.Instance.TargetArchitecture); + Assert.AreEqual(nameof(ObjectModel.Architecture.X64), _runSettingsProvider.QueryRunSettingsNode(PlatformArgumentExecutor.RunSettingsPath)); + } + + [TestMethod] + public void InitializeShouldNotConsiderCaseSensitivityOfTheArgumentPassed() + { + _executor.Initialize("ArM"); + Assert.AreEqual(ObjectModel.Architecture.ARM, CommandLineOptions.Instance.TargetArchitecture); + Assert.AreEqual(nameof(ObjectModel.Architecture.ARM), _runSettingsProvider.QueryRunSettingsNode(PlatformArgumentExecutor.RunSettingsPath)); + } + + #endregion + + #region PlatformArgumentExecutor Execute tests + + [TestMethod] + public void ExecuteShouldReturnSuccess() + { + Assert.AreEqual(ArgumentProcessorResult.Success, _executor.Execute()); + } + + #endregion +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/PortArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/PortArgumentProcessorTests.cs index 50181f7e6d..d73d115b9d 100644 --- a/test/vstest.console.UnitTests/Processors/PortArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/PortArgumentProcessorTests.cs @@ -1,192 +1,191 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +using Client.DesignMode; +using Client.RequestHelper; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using TestTools.UnitTesting; +using PlatformAbstractions.Interfaces; +using Moq; +using System; +using System.Diagnostics; + +[TestClass] +public class PortArgumentProcessorTests { - using Microsoft.VisualStudio.TestPlatform.Client.DesignMode; - using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Moq; - using System; - using System.Diagnostics; - - [TestClass] - public class PortArgumentProcessorTests - { - private Mock mockProcessHelper; - private Mock testDesignModeClient; - private Mock testRequestManager; - private PortArgumentExecutor executor; + private readonly Mock _mockProcessHelper; + private readonly Mock _testDesignModeClient; + private readonly Mock _testRequestManager; + private PortArgumentExecutor _executor; - public PortArgumentProcessorTests() - { - this.mockProcessHelper = new Mock(); - this.testDesignModeClient = new Mock(); - this.testRequestManager = new Mock(); - this.executor = new PortArgumentExecutor(CommandLineOptions.Instance, this.testRequestManager.Object); - } + public PortArgumentProcessorTests() + { + _mockProcessHelper = new Mock(); + _testDesignModeClient = new Mock(); + _testRequestManager = new Mock(); + _executor = new PortArgumentExecutor(CommandLineOptions.Instance, _testRequestManager.Object); + } - [TestMethod] - public void GetMetadataShouldReturnPortArgumentProcessorCapabilities() - { - var processor = new PortArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is PortArgumentProcessorCapabilities); - } + [TestMethod] + public void GetMetadataShouldReturnPortArgumentProcessorCapabilities() + { + var processor = new PortArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is PortArgumentProcessorCapabilities); + } - [TestMethod] - public void GetExecutorShouldReturnPortArgumentProcessorCapabilities() - { - var processor = new PortArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is PortArgumentExecutor); - } + [TestMethod] + public void GetExecutorShouldReturnPortArgumentProcessorCapabilities() + { + var processor = new PortArgumentProcessor(); + Assert.IsTrue(processor.Executor.Value is PortArgumentExecutor); + } - #region PortArgumentProcessorCapabilitiesTests + #region PortArgumentProcessorCapabilitiesTests - [TestMethod] - public void CapabilitiesShouldAppropriateProperties() - { - var capabilities = new PortArgumentProcessorCapabilities(); - Assert.AreEqual("/Port", capabilities.CommandName); - Assert.AreEqual("--Port|/Port:" + Environment.NewLine + " The Port for socket connection and receiving the event messages.", capabilities.HelpContentResourceName); + [TestMethod] + public void CapabilitiesShouldAppropriateProperties() + { + var capabilities = new PortArgumentProcessorCapabilities(); + Assert.AreEqual("/Port", capabilities.CommandName); + Assert.AreEqual("--Port|/Port:" + Environment.NewLine + " The Port for socket connection and receiving the event messages.", capabilities.HelpContentResourceName); - Assert.AreEqual(HelpContentPriority.PortArgumentProcessorHelpPriority, capabilities.HelpPriority); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.DesignMode, capabilities.Priority); + Assert.AreEqual(HelpContentPriority.PortArgumentProcessorHelpPriority, capabilities.HelpPriority); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.DesignMode, capabilities.Priority); - Assert.IsFalse(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); - } + Assert.IsFalse(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } - #endregion + #endregion - [TestMethod] - public void ExecutorInitializeWithNullOrEmptyPortShouldThrowCommandLineException() + [TestMethod] + public void ExecutorInitializeWithNullOrEmptyPortShouldThrowCommandLineException() + { + try { - try - { - executor.Initialize(null); - } - catch (Exception ex) - { - Assert.IsTrue(ex is CommandLineException); - Assert.AreEqual("The --Port|/Port argument requires the port number which is an integer. Specify the port for socket connection and receiving the event messages.", ex.Message); - } + _executor.Initialize(null); } - - [TestMethod] - public void ExecutorInitializeWithInvalidPortShouldThrowCommandLineException() + catch (Exception ex) { - try - { - this.executor.Initialize("Foo"); - } - catch (Exception ex) - { - Assert.IsTrue(ex is CommandLineException); - Assert.AreEqual("The --Port|/Port argument requires the port number which is an integer. Specify the port for socket connection and receiving the event messages.", ex.Message); - } + Assert.IsTrue(ex is CommandLineException); + Assert.AreEqual("The --Port|/Port argument requires the port number which is an integer. Specify the port for socket connection and receiving the event messages.", ex.Message); } + } - [TestMethod] - public void ExecutorInitializeWithValidPortShouldAddPortToCommandLineOptionsAndInitializeDesignModeManager() + [TestMethod] + public void ExecutorInitializeWithInvalidPortShouldThrowCommandLineException() + { + try { - int port = 2345; - CommandLineOptions.Instance.ParentProcessId = 0; + _executor.Initialize("Foo"); + } + catch (Exception ex) + { + Assert.IsTrue(ex is CommandLineException); + Assert.AreEqual("The --Port|/Port argument requires the port number which is an integer. Specify the port for socket connection and receiving the event messages.", ex.Message); + } + } - this.executor.Initialize(port.ToString()); + [TestMethod] + public void ExecutorInitializeWithValidPortShouldAddPortToCommandLineOptionsAndInitializeDesignModeManager() + { + int port = 2345; + CommandLineOptions.Instance.ParentProcessId = 0; - Assert.AreEqual(port, CommandLineOptions.Instance.Port); - Assert.IsNotNull(DesignModeClient.Instance); - } + _executor.Initialize(port.ToString()); - [TestMethod] - public void ExecutorInitializeShouldSetDesignMode() - { - int port = 2345; - CommandLineOptions.Instance.ParentProcessId = 0; + Assert.AreEqual(port, CommandLineOptions.Instance.Port); + Assert.IsNotNull(DesignModeClient.Instance); + } - this.executor.Initialize(port.ToString()); + [TestMethod] + public void ExecutorInitializeShouldSetDesignMode() + { + int port = 2345; + CommandLineOptions.Instance.ParentProcessId = 0; - Assert.IsTrue(CommandLineOptions.Instance.IsDesignMode); - } + _executor.Initialize(port.ToString()); - [TestMethod] - public void ExecutorInitializeShouldSetProcessExitCallback() - { - this.executor = new PortArgumentExecutor(CommandLineOptions.Instance, this.testRequestManager.Object, this.mockProcessHelper.Object); - int port = 2345; - int processId = Process.GetCurrentProcess().Id; - CommandLineOptions.Instance.ParentProcessId = processId; + Assert.IsTrue(CommandLineOptions.Instance.IsDesignMode); + } - this.executor.Initialize(port.ToString()); + [TestMethod] + public void ExecutorInitializeShouldSetProcessExitCallback() + { + _executor = new PortArgumentExecutor(CommandLineOptions.Instance, _testRequestManager.Object, _mockProcessHelper.Object); + int port = 2345; + int processId = Process.GetCurrentProcess().Id; + CommandLineOptions.Instance.ParentProcessId = processId; - this.mockProcessHelper.Verify(ph => ph.SetExitCallback(processId, It.IsAny>()), Times.Once); - } + _executor.Initialize(port.ToString()); - [TestMethod] - public void ExecutorExecuteForValidConnectionReturnsArgumentProcessorResultSuccess() - { - this.executor = new PortArgumentExecutor(CommandLineOptions.Instance, this.testRequestManager.Object, - (parentProcessId, ph) => this.testDesignModeClient.Object, this.mockProcessHelper.Object); + _mockProcessHelper.Verify(ph => ph.SetExitCallback(processId, It.IsAny>()), Times.Once); + } - int port = 2345; - this.executor.Initialize(port.ToString()); - var result = executor.Execute(); + [TestMethod] + public void ExecutorExecuteForValidConnectionReturnsArgumentProcessorResultSuccess() + { + _executor = new PortArgumentExecutor(CommandLineOptions.Instance, _testRequestManager.Object, + (parentProcessId, ph) => _testDesignModeClient.Object, _mockProcessHelper.Object); - this.testDesignModeClient.Verify(td => - td.ConnectToClientAndProcessRequests(port, this.testRequestManager.Object), Times.Once); + int port = 2345; + _executor.Initialize(port.ToString()); + var result = _executor.Execute(); - Assert.AreEqual(ArgumentProcessorResult.Success, result); - } + _testDesignModeClient.Verify(td => + td.ConnectToClientAndProcessRequests(port, _testRequestManager.Object), Times.Once); - [TestMethod] - public void ExecutorExecuteForFailedConnectionShouldThrowCommandLineException() - { - this.executor = new PortArgumentExecutor(CommandLineOptions.Instance, this.testRequestManager.Object, - (parentProcessId, ph) => testDesignModeClient.Object, this.mockProcessHelper.Object); + Assert.AreEqual(ArgumentProcessorResult.Success, result); + } - testDesignModeClient.Setup(td => td.ConnectToClientAndProcessRequests(It.IsAny(), - It.IsAny())).Callback(() => { throw new TimeoutException(); }); + [TestMethod] + public void ExecutorExecuteForFailedConnectionShouldThrowCommandLineException() + { + _executor = new PortArgumentExecutor(CommandLineOptions.Instance, _testRequestManager.Object, + (parentProcessId, ph) => _testDesignModeClient.Object, _mockProcessHelper.Object); - int port = 2345; - this.executor.Initialize(port.ToString()); - Assert.ThrowsException(() => executor.Execute()); + _testDesignModeClient.Setup(td => td.ConnectToClientAndProcessRequests(It.IsAny(), + It.IsAny())).Callback(() => throw new TimeoutException()); - testDesignModeClient.Verify(td => td.ConnectToClientAndProcessRequests(port, this.testRequestManager.Object), Times.Once); - } + int port = 2345; + _executor.Initialize(port.ToString()); + Assert.ThrowsException(() => _executor.Execute()); + _testDesignModeClient.Verify(td => td.ConnectToClientAndProcessRequests(port, _testRequestManager.Object), Times.Once); + } - [TestMethod] - public void ExecutorExecuteSetsParentProcessIdOnDesignModeInitializer() - { - var parentProcessId = 2346; - var parentProcessIdArgumentExecutor = new ParentProcessIdArgumentExecutor(CommandLineOptions.Instance); - parentProcessIdArgumentExecutor.Initialize(parentProcessId.ToString()); - - int actualParentProcessId = -1; - this.executor = new PortArgumentExecutor(CommandLineOptions.Instance, - this.testRequestManager.Object, - (ppid, ph) => - { - actualParentProcessId = ppid; - return testDesignModeClient.Object; - }, - this.mockProcessHelper.Object - ); - - int port = 2345; - this.executor.Initialize(port.ToString()); - var result = executor.Execute(); - - testDesignModeClient.Verify(td => - td.ConnectToClientAndProcessRequests(port, testRequestManager.Object), Times.Once); - - Assert.AreEqual(parentProcessId, actualParentProcessId, "Parent process Id must be set correctly on design mode initializer"); - - Assert.AreEqual(ArgumentProcessorResult.Success, result); - } + + [TestMethod] + public void ExecutorExecuteSetsParentProcessIdOnDesignModeInitializer() + { + var parentProcessId = 2346; + var parentProcessIdArgumentExecutor = new ParentProcessIdArgumentExecutor(CommandLineOptions.Instance); + parentProcessIdArgumentExecutor.Initialize(parentProcessId.ToString()); + + int actualParentProcessId = -1; + _executor = new PortArgumentExecutor(CommandLineOptions.Instance, + _testRequestManager.Object, + (ppid, ph) => + { + actualParentProcessId = ppid; + return _testDesignModeClient.Object; + }, + _mockProcessHelper.Object + ); + + int port = 2345; + _executor.Initialize(port.ToString()); + var result = _executor.Execute(); + + _testDesignModeClient.Verify(td => + td.ConnectToClientAndProcessRequests(port, _testRequestManager.Object), Times.Once); + + Assert.AreEqual(parentProcessId, actualParentProcessId, "Parent process Id must be set correctly on design mode initializer"); + + Assert.AreEqual(ArgumentProcessorResult.Success, result); } } \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/ResponseFileArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/ResponseFileArgumentProcessorTests.cs index 5e9e53c617..f9c66ab9b5 100644 --- a/test/vstest.console.UnitTests/Processors/ResponseFileArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/ResponseFileArgumentProcessorTests.cs @@ -1,52 +1,52 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +using TestTools.UnitTesting; + +using TestPlatform.CommandLine.Processors; + +[TestClass] +public class ResponseFileArgumentProcessorTests { - using Microsoft.VisualStudio.TestTools.UnitTesting; - using TestPlatform.CommandLine.Processors; + [TestCleanup] + public void TestCleanup() + { + CommandLineOptions.Instance.Reset(); + } + + [TestMethod] + public void GetMetadataShouldReturnResponseFileArgumentProcessorCapabilities() + { + var processor = new ResponseFileArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is ResponseFileArgumentProcessorCapabilities); + } - [TestClass] - public class ResponseFileArgumentProcessorTests + [TestMethod] + public void GetExecuterShouldReturnNull() { - [TestCleanup] - public void TestCleanup() - { - CommandLineOptions.Instance.Reset(); - } - - [TestMethod] - public void GetMetadataShouldReturnResponseFileArgumentProcessorCapabilities() - { - var processor = new ResponseFileArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is ResponseFileArgumentProcessorCapabilities); - } - - [TestMethod] - public void GetExecuterShouldReturnNull() - { - var processor = new ResponseFileArgumentProcessor(); - Assert.IsNull(processor.Executor); - } - - #region ResponseFileArgumentProcessorCapabilities tests - - [TestMethod] - public void CapabilitiesShouldReturnAppropriateProperties() - { - var capabilities = new ResponseFileArgumentProcessorCapabilities(); - Assert.AreEqual("@", capabilities.CommandName); - StringAssert.Contains(capabilities.HelpContentResourceName, "Read response file for more options"); - - Assert.AreEqual(HelpContentPriority.ResponseFileArgumentProcessorHelpPriority, capabilities.HelpPriority); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.Normal, capabilities.Priority); - - Assert.IsTrue(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsTrue(capabilities.IsSpecialCommand); - } - - #endregion + var processor = new ResponseFileArgumentProcessor(); + Assert.IsNull(processor.Executor); } -} + + #region ResponseFileArgumentProcessorCapabilities tests + + [TestMethod] + public void CapabilitiesShouldReturnAppropriateProperties() + { + var capabilities = new ResponseFileArgumentProcessorCapabilities(); + Assert.AreEqual("@", capabilities.CommandName); + StringAssert.Contains(capabilities.HelpContentResourceName, "Read response file for more options"); + + Assert.AreEqual(HelpContentPriority.ResponseFileArgumentProcessorHelpPriority, capabilities.HelpPriority); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.Normal, capabilities.Priority); + + Assert.IsTrue(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsTrue(capabilities.IsSpecialCommand); + } + + #endregion +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/ResultsDirectoryArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/ResultsDirectoryArgumentProcessorTests.cs index 1982257d91..5e9e1c07f9 100644 --- a/test/vstest.console.UnitTests/Processors/ResultsDirectoryArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/ResultsDirectoryArgumentProcessorTests.cs @@ -3,167 +3,166 @@ using System.Text.RegularExpressions; -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +using TestTools.UnitTesting; +using TestPlatform.CommandLine.Processors; +using System; +using System.IO; +using vstest.console.UnitTests.Processors; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; + +[TestClass] +public class ResultsDirectoryArgumentProcessorTests { - using Microsoft.VisualStudio.TestTools.UnitTesting; - using TestPlatform.CommandLine.Processors; - using System; - using System.IO; - using vstest.console.UnitTests.Processors; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - - [TestClass] - public class ResultsDirectoryArgumentProcessorTests + private ResultsDirectoryArgumentExecutor _executor; + private TestableRunSettingsProvider _runSettingsProvider; + + [TestInitialize] + public void Init() { - private ResultsDirectoryArgumentExecutor executor; - private TestableRunSettingsProvider runSettingsProvider; + _runSettingsProvider = new TestableRunSettingsProvider(); + _executor = new ResultsDirectoryArgumentExecutor(CommandLineOptions.Instance, _runSettingsProvider); + } - [TestInitialize] - public void Init() - { - this.runSettingsProvider = new TestableRunSettingsProvider(); - this.executor = new ResultsDirectoryArgumentExecutor(CommandLineOptions.Instance, this.runSettingsProvider); - } + [TestCleanup] + public void TestCleanup() + { + CommandLineOptions.Instance.Reset(); + } - [TestCleanup] - public void TestCleanup() - { - CommandLineOptions.Instance.Reset(); - } + [TestMethod] + public void GetMetadataShouldReturnResultsDirectoryArgumentProcessorCapabilities() + { + var processor = new ResultsDirectoryArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is ResultsDirectoryArgumentProcessorCapabilities); + } - [TestMethod] - public void GetMetadataShouldReturnResultsDirectoryArgumentProcessorCapabilities() - { - var processor = new ResultsDirectoryArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is ResultsDirectoryArgumentProcessorCapabilities); - } + [TestMethod] + public void GetExecuterShouldReturnResultsDirectoryArgumentExecutor() + { + var processor = new ResultsDirectoryArgumentProcessor(); + Assert.IsTrue(processor.Executor.Value is ResultsDirectoryArgumentExecutor); + } - [TestMethod] - public void GetExecuterShouldReturnResultsDirectoryArgumentExecutor() - { - var processor = new ResultsDirectoryArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is ResultsDirectoryArgumentExecutor); - } + #region ResultsDirectoryArgumentProcessorCapabilities tests - #region ResultsDirectoryArgumentProcessorCapabilities tests + [TestMethod] + public void CapabilitiesShouldReturnAppropriateProperties() + { + var capabilities = new ResultsDirectoryArgumentProcessorCapabilities(); + Assert.AreEqual("/ResultsDirectory", capabilities.CommandName); + var expected = "--ResultsDirectory|/ResultsDirectory\r\n Test results directory will be created in specified path if not exists.\r\n Example /ResultsDirectory:"; + Assert.AreEqual(expected.NormalizeLineEndings().ShowWhiteSpace(), capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); + + Assert.AreEqual(HelpContentPriority.ResultsDirectoryArgumentProcessorHelpPriority, capabilities.HelpPriority); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.AutoUpdateRunSettings, capabilities.Priority); + + Assert.IsFalse(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } - [TestMethod] - public void CapabilitiesShouldReturnAppropriateProperties() - { - var capabilities = new ResultsDirectoryArgumentProcessorCapabilities(); - Assert.AreEqual("/ResultsDirectory", capabilities.CommandName); - var expected = "--ResultsDirectory|/ResultsDirectory\r\n Test results directory will be created in specified path if not exists.\r\n Example /ResultsDirectory:"; - Assert.AreEqual(expected.NormalizeLineEndings().ShowWhiteSpace(), capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); - - Assert.AreEqual(HelpContentPriority.ResultsDirectoryArgumentProcessorHelpPriority, capabilities.HelpPriority); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.AutoUpdateRunSettings, capabilities.Priority); - - Assert.IsFalse(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); - } + #endregion - #endregion + #region ResultsDirectoryArgumentExecutor Initialize tests - #region ResultsDirectoryArgumentExecutor Initialize tests + [TestMethod] + public void InitializeShouldThrowIfArgumentIsNull() + { + string folder = null; + var message = + @"The /ResultsDirectory parameter requires a value, where the test results should be saved. Example: /ResultsDirectory:c:\MyTestResultsDirectory"; + InitializeExceptionTestTemplate(folder, message); + } - [TestMethod] - public void InitializeShouldThrowIfArgumentIsNull() - { - string folder = null; - var message = - @"The /ResultsDirectory parameter requires a value, where the test results should be saved. Example: /ResultsDirectory:c:\MyTestResultsDirectory"; - this.InitializeExceptionTestTemplate(folder, message); - } + [TestMethod] + public void InitializeShouldThrowIfArgumentIsAWhiteSpace() + { + var folder = " "; + var message = + @"The /ResultsDirectory parameter requires a value, where the test results should be saved. Example: /ResultsDirectory:c:\MyTestResultsDirectory"; + InitializeExceptionTestTemplate(folder, message); + } - [TestMethod] - public void InitializeShouldThrowIfArgumentIsAWhiteSpace() - { - var folder = " "; - var message = - @"The /ResultsDirectory parameter requires a value, where the test results should be saved. Example: /ResultsDirectory:c:\MyTestResultsDirectory"; - this.InitializeExceptionTestTemplate(folder, message); - } + [TestMethod] + public void InitializeShouldThrowIfGivenPathIsIllegal() + { + // the internal code uses IsPathRooted which does not consider this rooted on Linux + // so we need to convert the path, and use char that is invalid on the current platform + var invalidChar = Path.GetInvalidPathChars()[0]; - [TestMethod] - public void InitializeShouldThrowIfGivenPathIsIllegal() - { - // the internal code uses IsPathRooted which does not consider this rooted on Linux - // so we need to convert the path, and use char that is invalid on the current platform - var invalidChar = Path.GetInvalidPathChars()[0]; - - var folder = TranslatePath($@"c:\som{invalidChar}\illegal\path\"); - // The error varies based on the runtime and OS, just checking that we detect - // incorrect path should be enough and not so flaky - // you might get - // - The filename, directory name, or volume label syntax is incorrect - // - Illegal characters in path. - // - etc. - - var message = $"The path '{folder}' specified in the 'ResultsDirectory' is invalid. Error:"; - - this.InitializeExceptionTestTemplate(folder, message); - } + var folder = TranslatePath($@"c:\som{invalidChar}\illegal\path\"); + // The error varies based on the runtime and OS, just checking that we detect + // incorrect path should be enough and not so flaky + // you might get + // - The filename, directory name, or volume label syntax is incorrect + // - Illegal characters in path. + // - etc. - private void InitializeExceptionTestTemplate(string folder, string message) - { - var isExceptionThrown = false; - - try - { - this.executor.Initialize(folder); - } - catch (Exception ex) - { - isExceptionThrown = true; - Assert.IsTrue(ex is CommandLineException, "ex is CommandLineException"); - StringAssert.StartsWith( ex.Message, message); - } - - Assert.IsTrue(isExceptionThrown, "isExceptionThrown"); - } + var message = $"The path '{folder}' specified in the 'ResultsDirectory' is invalid. Error:"; - [TestMethod] - public void InitializeShouldSetCommandLineOptionsAndRunSettingsForRelativePathValue() + InitializeExceptionTestTemplate(folder, message); + } + + private void InitializeExceptionTestTemplate(string folder, string message) + { + var isExceptionThrown = false; + + try { - var relativePath = TranslatePath(@".\relative\path"); - var absolutePath = Path.GetFullPath(relativePath); - this.executor.Initialize(relativePath); - Assert.AreEqual(absolutePath, CommandLineOptions.Instance.ResultsDirectory); - Assert.AreEqual(absolutePath, this.runSettingsProvider.QueryRunSettingsNode(ResultsDirectoryArgumentExecutor.RunSettingsPath)); + _executor.Initialize(folder); } - - [TestMethod] - public void InitializeShouldSetCommandLineOptionsAndRunSettingsForAbsolutePathValue() + catch (Exception ex) { - var absolutePath = TranslatePath(@"c:\random\someone\testresults"); - this.executor.Initialize(absolutePath); - Assert.AreEqual(absolutePath, CommandLineOptions.Instance.ResultsDirectory); - Assert.AreEqual(absolutePath, this.runSettingsProvider.QueryRunSettingsNode(ResultsDirectoryArgumentExecutor.RunSettingsPath)); + isExceptionThrown = true; + Assert.IsTrue(ex is CommandLineException, "ex is CommandLineException"); + StringAssert.StartsWith(ex.Message, message); } - #endregion + Assert.IsTrue(isExceptionThrown, "isExceptionThrown"); + } + + [TestMethod] + public void InitializeShouldSetCommandLineOptionsAndRunSettingsForRelativePathValue() + { + var relativePath = TranslatePath(@".\relative\path"); + var absolutePath = Path.GetFullPath(relativePath); + _executor.Initialize(relativePath); + Assert.AreEqual(absolutePath, CommandLineOptions.Instance.ResultsDirectory); + Assert.AreEqual(absolutePath, _runSettingsProvider.QueryRunSettingsNode(ResultsDirectoryArgumentExecutor.RunSettingsPath)); + } - #region ResultsDirectoryArgumentExecutor Execute tests + [TestMethod] + public void InitializeShouldSetCommandLineOptionsAndRunSettingsForAbsolutePathValue() + { + var absolutePath = TranslatePath(@"c:\random\someone\testresults"); + _executor.Initialize(absolutePath); + Assert.AreEqual(absolutePath, CommandLineOptions.Instance.ResultsDirectory); + Assert.AreEqual(absolutePath, _runSettingsProvider.QueryRunSettingsNode(ResultsDirectoryArgumentExecutor.RunSettingsPath)); + } - [TestMethod] - public void ExecuteShouldReturnSuccess() - { - Assert.AreEqual(ArgumentProcessorResult.Success, executor.Execute()); - } + #endregion - #endregion - - private string TranslatePath(string path) - { - // RuntimeInformation has conflict when used - if (Environment.OSVersion.Platform.ToString().StartsWith("Win")) - return path; + #region ResultsDirectoryArgumentExecutor Execute tests - var prefix = Path.GetTempPath(); + [TestMethod] + public void ExecuteShouldReturnSuccess() + { + Assert.AreEqual(ArgumentProcessorResult.Success, _executor.Execute()); + } - return Regex.Replace(path.Replace("\\", "/"), @"(\w)\:/", $@"{prefix}$1/"); - } + #endregion + + private string TranslatePath(string path) + { + // RuntimeInformation has conflict when used + if (Environment.OSVersion.Platform.ToString().StartsWith("Win")) + return path; + + var prefix = Path.GetTempPath(); + + return Regex.Replace(path.Replace("\\", "/"), @"(\w)\:/", $@"{prefix}$1/"); } -} +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/RunSettingsArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/RunSettingsArgumentProcessorTests.cs index 199ae59c7e..d33cd78d1e 100644 --- a/test/vstest.console.UnitTests/Processors/RunSettingsArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/RunSettingsArgumentProcessorTests.cs @@ -1,443 +1,442 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors -{ - using System; - using System.IO; - using System.Xml; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +using System; +using System.IO; +using System.Xml; + +using Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using TestTools.UnitTesting; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using vstest.console.UnitTests.Processors; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using vstest.console.UnitTests.Processors; +using Moq; +using System.Text; - using Moq; - using System.Text; +using ExceptionUtilities = ExceptionUtilities; - using ExceptionUtilities = Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.ExceptionUtilities; +[TestClass] +public class RunSettingsArgumentProcessorTests +{ + private TestableRunSettingsProvider _settingsProvider; - [TestClass] - public class RunSettingsArgumentProcessorTests + [TestInitialize] + public void Init() { - private TestableRunSettingsProvider settingsProvider; + _settingsProvider = new TestableRunSettingsProvider(); + } - [TestInitialize] - public void Init() - { - this.settingsProvider = new TestableRunSettingsProvider(); - } + [TestCleanup] + public void TestCleanup() + { + CommandLineOptions.Instance.Reset(); + } - [TestCleanup] - public void TestCleanup() - { - CommandLineOptions.Instance.Reset(); - } + [TestMethod] + public void GetMetadataShouldReturnRunSettingsArgumentProcessorCapabilities() + { + var processor = new RunSettingsArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is RunSettingsArgumentProcessorCapabilities); + } - [TestMethod] - public void GetMetadataShouldReturnRunSettingsArgumentProcessorCapabilities() - { - var processor = new RunSettingsArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is RunSettingsArgumentProcessorCapabilities); - } + [TestMethod] + public void GetExecuterShouldReturnRunSettingsArgumentExecutor() + { + var processor = new RunSettingsArgumentProcessor(); + Assert.IsTrue(processor.Executor.Value is RunSettingsArgumentExecutor); + } - [TestMethod] - public void GetExecuterShouldReturnRunSettingsArgumentExecutor() - { - var processor = new RunSettingsArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is RunSettingsArgumentExecutor); - } + #region RunSettingsArgumentProcessorCapabilities tests - #region RunSettingsArgumentProcessorCapabilities tests + [TestMethod] + public void CapabilitiesShouldReturnAppropriateProperties() + { + var capabilities = new RunSettingsArgumentProcessorCapabilities(); + Assert.AreEqual("/Settings", capabilities.CommandName); + var expected = "--Settings|/Settings:\r\n Settings to use when running tests."; + Assert.AreEqual(expected.NormalizeLineEndings().ShowWhiteSpace(), capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); + + Assert.AreEqual(HelpContentPriority.RunSettingsArgumentProcessorHelpPriority, capabilities.HelpPriority); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.RunSettings, capabilities.Priority); + + Assert.IsFalse(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } - [TestMethod] - public void CapabilitiesShouldReturnAppropriateProperties() - { - var capabilities = new RunSettingsArgumentProcessorCapabilities(); - Assert.AreEqual("/Settings", capabilities.CommandName); - var expected = "--Settings|/Settings:\r\n Settings to use when running tests."; - Assert.AreEqual(expected.NormalizeLineEndings().ShowWhiteSpace(), capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); - - Assert.AreEqual(HelpContentPriority.RunSettingsArgumentProcessorHelpPriority, capabilities.HelpPriority); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.RunSettings, capabilities.Priority); - - Assert.IsFalse(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); - } + #endregion - #endregion + #region RunSettingsArgumentExecutor tests - #region RunSettingsArgumentExecutor tests + [TestMethod] + public void InitializeShouldThrowExceptionIfArgumentIsNull() + { + Action action = () => new RunSettingsArgumentExecutor(CommandLineOptions.Instance, null).Initialize(null); - [TestMethod] - public void InitializeShouldThrowExceptionIfArgumentIsNull() - { - Action action = () => new RunSettingsArgumentExecutor(CommandLineOptions.Instance, null).Initialize(null); + ExceptionUtilities.ThrowsException( + action, + "The /Settings parameter requires a settings file to be provided."); + } - ExceptionUtilities.ThrowsException( - action, - "The /Settings parameter requires a settings file to be provided."); - } + [TestMethod] + public void InitializeShouldThrowExceptionIfArgumentIsWhiteSpace() + { + Action action = () => new RunSettingsArgumentExecutor(CommandLineOptions.Instance, null).Initialize(" "); - [TestMethod] - public void InitializeShouldThrowExceptionIfArgumentIsWhiteSpace() - { - Action action = () => new RunSettingsArgumentExecutor(CommandLineOptions.Instance, null).Initialize(" "); + ExceptionUtilities.ThrowsException( + action, + "The /Settings parameter requires a settings file to be provided."); + } - ExceptionUtilities.ThrowsException( - action, - "The /Settings parameter requires a settings file to be provided."); - } + [TestMethod] + public void InitializeShouldThrowExceptionIfFileDoesNotExist() + { + var fileName = "C:\\Imaginary\\nonExistentFile.txt"; - [TestMethod] - public void InitializeShouldThrowExceptionIfFileDoesNotExist() - { - var fileName = "C:\\Imaginary\\nonExistentFile.txt"; + var executor = new RunSettingsArgumentExecutor(CommandLineOptions.Instance, null); + var mockFileHelper = new Mock(); + mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(false); - var executor = new RunSettingsArgumentExecutor(CommandLineOptions.Instance, null); - var mockFileHelper = new Mock(); - mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(false); + executor.FileHelper = mockFileHelper.Object; - executor.FileHelper = mockFileHelper.Object; + ExceptionUtilities.ThrowsException( + () => executor.Initialize(fileName), + "The Settings file '{0}' could not be found.", + fileName); + } - ExceptionUtilities.ThrowsException( - () => executor.Initialize(fileName), - "The Settings file '{0}' could not be found.", - fileName); - } + [TestMethod] + public void InitializeShouldThrowIfRunSettingsSchemaDoesNotMatch() + { + // Arrange. + var fileName = "C:\\temp\\r.runsettings"; + var settingsXml = ""; - [TestMethod] - public void InitializeShouldThrowIfRunSettingsSchemaDoesNotMatch() - { - // Arrange. - var fileName = "C:\\temp\\r.runsettings"; - var settingsXml = ""; + var executor = new TestableRunSettingsArgumentExecutor( + CommandLineOptions.Instance, + _settingsProvider, + settingsXml); - var executor = new TestableRunSettingsArgumentExecutor( - CommandLineOptions.Instance, - this.settingsProvider, - settingsXml); + // Setup mocks. + var mockFileHelper = new Mock(); + mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - // Setup mocks. - var mockFileHelper = new Mock(); - mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + executor.FileHelper = mockFileHelper.Object; - executor.FileHelper = mockFileHelper.Object; + // Act and Assert. + ExceptionUtilities.ThrowsException( + () => executor.Initialize(fileName), + "Settings file provided does not conform to required format."); + } - // Act and Assert. - ExceptionUtilities.ThrowsException( - () => executor.Initialize(fileName), - "Settings file provided does not conform to required format."); - } + [TestMethod] + public void InitializeShouldSetActiveRunSettings() + { + // Arrange. + var fileName = "C:\\temp\\r.runsettings"; + var settingsXml = ""; + + var executor = new TestableRunSettingsArgumentExecutor( + CommandLineOptions.Instance, + _settingsProvider, + settingsXml); + + // Setup mocks. + var mockFileHelper = new Mock(); + mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + executor.FileHelper = mockFileHelper.Object; + + // Act. + executor.Initialize(fileName); + + // Assert. + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + Assert.AreEqual(fileName, CommandLineOptions.Instance.SettingsFile); + } - [TestMethod] - public void InitializeShouldSetActiveRunSettings() - { - // Arrange. - var fileName = "C:\\temp\\r.runsettings"; - var settingsXml = ""; - - var executor = new TestableRunSettingsArgumentExecutor( - CommandLineOptions.Instance, - this.settingsProvider, - settingsXml); - - // Setup mocks. - var mockFileHelper = new Mock(); - mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - executor.FileHelper = mockFileHelper.Object; - - // Act. - executor.Initialize(fileName); - - // Assert. - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual(fileName, CommandLineOptions.Instance.SettingsFile); - } + [TestMethod] + public void InitializeShouldSetSettingsFileForCommandLineOptions() + { + // Arrange. + var fileName = "C:\\temp\\r.runsettings"; + var settingsXml = ""; - [TestMethod] - public void InitializeShouldSetSettingsFileForCommandLineOptions() - { - // Arrange. - var fileName = "C:\\temp\\r.runsettings"; - var settingsXml = ""; + var executor = new TestableRunSettingsArgumentExecutor( + CommandLineOptions.Instance, + _settingsProvider, + settingsXml); - var executor = new TestableRunSettingsArgumentExecutor( - CommandLineOptions.Instance, - this.settingsProvider, - settingsXml); + // Setup mocks. + var mockFileHelper = new Mock(); + mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + executor.FileHelper = mockFileHelper.Object; - // Setup mocks. - var mockFileHelper = new Mock(); - mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - executor.FileHelper = mockFileHelper.Object; + // Act. + executor.Initialize(fileName); - // Act. - executor.Initialize(fileName); + // Assert. + Assert.AreEqual(fileName, CommandLineOptions.Instance.SettingsFile); + } - // Assert. - Assert.AreEqual(fileName, CommandLineOptions.Instance.SettingsFile); - } + [TestMethod] + public void InitializeShouldAddDefaultSettingsIfNotPresent() + { + // Arrange. + var fileName = "C:\\temp\\r.runsettings"; + var settingsXml = ""; + + var executor = new TestableRunSettingsArgumentExecutor( + CommandLineOptions.Instance, + _settingsProvider, + settingsXml); + + // Setup mocks. + var mockFileHelper = new Mock(); + mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + executor.FileHelper = mockFileHelper.Object; + + // Act. + executor.Initialize(fileName); + + // Assert. + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + RunConfiguration runConfiguration = + XmlRunSettingsUtilities.GetRunConfigurationNode(_settingsProvider.ActiveRunSettings.SettingsXml); + Assert.AreEqual(runConfiguration.ResultsDirectory, Constants.DefaultResultsDirectory); + Assert.AreEqual(runConfiguration.TargetFramework.ToString(), Framework.DefaultFramework.ToString()); + Assert.AreEqual(runConfiguration.TargetPlatform, Constants.DefaultPlatform); - [TestMethod] - public void InitializeShouldAddDefaultSettingsIfNotPresent() - { - // Arrange. - var fileName = "C:\\temp\\r.runsettings"; - var settingsXml = ""; - - var executor = new TestableRunSettingsArgumentExecutor( - CommandLineOptions.Instance, - this.settingsProvider, - settingsXml); - - // Setup mocks. - var mockFileHelper = new Mock(); - mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - executor.FileHelper = mockFileHelper.Object; - - // Act. - executor.Initialize(fileName); - - // Assert. - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - RunConfiguration runConfiguration = - XmlRunSettingsUtilities.GetRunConfigurationNode(this.settingsProvider.ActiveRunSettings.SettingsXml); - Assert.AreEqual(runConfiguration.ResultsDirectory, Constants.DefaultResultsDirectory); - Assert.AreEqual(runConfiguration.TargetFramework.ToString(), Framework.DefaultFramework.ToString()); - Assert.AreEqual(runConfiguration.TargetPlatform, Constants.DefaultPlatform); + } - } + [TestMethod] + public void InitializeShouldSetActiveRunSettingsForTestSettingsFiles() + { + // Arrange. + var fileName = "C:\\temp\\r.testsettings"; + var settingsXml = ""; + + var executor = new TestableRunSettingsArgumentExecutor( + CommandLineOptions.Instance, + _settingsProvider, + settingsXml); + + // Setup mocks. + var mockFileHelper = new Mock(); + mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + executor.FileHelper = mockFileHelper.Object; + + // Act. + executor.Initialize(fileName); + + + // Assert. + Assert.IsNotNull(_settingsProvider.ActiveRunSettings); + + var expected = string.Join(Environment.NewLine, + $"", + $"", + $" ", + $" {Constants.DefaultResultsDirectory}", + $" {Constants.DefaultPlatform}", + $" {Framework.DefaultFramework.Name}", + $" ", + $" ", + $" C:\\temp\\r.testsettings", + $" true", + $" ", + $" ", + $" ", + $" ", + $""); + StringAssert.Contains(_settingsProvider.ActiveRunSettings.SettingsXml, expected); + } - [TestMethod] - public void InitializeShouldSetActiveRunSettingsForTestSettingsFiles() - { - // Arrange. - var fileName = "C:\\temp\\r.testsettings"; - var settingsXml = ""; - - var executor = new TestableRunSettingsArgumentExecutor( - CommandLineOptions.Instance, - this.settingsProvider, - settingsXml); - - // Setup mocks. - var mockFileHelper = new Mock(); - mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - executor.FileHelper = mockFileHelper.Object; - - // Act. - executor.Initialize(fileName); - - - // Assert. - Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - - var expected = string.Join(Environment.NewLine, - $"", - $"", - $" ", - $" {Constants.DefaultResultsDirectory}", - $" {Constants.DefaultPlatform}", - $" {Framework.DefaultFramework.Name}", - $" ", - $" ", - $" C:\\temp\\r.testsettings", - $" true", - $" ", - $" ", - $" ", - $" ", - $""); - StringAssert.Contains(this.settingsProvider.ActiveRunSettings.SettingsXml, expected); - } + [TestMethod] + public void InitializeShouldUpdateCommandLineOptionsArchitectureAndFxIfProvided() + { + // Arrange. + var fileName = "C:\\temp\\r.runsettings"; + var settingsXml = $"{nameof(Architecture.X64)}{Constants.DotNetFramework46}"; + + var executor = new TestableRunSettingsArgumentExecutor( + CommandLineOptions.Instance, + _settingsProvider, + settingsXml); + + // Setup mocks. + var mockFileHelper = new Mock(); + mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + executor.FileHelper = mockFileHelper.Object; + + // Act. + executor.Initialize(fileName); + + // Assert. + Assert.IsTrue(CommandLineOptions.Instance.ArchitectureSpecified); + Assert.IsTrue(CommandLineOptions.Instance.FrameworkVersionSpecified); + Assert.AreEqual(Architecture.X64, CommandLineOptions.Instance.TargetArchitecture); + Assert.AreEqual(Constants.DotNetFramework46, CommandLineOptions.Instance.TargetFrameworkVersion.Name); + } - [TestMethod] - public void InitializeShouldUpdateCommandLineOptionsArchitectureAndFxIfProvided() - { - // Arrange. - var fileName = "C:\\temp\\r.runsettings"; - var settingsXml = $"{nameof(Architecture.X64)}{Constants.DotNetFramework46}"; - - var executor = new TestableRunSettingsArgumentExecutor( - CommandLineOptions.Instance, - this.settingsProvider, - settingsXml); - - // Setup mocks. - var mockFileHelper = new Mock(); - mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - executor.FileHelper = mockFileHelper.Object; - - // Act. - executor.Initialize(fileName); - - // Assert. - Assert.IsTrue(CommandLineOptions.Instance.ArchitectureSpecified); - Assert.IsTrue(CommandLineOptions.Instance.FrameworkVersionSpecified); - Assert.AreEqual(Architecture.X64, CommandLineOptions.Instance.TargetArchitecture); - Assert.AreEqual(Constants.DotNetFramework46, CommandLineOptions.Instance.TargetFrameworkVersion.Name); - } + [TestMethod] + public void InitializeShouldNotUpdateCommandLineOptionsArchitectureAndFxIfNotProvided() + { + // Arrange. + var fileName = "C:\\temp\\r.runsettings"; + var settingsXml = ""; + + var executor = new TestableRunSettingsArgumentExecutor( + CommandLineOptions.Instance, + _settingsProvider, + settingsXml); + + // Setup mocks. + var mockFileHelper = new Mock(); + mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + executor.FileHelper = mockFileHelper.Object; + + // Act. + executor.Initialize(fileName); + + // Assert. + Assert.IsFalse(CommandLineOptions.Instance.ArchitectureSpecified); + Assert.IsFalse(CommandLineOptions.Instance.FrameworkVersionSpecified); + } - [TestMethod] - public void InitializeShouldNotUpdateCommandLineOptionsArchitectureAndFxIfNotProvided() - { - // Arrange. - var fileName = "C:\\temp\\r.runsettings"; - var settingsXml = ""; - - var executor = new TestableRunSettingsArgumentExecutor( - CommandLineOptions.Instance, - this.settingsProvider, - settingsXml); - - // Setup mocks. - var mockFileHelper = new Mock(); - mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - executor.FileHelper = mockFileHelper.Object; - - // Act. - executor.Initialize(fileName); - - // Assert. - Assert.IsFalse(CommandLineOptions.Instance.ArchitectureSpecified); - Assert.IsFalse(CommandLineOptions.Instance.FrameworkVersionSpecified); - } + [TestMethod] + public void InitializeShouldPreserveActualJapaneseString() + { + var runsettingsFile = Path.Combine(Path.GetTempPath(), "InitializeShouldPreserveActualJapaneseString.runsettings"); + var settingsXml = @"C:\新しいフォルダー"; - [TestMethod] - public void InitializeShouldPreserveActualJapaneseString() - { - var runsettingsFile = Path.Combine(Path.GetTempPath(), "InitializeShouldPreserveActualJapaneseString.runsettings"); - var settingsXml = @"C:\新しいフォルダー"; + File.WriteAllText(runsettingsFile, settingsXml, Encoding.UTF8); - File.WriteAllText(runsettingsFile, settingsXml, Encoding.UTF8); + var executor = new TestableRunSettingsArgumentExecutor( + CommandLineOptions.Instance, + _settingsProvider, + null); - var executor = new TestableRunSettingsArgumentExecutor( - CommandLineOptions.Instance, - this.settingsProvider, - null); + executor.Initialize(runsettingsFile); + Assert.IsTrue(_settingsProvider.ActiveRunSettings.SettingsXml.Contains(@"C:\新しいフォルダー")); + File.Delete(runsettingsFile); + } - executor.Initialize(runsettingsFile); - Assert.IsTrue(this.settingsProvider.ActiveRunSettings.SettingsXml.Contains(@"C:\新しいフォルダー")); - File.Delete(runsettingsFile); - } + [TestMethod] + public void InitializeShouldSetInIsolataionToTrueIfEnvironmentVariablesSpecified() + { + var settingsXml = @"C:\temp"; - [TestMethod] - public void InitializeShouldSetInIsolataionToTrueIfEnvironmentVariablesSpecified() - { - var settingsXml = @"C:\temp"; + // Arrange. + var fileName = "C:\\temp\\r.runsettings"; - // Arrange. - var fileName = "C:\\temp\\r.runsettings"; + var executor = new TestableRunSettingsArgumentExecutor( + CommandLineOptions.Instance, + _settingsProvider, + settingsXml); - var executor = new TestableRunSettingsArgumentExecutor( - CommandLineOptions.Instance, - this.settingsProvider, - settingsXml); + // Setup mocks. + var mockFileHelper = new Mock(); + mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + executor.FileHelper = mockFileHelper.Object; - // Setup mocks. - var mockFileHelper = new Mock(); - mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - executor.FileHelper = mockFileHelper.Object; + // Act. + executor.Initialize(fileName); - // Act. - executor.Initialize(fileName); + // Assert. + Assert.IsTrue(CommandLineOptions.Instance.InIsolation); + Assert.AreEqual("true", _settingsProvider.QueryRunSettingsNode(InIsolationArgumentExecutor.RunSettingsPath)); + } - // Assert. - Assert.IsTrue(CommandLineOptions.Instance.InIsolation); - Assert.AreEqual("true", this.settingsProvider.QueryRunSettingsNode(InIsolationArgumentExecutor.RunSettingsPath)); - } + [TestMethod] + public void InitializeShouldNotSetInIsolataionToTrueIfEnvironmentVariablesNotSpecified() + { + var settingsXml = @""; - [TestMethod] - public void InitializeShouldNotSetInIsolataionToTrueIfEnvironmentVariablesNotSpecified() - { - var settingsXml = @""; + /// Arrange. + var fileName = "C:\\temp\\r.runsettings"; - /// Arrange. - var fileName = "C:\\temp\\r.runsettings"; + var executor = new TestableRunSettingsArgumentExecutor( + CommandLineOptions.Instance, + _settingsProvider, + settingsXml); - var executor = new TestableRunSettingsArgumentExecutor( - CommandLineOptions.Instance, - this.settingsProvider, - settingsXml); + // Setup mocks. + var mockFileHelper = new Mock(); + mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + executor.FileHelper = mockFileHelper.Object; - // Setup mocks. - var mockFileHelper = new Mock(); - mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - executor.FileHelper = mockFileHelper.Object; + // Act. + executor.Initialize(fileName); - // Act. - executor.Initialize(fileName); + // Assert. + Assert.IsFalse(CommandLineOptions.Instance.InIsolation); + Assert.IsNull(_settingsProvider.QueryRunSettingsNode(InIsolationArgumentExecutor.RunSettingsPath)); + } - // Assert. - Assert.IsFalse(CommandLineOptions.Instance.InIsolation); - Assert.IsNull(this.settingsProvider.QueryRunSettingsNode(InIsolationArgumentExecutor.RunSettingsPath)); - } + [TestMethod] + public void InitializeShouldUpdateTestCaseFilterIfProvided() + { + // Arrange. + var fileName = "C:\\temp\\r.runsettings"; + var filter = "TestCategory=Included"; + var settingsXml = $"{filter}"; + + var executor = new TestableRunSettingsArgumentExecutor( + CommandLineOptions.Instance, + _settingsProvider, + settingsXml); + + // Setup mocks. + var mockFileHelper = new Mock(); + mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); + executor.FileHelper = mockFileHelper.Object; + + // Act. + executor.Initialize(fileName); + + // Assert. + Assert.AreEqual(filter, CommandLineOptions.Instance.TestCaseFilterValue); + } + #endregion - [TestMethod] - public void InitializeShouldUpdateTestCaseFilterIfProvided() - { - // Arrange. - var fileName = "C:\\temp\\r.runsettings"; - var filter = "TestCategory=Included"; - var settingsXml = $"{filter}"; - - var executor = new TestableRunSettingsArgumentExecutor( - CommandLineOptions.Instance, - this.settingsProvider, - settingsXml); - - // Setup mocks. - var mockFileHelper = new Mock(); - mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); - executor.FileHelper = mockFileHelper.Object; - - // Act. - executor.Initialize(fileName); - - // Assert. - Assert.AreEqual(filter, CommandLineOptions.Instance.TestCaseFilterValue); - } - #endregion + #region Testable Implementations - #region Testable Implementations + private class TestableRunSettingsArgumentExecutor : RunSettingsArgumentExecutor + { + private readonly string _runSettingsString; - private class TestableRunSettingsArgumentExecutor : RunSettingsArgumentExecutor - { - private string runSettingsString; + internal TestableRunSettingsArgumentExecutor( + CommandLineOptions commandLineOptions, + IRunSettingsProvider runSettingsManager, + string runSettings) + : base(commandLineOptions, runSettingsManager) - internal TestableRunSettingsArgumentExecutor( - CommandLineOptions commandLineOptions, - IRunSettingsProvider runSettingsManager, - string runSettings) - : base(commandLineOptions, runSettingsManager) + { + _runSettingsString = runSettings; + } + protected override XmlReader GetReaderForFile(string runSettingsFile) + { + if (_runSettingsString == null) { - this.runSettingsString = runSettings; + return base.GetReaderForFile(runSettingsFile); } - protected override XmlReader GetReaderForFile(string runSettingsFile) - { - if (this.runSettingsString == null) - { - return base.GetReaderForFile(runSettingsFile); - } - - var reader = new StringReader(this.runSettingsString); - var xmlReader = XmlReader.Create(reader, XmlRunSettingsUtilities.ReaderSettings); + var reader = new StringReader(_runSettingsString); + var xmlReader = XmlReader.Create(reader, XmlRunSettingsUtilities.ReaderSettings); - return xmlReader; - } + return xmlReader; } - - #endregion } -} + + #endregion +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/RunSpecificTestsArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/RunSpecificTestsArgumentProcessorTests.cs index b100a49197..fff2b9c69a 100644 --- a/test/vstest.console.UnitTests/Processors/RunSpecificTestsArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/RunSpecificTestsArgumentProcessorTests.cs @@ -2,584 +2,608 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +using System; +using System.Collections.Generic; +using System.Runtime.Versioning; +using System.Threading.Tasks; + +using CommandLineUtilities; + +using CoreUtilities.Tracing.Interfaces; + +using Extensions.FileSystemGlobbing; +using Client; +using Client.RequestHelper; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using Publisher; +using TestPlatformHelpers; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; +using PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using TestTools.UnitTesting; + +using Moq; + +using vstest.console.Internal; +using vstest.console.UnitTests.Processors; + +[TestClass] +public class RunSpecificTestsArgumentProcessorTests { - using System; - using System.Collections.Generic; - using System.Runtime.Versioning; - using System.Threading.Tasks; - - using CommandLineUtilities; - using CoreUtilities.Tracing.Interfaces; - using Microsoft.Extensions.FileSystemGlobbing; - using Microsoft.VisualStudio.TestPlatform.Client; - using Microsoft.VisualStudio.TestPlatform.Client.Discovery; - using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Publisher; - using Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using vstest.console.Internal; - using vstest.console.UnitTests.Processors; - - [TestClass] - public class RunSpecificTestsArgumentProcessorTests + private const string NoDiscoveredTestsWarning = @"No test is available in DummyTest.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again."; + private const string TestAdapterPathSuggestion = @"Additionally, path to test adapters can be specified using /TestAdapterPath command. Example /TestAdapterPath:."; + private readonly Mock _mockFileHelper; + private readonly Mock _mockOutput; + private readonly InferHelper _inferHelper; + private readonly string _dummyTestFilePath = "DummyTest.dll"; + private readonly Mock _mockTestPlatformEventSource; + private readonly Mock _mockAssemblyMetadataProvider; + private readonly Task _mockMetricsPublisherTask; + private readonly Mock _mockMetricsPublisher; + private readonly Mock _mockProcessHelper; + private readonly Mock _mockAttachmentsProcessingManager; + + private RunSpecificTestsArgumentExecutor GetExecutor(ITestRequestManager testRequestManager) { - private const string NoDiscoveredTestsWarning = @"No test is available in DummyTest.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again."; - private const string TestAdapterPathSuggestion = @"Additionally, path to test adapters can be specified using /TestAdapterPath command. Example /TestAdapterPath:."; - private readonly Mock mockFileHelper; - private readonly Mock mockOutput; - private readonly InferHelper inferHelper; - private string dummyTestFilePath = "DummyTest.dll"; - private Mock mockTestPlatformEventSource; - private Mock mockAssemblyMetadataProvider; - private Task mockMetricsPublisherTask; - private Mock mockMetricsPublisher; - private Mock mockProcessHelper; - private Mock mockAttachmentsProcessingManager; - - private RunSpecificTestsArgumentExecutor GetExecutor(ITestRequestManager testRequestManager) - { - var runSettingsProvider = new TestableRunSettingsProvider(); - runSettingsProvider.AddDefaultRunSettings(); - return new RunSpecificTestsArgumentExecutor(CommandLineOptions.Instance, runSettingsProvider, testRequestManager, this.mockOutput.Object); - } + var runSettingsProvider = new TestableRunSettingsProvider(); + runSettingsProvider.AddDefaultRunSettings(); + return new RunSpecificTestsArgumentExecutor(CommandLineOptions.Instance, runSettingsProvider, testRequestManager, _mockOutput.Object); + } - public RunSpecificTestsArgumentProcessorTests() - { - this.mockFileHelper = new Mock(); - this.mockOutput = new Mock(); - this.mockAssemblyMetadataProvider = new Mock(); - this.inferHelper = new InferHelper(this.mockAssemblyMetadataProvider.Object); - this.mockAssemblyMetadataProvider.Setup(x => x.GetArchitecture(It.IsAny())).Returns(Architecture.X64); - this.mockAssemblyMetadataProvider.Setup(x => x.GetFrameWork(It.IsAny())).Returns(new FrameworkName(Constants.DotNetFramework40)); - this.mockFileHelper.Setup(fh => fh.Exists(this.dummyTestFilePath)).Returns(true); - this.mockFileHelper.Setup(x => x.GetCurrentDirectory()).Returns(""); - this.mockMetricsPublisher = new Mock(); - this.mockMetricsPublisherTask = Task.FromResult(this.mockMetricsPublisher.Object); - this.mockTestPlatformEventSource = new Mock(); - this.mockProcessHelper = new Mock(); - this.mockProcessHelper.Setup(x => x.GetCurrentProcessId()).Returns(1234); - this.mockProcessHelper.Setup(x => x.GetProcessName(It.IsAny())).Returns("dotnet.exe"); - this.mockAttachmentsProcessingManager = new Mock(); - } - - [TestMethod] - public void GetMetadataShouldReturnRunSpecificTestsArgumentProcessorCapabilities() - { - RunSpecificTestsArgumentProcessor processor = new RunSpecificTestsArgumentProcessor(); + public RunSpecificTestsArgumentProcessorTests() + { + _mockFileHelper = new Mock(); + _mockOutput = new Mock(); + _mockAssemblyMetadataProvider = new Mock(); + _inferHelper = new InferHelper(_mockAssemblyMetadataProvider.Object); + _mockAssemblyMetadataProvider.Setup(x => x.GetArchitecture(It.IsAny())).Returns(Architecture.X64); + _mockAssemblyMetadataProvider.Setup(x => x.GetFrameWork(It.IsAny())).Returns(new FrameworkName(Constants.DotNetFramework40)); + _mockFileHelper.Setup(fh => fh.Exists(_dummyTestFilePath)).Returns(true); + _mockFileHelper.Setup(x => x.GetCurrentDirectory()).Returns(""); + _mockMetricsPublisher = new Mock(); + _mockMetricsPublisherTask = Task.FromResult(_mockMetricsPublisher.Object); + _mockTestPlatformEventSource = new Mock(); + _mockProcessHelper = new Mock(); + _mockProcessHelper.Setup(x => x.GetCurrentProcessId()).Returns(1234); + _mockProcessHelper.Setup(x => x.GetProcessName(It.IsAny())).Returns("dotnet.exe"); + _mockAttachmentsProcessingManager = new Mock(); + } - Assert.IsTrue(processor.Metadata.Value is RunSpecificTestsArgumentProcessorCapabilities); - } + [TestMethod] + public void GetMetadataShouldReturnRunSpecificTestsArgumentProcessorCapabilities() + { + RunSpecificTestsArgumentProcessor processor = new(); - [TestMethod] - public void GetExecutorShouldReturnRunSpecificTestsArgumentExecutor() - { - RunSpecificTestsArgumentProcessor processor = new RunSpecificTestsArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is RunSpecificTestsArgumentProcessorCapabilities); + } - Assert.IsTrue(processor.Executor.Value is RunSpecificTestsArgumentExecutor); - } + [TestMethod] + public void GetExecutorShouldReturnRunSpecificTestsArgumentExecutor() + { + RunSpecificTestsArgumentProcessor processor = new(); - #region RunSpecificTestsArgumentProcessorCapabilitiesTests + Assert.IsTrue(processor.Executor.Value is RunSpecificTestsArgumentExecutor); + } - [TestMethod] - public void CapabilitiesShouldReturnAppropriateProperties() - { - RunSpecificTestsArgumentProcessorCapabilities capabilities = new RunSpecificTestsArgumentProcessorCapabilities(); - Assert.AreEqual("/Tests", capabilities.CommandName); - StringAssert.Contains(capabilities.HelpContentResourceName.NormalizeLineEndings(), - "/Tests:\r\n Run tests with names that match the provided values.".NormalizeLineEndings()); + #region RunSpecificTestsArgumentProcessorCapabilitiesTests - Assert.AreEqual(HelpContentPriority.RunSpecificTestsArgumentProcessorHelpPriority, capabilities.HelpPriority); - Assert.IsTrue(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.Normal, capabilities.Priority); + [TestMethod] + public void CapabilitiesShouldReturnAppropriateProperties() + { + RunSpecificTestsArgumentProcessorCapabilities capabilities = new(); + Assert.AreEqual("/Tests", capabilities.CommandName); + StringAssert.Contains(capabilities.HelpContentResourceName.NormalizeLineEndings(), + "/Tests:\r\n Run tests with names that match the provided values.".NormalizeLineEndings()); + + Assert.AreEqual(HelpContentPriority.RunSpecificTestsArgumentProcessorHelpPriority, capabilities.HelpPriority); + Assert.IsTrue(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.Normal, capabilities.Priority); + + Assert.IsFalse(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } + #endregion - Assert.IsFalse(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); - } - #endregion + #region RunSpecificTestsArgumentExecutorTests - #region RunSpecificTestsArgumentExecutorTests + [TestMethod] + public void InitializeShouldThrowIfArgumentIsNull() + { + CommandLineOptions.Instance.Reset(); - [TestMethod] - public void InitializeShouldThrowIfArgumentIsNull() - { - CommandLineOptions.Instance.Reset(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + Assert.ThrowsException(() => executor.Initialize(null)); + } - Assert.ThrowsException(() => { executor.Initialize(null); }); - } + [TestMethod] + public void InitializeShouldThrowIfArgumentIsEmpty() + { + CommandLineOptions.Instance.Reset(); - [TestMethod] - public void InitializeShouldThrowIfArgumentIsEmpty() - { - CommandLineOptions.Instance.Reset(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + Assert.ThrowsException(() => executor.Initialize(String.Empty)); + } - Assert.ThrowsException(() => { executor.Initialize(String.Empty); }); - } + [TestMethod] + public void InitializeShouldThrowIfArgumentIsWhiteSpace() + { + CommandLineOptions.Instance.Reset(); - [TestMethod] - public void InitializeShouldThrowIfArgumentIsWhiteSpace() - { - CommandLineOptions.Instance.Reset(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + Assert.ThrowsException(() => executor.Initialize(" ")); + } - Assert.ThrowsException(() => { executor.Initialize(" "); }); - } + [TestMethod] + public void InitializeShouldThrowIfArgumentsAreEmpty() + { + CommandLineOptions.Instance.Reset(); - [TestMethod] - public void InitializeShouldThrowIfArgumentsAreEmpty() - { - CommandLineOptions.Instance.Reset(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + Assert.ThrowsException(() => executor.Initialize(" , ")); + } - Assert.ThrowsException(() => { executor.Initialize(" , "); }); - } + [TestMethod] + public void ExecutorShouldSplitTestsSeparatedByComma() + { + CommandLineOptions.Instance.Reset(); - [TestMethod] - public void ExecutorShouldSplitTestsSeparatedByComma() - { - CommandLineOptions.Instance.Reset(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + Assert.ThrowsException(() => executor.Execute()); + } - Assert.ThrowsException(() => executor.Execute()); - } + [TestMethod] + public void ExecutorExecuteForNoSourcesShouldThrowCommandLineException() + { + CommandLineOptions.Instance.Reset(); - [TestMethod] - public void ExecutorExecuteForNoSourcesShouldThrowCommandLineException() - { - CommandLineOptions.Instance.Reset(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + Assert.ThrowsException(() => executor.Execute()); + } - Assert.ThrowsException(() => executor.Execute()); - } + [TestMethod] + public void ExecutorExecuteForValidSourceWithTestCaseFilterShouldRunTests() + { + var mockTestPlatform = new Mock(); + var mockTestRunRequest = new Mock(); + var mockDiscoveryRequest = new Mock(); - [TestMethod] - public void ExecutorExecuteForValidSourceWithTestCaseFilterShouldRunTests() - { - var mockTestPlatform = new Mock(); - var mockTestRunRequest = new Mock(); - var mockDiscoveryRequest = new Mock(); + ResetAndAddSourceToCommandLineOptions(); - this.ResetAndAddSourceToCommandLineOptions(); + List list = new() + { + new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1"), + new TestCase("Test2", new Uri("http://FooTestUri1"), "Source1") + }; + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); - List list = new List(); - list.Add(new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1")); - list.Add(new TestCase("Test2", new Uri("http://FooTestUri1"), "Source1")); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); + mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + CommandLineOptions.Instance.TestCaseFilterValue = "Filter"; + executor.Initialize("Test1"); + ArgumentProcessorResult argumentProcessorResult = executor.Execute(); - CommandLineOptions.Instance.TestCaseFilterValue = "Filter"; - executor.Initialize("Test1"); - ArgumentProcessorResult argumentProcessorResult = executor.Execute(); + _mockOutput.Verify(o => o.WriteLine(It.IsAny(), OutputLevel.Warning), Times.Never); + mockTestPlatform.Verify(o => o.CreateDiscoveryRequest(It.IsAny(), It.Is(c => c.TestCaseFilter == "Filter"), It.IsAny()), Times.Once()); + Assert.AreEqual(ArgumentProcessorResult.Success, argumentProcessorResult); + } - mockOutput.Verify(o => o.WriteLine(It.IsAny(), OutputLevel.Warning), Times.Never); - mockTestPlatform.Verify(o => o.CreateDiscoveryRequest(It.IsAny(), It.Is(c => c.TestCaseFilter == "Filter"), It.IsAny()), Times.Once()); - Assert.AreEqual(ArgumentProcessorResult.Success, argumentProcessorResult); - } + [TestMethod] + public void ExecutorExecuteShouldThrowTestPlatformExceptionThrownDuringDiscovery() + { + var mockTestPlatform = new Mock(); + var mockTestRunRequest = new Mock(); + var mockDiscoveryRequest = new Mock(); - [TestMethod] - public void ExecutorExecuteShouldThrowTestPlatformExceptionThrownDuringDiscovery() - { - var mockTestPlatform = new Mock(); - var mockTestRunRequest = new Mock(); - var mockDiscoveryRequest = new Mock(); + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new TestPlatformException("DummyTestPlatformException")); + mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new TestPlatformException("DummyTestPlatformException")); - mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + ResetAndAddSourceToCommandLineOptions(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - this.ResetAndAddSourceToCommandLineOptions(); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + Assert.ThrowsException(() => executor.Execute()); + } - Assert.ThrowsException(() => executor.Execute()); - } + [TestMethod] + public void ExecutorExecuteShouldThrowInvalidOperationExceptionThrownDuringDiscovery() + { + var mockTestPlatform = new Mock(); + var mockTestRunRequest = new Mock(); + var mockDiscoveryRequest = new Mock(); - [TestMethod] - public void ExecutorExecuteShouldThrowInvalidOperationExceptionThrownDuringDiscovery() - { - var mockTestPlatform = new Mock(); - var mockTestRunRequest = new Mock(); - var mockDiscoveryRequest = new Mock(); + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new InvalidOperationException("DummyInvalidOperationException")); + mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new InvalidOperationException("DummyInvalidOperationException")); - mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + ResetAndAddSourceToCommandLineOptions(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - this.ResetAndAddSourceToCommandLineOptions(); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + Assert.ThrowsException(() => executor.Execute()); + } - Assert.ThrowsException(() => executor.Execute()); - } + [TestMethod] + public void ExecutorExecuteShouldThrowSettingsExceptionThrownDuringDiscovery() + { + var mockTestPlatform = new Mock(); + var mockTestRunRequest = new Mock(); + var mockDiscoveryRequest = new Mock(); - [TestMethod] - public void ExecutorExecuteShouldThrowSettingsExceptionThrownDuringDiscovery() - { - var mockTestPlatform = new Mock(); - var mockTestRunRequest = new Mock(); - var mockDiscoveryRequest = new Mock(); + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new SettingsException("DummySettingsException")); + mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Throws(new SettingsException("DummySettingsException")); - mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + ResetAndAddSourceToCommandLineOptions(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - this.ResetAndAddSourceToCommandLineOptions(); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + Assert.ThrowsException(() => executor.Execute()); + } - Assert.ThrowsException(() => executor.Execute()); - } + [TestMethod] + public void ExecutorExecuteShouldThrowTestPlatformExceptionThrownDuringExecution() + { + var mockTestPlatform = new Mock(); + var mockTestRunRequest = new Mock(); + var mockDiscoveryRequest = new Mock(); - [TestMethod] - public void ExecutorExecuteShouldThrowTestPlatformExceptionThrownDuringExecution() + List list = new() { - var mockTestPlatform = new Mock(); - var mockTestRunRequest = new Mock(); - var mockDiscoveryRequest = new Mock(); + new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1"), + new TestCase("Test2", new Uri("http://FooTestUri2"), "Source2") + }; + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); - List list = new List(); - list.Add(new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1")); - list.Add(new TestCase("Test2", new Uri("http://FooTestUri2"), "Source2")); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); + mockTestRunRequest.Setup(dr => dr.ExecuteAsync()).Throws(new TestPlatformException("DummyTestPlatformException")); + mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - mockTestRunRequest.Setup(dr => dr.ExecuteAsync()).Throws(new TestPlatformException("DummyTestPlatformException")); - mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + ResetAndAddSourceToCommandLineOptions(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - this.ResetAndAddSourceToCommandLineOptions(); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + executor.Initialize("Test1"); - executor.Initialize("Test1"); + Assert.ThrowsException(() => executor.Execute()); + } - Assert.ThrowsException(() => executor.Execute()); - } + [TestMethod] + public void ExecutorExecuteShouldThrowSettingsExceptionThrownDuringExecution() + { + var mockTestPlatform = new Mock(); + var mockTestRunRequest = new Mock(); + var mockDiscoveryRequest = new Mock(); - [TestMethod] - public void ExecutorExecuteShouldThrowSettingsExceptionThrownDuringExecution() + List list = new() { - var mockTestPlatform = new Mock(); - var mockTestRunRequest = new Mock(); - var mockDiscoveryRequest = new Mock(); + new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1"), + new TestCase("Test2", new Uri("http://FooTestUri2"), "Source2") + }; + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); - List list = new List(); - list.Add(new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1")); - list.Add(new TestCase("Test2", new Uri("http://FooTestUri2"), "Source2")); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); + mockTestRunRequest.Setup(dr => dr.ExecuteAsync()).Throws(new SettingsException("DummySettingsException")); + mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - mockTestRunRequest.Setup(dr => dr.ExecuteAsync()).Throws(new SettingsException("DummySettingsException")); - mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + ResetAndAddSourceToCommandLineOptions(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - this.ResetAndAddSourceToCommandLineOptions(); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + executor.Initialize("Test1"); - executor.Initialize("Test1"); + Assert.ThrowsException(() => executor.Execute()); + } - Assert.ThrowsException(() => executor.Execute()); - } + [TestMethod] + public void ExecutorExecuteShouldThrowInvalidOperationExceptionThrownDuringExecution() + { + var mockTestPlatform = new Mock(); + var mockTestRunRequest = new Mock(); + var mockDiscoveryRequest = new Mock(); - [TestMethod] - public void ExecutorExecuteShouldThrowInvalidOperationExceptionThrownDuringExecution() + List list = new() { - var mockTestPlatform = new Mock(); - var mockTestRunRequest = new Mock(); - var mockDiscoveryRequest = new Mock(); + new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1"), + new TestCase("Test2", new Uri("http://FooTestUri2"), "Source2") + }; + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); - List list = new List(); - list.Add(new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1")); - list.Add(new TestCase("Test2", new Uri("http://FooTestUri2"), "Source2")); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); + mockTestRunRequest.Setup(dr => dr.ExecuteAsync()).Throws(new InvalidOperationException("DummySettingsException")); + mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - mockTestRunRequest.Setup(dr => dr.ExecuteAsync()).Throws(new InvalidOperationException("DummySettingsException")); - mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + ResetAndAddSourceToCommandLineOptions(); - this.ResetAndAddSourceToCommandLineOptions(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + executor.Initialize("Test1"); - executor.Initialize("Test1"); + Assert.ThrowsException(() => executor.Execute()); + } - Assert.ThrowsException(() => executor.Execute()); - } + [TestMethod] + public void ExecutorExecuteShouldForValidSourcesAndNoTestsDiscoveredShouldLogWarningAndReturnSuccess() + { + var mockTestPlatform = new Mock(); + var mockDiscoveryRequest = new Mock(); - [TestMethod] - public void ExecutorExecuteShouldForValidSourcesAndNoTestsDiscoveredShouldLogWarningAndReturnSuccess() - { - var mockTestPlatform = new Mock(); - var mockDiscoveryRequest = new Mock(); + ResetAndAddSourceToCommandLineOptions(); - this.ResetAndAddSourceToCommandLineOptions(); + // Setting some test adapter path + CommandLineOptions.Instance.TestAdapterPath = @"C:\Foo"; - // Setting some test adapter path - CommandLineOptions.Instance.TestAdapterPath = @"C:\Foo"; + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(new List())); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(new List())); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + executor.Initialize("Test1"); + ArgumentProcessorResult argumentProcessorResult = executor.Execute(); - executor.Initialize("Test1"); - ArgumentProcessorResult argumentProcessorResult = executor.Execute(); + _mockOutput.Verify(o => o.WriteLine("Starting test discovery, please wait...", OutputLevel.Information), Times.Once); + _mockOutput.Verify(o => o.WriteLine(NoDiscoveredTestsWarning, OutputLevel.Warning), Times.Once); + Assert.AreEqual(ArgumentProcessorResult.Success, argumentProcessorResult); + } + + [TestMethod] + public void ExecutorExecuteShouldForValidSourcesAndNoTestsDiscoveredShouldLogAppropriateWarningIfTestAdapterPathIsNotSetAndReturnSuccess() + { + var mockTestPlatform = new Mock(); + var mockDiscoveryRequest = new Mock(); - this.mockOutput.Verify(o => o.WriteLine("Starting test discovery, please wait...", OutputLevel.Information), Times.Once); - this.mockOutput.Verify(o => o.WriteLine(NoDiscoveredTestsWarning, OutputLevel.Warning), Times.Once); - Assert.AreEqual(ArgumentProcessorResult.Success, argumentProcessorResult); - } + ResetAndAddSourceToCommandLineOptions(); - [TestMethod] - public void ExecutorExecuteShouldForValidSourcesAndNoTestsDiscoveredShouldLogAppropriateWarningIfTestAdapterPathIsNotSetAndReturnSuccess() - { - var mockTestPlatform = new Mock(); - var mockDiscoveryRequest = new Mock(); + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(new List())); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - this.ResetAndAddSourceToCommandLineOptions(); + executor.Initialize("Test1"); + ArgumentProcessorResult argumentProcessorResult = executor.Execute(); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(new List())); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + _mockOutput.Verify(o => o.WriteLine("Starting test discovery, please wait...", OutputLevel.Information), Times.Once); + _mockOutput.Verify(o => o.WriteLine(NoDiscoveredTestsWarning + " " + TestAdapterPathSuggestion, OutputLevel.Warning), Times.Once); + Assert.AreEqual(ArgumentProcessorResult.Success, argumentProcessorResult); + } - executor.Initialize("Test1"); - ArgumentProcessorResult argumentProcessorResult = executor.Execute(); + [TestMethod] + public void ExecutorExecuteShouldForValidSourcesAndValidSelectedTestsRunsTestsAndReturnSuccess() + { + var mockTestPlatform = new Mock(); + var mockTestRunRequest = new Mock(); + var mockDiscoveryRequest = new Mock(); - this.mockOutput.Verify(o => o.WriteLine("Starting test discovery, please wait...", OutputLevel.Information), Times.Once); - this.mockOutput.Verify(o => o.WriteLine(NoDiscoveredTestsWarning + " " + TestAdapterPathSuggestion, OutputLevel.Warning), Times.Once); - Assert.AreEqual(ArgumentProcessorResult.Success, argumentProcessorResult); - } + ResetAndAddSourceToCommandLineOptions(); - [TestMethod] - public void ExecutorExecuteShouldForValidSourcesAndValidSelectedTestsRunsTestsAndReturnSuccess() + List list = new() { - var mockTestPlatform = new Mock(); - var mockTestRunRequest = new Mock(); - var mockDiscoveryRequest = new Mock(); + new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1") + }; + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); - this.ResetAndAddSourceToCommandLineOptions(); + mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - List list = new List(); - list.Add(new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1")); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + executor.Initialize("Test1"); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + ArgumentProcessorResult argumentProcessorResult = executor.Execute(); + Assert.AreEqual(ArgumentProcessorResult.Success, argumentProcessorResult); + } - executor.Initialize("Test1"); + [TestMethod] + public void ExecutorShouldRunTestsWhenTestsAreCommaSeparated() + { + var mockTestPlatform = new Mock(); + var mockTestRunRequest = new Mock(); + var mockDiscoveryRequest = new Mock(); - ArgumentProcessorResult argumentProcessorResult = executor.Execute(); - Assert.AreEqual(ArgumentProcessorResult.Success, argumentProcessorResult); - } + ResetAndAddSourceToCommandLineOptions(); - [TestMethod] - public void ExecutorShouldRunTestsWhenTestsAreCommaSeparated() + List list = new() { - var mockTestPlatform = new Mock(); - var mockTestRunRequest = new Mock(); - var mockDiscoveryRequest = new Mock(); + new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1"), + new TestCase("Test2", new Uri("http://FooTestUri1"), "Source1") + }; + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); - ResetAndAddSourceToCommandLineOptions(); + mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - List list = new List(); - list.Add(new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1")); - list.Add(new TestCase("Test2", new Uri("http://FooTestUri1"), "Source1")); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + executor.Initialize("Test1, Test2"); + ArgumentProcessorResult argumentProcessorResult = executor.Execute(); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + _mockOutput.Verify(o => o.WriteLine(It.IsAny(), OutputLevel.Warning), Times.Never); + Assert.AreEqual(ArgumentProcessorResult.Success, argumentProcessorResult); + } - executor.Initialize("Test1, Test2"); - ArgumentProcessorResult argumentProcessorResult = executor.Execute(); + [TestMethod] + public void ExecutorShouldRunTestsWhenTestsAreFiltered() + { + var mockTestPlatform = new Mock(); + var mockTestRunRequest = new Mock(); + var mockDiscoveryRequest = new Mock(); - mockOutput.Verify(o => o.WriteLine(It.IsAny(), OutputLevel.Warning), Times.Never); - Assert.AreEqual(ArgumentProcessorResult.Success, argumentProcessorResult); - } + ResetAndAddSourceToCommandLineOptions(); - [TestMethod] - public void ExecutorShouldRunTestsWhenTestsAreFiltered() + List list = new() { - var mockTestPlatform = new Mock(); - var mockTestRunRequest = new Mock(); - var mockDiscoveryRequest = new Mock(); + new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1"), + new TestCase("Test2", new Uri("http://FooTestUri1"), "Source1") + }; + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); - ResetAndAddSourceToCommandLineOptions(); + mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - List list = new List(); - list.Add(new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1")); - list.Add(new TestCase("Test2", new Uri("http://FooTestUri1"), "Source1")); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + executor.Initialize("Test1"); + ArgumentProcessorResult argumentProcessorResult = executor.Execute(); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + _mockOutput.Verify(o => o.WriteLine(It.IsAny(), OutputLevel.Warning), Times.Never); + Assert.AreEqual(ArgumentProcessorResult.Success, argumentProcessorResult); + } - executor.Initialize("Test1"); - ArgumentProcessorResult argumentProcessorResult = executor.Execute(); + [TestMethod] + public void ExecutorShouldWarnWhenTestsAreNotAvailable() + { + var mockTestPlatform = new Mock(); + var mockTestRunRequest = new Mock(); + var mockDiscoveryRequest = new Mock(); - mockOutput.Verify(o => o.WriteLine(It.IsAny(), OutputLevel.Warning), Times.Never); - Assert.AreEqual(ArgumentProcessorResult.Success, argumentProcessorResult); - } + ResetAndAddSourceToCommandLineOptions(); - [TestMethod] - public void ExecutorShouldWarnWhenTestsAreNotAvailable() + List list = new() { - var mockTestPlatform = new Mock(); - var mockTestRunRequest = new Mock(); - var mockDiscoveryRequest = new Mock(); + new TestCase("Test2", new Uri("http://FooTestUri1"), "Source1") + }; + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); - ResetAndAddSourceToCommandLineOptions(); + mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - List list = new List(); - list.Add(new TestCase("Test2", new Uri("http://FooTestUri1"), "Source1")); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + executor.Initialize("Test1, Test2"); + ArgumentProcessorResult argumentProcessorResult = executor.Execute(); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + _mockOutput.Verify(o => o.WriteLine("A total of 1 tests were discovered but some tests do not match the specified selection criteria(Test1). Use right value(s) and try again.", OutputLevel.Warning), Times.Once); + Assert.AreEqual(ArgumentProcessorResult.Success, argumentProcessorResult); + } - executor.Initialize("Test1, Test2"); - ArgumentProcessorResult argumentProcessorResult = executor.Execute(); + [TestMethod] + public void ExecutorShouldRunTestsWhenTestsAreCommaSeparatedWithEscape() + { + var mockTestPlatform = new Mock(); + var mockTestRunRequest = new Mock(); + var mockDiscoveryRequest = new Mock(); - mockOutput.Verify(o => o.WriteLine("A total of 1 tests were discovered but some tests do not match the specified selection criteria(Test1). Use right value(s) and try again.", OutputLevel.Warning), Times.Once); - Assert.AreEqual(ArgumentProcessorResult.Success, argumentProcessorResult); - } + ResetAndAddSourceToCommandLineOptions(); - [TestMethod] - public void ExecutorShouldRunTestsWhenTestsAreCommaSeparatedWithEscape() + List list = new() { - var mockTestPlatform = new Mock(); - var mockTestRunRequest = new Mock(); - var mockDiscoveryRequest = new Mock(); + new TestCase("Test1(a,b)", new Uri("http://FooTestUri1"), "Source1"), + new TestCase("Test2(c,d)", new Uri("http://FooTestUri1"), "Source1") + }; + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); - ResetAndAddSourceToCommandLineOptions(); + mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - List list = new List(); - list.Add(new TestCase("Test1(a,b)", new Uri("http://FooTestUri1"), "Source1")); - list.Add(new TestCase("Test2(c,d)", new Uri("http://FooTestUri1"), "Source1")); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + executor.Initialize("Test1(a\\,b), Test2(c\\,d)"); + ArgumentProcessorResult argumentProcessorResult = executor.Execute(); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); - - executor.Initialize("Test1(a\\,b), Test2(c\\,d)"); - ArgumentProcessorResult argumentProcessorResult = executor.Execute(); + _mockOutput.Verify(o => o.WriteLine(It.IsAny(), OutputLevel.Warning), Times.Never); + Assert.AreEqual(ArgumentProcessorResult.Success, argumentProcessorResult); + } - mockOutput.Verify(o => o.WriteLine(It.IsAny(), OutputLevel.Warning), Times.Never); - Assert.AreEqual(ArgumentProcessorResult.Success, argumentProcessorResult); - } + [TestMethod] + public void ExecutorShouldDisplayWarningIfNoTestsAreExecuted() + { + var mockTestPlatform = new Mock(); + var mockTestRunRequest = new Mock(); + var mockDiscoveryRequest = new Mock(); + var mockTestRunStats = new Mock(); - [TestMethod] - public void ExecutorShouldDisplayWarningIfNoTestsAreExecuted() + List list = new() { - var mockTestPlatform = new Mock(); - var mockTestRunRequest = new Mock(); - var mockDiscoveryRequest = new Mock(); - var mockTestRunStats = new Mock(); + new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1"), + new TestCase("Test2", new Uri("http://FooTestUri2"), "Source2") + }; + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); - List list = new List(); - list.Add(new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1")); - list.Add(new TestCase("Test2", new Uri("http://FooTestUri2"), "Source2")); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); + mockTestRunRequest.Setup(tr => tr.ExecuteAsync()).Returns(1).Raises(tr => tr.OnRunCompletion += null, + new TestRunCompleteEventArgs(mockTestRunStats.Object, false, false, null, null, null, new TimeSpan())); - mockTestRunRequest.Setup(tr => tr.ExecuteAsync()).Returns(1).Raises(tr => tr.OnRunCompletion += null, - new TestRunCompleteEventArgs(mockTestRunStats.Object, false, false, null, null, null, new TimeSpan())); + mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + ResetAndAddSourceToCommandLineOptions(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - this.ResetAndAddSourceToCommandLineOptions(); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + executor.Initialize("Test1"); + executor.Execute(); - executor.Initialize("Test1"); - executor.Execute(); + _mockOutput.Verify(op => op.WriteLine(It.Is(st => st.Contains("Additionally, path to test adapters can be specified using /TestAdapterPath command.")), OutputLevel.Warning), Times.Once); + } - this.mockOutput.Verify(op => op.WriteLine(It.Is(st => st.Contains("Additionally, path to test adapters can be specified using /TestAdapterPath command.")), OutputLevel.Warning), Times.Once); - } + [TestMethod] + public void ExecutorShouldNotDisplayWarningIfTestsAreExecuted() + { + var mockTestPlatform = new Mock(); + var mockTestRunRequest = new Mock(); + var mockDiscoveryRequest = new Mock(); + var testRunStats = new TestRunStatistics(1, new Dictionary { { TestOutcome.Passed, 1 } }); - [TestMethod] - public void ExecutorShouldNotDisplayWarningIfTestsAreExecuted() + List list = new() { - var mockTestPlatform = new Mock(); - var mockTestRunRequest = new Mock(); - var mockDiscoveryRequest = new Mock(); - var testRunStats = new TestRunStatistics(1, new Dictionary { { TestOutcome.Passed, 1 } }); + new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1"), + new TestCase("Test2", new Uri("http://FooTestUri2"), "Source2") + }; + mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); - List list = new List(); - list.Add(new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1")); - list.Add(new TestCase("Test2", new Uri("http://FooTestUri2"), "Source2")); - mockDiscoveryRequest.Setup(dr => dr.DiscoverAsync()).Raises(dr => dr.OnDiscoveredTests += null, new DiscoveredTestsEventArgs(list)); + mockTestRunRequest.Setup(tr => tr.ExecuteAsync()).Returns(1).Raises(tr => tr.OnRunCompletion += null, + new TestRunCompleteEventArgs(testRunStats, false, false, null, null, null, new TimeSpan())); - mockTestRunRequest.Setup(tr => tr.ExecuteAsync()).Returns(1).Raises(tr => tr.OnRunCompletion += null, - new TestRunCompleteEventArgs(testRunStats, false, false, null, null, null, new TimeSpan())); + mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); + mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); - mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); - mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockDiscoveryRequest.Object); + ResetAndAddSourceToCommandLineOptions(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - this.ResetAndAddSourceToCommandLineOptions(); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + executor.Initialize("Test1"); + executor.Execute(); - executor.Initialize("Test1"); - executor.Execute(); - - this.mockOutput.Verify(op => op.WriteLine(It.Is(st => st.Contains("Additionally, path to test adapters can be specified using /TestAdapterPath command.")), OutputLevel.Warning), Times.Never); - } + _mockOutput.Verify(op => op.WriteLine(It.Is(st => st.Contains("Additionally, path to test adapters can be specified using /TestAdapterPath command.")), OutputLevel.Warning), Times.Never); + } - #endregion + #endregion - private void ResetAndAddSourceToCommandLineOptions() - { - CommandLineOptions.Instance.Reset(); - CommandLineOptions.Instance.TestCaseFilterValue = null; - CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, this.mockFileHelper.Object); - CommandLineOptions.Instance.FileHelper = this.mockFileHelper.Object; - CommandLineOptions.Instance.AddSource(this.dummyTestFilePath); - } + private void ResetAndAddSourceToCommandLineOptions() + { + CommandLineOptions.Instance.Reset(); + CommandLineOptions.Instance.TestCaseFilterValue = null; + CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, _mockFileHelper.Object); + CommandLineOptions.Instance.FileHelper = _mockFileHelper.Object; + CommandLineOptions.Instance.AddSource(_dummyTestFilePath); } -} +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs index 4a58431e54..4ec483fcba 100644 --- a/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs @@ -3,330 +3,333 @@ using Microsoft.VisualStudio.TestPlatform.CommandLineUtilities; -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Runtime.Versioning; +using System.Threading.Tasks; + +using Extensions.FileSystemGlobbing; +using Client; +using Client.RequestHelper; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using Publisher; +using TestPlatformHelpers; +using Common.ExtensionFramework; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using CoreUtilities.Tracing.Interfaces; +using ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using ObjectModel.Engine; +using ObjectModel.Logging; +using PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using TestTools.UnitTesting; + +using Moq; + +using vstest.console.Internal; +using vstest.console.UnitTests.Processors; + +/// +/// Tests for RunTestsArgumentProcessor +/// +[TestClass] +public class RunTestsArgumentProcessorTests { - using System; - using System.Collections.Generic; - using System.IO; - using System.Reflection; - using System.Runtime.Versioning; - using System.Threading.Tasks; - using Microsoft.Extensions.FileSystemGlobbing; - using Microsoft.VisualStudio.TestPlatform.Client; - using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Publisher; - using Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers; - using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using vstest.console.Internal; - using vstest.console.UnitTests.Processors; - - /// - /// Tests for RunTestsArgumentProcessor - /// - [TestClass] - public class RunTestsArgumentProcessorTests + private readonly Mock _mockFileHelper; + private readonly Mock _mockOutput; + private readonly Mock _mockAssemblyMetadataProvider; + private readonly InferHelper _inferHelper; + private readonly string _dummyTestFilePath = "DummyTest.dll"; + private readonly Mock _mockTestPlatformEventSource; + private readonly Task _mockMetricsPublisherTask; + private readonly Mock _mockMetricsPublisher; + private readonly Mock _mockProcessHelper; + private readonly Mock _mockAttachmentsProcessingManager; + + public RunTestsArgumentProcessorTests() { - private readonly Mock mockFileHelper; - private readonly Mock mockOutput; - private Mock mockAssemblyMetadataProvider; - private InferHelper inferHelper; - private string dummyTestFilePath = "DummyTest.dll"; - private Mock mockTestPlatformEventSource; - private Task mockMetricsPublisherTask; - private Mock mockMetricsPublisher; - private Mock mockProcessHelper; - private Mock mockAttachmentsProcessingManager; - - public RunTestsArgumentProcessorTests() - { - this.mockFileHelper = new Mock(); - this.mockOutput = new Mock(); - this.mockFileHelper.Setup(fh => fh.Exists(this.dummyTestFilePath)).Returns(true); - this.mockFileHelper.Setup(x => x.GetCurrentDirectory()).Returns(""); - this.mockMetricsPublisher = new Mock(); - this.mockMetricsPublisherTask = Task.FromResult(this.mockMetricsPublisher.Object); - this.mockTestPlatformEventSource = new Mock(); - this.mockAssemblyMetadataProvider = new Mock(); - this.inferHelper = new InferHelper(this.mockAssemblyMetadataProvider.Object); - SetupMockExtensions(); - this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) - .Returns(Architecture.X86); - this.mockAssemblyMetadataProvider.Setup(x => x.GetFrameWork(It.IsAny())).Returns(new FrameworkName(Constants.DotNetFramework40)); - this.mockProcessHelper = new Mock(); - this.mockAttachmentsProcessingManager = new Mock(); - } + _mockFileHelper = new Mock(); + _mockOutput = new Mock(); + _mockFileHelper.Setup(fh => fh.Exists(_dummyTestFilePath)).Returns(true); + _mockFileHelper.Setup(x => x.GetCurrentDirectory()).Returns(""); + _mockMetricsPublisher = new Mock(); + _mockMetricsPublisherTask = Task.FromResult(_mockMetricsPublisher.Object); + _mockTestPlatformEventSource = new Mock(); + _mockAssemblyMetadataProvider = new Mock(); + _inferHelper = new InferHelper(_mockAssemblyMetadataProvider.Object); + SetupMockExtensions(); + _mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) + .Returns(Architecture.X86); + _mockAssemblyMetadataProvider.Setup(x => x.GetFrameWork(It.IsAny())).Returns(new FrameworkName(Constants.DotNetFramework40)); + _mockProcessHelper = new Mock(); + _mockAttachmentsProcessingManager = new Mock(); + } - [TestMethod] - public void GetMetadataShouldReturnRunTestsArgumentProcessorCapabilities() - { - RunTestsArgumentProcessor processor = new RunTestsArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is RunTestsArgumentProcessorCapabilities); - } + [TestMethod] + public void GetMetadataShouldReturnRunTestsArgumentProcessorCapabilities() + { + RunTestsArgumentProcessor processor = new(); + Assert.IsTrue(processor.Metadata.Value is RunTestsArgumentProcessorCapabilities); + } - [TestMethod] - public void GetExecuterShouldReturnRunTestsArgumentProcessorCapabilities() - { - RunTestsArgumentProcessor processor = new RunTestsArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is RunTestsArgumentExecutor); - } + [TestMethod] + public void GetExecuterShouldReturnRunTestsArgumentProcessorCapabilities() + { + RunTestsArgumentProcessor processor = new(); + Assert.IsTrue(processor.Executor.Value is RunTestsArgumentExecutor); + } - #region RunTestsArgumentProcessorCapabilitiesTests + #region RunTestsArgumentProcessorCapabilitiesTests - [TestMethod] - public void CapabilitiesShouldReturnAppropriateProperties() - { - RunTestsArgumentProcessorCapabilities capabilities = new RunTestsArgumentProcessorCapabilities(); - Assert.AreEqual("/RunTests", capabilities.CommandName); - var expected = "[TestFileNames]\r\n Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern\r\n by spaces. Set console logger verbosity to detailed to view matched test files.\r\n Examples: mytestproject.dll\r\n mytestproject.dll myothertestproject.exe\r\n testproject*.dll my*project.dll"; - Assert.AreEqual(expected.NormalizeLineEndings().ShowWhiteSpace(), capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); - - Assert.AreEqual(HelpContentPriority.RunTestsArgumentProcessorHelpPriority, capabilities.HelpPriority); - Assert.IsTrue(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.Normal, capabilities.Priority); - - Assert.IsFalse(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsTrue(capabilities.IsSpecialCommand); - } - #endregion + [TestMethod] + public void CapabilitiesShouldReturnAppropriateProperties() + { + RunTestsArgumentProcessorCapabilities capabilities = new(); + Assert.AreEqual("/RunTests", capabilities.CommandName); + var expected = "[TestFileNames]\r\n Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern\r\n by spaces. Set console logger verbosity to detailed to view matched test files.\r\n Examples: mytestproject.dll\r\n mytestproject.dll myothertestproject.exe\r\n testproject*.dll my*project.dll"; + Assert.AreEqual(expected.NormalizeLineEndings().ShowWhiteSpace(), capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); + + Assert.AreEqual(HelpContentPriority.RunTestsArgumentProcessorHelpPriority, capabilities.HelpPriority); + Assert.IsTrue(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.Normal, capabilities.Priority); + + Assert.IsFalse(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsTrue(capabilities.IsSpecialCommand); + } + #endregion - #region RunTestsArgumentExecutorTests + #region RunTestsArgumentExecutorTests - [TestMethod] - public void ExecutorExecuteShouldReturnSuccessWithoutExecutionInDesignMode() - { - var runSettingsProvider = new TestableRunSettingsProvider(); - runSettingsProvider.UpdateRunSettings(""); + [TestMethod] + public void ExecutorExecuteShouldReturnSuccessWithoutExecutionInDesignMode() + { + var runSettingsProvider = new TestableRunSettingsProvider(); + runSettingsProvider.UpdateRunSettings(""); - CommandLineOptions.Instance.Reset(); - CommandLineOptions.Instance.IsDesignMode = true; - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = new RunTestsArgumentExecutor(CommandLineOptions.Instance, runSettingsProvider, testRequestManager, this.mockOutput.Object); + CommandLineOptions.Instance.Reset(); + CommandLineOptions.Instance.IsDesignMode = true; + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = new RunTestsArgumentExecutor(CommandLineOptions.Instance, runSettingsProvider, testRequestManager, _mockOutput.Object); - Assert.AreEqual(ArgumentProcessorResult.Success, executor.Execute()); - } + Assert.AreEqual(ArgumentProcessorResult.Success, executor.Execute()); + } - [TestMethod] - public void ExecutorExecuteForNoSourcesShouldThrowCommandLineException() - { - CommandLineOptions.Instance.Reset(); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + [TestMethod] + public void ExecutorExecuteForNoSourcesShouldThrowCommandLineException() + { + CommandLineOptions.Instance.Reset(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - Assert.ThrowsException(() => executor.Execute()); - } + Assert.ThrowsException(() => executor.Execute()); + } - private RunTestsArgumentExecutor GetExecutor(ITestRequestManager testRequestManager) - { - var runSettingsProvider = new TestableRunSettingsProvider(); - runSettingsProvider.AddDefaultRunSettings(); - var executor = new RunTestsArgumentExecutor( - CommandLineOptions.Instance, - runSettingsProvider, - testRequestManager, - this.mockOutput.Object - ); - return executor; - } + private RunTestsArgumentExecutor GetExecutor(ITestRequestManager testRequestManager) + { + var runSettingsProvider = new TestableRunSettingsProvider(); + runSettingsProvider.AddDefaultRunSettings(); + var executor = new RunTestsArgumentExecutor( + CommandLineOptions.Instance, + runSettingsProvider, + testRequestManager, + _mockOutput.Object + ); + return executor; + } - [TestMethod] - public void ExecutorExecuteShouldThrowTestPlatformException() - { - var mockTestPlatform = new Mock(); - var mockTestRunRequest = new Mock(); + [TestMethod] + public void ExecutorExecuteShouldThrowTestPlatformException() + { + var mockTestPlatform = new Mock(); + var mockTestRunRequest = new Mock(); - mockTestRunRequest.Setup(tr => tr.ExecuteAsync()).Throws(new TestPlatformException("DummyTestPlatformException")); - mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); + mockTestRunRequest.Setup(tr => tr.ExecuteAsync()).Throws(new TestPlatformException("DummyTestPlatformException")); + mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); - this.ResetAndAddSourceToCommandLineOptions(); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + ResetAndAddSourceToCommandLineOptions(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - Assert.ThrowsException(() => executor.Execute()); - } + Assert.ThrowsException(() => executor.Execute()); + } - [TestMethod] - public void ExecutorExecuteShouldThrowSettingsException() - { - var mockTestPlatform = new Mock(); - var mockTestRunRequest = new Mock(); + [TestMethod] + public void ExecutorExecuteShouldThrowSettingsException() + { + var mockTestPlatform = new Mock(); + var mockTestRunRequest = new Mock(); - mockTestRunRequest.Setup(tr => tr.ExecuteAsync()).Throws(new SettingsException("DummySettingsException")); - mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); + mockTestRunRequest.Setup(tr => tr.ExecuteAsync()).Throws(new SettingsException("DummySettingsException")); + mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); - this.ResetAndAddSourceToCommandLineOptions(); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + ResetAndAddSourceToCommandLineOptions(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - Assert.ThrowsException(() => executor.Execute()); - } + Assert.ThrowsException(() => executor.Execute()); + } - [TestMethod] - public void ExecutorExecuteShouldThrowInvalidOperationException() - { - var mockTestPlatform = new Mock(); - var mockTestRunRequest = new Mock(); + [TestMethod] + public void ExecutorExecuteShouldThrowInvalidOperationException() + { + var mockTestPlatform = new Mock(); + var mockTestRunRequest = new Mock(); - mockTestRunRequest.Setup(tr => tr.ExecuteAsync()).Throws(new InvalidOperationException("DummyInvalidOperationException")); - mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); + mockTestRunRequest.Setup(tr => tr.ExecuteAsync()).Throws(new InvalidOperationException("DummyInvalidOperationException")); + mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); - this.ResetAndAddSourceToCommandLineOptions(); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + ResetAndAddSourceToCommandLineOptions(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - Assert.ThrowsException(() => executor.Execute()); - } + Assert.ThrowsException(() => executor.Execute()); + } - [TestMethod] - public void ExecutorExecuteShouldThrowOtherExceptions() - { - var mockTestPlatform = new Mock(); - var mockTestRunRequest = new Mock(); + [TestMethod] + public void ExecutorExecuteShouldThrowOtherExceptions() + { + var mockTestPlatform = new Mock(); + var mockTestRunRequest = new Mock(); - mockTestRunRequest.Setup(tr => tr.ExecuteAsync()).Throws(new Exception("DummyException")); - mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); + mockTestRunRequest.Setup(tr => tr.ExecuteAsync()).Throws(new Exception("DummyException")); + mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(mockTestRunRequest.Object); - this.ResetAndAddSourceToCommandLineOptions(); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + ResetAndAddSourceToCommandLineOptions(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - Assert.ThrowsException(() => executor.Execute()); - } + Assert.ThrowsException(() => executor.Execute()); + } - [TestMethod] - public void ExecutorExecuteShouldForListOfTestsReturnSuccess() - { - var mockTestRunRequest = new Mock(); + [TestMethod] + public void ExecutorExecuteShouldForListOfTestsReturnSuccess() + { + var mockTestRunRequest = new Mock(); - var result = this.RunRunArgumentProcessorExecuteWithMockSetup(mockTestRunRequest.Object); + var result = RunRunArgumentProcessorExecuteWithMockSetup(mockTestRunRequest.Object); - mockTestRunRequest.Verify(tr => tr.ExecuteAsync(), Times.Once); - Assert.AreEqual(ArgumentProcessorResult.Success, result); - } + mockTestRunRequest.Verify(tr => tr.ExecuteAsync(), Times.Once); + Assert.AreEqual(ArgumentProcessorResult.Success, result); + } - [TestMethod] - public void TestRunRequestManagerShouldInstrumentExecutionRequestStart() - { - var mockTestRunRequest = new Mock(); + [TestMethod] + public void TestRunRequestManagerShouldInstrumentExecutionRequestStart() + { + var mockTestRunRequest = new Mock(); - var result = this.RunRunArgumentProcessorExecuteWithMockSetup(mockTestRunRequest.Object); + var result = RunRunArgumentProcessorExecuteWithMockSetup(mockTestRunRequest.Object); - this.mockTestPlatformEventSource.Verify(x => x.ExecutionRequestStart(), Times.Once); - } + _mockTestPlatformEventSource.Verify(x => x.ExecutionRequestStart(), Times.Once); + } - [TestMethod] - public void TestRunRequestManagerShouldInstrumentExecutionRequestStop() - { - var mockTestRunRequest = new Mock(); + [TestMethod] + public void TestRunRequestManagerShouldInstrumentExecutionRequestStop() + { + var mockTestRunRequest = new Mock(); - var result = this.RunRunArgumentProcessorExecuteWithMockSetup(mockTestRunRequest.Object); + var result = RunRunArgumentProcessorExecuteWithMockSetup(mockTestRunRequest.Object); - this.mockTestPlatformEventSource.Verify(x => x.ExecutionRequestStop(), Times.Once); - } + _mockTestPlatformEventSource.Verify(x => x.ExecutionRequestStop(), Times.Once); + } + + #endregion - #endregion + private ArgumentProcessorResult RunRunArgumentProcessorExecuteWithMockSetup(ITestRunRequest testRunRequest) + { + var mockTestPlatform = new Mock(); + var mockConsoleOutput = new Mock(); - private ArgumentProcessorResult RunRunArgumentProcessorExecuteWithMockSetup(ITestRunRequest testRunRequest) + List list = new() { - var mockTestPlatform = new Mock(); - var mockConsoleOutput = new Mock(); + new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1"), + new TestCase("Test2", new Uri("http://FooTestUri2"), "Source2") + }; + var mockTestRunStats = new Mock(); - List list = new List(); - list.Add(new TestCase("Test1", new Uri("http://FooTestUri1"), "Source1")); - list.Add(new TestCase("Test2", new Uri("http://FooTestUri2"), "Source2")); - var mockTestRunStats = new Mock(); + var args = new TestRunCompleteEventArgs(mockTestRunStats.Object, false, false, null, null, null, new TimeSpan()); - var args = new TestRunCompleteEventArgs(mockTestRunStats.Object, false, false, null, null, null, new TimeSpan()); + mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(testRunRequest); - mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Returns(testRunRequest); + ResetAndAddSourceToCommandLineOptions(); - this.ResetAndAddSourceToCommandLineOptions(); + var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, _mockTestPlatformEventSource.Object, _inferHelper, _mockMetricsPublisherTask, _mockProcessHelper.Object, _mockAttachmentsProcessingManager.Object); + var executor = GetExecutor(testRequestManager); - var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, mockTestPlatform.Object, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask, this.mockProcessHelper.Object, this.mockAttachmentsProcessingManager.Object); - var executor = GetExecutor(testRequestManager); + return executor.Execute(); + } - return executor.Execute(); - } + private void ResetAndAddSourceToCommandLineOptions() + { + CommandLineOptions.Instance.Reset(); - private void ResetAndAddSourceToCommandLineOptions() - { - CommandLineOptions.Instance.Reset(); + CommandLineOptions.Instance.FileHelper = _mockFileHelper.Object; + CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, _mockFileHelper.Object); + CommandLineOptions.Instance.AddSource(_dummyTestFilePath); + } - CommandLineOptions.Instance.FileHelper = this.mockFileHelper.Object; - CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, this.mockFileHelper.Object); - CommandLineOptions.Instance.AddSource(this.dummyTestFilePath); - } + public static void SetupMockExtensions() + { + SetupMockExtensions(() => { }); + } + + public static void SetupMockExtensions(Action callback) + { + SetupMockExtensions(new string[] { typeof(RunTestsArgumentProcessorTests).GetTypeInfo().Assembly.Location, typeof(ConsoleLogger).GetTypeInfo().Assembly.Location }, callback); + } - public static void SetupMockExtensions() + public static void SetupMockExtensions(string[] extensions, Action callback) + { + // Setup mocks. + var mockFileHelper = new Mock(); + mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); + mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny(), SearchOption.TopDirectoryOnly, new[] { ".dll" })) + .Callback(callback) + .Returns(extensions); + + var testableTestPluginCache = new TestableTestPluginCache(); + + // Setup the testable instance. + TestPluginCache.Instance = testableTestPluginCache; + } + + [ExtensionUri("testlogger://logger")] + [FriendlyName("TestLoggerExtension")] + private class ValidLogger3 : ITestLogger + { + public void Initialize(TestLoggerEvents events, string testRunDirectory) { - SetupMockExtensions(() => { }); + events.TestRunMessage += TestMessageHandler; + events.TestRunComplete += Events_TestRunComplete; + events.TestResult += Events_TestResult; } - public static void SetupMockExtensions(Action callback) + private void Events_TestResult(object sender, TestResultEventArgs e) { - SetupMockExtensions(new string[] { typeof(RunTestsArgumentProcessorTests).GetTypeInfo().Assembly.Location, typeof(ConsoleLogger).GetTypeInfo().Assembly.Location }, callback); } - public static void SetupMockExtensions(string[] extensions, Action callback) + private void Events_TestRunComplete(object sender, TestRunCompleteEventArgs e) { - // Setup mocks. - var mockFileHelper = new Mock(); - mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); - mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny(), SearchOption.TopDirectoryOnly, new[] { ".dll" })) - .Callback(callback) - .Returns(extensions); - var testableTestPluginCache = new TestableTestPluginCache(); - - // Setup the testable instance. - TestPluginCache.Instance = testableTestPluginCache; } - [ExtensionUri("testlogger://logger")] - [FriendlyName("TestLoggerExtension")] - private class ValidLogger3 : ITestLogger + private void TestMessageHandler(object sender, TestRunMessageEventArgs e) { - public void Initialize(TestLoggerEvents events, string testRunDirectory) - { - events.TestRunMessage += TestMessageHandler; - events.TestRunComplete += Events_TestRunComplete; - events.TestResult += Events_TestResult; - } - - private void Events_TestResult(object sender, TestResultEventArgs e) - { - } - - private void Events_TestRunComplete(object sender, TestRunCompleteEventArgs e) - { - - } - - private void TestMessageHandler(object sender, TestRunMessageEventArgs e) - { - } } } +} - #region Testable implementation +#region Testable implementation - public class TestableTestPluginCache : TestPluginCache - { - } - - #endregion +public class TestableTestPluginCache : TestPluginCache +{ +} -} \ No newline at end of file +#endregion \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/TestAdapterPathArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/TestAdapterPathArgumentProcessorTests.cs index 7069c4a4b4..13197bc5f5 100644 --- a/test/vstest.console.UnitTests/Processors/TestAdapterPathArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/TestAdapterPathArgumentProcessorTests.cs @@ -1,325 +1,324 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; + +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using Common; +using Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Utilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using TestTools.UnitTesting; + +using Moq; + +[TestClass] +public class TestAdapterPathArgumentProcessorTests { - using System; - using System.Collections.Generic; - using System.IO; - using System.Reflection; - - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Utilities; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - - [TestClass] - public class TestAdapterPathArgumentProcessorTests + RunSettings _currentActiveSetting; + + [TestInitialize] + public void TestInit() { - RunSettings currentActiveSetting; + _currentActiveSetting = RunSettingsManager.Instance.ActiveRunSettings; + } - [TestInitialize] - public void TestInit() - { - currentActiveSetting = RunSettingsManager.Instance.ActiveRunSettings; - } + [TestCleanup] + public void TestClean() + { + RunSettingsManager.Instance.SetActiveRunSettings(_currentActiveSetting); + } - [TestCleanup] - public void TestClean() - { - RunSettingsManager.Instance.SetActiveRunSettings(currentActiveSetting); - } + [TestMethod] + public void GetMetadataShouldReturnTestAdapterPathArgumentProcessorCapabilities() + { + var processor = new TestAdapterPathArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is TestAdapterPathArgumentProcessorCapabilities); + } + + [TestMethod] + public void GetExecuterShouldReturnTestAdapterPathArgumentProcessorCapabilities() + { + var processor = new TestAdapterPathArgumentProcessor(); + Assert.IsTrue(processor.Executor.Value is TestAdapterPathArgumentExecutor); + } + + #region TestAdapterPathArgumentProcessorCapabilities tests + + [TestMethod] + public void CapabilitiesShouldReturnAppropriateProperties() + { + var capabilities = new TestAdapterPathArgumentProcessorCapabilities(); + Assert.AreEqual("/TestAdapterPath", capabilities.CommandName); + var expected = "--TestAdapterPath|/TestAdapterPath\r\n This makes vstest.console.exe process use custom test adapters\r\n from a given path (if any) in the test run. \r\n Example /TestAdapterPath:"; + Assert.AreEqual(expected: expected.NormalizeLineEndings().ShowWhiteSpace(), capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); + + Assert.AreEqual(HelpContentPriority.TestAdapterPathArgumentProcessorHelpPriority, capabilities.HelpPriority); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.TestAdapterPath, capabilities.Priority); + + Assert.IsTrue(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } + + #endregion + + #region TestAdapterPathArgumentExecutor tests - [TestMethod] - public void GetMetadataShouldReturnTestAdapterPathArgumentProcessorCapabilities() + [TestMethod] + public void InitializeShouldThrowIfArgumentIsNull() + { + var mockRunSettingsProvider = new Mock(); + var mockOutput = new Mock(); + var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, mockRunSettingsProvider.Object, mockOutput.Object, new FileHelper()); + + var message = + @"The /TestAdapterPath parameter requires a value, which is path of a location containing custom test adapters. Example: /TestAdapterPath:c:\MyCustomAdapters"; + + var isExceptionThrown = false; + + try { - var processor = new TestAdapterPathArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is TestAdapterPathArgumentProcessorCapabilities); + executor.Initialize(null); } - - [TestMethod] - public void GetExecuterShouldReturnTestAdapterPathArgumentProcessorCapabilities() + catch (Exception ex) { - var processor = new TestAdapterPathArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is TestAdapterPathArgumentExecutor); + isExceptionThrown = true; + Assert.IsTrue(ex is CommandLineException); + Assert.AreEqual(message, ex.Message); } - #region TestAdapterPathArgumentProcessorCapabilities tests + Assert.IsTrue(isExceptionThrown); + } - [TestMethod] - public void CapabilitiesShouldReturnAppropriateProperties() - { - var capabilities = new TestAdapterPathArgumentProcessorCapabilities(); - Assert.AreEqual("/TestAdapterPath", capabilities.CommandName); - var expected = "--TestAdapterPath|/TestAdapterPath\r\n This makes vstest.console.exe process use custom test adapters\r\n from a given path (if any) in the test run. \r\n Example /TestAdapterPath:"; - Assert.AreEqual(expected: expected.NormalizeLineEndings().ShowWhiteSpace(), capabilities.HelpContentResourceName.NormalizeLineEndings().ShowWhiteSpace()); - - Assert.AreEqual(HelpContentPriority.TestAdapterPathArgumentProcessorHelpPriority, capabilities.HelpPriority); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.TestAdapterPath, capabilities.Priority); - - Assert.IsTrue(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); - } + [TestMethod] + public void InitializeShouldThrowIfArgumentIsAWhiteSpace() + { + var mockRunSettingsProvider = new Mock(); + var mockOutput = new Mock(); + var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, mockRunSettingsProvider.Object, mockOutput.Object, new FileHelper()); - #endregion + var message = + @"The /TestAdapterPath parameter requires a value, which is path of a location containing custom test adapters. Example: /TestAdapterPath:c:\MyCustomAdapters"; - #region TestAdapterPathArgumentExecutor tests + var isExceptionThrown = false; - [TestMethod] - public void InitializeShouldThrowIfArgumentIsNull() + try { - var mockRunSettingsProvider = new Mock(); - var mockOutput = new Mock(); - var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, mockRunSettingsProvider.Object, mockOutput.Object, new FileHelper()); - - var message = - @"The /TestAdapterPath parameter requires a value, which is path of a location containing custom test adapters. Example: /TestAdapterPath:c:\MyCustomAdapters"; - - var isExceptionThrown = false; - - try - { - executor.Initialize(null); - } - catch (Exception ex) - { - isExceptionThrown = true; - Assert.IsTrue(ex is CommandLineException); - Assert.AreEqual(message, ex.Message); - } - - Assert.IsTrue(isExceptionThrown); + executor.Initialize(" "); } - - [TestMethod] - public void InitializeShouldThrowIfArgumentIsAWhiteSpace() + catch (Exception ex) { - var mockRunSettingsProvider = new Mock(); - var mockOutput = new Mock(); - var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, mockRunSettingsProvider.Object, mockOutput.Object, new FileHelper()); - - var message = - @"The /TestAdapterPath parameter requires a value, which is path of a location containing custom test adapters. Example: /TestAdapterPath:c:\MyCustomAdapters"; - - var isExceptionThrown = false; - - try - { - executor.Initialize(" "); - } - catch (Exception ex) - { - isExceptionThrown = true; - Assert.IsTrue(ex is CommandLineException); - Assert.AreEqual(message, ex.Message); - } - - Assert.IsTrue(isExceptionThrown); + isExceptionThrown = true; + Assert.IsTrue(ex is CommandLineException); + Assert.AreEqual(message, ex.Message); } - [TestMethod] - public void InitializeShouldThrowIfPathDoesNotExist() - { - var mockRunSettingsProvider = new Mock(); - var mockOutput = new Mock(); - var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, mockRunSettingsProvider.Object, mockOutput.Object, new FileHelper()); - - var folder = "C:\\temp\\thisfolderdoesnotexist"; - - var message = string.Format( - @"The path '{0}' specified in the 'TestAdapterPath' is invalid. Error: {1}", - folder, - "The custom test adapter search path provided was not found, provide a valid path and try again."); - - var isExceptionThrown = false; - - try - { - executor.Initialize(folder); - } - catch (Exception ex) - { - isExceptionThrown = true; - Assert.IsTrue(ex is CommandLineException); - Assert.AreEqual(message, ex.Message); - } - - Assert.IsTrue(isExceptionThrown); - } + Assert.IsTrue(isExceptionThrown); + } - [TestMethod] - public void InitializeShouldUpdateTestAdapterPathInRunSettings() - { - RunSettingsManager.Instance.AddDefaultRunSettings(); + [TestMethod] + public void InitializeShouldThrowIfPathDoesNotExist() + { + var mockRunSettingsProvider = new Mock(); + var mockOutput = new Mock(); + var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, mockRunSettingsProvider.Object, mockOutput.Object, new FileHelper()); - var mockOutput = new Mock(); - var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, mockOutput.Object, new FileHelper()); + var folder = "C:\\temp\\thisfolderdoesnotexist"; - var currentAssemblyPath = typeof(TestAdapterPathArgumentExecutor).GetTypeInfo().Assembly.Location; - var currentFolder = Path.GetDirectoryName(currentAssemblyPath); + var message = string.Format( + @"The path '{0}' specified in the 'TestAdapterPath' is invalid. Error: {1}", + folder, + "The custom test adapter search path provided was not found, provide a valid path and try again."); - executor.Initialize(currentFolder); - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(RunSettingsManager.Instance.ActiveRunSettings.SettingsXml); - Assert.AreEqual(currentFolder, runConfiguration.TestAdaptersPaths); - } + var isExceptionThrown = false; - [TestMethod] - [TestCategory("Windows")] - public void InitializeShouldMergeTestAdapterPathsInRunSettings() + try + { + executor.Initialize(folder); + } + catch (Exception ex) { - var runSettingsXml = "d:\\users;f:\\users"; - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(runSettingsXml); - RunSettingsManager.Instance.SetActiveRunSettings(runSettings); - var mockFileHelper = new Mock(); - var mockOutput = new Mock(); + isExceptionThrown = true; + Assert.IsTrue(ex is CommandLineException); + Assert.AreEqual(message, ex.Message); + } - mockFileHelper.Setup(x => x.DirectoryExists(It.IsAny())).Returns(true); - var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, mockOutput.Object, mockFileHelper.Object); + Assert.IsTrue(isExceptionThrown); + } - executor.Initialize("c:\\users"); - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(RunSettingsManager.Instance.ActiveRunSettings.SettingsXml); - Assert.AreEqual("d:\\users;f:\\users;c:\\users", runConfiguration.TestAdaptersPaths); - } + [TestMethod] + public void InitializeShouldUpdateTestAdapterPathInRunSettings() + { + RunSettingsManager.Instance.AddDefaultRunSettings(); - [TestMethod] - [TestCategory("Windows")] - public void InitializeShouldMergeTestAdapterPathsInRunSettingsIgnoringDuplicatePaths() - { - var runSettingsXml = "d:\\users;c:\\users"; - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(runSettingsXml); - RunSettingsManager.Instance.SetActiveRunSettings(runSettings); - var mockFileHelper = new Mock(); - var mockOutput = new Mock(); + var mockOutput = new Mock(); + var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, mockOutput.Object, new FileHelper()); - mockFileHelper.Setup(x => x.DirectoryExists(It.IsAny())).Returns(true); - var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, mockOutput.Object, mockFileHelper.Object); + var currentAssemblyPath = typeof(TestAdapterPathArgumentExecutor).GetTypeInfo().Assembly.Location; + var currentFolder = Path.GetDirectoryName(currentAssemblyPath); - executor.Initialize("c:\\users"); - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(RunSettingsManager.Instance.ActiveRunSettings.SettingsXml); - Assert.AreEqual("d:\\users;c:\\users", runConfiguration.TestAdaptersPaths); - } + executor.Initialize(currentFolder); + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(RunSettingsManager.Instance.ActiveRunSettings.SettingsXml); + Assert.AreEqual(currentFolder, runConfiguration.TestAdaptersPaths); + } - [TestMethod] - [TestCategory("Windows")] - public void InitializeShouldMergeMultipleTestAdapterPathsWithPathsInRunSettings() - { - var runSettingsXml = "d:\\users;f:\\users"; - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(runSettingsXml); - RunSettingsManager.Instance.SetActiveRunSettings(runSettings); - var mockFileHelper = new Mock(); - var mockOutput = new Mock(); - - mockFileHelper.Setup(x => x.DirectoryExists(It.IsAny())).Returns(true); - var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, mockOutput.Object, mockFileHelper.Object); - - executor.Initialize("c:\\users;e:\\users"); - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(RunSettingsManager.Instance.ActiveRunSettings.SettingsXml); - Assert.AreEqual("d:\\users;f:\\users;c:\\users;e:\\users", runConfiguration.TestAdaptersPaths); - } + [TestMethod] + [TestCategory("Windows")] + public void InitializeShouldMergeTestAdapterPathsInRunSettings() + { + var runSettingsXml = "d:\\users;f:\\users"; + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(runSettingsXml); + RunSettingsManager.Instance.SetActiveRunSettings(runSettings); + var mockFileHelper = new Mock(); + var mockOutput = new Mock(); + + mockFileHelper.Setup(x => x.DirectoryExists(It.IsAny())).Returns(true); + var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, mockOutput.Object, mockFileHelper.Object); + + executor.Initialize("c:\\users"); + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(RunSettingsManager.Instance.ActiveRunSettings.SettingsXml); + Assert.AreEqual("d:\\users;f:\\users;c:\\users", runConfiguration.TestAdaptersPaths); + } - [TestMethod] - [TestCategory("Windows")] - public void InitializeShouldHonorEnvironmentVariablesInTestAdapterPaths() - { - var runSettingsXml = "%temp%\\adapters1"; - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(runSettingsXml); - RunSettingsManager.Instance.SetActiveRunSettings(runSettings); - var mockFileHelper = new Mock(); - var mockOutput = new Mock(); + [TestMethod] + [TestCategory("Windows")] + public void InitializeShouldMergeTestAdapterPathsInRunSettingsIgnoringDuplicatePaths() + { + var runSettingsXml = "d:\\users;c:\\users"; + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(runSettingsXml); + RunSettingsManager.Instance.SetActiveRunSettings(runSettings); + var mockFileHelper = new Mock(); + var mockOutput = new Mock(); + + mockFileHelper.Setup(x => x.DirectoryExists(It.IsAny())).Returns(true); + var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, mockOutput.Object, mockFileHelper.Object); + + executor.Initialize("c:\\users"); + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(RunSettingsManager.Instance.ActiveRunSettings.SettingsXml); + Assert.AreEqual("d:\\users;c:\\users", runConfiguration.TestAdaptersPaths); + } + + [TestMethod] + [TestCategory("Windows")] + public void InitializeShouldMergeMultipleTestAdapterPathsWithPathsInRunSettings() + { + var runSettingsXml = "d:\\users;f:\\users"; + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(runSettingsXml); + RunSettingsManager.Instance.SetActiveRunSettings(runSettings); + var mockFileHelper = new Mock(); + var mockOutput = new Mock(); + + mockFileHelper.Setup(x => x.DirectoryExists(It.IsAny())).Returns(true); + var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, mockOutput.Object, mockFileHelper.Object); + + executor.Initialize("c:\\users;e:\\users"); + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(RunSettingsManager.Instance.ActiveRunSettings.SettingsXml); + Assert.AreEqual("d:\\users;f:\\users;c:\\users;e:\\users", runConfiguration.TestAdaptersPaths); + } - mockFileHelper.Setup(x => x.DirectoryExists(It.IsAny())).Returns(true); - var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, mockOutput.Object, mockFileHelper.Object); + [TestMethod] + [TestCategory("Windows")] + public void InitializeShouldHonorEnvironmentVariablesInTestAdapterPaths() + { + var runSettingsXml = "%temp%\\adapters1"; + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(runSettingsXml); + RunSettingsManager.Instance.SetActiveRunSettings(runSettings); + var mockFileHelper = new Mock(); + var mockOutput = new Mock(); - executor.Initialize("%temp%\\adapters2"); - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(RunSettingsManager.Instance.ActiveRunSettings.SettingsXml); + mockFileHelper.Setup(x => x.DirectoryExists(It.IsAny())).Returns(true); + var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, mockOutput.Object, mockFileHelper.Object); - var tempPath = Path.GetFullPath(Environment.ExpandEnvironmentVariables("%temp%")); - Assert.AreEqual(string.Format("{0}\\adapters1;{0}\\adapters2", tempPath), runConfiguration.TestAdaptersPaths); - } + executor.Initialize("%temp%\\adapters2"); + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(RunSettingsManager.Instance.ActiveRunSettings.SettingsXml); + + var tempPath = Path.GetFullPath(Environment.ExpandEnvironmentVariables("%temp%")); + Assert.AreEqual(string.Format("{0}\\adapters1;{0}\\adapters2", tempPath), runConfiguration.TestAdaptersPaths); + } - [TestMethod] - [TestCategory("Windows")] - public void InitializeShouldAddRightAdapterPathInErrorMessage() + [TestMethod] + [TestCategory("Windows")] + public void InitializeShouldAddRightAdapterPathInErrorMessage() + { + var runSettingsXml = "d:\\users"; + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(runSettingsXml); + RunSettingsManager.Instance.SetActiveRunSettings(runSettings); + var mockFileHelper = new Mock(); + var mockOutput = new Mock(); + + mockFileHelper.Setup(x => x.DirectoryExists("d:\\users")).Returns(false); + mockFileHelper.Setup(x => x.DirectoryExists("c:\\users")).Returns(true); + var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, mockOutput.Object, mockFileHelper.Object); + + var message = string.Format( + @"The path '{0}' specified in the 'TestAdapterPath' is invalid. Error: {1}", + "d:\\users", + "The custom test adapter search path provided was not found, provide a valid path and try again."); + + var isExceptionThrown = false; + try { - var runSettingsXml = "d:\\users"; - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(runSettingsXml); - RunSettingsManager.Instance.SetActiveRunSettings(runSettings); - var mockFileHelper = new Mock(); - var mockOutput = new Mock(); - - mockFileHelper.Setup(x => x.DirectoryExists("d:\\users")).Returns(false); - mockFileHelper.Setup(x => x.DirectoryExists("c:\\users")).Returns(true); - var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, mockOutput.Object, mockFileHelper.Object); - - var message = string.Format( - @"The path '{0}' specified in the 'TestAdapterPath' is invalid. Error: {1}", - "d:\\users", - "The custom test adapter search path provided was not found, provide a valid path and try again."); - - var isExceptionThrown = false; - try - { - executor.Initialize("c:\\users"); - } - catch (Exception ex) - { - isExceptionThrown = true; - Assert.IsTrue(ex is CommandLineException); - Assert.AreEqual(message, ex.Message); - } - - Assert.IsTrue(isExceptionThrown); + executor.Initialize("c:\\users"); } - - [TestMethod] - [TestCategory("Windows")] - public void InitializeShouldTrimTrailingAndLeadingDoubleQuotes() + catch (Exception ex) { - var runSettingsXml = "d:\\users"; - var runSettings = new RunSettings(); - runSettings.LoadSettingsXml(runSettingsXml); - RunSettingsManager.Instance.SetActiveRunSettings(runSettings); - var mockFileHelper = new Mock(); - var mockOutput = new Mock(); + isExceptionThrown = true; + Assert.IsTrue(ex is CommandLineException); + Assert.AreEqual(message, ex.Message); + } - mockFileHelper.Setup(x => x.DirectoryExists(It.IsAny())).Returns(true); - var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, mockOutput.Object, mockFileHelper.Object); + Assert.IsTrue(isExceptionThrown); + } - executor.Initialize("\"c:\\users\""); - var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(RunSettingsManager.Instance.ActiveRunSettings.SettingsXml); - Assert.AreEqual("d:\\users;c:\\users", runConfiguration.TestAdaptersPaths); + [TestMethod] + [TestCategory("Windows")] + public void InitializeShouldTrimTrailingAndLeadingDoubleQuotes() + { + var runSettingsXml = "d:\\users"; + var runSettings = new RunSettings(); + runSettings.LoadSettingsXml(runSettingsXml); + RunSettingsManager.Instance.SetActiveRunSettings(runSettings); + var mockFileHelper = new Mock(); + var mockOutput = new Mock(); - } + mockFileHelper.Setup(x => x.DirectoryExists(It.IsAny())).Returns(true); + var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, mockOutput.Object, mockFileHelper.Object); - #endregion + executor.Initialize("\"c:\\users\""); + var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(RunSettingsManager.Instance.ActiveRunSettings.SettingsXml); + Assert.AreEqual("d:\\users;c:\\users", runConfiguration.TestAdaptersPaths); - #region Testable implementations + } - private class TestableTestAdapterPathArgumentExecutor : TestAdapterPathArgumentExecutor - { - internal TestableTestAdapterPathArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsProvider, IOutput output, IFileHelper fileHelper) - : base(options, runSettingsProvider, output, fileHelper) - { - } + #endregion - internal Func> TestAdapters { get; set; } + #region Testable implementations + + private class TestableTestAdapterPathArgumentExecutor : TestAdapterPathArgumentExecutor + { + internal TestableTestAdapterPathArgumentExecutor(CommandLineOptions options, IRunSettingsProvider runSettingsProvider, IOutput output, IFileHelper fileHelper) + : base(options, runSettingsProvider, output, fileHelper) + { } - #endregion + internal Func> TestAdapters { get; set; } } + + #endregion } \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/TestCaseFilterArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/TestCaseFilterArgumentProcessorTests.cs index 7bd0c9292d..cd2fe5b288 100644 --- a/test/vstest.console.UnitTests/Processors/TestCaseFilterArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/TestCaseFilterArgumentProcessorTests.cs @@ -1,100 +1,99 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors -{ - using System; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +using System; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using TestTools.UnitTesting; - using TestPlatform.CommandLine.Processors; +using TestPlatform.CommandLine.Processors; - [TestClass] - public class TestCaseFilterArgumentProcessorTests +[TestClass] +public class TestCaseFilterArgumentProcessorTests +{ + [TestMethod] + public void GetMetadataShouldReturnTestCaseFilterArgumentProcessorCapabilities() { - [TestMethod] - public void GetMetadataShouldReturnTestCaseFilterArgumentProcessorCapabilities() - { - TestCaseFilterArgumentProcessor processor = new TestCaseFilterArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is TestCaseFilterArgumentProcessorCapabilities); - } + TestCaseFilterArgumentProcessor processor = new(); + Assert.IsTrue(processor.Metadata.Value is TestCaseFilterArgumentProcessorCapabilities); + } - [TestMethod] - public void GetExecutorShouldReturnTestCaseFilterArgumentProcessorCapabilities() - { - TestCaseFilterArgumentProcessor processor = new TestCaseFilterArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is TestCaseFilterArgumentExecutor); - } + [TestMethod] + public void GetExecutorShouldReturnTestCaseFilterArgumentProcessorCapabilities() + { + TestCaseFilterArgumentProcessor processor = new(); + Assert.IsTrue(processor.Executor.Value is TestCaseFilterArgumentExecutor); + } - #region TestCaseFilterArgumentProcessorCapabilitiesTests + #region TestCaseFilterArgumentProcessorCapabilitiesTests - [TestMethod] - public void CapabilitiesShouldAppropriateProperties() - { - TestCaseFilterArgumentProcessorCapabilities capabilities = new TestCaseFilterArgumentProcessorCapabilities(); - Assert.AreEqual("/TestCaseFilter", capabilities.CommandName); - StringAssert.Contains(capabilities.HelpContentResourceName, "/TestCaseFilter:" + Environment.NewLine + " Run tests that match the given expression." + Environment.NewLine + " is of the format Operator[|&]"); + [TestMethod] + public void CapabilitiesShouldAppropriateProperties() + { + TestCaseFilterArgumentProcessorCapabilities capabilities = new(); + Assert.AreEqual("/TestCaseFilter", capabilities.CommandName); + StringAssert.Contains(capabilities.HelpContentResourceName, "/TestCaseFilter:" + Environment.NewLine + " Run tests that match the given expression." + Environment.NewLine + " is of the format Operator[|&]"); - Assert.AreEqual(HelpContentPriority.TestCaseFilterArgumentProcessorHelpPriority, capabilities.HelpPriority); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.Normal, capabilities.Priority); + Assert.AreEqual(HelpContentPriority.TestCaseFilterArgumentProcessorHelpPriority, capabilities.HelpPriority); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.Normal, capabilities.Priority); - Assert.IsFalse(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); - } + Assert.IsFalse(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } - #endregion + #endregion + + [TestMethod] + public void ExecutorInitializeWithNullOrEmptyTestCaseFilterShouldThrowCommandLineException() + { + var options = CommandLineOptions.Instance; + TestCaseFilterArgumentExecutor executor = new(options); - [TestMethod] - public void ExecutorInitializeWithNullOrEmptyTestCaseFilterShouldThrowCommandLineException() + try { - var options = CommandLineOptions.Instance; - TestCaseFilterArgumentExecutor executor = new TestCaseFilterArgumentExecutor(options); - - try - { - executor.Initialize(null); - } - catch (Exception ex) - { - Assert.IsTrue(ex is CommandLineException); - StringAssert.Contains(ex.Message, @"The /TestCaseFilter argument requires the filter value."); - } + executor.Initialize(null); + } + catch (Exception ex) + { + Assert.IsTrue(ex is CommandLineException); + StringAssert.Contains(ex.Message, @"The /TestCaseFilter argument requires the filter value."); } + } - [TestMethod] - public void ExecutorInitializeWithNullOrEmptyTestCaseFilterShouldNotThrowWhenTestFilterWasSpecifiedByPreviousStep() - { - var options = CommandLineOptions.Instance; - options.TestCaseFilterValue = "Test=FilterFromPreviousStep"; - TestCaseFilterArgumentExecutor executor = new TestCaseFilterArgumentExecutor(options); + [TestMethod] + public void ExecutorInitializeWithNullOrEmptyTestCaseFilterShouldNotThrowWhenTestFilterWasSpecifiedByPreviousStep() + { + var options = CommandLineOptions.Instance; + options.TestCaseFilterValue = "Test=FilterFromPreviousStep"; + TestCaseFilterArgumentExecutor executor = new(options); - executor.Initialize(null); - } + executor.Initialize(null); + } - [TestMethod] - public void ExecutorInitializeWithTestCaseFilterShouldMergeWithTheValueProvidedByPreviousStep() - { - var options = CommandLineOptions.Instance; - var defaultValue = "Test=FilterFromPreviousStep"; - options.TestCaseFilterValue = defaultValue; - Assert.AreEqual(defaultValue, options.TestCaseFilterValue); - TestCaseFilterArgumentExecutor executor = new TestCaseFilterArgumentExecutor(options); + [TestMethod] + public void ExecutorInitializeWithTestCaseFilterShouldMergeWithTheValueProvidedByPreviousStep() + { + var options = CommandLineOptions.Instance; + var defaultValue = "Test=FilterFromPreviousStep"; + options.TestCaseFilterValue = defaultValue; + Assert.AreEqual(defaultValue, options.TestCaseFilterValue); + TestCaseFilterArgumentExecutor executor = new(options); - var value = "Test=NewFilter"; - executor.Initialize(value); + var value = "Test=NewFilter"; + executor.Initialize(value); - var expectedValue = $"({defaultValue})&({value})"; - Assert.AreEqual(expectedValue, options.TestCaseFilterValue); - } + var expectedValue = $"({defaultValue})&({value})"; + Assert.AreEqual(expectedValue, options.TestCaseFilterValue); + } - [TestMethod] - public void ExecutorExecutoreturnArgumentProcessorResultSuccess() - { - var executor = new TestCaseFilterArgumentExecutor(CommandLineOptions.Instance); - var result = executor.Execute(); - Assert.AreEqual(ArgumentProcessorResult.Success, result); - } + [TestMethod] + public void ExecutorExecutoreturnArgumentProcessorResultSuccess() + { + var executor = new TestCaseFilterArgumentExecutor(CommandLineOptions.Instance); + var result = executor.Execute(); + Assert.AreEqual(ArgumentProcessorResult.Success, result); } -} +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/TestSourceArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/TestSourceArgumentProcessorTests.cs index 4ee6fe35ab..eaf8d35612 100644 --- a/test/vstest.console.UnitTests/Processors/TestSourceArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/TestSourceArgumentProcessorTests.cs @@ -1,118 +1,119 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; + +using System; +using System.Linq; + +using Extensions.FileSystemGlobbing; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using TestTools.UnitTesting; + +using Moq; + +using vstest.console.Internal; + +// +// Tests for TestSourceArgumentProcessor +// +[TestClass] +public class TestSourceArgumentProcessorTests { - using System; - using System.Linq; - using Microsoft.Extensions.FileSystemGlobbing; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using Moq; - using vstest.console.Internal; - - // - // Tests for TestSourceArgumentProcessor - // - [TestClass] - public class TestSourceArgumentProcessorTests + /// + /// The help argument processor get metadata should return help argument processor capabilities. + /// + [TestMethod] + public void GetMetadataShouldReturnTestSourceArgumentProcessorCapabilities() { - /// - /// The help argument processor get metadata should return help argument processor capabilities. - /// - [TestMethod] - public void GetMetadataShouldReturnTestSourceArgumentProcessorCapabilities() - { - TestSourceArgumentProcessor processor = new TestSourceArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is TestSourceArgumentProcessorCapabilities); - } + TestSourceArgumentProcessor processor = new(); + Assert.IsTrue(processor.Metadata.Value is TestSourceArgumentProcessorCapabilities); + } - /// - /// The help argument processor get executer should return help argument processor capabilities. - /// - [TestMethod] - public void GetExecuterShouldReturnTestSourceArgumentProcessorCapabilities() - { - TestSourceArgumentProcessor processor = new TestSourceArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is TestSourceArgumentExecutor); - } + /// + /// The help argument processor get executer should return help argument processor capabilities. + /// + [TestMethod] + public void GetExecuterShouldReturnTestSourceArgumentProcessorCapabilities() + { + TestSourceArgumentProcessor processor = new(); + Assert.IsTrue(processor.Executor.Value is TestSourceArgumentExecutor); + } - #region TestSourceArgumentProcessorCapabilitiesTests + #region TestSourceArgumentProcessorCapabilitiesTests - [TestMethod] - public void CapabilitiesShouldReturnAppropriateProperties() - { - TestSourceArgumentProcessorCapabilities capabilities = new TestSourceArgumentProcessorCapabilities(); - Assert.AreEqual("/TestSource", capabilities.CommandName); - Assert.IsNull(capabilities.HelpContentResourceName); + [TestMethod] + public void CapabilitiesShouldReturnAppropriateProperties() + { + TestSourceArgumentProcessorCapabilities capabilities = new(); + Assert.AreEqual("/TestSource", capabilities.CommandName); + Assert.IsNull(capabilities.HelpContentResourceName); - Assert.AreEqual(HelpContentPriority.None, capabilities.HelpPriority); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.Normal, capabilities.Priority); + Assert.AreEqual(HelpContentPriority.None, capabilities.HelpPriority); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.Normal, capabilities.Priority); - Assert.IsTrue(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsTrue(capabilities.IsSpecialCommand); - } + Assert.IsTrue(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsTrue(capabilities.IsSpecialCommand); + } - #endregion + #endregion - #region TestSourceArgumentExecutorTests + #region TestSourceArgumentExecutorTests - [TestMethod] - public void ExecuterInitializeWithInvalidSourceShouldThrowCommandLineException() + [TestMethod] + public void ExecuterInitializeWithInvalidSourceShouldThrowCommandLineException() + { + var options = CommandLineOptions.Instance; + var mockFileHelper = new Mock(); + mockFileHelper.Setup(x => x.GetCurrentDirectory()).Returns(""); + options.FileHelper = mockFileHelper.Object; + TestSourceArgumentExecutor executor = new(options); + + // This path is invalid + string testFilePath = "TestFile.txt"; + + try { - var options = CommandLineOptions.Instance; - var mockFileHelper = new Mock(); - mockFileHelper.Setup(x => x.GetCurrentDirectory()).Returns(""); - options.FileHelper = mockFileHelper.Object; - TestSourceArgumentExecutor executor = new TestSourceArgumentExecutor(options); - - // This path is invalid - string testFilePath = "TestFile.txt"; - - try - { - executor.Initialize(testFilePath); - } - catch (Exception ex) - { - Assert.IsTrue(ex is TestSourceException); - Assert.AreEqual("The test source file \"" + testFilePath + "\" provided was not found.", ex.Message); - } + executor.Initialize(testFilePath); } - - [TestMethod] - public void ExecuterInitializeWithValidSourceShouldAddItToTestSources() + catch (Exception ex) { - var testFilePath = "DummyTestFile.txt"; - var mockFileHelper = new Mock(); - mockFileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); - mockFileHelper.Setup(x => x.GetCurrentDirectory()).Returns(""); + Assert.IsTrue(ex is TestSourceException); + Assert.AreEqual("The test source file \"" + testFilePath + "\" provided was not found.", ex.Message); + } + } - var options = CommandLineOptions.Instance; - options.Reset(); - options.FileHelper = mockFileHelper.Object; - options.FilePatternParser = new FilePatternParser(new Mock().Object, mockFileHelper.Object); - var executor = new TestSourceArgumentExecutor(options); + [TestMethod] + public void ExecuterInitializeWithValidSourceShouldAddItToTestSources() + { + var testFilePath = "DummyTestFile.txt"; + var mockFileHelper = new Mock(); + mockFileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); + mockFileHelper.Setup(x => x.GetCurrentDirectory()).Returns(""); - executor.Initialize(testFilePath); + var options = CommandLineOptions.Instance; + options.Reset(); + options.FileHelper = mockFileHelper.Object; + options.FilePatternParser = new FilePatternParser(new Mock().Object, mockFileHelper.Object); + var executor = new TestSourceArgumentExecutor(options); - // Check if the testsource is present in the TestSources - Assert.IsTrue(options.Sources.Contains(testFilePath)); - } + executor.Initialize(testFilePath); - [TestMethod] - public void ExecutorExecuteReturnArgumentProcessorResultSuccess() - { - var options = CommandLineOptions.Instance; - var executor = new TestSourceArgumentExecutor(options); - var result = executor.Execute(); - Assert.AreEqual(ArgumentProcessorResult.Success, result); - } + // Check if the testsource is present in the TestSources + Assert.IsTrue(options.Sources.Contains(testFilePath)); + } - #endregion + [TestMethod] + public void ExecutorExecuteReturnArgumentProcessorResultSuccess() + { + var options = CommandLineOptions.Instance; + var executor = new TestSourceArgumentExecutor(options); + var result = executor.Execute(); + Assert.AreEqual(ArgumentProcessorResult.Success, result); } -} + + #endregion +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/TestableRunSettingsProvider.cs b/test/vstest.console.UnitTests/Processors/TestableRunSettingsProvider.cs index 169443da7d..8fef0ef04e 100644 --- a/test/vstest.console.UnitTests/Processors/TestableRunSettingsProvider.cs +++ b/test/vstest.console.UnitTests/Processors/TestableRunSettingsProvider.cs @@ -1,22 +1,21 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace vstest.console.UnitTests.Processors -{ - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; +namespace vstest.console.UnitTests.Processors; + +using Microsoft.VisualStudio.TestPlatform.Common; +using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - internal class TestableRunSettingsProvider : IRunSettingsProvider +internal class TestableRunSettingsProvider : IRunSettingsProvider +{ + public RunSettings ActiveRunSettings { - public RunSettings ActiveRunSettings - { - get; - set; - } + get; + set; + } - public void SetActiveRunSettings(RunSettings runSettings) - { - this.ActiveRunSettings = runSettings; - } + public void SetActiveRunSettings(RunSettings runSettings) + { + ActiveRunSettings = runSettings; } -} +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/UseVsixExtensionsArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/UseVsixExtensionsArgumentProcessorTests.cs index d0b31cdcc3..61e88fd1d3 100644 --- a/test/vstest.console.UnitTests/Processors/UseVsixExtensionsArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/UseVsixExtensionsArgumentProcessorTests.cs @@ -1,110 +1,110 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace vstest.console.UnitTests.Processors +namespace vstest.console.UnitTests.Processors; + +using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; +using Microsoft.VisualStudio.TestPlatform.CommandLine; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using Moq; + +using System.Collections.Generic; + +[TestClass] +public class UseVsixExtensionsArgumentProcessorTests { - using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; - using Microsoft.VisualStudio.TestPlatform.CommandLine; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using System.Collections.Generic; - - [TestClass] - public class UseVsixExtensionsArgumentProcessorTests + private const string DeprecationMessage = @"/UseVsixExtensions is getting deprecated. Please use /TestAdapterPath instead."; + private readonly Mock _testRequestManager; + private readonly Mock _extensionManager; + private readonly Mock _output; + private readonly UseVsixExtensionsArgumentExecutor _executor; + + public UseVsixExtensionsArgumentProcessorTests() + { + _testRequestManager = new Mock(); + _extensionManager = new Mock(); + _output = new Mock(); + _executor = new UseVsixExtensionsArgumentExecutor(CommandLineOptions.Instance, _testRequestManager.Object, _extensionManager.Object, _output.Object); + } + + [TestMethod] + public void GetMetadataShouldReturnUseVsixExtensionsArgumentProcessorCapabilities() + { + var processor = new UseVsixExtensionsArgumentProcessor(); + Assert.IsTrue(processor.Metadata.Value is UseVsixExtensionsArgumentProcessorCapabilities); + } + + [TestMethod] + public void GetExecuterShouldReturnUseVsixExtensionsArgumentProcessorCapabilities() + { + var processor = new UseVsixExtensionsArgumentProcessor(); + Assert.IsTrue(processor.Executor.Value is UseVsixExtensionsArgumentExecutor); + } + + #region UseVsixExtensionsArgumentProcessorCapabilities tests + + [TestMethod] + public void CapabilitiesShouldReturnAppropriateProperties() + { + var capabilities = new UseVsixExtensionsArgumentProcessorCapabilities(); + + Assert.AreEqual("/UseVsixExtensions", capabilities.CommandName); + Assert.IsNull(capabilities.HelpContentResourceName); + Assert.AreEqual(HelpContentPriority.None, capabilities.HelpPriority); + Assert.IsFalse(capabilities.IsAction); + Assert.AreEqual(ArgumentProcessorPriority.AutoUpdateRunSettings, capabilities.Priority); + + Assert.IsFalse(capabilities.AllowMultiple); + Assert.IsFalse(capabilities.AlwaysExecute); + Assert.IsFalse(capabilities.IsSpecialCommand); + } + + #endregion + + #region UseVsixExtensionsArgumentExecutor tests + + [TestMethod] + public void InitializeShouldThrowExceptionIfArgumentIsNull() + { + var message = Assert.ThrowsException(() => _executor.Initialize(null)).Message; + Assert.AreEqual(@"The /UseVsixExtensions parameter requires a value. If 'true', the installed VSIX extensions (if any) will be used in the test run. If false, they will be ignored. Example: /UseVsixExtensions:true", message); + } + + [TestMethod] + public void InitializeShouldThrowExceptionIfArgumentIsInvalid() + { + var invalidArg = "Foo"; + + var message = Assert.ThrowsException(() => _executor.Initialize(invalidArg)).Message; + Assert.AreEqual(@"Argument Foo is not expected in the 'UseVsixExtensions' command. Specify the command indicating whether the vsix extensions should be used or skipped (Example: vstest.console.exe myTests.dll /UseVsixExtensions:true) and try again.", message); + } + + [TestMethod] + public void InitializeForArgumentEqualTrueShouldCallTestRequestManagerInitializeExtensions() { - private const string DefaultRunSettings = "\r\n\r\n \r\n {0}\r\n \r\n"; - private const string DeprecationMessage = @"/UseVsixExtensions is getting deprecated. Please use /TestAdapterPath instead."; - private Mock testRequestManager; - private Mock extensionManager; - private Mock output; - private UseVsixExtensionsArgumentExecutor executor; - - public UseVsixExtensionsArgumentProcessorTests() - { - this.testRequestManager = new Mock(); - this.extensionManager = new Mock(); - this.output = new Mock(); - this.executor = new UseVsixExtensionsArgumentExecutor(CommandLineOptions.Instance, this.testRequestManager.Object, this.extensionManager.Object, this.output.Object); - } - - [TestMethod] - public void GetMetadataShouldReturnUseVsixExtensionsArgumentProcessorCapabilities() - { - var processor = new UseVsixExtensionsArgumentProcessor(); - Assert.IsTrue(processor.Metadata.Value is UseVsixExtensionsArgumentProcessorCapabilities); - } - - [TestMethod] - public void GetExecuterShouldReturnUseVsixExtensionsArgumentProcessorCapabilities() - { - var processor = new UseVsixExtensionsArgumentProcessor(); - Assert.IsTrue(processor.Executor.Value is UseVsixExtensionsArgumentExecutor); - } - - #region UseVsixExtensionsArgumentProcessorCapabilities tests - - [TestMethod] - public void CapabilitiesShouldReturnAppropriateProperties() - { - var capabilities = new UseVsixExtensionsArgumentProcessorCapabilities(); - - Assert.AreEqual("/UseVsixExtensions", capabilities.CommandName); - Assert.IsNull(capabilities.HelpContentResourceName); - Assert.AreEqual(HelpContentPriority.None, capabilities.HelpPriority); - Assert.IsFalse(capabilities.IsAction); - Assert.AreEqual(ArgumentProcessorPriority.AutoUpdateRunSettings, capabilities.Priority); - - Assert.IsFalse(capabilities.AllowMultiple); - Assert.IsFalse(capabilities.AlwaysExecute); - Assert.IsFalse(capabilities.IsSpecialCommand); - } - - #endregion - - #region UseVsixExtensionsArgumentExecutor tests - - [TestMethod] - public void InitializeShouldThrowExceptionIfArgumentIsNull() - { - var message = Assert.ThrowsException(() => this.executor.Initialize(null)).Message; - Assert.AreEqual(@"The /UseVsixExtensions parameter requires a value. If 'true', the installed VSIX extensions (if any) will be used in the test run. If false, they will be ignored. Example: /UseVsixExtensions:true", message); - } - - [TestMethod] - public void InitializeShouldThrowExceptionIfArgumentIsInvalid() - { - var invalidArg = "Foo"; - - var message = Assert.ThrowsException(() => this.executor.Initialize(invalidArg)).Message; - Assert.AreEqual(@"Argument Foo is not expected in the 'UseVsixExtensions' command. Specify the command indicating whether the vsix extensions should be used or skipped (Example: vstest.console.exe myTests.dll /UseVsixExtensions:true) and try again.", message); - } - - [TestMethod] - public void InitializeForArgumentEqualTrueShouldCallTestRequestManagerInitializeExtensions() - { - var extensions = new List { "T1.dll", "T2.dll" }; - this.extensionManager.Setup(em => em.GetUnitTestExtensions()).Returns(extensions); - - this.executor.Initialize("true"); - - this.output.Verify(o => o.WriteLine(DeprecationMessage, OutputLevel.Warning), Times.Once); - this.extensionManager.Verify(em => em.GetUnitTestExtensions(), Times.Once); - this.testRequestManager.Verify(trm => trm.InitializeExtensions(extensions, true), Times.Once); - } - - [TestMethod] - public void InitializeForArgumentEqualfalseShouldNotCallTestRequestManagerInitializeExtensions() - { - this.executor.Initialize("false"); - - this.output.Verify(o => o.WriteLine(DeprecationMessage, OutputLevel.Warning), Times.Once); - this.extensionManager.Verify(em => em.GetUnitTestExtensions(), Times.Never); - this.testRequestManager.Verify(trm => trm.InitializeExtensions(It.IsAny>(), true), Times.Never); - } - - #endregion + var extensions = new List { "T1.dll", "T2.dll" }; + _extensionManager.Setup(em => em.GetUnitTestExtensions()).Returns(extensions); + + _executor.Initialize("true"); + + _output.Verify(o => o.WriteLine(DeprecationMessage, OutputLevel.Warning), Times.Once); + _extensionManager.Verify(em => em.GetUnitTestExtensions(), Times.Once); + _testRequestManager.Verify(trm => trm.InitializeExtensions(extensions, true), Times.Once); } -} + + [TestMethod] + public void InitializeForArgumentEqualfalseShouldNotCallTestRequestManagerInitializeExtensions() + { + _executor.Initialize("false"); + + _output.Verify(o => o.WriteLine(DeprecationMessage, OutputLevel.Warning), Times.Once); + _extensionManager.Verify(em => em.GetUnitTestExtensions(), Times.Never); + _testRequestManager.Verify(trm => trm.InitializeExtensions(It.IsAny>(), true), Times.Never); + } + + #endregion +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Processors/Utilities/ArgumentProcessorFactoryTests.cs b/test/vstest.console.UnitTests/Processors/Utilities/ArgumentProcessorFactoryTests.cs index 1698ad51be..5898bf548f 100644 --- a/test/vstest.console.UnitTests/Processors/Utilities/ArgumentProcessorFactoryTests.cs +++ b/test/vstest.console.UnitTests/Processors/Utilities/ArgumentProcessorFactoryTests.cs @@ -1,176 +1,176 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors.Utilities -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Reflection; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors.Utilities; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; - using TestPlatform.CommandLine.Processors; - using TestTools.UnitTesting; +using TestPlatform.CommandLine.Processors; - [TestClass] - public class ArgumentProcessorFactoryTests +using TestTools.UnitTesting; + +[TestClass] +public class ArgumentProcessorFactoryTests +{ + [TestMethod] + public void CreateArgumentProcessorIsTreatingNonArgumentAsSource() { - [TestMethod] - public void CreateArgumentProcessorIsTreatingNonArgumentAsSource() - { - string argument = "--NonArgumet:Dummy"; + string argument = "--NonArgumet:Dummy"; - ArgumentProcessorFactory factory = ArgumentProcessorFactory.Create(); + ArgumentProcessorFactory factory = ArgumentProcessorFactory.Create(); - IArgumentProcessor result = factory.CreateArgumentProcessor(argument); + IArgumentProcessor result = factory.CreateArgumentProcessor(argument); - Assert.AreEqual(typeof(TestSourceArgumentProcessor), result.GetType()); - } + Assert.AreEqual(typeof(TestSourceArgumentProcessor), result.GetType()); + } - [TestMethod] - public void CreateArgumentProcessorIsTreatingNonArgumentAsSourceEvenItIsStratingFromForwardSlash() - { - string argument = "/foo/foo.dll"; + [TestMethod] + public void CreateArgumentProcessorIsTreatingNonArgumentAsSourceEvenItIsStratingFromForwardSlash() + { + string argument = "/foo/foo.dll"; - ArgumentProcessorFactory factory = ArgumentProcessorFactory.Create(); + ArgumentProcessorFactory factory = ArgumentProcessorFactory.Create(); - IArgumentProcessor result = factory.CreateArgumentProcessor(argument); + IArgumentProcessor result = factory.CreateArgumentProcessor(argument); - Assert.AreEqual(typeof(TestSourceArgumentProcessor), result.GetType()); - } + Assert.AreEqual(typeof(TestSourceArgumentProcessor), result.GetType()); + } - [TestMethod] - public void CreateArgumentProcessorShouldReturnPlatformArgumentProcessorWhenArgumentIsPlatform() - { - string argument = "/Platform:x64"; + [TestMethod] + public void CreateArgumentProcessorShouldReturnPlatformArgumentProcessorWhenArgumentIsPlatform() + { + string argument = "/Platform:x64"; - ArgumentProcessorFactory factory = ArgumentProcessorFactory.Create(); + ArgumentProcessorFactory factory = ArgumentProcessorFactory.Create(); - IArgumentProcessor result = factory.CreateArgumentProcessor(argument); + IArgumentProcessor result = factory.CreateArgumentProcessor(argument); - Assert.AreEqual(typeof(PlatformArgumentProcessor), result.GetType()); - } + Assert.AreEqual(typeof(PlatformArgumentProcessor), result.GetType()); + } - [TestMethod] - public void CreateArgumentProcessorShouldReturnPlatformArgumentProcessorWhenArgumentIsPlatformInXplat() - { - string argument = "--Platform:x64"; + [TestMethod] + public void CreateArgumentProcessorShouldReturnPlatformArgumentProcessorWhenArgumentIsPlatformInXplat() + { + string argument = "--Platform:x64"; - ArgumentProcessorFactory factory = ArgumentProcessorFactory.Create(); + ArgumentProcessorFactory factory = ArgumentProcessorFactory.Create(); - IArgumentProcessor result = factory.CreateArgumentProcessor(argument); + IArgumentProcessor result = factory.CreateArgumentProcessor(argument); - Assert.AreEqual(typeof(PlatformArgumentProcessor), result.GetType()); - } + Assert.AreEqual(typeof(PlatformArgumentProcessor), result.GetType()); + } - [TestMethod] - public void CreateArgumentProcessorShouldReturnThrowExceptionIfArgumentsIsNull() - { - var command = "--"; + [TestMethod] + public void CreateArgumentProcessorShouldReturnThrowExceptionIfArgumentsIsNull() + { + var command = "--"; - ArgumentProcessorFactory factory = ArgumentProcessorFactory.Create(); - Action action = () => factory.CreateArgumentProcessor(command, null); + ArgumentProcessorFactory factory = ArgumentProcessorFactory.Create(); + Action action = () => factory.CreateArgumentProcessor(command, null); - ExceptionUtilities.ThrowsException( - action, - "Cannot be null or empty", "argument"); - } + ExceptionUtilities.ThrowsException( + action, + "Cannot be null or empty", "argument"); + } - [TestMethod] - public void CreateArgumentProcessorShouldReturnNullIfInvalidCommandIsPassed() - { - var command = "/-"; + [TestMethod] + public void CreateArgumentProcessorShouldReturnNullIfInvalidCommandIsPassed() + { + var command = "/-"; - ArgumentProcessorFactory factory = ArgumentProcessorFactory.Create(); + ArgumentProcessorFactory factory = ArgumentProcessorFactory.Create(); - IArgumentProcessor result = factory.CreateArgumentProcessor(command, new string[] { "" }); + IArgumentProcessor result = factory.CreateArgumentProcessor(command, new string[] { "" }); - Assert.IsNull(result); - } + Assert.IsNull(result); + } - [TestMethod] - public void CreateArgumentProcessorShouldReturnCLIRunSettingsArgumentProcessorIfCommandIsGiven() - { - var command = "--"; + [TestMethod] + public void CreateArgumentProcessorShouldReturnCliRunSettingsArgumentProcessorIfCommandIsGiven() + { + var command = "--"; - ArgumentProcessorFactory factory = ArgumentProcessorFactory.Create(); + ArgumentProcessorFactory factory = ArgumentProcessorFactory.Create(); - IArgumentProcessor result = factory.CreateArgumentProcessor(command, new string[] { "" }); + IArgumentProcessor result = factory.CreateArgumentProcessor(command, new string[] { "" }); - Assert.AreEqual(typeof(CLIRunSettingsArgumentProcessor), result.GetType()); - } + Assert.AreEqual(typeof(CliRunSettingsArgumentProcessor), result.GetType()); + } - [TestMethod] - public void BuildCommadMapsForProcessorWithIsSpecialCommandSetAddsProcessorToSpecialMap() - { - var specialCommands = GetArgumentProcessors(specialCommandFilter: true); + [TestMethod] + public void BuildCommadMapsForProcessorWithIsSpecialCommandSetAddsProcessorToSpecialMap() + { + var specialCommands = GetArgumentProcessors(specialCommandFilter: true); - List xplatspecialCommandNames = new List(); - List specialCommandNames = new List(); + List xplatspecialCommandNames = new(); + List specialCommandNames = new(); - // for each command add there xplat version - foreach (var specialCommand in specialCommands) + // for each command add there xplat version + foreach (var specialCommand in specialCommands) + { + specialCommandNames.Add(specialCommand.Metadata.Value.CommandName); + if (!specialCommand.Metadata.Value.AlwaysExecute) { - specialCommandNames.Add(specialCommand.Metadata.Value.CommandName); - if (!specialCommand.Metadata.Value.AlwaysExecute) - { - xplatspecialCommandNames.Add(string.Concat("--", specialCommand.Metadata.Value.CommandName.Remove(0, 1))); - } + xplatspecialCommandNames.Add(string.Concat("--", specialCommand.Metadata.Value.CommandName.Remove(0, 1))); } - var factory = ArgumentProcessorFactory.Create(); - - CollectionAssert.AreEquivalent( - specialCommandNames.Concat(xplatspecialCommandNames).ToList(), - factory.SpecialCommandToProcessorMap.Keys.ToList()); } + var factory = ArgumentProcessorFactory.Create(); + + CollectionAssert.AreEquivalent( + specialCommandNames.Concat(xplatspecialCommandNames).ToList(), + factory.SpecialCommandToProcessorMap.Keys.ToList()); + } - [TestMethod] - public void BuildCommadMapsForMultipleProcessorAddsProcessorToAppropriateMaps() + [TestMethod] + public void BuildCommadMapsForMultipleProcessorAddsProcessorToAppropriateMaps() + { + var commandProcessors = GetArgumentProcessors(specialCommandFilter: false); + var commands = commandProcessors.Select(a => a.Metadata.Value.CommandName); + List xplatCommandName = new(); + + // for each command add there xplat version + foreach (string name in commands) { - var commandProcessors = GetArgumentProcessors(specialCommandFilter: false); - var commands = commandProcessors.Select(a => a.Metadata.Value.CommandName); - List xplatCommandName = new List(); + xplatCommandName.Add(string.Concat("--", name.Remove(0, 1))); + } - // for each command add there xplat version - foreach (string name in commands) - { - xplatCommandName.Add(string.Concat("--", name.Remove(0, 1))); - } + var shortCommands = commandProcessors.Where(a => !string.IsNullOrEmpty(a.Metadata.Value.ShortCommandName)) + .Select(a => a.Metadata.Value.ShortCommandName); - var shortCommands = commandProcessors.Where(a => !string.IsNullOrEmpty(a.Metadata.Value.ShortCommandName)) - .Select(a => a.Metadata.Value.ShortCommandName); + List xplatShortCommandName = new(); - List xplatShortCommandName = new List(); + // for each short command add there xplat version + foreach (string name in shortCommands) + { + xplatShortCommandName.Add(name.Replace('/', '-')); + } - // for each short command add there xplat version - foreach (string name in shortCommands) - { - xplatShortCommandName.Add(name.Replace('/', '-')); - } + ArgumentProcessorFactory factory = ArgumentProcessorFactory.Create(); - ArgumentProcessorFactory factory = ArgumentProcessorFactory.Create(); + // Expect command processors to contain both long and short commands. + CollectionAssert.AreEquivalent( + commands.Concat(xplatCommandName).Concat(shortCommands).Concat(xplatShortCommandName).ToList(), + factory.CommandToProcessorMap.Keys.ToList()); + } - // Expect command processors to contain both long and short commands. - CollectionAssert.AreEquivalent( - commands.Concat(xplatCommandName).Concat(shortCommands).Concat(xplatShortCommandName).ToList(), - factory.CommandToProcessorMap.Keys.ToList()); - } + private static IEnumerable GetArgumentProcessors(bool specialCommandFilter) + { + var allProcessors = typeof(ArgumentProcessorFactory).GetTypeInfo() + .Assembly.GetTypes() + .Where(t => !t.GetTypeInfo().IsAbstract && !t.Name.Equals("IArgumentProcessor") && typeof(IArgumentProcessor).IsAssignableFrom(t)); - private static IEnumerable GetArgumentProcessors(bool specialCommandFilter) + foreach (var processor in allProcessors) { - var allProcessors = typeof(ArgumentProcessorFactory).GetTypeInfo() - .Assembly.GetTypes() - .Where(t => !t.GetTypeInfo().IsAbstract && !t.Name.Equals("IArgumentProcessor") && typeof(IArgumentProcessor).IsAssignableFrom(t)); + var instance = Activator.CreateInstance(processor) as IArgumentProcessor; + Assert.IsNotNull(instance, "Unable to instantiate processor: {0}", processor); - foreach (var processor in allProcessors) + var specialProcessor = instance.Metadata.Value.IsSpecialCommand; + if ((specialCommandFilter && specialProcessor) || (!specialCommandFilter && !specialProcessor)) { - var instance = Activator.CreateInstance(processor) as IArgumentProcessor; - Assert.IsNotNull(instance, "Unable to instantiate processor: {0}", processor); - - var specialProcessor = instance.Metadata.Value.IsSpecialCommand; - if ((specialCommandFilter && specialProcessor) || (!specialCommandFilter && !specialProcessor)) - { - yield return instance; - } + yield return instance; } } } diff --git a/test/vstest.console.UnitTests/Processors/Utilities/ArgumentProcessorUtilitiesTests.cs b/test/vstest.console.UnitTests/Processors/Utilities/ArgumentProcessorUtilitiesTests.cs index c966df482d..c169833804 100644 --- a/test/vstest.console.UnitTests/Processors/Utilities/ArgumentProcessorUtilitiesTests.cs +++ b/test/vstest.console.UnitTests/Processors/Utilities/ArgumentProcessorUtilitiesTests.cs @@ -1,65 +1,66 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors.Utilities -{ - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; - using System; - using System.Collections.Generic; - using System.Linq; - using TestTools.UnitTesting; +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors.Utilities; + +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; + +using System; +using System.Collections.Generic; +using System.Linq; - [TestClass] - public class ArgumentProcessorUtilitiesTests +using TestTools.UnitTesting; + +[TestClass] +public class ArgumentProcessorUtilitiesTests +{ + [TestMethod] + [DataRow("")] + [DataRow(" ")] + [DataRow(";;;;")] + public void GetArgumentListShouldThrowErrorOnInvalidArgument(string argument) { - [TestMethod] - [DataRow("")] - [DataRow(" ")] - [DataRow(";;;;")] - public void GetArgumentListShouldThrowErrorOnInvalidArgument(string argument) + try { - try - { - ArgumentProcessorUtilities.GetArgumentList(argument, ArgumentProcessorUtilities.SemiColonArgumentSeparator, "test exception."); - } - catch (Exception e) - { - Assert.IsTrue(e.GetType().Equals(typeof(CommandLineException))); - Assert.IsTrue(e.Message.Contains("test exception.")); - } + ArgumentProcessorUtilities.GetArgumentList(argument, ArgumentProcessorUtilities.SemiColonArgumentSeparator, "test exception."); } - - [TestMethod] - [DataRow("abc.txt;tracelevel=info;newkey=newvalue")] - [DataRow(";;;abc.txt;;;tracelevel=info;;;newkey=newvalue;;;;")] - public void GetArgumentListShouldReturnCorrectArgumentList(string argument) + catch (Exception e) { - var argumentList = ArgumentProcessorUtilities.GetArgumentList(argument, ArgumentProcessorUtilities.SemiColonArgumentSeparator, "test exception."); - argumentList.SequenceEqual(new string[] { "abc.txt", "tracelevel=info", "newkey=newvalue" }); + Assert.IsTrue(e.GetType().Equals(typeof(CommandLineException))); + Assert.IsTrue(e.Message.Contains("test exception.")); } + } - [TestMethod] - [DataRow(new string[] { "key1=value1", "invalidPair", "key2=value2"})] - public void GetArgumentParametersShouldThrowErrorOnInvalidParameters(string[] parameterArgs) + [TestMethod] + [DataRow("abc.txt;tracelevel=info;newkey=newvalue")] + [DataRow(";;;abc.txt;;;tracelevel=info;;;newkey=newvalue;;;;")] + public void GetArgumentListShouldReturnCorrectArgumentList(string argument) + { + var argumentList = ArgumentProcessorUtilities.GetArgumentList(argument, ArgumentProcessorUtilities.SemiColonArgumentSeparator, "test exception."); + argumentList.SequenceEqual(new string[] { "abc.txt", "tracelevel=info", "newkey=newvalue" }); + } + + [TestMethod] + [DataRow(new string[] { "key1=value1", "invalidPair", "key2=value2" })] + public void GetArgumentParametersShouldThrowErrorOnInvalidParameters(string[] parameterArgs) + { + try { - try - { - ArgumentProcessorUtilities.GetArgumentParameters(parameterArgs, ArgumentProcessorUtilities.EqualNameValueSeparator, "test exception."); - } - catch (Exception e) - { - Assert.IsTrue(e.GetType().Equals(typeof(CommandLineException))); - Assert.IsTrue(e.Message.Contains("test exception.")); - } + ArgumentProcessorUtilities.GetArgumentParameters(parameterArgs, ArgumentProcessorUtilities.EqualNameValueSeparator, "test exception."); } - - [TestMethod] - public void GetArgumentParametersShouldReturnCorrectParameterDictionary() + catch (Exception e) { - var parameterDict = ArgumentProcessorUtilities.GetArgumentParameters(new string[] { "key1=value1", "key2=value2", "key3=value3" }, ArgumentProcessorUtilities.EqualNameValueSeparator, "test exception."); - - var expectedDict = new Dictionary { { "key1", "value1"}, { "key2", "value2"}, { "key3", "value3"} }; - CollectionAssert.AreEqual(parameterDict.OrderBy(kv => kv.Key).ToList(), expectedDict.OrderBy(kv => kv.Key).ToList()); + Assert.IsTrue(e.GetType().Equals(typeof(CommandLineException))); + Assert.IsTrue(e.Message.Contains("test exception.")); } } + + [TestMethod] + public void GetArgumentParametersShouldReturnCorrectParameterDictionary() + { + var parameterDict = ArgumentProcessorUtilities.GetArgumentParameters(new string[] { "key1=value1", "key2=value2", "key3=value3" }, ArgumentProcessorUtilities.EqualNameValueSeparator, "test exception."); + + var expectedDict = new Dictionary { { "key1", "value1" }, { "key2", "value2" }, { "key3", "value3" } }; + CollectionAssert.AreEqual(parameterDict.OrderBy(kv => kv.Key).ToList(), expectedDict.OrderBy(kv => kv.Key).ToList()); + } } \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Program.cs b/test/vstest.console.UnitTests/Program.cs index 845923d3c9..7ed2395162 100644 --- a/test/vstest.console.UnitTests/Program.cs +++ b/test/vstest.console.UnitTests/Program.cs @@ -1,11 +1,11 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests; + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - } } } \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Publisher/MetricsPublisherFactoryTests.cs b/test/vstest.console.UnitTests/Publisher/MetricsPublisherFactoryTests.cs index 0ba4da07d1..0864c3fdff 100644 --- a/test/vstest.console.UnitTests/Publisher/MetricsPublisherFactoryTests.cs +++ b/test/vstest.console.UnitTests/Publisher/MetricsPublisherFactoryTests.cs @@ -1,36 +1,35 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace vstest.console.UnitTests.Publisher -{ - using Microsoft.VisualStudio.TestPlatform.CommandLine.Publisher; - using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace vstest.console.UnitTests.Publisher; + +using Microsoft.VisualStudio.TestPlatform.CommandLine.Publisher; +using Microsoft.VisualStudio.TestTools.UnitTesting; - [TestClass] - public class MetricsPublisherFactoryTests +[TestClass] +public class MetricsPublisherFactoryTests +{ + [TestMethod] + public void GetMetricsPublisherShouldReturnNoOpMetricsPublisherIfTelemetryOptedOutAndNotInDesignMode() { - [TestMethod] - public void GetMetricsPublisherShouldReturnNoOpMetricsPublisherIfTelemetryOptedOutAndNotInDesignMode() - { - var result = MetricsPublisherFactory.GetMetricsPublisher(false, false); + var result = MetricsPublisherFactory.GetMetricsPublisher(false, false); - Assert.IsTrue(result.Result is NoOpMetricsPublisher); - } + Assert.IsTrue(result.Result is NoOpMetricsPublisher); + } - [TestMethod] - public void GetMetricsPublisherShouldReturnNoOpMetricsPublisherIfTelemetryOptedInAndInDesignMode() - { - var result = MetricsPublisherFactory.GetMetricsPublisher(true, true); + [TestMethod] + public void GetMetricsPublisherShouldReturnNoOpMetricsPublisherIfTelemetryOptedInAndInDesignMode() + { + var result = MetricsPublisherFactory.GetMetricsPublisher(true, true); - Assert.IsTrue(result.Result is NoOpMetricsPublisher); - } + Assert.IsTrue(result.Result is NoOpMetricsPublisher); + } - [TestMethod] - public void GetMetricsPublisherShouldReturnNoOpMetricsPublisherIfTelemetryOptedOutAndInDesignMode() - { - var result = MetricsPublisherFactory.GetMetricsPublisher(false, true); + [TestMethod] + public void GetMetricsPublisherShouldReturnNoOpMetricsPublisherIfTelemetryOptedOutAndInDesignMode() + { + var result = MetricsPublisherFactory.GetMetricsPublisher(false, true); - Assert.IsTrue(result.Result is NoOpMetricsPublisher); - } + Assert.IsTrue(result.Result is NoOpMetricsPublisher); } -} +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/Publisher/TextFileTelemetryPublisherTests.cs b/test/vstest.console.UnitTests/Publisher/TextFileTelemetryPublisherTests.cs index 39fb8027eb..16cd632cbd 100644 --- a/test/vstest.console.UnitTests/Publisher/TextFileTelemetryPublisherTests.cs +++ b/test/vstest.console.UnitTests/Publisher/TextFileTelemetryPublisherTests.cs @@ -1,50 +1,49 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace vstest.console.UnitTests.Publisher -{ - using System.Collections.Generic; +namespace vstest.console.UnitTests.Publisher; + +using System.Collections.Generic; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Publisher; - using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Publisher; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; +using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; +using Moq; + +[TestClass] +public class TextFileTelemetryPublisherTests +{ + [TestMethod] + public void LogToFileShouldCreateDirectoryIfNotExists() + { + var publishMetrics = new TextFileTelemetryPublisher(); + var dummyDictionary = new Dictionary(); + var mockFileHelper = new Mock(); + mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(false); + dummyDictionary.Add("DummyMessage://", "DummyValue"); + dummyDictionary.Add("Dummy2", "DummyValue2"); + + // Act. + publishMetrics.LogToFile("dummyevent", dummyDictionary, mockFileHelper.Object); + + // Verify. + mockFileHelper.Verify(fh => fh.CreateDirectory(It.IsAny()), Times.Once); + } - [TestClass] - public class TextFileTelemetryPublisherTests + [TestMethod] + public void LogToFileShouldWriteAllText() { - [TestMethod] - public void LogToFileShouldCreateDirectoryIfNotExists() - { - var publishMetrics = new TextFileTelemetryPublisher(); - var dummyDictionary = new Dictionary(); - var mockFileHelper = new Mock(); - mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(false); - dummyDictionary.Add("DummyMessage://", "DummyValue"); - dummyDictionary.Add("Dummy2", "DummyValue2"); - - // Act. - publishMetrics.LogToFile("dummyevent", dummyDictionary, mockFileHelper.Object); - - // Verify. - mockFileHelper.Verify(fh => fh.CreateDirectory(It.IsAny()), Times.Once); - } - - [TestMethod] - public void LogToFileShouldWriteAllText() - { - var publishMetrics = new TextFileTelemetryPublisher(); - var dummyDictionary = new Dictionary(); - var mockFileHelper = new Mock(); - dummyDictionary.Add("DummyMessage://", "DummyValue"); - dummyDictionary.Add("Dummy2", "DummyValue2"); - - // Act. - publishMetrics.LogToFile("dummyevent", dummyDictionary, mockFileHelper.Object); - - // Verify. - mockFileHelper.Verify(fh => fh.WriteAllTextToFile(It.IsAny(), It.IsAny()), Times.Once); - } + var publishMetrics = new TextFileTelemetryPublisher(); + var dummyDictionary = new Dictionary(); + var mockFileHelper = new Mock(); + dummyDictionary.Add("DummyMessage://", "DummyValue"); + dummyDictionary.Add("Dummy2", "DummyValue2"); + + // Act. + publishMetrics.LogToFile("dummyevent", dummyDictionary, mockFileHelper.Object); + + // Verify. + mockFileHelper.Verify(fh => fh.WriteAllTextToFile(It.IsAny(), It.IsAny()), Times.Once); } } \ No newline at end of file diff --git a/test/vstest.console.UnitTests/StringExtensions.cs b/test/vstest.console.UnitTests/StringExtensions.cs index 718f6e4610..8ea6cb13c5 100644 --- a/test/vstest.console.UnitTests/StringExtensions.cs +++ b/test/vstest.console.UnitTests/StringExtensions.cs @@ -1,47 +1,46 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests; + +using System; + +public static class StringExtensions { - using System; + /// + /// Replace all \r\n with \n to get Unix line endings to make strings easy to compare while still + /// keeping the formatting in mind. + /// + /// + public static string NormalizeLineEndings(this string text) + { + return text.Replace("\r\n", "\n"); + } - public static class StringExtensions + /// + /// Replace whitespace with printable characters (and still keep \r newlines for easy readability) + /// + /// + public static string ShowWhiteSpace(this string text) { - /// - /// Replace all \r\n with \n to get Unix line endings to make strings easy to compare while still - /// keeping the formatting in mind. - /// - /// - public static string NormalizeLineEndings(this string text) + // use mongolian vowel separator as placeholder for the newline that we add for formatting + var placeholder = "\u180E"; + if (text.Contains(placeholder)) { - return text.Replace("\r\n", "\n"); + throw new InvalidOperationException( + "The text contains mongolian vowel separator character that we use as a placeholder."); } - /// - /// Replace whitespace with printable characters (and still keep \r newlines for easy readability) - /// - /// - public static string ShowWhiteSpace(this string text) - { - // use mongolian vowel separator as placeholder for the newline that we add for formatting - var placeholder = "\u180E"; - if (text.Contains(placeholder)) - { - throw new InvalidOperationException( - "The text contains mongolian vowel separator character that we use as a placeholder."); - } - - var whiteSpaced = text - .Replace("\r\n", "\\r\\n\u180E") - .Replace("\r", "\\r") - .Replace("\n", "\\n\u180E") - .Replace("\t", "\\t") - .Replace(" ", "␣") - .Replace("\u180E", "\n"); + var whiteSpaced = text + .Replace("\r\n", "\\r\\n\u180E") + .Replace("\r", "\\r") + .Replace("\n", "\\n\u180E") + .Replace("\t", "\\t") + .Replace(" ", "␣") + .Replace("\u180E", "\n"); - // prepend one newline to get better output from assertion where both expected - // and actual output start on the same position - return "\n" + whiteSpaced; - } + // prepend one newline to get better output from assertion where both expected + // and actual output start on the same position + return "\n" + whiteSpaced; } } \ No newline at end of file diff --git a/test/vstest.console.UnitTests/TestDoubles/DummyCommandLineOptions.cs b/test/vstest.console.UnitTests/TestDoubles/DummyCommandLineOptions.cs index 9c62b4679e..519085bd32 100644 --- a/test/vstest.console.UnitTests/TestDoubles/DummyCommandLineOptions.cs +++ b/test/vstest.console.UnitTests/TestDoubles/DummyCommandLineOptions.cs @@ -1,11 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace vstest.console.UnitTests.TestDoubles -{ - using Microsoft.VisualStudio.TestPlatform.CommandLine; +namespace vstest.console.UnitTests.TestDoubles; + +using Microsoft.VisualStudio.TestPlatform.CommandLine; - internal class DummyCommandLineOptions : CommandLineOptions - { - } -} +internal class DummyCommandLineOptions : CommandLineOptions +{ +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/TestDoubles/DummyLoggerEvents.cs b/test/vstest.console.UnitTests/TestDoubles/DummyLoggerEvents.cs index 6c5a0f9bd3..817d4af901 100644 --- a/test/vstest.console.UnitTests/TestDoubles/DummyLoggerEvents.cs +++ b/test/vstest.console.UnitTests/TestDoubles/DummyLoggerEvents.cs @@ -1,26 +1,26 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace vstest.console.UnitTests.TestDoubles -{ - using System; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +namespace vstest.console.UnitTests.TestDoubles; + +using System; + +using Microsoft.VisualStudio.TestPlatform.Common.Logging; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - internal class DummyLoggerEvents : InternalTestLoggerEvents +internal class DummyLoggerEvents : InternalTestLoggerEvents +{ + public DummyLoggerEvents(TestSessionMessageLogger testSessionMessageLogger) : base(testSessionMessageLogger) { - public DummyLoggerEvents(TestSessionMessageLogger testSessionMessageLogger) : base(testSessionMessageLogger) - { - } + } - public override event EventHandler TestResult; - public override event EventHandler TestRunComplete; - public override event EventHandler TestRunMessage; + public override event EventHandler TestResult; + public override event EventHandler TestRunComplete; + public override event EventHandler TestRunMessage; - public bool EventsSubscribed() - { - return TestResult != null && TestRunComplete != null && TestRunMessage != null; - } + public bool EventsSubscribed() + { + return TestResult != null && TestRunComplete != null && TestRunMessage != null; } -} +} \ No newline at end of file diff --git a/test/vstest.console.UnitTests/TestDoubles/DummyTestRunResultAggregator.cs b/test/vstest.console.UnitTests/TestDoubles/DummyTestRunResultAggregator.cs index 1aafeeaf4f..ef65589545 100644 --- a/test/vstest.console.UnitTests/TestDoubles/DummyTestRunResultAggregator.cs +++ b/test/vstest.console.UnitTests/TestDoubles/DummyTestRunResultAggregator.cs @@ -1,11 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace vstest.console.UnitTests.TestDoubles -{ - using Microsoft.VisualStudio.TestPlatform.CommandLine; +namespace vstest.console.UnitTests.TestDoubles; + +using Microsoft.VisualStudio.TestPlatform.CommandLine; - internal class DummyTestRunResultAggregator : TestRunResultAggregator - { - } +internal class DummyTestRunResultAggregator : TestRunResultAggregator +{ } \ No newline at end of file diff --git a/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs b/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs index 0ab9bad45b..43ca8040d5 100644 --- a/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs +++ b/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs @@ -1,2482 +1,2382 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace vstest.console.UnitTests.TestPlatformHelpers +namespace vstest.console.UnitTests.TestPlatformHelpers; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; +using Microsoft.VisualStudio.TestPlatform.CommandLine; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using Microsoft.VisualStudio.TestPlatform.CommandLine.Publisher; +using Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers; +using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Common.Logging; +using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using System.Runtime.Versioning; +using Microsoft.VisualStudio.TestPlatform.CommandLineUtilities; + +using Moq; + +using TestDoubles; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; + +[TestClass] +public class TestRequestManagerTests { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Linq; - using System.Threading; - using System.Threading.Tasks; - - using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; - using Microsoft.VisualStudio.TestPlatform.CommandLine; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Publisher; - using Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.Common.Logging; - using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - using System.Runtime.Versioning; - using Microsoft.VisualStudio.TestPlatform.CommandLineUtilities; - - using Moq; - - using vstest.console.UnitTests.TestDoubles; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; - - [TestClass] - public class TestRequestManagerTests - { - private DummyLoggerEvents mockLoggerEvents; - private CommandLineOptions commandLineOptions; - private Mock mockTestPlatform; - private Mock mockOutput; - private Mock mockDiscoveryRequest; - private Mock mockRunRequest; - private Mock mockAssemblyMetadataProvider; - private InferHelper inferHelper; - private ITestRequestManager testRequestManager; - private Mock mockTestPlatformEventSource; - private ProtocolConfig protocolConfig; - private Task mockMetricsPublisherTask; - private Mock mockMetricsPublisher; - private Mock mockProcessHelper; - private Mock mockAttachmentsProcessingManager; - - private const string DefaultRunsettings = @" - - - - "; - - public TestRequestManagerTests() - { - this.mockLoggerEvents = new DummyLoggerEvents(TestSessionMessageLogger.Instance); - this.commandLineOptions = new DummyCommandLineOptions(); - this.mockOutput = new Mock(); - this.mockTestPlatform = new Mock(); - this.mockDiscoveryRequest = new Mock(); - this.mockRunRequest = new Mock(); - this.mockTestPlatformEventSource = new Mock(); - this.protocolConfig = new ProtocolConfig(); - this.mockAssemblyMetadataProvider = new Mock(); - this.inferHelper = new InferHelper(this.mockAssemblyMetadataProvider.Object); - var testRunResultAggregator = new DummyTestRunResultAggregator(); - this.mockProcessHelper = new Mock(); - - this.mockMetricsPublisher = new Mock(); - this.mockMetricsPublisherTask = Task.FromResult(this.mockMetricsPublisher.Object); - this.mockAttachmentsProcessingManager = new Mock(); - this.testRequestManager = new TestRequestManager( - this.commandLineOptions, - this.mockTestPlatform.Object, - testRunResultAggregator, - this.mockTestPlatformEventSource.Object, - this.inferHelper, - this.mockMetricsPublisherTask, - this.mockProcessHelper.Object, - this.mockAttachmentsProcessingManager.Object); - this.mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(this.mockDiscoveryRequest.Object); - this.mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(this.mockRunRequest.Object); - this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) - .Returns(Architecture.X86); - this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) - .Returns(new FrameworkName(Constants.DotNetFramework40)); - this.mockProcessHelper.Setup(x => x.GetCurrentProcessId()).Returns(1234); - this.mockProcessHelper.Setup(x => x.GetProcessName(It.IsAny())).Returns("dotnet.exe"); - } - - [TestCleanup] - public void Cleanup() - { - CommandLineOptions.Instance.Reset(); + private DummyLoggerEvents _mockLoggerEvents; + private readonly CommandLineOptions _commandLineOptions; + private readonly Mock _mockTestPlatform; + private readonly Mock _mockDiscoveryRequest; + private readonly Mock _mockRunRequest; + private readonly Mock _mockAssemblyMetadataProvider; + private readonly InferHelper _inferHelper; + private ITestRequestManager _testRequestManager; + private readonly Mock _mockTestPlatformEventSource; + private readonly ProtocolConfig _protocolConfig; + private readonly Task _mockMetricsPublisherTask; + private readonly Mock _mockMetricsPublisher; + private readonly Mock _mockProcessHelper; + private readonly Mock _mockAttachmentsProcessingManager; + + private const string DefaultRunsettings = @" + + + + "; + + public TestRequestManagerTests() + { + _mockLoggerEvents = new DummyLoggerEvents(TestSessionMessageLogger.Instance); + _commandLineOptions = new DummyCommandLineOptions(); + _mockTestPlatform = new Mock(); + _mockDiscoveryRequest = new Mock(); + _mockRunRequest = new Mock(); + _mockTestPlatformEventSource = new Mock(); + _protocolConfig = new ProtocolConfig(); + _mockAssemblyMetadataProvider = new Mock(); + _inferHelper = new InferHelper(_mockAssemblyMetadataProvider.Object); + var testRunResultAggregator = new DummyTestRunResultAggregator(); + _mockProcessHelper = new Mock(); + + _mockMetricsPublisher = new Mock(); + _mockMetricsPublisherTask = Task.FromResult(_mockMetricsPublisher.Object); + _mockAttachmentsProcessingManager = new Mock(); + _testRequestManager = new TestRequestManager( + _commandLineOptions, + _mockTestPlatform.Object, + testRunResultAggregator, + _mockTestPlatformEventSource.Object, + _inferHelper, + _mockMetricsPublisherTask, + _mockProcessHelper.Object, + _mockAttachmentsProcessingManager.Object); + _mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())) + .Returns(_mockDiscoveryRequest.Object); + _mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())) + .Returns(_mockRunRequest.Object); + _mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) + .Returns(Architecture.X86); + _mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) + .Returns(new FrameworkName(Constants.DotNetFramework40)); + _mockProcessHelper.Setup(x => x.GetCurrentProcessId()).Returns(1234); + _mockProcessHelper.Setup(x => x.GetProcessName(It.IsAny())).Returns("dotnet.exe"); + } - // Opt out the Telemetry - Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "0"); - } + [TestCleanup] + public void Cleanup() + { + CommandLineOptions.Instance.Reset(); - [TestMethod] - public void TestRequestManagerShouldNotInitializeConsoleLoggerIfDesignModeIsSet() - { - CommandLineOptions.Instance.IsDesignMode = true; - this.mockLoggerEvents = new DummyLoggerEvents(TestSessionMessageLogger.Instance); - var requestManager = new TestRequestManager(CommandLineOptions.Instance, - new Mock().Object, - TestRunResultAggregator.Instance, - new Mock().Object, - this.inferHelper, - this.mockMetricsPublisherTask, - this.mockProcessHelper.Object, - this.mockAttachmentsProcessingManager.Object); - - Assert.IsFalse(this.mockLoggerEvents.EventsSubscribed()); - } + // Opt out the Telemetry + Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "0"); + } - [TestMethod] - public void InitializeExtensionsShouldCallTestPlatformToClearAndUpdateExtensions() - { - var paths = new List() { "a", "b" }; - this.testRequestManager.InitializeExtensions(paths, false); + [TestMethod] + public void TestRequestManagerShouldNotInitializeConsoleLoggerIfDesignModeIsSet() + { + CommandLineOptions.Instance.IsDesignMode = true; + _mockLoggerEvents = new DummyLoggerEvents(TestSessionMessageLogger.Instance); + _ = new TestRequestManager(CommandLineOptions.Instance, + new Mock().Object, + TestRunResultAggregator.Instance, + new Mock().Object, + _inferHelper, + _mockMetricsPublisherTask, + _mockProcessHelper.Object, + _mockAttachmentsProcessingManager.Object); + + Assert.IsFalse(_mockLoggerEvents.EventsSubscribed()); + } - this.mockTestPlatform.Verify(mt => mt.ClearExtensions(), Times.Once); - this.mockTestPlatform.Verify(mt => mt.UpdateExtensions(paths, false), Times.Once); - } + [TestMethod] + public void InitializeExtensionsShouldCallTestPlatformToClearAndUpdateExtensions() + { + var paths = new List() { "a", "b" }; + _testRequestManager.InitializeExtensions(paths, false); - [TestMethod] - public void ResetShouldResetCommandLineOptionsInstance() - { - var oldInstance = CommandLineOptions.Instance; - this.testRequestManager.ResetOptions(); + _mockTestPlatform.Verify(mt => mt.ClearExtensions(), Times.Once); + _mockTestPlatform.Verify(mt => mt.UpdateExtensions(paths, false), Times.Once); + } - var newInstance = CommandLineOptions.Instance; + [TestMethod] + public void ResetShouldResetCommandLineOptionsInstance() + { + var oldInstance = CommandLineOptions.Instance; + _testRequestManager.ResetOptions(); - Assert.AreNotEqual(oldInstance, newInstance, "CommandLineOptions must be cleaned up"); - } + var newInstance = CommandLineOptions.Instance; - [TestMethod] - public void DiscoverTestsShouldReadTheBatchSizeFromSettingsAndSetItForDiscoveryCriteria() - { - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a" }, - RunSettings = - @" - - - 15 - - " - }; - - DiscoveryCriteria actualDiscoveryCriteria = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => - { - actualDiscoveryCriteria = discoveryCriteria; - }).Returns(mockDiscoveryRequest.Object); + Assert.AreNotEqual(oldInstance, newInstance, "CommandLineOptions must be cleaned up"); + } - this.testRequestManager.DiscoverTests(payload, new Mock().Object, this.protocolConfig); - Assert.AreEqual(15, actualDiscoveryCriteria.FrequencyOfDiscoveredTestsEvent); - } + [TestMethod] + public void DiscoverTestsShouldReadTheBatchSizeFromSettingsAndSetItForDiscoveryCriteria() + { + var payload = new DiscoveryRequestPayload() + { + Sources = new List() { "a" }, + RunSettings = + @" + + + 15 + + " + }; + + DiscoveryCriteria actualDiscoveryCriteria = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => actualDiscoveryCriteria = discoveryCriteria).Returns(mockDiscoveryRequest.Object); + + _testRequestManager.DiscoverTests(payload, new Mock().Object, _protocolConfig); + Assert.AreEqual(15, actualDiscoveryCriteria.FrequencyOfDiscoveredTestsEvent); + } - [TestMethod] - public void DiscoverTestsShouldCallTestPlatformAndSucceed() + [TestMethod] + public void DiscoverTestsShouldCallTestPlatformAndSucceed() + { + var payload = new DiscoveryRequestPayload() { - var payload = new DiscoveryRequestPayload() + Sources = new List() { "a", "b" }, + RunSettings = DefaultRunsettings + }; + + var createDiscoveryRequestCalled = 0; + DiscoveryCriteria actualDiscoveryCriteria = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => { - Sources = new List() { "a", "b" }, - RunSettings = DefaultRunsettings - }; - - var createDiscoveryRequestCalled = 0; - DiscoveryCriteria actualDiscoveryCriteria = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => - { - createDiscoveryRequestCalled++; - actualDiscoveryCriteria = discoveryCriteria; - }).Returns(mockDiscoveryRequest.Object); + createDiscoveryRequestCalled++; + actualDiscoveryCriteria = discoveryCriteria; + }).Returns(mockDiscoveryRequest.Object); - var mockDiscoveryRegistrar = new Mock(); + var mockDiscoveryRegistrar = new Mock(); - string testCaseFilterValue = "TestFilter"; - CommandLineOptions.Instance.TestCaseFilterValue = testCaseFilterValue; - this.testRequestManager = new TestRequestManager(CommandLineOptions.Instance, - this.mockTestPlatform.Object, - TestRunResultAggregator.Instance, - this.mockTestPlatformEventSource.Object, - this.inferHelper, - this.mockMetricsPublisherTask, - this.mockProcessHelper.Object, - this.mockAttachmentsProcessingManager.Object); + string testCaseFilterValue = "TestFilter"; + CommandLineOptions.Instance.TestCaseFilterValue = testCaseFilterValue; + _testRequestManager = new TestRequestManager(CommandLineOptions.Instance, + _mockTestPlatform.Object, + TestRunResultAggregator.Instance, + _mockTestPlatformEventSource.Object, + _inferHelper, + _mockMetricsPublisherTask, + _mockProcessHelper.Object, + _mockAttachmentsProcessingManager.Object); - this.testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, this.protocolConfig); + _testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, _protocolConfig); - Assert.AreEqual(testCaseFilterValue, actualDiscoveryCriteria.TestCaseFilter, "TestCaseFilter must be set"); + Assert.AreEqual(testCaseFilterValue, actualDiscoveryCriteria.TestCaseFilter, "TestCaseFilter must be set"); - Assert.AreEqual(1, createDiscoveryRequestCalled, "CreateDiscoveryRequest must be invoked only once."); - Assert.AreEqual(2, actualDiscoveryCriteria.Sources.Count(), "All Sources must be used for discovery request"); - Assert.AreEqual("a", actualDiscoveryCriteria.Sources.First(), "First Source in list is incorrect"); - Assert.AreEqual("b", actualDiscoveryCriteria.Sources.ElementAt(1), "Second Source in list is incorrect"); + Assert.AreEqual(1, createDiscoveryRequestCalled, "CreateDiscoveryRequest must be invoked only once."); + Assert.AreEqual(2, actualDiscoveryCriteria.Sources.Count(), "All Sources must be used for discovery request"); + Assert.AreEqual("a", actualDiscoveryCriteria.Sources.First(), "First Source in list is incorrect"); + Assert.AreEqual("b", actualDiscoveryCriteria.Sources.ElementAt(1), "Second Source in list is incorrect"); - // Default frequency is set to 10, unless specified in runsettings. - Assert.AreEqual(10, actualDiscoveryCriteria.FrequencyOfDiscoveredTestsEvent); + // Default frequency is set to 10, unless specified in runsettings. + Assert.AreEqual(10, actualDiscoveryCriteria.FrequencyOfDiscoveredTestsEvent); - mockDiscoveryRegistrar.Verify(md => md.RegisterDiscoveryEvents(It.IsAny()), Times.Once); - mockDiscoveryRegistrar.Verify(md => md.UnregisterDiscoveryEvents(It.IsAny()), Times.Once); + mockDiscoveryRegistrar.Verify(md => md.RegisterDiscoveryEvents(It.IsAny()), Times.Once); + mockDiscoveryRegistrar.Verify(md => md.UnregisterDiscoveryEvents(It.IsAny()), Times.Once); - mockDiscoveryRequest.Verify(md => md.DiscoverAsync(), Times.Once); + mockDiscoveryRequest.Verify(md => md.DiscoverAsync(), Times.Once); - mockTestPlatformEventSource.Verify(mt => mt.DiscoveryRequestStart(), Times.Once); - mockTestPlatformEventSource.Verify(mt => mt.DiscoveryRequestStop(), Times.Once); - } + _mockTestPlatformEventSource.Verify(mt => mt.DiscoveryRequestStart(), Times.Once); + _mockTestPlatformEventSource.Verify(mt => mt.DiscoveryRequestStop(), Times.Once); + } - [TestMethod] - public void DiscoverTestsShouldPassSameProtocolConfigInRequestData() + [TestMethod] + public void DiscoverTestsShouldPassSameProtocolConfigInRequestData() + { + var payload = new DiscoveryRequestPayload() { - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a", "b" }, - RunSettings = DefaultRunsettings - }; - - var mockProtocolConfig = new ProtocolConfig { Version = 5 }; - - IRequestData actualRequestData = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => { actualRequestData = requestData; }).Returns(mockDiscoveryRequest.Object); - - var mockDiscoveryRegistrar = new Mock(); - - string testCaseFilterValue = "TestFilter"; - CommandLineOptions.Instance.TestCaseFilterValue = testCaseFilterValue; - this.testRequestManager = new TestRequestManager(CommandLineOptions.Instance, - this.mockTestPlatform.Object, - TestRunResultAggregator.Instance, - this.mockTestPlatformEventSource.Object, - this.inferHelper, - this.mockMetricsPublisherTask, - this.mockProcessHelper.Object, - this.mockAttachmentsProcessingManager.Object); - - // Act - this.testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); - - // Verify. - Assert.AreEqual(5, actualRequestData.ProtocolConfig.Version); - } + Sources = new List() { "a", "b" }, + RunSettings = DefaultRunsettings + }; + var mockProtocolConfig = new ProtocolConfig { Version = 5 }; - [TestMethod] - public void DiscoverTestsShouldCollectMetrics() - { - // Opt in the Telemetry - Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + IRequestData actualRequestData = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => actualRequestData = requestData).Returns(mockDiscoveryRequest.Object); - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a.dll", "b.dll" }, - RunSettings = @" - - 2 - x86 - Framework35 - True - - - 169.254.193.190 - - " - }; - - var mockProtocolConfig = new ProtocolConfig { Version = 5 }; - var mockDiscoveryRegistrar = new Mock(); - - IRequestData actualRequestData = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => { actualRequestData = requestData; }).Returns(mockDiscoveryRequest.Object); - - this.testRequestManager = new TestRequestManager( - CommandLineOptions.Instance, - this.mockTestPlatform.Object, - TestRunResultAggregator.Instance, - this.mockTestPlatformEventSource.Object, - this.inferHelper, - this.mockMetricsPublisherTask, - this.mockProcessHelper.Object, - this.mockAttachmentsProcessingManager.Object); - - - // Act - this.testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); - - // Verify. - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.TargetDevice, out var targetDevice)); - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.MaxCPUcount, out var maxcount)); - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.TargetPlatform, out var targetPlatform)); - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.DisableAppDomain, out var disableAppDomain)); - Assert.AreEqual("Other", targetDevice); - Assert.AreEqual(2, maxcount); - Assert.AreEqual("X86", targetPlatform.ToString()); - Assert.AreEqual(true, disableAppDomain); - } + var mockDiscoveryRegistrar = new Mock(); - [TestMethod] - public void DiscoverTestsShouldCollectTargetDeviceLocalMachineIfTargetDeviceStringisEmpty() - { - // Opt in the Telemetry - Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + string testCaseFilterValue = "TestFilter"; + CommandLineOptions.Instance.TestCaseFilterValue = testCaseFilterValue; + _testRequestManager = new TestRequestManager(CommandLineOptions.Instance, + _mockTestPlatform.Object, + TestRunResultAggregator.Instance, + _mockTestPlatformEventSource.Object, + _inferHelper, + _mockMetricsPublisherTask, + _mockProcessHelper.Object, + _mockAttachmentsProcessingManager.Object); - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a", "b" }, - RunSettings = @" - - - - " - }; - - var mockProtocolConfig = new ProtocolConfig { Version = 5 }; - var mockDiscoveryRegistrar = new Mock(); - - IRequestData actualRequestData = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => { actualRequestData = requestData; }).Returns(mockDiscoveryRequest.Object); - - this.testRequestManager = new TestRequestManager( - CommandLineOptions.Instance, - this.mockTestPlatform.Object, - TestRunResultAggregator.Instance, - this.mockTestPlatformEventSource.Object, - this.inferHelper, - this.mockMetricsPublisherTask, - this.mockProcessHelper.Object, - this.mockAttachmentsProcessingManager.Object); - - - // Act - this.testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); - - // Verify. - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.TargetDevice, out var targetDevice)); - Assert.AreEqual("Local Machine", targetDevice); - } + // Act + _testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); - [TestMethod] - public void DiscoverTestsShouldCollectTargetDeviceIfTargetDeviceIsDevice() - { - // Opt in the Telemetry - Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + // Verify. + Assert.AreEqual(5, actualRequestData.ProtocolConfig.Version); + } - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a", "b" }, - RunSettings = @" - - Device - - " - }; - - var mockProtocolConfig = new ProtocolConfig { Version = 5 }; - var mockDiscoveryRegistrar = new Mock(); - - IRequestData actualRequestData = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => { actualRequestData = requestData; }).Returns(mockDiscoveryRequest.Object); - - this.testRequestManager = new TestRequestManager( - CommandLineOptions.Instance, - this.mockTestPlatform.Object, - TestRunResultAggregator.Instance, - this.mockTestPlatformEventSource.Object, - this.inferHelper, - this.mockMetricsPublisherTask, - this.mockProcessHelper.Object, - this.mockAttachmentsProcessingManager.Object); - - - // Act - this.testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); - - // Verify. - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.TargetDevice, out object targetDevice)); - Assert.AreEqual("Device", targetDevice); - } - [TestMethod] - public void DiscoverTestsShouldCollectTargetDeviceIfTargetDeviceIsEmulator() - { - // Opt in the Telemetry - Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + [TestMethod] + public void DiscoverTestsShouldCollectMetrics() + { + // Opt in the Telemetry + Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + + var payload = new DiscoveryRequestPayload() + { + Sources = new List() { "a.dll", "b.dll" }, + RunSettings = @" + + 2 + x86 + Framework35 + True + + + 169.254.193.190 + + " + }; + + var mockProtocolConfig = new ProtocolConfig { Version = 5 }; + var mockDiscoveryRegistrar = new Mock(); + + IRequestData actualRequestData = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => actualRequestData = requestData).Returns(mockDiscoveryRequest.Object); + + _testRequestManager = new TestRequestManager( + CommandLineOptions.Instance, + _mockTestPlatform.Object, + TestRunResultAggregator.Instance, + _mockTestPlatformEventSource.Object, + _inferHelper, + _mockMetricsPublisherTask, + _mockProcessHelper.Object, + _mockAttachmentsProcessingManager.Object); + + + // Act + _testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); + + // Verify. + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.TargetDevice, out var targetDevice)); + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.MaxCPUcount, out var maxcount)); + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.TargetPlatform, out var targetPlatform)); + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.DisableAppDomain, out var disableAppDomain)); + Assert.AreEqual("Other", targetDevice); + Assert.AreEqual(2, maxcount); + Assert.AreEqual("X86", targetPlatform.ToString()); + Assert.AreEqual(true, disableAppDomain); + } - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a", "b" }, - RunSettings = @" - - Emulator 8.1 U1 WVGA 4 inch 512MB - - " - }; - - var mockProtocolConfig = new ProtocolConfig { Version = 5 }; - var mockDiscoveryRegistrar = new Mock(); - - IRequestData actualRequestData = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => { actualRequestData = requestData; }).Returns(mockDiscoveryRequest.Object); - - this.testRequestManager = new TestRequestManager( - CommandLineOptions.Instance, - this.mockTestPlatform.Object, - TestRunResultAggregator.Instance, - this.mockTestPlatformEventSource.Object, - this.inferHelper, - this.mockMetricsPublisherTask, - this.mockProcessHelper.Object, - this.mockAttachmentsProcessingManager.Object); - - - // Act - this.testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); - - // Verify. - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.TargetDevice, out var targetDevice)); - Assert.AreEqual("Emulator 8.1 U1 WVGA 4 inch 512MB", targetDevice); - } + [TestMethod] + public void DiscoverTestsShouldCollectTargetDeviceLocalMachineIfTargetDeviceStringisEmpty() + { + // Opt in the Telemetry + Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + + var payload = new DiscoveryRequestPayload() + { + Sources = new List() { "a", "b" }, + RunSettings = @" + + + + " + }; + + var mockProtocolConfig = new ProtocolConfig { Version = 5 }; + var mockDiscoveryRegistrar = new Mock(); + + IRequestData actualRequestData = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => actualRequestData = requestData).Returns(mockDiscoveryRequest.Object); + + _testRequestManager = new TestRequestManager( + CommandLineOptions.Instance, + _mockTestPlatform.Object, + TestRunResultAggregator.Instance, + _mockTestPlatformEventSource.Object, + _inferHelper, + _mockMetricsPublisherTask, + _mockProcessHelper.Object, + _mockAttachmentsProcessingManager.Object); + + + // Act + _testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); + + // Verify. + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.TargetDevice, out var targetDevice)); + Assert.AreEqual("Local Machine", targetDevice); + } - [TestMethod] - public void DiscoverTestsShouldCollectCommands() - { - // Opt in the Telemetry - Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + [TestMethod] + public void DiscoverTestsShouldCollectTargetDeviceIfTargetDeviceIsDevice() + { + // Opt in the Telemetry + Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + + var payload = new DiscoveryRequestPayload() + { + Sources = new List() { "a", "b" }, + RunSettings = @" + + Device + + " + }; + + var mockProtocolConfig = new ProtocolConfig { Version = 5 }; + var mockDiscoveryRegistrar = new Mock(); + + IRequestData actualRequestData = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => actualRequestData = requestData).Returns(mockDiscoveryRequest.Object); + + _testRequestManager = new TestRequestManager( + CommandLineOptions.Instance, + _mockTestPlatform.Object, + TestRunResultAggregator.Instance, + _mockTestPlatformEventSource.Object, + _inferHelper, + _mockMetricsPublisherTask, + _mockProcessHelper.Object, + _mockAttachmentsProcessingManager.Object); + + + // Act + _testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); + + // Verify. + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.TargetDevice, out object targetDevice)); + Assert.AreEqual("Device", targetDevice); + } - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a", "b" }, - RunSettings = @" - - Device - - " - }; - - var mockProtocolConfig = new ProtocolConfig { Version = 5 }; - var mockDiscoveryRegistrar = new Mock(); - - IRequestData actualRequestData = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => { actualRequestData = requestData; }).Returns(mockDiscoveryRequest.Object); - - this.testRequestManager = new TestRequestManager( - CommandLineOptions.Instance, - this.mockTestPlatform.Object, - TestRunResultAggregator.Instance, - this.mockTestPlatformEventSource.Object, - this.inferHelper, - this.mockMetricsPublisherTask, - this.mockProcessHelper.Object, - this.mockAttachmentsProcessingManager.Object); - - CommandLineOptions.Instance.Parallel = true; - CommandLineOptions.Instance.EnableCodeCoverage = true; - CommandLineOptions.Instance.InIsolation = true; - CommandLineOptions.Instance.UseVsixExtensions = true; - CommandLineOptions.Instance.SettingsFile = @"c://temp/.runsettings"; - - // Act - this.testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); - - // Verify - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.CommandLineSwitches, out var commandLineSwitches)); - - var commandLineArray = commandLineSwitches.ToString(); - - Assert.IsTrue(commandLineArray.Contains("/Parallel")); - Assert.IsTrue(commandLineArray.Contains("/EnableCodeCoverage")); - Assert.IsTrue(commandLineArray.Contains("/InIsolation")); - Assert.IsTrue(commandLineArray.Contains("/UseVsixExtensions")); - Assert.IsTrue(commandLineArray.Contains("/settings//.RunSettings")); - } + [TestMethod] + public void DiscoverTestsShouldCollectTargetDeviceIfTargetDeviceIsEmulator() + { + // Opt in the Telemetry + Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + + var payload = new DiscoveryRequestPayload() + { + Sources = new List() { "a", "b" }, + RunSettings = @" + + Emulator 8.1 U1 WVGA 4 inch 512MB + + " + }; + + var mockProtocolConfig = new ProtocolConfig { Version = 5 }; + var mockDiscoveryRegistrar = new Mock(); + + IRequestData actualRequestData = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => actualRequestData = requestData).Returns(mockDiscoveryRequest.Object); + + _testRequestManager = new TestRequestManager( + CommandLineOptions.Instance, + _mockTestPlatform.Object, + TestRunResultAggregator.Instance, + _mockTestPlatformEventSource.Object, + _inferHelper, + _mockMetricsPublisherTask, + _mockProcessHelper.Object, + _mockAttachmentsProcessingManager.Object); + + + // Act + _testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); + + // Verify. + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.TargetDevice, out var targetDevice)); + Assert.AreEqual("Emulator 8.1 U1 WVGA 4 inch 512MB", targetDevice); + } - [TestMethod] - public void DiscoverTestsShouldCollectTestSettings() - { - // Opt in the Telemetry - Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + [TestMethod] + public void DiscoverTestsShouldCollectCommands() + { + // Opt in the Telemetry + Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + + var payload = new DiscoveryRequestPayload() + { + Sources = new List() { "a", "b" }, + RunSettings = @" + + Device + + " + }; + + var mockProtocolConfig = new ProtocolConfig { Version = 5 }; + var mockDiscoveryRegistrar = new Mock(); + + IRequestData actualRequestData = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => actualRequestData = requestData).Returns(mockDiscoveryRequest.Object); + + _testRequestManager = new TestRequestManager( + CommandLineOptions.Instance, + _mockTestPlatform.Object, + TestRunResultAggregator.Instance, + _mockTestPlatformEventSource.Object, + _inferHelper, + _mockMetricsPublisherTask, + _mockProcessHelper.Object, + _mockAttachmentsProcessingManager.Object); + + CommandLineOptions.Instance.Parallel = true; + CommandLineOptions.Instance.EnableCodeCoverage = true; + CommandLineOptions.Instance.InIsolation = true; + CommandLineOptions.Instance.UseVsixExtensions = true; + CommandLineOptions.Instance.SettingsFile = @"c://temp/.runsettings"; + + // Act + _testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); + + // Verify + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.CommandLineSwitches, out var commandLineSwitches)); + + var commandLineArray = commandLineSwitches.ToString(); + + Assert.IsTrue(commandLineArray.Contains("/Parallel")); + Assert.IsTrue(commandLineArray.Contains("/EnableCodeCoverage")); + Assert.IsTrue(commandLineArray.Contains("/InIsolation")); + Assert.IsTrue(commandLineArray.Contains("/UseVsixExtensions")); + Assert.IsTrue(commandLineArray.Contains("/settings//.RunSettings")); + } - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a", "b" }, - RunSettings = @" - - Device - - " - }; - - var mockProtocolConfig = new ProtocolConfig { Version = 5 }; - var mockDiscoveryRegistrar = new Mock(); - - IRequestData actualRequestData = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => { actualRequestData = requestData; }).Returns(mockDiscoveryRequest.Object); - - this.testRequestManager = new TestRequestManager( - CommandLineOptions.Instance, - this.mockTestPlatform.Object, - TestRunResultAggregator.Instance, - this.mockTestPlatformEventSource.Object, - this.inferHelper, - this.mockMetricsPublisherTask, - this.mockProcessHelper.Object, - this.mockAttachmentsProcessingManager.Object); - - CommandLineOptions.Instance.SettingsFile = @"c://temp/.testsettings"; - - // Act - this.testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); - - // Verify - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.CommandLineSwitches, out var commandLineSwitches)); - - var commandLineArray = commandLineSwitches.ToString(); - - Assert.IsTrue(commandLineArray.Contains("/settings//.TestSettings")); - } + [TestMethod] + public void DiscoverTestsShouldCollectTestSettings() + { + // Opt in the Telemetry + Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); - [TestMethod] - public void DiscoverTestsShouldCollectVsmdiFile() + var payload = new DiscoveryRequestPayload() { - // Opt in the Telemetry - Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + Sources = new List() { "a", "b" }, + RunSettings = @" + + Device + + " + }; - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a", "b" }, - RunSettings = @" - - Device - - " - }; - - var mockProtocolConfig = new ProtocolConfig { Version = 5 }; - var mockDiscoveryRegistrar = new Mock(); - - IRequestData actualRequestData = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => { actualRequestData = requestData; }).Returns(mockDiscoveryRequest.Object); - - this.testRequestManager = new TestRequestManager( - CommandLineOptions.Instance, - this.mockTestPlatform.Object, - TestRunResultAggregator.Instance, - this.mockTestPlatformEventSource.Object, - this.inferHelper, - this.mockMetricsPublisherTask, - this.mockProcessHelper.Object, - this.mockAttachmentsProcessingManager.Object); - - CommandLineOptions.Instance.SettingsFile = @"c://temp/.vsmdi"; - - // Act - this.testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); - - // Verify - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.CommandLineSwitches, out var commandLineSwitches)); - - var commandLineArray = commandLineSwitches.ToString(); - - Assert.IsTrue(commandLineArray.Contains("/settings//.vsmdi")); - } + var mockProtocolConfig = new ProtocolConfig { Version = 5 }; + var mockDiscoveryRegistrar = new Mock(); - [TestMethod] - public void DiscoverTestsShouldCollectTestRunConfigFile() - { - // Opt in the Telemetry - Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + IRequestData actualRequestData = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => actualRequestData = requestData).Returns(mockDiscoveryRequest.Object); - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a", "b" }, - RunSettings = @" - - Device - - " - }; - - var mockProtocolConfig = new ProtocolConfig { Version = 5 }; - var mockDiscoveryRegistrar = new Mock(); - - IRequestData actualRequestData = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => { actualRequestData = requestData; }).Returns(mockDiscoveryRequest.Object); - - this.testRequestManager = new TestRequestManager( - CommandLineOptions.Instance, - this.mockTestPlatform.Object, - TestRunResultAggregator.Instance, - this.mockTestPlatformEventSource.Object, - this.inferHelper, - this.mockMetricsPublisherTask, - this.mockProcessHelper.Object, - this.mockAttachmentsProcessingManager.Object); - - CommandLineOptions.Instance.SettingsFile = @"c://temp/.testrunConfig"; - - // Act - this.testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); - - // Verify - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.CommandLineSwitches, out var commandLineSwitches)); - - var commandLineArray = commandLineSwitches.ToString(); - - Assert.IsTrue(commandLineArray.Contains("/settings//.testrunConfig")); - } + _testRequestManager = new TestRequestManager( + CommandLineOptions.Instance, + _mockTestPlatform.Object, + TestRunResultAggregator.Instance, + _mockTestPlatformEventSource.Object, + _inferHelper, + _mockMetricsPublisherTask, + _mockProcessHelper.Object, + _mockAttachmentsProcessingManager.Object); - [TestMethod] - public void DiscoverTestsShouldUpdateFrameworkAndPlatformIfNotSpecifiedInDesignMode() - { - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - - " - }; - this.commandLineOptions.IsDesignMode = true; - this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) - .Returns(Architecture.ARM); - this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) - .Returns(new FrameworkName(Constants.DotNetFramework46)); - DiscoveryCriteria actualDiscoveryCriteria = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => - { - actualDiscoveryCriteria = discoveryCriteria; - }).Returns(mockDiscoveryRequest.Object); + CommandLineOptions.Instance.SettingsFile = @"c://temp/.testsettings"; - this.testRequestManager.DiscoverTests(payload, new Mock().Object, this.protocolConfig); + // Act + _testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); - this.mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny())); - this.mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny())); + // Verify + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.CommandLineSwitches, out var commandLineSwitches)); - Assert.IsTrue(actualDiscoveryCriteria.RunSettings.Contains(Constants.DotNetFramework46)); - Assert.IsTrue(actualDiscoveryCriteria.RunSettings.Contains(nameof(Architecture.ARM))); - } + var commandLineArray = commandLineSwitches.ToString(); - [TestMethod] - public void DiscoverTestsShouldNotUpdateFrameworkAndPlatformIfSpecifiedInDesignMode() - { - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a" }, - RunSettings = - $@" - - - {Constants.DotNetFramework46} - {Architecture.ARM} - - " - }; - this.commandLineOptions.IsDesignMode = true; - this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) - .Returns(Architecture.X86); - this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) - .Returns(new FrameworkName(Constants.DotNetFramework451)); - DiscoveryCriteria actualDiscoveryCriteria = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => - { - actualDiscoveryCriteria = discoveryCriteria; - }).Returns(mockDiscoveryRequest.Object); + Assert.IsTrue(commandLineArray.Contains("/settings//.TestSettings")); + } - this.testRequestManager.DiscoverTests(payload, new Mock().Object, this.protocolConfig); + [TestMethod] + public void DiscoverTestsShouldCollectVsmdiFile() + { + // Opt in the Telemetry + Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); - this.mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny()), Times.Never); - this.mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny()), Times.Never); + var payload = new DiscoveryRequestPayload() + { + Sources = new List() { "a", "b" }, + RunSettings = @" + + Device + + " + }; - Assert.IsTrue(actualDiscoveryCriteria.RunSettings.Contains(Constants.DotNetFramework46)); - Assert.IsTrue(actualDiscoveryCriteria.RunSettings.Contains(nameof(Architecture.ARM))); - } + var mockProtocolConfig = new ProtocolConfig { Version = 5 }; + var mockDiscoveryRegistrar = new Mock(); - [TestMethod] - public void DiscoverTestsShouldUpdateFrameworkAndPlatformInCommandLineScenariosIfNotSpecified() - { - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - - " - }; - this.commandLineOptions.IsDesignMode = false; - this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) - .Returns(Architecture.ARM); - this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) - .Returns(new FrameworkName(Constants.DotNetFramework46)); - DiscoveryCriteria actualDiscoveryCriteria = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => - { - actualDiscoveryCriteria = discoveryCriteria; - }).Returns(mockDiscoveryRequest.Object); + IRequestData actualRequestData = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => actualRequestData = requestData).Returns(mockDiscoveryRequest.Object); - this.testRequestManager.DiscoverTests(payload, new Mock().Object, this.protocolConfig); - this.mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny())); - this.mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny())); + _testRequestManager = new TestRequestManager( + CommandLineOptions.Instance, + _mockTestPlatform.Object, + TestRunResultAggregator.Instance, + _mockTestPlatformEventSource.Object, + _inferHelper, + _mockMetricsPublisherTask, + _mockProcessHelper.Object, + _mockAttachmentsProcessingManager.Object); - Assert.IsTrue(actualDiscoveryCriteria.RunSettings.Contains(Constants.DotNetFramework46)); - Assert.IsTrue(actualDiscoveryCriteria.RunSettings.Contains(nameof(Architecture.ARM))); - } + CommandLineOptions.Instance.SettingsFile = @"c://temp/.vsmdi"; - [TestMethod] - public void DiscoverTestsShouldNotUpdateFrameworkAndPlatformInCommandLineScenariosIfSpecifiedButInferred() - { - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - - " - }; - this.commandLineOptions.IsDesignMode = false; - this.commandLineOptions.TargetFrameworkVersion = Framework.DefaultFramework; - this.commandLineOptions.TargetArchitecture = Architecture.X86; - this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) - .Returns(Architecture.ARM); - this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) - .Returns(new FrameworkName(Constants.DotNetFramework46)); - DiscoveryCriteria actualDiscoveryCriteria = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform - .Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())) - .Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => - { - actualDiscoveryCriteria = discoveryCriteria; - }).Returns(mockDiscoveryRequest.Object); - - this.testRequestManager.DiscoverTests(payload, - new Mock().Object, this.protocolConfig); - this.mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny()), Times.Once); - this.mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny()), Times.Once); - - Assert.IsFalse(actualDiscoveryCriteria.RunSettings.Contains(Constants.DotNetFramework46)); - Assert.IsFalse(actualDiscoveryCriteria.RunSettings.Contains(nameof(Architecture.ARM))); - } + // Act + _testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); - [TestMethod] - public void DiscoverTestsShouldPublishMetrics() - { - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a", "b" } - }; - var mockProtocolConfig = new ProtocolConfig { Version = 2 }; - var mockDiscoveryRegistrar = new Mock(); + // Verify + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.CommandLineSwitches, out var commandLineSwitches)); - // Act - this.testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); + var commandLineArray = commandLineSwitches.ToString(); - // Verify. - this.mockMetricsPublisher.Verify(mp => mp.PublishMetrics(TelemetryDataConstants.TestDiscoveryCompleteEvent, It.IsAny>()), Times.Once); - } + Assert.IsTrue(commandLineArray.Contains("/settings//.vsmdi")); + } + + [TestMethod] + public void DiscoverTestsShouldCollectTestRunConfigFile() + { + // Opt in the Telemetry + Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); - [TestMethod] - public void CancelShouldNotThrowExceptionIfTestRunRequestHasBeenDisposed() + var payload = new DiscoveryRequestPayload() { - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a", "b" }, - RunSettings = DefaultRunsettings - }; + Sources = new List() { "a", "b" }, + RunSettings = @" + + Device + + " + }; - var mockRunEventsRegistrar = new Mock(); - var mockCustomlauncher = new Mock(); + var mockProtocolConfig = new ProtocolConfig { Version = 5 }; + var mockDiscoveryRegistrar = new Mock(); - this.testRequestManager.RunTests(payload, mockCustomlauncher.Object, mockRunEventsRegistrar.Object, this.protocolConfig); - this.testRequestManager.CancelTestRun(); - } + IRequestData actualRequestData = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => actualRequestData = requestData).Returns(mockDiscoveryRequest.Object); - [TestMethod] - public void AbortShouldNotThrowExceptionIfTestRunRequestHasBeenDisposed() - { - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a", "b" }, - RunSettings = DefaultRunsettings - }; + _testRequestManager = new TestRequestManager( + CommandLineOptions.Instance, + _mockTestPlatform.Object, + TestRunResultAggregator.Instance, + _mockTestPlatformEventSource.Object, + _inferHelper, + _mockMetricsPublisherTask, + _mockProcessHelper.Object, + _mockAttachmentsProcessingManager.Object); - var mockRunEventsRegistrar = new Mock(); - var mockCustomlauncher = new Mock(); + CommandLineOptions.Instance.SettingsFile = @"c://temp/.testrunConfig"; - this.testRequestManager.RunTests(payload, mockCustomlauncher.Object, mockRunEventsRegistrar.Object, this.protocolConfig); - this.testRequestManager.AbortTestRun(); - } + // Act + _testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); - [TestMethod] - public void RunTestsShouldReadTheBatchSizeFromSettingsAndSetItForTestRunCriteria() - { - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a" }, - RunSettings = - @" - - - 15 - - " - }; - - TestRunCriteria actualTestRunCriteria = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - actualTestRunCriteria = runCriteria; - }).Returns(mockDiscoveryRequest.Object); + // Verify + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.CommandLineSwitches, out var commandLineSwitches)); - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig); - Assert.AreEqual(15, actualTestRunCriteria.FrequencyOfRunStatsChangeEvent); - } + var commandLineArray = commandLineSwitches.ToString(); - [TestMethod] - public void RunTestsShouldNotThrowForFramework35() - { - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - Framework35 - - " - }; - - TestRunCriteria actualTestRunCriteria = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - actualTestRunCriteria = runCriteria; - }).Returns(mockDiscoveryRequest.Object); - this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())).Returns(new FrameworkName(Constants.DotNetFramework35)); + Assert.IsTrue(commandLineArray.Contains("/settings//.testrunConfig")); + } - var mockRunEventsRegistrar = new Mock(); - var mockCustomlauncher = new Mock(); + [TestMethod] + public void DiscoverTestsShouldUpdateFrameworkAndPlatformIfNotSpecifiedInDesignMode() + { + var payload = new DiscoveryRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + + " + }; + _commandLineOptions.IsDesignMode = true; + _mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) + .Returns(Architecture.ARM); + _mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) + .Returns(new FrameworkName(Constants.DotNetFramework46)); + DiscoveryCriteria actualDiscoveryCriteria = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => actualDiscoveryCriteria = discoveryCriteria).Returns(mockDiscoveryRequest.Object); + + _testRequestManager.DiscoverTests(payload, new Mock().Object, _protocolConfig); + + _mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny())); + _mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny())); + + Assert.IsTrue(actualDiscoveryCriteria.RunSettings.Contains(Constants.DotNetFramework46)); + Assert.IsTrue(actualDiscoveryCriteria.RunSettings.Contains(nameof(Architecture.ARM))); + } - this.testRequestManager.RunTests(payload, mockCustomlauncher.Object, mockRunEventsRegistrar.Object, this.protocolConfig); + [TestMethod] + public void DiscoverTestsShouldNotUpdateFrameworkAndPlatformIfSpecifiedInDesignMode() + { + var payload = new DiscoveryRequestPayload() + { + Sources = new List() { "a" }, + RunSettings = + $@" + + + {Constants.DotNetFramework46} + {Architecture.ARM} + + " + }; + _commandLineOptions.IsDesignMode = true; + _mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) + .Returns(Architecture.X86); + _mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) + .Returns(new FrameworkName(Constants.DotNetFramework451)); + DiscoveryCriteria actualDiscoveryCriteria = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => actualDiscoveryCriteria = discoveryCriteria).Returns(mockDiscoveryRequest.Object); + + _testRequestManager.DiscoverTests(payload, new Mock().Object, _protocolConfig); + + _mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny()), Times.Never); + _mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny()), Times.Never); + + Assert.IsTrue(actualDiscoveryCriteria.RunSettings.Contains(Constants.DotNetFramework46)); + Assert.IsTrue(actualDiscoveryCriteria.RunSettings.Contains(nameof(Architecture.ARM))); + } - mockRunEventsRegistrar.Verify(lw => lw.LogWarning("Framework35 is not supported. For projects targeting .Net Framework 3.5, test will run in CLR 4.0 \"compatibility mode\"."), Times.Once); - mockTestPlatformEventSource.Verify(mt => mt.ExecutionRequestStart(), Times.Once); - mockTestPlatformEventSource.Verify(mt => mt.ExecutionRequestStop(), Times.Once); - } + [TestMethod] + public void DiscoverTestsShouldUpdateFrameworkAndPlatformInCommandLineScenariosIfNotSpecified() + { + var payload = new DiscoveryRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + + " + }; + _commandLineOptions.IsDesignMode = false; + _mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) + .Returns(Architecture.ARM); + _mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) + .Returns(new FrameworkName(Constants.DotNetFramework46)); + DiscoveryCriteria actualDiscoveryCriteria = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => actualDiscoveryCriteria = discoveryCriteria).Returns(mockDiscoveryRequest.Object); + + _testRequestManager.DiscoverTests(payload, new Mock().Object, _protocolConfig); + _mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny())); + _mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny())); + + Assert.IsTrue(actualDiscoveryCriteria.RunSettings.Contains(Constants.DotNetFramework46)); + Assert.IsTrue(actualDiscoveryCriteria.RunSettings.Contains(nameof(Architecture.ARM))); + } - [TestMethod] - public void RunTestsShouldPassSameProtocolConfigInRequestData() - { - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a" }, - RunSettings = DefaultRunsettings - }; - var mockProtocolConfig = new ProtocolConfig { Version = 5 }; - IRequestData actualRequestData = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - actualRequestData = requestData; - }).Returns(mockDiscoveryRequest.Object); - - // Act. - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, mockProtocolConfig); - - // Verify. - Assert.AreEqual(5, actualRequestData.ProtocolConfig.Version); - } + [TestMethod] + public void DiscoverTestsShouldNotUpdateFrameworkAndPlatformInCommandLineScenariosIfSpecifiedButInferred() + { + var payload = new DiscoveryRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + + " + }; + _commandLineOptions.IsDesignMode = false; + _commandLineOptions.TargetFrameworkVersion = Framework.DefaultFramework; + _commandLineOptions.TargetArchitecture = Architecture.X86; + _mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) + .Returns(Architecture.ARM); + _mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) + .Returns(new FrameworkName(Constants.DotNetFramework46)); + DiscoveryCriteria actualDiscoveryCriteria = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform + .Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())) + .Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => actualDiscoveryCriteria = discoveryCriteria).Returns(mockDiscoveryRequest.Object); + + _testRequestManager.DiscoverTests(payload, + new Mock().Object, _protocolConfig); + _mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny()), Times.Once); + _mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny()), Times.Once); + + Assert.IsFalse(actualDiscoveryCriteria.RunSettings.Contains(Constants.DotNetFramework46)); + Assert.IsFalse(actualDiscoveryCriteria.RunSettings.Contains(nameof(Architecture.ARM))); + } - [TestMethod] - public void RunTestsShouldCollectCommands() + [TestMethod] + public void DiscoverTestsShouldPublishMetrics() + { + var payload = new DiscoveryRequestPayload() { - // Opt in the Telemetry - Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + Sources = new List() { "a", "b" } + }; + var mockProtocolConfig = new ProtocolConfig { Version = 2 }; + var mockDiscoveryRegistrar = new Mock(); - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a" }, - RunSettings = DefaultRunsettings - }; - var mockProtocolConfig = new ProtocolConfig { Version = 5 }; - IRequestData actualRequestData = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - actualRequestData = requestData; - }).Returns(mockDiscoveryRequest.Object); - - this.testRequestManager = new TestRequestManager( - CommandLineOptions.Instance, - this.mockTestPlatform.Object, - TestRunResultAggregator.Instance, - this.mockTestPlatformEventSource.Object, - this.inferHelper, - this.mockMetricsPublisherTask, - this.mockProcessHelper.Object, - this.mockAttachmentsProcessingManager.Object); - - CommandLineOptions.Instance.Parallel = true; - CommandLineOptions.Instance.EnableCodeCoverage = true; - CommandLineOptions.Instance.InIsolation = true; - CommandLineOptions.Instance.UseVsixExtensions = true; - CommandLineOptions.Instance.SettingsFile = @"c://temp/.runsettings"; - - // Act. - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, mockProtocolConfig); - - // Verify - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.CommandLineSwitches, out var commandLineSwitches)); - - var commandLineArray = commandLineSwitches.ToString(); - - Assert.IsTrue(commandLineArray.Contains("/Parallel")); - Assert.IsTrue(commandLineArray.Contains("/EnableCodeCoverage")); - Assert.IsTrue(commandLineArray.Contains("/InIsolation")); - Assert.IsTrue(commandLineArray.Contains("/UseVsixExtensions")); - Assert.IsTrue(commandLineArray.Contains("/settings//.RunSettings")); - } + // Act + _testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); + + // Verify. + _mockMetricsPublisher.Verify(mp => mp.PublishMetrics(TelemetryDataConstants.TestDiscoveryCompleteEvent, It.IsAny>()), Times.Once); + } - [TestMethod] - public void RunTestsShouldCollectTelemetryForLegacySettings() + [TestMethod] + public void CancelShouldNotThrowExceptionIfTestRunRequestHasBeenDisposed() + { + var payload = new TestRunRequestPayload() { - // Opt in the Telemetry - Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + Sources = new List() { "a", "b" }, + RunSettings = DefaultRunsettings + }; - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a" }, - RunSettings = @" - - - - - - - - - - - - - - - - " - }; - var mockProtocolConfig = new ProtocolConfig { Version = 5 }; - IRequestData actualRequestData = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - actualRequestData = requestData; - }).Returns(mockDiscoveryRequest.Object); - - this.testRequestManager = new TestRequestManager( - CommandLineOptions.Instance, - this.mockTestPlatform.Object, - TestRunResultAggregator.Instance, - this.mockTestPlatformEventSource.Object, - this.inferHelper, - this.mockMetricsPublisherTask, - this.mockProcessHelper.Object, - this.mockAttachmentsProcessingManager.Object); - - // Act. - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, mockProtocolConfig); - - // Verify - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue("VS.TestRun.LegacySettings.Elements", out var legacySettingsNodes)); - StringAssert.Equals("Deployment, Scripts, Execution, AssemblyResolution, Timeouts, Hosts", legacySettingsNodes); - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue("VS.TestRun.LegacySettings.DeploymentAttributes", out var deploymentAttributes)); - StringAssert.Equals("enabled, deploySatelliteAssemblies", deploymentAttributes); - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue("VS.TestRun.LegacySettings.ExecutionAttributes", out var executionAttributes)); - StringAssert.Equals("hostProcessPlatform, parallelTestCount", executionAttributes); - - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.TestSettingsUsed, out var testSettingsUsed)); - Assert.IsFalse((bool)testSettingsUsed); - } + var mockRunEventsRegistrar = new Mock(); + var mockCustomlauncher = new Mock(); + + _testRequestManager.RunTests(payload, mockCustomlauncher.Object, mockRunEventsRegistrar.Object, _protocolConfig); + _testRequestManager.CancelTestRun(); + } - [TestMethod] - public void RunTestsShouldCollectTelemetryForTestSettingsEmbeddedInsideRunSettings() + [TestMethod] + public void AbortShouldNotThrowExceptionIfTestRunRequestHasBeenDisposed() + { + var payload = new TestRunRequestPayload() { - // Opt in the Telemetry - Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + Sources = new List() { "a", "b" }, + RunSettings = DefaultRunsettings + }; - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a" }, - RunSettings = @" - - true - ..\..\Foo.testsettings - - " - }; - var mockProtocolConfig = new ProtocolConfig { Version = 5 }; - IRequestData actualRequestData = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - actualRequestData = requestData; - }).Returns(mockDiscoveryRequest.Object); - - this.testRequestManager = new TestRequestManager( - CommandLineOptions.Instance, - this.mockTestPlatform.Object, - TestRunResultAggregator.Instance, - this.mockTestPlatformEventSource.Object, - this.inferHelper, - this.mockMetricsPublisherTask, - this.mockProcessHelper.Object, - this.mockAttachmentsProcessingManager.Object); - - // Act. - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, mockProtocolConfig); - - // Verify - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.TestSettingsUsed, out var testSettingsUsed)); - Assert.IsTrue((bool)testSettingsUsed); - } + var mockRunEventsRegistrar = new Mock(); + var mockCustomlauncher = new Mock(); - [TestMethod] - public void RunTestsShouldCollectMetrics() - { - // Opt in the Telemetry - Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + _testRequestManager.RunTests(payload, mockCustomlauncher.Object, mockRunEventsRegistrar.Object, _protocolConfig); + _testRequestManager.AbortTestRun(); + } - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = @" - - 2 - x86 - Framework35 - True - - - 169.254.193.190 - - " - }; - var mockProtocolConfig = new ProtocolConfig { Version = 5 }; - IRequestData actualRequestData = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - actualRequestData = requestData; - }).Returns(mockDiscoveryRequest.Object); - - this.testRequestManager = new TestRequestManager( - CommandLineOptions.Instance, - this.mockTestPlatform.Object, - TestRunResultAggregator.Instance, - this.mockTestPlatformEventSource.Object, - this.inferHelper, - this.mockMetricsPublisherTask, - this.mockProcessHelper.Object, - this.mockAttachmentsProcessingManager.Object); - - // Act. - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, mockProtocolConfig); - - // Verify - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.TargetDevice, out var targetDevice)); - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.MaxCPUcount, out var maxcount)); - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.TargetPlatform, out var targetPlatform)); - Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.DisableAppDomain, out var disableAppDomain)); - Assert.AreEqual("Other", targetDevice); - Assert.AreEqual(2, maxcount); - Assert.AreEqual("X86", targetPlatform.ToString()); - Assert.AreEqual(true, disableAppDomain); - } + [TestMethod] + public void RunTestsShouldReadTheBatchSizeFromSettingsAndSetItForTestRunCriteria() + { + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a" }, + RunSettings = + @" + + + 15 + + " + }; + + TestRunCriteria actualTestRunCriteria = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => actualTestRunCriteria = runCriteria).Returns(mockDiscoveryRequest.Object); + + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, _protocolConfig); + Assert.AreEqual(15, actualTestRunCriteria.FrequencyOfRunStatsChangeEvent); + } - [TestMethod] - public void RunTestsWithSourcesShouldCallTestPlatformAndSucceed() - { - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a", "b" }, - RunSettings = DefaultRunsettings - }; - - var createRunRequestCalled = 0; - TestRunCriteria observedCriteria = null; - var mockRunRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - createRunRequestCalled++; - observedCriteria = runCriteria; - }).Returns(mockRunRequest.Object); - - var mockRunEventsRegistrar = new Mock(); - var mockCustomlauncher = new Mock(); - - string testCaseFilterValue = "TestFilter"; - payload.TestPlatformOptions = new TestPlatformOptions { TestCaseFilter = testCaseFilterValue }; - this.testRequestManager = new TestRequestManager(CommandLineOptions.Instance, - this.mockTestPlatform.Object, - TestRunResultAggregator.Instance, - this.mockTestPlatformEventSource.Object, - this.inferHelper, - this.mockMetricsPublisherTask, - this.mockProcessHelper.Object, - this.mockAttachmentsProcessingManager.Object); - - this.testRequestManager.RunTests(payload, mockCustomlauncher.Object, mockRunEventsRegistrar.Object, this.protocolConfig); - - Assert.AreEqual(testCaseFilterValue, observedCriteria.TestCaseFilter, "TestCaseFilter must be set"); - - Assert.AreEqual(1, createRunRequestCalled, "CreateRunRequest must be invoked only once."); - Assert.AreEqual(2, observedCriteria.Sources.Count(), "All Sources must be used for discovery request"); - Assert.AreEqual("a", observedCriteria.Sources.First(), "First Source in list is incorrect"); - Assert.AreEqual("b", observedCriteria.Sources.ElementAt(1), "Second Source in list is incorrect"); - - // Check for the default value for the frequency - Assert.AreEqual(10, observedCriteria.FrequencyOfRunStatsChangeEvent); - mockRunEventsRegistrar.Verify(md => md.RegisterTestRunEvents(It.IsAny()), Times.Once); - mockRunEventsRegistrar.Verify(md => md.UnregisterTestRunEvents(It.IsAny()), Times.Once); - - mockRunRequest.Verify(md => md.ExecuteAsync(), Times.Once); - - mockTestPlatformEventSource.Verify(mt => mt.ExecutionRequestStart(), Times.Once); - mockTestPlatformEventSource.Verify(mt => mt.ExecutionRequestStop(), Times.Once); - } + [TestMethod] + public void RunTestsShouldNotThrowForFramework35() + { + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + Framework35 + + " + }; + + TestRunCriteria actualTestRunCriteria = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => actualTestRunCriteria = runCriteria).Returns(mockDiscoveryRequest.Object); + _mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())).Returns(new FrameworkName(Constants.DotNetFramework35)); + + var mockRunEventsRegistrar = new Mock(); + var mockCustomlauncher = new Mock(); + + _testRequestManager.RunTests(payload, mockCustomlauncher.Object, mockRunEventsRegistrar.Object, _protocolConfig); + + mockRunEventsRegistrar.Verify(lw => lw.LogWarning("Framework35 is not supported. For projects targeting .Net Framework 3.5, test will run in CLR 4.0 \"compatibility mode\"."), Times.Once); + _mockTestPlatformEventSource.Verify(mt => mt.ExecutionRequestStart(), Times.Once); + _mockTestPlatformEventSource.Verify(mt => mt.ExecutionRequestStop(), Times.Once); + } - [TestMethod] - public void RunTestsMultipleCallsShouldNotRunInParallel() - { - var payload1 = new TestRunRequestPayload() - { - Sources = new List() { "a" }, - RunSettings = DefaultRunsettings - }; + [TestMethod] + public void RunTestsShouldPassSameProtocolConfigInRequestData() + { + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a" }, + RunSettings = DefaultRunsettings + }; + var mockProtocolConfig = new ProtocolConfig { Version = 5 }; + IRequestData actualRequestData = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => actualRequestData = requestData).Returns(mockDiscoveryRequest.Object); + + // Act. + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, mockProtocolConfig); + + // Verify. + Assert.AreEqual(5, actualRequestData.ProtocolConfig.Version); + } - var payload2 = new TestRunRequestPayload() - { - Sources = new List() { "b" }, - RunSettings = DefaultRunsettings - }; - - var mockRunRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(mockRunRequest.Object); - - var mockRunEventsRegistrar1 = new Mock(); - var mockRunEventsRegistrar2 = new Mock(); - - // Setup the second one to wait - var sw = new Stopwatch(); - sw.Start(); - - long run1Start = 0; - long run1Stop = 0; - long run2Start = 0; - long run2Stop = 0; - mockRunEventsRegistrar1.Setup(md => md.RegisterTestRunEvents(It.IsAny())).Callback(() => - { - Thread.Sleep(10); - run1Start = sw.ElapsedMilliseconds; - Thread.Sleep(1); - }); - mockRunEventsRegistrar1.Setup(md => md.UnregisterTestRunEvents(It.IsAny())).Callback(() => - { - Thread.Sleep(10); - run1Stop = sw.ElapsedMilliseconds; - Thread.Sleep(10); - }); + [TestMethod] + public void RunTestsShouldCollectCommands() + { + // Opt in the Telemetry + Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a" }, + RunSettings = DefaultRunsettings + }; + var mockProtocolConfig = new ProtocolConfig { Version = 5 }; + IRequestData actualRequestData = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => actualRequestData = requestData).Returns(mockDiscoveryRequest.Object); + + _testRequestManager = new TestRequestManager( + CommandLineOptions.Instance, + _mockTestPlatform.Object, + TestRunResultAggregator.Instance, + _mockTestPlatformEventSource.Object, + _inferHelper, + _mockMetricsPublisherTask, + _mockProcessHelper.Object, + _mockAttachmentsProcessingManager.Object); + + CommandLineOptions.Instance.Parallel = true; + CommandLineOptions.Instance.EnableCodeCoverage = true; + CommandLineOptions.Instance.InIsolation = true; + CommandLineOptions.Instance.UseVsixExtensions = true; + CommandLineOptions.Instance.SettingsFile = @"c://temp/.runsettings"; + + // Act. + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, mockProtocolConfig); + + // Verify + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.CommandLineSwitches, out var commandLineSwitches)); + + var commandLineArray = commandLineSwitches.ToString(); + + Assert.IsTrue(commandLineArray.Contains("/Parallel")); + Assert.IsTrue(commandLineArray.Contains("/EnableCodeCoverage")); + Assert.IsTrue(commandLineArray.Contains("/InIsolation")); + Assert.IsTrue(commandLineArray.Contains("/UseVsixExtensions")); + Assert.IsTrue(commandLineArray.Contains("/settings//.RunSettings")); + } - mockRunEventsRegistrar2.Setup(md => md.RegisterTestRunEvents(It.IsAny())).Callback(() => - { - Thread.Sleep(10); - run2Start = sw.ElapsedMilliseconds; - Thread.Sleep(10); - }); - mockRunEventsRegistrar2.Setup(md => md.UnregisterTestRunEvents(It.IsAny())).Callback(() => - { - Thread.Sleep(10); - run2Stop = sw.ElapsedMilliseconds; - }); + [TestMethod] + public void RunTestsShouldCollectTelemetryForLegacySettings() + { + // Opt in the Telemetry + Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a" }, + RunSettings = @" + + + + + + + + + + + + + + + + " + }; + var mockProtocolConfig = new ProtocolConfig { Version = 5 }; + IRequestData actualRequestData = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => actualRequestData = requestData).Returns(mockDiscoveryRequest.Object); + + _testRequestManager = new TestRequestManager( + CommandLineOptions.Instance, + _mockTestPlatform.Object, + TestRunResultAggregator.Instance, + _mockTestPlatformEventSource.Object, + _inferHelper, + _mockMetricsPublisherTask, + _mockProcessHelper.Object, + _mockAttachmentsProcessingManager.Object); + + // Act. + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, mockProtocolConfig); + + // Verify + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue("VS.TestRun.LegacySettings.Elements", out var legacySettingsNodes)); + Equals("Deployment, Scripts, Execution, AssemblyResolution, Timeouts, Hosts", legacySettingsNodes); + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue("VS.TestRun.LegacySettings.DeploymentAttributes", out var deploymentAttributes)); + Equals("enabled, deploySatelliteAssemblies", deploymentAttributes); + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue("VS.TestRun.LegacySettings.ExecutionAttributes", out var executionAttributes)); + Equals("hostProcessPlatform, parallelTestCount", executionAttributes); + + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.TestSettingsUsed, out var testSettingsUsed)); + Assert.IsFalse((bool)testSettingsUsed); + } - var mockCustomlauncher = new Mock(); - var task1 = Task.Run(() => - { - this.testRequestManager.RunTests(payload1, mockCustomlauncher.Object, mockRunEventsRegistrar1.Object, this.protocolConfig); - }); - var task2 = Task.Run(() => - { - this.testRequestManager.RunTests(payload2, mockCustomlauncher.Object, mockRunEventsRegistrar2.Object, this.protocolConfig); - }); + [TestMethod] + public void RunTestsShouldCollectTelemetryForTestSettingsEmbeddedInsideRunSettings() + { + // Opt in the Telemetry + Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a" }, + RunSettings = @" + + true + ..\..\Foo.testsettings + + " + }; + var mockProtocolConfig = new ProtocolConfig { Version = 5 }; + IRequestData actualRequestData = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => actualRequestData = requestData).Returns(mockDiscoveryRequest.Object); + + _testRequestManager = new TestRequestManager( + CommandLineOptions.Instance, + _mockTestPlatform.Object, + TestRunResultAggregator.Instance, + _mockTestPlatformEventSource.Object, + _inferHelper, + _mockMetricsPublisherTask, + _mockProcessHelper.Object, + _mockAttachmentsProcessingManager.Object); + + // Act. + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, mockProtocolConfig); + + // Verify + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.TestSettingsUsed, out var testSettingsUsed)); + Assert.IsTrue((bool)testSettingsUsed); + } - Task.WaitAll(task1, task2); + [TestMethod] + public void RunTestsShouldCollectMetrics() + { + // Opt in the Telemetry + Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = @" + + 2 + x86 + Framework35 + True + + + 169.254.193.190 + + " + }; + var mockProtocolConfig = new ProtocolConfig { Version = 5 }; + IRequestData actualRequestData = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => actualRequestData = requestData).Returns(mockDiscoveryRequest.Object); + + _testRequestManager = new TestRequestManager( + CommandLineOptions.Instance, + _mockTestPlatform.Object, + TestRunResultAggregator.Instance, + _mockTestPlatformEventSource.Object, + _inferHelper, + _mockMetricsPublisherTask, + _mockProcessHelper.Object, + _mockAttachmentsProcessingManager.Object); + + // Act. + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, mockProtocolConfig); + + // Verify + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.TargetDevice, out var targetDevice)); + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.MaxCPUcount, out var maxcount)); + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.TargetPlatform, out var targetPlatform)); + Assert.IsTrue(actualRequestData.MetricsCollection.Metrics.TryGetValue(TelemetryDataConstants.DisableAppDomain, out var disableAppDomain)); + Assert.AreEqual("Other", targetDevice); + Assert.AreEqual(2, maxcount); + Assert.AreEqual("X86", targetPlatform.ToString()); + Assert.AreEqual(true, disableAppDomain); + } - if (run1Start < run2Start) - { - Assert.IsTrue((run2Stop > run2Start) - && (run2Start > run1Stop) - && (run1Stop > run1Start)); - } - else - { - Assert.IsTrue((run1Stop > run1Start) - && (run1Start > run2Stop) - && (run2Stop > run2Start)); - } - } + [TestMethod] + public void RunTestsWithSourcesShouldCallTestPlatformAndSucceed() + { + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a", "b" }, + RunSettings = DefaultRunsettings + }; + + var createRunRequestCalled = 0; + TestRunCriteria observedCriteria = null; + var mockRunRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => + { + createRunRequestCalled++; + observedCriteria = runCriteria; + }).Returns(mockRunRequest.Object); + + var mockRunEventsRegistrar = new Mock(); + var mockCustomlauncher = new Mock(); + + string testCaseFilterValue = "TestFilter"; + payload.TestPlatformOptions = new TestPlatformOptions { TestCaseFilter = testCaseFilterValue }; + _testRequestManager = new TestRequestManager(CommandLineOptions.Instance, + _mockTestPlatform.Object, + TestRunResultAggregator.Instance, + _mockTestPlatformEventSource.Object, + _inferHelper, + _mockMetricsPublisherTask, + _mockProcessHelper.Object, + _mockAttachmentsProcessingManager.Object); + + _testRequestManager.RunTests(payload, mockCustomlauncher.Object, mockRunEventsRegistrar.Object, _protocolConfig); + + Assert.AreEqual(testCaseFilterValue, observedCriteria.TestCaseFilter, "TestCaseFilter must be set"); + + Assert.AreEqual(1, createRunRequestCalled, "CreateRunRequest must be invoked only once."); + Assert.AreEqual(2, observedCriteria.Sources.Count(), "All Sources must be used for discovery request"); + Assert.AreEqual("a", observedCriteria.Sources.First(), "First Source in list is incorrect"); + Assert.AreEqual("b", observedCriteria.Sources.ElementAt(1), "Second Source in list is incorrect"); + + // Check for the default value for the frequency + Assert.AreEqual(10, observedCriteria.FrequencyOfRunStatsChangeEvent); + mockRunEventsRegistrar.Verify(md => md.RegisterTestRunEvents(It.IsAny()), Times.Once); + mockRunEventsRegistrar.Verify(md => md.UnregisterTestRunEvents(It.IsAny()), Times.Once); + + mockRunRequest.Verify(md => md.ExecuteAsync(), Times.Once); + + _mockTestPlatformEventSource.Verify(mt => mt.ExecutionRequestStart(), Times.Once); + _mockTestPlatformEventSource.Verify(mt => mt.ExecutionRequestStop(), Times.Once); + } - [TestMethod] - public void RunTestsShouldPublishMetrics() + [TestMethod] + public void RunTestsMultipleCallsShouldNotRunInParallel() + { + var payload1 = new TestRunRequestPayload() { - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a", "b" }, - RunSettings = DefaultRunsettings - }; + Sources = new List() { "a" }, + RunSettings = DefaultRunsettings + }; - var mockRunEventsRegistrar = new Mock(); - var mockCustomlauncher = new Mock(); + var payload2 = new TestRunRequestPayload() + { + Sources = new List() { "b" }, + RunSettings = DefaultRunsettings + }; - this.testRequestManager.RunTests(payload, mockCustomlauncher.Object, mockRunEventsRegistrar.Object, this.protocolConfig); + var mockRunRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())) + .Returns(mockRunRequest.Object); - this.mockMetricsPublisher.Verify(mp => mp.PublishMetrics(TelemetryDataConstants.TestExecutionCompleteEvent, It.IsAny>()), Times.Once); - } + var mockRunEventsRegistrar1 = new Mock(); + var mockRunEventsRegistrar2 = new Mock(); - // TODO: add tests in design mode and executor that they are handling all the exceptions properly including printing inner exception. + // Setup the second one to wait + var sw = new Stopwatch(); + sw.Start(); - [TestMethod] - public void RunTestsIfThrowsTestPlatformExceptionShouldThrowOut() + long run1Start = 0; + long run1Stop = 0; + long run2Start = 0; + long run2Stop = 0; + mockRunEventsRegistrar1.Setup(md => md.RegisterTestRunEvents(It.IsAny())).Callback(() => { - Assert.ThrowsException(() => RunTestsIfThrowsExceptionShouldThrowOut(new TestPlatformException("HelloWorld"))); - } - - [TestMethod] - public void RunTestsIfThrowsSettingsExceptionShouldThrowOut() + Thread.Sleep(10); + run1Start = sw.ElapsedMilliseconds; + Thread.Sleep(1); + }); + mockRunEventsRegistrar1.Setup(md => md.UnregisterTestRunEvents(It.IsAny())).Callback(() => { - Assert.ThrowsException(() => RunTestsIfThrowsExceptionShouldThrowOut(new SettingsException("HelloWorld"))); - } + Thread.Sleep(10); + run1Stop = sw.ElapsedMilliseconds; + Thread.Sleep(10); + }); - [TestMethod] - public void RunTestsIfThrowsInvalidOperationExceptionShouldThrowOut() + mockRunEventsRegistrar2.Setup(md => md.RegisterTestRunEvents(It.IsAny())).Callback(() => { - Assert.ThrowsException(() => RunTestsIfThrowsExceptionShouldThrowOut(new InvalidOperationException("HelloWorld"))); - } - - [TestMethod] - public void RunTestsIfThrowsExceptionShouldThrowOut() + Thread.Sleep(10); + run2Start = sw.ElapsedMilliseconds; + Thread.Sleep(10); + }); + mockRunEventsRegistrar2.Setup(md => md.UnregisterTestRunEvents(It.IsAny())).Callback(() => { - Assert.ThrowsException(() => RunTestsIfThrowsExceptionShouldThrowOut(new NotImplementedException("HelloWorld"))); - } + Thread.Sleep(10); + run2Stop = sw.ElapsedMilliseconds; + }); - [TestMethod] - public void DiscoverTestsIfThrowsTestPlatformExceptionShouldThrowOut() - { - Assert.ThrowsException(() => DiscoverTestsIfThrowsExceptionShouldThrowOut(new TestPlatformException("HelloWorld"))); - } + var mockCustomlauncher = new Mock(); + var task1 = Task.Run(() => _testRequestManager.RunTests(payload1, mockCustomlauncher.Object, mockRunEventsRegistrar1.Object, _protocolConfig)); + var task2 = Task.Run(() => _testRequestManager.RunTests(payload2, mockCustomlauncher.Object, mockRunEventsRegistrar2.Object, _protocolConfig)); - [TestMethod] - public void DiscoverTestsIfThrowsSettingsExceptionShouldThrowOut() - { - Assert.ThrowsException(() => DiscoverTestsIfThrowsExceptionShouldThrowOut(new SettingsException("HelloWorld"))); - } + Task.WaitAll(task1, task2); - [TestMethod] - public void DiscoverTestsIfThrowsInvalidOperationExceptionShouldThrowOut() + if (run1Start < run2Start) { - Assert.ThrowsException(() => DiscoverTestsIfThrowsExceptionShouldThrowOut(new InvalidOperationException("HelloWorld"))); + Assert.IsTrue((run2Stop > run2Start) + && (run2Start > run1Stop) + && (run1Stop > run1Start)); } - - [TestMethod] - public void DiscoverTestsIfThrowsExceptionShouldThrowOut() + else { - Assert.ThrowsException(() => DiscoverTestsIfThrowsExceptionShouldThrowOut(new NotImplementedException("HelloWorld"))); + Assert.IsTrue((run1Stop > run1Start) + && (run1Start > run2Stop) + && (run2Stop > run2Start)); } + } - [DataTestMethod] - [DataRow(true)] - [DataRow(false)] - public void DiscoverTestsShouldUpdateDesignModeAndCollectSourceInformation(bool designModeValue) + [TestMethod] + public void RunTestsShouldPublishMetrics() + { + var payload = new TestRunRequestPayload() { - var runsettings = ".NETFramework,Version=v4.5"; - var discoveryPayload = CreateDiscoveryPayload(runsettings); - this.commandLineOptions.IsDesignMode = designModeValue; + Sources = new List() { "a", "b" }, + RunSettings = DefaultRunsettings + }; - this.testRequestManager.DiscoverTests(discoveryPayload, new Mock().Object, this.protocolConfig); + var mockRunEventsRegistrar = new Mock(); + var mockCustomlauncher = new Mock(); - var designmode = $"{designModeValue}"; - this.mockTestPlatform.Verify( - tp => tp.CreateDiscoveryRequest(It.IsAny(), It.Is(dc => dc.RunSettings.Contains(designmode)), It.IsAny())); + _testRequestManager.RunTests(payload, mockCustomlauncher.Object, mockRunEventsRegistrar.Object, _protocolConfig); - var collectSourceInformation = $"{designModeValue}"; - this.mockTestPlatform.Verify( - tp => tp.CreateDiscoveryRequest(It.IsAny(), It.Is(dc => dc.RunSettings.Contains(collectSourceInformation)), It.IsAny())); - } + _mockMetricsPublisher.Verify(mp => mp.PublishMetrics(TelemetryDataConstants.TestExecutionCompleteEvent, It.IsAny>()), Times.Once); + } - [TestMethod] - public void DiscoverTestsShouldNotUpdateDesignModeIfUserHasSetDesignModeInRunSettings() - { - var runsettings = "False.NETFramework,Version=v4.5"; - var discoveryPayload = CreateDiscoveryPayload(runsettings); - this.commandLineOptions.IsDesignMode = true; + // TODO: add tests in design mode and executor that they are handling all the exceptions properly including printing inner exception. - this.testRequestManager.DiscoverTests(discoveryPayload, new Mock().Object, this.protocolConfig); + [TestMethod] + public void RunTestsIfThrowsTestPlatformExceptionShouldThrowOut() + { + Assert.ThrowsException(() => RunTestsIfThrowsExceptionShouldThrowOut(new TestPlatformException("HelloWorld"))); + } - var designmode = "False"; - this.mockTestPlatform.Verify( - tp => tp.CreateDiscoveryRequest(It.IsAny(), It.Is(dc => dc.RunSettings.Contains(designmode)), It.IsAny())); - } + [TestMethod] + public void RunTestsIfThrowsSettingsExceptionShouldThrowOut() + { + Assert.ThrowsException(() => RunTestsIfThrowsExceptionShouldThrowOut(new SettingsException("HelloWorld"))); + } - [DataTestMethod] - [DataRow(true)] - [DataRow(false)] - public void RunTestsShouldUpdateDesignModeIfRunnerIsInDesignMode(bool designModeValue) - { - var runsettings = - ".NETFramework,Version=v4.5"; - var payload = new TestRunRequestPayload - { - RunSettings = runsettings, - Sources = new List { "c:\\testproject.dll" } - }; - this.commandLineOptions.IsDesignMode = designModeValue; + [TestMethod] + public void RunTestsIfThrowsInvalidOperationExceptionShouldThrowOut() + { + Assert.ThrowsException(() => RunTestsIfThrowsExceptionShouldThrowOut(new InvalidOperationException("HelloWorld"))); + } - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig); + [TestMethod] + public void RunTestsIfThrowsExceptionShouldThrowOut() + { + Assert.ThrowsException(() => RunTestsIfThrowsExceptionShouldThrowOut(new NotImplementedException("HelloWorld"))); + } - var designmode = $"{designModeValue}"; - this.mockTestPlatform.Verify(tp => tp.CreateTestRunRequest(It.IsAny(), It.Is(rc => rc.TestRunSettings.Contains(designmode)), It.IsAny())); - } + [TestMethod] + public void DiscoverTestsIfThrowsTestPlatformExceptionShouldThrowOut() + { + Assert.ThrowsException(() => DiscoverTestsIfThrowsExceptionShouldThrowOut(new TestPlatformException("HelloWorld"))); + } - [DataTestMethod] - [DataRow(true)] - [DataRow(false)] - public void DiscoverTestsShouldNotUpdateCollectSourceInformationIfUserHasSetItInRunSettings(bool val) - { - var runsettings = $"{val}"; - var discoveryPayload = CreateDiscoveryPayload(runsettings); + [TestMethod] + public void DiscoverTestsIfThrowsSettingsExceptionShouldThrowOut() + { + Assert.ThrowsException(() => DiscoverTestsIfThrowsExceptionShouldThrowOut(new SettingsException("HelloWorld"))); + } - this.testRequestManager.DiscoverTests(discoveryPayload, new Mock().Object, this.protocolConfig); + [TestMethod] + public void DiscoverTestsIfThrowsInvalidOperationExceptionShouldThrowOut() + { + Assert.ThrowsException(() => DiscoverTestsIfThrowsExceptionShouldThrowOut(new InvalidOperationException("HelloWorld"))); + } - var collectSourceInformation = $"{val}"; - this.mockTestPlatform.Verify( - tp => tp.CreateDiscoveryRequest(It.IsAny(), It.Is(dc => dc.RunSettings.Contains(collectSourceInformation)), It.IsAny())); - } + [TestMethod] + public void DiscoverTestsIfThrowsExceptionShouldThrowOut() + { + Assert.ThrowsException(() => DiscoverTestsIfThrowsExceptionShouldThrowOut(new NotImplementedException("HelloWorld"))); + } - [TestMethod] - public void RunTestsShouldShouldUpdateFrameworkAndPlatformIfNotSpecifiedInDesignMode() - { - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - - " - }; - - this.commandLineOptions.IsDesignMode = true; - this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) - .Returns(Architecture.ARM); - this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) - .Returns(new FrameworkName(Constants.DotNetFramework46)); - TestRunCriteria actualTestRunCriteria = null; - var mockTestRunRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - actualTestRunCriteria = runCriteria; - }).Returns(mockTestRunRequest.Object); + [DataTestMethod] + [DataRow(true)] + [DataRow(false)] + public void DiscoverTestsShouldUpdateDesignModeAndCollectSourceInformation(bool designModeValue) + { + var runsettings = ".NETFramework,Version=v4.5"; + var discoveryPayload = CreateDiscoveryPayload(runsettings); + _commandLineOptions.IsDesignMode = designModeValue; - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig); + _testRequestManager.DiscoverTests(discoveryPayload, new Mock().Object, _protocolConfig); - this.mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny())); - this.mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny())); + var designmode = $"{designModeValue}"; + _mockTestPlatform.Verify( + tp => tp.CreateDiscoveryRequest(It.IsAny(), It.Is(dc => dc.RunSettings.Contains(designmode)), It.IsAny())); - Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(Constants.DotNetFramework46)); - Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(nameof(Architecture.ARM))); + var collectSourceInformation = $"{designModeValue}"; + _mockTestPlatform.Verify( + tp => tp.CreateDiscoveryRequest(It.IsAny(), It.Is(dc => dc.RunSettings.Contains(collectSourceInformation)), It.IsAny())); + } - } + [TestMethod] + public void DiscoverTestsShouldNotUpdateDesignModeIfUserHasSetDesignModeInRunSettings() + { + var runsettings = "False.NETFramework,Version=v4.5"; + var discoveryPayload = CreateDiscoveryPayload(runsettings); + _commandLineOptions.IsDesignMode = true; - [TestMethod] - public void RunTestsShouldNotUpdateFrameworkAndPlatformIfSpecifiedInDesignModeButInferred() - { - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - $@" - - - {Constants.DotNetFramework46} - {Architecture.ARM} - - " - }; - - this.commandLineOptions.IsDesignMode = true; - this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) - .Returns(Architecture.X86); - this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) - .Returns(new FrameworkName(Constants.DotNetFramework451)); - TestRunCriteria actualTestRunCriteria = null; - var mockTestRunRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - actualTestRunCriteria = runCriteria; - }).Returns(mockTestRunRequest.Object); + _testRequestManager.DiscoverTests(discoveryPayload, new Mock().Object, _protocolConfig); - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig); + var designmode = "False"; + _mockTestPlatform.Verify( + tp => tp.CreateDiscoveryRequest(It.IsAny(), It.Is(dc => dc.RunSettings.Contains(designmode)), It.IsAny())); + } - this.mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny()), Times.Once); - this.mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny()), Times.Once); + [DataTestMethod] + [DataRow(true)] + [DataRow(false)] + public void RunTestsShouldUpdateDesignModeIfRunnerIsInDesignMode(bool designModeValue) + { + var runsettings = + ".NETFramework,Version=v4.5"; + var payload = new TestRunRequestPayload + { + RunSettings = runsettings, + Sources = new List { "c:\\testproject.dll" } + }; + _commandLineOptions.IsDesignMode = designModeValue; - Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(Constants.DotNetFramework46)); - Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(nameof(Architecture.ARM))); - } + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, _protocolConfig); - [TestMethod] - [DataRow("x86")] - [DataRow("X86")] - [DataRow("ARM")] - [DataRow("aRm")] - public void RunTestsShouldNotUpdatePlatformIfSpecifiedInDesignModeButInferred(string targetPlatform) - { - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - $@" - - - {targetPlatform} - - " - }; - - this.commandLineOptions.IsDesignMode = true; - this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) - .Returns(Architecture.X86); - this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) - .Returns(new FrameworkName(Constants.DotNetFramework451)); - TestRunCriteria actualTestRunCriteria = null; - var mockTestRunRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - actualTestRunCriteria = runCriteria; - }).Returns(mockTestRunRequest.Object); + var designmode = $"{designModeValue}"; + _mockTestPlatform.Verify(tp => tp.CreateTestRunRequest(It.IsAny(), It.Is(rc => rc.TestRunSettings.Contains(designmode)), It.IsAny())); + } - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig); + [DataTestMethod] + [DataRow(true)] + [DataRow(false)] + public void DiscoverTestsShouldNotUpdateCollectSourceInformationIfUserHasSetItInRunSettings(bool val) + { + var runsettings = $"{val}"; + var discoveryPayload = CreateDiscoveryPayload(runsettings); - this.mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny()), Times.Once); - this.mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny()), Times.Once); + _testRequestManager.DiscoverTests(discoveryPayload, new Mock().Object, _protocolConfig); - Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(targetPlatform)); - } + var collectSourceInformation = $"{val}"; + _mockTestPlatform.Verify( + tp => tp.CreateDiscoveryRequest(It.IsAny(), It.Is(dc => dc.RunSettings.Contains(collectSourceInformation)), It.IsAny())); + } - [TestMethod] - public void RunTestsShouldUpdateFrameworkAndPlatformInCommandLineScenarios() - { - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - - " - }; - - this.commandLineOptions.IsDesignMode = false; - this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) - .Returns(Architecture.ARM); - this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) - .Returns(new FrameworkName(Constants.DotNetFramework46)); - TestRunCriteria actualTestRunCriteria = null; - var mockTestRunRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - actualTestRunCriteria = runCriteria; - }).Returns(mockTestRunRequest.Object); + [TestMethod] + public void RunTestsShouldShouldUpdateFrameworkAndPlatformIfNotSpecifiedInDesignMode() + { + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + + " + }; + + _commandLineOptions.IsDesignMode = true; + _mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) + .Returns(Architecture.ARM); + _mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) + .Returns(new FrameworkName(Constants.DotNetFramework46)); + TestRunCriteria actualTestRunCriteria = null; + var mockTestRunRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => actualTestRunCriteria = runCriteria).Returns(mockTestRunRequest.Object); + + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, _protocolConfig); + + _mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny())); + _mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny())); + + Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(Constants.DotNetFramework46)); + Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(nameof(Architecture.ARM))); - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig); + } - this.mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny())); - this.mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny())); + [TestMethod] + public void RunTestsShouldNotUpdateFrameworkAndPlatformIfSpecifiedInDesignModeButInferred() + { + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + $@" + + + {Constants.DotNetFramework46} + {Architecture.ARM} + + " + }; + + _commandLineOptions.IsDesignMode = true; + _mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) + .Returns(Architecture.X86); + _mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) + .Returns(new FrameworkName(Constants.DotNetFramework451)); + TestRunCriteria actualTestRunCriteria = null; + var mockTestRunRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => actualTestRunCriteria = runCriteria).Returns(mockTestRunRequest.Object); + + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, _protocolConfig); + + _mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny()), Times.Once); + _mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny()), Times.Once); + + Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(Constants.DotNetFramework46)); + Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(nameof(Architecture.ARM))); + } - Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(Constants.DotNetFramework46)); - Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(nameof(Architecture.ARM))); - } + [TestMethod] + [DataRow("x86")] + [DataRow("X86")] + [DataRow("ARM")] + [DataRow("aRm")] + public void RunTestsShouldNotUpdatePlatformIfSpecifiedInDesignModeButInferred(string targetPlatform) + { + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + $@" + + + {targetPlatform} + + " + }; + + _commandLineOptions.IsDesignMode = true; + _mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) + .Returns(Architecture.X86); + _mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) + .Returns(new FrameworkName(Constants.DotNetFramework451)); + TestRunCriteria actualTestRunCriteria = null; + var mockTestRunRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => actualTestRunCriteria = runCriteria).Returns(mockTestRunRequest.Object); + + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, _protocolConfig); + + _mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny()), Times.Once); + _mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny()), Times.Once); + + Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(targetPlatform)); + } - [TestMethod] - public void RunTestsShouldNotpdateFrameworkAndPlatformInCommandLineScenariosIfSpecifiedButInferred() - { - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - - " - }; - - this.commandLineOptions.IsDesignMode = false; - this.commandLineOptions.TargetArchitecture = Architecture.X86; - this.commandLineOptions.TargetFrameworkVersion = Framework.DefaultFramework; - this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) - .Returns(Architecture.ARM); - this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) - .Returns(new FrameworkName(Constants.DotNetFramework46)); - TestRunCriteria actualTestRunCriteria = null; - var mockTestRunRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - actualTestRunCriteria = runCriteria; - }).Returns(mockTestRunRequest.Object); + [TestMethod] + public void RunTestsShouldUpdateFrameworkAndPlatformInCommandLineScenarios() + { + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + + " + }; + + _commandLineOptions.IsDesignMode = false; + _mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) + .Returns(Architecture.ARM); + _mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) + .Returns(new FrameworkName(Constants.DotNetFramework46)); + TestRunCriteria actualTestRunCriteria = null; + var mockTestRunRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => actualTestRunCriteria = runCriteria).Returns(mockTestRunRequest.Object); + + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, _protocolConfig); + + _mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny())); + _mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny())); + + Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(Constants.DotNetFramework46)); + Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(nameof(Architecture.ARM))); + } - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig); + [TestMethod] + public void RunTestsShouldNotpdateFrameworkAndPlatformInCommandLineScenariosIfSpecifiedButInferred() + { + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + + " + }; + + _commandLineOptions.IsDesignMode = false; + _commandLineOptions.TargetArchitecture = Architecture.X86; + _commandLineOptions.TargetFrameworkVersion = Framework.DefaultFramework; + _mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) + .Returns(Architecture.ARM); + _mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) + .Returns(new FrameworkName(Constants.DotNetFramework46)); + TestRunCriteria actualTestRunCriteria = null; + var mockTestRunRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => actualTestRunCriteria = runCriteria).Returns(mockTestRunRequest.Object); + + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, _protocolConfig); + + _mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny()), Times.Once); + _mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny()), Times.Once); + + Assert.IsFalse(actualTestRunCriteria.TestRunSettings.Contains(Constants.DotNetFramework46)); + Assert.IsFalse(actualTestRunCriteria.TestRunSettings.Contains(nameof(Architecture.ARM))); + } - this.mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny()), Times.Once); - this.mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny()), Times.Once); + [TestMethod] + public void RunTestsWithTestCasesShouldUpdateFrameworkAndPlatformIfNotSpecifiedInDesignMode() + { + var actualSources = new List() { "1.dll", "2.dll" }; + var payload = new TestRunRequestPayload() + { + TestCases = new List() { + new TestCase(){Source = actualSources[0]}, + new TestCase() { Source = actualSources[0]}, + new TestCase() { Source = actualSources[1] } + }, + RunSettings = + @" + + + + " + }; + + List archSources = new(), fxSources = new(); + + _commandLineOptions.IsDesignMode = true; + _mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())).Callback(source => archSources.Add(source)) + .Returns(Architecture.ARM); + _mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())).Callback(source => fxSources.Add(source)) + .Returns(new FrameworkName(Constants.DotNetFramework46)); + TestRunCriteria actualTestRunCriteria = null; + var mockTestRunRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => actualTestRunCriteria = runCriteria).Returns(mockTestRunRequest.Object); + + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, _protocolConfig); + + _mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny())); + _mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny())); + + Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(Constants.DotNetFramework46)); + Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(nameof(Architecture.ARM))); + CollectionAssert.AreEqual(actualSources, archSources); + CollectionAssert.AreEqual(actualSources, fxSources); + } - Assert.IsFalse(actualTestRunCriteria.TestRunSettings.Contains(Constants.DotNetFramework46)); - Assert.IsFalse(actualTestRunCriteria.TestRunSettings.Contains(nameof(Architecture.ARM))); - } + [TestMethod] + public void RunTestShouldThrowExceptionIfRunSettingWithDcHasTestSettingsInIt() + { + var settingXml = @" + + C:\temp.testsettings + true + + + + + + + + + + "; - [TestMethod] - public void RunTestsWithTestCasesShouldUpdateFrameworkAndPlatformIfNotSpecifiedInDesignMode() + var payload = new TestRunRequestPayload() { - var actualSources = new List() { "1.dll", "2.dll" }; - var payload = new TestRunRequestPayload() - { - TestCases = new List() { - new TestCase(){Source = actualSources[0]}, - new TestCase() { Source = actualSources[0]}, - new TestCase() { Source = actualSources[1] } - }, - RunSettings = - @" - - - - " - }; - - List archSources = new List(), fxSources = new List(); - - this.commandLineOptions.IsDesignMode = true; - this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())).Callback(source => archSources.Add(source)) - .Returns(Architecture.ARM); - this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())).Callback(source => fxSources.Add(source)) - .Returns(new FrameworkName(Constants.DotNetFramework46)); - TestRunCriteria actualTestRunCriteria = null; - var mockTestRunRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - actualTestRunCriteria = runCriteria; - }).Returns(mockTestRunRequest.Object); - - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig); + Sources = new List() { "a.dll" }, + RunSettings = settingXml + }; - this.mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny())); - this.mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny())); + _commandLineOptions.EnableCodeCoverage = false; + bool exceptionThrown = false; - Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(Constants.DotNetFramework46)); - Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(nameof(Architecture.ARM))); - CollectionAssert.AreEqual(actualSources, archSources); - CollectionAssert.AreEqual(actualSources, fxSources); + try + { + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, _protocolConfig); + } + catch (SettingsException ex) + { + exceptionThrown = true; + Assert.IsTrue(ex.Message.Contains(@"C:\temp.testsettings"), ex.Message); } - [TestMethod] - public void RunTestShouldThrowExceptionIfRunSettingWithDCHasTestSettingsInIt() - { - var settingXml = @" - - C:\temp.testsettings - true - - - - - - - - - - "; - - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = settingXml - }; + Assert.IsTrue(exceptionThrown, "Initialize should throw exception"); + } - this.commandLineOptions.EnableCodeCoverage = false; - bool exceptionThrown = false; + [TestMethod] + public void RunTestShouldThrowExceptionIfRunSettingWithDcHasTestSettingsAndEnableCodeCoverageTrue() + { + var settingXml = @" + + C:\temp.testsettings + true + + + + + + + + + + "; - try - { - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig); - } - catch (SettingsException ex) - { - exceptionThrown = true; - Assert.IsTrue(ex.Message.Contains(@"C:\temp.testsettings"), ex.Message); - } + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = settingXml + }; - Assert.IsTrue(exceptionThrown, "Initialize should throw exception"); + _commandLineOptions.EnableCodeCoverage = true; + bool exceptionThrown = false; + + try + { + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, _protocolConfig); + } + catch (SettingsException ex) + { + exceptionThrown = true; + Assert.IsTrue(ex.Message.Contains(@"C:\temp.testsettings"), ex.Message); } - [TestMethod] - public void RunTestShouldThrowExceptionIfRunSettingWithDCHasTestSettingsAndEnableCodeCoverageTrue() - { - var settingXml = @" - - C:\temp.testsettings - true - - - - - - - - - - "; - - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = settingXml - }; + Assert.IsTrue(exceptionThrown, "Initialize should throw exception"); + } - this.commandLineOptions.EnableCodeCoverage = true; - bool exceptionThrown = false; + [TestMethod] + public void RunTestShouldNotThrowExceptionIfRunSettingHasCodeCoverageDcAndTestSettingsInItWithEnableCoverageTrue() + { + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = @" + + C:\temp.testsettings + true + + + + + + + + " + }; + + _commandLineOptions.EnableCodeCoverage = true; + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, _protocolConfig); + } - try - { - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig); - } - catch (SettingsException ex) - { - exceptionThrown = true; - Assert.IsTrue(ex.Message.Contains(@"C:\temp.testsettings"), ex.Message); - } + [TestMethod] + public void RunTestsShouldAddConsoleLoggerInRunSettingsInNonDesignMode() + { + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + + " + }; + + _commandLineOptions.IsDesignMode = false; + TestRunCriteria actualTestRunCriteria = null; + var mockTestRunRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => actualTestRunCriteria = runCriteria).Returns(mockTestRunRequest.Object); + + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, _protocolConfig); + + var loggerSettingsList = XmlRunSettingsUtilities.GetLoggerRunSettings(actualTestRunCriteria.TestRunSettings).LoggerSettingsList; + Assert.AreEqual(1, loggerSettingsList.Count); + Assert.AreEqual("Console", loggerSettingsList[0].FriendlyName); + Assert.IsNotNull(loggerSettingsList[0].AssemblyQualifiedName); + Assert.IsNotNull(loggerSettingsList[0].CodeBase); + } - Assert.IsTrue(exceptionThrown, "Initialize should throw exception"); - } + [TestMethod] + public void RunTestsShouldAddConsoleLoggerInRunSettingsIfDesignModeSetFalseInRunSettings() + { + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + False + + + + + + Value1 + + + + + " + }; + + _commandLineOptions.IsDesignMode = true; + TestRunCriteria actualTestRunCriteria = null; + var mockTestRunRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => actualTestRunCriteria = runCriteria).Returns(mockTestRunRequest.Object); + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, _protocolConfig); + + var loggerSettingsList = XmlRunSettingsUtilities.GetLoggerRunSettings(actualTestRunCriteria.TestRunSettings).LoggerSettingsList; + Assert.AreEqual(2, loggerSettingsList.Count); + Assert.IsNotNull(loggerSettingsList[0].Configuration); + Assert.AreEqual("blabla", loggerSettingsList[0].FriendlyName); + Assert.AreEqual("Console", loggerSettingsList[1].FriendlyName); + Assert.IsNotNull(loggerSettingsList[1].AssemblyQualifiedName); + Assert.IsNotNull(loggerSettingsList[1].CodeBase); + } - [TestMethod] - public void RunTestShouldNotThrowExceptionIfRunSettingHasCodeCoverageDCAndTestSettingsInItWithEnableCoverageTrue() - { - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = @" - - C:\temp.testsettings - true - - - - - - - - " - }; - - this.commandLineOptions.EnableCodeCoverage = true; - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig); - } + [TestMethod] + public void DiscoverTestsShouldAddConsoleLoggerInRunSettingsIfDesignModeSetFalseInRunSettings() + { + var payload = new DiscoveryRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + False + + + + + + Value1 + + + + + " + }; + _commandLineOptions.IsDesignMode = true; + DiscoveryCriteria actualDiscoveryCriteria = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform + .Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())) + .Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => actualDiscoveryCriteria = discoveryCriteria).Returns(mockDiscoveryRequest.Object); + + _testRequestManager.DiscoverTests(payload, + new Mock().Object, _protocolConfig); + + var loggerSettingsList = XmlRunSettingsUtilities.GetLoggerRunSettings(actualDiscoveryCriteria.RunSettings).LoggerSettingsList; + Assert.AreEqual(2, loggerSettingsList.Count); + Assert.IsNotNull(loggerSettingsList[0].Configuration); + Assert.AreEqual("blabla", loggerSettingsList[0].FriendlyName); + Assert.AreEqual("Console", loggerSettingsList[1].FriendlyName); + Assert.IsNotNull(loggerSettingsList[1].AssemblyQualifiedName); + Assert.IsNotNull(loggerSettingsList[1].CodeBase); + } - [TestMethod] - public void RunTestsShouldAddConsoleLoggerInRunSettingsInNonDesignMode() - { - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - - " - }; - - this.commandLineOptions.IsDesignMode = false; - TestRunCriteria actualTestRunCriteria = null; - var mockTestRunRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - actualTestRunCriteria = runCriteria; - }).Returns(mockTestRunRequest.Object); + [TestMethod] + public void RunTestsShouldNotAddConsoleLoggerInRunSettingsInDesignMode() + { + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + True + + " + }; + + _commandLineOptions.IsDesignMode = false; + TestRunCriteria actualTestRunCriteria = null; + var mockTestRunRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => actualTestRunCriteria = runCriteria).Returns(mockTestRunRequest.Object); + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, _protocolConfig); + + Assert.IsFalse(actualTestRunCriteria.TestRunSettings.Contains("LoggerRunSettings")); + } - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig); + [TestMethod] + public void DiscoverTestsShouldAddConsoleLoggerInRunSettingsInNonDesignMode() + { + var payload = new DiscoveryRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + + " + }; + _commandLineOptions.IsDesignMode = false; + DiscoveryCriteria actualDiscoveryCriteria = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform + .Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())) + .Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => actualDiscoveryCriteria = discoveryCriteria).Returns(mockDiscoveryRequest.Object); + + _testRequestManager.DiscoverTests(payload, + new Mock().Object, _protocolConfig); + + var loggerSettingsList = XmlRunSettingsUtilities.GetLoggerRunSettings(actualDiscoveryCriteria.RunSettings).LoggerSettingsList; + Assert.AreEqual(1, loggerSettingsList.Count); + Assert.AreEqual("Console", loggerSettingsList[0].FriendlyName); + Assert.IsNotNull(loggerSettingsList[0].AssemblyQualifiedName); + Assert.IsNotNull(loggerSettingsList[0].CodeBase); + } - var loggerSettingsList = XmlRunSettingsUtilities.GetLoggerRunSettings(actualTestRunCriteria.TestRunSettings).LoggerSettingsList; - Assert.AreEqual(1, loggerSettingsList.Count); - Assert.AreEqual("Console", loggerSettingsList[0].FriendlyName); - Assert.IsNotNull(loggerSettingsList[0].AssemblyQualifiedName); - Assert.IsNotNull(loggerSettingsList[0].CodeBase); - } + [TestMethod] + public void DiscoverTestsShouldNotAddConsoleLoggerInRunSettingsInDesignMode() + { + var payload = new DiscoveryRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + True + + " + }; + _commandLineOptions.IsDesignMode = false; + DiscoveryCriteria actualDiscoveryCriteria = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform + .Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())) + .Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => actualDiscoveryCriteria = discoveryCriteria).Returns(mockDiscoveryRequest.Object); + + _testRequestManager.DiscoverTests(payload, + new Mock().Object, _protocolConfig); + + Assert.IsFalse(actualDiscoveryCriteria.RunSettings.Contains("LoggerRunSettings")); + } - [TestMethod] - public void RunTestsShouldAddConsoleLoggerInRunSettingsIfDesignModeSetFalseInRunSettings() - { - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - False - - - - - - Value1 - - - - - " - }; - - this.commandLineOptions.IsDesignMode = true; - TestRunCriteria actualTestRunCriteria = null; - var mockTestRunRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - actualTestRunCriteria = runCriteria; - }).Returns(mockTestRunRequest.Object); - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig); - - var loggerSettingsList = XmlRunSettingsUtilities.GetLoggerRunSettings(actualTestRunCriteria.TestRunSettings).LoggerSettingsList; - Assert.AreEqual(2, loggerSettingsList.Count); - Assert.IsNotNull(loggerSettingsList[0].Configuration); - Assert.AreEqual("blabla", loggerSettingsList[0].FriendlyName); - Assert.AreEqual("Console", loggerSettingsList[1].FriendlyName); - Assert.IsNotNull(loggerSettingsList[1].AssemblyQualifiedName); - Assert.IsNotNull(loggerSettingsList[1].CodeBase); - } + [TestMethod] + public void RunTestsShouldOverrideOnlyAssemblyNameIfConsoleLoggerAlreadyPresentInNonDesignMode() + { + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + False + + + + + + Value1 + + + + + Value1 + + + + + " + }; + + _commandLineOptions.IsDesignMode = false; + TestRunCriteria actualTestRunCriteria = null; + var mockTestRunRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => actualTestRunCriteria = runCriteria).Returns(mockTestRunRequest.Object); + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, _protocolConfig); + + var loggerSettingsList = XmlRunSettingsUtilities.GetLoggerRunSettings(actualTestRunCriteria.TestRunSettings).LoggerSettingsList; + Assert.AreEqual(2, loggerSettingsList.Count); + Assert.IsNotNull(loggerSettingsList[0].Configuration); + Assert.AreEqual("blabla", loggerSettingsList[0].FriendlyName); + Assert.AreEqual("console", loggerSettingsList[1].FriendlyName); + Assert.AreEqual(new Uri("logger://tempconsoleUri").ToString(), loggerSettingsList[1].Uri.ToString()); + Assert.AreNotEqual("tempAssemblyName", loggerSettingsList[1].AssemblyQualifiedName); + Assert.AreNotEqual("tempCodeBase", loggerSettingsList[1].CodeBase); + Assert.IsTrue(loggerSettingsList[1].Configuration.InnerXml.Contains("Value1")); + Assert.IsNotNull(loggerSettingsList[1].AssemblyQualifiedName); + Assert.IsNotNull(loggerSettingsList[1].CodeBase); + } - [TestMethod] - public void DiscoverTestsShouldAddConsoleLoggerInRunSettingsIfDesignModeSetFalseInRunSettings() - { - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - False - - - - - - Value1 - - - - - " - }; - this.commandLineOptions.IsDesignMode = true; - DiscoveryCriteria actualDiscoveryCriteria = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform - .Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())) - .Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => - { - actualDiscoveryCriteria = discoveryCriteria; - }).Returns(mockDiscoveryRequest.Object); - - this.testRequestManager.DiscoverTests(payload, - new Mock().Object, this.protocolConfig); - - var loggerSettingsList = XmlRunSettingsUtilities.GetLoggerRunSettings(actualDiscoveryCriteria.RunSettings).LoggerSettingsList; - Assert.AreEqual(2, loggerSettingsList.Count); - Assert.IsNotNull(loggerSettingsList[0].Configuration); - Assert.AreEqual("blabla", loggerSettingsList[0].FriendlyName); - Assert.AreEqual("Console", loggerSettingsList[1].FriendlyName); - Assert.IsNotNull(loggerSettingsList[1].AssemblyQualifiedName); - Assert.IsNotNull(loggerSettingsList[1].CodeBase); - } + [TestMethod] + public void DiscoverTestsShouldOverrideOnlyAssemblyNameIfConsoleLoggerAlreadyPresentInNonDesignMode() + { + var payload = new DiscoveryRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + False + + + + + + Value1 + + + + + Value1 + + + + + " + }; + _commandLineOptions.IsDesignMode = false; + DiscoveryCriteria actualDiscoveryCriteria = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform + .Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())) + .Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => actualDiscoveryCriteria = discoveryCriteria).Returns(mockDiscoveryRequest.Object); + + _testRequestManager.DiscoverTests(payload, + new Mock().Object, _protocolConfig); + + var loggerSettingsList = XmlRunSettingsUtilities.GetLoggerRunSettings(actualDiscoveryCriteria.RunSettings).LoggerSettingsList; + Assert.AreEqual(2, loggerSettingsList.Count); + Assert.IsNotNull(loggerSettingsList[0].Configuration); + Assert.AreEqual("blabla", loggerSettingsList[0].FriendlyName); + Assert.AreEqual("consoleTemp", loggerSettingsList[1].FriendlyName); + Assert.AreEqual(new Uri("logger://Microsoft/TestPlatform/ConsoleLogger/v1").ToString(), loggerSettingsList[1].Uri.ToString()); + Assert.AreNotEqual("tempAssemblyName", loggerSettingsList[1].AssemblyQualifiedName); + Assert.AreNotEqual("tempAssemblyName", loggerSettingsList[1].CodeBase); + Assert.IsTrue(loggerSettingsList[1].Configuration.InnerXml.Contains("Value1")); + Assert.IsNotNull(loggerSettingsList[1].AssemblyQualifiedName); + Assert.IsNotNull(loggerSettingsList[1].CodeBase); + } - [TestMethod] - public void RunTestsShouldNotAddConsoleLoggerInRunSettingsInDesignMode() - { - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - True - - " - }; - - this.commandLineOptions.IsDesignMode = false; - TestRunCriteria actualTestRunCriteria = null; - var mockTestRunRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - actualTestRunCriteria = runCriteria; - }).Returns(mockTestRunRequest.Object); - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig); + [TestMethod] + public void RunTestsShouldOverrideOnlyAssemblyNameIfConsoleLoggerAlreadyPresentInDesignMode() + { + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + True + + + + + + Value1 + + + + + Value1 + + + + + " + }; + + _commandLineOptions.IsDesignMode = false; + TestRunCriteria actualTestRunCriteria = null; + var mockTestRunRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => actualTestRunCriteria = runCriteria).Returns(mockTestRunRequest.Object); + _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, _protocolConfig); + + var loggerSettingsList = XmlRunSettingsUtilities.GetLoggerRunSettings(actualTestRunCriteria.TestRunSettings).LoggerSettingsList; + Assert.AreEqual(2, loggerSettingsList.Count); + Assert.IsNotNull(loggerSettingsList[0].Configuration); + Assert.AreEqual("blabla", loggerSettingsList[0].FriendlyName); + Assert.AreEqual("console", loggerSettingsList[1].FriendlyName); + Assert.AreEqual(new Uri("logger://tempconsoleUri").ToString(), loggerSettingsList[1].Uri.ToString()); + Assert.AreNotEqual("tempAssemblyName", loggerSettingsList[1].AssemblyQualifiedName); + Assert.AreNotEqual("tempCodeBase", loggerSettingsList[1].CodeBase); + Assert.IsTrue(loggerSettingsList[1].Configuration.InnerXml.Contains("Value1")); + Assert.IsNotNull(loggerSettingsList[1].AssemblyQualifiedName); + Assert.IsNotNull(loggerSettingsList[1].CodeBase); + } - Assert.IsFalse(actualTestRunCriteria.TestRunSettings.Contains("LoggerRunSettings")); - } + [TestMethod] + public void DiscoverTestsShouldOverrideOnlyAssemblyNameIfConsoleLoggerAlreadyPresentInDesignMode() + { + var payload = new DiscoveryRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + True + + + + + + Value1 + + + + + Value1 + + + + + " + }; + _commandLineOptions.IsDesignMode = false; + DiscoveryCriteria actualDiscoveryCriteria = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform + .Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())) + .Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => actualDiscoveryCriteria = discoveryCriteria).Returns(mockDiscoveryRequest.Object); + + _testRequestManager.DiscoverTests(payload, + new Mock().Object, _protocolConfig); + + var loggerSettingsList = XmlRunSettingsUtilities.GetLoggerRunSettings(actualDiscoveryCriteria.RunSettings).LoggerSettingsList; + Assert.AreEqual(2, loggerSettingsList.Count); + Assert.IsNotNull(loggerSettingsList[0].Configuration); + Assert.AreEqual("blabla", loggerSettingsList[0].FriendlyName); + Assert.AreEqual("consoleTemp", loggerSettingsList[1].FriendlyName); + Assert.AreEqual(new Uri("logger://Microsoft/TestPlatform/ConsoleLogger/v1").ToString(), loggerSettingsList[1].Uri.ToString()); + Assert.AreNotEqual("tempAssemblyName", loggerSettingsList[1].AssemblyQualifiedName); + Assert.AreNotEqual("tempAssemblyName", loggerSettingsList[1].CodeBase); + Assert.IsTrue(loggerSettingsList[1].Configuration.InnerXml.Contains("Value1")); + Assert.IsNotNull(loggerSettingsList[1].AssemblyQualifiedName); + Assert.IsNotNull(loggerSettingsList[1].CodeBase); + } - [TestMethod] - public void DiscoverTestsShouldAddConsoleLoggerInRunSettingsInNonDesignMode() - { - var payload = new DiscoveryRequestPayload() + [TestMethod] + public void ProcessTestRunAttachmentsShouldSucceedWithTelemetryEnabled() + { + var mockEventsHandler = new Mock(); + _mockAttachmentsProcessingManager + .Setup(m => m.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) + .Returns((string runSettingsXml, IRequestData r, ICollection a, ICollection b, ITestRunAttachmentsProcessingEventsHandler h, CancellationToken token) => Task.Run(() => { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - - " - }; - this.commandLineOptions.IsDesignMode = false; - DiscoveryCriteria actualDiscoveryCriteria = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform - .Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())) - .Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => - { - actualDiscoveryCriteria = discoveryCriteria; - }).Returns(mockDiscoveryRequest.Object); - - this.testRequestManager.DiscoverTests(payload, - new Mock().Object, this.protocolConfig); - - var loggerSettingsList = XmlRunSettingsUtilities.GetLoggerRunSettings(actualDiscoveryCriteria.RunSettings).LoggerSettingsList; - Assert.AreEqual(1, loggerSettingsList.Count); - Assert.AreEqual("Console", loggerSettingsList[0].FriendlyName); - Assert.IsNotNull(loggerSettingsList[0].AssemblyQualifiedName); - Assert.IsNotNull(loggerSettingsList[0].CodeBase); - } + r.MetricsCollection.Add(TelemetryDataConstants.NumberOfAttachmentsSentForProcessing, 5); + r.MetricsCollection.Add(TelemetryDataConstants.NumberOfAttachmentsAfterProcessing, 1); + })); - [TestMethod] - public void DiscoverTestsShouldNotAddConsoleLoggerInRunSettingsInDesignMode() + var payload = new TestRunAttachmentsProcessingPayload() { - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - True - - " - }; - this.commandLineOptions.IsDesignMode = false; - DiscoveryCriteria actualDiscoveryCriteria = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform - .Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())) - .Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => - { - actualDiscoveryCriteria = discoveryCriteria; - }).Returns(mockDiscoveryRequest.Object); - - this.testRequestManager.DiscoverTests(payload, - new Mock().Object, this.protocolConfig); - - Assert.IsFalse(actualDiscoveryCriteria.RunSettings.Contains("LoggerRunSettings")); - } + Attachments = new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") }, + InvokedDataCollectors = new List(), + RunSettings = Constants.EmptyRunSettings, + CollectMetrics = true + }; - [TestMethod] - public void RunTestsShouldOverrideOnlyAssemblyNameIfConsoleLoggerAlreadyPresentInNonDesignMode() - { - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - False - - - - - - Value1 - - - - - Value1 - - - - - " - }; - - this.commandLineOptions.IsDesignMode = false; - TestRunCriteria actualTestRunCriteria = null; - var mockTestRunRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - actualTestRunCriteria = runCriteria; - }).Returns(mockTestRunRequest.Object); - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig); - - var loggerSettingsList = XmlRunSettingsUtilities.GetLoggerRunSettings(actualTestRunCriteria.TestRunSettings).LoggerSettingsList; - Assert.AreEqual(2, loggerSettingsList.Count); - Assert.IsNotNull(loggerSettingsList[0].Configuration); - Assert.AreEqual("blabla", loggerSettingsList[0].FriendlyName); - Assert.AreEqual("console", loggerSettingsList[1].FriendlyName); - Assert.AreEqual(new Uri("logger://tempconsoleUri").ToString(), loggerSettingsList[1].Uri.ToString()); - Assert.AreNotEqual("tempAssemblyName", loggerSettingsList[1].AssemblyQualifiedName); - Assert.AreNotEqual("tempCodeBase", loggerSettingsList[1].CodeBase); - Assert.IsTrue(loggerSettingsList[1].Configuration.InnerXml.Contains("Value1")); - Assert.IsNotNull(loggerSettingsList[1].AssemblyQualifiedName); - Assert.IsNotNull(loggerSettingsList[1].CodeBase); - } + _testRequestManager.ProcessTestRunAttachments(payload, mockEventsHandler.Object, _protocolConfig); - [TestMethod] - public void DiscoverTestsShouldOverrideOnlyAssemblyNameIfConsoleLoggerAlreadyPresentInNonDesignMode() - { - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - False - - - - - - Value1 - - - - - Value1 - - - - - " - }; - this.commandLineOptions.IsDesignMode = false; - DiscoveryCriteria actualDiscoveryCriteria = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform - .Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())) - .Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => - { - actualDiscoveryCriteria = discoveryCriteria; - }).Returns(mockDiscoveryRequest.Object); - - this.testRequestManager.DiscoverTests(payload, - new Mock().Object, this.protocolConfig); - - var loggerSettingsList = XmlRunSettingsUtilities.GetLoggerRunSettings(actualDiscoveryCriteria.RunSettings).LoggerSettingsList; - Assert.AreEqual(2, loggerSettingsList.Count); - Assert.IsNotNull(loggerSettingsList[0].Configuration); - Assert.AreEqual("blabla", loggerSettingsList[0].FriendlyName); - Assert.AreEqual("consoleTemp", loggerSettingsList[1].FriendlyName); - Assert.AreEqual(new Uri("logger://Microsoft/TestPlatform/ConsoleLogger/v1").ToString(), loggerSettingsList[1].Uri.ToString()); - Assert.AreNotEqual("tempAssemblyName", loggerSettingsList[1].AssemblyQualifiedName); - Assert.AreNotEqual("tempAssemblyName", loggerSettingsList[1].CodeBase); - Assert.IsTrue(loggerSettingsList[1].Configuration.InnerXml.Contains("Value1")); - Assert.IsNotNull(loggerSettingsList[1].AssemblyQualifiedName); - Assert.IsNotNull(loggerSettingsList[1].CodeBase); - } + _mockAttachmentsProcessingManager.Verify(m => m.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, It.Is(r => r.IsTelemetryOptedIn), payload.Attachments, payload.InvokedDataCollectors, mockEventsHandler.Object, It.IsAny())); + _mockTestPlatformEventSource.Verify(es => es.TestRunAttachmentsProcessingRequestStart()); + _mockTestPlatformEventSource.Verify(es => es.TestRunAttachmentsProcessingRequestStop()); - [TestMethod] - public void RunTestsShouldOverrideOnlyAssemblyNameIfConsoleLoggerAlreadyPresentInDesignMode() - { - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - True - - - - - - Value1 - - - - - Value1 - - - - - " - }; - - this.commandLineOptions.IsDesignMode = false; - TestRunCriteria actualTestRunCriteria = null; - var mockTestRunRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - actualTestRunCriteria = runCriteria; - }).Returns(mockTestRunRequest.Object); - this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig); - - var loggerSettingsList = XmlRunSettingsUtilities.GetLoggerRunSettings(actualTestRunCriteria.TestRunSettings).LoggerSettingsList; - Assert.AreEqual(2, loggerSettingsList.Count); - Assert.IsNotNull(loggerSettingsList[0].Configuration); - Assert.AreEqual("blabla", loggerSettingsList[0].FriendlyName); - Assert.AreEqual("console", loggerSettingsList[1].FriendlyName); - Assert.AreEqual(new Uri("logger://tempconsoleUri").ToString(), loggerSettingsList[1].Uri.ToString()); - Assert.AreNotEqual("tempAssemblyName", loggerSettingsList[1].AssemblyQualifiedName); - Assert.AreNotEqual("tempCodeBase", loggerSettingsList[1].CodeBase); - Assert.IsTrue(loggerSettingsList[1].Configuration.InnerXml.Contains("Value1")); - Assert.IsNotNull(loggerSettingsList[1].AssemblyQualifiedName); - Assert.IsNotNull(loggerSettingsList[1].CodeBase); - } + _mockMetricsPublisher.Verify(p => p.PublishMetrics(TelemetryDataConstants.TestAttachmentsProcessingCompleteEvent, + It.Is>(m => m.Count == 2 && + m.ContainsKey(TelemetryDataConstants.NumberOfAttachmentsSentForProcessing) && (int)m[TelemetryDataConstants.NumberOfAttachmentsSentForProcessing] == 5 && + m.ContainsKey(TelemetryDataConstants.NumberOfAttachmentsAfterProcessing) && (int)m[TelemetryDataConstants.NumberOfAttachmentsAfterProcessing] == 1))); + } - [TestMethod] - public void DiscoverTestsShouldOverrideOnlyAssemblyNameIfConsoleLoggerAlreadyPresentInDesignMode() - { - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - True - - - - - - Value1 - - - - - Value1 - - - - - " - }; - this.commandLineOptions.IsDesignMode = false; - DiscoveryCriteria actualDiscoveryCriteria = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform - .Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())) - .Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => - { - actualDiscoveryCriteria = discoveryCriteria; - }).Returns(mockDiscoveryRequest.Object); - - this.testRequestManager.DiscoverTests(payload, - new Mock().Object, this.protocolConfig); - - var loggerSettingsList = XmlRunSettingsUtilities.GetLoggerRunSettings(actualDiscoveryCriteria.RunSettings).LoggerSettingsList; - Assert.AreEqual(2, loggerSettingsList.Count); - Assert.IsNotNull(loggerSettingsList[0].Configuration); - Assert.AreEqual("blabla", loggerSettingsList[0].FriendlyName); - Assert.AreEqual("consoleTemp", loggerSettingsList[1].FriendlyName); - Assert.AreEqual(new Uri("logger://Microsoft/TestPlatform/ConsoleLogger/v1").ToString(), loggerSettingsList[1].Uri.ToString()); - Assert.AreNotEqual("tempAssemblyName", loggerSettingsList[1].AssemblyQualifiedName); - Assert.AreNotEqual("tempAssemblyName", loggerSettingsList[1].CodeBase); - Assert.IsTrue(loggerSettingsList[1].Configuration.InnerXml.Contains("Value1")); - Assert.IsNotNull(loggerSettingsList[1].AssemblyQualifiedName); - Assert.IsNotNull(loggerSettingsList[1].CodeBase); - } + [TestMethod] + public void ProcessTestRunAttachmentsShouldSucceedWithTelemetryDisabled() + { + var mockEventsHandler = new Mock(); + _mockAttachmentsProcessingManager + .Setup(m => m.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) + .Returns(Task.FromResult(true)); - [TestMethod] - public void ProcessTestRunAttachmentsShouldSucceedWithTelemetryEnabled() + var payload = new TestRunAttachmentsProcessingPayload() { - var mockEventsHandler = new Mock(); - mockAttachmentsProcessingManager - .Setup(m => m.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) - .Returns((string runSettingsXml, IRequestData r, ICollection a, ICollection b, ITestRunAttachmentsProcessingEventsHandler h, CancellationToken token) => Task.Run(() => - { - r.MetricsCollection.Add(TelemetryDataConstants.NumberOfAttachmentsSentForProcessing, 5); - r.MetricsCollection.Add(TelemetryDataConstants.NumberOfAttachmentsAfterProcessing, 1); - })); + Attachments = new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") }, + InvokedDataCollectors = new List(), + RunSettings = Constants.EmptyRunSettings, + CollectMetrics = false + }; - var payload = new TestRunAttachmentsProcessingPayload() - { - Attachments = new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") }, - InvokedDataCollectors = new List(), - RunSettings = Constants.EmptyRunSettings, - CollectMetrics = true - }; - - testRequestManager.ProcessTestRunAttachments(payload, mockEventsHandler.Object, this.protocolConfig); - - mockAttachmentsProcessingManager.Verify(m => m.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, It.Is(r => r.IsTelemetryOptedIn), payload.Attachments, payload.InvokedDataCollectors, mockEventsHandler.Object, It.IsAny())); - mockTestPlatformEventSource.Verify(es => es.TestRunAttachmentsProcessingRequestStart()); - mockTestPlatformEventSource.Verify(es => es.TestRunAttachmentsProcessingRequestStop()); - - mockMetricsPublisher.Verify(p => p.PublishMetrics(TelemetryDataConstants.TestAttachmentsProcessingCompleteEvent, - It.Is>(m => m.Count == 2 && - m.ContainsKey(TelemetryDataConstants.NumberOfAttachmentsSentForProcessing) && (int)m[TelemetryDataConstants.NumberOfAttachmentsSentForProcessing] == 5 && - m.ContainsKey(TelemetryDataConstants.NumberOfAttachmentsAfterProcessing) && (int)m[TelemetryDataConstants.NumberOfAttachmentsAfterProcessing] == 1))); - } + _testRequestManager.ProcessTestRunAttachments(payload, mockEventsHandler.Object, _protocolConfig); - [TestMethod] - public void ProcessTestRunAttachmentsShouldSucceedWithTelemetryDisabled() - { - var mockEventsHandler = new Mock(); - mockAttachmentsProcessingManager - .Setup(m => m.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) - .Returns(Task.FromResult(true)); + _mockAttachmentsProcessingManager.Verify(m => m.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, It.Is(r => !r.IsTelemetryOptedIn), payload.Attachments, payload.InvokedDataCollectors, mockEventsHandler.Object, It.IsAny())); + _mockTestPlatformEventSource.Verify(es => es.TestRunAttachmentsProcessingRequestStart()); + _mockTestPlatformEventSource.Verify(es => es.TestRunAttachmentsProcessingRequestStop()); + } - var payload = new TestRunAttachmentsProcessingPayload() + [TestMethod] + public async Task CancelTestRunAttachmentsProcessingShouldSucceedIfRequestInProgress() + { + var mockEventsHandler = new Mock(); + _mockAttachmentsProcessingManager + .Setup(m => m.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) + .Returns((string runSettingsXml, IRequestData r, ICollection a, ICollection b, ITestRunAttachmentsProcessingEventsHandler h, CancellationToken token) => Task.Run(() => { - Attachments = new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") }, - InvokedDataCollectors = new List(), - RunSettings = Constants.EmptyRunSettings, - CollectMetrics = false - }; - - testRequestManager.ProcessTestRunAttachments(payload, mockEventsHandler.Object, this.protocolConfig); + int i = 0; + while (!token.IsCancellationRequested) + { + i++; + Console.WriteLine($"Iteration {i}"); + Task.Delay(5).Wait(); + } - mockAttachmentsProcessingManager.Verify(m => m.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, It.Is(r => !r.IsTelemetryOptedIn), payload.Attachments, payload.InvokedDataCollectors, mockEventsHandler.Object, It.IsAny())); - mockTestPlatformEventSource.Verify(es => es.TestRunAttachmentsProcessingRequestStart()); - mockTestPlatformEventSource.Verify(es => es.TestRunAttachmentsProcessingRequestStop()); - } + r.MetricsCollection.Add(TelemetryDataConstants.AttachmentsProcessingState, "Canceled"); + })); - [TestMethod] - public async Task CancelTestRunAttachmentsProcessingShouldSucceedIfRequestInProgress() - { - var mockEventsHandler = new Mock(); - mockAttachmentsProcessingManager - .Setup(m => m.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())) - .Returns((string runSettingsXml, IRequestData r, ICollection a, ICollection b, ITestRunAttachmentsProcessingEventsHandler h, CancellationToken token) => Task.Run(() => - { - int i = 0; - while (!token.IsCancellationRequested) - { - i++; - Console.WriteLine($"Iteration {i}"); - Task.Delay(5).Wait(); - } - - r.MetricsCollection.Add(TelemetryDataConstants.AttachmentsProcessingState, "Canceled"); - })); - - var payload = new TestRunAttachmentsProcessingPayload() - { - Attachments = new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") }, - InvokedDataCollectors = new List(), - RunSettings = Constants.EmptyRunSettings, - CollectMetrics = true - }; + var payload = new TestRunAttachmentsProcessingPayload() + { + Attachments = new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") }, + InvokedDataCollectors = new List(), + RunSettings = Constants.EmptyRunSettings, + CollectMetrics = true + }; - Task task = Task.Run(() => testRequestManager.ProcessTestRunAttachments(payload, mockEventsHandler.Object, this.protocolConfig)); - await Task.Delay(50); - testRequestManager.CancelTestRunAttachmentsProcessing(); + Task task = Task.Run(() => _testRequestManager.ProcessTestRunAttachments(payload, mockEventsHandler.Object, _protocolConfig)); + await Task.Delay(50); + _testRequestManager.CancelTestRunAttachmentsProcessing(); - await task; + await task; - mockAttachmentsProcessingManager.Verify(m => m.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, It.IsAny(), payload.Attachments, payload.InvokedDataCollectors, mockEventsHandler.Object, It.IsAny())); - mockTestPlatformEventSource.Verify(es => es.TestRunAttachmentsProcessingRequestStart()); - mockTestPlatformEventSource.Verify(es => es.TestRunAttachmentsProcessingRequestStop()); + _mockAttachmentsProcessingManager.Verify(m => m.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, It.IsAny(), payload.Attachments, payload.InvokedDataCollectors, mockEventsHandler.Object, It.IsAny())); + _mockTestPlatformEventSource.Verify(es => es.TestRunAttachmentsProcessingRequestStart()); + _mockTestPlatformEventSource.Verify(es => es.TestRunAttachmentsProcessingRequestStop()); - mockMetricsPublisher.Verify(p => p.PublishMetrics(TelemetryDataConstants.TestAttachmentsProcessingCompleteEvent, - It.Is>(m => m.Count == 1 && m.ContainsKey(TelemetryDataConstants.AttachmentsProcessingState) && (string)m[TelemetryDataConstants.AttachmentsProcessingState] == "Canceled"))); - } + _mockMetricsPublisher.Verify(p => p.PublishMetrics(TelemetryDataConstants.TestAttachmentsProcessingCompleteEvent, + It.Is>(m => m.Count == 1 && m.ContainsKey(TelemetryDataConstants.AttachmentsProcessingState) && (string)m[TelemetryDataConstants.AttachmentsProcessingState] == "Canceled"))); + } - [TestMethod] - public void CancelTestRunAttachmentsProcessingShouldSucceedIfNoRequest() - { - testRequestManager.CancelTestRunAttachmentsProcessing(); - } + [TestMethod] + public void CancelTestRunAttachmentsProcessingShouldSucceedIfNoRequest() + { + _testRequestManager.CancelTestRunAttachmentsProcessing(); + } - [TestMethod] - public void StartTestSessionShouldPassCorrectTelemetryOptedInOptionToTestPlatform() - { - this.mockTestPlatform.Setup( + [TestMethod] + public void StartTestSessionShouldPassCorrectTelemetryOptedInOptionToTestPlatform() + { + _mockTestPlatform.Setup( tp => tp.StartTestSession( It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(true) - .Callback( - (IRequestData rd, StartTestSessionCriteria _, ITestSessionEventsHandler __) => - { - Assert.IsTrue(rd.IsTelemetryOptedIn); - }); + .Returns(true) + .Callback( + (IRequestData rd, StartTestSessionCriteria _, ITestSessionEventsHandler _) => Assert.IsTrue(rd.IsTelemetryOptedIn)); - Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); + Environment.SetEnvironmentVariable("VSTEST_TELEMETRY_OPTEDIN", "1"); - this.testRequestManager.StartTestSession( - new StartTestSessionPayload() + _testRequestManager.StartTestSession( + new StartTestSessionPayload() + { + TestPlatformOptions = new TestPlatformOptions() { - TestPlatformOptions = new TestPlatformOptions() - { - CollectMetrics = true - } - }, - new Mock().Object, - new Mock().Object, - this.protocolConfig); - } + CollectMetrics = true + } + }, + new Mock().Object, + new Mock().Object, + _protocolConfig); + } - [TestMethod] - public void StartTestSessionShouldUpdateSettings() - { - var payload = new StartTestSessionPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - - " - }; - this.commandLineOptions.IsDesignMode = true; - - this.mockAssemblyMetadataProvider.Setup( + [TestMethod] + public void StartTestSessionShouldUpdateSettings() + { + var payload = new StartTestSessionPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + + " + }; + _commandLineOptions.IsDesignMode = true; + + _mockAssemblyMetadataProvider.Setup( a => a.GetArchitecture(It.IsAny())) - .Returns(Architecture.ARM); - this.mockAssemblyMetadataProvider.Setup( + .Returns(Architecture.ARM); + _mockAssemblyMetadataProvider.Setup( a => a.GetFrameWork(It.IsAny())) - .Returns(new FrameworkName(Constants.DotNetFramework46)); + .Returns(new FrameworkName(Constants.DotNetFramework46)); - this.mockTestPlatform.Setup( + _mockTestPlatform.Setup( tp => tp.StartTestSession( It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(true) - .Callback( - (IRequestData _, StartTestSessionCriteria criteria, ITestSessionEventsHandler __) => - { - Assert.IsTrue(criteria.RunSettings.Contains(Constants.DotNetFramework46)); - Assert.IsTrue(criteria.RunSettings.Contains(nameof(Architecture.ARM))); - }); - - this.testRequestManager.StartTestSession( + .Returns(true) + .Callback( + (IRequestData _, StartTestSessionCriteria criteria, ITestSessionEventsHandler _) => + { + Assert.IsTrue(criteria.RunSettings.Contains(Constants.DotNetFramework46)); + Assert.IsTrue(criteria.RunSettings.Contains(nameof(Architecture.ARM))); + }); + + _testRequestManager.StartTestSession( + payload, + new Mock().Object, + new Mock().Object, + _protocolConfig); + + _mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny())); + _mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny())); + } + + [TestMethod] + public void StartTestSessionShouldThrowSettingsExceptionWhenFindingIncompatibleDataCollectorsInTestSettings() + { + var settingXml = @" + + C:\temp.testsettings + true + + + + + + + + + + "; + + var payload = new StartTestSessionPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = settingXml + }; + + _commandLineOptions.EnableCodeCoverage = false; + bool exceptionThrown = false; + + try + { + _testRequestManager.StartTestSession( payload, new Mock().Object, new Mock().Object, - this.protocolConfig); - - this.mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny())); - this.mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny())); + _protocolConfig); } - - [TestMethod] - public void StartTestSessionShouldThrowSettingsExceptionWhenFindingIncompatibleDataCollectorsInTestSettings() - { - var settingXml = @" - - C:\temp.testsettings - true - - - - - - - - - - "; - - var payload = new StartTestSessionPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = settingXml - }; - - this.commandLineOptions.EnableCodeCoverage = false; - bool exceptionThrown = false; - - try - { - this.testRequestManager.StartTestSession( - payload, - new Mock().Object, - new Mock().Object, - this.protocolConfig); - } - catch (SettingsException ex) - { - exceptionThrown = true; - Assert.IsTrue(ex.Message.Contains(@"C:\temp.testsettings"), ex.Message); - } - - Assert.IsTrue(exceptionThrown, "Initialize should throw exception"); + catch (SettingsException ex) + { + exceptionThrown = true; + Assert.IsTrue(ex.Message.Contains(@"C:\temp.testsettings"), ex.Message); } - [TestMethod] - public void StartTestSessionShouldBeSuccessful() - { - this.mockTestPlatform.Setup( + Assert.IsTrue(exceptionThrown, "Initialize should throw exception"); + } + + [TestMethod] + public void StartTestSessionShouldBeSuccessful() + { + _mockTestPlatform.Setup( tp => tp.StartTestSession( It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(true); + .Returns(true); - this.testRequestManager.StartTestSession( - new StartTestSessionPayload() + _testRequestManager.StartTestSession( + new StartTestSessionPayload() + { + TestPlatformOptions = new TestPlatformOptions() { - TestPlatformOptions = new TestPlatformOptions() - { - CollectMetrics = true - } - }, - new Mock().Object, - new Mock().Object, - this.protocolConfig); - - this.mockTestPlatformEventSource.Verify( - tpes => tpes.StartTestSessionStart(), - Times.Once()); - this.mockTestPlatformEventSource.Verify( - tpes => tpes.StartTestSessionStop(), - Times.Once()); - } + CollectMetrics = true + } + }, + new Mock().Object, + new Mock().Object, + _protocolConfig); + + _mockTestPlatformEventSource.Verify( + tpes => tpes.StartTestSessionStart(), + Times.Once()); + _mockTestPlatformEventSource.Verify( + tpes => tpes.StartTestSessionStop(), + Times.Once()); + } - private static DiscoveryRequestPayload CreateDiscoveryPayload(string runsettings) + private static DiscoveryRequestPayload CreateDiscoveryPayload(string runsettings) + { + var discoveryPayload = new DiscoveryRequestPayload { - var discoveryPayload = new DiscoveryRequestPayload - { - RunSettings = runsettings, - Sources = new[] { "c:\\testproject.dll" } - }; - return discoveryPayload; - } + RunSettings = runsettings, + Sources = new[] { "c:\\testproject.dll" } + }; + return discoveryPayload; + } - private void RunTestsIfThrowsExceptionShouldThrowOut(Exception exception) + private void RunTestsIfThrowsExceptionShouldThrowOut(Exception exception) + { + var payload = new TestRunRequestPayload() { - var payload = new TestRunRequestPayload() + Sources = new List() { "a", "b" }, + RunSettings = DefaultRunsettings + }; + + var createRunRequestCalled = 0; + TestRunCriteria observedCriteria = null; + var mockRunRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => { - Sources = new List() { "a", "b" }, - RunSettings = DefaultRunsettings - }; - - var createRunRequestCalled = 0; - TestRunCriteria observedCriteria = null; - var mockRunRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - createRunRequestCalled++; - observedCriteria = runCriteria; - }).Returns(mockRunRequest.Object); + createRunRequestCalled++; + observedCriteria = runCriteria; + }).Returns(mockRunRequest.Object); - mockRunRequest.Setup(mr => mr.ExecuteAsync()).Throws(exception); + mockRunRequest.Setup(mr => mr.ExecuteAsync()).Throws(exception); - var mockRunEventsRegistrar = new Mock(); - var mockCustomlauncher = new Mock(); + var mockRunEventsRegistrar = new Mock(); + var mockCustomlauncher = new Mock(); - this.testRequestManager.RunTests(payload, mockCustomlauncher.Object, mockRunEventsRegistrar.Object, this.protocolConfig); - } + _testRequestManager.RunTests(payload, mockCustomlauncher.Object, mockRunEventsRegistrar.Object, _protocolConfig); + } - private void DiscoverTestsIfThrowsExceptionShouldThrowOut(Exception exception) + private void DiscoverTestsIfThrowsExceptionShouldThrowOut(Exception exception) + { + var payload = new DiscoveryRequestPayload() { - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a.dll", "b.dll" }, - RunSettings = DefaultRunsettings - }; - - DiscoveryCriteria observedCriteria = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => - { - observedCriteria = discoveryCriteria; - }).Returns(mockDiscoveryRequest.Object); + Sources = new List() { "a.dll", "b.dll" }, + RunSettings = DefaultRunsettings + }; - mockDiscoveryRequest.Setup(mr => mr.DiscoverAsync()).Throws(exception); + DiscoveryCriteria observedCriteria = null; + var mockDiscoveryRequest = new Mock(); + _mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => observedCriteria = discoveryCriteria).Returns(mockDiscoveryRequest.Object); - var mockDiscoveryEventsRegistrar = new Mock(); - var mockCustomlauncher = new Mock(); + mockDiscoveryRequest.Setup(mr => mr.DiscoverAsync()).Throws(exception); - this.testRequestManager.DiscoverTests(payload, mockDiscoveryEventsRegistrar.Object, this.protocolConfig); - } + var mockDiscoveryEventsRegistrar = new Mock(); + var mockCustomlauncher = new Mock(); + + _testRequestManager.DiscoverTests(payload, mockDiscoveryEventsRegistrar.Object, _protocolConfig); } } \ No newline at end of file